Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id yN5sBY5C+14/PgEA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 15:47:58 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id sKQvA45C+17gsgAA0J78UA (envelope-from ); Tue, 30 Jun 2020 15:47:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3FC54A1306; Tue, 30 Jun 2020 15:47:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731182AbgF3Nrv (ORCPT + 1 other); Tue, 30 Jun 2020 09:47:51 -0400 Received: from mxout03.lancloud.ru ([89.108.73.187]:47062 "EHLO mxout03.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726876AbgF3Nru (ORCPT ); Tue, 30 Jun 2020 09:47:50 -0400 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout03.lancloud.ru 95A7E2095C12 Received: from LanCloud Received: from LanCloud Received: by spb1wst017.omp.ru (Postfix, from userid 10000) id 22D52BA1D4B; Tue, 30 Jun 2020 16:47:47 +0300 (MSK) From: Denis Grigorev To: CC: , Denis Grigorev Subject: [RESEND PATCH BlueZ v3] gobex: Fix segfault caused by interrupted transfer Date: Tue, 30 Jun 2020 16:47:31 +0300 Message-ID: <20200630134731.18541-1-d.grigorev@omprussia.ru> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [81.3.167.34] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX09.lancloud.ru (fd00:f066::59) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3FC54A1306 X-Rspamd-UID: 0c0ef6 When a obex transfer is interrupted by a peer in the middle, the response G_OBEX_RSP_FORBIDDEN comes and the transfer is freed in transfer_complete. However gobex is still ref'ed and gobex->io continues to be writable, so write_data() and then g_obex_abort() are called. When the abort response comes, struct obc_transfer is already freed, which leads to the crash. Backtrace : __GI___pthread_mutex_lock (mutex=0x65732f74) at pthread_mutex_lock.c:67 0xecc6eeda in dbus_connection_get_object_path_data () from libdbus-1.so.3 0x000457d4 in g_dbus_emit_property_changed_full () at gdbus/object.c:1794 0x00045868 in g_dbus_emit_property_changed () at gdbus/object.c:1832 0x000367f0 in transfer_set_status () at obexd/client/transfer.c:211 0x0003681e in transfer_set_status () at obexd/client/transfer.c:206 xfer_complete () at obexd/client/transfer.c:672 0x00022df6 in transfer_complete () at gobex/gobex-transfer.c:103 0x00022f44 in transfer_abort_response () at gobex/gobex-transfer.c:124 0x00020a0e in handle_response () at gobex/gobex.c:1128 0x00020dde in incoming_data () at gobex/gobex.c:1373 This commit introduces g_obex_drop_tx_queue(), which will be called if a transfer error detected. After the tx queue is dropped, obex shuts down gracefully. --- Changes in v2 and v3: - Edit commit message formatting. gobex/gobex-transfer.c | 5 +++++ gobex/gobex.c | 10 ++++++++++ gobex/gobex.h | 1 + 3 files changed, 16 insertions(+) diff --git a/gobex/gobex-transfer.c b/gobex/gobex-transfer.c index bc9930679..e96e61fbc 100644 --- a/gobex/gobex-transfer.c +++ b/gobex/gobex-transfer.c @@ -100,6 +100,11 @@ static void transfer_complete(struct transfer *transfer, GError *err) g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", id); + if (err) { + /* No further tx must be performed */ + g_obex_drop_tx_queue(transfer->obex); + } + transfer->complete_func(transfer->obex, err, transfer->user_data); /* Check if the complete_func removed the transfer */ if (find_transfer(id) == NULL) diff --git a/gobex/gobex.c b/gobex/gobex.c index 77f1aaafd..d68a85eb6 100644 --- a/gobex/gobex.c +++ b/gobex/gobex.c @@ -521,6 +521,16 @@ static void enable_tx(GObex *obex) obex->write_source = g_io_add_watch(obex->io, cond, write_data, obex); } +void g_obex_drop_tx_queue(GObex *obex) +{ + struct pending_pkt *p; + + g_obex_debug(G_OBEX_DEBUG_COMMAND, ""); + + while ((p = g_queue_pop_head(obex->tx_queue))) + pending_pkt_free(p); +} + static gboolean g_obex_send_internal(GObex *obex, struct pending_pkt *p, GError **err) { diff --git a/gobex/gobex.h b/gobex/gobex.h index b223a2fac..a94d9246e 100644 --- a/gobex/gobex.h +++ b/gobex/gobex.h @@ -63,6 +63,7 @@ gboolean g_obex_remove_request_function(GObex *obex, guint id); void g_obex_suspend(GObex *obex); void g_obex_resume(GObex *obex); gboolean g_obex_srm_active(GObex *obex); +void g_obex_drop_tx_queue(GObex *obex); GObex *g_obex_new(GIOChannel *io, GObexTransportType transport_type, gssize rx_mtu, gssize tx_mtu); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id cOnnJzB1+16hOQEA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 19:24:00 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8DpZJjB1+15N3AEAlp8NpQ (envelope-from ); Tue, 30 Jun 2020 19:24:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6A0BDA2EF3; Tue, 30 Jun 2020 19:23:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390241AbgF3RVB (ORCPT + 1 other); Tue, 30 Jun 2020 13:21:01 -0400 Received: from mga17.intel.com ([192.55.52.151]:7500 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730584AbgF3RVA (ORCPT ); Tue, 30 Jun 2020 13:21:00 -0400 IronPort-SDR: zEhh1MH6fEOe5WrO5ztSD/J0hoSR7SbnrEQ6i7uO8VMIespvOPsipNwizX2GPfd3lNObDg9mHo azgcc4jkx6kg== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="126425057" X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="126425057" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 10:20:47 -0700 IronPort-SDR: NDNf2pbx/WZ71OBVnYDGBcS0uu/5kqkm56hoi20A4CzgnDJfZQudUuM1Ar1DL4ySbR69A1uL5Z u8yxzrQWWLpw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="481269202" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga005.fm.intel.com with ESMTP; 30 Jun 2020 10:20:47 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 30 Jun 2020 10:20:46 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 30 Jun 2020 10:20:46 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.175) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 30 Jun 2020 10:20:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gcgQLscjAkDcVWukv6DR/xZnLCjl1XQTJPj7H01E9YdJiuzK5hd5Dm/rx7AVjvEFMqEgATGg2ssZLb5/p+0h7cYESCaC4HQj+NHHfy9cvJbjBudiz3fCq7+4qpKVCqaddMnsxDjfj9XiKCedz9zftK43ASAKtfmKJ0mOmhw7YD0YVKFAHUUYbNrOavp9CV79JwhtA5jypUgYjkdAIh5VDXXuxCn5DmKqtbsKo2qAZO7iBYZBcNIDusrbXKpjKy92i+trcf+Zn29R2usNyrdrtV5x/g2Qeb3wiTl6SQM1X1F54dcoB4ndbDj4g5xoruxY/jOC+CXHzN/H6fqZFY8AoA== 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-SenderADCheck; bh=ZbDM2P5RCzsiJx6O2+RJ/cBNi7kKPXrvHZyGyoeYaaU=; b=I/vhf4sV3CWSm+XwpWvrO7jIS07uwhUwXACdBbibA+4pQ72Qd8dTZVcE/KVq7Zmoo4d17yuq2XAdjfZOKzIk4XpcBpQ+UVxvlZ7qdC+Kb9NDfcc4K/jMYrhzO6Rs+SJ8mT7d+fHvYpceDTBiekPn36kpTnZgvTq37Cqbw9wOL23VIitbi54zIU+vMdE5XCye9Y9fQ15GtFBVL3oYALwXor6SAOm/c7xGl3XaxAxyfS3j4lK6/01/GW6e4fqCzWnWOPMzXfAIObz7CFxOcgS4Bm/7oyo1Z8X4ootJXxov49XaKkyLuU2jqBDXTOFj4r+JolUgzfyD5OBQ8kNRFgeOcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZbDM2P5RCzsiJx6O2+RJ/cBNi7kKPXrvHZyGyoeYaaU=; b=st3vFT6IjfbiG0lqAgFGc+n9GzGwnBYVsXEyGQZOHx9yieLKcuyR++unwM0HYR3JiCrPv+o9aHfSZn4HjrkpIL0D5YqpmTk2sHc57PP4ghlRccdIUXxoE0SSvB0E8znJQ6ZLQCv8uWyWzxem8nA2ol4anN6d/4bHPi6nd4DMn9o= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB0048.namprd11.prod.outlook.com (2603:10b6:301:6a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.26; Tue, 30 Jun 2020 17:20:42 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::5b4:500e:f6a0:1ac0]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::5b4:500e:f6a0:1ac0%6]) with mapi id 15.20.3131.027; Tue, 30 Jun 2020 17:20:42 +0000 From: "Gix, Brian" To: "linux-bluetooth@vger.kernel.org" , "Stotland, Inga" Subject: Re: [PATCH BlueZ] mesh: Clean up config model publication set Thread-Topic: [PATCH BlueZ] mesh: Clean up config model publication set Thread-Index: AQHWTAUTXPNO9zUKekO3sbs/bjsftKjxbYYA Date: Tue, 30 Jun 2020 17:20:42 +0000 Message-ID: <72485ce2912bf48377bc577e4b5e1db013b1f2b6.camel@intel.com> References: <20200626215907.201532-1-inga.stotland@intel.com> In-Reply-To: <20200626215907.201532-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [134.134.139.74] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 21925ace-41f6-4144-cb12-08d81d19eafe x-ms-traffictypediagnostic: MWHPR11MB0048: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:291; x-forefront-prvs: 0450A714CB x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pbG3/9imGVZzV27PFnxfJUDq7JGHzBd1Fynwl9Gu0o1HG7gXzesV4xw52Yan8nchH0+8ouxdSK6hyisMDQy1Nve0QG4lIEHt5f4EhaWVb/wY+UTFaHjHwL3V4W7lP9t/Nsw5ssLEBLa3mIRw+XdGvEb9PIzJ9Spe7jHjDDTHOE0L5ByEjRMbz2p1GRBAI5Fr0BOGZamBqa8whLDmH1oaRv1C1VV2j2TUbD7jLnfhbGaPapSgUDBpET4gBlSbNaOd8BXsozgvdJHAB1SucCQ2K5T3c0ag+92XvjD6Va8qEeAHHiUeDU4WXZHJkiC5+E2wFHC5GRB0trshO8e3+uWpvg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(346002)(366004)(136003)(39860400002)(396003)(8936002)(26005)(2906002)(71200400001)(66556008)(64756008)(66946007)(5660300002)(6636002)(76116006)(6506007)(186003)(8676002)(66446008)(66476007)(110136005)(6512007)(86362001)(6486002)(36756003)(478600001)(316002)(83380400001)(2616005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: g20SiwaDJMU1HyGN2w0cE0CBHy2emJ2Rm0qMBUjFTlAi10FcUDayfIoMhdSJeExCdWfkKKsdAqOYzBGPYEGJR00jOLZvuvIzuS4veiSLfh/F7nC4u3OI5kc+GAXufkhLtnMkBBZiYZijdA7nAl1Dh/s5qOBGGEvTb9lBs7nu7+P1DwPeCpehkfun9pQVCqU+p0H1WwxAwVH+vtAPM25TLa0RgK9S3RKqpcww/1TwwNsJX6p0lZoVzoJBvB3DpU1tmxmPSH/Jjp5SH28USwS4rZV5lIiHSv5TgwJ5QldxCUeZ5FJGoW0yykKpb8MTy2ibMyny17AzO1ZFwHKNdKz3rH1+DeJB6DqSUsxvK+6/2hg5pRGqmokYUy3a+IDRhbV3C1WReKZuxwiqFT8sONbVodKmCjO5bw1ZRKqn0PLjOhpNxhmVYhd/7z4YJQYuEAvcShise6qkxtLBbZ/M8o+H6yX2vqnTuAWqBMBVqB+OXeXDBc+6rmLfV2zdDIJtzzXb Content-Type: text/plain; charset="utf-8" Content-ID: Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21925ace-41f6-4144-cb12-08d81d19eafe X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2020 17:20:42.5107 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Mcw5/CyoAz2nLTFoWUwTs7wUJi+vHN9WSMRICGRdH2ATBshNOkPzyKpDiYyYcL4rpOfNquAONmqvvosijzChCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB0048 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6A0BDA2EF3 X-Rspamd-UID: cafed5 QXBwbGllZA0KDQpPbiBGcmksIDIwMjAtMDYtMjYgYXQgMTQ6NTkgLTA3MDAsIEluZ2EgU3RvdGxh bmQgd3JvdGU6DQo+IE5vIGZ1bmN0aW9hbCBjaGFuZ2VzLiBNYWtlIGNvZGUgbW9yZSByZWFkYWJs ZSwgcGx1cyBzdHlsZSBmaXhlcy4NCj4gLS0tDQo+ICBtZXNoL2NmZ21vZC1zZXJ2ZXIuYyB8IDc3 ICsrKysrKysrKysrKysrKysrKysrKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQo+ICAxIGZpbGUg Y2hhbmdlZCwgMzcgaW5zZXJ0aW9ucygrKSwgNDAgZGVsZXRpb25zKC0pDQo+IA0KPiBkaWZmIC0t Z2l0IGEvbWVzaC9jZmdtb2Qtc2VydmVyLmMgYi9tZXNoL2NmZ21vZC1zZXJ2ZXIuYw0KPiBpbmRl eCA5MDIyMjhhZTAuLmM1MjVkOWQyNCAxMDA2NDQNCj4gLS0tIGEvbWVzaC9jZmdtb2Qtc2VydmVy LmMNCj4gKysrIGIvbWVzaC9jZmdtb2Qtc2VydmVyLmMNCj4gQEAgLTQ2LDEyICs0NiwxMCBAQCBz dGF0aWMgdm9pZCBzZW5kX3B1Yl9zdGF0dXMoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2 X3QgbmV0X2lkeCwNCj4gIAluID0gbWVzaF9tb2RlbF9vcGNvZGVfc2V0KE9QX0NPTkZJR19NT0RF TF9QVUJfU1RBVFVTLCBtc2cpOw0KPiAgCW1zZ1tuKytdID0gc3RhdHVzOw0KPiAgCWxfcHV0X2xl MTYoZWxlX2FkZHIsIG1zZyArIG4pOw0KPiAtCW4gKz0gMjsNCj4gLQlsX3B1dF9sZTE2KHB1Yl9h ZGRyLCBtc2cgKyBuKTsNCj4gLQluICs9IDI7DQo+ICsJbF9wdXRfbGUxNihwdWJfYWRkciwgbXNn ICsgbiArIDIpOw0KPiAgCWlkeCB8PSBjcmVkX2ZsYWcgPyBDUkVERkxBR19NQVNLIDogMDsNCj4g LQlsX3B1dF9sZTE2KGlkeCwgbXNnICsgbik7DQo+IC0JbiArPSAyOw0KPiArCWxfcHV0X2xlMTYo aWR4LCBtc2cgKyBuICsgNCk7DQo+ICsJbiArPSA2Ow0KPiAgCW1zZ1tuKytdID0gdHRsOw0KPiAg CW1zZ1tuKytdID0gcGVyaW9kOw0KPiAgCW1zZ1tuKytdID0gcmV0cmFuc21pdDsNCj4gQEAgLTYx LDE2ICs1OSwxNSBAQCBzdGF0aWMgdm9pZCBzZW5kX3B1Yl9zdGF0dXMoc3RydWN0IG1lc2hfbm9k ZSAqbm9kZSwgdWludDE2X3QgbmV0X2lkeCwNCj4gIAkJbiArPSAyOw0KPiAgCX0gZWxzZSB7DQo+ ICAJCWxfcHV0X2xlMTYobW9kX2lkID4+IDE2LCBtc2cgKyBuKTsNCj4gLQkJbiArPSAyOw0KPiAt CQlsX3B1dF9sZTE2KG1vZF9pZCwgbXNnICsgbik7DQo+IC0JCW4gKz0gMjsNCj4gKwkJbF9wdXRf bGUxNihtb2RfaWQsIG1zZyArIG4gKyAyKTsNCj4gKwkJbiArPSA0Ow0KPiAgCX0NCj4gIA0KPiAg CW1lc2hfbW9kZWxfc2VuZChub2RlLCBkc3QsIHNyYywgQVBQX0lEWF9ERVZfTE9DQUwsIG5ldF9p ZHgsIERFRkFVTFRfVFRMLA0KPiAgCQkJCQkJCQlmYWxzZSwgbXNnLCBuKTsNCj4gIH0NCj4gIA0K PiAtc3RhdGljIGJvb2wgY29uZmlnX3B1Yl9nZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWlu dDE2X3QgbmV0X2lkeCwNCj4gK3N0YXRpYyB2b2lkIGNvbmZpZ19wdWJfZ2V0KHN0cnVjdCBtZXNo X25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+ICAJCQkJCXVpbnQxNl90IHNyYywgdWlu dDE2X3QgZHN0LA0KPiAgCQkJCQljb25zdCB1aW50OF90ICpwa3QsIHVpbnQxNl90IHNpemUpDQo+ ICB7DQo+IEBAIC04Niw3ICs4Myw3IEBAIHN0YXRpYyBib29sIGNvbmZpZ19wdWJfZ2V0KHN0cnVj dCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+ICAJCW1vZF9pZCA9IGxfZ2V0 X2xlMTYocGt0ICsgMikgPDwgMTY7DQo+ICAJCW1vZF9pZCB8PSBsX2dldF9sZTE2KHBrdCArIDQp Ow0KPiAgCX0gZWxzZQ0KPiAtCQlyZXR1cm4gZmFsc2U7DQo+ICsJCXJldHVybjsNCj4gIA0KPiAg CWVsZV9hZGRyID0gbF9nZXRfbGUxNihwa3QpOw0KPiAgCXB1YiA9IG1lc2hfbW9kZWxfcHViX2dl dChub2RlLCBlbGVfYWRkciwgbW9kX2lkLCAmc3RhdHVzKTsNCj4gQEAgLTk4LDE2ICs5NSwxNSBA QCBzdGF0aWMgYm9vbCBjb25maWdfcHViX2dldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50 MTZfdCBuZXRfaWR4LA0KPiAgCWVsc2UNCj4gIAkJc2VuZF9wdWJfc3RhdHVzKG5vZGUsIG5ldF9p ZHgsIHNyYywgZHN0LCBzdGF0dXMsIGVsZV9hZGRyLA0KPiAgCQkJCW1vZF9pZCwgMCwgMCwgMCwg MCwgMCwgMCk7DQo+IC0JcmV0dXJuIHRydWU7DQo+ICB9DQo+ICANCj4gIHN0YXRpYyB2b2lkIGNv bmZpZ19wdWJfc2V0KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+ ICAJCQkJCXVpbnQxNl90IHNyYywgdWludDE2X3QgZHN0LA0KPiAtCQkJCQljb25zdCB1aW50OF90 ICpwa3QsIHVpbnQ4X3QgdmlydF9vZmZzZXQsDQo+ICsJCQkJCWNvbnN0IHVpbnQ4X3QgKnBrdCwg Ym9vbCB2aXJ0LA0KPiAgCQkJCQlib29sIHZlbmRvciwgYm9vbCB1bnJlbGlhYmxlKQ0KPiAgew0K PiAgCXVpbnQzMl90IG1vZF9pZDsNCj4gLQl1aW50MTZfdCBlbGVfYWRkciwgaWR4LCBvdGEgPSAw Ow0KPiArCXVpbnQxNl90IGVsZV9hZGRyLCBpZHgsIG90YSA9IFVOQVNTSUdORURfQUREUkVTUzsN Cj4gIAljb25zdCB1aW50OF90ICpwdWJfYWRkcjsNCj4gIAl1aW50MTZfdCB0ZXN0X2FkZHI7DQo+ ICAJdWludDhfdCB0dGwsIHBlcmlvZDsNCj4gQEAgLTExNSwzNCArMTExLDMzIEBAIHN0YXRpYyB2 b2lkIGNvbmZpZ19wdWJfc2V0KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9p ZHgsDQo+ICAJaW50IHN0YXR1czsNCj4gIAlib29sIGNyZWRfZmxhZzsNCj4gIA0KPiAtCWlkeCA9 IGxfZ2V0X2xlMTYocGt0ICsgNCArIHZpcnRfb2Zmc2V0KTsNCj4gLQl0dGwgPSBwa3RbNiArIHZp cnRfb2Zmc2V0XTsNCj4gLQlwZXJpb2QgPSBwa3RbNyArIHZpcnRfb2Zmc2V0XTsNCj4gLQlyZXRy YW5zbWl0ID0gcGt0WzggKyB2aXJ0X29mZnNldF07DQo+IC0JbW9kX2lkID0gbF9nZXRfbGUxNihw a3QgKyA5ICsgdmlydF9vZmZzZXQpOw0KPiArCWVsZV9hZGRyID0gbF9nZXRfbGUxNihwa3QpOw0K PiArCXB1Yl9hZGRyID0gcGt0ICsgMjsNCj4gKw0KPiArCXBrdCArPSAodmlydCA/IDE0IDogMCk7 DQo+ICsNCj4gKwlpZHggPSBsX2dldF9sZTE2KHBrdCArIDQpOw0KPiArCXR0bCA9IHBrdFs2XTsN Cj4gKwlwZXJpb2QgPSBwa3RbN107DQo+ICsJcmV0cmFuc21pdCA9IHBrdFs4XTsNCj4gKwltb2Rf aWQgPSBsX2dldF9sZTE2KHBrdCArIDkpOw0KPiAgDQo+ICAJaWYgKCF2ZW5kb3IpDQo+ICAJCW1v ZF9pZCB8PSBWRU5ET1JfSURfTUFTSzsNCj4gIAllbHNlDQo+IC0JCW1vZF9pZCA9IChtb2RfaWQg PDwgMTYpIHwgbF9nZXRfbGUxNihwa3QgKyAxMSArIHZpcnRfb2Zmc2V0KTsNCj4gLQ0KPiAtCWVs ZV9hZGRyID0gbF9nZXRfbGUxNihwa3QpOw0KPiAtCXB1Yl9hZGRyID0gcGt0ICsgMjsNCj4gKwkJ bW9kX2lkID0gKG1vZF9pZCA8PCAxNikgfCBsX2dldF9sZTE2KHBrdCArIDExKTsNCj4gIA0KPiAt CS8qIERvZXNuJ3QgYWNjZXB0IHZpcnR1YWwgc2VlbWluZyBhZGRyZXNzZXMgKi8NCj4gKwkvKiBE b24ndCBhY2NlcHQgdmlydHVhbCBzZWVtaW5nIGFkZHJlc3NlcyAqLw0KPiAgCXRlc3RfYWRkciA9 IGxfZ2V0X2xlMTYocHViX2FkZHIpOw0KPiAtCWlmICghdmlydF9vZmZzZXQgJiYgSVNfVklSVFVB TCh0ZXN0X2FkZHIpKQ0KPiArCWlmICghdmlydCAmJiBJU19WSVJUVUFMKHRlc3RfYWRkcikpDQo+ ICAJCXJldHVybjsNCj4gIA0KPiAtCS8qIEdldCBjcmVkX2ZsYWcgKi8NCj4gIAljcmVkX2ZsYWcg PSAhIShDUkVERkxBR19NQVNLICYgaWR4KTsNCj4gLQ0KPiAtCS8qIEdldCBBcHBLZXkgaW5kZXgg Ki8NCj4gIAlpZHggJj0gQVBQX0lEWF9NQVNLOw0KPiAgDQo+ICAJc3RhdHVzID0gbWVzaF9tb2Rl bF9wdWJfc2V0KG5vZGUsIGVsZV9hZGRyLCBtb2RfaWQsIHB1Yl9hZGRyLCBpZHgsDQo+ICAJCQkJ CWNyZWRfZmxhZywgdHRsLCBwZXJpb2QsIHJldHJhbnNtaXQsDQo+IC0JCQkJCXZpcnRfb2Zmc2V0 ICE9IDAsICZvdGEpOw0KPiArCQkJCQl2aXJ0LCAmb3RhKTsNCj4gIA0KPiAgCWxfZGVidWcoInB1 Yl9zZXQ6IHN0YXR1cyAlZCwgZWEgJTQuNHgsIG90YTogJTQuNHgsIG1vZDogJXgsIGlkeDogJTMu M3giLA0KPiAgCQkJCQlzdGF0dXMsIGVsZV9hZGRyLCBvdGEsIG1vZF9pZCwgaWR4KTsNCj4gQEAg LTE1NSwxNiArMTUwLDE3IEBAIHN0YXRpYyB2b2lkIGNvbmZpZ19wdWJfc2V0KHN0cnVjdCBtZXNo X25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+ICAJCXJldHVybjsNCj4gIAl9DQo+ICAN Cj4gLQlpZiAoSVNfVU5BU1NJR05FRChvdGEpICYmICF2aXJ0X29mZnNldCkgew0KPiArCWlmIChJ U19VTkFTU0lHTkVEKHRlc3RfYWRkcikgJiYgIXZpcnQpIHsNCj4gIAkJdHRsID0gcGVyaW9kID0g aWR4ID0gMDsNCj4gIA0KPiAgCQkvKiBSZW1vdmUgbW9kZWwgcHVibGljYXRpb24gZnJvbSBjb25m aWcgZmlsZSAqLw0KPiAtCQltZXNoX2NvbmZpZ19tb2RlbF9wdWJfZGVsKG5vZGVfY29uZmlnX2dl dChub2RlKSwgZWxlX2FkZHIsDQo+ICsJCWlmICghbWVzaF9jb25maWdfbW9kZWxfcHViX2RlbChu b2RlX2NvbmZpZ19nZXQobm9kZSksIGVsZV9hZGRyLA0KPiAgCQkJCXZlbmRvciA/IG1vZF9pZCA6 IG1vZF9pZCAmIH5WRU5ET1JfSURfTUFTSywNCj4gLQkJCQkJCQkJdmVuZG9yKTsNCj4gKwkJCQkJ CQkJCXZlbmRvcikpDQo+ICsJCQlzdGF0dXMgPSBNRVNIX1NUQVRVU19TVE9SQUdFX0ZBSUw7DQo+ ICAJfSBlbHNlIHsNCj4gIAkJc3RydWN0IG1lc2hfY29uZmlnX3B1YiBkYl9wdWIgPSB7DQo+IC0J CQkudmlydCA9ICh2aXJ0X29mZnNldCAhPSAwKSwNCj4gKwkJCS52aXJ0ID0gdmlydCwNCj4gIAkJ CS5hZGRyID0gb3RhLA0KPiAgCQkJLmlkeCA9IGlkeCwNCj4gIAkJCS50dGwgPSB0dGwsDQo+IEBA IC0xNzQsNyArMTcwLDcgQEAgc3RhdGljIHZvaWQgY29uZmlnX3B1Yl9zZXQoc3RydWN0IG1lc2hf bm9kZSAqbm9kZSwgdWludDE2X3QgbmV0X2lkeCwNCj4gIAkJCS5pbnRlcnZhbCA9ICgocmV0cmFu c21pdCA+PiAzKSArIDEpICogNTANCj4gIAkJfTsNCj4gIA0KPiAtCQlpZiAodmlydF9vZmZzZXQp DQo+ICsJCWlmICh2aXJ0KQ0KPiAgCQkJbWVtY3B5KGRiX3B1Yi52aXJ0X2FkZHIsIHB1Yl9hZGRy LCAxNik7DQo+ICANCj4gIAkJLyogU2F2ZSBtb2RlbCBwdWJsaWNhdGlvbiB0byBjb25maWcgZmls ZSAqLw0KPiBAQCAtMTg2LDcgKzE4Miw4IEBAIHN0YXRpYyB2b2lkIGNvbmZpZ19wdWJfc2V0KHN0 cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+ICANCj4gIAlpZiAoIXVu cmVsaWFibGUpDQo+ICAJCXNlbmRfcHViX3N0YXR1cyhub2RlLCBuZXRfaWR4LCBzcmMsIGRzdCwg c3RhdHVzLCBlbGVfYWRkciwNCj4gLQkJCW1vZF9pZCwgb3RhLCBpZHgsIGNyZWRfZmxhZywgdHRs LCBwZXJpb2QsIHJldHJhbnNtaXQpOw0KPiArCQkJCQltb2RfaWQsIG90YSwgaWR4LCBjcmVkX2Zs YWcsIHR0bCwNCj4gKwkJCQkJcGVyaW9kLCByZXRyYW5zbWl0KTsNCj4gIH0NCj4gIA0KPiAgc3Rh dGljIHZvaWQgc2VuZF9zdWJfc3RhdHVzKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90 IG5ldF9pZHgsDQo+IEBAIC03ODEsMTYgKzc3OCwxNiBAQCBzdGF0aWMgYm9vbCBjZmdfc3J2X3Br dCh1aW50MTZfdCBzcmMsIHVpbnQxNl90IGRzdCwgdWludDE2X3QgYXBwX2lkeCwNCj4gIAkJaWYg KHNpemUgIT0gMjUgJiYgc2l6ZSAhPSAyNykNCj4gIAkJCXJldHVybiB0cnVlOw0KPiAgDQo+IC0J CWNvbmZpZ19wdWJfc2V0KG5vZGUsIG5ldF9pZHgsIHNyYywgZHN0LCBwa3QsIDE0LCBzaXplID09 IDI3LA0KPiAtCQkJCSEhKG9wY29kZSAmIE9QX1VOUkVMSUFCTEUpKTsNCj4gLQkJYnJlYWs7DQo+ ICsJCXZpcnQgPSB0cnVlOw0KPiArCQkvKiBGYWxsIFRocm91Z2ggKi8NCj4gIA0KPiAgCWNhc2Ug T1BfQ09ORklHX01PREVMX1BVQl9TRVQ6DQo+IC0JCWlmIChzaXplICE9IDExICYmIHNpemUgIT0g MTMpDQo+ICsJCWlmICghdmlydCAmJiAoc2l6ZSAhPSAxMSAmJiBzaXplICE9IDEzKSkNCj4gIAkJ CXJldHVybiB0cnVlOw0KPiAgDQo+IC0JCWNvbmZpZ19wdWJfc2V0KG5vZGUsIG5ldF9pZHgsIHNy YywgZHN0LCBwa3QsIDAsIHNpemUgPT0gMTMsDQo+IC0JCQkJISEob3Bjb2RlICYgT1BfVU5SRUxJ QUJMRSkpOw0KPiArCQljb25maWdfcHViX3NldChub2RlLCBuZXRfaWR4LCBzcmMsIGRzdCwgcGt0 LCB2aXJ0LA0KPiArCQkJCQkJc2l6ZSA9PSAxMyB8fCBzaXplID09IDI3LA0KPiArCQkJCQkJISEo b3Bjb2RlICYgT1BfVU5SRUxJQUJMRSkpOw0KPiAgCQlicmVhazsNCj4gIA0KPiAgCWNhc2UgT1Bf Q09ORklHX01PREVMX1BVQl9HRVQ6DQo= Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id YOK5Ei18+15HvAEA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 19:53:49 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cN5eES18+14pbwAAlp8NpQ (envelope-from ); Tue, 30 Jun 2020 19:53:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 48A39A017C; Tue, 30 Jun 2020 19:53:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388248AbgF3RrU (ORCPT + 1 other); Tue, 30 Jun 2020 13:47:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726813AbgF3RrU (ORCPT ); Tue, 30 Jun 2020 13:47:20 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20C62C061755 for ; Tue, 30 Jun 2020 10:47:20 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id j1so9735605pfe.4 for ; Tue, 30 Jun 2020 10:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tFSRSERRZijSFK7hRNe5Kg4vhWLebcNBDc/HGzP5nvo=; b=HnUjlPya3iLGWP7NtsZaQx/gpDW4DyxWcsrfcHYKarn+GsaGar5Mnp4ddrVqu3XT/B CGWX0UiahrC29hK/Ff4FnZnJEFlrZxE2jGdAWwQjfCpdlbj8tjAs/6xeiN5obpZ3jmXL gLLYIo9bQq2W+2QtU6PBsL7Hk2DejIgROjjqc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tFSRSERRZijSFK7hRNe5Kg4vhWLebcNBDc/HGzP5nvo=; b=faITIJ31OxMTxdDCuAcSyqvzaULW2vjB+v672ICnfj8LkpZgl2O3IvETmlklk3Y7UG kpCqrqGY1zW1ZcS6cSJHyKcUm1bcyBArDm6ZbdCwcSRe0ERvuje78z4yOalrltsOBovA 20d9nMJe6PfjGUrvMVo1Grg8PJg8xHvaumg5mts7dGIlTVWyctE8dneMVODhBo8dPptD OpqRj1x1dltaEWY4lwFhcSJ1ED9F3tZsZ46mNkth5GiI9tqOlFJqux27GUx93AoLgAaK 2dyplyzS2jMjQIGrxCnBT1Mcz3All1m4/C0dNjO7uCw92TfzJuzxkL8WdUllnEvHaO4a DI1Q== X-Gm-Message-State: AOAM5302YW1p9gGKNtuWU9Fn35qmWCUt9GYeHG/1JFc5qwuarSJGjeHd prJR5TCE/mTpZI7423UGED2ZdRycayc= X-Google-Smtp-Source: ABdhPJwmBhOcrmpvrr1GchxHE/h9pOTtNfP4mgFzhm7maqlOhaCwAWZ3aZu0HJ7ztTVZzuxNFL5O4A== X-Received: by 2002:a63:457:: with SMTP id 84mr16203374pge.219.1593539239383; Tue, 30 Jun 2020 10:47:19 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:b7e2:9910:bd78:608d]) by smtp.gmail.com with ESMTPSA id u8sm2850417pjn.24.2020.06.30.10.47.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jun 2020 10:47:18 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka Subject: [PATCH 1/1] client: Add battery command Date: Tue, 30 Jun 2020 10:47:07 -0700 Message-Id: <20200630174707.214317-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.62 / 15.00 / 200.00 X-Rspamd-Queue-Id: 48A39A017C X-Rspamd-UID: 88b647 This adds the "battery" command to show battery information of a peer device based on org.bluez.Battery1 API. Example usage: [bluetooth]# battery XX:XX:XX:XX:XX:XX Percentage: 100% --- client/main.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/client/main.c b/client/main.c index 422da5593..cc5eb7ce8 100644 --- a/client/main.c +++ b/client/main.c @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; static GDBusProxy *default_dev; static GDBusProxy *default_attr; static GList *ctrl_list; +static GList *battery_proxies; static const char *agent_arguments[] = { "on", @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) bt_shell_set_prompt(PROMPT_OFF); g_list_free_full(ctrl_list, proxy_leak); + g_list_free_full(battery_proxies, proxy_leak); ctrl_list = NULL; + battery_proxies = NULL; default_ctrl = NULL; } @@ -445,6 +448,16 @@ done: g_free(desc); } +static void battery_added(GDBusProxy *proxy) +{ + battery_proxies = g_list_append(battery_proxies, proxy); +} + +static void battery_removed(GDBusProxy *proxy) +{ + battery_proxies = g_list_remove(battery_proxies, proxy); +} + static void device_added(GDBusProxy *proxy) { DBusMessageIter iter; @@ -539,6 +552,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) gatt_add_manager(proxy); } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { ad_manager_added(proxy); + } else if (!strcmp(interface, "org.bluez.Battery1")) { + battery_added(proxy); } } @@ -630,6 +645,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) gatt_remove_manager(proxy); } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { ad_unregister(dbus_conn, NULL); + } else if (!strcmp(interface, "org.bluez.Battery1")) { + battery_removed(proxy); } } @@ -763,6 +780,19 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) return NULL; } +static GDBusProxy *find_battery_by_path(GList *source, const char *path) +{ + GList *list; + + for (list = g_list_first(source); list; list = g_list_next(list)) { + GDBusProxy *proxy = list->data; + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) + return proxy; + } + + return NULL; +} + static GDBusProxy *find_proxy_by_address(GList *source, const char *address) { GList *list; @@ -1650,6 +1680,35 @@ static void cmd_info(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_SUCCESS); } +static void cmd_battery(int argc, char *argv[]) +{ + DBusMessageIter iter; + GDBusProxy *device_proxy; + GDBusProxy *battery_proxy; + unsigned char percentage; + + device_proxy = find_device(argc, argv); + if (!device_proxy) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + battery_proxy = find_battery_by_path(battery_proxies, + g_dbus_proxy_get_path(device_proxy)); + if (!battery_proxy) { + bt_shell_printf("Device %s does not have battery information\n", + argv[1]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (g_dbus_proxy_get_property(battery_proxy, "Percentage", &iter) == + FALSE) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + dbus_message_iter_get_basic(&iter, &percentage); + bt_shell_printf("Percentage: %d%%\n", percentage); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + static void pair_reply(DBusMessage *message, void *user_data) { DBusError error; @@ -2785,6 +2844,8 @@ static const struct bt_shell_menu main_menu = { dev_generator }, { "disconnect", "[dev]", cmd_disconn, "Disconnect device", dev_generator }, + { "battery", "[dev]", cmd_battery, "Show device battery", + dev_generator }, { } }, }; -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id CB7YFeSK+17cEgAA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 20:56:36 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ePIDFOSK+15XHwAADc0bRg (envelope-from ); Tue, 30 Jun 2020 20:56:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DDEB95080C; Tue, 30 Jun 2020 20:56:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726504AbgF3S4X (ORCPT + 1 other); Tue, 30 Jun 2020 14:56:23 -0400 Received: from mga05.intel.com ([192.55.52.43]:57136 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726207AbgF3S4X (ORCPT ); Tue, 30 Jun 2020 14:56:23 -0400 IronPort-SDR: 6n+nDLIJXPhryc5ADHUtC6B5Ywy7rmeYMkZ1NsSkWpN7XQcz3es4JTAFz6YNR3Dy6+IPlXoLyy hvM+PjClPPFg== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="231222959" X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="231222959" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 11:56:22 -0700 IronPort-SDR: q/I2bh4OLnBPF6jWSkOSnVJ/QPB/P6ZdRd94CXkvYchHp1Zd5cd+FEuCHOp+Y6fccMMIS1Qy5A rW/VcnMFvvmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="355864262" Received: from mlindstr-mobl1.amr.corp.intel.com (HELO ingas-nuc1.sea.intel.com) ([10.254.108.27]) by orsmga001.jf.intel.com with ESMTP; 30 Jun 2020 11:56:22 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland Subject: [PATCH BlueZ v2 4/4] test/test-mesh: Add options to "Models" property Date: Tue, 30 Jun 2020 11:56:17 -0700 Message-Id: <20200630185617.14755-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200630185617.14755-1-inga.stotland@intel.com> References: <20200630185617.14755-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 24 X-Rspamd-Score: 3.65 / 15.00 / 200.00 X-Rspamd-Queue-Id: DDEB95080C X-Rspamd-UID: b6474e This adds options dictionary to "Models" property to stay in sync with mesh-api changes. --- test/test-mesh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/test/test-mesh b/test/test-mesh index 7c8a25482..5da0278d6 100755 --- a/test/test-mesh +++ b/test/test-mesh @@ -430,32 +430,35 @@ class Element(dbus.service.Object): dbus.service.Object.__init__(self, bus, self.path) def _get_sig_models(self): - ids = [] + mods = [] for model in self.models: + opts = [] id = model.get_id() vendor = model.get_vendor() if vendor == VENDOR_ID_NONE: - ids.append(id) - return ids + mod = (id, opts) + mods.append(mod) + return mods def _get_v_models(self): - ids = [] + mods = [] for model in self.models: + opts = [] id = model.get_id() v = model.get_vendor() if v != VENDOR_ID_NONE: - vendor_id = (v, id) - ids.append(vendor_id) - return ids + mod = (v, id, opts) + mods.append(mod) + return mods def get_properties(self): vendor_models = self._get_v_models() sig_models = self._get_sig_models() props = {'Index' : dbus.Byte(self.index)} - props['Models'] = dbus.Array(sig_models, signature='q') + props['Models'] = dbus.Array(sig_models, signature='(qa{sv})') props['VendorModels'] = dbus.Array(vendor_models, - signature='(qq)') + signature='(qqa{sv})') #print(props) return { MESH_ELEMENT_IFACE: props } -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 8AwOGOmB+16N8wEA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 20:18:17 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id OJ5oFumB+147OgAA0J78UA (envelope-from ); Tue, 30 Jun 2020 20:18:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7489D4086C; Tue, 30 Jun 2020 20:18:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387658AbgF3SSL (ORCPT + 1 other); Tue, 30 Jun 2020 14:18:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbgF3SSK (ORCPT ); Tue, 30 Jun 2020 14:18:10 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61EE9C061755 for ; Tue, 30 Jun 2020 11:18:10 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id j80so19572694qke.0 for ; Tue, 30 Jun 2020 11:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=sn0glQxiqn/8NcrI67Txd/y31mvg+aG4rpK/LJ6p8ww=; b=QtEljWmTExkczWdEYqpl9k6XoVpCspRvPytEOSTZeEnvjz19Nt45B8Ah2xDIobpXyI 1Bdh0TekD+sIzF/uPnTr6PkINMsUyN0C8G43sqZWxcPgnbMsciuOXOAoi+t+HGl2050B NNm1EFZP8yT/bTJKbZAZFbTihX60IsVeUYNqJMiQQLwFYxiRJIZ6i3Rfe8uxdmV7bSZ5 iMYr1iSV4FtsCv+MU2qKzaAMeUHL1KpMs+yN/+2WxufLPK3eS+QyIhhG/pxEw78rZYnG VwQZfWlBKEOGKicBFzW8Xcj/PIzfk3A7NHn1482MAa3sHlAHkahXClQUtHeqBnFl50NT 3TpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=sn0glQxiqn/8NcrI67Txd/y31mvg+aG4rpK/LJ6p8ww=; b=FkswI4/jW1tJRRhPhMni0gGpkyj0pRnodRH1s/miK/igpqVHz2pDstX1oxYwke5FGm i/TxfqR1VSzE/QYSQihEY4V+fC9BXqqjMq4wsHhDKObwzUFp2w+Km1bUFEOmDCOBtX/s /6e8P7fzch/ksRgplJI+VdASyGvu6UbWSNUn9VRErYwVMOxw6cczCMvcuOP7nil7v4EM Jg99vnKYABC3AauwPCFlWanYbTKbARh2cXd5fM6K5anTIBQEp3+EywKp+THEor680DTV 120a8Bi0s9q+M8JGezl0SpmsAXRTXPKguI5xO8bPKEbs/JvuQMq7W27nOF4K45Ny3lwc wDCQ== X-Gm-Message-State: AOAM53229z/XM90doJ8vBaUdAfnQr6yVAVF2iNKpFPWfRAOwiTCzwI4l Hn6fpI5wlaRwMaMeIaHBACfFIE4EBqs= X-Google-Smtp-Source: ABdhPJyUUDeZtw4lA6MV/mexVcm0jMDsL1Kf9TdcMoqL9OTK7ahSejnYkRDUmNb+YDlKl9Ph8MEAJw== X-Received: by 2002:a37:65cc:: with SMTP id z195mr19812659qkb.89.1593541087743; Tue, 30 Jun 2020 11:18:07 -0700 (PDT) Received: from [172.17.0.2] ([52.167.132.39]) by smtp.gmail.com with ESMTPSA id p25sm3576923qki.107.2020.06.30.11.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 11:18:06 -0700 (PDT) Message-ID: <5efb81de.1c69fb81.1d653.158b@mx.google.com> Date: Tue, 30 Jun 2020 11:18:06 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============1402526054168955741==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, sonnysasaka@chromium.org Subject: RE: [1/1] client: Add battery command Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200630174707.214317-1-sonnysasaka@chromium.org> References: <20200630174707.214317-1-sonnysasaka@chromium.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 31 X-Rspamd-Score: 4.70 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7489D4086C X-Rspamd-UID: 43b4e0 --===============1402526054168955741== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:LINE_SPACING: Missing a blank line after declarations #79: FILE: client/main.c:789: + GDBusProxy *proxy = list->data; + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) - total: 0 errors, 1 warnings, 110 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============1402526054168955741==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id EN3fN86L+14fTAAA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 21:00:30 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4MFZNs6L+16DTgEAgupzMw (envelope-from ); Tue, 30 Jun 2020 21:00:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D3415A2FD7; Tue, 30 Jun 2020 21:00:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbgF3TAX (ORCPT + 1 other); Tue, 30 Jun 2020 15:00:23 -0400 Received: from mga05.intel.com ([192.55.52.43]:57132 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbgF3TAX (ORCPT ); Tue, 30 Jun 2020 15:00:23 -0400 IronPort-SDR: Q92GSGEd+lGbTVnW66d1ocLLfAWShtrtYMQkcrvjL55qWavjsO33RxPQcYuY07ILb0v/JzsvXu 3empO42KH4mA== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="231222956" X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="231222956" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 11:56:21 -0700 IronPort-SDR: 1br6XPM+IpqVFw2ZfMmg0hJddXBgnLbc+949FSLPz0N4mvYkEgNIGcHEyQ3T1smqALn5ornL5q GhUT/KOqoSdw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="355864256" Received: from mlindstr-mobl1.amr.corp.intel.com (HELO ingas-nuc1.sea.intel.com) ([10.254.108.27]) by orsmga001.jf.intel.com with ESMTP; 30 Jun 2020 11:56:20 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland Subject: [PATCH BlueZ v2 2/4] mesh: Check app model settings of pub/sub support Date: Tue, 30 Jun 2020 11:56:15 -0700 Message-Id: <20200630185617.14755-3-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200630185617.14755-1-inga.stotland@intel.com> References: <20200630185617.14755-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 19 X-Rspamd-Score: 2.97 / 15.00 / 200.00 X-Rspamd-Queue-Id: D3415A2FD7 X-Rspamd-UID: 86ceea This adds handling of new options dictionary included with "Models" and "VendorModels" properties on org.bluez.mesh.Element1 interface. Supported (optional) dictionary entries: "Publish" - indicates whether the model supports publication mechanism. If not present, publication is enabled. "Subscribe" - indicates whether the model supports subscription mechanism. If not present, subscriptions are enabled. If a config message related to subscription state is received for a model that does not support subscription mechanism, an error code 0x08, ("Not A Subscribe Model") is sent in response. If a config message related to publication state is received for a model that does not support publication mechanism, an error code 0x07 ("Invalid Publish Parameters") is sent in response. --- mesh/mesh-config-json.c | 76 +++++++++++++++++- mesh/mesh-config.h | 8 ++ mesh/model.c | 98 +++++++++++++++++++---- mesh/model.h | 6 ++ mesh/node.c | 168 ++++++++++++++++++++++++++++++++-------- 5 files changed, 309 insertions(+), 47 deletions(-) diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 05b2a5651..661775f95 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1096,6 +1096,16 @@ static bool parse_models(json_object *jmodels, struct mesh_config_element *ele) goto fail; } + if (json_object_object_get_ex(jmodel, "pubEnabled", &jvalue)) + mod->pub_enabled = json_object_get_boolean(jvalue); + else + mod->pub_enabled = true; + + if (json_object_object_get_ex(jmodel, "subEnabled", &jvalue)) + mod->sub_enabled = json_object_get_boolean(jvalue); + else + mod->sub_enabled = true; + if (json_object_object_get_ex(jmodel, "publish", &jvalue)) { mod->pub = parse_model_publication(jvalue); if (!mod->pub) @@ -1562,7 +1572,7 @@ bool mesh_config_write_iv_index(struct mesh_config *cfg, uint32_t idx, static void add_model(void *a, void *b) { struct mesh_config_model *mod = a; - json_object *jmodels = b, *jmodel; + json_object *jmodels = b, *jmodel, *jval; jmodel = json_object_new_object(); if (!jmodel) @@ -1574,6 +1584,12 @@ static void add_model(void *a, void *b) else write_uint32_hex(jmodel, "modelId", mod->id); + jval = json_object_new_boolean(mod->sub_enabled); + json_object_object_add(jmodel, "subEnabled", jval); + + jval = json_object_new_boolean(mod->pub_enabled); + json_object_object_add(jmodel, "pubEnabled", jval); + json_object_array_add(jmodels, jmodel); } @@ -1974,6 +1990,64 @@ bool mesh_config_model_sub_del_all(struct mesh_config *cfg, uint16_t addr, return save_config(cfg->jnode, cfg->node_dir_path); } +bool mesh_config_model_pub_enable(struct mesh_config *cfg, uint16_t ele_addr, + uint32_t mod_id, bool vendor, + bool enable) +{ + json_object *jmodel, *jval; + int ele_idx; + + if (!cfg) + return false; + + ele_idx = get_element_index(cfg->jnode, ele_addr); + if (ele_idx < 0) + return false; + + jmodel = get_element_model(cfg->jnode, ele_idx, mod_id, vendor); + if (!jmodel) + return false; + + json_object_object_del(jmodel, "pubDisabled"); + + jval = json_object_new_boolean(!enable); + json_object_object_add(jmodel, "pubDisabled", jval); + + if (!enable) + json_object_object_del(jmodel, "publish"); + + return save_config(cfg->jnode, cfg->node_dir_path); +} + +bool mesh_config_model_sub_enable(struct mesh_config *cfg, uint16_t ele_addr, + uint32_t mod_id, bool vendor, + bool enable) +{ + json_object *jmodel, *jval; + int ele_idx; + + if (!cfg) + return false; + + ele_idx = get_element_index(cfg->jnode, ele_addr); + if (ele_idx < 0) + return false; + + jmodel = get_element_model(cfg->jnode, ele_idx, mod_id, vendor); + if (!jmodel) + return false; + + json_object_object_del(jmodel, "subEnabled"); + + jval = json_object_new_boolean(enable); + json_object_object_add(jmodel, "subEnabled", jval); + + if (!enable) + json_object_object_del(jmodel, "subscribe"); + + return save_config(cfg->jnode, cfg->node_dir_path); +} + bool mesh_config_write_seq_number(struct mesh_config *cfg, uint32_t seq, bool cache) { diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 8ff7b63c7..9f30e693b 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -45,6 +45,8 @@ struct mesh_config_model { uint16_t *bindings; uint32_t id; bool vendor; + bool sub_enabled; + bool pub_enabled; uint32_t num_bindings; uint32_t num_subs; }; @@ -156,6 +158,12 @@ bool mesh_config_model_sub_del(struct mesh_config *cfg, uint16_t ele_addr, struct mesh_config_sub *sub); bool mesh_config_model_sub_del_all(struct mesh_config *cfg, uint16_t ele_addr, uint32_t mod_id, bool vendor); +bool mesh_config_model_pub_enable(struct mesh_config *cfg, uint16_t ele_addr, + uint32_t mod_id, bool vendor, + bool enable); +bool mesh_config_model_sub_enable(struct mesh_config *cfg, uint16_t ele_addr, + uint32_t mod_id, bool vendor, + bool enable); bool mesh_config_app_key_add(struct mesh_config *cfg, uint16_t net_idx, uint16_t app_idx, const uint8_t key[16]); bool mesh_config_app_key_update(struct mesh_config *cfg, uint16_t app_idx, diff --git a/mesh/model.c b/mesh/model.c index 5ed95afac..afac6ec69 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -51,6 +51,8 @@ struct mesh_model { struct l_queue *subs; struct l_queue *virtuals; struct mesh_model_pub *pub; + bool sub_enabled; + bool pub_enabled; uint32_t id; uint8_t ele_idx; }; @@ -1097,7 +1099,7 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod) return status; - if (id == CONFIG_SRV_MODEL || id == CONFIG_CLI_MODEL) + if (!mod->pub_enabled || (mod->cbs && !(mod->cbs->pub))) return MESH_STATUS_INVALID_PUB_PARAM; if (!appkey_have_key(node_get_net(node), idx)) @@ -1134,9 +1136,11 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, /* External model */ config_update_model_pub_period(node, mod->ele_idx, id, pub_period_to_ms(period)); - else + else { /* Internal model, call registered callbacks */ - mod->cbs->pub(mod->pub); + if (mod->cbs->pub) + mod->cbs->pub(mod->pub); + } return MESH_STATUS_SUCCESS; } @@ -1150,6 +1154,11 @@ struct mesh_model_pub *mesh_model_pub_get(struct mesh_node *node, uint16_t addr, if (!mod) return NULL; + if (!mod->pub_enabled || (mod->cbs && !(mod->cbs->pub))) + *status = MESH_STATUS_INVALID_PUB_PARAM; + else + *status = MESH_STATUS_SUCCESS; + return mod->pub; } @@ -1171,6 +1180,13 @@ struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t id) mod->id = id; mod->ele_idx = ele_idx; mod->virtuals = l_queue_new(); + + /* + * Unless specifically indicated by an app, subscriptions and + * publications are enabled by default + */ + mod->sub_enabled = true; + mod->pub_enabled = true; return mod; } @@ -1318,6 +1334,9 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod) return status; + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + entry = l_queue_get_entries(mod->subs); *size = 0; n = 0; @@ -1358,6 +1377,9 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod) return status; + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + status = add_sub(node_get_net(node), mod, group, is_virt, dst); if (status != MESH_STATUS_SUCCESS) @@ -1381,6 +1403,9 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod) return status; + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + subs = mod->subs; virtuals = mod->virtuals; mod->subs = l_queue_new(); @@ -1430,6 +1455,9 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod) return status; + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + if (is_virt) { struct mesh_virtual *virt; @@ -1448,27 +1476,22 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, *dst = grp; - if (l_queue_remove(mod->subs, L_UINT_TO_PTR(grp))) + if (l_queue_remove(mod->subs, L_UINT_TO_PTR(grp))) { mesh_net_dst_unreg(node_get_net(node), grp); - if (!mod->cbs) - /* External models */ - config_update_model_subscriptions(node, mod); + if (!mod->cbs) + /* External models */ + config_update_model_subscriptions(node, mod); + } return MESH_STATUS_SUCCESS; } -int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) +static void remove_subs(struct mesh_node *node, struct mesh_model *mod) { - int status; - struct mesh_model *mod; const struct l_queue_entry *entry; struct mesh_net *net = node_get_net(node); - mod = find_model(node, addr, id, &status); - if (!mod) - return status; - entry = l_queue_get_entries(mod->subs); for (; entry; entry = entry->next) @@ -1476,6 +1499,21 @@ int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) l_queue_clear(mod->subs, NULL); l_queue_clear(mod->virtuals, unref_virt); +} + +int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) +{ + int status; + struct mesh_model *mod; + + mod = find_model(node, addr, id, &status); + if (!mod) + return status; + + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + + remove_subs(node, mod); if (!mod->cbs) /* External models */ @@ -1677,6 +1715,38 @@ void model_build_config(void *model, void *msg_builder) l_dbus_message_builder_leave_struct(builder); } +void mesh_model_enable_pub(struct mesh_model *mod, bool enable) +{ + mod->pub_enabled = enable; + + if (!mod->pub_enabled && mod->pub) { + if (mod->pub->virt) + unref_virt(mod->pub->virt); + + l_free(mod->pub); + mod->pub = NULL; + } +} + +bool mesh_model_is_pub_enabled(struct mesh_model *mod) +{ + return mod->pub_enabled; +} + +void mesh_model_enable_sub(struct mesh_node *node, struct mesh_model *mod, + bool enable) +{ + mod->sub_enabled = enable; + + if (!mod->sub_enabled) + remove_subs(node, mod); +} + +bool mesh_model_is_sub_enabled(struct mesh_model *mod) +{ + return mod->sub_enabled; +} + void mesh_model_init(void) { mesh_virtuals = l_queue_new(); diff --git a/mesh/model.h b/mesh/model.h index f8e0f9d37..f717fb00c 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -112,5 +112,11 @@ bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, uint32_t *opcode, uint16_t *n); void model_build_config(void *model, void *msg_builder); +void mesh_model_enable_pub(struct mesh_model *mod, bool enable); +bool mesh_model_is_pub_enabled(struct mesh_model *mod); +void mesh_model_enable_sub(struct mesh_node *node, struct mesh_model *mod, + bool enable); +bool mesh_model_is_sub_enabled(struct mesh_model *mod); + void mesh_model_init(void); void mesh_model_cleanup(void); diff --git a/mesh/node.c b/mesh/node.c index ee6d1833f..9f0f15070 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -386,6 +386,12 @@ static bool add_models_from_storage(struct mesh_node *node, if (!mod) return false; + if (!db_mod->pub_enabled) + mesh_model_enable_pub(mod, false); + + if (!db_mod->sub_enabled) + mesh_model_enable_sub(node, mod, false); + l_queue_insert(ele->models, mod, compare_model_id, NULL); } @@ -1041,65 +1047,99 @@ static void app_disc_cb(struct l_dbus *bus, void *user_data) free_node_dbus_resources(node); } -static bool get_sig_models_from_properties(struct node_element *ele, +static bool get_model_options(struct mesh_node *node, struct mesh_model *mod, + struct l_dbus_message_iter *opts) +{ + const char *key; + struct l_dbus_message_iter var; + bool opt; + + while (l_dbus_message_iter_next_entry(opts, &key, &var)) { + + if (!strcmp(key, "Publish")) { + if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) + return false; + mesh_model_enable_pub(mod, opt); + } else if (!strcmp(key, "Subscribe")) { + if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) + return false; + mesh_model_enable_sub(node, mod, opt); + } else + return false; + } + + return true; +} + +static bool generate_model(struct mesh_node *node, struct node_element *ele, + uint32_t id, struct l_dbus_message_iter *opts) +{ + struct mesh_model *mod; + + /* Disallow duplicates */ + if (l_queue_find(ele->models, match_model_id, + L_UINT_TO_PTR(id))) + return false; + + mod = mesh_model_new(ele->idx, id); + + if (!get_model_options(node, mod, opts)) { + l_free(mod); + return false; + } + + l_queue_insert(ele->models, mod, compare_model_id, NULL); + + return true; +} + +static bool get_sig_models_from_properties(struct mesh_node *node, + struct node_element *ele, struct l_dbus_message_iter *property) { - struct l_dbus_message_iter ids; - uint16_t mod_id; + struct l_dbus_message_iter mods, var; + uint16_t m_id; if (!ele->models) ele->models = l_queue_new(); - if (!l_dbus_message_iter_get_variant(property, "aq", &ids)) + if (!l_dbus_message_iter_get_variant(property, "a(qa{sv})", &mods)) return false; /* Bluetooth SIG defined models */ - while (l_dbus_message_iter_next_entry(&ids, &mod_id)) { - struct mesh_model *mod; - uint32_t id = mod_id | VENDOR_ID_MASK; + while (l_dbus_message_iter_next_entry(&mods, &m_id, &var)) { + uint32_t id = m_id | VENDOR_ID_MASK; /* Allow Config Server Model only on the primary element */ if (ele->idx != PRIMARY_ELE_IDX && id == CONFIG_SRV_MODEL) return false; - /* Disallow duplicates */ - if (l_queue_find(ele->models, match_model_id, - L_UINT_TO_PTR(id))) + if (!generate_model(node, ele, id, &var)) return false; - - mod = mesh_model_new(ele->idx, id); - - l_queue_insert(ele->models, mod, compare_model_id, NULL); } return true; } -static bool get_vendor_models_from_properties(struct node_element *ele, +static bool get_vendor_models_from_properties(struct mesh_node *node, + struct node_element *ele, struct l_dbus_message_iter *property) { - struct l_dbus_message_iter ids; - uint16_t mod_id, vendor_id; + struct l_dbus_message_iter mods, var; + uint16_t m_id, v_id; if (!ele->models) ele->models = l_queue_new(); - if (!l_dbus_message_iter_get_variant(property, "a(qq)", &ids)) + if (!l_dbus_message_iter_get_variant(property, "a(qqa{sv})", &mods)) return false; /* Vendor defined models */ - while (l_dbus_message_iter_next_entry(&ids, &vendor_id, &mod_id)) { - struct mesh_model *mod; - uint32_t id = mod_id | (vendor_id << 16); + while (l_dbus_message_iter_next_entry(&mods, &v_id, &m_id, &var)) { + uint32_t id = m_id | (v_id << 16); - /* Disallow duplicates */ - if (l_queue_find(ele->models, match_model_id, - L_UINT_TO_PTR(id))) + if (!generate_model(node, ele, id, &var)) return false; - - mod = mesh_model_new(ele->idx, id); - - l_queue_insert(ele->models, mod, compare_model_id, NULL); } return true; @@ -1130,14 +1170,19 @@ static bool get_element_properties(struct mesh_node *node, const char *path, } else if (!strcmp(key, "Models")) { - if (mods || !get_sig_models_from_properties(ele, &var)) + if (mods) + goto fail; + + if (!get_sig_models_from_properties(node, ele, &var)) goto fail; mods = true; } else if (!strcmp(key, "VendorModels")) { - if (vendor_mods || - !get_vendor_models_from_properties(ele, &var)) + if (vendor_mods) + goto fail; + + if (!get_vendor_models_from_properties(node, ele, &var)) goto fail; vendor_mods = true; @@ -1225,7 +1270,8 @@ static void convert_node_to_storage(struct mesh_node *node, db_mod->id = mod_id; db_mod->vendor = ((mod_id & VENDOR_ID_MASK) != VENDOR_ID_MASK); - + db_mod->pub_enabled = mesh_model_is_pub_enabled(mod); + db_mod->sub_enabled = mesh_model_is_sub_enabled(mod); l_queue_push_tail(db_ele->models, db_mod); } l_queue_push_tail(db_node->elements, db_ele); @@ -1381,6 +1427,63 @@ static void update_composition(struct mesh_node *node, struct mesh_node *attach) attach->comp = node->comp; } +static void update_model_options(struct mesh_node *node, + struct mesh_node *attach) +{ + uint32_t len, i; + struct node_element *ele, *ele_attach; + + len = l_queue_length(node->elements); + + for (i = 0; i < len; i++) { + const struct l_queue_entry *entry; + + ele = l_queue_find(node->elements, match_element_idx, + L_UINT_TO_PTR(i)); + ele_attach = l_queue_find(attach->elements, match_element_idx, + L_UINT_TO_PTR(i)); + if (!ele || !ele_attach) + continue; + + entry = l_queue_get_entries(ele->models); + + for (; entry; entry = entry->next) { + struct mesh_model *mod, *updated_mod = entry->data; + uint32_t id = mesh_model_get_model_id(updated_mod); + bool opt, updated_opt; + bool vendor = id < VENDOR_ID_MASK; + + mod = l_queue_find(ele_attach->models, match_model_id, + L_UINT_TO_PTR(id)); + if (!mod) + continue; + + if (!vendor) + id &= ~VENDOR_ID_MASK; + + opt = mesh_model_is_pub_enabled(mod); + updated_opt = mesh_model_is_pub_enabled(updated_mod); + + if (updated_opt != opt) { + mesh_model_enable_pub(mod, updated_opt); + mesh_config_model_pub_enable(attach->cfg, + attach->primary + i, id, + vendor, updated_opt); + } + + opt = mesh_model_is_sub_enabled(mod); + updated_opt = mesh_model_is_sub_enabled(updated_mod); + + if (updated_opt != opt) { + mesh_model_enable_sub(node, mod, updated_opt); + mesh_config_model_sub_enable(attach->cfg, + attach->primary + i, id, + vendor, updated_opt); + } + } + } +} + static bool check_req_node(struct managed_obj_request *req) { uint8_t node_comp[MAX_MSG_LEN - 2]; @@ -1452,6 +1555,7 @@ static bool attach_req_node(struct mesh_node *attach, struct mesh_node *node) node->owner = NULL; update_composition(node, attach); + update_model_options(node, attach); node_remove(node); -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id yJKPJKKI+176FwAA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 20:46:58 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id YPj8IqKI+16QogAAlScrYA (envelope-from ); Tue, 30 Jun 2020 20:46:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E76454F1AC; Tue, 30 Jun 2020 20:46:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726741AbgF3Sqh (ORCPT + 1 other); Tue, 30 Jun 2020 14:46:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726611AbgF3Sqf (ORCPT ); Tue, 30 Jun 2020 14:46:35 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B20F2C061755 for ; Tue, 30 Jun 2020 11:46:35 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id g67so9459293pgc.8 for ; Tue, 30 Jun 2020 11:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1FgQAnwFRb0SbuGIiJ1g2NGG0KnctO//2a2EL3+ivRY=; b=GaJ1mEru3nSXAtMvW7DyRFUK0ctXtZwpM2jc8aD/rt8xt9U3FBBhrjk4MoAxNK8fXU njBZPDVMm14/Q563shxWzDscFUo8sFS0w+fhNO5NMGcldcsFOM+HbuS4NzD/6GdNFioo y7r+vYAcS5f2O8UwcYvQG5q/E6r3HlkAI/Jhw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1FgQAnwFRb0SbuGIiJ1g2NGG0KnctO//2a2EL3+ivRY=; b=jACLIxdAlVs9igBmCx7OhmC4fSXsZ3ZXv7SSuYFUnebta8TYlx1+lAkNkxXTM+bZ+n 7L03GeThSCo5eRb1B2D5uB+ONvjzjuuRoPh6LcGc89Tn9JRtyNsGbKOnDPpyMUxjNnta CUYQI6PwDBCiS+nX9uySNgGwPYU1TUbO77+jkHybILOhQhCI/disvG87pMpqm3zSbFK+ kFjOAuoHZzLuyOqac6TtaJqfEF9+2rdnq9kLoIavhfqR9LZH35yter3JETql0A3Lhmx3 cYW5889/pR20cVbTCKF4mwGpBzrO98fxwAnIBRzFfNBtJ1Dn3NJiAVp1SKvW6r1IvNbS y0xg== X-Gm-Message-State: AOAM531RBT1fvJijz+gzD42Eff0vf8m8hBctw01V9rnE5+MD3BLi5Q3O TOX9oIclco+FM+WjlFrKU+N3kKYJ78A= X-Google-Smtp-Source: ABdhPJxjNzsJTaS4QWJcts+5c6Ix9KTR0kIMPzWLISnTonBdPW88+5h20uOMnVWMXi8JpToDU228bw== X-Received: by 2002:a63:e114:: with SMTP id z20mr14165925pgh.300.1593542795031; Tue, 30 Jun 2020 11:46:35 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:b7e2:9910:bd78:608d]) by smtp.gmail.com with ESMTPSA id x10sm3488663pfp.80.2020.06.30.11.46.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jun 2020 11:46:33 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka Subject: [PATCH v2] client: Add battery command Date: Tue, 30 Jun 2020 11:46:29 -0700 Message-Id: <20200630184629.95013-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 19 X-Rspamd-Score: 2.87 / 15.00 / 200.00 X-Rspamd-Queue-Id: E76454F1AC X-Rspamd-UID: 08f256 This adds the "battery" command to show battery information of a peer device based on org.bluez.Battery1 API. Example usage: [bluetooth]# battery XX:XX:XX:XX:XX:XX Percentage: 100% --- client/main.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/client/main.c b/client/main.c index 422da5593..8c1ed00fb 100644 --- a/client/main.c +++ b/client/main.c @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; static GDBusProxy *default_dev; static GDBusProxy *default_attr; static GList *ctrl_list; +static GList *battery_proxies; static const char *agent_arguments[] = { "on", @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) bt_shell_set_prompt(PROMPT_OFF); g_list_free_full(ctrl_list, proxy_leak); + g_list_free_full(battery_proxies, proxy_leak); ctrl_list = NULL; + battery_proxies = NULL; default_ctrl = NULL; } @@ -445,6 +448,16 @@ done: g_free(desc); } +static void battery_added(GDBusProxy *proxy) +{ + battery_proxies = g_list_append(battery_proxies, proxy); +} + +static void battery_removed(GDBusProxy *proxy) +{ + battery_proxies = g_list_remove(battery_proxies, proxy); +} + static void device_added(GDBusProxy *proxy) { DBusMessageIter iter; @@ -539,6 +552,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) gatt_add_manager(proxy); } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { ad_manager_added(proxy); + } else if (!strcmp(interface, "org.bluez.Battery1")) { + battery_added(proxy); } } @@ -630,6 +645,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) gatt_remove_manager(proxy); } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { ad_unregister(dbus_conn, NULL); + } else if (!strcmp(interface, "org.bluez.Battery1")) { + battery_removed(proxy); } } @@ -763,6 +780,20 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) return NULL; } +static GDBusProxy *find_battery_by_path(GList *source, const char *path) +{ + GList *list; + + for (list = g_list_first(source); list; list = g_list_next(list)) { + GDBusProxy *proxy = list->data; + + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) + return proxy; + } + + return NULL; +} + static GDBusProxy *find_proxy_by_address(GList *source, const char *address) { GList *list; @@ -1650,6 +1681,35 @@ static void cmd_info(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_SUCCESS); } +static void cmd_battery(int argc, char *argv[]) +{ + DBusMessageIter iter; + GDBusProxy *device_proxy; + GDBusProxy *battery_proxy; + unsigned char percentage; + + device_proxy = find_device(argc, argv); + if (!device_proxy) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + battery_proxy = find_battery_by_path(battery_proxies, + g_dbus_proxy_get_path(device_proxy)); + if (!battery_proxy) { + bt_shell_printf("Device %s does not have battery information\n", + argv[1]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (g_dbus_proxy_get_property(battery_proxy, "Percentage", &iter) == + FALSE) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + dbus_message_iter_get_basic(&iter, &percentage); + bt_shell_printf("Percentage: %d%%\n", percentage); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + static void pair_reply(DBusMessage *message, void *user_data) { DBusError error; @@ -2785,6 +2845,8 @@ static const struct bt_shell_menu main_menu = { dev_generator }, { "disconnect", "[dev]", cmd_disconn, "Disconnect device", dev_generator }, + { "battery", "[dev]", cmd_battery, "Show device battery", + dev_generator }, { } }, }; -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id OPayI9mK+15NRQAA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 20:56:25 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wMkcItmK+14BrgAAlScrYA (envelope-from ); Tue, 30 Jun 2020 20:56:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3C13952B30; Tue, 30 Jun 2020 20:56:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726237AbgF3S4U (ORCPT + 1 other); Tue, 30 Jun 2020 14:56:20 -0400 Received: from mga05.intel.com ([192.55.52.43]:57132 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726207AbgF3S4T (ORCPT ); Tue, 30 Jun 2020 14:56:19 -0400 IronPort-SDR: kBZjAsK7k+1S+EQEPzg2mXLjMwHjoERIqdZuuzFBHklp/sXHJlpQdyoHGVyjp7TBqcAfjtFUvI 3XKSGwsVDY/A== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="231222951" X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="231222951" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 11:56:19 -0700 IronPort-SDR: t4lCX5bdzNGY2n6qKsUURRHzll4gyZzCU21OcFqodRPO2y3VNtsbYMBlBSQVbYV3u/jWUfMiAE qSYlksyx7+4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="355864248" Received: from mlindstr-mobl1.amr.corp.intel.com (HELO ingas-nuc1.sea.intel.com) ([10.254.108.27]) by orsmga001.jf.intel.com with ESMTP; 30 Jun 2020 11:56:18 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland Subject: [PATCH BlueZ v2 0/4] Add options to Models and VendorModels Date: Tue, 30 Jun 2020 11:56:13 -0700 Message-Id: <20200630185617.14755-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 39 X-Rspamd-Score: 5.97 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3C13952B30 X-Rspamd-UID: 928b4c v2: Changes constaned to patch 0002: - Fixed returned status in config pub/sub model calls - Consistent use of pub_enabled & sub_enabled in the code ************ If a model does not support either subscription mechanism, Config Server is supposed to return "Not a Subscribe Model" if a Config Client sends a subscription add/overwrite message. Similarly, if a model does not support publication, "Invalid Publish Parameters" should be returned in response to Publication Set message. Since config server is running even when an app is not attached, the only way to collect these model capabilities is on Attach, Join, Create, Import methods when the object manager collects app info. To address this issue, signatures for properties "Models" and "VendorModels" on Element interface change to include "options" dictionary: Models: signature change "aq" -> "a(qa{sv})" VendorModels: signature change "a(qq)" -> "a(qqa{sv})" The defined keywords for the options dictionary are: "Publish" - indicates whether the model supports publication mechanism. If not present, publication is enabled. "Subscribe" - indicates whether the model supports subscription mechanism. If not present, subscriptions are enabled. Inga Stotland (4): doc/mesh-api: Add dictionary to model properties mesh: Check app model settings of pub/sub support tools/mesh-cfgclient: Add options to "Models" property test/test-mesh: Add options to "Models" property doc/mesh-api.txt | 40 ++++++++-- mesh/mesh-config-json.c | 76 +++++++++++++++++- mesh/mesh-config.h | 8 ++ mesh/model.c | 98 +++++++++++++++++++---- mesh/model.h | 6 ++ mesh/node.c | 168 ++++++++++++++++++++++++++++++++-------- test/test-mesh | 21 ++--- tools/mesh-cfgclient.c | 25 ++++-- 8 files changed, 374 insertions(+), 68 deletions(-) -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id gJVxCt2K+14fTAAA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 20:56:29 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gDfgCN2K+15vRwEAgupzMw (envelope-from ); Tue, 30 Jun 2020 20:56:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AB96452227; Tue, 30 Jun 2020 20:56:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726385AbgF3S4U (ORCPT + 1 other); Tue, 30 Jun 2020 14:56:20 -0400 Received: from mga05.intel.com ([192.55.52.43]:57132 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726207AbgF3S4U (ORCPT ); Tue, 30 Jun 2020 14:56:20 -0400 IronPort-SDR: lSjb/vKyQfKfsiquppXIKvMymr3s/C6MqKMLtL4gOUKEigS4S5FfQX4vm5K5tIgj4ZkxQ41Wxx IePXfJPIJmnQ== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="231222955" X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="231222955" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 11:56:20 -0700 IronPort-SDR: L6rWgbEQzsSc2Y9vgiJc4OFQLTySxJd3KnZ2/HVDDGdQNaAUkOSSbOPDCpBGRDdcWLsgetYQ1f EtsSxNCbL9Rg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="355864252" Received: from mlindstr-mobl1.amr.corp.intel.com (HELO ingas-nuc1.sea.intel.com) ([10.254.108.27]) by orsmga001.jf.intel.com with ESMTP; 30 Jun 2020 11:56:20 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland Subject: [PATCH BlueZ v2 1/4] doc/mesh-api: Add dictionary to model properties Date: Tue, 30 Jun 2020 11:56:14 -0700 Message-Id: <20200630185617.14755-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200630185617.14755-1-inga.stotland@intel.com> References: <20200630185617.14755-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 31 X-Rspamd-Score: 4.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: AB96452227 X-Rspamd-UID: 6be081 This changes the signature of "Models" and "VendorModels" properties on org.bluez.mesh.Element1 interface to contain a dictionary with model options. Models: signature change "aq" -> "a(qa{sv})" VendorModels: signature change "a(qq)" -> "a(qqa{sv})" Currently, the defined keywords for the options dictionary are "Publish" - indicates whether the model supports publication mechanism. If not present, publication is enabled. "Subscribe" - indicates whether the model supports subscription mechanism. If not present, subscriptions are enabled. The dictionary allowed to be empty. --- doc/mesh-api.txt | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt index 3be11e342..495f95b0b 100644 --- a/doc/mesh-api.txt +++ b/doc/mesh-api.txt @@ -888,15 +888,43 @@ Properties: Element index. It is required that the application follows sequential numbering scheme for the elements, starting with 0. - array{uint16} Models [read-only] + array{(uint16 id, dict caps)} Models [read-only] - An array of SIG Model Identifiers. The array may be empty. + An array of SIG Models: - array{(uint16, uint16)} VendorModels [read-only] + id - SIG Model Identifier - An array of pairs (vendor, model ID): vendor is a 16-bit - Bluetooth-assigned Company ID as defined by Bluetooth SIG. - model ID is a 16-bit vendor-assigned Model Identifier + options - a dictionary that may contain additional model + info. The following keys are defined: + + boolean Publish - indicates whether the model + supports publication mechanism. If not + present, publication is enabled. + + boolean Subscribe - indicates whether the model + supports subscription mechanism. If not + present, subscriptons are enabled. + + The array may be empty. + + + array{(uint16 vendor, uint16 id, dict options)} VendorModels [read-only] + + An array of Vendor Models: + + vendor - a 16-bit Bluetooth-assigned Company ID as + defined by Bluetooth SIG. + + id - a 16-bit vendor-assigned Model Identifier + + options - a dictionary that may contain additional model + info. The following keys are defined: + + boolean Publish - indicates whether the model + supports publication mechanism + + boolean Subscribe - indicates whether the model + supports subscription mechanism The array may be empty. -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 0A7KLuCK+14fTAAA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 20:56:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ANFbLeCK+17krwAAlp8NpQ (envelope-from ); Tue, 30 Jun 2020 20:56:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 496F851A0B; Tue, 30 Jun 2020 20:56:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726382AbgF3S4W (ORCPT + 1 other); Tue, 30 Jun 2020 14:56:22 -0400 Received: from mga05.intel.com ([192.55.52.43]:57136 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726207AbgF3S4V (ORCPT ); Tue, 30 Jun 2020 14:56:21 -0400 IronPort-SDR: pWWsIlSY9yYBQ9umrtm7QeRcT3/LwP88zlya5ei2kS7IvR4LMRCTHRJsg9XNQs8utGtw9hJwZ/ Rm0A3l/dhXwA== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="231222957" X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="231222957" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 11:56:21 -0700 IronPort-SDR: H3VwgdpiP90NDUQW/Kkf8UERXuz4MoYIGKnnK2zDB8kdRRpqZ66IvLVraAWKwwCDpQ3A/wUAox DGK1UK+OJ4RQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="355864259" Received: from mlindstr-mobl1.amr.corp.intel.com (HELO ingas-nuc1.sea.intel.com) ([10.254.108.27]) by orsmga001.jf.intel.com with ESMTP; 30 Jun 2020 11:56:21 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland Subject: [PATCH BlueZ v2 3/4] tools/mesh-cfgclient: Add options to "Models" property Date: Tue, 30 Jun 2020 11:56:16 -0700 Message-Id: <20200630185617.14755-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200630185617.14755-1-inga.stotland@intel.com> References: <20200630185617.14755-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 19 X-Rspamd-Score: 2.97 / 15.00 / 200.00 X-Rspamd-Queue-Id: 496F851A0B X-Rspamd-UID: 94f428 This adds options dictionary to "Models" property to stay in sync with mesh-api changes. --- tools/mesh-cfgclient.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 0dd02fad8..59f079213 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -1448,14 +1448,26 @@ static void proxy_removed(struct l_dbus_proxy *proxy, void *user_data) } } +static void build_model(struct l_dbus_message_builder *builder, uint16_t mod_id, + bool pub_enable, bool sub_enable) +{ + l_dbus_message_builder_enter_struct(builder, "qa{sv}"); + l_dbus_message_builder_append_basic(builder, 'q', &mod_id); + l_dbus_message_builder_enter_array(builder, "{sv}"); + append_dict_entry_basic(builder, "Subscribe", "b", &sub_enable); + append_dict_entry_basic(builder, "Publish", "b", &pub_enable); + l_dbus_message_builder_leave_array(builder); + l_dbus_message_builder_leave_struct(builder); +} + static bool mod_getter(struct l_dbus *dbus, struct l_dbus_message *message, struct l_dbus_message_builder *builder, void *user_data) { - l_dbus_message_builder_enter_array(builder, "q"); - l_dbus_message_builder_append_basic(builder, 'q', &app.ele.mods[0]); - l_dbus_message_builder_append_basic(builder, 'q', &app.ele.mods[1]); + l_dbus_message_builder_enter_array(builder, "(qa{sv})"); + build_model(builder, app.ele.mods[0], false, false); + build_model(builder, app.ele.mods[1], false, false); l_dbus_message_builder_leave_array(builder); return true; @@ -1466,7 +1478,7 @@ static bool vmod_getter(struct l_dbus *dbus, struct l_dbus_message_builder *builder, void *user_data) { - l_dbus_message_builder_enter_array(builder, "(qq)"); + l_dbus_message_builder_enter_array(builder, "(qqa{sv})"); l_dbus_message_builder_leave_array(builder); return true; @@ -1517,9 +1529,10 @@ static void setup_ele_iface(struct l_dbus_interface *iface) /* Properties */ l_dbus_interface_property(iface, "Index", 0, "y", ele_idx_getter, NULL); - l_dbus_interface_property(iface, "VendorModels", 0, "a(qq)", + l_dbus_interface_property(iface, "VendorModels", 0, "a(qqa{sv})", vmod_getter, NULL); - l_dbus_interface_property(iface, "Models", 0, "aq", mod_getter, NULL); + l_dbus_interface_property(iface, "Models", 0, "a(qa{sv})", mod_getter, + NULL); /* Methods */ l_dbus_interface_method(iface, "DevKeyMessageReceived", 0, -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qGulAPle/F76kAAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 12:01:29 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aEBFOvhe/F65wgAAlp8NpQ (envelope-from ); Wed, 01 Jul 2020 12:01:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D5C8AA3120; Wed, 1 Jul 2020 12:01:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729671AbgGAKBL (ORCPT + 1 other); Wed, 1 Jul 2020 06:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBK (ORCPT ); Wed, 1 Jul 2020 06:01:10 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77D7AC061755 for ; Wed, 1 Jul 2020 03:01:10 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id bf7so395861plb.2 for ; Wed, 01 Jul 2020 03:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yhFm8iVS8rF216LAKKaefGhuvOqn0g+HGfEb++sXEKQ=; b=hdiqcRc63sJZg87JBlBrYqCN/EuvRLRr0Q4xTHYcPEY9fft8NYzC2mYjSkPb0Qckuo Y0JTvEVd8gCB/G5u2kjcb2UuGtX1RIt6wKbw4JsPlFUig1okeouA/Xeo21DMwZrqg48C dh104Na4SW6oTFpa+TbntOVTraqSRcpvtGQ8TF/ffnA9qYg2wN+gpHo9U6D0UV4KnWk9 USuRhIWhUewFnDewVPLfnjEOe5s+tWWl1kjel0RDZrViNkR0ib6toF/9/qCZGUNWdSAX akfIJcyu4KqDEgRA4kYBuEmpXXGrUPL6YrIZ8NfPvkbQWNc0rk08bgqrXM+JcWq5Jy8G dg6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yhFm8iVS8rF216LAKKaefGhuvOqn0g+HGfEb++sXEKQ=; b=pC++NKP8GJ+iDGTLawS5aq4t3Ze7NW+/mOqX9qJK5zqk4cbi2w82UZnIlJIW7pmJ3g gJGezxI50bYIMiqEGGqy+W0gqWvl45zbf4dRDwi1MxYNTR/DX/4PF3inMeL0BfUkXNTl 6MiBJw8csA91zObaU0VQXpvRcnLQjlQNbtvUqJ0FNOFhGXkd6vmTSYQjfFgAw76DDK60 wS0kwKuIte5+OsTQDtkcqxv7Z+q4aIMqI635ZIwLzPusFdshKsGdhNpwln4CKCjaf3yT WO1POidvXh/GCEqgfwjnn85o9i0so7d35kiPxft0g5XLkRnhwVZt6A7enSkib91vp677 fRfg== X-Gm-Message-State: AOAM53027R8/PEELBJj/UJiBK9ujHlpW+l8TV2Atl7cN6U2/59PCjjbs +d0OuHczDsCs/cTgDiO6s5OLSm2zHQYvCw== X-Google-Smtp-Source: ABdhPJz7pjDPMPwQk2aqCNZQcc80MO49nb4IBfUbOY0va6SS7YJlExR/vVF6IWntveQ/hYHOadll0w== X-Received: by 2002:a17:902:7204:: with SMTP id ba4mr20563799plb.250.1593597669730; Wed, 01 Jul 2020 03:01:09 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:09 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v2 2/8] Bluetooth: Configure controller address resolution if available Date: Wed, 1 Jul 2020 15:34:26 +0530 Message-Id: <20200701100432.28038-3-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: D5C8AA3120 X-Rspamd-UID: a1e08a From: Marcel Holtmann When the LL Privacy support is available, then as part of enabling or disabling passive background scanning, it is required to set up the controller based address resolution as well. Since only passive background scanning is utilizing the whitelist, the address resolution is now bound to the whitelist and passive background scanning. All other resolution can be easily done by the host stack. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_request.c | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 836dc997ff94..915f7a48bfaa 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1358,6 +1358,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn); #define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \ ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED)) +/* Use LL Privacy based address resolution if supported */ +#define use_ll_privacy(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY) + /* Use ext scanning if set ext scan param and ext scan enable is supported */ #define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \ ((dev)->commands[37] & 0x40)) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 116207009dde..5978f9177b3d 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -675,6 +675,12 @@ void hci_req_add_le_scan_disable(struct hci_request *req) cp.enable = LE_SCAN_DISABLE; hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + __u8 enable = 0x00; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } } static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, @@ -815,7 +821,8 @@ static bool scan_use_rpa(struct hci_dev *hdev) } static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, - u16 window, u8 own_addr_type, u8 filter_policy) + u16 window, u8 own_addr_type, u8 filter_policy, + bool addr_resolv) { struct hci_dev *hdev = req->hdev; @@ -824,6 +831,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } + if (use_ll_privacy(hdev) && addr_resolv) { + u8 enable = 0x01; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } + /* Use ext scanning if set ext scan param and ext scan enable is * supported */ @@ -897,12 +909,18 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, } } +/* Ensure to call hci_req_add_le_scan_disable() first to disable the + * controller based address resolution to be able to reconfigure + * resolving list. + */ void hci_req_add_le_passive_scan(struct hci_request *req) { struct hci_dev *hdev = req->hdev; u8 own_addr_type; u8 filter_policy; u16 window, interval; + /* Background scanning should run with address resolution */ + bool addr_resolv = true; if (hdev->scanning_paused) { bt_dev_dbg(hdev, "Scanning is paused for suspend"); @@ -948,7 +966,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) bt_dev_dbg(hdev, "LE passive scan with whitelist = %d", filter_policy); hci_req_start_scan(req, LE_SCAN_PASSIVE, interval, window, - own_addr_type, filter_policy); + own_addr_type, filter_policy, addr_resolv); } static u8 get_adv_instance_scan_rsp_len(struct hci_dev *hdev, u8 instance) @@ -2747,6 +2765,8 @@ static int active_scan(struct hci_request *req, unsigned long opt) u8 own_addr_type; /* White list is not used for discovery */ u8 filter_policy = 0x00; + /* Discovery doesn't require controller address resolution */ + bool addr_resolv = false; int err; BT_DBG("%s", hdev->name); @@ -2768,7 +2788,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) own_addr_type = ADDR_LE_DEV_PUBLIC; hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, DISCOV_LE_SCAN_WIN, - own_addr_type, filter_policy); + own_addr_type, filter_policy, addr_resolv); return 0; } -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id mInXFanB+15btQEA0J78UA (envelope-from ) for ; Wed, 01 Jul 2020 00:50:17 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ACVnFKnB+16vswEAlp8NpQ (envelope-from ); Wed, 01 Jul 2020 00:50:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0DC44A1306; Wed, 1 Jul 2020 00:50:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726352AbgF3WuL (ORCPT + 1 other); Tue, 30 Jun 2020 18:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726117AbgF3WuL (ORCPT ); Tue, 30 Jun 2020 18:50:11 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1DEFC061755 for ; Tue, 30 Jun 2020 15:50:10 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id bf1so8104657pjb.6 for ; Tue, 30 Jun 2020 15:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=cVROIil0P6Me4UmNrUmy9jeA88aHofdQBlO7lyf+/O4=; b=JB5A5Jb4NzllbO3m0+J+h8eiJURMMGVIg8h38t7RXOLWdMsrzuYRffbM/qDQngEqTl UG+PX6i0+sZd+JDt04t2SNIQIEkMlniucDCCEWbKibfXbCiSg/JmkLXC2CI7Np9PekGs kQQDrXnIK+btDZNy8XZ1ceh3Eg5lB1x7rEESWjINfys+GFaUIT03pmpLbxIbOwL1aMOa inh9VYk4uA8F1VM0Wq+l4dAwAZ9PDf51kgN9HDogFVPbSW7AVs9GqXj8NJXVYBsM8yFO A4BRYCAAwUc2/300YO1Lq3RnruZ+95UhfMob0dxGNthQyVupegOiTtn3rDM2hNEJLyJg abFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=cVROIil0P6Me4UmNrUmy9jeA88aHofdQBlO7lyf+/O4=; b=m5vz85Yvs2aJ2Gw/eabf2msDvliemihwnU+/UAgoNu4w54BgD1ot3P9koWY6rTZ0lF K3/0cRJQIn0vGVfPXsRKJOcdL+4pANy1DFsSvZpD2oDi2RiONexSyPQCNWp++7fXEnFd HPtYDn/hic1hkte+9/c2m0csok+l9HWoX1tpvfJryZiNo+TaGiNNpoNV4WNKcvZre3pr YTKDqtp4Gac1ggzouiaa9Ww5X9agjXdqHQmkc+J20IW67o+uxLSQuLBP3k3enu6Is6cI yqawMlFfWeu3OX5Yu+D60WIxfwzx+PKOG6NwmRQh56vayBSx+03chO9k6C8tp+x58Nvv 5LSw== X-Gm-Message-State: AOAM5336n8xfazDsRfIXQ+axZj+1AjM3enplRfwVjCRv8DBmHkipTWvE xiJjgPDSjr88niOIwfZ2YoxbzpP9UlSPWGr2/w1y06znZtFGnCkqHsx8EMud5/O+G9VZ0NlYtyY hxuml/XO9dR986fQhN7O2Ly9IrOJZdpw7pgP88a4vi1wSvU5ujs076qybc/btQimNOo8T5VFvnf kA X-Google-Smtp-Source: ABdhPJxGTayO9mHc2L7BN83AOy4exVzxM5TTUN0K8NJUCMXZRLcaLVJ+HDlkjIyGVI8zq78hdSCnDyKW48qs X-Received: by 2002:a62:2c54:: with SMTP id s81mr15503821pfs.252.1593557410362; Tue, 30 Jun 2020 15:50:10 -0700 (PDT) Date: Tue, 30 Jun 2020 15:49:34 -0700 Message-Id: <20200630154855.Bluez.v1.1.I63c3ddd54189c2ad9ca9aba2c08e0925d7f0aee3@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [Bluez PATCH v1] device - If HFP is supported, ignore HSP From: Yu Liu To: linux-bluetooth@vger.kernel.org Cc: Hsin-Yu Chao , Sonny Sasaka Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.13 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0DC44A1306 X-Rspamd-UID: ebc8ad From: Hsin-Yu Chao For a BT headset that supports both HSP and HFP, BlueZ creates service instances for these two profiles and connects them. It's uncertain that which of HSP and HFP eventually get connected and being used for SCO audio. And we start observing some problem because of this uncertainty: - For headset that supports WBS, we need HFP connect for codec negotiation. If HSP connects but not HFP, WBS cannot be used. - For WH-1000XM3, if BlueZ ever initiated HFP connection but failed, headset won't have working SCO audio even HSP is connected. Fix this at when device probes services, if HFP is in the uuid list, don't bother create one for HSP. Reviewed-by: Sonny Sasaka --- Changes in v1: - Initial change src/device.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/device.c b/src/device.c index 7b0eb256e..4036bfd81 100644 --- a/src/device.c +++ b/src/device.c @@ -4370,6 +4370,11 @@ static struct btd_service *probe_service(struct btd_device *device, if (!device_match_profile(device, profile, uuids)) return NULL; + /* If device supports HFP, don't bother create service for HSP. */ + if (g_slist_find_custom(uuids, HFP_HS_UUID, bt_uuid_strcmp) && + bt_uuid_strcmp(profile->remote_uuid, HSP_HS_UUID) == 0) + return NULL; + l = find_service_with_profile(device->services, profile); if (l) return l->data; -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id MOekINgz/F6/hgAA0J78UA (envelope-from ) for ; Wed, 01 Jul 2020 08:57:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id cI3ZHtgz/F5rVgEA0J78UA (envelope-from ); Wed, 01 Jul 2020 08:57:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=messagingengine.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 67BE7A1FE5; Wed, 1 Jul 2020 08:57:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727988AbgGAG5T (ORCPT + 1 other); Wed, 1 Jul 2020 02:57:19 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:45337 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726144AbgGAG5T (ORCPT ); Wed, 1 Jul 2020 02:57:19 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C4B145C00AC for ; Wed, 1 Jul 2020 02:57:13 -0400 (EDT) Received: from imap21 ([10.202.2.71]) by compute4.internal (MEProxy); Wed, 01 Jul 2020 02:57:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=JFxFGJJfXwbBZtz+yoOLPno+dfL+0 fxmEz+x8jhQJVc=; b=GKcSyzMTfkkctedwp6NwCoUDjaWmEaW3eBpq5gmRuJumK ZanjGZifM4FrYYskL2apQwfIbPfIxgZGJ5Z4nJwO5WmiMBUaIoBRujBnRqQvYTF0 KJ0QX87N2L1HVDdDVifd0JmAUCsBraGzaCN2iZuIA8cwC0xnTH3snw/zxA5WDrTz 8gyHDWDBnrHkJjeQ8cUQfNPoXhk98LO/q+bvwAHL8MBNrm7UOX2+4TICOcwV4i/y Sn9UdAb8Nal5rz8gj8/fNmWaNwfpxR0YnsdnXLazMuop+IvcR+FX4LMf0KO1UsJ0 da505klKcUsuPPlcmQXm1i8iQKd1p2WHBGdO8sYxA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrtddugdduudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfffhffvufgtsehmtderre erredtnecuhfhrohhmpedfffgrvhhiugcutehrrhhohihofdcuoegurhhohihosegrqhif rghrihdrnhgvtheqnecuggftrfgrthhtvghrnhepieeigfeuffevheduvedtuedvgfeiie effefgheffuedtieejueetuefhffeljedtnecuffhomhgrihhnpehkvghrnhgvlhdrohhr ghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurh hohihosegrqhifrghrihdrnhgvth X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8529E66007F; Wed, 1 Jul 2020 02:57:13 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-dev0-576-gfe2cd66-fm-20200629.001-gfe2cd668 Mime-Version: 1.0 Message-Id: <8fd0b6bd-9570-4841-ba6f-dbb74d93b1d2@www.fastmail.com> Date: Wed, 01 Jul 2020 02:56:24 -0400 From: "David Arroyo" To: linux-bluetooth@vger.kernel.org Subject: Segfault in bluetoothd on mouse connection Content-Type: multipart/mixed; boundary=1b501d68867e4954a0fb4b765137a701 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 8 X-Rspamd-Score: 1.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: 67BE7A1FE5 X-Rspamd-UID: 5e052d --1b501d68867e4954a0fb4b765137a701 Content-Type: text/plain I have a "3D connexion cadmouse pro wireless" that reliably causes bluetoothd to segfault whenever I put it into pairing mode. Attached is debug output from bluetoothd, along with a btmon trace, and a stack trace. I haven't the slightest idea how bluetooth (or bluez, for that matter) works, so any assistance would be appreciated. I stepped through a core dump with gdb. The segfault is from "io" being null, here: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/btio/btio.c?h=5.53&id=1524499483a3678951c0e3059b158836398c4e9b#n105 This is called as part of the report_map_read_cb callback and appears to be in response to a BT_ATT_OP_READ_BLOB_RSP opcode from the mouse. There are three such frames in the btmon trace, but I don't know which one was the trigger. I'm thinking this is a simple matter of adding a null guard to report_map_read_cb , but I wonder if this mouse is doing anything weird that will cause problems even after I fix this. Sincerely, David --1b501d68867e4954a0fb4b765137a701 Content-Disposition: attachment;filename="cadmouse.snoop" Content-Type: application/octet-stream; name="cadmouse.snoop" Content-Transfer-Encoding: BASE64 YnRzbm9vcAAAAAABAAAH0QAAAB4AAAAe//8ADAAAAAAA4ocM9HZuAUxpbnV4IHZlcnNpb24g NS40LjQ4ICh4ODZfNjQpAAAAACEAAAAh//8ADAAAAAAA4ocM9HZuCEJsdWV0b290aCBzdWJz eXN0ZW0gdmVyc2lvbiAyLjIyAAAAABAAAAAQAAAAAAAAAAAA4ocM9HZuCQABYhKFy1IwaGNp MAAAAAAAAAAAAAAAAAAAAAgAAAAAAOKHDPR2bgsAAAAIAAAACAAAAAoAAAAAAOKHDPR2bgxi EoXLUjAPAAAAAB4AAAAe//8ADgAAAAAA4ocM9HZuDwEAAAACAAEOAAEAAAAQYmx1ZXRvb3Ro ZAAAAAAAAAAAAB4AAAAe//8ADgAAAAAA4ocM9HZu9wIAAAACAAEOAAEAAAAQYnRtb24AAAAA AAAAAAAAAAAAAA4AAAAOAAAAAwAAAAAA4ocM9NHygT4MAgEBAbenIPrYzgCZAAAABQAAAAUA AAACAAAAAADihwz00fMEDCACAAAAAAAGAAAABgAAAAMAAAAAAOKHDPTR/i8OBAEMIAAAAAAc AAAAHAAAAAIAAAAAAOKHDPTR/n0NIBlgAGAAAAG3pyD62M4ACAAJACwALAEAAAAAAAAABgAA AAYAAAADAAAAAADihwz00gHtDwQAAQ0gAAAAFQAAABUAAAADAAAAAADihwz00n8SPhMBAEAA AAG3pyD62M4JACwALAEFAAAAEwAAABMAAAARAAAAAADihwz00n9TAgAAAAsAt6cg+tjOAgAA AAAAAAAAABMAAAATAAAAEQAAAAAA4ocM9NJ/UwEAAAALALenIPrYzgIAAAAAAAAAAAAFAAAA BQAAAAIAAAAAAOKHDPTSgEsWIAJAAAAAAAYAAAAGAAAAAwAAAAAA4ocM9NKC0A8EAAEWIAAA AGIAAABi//8ADQAAAAAA4ocM9NKFUwcLYmx1ZXRvb3RoZABzcmMvYWRhcHRlci5jOmNvbm5l Y3RlZF9jYWxsYmFjaygpIGhjaTAgZGV2aWNlIENFOkQ4OkZBOjIwOkE3OkI3IGNvbm5lY3Rl ZCBlaXJfbGVuIDAAAAAADgAAAA4AAAADAAAAAADihwz005hlPgwEPkAAHwAAAAAAAAAAAAAG AAAABgAAAAMAAAAAAOKHDPTTnBMFBABAAD4AAAAOAAAADgAAABEAAAAAAOKHDPTTnGQCAAAA DAC3pyD62M4CAAAAAA4AAAAOAAAAEQAAAAAA4ocM9NOcZAEAAAAMALenIPrYzgIAAAAAXgAA AF7//wANAAAAAADihwz00587BwtibHVldG9vdGhkAHNyYy9hZGFwdGVyLmM6ZGV2X2Rpc2Nv bm5lY3RlZCgpIERldmljZSBDRTpEODpGQToyMDpBNzpCNyBkaXNjb25uZWN0ZWQsIHJlYXNv biAwAAAAADgAAAA4//8ADQAAAAAA4ocM9NOfZQcLYmx1ZXRvb3RoZABzcmMvYWRhcHRlci5j OmFkYXB0ZXJfcmVtb3ZlX2Nvbm5lY3Rpb24oKSAAAAAANwAAADf//wANAAAAAADihwz005+H BwtibHVldG9vdGhkAHBsdWdpbnMvcG9saWN5LmM6ZGlzY29ubmVjdF9jYigpIHJlYXNvbiAw AAAAAGYAAABm//8ADQAAAAAA4ocM9NOfpgcLYmx1ZXRvb3RoZABzcmMvYWRhcHRlci5jOmJv bmRpbmdfYXR0ZW1wdF9jb21wbGV0ZSgpIGhjaTAgYmRhZGRyIENFOkQ4OkZBOjIwOkE3OkI3 IHR5cGUgMiBzdGF0dXMgMHhlAAAAAE4AAABO//8ADQAAAAAA4ocM9NOfxwcLYmx1ZXRvb3Ro ZABzcmMvZGV2aWNlLmM6ZGV2aWNlX2JvbmRpbmdfY29tcGxldGUoKSBib25kaW5nIChuaWwp IHN0YXR1cyAweDBlAAAAADwAAAA8//8ADQAAAAAA4ocM9NOf5QcLYmx1ZXRvb3RoZABzcmMv ZGV2aWNlLmM6ZGV2aWNlX2JvbmRpbmdfZmFpbGVkKCkgc3RhdHVzIDE0AAAAAC8AAAAv//8A DQAAAAAA4ocM9NOgAgcLYmx1ZXRvb3RoZABzcmMvYWRhcHRlci5jOnJlc3VtZV9kaXNjb3Zl cnkoKSAAAAAACgAAAAoAAAACAAAAAADihwz007TICyAHAGAAMAAAAAAAAAYAAAAGAAAAAwAA AAAA4ocM9NO3aw4EAQsgAAAAAAUAAAAFAAAAAgAAAAAA4ocM9NO3ygwgAgEBAAAABgAAAAYA AAADAAAAAADihwz007tUDgQBDCAAAAAADgAAAA4AAAADAAAAAADihwz1Ajn/PgwCAQEBt6cg +tjOAJkAAAAFAAAABQAAAAIAAAAAAOKHDPUCOo0MIAIAAAAAAAYAAAAGAAAAAwAAAAAA4ocM 9QJFsA4EAQwgAAAAABwAAAAcAAAAAgAAAAAA4ocM9QJGEA0gGWAAYAAAAbenIPrYzgAIAAkA LAAsAQAAAAAAAAAGAAAABgAAAAMAAAAAAOKHDPUCSZoPBAABDSAAAAAVAAAAFQAAAAMAAAAA AOKHDPUCXTE+EwEAQAAAAbenIPrYzgkALAAsAQUAAAATAAAAEwAAABEAAAAAAOKHDPUCXW8C AAAACwC3pyD62M4CAAAAAAAAAAAAEwAAABMAAAARAAAAAADihwz1Al1vAQAAAAsAt6cg+tjO AgAAAAAAAAAAAAUAAAAFAAAAAgAAAAAA4ocM9QJeJRYgAkAAAAAAYgAAAGL//wANAAAAAADi hwz1Al8/BwtibHVldG9vdGhkAHNyYy9hZGFwdGVyLmM6Y29ubmVjdGVkX2NhbGxiYWNrKCkg aGNpMCBkZXZpY2UgQ0U6RDg6RkE6MjA6QTc6QjcgY29ubmVjdGVkIGVpcl9sZW4gMAAAAAAG AAAABgAAAAMAAAAAAOKHDPUCYPAPBAABFiAAAAAOAAAADgAAAAMAAAAAAOKHDPUJWj0+DAQA QAABAAAAAAAAAAAAAE0AAABN//8ADQAAAAAA4ocM9QlcnwcLYmx1ZXRvb3RoZABzcmMvZ2F0 dC1kYXRhYmFzZS5jOmNvbm5lY3RfY2IoKSBOZXcgaW5jb21pbmcgTEUgQVRUIGNvbm5lY3Rp b24AAAAAXgAAAF7//wANAAAAAADihwz1CVzSBwtibHVldG9vdGhkAHNyYy9kZXZpY2UuYzpk ZXZpY2VfYXR0YWNoX2F0dCgpIEVsZXZhdGluZyBzZWN1cml0eSBsZXZlbCBzaW5jZSBMVEsg aXMgYXZhaWxhYmxlAAAAAB8AAAAfAAAAAgAAAAAA4ocM9QlcvBkgHEAAmLecBvCEi9+BjX4P O5Xf4n/xkXmJlAK1NGYAAAAGAAAABgAAAAMAAAAAAOKHDPUJYdUPBAABGSAAAABNAAAATf// AA0AAAAAAOKHDPUJY4wHC2JsdWV0b290aGQAYXR0cmliL2dhdHRyaWIuYzpnX2F0dHJpYl9y ZWYoKSAweDU2MTcyMjI2ZWFiMDogZ19hdHRyaWJfcmVmPTEgAAAAAF0AAABd//8ADQAAAAAA 4ocM9QljtgcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6bG9hZF9nYXR0X2RiKCkgUmVzdG9y aW5nIENFOkQ4OkZBOjIwOkE3OkI3IGdhdHQgZGF0YWJhc2UgZnJvbSBmaWxlAAAAAHoAAAB6 //8ADQAAAAAA4ocM9QlyDAcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6bG9hZF9zZXJ2aWNl KCkgbG9hZGluZyBzZXJ2aWNlOiAweDAwMDEsIGVuZDogMHgwMDA3LCB1dWlkOiAwMDAwMTgw MC0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIAAAAAegAAAHr//wANAAAAAADihwz1CXJR BwtibHVldG9vdGhkAHNyYy9kZXZpY2UuYzpsb2FkX3NlcnZpY2UoKSBsb2FkaW5nIHNlcnZp Y2U6IDB4MDAwOCwgZW5kOiAweDAwMDgsIHV1aWQ6IDAwMDAxODAxLTAwMDAtMTAwMC04MDAw LTAwODA1ZjliMzRmYgAAAAB6AAAAev//AA0AAAAAAOKHDPUJclgHC2JsdWV0b290aGQAc3Jj L2RldmljZS5jOmxvYWRfc2VydmljZSgpIGxvYWRpbmcgc2VydmljZTogMHgwMDA5LCBlbmQ6 IDB4MDAxMSwgdXVpZDogMDAwMDE4MGEtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAA AHoAAAB6//8ADQAAAAAA4ocM9QlyZQcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6bG9hZF9z ZXJ2aWNlKCkgbG9hZGluZyBzZXJ2aWNlOiAweDAwMTIsIGVuZDogMHgwMDE2LCB1dWlkOiAw MDAwMTgwZi0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIAAAAAegAAAHr//wANAAAAAADi hwz1CXJsBwtibHVldG9vdGhkAHNyYy9kZXZpY2UuYzpsb2FkX3NlcnZpY2UoKSBsb2FkaW5n IHNlcnZpY2U6IDB4MDAxNywgZW5kOiAweDAwMzAsIHV1aWQ6IDAwMDAxODEyLTAwMDAtMTAw MC04MDAwLTAwODA1ZjliMzRmYgAAAAB6AAAAev//AA0AAAAAAOKHDPUJcncHC2JsdWV0b290 aGQAc3JjL2RldmljZS5jOmxvYWRfc2VydmljZSgpIGxvYWRpbmcgc2VydmljZTogMHgwMDMx LCBlbmQ6IDB4ZmZmZiwgdXVpZDogMDAwMDE4MTItMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIz NGZiAAAAAKgAAACo//8ADQAAAAAA4ocM9QlyfgcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6 bG9hZF9jaHJjKCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAwMiwgdmFs dWUgaGFuZGxlOiAweDAwMDMsIHByb3BlcnRpZXMgMHgwMDBhIHZhbHVlOiAgdXVpZDogMDAw MDJhMDAtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAKgAAACo//8ADQAAAAAA4ocM 9QlyiwcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGluZyBjaGFy YWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAwNCwgdmFsdWUgaGFuZGxlOiAweDAwMDUsIHByb3Bl cnRpZXMgMHgwMDAyIHZhbHVlOiAgdXVpZDogMDAwMDJhMDEtMDAwMC0xMDAwLTgwMDAtMDA4 MDVmOWIzNGZiAAAAAKgAAACo//8ADQAAAAAA4ocM9QlylAcLYmx1ZXRvb3RoZABzcmMvZGV2 aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAw NiwgdmFsdWUgaGFuZGxlOiAweDAwMDcsIHByb3BlcnRpZXMgMHgwMDAyIHZhbHVlOiAgdXVp ZDogMDAwMDJhMDQtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAKgAAACo//8ADQAA AAAA4ocM9QlyyQcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGlu ZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAwYSwgdmFsdWUgaGFuZGxlOiAweDAwMGIs IHByb3BlcnRpZXMgMHgwMDAyIHZhbHVlOiAgdXVpZDogMDAwMDJhMjktMDAwMC0xMDAwLTgw MDAtMDA4MDVmOWIzNGZiAAAAAKgAAACo//8ADQAAAAAA4ocM9Qly0gcLYmx1ZXRvb3RoZABz cmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6 IDB4MDAwYywgdmFsdWUgaGFuZGxlOiAweDAwMGQsIHByb3BlcnRpZXMgMHgwMDAyIHZhbHVl OiAgdXVpZDogMDAwMDJhMjQtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAKgAAACo //8ADQAAAAAA4ocM9Qly2AcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkg bG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAwZSwgdmFsdWUgaGFuZGxlOiAw eDAwMGYsIHByb3BlcnRpZXMgMHgwMDAyIHZhbHVlOiAgdXVpZDogMDAwMDJhMjYtMDAwMC0x MDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAKgAAACo//8ADQAAAAAA4ocM9Qly3wcLYmx1ZXRv b3RoZABzcmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBo YW5kbGU6IDB4MDAxMCwgdmFsdWUgaGFuZGxlOiAweDAwMTEsIHByb3BlcnRpZXMgMHgwMDAy IHZhbHVlOiAgdXVpZDogMDAwMDJhNTAtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAA AKgAAACo//8ADQAAAAAA4ocM9QlzKQcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6bG9hZF9j aHJjKCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAxMywgdmFsdWUgaGFu ZGxlOiAweDAwMTQsIHByb3BlcnRpZXMgMHgwMDEyIHZhbHVlOiAgdXVpZDogMDAwMDJhMTkt MDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAIkAAACJ//8ADQAAAAAA4ocM9QlzMQcL Ymx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6bG9hZF9kZXNjKCkgbG9hZGluZyBkZXNjcmlwdG9y IGhhbmRsZTogMHgwMDE1LCB2YWx1ZTogMHgwMDAwLCB2YWx1ZSB1dWlkOiAwMDAwMjkwMi0w MDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIAAAAAiQAAAIn//wANAAAAAADihwz1CXM4Bwti bHVldG9vdGhkAHNyYy9kZXZpY2UuYzpsb2FkX2Rlc2MoKSBsb2FkaW5nIGRlc2NyaXB0b3Ig aGFuZGxlOiAweDAwMTYsIHZhbHVlOiAweDAwMDAsIHZhbHVlIHV1aWQ6IDAwMDAyOTA4LTAw MDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAACAAAAAgP//AA0AAAAAAOKHDPUJc0IHC2Js dWV0b290aGQAc3JjL2RldmljZS5jOmxvYWRfaW5jbCgpIGxvYWRpbmcgaW5jbHVkZWQgc2Vy dmljZTogMHgwMDEyLCBlbmQ6IDB4MDAxNiwgdXVpZDogMDAwMDE4MGYtMDAwMC0xMDAwLTgw MDAtMDA4MDVmOWIzNGZiAAAAAKgAAACo//8ADQAAAAAA4ocM9QlzSgcLYmx1ZXRvb3RoZABz cmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6 IDB4MDAxOSwgdmFsdWUgaGFuZGxlOiAweDAwMWEsIHByb3BlcnRpZXMgMHgwMDFhIHZhbHVl OiAgdXVpZDogMDAwMDJhNGQtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAIkAAACJ //8ADQAAAAAA4ocM9QlzUQcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6bG9hZF9kZXNjKCkg bG9hZGluZyBkZXNjcmlwdG9yIGhhbmRsZTogMHgwMDFiLCB2YWx1ZTogMHgwMDAwLCB2YWx1 ZSB1dWlkOiAwMDAwMjkwMi0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIAAAAAiQAAAIn/ /wANAAAAAADihwz1CXNYBwtibHVldG9vdGhkAHNyYy9kZXZpY2UuYzpsb2FkX2Rlc2MoKSBs b2FkaW5nIGRlc2NyaXB0b3IgaGFuZGxlOiAweDAwMWMsIHZhbHVlOiAweDAwMDAsIHZhbHVl IHV1aWQ6IDAwMDAyOTA4LTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAACoAAAAqP// AA0AAAAAAOKHDPUJc2EHC2JsdWV0b290aGQAc3JjL2RldmljZS5jOmxvYWRfY2hyYygpIGxv YWRpbmcgY2hhcmFjdGVyaXN0aWMgaGFuZGxlOiAweDAwMWQsIHZhbHVlIGhhbmRsZTogMHgw MDFlLCBwcm9wZXJ0aWVzIDB4MDAxYSB2YWx1ZTogIHV1aWQ6IDAwMDAyYTRkLTAwMDAtMTAw MC04MDAwLTAwODA1ZjliMzRmYgAAAACJAAAAif//AA0AAAAAAOKHDPUJc2gHC2JsdWV0b290 aGQAc3JjL2RldmljZS5jOmxvYWRfZGVzYygpIGxvYWRpbmcgZGVzY3JpcHRvciBoYW5kbGU6 IDB4MDAxZiwgdmFsdWU6IDB4MDAwMCwgdmFsdWUgdXVpZDogMDAwMDI5MDItMDAwMC0xMDAw LTgwMDAtMDA4MDVmOWIzNGZiAAAAAIkAAACJ//8ADQAAAAAA4ocM9QlzbwcLYmx1ZXRvb3Ro ZABzcmMvZGV2aWNlLmM6bG9hZF9kZXNjKCkgbG9hZGluZyBkZXNjcmlwdG9yIGhhbmRsZTog MHgwMDIwLCB2YWx1ZTogMHgwMDAwLCB2YWx1ZSB1dWlkOiAwMDAwMjkwOC0wMDAwLTEwMDAt ODAwMC0wMDgwNWY5YjM0ZmIAAAAAqAAAAKj//wANAAAAAADihwz1CXN4BwtibHVldG9vdGhk AHNyYy9kZXZpY2UuYzpsb2FkX2NocmMoKSBsb2FkaW5nIGNoYXJhY3RlcmlzdGljIGhhbmRs ZTogMHgwMDIxLCB2YWx1ZSBoYW5kbGU6IDB4MDAyMiwgcHJvcGVydGllcyAweDAwMWEgdmFs dWU6ICB1dWlkOiAwMDAwMmE0ZC0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIAAAAAiQAA AIn//wANAAAAAADihwz1CXOABwtibHVldG9vdGhkAHNyYy9kZXZpY2UuYzpsb2FkX2Rlc2Mo KSBsb2FkaW5nIGRlc2NyaXB0b3IgaGFuZGxlOiAweDAwMjMsIHZhbHVlOiAweDAwMDAsIHZh bHVlIHV1aWQ6IDAwMDAyOTAyLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAACJAAAA if//AA0AAAAAAOKHDPUJc4cHC2JsdWV0b290aGQAc3JjL2RldmljZS5jOmxvYWRfZGVzYygp IGxvYWRpbmcgZGVzY3JpcHRvciBoYW5kbGU6IDB4MDAyNCwgdmFsdWU6IDB4MDAwMCwgdmFs dWUgdXVpZDogMDAwMDI5MDgtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAKgAAACo //8ADQAAAAAA4ocM9Ql0UAcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkg bG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAyNSwgdmFsdWUgaGFuZGxlOiAw eDAwMjYsIHByb3BlcnRpZXMgMHgwMDBhIHZhbHVlOiAgdXVpZDogMDAwMDJhNGQtMDAwMC0x MDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAIkAAACJ//8ADQAAAAAA4ocM9Ql0XgcLYmx1ZXRv b3RoZABzcmMvZGV2aWNlLmM6bG9hZF9kZXNjKCkgbG9hZGluZyBkZXNjcmlwdG9yIGhhbmRs ZTogMHgwMDI3LCB2YWx1ZTogMHgwMDAwLCB2YWx1ZSB1dWlkOiAwMDAwMjkwOC0wMDAwLTEw MDAtODAwMC0wMDgwNWY5YjM0ZmIAAAAAqAAAAKj//wANAAAAAADihwz1CXRrBwtibHVldG9v dGhkAHNyYy9kZXZpY2UuYzpsb2FkX2NocmMoKSBsb2FkaW5nIGNoYXJhY3RlcmlzdGljIGhh bmRsZTogMHgwMDI4LCB2YWx1ZSBoYW5kbGU6IDB4MDAyOSwgcHJvcGVydGllcyAweDAwMGEg dmFsdWU6ICB1dWlkOiAwMDAwMmE0ZC0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIAAAAA iQAAAIn//wANAAAAAADihwz1CXRzBwtibHVldG9vdGhkAHNyYy9kZXZpY2UuYzpsb2FkX2Rl c2MoKSBsb2FkaW5nIGRlc2NyaXB0b3IgaGFuZGxlOiAweDAwMmEsIHZhbHVlOiAweDAwMDAs IHZhbHVlIHV1aWQ6IDAwMDAyOTA4LTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAACo AAAAqP//AA0AAAAAAOKHDPUJdwMHC2JsdWV0b290aGQAc3JjL2RldmljZS5jOmxvYWRfY2hy YygpIGxvYWRpbmcgY2hhcmFjdGVyaXN0aWMgaGFuZGxlOiAweDAwMmIsIHZhbHVlIGhhbmRs ZTogMHgwMDJjLCBwcm9wZXJ0aWVzIDB4MDAwMiB2YWx1ZTogIHV1aWQ6IDAwMDAyYTRiLTAw MDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAACoAAAAqP//AA0AAAAAAOKHDPUJdycHC2Js dWV0b290aGQAc3JjL2RldmljZS5jOmxvYWRfY2hyYygpIGxvYWRpbmcgY2hhcmFjdGVyaXN0 aWMgaGFuZGxlOiAweDAwMmQsIHZhbHVlIGhhbmRsZTogMHgwMDJlLCBwcm9wZXJ0aWVzIDB4 MDAwMiB2YWx1ZTogIHV1aWQ6IDAwMDAyYTRhLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRm YgAAAACoAAAAqP//AA0AAAAAAOKHDPUJd20HC2JsdWV0b290aGQAc3JjL2RldmljZS5jOmxv YWRfY2hyYygpIGxvYWRpbmcgY2hhcmFjdGVyaXN0aWMgaGFuZGxlOiAweDAwMmYsIHZhbHVl IGhhbmRsZTogMHgwMDMwLCBwcm9wZXJ0aWVzIDB4MDAwNCB2YWx1ZTogIHV1aWQ6IDAwMDAy YTRjLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAACoAAAAqP//AA0AAAAAAOKHDPUJ d4wHC2JsdWV0b290aGQAc3JjL2RldmljZS5jOmxvYWRfY2hyYygpIGxvYWRpbmcgY2hhcmFj dGVyaXN0aWMgaGFuZGxlOiAweDAwMzIsIHZhbHVlIGhhbmRsZTogMHgwMDMzLCBwcm9wZXJ0 aWVzIDB4MDAwNiB2YWx1ZTogIHV1aWQ6IDAwMDAyYTRlLTAwMDAtMTAwMC04MDAwLTAwODA1 ZjliMzRmYgAAAACoAAAAqP//AA0AAAAAAOKHDPUJd5cHC2JsdWV0b290aGQAc3JjL2Rldmlj ZS5jOmxvYWRfY2hyYygpIGxvYWRpbmcgY2hhcmFjdGVyaXN0aWMgaGFuZGxlOiAweDAwMzQs IHZhbHVlIGhhbmRsZTogMHgwMDM1LCBwcm9wZXJ0aWVzIDB4MDAxYSB2YWx1ZTogIHV1aWQ6 IDAwMDAyYTRkLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAACJAAAAif//AA0AAAAA AOKHDPUJd7MHC2JsdWV0b290aGQAc3JjL2RldmljZS5jOmxvYWRfZGVzYygpIGxvYWRpbmcg ZGVzY3JpcHRvciBoYW5kbGU6IDB4MDAzNiwgdmFsdWU6IDB4MDAwMCwgdmFsdWUgdXVpZDog MDAwMDI5MDItMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAIkAAACJ//8ADQAAAAAA 4ocM9Ql3wAcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6bG9hZF9kZXNjKCkgbG9hZGluZyBk ZXNjcmlwdG9yIGhhbmRsZTogMHgwMDM3LCB2YWx1ZTogMHgwMDAwLCB2YWx1ZSB1dWlkOiAw MDAwMjkwOC0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIAAAAAqAAAAKj//wANAAAAAADi hwz1CXfNBwtibHVldG9vdGhkAHNyYy9kZXZpY2UuYzpsb2FkX2NocmMoKSBsb2FkaW5nIGNo YXJhY3RlcmlzdGljIGhhbmRsZTogMHgwMDM4LCB2YWx1ZSBoYW5kbGU6IDB4MDAzOSwgcHJv cGVydGllcyAweDAwMGEgdmFsdWU6ICB1dWlkOiAwMDAwMmE0ZC0wMDAwLTEwMDAtODAwMC0w MDgwNWY5YjM0ZmIAAAAAiQAAAIn//wANAAAAAADihwz1CXf5BwtibHVldG9vdGhkAHNyYy9k ZXZpY2UuYzpsb2FkX2Rlc2MoKSBsb2FkaW5nIGRlc2NyaXB0b3IgaGFuZGxlOiAweDAwM2Es IHZhbHVlOiAweDAwMDAsIHZhbHVlIHV1aWQ6IDAwMDAyOTA4LTAwMDAtMTAwMC04MDAwLTAw ODA1ZjliMzRmYgAAAACoAAAAqP//AA0AAAAAAOKHDPUJeAYHC2JsdWV0b290aGQAc3JjL2Rl dmljZS5jOmxvYWRfY2hyYygpIGxvYWRpbmcgY2hhcmFjdGVyaXN0aWMgaGFuZGxlOiAweDAw M2IsIHZhbHVlIGhhbmRsZTogMHgwMDNjLCBwcm9wZXJ0aWVzIDB4MDAwMiB2YWx1ZTogIHV1 aWQ6IDAwMDAyYTRiLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAACoAAAAqP//AA0A AAAAAOKHDPUJeBwHC2JsdWV0b290aGQAc3JjL2RldmljZS5jOmxvYWRfY2hyYygpIGxvYWRp bmcgY2hhcmFjdGVyaXN0aWMgaGFuZGxlOiAweDAwM2QsIHZhbHVlIGhhbmRsZTogMHgwMDNl LCBwcm9wZXJ0aWVzIDB4MDAxYSB2YWx1ZTogIHV1aWQ6IDAwMDAyYTMzLTAwMDAtMTAwMC04 MDAwLTAwODA1ZjliMzRmYgAAAACJAAAAif//AA0AAAAAAOKHDPUJeCsHC2JsdWV0b290aGQA c3JjL2RldmljZS5jOmxvYWRfZGVzYygpIGxvYWRpbmcgZGVzY3JpcHRvciBoYW5kbGU6IDB4 MDAzZiwgdmFsdWU6IDB4MDAwMCwgdmFsdWUgdXVpZDogMDAwMDI5MDItMDAwMC0xMDAwLTgw MDAtMDA4MDVmOWIzNGZiAAAAAKgAAACo//8ADQAAAAAA4ocM9Ql4PgcLYmx1ZXRvb3RoZABz cmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6 IDB4MDA0MCwgdmFsdWUgaGFuZGxlOiAweDAwNDEsIHByb3BlcnRpZXMgMHgwMDAyIHZhbHVl OiAgdXVpZDogMDAwMDJhNGEtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAF4AAABe //8ADQAAAAAA4ocM9Ql4VwcLYmx1ZXRvb3RoZABwcm9maWxlcy9iYXR0ZXJ5L2JhdHRlcnku YzpiYXR0X2FjY2VwdCgpIEJBVFQgcHJvZmlsZSBhY2NlcHQgKENFOkQ4OkZBOjIwOkE3OkI3 KQAAAACVAAAAlf//AA0AAAAAAOKHDPUJeGIHC2JsdWV0b290aGQAc3JjL3NlcnZpY2UuYzpj aGFuZ2Vfc3RhdGUoKSAweDU2MTcyMjI3NzJkMDogZGV2aWNlIENFOkQ4OkZBOjIwOkE3OkI3 IHByb2ZpbGUgYmF0dC1wcm9maWxlIHN0YXRlIGNoYW5nZWQ6IGRpc2Nvbm5lY3RlZCAtPiBj b25uZWN0ZWQgKDApAAAAAHAAAABw//8ADQAAAAAA4ocM9Ql4bAcLYmx1ZXRvb3RoZABwcm9m aWxlcy9kZXZpY2VpbmZvL2RldmljZWluZm8uYzpkZXZpY2VpbmZvX2FjY2VwdCgpIGRldmlj ZWluZm8gcHJvZmlsZSBhY2NlcHQgKENFOkQ4OkZBOjIwOkE3OkI3KQAAAACHAAAAh///AA0A AAAAAOKHDPUJeHQHC2JsdWV0b290aGQAcHJvZmlsZXMvZGV2aWNlaW5mby9kZXZpY2VpbmZv LmM6aGFuZGxlX2NoYXJhY3RlcmlzdGljKCkgVW5zdXBwb3J0ZWQgY2hhcmFjdGVyaXN0aWM6 IDAwMDAyYTI5LTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAACHAAAAh///AA0AAAAA AOKHDPUJeH0HC2JsdWV0b290aGQAcHJvZmlsZXMvZGV2aWNlaW5mby9kZXZpY2VpbmZvLmM6 aGFuZGxlX2NoYXJhY3RlcmlzdGljKCkgVW5zdXBwb3J0ZWQgY2hhcmFjdGVyaXN0aWM6IDAw MDAyYTI0LTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAACHAAAAh///AA0AAAAAAOKH DPUJeJIHC2JsdWV0b290aGQAcHJvZmlsZXMvZGV2aWNlaW5mby9kZXZpY2VpbmZvLmM6aGFu ZGxlX2NoYXJhY3RlcmlzdGljKCkgVW5zdXBwb3J0ZWQgY2hhcmFjdGVyaXN0aWM6IDAwMDAy YTI2LTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAACTAAAAk///AA0AAAAAAOKHDPUJ eJkHC2JsdWV0b290aGQAc3JjL3NlcnZpY2UuYzpjaGFuZ2Vfc3RhdGUoKSAweDU2MTcyMjI3 NzQ2MDogZGV2aWNlIENFOkQ4OkZBOjIwOkE3OkI3IHByb2ZpbGUgZGV2aWNlaW5mbyBzdGF0 ZSBjaGFuZ2VkOiBkaXNjb25uZWN0ZWQgLT4gY29ubmVjdGVkICgwKQAAAABUAAAAVP//AA0A AAAAAOKHDPUJeKEHC2JsdWV0b290aGQAcHJvZmlsZXMvZ2FwL2dhcy5jOmdhcF9hY2NlcHQo KSBHQVAgcHJvZmlsZSBhY2NlcHQgKENFOkQ4OkZBOjIwOkE3OkI3KQAAAAB5AAAAef//AA0A AAAAAOKHDPUJeLQHC2JsdWV0b290aGQAcHJvZmlsZXMvZ2FwL2dhcy5jOmhhbmRsZV9jaGFy YWN0ZXJpc3RpYygpIFVuc3VwcG9ydGVkIGNoYXJhY3RlcmlzdGljOiAwMDAwMmEwNC0wMDAw LTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIAAAAAlAAAAJT//wANAAAAAADihwz1CXjDBwtibHVl dG9vdGhkAHNyYy9zZXJ2aWNlLmM6Y2hhbmdlX3N0YXRlKCkgMHg1NjE3MjIyNzcyNjA6IGRl dmljZSBDRTpEODpGQToyMDpBNzpCNyBwcm9maWxlIGdhcC1wcm9maWxlIHN0YXRlIGNoYW5n ZWQ6IGRpc2Nvbm5lY3RlZCAtPiBjb25uZWN0ZWQgKDApAAAAAH4AAAB+//8ADQAAAAAA4ocM 9Ql4zQcLYmx1ZXRvb3RoZABwcm9maWxlcy9pbnB1dC9ob2cuYzpob2dfZGV2aWNlX2FjY2Vw dCgpIG5hbWU9Q2FkTW91c2UgUHJvIFdpcmVsZXNzIHZlbmRvcj0weDI1NkYsIHByb2R1Y3Q9 MHhDNjU0LCB2ZXJzaW9uPTB4MTA2AAAAAE0AAABN//8ADQAAAAAA4ocM9Ql41wcLYmx1ZXRv b3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3JlZigpIDB4NTYxNzIyMjZlYWIwOiBn X2F0dHJpYl9yZWY9MiAAAAAATQAAAE3//wANAAAAAADihwz1CXjhBwtibHVldG9vdGhkAGF0 dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfcmVmKCkgMHg1NjE3MjIyNmVhYjA6IGdfYXR0cmli X3JlZj0zIAAAAABWAAAAVv//AA0AAAAAAOKHDPUJeOkHC2JsdWV0b290aGQAcHJvZmlsZXMv aW5wdXQvaG9nLWxpYi5jOmJ0X2hvZ19hdHRhY2goKSBIb0cgZGlzY292ZXJpbmcgY2hhcmFj dGVyaXN0aWNzAAAAAE0AAABN//8ADQAAAAAA4ocM9Ql5AQcLYmx1ZXRvb3RoZABhdHRyaWIv Z2F0dHJpYi5jOmdfYXR0cmliX3JlZigpIDB4NTYxNzIyMjZlYWIwOiBnX2F0dHJpYl9yZWY9 NCAAAAAATQAAAE3//wANAAAAAADihwz1CXkgBwtibHVldG9vdGhkAGF0dHJpYi9nYXR0cmli LmM6Z19hdHRyaWJfcmVmKCkgMHg1NjE3MjIyNmVhYjA6IGdfYXR0cmliX3JlZj01IAAAAABN AAAATf//AA0AAAAAAOKHDPUJeSkHC2JsdWV0b290aGQAYXR0cmliL2dhdHRyaWIuYzpnX2F0 dHJpYl9yZWYoKSAweDU2MTcyMjI2ZWFiMDogZ19hdHRyaWJfcmVmPTYgAAAAAE0AAABN//8A DQAAAAAA4ocM9Ql5NAcLYmx1ZXRvb3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3Jl ZigpIDB4NTYxNzIyMjZlYWIwOiBnX2F0dHJpYl9yZWY9NyAAAAAATQAAAE3//wANAAAAAADi hwz1CXlBBwtibHVldG9vdGhkAGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfcmVmKCkgMHg1 NjE3MjIyNmVhYjA6IGdfYXR0cmliX3JlZj04IAAAAABNAAAATf//AA0AAAAAAOKHDPUJeXUH C2JsdWV0b290aGQAYXR0cmliL2dhdHRyaWIuYzpnX2F0dHJpYl9yZWYoKSAweDU2MTcyMjI2 ZWFiMDogZ19hdHRyaWJfcmVmPTkgAAAAAE4AAABO//8ADQAAAAAA4ocM9Ql5ggcLYmx1ZXRv b3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3JlZigpIDB4NTYxNzIyMjZlYWIwOiBn X2F0dHJpYl9yZWY9MTAgAAAAAFYAAABW//8ADQAAAAAA4ocM9Ql5jQcLYmx1ZXRvb3RoZABw cm9maWxlcy9pbnB1dC9ob2ctbGliLmM6YnRfaG9nX2F0dGFjaCgpIEhvRyBkaXNjb3Zlcmlu ZyBjaGFyYWN0ZXJpc3RpY3MAAAAATgAAAE7//wANAAAAAADihwz1CXmXBwtibHVldG9vdGhk AGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfcmVmKCkgMHg1NjE3MjIyNmVhYjA6IGdfYXR0 cmliX3JlZj0xMSAAAAAATgAAAE7//wANAAAAAADihwz1CXmfBwtibHVldG9vdGhkAGF0dHJp Yi9nYXR0cmliLmM6Z19hdHRyaWJfcmVmKCkgMHg1NjE3MjIyNmVhYjA6IGdfYXR0cmliX3Jl Zj0xMiAAAAAATgAAAE7//wANAAAAAADihwz1CX+IBwtibHVldG9vdGhkAGF0dHJpYi9nYXR0 cmliLmM6Z19hdHRyaWJfcmVmKCkgMHg1NjE3MjIyNmVhYjA6IGdfYXR0cmliX3JlZj0xMyAA AAAATgAAAE7//wANAAAAAADihwz1CX+VBwtibHVldG9vdGhkAGF0dHJpYi9nYXR0cmliLmM6 Z19hdHRyaWJfcmVmKCkgMHg1NjE3MjIyNmVhYjA6IGdfYXR0cmliX3JlZj0xNCAAAAAATgAA AE7//wANAAAAAADihwz1CX+bBwtibHVldG9vdGhkAGF0dHJpYi9nYXR0cmliLmM6Z19hdHRy aWJfcmVmKCkgMHg1NjE3MjIyNmVhYjA6IGdfYXR0cmliX3JlZj0xNSAAAAAATgAAAE7//wAN AAAAAADihwz1CX+hBwtibHVldG9vdGhkAGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfcmVm KCkgMHg1NjE3MjIyNmVhYjA6IGdfYXR0cmliX3JlZj0xNiAAAAAATgAAAE7//wANAAAAAADi hwz1CX+nBwtibHVldG9vdGhkAGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfcmVmKCkgMHg1 NjE3MjIyNmVhYjA6IGdfYXR0cmliX3JlZj0xNyAAAAAAkgAAAJL//wANAAAAAADihwz1CX+t BwtibHVldG9vdGhkAHNyYy9zZXJ2aWNlLmM6Y2hhbmdlX3N0YXRlKCkgMHg1NjE3MjIyNzY1 ZjA6IGRldmljZSBDRTpEODpGQToyMDpBNzpCNyBwcm9maWxlIGlucHV0LWhvZyBzdGF0ZSBj aGFuZ2VkOiBkaXNjb25uZWN0ZWQgLT4gY29ubmVjdGVkICgwKQAAAABDAAAAQ///AA0AAAAA AOKHDPUJf7MHC2JsdWV0b290aGQAc3JjL3NlcnZpY2UuYzpidGRfc2VydmljZV9yZWYoKSAw eDU2MTcyMjI3NjVmMDogcmVmPTIAAAAARwAAAEf//wANAAAAAADihwz1CX+4BwtibHVldG9v dGhkAHBsdWdpbnMvcG9saWN5LmM6c2VydmljZV9jYigpIEFkZGVkIGlucHV0LWhvZyByZWNv bm5lY3QgMAAAAABNAAAATf//AA0AAAAAAOKHDPUJf74HC2JsdWV0b290aGQAc3JjL2dhdHQt Y2xpZW50LmM6YnRkX2dhdHRfY2xpZW50X2Nvbm5lY3RlZCgpIERldmljZSBjb25uZWN0ZWQu AAAAAF4AAABe//8ADQAAAAAA4ocM9Ql/xAcLYmx1ZXRvb3RoZABzcmMvZ2F0dC1kYXRhYmFz ZS5jOnNlbmRfbm90aWZpY2F0aW9uX3RvX2RldmljZSgpIEdBVFQgc2VydmVyIHNlbmRpbmcg aW5kaWNhdGlvbgAAAAAGAAAABgAAAAMAAAAAAOKHDPUS9ysIBABAAAEAAAAHAAAABwAAAAIA AAAAAOKHDPUS98x8DARAALgLAAAACwAAAAsAAAAEAAAAAADihwz1EvheQAAHAAMABAACBQIA AAAPAAAADwAAAAQAAAAAAOKHDPUS+QFAAAsABwAEAB0IAAoA//8AAAAIAAAACAAAAAMAAAAA AOKHDPUS+w0OBgF8DABAAAAAAAcAAAAHAAAAAwAAAAAA4ocM9RXVjhMFAUAAAQAAAAALAAAA CwAAAAUAAAAAAOKHDPUV4cBAIAcAAwAEAAMXAAAAAEsAAABL//8ADQAAAAAA4ocM9RXnoQcL Ymx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6Z2F0dF9kZWJ1ZygpIE1UVSBleGNoYW5nZSBjb21w bGV0ZSwgd2l0aCBNVFU6IDIzAAAAAAsAAAALAAAABAAAAAAA4ocM9RXmqEAABwADAAQAChQA AAAABwAAAAcAAAADAAAAAADihwz1F2vTEwUBQAACAAAAAAoAAAAKAAAABQAAAAAA4ocM9Rds WEAgBgACAAQAC2QAAAALAAAACwAAAAQAAAAAAOKHDPUXbcxAAAcAAwAEAAoRAAAAAAwAAAAM AAAABQAAAAAA4ocM9RduUEAgCAAEAAQAGxQAXAAAAFkAAABZ//8ADQAAAAAA4ocM9RdwAQcL Ymx1ZXRvb3RoZABwcm9maWxlcy9iYXR0ZXJ5L2JhdHRlcnkuYzpwYXJzZV9iYXR0ZXJ5X2xl dmVsKCkgQmF0dGVyeSBMZXZlbCB1cGRhdGVkOiA5MiUAAAAADQAAAA0AAAAFAAAAAADihwz1 F3I/QCAJAAUABAAbIgBcAAAAABAAAAAQAAAABQAAAAAA4ocM9Rj5EkAgDAAIAAQACwJvJVTG BgEAAAALAAAACwAAAAQAAAAAAOKHDPUY+ptAAAcAAwAEAAoDAAAAAAcAAAAHAAAAAwAAAAAA 4ocM9RuObRMFAUAAAQAAAAAeAAAAHgAAAAUAAAAAAOKHDPUbuPdAIBoAFgAEAAtDYWRNb3Vz ZSBQcm8gV2lyZWxlc3MAAABdAAAAXf//AA0AAAAAAOKHDPUbvl8HC2JsdWV0b290aGQAcHJv ZmlsZXMvZ2FwL2dhcy5jOnJlYWRfZGV2aWNlX25hbWVfY2IoKSBHQVAgRGV2aWNlIE5hbWU6 IENhZE1vdXNlIFBybyBXaXJlbGVzcwAAAAALAAAACwAAAAQAAAAAAOKHDPUbu19AAAcAAwAE AAoFAAAAAAcAAAAHAAAAAwAAAAAA4ocM9RwPVhMFAUAAAgAAAAALAAAACwAAAAUAAAAAAOKH DPUfJMxAIAcAAwAEAAvCAwAAAEwAAABM//8ADQAAAAAA4ocM9R8toAcLYmx1ZXRvb3RoZABw cm9maWxlcy9nYXAvZ2FzLmM6cmVhZF9hcHBlYXJhbmNlX2NiKCkgR0FQIEFwcGVhcmFuY2U6 IDB4MDNjMgAAAAALAAAACwAAAAQAAAAAAOKHDPUfJyZAAAcAAwAEAAozAAAAAAoAAAAKAAAA BQAAAAAA4ocM9SDcOUAgBgACAAQACwEAAABkAAAAZP//AA0AAAAAAOKHDPUg3eYHC2JsdWV0 b290aGQAcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnByb3RvX21vZGVfcmVhZF9jYigpIEhv RyBpcyBvcGVyYXRpbmcgaW4gUmVwb3J0IFByb3RvY29sIE1vZGUAAAAAUgAAAFL//wANAAAA AADihwz1IOH3BwtibHVldG9vdGhkAGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfdW5yZWYo KSAweDU2MTcyMjI2ZWFiMDogZ19hdHRyaWJfdW5yZWY9MTYgAAAAAAsAAAALAAAABAAAAAAA 4ocM9SDfIkAABwADAAQACjUAAAAABwAAAAcAAAADAAAAAADihwz1ImhZEwUBQAACAAAAAAkA AAAJAAAABQAAAAAA4ocM9SJp9EAgBQABAAQACwAAAFIAAABS//8ADQAAAAAA4ocM9SJuPAcL Ymx1ZXRvb3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3VucmVmKCkgMHg1NjE3MjIy NmVhYjA6IGdfYXR0cmliX3VucmVmPTE1IAAAAAALAAAACwAAAAQAAAAAAOKHDPUibCFAAAcA AwAEAAo3AAAAAAsAAAALAAAABQAAAAAA4ocM9SV+0UAgBwADAAQACxsBAAAAXgAAAF7//wAN AAAAAADihwz1JYBrBwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBv cnRfcmVmZXJlbmNlX2NiKCkgUmVwb3J0IDB4MDAzNTogaWQgMHgxYiB0eXBlIGlucHV0AAAA AE4AAABO//8ADQAAAAAA4ocM9SWAswcLYmx1ZXRvb3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdf YXR0cmliX3JlZigpIDB4NTYxNzIyMjZlYWIwOiBnX2F0dHJpYl9yZWY9MTYgAAAAAFIAAABS //8ADQAAAAAA4ocM9SWFyQcLYmx1ZXRvb3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmli X3VucmVmKCkgMHg1NjE3MjIyNmVhYjA6IGdfYXR0cmliX3VucmVmPTE1IAAAAAALAAAACwAA AAQAAAAAAOKHDPUlghRAAAcAAwAEAAo5AAAAAAcAAAAHAAAAAwAAAAAA4ocM9ScALRMFAUAA AQAAAAAKAAAACgAAAAUAAAAAAOKHDPUnDG5AIAYAAgAEAAsFAAAAUgAAAFL//wANAAAAAADi hwz1Jw/IBwtibHVldG9vdGhkAGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfdW5yZWYoKSAw eDU2MTcyMjI2ZWFiMDogZ19hdHRyaWJfdW5yZWY9MTQgAAAAAAsAAAALAAAABAAAAAAA4ocM 9ScQwUAABwADAAQACjoAAAAABwAAAAcAAAADAAAAAADihwz1KGtsEwUBQAACAAAAAAsAAAAL AAAABQAAAAAA4ocM9ShsJEAgBwADAAQACxIDAAAAYAAAAGD//wANAAAAAADihwz1KHDsBwti bHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfcmVmZXJlbmNlX2Ni KCkgUmVwb3J0IDB4MDAzOTogaWQgMHgxMiB0eXBlIGZlYXR1cmUAAAAAUgAAAFL//wANAAAA AADihwz1KHReBwtibHVldG9vdGhkAGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfdW5yZWYo KSAweDU2MTcyMjI2ZWFiMDogZ19hdHRyaWJfdW5yZWY9MTMgAAAAAAsAAAALAAAABAAAAAAA 4ocM9Sh0v0AABwADAAQACjwAAAAAHwAAAB8AAAAFAAAAAADihwz1KiPJQCAbABcABAALBQEJ AqEBBQEJAqEChRsJAaEABQkZAQAAAAsAAAALAAAABAAAAAAA4ocM9SoliUAABwADAAQACkEA AAAABwAAAAcAAAADAAAAAADihwz1KtC4EwUBQAABAAAAAAcAAAAHAAAAAwAAAAAA4ocM9S6h ThMFAUAAAQAAAAANAAAADQAAAAUAAAAAAOKHDPUuw9tAIAkABQAEAAsRAQADAAAAYwAAAGP/ /wANAAAAAADihwz1LsXqBwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpp bmZvX3JlYWRfY2IoKSBiY2RISUQ6IDB4MDExMSBiQ291bnRyeUNvZGU6IDB4MDAgRmxhZ3M6 IDB4MDMAAAAAUgAAAFL//wANAAAAAADihwz1LsZBBwtibHVldG9vdGhkAGF0dHJpYi9nYXR0 cmliLmM6Z19hdHRyaWJfdW5yZWYoKSAweDU2MTcyMjI2ZWFiMDogZ19hdHRyaWJfdW5yZWY9 MTIgAAAAAAsAAAALAAAABAAAAAAA4ocM9S7Gx0AABwADAAQAChwAAAAACwAAAAsAAAAFAAAA AADihwz1MHtPQCAHAAMABAALAQEAAABeAAAAXv//AA0AAAAAAOKHDPUwgasHC2JsdWV0b290 aGQAcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9yZWZlcmVuY2VfY2IoKSBSZXBv cnQgMHgwMDFhOiBpZCAweDAxIHR5cGUgaW5wdXQAAAAATgAAAE7//wANAAAAAADihwz1MIHn BwtibHVldG9vdGhkAGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfcmVmKCkgMHg1NjE3MjIy NmVhYjA6IGdfYXR0cmliX3JlZj0xMyAAAAAAUgAAAFL//wANAAAAAADihwz1MIPbBwtibHVl dG9vdGhkAGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfdW5yZWYoKSAweDU2MTcyMjI2ZWFi MDogZ19hdHRyaWJfdW5yZWY9MTIgAAAAAAsAAAALAAAABAAAAAAA4ocM9TCDVkAABwADAAQA CiAAAAAABwAAAAcAAAADAAAAAADihwz1MNPqEwUBQAACAAAAAAsAAAALAAAABQAAAAAA4ocM 9TDVcEAgBwADAAQACwMBAAAAXgAAAF7//wANAAAAAADihwz1MNduBwtibHVldG9vdGhkAHBy b2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfcmVmZXJlbmNlX2NiKCkgUmVwb3J0IDB4 MDAxZTogaWQgMHgwMyB0eXBlIGlucHV0AAAAAE4AAABO//8ADQAAAAAA4ocM9TDYXQcLYmx1 ZXRvb3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3JlZigpIDB4NTYxNzIyMjZlYWIw OiBnX2F0dHJpYl9yZWY9MTMgAAAAAFIAAABS//8ADQAAAAAA4ocM9TDYkAcLYmx1ZXRvb3Ro ZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3VucmVmKCkgMHg1NjE3MjIyNmVhYjA6IGdf YXR0cmliX3VucmVmPTEyIAAAAAALAAAACwAAAAQAAAAAAOKHDPUw2LpAAAcAAwAEAAokAAAA AAsAAAALAAAABQAAAAAA4ocM9TFXKEAgBwADAAQACxcBAAAAXgAAAF7//wANAAAAAADihwz1 MVuWBwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfcmVmZXJl bmNlX2NiKCkgUmVwb3J0IDB4MDAyMjogaWQgMHgxNyB0eXBlIGlucHV0AAAAAE4AAABO//8A DQAAAAAA4ocM9TFb2wcLYmx1ZXRvb3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3Jl ZigpIDB4NTYxNzIyMjZlYWIwOiBnX2F0dHJpYl9yZWY9MTMgAAAAAFIAAABS//8ADQAAAAAA 4ocM9TFb/wcLYmx1ZXRvb3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3VucmVmKCkg MHg1NjE3MjIyNmVhYjA6IGdfYXR0cmliX3VucmVmPTEyIAAAAAALAAAACwAAAAQAAAAAAOKH DPUxWplAAAcAAwAEAAonAAAAAAcAAAAHAAAAAwAAAAAA4ocM9TGD/BMFAUAAAgAAAAALAAAA CwAAAAUAAAAAAOKHDPUx2qtAIAcAAwAEAAsQAwAAAGAAAABg//8ADQAAAAAA4ocM9THc8QcL Ymx1ZXRvb3RoZABwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X3JlZmVyZW5jZV9j YigpIFJlcG9ydCAweDAwMjY6IGlkIDB4MTAgdHlwZSBmZWF0dXJlAAAAAFIAAABS//8ADQAA AAAA4ocM9THdBAcLYmx1ZXRvb3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3VucmVm KCkgMHg1NjE3MjIyNmVhYjA6IGdfYXR0cmliX3VucmVmPTExIAAAAAALAAAACwAAAAQAAAAA AOKHDPUx28RAAAcAAwAEAAoqAAAAAAsAAAALAAAABQAAAAAA4ocM9TIywkAgBwADAAQACwgD AAAAYAAAAGD//wANAAAAAADihwz1MjUBBwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hv Zy1saWIuYzpyZXBvcnRfcmVmZXJlbmNlX2NiKCkgUmVwb3J0IDB4MDAyOTogaWQgMHgwOCB0 eXBlIGZlYXR1cmUAAAAAUgAAAFL//wANAAAAAADihwz1MjVSBwtibHVldG9vdGhkAGF0dHJp Yi9nYXR0cmliLmM6Z19hdHRyaWJfdW5yZWYoKSAweDU2MTcyMjI2ZWFiMDogZ19hdHRyaWJf dW5yZWY9MTAgAAAAAAsAAAALAAAABAAAAAAA4ocM9TI1w0AABwADAAQACiwAAAAABwAAAAcA AAADAAAAAADihwz1MmJJEwUBQAACAAAAAB8AAAAfAAAABQAAAAAA4ocM9TK5GEAgGwAXAAQA CwYA/wkBoQEJAaEChf8ZASkIFQElQHUAAAALAAAACwAAAAQAAAAAAOKHDPUyutdAAAcAAwAE AAouAAAAAA0AAAANAAAABQAAAAAA4ocM9TM6bkAgCQAFAAQACxEBAAMAAABjAAAAY///AA0A AAAAAOKHDPUzPHUHC2JsdWV0b290aGQAcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOmluZm9f cmVhZF9jYigpIGJjZEhJRDogMHgwMTExIGJDb3VudHJ5Q29kZTogMHgwMCBGbGFnczogMHgw MwAAAABRAAAAUf//AA0AAAAAAOKHDPUzPQEHC2JsdWV0b290aGQAYXR0cmliL2dhdHRyaWIu YzpnX2F0dHJpYl91bnJlZigpIDB4NTYxNzIyMjZlYWIwOiBnX2F0dHJpYl91bnJlZj05IAAA AAAPAAAADwAAAAQAAAAAAOKHDPUzPW9AAAsABwAEABABAP//ACgAAAAHAAAABwAAAAMAAAAA AOKHDPUzZ/YTBQFAAAIAAAAAHAAAABwAAAAFAAAAAADihwz1M8C/QCAYABQABAARBgEABwAA GAgACAABGAkAEQAKGAAAAA0AAAANAAAABAAAAAAA4ocM9TPCoEAACQAFAAQAEhUAAQAAAAAJ AAAACQAAAAUAAAAAAOKHDPU1HblAIAUAAQAEABMAAABaAAAAWv//AA0AAAAAAOKHDPU1JVsH C2JsdWV0b290aGQAcHJvZmlsZXMvYmF0dGVyeS9iYXR0ZXJ5LmM6cGFyc2VfYmF0dGVyeV9s ZXZlbCgpIEJhdHRlcnkgTGV2ZWwgdXBkYXRlZDogMTAwJQAAAABlAAAAZf//AA0AAAAAAOKH DPU1JacHC2JsdWV0b290aGQAcHJvZmlsZXMvYmF0dGVyeS9iYXR0ZXJ5LmM6YmF0dF9pb19j Y2Nfd3JpdHRlbl9jYigpIEJhdHRlcnkgTGV2ZWw6IG5vdGlmaWNhdGlvbiBlbmFibGVkAAAA AAsAAAALAAAABAAAAAAA4ocM9TUgy0AABwADAAQACjYAAAAABwAAAAcAAAADAAAAAADihwz1 NaJUEwUBQAACAAAAAAsAAAALAAAABQAAAAAA4ocM9TapW0AgBwADAAQACwEAAAAAUQAAAFH/ /wANAAAAAADihwz1Nq2/BwtibHVldG9vdGhkAGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJf dW5yZWYoKSAweDU2MTcyMjI2ZWFiMDogZ19hdHRyaWJfdW5yZWY9OCAAAAAADQAAAA0AAAAE AAAAAADihwz1NqyNQAAJAAUABAAMPAAWAAAAAB8AAAAfAAAABQAAAAAA4ocM9Tg5qkAgGwAX AAQADSkIFQAlAZUIdQGBAgUBCTAJMRYCgCYAAAALAAAACwAAAAQAAAAAAOKHDPU4Ov5AAAcA AwAEAAobAAAAAAcAAAAHAAAAAwAAAAAA4ocM9TiMYhMFAUAAAgAAAAALAAAACwAAAAUAAAAA AOKHDPU4jvJAIAcAAwAEAAsBAAAAAFEAAABR//8ADQAAAAAA4ocM9TiU6AcLYmx1ZXRvb3Ro ZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3VucmVmKCkgMHg1NjE3MjIyNmVhYjA6IGdf YXR0cmliX3VucmVmPTcgAAAAAAsAAAALAAAABAAAAAAA4ocM9TiTnEAABwADAAQACh8AAAAA CwAAAAsAAAAFAAAAAADihwz1OcA+QCAHAAMABAALAQAAAABRAAAAUf//AA0AAAAAAOKHDPU5 wh0HC2JsdWV0b290aGQAYXR0cmliL2dhdHRyaWIuYzpnX2F0dHJpYl91bnJlZigpIDB4NTYx NzIyMjZlYWIwOiBnX2F0dHJpYl91bnJlZj02IAAAAAALAAAACwAAAAQAAAAAAOKHDPU5wpdA AAcAAwAEAAojAAAAAAsAAAALAAAABQAAAAAA4ocM9Tt6BkAgBwADAAQACwEAAAAABwAAAAcA AAADAAAAAADihwz1O3ooEwUBQAACAAAAAFEAAABR//8ADQAAAAAA4ocM9Tt/SwcLYmx1ZXRv b3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3VucmVmKCkgMHg1NjE3MjIyNmVhYjA6 IGdfYXR0cmliX3VucmVmPTUgAAAAAA0AAAANAAAABAAAAAAA4ocM9Tt/fUAACQAFAAQADCwA FgAAAAAfAAAAHwAAAAUAAAAAAOKHDPVAHHpAIBsAFwAEAA0IlQGBAMDABQEJCKEBBQEJCKEC hQMFAAAADwAAAA8AAAAEAAAAAADihwz1QB6sQAALAAcABAAQEgD//wAoAAAABwAAAAcAAAAD AAAAAADihwz1QahsEwUBQAACAAAAABwAAAAcAAAABQAAAAAA4ocM9UJXx0AgGAAUAAQAEQYS ABYADxgXADAAEhgxAP//EhgAAABBAAAAQf//AA0AAAAAAOKHDPVCWe8HC2JsdWV0b290aGQA c3JjL2RldmljZS5jOmdhdHRfZGVidWcoKSBQcmltYXJ5IHNlcnZpY2VzIGZvdW5kOiA2AAAA AG4AAABu//8ADQAAAAAA4ocM9UJaHAcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6Z2F0dF9k ZWJ1ZygpIHN0YXJ0OiAweDAwMDEsIGVuZDogMHgwMDA3LCB1dWlkOiAwMDAwMTgwMC0wMDAw LTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIAAAAAbgAAAG7//wANAAAAAADihwz1Qlo8BwtibHVl dG9vdGhkAHNyYy9kZXZpY2UuYzpnYXR0X2RlYnVnKCkgc3RhcnQ6IDB4MDAwOCwgZW5kOiAw eDAwMDgsIHV1aWQ6IDAwMDAxODAxLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgAAAABu AAAAbv//AA0AAAAAAOKHDPVCWl8HC2JsdWV0b290aGQAc3JjL2RldmljZS5jOmdhdHRfZGVi dWcoKSBzdGFydDogMHgwMDA5LCBlbmQ6IDB4MDAxMSwgdXVpZDogMDAwMDE4MGEtMDAwMC0x MDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAG4AAABu//8ADQAAAAAA4ocM9UJovgcLYmx1ZXRv b3RoZABzcmMvZGV2aWNlLmM6Z2F0dF9kZWJ1ZygpIHN0YXJ0OiAweDAwMTIsIGVuZDogMHgw MDE2LCB1dWlkOiAwMDAwMTgwZi0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIAAAAAbgAA AG7//wANAAAAAADihwz1Qmj4BwtibHVldG9vdGhkAHNyYy9kZXZpY2UuYzpnYXR0X2RlYnVn KCkgc3RhcnQ6IDB4MDAxNywgZW5kOiAweDAwMzAsIHV1aWQ6IDAwMDAxODEyLTAwMDAtMTAw MC04MDAwLTAwODA1ZjliMzRmYgAAAABuAAAAbv//AA0AAAAAAOKHDPVCaRgHC2JsdWV0b290 aGQAc3JjL2RldmljZS5jOmdhdHRfZGVidWcoKSBzdGFydDogMHgwMDMxLCBlbmQ6IDB4ZmZm ZiwgdXVpZDogMDAwMDE4MTItMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiAAAAAEsAAABL //8ADQAAAAAA4ocM9UJpOQcLYmx1ZXRvb3RoZABzcmMvZGV2aWNlLmM6Z2F0dF9jbGllbnRf cmVhZHlfY2IoKSBzdGF0dXM6IHN1Y2Nlc3MsIGVycm9yOiAwAAAAAEkAAABJ//8ADQAAAAAA 4ocM9UJpWwcLYmx1ZXRvb3RoZABzcmMvZ2F0dC1jbGllbnQuYzpidGRfZ2F0dF9jbGllbnRf cmVhZHkoKSBHQVRUIGNsaWVudCByZWFkeQAAAABoAAAAaP//AA0AAAAAAOKHDPVCaX4HC2Js dWV0b290aGQAc3JjL2dhdHQtY2xpZW50LmM6Y3JlYXRlX3NlcnZpY2VzKCkgRXhwb3J0aW5n IG9iamVjdHMgZm9yIEdBVFQgc2VydmljZXM6IENFOkQ4OkZBOjIwOkE3OkI3AAAAAHkAAAB5 //8ADQAAAAAA4ocM9UJpnQcLYmx1ZXRvb3RoZABzcmMvZ2F0dC1jbGllbnQuYzpzZXJ2aWNl X2NyZWF0ZSgpIEV4cG9ydGVkIEdBVFQgc2VydmljZTogL29yZy9ibHVlei9oY2kwL2Rldl9D RV9EOF9GQV8yMF9BN19CNy9zZXJ2aWNlMDAwOAAAAAB5AAAAef//AA0AAAAAAOKHDPVCabwH C2JsdWV0b290aGQAc3JjL2dhdHQtY2xpZW50LmM6c2VydmljZV9jcmVhdGUoKSBFeHBvcnRl ZCBHQVRUIHNlcnZpY2U6IC9vcmcvYmx1ZXovaGNpMC9kZXZfQ0VfRDhfRkFfMjBfQTdfQjcv c2VydmljZTAwMDkAAAAAkAAAAJD//wANAAAAAADihwz1QmnZBwtibHVldG9vdGhkAHNyYy9n YXR0LWNsaWVudC5jOmNoYXJhY3RlcmlzdGljX2NyZWF0ZSgpIEV4cG9ydGVkIEdBVFQgY2hh cmFjdGVyaXN0aWM6IC9vcmcvYmx1ZXovaGNpMC9kZXZfQ0VfRDhfRkFfMjBfQTdfQjcvc2Vy dmljZTAwMDkvY2hhcjAwMGEAAAAAkAAAAJD//wANAAAAAADihwz1Qmn3BwtibHVldG9vdGhk AHNyYy9nYXR0LWNsaWVudC5jOmNoYXJhY3RlcmlzdGljX2NyZWF0ZSgpIEV4cG9ydGVkIEdB VFQgY2hhcmFjdGVyaXN0aWM6IC9vcmcvYmx1ZXovaGNpMC9kZXZfQ0VfRDhfRkFfMjBfQTdf Qjcvc2VydmljZTAwMDkvY2hhcjAwMGMAAAAAkAAAAJD//wANAAAAAADihwz1QmoVBwtibHVl dG9vdGhkAHNyYy9nYXR0LWNsaWVudC5jOmNoYXJhY3RlcmlzdGljX2NyZWF0ZSgpIEV4cG9y dGVkIEdBVFQgY2hhcmFjdGVyaXN0aWM6IC9vcmcvYmx1ZXovaGNpMC9kZXZfQ0VfRDhfRkFf MjBfQTdfQjcvc2VydmljZTAwMDkvY2hhcjAwMGUAAAAAkAAAAJD//wANAAAAAADihwz1Qmo1 BwtibHVldG9vdGhkAHNyYy9nYXR0LWNsaWVudC5jOmNoYXJhY3RlcmlzdGljX2NyZWF0ZSgp IEV4cG9ydGVkIEdBVFQgY2hhcmFjdGVyaXN0aWM6IC9vcmcvYmx1ZXovaGNpMC9kZXZfQ0Vf RDhfRkFfMjBfQTdfQjcvc2VydmljZTAwMDkvY2hhcjAwMTAAAAAAXAAAAFz//wANAAAAAADi hwz1QmpUBwtibHVldG9vdGhkAHNyYy9kZXZpY2UuYzpkZXZpY2Vfc3ZjX3Jlc29sdmVkKCkg L29yZy9ibHVlei9oY2kwL2Rldl9DRV9EOF9GQV8yMF9BN19CNyBlcnIgMAAAAAANAAAADQAA AAQAAAAAAOKHDPVDaSJAAAkABQAEABI2AAEAAAAACQAAAAkAAAAFAAAAAADihwz1UiBAQCAF AAEABAATAAAAfgAAAH7//wANAAAAAADihwz1UiLnBwtibHVldG9vdGhkAHByb2ZpbGVzL2lu cHV0L2hvZy1saWIuYzpyZXBvcnRfY2NjX3dyaXR0ZW5fY2IoKSBSZXBvcnQgY2hhcmFjdGVy aXN0aWMgZGVzY3JpcHRvciB3cml0dGVuOiBub3RpZmljYXRpb25zIGVuYWJsZWQAAAAADQAA AA0AAAAEAAAAAADihwz1UiMOQAAJAAUABAAMPAAsAAAAAAcAAAAHAAAAAwAAAAAA4ocM9VJ5 ORMFAUAAAgAAAAAfAAAAHwAAAAUAAAAAAOKHDPVSfO1AIBsAFwAEAA3/f3UQlQKBBqEChRIJ SJUBdQIVACUBAAAADQAAAA0AAAAEAAAAAADihwz1Un3pQAAJAAUABAASGwABAAAAAAkAAAAJ AAAABQAAAAAA4ocM9VL7ykAgBQABAAQAEwAAAH4AAAB+//8ADQAAAAAA4ocM9VL+DwcLYmx1 ZXRvb3RoZABwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X2NjY193cml0dGVuX2Ni KCkgUmVwb3J0IGNoYXJhY3RlcmlzdGljIGRlc2NyaXB0b3Igd3JpdHRlbjogbm90aWZpY2F0 aW9ucyBlbmFibGVkAAAAAA0AAAANAAAABAAAAAAA4ocM9VL/E0AACQAFAAQAEh8AAQAAAAAH AAAABwAAAAMAAAAAAOKHDPVTKR4TBQFAAAIAAAAACQAAAAkAAAAFAAAAAADihwz1U3+kQCAF AAEABAATAAAAfgAAAH7//wANAAAAAADihwz1U4MgBwtibHVldG9vdGhkAHByb2ZpbGVzL2lu cHV0L2hvZy1saWIuYzpyZXBvcnRfY2NjX3dyaXR0ZW5fY2IoKSBSZXBvcnQgY2hhcmFjdGVy aXN0aWMgZGVzY3JpcHRvciB3cml0dGVuOiBub3RpZmljYXRpb25zIGVuYWJsZWQAAAAADQAA AA0AAAAEAAAAAADihwz1U4KUQAAJAAUABAASIwABAAAAAAkAAAAJAAAABQAAAAAA4ocM9VQD wUAgBQABAAQAEwAAAH4AAAB+//8ADQAAAAAA4ocM9VQF3AcLYmx1ZXRvb3RoZABwcm9maWxl cy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X2NjY193cml0dGVuX2NiKCkgUmVwb3J0IGNoYXJh Y3RlcmlzdGljIGRlc2NyaXB0b3Igd3JpdHRlbjogbm90aWZpY2F0aW9ucyBlbmFibGVkAAAA AA0AAAANAAAABAAAAAAA4ocM9VQGYEAACQAFAAQADCwALAAAAAAHAAAABwAAAAMAAAAAAOKH DPVU4lcTBQFAAAIAAAAABgAAAAYAAAADAAAAAADihwz1VhbwBQQAQAATAAAADgAAAA4AAAAR AAAAAADihwz1VhczAgAAAAwAt6cg+tjOAgMAAAAOAAAADgAAABEAAAAAAOKHDPVWFzMBAAAA DAC3pyD62M4CAwAAAF4AAABe//8ADQAAAAAA4ocM9VYcUwcLYmx1ZXRvb3RoZABzcmMvYWRh cHRlci5jOmRldl9kaXNjb25uZWN0ZWQoKSBEZXZpY2UgQ0U6RDg6RkE6MjA6QTc6QjcgZGlz Y29ubmVjdGVkLCByZWFzb24gMwAAAAA4AAAAOP//AA0AAAAAAOKHDPVWHY8HC2JsdWV0b290 aGQAc3JjL2FkYXB0ZXIuYzphZGFwdGVyX3JlbW92ZV9jb25uZWN0aW9uKCkgAAAAADcAAAA3 //8ADQAAAAAA4ocM9VYejgcLYmx1ZXRvb3RoZABwbHVnaW5zL3BvbGljeS5jOmRpc2Nvbm5l Y3RfY2IoKSByZWFzb24gMwAAAABmAAAAZv//AA0AAAAAAOKHDPVWH2UHC2JsdWV0b290aGQA c3JjL2FkYXB0ZXIuYzpib25kaW5nX2F0dGVtcHRfY29tcGxldGUoKSBoY2kwIGJkYWRkciBD RTpEODpGQToyMDpBNzpCNyB0eXBlIDIgc3RhdHVzIDB4ZQAAAABOAAAATv//AA0AAAAAAOKH DPVWIC8HC2JsdWV0b290aGQAc3JjL2RldmljZS5jOmRldmljZV9ib25kaW5nX2NvbXBsZXRl KCkgYm9uZGluZyAobmlsKSBzdGF0dXMgMHgwZQAAAAA8AAAAPP//AA0AAAAAAOKHDPVWIPQH C2JsdWV0b290aGQAc3JjL2RldmljZS5jOmRldmljZV9ib25kaW5nX2ZhaWxlZCgpIHN0YXR1 cyAxNAAAAAAvAAAAL///AA0AAAAAAOKHDPVWIogHC2JsdWV0b290aGQAc3JjL2FkYXB0ZXIu YzpyZXN1bWVfZGlzY292ZXJ5KCkgAAAAAFEAAABR//8ADQAAAAAA4ocM9VYjlQcLYmx1ZXRv b3RoZABhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3VucmVmKCkgMHg1NjE3MjIyNmVhYjA6 IGdfYXR0cmliX3VucmVmPTQgAAAAAFUAAABV//8ADQAAAAAA4ocM9VYkVAcLYmx1ZXRvb3Ro ZABwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgSG9HIGlu c3BlY3RpbmcgcmVwb3J0IG1hcAAAAABHAAAAR///AA0AAAAAAOKHDPVWJRoHC2JsdWV0b290 aGQAcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpIFJlcG9y dCBNQVA6AAAAAEMAAABD//8ADQAAAAAA4ocM9VYmAgcLYmx1ZXRvb3RoZABwcm9maWxlcy9p bnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgCSAwNSAwMQAAAABDAAAAQ/// AA0AAAAAAOKHDPVWJxoHC2JsdWV0b290aGQAcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJl cG9ydF9tYXBfcmVhZF9jYigpIAkgMDkgMDIAAAAAQwAAAEP//wANAAAAAADihwz1VigCBwti bHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2Io KSAJIGExIDAxAAAAAEMAAABD//8ADQAAAAAA4ocM9VYo5AcLYmx1ZXRvb3RoZABwcm9maWxl cy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgCSAwNSAwMQAAAABDAAAA Q///AA0AAAAAAOKHDPVWKb8HC2JsdWV0b290aGQAcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5j OnJlcG9ydF9tYXBfcmVhZF9jYigpIAkgMDkgMDIAAAAAQwAAAEP//wANAAAAAADihwz1VirN BwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRf Y2IoKSAJIGExIDAyAAAAAEMAAABD//8ADQAAAAAA4ocM9VYq/AcLYmx1ZXRvb3RoZABwcm9m aWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgCSA4NSAxYgAAAABD AAAAQ///AA0AAAAAAOKHDPVWKyoHC2JsdWV0b290aGQAcHJvZmlsZXMvaW5wdXQvaG9nLWxp Yi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpIAkgMDkgMDEAAAAAQwAAAEP//wANAAAAAADihwz1 VitXBwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3Jl YWRfY2IoKSAJIGExIDAwAAAAAEMAAABD//8ADQAAAAAA4ocM9VYrhAcLYmx1ZXRvb3RoZABw cm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgCSAwNSAwOQAA AABDAAAAQ///AA0AAAAAAOKHDPVWK7EHC2JsdWV0b290aGQAcHJvZmlsZXMvaW5wdXQvaG9n LWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpIAkgMTkgMDEAAAAAQwAAAEP//wANAAAAAADi hwz1VivdBwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFw X3JlYWRfY2IoKSAJIDI5IDA4AAAAAEMAAABD//8ADQAAAAAA4ocM9VYsCwcLYmx1ZXRvb3Ro ZABwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgCSAxNSAw MAAAAABDAAAAQ///AA0AAAAAAOKHDPVWLDcHC2JsdWV0b290aGQAcHJvZmlsZXMvaW5wdXQv aG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpIAkgMjUgMDEAAAAAQwAAAEP//wANAAAA AADihwz1VixjBwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRf bWFwX3JlYWRfY2IoKSAJIDk1IDA4AAAAAEMAAABD//8ADQAAAAAA4ocM9VYskQcLYmx1ZXRv b3RoZABwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgCSA3 NSAwMQAAAABDAAAAQ///AA0AAAAAAOKHDPVWLL8HC2JsdWV0b290aGQAcHJvZmlsZXMvaW5w dXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpIAkgODEgMDIAAAAAQwAAAEP//wAN AAAAAADihwz1VizzBwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBv cnRfbWFwX3JlYWRfY2IoKSAJIDA1IDAxAAAAAEMAAABD//8ADQAAAAAA4ocM9VYtNgcLYmx1 ZXRvb3RoZABwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkg CSAwOSAzMAAAAABDAAAAQ///AA0AAAAAAOKHDPVWLWcHC2JsdWV0b290aGQAcHJvZmlsZXMv aW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpIAkgMDkgMzEAAAAARgAAAEb/ /wANAAAAAADihwz1Vi2YBwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpy ZXBvcnRfbWFwX3JlYWRfY2IoKSAJIDE2IDAyIDgwAAAAAEYAAABG//8ADQAAAAAA4ocM9VYt yQcLYmx1ZXRvb3RoZABwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFk X2NiKCkgCSAyNiBmZiA3ZgAAAABDAAAAQ///AA0AAAAAAOKHDPVWLgwHC2JsdWV0b290aGQA cHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpIAkgNzUgMTAA AAAAQwAAAEP//wANAAAAAADihwz1Vi5LBwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0L2hv Zy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAJIDk1IDAyAAAAAEMAAABD//8ADQAAAAAA 4ocM9VYuhAcLYmx1ZXRvb3RoZABwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21h cF9yZWFkX2NiKCkgCSA4MSAwNgAAAABDAAAAQ///AA0AAAAAAOKHDPVWLr4HC2JsdWV0b290 aGQAcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpIAkgYTEg MDIAAAAAQwAAAEP//wANAAAAAADihwz1Vi8NBwtibHVldG9vdGhkAHByb2ZpbGVzL2lucHV0 L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAJIDg1IDEyAAAAAEMAAABD//8ADQAA AAAA4ocM9VYvRwcLYmx1ZXRvb3RoZABwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0 X21hcF9yZWFkX2NiKCkgCSAwOSA0OAAAAABDAAAAQ///AA0AAAAAAOKHDPVWL3sHC2JsdWV0 b290aGQAcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpIAkg OTUgMDEAAAAAQwAAAEP//wANAAAAAADihwz1Vi+rBwtibHVldG9vdGhkAHByb2ZpbGVzL2lu cHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAJIDc1IDAyAAAAAEMAAABD//8A DQAAAAAA4ocM9VYv4wcLYmx1ZXRvb3RoZABwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVw b3J0X21hcF9yZWFkX2NiKCkgCSAxNSAwMAAAAABDAAAAQ///AA0AAAAAAOKHDPVWMJ8HC2Js dWV0b290aGQAcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigp IAkgMjUgMDEAAAAACgAAAAoAAAACAAAAAADihwz1VlFsCyAHAGAAMAAAAAAAAAYAAAAGAAAA AwAAAAAA4ocM9VZVMw4EAQsgAAAAAAUAAAAFAAAAAgAAAAAA4ocM9VZVSgwgAgEBAAAABgAA AAYAAAADAAAAAADihwz1VlksDgQBDCAAAAAABAAAAAT//wAPAAAAAADihwz1WvnVAQAAAAAA ACoAAAAqAAAAAwAAAAAA4ocM9+7vvD4oAgEDAAfficCd1Bwb/3UAQgQBgGDUncCJ3wfWncCJ 3wYBAAAAAAAAugAAABUAAAAVAAAAAwAAAAAA4ocM9+8bHj4TAgEAAJ6XkgLikAcCAQYDAhL/ tg== --1b501d68867e4954a0fb4b765137a701 Content-Disposition: attachment;filename="stack.txt" Content-Type: text/plain; name="stack.txt" Content-Transfer-Encoding: BASE64 IzAgIGdfaW9fY2hhbm5lbF91bml4X2dldF9mZCAoY2hhbm5lbD0weDApIGF0IC4uL2dsaWIv Z2lvdW5peC5jOjY1NgojMSAgMHgwMDAwNTU1NTU1NWI2OGEzIGluIGJ0X2lvX2dldF90eXBl IChpbz08b3B0aW1pemVkIG91dD4sIGdlcnI9MHg3ZmZmZmZmZmMyYTApIGF0IGJ0aW8vYnRp by5jOjEwNQojMiAgMHgwMDAwNTU1NTU1NWI4OGRjIGluIGJ0X2lvX2dldCAoaW89MHgwLCBl cnI9MHg3ZmZmZmZmZmMyYTAsIG9wdDE9QlRfSU9fT1BUX1NPVVJDRSkgYXQgYnRpby9idGlv LmM6MTUxMwojMyAgMHgwMDAwNTU1NTU1NWExZTgyIGluIHJlcG9ydF9tYXBfcmVhZF9jYiAo c3RhdHVzPTxvcHRpbWl6ZWQgb3V0PiwgcGR1PTxvcHRpbWl6ZWQgb3V0PiwgcGxlbj08b3B0 aW1pemVkIG91dD4sCiAgICB1c2VyX2RhdGE9PG9wdGltaXplZCBvdXQ+KSBhdCBwcm9maWxl cy9pbnB1dC9ob2ctbGliLmM6OTkyCiM0ICAweDAwMDA1NTU1NTU1YjMzNWMgaW4gcmVhZF9i bG9iX2hlbHBlciAoc3RhdHVzPTAgJ1wwMDAnLCBycGR1PTxvcHRpbWl6ZWQgb3V0Piwgcmxl bj0xMywKICAgIHVzZXJfZGF0YT0weDU1NTU1NTZkM2ViMCkgYXQgYXR0cmliL2dhdHQuYzo4 MDQKIzUgIDB4MDAwMDU1NTU1NTViNDRjNiBpbiBhdHRyaWJfY2FsbGJhY2tfcmVzdWx0IChv cGNvZGU9PG9wdGltaXplZCBvdXQ+LCBwZHU9MHg1NTU1NTU2ZDVjMDEsCiAgICBsZW5ndGg9 PG9wdGltaXplZCBvdXQ+LCB1c2VyX2RhdGE9MHg1NTU1NTU2YzY4ODApIGF0IGF0dHJpYi9n YXR0cmliLmM6MjczCiM2ICAweDAwMDA1NTU1NTU2MGI5NTAgaW4gaGFuZGxlX3JzcCAoYXR0 PTB4NTU1NTU1NmM0MjAwLCBvcGNvZGU9PG9wdGltaXplZCBvdXQ+LCBwZHU9PG9wdGltaXpl ZCBvdXQ+LAogICAgcGR1X2xlbj08b3B0aW1pemVkIG91dD4pIGF0IHNyYy9zaGFyZWQvYXR0 LmM6NzE1CiM3ICAweDAwMDA1NTU1NTU2MGJhZWQgaW4gY2FuX3JlYWRfZGF0YSAoaW89PG9w dGltaXplZCBvdXQ+LCB1c2VyX2RhdGE9MHg1NTU1NTU2YzQyMDApIGF0IHNyYy9zaGFyZWQv YXR0LmM6OTA0CiM4ICAweDAwMDA1NTU1NTU2MTU0MjkgaW4gd2F0Y2hfY2FsbGJhY2sgKGNo YW5uZWw9PG9wdGltaXplZCBvdXQ+LCBjb25kPTxvcHRpbWl6ZWQgb3V0PiwgdXNlcl9kYXRh PTxvcHRpbWl6ZWQgb3V0PikKICAgIGF0IHNyYy9zaGFyZWQvaW8tZ2xpYi5jOjE3MAojOSAg MHgwMDAwN2ZmZmY3ZWY5YzFlIGluIGdfbWFpbl9kaXNwYXRjaCAoY29udGV4dD0weDU1NTU1 NTY4OWQzMCkgYXQgLi4vZ2xpYi9nbWFpbi5jOjMxNzkKIzEwIGdfbWFpbl9jb250ZXh0X2Rp c3BhdGNoIChjb250ZXh0PWNvbnRleHRAZW50cnk9MHg1NTU1NTU2ODlkMzApIGF0IC4uL2ds aWIvZ21haW4uYzozODQ0CiMxMSAweDAwMDA3ZmZmZjdlZjlmZDAgaW4gZ19tYWluX2NvbnRl eHRfaXRlcmF0ZSAoY29udGV4dD0weDU1NTU1NTY4OWQzMCwgYmxvY2s9YmxvY2tAZW50cnk9 MSwKICAgIGRpc3BhdGNoPWRpc3BhdGNoQGVudHJ5PTEsIHNlbGY9PG9wdGltaXplZCBvdXQ+ KSBhdCAuLi9nbGliL2dtYWluLmM6MzkxNwojMTIgMHgwMDAwN2ZmZmY3ZWZhMmEzIGluIGdf bWFpbl9sb29wX3J1biAobG9vcD0weDU1NTU1NTY4YWVlMCkgYXQgLi4vZ2xpYi9nbWFpbi5j OjQxMTEKIzEzIDB4MDAwMDU1NTU1NTYxNTliMSBpbiBtYWlubG9vcF9ydW4gKCkgYXQgc3Jj L3NoYXJlZC9tYWlubG9vcC1nbGliLmM6NzkKIzE0IDB4MDAwMDU1NTU1NTYxNWRiOCBpbiBt YWlubG9vcF9ydW5fd2l0aF9zaWduYWwgKGZ1bmM9PG9wdGltaXplZCBvdXQ+LCB1c2VyX2Rh dGE9MHgwKQogICAgYXQgc3JjL3NoYXJlZC9tYWlubG9vcC1ub3RpZnkuYzoyMDEKIzE1IDB4 MDAwMDU1NTU1NTViYTZiNSBpbiBtYWluIChhcmdjPTxvcHRpbWl6ZWQgb3V0PiwgYXJndj08 b3B0aW1pemVkIG91dD4pIGF0IHNyYy9tYWluLmM6NzI5Cg== --1b501d68867e4954a0fb4b765137a701 Content-Disposition: attachment;filename="debug.txt" Content-Type: text/plain; name="debug.txt" Content-Transfer-Encoding: BASE64 Ymx1ZXRvb3RoZFs4MTY2XTogc3JjL2FkYXB0ZXIuYzpjb25uZWN0ZWRfY2FsbGJhY2soKSBo Y2kwIGRldmljZSBDRTpEODpGQToyMDpBNzpCNyBjb25uZWN0ZWQgZWlyX2xlbiAwCmJsdWV0 b290aGRbODE2Nl06IHNyYy9nYXR0LWRhdGFiYXNlLmM6Y29ubmVjdF9jYigpIE5ldyBpbmNv bWluZyBMRSBBVFQgY29ubmVjdGlvbgpibHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6 ZGV2aWNlX2F0dGFjaF9hdHQoKSBFbGV2YXRpbmcgc2VjdXJpdHkgbGV2ZWwgc2luY2UgTFRL IGlzIGF2YWlsYWJsZQpibHVldG9vdGhkWzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0 cmliX3JlZigpIDB4NTU5Y2NlYjE1YWIwOiBnX2F0dHJpYl9yZWY9MQpibHVldG9vdGhkWzgx NjZdOiBzcmMvZGV2aWNlLmM6bG9hZF9nYXR0X2RiKCkgUmVzdG9yaW5nIENFOkQ4OkZBOjIw OkE3OkI3IGdhdHQgZGF0YWJhc2UgZnJvbSBmaWxlCmJsdWV0b290aGRbODE2Nl06IHNyYy9k ZXZpY2UuYzpsb2FkX3NlcnZpY2UoKSBsb2FkaW5nIHNlcnZpY2U6IDB4MDAwMSwgZW5kOiAw eDAwMDcsIHV1aWQ6IDAwMDAxODAwLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgpibHVl dG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6bG9hZF9zZXJ2aWNlKCkgbG9hZGluZyBzZXJ2 aWNlOiAweDAwMDgsIGVuZDogMHgwMDA4LCB1dWlkOiAwMDAwMTgwMS0wMDAwLTEwMDAtODAw MC0wMDgwNWY5YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2RldmljZS5jOmxvYWRfc2Vy dmljZSgpIGxvYWRpbmcgc2VydmljZTogMHgwMDA5LCBlbmQ6IDB4MDAxMSwgdXVpZDogMDAw MDE4MGEtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06IHNy Yy9kZXZpY2UuYzpsb2FkX3NlcnZpY2UoKSBsb2FkaW5nIHNlcnZpY2U6IDB4MDAxMiwgZW5k OiAweDAwMTYsIHV1aWQ6IDAwMDAxODBmLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgpi bHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6bG9hZF9zZXJ2aWNlKCkgbG9hZGluZyBz ZXJ2aWNlOiAweDAwMTcsIGVuZDogMHgwMDMwLCB1dWlkOiAwMDAwMTgxMi0wMDAwLTEwMDAt ODAwMC0wMDgwNWY5YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2RldmljZS5jOmxvYWRf c2VydmljZSgpIGxvYWRpbmcgc2VydmljZTogMHgwMDMxLCBlbmQ6IDB4ZmZmZiwgdXVpZDog MDAwMDE4MTItMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06 IHNyYy9kZXZpY2UuYzpsb2FkX2NocmMoKSBsb2FkaW5nIGNoYXJhY3RlcmlzdGljIGhhbmRs ZTogMHgwMDAyLCB2YWx1ZSBoYW5kbGU6IDB4MDAwMywgcHJvcGVydGllcyAweDAwMGEgdmFs dWU6ICB1dWlkOiAwMDAwMmEwMC0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIKYmx1ZXRv b3RoZFs4MTY2XTogc3JjL2RldmljZS5jOmxvYWRfY2hyYygpIGxvYWRpbmcgY2hhcmFjdGVy aXN0aWMgaGFuZGxlOiAweDAwMDQsIHZhbHVlIGhhbmRsZTogMHgwMDA1LCBwcm9wZXJ0aWVz IDB4MDAwMiB2YWx1ZTogIHV1aWQ6IDAwMDAyYTAxLTAwMDAtMTAwMC04MDAwLTAwODA1Zjli MzRmYgpibHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGlu ZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAwNiwgdmFsdWUgaGFuZGxlOiAweDAwMDcs IHByb3BlcnRpZXMgMHgwMDAyIHZhbHVlOiAgdXVpZDogMDAwMDJhMDQtMDAwMC0xMDAwLTgw MDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06IHNyYy9kZXZpY2UuYzpsb2FkX2No cmMoKSBsb2FkaW5nIGNoYXJhY3RlcmlzdGljIGhhbmRsZTogMHgwMDBhLCB2YWx1ZSBoYW5k bGU6IDB4MDAwYiwgcHJvcGVydGllcyAweDAwMDIgdmFsdWU6ICB1dWlkOiAwMDAwMmEyOS0w MDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2Rldmlj ZS5jOmxvYWRfY2hyYygpIGxvYWRpbmcgY2hhcmFjdGVyaXN0aWMgaGFuZGxlOiAweDAwMGMs IHZhbHVlIGhhbmRsZTogMHgwMDBkLCBwcm9wZXJ0aWVzIDB4MDAwMiB2YWx1ZTogIHV1aWQ6 IDAwMDAyYTI0LTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgpibHVldG9vdGhkWzgxNjZd OiBzcmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5k bGU6IDB4MDAwZSwgdmFsdWUgaGFuZGxlOiAweDAwMGYsIHByb3BlcnRpZXMgMHgwMDAyIHZh bHVlOiAgdXVpZDogMDAwMDJhMjYtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0 b290aGRbODE2Nl06IHNyYy9kZXZpY2UuYzpsb2FkX2NocmMoKSBsb2FkaW5nIGNoYXJhY3Rl cmlzdGljIGhhbmRsZTogMHgwMDEwLCB2YWx1ZSBoYW5kbGU6IDB4MDAxMSwgcHJvcGVydGll cyAweDAwMDIgdmFsdWU6ICB1dWlkOiAwMDAwMmE1MC0wMDAwLTEwMDAtODAwMC0wMDgwNWY5 YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2RldmljZS5jOmxvYWRfY2hyYygpIGxvYWRp bmcgY2hhcmFjdGVyaXN0aWMgaGFuZGxlOiAweDAwMTMsIHZhbHVlIGhhbmRsZTogMHgwMDE0 LCBwcm9wZXJ0aWVzIDB4MDAxMiB2YWx1ZTogIHV1aWQ6IDAwMDAyYTE5LTAwMDAtMTAwMC04 MDAwLTAwODA1ZjliMzRmYgpibHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6bG9hZF9k ZXNjKCkgbG9hZGluZyBkZXNjcmlwdG9yIGhhbmRsZTogMHgwMDE1LCB2YWx1ZTogMHgwMDAw LCB2YWx1ZSB1dWlkOiAwMDAwMjkwMi0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIKYmx1 ZXRvb3RoZFs4MTY2XTogc3JjL2RldmljZS5jOmxvYWRfZGVzYygpIGxvYWRpbmcgZGVzY3Jp cHRvciBoYW5kbGU6IDB4MDAxNiwgdmFsdWU6IDB4MDAwMCwgdmFsdWUgdXVpZDogMDAwMDI5 MDgtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06IHNyYy9k ZXZpY2UuYzpsb2FkX2luY2woKSBsb2FkaW5nIGluY2x1ZGVkIHNlcnZpY2U6IDB4MDAxMiwg ZW5kOiAweDAwMTYsIHV1aWQ6IDAwMDAxODBmLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRm YgpibHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGluZyBj aGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAxOSwgdmFsdWUgaGFuZGxlOiAweDAwMWEsIHBy b3BlcnRpZXMgMHgwMDFhIHZhbHVlOiAgdXVpZDogMDAwMDJhNGQtMDAwMC0xMDAwLTgwMDAt MDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06IHNyYy9kZXZpY2UuYzpsb2FkX2Rlc2Mo KSBsb2FkaW5nIGRlc2NyaXB0b3IgaGFuZGxlOiAweDAwMWIsIHZhbHVlOiAweDAwMDAsIHZh bHVlIHV1aWQ6IDAwMDAyOTAyLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgpibHVldG9v dGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6bG9hZF9kZXNjKCkgbG9hZGluZyBkZXNjcmlwdG9y IGhhbmRsZTogMHgwMDFjLCB2YWx1ZTogMHgwMDAwLCB2YWx1ZSB1dWlkOiAwMDAwMjkwOC0w MDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2Rldmlj ZS5jOmxvYWRfY2hyYygpIGxvYWRpbmcgY2hhcmFjdGVyaXN0aWMgaGFuZGxlOiAweDAwMWQs IHZhbHVlIGhhbmRsZTogMHgwMDFlLCBwcm9wZXJ0aWVzIDB4MDAxYSB2YWx1ZTogIHV1aWQ6 IDAwMDAyYTRkLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgpibHVldG9vdGhkWzgxNjZd OiBzcmMvZGV2aWNlLmM6bG9hZF9kZXNjKCkgbG9hZGluZyBkZXNjcmlwdG9yIGhhbmRsZTog MHgwMDFmLCB2YWx1ZTogMHgwMDAwLCB2YWx1ZSB1dWlkOiAwMDAwMjkwMi0wMDAwLTEwMDAt ODAwMC0wMDgwNWY5YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2RldmljZS5jOmxvYWRf ZGVzYygpIGxvYWRpbmcgZGVzY3JpcHRvciBoYW5kbGU6IDB4MDAyMCwgdmFsdWU6IDB4MDAw MCwgdmFsdWUgdXVpZDogMDAwMDI5MDgtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJs dWV0b290aGRbODE2Nl06IHNyYy9kZXZpY2UuYzpsb2FkX2NocmMoKSBsb2FkaW5nIGNoYXJh Y3RlcmlzdGljIGhhbmRsZTogMHgwMDIxLCB2YWx1ZSBoYW5kbGU6IDB4MDAyMiwgcHJvcGVy dGllcyAweDAwMWEgdmFsdWU6ICB1dWlkOiAwMDAwMmE0ZC0wMDAwLTEwMDAtODAwMC0wMDgw NWY5YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2RldmljZS5jOmxvYWRfZGVzYygpIGxv YWRpbmcgZGVzY3JpcHRvciBoYW5kbGU6IDB4MDAyMywgdmFsdWU6IDB4MDAwMCwgdmFsdWUg dXVpZDogMDAwMDI5MDItMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRb ODE2Nl06IHNyYy9kZXZpY2UuYzpsb2FkX2Rlc2MoKSBsb2FkaW5nIGRlc2NyaXB0b3IgaGFu ZGxlOiAweDAwMjQsIHZhbHVlOiAweDAwMDAsIHZhbHVlIHV1aWQ6IDAwMDAyOTA4LTAwMDAt MTAwMC04MDAwLTAwODA1ZjliMzRmYgpibHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6 bG9hZF9jaHJjKCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAyNSwgdmFs dWUgaGFuZGxlOiAweDAwMjYsIHByb3BlcnRpZXMgMHgwMDBhIHZhbHVlOiAgdXVpZDogMDAw MDJhNGQtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06IHNy Yy9kZXZpY2UuYzpsb2FkX2Rlc2MoKSBsb2FkaW5nIGRlc2NyaXB0b3IgaGFuZGxlOiAweDAw MjcsIHZhbHVlOiAweDAwMDAsIHZhbHVlIHV1aWQ6IDAwMDAyOTA4LTAwMDAtMTAwMC04MDAw LTAwODA1ZjliMzRmYgpibHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6bG9hZF9jaHJj KCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAyOCwgdmFsdWUgaGFuZGxl OiAweDAwMjksIHByb3BlcnRpZXMgMHgwMDBhIHZhbHVlOiAgdXVpZDogMDAwMDJhNGQtMDAw MC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06IHNyYy9kZXZpY2Uu Yzpsb2FkX2Rlc2MoKSBsb2FkaW5nIGRlc2NyaXB0b3IgaGFuZGxlOiAweDAwMmEsIHZhbHVl OiAweDAwMDAsIHZhbHVlIHV1aWQ6IDAwMDAyOTA4LTAwMDAtMTAwMC04MDAwLTAwODA1Zjli MzRmYgpibHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGlu ZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAyYiwgdmFsdWUgaGFuZGxlOiAweDAwMmMs IHByb3BlcnRpZXMgMHgwMDAyIHZhbHVlOiAgdXVpZDogMDAwMDJhNGItMDAwMC0xMDAwLTgw MDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06IHNyYy9kZXZpY2UuYzpsb2FkX2No cmMoKSBsb2FkaW5nIGNoYXJhY3RlcmlzdGljIGhhbmRsZTogMHgwMDJkLCB2YWx1ZSBoYW5k bGU6IDB4MDAyZSwgcHJvcGVydGllcyAweDAwMDIgdmFsdWU6ICB1dWlkOiAwMDAwMmE0YS0w MDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2Rldmlj ZS5jOmxvYWRfY2hyYygpIGxvYWRpbmcgY2hhcmFjdGVyaXN0aWMgaGFuZGxlOiAweDAwMmYs IHZhbHVlIGhhbmRsZTogMHgwMDMwLCBwcm9wZXJ0aWVzIDB4MDAwNCB2YWx1ZTogIHV1aWQ6 IDAwMDAyYTRjLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgpibHVldG9vdGhkWzgxNjZd OiBzcmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5k bGU6IDB4MDAzMiwgdmFsdWUgaGFuZGxlOiAweDAwMzMsIHByb3BlcnRpZXMgMHgwMDA2IHZh bHVlOiAgdXVpZDogMDAwMDJhNGUtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0 b290aGRbODE2Nl06IHNyYy9kZXZpY2UuYzpsb2FkX2NocmMoKSBsb2FkaW5nIGNoYXJhY3Rl cmlzdGljIGhhbmRsZTogMHgwMDM0LCB2YWx1ZSBoYW5kbGU6IDB4MDAzNSwgcHJvcGVydGll cyAweDAwMWEgdmFsdWU6ICB1dWlkOiAwMDAwMmE0ZC0wMDAwLTEwMDAtODAwMC0wMDgwNWY5 YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2RldmljZS5jOmxvYWRfZGVzYygpIGxvYWRp bmcgZGVzY3JpcHRvciBoYW5kbGU6IDB4MDAzNiwgdmFsdWU6IDB4MDAwMCwgdmFsdWUgdXVp ZDogMDAwMDI5MDItMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2 Nl06IHNyYy9kZXZpY2UuYzpsb2FkX2Rlc2MoKSBsb2FkaW5nIGRlc2NyaXB0b3IgaGFuZGxl OiAweDAwMzcsIHZhbHVlOiAweDAwMDAsIHZhbHVlIHV1aWQ6IDAwMDAyOTA4LTAwMDAtMTAw MC04MDAwLTAwODA1ZjliMzRmYgpibHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6bG9h ZF9jaHJjKCkgbG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAzOCwgdmFsdWUg aGFuZGxlOiAweDAwMzksIHByb3BlcnRpZXMgMHgwMDBhIHZhbHVlOiAgdXVpZDogMDAwMDJh NGQtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06IHNyYy9k ZXZpY2UuYzpsb2FkX2Rlc2MoKSBsb2FkaW5nIGRlc2NyaXB0b3IgaGFuZGxlOiAweDAwM2Es IHZhbHVlOiAweDAwMDAsIHZhbHVlIHV1aWQ6IDAwMDAyOTA4LTAwMDAtMTAwMC04MDAwLTAw ODA1ZjliMzRmYgpibHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6bG9hZF9jaHJjKCkg bG9hZGluZyBjaGFyYWN0ZXJpc3RpYyBoYW5kbGU6IDB4MDAzYiwgdmFsdWUgaGFuZGxlOiAw eDAwM2MsIHByb3BlcnRpZXMgMHgwMDAyIHZhbHVlOiAgdXVpZDogMDAwMDJhNGItMDAwMC0x MDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06IHNyYy9kZXZpY2UuYzps b2FkX2NocmMoKSBsb2FkaW5nIGNoYXJhY3RlcmlzdGljIGhhbmRsZTogMHgwMDNkLCB2YWx1 ZSBoYW5kbGU6IDB4MDAzZSwgcHJvcGVydGllcyAweDAwMWEgdmFsdWU6ICB1dWlkOiAwMDAw MmEzMy0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogc3Jj L2RldmljZS5jOmxvYWRfZGVzYygpIGxvYWRpbmcgZGVzY3JpcHRvciBoYW5kbGU6IDB4MDAz ZiwgdmFsdWU6IDB4MDAwMCwgdmFsdWUgdXVpZDogMDAwMDI5MDItMDAwMC0xMDAwLTgwMDAt MDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06IHNyYy9kZXZpY2UuYzpsb2FkX2NocmMo KSBsb2FkaW5nIGNoYXJhY3RlcmlzdGljIGhhbmRsZTogMHgwMDQwLCB2YWx1ZSBoYW5kbGU6 IDB4MDA0MSwgcHJvcGVydGllcyAweDAwMDIgdmFsdWU6ICB1dWlkOiAwMDAwMmE0YS0wMDAw LTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvYmF0 dGVyeS9iYXR0ZXJ5LmM6YmF0dF9hY2NlcHQoKSBCQVRUIHByb2ZpbGUgYWNjZXB0IChDRTpE ODpGQToyMDpBNzpCNykKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL3NlcnZpY2UuYzpjaGFuZ2Vf c3RhdGUoKSAweDU1OWNjZWIxZTJkMDogZGV2aWNlIENFOkQ4OkZBOjIwOkE3OkI3IHByb2Zp bGUgYmF0dC1wcm9maWxlIHN0YXRlIGNoYW5nZWQ6IGRpc2Nvbm5lY3RlZCAtPiBjb25uZWN0 ZWQgKDApCmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2RldmljZWluZm8vZGV2aWNlaW5m by5jOmRldmljZWluZm9fYWNjZXB0KCkgZGV2aWNlaW5mbyBwcm9maWxlIGFjY2VwdCAoQ0U6 RDg6RkE6MjA6QTc6QjcpCmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2RldmljZWluZm8v ZGV2aWNlaW5mby5jOmhhbmRsZV9jaGFyYWN0ZXJpc3RpYygpIFVuc3VwcG9ydGVkIGNoYXJh Y3RlcmlzdGljOiAwMDAwMmEyOS0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIKYmx1ZXRv b3RoZFs4MTY2XTogcHJvZmlsZXMvZGV2aWNlaW5mby9kZXZpY2VpbmZvLmM6aGFuZGxlX2No YXJhY3RlcmlzdGljKCkgVW5zdXBwb3J0ZWQgY2hhcmFjdGVyaXN0aWM6IDAwMDAyYTI0LTAw MDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgpibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9k ZXZpY2VpbmZvL2RldmljZWluZm8uYzpoYW5kbGVfY2hhcmFjdGVyaXN0aWMoKSBVbnN1cHBv cnRlZCBjaGFyYWN0ZXJpc3RpYzogMDAwMDJhMjYtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIz NGZiCmJsdWV0b290aGRbODE2Nl06IHNyYy9zZXJ2aWNlLmM6Y2hhbmdlX3N0YXRlKCkgMHg1 NTljY2ViMWU0NjA6IGRldmljZSBDRTpEODpGQToyMDpBNzpCNyBwcm9maWxlIGRldmljZWlu Zm8gc3RhdGUgY2hhbmdlZDogZGlzY29ubmVjdGVkIC0+IGNvbm5lY3RlZCAoMCkKYmx1ZXRv b3RoZFs4MTY2XTogcHJvZmlsZXMvZ2FwL2dhcy5jOmdhcF9hY2NlcHQoKSBHQVAgcHJvZmls ZSBhY2NlcHQgKENFOkQ4OkZBOjIwOkE3OkI3KQpibHVldG9vdGhkWzgxNjZdOiBwcm9maWxl cy9nYXAvZ2FzLmM6aGFuZGxlX2NoYXJhY3RlcmlzdGljKCkgVW5zdXBwb3J0ZWQgY2hhcmFj dGVyaXN0aWM6IDAwMDAyYTA0LTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgpibHVldG9v dGhkWzgxNjZdOiBzcmMvc2VydmljZS5jOmNoYW5nZV9zdGF0ZSgpIDB4NTU5Y2NlYjFlMjYw OiBkZXZpY2UgQ0U6RDg6RkE6MjA6QTc6QjcgcHJvZmlsZSBnYXAtcHJvZmlsZSBzdGF0ZSBj aGFuZ2VkOiBkaXNjb25uZWN0ZWQgLT4gY29ubmVjdGVkICgwKQpibHVldG9vdGhkWzgxNjZd OiBwcm9maWxlcy9pbnB1dC9ob2cuYzpob2dfZGV2aWNlX2FjY2VwdCgpIG5hbWU9Q2FkTW91 c2UgUHJvIFdpcmVsZXNzIHZlbmRvcj0weDI1NkYsIHByb2R1Y3Q9MHhDNjU0LCB2ZXJzaW9u PTB4MTA2CmJsdWV0b290aGRbODE2Nl06IGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfcmVm KCkgMHg1NTljY2ViMTVhYjA6IGdfYXR0cmliX3JlZj0yCmJsdWV0b290aGRbODE2Nl06IGF0 dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfcmVmKCkgMHg1NTljY2ViMTVhYjA6IGdfYXR0cmli X3JlZj0zCmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpidF9o b2dfYXR0YWNoKCkgSG9HIGRpc2NvdmVyaW5nIGNoYXJhY3RlcmlzdGljcwpibHVldG9vdGhk WzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3JlZigpIDB4NTU5Y2NlYjE1YWIw OiBnX2F0dHJpYl9yZWY9NApibHVldG9vdGhkWzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdf YXR0cmliX3JlZigpIDB4NTU5Y2NlYjE1YWIwOiBnX2F0dHJpYl9yZWY9NQpibHVldG9vdGhk WzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3JlZigpIDB4NTU5Y2NlYjE1YWIw OiBnX2F0dHJpYl9yZWY9NgpibHVldG9vdGhkWzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdf YXR0cmliX3JlZigpIDB4NTU5Y2NlYjE1YWIwOiBnX2F0dHJpYl9yZWY9NwpibHVldG9vdGhk WzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3JlZigpIDB4NTU5Y2NlYjE1YWIw OiBnX2F0dHJpYl9yZWY9OApibHVldG9vdGhkWzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdf YXR0cmliX3JlZigpIDB4NTU5Y2NlYjE1YWIwOiBnX2F0dHJpYl9yZWY9OQpibHVldG9vdGhk WzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3JlZigpIDB4NTU5Y2NlYjE1YWIw OiBnX2F0dHJpYl9yZWY9MTAKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9n LWxpYi5jOmJ0X2hvZ19hdHRhY2goKSBIb0cgZGlzY292ZXJpbmcgY2hhcmFjdGVyaXN0aWNz CmJsdWV0b290aGRbODE2Nl06IGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfcmVmKCkgMHg1 NTljY2ViMTVhYjA6IGdfYXR0cmliX3JlZj0xMQpibHVldG9vdGhkWzgxNjZdOiBhdHRyaWIv Z2F0dHJpYi5jOmdfYXR0cmliX3JlZigpIDB4NTU5Y2NlYjE1YWIwOiBnX2F0dHJpYl9yZWY9 MTIKYmx1ZXRvb3RoZFs4MTY2XTogYXR0cmliL2dhdHRyaWIuYzpnX2F0dHJpYl9yZWYoKSAw eDU1OWNjZWIxNWFiMDogZ19hdHRyaWJfcmVmPTEzCmJsdWV0b290aGRbODE2Nl06IGF0dHJp Yi9nYXR0cmliLmM6Z19hdHRyaWJfcmVmKCkgMHg1NTljY2ViMTVhYjA6IGdfYXR0cmliX3Jl Zj0xNApibHVldG9vdGhkWzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3JlZigp IDB4NTU5Y2NlYjE1YWIwOiBnX2F0dHJpYl9yZWY9MTUKYmx1ZXRvb3RoZFs4MTY2XTogYXR0 cmliL2dhdHRyaWIuYzpnX2F0dHJpYl9yZWYoKSAweDU1OWNjZWIxNWFiMDogZ19hdHRyaWJf cmVmPTE2CmJsdWV0b290aGRbODE2Nl06IGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfcmVm KCkgMHg1NTljY2ViMTVhYjA6IGdfYXR0cmliX3JlZj0xNwpibHVldG9vdGhkWzgxNjZdOiBz cmMvc2VydmljZS5jOmNoYW5nZV9zdGF0ZSgpIDB4NTU5Y2NlYjFkNWYwOiBkZXZpY2UgQ0U6 RDg6RkE6MjA6QTc6QjcgcHJvZmlsZSBpbnB1dC1ob2cgc3RhdGUgY2hhbmdlZDogZGlzY29u bmVjdGVkIC0+IGNvbm5lY3RlZCAoMCkKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL3NlcnZpY2Uu YzpidGRfc2VydmljZV9yZWYoKSAweDU1OWNjZWIxZDVmMDogcmVmPTIKYmx1ZXRvb3RoZFs4 MTY2XTogcGx1Z2lucy9wb2xpY3kuYzpzZXJ2aWNlX2NiKCkgQWRkZWQgaW5wdXQtaG9nIHJl Y29ubmVjdCAwCmJsdWV0b290aGRbODE2Nl06IHNyYy9nYXR0LWNsaWVudC5jOmJ0ZF9nYXR0 X2NsaWVudF9jb25uZWN0ZWQoKSBEZXZpY2UgY29ubmVjdGVkLgpibHVldG9vdGhkWzgxNjZd OiBzcmMvZ2F0dC1kYXRhYmFzZS5jOnNlbmRfbm90aWZpY2F0aW9uX3RvX2RldmljZSgpIEdB VFQgc2VydmVyIHNlbmRpbmcgaW5kaWNhdGlvbgpibHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2 aWNlLmM6Z2F0dF9kZWJ1ZygpIE1UVSBleGNoYW5nZSBjb21wbGV0ZSwgd2l0aCBNVFU6IDIz CmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2dhcC9nYXMuYzpyZWFkX2RldmljZV9uYW1l X2NiKCkgR0FQIERldmljZSBOYW1lOiBDYWRNb3VzZSBQcm8gV2lyZWxlc3MKYmx1ZXRvb3Ro ZFs4MTY2XTogcHJvZmlsZXMvZ2FwL2dhcy5jOnJlYWRfYXBwZWFyYW5jZV9jYigpIEdBUCBB cHBlYXJhbmNlOiAweDAzYzIKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9n LWxpYi5jOnByb3RvX21vZGVfcmVhZF9jYigpIEhvRyBpcyBvcGVyYXRpbmcgaW4gUmVwb3J0 IFByb3RvY29sIE1vZGUKYmx1ZXRvb3RoZFs4MTY2XTogYXR0cmliL2dhdHRyaWIuYzpnX2F0 dHJpYl91bnJlZigpIDB4NTU5Y2NlYjE1YWIwOiBnX2F0dHJpYl91bnJlZj0xNgpibHVldG9v dGhkWzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3VucmVmKCkgMHg1NTljY2Vi MTVhYjA6IGdfYXR0cmliX3VucmVmPTE1CmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2Jh dHRlcnkvYmF0dGVyeS5jOnBhcnNlX2JhdHRlcnlfbGV2ZWwoKSBCYXR0ZXJ5IExldmVsIHVw ZGF0ZWQ6IDkyJQpibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6 cmVwb3J0X3JlZmVyZW5jZV9jYigpIFJlcG9ydCAweDAwMzU6IGlkIDB4MWIgdHlwZSBpbnB1 dApibHVldG9vdGhkWzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3JlZigpIDB4 NTU5Y2NlYjE1YWIwOiBnX2F0dHJpYl9yZWY9MTYKYmx1ZXRvb3RoZFs4MTY2XTogYXR0cmli L2dhdHRyaWIuYzpnX2F0dHJpYl91bnJlZigpIDB4NTU5Y2NlYjE1YWIwOiBnX2F0dHJpYl91 bnJlZj0xNQpibHVldG9vdGhkWzgxNjZdOiBhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3Vu cmVmKCkgMHg1NTljY2ViMTVhYjA6IGdfYXR0cmliX3VucmVmPTE0CmJsdWV0b290aGRbODE2 Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfcmVmZXJlbmNlX2NiKCkgUmVw b3J0IDB4MDAzOTogaWQgMHgxMiB0eXBlIGZlYXR1cmUKYmx1ZXRvb3RoZFs4MTY2XTogYXR0 cmliL2dhdHRyaWIuYzpnX2F0dHJpYl91bnJlZigpIDB4NTU5Y2NlYjE1YWIwOiBnX2F0dHJp Yl91bnJlZj0xMwpibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6 aW5mb19yZWFkX2NiKCkgYmNkSElEOiAweDAxMTEgYkNvdW50cnlDb2RlOiAweDAwIEZsYWdz OiAweDAzCmJsdWV0b290aGRbODE2Nl06IGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfdW5y ZWYoKSAweDU1OWNjZWIxNWFiMDogZ19hdHRyaWJfdW5yZWY9MTIKYmx1ZXRvb3RoZFs4MTY2 XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9yZWZlcmVuY2VfY2IoKSBSZXBv cnQgMHgwMDFhOiBpZCAweDAxIHR5cGUgaW5wdXQKYmx1ZXRvb3RoZFs4MTY2XTogYXR0cmli L2dhdHRyaWIuYzpnX2F0dHJpYl9yZWYoKSAweDU1OWNjZWIxNWFiMDogZ19hdHRyaWJfcmVm PTEzCmJsdWV0b290aGRbODE2Nl06IGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfdW5yZWYo KSAweDU1OWNjZWIxNWFiMDogZ19hdHRyaWJfdW5yZWY9MTIKYmx1ZXRvb3RoZFs4MTY2XTog cHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9yZWZlcmVuY2VfY2IoKSBSZXBvcnQg MHgwMDFlOiBpZCAweDAzIHR5cGUgaW5wdXQKYmx1ZXRvb3RoZFs4MTY2XTogYXR0cmliL2dh dHRyaWIuYzpnX2F0dHJpYl9yZWYoKSAweDU1OWNjZWIxNWFiMDogZ19hdHRyaWJfcmVmPTEz CmJsdWV0b290aGRbODE2Nl06IGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfdW5yZWYoKSAw eDU1OWNjZWIxNWFiMDogZ19hdHRyaWJfdW5yZWY9MTIKYmx1ZXRvb3RoZFs4MTY2XTogcHJv ZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9yZWZlcmVuY2VfY2IoKSBSZXBvcnQgMHgw MDIyOiBpZCAweDE3IHR5cGUgaW5wdXQKYmx1ZXRvb3RoZFs4MTY2XTogYXR0cmliL2dhdHRy aWIuYzpnX2F0dHJpYl9yZWYoKSAweDU1OWNjZWIxNWFiMDogZ19hdHRyaWJfcmVmPTEzCmJs dWV0b290aGRbODE2Nl06IGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfdW5yZWYoKSAweDU1 OWNjZWIxNWFiMDogZ19hdHRyaWJfdW5yZWY9MTIKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmls ZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9yZWZlcmVuY2VfY2IoKSBSZXBvcnQgMHgwMDI2 OiBpZCAweDEwIHR5cGUgZmVhdHVyZQpibHVldG9vdGhkWzgxNjZdOiBhdHRyaWIvZ2F0dHJp Yi5jOmdfYXR0cmliX3VucmVmKCkgMHg1NTljY2ViMTVhYjA6IGdfYXR0cmliX3VucmVmPTEx CmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfcmVm ZXJlbmNlX2NiKCkgUmVwb3J0IDB4MDAyOTogaWQgMHgwOCB0eXBlIGZlYXR1cmUKYmx1ZXRv b3RoZFs4MTY2XTogYXR0cmliL2dhdHRyaWIuYzpnX2F0dHJpYl91bnJlZigpIDB4NTU5Y2Nl YjE1YWIwOiBnX2F0dHJpYl91bnJlZj0xMApibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9p bnB1dC9ob2ctbGliLmM6aW5mb19yZWFkX2NiKCkgYmNkSElEOiAweDAxMTEgYkNvdW50cnlD b2RlOiAweDAwIEZsYWdzOiAweDAzCmJsdWV0b290aGRbODE2Nl06IGF0dHJpYi9nYXR0cmli LmM6Z19hdHRyaWJfdW5yZWYoKSAweDU1OWNjZWIxNWFiMDogZ19hdHRyaWJfdW5yZWY9OQpi bHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9iYXR0ZXJ5L2JhdHRlcnkuYzpwYXJzZV9iYXR0 ZXJ5X2xldmVsKCkgQmF0dGVyeSBMZXZlbCB1cGRhdGVkOiAxMDAlCmJsdWV0b290aGRbODE2 Nl06IHByb2ZpbGVzL2JhdHRlcnkvYmF0dGVyeS5jOmJhdHRfaW9fY2NjX3dyaXR0ZW5fY2Io KSBCYXR0ZXJ5IExldmVsOiBub3RpZmljYXRpb24gZW5hYmxlZApibHVldG9vdGhkWzgxNjZd OiBhdHRyaWIvZ2F0dHJpYi5jOmdfYXR0cmliX3VucmVmKCkgMHg1NTljY2ViMTVhYjA6IGdf YXR0cmliX3VucmVmPTgKYmx1ZXRvb3RoZFs4MTY2XTogYXR0cmliL2dhdHRyaWIuYzpnX2F0 dHJpYl91bnJlZigpIDB4NTU5Y2NlYjE1YWIwOiBnX2F0dHJpYl91bnJlZj03CmJsdWV0b290 aGRbODE2Nl06IGF0dHJpYi9nYXR0cmliLmM6Z19hdHRyaWJfdW5yZWYoKSAweDU1OWNjZWIx NWFiMDogZ19hdHRyaWJfdW5yZWY9NgpibHVldG9vdGhkWzgxNjZdOiBhdHRyaWIvZ2F0dHJp Yi5jOmdfYXR0cmliX3VucmVmKCkgMHg1NTljY2ViMTVhYjA6IGdfYXR0cmliX3VucmVmPTUK Ymx1ZXRvb3RoZFs4MTY2XTogc3JjL2RldmljZS5jOmdhdHRfZGVidWcoKSBQcmltYXJ5IHNl cnZpY2VzIGZvdW5kOiA2CmJsdWV0b290aGRbODE2Nl06IHNyYy9kZXZpY2UuYzpnYXR0X2Rl YnVnKCkgc3RhcnQ6IDB4MDAwMSwgZW5kOiAweDAwMDcsIHV1aWQ6IDAwMDAxODAwLTAwMDAt MTAwMC04MDAwLTAwODA1ZjliMzRmYgpibHVldG9vdGhkWzgxNjZdOiBzcmMvZGV2aWNlLmM6 Z2F0dF9kZWJ1ZygpIHN0YXJ0OiAweDAwMDgsIGVuZDogMHgwMDA4LCB1dWlkOiAwMDAwMTgw MS0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2Rl dmljZS5jOmdhdHRfZGVidWcoKSBzdGFydDogMHgwMDA5LCBlbmQ6IDB4MDAxMSwgdXVpZDog MDAwMDE4MGEtMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIzNGZiCmJsdWV0b290aGRbODE2Nl06 IHNyYy9kZXZpY2UuYzpnYXR0X2RlYnVnKCkgc3RhcnQ6IDB4MDAxMiwgZW5kOiAweDAwMTYs IHV1aWQ6IDAwMDAxODBmLTAwMDAtMTAwMC04MDAwLTAwODA1ZjliMzRmYgpibHVldG9vdGhk WzgxNjZdOiBzcmMvZGV2aWNlLmM6Z2F0dF9kZWJ1ZygpIHN0YXJ0OiAweDAwMTcsIGVuZDog MHgwMDMwLCB1dWlkOiAwMDAwMTgxMi0wMDAwLTEwMDAtODAwMC0wMDgwNWY5YjM0ZmIKYmx1 ZXRvb3RoZFs4MTY2XTogc3JjL2RldmljZS5jOmdhdHRfZGVidWcoKSBzdGFydDogMHgwMDMx LCBlbmQ6IDB4ZmZmZiwgdXVpZDogMDAwMDE4MTItMDAwMC0xMDAwLTgwMDAtMDA4MDVmOWIz NGZiCmJsdWV0b290aGRbODE2Nl06IHNyYy9kZXZpY2UuYzpnYXR0X2NsaWVudF9yZWFkeV9j YigpIHN0YXR1czogc3VjY2VzcywgZXJyb3I6IDAKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2dh dHQtY2xpZW50LmM6YnRkX2dhdHRfY2xpZW50X3JlYWR5KCkgR0FUVCBjbGllbnQgcmVhZHkK Ymx1ZXRvb3RoZFs4MTY2XTogc3JjL2dhdHQtY2xpZW50LmM6Y3JlYXRlX3NlcnZpY2VzKCkg RXhwb3J0aW5nIG9iamVjdHMgZm9yIEdBVFQgc2VydmljZXM6IENFOkQ4OkZBOjIwOkE3OkI3 CmJsdWV0b290aGRbODE2Nl06IHNyYy9nYXR0LWNsaWVudC5jOnNlcnZpY2VfY3JlYXRlKCkg RXhwb3J0ZWQgR0FUVCBzZXJ2aWNlOiAvb3JnL2JsdWV6L2hjaTAvZGV2X0NFX0Q4X0ZBXzIw X0E3X0I3L3NlcnZpY2UwMDA4CmJsdWV0b290aGRbODE2Nl06IHNyYy9nYXR0LWNsaWVudC5j OnNlcnZpY2VfY3JlYXRlKCkgRXhwb3J0ZWQgR0FUVCBzZXJ2aWNlOiAvb3JnL2JsdWV6L2hj aTAvZGV2X0NFX0Q4X0ZBXzIwX0E3X0I3L3NlcnZpY2UwMDA5CmJsdWV0b290aGRbODE2Nl06 IHNyYy9nYXR0LWNsaWVudC5jOmNoYXJhY3RlcmlzdGljX2NyZWF0ZSgpIEV4cG9ydGVkIEdB VFQgY2hhcmFjdGVyaXN0aWM6IC9vcmcvYmx1ZXovaGNpMC9kZXZfQ0VfRDhfRkFfMjBfQTdf Qjcvc2VydmljZTAwMDkvY2hhcjAwMGEKYmx1ZXRvb3RoZFs4MTY2XTogc3JjL2dhdHQtY2xp ZW50LmM6Y2hhcmFjdGVyaXN0aWNfY3JlYXRlKCkgRXhwb3J0ZWQgR0FUVCBjaGFyYWN0ZXJp c3RpYzogL29yZy9ibHVlei9oY2kwL2Rldl9DRV9EOF9GQV8yMF9BN19CNy9zZXJ2aWNlMDAw OS9jaGFyMDAwYwpibHVldG9vdGhkWzgxNjZdOiBzcmMvZ2F0dC1jbGllbnQuYzpjaGFyYWN0 ZXJpc3RpY19jcmVhdGUoKSBFeHBvcnRlZCBHQVRUIGNoYXJhY3RlcmlzdGljOiAvb3JnL2Js dWV6L2hjaTAvZGV2X0NFX0Q4X0ZBXzIwX0E3X0I3L3NlcnZpY2UwMDA5L2NoYXIwMDBlCmJs dWV0b290aGRbODE2Nl06IHNyYy9nYXR0LWNsaWVudC5jOmNoYXJhY3RlcmlzdGljX2NyZWF0 ZSgpIEV4cG9ydGVkIEdBVFQgY2hhcmFjdGVyaXN0aWM6IC9vcmcvYmx1ZXovaGNpMC9kZXZf Q0VfRDhfRkFfMjBfQTdfQjcvc2VydmljZTAwMDkvY2hhcjAwMTAKYmx1ZXRvb3RoZFs4MTY2 XTogc3JjL2RldmljZS5jOmRldmljZV9zdmNfcmVzb2x2ZWQoKSAvb3JnL2JsdWV6L2hjaTAv ZGV2X0NFX0Q4X0ZBXzIwX0E3X0I3IGVyciAwCmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVz L2lucHV0L2hvZy1saWIuYzpyZXBvcnRfY2NjX3dyaXR0ZW5fY2IoKSBSZXBvcnQgY2hhcmFj dGVyaXN0aWMgZGVzY3JpcHRvciB3cml0dGVuOiBub3RpZmljYXRpb25zIGVuYWJsZWQKYmx1 ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9jY2Nfd3Jp dHRlbl9jYigpIFJlcG9ydCBjaGFyYWN0ZXJpc3RpYyBkZXNjcmlwdG9yIHdyaXR0ZW46IG5v dGlmaWNhdGlvbnMgZW5hYmxlZApibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9o b2ctbGliLmM6cmVwb3J0X2NjY193cml0dGVuX2NiKCkgUmVwb3J0IGNoYXJhY3RlcmlzdGlj IGRlc2NyaXB0b3Igd3JpdHRlbjogbm90aWZpY2F0aW9ucyBlbmFibGVkCmJsdWV0b290aGRb ODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfY2NjX3dyaXR0ZW5fY2Io KSBSZXBvcnQgY2hhcmFjdGVyaXN0aWMgZGVzY3JpcHRvciB3cml0dGVuOiBub3RpZmljYXRp b25zIGVuYWJsZWQKYmx1ZXRvb3RoZFs4MTY2XTogYXR0cmliL2dhdHRyaWIuYzpnX2F0dHJp Yl91bnJlZigpIDB4NTU5Y2NlYjE1YWIwOiBnX2F0dHJpYl91bnJlZj00CmJsdWV0b290aGRb ODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSBI b0cgaW5zcGVjdGluZyByZXBvcnQgbWFwCmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lu cHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSBSZXBvcnQgTUFQOgpibHVldG9v dGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2Ni KCkgICAgICAgICAgMDUgMDEKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9n LWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAgIDA5IDAyCmJsdWV0b290aGRb ODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAg ICAgICAgICBhMSAwMQpibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGli LmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAgMDUgMDEKYmx1ZXRvb3RoZFs4MTY2 XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAg ICAgIDA5IDAyCmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpy ZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICBhMSAwMgpibHVldG9vdGhkWzgxNjZdOiBw cm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAg ODUgMWIKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9y dF9tYXBfcmVhZF9jYigpICAgICAgICAgIDA5IDAxCmJsdWV0b290aGRbODE2Nl06IHByb2Zp bGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICBhMSAw MApibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21h cF9yZWFkX2NiKCkgICAgICAgICAgMDUgMDkKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMv aW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAgIDE5IDAxCmJs dWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3Jl YWRfY2IoKSAgICAgICAgICAyOSAwOApibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1 dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAgMTUgMDAKYmx1ZXRv b3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9j YigpICAgICAgICAgIDI1IDAxCmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hv Zy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICA5NSAwOApibHVldG9vdGhk WzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkg ICAgICAgICAgNzUgMDEKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxp Yi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAgIDgxIDAyCmJsdWV0b290aGRbODE2 Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAg ICAgICAwNSAwMQpibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6 cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAgMDkgMzAKYmx1ZXRvb3RoZFs4MTY2XTog cHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAg IDA5IDMxCmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBv cnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICAxNiAwMiA4MApibHVldG9vdGhkWzgxNjZdOiBw cm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAg MjYgZmYgN2YKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJl cG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAgIDc1IDEwCmJsdWV0b290aGRbODE2Nl06IHBy b2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICA5 NSAwMgpibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0 X21hcF9yZWFkX2NiKCkgICAgICAgICAgODEgMDYKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmls ZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAgIGExIDAy CmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFw X3JlYWRfY2IoKSAgICAgICAgICA4NSAxMgpibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9p bnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAgMDkgNDgKYmx1 ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVh ZF9jYigpICAgICAgICAgIDk1IDAxCmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0 L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICA3NSAwMgpibHVldG9v dGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2Ni KCkgICAgICAgICAgMTUgMDAKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9n LWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAgIDI1IDAxCmJsdWV0b290aGRb ODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAg ICAgICAgICAzNSAwMQpibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGli LmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAgNDUgNzgKYmx1ZXRvb3RoZFs4MTY2 XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAg ICAgIGIxIDAyCmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpy ZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICA4NSAxYgpibHVldG9vdGhkWzgxNjZdOiBw cm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAg MDkgMzgKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9y dF9tYXBfcmVhZF9jYigpICAgICAgICAgIDM1IDAwCmJsdWV0b290aGRbODE2Nl06IHByb2Zp bGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICA0NSAw MApibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21h cF9yZWFkX2NiKCkgICAgICAgICAgOTUgMDEKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMv aW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAgIDc1IDEwCmJs dWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3Jl YWRfY2IoKSAgICAgICAgICAxNiAwMiA4MApibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9p bnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAgMjYgZmYgN2YK Ymx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBf cmVhZF9jYigpICAgICAgICAgIDgxIDA2CmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lu cHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICBjMApibHVldG9v dGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2Ni KCkgICAgICAgICAgYTEgMDIKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9n LWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAgIDg1IDEyCmJsdWV0b290aGRb ODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAg ICAgICAgICAwOSA0OApibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGli LmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAgOTUgMDEKYmx1ZXRvb3RoZFs4MTY2 XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAg ICAgIDc1IDAyCmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpy ZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICAxNSAwMApibHVldG9vdGhkWzgxNjZdOiBw cm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAg MjUgMDEKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9y dF9tYXBfcmVhZF9jYigpICAgICAgICAgIDM1IDAxCmJsdWV0b290aGRbODE2Nl06IHByb2Zp bGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICA0NSA3 OApibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21h cF9yZWFkX2NiKCkgICAgICAgICAgYjEgMDIKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMv aW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAgIDM1IDAwCmJs dWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3Jl YWRfY2IoKSAgICAgICAgICA0NSAwMApibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1 dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAgOTUgMDEKYmx1ZXRv b3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9j YigpICAgICAgICAgIDc1IDA0CmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hv Zy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICBiMSAwMQpibHVldG9vdGhk WzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkg ICAgICAgICAgODUgMWIKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxp Yi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAgIDA1IDBjCmJsdWV0b290aGRbODE2 Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAg ICAgICAxNSA4MQpibHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6 cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAgMjUgN2YKYmx1ZXRvb3RoZFs4MTY2XTog cHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAg IDc1IDA4CmJsdWV0b290aGRbODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBv cnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICAwYSAzOCAwMgpibHVldG9vdGhkWzgxNjZdOiBw cm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9yZWFkX2NiKCkgICAgICAgICAg OTUgMDEKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQvaG9nLWxpYi5jOnJlcG9y dF9tYXBfcmVhZF9jYigpICAgICAgICAgIDgxIDA2CmJsdWV0b290aGRbODE2Nl06IHByb2Zp bGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAgICAgICAgICBjMApi bHVldG9vdGhkWzgxNjZdOiBwcm9maWxlcy9pbnB1dC9ob2ctbGliLmM6cmVwb3J0X21hcF9y ZWFkX2NiKCkgICAgICAgICAgYzAKYmx1ZXRvb3RoZFs4MTY2XTogcHJvZmlsZXMvaW5wdXQv aG9nLWxpYi5jOnJlcG9ydF9tYXBfcmVhZF9jYigpICAgICAgICAgIGMwCmJsdWV0b290aGRb ODE2Nl06IHByb2ZpbGVzL2lucHV0L2hvZy1saWIuYzpyZXBvcnRfbWFwX3JlYWRfY2IoKSAg ICAgICAgICBjMApTZWdtZW50YXRpb24gZmF1bHQK --1b501d68867e4954a0fb4b765137a701-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id sNKQN/hK/F5vegEA0J78UA (envelope-from ) for ; Wed, 01 Jul 2020 10:36:08 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cAPjNfhK/F5IxQAADc0bRg (envelope-from ); Wed, 01 Jul 2020 10:36:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C8637A1CDF; Wed, 1 Jul 2020 10:36:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728865AbgGAIf6 (ORCPT + 1 other); Wed, 1 Jul 2020 04:35:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:35534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728721AbgGAIf5 (ORCPT ); Wed, 1 Jul 2020 04:35:57 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BF7F22074D; Wed, 1 Jul 2020 08:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593592556; bh=UGtkda44woteFt7TyX2UWVAkG5/EtKAmYzl2P6Jfs7M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ol7WRkadln57KsG/emeb4pCHG8a3PejXP5/bKCrWlJKm2b6RmHj/APPzc4kJs3r1B uc/iZvd6p69y1MRV/vqfZzBmTMo9PnODSV9qko5i2iSUZgsN6zr6qbM2Q074dXG4NH OmtHSaUvGyB7k/UoAi/HHhrfO3YHDJF/oMSEC9eU= Received: by pali.im (Postfix) id F0A49102D; Wed, 1 Jul 2020 10:35:54 +0200 (CEST) Date: Wed, 1 Jul 2020 10:35:54 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: linux-bluetooth@vger.kernel.org Cc: Luiz Augusto von Dentz Subject: Re: [PATCH] avinfo: Print more A/V capabilities Message-ID: <20200701083554.bk6xlm7la6ap7qt3@pali> References: <20200512165112.24006-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200512165112.24006-1-pali@kernel.org> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -6.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: C8637A1CDF X-Rspamd-UID: aa2b0f Hello! Could you look at following patch? On Tuesday 12 May 2020 18:51:12 Pali Rohár wrote: > --- > tools/avinfo.c | 27 ++++++++++++++++++++++++--- > 1 file changed, 24 insertions(+), 3 deletions(-) > > diff --git a/tools/avinfo.c b/tools/avinfo.c > index e45b50918..576981a5e 100644 > --- a/tools/avinfo.c > +++ b/tools/avinfo.c > @@ -65,6 +65,7 @@ > #define AVDTP_HEADER_COMPRESSION 0x05 > #define AVDTP_MULTIPLEXING 0x06 > #define AVDTP_MEDIA_CODEC 0x07 > +#define AVDTP_DELAY_REPORTING 0x08 > > /* SEP types definitions */ > #define AVDTP_SEP_TYPE_SOURCE 0x00 > @@ -696,13 +697,33 @@ static void print_caps(void *data, int size) > > switch (cap->category) { > case AVDTP_MEDIA_TRANSPORT: > + printf("\tMedia Transport: Supported\n"); > + break; > case AVDTP_REPORTING: > + printf("\tReporting: Supported\n"); > + break; > + case AVDTP_DELAY_REPORTING: > + printf("\tDelay Reporting: Supported\n"); > + break; > case AVDTP_RECOVERY: > + case AVDTP_HEADER_COMPRESSION: > case AVDTP_MULTIPLEXING: > - /* FIXME: Add proper functions */ > - break; > default: > - printf("\tUnknown category: %d\n", cap->category); > + switch (cap->category) { > + case AVDTP_RECOVERY: > + printf("\tRecovery:\n"); > + break; > + case AVDTP_HEADER_COMPRESSION: > + printf("\tHeader compression:\n"); > + break; > + case AVDTP_MULTIPLEXING: > + printf("\tMultiplexing:\n"); > + break; > + default: > + printf("\tUnknown category: %d\n", cap->category); > + break; > + } > + /* FIXME: Add proper functions */ > printf("\t\tData:"); > for (i = 0; i < cap->length; ++i) > printf(" 0x%.02x", > -- > 2.20.1 > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0HOsCuRe/F76kAAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 12:01:08 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YGkkCORe/F78HAAAgupzMw (envelope-from ); Wed, 01 Jul 2020 12:01:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2503CA2922; Wed, 1 Jul 2020 12:00:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729525AbgGAKA5 (ORCPT + 1 other); Wed, 1 Jul 2020 06:00:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKA4 (ORCPT ); Wed, 1 Jul 2020 06:00:56 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB964C061755 for ; Wed, 1 Jul 2020 03:00:56 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id h22so10826843pjf.1 for ; Wed, 01 Jul 2020 03:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=1qmXXl5ZAhM0NzsYkJWFojtWCUNBKrIwVskn/btnQl4=; b=BsVTs5pR5d3WyVtsRwUfGp7l5ggX5G1hEAXVmw3TOLYF17qMQRWTwohhUwCmCM1k/U 6exB/CBq0mkKKSe06Qgv8GWbCaduJxq8x2b6ewJagbp/qtjQo3kCPXArVH9n8V2JV6H+ v2neMmEZwu3q3j2qzaTTg3zxO4++Xpyz8VsSddu7U0FPqSoGAbAZkF1tFLeBaUv4/szC GoN3KHIRO8ZMnJUSwDIz/fQP8/UHFwOnZJ4Nn+RHm35tSHygDRI/egnmmGPq6qtcyFw4 qQTgU4xnodkPMf9mr5b1ZvAzzFg6N66gOsMNoBgtSu3EjGHvCAXV3jQMgDnoZ4MPrTyW xVRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1qmXXl5ZAhM0NzsYkJWFojtWCUNBKrIwVskn/btnQl4=; b=lac9Qn9gsMJOg/oZ6VgH22DoDf/EdQnMp1Iy8rDOu/bfzE2KRiuhr/pEW93xFYOVca x1smTgW3BYpPaHj01kAjcO7+8v+qSQMn0O/o8u/zTSloyXE/iuBmisOwydkW5cE6QLj+ V0Lm3Ub6P2j1zbR2TgsRWmI1yy17hgoJD7/oqtyB7CNocviPsPzUDzRrjnKyNXAiqSfv wgAjWbsAe4tMcCNMAqEES1YCRwKrQ7uyZCo0TLanLCpLqcjan8CxmTj3KrfYN+rDlaB7 chgNWUFI0j0F3j8HWaRcRBmdrHLN9whYvkGhkc++dxO1MW0VpwfgowGVm+fa1QO/tef8 RaqQ== X-Gm-Message-State: AOAM531ANOjkaWgSJNFHTEvJ54z82DTi5+wpP9r5TQH4yKNEHRhA0GXV XmIbqvhamyt0Nnyv1nL2Xuy0Dc0w+Lw= X-Google-Smtp-Source: ABdhPJx7N5OT+j+URwqfDwbO+2RgSK857bLcz5H7pas7DLY42eJttHfEoK3j0Q88/cwRogC/r+4PIw== X-Received: by 2002:a17:90a:de94:: with SMTP id n20mr17096644pjv.125.1593597655818; Wed, 01 Jul 2020 03:00:55 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:00:55 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v3 0/8] LL Privacy support Date: Wed, 1 Jul 2020 15:34:24 +0530 Message-Id: <20200701100432.28038-1-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2503CA2922 X-Rspamd-UID: 6ced8b v3: rebased the patches Add support to enable LL privacy using mgmt with existing set_privacy command Marcel Holtmann (3): Bluetooth: Translate additional address type correctly Bluetooth: Configure controller address resolution if available Bluetooth: Update resolving list when updating whitelist Sathish Narasimman (5): Bluetooth: Translate additional address type during le_conn Bluetooth: Let controller creates RPA during le create conn Bluetooth: Enable/Disable address resolution during le create conn Bluetooth: Enable RPA Timeout Bluetooth: Add support to enable LL PRIVACY using set_privacy include/net/bluetooth/hci.h | 9 ++- include/net/bluetooth/hci_core.h | 3 + net/bluetooth/hci_conn.c | 7 +- net/bluetooth/hci_core.c | 17 +++++ net/bluetooth/hci_event.c | 22 ++++++ net/bluetooth/hci_request.c | 123 +++++++++++++++++++++++++++---- net/bluetooth/hci_request.h | 3 +- net/bluetooth/mgmt.c | 8 +- 8 files changed, 170 insertions(+), 22 deletions(-) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EA7/Le5e/F67FAAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 12:01:18 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qIxTLO5e/F6WmQAAlp8NpQ (envelope-from ); Wed, 01 Jul 2020 12:01:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D25DBA28DA; Wed, 1 Jul 2020 12:01:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729486AbgGAKBF (ORCPT + 1 other); Wed, 1 Jul 2020 06:01:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBF (ORCPT ); Wed, 1 Jul 2020 06:01:05 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E820C061755 for ; Wed, 1 Jul 2020 03:01:05 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id k71so7264505pje.0 for ; Wed, 01 Jul 2020 03:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XQsMIxXrDju3xAGiOt+lQ1c1a9XOuAjcFVyUXi9Jbzc=; b=qPIyk2MQ7xE5iit4ig06C+IlJAqBoFofUEB3fixTef2LJinF5BBVdOSZ32dvyDYGjA /cLvq91XC6c+wLfj+9998vpSRxamJ8YiDXeL8eVjTjhrlnVPcGDIs4zJ48oAWseaY1iG 6ANcNHxfgxoNW8oZe3Zozw821niCI/k/8b9TeGcj4FtzVneby7XuBiVfQk0eVSc5jZDB gjZ8KTzKxUFngKo7JmLtSutFfYT8gT4WgOKj7+qS51SGebMHSkhM7kiw1cmC+CHWRUfr +icEev1RiKhQwGqY4H1259hOL+lNaEluPwh8W64WGOWgV4b7c3vkuHhLG24R0zhvS9V1 ivSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XQsMIxXrDju3xAGiOt+lQ1c1a9XOuAjcFVyUXi9Jbzc=; b=o2+uMZYzSfzz/vIa80pbySq2BVtM+2elkVo88N/LoCeFIkiCM2FUQg+yGeLxPCOLId ycS4JaOVxJMURTBIlVx9cN8mQeh5JcpVAb7dOTgIYcsNS+d0ODbIRg3fNWz5M2pAE0IW UGnP5ABfnH2OVGMxiLBsXhoOl95KskyPkRh5nfqKNFdh+rML0103mXqLF9iy7vKEcYV4 oOyjKmYFQ/0esbRe/c12GhtQP1Aza9e1YHcTETUzKg5QbRuGWH2Am/ovWYqxVgVPwwxv ECE+1EwVLrVSBKy1d8lAzNaGKwjsinzJMPbWc9eUVrvWt4WksFy6BNKMtMI7xZodRlSK qD6w== X-Gm-Message-State: AOAM5316USq6PZocLzHVdwfeLHMTLvjAsKYEWl0Q+VBNqMltw/zAgtza /cvDSvfeXo7TYvnFw10yuXGyHXAooP6Cmw== X-Google-Smtp-Source: ABdhPJxeXuLH4fet/q2DK7GV3yM5Don8vOyea4yvctMPCuNcv4RaTPfj8DROHZBCfcNxxi5IR23YTA== X-Received: by 2002:a17:902:9309:: with SMTP id bc9mr22102673plb.232.1593597664642; Wed, 01 Jul 2020 03:01:04 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:04 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v3 1/8] Bluetooth: Translate additional address type correctly Date: Wed, 1 Jul 2020 15:34:25 +0530 Message-Id: <20200701100432.28038-2-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: D25DBA28DA X-Rspamd-UID: b31b4b From: Marcel Holtmann When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci.h | 6 ++++-- net/bluetooth/hci_core.c | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 1f18f71363e9..abab8b5981a7 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -2268,8 +2268,10 @@ struct hci_ev_le_conn_complete { #define LE_EXT_ADV_SCAN_RSP 0x0008 #define LE_EXT_ADV_LEGACY_PDU 0x0010 -#define ADDR_LE_DEV_PUBLIC 0x00 -#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC 0x00 +#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC_RESOLVED 0x02 +#define ADDR_LE_DEV_RANDOM_RESOLVED 0x03 #define HCI_EV_LE_ADVERTISING_REPORT 0x02 struct hci_ev_le_advertising_info { diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 5577cf9e2c7c..604a411a9b8f 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3292,6 +3292,15 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list, { struct hci_conn_params *param; + switch (addr_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + addr_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + addr_type = ADDR_LE_DEV_RANDOM; + break; + } + list_for_each_entry(param, list, action) { if (bacmp(¶m->addr, addr) == 0 && param->addr_type == addr_type) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mEiKNTpf/F76kAAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 12:02:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id KG70Mzpf/F5LTQEADc0bRg (envelope-from ); Wed, 01 Jul 2020 12:02:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 91AC1A2F31; Wed, 1 Jul 2020 12:02:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729772AbgGAKBh (ORCPT + 1 other); Wed, 1 Jul 2020 06:01:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBg (ORCPT ); Wed, 1 Jul 2020 06:01:36 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749FFC061755 for ; Wed, 1 Jul 2020 03:01:36 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id e8so11479848pgc.5 for ; Wed, 01 Jul 2020 03:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Tofe5K0oXmYz1C+QMUjX7aijC98yv1W6QBb5sW/j1KE=; b=Twp2rHZ5iwjWizLno7mIZY8KPEPwttjiFcf2vnx4Nj4Gw6UH6yHG4vKuOIPwQ6dde4 ll2dzkEDsW3Vl3KpcP8FK6R/WvOPgkmA5nx8JLNiGtxv8evU/PD35u2qNEvM9H8thNdj nvdy5YXyReu32zkZO0Iva4/SbWvvRkk90IDd2heOd0dZkJUa4IE82BeXjwqk+PVpOwmv rlrse0CHYldXXW3Vf4Lv5iGgYUQ6EWpW9lPTReAX60ErpuxwI4dgI5E17ZdpIk0+LR3C f7ZvxXXbpiOdwgTJoMwDSUytFwwGNMZEctoPFq/YlXqLMyc/ObDHrCw8JQLtUKWlp5UR u6mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Tofe5K0oXmYz1C+QMUjX7aijC98yv1W6QBb5sW/j1KE=; b=NN2ABA3cL6SBwVcBoeNh/c/CkjZ8ddf2WyZg8AcjPM2FWDkPGuX9xGshc37wE+FLLA OEZ8aPKODWF/FHwnhKyRqB8C9vpUEDMSs13sObw3xKiPB6SYluMdf2QANxoFqX70EZNi ok/aOSGKhMLcjI2cYOY9GkEQSuTHGCoxeU10LI5pzxWVZ7vKyPlMDqML9gcm7sGkS3RO Utq6kXR8xSLrJn7uyQA2OtCi137VZrG+KovMdddIj5nM681vkRHWYaCUb+StN5XdJdeb dvy+QWxkP39niARl93tuOs8jira+OP6aIcTRni4T2e7Ti1/C1VXgJuh6wPaZXVkBNiF5 bopw== X-Gm-Message-State: AOAM5302LFOOfY3StHLlbEkjU7uQrmuX9qe58tKT0f+EHRKlSudKDxKC Ba9q+3O4cLbyKM7QZdiRXtCAOIkjG1MGeA== X-Google-Smtp-Source: ABdhPJxmBmgJhpRJEGupfI4CgEleUolgb6zw7Q2qQncK/TwtxLFicyJWMAFJszLrQ6EmmeGT1+y9cQ== X-Received: by 2002:a62:195:: with SMTP id 143mr16252194pfb.226.1593597695503; Wed, 01 Jul 2020 03:01:35 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:35 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v3 8/8] Bluetooth: Add support to enable LL PRIVACY using set_privacy Date: Wed, 1 Jul 2020 15:34:32 +0530 Message-Id: <20200701100432.28038-9-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: 91AC1A2F31 X-Rspamd-UID: 036d43 Enable LL Privacy using mgmt set_privacy command. The privacy value 0x03 is used here to enable LL Privacy. Still to use LL Privacy controller support is must. Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_event.c | 6 ++++-- net/bluetooth/hci_request.c | 15 ++++++++++----- net/bluetooth/mgmt.c | 6 +++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 4ff2fc4498f3..2a42c7ceabb2 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -286,6 +286,7 @@ enum { HCI_SC_ONLY, HCI_PRIVACY, HCI_LIMITED_PRIVACY, + HCI_ENABLE_LL_PRIVACY, HCI_RPA_EXPIRED, HCI_RPA_RESOLVING, HCI_HS_ENABLED, diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 47a4050462ed..589bac9859ce 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2301,7 +2301,8 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, * converted back into either public address or random address type */ if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) { switch (own_address_type) { case ADDR_LE_DEV_PUBLIC_RESOLVED: own_address_type = ADDR_LE_DEV_PUBLIC; @@ -5223,7 +5224,8 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->supervision_timeout)); if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) hci_req_disable_address_resolution(hdev); } diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 0dc587026753..e1c2e2c13456 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -678,7 +678,8 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) /* Disable address resolution */ if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) { __u8 enable = 0x00; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } @@ -696,7 +697,8 @@ static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST, sizeof(cp), &cp); - if (use_ll_privacy(req->hdev)) { + if (use_ll_privacy(req->hdev) && + hci_dev_test_flag(req->hdev, HCI_ENABLE_LL_PRIVACY)) { struct smp_irk *irk; irk = hci_find_irk_by_addr(req->hdev, bdaddr, bdaddr_type); @@ -748,7 +750,8 @@ static int add_to_white_list(struct hci_request *req, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_ADD_TO_WHITE_LIST, sizeof(cp), &cp); - if (use_ll_privacy(hdev)) { + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) { struct smp_irk *irk; irk = hci_find_irk_by_addr(hdev, ¶ms->addr, @@ -869,7 +872,8 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } - if (use_ll_privacy(hdev) && addr_resolv) { + if (use_ll_privacy(hdev) && addr_resolv && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) { u8 enable = 0x01; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } @@ -2226,7 +2230,8 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, /* If Controller supports LL Privacy use own address type is * 0x03 */ - if (use_ll_privacy(hdev)) + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED; else *own_addr_type = ADDR_LE_DEV_RANDOM; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 65d93a38e5b3..c1106d97e3a9 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -5652,7 +5652,8 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY, MGMT_STATUS_NOT_SUPPORTED); - if (cp->privacy != 0x00 && cp->privacy != 0x01 && cp->privacy != 0x02) + if (cp->privacy != 0x00 && cp->privacy != 0x01 && cp->privacy != 0x02 + && cp->privacy != 0x03) return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY, MGMT_STATUS_INVALID_PARAMS); @@ -5674,6 +5675,8 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data, hci_adv_instances_set_rpa_expired(hdev, true); if (cp->privacy == 0x02) hci_dev_set_flag(hdev, HCI_LIMITED_PRIVACY); + else if (cp->privacy == 0x03) + hci_dev_set_flag(hdev, HCI_ENABLE_LL_PRIVACY); else hci_dev_clear_flag(hdev, HCI_LIMITED_PRIVACY); } else { @@ -5682,6 +5685,7 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data, hci_dev_clear_flag(hdev, HCI_RPA_EXPIRED); hci_adv_instances_set_rpa_expired(hdev, false); hci_dev_clear_flag(hdev, HCI_LIMITED_PRIVACY); + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); } err = send_settings_rsp(sk, MGMT_OP_SET_PRIVACY, hdev); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mNmVAgNf/F76kAAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 12:01:39 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UIAaAQNf/F5txwAAlp8NpQ (envelope-from ); Wed, 01 Jul 2020 12:01:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1DCBAA10CE; Wed, 1 Jul 2020 12:01:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729683AbgGAKBO (ORCPT + 1 other); Wed, 1 Jul 2020 06:01:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBO (ORCPT ); Wed, 1 Jul 2020 06:01:14 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C0B7C061755 for ; Wed, 1 Jul 2020 03:01:14 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id gc9so4272750pjb.2 for ; Wed, 01 Jul 2020 03:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AmvPW4v1t8mYI78mS127zBVBOMVhLn3jVVhr+y7gx+4=; b=J/GL13uO37fsfo/YLPOhh6CluFhyg3ONCqjCal+Y127YZd95FXn/NnfZk6goc8iczP iZeaM1PlJQaHxhhHqcdouA9hOPPIqt1jQQT/SB2pUAY2El8obZYHelzhQ1L1YBm0k8UE 5Fe1iD/jMx8qwxttwd8YU6ll37AzWaTNcUgn5Am/0oZqB2HIwbWnwQ+2mpVZOJ8+Z8h/ sgSpvn30RGQtFK/6Rtc7WAdsBlVqLK1zMFwFk0N03C35nMZGxoqOqxRAe7wawGf2DRmk O771KfW5wKekafGYw7IJ6H5IHcgfytCh2w8bYDM9OViuRTeUTi+mF+uljpIJQdcCP2Jb 8Hww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AmvPW4v1t8mYI78mS127zBVBOMVhLn3jVVhr+y7gx+4=; b=hjEEyj5i1lvGQR6Vs8GMvsYMgdA3fJ+XyYeUjzwF4Xx7FsGBkEaNZUEMm+S/TfjEc1 G0RkYGxuc/PqAdx6i++N96CyT4cEtZH3RKva2UcqolG3amxPQw17bJ7LSu9RDpIQ/cva QuBxDoXq8qMGJk68vMhZsIj3mHMBCCTOzp85NrGkcYrtyAssMPuLgOSXmoTel7/M9xOK Tqf3Wkzm5cY5C+MnDbhNXBDXoXovCdtWxhjZ1nAVnj8W+UA3j/0azCYb//q/XU/f8XVH 1HE+tLAsoohQd3vAaZiyLj6HQDvE0L9hbwWqWGryos79oS3R8lqKbU66qUgcrV9Kpues Ip5g== X-Gm-Message-State: AOAM532qJS9QKo7q3UVm6L0OwfNz0hjNFF/p+5XYAqBNaYsntu6VbNdc KMhSJdOwrMlhnHcyPQZaL9TaTEqzM62Cqg== X-Google-Smtp-Source: ABdhPJxuYu3xiadLfkFpoOWQ+teaogD4zTLxCsfxU++1RMK3odcmqoIrm32A7ONexAhHcjHYyDVODA== X-Received: by 2002:a17:902:b18b:: with SMTP id s11mr5705538plr.152.1593597673438; Wed, 01 Jul 2020 03:01:13 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:13 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v3 3/8] Bluetooth: Update resolving list when updating whitelist Date: Wed, 1 Jul 2020 15:34:27 +0530 Message-Id: <20200701100432.28038-4-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.14 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1DCBAA10CE X-Rspamd-UID: 028a95 From: Marcel Holtmann When the whitelist is updated, then also update the entries of the resolving list for devices where IRKs are available. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- net/bluetooth/hci_request.c | 41 +++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 5978f9177b3d..622016287628 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -694,6 +694,21 @@ static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, bt_dev_dbg(req->hdev, "Remove %pMR (0x%x) from whitelist", &cp.bdaddr, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST, sizeof(cp), &cp); + + if (use_ll_privacy(req->hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(req->hdev, bdaddr, bdaddr_type); + if (irk) { + struct hci_cp_le_del_from_resolv_list cp; + + cp.bdaddr_type = bdaddr_type; + bacpy(&cp.bdaddr, bdaddr); + + hci_req_add(req, HCI_OP_LE_DEL_FROM_RESOLV_LIST, + sizeof(cp), &cp); + } + } } /* Adds connection to white list if needed. On error, returns -1. */ @@ -714,7 +729,7 @@ static int add_to_white_list(struct hci_request *req, return -1; /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, ¶ms->addr, params->addr_type)) { return -1; } @@ -732,6 +747,28 @@ static int add_to_white_list(struct hci_request *req, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_ADD_TO_WHITE_LIST, sizeof(cp), &cp); + if (use_ll_privacy(hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(hdev, ¶ms->addr, + params->addr_type); + if (irk) { + struct hci_cp_le_add_to_resolv_list cp; + + cp.bdaddr_type = params->addr_type; + bacpy(&cp.bdaddr, ¶ms->addr); + memcpy(cp.peer_irk, irk->val, 16); + + if (hci_dev_test_flag(hdev, HCI_PRIVACY)) + memcpy(cp.local_irk, hdev->irk, 16); + else + memset(cp.local_irk, 0, 16); + + hci_req_add(req, HCI_OP_LE_ADD_TO_RESOLV_LIST, + sizeof(cp), &cp); + } + } + return 0; } @@ -772,7 +809,7 @@ static u8 update_white_list(struct hci_request *req) } /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, &b->bdaddr, b->bdaddr_type)) { return 0x00; } -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IOZ/Mwxf/F67FAAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 12:01:48 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cForMgxf/F4qJgEADc0bRg (envelope-from ); Wed, 01 Jul 2020 12:01:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2BB77A314D; Wed, 1 Jul 2020 12:01:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729689AbgGAKBT (ORCPT + 1 other); Wed, 1 Jul 2020 06:01:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBS (ORCPT ); Wed, 1 Jul 2020 06:01:18 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33437C061755 for ; Wed, 1 Jul 2020 03:01:17 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id x8so8822491plm.10 for ; Wed, 01 Jul 2020 03:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SiGWJykKRUEpwFqa25J4j/wcmszxEYFYY2Kihm0MUu8=; b=f7uURM5yqevpDA2KH5B6wkuUNNejZsTKOoudMOcwSrTbp9uqtfea0vtdtaJ4XCihwE YnRCaZrjE+Tff5LJn8M/EfcgFXvLjgF8MLSsaJ1PjT25z5iCaCXLACKFmYEjefyuXKWm 70RTNFZaJ7BFGjub2ivy6vRFIJadDWFV8ndaU3+0eNtMSHsUG136lBJTjocx0SsLOu0I GhXzpfv3vArKUE8AoCwUf7yv/crxahkF6ogmqOhNKNAdNeTvzhM1cGUDh+Syn8npHwd+ y9dk6iN1wAW7/6Jf/rl5nexwz7XjFtL7/iO0I6CY9C8j9iKVuPLOp5m7UNuqFFT/9WIg 6eZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SiGWJykKRUEpwFqa25J4j/wcmszxEYFYY2Kihm0MUu8=; b=q+/4uFQauWxhyk6QSAMSakGSnGFDS25siFtlBZ1wXmsJXgqNz4dam8CERRUIos0dkO mIP92ctjkMmQWtFwWBhZXxh++x1/dDzPQbacGdF4IaXU3+zTibBhvhstemwl/LeM7gjA ecJtyp+yYfRK7qbSRf6lJHFp9RSCLn5f8j3UB5CEBN3d5FF3fAONFBLZBO92SMJUoD2w UEjeLw+MX20/uGSkyYp99MxkWeNoPVUnSrhcNe1ejAdIgiyynsLyjugO5QHVJcUlrC37 +xSBbTFKcLPp+8waH8gUb7uD9F1MPL6uuieZjBD8YH4wD0qDL5OquTWxitdFZ1fO1AD+ g2xg== X-Gm-Message-State: AOAM533Q+Q8SjA8hcZq0dV9BMxalA+GWH8gc55tEhdr198GH03ajoppH GQf+WX+cwaetStQAFJGjj/UFd0hDknmZMQ== X-Google-Smtp-Source: ABdhPJyUvdacwJjPCU1dUiJqroxQse9Zkqz+wDNuAnasVH5jODG1XQSYH3iFrE646ihnscEq/gU6Mw== X-Received: by 2002:a17:90a:26a4:: with SMTP id m33mr6814342pje.124.1593597676371; Wed, 01 Jul 2020 03:01:16 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:15 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v3 4/8] Bluetooth: Translate additional address type during le_conn Date: Wed, 1 Jul 2020 15:34:28 +0530 Message-Id: <20200701100432.28038-5-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.13 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2BB77A314D X-Rspamd-UID: c5b514 When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. This patch is specially during LE_CREATE_CONN if using own_add_type as 0x02 or 0x03. Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_event.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index e060fc9ebb18..592ef5dda3ab 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2296,6 +2296,22 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, if (!conn) return; + /* When using controller based address resolution, then the new + * address types 0x02 and 0x03 are used. These types need to be + * converted back into either public address or random address type + */ + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + switch (own_address_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + own_address_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + own_address_type = ADDR_LE_DEV_RANDOM; + break; + } + } + /* Store the initiator and responder address information which * is needed for SMP. These values will not change during the * lifetime of the connection. -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uOGDABxf/F67FAAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 12:02:04 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id AIvvORtf/F5W5wEAlScrYA (envelope-from ); Wed, 01 Jul 2020 12:02:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 092DCA3190; Wed, 1 Jul 2020 12:01:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729716AbgGAKBV (ORCPT + 1 other); Wed, 1 Jul 2020 06:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBU (ORCPT ); Wed, 1 Jul 2020 06:01:20 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D199C061755 for ; Wed, 1 Jul 2020 03:01:20 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id x11so9711636plo.7 for ; Wed, 01 Jul 2020 03:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZfCBwWzszt0wp19IOQjQbWYB7ZUb16MS4aRNucJyhyI=; b=PG4tVNAmrYY6eQRIYWaffh3ohZNEpAr/1AHTsZTtAefCoamTRGLx1MM7XVIQcOBLfr vQdLmfN6Dyre2fXtb9+SuCWxUY+uDNPoZxhtdGKNVkkujDlZNSyLgsul6k6sC7nVcImV dIBtGFBw/ebHd7klghTjkGudMbAPIJilsLqnlA7UxhdMBsD4dI4cyfBDqb5H/LYpqQEW y3fCZWQZ8o67UqdKjEW3hjshjFaC4Gklxu3OnVpWC4JAQkZ0FqrRsj3o2LC/fM5F1tD8 H0IBApfv8hzPef4jUvZwnkRKwBvqUXWLS4vFaX6AaUrwa4Ap0y/ODO7neL7sRgg2hlEE oNBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZfCBwWzszt0wp19IOQjQbWYB7ZUb16MS4aRNucJyhyI=; b=DsnjCnu7cg0a/MUTkBsmwFdM89PYRu2MEuEXhcGlN27a+hTNjcwjKUZ14puNCq6zbr ThQ9G79JxMH7yLa8MYDbmv1z0ZY1tSExwpr7eA0xc29BUY7Myj1ysHNP8i4w7Ly8vcRm /ndfXj2abgChkYfihLV6qYjbAQ5JkQ3Uh7oiyUcIn8XVsHcUpsxFpmUHbt1OjHjgSc7n k72W2L2kujbOVOtAbN19ieM2Jgc9BEyYQ16hGfG9vC86d7y1P0brUUEfTNF+2elE03JP 1shb8QqkMejWg0tYegXHoSxb1m/7G0FFsCkouDFosPBraKOwNFECsh8LfIijvcU+dG2T yUBQ== X-Gm-Message-State: AOAM532FJTfwV8m+uBmM1Q2fTxNRbqu+wF27k39UIlpIrlq6FDecPiNP gXfTMNuwBp40LPzIAHGoyjThJZFyoI5CSg== X-Google-Smtp-Source: ABdhPJzKEsybwvFlzN+HoJvW9b9lD5678LZfi6sECRNqybPbiruESbcTxfId5jWVksMvWjmjh0Ggiw== X-Received: by 2002:a17:90a:ce96:: with SMTP id g22mr6851044pju.9.1593597679527; Wed, 01 Jul 2020 03:01:19 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:19 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v3 5/8] Bluetooth: Let controller creates RPA during le create conn Date: Wed, 1 Jul 2020 15:34:29 +0530 Message-Id: <20200701100432.28038-6-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 092DCA3190 X-Rspamd-UID: d61ef1 When address resolution is enabled and set_privacy is enabled let's use own address type as 0x03 Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_request.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 622016287628..906721759c2f 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2200,7 +2200,13 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, if (use_rpa) { int to; - *own_addr_type = ADDR_LE_DEV_RANDOM; + /* If Controller supports LL Privacy use own address type is + * 0x03 + */ + if (use_ll_privacy(hdev)) + *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED; + else + *own_addr_type = ADDR_LE_DEV_RANDOM; if (!hci_dev_test_and_clear_flag(hdev, HCI_RPA_EXPIRED) && !bacmp(&hdev->random_addr, &hdev->rpa)) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0BkxISZf/F76kAAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 12:02:14 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MK2KHyZf/F4lbQAAgupzMw (envelope-from ); Wed, 01 Jul 2020 12:02:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 22D85A3131; Wed, 1 Jul 2020 12:02:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729769AbgGAKBY (ORCPT + 1 other); Wed, 1 Jul 2020 06:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBY (ORCPT ); Wed, 1 Jul 2020 06:01:24 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CE90C061755 for ; Wed, 1 Jul 2020 03:01:24 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id o1so3147050plk.1 for ; Wed, 01 Jul 2020 03:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zJ2QpfO712U6ML1rl/3l7HQWUfo4RwY2Ra3Gjw2SIQM=; b=UbYLHpQGvfzsHOhj+sqEBJEbV4AEfMdA4TwWbBSk5G6f0mm5nOizgFIVG35TTlAyfq sQeXIku/xq+pKltA59QBbMqxWXWS1zwymqbZCjCYheHEgTD+dv632g7wy5zK6t6UsaVt vEy4rE1hcpPooQ5ORc8X0ALXfJhhYOTaYQ9m+xDFf5Tx0x9y0Oyb7OB+7sG2j1r3CO1B /MHwYkup9EZL3fAbqRFWUu1Uwehoc/5sa+DPfqqq21jyWruwYO+osdANblmI3qyVIiRc Jlr2kstV16LlC1VWpa1tNMZimoqjCIeaa9IDyrf3Sq4t60dTwE2WnB25OoCJJAzD6WLB WcxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zJ2QpfO712U6ML1rl/3l7HQWUfo4RwY2Ra3Gjw2SIQM=; b=kHEej3PKPBPCDpEz3Bc41ectxugF4B2OJ9rQaVpowXf3JgE2jx+L0YoMnWPqPzB3Uw Fn68q3he3JDRFCVGrvt316FgNSpu7zR1uqvV4t/gKNCTRx23uGpo3gkJNpyw4Mv/VYn0 MINtXxGMr6+djaGInUMLW0sLgbV3N7hlC5vRHAV1je2H53fMHljFeW+Zkxvv1hHkIGaq bSgyAwMKaapkfRKcpIzUbP+d+Rsv3XicwGRZXvls/sOycdAbAqroIZ3/DnfcmJWBYJBa uCLGMTbFeZzngUOusmFCCu9ilZNaJvck7BcMrtcyNwd8JK6QNGZXZpycdSj6RhMRFTCB Y0pw== X-Gm-Message-State: AOAM533xopQlzuQx37O+QN6mFYw0Jlc6Kptt9HUuJ0jiRMTwXa3LR/9f iCX6adWxpk2yCMMQ+j6DKzD+jWV/KuT1rA== X-Google-Smtp-Source: ABdhPJzVYm5C1xkGzoWc/dD359XYRJgvAXQ7ihhg9fERom3YSneeWtglAgZsr80eGiSM9o2mQMbLWg== X-Received: by 2002:a17:902:9a4b:: with SMTP id x11mr14305418plv.150.1593597682865; Wed, 01 Jul 2020 03:01:22 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:22 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v3 6/8] Bluetooth: Enable/Disable address resolution during le create conn Date: Wed, 1 Jul 2020 15:34:30 +0530 Message-Id: <20200701100432.28038-7-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: 22D85A3131 X-Rspamd-UID: 8fa948 In this patch if le_create_conn process is started restrict to disable address resolution and same is disabled during le_enh_connection_complete Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_conn.c | 7 +++++- net/bluetooth/hci_event.c | 4 ++++ net/bluetooth/hci_request.c | 45 ++++++++++++++++++++++++++++--------- net/bluetooth/hci_request.h | 3 ++- net/bluetooth/mgmt.c | 2 +- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 8805d68e65f2..8d762567ea16 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1003,6 +1003,11 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, struct hci_request req; int err; + /* This ensures that during disable le_scan address resolution + * will not be disabled if it is followed by le_create_conn + */ + bool rpa_le_conn = true; + /* Let's make sure that le is enabled.*/ if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { if (lmp_le_capable(hdev)) @@ -1103,7 +1108,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, * state. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, rpa_le_conn); hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED); } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 592ef5dda3ab..47a4050462ed 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5221,6 +5221,10 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->interval), le16_to_cpu(ev->latency), le16_to_cpu(ev->supervision_timeout)); + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + hci_req_disable_address_resolution(hdev); } static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 906721759c2f..0dc587026753 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -428,7 +428,7 @@ static void __hci_update_background_scan(struct hci_request *req) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) return; - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); BT_DBG("%s stopping background scanning", hdev->name); } else { @@ -447,7 +447,7 @@ static void __hci_update_background_scan(struct hci_request *req) * don't miss any advertising (due to duplicates filter). */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); hci_req_add_le_passive_scan(req); @@ -652,7 +652,7 @@ void __hci_req_update_eir(struct hci_request *req) hci_req_add(req, HCI_OP_WRITE_EIR, sizeof(cp), &cp); } -void hci_req_add_le_scan_disable(struct hci_request *req) +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) { struct hci_dev *hdev = req->hdev; @@ -676,8 +676,9 @@ void hci_req_add_le_scan_disable(struct hci_request *req) hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + /* Disable address resolution */ if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { __u8 enable = 0x00; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } @@ -1071,7 +1072,7 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) { /* Before changing params disable scan if enabled */ if (hci_dev_test_flag(req->hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ hci_req_add_le_passive_scan(req); @@ -1139,7 +1140,7 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) /* Disable LE passive scan if enabled */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); @@ -1700,6 +1701,28 @@ int hci_req_update_adv_data(struct hci_dev *hdev, u8 instance) return hci_req_run(&req, NULL); } +static void enable_addr_resolution_complete(struct hci_dev *hdev, u8 status, + u16 opcode) +{ + BT_DBG("%s status %u", hdev->name, status); +} + +void hci_req_disable_address_resolution(struct hci_dev *hdev) +{ + struct hci_request req; + __u8 enable = 0x00; + + if (!use_ll_privacy(hdev) && + !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + return; + + hci_req_init(&req, hdev); + + hci_req_add(&req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + + hci_req_run(&req, enable_addr_resolution_complete); +} + static void adv_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode) { BT_DBG("%s status %u", hdev->name, status); @@ -2625,7 +2648,7 @@ static void bg_scan_update(struct work_struct *work) static int le_scan_disable(struct hci_request *req, unsigned long opt) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); return 0; } @@ -2728,7 +2751,7 @@ static int le_scan_restart(struct hci_request *req, unsigned long opt) return 0; } - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); if (use_ext_scan(hdev)) { struct hci_cp_le_set_ext_scan_enable ext_enable_cp; @@ -2819,7 +2842,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) * discovery scanning parameters. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable @@ -2933,14 +2956,14 @@ bool hci_req_stop_discovery(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { cancel_delayed_work(&hdev->le_scan_disable); - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); } ret = true; } else { /* Passive scanning */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); ret = true; } } diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index 0e81614d235e..12bea10e7d70 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -65,11 +65,12 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable); void __hci_req_update_name(struct hci_request *req); void __hci_req_update_eir(struct hci_request *req); -void hci_req_add_le_scan_disable(struct hci_request *req); +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn); void hci_req_add_le_passive_scan(struct hci_request *req); void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next); +void hci_req_disable_address_resolution(struct hci_dev *hdev); void hci_req_reenable_advertising(struct hci_dev *hdev); void __hci_req_enable_advertising(struct hci_request *req); void __hci_req_disable_advertising(struct hci_request *req); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5e9b9728eeac..65d93a38e5b3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -5205,7 +5205,7 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev, hci_req_init(&req, hdev); - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); hci_req_add_le_passive_scan(&req); hci_req_run(&req, NULL); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yIGzGzBf/F76kAAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 12:02:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id ALWoGjBf/F7uNQAA0J78UA (envelope-from ); Wed, 01 Jul 2020 12:02:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A8AB9A2FE6; Wed, 1 Jul 2020 12:02:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729721AbgGAKBd (ORCPT + 1 other); Wed, 1 Jul 2020 06:01:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBc (ORCPT ); Wed, 1 Jul 2020 06:01:32 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1E50C061755 for ; Wed, 1 Jul 2020 03:01:32 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id f16so433651pjt.0 for ; Wed, 01 Jul 2020 03:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vkjx5T9Sq5IYIs+S7efhCR5KF66qOJdP9PWteN5i6Lo=; b=IQpaKIjkCKXiUJiPwiiS/vQiL0VViTB8EJ4zSEitaRCCIv1GmJZO0TvqeIiwjZSxA+ aUEHwJXYWc+TvF0abTyLbPr/HrdA0yMVgzfabd4nZqJizQnLd3GMAJSk9k55gJ324pQV lskhYX3IP58lwLaQOyryQluWrCk5hMbDO4reJzhlgUeEjke5Ia0dR5mceMDUYjS4jRkI h5QqsUVFyTmRmbW4wtF9+LVmWO6J1YjqhCaBLsLRrA+RwXZDtJ7tDWKWBCfI4D3nFbOo GwufLsMnn1nYOofrnuF2TeFo+iEHvopeqVst+QCZfICd0pSbU/IVmbYE5QVoRG81DNou /E7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vkjx5T9Sq5IYIs+S7efhCR5KF66qOJdP9PWteN5i6Lo=; b=lLNEYaZDl8Qlv3Pr3kVz2vG4HO+n7iX49BBcq2CBWrSuqAijeAgVXvJdJwN4sUKyuv Oy1FRuCTYZUJPI71yZxT+VRqil1kkxuC7xO/J6LnEBZQeVybFvbJQ5rLoUWheJV3GZbV X+yY1B+NpVX6WjgxwqgzONAkmmpGQex/atkdREvF2l2NL35TUSM5/oONJobL8c3GOFCK NKmAGDjE+bMfYN4wC65DrxxJYfwy8OSdUJ173ZQiFG1iaO65g7jHGd6Hl2DdO7T1Quda VqTPHWLZRKvA/CisMCYQG4rL6AhpBEMnUOAw4v7yrJfGPIrE8KAoGPvUAtRyIVtbiVHY WBlQ== X-Gm-Message-State: AOAM5314HzO2Tc5JaOAA3LgSBr9+WDZOd2ZRhBFyoDZL5xlWhA+S4dnA n0kzyANRx2ijgFz2huJ5Gk/5s9Blg6AJDA== X-Google-Smtp-Source: ABdhPJyFe2XHAKYJmO8+Lc4E1rTPDNDtHKOjbaEjlnvDZpcVm7aDpeMsMuHCKY/CG50ryTaCyfEY5g== X-Received: by 2002:a17:90a:e602:: with SMTP id j2mr23767397pjy.200.1593597692090; Wed, 01 Jul 2020 03:01:32 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:31 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v3 7/8] Bluetooth: Enable RPA Timeout Date: Wed, 1 Jul 2020 15:34:31 +0530 Message-Id: <20200701100432.28038-8-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: A8AB9A2FE6 X-Rspamd-UID: 53c97a Enable RPA timeout during bluetooth initialization. The RPA timeout value is used from hdev, which initialized from debug_fs Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 2 ++ net/bluetooth/hci_core.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index abab8b5981a7..4ff2fc4498f3 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1637,6 +1637,8 @@ struct hci_rp_le_read_resolv_list_size { #define HCI_OP_LE_SET_ADDR_RESOLV_ENABLE 0x202d +#define HCI_OP_LE_SET_RPA_TIMEOUT 0x202e + #define HCI_OP_LE_READ_MAX_DATA_LEN 0x202f struct hci_rp_le_read_max_data_len { __u8 status; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 604a411a9b8f..b496d5395bd3 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -762,6 +762,14 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt) hci_req_add(req, HCI_OP_LE_CLEAR_RESOLV_LIST, 0, NULL); } + if (hdev->commands[35] & 0x40) { + __le16 rpa_timeout = cpu_to_le16(hdev->rpa_timeout); + + /* Set RPA timeout */ + hci_req_add(req, HCI_OP_LE_SET_RPA_TIMEOUT, 2, + &rpa_timeout); + } + if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) { /* Read LE Maximum Data Length */ hci_req_add(req, HCI_OP_LE_READ_MAX_DATA_LEN, 0, NULL); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qEHaIr2F/F5lxQAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 14:46:53 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OKokIb2F/F6SAQEAgupzMw (envelope-from ); Wed, 01 Jul 2020 14:46:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5FD2FA105C; Wed, 1 Jul 2020 14:46:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730609AbgGAMqh (ORCPT + 1 other); Wed, 1 Jul 2020 08:46:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730604AbgGAMqf (ORCPT ); Wed, 1 Jul 2020 08:46:35 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C79FC03E97B for ; Wed, 1 Jul 2020 05:46:35 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id s1so26759109ljo.0 for ; Wed, 01 Jul 2020 05:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zOvTyVPom8sy12IqSAPoAUTKHIeIoMVlwU22bcDjqVI=; b=oqT6qh0IRRfF/hnPkpSxBlCyj8JlcIeGScOsmu3MknpD1FOeumlsiueZV9yQrK6CbT irSqPO/UzaDN6TU8bs6xDqkerVRlNw8OtpvQIms+HZuijJce976FRgfZHVOMOzJ+iuX4 KBxf6UE202KXfO2JbQ1mpcEZVV9gmuk+p/140T9mOkIVSVCp87s5NiE61LmBwFODPUiU HwuzN2rXXXp45jIAlyYWd2kpJooAB9pHBRbaHLSeoDnG954hScv6X8EOLIonsgOKOnvQ x+nCGPJrXDOssJfQ48uLMfwawqYhSXcU+SF7oq5ZY1VWDhKG4AUadO3Gth8hyX8CbkSG AdfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zOvTyVPom8sy12IqSAPoAUTKHIeIoMVlwU22bcDjqVI=; b=KAvdC9OU3TvjaGJgqTTsY21Ncty5GftFyMPBphNYN0phALJMSZYOEeWKq0NkLVuviA 0HURDVnTkhRQgP3mQJb5oPpnesqblW67OjApMYcS1SmW99EK84ClEmOHiriOKhD7L8cQ uMcqIc062dkKbjvRTLHwZRPevJE0I/lboyZaGa8ylQnxAsZ3zHhv3q13gNNTT5/WJIvU Vxoc9NCNEmwi+gRRKFYxZKumZ/Mfzooj0YnB6zBcAJowhYhF7ttFNqfUvhqkEuDd+WBY D8f10TpD/5JcJ6uKS0sHUklIm9VmK2Ws9fi/Jy9UY5On0mNBKw8BZWHlo2TsF2ausTfR U8Sg== X-Gm-Message-State: AOAM531ooEZvbriKkM5JqJqvOBlHu5gv272NhSGJXg+aZA5WmuUbQybF 0AsHJPZB3bH8Zhlew73HxHovWyyyh12lAW5CVMliUnwP6K4= X-Google-Smtp-Source: ABdhPJyqoZrcGcxMfGqgL0Ym5t+DxEuMVFUjY74p7t/TokcsIbFUid9tbE1q0whKvuYnl7vgX2sWaFjlwZnne9EfZcM= X-Received: by 2002:a2e:85d8:: with SMTP id h24mr12658637ljj.274.1593607593233; Wed, 01 Jul 2020 05:46:33 -0700 (PDT) MIME-Version: 1.0 References: <20200630164204.1.I2cc415fa5793b3e55acfd521ba8f0a71e79aa5f1@changeid> <20200701043001.73qhxyyjx6bayn2m@wunner.de> <20200701113904.7zh534vmlvjvojia@mobilestation> In-Reply-To: <20200701113904.7zh534vmlvjvojia@mobilestation> From: Alain Michaud Date: Wed, 1 Jul 2020 08:46:21 -0400 Message-ID: Subject: Re: [PATCH] Revert "serial: 8250: Fix max baud limit in generic 8250 port" To: Serge Semin , BlueZ Cc: Lukas Wunner , Daniel Winkler , Alexey Malahov , linux-serial@vger.kernel.org, linux-mediatek@lists.infradead.org, chromeos-bluetooth-upstreaming , Aaron Sierra , Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , Vignesh Raghavendra , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.63 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5FD2FA105C X-Rspamd-UID: 26088b Adding the bluetooth list as well per the Bluetooth impact. On Wed, Jul 1, 2020 at 7:39 AM Serge Semin wrote: > > Hello Lukas, > > On Wed, Jul 01, 2020 at 06:30:01AM +0200, Lukas Wunner wrote: > > On Tue, Jun 30, 2020 at 04:42:11PM -0700, Daniel Winkler wrote: > > > This reverts commit 0eeaf62981ecc79e8395ca8caa1570eaf3a12257. > > > > That is not an upstream commit. You probably mean: > > > > commit 7b668c064ec33f3d687c3a413d05e355172e6c92 > > Author: Serge Semin > > Date: Thu May 7 02:31:32 2020 +0300 > > > > serial: 8250: Fix max baud limit in generic 8250 port > > > > And you didn't cc the commit author (hereby fixed). > > > > Thanks, > > > > Lukas > > Thanks for Cc'ing me. > > > > > > > > > The change regresses the QCA6174A-3 bluetooth chip, preventing > > > firmware from being properly loaded. We have verified that without > > > this patch, the chip works as intended. > > That text doesn't say what is really wrong and why the firmware couldn't be loaded. > The original commit gets back the 8250 port baud rate limitation so if the baud > gets out of the range [uartclk / 16 / UART_DIV_MAX; (port->uartclk + tolerance) / > 16], then it will be clamped to be within it. That range is what the standard > 8250 port supports. Acceptance of out of that range values will cause a > problem further in calling serial8250_get_divisor() and uart_get_divisor() > methods (see the original patch log message) for standard 8250 ports. Any different > behavior must be taken into account by a custom set_termios() callbacks or at > least must be workarounded so the standard 8250 ports wouldn't be affected. So in > order to investigate the root cause of the problem it would be good to at least > know what your platform was and what UART port has been used in the attempt to > load the QCA6174A-3 chip firmware. > > -Sergey > > > > > > > Signed-off-by: Daniel Winkler > > > --- > > > > > > drivers/tty/serial/8250/8250_port.c | 4 +--- > > > 1 file changed, 1 insertion(+), 3 deletions(-) > > > > > > diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c > > > index 1632f7d25acca..e057c65ac1580 100644 > > > --- a/drivers/tty/serial/8250/8250_port.c > > > +++ b/drivers/tty/serial/8250/8250_port.c > > > @@ -2618,8 +2618,6 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port, > > > struct ktermios *termios, > > > struct ktermios *old) > > > { > > > - unsigned int tolerance = port->uartclk / 100; > > > - > > > /* > > > * Ask the core to calculate the divisor for us. > > > * Allow 1% tolerance at the upper limit so uart clks marginally > > > @@ -2628,7 +2626,7 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port, > > > */ > > > return uart_get_baud_rate(port, termios, old, > > > port->uartclk / 16 / UART_DIV_MAX, > > > - (port->uartclk + tolerance) / 16); > > > + port->uartclk); > > > } > > > > > > void > > > -- > > > 2.27.0.212.ge8ba1cc988-goog > > -- > You received this message because you are subscribed to the Google Groups "ChromeOS Bluetooth Upstreaming" group. > To unsubscribe from this group and stop receiving emails from it, send an email to chromeos-bluetooth-upstreaming+unsubscribe@chromium.org. > To post to this group, send email to chromeos-bluetooth-upstreaming@chromium.org. > To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromeos-bluetooth-upstreaming/20200701113904.7zh534vmlvjvojia%40mobilestation. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AOsRCAWM/F40HQEAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 15:13:41 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6IdDBgWM/F62IwEAgupzMw (envelope-from ); Wed, 01 Jul 2020 15:13:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BD7FBA2FB9; Wed, 1 Jul 2020 15:13:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729074AbgGANNe (ORCPT + 1 other); Wed, 1 Jul 2020 09:13:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729033AbgGANNd (ORCPT ); Wed, 1 Jul 2020 09:13:33 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC84AC03E979 for ; Wed, 1 Jul 2020 06:13:33 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id k7so11905953vso.2 for ; Wed, 01 Jul 2020 06:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YbCm4jyQ5Z7fswEhmWxi6mUhfjhFp3mrFc9hYHxgovw=; b=M6pBiCWrvV2QBMs3+8N/FzDlXAqLjhywAUpZIWBrkTzkJZw0UinfcgnTUQhP2zdOn7 B8o6/qbIB+3iw96obrSBOhTUQiTarMPAr/iLC3IxJi/Z1gZMKgyNt8gGWMHVOyej23cR 2YWvYmi/W0APuQOZN1+2iZVSLg3H9KzxWOOco= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YbCm4jyQ5Z7fswEhmWxi6mUhfjhFp3mrFc9hYHxgovw=; b=jQXgD26NV8rLgc9op9W7eIg9hQWvcKE2MDnWMh9bqVpKaHuWNjjsP6H8BfD5VLzYyM NTROrXhPqQsD2JRwXMxKuHqf4ZOqfVdCFvyuWuIeIWAba9/lgDvvyNujxG1LzII94YWI eGVPDyKqPvfWNoXwsZx4KTUvAFpL9oVvBWBfu0JoRA3+u2pj4fdNA4iTdV1Y4/70ZWwd U+Z0xqI1c7xrQcGcisBUVPLAluyt8l/7INxoAnJiHBedOcju/y5SeS7N9lvGhdsS8jTN jLqtJqdwRnK9lo9Y3hHY5DP7TZv86w1ZBAenNLW8KN7j15LzPGenzErLLOVceyX8QKbs no3g== X-Gm-Message-State: AOAM53137d5SrZ2xAicPvg5XIRPaTgRH1zR3pMEVTfeac3kVnstqM2QU Pp33AdwRuwRBwf3yIDEvHM08bGK5ca0= X-Google-Smtp-Source: ABdhPJySK84ybZGx4Gl6iAD5MZKPTQVkFMOWTZX4RIL6lMtK+SDlXd7V66qAYiB1Jd7UfwVVuNLyDg== X-Received: by 2002:a67:e007:: with SMTP id c7mr18399151vsl.209.1593609212482; Wed, 01 Jul 2020 06:13:32 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id y135sm949458vky.15.2020.07.01.06.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 06:13:31 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud , Miao-Chen Chou , Abhishek Pandit-Subedi , Manish Mandlik Subject: [BlueZ PATCH v3] profiles/scanparam: use configured scanparams when available Date: Wed, 1 Jul 2020 13:13:28 +0000 Message-Id: <20200701131328.3835273-1-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: BD7FBA2FB9 X-Rspamd-UID: 43ab0d This patch updates the scan parameter service to use the configured scan parameters when available rather than the hardcoded kernel defaults. Reviewed-by: Miao-Chen Chou Reviewed-by: Abhishek Pandit-Subedi Reviewed-by: Manish Mandlik --- Changes in v3: - Addin Chromium/Gerrit reviewers Changes in v2: - Fixing checkpatch comment warning. profiles/scanparam/scan.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c index 9e8f57747..d72be3dff 100644 --- a/profiles/scanparam/scan.c +++ b/profiles/scanparam/scan.c @@ -45,12 +45,11 @@ #include "src/shared/gatt-db.h" #include "src/shared/gatt-client.h" #include "attrib/att.h" +#include "src/hcid.h" #define SCAN_INTERVAL_WIN_UUID 0x2A4F #define SCAN_REFRESH_UUID 0x2A31 -#define SCAN_INTERVAL 0x0060 -#define SCAN_WINDOW 0x0030 #define SERVER_REQUIRES_REFRESH 0x00 struct scan { @@ -75,8 +74,16 @@ static void write_scan_params(struct scan *scan) { uint8_t value[4]; - put_le16(SCAN_INTERVAL, &value[0]); - put_le16(SCAN_WINDOW, &value[2]); + /* Unless scan parameters are configured, use the known kernel default + * parameters + */ + put_le16(main_opts.default_params.le_scan_interval_autoconnect ? + main_opts.default_params.le_scan_interval_autoconnect : + 0x60, &value[0]); + + put_le16(main_opts.default_params.le_scan_win_autoconnect ? + main_opts.default_params.le_scan_win_autoconnect : + 0x30, &value[2]); bt_gatt_client_write_without_response(scan->client, scan->iwhandle, false, value, sizeof(value)); -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id OFYzDNtu+16hOQEA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 18:56:59 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SJu3Cttu+16tzAEADc0bRg (envelope-from ); Tue, 30 Jun 2020 18:56:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3D2A4A2475; Tue, 30 Jun 2020 18:56:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389565AbgF3Qzb convert rfc822-to-8bit (ORCPT + 1 other); Tue, 30 Jun 2020 12:55:31 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:43189 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389308AbgF3Qzb (ORCPT ); Tue, 30 Jun 2020 12:55:31 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 8CF1ACECEE; Tue, 30 Jun 2020 19:05:24 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2] Bluetooth: btusb: USB alternate setting 1 for WBS From: Marcel Holtmann In-Reply-To: <20200630130940.14339-1-hildawu@realtek.com> Date: Tue, 30 Jun 2020 18:55:29 +0200 Cc: Johan Hedberg , Matthias Brugger , linux-bluetooth , kernel list , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, max.chou@realtek.com, alex_lu@realsil.com.cn, kidman@realtek.com Content-Transfer-Encoding: 8BIT Message-Id: <5A548628-4B7E-4E25-A728-B1CD06C28F39@holtmann.org> References: <20200630130940.14339-1-hildawu@realtek.com> To: hildawu@realtek.com X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3D2A4A2475 X-Rspamd-UID: 03ac39 Content-Length: 731 Hi Hilda, > RTL8822CE supports transparent WBS to apply USB alternate setting 1. > Add a flag to the device match data to apply alternate setting 1 which > meet the transfer speed for WBS support. > > Signed-off-by: Hilda Wu > --- > Changes in v2: > - More descriptive commit log and short description. > - Use BTUSB_USE_ALT1_FOR_WBS replace BTUSB_WBS_ALT1 for descriptive name. > - Move alternate setting 1 check into the btusb_probe() function and adjust position of data->isoc for alternate setting check. > --- > --- > drivers/bluetooth/btusb.c | 34 ++++++++++++++++++++-------------- > 1 file changed, 20 insertions(+), 14 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WKfyNURf/F67FAAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 12:02:44 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AJW+M0Rf/F4ybQAAgupzMw (envelope-from ); Wed, 01 Jul 2020 12:02:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0708CA26CD; Wed, 1 Jul 2020 12:02:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729339AbgGAKCX (ORCPT + 1 other); Wed, 1 Jul 2020 06:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKCW (ORCPT ); Wed, 1 Jul 2020 06:02:22 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75BFEC061755 for ; Wed, 1 Jul 2020 03:02:22 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id x9so20555880ila.3 for ; Wed, 01 Jul 2020 03:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=6vcIJ8eBrpFXMulGN9ndG9kD25/Ne9bo0gCXN7FEGP0=; b=Lo6FdJGLEtRm3FqSKL4z4kXbpSyTOKNf1wb9Dd0kgwnFfbg7eqN84TlJnOHtvtTc8r 5Rn8kUvzjmf+wHKHO63yy/YHAg85cy53NiP3cZDmUoA1rLyjFiKNSbW8QYgeQFA5HYJS ha6MB+B6SwZYgNNn3F9nOti2y8WxNXpvqd+7lwHYgO8KiB20driU4ERlwu3n6FeD5W8F dKd9X/DFCjMUp3jPEiHeRdXZOXP4Mq1qJC4mzaNW2UCLd5zLYre6IiniyvMhdAkRKmJ1 3j8rMBlxHDom8OcdBeVoO546Qv91SIh25FDvIxZoOBE3RouS4rv7T8vubp/b8zbQ7/bn Iy5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6vcIJ8eBrpFXMulGN9ndG9kD25/Ne9bo0gCXN7FEGP0=; b=aRyPMVKh8HiFeXEavmp5Ns0yyygEbMdwutZtGitCCmR4F+hmZqbUb7oSvXFeOvmie8 p/MVUnK0sFpJ7grWspX8CzywQIENzYMRIHxuIl9bQOCbqFMAhQgKDC62jR8DUUb4MNQQ hSrhzc+COnhHKSGdax7fFTG4+BUaLLr19Lja2HF+fLUN0zzP7BGPdr/18D0MpvHR1HGJ 4ie5M1ar9XAzFn69zpW7S/RXNsi8PRrasboxt/5HUF0r5tKUvAMZOZBZmVTfE7aYk6u/ yxIuuJ1gDd9kGAkuU5KwDYtIf8U8PsY0GH9mpGSfX0j9LUlzSQHvWONXj3+6bTZB1s97 vCIQ== X-Gm-Message-State: AOAM530c5LoSyV3dBzbpAu2bBLzHm0IFXtzZrnIattI1T02JaDXBz8tE xBZP8xJUMJHoyYDDlnB/+aDXBNysktgDeE0W3C4= X-Google-Smtp-Source: ABdhPJwPrua9Vx6V1J8cI3yohBfw8SBO7CISU2R/JFtCpb2Jkh9svH24n7/ehBl4mp2uDhnF2c9D2u5DiAOKNdM7Vvg= X-Received: by 2002:a92:dd02:: with SMTP id n2mr7019658ilm.257.1593597741812; Wed, 01 Jul 2020 03:02:21 -0700 (PDT) MIME-Version: 1.0 References: <20200603171713.9882-1-sathish.narasimman@intel.com> In-Reply-To: From: Sathish Narasimman Date: Wed, 1 Jul 2020 15:32:10 +0530 Message-ID: Subject: Re: [PATCH v2 0/7] LL Privacy support To: Marcel Holtmann Cc: Bluetooth Kernel Mailing List , Sathish Narasimman Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0708CA26CD X-Rspamd-UID: f965e9 Content-Length: 1981 Hi Marcel On Fri, Jun 19, 2020 at 1:28 PM Marcel Holtmann wrote= : > > Hi Sathish, > > > Based on the input the patches modified and verifed accordingly. > > > > Marcel Holtmann (3): > > Bluetooth: Translate additional address type correctly > > Bluetooth: Configure controller address resolution if available > > Bluetooth: Update resolving list when updating whitelist > > > > Sathish Narasimman (4): > > Bluetooth: Translate additional address type during le_conn > > Bluetooth: Let controller creates RPA during le create conn > > Bluetooth: Enable/Disable address resolution during le create conn > > Bluetooth: Enable RPA Timeout > > > > include/net/bluetooth/hci.h | 8 ++- > > include/net/bluetooth/hci_core.h | 3 + > > net/bluetooth/hci_conn.c | 6 +- > > net/bluetooth/hci_core.c | 17 +++++ > > net/bluetooth/hci_event.c | 20 ++++++ > > net/bluetooth/hci_request.c | 119 ++++++++++++++++++++++++++----- > > net/bluetooth/hci_request.h | 3 +- > > net/bluetooth/mgmt.c | 2 +- > > 8 files changed, 157 insertions(+), 21 deletions(-) > > can you please rebase this against the latest bluetooth-next tree. With t= he introduction of the advertising monitor, we now have a few conflicts tha= t you need to resolve. > > Also as discussed, we wanted to hide this initially after an experimental= feature flag so it would need to be enabled first. And I think once enable= d, we need to take the support of =E2=80=9Cadvertising=E2=80=9D aka periphe= ral away from the controller until we can fully ensure it works for scannin= g and advertising at the same time. Updated the v3 rebased and the flag is introduced to enable LL privacy from the host using mgmt set_privacy interface. what I understood regarding removing of advertising was when we enable LL privacy using mgmt interface. the advertisement should not work (correct me please). > > Regards > > Marcel > Regards Sathish N Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id YIDULPq0+16jbAEA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 23:56:10 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WK0zK/q0+16e6AEAgupzMw (envelope-from ); Tue, 30 Jun 2020 23:56:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 371DC52830; Tue, 30 Jun 2020 23:56:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727083AbgF3V4C (ORCPT + 1 other); Tue, 30 Jun 2020 17:56:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbgF3V4B (ORCPT ); Tue, 30 Jun 2020 17:56:01 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08F52C061755 for ; Tue, 30 Jun 2020 14:56:01 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id t74so12355392lff.2 for ; Tue, 30 Jun 2020 14:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tmOZ0XuG4g2eZl+4ZC4AL+xOIxaD6EMfVCRTLIIYYGE=; b=Vyf6XWz5jRcDww52yc4d4Oq+roFuuZKNq/BHB+ZWpxojfUqNPllihDN3f5lJ8Y/T9Z mwZ+lFjbe/hrfezCl+gc8clJtr574NRs/xP5o/wtJ8y+u91ep3VP16u8K22A7ej7qLdC ehvTBg23bF+6odhA/tdesc/Y3povKcjIUODms= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tmOZ0XuG4g2eZl+4ZC4AL+xOIxaD6EMfVCRTLIIYYGE=; b=JRXwxCUP7UQXyh5nHusgmI2md3mOU45yczKv83vYLsbELe8AIHsRydxjikOyrtCcil ibtK2IEoRJg8x/9pNDWmfBoZiVhqSzORYBHxkYq3ituQT633/yBfdPDlbmrOR4ouDuES o2iHP+NlUanf5Od8YM1ugoa6qLDILZlxitIvqoje01H2CTY5pSLkf2DPK72teMu/wAuM EYZ8BORf7PT3feh7C787IChh/arcD50UvVsoVx6InuSdO7N3AOWZ3eZs4ceEqicUu782 Ix8Ibbo2WTCa/RX3RyrquLbQElbG0Vfa7xLPN3f19sRphvca/UPGY1CeARDM/7x/hhuM FsDg== X-Gm-Message-State: AOAM530NctXgzTurm9kZY+Oad73N7wPFFcHRVHPd2V8rBW1c9tm/XhBe KCF3Ha0+R0O5Xqd4aaP+OmNiQdAdVro/2rbb9d+X0yY6lEY= X-Google-Smtp-Source: ABdhPJwR94n+7xH83mHqidczu9CR0DjnMKdnF/jaaPKl94g8fG7h0fWVOeEftBCONCQWeAKI/tJPnTqCAI/9SJ7Gstg= X-Received: by 2002:a19:8407:: with SMTP id g7mr13225699lfd.61.1593554159514; Tue, 30 Jun 2020 14:55:59 -0700 (PDT) MIME-Version: 1.0 References: <20200629201441.v1.1.I162e3c6c4f4d963250c37733c3428329110c5989@changeid> <968D6753-8ACB-4298-91A4-F2C9438EAC06@holtmann.org> In-Reply-To: <968D6753-8ACB-4298-91A4-F2C9438EAC06@holtmann.org> From: Miao-chen Chou Date: Tue, 30 Jun 2020 14:55:48 -0700 Message-ID: Subject: Re: [PATCH v1] Bluetooth: Fix kernel oops triggered by hci_adv_monitors_clear() To: Marcel Holtmann Cc: Bluetooth Kernel Mailing List , Alain Michaud , Pavel Machek , Abhishek Pandit-Subedi , "David S. Miller" , Jakub Kicinski , Johan Hedberg , LKML , netdev Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: 371DC52830 X-Rspamd-UID: 8e0053 Content-Length: 1789 Hi Marcel, hci_unregister_dev() is invoked when the controller is intended to be removed by btusb driver. In other words, there should not be any activity on hdev's workqueue, so the destruction of the workqueue should be the first thing to do to prevent the clear helpers from issuing any work. So my suggestion is to revert the patch re-arranging the workqueue and apply this instead. I should have uploaded this earlier, but I encountered some troubles while verifying the changes. Sorry for the inconvenience. Regards, Miao On Mon, Jun 29, 2020 at 11:51 PM Marcel Holtmann wrote: > > Hi Miao-chen, > > > This fixes the kernel oops by removing unnecessary background scan > > update from hci_adv_monitors_clear() which shouldn't invoke any work > > queue. > > > > The following test was performed. > > - Run "rmmod btusb" and verify that no kernel oops is triggered. > > > > Signed-off-by: Miao-chen Chou > > Reviewed-by: Abhishek Pandit-Subedi > > Reviewed-by: Alain Michaud > > --- > > > > net/bluetooth/hci_core.c | 2 -- > > 1 file changed, 2 deletions(-) > > > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > > index 5577cf9e2c7cd..77615161c7d72 100644 > > --- a/net/bluetooth/hci_core.c > > +++ b/net/bluetooth/hci_core.c > > @@ -3005,8 +3005,6 @@ void hci_adv_monitors_clear(struct hci_dev *hdev) > > hci_free_adv_monitor(monitor); > > > > idr_destroy(&hdev->adv_monitors_idr); > > - > > - hci_update_background_scan(hdev); > > } > > I am happy to apply this as well, but I also applied another patch re-arranging the workqueue destroy handling. Can you check which prefer or if we should include both patches. > > Regards > > Marcel > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id iNH8K0fZ+15qjQAA0J78UA (envelope-from ) for ; Wed, 01 Jul 2020 02:31:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id oIM+KkfZ+14twgEAlScrYA (envelope-from ); Wed, 01 Jul 2020 02:31:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D2F424086C; Wed, 1 Jul 2020 02:31:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726047AbgGAAa5 (ORCPT + 1 other); Tue, 30 Jun 2020 20:30:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbgGAAa4 (ORCPT ); Tue, 30 Jun 2020 20:30:56 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 951BBC061755 for ; Tue, 30 Jun 2020 17:30:56 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id 5so18070877oty.11 for ; Tue, 30 Jun 2020 17:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TKvRpCUpNSBLmtj5feOgRrmzFRKa8EAlVS6hQKObv4M=; b=bHzISLRKT4OYeZhPc6OnMqA+UWkxB36SABdA/LC8cuqm12qArfpT5gJkUIXgAsPpYb yDGUzev8s6ZKHCHFKg5+JMzxlBYWdIHPijJ0JguK+3xfloey68fpXwsVMfgz8wpac2T4 8LH8T3vcrBRzpqYjX0GKGJwAv7ZFjxqf4Lzyvjyst/g4Pk3tZkS3F+qwZHK3tnZfrxPz Mp29NRIEQQMXg5cZVk/uAVugCWsIAbokckCBmFCGnco+AAxgWWJsApAw+2PbwG4YNumo lrR3cH62B7l2FBqhLssjvs4T+J51GJIS3uBW1ejj8/LRbOM91RIfF50mk8pwBWc+XUa8 2brw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TKvRpCUpNSBLmtj5feOgRrmzFRKa8EAlVS6hQKObv4M=; b=AhATb1Skn7cHf0pSlA/msK4SLa7p6KdL6j0QTYkyKGSA/Y++Agn7l2KWg8bAQc+7yI dzLZofOwC/OTthdTGvUTWOmbz0vzYyExGEGvx0mFEfxi6RXfwAZztaLMRCAv7Z+8S3ro Z2b7Fs2yEUU4di5veXihlxzMlKlO/yhGhAbDLnY+OA56ENsB6D8eGeuNTxfNBY/F5qet 5RhGDYOXQsRTTbXNAimLejXRYXDPSzADOigwh6yIHgVz8jjHl6I2wY2LHaGNGwac4N96 tCXGyYrBnwsBTEVPczcpYPEcQQbAB977fN2Ck1YyafjV2oHFKdBoxp6eRE3HKJAOoiNn wcMw== X-Gm-Message-State: AOAM530sBZRI8G93/Lew9ZnAEyEOjqD7JB08i9OTwd9feoif+d4b78vA 7ltXk0kX7lv/50gfC69glrQivHXq0AEU0Ns3EvQ= X-Google-Smtp-Source: ABdhPJzXGyrvuCp2/PaRSpOgZONhKBVeUnysoowGwKlLl1hl/dwVhm3BOXBcleWOLIooG0qXaIO45c/idbsKTmX4J8U= X-Received: by 2002:a9d:6c09:: with SMTP id f9mr3176510otq.362.1593563455855; Tue, 30 Jun 2020 17:30:55 -0700 (PDT) MIME-Version: 1.0 References: <20200630154855.Bluez.v1.1.I63c3ddd54189c2ad9ca9aba2c08e0925d7f0aee3@changeid> In-Reply-To: <20200630154855.Bluez.v1.1.I63c3ddd54189c2ad9ca9aba2c08e0925d7f0aee3@changeid> From: Luiz Augusto von Dentz Date: Tue, 30 Jun 2020 17:30:44 -0700 Message-ID: Subject: Re: [Bluez PATCH v1] device - If HFP is supported, ignore HSP To: Yu Liu Cc: "linux-bluetooth@vger.kernel.org" , Hsin-Yu Chao , Sonny Sasaka Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: D2F424086C X-Rspamd-UID: 9fab59 Content-Length: 2234 Hi Yu Liu, On Tue, Jun 30, 2020 at 3:55 PM Yu Liu wrote: > > From: Hsin-Yu Chao > > For a BT headset that supports both HSP and HFP, BlueZ creates > service instances for these two profiles and connects them. > It's uncertain that which of HSP and HFP eventually get connected > and being used for SCO audio. And we start observing some problem > because of this uncertainty: > > - For headset that supports WBS, we need HFP connect for codec > negotiation. If HSP connects but not HFP, WBS cannot be used. We should probably have a way to detect when one or the other is connected and then don't attempt to connect again since they would likely conflict when it comes to connecting SCO, that said is your system setting AutoConnect for both HSP and HFP? > - For WH-1000XM3, if BlueZ ever initiated HFP connection but failed, > headset won't have working SCO audio even HSP is connected. Hmm I guess this will need to treated separately, not sure if we can exclude HSP to be connected once HFP fails, but then again I think the system should not have them both set to be Auto Connected, HSP most likely should only be set as as a fallback if HFP is not supported. > Fix this at when device probes services, if HFP is in the uuid list, > don't bother create one for HSP. > > Reviewed-by: Sonny Sasaka > --- > > Changes in v1: > - Initial change > > src/device.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/src/device.c b/src/device.c > index 7b0eb256e..4036bfd81 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -4370,6 +4370,11 @@ static struct btd_service *probe_service(struct btd_device *device, > if (!device_match_profile(device, profile, uuids)) > return NULL; > > + /* If device supports HFP, don't bother create service for HSP. */ > + if (g_slist_find_custom(uuids, HFP_HS_UUID, bt_uuid_strcmp) && > + bt_uuid_strcmp(profile->remote_uuid, HSP_HS_UUID) == 0) > + return NULL; > + > l = find_service_with_profile(device->services, profile); > if (l) > return l->data; > -- > 2.27.0.212.ge8ba1cc988-goog > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id wBN3ChBv+15GIwEA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 18:57:52 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mEXdCBBv+16owAEADc0bRg (envelope-from ); Tue, 30 Jun 2020 18:57:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 18386A1664; Tue, 30 Jun 2020 18:57:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389903AbgF3Qzd (ORCPT + 1 other); Tue, 30 Jun 2020 12:55:33 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:60223 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389899AbgF3Qzc (ORCPT ); Tue, 30 Jun 2020 12:55:32 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id E7DEDCECED; Tue, 30 Jun 2020 19:05:25 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2] Bluetooth: use configured default params for active scans From: Marcel Holtmann In-Reply-To: <20200629170415.3227892-1-alainm@chromium.org> Date: Tue, 30 Jun 2020 18:55:31 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: References: <20200629170415.3227892-1-alainm@chromium.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.94 / 15.00 / 200.00 X-Rspamd-Queue-Id: 18386A1664 X-Rspamd-UID: 982226 Content-Length: 356 Hi Alain, > This patch fixes active scans to use the configured default parameters. > > Signed-off-by: Alain Michaud > --- > > Changes in v2: > - Rebase onto master > > net/bluetooth/hci_request.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id iETFBIT3+l4RyQEA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 10:27:48 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id aM0/A4T3+l7JVwAAlScrYA (envelope-from ) for ; Tue, 30 Jun 2020 10:27:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1E551A2765 for ; Tue, 30 Jun 2020 10:27:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1731427AbgF3I1c for ; Tue, 30 Jun 2020 04:27:32 -0400 To: woutergordts@mailbox.org From: Majordomo@vger.kernel.org Subject: Welcome to linux-bluetooth Reply-To: Majordomo@vger.kernel.org Message-Id: Date: Tue, 30 Jun 2020 04:27:32 -0400 X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1E551A2765 X-Rspamd-UID: ed96cb Content-Length: 902 -- Welcome to the linux-bluetooth mailing list! Please save this message for future reference. Thank you. If you ever want to remove yourself from this mailing list, you can send mail to with the following command in the body of your email message: unsubscribe linux-bluetooth or from another account, besides woutergordts@mailbox.org: unsubscribe linux-bluetooth woutergordts@mailbox.org If you ever need to get in contact with the owner of the list, (if you have trouble unsubscribing, or have questions about the list itself) send email to . This is the general rule for most mailing lists when you need to contact a human. Here's the general information for the list you've subscribed to, in case you don't already have it: Linux Bluetooth discussion Archives: http://www.spinics.net/lists/linux-bluetooth/ Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id oD/MMAY6+14nNQEA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 15:11:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id GO2jLgY6+152dgAA0J78UA (envelope-from ); Tue, 30 Jun 2020 15:11:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EBC09A213D; Tue, 30 Jun 2020 15:11:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728191AbgF3NLF (ORCPT + 1 other); Tue, 30 Jun 2020 09:11:05 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:53132 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbgF3NLE (ORCPT ); Tue, 30 Jun 2020 09:11:04 -0400 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.69 with qID 05UD9m3N2022713, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexmb06.realtek.com.tw[172.21.6.99]) by rtits2.realtek.com.tw (8.15.2/2.66/5.86) with ESMTPS id 05UD9m3N2022713 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 30 Jun 2020 21:09:48 +0800 Received: from RTEXMB04.realtek.com.tw (172.21.6.97) by RTEXMB06.realtek.com.tw (172.21.6.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Tue, 30 Jun 2020 21:09:48 +0800 Received: from localhost.localdomain (172.21.87.237) by RTEXMB04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Tue, 30 Jun 2020 21:09:47 +0800 From: To: CC: , , , , , , , , Subject: [PATCH v2] Bluetooth: btusb: USB alternate setting 1 for WBS Date: Tue, 30 Jun 2020 21:09:40 +0800 Message-ID: <20200630130940.14339-1-hildawu@realtek.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.87.237] X-ClientProxiedBy: RTEXMB03.realtek.com.tw (172.21.6.96) To RTEXMB04.realtek.com.tw (172.21.6.97) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.90 / 15.00 / 200.00 X-Rspamd-Queue-Id: EBC09A213D X-Rspamd-UID: 20c0cb Content-Length: 3083 From: Hilda Wu RTL8822CE supports transparent WBS to apply USB alternate setting 1. Add a flag to the device match data to apply alternate setting 1 which meet the transfer speed for WBS support. Signed-off-by: Hilda Wu --- Changes in v2: - More descriptive commit log and short description. - Use BTUSB_USE_ALT1_FOR_WBS replace BTUSB_WBS_ALT1 for descriptive name. - Move alternate setting 1 check into the btusb_probe() function and adjust position of data->isoc for alternate setting check. --- --- drivers/bluetooth/btusb.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index c7cc8e594166..e4a12c58501e 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -453,6 +453,7 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { #define BTUSB_HW_RESET_ACTIVE 12 #define BTUSB_TX_WAIT_VND_EVT 13 #define BTUSB_WAKEUP_DISABLE 14 +#define BTUSB_USE_ALT1_FOR_WBS 15 struct btusb_data { struct hci_dev *hdev; @@ -1666,14 +1667,15 @@ static void btusb_work(struct work_struct *work) new_alts = data->sco_num; } } else if (data->air_mode == HCI_NOTIFY_ENABLE_SCO_TRANSP) { - - data->usb_alt6_packet_flow = true; - /* Check if Alt 6 is supported for Transparent audio */ - if (btusb_find_altsetting(data, 6)) + if (btusb_find_altsetting(data, 6)) { + data->usb_alt6_packet_flow = true; new_alts = 6; - else + } else if (test_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags)) { + new_alts = 1; + } else { bt_dev_err(hdev, "Device does not support ALT setting 6"); + } } if (btusb_switch_alt_setting(hdev, new_alts) < 0) @@ -3954,6 +3956,15 @@ static int btusb_probe(struct usb_interface *intf, btusb_check_needs_reset_resume(intf); } + if (id->driver_info & BTUSB_AMP) { + /* AMP controllers do not support SCO packets */ + data->isoc = NULL; + } else { + /* Interface orders are hardcoded in the specification */ + data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); + data->isoc_ifnum = ifnum_base + 1; + } + if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) && (id->driver_info & BTUSB_REALTEK)) { hdev->setup = btrtl_setup_realtek; @@ -3965,21 +3976,16 @@ static int btusb_probe(struct usb_interface *intf, * (DEVICE_REMOTE_WAKEUP) */ set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); + if (btusb_find_altsetting(data, 1)) + set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); + else + bt_dev_err(hdev, "Device does not support ALT setting 1"); err = usb_autopm_get_interface(intf); if (err < 0) goto out_free_dev; } - if (id->driver_info & BTUSB_AMP) { - /* AMP controllers do not support SCO packets */ - data->isoc = NULL; - } else { - /* Interface orders are hardcoded in the specification */ - data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); - data->isoc_ifnum = ifnum_base + 1; - } - if (!reset) set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 6LIgHIj3+l4RyQEA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 10:27:52 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id qETLGoj3+l7fugEADc0bRg (envelope-from ) for ; Tue, 30 Jun 2020 10:27:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4C990A158F for ; Tue, 30 Jun 2020 10:27:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1731425AbgF3I1c for ; Tue, 30 Jun 2020 04:27:32 -0400 To: woutergordts@mailbox.org From: Majordomo@vger.kernel.org Subject: Majordomo results: Re: Confirmation for subscribe linux-blu Reply-To: Majordomo@vger.kernel.org Message-Id: Date: Tue, 30 Jun 2020 04:27:32 -0400 X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4C990A158F X-Rspamd-UID: 416e35 Content-Length: 85 -- >>>> auth 2907518f subscribe linux-bluetooth woutergordts@mailbox.org Succeeded. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id ePKjIx9v+15GIwEA0J78UA (envelope-from ) for ; Tue, 30 Jun 2020 18:58:07 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id GGzIIR9v+17y6AEA0J78UA (envelope-from ); Tue, 30 Jun 2020 18:58:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4CC0BA1B5E; Tue, 30 Jun 2020 18:57:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387825AbgF3Qze (ORCPT + 1 other); Tue, 30 Jun 2020 12:55:34 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:36550 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389904AbgF3Qzd (ORCPT ); Tue, 30 Jun 2020 12:55:33 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id B3692CECED; Tue, 30 Jun 2020 19:05:27 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v3] Bluetooth: Adding a configurable autoconnect timeout From: Marcel Holtmann In-Reply-To: <20200629161100.3070288-1-alainm@chromium.org> Date: Tue, 30 Jun 2020 18:55:33 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: References: <20200629161100.3070288-1-alainm@chromium.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.94 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4CC0BA1B5E X-Rspamd-UID: 53bf55 Content-Length: 529 Hi Alain, > This patch adds a configurable LE autoconnect timeout. > > Signed-off-by: Alain Michaud > --- > > Changes in v3: > - Rebase onto master > > Changes in v2: > Fixing longer than 80 char line. > > include/net/bluetooth/hci_core.h | 1 + > net/bluetooth/hci_core.c | 1 + > net/bluetooth/hci_event.c | 2 +- > net/bluetooth/mgmt_config.c | 13 +++++++++++++ > 4 files changed, 16 insertions(+), 1 deletion(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EE17IlvO/F5OxAAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 19:56:43 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id wGsIIVvO/F7XBgAAgupzMw (envelope-from ); Wed, 01 Jul 2020 19:56:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0DE93400FA; Wed, 1 Jul 2020 19:56:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732016AbgGAR4h (ORCPT + 1 other); Wed, 1 Jul 2020 13:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729871AbgGAR4h (ORCPT ); Wed, 1 Jul 2020 13:56:37 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08162C08C5C1 for ; Wed, 1 Jul 2020 10:56:37 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id y22so8752333oie.8 for ; Wed, 01 Jul 2020 10:56:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0Ls8IsKIk7NU/ETs03RIvkIdisdmmvQF6Bl4XBfF4+E=; b=Z/AKkttCI2eIXOQi6/fByvTN36UJdKkDOn1aVIAp6HIpABDE/tZedpbPg7FpCQQ2vm oRA8obcuJrEnJV9ghlxUxyR4H3xeWCJ4eDydzJRZiR9UWx6HiHy6nHvCa2G5gMpDsGyx fQwDx1ctEtZ7JW5auvgnZvyuZ+ppttIaQvMywb6XJVFy1NHlEYMeH0v34t7USYUr1kfy sru9l9Xww165JMhZijnT80pLpGO2AZVN6cZWawylNg4e3i3G+3rowBNy2N1q7x7kZ+Nd KC3+0j31zqOF2smpwBUrYg6loj9y2RPg2drFkKuhIUdXkAq5bfb9/xx0jJQxOsU5uVRo 7/CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0Ls8IsKIk7NU/ETs03RIvkIdisdmmvQF6Bl4XBfF4+E=; b=sQjsVCYK4KqjLS5biSUKx73RnyvnwQQYTEMXXykc9Y65+J4Xgsc7rgbxCi1IQAN9ec rkfIgs8gxEQMV9urt3o0iFXitjFmHkHUf7Y920OhOcjqXYVEvF9qTHGzuBbydY7gvmrQ 2RKT+7GOoi0r3DZWyzKOHQaulKr52FC9+iE1XkC0r0Zk+pQsmDmZhNHtSEipdjX3IVtZ xaERmCUoOFA7RuWbTE0j5jzAHrhmF4jz1LEvMZgnMr9RkYIsRE7wfUibr+ldhqO5nrqb U4unlXYn2aP1PSmCqZHJMSrQ2O2Ovvm/9ju4PDo40dX8Sy4/pcYCSMpT33tMnhR3TG2H CUqw== X-Gm-Message-State: AOAM531RVPPP92yhK5uxatunF4ETBiWmOU2NAjLDycohfO+pryEJbj4e uho3Er2doy3JP1tx55y2mZmRp0C0MfP0gbODmNE= X-Google-Smtp-Source: ABdhPJyeEQSUGGoHfHKC8otW9FaxyxClTDkRoO8nLu3vK7lper9WpURQGnJ2GtVw0vzXH6p459QUH+GxkRZkwyCOk/k= X-Received: by 2002:aca:cf81:: with SMTP id f123mr15017156oig.137.1593626196366; Wed, 01 Jul 2020 10:56:36 -0700 (PDT) MIME-Version: 1.0 References: <20200630184629.95013-1-sonnysasaka@chromium.org> In-Reply-To: <20200630184629.95013-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz Date: Wed, 1 Jul 2020 10:56:24 -0700 Message-ID: Subject: Re: [PATCH v2] client: Add battery command To: Sonny Sasaka Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0DE93400FA X-Rspamd-UID: 565c23 Content-Length: 4913 Hi Sonny, On Tue, Jun 30, 2020 at 1:48 PM Sonny Sasaka wrote: > > This adds the "battery" command to show battery information of a peer > device based on org.bluez.Battery1 API. Example usage: > > [bluetooth]# battery XX:XX:XX:XX:XX:XX > Percentage: 100% It might be better to put the battery level under info command. > --- > client/main.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 62 insertions(+) > > diff --git a/client/main.c b/client/main.c > index 422da5593..8c1ed00fb 100644 > --- a/client/main.c > +++ b/client/main.c > @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; > static GDBusProxy *default_dev; > static GDBusProxy *default_attr; > static GList *ctrl_list; > +static GList *battery_proxies; > > static const char *agent_arguments[] = { > "on", > @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) > bt_shell_set_prompt(PROMPT_OFF); > > g_list_free_full(ctrl_list, proxy_leak); > + g_list_free_full(battery_proxies, proxy_leak); > ctrl_list = NULL; > + battery_proxies = NULL; > > default_ctrl = NULL; > } > @@ -445,6 +448,16 @@ done: > g_free(desc); > } > > +static void battery_added(GDBusProxy *proxy) > +{ > + battery_proxies = g_list_append(battery_proxies, proxy); > +} > + > +static void battery_removed(GDBusProxy *proxy) > +{ > + battery_proxies = g_list_remove(battery_proxies, proxy); > +} > + > static void device_added(GDBusProxy *proxy) > { > DBusMessageIter iter; > @@ -539,6 +552,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) > gatt_add_manager(proxy); > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > ad_manager_added(proxy); > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > + battery_added(proxy); > } > } > > @@ -630,6 +645,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) > gatt_remove_manager(proxy); > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > ad_unregister(dbus_conn, NULL); > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > + battery_removed(proxy); > } > } > > @@ -763,6 +780,20 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) > return NULL; > } > > +static GDBusProxy *find_battery_by_path(GList *source, const char *path) > +{ > + GList *list; > + > + for (list = g_list_first(source); list; list = g_list_next(list)) { > + GDBusProxy *proxy = list->data; > + > + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) > + return proxy; > + } > + > + return NULL; > +} > + > static GDBusProxy *find_proxy_by_address(GList *source, const char *address) > { > GList *list; > @@ -1650,6 +1681,35 @@ static void cmd_info(int argc, char *argv[]) > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > } > > +static void cmd_battery(int argc, char *argv[]) > +{ > + DBusMessageIter iter; > + GDBusProxy *device_proxy; > + GDBusProxy *battery_proxy; > + unsigned char percentage; > + > + device_proxy = find_device(argc, argv); > + if (!device_proxy) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + battery_proxy = find_battery_by_path(battery_proxies, > + g_dbus_proxy_get_path(device_proxy)); > + if (!battery_proxy) { > + bt_shell_printf("Device %s does not have battery information\n", > + argv[1]); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (g_dbus_proxy_get_property(battery_proxy, "Percentage", &iter) == > + FALSE) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + dbus_message_iter_get_basic(&iter, &percentage); > + bt_shell_printf("Percentage: %d%%\n", percentage); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > static void pair_reply(DBusMessage *message, void *user_data) > { > DBusError error; > @@ -2785,6 +2845,8 @@ static const struct bt_shell_menu main_menu = { > dev_generator }, > { "disconnect", "[dev]", cmd_disconn, "Disconnect device", > dev_generator }, > + { "battery", "[dev]", cmd_battery, "Show device battery", > + dev_generator }, > { } }, > }; > > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aA0POgPO/F5urQAAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 19:55:15 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id cDCLOAPO/F6alAAA0J78UA (envelope-from ); Wed, 01 Jul 2020 19:55:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0A9F85296A; Wed, 1 Jul 2020 19:55:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732016AbgGARzJ (ORCPT + 1 other); Wed, 1 Jul 2020 13:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726693AbgGARzJ (ORCPT ); Wed, 1 Jul 2020 13:55:09 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B8A4C08C5C1 for ; Wed, 1 Jul 2020 10:55:08 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id e4so13223229oib.1 for ; Wed, 01 Jul 2020 10:55:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gyQF7N46rccRe51etLI7nVzODLmPrqWQyISOUMmMZXM=; b=aT13mzU+yVEAV+120HJCM5aNR0ikcpI2/fyyC400rmUauGIrTZJ9HEswLx2SQSzShl KvMmT/yuK3RqOJwLWDxOUm0pmdEjtGDtk0w3mBdxzLOTSgFAYmqrUpVVJHj8TKiu7eMS WH9kuiP/qYr8dUZoMOjofTKoSofoHGhsDSFvrUdrpCyA/zb5sDM4cxbBonti1gXjh6rc dEpGwcDarfXeVawfmXyeesnNFhbkDZrYc1n9NDe6xHKQgg4tCCnsBmErMEW5I+QG4w2v 9iVQAEErt/h5vnAcb8NaBmikjUZPq1bgikhCv9ltVM11aXCn/GssR6UnA1Bxe8BSRWj8 MyRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gyQF7N46rccRe51etLI7nVzODLmPrqWQyISOUMmMZXM=; b=hN72Krpb/rN4Vr7AK/2dbd0Dav3zCpCS1r97JKC1njssrn4KDDxbgO11A0nNkLwLqt HZL1yCiz+9TodJVm5vxqKGjMPp2PXfc35a5xt+qsmQ6I8vd3nFObyRAlvXQzfHhruqey Xqt6ONjq1akVUnj50353eZmvclhBL/QCrX/W+xZzZ8Q5ovmNdyxdR+pla61pj/yaxfKR gjz1B4U0jiaPIpyLy0O7JBzGQE/e8IQCUvJCZ2DhS2lU8LMvHctsqNUih709XueXEiZy cQVtV1iOKEVfJfhQZFbvbyH9fueW8OcX3sb/5FADIdH4IM0LhycrhilApNTE7iLIlW3s rW5Q== X-Gm-Message-State: AOAM531DT7n19VuyrM4il8oob9xBMigK8+/Ipwr4IOph7BbBCKyb0Bf3 aNHkqu2GdBPBsZx5mOtys39dCS6LlT2k6ZeeyeaxNFIY X-Google-Smtp-Source: ABdhPJx0Vlug3SMuuYns/x1sLLojNvX7NRS2ZYHdNDFcWRh4CElcYaraPMcBI38a1jHJPARMzW3vQkDO5HNtA2rnBK8= X-Received: by 2002:aca:2819:: with SMTP id 25mr14927355oix.48.1593626107393; Wed, 01 Jul 2020 10:55:07 -0700 (PDT) MIME-Version: 1.0 References: <20200701131328.3835273-1-alainm@chromium.org> In-Reply-To: <20200701131328.3835273-1-alainm@chromium.org> From: Luiz Augusto von Dentz Date: Wed, 1 Jul 2020 10:54:55 -0700 Message-ID: Subject: Re: [BlueZ PATCH v3] profiles/scanparam: use configured scanparams when available To: Alain Michaud Cc: "linux-bluetooth@vger.kernel.org" , Miao-Chen Chou , Abhishek Pandit-Subedi , Manish Mandlik Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0A9F85296A X-Rspamd-UID: 796b60 Content-Length: 2162 Hi Alain, On Wed, Jul 1, 2020 at 6:16 AM Alain Michaud wrote: > > This patch updates the scan parameter service to use the configured scan > parameters when available rather than the hardcoded kernel defaults. > > Reviewed-by: Miao-Chen Chou > Reviewed-by: Abhishek Pandit-Subedi > Reviewed-by: Manish Mandlik > > --- > > Changes in v3: > - Addin Chromium/Gerrit reviewers > > Changes in v2: > - Fixing checkpatch comment warning. > > profiles/scanparam/scan.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c > index 9e8f57747..d72be3dff 100644 > --- a/profiles/scanparam/scan.c > +++ b/profiles/scanparam/scan.c > @@ -45,12 +45,11 @@ > #include "src/shared/gatt-db.h" > #include "src/shared/gatt-client.h" > #include "attrib/att.h" > +#include "src/hcid.h" > > #define SCAN_INTERVAL_WIN_UUID 0x2A4F > #define SCAN_REFRESH_UUID 0x2A31 > > -#define SCAN_INTERVAL 0x0060 > -#define SCAN_WINDOW 0x0030 > #define SERVER_REQUIRES_REFRESH 0x00 > > struct scan { > @@ -75,8 +74,16 @@ static void write_scan_params(struct scan *scan) > { > uint8_t value[4]; > > - put_le16(SCAN_INTERVAL, &value[0]); > - put_le16(SCAN_WINDOW, &value[2]); > + /* Unless scan parameters are configured, use the known kernel default > + * parameters > + */ > + put_le16(main_opts.default_params.le_scan_interval_autoconnect ? > + main_opts.default_params.le_scan_interval_autoconnect : > + 0x60, &value[0]); > + > + put_le16(main_opts.default_params.le_scan_win_autoconnect ? > + main_opts.default_params.le_scan_win_autoconnect : > + 0x30, &value[2]); > > bt_gatt_client_write_without_response(scan->client, scan->iwhandle, > false, value, sizeof(value)); > -- > 2.27.0.212.ge8ba1cc988-goog > Applied, thanks. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UNPMI9ff/F5DAAEAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 21:11:19 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id +K0tItff/F4YiAAA0J78UA (envelope-from ); Wed, 01 Jul 2020 21:11:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 08C82A0110; Wed, 1 Jul 2020 21:11:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726129AbgGATLN (ORCPT + 1 other); Wed, 1 Jul 2020 15:11:13 -0400 Received: from mga12.intel.com ([192.55.52.136]:19098 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725875AbgGATLM (ORCPT ); Wed, 1 Jul 2020 15:11:12 -0400 IronPort-SDR: WtHhUZ+EN2X0FcQOXEjYJ9LYvF2vCGtNaBwPMwRH4naV18xG6Ko39QELPze0oqVuCvJQ74BU78 JQP+Ow5puSLQ== X-IronPort-AV: E=McAfee;i="6000,8403,9669"; a="126306171" X-IronPort-AV: E=Sophos;i="5.75,301,1589266800"; d="scan'208";a="126306171" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2020 12:11:12 -0700 IronPort-SDR: eWeAiSZldan/YiB5I5Gyra/H1fDId6G1WRr03f2r8QD8t0liBku8iR75IE+QJUcvSv1cI58WnV 6dDCXI4tk+UQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,301,1589266800"; d="scan'208";a="481704532" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga005.fm.intel.com with ESMTP; 01 Jul 2020 12:11:12 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 1 Jul 2020 12:11:12 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 1 Jul 2020 12:11:11 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.170) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 1 Jul 2020 12:11:11 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=inHVn6UAaj6/QMHdSRrMBRK86d0acN0eTKtrJpLg2O5J9w0CfSMDBf1TJ1QqAYURo9S+RqR7okf2svetWeJSdPTrDhlHJUxKIWiDz/niJ7LzIWAwMpT2GgtuKCEnSxIZvBiggxAkCKjNRkFzclKBoMutjT290/TJghnvu2OMM/8X5f1wOGXD6r/rurbp0GgegKSR44pWTiOFsfF3J0fCk+TLtwzUx3tnNP8wuK+K3tgBwl16Ck7RuhqtKS5WIhpRV8FEJ07j34fBZcAOBxQwCf83FKB4K0WUQJgAVb/JoyUUkjwAUWFSr3KBMgy9kj555c98Piq/BweAHjGOjQ5PpQ== 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-SenderADCheck; bh=QMf8uLMpbiE1cyTqp337bPMRLv9tOLAhviTBrEvlDMc=; b=QxYwwt9whu3ZXkJujtEyVtKc4W8wC5cLWDhlhXw8WJ8ZZ4p+xbje1kHUetiY71YFrvUC9rKK9R22HeHIEbuIMFs7vfW/wiqflchJsW1z7bKjg6HWuhHF94BjuOkwx7k7LN7mLwhiL0bqWXScEKm41lqZ4kiHdm/clg7YJ240dNADLzL8qxSbjG7v7LxrAgYTpWfcgniMfXgaAgEBa0sRoIrkDluhoYRKbgikwS5kOWOvK6L7SK23sLrus/5GWtYEQ4n0CApNZXNd3vwLCUgP+TTntJJAy8z1FFR4K4Kt6B4EbqJRylUerpYRxR+b3RQKSMVuCPS7MZSEgGf9tpJokw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QMf8uLMpbiE1cyTqp337bPMRLv9tOLAhviTBrEvlDMc=; b=C3tej9Q7Bs6ZNQlBuxqw4VQbGZFT7hCRWJN+rYBAos8bzTbmZEPDvMpXJM615P1IpMRRKb6gFDjhVCMVHh0LkYM9tzwTxGzejT1Wel6LFtyaHzFMBME5vLz3PfYI2a+jZgZSP6D095Bh4WBIcZ8+32DGaPANw1LDBVaYnZ6lonQ= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB0047.namprd11.prod.outlook.com (2603:10b6:301:68::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22; Wed, 1 Jul 2020 19:11:09 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::5b4:500e:f6a0:1ac0]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::5b4:500e:f6a0:1ac0%6]) with mapi id 15.20.3131.030; Wed, 1 Jul 2020 19:11:09 +0000 From: "Gix, Brian" To: "linux-bluetooth@vger.kernel.org" , "Stotland, Inga" CC: "michal.lowas-rzechonek@silvair.com" Subject: Re: [PATCH BlueZ v2 0/4] Add options to Models and VendorModels Thread-Topic: [PATCH BlueZ v2 0/4] Add options to Models and VendorModels Thread-Index: AQHWTxAwejpo6g0RsEuWp6Vedp/nLKjzGKCA Date: Wed, 1 Jul 2020 19:11:09 +0000 Message-ID: <7f9da664fa4c34b42d5174f937c06e4ed9902cfe.camel@intel.com> References: <20200630185617.14755-1-inga.stotland@intel.com> In-Reply-To: <20200630185617.14755-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.39] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5f608d76-764b-4a18-a067-08d81df2838e x-ms-traffictypediagnostic: MWHPR11MB0047: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 04519BA941 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ewU70pi3ZxtDW0V0rkQp7xJqihE1yNeYoanR0MJybDlsPY/rvbbWwR7M7Xe2Qml4JDRYDPffYMYxpJaJLDdLi7ZUQo9h9OK4b+JquAjIC0nDAWN8mw4rPrprC1XxnNhxvW9UR+9R/JYk19fdpZ4BLkZQvFwa5qgQO2cslla+P3mSHb7qAyh3CcJFicdagyaHEQpLWwtmrN0kSii2KUr5ivl+jyLut9lzvEc5xzpHnYHEEbPzQnWgLxHdtx2KS4zuZ1tKHGcRWHaMNJL16ajYOoV6omIWyO+YAewpjy2SyijCZ8v8Y8oHi8v20tjczb34Ji/qvbTT1MXiDtVe8ustlA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(376002)(136003)(39860400002)(366004)(346002)(36756003)(110136005)(6506007)(6512007)(8936002)(8676002)(316002)(6486002)(26005)(86362001)(5660300002)(83380400001)(2906002)(186003)(6636002)(66946007)(478600001)(4326008)(76116006)(71200400001)(91956017)(2616005)(66476007)(66556008)(66446008)(64756008);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: QQEq7sJyHeosgRqyXigcGeBHHTdffqy53FaUjGLsiFwRJuDHAhwAOvaOoAdEhtH3BfkreegqJ5cxAOlIBPx2/snHB6Zkw4x51fv5fRCa65OGHpNr/69fZlTMTZtC7NTmfBe1WDriUBItJ2ahRjBoEjt3E+ZSyYJFPx/bNlyL1qW1xnUDoiaaLhliJFVUEII2e8MUmEyICN2ZDZ3HBqpbLup3ncXx8qXIFYLRRkCYkR2BDbjnWVG5Rl9BfFpQtGIGT2P11eC4gBc4DB0y1MjbdxCodQssEIKVCT9e1g1o0kUoJglFekyXFvr+12aBBRnQAO3c/ilE6eQd4QFTx7W0DTIyxniH23aBzJp8oEZEts3iY9OCMsHNabhdbePUl1zFyIXeVi/davGLeOADWzGmZFv+PLp6aXAnlnazyYwDMGhbCBtSOVoDelvpWQPxw32TvvXaiaU6sH11/D/K1SVsqCGFb20MpXllaAGfxPCx7ic= Content-Type: text/plain; charset="utf-8" Content-ID: Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f608d76-764b-4a18-a067-08d81df2838e X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Jul 2020 19:11:09.9010 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: tSixO+/8FRuM5nqcErJ1ubM/j+vTzsySINnYgbaB4p21c1hBhePPxOjUZ7td02415RJf9sKKZ/17E6SIheSh2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB0047 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 7 X-Rspamd-Score: 1.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 08C82A0110 X-Rspamd-UID: f502dd UGF0Y2hzZXQgQXBwbGllZA0KT24gVHVlLCAyMDIwLTA2LTMwIGF0IDExOjU2IC0wNzAwLCBJbmdh IFN0b3RsYW5kIHdyb3RlOg0KPiB2MjoNCj4gDQo+IENoYW5nZXMgY29uc3RhbmVkIHRvIHBhdGNo IDAwMDI6DQo+IA0KPiAtIEZpeGVkIHJldHVybmVkIHN0YXR1cyBpbiBjb25maWcgcHViL3N1YiBt b2RlbCBjYWxscw0KPiAtIENvbnNpc3RlbnQgdXNlIG9mIHB1Yl9lbmFibGVkICYgc3ViX2VuYWJs ZWQgaW4gdGhlIGNvZGUNCj4gDQo+ICoqKioqKioqKioqKg0KPiBJZiBhIG1vZGVsIGRvZXMgbm90 IHN1cHBvcnQgZWl0aGVyIHN1YnNjcmlwdGlvbiBtZWNoYW5pc20sDQo+IENvbmZpZyBTZXJ2ZXIg aXMgc3VwcG9zZWQgdG8gcmV0dXJuICJOb3QgYSBTdWJzY3JpYmUgTW9kZWwiIGlmIGEgQ29uZmln IENsaWVudCBzZW5kcw0KPiBhIHN1YnNjcmlwdGlvbiBhZGQvb3ZlcndyaXRlIG1lc3NhZ2UuDQo+ IA0KPiBTaW1pbGFybHksIGlmIGEgbW9kZWwgZG9lcyBub3Qgc3VwcG9ydCBwdWJsaWNhdGlvbiwg IkludmFsaWQgUHVibGlzaCBQYXJhbWV0ZXJzIg0KPiBzaG91bGQgYmUgcmV0dXJuZWQgaW4gcmVz cG9uc2UgdG8gUHVibGljYXRpb24gU2V0IG1lc3NhZ2UuDQo+IA0KPiBTaW5jZSBjb25maWcgc2Vy dmVyIGlzIHJ1bm5pbmcgZXZlbiB3aGVuIGFuIGFwcCBpcyBub3QgYXR0YWNoZWQsIHRoZSBvbmx5 IHdheSB0byBjb2xsZWN0DQo+IHRoZXNlIG1vZGVsIGNhcGFiaWxpdGllcyBpcyBvbiBBdHRhY2gs IEpvaW4sIENyZWF0ZSwgSW1wb3J0IG1ldGhvZHMgd2hlbiB0aGUNCj4gb2JqZWN0IG1hbmFnZXIg Y29sbGVjdHMgYXBwIGluZm8uDQo+IA0KPiBUbyBhZGRyZXNzIHRoaXMgaXNzdWUsIHNpZ25hdHVy ZXMgZm9yIHByb3BlcnRpZXMgIk1vZGVscyIgYW5kICJWZW5kb3JNb2RlbHMiIG9uIEVsZW1lbnQN Cj4gaW50ZXJmYWNlIGNoYW5nZSB0byBpbmNsdWRlICJvcHRpb25zIiBkaWN0aW9uYXJ5Og0KPiAg ICAgTW9kZWxzOiBzaWduYXR1cmUgY2hhbmdlICJhcSIgLT4gImEocWF7c3Z9KSINCj4gICAgIFZl bmRvck1vZGVsczogc2lnbmF0dXJlIGNoYW5nZSAiYShxcSkiIC0+ICJhKHFxYXtzdn0pIg0KPiAg ICAgDQo+IFRoZSBkZWZpbmVkIGtleXdvcmRzIGZvciB0aGUgb3B0aW9ucyBkaWN0aW9uYXJ5IGFy ZToNCj4gICAgICJQdWJsaXNoIiAtIGluZGljYXRlcyB3aGV0aGVyIHRoZSBtb2RlbCBzdXBwb3J0 cyBwdWJsaWNhdGlvbiBtZWNoYW5pc20uDQo+ICAgICAgICAgICAgICAgICBJZiBub3QgcHJlc2Vu dCwgcHVibGljYXRpb24gaXMgZW5hYmxlZC4NCj4gICAgICJTdWJzY3JpYmUiIC0gaW5kaWNhdGVz IHdoZXRoZXIgdGhlIG1vZGVsIHN1cHBvcnRzIHN1YnNjcmlwdGlvbiBtZWNoYW5pc20uDQo+ICAg ICAgICAgICAgICAgICBJZiBub3QgcHJlc2VudCwgc3Vic2NyaXB0aW9ucyBhcmUgZW5hYmxlZC4N Cj4gDQo+IEluZ2EgU3RvdGxhbmQgKDQpOg0KPiAgIGRvYy9tZXNoLWFwaTogQWRkIGRpY3Rpb25h cnkgdG8gbW9kZWwgcHJvcGVydGllcw0KPiAgIG1lc2g6IENoZWNrIGFwcCBtb2RlbCBzZXR0aW5n cyBvZiBwdWIvc3ViIHN1cHBvcnQNCj4gICB0b29scy9tZXNoLWNmZ2NsaWVudDogQWRkIG9wdGlv bnMgdG8gIk1vZGVscyIgcHJvcGVydHkNCj4gICB0ZXN0L3Rlc3QtbWVzaDogQWRkIG9wdGlvbnMg dG8gIk1vZGVscyIgcHJvcGVydHkNCj4gDQo+ICBkb2MvbWVzaC1hcGkudHh0ICAgICAgICB8ICA0 MCArKysrKysrKy0tDQo+ICBtZXNoL21lc2gtY29uZmlnLWpzb24uYyB8ICA3NiArKysrKysrKysr KysrKysrKy0NCj4gIG1lc2gvbWVzaC1jb25maWcuaCAgICAgIHwgICA4ICsrDQo+ICBtZXNoL21v ZGVsLmMgICAgICAgICAgICB8ICA5OCArKysrKysrKysrKysrKysrKysrLS0tLQ0KPiAgbWVzaC9t b2RlbC5oICAgICAgICAgICAgfCAgIDYgKysNCj4gIG1lc2gvbm9kZS5jICAgICAgICAgICAgIHwg MTY4ICsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrLS0tLS0tLS0NCj4gIHRlc3QvdGVz dC1tZXNoICAgICAgICAgIHwgIDIxICsrLS0tDQo+ICB0b29scy9tZXNoLWNmZ2NsaWVudC5jICB8 ICAyNSArKysrLS0NCj4gIDggZmlsZXMgY2hhbmdlZCwgMzc0IGluc2VydGlvbnMoKyksIDY4IGRl bGV0aW9ucygtKQ0KPiANCg== Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mD7VDXzi/F5nOAEAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 21:22:36 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +B+fDHzi/F6WZQEAlp8NpQ (envelope-from ); Wed, 01 Jul 2020 21:22:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CE977529F0; Wed, 1 Jul 2020 21:22:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725927AbgGATWa (ORCPT + 1 other); Wed, 1 Jul 2020 15:22:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbgGATW3 (ORCPT ); Wed, 1 Jul 2020 15:22:29 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C520CC08C5C1 for ; Wed, 1 Jul 2020 12:22:29 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id y2so26274539ioy.3 for ; Wed, 01 Jul 2020 12:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=6TlhrelhU8fdJUNlU1isvDCohx4f+8EV5ngRMY2hFfw=; b=NQuG+PirxnU/5vrjbV6BgXfINOlX4vcGT30WLG/GuqaFuFg12VkWnFPXqMxkLo0yTT Km77VknOYqThXBKAADpUuHXkWa91hw+kmvD1/1bxkf1sEOaAzpM4pDYsBP77LVuwvWdM kDYTLR/Qs/RCDlNYDD1lzlyd0uZEphasb1G8U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6TlhrelhU8fdJUNlU1isvDCohx4f+8EV5ngRMY2hFfw=; b=ofJftQTpUGibPjIOAnq6O7YSoMhDiGoRspvT5J5ZxIFISqNBGenQyYayA4K1gV6hiN cPs9eniDNwybt36rd2gXcKjn5iHlkFkwZr8ay2nes2febfNttZKi1FKZKEMY2j2YzVpQ 55FUl4t+yGTSgE680dTu8TbZ3t2Y3LTQumBme8G19fqOiF92zLFjD6dNFN0F2PnuRf3K 27Ml+yQLCYzJmrpeDBpPaUjUeQubGwlsc2KNHUNoUQmmvr50dygKGhZDzc1+K4mPOAuj 7KtkCCbkKvVtDcBY4HGaGNa751e3s0ZDylj9HYaWu6o9i1q7Sxj62VZo6BT9rLgoZ/gm Q5Nw== X-Gm-Message-State: AOAM531jS/jMrXLuL5L8Gmafl+OguB2sLV3YtR3FaH3rD95sAzjORiNA jr97tyaQXA2KPOP4EQAraUWmtyoUS0ooVg== X-Google-Smtp-Source: ABdhPJwY+awYWBCzem7yJ/upDongUzw/WbCaxnXSADtjN1JAHkw4fw+Y4CQMW6Bw7qLSQcAil6bo8g== X-Received: by 2002:a6b:90c:: with SMTP id t12mr3862455ioi.152.1593631348754; Wed, 01 Jul 2020 12:22:28 -0700 (PDT) Received: from localhost.localdomain (c-73-231-41-185.hsd1.ca.comcast.net. [73.231.41.185]) by smtp.googlemail.com with ESMTPSA id d77sm3862513ill.67.2020.07.01.12.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 12:22:28 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka Subject: [PATCH v2] client: Add battery percentage to info command Date: Wed, 1 Jul 2020 12:22:02 -0700 Message-Id: <20200701192202.9508-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: CE977529F0 X-Rspamd-UID: 4fbd0c This adds the Battery Percentage to the info command based on org.bluez.Battery1 API. Example usage: [bluetooth]# info XX:XX:XX:XX:XX:XX Device XX:XX:XX:XX:XX:XX (random) Name: ... Alias: ... ... Modalias: ... Battery Percentage: 100% --- client/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/client/main.c b/client/main.c index 422da5593..4b787240e 100644 --- a/client/main.c +++ b/client/main.c @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; static GDBusProxy *default_dev; static GDBusProxy *default_attr; static GList *ctrl_list; +static GList *battery_proxies; static const char *agent_arguments[] = { "on", @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) bt_shell_set_prompt(PROMPT_OFF); g_list_free_full(ctrl_list, proxy_leak); + g_list_free_full(battery_proxies, proxy_leak); ctrl_list = NULL; + battery_proxies = NULL; default_ctrl = NULL; } @@ -445,6 +448,16 @@ done: g_free(desc); } +static void battery_added(GDBusProxy *proxy) +{ + battery_proxies = g_list_append(battery_proxies, proxy); +} + +static void battery_removed(GDBusProxy *proxy) +{ + battery_proxies = g_list_remove(battery_proxies, proxy); +} + static void device_added(GDBusProxy *proxy) { DBusMessageIter iter; @@ -539,6 +552,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) gatt_add_manager(proxy); } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { ad_manager_added(proxy); + } else if (!strcmp(interface, "org.bluez.Battery1")) { + battery_added(proxy); } } @@ -630,6 +645,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) gatt_remove_manager(proxy); } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { ad_unregister(dbus_conn, NULL); + } else if (!strcmp(interface, "org.bluez.Battery1")) { + battery_removed(proxy); } } @@ -763,6 +780,20 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) return NULL; } +static GDBusProxy *find_battery_by_path(GList *source, const char *path) +{ + GList *list; + + for (list = g_list_first(source); list; list = g_list_next(list)) { + GDBusProxy *proxy = list->data; + + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) + return proxy; + } + + return NULL; +} + static GDBusProxy *find_proxy_by_address(GList *source, const char *address) { GList *list; @@ -1606,8 +1637,10 @@ static struct GDBusProxy *find_device(int argc, char *argv[]) static void cmd_info(int argc, char *argv[]) { GDBusProxy *proxy; + GDBusProxy *battery_proxy; DBusMessageIter iter; const char *address; + unsigned char percentage; proxy = find_device(argc, argv); if (!proxy) @@ -1647,6 +1680,16 @@ static void cmd_info(int argc, char *argv[]) print_property(proxy, "AdvertisingFlags"); print_property(proxy, "AdvertisingData"); + battery_proxy = find_battery_by_path(battery_proxies, + g_dbus_proxy_get_path(proxy)); + if (battery_proxy && g_dbus_proxy_get_property( + battery_proxy, "Percentage", &iter)) { + dbus_message_iter_get_basic(&iter, &percentage); + bt_shell_printf("\tBattery Percentage: %d%%\n", percentage); + } else { + bt_shell_printf("\tNo battery information\n"); + } + return bt_shell_noninteractive_quit(EXIT_SUCCESS); } -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WCvXNnH7/F5e3QEAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 23:09:05 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IDTwM3H7/F4P3gEAlp8NpQ (envelope-from ); Wed, 01 Jul 2020 23:09:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 70F5B52CA6; Wed, 1 Jul 2020 23:09:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726865AbgGAVJA (ORCPT + 1 other); Wed, 1 Jul 2020 17:09:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725847AbgGAVI7 (ORCPT ); Wed, 1 Jul 2020 17:08:59 -0400 Received: from mail-ua1-x941.google.com (mail-ua1-x941.google.com [IPv6:2607:f8b0:4864:20::941]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ACBCC08C5C1 for ; Wed, 1 Jul 2020 14:08:59 -0700 (PDT) Received: by mail-ua1-x941.google.com with SMTP id b24so702790uak.2 for ; Wed, 01 Jul 2020 14:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ka+PnVHK/1B/CrRrAZfYxcFHrqbNySjfxP7d7NkszAU=; b=m4oeAeMQkY62Y9pJCbsP2LJM44KZ2NxAjS1RZqeUD+uY9llI00BqEAcix5XIm//OCA Jkj6we/QqJ7VgCfsjBN/PL+RtDETarYm+q4hoYwc6vJ7eAMM76MM0VmSQ3o7uQcC2ulM 503PhAYUeTyD/tn3+KWz/LaZyRGGxgk/LAJOE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ka+PnVHK/1B/CrRrAZfYxcFHrqbNySjfxP7d7NkszAU=; b=MoWT9Nwugxw8z9eOjkZv3n9Xz0gfX2Hg4V1rqTnsaj8OZNRTDOFh8DiUwsakaloYT3 RVQigmsNxMQwZwjrDA0SuJqn3cnpT4U5RNwvFx4sEhD7QjUiYOqmzvtbIl4oz6rLaMg5 k2h2FJ2u2JlZeEpNmwVqLC39tAad1i48EmtBMZ/AsxjrPlt1oHcmDpenKP+MlHPZsKpi u9Mo5P22hZ70fgDdQZeywdqVU/sBYAy6HcOvxIiNID0/T8zGaNZlv2+10VjK8JHQmG1C FhiQ2ZgJ63OYVe0C0tYQQCzCAehiKZ6CSqHKeFZwxRLtNlv/TO6j/2duVWGJ3uV0In0r oMhw== X-Gm-Message-State: AOAM531r2/Solh+Ef/2MQfjoETHk/lCFHqhTWVK5/fOFfxnrpdixJFJo cuaRm1OMCarbYonhoVVoXvEjjNHAudM= X-Google-Smtp-Source: ABdhPJxLN0QM6HGgzDG6i9b4Dza95ez5N+UiN44S1w4R8cUTgXi/wWXRu4ExuMHMaeQRH/F0Fl9bDQ== X-Received: by 2002:a9f:260b:: with SMTP id 11mr19897956uag.49.1593637738606; Wed, 01 Jul 2020 14:08:58 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id d200sm1148839vkd.16.2020.07.01.14.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 14:08:58 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud Subject: [PATCH v1] Bluetooth: le_simult_central_peripheral exp feature Date: Wed, 1 Jul 2020 21:08:55 +0000 Message-Id: <20200701210855.351671-1-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 70F5B52CA6 X-Rspamd-UID: 9ac1c2 This patch adds an le_simult_central_peripheral features which allows a clients to determine if the controller is able to support peripheral and central connections at the same time. Signed-off-by: Alain Michaud --- net/bluetooth/mgmt.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5e9b9728eeac..b34547d7a897 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3753,10 +3753,16 @@ static const u8 debug_uuid[16] = { }; #endif +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ +static const u8 le_simult_central_peripheral[16] = { + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, +}; + static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { - char buf[42]; + char buf[44]; struct mgmt_rp_read_exp_features_info *rp = (void *)buf; u16 idx = 0; @@ -3774,6 +3780,13 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, } #endif + if (hdev && test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && + (hdev->le_states[3] & 0x10)) { + memcpy(rp->features[idx].uuid, le_simult_central_peripheral, + sizeof(le_simult_central_peripheral)); + rp->features[idx].flags = cpu_to_le32(BIT(0)); + } + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wLLRAZX8/F5e3QEAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 23:13:57 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id uC+MO5T8/F4UpAEADc0bRg (envelope-from ); Wed, 01 Jul 2020 23:13:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7278F51A0B; Wed, 1 Jul 2020 23:13:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727050AbgGAVNo (ORCPT + 1 other); Wed, 1 Jul 2020 17:13:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbgGAVNn (ORCPT ); Wed, 1 Jul 2020 17:13:43 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 456A6C08C5DC for ; Wed, 1 Jul 2020 14:13:43 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id p22so27394417ybg.21 for ; Wed, 01 Jul 2020 14:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=1693jLPCRTZKv04e3tT1L2R/SD/azULEZvoSLa7Hf7o=; b=X4N13e+9sePnsNX3KaC3ifEpq8r8prYY7zHclzCR5upKpuH+zMAIp0a3v81FRPNLSQ G/oEf3GoGKzfnImMohbfzdfak484FP/LerO7QfZnV6oiJy5RkPeJ4JGyaWW4d/KoT+og xaCTxxyLWdrK4Iy5oj1E4JZQLNCwWwFK+QmJ/rHwp8YgFpakYgrdyJcDKvQ7Hhutimdk veAa42QeTkaDOUzn9UlIWlC4KV+uT51zeVpLjn2F2l8a/oToAXzSKFN4laYPXVsvB7KO IWeEQJElTFTPPbn1R8LGZw8Vc3cSYrMYEomRY+SMbjXzjp+LawK0qruJeF/TCA8JmuqR 92mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=1693jLPCRTZKv04e3tT1L2R/SD/azULEZvoSLa7Hf7o=; b=QCT73f/0KrJgDrlMp5u9VXvMagC7QxmMwFOaFCWtIgmA0zk7XGchTht6R6V8fUqm5k 2DHpTsVXBchec5/3ta1wwstSGH6En44fjXwk5tESballDH5wnAKszuzTAfRSXI0xitba XuJp9M6FeqfaEYPtyvhwO/fLTADOWkeGo7GO/u9zKpCo9UcBpZSKWt4NcFy2Hnf5goSb yKEfYGYyLXM/mROpPmRH78OTRTI+nRkpAQ2e//KFJnHXIFq6V1ff8XYs9n4KmUtZhzLn 6NuLH70oSbZfcCUjGUVwHfJWWS/iTVvMgaBAkSS/pVdTiAx1ilnTEYwugwUw01tmxHsD 4TEA== X-Gm-Message-State: AOAM530D9+UMCYA95XsA4QqXA5cMd1OCICrGNDurpqw/F285bc+/+tZY mTwuHJVdxA3C53SWDst7CribIOS2NRzy5e4Oi0YP X-Google-Smtp-Source: ABdhPJz8wsHLEwNJYlVtw6qZZkh7AGzr6LYq5q8mwTBXuA/WiMwNXf+RKMjvBio06uTM33Rt9QsVW8X11w5NfovFi+WJ X-Received: by 2002:a25:c7d3:: with SMTP id w202mr29331301ybe.84.1593638022312; Wed, 01 Jul 2020 14:13:42 -0700 (PDT) Date: Wed, 1 Jul 2020 14:13:36 -0700 Message-Id: <20200701211337.3027448-1-danielwinkler@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port" From: Daniel Winkler To: linux-serial@vger.kernel.org, linux-mediatek@lists.infradead.org, Serge Semin , Alexey Malahov Cc: BlueZ , chromeos-bluetooth-upstreaming , stable@vger.kernel.org, abhishekpandit@chromium.org, Daniel Winkler , Aaron Sierra , Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , Lukas Wunner , Vignesh Raghavendra , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7278F51A0B X-Rspamd-UID: 1300cd This change regresses the QCA6174A-3 bluetooth chip, preventing firmware from being properly loaded. Without this change, the chip works as intended. The device is the Kukui Chromebook using the Mediatek chipset and the 8250_mtk uart. Initial controller baudrate is 115200 and operating speed is 3000000. Our entire suite of bluetooth tests now fail on this platform due to an apparent failure to sync its firmware on initialization. The driver is in the cros tree at drivers/bluetooth/hci_qca.c and uses the serdev interface. Specifically, this is the QCA_ROME chipset. Daniel Winkler (1): Revert "serial: 8250: Fix max baud limit in generic 8250 port" drivers/tty/serial/8250/8250_port.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CHAwDKL8/F5e3QEAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 23:14:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 4P3gCaL8/F705AEAlp8NpQ (envelope-from ); Wed, 01 Jul 2020 23:14:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AA74752CB2; Wed, 1 Jul 2020 23:14:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727099AbgGAVNu (ORCPT + 1 other); Wed, 1 Jul 2020 17:13:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbgGAVNr (ORCPT ); Wed, 1 Jul 2020 17:13:47 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77F85C08C5C1 for ; Wed, 1 Jul 2020 14:13:47 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id j4so16938902qvt.20 for ; Wed, 01 Jul 2020 14:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=quzZPMbm7PpMHF0Uc8MBUiav44rFFBJoy1a7Ni+U048=; b=cAUGuF/bBZXzPwqEA2KmnUAiIBZh74Axkc9kR9B2TU+pfmr0Ih1xclQdRWGsusUH4P aQzareypjNzLHXiV125/yObqrFXl50tJFV/rUKCZRWbD/D/1d0v4lzxP6KOcZXlgjjmi sgNNbvNdLJJHNlKCd14hQXkgYAlLrBsKFbkHvUNF/F6nxwrpT8jdvRZYXVdR0PC1eAI+ 4S16qlMArXxPc8oAS/ZA1yBh3hZnNw3KUW8jxg5bA8R+t6SFI15vBdFvk1Iceo4cfGw7 X0DgYL+QU5n2iQQVkAwshCPeU4e8v2RIOl8RM6la4Auqki927z9rPEsuDYZvWCyThq2u QdDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=quzZPMbm7PpMHF0Uc8MBUiav44rFFBJoy1a7Ni+U048=; b=aAq3TZESypTK5XyF+GFGB5n7msJ5IiUFanQGVjcfuGv8pfIslZC9/yTIlQXhwmCOLH K/ArreVReVoBdsduJSbvmVnWbj1d5yfUadQSxqIQMY9mjojZ0ugk4kPKLQvfONhUojqE pUJvAT2FVtWYYwxTkBViiW6Y1Q+QEUOpbAwV45bG6LzCT7k0U3C2gh6njC1lqAJ7Vsif BvMwc26gs2xhwY5l9+97UHV9JKyAh0kt5yVHotbgUM+8/LgwKHaXaElO9Mggjr4YfXcT DaerO4ii5lUEV2okymhziiDrTaO5itCuRcDRd+szEBrmIWQ2KBPfjOZ6HohEcrzE2KmV w44A== X-Gm-Message-State: AOAM531bBjpeAAtIb82unCfuYAZv92pUUTHzzlWixevbQ9ELqu2a0hWw hyL0GiplQGfG8fgXC8ZfC8ljRN/4jMsEQ2dv734B X-Google-Smtp-Source: ABdhPJweymvrG4WnmmEfQGpTdGKKPJnK+/o6UKqXb9nuHShRn93/877F29RoxTj0lr9gwAW3khi4TR681cXl8z12ryNZ X-Received: by 2002:a05:6214:10e1:: with SMTP id q1mr25772358qvt.78.1593638026665; Wed, 01 Jul 2020 14:13:46 -0700 (PDT) Date: Wed, 1 Jul 2020 14:13:37 -0700 In-Reply-To: <20200701211337.3027448-1-danielwinkler@google.com> Message-Id: <20200701141329.v2.1.I2cc415fa5793b3e55acfd521ba8f0a71e79aa5f1@changeid> Mime-Version: 1.0 References: <20200701211337.3027448-1-danielwinkler@google.com> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH v2 1/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port" From: Daniel Winkler To: linux-serial@vger.kernel.org, linux-mediatek@lists.infradead.org, Serge Semin , Alexey Malahov Cc: BlueZ , chromeos-bluetooth-upstreaming , stable@vger.kernel.org, abhishekpandit@chromium.org, Daniel Winkler , Aaron Sierra , Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , Lukas Wunner , Vignesh Raghavendra , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: AA74752CB2 X-Rspamd-UID: 5e6151 This reverts commit 7b668c064ec33f3d687c3a413d05e355172e6c92. Fixes: 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 port") Cc: stable@vger.kernel.org Signed-off-by: Daniel Winkler --- drivers/tty/serial/8250/8250_port.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 1632f7d25acca..e057c65ac1580 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2618,8 +2618,6 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port, struct ktermios *termios, struct ktermios *old) { - unsigned int tolerance = port->uartclk / 100; - /* * Ask the core to calculate the divisor for us. * Allow 1% tolerance at the upper limit so uart clks marginally @@ -2628,7 +2626,7 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port, */ return uart_get_baud_rate(port, termios, old, port->uartclk / 16 / UART_DIV_MAX, - (port->uartclk + tolerance) / 16); + port->uartclk); } void -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eJYrAoAJ/V6WGAAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 00:09:04 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WHqCAIAJ/V7t6gEADc0bRg (envelope-from ); Thu, 02 Jul 2020 00:09:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6594FA2FB9; Thu, 2 Jul 2020 00:08:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726687AbgGAWI6 (ORCPT + 1 other); Wed, 1 Jul 2020 18:08:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbgGAWI5 (ORCPT ); Wed, 1 Jul 2020 18:08:57 -0400 Received: from mail-vs1-xe43.google.com (mail-vs1-xe43.google.com [IPv6:2607:f8b0:4864:20::e43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B05DAC08C5C1 for ; Wed, 1 Jul 2020 15:08:57 -0700 (PDT) Received: by mail-vs1-xe43.google.com with SMTP id u133so638735vsc.0 for ; Wed, 01 Jul 2020 15:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K9SoVgLaXTOuNBg/am0VwKPBGo7WwjBx/4VauGhgdfs=; b=obwcbVEWRj3UW5eiy1ypSu6BqSlU937IPIHoxW3XA9ESlcz8HvcQSPTXGuO369mmHx xUuFadHywnYVncOEbvFb1x4KKMvQLi7Te2vrRPKv+yLisudxiiSAlc/g9cioUVHpBGL5 r5NA4IGOYyjlAoDNXsWNpram/JRi8DT5Jdroc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K9SoVgLaXTOuNBg/am0VwKPBGo7WwjBx/4VauGhgdfs=; b=mjtfv7N14Prtk9fuCAa1O4qySXKMEBCI7FuxfCo6PbVqRRhFGz81rQtYa0VRS7/F26 ReuP/ZUYJaDh36vV/uYjO3MxxBXa3WGT5X6vDrRYrJ5ocpDq+IE8wKmr5Rv5830uGAXm mggGPZh+BdYj8XXYhRCYH2LZSZRpU0Gc92a4YF6mPXxDkIpLSZVguKj5cffa0fhCzJXJ B0Q3nSRC2gHJuU6StcfXGQ6Iirrd5O0V3myXjprpDA38cLHY/QpPxxmtvyCQdB4F0TAW Fni2M7f3dNdumyyhM7LxIg4TG19t4XeodzydBjCQYxu8cORo2JyMOoLmeBsZFs7Jqx8j tjpg== X-Gm-Message-State: AOAM532asJ/8XLLIUpe2kLlueXxEZfCCVfCfizKF9Y+gkNXHteTNHO4T BjlMR5cOhLNPZYOQRj5Ne02be5cUuiw= X-Google-Smtp-Source: ABdhPJzPFVgnIBDBIw+hIlNvpDcdeS3BnnjhNdV6hClAXd+GbnTdIsgBlNp6CroCBv3wahfYyMtDUA== X-Received: by 2002:a67:d519:: with SMTP id l25mr20403031vsj.176.1593641336533; Wed, 01 Jul 2020 15:08:56 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id s4sm976678vsc.11.2020.07.01.15.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 15:08:55 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud Subject: [PATCH v2] Bluetooth: le_supported_roles experimental feature Date: Wed, 1 Jul 2020 22:08:53 +0000 Message-Id: <20200701220853.421445-1-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 12 X-Rspamd-Score: 1.85 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6594FA2FB9 X-Rspamd-UID: dd550c This patch adds an le_supported_roles features which allows a clients to determine if the controller is able to support peripheral and central connections separately and at the same time. Signed-off-by: Alain Michaud --- Changes in v2: - Slight change of design based on offline feedback net/bluetooth/mgmt.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5e9b9728eeac..c13fcc21745f 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3753,10 +3753,36 @@ static const u8 debug_uuid[16] = { }; #endif +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ +static const u8 le_supported_roles[16] = { + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, +}; + +static u32 get_le_roles_flags(struct hci_dev *hdev) +{ + u32 flags = 0; + + /* Central connections supported */ + if (hdev->le_states[4] & 0x08) + flags |= BIT(0); + + /* Peripheral connections supported */ + if (hdev->le_states[4] & 0x40) + flags |= BIT(1); + + /* Simult central and peripheral connections supported */ + if (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && + (hdev->le_states[3] & 0x10)) + flags |= BIT(2); + + return flags; +} + static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { - char buf[42]; + char buf[44]; struct mgmt_rp_read_exp_features_info *rp = (void *)buf; u16 idx = 0; @@ -3774,6 +3800,14 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, } #endif + if (hdev) { + memcpy(rp->features[idx].uuid, le_supported_roles, + sizeof(le_supported_roles)); + + rp->features[idx].flags = cpu_to_le32(get_le_roles_flags(hdev)); + ++idx; + } + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aB3dMzZw/V7/3gEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 07:27:18 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 6BNyMjZw/V7RPwEA0J78UA (envelope-from ); Thu, 02 Jul 2020 07:27:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E089551A0B; Thu, 2 Jul 2020 07:27:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726010AbgGBF1M convert rfc822-to-8bit (ORCPT + 1 other); Thu, 2 Jul 2020 01:27:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:43216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbgGBF1L (ORCPT ); Thu, 2 Jul 2020 01:27:11 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 208409] New: segfault in bluetoothd on mouse pairing Date: Thu, 02 Jul 2020 05:27:10 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: david@aqwari.net X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version cf_kernel_version rep_platform op_sys cf_tree bug_status bug_severity priority component assigned_to reporter cf_regression attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.90 / 15.00 / 200.00 X-Rspamd-Queue-Id: E089551A0B X-Rspamd-UID: 18dcff https://bugzilla.kernel.org/show_bug.cgi?id=208409 Bug ID: 208409 Summary: segfault in bluetoothd on mouse pairing Product: Drivers Version: 2.5 Kernel Version: 5.4.49 Hardware: Intel OS: Linux Tree: Mainline Status: NEW Severity: normal Priority: P1 Component: Bluetooth Assignee: linux-bluetooth@vger.kernel.org Reporter: david@aqwari.net Regression: No Created attachment 290051 --> https://bugzilla.kernel.org/attachment.cgi?id=290051&action=edit output of bluetoothd -n -d I have a "3D connexion cadmouse pro wireless" that reliably causes bluetoothd to segfault whenever I try to pair it with my Dell XPS 13 (9350). Here is the stack trace: #0 g_io_channel_unix_get_fd (channel=0x0) at ../glib/giounix.c:656 #1 0x00005555555b68a3 in bt_io_get_type (io=, gerr=0x7fffffffc2a0) at btio/btio.c:105 #2 0x00005555555b88dc in bt_io_get (io=0x0, err=0x7fffffffc2a0, opt1=BT_IO_OPT_SOURCE) at btio/btio.c:1513 #3 0x00005555555a1e82 in report_map_read_cb (status=, pdu=, plen=, user_data=) at profiles/input/hog-lib.c:992 #4 0x00005555555b335c in read_blob_helper (status=0 '\000', rpdu=, rlen=13, user_data=0x5555556d3eb0) at attrib/gatt.c:804 #5 0x00005555555b44c6 in attrib_callback_result (opcode=, pdu=0x5555556d5c01, length=, user_data=0x5555556c6880) at attrib/gattrib.c:273 #6 0x000055555560b950 in handle_rsp (att=0x5555556c4200, opcode=, pdu=, pdu_len=) at src/shared/att.c:715 #7 0x000055555560baed in can_read_data (io=, user_data=0x5555556c4200) at src/shared/att.c:904 #8 0x0000555555615429 in watch_callback (channel=, cond=, user_data=) at src/shared/io-glib.c:170 #9 0x00007ffff7ef9c1e in g_main_dispatch (context=0x555555689d30) at ../glib/gmain.c:3179 #10 g_main_context_dispatch (context=context@entry=0x555555689d30) at ../glib/gmain.c:3844 #11 0x00007ffff7ef9fd0 in g_main_context_iterate (context=0x555555689d30, block=block@entry=1, dispatch=dispatch@entry=1, self=) at ../glib/gmain.c:3917 #12 0x00007ffff7efa2a3 in g_main_loop_run (loop=0x55555568aee0) at ../glib/gmain.c:4111 #13 0x00005555556159b1 in mainloop_run () at src/shared/mainloop-glib.c:79 #14 0x0000555555615db8 in mainloop_run_with_signal (func=, user_data=0x0) at src/shared/mainloop-notify.c:201 #15 0x00005555555ba6b5 in main (argc=, argv=) at src/main.c:729 I stepped through a core dump with gdb. The mouse is sending a BT_ATT_OP_READ_BLOB_RSP command. report_map_read_cb passes a NULL pointer to g_attrib_get_channel here: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/profiles/input/hog-lib.c?h=5.53&id=1524499483a3678951c0e3059b158836398c4e9b#n992 which is not checked before being dereferenced. btmon trace to follow... -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OPRrIcTM/V4gHwEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 14:02:12 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iMyzH8TM/V48qQEAlp8NpQ (envelope-from ); Thu, 02 Jul 2020 14:02:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0F6F4A207B; Thu, 2 Jul 2020 14:02:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728742AbgGBMCG (ORCPT + 1 other); Thu, 2 Jul 2020 08:02:06 -0400 Received: from mga14.intel.com ([192.55.52.115]:27652 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728697AbgGBMCG (ORCPT ); Thu, 2 Jul 2020 08:02:06 -0400 IronPort-SDR: TG4/sEYIa8m7xIk78sPgt0iAGN5zZBnq7BZcoqy5obJY+9FhCgljYP7rRPWxTK/HnvVItVrAIu XOyRW3IvM9Kg== X-IronPort-AV: E=McAfee;i="6000,8403,9669"; a="145947812" X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="145947812" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 05:02:06 -0700 IronPort-SDR: djcz1Eo83MXMCRmRyJRqmliIvD50mP7od4NQwsU9NZN8B9U3eHLZJlhYI8DKZPZ2R/zEOyJ1jL cgZ2KVIE8yAA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="304224689" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by fmsmga004.fm.intel.com with ESMTP; 02 Jul 2020 05:02:04 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Kiran K Subject: [PATCH 0/5] Refactor firmware download Date: Thu, 2 Jul 2020 17:33:10 +0530 Message-Id: <20200702120315.26768-1-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0F6F4A207B X-Rspamd-UID: c787bd Hi, This patchset series refactors firmware download sequence to accomodate new generation Intel controllers. Few functions have been split to enhance readability and reusability. Kiran K (5): Bluetooth: btintel: Make controller version read generic Bluetooth: btintel: Refactor firmware header download sequence Bluetooth: btintel: Refactor firmware payload download code Bluetooth: btintel: Define tlv structure for new generation Controllers Bluetooth: btintel: Parse controller information present in TLV format drivers/bluetooth/btintel.c | 223 ++++++++++++++++++++++++++++++---- drivers/bluetooth/btintel.h | 110 +++++++++++++++-- drivers/bluetooth/btusb.c | 73 +++++++---- drivers/bluetooth/hci_ag6xx.c | 12 +- drivers/bluetooth/hci_intel.c | 14 ++- 5 files changed, 369 insertions(+), 63 deletions(-) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6ErXMcnM/V4gHwEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 14:02:17 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mMo/MMnM/V62uAAADc0bRg (envelope-from ); Thu, 02 Jul 2020 14:02:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E9DC6A31B8; Thu, 2 Jul 2020 14:02:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728778AbgGBMCL (ORCPT + 1 other); Thu, 2 Jul 2020 08:02:11 -0400 Received: from mga14.intel.com ([192.55.52.115]:27652 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728668AbgGBMCK (ORCPT ); Thu, 2 Jul 2020 08:02:10 -0400 IronPort-SDR: jwmiNYVKGNJOSxLvoKwrqLmSn9Q0dRkRRDeJY7gznFtUwT3gCxsB8L6BYcTeR25/IkwbD8PYn4 5MxSm5ZQn8nQ== X-IronPort-AV: E=McAfee;i="6000,8403,9669"; a="145947815" X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="145947815" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 05:02:09 -0700 IronPort-SDR: vY+9SStY/8TEzuxV6rTvQX2LczjwzClowCcBA0sN4oFzvMMBhEvtgmnZKMxm3LuplaMLtvYA4x ODP9XmnLkpfw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="304224706" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by fmsmga004.fm.intel.com with ESMTP; 02 Jul 2020 05:02:06 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH 1/5] Bluetooth: btintel: Make controller version read generic Date: Thu, 2 Jul 2020 17:33:11 +0530 Message-Id: <20200702120315.26768-2-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200702120315.26768-1-kiran.k@intel.com> References: <20200702120315.26768-1-kiran.k@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: E9DC6A31B8 X-Rspamd-UID: c08ee8 Make controller read vesion function more generic to support different type of controllers. Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Chethan T N Reviewed-by: Sathish Narasimman Reviewed-by: Srivatsa Ravishankar --- drivers/bluetooth/btintel.c | 36 ++++++++++++++---- drivers/bluetooth/btintel.h | 15 ++++++-- drivers/bluetooth/btusb.c | 71 +++++++++++++++++++++++------------ drivers/bluetooth/hci_ag6xx.c | 12 +++++- drivers/bluetooth/hci_intel.c | 12 +++++- 5 files changed, 106 insertions(+), 40 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index 5fa5be3c5598..dea96c585ecb 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -204,9 +204,15 @@ void btintel_hw_error(struct hci_dev *hdev, u8 code) } EXPORT_SYMBOL_GPL(btintel_hw_error); -void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver) +void btintel_version_info(struct hci_dev *hdev, const struct btintel_version *version) { const char *variant; + const struct intel_version *ver; + + if (version->is_tlv_supported) + return; + + ver = &version->intel_version; switch (ver->fw_variant) { case 0x06: @@ -335,27 +341,41 @@ int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug) } EXPORT_SYMBOL_GPL(btintel_set_event_mask_mfg); -int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver) +int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version) { struct sk_buff *skb; + u8 *data, param, status, check_tlv; + + if (!version) + return -EINVAL; - skb = __hci_cmd_sync(hdev, 0xfc05, 0, NULL, HCI_CMD_TIMEOUT); + param = 0xFF; + + skb = __hci_cmd_sync(hdev, 0xfc05, 1, ¶m, HCI_CMD_TIMEOUT); if (IS_ERR(skb)) { bt_dev_err(hdev, "Reading Intel version information failed (%ld)", PTR_ERR(skb)); return PTR_ERR(skb); } - if (skb->len != sizeof(*ver)) { - bt_dev_err(hdev, "Intel version event size mismatch"); + data = skb->data; + status = *data; + if (status) { + bt_dev_err(hdev, "Intel Read Version command failed (%02x)", + status); kfree_skb(skb); - return -EILSEQ; + return -bt_to_errno(status); } - memcpy(ver, skb->data, sizeof(*ver)); + check_tlv = *(data + 1); + if (skb->len == sizeof(version->intel_version) && check_tlv == 0x37) { + memcpy(&version->intel_version, skb->data, sizeof(version->intel_version)); + version->is_tlv_supported = false; + } else { + version->is_tlv_supported = true; + } kfree_skb(skb); - return 0; } EXPORT_SYMBOL_GPL(btintel_read_version); diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 08e20606fb58..0865d2d4aca7 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -66,6 +66,13 @@ struct intel_debug_features { __u8 page1[16]; } __packed; +struct btintel_version { + bool is_tlv_supported; + union { + struct intel_version intel_version; /* legacy version */ + }; +} __packed; + #if IS_ENABLED(CONFIG_BT_INTEL) int btintel_check_bdaddr(struct hci_dev *hdev); @@ -76,13 +83,13 @@ int btintel_set_diag(struct hci_dev *hdev, bool enable); int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable); void btintel_hw_error(struct hci_dev *hdev, u8 code); -void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver); +void btintel_version_info(struct hci_dev *hdev, const struct btintel_version *version); int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen, const void *param); int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name); int btintel_set_event_mask(struct hci_dev *hdev, bool debug); int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug); -int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver); +int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version); struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read, u16 opcode_write); @@ -133,7 +140,7 @@ static inline void btintel_hw_error(struct hci_dev *hdev, u8 code) } static inline void btintel_version_info(struct hci_dev *hdev, - struct intel_version *ver) + struct btintel_version *version) { } @@ -160,7 +167,7 @@ static inline int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug) } static inline int btintel_read_version(struct hci_dev *hdev, - struct intel_version *ver) + struct btintel_version *version) { return -EOPNOTSUPP; } diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index faa863dd5d0a..d06c946f7810 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -1938,6 +1938,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) const u8 *fw_ptr; int disable_patch, err; struct intel_version ver; + struct btintel_version version; BT_DBG("%s", hdev->name); @@ -1963,10 +1964,16 @@ static int btusb_setup_intel(struct hci_dev *hdev) * The returned information are hardware variant and revision plus * firmware variant, revision and build number. */ - err = btintel_read_version(hdev, &ver); + err = btintel_read_version(hdev, &version); if (err) return err; + if (version.is_tlv_supported) { + bt_dev_err(hdev, "FW download in tlv format not supported"); + return -EOPNOTSUPP; + } + ver = version.intel_version; + bt_dev_info(hdev, "read Intel version: %02x%02x%02x%02x%02x%02x%02x%02x%02x", ver.hw_platform, ver.hw_variant, ver.hw_revision, ver.fw_variant, ver.fw_revision, ver.fw_build_num, @@ -2049,11 +2056,11 @@ static int btusb_setup_intel(struct hci_dev *hdev) /* Need build number for downloaded fw patches in * every power-on boot */ - err = btintel_read_version(hdev, &ver); - if (err) - return err; - bt_dev_info(hdev, "Intel BT fw patch 0x%02x completed & activated", - ver.fw_patch_num); + err = btintel_read_version(hdev, &version); + if (err) + return err; + bt_dev_info(hdev, "Intel BT fw patch 0x%02x completed & activated", + version.intel_version.fw_patch_num); goto complete; @@ -2251,11 +2258,18 @@ static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb) return -EILSEQ; } -static bool btusb_setup_intel_new_get_fw_name(struct intel_version *ver, - struct intel_boot_params *params, - char *fw_name, size_t len, - const char *suffix) +static bool btusb_setup_intel_new_get_fw_name(const struct btintel_version *version, + struct intel_boot_params *params, + char *fw_name, size_t len, + const char *suffix) { + const struct intel_version *ver; + + if (version->is_tlv_supported) + return false; + + ver = &version->intel_version; + switch (ver->hw_variant) { case 0x0b: /* SfP */ case 0x0c: /* WsP */ @@ -2281,18 +2295,21 @@ static bool btusb_setup_intel_new_get_fw_name(struct intel_version *ver, } static int btusb_intel_download_firmware(struct hci_dev *hdev, - struct intel_version *ver, + struct btintel_version *version, struct intel_boot_params *params) { const struct firmware *fw; u32 boot_param; char fwname[64]; int err; + const struct intel_version *ver; struct btusb_data *data = hci_get_drvdata(hdev); - if (!ver || !params) + if (!version || !params) return -EINVAL; + ver = &version->intel_version; + /* The hardware platform number has a fixed value of 0x37 and * for now only accept this single value. */ @@ -2322,8 +2339,6 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev, return -EINVAL; } - btintel_version_info(hdev, ver); - /* The firmware variant determines if the device is in bootloader * mode or is running operational firmware. The value 0x06 identifies * the bootloader and the value 0x23 identifies the operational @@ -2398,7 +2413,7 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev, * ibt---.sfi. * */ - err = btusb_setup_intel_new_get_fw_name(ver, params, fwname, + err = btusb_setup_intel_new_get_fw_name(version, params, fwname, sizeof(fwname), "sfi"); if (!err) { bt_dev_err(hdev, "Unsupported Intel firmware naming"); @@ -2483,6 +2498,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) unsigned long long duration; int err; struct intel_debug_features features; + struct btintel_version version; BT_DBG("%s", hdev->name); @@ -2494,21 +2510,28 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) calltime = ktime_get(); - /* Read the Intel version information to determine if the device - * is in bootloader mode or if it already has operational firmware - * loaded. + /* Read controller version information and support of tlv format */ - err = btintel_read_version(hdev, &ver); + err = btintel_read_version(hdev, &version); if (err) { - bt_dev_err(hdev, "Intel Read version failed (%d)", err); + bt_dev_err(hdev, "Intel Read version new failed (%d)", err); btintel_reset_to_bootloader(hdev); return err; } - err = btusb_intel_download_firmware(hdev, &ver, ¶ms); + if (version.is_tlv_supported) { + bt_dev_err(hdev, "Firmware download in tlv format is not supported"); + return -EOPNOTSUPP; + } + + btintel_version_info(hdev, &version); + + err = btusb_intel_download_firmware(hdev, &version, ¶ms); if (err) return err; + ver = version.intel_version; + /* controller is already having an operational firmware */ if (ver.fw_variant == 0x23) goto finish; @@ -2562,7 +2585,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) clear_bit(BTUSB_BOOTLOADER, &data->flags); - err = btusb_setup_intel_new_get_fw_name(&ver, ¶ms, ddcname, + err = btusb_setup_intel_new_get_fw_name(&version, ¶ms, ddcname, sizeof(ddcname), "ddc"); if (!err) { @@ -2586,11 +2609,11 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) btintel_set_debug_features(hdev, &features); /* Read the Intel version information after loading the FW */ - err = btintel_read_version(hdev, &ver); + err = btintel_read_version(hdev, &version); if (err) return err; - btintel_version_info(hdev, &ver); + btintel_version_info(hdev, &version); finish: /* All Intel controllers that support the Microsoft vendor diff --git a/drivers/bluetooth/hci_ag6xx.c b/drivers/bluetooth/hci_ag6xx.c index 1f55df93e4ce..6f6a1e061972 100644 --- a/drivers/bluetooth/hci_ag6xx.c +++ b/drivers/bluetooth/hci_ag6xx.c @@ -153,6 +153,7 @@ static int ag6xx_setup(struct hci_uart *hu) struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; struct intel_version ver; + struct btintel_version version; const struct firmware *fw; const u8 *fw_ptr; char fwname[64]; @@ -166,11 +167,18 @@ static int ag6xx_setup(struct hci_uart *hu) if (err) return err; - err = btintel_read_version(hdev, &ver); + err = btintel_read_version(hdev, &version); if (err) return err; - btintel_version_info(hdev, &ver); + if (version.is_tlv_supported) { + bt_dev_err(hdev, "Firmware download in tlv format over ag6xx is not supported"); + return -EOPNOTSUPP; + } + + btintel_version_info(hdev, &version); + + ver = version.intel_version; /* The hardware platform number has a fixed value of 0x37 and * for now only accept this single value. diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c index f1299da6eed8..f30cbc66d48f 100644 --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -532,6 +532,7 @@ static int intel_setup(struct hci_uart *hu) struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; struct intel_version ver; + struct btintel_version version; struct intel_boot_params params; struct list_head *p; const struct firmware *fw; @@ -584,10 +585,17 @@ static int intel_setup(struct hci_uart *hu) * is in bootloader mode or if it already has operational firmware * loaded. */ - err = btintel_read_version(hdev, &ver); + err = btintel_read_version(hdev, &version); if (err) return err; + if (version.is_tlv_supported) { + /* firmware download in tlv format is not supported on UART transport */ + bt_dev_err(hdev, "Firmware download in tlv format is not supported"); + return -EOPNOTSUPP; + } + ver = version.intel_version; + /* The hardware platform number has a fixed value of 0x37 and * for now only accept this single value. */ @@ -614,7 +622,7 @@ static int intel_setup(struct hci_uart *hu) return -EINVAL; } - btintel_version_info(hdev, &ver); + btintel_version_info(hdev, &version); /* The firmware variant determines if the device is in bootloader * mode or is running operational firmware. The value 0x06 identifies -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mBhFLd/M/V4gHwEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 14:02:39 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id eHixK9/M/V6uuAAADc0bRg (envelope-from ); Thu, 02 Jul 2020 14:02:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 151B5A3059; Thu, 2 Jul 2020 14:02:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728807AbgGBMCM (ORCPT + 1 other); Thu, 2 Jul 2020 08:02:12 -0400 Received: from mga14.intel.com ([192.55.52.115]:27652 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728668AbgGBMCL (ORCPT ); Thu, 2 Jul 2020 08:02:11 -0400 IronPort-SDR: XGl3C8HuIy2Jk/PMhqYYGOf9VnzyYKu0pnj5uYUSTOeQs9Pg/vZGBmQiZNVAMm3QOKMuMVISQJ 2gcmdH3KhKlA== X-IronPort-AV: E=McAfee;i="6000,8403,9669"; a="145947827" X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="145947827" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 05:02:11 -0700 IronPort-SDR: W2BRSz48UqmPOn4XB85Y3nspYydEHmB0wdj0zs+Sd36QKGQzKovQd6ASbqbvoeQBGSTcyeaih2 0703lwsYyUlQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="304224715" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by fmsmga004.fm.intel.com with ESMTP; 02 Jul 2020 05:02:09 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH 2/5] Bluetooth: btintel: Refactor firmware header download sequence Date: Thu, 2 Jul 2020 17:33:12 +0530 Message-Id: <20200702120315.26768-3-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200702120315.26768-1-kiran.k@intel.com> References: <20200702120315.26768-1-kiran.k@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: 151B5A3059 X-Rspamd-UID: 71a966 Move firmware header download code to a separate function to enhance readability and reusability Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Chethan T N Reviewed-by: Sathish Narasimman Reviewed-by: Srivatsa Ravishankar --- drivers/bluetooth/btintel.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index dea96c585ecb..1c820c187421 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -646,12 +646,10 @@ int btintel_read_boot_params(struct hci_dev *hdev, } EXPORT_SYMBOL_GPL(btintel_read_boot_params); -int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, - u32 *boot_param) +static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev, + const struct firmware *fw) { int err; - const u8 *fw_ptr; - u32 frag_len; /* Start the firmware download transaction with the Init fragment * represented by the 128 bytes of CSS header. @@ -679,6 +677,21 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, bt_dev_err(hdev, "Failed to send firmware signature (%d)", err); goto done; } +done: + return err; +} + +int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, + u32 *boot_param) +{ + int err; + const u8 *fw_ptr; + u32 frag_len; + + err = btintel_sfi_rsa_header_secure_send(hdev, fw); + if (err) + goto done; + fw_ptr = fw->data + 644; frag_len = 0; -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ILO7IOXM/V4K9wEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 14:02:45 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IOHpHuXM/V7DqQEAlp8NpQ (envelope-from ); Thu, 02 Jul 2020 14:02:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CBEF7A2FB9; Thu, 2 Jul 2020 14:02:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728827AbgGBMCQ (ORCPT + 1 other); Thu, 2 Jul 2020 08:02:16 -0400 Received: from mga14.intel.com ([192.55.52.115]:27652 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728808AbgGBMCO (ORCPT ); Thu, 2 Jul 2020 08:02:14 -0400 IronPort-SDR: kH1COQjSUSRVcskqBe+NboQo63WDpALiWX9kgWIx8eS3H6E4o6Jcdk5ZKtMmQya7ZL5XYlMlum hYN/4ceB724g== X-IronPort-AV: E=McAfee;i="6000,8403,9669"; a="145947831" X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="145947831" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 05:02:14 -0700 IronPort-SDR: IuS5FJv9Xs18+7XPuq9aVg7WvtRi142tL8Y90l7j+mJsp443jK4jtTbhgBOLDpg3bWNcSKh2ue drvdkOQ9WbXA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="304224729" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by fmsmga004.fm.intel.com with ESMTP; 02 Jul 2020 05:02:11 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH 3/5] Bluetooth: btintel: Refactor firmware payload download code Date: Thu, 2 Jul 2020 17:33:13 +0530 Message-Id: <20200702120315.26768-4-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200702120315.26768-1-kiran.k@intel.com> References: <20200702120315.26768-1-kiran.k@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: CBEF7A2FB9 X-Rspamd-UID: a5e4cc Move firmware payload download code to a separate function to enhance readability and reusability Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Chethan T N Reviewed-by: Sathish Narasimman Reviewed-by: Srivatsa Ravishankar --- drivers/bluetooth/btintel.c | 29 ++++++++++++++++++++--------- drivers/bluetooth/btintel.h | 10 +++++----- drivers/bluetooth/btusb.c | 2 +- drivers/bluetooth/hci_intel.c | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index 1c820c187421..d0c6576212d7 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -19,6 +19,7 @@ #define VERSION "0.1" #define BDADDR_INTEL (&(bdaddr_t) {{0x00, 0x8b, 0x9e, 0x19, 0x03, 0x00}}) +#define RSA_HEADER_LEN 644 int btintel_check_bdaddr(struct hci_dev *hdev) { @@ -681,20 +682,17 @@ static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev, return err; } -int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, - u32 *boot_param) +static int btintel_download_firmware_payload(struct hci_dev *hdev, + const struct firmware *fw, + u32 *boot_param, size_t offset) { int err; const u8 *fw_ptr; u32 frag_len; - err = btintel_sfi_rsa_header_secure_send(hdev, fw); - if (err) - goto done; - - - fw_ptr = fw->data + 644; + fw_ptr = fw->data + offset; frag_len = 0; + err = -EINVAL; while (fw_ptr - fw->data < fw->size) { struct hci_command_hdr *cmd = (void *)(fw_ptr + frag_len); @@ -740,7 +738,20 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, done: return err; } -EXPORT_SYMBOL_GPL(btintel_download_firmware); + +int btintel_download_firmware_legacy(struct hci_dev *hdev, + const struct firmware *fw, + u32 *boot_param) +{ + int err; + + err = btintel_sfi_rsa_header_secure_send(hdev, fw); + if (err) + return err; + + return btintel_download_firmware_payload(hdev, fw, boot_param, RSA_HEADER_LEN); +} +EXPORT_SYMBOL_GPL(btintel_download_firmware_legacy); void btintel_reset_to_bootloader(struct hci_dev *hdev) { diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 0865d2d4aca7..e476105d495b 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -96,8 +96,8 @@ struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read, int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param); int btintel_read_boot_params(struct hci_dev *hdev, struct intel_boot_params *params); -int btintel_download_firmware(struct hci_dev *dev, const struct firmware *fw, - u32 *boot_param); +int btintel_download_firmware_legacy(struct hci_dev *dev, const struct firmware *fw, + u32 *boot_param); void btintel_reset_to_bootloader(struct hci_dev *hdev); int btintel_read_debug_features(struct hci_dev *hdev, struct intel_debug_features *features); @@ -191,9 +191,9 @@ static inline int btintel_read_boot_params(struct hci_dev *hdev, return -EOPNOTSUPP; } -static inline int btintel_download_firmware(struct hci_dev *dev, - const struct firmware *fw, - u32 *boot_param) +static inline int btintel_download_firmware_legacy(struct hci_dev *dev, + const struct firmware *fw, + u32 *boot_param) { return -EOPNOTSUPP; } diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index d06c946f7810..364da6d44ee3 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2438,7 +2438,7 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev, set_bit(BTUSB_DOWNLOADING, &data->flags); /* Start firmware downloading and get boot parameter */ - err = btintel_download_firmware(hdev, fw, &boot_param); + err = btintel_download_firmware_legacy(hdev, fw, &boot_param); if (err < 0) { /* When FW download fails, send Intel Reset to retry * FW download. diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c index f30cbc66d48f..14045a464309 100644 --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -755,7 +755,7 @@ static int intel_setup(struct hci_uart *hu) set_bit(STATE_DOWNLOADING, &intel->flags); /* Start firmware downloading and get boot parameter */ - err = btintel_download_firmware(hdev, fw, &boot_param); + err = btintel_download_firmware_legacy(hdev, fw, &boot_param); if (err < 0) goto done; -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +MszNenM/V4gHwEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 14:02:49 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MB0kNOnM/V4p8AEAgupzMw (envelope-from ); Thu, 02 Jul 2020 14:02:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 17AF9A3207; Thu, 2 Jul 2020 14:02:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728830AbgGBMCR (ORCPT + 1 other); Thu, 2 Jul 2020 08:02:17 -0400 Received: from mga14.intel.com ([192.55.52.115]:27652 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728808AbgGBMCR (ORCPT ); Thu, 2 Jul 2020 08:02:17 -0400 IronPort-SDR: akBWXgdARYuOAJ8SjTYgHaEqOU1KSaYXcjHuxSvgTuS+ADRAoTPu3KIsy2IuXpInGuxqIbfHNz Sesjq3pysSNA== X-IronPort-AV: E=McAfee;i="6000,8403,9669"; a="145947836" X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="145947836" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 05:02:16 -0700 IronPort-SDR: ZxOrpL5QWXxsFcqZEh1k6Gk+Qj+vOlj91ITW1vOExGaHLppWW0ziAMHMCs7js8+tjB4JgkVVFE U6XaCQomDDSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="304224741" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by fmsmga004.fm.intel.com with ESMTP; 02 Jul 2020 05:02:14 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH 4/5] Bluetooth: btintel: Define tlv structure for new generation Controllers Date: Thu, 2 Jul 2020 17:33:14 +0530 Message-Id: <20200702120315.26768-5-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200702120315.26768-1-kiran.k@intel.com> References: <20200702120315.26768-1-kiran.k@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: 17AF9A3207 X-Rspamd-UID: 496b33 Define structure used for reading controller information and to downloading firmware in tlv format used for new generation Intel controllers Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Chethan T N Reviewed-by: Sathish Narasimman Reviewed-by: Srivatsa Ravishankar --- drivers/bluetooth/btintel.h | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index e476105d495b..e37f84155c50 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -6,6 +6,90 @@ * Copyright (C) 2015 Intel Corporation */ +/* List of tlv type */ +enum { + INTEL_TLV_CNVI_TOP = 0x10, + INTEL_TLV_CNVR_TOP, + INTEL_TLV_CNVI_BT, + INTEL_TLV_CNVR_BT, + INTEL_TLV_CNVI_OTP, + INTEL_TLV_CNVR_OTP, + INTEL_TLV_DEV_REV_ID, + INTEL_TLV_USB_VENDOR_ID, + INTEL_TLV_USB_PRODUCT_ID, + INTEL_TLV_PCIE_VENDOR_ID, + INTEL_TLV_PCIE_DEVICE_ID, + INTEL_TLV_PCIE_SUBSYSTEM_ID, + INTEL_TLV_IMAGE_TYPE, + INTEL_TLV_TIME_STAMP, + INTEL_TLV_BUILD_TYPE, + INTEL_TLV_BUILD_NUM, + INTEL_TLV_FW_BUILD_PRODUCT, + INTEL_TLV_FW_BUILD_HW, + INTEL_TLV_FW_STEP, + INTEL_TLV_BT_SPEC, + INTEL_TLV_MFG_NAME, + INTEL_TLV_HCI_REV, + INTEL_TLV_LMP_SUBVER, + INTEL_TLV_OTP_PATCH_VER, + INTEL_TLV_SECURE_BOOT, + INTEL_TLV_KEY_FROM_HDR, + INTEL_TLV_OTP_LOCK, + INTEL_TLV_API_LOCK, + INTEL_TLV_DEBUG_LOCK, + INTEL_TLV_MIN_FW, + INTEL_TLV_LIMITED_CCE, + INTEL_TLV_SBE_TYPE, + INTEL_TLV_OTP_BDADDR, + INTEL_TLV_UNLOCKED_STATE +}; + +struct intel_tlv { + u8 type; + u8 len; + u8 val[0]; +} __packed; + +struct intel_version_tlv { + u8 status; + u32 cnvi_top; + u32 cnvr_top; + u32 cnvi_bt; + u32 cnvr_bt; + u16 cnvi_otp; + u16 cnvr_otp; + u16 dev_rev_id; + u16 usb_vid; + u16 usb_pid; + u16 pcie_vendor_id; + u16 pcie_dev_id; + u16 pcie_subsys_id; + u8 img_type; + u16 timestamp; + u8 build_type; + u32 build_num; + u8 fw_build_prod; + u8 fw_build_hw; + u8 fw_build_step; + u8 bt_spec_ver; + u16 mfg_name; + u16 hci_rev; + u16 lmp_sub_ver; + u8 otp_patch_ver; + u8 secure_boot; + u8 key_from_hdr; + u8 otp_lock; + u8 api_lock; + u8 debug_lock; + u8 min_fw_build_nn; + u8 min_fw_build_cw; + u8 min_fw_build_yy; + u8 limited_cce; + u8 sbe_type; + bdaddr_t otp_bd_addr; + u8 unlocked_state; +} __packed; + struct intel_version { u8 status; u8 hw_platform; @@ -70,6 +154,7 @@ struct btintel_version { bool is_tlv_supported; union { struct intel_version intel_version; /* legacy version */ + struct intel_version_tlv intel_version_tlv; }; } __packed; -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gILJKfXM/V61GwEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 14:03:01 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AA5bKPXM/V6engAADc0bRg (envelope-from ); Thu, 02 Jul 2020 14:03:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E02C1A313B; Thu, 2 Jul 2020 14:02:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728837AbgGBMCT (ORCPT + 1 other); Thu, 2 Jul 2020 08:02:19 -0400 Received: from mga14.intel.com ([192.55.52.115]:27652 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728808AbgGBMCT (ORCPT ); Thu, 2 Jul 2020 08:02:19 -0400 IronPort-SDR: 8Ooc2OLX4tBlKGKm4u+yx3NfekMt5g6icSV6bYE6YGIP6eQfJLT2jPi9T4OEEgFY2uXnmncjF3 YF8zwlWUVdWA== X-IronPort-AV: E=McAfee;i="6000,8403,9669"; a="145947837" X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="145947837" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 05:02:19 -0700 IronPort-SDR: q9tRtfvsuvhut+7YyuJVwOgcdkq40T4IUtjTHt8Zv7LuBGPXT61XrQ/nPbCWmYCORPN6nnLAb1 oub/PhJuv1vg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="304224756" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by fmsmga004.fm.intel.com with ESMTP; 02 Jul 2020 05:02:17 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH 5/5] Bluetooth: btintel: Parse controller information present in TLV format Date: Thu, 2 Jul 2020 17:33:15 +0530 Message-Id: <20200702120315.26768-6-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200702120315.26768-1-kiran.k@intel.com> References: <20200702120315.26768-1-kiran.k@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: E02C1A313B X-Rspamd-UID: 1c6172 New generation Intel controllers returns controller information in TLV format. Adding capability to parse and log it for debug purpose Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Chethan T N Reviewed-by: Sathish Narasimman Reviewed-by: Srivatsa Ravishankar --- drivers/bluetooth/btintel.c | 161 ++++++++++++++++++++++++++++++++---- drivers/bluetooth/btusb.c | 4 +- 2 files changed, 148 insertions(+), 17 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index d0c6576212d7..f0b087d97a83 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -209,27 +209,59 @@ void btintel_version_info(struct hci_dev *hdev, const struct btintel_version *ve { const char *variant; const struct intel_version *ver; + const struct intel_version_tlv *ver_tlv; - if (version->is_tlv_supported) - return; + if (!version->is_tlv_supported) { + ver = &version->intel_version; + + switch (ver->fw_variant) { + case 0x06: + variant = "Bootloader"; + break; + case 0x23: + variant = "Firmware"; + break; + default: + goto done; + } - ver = &version->intel_version; + bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u", + variant, ver->fw_revision >> 4, + ver->fw_revision & 0x0f, ver->fw_build_num, + ver->fw_build_ww, 2000 + ver->fw_build_yy); + goto done; + } + + ver_tlv = &version->intel_version_tlv; - switch (ver->fw_variant) { - case 0x06: + switch (ver_tlv->img_type) { + case 0x01: variant = "Bootloader"; - break; - case 0x23: + bt_dev_info(hdev, "Device revision is %u", ver_tlv->dev_rev_id); + bt_dev_info(hdev, "Secure boot is %s", + ver_tlv->secure_boot ? "enabled" : "disabled"); + bt_dev_info(hdev, "OTP lock is %s", + ver_tlv->otp_lock ? "enabled" : "disabled"); + bt_dev_info(hdev, "API lock is %s", + ver_tlv->api_lock ? "enabled" : "disabled"); + bt_dev_info(hdev, "Debug lock is %s", + ver_tlv->debug_lock ? "enabled" : "disabled"); + bt_dev_info(hdev, "Minimum firmware build %u week %u %u", + ver_tlv->min_fw_build_nn, ver_tlv->min_fw_build_cw, + 2000 + ver_tlv->min_fw_build_yy); + break; + case 0x03: variant = "Firmware"; - break; + break; default: - return; + goto done; } - bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u", - variant, ver->fw_revision >> 4, ver->fw_revision & 0x0f, - ver->fw_build_num, ver->fw_build_ww, - 2000 + ver->fw_build_yy); + bt_dev_info(hdev, "%s timestamp %u.%u buildtype %u build %u", variant, + 2000 + (ver_tlv->timestamp >> 8), ver_tlv->timestamp & 0xff, + ver_tlv->build_type, ver_tlv->build_num); +done: + return; } EXPORT_SYMBOL_GPL(btintel_version_info); @@ -346,6 +378,8 @@ int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version) { struct sk_buff *skb; u8 *data, param, status, check_tlv; + struct intel_version_tlv *ver_tlv; + struct intel_tlv *tlv; if (!version) return -EINVAL; @@ -373,9 +407,106 @@ int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version) if (skb->len == sizeof(version->intel_version) && check_tlv == 0x37) { memcpy(&version->intel_version, skb->data, sizeof(version->intel_version)); version->is_tlv_supported = false; - } else { - version->is_tlv_supported = true; + goto done; } + + bt_dev_info(hdev, "Supports tlv firmware download sequence"); + version->is_tlv_supported = true; + ver_tlv = &version->intel_version_tlv; + + /* Consume Command Complete Status field */ + skb_pull(skb, 1); + + /* Event parameters contatin multiple TLVs. Read each of them + * and only keep the required data. Also, it use existing legacy + * version field like hw_platform, hw_variant, and fw_variant + * to keep the existing setup flow + */ + while (skb->len) { + tlv = (struct intel_tlv *)skb->data; + switch (tlv->type) { + case INTEL_TLV_CNVI_TOP: + ver_tlv->cnvi_top = (tlv->val[3] << 24) | + (tlv->val[2] << 16) | + (tlv->val[1] << 8) | + (tlv->val[0]); + break; + case INTEL_TLV_CNVR_TOP: + ver_tlv->cnvr_top = (tlv->val[3] << 24) | + (tlv->val[2] << 16) | + (tlv->val[1] << 8) | + (tlv->val[0]); + break; + case INTEL_TLV_CNVI_BT: + ver_tlv->cnvi_bt = (tlv->val[3] << 24) | + (tlv->val[2] << 16) | + (tlv->val[1] << 8) | + (tlv->val[0]); + break; + case INTEL_TLV_CNVR_BT: + ver_tlv->cnvr_bt = (tlv->val[3] << 24) | + (tlv->val[2] << 16) | + (tlv->val[1] << 8) | + (tlv->val[0]); + break; + case INTEL_TLV_USB_VENDOR_ID: + ver_tlv->usb_vid = (tlv->val[1] << 8) | (tlv->val[0]); + break; + case INTEL_TLV_USB_PRODUCT_ID: + ver_tlv->usb_pid = (tlv->val[1] << 8) | (tlv->val[0]); + break; + case INTEL_TLV_IMAGE_TYPE: + ver_tlv->img_type = tlv->val[0]; + break; + case INTEL_TLV_TIME_STAMP: + ver_tlv->timestamp = (tlv->val[1] << 8) | (tlv->val[0]); + break; + case INTEL_TLV_BUILD_TYPE: + ver_tlv->build_type = tlv->val[0]; + break; + case INTEL_TLV_BUILD_NUM: + ver_tlv->build_num = (tlv->val[3] << 24) | + (tlv->val[2] << 16) | + (tlv->val[1] << 8) | + (tlv->val[0]); + break; + case INTEL_TLV_SECURE_BOOT: + ver_tlv->secure_boot = tlv->val[0]; + break; + case INTEL_TLV_KEY_FROM_HDR: + ver_tlv->key_from_hdr = tlv->val[0]; + break; + case INTEL_TLV_OTP_LOCK: + ver_tlv->otp_lock = tlv->val[0]; + break; + case INTEL_TLV_API_LOCK: + ver_tlv->api_lock = tlv->val[0]; + break; + case INTEL_TLV_DEBUG_LOCK: + ver_tlv->debug_lock = tlv->val[0]; + break; + case INTEL_TLV_MIN_FW: + ver_tlv->min_fw_build_nn = tlv->val[0]; + ver_tlv->min_fw_build_cw = tlv->val[1]; + ver_tlv->min_fw_build_yy = tlv->val[2]; + break; + case INTEL_TLV_LIMITED_CCE: + ver_tlv->limited_cce = tlv->val[0]; + break; + case INTEL_TLV_SBE_TYPE: + ver_tlv->sbe_type = tlv->val[0]; + break; + case INTEL_TLV_OTP_BDADDR: + memcpy(&ver_tlv->otp_bd_addr, tlv->val, tlv->len); + break; + default: + /* Ignore rest of information */ + break; + } + /* consume the current tlv and move to next*/ + skb_pull(skb, tlv->len + sizeof(*tlv)); + } +done: kfree_skb(skb); return 0; } diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 364da6d44ee3..f30b43e15a26 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2519,13 +2519,13 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) return err; } + btintel_version_info(hdev, &version); + if (version.is_tlv_supported) { bt_dev_err(hdev, "Firmware download in tlv format is not supported"); return -EOPNOTSUPP; } - btintel_version_info(hdev, &version); - err = btusb_intel_download_firmware(hdev, &version, ¶ms); if (err) return err; -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UD6oAG/g/V6xcQAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 15:26:07 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id EHfeOm7g/V66FgEA0J78UA (envelope-from ); Thu, 02 Jul 2020 15:26:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4C32C52851; Thu, 2 Jul 2020 15:26:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728851AbgGBNZ5 (ORCPT + 1 other); Thu, 2 Jul 2020 09:25:57 -0400 Received: from mga02.intel.com ([134.134.136.20]:44070 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729257AbgGBNZ4 (ORCPT ); Thu, 2 Jul 2020 09:25:56 -0400 IronPort-SDR: hX2QD1jNcMPx+Ez3JbKOFUDdZhFaYhA7iVRpF6SDLJ6xxZOdK375HJVK9t4qO5KXQE/2fpqt/l r6z25Fz4On6A== X-IronPort-AV: E=McAfee;i="6000,8403,9669"; a="135180168" X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="135180168" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 06:25:55 -0700 IronPort-SDR: o4Z7CBesEydbAQVIdPS5kijTD+yOzvFosrre8Isuj2jQVa0iAyttaUNxA/JVuV4VIPwKiV/aQm qPCQN/Rx+/cw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="265699912" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by fmsmga007.fm.intel.com with ESMTP; 02 Jul 2020 06:25:54 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 2 Jul 2020 06:25:54 -0700 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 2 Jul 2020 06:25:53 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 2 Jul 2020 06:25:53 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.108) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Jul 2020 06:25:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C+yXvT4pm716mcPp+NvOl2IWva5XTRFaTLACvISIDjx2qGuFweyxDgJyr3qSIZnlcapNOUPbRaqB8SrnLnhsJcH30q51asMhq1BsEpqvD88BkuOBMBhTpRDJ1pOW0EtHSnR42xmHnRMpxR6aJH1uof4g1PgNDAshNvGdPtnbJWpqqTaXCqNEhcugPgw6AYokOy/mdaK3QAmqv/s9ebx2cdJhoA7g1NcwyMrY9xKB4jqUfRBNvNmlcnuJ8J3nxm3ifyMJ86m2+hi1r5Ed67fle+rLNrBbXMTqmnPh6B7QZ8ysivMav2ZLwMQaYtI8/AryKzBYnaRRB8liDSo1UzpR8Q== 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-SenderADCheck; bh=m5/M6aGMgJh51Br7ePVw8oEdbj8G4S2JRwGtqPPAIcg=; b=eP69sEtk2yEPgxQ5w9WHrtxSCDrwOfzzmbr25fltXNuje0kWCn7942yutgFHW4pcGSdqICIuen+yd1M+6JX+gsAFBWDRE3xanC9P/CrQnyzzHAtN81wpptSp71msQ6IJgTdYr6ro7m3pbSGckCJ4dJm4NMoylDHYuES9ISIqAwMPSwnxCgoF7xoQDP5cm0Xe1QstV79vRACk/RCoTDUDzYlgee+1lyl7ybGNcPQCDHQ9DZiDBzAMm4yrbh1WNWYRAYo5oDpjM0tDRGmTkBjmBi3l22KU3Bxs0jHID4wPLOarfm9+w+5pl6Thnv+56NGql8lZyv4v2tLirsSkrdn08Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m5/M6aGMgJh51Br7ePVw8oEdbj8G4S2JRwGtqPPAIcg=; b=bFnEP9/69xpL9YfUhqfao2eCq0rTMOK5ElwFQQoXnGvCsP76lmRbSPUGUclLRf5hrryEWd5SGVnej4Op6BeMzpWv2PsO50T7SySMo3mAgPEpXLigVRwyDaJk30vfpZ8J3owbo2cqrTdMKfT7UWj91DcYnzI46/38vP8IRHSx4Os= Received: from BYAPR11MB3141.namprd11.prod.outlook.com (2603:10b6:a03:8d::13) by BY5PR11MB4372.namprd11.prod.outlook.com (2603:10b6:a03:1bb::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20; Thu, 2 Jul 2020 13:25:50 +0000 Received: from BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::9ce5:c8f4:581b:9d9f]) by BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::9ce5:c8f4:581b:9d9f%5]) with mapi id 15.20.3131.028; Thu, 2 Jul 2020 13:25:50 +0000 From: "K, Kiran" To: "linux-bluetooth@vger.kernel.org" CC: "Srivatsa, Ravishankar" , "kiraank@gmail.com" Subject: RE: [PATCH 0/4] Add support for new generation Intel controllers Thread-Topic: [PATCH 0/4] Add support for new generation Intel controllers Thread-Index: AQHWP+W9IdC9GwaE7UKfsfbct+pb7qj0Z8NA Date: Thu, 2 Jul 2020 13:25:50 +0000 Message-ID: References: <20200611114526.13594-1-kiran.k@intel.com> In-Reply-To: <20200611114526.13594-1-kiran.k@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.2.0.6 dlp-product: dlpe-windows authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.79.96] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5695206e-a214-4d23-6190-08d81e8b703d x-ms-traffictypediagnostic: BY5PR11MB4372: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4502; x-forefront-prvs: 0452022BE1 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9CZhUJ+tSQP8c9YlgLO2qGbF5qIgxNWWGFSsiLKSqbQYEyfDw4DoUY0oodfmt+j7sIxRW+N8aiLdcJMKyyOROvh1+FQDY499skIOLqR16fo0DLgnBF2Suv0j9GyY5/qVY8PJPmND+goT2DTlB6ML0luaO7byPTNev1y1346eKvI2B8wUmdrg8aftchfFW8j7L7iRGfD2FpdChyS9ltLfzTFYAuyRp73K7RJMqr0DEBkrrb984+O4sJahdJXgCDkKJl79VaYnzZi6+Vu3lHPvY+hDFirZ04cUsXK0P/+McelOoPbosjdryFwLy7GjqlPZ+UW7x26nd7Og8PDH5T5J0A== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3141.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(346002)(39860400002)(366004)(136003)(376002)(4326008)(478600001)(66556008)(66946007)(76116006)(8676002)(52536014)(2906002)(8936002)(66476007)(5660300002)(54906003)(71200400001)(6916009)(86362001)(316002)(186003)(4744005)(66446008)(64756008)(33656002)(83380400001)(6506007)(53546011)(55016002)(9686003)(26005)(7696005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: lFnor3wzWMUFh46fYrzj51Vx78YOfwopF3ZX95gJtXVb1297xFsWEO6vSqlnRQKAIvb5CIsOMctOUiFcVvebeb4/WGzWpWaO+TBuPiVfjsmTAqxmDEtUhkiiTNsAaqcI5SEYzO4i6fRGKuvTW7eyveBkjOjgzI6Bihs2npecSBSqIMG76E31w92ueQ/COiql5o7rBDOPxIzqNHf+RDWAWprcfow2hM0D0uwUlpdZBK965o18LPA91dqNDJ2bE7sILVpNrnou8JQQxW6rf8f2JAl1eSdTxAsCdmktfT+33JfF2VKMg1PlQ4D3W0fAb6UIvcZC3p8+BC9ZGHl6yKeGGvbzx7DpZTNkF9ZLBIv2cH9b8ZEfpfrijD9bfTbDW5IO3eLPIxyhtOAGuAwx4eNTq2MgEl+4trPZ/kopbJlmFyegdg03mrFkWBb1NIKLHI1M5fEFpRY8Nj2ZClObCDB6FF8sqq7+3ttN8loUTRmsikk= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3141.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5695206e-a214-4d23-6190-08d81e8b703d X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jul 2020 13:25:50.3644 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: cxUKQiPWpRB3b98ThB7/vO4M2JaqQSO4a6JlJII1bZ5Te+YwzqpkJoTScmkafSKUF1ESzf8wwczit0RCdx1rKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4372 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.90 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4C32C52851 X-Rspamd-UID: acfb00 Please ignore this patchset. I started uploading newer patches with smalle= r changes and more refactoring. > -----Original Message----- > From: K, Kiran > Sent: Thursday, June 11, 2020 5:15 PM > To: linux-bluetooth@vger.kernel.org > Cc: Srivatsa, Ravishankar ; > kiraank@gmail.com; K, Kiran > Subject: [PATCH 0/4] Add support for new generation Intel controllers >=20 > Hi All, > This patchset series defines a structure and few helper functions require= d to > enable new generation Intel controllers >=20 > Raghuram Hegde (4): > Bluetooth: btintel: Define tlv structure to enable firmware download > Bluetooth: btintel: Add helper functions to dump boot/firmware info > Bluetooth: btintel: Add helper functions to parse firmware name > Bluetooth: btintel: Add helper function to help controller type >=20 > drivers/bluetooth/btintel.c | 173 ++++++++++++++++++++++++++++++++++++ > drivers/bluetooth/btintel.h | 49 ++++++++++ > 2 files changed, 222 insertions(+) >=20 > -- > 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eMVsI63i/F5nOAEAvsO+Rg (envelope-from ) for ; Wed, 01 Jul 2020 21:23:25 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id GFJzIq3i/F6kZAEAlp8NpQ (envelope-from ); Wed, 01 Jul 2020 21:23:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 00C72A277B; Wed, 1 Jul 2020 21:23:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726324AbgGATXT (ORCPT + 1 other); Wed, 1 Jul 2020 15:23:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbgGATXT (ORCPT ); Wed, 1 Jul 2020 15:23:19 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76F23C08C5C1 for ; Wed, 1 Jul 2020 12:23:19 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id h1so110383otq.12 for ; Wed, 01 Jul 2020 12:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bShO5PDmct0f9bu7tk9Guh9swfNV4oTpxjld44HtZVk=; b=hOt4Huxeq1RPojKuUYowCT6t/vMi/vCpUXuxbJg9T2HT+qrFxln355/C8/HrYmg/gC YdQN5fnk2BjoIRW6UFyIZPHwAWtO7G6y5BfaRYAvj63VEIqjdu76dpWh1PYH+EByWnCw Lul703vYB9GOhPe1p8i6HlC4XGD3WVMeQPa1U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bShO5PDmct0f9bu7tk9Guh9swfNV4oTpxjld44HtZVk=; b=m8QwFHCektQxgcun68UoV9/GkxrhcTHoSI7+kPJ+fF4/+ieGtcEIxwXM0f1o6OCxq4 HpkmAJdW+qV1Z4Yd+eC1VmLoNAxHNu2oUuU6FtYitPC3Ijga5HEz4dA9//X91AeZPZXP Oo6ZhwqZ5GCWG6N3uJuI1NSeokoEQ7vXGVAZV6L0+SEucWtmdHIlQji8+n1Gd7+nqn/D /iP7O6mbFOSjUQzK5Os+ZTltIYRVpzAABw/HqL6faJhzAt9Ugc6NblrGcwNKMBYUYRZn jBgAO9gGQ4ONBqeS0rE2lO+n9/n3V4HvKbrnTfy6q3x9/X+7ijB8kTw2F0EudufOVlWG n3hg== X-Gm-Message-State: AOAM533I15LY8Hn7YBK2Oi4YJUaaj7j61lKuWhhX49LR/jaY05Ps8Qot KaIXnztOnunrYMnNrAQD4n/goAINZSIHAZbfncTO2wHV7IE= X-Google-Smtp-Source: ABdhPJxrQ2qx8nRisk5ESJV4eSS73BFcSe4ovFdmUayVyVTmXLFx6/J6A8V7WYNy7+X1iBx0gX5w4ZdQFvBxcNbfOfI= X-Received: by 2002:a9d:554d:: with SMTP id h13mr22544440oti.329.1593631398806; Wed, 01 Jul 2020 12:23:18 -0700 (PDT) MIME-Version: 1.0 References: <20200630184629.95013-1-sonnysasaka@chromium.org> In-Reply-To: From: Sonny Sasaka Date: Wed, 1 Jul 2020 12:23:06 -0700 Message-ID: Subject: Re: [PATCH v2] client: Add battery command To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: 00C72A277B X-Rspamd-UID: 4f3176 Hi Luiz, I thought of doing that (combining with info command). But we foresee that the Battery API will get more complex (such as support of multiple batteries like Pixel Buds and Airpods) and deserve its own command. Furthermore, it's a different API (org.bluez.Device1 vs org.bluez.Battery1) and its inner working uses a specific profile (BAS over GATT), so I think that it deserves its own command. But anyway I sent another patch that combines this into the "info" command and if you think this is more appropriate we can combine it for now and separate it in the future when needed. On Wed, Jul 1, 2020 at 10:56 AM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Tue, Jun 30, 2020 at 1:48 PM Sonny Sasaka wrote: > > > > This adds the "battery" command to show battery information of a peer > > device based on org.bluez.Battery1 API. Example usage: > > > > [bluetooth]# battery XX:XX:XX:XX:XX:XX > > Percentage: 100% > > It might be better to put the battery level under info command. > > > --- > > client/main.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 62 insertions(+) > > > > diff --git a/client/main.c b/client/main.c > > index 422da5593..8c1ed00fb 100644 > > --- a/client/main.c > > +++ b/client/main.c > > @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; > > static GDBusProxy *default_dev; > > static GDBusProxy *default_attr; > > static GList *ctrl_list; > > +static GList *battery_proxies; > > > > static const char *agent_arguments[] = { > > "on", > > @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) > > bt_shell_set_prompt(PROMPT_OFF); > > > > g_list_free_full(ctrl_list, proxy_leak); > > + g_list_free_full(battery_proxies, proxy_leak); > > ctrl_list = NULL; > > + battery_proxies = NULL; > > > > default_ctrl = NULL; > > } > > @@ -445,6 +448,16 @@ done: > > g_free(desc); > > } > > > > +static void battery_added(GDBusProxy *proxy) > > +{ > > + battery_proxies = g_list_append(battery_proxies, proxy); > > +} > > + > > +static void battery_removed(GDBusProxy *proxy) > > +{ > > + battery_proxies = g_list_remove(battery_proxies, proxy); > > +} > > + > > static void device_added(GDBusProxy *proxy) > > { > > DBusMessageIter iter; > > @@ -539,6 +552,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) > > gatt_add_manager(proxy); > > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > > ad_manager_added(proxy); > > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > > + battery_added(proxy); > > } > > } > > > > @@ -630,6 +645,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) > > gatt_remove_manager(proxy); > > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > > ad_unregister(dbus_conn, NULL); > > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > > + battery_removed(proxy); > > } > > } > > > > @@ -763,6 +780,20 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) > > return NULL; > > } > > > > +static GDBusProxy *find_battery_by_path(GList *source, const char *path) > > +{ > > + GList *list; > > + > > + for (list = g_list_first(source); list; list = g_list_next(list)) { > > + GDBusProxy *proxy = list->data; > > + > > + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) > > + return proxy; > > + } > > + > > + return NULL; > > +} > > + > > static GDBusProxy *find_proxy_by_address(GList *source, const char *address) > > { > > GList *list; > > @@ -1650,6 +1681,35 @@ static void cmd_info(int argc, char *argv[]) > > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > > } > > > > +static void cmd_battery(int argc, char *argv[]) > > +{ > > + DBusMessageIter iter; > > + GDBusProxy *device_proxy; > > + GDBusProxy *battery_proxy; > > + unsigned char percentage; > > + > > + device_proxy = find_device(argc, argv); > > + if (!device_proxy) > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > + > > + battery_proxy = find_battery_by_path(battery_proxies, > > + g_dbus_proxy_get_path(device_proxy)); > > + if (!battery_proxy) { > > + bt_shell_printf("Device %s does not have battery information\n", > > + argv[1]); > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > + } > > + > > + if (g_dbus_proxy_get_property(battery_proxy, "Percentage", &iter) == > > + FALSE) > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > + > > + dbus_message_iter_get_basic(&iter, &percentage); > > + bt_shell_printf("Percentage: %d%%\n", percentage); > > + > > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > > +} > > + > > static void pair_reply(DBusMessage *message, void *user_data) > > { > > DBusError error; > > @@ -2785,6 +2845,8 @@ static const struct bt_shell_menu main_menu = { > > dev_generator }, > > { "disconnect", "[dev]", cmd_disconn, "Disconnect device", > > dev_generator }, > > + { "battery", "[dev]", cmd_battery, "Show device battery", > > + dev_generator }, > > { } }, > > }; > > > > -- > > 2.26.2 > > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0PgDHy4Q/V5GNQAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 00:37:34 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ENyWHS4Q/V6CNwAAlp8NpQ (envelope-from ); Thu, 02 Jul 2020 00:37:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DF9ED52A9B; Thu, 2 Jul 2020 00:37:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726413AbgGAWhV (ORCPT + 1 other); Wed, 1 Jul 2020 18:37:21 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:49852 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726121AbgGAWhV (ORCPT ); Wed, 1 Jul 2020 18:37:21 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 1F473803202A; Wed, 1 Jul 2020 22:37:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DHd7Fb6uuWwY; Thu, 2 Jul 2020 01:37:16 +0300 (MSK) Date: Thu, 2 Jul 2020 01:37:13 +0300 From: Serge Semin To: Daniel Winkler CC: Serge Semin , , , Alexey Malahov , BlueZ , chromeos-bluetooth-upstreaming , , , Aaron Sierra , Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , Lukas Wunner , Vignesh Raghavendra , Subject: Re: [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port" Message-ID: <20200701223713.gavale4aramu3xnb@mobilestation> References: <20200701211337.3027448-1-danielwinkler@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200701211337.3027448-1-danielwinkler@google.com> X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 3 X-Rspamd-Score: 0.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: DF9ED52A9B X-Rspamd-UID: d02363 On Wed, Jul 01, 2020 at 02:13:36PM -0700, Daniel Winkler wrote: > > This change regresses the QCA6174A-3 bluetooth chip, preventing > firmware from being properly loaded. Without this change, the > chip works as intended. > > The device is the Kukui Chromebook using the Mediatek chipset > and the 8250_mtk uart. Initial controller baudrate is 115200 > and operating speed is 3000000. Our entire suite of bluetooth > tests now fail on this platform due to an apparent failure to > sync its firmware on initialization. Ok. It's mediatek 8250 driver, which is responsible for the failure. Then we'll have two options: 1) Add a new capability like UART_CAP_NO16DIV and take it into account in the serial8250_get_baud_rate() method. I don't have a documentation for the Mediatek UART port, but it seems to me that that controller calculates the baud rate differently from the standard 8250 port. A standard 8250 port does that by the next formulae: baud = uartclk / (16 * divisor). While it seems to me that the Mediatek port uses the formulae like: baud = uartclk / divisor. (Please, correct me if I'm wrong) If so, then we could introduce a new capability like UART_CAP_NO16DIV. The 8250_mtk driver will add it to the 8250-port capabilities field. The serial8250_get_baud_rate() method should be altered in a way so one would check whether the UART_CAP_NO16DIV flag is set and if it is then the uart_get_baud_rate() function will be called without uartclk normalized by the factor of 16. 2) Manually call serial8250_do_set_divisor() in the custom set_termios() callback. Just add the uart_update_timeout() and serial8250_do_set_divisor() methods invocation into the mtk8250_set_termios() function, which the original commit 81bb549fdf14 ("serial: 8250_mtk: support big baud rate") author should have done in the first place. -Sergey > > The driver is in the cros tree at drivers/bluetooth/hci_qca.c > and uses the serdev interface. Specifically, this is the > QCA_ROME chipset. > > > Daniel Winkler (1): > Revert "serial: 8250: Fix max baud limit in generic 8250 port" > > drivers/tty/serial/8250/8250_port.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > -- > 2.27.0.212.ge8ba1cc988-goog > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SMhxCpUt/V5XFAEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 02:43:01 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 0KOwCJUt/V55WgAADc0bRg (envelope-from ); Thu, 02 Jul 2020 02:43:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 75E5F52747; Thu, 2 Jul 2020 02:42:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726985AbgGBAmy (ORCPT + 1 other); Wed, 1 Jul 2020 20:42:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726388AbgGBAmy (ORCPT ); Wed, 1 Jul 2020 20:42:54 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B0E5C08C5C1 for ; Wed, 1 Jul 2020 17:42:54 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id c25so5256329otf.7 for ; Wed, 01 Jul 2020 17:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=a78PilIjJ284t3pjU0eKTgB65feaSV48np4OSgKY6xQ=; b=Hh5EWPj0LcBmFJmCjl4R/KO9FvzAdSlJigL+UzHXmfQ40A22zNxq+ZvvCcIVp6vcUT 9ehUbWjyJw9Wq72ZhWBOu74mksmAiaYffY7rPXIffNGLL1DVZhHCtGrHB6XXAHg+vJMm zJU/Et4Qu9C4pkAP0ioi1lGtl3k+sS/zb5utcYMgBN0LVh8BUrmr3lzHVEpXGJYqKC4S QqPNJGcff72/z9+3/rfI7il7au7fKGAYiX7Uft/8fMwdUmIDHhdGJ426eNfZpwq4kAJb GF7mRsMY3MlbI5Hl55bhezesggrOIPPaL4/ak4Osrj90ufIx0SLWh3Rjc0tOfNhMTics p5kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=a78PilIjJ284t3pjU0eKTgB65feaSV48np4OSgKY6xQ=; b=R7hVlGxINcXivhH3xHYzOn1ka7l5nQylusbR+i3bdkQGH/NgM8ve5YEGT6QzKfv6tu ahm4P2Dibb9ZZqiyaJ1ODpdCiEysI6BR4QhKDXl/CJfZqNoLYnzZHCMEFSXzJpFbRtEZ gQZ7uyxusMAy4HtjBnqjUQqs9bhp00nnUOD0msGnfgvd+K/nj25BsjZQe32I6WH6lSDz GV59CI3ezfrHWjOdSllJgVMq5rogd8gXwHX5Jn2evIp4ibUv7wCtXaoBQAiruNqy8l5d UJ4wiw7TeaIkxmOTn3R+lGI48uBEohfL6MEPAaj0A+fff/Jw7/qmQOU1zfg8r5Wxndl+ I9jw== X-Gm-Message-State: AOAM5337OEs9FcT/O1eJ1K/yznB/MqpKpi0FRuDrWEC4dKUuGCZN1hlY okjOGzGUlE9c316MuSHFsL6zzZWI0OBR7U8cBxE= X-Google-Smtp-Source: ABdhPJzjyBRTgQ8nbUBWwFeJrv3lKvRaWsfXsyu2CUJC3/c04ehON9e4cwDlv6gqpTjMK9FDLz1cI1NSsLpFAPx7m84= X-Received: by 2002:a9d:3da5:: with SMTP id l34mr24201819otc.88.1593650573420; Wed, 01 Jul 2020 17:42:53 -0700 (PDT) MIME-Version: 1.0 References: <20200630184629.95013-1-sonnysasaka@chromium.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Wed, 1 Jul 2020 17:42:41 -0700 Message-ID: Subject: Re: [PATCH v2] client: Add battery command To: Sonny Sasaka Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.12 / 15.00 / 200.00 X-Rspamd-Queue-Id: 75E5F52747 X-Rspamd-UID: 0368de Hi Sonny, On Wed, Jul 1, 2020 at 12:23 PM Sonny Sasaka wrote: > > Hi Luiz, > > I thought of doing that (combining with info command). But we foresee > that the Battery API will get more complex (such as support of > multiple batteries like Pixel Buds and Airpods) and deserve its own > command. Furthermore, it's a different API (org.bluez.Device1 vs > org.bluez.Battery1) and its inner working uses a specific profile (BAS > over GATT), so I think that it deserves its own command. But anyway I > sent another patch that combines this into the "info" command and if > you think this is more appropriate we can combine it for now and > separate it in the future when needed. It should be a problem to combine different interfaces, and if the Battery1 start to have more properties we just list them as well, our D-Bus client will have them cached anything since we do get the properties of all interface due to use of ObjectManager. > > On Wed, Jul 1, 2020 at 10:56 AM Luiz Augusto von Dentz > wrote: > > > > Hi Sonny, > > > > On Tue, Jun 30, 2020 at 1:48 PM Sonny Sasaka wrote: > > > > > > This adds the "battery" command to show battery information of a peer > > > device based on org.bluez.Battery1 API. Example usage: > > > > > > [bluetooth]# battery XX:XX:XX:XX:XX:XX > > > Percentage: 100% > > > > It might be better to put the battery level under info command. > > > > > --- > > > client/main.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ > > > 1 file changed, 62 insertions(+) > > > > > > diff --git a/client/main.c b/client/main.c > > > index 422da5593..8c1ed00fb 100644 > > > --- a/client/main.c > > > +++ b/client/main.c > > > @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; > > > static GDBusProxy *default_dev; > > > static GDBusProxy *default_attr; > > > static GList *ctrl_list; > > > +static GList *battery_proxies; > > > > > > static const char *agent_arguments[] = { > > > "on", > > > @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) > > > bt_shell_set_prompt(PROMPT_OFF); > > > > > > g_list_free_full(ctrl_list, proxy_leak); > > > + g_list_free_full(battery_proxies, proxy_leak); > > > ctrl_list = NULL; > > > + battery_proxies = NULL; > > > > > > default_ctrl = NULL; > > > } > > > @@ -445,6 +448,16 @@ done: > > > g_free(desc); > > > } > > > > > > +static void battery_added(GDBusProxy *proxy) > > > +{ > > > + battery_proxies = g_list_append(battery_proxies, proxy); > > > +} > > > + > > > +static void battery_removed(GDBusProxy *proxy) > > > +{ > > > + battery_proxies = g_list_remove(battery_proxies, proxy); > > > +} > > > + > > > static void device_added(GDBusProxy *proxy) > > > { > > > DBusMessageIter iter; > > > @@ -539,6 +552,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) > > > gatt_add_manager(proxy); > > > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > > > ad_manager_added(proxy); > > > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > > > + battery_added(proxy); > > > } > > > } > > > > > > @@ -630,6 +645,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) > > > gatt_remove_manager(proxy); > > > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > > > ad_unregister(dbus_conn, NULL); > > > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > > > + battery_removed(proxy); > > > } > > > } > > > > > > @@ -763,6 +780,20 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) > > > return NULL; > > > } > > > > > > +static GDBusProxy *find_battery_by_path(GList *source, const char *path) > > > +{ > > > + GList *list; > > > + > > > + for (list = g_list_first(source); list; list = g_list_next(list)) { > > > + GDBusProxy *proxy = list->data; > > > + > > > + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) > > > + return proxy; > > > + } > > > + > > > + return NULL; > > > +} > > > + > > > static GDBusProxy *find_proxy_by_address(GList *source, const char *address) > > > { > > > GList *list; > > > @@ -1650,6 +1681,35 @@ static void cmd_info(int argc, char *argv[]) > > > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > > > } > > > > > > +static void cmd_battery(int argc, char *argv[]) > > > +{ > > > + DBusMessageIter iter; > > > + GDBusProxy *device_proxy; > > > + GDBusProxy *battery_proxy; > > > + unsigned char percentage; > > > + > > > + device_proxy = find_device(argc, argv); > > > + if (!device_proxy) > > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > > + > > > + battery_proxy = find_battery_by_path(battery_proxies, > > > + g_dbus_proxy_get_path(device_proxy)); > > > + if (!battery_proxy) { > > > + bt_shell_printf("Device %s does not have battery information\n", > > > + argv[1]); > > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > > + } > > > + > > > + if (g_dbus_proxy_get_property(battery_proxy, "Percentage", &iter) == > > > + FALSE) > > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > > + > > > + dbus_message_iter_get_basic(&iter, &percentage); > > > + bt_shell_printf("Percentage: %d%%\n", percentage); > > > + > > > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > > > +} > > > + > > > static void pair_reply(DBusMessage *message, void *user_data) > > > { > > > DBusError error; > > > @@ -2785,6 +2845,8 @@ static const struct bt_shell_menu main_menu = { > > > dev_generator }, > > > { "disconnect", "[dev]", cmd_disconn, "Disconnect device", > > > dev_generator }, > > > + { "battery", "[dev]", cmd_battery, "Show device battery", > > > + dev_generator }, > > > { } }, > > > }; > > > > > > -- > > > 2.26.2 > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6BTDIZ1e/V7lwQEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 06:12:13 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 4GAIIJ1e/V5PEwAAlScrYA (envelope-from ); Thu, 02 Jul 2020 06:12:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 431BF51A0B; Thu, 2 Jul 2020 06:12:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726184AbgGBEL4 (ORCPT + 1 other); Thu, 2 Jul 2020 00:11:56 -0400 Received: from bmailout1.hostsharing.net ([83.223.95.100]:45731 "EHLO bmailout1.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbgGBEL4 (ORCPT ); Thu, 2 Jul 2020 00:11:56 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id 07030300011B9; Thu, 2 Jul 2020 06:11:53 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id BC3492ED3E2; Thu, 2 Jul 2020 06:11:52 +0200 (CEST) Date: Thu, 2 Jul 2020 06:11:52 +0200 From: Lukas Wunner To: Serge Semin Cc: Daniel Winkler , Serge Semin , linux-serial@vger.kernel.org, linux-mediatek@lists.infradead.org, Alexey Malahov , BlueZ , chromeos-bluetooth-upstreaming , stable@vger.kernel.org, abhishekpandit@chromium.org, Aaron Sierra , Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , Vignesh Raghavendra , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port" Message-ID: <20200702041152.e5csvbodojzwnagx@wunner.de> References: <20200701211337.3027448-1-danielwinkler@google.com> <20200701223713.gavale4aramu3xnb@mobilestation> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200701223713.gavale4aramu3xnb@mobilestation> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: 431BF51A0B X-Rspamd-UID: 423b54 On Thu, Jul 02, 2020 at 01:37:13AM +0300, Serge Semin wrote: > 1) Add a new capability like UART_CAP_NO16DIV and take it into account > in the serial8250_get_baud_rate() method. > > I don't have a documentation for the Mediatek UART port, but it seems to me > that that controller calculates the baud rate differently from the standard > 8250 port. A standard 8250 port does that by the next formulae: > baud = uartclk / (16 * divisor). > While it seems to me that the Mediatek port uses the formulae like: > baud = uartclk / divisor. (Please, correct me if I'm wrong) 8250_bcm2835aux.c seems to suffer from a similar issue and solves it like this in the ->probe hook: /* the HW-clock divider for bcm2835aux is 8, * but 8250 expects a divider of 16, * so we have to multiply the actual clock by 2 * to get identical baudrates. */ up.port.uartclk = clk_get_rate(data->clk) * 2; > 2) Manually call serial8250_do_set_divisor() in the custom set_termios() > callback. > > Just add the uart_update_timeout() and serial8250_do_set_divisor() methods > invocation into the mtk8250_set_termios() function, which the original commit > 81bb549fdf14 ("serial: 8250_mtk: support big baud rate") author should have > done in the first place. That sound preferable as adding new quirks into core code feels like a case of midlayer fallacy: https://blog.ffwll.ch/2016/12/midlayers-once-more-with-feeling.html Thanks, Lukas Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iG56OZFu/V6J7QEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 07:20:17 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SDRGOJFu/V6jVAAAgupzMw (envelope-from ); Thu, 02 Jul 2020 07:20:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8DCE352617; Thu, 2 Jul 2020 07:20:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726174AbgGBFUM (ORCPT + 1 other); Thu, 2 Jul 2020 01:20:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbgGBFUL (ORCPT ); Thu, 2 Jul 2020 01:20:11 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7B2AC08C5C1 for ; Wed, 1 Jul 2020 22:20:11 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id k15so23185638otp.8 for ; Wed, 01 Jul 2020 22:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+QuSF3vVBHGBgyyhE3tJdb3M+cAv1YvUDZ6m/v58lP8=; b=iMgSbogJ2VIELyvkevpGa1KBWZGHJr/i39GF9DUDy6BcUQIc8Kcv1y6mbHdW1x+YRh 0Qy0oDao55DwDsxuGGCkSMVOJvVMY5pxt2/hSGvxVLlHDm54n8eO+ufRUwYoNZPZ/uba +nDYn0ma6ciojnTq1mM0JaUuYg5f4U79Pw98gNIQ/5NBG7+H6WI9uHQufDbNj4i5opJ/ X5hnszT2wodgiG6b9zqVhiaoaA0W0vVM3vKB8XPnX59AF9nW3dWCCq04w36iRABYI7GY hVvnSj0vLn1mlxsAA63D3AxVJY21m1E7xeIB1NzgOzcBsfEezCBqJ133mKnUxwAWrhUz wn1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+QuSF3vVBHGBgyyhE3tJdb3M+cAv1YvUDZ6m/v58lP8=; b=rbe9/5PuHrm8/GzGsolk4xGgpm4W5DspIdBDhVlu6X7unR72kmz5/l2Z2dSERwuBKA aN/w8sbJYIcaSJyWNlYJGrzDi8suFho8VVtxvTrWP8wEMYPVoqvqn9qqdfdhbQpLc0uB 6lmgaQRBUTg2Gao4/zK/KxlNceDZ0GpAgAXkHPtEmFFuX8KsKP/BD/wmZ7vsu7gtVuZD l1fDdp3sApydST2LWeoM0S7J/GOg6yOLmuuXfUdysRkwKIyc0Y5Eh+N6bmCthzB9UAAp tpVUobIT77qsnVPIpUgNfXdUl55AXG6jJ+9qqSQ8nwy5AZBGBZjrHPIvZFHMQYyVwkri LA0w== X-Gm-Message-State: AOAM531C9O4PgnO//ZitsOUFNclCPZu2HRzCIdo/co551IR8oFBI9ytj pU89FUuRL0ZaBJ/LMPOxIKnnIKxL+QHqkYnhn68= X-Google-Smtp-Source: ABdhPJxdQiYxok6hDiKMNWxvwbeQ4fgJNtvPes/Mz5/Jp1ZPAeiqcOgg0qjjO/zvxLlAyqyVmGrLVjsQpuSY0JN5zSw= X-Received: by 2002:a9d:6c09:: with SMTP id f9mr8047001otq.362.1593667210999; Wed, 01 Jul 2020 22:20:10 -0700 (PDT) MIME-Version: 1.0 References: <20200701192202.9508-1-sonnysasaka@chromium.org> In-Reply-To: <20200701192202.9508-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz Date: Wed, 1 Jul 2020 22:19:55 -0700 Message-ID: Subject: Re: [PATCH v2] client: Add battery percentage to info command To: Sonny Sasaka Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.16 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8DCE352617 X-Rspamd-UID: cf26ff Hi Sonny, On Wed, Jul 1, 2020 at 12:24 PM Sonny Sasaka wrote: > > This adds the Battery Percentage to the info command based on > org.bluez.Battery1 API. Example usage: > > [bluetooth]# info XX:XX:XX:XX:XX:XX > Device XX:XX:XX:XX:XX:XX (random) > Name: ... > Alias: ... > ... > Modalias: ... > Battery Percentage: 100% > --- > client/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/client/main.c b/client/main.c > index 422da5593..4b787240e 100644 > --- a/client/main.c > +++ b/client/main.c > @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; > static GDBusProxy *default_dev; > static GDBusProxy *default_attr; > static GList *ctrl_list; > +static GList *battery_proxies; > > static const char *agent_arguments[] = { > "on", > @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) > bt_shell_set_prompt(PROMPT_OFF); > > g_list_free_full(ctrl_list, proxy_leak); > + g_list_free_full(battery_proxies, proxy_leak); > ctrl_list = NULL; > + battery_proxies = NULL; > > default_ctrl = NULL; > } > @@ -445,6 +448,16 @@ done: > g_free(desc); > } > > +static void battery_added(GDBusProxy *proxy) > +{ > + battery_proxies = g_list_append(battery_proxies, proxy); > +} > + > +static void battery_removed(GDBusProxy *proxy) > +{ > + battery_proxies = g_list_remove(battery_proxies, proxy); > +} > + > static void device_added(GDBusProxy *proxy) > { > DBusMessageIter iter; > @@ -539,6 +552,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) > gatt_add_manager(proxy); > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > ad_manager_added(proxy); > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > + battery_added(proxy); > } > } > > @@ -630,6 +645,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) > gatt_remove_manager(proxy); > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > ad_unregister(dbus_conn, NULL); > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > + battery_removed(proxy); > } > } > > @@ -763,6 +780,20 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) > return NULL; > } > > +static GDBusProxy *find_battery_by_path(GList *source, const char *path) > +{ > + GList *list; > + > + for (list = g_list_first(source); list; list = g_list_next(list)) { > + GDBusProxy *proxy = list->data; > + > + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) > + return proxy; > + } > + > + return NULL; > +} > + > static GDBusProxy *find_proxy_by_address(GList *source, const char *address) > { > GList *list; > @@ -1606,8 +1637,10 @@ static struct GDBusProxy *find_device(int argc, char *argv[]) > static void cmd_info(int argc, char *argv[]) > { > GDBusProxy *proxy; > + GDBusProxy *battery_proxy; > DBusMessageIter iter; > const char *address; > + unsigned char percentage; > > proxy = find_device(argc, argv); > if (!proxy) > @@ -1647,6 +1680,16 @@ static void cmd_info(int argc, char *argv[]) > print_property(proxy, "AdvertisingFlags"); > print_property(proxy, "AdvertisingData"); > > + battery_proxy = find_battery_by_path(battery_proxies, > + g_dbus_proxy_get_path(proxy)); I'd replace the lines below with just print_property(battery_proxy, "Percentage"); and just make print_property check for NULL proxy if it doesn't already. > + if (battery_proxy && g_dbus_proxy_get_property( > + battery_proxy, "Percentage", &iter)) { > + dbus_message_iter_get_basic(&iter, &percentage); > + bt_shell_printf("\tBattery Percentage: %d%%\n", percentage); > + } else { > + bt_shell_printf("\tNo battery information\n"); > + } > + > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > } > > -- > 2.17.1 > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aGmDMmR5/V7UOQAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 08:06:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id CA2hMGR5/V7jSQEADc0bRg (envelope-from ); Thu, 02 Jul 2020 08:06:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 48CACA1FE5; Thu, 2 Jul 2020 08:06:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726032AbgGBGGW (ORCPT + 1 other); Thu, 2 Jul 2020 02:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725263AbgGBGGW (ORCPT ); Thu, 2 Jul 2020 02:06:22 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCB43C08C5C1 for ; Wed, 1 Jul 2020 23:06:21 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id n24so21063417otr.13 for ; Wed, 01 Jul 2020 23:06:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+mwEzncHtl7pOSdCncnbrSkLJgrw1h8ZbowUpyYxQyU=; b=knmtaXyCeStDOZOY+cSU9c4eTdjEv6rUK0n8LjFpPnhKf+d2QYAXvxzR9X4MoJu5/M 7+j5CP/5Oui9XOQQLQrBA5nzdTSnE50HLjACOHpTxN6ZZEphG/u85vRlCFeEwJHAD5VH UyGvVPMoOdqnstl2sKGARLT4E6+quwois0wHY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+mwEzncHtl7pOSdCncnbrSkLJgrw1h8ZbowUpyYxQyU=; b=LlIZuUltLh+bKGt/53KCUffOsIxGVtPUQ16e7EQVgf56SZtZFAMpqRD+RC4WmrLfv3 LMEz4ccafDOL17LJ1UM826VD+QMEUsGrbgH1SudWJW5lRNLBadKWlI5UTWUFlU+JqPh8 hcA+M5y2zqSRC4F1UParr1OKJcdqMd3QSuWdarRbvHH5xyZkACRr3qGTrHU4A7o796nP mpyAFtM8u7W+Sotth4Yd2TClYTIVP5DnVnHGsOnSb0tqkxnDRraQY6AZJQK7kfWRcYzN FdZqL0CAwWPXSXQQ2EsI4Cgmb6VeF8Amy5Q63VvKawZH3NT5b2d26y1HnIdYycsvl9Z3 fPBw== X-Gm-Message-State: AOAM533L7ajM9V0eHpQVIW09rSKWYrZ/VfZ+Y+kQDE9zjmy8b23w/EBK LcCtioxnxM+IR2BdtEa0ALCqwl45i1wvaJDeyLZZqA== X-Google-Smtp-Source: ABdhPJxODmB244tZSlukhDP1Tybz95OqAYmdfrjDY6mWPRg4YvD23jdjaWNX4MnNvf/H8X89Dqji6Kx0Uj6I5qtVwXw= X-Received: by 2002:a9d:3648:: with SMTP id w66mr5130884otb.70.1593669981006; Wed, 01 Jul 2020 23:06:21 -0700 (PDT) MIME-Version: 1.0 References: <20200701192202.9508-1-sonnysasaka@chromium.org> In-Reply-To: From: Sonny Sasaka Date: Wed, 1 Jul 2020 23:06:09 -0700 Message-ID: Subject: Re: [PATCH v2] client: Add battery percentage to info command To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: 48CACA1FE5 X-Rspamd-UID: 4b84e4 Hi Luiz, On Wed, Jul 1, 2020 at 10:20 PM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Wed, Jul 1, 2020 at 12:24 PM Sonny Sasaka wrote: > > > > This adds the Battery Percentage to the info command based on > > org.bluez.Battery1 API. Example usage: > > > > [bluetooth]# info XX:XX:XX:XX:XX:XX > > Device XX:XX:XX:XX:XX:XX (random) > > Name: ... > > Alias: ... > > ... > > Modalias: ... > > Battery Percentage: 100% > > --- > > client/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 43 insertions(+) > > > > diff --git a/client/main.c b/client/main.c > > index 422da5593..4b787240e 100644 > > --- a/client/main.c > > +++ b/client/main.c > > @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; > > static GDBusProxy *default_dev; > > static GDBusProxy *default_attr; > > static GList *ctrl_list; > > +static GList *battery_proxies; > > > > static const char *agent_arguments[] = { > > "on", > > @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) > > bt_shell_set_prompt(PROMPT_OFF); > > > > g_list_free_full(ctrl_list, proxy_leak); > > + g_list_free_full(battery_proxies, proxy_leak); > > ctrl_list = NULL; > > + battery_proxies = NULL; > > > > default_ctrl = NULL; > > } > > @@ -445,6 +448,16 @@ done: > > g_free(desc); > > } > > > > +static void battery_added(GDBusProxy *proxy) > > +{ > > + battery_proxies = g_list_append(battery_proxies, proxy); > > +} > > + > > +static void battery_removed(GDBusProxy *proxy) > > +{ > > + battery_proxies = g_list_remove(battery_proxies, proxy); > > +} > > + > > static void device_added(GDBusProxy *proxy) > > { > > DBusMessageIter iter; > > @@ -539,6 +552,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) > > gatt_add_manager(proxy); > > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > > ad_manager_added(proxy); > > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > > + battery_added(proxy); > > } > > } > > > > @@ -630,6 +645,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) > > gatt_remove_manager(proxy); > > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > > ad_unregister(dbus_conn, NULL); > > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > > + battery_removed(proxy); > > } > > } > > > > @@ -763,6 +780,20 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) > > return NULL; > > } > > > > +static GDBusProxy *find_battery_by_path(GList *source, const char *path) > > +{ > > + GList *list; > > + > > + for (list = g_list_first(source); list; list = g_list_next(list)) { > > + GDBusProxy *proxy = list->data; > > + > > + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) > > + return proxy; > > + } > > + > > + return NULL; > > +} > > + > > static GDBusProxy *find_proxy_by_address(GList *source, const char *address) > > { > > GList *list; > > @@ -1606,8 +1637,10 @@ static struct GDBusProxy *find_device(int argc, char *argv[]) > > static void cmd_info(int argc, char *argv[]) > > { > > GDBusProxy *proxy; > > + GDBusProxy *battery_proxy; > > DBusMessageIter iter; > > const char *address; > > + unsigned char percentage; > > > > proxy = find_device(argc, argv); > > if (!proxy) > > @@ -1647,6 +1680,16 @@ static void cmd_info(int argc, char *argv[]) > > print_property(proxy, "AdvertisingFlags"); > > print_property(proxy, "AdvertisingData"); > > > > + battery_proxy = find_battery_by_path(battery_proxies, > > + g_dbus_proxy_get_path(proxy)); > > I'd replace the lines below with just print_property(battery_proxy, > "Percentage"); and just make print_property check for NULL proxy if it > doesn't already. I tried this but the result doesn't look quite good: Device XX:XX:XX:XX:XX:XX (random) Name: ... ... Modalias: ... Percentage: 0x64 The name "Percentage" is not clear (what kind of percentage does it mean) when shown in the "info" command. And also the format for byte data type is hex and there is no percent sign. I tried to modify the print_property function to support custom format but the code gets overly complex and I think it's more straightforward to use custom logic like in this patch. > > > + if (battery_proxy && g_dbus_proxy_get_property( > > + battery_proxy, "Percentage", &iter)) { > > + dbus_message_iter_get_basic(&iter, &percentage); > > + bt_shell_printf("\tBattery Percentage: %d%%\n", percentage); > > + } else { > > + bt_shell_printf("\tNo battery information\n"); > > + } > > + > > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > > } > > > > -- > > 2.17.1 > > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6MV0CnOO/V52fgAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 09:36:19 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6KCbCHOO/V7ScAAAlp8NpQ (envelope-from ); Thu, 02 Jul 2020 09:36:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D32CEA27B1; Thu, 2 Jul 2020 09:36:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728034AbgGBHgE (ORCPT + 1 other); Thu, 2 Jul 2020 03:36:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:60908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726844AbgGBHgD (ORCPT ); Thu, 2 Jul 2020 03:36:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A16A1206BE; Thu, 2 Jul 2020 07:36:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593675363; bh=1n77CNPeJ33Kywgw5iC9Ya49YYvivp0h8s4IwclTbf8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PKkyx7NdRs71xsCwaGxelmBAxbGoAQjIq8RmaCZiqgqFPOXr1MqVudESyN7L88Ms9 rZTGOpoQnLPyrJWY7SGzybyYPYxqJbxm6ptrjgt4ejS+OODyTWMVbGSwkA1GGtRyQW 3N5vEVBfGOwxoLMW/cqh1q8pB7g9lUfbs3ptCgXk= Date: Thu, 2 Jul 2020 09:36:07 +0200 From: Greg Kroah-Hartman To: Daniel Winkler Cc: linux-serial@vger.kernel.org, linux-mediatek@lists.infradead.org, Serge Semin , Alexey Malahov , BlueZ , chromeos-bluetooth-upstreaming , stable@vger.kernel.org, abhishekpandit@chromium.org, Aaron Sierra , Andy Shevchenko , Jiri Slaby , Lukas Wunner , Vignesh Raghavendra , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port" Message-ID: <20200702073607.GD1073011@kroah.com> References: <20200701211337.3027448-1-danielwinkler@google.com> <20200701141329.v2.1.I2cc415fa5793b3e55acfd521ba8f0a71e79aa5f1@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200701141329.v2.1.I2cc415fa5793b3e55acfd521ba8f0a71e79aa5f1@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.12 / 15.00 / 200.00 X-Rspamd-Queue-Id: D32CEA27B1 X-Rspamd-UID: e5ff9a On Wed, Jul 01, 2020 at 02:13:37PM -0700, Daniel Winkler wrote: > This reverts commit 7b668c064ec33f3d687c3a413d05e355172e6c92. > I need a reason _why_ to revert this in the changelog text. Your 0/1 comments would be great to see in here, otherwise I have no idea what is going on when I look at the kernel changelog in the future. > Fixes: 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 > port") Nit, in the future, this line does not need to be wrapped at all, just let it go the full length please. thanks, greg k-h Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aJZ6E7uO/V4UZwAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 09:37:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 0JQ4EruO/V6R3wEA0J78UA (envelope-from ); Thu, 02 Jul 2020 09:37:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 249E95080C; Thu, 2 Jul 2020 09:37:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728034AbgGBHhR (ORCPT + 1 other); Thu, 2 Jul 2020 03:37:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:33360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726630AbgGBHhQ (ORCPT ); Thu, 2 Jul 2020 03:37:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8A27F2085B; Thu, 2 Jul 2020 07:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593675436; bh=vpifWVwgbjHSUaEegAAHzDiKupI4P46wI+RPjm/wU9M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KmcMFIrPlH/DYGVA69kjk8PKCY/DCTSfxA7mi8F7SUmgwxhtcI3ae4CZwpCU359bq O48jck5Plf9ZR0KbrKdFvmTivRigbjS7x7dcIjocdZd0fcyNBPP6IoFm28o+ZJ2gwT rN71msrjI6cYKrnS0UT2QSDl1Lxr4H8miKM1euLk= Date: Thu, 2 Jul 2020 09:37:20 +0200 From: Greg Kroah-Hartman To: Serge Semin Cc: Daniel Winkler , Serge Semin , linux-serial@vger.kernel.org, linux-mediatek@lists.infradead.org, Alexey Malahov , BlueZ , chromeos-bluetooth-upstreaming , stable@vger.kernel.org, abhishekpandit@chromium.org, Aaron Sierra , Andy Shevchenko , Jiri Slaby , Lukas Wunner , Vignesh Raghavendra , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port" Message-ID: <20200702073720.GE1073011@kroah.com> References: <20200701211337.3027448-1-danielwinkler@google.com> <20200701223713.gavale4aramu3xnb@mobilestation> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200701223713.gavale4aramu3xnb@mobilestation> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: 249E95080C X-Rspamd-UID: aee0ac On Thu, Jul 02, 2020 at 01:37:13AM +0300, Serge Semin wrote: > On Wed, Jul 01, 2020 at 02:13:36PM -0700, Daniel Winkler wrote: > > > > This change regresses the QCA6174A-3 bluetooth chip, preventing > > firmware from being properly loaded. Without this change, the > > chip works as intended. > > > > The device is the Kukui Chromebook using the Mediatek chipset > > and the 8250_mtk uart. Initial controller baudrate is 115200 > > and operating speed is 3000000. Our entire suite of bluetooth > > tests now fail on this platform due to an apparent failure to > > sync its firmware on initialization. > > Ok. It's mediatek 8250 driver, which is responsible for the failure. > Then we'll have two options: > > 1) Add a new capability like UART_CAP_NO16DIV and take it into account > in the serial8250_get_baud_rate() method. > > I don't have a documentation for the Mediatek UART port, but it seems to me > that that controller calculates the baud rate differently from the standard > 8250 port. A standard 8250 port does that by the next formulae: > baud = uartclk / (16 * divisor). > While it seems to me that the Mediatek port uses the formulae like: > baud = uartclk / divisor. (Please, correct me if I'm wrong) > If so, then we could introduce a new capability like UART_CAP_NO16DIV. The > 8250_mtk driver will add it to the 8250-port capabilities field. The > serial8250_get_baud_rate() method should be altered in a way so one would check > whether the UART_CAP_NO16DIV flag is set and if it is then the > uart_get_baud_rate() function will be called without uartclk normalized by the > factor of 16. > > 2) Manually call serial8250_do_set_divisor() in the custom set_termios() > callback. > > Just add the uart_update_timeout() and serial8250_do_set_divisor() methods > invocation into the mtk8250_set_termios() function, which the original commit > 81bb549fdf14 ("serial: 8250_mtk: support big baud rate") author should have > done in the first place. Sounds like a sane fix, thanks for looking into this. greg k-h Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ONk9HxGf/V5hTQEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 10:47:13 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AF17HRGf/V4eJQEAgupzMw (envelope-from ); Thu, 02 Jul 2020 10:47:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0AADBA2317; Thu, 2 Jul 2020 10:47:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726682AbgGBIq6 (ORCPT + 1 other); Thu, 2 Jul 2020 04:46:58 -0400 Received: from mga07.intel.com ([134.134.136.100]:46981 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726445AbgGBIq5 (ORCPT ); Thu, 2 Jul 2020 04:46:57 -0400 IronPort-SDR: SMm7EsYoyGOCw1VH5AY5MYxjoaW32H29P1oECYocvko45IY5F5b95UUmHgEiCVDdbXD7I/6b+L oqc/XQVNs4sQ== X-IronPort-AV: E=McAfee;i="6000,8403,9669"; a="211871600" X-IronPort-AV: E=Sophos;i="5.75,303,1589266800"; d="scan'208";a="211871600" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 01:46:57 -0700 IronPort-SDR: 8v773znlm029UZL/qcOa676PS5qX3eVR1JOuEsIfC/o5+P9qUYXJro3MDuwBkXM9lWFBy+Zfy4 emMN3tj3kZLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,303,1589266800"; d="scan'208";a="455443914" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga005.jf.intel.com with ESMTP; 02 Jul 2020 01:46:53 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1jqurt-00HAon-VD; Thu, 02 Jul 2020 11:46:53 +0300 Date: Thu, 2 Jul 2020 11:46:53 +0300 From: Andy Shevchenko To: Lukas Wunner Cc: Serge Semin , Daniel Winkler , Serge Semin , linux-serial@vger.kernel.org, linux-mediatek@lists.infradead.org, Alexey Malahov , BlueZ , chromeos-bluetooth-upstreaming , stable@vger.kernel.org, abhishekpandit@chromium.org, Aaron Sierra , Greg Kroah-Hartman , Jiri Slaby , Vignesh Raghavendra , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port" Message-ID: <20200702084653.GG3703480@smile.fi.intel.com> References: <20200701211337.3027448-1-danielwinkler@google.com> <20200701223713.gavale4aramu3xnb@mobilestation> <20200702041152.e5csvbodojzwnagx@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200702041152.e5csvbodojzwnagx@wunner.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.63 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0AADBA2317 X-Rspamd-UID: d6398e On Thu, Jul 02, 2020 at 06:11:52AM +0200, Lukas Wunner wrote: > On Thu, Jul 02, 2020 at 01:37:13AM +0300, Serge Semin wrote: > > 1) Add a new capability like UART_CAP_NO16DIV and take it into account > > in the serial8250_get_baud_rate() method. > > > > I don't have a documentation for the Mediatek UART port, but it seems to me > > that that controller calculates the baud rate differently from the standard > > 8250 port. A standard 8250 port does that by the next formulae: > > baud = uartclk / (16 * divisor). > > While it seems to me that the Mediatek port uses the formulae like: > > baud = uartclk / divisor. (Please, correct me if I'm wrong) > > 8250_bcm2835aux.c seems to suffer from a similar issue and > solves it like this in the ->probe hook: > > /* the HW-clock divider for bcm2835aux is 8, > * but 8250 expects a divider of 16, > * so we have to multiply the actual clock by 2 > * to get identical baudrates. > */ > up.port.uartclk = clk_get_rate(data->clk) * 2; 8250_mid for example lies about UART clock due to this. It has a comment in the code in its ->set_termios(). Yes, we have a lot of possibilities here to fix, I guess. We have custom termios callback, also get and set divisor and so on. -- With Best Regards, Andy Shevchenko Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YH9ECcLe/V5ngQAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 15:18:58 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 4G9dB8Le/V5PCAAAlScrYA (envelope-from ); Thu, 02 Jul 2020 15:18:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CC6CBA31AF; Thu, 2 Jul 2020 15:18:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729166AbgGBNSp convert rfc822-to-8bit (ORCPT + 1 other); Thu, 2 Jul 2020 09:18:45 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:41205 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgGBNSo (ORCPT ); Thu, 2 Jul 2020 09:18:44 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 6AF6BCED12; Thu, 2 Jul 2020 15:28:38 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2] Bluetooth: le_supported_roles experimental feature From: Marcel Holtmann In-Reply-To: <20200701220853.421445-1-alainm@chromium.org> Date: Thu, 2 Jul 2020 15:18:42 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <427B6E1C-178C-405D-88F8-899EC48AC8A9@holtmann.org> References: <20200701220853.421445-1-alainm@chromium.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.13 / 15.00 / 200.00 X-Rspamd-Queue-Id: CC6CBA31AF X-Rspamd-UID: 2d5b04 Hi Alain, > This patch adds an le_supported_roles features which allows a > clients to determine if the controller is able to support peripheral and > central connections separately and at the same time. > > Signed-off-by: Alain Michaud > --- > > Changes in v2: > - Slight change of design based on offline feedback > > net/bluetooth/mgmt.c | 36 +++++++++++++++++++++++++++++++++++- > 1 file changed, 35 insertions(+), 1 deletion(-) > > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > index 5e9b9728eeac..c13fcc21745f 100644 > --- a/net/bluetooth/mgmt.c > +++ b/net/bluetooth/mgmt.c > @@ -3753,10 +3753,36 @@ static const u8 debug_uuid[16] = { > }; > #endif > > +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ > +static const u8 le_supported_roles[16] = { > + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, > + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > +}; > + > +static u32 get_le_roles_flags(struct hci_dev *hdev) > +{ > + u32 flags = 0; > + > + /* Central connections supported */ > + if (hdev->le_states[4] & 0x08) > + flags |= BIT(0); > + > + /* Peripheral connections supported */ > + if (hdev->le_states[4] & 0x40) > + flags |= BIT(1); > + > + /* Simult central and peripheral connections supported */ > + if (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && > + (hdev->le_states[3] & 0x10)) > + flags |= BIT(2); > + > + return flags; > +} this is not what we can do here. The flags are defined like this. The following bits are defined for the Flags parameter: 0 Feature active 1 Causes change in supported settings And I want these flags for generic handling of experimental features. Individual features can not overwrite it. So if you only want to support a the “read" functionality, then something like this please. if ((hdev->le_states[4] & 0x08) && /* Central */ (hdev->le_states[4] & 0x40) && /* Peripheral */ (hdev->le_states[3] & 0x10) && /* Simultaneous */ test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks)) flags |= BIT(0); > + > static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > void *data, u16 data_len) > { > - char buf[42]; > + char buf[44]; > struct mgmt_rp_read_exp_features_info *rp = (void *)buf; > u16 idx = 0; > > @@ -3774,6 +3800,14 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + if (hdev) { > + memcpy(rp->features[idx].uuid, le_supported_roles, > + sizeof(le_supported_roles)); > + And I would put it all here instead of a separate function. > + rp->features[idx].flags = cpu_to_le32(get_le_roles_flags(hdev)); > + ++idx; > + } > + > rp->feature_count = cpu_to_le16(idx); > > /* After reading the experimental features information, enable Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aBlEHHHf/V6xcQAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 15:21:53 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id MGPeGnHf/V43hgEA0J78UA (envelope-from ); Thu, 02 Jul 2020 15:21:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3ACECA2710; Thu, 2 Jul 2020 15:21:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729119AbgGBNVr convert rfc822-to-8bit (ORCPT + 1 other); Thu, 2 Jul 2020 09:21:47 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:54975 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgGBNVq (ORCPT ); Thu, 2 Jul 2020 09:21:46 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 932ABCED12; Thu, 2 Jul 2020 15:31:40 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v3 8/8] Bluetooth: Add support to enable LL PRIVACY using set_privacy From: Marcel Holtmann In-Reply-To: <20200701100432.28038-9-sathish.narasimman@intel.com> Date: Thu, 2 Jul 2020 15:21:45 +0200 Cc: linux-bluetooth , Sathish Narasimman Content-Transfer-Encoding: 8BIT Message-Id: <10FB84C9-79E7-48F9-88A5-B10FB67CB585@holtmann.org> References: <20200701100432.28038-1-sathish.narasimman@intel.com> <20200701100432.28038-9-sathish.narasimman@intel.com> To: Sathish Narasimman X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 2 X-Rspamd-Score: 0.36 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3ACECA2710 X-Rspamd-UID: 2d5d83 Hi Sathish, > Enable LL Privacy using mgmt set_privacy command. The privacy > value 0x03 is used here to enable LL Privacy. > Still to use LL Privacy controller support is must. that is not what I meant. And it is also misleading since Set Privacy is enabling RPA usage and not RPA resolution. So what I meant was using the Set Experimental Features mgmt command to enable usage of RPA resolution in the controller. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iEjgMI7g/V4RfQAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 15:26:38 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id SGeyL47g/V4tNwAAlp8NpQ (envelope-from ); Thu, 02 Jul 2020 15:26:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B114B48DF8; Thu, 2 Jul 2020 15:26:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729337AbgGBN0B convert rfc822-to-8bit (ORCPT + 1 other); Thu, 2 Jul 2020 09:26:01 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:46278 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729335AbgGBN0A (ORCPT ); Thu, 2 Jul 2020 09:26:00 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 45535CED13; Thu, 2 Jul 2020 15:35:53 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 2/5] Bluetooth: btintel: Refactor firmware header download sequence From: Marcel Holtmann In-Reply-To: <20200702120315.26768-3-kiran.k@intel.com> Date: Thu, 2 Jul 2020 15:25:57 +0200 Cc: linux-bluetooth , "Srivatsa, Ravishankar" , Chethan T N , kiraank@gmail.com, Amit K Bag , Raghuram Hegde Content-Transfer-Encoding: 8BIT Message-Id: <8040CBA1-AF50-43A1-8314-4E44E4F27173@holtmann.org> References: <20200702120315.26768-1-kiran.k@intel.com> <20200702120315.26768-3-kiran.k@intel.com> To: Kiran K X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: B114B48DF8 X-Rspamd-UID: 437a1b Hi Kiran, > Move firmware header download code to a separate function to > enhance readability and reusability > > Signed-off-by: Kiran K > Signed-off-by: Amit K Bag > Signed-off-by: Raghuram Hegde > Reviewed-by: Chethan T N > Reviewed-by: Sathish Narasimman > Reviewed-by: Srivatsa Ravishankar > --- > drivers/bluetooth/btintel.c | 21 +++++++++++++++++---- > 1 file changed, 17 insertions(+), 4 deletions(-) > > diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c > index dea96c585ecb..1c820c187421 100644 > --- a/drivers/bluetooth/btintel.c > +++ b/drivers/bluetooth/btintel.c > @@ -646,12 +646,10 @@ int btintel_read_boot_params(struct hci_dev *hdev, > } > EXPORT_SYMBOL_GPL(btintel_read_boot_params); > > -int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, > - u32 *boot_param) > +static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev, > + const struct firmware *fw) > { > int err; > - const u8 *fw_ptr; > - u32 frag_len; > > /* Start the firmware download transaction with the Init fragment > * represented by the 128 bytes of CSS header. > @@ -679,6 +677,21 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, > bt_dev_err(hdev, "Failed to send firmware signature (%d)", err); > goto done; > } Here should be an extra empty line before the label. > +done: > + return err; > +} > + > +int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, > + u32 *boot_param) > +{ > + int err; > + const u8 *fw_ptr; > + u32 frag_len; > + > + err = btintel_sfi_rsa_header_secure_send(hdev, fw); > + if (err) > + goto done; > + Scrap the extra empty line here. > > fw_ptr = fw->data + 644; > frag_len = 0; Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WJM5CODg/V4RfQAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 15:28:00 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qLyyBuDg/V6cHwAAlp8NpQ (envelope-from ); Thu, 02 Jul 2020 15:28:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5F554A310F; Thu, 2 Jul 2020 15:27:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729222AbgGBN1z convert rfc822-to-8bit (ORCPT + 1 other); Thu, 2 Jul 2020 09:27:55 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:44468 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728893AbgGBN1y (ORCPT ); Thu, 2 Jul 2020 09:27:54 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id C4182CED12; Thu, 2 Jul 2020 15:37:48 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 3/5] Bluetooth: btintel: Refactor firmware payload download code From: Marcel Holtmann In-Reply-To: <20200702120315.26768-4-kiran.k@intel.com> Date: Thu, 2 Jul 2020 15:27:53 +0200 Cc: linux-bluetooth , ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Amit K Bag , Raghuram Hegde Content-Transfer-Encoding: 8BIT Message-Id: References: <20200702120315.26768-1-kiran.k@intel.com> <20200702120315.26768-4-kiran.k@intel.com> To: Kiran K X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5F554A310F X-Rspamd-UID: 62d2ff Hi Kiran, > Move firmware payload download code to a separate function to > enhance readability and reusability this patch is doing more than that. It also introduces an extra public function. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UFRnJl/i/V6omwAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 15:34:23 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 4G47JV/i/V6cKgEA0J78UA (envelope-from ); Thu, 02 Jul 2020 15:34:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3010952806; Thu, 2 Jul 2020 15:34:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729323AbgGBNeR convert rfc822-to-8bit (ORCPT + 1 other); Thu, 2 Jul 2020 09:34:17 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:33689 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729115AbgGBNeR (ORCPT ); Thu, 2 Jul 2020 09:34:17 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 15313CED14; Thu, 2 Jul 2020 15:44:10 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 5/5] Bluetooth: btintel: Parse controller information present in TLV format From: Marcel Holtmann In-Reply-To: <20200702120315.26768-6-kiran.k@intel.com> Date: Thu, 2 Jul 2020 15:34:14 +0200 Cc: linux-bluetooth , "Srivatsa, Ravishankar" , chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Amit K Bag , Raghuram Hegde Content-Transfer-Encoding: 8BIT Message-Id: <0CCCE1DA-3700-4B8C-A75B-D98D07F51782@holtmann.org> References: <20200702120315.26768-1-kiran.k@intel.com> <20200702120315.26768-6-kiran.k@intel.com> To: Kiran K X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3010952806 X-Rspamd-UID: 049c32 Hi Kiran, > New generation Intel controllers returns controller information > in TLV format. Adding capability to parse and log it for debug purpose > > Signed-off-by: Kiran K > Signed-off-by: Amit K Bag > Signed-off-by: Raghuram Hegde > Reviewed-by: Chethan T N > Reviewed-by: Sathish Narasimman > Reviewed-by: Srivatsa Ravishankar > --- > drivers/bluetooth/btintel.c | 161 ++++++++++++++++++++++++++++++++---- > drivers/bluetooth/btusb.c | 4 +- > 2 files changed, 148 insertions(+), 17 deletions(-) > > diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c > index d0c6576212d7..f0b087d97a83 100644 > --- a/drivers/bluetooth/btintel.c > +++ b/drivers/bluetooth/btintel.c > @@ -209,27 +209,59 @@ void btintel_version_info(struct hci_dev *hdev, const struct btintel_version *ve > { > const char *variant; > const struct intel_version *ver; > + const struct intel_version_tlv *ver_tlv; > > - if (version->is_tlv_supported) > - return; > + if (!version->is_tlv_supported) { > + ver = &version->intel_version; > + > + switch (ver->fw_variant) { > + case 0x06: > + variant = "Bootloader"; > + break; The break; has to be indented with the variant =. > + case 0x23: > + variant = "Firmware"; > + break; > + default: > + goto done; > + } > > - ver = &version->intel_version; > + bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u", > + variant, ver->fw_revision >> 4, > + ver->fw_revision & 0x0f, ver->fw_build_num, > + ver->fw_build_ww, 2000 + ver->fw_build_yy); > + goto done; > + } > + > + ver_tlv = &version->intel_version_tlv; > > - switch (ver->fw_variant) { > - case 0x06: > + switch (ver_tlv->img_type) { > + case 0x01: > variant = "Bootloader"; > - break; > - case 0x23: > + bt_dev_info(hdev, "Device revision is %u", ver_tlv->dev_rev_id); > + bt_dev_info(hdev, "Secure boot is %s", > + ver_tlv->secure_boot ? "enabled" : "disabled"); > + bt_dev_info(hdev, "OTP lock is %s", > + ver_tlv->otp_lock ? "enabled" : "disabled"); > + bt_dev_info(hdev, "API lock is %s", > + ver_tlv->api_lock ? "enabled" : "disabled"); > + bt_dev_info(hdev, "Debug lock is %s", > + ver_tlv->debug_lock ? "enabled" : "disabled"); > + bt_dev_info(hdev, "Minimum firmware build %u week %u %u", > + ver_tlv->min_fw_build_nn, ver_tlv->min_fw_build_cw, > + 2000 + ver_tlv->min_fw_build_yy); > + break; > + case 0x03: > variant = "Firmware"; > - break; > + break; > default: > - return; > + goto done; > } > > - bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u", > - variant, ver->fw_revision >> 4, ver->fw_revision & 0x0f, > - ver->fw_build_num, ver->fw_build_ww, > - 2000 + ver->fw_build_yy); > + bt_dev_info(hdev, "%s timestamp %u.%u buildtype %u build %u", variant, > + 2000 + (ver_tlv->timestamp >> 8), ver_tlv->timestamp & 0xff, > + ver_tlv->build_type, ver_tlv->build_num); > +done: > + return; > } > EXPORT_SYMBOL_GPL(btintel_version_info); > > @@ -346,6 +378,8 @@ int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version) > { > struct sk_buff *skb; > u8 *data, param, status, check_tlv; > + struct intel_version_tlv *ver_tlv; > + struct intel_tlv *tlv; > > if (!version) > return -EINVAL; > @@ -373,9 +407,106 @@ int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version) > if (skb->len == sizeof(version->intel_version) && check_tlv == 0x37) { > memcpy(&version->intel_version, skb->data, sizeof(version->intel_version)); > version->is_tlv_supported = false; > - } else { > - version->is_tlv_supported = true; > + goto done; > } > + > + bt_dev_info(hdev, "Supports tlv firmware download sequence"); > + version->is_tlv_supported = true; > + ver_tlv = &version->intel_version_tlv; > + > + /* Consume Command Complete Status field */ > + skb_pull(skb, 1); > + > + /* Event parameters contatin multiple TLVs. Read each of them > + * and only keep the required data. Also, it use existing legacy > + * version field like hw_platform, hw_variant, and fw_variant > + * to keep the existing setup flow > + */ > + while (skb->len) { > + tlv = (struct intel_tlv *)skb->data; > + switch (tlv->type) { > + case INTEL_TLV_CNVI_TOP: > + ver_tlv->cnvi_top = (tlv->val[3] << 24) | > + (tlv->val[2] << 16) | > + (tlv->val[1] << 8) | > + (tlv->val[0]); We have get_unaligned functions for that. > + break; > + case INTEL_TLV_CNVR_TOP: > + ver_tlv->cnvr_top = (tlv->val[3] << 24) | > + (tlv->val[2] << 16) | > + (tlv->val[1] << 8) | > + (tlv->val[0]); > + break; > + case INTEL_TLV_CNVI_BT: > + ver_tlv->cnvi_bt = (tlv->val[3] << 24) | > + (tlv->val[2] << 16) | > + (tlv->val[1] << 8) | > + (tlv->val[0]); > + break; > + case INTEL_TLV_CNVR_BT: > + ver_tlv->cnvr_bt = (tlv->val[3] << 24) | > + (tlv->val[2] << 16) | > + (tlv->val[1] << 8) | > + (tlv->val[0]); > + break; > + case INTEL_TLV_USB_VENDOR_ID: > + ver_tlv->usb_vid = (tlv->val[1] << 8) | (tlv->val[0]); > + break; > + case INTEL_TLV_USB_PRODUCT_ID: > + ver_tlv->usb_pid = (tlv->val[1] << 8) | (tlv->val[0]); > + break; > + case INTEL_TLV_IMAGE_TYPE: > + ver_tlv->img_type = tlv->val[0]; > + break; > + case INTEL_TLV_TIME_STAMP: > + ver_tlv->timestamp = (tlv->val[1] << 8) | (tlv->val[0]); > + break; > + case INTEL_TLV_BUILD_TYPE: > + ver_tlv->build_type = tlv->val[0]; > + break; > + case INTEL_TLV_BUILD_NUM: > + ver_tlv->build_num = (tlv->val[3] << 24) | > + (tlv->val[2] << 16) | > + (tlv->val[1] << 8) | > + (tlv->val[0]); > + break; > + case INTEL_TLV_SECURE_BOOT: > + ver_tlv->secure_boot = tlv->val[0]; > + break; > + case INTEL_TLV_KEY_FROM_HDR: > + ver_tlv->key_from_hdr = tlv->val[0]; > + break; > + case INTEL_TLV_OTP_LOCK: > + ver_tlv->otp_lock = tlv->val[0]; > + break; > + case INTEL_TLV_API_LOCK: > + ver_tlv->api_lock = tlv->val[0]; > + break; > + case INTEL_TLV_DEBUG_LOCK: > + ver_tlv->debug_lock = tlv->val[0]; > + break; > + case INTEL_TLV_MIN_FW: > + ver_tlv->min_fw_build_nn = tlv->val[0]; > + ver_tlv->min_fw_build_cw = tlv->val[1]; > + ver_tlv->min_fw_build_yy = tlv->val[2]; > + break; > + case INTEL_TLV_LIMITED_CCE: > + ver_tlv->limited_cce = tlv->val[0]; > + break; > + case INTEL_TLV_SBE_TYPE: > + ver_tlv->sbe_type = tlv->val[0]; > + break; > + case INTEL_TLV_OTP_BDADDR: > + memcpy(&ver_tlv->otp_bd_addr, tlv->val, tlv->len); > + break; > + default: > + /* Ignore rest of information */ > + break; > + } > + /* consume the current tlv and move to next*/ > + skb_pull(skb, tlv->len + sizeof(*tlv)); > + } > +done: > kfree_skb(skb); > return 0; > } > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index 364da6d44ee3..f30b43e15a26 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -2519,13 +2519,13 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) > return err; > } > > + btintel_version_info(hdev, &version); > + > if (version.is_tlv_supported) { > bt_dev_err(hdev, "Firmware download in tlv format is not supported"); > return -EOPNOTSUPP; > } > > - btintel_version_info(hdev, &version); > - > err = btusb_intel_download_firmware(hdev, &version, ¶ms); > if (err) > return err; Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MCQONMn2/V4QAgEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 17:01:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UA9vMcn2/V5zqAAAgupzMw (envelope-from ); Thu, 02 Jul 2020 17:01:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 03146A2737; Thu, 2 Jul 2020 17:01:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728105AbgGBPBX (ORCPT + 1 other); Thu, 2 Jul 2020 11:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbgGBPBW (ORCPT ); Thu, 2 Jul 2020 11:01:22 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75A81C08C5C1 for ; Thu, 2 Jul 2020 08:01:22 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id z24so7701761ljn.8 for ; Thu, 02 Jul 2020 08:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=yz7Jmxr8mb3QoIiRZAxjOj5pQVUc4DNEwN36TOLAcqw=; b=cbKekr7emqwLL/vRPLe8buZGATil0p/VQOQqlji8rYv+yWc1UUrJD4p8s2b5gcb9JS fnc2usvul4lwtacK5YdXVWGqdl4b8TpVQz0jwVuAuIsbdBSpLfHNQoiuHrhfQVn8A1f7 bSfaVhUTqAoynEtz0oWESffrKkC5CCnLJqXgfBT6B4TrBlTqq6V3R/tZ9dVKg1gOHtex /HeRBkb7SNDRzNlE+J8oboOI+Vbwe2XbEC/LnlpIWceUxFTs18FNuUR1tc8CQQmziL1c lgC4S/ClVcF8OD3Nu15mN/gFknQFYrxDKuxtRpdwQ14XUE/MABXB9YD3YLTjY3dNX6Gz 5l4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=yz7Jmxr8mb3QoIiRZAxjOj5pQVUc4DNEwN36TOLAcqw=; b=YNJPMQps6+tYNy0ceeRqxRtyZpbdNd//NpnZEcJwwl++C0yYLrwZfc9NH8QGSV9LGc tc3wZd3bwY86ZySMcdi7bAlo52GjB2QPFcZ1QGNcQBuMr3f8xj8YuztDvyAAKLt7EU0H B82+jBOXWrqH3wLL/AxdSxtVf/6URlLZRDr8jQdUW8oS8nTB4hbSLu1HsQfrX1BiZPvx zP0nUPRi0UgczWahamk1tRGxQjYmxbZNapEKOnk+5tqB3H4aflYl1c5Y9EJw8/Ek3TsK gLMuJCRKYE7uPV079xQxy+NYnv6sGCeGvMcKt1KHdJVrNwhR+4JQwLshXtBqAXqnhoXj pNLQ== X-Gm-Message-State: AOAM530HcNI7k4ueDbTjTiHT4vHFgbx20Va/64RhD4LoA5Ct4TvNQzPz W76SmamKAJDFqnhABQ9PQ/x9Te6TbhjIWHNqf+kPgQ== X-Google-Smtp-Source: ABdhPJy/h0xDCvDFfGr8gMGmrpbIjY5MIp5Cxsj9j0ofU0WQzN8di+dv4laZrV3+j+fko4/bC+9PowQWtrUuaFka400= X-Received: by 2002:a05:651c:11c7:: with SMTP id z7mr9072197ljo.39.1593702080592; Thu, 02 Jul 2020 08:01:20 -0700 (PDT) MIME-Version: 1.0 References: <20200701220853.421445-1-alainm@chromium.org> <427B6E1C-178C-405D-88F8-899EC48AC8A9@holtmann.org> In-Reply-To: From: Alain Michaud Date: Thu, 2 Jul 2020 11:01:09 -0400 Message-ID: Subject: Re: [PATCH v2] Bluetooth: le_supported_roles experimental feature To: Marcel Holtmann Cc: Alain Michaud , BlueZ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.40 / 15.00 / 200.00 X-Rspamd-Queue-Id: 03146A2737 X-Rspamd-UID: cb4fd5 Resending as plaintext. On Thu, Jul 2, 2020 at 10:59 AM Alain Michaud wro= te: > > Hi Marcel > > On Thu, Jul 2, 2020 at 9:18 AM Marcel Holtmann wrot= e: >> >> Hi Alain, >> >> > This patch adds an le_supported_roles features which allows a >> > clients to determine if the controller is able to support peripheral a= nd >> > central connections separately and at the same time. >> > >> > Signed-off-by: Alain Michaud >> > --- >> > >> > Changes in v2: >> > - Slight change of design based on offline feedback >> > >> > net/bluetooth/mgmt.c | 36 +++++++++++++++++++++++++++++++++++- >> > 1 file changed, 35 insertions(+), 1 deletion(-) >> > >> > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c >> > index 5e9b9728eeac..c13fcc21745f 100644 >> > --- a/net/bluetooth/mgmt.c >> > +++ b/net/bluetooth/mgmt.c >> > @@ -3753,10 +3753,36 @@ static const u8 debug_uuid[16] =3D { >> > }; >> > #endif >> > >> > +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ >> > +static const u8 le_supported_roles[16] =3D { >> > + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, >> > + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, >> > +}; >> > + >> > +static u32 get_le_roles_flags(struct hci_dev *hdev) >> > +{ >> > + u32 flags =3D 0; >> > + >> > + /* Central connections supported */ >> > + if (hdev->le_states[4] & 0x08) >> > + flags |=3D BIT(0); >> > + >> > + /* Peripheral connections supported */ >> > + if (hdev->le_states[4] & 0x40) >> > + flags |=3D BIT(1); >> > + >> > + /* Simult central and peripheral connections supported */ >> > + if (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && >> > + (hdev->le_states[3] & 0x10)) >> > + flags |=3D BIT(2); >> > + >> > + return flags; >> > +} >> >> this is not what we can do here. The flags are defined like this. >> >> The following bits are defined for the Flags parameter: >> >> 0 Feature active >> 1 Causes change in supported settings >> >> And I want these flags for generic handling of experimental features. In= dividual features can not overwrite it. >> >> So if you only want to support a the =E2=80=9Cread" functionality, then = something like this please. >> >> if ((hdev->le_states[4] & 0x08) && /* Central */ >> (hdev->le_states[4] & 0x40) && /* Peripheral */ >> (hdev->le_states[3] & 0x10) && /* Simultaneous */ >> test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks)) >> flags |=3D BIT(0); >> > OK, Since the userspace Api we discussed reports individual states, would= you suggest if LE is supported that the Central and Peripheral roles are s= upported and just use this to query the simultaneous support? > >> >> > + >> > static int read_exp_features_info(struct sock *sk, struct hci_dev *hde= v, >> > void *data, u16 data_len) >> > { >> > - char buf[42]; >> > + char buf[44]; >> > struct mgmt_rp_read_exp_features_info *rp =3D (void *)buf; >> > u16 idx =3D 0; >> > >> > @@ -3774,6 +3800,14 @@ static int read_exp_features_info(struct sock *= sk, struct hci_dev *hdev, >> > } >> > #endif >> > >> > + if (hdev) { >> > + memcpy(rp->features[idx].uuid, le_supported_roles, >> > + sizeof(le_supported_roles)); >> > + >> >> And I would put it all here instead of a separate function. >> >> > + rp->features[idx].flags =3D cpu_to_le32(get_le_roles_fla= gs(hdev)); >> > + ++idx; >> > + } >> > + >> > rp->feature_count =3D cpu_to_le16(idx); >> > >> > /* After reading the experimental features information, enable >> >> Regards >> >> Marcel >> Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wG/kGI8A/l5yQAEAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 17:43:11 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id OAJ8F48A/l5YFAAA0J78UA (envelope-from ); Thu, 02 Jul 2020 17:43:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6E1FD41C58; Thu, 2 Jul 2020 17:43:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730280AbgGBPnE (ORCPT + 1 other); Thu, 2 Jul 2020 11:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbgGBPnD (ORCPT ); Thu, 2 Jul 2020 11:43:03 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C552C08C5C1 for ; Thu, 2 Jul 2020 08:43:03 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id g37so715400otb.9 for ; Thu, 02 Jul 2020 08:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wacwb6gdlVm4ErQQEHazoKnIUKGvN0uOle2VWL6Ms4E=; b=mn9sqSRjZ4t8Ol5Dr/3tVs9e8IIWHTvavbBa6p1ZnP7kF6kjbSkOC4Ccnu1u47y81U Ppr344czHUSkpMNKfFtX9e8MZsQa2I1wgD3BwLVVC4H3Mz2T9gePqc3bzkDi/p05s9Cv Du2N9JdnARhUAkN+QAMOB8LgwcBNR076rNMbEVA2Sgpn+kQbzIEg2umhOC4pxQXl0rA2 rhc2SKUlFvT3EOV++GyvCmUgaHDZd87RO11siv/vFTiS04HL7KUOqG8k/NAZWWCg0GJK Pt6Y+JyAs2dkxKb9aLgbcOLGAJz8ao3BV2+jyrxRtHzmTg7zk+iYYwFUM7dA78C0eCm3 Kpqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wacwb6gdlVm4ErQQEHazoKnIUKGvN0uOle2VWL6Ms4E=; b=j4WeUUQjdLHT1o4oZkM/TgrUmG3CsDHQc1tpm5cN1PeXOgDUanPW1GOurHvTD0XbFf N4CwgQZUBWwNxIs9f1eS0YWHyIrQC1XDEVQRAiURfddiHxgI2UhCfAN+XA0g73Kixrgu uU8V7kBnzTSQ+pyljN3jefgR02AvUP86KCDz/NZOcbbvqc5+0GuSz9+bMZZNuzYGFiBx US4XEuOPJE5+ylUOWV7ex2Zp7QPPdMAHYj1ykN/xy6a2Vld+UaJ4MSYfnteQWGcU0N/b wiOX+JxbGKncyd3lOI41vK3Q7RKG3OA+t3m88KUhALptTFvmxW7vFzLcEV7K1tUOLLtT wYrA== X-Gm-Message-State: AOAM531kuJIdkjgB35ogh307NYCls/ubw+lyS32oxBNdfLizwswlGzif QhSPAr+o43FvAOv+hcBhuxCQ7gi4sjXZTDdPuxM= X-Google-Smtp-Source: ABdhPJwgkTuQNDmuPh/0Bn8rVx5kEK4inahJY18zg8r8VIxIctYsH2x19jGSyEc0k3gjl2L+YsvoC9ckr5v6FtTPf7g= X-Received: by 2002:a9d:3da5:: with SMTP id l34mr26580484otc.88.1593704582694; Thu, 02 Jul 2020 08:43:02 -0700 (PDT) MIME-Version: 1.0 References: <20200701192202.9508-1-sonnysasaka@chromium.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Thu, 2 Jul 2020 08:42:50 -0700 Message-ID: Subject: Re: [PATCH v2] client: Add battery percentage to info command To: Sonny Sasaka Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.12 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6E1FD41C58 X-Rspamd-UID: 661308 Hi Sonny, On Wed, Jul 1, 2020 at 11:06 PM Sonny Sasaka wrote: > > Hi Luiz, > > On Wed, Jul 1, 2020 at 10:20 PM Luiz Augusto von Dentz > wrote: > > > > Hi Sonny, > > > > On Wed, Jul 1, 2020 at 12:24 PM Sonny Sasaka wrote: > > > > > > This adds the Battery Percentage to the info command based on > > > org.bluez.Battery1 API. Example usage: > > > > > > [bluetooth]# info XX:XX:XX:XX:XX:XX > > > Device XX:XX:XX:XX:XX:XX (random) > > > Name: ... > > > Alias: ... > > > ... > > > Modalias: ... > > > Battery Percentage: 100% > > > --- > > > client/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > > > 1 file changed, 43 insertions(+) > > > > > > diff --git a/client/main.c b/client/main.c > > > index 422da5593..4b787240e 100644 > > > --- a/client/main.c > > > +++ b/client/main.c > > > @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; > > > static GDBusProxy *default_dev; > > > static GDBusProxy *default_attr; > > > static GList *ctrl_list; > > > +static GList *battery_proxies; > > > > > > static const char *agent_arguments[] = { > > > "on", > > > @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) > > > bt_shell_set_prompt(PROMPT_OFF); > > > > > > g_list_free_full(ctrl_list, proxy_leak); > > > + g_list_free_full(battery_proxies, proxy_leak); > > > ctrl_list = NULL; > > > + battery_proxies = NULL; > > > > > > default_ctrl = NULL; > > > } > > > @@ -445,6 +448,16 @@ done: > > > g_free(desc); > > > } > > > > > > +static void battery_added(GDBusProxy *proxy) > > > +{ > > > + battery_proxies = g_list_append(battery_proxies, proxy); > > > +} > > > + > > > +static void battery_removed(GDBusProxy *proxy) > > > +{ > > > + battery_proxies = g_list_remove(battery_proxies, proxy); > > > +} > > > + > > > static void device_added(GDBusProxy *proxy) > > > { > > > DBusMessageIter iter; > > > @@ -539,6 +552,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) > > > gatt_add_manager(proxy); > > > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > > > ad_manager_added(proxy); > > > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > > > + battery_added(proxy); > > > } > > > } > > > > > > @@ -630,6 +645,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) > > > gatt_remove_manager(proxy); > > > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > > > ad_unregister(dbus_conn, NULL); > > > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > > > + battery_removed(proxy); > > > } > > > } > > > > > > @@ -763,6 +780,20 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) > > > return NULL; > > > } > > > > > > +static GDBusProxy *find_battery_by_path(GList *source, const char *path) > > > +{ > > > + GList *list; > > > + > > > + for (list = g_list_first(source); list; list = g_list_next(list)) { > > > + GDBusProxy *proxy = list->data; > > > + > > > + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) > > > + return proxy; > > > + } > > > + > > > + return NULL; > > > +} > > > + > > > static GDBusProxy *find_proxy_by_address(GList *source, const char *address) > > > { > > > GList *list; > > > @@ -1606,8 +1637,10 @@ static struct GDBusProxy *find_device(int argc, char *argv[]) > > > static void cmd_info(int argc, char *argv[]) > > > { > > > GDBusProxy *proxy; > > > + GDBusProxy *battery_proxy; > > > DBusMessageIter iter; > > > const char *address; > > > + unsigned char percentage; > > > > > > proxy = find_device(argc, argv); > > > if (!proxy) > > > @@ -1647,6 +1680,16 @@ static void cmd_info(int argc, char *argv[]) > > > print_property(proxy, "AdvertisingFlags"); > > > print_property(proxy, "AdvertisingData"); > > > > > > + battery_proxy = find_battery_by_path(battery_proxies, > > > + g_dbus_proxy_get_path(proxy)); > > > > I'd replace the lines below with just print_property(battery_proxy, > > "Percentage"); and just make print_property check for NULL proxy if it > > doesn't already. > I tried this but the result doesn't look quite good: > Device XX:XX:XX:XX:XX:XX (random) > Name: ... > ... > Modalias: ... > Percentage: 0x64 > > The name "Percentage" is not clear (what kind of percentage does it > mean) when shown in the "info" command. And also the format for byte > data type is hex and there is no percent sign. I tried to modify the > print_property function to support custom format but the code gets > overly complex and I think it's more straightforward to use custom > logic like in this patch. Just make it always print both the decimal and (hex). > > > > > + if (battery_proxy && g_dbus_proxy_get_property( > > > + battery_proxy, "Percentage", &iter)) { > > > + dbus_message_iter_get_basic(&iter, &percentage); > > > + bt_shell_printf("\tBattery Percentage: %d%%\n", percentage); > > > + } else { > > > + bt_shell_printf("\tNo battery information\n"); > > > + } > > > + > > > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > > > } > > > > > > -- > > > 2.17.1 > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2O+TDb4V/l6nVAAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 19:13:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id oHwODL4V/l60iwAA0J78UA (envelope-from ); Thu, 02 Jul 2020 19:13:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3304EA2429; Thu, 2 Jul 2020 19:13:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727951AbgGBRMi (ORCPT + 1 other); Thu, 2 Jul 2020 13:12:38 -0400 Received: from mga14.intel.com ([192.55.52.115]:60985 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727817AbgGBRMb (ORCPT ); Thu, 2 Jul 2020 13:12:31 -0400 IronPort-SDR: TdWHlBp//X+yXbhPyvjtBYEUldZ0/t5UYGEbPGeA63TyljAfSghAqCNKFvW/JEXhOdGD/irLbD TgZmDKHjU+Zw== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="146057739" X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="146057739" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 10:12:28 -0700 IronPort-SDR: CRaXBcYpNSNnzALPYcDthxnoGUuqbnzsQ5mEbBVEz7t3/N+9GqF7JVgT/vwX/t2ckW1Mq/k+Km gzAcGy4Qx16w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="295961668" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga002.jf.intel.com with ESMTP; 02 Jul 2020 10:12:28 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Jul 2020 10:12:28 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.176) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Jul 2020 10:12:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cIcDitTn7PObwoeAa7y1M8g+9hGa13VouXIVtpzteZIJ4qEX9wBp8bT21dgOMki/WyuWpngLbdUz6jjd8CIbQiY6ijwClQ0aX6heLjq1vzF72qn7lEtRQ2XgGR4Dzf5K8+4LHpK4nayvfZRKFPUu5wsHZj/nztumLwLCSl4qzS2V5m8AVVkHqtiFyVMrF1Ye55EVr/8asYmNipNuOTZKsdarfocWnXNipzhKg1mRCNKZTdsPCLqVfDHDZB3QVe1InfeVkAx6vRItEoyg4zJ2PwHAS/K8gOZDKDjMYySY1gExjklkcWPiC41Qi91o/Itb8h3+ddwJoCW0+hqLXg3XQw== 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-SenderADCheck; bh=8QwE996iYUojjzuErdA89dNQTCBB+5Ok/2gVElc7wFI=; b=gTjmHtUK59/+Q5ke7blHaUlKYad3q1NFO/JEmMjzA5naR1wtS+7aer+B/jwyYpz1apQy8VdRZrZElJsw9/GEBWKGeTT/i+TdgaemkqdDBVCTdM3bLa6Xyhzfrz681sViZJo5IQ1EHyD8k0umh6a4mtoGQ4FAeIo4ZVzb+HFw0myeLvc9FfMnV2broQ2nRh99RA443IqcjZT5M7X2v+6tpxzyPkdHGH7eZD5Ni/IgYohJFP7BcuN1jKHSTf6S8KLDcPW7eK8GE1dCqLAcTOHP48krzwCHlG5u3vYi32FjdxmEfp5iRI2NPjz8mjkzw/Hor/d4+bqSjLmNPEuMKN+ECQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8QwE996iYUojjzuErdA89dNQTCBB+5Ok/2gVElc7wFI=; b=oSMwrXn547Tft4W9FTGG2uNnBJujYGZNXK/wHskSaKwrdkSB6N4M9a8YyxL6CVAydAagsrw8TGkna3/PqwIFVsp9bZLJ/5DbUmHgxAoWirvmxi3ppZdqj1VOq8G1pL27JaDjKTXgGr1FF3yuagXjSk+rQd5BT44J4v49XjrYSuc= Received: from BYAPR11MB3141.namprd11.prod.outlook.com (2603:10b6:a03:8d::13) by BYAPR11MB3656.namprd11.prod.outlook.com (2603:10b6:a03:f8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20; Thu, 2 Jul 2020 17:12:23 +0000 Received: from BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::9ce5:c8f4:581b:9d9f]) by BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::9ce5:c8f4:581b:9d9f%5]) with mapi id 15.20.3131.028; Thu, 2 Jul 2020 17:12:23 +0000 From: "K, Kiran" To: Marcel Holtmann CC: linux-bluetooth , "Srivatsa, Ravishankar" , "Tumkur Narayan, Chethan" , "kiraank@gmail.com" , "Bag, Amit K" , Raghuram Hegde Subject: RE: [PATCH 2/5] Bluetooth: btintel: Refactor firmware header download sequence Thread-Topic: [PATCH 2/5] Bluetooth: btintel: Refactor firmware header download sequence Thread-Index: AQHWUGikJG8ZDOrkEUGU3i8Ku3Xo3Kj0R9GAgAA+jQA= Date: Thu, 2 Jul 2020 17:12:23 +0000 Message-ID: References: <20200702120315.26768-1-kiran.k@intel.com> <20200702120315.26768-3-kiran.k@intel.com> <8040CBA1-AF50-43A1-8314-4E44E4F27173@holtmann.org> In-Reply-To: <8040CBA1-AF50-43A1-8314-4E44E4F27173@holtmann.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.2.0.6 dlp-product: dlpe-windows authentication-results: holtmann.org; dkim=none (message not signed) header.d=none;holtmann.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.79.96] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6a4503c5-651c-4fd5-a2be-08d81eab162c x-ms-traffictypediagnostic: BYAPR11MB3656: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-forefront-prvs: 0452022BE1 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: RpJxg7ovTqggl6YV5ebnqPjOs1DhVcwjDUUXtnckoWUOOzSCp4A6emmmzrS8uJeIiTGZbL70OAGekPmqRscaHrl/7qNgmlvO6c48T7haMinqNTt0yv3odOtPixJL0u3nozhB63TL3ClxKW2cYP4J5+QOUGVYj8pZ2ddMDfRvwn0PB8aRelr5FY47jgh+Bmo+WDCAvCNK2X7xvlXMKCmq+wIB/TnwzwnymATGY7rCr30fLuwaDuOr0zdpy4lRHixhpCJ+nWpfz7TtSBCOZSduauykqm0h+RsS8tU30tptQUEWN4CFShZoFYn3Qsn9lxsLe1guCASw1q7rbDCR1UA5ZQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3141.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(366004)(39860400002)(396003)(136003)(376002)(346002)(8936002)(64756008)(76116006)(66556008)(4326008)(66446008)(66946007)(66476007)(83380400001)(8676002)(7696005)(33656002)(478600001)(55016002)(9686003)(54906003)(52536014)(316002)(107886003)(6506007)(71200400001)(86362001)(186003)(2906002)(26005)(6916009)(5660300002)(53546011);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: usD3W7JwpOiFlwg4yjty0Xfq4tRxYlkjPKdyS3mnb/wKeqNZAEEImdW0S8KLSJm15IP4M5fkwEsfnMKiyveBCN3aoQsafTHqq1F5zo4t5IrVvIWVdpxtmhF31JIVtOeSVCeHv/9hxUzMolNjxn2pa5+nrdZw0t/eqK7t8wC1e8yVu+lvT9h6vT0y0BCsbEk9TqYwLzVrVajaHsAFFIffCcxHanPsaRpRvxIknyfNaDzkueXrZR9xSQx460lEK5y988aRBTZ2lz4Z3nseQ9VdMN4Poyq2RdFLR11PCfiE2sojCVMA1MkbFgjJHQAwBqWMY3+5ZY5vlR/zcZTWoTTGDXcpHducZbDVH4rjBYk4MsgdaSudUkHLJ9EHE2T8Bu/DhDeQBFKkrzBFNqj+U8Jx1xmV6AhZUMOq56QpY3XXfYojGV3a64YL4b+RyKz3325HyhCMjJyYX7XsMYq5Wijw9sWlftrt7fP3WShzpTlqtD4= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3141.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a4503c5-651c-4fd5-a2be-08d81eab162c X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jul 2020 17:12:23.1061 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 1uT0wECCpVtHWiJxt8wlA+fqe5yLNE9npw4K7AUHr6TQVXS/DReA/TSo5HbbG9uGs2Aycov2KRP6vIDfkEpfwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3656 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3304EA2429 X-Rspamd-UID: ee6b32 Hi Marcel, > -----Original Message----- > From: linux-bluetooth-owner@vger.kernel.org owner@vger.kernel.org> On Behalf Of Marcel Holtmann > Sent: Thursday, July 2, 2020 6:56 PM > To: K, Kiran > Cc: linux-bluetooth ; Srivatsa, Ravishan= kar > ; Tumkur Narayan, Chethan > ; kiraank@gmail.com; Bag, Amit K > ; Raghuram Hegde > Subject: Re: [PATCH 2/5] Bluetooth: btintel: Refactor firmware header > download sequence >=20 > Hi Kiran, >=20 > > Move firmware header download code to a separate function to enhance > > readability and reusability > > > > Signed-off-by: Kiran K > > Signed-off-by: Amit K Bag > > Signed-off-by: Raghuram Hegde > > Reviewed-by: Chethan T N > > Reviewed-by: Sathish Narasimman > > Reviewed-by: Srivatsa Ravishankar > > --- > > drivers/bluetooth/btintel.c | 21 +++++++++++++++++---- > > 1 file changed, 17 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c > > index dea96c585ecb..1c820c187421 100644 > > --- a/drivers/bluetooth/btintel.c > > +++ b/drivers/bluetooth/btintel.c > > @@ -646,12 +646,10 @@ int btintel_read_boot_params(struct hci_dev > > *hdev, } EXPORT_SYMBOL_GPL(btintel_read_boot_params); > > > > -int btintel_download_firmware(struct hci_dev *hdev, const struct firmw= are > *fw, > > - u32 *boot_param) > > +static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev, > > + const struct firmware *fw) > > { > > int err; > > - const u8 *fw_ptr; > > - u32 frag_len; > > > > /* Start the firmware download transaction with the Init fragment > > * represented by the 128 bytes of CSS header. > > @@ -679,6 +677,21 @@ int btintel_download_firmware(struct hci_dev > *hdev, const struct firmware *fw, > > bt_dev_err(hdev, "Failed to send firmware signature (%d)", > err); > > goto done; > > } >=20 > Here should be an extra empty line before the label. Ack. I will fix it in v2. >=20 > > +done: > > + return err; > > +} > > + > > +int btintel_download_firmware(struct hci_dev *hdev, const struct firmw= are > *fw, > > + u32 *boot_param) > > +{ > > + int err; > > + const u8 *fw_ptr; > > + u32 frag_len; > > + > > + err =3D btintel_sfi_rsa_header_secure_send(hdev, fw); > > + if (err) > > + goto done; > > + >=20 > Scrap the extra empty line here. Ack. >=20 > > > > fw_ptr =3D fw->data + 644; > > frag_len =3D 0; >=20 > Regards >=20 > Marcel Thanks, Kiran Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IEyfK0sX/l42XQAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 19:20:11 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gBxXKksX/l4mQQEAlp8NpQ (envelope-from ); Thu, 02 Jul 2020 19:20:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 28C8C41952; Thu, 2 Jul 2020 19:20:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727072AbgGBRUF (ORCPT + 1 other); Thu, 2 Jul 2020 13:20:05 -0400 Received: from mga14.intel.com ([192.55.52.115]:61837 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726754AbgGBRUF (ORCPT ); Thu, 2 Jul 2020 13:20:05 -0400 IronPort-SDR: mQDG8grOP6uq29ubO3h7+bwHsd6nJN0DtG3mmwyYCIhfoMYXjlRvrjfdGwAZK+gLTmT77XPhXN 71fp7MB/1GRA== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="146058949" X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="146058949" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 10:20:03 -0700 IronPort-SDR: wQoNgPn+kD71zUVLijOimitpYIEjNsi4loBp/pdITqkf6Vp0dmgkKUGGoTOQ5xRj40T8GQSc86 3APPzPfRfLEA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="295964218" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga002.jf.intel.com with ESMTP; 02 Jul 2020 10:20:03 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Jul 2020 10:20:03 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 2 Jul 2020 10:20:02 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 2 Jul 2020 10:20:02 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.177) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Jul 2020 10:20:02 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RQR1XfcfPwo5j8Ig5uzIntfw2Ri7jy62aQ3velA+livXr9H63+UJvyeEJWqAwBs2avYfgRYeZshueXSSuz2I99Aj13jn4zGAwcjTFI+BbOUcVYRZdCsViKTpmnxJJhZ5wPs2ycR53qFBSTlOz4WHkGMzHsLU4QTnMLjj7r1Y5IMl33aK6lAwier3HzFuxNgrlLZl2jsZU1xMuFgLh/oXzyRaXXP4j8wyxyXTFMmAIR6jCccPsn7RPhNLMK77+etwGzoMIduq3foOL+DUf2uMffPj04rlZ4GvVuMbKI/WAtxKawFVPphmW5T8qr17IE1DpvQ11ii1wclSu7aQ5aWg2g== 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-SenderADCheck; bh=J+LOiogd6+ssSETNzLYKDdo3V3efi2b4aMgdkRMDzcU=; b=A6KOQ+hyBOcFcUWcsVzZCHFVANFF8mkC/oV0z8iRxQpgwqcA252dAsdUk8u2RJHUYqtYvuk/QYXTIsW7dXpNzWWsTtgbAUW8Tb6qaHhvP3HZnfCLLyQb2cSaSG2sFoZ00WMKaCMRsZX29f05J9oYbVJG0DoP6OH1z+oxEoJBz06yc9uQCIPWwuXPRpgzZvBGeIYQ8b3/JNzzuhP8lzbQACbldAapOnlKCCfu3k0NLaMAMlGbBu+IqaoaKytoJhH4EmILtzaQAKcsM1UiF5DZYmIkA3VAPDufNQweeUHMgTw0LNZRHjUL+Yt8BxzlYIH9IQ5eululko6+9CUcK/hV7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J+LOiogd6+ssSETNzLYKDdo3V3efi2b4aMgdkRMDzcU=; b=m9pXUzMmXEqRjIYVLfQzBHLs5d5702WsnAMP8yNidaQQmxLmIasHKB50vt5fwRCLv9Dq8y7e904Wzgp2JJZw4QTPbtNnXXL3nezqD4/0ZNSynRMPvQNcQrfBrFfzOsVb6Hs5TwrUM1TWqhWceDZ84zFGvTHrrad5au68HB+Z7wY= Received: from BYAPR11MB3141.namprd11.prod.outlook.com (2603:10b6:a03:8d::13) by BY5PR11MB3991.namprd11.prod.outlook.com (2603:10b6:a03:186::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22; Thu, 2 Jul 2020 17:20:01 +0000 Received: from BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::9ce5:c8f4:581b:9d9f]) by BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::9ce5:c8f4:581b:9d9f%5]) with mapi id 15.20.3131.028; Thu, 2 Jul 2020 17:20:01 +0000 From: "K, Kiran" To: Marcel Holtmann CC: linux-bluetooth , "Srivatsa, Ravishankar" , "Tumkur Narayan, Chethan" , "kiraank@gmail.com" , "Bag, Amit K" , Raghuram Hegde Subject: RE: [PATCH 3/5] Bluetooth: btintel: Refactor firmware payload download code Thread-Topic: [PATCH 3/5] Bluetooth: btintel: Refactor firmware payload download code Thread-Index: AQHWUGimk4Dw0MgRiESE22VK2LjDvqj0SFyAgAA+vJA= Date: Thu, 2 Jul 2020 17:20:01 +0000 Message-ID: References: <20200702120315.26768-1-kiran.k@intel.com> <20200702120315.26768-4-kiran.k@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.2.0.6 dlp-product: dlpe-windows authentication-results: holtmann.org; dkim=none (message not signed) header.d=none;holtmann.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.79.96] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7c5d2048-b554-449f-1cac-08d81eac271e x-ms-traffictypediagnostic: BY5PR11MB3991: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 0452022BE1 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Zf70rsBiaSWvsh9CWnNZamMwfwG22hadIgmC7DGi01q8XqBvRAwDHwRdDmr8fdOg9lVpykUDS5S6/9DTFuwL22ggNBLH2hsgxRSaSiggpQq3aD97ZxupvpwphMTmKjQWA/P5/g3lT7sZ6GOgTiTqJARJ54tdFv+D9ETd9RlDwPRsg6PJGhlu79q3ACeVmEyMubYxmASlhzLn0B1snIqgtuHfT/WZgJ5Huwt9DPz2kT3AhJr8Ku2cW+a+mYRcx0wzJbnDiNT+pW+B2nGmuSr/cubJTVAXNY9bYmisZmNoPvicTpQrGUy/b2ZUD6s7pJw2L1fn6o/bR5uwbioHeYfdLw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3141.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(396003)(346002)(376002)(39860400002)(366004)(107886003)(9686003)(4744005)(86362001)(83380400001)(66446008)(316002)(5660300002)(64756008)(66556008)(54906003)(66946007)(33656002)(66476007)(186003)(52536014)(6506007)(76116006)(71200400001)(53546011)(26005)(4326008)(6916009)(55016002)(7696005)(478600001)(2906002)(8676002)(8936002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: BtX8X72JecXPRr6Zb3fthV5fD/a5eqXTsvOLA7aHM770zuNPIgq1fsnpXKPs21/BlxN46wNszF5kJjhIRmH0h31GBWPzcDkjjGYSz/HtaXXFVuxurXMGfJLCYlI4sVqhCxHYWrYshzxaI2uqdEqKJIrvn6Uzl1sexTz4pzvN0+w5Ws4WuP1sL7MnQImbypx2lQ/vprXuvz+6I9YQJh2PoY3dzQTyGcayg5VQ+qKlh9DN4ooJzs6ncDKNaTvnG9zvWYPMIHlHiNek9Q8EON3tQ2EJv6Nv7LIjMiYOohIOscKfvCdfVfoIaraWuFbwZUKzna44bb2XKiBPw/SoEHgBiRTKOlkH+Y+pqmyYXkociIQQWui0oVD71U69KvI7EZmTbzGFAax9ikftWVtvVy+wFFUQPAbV7K31Q5n5psHedBfHYYKMJtfuCSwGXGnfW6jukFUGg+3ZK+sW4Nw/y9N5UjrNEMr6yd4EnhCxe39zCzg= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3141.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c5d2048-b554-449f-1cac-08d81eac271e X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jul 2020 17:20:01.0779 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 9DxwQYQ7US0IxAh0ECxbs+DJTO17Gab0fry8OuULBFPxW/Bu0PhgcQl4LEPE9iLBSQV1edjuOYFj6qNU6k8NsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB3991 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 28C8C41952 X-Rspamd-UID: 4b7e52 Hi Marcel, > -----Original Message----- > From: Marcel Holtmann > Sent: Thursday, July 2, 2020 6:58 PM > To: K, Kiran > Cc: linux-bluetooth ; Srivatsa, Ravishan= kar > ; Tumkur Narayan, Chethan > ; kiraank@gmail.com; Bag, Amit K > ; Raghuram Hegde > Subject: Re: [PATCH 3/5] Bluetooth: btintel: Refactor firmware payload > download code >=20 > Hi Kiran, >=20 > > Move firmware payload download code to a separate function to enhance > > readability and reusability >=20 > this patch is doing more than that. It also introduces an extra public fu= nction. The existing firmware download function is suffixed with "_legacy" to disti= nguish from an upcoming method to support firmware download in tlv format. = I will retain the older one as it is and use "_tlv" suffix for new one wit= hout losing the intention of the methods. I will send the changes in the ne= xt version. >=20 > Regards >=20 > Marcel Thanks, Kiran Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gDgME0gY/l42XQAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 19:24:24 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qPlREUgY/l5WYgEAlp8NpQ (envelope-from ); Thu, 02 Jul 2020 19:24:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 68A794014C; Thu, 2 Jul 2020 19:24:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727005AbgGBRYR (ORCPT + 1 other); Thu, 2 Jul 2020 13:24:17 -0400 Received: from mga07.intel.com ([134.134.136.100]:26787 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726934AbgGBRYR (ORCPT ); Thu, 2 Jul 2020 13:24:17 -0400 IronPort-SDR: lzxIlYem1C2jE5FpQXUKrufeDhMeTBXLA6z2sD5QJLNRBUH4PPhN43xwbE9994naY8E9d4I0Ht CArKCKPu4idw== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="212014811" X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="212014811" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 10:24:16 -0700 IronPort-SDR: u6C72pysQ3Kk/b6iNfvek/e+1iKwPfxfJFigTZabkV3jlrILFjmTm8hEOBMKq9FrAwPN0O/mSL iPYo78WQmZfA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,304,1589266800"; d="scan'208";a="313088323" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga008.jf.intel.com with ESMTP; 02 Jul 2020 10:24:16 -0700 Received: from fmsmsx161.amr.corp.intel.com (10.18.125.9) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Jul 2020 10:24:15 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by FMSMSX161.amr.corp.intel.com (10.18.125.9) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Jul 2020 10:24:15 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.45) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Jul 2020 10:24:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HSnbhzIfKUIOMA6bpV4O9wnypbIftNq1lEz4eUelCOGJkYNPzvvBufHz8fE6q8fjSeZs5eQvCY09Qptyhn9aCQ1VA4wdH8EsOoFP7XlLUfZj9SskS5aI1W8YXIbt+25DqCgoE0EMKNkk2LZWH3C8WDAkdv1TyFelE3GXcTRb4HEGndRNWGsD0UThClU9S5YRhmeA8xXHKgJbv/sv0gYcix4eS5kefGxeb1ZJnDc/U09XUSqt5v5qvAr7zFDWMbSQtDr8sEA/YTdXTHjEV/HYMcD3h9fkQaBWAdLYecNlkCrSUGD7Ika/gm1tLmgtusdpDMVF7wyIZZSptboEhRkbww== 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-SenderADCheck; bh=a09VmOj/5WsnV84MDFG3n6Y+fFOmBkorq5drbILtQ6k=; b=QHqI6TO3GzEbFUSAQWYtosxZwADmgOF5LhAaPpgrL9nQkifpK5wXK6iYsiA//Tbsm2gm++bwY/zqcbCdL2YDLoD1awWPdwMD/Cppx0Tc82o3a4ygZhHg36NuGFsTwIDew93rHtr47xEBjPk+j5m8XUoEX94LXLnvU5cs9Go4dCZ/WD2WQmBdOl07mug5YxCmFCS/Sx54Hy//hvSN9Urv7S9WK8MkipM9l9m22jN2vV+6UexOikbpm90eZWEejp6Pl1Rfy/ANd47PwzeEZrjSPuLoR0Ag/PYYRtCWU2QOSfMtYq2FP8kCuNaY52iabbxuqLU7IxnEMtIIhheysNrgQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a09VmOj/5WsnV84MDFG3n6Y+fFOmBkorq5drbILtQ6k=; b=K0wHeUcvbc/MaqjTVTKXB3iBssTowmXcb7bLf6V8Rda6J7ZvDuv05br14G1Kin+N6WTzjp29TeMIt+lgdGEo9t+K+gjBoF0K2ch3yd/kiLZiN13n07B8/0FPyz7zGTHOIHWW8p3rjLskb+PpPvMG/3/tGiTGAPeM9anaPaq5Pmg= Received: from BYAPR11MB3141.namprd11.prod.outlook.com (2603:10b6:a03:8d::13) by BYAPR11MB2709.namprd11.prod.outlook.com (2603:10b6:a02:be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.25; Thu, 2 Jul 2020 17:24:13 +0000 Received: from BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::9ce5:c8f4:581b:9d9f]) by BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::9ce5:c8f4:581b:9d9f%5]) with mapi id 15.20.3131.028; Thu, 2 Jul 2020 17:24:13 +0000 From: "K, Kiran" To: Marcel Holtmann CC: linux-bluetooth , "Srivatsa, Ravishankar" , "Tumkur Narayan, Chethan" , "kiraank@gmail.com" , "Bag, Amit K" , Raghuram Hegde Subject: RE: [PATCH 5/5] Bluetooth: btintel: Parse controller information present in TLV format Thread-Topic: [PATCH 5/5] Bluetooth: btintel: Parse controller information present in TLV format Thread-Index: AQHWUGinV5pHoaB/c0WTx+kkMcqVYKj0SiIAgAA/QpA= Date: Thu, 2 Jul 2020 17:24:13 +0000 Message-ID: References: <20200702120315.26768-1-kiran.k@intel.com> <20200702120315.26768-6-kiran.k@intel.com> <0CCCE1DA-3700-4B8C-A75B-D98D07F51782@holtmann.org> In-Reply-To: <0CCCE1DA-3700-4B8C-A75B-D98D07F51782@holtmann.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.2.0.6 dlp-product: dlpe-windows authentication-results: holtmann.org; dkim=none (message not signed) header.d=none;holtmann.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.79.96] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 684e5e96-e2a5-4a43-4f8c-08d81eacbd53 x-ms-traffictypediagnostic: BYAPR11MB2709: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1332; x-forefront-prvs: 0452022BE1 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: APenwBCz8T0oWUAoT3iJ1cokZpOkP0x77PBM8IB1JbftFh8sR7QPzFUWellX1+rvKuYPUPj1p1ScI6oamBf42lzGQEacKAL7++UOq7aclg3z6ywlLOQx+kb+d+IgjjvgwskIPI8XfyiV1uhh95uXznmglaC86O/btHa8Ep5DxrBnJ00HsO5PrvlRccGw5NhfYq2WoUYCOg3HG5lanAauLRqB/eu9HV0DyrVXHNzMee9C4QnumF9X6qS1Pbnsu64ThWqJ+iPIMJE3LCfG06p19GEPy+4jkMZTZ4Cq+L5CxImo14wQqoGsi/h5aYe6RPRc3J5qy54M8sfaVKLycRQgIg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3141.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(136003)(376002)(346002)(39860400002)(366004)(7696005)(76116006)(54906003)(8676002)(66946007)(55016002)(66446008)(2906002)(9686003)(5660300002)(6916009)(64756008)(66556008)(107886003)(66476007)(52536014)(478600001)(316002)(4326008)(71200400001)(53546011)(6506007)(83380400001)(33656002)(86362001)(26005)(186003)(8936002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: hxyyFCMpOzZMb5rlxPkEFv3eo7JCQMTfN9aCfRh2MwwYtn7fEHJfpEJteYmBnwLjM+18xGSvlYPh4oKY7iRh9fuxiCdM4VGrfD7oshAMNfbYT3Y+cZ/a33A6igqs2Iz7YW7kMfWPFPKQROQniYq5U+o7B+yrml0wZp/OpApuk7a6Fu5xjh/0MqS/EN1xNxWwGTTKXP36lnEqOfQGo1sexgeN2bfDe6x8UJTeezLHYWLpQbVPd9xTktQRnMCGItHgL16l1Xkq+NDaWrHVJH7Cts5lkwVMCsYWCedohs2HW72T/ku8+2lqsuB+utR7VaZh6IFyMLDuANFIo3BnIdJzSavdpu531vl9c9LElsb+nOJAOCvMBpD6DuSWwCPa90qyGs9EF5ALfJTie4/Hst04/Uin2h8ETauThzFS7sjDI+oF3Y2MTho0Nrcqx7oijfREOcPt+FA2lrJUJ7PAz0zmTJpLweil93Uc5PmXDmnMjHo= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3141.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 684e5e96-e2a5-4a43-4f8c-08d81eacbd53 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jul 2020 17:24:13.0368 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: f9gBTWVWuEbeAabV2L8C55dtI85YdsgXb/rj8c6Noh3jYeCavg58SyJD4gLrTEE6h/p9gIHaZFUr9fWC6K6Opg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2709 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 68A794014C X-Rspamd-UID: 753355 Hi Marcel, > -----Original Message----- > From: linux-bluetooth-owner@vger.kernel.org owner@vger.kernel.org> On Behalf Of Marcel Holtmann > Sent: Thursday, July 2, 2020 7:04 PM > To: K, Kiran > Cc: linux-bluetooth ; Srivatsa, Ravishan= kar > ; Tumkur Narayan, Chethan > ; kiraank@gmail.com; Bag, Amit K > ; Raghuram Hegde > Subject: Re: [PATCH 5/5] Bluetooth: btintel: Parse controller information > present in TLV format >=20 > Hi Kiran, >=20 > > New generation Intel controllers returns controller information in TLV > > format. Adding capability to parse and log it for debug purpose > > > > Signed-off-by: Kiran K > > Signed-off-by: Amit K Bag > > Signed-off-by: Raghuram Hegde > > Reviewed-by: Chethan T N > > Reviewed-by: Sathish Narasimman > > Reviewed-by: Srivatsa Ravishankar > > --- > > drivers/bluetooth/btintel.c | 161 ++++++++++++++++++++++++++++++++---- > > drivers/bluetooth/btusb.c | 4 +- > > 2 files changed, 148 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c > > index d0c6576212d7..f0b087d97a83 100644 > > --- a/drivers/bluetooth/btintel.c > > +++ b/drivers/bluetooth/btintel.c > > @@ -209,27 +209,59 @@ void btintel_version_info(struct hci_dev *hdev, > > const struct btintel_version *ve { > > const char *variant; > > const struct intel_version *ver; > > + const struct intel_version_tlv *ver_tlv; > > > > - if (version->is_tlv_supported) > > - return; > > + if (!version->is_tlv_supported) { > > + ver =3D &version->intel_version; > > + > > + switch (ver->fw_variant) { > > + case 0x06: > > + variant =3D "Bootloader"; > > + break; >=20 > The break; has to be indented with the variant =3D. Ack. checkpatch.pl didn't report any warning/error for this issue :(. I w= ill fix it in the next patch. >=20 > > + case 0x23: > > + variant =3D "Firmware"; > > + break; > > + default: > > + goto done; > > + } > > > > - ver =3D &version->intel_version; > > + bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u", > > + variant, ver->fw_revision >> 4, > > + ver->fw_revision & 0x0f, ver->fw_build_num, > > + ver->fw_build_ww, 2000 + ver->fw_build_yy); > > + goto done; > > + } > > + > > + ver_tlv =3D &version->intel_version_tlv; > > > > - switch (ver->fw_variant) { > > - case 0x06: > > + switch (ver_tlv->img_type) { > > + case 0x01: > > variant =3D "Bootloader"; > > - break; > > - case 0x23: > > + bt_dev_info(hdev, "Device revision is %u", ver_tlv- > >dev_rev_id); > > + bt_dev_info(hdev, "Secure boot is %s", > > + ver_tlv->secure_boot ? "enabled" : "disabled"); > > + bt_dev_info(hdev, "OTP lock is %s", > > + ver_tlv->otp_lock ? "enabled" : "disabled"); > > + bt_dev_info(hdev, "API lock is %s", > > + ver_tlv->api_lock ? "enabled" : "disabled"); > > + bt_dev_info(hdev, "Debug lock is %s", > > + ver_tlv->debug_lock ? "enabled" : "disabled"); > > + bt_dev_info(hdev, "Minimum firmware build %u week %u > %u", > > + ver_tlv->min_fw_build_nn, ver_tlv- > >min_fw_build_cw, > > + 2000 + ver_tlv->min_fw_build_yy); > > + break; > > + case 0x03: > > variant =3D "Firmware"; > > - break; > > + break; > > default: > > - return; > > + goto done; > > } > > > > - bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u", > > - variant, ver->fw_revision >> 4, ver->fw_revision & 0x0f, > > - ver->fw_build_num, ver->fw_build_ww, > > - 2000 + ver->fw_build_yy); > > + bt_dev_info(hdev, "%s timestamp %u.%u buildtype %u build %u", > variant, > > + 2000 + (ver_tlv->timestamp >> 8), ver_tlv->timestamp & 0xff, > > + ver_tlv->build_type, ver_tlv->build_num); > > +done: > > + return; > > } > > EXPORT_SYMBOL_GPL(btintel_version_info); > > > > @@ -346,6 +378,8 @@ int btintel_read_version(struct hci_dev *hdev, > > struct btintel_version *version) { > > struct sk_buff *skb; > > u8 *data, param, status, check_tlv; > > + struct intel_version_tlv *ver_tlv; > > + struct intel_tlv *tlv; > > > > if (!version) > > return -EINVAL; > > @@ -373,9 +407,106 @@ int btintel_read_version(struct hci_dev *hdev, > struct btintel_version *version) > > if (skb->len =3D=3D sizeof(version->intel_version) && check_tlv =3D=3D= 0x37) { > > memcpy(&version->intel_version, skb->data, sizeof(version- > >intel_version)); > > version->is_tlv_supported =3D false; > > - } else { > > - version->is_tlv_supported =3D true; > > + goto done; > > } > > + > > + bt_dev_info(hdev, "Supports tlv firmware download sequence"); > > + version->is_tlv_supported =3D true; > > + ver_tlv =3D &version->intel_version_tlv; > > + > > + /* Consume Command Complete Status field */ > > + skb_pull(skb, 1); > > + > > + /* Event parameters contatin multiple TLVs. Read each of them > > + * and only keep the required data. Also, it use existing legacy > > + * version field like hw_platform, hw_variant, and fw_variant > > + * to keep the existing setup flow > > + */ > > + while (skb->len) { > > + tlv =3D (struct intel_tlv *)skb->data; > > + switch (tlv->type) { > > + case INTEL_TLV_CNVI_TOP: > > + ver_tlv->cnvi_top =3D (tlv->val[3] << 24) | > > + (tlv->val[2] << 16) | > > + (tlv->val[1] << 8) | > > + (tlv->val[0]); >=20 > We have get_unaligned functions for that. >=20 Ack.=20 > > + break; > > + case INTEL_TLV_CNVR_TOP: > > + ver_tlv->cnvr_top =3D (tlv->val[3] << 24) | > > + (tlv->val[2] << 16) | > > + (tlv->val[1] << 8) | > > + (tlv->val[0]); > > + break; > > + case INTEL_TLV_CNVI_BT: > > + ver_tlv->cnvi_bt =3D (tlv->val[3] << 24) | > > + (tlv->val[2] << 16) | > > + (tlv->val[1] << 8) | > > + (tlv->val[0]); > > + break; > > + case INTEL_TLV_CNVR_BT: > > + ver_tlv->cnvr_bt =3D (tlv->val[3] << 24) | > > + (tlv->val[2] << 16) | > > + (tlv->val[1] << 8) | > > + (tlv->val[0]); > > + break; > > + case INTEL_TLV_USB_VENDOR_ID: > > + ver_tlv->usb_vid =3D (tlv->val[1] << 8) | (tlv->val[0]); > > + break; > > + case INTEL_TLV_USB_PRODUCT_ID: > > + ver_tlv->usb_pid =3D (tlv->val[1] << 8) | (tlv->val[0]); > > + break; > > + case INTEL_TLV_IMAGE_TYPE: > > + ver_tlv->img_type =3D tlv->val[0]; > > + break; > > + case INTEL_TLV_TIME_STAMP: > > + ver_tlv->timestamp =3D (tlv->val[1] << 8) | (tlv->val[0]); > > + break; > > + case INTEL_TLV_BUILD_TYPE: > > + ver_tlv->build_type =3D tlv->val[0]; > > + break; > > + case INTEL_TLV_BUILD_NUM: > > + ver_tlv->build_num =3D (tlv->val[3] << 24) | > > + (tlv->val[2] << 16) | > > + (tlv->val[1] << 8) | > > + (tlv->val[0]); > > + break; > > + case INTEL_TLV_SECURE_BOOT: > > + ver_tlv->secure_boot =3D tlv->val[0]; > > + break; > > + case INTEL_TLV_KEY_FROM_HDR: > > + ver_tlv->key_from_hdr =3D tlv->val[0]; > > + break; > > + case INTEL_TLV_OTP_LOCK: > > + ver_tlv->otp_lock =3D tlv->val[0]; > > + break; > > + case INTEL_TLV_API_LOCK: > > + ver_tlv->api_lock =3D tlv->val[0]; > > + break; > > + case INTEL_TLV_DEBUG_LOCK: > > + ver_tlv->debug_lock =3D tlv->val[0]; > > + break; > > + case INTEL_TLV_MIN_FW: > > + ver_tlv->min_fw_build_nn =3D tlv->val[0]; > > + ver_tlv->min_fw_build_cw =3D tlv->val[1]; > > + ver_tlv->min_fw_build_yy =3D tlv->val[2]; > > + break; > > + case INTEL_TLV_LIMITED_CCE: > > + ver_tlv->limited_cce =3D tlv->val[0]; > > + break; > > + case INTEL_TLV_SBE_TYPE: > > + ver_tlv->sbe_type =3D tlv->val[0]; > > + break; > > + case INTEL_TLV_OTP_BDADDR: > > + memcpy(&ver_tlv->otp_bd_addr, tlv->val, tlv->len); > > + break; > > + default: > > + /* Ignore rest of information */ > > + break; > > + } > > + /* consume the current tlv and move to next*/ > > + skb_pull(skb, tlv->len + sizeof(*tlv)); > > + } > > +done: > > kfree_skb(skb); > > return 0; > > } > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > > index 364da6d44ee3..f30b43e15a26 100644 > > --- a/drivers/bluetooth/btusb.c > > +++ b/drivers/bluetooth/btusb.c > > @@ -2519,13 +2519,13 @@ static int btusb_setup_intel_new(struct hci_dev > *hdev) > > return err; > > } > > > > + btintel_version_info(hdev, &version); > > + > > if (version.is_tlv_supported) { > > bt_dev_err(hdev, "Firmware download in tlv format is not > supported"); > > return -EOPNOTSUPP; > > } > > > > - btintel_version_info(hdev, &version); > > - > > err =3D btusb_intel_download_firmware(hdev, &version, ¶ms); > > if (err) > > return err; >=20 > Regards >=20 > Marcel Thanks, Kiran Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cJUHJXAb/l4AZQAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 19:37:52 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id GN8XI3Ab/l6GIAAADc0bRg (envelope-from ); Thu, 02 Jul 2020 19:37:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5CADEA3182; Thu, 2 Jul 2020 19:37:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727891AbgGBRhp (ORCPT + 1 other); Thu, 2 Jul 2020 13:37:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727882AbgGBRhp (ORCPT ); Thu, 2 Jul 2020 13:37:45 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BF4CC08C5C1 for ; Thu, 2 Jul 2020 10:37:45 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id q7so20042576ljm.1 for ; Thu, 02 Jul 2020 10:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Hjypz7hFyFKrs0DnFxsXcBRXvUNFSdjgwsRh4IgaA38=; b=s0VX9fWqu4Uc55ZWvRMyuapD9SZPgcQRA706bED0/IyCXRexdcElq9tutq3md5ZWMc e5jsAdZJo6xsqcLH4DJMEax7/XZY/agO4ll7I8H69qrNwC7e0rrminUfkK5qF7MKw+2q M6VQmTCFywCyo4I9347JGxQJ3giC7JiMVQPMGF9KzIdehutmOkyDLcE1JlYrQCMZqAwZ T78mzFdOwTsxl+tU2NcSu0lWOnwm/9Tp1PubkTPuxEcMyVN0fJN7E/GbgeubQtOGzQPe 5QZ7BZvtAzjQQOvsf1d5lHCjaBS/Uz5KUfBGG+E1pEwL5YYygLN8iVlayHk3WnGObpOO LQDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Hjypz7hFyFKrs0DnFxsXcBRXvUNFSdjgwsRh4IgaA38=; b=IexdHhbRUuYJOn9+mLKG5WalO0RLDsSa16i+8QCPdTvrxZCQ8O4kgpXLvNsaTjwlCI zsjh8OpS9Pgf3tT4uNdBxOwkfIZS1IDbVBhZDpyiejLnoUySXHRshNr2xGkDRggFL3do Xtrhp8Vn3g2X6YGmGqlS3g/juvjOnhY7o704IUUjHdKId7czLz+AakWPslYoBckVK/fP wO5SLWOextP7YL5zTE+GnnySgnoFh8K0b9SYLa/dQ29cnwAYVUfwS6yWN1Vgqu7h7ANl epjec8orvsgWBZJdxwTXb8GProzA6W2jD3ud4F0GkjoECx+7X6f2EjnUjNYSRuC6x1uN UCSQ== X-Gm-Message-State: AOAM530lUm86EmI7RDJze9WUZzJeusk2nL7GXBVVz9FnV9hTaLj9i4Wa FCz0BxAYnFBSUP9GKjdYeQ4n/kRVu5YlmJUJNrckHPKP9G0= X-Google-Smtp-Source: ABdhPJz5o6Vok/n2Vp8zN8pvbrZiV0oIyQZl4Iq36noUv/1OdSv+B5D/x2Z6NX7XgNYxnSnJT1xNv8VyXL+aTI/K9OY= X-Received: by 2002:a2e:7019:: with SMTP id l25mr3791002ljc.256.1593711463048; Thu, 02 Jul 2020 10:37:43 -0700 (PDT) MIME-Version: 1.0 References: <20200701220853.421445-1-alainm@chromium.org> <427B6E1C-178C-405D-88F8-899EC48AC8A9@holtmann.org> In-Reply-To: From: Alain Michaud Date: Thu, 2 Jul 2020 13:37:31 -0400 Message-ID: Subject: Re: [PATCH v2] Bluetooth: le_supported_roles experimental feature To: Marcel Holtmann Cc: Alain Michaud , BlueZ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.14 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5CADEA3182 X-Rspamd-UID: 9a9732 On Thu, Jul 2, 2020 at 11:01 AM Alain Michaud wro= te: > > Resending as plaintext. > > > On Thu, Jul 2, 2020 at 10:59 AM Alain Michaud w= rote: > > > > Hi Marcel > > > > On Thu, Jul 2, 2020 at 9:18 AM Marcel Holtmann wr= ote: > >> > >> Hi Alain, > >> > >> > This patch adds an le_supported_roles features which allows a > >> > clients to determine if the controller is able to support peripheral= and > >> > central connections separately and at the same time. > >> > > >> > Signed-off-by: Alain Michaud > >> > --- > >> > > >> > Changes in v2: > >> > - Slight change of design based on offline feedback > >> > > >> > net/bluetooth/mgmt.c | 36 +++++++++++++++++++++++++++++++++++- > >> > 1 file changed, 35 insertions(+), 1 deletion(-) > >> > > >> > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > >> > index 5e9b9728eeac..c13fcc21745f 100644 > >> > --- a/net/bluetooth/mgmt.c > >> > +++ b/net/bluetooth/mgmt.c > >> > @@ -3753,10 +3753,36 @@ static const u8 debug_uuid[16] =3D { > >> > }; > >> > #endif > >> > > >> > +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ > >> > +static const u8 le_supported_roles[16] =3D { > >> > + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, > >> > + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > >> > +}; > >> > + > >> > +static u32 get_le_roles_flags(struct hci_dev *hdev) > >> > +{ > >> > + u32 flags =3D 0; > >> > + > >> > + /* Central connections supported */ > >> > + if (hdev->le_states[4] & 0x08) > >> > + flags |=3D BIT(0); > >> > + > >> > + /* Peripheral connections supported */ > >> > + if (hdev->le_states[4] & 0x40) > >> > + flags |=3D BIT(1); > >> > + > >> > + /* Simult central and peripheral connections supported */ > >> > + if (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && > >> > + (hdev->le_states[3] & 0x10)) > >> > + flags |=3D BIT(2); > >> > + > >> > + return flags; > >> > +} > >> > >> this is not what we can do here. The flags are defined like this. > >> > >> The following bits are defined for the Flags parameter: > >> > >> 0 Feature active > >> 1 Causes change in supported settings > >> > >> And I want these flags for generic handling of experimental features. = Individual features can not overwrite it. > >> > >> So if you only want to support a the =E2=80=9Cread" functionality, the= n something like this please. > >> > >> if ((hdev->le_states[4] & 0x08) && /* Central */ > >> (hdev->le_states[4] & 0x40) && /* Peripheral */ > >> (hdev->le_states[3] & 0x10) && /* Simultaneous */ > >> test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks)) > >> flags |=3D BIT(0); > >> > > OK, Since the userspace Api we discussed reports individual states, wou= ld you suggest if LE is supported that the Central and Peripheral roles are= supported and just use this to query the simultaneous support? Also, seems= like what you are suggesting looks a lot like v1. > > > >> > >> > + > >> > static int read_exp_features_info(struct sock *sk, struct hci_dev *h= dev, > >> > void *data, u16 data_len) > >> > { > >> > - char buf[42]; > >> > + char buf[44]; > >> > struct mgmt_rp_read_exp_features_info *rp =3D (void *)buf; > >> > u16 idx =3D 0; > >> > > >> > @@ -3774,6 +3800,14 @@ static int read_exp_features_info(struct sock= *sk, struct hci_dev *hdev, > >> > } > >> > #endif > >> > > >> > + if (hdev) { > >> > + memcpy(rp->features[idx].uuid, le_supported_roles, > >> > + sizeof(le_supported_roles)); > >> > + > >> > >> And I would put it all here instead of a separate function. > >> > >> > + rp->features[idx].flags =3D cpu_to_le32(get_le_roles_f= lags(hdev)); > >> > + ++idx; > >> > + } > >> > + > >> > rp->feature_count =3D cpu_to_le16(idx); > >> > > >> > /* After reading the experimental features information, enable > >> > >> Regards > >> > >> Marcel > >> Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8CkfAywh/l6nVAAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 20:02:20 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id KOjuACwh/l56LgAADc0bRg (envelope-from ); Thu, 02 Jul 2020 20:02:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8CC81529D4; Thu, 2 Jul 2020 20:02:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728050AbgGBSCM (ORCPT + 1 other); Thu, 2 Jul 2020 14:02:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727968AbgGBSCM (ORCPT ); Thu, 2 Jul 2020 14:02:12 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3848FC08C5C1 for ; Thu, 2 Jul 2020 11:02:12 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id v6so16164320iob.4 for ; Thu, 02 Jul 2020 11:02:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PhEY+ZLmgzCOdXaoAmlFY6h7wEgm4AErb9qvafvGMiM=; b=HxuUPhipxqBckpMBVK/bvcxHX7JLyRH3ekGJZnJVovoFYP4nVz734pEpCQzLS/YVCh soUiQTwzBIYcetILqZrKXHJqxyUots4KojV4muOslHISdEYFeqRhxFtYET3tdkDkhtvz ivWQkZegip1ibgkG+5FaLP9EjyDmJrCtH7vsk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PhEY+ZLmgzCOdXaoAmlFY6h7wEgm4AErb9qvafvGMiM=; b=q/piSfzxRUCRkA7BezaqJMquoIBBHgTNNWqQ+9ETn9WosrPlB8N4mTej7wCMu26h8X HjvJgd/3ogP3rl8As6ax8+lmU00p/B8nJS0bc7FUdXeZRT0vSS/BmR19KIXpTN2lxnXV CvOuQxR4i+rL+jBwFEcDvNGZk8AzMwmm8v1JYsEVy0GRXvOjk7xiud2wWqYowf14pMcz z8e5tULisGNWDxZ/OtwSG8vPStIPbGBAgyBRwpGYWUythxfr0YTEfTcRteb7Hu9CKoOY WTv24TQwXmPyG/h2Pn/hbPz0oxGG6SqMTKxSgQGmPiZPNVPJ/HtIHFaSLGqqkEag/kNb XFlA== X-Gm-Message-State: AOAM530xc+/et7hOZFibicOLSxJgoffYGHuaBHksjDbLtZJuB/q/7sC/ TYwa3YJZi7fLHOH3MWVr5laMB8HClPn3Hg== X-Google-Smtp-Source: ABdhPJwCzzxyJaGD/ZPW1o6GYX8vnIh/WTVLOeIJBFYfbvYx64yynbGj7r2XH2Ogq0yr47L+kBtbpA== X-Received: by 2002:a05:6602:2d89:: with SMTP id k9mr8592389iow.41.1593712931214; Thu, 02 Jul 2020 11:02:11 -0700 (PDT) Received: from localhost.localdomain (c-73-231-41-185.hsd1.ca.comcast.net. [73.231.41.185]) by smtp.googlemail.com with ESMTPSA id u6sm5097647ilg.32.2020.07.02.11.02.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 11:02:10 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka Subject: [PATCH v3] client: Add battery percentage to info command Date: Thu, 2 Jul 2020 11:01:55 -0700 Message-Id: <20200702180155.24260-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.13 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8CC81529D4 X-Rspamd-UID: c16bc4 This adds the Battery Percentage to the info command based on org.bluez.Battery1 API. Example usage: [bluetooth]# info XX:XX:XX:XX:XX:XX Device XX:XX:XX:XX:XX:XX (random) Name: ... Alias: ... ... Modalias: ... Battery Percentage: 0x64 (100) --- client/main.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/client/main.c b/client/main.c index 422da5593..c0b351aed 100644 --- a/client/main.c +++ b/client/main.c @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; static GDBusProxy *default_dev; static GDBusProxy *default_attr; static GList *ctrl_list; +static GList *battery_proxies; static const char *agent_arguments[] = { "on", @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) bt_shell_set_prompt(PROMPT_OFF); g_list_free_full(ctrl_list, proxy_leak); + g_list_free_full(battery_proxies, proxy_leak); ctrl_list = NULL; + battery_proxies = NULL; default_ctrl = NULL; } @@ -271,7 +274,7 @@ static void print_iter(const char *label, const char *name, break; case DBUS_TYPE_BYTE: dbus_message_iter_get_basic(iter, &byte); - bt_shell_printf("%s%s: 0x%02x\n", label, name, byte); + bt_shell_printf("%s%s: 0x%02x (%d)\n", label, name, byte, byte); break; case DBUS_TYPE_VARIANT: dbus_message_iter_recurse(iter, &subiter); @@ -309,14 +312,20 @@ static void print_iter(const char *label, const char *name, } } -static void print_property(GDBusProxy *proxy, const char *name) +static void print_property_with_label(GDBusProxy *proxy, const char *name, + const char *label) { DBusMessageIter iter; if (g_dbus_proxy_get_property(proxy, name, &iter) == FALSE) return; - print_iter("\t", name, &iter); + print_iter("\t", label ? label : name, &iter); +} + +static void print_property(GDBusProxy *proxy, const char *name) +{ + print_property_with_label(proxy, name, NULL); } static void print_uuid(const char *uuid) @@ -445,6 +454,16 @@ done: g_free(desc); } +static void battery_added(GDBusProxy *proxy) +{ + battery_proxies = g_list_append(battery_proxies, proxy); +} + +static void battery_removed(GDBusProxy *proxy) +{ + battery_proxies = g_list_remove(battery_proxies, proxy); +} + static void device_added(GDBusProxy *proxy) { DBusMessageIter iter; @@ -539,6 +558,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) gatt_add_manager(proxy); } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { ad_manager_added(proxy); + } else if (!strcmp(interface, "org.bluez.Battery1")) { + battery_added(proxy); } } @@ -630,6 +651,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) gatt_remove_manager(proxy); } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { ad_unregister(dbus_conn, NULL); + } else if (!strcmp(interface, "org.bluez.Battery1")) { + battery_removed(proxy); } } @@ -763,6 +786,20 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) return NULL; } +static GDBusProxy *find_battery_by_path(GList *source, const char *path) +{ + GList *list; + + for (list = g_list_first(source); list; list = g_list_next(list)) { + GDBusProxy *proxy = list->data; + + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) + return proxy; + } + + return NULL; +} + static GDBusProxy *find_proxy_by_address(GList *source, const char *address) { GList *list; @@ -1606,6 +1643,7 @@ static struct GDBusProxy *find_device(int argc, char *argv[]) static void cmd_info(int argc, char *argv[]) { GDBusProxy *proxy; + GDBusProxy *battery_proxy; DBusMessageIter iter; const char *address; @@ -1647,6 +1685,11 @@ static void cmd_info(int argc, char *argv[]) print_property(proxy, "AdvertisingFlags"); print_property(proxy, "AdvertisingData"); + battery_proxy = find_battery_by_path(battery_proxies, + g_dbus_proxy_get_path(proxy)); + print_property_with_label(battery_proxy, "Percentage", + "Battery Percentage"); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); } -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CJ2nKwsi/l4JsgAAvsO+Rg (envelope-from ) for ; Thu, 02 Jul 2020 20:06:03 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iPoWKgsi/l78iAEAlp8NpQ (envelope-from ); Thu, 02 Jul 2020 20:06:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E0A0EA2429; Thu, 2 Jul 2020 20:05:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727926AbgGBSF5 (ORCPT + 1 other); Thu, 2 Jul 2020 14:05:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726349AbgGBSF5 (ORCPT ); Thu, 2 Jul 2020 14:05:57 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3CFBC08C5C1 for ; Thu, 2 Jul 2020 11:05:56 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id r8so24382073oij.5 for ; Thu, 02 Jul 2020 11:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Luqimbir/57tQriFXcTbh2hWaUyPr2MwVfjaS7PtjWY=; b=UKJI1gBfEXwejkMPGNb1EiHRVaOAnGVyBacr6FwZSP4QBFjetEm9BR9RlTGSDNAESM MX2PvENNMbE6F2d7chHuxHyTabMznjrRxME10gnWhN1UM1ZQXw/ZtvuiLTWzo2G4l3nN hqAl7WqArT9YJ9z8Hn+6WBH/7Nnr294L3EmfY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Luqimbir/57tQriFXcTbh2hWaUyPr2MwVfjaS7PtjWY=; b=WpBFHw0xuz5wFAuylZhP/cibFBLowThgyDpSsWw7FmSymgC136lSnd035MPiffQF8Y QtDFIQ33UWTIGM8DEaf6kmsjXCccOi/On/D1e4zZSbxBEUkfNbZN6Ob5F4mDUSD4SBH4 ObNNqNHq1DsByZSCatVCrpkI5ssLY7SaYJKSipJ2AlRQZbGG1OAPwzROwtpESk3oYDsY Vg6q7ZKKH/u/enSbmXJtl6GTXRgc/aMe71VoKEnmHeE2HlJvQAe3BoKoJN9GIrOwhR28 6bxOwbUXz+JRofbEChDT+cwgl6YGWhfZygqbNrjDL0kYPmxD+8v9nWyQ6G0yCib/4Z1I aHuQ== X-Gm-Message-State: AOAM532iyTlTNLg1T+t0FztlTI6WPKSZ69Yca+3jiqYxTAxMfctWSSIS 1XLoqH0vTh+/J8nhC+N100us+R/rCFi4XROyLiwgu1B2zz0= X-Google-Smtp-Source: ABdhPJzCRQYR5ZclBRWxw6Nn8fSCjOYxcl+Sm/M9SWk6S4VnCr5aw9CsPYwUtkKQ5yjgtirNa9CuBI7k5FUXEVBRpyk= X-Received: by 2002:aca:c157:: with SMTP id r84mr16965301oif.136.1593713154852; Thu, 02 Jul 2020 11:05:54 -0700 (PDT) MIME-Version: 1.0 References: <20200701192202.9508-1-sonnysasaka@chromium.org> In-Reply-To: From: Sonny Sasaka Date: Thu, 2 Jul 2020 11:05:43 -0700 Message-ID: Subject: Re: [PATCH v2] client: Add battery percentage to info command To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.37 / 15.00 / 200.00 X-Rspamd-Queue-Id: E0A0EA2429 X-Rspamd-UID: 314574 Hi Luiz, I just sent another patch following your feedback. Please take another look. Thanks! On Thu, Jul 2, 2020 at 8:43 AM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Wed, Jul 1, 2020 at 11:06 PM Sonny Sasaka wrote: > > > > Hi Luiz, > > > > On Wed, Jul 1, 2020 at 10:20 PM Luiz Augusto von Dentz > > wrote: > > > > > > Hi Sonny, > > > > > > On Wed, Jul 1, 2020 at 12:24 PM Sonny Sasaka wrote: > > > > > > > > This adds the Battery Percentage to the info command based on > > > > org.bluez.Battery1 API. Example usage: > > > > > > > > [bluetooth]# info XX:XX:XX:XX:XX:XX > > > > Device XX:XX:XX:XX:XX:XX (random) > > > > Name: ... > > > > Alias: ... > > > > ... > > > > Modalias: ... > > > > Battery Percentage: 100% > > > > --- > > > > client/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > > > > 1 file changed, 43 insertions(+) > > > > > > > > diff --git a/client/main.c b/client/main.c > > > > index 422da5593..4b787240e 100644 > > > > --- a/client/main.c > > > > +++ b/client/main.c > > > > @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; > > > > static GDBusProxy *default_dev; > > > > static GDBusProxy *default_attr; > > > > static GList *ctrl_list; > > > > +static GList *battery_proxies; > > > > > > > > static const char *agent_arguments[] = { > > > > "on", > > > > @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) > > > > bt_shell_set_prompt(PROMPT_OFF); > > > > > > > > g_list_free_full(ctrl_list, proxy_leak); > > > > + g_list_free_full(battery_proxies, proxy_leak); > > > > ctrl_list = NULL; > > > > + battery_proxies = NULL; > > > > > > > > default_ctrl = NULL; > > > > } > > > > @@ -445,6 +448,16 @@ done: > > > > g_free(desc); > > > > } > > > > > > > > +static void battery_added(GDBusProxy *proxy) > > > > +{ > > > > + battery_proxies = g_list_append(battery_proxies, proxy); > > > > +} > > > > + > > > > +static void battery_removed(GDBusProxy *proxy) > > > > +{ > > > > + battery_proxies = g_list_remove(battery_proxies, proxy); > > > > +} > > > > + > > > > static void device_added(GDBusProxy *proxy) > > > > { > > > > DBusMessageIter iter; > > > > @@ -539,6 +552,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) > > > > gatt_add_manager(proxy); > > > > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > > > > ad_manager_added(proxy); > > > > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > > > > + battery_added(proxy); > > > > } > > > > } > > > > > > > > @@ -630,6 +645,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) > > > > gatt_remove_manager(proxy); > > > > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > > > > ad_unregister(dbus_conn, NULL); > > > > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > > > > + battery_removed(proxy); > > > > } > > > > } > > > > > > > > @@ -763,6 +780,20 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) > > > > return NULL; > > > > } > > > > > > > > +static GDBusProxy *find_battery_by_path(GList *source, const char *path) > > > > +{ > > > > + GList *list; > > > > + > > > > + for (list = g_list_first(source); list; list = g_list_next(list)) { > > > > + GDBusProxy *proxy = list->data; > > > > + > > > > + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) > > > > + return proxy; > > > > + } > > > > + > > > > + return NULL; > > > > +} > > > > + > > > > static GDBusProxy *find_proxy_by_address(GList *source, const char *address) > > > > { > > > > GList *list; > > > > @@ -1606,8 +1637,10 @@ static struct GDBusProxy *find_device(int argc, char *argv[]) > > > > static void cmd_info(int argc, char *argv[]) > > > > { > > > > GDBusProxy *proxy; > > > > + GDBusProxy *battery_proxy; > > > > DBusMessageIter iter; > > > > const char *address; > > > > + unsigned char percentage; > > > > > > > > proxy = find_device(argc, argv); > > > > if (!proxy) > > > > @@ -1647,6 +1680,16 @@ static void cmd_info(int argc, char *argv[]) > > > > print_property(proxy, "AdvertisingFlags"); > > > > print_property(proxy, "AdvertisingData"); > > > > > > > > + battery_proxy = find_battery_by_path(battery_proxies, > > > > + g_dbus_proxy_get_path(proxy)); > > > > > > I'd replace the lines below with just print_property(battery_proxy, > > > "Percentage"); and just make print_property check for NULL proxy if it > > > doesn't already. > > I tried this but the result doesn't look quite good: > > Device XX:XX:XX:XX:XX:XX (random) > > Name: ... > > ... > > Modalias: ... > > Percentage: 0x64 > > > > The name "Percentage" is not clear (what kind of percentage does it > > mean) when shown in the "info" command. And also the format for byte > > data type is hex and there is no percent sign. I tried to modify the > > print_property function to support custom format but the code gets > > overly complex and I think it's more straightforward to use custom > > logic like in this patch. > > Just make it always print both the decimal and (hex). > > > > > > > > + if (battery_proxy && g_dbus_proxy_get_property( > > > > + battery_proxy, "Percentage", &iter)) { > > > > + dbus_message_iter_get_basic(&iter, &percentage); > > > > + bt_shell_printf("\tBattery Percentage: %d%%\n", percentage); > > > > + } else { > > > > + bt_shell_printf("\tNo battery information\n"); > > > > + } > > > > + > > > > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > > > > } > > > > > > > > -- > > > > 2.17.1 > > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qD9RK09a/l7njwEAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 00:06:07 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id qHIQKk9a/l7fIgEA0J78UA (envelope-from ); Fri, 03 Jul 2020 00:06:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7210452DA8; Fri, 3 Jul 2020 00:06:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726102AbgGBWGC (ORCPT + 1 other); Thu, 2 Jul 2020 18:06:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbgGBWGB (ORCPT ); Thu, 2 Jul 2020 18:06:01 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E671C08C5C1 for ; Thu, 2 Jul 2020 15:06:01 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id o22so8027041pjw.2 for ; Thu, 02 Jul 2020 15:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=KLVCAsgCYrnpTxr27cIa0AxMzfsiLcn5LAAMEfcyjfE=; b=tDKrpJMAT9o1aJH2sbCJBpDqxi0koKXj7Pfspk7oqLzUnYn5L5DhjgCQAAk4fTN234 Zplu+2sBFr03j3W7L3+wFCt0/MGB0XLk0zEhBvj/G9SdCWxE7FLd/rXLwWSF0Pay+/J1 ylF+YC3WtY7Plr3dHQaCQZym15q4KdMPa/+kLKtcSSyBvKub/tRLmqICe566cdJ1akuF Zjfk1TTAGHJxVAgXrU4annHUiENONtXUG0BLskHHDH8eg4Tmwt9J4tzQWG0GAKM+EL7R lWwRJRvGmDVudU+P7V7FoY30BxLoErQmlf1eTcqPHrJrLdGpRyDws0R8mQo+bKtsn3hM wMzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=KLVCAsgCYrnpTxr27cIa0AxMzfsiLcn5LAAMEfcyjfE=; b=K+oFBz/91ckOD1ezGnzpFsQAYVOAh8EBRcMcpdJU9B4jkjA5Kvh4OLRG7LQIxla6yp 3q3tZjsex3a8xP8avUDqHBsok7NsUCqXCB6mnmQKSE0sZKTHOcdTa51uH25Ix49VGo9Z csdcAjPomD/6IYvkVpIEfbTV5+7PU3I4KlzBMuO6Pfs0Kf/tWnjj2XTgQUClFbjWaWjm L18VF3oCUuMyZvGRpgZU7y9ztA+SnqIAIHfjQQUPs4PTPthd5IgahMSolf9G10198N7l D7LcSwH+4JcnV6NxFH+fxUdjUFzbH4k9u48FSr6+5aT91tdKljD+V4SMc9L65F4oT5/D FCHg== X-Gm-Message-State: AOAM531CqaT54sR75lzOPRBbth2ystmo2SnAlYVWMwhxDZ+s5G26Ecdt vBC4XDNj3xDymYz9UzziyBS8ivkXFKQ= X-Google-Smtp-Source: ABdhPJwHgiffdaMpEtoTgA+utXtko8kgsMcL7bDfVXCJHgbamE/Oey45oJwLGSv3eJ4KKjuYwwHAqg== X-Received: by 2002:a17:902:bccc:: with SMTP id o12mr29615636pls.29.1593727560549; Thu, 02 Jul 2020 15:06:00 -0700 (PDT) Received: from localhost.localdomain ([192.102.209.44]) by smtp.gmail.com with ESMTPSA id n62sm9284219pjb.42.2020.07.02.15.05.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 15:05:59 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [RFC] Bluetooth: btusb: Add support for notifying the polling interval Date: Thu, 2 Jul 2020 15:05:58 -0700 Message-Id: <20200702220558.3467870-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.25.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 5 X-Rspamd-Score: 0.85 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7210452DA8 X-Rspamd-UID: f0fe07 From: Luiz Augusto von Dentz This enables btusb to inform the polling interval used for receiving packets, the interval is then used wih rx_work which has been changed to be a delayed work. The interval is then used as a time window where frames received from different endpoints are considered to be arrived at same time. In order to resolve potential conflicts between endpoints a dedicated queue for events was introduced and it is now processed before the ACL packets. It worth noting though that priorizing events over ACL data may result in inverting the order of the packets over the air, for instance there may be packets received before a disconnect event that will be discarded and unencrypted packets received before encryption change which would considered encrypted, because of these potential inversions the support for polling interval is not enabled by default so platforms have the following means to enable it: At build-time: CONFIG_BT_HCIBTUSB_INTERVAL=y At runtime with use of module option: enable_interval Signed-off-by: Luiz Augusto von Dentz --- drivers/bluetooth/Kconfig | 7 ++++ drivers/bluetooth/btusb.c | 16 +++++++-- include/net/bluetooth/hci_core.h | 6 +++- net/bluetooth/hci_core.c | 60 +++++++++++++++++++++++++------- 4 files changed, 72 insertions(+), 17 deletions(-) diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig index 4e73a531b377..2f20a853d946 100644 --- a/drivers/bluetooth/Kconfig +++ b/drivers/bluetooth/Kconfig @@ -41,6 +41,13 @@ config BT_HCIBTUSB_AUTOSUSPEND This can be overridden by passing btusb.enable_autosuspend=[y|n] on the kernel commandline. +config BT_HCIBTUSB_INTERVAL + bool "Enable notification of USB polling interval" + depends on BT_HCIBTUSB + help + Say Y here to enable notification of USB polling interval for + Bluetooth USB devices by default. + config BT_HCIBTUSB_BCM bool "Broadcom protocol support" depends on BT_HCIBTUSB diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index faa863dd5d0a..6525b10bd40c 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -30,7 +30,7 @@ static bool disable_scofix; static bool force_scofix; static bool enable_autosuspend = IS_ENABLED(CONFIG_BT_HCIBTUSB_AUTOSUSPEND); - +static bool enable_interval = IS_ENABLED(CONFIG_BT_HCIBTUSB_INTERVAL); static bool reset = true; static struct usb_driver btusb_driver; @@ -711,7 +711,14 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count) if (!hci_skb_expect(skb)) { /* Complete frame */ - hci_recv_frame(data->hdev, skb); + if (enable_interval) + /* TODO: Calculate polling interval based on + * endpoint bInterval? + */ + hci_recv_acl(data->hdev, skb, + msecs_to_jiffies(1)); + else + hci_recv_frame(data->hdev, skb); skb = NULL; } } @@ -3866,7 +3873,7 @@ static int btusb_probe(struct usb_interface *intf, data->recv_bulk = btusb_recv_bulk_intel; set_bit(BTUSB_BOOTLOADER, &data->flags); } else { - data->recv_event = hci_recv_frame; + data->recv_event = hci_recv_evt; data->recv_bulk = btusb_recv_bulk; } @@ -4335,6 +4342,9 @@ MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size"); module_param(enable_autosuspend, bool, 0644); MODULE_PARM_DESC(enable_autosuspend, "Enable USB autosuspend by default"); +module_param(enable_interval, bool, 0644); +MODULE_PARM_DESC(enable_interval, "Enable USB polling interval by default"); + module_param(reset, bool, 0644); MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 0de041eac844..d07d3df27ba9 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -444,7 +444,7 @@ struct hci_dev { struct delayed_work cmd_timer; - struct work_struct rx_work; + struct delayed_work rx_work; struct work_struct cmd_work; struct work_struct tx_work; @@ -457,6 +457,7 @@ struct hci_dev { struct delayed_work le_scan_restart; struct sk_buff_head rx_q; + struct sk_buff_head ev_q; struct sk_buff_head raw_q; struct sk_buff_head cmd_q; @@ -1190,6 +1191,9 @@ int hci_suspend_dev(struct hci_dev *hdev); int hci_resume_dev(struct hci_dev *hdev); int hci_reset_dev(struct hci_dev *hdev); int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb); +int hci_recv_acl(struct hci_dev *hdev, struct sk_buff *skb, + unsigned int interval); +int hci_recv_evt(struct hci_dev *hdev, struct sk_buff *skb); int hci_recv_diag(struct hci_dev *hdev, struct sk_buff *skb); __printf(2, 3) void hci_set_hw_info(struct hci_dev *hdev, const char *fmt, ...); __printf(2, 3) void hci_set_fw_info(struct hci_dev *hdev, const char *fmt, ...); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 1920e3c5c6f6..bbf02cd24cfb 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1591,10 +1591,11 @@ static int hci_dev_do_open(struct hci_dev *hdev) /* Init failed, cleanup */ flush_work(&hdev->tx_work); flush_work(&hdev->cmd_work); - flush_work(&hdev->rx_work); + cancel_delayed_work(&hdev->rx_work); skb_queue_purge(&hdev->cmd_q); skb_queue_purge(&hdev->rx_q); + skb_queue_purge(&hdev->ev_q); if (hdev->flush) hdev->flush(hdev); @@ -1719,7 +1720,7 @@ int hci_dev_do_close(struct hci_dev *hdev) /* Flush RX and TX works */ flush_work(&hdev->tx_work); - flush_work(&hdev->rx_work); + cancel_delayed_work(&hdev->rx_work); if (hdev->discov_timeout > 0) { hdev->discov_timeout = 0; @@ -1784,6 +1785,7 @@ int hci_dev_do_close(struct hci_dev *hdev) /* Drop queues */ skb_queue_purge(&hdev->rx_q); + skb_queue_purge(&hdev->ev_q); skb_queue_purge(&hdev->cmd_q); skb_queue_purge(&hdev->raw_q); @@ -1855,6 +1857,7 @@ static int hci_dev_do_reset(struct hci_dev *hdev) /* Drop queues */ skb_queue_purge(&hdev->rx_q); + skb_queue_purge(&hdev->ev_q); skb_queue_purge(&hdev->cmd_q); /* Avoid potential lockdep warnings from the *_flush() calls by @@ -3603,16 +3606,17 @@ struct hci_dev *hci_alloc_dev(void) INIT_LIST_HEAD(&hdev->adv_instances); INIT_LIST_HEAD(&hdev->blocked_keys); - INIT_WORK(&hdev->rx_work, hci_rx_work); INIT_WORK(&hdev->cmd_work, hci_cmd_work); INIT_WORK(&hdev->tx_work, hci_tx_work); INIT_WORK(&hdev->power_on, hci_power_on); INIT_WORK(&hdev->error_reset, hci_error_reset); INIT_WORK(&hdev->suspend_prepare, hci_prepare_suspend); + INIT_DELAYED_WORK(&hdev->rx_work, hci_rx_work); INIT_DELAYED_WORK(&hdev->power_off, hci_power_off); skb_queue_head_init(&hdev->rx_q); + skb_queue_head_init(&hdev->ev_q); skb_queue_head_init(&hdev->cmd_q); skb_queue_head_init(&hdev->raw_q); @@ -3856,8 +3860,8 @@ int hci_reset_dev(struct hci_dev *hdev) } EXPORT_SYMBOL(hci_reset_dev); -/* Receive frame from HCI drivers */ -int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb) +static int hci_rx_queue(struct hci_dev *hdev, struct sk_buff *skb, + struct sk_buff_head *queue, unsigned int interval) { if (!hdev || (!test_bit(HCI_UP, &hdev->flags) && !test_bit(HCI_INIT, &hdev->flags))) { @@ -3879,13 +3883,35 @@ int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb) /* Time stamp */ __net_timestamp(skb); - skb_queue_tail(&hdev->rx_q, skb); - queue_work(hdev->workqueue, &hdev->rx_work); + skb_queue_tail(queue, skb); + + queue_delayed_work(hdev->workqueue, &hdev->rx_work, interval); return 0; } + +/* Receive frame from HCI drivers */ +int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb) +{ + return hci_rx_queue(hdev, skb, &hdev->rx_q, 0); +} EXPORT_SYMBOL(hci_recv_frame); +/* Receive ACL frame from HCI drivers */ +int hci_recv_acl(struct hci_dev *hdev, struct sk_buff *skb, + unsigned int interval) +{ + return hci_rx_queue(hdev, skb, &hdev->rx_q, interval); +} +EXPORT_SYMBOL(hci_recv_acl); + +/* Receive Event frame from HCI drivers */ +int hci_recv_evt(struct hci_dev *hdev, struct sk_buff *skb) +{ + return hci_rx_queue(hdev, skb, &hdev->ev_q, 0); +} +EXPORT_SYMBOL(hci_recv_evt); + /* Receive diagnostic message from HCI drivers */ int hci_recv_diag(struct hci_dev *hdev, struct sk_buff *skb) { @@ -3896,7 +3922,7 @@ int hci_recv_diag(struct hci_dev *hdev, struct sk_buff *skb) __net_timestamp(skb); skb_queue_tail(&hdev->rx_q, skb); - queue_work(hdev->workqueue, &hdev->rx_work); + queue_delayed_work(hdev->workqueue, &hdev->rx_work, 0); return 0; } @@ -4825,14 +4851,11 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status, spin_unlock_irqrestore(&hdev->cmd_q.lock, flags); } -static void hci_rx_work(struct work_struct *work) +static void hci_rx_dequeue(struct hci_dev *hdev, struct sk_buff_head *queue) { - struct hci_dev *hdev = container_of(work, struct hci_dev, rx_work); struct sk_buff *skb; - BT_DBG("%s", hdev->name); - - while ((skb = skb_dequeue(&hdev->rx_q))) { + while ((skb = skb_dequeue(queue))) { /* Send copy to monitor */ hci_send_to_monitor(hdev, skb); @@ -4888,6 +4911,17 @@ static void hci_rx_work(struct work_struct *work) } } +static void hci_rx_work(struct work_struct *work) +{ + struct hci_dev *hdev = container_of(work, struct hci_dev, rx_work.work); + + BT_DBG("%s", hdev->name); + + /* Process HCI event packets so states changes are synchronized first */ + hci_rx_dequeue(hdev, &hdev->ev_q); + hci_rx_dequeue(hdev, &hdev->rx_q); +} + static void hci_cmd_work(struct work_struct *work) { struct hci_dev *hdev = container_of(work, struct hci_dev, cmd_work); -- 2.25.3 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8FlRI39s/l52DAAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 01:23:43 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id UE6GIX9s/l46cwAAlScrYA (envelope-from ); Fri, 03 Jul 2020 01:23:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C2A2DA2429; Fri, 3 Jul 2020 01:23:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726122AbgGBXX0 (ORCPT + 1 other); Thu, 2 Jul 2020 19:23:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726017AbgGBXXZ (ORCPT ); Thu, 2 Jul 2020 19:23:25 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CFDDC08C5C1 for ; Thu, 2 Jul 2020 16:23:25 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id 18so25401095otv.6 for ; Thu, 02 Jul 2020 16:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=So6hipOar99ikd7Np37Ut+mfDA/xdCw/Ua65a7snIDc=; b=GxGv5o8lkJmvD/98WMAAZd3gnyzxKHowthL/AohDBJ9xVCshlp8IoimYU8duL4ZYC6 MM9nTHP9xZq40hGOYeMEmpitIwmhY7DCq+byPwzSbPrsCOn1Pi7cpMAmu6ZRR0qC0Zpy ppv70NRMh4C3I+jW7keWuqmfFQ4rYjGzElIFH7lUpYIbcBwplgX2HFgrstxJAQMdFzz0 0yo2YaX7NZZx27EzVX80eVbNqllcFcOiTSV7Wy8LxQIiAk8ztCmw8HG/IM17cb6zqWx1 Yf3udPIyoO2uQ5dSBDmrcNy/xJWzmTcPsLAfi7Q8bhfMH5DuPLMI4J8RgTdaUdI47FMZ BKiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=So6hipOar99ikd7Np37Ut+mfDA/xdCw/Ua65a7snIDc=; b=XxK2Sxz5a7oSLjooZPYQqtzYRtbirwfJnkh+cO/4mv0SngTiBJHxTmLwAGmW8fPvxT 11qF1n7hRBUXv6DWKuRiXmXXqCJNeHX/nV5S0UrGDDlDLmaS/n9qMLDP0aqAeBIZOF9J zSGfgDiPuF6GRn6XyRlNnl82P9sVoFENtcgn7lDvF44SicQDOjqAoEbTIMKt17j6ENz8 iefMhWuz0v/FJL0nDON/k0eetV7M/yTZhONWluijGgH4GckuTE8aoVXGLJ/6SYf/NjNq GnsO+8Nq+W6AxFM708Nf7j4U2arP+Cmwi01Y9EoU9rKSTBkMoL8HmKD973M8Ae1V47la V1jA== X-Gm-Message-State: AOAM531wQ47bgbZrTG44qax/2/uEkhJLbU+dkycnSsMKg4rJAFJ4ouF7 78Qa1NBxgiFygsQWF8eBhnXtFZ84qEmB+FL/fCmmOADc X-Google-Smtp-Source: ABdhPJw3hu+pGr9nI1dlGSJDn4o8KXaUp0GEsEJlZz6fV+bDWt6T9iyUOseZkaxCnAkFV5Gq5phkPoYFsBQVmy78dj8= X-Received: by 2002:a05:6830:1bd3:: with SMTP id v19mr26172598ota.91.1593732204409; Thu, 02 Jul 2020 16:23:24 -0700 (PDT) MIME-Version: 1.0 References: <20200702180155.24260-1-sonnysasaka@chromium.org> In-Reply-To: <20200702180155.24260-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz Date: Thu, 2 Jul 2020 16:23:12 -0700 Message-ID: Subject: Re: [PATCH v3] client: Add battery percentage to info command To: Sonny Sasaka Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.41 / 15.00 / 200.00 X-Rspamd-Queue-Id: C2A2DA2429 X-Rspamd-UID: 0eb9ae Hi Sonny, On Thu, Jul 2, 2020 at 11:06 AM Sonny Sasaka wrote: > > This adds the Battery Percentage to the info command based on > org.bluez.Battery1 API. Example usage: > > [bluetooth]# info XX:XX:XX:XX:XX:XX > Device XX:XX:XX:XX:XX:XX (random) > Name: ... > Alias: ... > ... > Modalias: ... > Battery Percentage: 0x64 (100) > --- > client/main.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 46 insertions(+), 3 deletions(-) > > diff --git a/client/main.c b/client/main.c > index 422da5593..c0b351aed 100644 > --- a/client/main.c > +++ b/client/main.c > @@ -65,6 +65,7 @@ static struct adapter *default_ctrl; > static GDBusProxy *default_dev; > static GDBusProxy *default_attr; > static GList *ctrl_list; > +static GList *battery_proxies; > > static const char *agent_arguments[] = { > "on", > @@ -107,7 +108,9 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) > bt_shell_set_prompt(PROMPT_OFF); > > g_list_free_full(ctrl_list, proxy_leak); > + g_list_free_full(battery_proxies, proxy_leak); > ctrl_list = NULL; > + battery_proxies = NULL; > > default_ctrl = NULL; > } > @@ -271,7 +274,7 @@ static void print_iter(const char *label, const char *name, > break; > case DBUS_TYPE_BYTE: > dbus_message_iter_get_basic(iter, &byte); > - bt_shell_printf("%s%s: 0x%02x\n", label, name, byte); > + bt_shell_printf("%s%s: 0x%02x (%d)\n", label, name, byte, byte); > break; > case DBUS_TYPE_VARIANT: > dbus_message_iter_recurse(iter, &subiter); > @@ -309,14 +312,20 @@ static void print_iter(const char *label, const char *name, > } > } > > -static void print_property(GDBusProxy *proxy, const char *name) > +static void print_property_with_label(GDBusProxy *proxy, const char *name, > + const char *label) > { > DBusMessageIter iter; > > if (g_dbus_proxy_get_property(proxy, name, &iter) == FALSE) > return; > > - print_iter("\t", name, &iter); > + print_iter("\t", label ? label : name, &iter); > +} > + > +static void print_property(GDBusProxy *proxy, const char *name) > +{ > + print_property_with_label(proxy, name, NULL); > } > > static void print_uuid(const char *uuid) > @@ -445,6 +454,16 @@ done: > g_free(desc); > } > > +static void battery_added(GDBusProxy *proxy) > +{ > + battery_proxies = g_list_append(battery_proxies, proxy); > +} > + > +static void battery_removed(GDBusProxy *proxy) > +{ > + battery_proxies = g_list_remove(battery_proxies, proxy); > +} > + > static void device_added(GDBusProxy *proxy) > { > DBusMessageIter iter; > @@ -539,6 +558,8 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) > gatt_add_manager(proxy); > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > ad_manager_added(proxy); > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > + battery_added(proxy); > } > } > > @@ -630,6 +651,8 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) > gatt_remove_manager(proxy); > } else if (!strcmp(interface, "org.bluez.LEAdvertisingManager1")) { > ad_unregister(dbus_conn, NULL); > + } else if (!strcmp(interface, "org.bluez.Battery1")) { > + battery_removed(proxy); > } > } > > @@ -763,6 +786,20 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address) > return NULL; > } > > +static GDBusProxy *find_battery_by_path(GList *source, const char *path) > +{ > + GList *list; > + > + for (list = g_list_first(source); list; list = g_list_next(list)) { > + GDBusProxy *proxy = list->data; > + > + if (strcmp(g_dbus_proxy_get_path(proxy), path) == 0) > + return proxy; > + } > + > + return NULL; > +} > + > static GDBusProxy *find_proxy_by_address(GList *source, const char *address) > { > GList *list; > @@ -1606,6 +1643,7 @@ static struct GDBusProxy *find_device(int argc, char *argv[]) > static void cmd_info(int argc, char *argv[]) > { > GDBusProxy *proxy; > + GDBusProxy *battery_proxy; > DBusMessageIter iter; > const char *address; > > @@ -1647,6 +1685,11 @@ static void cmd_info(int argc, char *argv[]) > print_property(proxy, "AdvertisingFlags"); > print_property(proxy, "AdvertisingData"); > > + battery_proxy = find_battery_by_path(battery_proxies, > + g_dbus_proxy_get_path(proxy)); > + print_property_with_label(battery_proxy, "Percentage", > + "Battery Percentage"); > + > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > } > > -- > 2.17.1 > Applied, thanks. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KIcZANuF/l4K7AAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 03:11:55 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id wA8oOtqF/l7ldwAA0J78UA (envelope-from ); Fri, 03 Jul 2020 03:11:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8599AA221F; Fri, 3 Jul 2020 03:11:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726445AbgGCBLs (ORCPT + 1 other); Thu, 2 Jul 2020 21:11:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726015AbgGCBLs (ORCPT ); Thu, 2 Jul 2020 21:11:48 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E07C08C5DD for ; Thu, 2 Jul 2020 18:11:48 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id m9so3020013pfh.0 for ; Thu, 02 Jul 2020 18:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GR99GIZZjMuYiZzLF19Koiioj28kl/2jLD/QPVbsMmo=; b=Gf70XC+FENM8wk9LD/IhT3t17C7HyY4bCdWxH2/yBHTDClzfDME3YPjnA3reqYxscT tan/vmiTxI4TScYutZAEUAubtTfmezTcSfcMxG8/xTshXGM4haDnyswOHyd4QuZXFPwT FPrSXRYFiRANfbKgOi9wsvCyIvCwZ/PkLVkqQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GR99GIZZjMuYiZzLF19Koiioj28kl/2jLD/QPVbsMmo=; b=bBVvtUYGUeYotc+PZFKBU+1cxmN9lAwyErbaJxpuds6zEnDQSTXbGhAeI6nd3+/V90 pH1z2OeuF82J6I30nYuv2oyl7IcUAPZTprDAlKvmhOO05/yOhcGSJPpXH8BUa+fMm5al Nl/DqblTrCLJKQN0oKxDTMu7lpv/abFDytTmYgTKrA2h3Czle2rbFOLKuNiCOabf2M/C LA6SEgQL5P5xTqmxjOA3D42TnqvOJmKE/6e11XAUfidYiav0cBMgWnhoV1PIgJz0M12q qwO71PdlQRxT1ewfLR8MMGtY5EhIHyMjWve3Pm5yfNE1J2TuxSsi0XYe7pCRcX72GMcN WEgg== X-Gm-Message-State: AOAM533/ZNkD7/4rdKFICLyQ5HmONw64lbzi0ezLLArqaji/6Xb3I9ka TMhZ6pFuWj1VtPKxClsjOVsgQMdyajTUJw== X-Google-Smtp-Source: ABdhPJytWvIWeK1ATDg3B20v4sgj59qnn+uhC1n/GMs05mdtVBs9Gt4NyvBkIjNx6BlJ/vdoEyr9xQ== X-Received: by 2002:a62:cdc4:: with SMTP id o187mr9910453pfg.200.1593738707606; Thu, 02 Jul 2020 18:11:47 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id e12sm9662721pfd.69.2020.07.02.18.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 18:11:47 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Joseph Hwang , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH] Bluetooth: btusb: add Realtek 8822CE to blacklist_table Date: Fri, 3 Jul 2020 09:11:32 +0800 Message-Id: <20200703091124.1.I63705bf6abab9cb79c14f7959a59b201af2b8827@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8599AA221F X-Rspamd-UID: 2ac0b1 This patch adds the Realtek 8822CE controller to the blacklist_table to support the wideband speech capability. Signed-off-by: Joseph Hwang --- drivers/bluetooth/btusb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 0e143c0cecf2a1..34a84c64e4c83e 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -359,6 +359,10 @@ static const struct usb_device_id blacklist_table[] = { { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01), .driver_info = BTUSB_IGNORE }, + /* Realtek 8822CE Bluetooth devices */ + { USB_DEVICE(0x0bda, 0xb00c), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, + /* Realtek Bluetooth devices */ { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01), .driver_info = BTUSB_REALTEK }, -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uD4dGRfa/l5zKQAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 09:11:19 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OFqXFxfa/l4uuAAADc0bRg (envelope-from ); Fri, 03 Jul 2020 09:11:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4B92952EC2; Fri, 3 Jul 2020 09:11:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725891AbgGCHLM (ORCPT + 1 other); Fri, 3 Jul 2020 03:11:12 -0400 Received: from mga07.intel.com ([134.134.136.100]:29061 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbgGCHLM (ORCPT ); Fri, 3 Jul 2020 03:11:12 -0400 IronPort-SDR: EMcCZqAumeLSyTWl9EPOmLjZq3eor3ggHDNNylkglO1aevz7BAYN2I4e1oYc4wq0tMHleWzF4w csjOuxnhzl1A== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="212125510" X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="212125510" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2020 00:11:11 -0700 IronPort-SDR: XlVUGBu5Ex793fN28TKx1lgSzIKe1a6hx8XtofGK4BN5xpeSIGJVGj+Xz0xYKWng6Op85myxfR vi76LehJ7IOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="426212099" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by orsmga004.jf.intel.com with ESMTP; 03 Jul 2020 00:11:09 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH v2 1/5] Bluetooth: btintel: Make controller version read generic Date: Fri, 3 Jul 2020 12:42:08 +0530 Message-Id: <20200703071212.17046-1-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4B92952EC2 X-Rspamd-UID: 8f6160 Make controller read vesion function more generic to support different type of controllers. Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Chethan T N Reviewed-by: Sathish Narasimman Reviewed-by: Srivatsa Ravishankar --- Changes in v2: None Changes in v1: - Make controller read version function generic drivers/bluetooth/btintel.c | 36 ++++++++++++++---- drivers/bluetooth/btintel.h | 15 ++++++-- drivers/bluetooth/btusb.c | 71 +++++++++++++++++++++++------------ drivers/bluetooth/hci_ag6xx.c | 12 +++++- drivers/bluetooth/hci_intel.c | 12 +++++- 5 files changed, 106 insertions(+), 40 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index 5fa5be3c5598..dea96c585ecb 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -204,9 +204,15 @@ void btintel_hw_error(struct hci_dev *hdev, u8 code) } EXPORT_SYMBOL_GPL(btintel_hw_error); -void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver) +void btintel_version_info(struct hci_dev *hdev, const struct btintel_version *version) { const char *variant; + const struct intel_version *ver; + + if (version->is_tlv_supported) + return; + + ver = &version->intel_version; switch (ver->fw_variant) { case 0x06: @@ -335,27 +341,41 @@ int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug) } EXPORT_SYMBOL_GPL(btintel_set_event_mask_mfg); -int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver) +int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version) { struct sk_buff *skb; + u8 *data, param, status, check_tlv; + + if (!version) + return -EINVAL; - skb = __hci_cmd_sync(hdev, 0xfc05, 0, NULL, HCI_CMD_TIMEOUT); + param = 0xFF; + + skb = __hci_cmd_sync(hdev, 0xfc05, 1, ¶m, HCI_CMD_TIMEOUT); if (IS_ERR(skb)) { bt_dev_err(hdev, "Reading Intel version information failed (%ld)", PTR_ERR(skb)); return PTR_ERR(skb); } - if (skb->len != sizeof(*ver)) { - bt_dev_err(hdev, "Intel version event size mismatch"); + data = skb->data; + status = *data; + if (status) { + bt_dev_err(hdev, "Intel Read Version command failed (%02x)", + status); kfree_skb(skb); - return -EILSEQ; + return -bt_to_errno(status); } - memcpy(ver, skb->data, sizeof(*ver)); + check_tlv = *(data + 1); + if (skb->len == sizeof(version->intel_version) && check_tlv == 0x37) { + memcpy(&version->intel_version, skb->data, sizeof(version->intel_version)); + version->is_tlv_supported = false; + } else { + version->is_tlv_supported = true; + } kfree_skb(skb); - return 0; } EXPORT_SYMBOL_GPL(btintel_read_version); diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 08e20606fb58..0865d2d4aca7 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -66,6 +66,13 @@ struct intel_debug_features { __u8 page1[16]; } __packed; +struct btintel_version { + bool is_tlv_supported; + union { + struct intel_version intel_version; /* legacy version */ + }; +} __packed; + #if IS_ENABLED(CONFIG_BT_INTEL) int btintel_check_bdaddr(struct hci_dev *hdev); @@ -76,13 +83,13 @@ int btintel_set_diag(struct hci_dev *hdev, bool enable); int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable); void btintel_hw_error(struct hci_dev *hdev, u8 code); -void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver); +void btintel_version_info(struct hci_dev *hdev, const struct btintel_version *version); int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen, const void *param); int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name); int btintel_set_event_mask(struct hci_dev *hdev, bool debug); int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug); -int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver); +int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version); struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read, u16 opcode_write); @@ -133,7 +140,7 @@ static inline void btintel_hw_error(struct hci_dev *hdev, u8 code) } static inline void btintel_version_info(struct hci_dev *hdev, - struct intel_version *ver) + struct btintel_version *version) { } @@ -160,7 +167,7 @@ static inline int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug) } static inline int btintel_read_version(struct hci_dev *hdev, - struct intel_version *ver) + struct btintel_version *version) { return -EOPNOTSUPP; } diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index faa863dd5d0a..d06c946f7810 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -1938,6 +1938,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) const u8 *fw_ptr; int disable_patch, err; struct intel_version ver; + struct btintel_version version; BT_DBG("%s", hdev->name); @@ -1963,10 +1964,16 @@ static int btusb_setup_intel(struct hci_dev *hdev) * The returned information are hardware variant and revision plus * firmware variant, revision and build number. */ - err = btintel_read_version(hdev, &ver); + err = btintel_read_version(hdev, &version); if (err) return err; + if (version.is_tlv_supported) { + bt_dev_err(hdev, "FW download in tlv format not supported"); + return -EOPNOTSUPP; + } + ver = version.intel_version; + bt_dev_info(hdev, "read Intel version: %02x%02x%02x%02x%02x%02x%02x%02x%02x", ver.hw_platform, ver.hw_variant, ver.hw_revision, ver.fw_variant, ver.fw_revision, ver.fw_build_num, @@ -2049,11 +2056,11 @@ static int btusb_setup_intel(struct hci_dev *hdev) /* Need build number for downloaded fw patches in * every power-on boot */ - err = btintel_read_version(hdev, &ver); - if (err) - return err; - bt_dev_info(hdev, "Intel BT fw patch 0x%02x completed & activated", - ver.fw_patch_num); + err = btintel_read_version(hdev, &version); + if (err) + return err; + bt_dev_info(hdev, "Intel BT fw patch 0x%02x completed & activated", + version.intel_version.fw_patch_num); goto complete; @@ -2251,11 +2258,18 @@ static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb) return -EILSEQ; } -static bool btusb_setup_intel_new_get_fw_name(struct intel_version *ver, - struct intel_boot_params *params, - char *fw_name, size_t len, - const char *suffix) +static bool btusb_setup_intel_new_get_fw_name(const struct btintel_version *version, + struct intel_boot_params *params, + char *fw_name, size_t len, + const char *suffix) { + const struct intel_version *ver; + + if (version->is_tlv_supported) + return false; + + ver = &version->intel_version; + switch (ver->hw_variant) { case 0x0b: /* SfP */ case 0x0c: /* WsP */ @@ -2281,18 +2295,21 @@ static bool btusb_setup_intel_new_get_fw_name(struct intel_version *ver, } static int btusb_intel_download_firmware(struct hci_dev *hdev, - struct intel_version *ver, + struct btintel_version *version, struct intel_boot_params *params) { const struct firmware *fw; u32 boot_param; char fwname[64]; int err; + const struct intel_version *ver; struct btusb_data *data = hci_get_drvdata(hdev); - if (!ver || !params) + if (!version || !params) return -EINVAL; + ver = &version->intel_version; + /* The hardware platform number has a fixed value of 0x37 and * for now only accept this single value. */ @@ -2322,8 +2339,6 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev, return -EINVAL; } - btintel_version_info(hdev, ver); - /* The firmware variant determines if the device is in bootloader * mode or is running operational firmware. The value 0x06 identifies * the bootloader and the value 0x23 identifies the operational @@ -2398,7 +2413,7 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev, * ibt---.sfi. * */ - err = btusb_setup_intel_new_get_fw_name(ver, params, fwname, + err = btusb_setup_intel_new_get_fw_name(version, params, fwname, sizeof(fwname), "sfi"); if (!err) { bt_dev_err(hdev, "Unsupported Intel firmware naming"); @@ -2483,6 +2498,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) unsigned long long duration; int err; struct intel_debug_features features; + struct btintel_version version; BT_DBG("%s", hdev->name); @@ -2494,21 +2510,28 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) calltime = ktime_get(); - /* Read the Intel version information to determine if the device - * is in bootloader mode or if it already has operational firmware - * loaded. + /* Read controller version information and support of tlv format */ - err = btintel_read_version(hdev, &ver); + err = btintel_read_version(hdev, &version); if (err) { - bt_dev_err(hdev, "Intel Read version failed (%d)", err); + bt_dev_err(hdev, "Intel Read version new failed (%d)", err); btintel_reset_to_bootloader(hdev); return err; } - err = btusb_intel_download_firmware(hdev, &ver, ¶ms); + if (version.is_tlv_supported) { + bt_dev_err(hdev, "Firmware download in tlv format is not supported"); + return -EOPNOTSUPP; + } + + btintel_version_info(hdev, &version); + + err = btusb_intel_download_firmware(hdev, &version, ¶ms); if (err) return err; + ver = version.intel_version; + /* controller is already having an operational firmware */ if (ver.fw_variant == 0x23) goto finish; @@ -2562,7 +2585,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) clear_bit(BTUSB_BOOTLOADER, &data->flags); - err = btusb_setup_intel_new_get_fw_name(&ver, ¶ms, ddcname, + err = btusb_setup_intel_new_get_fw_name(&version, ¶ms, ddcname, sizeof(ddcname), "ddc"); if (!err) { @@ -2586,11 +2609,11 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) btintel_set_debug_features(hdev, &features); /* Read the Intel version information after loading the FW */ - err = btintel_read_version(hdev, &ver); + err = btintel_read_version(hdev, &version); if (err) return err; - btintel_version_info(hdev, &ver); + btintel_version_info(hdev, &version); finish: /* All Intel controllers that support the Microsoft vendor diff --git a/drivers/bluetooth/hci_ag6xx.c b/drivers/bluetooth/hci_ag6xx.c index 1f55df93e4ce..6f6a1e061972 100644 --- a/drivers/bluetooth/hci_ag6xx.c +++ b/drivers/bluetooth/hci_ag6xx.c @@ -153,6 +153,7 @@ static int ag6xx_setup(struct hci_uart *hu) struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; struct intel_version ver; + struct btintel_version version; const struct firmware *fw; const u8 *fw_ptr; char fwname[64]; @@ -166,11 +167,18 @@ static int ag6xx_setup(struct hci_uart *hu) if (err) return err; - err = btintel_read_version(hdev, &ver); + err = btintel_read_version(hdev, &version); if (err) return err; - btintel_version_info(hdev, &ver); + if (version.is_tlv_supported) { + bt_dev_err(hdev, "Firmware download in tlv format over ag6xx is not supported"); + return -EOPNOTSUPP; + } + + btintel_version_info(hdev, &version); + + ver = version.intel_version; /* The hardware platform number has a fixed value of 0x37 and * for now only accept this single value. diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c index f1299da6eed8..f30cbc66d48f 100644 --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -532,6 +532,7 @@ static int intel_setup(struct hci_uart *hu) struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; struct intel_version ver; + struct btintel_version version; struct intel_boot_params params; struct list_head *p; const struct firmware *fw; @@ -584,10 +585,17 @@ static int intel_setup(struct hci_uart *hu) * is in bootloader mode or if it already has operational firmware * loaded. */ - err = btintel_read_version(hdev, &ver); + err = btintel_read_version(hdev, &version); if (err) return err; + if (version.is_tlv_supported) { + /* firmware download in tlv format is not supported on UART transport */ + bt_dev_err(hdev, "Firmware download in tlv format is not supported"); + return -EOPNOTSUPP; + } + ver = version.intel_version; + /* The hardware platform number has a fixed value of 0x37 and * for now only accept this single value. */ @@ -614,7 +622,7 @@ static int intel_setup(struct hci_uart *hu) return -EINVAL; } - btintel_version_info(hdev, &ver); + btintel_version_info(hdev, &version); /* The firmware variant determines if the device is in bootloader * mode or is running operational firmware. The value 0x06 identifies -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2BhaGRva/l5ddQAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 09:11:23 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 0OPyFxva/l4SnQAADc0bRg (envelope-from ); Fri, 03 Jul 2020 09:11:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A1AB35296A; Fri, 3 Jul 2020 09:11:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725984AbgGCHLO (ORCPT + 1 other); Fri, 3 Jul 2020 03:11:14 -0400 Received: from mga07.intel.com ([134.134.136.100]:29061 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbgGCHLO (ORCPT ); Fri, 3 Jul 2020 03:11:14 -0400 IronPort-SDR: oC3WHtwvb5A/8rJ/1z/omLJG75TbWOnz8iTin5QA5LvWihpeq/klxvJ9AUN9zTPpFVw8SywdtC RvvoL179aJUQ== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="212125514" X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="212125514" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2020 00:11:14 -0700 IronPort-SDR: vrIiuVpGYi0pV2Gz0wp+TB9YE6Gx9xVGd08RMt6RduF1IPK3zyQV4nJHACcHmKoSgOZN4UuVy2 IYtVt0NST9og== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="426212110" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by orsmga004.jf.intel.com with ESMTP; 03 Jul 2020 00:11:12 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH v2 2/5] Bluetooth: btintel: Refactor firmware header download sequence Date: Fri, 3 Jul 2020 12:42:09 +0530 Message-Id: <20200703071212.17046-2-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703071212.17046-1-kiran.k@intel.com> References: <20200703071212.17046-1-kiran.k@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: A1AB35296A X-Rspamd-UID: c59b61 Move firmware header download code to a separate function to enhance readability and reusability Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Chethan T N Reviewed-by: Sathish Narasimman Reviewed-by: Srivatsa Ravishankar --- Changes in v2: - Remove unwanted blank line, add empty line before goto label Changes in v1: - Move firmware header download code to new function drivers/bluetooth/btintel.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index dea96c585ecb..ffc888c4e9e3 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -646,12 +646,10 @@ int btintel_read_boot_params(struct hci_dev *hdev, } EXPORT_SYMBOL_GPL(btintel_read_boot_params); -int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, - u32 *boot_param) +static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev, + const struct firmware *fw) { int err; - const u8 *fw_ptr; - u32 frag_len; /* Start the firmware download transaction with the Init fragment * represented by the 128 bytes of CSS header. @@ -680,6 +678,21 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, goto done; } +done: + return err; +} + +int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, + u32 *boot_param) +{ + int err; + const u8 *fw_ptr; + u32 frag_len; + + err = btintel_sfi_rsa_header_secure_send(hdev, fw); + if (err) + goto done; + fw_ptr = fw->data + 644; frag_len = 0; -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oI1hFh/a/l5zKQAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 09:11:27 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MNzZFB/a/l5F8wEAlScrYA (envelope-from ); Fri, 03 Jul 2020 09:11:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8558F52CEA; Fri, 3 Jul 2020 09:11:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726063AbgGCHLQ (ORCPT + 1 other); Fri, 3 Jul 2020 03:11:16 -0400 Received: from mga07.intel.com ([134.134.136.100]:29061 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbgGCHLQ (ORCPT ); Fri, 3 Jul 2020 03:11:16 -0400 IronPort-SDR: dEFShv6a8V6nWz28gMGq0c08zL7o3XlWBeH0OryM2wf1YBmWrcC+muih9o1zzdpCYmI8uPbXoJ fOBsIQow4eyQ== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="212125516" X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="212125516" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2020 00:11:16 -0700 IronPort-SDR: NCoqYr1U0RYdT5zbdhvtWwb/iBVtqUIIdgsKprhhUdewFMap6kzrT7CFG0xstBiTla0ZXJ85Cz BicUhRIJ1efQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="426212120" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by orsmga004.jf.intel.com with ESMTP; 03 Jul 2020 00:11:14 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH v2 3/5] Bluetooth: btintel: Refactor firmware payload download code Date: Fri, 3 Jul 2020 12:42:10 +0530 Message-Id: <20200703071212.17046-3-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703071212.17046-1-kiran.k@intel.com> References: <20200703071212.17046-1-kiran.k@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8558F52CEA X-Rspamd-UID: 60a9da Move firmware payload download code to a separate function to enhance readability and reusability Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Chethan T N Reviewed-by: Sathish Narasimman Reviewed-by: Srivatsa Ravishankar --- Changes in v2: - Avoid exporting new public function for firmware download - Move firmware payload download code to a new function Changes in v1: - Move firmware payload download code to a new function drivers/bluetooth/btintel.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index ffc888c4e9e3..2cb55a97598c 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -19,6 +19,7 @@ #define VERSION "0.1" #define BDADDR_INTEL (&(bdaddr_t) {{0x00, 0x8b, 0x9e, 0x19, 0x03, 0x00}}) +#define RSA_HEADER_LEN 644 int btintel_check_bdaddr(struct hci_dev *hdev) { @@ -682,8 +683,9 @@ static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev, return err; } -int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, - u32 *boot_param) +static int btintel_download_firmware_payload(struct hci_dev *hdev, + const struct firmware *fw, + u32 *boot_param, size_t offset) { int err; const u8 *fw_ptr; @@ -693,8 +695,9 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, if (err) goto done; - fw_ptr = fw->data + 644; + fw_ptr = fw->data + offset; frag_len = 0; + err = -EINVAL; while (fw_ptr - fw->data < fw->size) { struct hci_command_hdr *cmd = (void *)(fw_ptr + frag_len); @@ -740,6 +743,19 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, done: return err; } + +int btintel_download_firmware(struct hci_dev *hdev, + const struct firmware *fw, + u32 *boot_param) +{ + int err; + + err = btintel_sfi_rsa_header_secure_send(hdev, fw); + if (err) + return err; + + return btintel_download_firmware_payload(hdev, fw, boot_param, RSA_HEADER_LEN); +} EXPORT_SYMBOL_GPL(btintel_download_firmware); void btintel_reset_to_bootloader(struct hci_dev *hdev) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IKc1DSPa/l5zKQAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 09:11:31 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id sIotCyPa/l7iqQEAgupzMw (envelope-from ); Fri, 03 Jul 2020 09:11:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9FDFC52CA6; Fri, 3 Jul 2020 09:11:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726106AbgGCHLT (ORCPT + 1 other); Fri, 3 Jul 2020 03:11:19 -0400 Received: from mga07.intel.com ([134.134.136.100]:29061 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbgGCHLT (ORCPT ); Fri, 3 Jul 2020 03:11:19 -0400 IronPort-SDR: kV7g+7yR5b1Ph+nsc7G+vHiJkhdUMpExrqUsGE/s8CeSx23tgbEvmaIP6eCzzjXG83b678XBkl f8zIZFKe7zAw== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="212125521" X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="212125521" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2020 00:11:19 -0700 IronPort-SDR: Jv9y9nhdsF2SrtzKh7MlbV1Ueaf7Yt9R7lBDyTDfSQ6MKamup2bC8xfXblW4o/Up476WH64rbH 2KKkKTSOUruA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="426212126" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by orsmga004.jf.intel.com with ESMTP; 03 Jul 2020 00:11:16 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH v2 4/5] Bluetooth: btintel: Define tlv structure for new generation Controllers Date: Fri, 3 Jul 2020 12:42:11 +0530 Message-Id: <20200703071212.17046-4-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703071212.17046-1-kiran.k@intel.com> References: <20200703071212.17046-1-kiran.k@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9FDFC52CA6 X-Rspamd-UID: 623f7a Define structure used for reading controller information and to downloading firmware in tlv format used for new generation Intel controllers Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Chethan T N Reviewed-by: Sathish Narasimman Reviewed-by: Srivatsa Ravishankar --- Changes in v2: None Changes in v1: - Add tlv structure definition drivers/bluetooth/btintel.h | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 0865d2d4aca7..20007da6b9bd 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -6,6 +6,90 @@ * Copyright (C) 2015 Intel Corporation */ +/* List of tlv type */ +enum { + INTEL_TLV_CNVI_TOP = 0x10, + INTEL_TLV_CNVR_TOP, + INTEL_TLV_CNVI_BT, + INTEL_TLV_CNVR_BT, + INTEL_TLV_CNVI_OTP, + INTEL_TLV_CNVR_OTP, + INTEL_TLV_DEV_REV_ID, + INTEL_TLV_USB_VENDOR_ID, + INTEL_TLV_USB_PRODUCT_ID, + INTEL_TLV_PCIE_VENDOR_ID, + INTEL_TLV_PCIE_DEVICE_ID, + INTEL_TLV_PCIE_SUBSYSTEM_ID, + INTEL_TLV_IMAGE_TYPE, + INTEL_TLV_TIME_STAMP, + INTEL_TLV_BUILD_TYPE, + INTEL_TLV_BUILD_NUM, + INTEL_TLV_FW_BUILD_PRODUCT, + INTEL_TLV_FW_BUILD_HW, + INTEL_TLV_FW_STEP, + INTEL_TLV_BT_SPEC, + INTEL_TLV_MFG_NAME, + INTEL_TLV_HCI_REV, + INTEL_TLV_LMP_SUBVER, + INTEL_TLV_OTP_PATCH_VER, + INTEL_TLV_SECURE_BOOT, + INTEL_TLV_KEY_FROM_HDR, + INTEL_TLV_OTP_LOCK, + INTEL_TLV_API_LOCK, + INTEL_TLV_DEBUG_LOCK, + INTEL_TLV_MIN_FW, + INTEL_TLV_LIMITED_CCE, + INTEL_TLV_SBE_TYPE, + INTEL_TLV_OTP_BDADDR, + INTEL_TLV_UNLOCKED_STATE +}; + +struct intel_tlv { + u8 type; + u8 len; + u8 val[0]; +} __packed; + +struct intel_version_tlv { + u8 status; + u32 cnvi_top; + u32 cnvr_top; + u32 cnvi_bt; + u32 cnvr_bt; + u16 cnvi_otp; + u16 cnvr_otp; + u16 dev_rev_id; + u16 usb_vid; + u16 usb_pid; + u16 pcie_vendor_id; + u16 pcie_dev_id; + u16 pcie_subsys_id; + u8 img_type; + u16 timestamp; + u8 build_type; + u32 build_num; + u8 fw_build_prod; + u8 fw_build_hw; + u8 fw_build_step; + u8 bt_spec_ver; + u16 mfg_name; + u16 hci_rev; + u16 lmp_sub_ver; + u8 otp_patch_ver; + u8 secure_boot; + u8 key_from_hdr; + u8 otp_lock; + u8 api_lock; + u8 debug_lock; + u8 min_fw_build_nn; + u8 min_fw_build_cw; + u8 min_fw_build_yy; + u8 limited_cce; + u8 sbe_type; + bdaddr_t otp_bd_addr; + u8 unlocked_state; +} __packed; + struct intel_version { u8 status; u8 hw_platform; @@ -70,6 +154,7 @@ struct btintel_version { bool is_tlv_supported; union { struct intel_version intel_version; /* legacy version */ + struct intel_version_tlv intel_version_tlv; }; } __packed; -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4P/gAifa/l6peQAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 09:11:35 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id UJIXASfa/l4M5wEAlScrYA (envelope-from ); Fri, 03 Jul 2020 09:11:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5107F52851; Fri, 3 Jul 2020 09:11:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726107AbgGCHLW (ORCPT + 1 other); Fri, 3 Jul 2020 03:11:22 -0400 Received: from mga07.intel.com ([134.134.136.100]:29061 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbgGCHLW (ORCPT ); Fri, 3 Jul 2020 03:11:22 -0400 IronPort-SDR: YW4EgGjQDlV7MK8ff+/850fgzFtTj5pgRtj2YkSq0ClcKkYIOrxF6qO1OC662MwBH45Flf32DS w2W2j8ux/1tQ== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="212125523" X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="212125523" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2020 00:11:21 -0700 IronPort-SDR: oIFz0nwztY41WRjIp4kAZaHOhwIapKAuibuRV/4KTC7uKhYFWz4DPQn4dUMV8X5sqLc9IiMXhy dPWxlJeBd9tg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="426212147" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by orsmga004.jf.intel.com with ESMTP; 03 Jul 2020 00:11:19 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH v2 5/5] Bluetooth: btintel: Parse controller information present in TLV format Date: Fri, 3 Jul 2020 12:42:12 +0530 Message-Id: <20200703071212.17046-5-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703071212.17046-1-kiran.k@intel.com> References: <20200703071212.17046-1-kiran.k@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5107F52851 X-Rspamd-UID: 7fea05 New generation Intel controllers returns controller information in TLV format. Adding capability to parse and log it for debug purpose Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Chethan T N Reviewed-by: Sathish Narasimman Reviewed-by: Srivatsa Ravishankar --- Changes in v2: - Fix alignment for break statement - Use get_unaligned_* - Add empty line before goto label drivers/bluetooth/btintel.c | 144 ++++++++++++++++++++++++++++++++---- drivers/bluetooth/btusb.c | 4 +- 2 files changed, 133 insertions(+), 15 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index 2cb55a97598c..d71dcef58a89 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -209,27 +209,60 @@ void btintel_version_info(struct hci_dev *hdev, const struct btintel_version *ve { const char *variant; const struct intel_version *ver; + const struct intel_version_tlv *ver_tlv; + + if (!version->is_tlv_supported) { + ver = &version->intel_version; + + switch (ver->fw_variant) { + case 0x06: + variant = "Bootloader"; + break; + case 0x23: + variant = "Firmware"; + break; + default: + goto done; + } - if (version->is_tlv_supported) - return; + bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u", + variant, ver->fw_revision >> 4, + ver->fw_revision & 0x0f, ver->fw_build_num, + ver->fw_build_ww, 2000 + ver->fw_build_yy); + goto done; + } - ver = &version->intel_version; + ver_tlv = &version->intel_version_tlv; - switch (ver->fw_variant) { - case 0x06: + switch (ver_tlv->img_type) { + case 0x01: variant = "Bootloader"; + bt_dev_info(hdev, "Device revision is %u", ver_tlv->dev_rev_id); + bt_dev_info(hdev, "Secure boot is %s", + ver_tlv->secure_boot ? "enabled" : "disabled"); + bt_dev_info(hdev, "OTP lock is %s", + ver_tlv->otp_lock ? "enabled" : "disabled"); + bt_dev_info(hdev, "API lock is %s", + ver_tlv->api_lock ? "enabled" : "disabled"); + bt_dev_info(hdev, "Debug lock is %s", + ver_tlv->debug_lock ? "enabled" : "disabled"); + bt_dev_info(hdev, "Minimum firmware build %u week %u %u", + ver_tlv->min_fw_build_nn, ver_tlv->min_fw_build_cw, + 2000 + ver_tlv->min_fw_build_yy); break; - case 0x23: + case 0x03: variant = "Firmware"; break; default: - return; + goto done; } - bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u", - variant, ver->fw_revision >> 4, ver->fw_revision & 0x0f, - ver->fw_build_num, ver->fw_build_ww, - 2000 + ver->fw_build_yy); + bt_dev_info(hdev, "%s timestamp %u.%u buildtype %u build %u", variant, + 2000 + (ver_tlv->timestamp >> 8), ver_tlv->timestamp & 0xff, + ver_tlv->build_type, ver_tlv->build_num); + +done: + return; } EXPORT_SYMBOL_GPL(btintel_version_info); @@ -346,6 +379,8 @@ int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version) { struct sk_buff *skb; u8 *data, param, status, check_tlv; + struct intel_version_tlv *ver_tlv; + struct intel_tlv *tlv; if (!version) return -EINVAL; @@ -373,9 +408,92 @@ int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version) if (skb->len == sizeof(version->intel_version) && check_tlv == 0x37) { memcpy(&version->intel_version, skb->data, sizeof(version->intel_version)); version->is_tlv_supported = false; - } else { - version->is_tlv_supported = true; + goto done; } + + bt_dev_info(hdev, "Supports tlv firmware download sequence"); + version->is_tlv_supported = true; + ver_tlv = &version->intel_version_tlv; + + /* Consume Command Complete Status field */ + skb_pull(skb, 1); + + /* Event parameters contatin multiple TLVs. Read each of them + * and only keep the required data. Also, it use existing legacy + * version field like hw_platform, hw_variant, and fw_variant + * to keep the existing setup flow + */ + while (skb->len) { + tlv = (struct intel_tlv *)skb->data; + switch (tlv->type) { + case INTEL_TLV_CNVI_TOP: + ver_tlv->cnvi_top = get_unaligned_le32(tlv->val); + break; + case INTEL_TLV_CNVR_TOP: + ver_tlv->cnvr_top = get_unaligned_le32(tlv->val); + break; + case INTEL_TLV_CNVI_BT: + ver_tlv->cnvi_bt = get_unaligned_le32(tlv->val); + break; + case INTEL_TLV_CNVR_BT: + ver_tlv->cnvr_bt = get_unaligned_le32(tlv->val); + break; + case INTEL_TLV_USB_VENDOR_ID: + ver_tlv->usb_vid = get_unaligned_le16(tlv->val); + break; + case INTEL_TLV_USB_PRODUCT_ID: + ver_tlv->usb_pid = get_unaligned_le16(tlv->val); + break; + case INTEL_TLV_IMAGE_TYPE: + ver_tlv->img_type = tlv->val[0]; + break; + case INTEL_TLV_TIME_STAMP: + ver_tlv->timestamp = get_unaligned_le16(tlv->val); + break; + case INTEL_TLV_BUILD_TYPE: + ver_tlv->build_type = tlv->val[0]; + break; + case INTEL_TLV_BUILD_NUM: + ver_tlv->build_num = get_unaligned_le32(tlv->val); + break; + case INTEL_TLV_SECURE_BOOT: + ver_tlv->secure_boot = tlv->val[0]; + break; + case INTEL_TLV_KEY_FROM_HDR: + ver_tlv->key_from_hdr = tlv->val[0]; + break; + case INTEL_TLV_OTP_LOCK: + ver_tlv->otp_lock = tlv->val[0]; + break; + case INTEL_TLV_API_LOCK: + ver_tlv->api_lock = tlv->val[0]; + break; + case INTEL_TLV_DEBUG_LOCK: + ver_tlv->debug_lock = tlv->val[0]; + break; + case INTEL_TLV_MIN_FW: + ver_tlv->min_fw_build_nn = tlv->val[0]; + ver_tlv->min_fw_build_cw = tlv->val[1]; + ver_tlv->min_fw_build_yy = tlv->val[2]; + break; + case INTEL_TLV_LIMITED_CCE: + ver_tlv->limited_cce = tlv->val[0]; + break; + case INTEL_TLV_SBE_TYPE: + ver_tlv->sbe_type = tlv->val[0]; + break; + case INTEL_TLV_OTP_BDADDR: + memcpy(&ver_tlv->otp_bd_addr, tlv->val, tlv->len); + break; + default: + /* Ignore rest of information */ + break; + } + /* consume the current tlv and move to next*/ + skb_pull(skb, tlv->len + sizeof(*tlv)); + } + +done: kfree_skb(skb); return 0; } diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index d06c946f7810..39f0e4522b06 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2519,13 +2519,13 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) return err; } + btintel_version_info(hdev, &version); + if (version.is_tlv_supported) { bt_dev_err(hdev, "Firmware download in tlv format is not supported"); return -EOPNOTSUPP; } - btintel_version_info(hdev, &version); - err = btusb_intel_download_firmware(hdev, &version, ¶ms); if (err) return err; -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KJ8xJS/d/l5zKQAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 09:24:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8Ob7Ii/d/l4f1AAAlp8NpQ (envelope-from ); Fri, 03 Jul 2020 09:24:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 31F2352CF9; Fri, 3 Jul 2020 09:24:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726108AbgGCHYZ convert rfc822-to-8bit (ORCPT + 1 other); Fri, 3 Jul 2020 03:24:25 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:46836 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725648AbgGCHYZ (ORCPT ); Fri, 3 Jul 2020 03:24:25 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id A2DE1CED23; Fri, 3 Jul 2020 09:34:19 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2] Bluetooth: le_supported_roles experimental feature From: Marcel Holtmann In-Reply-To: Date: Fri, 3 Jul 2020 09:24:23 +0200 Cc: Alain Michaud , BlueZ Content-Transfer-Encoding: 8BIT Message-Id: <2CCCE793-1489-4162-AD02-A5737718B956@holtmann.org> References: <20200701220853.421445-1-alainm@chromium.org> <427B6E1C-178C-405D-88F8-899EC48AC8A9@holtmann.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 31F2352CF9 X-Rspamd-UID: 074889 Hi Alain, > > This patch adds an le_supported_roles features which allows a > > clients to determine if the controller is able to support peripheral and > > central connections separately and at the same time. > > > > Signed-off-by: Alain Michaud > > --- > > > > Changes in v2: > > - Slight change of design based on offline feedback > > > > net/bluetooth/mgmt.c | 36 +++++++++++++++++++++++++++++++++++- > > 1 file changed, 35 insertions(+), 1 deletion(-) > > > > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > > index 5e9b9728eeac..c13fcc21745f 100644 > > --- a/net/bluetooth/mgmt.c > > +++ b/net/bluetooth/mgmt.c > > @@ -3753,10 +3753,36 @@ static const u8 debug_uuid[16] = { > > }; > > #endif > > > > +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ > > +static const u8 le_supported_roles[16] = { > > + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, > > + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > > +}; > > + > > +static u32 get_le_roles_flags(struct hci_dev *hdev) > > +{ > > + u32 flags = 0; > > + > > + /* Central connections supported */ > > + if (hdev->le_states[4] & 0x08) > > + flags |= BIT(0); > > + > > + /* Peripheral connections supported */ > > + if (hdev->le_states[4] & 0x40) > > + flags |= BIT(1); > > + > > + /* Simult central and peripheral connections supported */ > > + if (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && > > + (hdev->le_states[3] & 0x10)) > > + flags |= BIT(2); > > + > > + return flags; > > +} > > this is not what we can do here. The flags are defined like this. > > The following bits are defined for the Flags parameter: > > 0 Feature active > 1 Causes change in supported settings > > And I want these flags for generic handling of experimental features. Individual features can not overwrite it. > > So if you only want to support a the “read" functionality, then something like this please. > > if ((hdev->le_states[4] & 0x08) && /* Central */ > (hdev->le_states[4] & 0x40) && /* Peripheral */ > (hdev->le_states[3] & 0x10) && /* Simultaneous */ > test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks)) > flags |= BIT(0); > > OK, Since the userspace Api we discussed reports individual states, would you suggest if LE is supported that the Central and Peripheral roles are supported and just use this to query the simultaneous support? you get the Central state support from the LE setting and Peripheral from the Advertising setting. So I think the only extra information you would need is the support for both at the same time. That said, I have been discussing with Daniel if we could extend (and with that rename) the Read Security Information command and allow it to report static information about the controller support. Maybe it fits better there. However for now, I would just export this via a simple experimental feature. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uNqGGNvd/l5ddQAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 09:27:23 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qAnYFtvd/l6G4QAAlp8NpQ (envelope-from ); Fri, 03 Jul 2020 09:27:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DD46A52C46; Fri, 3 Jul 2020 09:27:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726035AbgGCH1L convert rfc822-to-8bit (ORCPT + 1 other); Fri, 3 Jul 2020 03:27:11 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:46473 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725648AbgGCH1L (ORCPT ); Fri, 3 Jul 2020 03:27:11 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 26A0DCED23; Fri, 3 Jul 2020 09:37:05 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Bluetooth: btusb: add Realtek 8822CE to blacklist_table From: Marcel Holtmann In-Reply-To: <20200703091124.1.I63705bf6abab9cb79c14f7959a59b201af2b8827@changeid> Date: Fri, 3 Jul 2020 09:27:09 +0200 Cc: linux-bluetooth , Luiz Augusto von Dentz , josephsih@google.com, chromeos-bluetooth-upstreaming , Johan Hedberg , linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <5B5301EF-4C71-4EBC-8753-C872071D4DC5@holtmann.org> References: <20200703091124.1.I63705bf6abab9cb79c14f7959a59b201af2b8827@changeid> To: Joseph Hwang X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: DD46A52C46 X-Rspamd-UID: c212b6 Hi Joseph, > This patch adds the Realtek 8822CE controller to the blacklist_table > to support the wideband speech capability. > > Signed-off-by: Joseph Hwang > --- > > drivers/bluetooth/btusb.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index 0e143c0cecf2a1..34a84c64e4c83e 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -359,6 +359,10 @@ static const struct usb_device_id blacklist_table[] = { > { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01), > .driver_info = BTUSB_IGNORE }, > > + /* Realtek 8822CE Bluetooth devices */ > + { USB_DEVICE(0x0bda, 0xb00c), .driver_info = BTUSB_REALTEK | > + BTUSB_WIDEBAND_SPEECH }, > + > /* Realtek Bluetooth devices */ > { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01), > .driver_info = BTUSB_REALTEK }, I rather not have to list these one-by-one. Can we just not globally declare support for this? Or can we have a Realtek vendor command to read this out? Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GJehDloF/155UgAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 12:15:54 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id YKX8DFoF/16a9QAA0J78UA (envelope-from ); Fri, 03 Jul 2020 12:15:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DEE59A017C; Fri, 3 Jul 2020 12:15:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725972AbgGCKPr (ORCPT + 1 other); Fri, 3 Jul 2020 06:15:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:55978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725891AbgGCKPr (ORCPT ); Fri, 3 Jul 2020 06:15:47 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 857E520720; Fri, 3 Jul 2020 10:15:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593771346; bh=riTgBkhb10cSb888g5PwM76KzzVM7R+64oGXCOixw6M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KfL3eZUxINTpmtT3zphPdyUVMVi1XnvrNzMIUouBAR8he83qRRAVSnwb+RXRVvlgn +QhbN32fW/dTYYc80UFnQfmyKTB0baxXmNA/miQQJUnT4oPmwG41HPgpmzKJTu91qD QwYZO7CW+++4iFtZcL8Mf/0xTCISMXP0tLtoZnf0= Received: by pali.im (Postfix) id 18D20121B; Fri, 3 Jul 2020 12:15:44 +0200 (CEST) Date: Fri, 3 Jul 2020 12:15:43 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Yu Liu Cc: linux-bluetooth@vger.kernel.org, Hsin-Yu Chao , Sonny Sasaka Subject: Re: [Bluez PATCH v1] device - If HFP is supported, ignore HSP Message-ID: <20200703101543.nrkpczji7zasqueg@pali> References: <20200630154855.Bluez.v1.1.I63c3ddd54189c2ad9ca9aba2c08e0925d7f0aee3@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200630154855.Bluez.v1.1.I63c3ddd54189c2ad9ca9aba2c08e0925d7f0aee3@changeid> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -7.14 / 15.00 / 200.00 X-Rspamd-Queue-Id: DEE59A017C X-Rspamd-UID: 70e74a On Tuesday 30 June 2020 15:49:34 Yu Liu wrote: > From: Hsin-Yu Chao > > For a BT headset that supports both HSP and HFP, BlueZ creates > service instances for these two profiles and connects them. > It's uncertain that which of HSP and HFP eventually get connected > and being used for SCO audio. And we start observing some problem > because of this uncertainty: > > - For headset that supports WBS, we need HFP connect for codec > negotiation. If HSP connects but not HFP, WBS cannot be used. > - For WH-1000XM3, if BlueZ ever initiated HFP connection but failed, > headset won't have working SCO audio even HSP is connected. > > Fix this at when device probes services, if HFP is in the uuid list, > don't bother create one for HSP. > > Reviewed-by: Sonny Sasaka > --- > > Changes in v1: > - Initial change > > src/device.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/src/device.c b/src/device.c > index 7b0eb256e..4036bfd81 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -4370,6 +4370,11 @@ static struct btd_service *probe_service(struct btd_device *device, > if (!device_match_profile(device, profile, uuids)) > return NULL; > > + /* If device supports HFP, don't bother create service for HSP. */ > + if (g_slist_find_custom(uuids, HFP_HS_UUID, bt_uuid_strcmp) && > + bt_uuid_strcmp(profile->remote_uuid, HSP_HS_UUID) == 0) > + return NULL; > + This patch would completely break devices with buggy HFP profile support. Also this patch disallow usage of HSP when both HSP and HFP are supported. I'm against this change as it disallow to use HSP and HFP simultaneously with hsphpfd daemon. With hsphfpd daemon it is working with non-buggy headsets. Also in pulseaudio we have more bug reports that HFP is does not work (even when advertised), but HSP is working fine. If you have a broken headset as you described in commit message, then please add some quirk for it. But do not disallow usage of HSP / HFP for all devices including non-broken ones, just because you have one broken device. > l = find_service_with_profile(device->services, profile); > if (l) > return l->data; > -- > 2.27.0.212.ge8ba1cc988-goog > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SHYBGI8s/15q/AAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 15:03:11 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MLosFo8s/158KgEAgupzMw (envelope-from ); Fri, 03 Jul 2020 15:03:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 894EE53044; Fri, 3 Jul 2020 15:03:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbgGCNDD convert rfc822-to-8bit (ORCPT + 1 other); Fri, 3 Jul 2020 09:03:03 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:32797 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726074AbgGCNDD (ORCPT ); Fri, 3 Jul 2020 09:03:03 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 28816CED26; Fri, 3 Jul 2020 15:12:57 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2] Bluetooth: le_supported_roles experimental feature From: Marcel Holtmann In-Reply-To: <2CCCE793-1489-4162-AD02-A5737718B956@holtmann.org> Date: Fri, 3 Jul 2020 15:03:01 +0200 Cc: Alain Michaud , BlueZ Content-Transfer-Encoding: 8BIT Message-Id: References: <20200701220853.421445-1-alainm@chromium.org> <427B6E1C-178C-405D-88F8-899EC48AC8A9@holtmann.org> <2CCCE793-1489-4162-AD02-A5737718B956@holtmann.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 894EE53044 X-Rspamd-UID: 672e32 Hi Alain, >>> This patch adds an le_supported_roles features which allows a >>> clients to determine if the controller is able to support peripheral and >>> central connections separately and at the same time. >>> >>> Signed-off-by: Alain Michaud >>> --- >>> >>> Changes in v2: >>> - Slight change of design based on offline feedback >>> >>> net/bluetooth/mgmt.c | 36 +++++++++++++++++++++++++++++++++++- >>> 1 file changed, 35 insertions(+), 1 deletion(-) >>> >>> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c >>> index 5e9b9728eeac..c13fcc21745f 100644 >>> --- a/net/bluetooth/mgmt.c >>> +++ b/net/bluetooth/mgmt.c >>> @@ -3753,10 +3753,36 @@ static const u8 debug_uuid[16] = { >>> }; >>> #endif >>> >>> +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ >>> +static const u8 le_supported_roles[16] = { >>> + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, >>> + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, >>> +}; >>> + >>> +static u32 get_le_roles_flags(struct hci_dev *hdev) >>> +{ >>> + u32 flags = 0; >>> + >>> + /* Central connections supported */ >>> + if (hdev->le_states[4] & 0x08) >>> + flags |= BIT(0); >>> + >>> + /* Peripheral connections supported */ >>> + if (hdev->le_states[4] & 0x40) >>> + flags |= BIT(1); >>> + >>> + /* Simult central and peripheral connections supported */ >>> + if (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && >>> + (hdev->le_states[3] & 0x10)) >>> + flags |= BIT(2); >>> + >>> + return flags; >>> +} >> >> this is not what we can do here. The flags are defined like this. >> >> The following bits are defined for the Flags parameter: >> >> 0 Feature active >> 1 Causes change in supported settings >> >> And I want these flags for generic handling of experimental features. Individual features can not overwrite it. >> >> So if you only want to support a the “read" functionality, then something like this please. >> >> if ((hdev->le_states[4] & 0x08) && /* Central */ >> (hdev->le_states[4] & 0x40) && /* Peripheral */ >> (hdev->le_states[3] & 0x10) && /* Simultaneous */ >> test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks)) >> flags |= BIT(0); >> >> OK, Since the userspace Api we discussed reports individual states, would you suggest if LE is supported that the Central and Peripheral roles are supported and just use this to query the simultaneous support? > > you get the Central state support from the LE setting and Peripheral from the Advertising setting. So I think the only extra information you would need is the support for both at the same time. > > That said, I have been discussing with Daniel if we could extend (and with that rename) the Read Security Information command and allow it to report static information about the controller support. Maybe it fits better there. However for now, I would just export this via a simple experimental feature. so something like this and then we can extend it. diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index ca0d38469e56..84a26183029d 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -3110,20 +3110,20 @@ Set Wideband Speech Command Invalid Index -Read Security Information Command -================================= +Read System Information Command +=============================== Command Code: 0x0048 Controller Index: Command Parameters: - Return Parameters: Security_Data_Length (2 Octets) - Security_Data (0-65535 Octets) + Return Parameters: System_Data_Length (2 Octets) + System_Data (0-65535 Octets) - This command is used to retrieve the supported security features - by the controller or the host stack. + This command is used to retrieve the supported system and security + features by the controller or the host stack. - The Security_Data_Length and Security_Data parameters provide - a list of security settings, features and information. It uses + The System_Data_Length and System_Data parameters provide a list + of system and security settings, features and information. It uses the same format as EIR_Data, but with the namespace defined here. Data Type Name @@ -3131,6 +3131,8 @@ Read Security Information Command 0x01 Flags 0x02 Max Encryption Key Size (BR/EDR) 0x03 Max Encryption Key Size (LE) + 0x04 Transmit Power (BR/EDR) + 0x05 Transmit Power (LE) Flags (data type 0x01) @@ -3146,6 +3148,11 @@ Read Security Information Command present, then it is unknown what the max encryption key size of the controller or host is in use. + Transmit Power (data types 0x04 and 0x05) + + When this field is present, then it provides 4 Octets + indicating min and max transmit power values. + This command generates a Command Complete event on success or a Command Status event on failure. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UB/7NdFa/152QwAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 18:20:33 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id eCV0NNFa/14BogAA0J78UA (envelope-from ); Fri, 03 Jul 2020 18:20:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 020C6A0128; Fri, 3 Jul 2020 18:20:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726236AbgGCQU1 (ORCPT + 1 other); Fri, 3 Jul 2020 12:20:27 -0400 Received: from mga05.intel.com ([192.55.52.43]:10774 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbgGCQU1 (ORCPT ); Fri, 3 Jul 2020 12:20:27 -0400 IronPort-SDR: no61GK9JPuKqki1UeFNeL4jYFs6sA45YCyUZS1AxxcRdD0L2HSlX7sUFvB9jrZXPiXxhH/a0VG dpKpxhlsgz9g== X-IronPort-AV: E=McAfee;i="6000,8403,9671"; a="232033682" X-IronPort-AV: E=Sophos;i="5.75,308,1589266800"; d="scan'208";a="232033682" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2020 09:20:26 -0700 IronPort-SDR: 7WBDWnu79obzexHNvVgFM6SQS1cbb5IsQ02Cc5lfHZEMMp8OGY1kqmXz6P978KMlacTzjWKOya aRTgZgcHjVog== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,308,1589266800"; d="scan'208";a="296244897" Received: from bgi1-mobl2.amr.corp.intel.com ([10.251.6.196]) by orsmga002.jf.intel.com with ESMTP; 03 Jul 2020 09:20:26 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ] mesh: Fix Seg Fault - App unattached IVIndex chg Date: Fri, 3 Jul 2020 09:20:18 -0700 Message-Id: <20200703162018.940172-1-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.58 / 15.00 / 200.00 X-Rspamd-Queue-Id: 020C6A0128 X-Rspamd-UID: 6636db Object path to node interfaces do not exist unless the owning application is attached. This caused a Segmentation fault if IVIndex change was signaled. Crash output: mesh/pb-adv.c:send_adv_segs() size: 01, CRC: 3e mesh/pb-adv.c:pb_adv_packet() Link closed notification: 00 mesh/net.c:update_iv_ivu_state() iv_upd_state = IV_UPD_NORMAL Program received signal SIGSEGV, Segmentation fault. 0xb6fbc1dc in strlen () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (gdb) backtrace 0 0xb6fbc1dc in strlen () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so 1 0x00448488 in l_str_hash (p=0x0) at ell/hashmap.c:168 2 0x00448980 in l_hashmap_lookup (hashmap=0x46b550, key=key@entry=0x0) at ell/hashmap.c:487 3 0x00444704 in _dbus_object_tree_property_changed (dbus=0x469438, path=0x0, interface_name=0x44bb74 "org.bluez.mesh.Node1", property_name=0x44aa18 "IVIndex") at ell/dbus-service.c:1196 4 0x0044545c in l_dbus_property_changed (dbus=, path=, interface=, property=) at ell/dbus-service.c:1804 5 0x0041805c in node_property_changed (node=, property=) at mesh/node.c:2392 6 0x0040c690 in update_iv_ivu_state (ivu=false, iv_index=0, net=0x46e240) at mesh/net.c:2569 7 process_beacon (net_ptr=0x46e240, user_data=0xbefff1e4) at mesh/net.c:2610 8 0x00431edc in l_queue_foreach (queue=, function=0x40c468 , user_data=user_data@entry=0xbefff1e4) at ell/queue.c:441 9 0x0040a848 in beacon_recv (user_data=, info=, data=, len=) at mesh/net.c:2647 10 0x00431edc in l_queue_foreach (queue=, function=0x408bec , function@entry=0x15463acd, user_data=user_data@entry=0xbefff230) at ell/queue.c:441 11 0x00409ec0 in process_rx (len=, data=0xbefff297 "+\001", addr=0xbefff258 "\260\362B", instant=4646248, rssi=-78 '\262', pvt=) at mesh/mesh-io-generic.c:121 12 event_adv_report (io=0x46c3c8, size=, buf=0xbefff255) at mesh/mesh-io-generic.c:159 13 event_callback (buf=, size=, user_data=0x46c3c8) at mesh/mesh-io- generic.c:172 14 0x0042ff58 in queue_foreach (queue=0x46d370, function=0x42f2b0 , user_data=user_data@entry= 0xbefff289) at src/shared/queue.c:219 15 0x0042f674 in process_event (size=, data=0xbefff283, hci=0x46c3d8) at src/shared/hci.c:258 16 io_read_callback (io=, user_data=0x46c3d8) at src/shared/hci.c:286 17 0x00432600 in io_callback (fd=, events=1, user_data=0x46d318) at ell/io.c:126 18 0x0043348c in l_main_iterate (timeout=) at ell/main.c:470 19 0x00433554 in l_main_run () at ell/main.c:520 20 l_main_run () at ell/main.c:502 21 0x004337b4 in l_main_run_with_signal (callback=, user_data=0x0) at ell/main.c:642 22 0x00404e90 in main (argc=, argv=) at mesh/main.c:269 (gdb) --- mesh/node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh/node.c b/mesh/node.c index 9f0f15070..3e888ce61 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -2388,7 +2388,7 @@ void node_property_changed(struct mesh_node *node, const char *property) { struct l_dbus *bus = dbus_get_bus(); - if (bus) + if (bus && node->obj_path) l_dbus_property_changed(dbus_get_bus(), node->obj_path, MESH_NODE_INTERFACE, property); } -- 2.25.4 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sB/QGUxh/16KMgAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 18:48:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aAQhGExh/16joQEAlp8NpQ (envelope-from ); Fri, 03 Jul 2020 18:48:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1E900A1BEA; Fri, 3 Jul 2020 18:48:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726157AbgGCQsG (ORCPT + 1 other); Fri, 3 Jul 2020 12:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726111AbgGCQsG (ORCPT ); Fri, 3 Jul 2020 12:48:06 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EB25C061794 for ; Fri, 3 Jul 2020 09:48:06 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id ed14so4008636qvb.2 for ; Fri, 03 Jul 2020 09:48:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=anG1Oo2SNB8vzM8YnvrDtiCG6DNwKsTBaFN00s1SrCk=; b=FPTwC4ZAFWvLMGg3RDSlj9UUUnFJzO1uO/lI+RXDR7rzM6T8jR5Ci1ubOH85rETm7L sfWLZ1QtsoQZ4wo//YBpP5kIE7e5e2UnfEm1iXpPv3i0VPLg/Vxt1ov1v1y5YGj0Pfvn 93pWrHKBXf8elbISwweFY8B15NDyk/lJSqnUdhfasAG4yBYKGRAf4ppMD0ctYljmqBtr n+Yu0kistjIh7DT/Ko96eYTDCUnBDSKTPaGAEc6hc9Y9PFUid6IBx9SFmOca7qo34CS8 E8SzU32nnDLnmgvf6ptPipUAN0gD9qAJXWVljCAQlUUVkgR4kF3kCKzr61MfO6xeh3Y9 NFQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=anG1Oo2SNB8vzM8YnvrDtiCG6DNwKsTBaFN00s1SrCk=; b=Hp8p4ukRUL9MTS3bB0PSp3YYaCL6jQUnhDTanJjwv6p88daU6b+ozaqvEn9Q/Mxl3u viwG20wqgITpOrCtnWI7/XxINU2q/AQ+TTVbCAz8eklRSv/1EfNhu3vJEeikz0l9HRkV u8bfwi1QnN5iCMwmBgTUqUXj2aMfQDhHbiMR/mSPjx2ENW4l2Jhfh2R59jc+aWUUZTY7 vs6nIh5+bVCKdjWXqj5Zy5r12s6VG8J08O/Q4BXWIjS56bVaMONvs1vpZhwdP729S7ph qHEL6crhYzoYEmXHFZqh/mYvucZnM5fcDefSsuGzuAZ01xpx88LEkyQFf+xf9tU+5YLG /C2g== X-Gm-Message-State: AOAM530q8jchjvwEhGLTtNf04t/EOG3OUK+BDki6YensYHjD5eZyIyhY KFTRutGfSyk/nwFKVFtZZxZbwcjheiA= X-Google-Smtp-Source: ABdhPJyvrw2adc1hlFo2gwdk4eW+iHlJihdEE4RnYyC+6TU/4/JfEiT0gQ4QCjHjzZ09x7OACuRp3A== X-Received: by 2002:a05:6214:72c:: with SMTP id c12mr33580149qvz.76.1593794884913; Fri, 03 Jul 2020 09:48:04 -0700 (PDT) Received: from [172.17.0.2] ([104.208.240.96]) by smtp.gmail.com with ESMTPSA id d13sm10940183qkj.27.2020.07.03.09.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2020 09:48:04 -0700 (PDT) Message-ID: <5eff6144.1c69fb81.489f1.ba81@mx.google.com> Date: Fri, 03 Jul 2020 09:48:04 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============1451388738377639551==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, brian.gix@intel.com Subject: RE: [BlueZ] mesh: Fix Seg Fault - App unattached IVIndex chg Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200703162018.940172-1-brian.gix@intel.com> References: <20200703162018.940172-1-brian.gix@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 22 X-Rspamd-Score: 3.39 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1E900A1BEA X-Rspamd-UID: 0a4393 --===============1451388738377639551== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #19: 0 0xb6fbc1dc in strlen () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so - total: 0 errors, 1 warnings, 8 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============1451388738377639551==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SEf0F7mfAF+76wEAvsO+Rg (envelope-from ) for ; Sat, 04 Jul 2020 17:26:49 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +OVCFrmfAF9hSwAAlScrYA (envelope-from ); Sat, 04 Jul 2020 17:26:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C96254ACCA; Sat, 4 Jul 2020 17:26:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726639AbgGDP0l convert rfc822-to-8bit (ORCPT + 1 other); Sat, 4 Jul 2020 11:26:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:46680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbgGDP0k (ORCPT ); Sat, 4 Jul 2020 11:26:40 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 206235] kernel BUG at mm/slub.c:294 Date: Sat, 04 Jul 2020 15:26:39 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: steffen@sdaoden.eu X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: WILL_NOT_FIX X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_kernel_version resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.55 / 15.00 / 200.00 X-Rspamd-Queue-Id: C96254ACCA X-Rspamd-UID: 794f41 https://bugzilla.kernel.org/show_bug.cgi?id=206235 Steffen Nurpmeso (steffen@sdaoden.eu) changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Kernel Version|4.19.107 |4.19.128 Resolution|--- |WILL_NOT_FIX --- Comment #4 from Steffen Nurpmeso (steffen@sdaoden.eu) --- Hello. It happened again, but the trace is the same. I am updating to kernel series 5.4 now, so i close this, ok? I post nonetheless because here the second RIP comes without the leading [cut here], which made me wonder a bit. Jul 4 01:04:15 kent kernel: wlp1s0: deauthenticating from d0:5b:a8:4a:88:84 by local choice (Reason: 3=DEAUTH_LEAVING) Jul 4 01:06:36 kent kernel: ------------[ cut here ]------------ Jul 4 01:06:36 kent kernel: kernel BUG at mm/slub.c:294! Jul 4 01:06:36 kent kernel: invalid opcode: 0000 [#1] PREEMPT SMP PTI Jul 4 01:06:36 kent kernel: CPU: 2 PID: 2563 Comm: rfkill Tainted: G C 4.19.128-kent #1 Jul 4 01:06:36 kent kernel: Hardware name: LENOVO 81EU/LNVNB161216, BIOS 7PCN35WW 09/25/2018 Jul 4 01:06:36 kent kernel: RIP: 0010:__slab_free.isra.20+0x1be/0x2a0 Jul 4 01:06:36 kent kernel: Code: 75 6a 80 7c 24 4b 00 79 05 40 84 f6 74 1e 48 8d 65 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 80 4c 24 4b 80 4d 89 ef e9 03 ff ff ff <0f> 0b 48 8d 65 d8 4c 89 e6 4c 89 f7 ba 01 00 00 00 5b 41 5c 41 5d Jul 4 01:06:36 kent kernel: RSP: 0018:ffffb199c0ea3cd0 EFLAGS: 00010246 Jul 4 01:06:36 kent kernel: RAX: ffff99812a296d00 RBX: ffff99812a296d00 RCX: ffff99812a296d00 Jul 4 01:06:36 kent kernel: RDX: 0000000080200015 RSI: ffffe21e84a8a580 RDI: ffff998264d2b200 Jul 4 01:06:36 kent kernel: RBP: ffffb199c0ea3d60 R08: 0000000000000001 R09: ffff99812a296d00 Jul 4 01:06:36 kent kernel: R10: 0000310c568441a2 R11: 0000000000000400 R12: ffffe21e84a8a580 Jul 4 01:06:36 kent kernel: R13: ffff99812a296d00 R14: ffff998264d2b200 R15: 0000000000000000 Jul 4 01:06:36 kent kernel: FS: 00007f83a8795740(0000) GS:ffff998266a80000(0000) knlGS:0000000000000000 Jul 4 01:06:36 kent kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 Jul 4 01:06:36 kent kernel: CR2: 000055e1a95c65a8 CR3: 0000000132bba002 CR4: 00000000003606e0 Jul 4 01:06:36 kent kernel: Call Trace: Jul 4 01:06:36 kent kernel: ? finish_wait+0x2a/0x60 Jul 4 01:06:36 kent kernel: ? __hci_cmd_sync_ev+0x20a/0x230 Jul 4 01:06:36 kent kernel: kmem_cache_free+0x19b/0x1c0 Jul 4 01:06:36 kent kernel: btrtl_shutdown_realtek+0x2b/0x50 Jul 4 01:06:36 kent kernel: hci_dev_do_close+0x3cf/0x480 Jul 4 01:06:36 kent kernel: hci_rfkill_set_block+0x37/0x50 Jul 4 01:06:36 kent kernel: rfkill_set_block+0x8f/0x140 Jul 4 01:06:36 kent kernel: rfkill_fop_write+0x12a/0x1d0 Jul 4 01:06:36 kent kernel: __vfs_write+0x31/0x180 Jul 4 01:06:36 kent kernel: vfs_write+0xa4/0x190 Jul 4 01:06:36 kent kernel: ksys_write+0x52/0xd0 Jul 4 01:06:36 kent kernel: do_syscall_64+0x5a/0x190 Jul 4 01:06:36 kent kernel: ? prepare_exit_to_usermode+0x66/0x90 Jul 4 01:06:36 kent kernel: entry_SYSCALL_64_after_hwframe+0x44/0xa9 Jul 4 01:06:36 kent kernel: RIP: 0033:0x7f83a8882644 Jul 4 01:06:36 kent kernel: Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b3 0f 1f 80 00 00 00 00 48 8d 05 b9 50 0d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53 Jul 4 01:06:36 kent kernel: RSP: 002b:00007fff97dfdf48 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 Jul 4 01:06:36 kent kernel: RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f83a8882644 Jul 4 01:06:36 kent kernel: RDX: 0000000000000008 RSI: 00007fff97dfdf60 RDI: 0000000000000003 Jul 4 01:06:36 kent kernel: RBP: 0000000000000001 R08: 0000000000000003 R09: 0000000000000000 Jul 4 01:06:36 kent kernel: R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 Jul 4 01:06:36 kent kernel: R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Jul 4 01:06:36 kent kernel: Modules linked in: r8822be(C) Jul 4 01:06:36 kent kernel: ---[ end trace 4107545f4866f48c ]--- ul 4 01:06:36 kent kernel: RIP: 0010:__slab_free.isra.20+0x1be/0x2a0 Jul 4 01:06:36 kent kernel: Code: 75 6a 80 7c 24 4b 00 79 05 40 84 f6 74 1e 48 8d 65 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 80 4c 24 4b 80 4d 89 ef e9 03 ff ff ff <0f> 0b 48 8d 65 d8 4c 89 e6 4c 89 f7 ba 01 00 00 00 5b 41 5c 41 5d Jul 4 01:06:36 kent kernel: RSP: 0018:ffffb199c0ea3cd0 EFLAGS: 00010246 Jul 4 01:06:36 kent kernel: RAX: ffff99812a296d00 RBX: ffff99812a296d00 RCX: ffff99812a296d00 Jul 4 01:06:36 kent kernel: RDX: 0000000080200015 RSI: ffffe21e84a8a580 RDI: ffff998264d2b200 Jul 4 01:06:36 kent kernel: RBP: ffffb199c0ea3d60 R08: 0000000000000001 R09: ffff99812a296d00 Jul 4 01:06:36 kent kernel: R10: 0000310c568441a2 R11: 0000000000000400 R12: ffffe21e84a8a580 Jul 4 01:06:36 kent kernel: R13: ffff99812a296d00 R14: ffff998264d2b200 R15: 0000000000000000 Jul 4 01:06:36 kent kernel: FS: 00007f83a8795740(0000) GS:ffff998266a80000(0000) knlGS:0000000000000000 Jul 4 01:06:36 kent kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 Jul 4 01:06:36 kent kernel: CR2: 000055e1a95c65a8 CR3: 0000000132bba002 CR4: 00000000003606e0 Jul 4 01:13:22 kent kernel: device v_i left promiscuous mode Jul 4 01:13:22 kent kernel: v_br: port 1(v_i) entered disabled state Jul 4 15:43:14 kent kernel: microcode: microcode updated early to revision 0xd6, date = 2020-04-27 Jul 4 15:43:14 kent kernel: Linux version 4.19.128-kent (guest@kent) (gcc version 8.4.0 (CRUX-x86_64-multilib)) #1 SMP PREEMPT Sat Jun 13 18:36:47 CEST 2020 -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uJyhMVFh/17uZgAAvsO+Rg (envelope-from ) for ; Fri, 03 Jul 2020 18:48:17 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UwdYMFFh/16loQEAlp8NpQ (envelope-from ); Fri, 03 Jul 2020 18:48:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 87553A3142; Fri, 3 Jul 2020 18:48:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726258AbgGCQsJ (ORCPT + 1 other); Fri, 3 Jul 2020 12:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726111AbgGCQsJ (ORCPT ); Fri, 3 Jul 2020 12:48:09 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE5D2C061794 for ; Fri, 3 Jul 2020 09:48:08 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id p7so14513730qvl.4 for ; Fri, 03 Jul 2020 09:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=+Up3ZyusUMy5a05aqkaTQkkIYPZzDl5XBJxyPMX+it0=; b=PtqjlbhSLTmQO1d7KKTY+8lTpdB5g+QZ6wapSwOgt5FythAPnLehodmvuohu6Jydg/ 8wKYFTxGLgguWfHNWwD2w028isoYkscPOWDfaFy7tE4f6CR5BaVRgK4K+KpGpyOj0oF1 Vy+956THND+H1LBWGxcACs+DBf8cSRBjozvqVSKnNWtqxblw6ybdkBzENbhcsF88dECb DZ0ghvJ9il/zneRdhASyIGhTxW1Lhop2G2FLTQO2NruZuX+Ozh3nT4yKSv5dZTIpsteg oK9gd/cv9KpUf0epbxg4DrIh1r9MnlmHwBeTlA64hMk3/s5FgcmluwOk8c9lV/D8KNty mcHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=+Up3ZyusUMy5a05aqkaTQkkIYPZzDl5XBJxyPMX+it0=; b=R02OngppKUBMe+0x2Yap5plHTUKtR6JzJbBzhLRlK94b90WuMKtckAkt76jGQA6VIj Nyu3zvHZNsrw43moTXm2u3gZv4opiYBZfj+bZBlU3V6U5mH+5S0Ml5WKluNlZpMh0xfg LCT3hZ2BwH7qPoCBwTloSKfZ49ym3vG7ufV4N/+Y5SKn6OI0aSFpTKl9AVn35rwKR3PO DaoEYY2OwcjdhMKq1asfUWBFX5vzpG9zixqNK9Bg8djxfWlX/LCLnWaAx5LU/d0+LsQ5 f8SvX1BuuBppV6LxL/l2GpK2s8dnOMKk5z2JEMephozvbRA3SqL8l++5O6Bu8EVEQh6z UaSA== X-Gm-Message-State: AOAM5335YYPkJj5w6G4TH0y44QL60uWpW+I7lVjDHCMoOoldU3OckCQW y9ENN1TRf4rInMPKCvEwT8Heq8mk2Xw= X-Google-Smtp-Source: ABdhPJzzM3mYpacsN2/wNA/Q9AMF3j98FaaWEvUTVTX6/bCWcW1uq1+n4ootpI40yKfEKZ9vV2M7wg== X-Received: by 2002:a05:6214:370:: with SMTP id t16mr34934204qvu.206.1593794887998; Fri, 03 Jul 2020 09:48:07 -0700 (PDT) Received: from [172.17.0.2] ([104.208.240.96]) by smtp.gmail.com with ESMTPSA id h41sm1041599qtk.68.2020.07.03.09.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2020 09:48:07 -0700 (PDT) Message-ID: <5eff6147.1c69fb81.05e7.58b9@mx.google.com> Date: Fri, 03 Jul 2020 09:48:07 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============6795625013646968184==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, brian.gix@intel.com Subject: RE: [BlueZ] mesh: Fix Seg Fault - App unattached IVIndex chg Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200703162018.940172-1-brian.gix@intel.com> References: <20200703162018.940172-1-brian.gix@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 32 X-Rspamd-Score: 4.93 / 15.00 / 200.00 X-Rspamd-Queue-Id: 87553A3142 X-Rspamd-UID: 5765a7 --===============6795625013646968184== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 18: B1 Line exceeds max length (92>80): "2 0x00448980 in l_hashmap_lookup (hashmap=0x46b550, key=key@entry=0x0) at ell/hashmap.c:487" 19: B1 Line exceeds max length (186>80): "3 0x00444704 in _dbus_object_tree_property_changed (dbus=0x469438, path=0x0, interface_name=0x44bb74 "org.bluez.mesh.Node1", property_name=0x44aa18 "IVIndex") at ell/dbus-service.c:1196" 20: B1 Line exceeds max length (165>80): "4 0x0044545c in l_dbus_property_changed (dbus=, path=, interface=, property=) at ell/dbus-service.c:1804" 21: B1 Line exceeds max length (107>80): "5 0x0041805c in node_property_changed (node=, property=) at mesh/node.c:2392" 22: B1 Line exceeds max length (93>80): "6 0x0040c690 in update_iv_ivu_state (ivu=false, iv_index=0, net=0x46e240) at mesh/net.c:2569" 24: B1 Line exceeds max length (149>80): "8 0x00431edc in l_queue_foreach (queue=, function=0x40c468 , user_data=user_data@entry=0xbefff1e4) at ell/queue.c:441" 25: B1 Line exceeds max length (140>80): "9 0x0040a848 in beacon_recv (user_data=, info=, data=, len=) at mesh/net.c:2647" 26: B1 Line exceeds max length (182>80): "10 0x00431edc in l_queue_foreach (queue=, function=0x408bec , function@entry=0x15463acd, user_data=user_data@entry=0xbefff230) at ell/queue.c:441" 27: B1 Line exceeds max length (188>80): "11 0x00409ec0 in process_rx (len=, data=0xbefff297 "+\001", addr=0xbefff258 "\260\362B", instant=4646248, rssi=-78 '\262', pvt=) at mesh/mesh-io-generic.c:121" 28: B1 Line exceeds max length (101>80): "12 event_adv_report (io=0x46c3c8, size=, buf=0xbefff255) at mesh/mesh-io-generic.c:159" 29: B1 Line exceeds max length (112>80): "13 event_callback (buf=, size=, user_data=0x46c3c8) at mesh/mesh-io- generic.c:172" 30: B1 Line exceeds max length (148>80): "14 0x0042ff58 in queue_foreach (queue=0x46d370, function=0x42f2b0 , user_data=user_data@entry= 0xbefff289) at src/shared/queue.c:219" 31: B1 Line exceeds max length (108>80): "15 0x0042f674 in process_event (size=, data=0xbefff283, hci=0x46c3d8) at src/shared/hci.c:258" 32: B1 Line exceeds max length (84>80): "16 io_read_callback (io=, user_data=0x46c3d8) at src/shared/hci.c:286" 33: B1 Line exceeds max length (95>80): "17 0x00432600 in io_callback (fd=, events=1, user_data=0x46d318) at ell/io.c:126" 37: B1 Line exceeds max length (99>80): "21 0x004337b4 in l_main_run_with_signal (callback=, user_data=0x0) at ell/main.c:642" 38: B1 Line exceeds max length (85>80): "22 0x00404e90 in main (argc=, argv=) at mesh/main.c:269" --- Regards, Linux Bluetooth --===============6795625013646968184==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IDzxAlQoAl8FegEAvsO+Rg (envelope-from ) for ; Sun, 05 Jul 2020 21:21:56 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id sLtMAVQoAl+qiAEAlp8NpQ (envelope-from ); Sun, 05 Jul 2020 21:21:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 40F3FA27B1; Sun, 5 Jul 2020 21:21:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727842AbgGETVr (ORCPT + 1 other); Sun, 5 Jul 2020 15:21:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727781AbgGETVq (ORCPT ); Sun, 5 Jul 2020 15:21:46 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7899EC061794 for ; Sun, 5 Jul 2020 12:21:46 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id r12so38487374wrj.13 for ; Sun, 05 Jul 2020 12:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=8Hja5VcLLy1RGMrUMqsHxzuU/DDmvRgUxzFKmXiKvHs=; b=TYxhHsMeUuD5Fydk6Q9l+Is3ZC1NB8Z1hoEEIKPgrJXOAbhRFMZ2Pqx5jKBpb38an3 Hy2dQHI9glvdtSvyn/6vKdBsyXe3pYMule5RTeWCrtvXMkSRYjoCn2ofNIAvT9I1MHK+ sIg52sXIsmvObicd6Q0+n9rFwyZay+ExKouyZYitgYqeVUgNOjToLUdpHM20vH5zOvFp yLyAOcEDTa2fUQU5GEImpCfRr3cPMsjtHLDNP3TYnbyRqaO2D4oclA2hQO8WTS6nmlAz CnFql5eIGjQ3EpeqqSoWtv6SvSvW0OenDBLutEBzoe/1Eue49x3wLLjrB8m2waqg2pGF Kz5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=8Hja5VcLLy1RGMrUMqsHxzuU/DDmvRgUxzFKmXiKvHs=; b=Qh42So+HJWiUGaWIcJNj7S8OK71J4qGC7lnL5lLdsb+gV1NS8rveCpe3L7rBD5MDwH v0/0n07TCH6OJ7805rxTWpl1MNRrDTZdVOfTkqxsrI4O1ChdmSvpt6QhKuMVDMCKd0gc YEfz4NB7qyQwael1GOApEmia2quXSH8KcmOWQhuImbwI6GXoTj1on8IQmg9B7MnwWXQ+ 8NfIAdI8jcvahoZ/VgX8ftx6ntqlE+E9tWNS+RRGe8UsAKxVyIk/9QK0Sdv0XKi9TFAU 1k5fYcrglJbJ7VXvmkMhc/VOy8CPDAKpSdggwVp9MxTYt7i97+toNRPqekA0rtZtitrI vFxQ== X-Gm-Message-State: AOAM530AikTQmKzo3m4j2Fya9B4EjMA9XMR2GY2CBW6rPIVu4MsoRggk duUW8WhvEid1nIog4HcsgZPf0HTi X-Google-Smtp-Source: ABdhPJxLGG7bZwL5kO9yUaVFfzmeMlGstdi828BnYgkQWIXWfEB6lX/nna/+QMxHpA79HLzuIR/FSA== X-Received: by 2002:a5d:538e:: with SMTP id d14mr45550302wrv.21.1593976904926; Sun, 05 Jul 2020 12:21:44 -0700 (PDT) Received: from 168.52.45.77 (201.ip-51-68-45.eu. [51.68.45.201]) by smtp.gmail.com with ESMTPSA id z1sm21242044wru.30.2020.07.05.12.21.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 05 Jul 2020 12:21:43 -0700 (PDT) From: Ismael Ferreras Morezuelas Subject: [PATCH v3] Bluetooth: btusb: Fix and detect most of the Chinese Bluetooth controllers To: BlueZ Cc: Marcel Holtmann , Johan Hedberg Message-ID: <6bce2c08-48f0-f49c-d70c-280475220550@gmail.com> Date: Sun, 5 Jul 2020 21:21:41 +0200 User-Agent: nano 6.4 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.79 / 15.00 / 200.00 X-Rspamd-Queue-Id: 40F3FA27B1 X-Rspamd-UID: 3addd3 For some reason they tend to squat on the very first CSR/ Cambridge Silicon Radio VID/PID instead of paying fees. This is an extremely common problem; the issue goes as back as 2013 and these devices are only getting more popular, even rebranded by reputable vendors and sold by retailers everywhere. So, at this point in time there are hundreds of modern dongles reusing the ID of what originally was an early Bluetooth 1.1 controller. Linux is the only place where they don't work due to spotty checks in our detection code. It only covered a minimum subset. So what's the big idea? Take advantage of the fact that all CSR chips report the same internal version as both the LMP sub-version and HCI revision number. It always matches, couple that with the manufacturer code, that rarely lies, and we now have a good idea of who is who. Additionally, by compiling a list of user-reported HCI/lsusb dumps, and searching around for legit CSR dongles in similar product ranges we can find what CSR BlueCore firmware supported which Bluetooth versions. That way we can narrow down ranges of fakes for each of them. e.g. Real CSR dongles with LMP subversion 0x73 are old enough that support BT 1.1 only; so it's a dead giveaway when some third-party BT 4.0 dongle reuses it. So, to sum things up; there are multiple classes of fake controllers reusing the same 0A12:0001 VID/PID. This has been broken for a while. Known 'fake' bcdDevices: 0x0100, 0x0134, 0x1915, 0x2520, 0x7558, 0x8891 IC markings on 0x7558: FR3191AHAL 749H15143 (???) https://bugzilla.kernel.org/show_bug.cgi?id=60824 Fixes: 81cac64ba258ae (Deal with USB devices that are faking CSR vendor) Reported-by: Michał Wiśniewski Tested-by: Mike Johnson Tested-by: Ismael Ferreras Morezuelas Signed-off-by: Ismael Ferreras Morezuelas --- Changes in v3: * Find an even better way of detecting which type is which; use the best parts of v1 and v2 and combine them with previous feedback. * Additionally, detect fakes by comparing against a BlueCore firmware numbers and their supported protocol versions. * Introduce HCI_QUIRK_BROKEN_ERR_DATA_REPORTING and use it on all fake chips. It doesn't seem to cause any drawback, and if we make it too specific a lot of these chips won't work at all, so it's probably better than nothing. Other user reported being able to finally pair with their stereo A2DP speaker with this fix. * Limit the use of btusb_setup_csr() only to cover 0A12:0001. * Use bt_dev_warn for the fake detection notice. * Remove all other noisy bt_dev_info() calls. Changes in v2: * Find a better way of detecting which type is which; scrap the wonky >=Bluetooth 1.2 protocol check and instead do what's described above. * Move all the quirk logic to btusb_setup_csr(), simplify it a bit. * Use a switch statement and list all the known broken bcdDevice instead of trying to penalize the real CSR devices. * Add two bt_dev_info() prints because this may be important in the future, given the amount of variables we are playing with here. * Try to keep my comments within a 80-column limit. Now I'm able of pairing with Android devices, A2DP headphones, DS4 controllers and more; whereas previously set up failed and userland software couldn't even scan with it. This patch probably uncovers other quirks in some of these previously *unusable* dongles, so it's probably a good start point so that other fixes can be implemented on top. Looking forward to fine-tune these checks in the future. Let me know what you think. drivers/bluetooth/btusb.c | 74 ++++++++++++++++++++++++++----- include/net/bluetooth/bluetooth.h | 2 + include/net/bluetooth/hci.h | 11 +++++ net/bluetooth/hci_core.c | 6 ++- 4 files changed, 81 insertions(+), 12 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 5f022e9cf..89686379a 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -1720,6 +1720,7 @@ static int btusb_setup_csr(struct hci_dev *hdev) { struct hci_rp_read_local_version *rp; struct sk_buff *skb; + bool is_fake = false; BT_DBG("%s", hdev->name); @@ -1739,18 +1740,69 @@ static int btusb_setup_csr(struct hci_dev *hdev) rp = (struct hci_rp_read_local_version *)skb->data; - /* Detect controllers which aren't real CSR ones. */ + /* Detect a wide host of Chinese controllers that aren't CSR. + * + * Known fake bcdDevices: 0x0100, 0x0134, 0x1915, 0x2520, 0x7558, 0x8891 + * + * The main thing they have in common is that these are really popular low-cost + * options that support newer Bluetooth versions but rely on heavy VID/PID + * squatting of this poor old Bluetooth 1.1 device. Even sold as such. + * + * We detect actual CSR devices by checking that the HCI manufacturer code + * is Cambridge Silicon Radio (10) and ensuring that LMP sub-version and + * HCI rev values always match. As they both store the firmware number. + */ if (le16_to_cpu(rp->manufacturer) != 10 || - le16_to_cpu(rp->lmp_subver) == 0x0c5c) { + le16_to_cpu(rp->hci_rev) != le16_to_cpu(rp->lmp_subver)) + is_fake = true; + + /* Known legit CSR firmware build numbers and their supported BT versions: + * - 1.1 (0x1) -> 0x0073, 0x020d, 0x033c, 0x034e + * - 1.2 (0x2) -> 0x04d9, 0x0529 + * - 2.0 (0x3) -> 0x07a6, 0x07ad, 0x0c5c + * - 2.1 (0x4) -> 0x149c, 0x1735, 0x1899 (0x1899 is a BlueCore4-External) + * - 4.0 (0x6) -> 0x1d86, 0x2031, 0x22bb + * + * e.g. Real CSR dongles with LMP subversion 0x73 are old enough that + * support BT 1.1 only; so it's a dead giveaway when some + * third-party BT 4.0 dongle reuses it. + */ + if (le16_to_cpu(rp->lmp_subver) <= 0x034e && + le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_1_1) + is_fake = true; + + if (le16_to_cpu(rp->lmp_subver) <= 0x0529 && + le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_1_2) + is_fake = true; + + if (le16_to_cpu(rp->lmp_subver) <= 0x0c5c && + le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_2_0) + is_fake = true; + + if (le16_to_cpu(rp->lmp_subver) <= 0x1899 && + le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_2_1) + is_fake = true; + + if (le16_to_cpu(rp->lmp_subver) <= 0x22bb && + le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_4_0) + is_fake = true; + + if (is_fake) { + bt_dev_warn(hdev, "CSR: Unbranded CSR clone detected; adding workarounds..."); + + /* Generally these clones have big discrepancies between + * advertised features and what's actually supported. + * Probably will need to be expanded in the future; + * without these the controller will lock up. + */ + set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks); + set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks); + /* Clear the reset quirk since this is not an actual * early Bluetooth 1.1 device from CSR. */ clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); - - /* These fake CSR controllers have all a broken - * stored link key handling and so just disable it. - */ - set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks); + clear_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); } kfree_skb(skb); @@ -4001,11 +4053,13 @@ static int btusb_probe(struct usb_interface *intf, if (bcdDevice < 0x117) set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); + /* This must be set first in case we disable it for fakes */ + set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); + /* Fake CSR devices with broken commands */ - if (bcdDevice <= 0x100 || bcdDevice == 0x134) + if (udev->descriptor.idVendor == 0x0a12 && + udev->descriptor.idProduct == 0x0001) hdev->setup = btusb_setup_csr; - - set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); } if (id->driver_info & BTUSB_SNIFFER) { diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 181900553..155019220 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -41,6 +41,8 @@ #define BLUETOOTH_VER_1_1 1 #define BLUETOOTH_VER_1_2 2 #define BLUETOOTH_VER_2_0 3 +#define BLUETOOTH_VER_2_1 4 +#define BLUETOOTH_VER_4_0 6 /* Reserv for core and drivers use */ #define BT_SKB_RESERVE 8 diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 16ab6ce87..1c321b6d1 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -227,6 +227,17 @@ enum { * supported. */ HCI_QUIRK_VALID_LE_STATES, + + /* When this quirk is set, then erroneous data reporting + * is ignored. This is mainly due to the fact that the HCI + * Read Default Erroneous Data Reporting command is advertised, + * but not supported; these controllers often reply with unknown + * command and tend to lock up randomly. Needing a hard reset. + * + * This quirk can be set before hci_register_dev is called or + * during the hdev->setup vendor callback. + */ + HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, }; /* HCI device flags */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index dbe2d79f2..48d7c7e23 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -606,7 +606,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt) if (hdev->commands[8] & 0x01) hci_req_add(req, HCI_OP_READ_PAGE_SCAN_ACTIVITY, 0, NULL); - if (hdev->commands[18] & 0x04) + if (hdev->commands[18] & 0x04 && + !test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks)) hci_req_add(req, HCI_OP_READ_DEF_ERR_DATA_REPORTING, 0, NULL); /* Some older Broadcom based Bluetooth 1.2 controllers do not @@ -851,7 +852,8 @@ static int hci_init4_req(struct hci_request *req, unsigned long opt) /* Set erroneous data reporting if supported to the wideband speech * setting value */ - if (hdev->commands[18] & 0x08) { + if (hdev->commands[18] & 0x08 && + !test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks)) { bool enabled = hci_dev_test_flag(hdev, HCI_WIDEBAND_SPEECH_ENABLED); -- 2.22.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IDxDH1wvAl8JjAEAvsO+Rg (envelope-from ) for ; Sun, 05 Jul 2020 21:51:56 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qIauHVwvAl8N0gEAlp8NpQ (envelope-from ); Sun, 05 Jul 2020 21:51:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E42E641952; Sun, 5 Jul 2020 21:51:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728199AbgGETvf (ORCPT + 1 other); Sun, 5 Jul 2020 15:51:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728192AbgGETvd (ORCPT ); Sun, 5 Jul 2020 15:51:33 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69290C061794; Sun, 5 Jul 2020 12:51:33 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id j19so10539794pgm.11; Sun, 05 Jul 2020 12:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1DM6xVZWZJvMpDAjz6LICmJeK1B/WJSbpsotDSZl8bo=; b=SPAw+UuKw/tc6ApBfi4rN3P+pttZynhKwUcVcFYKjqUkKctxLFn2VoCr3QEqTlxy5R djmSMDePYrzvTBaL/umG7PRUYgOxbs4YQ/m6cuXJJaNtYQQR16mIctgtJWtODWsHmraR 0+BOXSMK0BcPHEjbXtycUdTyDmdqDnFR1DKlmc35OCN3YoRhkL3/Bq67iC1LLv6A/kHa hJ/GXUO0R6ruDn2rnEBGEnq4AUJQ22b9Kpb9yS8j017V61tVXi1bDChx/dA5yU/1EZjX M8VeCKdMKCOdiv8S7QzUWSUnx05TiL1CXExHk49vefmlzzmDMEwdA4rowrrPRElSyUZ1 lloA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1DM6xVZWZJvMpDAjz6LICmJeK1B/WJSbpsotDSZl8bo=; b=GUqKUCy6bszKGsl65awK7MVEjK9u4YnNWowyCnhsCaAKXOdbv70VhffXiKLLH0NY9o 1d8gZDW3lUIUlTpmeSIpClT/7hqKNUnya19fCtm9JPKvOrOY8tyqXJvt24zlkVuvyb0y dmDUJ4c92tgAwjqB2E6K2JTWvGAskS/uF5o8djnzMI+p9LJ4dIyaKemcL3ZJbvqUYYJ+ VpuIjH2oCpqOjbbOZgtMzYJJ46ZcLhZ4+n5BGpc0kHSjfaslXXFFiKN6T29T5SwK4Kvm JgW9ZNFoOH9WxP4NILiy1UjOh5PiPr1v72y4WXq8YZqV/zQQeWRF1VnfJHG3Hd4JP/+w YLFQ== X-Gm-Message-State: AOAM533ZhvgVddogdm04NAWznHjU0t1nfAUjTjpUDvvjx1yRSNnw3ajg VsAo6+jEDLelpVkZrNdB7PM= X-Google-Smtp-Source: ABdhPJywhEIbbZJi+sfs9qoPVmo6wP+zmVvWXONJnb9edBcUmKAyA7A9x6PsWAfDc8TF7Hc/tKx3Vg== X-Received: by 2002:a65:5c08:: with SMTP id u8mr7911082pgr.184.1593978693025; Sun, 05 Jul 2020 12:51:33 -0700 (PDT) Received: from anarsoul-thinkpad.lan (216-71-213-236.dyn.novuscom.net. [216.71.213.236]) by smtp.gmail.com with ESMTPSA id g9sm16072879pfm.151.2020.07.05.12.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 12:51:32 -0700 (PDT) From: Vasily Khoruzhick To: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Marcel Holtmann , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, Ondrej Jirman Cc: Vasily Khoruzhick Subject: [PATCH 3/3] arm64: allwinner: a64: enable Bluetooth On Pinebook Date: Sun, 5 Jul 2020 12:51:10 -0700 Message-Id: <20200705195110.405139-4-anarsoul@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200705195110.405139-1-anarsoul@gmail.com> References: <20200705195110.405139-1-anarsoul@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.31 / 15.00 / 200.00 X-Rspamd-Queue-Id: E42E641952 X-Rspamd-UID: c939cb Pinebook has an RTL8723CS WiFi + BT chip, BT is connected to UART1 and uses PL5 as device wake GPIO, PL6 as host wake GPIO the I2C controlling signals are connected to R_I2C bus. Enable it in the device tree. Signed-off-by: Vasily Khoruzhick --- .../arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts index 64b1c54f87c0..e63ff271be4e 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts @@ -408,6 +408,18 @@ &uart0 { status = "okay"; }; +&uart1 { + pinctrl-names = "default"; + pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>; + status = "okay"; + + bluetooth { + compatible = "realtek,rtl8723cs-bt"; + device-wake-gpios = <&r_pio 0 5 GPIO_ACTIVE_LOW>; /* PL5 */ + host-wake-gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */ + }; +}; + &usb_otg { dr_mode = "host"; }; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0Hk6CGcvAl8suwEAvsO+Rg (envelope-from ) for ; Sun, 05 Jul 2020 21:52:07 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wMNIBmcvAl+hVwEAlScrYA (envelope-from ); Sun, 05 Jul 2020 21:52:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 85CB340079; Sun, 5 Jul 2020 21:52:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728185AbgGETvc (ORCPT + 1 other); Sun, 5 Jul 2020 15:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728006AbgGETvb (ORCPT ); Sun, 5 Jul 2020 15:51:31 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E865C061794; Sun, 5 Jul 2020 12:51:31 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id q17so16080733pfu.8; Sun, 05 Jul 2020 12:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7RJ6rE3+V5FkJZxVb3v+pVHBk2ZYQcboCzbdh+i0x+E=; b=rDPbtc8vdEMGwEPSHOV5kjTzILxUmRSxurBdo2x2VNrnCmNg2CA4bK0En8Ox5voIVu jflBYMA4ESDAWl5Z5xfAI1Z0QOsgQFDF+9EILJPiVkk7sbSYqF+PGpppNvj28yCpvV1e J3uX+qBHX8q98F9wSaUQxa1WzQBoq7FP2jsovR3BMmfkY+GRu6HXMA0LRHtTJuZ1/KPr ROQRuXbp4XcX2Cuj7m5cpn9QaxXC/kdiSpQdHsNsHVDwtHf009y0ToxFBFQ+AGfulJJ/ QWwblLBZYGdcv/RLUYKFXpvuuTg0YzYH0IAVca3Wb435JlEfrsATbmwoSu+6K0pgbVVU jATg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7RJ6rE3+V5FkJZxVb3v+pVHBk2ZYQcboCzbdh+i0x+E=; b=Vm4WrgtoYuITeKaybUxVTkYxyZ16McvAsD5pCaa6TI5N2OOa1MA2C2qNKjEYmS4non 2poRfp01eGf8TkxoEDFcJghEodLqnCYhek1t1gw3uT+Wos+2Mdo2elWG5LVjs3gjr5mf XpVzSZgASBSHtUX50HCtD2mFhCoqgQeXXYl7djM+d4dUeKuINSgBycQQqW1iMsZPHOML 4WCoB4la8nxpt6rmpf4Cok4GBlF6Ntyz87uFsS45506/74NzjZFZesMfjj2cYS3MfLB6 xfZkRM9P9EBXvXaehXBJQnIMERMcNKyY4s13HP1vwHdOtm8c9IBeIAkS0suimO3uHmJi Odnw== X-Gm-Message-State: AOAM532rpKkucXYOWH3VmXFQT9Qw1jCluizsZ/jVaqsY6edevOvpMZtn xeyawXE2R4h9YMMHe2hRueY= X-Google-Smtp-Source: ABdhPJyx/0NFcW6FSUxmSN3DKYwTjkoKbr6mmBjMln0ATSOvaHAugjHxaxi03vs9u8Jiv8C8NEH4gQ== X-Received: by 2002:a63:4b04:: with SMTP id y4mr37299434pga.158.1593978690666; Sun, 05 Jul 2020 12:51:30 -0700 (PDT) Received: from anarsoul-thinkpad.lan (216-71-213-236.dyn.novuscom.net. [216.71.213.236]) by smtp.gmail.com with ESMTPSA id g9sm16072879pfm.151.2020.07.05.12.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 12:51:30 -0700 (PDT) From: Vasily Khoruzhick To: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Marcel Holtmann , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, Ondrej Jirman Cc: Vasily Khoruzhick Subject: [PATCH 1/3] Bluetooth: Add new quirk for broken local ext features max_page Date: Sun, 5 Jul 2020 12:51:08 -0700 Message-Id: <20200705195110.405139-2-anarsoul@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200705195110.405139-1-anarsoul@gmail.com> References: <20200705195110.405139-1-anarsoul@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.31 / 15.00 / 200.00 X-Rspamd-Queue-Id: 85CB340079 X-Rspamd-UID: 2cfff7 Some adapters (e.g. RTL8723CS) advertise that they have more than 2 pages for local ext features, but they don't support any features declared in these pages. RTL8723CS reports max_page = 2 and declares support for sync train and secure connection, but it responds with either garbage or with error in status on corresponding commands. Signed-off-by: Vasily Khoruzhick --- include/net/bluetooth/hci.h | 7 +++++++ net/bluetooth/hci_event.c | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 16ab6ce87883..8e4c16210d18 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -227,6 +227,13 @@ enum { * supported. */ HCI_QUIRK_VALID_LE_STATES, + + /* When this quirk is set, max_page for local extended features + * is set to 1, even if controller reports higher number. Some + * controllers (e.g. RTL8723CS) report more pages, but they + * don't actually support features declared there. + */ + HCI_QUIRK_BROKEN_LOCAL_EXT_FTR_MAX_PAGE, }; /* HCI device flags */ diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index cfeaee347db3..df3232828978 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -700,7 +700,9 @@ static void hci_cc_read_local_ext_features(struct hci_dev *hdev, if (rp->status) return; - if (hdev->max_page < rp->max_page) + if (!test_bit(HCI_QUIRK_BROKEN_LOCAL_EXT_FTR_MAX_PAGE, + &hdev->quirks) && + hdev->max_page < rp->max_page) hdev->max_page = rp->max_page; if (rp->page < HCI_MAX_PAGES) -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YCBLB3MvAl8suwEAvsO+Rg (envelope-from ) for ; Sun, 05 Jul 2020 21:52:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SIGGBXMvAl+GYAAADc0bRg (envelope-from ); Sun, 05 Jul 2020 21:52:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 042E840B79; Sun, 5 Jul 2020 21:52:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728235AbgGETvp (ORCPT + 1 other); Sun, 5 Jul 2020 15:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728186AbgGETvc (ORCPT ); Sun, 5 Jul 2020 15:51:32 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A2A7C061794; Sun, 5 Jul 2020 12:51:32 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id s26so2457054pfm.4; Sun, 05 Jul 2020 12:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8RxFxHIhRTfQ88Ajho7DUEkvdSU53o3E/+ucacuAmuE=; b=Bktc9PzW6m4mPw2XM4Xdx6aHmmtp8uLEGH6FQtz/qRUEXqbPUGISVr/88AVm7ef1wE SunZuw6hXvyU45Ne5nRcaxe9n4AwXU7tA6nSNjWBxWR8n5LQCCzwJC/6PRRnBtO1WAAi NFMV7epswHOjjdaBzKn0G3Lq01YAm04+1VpRVz8kH5avSiQ/ojc/qGWzB39EDsRQKYzN UZ+DsQGp7dMB02TG0RZk/y83bSLKe7t6ZnvntncTsKcXOXiYUtvx/XUPqf0OUgC5UJS5 x1LzRwYcT8uYHj6HjXDwEP5QWT3TolXtdPsJo6ahDCmC01nEflFdAxhi2QHg21tuboIg A3BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8RxFxHIhRTfQ88Ajho7DUEkvdSU53o3E/+ucacuAmuE=; b=P8Y+26xB9nb3rXq2yjv+DdlPffLMuS7Wl9yHke7QKKx+esorGzqg4qFQsJAJIUMX9M UFCGHJ/C7vZL70NAwGT2zouLXJSeInfiZP57PUQ7hk6efoD8faVTpEAE5djj4chgjxCB awzp3oKY3c0P7XvbDN8KX4uM8lnvbTAHRGW+Y1SCdNZptThUe+WqgmJoI1JaeFSheMPe ha++vOo3GqwsQgwJaokRV0eU7xqrNhfua9ci58mw7Jr+gNv47cg6ExT9kIFXHRpDbaUl Ts3+8ZaJQhws5g7GkZfq0T9ERLPyRgnb68PsnRKP9ou4//iUZbKOjdswVElLskMWvF27 ZoMQ== X-Gm-Message-State: AOAM533hxB1/Kjb7IH6/ryGK6IjZTnU0EAyhJWiE5eEWtknxizw1ONK1 33cOYvdcHTHWcI9pKwr1orw= X-Google-Smtp-Source: ABdhPJx0WNg6bGOmMJrb7U7L3guow3K3YcqBQHTFI7xacMV1PvqLzsL08lfqIXiMjAaaSeOxG6dXhQ== X-Received: by 2002:a63:d44e:: with SMTP id i14mr23030045pgj.280.1593978692106; Sun, 05 Jul 2020 12:51:32 -0700 (PDT) Received: from anarsoul-thinkpad.lan (216-71-213-236.dyn.novuscom.net. [216.71.213.236]) by smtp.gmail.com with ESMTPSA id g9sm16072879pfm.151.2020.07.05.12.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 12:51:31 -0700 (PDT) From: Vasily Khoruzhick To: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Marcel Holtmann , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, Ondrej Jirman Cc: Vasily Khoruzhick Subject: [PATCH 2/3] Bluetooth: btrtl: add support for the RTL8723CS Date: Sun, 5 Jul 2020 12:51:09 -0700 Message-Id: <20200705195110.405139-3-anarsoul@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200705195110.405139-1-anarsoul@gmail.com> References: <20200705195110.405139-1-anarsoul@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 8 X-Rspamd-Score: 1.31 / 15.00 / 200.00 X-Rspamd-Queue-Id: 042E840B79 X-Rspamd-UID: 57a896 The Realtek RTL8723CS is SDIO WiFi chip. It also contains a Bluetooth module which is connected via UART to the host. It shares lmp subversion with 8703B, so Realtek's userspace initialization tool (rtk_hciattach) differentiates varieties of RTL8723CS (CG, VF, XX) with RTL8703B using vendor's command to read chip type. Also this chip declares support for some features it doesn't support so add a quirk to indicate that these features are broken. Signed-off-by: Vasily Khoruzhick --- drivers/bluetooth/btrtl.c | 128 ++++++++++++++++++++++++++++++++++++- drivers/bluetooth/btrtl.h | 12 ++++ drivers/bluetooth/hci_h5.c | 6 ++ 3 files changed, 143 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index 3a9afc905f24..8c7b35abe492 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -17,8 +17,12 @@ #define VERSION "0.1" +#define RTL_CHIP_8723CS_CG 3 +#define RTL_CHIP_8723CS_VF 4 +#define RTL_CHIP_8723CS_XX 5 #define RTL_EPATCH_SIGNATURE "Realtech" #define RTL_ROM_LMP_3499 0x3499 +#define RTL_ROM_LMP_8703B 0x8703 #define RTL_ROM_LMP_8723A 0x1200 #define RTL_ROM_LMP_8723B 0x8723 #define RTL_ROM_LMP_8723D 0x8873 @@ -31,6 +35,7 @@ #define IC_MATCH_FL_HCIREV (1 << 1) #define IC_MATCH_FL_HCIVER (1 << 2) #define IC_MATCH_FL_HCIBUS (1 << 3) +#define IC_MATCH_FL_CHIP_TYPE (1 << 4) #define IC_INFO(lmps, hcir) \ .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV, \ .lmp_subver = (lmps), \ @@ -42,6 +47,7 @@ struct id_table { __u16 hci_rev; __u8 hci_ver; __u8 hci_bus; + __u8 chip_type; bool config_needed; bool has_rom_version; char *fw_name; @@ -89,6 +95,39 @@ static const struct id_table ic_id_table[] = { .fw_name = "rtl_bt/rtl8723b_fw.bin", .cfg_name = "rtl_bt/rtl8723b_config" }, + /* 8723CS-CG */ + { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_CHIP_TYPE | + IC_MATCH_FL_HCIBUS, + .lmp_subver = RTL_ROM_LMP_8703B, + .chip_type = RTL_CHIP_8723CS_CG, + .hci_bus = HCI_UART, + .config_needed = true, + .has_rom_version = true, + .fw_name = "rtl_bt/rtl8723cs_cg_fw.bin", + .cfg_name = "rtl_bt/rtl8723cs_cg_config" }, + + /* 8723CS-VF */ + { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_CHIP_TYPE | + IC_MATCH_FL_HCIBUS, + .lmp_subver = RTL_ROM_LMP_8703B, + .chip_type = RTL_CHIP_8723CS_VF, + .hci_bus = HCI_UART, + .config_needed = true, + .has_rom_version = true, + .fw_name = "rtl_bt/rtl8723cs_vf_fw.bin", + .cfg_name = "rtl_bt/rtl8723cs_vf_config" }, + + /* 8723CS-XX */ + { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_CHIP_TYPE | + IC_MATCH_FL_HCIBUS, + .lmp_subver = RTL_ROM_LMP_8703B, + .chip_type = RTL_CHIP_8723CS_XX, + .hci_bus = HCI_UART, + .config_needed = true, + .has_rom_version = true, + .fw_name = "rtl_bt/rtl8723cs_xx_fw.bin", + .cfg_name = "rtl_bt/rtl8723cs_xx_config" }, + /* 8723D */ { IC_INFO(RTL_ROM_LMP_8723B, 0xd), .config_needed = true, @@ -171,7 +210,8 @@ static const struct id_table ic_id_table[] = { }; static const struct id_table *btrtl_match_ic(u16 lmp_subver, u16 hci_rev, - u8 hci_ver, u8 hci_bus) + u8 hci_ver, u8 hci_bus, + u8 chip_type) { int i; @@ -188,6 +228,9 @@ static const struct id_table *btrtl_match_ic(u16 lmp_subver, u16 hci_rev, if ((ic_id_table[i].match_flags & IC_MATCH_FL_HCIBUS) && (ic_id_table[i].hci_bus != hci_bus)) continue; + if ((ic_id_table[i].match_flags & IC_MATCH_FL_CHIP_TYPE) && + (ic_id_table[i].chip_type != chip_type)) + continue; break; } @@ -270,6 +313,7 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev, { RTL_ROM_LMP_8723B, 1 }, { RTL_ROM_LMP_8821A, 2 }, { RTL_ROM_LMP_8761A, 3 }, + { RTL_ROM_LMP_8703B, 7 }, { RTL_ROM_LMP_8822B, 8 }, { RTL_ROM_LMP_8723B, 9 }, /* 8723D */ { RTL_ROM_LMP_8821A, 10 }, /* 8821C */ @@ -545,6 +589,48 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, return ret; } +static bool rtl_has_chip_type(u16 lmp_subver) +{ + switch (lmp_subver) { + case RTL_ROM_LMP_8703B: + return true; + default: + break; + } + + return false; +} + +static int rtl_read_chip_type(struct hci_dev *hdev, u8 *type) +{ + struct rtl_chip_type_evt *chip_type; + struct sk_buff *skb; + const unsigned char cmd_buf[] = {0x00, 0x94, 0xa0, 0x00, 0xb0}; + + /* Read RTL chip type command */ + skb = __hci_cmd_sync(hdev, 0xfc61, 5, cmd_buf, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + rtl_dev_err(hdev, "Read chip type failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + + if (skb->len != sizeof(*chip_type)) { + rtl_dev_err(hdev, "RTL chip type event length mismatch"); + kfree_skb(skb); + return -EIO; + } + + chip_type = (struct rtl_chip_type_evt *)skb->data; + rtl_dev_info(hdev, "chip_type status=%x type=%x", + chip_type->status, chip_type->type); + + *type = chip_type->type & 0x0f; + + kfree_skb(skb); + return 0; +} + void btrtl_free(struct btrtl_device_info *btrtl_dev) { kvfree(btrtl_dev->fw_data); @@ -561,7 +647,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, struct hci_rp_read_local_version *resp; char cfg_name[40]; u16 hci_rev, lmp_subver; - u8 hci_ver; + u8 hci_ver, chip_type = 0; int ret; btrtl_dev = kzalloc(sizeof(*btrtl_dev), GFP_KERNEL); @@ -586,8 +672,14 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, lmp_subver = le16_to_cpu(resp->lmp_subver); kfree_skb(skb); + if (rtl_has_chip_type(lmp_subver)) { + ret = rtl_read_chip_type(hdev, &chip_type); + if (ret) + goto err_free; + } + btrtl_dev->ic_info = btrtl_match_ic(lmp_subver, hci_rev, hci_ver, - hdev->bus); + hdev->bus, chip_type); if (!btrtl_dev->ic_info) { rtl_dev_info(hdev, "unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x", @@ -660,6 +752,7 @@ int btrtl_download_firmware(struct hci_dev *hdev, case RTL_ROM_LMP_8821A: case RTL_ROM_LMP_8761A: case RTL_ROM_LMP_8822B: + case RTL_ROM_LMP_8703B: return btrtl_setup_rtl8723b(hdev, btrtl_dev); default: rtl_dev_info(hdev, "assuming no firmware upload needed"); @@ -678,7 +771,12 @@ int btrtl_setup_realtek(struct hci_dev *hdev) return PTR_ERR(btrtl_dev); ret = btrtl_download_firmware(hdev, btrtl_dev); + if (ret) + goto out_free; + btrtl_apply_quirks(hdev, btrtl_dev); + +out_free: btrtl_free(btrtl_dev); /* Enable controller to do both LE scan and BR/EDR inquiry @@ -818,6 +916,24 @@ int btrtl_get_uart_settings(struct hci_dev *hdev, } EXPORT_SYMBOL_GPL(btrtl_get_uart_settings); +void btrtl_apply_quirks(struct hci_dev *hdev, + struct btrtl_device_info *btrtl_dev) +{ + switch (btrtl_dev->ic_info->lmp_subver) { + case RTL_ROM_LMP_8703B: + /* 8723CS reports two pages for local ext features, + * but it doesn't support any features from page 2 - + * it either responds with garbage or with error status + */ + set_bit(HCI_QUIRK_BROKEN_LOCAL_EXT_FTR_MAX_PAGE, + &hdev->quirks); + break; + default: + break; + } +} +EXPORT_SYMBOL_GPL(btrtl_apply_quirks); + MODULE_AUTHOR("Daniel Drake "); MODULE_DESCRIPTION("Bluetooth support for Realtek devices ver " VERSION); MODULE_VERSION(VERSION); @@ -827,6 +943,12 @@ MODULE_FIRMWARE("rtl_bt/rtl8723b_fw.bin"); MODULE_FIRMWARE("rtl_bt/rtl8723b_config.bin"); MODULE_FIRMWARE("rtl_bt/rtl8723bs_fw.bin"); MODULE_FIRMWARE("rtl_bt/rtl8723bs_config.bin"); +MODULE_FIRMWARE("rtl_bt/rtl8723cs_cg_fw.bin"); +MODULE_FIRMWARE("rtl_bt/rtl8723cs_cg_config.bin"); +MODULE_FIRMWARE("rtl_bt/rtl8723cs_vf_fw.bin"); +MODULE_FIRMWARE("rtl_bt/rtl8723cs_vf_config.bin"); +MODULE_FIRMWARE("rtl_bt/rtl8723cs_xx_fw.bin"); +MODULE_FIRMWARE("rtl_bt/rtl8723cs_xx_config.bin"); MODULE_FIRMWARE("rtl_bt/rtl8723ds_fw.bin"); MODULE_FIRMWARE("rtl_bt/rtl8723ds_config.bin"); MODULE_FIRMWARE("rtl_bt/rtl8761a_fw.bin"); diff --git a/drivers/bluetooth/btrtl.h b/drivers/bluetooth/btrtl.h index 2a582682136d..152ed2ece4c2 100644 --- a/drivers/bluetooth/btrtl.h +++ b/drivers/bluetooth/btrtl.h @@ -14,6 +14,11 @@ struct btrtl_device_info; +struct rtl_chip_type_evt { + __u8 status; + __u8 type; +} __packed; + struct rtl_download_cmd { __u8 index; __u8 data[RTL_FRAG_LEN]; @@ -60,6 +65,8 @@ int btrtl_get_uart_settings(struct hci_dev *hdev, struct btrtl_device_info *btrtl_dev, unsigned int *controller_baudrate, u32 *device_baudrate, bool *flow_control); +void btrtl_apply_quirks(struct hci_dev *hdev, + struct btrtl_device_info *btrtl_dev); #else @@ -96,6 +103,11 @@ static inline int btrtl_get_uart_settings(struct hci_dev *hdev, bool *flow_control) { return -ENOENT; + +static inline void btrtl_apply_quirks(struct hci_dev *hdev, + struct btrtl_device_info *btrtl_dev) +{ +} } #endif diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index e60b2e0773db..c34acab9e8ac 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c @@ -904,6 +904,10 @@ static int h5_btrtl_setup(struct h5 *h5) err = btrtl_download_firmware(h5->hu->hdev, btrtl_dev); /* Give the device some time before the hci-core sends it a reset */ usleep_range(10000, 20000); + if (err) + goto out_free; + + btrtl_apply_quirks(h5->hu->hdev, btrtl_dev); out_free: btrtl_free(btrtl_dev); @@ -1020,6 +1024,8 @@ static const struct of_device_id rtl_bluetooth_of_match[] = { .data = (const void *)&rtl_vnd }, { .compatible = "realtek,rtl8723bs-bt", .data = (const void *)&rtl_vnd }, + { .compatible = "realtek,rtl8723cs-bt", + .data = (const void *)&rtl_vnd }, #endif { }, }; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SLAaLnYvAl+fsQEAvsO+Rg (envelope-from ) for ; Sun, 05 Jul 2020 21:52:22 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id KMGoLHYvAl98jQAA0J78UA (envelope-from ); Sun, 05 Jul 2020 21:52:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3A7BA4D6C0; Sun, 5 Jul 2020 21:52:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728139AbgGETva (ORCPT + 1 other); Sun, 5 Jul 2020 15:51:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728006AbgGETva (ORCPT ); Sun, 5 Jul 2020 15:51:30 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F184C061794; Sun, 5 Jul 2020 12:51:30 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id u18so782796pfk.10; Sun, 05 Jul 2020 12:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3mJ//dF2UdH+rMidooXAGoMJs/gWdqGSD9KZJf42iTw=; b=p8xZbkhs+DbIDcbMjb4gSiF+czEN1o55lIQEib7q/iq6WSsVjoh9tcuu780oo/K9b5 fLXgr8Wr6bZBCITk7jKb1hIIx0cqCEm9k+OSETNV7afrljx9CHIDlBDdOx18GRf2SNxx uFJvL+4n6hT6ktayyGGdvYleeZU78Kb0aL0YlodwQSnv33L1qx7D2jC/BvJpQDk63hFX 51ykPSIhoVcF0F5x1J79N+SsfhKjcMxwiQ/4RS8HjN/yi94IcDY9g/wDcVdn8l0iF4Nz gEVUT176CAxrPSDR7gA53kbAZxWMrowoNxReq71eu315UbxSPwR2Xerb3hRlFz9CB8k5 s73A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3mJ//dF2UdH+rMidooXAGoMJs/gWdqGSD9KZJf42iTw=; b=e71a/CGcfP5aLi3UQwF9QQqV8afuKKBBz83P+cYY180272cZz3evPivIlBjAjZhpm0 awLsdLugkQX+hLExZPVwf3BNFuKbFR4BKRo9DHneqGBJBUZ1AUL+DQD5okSR3izH5Eeo kKSDaYVRwhQTGMqm5Z2FVJe2OWjpg+ekQAadpkxwxi7Wc+5j+PEWONYst8Mu/8cd7Elb 6XVYO96x9uRjePqynzwUus738itmf1kDig5lQU6DXbOqvwPN7QrxW43lWVgEF3cmR6tO Xz8RYqGVMWV5uwGL16+WDu3h0JBVGw0isH5ZGqLlMA/T3eL/oEjeeMsv3JnlaczkV0f9 5hdw== X-Gm-Message-State: AOAM530v9m3ZQKIemLVcfW68C0hW0fzcTf24Dc5a+uMNEoiLSQiflSqm xVGdcjiGEmYMgHNqV0DAWcU= X-Google-Smtp-Source: ABdhPJy6IBNuTNcV1yL+0S/fz5uBmP+u7Vze7qmbvouZ/MIxJi2Vltxe+zo6hKV1mg5Vp2jRQQn44w== X-Received: by 2002:a63:4521:: with SMTP id s33mr29729095pga.388.1593978689678; Sun, 05 Jul 2020 12:51:29 -0700 (PDT) Received: from anarsoul-thinkpad.lan (216-71-213-236.dyn.novuscom.net. [216.71.213.236]) by smtp.gmail.com with ESMTPSA id g9sm16072879pfm.151.2020.07.05.12.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 12:51:28 -0700 (PDT) From: Vasily Khoruzhick To: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Marcel Holtmann , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, Ondrej Jirman Cc: Vasily Khoruzhick Subject: [PATCH 0/3] arm64: allwinner: a64: add bluetooth support for Pinebook Date: Sun, 5 Jul 2020 12:51:07 -0700 Message-Id: <20200705195110.405139-1-anarsoul@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 23 X-Rspamd-Score: 3.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3A7BA4D6C0 X-Rspamd-UID: 840883 Pinebook uses RTL8723CS for WiFi and bluetooth. Unfortunately RTL8723CS has broken BT-4.1 support, so it requires a quirk. Add a quirk, wire up 8723CS support in btrtl and enable bluetooth in Pinebook dts. Vasily Khoruzhick (3): Bluetooth: Add new quirk for broken local ext features max_page Bluetooth: btrtl: add support for the RTL8723CS arm64: allwinner: a64: enable Bluetooth On Pinebook .../dts/allwinner/sun50i-a64-pinebook.dts | 12 ++ drivers/bluetooth/btrtl.c | 128 +++++++++++++++++- drivers/bluetooth/btrtl.h | 12 ++ drivers/bluetooth/hci_h5.c | 6 + include/net/bluetooth/hci.h | 7 + net/bluetooth/hci_event.c | 4 +- 6 files changed, 165 insertions(+), 4 deletions(-) -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8LwDDiw+Al+iEwAAvsO+Rg (envelope-from ) for ; Sun, 05 Jul 2020 22:55:08 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MNARDCw+Al/usQEAlScrYA (envelope-from ); Sun, 05 Jul 2020 22:55:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EA6BFA213D; Sun, 5 Jul 2020 22:55:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728263AbgGEUzC (ORCPT + 1 other); Sun, 5 Jul 2020 16:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728056AbgGEUzB (ORCPT ); Sun, 5 Jul 2020 16:55:01 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 811A5C061794 for ; Sun, 5 Jul 2020 13:55:01 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id 17so39542454wmo.1 for ; Sun, 05 Jul 2020 13:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=JfCRq0yAQSqEnZ+BJ++zg1D86ATDnpdb5dG2rsEII9g=; b=eJmZK4rBlU5HIpBkKO5zEVqFQW+IX37J3WSqVbasXODb2SptQ1LIvtpk+WxT2SJ4pC Q+dweqx6gDF8Tbtx0BR4jRFKveTFG/XqGU/FCG9bgO+vt2j1ISR6xEmSZMYXfMiG/roR hFpyRzcoahRD5dQVaYeuSbmBJ3U1xYH33jvHj9EOqM9YeTNYv91VO//6wQ3VgCZTkr/7 kJZI/VXk7xHkoETVC6bIvVy4LHxQA2UXsZJwQHq+96GU1BDLXpa+RKGXciJayiUzaal9 KN6Jx8IjIKkN4rW+PQ1Koa1/KGJUsGCMwecgBUSkU2+sYo+yM43vCQ1rxnrKdcNP7nGO HUJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=JfCRq0yAQSqEnZ+BJ++zg1D86ATDnpdb5dG2rsEII9g=; b=Osvff5l3/j3vCfA4XTwrh5ZJ21so9Dz0hZfqyY/LshgoaQYKID71zNvnVzPLOOnRF3 nj9UbjkD3B90cZj9CIyXGOcauaDEDIH4VryVIYW8qLKR3nDI0GONiR9xjXAdHX9UP/8S 8Zb0ldttrMiS/3sCMfk2GFo9CmhFxO29q9wJKVHWj3tw9mnPwhpZxuWyyySLxnbR1RZm mKM1vkeyJORJDWAyT6hWhW+J1XVMKQNppZ3rHp3V3Duxq99cmec45qAIlQtt0rmuObgl EgrmQhBOSQORWh7URU4GbnFEOd2zFJbohfbV6pcqUQj/ULaBxDesx84A/77yv6LWgDeY eQiA== X-Gm-Message-State: AOAM530trbmLGsmS1TYAWl6D7ICzB+2dtMpWTJZWjjf7LiH0JRBeuxHW dhWo9DEeRYnOmxayU5/S2HGT1xt0 X-Google-Smtp-Source: ABdhPJy9mccU/ZJxWwsD/PKwt2JFY/WBN1kA+AchaK3Hpb/mEW0crbqaJAiwGYmz9Yl92VSA59APvQ== X-Received: by 2002:a1c:2982:: with SMTP id p124mr46107096wmp.26.1593982500319; Sun, 05 Jul 2020 13:55:00 -0700 (PDT) Received: from 168.52.45.77 (201.ip-51-68-45.eu. [51.68.45.201]) by smtp.gmail.com with ESMTPSA id 92sm22757522wrr.96.2020.07.05.13.54.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 05 Jul 2020 13:54:59 -0700 (PDT) Subject: Re: [PATCH v3] Bluetooth: btusb: Fix and detect most of the Chinese Bluetooth controllers From: Swyter To: BlueZ Cc: Marcel Holtmann , Johan Hedberg References: <6bce2c08-48f0-f49c-d70c-280475220550@gmail.com> Message-ID: <1bff6e62-1815-ffe7-a06e-8e303b717e46@gmail.com> Date: Sun, 5 Jul 2020 22:54:57 +0200 User-Agent: nano 6.4 MIME-Version: 1.0 In-Reply-To: <6bce2c08-48f0-f49c-d70c-280475220550@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: EA6BFA213D X-Rspamd-UID: 9fe797 On 05/07/2020 21:21, Ismael Ferreras Morezuelas wrote: > @@ -4001,11 +4053,13 @@ static int btusb_probe(struct usb_interface *intf, > if (bcdDevice < 0x117) > set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); > > + /* This must be set first in case we disable it for fakes */ > + set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); > + > /* Fake CSR devices with broken commands */ > - if (bcdDevice <= 0x100 || bcdDevice == 0x134) > + if (udev->descriptor.idVendor == 0x0a12 && > + udev->descriptor.idProduct == 0x0001) > hdev->setup = btusb_setup_csr; Noticed that I'm probably missing a few le16_to_cpu() there, from what I've seen in other places. I'll keep it in mind. Self-review. :) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +LpLLnSbAl+E7AEAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 05:33:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CClhLHSbAl+Q0gEAlp8NpQ (envelope-from ); Mon, 06 Jul 2020 05:33:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5E11F400FA; Mon, 6 Jul 2020 05:33:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728724AbgGFDcw (ORCPT + 1 other); Sun, 5 Jul 2020 23:32:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728686AbgGFDcv (ORCPT ); Sun, 5 Jul 2020 23:32:51 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FCCCC08C5DE for ; Sun, 5 Jul 2020 20:32:51 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id t11so11542208pfq.11 for ; Sun, 05 Jul 2020 20:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=dJ6KC89zq4JHk4HwHxXJeuQRbWKXL9v2dmGLn/RXOwQ=; b=hjZ+nHV3lTcZ+01aIKLB+dzeetHzoQdvvxOzyZNfNlbqqkMgwfMtp9tXKOxOyrpS2y ie4OLrhQkJp940oZJyyy3LeOiP1Pfi0yzbPf36LczrG5OZslSkAgiOpjUvEUuvppiDtk GMzehUp2bnqH7S5OThRfcfQ3EUMXa+Si4/FVw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dJ6KC89zq4JHk4HwHxXJeuQRbWKXL9v2dmGLn/RXOwQ=; b=bEUaI5tPJHADPVhMBOe74JiFc5OJg35ReQnzyG7UXNQJBfrtVmWGAixB6Jj6n8XO17 Q6+W2e+kQuvo33P2HKi2wFDOrUi7yhHm3JbyY3KCwUuEKiO1YBhvcAdw8r9LWbJd2Vdr 5kqZlD+3XrGnUMi0exofYxOwq5IL3Gmwt3HLH102o9PNT4bgMQAirXoaNzIt/8trLnNs hDmFNeSzfnhif9iT/MFjOkCmwbmFgK7j89BoWz29NPbCDk5o7vnpkETCfl2ldFCoXXeo g0g72gzLgChZ4vPPaoFd4OZqFzI5uILawh7U8RI1RZXSkVVdUNQ2X8dg8ncFAlABXQDx KjsA== X-Gm-Message-State: AOAM531q7WDiuRU04YoVWhHfPQqLDXCnwmhcQVeYcuDc9XmmibSeI5jj tnqzakV6I1LYLiV0O55y/29u0A== X-Google-Smtp-Source: ABdhPJyXLbBZZRqMW0IFSiPfcpoFoDD04pDA5gw2IyyJHGwCVkr/7j8KHqWKBMg/0Sj3/ImpBH9j6Q== X-Received: by 2002:aa7:8f2a:: with SMTP id y10mr41288831pfr.182.1594006370798; Sun, 05 Jul 2020 20:32:50 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id bg6sm16835521pjb.51.2020.07.05.20.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 20:32:49 -0700 (PDT) Date: Sun, 5 Jul 2020 20:32:48 -0700 From: Kees Cook To: Jukka Rissanen , Johan Hedberg Cc: davem@davemloft.net, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, syzbot , Michael Scott , Josua Mayer Subject: Re: use-after-free in Bluetooth: 6lowpan (was Re: KASAN: use-after-free Write in refcount_warn_saturate) Message-ID: <202007052022.984BAD97@keescook> References: <00000000000055e1a9059f9e169f@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00000000000055e1a9059f9e169f@google.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5E11F400FA X-Rspamd-UID: 2ba333 On Thu, Feb 27, 2020 at 11:50:11PM -0800, syzbot wrote: > Hello, > > syzbot found the following crash on: > > HEAD commit: f8788d86 Linux 5.6-rc3 > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=13005fd9e00000 > kernel config: https://syzkaller.appspot.com/x/.config?x=9833e26bab355358 > dashboard link: https://syzkaller.appspot.com/bug?extid=7dd7f2f77a7a01d1dc14 > compiler: gcc (GCC) 9.0.0 20181231 (experimental) > userspace arch: i386 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17e3ebede00000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16a9f8f9e00000 > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > Reported-by: syzbot+7dd7f2f77a7a01d1dc14@syzkaller.appspotmail.com > > ================================================================== > BUG: KASAN: use-after-free in atomic_set include/asm-generic/atomic-instrumented.h:44 [inline] > BUG: KASAN: use-after-free in refcount_set include/linux/refcount.h:123 [inline] > BUG: KASAN: use-after-free in refcount_warn_saturate+0x1f/0x1f0 lib/refcount.c:15 > Write of size 4 at addr ffff888090eb4018 by task kworker/1:24/2888 > > CPU: 1 PID: 2888 Comm: kworker/1:24 Not tainted 5.6.0-rc3-syzkaller #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 > Workqueue: events do_enable_set > Call Trace: > __dump_stack lib/dump_stack.c:77 [inline] > dump_stack+0x197/0x210 lib/dump_stack.c:118 > print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374 > __kasan_report.cold+0x1b/0x32 mm/kasan/report.c:506 > kasan_report+0x12/0x20 mm/kasan/common.c:641 > check_memory_region_inline mm/kasan/generic.c:185 [inline] > check_memory_region+0x134/0x1a0 mm/kasan/generic.c:192 > __kasan_check_write+0x14/0x20 mm/kasan/common.c:101 > atomic_set include/asm-generic/atomic-instrumented.h:44 [inline] > refcount_set include/linux/refcount.h:123 [inline] > refcount_warn_saturate+0x1f/0x1f0 lib/refcount.c:15 > refcount_sub_and_test include/linux/refcount.h:261 [inline] > refcount_dec_and_test include/linux/refcount.h:281 [inline] > kref_put include/linux/kref.h:64 [inline] > l2cap_chan_put+0x1d9/0x240 net/bluetooth/l2cap_core.c:498 > do_enable_set+0x54b/0x960 net/bluetooth/6lowpan.c:1075 > process_one_work+0xa05/0x17a0 kernel/workqueue.c:2264 > worker_thread+0x98/0xe40 kernel/workqueue.c:2410 > kthread+0x361/0x430 kernel/kthread.c:255 > ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 > > Allocated by task 2888: > save_stack+0x23/0x90 mm/kasan/common.c:72 > set_track mm/kasan/common.c:80 [inline] > __kasan_kmalloc mm/kasan/common.c:515 [inline] > __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:488 > kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529 > kmem_cache_alloc_trace+0x158/0x790 mm/slab.c:3551 > kmalloc include/linux/slab.h:555 [inline] > kzalloc include/linux/slab.h:669 [inline] > l2cap_chan_create+0x45/0x3a0 net/bluetooth/l2cap_core.c:446 > chan_create+0x10/0xe0 net/bluetooth/6lowpan.c:640 > bt_6lowpan_listen net/bluetooth/6lowpan.c:959 [inline] > do_enable_set+0x583/0x960 net/bluetooth/6lowpan.c:1078 > process_one_work+0xa05/0x17a0 kernel/workqueue.c:2264 > worker_thread+0x98/0xe40 kernel/workqueue.c:2410 > kthread+0x361/0x430 kernel/kthread.c:255 > ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 > > Freed by task 2975: > save_stack+0x23/0x90 mm/kasan/common.c:72 > set_track mm/kasan/common.c:80 [inline] > kasan_set_free_info mm/kasan/common.c:337 [inline] > __kasan_slab_free+0x102/0x150 mm/kasan/common.c:476 > kasan_slab_free+0xe/0x10 mm/kasan/common.c:485 > __cache_free mm/slab.c:3426 [inline] > kfree+0x10a/0x2c0 mm/slab.c:3757 > l2cap_chan_destroy net/bluetooth/l2cap_core.c:484 [inline] > kref_put include/linux/kref.h:65 [inline] > l2cap_chan_put+0x1b7/0x240 net/bluetooth/l2cap_core.c:498 > do_enable_set+0x54b/0x960 net/bluetooth/6lowpan.c:1075 > process_one_work+0xa05/0x17a0 kernel/workqueue.c:2264 > worker_thread+0x98/0xe40 kernel/workqueue.c:2410 > kthread+0x361/0x430 kernel/kthread.c:255 > ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 The free and use-after-free are both via the same do_enable_set() path which implies there are racing writes to the debugfs write handler. It seems locking is missing for both listen_chan and enable_6lowpan. The latter seems misused in is_bt_6lowpan(), which should likely just be checking for chan->ops == &bt_6lowpan_chan_ops, I think? I have no way to actually test changes to this code... -- Kees Cook Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2JWsNUgPA19i4wAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 13:47:20 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CI8mM0gPA1+IVgAAgupzMw (envelope-from ); Mon, 06 Jul 2020 13:47:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=cerno.tech header.b=Zzs66ifj; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=SZ4cYbHK X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F0C60526CF; Mon, 6 Jul 2020 13:47:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728921AbgGFLrO (ORCPT + 1 other); Mon, 6 Jul 2020 07:47:14 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:50705 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728845AbgGFLrO (ORCPT ); Mon, 6 Jul 2020 07:47:14 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 846375803CA; Mon, 6 Jul 2020 07:47:12 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 06 Jul 2020 07:47:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:content-transfer-encoding:in-reply-to; s=fm3; bh=2 j5XHM8eiIAtdQDxQdQP6yCaAAsGGZ2pUNXQED85J7g=; b=Zzs66ifjtoAR5TI2a tCf7OIEx92ai/QD7cSp0uedZvsK8UTWbCHjYxNr/z36PyKgM1pctOeTGulfGFUsM 91YgsL7gY0B+On1Rgpc3N+37WpUA6Qb8BZUOCgde0ik0vXiD7kWot0VeEyQ0vknZ wQBIsBuOdBAif9XmzN+JNVaAqe00F+P7q4hBI5BUYwzUfKiKUmBSjKiOGxW3lUEz ArJVteF2X1ifaUbcLS198iDYVvlED8Oln13Ku5h4Qtn8XOJQk/C4LO/YgVIKvqcu bzaxpi7yaFW8NeekoC3vDhgfrd7MlHOuzVLNUE2RctGUgxNcSuDlXO8chLU3JQ0E vgW7A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=2j5XHM8eiIAtdQDxQdQP6yCaAAsGGZ2pUNXQED85J 7g=; b=SZ4cYbHKTKhaqeOfZUDYAWuZ6oY6YVQapo04+2pcJsRnP/k+si0WCkSSC HIj1iQeGPdwFH9+0YSSTJ866051WiSWrrCOYau/UQowMy9hk7Ivm+QrVOA59ewiS /xVZDtxhEX1ZwROmgJdrxcKOpT0KfHzwk9O3TTzKyHLDy/jUfgobWRXj6V6VFRc5 q1Gh3gUpyi5uj2fdNDrHX2Xp0Xn4Xz+QsPwZXn73Mb4i0NqOvrG0oWHGyMveFOse 8sozd7xbl1AZOF5IzHshSB64dyGcMSWO335MduOHKlkKtYk3KzC+PqlnzQTwO5om Mt1Qfwv5SA9rbrIceM76Zo+c7I1CQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudefgdeghecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggugfgjsehtqhertddttddvnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepgfejtedtjefggfffvdetuedthedtheegheeuteekfeeghfdtteejkeeludeg vddunecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 774E830653ED; Mon, 6 Jul 2020 07:47:10 -0400 (EDT) Date: Mon, 6 Jul 2020 13:47:09 +0200 From: Maxime Ripard To: Vasily Khoruzhick Cc: Rob Herring , Chen-Yu Tsai , Marcel Holtmann , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, Ondrej Jirman Subject: Re: [PATCH 3/3] arm64: allwinner: a64: enable Bluetooth On Pinebook Message-ID: <20200706114709.l6poszepqsmg5p5r@gilmour.lan> References: <20200705195110.405139-1-anarsoul@gmail.com> <20200705195110.405139-4-anarsoul@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20200705195110.405139-4-anarsoul@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: F0C60526CF X-Rspamd-UID: d30ed8 Hi, On Sun, Jul 05, 2020 at 12:51:10PM -0700, Vasily Khoruzhick wrote: > Pinebook has an RTL8723CS WiFi + BT chip, BT is connected to UART1 > and uses PL5 as device wake GPIO, PL6 as host wake GPIO the I2C > controlling signals are connected to R_I2C bus. >=20 > Enable it in the device tree. >=20 > Signed-off-by: Vasily Khoruzhick > --- > .../arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts | 12 ++++++++++++ > 1 file changed, 12 insertions(+) >=20 > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts b/arch= /arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts > index 64b1c54f87c0..e63ff271be4e 100644 > --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts > +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts > @@ -408,6 +408,18 @@ &uart0 { > status =3D "okay"; > }; > =20 > +&uart1 { > + pinctrl-names =3D "default"; > + pinctrl-0 =3D <&uart1_pins>, <&uart1_rts_cts_pins>; > + status =3D "okay"; You probably need uart-has-rtscts here > + > + bluetooth { > + compatible =3D "realtek,rtl8723cs-bt"; > + device-wake-gpios =3D <&r_pio 0 5 GPIO_ACTIVE_LOW>; /* PL5 */ > + host-wake-gpios =3D <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */ > + }; And max-speed I guess? Maxime > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MOG9HKUrA1+a0gEAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 15:48:21 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id AMciG6UrA1/HFAEAlScrYA (envelope-from ); Mon, 06 Jul 2020 15:48:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 128C0A1818; Mon, 6 Jul 2020 15:48:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729112AbgGFNsP (ORCPT + 1 other); Mon, 6 Jul 2020 09:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729109AbgGFNsO (ORCPT ); Mon, 6 Jul 2020 09:48:14 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1F0BC061755 for ; Mon, 6 Jul 2020 06:48:13 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id h17so1285997qvr.0 for ; Mon, 06 Jul 2020 06:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=SJj/JvBPbNhbHyJm/9hDgOHzKrUjF4dRqvNCzuVKegE=; b=PrO9XmItLYJZ+8Ggre51FsCbathoDhq2k08KS+edj6FjEicFyBNmy1iQ40Q9JqeEwt SqTYNEqXDYPlX48v5LCqbWvKQmGSBfACM0/B7PDRqQTvE1oI8NOusKTuycZBcGGX6lkG NoToffZhDljH5lq4Pg4xGeSgWOXvrRZztLYlkO8br+3V48v6L83z7KiB1ogA3APa5Jxi uw/dvaOQZhqonppcUOzELSqz+/fG/PFH8oQdOok10e2Oem2NhGIRlnyf98YGhxRYq4IB CemyPPWxHYZ440Geyimv5LHHJzFauete94ld+PGGNJ8eTGsCPeDbwFPHJ9RpH5Kt0BDb KA+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=SJj/JvBPbNhbHyJm/9hDgOHzKrUjF4dRqvNCzuVKegE=; b=V2+i3QxGeBqxUdwsNUuFEQUEmeRaysiG4pZ+JqYUdJCEsziZa6HpdGieIpgXFPDwFJ xe/FgzpwJZVGiJ+1eJKcUBl2YmYhVH/qn3xaK4Uc3BESEDfFCNT6guKqtIaJCzf+UaMh L+ZtpBktg5hZtIbMxU4FT7It+NcBGks1PmRsK21UXpuSYmPhphUL0fO090qlgD9fxDMe 7HJ52s1VL13o77PKhGxZAypCCdr+GiZ6DyXHr4PdiXFqaUep9cG7XI75uDzjGAH3A3p0 8lYompOXLHDXToZKV8sTjQ7Oz27yFw21FQqLeicfiqnbv8Hie+jX1x/DeNjz9/nv39oX WuJQ== X-Gm-Message-State: AOAM532v9S1xF63zwu3a8evW7yiyHInQrUtUIyPSoXt2k7oegAlMVPU/ 897U8nJh64C0lTWsPiu4sdeGWegpz/KYneW8QBerDoNI X-Google-Smtp-Source: ABdhPJxf2AEXYcdAWa8ewvVnaVllCMCg4t0saeQoUcFQoI0IWKW2s+bpGxj8igVn5hAzwM728rkrQYRQhI6HlV9eRWk= X-Received: by 2002:a0c:fd2a:: with SMTP id i10mr48305210qvs.23.1594043292811; Mon, 06 Jul 2020 06:48:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jean-Baptiste MARIE Date: Mon, 6 Jul 2020 15:48:01 +0200 Message-ID: Subject: L2CAP channels bit rate sharing policy To: linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 128C0A1818 X-Rspamd-UID: 6696fa Hello, I would like to know how is managed the sharing of available bandwidth between two L2CAP sockets over the same link. Here are my observations so far: - Connect one L2CAP socket from one device to another device. - Generate permanent traffic over the socket and measure the bitrate. - Open a second L2CAP socket over the same link - The throughput of the first socket is divided by 2. Is it possible through a patch or any configuration to set a maximum allowed bitrate for a L2CAP channel? How is managed the sharing of the link capability between the L2CAP channels? Thank you for your feedback, Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4Pb7HQFHA1/TygAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 17:45:05 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QLpNHAFHA191bQEAgupzMw (envelope-from ); Mon, 06 Jul 2020 17:45:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2822AA1883; Mon, 6 Jul 2020 17:44:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729495AbgGFPoz (ORCPT + 1 other); Mon, 6 Jul 2020 11:44:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729321AbgGFPoz (ORCPT ); Mon, 6 Jul 2020 11:44:55 -0400 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F6E9C061755 for ; Mon, 6 Jul 2020 08:44:55 -0700 (PDT) Received: by mail-vs1-xe42.google.com with SMTP id u133so7293936vsc.0 for ; Mon, 06 Jul 2020 08:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oTsBX04mEBGPv1WhXNBZwuT674fIoWLWZXtYZxokmDc=; b=LLs/igHinh+dfXo+MuLreYu8kx5tg3sVAiKujXkBRBuXFNG3bH41P14GE0iHOChPOI dTs1hJmnX4fWkikstAP+3+MlHBnQAnIV3gk+heS7UNJarE7CRJPHs9s76E4J77EgVkbr EVwGetEzTac3qG98ai9nCJluDiejllkXYs2zU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oTsBX04mEBGPv1WhXNBZwuT674fIoWLWZXtYZxokmDc=; b=lta63LFwA5MsCITeHHgpMz9qcVQaUbQzoajDTTcIjcgY358swGhQzOZgv8ihj1xmc9 inUi1GXiPLiSNkDSgOkGPKXcQWP85J0iHzqem3JyOV4bGfg3v38aA8Yxuh6cOl/cAET/ 4qiDd2DVSkksEVckx4C5eKEOC0H9uEPG5SzZ8vqlSvsFQy9Ey1BAYLmKjAmn2pgj3yht CimEOeWuBsNuhzezivUAwSNwjUexWf466Zdoqfb/yzufLiANXAWt1BD9jbub0xvhpcbi z157+Y0K9n/ebatbpkKgqQYoZlsR9X1JZMTE4zaT17dLl4NgRIHCDGKjyT5iW4iVaIku X6AQ== X-Gm-Message-State: AOAM533DibNDCX2gzfXlrckKNnUOszmpqaw0APiuNRKZ0eHGo+YeK88E H38rOSNcwRT23ctBjTIbWuyujgESkzE= X-Google-Smtp-Source: ABdhPJxvrSkD9HjYRPDV6v3iOXVyHkiBHpdgnbz4DquN3b+dwDJkiEXXT8m9wjaZ0ZoVvLOWtdbtFg== X-Received: by 2002:a05:6102:21b4:: with SMTP id i20mr37484539vsb.164.1594050294287; Mon, 06 Jul 2020 08:44:54 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id o15sm4437576vsa.20.2020.07.06.08.44.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 08:44:53 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud Subject: [PATCH v3] Bluetooth: le_simult_central_peripheral experimental feature Date: Mon, 6 Jul 2020 15:44:49 +0000 Message-Id: <20200706154449.3828193-1-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2822AA1883 X-Rspamd-UID: a15bb1 This patch adds an le_simult_central_peripheral features which allows a clients to determine if the controller is able to support peripheral and central connections separately and at the same time. Signed-off-by: Alain Michaud --- Changes in v3: - Back to the original design of V1 and integrated Marcel's feedback. Changes in v2: - Slight change of design based on offline feedback net/bluetooth/mgmt.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5e9b9728eeac..b34e6f3c07ec 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3753,12 +3753,19 @@ static const u8 debug_uuid[16] = { }; #endif +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ +static const u8 le_simult_central_peripheral[16] = { + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, +}; + static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { - char buf[42]; + char buf[44]; struct mgmt_rp_read_exp_features_info *rp = (void *)buf; u16 idx = 0; + u32 flags; bt_dev_dbg(hdev, "sock %p", sk); @@ -3766,7 +3773,7 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, #ifdef CONFIG_BT_FEATURE_DEBUG if (!hdev) { - u32 flags = bt_dbg_get() ? BIT(0) : 0; + flags = bt_dbg_get() ? BIT(0) : 0; memcpy(rp->features[idx].uuid, debug_uuid, 16); rp->features[idx].flags = cpu_to_le32(flags); @@ -3774,6 +3781,19 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, } #endif + flags = 0; + memcpy(rp->features[idx].uuid, le_simult_central_peripheral, + sizeof(le_simult_central_peripheral)); + + if (hdev && test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && + (hdev->le_states[4] & 0x08) && /* Central */ + (hdev->le_states[4] & 0x40) && /* Peripheral */ + (hdev->le_states[3] & 0x10) /* Simultaneous */) + flags |= BIT(0); + + rp->features[idx].flags = cpu_to_le32(flags); + idx++; + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OMLfFkiAA1+aawAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 21:49:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id gGlgFUiAA1+t7AAA0J78UA (envelope-from ); Mon, 06 Jul 2020 21:49:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9A1AEA24EF; Mon, 6 Jul 2020 21:49:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726810AbgGFTtV (ORCPT + 1 other); Mon, 6 Jul 2020 15:49:21 -0400 Received: from mga01.intel.com ([192.55.52.88]:57184 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgGFTtV (ORCPT ); Mon, 6 Jul 2020 15:49:21 -0400 IronPort-SDR: d2SYP8NrcID7gy0W2y22xT0JU80mWmdm8oLnJ+CPfQcA39EAmlDV4e+PTLX2UMlJNJzSF5BB9x a3KRA6Lk24PQ== X-IronPort-AV: E=McAfee;i="6000,8403,9674"; a="165565754" X-IronPort-AV: E=Sophos;i="5.75,320,1589266800"; d="scan'208";a="165565754" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 12:49:20 -0700 IronPort-SDR: 3cNi2f3rcLBqZvJMG3OO7luTvPyWosHjSg6C+2eGLTDZ38G0wIrV2qQ8xJRtXI2RMLbzwv+X+Q qsoZNb6p1K3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="388285975" Received: from bgi1-mobl2.amr.corp.intel.com ([10.255.228.100]) by fmsmga001.fm.intel.com with ESMTP; 06 Jul 2020 12:49:20 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ] mesh: Add Composition page storage to node.json Date: Mon, 6 Jul 2020 12:49:15 -0700 Message-Id: <20200706194915.189849-1-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9A1AEA24EF X-Rspamd-UID: ef1d50 --- mesh/cfgmod-server.c | 42 ++++++++++--- mesh/mesh-config-json.c | 131 +++++++++++++++++++++++++++++++++++++++ mesh/mesh-config.h | 12 ++++ mesh/node.c | 132 +++++++++++++++++++++++++++++++++------- mesh/node.h | 6 +- 5 files changed, 291 insertions(+), 32 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index c525d9d24..6194fc7d4 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -34,6 +34,12 @@ #define CFG_MAX_MSG_LEN 380 +/* Supported composition pages, sorted high to low */ +/* Only page 0 is currently supported */ +static const uint8_t supported_pages[] = { + 0 +}; + static void send_pub_status(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t status, uint16_t ele_addr, uint32_t mod_id, @@ -701,6 +707,33 @@ static void node_reset(void *user_data) node_remove(node); } +static uint16_t get_composition(struct mesh_node *node, uint8_t page, + uint8_t *buf) +{ + const uint8_t *comp; + uint16_t len = 0; + size_t i; + + for (i = 0; i < sizeof(supported_pages); i++) { + if (page < supported_pages[i]) + continue; + + page = supported_pages[i]; + comp = node_get_comp(node, page, &len); + + if (!page || len) + break; + } + + if (!len) + return 0; + + *buf++ = page; + memcpy(buf, comp, len); + + return len + 1; +} + static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, const uint8_t *data, uint16_t size, const void *user_data) @@ -746,16 +779,9 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 1) return false; - /* Only page 0 is currently supported */ - if (pkt[0] != 0) { - l_debug("Unsupported page number %d", pkt[0]); - l_debug("Returning page number 0"); - } long_msg = l_malloc(CFG_MAX_MSG_LEN); n = mesh_model_opcode_set(OP_DEV_COMP_STATUS, long_msg); - long_msg[n++] = 0; - n += node_generate_comp(node, long_msg + n, - CFG_MAX_MSG_LEN - n); + n += get_composition(node, pkt[0], long_msg + n); break; diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 661775f95..aef5540c0 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -430,6 +430,54 @@ static bool read_device_key(json_object *jobj, uint8_t key_buf[16]) return true; } +static bool read_comp_pages(json_object *jobj, struct mesh_config_node *node) +{ + json_object *jarray, *jentry; + struct mesh_config_comp_page *page; + int len; + int i; + + if (!json_object_object_get_ex(jobj, "pages", &jarray)) + return true; + + if (json_object_get_type(jarray) != json_type_array) + return false; + + len = json_object_array_length(jarray); + + for (i = 0; i < len; i++) { + size_t clen; + char *str; + + jentry = json_object_array_get_idx(jarray, i); + str = (char *)json_object_get_string(jentry); + clen = strlen(str); + + if (clen < ((MIN_COMP_SIZE * 2) + 1)) + continue; + + clen = (clen / 2) - 1; + + page = l_malloc(sizeof(struct mesh_config_comp_page) + clen); + + if (!str2hex(str + 2, clen * 2, page->data, clen)) + goto parse_fail; + + if (sscanf(str, "%02hhx", &page->page_num) != 1) + goto parse_fail; + + page->len = clen; + + l_queue_push_tail(node->pages, page); + } + + return true; + +parse_fail: + l_free(page); + return false; +} + static bool read_app_keys(json_object *jobj, struct mesh_config_node *node) { json_object *jarray; @@ -1384,6 +1432,11 @@ static bool read_node(json_object *jnode, struct mesh_config_node *node) return false; } + if (!read_comp_pages(jnode, node)) { + l_info("Failed to read Composition Pages"); + return false; + } + if (!parse_elements(jvalue, node)) { l_info("Failed to parse elements"); return false; @@ -1889,6 +1942,82 @@ bool mesh_config_model_pub_del(struct mesh_config *cfg, uint16_t addr, return save_config(cfg->jnode, cfg->node_dir_path); } +static void del_page(json_object *jarray, uint8_t page) +{ + char buf[3]; + int i, len; + + if (!jarray) + return; + + snprintf(buf, 3, "%2.2x", page); + + len = json_object_array_length(jarray); + + for (i = 0; i < len; i++) { + json_object *jentry; + char *str; + + jentry = json_object_array_get_idx(jarray, i); + str = (char *)json_object_get_string(jentry); + + /* Delete matching page(s) */ + if (!memcmp(str, buf, 2)) + json_object_array_del_idx(jarray, i, 1); + } +} + +bool mesh_config_comp_page_add(struct mesh_config *cfg, uint8_t page, + uint8_t *data, uint16_t size) +{ + json_object *jnode, *jstring, *jarray = NULL; + char *buf; + int len; + + if (!cfg) + return false; + + jnode = cfg->jnode; + + json_object_object_get_ex(jnode, "pages", &jarray); + + len = (size * 2) + 3; + buf = l_malloc(len); + snprintf(buf, len, "%2.2x", page); + hex2str(data, size, buf + 2, len - 2); + + if (jarray && jarray_has_string(jarray, buf, len)) { + l_free(buf); + return true; + } else if (!jarray) { + jarray = json_object_new_array(); + json_object_object_add(jnode, "pages", jarray); + } else + del_page(jarray, page); + + jstring = json_object_new_string(buf); + json_object_array_add(jarray, jstring); + l_free(buf); + + return save_config(jnode, cfg->node_dir_path); +} + +bool mesh_config_comp_page_del(struct mesh_config *cfg, uint8_t page) +{ + json_object *jnode, *jarray = NULL; + + if (!cfg) + return false; + + jnode = cfg->jnode; + + json_object_object_get_ex(jnode, "pages", &jarray); + + del_page(jarray, page); + + return true; +} + bool mesh_config_model_sub_add(struct mesh_config *cfg, uint16_t ele_addr, uint32_t mod_id, bool vendor, struct mesh_config_sub *sub) @@ -2212,6 +2341,7 @@ static bool load_node(const char *fname, const uint8_t uuid[16], node.elements = l_queue_new(); node.netkeys = l_queue_new(); node.appkeys = l_queue_new(); + node.pages = l_queue_new(); result = read_node(jnode, &node); @@ -2238,6 +2368,7 @@ static bool load_node(const char *fname, const uint8_t uuid[16], l_free(node.net_transmit); l_queue_destroy(node.netkeys, l_free); l_queue_destroy(node.appkeys, l_free); + l_queue_destroy(node.pages, l_free); l_queue_destroy(node.elements, free_element); if (!result) diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 9f30e693b..e1107bbe5 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -17,6 +17,8 @@ * */ +#define MIN_COMP_SIZE 14 + struct mesh_config; struct mesh_config_sub { @@ -88,10 +90,17 @@ struct mesh_config_transmit { uint8_t count; }; +struct mesh_config_comp_page { + uint16_t len; + uint8_t page_num; + uint8_t data[]; +}; + struct mesh_config_node { struct l_queue *elements; struct l_queue *netkeys; struct l_queue *appkeys; + struct l_queue *pages; uint32_t seq_number; uint32_t iv_index; bool iv_update; @@ -139,6 +148,9 @@ bool mesh_config_write_relay_mode(struct mesh_config *cfg, uint8_t mode, bool mesh_config_write_ttl(struct mesh_config *cfg, uint8_t ttl); bool mesh_config_write_mode(struct mesh_config *cfg, const char *keyword, int value); +bool mesh_config_comp_page_add(struct mesh_config *cfg, uint8_t page, + uint8_t *data, uint16_t size); +bool mesh_config_comp_page_del(struct mesh_config *cfg, uint8_t page); bool mesh_config_model_binding_add(struct mesh_config *cfg, uint16_t ele_addr, bool vendor, uint32_t mod_id, uint16_t app_idx); diff --git a/mesh/node.c b/mesh/node.c index 3e888ce61..a01842c95 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -46,8 +46,6 @@ #include "mesh/manager.h" #include "mesh/node.h" -#define MIN_COMP_SIZE 14 - #define MESH_NODE_PATH_PREFIX "/node" /* Default values for a new locally created node */ @@ -81,6 +79,7 @@ struct node_composition { struct mesh_node { struct mesh_net *net; struct l_queue *elements; + struct l_queue *pages; char *app_path; char *owner; char *obj_path; @@ -266,6 +265,7 @@ static struct mesh_node *node_new(const uint8_t uuid[16]) node = l_new(struct mesh_node, 1); node->net = mesh_net_new(node); node->elements = l_queue_new(); + node->pages = l_queue_new(); memcpy(node->uuid, uuid, sizeof(node->uuid)); set_defaults(node); @@ -335,6 +335,7 @@ static void free_node_resources(void *data) /* Free dynamic resources */ free_node_dbus_resources(node); l_queue_destroy(node->elements, element_free); + l_queue_destroy(node->pages, l_free); mesh_agent_remove(node->agent); mesh_config_release(node->cfg); mesh_net_free(node->net); @@ -557,8 +558,15 @@ static bool init_from_storage(struct mesh_config_node *db_node, l_queue_foreach(db_node->netkeys, set_net_key, node); - if (db_node->appkeys) - l_queue_foreach(db_node->appkeys, set_appkey, node); + l_queue_foreach(db_node->appkeys, set_appkey, node); + + while (l_queue_length(db_node->pages)) { + struct mesh_config_comp_page *page; + + /* Move the composition pages to the node struct */ + page = l_queue_pop_head(db_node->pages); + l_queue_push_tail(node->pages, page); + } mesh_net_set_seq_num(node->net, node->seq_number); mesh_net_set_default_ttl(node->net, node->ttl); @@ -877,7 +885,8 @@ uint8_t node_friend_mode_get(struct mesh_node *node) return node->friend; } -uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz) +static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, + uint16_t sz) { uint16_t n, features; uint16_t num_ele = 0; @@ -991,6 +1000,80 @@ element_done: return n; } +static bool match_page(const void *a, const void *b) +{ + const struct mesh_config_comp_page *page = a; + uint8_t page_num = L_PTR_TO_UINT(b); + + return page->page_num == page_num; +} + +bool node_set_comp(struct mesh_node *node, uint8_t page_num, + const uint8_t *data, uint16_t len) +{ + struct mesh_config_comp_page *page; + + if (!node || len < MIN_COMP_SIZE) + return false; + + page = l_queue_remove_if(node->pages, match_page, + L_UINT_TO_PTR(page_num)); + + l_free(page); + + page = l_malloc(sizeof(struct mesh_config_comp_page) + len); + page->len = len; + page->page_num = page_num; + memcpy(page->data, data, len); + l_queue_push_tail(node->pages, page); + + mesh_config_comp_page_add(node->cfg, page_num, page->data, len); + + return true; +} + +const uint8_t *node_get_comp(struct mesh_node *node, uint8_t page_num, + uint16_t *len) +{ + struct mesh_config_comp_page *page = NULL; + + if (node) + page = l_queue_find(node->pages, match_page, + L_UINT_TO_PTR(page_num)); + + if (!page) { + *len = 0; + return NULL; + } + + *len = page->len; + return page->data; +} + +bool node_replace_comp(struct mesh_node *node, uint8_t retire, uint8_t with) +{ + struct mesh_config_comp_page *old_page, *keep; + + if (!node) + return false; + + keep = l_queue_find(node->pages, match_page, L_UINT_TO_PTR(with)); + + if (!keep) + return false; + + old_page = l_queue_remove_if(node->pages, match_page, + L_UINT_TO_PTR(retire)); + + mesh_config_comp_page_del(node->cfg, with); + mesh_config_comp_page_add(node->cfg, retire, keep->data, keep->len); + + l_free(old_page); + keep->page_num = retire; + + return true; +} + static void attach_io(void *a, void *b) { struct mesh_node *node = a; @@ -1486,27 +1569,30 @@ static void update_model_options(struct mesh_node *node, static bool check_req_node(struct managed_obj_request *req) { - uint8_t node_comp[MAX_MSG_LEN - 2]; - uint8_t attach_comp[MAX_MSG_LEN - 2]; - uint16_t offset = 10; - uint16_t node_len = node_generate_comp(req->node, node_comp, - sizeof(node_comp)); + struct mesh_node *node; + const int offset = 8; + uint16_t node_len, len; + uint8_t comp[MAX_MSG_LEN - 2]; + const uint8_t *node_comp; - if (!node_len) - return false; + if (req->type == REQUEST_TYPE_ATTACH) + node = req->attach; + else + node = req->node; - if (req->type == REQUEST_TYPE_ATTACH) { - uint16_t attach_len = node_generate_comp(req->attach, - attach_comp, sizeof(attach_comp)); + node_comp = node_get_comp(node, 0, &node_len); + len = node_generate_comp(node, comp, sizeof(comp)); - /* Verify only element/models composition */ - if (node_len != attach_len || - memcmp(&node_comp[offset], &attach_comp[offset], - node_len - offset)) { - l_debug("Failed to verify app's composition data"); - return false; - } - } + /* If no page 0 exists, save it and return */ + if (req->type != REQUEST_TYPE_ATTACH || !node_len || !node_comp) + return node_set_comp(node, 0, comp, len); + + if (node_len != len || memcmp(&node_comp[offset], &comp[offset], + node_len - offset)) + return false; + + else if (memcmp(node_comp, comp, node_len)) + return node_set_comp(node, 0, comp, len); return true; } diff --git a/mesh/node.h b/mesh/node.h index 6c4542a78..df058458a 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -63,7 +63,11 @@ struct l_queue *node_get_element_models(struct mesh_node *node, uint8_t ele_idx, uint16_t node_get_crpl(struct mesh_node *node); bool node_init_from_storage(struct mesh_node *node, const uint8_t uuid[16], struct mesh_config_node *db_node); -uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz); +const uint8_t *node_get_comp(struct mesh_node *node, uint8_t page_num, + uint16_t *len); +bool node_set_comp(struct mesh_node *node, uint8_t page_num, + const uint8_t *data, uint16_t len); +bool node_replace_comp(struct mesh_node *node, uint8_t retire, uint8_t with); uint8_t node_lpn_mode_get(struct mesh_node *node); bool node_relay_mode_set(struct mesh_node *node, bool enable, uint8_t cnt, uint16_t interval); -- 2.25.4 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IFM9DuiHA1+ElgAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 22:22:00 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wE52DOiHA1/NgwAAlScrYA (envelope-from ); Mon, 06 Jul 2020 22:22:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0C07641952; Mon, 6 Jul 2020 22:21:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725941AbgGFUVy (ORCPT + 1 other); Mon, 6 Jul 2020 16:21:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgGFUVy (ORCPT ); Mon, 6 Jul 2020 16:21:54 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D80B7C061755 for ; Mon, 6 Jul 2020 13:21:53 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id g13so30035895qtv.8 for ; Mon, 06 Jul 2020 13:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=u9ytgxLq6uH2Yn515WsUdQOmhh5WiqorZ9YxqrEuwYg=; b=ebETRFGOXZe09mm0LHh09/laYZYmDLu8u5oSh/tS1xRJuR1jAgvXVdyTuUbd1Cj4fW /iZmmNrIHS1wVhnyZREfaQGkRAolKQI0JLpQT5SqZX2s2X8XTABVxyQ7hj2H3aVd7hRO 7ooFk+BJQDTJn7LaHIHUNPU+Hx9TiVS2mLvZrXHCEJOW/BjyzMf1ht/pwdpSAElyFXO1 chn6BbIeWN1EoGOFXsGOjE7IH/4dgGki4rFPyMleL10bwj/zUjzWzhk2oOwbWNc5AR46 LRGM/yhvaXZs30i/UV5okAdP1vkm9QhS/dAkfbj/C/Hl9d2MrhG7DaZv9ihXErswbtrv fUOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=u9ytgxLq6uH2Yn515WsUdQOmhh5WiqorZ9YxqrEuwYg=; b=TRE31YUAyZUZlJqkAeHFRESd6EiPTlc3C3FauzES2Ppy/+jLiInLp2IS+X1bVsbpq8 k9sOnVuPPhUXzFc9XJZQRRh8gABkhJfXS0kc2EkoZsuydnKtamrEHiVj+obm7fHYuEiH 6N4OTlAa/Vf1/hD03PkXq6mexsFscK2DuI/0YY0mowCFKDISyKIEakGpvL9tF9iFpCNB scT4+oB8lxoPReGllOf03zNeo1ROZTGlAPRVhnVENy6MLG7G9z8PnMWDbAesX/pg7ClZ CvMiv/YWO0Yr+ydLFia3Q0oVyNZcxNTVQ9ORZHvA9wNzDwb83B5IXkD8R0nmFqzZhEg8 21Bg== X-Gm-Message-State: AOAM533vbhpFjwhAK8sEulAHZXGbbOQ4Ght8Nl+NtAdnpMUsAaDwONjr xZpsWuZidEs2JOoNtLZq9L6RqYbl/qw= X-Google-Smtp-Source: ABdhPJz8jv/kSeevLB9WYam0U+Y3A6OMEESit5hq49it7qU1xjxbIIkfe1rXO95bf4ohWz/pPK5tUA== X-Received: by 2002:ac8:4649:: with SMTP id f9mr3086484qto.313.1594066912337; Mon, 06 Jul 2020 13:21:52 -0700 (PDT) Received: from [172.17.0.2] ([40.84.37.163]) by smtp.gmail.com with ESMTPSA id q29sm20446067qtc.10.2020.07.06.13.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 13:21:51 -0700 (PDT) Message-ID: <5f0387df.1c69fb81.521c.e331@mx.google.com> Date: Mon, 06 Jul 2020 13:21:51 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============6048096995076221070==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, brian.gix@intel.com Subject: RE: [BlueZ] mesh: Add Composition page storage to node.json Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200706194915.189849-1-brian.gix@intel.com> References: <20200706194915.189849-1-brian.gix@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 27 X-Rspamd-Score: 4.13 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0C07641952 X-Rspamd-UID: ff8063 --===============6048096995076221070== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 3: B6 Body message is missing --- Regards, Linux Bluetooth --===============6048096995076221070==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0BeEL8GIA1+ElgAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 22:25:37 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id AHM7LsGIA1/2/AAA0J78UA (envelope-from ); Mon, 06 Jul 2020 22:25:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C3A4AA2765; Mon, 6 Jul 2020 22:25:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726591AbgGFUZb (ORCPT + 1 other); Mon, 6 Jul 2020 16:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgGFUZb (ORCPT ); Mon, 6 Jul 2020 16:25:31 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FC51C061755 for ; Mon, 6 Jul 2020 13:25:31 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id x8so14883335plm.10 for ; Mon, 06 Jul 2020 13:25:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AFa8f5h40SxZunFFosO+SN5tP3OS76FTxNl6Rbhd3ek=; b=LNvimZU7D4zgBbzEbUKtnYiDajuoKUt/lfFSoqKHR2xvldFeIewtwiBKEFCKywAXAO F5CSmIoP5akHs0Bu4HSaTYjaI5IqeXBhfkFqE/m4DRZf5Tu9JGjdcIrajdx8N5yKc+C9 KsAFO/WBrI4w4CioVlfkCigVK1EQNZVw7D8So= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AFa8f5h40SxZunFFosO+SN5tP3OS76FTxNl6Rbhd3ek=; b=EOHcB1IFRyMcnmBztrPtxHQbkzU4EtErWhXMakdq9NTjlrxHbm+SE4rIJfFfTKMSTH tgl1TVL/Q5Vsi5ILWxBASpEYyCD8fvZSHKr9va6BJHCNDo88l0bmUws2zC+f3laHn/mC kl35sw414GLdKQJE78Tw+SziyLwmRoKAruuHocNZqJ4oUq2Hp+EJd2fA+zUeYIA47fec n0C8g8ix78XwZquZ45nPIAi1Yv3XqHg90HWudqqsvPFDhEbXm/0iLqv2oFUbT5mosqRU 1qmVrVZMMRUJSwRCzqhJ+epXnx9fuFJMqKO3dLbxhxTNMVE09JX6Nw9C4UySPteNaTcq vCGA== X-Gm-Message-State: AOAM531wfTluu3lM1I8NYZAMiRyWzFzaKqC/6SWUE9QeKK/7vzWygjEo 7YcBchPCHjMbehJkPWfUH5K3wA== X-Google-Smtp-Source: ABdhPJxhddIkmc8QQu5TMHvbwi3u8RjaSIwGjjGXGzgBNbFfZGvISjRZRtyhM/k6a6lnG5BUdh5fCQ== X-Received: by 2002:a17:90b:188b:: with SMTP id mn11mr835984pjb.179.1594067130894; Mon, 06 Jul 2020 13:25:30 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id n25sm3320226pff.51.2020.07.06.13.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 13:25:30 -0700 (PDT) From: Abhishek Pandit-Subedi To: luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, marcel@holtmann.org, chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi Subject: [BlueZ PATCH v7 0/6] device: Allow devices to be marked as wake capable Date: Mon, 6 Jul 2020 13:25:12 -0700 Message-Id: <20200706202518.1153647-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 18 X-Rspamd-Score: 2.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: C3A4AA2765 X-Rspamd-UID: 7d747b Hi Luiz, This change accompanies a change in the kernel to allow marking devices as wakeable so they can wake the system from suspend. Currently, only HID devices support this and will be configured to allow this setting to be changed via the WakeAllowed property. Accompanying kernel change: https://patchwork.kernel.org/patch/11609999/ In order to set this flag, Bluez must call Set Device Flags with the Remote Wakeup bit set. This change was tested with the accompanying kernel changes on v5.4 with both manual tests and automated tests. Here's the tests that I ran manually: - Pair new HID device and confirm it has Wake Allowed to True (default). Verify device can be woken from suspend with device. - Restart bluetoothd, confirm Device Flags Changed event after Add Device has no Remote Wakeup flag and Set Device Flags is called afterwards to restore it. Verify wake from suspend still works. - Disable Wake allowed via dbus and confirm wake from suspend no longer works. - Restart bluetoothd and confirm Wake Allowed is still false. Verify wake from suspend does not work. Thanks Abhishek Changes in v7: * Fix more build issues reported by bluez.test.bot Changes in v6: * Fix up some build issues reported by bluez.test.bot * Save pending property id and emit success only after set flags returns * Ignore multiple calls to set_wake_allowed to the same value * Emit property error busy if same value is already sent to mgmt * Fix up build issues reported by bluez.test.bot Changes in v5: - Use device_flags mgmt op * Decode device flags * Refactor to use set_wake_flags and respond to device flags changed * Add wake_override so we can keep track of user/profile configuration vs what is currently active * Only call device_set_wake_support Changes in v4: * Renamed wake_capable to wake_allowed * Removed set_wake_capable mgmt op and updated add_device to accept flags to set whether a device is wakeable * Refactored adapter_whitelist_add and adapter_auto_connect_add to call adapter_add_device * Renamed WakeCapable to WakeAllowed * Renamed WakeCapable to WakeAllowed * Renamed device_set_profile_wake_support to just device_set_wake_support Changes in v3: * Added profile_wake_support and made wake_capable dependent on it * Added documentation for WakeCapable * Mark HID device to support wake from suspend Changes in v2: * Added dbus api "WakeCapable" to set value * Update device_set_wake_capable to be called by adapter_set_wake_capable_complete so we can emit property changed * Newly added to show whether device is wake capable * Removed automatically setting wake capable for HID devices Abhishek Pandit-Subedi (6): mgmt: Add mgmt op and events for device flags monitor: Decode device flags mgmt ops and event device: Support marking a device with wake allowed client: Display wake allowed property with info doc/device-api: Add WakeAllowed input: Make HID devices support wake client/main.c | 1 + doc/device-api.txt | 5 + lib/mgmt.h | 33 +++++++ monitor/packet.c | 70 ++++++++++++++ profiles/input/device.c | 1 + profiles/input/hog.c | 1 + src/adapter.c | 93 ++++++++++++++++++ src/adapter.h | 3 +- src/device.c | 210 ++++++++++++++++++++++++++++++++++++++++ src/device.h | 10 ++ 10 files changed, 426 insertions(+), 1 deletion(-) -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mL4BEceIA1+aawAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 22:25:43 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gAOhDceIA19vYAAAlp8NpQ (envelope-from ); Mon, 06 Jul 2020 22:25:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E2C00A242B; Mon, 6 Jul 2020 22:25:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727031AbgGFUZe (ORCPT + 1 other); Mon, 6 Jul 2020 16:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgGFUZc (ORCPT ); Mon, 6 Jul 2020 16:25:32 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 678BCC061755 for ; Mon, 6 Jul 2020 13:25:32 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id j7so2425530plk.13 for ; Mon, 06 Jul 2020 13:25:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PYYU0UwoMy/TrOAen5MS1rO2nahTd7K1yKosFEDdKU4=; b=jl6M085MpXP1jNgwTQeo0D4rx7tqf7+So3lf9DO2o6/fQBK65YQRh/3hRUJPDCo2O7 W1Z8eEJ7wvst4shvHxUXR5VJTON3x3k0cF9NZuXX4K8BxmQhSwyH7zBGmv7HnvQDH/ro HJZR32kRCu3TZkkt8/tvp7o3f0tBKZpvgWp4U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PYYU0UwoMy/TrOAen5MS1rO2nahTd7K1yKosFEDdKU4=; b=CfPwOGxSZCZHsNhJBP/GyHLZWfidZRmXIUyh/pWpCiTUcuyin5YXOq3NDMqsgjp7y2 w6ORPyD8+HIehpQSAEse+heIMlrMuQyHb+jIzgdOdrce5tAuCO/gYxDsXbc+NY2QDd0/ BbLXQwZFWfiOiiNuGMwtEgWWb7db1HM14CWh6WJzVevbHW1Zj9p6ln4vAfKBofilcZUd cY4e6JAW9zpzuWKRooPycawuQC1DOOxi7rQkT4tCV2jE3edTcnwONXSsybgGzc4UF1x2 3P66UonE0pYjQFBkWXShujp9FXC9ppkLgwWunOcafXQ3w/SctQfBPpQxazI27p0jXrj5 V4aw== X-Gm-Message-State: AOAM531Mp1o/Pu08egPQV+A0IKL/AFDNQzEKt6AVzP5wAEohgaClGKeA Gn+xYqNPml67gjlZDMICkWuJSJBEjM0= X-Google-Smtp-Source: ABdhPJyuoptO/FAMSNzibYd5ThR3oaPC+Yge5n1u9otcN+O2F+n8WgqyWAAzG+Fz7f2ExGO65NSicA== X-Received: by 2002:a17:902:9a47:: with SMTP id x7mr25498158plv.90.1594067131894; Mon, 06 Jul 2020 13:25:31 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id n25sm3320226pff.51.2020.07.06.13.25.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 13:25:31 -0700 (PDT) From: Abhishek Pandit-Subedi To: luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, marcel@holtmann.org, chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi Subject: [BlueZ PATCH v7 1/6] mgmt: Add mgmt op and events for device flags Date: Mon, 6 Jul 2020 13:25:13 -0700 Message-Id: <20200706132503.BlueZ.v7.1.I3a6c238b09e1a0fad69e69cc2e6f4063af989b37@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200706202518.1153647-1-abhishekpandit@chromium.org> References: <20200706202518.1153647-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: E2C00A242B X-Rspamd-UID: 356365 Add Get Device Flags, Set Device Flags and Device Flags Changed. --- Changes in v7: None Changes in v6: None Changes in v5: - Use device_flags mgmt op Changes in v4: None Changes in v3: None Changes in v2: None lib/mgmt.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index fad1f3dfe..525c4dd62 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -654,6 +654,27 @@ struct mgmt_cp_set_default_runtime_config { uint8_t parameters[0]; /* mgmt_tlv */ } __packed; +#define MGMT_OP_GET_DEVICE_FLAGS 0x004F +#define MGMT_GET_DEVICE_FLAGS_SIZE 7 +struct mgmt_cp_get_device_flags { + struct mgmt_addr_info addr; +} __packed; +struct mgmt_rp_get_device_flags { + struct mgmt_addr_info addr; + uint32_t supported_flags; + uint32_t current_flags; +} __packed; + +#define MGMT_OP_SET_DEVICE_FLAGS 0x0050 +#define MGMT_SET_DEVICE_FLAGS_SIZE 11 +struct mgmt_cp_set_device_flags { + struct mgmt_addr_info addr; + uint32_t current_flags; +} __packed; +struct mgmt_rp_set_device_flags { + struct mgmt_addr_info addr; +} __packed; + #define MGMT_ADV_MONITOR_FEATURE_MASK_OR_PATTERNS (1 << 0) #define MGMT_OP_READ_ADV_MONITOR_FEATURES 0x0051 @@ -919,6 +940,13 @@ struct mgmt_ev_exp_feature_changed { uint32_t flags; } __packed; +#define MGMT_EV_DEVICE_FLAGS_CHANGED 0x002a +struct mgmt_ev_device_flags_changed { + struct mgmt_addr_info addr; + uint32_t supported_flags; + uint32_t current_flags; +} __packed; + #define MGMT_EV_ADV_MONITOR_ADDED 0x002b struct mgmt_ev_adv_monitor_added { uint16_t monitor_handle; @@ -1007,6 +1035,8 @@ static const char *mgmt_op[] = { "Set Experimental Feature", "Read Default System Configuration", "Set Default System Configuration", + "Get Device Flags", + "Set Device Flags", /* 0x0050 */ "Read Advertisement Monitor Features", "Add Advertisement Patterns Monitor", "Remove Advertisement Monitor", @@ -1053,6 +1083,7 @@ static const char *mgmt_ev[] = { "Extended Controller Information Changed", "PHY Configuration Changed", "Experimental Feature Changed", + "Device Flags Changed", "Advertisement Monitor Added", /* 0x002b */ "Advertisement Monitor Removed", }; -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2Oc/N8yIA1+aawAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 22:25:48 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OGSINcyIA1+hXgAAgupzMw (envelope-from ); Mon, 06 Jul 2020 22:25:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5D4ECA3076; Mon, 6 Jul 2020 22:25:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727053AbgGFUZg (ORCPT + 1 other); Mon, 6 Jul 2020 16:25:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726869AbgGFUZd (ORCPT ); Mon, 6 Jul 2020 16:25:33 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5842BC061755 for ; Mon, 6 Jul 2020 13:25:33 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id k5so7928572pjg.3 for ; Mon, 06 Jul 2020 13:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sp2PpsNYtdlkB2zGQ5iXNthHuroaVA/dnOY7kVTTSGk=; b=k/lQQyPrWkjj2dmUt1M+PIwzylCjgPoQRd4G/xVLpSE6xboGetNnjQvQ9BMeWqvBnl 3PVlVH4F2CwFWXrWJbZsIhtIqRX4p+AtecLkVG4U69bE01FgNInPaEQb6H2cgmWlAKIC z4zQaF7LslGiUjzrwR9yJxJGIYe7/dl8z5paE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sp2PpsNYtdlkB2zGQ5iXNthHuroaVA/dnOY7kVTTSGk=; b=gRA51lLR5zkSuuFhd8pmzLzdjueEvvRux0Yq9zHhM/HLYjtDueRhyfPXi6ILz765hq DhafR84QNL1/gl4gadCloBC/bsC5eH6yMOAiRFgCW0SHcnuhwPS5dsjhEiWd4dLK+Hxd 1boZOOjAcPAL2Ua7bn6nVrzha017h+iQBQEDmg6ZAYiiwSR0Vw6tUGEYz9g7Wc+AiRw+ qthWlyfCouthuI9vM/kEPOZp5CuenAMJvGsb6f1fJhxhyQQ26fgnXLm823YrtVJQlT/j yNvkQ4CJHKaaKBo+jScH+DN+1h0BQGCbfj2LBPTVdwgUQ/iOuc2SyiwFtDTxLt5bvod5 DRGg== X-Gm-Message-State: AOAM530ohh5uvu78Gdi9qL4OMKyCmOxAsw3/aUul77rru8Aa6JczjaX4 hV+NA2EHfTweiWDadUtPy23P+w== X-Google-Smtp-Source: ABdhPJzF5hes9AigF0tS3z3rNIxt9q118eFHumvlFRr6BUw/qnEd/wtHVzeuGJKdvvaAwHtt1MXWUQ== X-Received: by 2002:a17:902:8bc7:: with SMTP id r7mr42583233plo.174.1594067132876; Mon, 06 Jul 2020 13:25:32 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id n25sm3320226pff.51.2020.07.06.13.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 13:25:32 -0700 (PDT) From: Abhishek Pandit-Subedi To: luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, marcel@holtmann.org, chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi Subject: [BlueZ PATCH v7 2/6] monitor: Decode device flags mgmt ops and event Date: Mon, 6 Jul 2020 13:25:14 -0700 Message-Id: <20200706132503.BlueZ.v7.2.Ieac700ddea68a19e8c3dc53528f686482076a77a@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200706202518.1153647-1-abhishekpandit@chromium.org> References: <20200706202518.1153647-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 18 X-Rspamd-Score: 2.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5D4ECA3076 X-Rspamd-UID: b6d33a Add support for Get Device Flags and Set Device Flags mgmt operations and Device Flags Changed mgmt event. Sample trace: @ MGMT Command: Set Device Flags (0x0050) plen 11 {0x0002} [hci0] LE Address: CD:F3:CD:13:C5:91 (Static) Current Flags: 0x00000000 @ MGMT Event: Device Flags Changed (0x002a) plen 15 {0x0001} [hci0] LE Address: CD:F3:CD:13:C5:91 (Static) Supported Flags: 0x00000001 Remote Wakeup Current Flags: 0x00000000 @ MGMT Event: Device Flags Changed (0x002a) plen 15 {0x0004} [hci0] LE Address: CD:F3:CD:13:C5:91 (Static) Supported Flags: 0x00000001 Remote Wakeup Current Flags: 0x00000000 @ MGMT Event: Device Flags Changed (0x002a) plen 15 {0x0003} [hci0] LE Address: CD:F3:CD:13:C5:91 (Static) Supported Flags: 0x00000001 Remote Wakeup Current Flags: 0x00000000 @ MGMT Event: Command Complete (0x0001) plen 10 {0x0002} [hci0] Set Device Flags (0x0050) plen 7 Status: Success (0x00) LE Address: CD:F3:CD:13:C5:91 (Static) --- Changes in v7: None Changes in v6: * Fix up some build issues reported by bluez.test.bot Changes in v5: * Decode device flags Changes in v4: None Changes in v3: None Changes in v2: None monitor/packet.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 3b9c06512..431a39b66 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -100,6 +100,7 @@ #define COLOR_UNKNOWN_EXP_FEATURE_FLAG COLOR_WHITE_BG #define COLOR_UNKNOWN_ADV_FLAG COLOR_WHITE_BG #define COLOR_UNKNOWN_PHY COLOR_WHITE_BG +#define COLOR_UNKNOWN_ADDED_DEVICE_FLAG COLOR_WHITE_BG #define COLOR_PHY_PACKET COLOR_BLUE @@ -13099,6 +13100,56 @@ static void mgmt_set_exp_feature_rsp(const void *data, uint16_t size) mgmt_print_exp_feature(data); } +static const struct bitfield_data mgmt_added_device_flags_table[] = { + { 0, "Remote Wakeup" }, + { } +}; + +static void mgmt_print_added_device_flags(char *label, uint32_t flags) +{ + uint32_t mask; + + print_field("%s: 0x%8.8x", label, flags); + mask = print_bitfield(2, flags, mgmt_added_device_flags_table); + if (mask) + print_text(COLOR_UNKNOWN_ADDED_DEVICE_FLAG, + " Unknown Flags (0x%8.8x)", mask); +} + +static void mgmt_get_device_flags_cmd(const void *data, uint16_t size) +{ + uint8_t type = get_u8(data + 6); + + mgmt_print_address(data, type); +} + +static void mgmt_get_device_flags_rsp(const void *data, uint16_t size) +{ + uint8_t type = get_u8(data + 6); + uint32_t supported_flags = get_le32(data + 7); + uint32_t current_flags = get_le32(data + 11); + + mgmt_print_address(data, type); + mgmt_print_added_device_flags("Supported Flags", supported_flags); + mgmt_print_added_device_flags("Current Flags", current_flags); +} + +static void mgmt_set_device_flags_cmd(const void *data, uint16_t size) +{ + uint8_t type = get_u8(data + 6); + uint32_t current_flags = get_le32(data + 7); + + mgmt_print_address(data, type); + mgmt_print_added_device_flags("Current Flags", current_flags); +} + +static void mgmt_set_device_flags_rsp(const void *data, uint16_t size) +{ + uint8_t type = get_u8(data + 6); + + mgmt_print_address(data, type); +} + struct mgmt_data { uint16_t opcode; const char *str; @@ -13324,6 +13375,12 @@ static const struct mgmt_data mgmt_command_table[] = { { 0x004a, "Set Experimental Feature", mgmt_set_exp_feature_cmd, 17, true, mgmt_set_exp_feature_rsp, 20, true }, + { 0x004f, "Get Device Flags", + mgmt_get_device_flags_cmd, 7, true, + mgmt_get_device_flags_rsp, 15, true}, + { 0x0050, "Set Device Flags", + mgmt_set_device_flags_cmd, 11, true, + mgmt_set_device_flags_rsp, 7, true}, { } }; @@ -13714,6 +13771,17 @@ static void mgmt_exp_feature_changed_evt(const void *data, uint16_t size) mgmt_print_exp_feature(data); } +static void mgmt_device_flags_changed_evt(const void *data, uint16_t size) +{ + uint8_t type = get_u8(data + 6); + uint32_t supported_flags = get_le32(data + 7); + uint32_t current_flags = get_le32(data + 11); + + mgmt_print_address(data, type); + mgmt_print_added_device_flags("Supported Flags", supported_flags); + mgmt_print_added_device_flags("Current Flags", current_flags); +} + static const struct mgmt_data mgmt_event_table[] = { { 0x0001, "Command Complete", mgmt_command_complete_evt, 3, false }, @@ -13793,6 +13861,8 @@ static const struct mgmt_data mgmt_event_table[] = { mgmt_phy_changed_evt, 4, true }, { 0x0027, "Experimental Feature Changed", mgmt_exp_feature_changed_evt, 20, true }, + { 0x002a, "Device Flags Changed", + mgmt_device_flags_changed_evt, 15, true }, { } }; -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uNs2DdOIA19+nAAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 22:25:55 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wON4C9OIA1/yiAAAlScrYA (envelope-from ); Mon, 06 Jul 2020 22:25:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0AB46A3140; Mon, 6 Jul 2020 22:25:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727120AbgGFUZg (ORCPT + 1 other); Mon, 6 Jul 2020 16:25:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727088AbgGFUZe (ORCPT ); Mon, 6 Jul 2020 16:25:34 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65D97C061794 for ; Mon, 6 Jul 2020 13:25:34 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id k4so1612036pld.12 for ; Mon, 06 Jul 2020 13:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0SKTS/P3VVnxtXiKmmcc9yL2vznCzJDGVC6hgr5NWd8=; b=Qh9Xe9qSMSTqvB68j2i5QzuSgSb0C1QiQw3xUSEQJLK/0Js84pY95EBAEuvAruEcK9 IIl6mtvQlPxqpyhkfWrnIpYq3cVA6hSDTD+0RfEVRL5nmBOe6fQZiLRNWuLXOtV3BpiW EhKy+nHYn76BC4b+lO/N5PTqDw0ljCRj6Ra5s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0SKTS/P3VVnxtXiKmmcc9yL2vznCzJDGVC6hgr5NWd8=; b=ccQFwn/Mm02kzztjsPym27Dpya7r95cKuv/9DFzA5562pM1favTs3BOj0tpiwdFaJn Hjjh5yWNctF0zl+YWcl2t0mUJvKqnYBWxQrRnaaN7639t6OmgpRTPptVqSsFE0G0oJt8 AWiE42Gx3UuRITfGG6Wf4Qaq55hbJa7Zq7kegHnVs1LqnlPv2u7LNK3/rv8XL05gU9VW XcYbrSSBWnfNtf82gJFOSnBKqMQUkA2cbNHOHv78nJTWdUEWWpJta7f/cKRo2i6pcPlA we0pyxOjOf4e/0nwAxf0ItotqoypNdwT8AY24Uy58VHKU8NIxa/llu6gFShnbhATfQJp pB6g== X-Gm-Message-State: AOAM533H6JBG2hqs/p8pB2qXlrdrCZeK0/am8Uyliyknv0rN1Kv/cgwF 0KQ6TogCFwoNhObkxovFzhIGaQ== X-Google-Smtp-Source: ABdhPJwf35MTPoQgz5QG1C8aP5J+BSvlAouurmNUsmq/Vt8qmhzp422dmgquBd+8im+0XFJhhc716g== X-Received: by 2002:a17:902:d392:: with SMTP id e18mr30091623pld.139.1594067133799; Mon, 06 Jul 2020 13:25:33 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id n25sm3320226pff.51.2020.07.06.13.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 13:25:33 -0700 (PDT) From: Abhishek Pandit-Subedi To: luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, marcel@holtmann.org, chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi Subject: [BlueZ PATCH v7 3/6] device: Support marking a device with wake allowed Date: Mon, 6 Jul 2020 13:25:15 -0700 Message-Id: <20200706132503.BlueZ.v7.3.I1b0ff04f458fdaec2a193d27c2b94ce8f2cc4138@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200706202518.1153647-1-abhishekpandit@chromium.org> References: <20200706202518.1153647-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 18 X-Rspamd-Score: 2.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0AB46A3140 X-Rspamd-UID: df7402 If a device is allowed to wake the host system from suspend, it should be marked as wake allowed. We add support for a new property that is sent to the kernel via set device flags mgmt op. We also add the dbus endpoint to allow the wake allowed setting to be controlled. In order for wake allowed to be set, the profile must also support wake. This setting isn't exposed to the user but must be set by profiles that intend to support wake from suspend. If a device is connecting for the first time, it will be marked WakeAllowed if the profile supports it. On subsequent reloads of bluez, the stored setting "WakeAllowed" will be used to override any other setting. --- Changes in v7: * Fix more build issues reported by bluez.test.bot Changes in v6: * Save pending property id and emit success only after set flags returns * Ignore multiple calls to set_wake_allowed to the same value * Emit property error busy if same value is already sent to mgmt * Fix up build issues reported by bluez.test.bot Changes in v5: * Refactor to use set_wake_flags and respond to device flags changed * Add wake_override so we can keep track of user/profile configuration vs what is currently active Changes in v4: * Renamed wake_capable to wake_allowed * Removed set_wake_capable mgmt op and updated add_device to accept flags to set whether a device is wakeable * Refactored adapter_whitelist_add and adapter_auto_connect_add to call adapter_add_device Changes in v3: * Added profile_wake_support and made wake_capable dependent on it Changes in v2: * Added dbus api "WakeCapable" to set value * Update device_set_wake_capable to be called by adapter_set_wake_capable_complete so we can emit property changed lib/mgmt.h | 2 + src/adapter.c | 93 ++++++++++++++++++++++ src/adapter.h | 3 +- src/device.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/device.h | 10 +++ 5 files changed, 317 insertions(+), 1 deletion(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index 525c4dd62..a800bcab4 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -665,6 +665,8 @@ struct mgmt_rp_get_device_flags { uint32_t current_flags; } __packed; +#define DEVICE_FLAG_REMOTE_WAKEUP (1 << 0) + #define MGMT_OP_SET_DEVICE_FLAGS 0x0050 #define MGMT_SET_DEVICE_FLAGS_SIZE 11 struct mgmt_cp_set_device_flags { diff --git a/src/adapter.c b/src/adapter.c index 9ce351893..bccdbe8bf 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -5102,6 +5102,94 @@ void adapter_auto_connect_add(struct btd_adapter *adapter, adapter->connect_list = g_slist_append(adapter->connect_list, device); } +static void set_device_wakeable_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_rp_set_device_flags *rp = param; + struct btd_adapter *adapter = user_data; + struct btd_device *dev; + char addr[18]; + + if (status != MGMT_STATUS_SUCCESS) { + btd_error(adapter->dev_id, "Set device flags return status: %s", + mgmt_errstr(status)); + return; + } + + if (length < sizeof(*rp)) { + btd_error(adapter->dev_id, + "Too small Set Device Flags complete event: %d", + length); + return; + } + + ba2str(&rp->addr.bdaddr, addr); + + dev = btd_adapter_find_device(adapter, &rp->addr.bdaddr, rp->addr.type); + if (!dev) { + btd_error(adapter->dev_id, + "Set Device Flags complete for unknown device %s", + addr); + return; + } + + device_set_wake_allowed_complete(dev); +} + +void adapter_set_device_wakeable(struct btd_adapter *adapter, + struct btd_device *device, bool wakeable) +{ + struct mgmt_cp_set_device_flags cp; + const bdaddr_t *bdaddr; + uint8_t bdaddr_type; + + if (!kernel_conn_control) + return; + + bdaddr = device_get_address(device); + bdaddr_type = btd_device_get_bdaddr_type(device); + + memset(&cp, 0, sizeof(cp)); + bacpy(&cp.addr.bdaddr, bdaddr); + cp.addr.type = bdaddr_type; + cp.current_flags = btd_device_get_current_flags(device); + if (wakeable) + cp.current_flags |= DEVICE_FLAG_REMOTE_WAKEUP; + else + cp.current_flags &= ~DEVICE_FLAG_REMOTE_WAKEUP; + + mgmt_send(adapter->mgmt, MGMT_OP_SET_DEVICE_FLAGS, adapter->dev_id, + sizeof(cp), &cp, set_device_wakeable_complete, adapter, NULL); +} + +static void device_flags_changed_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_ev_device_flags_changed *ev = param; + struct btd_adapter *adapter = user_data; + struct btd_device *dev; + char addr[18]; + + if (length < sizeof(*ev)) { + btd_error(adapter->dev_id, + "Too small Device Flags Changed event: %d", + length); + return; + } + + ba2str(&ev->addr.bdaddr, addr); + + dev = btd_adapter_find_device(adapter, &ev->addr.bdaddr, ev->addr.type); + if (!dev) { + btd_error(adapter->dev_id, + "Device Flags Changed for unknown device %s", addr); + return; + } + + btd_device_flags_changed(dev, ev->supported_flags, ev->current_flags); +} + + static void remove_device_complete(uint8_t status, uint16_t length, const void *param, void *user_data) { @@ -8544,6 +8632,11 @@ static int adapter_register(struct btd_adapter *adapter) adapter, NULL); load: + mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_FLAGS_CHANGED, + adapter->dev_id, + device_flags_changed_callback, + adapter, NULL); + load_config(adapter); fix_storage(adapter); load_drivers(adapter); diff --git a/src/adapter.h b/src/adapter.h index d0a5253bd..f8ac20261 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -213,6 +213,8 @@ int adapter_connect_list_add(struct btd_adapter *adapter, struct btd_device *device); void adapter_connect_list_remove(struct btd_adapter *adapter, struct btd_device *device); +void adapter_set_device_wakeable(struct btd_adapter *adapter, + struct btd_device *dev, bool wakeable); void adapter_auto_connect_add(struct btd_adapter *adapter, struct btd_device *device); void adapter_auto_connect_remove(struct btd_adapter *adapter, @@ -231,4 +233,3 @@ void btd_adapter_for_each_device(struct btd_adapter *adapter, void *data); bool btd_le_connect_before_pairing(void); - diff --git a/src/device.c b/src/device.c index 7b0eb256e..0deee2707 100644 --- a/src/device.c +++ b/src/device.c @@ -177,6 +177,12 @@ struct csrk_info { uint32_t counter; }; +enum { + WAKE_FLAG_DEFAULT = 0, + WAKE_FLAG_ENABLED, + WAKE_FLAG_DISABLED, +}; + struct btd_device { int ref_count; @@ -189,6 +195,21 @@ struct btd_device { bool le; bool pending_paired; /* "Paired" waiting for SDP */ bool svc_refreshed; + + /* Manage whether this device can wake the system from suspend. + * - wake_support: Requires a profile that supports wake (i.e. HID) + * - wake_allowed: Is wake currently allowed? + * - pending_wake_allowed - Wake flag sent via set_device_flags + * - wake_override - User configured wake setting + */ + bool wake_support; + bool wake_allowed; + bool pending_wake_allowed; + uint8_t wake_override; + GDBusPendingPropertySet wake_id; + + uint32_t supported_flags; + uint32_t current_flags; GSList *svc_callbacks; GSList *eir_uuids; struct bt_ad *ad; @@ -415,6 +436,12 @@ static gboolean store_device_info_cb(gpointer user_data) g_key_file_set_boolean(key_file, "General", "Blocked", device->blocked); + if (device->wake_override != WAKE_FLAG_DEFAULT) { + g_key_file_set_boolean(key_file, "General", "WakeAllowed", + device->wake_override == + WAKE_FLAG_ENABLED); + } + if (device->uuids) { GSList *l; int i; @@ -1318,6 +1345,130 @@ dev_property_advertising_data_exist(const GDBusPropertyTable *property, return bt_ad_has_data(device->ad, NULL); } +static bool device_get_wake_support(struct btd_device *device) +{ + return device->wake_support; +} + +void device_set_wake_support(struct btd_device *device, bool wake_support) +{ + device->wake_support = wake_support; + + /* If wake configuration has not been made yet, set the initial + * configuration. + */ + if (device->wake_override == WAKE_FLAG_DEFAULT) { + device_set_wake_override(device, wake_support); + device_set_wake_allowed(device, wake_support, -1U); + } +} + +static bool device_get_wake_allowed(struct btd_device *device) +{ + return device->wake_allowed; +} + +void device_set_wake_override(struct btd_device *device, bool wake_override) +{ + if (wake_override) { + device->wake_override = WAKE_FLAG_ENABLED; + device->current_flags |= DEVICE_FLAG_REMOTE_WAKEUP; + } else { + device->wake_override = WAKE_FLAG_DISABLED; + device->current_flags &= ~DEVICE_FLAG_REMOTE_WAKEUP; + } +} + +void device_set_wake_allowed(struct btd_device *device, bool wake_allowed, + GDBusPendingPropertySet id) +{ + /* Pending and current value are the same unless there is a change in + * progress. Only update wake allowed if pending value doesn't match the + * new value. + */ + if (wake_allowed == device->pending_wake_allowed) + return; + + device->wake_id = id; + device->pending_wake_allowed = wake_allowed; + adapter_set_device_wakeable(device_get_adapter(device), device, + wake_allowed); +} + +void device_set_wake_allowed_complete(struct btd_device *device) +{ + if (device->wake_id != -1U) { + g_dbus_pending_property_success(device->wake_id); + device->wake_id = -1U; + } + + device->wake_allowed = device->pending_wake_allowed; + g_dbus_emit_property_changed(dbus_conn, device->path, + DEVICE_INTERFACE, "WakeAllowed"); + + store_device_info(device); +} + + +static gboolean +dev_property_get_wake_allowed(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct btd_device *device = data; + dbus_bool_t wake_allowed = device_get_wake_allowed(device); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &wake_allowed); + + return TRUE; +} + +static void dev_property_set_wake_allowed(const GDBusPropertyTable *property, + DBusMessageIter *value, + GDBusPendingPropertySet id, void *data) +{ + struct btd_device *device = data; + dbus_bool_t b; + + if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN) { + g_dbus_pending_property_error(id, + ERROR_INTERFACE ".InvalidArguments", + "Invalid arguments in method call"); + return; + } + + if (device->temporary) { + g_dbus_pending_property_error(id, + ERROR_INTERFACE ".Unsupported", + "Cannot set property while temporary"); + return; + } + + /* Emit busy or success depending on current value. */ + if (b == device->pending_wake_allowed) { + if (device->wake_allowed == device->pending_wake_allowed) + g_dbus_pending_property_success(id); + else + g_dbus_pending_property_error( + id, ERROR_INTERFACE ".Busy", + "Property change in progress"); + + return; + } + + dbus_message_iter_get_basic(value, &b); + device_set_wake_override(device, b); + device_set_wake_allowed(device, b, id); +} + +static gboolean dev_property_wake_allowed_exist( + const GDBusPropertyTable *property, void *data) +{ + struct btd_device *device = data; + + return device_get_wake_support(device); +} + + static gboolean disconnect_all(gpointer user_data) { struct btd_device *device = user_data; @@ -2790,6 +2941,9 @@ static const GDBusPropertyTable device_properties[] = { { "AdvertisingData", "a{yv}", dev_property_get_advertising_data, NULL, dev_property_advertising_data_exist, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, + { "WakeAllowed", "b", dev_property_get_wake_allowed, + dev_property_set_wake_allowed, + dev_property_wake_allowed_exist }, { } }; @@ -3038,9 +3192,11 @@ static void convert_info(struct btd_device *device, GKeyFile *key_file) static void load_info(struct btd_device *device, const char *local, const char *peer, GKeyFile *key_file) { + GError *gerr = NULL; char *str; gboolean store_needed = FALSE; gboolean blocked; + gboolean wake_allowed; char **uuids; int source, vendor, product, version; char **techno, **t; @@ -3152,6 +3308,18 @@ next: btd_device_set_pnpid(device, source, vendor, product, version); } + /* Wake allowed is only configured and stored if user changed it. + * Otherwise, we enable if profile supports it. + */ + wake_allowed = g_key_file_get_boolean(key_file, "General", + "WakeAllowed", &gerr); + if (!gerr) { + device_set_wake_override(device, wake_allowed); + } else { + g_error_free(gerr); + gerr = NULL; + } + if (store_needed) store_device_info(device); } @@ -6558,6 +6726,48 @@ void btd_device_set_pnpid(struct btd_device *device, uint16_t source, store_device_info(device); } +uint32_t btd_device_get_current_flags(struct btd_device *dev) +{ + return dev->current_flags; +} + +/* This event is sent immediately after add device on all mgmt sockets. + * Afterwards, it is only sent to mgmt sockets other than the one which called + * set_device_flags. + */ +void btd_device_flags_changed(struct btd_device *dev, uint32_t supported_flags, + uint32_t current_flags) +{ + const uint32_t changed_flags = dev->current_flags ^ current_flags; + bool flag_value; + + dev->supported_flags = supported_flags; + dev->current_flags = current_flags; + + if (!changed_flags) + return; + + if (changed_flags & DEVICE_FLAG_REMOTE_WAKEUP) { + flag_value = !!(current_flags & DEVICE_FLAG_REMOTE_WAKEUP); + dev->pending_wake_allowed = flag_value; + + /* If an override exists and doesn't match the current state, + * apply it. This logic will run after Add Device only and will + * enable wake for previously paired devices. + */ + if (dev->wake_override != WAKE_FLAG_DEFAULT) { + bool wake_allowed = + dev->wake_override == WAKE_FLAG_ENABLED; + if (flag_value != wake_allowed) + device_set_wake_allowed(dev, wake_allowed, -1U); + else + device_set_wake_allowed_complete(dev); + } else { + device_set_wake_allowed_complete(dev); + } + } +} + static void service_state_changed(struct btd_service *service, btd_service_state_t old_state, btd_service_state_t new_state, diff --git a/src/device.h b/src/device.h index 06b100499..cb8d884e8 100644 --- a/src/device.h +++ b/src/device.h @@ -33,6 +33,7 @@ struct btd_device *device_create_from_storage(struct btd_adapter *adapter, char *btd_device_get_storage_path(struct btd_device *device, const char *filename); + void btd_device_device_set_name(struct btd_device *device, const char *name); void device_store_cached_name(struct btd_device *dev, const char *name); void device_get_name(struct btd_device *device, char *name, size_t len); @@ -139,6 +140,11 @@ void device_store_svc_chng_ccc(struct btd_device *device, uint8_t bdaddr_type, uint16_t value); void device_load_svc_chng_ccc(struct btd_device *device, uint16_t *ccc_le, uint16_t *ccc_bredr); +void device_set_wake_support(struct btd_device *device, bool wake_support); +void device_set_wake_override(struct btd_device *device, bool wake_override); +void device_set_wake_allowed(struct btd_device *device, bool wake_allowed, + guint32 id); +void device_set_wake_allowed_complete(struct btd_device *device); typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal, void *user_data); @@ -176,5 +182,9 @@ struct btd_service *btd_device_get_service(struct btd_device *dev, int device_discover_services(struct btd_device *device); int btd_device_connect_services(struct btd_device *dev, GSList *services); +uint32_t btd_device_get_current_flags(struct btd_device *dev); +void btd_device_flags_changed(struct btd_device *dev, uint32_t supported_flags, + uint32_t current_flags); + void btd_device_init(void); void btd_device_cleanup(void); -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ICfqI9iIA19+nAAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 22:26:00 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id +Mq6ItiIA1/2/AAA0J78UA (envelope-from ); Mon, 06 Jul 2020 22:26:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 55F9FA30CB; Mon, 6 Jul 2020 22:25:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727088AbgGFUZg (ORCPT + 1 other); Mon, 6 Jul 2020 16:25:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbgGFUZf (ORCPT ); Mon, 6 Jul 2020 16:25:35 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31AB9C08C5DF for ; Mon, 6 Jul 2020 13:25:35 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id o22so12442875pjw.2 for ; Mon, 06 Jul 2020 13:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0LatEk0g8LQ9EDPYxpI3OOipaRxOzP67SKgN1Taywi8=; b=h0rswxM9fGGKb7fWb1RA8CqYAQSY0g4KTkQVjgTXdhC8ClNpny5VVVEZnrCIcgyul9 trqe99WQMNUjPfqZMGWOZ0Qz23qMYB7p3B5KZKn944uU5f8de/0W2oDGDYyAisDT8/Iw vwJASBPafny/VcNzrG4dZ8+6l+9uG+Uh12NyM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0LatEk0g8LQ9EDPYxpI3OOipaRxOzP67SKgN1Taywi8=; b=P2wm+m0LZ7H3tTnoSI1diDwSZRgz0ZS+ITfpSiB0lwztJpIraBr8LjMzPymn3yGx/u BY64oTUIaR4lqcOChcc7z4026OkQjnGh3hO+9sEnLjiNdU4jjb3UUq7APs4wfUk5+apc 9i7coGPiavAmXF8dBJVAR8VBnfI13+RBo1t1smtFO5r+S8OMspO6YqoZ77wQLsmDl0u2 nshS68qNe0YmPMf5jWdrEvHEt3610Fks1OvTCzglkkuOHbartMcF6sN2c6XiSA8mtczj x6DG1jEubUNDwsgqvkAzB+GY9wOXIMC0F9l+vVyp0U+tH0532RB3/w0Q423kaIAut1eQ /IvA== X-Gm-Message-State: AOAM533FhVQmrwGDOxZ8sIctATF2wr3tLmpuT9cAQV3+cqOTtou1ajH0 BKB1GFzahNX1vKZDG19ht36ieA== X-Google-Smtp-Source: ABdhPJz/irbGi3WKkdJArD0wq5wK9eVTNJfqtwqTIJCQgjX/dnau3rOffPRsfN3GXLJKGN1dThAqNg== X-Received: by 2002:a17:902:bcc1:: with SMTP id o1mr41810694pls.246.1594067134774; Mon, 06 Jul 2020 13:25:34 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id n25sm3320226pff.51.2020.07.06.13.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 13:25:34 -0700 (PDT) From: Abhishek Pandit-Subedi To: luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, marcel@holtmann.org, chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi Subject: [BlueZ PATCH v7 4/6] client: Display wake allowed property with info Date: Mon, 6 Jul 2020 13:25:16 -0700 Message-Id: <20200706132503.BlueZ.v7.4.I45dbf8ee15dff6c9346dc9754574a0be9bee1fa1@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200706202518.1153647-1-abhishekpandit@chromium.org> References: <20200706202518.1153647-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 18 X-Rspamd-Score: 2.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 55F9FA30CB X-Rspamd-UID: dcb277 Display whether the device is configured as wake allowed when queried with cmd_info. --- Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: * Renamed WakeCapable to WakeAllowed Changes in v3: None Changes in v2: * Newly added to show whether device is wake capable * Removed automatically setting wake capable for HID devices client/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/main.c b/client/main.c index 422da5593..4953f50f0 100644 --- a/client/main.c +++ b/client/main.c @@ -1637,6 +1637,7 @@ static void cmd_info(int argc, char *argv[]) print_property(proxy, "Trusted"); print_property(proxy, "Blocked"); print_property(proxy, "Connected"); + print_property(proxy, "WakeAllowed"); print_property(proxy, "LegacyPairing"); print_uuids(proxy); print_property(proxy, "Modalias"); -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uIjWBt6IA1+ElgAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 22:26:06 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 6Go5Bd6IA1/8JAEA0J78UA (envelope-from ); Mon, 06 Jul 2020 22:26:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C5400A3123; Mon, 6 Jul 2020 22:26:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727123AbgGFUZi (ORCPT + 1 other); Mon, 6 Jul 2020 16:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbgGFUZh (ORCPT ); Mon, 6 Jul 2020 16:25:37 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B951C061755 for ; Mon, 6 Jul 2020 13:25:37 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id k27so2824359pgm.2 for ; Mon, 06 Jul 2020 13:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kufSIwBkTCOC8NS3izomh7PEGJvrLLTDuQTWRmVaS3c=; b=WMsRRXFAsVnGc3JgqeyrWeQNQ0kqBbB8/AHUpF5Kawxj6P7sEJaiFBjkNqjWlRY1RJ eImakgV8lXHteuTc1tsC68NI0T7Ls9JdsEqzOwSHLVfszBYo6g2VXlrYnxdM6W+zyk2T elkNKxlXkoF5C8uTuGksqGWzAbpr/I79+MpEI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kufSIwBkTCOC8NS3izomh7PEGJvrLLTDuQTWRmVaS3c=; b=gNsJIdaETgxwMSaS9kZATTq1EmF34X6xZHvRmnaJhybIE3oofXTZvUu2gGqoiGD73G MQuyVUWIppxxQSSy2TjJ45Q9t/sK09bpYZ39nhgnf1HeUDv10QoXAIxBFKbWOXFaBbcQ 7c8VNP1tP4bIhsx6c8LbljrBUppSpohM/PiF2Rs04pu5A/fwcvFhIXGKiXaiz1LbNF0a 7FefgNK5jpLz3iV1uUwyDq9UnTPWTKFmDLMymS0J0xNtGJBppsnHelEteQG8Nik5+wGq ILrVv1W2SKPnOuCf5dKoTex3Dg8+H6C+JSHMmtXIWxkOysATpIlAIDq83l3jf/b1QxZM 08sg== X-Gm-Message-State: AOAM530OPjKmWLJTauTiQNyI44d1C4rK/G0z31rOkzXbXCUbkejtgpsJ KT0P6YceI3zWRDT9Fls9Rqq6LA== X-Google-Smtp-Source: ABdhPJzRQSblEfSUXwfIhsKThWX/YcGcUNbhgVD+xNOMqB7FCxZPtpIPVACoVPl+OklOwZrArP6FeQ== X-Received: by 2002:a65:60d4:: with SMTP id r20mr37992478pgv.436.1594067136842; Mon, 06 Jul 2020 13:25:36 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id n25sm3320226pff.51.2020.07.06.13.25.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 13:25:36 -0700 (PDT) From: Abhishek Pandit-Subedi To: luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, marcel@holtmann.org, chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi Subject: [BlueZ PATCH v7 6/6] input: Make HID devices support wake Date: Mon, 6 Jul 2020 13:25:18 -0700 Message-Id: <20200706132503.BlueZ.v7.6.I3290604153369ff32013f3dcadda4df3f2eb0f36@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200706202518.1153647-1-abhishekpandit@chromium.org> References: <20200706202518.1153647-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 29 X-Rspamd-Score: 4.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: C5400A3123 X-Rspamd-UID: 37062e HID devices can wake the host from a suspended state. Mark the profiles to support wake when they are accepted. If the device hasn't already been configured with a Wake Allowed configuration, it will default to yes when the profile is accepted. --- Changes in v7: None Changes in v6: None Changes in v5: * Only call device_set_wake_support Changes in v4: * Renamed device_set_profile_wake_support to just device_set_wake_support Changes in v3: * Mark HID device to support wake from suspend Changes in v2: None profiles/input/device.c | 1 + profiles/input/hog.c | 1 + 2 files changed, 2 insertions(+) diff --git a/profiles/input/device.c b/profiles/input/device.c index d3724ed54..2dc2ecab2 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -1409,6 +1409,7 @@ int input_device_register(struct btd_service *service) } btd_service_set_user_data(service, idev); + device_set_wake_support(device, true); return 0; } diff --git a/profiles/input/hog.c b/profiles/input/hog.c index 9335b7e8b..130f696a9 100644 --- a/profiles/input/hog.c +++ b/profiles/input/hog.c @@ -166,6 +166,7 @@ static int hog_probe(struct btd_service *service) return -EINVAL; btd_service_set_user_data(service, dev); + device_set_wake_support(device, true); return 0; } -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8EWWH+OIA19+nAAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 22:26:11 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wO0uHuOIA1/yiAAAlScrYA (envelope-from ); Mon, 06 Jul 2020 22:26:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 392D5A1FE5; Mon, 6 Jul 2020 22:26:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727124AbgGFUZi (ORCPT + 1 other); Mon, 6 Jul 2020 16:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727116AbgGFUZg (ORCPT ); Mon, 6 Jul 2020 16:25:36 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A47FC061755 for ; Mon, 6 Jul 2020 13:25:36 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id d10so3743910pll.3 for ; Mon, 06 Jul 2020 13:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QJK/v7CS6qpK7d2NGsWDNwIq2Zg5Zj/Jc/lazqa5Mqo=; b=HwaG98fe6K1/6kIWNzabVqHxk6u50+S0dVD5BXK6ptaw+INBnM0gGzLaAEKadOYfnK JaGhylFLHaJIVyqzZRaIngjbUjdMCgOXTVxNUoM0Z1jIEstmHZTmByVn8PwIZ1CXUsZL jxBY3YoiUW3xScK9B/SxKXMNQmbMxMZoL6vn0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QJK/v7CS6qpK7d2NGsWDNwIq2Zg5Zj/Jc/lazqa5Mqo=; b=uQiIzfNtooWcGdudDijiVus9bL9BlwbckPceY3FP5TZDrDN/xCBm/bRNZTjVVaQnEq OvWu1cdRz9izHNbGLbBDzrDRifcTImFE4mkfqd3Yx8yHy7QEHb+vqvxoe0eYhHFWICDR BDrZq7XIE+/AYcSfD1WfhO0nxF//rbkQ6TTFKi/L2ey3xPKSO2cfDUCCIvBTNHPj5eXq zqrd9s61bbb9vVYSvsNtp304zKo0AxHvTD6k+4U8HDlTYYPhJjy5wtaKRNgD5uTx5c2j GbLh9uuIQXqGDSdqc9G7NEiJMn925oJmJgCdD8V2ozX+5lQRL23Xsdc2lf9cbdrGq59K A/Fw== X-Gm-Message-State: AOAM532NpkEBjGxvrT+VFxoT0ecQdD0zM0OMsPP+EgL2hJ2UryGhBXm0 t69wX/MckSA7jJLLhcq3NIcscA== X-Google-Smtp-Source: ABdhPJxFVkbpydRsaYoZNDNe7dTasihd5IQ0YgRzpeJb/dmbK9n8z7KJwU0NI7iyY8PqKpzU7C30nw== X-Received: by 2002:a17:902:7d8f:: with SMTP id a15mr2742106plm.37.1594067135735; Mon, 06 Jul 2020 13:25:35 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id n25sm3320226pff.51.2020.07.06.13.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 13:25:35 -0700 (PDT) From: Abhishek Pandit-Subedi To: luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, marcel@holtmann.org, chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi Subject: [BlueZ PATCH v7 5/6] doc/device-api: Add WakeAllowed Date: Mon, 6 Jul 2020 13:25:17 -0700 Message-Id: <20200706132503.BlueZ.v7.5.If391d18ed934a1d9c24d3f54e4fee3fded0b17ab@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200706202518.1153647-1-abhishekpandit@chromium.org> References: <20200706202518.1153647-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 18 X-Rspamd-Score: 2.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 392D5A1FE5 X-Rspamd-UID: 76d96c Add documentation for WakeAllowed, which allows a device to wake the system from suspend. --- Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: * Renamed WakeCapable to WakeAllowed Changes in v3: * Added documentation for WakeCapable Changes in v2: None doc/device-api.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/device-api.txt b/doc/device-api.txt index 65d8fee37..4e824d2de 100644 --- a/doc/device-api.txt +++ b/doc/device-api.txt @@ -189,6 +189,11 @@ Properties string Address [readonly] drivers will also be removed and no new ones will be probed as long as the device is blocked. + boolean WakeAllowed [readwrite] + + If set to true this device will be allowed to wake the + host from system suspend. + string Alias [readwrite] The name alias for the remote device. The alias can -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6ExCLpyJA1+ElgAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 22:29:16 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id eNMELZyJA1+SUwAAgupzMw (envelope-from ); Mon, 06 Jul 2020 22:29:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F0CFAA31A5; Mon, 6 Jul 2020 22:29:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726996AbgGFU3K convert rfc822-to-8bit (ORCPT + 1 other); Mon, 6 Jul 2020 16:29:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:47532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726280AbgGFU3K (ORCPT ); Mon, 6 Jul 2020 16:29:10 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 198993] Intel Bluetooth 8260: Spurious wake events prevent from staying suspended in s2idle state on Dell Latitude 7275 Date: Mon, 06 Jul 2020 20:29:10 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jerome.debretagne@gmail.com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: CODE_FIX X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: F0CFAA31A5 X-Rspamd-UID: bc95bf https://bugzilla.kernel.org/show_bug.cgi?id=198993 Jérôme de Bretagne (jerome.debretagne@gmail.com) changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |CODE_FIX --- Comment #5 from Jérôme de Bretagne (jerome.debretagne@gmail.com) --- Confirmed as fixed in v5.7 , thanks again Abhishek. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4FdrL26MA187rAAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 22:41:18 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id mAxBLm6MA19wPAEA0J78UA (envelope-from ); Mon, 06 Jul 2020 22:41:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 21F9740079; Mon, 6 Jul 2020 22:41:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726805AbgGFUlM convert rfc822-to-8bit (ORCPT + 1 other); Mon, 6 Jul 2020 16:41:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:51462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726434AbgGFUlM (ORCPT ); Mon, 6 Jul 2020 16:41:12 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 198993] Intel Bluetooth 8260: Spurious wake events prevent from staying suspended in s2idle state on Dell Latitude 7275 Date: Mon, 06 Jul 2020 20:41:12 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: abhishekpandit@chromium.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: CODE_FIX X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: 21F9740079 X-Rspamd-UID: 589539 https://bugzilla.kernel.org/show_bug.cgi?id=198993 --- Comment #6 from Abhishek Pandit-Subedi (abhishekpandit@chromium.org) --- FYI, there's a few more spurious wake issues being discussed in https://bugzilla.kernel.org/show_bug.cgi?id=207629 (usually occurring when you run suspend stress test) -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4InKAkSPA1+/wAAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 22:53:24 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id eCUvAUSPA18h/wAA0J78UA (envelope-from ); Mon, 06 Jul 2020 22:53:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1A6B84F22D; Mon, 6 Jul 2020 22:53:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727853AbgGFUxR convert rfc822-to-8bit (ORCPT + 1 other); Mon, 6 Jul 2020 16:53:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:54496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727122AbgGFUxR (ORCPT ); Mon, 6 Jul 2020 16:53:17 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 203535] Bluetooth: command tx timeout with Intel Corporation Wireless 7260 in A2DP mode Date: Mon, 06 Jul 2020 20:53:16 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: abhishekpandit@chromium.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.07 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1A6B84F22D X-Rspamd-UID: ed95e6 https://bugzilla.kernel.org/show_bug.cgi?id=203535 Abhishek Pandit-Subedi (abhishekpandit@chromium.org) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |abhishekpandit@chromium.org --- Comment #5 from Abhishek Pandit-Subedi (abhishekpandit@chromium.org) --- There's a recovery mechanism via `cmd_timeout` that the btusb driver uses to recover from these issues. For Intel chipsets, this requires having a reset gpio available and listed in the ACPI/DeviceTree. From the logs above, it looks like that's not the case. I've had some success on a QCA chipset (6174A) by just resetting the port when this happens (see https://patchwork.kernel.org/patch/11624041/) If you don't mind patching your kernel, you could try the following and see if it helps (you will need the series I linked above as well if you're not using bluetooth-next master branch). diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 0e143c0cecf2a1..cf86104fd62018 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -511,6 +511,7 @@ struct btusb_data { unsigned cmd_timeout_cnt; }; +static void btusb_qca_cmd_timeout(struct hci_dev *hdev); static void btusb_intel_cmd_timeout(struct hci_dev *hdev) { struct btusb_data *data = hci_get_drvdata(hdev); @@ -520,7 +521,8 @@ static void btusb_intel_cmd_timeout(struct hci_dev *hdev) return; if (!reset_gpio) { - bt_dev_err(hdev, "No way to reset. Ignoring and continuing"); + bt_dev_err(hdev, "No reset gpio. Resetting usb instead."); + btusb_qca_cmd_timeout(hdev); return; } -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2B2LKQORA1+/wAAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 23:00:51 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gNcvKAORA18NeAAAgupzMw (envelope-from ); Mon, 06 Jul 2020 23:00:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5C7AC526C5; Mon, 6 Jul 2020 23:00:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726134AbgGFVAp convert rfc822-to-8bit (ORCPT + 1 other); Mon, 6 Jul 2020 17:00:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:56602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgGFVAp (ORCPT ); Mon, 6 Jul 2020 17:00:45 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 198993] Intel Bluetooth 8260: Spurious wake events prevent from staying suspended in s2idle state on Dell Latitude 7275 Date: Mon, 06 Jul 2020 21:00:45 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jerome.debretagne@gmail.com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: CODE_FIX X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5C7AC526C5 X-Rspamd-UID: a13d5b https://bugzilla.kernel.org/show_bug.cgi?id=198993 --- Comment #7 from Jérôme de Bretagne (jerome.debretagne@gmail.com) --- Thanks for this pointer, I haven't detected this issue on my machine (Dell Latitude 7275) so far, suspend looks reliable with the XHC entry re-enabled. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wCkkMyqSA19zswAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 23:05:46 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id GPkMMiqSA18EUwEA0J78UA (envelope-from ); Mon, 06 Jul 2020 23:05:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3BE3AA319B; Mon, 6 Jul 2020 23:05:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726625AbgGFVFe (ORCPT + 1 other); Mon, 6 Jul 2020 17:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbgGFVFe (ORCPT ); Mon, 6 Jul 2020 17:05:34 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4A4CC08C5DF for ; Mon, 6 Jul 2020 14:05:33 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id d21so23466120lfb.6 for ; Mon, 06 Jul 2020 14:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZIf5BAN7x2kxktXeQK1tz8O0tAhgpueX6XBodeYeUWU=; b=G88ybYN2JoC2gLQbYZnAHhHeRYyuWI/EaZ/NPsAE9s8SgZDV1E++W8K6TB6h0sLqZV 0RVVM206wkSWJWkz/Zs0WB0IenfA3pY7Es2vvKWlSfEjaOXrvuAfTlqTwRqPeVQUsCxE oI6a0rwOWOy0jtk2LbEFmwjbAka7qT2PiEzew= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZIf5BAN7x2kxktXeQK1tz8O0tAhgpueX6XBodeYeUWU=; b=uMFsivD25muyFq6m/BtcGJxkAY7pOQrhIHK25xxL/Hsk14VwO547IkosffRbtOSRnU 9BDJg7b/4eCOCCaAJFBix2kB37efWsadqdwPxW/QL8nLlUSmBNtCj1/KslC1FMh4pLRJ HIrMIdZ/mqBa5XyRmf6V6Ke3aaK4iML4heA2aWRgg8aHnvkHNRWxUktvg6fBBpj5IT7n pKV1crCNv4hL4WYeyt7IDYWyPMy21E9cIPMM0qk+RO6WHT0jeDc0EGi6kIjks79V9wYk hD71NUTKR0RCYgKPaaFytlxKaJeAgbaZRCwl1VLyT5wKBkCFIPOXER4lrCUJXi1VxKtC 0GLA== X-Gm-Message-State: AOAM531ZgV7WuOC7kq5WSTdgKhqBsi0KmMeCWS0TX6Or/DcwGU+pTTfh h+Wnn6ltmXxwFX0HF3jaSkGJQLOEHjaLgJHkLkEj4g== X-Google-Smtp-Source: ABdhPJw/C573wYg00zUcrBo1SJd6xbJ33WaRub/AC8BVEfvsSEBHLyWeDw7+PTsKYsSLlFM0Xc3zTWuUv5TYsAtqscI= X-Received: by 2002:ac2:5619:: with SMTP id v25mr31528433lfd.117.1594069532077; Mon, 06 Jul 2020 14:05:32 -0700 (PDT) MIME-Version: 1.0 References: <20200629201441.v1.1.I162e3c6c4f4d963250c37733c3428329110c5989@changeid> <968D6753-8ACB-4298-91A4-F2C9438EAC06@holtmann.org> In-Reply-To: From: Miao-chen Chou Date: Mon, 6 Jul 2020 14:05:21 -0700 Message-ID: Subject: Re: [PATCH v1] Bluetooth: Fix kernel oops triggered by hci_adv_monitors_clear() To: Marcel Holtmann Cc: Bluetooth Kernel Mailing List , Alain Michaud , Pavel Machek , Abhishek Pandit-Subedi , "David S. Miller" , Jakub Kicinski , Johan Hedberg , LKML , netdev Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: 0.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3BE3AA319B X-Rspamd-UID: 80cea2 Hi Marcel, In case you missed this thread, my suggestion is to revert the previous patch and apply this patch. Please see my earlier email for the reason. Thanks. Regards, Miao On Tue, Jun 30, 2020 at 2:55 PM Miao-chen Chou wrote: > > Hi Marcel, > > hci_unregister_dev() is invoked when the controller is intended to be > removed by btusb driver. In other words, there should not be any > activity on hdev's workqueue, so the destruction of the workqueue > should be the first thing to do to prevent the clear helpers from > issuing any work. So my suggestion is to revert the patch re-arranging > the workqueue and apply this instead. > I should have uploaded this earlier, but I encountered some troubles > while verifying the changes. Sorry for the inconvenience. > > Regards, > Miao > > On Mon, Jun 29, 2020 at 11:51 PM Marcel Holtmann wrote: > > > > Hi Miao-chen, > > > > > This fixes the kernel oops by removing unnecessary background scan > > > update from hci_adv_monitors_clear() which shouldn't invoke any work > > > queue. > > > > > > The following test was performed. > > > - Run "rmmod btusb" and verify that no kernel oops is triggered. > > > > > > Signed-off-by: Miao-chen Chou > > > Reviewed-by: Abhishek Pandit-Subedi > > > Reviewed-by: Alain Michaud > > > --- > > > > > > net/bluetooth/hci_core.c | 2 -- > > > 1 file changed, 2 deletions(-) > > > > > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > > > index 5577cf9e2c7cd..77615161c7d72 100644 > > > --- a/net/bluetooth/hci_core.c > > > +++ b/net/bluetooth/hci_core.c > > > @@ -3005,8 +3005,6 @@ void hci_adv_monitors_clear(struct hci_dev *hdev) > > > hci_free_adv_monitor(monitor); > > > > > > idr_destroy(&hdev->adv_monitors_idr); > > > - > > > - hci_update_background_scan(hdev); > > > } > > > > I am happy to apply this as well, but I also applied another patch re-arranging the workqueue destroy handling. Can you check which prefer or if we should include both patches. > > > > Regards > > > > Marcel > > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yMydJ6CSA19zswAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 23:07:44 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id WNt5JaCSA1/nrwAAlScrYA (envelope-from ); Mon, 06 Jul 2020 23:07:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A59CB4283D; Mon, 6 Jul 2020 23:07:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726839AbgGFVHb (ORCPT + 1 other); Mon, 6 Jul 2020 17:07:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgGFVHa (ORCPT ); Mon, 6 Jul 2020 17:07:30 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A98FFC061755 for ; Mon, 6 Jul 2020 14:07:30 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id k27so2871541pgm.2 for ; Mon, 06 Jul 2020 14:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ltxd3dYIIoYCEWLVWkAFd+Lvzl8zZTtrqnBoRTLOPrw=; b=h2cbsGNvG0tAe/ImaTVsxGwkE46Q+vlxD3xFsSo9MKqc4fVdwDwBfTqyph9hswjzur CYqkBZet0gWna39RzAOQhznMY3bFxO6++cwd1MVuakUPA9PHjxpwnjzfSkwh/f1/OrM7 aSBK9wYYoe8Umfp4asSMM2vMDK98EqA4ftz7Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ltxd3dYIIoYCEWLVWkAFd+Lvzl8zZTtrqnBoRTLOPrw=; b=m+YsGVQoqkJSvW1Ku0RsD5BH2dEtnJEZ3HD7CGL4cVJH+ykw6dbgpwyBWcqWrBULg1 K0CKARylFMKOVKU0cXAloR785KFcqE7qOb6uVoOQR/4CnCfjO/pK4SWHkUTp0K9v6Za0 n6X10KPL532xjUlVRMJEoajXZAZRYgSyKzUCspt+fhYrWsJ1j0iCXvw8YdOSGqWBGN9i 0Z9AP7VdauhpjSusOLjowRNX1TMT0Ag1TYcKeEER7QGekZmTV5HUmWEuz3Bx2uNZZnPr x+N5S5BwrZi1VVb5YhNXfMiIyckHVBQXCV5QUksmqJemGAEK7MGSkrBysdWyzawXt6XZ A24A== X-Gm-Message-State: AOAM532enAdlDFe8TPhbMT7fMSpIOGlVB7t/pxhHO72hSlD/gQa/d1/E qNZPxLigb+pWRmuAWpfdgx61rw== X-Google-Smtp-Source: ABdhPJy7PL/hlbFhwfnzuhW1Tr79eUWHhfP6EcBz2eu08ukka/c7cEFGGfAvpTJxtAZYYZAIv4kw1Q== X-Received: by 2002:a63:338c:: with SMTP id z134mr27954169pgz.245.1594069649524; Mon, 06 Jul 2020 14:07:29 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id j8sm21088609pfd.145.2020.07.06.14.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 14:07:28 -0700 (PDT) From: Abhishek Pandit-Subedi To: linux-pm@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, rafael.j.wysocki@intel.com, swboyd@chromium.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Greg Kroah-Hartman , Pavel Machek Subject: [PATCH v2 0/1] power: Emit change uevent when updating sysfs Date: Mon, 6 Jul 2020 14:07:16 -0700 Message-Id: <20200706210717.1210639-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 32 X-Rspamd-Score: 4.93 / 15.00 / 200.00 X-Rspamd-Queue-Id: A59CB4283D X-Rspamd-UID: e78852 Hi linux-pm, ChromeOS has a udev rule to chown the `power/wakeup` attribute so that the power manager can modify it during runtime. (https://source.chromium.org/chromiumos/chromiumos/codesearch/+/master:src/platform2/power_manager/udev/99-powerd-permissions.rules) In our automated tests, we found that the `power/wakeup` attributes weren't being chown-ed for some boards. On investigating, I found that when the drivers probe and call device_set_wakeup_capable, no uevent was being emitted for the newly added power/wakeup attribute. This was manifesting at boot on some boards (Marvell SDIO bluetooth and Broadcom Serial bluetooth drivers) or during usb disconnects during resume (Realtek btusb driver with reset resume quirk). It seems reasonable to me that changes to the attributes of a device should cause a changed uevent so I have added that here. Here's an example of the kernel events after toggling the authorized bit of /sys/bus/usb/devices/1-3/ $ echo 0 > /sys/bus/usb/devices/1-3/authorized KERNEL[27.357994] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill1 (rfkill) KERNEL[27.358049] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[27.358458] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[27.358486] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) KERNEL[27.358529] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) $ echo 1 > /sys/bus/usb/devices/1-3/authorized KERNEL[36.415749] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) KERNEL[36.415798] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[36.417414] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[36.417447] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill2 (rfkill) KERNEL[36.417481] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) Thanks Abhishek Changes in v2: - Add newline at end of bt_dev_err Abhishek Pandit-Subedi (1): power: Emit changed uevent on wakeup_sysfs_add/remove drivers/base/power/sysfs.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KDp8A6uSA1+I4AAAvsO+Rg (envelope-from ) for ; Mon, 06 Jul 2020 23:07:55 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8D9LAquSA18QhAAAgupzMw (envelope-from ); Mon, 06 Jul 2020 23:07:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8AFE841952; Mon, 6 Jul 2020 23:07:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726852AbgGFVHc (ORCPT + 1 other); Mon, 6 Jul 2020 17:07:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726819AbgGFVHb (ORCPT ); Mon, 6 Jul 2020 17:07:31 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22591C061755 for ; Mon, 6 Jul 2020 14:07:31 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id d194so15582942pga.13 for ; Mon, 06 Jul 2020 14:07:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4duSpApL0OEcflw6oiG/5wMmEL4Cmw3V+9yHdG3N38U=; b=XmsAhP4DdWtK3W4olE1WbLyYpUKk11eaUe0dO82ItIsxpJc6PQBXfSrrS6MZtwHs8m f0CY9K+RlEEq+1dfZGK+JICWadd3cjgom7vPkIL5LYEdsgG4By9E0RAo/m1PIPDhCJyy Ykw5aSq0eA4CKCg5oSsRLxOMF9uQuVVOxb48M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4duSpApL0OEcflw6oiG/5wMmEL4Cmw3V+9yHdG3N38U=; b=tRaEccZblF2AMK2j0HUyW7fa3PHTexyNjoFwoR9ZbgRSMr6erYqKX0ttgjvDRJhpii bBWPn3vDPw0xJTLnaT2MD+ikprBiUtc681iIFKvaRV8C85bmKTdv4+/0ICeapLCAjH8G ph/xdr+bNR1BlcRK3Hdi9Mn3NdYv2h6eFQexEd7LCnCUcgUWYP6/87IIcou12900vWyS X0iG0CNK3gud4MQzAz023Wq7Z1K/MiyK0VhwtGEabqSBKbROXaGLyv4lubSGzcwYb0KP Ec74v04o6o2g8nN3Q1zJykq+ApQtLEpVRp+crinAQEfubfTH3Im8daQmL8OVMVb5oHfW R6qw== X-Gm-Message-State: AOAM531kBYWjmpSuo2LWB7oWENoXqbg7zcvdQQ4ICueJps7UsnAJ/+EU KYJ5WQWE+lD+Opf7P67LSj64aA== X-Google-Smtp-Source: ABdhPJwgdoH9pz5Y5wcjCE9hjkYwspxTSbpI/kAOsnuiwZnTwDYlG7ymZuFB6AffdVodou00H5Pizw== X-Received: by 2002:a05:6a00:1511:: with SMTP id q17mr46701197pfu.16.1594069650636; Mon, 06 Jul 2020 14:07:30 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id j8sm21088609pfd.145.2020.07.06.14.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 14:07:30 -0700 (PDT) From: Abhishek Pandit-Subedi To: linux-pm@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, rafael.j.wysocki@intel.com, swboyd@chromium.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Greg Kroah-Hartman , Pavel Machek Subject: [PATCH v2 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove Date: Mon, 6 Jul 2020 14:07:17 -0700 Message-Id: <20200706140715.v2.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200706210717.1210639-1-abhishekpandit@chromium.org> References: <20200706210717.1210639-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8AFE841952 X-Rspamd-UID: 8e4eea Udev rules that depend on the power/wakeup attribute don't get triggered correctly if device_set_wakeup_capable is called after the device is created. This can happen for several reasons (driver sets wakeup after device is created, wakeup is changed on parent device, etc) and it seems reasonable to emit a changed event when adding or removing attributes on the device. Signed-off-by: Abhishek Pandit-Subedi --- Changes in v2: - Add newline at end of bt_dev_err drivers/base/power/sysfs.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index 24d25cf8ab1487..d57e8e7f175ebf 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* sysfs entries for device PM */ #include +#include #include #include #include @@ -739,12 +740,30 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) int wakeup_sysfs_add(struct device *dev) { - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); + + if (!ret) { + int tmp = kobject_uevent(&dev->kobj, KOBJ_CHANGE); + + if (tmp) + dev_err(dev, + "Error in uevent for wakeup_sysfs_add: %d\n", + tmp); + } + + return ret; } void wakeup_sysfs_remove(struct device *dev) { + int tmp; + sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); + + tmp = kobject_uevent(&dev->kobj, KOBJ_CHANGE); + if (tmp) + dev_err(dev, "Error in uevent for wakeup_sysfs_remove: %d\n", + tmp); } int pm_qos_sysfs_add_resume_latency(struct device *dev) -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ILucHlfEA18mEQAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 02:39:51 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uGcTHVfEA1/RaAEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 02:39:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D5B17A010F; Tue, 7 Jul 2020 02:39:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726911AbgGGAjo (ORCPT + 1 other); Mon, 6 Jul 2020 20:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725942AbgGGAjo (ORCPT ); Mon, 6 Jul 2020 20:39:44 -0400 Received: from mail-vs1-xe44.google.com (mail-vs1-xe44.google.com [IPv6:2607:f8b0:4864:20::e44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49AD7C061755 for ; Mon, 6 Jul 2020 17:39:43 -0700 (PDT) Received: by mail-vs1-xe44.google.com with SMTP id a17so10713996vsq.6 for ; Mon, 06 Jul 2020 17:39:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pTKT+OgdQXytrQx567fvW+SoDkWq0qLBy6EFdrqiakI=; b=IwfVu7Z50Ix/dHptaW/scdYp/lsAs0w3+g+z7kjzQEcB9jG6S44YmIj8pnsC23X1xL fyDpWbsyw75QbEQyEQnJw0DF0WmYZa8kSbM/+hrEva4pMcLj/g5qapUN6Ut+WtCNly+7 k2n2FmLsieBt/4bc0TT8fKNHOVCf0hiRGImeU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pTKT+OgdQXytrQx567fvW+SoDkWq0qLBy6EFdrqiakI=; b=rWSHrgXkIPgpI32WOOufYoPT+fxgli28uU70Rb01bX2pn0YLFiXjNJt6RxRwzw0eUw sZMDMet+lvSlYAaLhB4eI5BJc/VlFG6+e6y/WvjU1I17+Qx3SoLrAeoVzYcdK1mI9a71 yiifRG65qnDSb1UhtRVKKKr7cylKhXyLs2YvQDpGdpR2oEyS7RJPC7I1S6Bv8zjzhlPu hOZSSOBdjQOHB47W2MkrwkKUn5jqNpFo+GWuayhFYfXesSsMHXgWMKn0dKm2+4u4DIeM +1HqGilUh7X34fsD5PS2d7VyFoCe59KhUbcoPeZiyX+HvriXmMXGR2QdSA73OKtD77Jq L/Pg== X-Gm-Message-State: AOAM530N6eSXsClelcEX/karS8jEhAEpiJS8TeMg0NcGiZuTClN6XGbx y3pKmfDe6b2tH/KKR4qNHzvvnMXgmnI= X-Google-Smtp-Source: ABdhPJw4Hr3Vj/GeTsZgwGGCmJQ9+pU3SOhLqoMVcoQlutObFYVOA4/9bjm10lo0OK4wMxfoYY9EDA== X-Received: by 2002:a05:6102:3002:: with SMTP id s2mr21458975vsa.2.1594082382203; Mon, 06 Jul 2020 17:39:42 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id c62sm323315vkg.30.2020.07.06.17.39.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 17:39:41 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud , Abhishek Pandit-Subedi Subject: [PATCH v1] Bluetooth: create CONFIG_BT_DEBUG_FUNC_NAME Date: Tue, 7 Jul 2020 00:39:37 +0000 Message-Id: <20200707003937.187125-1-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: D5B17A010F X-Rspamd-UID: 26720a Creates a CONFIG_BT_DEBUG_FUNC_NAME option to include function names in debug statements. Unlike other platforms __func__ isn't a string literal so it cannot be automatically concatenated by the pre-processor. As a result, the function name is passed as a parameter to the tracing function. Since pr_debug is a function like macro, the normal expansion of BT_PREFIX_PARAM does not work as it gets processed within the first parameter as well, for this reason, BT_DBG is split into two versions. This patch was built tested with all 4 possible combinations of CONFIG_BT_DEBUG_FUNC_NAME and CONFIG_BT_FEATURE_DEBUG configurations. Signed-off-by: Alain Michaud Reviewed-by: Abhishek Pandit-Subedi --- include/net/bluetooth/bluetooth.h | 32 +++++++++++++++++++++++-------- net/bluetooth/Kconfig | 11 +++++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 7ee8041af803..27ec8f2a7c28 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -162,22 +162,37 @@ void bt_dbg_set(bool enable); bool bt_dbg_get(void); __printf(1, 2) void bt_dbg(const char *fmt, ...); +#define BT_DBG_INT bt_dbg +#else +#define BT_DBG_INT pr_debug #endif __printf(1, 2) void bt_warn_ratelimited(const char *fmt, ...); __printf(1, 2) void bt_err_ratelimited(const char *fmt, ...); -#define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__) -#define BT_WARN(fmt, ...) bt_warn(fmt "\n", ##__VA_ARGS__) -#define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) - -#if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG) -#define BT_DBG(fmt, ...) bt_dbg(fmt "\n", ##__VA_ARGS__) +#if IS_ENABLED(CONFIG_BT_DEBUG_FUNC_NAMES) +#define BT_PREFIX "%s() " +#define BT_PREFIX_PARAM ,__func__ +#define BT_DBG(fmt, ...) \ + BT_DBG_INT(BT_PREFIX fmt "\n", __func__, ##__VA_ARGS__) #else -#define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__) +#define BT_PREFIX +#define BT_PREFIX_PARAM +#define BT_DBG(fmt, ...) \ + BT_DBG_INT(fmt "\n", ##__VA_ARGS__) #endif +#define BT_INFO(fmt, ...) \ + bt_info(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) +#define BT_WARN(fmt, ...) \ + bt_warn(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) +#define BT_ERR(fmt, ...) \ + bt_err(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) + +#define BT_ERR_RATELIMITED(fmt, ...) \ + bt_err_ratelimited(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) + #define bt_dev_info(hdev, fmt, ...) \ BT_INFO("%s: " fmt, (hdev)->name, ##__VA_ARGS__) #define bt_dev_warn(hdev, fmt, ...) \ @@ -188,7 +203,8 @@ void bt_err_ratelimited(const char *fmt, ...); BT_DBG("%s: " fmt, (hdev)->name, ##__VA_ARGS__) #define bt_dev_warn_ratelimited(hdev, fmt, ...) \ - bt_warn_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + bt_warn_ratelimited("%s: " BT_PREFIX fmt, (hdev)->name \ + BT_PREFIX_PARAM, ##__VA_ARGS__) #define bt_dev_err_ratelimited(hdev, fmt, ...) \ bt_err_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index 1d6d243cdde9..de31c682c7b0 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -142,4 +142,15 @@ config BT_FEATURE_DEBUG This provides an option to enable/disable debugging statements at runtime via the experimental features interface. +config BT_DEBUG_FUNC_NAMES + bool "Include function names in debugging statements" + depends on BT + default n + help + Provides an option to include function names in debugging + statements. + + When enabled, trace statements will include the function name as a + prefix which may help identify the source code references. + source "drivers/bluetooth/Kconfig" -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6BDbK7TbA191XwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 04:19:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 8KeXKrTbA19RWAAA0J78UA (envelope-from ); Tue, 07 Jul 2020 04:19:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4BAFD400FA; Tue, 7 Jul 2020 04:19:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726681AbgGGCT0 (ORCPT + 1 other); Mon, 6 Jul 2020 22:19:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726583AbgGGCT0 (ORCPT ); Mon, 6 Jul 2020 22:19:26 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 564C8C061755 for ; Mon, 6 Jul 2020 19:19:26 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id v1so21698351vsb.10 for ; Mon, 06 Jul 2020 19:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fXlDVwOK9y2sRda2nGIuhcRuMpsLxZNBuUuDCTcE2Uk=; b=XqI44sTllruhD3zy/xvdUWl2f7aJPJne1DfyUdUbL1MxiAQJS9woTQ67PnHrvldesw LKr1TDtKG9MCMXg1TKjXQ7DjWQlBINXDGXvsvYonss9vDl9yqerCBFWRwl+xwpVWyhVf KhEkPujx2Uuf2vrZ5XzbDmlqZPhyAOMK5S07Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fXlDVwOK9y2sRda2nGIuhcRuMpsLxZNBuUuDCTcE2Uk=; b=pGKMCVDdRVBokVDeDePuj6uNPoaXFYPEaoI+ISJgyOkC/CkYpNys1/JnfQ4jzjXdnD bE8KKW/WPVTPkWdI4sFeMT49C33UpOVvQMcYkQBr0cHqNngVOXChcizzIeFo8l8rvdtP FtLukQYQ3iWb7d0ShYJ+1XeoeZWXmEtlsg9R/pfAmPD5Hd6iVQwzRmj6CXIfkkJ79ppJ ILH4ziX+V/SXmEmXjNTIFVRC9zsOcwU5P9zMefazdJVy07kxNh9vqm3UDHt1RKSfk+fN K7I7l/WhV9C5C2GRU37dLXuO8tdOqXMm93LahaCuPwYgdHZIPcZ5eQ2ERDvbysgKznRo zIPg== X-Gm-Message-State: AOAM530f5dNrOsYZGcY/VylngYSP2TaYMWCWCI3tbrrDZ/MpC3ASqe5G v7vCqQlmCqsBDgEJrmH6S3ueb/b+ATM= X-Google-Smtp-Source: ABdhPJzdoL9gbR78xJ64mxmGHylXLShpoitfalka4xzYvWlINC/4cOgKTz9Lk2s9h/3mZMDXtA4uGg== X-Received: by 2002:a67:7d50:: with SMTP id y77mr37509155vsc.66.1594088364876; Mon, 06 Jul 2020 19:19:24 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id q200sm4855727vke.53.2020.07.06.19.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 19:19:24 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud Subject: [BlueZ PATCH 1/2] adapter: add support for the Roles property Date: Tue, 7 Jul 2020 02:19:18 +0000 Message-Id: <20200707021920.209213-1-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4BAFD400FA X-Rspamd-UID: 3a2cf7 This patch adds support for the Roles property as defined in adapter-api.txt. --- src/adapter.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 9ce351893..7afd6980c 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -122,6 +122,8 @@ static bool kernel_blocked_keys_supported = false; static bool kernel_set_system_config = false; +static bool kernel_exp_features = false; + static GList *adapter_list = NULL; static unsigned int adapter_remaining = 0; static bool powering_down = false; @@ -293,6 +295,8 @@ struct btd_adapter { unsigned int db_id; /* Service event handler for GATT db */ bool is_default; /* true if adapter is default one */ + + bool le_simult_roles_supported; }; typedef enum { @@ -3199,6 +3203,35 @@ static gboolean property_get_modalias(const GDBusPropertyTable *property, return TRUE; } +static gboolean property_get_roles(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct btd_adapter *adapter = user_data; + DBusMessageIter entry; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &entry); + + if (adapter->supported_settings & MGMT_SETTING_LE) { + const char *str = "central"; + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str); + } + + if (adapter->supported_settings & MGMT_SETTING_ADVERTISING) { + const char *str = "peripheral"; + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str); + } + + if (adapter->le_simult_roles_supported) { + const char *str = "central-peripheral"; + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str); + } + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + static int device_path_cmp(gconstpointer a, gconstpointer b) { const struct btd_device *device = a; @@ -3479,6 +3512,7 @@ static const GDBusPropertyTable adapter_properties[] = { { "UUIDs", "as", property_get_uuids }, { "Modalias", "s", property_get_modalias, NULL, property_exists_modalias }, + { "Roles", "as", property_get_roles }, { } }; @@ -9023,6 +9057,56 @@ static bool set_blocked_keys(struct btd_adapter *adapter) adapter, NULL); } +static void read_exp_features_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct btd_adapter *adapter = user_data; + const struct mgmt_rp_read_exp_features_info *rp = param; + size_t feature_count = 0; + size_t i = 0; + + DBG("index %u status 0x%02x", adapter->dev_id, status); + + if (status != MGMT_STATUS_SUCCESS) { + btd_error(adapter->dev_id, + "Failed to read exp features info: %s (0x%02x)", + mgmt_errstr(status), status); + return; + } + + if (length < sizeof(*rp)) { + btd_error(adapter->dev_id, "Response too small"); + return; + } + + feature_count = le16_to_cpu(rp->feature_count); + for (i = 0; i < feature_count; ++i) { + + /* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ + static const uint8_t le_simult_central_peripheral[16] = { + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, + }; + + if (memcmp(rp->features[i].uuid, le_simult_central_peripheral, + sizeof(le_simult_central_peripheral)) == 0) { + uint32_t flags = le32_to_cpu(rp->features[i].flags); + + adapter->le_simult_roles_supported = flags & 0x01; + } + } +} + +static void read_exp_features(struct btd_adapter *adapter) +{ + if (mgmt_send(adapter->mgmt, MGMT_OP_READ_EXP_FEATURES_INFO, + adapter->dev_id, 0, NULL, read_exp_features_complete, + adapter, NULL) > 0) + return; + + btd_error(adapter->dev_id, "Failed to read exp features info"); +} + static void read_info_complete(uint8_t status, uint16_t length, const void *param, void *user_data) { @@ -9132,6 +9216,9 @@ static void read_info_complete(uint8_t status, uint16_t length, (missing_settings & MGMT_SETTING_FAST_CONNECTABLE)) set_mode(adapter, MGMT_OP_SET_FAST_CONNECTABLE, 0x01); + if (kernel_exp_features) + read_exp_features(adapter); + err = adapter_register(adapter); if (err < 0) { btd_error(adapter->dev_id, "Unable to register new adapter"); @@ -9447,6 +9534,10 @@ static void read_commands_complete(uint8_t status, uint16_t length, DBG("kernel supports set system confic"); kernel_set_system_config = true; break; + case MGMT_OP_READ_EXP_FEATURES_INFO: + DBG("kernel supports exp features"); + kernel_exp_features = true; + break; default: break; } -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2HPFFsPbA191XwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 04:19:47 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 4HUIFcPbA1/NYwEAlScrYA (envelope-from ); Tue, 07 Jul 2020 04:19:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2AC7C40079; Tue, 7 Jul 2020 04:19:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726933AbgGGCTl (ORCPT + 1 other); Mon, 6 Jul 2020 22:19:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726583AbgGGCTl (ORCPT ); Mon, 6 Jul 2020 22:19:41 -0400 Received: from mail-vk1-xa43.google.com (mail-vk1-xa43.google.com [IPv6:2607:f8b0:4864:20::a43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52151C061755 for ; Mon, 6 Jul 2020 19:19:41 -0700 (PDT) Received: by mail-vk1-xa43.google.com with SMTP id e10so2243603vkm.10 for ; Mon, 06 Jul 2020 19:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=COXbuCTb1uxtXUkclqvogDk3kuYU7hDA74gntG4a48g=; b=hxDzQktX3lf+qlZOLr/v+bqWr4EKqomcnjjwKbDmIlDY5DwnfioKFxyGUsLEkNn47I jAOaYZYW5rFeey26CTOQ/aYJkZ0DrfI39US3Hpw0v/pOM6JZK669ki9tTYbrYt+0tl6n FXdrCcLb6Cw1ec8jtXHGmP/hdEUSSGU9whtpU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=COXbuCTb1uxtXUkclqvogDk3kuYU7hDA74gntG4a48g=; b=EGvYFYYbco7E9+8yBXrcdqKnkgk5FEFjFcHZnv/Y0M7YLsngRaV2gyX0szp+hD0YOH OteYwb1R4/rdRNC5/Mh/6euMq3HFh220fxkf6M23PxsMKO2RpeCgMGoQgep4azYw0vHI 31Y8xQdBQ7uCEZa/xVMH30jlO4I4pOb7fkGw4lfyAwUfW98V9RdyXbkCmfgiWRK5dk+V /9KP0cid6T8J/b0+Z8PdBop4GWD47G4PbAtg9iRYZDjIjPaiTIFQVb909JiPhxkdNjpl vbrP2IG+QO8R34roj3c62QrwZur2W9D2BRyxSVEWtuBxxJF8mDTzSH4S6+8O/8AhsaxL dl2Q== X-Gm-Message-State: AOAM5334WDM5p7ekfguYD2TXGaBqEFUuc54rIeqereI0t+UkI4KuxYBy tOYT6WWhDhYyaRK7zS5d5KzsjEUZy5g= X-Google-Smtp-Source: ABdhPJyQcmMzGnekXBAL0Memn0Ei4Vy4juD0V/5MuJFv/Z5F7SNghfr9NW0JmksAU663JBAQJij0rA== X-Received: by 2002:ac5:c183:: with SMTP id z3mr19464427vkb.74.1594088380245; Mon, 06 Jul 2020 19:19:40 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id q200sm4855727vke.53.2020.07.06.19.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 19:19:39 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud Subject: [BlueZ PATCH 2/2] client: Add support for the Roles property. Date: Tue, 7 Jul 2020 02:19:20 +0000 Message-Id: <20200707021920.209213-2-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200707021920.209213-1-alainm@chromium.org> References: <20200707021920.209213-1-alainm@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2AC7C40079 X-Rspamd-UID: 97228a This adds support for reading the Roles property through bluetootctl's show option. [bluetooth]# show ... Roles: central Roles: peripheral Roles: central-peripheral --- client/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/main.c b/client/main.c index c0b351aed..8af7c4e0f 100644 --- a/client/main.c +++ b/client/main.c @@ -925,6 +925,7 @@ static void cmd_show(int argc, char *argv[]) print_uuids(adapter->proxy); print_property(adapter->proxy, "Modalias"); print_property(adapter->proxy, "Discovering"); + print_property(adapter->proxy, "Roles"); if (adapter->ad_proxy) { bt_shell_printf("Advertising Features:\n"); -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OIs4Ig3cA18RagAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 04:21:01 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 6L9uIA3cA1/NYwEAlScrYA (envelope-from ); Tue, 07 Jul 2020 04:21:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A10CA400FA; Tue, 7 Jul 2020 04:20:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727008AbgGGCUz (ORCPT + 1 other); Mon, 6 Jul 2020 22:20:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726681AbgGGCUy (ORCPT ); Mon, 6 Jul 2020 22:20:54 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62FF5C061755 for ; Mon, 6 Jul 2020 19:20:54 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id m26so23855571lfo.13 for ; Mon, 06 Jul 2020 19:20:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mPuUrJIlJbDH1FXvjHv4kD8C1vGWoHt9ZrDqXArb4Cw=; b=IfqbSYTGIG9gwzwbE44OSbtKyGpPck0hEAv1buAoqSLx9XuFT6VYMF6URNZgMoBiVs fcRP/sxSx5vXVM09EiloMlK5z+ueSdGYmpXoPDBJqUYzjDk6wGadK4UJ5SCMO4LirWFF p8Dxrr77Fj/cc19xwYj6AQJ69dNL1vIQ+lPxqWmgol0PQqLzhKMCBYqp1MgscP+Xw0Xi wB4S/LkaS2YzXkhSxKlRTLlqjrhBni5Ixuzeyz15TaUni3ZtawbipMA6tyJ3vf5kXhne gqC+87CPJ2N2xit79C38qZwEqyg8XuTsuEVCp8QH8LheGvltqqS1edPnkGYEupbIHtd5 GbYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mPuUrJIlJbDH1FXvjHv4kD8C1vGWoHt9ZrDqXArb4Cw=; b=Ljkk9Pgq/n138BZcK6GDAL2OkZvFd6vGSrTRHIvQilktw4KwDb+OAkZlhgCekaOUDG JOVSCaKMvxtZHVfQrfYnokU50VKkkgon0qpmM+Eta7cJ+YFtiBUNu59koeUHpRRqIII6 apfdHUD5BhSVeQsOU+YbNTZgHBx5DsvYNRmQSJetekavF5paTx6JPPpVGaOH4gvq05Ok KS3KKQWH5bzRAxVhY+m0qG2MuN4xr09hDwNTttpb3xP0Zvyvmd8e2w6MI65slv1w8vrH LprdQMeoHnjuyGfBb5WHMYePOz/2aaCPlFlZG/s6wF+SaQSKEXjf6hEcgMvsLFeHmxbu H5pw== X-Gm-Message-State: AOAM532vz/qE8YimY+RYjLOKvFu4OcyVMOyPweoTbWuwbc65KzurSrr6 ItP36QStRtKzfwKnZKBR+KxOwg50opZupKShlYkj5w== X-Google-Smtp-Source: ABdhPJwzY+VqX5Gt/y/9Auo2JsStC5oI5oUZTHZfESmAgNaW9McxJUfWPEP07zIEGGG4OgRksz6mT/pPgIjCGQJHx/c= X-Received: by 2002:a19:64c:: with SMTP id 73mr32293247lfg.0.1594088452637; Mon, 06 Jul 2020 19:20:52 -0700 (PDT) MIME-Version: 1.0 References: <20200706154449.3828193-1-alainm@chromium.org> In-Reply-To: <20200706154449.3828193-1-alainm@chromium.org> From: Alain Michaud Date: Mon, 6 Jul 2020 22:20:41 -0400 Message-ID: Subject: Re: [PATCH v3] Bluetooth: le_simult_central_peripheral experimental feature To: Alain Michaud Cc: BlueZ Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: A10CA400FA X-Rspamd-UID: 13de39 Here is the userspace change associated with this change: https://patchwork.kernel.org/project/bluetooth/list/?series=313771 On Mon, Jul 6, 2020 at 11:44 AM Alain Michaud wrote: > > This patch adds an le_simult_central_peripheral features which allows a > clients to determine if the controller is able to support peripheral and > central connections separately and at the same time. > > Signed-off-by: Alain Michaud > --- > > Changes in v3: > - Back to the original design of V1 and integrated Marcel's feedback. > > Changes in v2: > - Slight change of design based on offline feedback > > net/bluetooth/mgmt.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > index 5e9b9728eeac..b34e6f3c07ec 100644 > --- a/net/bluetooth/mgmt.c > +++ b/net/bluetooth/mgmt.c > @@ -3753,12 +3753,19 @@ static const u8 debug_uuid[16] = { > }; > #endif > > +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ > +static const u8 le_simult_central_peripheral[16] = { > + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, > + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > +}; > + > static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > void *data, u16 data_len) > { > - char buf[42]; > + char buf[44]; > struct mgmt_rp_read_exp_features_info *rp = (void *)buf; > u16 idx = 0; > + u32 flags; > > bt_dev_dbg(hdev, "sock %p", sk); > > @@ -3766,7 +3773,7 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > > #ifdef CONFIG_BT_FEATURE_DEBUG > if (!hdev) { > - u32 flags = bt_dbg_get() ? BIT(0) : 0; > + flags = bt_dbg_get() ? BIT(0) : 0; > > memcpy(rp->features[idx].uuid, debug_uuid, 16); > rp->features[idx].flags = cpu_to_le32(flags); > @@ -3774,6 +3781,19 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + flags = 0; > + memcpy(rp->features[idx].uuid, le_simult_central_peripheral, > + sizeof(le_simult_central_peripheral)); > + > + if (hdev && test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && > + (hdev->le_states[4] & 0x08) && /* Central */ > + (hdev->le_states[4] & 0x40) && /* Peripheral */ > + (hdev->le_states[3] & 0x10) /* Simultaneous */) > + flags |= BIT(0); > + > + rp->features[idx].flags = cpu_to_le32(flags); > + idx++; > + > rp->feature_count = cpu_to_le16(idx); > > /* After reading the experimental features information, enable > -- > 2.27.0.212.ge8ba1cc988-goog > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QBpVLXHcA18RagAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 04:22:41 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8GPGK3HcA19t3wEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 04:22:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A7BD0A1FE5; Tue, 7 Jul 2020 04:22:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728126AbgGGCWY (ORCPT + 1 other); Mon, 6 Jul 2020 22:22:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727976AbgGGCWX (ORCPT ); Mon, 6 Jul 2020 22:22:23 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59A03C061755 for ; Mon, 6 Jul 2020 19:22:23 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id t25so43474191lji.12 for ; Mon, 06 Jul 2020 19:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nSfJBFlbue3JcAbTaRtLjXjgfXtlC/lcr7gFauiCb5E=; b=OtP26L7Uxd23GhSRUM10aexhT6XbVkI6DmxC530QzW8UHH4P3ClEjO1gtUaX08nSxV ib+yJg5OuVYJSlXV90Iqk2KMnt/jJa4IVdbo9H7AiHR3GHqjY/xi8zMwPMNcTd8Z2Pjc exdp8mLxeuRY9rH7b4Lq69NKexWWgXG/OSLbseP084NBRKVvompJaANDiZo0ltdiUEHF EW6vHrzNAaGv18knRg7QM8azO67yPTF5sMHzUMHKe33C5/IakLUE/C8CxeDabOcj9GUR ber3ngl/03CUhMmDgJMjrTWkawkxWkfgAM+cuR2kvOgm+Z3DPf9xZTAEnQe8wUaze6k8 TLAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nSfJBFlbue3JcAbTaRtLjXjgfXtlC/lcr7gFauiCb5E=; b=rPuzTM8Jh7VmqXVwo2+n0WSbGKNwQhQkchdKQZzkmmJMwotACp+QbCz0wUTifzCxxW 7piMM8sKHqtj+u8XA9psgSfX6Rcze4F46OXxioYCr0ieFXLqzzFEpc4bbQBSSUBGDRT7 Tr0QeBb4+PzfqUnk9oZDzXSX9e1E61dpvZo00loLnOdnMdSwnZCg2GX+mqFTSZvdKbh1 7zlv+bLpRjXtGKfse9tMzQo7uQ3rmTertVkTE3cv2S9WirmOXo/NlCZDpxyBu87i85mo suxudz8YqRK9f+FuOAnh2dtCkA59M6AtvWCwLZ/scbp2lq/vU9yz7ebdoAi4j66ESOhM zrJw== X-Gm-Message-State: AOAM532Tv9OMDyuKVIkin/arJ1IRd78fNq2DkrVgSPSL7yKBXeTEzOkN dcd/LbgkAScIoDhWQ6l/Erspr6H6JgfvhbFFBnwiPQ== X-Google-Smtp-Source: ABdhPJxVjah1LUVYsUEzgOhD4+Z1YyCe+esZN1hn6y2GPJON75KKwVyUNyb2x+2uEFKYzVkFrFYGwV02kru+Ya9nfGk= X-Received: by 2002:a2e:80cc:: with SMTP id r12mr23072026ljg.344.1594088541541; Mon, 06 Jul 2020 19:22:21 -0700 (PDT) MIME-Version: 1.0 References: <20200707003937.187125-1-alainm@chromium.org> In-Reply-To: <20200707003937.187125-1-alainm@chromium.org> From: Alain Michaud Date: Mon, 6 Jul 2020 22:22:09 -0400 Message-ID: Subject: Re: [PATCH v1] Bluetooth: create CONFIG_BT_DEBUG_FUNC_NAME To: Alain Michaud Cc: BlueZ , Abhishek Pandit-Subedi Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: A7BD0A1FE5 X-Rspamd-UID: 266370 This feature depends (soft dependency) on the kernel experimental feature defined in this patch: https://patchwork.kernel.org/patch/11646081/ On Mon, Jul 6, 2020 at 8:39 PM Alain Michaud wrote: > > Creates a CONFIG_BT_DEBUG_FUNC_NAME option to include function names in > debug statements. > > Unlike other platforms __func__ isn't a string literal so it cannot be > automatically concatenated by the pre-processor. As a result, the > function name is passed as a parameter to the tracing function. Since > pr_debug is a function like macro, the normal expansion of BT_PREFIX_PARAM > does not work as it gets processed within the first parameter as well, > for this reason, BT_DBG is split into two versions. > > This patch was built tested with all 4 possible combinations of > CONFIG_BT_DEBUG_FUNC_NAME and CONFIG_BT_FEATURE_DEBUG configurations. > > Signed-off-by: Alain Michaud > Reviewed-by: Abhishek Pandit-Subedi > --- > > include/net/bluetooth/bluetooth.h | 32 +++++++++++++++++++++++-------- > net/bluetooth/Kconfig | 11 +++++++++++ > 2 files changed, 35 insertions(+), 8 deletions(-) > > diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h > index 7ee8041af803..27ec8f2a7c28 100644 > --- a/include/net/bluetooth/bluetooth.h > +++ b/include/net/bluetooth/bluetooth.h > @@ -162,22 +162,37 @@ void bt_dbg_set(bool enable); > bool bt_dbg_get(void); > __printf(1, 2) > void bt_dbg(const char *fmt, ...); > +#define BT_DBG_INT bt_dbg > +#else > +#define BT_DBG_INT pr_debug > #endif > __printf(1, 2) > void bt_warn_ratelimited(const char *fmt, ...); > __printf(1, 2) > void bt_err_ratelimited(const char *fmt, ...); > > -#define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__) > -#define BT_WARN(fmt, ...) bt_warn(fmt "\n", ##__VA_ARGS__) > -#define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) > - > -#if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG) > -#define BT_DBG(fmt, ...) bt_dbg(fmt "\n", ##__VA_ARGS__) > +#if IS_ENABLED(CONFIG_BT_DEBUG_FUNC_NAMES) > +#define BT_PREFIX "%s() " > +#define BT_PREFIX_PARAM ,__func__ > +#define BT_DBG(fmt, ...) \ > + BT_DBG_INT(BT_PREFIX fmt "\n", __func__, ##__VA_ARGS__) > #else > -#define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__) > +#define BT_PREFIX > +#define BT_PREFIX_PARAM > +#define BT_DBG(fmt, ...) \ > + BT_DBG_INT(fmt "\n", ##__VA_ARGS__) > #endif > > +#define BT_INFO(fmt, ...) \ > + bt_info(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) > +#define BT_WARN(fmt, ...) \ > + bt_warn(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) > +#define BT_ERR(fmt, ...) \ > + bt_err(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) > + > +#define BT_ERR_RATELIMITED(fmt, ...) \ > + bt_err_ratelimited(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) > + > #define bt_dev_info(hdev, fmt, ...) \ > BT_INFO("%s: " fmt, (hdev)->name, ##__VA_ARGS__) > #define bt_dev_warn(hdev, fmt, ...) \ > @@ -188,7 +203,8 @@ void bt_err_ratelimited(const char *fmt, ...); > BT_DBG("%s: " fmt, (hdev)->name, ##__VA_ARGS__) > > #define bt_dev_warn_ratelimited(hdev, fmt, ...) \ > - bt_warn_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) > + bt_warn_ratelimited("%s: " BT_PREFIX fmt, (hdev)->name \ > + BT_PREFIX_PARAM, ##__VA_ARGS__) > #define bt_dev_err_ratelimited(hdev, fmt, ...) \ > bt_err_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) > > diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig > index 1d6d243cdde9..de31c682c7b0 100644 > --- a/net/bluetooth/Kconfig > +++ b/net/bluetooth/Kconfig > @@ -142,4 +142,15 @@ config BT_FEATURE_DEBUG > This provides an option to enable/disable debugging statements > at runtime via the experimental features interface. > > +config BT_DEBUG_FUNC_NAMES > + bool "Include function names in debugging statements" > + depends on BT > + default n > + help > + Provides an option to include function names in debugging > + statements. > + > + When enabled, trace statements will include the function name as a > + prefix which may help identify the source code references. > + > source "drivers/bluetooth/Kconfig" > -- > 2.27.0.212.ge8ba1cc988-goog > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eAeBCfUABF8m+QAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 06:58:29 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EANZB/UABF97pgAAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 06:58:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=mg.codeaurora.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EE8064F1AC; Tue, 7 Jul 2020 06:58:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727826AbgGGE6W (ORCPT + 1 other); Tue, 7 Jul 2020 00:58:22 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:51450 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbgGGE6W (ORCPT ); Tue, 7 Jul 2020 00:58:22 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1594097902; h=Message-ID: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=vQlGC+g6PBorvbW3VjCchVGAirpTLmSK6+Ls9tR3oXY=; b=K+SW0+Y59f/PlotoQnQUV53B2QIKupURSTetWrZLUa02VvTQsZmG7JNxdwBpxy23v72B/irf 8ux0rNEXXEgKQwAiPMvsVIncXwmQhcI318AHp/ziDx3Mucqii4lr6arIyExsXEAb3Ors+T1i +zNdBxi1T4DrvjoL0ljt8ydF2RU= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI2MTA3ZSIsICJsaW51eC1ibHVldG9vdGhAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n19.prod.us-east-1.postgun.com with SMTP id 5f0400e1d07c1358553c02f9 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 07 Jul 2020 04:58:09 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 82E12C433CA; Tue, 7 Jul 2020 04:58:08 +0000 (UTC) Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: rjliao) by smtp.codeaurora.org (Postfix) with ESMTPSA id AF5F6C433C6; Tue, 7 Jul 2020 04:58:07 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 07 Jul 2020 12:58:07 +0800 From: Rocky Liao To: linux-firmware@kernel.org Cc: linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PULL] btqca firmware 20200401 Message-ID: X-Sender: rjliao@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 19 X-Rspamd-Score: 2.98 / 15.00 / 200.00 X-Rspamd-Queue-Id: EE8064F1AC X-Rspamd-UID: 707006 Hi linux-firmware maintainers, Here's a pull request for btqca bluetooth driver. Please let me know if you have any problems. The following changes since commit 74ac3b5a7e7962cd1135ef691c72d48cb5210251: Merge https://github.com/bgodavar/qca_wcn3991 into main (2020-07-02 08:23:09 -0400) are available in the Git repository at: https://github.com/rjliao-qca/qca-btfw.git for you to fetch changes up to c4e04b49b46a3e3e4c0bf4a3007f352d09c7ae0c: ---------------------------------------------------------------- Rocky Liao (1): QCA: Update Bluetooth firmware for QCA6390 (2020-07-07 12:45:15 +0800) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0GswETMXBF+RSgEAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 08:33:23 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0HT8DjMXBF8NAwEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 08:33:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 19F01A1B61; Tue, 7 Jul 2020 08:33:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728029AbgGGGcz convert rfc822-to-8bit (ORCPT + 1 other); Tue, 7 Jul 2020 02:32:55 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:47389 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbgGGGcy (ORCPT ); Tue, 7 Jul 2020 02:32:54 -0400 Received: from [192.168.1.91] (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 08718CECE5; Tue, 7 Jul 2020 08:42:49 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v1] Bluetooth: create CONFIG_BT_DEBUG_FUNC_NAME From: Marcel Holtmann In-Reply-To: <20200707003937.187125-1-alainm@chromium.org> Date: Tue, 7 Jul 2020 08:32:22 +0200 Cc: linux-bluetooth , Abhishek Pandit-Subedi Content-Transfer-Encoding: 8BIT Message-Id: <4B0E4627-26D8-4D70-ABE9-6CB7A9E86D35@holtmann.org> References: <20200707003937.187125-1-alainm@chromium.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.47 / 15.00 / 200.00 X-Rspamd-Queue-Id: 19F01A1B61 X-Rspamd-UID: acffc6 Hi Alain, > Creates a CONFIG_BT_DEBUG_FUNC_NAME option to include function names in > debug statements. > > Unlike other platforms __func__ isn't a string literal so it cannot be > automatically concatenated by the pre-processor. As a result, the > function name is passed as a parameter to the tracing function. Since > pr_debug is a function like macro, the normal expansion of BT_PREFIX_PARAM > does not work as it gets processed within the first parameter as well, > for this reason, BT_DBG is split into two versions. > > This patch was built tested with all 4 possible combinations of > CONFIG_BT_DEBUG_FUNC_NAME and CONFIG_BT_FEATURE_DEBUG configurations. can we please limit this to FEATURE_DEBUG since dynamic debug doesn’t need it. It can switch on function name debugging on a per debug statement. And even for FEATURE_DEBUG I would rather have it optional that can be enabled when needed via the experimental feature itself. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yIeTNb0ZBF+ecgEAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 08:44:13 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ODbvM70ZBF+IZwEADc0bRg (envelope-from ); Tue, 07 Jul 2020 08:44:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 590BE51A0B; Tue, 7 Jul 2020 08:44:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726889AbgGGGoH convert rfc822-to-8bit (ORCPT + 1 other); Tue, 7 Jul 2020 02:44:07 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:43446 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbgGGGoH (ORCPT ); Tue, 7 Jul 2020 02:44:07 -0400 Received: from [192.168.1.91] (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 790BFCECE5; Tue, 7 Jul 2020 08:54:02 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v3] Bluetooth: le_simult_central_peripheral experimental feature From: Marcel Holtmann In-Reply-To: <20200706154449.3828193-1-alainm@chromium.org> Date: Tue, 7 Jul 2020 08:43:35 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <0175E6D3-8547-4633-B9A8-2AB15CE25C5B@holtmann.org> References: <20200706154449.3828193-1-alainm@chromium.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.42 / 15.00 / 200.00 X-Rspamd-Queue-Id: 590BE51A0B X-Rspamd-UID: 0bbc4d Hi Alain, > This patch adds an le_simult_central_peripheral features which allows a > clients to determine if the controller is able to support peripheral and > central connections separately and at the same time. > > Signed-off-by: Alain Michaud > --- > > Changes in v3: > - Back to the original design of V1 and integrated Marcel's feedback. > > Changes in v2: > - Slight change of design based on offline feedback > > net/bluetooth/mgmt.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > index 5e9b9728eeac..b34e6f3c07ec 100644 > --- a/net/bluetooth/mgmt.c > +++ b/net/bluetooth/mgmt.c > @@ -3753,12 +3753,19 @@ static const u8 debug_uuid[16] = { > }; > #endif > > +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ > +static const u8 le_simult_central_peripheral[16] = { > + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, > + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > +}; > + > static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > void *data, u16 data_len) > { > - char buf[42]; > + char buf[44]; > struct mgmt_rp_read_exp_features_info *rp = (void *)buf; > u16 idx = 0; > + u32 flags; > > bt_dev_dbg(hdev, "sock %p", sk); > > @@ -3766,7 +3773,7 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > > #ifdef CONFIG_BT_FEATURE_DEBUG > if (!hdev) { > - u32 flags = bt_dbg_get() ? BIT(0) : 0; > + flags = bt_dbg_get() ? BIT(0) : 0; I was trying to contain the used variables in the scope here so that we don’t get funny kernel warnings about unused or uninitialized variables when options are not selected and we eventually add more here. > > memcpy(rp->features[idx].uuid, debug_uuid, 16); > rp->features[idx].flags = cpu_to_le32(flags); > @@ -3774,6 +3781,19 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + flags = 0; > + memcpy(rp->features[idx].uuid, le_simult_central_peripheral, > + sizeof(le_simult_central_peripheral)); > + > + if (hdev && test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && > + (hdev->le_states[4] & 0x08) && /* Central */ > + (hdev->le_states[4] & 0x40) && /* Peripheral */ > + (hdev->le_states[3] & 0x10) /* Simultaneous */) > + flags |= BIT(0); > + > + rp->features[idx].flags = cpu_to_le32(flags); > + idx++; > + > rp->feature_count = cpu_to_le16(idx); You do actually need to wrap this in if (hdev) { } so that a) this looks cleanly and b) this is only reported when the is provided. The experimental feature command is special since it can be used per hdev or globally. > > /* After reading the experimental features information, enable > -- > 2.27.0.212.ge8ba1cc988-goog > Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OO+eKt1BBF/aggAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 11:35:25 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 6L7QKN1BBF8o7AEADc0bRg (envelope-from ); Tue, 07 Jul 2020 11:35:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 21C74A27C6; Tue, 7 Jul 2020 11:35:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727791AbgGGJfB (ORCPT + 1 other); Tue, 7 Jul 2020 05:35:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbgGGJfA (ORCPT ); Tue, 7 Jul 2020 05:35:00 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E1E3C061755 for ; Tue, 7 Jul 2020 02:35:00 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id k6so44430719wrn.3 for ; Tue, 07 Jul 2020 02:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uA8EhsPuwTAmoWTLY0mx1vOJ7jGJwFLaF3KRVuoae/s=; b=p4SZRfJQlGDxKqQkwezbwPHU1pvNMWIVhAdwqcIYSCYZ1vw8XmEK3pdcQrhfjKmG4H yFCCdpdBwkRVBsqZNgf6FGvl/49iI7GZKJjiH+GTeCeDsfP5UhUH7IUXk0elWt8EwkI8 8Z5CJaYqXUYRE/TOrfUcwOxDf3r9vLRGw/W+9eg3yKzoe/VNhtoRkm+YXqDnK8Hw3xrH GqZbIGNCMZH71JYU3xZnlmdDyYEKGxV7Fja6RJ/oAv+xk5DsdvIArQXLtwMMW+eTR6iN Mlgk+stKN0iZ1vj0/fOvOoihgDuXWagMuPXNXANxH2WNGVWsVSgKk7MrTEA/8fC1HIl/ Wxkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uA8EhsPuwTAmoWTLY0mx1vOJ7jGJwFLaF3KRVuoae/s=; b=nXYYc9PM/K7YQQortp1V9rW/p8oQSqLIv/x1Ofz2K22FZCOA5DtgkIXZUT22OGHuab VgeAtvcR0POf5D+BEA+AyiJX/pgMuqyTkvAoefn1qbB183Jah9T0/5BmbtYSw8pRJjDW pxhI7BtjKGcyHZXRIJrbNCDCngKFZNDoXezmcbr48AFUBOtELEL1XxsP+jEzJJv2EM9/ cnrW5N1zPfqP1/anlxOXWuWC09o2Y/9nQy7zMFDS40aGjl9V9L5tIkWSIk/2vBFXXDC8 2TZyPdaMkjxPL52tqSGgPLC1Ky94odEXp62AGx7Pk0+DgtA3HA5hy2hs/VbS+Uja4U3T 04mg== X-Gm-Message-State: AOAM530lS70KihDx5ZUtJoX978SG5YMux4dRWBvktT4fr3b9kUivx7Em HTWa7ZrTPbmaEeCfkbsq0Kei70kaZqPj2vBo+1YiV4Ol X-Google-Smtp-Source: ABdhPJwZ4t/cKR4jQ4ufTUeYIKAjlG9WXvyHxO8SCcLKnYdEw37u4KMNYIVPA8XFcPNa0eioj0JVF2f8KydpkeXmm/4= X-Received: by 2002:a5d:46c7:: with SMTP id g7mr52696015wrs.365.1594114498536; Tue, 07 Jul 2020 02:34:58 -0700 (PDT) MIME-Version: 1.0 References: <20200627235318.Bluez.v2.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> <20200627235318.Bluez.v2.2.I16f38fd33617bbbf84d144605861b8391605a761@changeid> In-Reply-To: <20200627235318.Bluez.v2.2.I16f38fd33617bbbf84d144605861b8391605a761@changeid> From: Archie Pusaka Date: Tue, 7 Jul 2020 17:34:47 +0800 Message-ID: Subject: Re: [Bluez PATCH v2 2/2] input: Remove bonding info when receiving virtual cable unplug To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 21C74A27C6 X-Rspamd-UID: 57af8d Hi Bluez maintainers, Could you take a look at this patch? Thanks, Archie On Sat, 27 Jun 2020 at 23:54, Archie Pusaka wrote: > > From: Archie Pusaka > > From Bluetooth HID Profile 1.1 Spec: If a Virtual Cable is > unplugged via a HID control Virtual Unplug command, then both the > Bluetooth HID device and Bluetooth HID Host shall destroy or > invalidate all Bluetooth bonding and Virtual Cable information > that was previously stored in persistent memory for the respective > Virtually Cabled devices and hosts. > > This patch removes the bonding information upon receiving and/or > sending a "virtual cable unplug". > > Reviewed-by: Alain Michaud > --- > > Changes in v2: > - Properly pass the correct argument to device_remove_bonding > - rename unbond_on_disconnect to virtual_cable_unplug > > profiles/input/device.c | 23 ++++++++++++++++++++++- > 1 file changed, 22 insertions(+), 1 deletion(-) > > diff --git a/profiles/input/device.c b/profiles/input/device.c > index d3724ed54..a76ab90bd 100644 > --- a/profiles/input/device.c > +++ b/profiles/input/device.c > @@ -88,6 +88,7 @@ struct input_device { > uint8_t report_req_pending; > guint report_req_timer; > uint32_t report_rsp_id; > + bool virtual_cable_unplug; > }; > > static int idle_timeout = 0; > @@ -148,6 +149,14 @@ static void input_device_free(struct input_device *idev) > g_free(idev); > } > > +static void virtual_cable_unplug(struct input_device *idev) > +{ > + device_remove_bonding(idev->device, > + btd_device_get_bdaddr_type(idev->device)); > + > + idev->virtual_cable_unplug = false; > +} > + > static bool hidp_send_message(GIOChannel *chan, uint8_t hdr, > const uint8_t *data, size_t size) > { > @@ -188,6 +197,9 @@ static bool hidp_send_message(GIOChannel *chan, uint8_t hdr, > static bool hidp_send_ctrl_message(struct input_device *idev, uint8_t hdr, > const uint8_t *data, size_t size) > { > + if (hdr == (HIDP_TRANS_HID_CONTROL | HIDP_CTRL_VIRTUAL_CABLE_UNPLUG)) > + idev->virtual_cable_unplug = true; > + > return hidp_send_message(idev->ctrl_io, hdr, data, size); > } > > @@ -344,6 +356,9 @@ static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data > /* Enter the auto-reconnect mode if needed */ > input_device_enter_reconnect_mode(idev); > > + if (!idev->ctrl_io && idev->virtual_cable_unplug) > + virtual_cable_unplug(idev); > + > return FALSE; > } > > @@ -408,7 +423,7 @@ static void hidp_recv_ctrl_hid_control(struct input_device *idev, uint8_t param) > DBG(""); > > if (param == HIDP_CTRL_VIRTUAL_CABLE_UNPLUG) > - connection_disconnect(idev, 0); > + connection_disconnect(idev, (1 << HIDP_VIRTUAL_CABLE_UNPLUG)); > } > > static void hidp_recv_ctrl_data(struct input_device *idev, uint8_t param, > @@ -532,6 +547,9 @@ static gboolean ctrl_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data > if (idev->intr_io && !(cond & G_IO_NVAL)) > g_io_channel_shutdown(idev->intr_io, TRUE, NULL); > > + if (!idev->intr_io && idev->virtual_cable_unplug) > + virtual_cable_unplug(idev); > + > return FALSE; > } > > @@ -1042,6 +1060,9 @@ static int connection_disconnect(struct input_device *idev, uint32_t flags) > shutdown(sock, SHUT_WR); > } > > + if (flags & (1 << HIDP_VIRTUAL_CABLE_UNPLUG)) > + idev->virtual_cable_unplug = true; > + > if (idev->uhid) > return 0; > else > -- > 2.27.0.212.ge8ba1cc988-goog > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6Fc5CbCBBF+1LgEAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 16:07:44 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cINBB7CBBF8QNAEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 16:07:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2D52FA2C65; Tue, 7 Jul 2020 16:07:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727044AbgGGOHh (ORCPT + 1 other); Tue, 7 Jul 2020 10:07:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726805AbgGGOHh (ORCPT ); Tue, 7 Jul 2020 10:07:37 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0CEAC061755 for ; Tue, 7 Jul 2020 07:07:36 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id q4so14321584lji.2 for ; Tue, 07 Jul 2020 07:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=gDREQy+iX7HB0ezoJS82NhBL+1QVhEDLJwBBM3IlKVU=; b=E751pbe/T/QDenU9q3rnAZg2lLouy6lQHJuiFlRqxv76ijGVdnbxydwpRNouqqBz0v 8+jbzOHLTLJD4R0SSx/DyOZ6qh+A31chBilwZDoCXKhaZQIj1ORQBP9x8fbSHdhI7tRJ Hz7C540+BqiEpvZh3td9fUB2MH+beBQt8UPfpNaUtC5Jn/9ZRofHNdxZH0b7IELK7cv5 wyTKdqs8ME9e9i91NXE05GB9OPYgTgNB73Bgx2SM3rB8qYN2i8p/NOCsaceOqsmXiJJK hgDhMJpKHKEe7Kj6eLMQ9DSdAXz2CUSSfXbk9hh3yr4pUQUpFW7eoUUmOHt3ZHbli6E7 NeUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=gDREQy+iX7HB0ezoJS82NhBL+1QVhEDLJwBBM3IlKVU=; b=YfZFDZEuLMcS/6Vg67Pxko65IfqCF431ykryoiJ9dyf9s7udUBtobsnzoU9vbsOFF/ +tcnNiONXMqUhnVt6fG2lyR/8FqhnZhn9JaxsOY4ZJtivnpi7NbICdl4eYLPvhgM/yth rMWvzz7LMZ80UTFex4jQmgFkXfmcFeOXDzSZ+1JxBKhXA5awI7D4bu17JNqC/1x7BXEv uqFon1S0oaIiWa6KKk+pmILtlsJMlqZJeecdJFfIPkWmBz0WaKPdJlSyPt+hzHlpQOS0 TcyYKHjo3gMfMAQQY4oRqqKJYJniv3cJs+6MnV0NUBvYz0dZ1aBw7x/p/G+VSn/r14Qv KlUQ== X-Gm-Message-State: AOAM532/bVZomb5j7Tfo3FevLSmS9FcAAtE0V1t3DnGq09aav3I2J1Dz 9usolvQu7L5c+Zn/zzXr3PN1Ze3k67/A9ofI/DJ56pQXc+U= X-Google-Smtp-Source: ABdhPJzaKe5FqnlDMenR5uHO3gdltJ3BsiK6cIEE7E6p9QU2Q1NFx1IMH/AtBAL/lEYvRDGNuMHU5wIZTdjjwusjXx8= X-Received: by 2002:a2e:8684:: with SMTP id l4mr1838103lji.75.1594130855060; Tue, 07 Jul 2020 07:07:35 -0700 (PDT) MIME-Version: 1.0 References: <20200707003937.187125-1-alainm@chromium.org> <4B0E4627-26D8-4D70-ABE9-6CB7A9E86D35@holtmann.org> In-Reply-To: <4B0E4627-26D8-4D70-ABE9-6CB7A9E86D35@holtmann.org> From: Alain Michaud Date: Tue, 7 Jul 2020 10:07:23 -0400 Message-ID: Subject: Re: [PATCH v1] Bluetooth: create CONFIG_BT_DEBUG_FUNC_NAME To: Marcel Holtmann Cc: Alain Michaud , linux-bluetooth , Abhishek Pandit-Subedi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.34 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2D52FA2C65 X-Rspamd-UID: 82d33d Hi Marcel On Tue, Jul 7, 2020 at 2:32 AM Marcel Holtmann wrote: > > Hi Alain, > > > Creates a CONFIG_BT_DEBUG_FUNC_NAME option to include function names in > > debug statements. > > > > Unlike other platforms __func__ isn't a string literal so it cannot be > > automatically concatenated by the pre-processor. As a result, the > > function name is passed as a parameter to the tracing function. Since > > pr_debug is a function like macro, the normal expansion of BT_PREFIX_PA= RAM > > does not work as it gets processed within the first parameter as well, > > for this reason, BT_DBG is split into two versions. > > > > This patch was built tested with all 4 possible combinations of > > CONFIG_BT_DEBUG_FUNC_NAME and CONFIG_BT_FEATURE_DEBUG configurations. > > can we please limit this to FEATURE_DEBUG since dynamic debug doesn=E2=80= =99t need it. It can switch on function name debugging on a per debug state= ment. And even for FEATURE_DEBUG I would rather have it optional that can b= e enabled when needed via the experimental feature itself. I agree on making this dependent on FEATURE_DEBUG as it may simplify the configuration, but I don't think I like having this enabled via an experimental feature as it complicates the tracing macros quite a bit for no good reason. I don't see a scenario where someone would turn on CONFIG_DEBUG_FUNC_NAME but not want it enabled. > > Regards > > Marcel > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gOkzEgyDBF+c7wAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 16:13:32 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YBBrEAyDBF/o/QAAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 16:13:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AC94552830; Tue, 7 Jul 2020 16:13:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727989AbgGGONZ convert rfc822-to-8bit (ORCPT + 1 other); Tue, 7 Jul 2020 10:13:25 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:45755 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726900AbgGGONZ (ORCPT ); Tue, 7 Jul 2020 10:13:25 -0400 Received: from [192.168.1.91] (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id C68AFCECEC; Tue, 7 Jul 2020 16:23:19 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v1] Bluetooth: create CONFIG_BT_DEBUG_FUNC_NAME From: Marcel Holtmann In-Reply-To: Date: Tue, 7 Jul 2020 16:12:52 +0200 Cc: Alain Michaud , linux-bluetooth , Abhishek Pandit-Subedi Content-Transfer-Encoding: 8BIT Message-Id: <67720527-0A53-4B5B-A1CB-D53AE162A82C@holtmann.org> References: <20200707003937.187125-1-alainm@chromium.org> <4B0E4627-26D8-4D70-ABE9-6CB7A9E86D35@holtmann.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 21 X-Rspamd-Score: 3.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: AC94552830 X-Rspamd-UID: fb5a9d Hi Alain, >>> Creates a CONFIG_BT_DEBUG_FUNC_NAME option to include function names in >>> debug statements. >>> >>> Unlike other platforms __func__ isn't a string literal so it cannot be >>> automatically concatenated by the pre-processor. As a result, the >>> function name is passed as a parameter to the tracing function. Since >>> pr_debug is a function like macro, the normal expansion of BT_PREFIX_PARAM >>> does not work as it gets processed within the first parameter as well, >>> for this reason, BT_DBG is split into two versions. >>> >>> This patch was built tested with all 4 possible combinations of >>> CONFIG_BT_DEBUG_FUNC_NAME and CONFIG_BT_FEATURE_DEBUG configurations. >> >> can we please limit this to FEATURE_DEBUG since dynamic debug doesn’t need it. It can switch on function name debugging on a per debug statement. And even for FEATURE_DEBUG I would rather have it optional that can be enabled when needed via the experimental feature itself. > I agree on making this dependent on FEATURE_DEBUG as it may simplify > the configuration, but I don't think I like having this enabled via an > experimental feature as it complicates the tracing macros quite a bit > for no good reason. I don't see a scenario where someone would turn > on CONFIG_DEBUG_FUNC_NAME but not want it enabled. I left the Set Experimental Feature command flexible and so you could add an extra flags/settings bitmask additionally to choose how to format the debug strings. Similar to what dynamic debug is doing. An alternative is that you have two debug features, one for with function names and one without. If you turn on both, then the one with function names supersedes. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iE6fEcmDBF+c7wAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 16:16:41 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 0CQtEMmDBF/MbAAAlScrYA (envelope-from ); Tue, 07 Jul 2020 16:16:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8C7F6A1FBD; Tue, 7 Jul 2020 16:16:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728025AbgGGOQe (ORCPT + 1 other); Tue, 7 Jul 2020 10:16:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726805AbgGGOQc (ORCPT ); Tue, 7 Jul 2020 10:16:32 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 631ABC061755 for ; Tue, 7 Jul 2020 07:16:32 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id j186so620034vsd.10 for ; Tue, 07 Jul 2020 07:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bcZ1dutZuBclgpEZqW6bnbWQfRovaM1ud/8ymGPFI7Y=; b=aK+IhfctraYMsnU/Nltw8ObMooaC22oTValrTKfAF4xzhO6KGTlIxyYASAUPE7t7LC DtVQknu8Hjx1BWvtJp5e5YaVKXFekKlRHF4fvanAlHVt7N1hQgiurpyKySG9+d4r9Ffr CiOM7RT23IiT5h5GJrood7neeAPMmVZD+NkzA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bcZ1dutZuBclgpEZqW6bnbWQfRovaM1ud/8ymGPFI7Y=; b=Wd7OhrHDuDHwmkZIrrr1VEt272sIR4YvNp+BhZApkkyPXcKj3fkJUAzGeX0hxujc0G vDFxYfsMXRsawp2rQkd+p/km74np+1l/32jWMTbCoBJ1LAUGxri1XJKhnWA3wmhtDrN1 76HmE5YtIIkmhpw4xx/5tau6Y7UDkLDY6EztOuR2MrClRLpVnbMSln3HzYD23MB6d4Cy bHw/tDf7lxIIN1O1DhzTYww7Qzu+98nY7VFFHqPAqV4THe6i/mzECuiXzB+C+9x9kn0U TD6k9l3YTiVUqbVTsT3gEuYx4KcSpmxum9wm/X81IZxff88QUTqgq+EtbJKPDE0xmxtO vBxA== X-Gm-Message-State: AOAM533XclUHftVv4YRaxb0BnUhVzRrI5/GPkLkdK7zaAfK/0wkBG2yg r9+sAqZi9bSiesrj4pvvefejonMULh0= X-Google-Smtp-Source: ABdhPJyek+qEUiWchwWgIA89ng+r6gQDIX7p74cKG/Uf8F03okltt6BgEpM+zzPO6QZvfEeoN2UypA== X-Received: by 2002:a67:8084:: with SMTP id b126mr14281534vsd.163.1594131391277; Tue, 07 Jul 2020 07:16:31 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id 140sm111811vkx.20.2020.07.07.07.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 07:16:30 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud , Archie Pusaka Subject: [PATCH v2] Bluetooth: create CONFIG_BT_DEBUG_FEATURE_FUNC_NAME Date: Tue, 7 Jul 2020 14:16:28 +0000 Message-Id: <20200707141628.368748-1-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8C7F6A1FBD X-Rspamd-UID: 774efc Creates a CONFIG_BT_DEBUG_FEATURE_FUNC_NAME option to include function names in debug statements. Unlike other platforms __func__ isn't a string literal so it cannot be automatically concatenated by the pre-processor. As a result, the function name is passed as a parameter to the tracing function. Since pr_debug is a function like macro, the normal expansion of BT_PREFIX_PARAM does not work as it gets processed within the first parameter as well, for this reason, BT_DBG is split into two versions. This patch was built tested with all 4 possible combinations of CONFIG_BT_DEBUG_FUNC_NAME and CONFIG_BT_FEATURE_DEBUG configurations. Signed-off-by: Alain Michaud Reviewed-by: Archie Pusaka --- Changes in v2: - Making CONFIG_BT_DEBUG_FEATURE_FUNC_NAME dependent on CONFIG_BT_DEBUG_FEATURE include/net/bluetooth/bluetooth.h | 32 +++++++++++++++++++++++-------- net/bluetooth/Kconfig | 11 +++++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 7ee8041af803..8506dd268d4b 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -162,22 +162,37 @@ void bt_dbg_set(bool enable); bool bt_dbg_get(void); __printf(1, 2) void bt_dbg(const char *fmt, ...); +#define BT_DBG_INT bt_dbg +#else +#define BT_DBG_INT pr_debug #endif __printf(1, 2) void bt_warn_ratelimited(const char *fmt, ...); __printf(1, 2) void bt_err_ratelimited(const char *fmt, ...); -#define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__) -#define BT_WARN(fmt, ...) bt_warn(fmt "\n", ##__VA_ARGS__) -#define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) - -#if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG) -#define BT_DBG(fmt, ...) bt_dbg(fmt "\n", ##__VA_ARGS__) +#if IS_ENABLED(BT_FEATURE_DEBUG_FUNC_NAMES) +#define BT_PREFIX "%s() " +#define BT_PREFIX_PARAM ,__func__ +#define BT_DBG(fmt, ...) \ + BT_DBG_INT(BT_PREFIX fmt "\n", __func__, ##__VA_ARGS__) #else -#define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__) +#define BT_PREFIX +#define BT_PREFIX_PARAM +#define BT_DBG(fmt, ...) \ + BT_DBG_INT(fmt "\n", ##__VA_ARGS__) #endif +#define BT_INFO(fmt, ...) \ + bt_info(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) +#define BT_WARN(fmt, ...) \ + bt_warn(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) +#define BT_ERR(fmt, ...) \ + bt_err(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) + +#define BT_ERR_RATELIMITED(fmt, ...) \ + bt_err_ratelimited(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) + #define bt_dev_info(hdev, fmt, ...) \ BT_INFO("%s: " fmt, (hdev)->name, ##__VA_ARGS__) #define bt_dev_warn(hdev, fmt, ...) \ @@ -188,7 +203,8 @@ void bt_err_ratelimited(const char *fmt, ...); BT_DBG("%s: " fmt, (hdev)->name, ##__VA_ARGS__) #define bt_dev_warn_ratelimited(hdev, fmt, ...) \ - bt_warn_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + bt_warn_ratelimited("%s: " BT_PREFIX fmt, (hdev)->name \ + BT_PREFIX_PARAM, ##__VA_ARGS__) #define bt_dev_err_ratelimited(hdev, fmt, ...) \ bt_err_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index 1d6d243cdde9..ccbf762053f1 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -142,4 +142,15 @@ config BT_FEATURE_DEBUG This provides an option to enable/disable debugging statements at runtime via the experimental features interface. +config BT_FEATURE_DEBUG_FUNC_NAMES + bool "Include function names in debugging statements" + depends on BT_FEATURE_DEBUG + default n + help + Provides an option to include function names in debugging + statements. + + When enabled, trace statements will include the function name as a + prefix which may help identify the source code references. + source "drivers/bluetooth/Kconfig" -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wJNsK/2FBF+1LgEAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 16:26:05 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +KLqKf2FBF8UEwEADc0bRg (envelope-from ); Tue, 07 Jul 2020 16:26:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4093EA2B61; Tue, 7 Jul 2020 16:26:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727951AbgGGOZ7 (ORCPT + 1 other); Tue, 7 Jul 2020 10:25:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727090AbgGGOZ7 (ORCPT ); Tue, 7 Jul 2020 10:25:59 -0400 Received: from mail-vk1-xa42.google.com (mail-vk1-xa42.google.com [IPv6:2607:f8b0:4864:20::a42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BD7DC061755 for ; Tue, 7 Jul 2020 07:25:59 -0700 (PDT) Received: by mail-vk1-xa42.google.com with SMTP id c11so4368918vkn.11 for ; Tue, 07 Jul 2020 07:25:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VnZmo5aG+HFBUgW4//dN6Ikyqu1siCQtSkjWOi1Ga3M=; b=PXHSe2o5AnxQyAW4UCumaLJKIam4lZWtyLZ4UTd2M+uCT+gHYhXezn1unoor3k1C9i Zfgl2ieFWcWFDiKr2Fi3ASvifvmq4y0JLH0n8nwOw3zlj3/hQSK+ohtQe+iVCHxqzM4N gJ6Jv0L91FFMvnY2lT6cRiV2Zi70pqOhAaHL8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VnZmo5aG+HFBUgW4//dN6Ikyqu1siCQtSkjWOi1Ga3M=; b=T9zBBF472fGYVJxauHnDIXlCzeCWV30ePA10YGEIpsu9kiKm1WT1aw0HBnX7dSsxRs 79p7CsNpFxO0dPZXHkpyZHhBXviVAH4+CHPt5hDD3LfM133IhmBqXB8cJ8zHEMTKjih6 kLlpmtkx9VwAG7meVkPhTzQua7DbgezGuQaHlD8UaoCclEBEnZU8c0Phfv6fWf/cpuln 7NX4X46Hsd5V7PdRwVocSKDOyWD/igprf0erPjuRxD3hdiWImRPMcJkp1iTOa/0kNEJL INkS/k3Om3Y5gSDc2J7TmUeC3DLOO+o72uuEWKbj+kmNf/JTnmW7m8LyU2o109AcuaMc yPPQ== X-Gm-Message-State: AOAM531MJ/1WyVMJn2RDhDBKxHluq+3orbnH7zQEu80+/TiaHEMFQEwa ZIzW5cFB8tHeHHn9OdPOypY75zLcV0c= X-Google-Smtp-Source: ABdhPJxfI9Vq6m0Yt5DXVZfKb0xVna61RaM+8hRmvZwEcfK2Q6wY+q2zBYV7LjZcZ7ILE2ghxl3x9A== X-Received: by 2002:a1f:7dc6:: with SMTP id y189mr25600159vkc.57.1594131957921; Tue, 07 Jul 2020 07:25:57 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id p2sm5104876uap.3.2020.07.07.07.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 07:25:57 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud Subject: [PATCH v4] Bluetooth: le_simult_central_peripheral experimental feature Date: Tue, 7 Jul 2020 14:25:55 +0000 Message-Id: <20200707142555.397598-1-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 5 X-Rspamd-Score: 0.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4093EA2B61 X-Rspamd-UID: c3b2f2 This patch adds an le_simult_central_peripheral features which allows a clients to determine if the controller is able to support peripheral and central connections separately and at the same time. Signed-off-by: Alain Michaud --- Changes in v4: - Wrapping the feature around an if (hdev) per Marcel's feedback. Changes in v3: - Back to the original design of V1 and integrated Marcel's feedback. Changes in v2: - Slight change of design based on offline feedback net/bluetooth/mgmt.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5e9b9728eeac..18a7ae9cb3b2 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3753,12 +3753,19 @@ static const u8 debug_uuid[16] = { }; #endif +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ +static const u8 le_simult_central_peripheral[16] = { + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, +}; + static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { - char buf[42]; + char buf[44]; struct mgmt_rp_read_exp_features_info *rp = (void *)buf; u16 idx = 0; + u32 flags; bt_dev_dbg(hdev, "sock %p", sk); @@ -3766,7 +3773,7 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, #ifdef CONFIG_BT_FEATURE_DEBUG if (!hdev) { - u32 flags = bt_dbg_get() ? BIT(0) : 0; + flags = bt_dbg_get() ? BIT(0) : 0; memcpy(rp->features[idx].uuid, debug_uuid, 16); rp->features[idx].flags = cpu_to_le32(flags); @@ -3774,6 +3781,21 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, } #endif + if (hdev) { + flags = 0; + memcpy(rp->features[idx].uuid, le_simult_central_peripheral, + sizeof(le_simult_central_peripheral)); + + if (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && + (hdev->le_states[4] & 0x08) && /* Central */ + (hdev->le_states[4] & 0x40) && /* Peripheral */ + (hdev->le_states[3] & 0x10) /* Simultaneous */) + flags |= BIT(0); + + rp->features[idx].flags = cpu_to_le32(flags); + idx++; + } + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UOtMDruGBF+c7wAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 16:29:15 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wNWeDLuGBF/MbAAAlScrYA (envelope-from ); Tue, 07 Jul 2020 16:29:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AC88AA1AA5; Tue, 7 Jul 2020 16:29:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727876AbgGGO3C (ORCPT + 1 other); Tue, 7 Jul 2020 10:29:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:58658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726805AbgGGO3C (ORCPT ); Tue, 7 Jul 2020 10:29:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D7AAA2073E; Tue, 7 Jul 2020 14:29:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594132141; bh=SeXjnrv0KQvcd5JrSwJuK4Z3XaoksQu7R84+qAENwuw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=P4FBXdVCCTFVLNly8/ClwjMiwbxZo2+1v2fWs/GeevPXQR9aB6PotkQGnK9uDtI8n Pj4Nw9OWHPnEpZtqW43oBirhBGSOHdjg+NHVJHuuJMvdG0gsH5QAiw7MASezJfgq7Q J0CRRFVkt+M1awRqGwq2cUUTDo6vkfeMFo/+qWAo= Date: Tue, 7 Jul 2020 16:28:59 +0200 From: Greg Kroah-Hartman To: Abhishek Pandit-Subedi Cc: linux-pm@vger.kernel.org, linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, rafael.j.wysocki@intel.com, swboyd@chromium.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: Re: [PATCH v2 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove Message-ID: <20200707142859.GB55434@kroah.com> References: <20200706210717.1210639-1-abhishekpandit@chromium.org> <20200706140715.v2.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200706140715.v2.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: AC88AA1AA5 X-Rspamd-UID: 7c2f78 On Mon, Jul 06, 2020 at 02:07:17PM -0700, Abhishek Pandit-Subedi wrote: > Udev rules that depend on the power/wakeup attribute don't get triggered > correctly if device_set_wakeup_capable is called after the device is > created. This can happen for several reasons (driver sets wakeup after > device is created, wakeup is changed on parent device, etc) and it seems > reasonable to emit a changed event when adding or removing attributes on > the device. > > Signed-off-by: Abhishek Pandit-Subedi > --- > > Changes in v2: > - Add newline at end of bt_dev_err > > drivers/base/power/sysfs.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c > index 24d25cf8ab1487..d57e8e7f175ebf 100644 > --- a/drivers/base/power/sysfs.c > +++ b/drivers/base/power/sysfs.c > @@ -1,6 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0 > /* sysfs entries for device PM */ > #include > +#include > #include > #include > #include > @@ -739,12 +740,30 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) > > int wakeup_sysfs_add(struct device *dev) > { > - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > + > + if (!ret) { > + int tmp = kobject_uevent(&dev->kobj, KOBJ_CHANGE); > + > + if (tmp) > + dev_err(dev, > + "Error in uevent for wakeup_sysfs_add: %d\n", > + tmp); > + } > + > + return ret; > } Shouldn't the above function look like this instead to be simpler: int wakeup_sysfs_add(struct device *dev) { int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); if (ret) return ret; return kobject_uevent(&dev->kobj, KOBJ_CHANGE); } > > void wakeup_sysfs_remove(struct device *dev) > { > + int tmp; Use 'ret' like the above function had, to be consistent. > + > sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); > + > + tmp = kobject_uevent(&dev->kobj, KOBJ_CHANGE); > + if (tmp) > + dev_err(dev, "Error in uevent for wakeup_sysfs_remove: %d\n", nit, use __func__ to describe a function name, if you really want it. Why do you need to send a message for this error, will that really ever happen? thanks, greg k-h Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KHNnOUubBF/vvwEAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 17:56:59 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 6DOiN0ubBF8OlQEADc0bRg (envelope-from ); Tue, 07 Jul 2020 17:56:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9983B529FF; Tue, 7 Jul 2020 17:56:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730140AbgGGPbc (ORCPT + 1 other); Tue, 7 Jul 2020 11:31:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729991AbgGGPba (ORCPT ); Tue, 7 Jul 2020 11:31:30 -0400 Received: from mail-vk1-xa41.google.com (mail-vk1-xa41.google.com [IPv6:2607:f8b0:4864:20::a41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E85D8C061755 for ; Tue, 7 Jul 2020 08:31:29 -0700 (PDT) Received: by mail-vk1-xa41.google.com with SMTP id m21so8207359vkp.1 for ; Tue, 07 Jul 2020 08:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=k9pD5UhiE599Tk9wmQP354KMod/Tb87VcByMMuwvg3k=; b=G+VWkqkqtjaLmPcbE4Vr+ciMMRNHr+VCxIoF6KeYJNsyLUH8ifsFw42bsVUuCQcL2v 4h8B6RVOb0A7JHYxkMMPFot6aNEHIX4sO1KFmTN9HVLhhirhuN/5M7I9phPJxLAU7aez 9P7ONjtIUTLRxZSOQviFEN8aNFPBqxVoZEhGU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=k9pD5UhiE599Tk9wmQP354KMod/Tb87VcByMMuwvg3k=; b=bWY+E7B+9VmgRHjT7rIADQlLHKvGwOsSLSeexb2JhPPG22c0y0bESME9W+9UhcDhI5 /knTs7M7pQ/Nu6s5PUaybvq2uxFxpJmsrere1cvg7CDIz7+iF2n9NslaMzPgSp+o0eus RGjl8gIxmfW4KKPLb3+pJoV8iau2bMpAoN7XB2C2856riDR/33D/wQTSMy2pLO6jqDdh IXyre2C1gUOe9IFxlSiQRN1DYrSYAtTJmEafIzDmXusb0lI4+VGVcbw3djuoboL2w8j0 sqjaKz52CQZN4qB/j1q31W9zTJspYw5mrJiTJS8I34V1Bnwcym6aQ2OMOuVMvCs7uYUg YalA== X-Gm-Message-State: AOAM533x07Uvkpq4JzWDTPzbpZpdLWW1sYOGZpsS0F/gFWcFtMRtHAjA rLFvSwde62Usv/gcgsQsK/Prap0SNNbqp43qB4vKOA== X-Google-Smtp-Source: ABdhPJzywIHzvHEbshbYh1BPf/R2VSON3B3el7elCV5+s8tTIaZ0pNfM6hRiiIO9NHAG6kQxEZ1i9zEbDrKxhAAT9zg= X-Received: by 2002:a1f:418f:: with SMTP id o137mr37478018vka.25.1594135888939; Tue, 07 Jul 2020 08:31:28 -0700 (PDT) MIME-Version: 1.0 References: <20200706210717.1210639-1-abhishekpandit@chromium.org> <20200706140715.v2.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> <20200707142859.GB55434@kroah.com> In-Reply-To: <20200707142859.GB55434@kroah.com> From: Abhishek Pandit-Subedi Date: Tue, 7 Jul 2020 08:31:18 -0700 Message-ID: Subject: Re: [PATCH v2 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove To: Greg Kroah-Hartman Cc: Linux PM , Bluez mailing list , ChromeOS Bluetooth Upstreaming , rafael.j.wysocki@intel.com, Stephen Boyd , "Rafael J. Wysocki" , LKML , Len Brown , Pavel Machek Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9983B529FF X-Rspamd-UID: 777734 Hi Greg, On Tue, Jul 7, 2020 at 7:29 AM Greg Kroah-Hartman wrote: > > On Mon, Jul 06, 2020 at 02:07:17PM -0700, Abhishek Pandit-Subedi wrote: > > Udev rules that depend on the power/wakeup attribute don't get triggered > > correctly if device_set_wakeup_capable is called after the device is > > created. This can happen for several reasons (driver sets wakeup after > > device is created, wakeup is changed on parent device, etc) and it seems > > reasonable to emit a changed event when adding or removing attributes on > > the device. > > > > Signed-off-by: Abhishek Pandit-Subedi > > --- > > > > Changes in v2: > > - Add newline at end of bt_dev_err > > > > drivers/base/power/sysfs.c | 21 ++++++++++++++++++++- > > 1 file changed, 20 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c > > index 24d25cf8ab1487..d57e8e7f175ebf 100644 > > --- a/drivers/base/power/sysfs.c > > +++ b/drivers/base/power/sysfs.c > > @@ -1,6 +1,7 @@ > > // SPDX-License-Identifier: GPL-2.0 > > /* sysfs entries for device PM */ > > #include > > +#include > > #include > > #include > > #include > > @@ -739,12 +740,30 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) > > > > int wakeup_sysfs_add(struct device *dev) > > { > > - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > > + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > > + > > + if (!ret) { > > + int tmp = kobject_uevent(&dev->kobj, KOBJ_CHANGE); > > + > > + if (tmp) > > + dev_err(dev, > > + "Error in uevent for wakeup_sysfs_add: %d\n", > > + tmp); > > + } > > + > > + return ret; > > } > > Shouldn't the above function look like this instead to be simpler: > > int wakeup_sysfs_add(struct device *dev) > { > int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > > if (ret) > return ret; > > return kobject_uevent(&dev->kobj, KOBJ_CHANGE); > } > > > > > > void wakeup_sysfs_remove(struct device *dev) > > { > > + int tmp; > > Use 'ret' like the above function had, to be consistent. > > > + > > sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); > > + > > + tmp = kobject_uevent(&dev->kobj, KOBJ_CHANGE); > > + if (tmp) > > + dev_err(dev, "Error in uevent for wakeup_sysfs_remove: %d\n", > > nit, use __func__ to describe a function name, if you really want it. > Why do you need to send a message for this error, will that really ever > happen? > Looking through kobject_uevent, it does look like the errors are unlikely to be seen (-ENOMEM, -ENOENT) and probably don't need to be logged. Will apply the suggestions above and send a v3. Thanks, Abhishek > thanks, > > greg k-h Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SMnwG8+dBF8pCQAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:07:43 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id gFmeGc+dBF9P2gAAlScrYA (envelope-from ); Tue, 07 Jul 2020 18:07:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5831E52BD6; Tue, 7 Jul 2020 18:07:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728632AbgGGPit (ORCPT + 1 other); Tue, 7 Jul 2020 11:38:49 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:58563 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728194AbgGGPis (ORCPT ); Tue, 7 Jul 2020 11:38:48 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id DF556CECED; Tue, 7 Jul 2020 17:48:42 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v1] Bluetooth: Fix kernel oops triggered by hci_adv_monitors_clear() From: Marcel Holtmann In-Reply-To: <20200629201441.v1.1.I162e3c6c4f4d963250c37733c3428329110c5989@changeid> Date: Tue, 7 Jul 2020 17:38:46 +0200 Cc: Bluetooth Kernel Mailing List , Alain Michaud , Pavel Machek , Abhishek Pandit-Subedi , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <8174F3F7-52C5-4F15-8BF5-E005B44A55C0@holtmann.org> References: <20200629201441.v1.1.I162e3c6c4f4d963250c37733c3428329110c5989@changeid> To: Miao-chen Chou X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5831E52BD6 X-Rspamd-UID: ea9018 Hi Miao-chen, > This fixes the kernel oops by removing unnecessary background scan > update from hci_adv_monitors_clear() which shouldn't invoke any work > queue. > > The following test was performed. > - Run "rmmod btusb" and verify that no kernel oops is triggered. > > Signed-off-by: Miao-chen Chou > Reviewed-by: Abhishek Pandit-Subedi > Reviewed-by: Alain Michaud > --- > > net/bluetooth/hci_core.c | 2 -- > 1 file changed, 2 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QH8LOn2eBF96HwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:10:37 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id YOsSOH2eBF9raQEADc0bRg (envelope-from ); Tue, 07 Jul 2020 18:10:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5EE89530CB; Tue, 7 Jul 2020 18:10:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728348AbgGGPqN (ORCPT + 1 other); Tue, 7 Jul 2020 11:46:13 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:43377 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727791AbgGGPqM (ORCPT ); Tue, 7 Jul 2020 11:46:12 -0400 Received: from localhost.localdomain (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 20F71CECED for ; Tue, 7 Jul 2020 17:56:07 +0200 (CEST) From: Marcel Holtmann To: linux-bluetooth@vger.kernel.org Subject: [PATCH v5] Bluetooth: le_simult_central_peripheral experimental feature Date: Tue, 7 Jul 2020 17:46:06 +0200 Message-Id: <20200707154606.52947-1-marcel@holtmann.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 2 X-Rspamd-Score: 0.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5EE89530CB X-Rspamd-UID: f95257 From: Alain Michaud This patch adds an le_simult_central_peripheral features which allows a clients to determine if the controller is able to support peripheral and central connections separately and at the same time. Signed-off-by: Alain Michaud Signed-off-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5e9b9728eeac..d29da80e38fe 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3753,12 +3753,19 @@ static const u8 debug_uuid[16] = { }; #endif +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ +static const u8 simult_central_periph_uuid[16] = { + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, +}; + static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { - char buf[42]; + char buf[44]; struct mgmt_rp_read_exp_features_info *rp = (void *)buf; u16 idx = 0; + u32 flags; bt_dev_dbg(hdev, "sock %p", sk); @@ -3766,7 +3773,7 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, #ifdef CONFIG_BT_FEATURE_DEBUG if (!hdev) { - u32 flags = bt_dbg_get() ? BIT(0) : 0; + flags = bt_dbg_get() ? BIT(0) : 0; memcpy(rp->features[idx].uuid, debug_uuid, 16); rp->features[idx].flags = cpu_to_le32(flags); @@ -3774,6 +3781,20 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, } #endif + if (hdev) { + if (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && + (hdev->le_states[4] & 0x08) && /* Central */ + (hdev->le_states[4] & 0x40) && /* Peripheral */ + (hdev->le_states[3] & 0x10)) /* Simultaneous */ + flags = BIT(0); + else + flags = 0; + + memcpy(rp->features[idx].uuid, simult_central_periph_uuid, 16); + rp->features[idx].flags = cpu_to_le32(flags); + idx++; + } + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id INBbCdmeBF/tBwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:12:09 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id IFGRB9meBF9XiQAAgupzMw (envelope-from ); Tue, 07 Jul 2020 18:12:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5211352F64; Tue, 7 Jul 2020 18:12:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729051AbgGGPrg convert rfc822-to-8bit (ORCPT + 1 other); Tue, 7 Jul 2020 11:47:36 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:47902 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728133AbgGGPrg (ORCPT ); Tue, 7 Jul 2020 11:47:36 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 1BE05CECED; Tue, 7 Jul 2020 17:57:31 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v4] Bluetooth: le_simult_central_peripheral experimental feature From: Marcel Holtmann In-Reply-To: <20200707142555.397598-1-alainm@chromium.org> Date: Tue, 7 Jul 2020 17:47:34 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20200707142555.397598-1-alainm@chromium.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 2 X-Rspamd-Score: 0.40 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5211352F64 X-Rspamd-UID: 997aa8 Hi Alain, > This patch adds an le_simult_central_peripheral features which allows a > clients to determine if the controller is able to support peripheral and > central connections separately and at the same time. > > Signed-off-by: Alain Michaud > --- > > Changes in v4: > - Wrapping the feature around an if (hdev) per Marcel's feedback. > > Changes in v3: > - Back to the original design of V1 and integrated Marcel's feedback. > > Changes in v2: > - Slight change of design based on offline feedback > > net/bluetooth/mgmt.c | 26 ++++++++++++++++++++++++-- > 1 file changed, 24 insertions(+), 2 deletions(-) I changed the code a little bit to make it simpler to read. See the modified v5 I just mailed to the mailing list. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KF8fDgygBF8pCQAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:17:16 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iJXGDAygBF/AwgEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 18:17:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 56A5952DF5; Tue, 7 Jul 2020 18:17:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728135AbgGGQJp convert rfc822-to-8bit (ORCPT + 1 other); Tue, 7 Jul 2020 12:09:45 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:36672 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbgGGQJp (ORCPT ); Tue, 7 Jul 2020 12:09:45 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 71B9ECECEE; Tue, 7 Jul 2020 18:19:40 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [RFC] Bluetooth: btusb: Add support for notifying the polling interval From: Marcel Holtmann In-Reply-To: <20200702220558.3467870-1-luiz.dentz@gmail.com> Date: Tue, 7 Jul 2020 18:09:43 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20200702220558.3467870-1-luiz.dentz@gmail.com> To: Luiz Augusto von Dentz X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.47 / 15.00 / 200.00 X-Rspamd-Queue-Id: 56A5952DF5 X-Rspamd-UID: 5a85dc Hi Luiz, > This enables btusb to inform the polling interval used for receiving > packets, the interval is then used wih rx_work which has been changed > to be a delayed work. > > The interval is then used as a time window where frames received from > different endpoints are considered to be arrived at same time. > > In order to resolve potential conflicts between endpoints a dedicated > queue for events was introduced and it is now processed before the ACL > packets. > > It worth noting though that priorizing events over ACL data may result > in inverting the order of the packets over the air, for instance there > may be packets received before a disconnect event that will be > discarded and unencrypted packets received before encryption change > which would considered encrypted, because of these potential inversions > the support for polling interval is not enabled by default so platforms > have the following means to enable it: we can not touch the core that impacts all transport layers even if they are not broken. So adding the second queue is not something that I think is a good idea. And again, we are just papering over a hole. However if you want to queue within btusb driver before sending it to the core, then maybe. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GFpyGyegBF/tBwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:17:43 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YE2TGSegBF8+qwEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 18:17:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1088352DDE; Tue, 7 Jul 2020 18:17:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728494AbgGGQLS (ORCPT + 1 other); Tue, 7 Jul 2020 12:11:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727079AbgGGQLS (ORCPT ); Tue, 7 Jul 2020 12:11:18 -0400 Received: from mail-vs1-xe44.google.com (mail-vs1-xe44.google.com [IPv6:2607:f8b0:4864:20::e44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1174DC061755 for ; Tue, 7 Jul 2020 09:11:18 -0700 (PDT) Received: by mail-vs1-xe44.google.com with SMTP id 64so16578628vsl.3 for ; Tue, 07 Jul 2020 09:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=PdkRv62nUyer3utyHGyA4zyawQ7UJwHUu+IzIsdxXbk=; b=ZIRm1sCwWG3uRuWaf7gqVsqLFlt4i5nQz7D3SKhQhXqifxYIfsrwV7RYthE1frvidf BirGcXuaaJKJ4hYD7MHm32VHftEpvf0G5tFcM7LQkFDNl8cT0WJ0NQdDwx10Ci9aIObS OCMwze0DIhf2sgT7WI1QToBUwX4SISOB1G0+M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=PdkRv62nUyer3utyHGyA4zyawQ7UJwHUu+IzIsdxXbk=; b=Xm0aK3GRpu2wqtcfcvsWBzK0Z+/3FJI9+Nz4LCZtROMTBwZY/+EbF4MYU+QLb76ITX a68+BvPK8DjJ3h69TgPf12aVjaVbe7vazqGK7O64PM9/e1XD2sGyazr/kW8NLJXMny1D hqwp8EK3oXomtFsc+sPBzXkOUQJEApL9gXwFJ/Fr/WKpOEhHAoAbOgwz3GUWW7IxWYoq uHdFijuibkotlEnw9ujnTth1QTIDJQPGM3jS2ZDO5D/bybvmaaHjRlORDQ8CO0LPwcI/ T2gx0kbClRxzCb7l2zxZJ7RBzeLuIZhP7H8KQBzwwKvwNI5gbbYXh8PpTQjG6mwXqqJi hh2g== X-Gm-Message-State: AOAM5312CkE4KK2T5VpBLyTupjpDdTP6Ed9xMP/Z1mZXxVLmFk3kcO3j KgwjVP/UHOpc2L7+2dnsbQfvLkn8/qtnjgq/nD/2xw== X-Google-Smtp-Source: ABdhPJxMj1B4DMC0cpSoOzvOLQGp4qu9v2iXoupdVrCYhGX2pRj4jjKQXOUpCAK37GZcNDrEen+wpsqytTGK7L52DQc= X-Received: by 2002:a67:6e05:: with SMTP id j5mr32157567vsc.196.1594138277134; Tue, 07 Jul 2020 09:11:17 -0700 (PDT) MIME-Version: 1.0 References: <20200707154905.2763616-1-abhishekpandit@chromium.org> <20200707084857.v3.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> <20200707160045.GA118278@kroah.com> In-Reply-To: <20200707160045.GA118278@kroah.com> From: Abhishek Pandit-Subedi Date: Tue, 7 Jul 2020 09:11:06 -0700 Message-ID: Subject: Re: [PATCH v3 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove To: Greg Kroah-Hartman Cc: Linux PM , Bluez mailing list , ChromeOS Bluetooth Upstreaming , rafael.j.wysocki@intel.com, Stephen Boyd , "Rafael J. Wysocki" , LKML , Len Brown , Pavel Machek Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1088352DDE X-Rspamd-UID: 3e4133 I admit I didn't test this but I built it with allmodconfig. Sadly, this only raised a warning instead of an error so I didn't go look through the build logs (ignore the 5.4, the remote here is the linux-pm git repo): /usr/local/google/home/abhishekpandit/chromiumos/src/third_party/kernel/v5.= 4/drivers/base/power/sysfs.c: In function =E2=80=98wakeup_sysfs_remove=E2=80=99: /usr/local/google/home/abhishekpandit/chromiumos/src/third_party/kernel/v5.= 4/drivers/base/power/sysfs.c:754:9: warning: =E2=80=98return=E2=80=99 with a value, in function returning void [-Wreturn-type] 754 | return kobject_uevent(&dev->kobj, KOBJ_CHANGE); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/google/home/abhishekpandit/chromiumos/src/third_party/kernel/v5.= 4/drivers/base/power/sysfs.c:751:6: note: declared here 751 | void wakeup_sysfs_remove(struct device *dev) Will send up another fix. Thanks Abhishek On Tue, Jul 7, 2020 at 9:00 AM Greg Kroah-Hartman wrote: > > On Tue, Jul 07, 2020 at 08:49:05AM -0700, Abhishek Pandit-Subedi wrote: > > Udev rules that depend on the power/wakeup attribute don't get triggere= d > > correctly if device_set_wakeup_capable is called after the device is > > created. This can happen for several reasons (driver sets wakeup after > > device is created, wakeup is changed on parent device, etc) and it seem= s > > reasonable to emit a changed event when adding or removing attributes o= n > > the device. > > > > Signed-off-by: Abhishek Pandit-Subedi > > --- > > > > Changes in v3: > > - Simplified error handling > > > > Changes in v2: > > - Add newline at end of bt_dev_err > > > > drivers/base/power/sysfs.c | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c > > index 24d25cf8ab1487..04c82373c8f240 100644 > > --- a/drivers/base/power/sysfs.c > > +++ b/drivers/base/power/sysfs.c > > @@ -1,6 +1,7 @@ > > // SPDX-License-Identifier: GPL-2.0 > > /* sysfs entries for device PM */ > > #include > > +#include > > #include > > #include > > #include > > @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, ku= id_t kuid, kgid_t kgid) > > > > int wakeup_sysfs_add(struct device *dev) > > { > > - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > > + int ret =3D sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > > + > > + if (ret) > > + return ret; > > + > > + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); > > } > > > > void wakeup_sysfs_remove(struct device *dev) > > { > > sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); > > + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); > > Always test build and hopefully actually test, your patches before > sending them out :( > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wIQwK9GhBF8pCQAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:24:49 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id mFTiJtGhBF/8AgEAlScrYA (envelope-from ); Tue, 07 Jul 2020 18:24:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 176A052C51; Tue, 7 Jul 2020 18:24:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728230AbgGGQYa (ORCPT + 1 other); Tue, 7 Jul 2020 12:24:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728189AbgGGQY3 (ORCPT ); Tue, 7 Jul 2020 12:24:29 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB33EC08C5DC for ; Tue, 7 Jul 2020 09:24:29 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id e8so20249592pgc.5 for ; Tue, 07 Jul 2020 09:24:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u5qLlzv2IdrRVupqKqhulZt6939J+XBU60CiFxmM7cU=; b=VQXfal6SP48mb+vig4iHdom3I2bB3mnJ44t9z32OcHIh1Nr57lzNzH42xrgkRUiF/w GnrEUHLPWufx2Smn911xp8Ln7oxiyrNsVjYM6SKl3dAaOKQIW1UZR7Ay2+MA3gkD8xUq kTfdRupNbe3AbhnA8wa+W1HyqMOsP99kfS9yo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u5qLlzv2IdrRVupqKqhulZt6939J+XBU60CiFxmM7cU=; b=S/lECtQ1z1LLQzQzh6Dz7wbd8ndY7D+ebwwd1qdmW4tRi7XagV0NOhnWqsCx3cj0av rlrUWY+2myJIKaFAAuuVeMj1nlVzCekbg6tCJiiJwwX7Q//l2Lfg8SZlqqrs6V8Vea+C 0MVsgL7rdoRgD4sxRzO/tJHLE/EpbyKwVYU4WMkFWC0AgrI0S+R3tbQOfF4bnafkJ5Yx 81+TyrytmfWiM79ZudOYwrBjluPmTGmSJ0D3iTgz2j08PRXkOT0zly088XBcvaAXFzRd iuz5w/ECDCxBIIPcflakWwsUz7g6ZcqkJhW/cIjoJ4ccIZH9/xqvAax6XJM0gcCH1+22 Oq6Q== X-Gm-Message-State: AOAM531ceOMYtnBN2GlTMDb8vV+iWlEx2qrKIFYNLOsj4jAClzlWhSPu fYny4HGrWZkaVJAMFjs7hDa4ng== X-Google-Smtp-Source: ABdhPJwPoRk7OUCfAEPQBUn0rnvuerUwTtUvOtQLNJJOujLrkHwMcXQ6UE6f2EqOSWu4FnD7yqLVeg== X-Received: by 2002:a63:3508:: with SMTP id c8mr46959312pga.9.1594139069345; Tue, 07 Jul 2020 09:24:29 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id s10sm3758196pjf.3.2020.07.07.09.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 09:24:28 -0700 (PDT) From: Abhishek Pandit-Subedi To: Greg Kroah-Hartman , linux-pm@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, rafael.j.wysocki@intel.com, swboyd@chromium.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: [PATCH v4 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove Date: Tue, 7 Jul 2020 09:24:17 -0700 Message-Id: <20200707092406.v4.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200707162417.3514284-1-abhishekpandit@chromium.org> References: <20200707162417.3514284-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: 176A052C51 X-Rspamd-UID: 2b140d Udev rules that depend on the power/wakeup attribute don't get triggered correctly if device_set_wakeup_capable is called after the device is created. This can happen for several reasons (driver sets wakeup after device is created, wakeup is changed on parent device, etc) and it seems reasonable to emit a changed event when adding or removing attributes on the device. Signed-off-by: Abhishek Pandit-Subedi --- Changes in v4: - Fix warning where returning from void and tested on device Changes in v3: - Simplified error handling Changes in v2: - Add newline at end of bt_dev_err drivers/base/power/sysfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index 24d25cf8ab1487..aeb58d40aac8de 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* sysfs entries for device PM */ #include +#include #include #include #include @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) int wakeup_sysfs_add(struct device *dev) { - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); + + if (ret) + return ret; + + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); } void wakeup_sysfs_remove(struct device *dev) { sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); + kobject_uevent(&dev->kobj, KOBJ_CHANGE); } int pm_qos_sysfs_add_resume_latency(struct device *dev) -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MDw8AuaeBF8pCQAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:12:22 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id CHuLAOaeBF89jgEADc0bRg (envelope-from ); Tue, 07 Jul 2020 18:12:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6376952EE3; Tue, 7 Jul 2020 18:12:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728883AbgGGPtP (ORCPT + 1 other); Tue, 7 Jul 2020 11:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728133AbgGGPtO (ORCPT ); Tue, 7 Jul 2020 11:49:14 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65D3EC08C5E1 for ; Tue, 7 Jul 2020 08:49:14 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id t15so4296594pjq.5 for ; Tue, 07 Jul 2020 08:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e5vsrk7vEHY5/cQx0UlucywmyaBj8fW6BqF1VBBdS+A=; b=Pv2fPxp7OIeEF3uKCol9thsCERjYulCcAkB8AUk4Gwl1bXaMqg3qeUpmuYbfoG9h9f R5P3I1Ko6Ww0MIpmSFkLAAtMlFxfdZNVyLLOkErJST905aoYkJitnFGHHJ6iFlOuBYlK CgPKunazaYPhxRQlwQCb+IDxN7kMA+6YmsRDU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e5vsrk7vEHY5/cQx0UlucywmyaBj8fW6BqF1VBBdS+A=; b=PMU8AZfVj8oIjN4YnsJ7ItxZXIib1akizsIdInwIG6Klz5iMOvx/OfKlh3sCn46DjX yOAK9Uhp9h1/QsEqw7YaTmF3s5f323O9c25cDuMwnDLE61rJGpPVVNWxUfBQcdvGPiNf jx0GAz0n3sM/MSxI0ncRt4tITdGoRXhlgSKyzYFboYMiPYFJRPqKoUwacQhXaUyiclHk MaWHIe2CaI0EZo+g+umyfg8shX5VZ/ziH/7n3XjYGJdZZRU0mPRB39++lVJl323wczi1 PSxTiW7T97id88f4UnGcXWHwNosmGWl6k18q65jO+Kh8hYe51/j+wZEdMpp9NBvuH/HG UgRQ== X-Gm-Message-State: AOAM530Qf6RoI/YVnv1KzGSJAExE+2rGop6on4/qVHSWfRAKprzX9mAg 5VwVfTKz3VelVKatZT+UU5Xmgw== X-Google-Smtp-Source: ABdhPJzLS/0a5ZIkTRnBJsarvJBHCyL5ykuVlth8AWwaID0VPkNo2x7wmAhQzmyPS9TNjQsw6QlLFA== X-Received: by 2002:a17:90a:cd01:: with SMTP id d1mr5071431pju.212.1594136953766; Tue, 07 Jul 2020 08:49:13 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id t5sm1360194pgl.38.2020.07.07.08.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 08:49:13 -0700 (PDT) From: Abhishek Pandit-Subedi To: Greg Kroah-Hartman , linux-pm@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, rafael.j.wysocki@intel.com, swboyd@chromium.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: [PATCH v3 0/1] power: Emit change uevent when updating sysfs Date: Tue, 7 Jul 2020 08:49:04 -0700 Message-Id: <20200707154905.2763616-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 28 X-Rspamd-Score: 4.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6376952EE3 X-Rspamd-UID: d32a51 Hi linux-pm, ChromeOS has a udev rule to chown the `power/wakeup` attribute so that the power manager can modify it during runtime. (https://source.chromium.org/chromiumos/chromiumos/codesearch/+/master:src/platform2/power_manager/udev/99-powerd-permissions.rules) In our automated tests, we found that the `power/wakeup` attributes weren't being chown-ed for some boards. On investigating, I found that when the drivers probe and call device_set_wakeup_capable, no uevent was being emitted for the newly added power/wakeup attribute. This was manifesting at boot on some boards (Marvell SDIO bluetooth and Broadcom Serial bluetooth drivers) or during usb disconnects during resume (Realtek btusb driver with reset resume quirk). It seems reasonable to me that changes to the attributes of a device should cause a changed uevent so I have added that here. Here's an example of the kernel events after toggling the authorized bit of /sys/bus/usb/devices/1-3/ $ echo 0 > /sys/bus/usb/devices/1-3/authorized KERNEL[27.357994] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill1 (rfkill) KERNEL[27.358049] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[27.358458] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[27.358486] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) KERNEL[27.358529] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) $ echo 1 > /sys/bus/usb/devices/1-3/authorized KERNEL[36.415749] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) KERNEL[36.415798] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[36.417414] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[36.417447] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill2 (rfkill) KERNEL[36.417481] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) Thanks Abhishek Changes in v3: - Simplified error handling Changes in v2: - Add newline at end of bt_dev_err Abhishek Pandit-Subedi (1): power: Emit changed uevent on wakeup_sysfs_add/remove drivers/base/power/sysfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oKQNEvqeBF/vvwEAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:12:42 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cIBKEPqeBF/AwgEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 18:12:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6ECAB5296A; Tue, 7 Jul 2020 18:12:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728925AbgGGPtQ (ORCPT + 1 other); Tue, 7 Jul 2020 11:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728678AbgGGPtP (ORCPT ); Tue, 7 Jul 2020 11:49:15 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37E8EC08C5E1 for ; Tue, 7 Jul 2020 08:49:15 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id cv18so1050095pjb.1 for ; Tue, 07 Jul 2020 08:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QIa6nXktLNxV0OJGlYLuHe4XdRrUEelYZWVni//KxsU=; b=ZENk32FXh9uVqWbCNy26QjHPUtixN1Mj5Z4BllFM9EXpZrcM4xdZqepp2x8GHb8w4T xo+RKmHHP+GwBykMt+Ngp2u909P+u+/8U/5gapxacqAu1AL5+7MgPlSJ+wWGl7sbiXea yH4t7ZL3ssoXqvdaICXTKyOhKS5BbWelsOIbo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QIa6nXktLNxV0OJGlYLuHe4XdRrUEelYZWVni//KxsU=; b=aOxS8rAojxmNZMJj3unVGFRj2kHv8ndmoRy1WXWVFG95XET5h/TPjndMLG4p2NFLFq /REHTj/GxAvQHkzQdKNRDm3o3Z/d+uDJxMpbb1mdKwRmO5i+uwqfkssWKrHiMVlEl5ug mTLL0ke4/qqos7JdUnIbI0NvgGqmwitTBOnJsT0/bNqGQcx4KBXPv+tIcaAIiRJg1OQX 73oMYQdKeFOtKWFwS9Qb/BQmX9Z7lBqvv/EVKJmNpJQZixl0uuiD+KvJlc5wMrPBwLeu mjrZ6pPbWXBMi4jaiSCB2UIegrKCk17+7nODPcc0amrKaqLYcjgYMW4TfNVICWQ6GmBU jGZg== X-Gm-Message-State: AOAM5315WCcrE2zDUW17WFLiFli0ww/rOcp3bE67LjegJrIGwEQ8csch uy1zE3QhQZouyPb8uiHmQ5rApw== X-Google-Smtp-Source: ABdhPJz9iHG+DFuUyYcBIjr3vVuYxa0ZU2rFQLx+SaJILKp2THWi5NfPgogurVf9a1QeoPIhrUJUuA== X-Received: by 2002:a17:90a:67c7:: with SMTP id g7mr4910530pjm.165.1594136954819; Tue, 07 Jul 2020 08:49:14 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id t5sm1360194pgl.38.2020.07.07.08.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 08:49:14 -0700 (PDT) From: Abhishek Pandit-Subedi To: Greg Kroah-Hartman , linux-pm@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, rafael.j.wysocki@intel.com, swboyd@chromium.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: [PATCH v3 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove Date: Tue, 7 Jul 2020 08:49:05 -0700 Message-Id: <20200707084857.v3.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200707154905.2763616-1-abhishekpandit@chromium.org> References: <20200707154905.2763616-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6ECAB5296A X-Rspamd-UID: 0c06b4 Udev rules that depend on the power/wakeup attribute don't get triggered correctly if device_set_wakeup_capable is called after the device is created. This can happen for several reasons (driver sets wakeup after device is created, wakeup is changed on parent device, etc) and it seems reasonable to emit a changed event when adding or removing attributes on the device. Signed-off-by: Abhishek Pandit-Subedi --- Changes in v3: - Simplified error handling Changes in v2: - Add newline at end of bt_dev_err drivers/base/power/sysfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index 24d25cf8ab1487..04c82373c8f240 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* sysfs entries for device PM */ #include +#include #include #include #include @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) int wakeup_sysfs_add(struct device *dev) { - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); + + if (ret) + return ret; + + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); } void wakeup_sysfs_remove(struct device *dev) { sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); } int pm_qos_sysfs_add_resume_latency(struct device *dev) -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KKfQLRyfBF/tBwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:13:16 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yJjhKxyfBF9P2gAAlScrYA (envelope-from ); Tue, 07 Jul 2020 18:13:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 728F052DDE; Tue, 7 Jul 2020 18:13:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728477AbgGGPvb (ORCPT + 1 other); Tue, 7 Jul 2020 11:51:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728029AbgGGPva (ORCPT ); Tue, 7 Jul 2020 11:51:30 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6960BC061755 for ; Tue, 7 Jul 2020 08:51:30 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id y18so24997786lfh.11 for ; Tue, 07 Jul 2020 08:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kjHG2fEc32d5jG/RXXsuugh7BBMStXUSYttEp1ymo5Q=; b=ie10kp3godHa5Qm23qDWti0L4tWyZ/zMx7LwRaOf4n3hCjenf5eBVyb10H79rJt0pN Wy9g6BKfZ6Bk9XyVby49F0elUzhUuYCHmmJRKFQLm1ApnVVTN4a3QUN/qVbqAnM03WHS D9Rk1hloRSv+JJjR/x3NJyKRSvnAJElRWZNyrjPFFRwpzXiQTW0QsKNtB1zi/Bi7iCQb u8ojXFlWfW+dpEoGCFEwLKsD0l5ghIGbYOqm2USrYk6aqbHSmFsj2SaYQuuvAO5f0fRl 7vdrIzbrVlPy6u2sOmaU99Of3SbxUsDA8CGJYA7ibxdYr8Wh+GKEzF6I2RdnwmM7PPwE 1Wiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kjHG2fEc32d5jG/RXXsuugh7BBMStXUSYttEp1ymo5Q=; b=a8ZDqHOmi+/sJKm9qBdikG5Qhdap2NwHIG/kktGkM9yUIdD2kXh51NHJ33Fi0TJnMh 8Da3qqyZb9cTfbMrBehRBumPvwgWt6NaBdbg7TpszLu7esTc/h6cREqdQPvDSRAvd1Kx TCldibieizlesMxTKEOPQv8MIMPKLneVVKVhj4kGLlvPWPZf6B3kFm97w8RfNLI/3sJp +ctt/3hMD00/sU7PCQ+eGXT8Yh/DeQcTv8xzzI3pIXkOTdgaGQrM7GH0ZhjLyWc/9/yQ t7zcWYOVv3KGQAu1+e8eH9FA03F6NSb004jNT29FHlA3iOyQKHWi0Lvkv5lE1N3J/31o iXvA== X-Gm-Message-State: AOAM533x9demcBcsYIHbPcCU02K5gb2X0PmRYFvcRINnVj27ct/Zg4Xv iFLUirZxVQDm5CvlIY5ZnChtboOYOyk46SCpkKQS6XamNwQ= X-Google-Smtp-Source: ABdhPJwxW0awucU9IURnjrevSmYMDFPmpmkIGSSmEn7KGmWW90q20TW4lt7b8XKx+yVABP550T1J+5737Vrq8umz68Q= X-Received: by 2002:a19:c78d:: with SMTP id x135mr33396486lff.82.1594137088645; Tue, 07 Jul 2020 08:51:28 -0700 (PDT) MIME-Version: 1.0 References: <20200707154606.52947-1-marcel@holtmann.org> In-Reply-To: <20200707154606.52947-1-marcel@holtmann.org> From: Alain Michaud Date: Tue, 7 Jul 2020 11:51:17 -0400 Message-ID: Subject: Re: [PATCH v5] Bluetooth: le_simult_central_peripheral experimental feature To: Marcel Holtmann Cc: BlueZ Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 728F052DDE X-Rspamd-UID: 7d7936 Hi Marcel, I'm ok with your modifications. Thanks, Alain On Tue, Jul 7, 2020 at 11:46 AM Marcel Holtmann wrote: > > From: Alain Michaud > > This patch adds an le_simult_central_peripheral features which allows a > clients to determine if the controller is able to support peripheral and > central connections separately and at the same time. > > Signed-off-by: Alain Michaud > Signed-off-by: Marcel Holtmann > --- > net/bluetooth/mgmt.c | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) > > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > index 5e9b9728eeac..d29da80e38fe 100644 > --- a/net/bluetooth/mgmt.c > +++ b/net/bluetooth/mgmt.c > @@ -3753,12 +3753,19 @@ static const u8 debug_uuid[16] = { > }; > #endif > > +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ > +static const u8 simult_central_periph_uuid[16] = { > + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, > + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > +}; > + > static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > void *data, u16 data_len) > { > - char buf[42]; > + char buf[44]; > struct mgmt_rp_read_exp_features_info *rp = (void *)buf; > u16 idx = 0; > + u32 flags; > > bt_dev_dbg(hdev, "sock %p", sk); > > @@ -3766,7 +3773,7 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > > #ifdef CONFIG_BT_FEATURE_DEBUG > if (!hdev) { > - u32 flags = bt_dbg_get() ? BIT(0) : 0; > + flags = bt_dbg_get() ? BIT(0) : 0; > > memcpy(rp->features[idx].uuid, debug_uuid, 16); > rp->features[idx].flags = cpu_to_le32(flags); > @@ -3774,6 +3781,20 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + if (hdev) { > + if (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && > + (hdev->le_states[4] & 0x08) && /* Central */ > + (hdev->le_states[4] & 0x40) && /* Peripheral */ > + (hdev->le_states[3] & 0x10)) /* Simultaneous */ > + flags = BIT(0); > + else > + flags = 0; > + > + memcpy(rp->features[idx].uuid, simult_central_periph_uuid, 16); > + rp->features[idx].flags = cpu_to_le32(flags); > + idx++; > + } > + > rp->feature_count = cpu_to_le16(idx); > > /* After reading the experimental features information, enable > -- > 2.26.2 > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yDO7B0WfBF/vvwEAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:13:57 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id MG2KBUWfBF+8wgEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 18:13:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6B8295296A; Tue, 7 Jul 2020 18:13:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728207AbgGGPxh convert rfc822-to-8bit (ORCPT + 1 other); Tue, 7 Jul 2020 11:53:37 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:51195 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728029AbgGGPxg (ORCPT ); Tue, 7 Jul 2020 11:53:36 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 1B700CECED; Tue, 7 Jul 2020 18:03:31 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2] Bluetooth: create CONFIG_BT_DEBUG_FEATURE_FUNC_NAME From: Marcel Holtmann In-Reply-To: <20200707141628.368748-1-alainm@chromium.org> Date: Tue, 7 Jul 2020 17:53:33 +0200 Cc: linux-bluetooth@vger.kernel.org, Archie Pusaka Content-Transfer-Encoding: 8BIT Message-Id: <67268C4E-674E-4DE9-B642-E1CAE8748E28@holtmann.org> References: <20200707141628.368748-1-alainm@chromium.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 2 X-Rspamd-Score: 0.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6B8295296A X-Rspamd-UID: 2bed24 Hi Alain, > Creates a CONFIG_BT_DEBUG_FEATURE_FUNC_NAME option to include function names in > debug statements. > > Unlike other platforms __func__ isn't a string literal so it cannot be > automatically concatenated by the pre-processor. As a result, the > function name is passed as a parameter to the tracing function. Since > pr_debug is a function like macro, the normal expansion of BT_PREFIX_PARAM > does not work as it gets processed within the first parameter as well, > for this reason, BT_DBG is split into two versions. > > This patch was built tested with all 4 possible combinations of > CONFIG_BT_DEBUG_FUNC_NAME and CONFIG_BT_FEATURE_DEBUG configurations. > > Signed-off-by: Alain Michaud > Reviewed-by: Archie Pusaka > --- > > Changes in v2: > - Making CONFIG_BT_DEBUG_FEATURE_FUNC_NAME dependent on > CONFIG_BT_DEBUG_FEATURE > > include/net/bluetooth/bluetooth.h | 32 +++++++++++++++++++++++-------- > net/bluetooth/Kconfig | 11 +++++++++++ > 2 files changed, 35 insertions(+), 8 deletions(-) > > diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h > index 7ee8041af803..8506dd268d4b 100644 > --- a/include/net/bluetooth/bluetooth.h > +++ b/include/net/bluetooth/bluetooth.h > @@ -162,22 +162,37 @@ void bt_dbg_set(bool enable); > bool bt_dbg_get(void); > __printf(1, 2) > void bt_dbg(const char *fmt, ...); > +#define BT_DBG_INT bt_dbg > +#else > +#define BT_DBG_INT pr_debug > #endif > __printf(1, 2) > void bt_warn_ratelimited(const char *fmt, ...); > __printf(1, 2) > void bt_err_ratelimited(const char *fmt, ...); > > -#define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__) > -#define BT_WARN(fmt, ...) bt_warn(fmt "\n", ##__VA_ARGS__) > -#define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) > - > -#if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG) > -#define BT_DBG(fmt, ...) bt_dbg(fmt "\n", ##__VA_ARGS__) > +#if IS_ENABLED(BT_FEATURE_DEBUG_FUNC_NAMES) are you sure you tested this? And frankly I don’t get the point for the new Kconfig option. It is rather useless in this patch. Tell me one thing, do you prefer that FEATURE_DEBUG prints the function names or not. Because if dynamic debug is used, we don’t need it since that is all configurable via dynamic debug itself and we don’t need it there (and I also don’t want it in the dynamic debug case). Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GLoJFU+fBF/tBwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:14:07 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YJ9WE0+fBF9XiQAAgupzMw (envelope-from ); Tue, 07 Jul 2020 18:14:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0D23952DDE; Tue, 7 Jul 2020 18:14:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728288AbgGGPyL (ORCPT + 1 other); Tue, 7 Jul 2020 11:54:11 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:45775 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728029AbgGGPyL (ORCPT ); Tue, 7 Jul 2020 11:54:11 -0400 Received: by mail-ot1-f65.google.com with SMTP id h1so12493127otq.12; Tue, 07 Jul 2020 08:54:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wUWo+ABoGaY5YMN3ISixI5iI43FT2WEg9Sy5KiriC20=; b=oyqhDNALTNcyifuSOqgl8e5r6T/Q7DkTB1tC22wCUk3jXxMu7F0cFF+77mW413do+E pD4tOjynUZnDW5hMPmhyCauImweEivRIO0WuyU+6eZJOX33Kq3lUk1TAyZD5oWSYs+zM RehPsLBIMyKa+vLkHr3yZ1w6KplbFfuHc+itOAsgVfqBBRcALdAFtE25+rlM+GR5bPbb RMzkjoUjAKsbj8t1KAKgCuiyD4mu3zVSxd685sAhM6x2XX4qYGm/3LNcez4fmZ5f/67x Emu2hBVLPGX13wRQm1IAkNV4fCp+8NjxRhHVDjTN40OlqCz6k+Z71vsPYTZ/M8FFukMv zGZw== X-Gm-Message-State: AOAM5320Rkh046dWjjys00ZPuRy5RHcRSHx+suOZPDeo5nhc5jNXQYgm StrK5TrM7BzQcgOfICtIHs2Kg9350D26r6CG+uE= X-Google-Smtp-Source: ABdhPJx1Ku7oIoTGez7vzkNKzJzCy5ZHGH/LnBGgtx2DghCYvkbjHJdNWl4cNLuuFhtveS0OmaQjT7n0dYlzh/UIpRU= X-Received: by 2002:a9d:1c82:: with SMTP id l2mr27979494ota.167.1594137250094; Tue, 07 Jul 2020 08:54:10 -0700 (PDT) MIME-Version: 1.0 References: <20200707154905.2763616-1-abhishekpandit@chromium.org> <20200707084857.v3.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> In-Reply-To: <20200707084857.v3.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> From: "Rafael J. Wysocki" Date: Tue, 7 Jul 2020 17:53:59 +0200 Message-ID: Subject: Re: [PATCH v3 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove To: Abhishek Pandit-Subedi Cc: Greg Kroah-Hartman , Linux PM , "open list:BLUETOOTH DRIVERS" , chromeos-bluetooth-upstreaming@chromium.org, Rafael Wysocki , Stephen Boyd , "Rafael J. Wysocki" , Linux Kernel Mailing List , Len Brown , Pavel Machek Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0D23952DDE X-Rspamd-UID: d17a21 On Tue, Jul 7, 2020 at 5:49 PM Abhishek Pandit-Subedi wrote: > > Udev rules that depend on the power/wakeup attribute don't get triggered > correctly if device_set_wakeup_capable is called after the device is > created. This can happen for several reasons (driver sets wakeup after > device is created, wakeup is changed on parent device, etc) and it seems > reasonable to emit a changed event when adding or removing attributes on > the device. > > Signed-off-by: Abhishek Pandit-Subedi > --- > > Changes in v3: > - Simplified error handling > > Changes in v2: > - Add newline at end of bt_dev_err > > drivers/base/power/sysfs.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c > index 24d25cf8ab1487..04c82373c8f240 100644 > --- a/drivers/base/power/sysfs.c > +++ b/drivers/base/power/sysfs.c > @@ -1,6 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0 > /* sysfs entries for device PM */ > #include > +#include > #include > #include > #include > @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) > > int wakeup_sysfs_add(struct device *dev) > { > - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > + > + if (ret) > + return ret; > + > + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); Returning an error code here may be misleading, because the basic operation (i.e. merging the attribute group) has succeeded already. What about printing a message if kobject_uevent() returns an error and returning 0 anyway? > } > > void wakeup_sysfs_remove(struct device *dev) > { > sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); > + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); This is a void function, so it cannot return anything. > } > > int pm_qos_sysfs_add_resume_latency(struct device *dev) > -- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kC/eG2SfBF/tBwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:14:28 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0EumGmSfBF+8wgEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 18:14:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4EA77526C5; Tue, 7 Jul 2020 18:14:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728456AbgGGPyf (ORCPT + 1 other); Tue, 7 Jul 2020 11:54:35 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:54568 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727793AbgGGPyf (ORCPT ); Tue, 7 Jul 2020 11:54:35 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 6702DCECEF for ; Tue, 7 Jul 2020 18:04:30 +0200 (CEST) From: Marcel Holtmann Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v5] Bluetooth: le_simult_central_peripheral experimental feature Date: Tue, 7 Jul 2020 17:54:33 +0200 References: <20200707154606.52947-1-marcel@holtmann.org> To: linux-bluetooth In-Reply-To: <20200707154606.52947-1-marcel@holtmann.org> Message-Id: <6FF8C288-58E7-4010-AA12-9AA7831FB2BE@holtmann.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.48 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4EA77526C5 X-Rspamd-UID: a70bbf Hi Alain, > This patch adds an le_simult_central_peripheral features which allows a > clients to determine if the controller is able to support peripheral and > central connections separately and at the same time. > > Signed-off-by: Alain Michaud > Signed-off-by: Marcel Holtmann > --- > net/bluetooth/mgmt.c | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iFNyB6qfBF96HwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:15:38 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 6Px0BaqfBF957gAAlScrYA (envelope-from ); Tue, 07 Jul 2020 18:15:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C021E52C05; Tue, 7 Jul 2020 18:15:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728643AbgGGQAt (ORCPT + 1 other); Tue, 7 Jul 2020 12:00:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:60600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728100AbgGGQAs (ORCPT ); Tue, 7 Jul 2020 12:00:48 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 77402206E2; Tue, 7 Jul 2020 16:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594137647; bh=0BlRynaDNr3hx41psfYOd+ICHIe/RtCgteNSx90K9JE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=INE9r+/HdvJPhuASOEkh8ETNgO4NdGufY/na5p6QUOGo4vyNijRYlsww2dwSU4yCz d+HAhNn28aW+s0NJpJ6lOOzlE8bHkIuvfxAPjVaQ4+/9hR9FvR0jvEVdOPWYfjHuMS scppuriDxmSkBf37MeolAGQODZ1035i4wsqBEQGY= Date: Tue, 7 Jul 2020 18:00:45 +0200 From: Greg Kroah-Hartman To: Abhishek Pandit-Subedi Cc: linux-pm@vger.kernel.org, linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, rafael.j.wysocki@intel.com, swboyd@chromium.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: Re: [PATCH v3 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove Message-ID: <20200707160045.GA118278@kroah.com> References: <20200707154905.2763616-1-abhishekpandit@chromium.org> <20200707084857.v3.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707084857.v3.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: C021E52C05 X-Rspamd-UID: e0db44 On Tue, Jul 07, 2020 at 08:49:05AM -0700, Abhishek Pandit-Subedi wrote: > Udev rules that depend on the power/wakeup attribute don't get triggered > correctly if device_set_wakeup_capable is called after the device is > created. This can happen for several reasons (driver sets wakeup after > device is created, wakeup is changed on parent device, etc) and it seems > reasonable to emit a changed event when adding or removing attributes on > the device. > > Signed-off-by: Abhishek Pandit-Subedi > --- > > Changes in v3: > - Simplified error handling > > Changes in v2: > - Add newline at end of bt_dev_err > > drivers/base/power/sysfs.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c > index 24d25cf8ab1487..04c82373c8f240 100644 > --- a/drivers/base/power/sysfs.c > +++ b/drivers/base/power/sysfs.c > @@ -1,6 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0 > /* sysfs entries for device PM */ > #include > +#include > #include > #include > #include > @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) > > int wakeup_sysfs_add(struct device *dev) > { > - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > + > + if (ret) > + return ret; > + > + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); > } > > void wakeup_sysfs_remove(struct device *dev) > { > sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); > + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); Always test build and hopefully actually test, your patches before sending them out :( Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eKT9K7efBF96HwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:15:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id AG4/KrefBF9foQEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 18:15:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D73BC52DF5; Tue, 7 Jul 2020 18:15:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728218AbgGGQBg convert rfc822-to-8bit (ORCPT + 1 other); Tue, 7 Jul 2020 12:01:36 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:40849 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728029AbgGGQBg (ORCPT ); Tue, 7 Jul 2020 12:01:36 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id C6DF8CECED; Tue, 7 Jul 2020 18:11:29 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 2/3] Bluetooth: btrtl: add support for the RTL8723CS From: Marcel Holtmann In-Reply-To: <20200705195110.405139-3-anarsoul@gmail.com> Date: Tue, 7 Jul 2020 18:01:33 +0200 Cc: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree , linux-arm-kernel@lists.infradead.org, kernel list , linux-bluetooth , netdev@vger.kernel.org, Ondrej Jirman Content-Transfer-Encoding: 8BIT Message-Id: <99A48FC7-0DCB-42F9-A3E3-91292BB92100@holtmann.org> References: <20200705195110.405139-1-anarsoul@gmail.com> <20200705195110.405139-3-anarsoul@gmail.com> To: Vasily Khoruzhick X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: D73BC52DF5 X-Rspamd-UID: 9d44c1 Hi Vasily, > The Realtek RTL8723CS is SDIO WiFi chip. It also contains a Bluetooth > module which is connected via UART to the host. > > It shares lmp subversion with 8703B, so Realtek's userspace > initialization tool (rtk_hciattach) differentiates varieties of RTL8723CS > (CG, VF, XX) with RTL8703B using vendor's command to read chip type. > > Also this chip declares support for some features it doesn't support > so add a quirk to indicate that these features are broken. > > Signed-off-by: Vasily Khoruzhick > --- > drivers/bluetooth/btrtl.c | 128 ++++++++++++++++++++++++++++++++++++- > drivers/bluetooth/btrtl.h | 12 ++++ > drivers/bluetooth/hci_h5.c | 6 ++ > 3 files changed, 143 insertions(+), 3 deletions(-) > > diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c > index 3a9afc905f24..8c7b35abe492 100644 > --- a/drivers/bluetooth/btrtl.c > +++ b/drivers/bluetooth/btrtl.c > @@ -17,8 +17,12 @@ > > #define VERSION "0.1" > > +#define RTL_CHIP_8723CS_CG 3 > +#define RTL_CHIP_8723CS_VF 4 > +#define RTL_CHIP_8723CS_XX 5 > #define RTL_EPATCH_SIGNATURE "Realtech" > #define RTL_ROM_LMP_3499 0x3499 > +#define RTL_ROM_LMP_8703B 0x8703 > #define RTL_ROM_LMP_8723A 0x1200 > #define RTL_ROM_LMP_8723B 0x8723 > #define RTL_ROM_LMP_8723D 0x8873 > @@ -31,6 +35,7 @@ > #define IC_MATCH_FL_HCIREV (1 << 1) > #define IC_MATCH_FL_HCIVER (1 << 2) > #define IC_MATCH_FL_HCIBUS (1 << 3) > +#define IC_MATCH_FL_CHIP_TYPE (1 << 4) > #define IC_INFO(lmps, hcir) \ > .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV, \ > .lmp_subver = (lmps), \ > @@ -42,6 +47,7 @@ struct id_table { > __u16 hci_rev; > __u8 hci_ver; > __u8 hci_bus; > + __u8 chip_type; > bool config_needed; > bool has_rom_version; > char *fw_name; > @@ -89,6 +95,39 @@ static const struct id_table ic_id_table[] = { > .fw_name = "rtl_bt/rtl8723b_fw.bin", > .cfg_name = "rtl_bt/rtl8723b_config" }, > > + /* 8723CS-CG */ > + { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_CHIP_TYPE | > + IC_MATCH_FL_HCIBUS, > + .lmp_subver = RTL_ROM_LMP_8703B, > + .chip_type = RTL_CHIP_8723CS_CG, > + .hci_bus = HCI_UART, > + .config_needed = true, > + .has_rom_version = true, > + .fw_name = "rtl_bt/rtl8723cs_cg_fw.bin", > + .cfg_name = "rtl_bt/rtl8723cs_cg_config" }, > + > + /* 8723CS-VF */ > + { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_CHIP_TYPE | > + IC_MATCH_FL_HCIBUS, > + .lmp_subver = RTL_ROM_LMP_8703B, > + .chip_type = RTL_CHIP_8723CS_VF, > + .hci_bus = HCI_UART, > + .config_needed = true, > + .has_rom_version = true, > + .fw_name = "rtl_bt/rtl8723cs_vf_fw.bin", > + .cfg_name = "rtl_bt/rtl8723cs_vf_config" }, > + > + /* 8723CS-XX */ > + { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_CHIP_TYPE | > + IC_MATCH_FL_HCIBUS, > + .lmp_subver = RTL_ROM_LMP_8703B, > + .chip_type = RTL_CHIP_8723CS_XX, > + .hci_bus = HCI_UART, > + .config_needed = true, > + .has_rom_version = true, > + .fw_name = "rtl_bt/rtl8723cs_xx_fw.bin", > + .cfg_name = "rtl_bt/rtl8723cs_xx_config" }, > + > /* 8723D */ > { IC_INFO(RTL_ROM_LMP_8723B, 0xd), > .config_needed = true, > @@ -171,7 +210,8 @@ static const struct id_table ic_id_table[] = { > }; > > static const struct id_table *btrtl_match_ic(u16 lmp_subver, u16 hci_rev, > - u8 hci_ver, u8 hci_bus) > + u8 hci_ver, u8 hci_bus, > + u8 chip_type) > { > int i; > > @@ -188,6 +228,9 @@ static const struct id_table *btrtl_match_ic(u16 lmp_subver, u16 hci_rev, > if ((ic_id_table[i].match_flags & IC_MATCH_FL_HCIBUS) && > (ic_id_table[i].hci_bus != hci_bus)) > continue; > + if ((ic_id_table[i].match_flags & IC_MATCH_FL_CHIP_TYPE) && > + (ic_id_table[i].chip_type != chip_type)) > + continue; > > break; > } > @@ -270,6 +313,7 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev, > { RTL_ROM_LMP_8723B, 1 }, > { RTL_ROM_LMP_8821A, 2 }, > { RTL_ROM_LMP_8761A, 3 }, > + { RTL_ROM_LMP_8703B, 7 }, > { RTL_ROM_LMP_8822B, 8 }, > { RTL_ROM_LMP_8723B, 9 }, /* 8723D */ > { RTL_ROM_LMP_8821A, 10 }, /* 8821C */ > @@ -545,6 +589,48 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, > return ret; > } > > +static bool rtl_has_chip_type(u16 lmp_subver) > +{ > + switch (lmp_subver) { > + case RTL_ROM_LMP_8703B: > + return true; > + default: > + break; > + } > + > + return false; > +} > + > +static int rtl_read_chip_type(struct hci_dev *hdev, u8 *type) > +{ > + struct rtl_chip_type_evt *chip_type; > + struct sk_buff *skb; > + const unsigned char cmd_buf[] = {0x00, 0x94, 0xa0, 0x00, 0xb0}; > + > + /* Read RTL chip type command */ > + skb = __hci_cmd_sync(hdev, 0xfc61, 5, cmd_buf, HCI_INIT_TIMEOUT); > + if (IS_ERR(skb)) { > + rtl_dev_err(hdev, "Read chip type failed (%ld)", > + PTR_ERR(skb)); > + return PTR_ERR(skb); > + } > + > + if (skb->len != sizeof(*chip_type)) { > + rtl_dev_err(hdev, "RTL chip type event length mismatch"); > + kfree_skb(skb); > + return -EIO; > + } > + > + chip_type = (struct rtl_chip_type_evt *)skb->data; > + rtl_dev_info(hdev, "chip_type status=%x type=%x", > + chip_type->status, chip_type->type); > + > + *type = chip_type->type & 0x0f; > + > + kfree_skb(skb); > + return 0; > +} > + > void btrtl_free(struct btrtl_device_info *btrtl_dev) > { > kvfree(btrtl_dev->fw_data); > @@ -561,7 +647,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, > struct hci_rp_read_local_version *resp; > char cfg_name[40]; > u16 hci_rev, lmp_subver; > - u8 hci_ver; > + u8 hci_ver, chip_type = 0; > int ret; > > btrtl_dev = kzalloc(sizeof(*btrtl_dev), GFP_KERNEL); > @@ -586,8 +672,14 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, > lmp_subver = le16_to_cpu(resp->lmp_subver); > kfree_skb(skb); > > + if (rtl_has_chip_type(lmp_subver)) { > + ret = rtl_read_chip_type(hdev, &chip_type); > + if (ret) > + goto err_free; > + } > + > btrtl_dev->ic_info = btrtl_match_ic(lmp_subver, hci_rev, hci_ver, > - hdev->bus); > + hdev->bus, chip_type); > > if (!btrtl_dev->ic_info) { > rtl_dev_info(hdev, "unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x", > @@ -660,6 +752,7 @@ int btrtl_download_firmware(struct hci_dev *hdev, > case RTL_ROM_LMP_8821A: > case RTL_ROM_LMP_8761A: > case RTL_ROM_LMP_8822B: > + case RTL_ROM_LMP_8703B: > return btrtl_setup_rtl8723b(hdev, btrtl_dev); > default: > rtl_dev_info(hdev, "assuming no firmware upload needed"); > @@ -678,7 +771,12 @@ int btrtl_setup_realtek(struct hci_dev *hdev) > return PTR_ERR(btrtl_dev); > > ret = btrtl_download_firmware(hdev, btrtl_dev); > + if (ret) > + goto out_free; > > + btrtl_apply_quirks(hdev, btrtl_dev); > + > +out_free: > btrtl_free(btrtl_dev); > > /* Enable controller to do both LE scan and BR/EDR inquiry > @@ -818,6 +916,24 @@ int btrtl_get_uart_settings(struct hci_dev *hdev, > } > EXPORT_SYMBOL_GPL(btrtl_get_uart_settings); > > +void btrtl_apply_quirks(struct hci_dev *hdev, > + struct btrtl_device_info *btrtl_dev) > +{ > + switch (btrtl_dev->ic_info->lmp_subver) { > + case RTL_ROM_LMP_8703B: > + /* 8723CS reports two pages for local ext features, > + * but it doesn't support any features from page 2 - > + * it either responds with garbage or with error status > + */ > + set_bit(HCI_QUIRK_BROKEN_LOCAL_EXT_FTR_MAX_PAGE, > + &hdev->quirks); > + break; > + default: > + break; > + } > +} > +EXPORT_SYMBOL_GPL(btrtl_apply_quirks); > + > MODULE_AUTHOR("Daniel Drake "); > MODULE_DESCRIPTION("Bluetooth support for Realtek devices ver " VERSION); > MODULE_VERSION(VERSION); > @@ -827,6 +943,12 @@ MODULE_FIRMWARE("rtl_bt/rtl8723b_fw.bin"); > MODULE_FIRMWARE("rtl_bt/rtl8723b_config.bin"); > MODULE_FIRMWARE("rtl_bt/rtl8723bs_fw.bin"); > MODULE_FIRMWARE("rtl_bt/rtl8723bs_config.bin"); > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_cg_fw.bin"); > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_cg_config.bin"); > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_vf_fw.bin"); > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_vf_config.bin"); > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_xx_fw.bin"); > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_xx_config.bin"); > MODULE_FIRMWARE("rtl_bt/rtl8723ds_fw.bin"); > MODULE_FIRMWARE("rtl_bt/rtl8723ds_config.bin"); > MODULE_FIRMWARE("rtl_bt/rtl8761a_fw.bin"); > diff --git a/drivers/bluetooth/btrtl.h b/drivers/bluetooth/btrtl.h > index 2a582682136d..152ed2ece4c2 100644 > --- a/drivers/bluetooth/btrtl.h > +++ b/drivers/bluetooth/btrtl.h > @@ -14,6 +14,11 @@ > > struct btrtl_device_info; > > +struct rtl_chip_type_evt { > + __u8 status; > + __u8 type; > +} __packed; > + > struct rtl_download_cmd { > __u8 index; > __u8 data[RTL_FRAG_LEN]; > @@ -60,6 +65,8 @@ int btrtl_get_uart_settings(struct hci_dev *hdev, > struct btrtl_device_info *btrtl_dev, > unsigned int *controller_baudrate, > u32 *device_baudrate, bool *flow_control); > +void btrtl_apply_quirks(struct hci_dev *hdev, > + struct btrtl_device_info *btrtl_dev); > > #else > > @@ -96,6 +103,11 @@ static inline int btrtl_get_uart_settings(struct hci_dev *hdev, > bool *flow_control) > { > return -ENOENT; > + > +static inline void btrtl_apply_quirks(struct hci_dev *hdev, > + struct btrtl_device_info *btrtl_dev) > +{ > +} > } this hunk is fundamentally broken. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GPaxIdufBF96HwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:16:27 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id YFwoINufBF8S9gEA0J78UA (envelope-from ); Tue, 07 Jul 2020 18:16:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 70C4F5296A; Tue, 7 Jul 2020 18:16:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728784AbgGGQDk convert rfc822-to-8bit (ORCPT + 1 other); Tue, 7 Jul 2020 12:03:40 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:33373 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727793AbgGGQDj (ORCPT ); Tue, 7 Jul 2020 12:03:39 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 6DD81CECEE; Tue, 7 Jul 2020 18:13:34 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 1/3] Bluetooth: Add new quirk for broken local ext features max_page From: Marcel Holtmann In-Reply-To: <20200705195110.405139-2-anarsoul@gmail.com> Date: Tue, 7 Jul 2020 18:03:37 +0200 Cc: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree , linux-arm-kernel@lists.infradead.org, kernel list , linux-bluetooth , "open list:NETWORKING [GENERAL]" , Ondrej Jirman Content-Transfer-Encoding: 8BIT Message-Id: References: <20200705195110.405139-1-anarsoul@gmail.com> <20200705195110.405139-2-anarsoul@gmail.com> To: Vasily Khoruzhick X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 7 X-Rspamd-Score: 1.16 / 15.00 / 200.00 X-Rspamd-Queue-Id: 70C4F5296A X-Rspamd-UID: f66e5d Hi Vasily, > Some adapters (e.g. RTL8723CS) advertise that they have more than > 2 pages for local ext features, but they don't support any features > declared in these pages. RTL8723CS reports max_page = 2 and declares > support for sync train and secure connection, but it responds with > either garbage or with error in status on corresponding commands. please send the btmon for this so I can see what the controller is responding. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MCcFK9WhBF96HwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:24:53 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id uI6AKdWhBF9OSAAA0J78UA (envelope-from ); Tue, 07 Jul 2020 18:24:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C129952BD6; Tue, 7 Jul 2020 18:24:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728150AbgGGQY3 (ORCPT + 1 other); Tue, 7 Jul 2020 12:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728137AbgGGQY2 (ORCPT ); Tue, 7 Jul 2020 12:24:28 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF558C08C5E1 for ; Tue, 7 Jul 2020 09:24:28 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id x72so9208185pfc.6 for ; Tue, 07 Jul 2020 09:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5rypinuxXWPOxBq0owicS6HAyIDLu+UTWiTWHRsqzsM=; b=a6KuHtzO7bUw2Zu7AcFiqm+FYYpWbMKNAVPXezA5PYDzrmI6qmmgD8/HhryzwUeqcM r4J7H8s+/yyJHzZaS+AzzQTcMDOXUmuX6CxLKeatH/MfvudUFah7Q+a3LqlIeGMgY32X ruNb6uhgvj3iJJGUAnSAFfRuhQXM850/1dplw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5rypinuxXWPOxBq0owicS6HAyIDLu+UTWiTWHRsqzsM=; b=tZQ3AkJEjFgzFVRSUL3RGknV/+5/2ZZqQA4WWr8fFAHnBFaItCz2coXQ1qi0UYDnS9 whyuU5DJb/7O1jef9rbmSBCNctuNLNEALo1STZFiYrFrBZiw59Jm06JS2Y5GfOQTQg3r x7hXipzT2f67FqBCa0XN7eapQ1fKjEX1yD4D70x5FO9R8zX3B8XrwbOhDc/qNtjgo9oX LyULrEsWO/FmjwvVROjooEdpE4UZ1MGoajhLnsF6VXf0uB5dx6OuVV9SV1MeDjj+93mn fQvdWCiKjyIE4rqpW7/vtzhZQ92dgQCEol8uNLk/BawNR4gS750Nu7MgxeOFx24SjC1s 3H/A== X-Gm-Message-State: AOAM533OtXxC74mQN9hijB0GkNeGZrGzk046X8HVDBKjneUw1JwMeRC7 JRwuYgf57BaOcKgOmJZUjxJK1Q== X-Google-Smtp-Source: ABdhPJxmzVAmqiU/WipgiQj/0Er/2Olj3Fa/b4b8Nji1KGrP79hTlLqseViA/H+Uj3J2c0s/KP1Aow== X-Received: by 2002:a05:6a00:790:: with SMTP id g16mr13906032pfu.36.1594139068170; Tue, 07 Jul 2020 09:24:28 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id s10sm3758196pjf.3.2020.07.07.09.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 09:24:27 -0700 (PDT) From: Abhishek Pandit-Subedi To: Greg Kroah-Hartman , linux-pm@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, rafael.j.wysocki@intel.com, swboyd@chromium.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: [PATCH v4 0/1] power: Emit change uevent when updating sysfs Date: Tue, 7 Jul 2020 09:24:16 -0700 Message-Id: <20200707162417.3514284-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: C129952BD6 X-Rspamd-UID: 32a90b Hi linux-pm, ChromeOS has a udev rule to chown the `power/wakeup` attribute so that the power manager can modify it during runtime. (https://source.chromium.org/chromiumos/chromiumos/codesearch/+/master:src/platform2/power_manager/udev/99-powerd-permissions.rules) In our automated tests, we found that the `power/wakeup` attributes weren't being chown-ed for some boards. On investigating, I found that when the drivers probe and call device_set_wakeup_capable, no uevent was being emitted for the newly added power/wakeup attribute. This was manifesting at boot on some boards (Marvell SDIO bluetooth and Broadcom Serial bluetooth drivers) or during usb disconnects during resume (Realtek btusb driver with reset resume quirk). It seems reasonable to me that changes to the attributes of a device should cause a changed uevent so I have added that here. Here's an example of the kernel events after toggling the authorized bit of /sys/bus/usb/devices/1-3/ $ echo 0 > /sys/bus/usb/devices/1-3/authorized KERNEL[27.357994] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill1 (rfkill) KERNEL[27.358049] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[27.358458] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[27.358486] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) KERNEL[27.358529] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) $ echo 1 > /sys/bus/usb/devices/1-3/authorized KERNEL[36.415749] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) KERNEL[36.415798] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[36.417414] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[36.417447] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill2 (rfkill) KERNEL[36.417481] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) Series-version 4 update: Tested again on device and verified it's working as expected: KERNEL[52.678174] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill2 (rfkill) KERNEL[52.678211] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[52.678251] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[52.679721] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) KERNEL[52.679772] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) KERNEL[56.022259] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) KERNEL[56.022306] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[56.022488] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[56.022531] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill3 (rfkill) KERNEL[56.023392] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) Thanks Abhishek Changes in v4: - Fix warning where returning from void and tested on device Changes in v3: - Simplified error handling Changes in v2: - Add newline at end of bt_dev_err Abhishek Pandit-Subedi (1): power: Emit changed uevent on wakeup_sysfs_add/remove drivers/base/power/sysfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GIu/MzmiBF96HwAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:26:33 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ILwPMjmiBF+rswEADc0bRg (envelope-from ); Tue, 07 Jul 2020 18:26:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4868A52DF5; Tue, 7 Jul 2020 18:26:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728283AbgGGQ0T (ORCPT + 1 other); Tue, 7 Jul 2020 12:26:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728036AbgGGQ0S (ORCPT ); Tue, 7 Jul 2020 12:26:18 -0400 Received: from mail-vs1-xe43.google.com (mail-vs1-xe43.google.com [IPv6:2607:f8b0:4864:20::e43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E496C08C5DC for ; Tue, 7 Jul 2020 09:26:18 -0700 (PDT) Received: by mail-vs1-xe43.google.com with SMTP id o15so22821649vsp.12 for ; Tue, 07 Jul 2020 09:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bRr27JuPAO9BtO0TvQuQd84+DLvcv/di5urxMpWy8HU=; b=AMbK+oPGJMrhcLzdTKVqdsj/fnW07exNQ4TfkfoR1gVnKJjaWCGe5xwBxQVmKK+irV fjX5Y8mO1V428PM8obISuijQcpBkW3hAMzyCcsx6xB+puWYTFe36YATxutNJJhA5YkYz /FK0hkJuuyzABQqkl43WR2KDwIVw/lALcBtlI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bRr27JuPAO9BtO0TvQuQd84+DLvcv/di5urxMpWy8HU=; b=rn63Xrc9cjoWGj+CMspbMfulOZje6sd7IOBXIt5PJGcdX6ULGCP6a0x/yQ8Qu0UyuG 5hRJy3M4SQRCRZfQrwOL8ZwjSzRxRtuyCc7EVLf/TjBIeekwmFmo/EQz7qVO3QLK29Qi eUKi68ToqSZclV7KOAZmj1Ke0XuiZg3A3dre2n3OBBOvtfxOh+8LLZhA6cRAbkpAxlnF EvRqCrEygP46pY3tezuOL828toekWSCYpRU0BL9P65rCYxI5osUHtRcE9JT714ObfsXW kNlZ9gUkckqWQSkVIwCsVDJmawKsC9FKLHjnwHQVmw1Mgi7THBrRCJBczZGYPCdKNY+o pTbQ== X-Gm-Message-State: AOAM531f9jb0TTxZ6wnfi6YXFcuqJ4/zIJaDrFwY25dGFlFAlX3kDJJj IhrQLAzETgbqSzogfMTuE2gJM7x+m5/WeWj4mlcUUg== X-Google-Smtp-Source: ABdhPJxCjKbtHJ0QRoS8w68vwUhPXgCL2a51zg3xQGp0FusBhjC89hy1Xe2YrPDkL0SatDDJVVgU9IMvnLThGvduZTU= X-Received: by 2002:a67:6e05:: with SMTP id j5mr32213071vsc.196.1594139177799; Tue, 07 Jul 2020 09:26:17 -0700 (PDT) MIME-Version: 1.0 References: <20200707162417.3514284-1-abhishekpandit@chromium.org> <20200707092406.v4.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> In-Reply-To: <20200707092406.v4.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> From: Abhishek Pandit-Subedi Date: Tue, 7 Jul 2020 09:26:07 -0700 Message-ID: Subject: Re: [PATCH v4 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove To: Greg Kroah-Hartman , Linux PM Cc: Bluez mailing list , ChromeOS Bluetooth Upstreaming , rafael.j.wysocki@intel.com, Stephen Boyd , "Rafael J. Wysocki" , LKML , Len Brown , Pavel Machek Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4868A52DF5 X-Rspamd-UID: 10ef6f Built and tested on Chromebook w/ 5.4 kernel. Sorry about the churn -- will start building with warnings = errors before I send patches upstream. Thanks Abhishek On Tue, Jul 7, 2020 at 9:24 AM Abhishek Pandit-Subedi wrote: > > Udev rules that depend on the power/wakeup attribute don't get triggered > correctly if device_set_wakeup_capable is called after the device is > created. This can happen for several reasons (driver sets wakeup after > device is created, wakeup is changed on parent device, etc) and it seems > reasonable to emit a changed event when adding or removing attributes on > the device. > > Signed-off-by: Abhishek Pandit-Subedi > --- > > Changes in v4: > - Fix warning where returning from void and tested on device > > Changes in v3: > - Simplified error handling > > Changes in v2: > - Add newline at end of bt_dev_err > > drivers/base/power/sysfs.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c > index 24d25cf8ab1487..aeb58d40aac8de 100644 > --- a/drivers/base/power/sysfs.c > +++ b/drivers/base/power/sysfs.c > @@ -1,6 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0 > /* sysfs entries for device PM */ > #include > +#include > #include > #include > #include > @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) > > int wakeup_sysfs_add(struct device *dev) > { > - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > + > + if (ret) > + return ret; > + > + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); > } > > void wakeup_sysfs_remove(struct device *dev) > { > sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); > + kobject_uevent(&dev->kobj, KOBJ_CHANGE); > } > > int pm_qos_sysfs_add_resume_latency(struct device *dev) > -- > 2.27.0.212.ge8ba1cc988-goog > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GKe8EK6iBF9INgAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:28:30 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id eIy1Dq6iBF/jrAEADc0bRg (envelope-from ); Tue, 07 Jul 2020 18:28:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9955152C51; Tue, 7 Jul 2020 18:28:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728172AbgGGQ2S (ORCPT + 1 other); Tue, 7 Jul 2020 12:28:18 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:46180 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbgGGQ2S (ORCPT ); Tue, 7 Jul 2020 12:28:18 -0400 Received: by mail-oi1-f193.google.com with SMTP id l63so33924109oih.13; Tue, 07 Jul 2020 09:28:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qqA8J6CgHJ1oaRzYuw9U/pBjnnBjCWF7/6JXnD6SNeI=; b=fAiVt3yqIgVL/Vd9TRAgthE4dRaHiCqRkxSnfarLUPMS4LYutAu8xdEPhJoA4bi1pw ne+rdWwu/aQAaFAuqIVf6IhdMBWAy8XRlMOowocJ1sYWMhD0srRbqDv89rlbaN1lLCoD XbGJ892l6I7pVFjPd1ngGQgTn/dGqaWpqXVZl4vhf8M47bXZdysOt/0C1mTkYbGxT7B8 xvqn1X1xssyxWuJTpJQZS5pwKr2e84+Cn2qinjANbazLFS6iUiph9U9GwLYdaVN2yn2N 7Wped44lTUlbjZ2Xt3V9lkaaWTm1VM0uLXkOpIazHk53EK/Hl3oD+xBUAgLekBUK3cER X/wQ== X-Gm-Message-State: AOAM530Y4wubsuDnbmiZXxo9vUubteHb0wgrD+VSwvzdp37gXBro5BHr GTZpZ4wFHZJn053oxSPBGllrVQJ75OdKc2vfBoo= X-Google-Smtp-Source: ABdhPJwWEu1nW2hVdT2oditOw+IT/F4slchce0IYqSxCLUtcrqN8q00tngKV7H/5HMxNHixTJq1zO157Gf900Ep315g= X-Received: by 2002:aca:f58a:: with SMTP id t132mr3798335oih.68.1594139296771; Tue, 07 Jul 2020 09:28:16 -0700 (PDT) MIME-Version: 1.0 References: <20200707162417.3514284-1-abhishekpandit@chromium.org> <20200707092406.v4.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> In-Reply-To: <20200707092406.v4.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> From: "Rafael J. Wysocki" Date: Tue, 7 Jul 2020 18:28:05 +0200 Message-ID: Subject: Re: [PATCH v4 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove To: Abhishek Pandit-Subedi Cc: Greg Kroah-Hartman , Linux PM , "open list:BLUETOOTH DRIVERS" , chromeos-bluetooth-upstreaming@chromium.org, Rafael Wysocki , Stephen Boyd , "Rafael J. Wysocki" , Linux Kernel Mailing List , Len Brown , Pavel Machek Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9955152C51 X-Rspamd-UID: ce01fb On Tue, Jul 7, 2020 at 6:24 PM Abhishek Pandit-Subedi wrote: > > Udev rules that depend on the power/wakeup attribute don't get triggered > correctly if device_set_wakeup_capable is called after the device is > created. This can happen for several reasons (driver sets wakeup after > device is created, wakeup is changed on parent device, etc) and it seems > reasonable to emit a changed event when adding or removing attributes on > the device. > > Signed-off-by: Abhishek Pandit-Subedi > --- > > Changes in v4: > - Fix warning where returning from void and tested on device > > Changes in v3: > - Simplified error handling > > Changes in v2: > - Add newline at end of bt_dev_err > > drivers/base/power/sysfs.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c > index 24d25cf8ab1487..aeb58d40aac8de 100644 > --- a/drivers/base/power/sysfs.c > +++ b/drivers/base/power/sysfs.c > @@ -1,6 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0 > /* sysfs entries for device PM */ > #include > +#include > #include > #include > #include > @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) > > int wakeup_sysfs_add(struct device *dev) > { > - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > + > + if (ret) > + return ret; > + > + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); So let me repeat the previous comment: If you return an error here, it may confuse the caller to think that the operation has failed completely, whereas the merging of the attribute group has been successful already. I don't think that an error can be returned at this point. > } > > void wakeup_sysfs_remove(struct device *dev) > { > sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); > + kobject_uevent(&dev->kobj, KOBJ_CHANGE); > } > > int pm_qos_sysfs_add_resume_latency(struct device *dev) > -- > 2.27.0.212.ge8ba1cc988-goog > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2E1hBYmmBF9INgAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:44:57 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UAvdA4mmBF9v/wEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 18:44:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 61334A2992; Tue, 7 Jul 2020 18:44:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728122AbgGGQot (ORCPT + 1 other); Tue, 7 Jul 2020 12:44:49 -0400 Received: from mga03.intel.com ([134.134.136.65]:62900 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbgGGQot (ORCPT ); Tue, 7 Jul 2020 12:44:49 -0400 IronPort-SDR: LfPdDm9L2YEyqXQFYfEaCz73AXcz8XGvybsbrwAVSvlU14JRNKlRMe0tQNrEd3QFKhfqRZL77I +NfLn6oAL7RQ== X-IronPort-AV: E=McAfee;i="6000,8403,9675"; a="147657526" X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="147657526" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2020 09:44:41 -0700 IronPort-SDR: sjwYZw1bSqGtv389avo8bjKvuUYNTxpyaoI292FaUiM/VRv2C1RCDzXrZSXsB4SyaTvNIHS61f 1HK+P5oItxpQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="323592435" Received: from jdlachim-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.230.123]) by orsmga007.jf.intel.com with ESMTP; 07 Jul 2020 09:44:40 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 2/2] tools/mesh: Get rid of "unreliable opcodes" in models Date: Tue, 7 Jul 2020 09:44:39 -0700 Message-Id: <20200707164439.24146-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200707164439.24146-1-inga.stotland@intel.com> References: <20200707164439.24146-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: 61334A2992 X-Rspamd-UID: 00abda This removes an old notion of unreliable opcodes in models , i.e., a correctly formatted acknowledged message always gets a response. --- tools/mesh-gatt/config-client.c | 2 +- tools/mesh-gatt/config-server.c | 2 +- tools/mesh-gatt/onoff-model.c | 2 +- tools/mesh-gatt/util.h | 2 -- tools/mesh/cfgcli.c | 4 ++-- tools/mesh/model.h | 1 - 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/mesh-gatt/config-client.c b/tools/mesh-gatt/config-client.c index ed31c67d9..bfc788258 100644 --- a/tools/mesh-gatt/config-client.c +++ b/tools/mesh-gatt/config-client.c @@ -100,7 +100,7 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data, if (primary != src) return false; - switch (opcode & ~OP_UNRELIABLE) { + switch (opcode) { default: return false; diff --git a/tools/mesh-gatt/config-server.c b/tools/mesh-gatt/config-server.c index 8fc6edcc0..9e9b93959 100644 --- a/tools/mesh-gatt/config-server.c +++ b/tools/mesh-gatt/config-server.c @@ -73,7 +73,7 @@ static bool server_msg_recvd(uint16_t src, uint8_t *data, n = 0; - switch (opcode & ~OP_UNRELIABLE) { + switch (opcode) { default: return false; diff --git a/tools/mesh-gatt/onoff-model.c b/tools/mesh-gatt/onoff-model.c index 92c9a3105..be519c969 100644 --- a/tools/mesh-gatt/onoff-model.c +++ b/tools/mesh-gatt/onoff-model.c @@ -123,7 +123,7 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data, len, opcode); print_byte_array("\t",data, len); - switch (opcode & ~OP_UNRELIABLE) { + switch (opcode) { default: return false; diff --git a/tools/mesh-gatt/util.h b/tools/mesh-gatt/util.h index c3facfa73..dba2c480b 100644 --- a/tools/mesh-gatt/util.h +++ b/tools/mesh-gatt/util.h @@ -25,8 +25,6 @@ struct mesh_publication; -#define OP_UNRELIABLE 0x0100 - void set_menu_prompt(const char *name, const char *id); void print_byte_array(const char *prefix, const void *ptr, int len); bool str2hex(const char *str, uint16_t in_len, uint8_t *out_buf, diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c index 218e82c50..e36c8dca5 100644 --- a/tools/mesh/cfgcli.c +++ b/tools/mesh/cfgcli.c @@ -416,7 +416,7 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data, bt_shell_printf("Received %s (len %u)\n", opcode_str(opcode), len); - req = get_req_by_rsp(src, (opcode & ~OP_UNRELIABLE)); + req = get_req_by_rsp(src, opcode); if (req) { cmd = req->cmd; free_request(req); @@ -424,7 +424,7 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data, } else cmd = NULL; - switch (opcode & ~OP_UNRELIABLE) { + switch (opcode) { default: return false; diff --git a/tools/mesh/model.h b/tools/mesh/model.h index 449fe19b2..35bb80efc 100644 --- a/tools/mesh/model.h +++ b/tools/mesh/model.h @@ -18,7 +18,6 @@ * */ -#define OP_UNRELIABLE 0x0100 #define VENDOR_ID_INVALID 0xFFFF typedef bool (*model_send_msg_func_t) (void *user_data, uint16_t dst, -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SLUXHY6mBF8pCQAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:45:02 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id OA13G46mBF/h8gEAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 18:45:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 336E2A105C; Tue, 7 Jul 2020 18:44:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728155AbgGGQot (ORCPT + 1 other); Tue, 7 Jul 2020 12:44:49 -0400 Received: from mga03.intel.com ([134.134.136.65]:62900 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728073AbgGGQot (ORCPT ); Tue, 7 Jul 2020 12:44:49 -0400 IronPort-SDR: 4MMHdr2gbIQbT9W2XLLV/MwOsyUhWBDfncWD7lA76htGQRnumqNBb2PQZ5TcQZAmTfVd+XfqsU eakmiqgQslwQ== X-IronPort-AV: E=McAfee;i="6000,8403,9675"; a="147657525" X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="147657525" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2020 09:44:40 -0700 IronPort-SDR: JLP6Xz/YBRmEUso3fbskmMKTEYHUoAE+f0LEAY67oo4ZRwa8GmEF64m2AzHmQrkO2paptUhRI8 cXIwwojdTClw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="323592430" Received: from jdlachim-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.230.123]) by orsmga007.jf.intel.com with ESMTP; 07 Jul 2020 09:44:40 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 1/2] mesh: Get rid of "unreliable opcodes" in config server Date: Tue, 7 Jul 2020 09:44:38 -0700 Message-Id: <20200707164439.24146-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 28 X-Rspamd-Score: 4.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: 336E2A105C X-Rspamd-UID: 95f0af This removes an old notion of unreliable opcodes in config server model , i.e., a correctly formatted acknowledged message always gets a response. --- mesh/cfgmod-server.c | 31 +++++++++++-------------------- mesh/model.h | 2 -- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index c525d9d24..8ba9bc6ec 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -98,9 +98,8 @@ static void config_pub_get(struct mesh_node *node, uint16_t net_idx, } static void config_pub_set(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, bool virt, - bool vendor, bool unreliable) + uint16_t src, uint16_t dst, + const uint8_t *pkt, bool virt, bool vendor) { uint32_t mod_id; uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; @@ -143,9 +142,8 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, status, ele_addr, ota, mod_id, idx); if (status != MESH_STATUS_SUCCESS) { - if (!unreliable) - send_pub_status(node, net_idx, src, dst, status, - ele_addr, mod_id, 0, 0, 0, 0, 0, 0); + send_pub_status(node, net_idx, src, dst, status, ele_addr, + mod_id, 0, 0, 0, 0, 0, 0); return; } @@ -180,10 +178,8 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, status = MESH_STATUS_STORAGE_FAIL; } - if (!unreliable) - send_pub_status(node, net_idx, src, dst, status, ele_addr, - mod_id, ota, idx, cred_flag, ttl, - period, retransmit); + send_pub_status(node, net_idx, src, dst, status, ele_addr, mod_id, ota, + idx, cred_flag, ttl, period, retransmit); } static void send_sub_status(struct mesh_node *node, uint16_t net_idx, @@ -311,7 +307,6 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, bool virt, uint32_t opcode) { uint16_t grp, ele_addr; - bool unreliable = !!(opcode & OP_UNRELIABLE); uint32_t mod_id; const uint8_t *addr = NULL; int status = MESH_STATUS_SUCCESS; @@ -369,7 +364,7 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, } else grp = UNASSIGNED_ADDRESS; - switch (opcode & ~OP_UNRELIABLE) { + switch (opcode) { default: l_debug("Bad opcode: %x", opcode); return; @@ -411,8 +406,8 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, grp = UNASSIGNED_ADDRESS; /* Fall Through */ case OP_CONFIG_MODEL_SUB_DELETE: - status = mesh_model_sub_del(node, ele_addr, mod_id, - addr, virt, &grp); + status = mesh_model_sub_del(node, ele_addr, mod_id, addr, virt, + &grp); if (status == MESH_STATUS_SUCCESS) save_config_sub(node, ele_addr, mod_id, vendor, addr, @@ -421,10 +416,7 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, break; } - if (!unreliable) - send_sub_status(node, net_idx, src, dst, status, ele_addr, - grp, mod_id); - + send_sub_status(node, net_idx, src, dst, status, ele_addr, grp, mod_id); } static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, @@ -786,8 +778,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, return true; config_pub_set(node, net_idx, src, dst, pkt, virt, - size == 13 || size == 27, - !!(opcode & OP_UNRELIABLE)); + size == 13 || size == 27); break; case OP_CONFIG_MODEL_PUB_GET: diff --git a/mesh/model.h b/mesh/model.h index f717fb00c..0377d3fdd 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -19,8 +19,6 @@ struct mesh_model; -#define OP_UNRELIABLE 0x0100 - #define MAX_BINDINGS 10 #define MAX_GRP_PER_MOD 10 -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aPhkDVOnBF+aVgAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 18:48:19 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 2JeEC1OnBF8AHgEAlScrYA (envelope-from ); Tue, 07 Jul 2020 18:48:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C132440079; Tue, 7 Jul 2020 18:48:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728185AbgGGQsG (ORCPT + 1 other); Tue, 7 Jul 2020 12:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727886AbgGGQsE (ORCPT ); Tue, 7 Jul 2020 12:48:04 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0EE9C08C5DC for ; Tue, 7 Jul 2020 09:48:04 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id u133so9353191vsc.0 for ; Tue, 07 Jul 2020 09:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1eWoCnOASAKMtuQZyGLOuX3o7NTlzqUAEG+oBEPWKJ8=; b=El0vxZtqg6JPxeKZyM66PqiJ4jyD0i9lHL6yotyIIDUC+AViY0YG4D/79jNwjMUabw 9Pr+v/FoxAAvwkEMHuljUs0iNcnGbyDN1kDvHa6dchgrr3JbLcEOq/qc5RS43jbf9URR JVyJb24B6MSCghW0Q5LihVIf3+BHxKMaYaFA8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1eWoCnOASAKMtuQZyGLOuX3o7NTlzqUAEG+oBEPWKJ8=; b=hGrUVRhJSxdsONG/siCW+ff4VpSiiErIOq5OWafvjDi9dctElV28NRjSuM2PHKx2QJ Dsd7MoqCfsWHq16ifeuuayy6bCtOmNglQtVq5vUlRM9R++7Rjx95biLtDLS69wcZ43ni 72IoUKwX0JjNpn+rWoIF918FG64tyuy51Z2fveQV1hDVnqxhCMChENYxCEz8WwBN3T80 WEjJ7FKQsQk/sveZKERsu3KKjaD+P/pyvDvyvdIcPuM2feh4aNyl1dkHppUfdQII24mR 5luiChznnn0CADqTKR/pDP3rGghs4hqfQNWIY40uKRgl1W6UMDOgtd20KDxati13MKh2 f+vQ== X-Gm-Message-State: AOAM530Av1XtvEEfWJWYOawlRii/WvzTYjeZ4q5mZTuhHkxlMBmp4ZUN kLvvXNo68wYPty7Taf8TKOxP93CNiTYWy0GYTwUUvg== X-Google-Smtp-Source: ABdhPJysq8+6FxhpZrg1dgwHaUrHRyK3KI93qSdqzWL6HNijbQcEkUjFbxYm09sE8WLnXhQ1UoylWLanSIj9IJCT5bo= X-Received: by 2002:a67:c90c:: with SMTP id w12mr30280616vsk.86.1594140483655; Tue, 07 Jul 2020 09:48:03 -0700 (PDT) MIME-Version: 1.0 References: <20200707162417.3514284-1-abhishekpandit@chromium.org> <20200707092406.v4.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> In-Reply-To: From: Abhishek Pandit-Subedi Date: Tue, 7 Jul 2020 09:47:52 -0700 Message-ID: Subject: Re: [PATCH v4 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove To: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman , Linux PM , "open list:BLUETOOTH DRIVERS" , ChromeOS Bluetooth Upstreaming , Rafael Wysocki , Stephen Boyd , "Rafael J. Wysocki" , Linux Kernel Mailing List , Len Brown , Pavel Machek Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: C132440079 X-Rspamd-UID: 70b208 Hi Rafael, (resent in plain text) On Tue, Jul 7, 2020 at 9:28 AM Rafael J. Wysocki wrote: > > On Tue, Jul 7, 2020 at 6:24 PM Abhishek Pandit-Subedi > wrote: > > > > Udev rules that depend on the power/wakeup attribute don't get triggered > > correctly if device_set_wakeup_capable is called after the device is > > created. This can happen for several reasons (driver sets wakeup after > > device is created, wakeup is changed on parent device, etc) and it seems > > reasonable to emit a changed event when adding or removing attributes on > > the device. > > > > Signed-off-by: Abhishek Pandit-Subedi > > --- > > > > Changes in v4: > > - Fix warning where returning from void and tested on device > > > > Changes in v3: > > - Simplified error handling > > > > Changes in v2: > > - Add newline at end of bt_dev_err > > > > drivers/base/power/sysfs.c | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c > > index 24d25cf8ab1487..aeb58d40aac8de 100644 > > --- a/drivers/base/power/sysfs.c > > +++ b/drivers/base/power/sysfs.c > > @@ -1,6 +1,7 @@ > > // SPDX-License-Identifier: GPL-2.0 > > /* sysfs entries for device PM */ > > #include > > +#include > > #include > > #include > > #include > > @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) > > > > int wakeup_sysfs_add(struct device *dev) > > { > > - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > > + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > > + > > + if (ret) > > + return ret; > > + > > + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); > > So let me repeat the previous comment: > > If you return an error here, it may confuse the caller to think that > the operation has failed completely, whereas the merging of the > attribute group has been successful already. > > I don't think that an error can be returned at this point. > The caller looks at the return code and just logs that an error occurred (no other action). It's also unlikely for kobject_uevent to fail (I saw mostly -ENOMEM and an -ENOENT when the kobj wasn't in the correct set). Call site: int ret = wakeup_sysfs_add(dev); if (ret) dev_info(dev, "Wakeup sysfs attributes not added\n"); So I'm ok with either keeping this as-is (caller isn't getting confused, just logging) or swallowing the return of kobject_uevent. > > } > > > > void wakeup_sysfs_remove(struct device *dev) > > { > > sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); > > + kobject_uevent(&dev->kobj, KOBJ_CHANGE); > > } > > > > int pm_qos_sysfs_add_resume_latency(struct device *dev) > > -- > > 2.27.0.212.ge8ba1cc988-goog > > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wM2YKcqtBF+IaAAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 19:15:54 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 4I76J8qtBF94JwAA0J78UA (envelope-from ); Tue, 07 Jul 2020 19:15:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C20B8A2BA3; Tue, 7 Jul 2020 19:15:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728519AbgGGRPs (ORCPT + 1 other); Tue, 7 Jul 2020 13:15:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728208AbgGGRPq (ORCPT ); Tue, 7 Jul 2020 13:15:46 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C990DC061755 for ; Tue, 7 Jul 2020 10:15:45 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id m26so25194093lfo.13 for ; Tue, 07 Jul 2020 10:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=sJDZPklgLSz+bMRCtm1xi8y9hsWb4olH788+hzSKmpc=; b=WU2bb6PfdBoznpT00kQbPfsp33gzKy0a5KqENwSsU/gVoWIvE49o5u2I+6Sez81hbH w5fYuOus/0PYiDWA+RkRzY9ezg1OhuCGxVUfNf85Cv4g/29s/FhS8WbIKh4jDMEbOp1p B5+ZVSvp2WtzIfDvCw5QXs9NwbWsSKpo7YNPIf2U5Zy+yrNV6y4Q+NNmp3SotlKVaNUH r5QFHef5Xni4w6CsBCC3IXFE0lAPQQcnVZ4ocsC06VpM0PTLBNMCU7NeKu79Pdg/JpXg wDr/Ihr7cZ17ygR3kCgN0P1uAdg2sltX4LAirT86NQdzYfI+ZhbKAymYDj/OGLHeqn7n 1LZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=sJDZPklgLSz+bMRCtm1xi8y9hsWb4olH788+hzSKmpc=; b=uMavb3GhOSRaQ5M9fyEEHAxkxCF4cieza5NFukAZ540TQZbTwalqDYRpmOOFGKZVfz coIiSt2/G0oTPkbe+B7HBNomsL9WCml8+VkVz7NAWLCWL/nSd8YoOtt8toRkctwb8lUS 42394t4CcEImyQ/ObIoPjQNXwEtgGXde9q6vkL/qyD7dVNOL2hvc0uFqIsws0BJjwzxn 8KkzxYxPFu90pyCXQzwn7IPBLgkqErHgid0KA936uu3y8ZVQd/LGdUkCTvmyFkcUYIdc aIbD+FNxpbamyqaRLy8SJM+nn4rG8VknJTp8nDkEsEge3eZiR3cjfJGgP8G8ikF1p+py YDAg== X-Gm-Message-State: AOAM531++kN+P9l7IaoEKoLu6/aYBBkAEn9Q0kLOH6eA3Yzam7bnzbVU SacybgqufV3exFqQ6O5+OyUvmxHYjdjMoWHE0xtyiw== X-Google-Smtp-Source: ABdhPJw0O/NQ9Ttp8qPZtYIS6Gf/pmCpEN6ZaMZtLnMb2C0HbUS0zh7XzrX5OjjGaDJ11wyJklRuNze8RLtFhwec+f4= X-Received: by 2002:a19:ad41:: with SMTP id s1mr17609418lfd.191.1594142143948; Tue, 07 Jul 2020 10:15:43 -0700 (PDT) MIME-Version: 1.0 References: <20200707141628.368748-1-alainm@chromium.org> <67268C4E-674E-4DE9-B642-E1CAE8748E28@holtmann.org> In-Reply-To: <67268C4E-674E-4DE9-B642-E1CAE8748E28@holtmann.org> From: Alain Michaud Date: Tue, 7 Jul 2020 13:15:32 -0400 Message-ID: Subject: Re: [PATCH v2] Bluetooth: create CONFIG_BT_DEBUG_FEATURE_FUNC_NAME To: Marcel Holtmann Cc: Alain Michaud , BlueZ , Archie Pusaka Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: C20B8A2BA3 X-Rspamd-UID: cc1a00 On Tue, Jul 7, 2020 at 11:53 AM Marcel Holtmann wrote= : > > Hi Alain, > > > Creates a CONFIG_BT_DEBUG_FEATURE_FUNC_NAME option to include function = names in > > debug statements. > > > > Unlike other platforms __func__ isn't a string literal so it cannot be > > automatically concatenated by the pre-processor. As a result, the > > function name is passed as a parameter to the tracing function. Since > > pr_debug is a function like macro, the normal expansion of BT_PREFIX_PA= RAM > > does not work as it gets processed within the first parameter as well, > > for this reason, BT_DBG is split into two versions. > > > > This patch was built tested with all 4 possible combinations of > > CONFIG_BT_DEBUG_FUNC_NAME and CONFIG_BT_FEATURE_DEBUG configurations. > > > > Signed-off-by: Alain Michaud > > Reviewed-by: Archie Pusaka > > --- > > > > Changes in v2: > > - Making CONFIG_BT_DEBUG_FEATURE_FUNC_NAME dependent on > > CONFIG_BT_DEBUG_FEATURE > > > > include/net/bluetooth/bluetooth.h | 32 +++++++++++++++++++++++-------- > > net/bluetooth/Kconfig | 11 +++++++++++ > > 2 files changed, 35 insertions(+), 8 deletions(-) > > > > diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/= bluetooth.h > > index 7ee8041af803..8506dd268d4b 100644 > > --- a/include/net/bluetooth/bluetooth.h > > +++ b/include/net/bluetooth/bluetooth.h > > @@ -162,22 +162,37 @@ void bt_dbg_set(bool enable); > > bool bt_dbg_get(void); > > __printf(1, 2) > > void bt_dbg(const char *fmt, ...); > > +#define BT_DBG_INT bt_dbg > > +#else > > +#define BT_DBG_INT pr_debug > > #endif > > __printf(1, 2) > > void bt_warn_ratelimited(const char *fmt, ...); > > __printf(1, 2) > > void bt_err_ratelimited(const char *fmt, ...); > > > > -#define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__) > > -#define BT_WARN(fmt, ...) bt_warn(fmt "\n", ##__VA_ARGS__) > > -#define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) > > - > > -#if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG) > > -#define BT_DBG(fmt, ...) bt_dbg(fmt "\n", ##__VA_ARGS__) > > +#if IS_ENABLED(BT_FEATURE_DEBUG_FUNC_NAMES) > > are you sure you tested this? This was tested on chromeos using this patch chain which also sets the configuration and revert our original patch: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/= 2279613 > > > And frankly I don=E2=80=99t get the point for the new Kconfig option. It = is rather useless in this patch. Tell me one thing, do you prefer that FEAT= URE_DEBUG prints the function names or not. Because if dynamic debug is use= d, we don=E2=80=99t need it since that is all configurable via dynamic debu= g itself and we don=E2=80=99t need it there (and I also don=E2=80=99t want = it in the dynamic debug case). I'd be ok if we unconditionally print function names if CONFIG_BT_FEATURE_DEBUG is set. what I want to avoid is to overly complicate the debug macros to have the function names configurable at runtime. > > Regards > > Marcel > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ACxhOwiuBF9kfQAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 19:16:56 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id IHODOQiuBF/qMAEAlScrYA (envelope-from ); Tue, 07 Jul 2020 19:16:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 41464A2317; Tue, 7 Jul 2020 19:16:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728267AbgGGRQo (ORCPT + 1 other); Tue, 7 Jul 2020 13:16:44 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:37235 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727886AbgGGRQn (ORCPT ); Tue, 7 Jul 2020 13:16:43 -0400 Received: by mail-ot1-f68.google.com with SMTP id w17so27027483otl.4; Tue, 07 Jul 2020 10:16:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TUdKoU1H+z8qeBTxQdM+SPgy95nTHPoa7jpopZEDv8Y=; b=Pf6FMT5LyEMitO9qDPArxDr4uMH/z/aW3bgwB682VenojpZ1OL3XD4exe5l3VC99rM b8KeATINejGg2ywbQa75nwXG+kjYfGOIHpN+jIIF9dsmkgQ8usP2utRu/MuteJVJKnl/ BjaQRfr/LQipscWjSUNq93QvZm5q9gy25mHYMfZdwlrVvMFOexza0nu3A5/Km2il6r3j T0GqLb3OqGY6ZKDS+2r/5GAlsFdybpwcY9jDK8lr9J/TRiegRQtpI9gQVcUnClsnnCu7 /Xl8GNEgBjIyoGOetVldvar/UgMsHtq4BI1MTAtqNCn4Z7z80cK8uCHjohq8gO3UitAs wb2w== X-Gm-Message-State: AOAM531x+oKnoQQT+oNWQzSrWfcHD7rmG2ZvegSdZ5BAXccEppmjXmtf c6+DDfLx7xH41Iz0sWRRheOwOZKtNnzXf3Eqthc= X-Google-Smtp-Source: ABdhPJx8HATaz0zjRx9gs1OrA241/fnh2U+zL02uEuN+UC4P7Dh1KnovbuqHuDqumPh5Ub2BG0nc5bCvGslWULqn6lk= X-Received: by 2002:a9d:590a:: with SMTP id t10mr9944178oth.262.1594142202516; Tue, 07 Jul 2020 10:16:42 -0700 (PDT) MIME-Version: 1.0 References: <20200707162417.3514284-1-abhishekpandit@chromium.org> <20200707092406.v4.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> In-Reply-To: From: "Rafael J. Wysocki" Date: Tue, 7 Jul 2020 19:16:31 +0200 Message-ID: Subject: Re: [PATCH v4 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove To: Abhishek Pandit-Subedi Cc: "Rafael J. Wysocki" , Greg Kroah-Hartman , Linux PM , "open list:BLUETOOTH DRIVERS" , ChromeOS Bluetooth Upstreaming , Rafael Wysocki , Stephen Boyd , "Rafael J. Wysocki" , Linux Kernel Mailing List , Len Brown , Pavel Machek Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.09 / 15.00 / 200.00 X-Rspamd-Queue-Id: 41464A2317 X-Rspamd-UID: 38eb3a On Tue, Jul 7, 2020 at 6:48 PM Abhishek Pandit-Subedi wrote: > > Hi Rafael, > > (resent in plain text) > > On Tue, Jul 7, 2020 at 9:28 AM Rafael J. Wysocki wrote: > > > > On Tue, Jul 7, 2020 at 6:24 PM Abhishek Pandit-Subedi > > wrote: > > > > > > Udev rules that depend on the power/wakeup attribute don't get triggered > > > correctly if device_set_wakeup_capable is called after the device is > > > created. This can happen for several reasons (driver sets wakeup after > > > device is created, wakeup is changed on parent device, etc) and it seems > > > reasonable to emit a changed event when adding or removing attributes on > > > the device. > > > > > > Signed-off-by: Abhishek Pandit-Subedi > > > --- > > > > > > Changes in v4: > > > - Fix warning where returning from void and tested on device > > > > > > Changes in v3: > > > - Simplified error handling > > > > > > Changes in v2: > > > - Add newline at end of bt_dev_err > > > > > > drivers/base/power/sysfs.c | 9 ++++++++- > > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c > > > index 24d25cf8ab1487..aeb58d40aac8de 100644 > > > --- a/drivers/base/power/sysfs.c > > > +++ b/drivers/base/power/sysfs.c > > > @@ -1,6 +1,7 @@ > > > // SPDX-License-Identifier: GPL-2.0 > > > /* sysfs entries for device PM */ > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) > > > > > > int wakeup_sysfs_add(struct device *dev) > > > { > > > - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > > > + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > > > + > > > + if (ret) > > > + return ret; > > > + > > > + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); > > > > So let me repeat the previous comment: > > > > If you return an error here, it may confuse the caller to think that > > the operation has failed completely, whereas the merging of the > > attribute group has been successful already. > > > > I don't think that an error can be returned at this point. > > > > The caller looks at the return code and just logs that an error > occurred (no other action). It's also unlikely for kobject_uevent to > fail (I saw mostly -ENOMEM and an -ENOENT when the kobj wasn't in the > correct set). > > Call site: > int ret = wakeup_sysfs_add(dev); > > if (ret) > dev_info(dev, "Wakeup sysfs attributes not added\n"); Yes, which is confusing, because the wakeup attributes may in fact have been added. Which is my point. > > So I'm ok with either keeping this as-is (caller isn't getting > confused, just logging) or swallowing the return of kobject_uevent. I would just ignore the return value of kobject_uevent() along the lines of wakeup_sysfs_remove() below. Thanks! > > > } > > > > > > void wakeup_sysfs_remove(struct device *dev) > > > { > > > sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); > > > + kobject_uevent(&dev->kobj, KOBJ_CHANGE); > > > } > > > > > > int pm_qos_sysfs_add_resume_latency(struct device *dev) > > > -- > > > 2.27.0.212.ge8ba1cc988-goog > > > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eLmwGGquBF9tcQAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 19:18:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id UFEGF2quBF91NwEAlScrYA (envelope-from ); Tue, 07 Jul 2020 19:18:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D178FA238F; Tue, 7 Jul 2020 19:18:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727975AbgGGRS2 (ORCPT + 1 other); Tue, 7 Jul 2020 13:18:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728036AbgGGRS1 (ORCPT ); Tue, 7 Jul 2020 13:18:27 -0400 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57C14C08C5E1 for ; Tue, 7 Jul 2020 10:18:27 -0700 (PDT) Received: by mail-vs1-xe42.google.com with SMTP id s20so15562970vsq.5 for ; Tue, 07 Jul 2020 10:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=74Xd65ujs50AwKytINLgt7qtTa7IevS/aqZRV1i9Rd8=; b=UWYVic96pOSZRZsRmw2D0xW579eTy1JPNBw9lI+/tOGAhV3ymR2VcORJIdFnYMXlx/ Pyh7l5oLPF9TOnZJYezcZKg0Et63e+3Ah4oPnZkC/aFt8IXpEP/Dw63qRvAoiZeMGyTl BkYS5dtdJ+VAfBgPrKdTozMDQ4weGwZxX/96E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=74Xd65ujs50AwKytINLgt7qtTa7IevS/aqZRV1i9Rd8=; b=h2RN3GMo8vyYVplFxs++00qy1m8MO+BiW91rBO325l9jPN07lquZ80FNXWvSyabFIp l/RgjZtCjJQk2AF8s3MyVI2aRCp0VGPQBMNUIw/IP+2/HobNYhaAmR/sLh95zHL1Tol5 ABqkN0hrqCDdx/YBcAkDohKHxNt8RkJvQLr3jAV0RWXvq0L9ApAu5UncjhUB8VFQSr0t P5kxw07TSD5LH4WIJVYZS83/MJEqhrSgqctFsIAuTghNq4Ml1NTCNNtBSr+73IKlQjPY OlPADJXEPR/Yz5PaKbJXh+hka21lb42c4JifiyoY/EoyubRXIiClXrufZtZt4A88bEy/ kA2g== X-Gm-Message-State: AOAM533HQO6mKZPyMHJwfYYWqo7m4kgBlGz1//L8HctAdr6Zuu8lexKn 5E7twnDc6CH2QX7/zi5PNDZT2vzJbAv6VfYbppM7vA== X-Google-Smtp-Source: ABdhPJwk+V71z2wv/WQnTefFWymSCRO53UNKZiBT8TehImzf1AUUKNg93mkz/cBBz2gO3h2NY5EkhH6PKev8387kkUo= X-Received: by 2002:a67:6e05:: with SMTP id j5mr32408546vsc.196.1594142306552; Tue, 07 Jul 2020 10:18:26 -0700 (PDT) MIME-Version: 1.0 References: <20200707162417.3514284-1-abhishekpandit@chromium.org> <20200707092406.v4.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> In-Reply-To: From: Abhishek Pandit-Subedi Date: Tue, 7 Jul 2020 10:18:15 -0700 Message-ID: Subject: Re: [PATCH v4 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove To: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman , Linux PM , "open list:BLUETOOTH DRIVERS" , ChromeOS Bluetooth Upstreaming , Rafael Wysocki , Stephen Boyd , "Rafael J. Wysocki" , Linux Kernel Mailing List , Len Brown , Pavel Machek Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: D178FA238F X-Rspamd-UID: 137ad5 Sounds good to me. Patch v5 incoming after compile-test. Thanks Abhishek On Tue, Jul 7, 2020 at 10:16 AM Rafael J. Wysocki wrote: > > On Tue, Jul 7, 2020 at 6:48 PM Abhishek Pandit-Subedi > wrote: > > > > Hi Rafael, > > > > (resent in plain text) > > > > On Tue, Jul 7, 2020 at 9:28 AM Rafael J. Wysocki wrote: > > > > > > On Tue, Jul 7, 2020 at 6:24 PM Abhishek Pandit-Subedi > > > wrote: > > > > > > > > Udev rules that depend on the power/wakeup attribute don't get triggered > > > > correctly if device_set_wakeup_capable is called after the device is > > > > created. This can happen for several reasons (driver sets wakeup after > > > > device is created, wakeup is changed on parent device, etc) and it seems > > > > reasonable to emit a changed event when adding or removing attributes on > > > > the device. > > > > > > > > Signed-off-by: Abhishek Pandit-Subedi > > > > --- > > > > > > > > Changes in v4: > > > > - Fix warning where returning from void and tested on device > > > > > > > > Changes in v3: > > > > - Simplified error handling > > > > > > > > Changes in v2: > > > > - Add newline at end of bt_dev_err > > > > > > > > drivers/base/power/sysfs.c | 9 ++++++++- > > > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c > > > > index 24d25cf8ab1487..aeb58d40aac8de 100644 > > > > --- a/drivers/base/power/sysfs.c > > > > +++ b/drivers/base/power/sysfs.c > > > > @@ -1,6 +1,7 @@ > > > > // SPDX-License-Identifier: GPL-2.0 > > > > /* sysfs entries for device PM */ > > > > #include > > > > +#include > > > > #include > > > > #include > > > > #include > > > > @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) > > > > > > > > int wakeup_sysfs_add(struct device *dev) > > > > { > > > > - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > > > > + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); > > > > + > > > > + if (ret) > > > > + return ret; > > > > + > > > > + return kobject_uevent(&dev->kobj, KOBJ_CHANGE); > > > > > > So let me repeat the previous comment: > > > > > > If you return an error here, it may confuse the caller to think that > > > the operation has failed completely, whereas the merging of the > > > attribute group has been successful already. > > > > > > I don't think that an error can be returned at this point. > > > > > > > The caller looks at the return code and just logs that an error > > occurred (no other action). It's also unlikely for kobject_uevent to > > fail (I saw mostly -ENOMEM and an -ENOENT when the kobj wasn't in the > > correct set). > > > > Call site: > > int ret = wakeup_sysfs_add(dev); > > > > if (ret) > > dev_info(dev, "Wakeup sysfs attributes not added\n"); > > Yes, which is confusing, because the wakeup attributes may in fact > have been added. Which is my point. > > > > > So I'm ok with either keeping this as-is (caller isn't getting > > confused, just logging) or swallowing the return of kobject_uevent. > > I would just ignore the return value of kobject_uevent() along the > lines of wakeup_sysfs_remove() below. > > Thanks! > > > > > } > > > > > > > > void wakeup_sysfs_remove(struct device *dev) > > > > { > > > > sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); > > > > + kobject_uevent(&dev->kobj, KOBJ_CHANGE); > > > > } > > > > > > > > int pm_qos_sysfs_add_resume_latency(struct device *dev) > > > > -- > > > > 2.27.0.212.ge8ba1cc988-goog > > > > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wH2/AvGwBF9tcQAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 19:29:21 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id MFUpAfGwBF+rswEADc0bRg (envelope-from ); Tue, 07 Jul 2020 19:29:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2748852DF1; Tue, 7 Jul 2020 19:29:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728428AbgGGR3C (ORCPT + 1 other); Tue, 7 Jul 2020 13:29:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727777AbgGGR3B (ORCPT ); Tue, 7 Jul 2020 13:29:01 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 879BBC08C5E1 for ; Tue, 7 Jul 2020 10:29:00 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id e18so20312653pgn.7 for ; Tue, 07 Jul 2020 10:29:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gFm0zZsEee0jyOpcffZkH1BBWPUeyZACVROnx5BmvFo=; b=aQ/vxe3ywvqhq7YhSCKxmIKhYaHRQV/lAb0Ay3c3hWSBBVyWq+D/OHnRFO8RNeQtRg 2k//7Epb+Gf4F5KD/StYT7UInpD5GLuyr8RaAU5jBdE3mfl2F0hNn3gYounrtwMBPGFs /rpq/eVGdY4Pz88MPR5amU68PTfCRQRDua2/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gFm0zZsEee0jyOpcffZkH1BBWPUeyZACVROnx5BmvFo=; b=nRl7qK6C3eVivF9Gf6tqRyfe9qZgp6laq8giMi+hWuR6LvrU/12jnUztqvot6Ylxem 4cy0FGZFkcqitmH8Rellhq9KNRE/zlaAtAjGHcuHYgpaldWIQDiJbW/jQGvxSeJeKV59 AUUIjbiizZWy88m8twxau5GLpywTYVnAtpGlke8sGAz04DkggiB4VA+CWA+zSsipS7eW M4RKj5yjaTF+uCumIA8oE8k/j9fy2WOsT/nsIt/omTZU5uNT9GHXtMK/Q8KgP97Ijwxn ElhWtCdwfoeZv2huu8WwMUBAgHTB+IrG9JofPgRGWlXBFkatdwn+PrvdxQDNG9ZxZzyN lPqQ== X-Gm-Message-State: AOAM533KjqbDey0i3GmJk/R1f2cZ5qLW9IYEN+Zmcz/V+kAo2gBmyhQe GqijP5fWMdhZZfFIWse1G3ayqA== X-Google-Smtp-Source: ABdhPJzs7CUdSj1Gwg62L4bJ94/aaSFpSOiduFOUy+QsKRQ9yrQ+xhNyo9VbVBvbbbAX6udNlEsTZA== X-Received: by 2002:a62:fb06:: with SMTP id x6mr50324326pfm.28.1594142940088; Tue, 07 Jul 2020 10:29:00 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id e15sm1414285pgt.17.2020.07.07.10.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 10:28:59 -0700 (PDT) From: Abhishek Pandit-Subedi To: Greg Kroah-Hartman , rafael.j.wysocki@intel.com, linux-pm@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, swboyd@chromium.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: [PATCH v5 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove Date: Tue, 7 Jul 2020 10:28:44 -0700 Message-Id: <20200707102823.v5.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200707172845.4177903-1-abhishekpandit@chromium.org> References: <20200707172845.4177903-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2748852DF1 X-Rspamd-UID: b7fef9 Udev rules that depend on the power/wakeup attribute don't get triggered correctly if device_set_wakeup_capable is called after the device is created. This can happen for several reasons (driver sets wakeup after device is created, wakeup is changed on parent device, etc) and it seems reasonable to emit a changed event when adding or removing attributes on the device. Signed-off-by: Abhishek Pandit-Subedi --- Changes in v5: - Ignore return from kobject_uevent when adding to sysfs Changes in v4: - Fix warning where returning from void and tested on device Changes in v3: - Simplified error handling Changes in v2: - Add newline at end of bt_dev_err drivers/base/power/sysfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index 24d25cf8ab1487..c7b24812523c9e 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* sysfs entries for device PM */ #include +#include #include #include #include @@ -739,12 +740,18 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) int wakeup_sysfs_add(struct device *dev) { - return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); + int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); + + if (!ret) + kobject_uevent(&dev->kobj, KOBJ_CHANGE); + + return ret; } void wakeup_sysfs_remove(struct device *dev) { sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); + kobject_uevent(&dev->kobj, KOBJ_CHANGE); } int pm_qos_sysfs_add_resume_latency(struct device *dev) -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2BurAfWwBF/FkgAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 19:29:25 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id oIYBAPWwBF/N7AEADc0bRg (envelope-from ); Tue, 07 Jul 2020 19:29:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2A76052CDD; Tue, 7 Jul 2020 19:29:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728194AbgGGR3A (ORCPT + 1 other); Tue, 7 Jul 2020 13:29:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728073AbgGGR27 (ORCPT ); Tue, 7 Jul 2020 13:28:59 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F2C3C08C5E1 for ; Tue, 7 Jul 2020 10:28:59 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id o22so13750004pjw.2 for ; Tue, 07 Jul 2020 10:28:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GDk3o4K7Qdy44WeUL6xRZLs/1lKN7Q2+qDuM1ziAKUE=; b=AD6CoW2UICDWk/1zx/l6PEom5Vnjn8v6sAqR+Vebu1tpz3GUosmm3pgGhiWnNTMqEn m+gTH9ORFg6cG+8B+7LfOi7FXvVjWYao93wjk1OI12A4kbeZrQ1mKBOLdFjwX0/wEq0W NkqU+R92VjKbfG/v2osMCZiL9GgHrO1xI5Upo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GDk3o4K7Qdy44WeUL6xRZLs/1lKN7Q2+qDuM1ziAKUE=; b=eQ8b95INMZ123O33lKFHSUb81rGXveGKAYPUCYZMyIvpSRTPBFQj0PAQACIry3QLIR jYCxzESpsglBgtOMYU/eMOpMbaxO7PJ4mE1TI2ySdtReSLTP1pSN7Z2XaWy8fbPzx6EK jn7M7lipXhVANPoarTIh+NtF2IMvTJT2bexzhExJwULL7bWyOvlTnwu7sryvT+FHwdtk a4mhomVNDsGgkmPOa9QBNGG/ZxAn+36uUqvy9A8Gs3XXOcw/4NOUHRkFGU1zd5EeldSZ gHLLGA8SBAwaYGvfoMgJtn/+tFnshFYfLpKuMAAlJZ3P8k65FkP+i+j/hSuqzLYOzSr1 PPcw== X-Gm-Message-State: AOAM530+9iHyUql+AJVajd9D7VIkKLzwdYdpuDGapLURbPBP/yiur9II JMRh4OgJ7o7Qrtzd8HJNyeuHU7wmI0o= X-Google-Smtp-Source: ABdhPJzf226Gragbu1zI/saxunXJOqH4GwQ3BKzo0ajhKJmOD3ROv3HiPeqfCvACm0AL0aY/4IdfFQ== X-Received: by 2002:a17:902:8d89:: with SMTP id v9mr45486975plo.191.1594142938963; Tue, 07 Jul 2020 10:28:58 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id e15sm1414285pgt.17.2020.07.07.10.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 10:28:58 -0700 (PDT) From: Abhishek Pandit-Subedi To: Greg Kroah-Hartman , rafael.j.wysocki@intel.com, linux-pm@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, swboyd@chromium.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: [PATCH v5 0/1] power: Emit change uevent when updating sysfs Date: Tue, 7 Jul 2020 10:28:43 -0700 Message-Id: <20200707172845.4177903-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2A76052CDD X-Rspamd-UID: e97ee3 Hi linux-pm, ChromeOS has a udev rule to chown the `power/wakeup` attribute so that the power manager can modify it during runtime. (https://source.chromium.org/chromiumos/chromiumos/codesearch/+/master:src/platform2/power_manager/udev/99-powerd-permissions.rules) In our automated tests, we found that the `power/wakeup` attributes weren't being chown-ed for some boards. On investigating, I found that when the drivers probe and call device_set_wakeup_capable, no uevent was being emitted for the newly added power/wakeup attribute. This was manifesting at boot on some boards (Marvell SDIO bluetooth and Broadcom Serial bluetooth drivers) or during usb disconnects during resume (Realtek btusb driver with reset resume quirk). It seems reasonable to me that changes to the attributes of a device should cause a changed uevent so I have added that here. Here's an example of the kernel events after toggling the authorized bit of /sys/bus/usb/devices/1-3/ $ echo 0 > /sys/bus/usb/devices/1-3/authorized KERNEL[27.357994] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill1 (rfkill) KERNEL[27.358049] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[27.358458] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[27.358486] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) KERNEL[27.358529] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) $ echo 1 > /sys/bus/usb/devices/1-3/authorized KERNEL[36.415749] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) KERNEL[36.415798] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[36.417414] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[36.417447] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill2 (rfkill) KERNEL[36.417481] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) Series-version 4 update: Tested again on device and verified it's working as expected: KERNEL[52.678174] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill2 (rfkill) KERNEL[52.678211] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[52.678251] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[52.679721] remove /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) KERNEL[52.679772] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) KERNEL[56.022259] change /devices/pci0000:00/0000:00:15.0/usb1/1-3 (usb) KERNEL[56.022306] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0 (usb) KERNEL[56.022488] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0 (bluetooth) KERNEL[56.022531] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.0/bluetooth/hci0/rfkill3 (rfkill) KERNEL[56.023392] add /devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3:1.1 (usb) Thanks Abhishek Changes in v5: - Ignore return from kobject_uevent when adding to sysfs Changes in v4: - Fix warning where returning from void and tested on device Changes in v3: - Simplified error handling Changes in v2: - Add newline at end of bt_dev_err Abhishek Pandit-Subedi (1): power: Emit changed uevent on wakeup_sysfs_add/remove drivers/base/power/sysfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GP3MBDuxBF9tcQAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 19:30:35 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WFWLAzuxBF/05QEADc0bRg (envelope-from ); Tue, 07 Jul 2020 19:30:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8D01552C05; Tue, 7 Jul 2020 19:30:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728386AbgGGRaU (ORCPT + 1 other); Tue, 7 Jul 2020 13:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727834AbgGGRaU (ORCPT ); Tue, 7 Jul 2020 13:30:20 -0400 Received: from mail-ua1-x944.google.com (mail-ua1-x944.google.com [IPv6:2607:f8b0:4864:20::944]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F266C061755 for ; Tue, 7 Jul 2020 10:30:20 -0700 (PDT) Received: by mail-ua1-x944.google.com with SMTP id n4so2360943uae.5 for ; Tue, 07 Jul 2020 10:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xuq/cPtz4H8qHzQbgSRImu0AoYB1hM4DNGsoUIniXWY=; b=fwGbCy9YCvQBDRQlOQ25QRUychesGDZK3sJuyPcvSnyuyS0I22pqF4exaGQ3mQyN/r DayeW+opzCqR2T2qzTTTGrU7hm+4tM5zuU/EtzraZe5onxlrJGgWC5QeLPMJrVcdMSWz ojecYyRdTC/hSK8h0GMUZdKXilvmRHXgpiLdo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xuq/cPtz4H8qHzQbgSRImu0AoYB1hM4DNGsoUIniXWY=; b=PVFxXWFajanDNe+c7OFG8ok9Wi1mX8KnfuOr2PkkSBbGJKD5/ZjPQYMlIXXp13PavN HsHFETgH2tS+ewoYY3tbCKkXecVklYEjxup3qfO12dJcQvW2+w5yrasE0iN/jZlSC4pK x1f6KkVcGqrcHwG1fdOuqyEGfQOv13rJRDoYce2dAy34Z9/09hqUWDGCxtDyEYpKLQjI HFZSH66ELEFOk2/GmpkNDSTiS/JsDK+fCPo0hZAntjN8nrzEPiKOS9mgcKZDBcSehYKv gG8sNLoUk+BVsbFqvSZCDQKKoOZz8cyW8S6Ful4rySZL6kSYaqMjGBYfSmQRZGHPIJZC AxbA== X-Gm-Message-State: AOAM532vJa5+Ffmn9wOIuwT/XfjlynsxQEMek+BgHZtnd7dbv7QuiYME Vp+JiBHkluzISHaNc/8oUb2XxiIAQNo= X-Google-Smtp-Source: ABdhPJxlFpzLk0NFQqzKJTTbvutsQGyOY1l75h8QASiigsice6dgJn/zVDMUT4sJKnZ2+a3gaMyyAA== X-Received: by 2002:a9f:260b:: with SMTP id 11mr38745138uag.49.1594143019041; Tue, 07 Jul 2020 10:30:19 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id r18sm168394vkf.49.2020.07.07.10.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 10:30:18 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud , Chethan Tumkur Narayan Subject: [PATCH v1] Bluetooth: adding BTUSB_VALID_LE_STATES to Intel Controllers Date: Tue, 7 Jul 2020 17:30:15 +0000 Message-Id: <20200707173015.543198-1-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 23 X-Rspamd-Score: 3.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8D01552C05 X-Rspamd-UID: 187510 This patch adds the BTUSB_VALID_LE_STATES to the appropriate Intel controllers. Signed-off-by: Alain Michaud Reviewed-by: Chethan Tumkur Narayan --- drivers/bluetooth/btusb.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index faa863dd5d0a..ca387531b940 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -339,18 +339,23 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH | BTUSB_VALID_LE_STATES }, { USB_DEVICE(0x8087, 0x0026), .driver_info = BTUSB_INTEL_NEW | - BTUSB_WIDEBAND_SPEECH }, + BTUSB_WIDEBAND_SPEECH | + BTUSB_VALID_LE_STATES }, { USB_DEVICE(0x8087, 0x0029), .driver_info = BTUSB_INTEL_NEW | - BTUSB_WIDEBAND_SPEECH }, + BTUSB_WIDEBAND_SPEECH | + BTUSB_VALID_LE_STATES }, { USB_DEVICE(0x8087, 0x0032), .driver_info = BTUSB_INTEL_NEW | - BTUSB_WIDEBAND_SPEECH}, + BTUSB_WIDEBAND_SPEECH | + BTUSB_VALID_LE_STATES }, { USB_DEVICE(0x8087, 0x07da), .driver_info = BTUSB_CSR }, { USB_DEVICE(0x8087, 0x07dc), .driver_info = BTUSB_INTEL }, { USB_DEVICE(0x8087, 0x0a2a), .driver_info = BTUSB_INTEL }, { USB_DEVICE(0x8087, 0x0a2b), .driver_info = BTUSB_INTEL_NEW | - BTUSB_WIDEBAND_SPEECH }, + BTUSB_WIDEBAND_SPEECH | + BTUSB_VALID_LE_STATES }, { USB_DEVICE(0x8087, 0x0aa7), .driver_info = BTUSB_INTEL | - BTUSB_WIDEBAND_SPEECH }, + BTUSB_WIDEBAND_SPEECH | + BTUSB_VALID_LE_STATES }, { USB_DEVICE(0x8087, 0x0aaa), .driver_info = BTUSB_INTEL_NEW | BTUSB_WIDEBAND_SPEECH | BTUSB_VALID_LE_STATES }, -- 2.27.0.212.ge8ba1cc988-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QNe3DTizBF9tcQAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 19:39:04 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id AEBUDDizBF8yswAA0J78UA (envelope-from ); Tue, 07 Jul 2020 19:39:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E8FE7A238F; Tue, 7 Jul 2020 19:38:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727886AbgGGRi6 (ORCPT + 1 other); Tue, 7 Jul 2020 13:38:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727777AbgGGRi6 (ORCPT ); Tue, 7 Jul 2020 13:38:58 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 220EAC061755 for ; Tue, 7 Jul 2020 10:38:58 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id g37so11194511otb.9 for ; Tue, 07 Jul 2020 10:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+iG6/TEYwis8lNrhhxu1yaHgEn0SxtbkRTd4/TNylxg=; b=R9G4+gZ+aaSQistrmzZMbk4rAQF6I+fd1zgQ6NLgL6ysPJhFcJw0HmJ4ydMhDr3l3h 6/9/31DggUK6914jZgPOr69o2WeDaO4FmWJ9fknzek6Kxky3qREbmJUpX0tPFZYFtCIo YLjTmEvCD6m3S4eGb2rapw+fgTPy5zk2DiGc+Q9HlAbh9XXOKtmRjUee0x2sT/JTtrHI Wsa/B8Nzav3FXIZ/odTaG+dwFejeIW9NXVMMdejrC9suU8F8PqQM6xDnjhgQnCE50+fg W+QY7FisxdZ131Xn52JGAtZ7OOkgAep/sSN+wtW+fbmrZzRyAVc4LqGTyA1HezWtxs+i jSFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+iG6/TEYwis8lNrhhxu1yaHgEn0SxtbkRTd4/TNylxg=; b=eaZ+ps8fj5yeaPPW1QhIGeYMfwefKYKL3LA0dynZS+R6Qtdcfv5kxUxOSQhpIFtnaY ZyDzo2vF34MBjpUOrjI3HFUCjstaZrHuo1tJi54GWlf1Nc0L18yidEg9GElC13xVEARU HPkMmrcuagFZ0pcwgkRbW+ztjFEbRlQnJUzTj0jwYj10AulC7FdCQ6ke64hVGTQzPRGt wCspi1SLCWnO6hnujmlspiO+YYWFtbE7ViHtTM/VVq4EOe4TtZtyknuZ4c5P0RmXibBe T9eEQg6x0bCGdX6wIhxG1OGZ9kCnxYL6FYtWhsoET9ETEgWxCGUNaDPCfza0uBy79w9m ErEQ== X-Gm-Message-State: AOAM533pDsK/O9OmE51Apxymf97u96wHtttthMthVXqUqoVAAyaxcOEo FEMMVAd6nr1ZVt4VAvsN9qiXxHw5VrYVxRJuB72XgC7K X-Google-Smtp-Source: ABdhPJy4QeivwJAZQU/YGj4HcsUPvzaIfhP16eAvpjUXXFjNzPwNV91asNUZUJ5fq1oOs8vxsLZyN4/Tu4+c/gQCrV4= X-Received: by 2002:a05:6830:1bd3:: with SMTP id v19mr44037513ota.91.1594143536476; Tue, 07 Jul 2020 10:38:56 -0700 (PDT) MIME-Version: 1.0 References: <20200702220558.3467870-1-luiz.dentz@gmail.com> In-Reply-To: From: Luiz Augusto von Dentz Date: Tue, 7 Jul 2020 10:38:45 -0700 Message-ID: Subject: Re: [RFC] Bluetooth: btusb: Add support for notifying the polling interval To: Marcel Holtmann Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.50 / 15.00 / 200.00 X-Rspamd-Queue-Id: E8FE7A238F X-Rspamd-UID: f95bd0 Hi Marcel On Tue, Jul 7, 2020 at 9:09 AM Marcel Holtmann wrote: > > Hi Luiz, > > > This enables btusb to inform the polling interval used for receiving > > packets, the interval is then used wih rx_work which has been changed > > to be a delayed work. > > > > The interval is then used as a time window where frames received from > > different endpoints are considered to be arrived at same time. > > > > In order to resolve potential conflicts between endpoints a dedicated > > queue for events was introduced and it is now processed before the ACL > > packets. > > > > It worth noting though that priorizing events over ACL data may result > > in inverting the order of the packets over the air, for instance there > > may be packets received before a disconnect event that will be > > discarded and unencrypted packets received before encryption change > > which would considered encrypted, because of these potential inversions > > the support for polling interval is not enabled by default so platforms > > have the following means to enable it: > > we can not touch the core that impacts all transport layers even if they are not broken. So adding the second queue is not something that I think is a good idea. And again, we are just papering over a hole. I guess you are referring to hdev->ev_q, that is only used if the driver calls hci_recv_evt so it doesn't affect the user of hci_recv_frame. > However if you want to queue within btusb driver before sending it to the core, then maybe. That might require introducing a workqueue into btusb though, but perhaps that is not such a big deal given that we are not that concerned on the memory usage, are there any other remarks about the conflict resolution though? I probably will add some text to the Kconfig option stating this is a workaround which may cause reordering of events vs ACL data, but imo it is much cleaner then trying to handle these races on the upper layers since they might not be limited to just Connection Complete and Encryption Change, so instead of papering each hole separately we just use a bigger paper to cover everything up, it is still just a workaround so platforms would have to decide if they want to run with it or not. > Regards > > Marcel > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WI5BLUO2BF+mygAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 19:52:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id +A+4K0O2BF/+qwAA0J78UA (envelope-from ); Tue, 07 Jul 2020 19:52:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AB9A452DBE; Tue, 7 Jul 2020 19:51:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728674AbgGGRu7 (ORCPT + 1 other); Tue, 7 Jul 2020 13:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728211AbgGGRu6 (ORCPT ); Tue, 7 Jul 2020 13:50:58 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A16B3C061755 for ; Tue, 7 Jul 2020 10:50:58 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id s190so4767002ooa.13 for ; Tue, 07 Jul 2020 10:50:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AjJzSpH+6PSgjm7K9Fmcq3Du4iGdtClqyugjGVFCgYE=; b=dIdBr80o69ULkmGHD/noIM9/vWDvLeQcc7bXpGZoIlEzn8yAGECqovUxUNgQyn/mMf 6dc5WtZihvq2SlAhnvKc6xOu7Q4Qy3JHSAMHPnPdCJN/IGXQyY9f1aJkHyH46rJ7DqL+ jEUHGZ2Vf/qrFpTQhG+iKqodsBGJKhIxo1T4lM/mfz9RNMpqNLPmOI8zPHVOnqjz248M PagwRgFJnRa518NGSlgCZyZPoSfdpewUr+Mced7Q5LezZ5gRc558u++tdMmi2lOlq60x 349qu1i07TZbw9XzBAKbxM+RbFGAI0XRaYMvsphPHQALQZu2Kzpx/lm20zSM//QJYKH6 I2tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AjJzSpH+6PSgjm7K9Fmcq3Du4iGdtClqyugjGVFCgYE=; b=sI+TFL1oFuRgzds1i1tdKQXm0cAy2DkCUTR9fANH1ICqDQ0/cCFse3U+w+IfbK268e HUJ+pfboAEbwxUAJ6t73/sWRe3r2zyaqNYWnz/v/IjM2ubEvAM4IMNviilrKKccu2oTV 2mCQHIxigPLd2zEayE2ridPhCCALSwdCtkFL4Qfk8P7ejg48QmmcS/wUzdfDNgx4lsg/ 1TQD/a3/r9bgQI8Oos8PaTEGusFcg6j7nXTzuMWVzQTnU45RLjz8r9CDTUmpyvOCTpx0 lidWyF37AvB/7V4fwej7f76XPTWtes25ew0zDk269eMYEBh75hS/uUlYAYIPfhh7rl3h KIbQ== X-Gm-Message-State: AOAM530+uHky7wyjxpuDmRHJdweRUYt1ARSBWZPlZETQSRUWkV8Wo9wj 7uvWN4t3bT6Mto+2+m4aBt720q1ekBJEqPNr7e+c9mqw X-Google-Smtp-Source: ABdhPJwTkOheZNHaq4c4RTNRDbNKk1vvm5I47GDhcg9cpRTT+5/I5VVtMUdpS6is0aDYpEMprOGPMf4stoMPjPyUdzA= X-Received: by 2002:a4a:b284:: with SMTP id k4mr9384681ooo.49.1594144257960; Tue, 07 Jul 2020 10:50:57 -0700 (PDT) MIME-Version: 1.0 References: <20200706202518.1153647-1-abhishekpandit@chromium.org> In-Reply-To: <20200706202518.1153647-1-abhishekpandit@chromium.org> From: Luiz Augusto von Dentz Date: Tue, 7 Jul 2020 10:50:46 -0700 Message-ID: Subject: Re: [BlueZ PATCH v7 0/6] device: Allow devices to be marked as wake capable To: Abhishek Pandit-Subedi Cc: "linux-bluetooth@vger.kernel.org" , Alain Michaud , Marcel Holtmann , ChromeOS Bluetooth Upstreaming Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: AB9A452DBE X-Rspamd-UID: 1c2393 Hi Abhishek, On Mon, Jul 6, 2020 at 1:25 PM Abhishek Pandit-Subedi wrote: > > > Hi Luiz, > > This change accompanies a change in the kernel to allow marking devices > as wakeable so they can wake the system from suspend. Currently, only > HID devices support this and will be configured to allow this setting to > be changed via the WakeAllowed property. > > Accompanying kernel change: https://patchwork.kernel.org/patch/11609999/ > > In order to set this flag, Bluez must call Set Device Flags with the > Remote Wakeup bit set. This change was tested with the accompanying > kernel changes on v5.4 with both manual tests and automated tests. > > Here's the tests that I ran manually: > - Pair new HID device and confirm it has Wake Allowed to True > (default). Verify device can be woken from suspend with device. > - Restart bluetoothd, confirm Device Flags Changed event after Add > Device has no Remote Wakeup flag and Set Device Flags is called > afterwards to restore it. Verify wake from suspend still works. > - Disable Wake allowed via dbus and confirm wake from suspend no > longer works. > - Restart bluetoothd and confirm Wake Allowed is still false. Verify > wake from suspend does not work. > > Thanks > Abhishek > > Changes in v7: > * Fix more build issues reported by bluez.test.bot > > Changes in v6: > * Fix up some build issues reported by bluez.test.bot > * Save pending property id and emit success only after set flags returns > * Ignore multiple calls to set_wake_allowed to the same value > * Emit property error busy if same value is already sent to mgmt > * Fix up build issues reported by bluez.test.bot > > Changes in v5: > - Use device_flags mgmt op > * Decode device flags > * Refactor to use set_wake_flags and respond to device flags changed > * Add wake_override so we can keep track of user/profile configuration > vs what is currently active > * Only call device_set_wake_support > > Changes in v4: > * Renamed wake_capable to wake_allowed > * Removed set_wake_capable mgmt op and updated add_device to accept > flags to set whether a device is wakeable > * Refactored adapter_whitelist_add and adapter_auto_connect_add to call > adapter_add_device > * Renamed WakeCapable to WakeAllowed > * Renamed WakeCapable to WakeAllowed > * Renamed device_set_profile_wake_support to just > device_set_wake_support > > Changes in v3: > * Added profile_wake_support and made wake_capable dependent on it > * Added documentation for WakeCapable > * Mark HID device to support wake from suspend > > Changes in v2: > * Added dbus api "WakeCapable" to set value > * Update device_set_wake_capable to be called by > adapter_set_wake_capable_complete so we can emit property changed > * Newly added to show whether device is wake capable > * Removed automatically setting wake capable for HID devices > > Abhishek Pandit-Subedi (6): > mgmt: Add mgmt op and events for device flags > monitor: Decode device flags mgmt ops and event > device: Support marking a device with wake allowed > client: Display wake allowed property with info > doc/device-api: Add WakeAllowed > input: Make HID devices support wake > > client/main.c | 1 + > doc/device-api.txt | 5 + > lib/mgmt.h | 33 +++++++ > monitor/packet.c | 70 ++++++++++++++ > profiles/input/device.c | 1 + > profiles/input/hog.c | 1 + > src/adapter.c | 93 ++++++++++++++++++ > src/adapter.h | 3 +- > src/device.c | 210 ++++++++++++++++++++++++++++++++++++++++ > src/device.h | 10 ++ > 10 files changed, 426 insertions(+), 1 deletion(-) > > -- > 2.27.0.212.ge8ba1cc988-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qPQCBlC2BF+9ygAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 19:52:16 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kBAXAlC2BF+uSAAAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 19:52:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AE2E252EC2; Tue, 7 Jul 2020 19:52:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728137AbgGGRv2 (ORCPT + 1 other); Tue, 7 Jul 2020 13:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728036AbgGGRv2 (ORCPT ); Tue, 7 Jul 2020 13:51:28 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E822C061755 for ; Tue, 7 Jul 2020 10:51:28 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id c25so17356226otf.7 for ; Tue, 07 Jul 2020 10:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bCVEYuJGviAWDatB6nt/gU/BOAlgCXbGWrHAbOwkPM8=; b=Rht8URpwxd9gX5PA5/JT+3uV5XL9oFaGK/Jao/JBHQppF7uaeAVNBYtpyjK2fsw6z2 Fe+svI+i5aQ6woIvUpHIAdhqyu8iXNh749QLE2ABQspG+OLKSGMPAdemox+C4E1T8yi4 I5dNHh5NIVxPQ+4NGocIqMObudiFOCFMK5tSxR7WLBWM2B6cCIatjD5iZ3XEWzobI2cZ vFD2SU2kDx/B7knd53xO4QPLj5rYZ+9mur6y+r48hEDN9S1rQ6jhlIE0mgHKcVY73rPt YX+IONEQO56nUcAEP8OIard2D+8KFq8MRRf/FZ/87anJJ3kptGf72oBdCRDH/phHLgb1 rehg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bCVEYuJGviAWDatB6nt/gU/BOAlgCXbGWrHAbOwkPM8=; b=uSI0U5z2flJIdtSg2gtF4RJp6DEHHQc6CJ8brVxQPIUxHdViOHXFGDeAknsTiJOhlI e9cqGPYbeu/qVfJC1mEKMA7iGVho5o2AhqCuNRREneyjPZzFOf7h/xEMWLB8smZwE5ow XIxhO18xv7upRoFu+xxiTRxLEwKy54Vhgwn+wGF+92k6KYEyBKnPYa6dW0KkTbcZ7O5x l02Xc7HR0wvmcrr2WfBV0IykzXvN027AefVAoZEywn/YxfHmO10JYPdfMXRh1EcPXzVD MmN3PxYS4Ex+Wu93cE0vBrEjy75gp7AHuNAGB2h1pV/Omb1nXLfwJoaF6IrCOLl4eWq5 h9QQ== X-Gm-Message-State: AOAM533NQk1B6r4A11wYASG7cWACU7WroAotSrJoC9KXl9XOY6R3CM8a EZuDdS5PXVrFMxuASnepMiLXbXQKqWl7yy6D17k= X-Google-Smtp-Source: ABdhPJytVQaekzSiypSjEbBEFmsiq2WgrZ3CHfbaBDCrGPA0fbJpODg4jKZIuvIoFG1pzw9ogrzMf4cSwQimOepYX9g= X-Received: by 2002:a9d:5e18:: with SMTP id d24mr6700783oti.88.1594144287426; Tue, 07 Jul 2020 10:51:27 -0700 (PDT) MIME-Version: 1.0 References: <20200707021920.209213-1-alainm@chromium.org> In-Reply-To: <20200707021920.209213-1-alainm@chromium.org> From: Luiz Augusto von Dentz Date: Tue, 7 Jul 2020 10:51:16 -0700 Message-ID: Subject: Re: [BlueZ PATCH 1/2] adapter: add support for the Roles property To: Alain Michaud Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: AE2E252EC2 X-Rspamd-UID: f871cc Hi Alain, On Mon, Jul 6, 2020 at 7:22 PM Alain Michaud wrote: > > This patch adds support for the Roles property as defined in > adapter-api.txt. > > --- > > src/adapter.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 91 insertions(+) > > diff --git a/src/adapter.c b/src/adapter.c > index 9ce351893..7afd6980c 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -122,6 +122,8 @@ static bool kernel_blocked_keys_supported = false; > > static bool kernel_set_system_config = false; > > +static bool kernel_exp_features = false; > + > static GList *adapter_list = NULL; > static unsigned int adapter_remaining = 0; > static bool powering_down = false; > @@ -293,6 +295,8 @@ struct btd_adapter { > unsigned int db_id; /* Service event handler for GATT db */ > > bool is_default; /* true if adapter is default one */ > + > + bool le_simult_roles_supported; > }; > > typedef enum { > @@ -3199,6 +3203,35 @@ static gboolean property_get_modalias(const GDBusPropertyTable *property, > return TRUE; > } > > +static gboolean property_get_roles(const GDBusPropertyTable *property, > + DBusMessageIter *iter, void *user_data) > +{ > + struct btd_adapter *adapter = user_data; > + DBusMessageIter entry; > + > + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, > + DBUS_TYPE_STRING_AS_STRING, &entry); > + > + if (adapter->supported_settings & MGMT_SETTING_LE) { > + const char *str = "central"; > + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str); > + } > + > + if (adapter->supported_settings & MGMT_SETTING_ADVERTISING) { > + const char *str = "peripheral"; > + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str); > + } > + > + if (adapter->le_simult_roles_supported) { > + const char *str = "central-peripheral"; > + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str); > + } > + > + dbus_message_iter_close_container(iter, &entry); > + > + return TRUE; > +} > + > static int device_path_cmp(gconstpointer a, gconstpointer b) > { > const struct btd_device *device = a; > @@ -3479,6 +3512,7 @@ static const GDBusPropertyTable adapter_properties[] = { > { "UUIDs", "as", property_get_uuids }, > { "Modalias", "s", property_get_modalias, NULL, > property_exists_modalias }, > + { "Roles", "as", property_get_roles }, > { } > }; > > @@ -9023,6 +9057,56 @@ static bool set_blocked_keys(struct btd_adapter *adapter) > adapter, NULL); > } > > +static void read_exp_features_complete(uint8_t status, uint16_t length, > + const void *param, void *user_data) > +{ > + struct btd_adapter *adapter = user_data; > + const struct mgmt_rp_read_exp_features_info *rp = param; > + size_t feature_count = 0; > + size_t i = 0; > + > + DBG("index %u status 0x%02x", adapter->dev_id, status); > + > + if (status != MGMT_STATUS_SUCCESS) { > + btd_error(adapter->dev_id, > + "Failed to read exp features info: %s (0x%02x)", > + mgmt_errstr(status), status); > + return; > + } > + > + if (length < sizeof(*rp)) { > + btd_error(adapter->dev_id, "Response too small"); > + return; > + } > + > + feature_count = le16_to_cpu(rp->feature_count); > + for (i = 0; i < feature_count; ++i) { > + > + /* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ > + static const uint8_t le_simult_central_peripheral[16] = { > + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, > + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > + }; > + > + if (memcmp(rp->features[i].uuid, le_simult_central_peripheral, > + sizeof(le_simult_central_peripheral)) == 0) { > + uint32_t flags = le32_to_cpu(rp->features[i].flags); > + > + adapter->le_simult_roles_supported = flags & 0x01; > + } > + } > +} > + > +static void read_exp_features(struct btd_adapter *adapter) > +{ > + if (mgmt_send(adapter->mgmt, MGMT_OP_READ_EXP_FEATURES_INFO, > + adapter->dev_id, 0, NULL, read_exp_features_complete, > + adapter, NULL) > 0) > + return; > + > + btd_error(adapter->dev_id, "Failed to read exp features info"); > +} > + > static void read_info_complete(uint8_t status, uint16_t length, > const void *param, void *user_data) > { > @@ -9132,6 +9216,9 @@ static void read_info_complete(uint8_t status, uint16_t length, > (missing_settings & MGMT_SETTING_FAST_CONNECTABLE)) > set_mode(adapter, MGMT_OP_SET_FAST_CONNECTABLE, 0x01); > > + if (kernel_exp_features) > + read_exp_features(adapter); > + > err = adapter_register(adapter); > if (err < 0) { > btd_error(adapter->dev_id, "Unable to register new adapter"); > @@ -9447,6 +9534,10 @@ static void read_commands_complete(uint8_t status, uint16_t length, > DBG("kernel supports set system confic"); > kernel_set_system_config = true; > break; > + case MGMT_OP_READ_EXP_FEATURES_INFO: > + DBG("kernel supports exp features"); > + kernel_exp_features = true; > + break; > default: > break; > } > -- > 2.27.0.212.ge8ba1cc988-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4L0fJN24BF+9ygAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 20:03:09 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id wJOiIt24BF8yswAA0J78UA (envelope-from ); Tue, 07 Jul 2020 20:03:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 54FF7A3083; Tue, 7 Jul 2020 20:03:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728264AbgGGSDD (ORCPT + 1 other); Tue, 7 Jul 2020 14:03:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727777AbgGGSDD (ORCPT ); Tue, 7 Jul 2020 14:03:03 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 422E3C061755 for ; Tue, 7 Jul 2020 11:03:03 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id q10so4782897ooo.11 for ; Tue, 07 Jul 2020 11:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lRr6+HaeKxg8lQrgjOjqWdjOvlKqY55Ck1+poPqVOdg=; b=bWvOhgSborB6tGvsTQNao1iQjpbnR5188qmB+yS0gmdkrXna8/lJvMPMDYki5AHeTx qYX+4ArReBbrkApxLaDV7h52dEBFm/UggzX9/OLDIVIZHN4ar2Z1GnVJyEWDxb6SEhPH 5Jcxk6CtzFZaJTfIMTMX3bf31d+gaX1wKEBbNV3uLG9HsQs69jcmYF4nz8p9ZaVcLnCY Hev38AJyV3PPNEx+D3mvMwyqsrQofFa5OasHYs5rRhugKtKLRtmr13bJa7Y+zDgIBgHO yaP2DAngjEI8nNMpipgTkwLnwfQS5CCVuR3hDN/Fa3h9YTvPhM3VXwpSk5Ee7AEEX1C0 ng0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lRr6+HaeKxg8lQrgjOjqWdjOvlKqY55Ck1+poPqVOdg=; b=dzYxpeTaoCPk2248C/9KkGuL2oyLacNj08FaQJhfKCRB3cDK8AlaJ+XVsxdtJcVb9v 2nw1SeZzN194jWVXrsvrrN3CtPlih/wZ4m0vQ5jaqoPF/npX1/Rav2D5JXJFtS1IfUrq SfiUmvqhqrLOkI870vANrIarJLD3lIngvqhZeCAxrwMutXTrYTAxnakYZYFzdrxwwsWG nhRx+tFTtAXcJ915lzl5j9hl/IHga9xtwcarEHGzEfw9txA8NsQ0xOGmspHEWLn90s1+ beXSlNfwV4vCVypHOUYdVAqjcf/9Z55qS+p48Z2W3wh+2fSXg/6kBQ0laVuttorbuRmX jQog== X-Gm-Message-State: AOAM531oVuePyIn6QG2DZhF0FG/sEbjoRw3cPeKrkBrR7QXM9VgCTd4k nz3qALhyGuI7rja/CXkIi3ptUrqMU3fhYEgQkvg= X-Google-Smtp-Source: ABdhPJxLuqeUaA9U3qKfBl+u0p9rqAtkOGEfNNrgxcMU4dpOBSAXjYnYUBEHKxHYLEtbBgibGMiIMRib3CUwic+IYiA= X-Received: by 2002:a4a:b284:: with SMTP id k4mr9428648ooo.49.1594144982497; Tue, 07 Jul 2020 11:03:02 -0700 (PDT) MIME-Version: 1.0 References: <20200627235318.Bluez.v2.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> In-Reply-To: <20200627235318.Bluez.v2.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> From: Luiz Augusto von Dentz Date: Tue, 7 Jul 2020 11:02:51 -0700 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] device: add device_remove_bonding function To: Archie Pusaka Cc: linux-bluetooth , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 54FF7A3083 X-Rspamd-UID: 2ae32d Hi Archie, On Sat, Jun 27, 2020 at 8:54 AM Archie Pusaka wrote: > > From: Archie Pusaka > > This patch splits the "bonding removal" function in device.c, > because we need to remove bonding information when receiving > "virtual cable unplug" in HID profile. > > Reviewed-by: Alain Michaud > --- > > Changes in v2: None > > src/device.c | 25 +++++++++++++++---------- > src/device.h | 1 + > 2 files changed, 16 insertions(+), 10 deletions(-) > > diff --git a/src/device.c b/src/device.c > index 7b0eb256e..9fb0e018c 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -4162,6 +4162,17 @@ static void delete_folder_tree(const char *dirname) > rmdir(dirname); > } > > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr_type) > +{ > + if (bdaddr_type == BDADDR_BREDR) > + device->bredr_state.bonded = false; > + else > + device->le_state.bonded = false; > + > + btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > + bdaddr_type); > +} > + > static void device_remove_stored(struct btd_device *device) > { > char device_addr[18]; > @@ -4170,17 +4181,11 @@ static void device_remove_stored(struct btd_device *device) > char *data; > gsize length = 0; > > - if (device->bredr_state.bonded) { > - device->bredr_state.bonded = false; > - btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > - BDADDR_BREDR); > - } > + if (device->bredr_state.bonded) > + device_remove_bonding(device, BDADDR_BREDR); > > - if (device->le_state.bonded) { > - device->le_state.bonded = false; > - btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > - device->bdaddr_type); > - } > + if (device->le_state.bonded) > + device_remove_bonding(device, device->bdaddr_type); > > device->bredr_state.paired = false; > device->le_state.paired = false; > diff --git a/src/device.h b/src/device.h > index 06b100499..907c7c5c4 100644 > --- a/src/device.h > +++ b/src/device.h > @@ -49,6 +49,7 @@ uint16_t btd_device_get_vendor(struct btd_device *device); > uint16_t btd_device_get_vendor_src(struct btd_device *device); > uint16_t btd_device_get_product(struct btd_device *device); > uint16_t btd_device_get_version(struct btd_device *device); > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr_type); > void device_remove(struct btd_device *device, gboolean remove_stored); Is there any particular reason why device_remove is not enough here? I don't see any reason to leave the device object around after removing its bonding. > int device_address_cmp(gconstpointer a, gconstpointer b); > int device_bdaddr_cmp(gconstpointer a, gconstpointer b); > -- > 2.27.0.212.ge8ba1cc988-goog > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IHmyMQW8BF+r5AAAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 20:16:37 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IHUSMAW8BF/xawAAlp8NpQ (envelope-from ); Tue, 07 Jul 2020 20:16:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E875DA3099; Tue, 7 Jul 2020 20:16:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728315AbgGGSQa (ORCPT + 1 other); Tue, 7 Jul 2020 14:16:30 -0400 Received: from mga06.intel.com ([134.134.136.31]:48438 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728036AbgGGSQa (ORCPT ); Tue, 7 Jul 2020 14:16:30 -0400 IronPort-SDR: ziQpBEowCT9YPXgtO+CeqHAzSMVwM8b/ab/sfhuEq5j596qQutfFjteQiU/C1GKh2Wo+Vx0ExA 3SGhYX3XVqIA== X-IronPort-AV: E=McAfee;i="6000,8403,9675"; a="209202552" X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="209202552" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2020 11:16:14 -0700 IronPort-SDR: U24HwwBhsxR2f/kEkJ/WVkVk3S+0/YrlHCaIpQIwusjDiZKBDsxuW19Zr1I/uTeGXZbMjNLbAj iFKpCB/JhAVw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="457204842" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.77.128]) by orsmga005.jf.intel.com with ESMTP; 07 Jul 2020 11:16:14 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ v2] mesh: Add Composition page storage to node.json Date: Tue, 7 Jul 2020 11:16:11 -0700 Message-Id: <20200707181611.135109-1-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: E875DA3099 X-Rspamd-UID: fe9894 Mesh supports multiple Composition Pages, although only one is defined in the current specification. This change allows saving and retrieval of any pages, numbered 0-255. --- mesh/cfgmod-server.c | 42 +++++++++-- mesh/mesh-config-json.c | 162 ++++++++++++++++++++++++++++++++++++++++ mesh/mesh-config.h | 12 +++ mesh/node.c | 130 ++++++++++++++++++++++++++------ mesh/node.h | 6 +- 5 files changed, 320 insertions(+), 32 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index c525d9d24..6194fc7d4 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -34,6 +34,12 @@ #define CFG_MAX_MSG_LEN 380 +/* Supported composition pages, sorted high to low */ +/* Only page 0 is currently supported */ +static const uint8_t supported_pages[] = { + 0 +}; + static void send_pub_status(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t status, uint16_t ele_addr, uint32_t mod_id, @@ -701,6 +707,33 @@ static void node_reset(void *user_data) node_remove(node); } +static uint16_t get_composition(struct mesh_node *node, uint8_t page, + uint8_t *buf) +{ + const uint8_t *comp; + uint16_t len = 0; + size_t i; + + for (i = 0; i < sizeof(supported_pages); i++) { + if (page < supported_pages[i]) + continue; + + page = supported_pages[i]; + comp = node_get_comp(node, page, &len); + + if (!page || len) + break; + } + + if (!len) + return 0; + + *buf++ = page; + memcpy(buf, comp, len); + + return len + 1; +} + static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, const uint8_t *data, uint16_t size, const void *user_data) @@ -746,16 +779,9 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 1) return false; - /* Only page 0 is currently supported */ - if (pkt[0] != 0) { - l_debug("Unsupported page number %d", pkt[0]); - l_debug("Returning page number 0"); - } long_msg = l_malloc(CFG_MAX_MSG_LEN); n = mesh_model_opcode_set(OP_DEV_COMP_STATUS, long_msg); - long_msg[n++] = 0; - n += node_generate_comp(node, long_msg + n, - CFG_MAX_MSG_LEN - n); + n += get_composition(node, pkt[0], long_msg + n); break; diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 661775f95..88f715fc1 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -430,6 +430,54 @@ static bool read_device_key(json_object *jobj, uint8_t key_buf[16]) return true; } +static bool read_comp_pages(json_object *jobj, struct mesh_config_node *node) +{ + json_object *jarray, *jentry; + struct mesh_config_comp_page *page; + int len; + int i; + + if (!json_object_object_get_ex(jobj, "pages", &jarray)) + return true; + + if (json_object_get_type(jarray) != json_type_array) + return false; + + len = json_object_array_length(jarray); + + for (i = 0; i < len; i++) { + size_t clen; + char *str; + + jentry = json_object_array_get_idx(jarray, i); + str = (char *)json_object_get_string(jentry); + clen = strlen(str); + + if (clen < ((MIN_COMP_SIZE * 2) + 1)) + continue; + + clen = (clen / 2) - 1; + + page = l_malloc(sizeof(struct mesh_config_comp_page) + clen); + + if (!str2hex(str + 2, clen * 2, page->data, clen)) + goto parse_fail; + + if (sscanf(str, "%02hhx", &page->page_num) != 1) + goto parse_fail; + + page->len = clen; + + l_queue_push_tail(node->pages, page); + } + + return true; + +parse_fail: + l_free(page); + return false; +} + static bool read_app_keys(json_object *jobj, struct mesh_config_node *node) { json_object *jarray; @@ -1384,6 +1432,11 @@ static bool read_node(json_object *jnode, struct mesh_config_node *node) return false; } + if (!read_comp_pages(jnode, node)) { + l_info("Failed to read Composition Pages"); + return false; + } + if (!parse_elements(jvalue, node)) { l_info("Failed to parse elements"); return false; @@ -1889,6 +1942,113 @@ bool mesh_config_model_pub_del(struct mesh_config *cfg, uint16_t addr, return save_config(cfg->jnode, cfg->node_dir_path); } +static void del_page(json_object *jarray, uint8_t page) +{ + char buf[3]; + int i, len; + + if (!jarray) + return; + + snprintf(buf, 3, "%2.2x", page); + + len = json_object_array_length(jarray); + + for (i = 0; i < len; i++) { + json_object *jentry; + char *str; + + jentry = json_object_array_get_idx(jarray, i); + str = (char *)json_object_get_string(jentry); + + /* Delete matching page(s) */ + if (!memcmp(str, buf, 2)) + json_object_array_del_idx(jarray, i, 1); + } +} + +bool mesh_config_comp_page_add(struct mesh_config *cfg, uint8_t page, + uint8_t *data, uint16_t size) +{ + json_object *jnode, *jstring, *jarray = NULL; + char *buf; + int len; + + if (!cfg) + return false; + + jnode = cfg->jnode; + + json_object_object_get_ex(jnode, "pages", &jarray); + + len = (size * 2) + 3; + buf = l_malloc(len); + snprintf(buf, len, "%2.2x", page); + hex2str(data, size, buf + 2, len - 2); + + if (jarray && jarray_has_string(jarray, buf, len)) { + l_free(buf); + return true; + } else if (!jarray) { + jarray = json_object_new_array(); + json_object_object_add(jnode, "pages", jarray); + } else + del_page(jarray, page); + + jstring = json_object_new_string(buf); + json_object_array_add(jarray, jstring); + l_free(buf); + + return save_config(jnode, cfg->node_dir_path); +} + +bool mesh_config_comp_page_mv(struct mesh_config *cfg, uint8_t old, uint8_t nw) +{ + json_object *jnode, *jarray = NULL; + uint8_t *data; + char *str; + char old_buf[3]; + int i, len, dlen = 0; + bool status = true; + + if (!cfg || old == nw) + return false; + + jnode = cfg->jnode; + + json_object_object_get_ex(jnode, "pages", &jarray); + + if (!jarray) + return false; + + snprintf(old_buf, 3, "%2.2x", old); + data = l_malloc(MAX_MSG_LEN); + + len = json_object_array_length(jarray); + + for (i = 0; i < len; i++) { + json_object *jentry; + + jentry = json_object_array_get_idx(jarray, i); + str = (char *)json_object_get_string(jentry); + + /* Delete matching page(s) but save data*/ + if (!memcmp(str, old_buf, 2)) { + dlen = strlen(str + 2); + str2hex(str + 2, dlen, data, MAX_MSG_LEN); + dlen /= 2; + json_object_array_del_idx(jarray, i, 1); + } + } + + if (dlen) + status = mesh_config_comp_page_add(cfg, nw, data, dlen); + + l_free(data); + + return status; +} + bool mesh_config_model_sub_add(struct mesh_config *cfg, uint16_t ele_addr, uint32_t mod_id, bool vendor, struct mesh_config_sub *sub) @@ -2212,6 +2372,7 @@ static bool load_node(const char *fname, const uint8_t uuid[16], node.elements = l_queue_new(); node.netkeys = l_queue_new(); node.appkeys = l_queue_new(); + node.pages = l_queue_new(); result = read_node(jnode, &node); @@ -2238,6 +2399,7 @@ static bool load_node(const char *fname, const uint8_t uuid[16], l_free(node.net_transmit); l_queue_destroy(node.netkeys, l_free); l_queue_destroy(node.appkeys, l_free); + l_queue_destroy(node.pages, l_free); l_queue_destroy(node.elements, free_element); if (!result) diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 9f30e693b..7dfa9f20c 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -17,6 +17,8 @@ * */ +#define MIN_COMP_SIZE 14 + struct mesh_config; struct mesh_config_sub { @@ -88,10 +90,17 @@ struct mesh_config_transmit { uint8_t count; }; +struct mesh_config_comp_page { + uint16_t len; + uint8_t page_num; + uint8_t data[]; +}; + struct mesh_config_node { struct l_queue *elements; struct l_queue *netkeys; struct l_queue *appkeys; + struct l_queue *pages; uint32_t seq_number; uint32_t iv_index; bool iv_update; @@ -139,6 +148,9 @@ bool mesh_config_write_relay_mode(struct mesh_config *cfg, uint8_t mode, bool mesh_config_write_ttl(struct mesh_config *cfg, uint8_t ttl); bool mesh_config_write_mode(struct mesh_config *cfg, const char *keyword, int value); +bool mesh_config_comp_page_add(struct mesh_config *cfg, uint8_t page, + uint8_t *data, uint16_t size); +bool mesh_config_comp_page_mv(struct mesh_config *cfg, uint8_t old, uint8_t nw); bool mesh_config_model_binding_add(struct mesh_config *cfg, uint16_t ele_addr, bool vendor, uint32_t mod_id, uint16_t app_idx); diff --git a/mesh/node.c b/mesh/node.c index 3e888ce61..c61167bda 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -46,8 +46,6 @@ #include "mesh/manager.h" #include "mesh/node.h" -#define MIN_COMP_SIZE 14 - #define MESH_NODE_PATH_PREFIX "/node" /* Default values for a new locally created node */ @@ -81,6 +79,7 @@ struct node_composition { struct mesh_node { struct mesh_net *net; struct l_queue *elements; + struct l_queue *pages; char *app_path; char *owner; char *obj_path; @@ -266,6 +265,7 @@ static struct mesh_node *node_new(const uint8_t uuid[16]) node = l_new(struct mesh_node, 1); node->net = mesh_net_new(node); node->elements = l_queue_new(); + node->pages = l_queue_new(); memcpy(node->uuid, uuid, sizeof(node->uuid)); set_defaults(node); @@ -335,6 +335,7 @@ static void free_node_resources(void *data) /* Free dynamic resources */ free_node_dbus_resources(node); l_queue_destroy(node->elements, element_free); + l_queue_destroy(node->pages, l_free); mesh_agent_remove(node->agent); mesh_config_release(node->cfg); mesh_net_free(node->net); @@ -557,8 +558,15 @@ static bool init_from_storage(struct mesh_config_node *db_node, l_queue_foreach(db_node->netkeys, set_net_key, node); - if (db_node->appkeys) - l_queue_foreach(db_node->appkeys, set_appkey, node); + l_queue_foreach(db_node->appkeys, set_appkey, node); + + while (l_queue_length(db_node->pages)) { + struct mesh_config_comp_page *page; + + /* Move the composition pages to the node struct */ + page = l_queue_pop_head(db_node->pages); + l_queue_push_tail(node->pages, page); + } mesh_net_set_seq_num(node->net, node->seq_number); mesh_net_set_default_ttl(node->net, node->ttl); @@ -877,7 +885,8 @@ uint8_t node_friend_mode_get(struct mesh_node *node) return node->friend; } -uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz) +static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, + uint16_t sz) { uint16_t n, features; uint16_t num_ele = 0; @@ -991,6 +1000,78 @@ element_done: return n; } +static bool match_page(const void *a, const void *b) +{ + const struct mesh_config_comp_page *page = a; + uint8_t page_num = L_PTR_TO_UINT(b); + + return page->page_num == page_num; +} + +bool node_set_comp(struct mesh_node *node, uint8_t page_num, + const uint8_t *data, uint16_t len) +{ + struct mesh_config_comp_page *page; + + if (!node || len < MIN_COMP_SIZE) + return false; + + page = l_queue_remove_if(node->pages, match_page, + L_UINT_TO_PTR(page_num)); + + l_free(page); + + page = l_malloc(sizeof(struct mesh_config_comp_page) + len); + page->len = len; + page->page_num = page_num; + memcpy(page->data, data, len); + l_queue_push_tail(node->pages, page); + + mesh_config_comp_page_add(node->cfg, page_num, page->data, len); + + return true; +} + +const uint8_t *node_get_comp(struct mesh_node *node, uint8_t page_num, + uint16_t *len) +{ + struct mesh_config_comp_page *page = NULL; + + if (node) + page = l_queue_find(node->pages, match_page, + L_UINT_TO_PTR(page_num)); + + if (!page) { + *len = 0; + return NULL; + } + + *len = page->len; + return page->data; +} + +bool node_replace_comp(struct mesh_node *node, uint8_t retire, uint8_t with) +{ + struct mesh_config_comp_page *old_page, *keep; + + if (!node) + return false; + + keep = l_queue_find(node->pages, match_page, L_UINT_TO_PTR(with)); + + if (!keep) + return false; + + old_page = l_queue_remove_if(node->pages, match_page, + L_UINT_TO_PTR(retire)); + + l_free(old_page); + keep->page_num = retire; + mesh_config_comp_page_mv(node->cfg, with, retire); + + return true; +} + static void attach_io(void *a, void *b) { struct mesh_node *node = a; @@ -1486,27 +1567,30 @@ static void update_model_options(struct mesh_node *node, static bool check_req_node(struct managed_obj_request *req) { - uint8_t node_comp[MAX_MSG_LEN - 2]; - uint8_t attach_comp[MAX_MSG_LEN - 2]; - uint16_t offset = 10; - uint16_t node_len = node_generate_comp(req->node, node_comp, - sizeof(node_comp)); + struct mesh_node *node; + const int offset = 8; + uint16_t node_len, len; + uint8_t comp[MAX_MSG_LEN - 2]; + const uint8_t *node_comp; - if (!node_len) - return false; + if (req->type == REQUEST_TYPE_ATTACH) + node = req->attach; + else + node = req->node; - if (req->type == REQUEST_TYPE_ATTACH) { - uint16_t attach_len = node_generate_comp(req->attach, - attach_comp, sizeof(attach_comp)); + node_comp = node_get_comp(node, 0, &node_len); + len = node_generate_comp(node, comp, sizeof(comp)); - /* Verify only element/models composition */ - if (node_len != attach_len || - memcmp(&node_comp[offset], &attach_comp[offset], - node_len - offset)) { - l_debug("Failed to verify app's composition data"); - return false; - } - } + /* If no page 0 exists, save it and return */ + if (req->type != REQUEST_TYPE_ATTACH || !node_len || !node_comp) + return node_set_comp(node, 0, comp, len); + + if (node_len != len || memcmp(&node_comp[offset], &comp[offset], + node_len - offset)) + return false; + + else if (memcmp(node_comp, comp, node_len)) + return node_set_comp(node, 0, comp, len); return true; } diff --git a/mesh/node.h b/mesh/node.h index 6c4542a78..df058458a 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -63,7 +63,11 @@ struct l_queue *node_get_element_models(struct mesh_node *node, uint8_t ele_idx, uint16_t node_get_crpl(struct mesh_node *node); bool node_init_from_storage(struct mesh_node *node, const uint8_t uuid[16], struct mesh_config_node *db_node); -uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz); +const uint8_t *node_get_comp(struct mesh_node *node, uint8_t page_num, + uint16_t *len); +bool node_set_comp(struct mesh_node *node, uint8_t page_num, + const uint8_t *data, uint16_t len); +bool node_replace_comp(struct mesh_node *node, uint8_t retire, uint8_t with); uint8_t node_lpn_mode_get(struct mesh_node *node); bool node_relay_mode_set(struct mesh_node *node, bool enable, uint8_t cnt, uint16_t interval); -- 2.25.4 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oCk2GXLSBF/ETgEAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 21:52:18 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wLFiF3LSBF/XlAEAlScrYA (envelope-from ); Tue, 07 Jul 2020 21:52:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6E49E51A0B; Tue, 7 Jul 2020 21:52:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728036AbgGGTwG (ORCPT + 1 other); Tue, 7 Jul 2020 15:52:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728254AbgGGTwA (ORCPT ); Tue, 7 Jul 2020 15:52:00 -0400 Received: from mail-vs1-xe43.google.com (mail-vs1-xe43.google.com [IPv6:2607:f8b0:4864:20::e43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 949F8C061755 for ; Tue, 7 Jul 2020 12:52:00 -0700 (PDT) Received: by mail-vs1-xe43.google.com with SMTP id x205so2976697vsc.11 for ; Tue, 07 Jul 2020 12:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WgPoz0FJ30UPfGpy4Cb13jMdX0qVm1LilRnd+oWGuDw=; b=RyHl2c2+kgfmWJVFqOd/Io7Rxe9mmPc2iGR+v1P1BT9PwfcKfd7jXkF72irWMAcsJT qz3+e6PtyEZxESbJqznENCJYPsD3oaPGC8wkgS+zZqzOlpwKeou4WhCsrBlDrNsZVULX Pvj3kVdVMDLQQi3Ep7IeG+QZYErSw6ExVfUBI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WgPoz0FJ30UPfGpy4Cb13jMdX0qVm1LilRnd+oWGuDw=; b=l/dw5ufziz846fQZFWfEnb53fX95zN6lsaZw09nOYJpTQFrEWujUDrjAHHq8iV2j+M W0OCPB676qNcR9LHXy3DxFn6JX0Hj2OU2vG/mppbB7Xry81N8buGCXy2T8O6JeQOcBtn wUVpd38BxkFqfcvNqIdBy+toJ35Ur2h8Q6w647YsVqE/qB7QO1n5ckjiBJnFcmELZqtX MwDx+8ZQPRTCnVNBnFxMuqqd9E1l38UzWsK9xdkOpwwUbOF6EGs6+fJPPaWFlgFLZqFh ypk74eCopygKhbW89c2Hh2F9A5qzYRQGkLwUrA1mX/MGOZvHi7brA/Kwynt81JssahWI /aeQ== X-Gm-Message-State: AOAM533q+zeZilfDOjV0+mxyhrtF/kzy7WEfE0I/TOCO7Fx4HAw/7o2h McQWkyuZTlHLCmMUa9Si6Sc1nEkGo9M= X-Google-Smtp-Source: ABdhPJzeRp19fMav6E9eBd29i12t7babCVLjUDWIshN+yxWcg81OnM2jqxZz6kveFemRci1XakrPEg== X-Received: by 2002:a67:e9d1:: with SMTP id q17mr31538248vso.212.1594151519408; Tue, 07 Jul 2020 12:51:59 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id i203sm230625vke.7.2020.07.07.12.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 12:51:58 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud , Archie Pusaka Subject: [PATCH v3] Bluetooth: create CONFIG_BT_DEBUG_FEATURE_FUNC_NAME Date: Tue, 7 Jul 2020 19:51:56 +0000 Message-Id: <20200707195156.885137-1-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6E49E51A0B X-Rspamd-UID: 647573 Creates a CONFIG_BT_DEBUG_FEATURE_FUNC_NAME option to include function names in debug statements. Unlike other platforms __func__ isn't a string literal so it cannot be automatically concatenated by the pre-processor. As a result, the function name is passed as a parameter to the tracing function. Since pr_debug is a function like macro, the normal expansion of BT_PREFIX_PARAM does not work as it gets processed within the first parameter as well, for this reason, BT_DBG is split into two versions. This patch was built tested with all 4 possible combinations of CONFIG_BT_DEBUG_FUNC_NAME and CONFIG_BT_FEATURE_DEBUG configurations. Signed-off-by: Alain Michaud Reviewed-by: Archie Pusaka --- Changes in v3: - Fixing bug introduced in the last version when the configuration name was changed. Changes in v2: - Making CONFIG_BT_DEBUG_FEATURE_FUNC_NAME dependent on CONFIG_BT_DEBUG_FEATURE include/net/bluetooth/bluetooth.h | 32 +++++++++++++++++++++++-------- net/bluetooth/Kconfig | 11 +++++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 7ee8041af803..2528589c0b28 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -162,22 +162,37 @@ void bt_dbg_set(bool enable); bool bt_dbg_get(void); __printf(1, 2) void bt_dbg(const char *fmt, ...); +#define BT_DBG_INT bt_dbg +#else +#define BT_DBG_INT pr_debug #endif __printf(1, 2) void bt_warn_ratelimited(const char *fmt, ...); __printf(1, 2) void bt_err_ratelimited(const char *fmt, ...); -#define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__) -#define BT_WARN(fmt, ...) bt_warn(fmt "\n", ##__VA_ARGS__) -#define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) - -#if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG) -#define BT_DBG(fmt, ...) bt_dbg(fmt "\n", ##__VA_ARGS__) +#if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG_FUNC_NAMES) +#define BT_PREFIX "%s() " +#define BT_PREFIX_PARAM ,__func__ +#define BT_DBG(fmt, ...) \ + BT_DBG_INT(BT_PREFIX fmt "\n", __func__, ##__VA_ARGS__) #else -#define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__) +#define BT_PREFIX +#define BT_PREFIX_PARAM +#define BT_DBG(fmt, ...) \ + BT_DBG_INT(fmt "\n", ##__VA_ARGS__) #endif +#define BT_INFO(fmt, ...) \ + bt_info(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) +#define BT_WARN(fmt, ...) \ + bt_warn(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) +#define BT_ERR(fmt, ...) \ + bt_err(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) + +#define BT_ERR_RATELIMITED(fmt, ...) \ + bt_err_ratelimited(BT_PREFIX fmt "\n" BT_PREFIX_PARAM, ##__VA_ARGS__) + #define bt_dev_info(hdev, fmt, ...) \ BT_INFO("%s: " fmt, (hdev)->name, ##__VA_ARGS__) #define bt_dev_warn(hdev, fmt, ...) \ @@ -188,7 +203,8 @@ void bt_err_ratelimited(const char *fmt, ...); BT_DBG("%s: " fmt, (hdev)->name, ##__VA_ARGS__) #define bt_dev_warn_ratelimited(hdev, fmt, ...) \ - bt_warn_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + bt_warn_ratelimited("%s: " BT_PREFIX fmt, (hdev)->name \ + BT_PREFIX_PARAM, ##__VA_ARGS__) #define bt_dev_err_ratelimited(hdev, fmt, ...) \ bt_err_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index 1d6d243cdde9..ccbf762053f1 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -142,4 +142,15 @@ config BT_FEATURE_DEBUG This provides an option to enable/disable debugging statements at runtime via the experimental features interface. +config BT_FEATURE_DEBUG_FUNC_NAMES + bool "Include function names in debugging statements" + depends on BT_FEATURE_DEBUG + default n + help + Provides an option to include function names in debugging + statements. + + When enabled, trace statements will include the function name as a + prefix which may help identify the source code references. + source "drivers/bluetooth/Kconfig" -- 2.27.0.383.g050319c2ae-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qLOZAOPUBF/ETgEAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 22:02:43 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id sPD2OuLUBF8t3wAA0J78UA (envelope-from ); Tue, 07 Jul 2020 22:02:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E1383A30AC; Tue, 7 Jul 2020 22:02:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727834AbgGGUCf (ORCPT + 1 other); Tue, 7 Jul 2020 16:02:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727003AbgGGUCf (ORCPT ); Tue, 7 Jul 2020 16:02:35 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41653C061755 for ; Tue, 7 Jul 2020 13:02:35 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id k15so25491916lfc.4 for ; Tue, 07 Jul 2020 13:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=uTyg3tJMPD5Lk1s77wrHuXbd7OOCmjF9sWfiuTAkIkU=; b=tRYhFNeFy/wfHMfDpxn2Xmbs2ez/U4weX/XmaGyjAIGg1gaMoXjOhC3F92+Jt17aP8 jXnI9r7YCy3A0mAvlRX7FuAZs1WBPbYy4pxlh8PxUG8Kf1nJ6oNcVsSVELTmbQYgJjeg yZguJ13CW5zlBjMSmIo6ii/mjEv5EuBtJKVfRUHDOQyISopHsruEEkCAhMioAaiCyQvw lQlN7GZOtQCdDtjwP6wjNnwMJoQOlGd4GdhPT0yJb0OJdP5+4tfR5kke5nvYppwRIcc3 gNP1P+OeDwmnnw8MFU0hHcJmsefSg3UqTgPfGLYeIT8U6ZWUEZaxVPLgmoh0nFxiU0PW vwTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=uTyg3tJMPD5Lk1s77wrHuXbd7OOCmjF9sWfiuTAkIkU=; b=Ck99v3jhbmBkG0T4v/59MDnttTNQJwQyTtrOtcMlmVutBJ3MdeR8lT9UH3VQQEDt7w XkUGQR02bGArcNFzIY3Ur13k3BLrAnDUbnddAUpdsfPWllAPcJfP5JhMGCiwZhGoB8Va mSaUY74iCWEhvodOZHz9h0UFAAVsFljBD7KlDKjTN5x4vjfWp5Hf0IqF1K1vEUPRui1b BDzlefJRToGihjI7gHJDi62GQ0F6Laq0DqtrKd6fGk/Z4fOODqiNedLEBFqBp3eUuhHl p4RwTdMIyoogE6yPk6dDP3jXrcArQjvDgeD655K+uXgp+zybMYZdd05R10hffLSYxMg8 TKdg== X-Gm-Message-State: AOAM530sr0i7FaQW3fCrZPZZvwUpa5WT4smf0dbabjqtwMUoo6nqOxN9 l9H2fq55vHMwcs1FVSCCmsF8Noh+UN/jiKucYdn6y2f58T4= X-Google-Smtp-Source: ABdhPJzK7vsWEHYiR8RgkdL0394c6XtLgvT8MN8DPZ6U8DRjwZUEWVc+wcfJ8yme/RQJ7OU6La4gGeP3bHidQDqppcM= X-Received: by 2002:a19:c78d:: with SMTP id x135mr33854676lff.82.1594152153448; Tue, 07 Jul 2020 13:02:33 -0700 (PDT) MIME-Version: 1.0 References: <20200707141628.368748-1-alainm@chromium.org> <67268C4E-674E-4DE9-B642-E1CAE8748E28@holtmann.org> In-Reply-To: From: Alain Michaud Date: Tue, 7 Jul 2020 16:02:21 -0400 Message-ID: Subject: Re: [PATCH v2] Bluetooth: create CONFIG_BT_DEBUG_FEATURE_FUNC_NAME To: Marcel Holtmann Cc: Alain Michaud , BlueZ , Archie Pusaka Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -6.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: E1383A30AC X-Rspamd-UID: f062ea On Tue, Jul 7, 2020 at 1:15 PM Alain Michaud wrot= e: > > On Tue, Jul 7, 2020 at 11:53 AM Marcel Holtmann wro= te: > > > > Hi Alain, > > > > > Creates a CONFIG_BT_DEBUG_FEATURE_FUNC_NAME option to include functio= n names in > > > debug statements. > > > > > > Unlike other platforms __func__ isn't a string literal so it cannot b= e > > > automatically concatenated by the pre-processor. As a result, the > > > function name is passed as a parameter to the tracing function. Sinc= e > > > pr_debug is a function like macro, the normal expansion of BT_PREFIX_= PARAM > > > does not work as it gets processed within the first parameter as well= , > > > for this reason, BT_DBG is split into two versions. > > > > > > This patch was built tested with all 4 possible combinations of > > > CONFIG_BT_DEBUG_FUNC_NAME and CONFIG_BT_FEATURE_DEBUG configurations. > > > > > > Signed-off-by: Alain Michaud > > > Reviewed-by: Archie Pusaka > > > --- > > > > > > Changes in v2: > > > - Making CONFIG_BT_DEBUG_FEATURE_FUNC_NAME dependent on > > > CONFIG_BT_DEBUG_FEATURE > > > > > > include/net/bluetooth/bluetooth.h | 32 +++++++++++++++++++++++-------= - > > > net/bluetooth/Kconfig | 11 +++++++++++ > > > 2 files changed, 35 insertions(+), 8 deletions(-) > > > > > > diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetoot= h/bluetooth.h > > > index 7ee8041af803..8506dd268d4b 100644 > > > --- a/include/net/bluetooth/bluetooth.h > > > +++ b/include/net/bluetooth/bluetooth.h > > > @@ -162,22 +162,37 @@ void bt_dbg_set(bool enable); > > > bool bt_dbg_get(void); > > > __printf(1, 2) > > > void bt_dbg(const char *fmt, ...); > > > +#define BT_DBG_INT bt_dbg > > > +#else > > > +#define BT_DBG_INT pr_debug > > > #endif > > > __printf(1, 2) > > > void bt_warn_ratelimited(const char *fmt, ...); > > > __printf(1, 2) > > > void bt_err_ratelimited(const char *fmt, ...); > > > > > > -#define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__) > > > -#define BT_WARN(fmt, ...) bt_warn(fmt "\n", ##__VA_ARGS__) > > > -#define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) > > > - > > > -#if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG) > > > -#define BT_DBG(fmt, ...) bt_dbg(fmt "\n", ##__VA_ARGS__) > > > +#if IS_ENABLED(BT_FEATURE_DEBUG_FUNC_NAMES) > > > > are you sure you tested this? > > This was tested on chromeos using this patch chain which also sets the > configuration and revert our original patch: > https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/= +/2279613 (facepalm) You were right, I introduced this bug in v2's rename. This is now fixed in V3. > > > > > > > And frankly I don=E2=80=99t get the point for the new Kconfig option. I= t is rather useless in this patch. Tell me one thing, do you prefer that FE= ATURE_DEBUG prints the function names or not. Because if dynamic debug is u= sed, we don=E2=80=99t need it since that is all configurable via dynamic de= bug itself and we don=E2=80=99t need it there (and I also don=E2=80=99t wan= t it in the dynamic debug case). > I'd be ok if we unconditionally print function names if > CONFIG_BT_FEATURE_DEBUG is set. what I want to avoid is to overly > complicate the debug macros to have the function names configurable at > runtime. > > > > > Regards > > > > Marcel > > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AK0CKGXYBF9/hwEAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 22:17:41 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id MEJdJmXYBF8dZAEA0J78UA (envelope-from ); Tue, 07 Jul 2020 22:17:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D878652B95; Tue, 7 Jul 2020 22:17:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728650AbgGGURf (ORCPT + 1 other); Tue, 7 Jul 2020 16:17:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728280AbgGGURf (ORCPT ); Tue, 7 Jul 2020 16:17:35 -0400 Received: from mail-ua1-x942.google.com (mail-ua1-x942.google.com [IPv6:2607:f8b0:4864:20::942]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3D4EC061755 for ; Tue, 7 Jul 2020 13:17:34 -0700 (PDT) Received: by mail-ua1-x942.google.com with SMTP id n4so2519076uae.5 for ; Tue, 07 Jul 2020 13:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DAZkdSMy6rGL4HXgiQRy1c3I5dw1ddM0iPQtXxoHahE=; b=dqJod+UNQhVJ3Fx+S7PWIqRHnDCKbaQ3tsgfsN0vogU2uMBuaiscmPV9zaT6PwrCeU qAXZNqC2zqZjiEgG3civZzp5luib28FwVxrq9EMC1Q0GwO0z2D9bc+LZdQX4BCHsijqf chOiIsZI9WS6vOG6cDudlMjyRPUVh2SNZY8fI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DAZkdSMy6rGL4HXgiQRy1c3I5dw1ddM0iPQtXxoHahE=; b=CoavVwS1V9HlqqFe3dkbQ67JP+wwikz0inR/hQTmrqkMbJwDBbljgzyIZcpvwIoyNX /fOpThyPfxODbesLQlRsrw1O7vp1u9/hbvgKAkAFIXXUCZ9yL9f58w8ZIZkLIzVsPXGU hCu2FnmJ/h3zLB4T1w+LT9jHhHf3Nr0k3XUcGawa7/ursg4+Ncix+NZ1BZ8D7Ddmcjgq inbSez4qrB2yg9BcTMlHVfvfyYbW+g3odEuqIQwovOcF/Uyhd83cRTYnzonZUdPDXvBH MzQ5mowSlxYWzjMYoaq4+Cc0BiR9xhwzbvljIAdL16I4giusp6RhcPEKJTAcyyiEzEaN CKaw== X-Gm-Message-State: AOAM5325cSNpsdIQG3xx7OsAEXs9wlkuvX1eAonv8ZF54Bwljr9qTpOv nUFs5IinkLeP51Zh8/q6ttidqu+6NOuyOLmDF4mvvsjO X-Google-Smtp-Source: ABdhPJwbwz2VtnczVTp0LUD8is096j7n/ZGvI9tGRI23EcsBchrW9jDRiV0Y8Xx3s0wkx1eyOgJKP2OV+eAf3+FK+3k= X-Received: by 2002:ab0:1167:: with SMTP id g39mr21484290uac.60.1594153054128; Tue, 07 Jul 2020 13:17:34 -0700 (PDT) MIME-Version: 1.0 References: <20200706202518.1153647-1-abhishekpandit@chromium.org> In-Reply-To: From: Abhishek Pandit-Subedi Date: Tue, 7 Jul 2020 13:17:23 -0700 Message-ID: Subject: Re: [BlueZ PATCH v7 0/6] device: Allow devices to be marked as wake capable To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" , Alain Michaud , Marcel Holtmann , ChromeOS Bluetooth Upstreaming Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: D878652B95 X-Rspamd-UID: c23771 Thanks Luiz. On Tue, Jul 7, 2020 at 10:50 AM Luiz Augusto von Dentz wrote: > > Hi Abhishek, > > On Mon, Jul 6, 2020 at 1:25 PM Abhishek Pandit-Subedi > wrote: > > > > > > Hi Luiz, > > > > This change accompanies a change in the kernel to allow marking devices > > as wakeable so they can wake the system from suspend. Currently, only > > HID devices support this and will be configured to allow this setting to > > be changed via the WakeAllowed property. > > > > Accompanying kernel change: https://patchwork.kernel.org/patch/11609999/ > > > > In order to set this flag, Bluez must call Set Device Flags with the > > Remote Wakeup bit set. This change was tested with the accompanying > > kernel changes on v5.4 with both manual tests and automated tests. > > > > Here's the tests that I ran manually: > > - Pair new HID device and confirm it has Wake Allowed to True > > (default). Verify device can be woken from suspend with device. > > - Restart bluetoothd, confirm Device Flags Changed event after Add > > Device has no Remote Wakeup flag and Set Device Flags is called > > afterwards to restore it. Verify wake from suspend still works. > > - Disable Wake allowed via dbus and confirm wake from suspend no > > longer works. > > - Restart bluetoothd and confirm Wake Allowed is still false. Verify > > wake from suspend does not work. > > > > Thanks > > Abhishek > > > > Changes in v7: > > * Fix more build issues reported by bluez.test.bot > > > > Changes in v6: > > * Fix up some build issues reported by bluez.test.bot > > * Save pending property id and emit success only after set flags returns > > * Ignore multiple calls to set_wake_allowed to the same value > > * Emit property error busy if same value is already sent to mgmt > > * Fix up build issues reported by bluez.test.bot > > > > Changes in v5: > > - Use device_flags mgmt op > > * Decode device flags > > * Refactor to use set_wake_flags and respond to device flags changed > > * Add wake_override so we can keep track of user/profile configuration > > vs what is currently active > > * Only call device_set_wake_support > > > > Changes in v4: > > * Renamed wake_capable to wake_allowed > > * Removed set_wake_capable mgmt op and updated add_device to accept > > flags to set whether a device is wakeable > > * Refactored adapter_whitelist_add and adapter_auto_connect_add to call > > adapter_add_device > > * Renamed WakeCapable to WakeAllowed > > * Renamed WakeCapable to WakeAllowed > > * Renamed device_set_profile_wake_support to just > > device_set_wake_support > > > > Changes in v3: > > * Added profile_wake_support and made wake_capable dependent on it > > * Added documentation for WakeCapable > > * Mark HID device to support wake from suspend > > > > Changes in v2: > > * Added dbus api "WakeCapable" to set value > > * Update device_set_wake_capable to be called by > > adapter_set_wake_capable_complete so we can emit property changed > > * Newly added to show whether device is wake capable > > * Removed automatically setting wake capable for HID devices > > > > Abhishek Pandit-Subedi (6): > > mgmt: Add mgmt op and events for device flags > > monitor: Decode device flags mgmt ops and event > > device: Support marking a device with wake allowed > > client: Display wake allowed property with info > > doc/device-api: Add WakeAllowed > > input: Make HID devices support wake > > > > client/main.c | 1 + > > doc/device-api.txt | 5 + > > lib/mgmt.h | 33 +++++++ > > monitor/packet.c | 70 ++++++++++++++ > > profiles/input/device.c | 1 + > > profiles/input/hog.c | 1 + > > src/adapter.c | 93 ++++++++++++++++++ > > src/adapter.h | 3 +- > > src/device.c | 210 ++++++++++++++++++++++++++++++++++++++++ > > src/device.h | 10 ++ > > 10 files changed, 426 insertions(+), 1 deletion(-) > > > > -- > > 2.27.0.212.ge8ba1cc988-goog > > Applied, thanks. > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yHBNKWbbBF8+XgEAvsO+Rg (envelope-from ) for ; Tue, 07 Jul 2020 22:30:30 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id KJzhJ2bbBF8UTgEAgupzMw (envelope-from ); Tue, 07 Jul 2020 22:30:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AE4B1A302D; Tue, 7 Jul 2020 22:30:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728430AbgGGUaR (ORCPT + 1 other); Tue, 7 Jul 2020 16:30:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:48980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728020AbgGGUaR (ORCPT ); Tue, 7 Jul 2020 16:30:17 -0400 Received: from embeddedor (unknown [200.39.26.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2129206C3; Tue, 7 Jul 2020 20:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594153815; bh=ZBG73L/0WVqupbAF8AmWnDxYad91I+9I1o5IDmHitwY=; h=Date:From:To:Cc:Subject:From; b=NzUBMPH/ZaapJTJiyzPUPPW1foolDWpL0iqmVYiH4frWQyxIpGocwDiReTEJo31Ul CZ49UYizkrY++Si77EnlY3L448s4U3/xeNe97CUzBzFfJGmI+O2mlkcH0kGfjdQ6vN QjQzahhoQ5rWu9yUmfrrDJYEzaWyQe4UWFp3GpbU= Date: Tue, 7 Jul 2020 15:35:41 -0500 From: "Gustavo A. R. Silva" To: Marcel Holtmann , Johan Hedberg , "David S. Miller" , Jakub Kicinski Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH][next] Bluetooth: Use fallthrough pseudo-keyword Message-ID: <20200707203541.GA8972@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: AE4B1A302D X-Rspamd-UID: fd21a0 Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva --- drivers/bluetooth/bcm203x.c | 2 +- drivers/bluetooth/bluecard_cs.c | 2 -- drivers/bluetooth/hci_ll.c | 2 +- drivers/bluetooth/hci_qca.c | 8 +------- net/bluetooth/hci_event.c | 4 ++-- net/bluetooth/hci_sock.c | 3 +-- net/bluetooth/l2cap_core.c | 19 +++++++++---------- net/bluetooth/l2cap_sock.c | 4 ++-- net/bluetooth/mgmt.c | 4 ++-- net/bluetooth/rfcomm/core.c | 2 +- net/bluetooth/rfcomm/sock.c | 2 +- net/bluetooth/smp.c | 2 +- 12 files changed, 22 insertions(+), 32 deletions(-) diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c index 3b176257b993..e667933c3d70 100644 --- a/drivers/bluetooth/bcm203x.c +++ b/drivers/bluetooth/bcm203x.c @@ -106,7 +106,7 @@ static void bcm203x_complete(struct urb *urb) } data->state = BCM203X_LOAD_FIRMWARE; - /* fall through */ + fallthrough; case BCM203X_LOAD_FIRMWARE: if (data->fw_sent == data->fw_size) { usb_fill_int_urb(urb, udev, usb_rcvintpipe(udev, BCM203X_IN_EP), diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index cc6e56223656..36eabf61717f 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -295,7 +295,6 @@ static void bluecard_write_wakeup(struct bluecard_info *info) baud_reg = REG_CONTROL_BAUD_RATE_115200; break; case PKT_BAUD_RATE_57600: - /* Fall through... */ default: baud_reg = REG_CONTROL_BAUD_RATE_57600; break; @@ -585,7 +584,6 @@ static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud) hci_skb_pkt_type(skb) = PKT_BAUD_RATE_115200; break; case 57600: - /* Fall through... */ default: cmd[4] = 0x03; hci_skb_pkt_type(skb) = PKT_BAUD_RATE_57600; diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c index d9a4c6c691e0..8bfe024d1fcd 100644 --- a/drivers/bluetooth/hci_ll.c +++ b/drivers/bluetooth/hci_ll.c @@ -219,7 +219,7 @@ static void ll_device_want_to_wakeup(struct hci_uart *hu) * perfectly safe to always send one. */ BT_DBG("dual wake-up-indication"); - /* fall through */ + fallthrough; case HCILL_ASLEEP: /* acknowledge device wake up */ if (send_hcill_cmd(HCILL_WAKE_UP_ACK, hu) < 0) { diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 99d14c777105..7e395469ca4f 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -472,8 +472,6 @@ static void hci_ibs_tx_idle_timeout(struct timer_list *t) case HCI_IBS_TX_ASLEEP: case HCI_IBS_TX_WAKING: - /* Fall through */ - default: BT_ERR("Spurious timeout tx state %d", qca->tx_ibs_state); break; @@ -516,8 +514,6 @@ static void hci_ibs_wake_retrans_timeout(struct timer_list *t) case HCI_IBS_TX_ASLEEP: case HCI_IBS_TX_AWAKE: - /* Fall through */ - default: BT_ERR("Spurious timeout tx state %d", qca->tx_ibs_state); break; @@ -835,8 +831,6 @@ static void device_woke_up(struct hci_uart *hu) break; case HCI_IBS_TX_ASLEEP: - /* Fall through */ - default: BT_ERR("Received HCI_IBS_WAKE_ACK in tx state %d", qca->tx_ibs_state); @@ -2072,7 +2066,7 @@ static int __maybe_unused qca_suspend(struct device *dev) switch (qca->tx_ibs_state) { case HCI_IBS_TX_WAKING: del_timer(&qca->wake_retrans_timer); - /* Fall through */ + fallthrough; case HCI_IBS_TX_AWAKE: del_timer(&qca->tx_idle_timer); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 03a0759f2fc2..94f046f08301 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2825,7 +2825,7 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) case HCI_AUTO_CONN_LINK_LOSS: if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT) break; - /* Fall through */ + fallthrough; case HCI_AUTO_CONN_DIRECT: case HCI_AUTO_CONN_ALWAYS: @@ -4320,7 +4320,7 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev, if (hci_setup_sync(conn, conn->link->handle)) goto unlock; } - /* fall through */ + fallthrough; default: conn->state = BT_CLOSED; diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index d5627967fc25..fad842750442 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -443,8 +443,7 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event) case HCI_DEV_SETUP: if (hdev->manufacturer == 0xffff) return NULL; - - /* fall through */ + fallthrough; case HCI_DEV_UP: skb = bt_skb_alloc(HCI_MON_INDEX_INFO_SIZE, GFP_ATOMIC); diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 35d2bc569a2d..ade83e224567 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -666,8 +666,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err) l2cap_seq_list_free(&chan->srej_list); l2cap_seq_list_free(&chan->retrans_list); - - /* fall through */ + fallthrough; case L2CAP_MODE_STREAMING: skb_queue_purge(&chan->tx_q); @@ -872,7 +871,8 @@ static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan) else return HCI_AT_NO_BONDING; } - /* fall through */ + fallthrough; + default: switch (chan->sec_level) { case BT_SECURITY_HIGH: @@ -2983,8 +2983,7 @@ static void l2cap_tx_state_wait_f(struct l2cap_chan *chan, break; case L2CAP_EV_RECV_REQSEQ_AND_FBIT: l2cap_process_reqseq(chan, control->reqseq); - - /* Fall through */ + fallthrough; case L2CAP_EV_RECV_FBIT: if (control && control->final) { @@ -3311,7 +3310,7 @@ static inline __u8 l2cap_select_mode(__u8 mode, __u16 remote_feat_mask) case L2CAP_MODE_ERTM: if (l2cap_mode_supported(mode, remote_feat_mask)) return mode; - /* fall through */ + fallthrough; default: return L2CAP_MODE_BASIC; } @@ -3447,7 +3446,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data, size_t data if (__l2cap_efs_supported(chan->conn)) set_bit(FLAG_EFS_ENABLE, &chan->flags); - /* fall through */ + fallthrough; default: chan->mode = l2cap_select_mode(rfc.mode, chan->conn->feat_mask); break; @@ -4539,7 +4538,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, goto done; break; } - /* fall through */ + fallthrough; default: l2cap_chan_set_err(chan, ECONNRESET); @@ -7719,7 +7718,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) conn->mtu = hcon->hdev->le_mtu; break; } - /* fall through */ + fallthrough; default: conn->mtu = hcon->hdev->acl_mtu; break; @@ -7841,7 +7840,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, case L2CAP_MODE_STREAMING: if (!disable_ertm) break; - /* fall through */ + fallthrough; default: err = -EOPNOTSUPP; goto done; diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index a995d2c51fa7..738a5345fa21 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -284,7 +284,7 @@ static int l2cap_sock_listen(struct socket *sock, int backlog) case L2CAP_MODE_STREAMING: if (!disable_ertm) break; - /* fall through */ + fallthrough; default: err = -EOPNOTSUPP; goto done; @@ -760,7 +760,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, case L2CAP_MODE_STREAMING: if (!disable_ertm) break; - /* fall through */ + fallthrough; default: err = -EINVAL; break; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5e9b9728eeac..2e6b4312f5fe 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -4504,7 +4504,7 @@ static bool discovery_type_is_valid(struct hci_dev *hdev, uint8_t type, *mgmt_status = mgmt_le_support(hdev); if (*mgmt_status) return false; - /* Intentional fall-through */ + fallthrough; case DISCOV_TYPE_BREDR: *mgmt_status = mgmt_bredr_support(hdev); if (*mgmt_status) @@ -5880,7 +5880,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, case MGMT_LTK_P256_DEBUG: authenticated = 0x00; type = SMP_LTK_P256_DEBUG; - /* fall through */ + fallthrough; default: continue; } diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 2e20af317cea..f2bacb464ccf 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c @@ -479,7 +479,7 @@ static int __rfcomm_dlc_close(struct rfcomm_dlc *d, int err) /* if closing a dlc in a session that hasn't been started, * just close and unlink the dlc */ - /* fall through */ + fallthrough; default: rfcomm_dlc_clear_timer(d); diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index df14eebe80da..0afc4bc5ab41 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -218,7 +218,7 @@ static void __rfcomm_sock_close(struct sock *sk) case BT_CONFIG: case BT_CONNECTED: rfcomm_dlc_close(d, 0); - /* fall through */ + fallthrough; default: sock_set_flag(sk, SOCK_ZAPPED); diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 684e60e1915c..21f5e6d9ea95 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -1654,7 +1654,7 @@ int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey) memset(smp->tk, 0, sizeof(smp->tk)); BT_DBG("PassKey: %d", value); put_unaligned_le32(value, smp->tk); - /* Fall Through */ + fallthrough; case MGMT_OP_USER_CONFIRM_REPLY: set_bit(SMP_FLAG_TK_VALID, &smp->flags); break; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iGNAAQP9BF89MQAAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 00:53:55 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id AHVAOwL9BF9bfAEAlp8NpQ (envelope-from ); Wed, 08 Jul 2020 00:53:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id ADD76A2C65; Wed, 8 Jul 2020 00:53:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729348AbgGGWwe (ORCPT + 1 other); Tue, 7 Jul 2020 18:52:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728299AbgGGWwe (ORCPT ); Tue, 7 Jul 2020 18:52:34 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB9DCC08C5E1 for ; Tue, 7 Jul 2020 15:52:33 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id w2so19890638pgg.10 for ; Tue, 07 Jul 2020 15:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Tg/83hrbdiKC/nqtULfMVzExwdn+D48CNwXlyo8fmO4=; b=BUW2C+eLfsuR3+MVx1e1OCy+7uFgx75RJLG1jW550N43OasNBoRqPU9cB8UXYlfNDu pcU1SBWMsnh822z3jayvN0pIM00XnDdb8FMJBRAAJGgSeedETZntzbCQ8EbrVjJqGFUR g8Z/FkPIapa/KAtXuPv/Xx9z25M1nW9ELxH1U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Tg/83hrbdiKC/nqtULfMVzExwdn+D48CNwXlyo8fmO4=; b=UyWIw5pphU1WyzNb9J4kGysGwcT277WYBgx0xWWon7S3PX0J8XYR6AF6w/A5kfXCPz 3UvQuJuicEueR1Td22ymXoKojLO6M5klbQRQrWAEv5Bdg533hKY7q5+Wn1f0cVsrQwvQ P/m6pwYb3IgPcowBodvKtYvflVw/6AD3j0FbEtf7/NJQCiMSM2iEF1jvmdzO0gkfRd+6 /Ar3CiamWo4X8MSQoxr+Mn6K49xbUSIzRLsqlKh3zo277RaGQfGNqf6SvLnujUlTh0V4 iLsNzGdGpHcwPhy4vMbT3xBDHFYyb2jWgYtIi5EAw0yylLmSFJTjMyurOBoN7HT1FjGU VL8g== X-Gm-Message-State: AOAM531RokutxP9YfWmmPA89Ex/HrEkhCai3EbPLvLbPcjBF5hQGkCPg DXWBXOj2b/MZw3Mjf8CI/F6wlVpz6SI= X-Google-Smtp-Source: ABdhPJwu9V/dqmxBw5pNmoYQaZrQMps5/47kI7zjjDffv70FpI2X7Gle+8miopcdNJQjUzX2lnINDg== X-Received: by 2002:a62:7bc9:: with SMTP id w192mr49102384pfc.255.1594162353028; Tue, 07 Jul 2020 15:52:33 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id 73sm23737551pfy.24.2020.07.07.15.52.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 15:52:32 -0700 (PDT) From: Miao-chen Chou To: Bluetooth Kernel Mailing List Cc: Alain Michaud , Marcel Holtmann , Abhishek Pandit-Subedi , Miao-chen Chou , "David S. Miller" , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] Bluetooth: Use whitelist for scan policy when suspending Date: Tue, 7 Jul 2020 15:52:28 -0700 Message-Id: <20200707155207.1.Id31098b8dbbcf90468fcd7fb07ad0e872b11c36b@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 25 X-Rspamd-Score: 3.84 / 15.00 / 200.00 X-Rspamd-Queue-Id: ADD76A2C65 X-Rspamd-UID: 138166 Even with one advertisement monitor in place, the scan policy should use the whitelist while the system is going to suspend to prevent waking by random advertisement. The following test was performed. - With a paired device, register one advertisement monitor, suspend the system and verify that the host was not awaken by random advertisements. Signed-off-by: Miao-chen Chou Reviewed-by: Abhishek Pandit-Subedi --- net/bluetooth/hci_request.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 6168a3440eff9..e161aabd7bf36 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -799,9 +799,10 @@ static u8 update_white_list(struct hci_request *req) /* Once the controller offloading of advertisement monitor is in place, * the if condition should include the support of MSFT extension - * support. + * support. If suspend is ongoing, whitelist should be the default to + * prevent waking by random advertisements. */ - if (!idr_is_empty(&hdev->adv_monitors_idr)) + if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended) return 0x00; /* Select filter policy to use white list */ -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KB5oFfIkBV/gKgEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 03:44:18 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id gFUWFPIkBV+miQAA0J78UA (envelope-from ); Wed, 08 Jul 2020 03:44:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 19CB8A2474; Wed, 8 Jul 2020 03:44:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729155AbgGHBnW (ORCPT + 1 other); Tue, 7 Jul 2020 21:43:22 -0400 Received: from mail-il1-f200.google.com ([209.85.166.200]:55974 "EHLO mail-il1-f200.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728592AbgGHBnW (ORCPT ); Tue, 7 Jul 2020 21:43:22 -0400 Received: by mail-il1-f200.google.com with SMTP id b2so25840760ilh.22 for ; Tue, 07 Jul 2020 18:43:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=0NTrAf+pEMjlV6Xv2ifwmFFXw6VXjE6A98kcSeFtJiY=; b=uRSb5KlgNBlk6sCEFFO1jtASS/N74adLNdbYkx1vEun7QEntOBCMhzz7PCsvWGbXgO wxh7hzALrce/cO/LvnSkZRoD/7DuH5nEoUJ/lJH7R/gLTM7Ri/wWEh9bgLFh3+uIZIO1 C4+tdUs+RS7xEPoAIOF9yAavUNZ7f5l6AbCuYDLJyFoIGChBTshFWC30ZSn1Ci3ZIhKB zjiTzSDxk5etfkslxVhM0cO0GLUItelowC4I0OtwC24Nk6/F1DYdLtd9hrGM2rnJSXno 1X5ZF11X9SrXHOF/FsIwN/Xg5/3wH2nRc16+bUUxaUwAtDQ8YfvpTTEwvWJjbf9pnd1k LBmg== X-Gm-Message-State: AOAM533rljev+S16e43RiXMkmn4Rk6SynjkhvUMnQsSxzhmlabYQmbv+ R1bsH7PeNtkSJ5tAUHKSxyohB/0SSFh0AKEFe8sfkWbBs44f X-Google-Smtp-Source: ABdhPJwFoXDqjYEyfm/RyYF2jVWY/ysqHnAgWW4txPuO0JVErrGIMtix7yYN6OCkK83q7DSmq1uyR0RQ7B6zCE7tNYDjfXDlHGv2 MIME-Version: 1.0 X-Received: by 2002:a6b:3985:: with SMTP id g127mr19244869ioa.107.1594172600851; Tue, 07 Jul 2020 18:43:20 -0700 (PDT) Date: Tue, 07 Jul 2020 18:43:20 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000095a5f205a9e43b69@google.com> Subject: KASAN: slab-out-of-bounds Read in hci_extended_inquiry_result_evt From: syzbot To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@armlinux.org.uk, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.79 / 15.00 / 200.00 X-Rspamd-Queue-Id: 19CB8A2474 X-Rspamd-UID: 2f1f50 Hello, syzbot found the following crash on: HEAD commit: 7cc2a8ea Merge tag 'block-5.8-2020-07-01' of git://git.ker.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10261e7b100000 kernel config: https://syzkaller.appspot.com/x/.config?x=7be693511b29b338 dashboard link: https://syzkaller.appspot.com/bug?extid=d8489a79b781849b9c46 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12d62e6d100000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1061f66d100000 IMPORTANT: if you fix the bug, please add the following tag to the commit: Reported-by: syzbot+d8489a79b781849b9c46@syzkaller.appspotmail.com ================================================================== BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:406 [inline] BUG: KASAN: slab-out-of-bounds in bacpy include/net/bluetooth/bluetooth.h:274 [inline] BUG: KASAN: slab-out-of-bounds in hci_extended_inquiry_result_evt.isra.0+0x1be/0x5e0 net/bluetooth/hci_event.c:4394 Read of size 6 at addr ffff88809f0ec404 by task kworker/u5:2/6794 CPU: 0 PID: 6794 Comm: kworker/u5:2 Not tainted 5.8.0-rc3-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530 check_memory_region_inline mm/kasan/generic.c:186 [inline] check_memory_region+0x13d/0x180 mm/kasan/generic.c:192 memcpy+0x20/0x60 mm/kasan/common.c:105 memcpy include/linux/string.h:406 [inline] bacpy include/net/bluetooth/bluetooth.h:274 [inline] hci_extended_inquiry_result_evt.isra.0+0x1be/0x5e0 net/bluetooth/hci_event.c:4394 hci_event_packet+0x2828/0x86f5 net/bluetooth/hci_event.c:6115 hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Allocated by task 6797: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494 __kmalloc_reserve net/core/skbuff.c:142 [inline] __alloc_skb+0xae/0x550 net/core/skbuff.c:210 alloc_skb include/linux/skbuff.h:1083 [inline] bt_skb_alloc include/net/bluetooth/bluetooth.h:377 [inline] vhci_get_user drivers/bluetooth/hci_vhci.c:165 [inline] vhci_write+0xbd/0x450 drivers/bluetooth/hci_vhci.c:285 call_write_iter include/linux/fs.h:1907 [inline] new_sync_write+0x422/0x650 fs/read_write.c:484 __vfs_write+0xc9/0x100 fs/read_write.c:497 vfs_write+0x268/0x5d0 fs/read_write.c:559 ksys_write+0x12d/0x250 fs/read_write.c:612 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:359 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 4786: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x103/0x2c0 mm/slab.c:3757 skb_free_head net/core/skbuff.c:590 [inline] skb_release_data+0x6d9/0x910 net/core/skbuff.c:610 skb_release_all net/core/skbuff.c:664 [inline] __kfree_skb+0x46/0x60 net/core/skbuff.c:678 sk_wmem_free_skb include/net/sock.h:1532 [inline] tcp_rtx_queue_unlink_and_free include/net/tcp.h:1849 [inline] tcp_clean_rtx_queue net/ipv4/tcp_input.c:3152 [inline] tcp_ack+0x1bea/0x58f0 net/ipv4/tcp_input.c:3688 tcp_rcv_established+0x1820/0x1e70 net/ipv4/tcp_input.c:5712 tcp_v4_do_rcv+0x5d1/0x870 net/ipv4/tcp_ipv4.c:1629 tcp_v4_rcv+0x2cef/0x3760 net/ipv4/tcp_ipv4.c:2011 ip_protocol_deliver_rcu+0x5c/0x880 net/ipv4/ip_input.c:204 ip_local_deliver_finish+0x20a/0x370 net/ipv4/ip_input.c:231 NF_HOOK include/linux/netfilter.h:307 [inline] NF_HOOK include/linux/netfilter.h:301 [inline] ip_local_deliver+0x1b3/0x200 net/ipv4/ip_input.c:252 dst_input include/net/dst.h:441 [inline] ip_sublist_rcv_finish+0x9a/0x2c0 net/ipv4/ip_input.c:550 ip_list_rcv_finish.constprop.0+0x514/0x6e0 net/ipv4/ip_input.c:600 ip_sublist_rcv net/ipv4/ip_input.c:608 [inline] ip_list_rcv+0x34e/0x488 net/ipv4/ip_input.c:643 __netif_receive_skb_list_ptype net/core/dev.c:5324 [inline] __netif_receive_skb_list_core+0x549/0x8e0 net/core/dev.c:5372 __netif_receive_skb_list net/core/dev.c:5424 [inline] netif_receive_skb_list_internal+0x777/0xd70 net/core/dev.c:5531 gro_normal_list net/core/dev.c:5642 [inline] gro_normal_list net/core/dev.c:5638 [inline] napi_complete_done+0x1f1/0x860 net/core/dev.c:6367 virtqueue_napi_complete+0x2c/0xc0 drivers/net/virtio_net.c:329 virtnet_poll+0xae0/0xd76 drivers/net/virtio_net.c:1455 napi_poll net/core/dev.c:6684 [inline] net_rx_action+0x4a1/0xe60 net/core/dev.c:6752 __do_softirq+0x34c/0xa60 kernel/softirq.c:292 The buggy address belongs to the object at ffff88809f0ec000 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 4 bytes to the right of 1024-byte region [ffff88809f0ec000, ffff88809f0ec400) The buggy address belongs to the page: page:ffffea00027c3b00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea0002587dc8 ffffea00027c8e08 ffff8880aa000c40 raw: 0000000000000000 ffff88809f0ec000 0000000100000002 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809f0ec300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88809f0ec380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff88809f0ec400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff88809f0ec480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88809f0ec500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ================================================================== --- This bug is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this bug report. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this bug, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oJ5IMmM+BV++lgEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 05:32:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id GCKkMGM+BV/KZQAAlp8NpQ (envelope-from ); Wed, 08 Jul 2020 05:32:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8B2A852428; Wed, 8 Jul 2020 05:32:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729238AbgGHDcp (ORCPT + 1 other); Tue, 7 Jul 2020 23:32:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727090AbgGHDcp (ORCPT ); Tue, 7 Jul 2020 23:32:45 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C05AC061755 for ; Tue, 7 Jul 2020 20:32:45 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id y3so50233143ybf.4 for ; Tue, 07 Jul 2020 20:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=odnQeCCDeJlo4axhRc7XyOZpCom8cJ2ILuCEO99s6zs=; b=dAP0WOMWjSVSsL757K4+s7n5xeRs51KtF4+KBxJSwGYcJlVgT9BAYzSCVGaUdpi5uK ydksM3Dg7zrYypgOEDuC3BynbfQjTOLcYb4eNwg7kO2n6dbyTGQ9CpIIHuRiVs3ad+Uz CQvxAVh8KSqEvFAcs7w9TGxm/Xqc6A4ruLhU65KwGT/6uxLolCpXpuHYYcUBTjnwcyPe m+6noJLuLHnL4nIU+pxTky14zKoPZQtE4fzdnywRIbDvum3mIwTtyfq4E2H1lIa383V+ L418tai7NfHpzgwRgbUFbV4iN+3WbYoGCtaGltKxOBmaSZB+GXHhVLPCq04lZHmGMe+t 7rBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=odnQeCCDeJlo4axhRc7XyOZpCom8cJ2ILuCEO99s6zs=; b=t0QYXKD/49BhxBhP/eADIPj1LYn5bqsU7ZgiouDNWN0r8Ya0QU9ZIqxBhcOiDCq2ya 0USrtXAdr7iZaDG4AL+jEzfxytmgZ5ss7Yrbax2VXmL+QnWhJozUfSEGAwYIL80njMUF n03r1vlrd7F2dcTS4EAFmVIrfijkE+k9qXL6QYWxmmCKrgYq/Srqr0PqiJ9tj+Fvvedy ul6FlxUej3ArRZbWjRyoCDoE/V4xBDUT4nYGz4l0TxHrAnchKMLUEJneULGXlkEY/PcJ t561VJcbzDCkIu9ItoxmrV6h1JMGChpHO4f3M1r6c2cOw89U3ZHmYvsP1Tc0zGSHmD4y SC/g== X-Gm-Message-State: AOAM533V+hx9Yuac9i8wf4hq3wlDJR80wdlD2miLp7NmmoJng2ciaTJy A67JQoz9SxUf6jWTLhhM+MoRk9O2sTDGEjICNRaw4+atxl+dk0SNccBPkCGAldgK6KjdYlt4KJo tMYy+YReru+spq8gXZ5QaHIGU6/WLXOgw3hBfcQZGGIchql6jsxc8uznDgxHhcF4MNwMVpKZqeY eFOLfE+rL6YOE= X-Google-Smtp-Source: ABdhPJxLbJuaS3QepNbC3Sa1cThNz7v51z6Icq1ygy3xGHdS22QHClXgD00KSNpBSqQyFovpTGicvSSjKMuVB+lLeQ== X-Received: by 2002:a25:3342:: with SMTP id z63mr87459609ybz.200.1594179164413; Tue, 07 Jul 2020 20:32:44 -0700 (PDT) Date: Wed, 8 Jul 2020 11:32:23 +0800 Message-Id: <20200708113139.bluez.v1.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog Subject: [bluez PATCH v1] avrcp: include all player settings in notif event From: Howard Chung To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, Howard Chung , Archie Pusaka Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 0.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8B2A852428 X-Rspamd-UID: 229f62 According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player application settings should be returned to the CT and let CT to determine which settings have changed. Currently bluez only returns the changed attribute instead. This patch also addresses a potential issue on which the number of application settings mismatches with the actual number returned. Reviewed-by: Archie Pusaka --- profiles/audio/avrcp.c | 69 ++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index e2428250e..da0c7c9da 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -369,6 +369,7 @@ static uint32_t company_ids[] = { }; static void avrcp_register_notification(struct avrcp *session, uint8_t event); +static GList *player_list_settings(struct avrcp_player *player); static sdp_record_t *avrcp_ct_record(void) { @@ -743,6 +744,35 @@ static int play_status_to_val(const char *status) return -EINVAL; } +static uint16_t player_settings_changed(struct avrcp_player *player, + struct avrcp_header *pdu) +{ + GList *settings = player_list_settings(player); + int size = 2; + + for (; settings; settings = settings->next) { + const char *key = settings->data; + int attr; + int val; + + attr = attr_to_val(key); + if (attr < 0) + continue; + + val = player_get_setting(player, attr); + if (val < 0) + continue; + + pdu->params[size++] = attr; + pdu->params[size++] = val; + } + + g_list_free(settings); + + pdu->params[1] = (size - 2) >> 1; + return size; +} + void avrcp_player_event(struct avrcp_player *player, uint8_t id, const void *data) { @@ -751,6 +781,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, uint8_t code; uint16_t size; GSList *l; + GList *settings; int attr; int val; @@ -791,19 +822,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, size = 1; break; case AVRCP_EVENT_SETTINGS_CHANGED: - size = 2; - pdu->params[1] = 1; - - attr = attr_to_val(data); - if (attr < 0) - return; - - val = player_get_setting(player, attr); - if (val < 0) - return; - - pdu->params[size++] = attr; - pdu->params[size++] = val; + size = player_settings_changed(player, pdu); break; case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: size = 5; @@ -1626,29 +1645,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, len = 1; break; case AVRCP_EVENT_SETTINGS_CHANGED: - len = 1; - settings = player_list_settings(player); - - pdu->params[len++] = g_list_length(settings); - for (; settings; settings = settings->next) { - const char *key = settings->data; - int attr; - int val; - - attr = attr_to_val(key); - if (attr < 0) - continue; - - val = player_get_setting(player, attr); - if (val < 0) - continue; - - pdu->params[len++] = attr; - pdu->params[len++] = val; - } - - g_list_free(settings); - + len = player_settings_changed(player, pdu); break; case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: len = 5; -- 2.27.0.383.g050319c2ae-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EKbQAIRCBV8pogEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 05:50:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2N3/OoNCBV/GyQEADc0bRg (envelope-from ); Wed, 08 Jul 2020 05:50:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D6F1EA10B1; Wed, 8 Jul 2020 05:50:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729556AbgGHDuW (ORCPT + 1 other); Tue, 7 Jul 2020 23:50:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729506AbgGHDuV (ORCPT ); Tue, 7 Jul 2020 23:50:21 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B22D8C061755 for ; Tue, 7 Jul 2020 20:50:21 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id g13so33494227qtv.8 for ; Tue, 07 Jul 2020 20:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=oQ73hcC0RLyzUpoLxb3yCD8dQWRA/dbCO/y1l+UPuKA=; b=Nh0GMeRESx312cpmpYq95nn4YvhfKUmLiIu0g75kHhG2GmK2/rdGhFQO+aDLadNXfA p8LWtCYjhoLadqfgxfzkIG2baDZlTox+bUXF75HtGIJxXyCnGRSwzojOQX0EmRf9pN3Z hXrCmeHd/O0TNz61vbwIL7hMmJBE/e7N8sXJvdQCygqz+lBEh32N3Ee7V8SQxE73aMjv v1BwhkOQgpHxDI7UGBED5z+YrBlVsCnA6388J3b/G2KqXjJuqd/sdNAbP4D6YS9BpR5N 6jtZYcCyuAi7AEugyWxuw1t1IiGYzs+PLU9eqJ3cz0tnIw7hm5VklZjW/UD5yyHXfn/8 Ck3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=oQ73hcC0RLyzUpoLxb3yCD8dQWRA/dbCO/y1l+UPuKA=; b=U9djFM43pjb1zM3p2gZI0jBJW6l4wPattcSeIk/YrqCoqpEiH6JwwytbyV56GNdQGH ZQcntGBvzmmOfpe6OYfaksvoioJrn9PhKz0Shik4M6ML9cOWfbr29vDUnDcm1/ow2pAa Ve0ZZUCtPSmW4LYK3/L4jf+/XlsL5otEiKYyaIQLEWFMxQyevAn6lKJOUkOCAqbYxY7k g2QZhk/1gSFoAVI3VbU+gAVbTDVHtXEo7LxPk/DfTWTAIxCSbIzDyygtVxgkv3h4z4YX wKqLfdeqHDe5OKnRMC+Liwwa0z0Ew1cCQ8x6VS+wXwkgtIlINZfBfOtGLa/95eHDhcWu 4pSA== X-Gm-Message-State: AOAM531AeYL48eFPxv+Vd+ol8ssiqTMBaDNAjGwocat+Qi7UqjXGCLrq kLdieg/5SmUu2mEZr8hjvnJRclIYm0g= X-Google-Smtp-Source: ABdhPJx0HhmFA5ckq8VB45rWgB9u6pqRkepJDbtDQS09JJh4bF3EYF6dcxF0HKbuDr5/HuD4aS3oeg== X-Received: by 2002:ac8:2783:: with SMTP id w3mr7106032qtw.66.1594180220830; Tue, 07 Jul 2020 20:50:20 -0700 (PDT) Received: from [172.17.0.2] ([104.209.191.168]) by smtp.gmail.com with ESMTPSA id w11sm29423781qtk.35.2020.07.07.20.50.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 20:50:20 -0700 (PDT) Message-ID: <5f05427c.1c69fb81.f61e.0992@mx.google.com> Date: Tue, 07 Jul 2020 20:50:20 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3475845981174350110==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, howardchung@google.com Subject: RE: [bluez,v1] avrcp: include all player settings in notif event Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200708113139.bluez.v1.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> References: <20200708113139.bluez.v1.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 19 X-Rspamd-Score: 2.86 / 15.00 / 200.00 X-Rspamd-Queue-Id: D6F1EA10B1 X-Rspamd-UID: f8f0f9 --===============3475845981174350110== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnByb2ZpbGVzL2F1ZGlvL2F2cmNwLmM6IEluIGZ1bmN0aW9uIOKAmGF2 cmNwX3BsYXllcl9ldmVudOKAmToKcHJvZmlsZXMvYXVkaW8vYXZyY3AuYzo3ODY6NjogZXJyb3I6 IHVudXNlZCB2YXJpYWJsZSDigJh2YWzigJkgWy1XZXJyb3I9dW51c2VkLXZhcmlhYmxlXQogIDc4 NiB8ICBpbnQgdmFsOwogICAgICB8ICAgICAgXn5+CnByb2ZpbGVzL2F1ZGlvL2F2cmNwLmM6Nzg1 OjY6IGVycm9yOiB1bnVzZWQgdmFyaWFibGUg4oCYYXR0cuKAmSBbLVdlcnJvcj11bnVzZWQtdmFy aWFibGVdCiAgNzg1IHwgIGludCBhdHRyOwogICAgICB8ICAgICAgXn5+fgpwcm9maWxlcy9hdWRp by9hdnJjcC5jOjc4NDo5OiBlcnJvcjogdW51c2VkIHZhcmlhYmxlIOKAmHNldHRpbmdz4oCZIFst V2Vycm9yPXVudXNlZC12YXJpYWJsZV0KICA3ODQgfCAgR0xpc3QgKnNldHRpbmdzOwogICAgICB8 ICAgICAgICAgXn5+fn5+fn4KcHJvZmlsZXMvYXVkaW8vYXZyY3AuYzogSW4gZnVuY3Rpb24g4oCY YXZyY3BfaGFuZGxlX3JlZ2lzdGVyX25vdGlmaWNhdGlvbuKAmToKcHJvZmlsZXMvYXVkaW8vYXZy Y3AuYzoxNjE3Ojk6IGVycm9yOiB1bnVzZWQgdmFyaWFibGUg4oCYc2V0dGluZ3PigJkgWy1XZXJy b3I9dW51c2VkLXZhcmlhYmxlXQogMTYxNyB8ICBHTGlzdCAqc2V0dGluZ3M7CiAgICAgIHwgICAg ICAgICBefn5+fn5+fgpjYzE6IGFsbCB3YXJuaW5ncyBiZWluZyB0cmVhdGVkIGFzIGVycm9ycwpt YWtlWzFdOiAqKiogW01ha2VmaWxlOjg0Njc6IHByb2ZpbGVzL2F1ZGlvL2JsdWV0b290aGQtYXZy Y3Aub10gRXJyb3IgMQptYWtlOiAqKiogW01ha2VmaWxlOjQwMTA6IGFsbF0gRXJyb3IgMgoKCgot LS0KUmVnYXJkcywKTGludXggQmx1ZXRvb3RoCg== --===============3475845981174350110==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4IJ6E2lJBV/XwAEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 06:19:53 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id APznEWlJBV/+BgEA0J78UA (envelope-from ); Wed, 08 Jul 2020 06:19:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B68EF52B95; Wed, 8 Jul 2020 06:19:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729385AbgGHETm (ORCPT + 1 other); Wed, 8 Jul 2020 00:19:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725446AbgGHETm (ORCPT ); Wed, 8 Jul 2020 00:19:42 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00DEEC061755 for ; Tue, 7 Jul 2020 21:19:41 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id t7so35296078ybk.2 for ; Tue, 07 Jul 2020 21:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=IgLPwFPJVaB1oc0Pd9NiOCIHkZRJPlObT0iPNSI37aQ=; b=XxI29Sz53C4fa2qizmf+lhuIIKSTAOmfn/gtlMYndgCPQXKmqrLaA2ofJy9unue41w t9Y845lAdWMewYd+4MdGdCrwBuCVBskg41ROWi3M9CZ6qVyd6CqB5lWSiqAxLFvJTC3v jHO7dbZNSaWzg+2FOam/r+y/gVn3T88pbYyA7BaYMOmtjtnOUUG0yX4sFeZvLHQuqv6O tHvEB/la8YM2/8XCcBUm4KalWlfRwlBvJXDmyFO5DEyswJkrsRWtwBG+lqDM5fyFyrvI /bH/7alLYQHf/btXrk/zQxUKndyvPtgVPfv+AXd44ZctIEu4ddLDZhxMR3HGtdtcbecg unxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=IgLPwFPJVaB1oc0Pd9NiOCIHkZRJPlObT0iPNSI37aQ=; b=DB3qG2uTAC5G+1GrhXgU63FGPfIVDvZwxpQLhwySJTdXd08YdFRhKmG8ymYbMjd8wb 0izQE+c4uEPKqLjMGqygLKEAFz5NWpjliS7pFACkyje26PSakPPHTdTtUycR5UiUpGG2 msXFfWXpKJaLsnTXffzLcgVZVvIPei0ST3cK6iF9jg5zFT6P+XBBXyvnAxQUz07sUijw YWtACfnlBamAq1ufRBAQGi/LH9+g97eHdxSToebwMeDbnlKdOT2BMl+HdHSxCwNaOVoF OQNrjK4NRO99cOQUuMd3b4RGCKSlb2w7uXXtI7gtrfMy2MnGFOH0+WMWEPN9zH7x/YtO PPGg== X-Gm-Message-State: AOAM531t7qZmsY8pnxFJGCgkDJP8k/4svi+EiLXmSs59IIiQgFnDpy2k rkJGd3v47gzaxfJ5Gr5x8QEipzc87Re6v37v6vGCiJb8ULRrmUOTbMkPBwKnXcFxILjrOwqJG78 T/VNox2ymxlw5h+krCnABEGGj/McGLNd2g1zvxUgwqawV0pV+TRRgMnFQ8RJWorkBvmumFzyjYV k/X/33Zd66vr8= X-Google-Smtp-Source: ABdhPJwOm6ZZ1/S0Seu5p6Soe7jzFJMn3HauEmEs1GHcMABxksPmbEDLz/zI2L0mam6JBJ+2IHUX/yIcBZs3moPtww== X-Received: by 2002:a25:c711:: with SMTP id w17mr10971154ybe.465.1594181981156; Tue, 07 Jul 2020 21:19:41 -0700 (PDT) Date: Wed, 8 Jul 2020 12:19:32 +0800 Message-Id: <20200708121928.bluez.v2.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog Subject: [bluez PATCH v2] avrcp: include all player settings in notif event From: Howard Chung To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, Howard Chung , Archie Pusaka Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: B68EF52B95 X-Rspamd-UID: 15cb21 According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player application settings should be returned to the CT and let CT to determine which settings have changed. Currently bluez only returns the changed attribute instead. This patch also addresses a potential issue on which the number of application settings mismatches with the actual number returned. Reviewed-by: Archie Pusaka --- Changes in v2: - Fixed unused variables profiles/audio/avrcp.c | 71 +++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index e2428250e..a4de7530e 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -369,6 +369,7 @@ static uint32_t company_ids[] = { }; static void avrcp_register_notification(struct avrcp *session, uint8_t event); +static GList *player_list_settings(struct avrcp_player *player); static sdp_record_t *avrcp_ct_record(void) { @@ -743,6 +744,35 @@ static int play_status_to_val(const char *status) return -EINVAL; } +static uint16_t player_settings_changed(struct avrcp_player *player, + struct avrcp_header *pdu) +{ + GList *settings = player_list_settings(player); + int size = 2; + + for (; settings; settings = settings->next) { + const char *key = settings->data; + int attr; + int val; + + attr = attr_to_val(key); + if (attr < 0) + continue; + + val = player_get_setting(player, attr); + if (val < 0) + continue; + + pdu->params[size++] = attr; + pdu->params[size++] = val; + } + + g_list_free(settings); + + pdu->params[1] = (size - 2) >> 1; + return size; +} + void avrcp_player_event(struct avrcp_player *player, uint8_t id, const void *data) { @@ -751,8 +781,6 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, uint8_t code; uint16_t size; GSList *l; - int attr; - int val; if (player->sessions == NULL) return; @@ -791,19 +819,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, size = 1; break; case AVRCP_EVENT_SETTINGS_CHANGED: - size = 2; - pdu->params[1] = 1; - - attr = attr_to_val(data); - if (attr < 0) - return; - - val = player_get_setting(player, attr); - if (val < 0) - return; - - pdu->params[size++] = attr; - pdu->params[size++] = val; + size = player_settings_changed(player, pdu); break; case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: size = 5; @@ -1595,7 +1611,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, struct btd_device *dev = session->dev; uint16_t len = ntohs(pdu->params_len); uint64_t uid; - GList *settings; /* * 1 byte for EventID, 4 bytes for Playback interval but the latest @@ -1626,29 +1641,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, len = 1; break; case AVRCP_EVENT_SETTINGS_CHANGED: - len = 1; - settings = player_list_settings(player); - - pdu->params[len++] = g_list_length(settings); - for (; settings; settings = settings->next) { - const char *key = settings->data; - int attr; - int val; - - attr = attr_to_val(key); - if (attr < 0) - continue; - - val = player_get_setting(player, attr); - if (val < 0) - continue; - - pdu->params[len++] = attr; - pdu->params[len++] = val; - } - - g_list_free(settings); - + len = player_settings_changed(player, pdu); break; case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: len = 5; -- 2.27.0.383.g050319c2ae-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8Ge0IAhMBV+kzgEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 06:31:04 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4JsZHwhMBV+UxwAAgupzMw (envelope-from ); Wed, 08 Jul 2020 06:31:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1B680A010F; Wed, 8 Jul 2020 06:31:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728388AbgGHEa7 (ORCPT + 1 other); Wed, 8 Jul 2020 00:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726313AbgGHEa6 (ORCPT ); Wed, 8 Jul 2020 00:30:58 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24EB9C061755 for ; Tue, 7 Jul 2020 21:30:58 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id w3so1488698wmi.4 for ; Tue, 07 Jul 2020 21:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ZKamWyOk2LKr0w8kMEWnJTr+pCyij1spBpIwpyFRRm8=; b=YIYXBg1NoP8wmcNsD0Sf4ZqISekt1oF13AOJdsyxFYf8nBDU8Yj57Tc3HD/prjdXlP TrHYJjd97VIb2gnO0Ydbfv2wHVeRcvn/8Id392i3nbpDMKhzQm2wCcH23rl4q3VgrpOD gE8XnSt3Go7HqEkVJIuwKALtOZljq9scAKLYiGQ6RIFy1Rq4OWoSMaKITjUU/D7n/sJ1 gcSDlt6BpNSnXnn1ZS8Kj643VJkUY6gmYfdnVV5f4q+lgWu+U871fLpg2HFPh9KeZEJw 5Tens72l8M3bXXe3NKu4IIzqNsHLvhx5fttAo7cLSkECLJzCmCGDMWHPUFsKyxLgpMtJ CmuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ZKamWyOk2LKr0w8kMEWnJTr+pCyij1spBpIwpyFRRm8=; b=IRVWxMasyxlreOPv/saPt9HmpmlJ5tmjtngGgpKxjYYc+Gcz0IoQBDArELoa1t9wI2 0rzvtf/gSDwdsy0pyrTt/ExFF+x7r6LFlbDbJmOwjFe/Fri9AfByrOP2kToBW3/LH6QL kKlZzn4CrDnwSXg9jrcZ7Hr+3hT4192zzCMtYU8Zu+NeW0HK+S0hDZvsK+V6jsgRWNbW gu+gnQmzmMQjVDjbQELMYkHlqsXqE0qSFe3Gpw3NtX+GGuy9w2hHq8LdVibaH6w8KEqP kOGNBYzhGFitaCxP5l0H9XrvPWrTDe2c0wQKG65h0tGt0NWdOrJ6ZEF7pwDTIIH0RxqI XrYg== X-Gm-Message-State: AOAM532c4ZvdAEwhr9xuYtGMdexDBKsbBSzcbYNYPtismH8cpNbw5S7K 74C8frf7dY0UIsSyNsPL7FI+jtyZvXu8ZNRWT16ozF6zqnQ= X-Google-Smtp-Source: ABdhPJxFbBVjezHuFVJcepbKCoHMytsvAr4E0Rgswv1fMikjAKlRrVAFmagjIMc1h7jQD35dbDs+WUVZGuhZPv8ph5E= X-Received: by 2002:a7b:cc85:: with SMTP id p5mr7079420wma.18.1594182656690; Tue, 07 Jul 2020 21:30:56 -0700 (PDT) MIME-Version: 1.0 References: <20200627235318.Bluez.v2.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> In-Reply-To: From: Archie Pusaka Date: Wed, 8 Jul 2020 12:30:45 +0800 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] device: add device_remove_bonding function To: Luiz Augusto von Dentz Cc: linux-bluetooth , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1B680A010F X-Rspamd-UID: cad001 Hi Luiz, As far as the spec is concerned, we can also remove the device by calling device_remove. However, I suppose it would be confusing for end users if they can no longer find their HID device on the device list just because the device previously sent a virtual cable disconnection. The HID 1.0 spec part 6.4.2 also gives an example of a possible scenario when a virtually cabled device is removed: "Unplugged devices shall be marked as known and put into a =E2=80=9Cmost recently used list=E2= =80=9D of known devices to facilitate future re-connecting". Thanks, Archie On Wed, 8 Jul 2020 at 02:03, Luiz Augusto von Dentz wrote: > > Hi Archie, > > On Sat, Jun 27, 2020 at 8:54 AM Archie Pusaka wrote: > > > > From: Archie Pusaka > > > > This patch splits the "bonding removal" function in device.c, > > because we need to remove bonding information when receiving > > "virtual cable unplug" in HID profile. > > > > Reviewed-by: Alain Michaud > > --- > > > > Changes in v2: None > > > > src/device.c | 25 +++++++++++++++---------- > > src/device.h | 1 + > > 2 files changed, 16 insertions(+), 10 deletions(-) > > > > diff --git a/src/device.c b/src/device.c > > index 7b0eb256e..9fb0e018c 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -4162,6 +4162,17 @@ static void delete_folder_tree(const char *dirna= me) > > rmdir(dirname); > > } > > > > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr_t= ype) > > +{ > > + if (bdaddr_type =3D=3D BDADDR_BREDR) > > + device->bredr_state.bonded =3D false; > > + else > > + device->le_state.bonded =3D false; > > + > > + btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > > + bdaddr_type); > > +} > > + > > static void device_remove_stored(struct btd_device *device) > > { > > char device_addr[18]; > > @@ -4170,17 +4181,11 @@ static void device_remove_stored(struct btd_dev= ice *device) > > char *data; > > gsize length =3D 0; > > > > - if (device->bredr_state.bonded) { > > - device->bredr_state.bonded =3D false; > > - btd_adapter_remove_bonding(device->adapter, &device->bd= addr, > > - BDADDR_= BREDR); > > - } > > + if (device->bredr_state.bonded) > > + device_remove_bonding(device, BDADDR_BREDR); > > > > - if (device->le_state.bonded) { > > - device->le_state.bonded =3D false; > > - btd_adapter_remove_bonding(device->adapter, &device->bd= addr, > > - device->bdaddr_= type); > > - } > > + if (device->le_state.bonded) > > + device_remove_bonding(device, device->bdaddr_type); > > > > device->bredr_state.paired =3D false; > > device->le_state.paired =3D false; > > diff --git a/src/device.h b/src/device.h > > index 06b100499..907c7c5c4 100644 > > --- a/src/device.h > > +++ b/src/device.h > > @@ -49,6 +49,7 @@ uint16_t btd_device_get_vendor(struct btd_device *dev= ice); > > uint16_t btd_device_get_vendor_src(struct btd_device *device); > > uint16_t btd_device_get_product(struct btd_device *device); > > uint16_t btd_device_get_version(struct btd_device *device); > > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr_t= ype); > > void device_remove(struct btd_device *device, gboolean remove_stored); > > Is there any particular reason why device_remove is not enough here? I > don't see any reason to leave the device object around after removing > its bonding. > > > int device_address_cmp(gconstpointer a, gconstpointer b); > > int device_bdaddr_cmp(gconstpointer a, gconstpointer b); > > -- > > 2.27.0.212.ge8ba1cc988-goog > > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AGZOBZJQBV/XwAEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 06:50:26 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id uIYSBJJQBV/POQEA0J78UA (envelope-from ); Wed, 08 Jul 2020 06:50:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 61EC4526CF; Wed, 8 Jul 2020 06:50:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728973AbgGHEuM convert rfc822-to-8bit (ORCPT + 1 other); Wed, 8 Jul 2020 00:50:12 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:36097 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725903AbgGHEuL (ORCPT ); Wed, 8 Jul 2020 00:50:11 -0400 Received: from [192.168.1.91] (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 51BEACECF6; Wed, 8 Jul 2020 07:00:06 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH][next] Bluetooth: Use fallthrough pseudo-keyword From: Marcel Holtmann In-Reply-To: <20200707203541.GA8972@embeddedor> Date: Wed, 8 Jul 2020 06:49:39 +0200 Cc: Johan Hedberg , "David S. Miller" , Jakub Kicinski , linux-bluetooth , kernel list , netdev@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20200707203541.GA8972@embeddedor> To: "Gustavo A. R. Silva" X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 3 X-Rspamd-Score: 0.47 / 15.00 / 200.00 X-Rspamd-Queue-Id: 61EC4526CF X-Rspamd-UID: 96e2a6 Hi Gustavo, > Replace the existing /* fall through */ comments and its variants with > the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary > fall-through markings when it is the case. > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through > > Signed-off-by: Gustavo A. R. Silva > --- > drivers/bluetooth/bcm203x.c | 2 +- > drivers/bluetooth/bluecard_cs.c | 2 -- > drivers/bluetooth/hci_ll.c | 2 +- > drivers/bluetooth/hci_qca.c | 8 +------- > net/bluetooth/hci_event.c | 4 ++-- > net/bluetooth/hci_sock.c | 3 +-- > net/bluetooth/l2cap_core.c | 19 +++++++++---------- > net/bluetooth/l2cap_sock.c | 4 ++-- > net/bluetooth/mgmt.c | 4 ++-- > net/bluetooth/rfcomm/core.c | 2 +- > net/bluetooth/rfcomm/sock.c | 2 +- > net/bluetooth/smp.c | 2 +- > 12 files changed, 22 insertions(+), 32 deletions(-) can we split these a little bit between drivers, core and rfcomm. Thanks. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aAoOG/OeBV+P7gEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 12:24:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2NHNGfOeBV8PegAAlp8NpQ (envelope-from ); Wed, 08 Jul 2020 12:24:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 363CB52E6A; Wed, 8 Jul 2020 12:24:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728234AbgGHKYp (ORCPT + 1 other); Wed, 8 Jul 2020 06:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728176AbgGHKYo (ORCPT ); Wed, 8 Jul 2020 06:24:44 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59E74C08C5DC for ; Wed, 8 Jul 2020 03:24:44 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id k5so990482pjg.3 for ; Wed, 08 Jul 2020 03:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=hjVFcpSUOWmjOUhAjbp9t713LG+CPl0W9t3Mxd3PJhw=; b=lqgiA+9P0w4AkyRmLchQwJ5uJibOVFuKS4wdleLwl1h38Ia3QsPrmYX8EmCZ7+OOOO xGOhTDAaKAzpLX+BwdrCwgGsAETCaoEQTmly+xmdjsA2zOLKMKZrM+4hB+4J02Egk+HU kxEkji//WwfQlrZlkTJffIfZZqT/VeG5lFh9xd/SurtZWXd7m1f+4CYPSPOdgXKwVzyW 8AaYsGN0EgyNIO5EBEyNQfsPBYZpHPR/gfKrU8vwx7mi6HsGIZmKPgc1wwxyQShWoW7V RQmJls3WE7+ncKLIcWnxMGTnrAuay8GRlpzhG+rxEE2d0uD1Ja5SviLqUj4QyA91vEAJ EYqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=hjVFcpSUOWmjOUhAjbp9t713LG+CPl0W9t3Mxd3PJhw=; b=dadONMtFVJ7vBvqTPasmfzncU8CgGKGdiXcIC7JWMcG/hlpdR3C0h1flsjFWr2enTA Nbigx9B5TdQ/NSmTCu8OJOT/EHLi2bXji118vqx+eogPQqSr2ga279hvpaThqDf3Is5e EMYPycjrCIBXk3wxRaRgZ4Acqm++dXTsrukAXNoY2hGQB64hOJkNRhn9+TZI3389v3XC raWQlXgXYjohlNmB+b5U1o7EtCrPiuxDFa0AgRONh1gTDZ+d7xW/jeZq1MvWQP9DlY+w fh+eUusRSJvQk4LkUpT8OjdsD549E6McyKSOK906MalypiiAzwK/m/KTre5RGwZYOb2L /frw== X-Gm-Message-State: AOAM531Xp0V7/O9jGQ2CP7thRHsKjNsJ38boa6HXWMc503lIvYfa7uKB ZQb6zE8AtBVCm93PUt8Q8+XyTUH+Cze+/eulP8RduQC6 X-Google-Smtp-Source: ABdhPJyPrg9MM4m+PXrcJSlLcj/0bLFVXal6J85DnEhsSTwSIX17QIH/69lDp8MalJS7aaoqzLko3imIjL1xrW2GWYs= X-Received: by 2002:a17:90b:3683:: with SMTP id mj3mr8831412pjb.91.1594203883469; Wed, 08 Jul 2020 03:24:43 -0700 (PDT) MIME-Version: 1.0 From: Andrey Batyiev Date: Wed, 8 Jul 2020 13:24:32 +0300 Message-ID: Subject: Temporary device removal during discovery To: linux-bluetooth Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 363CB52E6A X-Rspamd-UID: b80ddc Hello everyone, I've found the following issue: 1. in bluetoothctl run "power on", "scan on" 2. discovery is now permanent 3. make one device discoverable for a moment (e.g. turn bluetooth on on your phone) 4. bluez would detect new device 5. turn bluetooth off on your phone 6. now wait Expected result: 7. your phone should disappear from discovered set after some time Actual result: 7. phone would stay there until discovery is off (i.e. "scan off" in bluetoothctl) It seems like there is a code in src/adapter.c responsible for purge stale entries (remove_temp_devices), however it only triggers when discovery is off (and after 3 mins). My use case is to continuously monitor the bluetooth environment. Is it bluez responsibility to remove stale entries during discovery or should my own app repeatedly stop discovery? Thanks, Andrey Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mOXkMySuBV9hewAAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 13:29:40 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id GAFfMiSuBV8/FAEA0J78UA (envelope-from ); Wed, 08 Jul 2020 13:29:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 985CFA1D3F; Wed, 8 Jul 2020 13:29:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728762AbgGHL3c (ORCPT + 1 other); Wed, 8 Jul 2020 07:29:32 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:55527 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728385AbgGHL3c (ORCPT ); Wed, 8 Jul 2020 07:29:32 -0400 Received: from classic (lns-bzn-39-82-255-60-242.adsl.proxad.net [82.255.60.242]) (Authenticated sender: hadess@hadess.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 0657B240011; Wed, 8 Jul 2020 11:29:29 +0000 (UTC) Message-ID: Subject: Re: Temporary device removal during discovery From: Bastien Nocera To: Andrey Batyiev , linux-bluetooth Date: Wed, 08 Jul 2020 13:29:29 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 14 X-Rspamd-Score: 2.14 / 15.00 / 200.00 X-Rspamd-Queue-Id: 985CFA1D3F X-Rspamd-UID: f96259 Hey Andrey, On Wed, 2020-07-08 at 13:24 +0300, Andrey Batyiev wrote: > Hello everyone, > > I've found the following issue: > 1. in bluetoothctl run "power on", "scan on" > 2. discovery is now permanent > 3. make one device discoverable for a moment (e.g. turn bluetooth on > on your phone) > 4. bluez would detect new device > 5. turn bluetooth off on your phone > 6. now wait > > Expected result: > 7. your phone should disappear from discovered set after some time > > Actual result: > 7. phone would stay there until discovery is off (i.e. "scan off" in > bluetoothctl) > > > It seems like there is a code in src/adapter.c responsible for purge > stale entries > (remove_temp_devices), however it only triggers when discovery is off > (and after 3 mins). > > > My use case is to continuously monitor the bluetooth environment. Is > it bluez responsibility to > remove stale entries during discovery or should my own app repeatedly > stop discovery? It's been a problem for a while. I sent one of those mails as well: https://www.spinics.net/lists/linux-bluetooth/msg75947.html https://www.spinics.net/lists/linux-bluetooth/msg74397.html Can you please file a bug at https://github.com/bluez/bluez/issues ? I'll CC: myself on it too. Cheers Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WIhhE1q1BV8vpwAAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 14:00:26 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id SC+fEVq1BV+y5QAAlp8NpQ (envelope-from ); Wed, 08 Jul 2020 14:00:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5B3E6A2FC8; Wed, 8 Jul 2020 14:00:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728864AbgGHMAM (ORCPT + 1 other); Wed, 8 Jul 2020 08:00:12 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:53915 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728723AbgGHMAM (ORCPT ); Wed, 8 Jul 2020 08:00:12 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id CA3CECECFA; Wed, 8 Jul 2020 14:10:06 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Bluetooth: Use whitelist for scan policy when suspending From: Marcel Holtmann In-Reply-To: <20200707155207.1.Id31098b8dbbcf90468fcd7fb07ad0e872b11c36b@changeid> Date: Wed, 8 Jul 2020 14:00:09 +0200 Cc: Bluetooth Kernel Mailing List , Alain Michaud , Abhishek Pandit-Subedi , "David S. Miller" , Johan Hedberg , kernel list , netdev@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: References: <20200707155207.1.Id31098b8dbbcf90468fcd7fb07ad0e872b11c36b@changeid> To: Miao-chen Chou X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5B3E6A2FC8 X-Rspamd-UID: 3b40f9 Hi Miao-chen, > Even with one advertisement monitor in place, the scan policy should use > the whitelist while the system is going to suspend to prevent waking by > random advertisement. > > The following test was performed. > - With a paired device, register one advertisement monitor, suspend > the system and verify that the host was not awaken by random > advertisements. > > Signed-off-by: Miao-chen Chou > Reviewed-by: Abhishek Pandit-Subedi > > --- > > net/bluetooth/hci_request.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yOm/JArMBV8KWgEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 15:37:14 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IPsgIwrMBV8wdgEAlp8NpQ (envelope-from ); Wed, 08 Jul 2020 15:37:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E6DCC526CF; Wed, 8 Jul 2020 15:37:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729772AbgGHNgu (ORCPT + 1 other); Wed, 8 Jul 2020 09:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729762AbgGHNgt (ORCPT ); Wed, 8 Jul 2020 09:36:49 -0400 Received: from smtp.al2klimov.de (smtp.al2klimov.de [IPv6:2a01:4f8:c0c:1465::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B0E8C08C5CE; Wed, 8 Jul 2020 06:36:49 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.al2klimov.de (Postfix) with ESMTPA id C5E5DBC06E; Wed, 8 Jul 2020 13:36:44 +0000 (UTC) From: "Alexander A. Klimov" To: marcel@holtmann.org, johan.hedberg@gmail.com, davem@davemloft.net, kuba@kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Alexander A. Klimov" Subject: [PATCH] Replace HTTP links with HTTPS ones: BLUETOOTH SUBSYSTEM Date: Wed, 8 Jul 2020 15:36:38 +0200 Message-Id: <20200708133638.14589-1-grandmaster@al2klimov.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: ++++++ Authentication-Results: smtp.al2klimov.de; auth=pass smtp.auth=aklimov@al2klimov.de smtp.mailfrom=grandmaster@al2klimov.de Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 61 X-Rspamd-Score: 9.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: E6DCC526CF X-Rspamd-UID: 3c0c61 Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov --- Continuing my work started at 93431e0607e5. See also: git log --oneline '--author=Alexander A. Klimov ' v5.7..master (Actually letting a shell for loop submit all this stuff for me.) If there are any URLs to be removed completely or at least not HTTPSified: Just clearly say so and I'll *undo my change*. See also: https://lkml.org/lkml/2020/6/27/64 If there are any valid, but yet not changed URLs: See: https://lkml.org/lkml/2020/6/26/837 If you apply the patch, please let me know. net/bluetooth/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index 1d6d243cdde9..e2497d764e97 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -21,7 +21,7 @@ menuconfig BT It was designed as a replacement for cables and other short-range technologies like IrDA. Bluetooth operates in personal area range that typically extends up to 10 meters. More information about - Bluetooth can be found at . + Bluetooth can be found at . Linux Bluetooth subsystem consist of several layers: Bluetooth Core -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iMNMJvDrBV8OUgAAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 17:53:20 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 8J5+JPDrBV+Z5gEAlScrYA (envelope-from ); Wed, 08 Jul 2020 17:53:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0A2BB52C46; Wed, 8 Jul 2020 17:53:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730071AbgGHPxN (ORCPT + 1 other); Wed, 8 Jul 2020 11:53:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729022AbgGHPxN (ORCPT ); Wed, 8 Jul 2020 11:53:13 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FE61C061A0B for ; Wed, 8 Jul 2020 08:53:13 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id mn17so1394035pjb.4 for ; Wed, 08 Jul 2020 08:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3Rhw7BD+8GQYrmfzt2oYwuMMnAaDzpl0AiN3h3ecb1s=; b=n6etBYEN0g1HSageAUZbTww+qJrrsdPyEgON1OnzgBjLdR+5EDF5RqGyVC9t88JAdA BHPdLhAFCqx8JQqHyMvK9f2gReOFiyDNEu13EifQI7LN2guI9aLA4TnxapDiuLMhfw11 2NkN2R7TlnL0IblcvCnnwx1fnHHZilkwx2QAyza8ZKHPZaxyXg+DEWhvCz0/Vu5BdGpA 5mYoLpg5ixTGBKhsHgMOdgUC6ZUTGym19gRqpL44Lf7R2KxBIgJlhrnScLQfDP6G2pXX xm/UlRiilVoZIzv8pBEED3SUoCmOQPDB1I78Vr3vOk67fwPlxKeuug88L9PWR83Mk7EL zcrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3Rhw7BD+8GQYrmfzt2oYwuMMnAaDzpl0AiN3h3ecb1s=; b=m169Xp/bHEmadog4I/7rTAfGMu2WDdrpHeJobp+WCKMAiXErLyjFUQytx8dUy+mnfu 4H95OrOHLXMTsvmtk8pFURB6z+kfbmwg/n3r5Ko8XBVJZHurPMXSo7A6C1Ori7qx/Gvj e7WB32i+y7YuQlJDqr4C2te/zssyxg5KIdrctY5xJkD+9yS+Pk5Igj38VYNC/PF02D5V DE+VvrsvDz98+D0SOHLGOsKoohisdB0PsqdV7LaTAhftbm3Ay29OSyysO3UeQD6SFpwE QhskZf4Pe2O8Y6tJ2S7W9dvCPgAB+f6NMwzqLtPN+/htI5cqzhHYJXdHj+1q7Ty5V5Nk FrgA== X-Gm-Message-State: AOAM530bikkWA1tfMmUW5mEOAH7irzj9kzX++9KpR8Eyw8jTZhYSJwCn kV7NrHRslVCD1Js5hd3vRc8kJ7P0mpz/KyXV4Z3Xcqkw X-Google-Smtp-Source: ABdhPJxZFVdQVAgOdGJQjbXNZd0io0/6Qd2EnPGJYjYGjmuS2/fEJUl0UbPDsExlLi5tOmqKX1ObL+WzfxRShEhnqZQ= X-Received: by 2002:a17:90b:3683:: with SMTP id mj3mr10262945pjb.91.1594223592841; Wed, 08 Jul 2020 08:53:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Batyiev Date: Wed, 8 Jul 2020 18:53:00 +0300 Message-ID: Subject: Re: Temporary device removal during discovery To: Bastien Nocera Cc: linux-bluetooth Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0A2BB52C46 X-Rspamd-UID: f42f42 Hi Bastien, everyone, I've made a patch to the bluez, so the temporary devices are routinely purged based on their last_seen attribute. What do you think about such solution? Thanks, Andrey diff --git a/src/adapter.c b/src/adapter.c index 529002b02..101b03633 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -88,6 +88,7 @@ #define CONN_SCAN_TIMEOUT (3) #define IDLE_DISCOV_TIMEOUT (5) +#define TEMP_DEV_REAPER_INTERVAL (30) #define TEMP_DEV_TIMEOUT (3 * 60) #define BONDING_TIMEOUT (2 * 60) @@ -1491,18 +1492,18 @@ static gboolean remove_temp_devices(gpointer user_data) DBG("%s", adapter->path); - adapter->temp_devices_timeout = 0; - for (l = adapter->devices; l != NULL; l = next) { struct btd_device *dev = l->data; next = g_slist_next(l); - if (device_is_temporary(dev) && !btd_device_is_connected(dev)) + if (device_is_temporary(dev) && + !btd_device_is_connected(dev) && + device_last_seen_delta(dev) > TEMP_DEV_TIMEOUT) btd_adapter_remove_device(adapter, dev); } - return FALSE; + return TRUE; } static void discovery_cleanup(struct btd_adapter *adapter) @@ -1516,11 +1517,6 @@ static void discovery_cleanup(struct btd_adapter *adapter) adapter->discovery_idle_timeout = 0; } - if (adapter->temp_devices_timeout > 0) { - g_source_remove(adapter->temp_devices_timeout); - adapter->temp_devices_timeout = 0; - } - g_slist_free_full(adapter->discovery_found, invalidate_rssi_and_tx_power); adapter->discovery_found = NULL; @@ -1536,9 +1532,6 @@ static void discovery_cleanup(struct btd_adapter *adapter) if (device_is_temporary(dev) && !device_is_connectable(dev)) btd_adapter_remove_device(adapter, dev); } - - adapter->temp_devices_timeout = g_timeout_add_seconds(TEMP_DEV_TIMEOUT, - remove_temp_devices, adapter); } static void discovery_free(void *user_data) @@ -2405,7 +2398,7 @@ static bool parse_pathloss(DBusMessageIter *value, return true; } -static bool parse_transport(DBusMessageIter *value, +static bool parse_transport(DBusMessageIter *value, struct discovery_filter *filter) { char *transport_str; @@ -5362,6 +5355,11 @@ static void adapter_free(gpointer user_data) adapter->passive_scan_timeout = 0; } + if (adapter->temp_devices_timeout > 0) { + g_source_remove(adapter->temp_devices_timeout); + adapter->temp_devices_timeout = 0; + } + if (adapter->load_ltks_timeout > 0) g_source_remove(adapter->load_ltks_timeout); @@ -6343,6 +6341,9 @@ static struct btd_adapter *btd_adapter_new(uint16_t index) adapter->auths = g_queue_new(); + adapter->temp_devices_timeout = g_timeout_add_seconds(TEMP_DEV_REAPER_INTERVAL, + remove_temp_devices, adapter); + return btd_adapter_ref(adapter); } diff --git a/src/device.c b/src/device.c index 0deee2707..cebbabab2 100644 --- a/src/device.c +++ b/src/device.c @@ -4240,6 +4240,15 @@ void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type) device->le_seen = time(NULL); } +time_t device_last_seen_delta(struct btd_device *device) +{ + const time_t now = time(NULL); + const time_t bredr_time = now - device->bredr_seen; + const time_t le_time = now - device->le_seen; + + return bredr_time < le_time ? bredr_time : le_time; +} + /* It is possible that we have two device objects for the same device in * case it has first been discovered over BR/EDR and has a private * address when discovered over LE for the first time. In such a case we diff --git a/src/device.h b/src/device.h index cb8d884e8..75fd3ec60 100644 --- a/src/device.h +++ b/src/device.h @@ -44,6 +44,7 @@ void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr, void device_set_bredr_support(struct btd_device *device); void device_set_le_support(struct btd_device *device, uint8_t bdaddr_type); void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type); +time_t device_last_seen_delta(struct btd_device *device); void device_merge_duplicate(struct btd_device *dev, struct btd_device *dup); uint32_t btd_device_get_class(struct btd_device *device); uint16_t btd_device_get_vendor(struct btd_device *device); Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gC5ILO4HBl95ywAAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 19:52:46 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WEQGK+4HBl+W5gAADc0bRg (envelope-from ); Wed, 08 Jul 2020 19:52:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=jm0.eu X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 164F9A3186; Wed, 8 Jul 2020 19:52:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728012AbgGHRsN (ORCPT + 1 other); Wed, 8 Jul 2020 13:48:13 -0400 Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.53]:18136 "EHLO mo4-p01-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726475AbgGHRsF (ORCPT ); Wed, 8 Jul 2020 13:48:05 -0400 X-Greylist: delayed 533 seconds by postgrey-1.27 at vger.kernel.org; Wed, 08 Jul 2020 13:48:01 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1594230480; s=strato-dkim-0002; d=jm0.eu; h=In-Reply-To:Date:Message-ID:From:References:Cc:To:Subject: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=EZeg6fI6ttKUi7UP14G00kZ70cwnxfgmSdSYiNxnja4=; b=PkZPrTIc3fhirFL/TM4M9QJ83uc62xOXnf9kVYnqdYPGHW6KTYm4nEIonWL8vF1ppU I+EtqGxb1smxUMzfF/YOyNYKgDc6iz6xvy8oR3+7RNFxX8QKli+hr+n4aXhhtXr5xm2/ 2bXtrr8GY0NIxiP39B8CZO25T4hkfSIV5pjzCOmLUp4jCtTLfBNH8q2Pbnij0ryjM2Ww xKCpN4epZwAABdKb5dFALRUPQ9XEkMkNEHshgybFVSgaYmszJMUgrQgF1N9KQk/9aRSJ 7vKZ48k2jmB7eoPx+c9ZozcogZZWGN5Q1e9CeZSneIqxlCIQQj2LRsBYyXmTt7rPMuKe PwTA== X-RZG-AUTH: ":JmMXYEHmdv4HaV2cbPh7iS0wbr/uKIfGM0EPXvQCbXgI7t69COvnl6LERsNcX+38fzXJ1XO/JvLGWj59ag==" X-RZG-CLASS-ID: mo00 Received: from [IPv6:2003:c6:1f3d:7510::f30] by smtp.strato.de (RZmta 46.10.5 AUTH) with ESMTPSA id c08c89w68Ha0tHd (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 8 Jul 2020 19:36:00 +0200 (CEST) Subject: Re: use-after-free in Bluetooth: 6lowpan (was Re: KASAN: use-after-free Write in refcount_warn_saturate) To: Kees Cook , Jukka Rissanen , Johan Hedberg Cc: davem@davemloft.net, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, syzbot , Michael Scott , Josua Mayer References: <00000000000055e1a9059f9e169f@google.com> <202007052022.984BAD97@keescook> From: "Ing. Josua Mayer" Autocrypt: addr=josua.mayer@jm0.eu; prefer-encrypt=mutual; keydata= mQINBFtbYt4BEACysNSF+vmzzBvR+YgJDK6X34V+WUStfjN3YqbcClZxUWe2rOt3BfxsuG+a cmOHVmS5ufOOXE7dsB6w9eviNOO2h/XWCdyjnrtYY4bCxmDzyHV3MZW3Z4OlJWOFffOa5HPe fog8Xn5wsLm+tKyMWJAqSjJrJSJmmgucT/QkHOsnUtPRPSDRsTiWBZQgtplgVYswdaGxE8sy XIJJfpQVX9G6rm+1Qyc8BEGcgvx9cHjzaK+NbFPo8UsZZ1YxuqPba3Kr7NlmLFp78oTBYtTY 2bTCtNd/mBKkDd1qhEm/TqX1DElXlnWwKOEDX9FxvWIjVtVP04kdXJspb8U404GLbH3H86+D XAjAkXI7QY/CRsmENvi0wzxjb8PduWYslqJA6yMeoJY9iB1aiK/1LetfozUBX1nKhXCzfOz3 dAaHhUel0dylxRndQP7lpahvZw9FLv9Ijc2gafh7hQ7PxJue1H0v5nrOkyfxr9/kZSLnKk16 /LD88Wlu3O2oDNOc0Mcw29VGxTkHMsi5qWsYXGX4fFrIpmuZ9L1yNdY2Z0HJEMFC3oP7imts X05sQzIdDwlDe9afW5bI1QzYHeve1EvC3hDTjl3uAbKY5tOFs0S6bZo1mXDe7Ul6gCkMJSg3 j1WKRC9N1fp7sW9qVxfyFYljGVeN2UpJqBXEIghLewgetxnzSwARAQABtCBKb3N1YSBNYXll ciA8am9zdWEubWF5ZXJAam0wLmV1PokCTgQTAQoAOBYhBARsyk7gXmLh8sUoAGOyWxAcjfAZ BQJbW2LeAhsDBQsJCAcDBRUKCQgLBRYCAwEAAh4BAheAAAoJEGOyWxAcjfAZloIQALDePc3A ghaFJtiwzDbvwkJC6XTEl1KpZMBFPwdsknjy9o40AqHFOwT3GHGh0kXJzV/ZpOcSQFFi9jfx P+m5fuOH2lgDbR6tT5OzvE8IchK5bpsoLghhb8vpTQX7UhSE5lENq1brmndRv5Aw6pUHvDcN LDMcyFVFnxRZ18mbTY6Ji1QDJKC/z1F4wdo9dU2RvSNKTF6tMr9C/g51D+ueShdBFPyEGL2q QANe1GP/0qLpF5/uzhMqw+j03s1FmvdqEJ4JLbYE4zgv2jHmOXUFHXx/hy19zp5jh6QQYzcl 408W2c64JT6exANRNYIetlwKSbDYOLRWqup09VQIl2NmEMbnFgr+Y5pEMECHJXebYMt8wKJ/ brhgjDY5ex+e3IRFpm09lP1l88aW2DQm/fAXUOa1Ulm970toZaPOVF8N+Mdua0ugveK8VG72 wcPf+uRRUU8aqj3yQ3RQXhOBf6ySmdlxLZKsPAX2483JxRDaRBh/iuDI+JD0JZjz+FCvjG89 REaw1c6MX+blm9GOGlyS7nu6FMuNblIwe/ahPLGzpLy8RTT00s2ww5BR+CKNsWOKgB1jWYtk yXVntfOjpBDaOeuIXNB9nEdqBSpw/b9Iu2UwRtIJU13vWm3j3hbdz+4W79rAqhHSmAStk+nJ Bg1qLhEhLPn91sFZwsajZEno46XcuQINBFtbYt4BEADJ4AZ4U4PXNNdfSsRataSQoZ7AjWJT UF1Xpm2R48QlO7otLEybA6LSeEWXxZyMl7g39MT6S8MbULHWkoceujKlBMBaJ4vl+GvI/quq LFhedbzUvFV09w/4JgLm7n9Aq1T1poHlPSL7AbVKLX6unaS5ARqhXvaVx52lKL0W3HHV42AR cFK6cQMDajiVoC0PXjxGmd74l769CsCLdmB9Z911nlaqqRpl3r7IqFSmz+CYKvBhRKafVZ62 hIkPlPIWBoykRcgorA0lYUMzdSflw0mJUO2uAEGfgu8juESXveSQ4XN1jdJ878hHKwBSxoAl jsXxAYPvrqQNwU5lcREkQBk3/s6OsvawgIAek249lWcTfNjD27PQu85yr0EfFeXFAlxGJZsS BkrrryfIXOquOsoGZWRDw9cLwlflIkInBL9EIt39quLzUDlgsWHECyDuniQepZ1G2pgva1kK kIlR3Oe9lO4JrFG0bS/EXvGbhUGW2DbvpA5DJuIKgy56TOkiwWUZoxgGJMBrLMnFAZzw0Vmi kw4Zy6qo5RaPhgFzcbf6xuqNlBqiWAEifeom9HdZe0Wz7IQ49IWJpChutj/QuMkeZ45F154y Smx3K2k98Pljvm6uqgxokSRrZWK9rvGOvO5P8Sc4EUSw3SIDvlBIDDXXOTVM49X/jEplAskq 5LlUuwARAQABiQI2BBgBCgAgFiEEBGzKTuBeYuHyxSgAY7JbEByN8BkFAltbYt4CGwwACgkQ Y7JbEByN8BlFPRAAqkz4GfM7h9IgYXVYjP0Uo16ElBK3uNGXan1+D8L2MNi1qjztpYTBBQdf JY6U0BoObDAYbsyEVpQe1+xNj3t3DRusLcx2mgx69w18Yq/2PoR98e14fF3bsyr7H52MYHfA azVwng884Bs48Nu5ongB5orbvkzaKvPsIXHmeRVbSLOftZaLxxHbgGKjDYOmnAI2MLwiXAqj A/i8GezLmTZs1bJkwTl2LfPRudU8xCTZ4sYaS37yUL+l43wdxkkF+bdiu3gpx0I3Fh8GQovf vyM577iiHV7aFw5BGDvff4V6vD2Mj88M0LrocQ+6tsuFXqYPPdlnduVV6JItUDQ8WwUjkdCW GGGIvLlGjFMG//2lTng0q1QejAu/R3s1NFOlmmwG8JgzIOUWBsAbTizoOVeJITxgQ0uJ7bKT MZ+rsB5lD920CPYuP0d2Qm5vNgSqw57pr4FwNmYzqHJuCpwVKu4hXBwh7V0xdHD93wijubnu N3aaaBMsv2G2PjMpDBkg3bNGaNVkuwS7WNY1OewSaXgNi8gfrZZ6p3gWO20ogpyxZEeOORll EXHrL9gXtO+sioW1YILLtvtcr/jW06BQYSzYahyR9HtJ1K8Zr6Fg2EYRiDg0bZN3ZJv6WPOg 2xHjSvmPAcjEQ7eT2tERQDngwMQPAXDw9f5KEGzYKdIre9CNpza5Ag0EW1tk4gEQAMmeKkPu l1ig5yvH/Hx1EnOVPgvMkCcMI8KvGI0ziQBpayTx+tmqdQbPCindB1y2Md2dGgDrcJRlmFBC bR0ADFHnfLGM9PHUrOV60UNKedKPuyYNdlwKmgqnEI6tl0vWCJgQeFthkAEoh8A6UWZSU/rO An6M1jIitMgYmMmBF7953ZF6tg5TmFyBtx8Rh/PNUXp7VEuLn0aXt40tePKSo2IOTqdeNlz/ YwVTvbEqjHKUJ5yWkZS8bf391r4TgIErovhP1U5EfvgL6NeoXKzPrrNOWLhnj8xywfNWXBDQ LbPVUQUh9MjNbgNaJloMvolTKk07c9CsiOYbopLTZA76E+HjtKlfW72hA/r62Uftp9uU7qiD 6EKQFusn3YKLf9jMkRhBZQb5rIRQ7lAcEdhyHyK3sG/qQqYn/WEwl20/ZOEjsGIqyU7yLSr/ 8PwFTkOY6QXeydvn7IqzWIXQtg4BD1vGiRq2tBJcCQUv20t3iLoULd47aE5SvRTe2XhNIaRS 6pbCWdw2Lp7EOfWpWYx6ObvaiwwyNn/des7GyPnmo0L2vWsf5F1l3BB6UJNtDBY+3AE+LQmx WMvOLD6ijBHHGNga255cyr0sB6kSQMitEwKSiZNhBv4qOkjFOxM+jtEb9iVtl0MvEEThrw9S MGFzhnc+NgnjR0wBr1lMG/sR0wGBABEBAAGJBGwEGAEKACAWIQQEbMpO4F5i4fLFKABjslsQ HI3wGQUCW1tk4gIbAgJACRBjslsQHI3wGcF0IAQZAQoAHRYhBKf5iq57WYH5+OgvZjjGvNW9 X5T8BQJbW2TiAAoJEDjGvNW9X5T8syMP/12Pi3+7+dEw22pLNmx3O7IMrCEJWDC4xEA+LS13 qMIJejQfLmL1N5qJP5oJApVxJmFKjWGbQWfZVucHTpWfbY1irIWRF7QmnUTgKtLseyeZyTIL UEYn/fkJlvw0jkdNi2dce6hlgWzARk/JGF+AIl6NUTDkW3KF8/2uvkTvC10HgGHaxUCG2+Ts 1SpwIlS4qwlJyN2TH4Mo7QIHB2EjVYIB2wTiOWyRMBULzLg+ucM24C2zUASVzTHmUUfVrnEZ vRnBWYF/l5cBsfy5bNeoh/rYLxJ6FCZ7pDWnfhHhhEgabrchobUubZJxdQjezMR4/jCPhjqZ HCtftk1HAOAhJ/PSoizVbyJC3plg3AcFwt6JIhVxmqpiDhh8OJ4BKxj2ynJgoTv94ZUQCWFb mC0rSTD3IK/kPG+ZYtRM3s1djVtzDaZlxKQ5wNxhaHIepKyNHMsrPOvNE6Ack8ER2R6Q+DCT T3UutGS++YH5zvpExxYq5b8P+zpqPgn2wsU0AtrlJ3kjL86WXuJ39P1HWF26PLewEXYlGcym LH85f8Crcy2ilr7lSWZ1eY/qeu7gcKKrQs8GXe7KzqNc05pXB8I3DV9JLPz9NjcZ3vH1GIw8 7ypt12Ui+zx6MYkJmZXE9d697YS+OUjuw00Ak4EZWD7JjOOSGT3ZgDtN339Ls9kmjxwPk2EP +QHhqfGF3liU9LbPu8M+zH9s7UwfwkrrEOOAom6ATirtPhA+Rs3y7ZPng2Q1yCFoUMsXsvBv SUa7YSHUbsXkyqkjnj5yMgafHDZZYMe3IMi9qFwh1VTjpPJkQvexqBccN+S7PBUM4JJ6wtMW xcrQiyVSMDl2LSUXPpJKmuF/M54R7UonKFEq4kmm/L0EexHnV8TkrdWm1lYfGPop54VvJ6/5 TxnXGZQn3+9rS5R2RIHcGNaOqimZLnYk3cE8KQfsWA7+fEySg7QlGhYiiIz+mFUsIjoG8swF tXYjCNuOoyYP8fkcrUc5FpIOB7ziYlDN8tqa/Smh4xczAUmAA7pE7iejJHLwtWqrGMISlzMe XFjKQorD+pGUDX7HzOVHbxYIZPtm7N91zTxTopQaMxaPTpBD6XPLXs2aqu7HmbqWF+ALAoh8 cGrfGfiOnnDTSHNDvM5M1D6iaLVnoTtdr5U6T1OKsg48p9elHXtTW/sunCt0dQbtfm2mg1su mMfWyGrdZKGF2NEw/YYSEXUNWd09Kgaptm/aDE/F84SIZQc8JK5LuV5lXxyC4epvwwLXOV6H jZLDGlel7HcUgLAU+lcuQJ3HfS0OocdheDfxGNivl/4+t0UMMiUqx11h8mNYn/02NwihLhMJ Si21CLNeIbliI0CNR5kPUY1ntw1JCOmOjKZm Message-ID: <2f14ae85-6ec7-2a37-a54c-ab9a68bbc40a@jm0.eu> Date: Wed, 8 Jul 2020 19:36:00 +0200 MIME-Version: 1.0 In-Reply-To: <202007052022.984BAD97@keescook> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 164F9A3186 X-Rspamd-UID: 391854 Greetings everybody, Am 06.07.20 um 05:32 schrieb Kees Cook: > On Thu, Feb 27, 2020 at 11:50:11PM -0800, syzbot wrote: >> Hello, >> >> syzbot found the following crash on: >> >> HEAD commit: f8788d86 Linux 5.6-rc3 >> git tree: upstream >> console output: https://syzkaller.appspot.com/x/log.txt?x=13005fd9e00000 >> kernel config: https://syzkaller.appspot.com/x/.config?x=9833e26bab355358 >> dashboard link: https://syzkaller.appspot.com/bug?extid=7dd7f2f77a7a01d1dc14 >> compiler: gcc (GCC) 9.0.0 20181231 (experimental) >> userspace arch: i386 >> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17e3ebede00000 >> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16a9f8f9e00000 >> >> IMPORTANT: if you fix the bug, please add the following tag to the commit: >> Reported-by: syzbot+7dd7f2f77a7a01d1dc14@syzkaller.appspotmail.com >> >> ================================================================== >> BUG: KASAN: use-after-free in atomic_set include/asm-generic/atomic-instrumented.h:44 [inline] >> BUG: KASAN: use-after-free in refcount_set include/linux/refcount.h:123 [inline] >> BUG: KASAN: use-after-free in refcount_warn_saturate+0x1f/0x1f0 lib/refcount.c:15 >> Write of size 4 at addr ffff888090eb4018 by task kworker/1:24/2888 >> >> CPU: 1 PID: 2888 Comm: kworker/1:24 Not tainted 5.6.0-rc3-syzkaller #0 >> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 >> Workqueue: events do_enable_set >> Call Trace: >> __dump_stack lib/dump_stack.c:77 [inline] >> dump_stack+0x197/0x210 lib/dump_stack.c:118 >> print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374 >> __kasan_report.cold+0x1b/0x32 mm/kasan/report.c:506 >> kasan_report+0x12/0x20 mm/kasan/common.c:641 >> check_memory_region_inline mm/kasan/generic.c:185 [inline] >> check_memory_region+0x134/0x1a0 mm/kasan/generic.c:192 >> __kasan_check_write+0x14/0x20 mm/kasan/common.c:101 >> atomic_set include/asm-generic/atomic-instrumented.h:44 [inline] >> refcount_set include/linux/refcount.h:123 [inline] >> refcount_warn_saturate+0x1f/0x1f0 lib/refcount.c:15 >> refcount_sub_and_test include/linux/refcount.h:261 [inline] >> refcount_dec_and_test include/linux/refcount.h:281 [inline] >> kref_put include/linux/kref.h:64 [inline] >> l2cap_chan_put+0x1d9/0x240 net/bluetooth/l2cap_core.c:498 >> do_enable_set+0x54b/0x960 net/bluetooth/6lowpan.c:1075 >> process_one_work+0xa05/0x17a0 kernel/workqueue.c:2264 >> worker_thread+0x98/0xe40 kernel/workqueue.c:2410 >> kthread+0x361/0x430 kernel/kthread.c:255 >> ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 >> >> Allocated by task 2888: >> save_stack+0x23/0x90 mm/kasan/common.c:72 >> set_track mm/kasan/common.c:80 [inline] >> __kasan_kmalloc mm/kasan/common.c:515 [inline] >> __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:488 >> kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529 >> kmem_cache_alloc_trace+0x158/0x790 mm/slab.c:3551 >> kmalloc include/linux/slab.h:555 [inline] >> kzalloc include/linux/slab.h:669 [inline] >> l2cap_chan_create+0x45/0x3a0 net/bluetooth/l2cap_core.c:446 >> chan_create+0x10/0xe0 net/bluetooth/6lowpan.c:640 >> bt_6lowpan_listen net/bluetooth/6lowpan.c:959 [inline] >> do_enable_set+0x583/0x960 net/bluetooth/6lowpan.c:1078 >> process_one_work+0xa05/0x17a0 kernel/workqueue.c:2264 >> worker_thread+0x98/0xe40 kernel/workqueue.c:2410 >> kthread+0x361/0x430 kernel/kthread.c:255 >> ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 >> >> Freed by task 2975: >> save_stack+0x23/0x90 mm/kasan/common.c:72 >> set_track mm/kasan/common.c:80 [inline] >> kasan_set_free_info mm/kasan/common.c:337 [inline] >> __kasan_slab_free+0x102/0x150 mm/kasan/common.c:476 >> kasan_slab_free+0xe/0x10 mm/kasan/common.c:485 >> __cache_free mm/slab.c:3426 [inline] >> kfree+0x10a/0x2c0 mm/slab.c:3757 >> l2cap_chan_destroy net/bluetooth/l2cap_core.c:484 [inline] >> kref_put include/linux/kref.h:65 [inline] >> l2cap_chan_put+0x1b7/0x240 net/bluetooth/l2cap_core.c:498 >> do_enable_set+0x54b/0x960 net/bluetooth/6lowpan.c:1075 >> process_one_work+0xa05/0x17a0 kernel/workqueue.c:2264 >> worker_thread+0x98/0xe40 kernel/workqueue.c:2410 >> kthread+0x361/0x430 kernel/kthread.c:255 >> ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 > > The free and use-after-free are both via the same do_enable_set() path > which implies there are racing writes to the debugfs write handler. It > seems locking is missing for both listen_chan and enable_6lowpan. The > latter seems misused in is_bt_6lowpan(), which should likely just be > checking for chan->ops == &bt_6lowpan_chan_ops, I think? > > I have no way to actually test changes to this code... > I do have limited hardware for testing bluetooth 6lowpan connections, but am a little busy these weeks. So some time by the end of this month I should be able to at least verify if my use-case would be broken by a change, if somebody were to propose one ;) br Josua Mayer Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +H+PDOkIBl/C7QAAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 19:56:57 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id GKUKC+kIBl+U2wAAlp8NpQ (envelope-from ); Wed, 08 Jul 2020 19:56:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9D0DAA015E; Wed, 8 Jul 2020 19:56:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726100AbgGHR4u (ORCPT + 1 other); Wed, 8 Jul 2020 13:56:50 -0400 Received: from mga09.intel.com ([134.134.136.24]:57442 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725978AbgGHR4t (ORCPT ); Wed, 8 Jul 2020 13:56:49 -0400 IronPort-SDR: sQu6qFDshyIX+lcBhkEAx3wMQQahyIsmmcAVLBZNXrucz+7SHypNurH0VnfiEjgrJpL79JYc0B KosoaIA+XGYg== X-IronPort-AV: E=McAfee;i="6000,8403,9676"; a="149374277" X-IronPort-AV: E=Sophos;i="5.75,328,1589266800"; d="scan'208";a="149374277" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2020 10:56:48 -0700 IronPort-SDR: qAAGtQj3L8yf12pdLUGmT4nhPvmov9ql8YvlJgrP6fmH8zgwftyJ7U8/frJk2WkI/Y2UDkVs97 wFM3mHQo6P3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,328,1589266800"; d="scan'208";a="388887560" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by fmsmga001.fm.intel.com with ESMTP; 08 Jul 2020 10:56:48 -0700 Received: from orsmsx121.amr.corp.intel.com (10.22.225.226) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 10:56:47 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX121.amr.corp.intel.com (10.22.225.226) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 10:56:47 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.108) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 10:56:47 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ifKwJ7emoTAc/9rHAg5WJzgBjKziSqgV1gdEDyza23DqYE9u93FO0d+MBrmtQqMEABmyUnCZWkFxynCLGvnW99zEYNenerrawL3iHUJzEybjfxzJU/k9GcVILcGFeF4vrXnq4mTQih5CJbS4EcakXnVR5bznQJ96fOsWqaO192YV2WPrlJMv42abhnEO8949YSB5s+R+Ppqxa5dMYuXexIBY7IfnlwC1DtjM0jWSkLGp0C0W8/SFAdJhOebdvoV4ixM0xG6LVJtQPbBMihaMnnDuvLr9u3xaXRUNL5Csq1t+kI5tjFTZJ5ML8SlpEFUWuPqwWRaUQ91aYHOvees2jQ== 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-SenderADCheck; bh=Ti7VqL0Co1R0rSjW6L58VCpXOw9IEn9HsNlSvOSpTuo=; b=eaRaavLg7FMhKQFuIb1cXLNcEXxrztMueNfiyBxZ0HZP1gTtMws3KOYS1SxK0UFlsAVYaQqeZ8I78cBRfnn4j+KBoiEiC5h23UkXl11uTT31WZZXCNYuAk2C+xiIjoPaO+spHE4K/0z+HAkzprmp5Ig8HgKIDV1dP9i2UdH8aY4ZhyC8yUg2bqXZgkXBUflFPpezbwjo8Yw3AkxvZj/5dNEOiJKIiuEn2sbdXrDmnbznnroK9mSrcnWUpVrrNnPhTH4YEKr3Ly+4kmbbjhDKkPuwjG6M5/iUCx6ur/fRVWdK/4+cwSHvsdkjatr+WUKP2TGqvLSYCeZcfIBM0lbwww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ti7VqL0Co1R0rSjW6L58VCpXOw9IEn9HsNlSvOSpTuo=; b=UgNAq/OoNAWDr7yaNQqXm+XezUCsrKO2lKrHzQ1Rm2u/NdZyG4fQEqHMELMIARLV0BnyKv+X/ORc/nJaNHQ/bM9sdV/BiIL/oVduKmqJvhf2D3STT2OTwLjG7eXc/wTrLZumBhXxx15D8O9w94MvHo1cKcdm5TIFAZVHuQ/AsqY= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1264.namprd11.prod.outlook.com (2603:10b6:300:27::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20; Wed, 8 Jul 2020 17:56:47 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%7]) with mapi id 15.20.3174.021; Wed, 8 Jul 2020 17:56:47 +0000 From: "Gix, Brian" To: "linux-bluetooth@vger.kernel.org" , "Stotland, Inga" Subject: Re: [PATCH BlueZ 1/2] mesh: Get rid of "unreliable opcodes" in config server Thread-Topic: [PATCH BlueZ 1/2] mesh: Get rid of "unreliable opcodes" in config server Thread-Index: AQHWVH3xZ/3pazV0xUKUuhkvaEFGoaj9+U4A Date: Wed, 8 Jul 2020 17:56:46 +0000 Message-ID: References: <20200707164439.24146-1-inga.stotland@intel.com> In-Reply-To: <20200707164439.24146-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.39] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e4d14be7-0100-4da6-e856-08d823684864 x-ms-traffictypediagnostic: MWHPR11MB1264: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1360; x-forefront-prvs: 04583CED1A x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ovMxnsjze0zW2ZvyeqS2Bvcft8ap/uJeODYT4oZo3KLSC+LYBe+5+9mERXWLQ5xFKqS/KHebFDjhBovbz1ls4o612LSabxBVB/ZYKO9chx3vH4Pd0fJn9xcVZ+jdxdBMGMvio1qgQZdlP64zQmBqAzzCUKr1CesuDiO+c1GxodFJHGmgyDEmlvgMSNyUwLuUPFsUSoQw6TNoz03hJX7UM3xv21t62+0FbZYJgixWJH1l/cXrqvB4yvotJkms7ZqqlqzJ1EDS3jEeg7KiqeAGZffg6UQZbffiDpC6XVmwHqkYvo72uEvZh0p9INfd0CaKGatQxHh2DR0W7jv2vPsyVTYuFnUOkHahPftA0S5NddJEWC2DIdCktxKpMKG3IQSD x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(66946007)(66446008)(6636002)(66476007)(110136005)(8676002)(86362001)(26005)(71200400001)(316002)(6486002)(8936002)(2616005)(2906002)(6506007)(6512007)(5660300002)(186003)(36756003)(66556008)(64756008)(91956017)(478600001)(76116006)(83380400001)(26583001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 7MsCJeGRI3aeZpeuMgSJFLjXyOidtQ3y/uilWV2k7+WmKuC+qjAXqewnUsMKv18ICgwHvhyHZelhapAv4litktUNkpftjxlbdBCjT4IskkR6vAQhCHDwBnl471Wm/oZ3pcfymdafwwzuucO2BElBuaqTyoiai9ClZZeh68w7nfmXQnONip4VjNgNNzzjwX29zarWBPaWmanriQJEE9FM8hi/+4xL4LXNTOHjIY9NtpjAQib0jqg55Wab1T0Q+wDjc1WUTLt8rBORPA01OttGx27P+WuR8ff2EuviecowwWlyGx6zE1XevuB776FosjbNtb5gsJYw1yNoOaEInt23TuTN90pK3oWcT/y4rM/dqRfrnd7yOXMcd3t2/HnKcSBo/xD/mpgBoYNtYseosFbvpmeS1SX/yuuobJ8wNe9T8Q6GWJegSE8IWvBeXWuIG1CjGr/zhXIAU5XeVABgUKFAbgFGqSuskJucWOJ6RExZnsE= Content-Type: text/plain; charset="utf-8" Content-ID: <17C8926655AB9643A4BD68C5DD2A4ED3@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4d14be7-0100-4da6-e856-08d823684864 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jul 2020 17:56:46.9953 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: jWQiJlKLG5pO4FrfUV/1WAFa6I2bMOkFoNszJURrndyI/IzxyTktrSgZu8tMtsNhzm9BUfYryhU6c0fawpp0Hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1264 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.79 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9D0DAA015E X-Rspamd-UID: dac59c UGF0Y2hzZXQgQXBwbGllZA0KDQpPbiBUdWUsIDIwMjAtMDctMDcgYXQgMDk6NDQgLTA3MDAsIElu Z2EgU3RvdGxhbmQgd3JvdGU6DQo+IFRoaXMgcmVtb3ZlcyBhbiBvbGQgbm90aW9uIG9mIHVucmVs aWFibGUgb3Bjb2RlcyBpbiBjb25maWcgc2VydmVyDQo+IG1vZGVsICwgaS5lLiwgYSBjb3JyZWN0 bHkgZm9ybWF0dGVkIGFja25vd2xlZGdlZCBtZXNzYWdlIGFsd2F5cw0KPiBnZXRzIGEgcmVzcG9u c2UuDQo+IC0tLQ0KPiAgbWVzaC9jZmdtb2Qtc2VydmVyLmMgfCAzMSArKysrKysrKysrKy0tLS0t LS0tLS0tLS0tLS0tLS0tDQo+ICBtZXNoL21vZGVsLmggICAgICAgICB8ICAyIC0tDQo+ICAyIGZp bGVzIGNoYW5nZWQsIDExIGluc2VydGlvbnMoKyksIDIyIGRlbGV0aW9ucygtKQ0KPiANCj4gZGlm ZiAtLWdpdCBhL21lc2gvY2ZnbW9kLXNlcnZlci5jIGIvbWVzaC9jZmdtb2Qtc2VydmVyLmMNCj4g aW5kZXggYzUyNWQ5ZDI0Li44YmE5YmM2ZWMgMTAwNjQ0DQo+IC0tLSBhL21lc2gvY2ZnbW9kLXNl cnZlci5jDQo+ICsrKyBiL21lc2gvY2ZnbW9kLXNlcnZlci5jDQo+IEBAIC05OCw5ICs5OCw4IEBA IHN0YXRpYyB2b2lkIGNvbmZpZ19wdWJfZ2V0KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQx Nl90IG5ldF9pZHgsDQo+ICB9DQo+ICANCj4gIHN0YXRpYyB2b2lkIGNvbmZpZ19wdWJfc2V0KHN0 cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+IC0JCQkJCXVpbnQxNl90 IHNyYywgdWludDE2X3QgZHN0LA0KPiAtCQkJCQljb25zdCB1aW50OF90ICpwa3QsIGJvb2wgdmly dCwNCj4gLQkJCQkJYm9vbCB2ZW5kb3IsIGJvb2wgdW5yZWxpYWJsZSkNCj4gKwkJCQl1aW50MTZf dCBzcmMsIHVpbnQxNl90IGRzdCwNCj4gKwkJCQljb25zdCB1aW50OF90ICpwa3QsIGJvb2wgdmly dCwgYm9vbCB2ZW5kb3IpDQo+ICB7DQo+ICAJdWludDMyX3QgbW9kX2lkOw0KPiAgCXVpbnQxNl90 IGVsZV9hZGRyLCBpZHgsIG90YSA9IFVOQVNTSUdORURfQUREUkVTUzsNCj4gQEAgLTE0Myw5ICsx NDIsOCBAQCBzdGF0aWMgdm9pZCBjb25maWdfcHViX3NldChzdHJ1Y3QgbWVzaF9ub2RlICpub2Rl LCB1aW50MTZfdCBuZXRfaWR4LA0KPiAgCQkJCQlzdGF0dXMsIGVsZV9hZGRyLCBvdGEsIG1vZF9p ZCwgaWR4KTsNCj4gIA0KPiAgCWlmIChzdGF0dXMgIT0gTUVTSF9TVEFUVVNfU1VDQ0VTUykgew0K PiAtCQlpZiAoIXVucmVsaWFibGUpDQo+IC0JCQlzZW5kX3B1Yl9zdGF0dXMobm9kZSwgbmV0X2lk eCwgc3JjLCBkc3QsIHN0YXR1cywNCj4gLQkJCQkJZWxlX2FkZHIsIG1vZF9pZCwgMCwgMCwgMCwg MCwgMCwgMCk7DQo+ICsJCXNlbmRfcHViX3N0YXR1cyhub2RlLCBuZXRfaWR4LCBzcmMsIGRzdCwg c3RhdHVzLCBlbGVfYWRkciwNCj4gKwkJCQkJCW1vZF9pZCwgMCwgMCwgMCwgMCwgMCwgMCk7DQo+ ICANCj4gIAkJcmV0dXJuOw0KPiAgCX0NCj4gQEAgLTE4MCwxMCArMTc4LDggQEAgc3RhdGljIHZv aWQgY29uZmlnX3B1Yl9zZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgbmV0X2lk eCwNCj4gIAkJCXN0YXR1cyA9IE1FU0hfU1RBVFVTX1NUT1JBR0VfRkFJTDsNCj4gIAl9DQo+ICAN Cj4gLQlpZiAoIXVucmVsaWFibGUpDQo+IC0JCXNlbmRfcHViX3N0YXR1cyhub2RlLCBuZXRfaWR4 LCBzcmMsIGRzdCwgc3RhdHVzLCBlbGVfYWRkciwNCj4gLQkJCQkJbW9kX2lkLCBvdGEsIGlkeCwg Y3JlZF9mbGFnLCB0dGwsDQo+IC0JCQkJCXBlcmlvZCwgcmV0cmFuc21pdCk7DQo+ICsJc2VuZF9w dWJfc3RhdHVzKG5vZGUsIG5ldF9pZHgsIHNyYywgZHN0LCBzdGF0dXMsIGVsZV9hZGRyLCBtb2Rf aWQsIG90YSwNCj4gKwkJCQlpZHgsIGNyZWRfZmxhZywgdHRsLCBwZXJpb2QsIHJldHJhbnNtaXQp Ow0KPiAgfQ0KPiAgDQo+ICBzdGF0aWMgdm9pZCBzZW5kX3N1Yl9zdGF0dXMoc3RydWN0IG1lc2hf bm9kZSAqbm9kZSwgdWludDE2X3QgbmV0X2lkeCwNCj4gQEAgLTMxMSw3ICszMDcsNiBAQCBzdGF0 aWMgdm9pZCBjb25maWdfc3ViX3NldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBu ZXRfaWR4LA0KPiAgCQkJCQlib29sIHZpcnQsIHVpbnQzMl90IG9wY29kZSkNCj4gIHsNCj4gIAl1 aW50MTZfdCBncnAsIGVsZV9hZGRyOw0KPiAtCWJvb2wgdW5yZWxpYWJsZSA9ICEhKG9wY29kZSAm IE9QX1VOUkVMSUFCTEUpOw0KPiAgCXVpbnQzMl90IG1vZF9pZDsNCj4gIAljb25zdCB1aW50OF90 ICphZGRyID0gTlVMTDsNCj4gIAlpbnQgc3RhdHVzID0gTUVTSF9TVEFUVVNfU1VDQ0VTUzsNCj4g QEAgLTM2OSw3ICszNjQsNyBAQCBzdGF0aWMgdm9pZCBjb25maWdfc3ViX3NldChzdHJ1Y3QgbWVz aF9ub2RlICpub2RlLCB1aW50MTZfdCBuZXRfaWR4LA0KPiAgCX0gZWxzZQ0KPiAgCQlncnAgPSBV TkFTU0lHTkVEX0FERFJFU1M7DQo+ICANCj4gLQlzd2l0Y2ggKG9wY29kZSAmIH5PUF9VTlJFTElB QkxFKSB7DQo+ICsJc3dpdGNoIChvcGNvZGUpIHsNCj4gIAlkZWZhdWx0Og0KPiAgCQlsX2RlYnVn KCJCYWQgb3Bjb2RlOiAleCIsIG9wY29kZSk7DQo+ICAJCXJldHVybjsNCj4gQEAgLTQxMSw4ICs0 MDYsOCBAQCBzdGF0aWMgdm9pZCBjb25maWdfc3ViX3NldChzdHJ1Y3QgbWVzaF9ub2RlICpub2Rl LCB1aW50MTZfdCBuZXRfaWR4LA0KPiAgCQlncnAgPSBVTkFTU0lHTkVEX0FERFJFU1M7DQo+ICAJ CS8qIEZhbGwgVGhyb3VnaCAqLw0KPiAgCWNhc2UgT1BfQ09ORklHX01PREVMX1NVQl9ERUxFVEU6 DQo+IC0JCXN0YXR1cyA9IG1lc2hfbW9kZWxfc3ViX2RlbChub2RlLCBlbGVfYWRkciwgbW9kX2lk LA0KPiAtCQkJCQkJCWFkZHIsIHZpcnQsICZncnApOw0KPiArCQlzdGF0dXMgPSBtZXNoX21vZGVs X3N1Yl9kZWwobm9kZSwgZWxlX2FkZHIsIG1vZF9pZCwgYWRkciwgdmlydCwNCj4gKwkJCQkJCQkJ CSZncnApOw0KPiAgDQo+ICAJCWlmIChzdGF0dXMgPT0gTUVTSF9TVEFUVVNfU1VDQ0VTUykNCj4g IAkJCXNhdmVfY29uZmlnX3N1Yihub2RlLCBlbGVfYWRkciwgbW9kX2lkLCB2ZW5kb3IsIGFkZHIs DQo+IEBAIC00MjEsMTAgKzQxNiw3IEBAIHN0YXRpYyB2b2lkIGNvbmZpZ19zdWJfc2V0KHN0cnVj dCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+ICAJCWJyZWFrOw0KPiAgCX0N Cj4gIA0KPiAtCWlmICghdW5yZWxpYWJsZSkNCj4gLQkJc2VuZF9zdWJfc3RhdHVzKG5vZGUsIG5l dF9pZHgsIHNyYywgZHN0LCBzdGF0dXMsIGVsZV9hZGRyLA0KPiAtCQkJCQkJCQlncnAsIG1vZF9p ZCk7DQo+IC0NCj4gKwlzZW5kX3N1Yl9zdGF0dXMobm9kZSwgbmV0X2lkeCwgc3JjLCBkc3QsIHN0 YXR1cywgZWxlX2FkZHIsIGdycCwgbW9kX2lkKTsNCj4gIH0NCj4gIA0KPiAgc3RhdGljIHZvaWQg c2VuZF9tb2RlbF9hcHBfc3RhdHVzKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IG5l dF9pZHgsDQo+IEBAIC03ODYsOCArNzc4LDcgQEAgc3RhdGljIGJvb2wgY2ZnX3Nydl9wa3QodWlu dDE2X3Qgc3JjLCB1aW50MTZfdCBkc3QsIHVpbnQxNl90IGFwcF9pZHgsDQo+ICAJCQlyZXR1cm4g dHJ1ZTsNCj4gIA0KPiAgCQljb25maWdfcHViX3NldChub2RlLCBuZXRfaWR4LCBzcmMsIGRzdCwg cGt0LCB2aXJ0LA0KPiAtCQkJCQkJc2l6ZSA9PSAxMyB8fCBzaXplID09IDI3LA0KPiAtCQkJCQkJ ISEob3Bjb2RlICYgT1BfVU5SRUxJQUJMRSkpOw0KPiArCQkJCQkJc2l6ZSA9PSAxMyB8fCBzaXpl ID09IDI3KTsNCj4gIAkJYnJlYWs7DQo+ICANCj4gIAljYXNlIE9QX0NPTkZJR19NT0RFTF9QVUJf R0VUOg0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9tb2RlbC5oIGIvbWVzaC9tb2RlbC5oDQo+IGluZGV4 IGY3MTdmYjAwYy4uMDM3N2QzZmRkIDEwMDY0NA0KPiAtLS0gYS9tZXNoL21vZGVsLmgNCj4gKysr IGIvbWVzaC9tb2RlbC5oDQo+IEBAIC0xOSw4ICsxOSw2IEBADQo+ICANCj4gIHN0cnVjdCBtZXNo X21vZGVsOw0KPiAgDQo+IC0jZGVmaW5lIE9QX1VOUkVMSUFCTEUJCQkweDAxMDANCj4gLQ0KPiAg I2RlZmluZSBNQVhfQklORElOR1MJMTANCj4gICNkZWZpbmUgTUFYX0dSUF9QRVJfTU9ECTEwDQo+ ICANCg== Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wIWIBKIJBl95ywAAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 20:00:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id KDvqAqIJBl+AoQEAgupzMw (envelope-from ); Wed, 08 Jul 2020 20:00:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7777A53020; Wed, 8 Jul 2020 19:59:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726289AbgGHR7n (ORCPT + 1 other); Wed, 8 Jul 2020 13:59:43 -0400 Received: from mga09.intel.com ([134.134.136.24]:57482 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbgGHR7m (ORCPT ); Wed, 8 Jul 2020 13:59:42 -0400 IronPort-SDR: PNYdto/PfM122A2+418oBTDz/d5W5/1mihkr9Ze1ZWlbAh2H3xbDi3DKnBLmb6sP52sKE35Drv mNmZsV+Z6cZA== X-IronPort-AV: E=McAfee;i="6000,8403,9676"; a="149374324" X-IronPort-AV: E=Sophos;i="5.75,328,1589266800"; d="scan'208";a="149374324" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2020 10:57:15 -0700 IronPort-SDR: elgMiwLrCdbdh9TGR1IJo4pLEoDXKWBCbvViy31HlDuTw05/Ee3TTz87eATkesdNwZhXQKsaEF 2ExcqRZrSx4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,328,1589266800"; d="scan'208";a="268528430" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga008.fm.intel.com with ESMTP; 08 Jul 2020 10:57:15 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 8 Jul 2020 10:57:14 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 8 Jul 2020 10:57:14 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.103) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 10:57:14 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FiFNEaGGTjlwfTrwS92LGvlySIyjHMZTkRq8R+9+axBVCZc4J4zbSXY4tUSlMI53ra3iRP+FvPrzGKBseshqd9e3fLMF/DLjKX0Waeu/14QoQ5tfPU1sIhP1GLmTL7LIWgaBJbdn9hRcmHNNkUVhkK4WNQ0jM/V3GWG+xiTUIDmIZkBcpTkhff9ahqX8fupQyk8bWjJuNDCLZO5gc/cD8ODaSqkWT0T1TonbtRN1zlp/Cnf3Ct18tJZHOGcxBl8g75HQSvkKj/5suLajpGqtZJm9onf+yN2I0SjupVHIBA9BTGCwb9aHQcYx3eMKrR3cRBSSzQbuFtCIJjSCJHA7ew== 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-SenderADCheck; bh=gG4xFiajl7fC+VnaoOtG0BSt2YGsxc2SSV65uDKUHAw=; b=Td9pz75p2j6WC5OFHuOISSIlL/UNUui+HhivsbUgcYeyU7SFNqthwaqz7c27IMy9OhBWels20cv1gWA5SVmEHPgxp0ZpbNNuKbrVIWQlo9GqJgFhGn7pZCUsP7agyX7I53JjArS+KnkgkmHINdNGd2ZtefvPMGcVs4hUeGmHw8WwK3Fy2oZ1doJxphyeiBZr2cC5U9FFOP7nZq+L/V8MsW5KxYb2xMzOcBycFX2GagIK2/SJtfAUOqf5zc5mjcKfSiTn2eVpwfFziA9NfNkdIRyq5oMEctiExJBwEEqNNRsLrLfdxFkvbPUYUwREoeqtu62QjN9M7oODNFYBZTyCsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gG4xFiajl7fC+VnaoOtG0BSt2YGsxc2SSV65uDKUHAw=; b=mu/k82yjRPcJCWheoqUIl46iUdiZGDPfcb+T/VgOb0YgCBxb7s7v7B2KGxV5ywmHnVjUw4SeKzUpFXhXEl0POvSMaSnsXWfm0zjHUIzUmTukMqluBJbvs5OzmzJp/Ybfepgoev0q1RP26qrXXBLBqimBufeRPVOFEHN4lRZSuyc= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1264.namprd11.prod.outlook.com (2603:10b6:300:27::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20; Wed, 8 Jul 2020 17:57:13 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%7]) with mapi id 15.20.3174.021; Wed, 8 Jul 2020 17:57:13 +0000 From: "Gix, Brian" To: "linux-bluetooth@vger.kernel.org" CC: "Stotland, Inga" Subject: Re: [PATCH BlueZ v2] mesh: Add Composition page storage to node.json Thread-Topic: [PATCH BlueZ v2] mesh: Add Composition page storage to node.json Thread-Index: AQHWVIq3CE+2D/FlUUSPtokXwpgJHqj9+VQA Date: Wed, 8 Jul 2020 17:57:13 +0000 Message-ID: <030ee93f45d42df35b1ba03d6ae2159b3bb21885.camel@intel.com> References: <20200707181611.135109-1-brian.gix@intel.com> In-Reply-To: <20200707181611.135109-1-brian.gix@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.39] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f72973d1-261f-4e3d-2c94-08d82368582c x-ms-traffictypediagnostic: MWHPR11MB1264: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:483; x-forefront-prvs: 04583CED1A x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: UuFRmO94xLjTevP7iTAjnvBncKkcHwRscZvwEryplvQorACBHZr7BRYo+wzd3NsXn96cE8vHVBc7ZkTBpY1YxWBUm/s4adSGngcvRkD5xQwlZHtipacR9lz2BHLyQPZnvy+DK15CDh8kcdPZkyF4F6h1OnvvSUzJmWH7WC74AA9953iWmmcBe6n+ox3hE4UihaqdmmE8su8F4fBeDWMCPRHUwpbEhYtwmsX3o2FiZ9NvQREFXdwbWjwxJnBvuY0zBNFfN0S7IVdHvjCEzdgfYRob733/yykCXvdFSa2fS5LFQG70g2oaHofhj4eyDZiza2NQtpCs1IqSiLcO1OjDEQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(66946007)(66446008)(66476007)(6916009)(8676002)(86362001)(26005)(71200400001)(316002)(6486002)(8936002)(2616005)(2906002)(107886003)(4326008)(30864003)(6506007)(6512007)(5660300002)(186003)(36756003)(66556008)(64756008)(91956017)(478600001)(76116006)(83380400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: NhISA2QltLYBxf/jzqtkGgCZYpMUhIJ4nHcS0xPPGC05zKCdTMiIEBzlEM4stu9fOboLAuDgHX7lMDKdVhiol5cGXT8TTAzHHOn4aflY1CcWFsYIVabSGO5C1q4BOLEJHD0V+hFlMSvy8k9GXhrflP3TbBh/9UO3z/UgjJJqUCy+uzHJiff19JsNCqn/6U/LcRZHYAm+PWLFyZ6/nN4ppnstNW/VcN6h0Tez+0kGGYP3lEIre0Viz+oB+A2e5ENZwuDQCVhlqo+HdmncRHIQMnBTBmTe5oMMrXHzYNjencztK0bxA1ouf546qBe24CdvQUWaPqkr25MyAqZXxwoE7r39DponNhLy0mr8HIeVMIPrl9JBsga0CWP5TXdjDBcSIb/7dLSZ1lPdPrwQz88ZpuYZcEIx/UE6UhsPfxrKI8vCWMpRdJD9Y6Ej/SDuuAO6jJMEbhsx9LjhvlBH2VHNTQBxL1nOtrs5YRURMO6R3OU= Content-Type: text/plain; charset="utf-8" Content-ID: <74D2CD71E1A2C1498EC876F5F5CCE81E@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f72973d1-261f-4e3d-2c94-08d82368582c X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jul 2020 17:57:13.3974 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LBfF9oIfk2r5lGQIUaeXGuXJSONY9LovAUSrQ3myk3/0lk+tPJtZUPQS8xDEonl5lnG7Mk0ukCeNb+SuGuBFgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1264 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7777A53020 X-Rspamd-UID: 294c2e QXBwbGllZA0KT24gVHVlLCAyMDIwLTA3LTA3IGF0IDExOjE2IC0wNzAwLCBCcmlhbiBHaXggd3Jv dGU6DQo+IE1lc2ggc3VwcG9ydHMgbXVsdGlwbGUgQ29tcG9zaXRpb24gUGFnZXMsIGFsdGhvdWdo IG9ubHkgb25lIGlzIGRlZmluZWQNCj4gaW4gdGhlIGN1cnJlbnQgc3BlY2lmaWNhdGlvbi4gVGhp cyBjaGFuZ2UgYWxsb3dzIHNhdmluZyBhbmQgcmV0cmlldmFsIG9mDQo+IGFueSBwYWdlcywgbnVt YmVyZWQgMC0yNTUuDQo+IC0tLQ0KPiAgbWVzaC9jZmdtb2Qtc2VydmVyLmMgICAgfCAgNDIgKysr KysrKysrLS0NCj4gIG1lc2gvbWVzaC1jb25maWctanNvbi5jIHwgMTYyICsrKysrKysrKysrKysr KysrKysrKysrKysrKysrKysrKysrKysrKysNCj4gIG1lc2gvbWVzaC1jb25maWcuaCAgICAgIHwg IDEyICsrKw0KPiAgbWVzaC9ub2RlLmMgICAgICAgICAgICAgfCAxMzAgKysrKysrKysrKysrKysr KysrKysrKysrKystLS0tLS0NCj4gIG1lc2gvbm9kZS5oICAgICAgICAgICAgIHwgICA2ICstDQo+ ICA1IGZpbGVzIGNoYW5nZWQsIDMyMCBpbnNlcnRpb25zKCspLCAzMiBkZWxldGlvbnMoLSkNCj4g DQo+IGRpZmYgLS1naXQgYS9tZXNoL2NmZ21vZC1zZXJ2ZXIuYyBiL21lc2gvY2ZnbW9kLXNlcnZl ci5jDQo+IGluZGV4IGM1MjVkOWQyNC4uNjE5NGZjN2Q0IDEwMDY0NA0KPiAtLS0gYS9tZXNoL2Nm Z21vZC1zZXJ2ZXIuYw0KPiArKysgYi9tZXNoL2NmZ21vZC1zZXJ2ZXIuYw0KPiBAQCAtMzQsNiAr MzQsMTIgQEANCj4gIA0KPiAgI2RlZmluZSBDRkdfTUFYX01TR19MRU4gMzgwDQo+ICANCj4gKy8q IFN1cHBvcnRlZCBjb21wb3NpdGlvbiBwYWdlcywgc29ydGVkIGhpZ2ggdG8gbG93ICovDQo+ICsv KiBPbmx5IHBhZ2UgMCBpcyBjdXJyZW50bHkgc3VwcG9ydGVkICovDQo+ICtzdGF0aWMgY29uc3Qg dWludDhfdCBzdXBwb3J0ZWRfcGFnZXNbXSA9IHsNCj4gKwkwDQo+ICt9Ow0KPiArDQo+ICBzdGF0 aWMgdm9pZCBzZW5kX3B1Yl9zdGF0dXMoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3Qg bmV0X2lkeCwNCj4gIAkJCXVpbnQxNl90IHNyYywgdWludDE2X3QgZHN0LA0KPiAgCQkJdWludDhf dCBzdGF0dXMsIHVpbnQxNl90IGVsZV9hZGRyLCB1aW50MzJfdCBtb2RfaWQsDQo+IEBAIC03MDEs NiArNzA3LDMzIEBAIHN0YXRpYyB2b2lkIG5vZGVfcmVzZXQodm9pZCAqdXNlcl9kYXRhKQ0KPiAg CW5vZGVfcmVtb3ZlKG5vZGUpOw0KPiAgfQ0KPiAgDQo+ICtzdGF0aWMgdWludDE2X3QgZ2V0X2Nv bXBvc2l0aW9uKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgcGFnZSwNCj4gKwkJCQkJ CQkJdWludDhfdCAqYnVmKQ0KPiArew0KPiArCWNvbnN0IHVpbnQ4X3QgKmNvbXA7DQo+ICsJdWlu dDE2X3QgbGVuID0gMDsNCj4gKwlzaXplX3QgaTsNCj4gKw0KPiArCWZvciAoaSA9IDA7IGkgPCBz aXplb2Yoc3VwcG9ydGVkX3BhZ2VzKTsgaSsrKSB7DQo+ICsJCWlmIChwYWdlIDwgc3VwcG9ydGVk X3BhZ2VzW2ldKQ0KPiArCQkJY29udGludWU7DQo+ICsNCj4gKwkJcGFnZSA9IHN1cHBvcnRlZF9w YWdlc1tpXTsNCj4gKwkJY29tcCA9IG5vZGVfZ2V0X2NvbXAobm9kZSwgcGFnZSwgJmxlbik7DQo+ ICsNCj4gKwkJaWYgKCFwYWdlIHx8IGxlbikNCj4gKwkJCWJyZWFrOw0KPiArCX0NCj4gKw0KPiAr CWlmICghbGVuKQ0KPiArCQlyZXR1cm4gMDsNCj4gKw0KPiArCSpidWYrKyA9IHBhZ2U7DQo+ICsJ bWVtY3B5KGJ1ZiwgY29tcCwgbGVuKTsNCj4gKw0KPiArCXJldHVybiBsZW4gKyAxOw0KPiArfQ0K PiArDQo+ICBzdGF0aWMgYm9vbCBjZmdfc3J2X3BrdCh1aW50MTZfdCBzcmMsIHVpbnQxNl90IGRz dCwgdWludDE2X3QgYXBwX2lkeCwNCj4gIAkJCQl1aW50MTZfdCBuZXRfaWR4LCBjb25zdCB1aW50 OF90ICpkYXRhLA0KPiAgCQkJCXVpbnQxNl90IHNpemUsIGNvbnN0IHZvaWQgKnVzZXJfZGF0YSkN Cj4gQEAgLTc0NiwxNiArNzc5LDkgQEAgc3RhdGljIGJvb2wgY2ZnX3Nydl9wa3QodWludDE2X3Qg c3JjLCB1aW50MTZfdCBkc3QsIHVpbnQxNl90IGFwcF9pZHgsDQo+ICAJCWlmIChzaXplICE9IDEp DQo+ICAJCQlyZXR1cm4gZmFsc2U7DQo+ICANCj4gLQkJLyogT25seSBwYWdlIDAgaXMgY3VycmVu dGx5IHN1cHBvcnRlZCAqLw0KPiAtCQlpZiAocGt0WzBdICE9IDApIHsNCj4gLQkJCWxfZGVidWco IlVuc3VwcG9ydGVkIHBhZ2UgbnVtYmVyICVkIiwgcGt0WzBdKTsNCj4gLQkJCWxfZGVidWcoIlJl dHVybmluZyBwYWdlIG51bWJlciAwIik7DQo+IC0JCX0NCj4gIAkJbG9uZ19tc2cgPSBsX21hbGxv YyhDRkdfTUFYX01TR19MRU4pOw0KPiAgCQluID0gbWVzaF9tb2RlbF9vcGNvZGVfc2V0KE9QX0RF Vl9DT01QX1NUQVRVUywgbG9uZ19tc2cpOw0KPiAtCQlsb25nX21zZ1tuKytdID0gMDsNCj4gLQkJ biArPSBub2RlX2dlbmVyYXRlX2NvbXAobm9kZSwgbG9uZ19tc2cgKyBuLA0KPiAtCQkJCQkJCUNG R19NQVhfTVNHX0xFTiAtIG4pOw0KPiArCQluICs9IGdldF9jb21wb3NpdGlvbihub2RlLCBwa3Rb MF0sIGxvbmdfbXNnICsgbik7DQo+ICANCj4gIAkJYnJlYWs7DQo+ICANCj4gZGlmZiAtLWdpdCBh L21lc2gvbWVzaC1jb25maWctanNvbi5jIGIvbWVzaC9tZXNoLWNvbmZpZy1qc29uLmMNCj4gaW5k ZXggNjYxNzc1Zjk1Li44OGY3MTVmYzEgMTAwNjQ0DQo+IC0tLSBhL21lc2gvbWVzaC1jb25maWct anNvbi5jDQo+ICsrKyBiL21lc2gvbWVzaC1jb25maWctanNvbi5jDQo+IEBAIC00MzAsNiArNDMw LDU0IEBAIHN0YXRpYyBib29sIHJlYWRfZGV2aWNlX2tleShqc29uX29iamVjdCAqam9iaiwgdWlu dDhfdCBrZXlfYnVmWzE2XSkNCj4gIAlyZXR1cm4gdHJ1ZTsNCj4gIH0NCj4gIA0KPiArc3RhdGlj IGJvb2wgcmVhZF9jb21wX3BhZ2VzKGpzb25fb2JqZWN0ICpqb2JqLCBzdHJ1Y3QgbWVzaF9jb25m aWdfbm9kZSAqbm9kZSkNCj4gK3sNCj4gKwlqc29uX29iamVjdCAqamFycmF5LCAqamVudHJ5Ow0K PiArCXN0cnVjdCBtZXNoX2NvbmZpZ19jb21wX3BhZ2UgKnBhZ2U7DQo+ICsJaW50IGxlbjsNCj4g KwlpbnQgaTsNCj4gKw0KPiArCWlmICghanNvbl9vYmplY3Rfb2JqZWN0X2dldF9leChqb2JqLCAi cGFnZXMiLCAmamFycmF5KSkNCj4gKwkJcmV0dXJuIHRydWU7DQo+ICsNCj4gKwlpZiAoanNvbl9v YmplY3RfZ2V0X3R5cGUoamFycmF5KSAhPSBqc29uX3R5cGVfYXJyYXkpDQo+ICsJCXJldHVybiBm YWxzZTsNCj4gKw0KPiArCWxlbiA9IGpzb25fb2JqZWN0X2FycmF5X2xlbmd0aChqYXJyYXkpOw0K PiArDQo+ICsJZm9yIChpID0gMDsgaSA8IGxlbjsgaSsrKSB7DQo+ICsJCXNpemVfdCBjbGVuOw0K PiArCQljaGFyICpzdHI7DQo+ICsNCj4gKwkJamVudHJ5ID0ganNvbl9vYmplY3RfYXJyYXlfZ2V0 X2lkeChqYXJyYXksIGkpOw0KPiArCQlzdHIgPSAoY2hhciAqKWpzb25fb2JqZWN0X2dldF9zdHJp bmcoamVudHJ5KTsNCj4gKwkJY2xlbiA9IHN0cmxlbihzdHIpOw0KPiArDQo+ICsJCWlmIChjbGVu IDwgKChNSU5fQ09NUF9TSVpFICogMikgKyAxKSkNCj4gKwkJCWNvbnRpbnVlOw0KPiArDQo+ICsJ CWNsZW4gPSAoY2xlbiAvIDIpIC0gMTsNCj4gKw0KPiArCQlwYWdlID0gbF9tYWxsb2Moc2l6ZW9m KHN0cnVjdCBtZXNoX2NvbmZpZ19jb21wX3BhZ2UpICsgY2xlbik7DQo+ICsNCj4gKwkJaWYgKCFz dHIyaGV4KHN0ciArIDIsIGNsZW4gKiAyLCBwYWdlLT5kYXRhLCBjbGVuKSkNCj4gKwkJCWdvdG8g cGFyc2VfZmFpbDsNCj4gKw0KPiArCQlpZiAoc3NjYW5mKHN0ciwgIiUwMmhoeCIsICZwYWdlLT5w YWdlX251bSkgIT0gMSkNCj4gKwkJCWdvdG8gcGFyc2VfZmFpbDsNCj4gKw0KPiArCQlwYWdlLT5s ZW4gPSBjbGVuOw0KPiArDQo+ICsJCWxfcXVldWVfcHVzaF90YWlsKG5vZGUtPnBhZ2VzLCBwYWdl KTsNCj4gKwl9DQo+ICsNCj4gKwlyZXR1cm4gdHJ1ZTsNCj4gKw0KPiArcGFyc2VfZmFpbDoNCj4g KwlsX2ZyZWUocGFnZSk7DQo+ICsJcmV0dXJuIGZhbHNlOw0KPiArfQ0KPiArDQo+ICBzdGF0aWMg Ym9vbCByZWFkX2FwcF9rZXlzKGpzb25fb2JqZWN0ICpqb2JqLCBzdHJ1Y3QgbWVzaF9jb25maWdf bm9kZSAqbm9kZSkNCj4gIHsNCj4gIAlqc29uX29iamVjdCAqamFycmF5Ow0KPiBAQCAtMTM4NCw2 ICsxNDMyLDExIEBAIHN0YXRpYyBib29sIHJlYWRfbm9kZShqc29uX29iamVjdCAqam5vZGUsIHN0 cnVjdCBtZXNoX2NvbmZpZ19ub2RlICpub2RlKQ0KPiAgCQlyZXR1cm4gZmFsc2U7DQo+ICAJfQ0K PiAgDQo+ICsJaWYgKCFyZWFkX2NvbXBfcGFnZXMoam5vZGUsIG5vZGUpKSB7DQo+ICsJCWxfaW5m bygiRmFpbGVkIHRvIHJlYWQgQ29tcG9zaXRpb24gUGFnZXMiKTsNCj4gKwkJcmV0dXJuIGZhbHNl Ow0KPiArCX0NCj4gKw0KPiAgCWlmICghcGFyc2VfZWxlbWVudHMoanZhbHVlLCBub2RlKSkgew0K PiAgCQlsX2luZm8oIkZhaWxlZCB0byBwYXJzZSBlbGVtZW50cyIpOw0KPiAgCQlyZXR1cm4gZmFs c2U7DQo+IEBAIC0xODg5LDYgKzE5NDIsMTEzIEBAIGJvb2wgbWVzaF9jb25maWdfbW9kZWxfcHVi X2RlbChzdHJ1Y3QgbWVzaF9jb25maWcgKmNmZywgdWludDE2X3QgYWRkciwNCj4gIAlyZXR1cm4g c2F2ZV9jb25maWcoY2ZnLT5qbm9kZSwgY2ZnLT5ub2RlX2Rpcl9wYXRoKTsNCj4gIH0NCj4gIA0K PiArc3RhdGljIHZvaWQgZGVsX3BhZ2UoanNvbl9vYmplY3QgKmphcnJheSwgdWludDhfdCBwYWdl KQ0KPiArew0KPiArCWNoYXIgYnVmWzNdOw0KPiArCWludCBpLCBsZW47DQo+ICsNCj4gKwlpZiAo IWphcnJheSkNCj4gKwkJcmV0dXJuOw0KPiArDQo+ICsJc25wcmludGYoYnVmLCAzLCAiJTIuMngi LCBwYWdlKTsNCj4gKw0KPiArCWxlbiA9IGpzb25fb2JqZWN0X2FycmF5X2xlbmd0aChqYXJyYXkp Ow0KPiArDQo+ICsJZm9yIChpID0gMDsgaSA8IGxlbjsgaSsrKSB7DQo+ICsJCWpzb25fb2JqZWN0 ICpqZW50cnk7DQo+ICsJCWNoYXIgKnN0cjsNCj4gKw0KPiArCQlqZW50cnkgPSBqc29uX29iamVj dF9hcnJheV9nZXRfaWR4KGphcnJheSwgaSk7DQo+ICsJCXN0ciA9IChjaGFyICopanNvbl9vYmpl Y3RfZ2V0X3N0cmluZyhqZW50cnkpOw0KPiArDQo+ICsJCS8qIERlbGV0ZSBtYXRjaGluZyBwYWdl KHMpICovDQo+ICsJCWlmICghbWVtY21wKHN0ciwgYnVmLCAyKSkNCj4gKwkJCWpzb25fb2JqZWN0 X2FycmF5X2RlbF9pZHgoamFycmF5LCBpLCAxKTsNCj4gKwl9DQo+ICt9DQo+ICsNCj4gK2Jvb2wg bWVzaF9jb25maWdfY29tcF9wYWdlX2FkZChzdHJ1Y3QgbWVzaF9jb25maWcgKmNmZywgdWludDhf dCBwYWdlLA0KPiArCQkJCQkJdWludDhfdCAqZGF0YSwgdWludDE2X3Qgc2l6ZSkNCj4gK3sNCj4g Kwlqc29uX29iamVjdCAqam5vZGUsICpqc3RyaW5nLCAqamFycmF5ID0gTlVMTDsNCj4gKwljaGFy ICpidWY7DQo+ICsJaW50IGxlbjsNCj4gKw0KPiArCWlmICghY2ZnKQ0KPiArCQlyZXR1cm4gZmFs c2U7DQo+ICsNCj4gKwlqbm9kZSA9IGNmZy0+am5vZGU7DQo+ICsNCj4gKwlqc29uX29iamVjdF9v YmplY3RfZ2V0X2V4KGpub2RlLCAicGFnZXMiLCAmamFycmF5KTsNCj4gKw0KPiArCWxlbiA9IChz aXplICogMikgKyAzOw0KPiArCWJ1ZiA9IGxfbWFsbG9jKGxlbik7DQo+ICsJc25wcmludGYoYnVm LCBsZW4sICIlMi4yeCIsIHBhZ2UpOw0KPiArCWhleDJzdHIoZGF0YSwgc2l6ZSwgYnVmICsgMiwg bGVuIC0gMik7DQo+ICsNCj4gKwlpZiAoamFycmF5ICYmIGphcnJheV9oYXNfc3RyaW5nKGphcnJh eSwgYnVmLCBsZW4pKSB7DQo+ICsJCWxfZnJlZShidWYpOw0KPiArCQlyZXR1cm4gdHJ1ZTsNCj4g Kwl9IGVsc2UgaWYgKCFqYXJyYXkpIHsNCj4gKwkJamFycmF5ID0ganNvbl9vYmplY3RfbmV3X2Fy cmF5KCk7DQo+ICsJCWpzb25fb2JqZWN0X29iamVjdF9hZGQoam5vZGUsICJwYWdlcyIsIGphcnJh eSk7DQo+ICsJfSBlbHNlDQo+ICsJCWRlbF9wYWdlKGphcnJheSwgcGFnZSk7DQo+ICsNCj4gKwlq c3RyaW5nID0ganNvbl9vYmplY3RfbmV3X3N0cmluZyhidWYpOw0KPiArCWpzb25fb2JqZWN0X2Fy cmF5X2FkZChqYXJyYXksIGpzdHJpbmcpOw0KPiArCWxfZnJlZShidWYpOw0KPiArDQo+ICsJcmV0 dXJuIHNhdmVfY29uZmlnKGpub2RlLCBjZmctPm5vZGVfZGlyX3BhdGgpOw0KPiArfQ0KPiArDQo+ ICtib29sIG1lc2hfY29uZmlnX2NvbXBfcGFnZV9tdihzdHJ1Y3QgbWVzaF9jb25maWcgKmNmZywg dWludDhfdCBvbGQsIHVpbnQ4X3QgbncpDQo+ICt7DQo+ICsJanNvbl9vYmplY3QgKmpub2RlLCAq amFycmF5ID0gTlVMTDsNCj4gKwl1aW50OF90ICpkYXRhOw0KPiArCWNoYXIgKnN0cjsNCj4gKwlj aGFyIG9sZF9idWZbM107DQo+ICsJaW50IGksIGxlbiwgZGxlbiA9IDA7DQo+ICsJYm9vbCBzdGF0 dXMgPSB0cnVlOw0KPiArDQo+ICsJaWYgKCFjZmcgfHwgb2xkID09IG53KQ0KPiArCQlyZXR1cm4g ZmFsc2U7DQo+ICsNCj4gKwlqbm9kZSA9IGNmZy0+am5vZGU7DQo+ICsNCj4gKwlqc29uX29iamVj dF9vYmplY3RfZ2V0X2V4KGpub2RlLCAicGFnZXMiLCAmamFycmF5KTsNCj4gKw0KPiArCWlmICgh amFycmF5KQ0KPiArCQlyZXR1cm4gZmFsc2U7DQo+ICsNCj4gKwlzbnByaW50ZihvbGRfYnVmLCAz LCAiJTIuMngiLCBvbGQpOw0KPiArCWRhdGEgPSBsX21hbGxvYyhNQVhfTVNHX0xFTik7DQo+ICsN Cj4gKwlsZW4gPSBqc29uX29iamVjdF9hcnJheV9sZW5ndGgoamFycmF5KTsNCj4gKw0KPiArCWZv ciAoaSA9IDA7IGkgPCBsZW47IGkrKykgew0KPiArCQlqc29uX29iamVjdCAqamVudHJ5Ow0KPiAr DQo+ICsJCWplbnRyeSA9IGpzb25fb2JqZWN0X2FycmF5X2dldF9pZHgoamFycmF5LCBpKTsNCj4g KwkJc3RyID0gKGNoYXIgKilqc29uX29iamVjdF9nZXRfc3RyaW5nKGplbnRyeSk7DQo+ICsNCj4g KwkJLyogRGVsZXRlIG1hdGNoaW5nIHBhZ2UocykgYnV0IHNhdmUgZGF0YSovDQo+ICsJCWlmICgh bWVtY21wKHN0ciwgb2xkX2J1ZiwgMikpIHsNCj4gKwkJCWRsZW4gPSBzdHJsZW4oc3RyICsgMik7 DQo+ICsJCQlzdHIyaGV4KHN0ciArIDIsIGRsZW4sIGRhdGEsIE1BWF9NU0dfTEVOKTsNCj4gKwkJ CWRsZW4gLz0gMjsNCj4gKwkJCWpzb25fb2JqZWN0X2FycmF5X2RlbF9pZHgoamFycmF5LCBpLCAx KTsNCj4gKwkJfQ0KPiArCX0NCj4gKw0KPiArCWlmIChkbGVuKQ0KPiArCQlzdGF0dXMgPSBtZXNo X2NvbmZpZ19jb21wX3BhZ2VfYWRkKGNmZywgbncsIGRhdGEsIGRsZW4pOw0KPiArDQo+ICsJbF9m cmVlKGRhdGEpOw0KPiArDQo+ICsJcmV0dXJuIHN0YXR1czsNCj4gK30NCj4gKw0KPiAgYm9vbCBt ZXNoX2NvbmZpZ19tb2RlbF9zdWJfYWRkKHN0cnVjdCBtZXNoX2NvbmZpZyAqY2ZnLCB1aW50MTZf dCBlbGVfYWRkciwNCj4gIAkJCQkJCXVpbnQzMl90IG1vZF9pZCwgYm9vbCB2ZW5kb3IsDQo+ICAJ CQkJCQlzdHJ1Y3QgbWVzaF9jb25maWdfc3ViICpzdWIpDQo+IEBAIC0yMjEyLDYgKzIzNzIsNyBA QCBzdGF0aWMgYm9vbCBsb2FkX25vZGUoY29uc3QgY2hhciAqZm5hbWUsIGNvbnN0IHVpbnQ4X3Qg dXVpZFsxNl0sDQo+ICAJbm9kZS5lbGVtZW50cyA9IGxfcXVldWVfbmV3KCk7DQo+ICAJbm9kZS5u ZXRrZXlzID0gbF9xdWV1ZV9uZXcoKTsNCj4gIAlub2RlLmFwcGtleXMgPSBsX3F1ZXVlX25ldygp Ow0KPiArCW5vZGUucGFnZXMgPSBsX3F1ZXVlX25ldygpOw0KPiAgDQo+ICAJcmVzdWx0ID0gcmVh ZF9ub2RlKGpub2RlLCAmbm9kZSk7DQo+ICANCj4gQEAgLTIyMzgsNiArMjM5OSw3IEBAIHN0YXRp YyBib29sIGxvYWRfbm9kZShjb25zdCBjaGFyICpmbmFtZSwgY29uc3QgdWludDhfdCB1dWlkWzE2 XSwNCj4gIAlsX2ZyZWUobm9kZS5uZXRfdHJhbnNtaXQpOw0KPiAgCWxfcXVldWVfZGVzdHJveShu b2RlLm5ldGtleXMsIGxfZnJlZSk7DQo+ICAJbF9xdWV1ZV9kZXN0cm95KG5vZGUuYXBwa2V5cywg bF9mcmVlKTsNCj4gKwlsX3F1ZXVlX2Rlc3Ryb3kobm9kZS5wYWdlcywgbF9mcmVlKTsNCj4gIAls X3F1ZXVlX2Rlc3Ryb3kobm9kZS5lbGVtZW50cywgZnJlZV9lbGVtZW50KTsNCj4gIA0KPiAgCWlm ICghcmVzdWx0KQ0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9tZXNoLWNvbmZpZy5oIGIvbWVzaC9tZXNo LWNvbmZpZy5oDQo+IGluZGV4IDlmMzBlNjkzYi4uN2RmYTlmMjBjIDEwMDY0NA0KPiAtLS0gYS9t ZXNoL21lc2gtY29uZmlnLmgNCj4gKysrIGIvbWVzaC9tZXNoLWNvbmZpZy5oDQo+IEBAIC0xNyw2 ICsxNyw4IEBADQo+ICAgKg0KPiAgICovDQo+ICANCj4gKyNkZWZpbmUgTUlOX0NPTVBfU0laRSAx NA0KPiArDQo+ICBzdHJ1Y3QgbWVzaF9jb25maWc7DQo+ICANCj4gIHN0cnVjdCBtZXNoX2NvbmZp Z19zdWIgew0KPiBAQCAtODgsMTAgKzkwLDE3IEBAIHN0cnVjdCBtZXNoX2NvbmZpZ190cmFuc21p dCB7DQo+ICAJdWludDhfdCBjb3VudDsNCj4gIH07DQo+ICANCj4gK3N0cnVjdCBtZXNoX2NvbmZp Z19jb21wX3BhZ2Ugew0KPiArCXVpbnQxNl90IGxlbjsNCj4gKwl1aW50OF90IHBhZ2VfbnVtOw0K PiArCXVpbnQ4X3QgZGF0YVtdOw0KPiArfTsNCj4gKw0KPiAgc3RydWN0IG1lc2hfY29uZmlnX25v ZGUgew0KPiAgCXN0cnVjdCBsX3F1ZXVlICplbGVtZW50czsNCj4gIAlzdHJ1Y3QgbF9xdWV1ZSAq bmV0a2V5czsNCj4gIAlzdHJ1Y3QgbF9xdWV1ZSAqYXBwa2V5czsNCj4gKwlzdHJ1Y3QgbF9xdWV1 ZSAqcGFnZXM7DQo+ICAJdWludDMyX3Qgc2VxX251bWJlcjsNCj4gIAl1aW50MzJfdCBpdl9pbmRl eDsNCj4gIAlib29sIGl2X3VwZGF0ZTsNCj4gQEAgLTEzOSw2ICsxNDgsOSBAQCBib29sIG1lc2hf Y29uZmlnX3dyaXRlX3JlbGF5X21vZGUoc3RydWN0IG1lc2hfY29uZmlnICpjZmcsIHVpbnQ4X3Qg bW9kZSwNCj4gIGJvb2wgbWVzaF9jb25maWdfd3JpdGVfdHRsKHN0cnVjdCBtZXNoX2NvbmZpZyAq Y2ZnLCB1aW50OF90IHR0bCk7DQo+ICBib29sIG1lc2hfY29uZmlnX3dyaXRlX21vZGUoc3RydWN0 IG1lc2hfY29uZmlnICpjZmcsIGNvbnN0IGNoYXIgKmtleXdvcmQsDQo+ICAJCQkJCQkJCWludCB2 YWx1ZSk7DQo+ICtib29sIG1lc2hfY29uZmlnX2NvbXBfcGFnZV9hZGQoc3RydWN0IG1lc2hfY29u ZmlnICpjZmcsIHVpbnQ4X3QgcGFnZSwNCj4gKwkJCQkJCXVpbnQ4X3QgKmRhdGEsIHVpbnQxNl90 IHNpemUpOw0KPiArYm9vbCBtZXNoX2NvbmZpZ19jb21wX3BhZ2VfbXYoc3RydWN0IG1lc2hfY29u ZmlnICpjZmcsIHVpbnQ4X3Qgb2xkLCB1aW50OF90IG53KTsNCj4gIGJvb2wgbWVzaF9jb25maWdf bW9kZWxfYmluZGluZ19hZGQoc3RydWN0IG1lc2hfY29uZmlnICpjZmcsIHVpbnQxNl90IGVsZV9h ZGRyLA0KPiAgCQkJCQkJYm9vbCB2ZW5kb3IsIHVpbnQzMl90IG1vZF9pZCwNCj4gIAkJCQkJCQl1 aW50MTZfdCBhcHBfaWR4KTsNCj4gZGlmZiAtLWdpdCBhL21lc2gvbm9kZS5jIGIvbWVzaC9ub2Rl LmMNCj4gaW5kZXggM2U4ODhjZTYxLi5jNjExNjdiZGEgMTAwNjQ0DQo+IC0tLSBhL21lc2gvbm9k ZS5jDQo+ICsrKyBiL21lc2gvbm9kZS5jDQo+IEBAIC00Niw4ICs0Niw2IEBADQo+ICAjaW5jbHVk ZSAibWVzaC9tYW5hZ2VyLmgiDQo+ICAjaW5jbHVkZSAibWVzaC9ub2RlLmgiDQo+ICANCj4gLSNk ZWZpbmUgTUlOX0NPTVBfU0laRSAxNA0KPiAtDQo+ICAjZGVmaW5lIE1FU0hfTk9ERV9QQVRIX1BS RUZJWCAiL25vZGUiDQo+ICANCj4gIC8qIERlZmF1bHQgdmFsdWVzIGZvciBhIG5ldyBsb2NhbGx5 IGNyZWF0ZWQgbm9kZSAqLw0KPiBAQCAtODEsNiArNzksNyBAQCBzdHJ1Y3Qgbm9kZV9jb21wb3Np dGlvbiB7DQo+ICBzdHJ1Y3QgbWVzaF9ub2RlIHsNCj4gIAlzdHJ1Y3QgbWVzaF9uZXQgKm5ldDsN Cj4gIAlzdHJ1Y3QgbF9xdWV1ZSAqZWxlbWVudHM7DQo+ICsJc3RydWN0IGxfcXVldWUgKnBhZ2Vz Ow0KPiAgCWNoYXIgKmFwcF9wYXRoOw0KPiAgCWNoYXIgKm93bmVyOw0KPiAgCWNoYXIgKm9ial9w YXRoOw0KPiBAQCAtMjY2LDYgKzI2NSw3IEBAIHN0YXRpYyBzdHJ1Y3QgbWVzaF9ub2RlICpub2Rl X25ldyhjb25zdCB1aW50OF90IHV1aWRbMTZdKQ0KPiAgCW5vZGUgPSBsX25ldyhzdHJ1Y3QgbWVz aF9ub2RlLCAxKTsNCj4gIAlub2RlLT5uZXQgPSBtZXNoX25ldF9uZXcobm9kZSk7DQo+ICAJbm9k ZS0+ZWxlbWVudHMgPSBsX3F1ZXVlX25ldygpOw0KPiArCW5vZGUtPnBhZ2VzID0gbF9xdWV1ZV9u ZXcoKTsNCj4gIAltZW1jcHkobm9kZS0+dXVpZCwgdXVpZCwgc2l6ZW9mKG5vZGUtPnV1aWQpKTsN Cj4gIAlzZXRfZGVmYXVsdHMobm9kZSk7DQo+ICANCj4gQEAgLTMzNSw2ICszMzUsNyBAQCBzdGF0 aWMgdm9pZCBmcmVlX25vZGVfcmVzb3VyY2VzKHZvaWQgKmRhdGEpDQo+ICAJLyogRnJlZSBkeW5h bWljIHJlc291cmNlcyAqLw0KPiAgCWZyZWVfbm9kZV9kYnVzX3Jlc291cmNlcyhub2RlKTsNCj4g IAlsX3F1ZXVlX2Rlc3Ryb3kobm9kZS0+ZWxlbWVudHMsIGVsZW1lbnRfZnJlZSk7DQo+ICsJbF9x dWV1ZV9kZXN0cm95KG5vZGUtPnBhZ2VzLCBsX2ZyZWUpOw0KPiAgCW1lc2hfYWdlbnRfcmVtb3Zl KG5vZGUtPmFnZW50KTsNCj4gIAltZXNoX2NvbmZpZ19yZWxlYXNlKG5vZGUtPmNmZyk7DQo+ICAJ bWVzaF9uZXRfZnJlZShub2RlLT5uZXQpOw0KPiBAQCAtNTU3LDggKzU1OCwxNSBAQCBzdGF0aWMg Ym9vbCBpbml0X2Zyb21fc3RvcmFnZShzdHJ1Y3QgbWVzaF9jb25maWdfbm9kZSAqZGJfbm9kZSwN Cj4gIA0KPiAgCWxfcXVldWVfZm9yZWFjaChkYl9ub2RlLT5uZXRrZXlzLCBzZXRfbmV0X2tleSwg bm9kZSk7DQo+ICANCj4gLQlpZiAoZGJfbm9kZS0+YXBwa2V5cykNCj4gLQkJbF9xdWV1ZV9mb3Jl YWNoKGRiX25vZGUtPmFwcGtleXMsIHNldF9hcHBrZXksIG5vZGUpOw0KPiArCWxfcXVldWVfZm9y ZWFjaChkYl9ub2RlLT5hcHBrZXlzLCBzZXRfYXBwa2V5LCBub2RlKTsNCj4gKw0KPiArCXdoaWxl IChsX3F1ZXVlX2xlbmd0aChkYl9ub2RlLT5wYWdlcykpIHsNCj4gKwkJc3RydWN0IG1lc2hfY29u ZmlnX2NvbXBfcGFnZSAqcGFnZTsNCj4gKw0KPiArCQkvKiBNb3ZlIHRoZSBjb21wb3NpdGlvbiBw YWdlcyB0byB0aGUgbm9kZSBzdHJ1Y3QgKi8NCj4gKwkJcGFnZSA9IGxfcXVldWVfcG9wX2hlYWQo ZGJfbm9kZS0+cGFnZXMpOw0KPiArCQlsX3F1ZXVlX3B1c2hfdGFpbChub2RlLT5wYWdlcywgcGFn ZSk7DQo+ICsJfQ0KPiAgDQo+ICAJbWVzaF9uZXRfc2V0X3NlcV9udW0obm9kZS0+bmV0LCBub2Rl LT5zZXFfbnVtYmVyKTsNCj4gIAltZXNoX25ldF9zZXRfZGVmYXVsdF90dGwobm9kZS0+bmV0LCBu b2RlLT50dGwpOw0KPiBAQCAtODc3LDcgKzg4NSw4IEBAIHVpbnQ4X3Qgbm9kZV9mcmllbmRfbW9k ZV9nZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSkNCj4gIAlyZXR1cm4gbm9kZS0+ZnJpZW5kOw0K PiAgfQ0KPiAgDQo+IC11aW50MTZfdCBub2RlX2dlbmVyYXRlX2NvbXAoc3RydWN0IG1lc2hfbm9k ZSAqbm9kZSwgdWludDhfdCAqYnVmLCB1aW50MTZfdCBzeikNCj4gK3N0YXRpYyB1aW50MTZfdCBu b2RlX2dlbmVyYXRlX2NvbXAoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDhfdCAqYnVmLA0K PiArCQkJCQkJCQl1aW50MTZfdCBzeikNCj4gIHsNCj4gIAl1aW50MTZfdCBuLCBmZWF0dXJlczsN Cj4gIAl1aW50MTZfdCBudW1fZWxlID0gMDsNCj4gQEAgLTk5MSw2ICsxMDAwLDc4IEBAIGVsZW1l bnRfZG9uZToNCj4gIAlyZXR1cm4gbjsNCj4gIH0NCj4gIA0KPiArc3RhdGljIGJvb2wgbWF0Y2hf cGFnZShjb25zdCB2b2lkICphLCBjb25zdCB2b2lkICpiKQ0KPiArew0KPiArCWNvbnN0IHN0cnVj dCBtZXNoX2NvbmZpZ19jb21wX3BhZ2UgKnBhZ2UgPSBhOw0KPiArCXVpbnQ4X3QgcGFnZV9udW0g PSBMX1BUUl9UT19VSU5UKGIpOw0KPiArDQo+ICsJcmV0dXJuIHBhZ2UtPnBhZ2VfbnVtID09IHBh Z2VfbnVtOw0KPiArfQ0KPiArDQo+ICtib29sIG5vZGVfc2V0X2NvbXAoc3RydWN0IG1lc2hfbm9k ZSAqbm9kZSwgdWludDhfdCBwYWdlX251bSwNCj4gKwkJCQkJY29uc3QgdWludDhfdCAqZGF0YSwg dWludDE2X3QgbGVuKQ0KPiArew0KPiArCXN0cnVjdCBtZXNoX2NvbmZpZ19jb21wX3BhZ2UgKnBh Z2U7DQo+ICsNCj4gKwlpZiAoIW5vZGUgfHwgbGVuIDwgTUlOX0NPTVBfU0laRSkNCj4gKwkJcmV0 dXJuIGZhbHNlOw0KPiArDQo+ICsJcGFnZSA9IGxfcXVldWVfcmVtb3ZlX2lmKG5vZGUtPnBhZ2Vz LCBtYXRjaF9wYWdlLA0KPiArCQkJCQkJTF9VSU5UX1RPX1BUUihwYWdlX251bSkpOw0KPiArDQo+ ICsJbF9mcmVlKHBhZ2UpOw0KPiArDQo+ICsJcGFnZSA9IGxfbWFsbG9jKHNpemVvZihzdHJ1Y3Qg bWVzaF9jb25maWdfY29tcF9wYWdlKSArIGxlbik7DQo+ICsJcGFnZS0+bGVuID0gbGVuOw0KPiAr CXBhZ2UtPnBhZ2VfbnVtID0gcGFnZV9udW07DQo+ICsJbWVtY3B5KHBhZ2UtPmRhdGEsIGRhdGEs IGxlbik7DQo+ICsJbF9xdWV1ZV9wdXNoX3RhaWwobm9kZS0+cGFnZXMsIHBhZ2UpOw0KPiArDQo+ ICsJbWVzaF9jb25maWdfY29tcF9wYWdlX2FkZChub2RlLT5jZmcsIHBhZ2VfbnVtLCBwYWdlLT5k YXRhLCBsZW4pOw0KPiArDQo+ICsJcmV0dXJuIHRydWU7DQo+ICt9DQo+ICsNCj4gK2NvbnN0IHVp bnQ4X3QgKm5vZGVfZ2V0X2NvbXAoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDhfdCBwYWdl X251bSwNCj4gKwkJCQkJCQkJdWludDE2X3QgKmxlbikNCj4gK3sNCj4gKwlzdHJ1Y3QgbWVzaF9j b25maWdfY29tcF9wYWdlICpwYWdlID0gTlVMTDsNCj4gKw0KPiArCWlmIChub2RlKQ0KPiArCQlw YWdlID0gbF9xdWV1ZV9maW5kKG5vZGUtPnBhZ2VzLCBtYXRjaF9wYWdlLA0KPiArCQkJCQkJTF9V SU5UX1RPX1BUUihwYWdlX251bSkpOw0KPiArDQo+ICsJaWYgKCFwYWdlKSB7DQo+ICsJCSpsZW4g PSAwOw0KPiArCQlyZXR1cm4gTlVMTDsNCj4gKwl9DQo+ICsNCj4gKwkqbGVuID0gcGFnZS0+bGVu Ow0KPiArCXJldHVybiBwYWdlLT5kYXRhOw0KPiArfQ0KPiArDQo+ICtib29sIG5vZGVfcmVwbGFj ZV9jb21wKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgcmV0aXJlLCB1aW50OF90IHdp dGgpDQo+ICt7DQo+ICsJc3RydWN0IG1lc2hfY29uZmlnX2NvbXBfcGFnZSAqb2xkX3BhZ2UsICpr ZWVwOw0KPiArDQo+ICsJaWYgKCFub2RlKQ0KPiArCQlyZXR1cm4gZmFsc2U7DQo+ICsNCj4gKwlr ZWVwID0gbF9xdWV1ZV9maW5kKG5vZGUtPnBhZ2VzLCBtYXRjaF9wYWdlLCBMX1VJTlRfVE9fUFRS KHdpdGgpKTsNCj4gKw0KPiArCWlmICgha2VlcCkNCj4gKwkJcmV0dXJuIGZhbHNlOw0KPiArDQo+ ICsJb2xkX3BhZ2UgPSBsX3F1ZXVlX3JlbW92ZV9pZihub2RlLT5wYWdlcywgbWF0Y2hfcGFnZSwN Cj4gKwkJCQkJCQlMX1VJTlRfVE9fUFRSKHJldGlyZSkpOw0KPiArDQo+ICsJbF9mcmVlKG9sZF9w YWdlKTsNCj4gKwlrZWVwLT5wYWdlX251bSA9IHJldGlyZTsNCj4gKwltZXNoX2NvbmZpZ19jb21w X3BhZ2VfbXYobm9kZS0+Y2ZnLCB3aXRoLCByZXRpcmUpOw0KPiArDQo+ICsJcmV0dXJuIHRydWU7 DQo+ICt9DQo+ICsNCj4gIHN0YXRpYyB2b2lkIGF0dGFjaF9pbyh2b2lkICphLCB2b2lkICpiKQ0K PiAgew0KPiAgCXN0cnVjdCBtZXNoX25vZGUgKm5vZGUgPSBhOw0KPiBAQCAtMTQ4NiwyNyArMTU2 NywzMCBAQCBzdGF0aWMgdm9pZCB1cGRhdGVfbW9kZWxfb3B0aW9ucyhzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlLA0KPiAgDQo+ICBzdGF0aWMgYm9vbCBjaGVja19yZXFfbm9kZShzdHJ1Y3QgbWFuYWdl ZF9vYmpfcmVxdWVzdCAqcmVxKQ0KPiAgew0KPiAtCXVpbnQ4X3Qgbm9kZV9jb21wW01BWF9NU0df TEVOIC0gMl07DQo+IC0JdWludDhfdCBhdHRhY2hfY29tcFtNQVhfTVNHX0xFTiAtIDJdOw0KPiAt CXVpbnQxNl90IG9mZnNldCA9IDEwOw0KPiAtCXVpbnQxNl90IG5vZGVfbGVuID0gbm9kZV9nZW5l cmF0ZV9jb21wKHJlcS0+bm9kZSwgbm9kZV9jb21wLA0KPiAtCQkJCQkJCXNpemVvZihub2RlX2Nv bXApKTsNCj4gKwlzdHJ1Y3QgbWVzaF9ub2RlICpub2RlOw0KPiArCWNvbnN0IGludCBvZmZzZXQg PSA4Ow0KPiArCXVpbnQxNl90IG5vZGVfbGVuLCBsZW47DQo+ICsJdWludDhfdCBjb21wW01BWF9N U0dfTEVOIC0gMl07DQo+ICsJY29uc3QgdWludDhfdCAqbm9kZV9jb21wOw0KPiAgDQo+IC0JaWYg KCFub2RlX2xlbikNCj4gLQkJcmV0dXJuIGZhbHNlOw0KPiArCWlmIChyZXEtPnR5cGUgPT0gUkVR VUVTVF9UWVBFX0FUVEFDSCkNCj4gKwkJbm9kZSA9IHJlcS0+YXR0YWNoOw0KPiArCWVsc2UNCj4g KwkJbm9kZSA9IHJlcS0+bm9kZTsNCj4gIA0KPiAtCWlmIChyZXEtPnR5cGUgPT0gUkVRVUVTVF9U WVBFX0FUVEFDSCkgew0KPiAtCQl1aW50MTZfdCBhdHRhY2hfbGVuID0gbm9kZV9nZW5lcmF0ZV9j b21wKHJlcS0+YXR0YWNoLA0KPiAtCQkJCQlhdHRhY2hfY29tcCwgc2l6ZW9mKGF0dGFjaF9jb21w KSk7DQo+ICsJbm9kZV9jb21wID0gbm9kZV9nZXRfY29tcChub2RlLCAwLCAmbm9kZV9sZW4pOw0K PiArCWxlbiA9IG5vZGVfZ2VuZXJhdGVfY29tcChub2RlLCBjb21wLCBzaXplb2YoY29tcCkpOw0K PiAgDQo+IC0JCS8qIFZlcmlmeSBvbmx5IGVsZW1lbnQvbW9kZWxzIGNvbXBvc2l0aW9uICovDQo+ IC0JCWlmIChub2RlX2xlbiAhPSBhdHRhY2hfbGVuIHx8DQo+IC0JCQkJbWVtY21wKCZub2RlX2Nv bXBbb2Zmc2V0XSwgJmF0dGFjaF9jb21wW29mZnNldF0sDQo+IC0JCQkJCQkJbm9kZV9sZW4gLSBv ZmZzZXQpKSB7DQo+IC0JCQlsX2RlYnVnKCJGYWlsZWQgdG8gdmVyaWZ5IGFwcCdzIGNvbXBvc2l0 aW9uIGRhdGEiKTsNCj4gLQkJCXJldHVybiBmYWxzZTsNCj4gLQkJfQ0KPiAtCX0NCj4gKwkvKiBJ ZiBubyBwYWdlIDAgZXhpc3RzLCBzYXZlIGl0IGFuZCByZXR1cm4gKi8NCj4gKwlpZiAocmVxLT50 eXBlICE9IFJFUVVFU1RfVFlQRV9BVFRBQ0ggfHwgIW5vZGVfbGVuIHx8ICFub2RlX2NvbXApDQo+ ICsJCXJldHVybiBub2RlX3NldF9jb21wKG5vZGUsIDAsIGNvbXAsIGxlbik7DQo+ICsNCj4gKwlp ZiAobm9kZV9sZW4gIT0gbGVuIHx8IG1lbWNtcCgmbm9kZV9jb21wW29mZnNldF0sICZjb21wW29m ZnNldF0sDQo+ICsJCQkJCQkJbm9kZV9sZW4gLSBvZmZzZXQpKQ0KPiArCQlyZXR1cm4gZmFsc2U7 DQo+ICsNCj4gKwllbHNlIGlmIChtZW1jbXAobm9kZV9jb21wLCBjb21wLCBub2RlX2xlbikpDQo+ ICsJCXJldHVybiBub2RlX3NldF9jb21wKG5vZGUsIDAsIGNvbXAsIGxlbik7DQo+ICANCj4gIAly ZXR1cm4gdHJ1ZTsNCj4gIH0NCj4gZGlmZiAtLWdpdCBhL21lc2gvbm9kZS5oIGIvbWVzaC9ub2Rl LmgNCj4gaW5kZXggNmM0NTQyYTc4Li5kZjA1ODQ1OGEgMTAwNjQ0DQo+IC0tLSBhL21lc2gvbm9k ZS5oDQo+ICsrKyBiL21lc2gvbm9kZS5oDQo+IEBAIC02Myw3ICs2MywxMSBAQCBzdHJ1Y3QgbF9x dWV1ZSAqbm9kZV9nZXRfZWxlbWVudF9tb2RlbHMoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWlu dDhfdCBlbGVfaWR4LA0KPiAgdWludDE2X3Qgbm9kZV9nZXRfY3JwbChzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlKTsNCj4gIGJvb2wgbm9kZV9pbml0X2Zyb21fc3RvcmFnZShzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlLCBjb25zdCB1aW50OF90IHV1aWRbMTZdLA0KPiAgCQkJCQlzdHJ1Y3QgbWVzaF9jb25m aWdfbm9kZSAqZGJfbm9kZSk7DQo+IC11aW50MTZfdCBub2RlX2dlbmVyYXRlX2NvbXAoc3RydWN0 IG1lc2hfbm9kZSAqbm9kZSwgdWludDhfdCAqYnVmLCB1aW50MTZfdCBzeik7DQo+ICtjb25zdCB1 aW50OF90ICpub2RlX2dldF9jb21wKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgcGFn ZV9udW0sDQo+ICsJCQkJCQkJCXVpbnQxNl90ICpsZW4pOw0KPiArYm9vbCBub2RlX3NldF9jb21w KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgcGFnZV9udW0sDQo+ICsJCQkJCWNvbnN0 IHVpbnQ4X3QgKmRhdGEsIHVpbnQxNl90IGxlbik7DQo+ICtib29sIG5vZGVfcmVwbGFjZV9jb21w KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgcmV0aXJlLCB1aW50OF90IHdpdGgpOw0K PiAgdWludDhfdCBub2RlX2xwbl9tb2RlX2dldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlKTsNCj4g IGJvb2wgbm9kZV9yZWxheV9tb2RlX3NldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCBib29sIGVu YWJsZSwgdWludDhfdCBjbnQsDQo+ICAJCQkJCQkJdWludDE2X3QgaW50ZXJ2YWwpOw0K Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0EhdB/QPBl8hSQEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 20:27:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id iCiaBfQPBl/tCwEA0J78UA (envelope-from ); Wed, 08 Jul 2020 20:27:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 327E6A1E22; Wed, 8 Jul 2020 20:26:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbgGHS0s (ORCPT + 1 other); Wed, 8 Jul 2020 14:26:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:44932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbgGHS0r (ORCPT ); Wed, 8 Jul 2020 14:26:47 -0400 Received: from embeddedor (unknown [201.162.240.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 261E1206F6; Wed, 8 Jul 2020 18:26:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594232806; bh=P4cXOjS7XD3EKQggGz2XzeV426YqZpcn9AX6M313xkw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LJXCmf2cjDCxZnRljodId9rJBikTsGOMlIjDlRQ7f8DigAdE9Rv0nsNrc+0HPNGQb G5yItZnEO9a3TUHzTYDgwPvuqvCjq3zwH+eYbSo4ulPMzrgKgETloyCCw0BWjhcZZw 3sdrN/xrED/RSiWoeF04gTc0HQPYmi9cCyxkjFzA= Date: Wed, 8 Jul 2020 13:32:15 -0500 From: "Gustavo A. R. Silva" To: Marcel Holtmann Cc: Johan Hedberg , "David S. Miller" , Jakub Kicinski , linux-bluetooth , kernel list , netdev@vger.kernel.org Subject: Re: [PATCH][next] Bluetooth: Use fallthrough pseudo-keyword Message-ID: <20200708183215.GI11533@embeddedor> References: <20200707203541.GA8972@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 327E6A1E22 X-Rspamd-UID: 229c61 On Wed, Jul 08, 2020 at 06:49:39AM +0200, Marcel Holtmann wrote: > Hi Gustavo, > > > Replace the existing /* fall through */ comments and its variants with > > the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary > > fall-through markings when it is the case. > > > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through > > > > Signed-off-by: Gustavo A. R. Silva > > --- > > drivers/bluetooth/bcm203x.c | 2 +- > > drivers/bluetooth/bluecard_cs.c | 2 -- > > drivers/bluetooth/hci_ll.c | 2 +- > > drivers/bluetooth/hci_qca.c | 8 +------- > > net/bluetooth/hci_event.c | 4 ++-- > > net/bluetooth/hci_sock.c | 3 +-- > > net/bluetooth/l2cap_core.c | 19 +++++++++---------- > > net/bluetooth/l2cap_sock.c | 4 ++-- > > net/bluetooth/mgmt.c | 4 ++-- > > net/bluetooth/rfcomm/core.c | 2 +- > > net/bluetooth/rfcomm/sock.c | 2 +- > > net/bluetooth/smp.c | 2 +- > > 12 files changed, 22 insertions(+), 32 deletions(-) > > can we split these a little bit between drivers, core and rfcomm. Thanks. > Sure thing, no problem. I'll split this up and send again. Thanks -- Gustavo Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0Bj4LdkoBl/adAEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 22:13:13 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2BQ8LNkoBl9SXAEADc0bRg (envelope-from ); Wed, 08 Jul 2020 22:13:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EE22E52AF2; Wed, 8 Jul 2020 22:13:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726112AbgGHUM4 (ORCPT + 1 other); Wed, 8 Jul 2020 16:12:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:34274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725964AbgGHUMz (ORCPT ); Wed, 8 Jul 2020 16:12:55 -0400 Received: from embeddedor (unknown [201.162.240.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A443206F6; Wed, 8 Jul 2020 20:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594239175; bh=/oZNYXkUuncpQ7MRSVjnoq+faFRhFQzcs8SweMSBbF4=; h=Date:From:To:Cc:Subject:From; b=nN2+GlrJm8Tb/736hM2zeg5pf296zZmUVfvcVTzfzAvNoghyJqxpP093aN8qPltxz sqZ4xJVJJelAGPbOUwgkFzEtv3VnYfgrQ2lmIyenqAYSx5bEz8uZGV2mZO9fa3JZ5+ v6R5fPgSO5lT9J5z24afsP234CrKEijEGLMTG+ms= Date: Wed, 8 Jul 2020 15:18:23 -0500 From: "Gustavo A. R. Silva" To: Marcel Holtmann , Johan Hedberg , "David S. Miller" , Jakub Kicinski Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] Bluetooth: core: Use fallthrough pseudo-keyword Message-ID: <20200708201823.GA400@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: EE22E52AF2 X-Rspamd-UID: 76e0c1 Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva --- net/bluetooth/hci_event.c | 4 ++-- net/bluetooth/hci_sock.c | 3 +-- net/bluetooth/l2cap_core.c | 19 +++++++++---------- net/bluetooth/l2cap_sock.c | 4 ++-- net/bluetooth/mgmt.c | 4 ++-- net/bluetooth/smp.c | 2 +- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 03a0759f2fc2..94f046f08301 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2825,7 +2825,7 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) case HCI_AUTO_CONN_LINK_LOSS: if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT) break; - /* Fall through */ + fallthrough; case HCI_AUTO_CONN_DIRECT: case HCI_AUTO_CONN_ALWAYS: @@ -4320,7 +4320,7 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev, if (hci_setup_sync(conn, conn->link->handle)) goto unlock; } - /* fall through */ + fallthrough; default: conn->state = BT_CLOSED; diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index d5627967fc25..fad842750442 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -443,8 +443,7 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event) case HCI_DEV_SETUP: if (hdev->manufacturer == 0xffff) return NULL; - - /* fall through */ + fallthrough; case HCI_DEV_UP: skb = bt_skb_alloc(HCI_MON_INDEX_INFO_SIZE, GFP_ATOMIC); diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 35d2bc569a2d..ade83e224567 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -666,8 +666,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err) l2cap_seq_list_free(&chan->srej_list); l2cap_seq_list_free(&chan->retrans_list); - - /* fall through */ + fallthrough; case L2CAP_MODE_STREAMING: skb_queue_purge(&chan->tx_q); @@ -872,7 +871,8 @@ static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan) else return HCI_AT_NO_BONDING; } - /* fall through */ + fallthrough; + default: switch (chan->sec_level) { case BT_SECURITY_HIGH: @@ -2983,8 +2983,7 @@ static void l2cap_tx_state_wait_f(struct l2cap_chan *chan, break; case L2CAP_EV_RECV_REQSEQ_AND_FBIT: l2cap_process_reqseq(chan, control->reqseq); - - /* Fall through */ + fallthrough; case L2CAP_EV_RECV_FBIT: if (control && control->final) { @@ -3311,7 +3310,7 @@ static inline __u8 l2cap_select_mode(__u8 mode, __u16 remote_feat_mask) case L2CAP_MODE_ERTM: if (l2cap_mode_supported(mode, remote_feat_mask)) return mode; - /* fall through */ + fallthrough; default: return L2CAP_MODE_BASIC; } @@ -3447,7 +3446,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data, size_t data if (__l2cap_efs_supported(chan->conn)) set_bit(FLAG_EFS_ENABLE, &chan->flags); - /* fall through */ + fallthrough; default: chan->mode = l2cap_select_mode(rfc.mode, chan->conn->feat_mask); break; @@ -4539,7 +4538,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, goto done; break; } - /* fall through */ + fallthrough; default: l2cap_chan_set_err(chan, ECONNRESET); @@ -7719,7 +7718,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) conn->mtu = hcon->hdev->le_mtu; break; } - /* fall through */ + fallthrough; default: conn->mtu = hcon->hdev->acl_mtu; break; @@ -7841,7 +7840,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, case L2CAP_MODE_STREAMING: if (!disable_ertm) break; - /* fall through */ + fallthrough; default: err = -EOPNOTSUPP; goto done; diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index a995d2c51fa7..738a5345fa21 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -284,7 +284,7 @@ static int l2cap_sock_listen(struct socket *sock, int backlog) case L2CAP_MODE_STREAMING: if (!disable_ertm) break; - /* fall through */ + fallthrough; default: err = -EOPNOTSUPP; goto done; @@ -760,7 +760,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, case L2CAP_MODE_STREAMING: if (!disable_ertm) break; - /* fall through */ + fallthrough; default: err = -EINVAL; break; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index d29da80e38fe..686ef4792831 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -4525,7 +4525,7 @@ static bool discovery_type_is_valid(struct hci_dev *hdev, uint8_t type, *mgmt_status = mgmt_le_support(hdev); if (*mgmt_status) return false; - /* Intentional fall-through */ + fallthrough; case DISCOV_TYPE_BREDR: *mgmt_status = mgmt_bredr_support(hdev); if (*mgmt_status) @@ -5901,7 +5901,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, case MGMT_LTK_P256_DEBUG: authenticated = 0x00; type = SMP_LTK_P256_DEBUG; - /* fall through */ + fallthrough; default: continue; } diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 684e60e1915c..21f5e6d9ea95 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -1654,7 +1654,7 @@ int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey) memset(smp->tk, 0, sizeof(smp->tk)); BT_DBG("PassKey: %d", value); put_unaligned_le32(value, smp->tk); - /* Fall Through */ + fallthrough; case MGMT_OP_USER_CONFIRM_REPLY: set_bit(SMP_FLAG_TK_VALID, &smp->flags); break; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sNPFAXsqBl8rxAEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 22:20:11 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id SPgoAHsqBl/RZAEAlp8NpQ (envelope-from ); Wed, 08 Jul 2020 22:20:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 41309527CF; Wed, 8 Jul 2020 22:20:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726437AbgGHUTh (ORCPT + 1 other); Wed, 8 Jul 2020 16:19:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:36152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726122AbgGHUTh (ORCPT ); Wed, 8 Jul 2020 16:19:37 -0400 Received: from embeddedor (unknown [201.162.240.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D902620672; Wed, 8 Jul 2020 20:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594239576; bh=S84KvemR4M6dpgIi8v4v9eUz3FpWojXbsMcXjZdI0HE=; h=Date:From:To:Cc:Subject:From; b=weUr/blubCR5NpqUVcA2gNZD7HfiGJu4ukvmAQrs8BO7LOjwgQRhyYwztWJWORaxs SOZspislB67pt+1oKgI+XZ9Agd2Gus49p6dxI+EzcZXPITwrwU3GNAQuuTz5K5HSTR 6OVMfB+MhqXDHa11OPQRt3zeYxH3ocGNZmkIRbqE= Date: Wed, 8 Jul 2020 15:25:05 -0500 From: "Gustavo A. R. Silva" To: Marcel Holtmann , Johan Hedberg , "David S. Miller" , Jakub Kicinski Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] Bluetooth: RFCOMM: Use fallthrough pseudo-keyword Message-ID: <20200708202505.GA1733@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 41309527CF X-Rspamd-UID: b08cd7 Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva --- net/bluetooth/rfcomm/core.c | 2 +- net/bluetooth/rfcomm/sock.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 2e20af317cea..f2bacb464ccf 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c @@ -479,7 +479,7 @@ static int __rfcomm_dlc_close(struct rfcomm_dlc *d, int err) /* if closing a dlc in a session that hasn't been started, * just close and unlink the dlc */ - /* fall through */ + fallthrough; default: rfcomm_dlc_clear_timer(d); diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index df14eebe80da..0afc4bc5ab41 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -218,7 +218,7 @@ static void __rfcomm_sock_close(struct sock *sk) case BT_CONFIG: case BT_CONNECTED: rfcomm_dlc_close(d, 0); - /* fall through */ + fallthrough; default: sock_set_flag(sk, SOCK_ZAPPED); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EPpPKM4qBl8rxAEAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 22:21:34 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SF1DJs4qBl9G1gAAlScrYA (envelope-from ); Wed, 08 Jul 2020 22:21:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A4F6552EEA; Wed, 8 Jul 2020 22:21:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726044AbgGHUVW (ORCPT + 1 other); Wed, 8 Jul 2020 16:21:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:36490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725915AbgGHUVW (ORCPT ); Wed, 8 Jul 2020 16:21:22 -0400 Received: from embeddedor (unknown [201.162.240.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E9AC206DF; Wed, 8 Jul 2020 20:21:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594239681; bh=UeCNSUIXhUf07hExa3mxpd08ul/F7bP7XImjtU6s0mQ=; h=Date:From:To:Cc:Subject:From; b=qpT21zjyUpZRBes6dwkVF7VRpNo7GVmRVSB6Z8LaZTi2JEQxIMzHw64KWRNqB7U7u ltBidmEtNbtwkVXLYf0V/xmUZ+JXRstbLw5hxbqCkpOSgjsqu9XrdlhlkZdCgps4Pu BGa5rraSVTfspfi+I7fjZMP4d9Tkx33lbeEij7ls= Date: Wed, 8 Jul 2020 15:26:50 -0500 From: "Gustavo A. R. Silva" To: Marcel Holtmann , Johan Hedberg Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] Bluetooth: Use fallthrough pseudo-keyword Message-ID: <20200708202650.GA3866@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: A4F6552EEA X-Rspamd-UID: bb12d5 Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva --- drivers/bluetooth/bcm203x.c | 2 +- drivers/bluetooth/bluecard_cs.c | 2 -- drivers/bluetooth/hci_ll.c | 2 +- drivers/bluetooth/hci_qca.c | 8 +------- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c index 3b176257b993..e667933c3d70 100644 --- a/drivers/bluetooth/bcm203x.c +++ b/drivers/bluetooth/bcm203x.c @@ -106,7 +106,7 @@ static void bcm203x_complete(struct urb *urb) } data->state = BCM203X_LOAD_FIRMWARE; - /* fall through */ + fallthrough; case BCM203X_LOAD_FIRMWARE: if (data->fw_sent == data->fw_size) { usb_fill_int_urb(urb, udev, usb_rcvintpipe(udev, BCM203X_IN_EP), diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index cc6e56223656..36eabf61717f 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -295,7 +295,6 @@ static void bluecard_write_wakeup(struct bluecard_info *info) baud_reg = REG_CONTROL_BAUD_RATE_115200; break; case PKT_BAUD_RATE_57600: - /* Fall through... */ default: baud_reg = REG_CONTROL_BAUD_RATE_57600; break; @@ -585,7 +584,6 @@ static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud) hci_skb_pkt_type(skb) = PKT_BAUD_RATE_115200; break; case 57600: - /* Fall through... */ default: cmd[4] = 0x03; hci_skb_pkt_type(skb) = PKT_BAUD_RATE_57600; diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c index d9a4c6c691e0..8bfe024d1fcd 100644 --- a/drivers/bluetooth/hci_ll.c +++ b/drivers/bluetooth/hci_ll.c @@ -219,7 +219,7 @@ static void ll_device_want_to_wakeup(struct hci_uart *hu) * perfectly safe to always send one. */ BT_DBG("dual wake-up-indication"); - /* fall through */ + fallthrough; case HCILL_ASLEEP: /* acknowledge device wake up */ if (send_hcill_cmd(HCILL_WAKE_UP_ACK, hu) < 0) { diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 99d14c777105..7e395469ca4f 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -472,8 +472,6 @@ static void hci_ibs_tx_idle_timeout(struct timer_list *t) case HCI_IBS_TX_ASLEEP: case HCI_IBS_TX_WAKING: - /* Fall through */ - default: BT_ERR("Spurious timeout tx state %d", qca->tx_ibs_state); break; @@ -516,8 +514,6 @@ static void hci_ibs_wake_retrans_timeout(struct timer_list *t) case HCI_IBS_TX_ASLEEP: case HCI_IBS_TX_AWAKE: - /* Fall through */ - default: BT_ERR("Spurious timeout tx state %d", qca->tx_ibs_state); break; @@ -835,8 +831,6 @@ static void device_woke_up(struct hci_uart *hu) break; case HCI_IBS_TX_ASLEEP: - /* Fall through */ - default: BT_ERR("Received HCI_IBS_WAKE_ACK in tx state %d", qca->tx_ibs_state); @@ -2072,7 +2066,7 @@ static int __maybe_unused qca_suspend(struct device *dev) switch (qca->tx_ibs_state) { case HCI_IBS_TX_WAKING: del_timer(&qca->wake_retrans_timer); - /* Fall through */ + fallthrough; case HCI_IBS_TX_AWAKE: del_timer(&qca->tx_idle_timer); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4J0TGVA3Bl+4jAAAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 23:14:56 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yKgVFVA3Bl/D5AAAlScrYA (envelope-from ); Wed, 08 Jul 2020 23:14:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C4E32A10B1; Wed, 8 Jul 2020 23:14:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726140AbgGHVOu (ORCPT + 1 other); Wed, 8 Jul 2020 17:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726122AbgGHVOu (ORCPT ); Wed, 8 Jul 2020 17:14:50 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 128BCC061A0B for ; Wed, 8 Jul 2020 14:14:50 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id a21so186235otq.8 for ; Wed, 08 Jul 2020 14:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=a8uXdX1ijQUFjAgU9Yg2R5ixp4s5oGR8LBnzH9CAzck=; b=rarHCj3WpsfYgsOnwhLlgUOtEbVV9t4cJkkn5f/NQHrnhzyu1SkP0ExKY7j/KehSNW 5+g/CitpqpuxmWutNiXyMbxHxTuYe4bL7kI9RuuGq9ceFA3XlKDJy7bTrY5s++fygn4m SmYYUjrtgfxJNasLhGfjWKxYWi9DA8qPFpyJMO6Mmy5rpiagsVwi4FunpGKiW2UcDi4U o7kNWtkNdsHR3snP+OQghcXBpl09N/OkewLlMW9H78Uo6mv9PdoHMXXW9IOe8Ph8+GQa NswQkBpKeA3n2k0lN6mkxq/B2UKtjpye/3mPiLxnnlQg/3JWFaouPIp691usHgwVVjoF oUhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=a8uXdX1ijQUFjAgU9Yg2R5ixp4s5oGR8LBnzH9CAzck=; b=Uh4QlDCiAYULSXgyRKK40/9tMOVMKjltGvTKSIU27e56m2dkjZs2oNL1jqDu2kPerF vGK+1zc+h6BrmRcFTqd3INOyHfKq37gMZSs+3k+c2fUZ09YgmrYPUYGOheCQgj85QuAl 9A2yaJdl/enQUCy21s0XXQtRLHXmI41zkCRLaJMP2PlHUqnoG/+ffj3IpRSEUBloA6W1 rdpK9e6RZLthqcJLF/dSZ1Lb5sdozinkYWNXoDj1dR0mVgT0QVxhEgx/KjgWk3TcwBv2 DmwdetiTIUSrwk3YHGgAUNgRMxZAOUYnRS/66dKlCZiZo9G9Sk/mgfwE5hV2dxNeMbXb MdBA== X-Gm-Message-State: AOAM531lKayHclTpv2+qjokpI+sJc5mFnqG83ys0GVBSyl8eKNQKJL4x whf1kTuNcGZZZceMzhvj8Hd7E/D8lPXHRNcd/QrWWbOa X-Google-Smtp-Source: ABdhPJwtGf50TB8UM41R1x+eyjgZXu8kHiZf7gnyiL29gVBaabjS0hHzGGB/lvAGzWRbYSdj4qracPozvkIT75hLres= X-Received: by 2002:a05:6830:1bd3:: with SMTP id v19mr48815673ota.91.1594242889325; Wed, 08 Jul 2020 14:14:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Luiz Augusto von Dentz Date: Wed, 8 Jul 2020 14:14:37 -0700 Message-ID: Subject: Re: Temporary device removal during discovery To: Andrey Batyiev Cc: Bastien Nocera , linux-bluetooth Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: C4E32A10B1 X-Rspamd-UID: 5701d9 Hi Andrey, On Wed, Jul 8, 2020 at 8:56 AM Andrey Batyiev wrote: > > Hi Bastien, everyone, > > I've made a patch to the bluez, so the temporary devices are routinely > purged based on their last_seen attribute. > > What do you think about such solution? > > Thanks, > Andrey > > > > diff --git a/src/adapter.c b/src/adapter.c > index 529002b02..101b03633 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -88,6 +88,7 @@ > > #define CONN_SCAN_TIMEOUT (3) > #define IDLE_DISCOV_TIMEOUT (5) > +#define TEMP_DEV_REAPER_INTERVAL (30) > #define TEMP_DEV_TIMEOUT (3 * 60) > #define BONDING_TIMEOUT (2 * 60) > > @@ -1491,18 +1492,18 @@ static gboolean remove_temp_devices(gpointer user_data) > > DBG("%s", adapter->path); > > - adapter->temp_devices_timeout = 0; > - > for (l = adapter->devices; l != NULL; l = next) { > struct btd_device *dev = l->data; > > next = g_slist_next(l); > > - if (device_is_temporary(dev) && !btd_device_is_connected(dev)) > + if (device_is_temporary(dev) && > + !btd_device_is_connected(dev) && > + device_last_seen_delta(dev) > TEMP_DEV_TIMEOUT) The delta logic might be a nice addition as a separate patch, it is more for detecting devices disappearing then actually cleanup during power off. > btd_adapter_remove_device(adapter, dev); > } > > - return FALSE; > + return TRUE; > } > > static void discovery_cleanup(struct btd_adapter *adapter) > @@ -1516,11 +1517,6 @@ static void discovery_cleanup(struct > btd_adapter *adapter) > adapter->discovery_idle_timeout = 0; > } > > - if (adapter->temp_devices_timeout > 0) { > - g_source_remove(adapter->temp_devices_timeout); > - adapter->temp_devices_timeout = 0; > - } > - > g_slist_free_full(adapter->discovery_found, > invalidate_rssi_and_tx_power); > adapter->discovery_found = NULL; > @@ -1536,9 +1532,6 @@ static void discovery_cleanup(struct btd_adapter *adapter) > if (device_is_temporary(dev) && !device_is_connectable(dev)) > btd_adapter_remove_device(adapter, dev); > } > - > - adapter->temp_devices_timeout = g_timeout_add_seconds(TEMP_DEV_TIMEOUT, > - remove_temp_devices, adapter); > } > > static void discovery_free(void *user_data) > @@ -2405,7 +2398,7 @@ static bool parse_pathloss(DBusMessageIter *value, > return true; > } > > -static bool parse_transport(DBusMessageIter *value, > +static bool parse_transport(DBusMessageIter *value, > struct discovery_filter *filter) > { > char *transport_str; > @@ -5362,6 +5355,11 @@ static void adapter_free(gpointer user_data) > adapter->passive_scan_timeout = 0; > } > > + if (adapter->temp_devices_timeout > 0) { > + g_source_remove(adapter->temp_devices_timeout); > + adapter->temp_devices_timeout = 0; > + } > + > if (adapter->load_ltks_timeout > 0) > g_source_remove(adapter->load_ltks_timeout); > > @@ -6343,6 +6341,9 @@ static struct btd_adapter *btd_adapter_new(uint16_t index) > > adapter->auths = g_queue_new(); > > + adapter->temp_devices_timeout = > g_timeout_add_seconds(TEMP_DEV_REAPER_INTERVAL, > + remove_temp_devices, adapter); > + > return btd_adapter_ref(adapter); > } > > diff --git a/src/device.c b/src/device.c > index 0deee2707..cebbabab2 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -4240,6 +4240,15 @@ void device_update_last_seen(struct btd_device > *device, uint8_t bdaddr_type) > device->le_seen = time(NULL); > } > > +time_t device_last_seen_delta(struct btd_device *device) > +{ > + const time_t now = time(NULL); > + const time_t bredr_time = now - device->bredr_seen; > + const time_t le_time = now - device->le_seen; > + > + return bredr_time < le_time ? bredr_time : le_time; > +} > + > /* It is possible that we have two device objects for the same device in > * case it has first been discovered over BR/EDR and has a private > * address when discovered over LE for the first time. In such a case we > diff --git a/src/device.h b/src/device.h > index cb8d884e8..75fd3ec60 100644 > --- a/src/device.h > +++ b/src/device.h > @@ -44,6 +44,7 @@ void device_update_addr(struct btd_device *device, > const bdaddr_t *bdaddr, > void device_set_bredr_support(struct btd_device *device); > void device_set_le_support(struct btd_device *device, uint8_t bdaddr_type); > void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type); > +time_t device_last_seen_delta(struct btd_device *device); > void device_merge_duplicate(struct btd_device *dev, struct btd_device *dup); > uint32_t btd_device_get_class(struct btd_device *device); > uint16_t btd_device_get_vendor(struct btd_device *device); -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EJWrGGA4Bl9TkAAAvsO+Rg (envelope-from ) for ; Wed, 08 Jul 2020 23:19:28 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id KMcrF2A4Bl9VpwEA0J78UA (envelope-from ); Wed, 08 Jul 2020 23:19:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9BA32A28DA; Wed, 8 Jul 2020 23:19:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726162AbgGHVTV (ORCPT + 1 other); Wed, 8 Jul 2020 17:19:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725903AbgGHVTV (ORCPT ); Wed, 8 Jul 2020 17:19:21 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CEEEC061A0B for ; Wed, 8 Jul 2020 14:19:21 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id a9so1946448oof.12 for ; Wed, 08 Jul 2020 14:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vl/FYHLqjZ2oHat94kKM5EVL+kYgEyeYQaLTsvpkkiM=; b=psoz/PTN+JYgWibcSoCuW877S4nSnLobm2bSv/zv3bQkm27nsuEwvNIRoQTFzVfiF8 wDkG2shYUrEL5slP3HWDse7WfIYdckg7vRZwgbBTiKiMifmiUMrdXEKLnS/VTzc8Hbll Ij88EXouyX50VAZAelAiAPNe7ysNUItv4SJ2GR+29M86yF917q3of+NUxjnr2RfTOB/S F0fim7+42hlX4qiG4UYJLR6qJTn1ncUWWQN9kZkVONaxO3tPytrUw2d/eoSl2lebl4W9 TRyZDE3v4+trS8Shj1uGPnMqsGccbfl09u/rYQyKyzqf9HA1HiRYbBLb/RiALJxcfN97 Dihg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vl/FYHLqjZ2oHat94kKM5EVL+kYgEyeYQaLTsvpkkiM=; b=O9iG/Kb8tQgD2D0yl74fkF34RUiOmGkvl8/T+DSDHDD1whDPFl8siIMzIC9GJ9zWbB s1mzsiK+WG8k+U2Esdmep2EZgeA2aF3Alv087wtK7Qp3ZT3MDx0+E/1fPthLRQR6zv8i TdpoIu7vqZruyc26HK+3VFhYXGGM20obSDcuOO4tcdfV7f2Vea6TOsO+9Y5vLdvr7t4E VPLej5PwXwZyD3f+OAMJQswgyp94KiIa+3/hzuRUCdv0RZBAk4ZlV4XoXs0+rpmTJFQI ERz47Y4AAIkmLejH5oHoxuJJjtBGRVydffhRA4VTDrtzw/YSgWNpOS31jOw1AupH2c4l TLvw== X-Gm-Message-State: AOAM5304oYr7OrMssXub0Nn4zxwEknpOw+mYTJxnj34Tw66XfOgbLFkC 7ACJQxEqyF6Knl00HYWcvYkjJNTjDdqH61SXaTWPDKp0 X-Google-Smtp-Source: ABdhPJwo0f42Wo1MWhRk7kTICUHp6qVvIjKupXpYDJ5QlF2fmRqc9qAGtUD12s7zlXvE9KmPmdzyKpH4+5/Cz5gU7O8= X-Received: by 2002:a4a:3405:: with SMTP id b5mr3402166ooa.9.1594243160894; Wed, 08 Jul 2020 14:19:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Luiz Augusto von Dentz Date: Wed, 8 Jul 2020 14:19:09 -0700 Message-ID: Subject: Re: Temporary device removal during discovery To: Andrey Batyiev Cc: Bastien Nocera , linux-bluetooth Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9BA32A28DA X-Rspamd-UID: f92ad3 Hi Andrey, Bastien, On Wed, Jul 8, 2020 at 2:14 PM Luiz Augusto von Dentz wrote: > > Hi Andrey, > > On Wed, Jul 8, 2020 at 8:56 AM Andrey Batyiev wrote: > > > > Hi Bastien, everyone, > > > > I've made a patch to the bluez, so the temporary devices are routinely > > purged based on their last_seen attribute. > > > > What do you think about such solution? I pushed a patch so than if the adapter is power off or unplugged it will immediately remove all temporary devices. > > Thanks, > > Andrey > > > > > > > > diff --git a/src/adapter.c b/src/adapter.c > > index 529002b02..101b03633 100644 > > --- a/src/adapter.c > > +++ b/src/adapter.c > > @@ -88,6 +88,7 @@ > > > > #define CONN_SCAN_TIMEOUT (3) > > #define IDLE_DISCOV_TIMEOUT (5) > > +#define TEMP_DEV_REAPER_INTERVAL (30) > > #define TEMP_DEV_TIMEOUT (3 * 60) > > #define BONDING_TIMEOUT (2 * 60) > > > > @@ -1491,18 +1492,18 @@ static gboolean remove_temp_devices(gpointer user_data) > > > > DBG("%s", adapter->path); > > > > - adapter->temp_devices_timeout = 0; > > - > > for (l = adapter->devices; l != NULL; l = next) { > > struct btd_device *dev = l->data; > > > > next = g_slist_next(l); > > > > - if (device_is_temporary(dev) && !btd_device_is_connected(dev)) > > + if (device_is_temporary(dev) && > > + !btd_device_is_connected(dev) && > > + device_last_seen_delta(dev) > TEMP_DEV_TIMEOUT) > > The delta logic might be a nice addition as a separate patch, it is > more for detecting devices disappearing then actually cleanup during > power off. > > > btd_adapter_remove_device(adapter, dev); > > } > > > > - return FALSE; > > + return TRUE; > > } > > > > static void discovery_cleanup(struct btd_adapter *adapter) > > @@ -1516,11 +1517,6 @@ static void discovery_cleanup(struct > > btd_adapter *adapter) > > adapter->discovery_idle_timeout = 0; > > } > > > > - if (adapter->temp_devices_timeout > 0) { > > - g_source_remove(adapter->temp_devices_timeout); > > - adapter->temp_devices_timeout = 0; > > - } > > - > > g_slist_free_full(adapter->discovery_found, > > invalidate_rssi_and_tx_power); > > adapter->discovery_found = NULL; > > @@ -1536,9 +1532,6 @@ static void discovery_cleanup(struct btd_adapter *adapter) > > if (device_is_temporary(dev) && !device_is_connectable(dev)) > > btd_adapter_remove_device(adapter, dev); > > } > > - > > - adapter->temp_devices_timeout = g_timeout_add_seconds(TEMP_DEV_TIMEOUT, > > - remove_temp_devices, adapter); > > } > > > > static void discovery_free(void *user_data) > > @@ -2405,7 +2398,7 @@ static bool parse_pathloss(DBusMessageIter *value, > > return true; > > } > > > > -static bool parse_transport(DBusMessageIter *value, > > +static bool parse_transport(DBusMessageIter *value, > > struct discovery_filter *filter) > > { > > char *transport_str; > > @@ -5362,6 +5355,11 @@ static void adapter_free(gpointer user_data) > > adapter->passive_scan_timeout = 0; > > } > > > > + if (adapter->temp_devices_timeout > 0) { > > + g_source_remove(adapter->temp_devices_timeout); > > + adapter->temp_devices_timeout = 0; > > + } > > + > > if (adapter->load_ltks_timeout > 0) > > g_source_remove(adapter->load_ltks_timeout); > > > > @@ -6343,6 +6341,9 @@ static struct btd_adapter *btd_adapter_new(uint16_t index) > > > > adapter->auths = g_queue_new(); > > > > + adapter->temp_devices_timeout = > > g_timeout_add_seconds(TEMP_DEV_REAPER_INTERVAL, > > + remove_temp_devices, adapter); > > + > > return btd_adapter_ref(adapter); > > } > > > > diff --git a/src/device.c b/src/device.c > > index 0deee2707..cebbabab2 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -4240,6 +4240,15 @@ void device_update_last_seen(struct btd_device > > *device, uint8_t bdaddr_type) > > device->le_seen = time(NULL); > > } > > > > +time_t device_last_seen_delta(struct btd_device *device) > > +{ > > + const time_t now = time(NULL); > > + const time_t bredr_time = now - device->bredr_seen; > > + const time_t le_time = now - device->le_seen; > > + > > + return bredr_time < le_time ? bredr_time : le_time; > > +} > > + > > /* It is possible that we have two device objects for the same device in > > * case it has first been discovered over BR/EDR and has a private > > * address when discovered over LE for the first time. In such a case we > > diff --git a/src/device.h b/src/device.h > > index cb8d884e8..75fd3ec60 100644 > > --- a/src/device.h > > +++ b/src/device.h > > @@ -44,6 +44,7 @@ void device_update_addr(struct btd_device *device, > > const bdaddr_t *bdaddr, > > void device_set_bredr_support(struct btd_device *device); > > void device_set_le_support(struct btd_device *device, uint8_t bdaddr_type); > > void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type); > > +time_t device_last_seen_delta(struct btd_device *device); > > void device_merge_duplicate(struct btd_device *dev, struct btd_device *dup); > > uint32_t btd_device_get_class(struct btd_device *device); > > uint16_t btd_device_get_vendor(struct btd_device *device); > > > > -- > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6Oo5OVVPBl+g2gAAvsO+Rg (envelope-from ) for ; Thu, 09 Jul 2020 00:57:25 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EGt1N1VPBl8jBwAADc0bRg (envelope-from ); Thu, 09 Jul 2020 00:57:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C40CFA1CDA; Thu, 9 Jul 2020 00:57:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726116AbgGHW5U (ORCPT + 1 other); Wed, 8 Jul 2020 18:57:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbgGHW5U (ORCPT ); Wed, 8 Jul 2020 18:57:20 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63FBFC061A0B for ; Wed, 8 Jul 2020 15:57:20 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id u185so139342pfu.1 for ; Wed, 08 Jul 2020 15:57:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c7QG6h/xauqnUlFYdVCs+cNioLLC9h6T11l5pPM7bJE=; b=qRziQvtmDkqWDt3vxVoG4szjKQ+s5SKmA4/R9nywha/B836KkdMPHi345QOkIHh8rC Pd7qnFiIF3UOV3QiB0ES7Gl89QDjC2rbcSZ6A0PWXsiX25sVicLyxvJd8/TwHl2M1SdW 9CI3XxeEHD+3fFDb/i7ctOSN6z/sGr2QJ1G7kgRqsWb8Ze2AIAlNwpEPeLo92Yv6Rxj1 LRLUu7frCf4xtrpr9U0dQP973Y/1D5asY5PEC3dlX0pKhcznHEv2ZJbuwEM6qU5i5ebq Jj+S7pGybVyb1oOtcsOsl0rdh7QoW4W1xG2w/YrSJsOejD1HMtsCFvkOYDjmCFkD7+1t soFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=c7QG6h/xauqnUlFYdVCs+cNioLLC9h6T11l5pPM7bJE=; b=e5WyGNC3o1Grtcc8TEoPW8WYz9eJGMOB3J4dIFtocGL/n+lhxHtk6QXughmak3VJMh Az3Z6lii/EBctAL5K8bC0puxIHQPK4/zKCxd6zI79RBux0OEZRseYRjoqXHeDFJSl353 czVALy06Vb90kz2gQKhzIOAKODk7P2cj3JqrnsA863AMCRnQxm3mTjskEnzkGu2KPPcF Dp2H+WXRo71K1CQJqcuI45wVSfyTAn6jvwXiFOF4jUg3FTzYJI1ztyr8Ou4k1HA4G90S 98A1jtl+qcL0Ot8EjkRjhPYG4VhbGax9LyLYLKjiEwoIPMm6oVFKNVjOUzybnSy/Lmxv AMTw== X-Gm-Message-State: AOAM5318G21TgjSw/TiKYNokwknwUUN/0Vbofho90QBVbfOUUNzoRu9r 0y2tv0hNhZrNQOWBAv0UWyWseGgyUu5IsOcjVnA= X-Google-Smtp-Source: ABdhPJy9f74uSOnL6svH7hpkPKQBliOvujsZbmJVbsU4mXfkJFK5Yd1ulCLfkaG6eGfJmHYnTUThthsMleZRfRjpD48= X-Received: by 2002:a62:4ec8:: with SMTP id c191mr20506953pfb.15.1594249039873; Wed, 08 Jul 2020 15:57:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Batyiev Date: Thu, 9 Jul 2020 01:57:06 +0300 Message-ID: Subject: Re: Temporary device removal during discovery To: Luiz Augusto von Dentz Cc: Bastien Nocera , linux-bluetooth Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: C40CFA1CDA X-Rspamd-UID: b7cb33 Hi Luiz, On Thu, Jul 9, 2020 at 12:14 AM Luiz Augusto von Dentz wrote: > The delta logic might be a nice addition as a separate patch, it is > more for detecting devices disappearing then actually cleanup during > power off. No-no, it's not about adapter powering off. I meant that (external) devices never disappear from the bluez device list during the discovery, even if the (external) devices are turned off (i.e. they should be purged by bluez). So: - bluez is central - bluez is discovering - peripheral appear for a moment, than disappear (i.e. peripheral would be turned off) - bluez would not remove device from the list (at least until discovery is stopped) Use case: - bluez is monitoring environment (discovering literally forever) - peripherals are brought in and out of bluez visibility range - bluez list of visible devices grows infinitely and causes problems (hundreds of devices) Thanks, Andrey Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oCikH1FhBl+wkAEAvsO+Rg (envelope-from ) for ; Thu, 09 Jul 2020 02:14:09 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id oBnxHVFhBl8DkAEAlScrYA (envelope-from ); Thu, 09 Jul 2020 02:14:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 393AD52C05; Thu, 9 Jul 2020 02:14:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726228AbgGIAOD (ORCPT + 1 other); Wed, 8 Jul 2020 20:14:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725848AbgGIAOD (ORCPT ); Wed, 8 Jul 2020 20:14:03 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D15BAC061A0B for ; Wed, 8 Jul 2020 17:14:02 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id l63so435361oih.13 for ; Wed, 08 Jul 2020 17:14:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DAy6fpR5/xZbQxxlH57PWAcHB2SkdiT0qmgOwdkwU3M=; b=Vo0AD9F2JCLgzg51iFjf4CjdrlnaKjCfb72swb5t8LB83DSXRI2OQfip1ztqiVOtWp h+pCVqeuc8ogG0Bp72fU+bZfCUhMFUAmu0mYbjKlsX03oLT/Y2xxfu2dmclgE3cqoNqd XCagqhQYHGo02BryRIysoVGGab2af3B/m0R+5f8VpUd1HwKL5AFUFQSYKbLsl09NbBle RSXBpGHpAEWu/O5e5mbet9WxRxdhFBV0S/g9fyqOPna04xAlJk3HTD7EQCrBvqTiuJff sUwaBWHI5PMExnWQISzgs/lyJ++3z9mhcz2j4GPNqWb3EW4ASpHy+0n6WUhtRbtu4mt7 RlJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DAy6fpR5/xZbQxxlH57PWAcHB2SkdiT0qmgOwdkwU3M=; b=FWsz6WwVow9r8ZoTuabfen0yVsa0Y9dw0IqJPiuugjnKvDvpEkRTFrNUB99KgO18Ps 6z4W3Yp9/PLJu1DkaXRLwrYn3b9H6nhwZ/sN5P5J49RkdwG1cX4bxbuAerCj5JRirwha GNeEQ5SlmultyZry9bTtC+UOdHyMFSe/bpUDvvDdfWFTwJ2WqU3jNzQip34x0fNC+tX8 eiRMuQYqnZibQlqrcYICg9rOJHwHrWAmvgIeCLjJsEYzoXvsVXD7o6buYYIpPTs6MmaE rbBN4GTK18zNst0gAJmbTKCu9Elfh6Re4IIi/0lIww2vMCOogREu0UUvcdfGWoeSlsPb YWEQ== X-Gm-Message-State: AOAM531wh9iqg9G2qfCsuUwOxfIYMoqnqKjLEausnMp8+AvZvsQ6A97X a7Y/SdsU8JGs2GH9xvmAi24LS9ryTRGXi1VcRuE= X-Google-Smtp-Source: ABdhPJyvh1v32zht01ybkI9BpmyAXJ9zuhxhLNX79/znuJlKBahdpKkN7WLQ9SX66Us26HIqWCH7g05n5hAURXc/6mk= X-Received: by 2002:aca:2819:: with SMTP id 25mr8632910oix.48.1594253642055; Wed, 08 Jul 2020 17:14:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Luiz Augusto von Dentz Date: Wed, 8 Jul 2020 17:13:49 -0700 Message-ID: Subject: Re: Temporary device removal during discovery To: Andrey Batyiev Cc: Bastien Nocera , linux-bluetooth Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 393AD52C05 X-Rspamd-UID: be1f2d Hi Andrey, On Wed, Jul 8, 2020 at 3:57 PM Andrey Batyiev wrote: > > Hi Luiz, > > On Thu, Jul 9, 2020 at 12:14 AM Luiz Augusto von Dentz > wrote: > > The delta logic might be a nice addition as a separate patch, it is > > more for detecting devices disappearing then actually cleanup during > > power off. > No-no, it's not about adapter powering off. > > I meant that (external) devices never disappear from the bluez device > list during the discovery, > even if the (external) devices are turned off (i.e. they should be > purged by bluez). > > So: > - bluez is central > - bluez is discovering > - peripheral appear for a moment, than disappear (i.e. peripheral > would be turned off) > - bluez would not remove device from the list (at least until > discovery is stopped) > > Use case: > - bluez is monitoring environment (discovering literally forever) > - peripherals are brought in and out of bluez visibility range > - bluez list of visible devices grows infinitely and causes problems > (hundreds of devices) That is exactly what I mean with detecting devices disappearing, so I'm fine to introduce such logic and use the temporary timeout so it can be removed while an existing discovery is in place. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uA98Bw6pBl/EqQAAvsO+Rg (envelope-from ) for ; Thu, 09 Jul 2020 07:20:14 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id qGMvBg6pBl+zzAEAgupzMw (envelope-from ); Thu, 09 Jul 2020 07:20:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5CBEE40016; Thu, 9 Jul 2020 07:20:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726367AbgGIFUA (ORCPT + 1 other); Thu, 9 Jul 2020 01:20:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726124AbgGIFUA (ORCPT ); Thu, 9 Jul 2020 01:20:00 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25B8AC08C5CE; Wed, 8 Jul 2020 22:20:00 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id t7so432913qvl.8; Wed, 08 Jul 2020 22:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=h2ey5u0rQyusT9d/zc6U5JsDDVWxF+R85sT24kpAB5c=; b=rR8wMB0WbQzJVmK1fG6vrA9QgvikGKfYsQl+iy+CoUKQ+prDnqBeSkuG178FVewnNR n7PpgaXv02dMHyYy29chR5Ui46SVLx5QcQvAiSauy9uNwq9Tzt47WxTO3BVMOODMgwaL 6MHRhl0+ZwymBPoWbQqUVhWwbqvIjmy86Et/RPKmPJ/ZSKZBZTT/KXXhnS+A6U4IDEfw INW6hYTuqzC+srHq80xDOjEV1TEzQbZ1QSWcY9DZzOLwcZzmJDfvKjHy5KbAP3Ll8FgO 2aWwhwUq9duT2DQ7p5SbWR3qalA0C9DtOShUzl2J76jUBmG+sDac0gyA0cTw6Y45/Pm4 yLhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=h2ey5u0rQyusT9d/zc6U5JsDDVWxF+R85sT24kpAB5c=; b=EUwJWHeyHjK5GBDGz1PD8PVHXIeURKxZNpFXGc5Qp61ai9T2WmBNanoVlSHSUITcL+ YkIbIvGVP/ioIpKIoHets4qtwP6fCN6TWpIfDlZyjWWPcPiL14MD1qOrj+x8EpMSxEYZ o9Zkxhi4ljF+yRROi26yxeby35USOwmXPluPsjJQPWNpC863yRtjqBNJRR7qNucL2sJz zd1VwxOFJn1pGOO1PaFJpN7oue+4nTV1On09ZvbZfICtl4oKVxPQX29OP7b83myeX+OM UtQcmw1OmDsps5anJzff6ofFeznwyPUWaq9novPan81Xhzwu0wuqEVv0x/inH/oC1yg+ uP5A== X-Gm-Message-State: AOAM533dZ5XMFb6b6Q9Omgoc+I5cowRughxYQMbLcbvT4dOt1P+tSJXz wZTMx/CM+2a6n/Cvo2O8bk9MrwWDHInM X-Google-Smtp-Source: ABdhPJysCYkfIBcts8kENFrUYmdr3eXiSmrlK8fWILE44f0rLD8RRzITYv0N2MTnGAM7xAIdtT++8g== X-Received: by 2002:a05:6214:4c4:: with SMTP id ck4mr59679790qvb.202.1594271999346; Wed, 08 Jul 2020 22:19:59 -0700 (PDT) Received: from localhost.localdomain (c-76-119-149-155.hsd1.ma.comcast.net. [76.119.149.155]) by smtp.gmail.com with ESMTPSA id p7sm2502952qki.61.2020.07.08.22.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 22:19:58 -0700 (PDT) From: Peilin Ye To: Marcel Holtmann , Johan Hedberg Cc: Peilin Ye , "David S . Miller" , Jakub Kicinski , Russell King , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH] net/bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt() Date: Thu, 9 Jul 2020 01:18:02 -0400 Message-Id: <20200709051802.185168-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5CBEE40016 X-Rspamd-UID: 5f48c3 Check upon `num_rsp` is insufficient. A malformed event packet with a large `num_rsp` number makes hci_extended_inquiry_result_evt() go out of bounds. Fix it. Also, make `num_rsp` unsigned. This patch fixes the following syzbot bug: https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2 Reported-by: syzbot+d8489a79b781849b9c46@syzkaller.appspotmail.com Signed-off-by: Peilin Ye --- net/bluetooth/hci_event.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 03a0759f2fc2..29aff5e7dec2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4369,13 +4369,13 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct inquiry_data data; - struct extended_inquiry_info *info = (void *) (skb->data + 1); - int num_rsp = *((__u8 *) skb->data); + struct extended_inquiry_info *info = (void *)(skb->data + 1); + __u8 num_rsp = *((__u8 *)skb->data); size_t eir_len; BT_DBG("%s num_rsp %d", hdev->name, num_rsp); - if (!num_rsp) + if (!num_rsp || num_rsp * sizeof(*info) > skb->truesize) return; if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) -- 2.25.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QHymAafUBl9/cQAAvsO+Rg (envelope-from ) for ; Thu, 09 Jul 2020 10:26:15 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2CgyO6bUBl+h0gEADc0bRg (envelope-from ); Thu, 09 Jul 2020 10:26:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A428852CB2; Thu, 9 Jul 2020 10:26:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726286AbgGII0J (ORCPT + 1 other); Thu, 9 Jul 2020 04:26:09 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:41779 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbgGII0J (ORCPT ); Thu, 9 Jul 2020 04:26:09 -0400 Received: from classic (lns-bzn-39-82-255-60-242.adsl.proxad.net [82.255.60.242]) (Authenticated sender: hadess@hadess.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id E4FFB24000E; Thu, 9 Jul 2020 08:26:06 +0000 (UTC) Message-ID: Subject: Re: Temporary device removal during discovery From: Bastien Nocera To: Andrey Batyiev , Luiz Augusto von Dentz Cc: linux-bluetooth Date: Thu, 09 Jul 2020 10:26:06 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: A428852CB2 X-Rspamd-UID: b5d51a On Thu, 2020-07-09 at 01:57 +0300, Andrey Batyiev wrote: > Hi Luiz, > > On Thu, Jul 9, 2020 at 12:14 AM Luiz Augusto von Dentz > wrote: > > The delta logic might be a nice addition as a separate patch, it is > > more for detecting devices disappearing then actually cleanup > > during > > power off. > No-no, it's not about adapter powering off. > > I meant that (external) devices never disappear from the bluez device > list during the discovery, > even if the (external) devices are turned off (i.e. they should be > purged by bluez). > > So: > - bluez is central > - bluez is discovering > - peripheral appear for a moment, than disappear (i.e. peripheral > would be turned off) > - bluez would not remove device from the list (at least until > discovery is stopped) > > Use case: > - bluez is monitoring environment (discovering literally forever) > - peripherals are brought in and out of bluez visibility range > - bluez list of visible devices grows infinitely and causes problems > (hundreds of devices) I'd also expect devices that are recently discovered to disappear if they haven't replied to a discovery in 30 seconds. It would stop GNOME's Bluetooth Settings's Bluetooth list forever expanding. Or we need to give the ability for front-ends to do that by exporting the "last seen" dates. Cheers Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iPDRGdcVB18CmAAAvsO+Rg (envelope-from ) for ; Thu, 09 Jul 2020 15:04:23 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oGeFGNcVB1+5ywEAlp8NpQ (envelope-from ); Thu, 09 Jul 2020 15:04:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 23AFD52A3B; Thu, 9 Jul 2020 15:04:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726767AbgGINEK (ORCPT + 1 other); Thu, 9 Jul 2020 09:04:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726320AbgGINEJ (ORCPT ); Thu, 9 Jul 2020 09:04:09 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A90CAC061A0B; Thu, 9 Jul 2020 06:04:09 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id e12so1535600qtr.9; Thu, 09 Jul 2020 06:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QGEwhK7+HOB5UDgh/+KiU6/EDHzIv+5VNqxy139wdGM=; b=sdQvfSnDRAJBUsy+ESk4398OyprIdU0M5hUcZa+PA922C/+M4v0Z9UQNrEC4+TYTfA tYneGiD04EOzzYC+Wkznu3Illuf9QZVpbClghcgrU7TSFQQyCuPQpLR/6axtrYtHm8nN LhQNtvhdmlwyLWO1ggwMrTITgwSXREje0yQ7kTRWIE0N7pr1c9LgHgsaetzb0pTI8cA1 12xew+zGAloXiRL9HDVvy3Tn8A1y0+bpLIgG0SGtaA8Q89Zyosc3trGCo5iDVkGV3D49 TQWx0H/rl1dGETXFQgt7j2/rY/bO/iPkk4a7Qv7syqb8RycQ7I7GRnsXSDomWmElG3Hf ditw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QGEwhK7+HOB5UDgh/+KiU6/EDHzIv+5VNqxy139wdGM=; b=As9XFwq/lVKGnZ2TyWw8+5TxrsMLQAIpizOaA2q1AC/Q1lZz9T8k6tvIQkqxhc+0/Z /se379FSuEdWNK+uqTSl20r6BuFwA9bhAXKZZ0F+kThs7atMZOAgxQsecEMmCYa2w86C afDk9G7qUt1cOwz7Oxz6kqxX0WFBlROPHcyKMIfFM50JBVGMkmmzgI49R1XMLOA6Dgkp zROAKk14qhTyJgVAvPgDwxuxLXBMbrjXcjBqF8sAiHRKBbdXpcDs4vshAShbiJ1kOGWZ pwQXzPANWIpjBW5328xMnxJr7uqt3OIWsEnC/RmnoPCAusZMdbmrGgcw4v9CUCdLSiiZ Se2Q== X-Gm-Message-State: AOAM532etSLmIaRbBg6B4sbDgC0m9XEnnQzRBCDSEgg0VuPoeXS/4bTT lMzYRjxz7IYehC7i9bbU8mOr9wjzsBHa X-Google-Smtp-Source: ABdhPJw73GzxPHh95KuS+8iUpcn45BCe3CRu5/OTi7CJ2JO0fCvf4YVaQIXayVOeIH8DOPuKW38axQ== X-Received: by 2002:ac8:47d0:: with SMTP id d16mr65906935qtr.349.1594299848927; Thu, 09 Jul 2020 06:04:08 -0700 (PDT) Received: from localhost.localdomain (c-76-119-149-155.hsd1.ma.comcast.net. [76.119.149.155]) by smtp.gmail.com with ESMTPSA id v62sm3882456qkb.81.2020.07.09.06.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 06:04:08 -0700 (PDT) From: Peilin Ye To: Marcel Holtmann , Johan Hedberg Cc: Peilin Ye , "David S . Miller" , Jakub Kicinski , Russell King , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH v2] net/bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt() Date: Thu, 9 Jul 2020 09:02:24 -0400 Message-Id: <20200709130224.214204-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200709051802.185168-1-yepeilin.cs@gmail.com> References: <20200709051802.185168-1-yepeilin.cs@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.68 / 15.00 / 200.00 X-Rspamd-Queue-Id: 23AFD52A3B X-Rspamd-UID: 5ada4f Check upon `num_rsp` is insufficient. A malformed event packet with a large `num_rsp` number makes hci_extended_inquiry_result_evt() go out of bounds. Fix it. This patch fixes the following syzbot bug: https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2 Reported-by: syzbot+d8489a79b781849b9c46@syzkaller.appspotmail.com Signed-off-by: Peilin Ye --- Changes in v2: - Use `skb->len` instead of `skb->truesize` as the length limit. - Leave `num_rsp` as of type `int`. net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 03a0759f2fc2..91cb3707d20a 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4375,7 +4375,7 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, BT_DBG("%s num_rsp %d", hdev->name, num_rsp); - if (!num_rsp) + if (!num_rsp || skb->len < num_rsp * sizeof(*info)) return; if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) -- 2.25.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oJbxHdtAB19YYAAAvsO+Rg (envelope-from ) for ; Thu, 09 Jul 2020 18:07:55 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aHz1G9tAB18GhgAAlp8NpQ (envelope-from ); Thu, 09 Jul 2020 18:07:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E42F2530CD; Thu, 9 Jul 2020 18:07:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728206AbgGIQGl (ORCPT + 1 other); Thu, 9 Jul 2020 12:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726357AbgGIQGl (ORCPT ); Thu, 9 Jul 2020 12:06:41 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E4CFC08C5CE for ; Thu, 9 Jul 2020 09:06:41 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id g16so1999547pjz.3 for ; Thu, 09 Jul 2020 09:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=Y+kIbnGkHotm9lccHj/nLpbXHnZU4LZKnUryVen0AX4=; b=fbYJKts353khLfb+Q/WIRbn0JcADVkHtG3LnD05lA5wN9VzX5D4YX1ZXvuKurOUBNQ uC8WG5Avrv194R7bb+MOBFxw9NZklkPkbx3D6r6liEGwLJF1mDxMniixxQN4fpGffjoe 7XuJGPIZpq0KzwzELCxfABIWqYvy9UXcANbx0ZaxLM2vu1IeeFwcJmkfmtS4cEYJJEVK YXd2P+uDeVLqmfjE6AsI2vUBeOWbri6PknX1GlRRETOdadln+zM7IZxIDXzoKeJ0Nnfc rBs0+zK8N/Lk9zmYqZgEZKxDwEGIQ5ni0kmGjudzF3JqbYkUo3BwGnUjSDQrgu0YNIfS lfyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Y+kIbnGkHotm9lccHj/nLpbXHnZU4LZKnUryVen0AX4=; b=lcHBEz2dbQV2TjBk6sweUZ4ljxNlcfngeXA1+2+JsCma9Z04sTro/QVkRt8zyv/8Oo f2bvwEpHc/zYDozKv3MA54TVyVQmIVaN3RJkTgxEpQLEnaUfk+3dxbaSwmv6wLalUtGF sf2sBIOZKs477dalOo6ZnArzZr9XLv/7tzWEePGsTyrQVkf9eo0JmhXWcmjhM22TnXUq M2kfqWzAXqvVeBHh6FVSvpZ26Lr6TH9Vlcb84/m4rmGxwsYOyXyUr6xq93r3+Ht4XohO XJDTSaCMQWKGTqXrt7Du1/jxcBRZ4lxCf3TZFgZFNyTuW0Btpc64LbamKnuKx2YxGi4A AXlg== X-Gm-Message-State: AOAM5306n+pR+CYDqRUX9nNmjVZunjm63kpXkuJy0FPeoFGA/S7jCAhH MzMAqlot6BhL1iVx3tN2Ysl0vtcPT731f/fWu/6fi60XiiNdcbpEpUnw/blgqqyk3BJTtela6y7 k+HrJebhCflwbkJtl3M/E2YTqQaUkpgWv8N7d0swGAAUAz1RfViLTHEssMgLiReraHyOWunaYCC oL X-Google-Smtp-Source: ABdhPJxWrGtk9geN/md/yQve8C/kI1We/jnmnzs55UKYX/6gx79TbpUBn/tO3WwooC6G4CgHaGOjdbkrD3bt X-Received: by 2002:a17:902:be0e:: with SMTP id r14mr28892156pls.309.1594310800664; Thu, 09 Jul 2020 09:06:40 -0700 (PDT) Date: Thu, 9 Jul 2020 09:06:37 -0700 Message-Id: <20200709090631.Bluez.v1.1.I6aa22c6e425e5b19c321c0768f50ca3fc2c090da@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog Subject: [Bluez PATCH v1] audio/media - Fix volume sync between media and transport From: Yu Liu To: linux-bluetooth@vger.kernel.org Cc: Hsin-Yu Chao , sonnysasaka@chromium.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: E42F2530CD X-Rspamd-UID: ea17f2 From: Hsin-Yu Chao A volume value is cached on the global media player object. And a check was used to NOT update volume to each transport if this value doesn't change. That is causing problem at disconnect then reconnect when the new constructed transport never receive update about the last used volume value. Reviewed-by: sonnysasaka@chromium.org Reviewed-by: hychao@chromium.org --- Changes in v1: - Initial change profiles/audio/media.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 993ecb3b3..92e363de9 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -1204,9 +1204,6 @@ static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) struct media_player *mp = user_data; GSList *l; - if (mp->volume == volume) - return; - mp->volume = volume; for (l = mp->adapter->endpoints; l; l = l->next) { -- 2.27.0.383.g050319c2ae-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EFe6M8WHB18kMQAAvsO+Rg (envelope-from ) for ; Thu, 09 Jul 2020 23:10:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id Btn4McWHB1+SoAAADc0bRg (envelope-from ); Thu, 09 Jul 2020 23:10:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B4ECBA1B5E; Thu, 9 Jul 2020 23:10:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726323AbgGIVKY (ORCPT + 1 other); Thu, 9 Jul 2020 17:10:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726220AbgGIVKX (ORCPT ); Thu, 9 Jul 2020 17:10:23 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31390C08C5CE for ; Thu, 9 Jul 2020 14:10:23 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id o1so1336885plk.1 for ; Thu, 09 Jul 2020 14:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nUdWCpDi1dn5PTCttl/9ZFOQYydznYHG0C95TtGGYgk=; b=eLLkvGVnTveO6Dj2TJ5JGP7eqEViAf6yw7Y1swsKuYJwNXJj8k37hhsoj9e4OiG0Wl +epC6eT+Q33epYdlD4qXdMdt0WqqyBHpqH18TODBJNiObnXXiIlVG/yAlJEOLMrjCGUL qS1T/LK5/y+IXvjVjOOhcPkcZR+0N0/sarYlM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nUdWCpDi1dn5PTCttl/9ZFOQYydznYHG0C95TtGGYgk=; b=iZ9F254dd16IU//cvVneGqV7j4AC3k7gRFK1G3M4pYKvWEmH53KYOCk78YEKF6TJsC g1WHtGjtfZKWBUJlYg3XLePvpBbMKh8PqUWMCLRSzywM9+t8prFpcfIsL3CkggnRk1s0 enmIWrAgK8Wfnu9oQ2MUTtvU4MIBLCzOMUxZW3GFgD9pThvEQJhH+qq8YV2kaba7Igdj 503SxDAAHFqWaGYAPRHoGqsZmr/RAZx0Gz71VKXZhhIjKYwtXhtCM6opdd2c6PTHpEJ6 oNgBolPlej+x94rPpmmkbAo//aaCcKq30GD/k9g7rgrfsnkvcdGgRtF0V4hYLIHkVVw7 pInw== X-Gm-Message-State: AOAM5335mdmaTUI2Xm0X69Mpi8fXYvfuN1F6J2c7peX3C6qYtBekrbGi WiWwFx/r1mo9ay41hmFBHrZfQw== X-Google-Smtp-Source: ABdhPJwnf5McXN9zUXxfAAwFxxkZM5hsfxOBSrH9p89jSIcJ9ihcjFi8h70h4RQxLMj9spOmwTrLZA== X-Received: by 2002:a17:902:d715:: with SMTP id w21mr15828758ply.140.1594329022590; Thu, 09 Jul 2020 14:10:22 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id l191sm3441374pfd.149.2020.07.09.14.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 14:10:22 -0700 (PDT) From: Abhishek Pandit-Subedi To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi , Alain Michaud , Miao-chen Chou Subject: [Bluez PATCH] doc: Add Suspend and Resume events Date: Thu, 9 Jul 2020 14:10:02 -0700 Message-Id: <20200709140928.Bluez.1.I9181af521cf0fba8f4315c9b89975848d437d6dd@changeid> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 24 X-Rspamd-Score: 3.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: B4ECBA1B5E X-Rspamd-UID: ca22aa Add Controller Suspend Event and Controller Resume Event to identify suspend or resume of the Bluetooth stack has occurred. Also update Device Disconnected Event to indicate a new disconnect reason: "Connection terminated by local host for suspend" Reviewed-by: Alain Michaud Reviewed-by: Miao-chen Chou --- doc/mgmt-api.txt | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index ca0d38469..f79c0222c 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -3834,6 +3834,7 @@ Device Disconnected Event 2 Connection terminated by local host 3 Connection terminated by remote host 4 Connection terminated due to authentication failure + 5 Connection terminated by local host for suspend Note that the local/remote distinction just determines which side terminated the low-level connection, regardless of the @@ -4577,3 +4578,55 @@ Advertisement Monitor Removed Event The event will only be sent to management sockets other than the one through which the command was sent. + + +Controller Suspend Event +======================== + + Event code: 0x002d + Controller Index: + Event Parameters: Suspend_State (1 octet) + + This event indicates that the controller is suspended for host suspend. + + Possible values for the Suspend_State parameter: + 0 Running (not disconnected) + 1 Disconnected and not scanning + 2 Page scanning and/or passive scanning. + + The value 0 is used for the running state and may be sent if the + controller could not be configured to suspend properly. + + This event will be sent to all management sockets. + + +Controller Resume Event +======================= + + Event code: 0x002e + Controller Index: + Event Parameters: Address (6 octets) + Address_Type (1 octet) + Wake_Reason (1 octet) + + This event indicates that the controller has resumed from suspend. + + Possible values for the Wake_Reason parameter: + 0 Unexpected Event + 1 Resume from non-Bluetooth wake source + 2 Connection Request (BR/EDR) + 3 Connection Complete (BR/EDR) + 4 LE Advertisement + 5 LE Direct Advertisement + 6 LE Extended Advertisement + + We expect that only peer reconnections should wake us from the suspended + state. Any other events that cause a wakeup will be marked as Unexpected + Event. + + If the Wake_Reason was any of the expected wake reasons (values 2-6), + the address of the peer device that caused the event will be shared in + Address and Address_Type. Otherwise, Address and Address_Type will both + be zero. + + This event will be sent to all management sockets. -- 2.27.0.383.g050319c2ae-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sPz6OW7vB1/ZNQAAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 06:32:46 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id OJxDOG7vB1/ROwEA0J78UA (envelope-from ); Fri, 10 Jul 2020 06:32:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 674B6526C5; Fri, 10 Jul 2020 06:32:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726545AbgGJEck (ORCPT + 1 other); Fri, 10 Jul 2020 00:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbgGJEck (ORCPT ); Fri, 10 Jul 2020 00:32:40 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 272B9C08C5CE for ; Thu, 9 Jul 2020 21:32:40 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id u64so5564198ybf.13 for ; Thu, 09 Jul 2020 21:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=K8me4fEPpb0/1iN+Pz1d6/HbNmdDLSl9D0NJTx0R2R8=; b=uFVbP1ef8i1+JSztIT48ZdIf5CrV0b08bJbbwIvGn/OArkNe9o7xhgO75Q6i1NZRt2 J4qiUMxwiI8la4MJbMioyANPtjYYXCkdcsHVMsxWmZ+BNSOkOof/OqWS4hjU3TRdSB2j 3MZZ8TAbdb/45xIbeuyKR4l1Hj0vJsHQEamW75pSPCKCBh1Qpb/9i/cW1b99IPkfp/jb Ut+agNb1bhhZs8HYDbFw1UTogEg34ywiFRgzov/6ADHLFWsk2zOf6e4NsnJzy0aMktCO SzgCuIWwDEYvyLfg/DIuVNj1LrtIhsX3lA1ZsM2b8xbTam3A0zwYcx9NTm0x+W89/kXS YD8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=K8me4fEPpb0/1iN+Pz1d6/HbNmdDLSl9D0NJTx0R2R8=; b=dwL6pN5Csu1cH7XHhS2CI4u+rlzpQ1Ibwb9H+Znzmmc34wHmV965uOl1xYjJHS2iBf VI2RnHFHi01ZYhQka58z8MMieafo1d9TMrprbc8gJ/KvrBFssxnEAmbRUSfSjc45oaZE Aj/yt7fhAKm/F7YVb//cnwwCe9SJmF9A9s6GqMPXlGM2JEKIMCMu2NqnsX667WYUK/X9 n6tu7RP43JNBarzw10OiO3ZizQ58qCGzY1+FgN0vuFnOsO2jjDpOlzFb0I5SR6hGHqdj gk2xCbiUHHyVFr1B5Qp+yoGm4TdIcEHW9WthjaUgwuEha1CW845I0GTshqwb++pGDn4D mwWQ== X-Gm-Message-State: AOAM532VGaxp0uPnZnPPVscHBAKFNOmkJlYVUQ8IQ2iY/ceGSDY4QmE1 saGOoNYUN2I1Sy5hNfV/Aa/CfP05wco/cdIOUzS1DIUKwG42rKr/WDS6g2BHro+T2GYZqsG4Vje fygZgA9kcWxnBGmvCNXkyWjSsJrnNl6SrWmO+ViDqMVspKCORtxqEg81eC+SVNZrsnNUyOCmoXk JC X-Google-Smtp-Source: ABdhPJz8bOebN7xF+G4baz/PGtgsR3Czetq+8TDRdr3q9j5GAHHpi4XC/dEOpQ197Y8Mg1Z3UUojYlN9LwTH X-Received: by 2002:a25:901:: with SMTP id 1mr10952355ybj.378.1594355559308; Thu, 09 Jul 2020 21:32:39 -0700 (PDT) Date: Fri, 10 Jul 2020 12:32:32 +0800 Message-Id: <20200710123105.Bluez.v1.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog Subject: [Bluez PATCH v1 1/2] audio/transport: change volume to 8bit From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Michael Sun Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 0.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: 674B6526C5 X-Rspamd-UID: e1bfda From: Archie Pusaka The valid range of volume is 0 - 127, yet it is stored in 16bit data type. This patch modifies it so we use 8bit data type to store volume instead. Furthermore, this patch introduces helper function and defined values to check for volume validity, to prevent numbers scattered all over. Reviewed-by: Michael Sun --- profiles/audio/avrcp.c | 2 +- profiles/audio/avrcp.h | 1 - profiles/audio/transport.c | 46 ++++++++++++++++++++++---------------- profiles/audio/transport.h | 3 ++- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index e2428250e..a11b3ef6e 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -1660,7 +1660,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, break; case AVRCP_EVENT_VOLUME_CHANGED: pdu->params[1] = media_transport_get_device_volume(dev); - if (pdu->params[1] > 127) + if (!media_transport_volume_valid(pdu->params[1])) goto err; len = 2; diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index 86d310c73..3fd74e18a 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -114,6 +114,5 @@ void avrcp_unregister_player(struct avrcp_player *player); void avrcp_player_event(struct avrcp_player *player, uint8_t id, const void *data); - size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands); size_t avrcp_browsing_general_reject(uint8_t *operands); diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 48fabba9b..a32073380 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -55,6 +55,8 @@ #define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1" +#define UNINITIALIZED_VOLUME_VALUE 128 + typedef enum { TRANSPORT_STATE_IDLE, /* Not acquired and suspended */ TRANSPORT_STATE_PENDING, /* Playing but not acquired */ @@ -86,7 +88,7 @@ struct media_owner { struct a2dp_transport { struct avdtp *session; uint16_t delay; - uint16_t volume; + uint8_t volume; }; struct media_transport { @@ -634,7 +636,7 @@ static gboolean volume_exists(const GDBusPropertyTable *property, void *data) struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; - return a2dp->volume <= 127; + return media_transport_volume_valid(a2dp->volume); } static gboolean get_volume(const GDBusPropertyTable *property, @@ -654,24 +656,20 @@ static void set_volume(const GDBusPropertyTable *property, { struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; - uint16_t volume; + uint16_t arg; + uint8_t volume; bool notify; - if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) { - g_dbus_pending_property_error(id, - ERROR_INTERFACE ".InvalidArguments", - "Invalid arguments in method call"); - return; - } + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) + goto error; - dbus_message_iter_get_basic(iter, &volume); + dbus_message_iter_get_basic(iter, &arg); + if (arg > UINT8_MAX) + goto error; - if (volume > 127) { - g_dbus_pending_property_error(id, - ERROR_INTERFACE ".InvalidArguments", - "Invalid arguments in method call"); - return; - } + volume = (uint8_t)arg; + if (!media_transport_volume_valid(volume)) + goto error; g_dbus_pending_property_success(id); @@ -688,6 +686,11 @@ static void set_volume(const GDBusPropertyTable *property, "Volume"); avrcp_set_volume(transport->device, volume, notify); + return; + +error: + g_dbus_pending_property_error(id, ERROR_INTERFACE ".InvalidArguments", + "Invalid arguments in method call"); } static gboolean endpoint_exists(const GDBusPropertyTable *property, void *data) @@ -824,7 +827,7 @@ static int media_transport_init_source(struct media_transport *transport) transport->data = a2dp; transport->destroy = destroy_a2dp; - a2dp->volume = -1; + a2dp->volume = UNINITIALIZED_VOLUME_VALUE; transport->sink_watch = sink_add_state_cb(service, sink_state_changed, transport); @@ -931,7 +934,7 @@ struct btd_device *media_transport_get_dev(struct media_transport *transport) return transport->device; } -uint16_t media_transport_get_volume(struct media_transport *transport) +uint8_t media_transport_get_volume(struct media_transport *transport) { struct a2dp_transport *a2dp = transport->data; return a2dp->volume; @@ -958,7 +961,7 @@ uint8_t media_transport_get_device_volume(struct btd_device *dev) GSList *l; if (dev == NULL) - return 128; + return UNINITIALIZED_VOLUME_VALUE; for (l = transports; l; l = l->next) { struct media_transport *transport = l->data; @@ -991,3 +994,8 @@ void media_transport_update_device_volume(struct btd_device *dev, media_transport_update_volume(transport, volume); } } + +bool media_transport_volume_valid(uint8_t volume) +{ + return volume < 128; +} diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index ac542bf6c..c430515f2 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -32,7 +32,7 @@ struct media_transport *media_transport_create(struct btd_device *device, void media_transport_destroy(struct media_transport *transport); const char *media_transport_get_path(struct media_transport *transport); struct btd_device *media_transport_get_dev(struct media_transport *transport); -uint16_t media_transport_get_volume(struct media_transport *transport); +uint8_t media_transport_get_volume(struct media_transport *transport); void media_transport_update_delay(struct media_transport *transport, uint16_t delay); void media_transport_update_volume(struct media_transport *transport, @@ -43,3 +43,4 @@ void transport_get_properties(struct media_transport *transport, uint8_t media_transport_get_device_volume(struct btd_device *dev); void media_transport_update_device_volume(struct btd_device *dev, uint8_t volume); +bool media_transport_volume_valid(uint8_t volume); -- 2.27.0.383.g050319c2ae-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sC2qGHTvB19bPgAAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 06:32:52 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wBZzFXTvB18p3gEAlp8NpQ (envelope-from ); Fri, 10 Jul 2020 06:32:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 18A4F5278A; Fri, 10 Jul 2020 06:32:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726828AbgGJEcp (ORCPT + 1 other); Fri, 10 Jul 2020 00:32:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbgGJEcp (ORCPT ); Fri, 10 Jul 2020 00:32:45 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86527C08C5CE for ; Thu, 9 Jul 2020 21:32:45 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id a25so2875301pfl.2 for ; Thu, 09 Jul 2020 21:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=LKAAkIEAP0cQja6zPmfnfktGRKXtJMDnwdCtU8F3HvI=; b=vhmZLbeS4l0eJcWDi5KfmfvAJfvaNDacLBw/NXdKH+iCV14MpvFPe5YkqPxtrtPu5r Ok4ClEB3iFrA9Mh7K6VOuHXJYPZqa0QABxTeTU+zaIwkeVMz6p6E6cipjOzjpRTvDWuG Y71UgoegYP0a8TW2Vol8vrTH1r+R6JFH43omR0sZKxpKQpMDPHemp/KjCxy4r5zFyDAM ji4Cn+AJV+tnlWmn0tggaCTB2Rr1Ov/0plH8gXD73jiAfZe/LQ1O9dzz6PeR1sELKKW8 r1vCM5NHyyp6jdzYP24rfSfC+VIvQmKfHTCH7nnN/5TyqE1fOjkIjpyxY9OsAC/QaooH zQXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=LKAAkIEAP0cQja6zPmfnfktGRKXtJMDnwdCtU8F3HvI=; b=lpZV981M2kMbZUfCl85T9LmMtKn9x7OQC0cmQnvOCpMr7CRyQ6r/yCBo1miXmhFIur za9TigfU/uRNrUB3ZTCNYAzeUMRV3pQF/hV0RmJ2so/DsCf4NyxGyJ7vqNBZD9xHImbf EDdNBJdh9FRlTRmZBKrc9L6U0dtW7eLXSt+t0EvFK1JaBGV9II/D+WoBtlYa/uPhEVrS 2CM1zyT9BrrRBKyc9L8Uy+LYqoR8seoYRrlXHXo+/dizzGHlVlIKUvQfk5N0HVOI4O4R tFx2BHjA+mq+DJtrm2KdyotYSN2EZBeL/tx4LN4DKA8PjCHUnvUidNs7bWkoC8wau1OB Xrig== X-Gm-Message-State: AOAM530GM93gk8Rw2/TRJwtCK5+5zD2/cNaCIhwGhCQ3bwBX579N3XMa Y9FfQlYr1gYaie+ygJfM0d3TPSOjjIpaqVXu63mLOjuVQq118GJwxfFpd1G9+81yybvqBgSFYok /NMD69h1FcdMYXIW6fNSiJacJXuKRKvrwtAz5TzYvIuTlLK9CHKdJL/gySsvbwmtx406zxKdxgO /B X-Google-Smtp-Source: ABdhPJzdOymAy/4jxVXWORX17wmjq6cWBEopaj+GTprV0HhjYf7fKhIpcBNKcFIjP4VxkYpB5CkArk+sGWG4 X-Received: by 2002:a17:902:6506:: with SMTP id b6mr54542666plk.13.1594355564833; Thu, 09 Jul 2020 21:32:44 -0700 (PDT) Date: Fri, 10 Jul 2020 12:32:33 +0800 In-Reply-To: <20200710123105.Bluez.v1.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Message-Id: <20200710123105.Bluez.v1.2.Ic16589fde45fac0c496dfca2fa27672059114c3b@changeid> Mime-Version: 1.0 References: <20200710123105.Bluez.v1.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog Subject: [Bluez PATCH v1 2/2] audio/transport: store volume for initialization From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Howard Chung Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 0.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: 18A4F5278A X-Rspamd-UID: d7dfd0 From: Archie Pusaka Sometimes the response of RegisterNotification for volume change event came before we create the transport for the corresponding device. If that happens, we lose the volume information. After the transport is created, the volume is also potentially stuck to an uninitialized invalid value. The property Volume of MediaTransport1 will also be left unaccessible. This patch stores the value of the volume notification response. When the transport is initialized, we try to match the device with the previously stored volume and assign that value instead. Reviewed-by: Howard Chung --- profiles/audio/media.c | 17 +---------- profiles/audio/transport.c | 61 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 993ecb3b3..be1ca18ee 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -1202,27 +1202,12 @@ static uint32_t get_duration(void *user_data) static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) { struct media_player *mp = user_data; - GSList *l; if (mp->volume == volume) return; mp->volume = volume; - - for (l = mp->adapter->endpoints; l; l = l->next) { - struct media_endpoint *endpoint = l->data; - struct media_transport *transport; - - /* Volume is A2DP only */ - if (endpoint->sep == NULL) - continue; - - transport = find_device_transport(endpoint, dev); - if (transport == NULL) - continue; - - media_transport_update_volume(transport, volume); - } + media_transport_update_device_volume(dev, volume); } static bool media_player_send(struct media_player *mp, const char *name) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index a32073380..2fd04dd42 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -56,6 +56,7 @@ #define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1" #define UNINITIALIZED_VOLUME_VALUE 128 +#define PEND_DEVICE_VOLUME_TIMEOUT 1 typedef enum { TRANSPORT_STATE_IDLE, /* Not acquired and suspended */ @@ -116,7 +117,13 @@ struct media_transport { void *data; }; +struct pending_device_volume { + struct btd_device *device; + uint8_t volume; +}; + static GSList *transports = NULL; +static GSList *pending_device_volumes; static const char *state2str(transport_state_t state) { @@ -810,6 +817,52 @@ static void source_state_changed(struct btd_service *service, transport_update_playing(transport, FALSE); } +static uint8_t get_pending_device_volume(struct btd_device *dev) +{ + GSList *l; + + for (l = pending_device_volumes; l; l = l->next) { + struct pending_device_volume *pend = l->data; + + if (pend->device == dev) + return pend->volume; + } + + return UNINITIALIZED_VOLUME_VALUE; +} + +static gboolean remove_pending_device_volume(gpointer user_data) +{ + struct pending_device_volume *pend = user_data; + + pending_device_volumes = g_slist_remove(pending_device_volumes, pend); + g_free(pend); + + return FALSE; +} + +static void add_pending_device_volume(struct btd_device *dev, uint8_t volume) +{ + GSList *l; + struct pending_device_volume *pend; + + for (l = pending_device_volumes; l; l = l->next) { + pend = l->data; + + if (pend->device == dev) { + pend->volume = volume; + return; + } + } + + pend = g_new0(struct pending_device_volume, 1); + pend->device = dev; + pend->volume = volume; + g_timeout_add_seconds(PEND_DEVICE_VOLUME_TIMEOUT, + remove_pending_device_volume, pend); + pending_device_volumes = g_slist_append(pending_device_volumes, pend); +} + static int media_transport_init_source(struct media_transport *transport) { struct btd_service *service; @@ -827,7 +880,7 @@ static int media_transport_init_source(struct media_transport *transport) transport->data = a2dp; transport->destroy = destroy_a2dp; - a2dp->volume = UNINITIALIZED_VOLUME_VALUE; + a2dp->volume = get_pending_device_volume(transport->device); transport->sink_watch = sink_add_state_cb(service, sink_state_changed, transport); @@ -990,9 +1043,13 @@ void media_transport_update_device_volume(struct btd_device *dev, continue; /* Volume is A2DP only */ - if (media_endpoint_get_sep(transport->endpoint)) + if (media_endpoint_get_sep(transport->endpoint)) { media_transport_update_volume(transport, volume); + return; + } } + + add_pending_device_volume(dev, volume); } bool media_transport_volume_valid(uint8_t volume) -- 2.27.0.383.g050319c2ae-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QFnYC4VGCF9YdgAAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 12:44:21 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id EIVbCoVGCF/uQAEA0J78UA (envelope-from ); Fri, 10 Jul 2020 12:44:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1ACA952AF2; Fri, 10 Jul 2020 12:44:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbgGJKnD (ORCPT + 1 other); Fri, 10 Jul 2020 06:43:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:45408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726816AbgGJKnB (ORCPT ); Fri, 10 Jul 2020 06:43:01 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A442920767; Fri, 10 Jul 2020 10:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594377781; bh=EW9MXB8Q/dnRDJNPSoM2A4yEsAsEcseFCmlJ8Ror7LM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Tgf16EmbXRYSEQZYn/cD34QnoXjzA8+ynp8kG9ZTETZVgYmoZQ9HvJcHNXOiKeHSn ehE3cqhz2C4YyZLSq60EHVpE21xVtudo/UnjDSVTbJXS6+ZLI1L1JyynmCLNZ/0g6z AvmxePRff76ZbZNo72ZomEjDcZUd8MKCvgjWHDRI= Date: Fri, 10 Jul 2020 12:43:06 +0200 From: Greg KH To: Peilin Ye Cc: Marcel Holtmann , Johan Hedberg , "David S . Miller" , Jakub Kicinski , Russell King , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: Re: [Linux-kernel-mentees] [PATCH v2] net/bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt() Message-ID: <20200710104306.GA1229536@kroah.com> References: <20200709051802.185168-1-yepeilin.cs@gmail.com> <20200709130224.214204-1-yepeilin.cs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200709130224.214204-1-yepeilin.cs@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.21 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1ACA952AF2 X-Rspamd-UID: 19ab8c On Thu, Jul 09, 2020 at 09:02:24AM -0400, Peilin Ye wrote: > Check upon `num_rsp` is insufficient. A malformed event packet with a > large `num_rsp` number makes hci_extended_inquiry_result_evt() go out > of bounds. Fix it. > > This patch fixes the following syzbot bug: > > https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2 > > Reported-by: syzbot+d8489a79b781849b9c46@syzkaller.appspotmail.com > Signed-off-by: Peilin Ye Acked-by: Greg Kroah-Hartman Bluetooth maintainers, can you also add a cc: stable on this so it gets picked up properly there? thanks, greg k-h Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0O1cDYBeCF/HXQEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 14:26:40 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MBiJC4BeCF/LowEAlScrYA (envelope-from ); Fri, 10 Jul 2020 14:26:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9D04752B89; Fri, 10 Jul 2020 14:26:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728024AbgGJM0P (ORCPT + 1 other); Fri, 10 Jul 2020 08:26:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:33082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727886AbgGJM0M (ORCPT ); Fri, 10 Jul 2020 08:26:12 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2698520748; Fri, 10 Jul 2020 12:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594383971; bh=6aBy/efwqSNbHGKVg4ZdfQ85XJ40aFOZJto45y2cftA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FuvBYzFNdOILgKmCl8WTmMc9uSS8TtRrZYsWLdPSFAxtfq1+kcYE+LuW2OMewf2Ib SRdSW9YxYBwNoCddgSNlB9Y802yVLA6F1eXldKyCtWAVowT+aFa8n1TgPe02jfEdxD x8hI83YRkUK4WPcpPky6f/5fN9CqWEI1/zTZP4QE= Date: Fri, 10 Jul 2020 14:26:16 +0200 From: Greg Kroah-Hartman To: Abhishek Pandit-Subedi Cc: rafael.j.wysocki@intel.com, linux-pm@vger.kernel.org, linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, swboyd@chromium.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: Re: [PATCH v5 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove Message-ID: <20200710122616.GA1536085@kroah.com> References: <20200707172845.4177903-1-abhishekpandit@chromium.org> <20200707102823.v5.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707102823.v5.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9D04752B89 X-Rspamd-UID: 2700dd On Tue, Jul 07, 2020 at 10:28:44AM -0700, Abhishek Pandit-Subedi wrote: > Udev rules that depend on the power/wakeup attribute don't get triggered > correctly if device_set_wakeup_capable is called after the device is > created. This can happen for several reasons (driver sets wakeup after > device is created, wakeup is changed on parent device, etc) and it seems > reasonable to emit a changed event when adding or removing attributes on > the device. > > Signed-off-by: Abhishek Pandit-Subedi Reviewed-by: Greg Kroah-Hartman Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WLd+OqCQCF/ouwAAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 18:00:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0JeSN6CQCF//GQEAlp8NpQ (envelope-from ); Fri, 10 Jul 2020 18:00:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 05B8B52E8A; Fri, 10 Jul 2020 18:00:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728047AbgGJPup (ORCPT + 1 other); Fri, 10 Jul 2020 11:50:45 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:52311 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727983AbgGJPup (ORCPT ); Fri, 10 Jul 2020 11:50:45 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jtvIQ-0003rQ-9K; Fri, 10 Jul 2020 15:50:42 +0000 To: Rocky Liao From: Colin Ian King Autocrypt: addr=colin.king@canonical.com; prefer-encrypt=mutual; keydata= mQINBE6TJCgBEACo6nMNvy06zNKj5tiwDsXXS+LhT+LwtEsy9EnraKYXAf2xwazcICSjX06e fanlyhB0figzQO0n/tP7BcfMVNG7n1+DC71mSyRK1ZERcG1523ajvdZOxbBCTvTitYOy3bjs +LXKqeVMhK3mRvdTjjmVpWnWqJ1LL+Hn12ysDVVfkbtuIm2NoaSEC8Ae8LSSyCMecd22d9Pn LR4UeFgrWEkQsqROq6ZDJT9pBLGe1ZS0pVGhkRyBP9GP65oPev39SmfAx9R92SYJygCy0pPv BMWKvEZS/7bpetPNx6l2xu9UvwoeEbpzUvH26PHO3DDAv0ynJugPCoxlGPVf3zcfGQxy3oty dNTWkP6Wh3Q85m+AlifgKZudjZLrO6c+fAw/jFu1UMjNuyhgShtFU7NvEzL3RqzFf9O1qM2m uj83IeFQ1FZ65QAiCdTa3npz1vHc7N4uEQBUxyXgXfCI+A5yDnjHwzU0Y3RYS52TA3nfa08y LGPLTf5wyAREkFYou20vh5vRvPASoXx6auVf1MuxokDShVhxLpryBnlKCobs4voxN54BUO7m zuERXN8kadsxGFzItAyfKYzEiJrpUB1yhm78AecDyiPlMjl99xXk0zs9lcKriaByVUv/NsyJ FQj/kmdxox3XHi9K29kopFszm1tFiDwCFr/xumbZcMY17Yi2bQARAQABtCVDb2xpbiBLaW5n IDxjb2xpbi5raW5nQGNhbm9uaWNhbC5jb20+iQI2BBMBCAAhBQJOkyQoAhsDBQsJCAcDBRUK CQgLBRYCAwEAAh4BAheAAAoJEGjCh9/GqAImsBcP9i6C/qLewfi7iVcOwqF9avfGzOPf7CVr n8CayQnlWQPchmGKk6W2qgnWI2YLIkADh53TS0VeSQ7Tetj8f1gV75eP0Sr/oT/9ovn38QZ2 vN8hpZp0GxOUrzkvvPjpH+zdmKSaUsHGp8idfPpZX7XeBO0yojAs669+3BrnBcU5wW45SjSV nfmVj1ZZj3/yBunb+hgNH1QRcm8ZPICpjvSsGFClTdB4xu2AR28eMiL/TTg9k8Gt72mOvhf0 fS0/BUwcP8qp1TdgOFyiYpI8CGyzbfwwuGANPSupGaqtIRVf+/KaOdYUM3dx/wFozZb93Kws gXR4z6tyvYCkEg3x0Xl9BoUUyn9Jp5e6FOph2t7TgUvv9dgQOsZ+V9jFJplMhN1HPhuSnkvP 5/PrX8hNOIYuT/o1AC7K5KXQmr6hkkxasjx16PnCPLpbCF5pFwcXc907eQ4+b/42k+7E3fDA Erm9blEPINtt2yG2UeqEkL+qoebjFJxY9d4r8PFbEUWMT+t3+dmhr/62NfZxrB0nTHxDVIia u8xM+23iDRsymnI1w0R78yaa0Eea3+f79QsoRW27Kvu191cU7QdW1eZm05wO8QUvdFagVVdW Zg2DE63Fiin1AkGpaeZG9Dw8HL3pJAJiDe0KOpuq9lndHoGHs3MSa3iyQqpQKzxM6sBXWGfk EkK5Ag0ETpMkKAEQAMX6HP5zSoXRHnwPCIzwz8+inMW7mJ60GmXSNTOCVoqExkopbuUCvinN 4Tg+AnhnBB3R1KTHreFGoz3rcV7fmJeut6CWnBnGBtsaW5Emmh6gZbO5SlcTpl7QDacgIUuT v1pgewVHCcrKiX0zQDJkcK8FeLUcB2PXuJd6sJg39kgsPlI7R0OJCXnvT/VGnd3XPSXXoO4K cr5fcjsZPxn0HdYCvooJGI/Qau+imPHCSPhnX3WY/9q5/WqlY9cQA8tUC+7mgzt2VMjFft1h rp/CVybW6htm+a1d4MS4cndORsWBEetnC6HnQYwuC4bVCOEg9eXMTv88FCzOHnMbE+PxxHzW 3Gzor/QYZGcis+EIiU6hNTwv4F6fFkXfW6611JwfDUQCAHoCxF3B13xr0BH5d2EcbNB6XyQb IGngwDvnTyKHQv34wE+4KtKxxyPBX36Z+xOzOttmiwiFWkFp4c2tQymHAV70dsZTBB5Lq06v 6nJs601Qd6InlpTc2mjd5mRZUZ48/Y7i+vyuNVDXFkwhYDXzFRotO9VJqtXv8iqMtvS4xPPo 2DtJx6qOyDE7gnfmk84IbyDLzlOZ3k0p7jorXEaw0bbPN9dDpw2Sh9TJAUZVssK119DJZXv5 2BSc6c+GtMqkV8nmWdakunN7Qt/JbTcKlbH3HjIyXBy8gXDaEto5ABEBAAGJAh8EGAEIAAkF Ak6TJCgCGwwACgkQaMKH38aoAiZ4lg/+N2mkx5vsBmcsZVd3ys3sIsG18w6RcJZo5SGMxEBj t1UgyIXWI9lzpKCKIxKx0bskmEyMy4tPEDSRfZno/T7p1mU7hsM4owi/ic0aGBKP025Iok9G LKJcooP/A2c9dUV0FmygecRcbIAUaeJ27gotQkiJKbi0cl2gyTRlolKbC3R23K24LUhYfx4h pWj8CHoXEJrOdHO8Y0XH7059xzv5oxnXl2SD1dqA66INnX+vpW4TD2i+eQNPgfkECzKzGj+r KRfhdDZFBJj8/e131Y0t5cu+3Vok1FzBwgQqBnkA7dhBsQm3V0R8JTtMAqJGmyOcL+JCJAca 3Yi81yLyhmYzcRASLvJmoPTsDp2kZOdGr05Dt8aGPRJL33Jm+igfd8EgcDYtG6+F8MCBOult TTAu+QAijRPZv1KhEJXwUSke9HZvzo1tNTlY3h6plBsBufELu0mnqQvHZmfa5Ay99dF+dL1H WNp62+mTeHsX6v9EACH4S+Cw9Q1qJElFEu9/1vFNBmGY2vDv14gU2xEiS2eIvKiYl/b5Y85Q QLOHWV8up73KK5Qq/6bm4BqVd1rKGI9un8kezUQNGBKre2KKs6wquH8oynDP/baoYxEGMXBg GF/qjOC6OY+U7kNUW3N/A7J3M2VdOTLu3hVTzJMZdlMmmsg74azvZDV75dUigqXcwjE= Cc: Marcel Holtmann , Johan Hedberg , linux-bluetooth@vger.kernel.org, "linux-kernel@vger.kernel.org" Subject: re: Bluetooth: hci_qca: Add QCA Rome power off support to the qca_power_shutdown() Message-ID: Date: Fri, 10 Jul 2020 16:50:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.34 / 15.00 / 200.00 X-Rspamd-Queue-Id: 05B8B52E8A X-Rspamd-UID: 12460d Hi, Static analysis with Coverity has found a potential issue in drivers/bluetooth/hci_qca.c, function qca_power_shutdown. The commit that triggered the detection of the issue was as follows: commit 5559904ccc0867a0ce796761681e40defe4a5f44 Author: Rocky Liao Date: Wed Jan 15 16:55:50 2020 +0800 Bluetooth: hci_qca: Add QCA Rome power off support to the qca_power_shutdown() The issue is as follows: 1776 static void qca_power_shutdown(struct hci_uart *hu) 1777 { 1778 struct qca_serdev *qcadev; 1779 struct qca_data *qca = hu->priv; 1780 unsigned long flags; 1781 enum qca_btsoc_type soc_type = qca_soc_type(hu); 1782 deref_ptr_in_call: Dereferencing pointer hu->serdev. 1783 qcadev = serdev_device_get_drvdata(hu->serdev); ... 1797 /* Non-serdev device usually is powered by external power 1798 * and don't need additional action in driver for power down 1799 */ Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking hu->serdev suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 1800 if (!hu->serdev) 1801 return; There is a null check on hu->serdev on line 1800, however, in a previous statement in line 1783 hu->serdev is being dereferenced. Either hu->serdev is never null and the check is redundant, or it can be null and the null check needs to be moved to before line 1783. Colin Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QD8uL3+UCF+Y1wAAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 18:17:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OMLSLX+UCF//ZAEAgupzMw (envelope-from ); Fri, 10 Jul 2020 18:17:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AE0D952E91; Fri, 10 Jul 2020 18:16:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728127AbgGJQLW (ORCPT + 1 other); Fri, 10 Jul 2020 12:11:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727915AbgGJQLG (ORCPT ); Fri, 10 Jul 2020 12:11:06 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0286DC08C5DC; Fri, 10 Jul 2020 09:11:05 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id k18so4804257qtm.10; Fri, 10 Jul 2020 09:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y861TMCTvpy5racGqaIyx07iIXHTPCR4jkREHmo0X5A=; b=Wo/NdRrrqJwONxOj542PxpeohJSIuPR2d8D8UJ1NhigILOhHqNScqYXo4FuVZW2m3/ 4RPeZrUFgFC2r6OcczdiXafs3KAFyuFac9hPAx3VIFAquc2YLN5wZfJR2/AZuPOe/1IB 80KfxaoKKw1yQV2CGz+SqD5mNjW2/O6nfzxTVu+Rj1AiYHvNEG5AMiv3ZGINdzhcZQFi i24JSldDuvZ+7xCh4BqUniylYKz/mZrnfDtPiG32tlf5xy6WYBzVSuI3/TBYee1hqDwc kYBrYUkhB0uSwY/2RQ0g13WfbTUrqPAhz991mdMZprIDnTXUlkHEb6evurkptYXEuxON 7XdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y861TMCTvpy5racGqaIyx07iIXHTPCR4jkREHmo0X5A=; b=J+QlFEn0nDg0PmFFtiooI0TqHzzfeonzKbATDgoqyNfi72egORJrFMmsbueit2S7pz TmZQy/oDow4zkGl4gdlYU+/J8nbPHgUFW63LxJt3pGSxekN6vxyMsC+DJJhMaZbv6/tG noaJnMSzPt0au+B9KYEYk27nroLKBpeqZTO4LhpQU5DYDVZe4hLNRoSy7iQsoQFlg8bw 1P7wEPnkUTKeq87TPSy06kiUrgaRqfXzfYub1Wq/se3uiywFv2ETUuigfcqFtUY3fqdq L+JSu3C/5ZY1kf95j/bzUqaxezJj43s8lZm56xhr6VxbCSHN5wcrhlh0UwyhR6l3fDDw /iPg== X-Gm-Message-State: AOAM5337nmwuiiVT+cjxBGrO2GMRuMunhj9Q4X00PSRfnpRdVK81wXhx hQi+7bCJ8VPIbZehsxN5G5o1ZoJpiioU X-Google-Smtp-Source: ABdhPJzpzxl71N47ydC8eo3OOanW2bRGZsq9dHQ51PlHyGRFUZjTOqsaik7xr3g2ncxiofZqEgzKxA== X-Received: by 2002:ac8:7454:: with SMTP id h20mr26634878qtr.84.1594397465192; Fri, 10 Jul 2020 09:11:05 -0700 (PDT) Received: from localhost.localdomain (c-76-119-149-155.hsd1.ma.comcast.net. [76.119.149.155]) by smtp.gmail.com with ESMTPSA id o18sm7360586qkk.91.2020.07.10.09.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 09:11:04 -0700 (PDT) From: Peilin Ye To: Marcel Holtmann , Johan Hedberg Cc: Peilin Ye , "David S . Miller" , Jakub Kicinski , Russell King , Greg Kroah-Hartman , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH v3] net/bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt() Date: Fri, 10 Jul 2020 12:09:15 -0400 Message-Id: <20200710160915.228980-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200709130224.214204-1-yepeilin.cs@gmail.com> References: <20200709130224.214204-1-yepeilin.cs@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.70 / 15.00 / 200.00 X-Rspamd-Queue-Id: AE0D952E91 X-Rspamd-UID: 387142 Check upon `num_rsp` is insufficient. A malformed event packet with a large `num_rsp` number makes hci_extended_inquiry_result_evt() go out of bounds. Fix it. This patch fixes the following syzbot bug: https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2 Reported-by: syzbot+d8489a79b781849b9c46@syzkaller.appspotmail.com Cc: stable@vger.kernel.org Signed-off-by: Peilin Ye --- Change in v3: - Minimum `skb->len` requirement was 1 byte inaccurate since `info` starts from `skb->data + 1`. Fix it. Changes in v2: - Use `skb->len` instead of `skb->truesize` as the length limit. - Leave `num_rsp` as of type `int`. net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 03a0759f2fc2..13d8802b8137 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4375,7 +4375,7 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, BT_DBG("%s num_rsp %d", hdev->name, num_rsp); - if (!num_rsp) + if (!num_rsp || skb->len < num_rsp * sizeof(*info) + 1) return; if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) -- 2.25.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KBpXEemzCF8UkgEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 20:31:05 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id kH6HD+mzCF974wEAgupzMw (envelope-from ); Fri, 10 Jul 2020 20:31:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E6D715278A; Fri, 10 Jul 2020 20:30:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727091AbgGJSa6 (ORCPT + 1 other); Fri, 10 Jul 2020 14:30:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727082AbgGJSa6 (ORCPT ); Fri, 10 Jul 2020 14:30:58 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9018C08C5DC for ; Fri, 10 Jul 2020 11:30:57 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id c25so4872582otf.7 for ; Fri, 10 Jul 2020 11:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zEXb/I8QaIOCPUqUy5RRDx8pcQ8cX03xPqPuJYyOe9I=; b=UNvxclGJvm1WJ6Oz6ShYi9Qx76YzvjosdsJPnd0DTNLCDugTCCv/jrq/yqIXomGzlc 7WwtX3EY+aIH9oqaCDPj08RmXmrk1s5S9LHMjR/T496Wax//pZfOCTLit5WjFvyaAI0b muAY+k/3YDG32/0RsxErhSwsD2il4/qDOJaOYisULSHKkw8b/j4J/gcunqKN9g5NZEm9 +GFrhqaItfWJUcZf5be7LnLOEMZGC459aMtp4R8HYCvQgR1XzEDxHpLRiyl5V5iefxQs kPMM9malR8GvGffIkhMeLGkQAX0EPjhVPaZGiYVAv8YiPf+myiNlKbW56iCYB1/UQ5aF 1v0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zEXb/I8QaIOCPUqUy5RRDx8pcQ8cX03xPqPuJYyOe9I=; b=Ip6pwunfCqF4XdTQ1RRxbx1FjK0hgqfj0+f3SPFu6+9UPmjbracTIj/U8LY2Hn8Iqf Stp/kS3NpCa5uPn0mjlD9BMOaG3zGrdEX20/6Yv/gijjfch0NZs4A15xHgmqX4qcNJwE i8WRgpFPhp7rc5wqLHyt1rOCNb28C2f9gS540TxWwvY29NrftmNUlFUwzPfpFQagD87G dSs98UD+Efeeyy/gDe9AUHBVzXqgdfCRaDoUEL0OPkWj7fyR0qslboxzjw53HBRLhozb 7VbXc8oXTZ532XnTJO/pfwSYY6RFl7nWT18T4px63GZ4OMOHmr7CnNnBXsn+PWHDCSIw Pz1Q== X-Gm-Message-State: AOAM532AzemYVvgVNxiNEVxOk6KuNFe6+3bKCblBU5VUX80c5PeuDo6E Jsk5wUkEigrFhlRSwJ3PeFwCMXef203YW++QIZI= X-Google-Smtp-Source: ABdhPJyk2s9JGlHhrmsJ7/q5KgL1BqR2laTK34ry4BqAaIKmF9EdOM8ujiJe8da0PWpeJS0wCUnks2ZClY8bUBf4MT4= X-Received: by 2002:a9d:5e18:: with SMTP id d24mr19071803oti.88.1594405857197; Fri, 10 Jul 2020 11:30:57 -0700 (PDT) MIME-Version: 1.0 References: <20200710123105.Bluez.v1.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> <20200710123105.Bluez.v1.2.Ic16589fde45fac0c496dfca2fa27672059114c3b@changeid> In-Reply-To: <20200710123105.Bluez.v1.2.Ic16589fde45fac0c496dfca2fa27672059114c3b@changeid> From: Luiz Augusto von Dentz Date: Fri, 10 Jul 2020 11:30:45 -0700 Message-ID: Subject: Re: [Bluez PATCH v1 2/2] audio/transport: store volume for initialization To: Archie Pusaka Cc: linux-bluetooth , Archie Pusaka , Howard Chung Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: E6D715278A X-Rspamd-UID: 1bf57b Hi Archie, On Thu, Jul 9, 2020 at 9:32 PM Archie Pusaka wrote: > > From: Archie Pusaka > > Sometimes the response of RegisterNotification for volume change > event came before we create the transport for the corresponding > device. If that happens, we lose the volume information. After the > transport is created, the volume is also potentially stuck to an > uninitialized invalid value. The property Volume of > MediaTransport1 will also be left unaccessible. > > This patch stores the value of the volume notification response. > When the transport is initialized, we try to match the device > with the previously stored volume and assign that value instead. > > Reviewed-by: Howard Chung > --- > > profiles/audio/media.c | 17 +---------- > profiles/audio/transport.c | 61 ++++++++++++++++++++++++++++++++++++-- > 2 files changed, 60 insertions(+), 18 deletions(-) > > diff --git a/profiles/audio/media.c b/profiles/audio/media.c > index 993ecb3b3..be1ca18ee 100644 > --- a/profiles/audio/media.c > +++ b/profiles/audio/media.c > @@ -1202,27 +1202,12 @@ static uint32_t get_duration(void *user_data) > static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) > { > struct media_player *mp = user_data; > - GSList *l; > > if (mp->volume == volume) > return; > > mp->volume = volume; > - > - for (l = mp->adapter->endpoints; l; l = l->next) { > - struct media_endpoint *endpoint = l->data; > - struct media_transport *transport; > - > - /* Volume is A2DP only */ > - if (endpoint->sep == NULL) > - continue; > - > - transport = find_device_transport(endpoint, dev); > - if (transport == NULL) > - continue; > - > - media_transport_update_volume(transport, volume); > - } > + media_transport_update_device_volume(dev, volume); > } > > static bool media_player_send(struct media_player *mp, const char *name) > diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c > index a32073380..2fd04dd42 100644 > --- a/profiles/audio/transport.c > +++ b/profiles/audio/transport.c > @@ -56,6 +56,7 @@ > #define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1" > > #define UNINITIALIZED_VOLUME_VALUE 128 > +#define PEND_DEVICE_VOLUME_TIMEOUT 1 > > typedef enum { > TRANSPORT_STATE_IDLE, /* Not acquired and suspended */ > @@ -116,7 +117,13 @@ struct media_transport { > void *data; > }; > > +struct pending_device_volume { > + struct btd_device *device; > + uint8_t volume; > +}; > + > static GSList *transports = NULL; > +static GSList *pending_device_volumes; > > static const char *state2str(transport_state_t state) > { > @@ -810,6 +817,52 @@ static void source_state_changed(struct btd_service *service, > transport_update_playing(transport, FALSE); > } > > +static uint8_t get_pending_device_volume(struct btd_device *dev) > +{ > + GSList *l; > + > + for (l = pending_device_volumes; l; l = l->next) { > + struct pending_device_volume *pend = l->data; > + > + if (pend->device == dev) > + return pend->volume; > + } > + > + return UNINITIALIZED_VOLUME_VALUE; > +} > + > +static gboolean remove_pending_device_volume(gpointer user_data) > +{ > + struct pending_device_volume *pend = user_data; > + > + pending_device_volumes = g_slist_remove(pending_device_volumes, pend); > + g_free(pend); > + > + return FALSE; > +} > + > +static void add_pending_device_volume(struct btd_device *dev, uint8_t volume) > +{ > + GSList *l; > + struct pending_device_volume *pend; > + > + for (l = pending_device_volumes; l; l = l->next) { > + pend = l->data; > + > + if (pend->device == dev) { > + pend->volume = volume; > + return; > + } > + } > + > + pend = g_new0(struct pending_device_volume, 1); > + pend->device = dev; > + pend->volume = volume; > + g_timeout_add_seconds(PEND_DEVICE_VOLUME_TIMEOUT, > + remove_pending_device_volume, pend); > + pending_device_volumes = g_slist_append(pending_device_volumes, pend); > +} > + > static int media_transport_init_source(struct media_transport *transport) > { > struct btd_service *service; > @@ -827,7 +880,7 @@ static int media_transport_init_source(struct media_transport *transport) > transport->data = a2dp; > transport->destroy = destroy_a2dp; > > - a2dp->volume = UNINITIALIZED_VOLUME_VALUE; > + a2dp->volume = get_pending_device_volume(transport->device); > transport->sink_watch = sink_add_state_cb(service, sink_state_changed, > transport); > > @@ -990,9 +1043,13 @@ void media_transport_update_device_volume(struct btd_device *dev, > continue; > > /* Volume is A2DP only */ > - if (media_endpoint_get_sep(transport->endpoint)) > + if (media_endpoint_get_sep(transport->endpoint)) { > media_transport_update_volume(transport, volume); > + return; > + } > } > + > + add_pending_device_volume(dev, volume); > } > > bool media_transport_volume_valid(uint8_t volume) > -- > 2.27.0.383.g050319c2ae-goog This sounds a little too complicated, what I would have done it is to locate the media_player (if there is one), and then pass its stored volume (mp->volume) to media_transport_create so instead of always initialize it 127 we actually pass value if it was already fetched and stored by the media_player instance. Btw, I guess once we merge this changes we should close the following bug: https://github.com/bluez/bluez/issues/17 -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WLFSA+K6CF8s2AEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 21:00:50 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id KNjBAeK6CF/ECgEADc0bRg (envelope-from ); Fri, 10 Jul 2020 21:00:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BB0B85291E; Fri, 10 Jul 2020 21:00:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727082AbgGJTAn (ORCPT + 1 other); Fri, 10 Jul 2020 15:00:43 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:38861 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726872AbgGJTAl (ORCPT ); Fri, 10 Jul 2020 15:00:41 -0400 Received: from classic (lns-bzn-39-82-255-60-242.adsl.proxad.net [82.255.60.242]) (Authenticated sender: hadess@hadess.net) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 91AED200003; Fri, 10 Jul 2020 19:00:35 +0000 (UTC) Message-ID: <3f9aeb5d7aa896770946a8c04bd8483e9d7ba4f3.camel@hadess.net> Subject: Re: Temporary device removal during discovery From: Bastien Nocera To: Luiz Augusto von Dentz Cc: Andrey Batyiev , linux-bluetooth Date: Fri, 10 Jul 2020 21:00:35 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: BB0B85291E X-Rspamd-UID: 0283b1 On Fri, 2020-07-10 at 11:06 -0700, Luiz Augusto von Dentz wrote: > Hi Bastien, > > On Thu, Jul 9, 2020 at 1:26 AM Bastien Nocera > wrote: > > On Thu, 2020-07-09 at 01:57 +0300, Andrey Batyiev wrote: > > > Hi Luiz, > > > > > > On Thu, Jul 9, 2020 at 12:14 AM Luiz Augusto von Dentz > > > wrote: > > > > The delta logic might be a nice addition as a separate patch, > > > > it is > > > > more for detecting devices disappearing then actually cleanup > > > > during > > > > power off. > > > No-no, it's not about adapter powering off. > > > > > > I meant that (external) devices never disappear from the bluez > > > device > > > list during the discovery, > > > even if the (external) devices are turned off (i.e. they should > > > be > > > purged by bluez). > > > > > > So: > > > - bluez is central > > > - bluez is discovering > > > - peripheral appear for a moment, than disappear (i.e. peripheral > > > would be turned off) > > > - bluez would not remove device from the list (at least until > > > discovery is stopped) > > > > > > Use case: > > > - bluez is monitoring environment (discovering literally forever) > > > - peripherals are brought in and out of bluez visibility range > > > - bluez list of visible devices grows infinitely and causes > > > problems > > > (hundreds of devices) > > > > I'd also expect devices that are recently discovered to disappear > > if > > they haven't replied to a discovery in 30 seconds. It would stop > > GNOME's Bluetooth Settings's Bluetooth list forever expanding. > > > > Or we need to give the ability for front-ends to do that by > > exporting > > the "last seen" dates. > > I am fine with that as well, 30 seconds doesn't sound too bad even > for > cleanup temporary devices as the current 3 minutes seems awful long > sometimes, we could perhaps have a filter for configuring that though > so if the application wants to have its own timeout, the only problem > is if there are multiple application doing that on parallel we would > need a strategy on how to handle that. In which case it might be easier to export that last seen date, otherwise that's just a lot of moving parts inside bluetoothd when we could filter it trivially in the front-ends. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WJCgKyzPCF+pPwAAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 22:27:24 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id IMbqKSzPCF8LtQEA0J78UA (envelope-from ); Fri, 10 Jul 2020 22:27:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 38FA752C29; Fri, 10 Jul 2020 22:27:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727038AbgGJU1S (ORCPT + 1 other); Fri, 10 Jul 2020 16:27:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbgGJU1S (ORCPT ); Fri, 10 Jul 2020 16:27:18 -0400 Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BD16C08C5DC for ; Fri, 10 Jul 2020 13:27:18 -0700 (PDT) Received: by mail-oo1-xc31.google.com with SMTP id p26so1236408oos.7 for ; Fri, 10 Jul 2020 13:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GlueREa58b7R7VgL4TssSAMNWNyU4cNA/gxFnLfVl+c=; b=HVBBdLnXBVyVmBkn+U8swcNvwrekcAUYiq9XAL/9Jx17Y/CEgfq1lwNp4dB/qhNYmR Nxk08EfnmjL8vG0XO8JL3nCTjjzhpdysRO0bPoCo4pBhMkZXJHHKU9BMfN0IUwcYa7ac Js2kOpqY4vDJSB1sso6tQ/Skl3LGJDnETckjEuuleTUgIpfhIF6ytiCEi/DiaYyivSZx 55bxfLddOXGmC/76sAQT6ONhcqtZY/Nr+ZuYx76BsvG6p9f9O5U1ZHuy/iOnqjH74btI fRFu4ZxGm/nvUutVVSK8CgOjJnD+lRCzNhVYCltHpAAWT6cPpMeOlGuQiGWZVyHNwigg MwSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GlueREa58b7R7VgL4TssSAMNWNyU4cNA/gxFnLfVl+c=; b=nRXiOzkt9PwQIEd/pOqKOPoW4vDacg2wPJD8rw9Ob4onyFMpKI3YkEJCuADJr+YohN 1o9asr53WICAjAmfqawIKVXOcxLC8H2jRQ69N6yN/VRGO3ZyEfszf7rHEnNCAYE/laPK H9wm1ZPFYs4u6fpYz+Ap3jGFbed++2fGoE4iYhEGHwHSrzTR2tTD+1ab4JdzfZ+HmXKn WDEJRx7YMeP/h3DEkwy55na6cxxC7oMWEG7gF6azV5d3Nr2qzditW0EhLALHpIiFJJmT L/x7XRmBeSmqqbCgH0/xIv7cJ854LgzZyUXi7+5ZCuVIFWeCqB/W0VLAkLttwUU5nu7g U/iw== X-Gm-Message-State: AOAM532XXNcKPpQzOI5CwbHeCp7uU6uIo38uEL8LwBwp3TV1K8fNhDck HU6jRjTr4bEElTNz/+ndrTY1UqyIIFLE2GaqhES37JDD X-Google-Smtp-Source: ABdhPJyzxmQbbgtFuQaFSVkySsG4ZUkgrRodCAHhtsAFP0B5YZr3/TaXUnPjZL0SR2iNG/Se/hJ5rLJQVSNL6X9vCA8= X-Received: by 2002:a4a:b284:: with SMTP id k4mr22935561ooo.49.1594412836576; Fri, 10 Jul 2020 13:27:16 -0700 (PDT) MIME-Version: 1.0 References: <3f9aeb5d7aa896770946a8c04bd8483e9d7ba4f3.camel@hadess.net> In-Reply-To: <3f9aeb5d7aa896770946a8c04bd8483e9d7ba4f3.camel@hadess.net> From: Luiz Augusto von Dentz Date: Fri, 10 Jul 2020 13:27:05 -0700 Message-ID: Subject: Re: Temporary device removal during discovery To: Bastien Nocera Cc: Andrey Batyiev , linux-bluetooth Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 38FA752C29 X-Rspamd-UID: 6c03e1 Hi Bastien, On Fri, Jul 10, 2020 at 12:00 PM Bastien Nocera wrote: > > On Fri, 2020-07-10 at 11:06 -0700, Luiz Augusto von Dentz wrote: > > Hi Bastien, > > > > On Thu, Jul 9, 2020 at 1:26 AM Bastien Nocera > > wrote: > > > On Thu, 2020-07-09 at 01:57 +0300, Andrey Batyiev wrote: > > > > Hi Luiz, > > > > > > > > On Thu, Jul 9, 2020 at 12:14 AM Luiz Augusto von Dentz > > > > wrote: > > > > > The delta logic might be a nice addition as a separate patch, > > > > > it is > > > > > more for detecting devices disappearing then actually cleanup > > > > > during > > > > > power off. > > > > No-no, it's not about adapter powering off. > > > > > > > > I meant that (external) devices never disappear from the bluez > > > > device > > > > list during the discovery, > > > > even if the (external) devices are turned off (i.e. they should > > > > be > > > > purged by bluez). > > > > > > > > So: > > > > - bluez is central > > > > - bluez is discovering > > > > - peripheral appear for a moment, than disappear (i.e. peripheral > > > > would be turned off) > > > > - bluez would not remove device from the list (at least until > > > > discovery is stopped) > > > > > > > > Use case: > > > > - bluez is monitoring environment (discovering literally forever) > > > > - peripherals are brought in and out of bluez visibility range > > > > - bluez list of visible devices grows infinitely and causes > > > > problems > > > > (hundreds of devices) > > > > > > I'd also expect devices that are recently discovered to disappear > > > if > > > they haven't replied to a discovery in 30 seconds. It would stop > > > GNOME's Bluetooth Settings's Bluetooth list forever expanding. > > > > > > Or we need to give the ability for front-ends to do that by > > > exporting > > > the "last seen" dates. > > > > I am fine with that as well, 30 seconds doesn't sound too bad even > > for > > cleanup temporary devices as the current 3 minutes seems awful long > > sometimes, we could perhaps have a filter for configuring that though > > so if the application wants to have its own timeout, the only problem > > is if there are multiple application doing that on parallel we would > > need a strategy on how to handle that. > > In which case it might be easier to export that last seen date, > otherwise that's just a lot of moving parts inside bluetoothd when we > could filter it trivially in the front-ends. > Right, we still need to clean up the temporary devices though, but perhaps adding a LastSeen property is not a bad idea after all so applications can do this sort of filtering themselves. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MCdGNRSkCF8nOwEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 19:23:32 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id ECZaMxSkCF+z+wAAlScrYA (envelope-from ); Fri, 10 Jul 2020 19:23:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E9CC452E1F; Fri, 10 Jul 2020 19:23:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727819AbgGJRIx convert rfc822-to-8bit (ORCPT + 1 other); Fri, 10 Jul 2020 13:08:53 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:42254 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbgGJRIx (ORCPT ); Fri, 10 Jul 2020 13:08:53 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id B137CCED26; Fri, 10 Jul 2020 19:18:48 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [Linux-kernel-mentees] [PATCH v3] net/bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt() From: Marcel Holtmann In-Reply-To: <20200710160915.228980-1-yepeilin.cs@gmail.com> Date: Fri, 10 Jul 2020 19:08:51 +0200 Cc: Johan Hedberg , "David S. Miller" , Jakub Kicinski , Russell King , Greg Kroah-Hartman , Bluetooth Kernel Mailing List , "open list:NETWORKING [GENERAL]" , syzkaller-bugs@googlegroups.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <43E6945B-1FFE-4283-9F1B-E84AFDCB528F@holtmann.org> References: <20200709130224.214204-1-yepeilin.cs@gmail.com> <20200710160915.228980-1-yepeilin.cs@gmail.com> To: Peilin Ye X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: E9CC452E1F X-Rspamd-UID: bb7ab0 Hi Peilin, > Check upon `num_rsp` is insufficient. A malformed event packet with a > large `num_rsp` number makes hci_extended_inquiry_result_evt() go out > of bounds. Fix it. > > This patch fixes the following syzbot bug: > > https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2 > > Reported-by: syzbot+d8489a79b781849b9c46@syzkaller.appspotmail.com > Cc: stable@vger.kernel.org > Signed-off-by: Peilin Ye > --- > Change in v3: > - Minimum `skb->len` requirement was 1 byte inaccurate since `info` > starts from `skb->data + 1`. Fix it. > > Changes in v2: > - Use `skb->len` instead of `skb->truesize` as the length limit. > - Leave `num_rsp` as of type `int`. > > net/bluetooth/hci_event.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eCDNDaGkCF8nOwEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 19:25:53 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 4D9HDKGkCF97jAEAlp8NpQ (envelope-from ); Fri, 10 Jul 2020 19:25:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C744052A3B; Fri, 10 Jul 2020 19:25:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727818AbgGJRK5 convert rfc822-to-8bit (ORCPT + 1 other); Fri, 10 Jul 2020 13:10:57 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:43121 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbgGJRK5 (ORCPT ); Fri, 10 Jul 2020 13:10:57 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 755B8CED27; Fri, 10 Jul 2020 19:20:52 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Bluetooth: Use fallthrough pseudo-keyword From: Marcel Holtmann In-Reply-To: <20200708202650.GA3866@embeddedor> Date: Fri, 10 Jul 2020 19:10:55 +0200 Cc: Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20200708202650.GA3866@embeddedor> To: "Gustavo A. R. Silva" X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.20 / 15.00 / 200.00 X-Rspamd-Queue-Id: C744052A3B X-Rspamd-UID: f94318 Hi Gustavo, > Replace the existing /* fall through */ comments and its variants with > the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary > fall-through markings when it is the case. > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through > > Signed-off-by: Gustavo A. R. Silva > --- > drivers/bluetooth/bcm203x.c | 2 +- > drivers/bluetooth/bluecard_cs.c | 2 -- > drivers/bluetooth/hci_ll.c | 2 +- > drivers/bluetooth/hci_qca.c | 8 +------- > 4 files changed, 3 insertions(+), 11 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gHbdJiOlCF/0XgEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 19:28:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id KGQmJSOlCF/fqwEAgupzMw (envelope-from ); Fri, 10 Jul 2020 19:28:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BF6F152F17; Fri, 10 Jul 2020 19:27:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728209AbgGJRLE convert rfc822-to-8bit (ORCPT + 1 other); Fri, 10 Jul 2020 13:11:04 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:38531 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728048AbgGJRLB (ORCPT ); Fri, 10 Jul 2020 13:11:01 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 455FBCED28; Fri, 10 Jul 2020 19:20:57 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Bluetooth: core: Use fallthrough pseudo-keyword From: Marcel Holtmann In-Reply-To: <20200708201823.GA400@embeddedor> Date: Fri, 10 Jul 2020 19:11:00 +0200 Cc: Johan Hedberg , "David S. Miller" , Jakub Kicinski , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <506A63D3-4B3E-4148-B862-2CB5418FF84A@holtmann.org> References: <20200708201823.GA400@embeddedor> To: "Gustavo A. R. Silva" X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: BF6F152F17 X-Rspamd-UID: 607b51 Hi Gustavo, > Replace the existing /* fall through */ comments and its variants with > the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary > fall-through markings when it is the case. > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through > > Signed-off-by: Gustavo A. R. Silva > --- > net/bluetooth/hci_event.c | 4 ++-- > net/bluetooth/hci_sock.c | 3 +-- > net/bluetooth/l2cap_core.c | 19 +++++++++---------- > net/bluetooth/l2cap_sock.c | 4 ++-- > net/bluetooth/mgmt.c | 4 ++-- > net/bluetooth/smp.c | 2 +- > 6 files changed, 17 insertions(+), 19 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MDMbJzOlCF/0XgEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 19:28:19 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id aKN0JTOlCF8DEwEA0J78UA (envelope-from ); Fri, 10 Jul 2020 19:28:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BEACC5080C; Fri, 10 Jul 2020 19:28:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728172AbgGJRLE convert rfc822-to-8bit (ORCPT + 1 other); Fri, 10 Jul 2020 13:11:04 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:58642 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbgGJRK7 (ORCPT ); Fri, 10 Jul 2020 13:10:59 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 0C750CED27; Fri, 10 Jul 2020 19:20:55 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Bluetooth: RFCOMM: Use fallthrough pseudo-keyword From: Marcel Holtmann In-Reply-To: <20200708202505.GA1733@embeddedor> Date: Fri, 10 Jul 2020 19:10:57 +0200 Cc: Johan Hedberg , "David S. Miller" , Jakub Kicinski , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <1DB804F8-B14A-4A27-BB33-8622929F20CF@holtmann.org> References: <20200708202505.GA1733@embeddedor> To: "Gustavo A. R. Silva" X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: BEACC5080C X-Rspamd-UID: 17e5f9 Hi Gustavo, > Replace the existing /* fall through */ comments and its variants with > the new pseudo-keyword macro fallthrough[1]. > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through > > Signed-off-by: Gustavo A. R. Silva > --- > net/bluetooth/rfcomm/core.c | 2 +- > net/bluetooth/rfcomm/sock.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GK4oJU+mCF8nOwEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 19:33:03 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id YEfVI0+mCF/RDQEA0J78UA (envelope-from ); Fri, 10 Jul 2020 19:33:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B6DC952CF4; Fri, 10 Jul 2020 19:32:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728179AbgGJRP7 (ORCPT + 1 other); Fri, 10 Jul 2020 13:15:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:46696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728054AbgGJRP5 (ORCPT ); Fri, 10 Jul 2020 13:15:57 -0400 Received: from embeddedor (unknown [200.39.25.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F2C9D20674; Fri, 10 Jul 2020 17:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594401357; bh=8BlM6oYrDWVXFwdkiKVw0CvLzU+HCpGIc+rJuBWYCxE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fBC59ssUIz4aHv6uokkVYB3PO6+eBcxcrP0+g0UwBhDwXCqNru5WyOjP0Q62C4Oxl lSyzkqnvHikOT7xhtOhttveiJ0tzj3HkNXMWNhLMDB+Dmq313C7yuDpD4Tw8hKONYw BWZrxO4wBDXLzZLpeHlDOWFNS7HifqqNwwk19fWg= Date: Fri, 10 Jul 2020 12:21:31 -0500 From: "Gustavo A. R. Silva" To: Marcel Holtmann Cc: Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Bluetooth: Use fallthrough pseudo-keyword Message-ID: <20200710172131.GA21202@embeddedor> References: <20200708202650.GA3866@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -7.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: B6DC952CF4 X-Rspamd-UID: 0ad45a On Fri, Jul 10, 2020 at 07:10:55PM +0200, Marcel Holtmann wrote: > Hi Gustavo, > > > Replace the existing /* fall through */ comments and its variants with > > the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary > > fall-through markings when it is the case. > > > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through > > > > Signed-off-by: Gustavo A. R. Silva > > --- > > drivers/bluetooth/bcm203x.c | 2 +- > > drivers/bluetooth/bluecard_cs.c | 2 -- > > drivers/bluetooth/hci_ll.c | 2 +- > > drivers/bluetooth/hci_qca.c | 8 +------- > > 4 files changed, 3 insertions(+), 11 deletions(-) > > patch has been applied to bluetooth-next tree. > Thanks, Marcel. -- Gustavo Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MDy+FpqmCF8nOwEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 19:34:18 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 4OS3FJqmCF+AHAEA0J78UA (envelope-from ); Fri, 10 Jul 2020 19:34:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C564B53078; Fri, 10 Jul 2020 19:34:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbgGJRUc convert rfc822-to-8bit (ORCPT + 1 other); Fri, 10 Jul 2020 13:20:32 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:35994 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726977AbgGJRUb (ORCPT ); Fri, 10 Jul 2020 13:20:31 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 93CCCCED26; Fri, 10 Jul 2020 19:30:27 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [Bluez PATCH] doc: Add Suspend and Resume events From: Marcel Holtmann In-Reply-To: <20200709140928.Bluez.1.I9181af521cf0fba8f4315c9b89975848d437d6dd@changeid> Date: Fri, 10 Jul 2020 19:20:30 +0200 Cc: Luiz Augusto von Dentz , chromeos-bluetooth-upstreaming , Bluetooth Kernel Mailing List , Alain Michaud , Miao-chen Chou Content-Transfer-Encoding: 8BIT Message-Id: <22D4931F-A15D-4ECE-9EBC-D080EF6430E2@holtmann.org> References: <20200709140928.Bluez.1.I9181af521cf0fba8f4315c9b89975848d437d6dd@changeid> To: Abhishek Pandit-Subedi X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: C564B53078 X-Rspamd-UID: 555cf5 Hi Abhishek, > Add Controller Suspend Event and Controller Resume Event to identify > suspend or resume of the Bluetooth stack has occurred. > > Also update Device Disconnected Event to indicate a new disconnect > reason: "Connection terminated by local host for suspend" > > Reviewed-by: Alain Michaud > Reviewed-by: Miao-chen Chou > --- > > doc/mgmt-api.txt | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 53 insertions(+) > > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt > index ca0d38469..f79c0222c 100644 > --- a/doc/mgmt-api.txt > +++ b/doc/mgmt-api.txt > @@ -3834,6 +3834,7 @@ Device Disconnected Event > 2 Connection terminated by local host > 3 Connection terminated by remote host > 4 Connection terminated due to authentication failure > + 5 Connection terminated by local host for suspend > > Note that the local/remote distinction just determines which side > terminated the low-level connection, regardless of the > @@ -4577,3 +4578,55 @@ Advertisement Monitor Removed Event > > The event will only be sent to management sockets other than the > one through which the command was sent. > + > + > +Controller Suspend Event > +======================== > + > + Event code: 0x002d > + Controller Index: > + Event Parameters: Suspend_State (1 octet) > + > + This event indicates that the controller is suspended for host suspend. > + > + Possible values for the Suspend_State parameter: > + 0 Running (not disconnected) > + 1 Disconnected and not scanning > + 2 Page scanning and/or passive scanning. > + > + The value 0 is used for the running state and may be sent if the > + controller could not be configured to suspend properly. does it make sense to send a suspend event with state suspend not succeeded. That doesn’t really fit well. > + > + This event will be sent to all management sockets. > + > + > +Controller Resume Event > +======================= > + > + Event code: 0x002e > + Controller Index: > + Event Parameters: Address (6 octets) > + Address_Type (1 octet) > + Wake_Reason (1 octet) > + > + This event indicates that the controller has resumed from suspend. > + > + Possible values for the Wake_Reason parameter: > + 0 Unexpected Event > + 1 Resume from non-Bluetooth wake source > + 2 Connection Request (BR/EDR) > + 3 Connection Complete (BR/EDR) > + 4 LE Advertisement > + 5 LE Direct Advertisement > + 6 LE Extended Advertisement > + > + We expect that only peer reconnections should wake us from the suspended > + state. Any other events that cause a wakeup will be marked as Unexpected > + Event. > + > + If the Wake_Reason was any of the expected wake reasons (values 2-6), > + the address of the peer device that caused the event will be shared in > + Address and Address_Type. Otherwise, Address and Address_Type will both > + be zero. So I would be using Wake_Reason as first argument. However do you need all this distinction. For example the Device Connected event could gain an extra Flags bit for wakeup. I would especially not make any distinction between the advertising types. I am in principal fine telling bluetoothd when suspend / resume happened, but letting HCI event specifics bleed into the mgmt API is not really helpful. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iIE7Ac+mCF9FaAEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 19:35:11 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id +EY6O86mCF8DEwEA0J78UA (envelope-from ); Fri, 10 Jul 2020 19:35:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5126F52F82; Fri, 10 Jul 2020 19:34:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728168AbgGJRVt convert rfc822-to-8bit (ORCPT + 1 other); Fri, 10 Jul 2020 13:21:49 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:41325 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbgGJRVt (ORCPT ); Fri, 10 Jul 2020 13:21:49 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 5FB0ECED26; Fri, 10 Jul 2020 19:31:44 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Replace HTTP links with HTTPS ones: BLUETOOTH SUBSYSTEM From: Marcel Holtmann In-Reply-To: <20200708133638.14589-1-grandmaster@al2klimov.de> Date: Fri, 10 Jul 2020 19:21:46 +0200 Cc: Johan Hedberg , "David S. Miller" , Jakub Kicinski , Bluetooth Kernel Mailing List , "open list:NETWORKING [GENERAL]" , linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <330C715F-ADB9-42B7-93CF-7605F5E9A9D2@holtmann.org> References: <20200708133638.14589-1-grandmaster@al2klimov.de> To: "Alexander A. Klimov" X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5126F52F82 X-Rspamd-UID: d0df6f Hi Alexander, > Rationale: > Reduces attack surface on kernel devs opening the links for MITM > as HTTPS traffic is much harder to manipulate. > > Deterministic algorithm: > For each file: > If not .svg: > For each line: > If doesn't contain `\bxmlns\b`: > For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: > If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: > If both the HTTP and HTTPS versions > return 200 OK and serve the same content: > Replace HTTP with HTTPS. > > Signed-off-by: Alexander A. Klimov > --- > Continuing my work started at 93431e0607e5. > See also: git log --oneline '--author=Alexander A. Klimov ' v5.7..master > (Actually letting a shell for loop submit all this stuff for me.) > > If there are any URLs to be removed completely or at least not HTTPSified: > Just clearly say so and I'll *undo my change*. > See also: https://lkml.org/lkml/2020/6/27/64 > > If there are any valid, but yet not changed URLs: > See: https://lkml.org/lkml/2020/6/26/837 > > If you apply the patch, please let me know. > > > net/bluetooth/Kconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QDryC4qqCF9FaAEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 19:51:06 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id GHUYCoqqCF8L+gAAlScrYA (envelope-from ); Fri, 10 Jul 2020 19:51:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5E9B5A31B0; Fri, 10 Jul 2020 19:50:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728044AbgGJRui (ORCPT + 1 other); Fri, 10 Jul 2020 13:50:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbgGJRui (ORCPT ); Fri, 10 Jul 2020 13:50:38 -0400 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E71E6C08C5DC for ; Fri, 10 Jul 2020 10:50:37 -0700 (PDT) Received: by mail-vs1-xe42.google.com with SMTP id a17so3430630vsq.6 for ; Fri, 10 Jul 2020 10:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=4rzocPAk8ZjAvLrdFpel7D1BLIGZFyXCyq25N8W6QTc=; b=af2/oRs1dUTONsRkDgibkWKjUlmBXuzOVfP0iIqcwQZRwwsT7GJURaRfW5tfIrVeMM GlUNJ6HqrtqLyH3UMDrtsEiJjXwRxTPbdjLy9925t9XcZhdUHnWxRJWBPdQGyR68lyz9 72qG8aDWiFlnQ5JoLd61PyXs/oNv64jPPmXhE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=4rzocPAk8ZjAvLrdFpel7D1BLIGZFyXCyq25N8W6QTc=; b=Qc7Gj/oAtF+HwO/Iw03T/TfBumXublX3aqAAsCwMP29W1+4a4YkARr5hnV5Ccn251P 5SYcyK10Kx9eGDH9eFBgX0nmTsGqw3RyXZo1DdBOXNBsFbXW4lhx9B6LfqfkvlpqRTLE tzeOdAlbrzgAcrWe8viOQ6r0nmqzebnCdoL37qNxIbLK14oEjImSulwYJh/RQFO1nkTM i6sqUDND/aRAH5ppkRC4UvpTb/GRt75QpYinhBFQwmRA9zjblZ60hc41RtN2lCe5GOVB XdMZSpi+ZZ1OH8CNYKGWYR2OzDZPDcMXNXt2z9UEgNERE3abOyfi9GygmBcV/p8UIvma elNQ== X-Gm-Message-State: AOAM531RcEd8fC9TSOtQ8gTibjjRVOzUB7lmiTDcNLzM6kNRZPlj5LPB uTcwy8Z8Ge+hm18Mw/NUtRafUb4n5H1cS1bv0ku+qg== X-Google-Smtp-Source: ABdhPJyKGKy71roZteV3huBY9UQjAPpitJCambFzQ4Joq33T5VS2hYF6ZJd3PXQXOBnIfvN1WjxleWSNyTNUfbZcSyo= X-Received: by 2002:a67:fd0b:: with SMTP id f11mr49031013vsr.93.1594403437055; Fri, 10 Jul 2020 10:50:37 -0700 (PDT) MIME-Version: 1.0 References: <20200709140928.Bluez.1.I9181af521cf0fba8f4315c9b89975848d437d6dd@changeid> <22D4931F-A15D-4ECE-9EBC-D080EF6430E2@holtmann.org> In-Reply-To: <22D4931F-A15D-4ECE-9EBC-D080EF6430E2@holtmann.org> From: Abhishek Pandit-Subedi Date: Fri, 10 Jul 2020 10:50:25 -0700 Message-ID: Subject: Re: [Bluez PATCH] doc: Add Suspend and Resume events To: Marcel Holtmann Cc: Luiz Augusto von Dentz , chromeos-bluetooth-upstreaming , Bluetooth Kernel Mailing List , Alain Michaud , Miao-chen Chou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5E9B5A31B0 X-Rspamd-UID: e7cf92 Hi Marcel, On Fri, Jul 10, 2020 at 10:20 AM Marcel Holtmann wrot= e: > > Hi Abhishek, > > > Add Controller Suspend Event and Controller Resume Event to identify > > suspend or resume of the Bluetooth stack has occurred. > > > > Also update Device Disconnected Event to indicate a new disconnect > > reason: "Connection terminated by local host for suspend" > > > > Reviewed-by: Alain Michaud > > Reviewed-by: Miao-chen Chou > > --- > > > > doc/mgmt-api.txt | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 53 insertions(+) > > > > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt > > index ca0d38469..f79c0222c 100644 > > --- a/doc/mgmt-api.txt > > +++ b/doc/mgmt-api.txt > > @@ -3834,6 +3834,7 @@ Device Disconnected Event > > 2 Connection terminated by local host > > 3 Connection terminated by remote host > > 4 Connection terminated due to authentication failu= re > > + 5 Connection terminated by local host for suspend > > > > Note that the local/remote distinction just determines which side > > terminated the low-level connection, regardless of the > > @@ -4577,3 +4578,55 @@ Advertisement Monitor Removed Event > > > > The event will only be sent to management sockets other than the > > one through which the command was sent. > > + > > + > > +Controller Suspend Event > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D > > + > > + Event code: 0x002d > > + Controller Index: > > + Event Parameters: Suspend_State (1 octet) > > + > > + This event indicates that the controller is suspended for host su= spend. > > + > > + Possible values for the Suspend_State parameter: > > + 0 Running (not disconnected) > > + 1 Disconnected and not scanning > > + 2 Page scanning and/or passive scanning. > > + > > + The value 0 is used for the running state and may be sent if the > > + controller could not be configured to suspend properly. > > does it make sense to send a suspend event with state suspend not succeed= ed. That doesn=E2=80=99t really fit well. We don't block suspend if preparing for suspend fails so it's useful to know when a suspend was attempted. Also, having the suspend event emitted acts as an anchor that lets us search through the HCI trace quickly and observe what happened around it to cause an unexpected state. > > > + > > + This event will be sent to all management sockets. > > + > > + > > +Controller Resume Event > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > + Event code: 0x002e > > + Controller Index: > > + Event Parameters: Address (6 octets) > > + Address_Type (1 octet) > > + Wake_Reason (1 octet) > > + > > + This event indicates that the controller has resumed from suspend= . > > + > > + Possible values for the Wake_Reason parameter: > > + 0 Unexpected Event > > + 1 Resume from non-Bluetooth wake source > > + 2 Connection Request (BR/EDR) > > + 3 Connection Complete (BR/EDR) > > + 4 LE Advertisement > > + 5 LE Direct Advertisement > > + 6 LE Extended Advertisement > > + > > + We expect that only peer reconnections should wake us from the su= spended > > + state. Any other events that cause a wakeup will be marked as Une= xpected > > + Event. > > + > > + If the Wake_Reason was any of the expected wake reasons (values 2= -6), > > + the address of the peer device that caused the event will be shar= ed in > > + Address and Address_Type. Otherwise, Address and Address_Type wil= l both > > + be zero. > > So I would be using Wake_Reason as first argument. However do you need al= l this distinction. For example the Device Connected event could gain an ex= tra Flags bit for wakeup. I would especially not make any distinction betwe= en the advertising types. > > I am in principal fine telling bluetoothd when suspend / resume happened,= but letting HCI event specifics bleed into the mgmt API is not really help= ful. Sure, we can reduce the wake_reason to 0 =3D Unexpected, 1 =3D Non bluetooth source, 2 =3D Device Connection. I think a distinct event is preferable to adding another bit to Device Connected. a) It acts as an anchor point for searching an HCI trace for suspend occurr= ing. b) It is resilient to failures in any of the connection events (since the Device Connected event sometimes requires subsequent calls to the controller before the connection completes). c) Properly captures wake from unexpected events. This is really nice to understand what events came BEFORE the PM_SUSPEND_DONE event was sent by the kernel and would help identify suspend bugs and regressions. > > Regards > > Marcel > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OGxrCUyuCF9FaAEAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 20:07:08 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WAjoB0yuCF/UzAEAgupzMw (envelope-from ); Fri, 10 Jul 2020 20:07:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 84BA6A315D; Fri, 10 Jul 2020 20:06:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727046AbgGJSGf (ORCPT + 1 other); Fri, 10 Jul 2020 14:06:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726920AbgGJSGf (ORCPT ); Fri, 10 Jul 2020 14:06:35 -0400 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E963BC08C5DC for ; Fri, 10 Jul 2020 11:06:34 -0700 (PDT) Received: by mail-oi1-x22b.google.com with SMTP id t198so5496708oie.7 for ; Fri, 10 Jul 2020 11:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Mwwxt+6Dm0ceODIWJuacgu8G2+IT6Ypl2+OAhI2wq48=; b=dXsLtgdIutKGrFJ+t1nZg/NvSd2nia9K52l7u1DSdYJeipCK2p/LXuLdR8DopSq8Ey aFTkYa9JUaVVuyPbKqYShTkb6nutyBzRaDWAlTqAi7Qw3JZp7D4rd7isGjIPfqS5qTYx Rm5JbyXzvDrUPUNqgQ0p6VNOyrAthJddWV6o7f9vm1HX92GXRz5AmAWd/Z+WCGZxFAAD BJ+VN4c7NJOrsGqRUeJuiGTjBgWNiK1ZE5vz4jS4mMdOe6AzPVA1sGXtlatVEOBSgL7s J7h9T0zmaAN+U9ofTjzJ3ZQxJpNPF1cweR3q68fE7ZEAeiy4pcuWY5Q+C+meFoJgP67+ bAuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Mwwxt+6Dm0ceODIWJuacgu8G2+IT6Ypl2+OAhI2wq48=; b=ctFA+DXGfRF4zi8d1AvwxpUzjUbpHJAUtFKlVxHgt4zszZChXeSYRl8F4y4OkTsMRq pclDxJzaqRQuqQ94Ydlo1okFiJbHK1O4i+i2mxyRd32OBHc7PZuwlFzQ3q5snD4JbsPD 5u77+Jx9Kz3evI3KsZDOMVOfQrDTXxvmCanSvL6fIQ4ZE8/LzpZsFSxPWpMVH+jsyTW+ uv3bdrhKvmHoAgw+uUJjk9wL/MGt+ge///XC0iMbZXg/GhqsVO15IZdT7trYbUnqDISq SHN568WjDbx+SdcO/4gpgp6MJFNQgWzx1Zj7sU8X5S6sPtCMQVEeg+EmdfJqqmEXqn8B UV2Q== X-Gm-Message-State: AOAM532YzYRmt//Z/p8mWopeZTvGFeUuURcuWkRXW0CbAOLmU0a331Oc SJLPGE+5L2gH0SA9TYtoSwg15NRNYRM3m24fd1w= X-Google-Smtp-Source: ABdhPJyaZ42ywxpwRjsUjOjUP22rq2zM7MRTu54uRilzOkq0s0p5vGnKyQfobFbk+49P1rvCvrxP9wqPuZtteWTRUmY= X-Received: by 2002:aca:4a04:: with SMTP id x4mr4898436oia.152.1594404394207; Fri, 10 Jul 2020 11:06:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Luiz Augusto von Dentz Date: Fri, 10 Jul 2020 11:06:22 -0700 Message-ID: Subject: Re: Temporary device removal during discovery To: Bastien Nocera Cc: Andrey Batyiev , linux-bluetooth Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 84BA6A315D X-Rspamd-UID: b570bf Hi Bastien, On Thu, Jul 9, 2020 at 1:26 AM Bastien Nocera wrote: > > On Thu, 2020-07-09 at 01:57 +0300, Andrey Batyiev wrote: > > Hi Luiz, > > > > On Thu, Jul 9, 2020 at 12:14 AM Luiz Augusto von Dentz > > wrote: > > > The delta logic might be a nice addition as a separate patch, it is > > > more for detecting devices disappearing then actually cleanup > > > during > > > power off. > > No-no, it's not about adapter powering off. > > > > I meant that (external) devices never disappear from the bluez device > > list during the discovery, > > even if the (external) devices are turned off (i.e. they should be > > purged by bluez). > > > > So: > > - bluez is central > > - bluez is discovering > > - peripheral appear for a moment, than disappear (i.e. peripheral > > would be turned off) > > - bluez would not remove device from the list (at least until > > discovery is stopped) > > > > Use case: > > - bluez is monitoring environment (discovering literally forever) > > - peripherals are brought in and out of bluez visibility range > > - bluez list of visible devices grows infinitely and causes problems > > (hundreds of devices) > > I'd also expect devices that are recently discovered to disappear if > they haven't replied to a discovery in 30 seconds. It would stop > GNOME's Bluetooth Settings's Bluetooth list forever expanding. > > Or we need to give the ability for front-ends to do that by exporting > the "last seen" dates. I am fine with that as well, 30 seconds doesn't sound too bad even for cleanup temporary devices as the current 3 minutes seems awful long sometimes, we could perhaps have a filter for configuring that though so if the application wants to have its own timeout, the only problem is if there are multiple application doing that on parallel we would need a strategy on how to handle that. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +DaWOhLRCF/vJgAAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 22:35:30 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id IBzWOBLRCF/NrQEAlScrYA (envelope-from ); Fri, 10 Jul 2020 22:35:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A8C87A31D8; Fri, 10 Jul 2020 22:35:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727101AbgGJUfY (ORCPT + 1 other); Fri, 10 Jul 2020 16:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726725AbgGJUfY (ORCPT ); Fri, 10 Jul 2020 16:35:24 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CB37C08C5DC for ; Fri, 10 Jul 2020 13:35:24 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id 12so5852580oir.4 for ; Fri, 10 Jul 2020 13:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4rTNzcMkZJncAMvaHB7Lfn854pyoDmxRixBWBSIhfgI=; b=nH3uQQIgRl8BJOB1JmvfzBYe2itQSvKYw9MxwKIkyLHMU6htIhdTLAp0Tc1Vtv8swB QL20Od7WB1ceqIA3K2LXOCtCe6xA7CA99IjJ11+sGKTJ1Ycix1KadoI6/ZWhR1Rm4giJ ovn9KitsVJ/vRpI/iwtw8qXbsmiMKkhl+zBsBgnicARuv//mpeND5q6xSqdNEU4paQDC 5lfjP7NY1a7TX43r8sfgvmnd9VuBDsvDfWU7R3hVHmZhPTSGvd96jXJoOGzuu4lGeXG/ 1bz3OkqeZjMmhq9dbwFLDXbabQx5WiVd5alQdmXGt1X/IaWg5e5wq2Vo4ugONaMGCLyl 1zdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4rTNzcMkZJncAMvaHB7Lfn854pyoDmxRixBWBSIhfgI=; b=czL+cKNX+Vyfkbkg2kyog60lcOCBYaThwVsf0EmfhKlR3VtaNvm3i+lvRTBFeRgCUR rE05apc1/Nxdot3kzRl0KBk8b0E5TAm9xcBPGI168Ri3YkdJT8AZK5+icIYVh8kjdG00 jIjM6KZRyrbf3N+VUVvrDEti99gZ2kLNmw9W1Cf1I38U+lCWUhG2ZCgLV+3N8hqiZM2W 1oOEu8I05G774fFQ/VU0zSZLwwEpo7RCprqKkpv19qncaRgeh9gIySGl4URfm0FLJAnz SwF/jgxK0qafZu35590OUoM+p3ZPDPwixNrxppKgfGpYU48SEgh/e9uXaI/mz2DafXUM 4mWg== X-Gm-Message-State: AOAM531ET6yevy/mO4JeZZ7eEmT6s2ZHDMoe6gNnD1ezF7c7ynmA+wMh HcMYT6xgRPYpDxiwAeOmlE8Q353rTSVnCfxKZnDHTqDX X-Google-Smtp-Source: ABdhPJzChgFtQ49ZrVHUfbZvfrxnk3Mp40ik/ET2zyu7S37Fj1eB8URv06dQvcC2jhzJTr3JDv/gCICSlWJFIt1OOVU= X-Received: by 2002:aca:4a04:: with SMTP id x4mr5294868oia.152.1594413323851; Fri, 10 Jul 2020 13:35:23 -0700 (PDT) MIME-Version: 1.0 References: <20200709090631.Bluez.v1.1.I6aa22c6e425e5b19c321c0768f50ca3fc2c090da@changeid> In-Reply-To: <20200709090631.Bluez.v1.1.I6aa22c6e425e5b19c321c0768f50ca3fc2c090da@changeid> From: Luiz Augusto von Dentz Date: Fri, 10 Jul 2020 13:35:12 -0700 Message-ID: Subject: Re: [Bluez PATCH v1] audio/media - Fix volume sync between media and transport To: Yu Liu Cc: "linux-bluetooth@vger.kernel.org" , Hsin-Yu Chao , Sonny Sasaka Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: A8C87A31D8 X-Rspamd-UID: b6ec82 Hi, On Thu, Jul 9, 2020 at 9:10 AM Yu Liu wrote: > > From: Hsin-Yu Chao > > A volume value is cached on the global media player object. And a > check was used to NOT update volume to each transport if this > value doesn't change. That is causing problem at disconnect then > reconnect when the new constructed transport never receive update > about the last used volume value. I think this might be related to the other bug we have where the transport is created after the fetch of the volume so the volume we have stored in mp->volume is never updated in the transport, see my comments on the other patch. > Reviewed-by: sonnysasaka@chromium.org > Reviewed-by: hychao@chromium.org > > --- > > Changes in v1: > - Initial change > > profiles/audio/media.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/profiles/audio/media.c b/profiles/audio/media.c > index 993ecb3b3..92e363de9 100644 > --- a/profiles/audio/media.c > +++ b/profiles/audio/media.c > @@ -1204,9 +1204,6 @@ static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) > struct media_player *mp = user_data; > GSList *l; > > - if (mp->volume == volume) > - return; > - > mp->volume = volume; > > for (l = mp->adapter->endpoints; l; l = l->next) { > -- > 2.27.0.383.g050319c2ae-goog > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kEq0AqPWCF8OVAAAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 22:59:15 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OFD5AKPWCF92RgEADc0bRg (envelope-from ); Fri, 10 Jul 2020 22:59:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0DAE7A1A21; Fri, 10 Jul 2020 22:59:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726203AbgGJU7I (ORCPT + 1 other); Fri, 10 Jul 2020 16:59:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbgGJU7H (ORCPT ); Fri, 10 Jul 2020 16:59:07 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B51C0C08C5DC for ; Fri, 10 Jul 2020 13:59:07 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id x2so1249098oog.5 for ; Fri, 10 Jul 2020 13:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u1/JtT6kLeY1DxICnY5yfjydt1+DeA48Qpq7XZ7cwH8=; b=e+mY1V5SRk9jMxgAuxR1ALEBIWQCS2dKQYBgbzIqvUh3h2zTic3F2cIbvxKr4mzosI 5UPqZl2xD8ssNZhFK6PdZlYDulUHtPJVKjAZ6mykphqnz6iipFPPwrNrc/pytPBF0N9h zQuwp0tO+8aKUu4ZZedN1a8nmsa+/rIGkpGOmLwk/md6a7NKc/5I0fC3mxwTLWHF3IHT 9PALA49UcuC8WfMPwlZPXx1SUQd2yFyVSh1hUo8M4RO3CeTidjyKlILx3TrtOXUtYsQu as/8zvUYe9JUegOk9xxc7nbWObKl5PxYecpezS/D/15m2SvU0SqOy3teDEjYIIF5r2fX PhLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=u1/JtT6kLeY1DxICnY5yfjydt1+DeA48Qpq7XZ7cwH8=; b=l5e1ev5Kd8xi1gok/ZWboGTG/YRrKkdONErY3EGxyomXLb++XkcuBH+TyMWTcSLUBd yKIu74pPNELSIH2oDMzWv24o4pl+JFxyWow5t1d+ooqAx6StxguT/gA7EsZXclIGAvZH lJvhOpAXERhRRYssYBVFnp/nQ3HlnFyy4Svn9Xp0KYYuoutmCAlZK/g7nC31xaN0vJ76 rR8xea0SQCb9KMRh49vZfIltckp7On+3ceyr10H9hJCvNmnbQVrc0daXJje3BpCOVr4w Dp17drQS3hdwKZQxvUGOS9QvZ+WSqKfHO0Uali+MTD/aXx/C/FO0zvwtIBuVnSXeH9lb P8+g== X-Gm-Message-State: AOAM531R8AxDcMnnOB02cEpNXmMLeIejDpZj+qWZUYiXiB3ZI0DdIqwc hr+hdrbMwe1tpb8OhGGh13mgLtwXbKsiEFFXnns= X-Google-Smtp-Source: ABdhPJw5xkkP/M93zd75u8JYU7THT31FsfwbacltCQEv7Af3+UtOGD7Y0medVnsKw8RySJV0tmdQ8nfRsUVIsaPm02w= X-Received: by 2002:a4a:a21d:: with SMTP id m29mr10096110ool.17.1594414747083; Fri, 10 Jul 2020 13:59:07 -0700 (PDT) MIME-Version: 1.0 References: <20200709090631.Bluez.v1.1.I6aa22c6e425e5b19c321c0768f50ca3fc2c090da@changeid> In-Reply-To: From: Luiz Augusto von Dentz Date: Fri, 10 Jul 2020 13:58:55 -0700 Message-ID: Subject: Re: [Bluez PATCH v1] audio/media - Fix volume sync between media and transport To: Yu Liu Cc: "linux-bluetooth@vger.kernel.org" , Hsin-Yu Chao , Sonny Sasaka Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.21 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0DAE7A1A21 X-Rspamd-UID: 5a69ca On Fri, Jul 10, 2020 at 1:48 PM Yu Liu wrote: > > Sorry, which patch? From Archie, subject: [Bluez PATCH v1 2/2] audio/transport: store volume for initialization > On Fri, Jul 10, 2020 at 1:35 PM Luiz Augusto von Dentz wrote: >> >> Hi, >> >> On Thu, Jul 9, 2020 at 9:10 AM Yu Liu wrote: >> > >> > From: Hsin-Yu Chao >> > >> > A volume value is cached on the global media player object. And a >> > check was used to NOT update volume to each transport if this >> > value doesn't change. That is causing problem at disconnect then >> > reconnect when the new constructed transport never receive update >> > about the last used volume value. >> >> I think this might be related to the other bug we have where the >> transport is created after the fetch of the volume so the volume we >> have stored in mp->volume is never updated in the transport, see my >> comments on the other patch. >> >> > Reviewed-by: sonnysasaka@chromium.org >> > Reviewed-by: hychao@chromium.org >> > >> > --- >> > >> > Changes in v1: >> > - Initial change >> > >> > profiles/audio/media.c | 3 --- >> > 1 file changed, 3 deletions(-) >> > >> > diff --git a/profiles/audio/media.c b/profiles/audio/media.c >> > index 993ecb3b3..92e363de9 100644 >> > --- a/profiles/audio/media.c >> > +++ b/profiles/audio/media.c >> > @@ -1204,9 +1204,6 @@ static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) >> > struct media_player *mp = user_data; >> > GSList *l; >> > >> > - if (mp->volume == volume) >> > - return; >> > - >> > mp->volume = volume; >> > >> > for (l = mp->adapter->endpoints; l; l = l->next) { >> > -- >> > 2.27.0.383.g050319c2ae-goog >> > >> >> >> -- >> Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qOW6B4/gCF8khQAAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 23:41:35 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UJ2PBY/gCF/PcQAAgupzMw (envelope-from ); Fri, 10 Jul 2020 23:41:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 84046A179F; Fri, 10 Jul 2020 23:41:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726275AbgGJVlX (ORCPT + 1 other); Fri, 10 Jul 2020 17:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726251AbgGJVlW (ORCPT ); Fri, 10 Jul 2020 17:41:22 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77E47C08C5DC; Fri, 10 Jul 2020 14:41:22 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id di5so3270563qvb.11; Fri, 10 Jul 2020 14:41:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Da2tkZhxp36WWIM5SU4wWRnWrL+fbZs7REwsgJam7ZQ=; b=VHhl70xJKGvDmkqn9+GFeBcUZmC518WJVEFdfy8ur5HqlFExf0rxCQqHtur+CxOaqb iC/aDjq4YILIXcE9snn6uUpJEJSctpWWeSIcBd1gpIwKFbv+erXR9MKTWreSo0dOQKMo +S2JOme4t+ViPdBBTh2LgOFP78FdMRVZa/KvKW3P12B3HMV4vmIDdLoL79AnN3/2ZMDp GI/pYYdntjQ8qmt2ICS6qw2mjW85VFeM86w2EtTA4jwe+uQ4Zgt9eXxcDc8W1JL+247M SDWh+bYC/tB5vjOXT2GObQ3uC1A7k3UDT3aCQI4VnJ9IcFq51Wrp+jeuyastgyymV+A4 D/QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Da2tkZhxp36WWIM5SU4wWRnWrL+fbZs7REwsgJam7ZQ=; b=JO7KY24cK6qlP+MaJXUMypghc1aH8DTWDqJLMAP2hSUm1CP0JyM00cFr0dWO8fj6yx MKpLOCnbRDRvajPppP/Zn9I2bjdwpGs5SJxIsQ+PyMra93TKxP3CYUe93B2tnwSA24hP yNsQ+c6mCAVIE+/OPEeCAM9Oax20Hbi6sUtLDhCfiWqC24ZGpBQzonFUYmLM7Oo/m/97 6qqcFvNKG/KSsrqLC767tnsHZ7FS9THuhabQY3QGDlbaQqJ09WaQr06VhBINpXwFRMQb 4hDEZwxNlEfoA9pvPDlviFD954YryCcULumfG1S0+VPGpQTd68UujzgTMxftE9nOAZqN 08bg== X-Gm-Message-State: AOAM532jxGiq47B/utf5vJ2tVW+v/3GLPyBqqRnreKq81c9dnGhcc0Gm eK+CggF9QIpAEFKJ1k0kZw== X-Google-Smtp-Source: ABdhPJwg0Bs8T3eqvmOkVd+YCSi+G7i0B+ClGVozwdpkm7Ok6mUVGyf25q1e54in3JRQd8S88Lf8gg== X-Received: by 2002:a0c:ab55:: with SMTP id i21mr71409390qvb.139.1594417281580; Fri, 10 Jul 2020 14:41:21 -0700 (PDT) Received: from localhost.localdomain (c-76-119-149-155.hsd1.ma.comcast.net. [76.119.149.155]) by smtp.gmail.com with ESMTPSA id 2sm8652249qka.42.2020.07.10.14.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 14:41:21 -0700 (PDT) From: Peilin Ye To: Marcel Holtmann , Johan Hedberg Cc: Peilin Ye , "David S . Miller" , Jakub Kicinski , Russell King , Greg KH , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH 1/2] net/bluetooth: Prevent out-of-bounds read in hci_inquiry_result_evt() Date: Fri, 10 Jul 2020 17:39:18 -0400 Message-Id: <3f69f09d6eb0bc1430cae2894c635252a1cb09e1.1594414498.git.yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: 84046A179F X-Rspamd-UID: 34c2ee Check `num_rsp` before using it as for-loop counter. Cc: stable@vger.kernel.org Signed-off-by: Peilin Ye --- net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 03a0759f2fc2..8b3736c83b8e 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2517,7 +2517,7 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s num_rsp %d", hdev->name, num_rsp); - if (!num_rsp) + if (!num_rsp || skb->len < num_rsp * sizeof(*info) + 1) return; if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) -- 2.25.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0MDwAPnhCF8khQAAvsO+Rg (envelope-from ) for ; Fri, 10 Jul 2020 23:47:37 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id UIVJO/jhCF92MAAA0J78UA (envelope-from ); Fri, 10 Jul 2020 23:47:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 70DA2A26F0; Fri, 10 Jul 2020 23:47:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726505AbgGJVrZ (ORCPT + 1 other); Fri, 10 Jul 2020 17:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726251AbgGJVrZ (ORCPT ); Fri, 10 Jul 2020 17:47:25 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BA0BC08C5DC; Fri, 10 Jul 2020 14:47:25 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id a14so3294100qvq.6; Fri, 10 Jul 2020 14:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H4BIXM/X/4TDwBaDfHH2qeLVBAs7PCGQrZDucm3WMQA=; b=lXA0dnkhWEzo+ZcE67jH+G1OgotEBlFxSKDTrTSdVqYCG25rP2YQDQjX8ZX2ow1Q1/ XlzIEgUG9K6iyMLvNZFTuxDS7VSBtmGBdcVsjPM+2I8UX3K5VAsatr9rnxB9FfBvjsJq hABIVqaZYYjcKtikl3YtQSstw1Iv512kGKS/L21/Yro9jRmyD8t/OtRiByiwvlFiixgz 9C1CnWBNmZQfAm3+g2JVCaxPmzfqZIPr2DvRSCA3EonhzUW4Z3W1oS46s/06jAky2TW1 IH0hvL3WhTD98VFnr3vKykPgI2eZVcLjZz8PgsVx1H7itedHXLhQm2hRbCUkxOqFFFll 6KaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H4BIXM/X/4TDwBaDfHH2qeLVBAs7PCGQrZDucm3WMQA=; b=UyFu8h6Y7gp8UktsR9xP2HnmBHHEITCOT5ivZ1aFfuvLQg/bQmpDf4KQCisW8kM+KN UGrbh42GqOjXrvE0TYku82v9qB/vhTLN8vq7q3RxUYTlBLYEFaNuxQfe5OeXlrVaNDH4 3izTCPBbYPz38aXUABKBfz4Qyy5KPjU/iWM810WRt8JsRwrYxEJmKglYGGvBbnuDeoK8 kn6gW1jSQYyDpvL6avbD+8ofxdp3ibj1i7PPi0AqPgFyAvIPCBA9ozIveZeBYoT3bQoC clYR5d0hgN/aKGSNiiRPbTTX1ptnkN6oh0CDd0ruV6LW1Gq9flIN+rCg4wP0hEdV4A4w n6xg== X-Gm-Message-State: AOAM532170PK2l+vuyoXpM1AilKWqKowti22fmSXjB1dhOTNYPw9343Q 1ES3DSVmIg6PQ5eDBcjHKw== X-Google-Smtp-Source: ABdhPJy+8ouNnOFsAjWlZGUPZPhMenwY4SizL6H6mf4dXiIltgFw3gi7pzw+NnH3gWcRNGhFtiNNMA== X-Received: by 2002:a0c:f109:: with SMTP id i9mr66510402qvl.154.1594417644040; Fri, 10 Jul 2020 14:47:24 -0700 (PDT) Received: from localhost.localdomain (c-76-119-149-155.hsd1.ma.comcast.net. [76.119.149.155]) by smtp.gmail.com with ESMTPSA id p66sm8930426qkf.58.2020.07.10.14.47.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 14:47:23 -0700 (PDT) From: Peilin Ye To: Marcel Holtmann , Johan Hedberg Cc: Peilin Ye , "David S . Miller" , Jakub Kicinski , Russell King , Greg KH , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH 2/2] net/bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi_evt() Date: Fri, 10 Jul 2020 17:45:26 -0400 Message-Id: <82c4e719b7615f5333444bdc2b5cc243a693eeb1.1594414498.git.yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <3f69f09d6eb0bc1430cae2894c635252a1cb09e1.1594414498.git.yepeilin.cs@gmail.com> References: <3f69f09d6eb0bc1430cae2894c635252a1cb09e1.1594414498.git.yepeilin.cs@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: 70DA2A26F0 X-Rspamd-UID: 9a64c8 Check `num_rsp` before using it as for-loop counter. Add `unlock` label. Cc: stable@vger.kernel.org Signed-off-by: Peilin Ye --- net/bluetooth/hci_event.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 8b3736c83b8e..f9f4262414b3 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4159,6 +4159,9 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct inquiry_info_with_rssi_and_pscan_mode *info; info = (void *) (skb->data + 1); + if (skb->len < num_rsp * sizeof(*info) + 1) + goto unlock; + for (; num_rsp; num_rsp--, info++) { u32 flags; @@ -4180,6 +4183,9 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, } else { struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); + if (skb->len < num_rsp * sizeof(*info) + 1) + goto unlock; + for (; num_rsp; num_rsp--, info++) { u32 flags; @@ -4200,6 +4206,7 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, } } +unlock: hci_dev_unlock(hdev); } -- 2.25.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IAHxFZunCV84KgAAvsO+Rg (envelope-from ) for ; Sat, 11 Jul 2020 13:50:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WHX2E5unCV/f5wAAgupzMw (envelope-from ); Sat, 11 Jul 2020 13:50:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5CD7E52906; Sat, 11 Jul 2020 13:50:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726342AbgGKLuo (ORCPT + 1 other); Sat, 11 Jul 2020 07:50:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726286AbgGKLuo (ORCPT ); Sat, 11 Jul 2020 07:50:44 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6D7BC08C5DD for ; Sat, 11 Jul 2020 04:50:43 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id l12so8835753ejn.10 for ; Sat, 11 Jul 2020 04:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KkW096i9+5eJN3hC9xnduzvQMW/1zVfzh2PG2TAfy8M=; b=eMgxq6ZoWFzYQoKI3cTKexXvHnPBVTGlPr9Oo9Q3zhkHhbK7ChUOZATS6lbMNL6lRb x36o661wz3NACkCf9kIXoNJP6WktfEed1fw18HulFD8W+LdYVS2TdleN8jYU/NoZIIH2 l/fDMfUyHKTnht0xPu+izxNxFwFVfHS/MKoxXCpwnO+tVkZoJo/TDk+qsTkz9YnPT09y M26LtxU+mg8wDSGUy5TyhUbi8FQxvLYTX2CqmLjrCrPhGz+Wp4zWFAPzSxMYn5lfNXIa 9xviThxuVv0kwqkduMr1Jj8A3SHpL2ETmCTNPNwuT3zzUoDkarcSaRdxusIvrRKNPLoV u+LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KkW096i9+5eJN3hC9xnduzvQMW/1zVfzh2PG2TAfy8M=; b=a97uCAiN135cuigNw+eNbwtHaq3/ZtB+ZH2VX+kkEvtJUgt27kD5O7iNB/SFGovqy3 54KL3PuqUGEucMWsdmoN5Q9Rm0doYheN/vkGn017/oUhhnwQYYwNVW2BNW/s4owmux1Q 7zAUEWIAoLrK/OxCnMjezk4TqHDAy7lM7mDVrOcHzb8m665PDZ9VT9tnRxvFMZ3dFVey Iv2SOANNfsweFq0IbaBSO4YtrQVUoHWv7Wo8FLKvqHyBeTSNANU6hSyw/J29I5pl1tvC TrIwl8liIV9Alo3KS415R9oHKw9yM3VInQZlkOkbXHLD2kZ9RXUpXwRiI8EFZJBr9i+q vUXA== X-Gm-Message-State: AOAM533N10VYesTU3skNr4My9QR9TbmVmzwG6qy+hbTLqjWhkHeVPB62 HQXcLXZAgRBzngiGk1VE/jeKn8yx X-Google-Smtp-Source: ABdhPJw4aq4c7+W4Mo80DxFnzU/SqcTew2qkvtzdGQJ3aHi73puH/kliYhhFOENkWsuneyrMubPBuA== X-Received: by 2002:a17:907:9484:: with SMTP id dm4mr68635641ejc.56.1594468242158; Sat, 11 Jul 2020 04:50:42 -0700 (PDT) Received: from Marijn-Arch-PC.localdomain (94-209-165-62.cable.dynamic.v4.ziggo.nl. [94.209.165.62]) by smtp.gmail.com with ESMTPSA id d26sm5425462ejw.89.2020.07.11.04.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2020 04:50:41 -0700 (PDT) From: Marijn Suijten To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, Marijn Suijten Subject: [PATCH BlueZ] audio/avrcp: Always update transport volume regardless of player Date: Sat, 11 Jul 2020 13:50:31 +0200 Message-Id: <20200711115031.123793-1-marijns95@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 23 X-Rspamd-Score: 3.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5CD7E52906 X-Rspamd-UID: 159342 `Volume` is a special property that not only exists on players but also on the transport (see org.bluez.MediaTransport1). A player is not attached when the controller does not support FEATURE_CATEGORY_1, which is common on headphones without media browsing capabilities. On such audio devices (headphones, in-ears and the like) Absolute Volume is not available unless an external player is registered (org.bluez.Media1.RegisterPlayer) and the device sends a volume event back after that to set a2dp->volume in transport.c to a valid value (causing volume_exists to finally return true). This [1] mail thread denoting the same issue has a solution to at least request capabilities from the controller, but the proposed player object is not created on category 2 devices. Any notifications received on AVRCP_EVENT_VOLUME_CHANGED (avrcp_volume_changed) that is subsequently registered, or handling the result of avrcp_set_volume in avrcp_handle_set_volume will be ignored unless said player is present. This issue is not addressed by adding a fake player but instead dealing with the fact that volume is "special" and available on the transport regardless of the existence of a player. This is confirmed in avrcp_get_capabilities_resp as well which requires a player to register any event except AVRCP_EVENT_VOLUME_CHANGED. The applied solution moves media_transport_update_device_volume out of the player and into avrcp_volume_changed/avrcp_handle_set_volume where it is unconditionally called. These functions are the only users of avrcp_player->set_volume. Note that the volume member of media_player is never used which seems a result of updating from org.bluez.MediaPlayer1 to org.mpris.MediaPlayer2.Player in 15e421737ccc4696ed567edcc24d178aedb47854, where the volume property [2] is left out. [1]: https://marc.info/?l=linux-bluetooth&m=145337574806153 [2]: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Volume --- Hi, This is is a resend from an earlier mail that didn't comply with the contributor guidelines. Seeing that the topic of AVRCP volume is brought up recently it is about time to repair it and hereby send it again. I still have an incomplete patch lying around that synchronizes Volume on org.mpris.MediaPlayer2.Player back when this patch was written 6 months ago. It'll require some time to get back in to it and finalize it, let me know if that's desired. - Marijn Suijten profiles/audio/avrcp.c | 12 ++++++++---- profiles/audio/media.c | 16 ---------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index e2428250e..8370c8a44 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -3625,12 +3625,13 @@ static void avrcp_volume_changed(struct avrcp *session, struct avrcp_player *player = target_get_player(session); uint8_t volume; - if (!player) - return; - volume = pdu->params[1] & 0x7F; - player->cb->set_volume(volume, session->dev, player->user_data); + /* Always update the transport volume, which is separate from the player */ + media_transport_update_device_volume(session->dev, volume); + + if (player) + player->cb->set_volume(volume, session->dev, player->user_data); } static void avrcp_status_changed(struct avrcp *session, @@ -4378,6 +4379,9 @@ static gboolean avrcp_handle_set_volume(struct avctp *conn, uint8_t code, volume = pdu->params[0] & 0x7F; + /* Always update the transport volume, which is separate from the player */ + media_transport_update_device_volume(session->dev, volume); + if (player != NULL) player->cb->set_volume(volume, session->dev, player->user_data); diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 993ecb3b3..a0173fdd4 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -1202,27 +1202,11 @@ static uint32_t get_duration(void *user_data) static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) { struct media_player *mp = user_data; - GSList *l; if (mp->volume == volume) return; mp->volume = volume; - - for (l = mp->adapter->endpoints; l; l = l->next) { - struct media_endpoint *endpoint = l->data; - struct media_transport *transport; - - /* Volume is A2DP only */ - if (endpoint->sep == NULL) - continue; - - transport = find_device_transport(endpoint, dev); - if (transport == NULL) - continue; - - media_transport_update_volume(transport, volume); - } } static bool media_player_send(struct media_player *mp, const char *name) -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IMq5OEejCV8REQAAvsO+Rg (envelope-from ) for ; Sat, 11 Jul 2020 13:32:23 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cGf2NkejCV/T3AEAlp8NpQ (envelope-from ); Sat, 11 Jul 2020 13:32:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 566F4A3118; Sat, 11 Jul 2020 13:32:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728025AbgGKLbl (ORCPT + 1 other); Sat, 11 Jul 2020 07:31:41 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:13526 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726725AbgGKLbl (ORCPT ); Sat, 11 Jul 2020 07:31:41 -0400 Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 11 Jul 2020 04:31:40 -0700 Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 11 Jul 2020 04:31:38 -0700 Received: from gubbaven-linux.qualcomm.com ([10.206.64.32]) by ironmsg02-blr.qualcomm.com with ESMTP; 11 Jul 2020 17:01:16 +0530 Received: by gubbaven-linux.qualcomm.com (Postfix, from userid 2365015) id 5534B21515; Sat, 11 Jul 2020 17:01:15 +0530 (IST) From: Venkata Lakshmi Narayana Gubba To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org, Venkata Lakshmi Narayana Gubba Subject: [PATCH v1] Bluetooth: hci_qca: Bug fixes for SSR Date: Sat, 11 Jul 2020 17:01:12 +0530 Message-Id: <1594467072-13332-1-git-send-email-gubbaven@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 566F4A3118 X-Rspamd-UID: 268bff 1.During SSR for command time out if BT SoC goes to inresponsive state, power cycling of BT SoC was not happening.Given the fix by sending hw error event to reset the BT SoC. 2.If SSR is triggered then ignore the transmit data requests to BT SoC until SSR is completed. Signed-off-by: Venkata Lakshmi Narayana Gubba --- drivers/bluetooth/hci_qca.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 7e39546..bfebefa 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -72,7 +72,8 @@ enum qca_flags { QCA_DROP_VENDOR_EVENT, QCA_SUSPENDING, QCA_MEMDUMP_COLLECTION, - QCA_HW_ERROR_EVENT + QCA_HW_ERROR_EVENT, + QCA_SSR_TRIGGERED }; enum qca_capabilities { @@ -854,6 +855,13 @@ static int qca_enqueue(struct hci_uart *hu, struct sk_buff *skb) BT_DBG("hu %p qca enq skb %p tx_ibs_state %d", hu, skb, qca->tx_ibs_state); + if (test_bit(QCA_SSR_TRIGGERED, &qca->flags)) { + /* As SSR is in progress,Ignore the packets */ + bt_dev_dbg(hu->hdev, "SSR is in progress"); + kfree_skb(skb); + return 0; + } + /* Prepend skb with frame type */ memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1); @@ -1123,6 +1131,7 @@ static int qca_controller_memdump_event(struct hci_dev *hdev, struct hci_uart *hu = hci_get_drvdata(hdev); struct qca_data *qca = hu->priv; + set_bit(QCA_SSR_TRIGGERED, &qca->flags); skb_queue_tail(&qca->rx_memdump_q, skb); queue_work(qca->workqueue, &qca->ctrl_memdump_evt); @@ -1481,6 +1490,7 @@ static void qca_hw_error(struct hci_dev *hdev, u8 code) struct hci_uart *hu = hci_get_drvdata(hdev); struct qca_data *qca = hu->priv; + set_bit(QCA_SSR_TRIGGERED, &qca->flags); set_bit(QCA_HW_ERROR_EVENT, &qca->flags); bt_dev_info(hdev, "mem_dump_status: %d", qca->memdump_state); @@ -1529,10 +1539,30 @@ static void qca_cmd_timeout(struct hci_dev *hdev) struct hci_uart *hu = hci_get_drvdata(hdev); struct qca_data *qca = hu->priv; - if (qca->memdump_state == QCA_MEMDUMP_IDLE) + set_bit(QCA_SSR_TRIGGERED, &qca->flags); + if (qca->memdump_state == QCA_MEMDUMP_IDLE) { + set_bit(QCA_MEMDUMP_COLLECTION, &qca->flags); qca_send_crashbuffer(hu); - else - bt_dev_info(hdev, "Dump collection is in process"); + qca_wait_for_dump_collection(hdev); + } else if (qca->memdump_state == QCA_MEMDUMP_COLLECTING) { + /* Let us wait here until memory dump collected or + * memory dump timer expired. + */ + bt_dev_info(hdev, "waiting for dump to complete"); + qca_wait_for_dump_collection(hdev); + } + + mutex_lock(&qca->hci_memdump_lock); + if (qca->memdump_state != QCA_MEMDUMP_COLLECTED) { + qca->memdump_state = QCA_MEMDUMP_TIMEOUT; + if (!test_bit(QCA_HW_ERROR_EVENT, &qca->flags)) { + /* Inject hw error event to reset the device + * and driver. + */ + hci_reset_dev(hu->hdev); + } + } + mutex_unlock(&qca->hci_memdump_lock); } static int qca_wcn3990_init(struct hci_uart *hu) @@ -1643,6 +1673,8 @@ static int qca_setup(struct hci_uart *hu) if (ret) return ret; + clear_bit(QCA_SSR_TRIGGERED, &qca->flags); + if (qca_is_wcn399x(soc_type)) { set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iEYkA2CvCV87ZgAAvsO+Rg (envelope-from ) for ; Sat, 11 Jul 2020 14:24:00 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AIefAWCvCV+7OAAADc0bRg (envelope-from ); Sat, 11 Jul 2020 14:24:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 20AB152AE8; Sat, 11 Jul 2020 14:23:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726523AbgGKMXu (ORCPT + 1 other); Sat, 11 Jul 2020 08:23:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726480AbgGKMXt (ORCPT ); Sat, 11 Jul 2020 08:23:49 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1627C08C5DD for ; Sat, 11 Jul 2020 05:23:49 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id k18so7932492qke.4 for ; Sat, 11 Jul 2020 05:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=bguH9NPoTSMPiIqfLlGSETGclFvqXfQPOxujoD6NWbU=; b=TaeznO0CjK5CZNxRn9T5aPMow1gcxfGxHHHjhuwOfoRUb01wCYuhgJKdtIv1W0cz/0 AjjieH6+2rZuoEx31vH8fSyqE/UxFOM8w+XxBPhSKJWsvldreirrmwR6w7ZhMIQLp7cK o6JXRJjWh1oPe2bve9o1OVlJr3An59BonlFH+7n3JI9JNFhtXZIxAZ/DE/HCgHc5zU/Q AhlC7QAuQt1O1Cn7ii4QwWnPEvZOIvqv2+YxLqDZ+sdlF0pLScQRPmiZhYhL5pdf+GCd 3ANMY8613wbi7JBuV9x+NenDJ41P3haUjyIH12zZgvD6kI/gG2kQsue/dfiBgDCJXnjV YMQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=bguH9NPoTSMPiIqfLlGSETGclFvqXfQPOxujoD6NWbU=; b=FGIUuokHprcIZyVfl3/KmeiaQqdFWFB2sYrMFDj8hD8kgjPbYZzBJ4EIyjTRpLpE8s BE47FeDysdkdOX58tb77npOX0JqS9fFz847Vc3lM1EzbEsavjVWypnEwPFIQb3acWkig dxfobr+3Xevlu24ofrGhUhcTAOv5kf8KRThSunSMv0q30gDPzxgSIcIrKzq+yWZTTdzu bf/m/SiJd06ghE8MdWCnXGokvpxyLT6fLD6EX9c2LXEo6eMzdvef13r7lr9bBgcVeOsA LLvlxaAszzjV+WpijDDl+cibqZ32f9rCN9b5e9bJnXG2KuKO3oDs7YjbCHp6gJ/eNhrJ Ewdw== X-Gm-Message-State: AOAM530bOTEEeL42Tmb0adJzn8q9aCE6xertQuWq06zwUd0V7m9xrbK0 OkeYKMSrUqk1zlpuVEfv4b4gPC5bP0o= X-Google-Smtp-Source: ABdhPJyeAjsWTcPL0GgJper1nQ9zyq8qZrPvy+dSXvDXwi0sbF3IjzQQ7bupovQvF51VCuqdkr49ug== X-Received: by 2002:a37:46d1:: with SMTP id t200mr50427313qka.17.1594470228645; Sat, 11 Jul 2020 05:23:48 -0700 (PDT) Received: from [172.17.0.2] ([40.75.31.62]) by smtp.gmail.com with ESMTPSA id x23sm10742252qki.6.2020.07.11.05.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2020 05:23:48 -0700 (PDT) Message-ID: <5f09af54.1c69fb81.6ddf5.a1e1@mx.google.com> Date: Sat, 11 Jul 2020 05:23:48 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============5842721584137256734==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, marijns95@gmail.com Subject: RE: [BlueZ] audio/avrcp: Always update transport volume regardless of player Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200711115031.123793-1-marijns95@gmail.com> References: <20200711115031.123793-1-marijns95@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 41 X-Rspamd-Score: 6.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 20AB152AE8 X-Rspamd-UID: 0a5a0c --===============5842721584137256734== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #43: [2]: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Volume WARNING:LONG_LINE_COMMENT: line over 80 characters #59: FILE: profiles/audio/avrcp.c:3630: + /* Always update the transport volume, which is separate from the player */ WARNING:LONG_LINE_COMMENT: line over 80 characters #71: FILE: profiles/audio/avrcp.c:4382: + /* Always update the transport volume, which is separate from the player */ - total: 0 errors, 3 warnings, 53 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============5842721584137256734==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eAkKAWavCV87ZgAAvsO+Rg (envelope-from ) for ; Sat, 11 Jul 2020 14:24:06 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id wCtNOmWvCV8HFwEAgupzMw (envelope-from ); Sat, 11 Jul 2020 14:24:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2B51452227; Sat, 11 Jul 2020 14:24:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727876AbgGKMXw (ORCPT + 1 other); Sat, 11 Jul 2020 08:23:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726480AbgGKMXv (ORCPT ); Sat, 11 Jul 2020 08:23:51 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C09CFC08C5DD for ; Sat, 11 Jul 2020 05:23:51 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id o38so6566909qtf.6 for ; Sat, 11 Jul 2020 05:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=lwN9yTLc2fy1rlFwfJDPPj5UeCfZ0TZdL4IUjNFX0kU=; b=LvkN1zjAu/qmwYYuAbHbAnomIYR3hC4ac5lqmnP6pP2iA0EPp6z+dxmJYYWWimFRIQ LmzUycTKRO0Nwv06QrbcwRrOXjYjL1P4p3lLg9BHcSHgL+3ZwjfCRFEU84QVbQ8PVRc+ ClxB9v+DuktH7z17RetJ8MD9ANsFLxqRyx4/+eWv86bPsQF316mdbnB3k1YtW0f+TFgy BJl5UqCRPw5AJFBhpH8+azc0y7hxWbb2vmn829Az73uXlvdWwEPmymFrelNJAl6Qvfoc E9kHLB+xPrCMIZVPgv6j1+f3jxqQncAyZmL/c72tcXXIQKxS/K3dDi2qlr6DtIYImsxw QQdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=lwN9yTLc2fy1rlFwfJDPPj5UeCfZ0TZdL4IUjNFX0kU=; b=HDabDXkoW0mxBNtN4IHCoXhpwp8v6Y7lFX19OzCzbqcW9nO6MTLkdWZIlhWlUkJya9 /674AcEeRjvRdtZcRMs/ef5NcWN/GH8xalHfyoBiqrdQUmH+uvoNxs41dpa0902Lz1IA NqZsUBEKGhjYWScSf/2Tbyw2k7NhptrU8s1m5kb+w/hyFFcunk5uVOhZAW6dmd+iRW9v 4EhGjPuBEjPoUPOwc1knErj7oWgeiXPA2r2HosD69442NY3n0TNTH/nX2yiLNNjDZqpq fHU4K78yhsMwJgBhapA+k03V5QYeRm5qfrZu5x4regT1xG1MeW7IbOCpNmW8vLD4fH7R X4LA== X-Gm-Message-State: AOAM533L2CYyPhNmUEZhvJJvQITVtZAWbyF6/ZhYJOOG1+2V36hk35NY MtmhTQY/K5v23P2bsXTRlAF7/HbQxa8= X-Google-Smtp-Source: ABdhPJw4YnpDil2vcHX6/HDWgIgUC7L4XzrN49GIu1RkgLH9dWsAJW4LToKPSu2quHgIFzt3/QAhQw== X-Received: by 2002:aed:2569:: with SMTP id w38mr74912416qtc.3.1594470230922; Sat, 11 Jul 2020 05:23:50 -0700 (PDT) Received: from [172.17.0.2] ([40.75.31.62]) by smtp.gmail.com with ESMTPSA id w11sm11226796qtk.35.2020.07.11.05.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2020 05:23:50 -0700 (PDT) Message-ID: <5f09af56.1c69fb81.d7950.b11d@mx.google.com> Date: Sat, 11 Jul 2020 05:23:50 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============6647223998889505768==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, marijns95@gmail.com Subject: RE: [BlueZ] audio/avrcp: Always update transport volume regardless of player Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200711115031.123793-1-marijns95@gmail.com> References: <20200711115031.123793-1-marijns95@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 21 X-Rspamd-Score: 3.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2B51452227 X-Rspamd-UID: c657dd --===============6647223998889505768== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 39: B1 Line exceeds max length (96>80): "[2]: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Volume" --- Regards, Linux Bluetooth --===============6647223998889505768==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OIiPHiHACl+WWwEAvsO+Rg (envelope-from ) for ; Sun, 12 Jul 2020 09:47:45 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qAocHSHACl/23gEAlScrYA (envelope-from ); Sun, 12 Jul 2020 09:47:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6B17440079; Sun, 12 Jul 2020 09:47:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728198AbgGLHqM (ORCPT + 1 other); Sun, 12 Jul 2020 03:46:12 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:48354 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbgGLHqM (ORCPT ); Sun, 12 Jul 2020 03:46:12 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 385BE1C0BD5; Sun, 12 Jul 2020 09:46:09 +0200 (CEST) Date: Sun, 12 Jul 2020 09:46:08 +0200 From: Pavel Machek To: Marcel Holtmann Cc: Miao-chen Chou , Bluetooth Kernel Mailing List , Alain Michaud , Abhishek Pandit-Subedi , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v1] Bluetooth: Fix kernel oops triggered by hci_adv_monitors_clear() Message-ID: <20200712074608.GA8295@amd> References: <20200629201441.v1.1.I162e3c6c4f4d963250c37733c3428329110c5989@changeid> <8174F3F7-52C5-4F15-8BF5-E005B44A55C0@holtmann.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7AUc2qLy4jB3hD7Z" Content-Disposition: inline In-Reply-To: <8174F3F7-52C5-4F15-8BF5-E005B44A55C0@holtmann.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6B17440079 X-Rspamd-UID: e50b3c --7AUc2qLy4jB3hD7Z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue 2020-07-07 17:38:46, Marcel Holtmann wrote: > Hi Miao-chen, >=20 > > This fixes the kernel oops by removing unnecessary background scan > > update from hci_adv_monitors_clear() which shouldn't invoke any work > > queue. > >=20 > > The following test was performed. > > - Run "rmmod btusb" and verify that no kernel oops is triggered. > >=20 > > Signed-off-by: Miao-chen Chou > > Reviewed-by: Abhishek Pandit-Subedi > > Reviewed-by: Alain Michaud > > --- > >=20 > > net/bluetooth/hci_core.c | 2 -- > > 1 file changed, 2 deletions(-) >=20 > patch has been applied to bluetooth-next tree. Bluetooth no longer seems to oops for me... but there's different showstopper in next (graphics -- i915 -- related). Oh well :-(. Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --7AUc2qLy4jB3hD7Z Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl8Kv8AACgkQMOfwapXb+vJVggCgt4XZsqZWkWHltL/8Ca4hKtqg 10wAoMAfyUwKIh0H74EAgooNTS6ABM6D =nbI4 -----END PGP SIGNATURE----- --7AUc2qLy4jB3hD7Z-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YJzQHtWxC1/r6wAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 02:59:01 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QGMXHdWxC1+qvwEAgupzMw (envelope-from ); Mon, 13 Jul 2020 02:59:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6DBB14F1AC; Mon, 13 Jul 2020 02:58:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726491AbgGMA6z (ORCPT + 1 other); Sun, 12 Jul 2020 20:58:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726262AbgGMA6y (ORCPT ); Sun, 12 Jul 2020 20:58:54 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5624CC061794 for ; Sun, 12 Jul 2020 17:58:54 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id g13so8802604qtv.8 for ; Sun, 12 Jul 2020 17:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:autocrypt:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=8vy1eANgDjv0peNQM5v7lWEdM7p24FJdnYs8I5JxYGo=; b=ho0AkJg2Fz+PKv5z/BBMGm8oCmsSDsKlKaVFO94q5H8iZJK5gGTln12RM9MSBX6S6p t6hMPNMyXhUZ1qhOj/8oa6l+2tKCew9MF0NoFGdJTXwCV9rnOP61D82ISfJPLa9xS4Kb zPW+LU5ONgXWmHiwbidNEHmlNyqnqCNPSJJBkXNIZFN+6C3b7Rdkk7BKohj66ILB8Gyz lWSKIUCF37fup42HnIAIJ/+Eq8R6Yp4BfKCDntnthd9r1OsSreyr2NIhzS3bCgNxNqyZ ukwqI9OT4DhhMsalH8jO8HrNGkSf8z+6Orda4BMmhRhCTqwh+jkwuFxyvqGJCLtNcowc K/gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:autocrypt:message-id:date :user-agent:mime-version:content-transfer-encoding:content-language; bh=8vy1eANgDjv0peNQM5v7lWEdM7p24FJdnYs8I5JxYGo=; b=N29XkT7B/ybJEx58jU0i8VQDdUMCkqVxlo3cbLNFnFQ7BxLR6AXkv1exTliKXH9wYl XgHe/lfiIFAs7f2y0TzpfbtIyYVLYlNU2Cb+sfkcyh9wHE5Miy9nDnfUvTxu8pYyw7Lv zRRSFTsUN0bOuMh5Yv2xHE/5Sfbqg3/H1KgDGx0IuUN1GIdTePh3Inz5cxopfcJ8qdZE RdLTsMDE8XhGlDji5Yefr9M0YMMKBjzcl7A0alFU3Ip7kdvAOww7zZNAiDxDc44kpCqb OyONAKUXTKQSWuDn/zax+3iSmP1X/iFMalOHLKrPpbvwnp8ifgNy4ZwbmciJ+Kk7/9Cf 5WYA== X-Gm-Message-State: AOAM533CUAuaLu4CA09a4Y3SE989g5zIZAT+8NB/BzV1Mk6lUzrZATZQ 0yY1yR0z7pGQ2PsMkk0ROPB44EZL X-Google-Smtp-Source: ABdhPJzAS28sN5C71smpN3FK+vQP3402Hh2tb6cvDfd/skXwzw/6fnFgmsdao+XXgdeTvDckLnUvfQ== X-Received: by 2002:ac8:19d3:: with SMTP id s19mr73308804qtk.356.1594601933040; Sun, 12 Jul 2020 17:58:53 -0700 (PDT) Received: from meimei.greshko.com (2001-b030-112f-0000-0000-0000-0000-140e.hinet-ip6.hinet.net. [2001:b030:112f::140e]) by smtp.gmail.com with ESMTPSA id p5sm8501428qtb.62.2020.07.12.17.58.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Jul 2020 17:58:52 -0700 (PDT) From: Ed Greshko X-Google-Original-From: Ed Greshko To: linux-bluetooth Subject: Unsupported Adapter? Autocrypt: addr=Ed.Greshko@gmail.com; prefer-encrypt=mutual; keydata= mQINBFib3RQBEADHZwYcxrZlzTh/QVzUYbWH2SfcJvVAIvonOunb0JudiPaBcW14+3WkQa3i xnT7VYcN8AzLL0q5Omsy8t/TsAMmZxLffZCBL+jY8uxgkIR5yZkqCH0zhKSiTz7LTdFXf370 +Q1LLnvEaZHpM9kwfCVi0uV+WpCfEY+HsaYjMIJnHk1xQVG18Fo3uzZY/dh2bMvo0JcFRugU 6nn3Te5mcVt42sU/+l63dqubq0/8yRC9Nnp1+iE2qjkz+JUROWidPrIKWyBgapTRCctSJTA5 9FCwMNAftde1HVL1sibY+n8xV4RmFGRwLllsFE8KLhi85p3FMRAOtbsjdsTeiuFJo5ROdoQN mS3KHrOXCD4Fxs6+NbGhocsYNxfWW2deZrE+C7YULDkf1rhsUQaEScxHA5WDKA8BqiDewK8b DXmYYEFXmqP3SrujuedTOLls62I0myfsPpY6bMJzsQB1CvaM9DhXjN1DMxdcJHXk68ioX5Kh gxj6F41xitMfXBxh6AC8KzrPlVPzKesskHD7+M3E5P0+Dr9/8ijeMWa5aU/cZ9GvefryDIBO Ckh4BZz/ISeXcRVgaVrQvhgmr8W23IZggLvqduo0BqCK56EPPqW8KuZzN/64g/HMvjrCP1Na 0Uc29bfp1ySXiUaPTIz60guqAohm2z6SbIxPJC/TfnqDM+3dPwARAQABtCFFZCBHcmVzaGtv IDxFZC5HcmVzaGtvQGdtYWlsLmNvbT6JAjcEEwEIACEFAlib3RQCGyMFCwkIBwIGFQgJCgsC BBYCAwECHgECF4AACgkQMNGK02s7QIHTdA//TACw2PqlRT53HcoDNZt1afVyCgH8jo9CBtOF rhqxni2wsp8wke9a+qghRPXO57s1Te6NEPo33EF/ORrDauOchQDffhIqlKBZsn0nub1Hj/OB ERXtIxtr0jU83sTeeHg6GFu+mnQ8l2nwgZOM65rTfP1voMOKSQToFONqhzj0FwZLuMJoxSMP lOJHIg5QO4uWBmLBIYoEqxDdsc4RYhC79apGnzbQW1fvSpNGMzYfzqeJnTZso+km7VgXCRgP UOb0RPpRIjvobniwOxevXs6wXiQtT62EXlnHr6yZISd7i6Ca1rGNaGMLb0pnhuIw6KwqcWJJ aAfiUUnorY9vpQnruwmb1JsU3eGRKv11B+0lwQxWGpJC3/0uKqauOUsmbWmgMnvK8DYvLBKr TDOXsYpXowYE2IgQLHktscyIMMJJoNtLc+HS6DpQ2ajBQqQR0RCZvB16mmgSqz/tN2t72ZVx 6Rd6M23aFzbwGXFyefLhVPMaN4T5OUUjCWzeWzPPxET+nbeBIn65oUTnO8TVay1LWdkEcGUx gy4L2m/jDQp1E7xl2CMDnaXbmuIiuwbXRfRWfT3txKixc14TA1RT9TClQ+p3ltv9wIcZLqWO 0Mqy+DbVtwQCeDJkuF+ofg3MdUwtHOwoXdTkyA/UYtFxnZkKRgaPGBNdQjJmQDxQkm/H27W5 Ag0EWJvdFAEQAJgDOGyuOKSm8o6ouML+j+gh+PH47/CypLpx/RCwdTGjzlPUXa3+nE5O237E tPZkun3LbIrALjLnkXr83jRnZDzKLFuk3+DjPZ59WPLNmrTGlavg9jR10tmaMfP4H/4YhdV1 WbfyB2e0tqA5pN+T5ODuJaaJcbDA98tB3s68xuGz/Tv5OduDCtSkQw0yUJpBPcMGQ0Pz6bOF fg5SetAT8/CgLuSI5CaMz1CYm1PDj+2UCVYazNox9VJjhdWQ74h3c9YQEk5X4rNNd9No5xDO XcRTZh8TOlHtwcEBAD0xbST2lnryydBsLezftpiB66bAA8X2OlnXgsSQ3OiMrwuU8aRu0HQ4 Op83t1fDO6Z8aFfBOVCTkvF/OoCVyDEj3PXHrU1a/yvA3qa04hwQB7hpmBes5alvbcl8QvgA SJJD3YGuz1UuG6CMzLB6ADRMIKcgR0bR7rqSJ7Cguz5RzlOp/80EK6gWTjVrpFlq7nf7mb8Y tN1XF6j+UERBVx7RTvTnu0ZTLPbw4HYHtS/f5LsWtEbuPgVA9JXzYJkGoJDBaSjK1yKP/Dck udg3NtHU6NgY1A4SET7N1uvlb9tV3zRwcd9Q1+3Vi7k0dBDg1JGqz9rTRzESaHJsTTjsna+P yfd+wNbJ7nr6PXNeyvjk0dLGzjxPNdwuvQXwJuW5Wk87RzVNABEBAAGJAh8EGAEIAAkFAlib 3RQCGwwACgkQMNGK02s7QIHNdw/+PByovfcsXIb3JLzz2MQj1Zz5aTOV5A34eYKXIm1jg17/ KLnPABQz9XX5vFbH89DCFLqWyaBncoZCR3bsCIuTLFzulHRFuKgTwOInDHEoJHmxV9SL2v0l FHQK3uCT3rEs45PGoDtNLdsCvlIvaTM1SQ0Irr1dmpL1esUiSepYfLKBp4DVc9P/YJOz6M7a JQVrPbdgMmwuALDw8//kKe28yz+ezIX/33jtzuL4H8woIOO+Q6BCWzLA7akUKvIol/wIvAE2 +l4NwNUGkKu4W1Bgk1L303lepRIe7PqRbfZNbXH1AwhaKLEO3ZIov3AjpUzKClkU8T9eLki9 OCsAbOkziG4UYJPddn7JnMSFamqPTxOliLyi+c0T4ThTtZLYKFsd4iRXdPOKoH1aRUsihXOZ qrTKAcZpgHKcVZ7FCXF6uBCzuLqmhgAYcudPVZ8KT23N3g4m3qb3evbJ3E7gJrH7i57elISk c9Dm6egzpCXuJs22DpkrOjhDlxM902ii4RmXnzYpbbSOwNBBvRAWnTJMIbxl0VgPjD0SzXGb miP4iWQyz5Q590zJT1sN4qUOcKQIpTIhJWkj0PVrcji3yS6xzgxJZXte6btvoKX1qarQh1sm zgCych1oCte93iAESL7peGjSPCQgGk325Rz8QwtMgrAqObTPP0wHw4XR0V5t2Go= Message-ID: <5c552dc0-1ef8-ae35-b51a-b6889853d535@gmail.com> Date: Mon, 13 Jul 2020 08:58:49 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6DBB14F1AC X-Rspamd-UID: dbec92 Hello, I'm running the Fedora 32 disto and bluez-5.54-1.fc32 is installed. I have 2 bluetooth dongles.  One is recognized and the other isn't. The one not recognized is shown in lsusb. The info is as below.  It there a process to get an adapter supported? Bus 002 Device 008: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) Device Descriptor:   bLength                18   bDescriptorType         1   bcdUSB               1.10   bDeviceClass          224 Wireless   bDeviceSubClass         1 Radio Frequency   bDeviceProtocol         1 Bluetooth   bMaxPacketSize0        64   idVendor           0x0a12 Cambridge Silicon Radio, Ltd   idProduct          0x0001 Bluetooth Dongle (HCI mode)   bcdDevice           88.91   iManufacturer           0   iProduct                2 USB1.1-A￿翼   iSerial                 0   bNumConfigurations      1   Configuration Descriptor:     bLength                 9     bDescriptorType         2     wTotalLength       0x00b1     bNumInterfaces          2     bConfigurationValue     1     iConfiguration          0     bmAttributes         0xe0       Self Powered       Remote Wakeup     MaxPower              100mA     Interface Descriptor:       bLength                 9       bDescriptorType         4       bInterfaceNumber        0       bAlternateSetting       0       bNumEndpoints           3       bInterfaceClass       224 Wireless       bInterfaceSubClass      1 Radio Frequency       bInterfaceProtocol      1 Bluetooth       iInterface              0       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x81  EP 1 IN         bmAttributes            3           Transfer Type            Interrupt           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0010  1x 16 bytes         bInterval               1       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x02  EP 2 OUT         bmAttributes            2           Transfer Type            Bulk           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0040  1x 64 bytes         bInterval               1       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x82  EP 2 IN         bmAttributes            2           Transfer Type            Bulk           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0040  1x 64 bytes         bInterval               1     Interface Descriptor:       bLength                 9       bDescriptorType         4       bInterfaceNumber        1       bAlternateSetting       0       bNumEndpoints           2       bInterfaceClass       224 Wireless       bInterfaceSubClass      1 Radio Frequency       bInterfaceProtocol      1 Bluetooth       iInterface              0       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x03  EP 3 OUT         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0000  1x 0 bytes         bInterval               1       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x83  EP 3 IN         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0000  1x 0 bytes         bInterval               1     Interface Descriptor:       bLength                 9       bDescriptorType         4       bInterfaceNumber        1       bAlternateSetting       1       bNumEndpoints           2       bInterfaceClass       224 Wireless       bInterfaceSubClass      1 Radio Frequency       bInterfaceProtocol      1 Bluetooth       iInterface              0       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x03  EP 3 OUT         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0009  1x 9 bytes         bInterval               1       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x83  EP 3 IN         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0009  1x 9 bytes         bInterval               1     Interface Descriptor:       bLength                 9       bDescriptorType         4       bInterfaceNumber        1       bAlternateSetting       2       bNumEndpoints           2       bInterfaceClass       224 Wireless       bInterfaceSubClass      1 Radio Frequency       bInterfaceProtocol      1 Bluetooth       iInterface              0       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x03  EP 3 OUT         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0011  1x 17 bytes         bInterval               1       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x83  EP 3 IN         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0011  1x 17 bytes         bInterval               1     Interface Descriptor:       bLength                 9       bDescriptorType         4       bInterfaceNumber        1       bAlternateSetting       3       bNumEndpoints           2       bInterfaceClass       224 Wireless       bInterfaceSubClass      1 Radio Frequency       bInterfaceProtocol      1 Bluetooth       iInterface              0       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x03  EP 3 OUT         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0019  1x 25 bytes         bInterval               1       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x83  EP 3 IN         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0019  1x 25 bytes         bInterval               1     Interface Descriptor:       bLength                 9       bDescriptorType         4       bInterfaceNumber        1       bAlternateSetting       4       bNumEndpoints           2       bInterfaceClass       224 Wireless       bInterfaceSubClass      1 Radio Frequency       bInterfaceProtocol      1 Bluetooth       iInterface              0       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x03  EP 3 OUT         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0021  1x 33 bytes         bInterval               1       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x83  EP 3 IN         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x0021  1x 33 bytes         bInterval               1     Interface Descriptor:       bLength                 9       bDescriptorType         4       bInterfaceNumber        1       bAlternateSetting       5       bNumEndpoints           2       bInterfaceClass       224 Wireless       bInterfaceSubClass      1 Radio Frequency       bInterfaceProtocol      1 Bluetooth       iInterface              0       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x03  EP 3 OUT         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x003f  1x 63 bytes         bInterval               1       Endpoint Descriptor:         bLength                 7         bDescriptorType         5         bEndpointAddress     0x83  EP 3 IN         bmAttributes            1           Transfer Type            Isochronous           Synch Type               None           Usage Type               Data         wMaxPacketSize     0x003f  1x 63 bytes         bInterval               1 Device Status:     0x0000   (Bus Powered) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OAjDCz3sC18PeAAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 07:08:13 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ANOGCj3sC18eugEADc0bRg (envelope-from ); Mon, 13 Jul 2020 07:08:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D8BB5525EE; Mon, 13 Jul 2020 07:08:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728599AbgGMFHy (ORCPT + 1 other); Mon, 13 Jul 2020 01:07:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbgGMFHy (ORCPT ); Mon, 13 Jul 2020 01:07:54 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34CE8C061794; Sun, 12 Jul 2020 22:07:54 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id a32so9093040qtb.5; Sun, 12 Jul 2020 22:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zn4QovJTObyer1bkeM2XLJCYckJFice9R/PcByfIUJ8=; b=ThNgHLlSpgpnRfaARHvJvVG762LNQbG0fUZAGvcBXEsS3bqrJJN0UVVluSCt8deMyi uWEnzKHO4QMhyjYoomcglALeDyflrhp1TTfcU26u8OzhWaRWQ3oX1YDLWBdwND0nuHAl UI8w13XGp5yb9iP0WzOb8jDEch5c0DFakcv0ZedPje1CspVB56pIH9mLyTKxleRlqMMQ 7pS8g/iqBZGI5xpKK6462NsdnHGM5EzeJ1sUDJ2Jh/fi6ZXc1ZXtvO/LT+lb6qAKbiKd N6+mHT/tuREq7G9rdOVgMY2QAIKCr/a3zmcEEFuYrPF/qf5kurc3rbn/t9NfhAadIvR0 DK9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zn4QovJTObyer1bkeM2XLJCYckJFice9R/PcByfIUJ8=; b=Mqo4xTEg+LSiv8KVRtSQbunBh2qZzoVqHAT7J9Xk1jsq7vdq71e66bZZ57O24DwlmP zY2ApVmqFtRDTdMT79fiylaNGcdd8YucK5lLpwlMXL520QbNs5FctLJy59Ag12SgTdv3 MonW24/lKZfWaw1mt9EQjz1jDYskDN0N54UVD4iprhQesD3y4Y8zu/G6K/AMC5QHWFl6 Vo9YQOvNyueb3T1JZ/oxdMLFwt4ycv1So3A7jIJq/JE66gtbu4su5n74CGuJu141b8wb 663QlDH76HCmAlkZdjGjLdj0N+Z1I5WedFdmP+uzchxlsjZSEP1PPowPdn2MHJPU+3rJ EZhg== X-Gm-Message-State: AOAM533mope4/FrgVtxmR6j8UvKdXkNhvN8lWRSrF5nj+OHHBceRhuUD s6RrJxV/IYg5ggkdHrgBWJI27c4BWPe3pueCWlI= X-Google-Smtp-Source: ABdhPJwAyvvGNRCcOOt8bd/qMLFaLFQW73VNJhJJ0aRdBdnbxvk2SK/yLjDUI7jnRE1G6McBbITWAyI7HcCP3XNgRmw= X-Received: by 2002:ac8:6d1a:: with SMTP id o26mr76449982qtt.87.1594616873269; Sun, 12 Jul 2020 22:07:53 -0700 (PDT) MIME-Version: 1.0 References: <20200705195110.405139-1-anarsoul@gmail.com> <20200705195110.405139-3-anarsoul@gmail.com> <99A48FC7-0DCB-42F9-A3E3-91292BB92100@holtmann.org> In-Reply-To: <99A48FC7-0DCB-42F9-A3E3-91292BB92100@holtmann.org> From: Vasily Khoruzhick Date: Sun, 12 Jul 2020 22:07:27 -0700 Message-ID: Subject: Re: [PATCH 2/3] Bluetooth: btrtl: add support for the RTL8723CS To: Marcel Holtmann Cc: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree , arm-linux , kernel list , linux-bluetooth , netdev , Ondrej Jirman Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: D8BB5525EE X-Rspamd-UID: c090a2 On Tue, Jul 7, 2020 at 9:01 AM Marcel Holtmann wrote: > > Hi Vasily, > > > The Realtek RTL8723CS is SDIO WiFi chip. It also contains a Bluetooth > > module which is connected via UART to the host. > > > > It shares lmp subversion with 8703B, so Realtek's userspace > > initialization tool (rtk_hciattach) differentiates varieties of RTL8723CS > > (CG, VF, XX) with RTL8703B using vendor's command to read chip type. > > > > Also this chip declares support for some features it doesn't support > > so add a quirk to indicate that these features are broken. > > > > Signed-off-by: Vasily Khoruzhick > > --- > > drivers/bluetooth/btrtl.c | 128 ++++++++++++++++++++++++++++++++++++- > > drivers/bluetooth/btrtl.h | 12 ++++ > > drivers/bluetooth/hci_h5.c | 6 ++ > > 3 files changed, 143 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c > > index 3a9afc905f24..8c7b35abe492 100644 > > --- a/drivers/bluetooth/btrtl.c > > +++ b/drivers/bluetooth/btrtl.c > > @@ -17,8 +17,12 @@ > > > > #define VERSION "0.1" > > > > +#define RTL_CHIP_8723CS_CG 3 > > +#define RTL_CHIP_8723CS_VF 4 > > +#define RTL_CHIP_8723CS_XX 5 > > #define RTL_EPATCH_SIGNATURE "Realtech" > > #define RTL_ROM_LMP_3499 0x3499 > > +#define RTL_ROM_LMP_8703B 0x8703 > > #define RTL_ROM_LMP_8723A 0x1200 > > #define RTL_ROM_LMP_8723B 0x8723 > > #define RTL_ROM_LMP_8723D 0x8873 > > @@ -31,6 +35,7 @@ > > #define IC_MATCH_FL_HCIREV (1 << 1) > > #define IC_MATCH_FL_HCIVER (1 << 2) > > #define IC_MATCH_FL_HCIBUS (1 << 3) > > +#define IC_MATCH_FL_CHIP_TYPE (1 << 4) > > #define IC_INFO(lmps, hcir) \ > > .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV, \ > > .lmp_subver = (lmps), \ > > @@ -42,6 +47,7 @@ struct id_table { > > __u16 hci_rev; > > __u8 hci_ver; > > __u8 hci_bus; > > + __u8 chip_type; > > bool config_needed; > > bool has_rom_version; > > char *fw_name; > > @@ -89,6 +95,39 @@ static const struct id_table ic_id_table[] = { > > .fw_name = "rtl_bt/rtl8723b_fw.bin", > > .cfg_name = "rtl_bt/rtl8723b_config" }, > > > > + /* 8723CS-CG */ > > + { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_CHIP_TYPE | > > + IC_MATCH_FL_HCIBUS, > > + .lmp_subver = RTL_ROM_LMP_8703B, > > + .chip_type = RTL_CHIP_8723CS_CG, > > + .hci_bus = HCI_UART, > > + .config_needed = true, > > + .has_rom_version = true, > > + .fw_name = "rtl_bt/rtl8723cs_cg_fw.bin", > > + .cfg_name = "rtl_bt/rtl8723cs_cg_config" }, > > + > > + /* 8723CS-VF */ > > + { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_CHIP_TYPE | > > + IC_MATCH_FL_HCIBUS, > > + .lmp_subver = RTL_ROM_LMP_8703B, > > + .chip_type = RTL_CHIP_8723CS_VF, > > + .hci_bus = HCI_UART, > > + .config_needed = true, > > + .has_rom_version = true, > > + .fw_name = "rtl_bt/rtl8723cs_vf_fw.bin", > > + .cfg_name = "rtl_bt/rtl8723cs_vf_config" }, > > + > > + /* 8723CS-XX */ > > + { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_CHIP_TYPE | > > + IC_MATCH_FL_HCIBUS, > > + .lmp_subver = RTL_ROM_LMP_8703B, > > + .chip_type = RTL_CHIP_8723CS_XX, > > + .hci_bus = HCI_UART, > > + .config_needed = true, > > + .has_rom_version = true, > > + .fw_name = "rtl_bt/rtl8723cs_xx_fw.bin", > > + .cfg_name = "rtl_bt/rtl8723cs_xx_config" }, > > + > > /* 8723D */ > > { IC_INFO(RTL_ROM_LMP_8723B, 0xd), > > .config_needed = true, > > @@ -171,7 +210,8 @@ static const struct id_table ic_id_table[] = { > > }; > > > > static const struct id_table *btrtl_match_ic(u16 lmp_subver, u16 hci_rev, > > - u8 hci_ver, u8 hci_bus) > > + u8 hci_ver, u8 hci_bus, > > + u8 chip_type) > > { > > int i; > > > > @@ -188,6 +228,9 @@ static const struct id_table *btrtl_match_ic(u16 lmp_subver, u16 hci_rev, > > if ((ic_id_table[i].match_flags & IC_MATCH_FL_HCIBUS) && > > (ic_id_table[i].hci_bus != hci_bus)) > > continue; > > + if ((ic_id_table[i].match_flags & IC_MATCH_FL_CHIP_TYPE) && > > + (ic_id_table[i].chip_type != chip_type)) > > + continue; > > > > break; > > } > > @@ -270,6 +313,7 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev, > > { RTL_ROM_LMP_8723B, 1 }, > > { RTL_ROM_LMP_8821A, 2 }, > > { RTL_ROM_LMP_8761A, 3 }, > > + { RTL_ROM_LMP_8703B, 7 }, > > { RTL_ROM_LMP_8822B, 8 }, > > { RTL_ROM_LMP_8723B, 9 }, /* 8723D */ > > { RTL_ROM_LMP_8821A, 10 }, /* 8821C */ > > @@ -545,6 +589,48 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, > > return ret; > > } > > > > +static bool rtl_has_chip_type(u16 lmp_subver) > > +{ > > + switch (lmp_subver) { > > + case RTL_ROM_LMP_8703B: > > + return true; > > + default: > > + break; > > + } > > + > > + return false; > > +} > > + > > +static int rtl_read_chip_type(struct hci_dev *hdev, u8 *type) > > +{ > > + struct rtl_chip_type_evt *chip_type; > > + struct sk_buff *skb; > > + const unsigned char cmd_buf[] = {0x00, 0x94, 0xa0, 0x00, 0xb0}; > > + > > + /* Read RTL chip type command */ > > + skb = __hci_cmd_sync(hdev, 0xfc61, 5, cmd_buf, HCI_INIT_TIMEOUT); > > + if (IS_ERR(skb)) { > > + rtl_dev_err(hdev, "Read chip type failed (%ld)", > > + PTR_ERR(skb)); > > + return PTR_ERR(skb); > > + } > > + > > + if (skb->len != sizeof(*chip_type)) { > > + rtl_dev_err(hdev, "RTL chip type event length mismatch"); > > + kfree_skb(skb); > > + return -EIO; > > + } > > + > > + chip_type = (struct rtl_chip_type_evt *)skb->data; > > + rtl_dev_info(hdev, "chip_type status=%x type=%x", > > + chip_type->status, chip_type->type); > > + > > + *type = chip_type->type & 0x0f; > > + > > + kfree_skb(skb); > > + return 0; > > +} > > + > > void btrtl_free(struct btrtl_device_info *btrtl_dev) > > { > > kvfree(btrtl_dev->fw_data); > > @@ -561,7 +647,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, > > struct hci_rp_read_local_version *resp; > > char cfg_name[40]; > > u16 hci_rev, lmp_subver; > > - u8 hci_ver; > > + u8 hci_ver, chip_type = 0; > > int ret; > > > > btrtl_dev = kzalloc(sizeof(*btrtl_dev), GFP_KERNEL); > > @@ -586,8 +672,14 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, > > lmp_subver = le16_to_cpu(resp->lmp_subver); > > kfree_skb(skb); > > > > + if (rtl_has_chip_type(lmp_subver)) { > > + ret = rtl_read_chip_type(hdev, &chip_type); > > + if (ret) > > + goto err_free; > > + } > > + > > btrtl_dev->ic_info = btrtl_match_ic(lmp_subver, hci_rev, hci_ver, > > - hdev->bus); > > + hdev->bus, chip_type); > > > > if (!btrtl_dev->ic_info) { > > rtl_dev_info(hdev, "unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x", > > @@ -660,6 +752,7 @@ int btrtl_download_firmware(struct hci_dev *hdev, > > case RTL_ROM_LMP_8821A: > > case RTL_ROM_LMP_8761A: > > case RTL_ROM_LMP_8822B: > > + case RTL_ROM_LMP_8703B: > > return btrtl_setup_rtl8723b(hdev, btrtl_dev); > > default: > > rtl_dev_info(hdev, "assuming no firmware upload needed"); > > @@ -678,7 +771,12 @@ int btrtl_setup_realtek(struct hci_dev *hdev) > > return PTR_ERR(btrtl_dev); > > > > ret = btrtl_download_firmware(hdev, btrtl_dev); > > + if (ret) > > + goto out_free; > > > > + btrtl_apply_quirks(hdev, btrtl_dev); > > + > > +out_free: > > btrtl_free(btrtl_dev); > > > > /* Enable controller to do both LE scan and BR/EDR inquiry > > @@ -818,6 +916,24 @@ int btrtl_get_uart_settings(struct hci_dev *hdev, > > } > > EXPORT_SYMBOL_GPL(btrtl_get_uart_settings); > > > > +void btrtl_apply_quirks(struct hci_dev *hdev, > > + struct btrtl_device_info *btrtl_dev) > > +{ > > + switch (btrtl_dev->ic_info->lmp_subver) { > > + case RTL_ROM_LMP_8703B: > > + /* 8723CS reports two pages for local ext features, > > + * but it doesn't support any features from page 2 - > > + * it either responds with garbage or with error status > > + */ > > + set_bit(HCI_QUIRK_BROKEN_LOCAL_EXT_FTR_MAX_PAGE, > > + &hdev->quirks); > > + break; > > + default: > > + break; > > + } > > +} > > +EXPORT_SYMBOL_GPL(btrtl_apply_quirks); > > + > > MODULE_AUTHOR("Daniel Drake "); > > MODULE_DESCRIPTION("Bluetooth support for Realtek devices ver " VERSION); > > MODULE_VERSION(VERSION); > > @@ -827,6 +943,12 @@ MODULE_FIRMWARE("rtl_bt/rtl8723b_fw.bin"); > > MODULE_FIRMWARE("rtl_bt/rtl8723b_config.bin"); > > MODULE_FIRMWARE("rtl_bt/rtl8723bs_fw.bin"); > > MODULE_FIRMWARE("rtl_bt/rtl8723bs_config.bin"); > > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_cg_fw.bin"); > > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_cg_config.bin"); > > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_vf_fw.bin"); > > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_vf_config.bin"); > > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_xx_fw.bin"); > > +MODULE_FIRMWARE("rtl_bt/rtl8723cs_xx_config.bin"); > > MODULE_FIRMWARE("rtl_bt/rtl8723ds_fw.bin"); > > MODULE_FIRMWARE("rtl_bt/rtl8723ds_config.bin"); > > MODULE_FIRMWARE("rtl_bt/rtl8761a_fw.bin"); > > diff --git a/drivers/bluetooth/btrtl.h b/drivers/bluetooth/btrtl.h > > index 2a582682136d..152ed2ece4c2 100644 > > --- a/drivers/bluetooth/btrtl.h > > +++ b/drivers/bluetooth/btrtl.h > > @@ -14,6 +14,11 @@ > > > > struct btrtl_device_info; > > > > +struct rtl_chip_type_evt { > > + __u8 status; > > + __u8 type; > > +} __packed; > > + > > struct rtl_download_cmd { > > __u8 index; > > __u8 data[RTL_FRAG_LEN]; > > @@ -60,6 +65,8 @@ int btrtl_get_uart_settings(struct hci_dev *hdev, > > struct btrtl_device_info *btrtl_dev, > > unsigned int *controller_baudrate, > > u32 *device_baudrate, bool *flow_control); > > +void btrtl_apply_quirks(struct hci_dev *hdev, > > + struct btrtl_device_info *btrtl_dev); > > > > #else > > > > @@ -96,6 +103,11 @@ static inline int btrtl_get_uart_settings(struct hci_dev *hdev, > > bool *flow_control) > > { > > return -ENOENT; > > + > > +static inline void btrtl_apply_quirks(struct hci_dev *hdev, > > + struct btrtl_device_info *btrtl_dev) > > +{ > > +} > > } > > this hunk is fundamentally broken. Will fix in v2 > Regards > > Marcel > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KBgKEJDsC1+UdAAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 07:09:36 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id yPYyDpDsC18j/QEAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 07:09:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BC607526CF; Mon, 13 Jul 2020 07:09:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728866AbgGMFJY (ORCPT + 1 other); Mon, 13 Jul 2020 01:09:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725830AbgGMFJY (ORCPT ); Mon, 13 Jul 2020 01:09:24 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F28FC061794; Sun, 12 Jul 2020 22:09:24 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id o38so9085956qtf.6; Sun, 12 Jul 2020 22:09:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Mgj/wvd79X6Tg0otEw1MjyAhvhEJqLE80+gVPS33EpM=; b=Agzoe9FSrpGTKPO+ZjPAOqoT76Xl/XX1v0yMlXP5nbGof6W1/JAmCMjBdIopUjwhw3 FvslyZbteEaNueMND2tqEw7qxjofYqRQ0e0+kgBwpWN656vEtasQf665kounoqet6iGw ui3e9LtGa0wCYk3zVc/2Px7MKpzWlbQjfkvxkO8o2oTDSLoFLW8f0I3N20xDX1llYivr s42qm/WZB7hP0OqjAt+u6tVOn3fb1wBcM9/8EWCrd/c1Mdx2YlLiFkKKeQzpvslWBzLr PXMcAi8wg6/jmwSp+psa2Yw1mLGSyn4DaoJ8J+2FIeX+vyj9SbFURP3TQ6g09gh0/ylh /WPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Mgj/wvd79X6Tg0otEw1MjyAhvhEJqLE80+gVPS33EpM=; b=eYmt97XTYeYGEx/CL1x137GLCcTW2aVrUWhbDWuhrJSHfn5lTz45ZeQJVu971YjoqT fvIP60DVbPWJAD/43IJyx+9TycIOV6L4loRX95wE+10WbcGEdPVPNWEV8UTVCi2EI8ur QUf+JluhuT+0Pk4IAsTh2XJILh3BArQYZaXQoH4pGa3kV38yZYZ1d3vdHP2RR7tbX1Kg vwa7wIXysyvvojI7FgLF+TfmlFybqLvmBYRSnEZS567RzxaMRDdNSfQtDXXuaxtxB5tb PgE72RMtNgSyRz5F5/j4Fn+0VX4xv1gmEUu9BgRfS3mAxSAJLC4EMVNSHJtTu/E42WWy V8qw== X-Gm-Message-State: AOAM530msnpKJdt00qb4IXvw/L0X77yPSR+4nvzo5xe5iNlIMppayjTL RH37e/gVl5J3B/SHepdnw8Mv5CbGYaFnwbY3iNUXhTUR X-Google-Smtp-Source: ABdhPJzD7BsbNZXIjdhXtbehLOCjRVk4RfzGsSOpsgLAbeS7Uko6VPVwDPPI9M+P5gIgNFSmYPVC02V9b45NXmkMSiY= X-Received: by 2002:ac8:40cd:: with SMTP id f13mr79930028qtm.373.1594616963390; Sun, 12 Jul 2020 22:09:23 -0700 (PDT) MIME-Version: 1.0 References: <20200705195110.405139-1-anarsoul@gmail.com> <20200705195110.405139-2-anarsoul@gmail.com> In-Reply-To: From: Vasily Khoruzhick Date: Sun, 12 Jul 2020 22:08:57 -0700 Message-ID: Subject: Re: [PATCH 1/3] Bluetooth: Add new quirk for broken local ext features max_page To: Marcel Holtmann Cc: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree , arm-linux , kernel list , linux-bluetooth , "open list:NETWORKING [GENERAL]" , Ondrej Jirman Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.50 / 15.00 / 200.00 X-Rspamd-Queue-Id: BC607526CF X-Rspamd-UID: f35a9c On Tue, Jul 7, 2020 at 9:03 AM Marcel Holtmann wrote: > > Hi Vasily, > > > Some adapters (e.g. RTL8723CS) advertise that they have more than > > 2 pages for local ext features, but they don't support any features > > declared in these pages. RTL8723CS reports max_page = 2 and declares > > support for sync train and secure connection, but it responds with > > either garbage or with error in status on corresponding commands. > > please send the btmon for this so I can see what the controller is responding. Here is relevant part: < HCI Command: Read Local Extend.. (0x04|0x0004) plen 1 #228 [hci0] 6.889869 Page: 2 > HCI Event: Command Complete (0x0e) plen 14 #229 [hci0] 6.890487 Read Local Extended Features (0x04|0x0004) ncmd 2 Status: Success (0x00) Page: 2/2 Features: 0x5f 0x03 0x00 0x00 0x00 0x00 0x00 0x00 Connectionless Slave Broadcast - Master Connectionless Slave Broadcast - Slave Synchronization Train Synchronization Scan Inquiry Response Notification Event Coarse Clock Adjustment Secure Connections (Controller Support) Ping < HCI Command: Delete Stored Lin.. (0x03|0x0012) plen 7 #230 [hci0] 6.890559 Address: 00:00:00:00:00:00 (OUI 00-00-00) Delete all: 0x01 > HCI Event: Command Complete (0x0e) plen 6 #231 [hci0] 6.891170 Delete Stored Link Key (0x03|0x0012) ncmd 2 Status: Success (0x00) Num keys: 0 < HCI Command: Read Synchronizat.. (0x03|0x0077) plen 0 #232 [hci0] 6.891199 > HCI Event: Command Complete (0x0e) plen 9 #233 [hci0] 6.891788 Read Synchronization Train Parameters (0x03|0x0077) ncmd 2 invalid packet size 01 ac bd 11 80 80 ...... = Close Index: 00:E0:4C:23:99:87 [hci0] 6.891832 hci0 registration stops here and bluetoothctl doesn't even see the controller. > Regards > > Marcel > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cHlDAN/tC1+qiAAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 07:15:11 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id IJQ5Ot7tC18RdwAAgupzMw (envelope-from ); Mon, 13 Jul 2020 07:15:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 420E352830; Mon, 13 Jul 2020 07:15:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728869AbgGMFO6 (ORCPT + 1 other); Mon, 13 Jul 2020 01:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMFO6 (ORCPT ); Mon, 13 Jul 2020 01:14:58 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38958C061794; Sun, 12 Jul 2020 22:14:58 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id b185so11119104qkg.1; Sun, 12 Jul 2020 22:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HJfMKkuixe8TcFmSgPVFQeX2ebVBk2NIfALDJvpOegk=; b=t1YTVsAOG7g2piVPzr9XqfcOnf1nl6fNsrPCzOhU25jJur4I0iJE19KVWcxP9TixlH hA57KrAkQoI5IRkXUIwJDb5X00QSGkNpOaOxcD3Nan/XQTZVduQjrEg9Z14YNRooh0xq YkYJUAB1lMa26uVrPQtmfvx05NKveu8jVXhT7ISzvFaojV/IuhzB9juQsNLM3nZX6QQD /qypLMf6oZvwdlxwTxzwIwzH7E9u7lNMkYjJAceAoVyAthjE9BnK7zA8TE7Rk6oyIh60 ynOFniFe80hCUQ6h5+qkWRhJ8BTalGQHjoywwL3/780fkljffvktE9z46d8S7NnRo8NP Pcrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HJfMKkuixe8TcFmSgPVFQeX2ebVBk2NIfALDJvpOegk=; b=RNSKVmAOg6thIvBcvJUq6+3eFdcH5xiFQhlXG6eDRxyKu1jh76dauF/Wcf8Gfr4Szj 0mc0eBddzEBohWpVuIgzBXm+J3ucz7Uy/NZYrT3Kak9DHqdXsJ7L5xF+auWrBltrNpJE 1ECRdrdmD3ujcWZKz9VC2KX6O7JV2riVu117BsaYF1WXKixyRsO05faBSCspLOjQ7A5W SuaLmRt1j7HQu5N65MUeW/CQOYEIenkt8L7eZPkTlKtf9YERTlTS/+6n/IJYbTaSXOUz QAs3n4P7vSqNjQe569CGCueTbwgqDKnLYUsqKWYmWZ2u702THHU71nTv6wSbEfMzgVeI G/Ew== X-Gm-Message-State: AOAM530TRfWQQe0FuEMnTWGtHnCTIpHvAmpfk4oaAuE7NRB7AVjM1dDp rPt0QacZWdkpgA0zh26YNvuW9A2R841sMg9WzhU= X-Google-Smtp-Source: ABdhPJzZeRI4Vo+yZmNHHCrZWhnaKiX6BuWRvS5dt2QggK3l73mOoFiEQTzrVHTr+lD9cXIK0pQuLgSHhO8q2rUM2KU= X-Received: by 2002:a37:ec7:: with SMTP id 190mr75015576qko.421.1594617297477; Sun, 12 Jul 2020 22:14:57 -0700 (PDT) MIME-Version: 1.0 References: <20200705195110.405139-1-anarsoul@gmail.com> <20200705195110.405139-4-anarsoul@gmail.com> <20200706114709.l6poszepqsmg5p5r@gilmour.lan> In-Reply-To: <20200706114709.l6poszepqsmg5p5r@gilmour.lan> From: Vasily Khoruzhick Date: Sun, 12 Jul 2020 22:14:31 -0700 Message-ID: Subject: Re: [PATCH 3/3] arm64: allwinner: a64: enable Bluetooth On Pinebook To: Maxime Ripard Cc: Rob Herring , Chen-Yu Tsai , Marcel Holtmann , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree , arm-linux , linux-kernel , "open list:BLUETOOTH DRIVERS" , netdev , Ondrej Jirman Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 420E352830 X-Rspamd-UID: ec84ca On Mon, Jul 6, 2020 at 4:47 AM Maxime Ripard wrote: > > Hi, > > On Sun, Jul 05, 2020 at 12:51:10PM -0700, Vasily Khoruzhick wrote: > > Pinebook has an RTL8723CS WiFi + BT chip, BT is connected to UART1 > > and uses PL5 as device wake GPIO, PL6 as host wake GPIO the I2C > > controlling signals are connected to R_I2C bus. > > > > Enable it in the device tree. > > > > Signed-off-by: Vasily Khoruzhick > > --- > > .../arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts > > index 64b1c54f87c0..e63ff271be4e 100644 > > --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts > > @@ -408,6 +408,18 @@ &uart0 { > > status = "okay"; > > }; > > > > +&uart1 { > > + pinctrl-names = "default"; > > + pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>; > > + status = "okay"; > > You probably need uart-has-rtscts here Will add in v2 > > + > > + bluetooth { > > + compatible = "realtek,rtl8723cs-bt"; > > + device-wake-gpios = <&r_pio 0 5 GPIO_ACTIVE_LOW>; /* PL5 */ > > + host-wake-gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */ > > + }; > > And max-speed I guess? There's no max-speed in the schema for this bluetooth controller. Moreover it reads uart settings from firmware config. See btrtl_get_uart_settings() in drivers/bluetooth/btrtl.c > Maxime > > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OC78OGT6C1/ZwgAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:08:36 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 2BmLN2T6C187IAEA0J78UA (envelope-from ); Mon, 13 Jul 2020 08:08:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BA2E5A3182; Mon, 13 Jul 2020 08:08:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728950AbgGMGIb (ORCPT + 1 other); Mon, 13 Jul 2020 02:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbgGMGIb (ORCPT ); Mon, 13 Jul 2020 02:08:31 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44A59C061794 for ; Sun, 12 Jul 2020 23:08:31 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id w2so5569314pgg.10 for ; Sun, 12 Jul 2020 23:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=lSPwcC2DR49/2//P8zU4LAtRpkobwSTOzg0X78esOCI=; b=f7RUEu0cdj/1L6Lg5CRbLSE6/0A7vqmf22meXZ7FOfuzdYsGlmgSAMZFCWOjA23L5V jzWSdrbnUf4t5axOnu674NhY2SY4aVtFFVDrJfUa8OgdpppZaens5g9SxJftDp/8uLBn Pxij9pFcbQEzDtM0fsP3GqjVUFvZOy2pur6EQ6P+6s7tn+BpBdEBQqr3j1jNrDZDpMvw +FkRW8UbsFnrClLfD2efuRVLouScgh6ZcLaAnXBa/QMuFc3F2WcF87H9e5xCwvNX0GkZ o0nEvtwgWMApZzYCcKA0pYfY3oD3HhKmMSjme7rDtZB82yLIiNA9DmzAqEFHyc10l9g7 izVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lSPwcC2DR49/2//P8zU4LAtRpkobwSTOzg0X78esOCI=; b=tiDdYwlsot0x7IO/bLFyZTnZIjroebL86PdLwZ9xzNseFXJWqdvHiW5SCG99bjDb6Y ZvbCYRt7IAVxgDZVsNgfevnqBSByfMM9MxyPTJe6U/vzEbTgOQ+YOBLRe++sfGAdhRxJ /CAassUn8rnAk3g4XEcP0ucruva7yV7fsWIppcODz7L1Gz0VLca8ztHsA7NFK7dRSiHV N/ZqCRPYpKLhsfxwfMaAntuZkULDv8JREPbv5T/B+X+oEATYhLCYxambLjJln3ATOUf6 DmHDHJR9zzNOGgemhS1nKptlwP72D2PxujGrRrB9WRGFX0S6Q5/CgNqbI2CVhNfRDtk+ 2vag== X-Gm-Message-State: AOAM530BsGiCzDbcSIiZPLiaEzCeukYCD5zmjMzx32wOadttkQL1kjuK gx8C8jNnu9ftC8umGfs0xWuWkMGAlAZ3/A== X-Google-Smtp-Source: ABdhPJw4gVsV8fUA2KeZou9+47d4OZBI3ITpz1HJygYvamBtNLegypBSBAvOqnDHDlN+duX6+Q0+ig== X-Received: by 2002:a63:6945:: with SMTP id e66mr65331902pgc.177.1594620510558; Sun, 12 Jul 2020 23:08:30 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id e5sm12787172pjy.26.2020.07.12.23.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:08:30 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH 0/8] LL Privacy Support Date: Mon, 13 Jul 2020 11:42:12 +0530 Message-Id: <20200713061220.3252-1-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: BA2E5A3182 X-Rspamd-UID: 932cfd V4: patches are rebased Added support to use set Experimental feature to enable controller address resolution Marcel Holtmann (3): Bluetooth: Translate additional address type correctly Bluetooth: Configure controller address resolution if available Bluetooth: Update resolving list when updating whitelist Sathish Narasimman (5): Bluetooth: Translate additional address type during le_conn Bluetooth: Let controller creates RPA during le create conn Bluetooth: Enable/Disable address resolution during le create conn Bluetooth: Enable RPA Timeout Bluetooth: Enable controller RPA resolution using Experimental feature include/net/bluetooth/hci.h | 9 ++- include/net/bluetooth/hci_core.h | 3 + net/bluetooth/hci_conn.c | 7 +- net/bluetooth/hci_core.c | 17 +++++ net/bluetooth/hci_event.c | 21 ++++++ net/bluetooth/hci_request.c | 120 ++++++++++++++++++++++++++----- net/bluetooth/hci_request.h | 3 +- net/bluetooth/mgmt.c | 54 +++++++++++++- 8 files changed, 213 insertions(+), 21 deletions(-) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8IbQF2r6C1+FvAAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:08:42 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UAqAFmr6C1/BLgAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 08:08:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2142EA2765; Mon, 13 Jul 2020 08:08:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729003AbgGMGIf (ORCPT + 1 other); Mon, 13 Jul 2020 02:08:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbgGMGIf (ORCPT ); Mon, 13 Jul 2020 02:08:35 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68D4FC061794 for ; Sun, 12 Jul 2020 23:08:35 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id z5so5577067pgb.6 for ; Sun, 12 Jul 2020 23:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xSub10RztAkAVkR7dQ1tuib+ohmh4r9LyvxXZPcSzms=; b=CPd7Sm4TlRPWYosX9tW/r3dPGBy0AvY3Bh/M6+lf1lmsS1eV1GJJxepMVj+lgInh3G uMfGUDlI5jh8grnmG+h1wUxqNSule4RZkHwTAvDn+QZKridnb8Es9BBcMbB+zq6ffM/m 7LOo8Z5ZLWrTHQmrDo7uQoAAFUFqAIQDLdMxLJHalBIqkyGoIwb4L38oHx5XIr57GTss z17BE5cEHrL/5njPAd9jO1GlvQ9+yq7MTpvSlc8Sfo5YMdjmeRmG1kX5AXuZ8FKzt5Xh Qio+ITndxr1IS0NWdWX1/SPGTx8NyOSLuH4JCTpefswlmiAdcnECMUsOBCvg6eMT7vQ0 hG7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xSub10RztAkAVkR7dQ1tuib+ohmh4r9LyvxXZPcSzms=; b=DvXSLy6J1hOeQUHBS2oFfK0sC6iyQs/0vMGUaCpK03FuAB3zm6eU6wUux25Na0u02n L7on3STheFYdHf3XAkdm/1UTMbxADJggCBsqKAYNjuttkjobELJQSfsJy9PGyY3SR7Cc zrBrxOP8jMjD5/oa59cVUCcaD07osU+7m83rwc2qqznsA7H5ZyRAmydtDvWo+CXiwf0q eeqRAlU+iTKIEuve7dL9M9aXofgbbJuXvZjYtDMsqEBGjEuh1MQ+vsaOQR3B/9w3L0RK ROyedp7/Vc4OivuiCdi1+nQY+ZC9QqcjXagPVHpA3hAUDyCarmJPZcPOMxWIxB7tAnFy lWmA== X-Gm-Message-State: AOAM531OFgLOrHqC98eaEfJoAyVVys1GLXQRFlULvOLSXzofFBQMzMCC 1STjx92tAR46YHOTGzECuCRRDOvKrBwsCA== X-Google-Smtp-Source: ABdhPJyhnSC8rE3wulFMuWP6H7sWccibZlpM1+tMTVQZayNiuaBSX95D23frXmrh78ALllah5SUMDA== X-Received: by 2002:aa7:858c:: with SMTP id w12mr53777378pfn.143.1594620514778; Sun, 12 Jul 2020 23:08:34 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id e5sm12787172pjy.26.2020.07.12.23.08.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:08:34 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH 1/8] Bluetooth: Translate additional address type correctly Date: Mon, 13 Jul 2020 11:42:13 +0530 Message-Id: <20200713061220.3252-2-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713061220.3252-1-sathish.narasimman@intel.com> References: <20200713061220.3252-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2142EA2765 X-Rspamd-UID: 10d813 From: Marcel Holtmann When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci.h | 6 ++++-- net/bluetooth/hci_core.c | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 1f18f71363e9..abab8b5981a7 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -2268,8 +2268,10 @@ struct hci_ev_le_conn_complete { #define LE_EXT_ADV_SCAN_RSP 0x0008 #define LE_EXT_ADV_LEGACY_PDU 0x0010 -#define ADDR_LE_DEV_PUBLIC 0x00 -#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC 0x00 +#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC_RESOLVED 0x02 +#define ADDR_LE_DEV_RANDOM_RESOLVED 0x03 #define HCI_EV_LE_ADVERTISING_REPORT 0x02 struct hci_ev_le_advertising_info { diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6509f785dd14..4af208b82138 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3290,6 +3290,15 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list, { struct hci_conn_params *param; + switch (addr_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + addr_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + addr_type = ADDR_LE_DEV_RANDOM; + break; + } + list_for_each_entry(param, list, action) { if (bacmp(¶m->addr, addr) == 0 && param->addr_type == addr_type) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aO4XKL78C1/ZwgAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:18:38 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UIpeJr78C1+ELgAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 08:18:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5D49952C29; Mon, 13 Jul 2020 08:18:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728950AbgGMGSa (ORCPT + 1 other); Mon, 13 Jul 2020 02:18:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSa (ORCPT ); Mon, 13 Jul 2020 02:18:30 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EA8CC061794 for ; Sun, 12 Jul 2020 23:18:30 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id j20so5563790pfe.5 for ; Sun, 12 Jul 2020 23:18:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xSub10RztAkAVkR7dQ1tuib+ohmh4r9LyvxXZPcSzms=; b=PYtuEI24SUiceyjMGvP8DZ9fcw4kzUoqVdCJIl22dOi89C/ex/cniSYZpVA7KQixZG fY7OKc2Gr67Ho/vjnGI1+z3O+Vbsu/H8Etl81ziYf4MTFSqNCeml4SM20StY0T0vUO7h 63Bk5qiYquUOi69iuqbI/CChpvpXDscIFmOQCHX2EjJVq1e0eUfJbjcXLVs6T6EHAhiB Io2LtaNgBGF3ZuEjo9QbSeyuxJoR2txATJbgzZt+smMZ03DR+Y2emcwP/pt6ctl8gA62 nt02/TdUg3XDcSSpa/hsDJYOtVvbguU8AuLW3b8xBWF1eyWAmAAKgLqTFjIUjwhIuj6u JlLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xSub10RztAkAVkR7dQ1tuib+ohmh4r9LyvxXZPcSzms=; b=iBVQ24+U2kgNLnWcCwx+XrYyHhkNbGwuWSIBB+MqGHLgue0og36s6qqtOvExzUqkrN /65Dio2T/5ATHEDCHsxzg1FAckBLdtjSc+lLmIj8G06PFDIwkFOH+5sGgh9W+NzzNxzp alQ62XQRmUVrYNUgOcrbbjwjuwyAGHdL5UTqgRzlcGkWyus/9JrxrsyfOnYm+EtWDHzB WLufa4xz7DVLTZa4gvKWRd7hcN3iGxM6VlAL4eo3rz3Ts67BtgYuXcCZZ1p2ECc0uiQk wdh6aGIccCJmRStvVB6AxCQK6JMLc3WmirW3SuvaVxK5+AR6wsVQ22gx6wn5/rHa7ULG hMWw== X-Gm-Message-State: AOAM532GeoWXNtAI+hMp8mpH72z7jmtYnG44yVUb/avNtvj2Mo9tUb2S 5D/nKEPKpoGfJGgZ5Bpm94iv8Je6r693TQ== X-Google-Smtp-Source: ABdhPJxGd+UgMH68xXk6MSqy1axeE3LMMVxel5LtDzJ8mfBZs3SCMKaLVq4ysnZ8zH3kNagDdKxggQ== X-Received: by 2002:a63:6744:: with SMTP id b65mr48189679pgc.42.1594621109882; Sun, 12 Jul 2020 23:18:29 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:29 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v4 1/8] Bluetooth: Translate additional address type correctly Date: Mon, 13 Jul 2020 11:52:06 +0530 Message-Id: <20200713062213.3692-2-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5D49952C29 X-Rspamd-UID: 0793bc From: Marcel Holtmann When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci.h | 6 ++++-- net/bluetooth/hci_core.c | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 1f18f71363e9..abab8b5981a7 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -2268,8 +2268,10 @@ struct hci_ev_le_conn_complete { #define LE_EXT_ADV_SCAN_RSP 0x0008 #define LE_EXT_ADV_LEGACY_PDU 0x0010 -#define ADDR_LE_DEV_PUBLIC 0x00 -#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC 0x00 +#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC_RESOLVED 0x02 +#define ADDR_LE_DEV_RANDOM_RESOLVED 0x03 #define HCI_EV_LE_ADVERTISING_REPORT 0x02 struct hci_ev_le_advertising_info { diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6509f785dd14..4af208b82138 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3290,6 +3290,15 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list, { struct hci_conn_params *param; + switch (addr_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + addr_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + addr_type = ADDR_LE_DEV_RANDOM; + break; + } + list_for_each_entry(param, list, action) { if (bacmp(¶m->addr, addr) == 0 && param->addr_type == addr_type) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mGDrOW/6C19eugAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:08:47 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4GFdOG/6C1/YpQAAgupzMw (envelope-from ); Mon, 13 Jul 2020 08:08:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7DA82A179F; Mon, 13 Jul 2020 08:08:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729007AbgGMGIj (ORCPT + 1 other); Mon, 13 Jul 2020 02:08:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbgGMGIj (ORCPT ); Mon, 13 Jul 2020 02:08:39 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F0BAC061794 for ; Sun, 12 Jul 2020 23:08:39 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id mn17so5696915pjb.4 for ; Sun, 12 Jul 2020 23:08:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0uDYaKG7efI3+NfcjCvxS1+KgIa76fmhv33RI9RFLbw=; b=px2ksbWwSJhbjmUbIJ63HBzYBvOGlHyUBt9B0pF+4pgvgLXeq34BDrdMfO/gxmUZhp rYhY5ppi7cRTdLfhFiWmxYhgGYIZDEIJKHSxQVub8c6ZkMzIByaWxUZyBLCIcTO4DOdR Lt36K+tKEg5eJCT4CvnrE4QwjOe9aSspQlO0f1IfBS32TGpbYzPwbhwndW2Bsh5jbIn0 kF0wlJj9ZEIrCFsl+UtFTNTweBAlw28PwJ12H8TwXE1S0+ug4VDK0qRFrL3shHznLgqB uTY1G7tF3n7pizLiWSFR/gG15sqenq+0xvWd1wlWxRe+O52sUPq4fCOzn1drvUAodTPG ggAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0uDYaKG7efI3+NfcjCvxS1+KgIa76fmhv33RI9RFLbw=; b=ZlZMOGQXnHZQ2KW9aAJZzRvSTD7KrFegWb2nujH84prTNrqLmXtdgSInz89CX4gSoi B/QSjC8Ze9pNrJ7MiAy/YGWWbMYWWsi4qaPcRdWEj/IjCz/0k7E1sBHTevJR+GjPfBJ2 8WeoDfH3uDo4tVSHsdJ/UrK5qllf2UBlCr0p0fE8xWro7VSF/F2bOekhQiMxoetQNbBw auLZ8w0Iw3Qd35KvoPTna03jbt0Ydt/FSYfc0IhrIAkamBsWePOBN6SA7iaY1/CBOYSh hDt+ctI9wZ34yyG5XvhPCbY/yR7dkpYGVcg0gy655c45Pdk3RVoAEBZMn44LIm1OcXPX dLWg== X-Gm-Message-State: AOAM533ikU+eupZJb/oO7st17RpclNYB3Ho6lCATj9GAe+4k8CdEISJR 3om4ThPTCllKdx0AdFxl87woRqz/01pbFw== X-Google-Smtp-Source: ABdhPJwNQ6NolcuI4fo2EMFSmZV5v3hizkmCsrOVSp897Tzx1OrF8N7vMAaCwW8no8YvsCBGHQcl6g== X-Received: by 2002:a17:90a:21ef:: with SMTP id q102mr19042543pjc.101.1594620518503; Sun, 12 Jul 2020 23:08:38 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id e5sm12787172pjy.26.2020.07.12.23.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:08:38 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH 2/8] Bluetooth: Configure controller address resolution if available Date: Mon, 13 Jul 2020 11:42:14 +0530 Message-Id: <20200713061220.3252-3-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713061220.3252-1-sathish.narasimman@intel.com> References: <20200713061220.3252-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7DA82A179F X-Rspamd-UID: 729af8 From: Marcel Holtmann When the LL Privacy support is available, then as part of enabling or disabling passive background scanning, it is required to set up the controller based address resolution as well. Since only passive background scanning is utilizing the whitelist, the address resolution is now bound to the whitelist and passive background scanning. All other resolution can be easily done by the host stack. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_request.c | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 34ad5b207598..065250242a1b 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1359,6 +1359,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn); #define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \ ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED)) +/* Use LL Privacy based address resolution if supported */ +#define use_ll_privacy(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY) + /* Use ext scanning if set ext scan param and ext scan enable is supported */ #define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \ ((dev)->commands[37] & 0x40)) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 770b93758112..d3c7ddbcff33 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -675,6 +675,12 @@ void hci_req_add_le_scan_disable(struct hci_request *req) cp.enable = LE_SCAN_DISABLE; hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + __u8 enable = 0x00; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } } static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, @@ -816,7 +822,8 @@ static bool scan_use_rpa(struct hci_dev *hdev) } static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, - u16 window, u8 own_addr_type, u8 filter_policy) + u16 window, u8 own_addr_type, u8 filter_policy, + bool addr_resolv) { struct hci_dev *hdev = req->hdev; @@ -825,6 +832,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } + if (use_ll_privacy(hdev) && addr_resolv) { + u8 enable = 0x01; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } + /* Use ext scanning if set ext scan param and ext scan enable is * supported */ @@ -898,12 +910,18 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, } } +/* Ensure to call hci_req_add_le_scan_disable() first to disable the + * controller based address resolution to be able to reconfigure + * resolving list. + */ void hci_req_add_le_passive_scan(struct hci_request *req) { struct hci_dev *hdev = req->hdev; u8 own_addr_type; u8 filter_policy; u16 window, interval; + /* Background scanning should run with address resolution */ + bool addr_resolv = true; if (hdev->scanning_paused) { bt_dev_dbg(hdev, "Scanning is paused for suspend"); @@ -949,7 +967,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) bt_dev_dbg(hdev, "LE passive scan with whitelist = %d", filter_policy); hci_req_start_scan(req, LE_SCAN_PASSIVE, interval, window, - own_addr_type, filter_policy); + own_addr_type, filter_policy, addr_resolv); } static u8 get_adv_instance_scan_rsp_len(struct hci_dev *hdev, u8 instance) @@ -2748,6 +2766,8 @@ static int active_scan(struct hci_request *req, unsigned long opt) u8 own_addr_type; /* White list is not used for discovery */ u8 filter_policy = 0x00; + /* Discovery doesn't require controller address resolution */ + bool addr_resolv = false; int err; BT_DBG("%s", hdev->name); @@ -2770,7 +2790,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, hdev->le_scan_window_discovery, own_addr_type, - filter_policy); + filter_policy, addr_resolv); return 0; } -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id APqCFHX6C19eugAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:08:53 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8OgxE3X6C18rkgAAgupzMw (envelope-from ); Mon, 13 Jul 2020 08:08:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 16906A245F; Mon, 13 Jul 2020 08:08:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729037AbgGMGIn (ORCPT + 1 other); Mon, 13 Jul 2020 02:08:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbgGMGIm (ORCPT ); Mon, 13 Jul 2020 02:08:42 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDAE6C061794 for ; Sun, 12 Jul 2020 23:08:42 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id k5so5040059plk.13 for ; Sun, 12 Jul 2020 23:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3K8YriwZsyJ0Zz+v0ZMtNGnBg6m3R1aaPPOtC++AWHM=; b=OtgT0v669yyJ67928LZrReEFlyAUhdBrmf6BniYd3jo8P42mHDNHsjwP9g6Hfb+z6V /OswKBRefzMpfj+fzkP++Qwq0HBxSvzW+DgNnYUlhyhxbYZRbqyltWnTM2eLQBoZXDqn sS2W8ygJO2LqjdXwfAUu0BHN1Wn7EJcsgPao/rttJ92wOFGlKCpRXvOR8eFyrZ9hEzoO hfEfLz4xDhPetRLjchOlUV+NTPUMsjwL++uePtOc8l3StkoQdN/iifL5cehhUHdnbcZj EIY+6ZdtDdKa41CO+49eacDEUlfBPaI+PRYvpqovKUJWuqcKDEmM98vCXcoLb88+q5WH bG+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3K8YriwZsyJ0Zz+v0ZMtNGnBg6m3R1aaPPOtC++AWHM=; b=Q5H9fDVA1XcfWeyRtCvGF4lTv0+QDKku90z5t5SEMiLs/xJURv0Vs6O0sm6Y4xSCZy R7ApMEFBOFIO2IuRdq6EOAi1QfxizzB04mwUHQ+R96Bxl8d8wR1QGiXUALfcgGvvFBK1 CGtOPiKqzrns9ReHZ6/M1YlhqhVkXqLn9G4fSvuLz01YD6VewD8sv93UQxl156W3Ol97 L3rSM4uY8d4MVZDS2Ol0ZyfQsDoKj/hsLhWRpFxA9HdKhIFrRYehFZtsc04SUkPWS8B8 tNCDNMaDRlK+x9GdkxpiiPxW0V4p5Xpk+KEyaSyfyGBscb5EwHPIRENBtx/a6wNo8B+k eqhw== X-Gm-Message-State: AOAM532D7Q/IlORqkmf/ksAr5lh6HxxbXL0nd2AznSRCAYp+qXsso6O7 Q5MyFhk/tDLJar+maD29bRlWdrqFdBdjUg== X-Google-Smtp-Source: ABdhPJxqmaDnD9WQSziZUjlE86gBRjb9rxh79IXSexxrC3EL9cB0KVOxhLcwNieGFYMBHDM+AKUrvA== X-Received: by 2002:a17:90a:d086:: with SMTP id k6mr4616498pju.171.1594620522122; Sun, 12 Jul 2020 23:08:42 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id e5sm12787172pjy.26.2020.07.12.23.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:08:41 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH 3/8] Bluetooth: Update resolving list when updating whitelist Date: Mon, 13 Jul 2020 11:42:15 +0530 Message-Id: <20200713061220.3252-4-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713061220.3252-1-sathish.narasimman@intel.com> References: <20200713061220.3252-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 16906A245F X-Rspamd-UID: 068318 From: Marcel Holtmann When the whitelist is updated, then also update the entries of the resolving list for devices where IRKs are available. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- net/bluetooth/hci_request.c | 41 +++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index d3c7ddbcff33..2dc00604412c 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -694,6 +694,21 @@ static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, bt_dev_dbg(req->hdev, "Remove %pMR (0x%x) from whitelist", &cp.bdaddr, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST, sizeof(cp), &cp); + + if (use_ll_privacy(req->hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(req->hdev, bdaddr, bdaddr_type); + if (irk) { + struct hci_cp_le_del_from_resolv_list cp; + + cp.bdaddr_type = bdaddr_type; + bacpy(&cp.bdaddr, bdaddr); + + hci_req_add(req, HCI_OP_LE_DEL_FROM_RESOLV_LIST, + sizeof(cp), &cp); + } + } } /* Adds connection to white list if needed. On error, returns -1. */ @@ -714,7 +729,7 @@ static int add_to_white_list(struct hci_request *req, return -1; /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, ¶ms->addr, params->addr_type)) { return -1; } @@ -732,6 +747,28 @@ static int add_to_white_list(struct hci_request *req, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_ADD_TO_WHITE_LIST, sizeof(cp), &cp); + if (use_ll_privacy(hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(hdev, ¶ms->addr, + params->addr_type); + if (irk) { + struct hci_cp_le_add_to_resolv_list cp; + + cp.bdaddr_type = params->addr_type; + bacpy(&cp.bdaddr, ¶ms->addr); + memcpy(cp.peer_irk, irk->val, 16); + + if (hci_dev_test_flag(hdev, HCI_PRIVACY)) + memcpy(cp.local_irk, hdev->irk, 16); + else + memset(cp.local_irk, 0, 16); + + hci_req_add(req, HCI_OP_LE_ADD_TO_RESOLV_LIST, + sizeof(cp), &cp); + } + } + return 0; } @@ -772,7 +809,7 @@ static u8 update_white_list(struct hci_request *req) } /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, &b->bdaddr, b->bdaddr_type)) { return 0x00; } -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EDwFCXv6C19eugAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:08:59 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id qLCuB3v6C1/hpAAAgupzMw (envelope-from ); Mon, 13 Jul 2020 08:08:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 77A5CA3064; Mon, 13 Jul 2020 08:08:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729049AbgGMGIq (ORCPT + 1 other); Mon, 13 Jul 2020 02:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbgGMGIq (ORCPT ); Mon, 13 Jul 2020 02:08:46 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 191C3C061794 for ; Sun, 12 Jul 2020 23:08:46 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id p3so5591558pgh.3 for ; Sun, 12 Jul 2020 23:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s2IcTEAY6E8gqIiH1UvcKWcRD7F04eaPXNmCRRgH/EI=; b=UX+daJPIEuP+dPh8PvOHWEB96LtLs8zZGJ2Sf6WAnNrDdiFL7t/n21KdDqUnkzJveF l1a2A2P+XBmqMMCP+uYgo6Pf87yzjZL5IGshlMRuYCUKLKtw0XITUOmgFkUucLXU3MGJ tOPq6Y+HdDZm6OO1gmb0Dsy06o+ARmCygSpY8YIiASNNvctF2xTldH9i2b56lM6+jiF0 IzCDAU34IH1JzG1TPiVFk+zcbMXR5cp04DR3X3sqPYs4v3ufcVGrGJvKam9r1YLG11nj n8GeXfceaekQGucTVpDOrSOeqiFtmSyBCl82v0u8qoX0H6J2CMyllQDebbzYI4sR8Sxe VcOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s2IcTEAY6E8gqIiH1UvcKWcRD7F04eaPXNmCRRgH/EI=; b=Qi8/aEk01bResru4tJGJF5ldsmP0RdybwUXTCISyhtgd0uetS2xdlHugC7pXg8zBf4 oW8fcY/3ACIo8tpVKQJQX9Pa37LZv7bLxmSj/2LLJiwaJiSGd7R2Gb1f2RM1TMn5EHnt 5nO9T17azBNaKt415eGnVTMCTgWa1P6cga7M5rNdq5rSd6YsKu1w8cXCqIYYDANegzXl X5MOHdfwg3aYHXvpZqy2sVAlM4jDz8w3QtgilUlXNNMmh1VlgIOIoItRj9CaZARQbnNj xirXRlxt+d2cSDgsnsUHkwLkodGbgz2dchHhIVctH+70TR8CbNSDVjmBkgld5K4/ZyFj y3LQ== X-Gm-Message-State: AOAM532Ie/wNtOuyLFCe0j7fihVapDZql/ZD5q9dGo9XteCMw9K5LjjV y+4LVPA5aDnlQFv9Qf4w8DyEydfFFzyJ8g== X-Google-Smtp-Source: ABdhPJy9Uc1Yz2TEZcgp9KLzQFPJzYdZ/F1ZFmHPYFIvdbA+QirBsDe7f06Zg1P2gijcyDo5EGDIrA== X-Received: by 2002:a63:b90a:: with SMTP id z10mr64900272pge.277.1594620525467; Sun, 12 Jul 2020 23:08:45 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id e5sm12787172pjy.26.2020.07.12.23.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:08:45 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH 4/8] Bluetooth: Translate additional address type during le_conn Date: Mon, 13 Jul 2020 11:42:16 +0530 Message-Id: <20200713061220.3252-5-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713061220.3252-1-sathish.narasimman@intel.com> References: <20200713061220.3252-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: 77A5CA3064 X-Rspamd-UID: df92d4 When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. This patch is specially during LE_CREATE_CONN if using own_add_type as 0x02 or 0x03. Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_event.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 927bde511170..eae5bd4a53ac 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2296,6 +2296,22 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, if (!conn) return; + /* When using controller based address resolution, then the new + * address types 0x02 and 0x03 are used. These types need to be + * converted back into either public address or random address type + */ + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + switch (own_address_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + own_address_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + own_address_type = ADDR_LE_DEV_RANDOM; + break; + } + } + /* Store the initiator and responder address information which * is needed for SMP. These values will not change during the * lifetime of the connection. -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eEEXIID6C1/ZwgAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:09:04 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qFA0HoD6C1+ELgAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 08:09:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4C306A2F31; Mon, 13 Jul 2020 08:08:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729053AbgGMGIt (ORCPT + 1 other); Mon, 13 Jul 2020 02:08:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbgGMGIt (ORCPT ); Mon, 13 Jul 2020 02:08:49 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72626C061794 for ; Sun, 12 Jul 2020 23:08:49 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id z3so5525690pfn.12 for ; Sun, 12 Jul 2020 23:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nCVTz/TW1C8kDWW89hWnxqM0hLVoG7bmfidmPtnLD50=; b=GBQNpsxHWzus4iheWeS6lUiRhY4S92H+Qhv+rsw/+d2OrsJcTor9RmgbSXLwwfaytM kaKiuadUNhQS2YFRJWV7n5pin7xM5GlNrYXNP/fTJEzKfsLt2BO86GnfoUZptuEfi1gu NE8htptB+Q6h8QjHIVq92I0PcT7WjouvoyU1wKVoh6ZUf5hJxgO2i0seP0Pckxb38rPo umckJzxaCwf/AUoHGPykj65MgYS2zKI7uYrF8eEdQYg7GFLJauT1UcQFx2/Qo+IsVeno 6R/gqG2UUFtHsVkRug9R2DpgXs/OfQaDSrrCj6ONSFj5uFdPfGYubQMODAcqZZbm9710 B5lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nCVTz/TW1C8kDWW89hWnxqM0hLVoG7bmfidmPtnLD50=; b=j6Tdy5C2uPP66ZFJnwDeWYloeYbV9bYX9nbJBR1/sP8dVSdf7neI4hwl7jYgwLwzPX BHDUsdKoNfEQlsTamjW95OgV2fS0G/r0x+4Blm6GfaFomIeJOTxXuX2imgHjhZjzCrFP PWwhzi1dlxqLtrUQAwfi2NmS9KDN8De6R61zW8F5N4t8lUMy6+mxDJgGPsfnvb4gxx4f qMDXw1Xhmzv6kRcci6KO9HgbhuTpwcG7kyL8s8X/qLMrx7CRlbv4kmpNeIaJUyCaNu3s KHR0nLkwKP5pbFkkak969g7AkEBQBl6V2tJPvXvheybP2j1CrsqAafQ6Ci+ij1D0CA7t fmtw== X-Gm-Message-State: AOAM5320YcXWnWXyPjLqkv07J+pbFtyx6/8b1dQcyHUGPaESJBYB3YAe RgkT3c4e9sDNnXCwhNiHgdmi2FXmsy3J1Q== X-Google-Smtp-Source: ABdhPJwl3t7rbzBeWndSz7LewxAbB+WZaDknkJGrAGoZQkxaRQ4+Gftkk/MD3qzFtLqu/4r8KPZObA== X-Received: by 2002:a63:2241:: with SMTP id t1mr66885154pgm.440.1594620528835; Sun, 12 Jul 2020 23:08:48 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id e5sm12787172pjy.26.2020.07.12.23.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:08:48 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH 5/8] Bluetooth: Let controller creates RPA during le create conn Date: Mon, 13 Jul 2020 11:42:17 +0530 Message-Id: <20200713061220.3252-6-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713061220.3252-1-sathish.narasimman@intel.com> References: <20200713061220.3252-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.98 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4C306A2F31 X-Rspamd-UID: 9b8599 When address resolution is enabled and set_privacy is enabled let's use own address type as 0x03 Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_request.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 2dc00604412c..e16d5154b2cf 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2201,7 +2201,13 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, if (use_rpa) { int to; - *own_addr_type = ADDR_LE_DEV_RANDOM; + /* If Controller supports LL Privacy use own address type is + * 0x03 + */ + if (use_ll_privacy(hdev)) + *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED; + else + *own_addr_type = ADDR_LE_DEV_RANDOM; if (!hci_dev_test_and_clear_flag(hdev, HCI_RPA_EXPIRED) && !bacmp(&hdev->random_addr, &hdev->rpa)) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wK5mDIb6C1/ZwgAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:09:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WG5ICob6C18rkgAAgupzMw (envelope-from ); Mon, 13 Jul 2020 08:09:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9E714A2C65; Mon, 13 Jul 2020 08:09:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729059AbgGMGIw (ORCPT + 1 other); Mon, 13 Jul 2020 02:08:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbgGMGIw (ORCPT ); Mon, 13 Jul 2020 02:08:52 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76530C061794 for ; Sun, 12 Jul 2020 23:08:52 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id z5so5577355pgb.6 for ; Sun, 12 Jul 2020 23:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gqesOFNLs3tg0XsWgFXS5D1nTeu/tqmZApdWPI1nKEU=; b=SSBHmv6MrXGTdUjKJlZ6wRDj8BYpx0/JsYTjUEAP/hhWS4PoLO1jdYGLn8o3PkdBkU eQySQiT2EA0MfgvDByFUIV8C7lRm6bQXaPLR6isltPw6MFkkNpBcTzpFfsgLO+wy7lxB bhKT7gYlOT8TtM8rGYis7AAEr/UUFmovp6m7TzPkpejgGCCiby4GMrBg2DP6CS29YZS7 BsVLSLsBbYscJ3kputOuiejbCDpWEBq/WQb4OTOF0vxZybuT632lIcx6skhVVWzg0rtn CcSCwIliYnp1lWIa9OhZQuZxySUAiZnn8N2m69s9TU6V3Wr3DdPLFTL1JWE0/MuQbpti PdWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gqesOFNLs3tg0XsWgFXS5D1nTeu/tqmZApdWPI1nKEU=; b=Ya4gIQYMzFHCYlojdQhXSphowk7m2lRLZ6MgoFK8wSbAsemDFZQj93Klck2RdG74hn OIkdFBIyb1ygeW2oxiCwvKWHSYHeUKXWGzscewLsi5Gb3xpDWVc8QG/bI2bDZ89S1BmR +9fPR8Jph7cRBDHipRJu7LkNbMGn1d/eUtPZSWETHM+6IGWeNPILTyjqnd4uWVN2dG0X Eh/aKHvVnZQ+W+HGOuDwkNw0rTD3Z59tT5ujan6NNJUcUy0XYU5vWudaOYFmHGtPCCv+ 1Q8RmyMgBWVYJ6YhhGm8zD9+T/tHbYRnaKK9CLn4deF75iViDiVRBtL6oJMJL2fBAMQZ zo7g== X-Gm-Message-State: AOAM531N6ILq7KVURNL4JdCWdotnSQAFGrF5qkDJnzp5Bqr+j1sOwxwX PKw4/FzOc20o9nS42ib8MKlYXApY58NZ+g== X-Google-Smtp-Source: ABdhPJzJyTeFvqjbSipn7qyPqlMZ76dv/zUyZ7JuO6LH/Lc+cj4zebrwguLcfJTr04g/p9nRZJ/e3g== X-Received: by 2002:a63:2104:: with SMTP id h4mr69899532pgh.427.1594620531727; Sun, 12 Jul 2020 23:08:51 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id e5sm12787172pjy.26.2020.07.12.23.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:08:51 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH 6/8] Bluetooth: Enable/Disable address resolution during le create conn Date: Mon, 13 Jul 2020 11:42:18 +0530 Message-Id: <20200713061220.3252-7-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713061220.3252-1-sathish.narasimman@intel.com> References: <20200713061220.3252-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9E714A2C65 X-Rspamd-UID: 16626e In this patch if le_create_conn process is started restrict to disable address resolution and same is disabled during le_enh_connection_complete Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_conn.c | 7 +++++- net/bluetooth/hci_event.c | 4 ++++ net/bluetooth/hci_request.c | 45 ++++++++++++++++++++++++++++--------- net/bluetooth/hci_request.h | 3 ++- net/bluetooth/mgmt.c | 2 +- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 8805d68e65f2..caf1598758bf 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1003,6 +1003,11 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, struct hci_request req; int err; + /* This ensures that during disable le_scan address resolution + * will not be disabled if it is followed by le_create_conn + */ + bool rpa_le_conn = true; + /* Let's make sure that le is enabled.*/ if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { if (lmp_le_capable(hdev)) @@ -1103,7 +1108,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, * state. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, rpa_le_conn); hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED); } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index eae5bd4a53ac..684c68cb5c76 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5221,6 +5221,10 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->interval), le16_to_cpu(ev->latency), le16_to_cpu(ev->supervision_timeout)); + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + hci_req_disable_address_resolution(hdev); } static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index e16d5154b2cf..c3193f7f9ff0 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -428,7 +428,7 @@ static void __hci_update_background_scan(struct hci_request *req) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) return; - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); BT_DBG("%s stopping background scanning", hdev->name); } else { @@ -447,7 +447,7 @@ static void __hci_update_background_scan(struct hci_request *req) * don't miss any advertising (due to duplicates filter). */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); hci_req_add_le_passive_scan(req); @@ -652,7 +652,7 @@ void __hci_req_update_eir(struct hci_request *req) hci_req_add(req, HCI_OP_WRITE_EIR, sizeof(cp), &cp); } -void hci_req_add_le_scan_disable(struct hci_request *req) +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) { struct hci_dev *hdev = req->hdev; @@ -676,8 +676,9 @@ void hci_req_add_le_scan_disable(struct hci_request *req) hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + /* Disable address resolution */ if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { __u8 enable = 0x00; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } @@ -1072,7 +1073,7 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) { /* Before changing params disable scan if enabled */ if (hci_dev_test_flag(req->hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ hci_req_add_le_passive_scan(req); @@ -1140,7 +1141,7 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) /* Disable LE passive scan if enabled */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); @@ -1701,6 +1702,28 @@ int hci_req_update_adv_data(struct hci_dev *hdev, u8 instance) return hci_req_run(&req, NULL); } +static void enable_addr_resolution_complete(struct hci_dev *hdev, u8 status, + u16 opcode) +{ + BT_DBG("%s status %u", hdev->name, status); +} + +void hci_req_disable_address_resolution(struct hci_dev *hdev) +{ + struct hci_request req; + __u8 enable = 0x00; + + if (!use_ll_privacy(hdev) && + !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + return; + + hci_req_init(&req, hdev); + + hci_req_add(&req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + + hci_req_run(&req, enable_addr_resolution_complete); +} + static void adv_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode) { BT_DBG("%s status %u", hdev->name, status); @@ -2626,7 +2649,7 @@ static void bg_scan_update(struct work_struct *work) static int le_scan_disable(struct hci_request *req, unsigned long opt) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); return 0; } @@ -2729,7 +2752,7 @@ static int le_scan_restart(struct hci_request *req, unsigned long opt) return 0; } - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); if (use_ext_scan(hdev)) { struct hci_cp_le_set_ext_scan_enable ext_enable_cp; @@ -2820,7 +2843,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) * discovery scanning parameters. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable @@ -2935,14 +2958,14 @@ bool hci_req_stop_discovery(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { cancel_delayed_work(&hdev->le_scan_disable); - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); } ret = true; } else { /* Passive scanning */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); ret = true; } } diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index 0e81614d235e..12bea10e7d70 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -65,11 +65,12 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable); void __hci_req_update_name(struct hci_request *req); void __hci_req_update_eir(struct hci_request *req); -void hci_req_add_le_scan_disable(struct hci_request *req); +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn); void hci_req_add_le_passive_scan(struct hci_request *req); void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next); +void hci_req_disable_address_resolution(struct hci_dev *hdev); void hci_req_reenable_advertising(struct hci_dev *hdev); void __hci_req_enable_advertising(struct hci_request *req); void __hci_req_disable_advertising(struct hci_request *req); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 686ef4792831..c292d5de4dc3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -5226,7 +5226,7 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev, hci_req_init(&req, hdev); - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); hci_req_add_le_passive_scan(&req); hci_req_run(&req, NULL); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kIHcIIv6C1+FvAAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:09:15 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +KHEHov6C1+ELgAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 08:09:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3B581A3059; Mon, 13 Jul 2020 08:09:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729069AbgGMGIz (ORCPT + 1 other); Mon, 13 Jul 2020 02:08:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbgGMGIz (ORCPT ); Mon, 13 Jul 2020 02:08:55 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B13FC061794 for ; Sun, 12 Jul 2020 23:08:55 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id m16so3856788pls.5 for ; Sun, 12 Jul 2020 23:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PK9IFrqGA8tYf+eWNXSfj5UIMsffCcBtO2fOhU2TTN4=; b=mSGENNWuz+5DFcCC++eo64EguI3yOMGm+wbneGECzOF+p3uN2wnjo82+pBQDToUzOq glUk9u3mTEWocdjxMo41FNifcAmUveljzUTvjSvLgQmN64evIJZdyLY93Uy++YGXRFWc iOn9I5Daktdi0Zn3NJoj7W0SV4glqhfgdb3NlFRiEl4GeTfBJvvLe6plxy6aqc5aGuBx emMCW0DU/F4bJV5Pn9qkTixAta17IsJjOTWskH5Ra6XM9snQ5k1m3OXx+99Oyheg4BZW OMEEwAk4jZqyWTMPJit+rPUcKCoWJHznO7oTw/eB5vr0/foUbcUigz5snvWiziBfyrKu yT9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PK9IFrqGA8tYf+eWNXSfj5UIMsffCcBtO2fOhU2TTN4=; b=NmSuAuztgRWvO9Jtz/CWtbfTuGfut/AMbEj53YSmj9Q4psZas56eg7Odu6Z2MuJ8R+ 8Wbn4kuKvN5w6JLxmN4ez5jPqbKyNxW8aayqebm9euAhVH8tjPW7v+Uh/XWwUxPM1sQ/ /8jf31SuNAZl+l2B38l//6dfQKKlWOzjN188VLpRwvvLtb8hC72xxnllCVzksP2yjAwl PysC0ksTteoGZU48jxyAOQu52+SogGUkJ2kBKFSBxnmy8CQF4g5lVCFXDFsRj3KkKcFk Kxy6tA6vaSqdrJtv+o+nAbwFPHUh4IfHjDgKMx8lkG7bvRtAASUESuc6ub5hGQGm3fCp Jk0g== X-Gm-Message-State: AOAM5317LATQWkN4di7Mu3+qbZUJ6XaiRdBMh+tN+6DvOT/WG7lj9jZL qm0g+vOV1WE71GCxJNCYEi6591nnGfhQiw== X-Google-Smtp-Source: ABdhPJx2384XBpTsijDnW4mdF4LV1bBMe5R6BRfL9GoNcFsij5XZ1yQVyfU+y5reTHiSHJqM9ql3yA== X-Received: by 2002:a17:90b:33c5:: with SMTP id lk5mr18743064pjb.181.1594620534693; Sun, 12 Jul 2020 23:08:54 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id e5sm12787172pjy.26.2020.07.12.23.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:08:54 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH 7/8] Bluetooth: Enable RPA Timeout Date: Mon, 13 Jul 2020 11:42:19 +0530 Message-Id: <20200713061220.3252-8-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713061220.3252-1-sathish.narasimman@intel.com> References: <20200713061220.3252-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3B581A3059 X-Rspamd-UID: 285250 Enable RPA timeout during bluetooth initialization. The RPA timeout value is used from hdev, which initialized from debug_fs Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 2 ++ net/bluetooth/hci_core.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index abab8b5981a7..4ff2fc4498f3 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1637,6 +1637,8 @@ struct hci_rp_le_read_resolv_list_size { #define HCI_OP_LE_SET_ADDR_RESOLV_ENABLE 0x202d +#define HCI_OP_LE_SET_RPA_TIMEOUT 0x202e + #define HCI_OP_LE_READ_MAX_DATA_LEN 0x202f struct hci_rp_le_read_max_data_len { __u8 status; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 4af208b82138..2030536cc5d8 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -762,6 +762,14 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt) hci_req_add(req, HCI_OP_LE_CLEAR_RESOLV_LIST, 0, NULL); } + if (hdev->commands[35] & 0x40) { + __le16 rpa_timeout = cpu_to_le16(hdev->rpa_timeout); + + /* Set RPA timeout */ + hci_req_add(req, HCI_OP_LE_SET_RPA_TIMEOUT, 2, + &rpa_timeout); + } + if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) { /* Read LE Maximum Data Length */ hci_req_add(req, HCI_OP_LE_READ_MAX_DATA_LEN, 0, NULL); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WBydDJH6C1+FvAAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:09:21 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 8FVBCpH6C18rQwEA0J78UA (envelope-from ); Mon, 13 Jul 2020 08:09:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B0E4DA2C3E; Mon, 13 Jul 2020 08:09:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729076AbgGMGI6 (ORCPT + 1 other); Mon, 13 Jul 2020 02:08:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbgGMGI6 (ORCPT ); Mon, 13 Jul 2020 02:08:58 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B686C061794 for ; Sun, 12 Jul 2020 23:08:58 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id z3so5525810pfn.12 for ; Sun, 12 Jul 2020 23:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f1oHIKp+Xl1MtDR3jCF7Dp+Qm8VEDoGCEovuZWBlKwk=; b=opUp1mgiqEffoAGAiGzfX0j/sMLfLwQUNb1w+FbqcvexS5XvmotvlAln4jxDZDQ1kw 2IaVtk+P5h/AdjOEenkbm3sj9xOGPuKfHjcDOyuYJaO7SZRTGUyyjzfXegaJpKgTYcEB R6pddPdBPKJ+NsSyRzyBJsjoyvRRvVLsSHCwCEdfSWhS6uVBeUuIvRdODgTekF4ikSh2 7mTg5CkG/2zG7LrqvXkWQysgcpaOEKjrP5H6S0iTh2gXg0qnuW60OwReogjkDL4aw8Dp IBhgQMLqyjX4M+iy7vIJOq4oD7s8kVQSfsJGhRHDlrM672Dt974H8LkvVfpNfHVY1WaN Sz7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f1oHIKp+Xl1MtDR3jCF7Dp+Qm8VEDoGCEovuZWBlKwk=; b=ZzPsSWgyxlQ+2AtwgQ2YumV4RCMSAe4VBbc1Qeh3HE7A5ybyxu8bNPxIHcHYn5mUph OK4j6Od3HcL5HFcqVXQNzu+UYD/+lly+SDW/hggB9QeTIohKQASf8I5xKafutExLWpvZ 6jEvu6CU0QNyVoeAMcHfI7MCri7hV5HH6izOUmdGE7juXGg9Qx4jnfO+RYGMuAc6P7pE WeM9AqVqw3Au8B9r4Q5RFzcIO6/4hkByx1ZUH7wfVh4/sRGPHwqKoRxAabXm7H+CEF5V PNqLFsNbkUwjVbufh+RhiVptN0JcTooY9KQyr1OOWgcoM6Ca1G9bIfneXT88tpfHl617 8v0w== X-Gm-Message-State: AOAM531+38UmehCViCaAYBfuambuuRjHzck1OI2tJknZ1tfImsVhCxHE xL0/bZ8ZPHwPeDVr4dNj6ayJBUhLPZUxXw== X-Google-Smtp-Source: ABdhPJyXcXuFvO1GAtWOvs49o5HbgXpUT38BhwxbIFeklm2RDU2fJuvAmp/ASIx6L1qNLBEmeBtW0Q== X-Received: by 2002:a63:6cd:: with SMTP id 196mr67430676pgg.169.1594620537567; Sun, 12 Jul 2020 23:08:57 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id e5sm12787172pjy.26.2020.07.12.23.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:08:57 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH 8/8] Bluetooth: Enable controller RPA resolution using Experimental feature Date: Mon, 13 Jul 2020 11:42:20 +0530 Message-Id: <20200713061220.3252-9-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713061220.3252-1-sathish.narasimman@intel.com> References: <20200713061220.3252-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: B0E4DA2C3E X-Rspamd-UID: 1b6269 This patch adds support to enable the use of RPA Address resolution using expermental feature mgmt command. Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_event.c | 3 ++- net/bluetooth/hci_request.c | 6 +++-- net/bluetooth/mgmt.c | 52 +++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 4ff2fc4498f3..cb284365b4c1 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -307,6 +307,7 @@ enum { HCI_FORCE_BREDR_SMP, HCI_FORCE_STATIC_ADDR, HCI_LL_RPA_RESOLUTION, + HCI_ENABLE_RPA_RESOLUTION, HCI_CMD_PENDING, HCI_FORCE_NO_MITM, diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 684c68cb5c76..c8a5e1e4dba2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5222,7 +5222,8 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->latency), le16_to_cpu(ev->supervision_timeout)); - if (use_ll_privacy(hdev) && + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && + use_ll_privacy(hdev) && hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) hci_req_disable_address_resolution(hdev); } diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index c3193f7f9ff0..cb44b83539e6 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -677,7 +677,8 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) } /* Disable address resolution */ - if (use_ll_privacy(hdev) && + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && + use_ll_privacy(hdev) && hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { __u8 enable = 0x00; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); @@ -870,7 +871,8 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } - if (use_ll_privacy(hdev) && addr_resolv) { + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && + use_ll_privacy(hdev) && addr_resolv) { u8 enable = 0x01; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c292d5de4dc3..fbe02ab5fa05 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3759,6 +3759,12 @@ static const u8 simult_central_periph_uuid[16] = { 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, }; +/* 15c0a148-c273-11ea-b3de-0242ac130004 */ +static const u8 rpa_resolution_uuid[16] = { + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, +}; + static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { @@ -3795,6 +3801,17 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, idx++; } + if (hdev) { + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION)) + flags = BIT(0); + else + flags = 0; + + memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); + rp->features[idx].flags = cpu_to_le32(flags); + idx++; + } + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable @@ -3895,6 +3912,41 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, } #endif + if (!memcmp(cp->uuid, rpa_resolution_uuid, 16)) { + bool val; + int err; + + /* Parameters are limited to a single octet */ + if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + /* Only boolean on/off is supported */ + if (cp->param[0] != 0x00 && cp->param[0] != 0x01) + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + val = !!cp->param[0]; + + if (val) + hci_dev_set_flag(hdev, HCI_ENABLE_RPA_RESOLUTION); + else + hci_dev_clear_flag(hdev, HCI_ENABLE_RPA_RESOLUTION); + + memcpy(rp.uuid, rpa_resolution_uuid, 16); + rp.flags = cpu_to_le32(val ? BIT(0) : 0); + + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); + + err = mgmt_cmd_complete(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, 0, + &rp, sizeof(rp)); + + return err; + } + return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, MGMT_OP_SET_EXP_FEATURE, MGMT_STATUS_NOT_SUPPORTED); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UGchBIT8C1+FvAAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:17:40 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +KNIAoT8C18NBAAAlScrYA (envelope-from ); Mon, 13 Jul 2020 08:17:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CE43C525EE; Mon, 13 Jul 2020 08:17:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727890AbgGMGRe (ORCPT + 1 other); Mon, 13 Jul 2020 02:17:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbgGMGRe (ORCPT ); Mon, 13 Jul 2020 02:17:34 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E892DC061794 for ; Sun, 12 Jul 2020 23:17:33 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id k23so12203294iom.10 for ; Sun, 12 Jul 2020 23:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Gj7c2u/6Xj4mWnH3j6aEe5TRH2mmbMZCrZufKif45fA=; b=eocS2KjVFzniq451GRWftEmQK0Rziw1optkroY/jV85O4iAYswEGWXkdg5Ac6xOhi7 zWeGq5u5BxHcuOdZNMjKPJjhQxS91XkaHO1ZJXgMQlZgw7cTsixvT7BnlX83PmIVFCCx e2alrWDAafkQb9FuE86qNRrrxPbWZ7UlSdId6fwnZIsING613+jCUQSeIJOvfUAyR1wo BTp+FfUzPQHuZKWbgxt1IMFJY1AE9CYNnKDpCe8UfSppwk8N2/hlBjbHzlto9D0A8+E9 notOoZLe8/T1ANJg09o/WurYi7PCy8MciE0OvM0nbxYjNZZE+wm6t6IxLk2RTL7rCmgh grOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Gj7c2u/6Xj4mWnH3j6aEe5TRH2mmbMZCrZufKif45fA=; b=rTA8jByAsWMRzAO22GaXf2EI0J2TkLLN4InkjcZrcNG5GU2ZUewtCC+WY1P2Cx+Hu8 AgeSVfFFY6aYkRHJ1SgAdpIF8AvCYgeesVN0hCEhfN7kzj6KXTO/F99NUpp47TZU8cFH RLtEyKD82i0zA2JloS3Gt1DF6qNa6m6KyHLXEuyDJcNSY9APQbSiZHkwRkxUELqg9hAJ 1WKlh1vley1fdoHmgj0psE69bq5TuSYrZhKrsrFcwGcXM1zd73beXBnI5wXGUUjCUuR0 x8/ssR5UFaBTP5JVsTfMIxIuVWupCzpwRU8/ekoYJW88QsypUS0gHkuQCoNRA1DualYE y3WA== X-Gm-Message-State: AOAM533BqM+2Dv9NnNPPFzFWkbAnfm5Xjt7m3yEETFwfVSa+eI9Awqtx EsH4+UqfE9dwcCGCUMYpaTXaQxdpjejmfEWOkAk4705O X-Google-Smtp-Source: ABdhPJzS5UktmnrkldUOpvqq5Zlx+xxS6td3Bvics4XsH2o9MOoVWGC91pR5BUDKb4VQZYhvfyw+kAqbT3E/gt7VqDg= X-Received: by 2002:a05:6602:21c7:: with SMTP id c7mr59628814ioc.1.1594621053137; Sun, 12 Jul 2020 23:17:33 -0700 (PDT) MIME-Version: 1.0 References: <20200713061220.3252-1-sathish.narasimman@intel.com> In-Reply-To: <20200713061220.3252-1-sathish.narasimman@intel.com> From: Sathish Narasimman Date: Mon, 13 Jul 2020 11:47:22 +0530 Message-ID: Subject: Re: [PATCH 0/8] LL Privacy Support To: Bluez mailing list Cc: Sathish Narasimman Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: CE43C525EE X-Rspamd-UID: 3b7fd2 Please Ignore this version as failed to mention the Version in the Subject On Mon, Jul 13, 2020 at 11:38 AM Sathish Narasimman wrote: > > V4: patches are rebased > Added support to use set Experimental feature to enable controller > address resolution > > Marcel Holtmann (3): > Bluetooth: Translate additional address type correctly > Bluetooth: Configure controller address resolution if available > Bluetooth: Update resolving list when updating whitelist > > Sathish Narasimman (5): > Bluetooth: Translate additional address type during le_conn > Bluetooth: Let controller creates RPA during le create conn > Bluetooth: Enable/Disable address resolution during le create conn > Bluetooth: Enable RPA Timeout > Bluetooth: Enable controller RPA resolution using Experimental feature > > include/net/bluetooth/hci.h | 9 ++- > include/net/bluetooth/hci_core.h | 3 + > net/bluetooth/hci_conn.c | 7 +- > net/bluetooth/hci_core.c | 17 +++++ > net/bluetooth/hci_event.c | 21 ++++++ > net/bluetooth/hci_request.c | 120 ++++++++++++++++++++++++++----- > net/bluetooth/hci_request.h | 3 +- > net/bluetooth/mgmt.c | 54 +++++++++++++- > 8 files changed, 213 insertions(+), 21 deletions(-) > > -- > 2.17.1 > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kHOYCbn8C1/ZwgAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:18:33 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IDc8CLn8C195OQAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 08:18:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DED935080C; Mon, 13 Jul 2020 08:18:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727830AbgGMGS1 (ORCPT + 1 other); Mon, 13 Jul 2020 02:18:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGS1 (ORCPT ); Mon, 13 Jul 2020 02:18:27 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 878BBC061794 for ; Sun, 12 Jul 2020 23:18:27 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id m22so5585411pgv.9 for ; Sun, 12 Jul 2020 23:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=lSPwcC2DR49/2//P8zU4LAtRpkobwSTOzg0X78esOCI=; b=mniONp8yZbx4LITqr9V3yBGfDgQX26QyIhgcZzrx25zC1gpUB8sxP+pQgDaBlr7W/t smjErQXwCpFEoniH/5Ab8scCETmz8YbMVWpwjcgCCee4pnSEqQsa8f9ZlCEDQnyQBG6V m65xm9ik+t0v4cO9x5sIjfvRNyXYT0rY72b1KkudZiOK/a5FNwpVVecVtEWgwQii5wDs g3nct6gGK1z2vtsqoL2EP9bGybOpbMZASCwDECZzuBS6SSxkaxq+Jyv/oQreNb+FpeBZ oVKpI4DJvjhfja4ODiN1q4IcNQSghSp9GTBwzmTnBZEdhtqaCwKyDyF5CAZ40fneF7FN RRmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lSPwcC2DR49/2//P8zU4LAtRpkobwSTOzg0X78esOCI=; b=BTC+f+TXGYzQ1GeIBtDr20rklEOXT30qXDP5ZIBfzVpcasDSCxyWibJ9+ShTW0i2Ju L06Jrf5K2tM18F632DHhZ5ZYRIYFeBt6uSzHFNcCGjw371/zRQHcJpMAVTL0STkxGVHh RNSg/hZflk6533yraaSKDKl4tPD80c3X+xvE2tQtzN+fHyjXsuyTttHb1KrTBipStcRR 0u5bZOB73tYw4dbdI6kBYcWxBW9sqpt/qfg2YjbrGu0JdXrWZZokRrwvvOpCj3AFzdhM ds0tFwlYBr42YBCmouo7OJDT0xuwi5THZ9HgBagISMh/RC9sr9f9clnvj4mUquB4JkmL z8yA== X-Gm-Message-State: AOAM5327VjnGR4uIK6tcIPml0SdPbPJcrj3PdnVvVVMtG/1US/q0AqFS eAm8dCdaama6vl/c7zSdPxax3ANwly1BWQ== X-Google-Smtp-Source: ABdhPJxbGOrzD4wzLJHfLQ1sD04msuAiIZuypAPQfHnp68ikFUiaLz2l3tZeLXssBylLBqzj1BX/Nw== X-Received: by 2002:aa7:871a:: with SMTP id b26mr66248001pfo.294.1594621106690; Sun, 12 Jul 2020 23:18:26 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:26 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v4 0/8] LL Privacy Support Date: Mon, 13 Jul 2020 11:52:05 +0530 Message-Id: <20200713062213.3692-1-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: DED935080C X-Rspamd-UID: 35bb22 V4: patches are rebased Added support to use set Experimental feature to enable controller address resolution Marcel Holtmann (3): Bluetooth: Translate additional address type correctly Bluetooth: Configure controller address resolution if available Bluetooth: Update resolving list when updating whitelist Sathish Narasimman (5): Bluetooth: Translate additional address type during le_conn Bluetooth: Let controller creates RPA during le create conn Bluetooth: Enable/Disable address resolution during le create conn Bluetooth: Enable RPA Timeout Bluetooth: Enable controller RPA resolution using Experimental feature include/net/bluetooth/hci.h | 9 ++- include/net/bluetooth/hci_core.h | 3 + net/bluetooth/hci_conn.c | 7 +- net/bluetooth/hci_core.c | 17 +++++ net/bluetooth/hci_event.c | 21 ++++++ net/bluetooth/hci_request.c | 120 ++++++++++++++++++++++++++----- net/bluetooth/hci_request.h | 3 +- net/bluetooth/mgmt.c | 54 +++++++++++++- 8 files changed, 213 insertions(+), 21 deletions(-) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kP5UDcX8C1/ZwgAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:18:45 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CGYIDMX8C1+9swAAgupzMw (envelope-from ); Mon, 13 Jul 2020 08:18:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D65C852B0E; Mon, 13 Jul 2020 08:18:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729013AbgGMGSj (ORCPT + 1 other); Mon, 13 Jul 2020 02:18:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSj (ORCPT ); Mon, 13 Jul 2020 02:18:39 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96AB1C061794 for ; Sun, 12 Jul 2020 23:18:39 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id f16so5729875pjt.0 for ; Sun, 12 Jul 2020 23:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0uDYaKG7efI3+NfcjCvxS1+KgIa76fmhv33RI9RFLbw=; b=hUtjcKtgoBapahxkdmERTduk04+ofTqj2xNcTSMk5qW2ivR/AIl59W9/v5Co1Yxh9O Dhd0WSJnUc7opL0EeEDVgG3XO+r4LwLM08bDTuFhChIElShcLVinBFAUDXGybgGg7+ER agSrHrS/xhHJrkV0YWT/p270AcUUQDH9EaSoorbaTDIcO6RBTGva5PUtVuZOAlWUPfsU AVtNNTryoNn7GcvJJHa/BaanIOCqaWKSQW0TowMYDQfebYfSB92bLy4FCXY1RvYx4pGo kHu6ClK4zfqQ0pT1BrECmGtINU0vkyMqN01YJ74TQP1HN8isfzwIYRsSUnNdgPHN8NrO Rjug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0uDYaKG7efI3+NfcjCvxS1+KgIa76fmhv33RI9RFLbw=; b=sJb8SkzzNkPjwzs21AlGXx64LwcowYLsc2hRdJ3CfCJFfgkoouoLWWcfYn1JFDSAu5 1VNYuRd52dykLZcEBVuqKNksQ56ZyJJ/9HXQ58hDtPTY26yBu3v9EgYAXEJItVl3zcv1 x9RwFGDA1TDLcFqy4dbiEewXfml91oO+EhyDAyWzN0d3twC5IdTP+Gxj31VtMh0glfEv Q+ge9gl9D9SglEJQQ9RsmYYH61nC2sbnnhuMmZ/3oKRjvD7rcoRjZrUfc/X93aSeP6Yb itXtotqBHx4Zi0sbbF6PYOWvr3j5Pl0V4ZggjTqb3eEm1YibDO+TjOcKbMry8mUpybGV lpVQ== X-Gm-Message-State: AOAM530hL/VhSNLB3vZnteelHK2ZqHqtj8/+RfaLbmQGtZfQ+weBvGyn lz9dFdpHl6QzQJnz+kKed/Ebb5131OcpmA== X-Google-Smtp-Source: ABdhPJx8P3oxwtEo0ns2ScQu4IKDUTrgpWu/hD6SWZtM7YMg2zCU3ZDHaH8MJybO016/eVhWiFIZ3Q== X-Received: by 2002:a17:902:654e:: with SMTP id d14mr26325038pln.60.1594621118885; Sun, 12 Jul 2020 23:18:38 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:38 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v4 2/8] Bluetooth: Configure controller address resolution if available Date: Mon, 13 Jul 2020 11:52:07 +0530 Message-Id: <20200713062213.3692-3-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: D65C852B0E X-Rspamd-UID: 9c75c8 From: Marcel Holtmann When the LL Privacy support is available, then as part of enabling or disabling passive background scanning, it is required to set up the controller based address resolution as well. Since only passive background scanning is utilizing the whitelist, the address resolution is now bound to the whitelist and passive background scanning. All other resolution can be easily done by the host stack. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_request.c | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 34ad5b207598..065250242a1b 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1359,6 +1359,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn); #define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \ ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED)) +/* Use LL Privacy based address resolution if supported */ +#define use_ll_privacy(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY) + /* Use ext scanning if set ext scan param and ext scan enable is supported */ #define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \ ((dev)->commands[37] & 0x40)) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 770b93758112..d3c7ddbcff33 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -675,6 +675,12 @@ void hci_req_add_le_scan_disable(struct hci_request *req) cp.enable = LE_SCAN_DISABLE; hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + __u8 enable = 0x00; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } } static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, @@ -816,7 +822,8 @@ static bool scan_use_rpa(struct hci_dev *hdev) } static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, - u16 window, u8 own_addr_type, u8 filter_policy) + u16 window, u8 own_addr_type, u8 filter_policy, + bool addr_resolv) { struct hci_dev *hdev = req->hdev; @@ -825,6 +832,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } + if (use_ll_privacy(hdev) && addr_resolv) { + u8 enable = 0x01; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } + /* Use ext scanning if set ext scan param and ext scan enable is * supported */ @@ -898,12 +910,18 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, } } +/* Ensure to call hci_req_add_le_scan_disable() first to disable the + * controller based address resolution to be able to reconfigure + * resolving list. + */ void hci_req_add_le_passive_scan(struct hci_request *req) { struct hci_dev *hdev = req->hdev; u8 own_addr_type; u8 filter_policy; u16 window, interval; + /* Background scanning should run with address resolution */ + bool addr_resolv = true; if (hdev->scanning_paused) { bt_dev_dbg(hdev, "Scanning is paused for suspend"); @@ -949,7 +967,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) bt_dev_dbg(hdev, "LE passive scan with whitelist = %d", filter_policy); hci_req_start_scan(req, LE_SCAN_PASSIVE, interval, window, - own_addr_type, filter_policy); + own_addr_type, filter_policy, addr_resolv); } static u8 get_adv_instance_scan_rsp_len(struct hci_dev *hdev, u8 instance) @@ -2748,6 +2766,8 @@ static int active_scan(struct hci_request *req, unsigned long opt) u8 own_addr_type; /* White list is not used for discovery */ u8 filter_policy = 0x00; + /* Discovery doesn't require controller address resolution */ + bool addr_resolv = false; int err; BT_DBG("%s", hdev->name); @@ -2770,7 +2790,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, hdev->le_scan_window_discovery, own_addr_type, - filter_policy); + filter_policy, addr_resolv); return 0; } -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IOnpAtL8C19eugAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:18:58 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id MDpsAdL8C18x8AEADc0bRg (envelope-from ); Mon, 13 Jul 2020 08:18:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A437452747; Mon, 13 Jul 2020 08:18:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729196AbgGMGSn (ORCPT + 1 other); Mon, 13 Jul 2020 02:18:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSm (ORCPT ); Mon, 13 Jul 2020 02:18:42 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7634FC061794 for ; Sun, 12 Jul 2020 23:18:42 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id k5so5050557plk.13 for ; Sun, 12 Jul 2020 23:18:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3K8YriwZsyJ0Zz+v0ZMtNGnBg6m3R1aaPPOtC++AWHM=; b=l7r1+2ibixy8apzMhAuVaOsq8w1ErNaDrFgvnQWRdtBPq6k2i9t41yo1oOtUz2ROHu OYNHQ02kojU884wfCU4H1ijFOYTIpXxrmFUD5wpFbE06ILkj8pNzrpd1iM34MDFiPQxw LtVAyGl2eIYC3uYdsIqeBZJ1wZtyjt10aRCQZoTdKt/HxqOEoP2Qtj74d9MJ2PuyWCpx xVK684TDkCCbC1I6pYVCS0fzI94eZpVzYWmLq5zX5aQKmPV8EwQrzQ9b8kSb6NsIS3sz XITkco4F1vKA3T6+OayCP4qg1C8gmALJHpbuRvUP3zhhUkU8welCJa2hbAM/5oY6I4jq L0cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3K8YriwZsyJ0Zz+v0ZMtNGnBg6m3R1aaPPOtC++AWHM=; b=dBDJl8jVE07omojxl2EegmDaxtFG/YwcLPaXzAjKn1bxLzv2CKX3RS6Zu+sGDfApx0 j3ytRaEUwL0VuquWCxScIevcwCy0/m5CbpEkCTooMH+8Zl9U1tD7nzUCHrghYRnTgCqn +Z8pkDbPZUc1N6yeV8DjWBmpFcKu7JZRk3aVoPtIFeW+zJwlvUBnkTSG0I80X+G0Sn3e Kdt+tPIUb80ioJezTwXvT3JkijoYrxOnmB7zYATQ+OI2JKtv1oJ6zzabN7Rf9tR7uCod ofpUDZ1y8jAuLbid85smU7zX+lFl5h9j6ILXQ2QHZTnxzN+AncYo28mgx4C9dZ2Qk6XZ dLzA== X-Gm-Message-State: AOAM530fBqHJGMG23N0cXe0h3R40Qc4wTVYa67w7Nm4su03hcI3sYX6m 59G4IGdy06Ob2IEn7JRL6iYtAnOvIAxHWw== X-Google-Smtp-Source: ABdhPJyLJ7HNm2uwWsfCO2XXgDAfyFxkE51/JUsXzkLqYj5npPSEIpp1cWTMx+UtuKQ37Dpev0oydA== X-Received: by 2002:a17:90a:764c:: with SMTP id s12mr18481758pjl.201.1594621121796; Sun, 12 Jul 2020 23:18:41 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:41 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v4 3/8] Bluetooth: Update resolving list when updating whitelist Date: Mon, 13 Jul 2020 11:52:08 +0530 Message-Id: <20200713062213.3692-4-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: A437452747 X-Rspamd-UID: aef57b From: Marcel Holtmann When the whitelist is updated, then also update the entries of the resolving list for devices where IRKs are available. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- net/bluetooth/hci_request.c | 41 +++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index d3c7ddbcff33..2dc00604412c 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -694,6 +694,21 @@ static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, bt_dev_dbg(req->hdev, "Remove %pMR (0x%x) from whitelist", &cp.bdaddr, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST, sizeof(cp), &cp); + + if (use_ll_privacy(req->hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(req->hdev, bdaddr, bdaddr_type); + if (irk) { + struct hci_cp_le_del_from_resolv_list cp; + + cp.bdaddr_type = bdaddr_type; + bacpy(&cp.bdaddr, bdaddr); + + hci_req_add(req, HCI_OP_LE_DEL_FROM_RESOLV_LIST, + sizeof(cp), &cp); + } + } } /* Adds connection to white list if needed. On error, returns -1. */ @@ -714,7 +729,7 @@ static int add_to_white_list(struct hci_request *req, return -1; /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, ¶ms->addr, params->addr_type)) { return -1; } @@ -732,6 +747,28 @@ static int add_to_white_list(struct hci_request *req, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_ADD_TO_WHITE_LIST, sizeof(cp), &cp); + if (use_ll_privacy(hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(hdev, ¶ms->addr, + params->addr_type); + if (irk) { + struct hci_cp_le_add_to_resolv_list cp; + + cp.bdaddr_type = params->addr_type; + bacpy(&cp.bdaddr, ¶ms->addr); + memcpy(cp.peer_irk, irk->val, 16); + + if (hci_dev_test_flag(hdev, HCI_PRIVACY)) + memcpy(cp.local_irk, hdev->irk, 16); + else + memset(cp.local_irk, 0, 16); + + hci_req_add(req, HCI_OP_LE_ADD_TO_RESOLV_LIST, + sizeof(cp), &cp); + } + } + return 0; } @@ -772,7 +809,7 @@ static u8 update_white_list(struct hci_request *req) } /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, &b->bdaddr, b->bdaddr_type)) { return 0x00; } -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cKVFNtr8C19eugAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:19:06 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 6GjANNr8C19K+QEAlScrYA (envelope-from ); Mon, 13 Jul 2020 08:19:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 13DD752A3B; Mon, 13 Jul 2020 08:19:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729198AbgGMGSp (ORCPT + 1 other); Mon, 13 Jul 2020 02:18:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSp (ORCPT ); Mon, 13 Jul 2020 02:18:45 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A5AFC061794 for ; Sun, 12 Jul 2020 23:18:45 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id m16so3866848pls.5 for ; Sun, 12 Jul 2020 23:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s2IcTEAY6E8gqIiH1UvcKWcRD7F04eaPXNmCRRgH/EI=; b=j6HuWtKXJA0LJN3It5/huBCCyvIsHDa95qy/PrtPY0SHVarddS5eFhjMMqvUr4b+tV 8op+y5evL7Ai0OdNrqE6iKaPeBgO5uEtIyX5YC0whmpQvgIgeCV7Z1Dp5Jwmr6DmexUQ BfVUXfMTrzwTHvoNEGDIJEetl2T1Ps2RMrxWRClU7psHNsYbXnZtg4Yg6YFz4a/1p6V1 kQIcJN9pkyXPaUI5Tpz7rAshwzulXlfAdOyJRTL2Ok5xJswtLtf6mdKL9N9qyLKbaGQC nCsoaTYmKMvQCdMWzwhXIIclBJYLn/td3cxCkF9me1ACxIMayTj9gYip7js9DgxZjOdL wZEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s2IcTEAY6E8gqIiH1UvcKWcRD7F04eaPXNmCRRgH/EI=; b=KlXUnqSdYe1ATUvPBqv/W3SqlPqtKLNHHWdi4YzzwS6uU8XPHUOoKaLE/FQXoNhEsd oyLuTnusQaQ6QPGlfLSsBJ8Q+ZlxKWWeqcFTfiXEpPUjI2KRdg+Qkob66Kx3syx+6u3d ODCptGPpNXghCE1+uIzauTgTZY/ZeNBIKCwHHbCTB6duSwin3r6dOCzafs/csdfIx785 SFatGzZBGj5/0iN3xoJya1s0YDN1ppu6nrqQVJsw4VaCAEShM6Rj1RHtR5jSI8Eao6Na bldd6Q7chhD4p2Pw25teEmeHjPR8p1g8vIzmPq0GwVeOtliLx5gFQAmArNhA9TzB1WOB XO4g== X-Gm-Message-State: AOAM53202gMV53YHxRm+CH+JYu1jYd9I+k6ZcDV2bbBW6V1JissUhUUe Ap7oWYy5XOWjgf/q2kheI0l5ek3v9+Y/yQ== X-Google-Smtp-Source: ABdhPJyn8nljlXT68UpGRDusEmqYlIgFDYMFEfPtiFKpaBpclIpd+Vw8jj8HKc5t47FbUbVeC7TvwA== X-Received: by 2002:a17:90a:8a8b:: with SMTP id x11mr19062807pjn.127.1594621124489; Sun, 12 Jul 2020 23:18:44 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:44 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v4 4/8] Bluetooth: Translate additional address type during le_conn Date: Mon, 13 Jul 2020 11:52:09 +0530 Message-Id: <20200713062213.3692-5-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: 13DD752A3B X-Rspamd-UID: 4fb6f8 When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. This patch is specially during LE_CREATE_CONN if using own_add_type as 0x02 or 0x03. Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_event.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 927bde511170..eae5bd4a53ac 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2296,6 +2296,22 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, if (!conn) return; + /* When using controller based address resolution, then the new + * address types 0x02 and 0x03 are used. These types need to be + * converted back into either public address or random address type + */ + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + switch (own_address_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + own_address_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + own_address_type = ADDR_LE_DEV_RANDOM; + break; + } + } + /* Store the initiator and responder address information which * is needed for SMP. These values will not change during the * lifetime of the connection. -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QHHCDuD8C1/ZwgAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:19:12 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AFqdDeD8C18G4QEADc0bRg (envelope-from ); Mon, 13 Jul 2020 08:19:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 07B5952762; Mon, 13 Jul 2020 08:19:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729199AbgGMGSs (ORCPT + 1 other); Mon, 13 Jul 2020 02:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSs (ORCPT ); Mon, 13 Jul 2020 02:18:48 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC915C061794 for ; Sun, 12 Jul 2020 23:18:47 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id f2so5062069plr.8 for ; Sun, 12 Jul 2020 23:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nCVTz/TW1C8kDWW89hWnxqM0hLVoG7bmfidmPtnLD50=; b=JgQsTLPhaOkj5WpKoQTBdC0hd15AEi3eR+BAxFwUa4FmUr1K13f7vAo8cR24V3CVxj UDjufzkeTE4vvM3swvHZvaTQsl+RL6xv0wfxkEX7+SNWlwqVBImvISzRrJ1Gscr92Rl+ VF40S6A8c054Ys2CTDO92263itje5gqOq4gq+RLiM8RtWbkenJuk5Of27Q2jsDxblaE7 McxjtkYnb7AO+rFmlxaPAkzed2Drba4KdGI0FBOFMaLTWpxZbRjXN0NCou3BXMI+60uR PKo7CdzwnMTo1WXwtM82ak+pMzYTTnL5chGciLPTbzGtxL8AaLaabMa1AU4BS/Fq4jYe SA4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nCVTz/TW1C8kDWW89hWnxqM0hLVoG7bmfidmPtnLD50=; b=WN4a+rIoRzs8GLtbsvxn9oJXGDnkXpb2WH8iC4iVmshctDegG/7p8wRsYd1unyjAYl rDjVbJD/zdihy31ZcAsiuZ6Ir6yF1OKWufDpDgmsXohB2LaMxxwzvhoXo7XxEfML2/Ux OzelOW/sNpPCpPrSMPtpOaDdMlPvR77lbDmzqfFt+piMkdTE5lOdRYu5T5QBC8akjP09 5sRPujto/tGsR2cfgR3XGvnIhqcwE8PWANPLmTFDpaNaK/vfBEBfDsJEXg0eVrZSF0OL KCIKEOM0Yt5KdgMWIvS5EILeU9Nc0AJND/PCnZTVOHUi5fmdOFGkT8R64BaOt2th8w4X 6PjA== X-Gm-Message-State: AOAM532DYR6jLJXhPn/2pjs+gmXi1/d0NisPWuQD7eikomfk01+h/Vu3 Yeq5HPyByHonrZODGZ1+2dfayhJOre29AA== X-Google-Smtp-Source: ABdhPJz2kM9OG9o0jmvaS+BzXUTQcpngBKNaoIG2RfbaTjGsVy3WXY4bHWEIewCHLVYcD30xRVDWYA== X-Received: by 2002:a17:90a:1d06:: with SMTP id c6mr19291143pjd.194.1594621127375; Sun, 12 Jul 2020 23:18:47 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:46 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v4 5/8] Bluetooth: Let controller creates RPA during le create conn Date: Mon, 13 Jul 2020 11:52:10 +0530 Message-Id: <20200713062213.3692-6-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 07B5952762 X-Rspamd-UID: 647aa3 When address resolution is enabled and set_privacy is enabled let's use own address type as 0x03 Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_request.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 2dc00604412c..e16d5154b2cf 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2201,7 +2201,13 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, if (use_rpa) { int to; - *own_addr_type = ADDR_LE_DEV_RANDOM; + /* If Controller supports LL Privacy use own address type is + * 0x03 + */ + if (use_ll_privacy(hdev)) + *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED; + else + *own_addr_type = ADDR_LE_DEV_RANDOM; if (!hci_dev_test_and_clear_flag(hdev, HCI_RPA_EXPIRED) && !bacmp(&hdev->random_addr, &hdev->rpa)) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +Ct/Eeb8C1/ZwgAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:19:18 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2K76D+b8C18x8AEADc0bRg (envelope-from ); Mon, 13 Jul 2020 08:19:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 70B6752DF5; Mon, 13 Jul 2020 08:19:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729143AbgGMGSv (ORCPT + 1 other); Mon, 13 Jul 2020 02:18:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSu (ORCPT ); Mon, 13 Jul 2020 02:18:50 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D679EC061794 for ; Sun, 12 Jul 2020 23:18:50 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id t15so5723971pjq.5 for ; Sun, 12 Jul 2020 23:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gqesOFNLs3tg0XsWgFXS5D1nTeu/tqmZApdWPI1nKEU=; b=lCwdJeFOT+uC+zUVyZkAeAZ2Zo65yBgVERNGPrmBib9Fu1ugNCOmzpv4uKQ9kPz9BH 9EFd2MBuMzCnv3Sm/J8/uVHvyZpOQ8Rhtm1MBXJ0QWjjen/75r2nCHli2jsslABeRBHI 3EiFfr2pSfRhevZjmHd0Jooa5/bHIRU8BKKf8eZcjczrp0qOy9yiogcyw+vy5UAQOsuj sXXcB9/gz1EKwJQa/tHY/1dGnT8r7W9xWdDc0TQqDZH92V8CekJW2HFqsy7L6qL6SXFs 9WpZq0H2/K1BO80nkBYUKJ3IVHT6BJtdo5NM5wl/RO/3RUmRm3LaMsaDi+LzNjWd1E6R fMHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gqesOFNLs3tg0XsWgFXS5D1nTeu/tqmZApdWPI1nKEU=; b=Wy7HPEW4Qb3oIvQ8rg6jIJaEokRFlEbSWw6hVT/fK8c6uM5gTbsb43yOIkYQRSFREq 8agQdxoDVhcRXZ9q4BuzsxwN6JIvP+Zo9gD6NxRIWSS3tB0zhVvJGzQWO0mexlCl67XU osuctGWqi94MLuTuSKCtWKFNByP2Pw4Tab08305Uf5OlV65X7Wv/oaSFiF5Azs/ESZ8T VQ487nnEIGOmysM9dAap9clwBGkGjt1K4D3296hedFU/lrMmaA/i4T6hXh2zzCz2+QJg n8K0Y4XpvZCFwEoe5EgK97qyzp0xbdPEMJfQPvBcM4EgxJwexuw+DrmqVZABpxzh/gkP Sm0Q== X-Gm-Message-State: AOAM531AVDaxSgApRRQiaPyTzbMwe1OtY0lTX4AIyYXEg8Ys0vZw5Qjj hGRS6KiaTqNHWspJ33hg9Pjl6wYQ3zj7IQ== X-Google-Smtp-Source: ABdhPJyapFmIKfe7aiayLpP33iR52qoGqLpIPyu3zAlAIwW6aB1PpWbC8QTH2Yhs1iMgnt4S1yf8Bw== X-Received: by 2002:a17:90b:1650:: with SMTP id il16mr17833277pjb.79.1594621130040; Sun, 12 Jul 2020 23:18:50 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:49 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v4 6/8] Bluetooth: Enable/Disable address resolution during le create conn Date: Mon, 13 Jul 2020 11:52:11 +0530 Message-Id: <20200713062213.3692-7-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 70B6752DF5 X-Rspamd-UID: 7d205a In this patch if le_create_conn process is started restrict to disable address resolution and same is disabled during le_enh_connection_complete Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_conn.c | 7 +++++- net/bluetooth/hci_event.c | 4 ++++ net/bluetooth/hci_request.c | 45 ++++++++++++++++++++++++++++--------- net/bluetooth/hci_request.h | 3 ++- net/bluetooth/mgmt.c | 2 +- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 8805d68e65f2..caf1598758bf 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1003,6 +1003,11 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, struct hci_request req; int err; + /* This ensures that during disable le_scan address resolution + * will not be disabled if it is followed by le_create_conn + */ + bool rpa_le_conn = true; + /* Let's make sure that le is enabled.*/ if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { if (lmp_le_capable(hdev)) @@ -1103,7 +1108,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, * state. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, rpa_le_conn); hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED); } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index eae5bd4a53ac..684c68cb5c76 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5221,6 +5221,10 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->interval), le16_to_cpu(ev->latency), le16_to_cpu(ev->supervision_timeout)); + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + hci_req_disable_address_resolution(hdev); } static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index e16d5154b2cf..c3193f7f9ff0 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -428,7 +428,7 @@ static void __hci_update_background_scan(struct hci_request *req) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) return; - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); BT_DBG("%s stopping background scanning", hdev->name); } else { @@ -447,7 +447,7 @@ static void __hci_update_background_scan(struct hci_request *req) * don't miss any advertising (due to duplicates filter). */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); hci_req_add_le_passive_scan(req); @@ -652,7 +652,7 @@ void __hci_req_update_eir(struct hci_request *req) hci_req_add(req, HCI_OP_WRITE_EIR, sizeof(cp), &cp); } -void hci_req_add_le_scan_disable(struct hci_request *req) +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) { struct hci_dev *hdev = req->hdev; @@ -676,8 +676,9 @@ void hci_req_add_le_scan_disable(struct hci_request *req) hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + /* Disable address resolution */ if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { __u8 enable = 0x00; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } @@ -1072,7 +1073,7 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) { /* Before changing params disable scan if enabled */ if (hci_dev_test_flag(req->hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ hci_req_add_le_passive_scan(req); @@ -1140,7 +1141,7 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) /* Disable LE passive scan if enabled */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); @@ -1701,6 +1702,28 @@ int hci_req_update_adv_data(struct hci_dev *hdev, u8 instance) return hci_req_run(&req, NULL); } +static void enable_addr_resolution_complete(struct hci_dev *hdev, u8 status, + u16 opcode) +{ + BT_DBG("%s status %u", hdev->name, status); +} + +void hci_req_disable_address_resolution(struct hci_dev *hdev) +{ + struct hci_request req; + __u8 enable = 0x00; + + if (!use_ll_privacy(hdev) && + !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + return; + + hci_req_init(&req, hdev); + + hci_req_add(&req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + + hci_req_run(&req, enable_addr_resolution_complete); +} + static void adv_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode) { BT_DBG("%s status %u", hdev->name, status); @@ -2626,7 +2649,7 @@ static void bg_scan_update(struct work_struct *work) static int le_scan_disable(struct hci_request *req, unsigned long opt) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); return 0; } @@ -2729,7 +2752,7 @@ static int le_scan_restart(struct hci_request *req, unsigned long opt) return 0; } - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); if (use_ext_scan(hdev)) { struct hci_cp_le_set_ext_scan_enable ext_enable_cp; @@ -2820,7 +2843,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) * discovery scanning parameters. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable @@ -2935,14 +2958,14 @@ bool hci_req_stop_discovery(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { cancel_delayed_work(&hdev->le_scan_disable); - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); } ret = true; } else { /* Passive scanning */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); ret = true; } } diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index 0e81614d235e..12bea10e7d70 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -65,11 +65,12 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable); void __hci_req_update_name(struct hci_request *req); void __hci_req_update_eir(struct hci_request *req); -void hci_req_add_le_scan_disable(struct hci_request *req); +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn); void hci_req_add_le_passive_scan(struct hci_request *req); void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next); +void hci_req_disable_address_resolution(struct hci_dev *hdev); void hci_req_reenable_advertising(struct hci_dev *hdev); void __hci_req_enable_advertising(struct hci_request *req); void __hci_req_disable_advertising(struct hci_request *req); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 686ef4792831..c292d5de4dc3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -5226,7 +5226,7 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev, hci_req_init(&req, hdev); - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); hci_req_add_le_passive_scan(&req); hci_req_run(&req, NULL); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sGW9Nuv8C19eugAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:19:23 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wEPwM+v8C19PLAAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 08:19:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ADB47529D4; Mon, 13 Jul 2020 08:19:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729144AbgGMGSx (ORCPT + 1 other); Mon, 13 Jul 2020 02:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729119AbgGMGSx (ORCPT ); Mon, 13 Jul 2020 02:18:53 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ECF4C061794 for ; Sun, 12 Jul 2020 23:18:53 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id ch3so5707935pjb.5 for ; Sun, 12 Jul 2020 23:18:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PK9IFrqGA8tYf+eWNXSfj5UIMsffCcBtO2fOhU2TTN4=; b=NhQbI2ei67hufJgVSdS8zpkQQXKWe+xpErfVRbSXURKMOQ7eHBVc331c3BD0Dyp3yH bLzc/KC7PRop3VlBwJRmqGP549GoPyLTdxJKepJx1qXGXT86+8oTbGYcUGzVESe09sOL 49ZH58GotMOGsiEUGuZWzNgP5TEsF+DWuEbqCtn+gxhOiIkVJyZm7erULcWSy+OpLTEa X9ijT7M47YPO+meb/naSGX6yCaJtQXKSamXZ5wv+BODYs4nV8M9XFLuZRGPjem1fPLTP Pjwk/aGQ4IqJk3LmDfXbND8CaI0k51mAncGYtex+9PTXX7247sv/FrW5qL7rEcIKAg4c enBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PK9IFrqGA8tYf+eWNXSfj5UIMsffCcBtO2fOhU2TTN4=; b=oQiJrIYJaM81WWNFeCr3oOf57cMZl2/Qa7ks3xTuTQ3w6o73olnH3ysr2dV7mCaqV6 LENQUQVQEL8XiP+EP0N/uCPJwKjtbKciMsCbLVLr/bjvtM9XF1i+lJSzZ+oLN9YHC0+d tNjdSHvyaRDJtM+GRYl3wX0q8gu0PkIe+jOyslgMpm4qWk2bV6U2dwlstHfRvL3C0FNu i/14eSm80nRcnrsLqxTFv6HtjPFSF+ro3pH0hBDnE0icvpB4kvj8y4X8YpozGwM1aegg l9VVKXw+KbKwMVZGI0MTQfxxOs43jCecVDdL+8SKuGLWy8oOnqzJTzCal2JkBSthv8zO IdmA== X-Gm-Message-State: AOAM533ARJ+7Oa0SwKlMo9GBSUf6rkaHuBTwNlq3B3qxmLdrj4s+v34U L53LGagyI9yHApLIzCasqi5uWFO64KMZDA== X-Google-Smtp-Source: ABdhPJxfWUUJkvx7LaKkaub5iMWPPZChuj/DK9iVV92p4uvA7jUKRB8GAizrlWzKrg9qNpSBZt+mxA== X-Received: by 2002:a17:90a:71c4:: with SMTP id m4mr19130787pjs.178.1594621132889; Sun, 12 Jul 2020 23:18:52 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:52 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v4 7/8] Bluetooth: Enable RPA Timeout Date: Mon, 13 Jul 2020 11:52:12 +0530 Message-Id: <20200713062213.3692-8-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: ADB47529D4 X-Rspamd-UID: 7b1550 Enable RPA timeout during bluetooth initialization. The RPA timeout value is used from hdev, which initialized from debug_fs Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 2 ++ net/bluetooth/hci_core.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index abab8b5981a7..4ff2fc4498f3 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1637,6 +1637,8 @@ struct hci_rp_le_read_resolv_list_size { #define HCI_OP_LE_SET_ADDR_RESOLV_ENABLE 0x202d +#define HCI_OP_LE_SET_RPA_TIMEOUT 0x202e + #define HCI_OP_LE_READ_MAX_DATA_LEN 0x202f struct hci_rp_le_read_max_data_len { __u8 status; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 4af208b82138..2030536cc5d8 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -762,6 +762,14 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt) hci_req_add(req, HCI_OP_LE_CLEAR_RESOLV_LIST, 0, NULL); } + if (hdev->commands[35] & 0x40) { + __le16 rpa_timeout = cpu_to_le16(hdev->rpa_timeout); + + /* Set RPA timeout */ + hci_req_add(req, HCI_OP_LE_SET_RPA_TIMEOUT, 2, + &rpa_timeout); + } + if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) { /* Read LE Maximum Data Length */ hci_req_add(req, HCI_OP_LE_READ_MAX_DATA_LEN, 0, NULL); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iEvGFfH8C19eugAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:19:29 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kEAgFPH8C195OQAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 08:19:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 052EA52CA6; Mon, 13 Jul 2020 08:19:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729211AbgGMGS4 (ORCPT + 1 other); Mon, 13 Jul 2020 02:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729119AbgGMGS4 (ORCPT ); Mon, 13 Jul 2020 02:18:56 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7051DC061794 for ; Sun, 12 Jul 2020 23:18:56 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id m16so3867084pls.5 for ; Sun, 12 Jul 2020 23:18:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f1oHIKp+Xl1MtDR3jCF7Dp+Qm8VEDoGCEovuZWBlKwk=; b=kIhed68WGVNC99IJGz/zYURc14jeots+sVpKjP9Wzfb3Hjrkj/d0txeaOuiD7a7sEM 8zutwg/JuQuYiL/ExxO5zghiFonoiy9FxdeLtKUi46/slPx2WZGDd83daqAr8a3SALH2 SKpJczv9d1UFjaQ3/4hpi3uT0MnBsz8f7ub1nOmYwT2bul1NVk9xloV0xVsZX0sXZfWx /YLrL7faNLjG49VV2I9QkNB5aGy6J5NZ9mTqj5eMQUFfwBO+onZEtFUX2+Mrp5+dnqZ1 pKcygtPni9R1mXHz6v71de48owQWRogvrRJerEIpLY/4T7WQt5f5iGBSveuVFnqdCyWV 66hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f1oHIKp+Xl1MtDR3jCF7Dp+Qm8VEDoGCEovuZWBlKwk=; b=DLyqPgO5KlUFGfj9Lc8+tDNwWIn+PrhmtsZAvETlHVgPKTh9+BepXDTUBzfXb1YEHp gw3ZK1wTl4gxz7oc/OFASgr3SC6BsqbOOdb2bXRN3MN+6pLcmLBTc7GWc8cdm8DC8acT aRmVhALNb2fL+N7Odmob4HZw8QI28uC4uwM1sJ9xGvpf5gEYnAjgjb3pUFW54Ehu3fqE +UX0/s8a5pQ40Odj4tSR+og85ld35VmZOSbOUFtyPUnT937lOEhq77g7iU+XnOEzCbZ6 oPggdcoq9/BnHPu65MMimzOwARN10xwE666ADLmsWXleZuoJQfEGMyFuvhyzZkg5ED6C RfSg== X-Gm-Message-State: AOAM531ozeW2DREafnv12nuotlOlD8uXVsOflc9sU9+aApE9Eb6s3Ojb TXXwfA84zKBHLG4CmK/yX2tWeEhRJ7TuYA== X-Google-Smtp-Source: ABdhPJwEOJ7OadWiiCZv5/lLsdk4wDT/US4qI/Jr7EnWPHLjrPEYmgM/ezRfSh6YVl9UWGHpdG0Kkg== X-Received: by 2002:a17:90a:db8a:: with SMTP id h10mr18903824pjv.58.1594621135806; Sun, 12 Jul 2020 23:18:55 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:55 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v4 8/8] Bluetooth: Enable controller RPA resolution using Experimental feature Date: Mon, 13 Jul 2020 11:52:13 +0530 Message-Id: <20200713062213.3692-9-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 052EA52CA6 X-Rspamd-UID: 019d19 This patch adds support to enable the use of RPA Address resolution using expermental feature mgmt command. Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_event.c | 3 ++- net/bluetooth/hci_request.c | 6 +++-- net/bluetooth/mgmt.c | 52 +++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 4ff2fc4498f3..cb284365b4c1 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -307,6 +307,7 @@ enum { HCI_FORCE_BREDR_SMP, HCI_FORCE_STATIC_ADDR, HCI_LL_RPA_RESOLUTION, + HCI_ENABLE_RPA_RESOLUTION, HCI_CMD_PENDING, HCI_FORCE_NO_MITM, diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 684c68cb5c76..c8a5e1e4dba2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5222,7 +5222,8 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->latency), le16_to_cpu(ev->supervision_timeout)); - if (use_ll_privacy(hdev) && + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && + use_ll_privacy(hdev) && hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) hci_req_disable_address_resolution(hdev); } diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index c3193f7f9ff0..cb44b83539e6 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -677,7 +677,8 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) } /* Disable address resolution */ - if (use_ll_privacy(hdev) && + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && + use_ll_privacy(hdev) && hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { __u8 enable = 0x00; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); @@ -870,7 +871,8 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } - if (use_ll_privacy(hdev) && addr_resolv) { + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && + use_ll_privacy(hdev) && addr_resolv) { u8 enable = 0x01; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c292d5de4dc3..fbe02ab5fa05 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3759,6 +3759,12 @@ static const u8 simult_central_periph_uuid[16] = { 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, }; +/* 15c0a148-c273-11ea-b3de-0242ac130004 */ +static const u8 rpa_resolution_uuid[16] = { + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, +}; + static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { @@ -3795,6 +3801,17 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, idx++; } + if (hdev) { + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION)) + flags = BIT(0); + else + flags = 0; + + memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); + rp->features[idx].flags = cpu_to_le32(flags); + idx++; + } + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable @@ -3895,6 +3912,41 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, } #endif + if (!memcmp(cp->uuid, rpa_resolution_uuid, 16)) { + bool val; + int err; + + /* Parameters are limited to a single octet */ + if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + /* Only boolean on/off is supported */ + if (cp->param[0] != 0x00 && cp->param[0] != 0x01) + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + val = !!cp->param[0]; + + if (val) + hci_dev_set_flag(hdev, HCI_ENABLE_RPA_RESOLUTION); + else + hci_dev_clear_flag(hdev, HCI_ENABLE_RPA_RESOLUTION); + + memcpy(rp.uuid, rpa_resolution_uuid, 16); + rp.flags = cpu_to_le32(val ? BIT(0) : 0); + + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); + + err = mgmt_cmd_complete(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, 0, + &rp, sizeof(rp)); + + return err; + } + return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, MGMT_OP_SET_EXP_FEATURE, MGMT_STATUS_NOT_SUPPORTED); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WPEiJVz9C1/ZwgAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:21:16 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id CLC/I1z9C1/d+gEADc0bRg (envelope-from ); Mon, 13 Jul 2020 08:21:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 519A0A2C65; Mon, 13 Jul 2020 08:21:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728541AbgGMGVK (ORCPT + 1 other); Mon, 13 Jul 2020 02:21:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728463AbgGMGVK (ORCPT ); Mon, 13 Jul 2020 02:21:10 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53C11C061794 for ; Sun, 12 Jul 2020 23:21:10 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id i18so10199584ilk.10 for ; Sun, 12 Jul 2020 23:21:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h4CintOxCJTb1rZhZ+UdVT8MIuTrjLv1VUQEptjjqko=; b=K3F9LSHwPzlZ9x9z0kFRnWC0uAp006SVtLvwdNYlndkuhxrL9+S7E7K1UxuMpxIHaQ X8ez5yqWm2swVms3Ouf2X6HffxNS3LE+q1Il3rGd4qltLZbLmHUj5wOkJD88RVvU4V3D HH5osWpCOiEfE1WToL7ezBubrdQCkTZPnK/QnGPP1DcuCFi1TlWrTQ/f0NswEvWAcF2W /QvnbHRwCRz4FatGSJk6nB0f3sJl7wyrf+pW4/j0V1/qz/t8+XY+VNf0Fp13F3k/C9eR PlbIseQekz48JOLLLcHYR/mtowmBpIxuRzgtmCVWSfpXF311hURcMU8J7rYYVMum/bm/ IoUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h4CintOxCJTb1rZhZ+UdVT8MIuTrjLv1VUQEptjjqko=; b=hpQWt4dvbRC2WrYgNJxWpicI+tXbxqoGsjrnYSUsM7xKMdcGSVhQJB9eY62NfcLNEf TWSMm6YtURD/kpwXUhDlwVsldb1oAcr/jld1PmNmAWz4l02PRcBDBpzFUViF2BgKMUzd qUmxXvFSZPilwyGPTsk4qa/s6t6MKJ+k+5EwXTnykGsflaFOU7TmXK5DPIcd98LOhCwL Kzui/rlB5Axt67yqirIxR2D0OzxDyoc17vQsIV/cesavNBI5cDaZGn3DWFv/DeXX3Xvv IUeuQMXdVy7MzVHQTHKf9iULgAKAgQQ3MXgkAEUeDKKZfGhFFnrVUd8nJsB5CsG5jfLv U7HA== X-Gm-Message-State: AOAM530+nWxelqD3+H7sW7EH1ajPyadZH1/3pqmQL9JDr1ReYfEKmE+S lV1k3uqLvw43vAnNC3x2TCuunEKvev8NE4sXL9Q= X-Google-Smtp-Source: ABdhPJxvfKx+pQ0cdNgeKbHvP48JPiumYI+f0z5MDjSmNqS9Pb2Tqx0idn1T6BFRfgbVZuiDTe+GK0yKJa4SMqygPoo= X-Received: by 2002:a92:aa92:: with SMTP id p18mr63077577ill.199.1594621269557; Sun, 12 Jul 2020 23:21:09 -0700 (PDT) MIME-Version: 1.0 References: <20200701100432.28038-1-sathish.narasimman@intel.com> <20200701100432.28038-9-sathish.narasimman@intel.com> <10FB84C9-79E7-48F9-88A5-B10FB67CB585@holtmann.org> In-Reply-To: <10FB84C9-79E7-48F9-88A5-B10FB67CB585@holtmann.org> From: Sathish Narasimman Date: Mon, 13 Jul 2020 11:50:58 +0530 Message-ID: Subject: Re: [PATCH v3 8/8] Bluetooth: Add support to enable LL PRIVACY using set_privacy To: Marcel Holtmann Cc: linux-bluetooth , Sathish Narasimman Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: 519A0A2C65 X-Rspamd-UID: 66de1f Hi Marcel On Thu, Jul 2, 2020 at 6:51 PM Marcel Holtmann wrote: > > Hi Sathish, > > > Enable LL Privacy using mgmt set_privacy command. The privacy > > value 0x03 is used here to enable LL Privacy. > > Still to use LL Privacy controller support is must. > > that is not what I meant. And it is also misleading since Set Privacy is enabling RPA usage and not RPA resolution. So what I meant was using the Set Experimental Features mgmt command to enable usage of RPA resolution in the controller. Updated v4 of the patches Please review them > > Regards > > Marcel > Regards Sathish N Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QAVVOAL/C1/ZwgAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 08:28:18 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iFCRNgL/C1/MDAAAlScrYA (envelope-from ); Mon, 13 Jul 2020 08:28:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3DF81A179F; Mon, 13 Jul 2020 08:28:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728949AbgGMG2G convert rfc822-to-8bit (ORCPT + 1 other); Mon, 13 Jul 2020 02:28:06 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:38951 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMG2F (ORCPT ); Mon, 13 Jul 2020 02:28:05 -0400 Received: from [192.168.1.91] (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id CFBE6CECA3; Mon, 13 Jul 2020 08:38:01 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 1/3] Bluetooth: Add new quirk for broken local ext features max_page From: Marcel Holtmann In-Reply-To: Date: Mon, 13 Jul 2020 08:27:33 +0200 Cc: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree , arm-linux , kernel list , linux-bluetooth , "open list:NETWORKING [GENERAL]" , Ondrej Jirman Content-Transfer-Encoding: 8BIT Message-Id: <70578F86-20D3-41C7-A968-83B0605D3526@holtmann.org> References: <20200705195110.405139-1-anarsoul@gmail.com> <20200705195110.405139-2-anarsoul@gmail.com> To: Vasily Khoruzhick X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 24 X-Rspamd-Score: 3.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3DF81A179F X-Rspamd-UID: a08773 Hi Vasily, >>> Some adapters (e.g. RTL8723CS) advertise that they have more than >>> 2 pages for local ext features, but they don't support any features >>> declared in these pages. RTL8723CS reports max_page = 2 and declares >>> support for sync train and secure connection, but it responds with >>> either garbage or with error in status on corresponding commands. >> >> please send the btmon for this so I can see what the controller is responding. > > Here is relevant part: > > < HCI Command: Read Local Extend.. (0x04|0x0004) plen 1 #228 [hci0] 6.889869 > Page: 2 >> HCI Event: Command Complete (0x0e) plen 14 #229 [hci0] 6.890487 > Read Local Extended Features (0x04|0x0004) ncmd 2 > Status: Success (0x00) > Page: 2/2 > Features: 0x5f 0x03 0x00 0x00 0x00 0x00 0x00 0x00 > Connectionless Slave Broadcast - Master > Connectionless Slave Broadcast - Slave > Synchronization Train > Synchronization Scan > Inquiry Response Notification Event > Coarse Clock Adjustment > Secure Connections (Controller Support) > Ping > < HCI Command: Delete Stored Lin.. (0x03|0x0012) plen 7 #230 [hci0] 6.890559 > Address: 00:00:00:00:00:00 (OUI 00-00-00) > Delete all: 0x01 >> HCI Event: Command Complete (0x0e) plen 6 #231 [hci0] 6.891170 > Delete Stored Link Key (0x03|0x0012) ncmd 2 > Status: Success (0x00) > Num keys: 0 > < HCI Command: Read Synchronizat.. (0x03|0x0077) plen 0 #232 [hci0] 6.891199 >> HCI Event: Command Complete (0x0e) plen 9 #233 [hci0] 6.891788 > Read Synchronization Train Parameters (0x03|0x0077) ncmd 2 > invalid packet size > 01 ac bd 11 80 80 ...... > = Close Index: 00:E0:4C:23:99:87 [hci0] 6.891832 > > hci0 registration stops here and bluetoothctl doesn't even see the controller. maybe just the read sync train params command is broken? Can you change the init code and not send it and see if the rest of the init phase proceeds. I would rather have the secure connections actually tested before dismissing it altogether. Mind you, there were broken Broadcom implementation of connectionless slave broadcast as well. Maybe this is similar. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6LXaMUIRDF8ibAEAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 09:46:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id sKuCMEIRDF8W3gAAgupzMw (envelope-from ); Mon, 13 Jul 2020 09:46:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3BD34A2429; Mon, 13 Jul 2020 09:46:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbgGMHpu (ORCPT + 1 other); Mon, 13 Jul 2020 03:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbgGMHps (ORCPT ); Mon, 13 Jul 2020 03:45:48 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73964C061794 for ; Mon, 13 Jul 2020 00:45:48 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id 1so5637849pfn.9 for ; Mon, 13 Jul 2020 00:45:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+xSpopuz70JG6iQfzM5HgibXAJUo1c/P7qmmEsvws9s=; b=Kc5iLI/iQywUAZzcS/x0aAofjXobkcKggku2JP87VotyNaCUPk2Py7OWxK8E9eVaxa CahAMnsRsqRjstEh9jYRglZqFJ7nQJNIVORRbfGSzjOG/UdG8t6tQqFc39Acu563iNdX 74kCvC+jQYgz/0vCK77oVtwe7UbVamVpsCR9Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+xSpopuz70JG6iQfzM5HgibXAJUo1c/P7qmmEsvws9s=; b=tCfpOzvkXhRJeAztnorglS5UQ2f1DYY4XMqXlce5hfRUVKXtjAqThuF0LxgFl2Qjuc 5Xjr/eIB5vDy+RlCsAVIt4v2y99Owl6qzAeCS4g8VsByUp8VYLNlnvu3DmQLwERtjFNy m/5p1AfQCyZFQ36ndAC3M2R06fr1Q6jedrrUHnRJRcHm5WZhmQTedueXuWYVc+h9+dqA 730o6Ha8bLmqZ+AsADvI1ONeqIYg7RqRuZDBRwNQn5C+xGvElDfOBzYjno6d8p5WtvHx 6mAWdV3rZ+I3bawmRjwDXDoOu0bFmY6GnatO4E/0NS5WzHkntmVPpV+j3wdJCDPbouuC FuNg== X-Gm-Message-State: AOAM532lKvpps67rk7f97t07WRcOYCCuOMw96ZN1ze0kYC+gcwFBoBSV Z5Vo1gx1xXi9nUIDaab0QKllUDtyVXBTCw== X-Google-Smtp-Source: ABdhPJzW69Vm+lK8/pCwW1u4QfMsHRO3SS16AexP6hozF17c7XNzQfwn82/Bxo+zSG+hxNagRn79rQ== X-Received: by 2002:a65:4bc8:: with SMTP id p8mr67352267pgr.418.1594626347737; Mon, 13 Jul 2020 00:45:47 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id g8sm12691498pgr.70.2020.07.13.00.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 00:45:46 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Joseph Hwang , alainm@chromium.org, Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH v2] Bluetooth: btusb: add Realtek 8822CE to usb_device_id table Date: Mon, 13 Jul 2020 15:45:29 +0800 Message-Id: <20200713154512.v2.1.I63705bf6abab9cb79c14f7959a59b201af2b8827@changeid> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.48 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3BD34A2429 X-Rspamd-UID: 4a3d62 This patch adds the Realtek 8822CE controller to the usb_device_id table to support the wideband speech capability. Reviewed-by: alainm@chromium.org Signed-off-by: Joseph Hwang --- Changes in v2: - Fixed the commit subject and message body. drivers/bluetooth/btusb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index faa863dd5d0a33..aa0bc9942afda9 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -359,6 +359,10 @@ static const struct usb_device_id blacklist_table[] = { { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01), .driver_info = BTUSB_IGNORE }, + /* Realtek 8822CE Bluetooth devices */ + { USB_DEVICE(0x0bda, 0xb00c), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, + /* Realtek Bluetooth devices */ { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01), .driver_info = BTUSB_REALTEK }, -- 2.27.0.383.g050319c2ae-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6LLYJ4EVDF/idgEAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 10:04:17 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id kEIHJoEVDF/kKgAAlScrYA (envelope-from ); Mon, 13 Jul 2020 10:04:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4CB4CA245F; Mon, 13 Jul 2020 10:04:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729662AbgGMIBz (ORCPT + 1 other); Mon, 13 Jul 2020 04:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729666AbgGMIBx (ORCPT ); Mon, 13 Jul 2020 04:01:53 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B301FC061755 for ; Mon, 13 Jul 2020 01:01:53 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id i3so9249778qtq.13 for ; Mon, 13 Jul 2020 01:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=EOALdvxiHqoaACfMtoifiqT35+z4bvJD1lbhLzO6lrk=; b=l3xy2owNKhdwuAQEGTjDc2IcKFjpt1PyHYnAb/ymiOucZj3241kOVkgdzsn6WZq6DN +dOfLXE8iHpPUJOAu2L8ckAEC/G2+ycz+IuHcvdOGCdatl6xbMllpa3lbZ7TkfO7+Hsi t3X945lVQt9CGdsHnllPFzKizYfuxGORPynlupx5Ys+lVY0VVy36thcU0EAwTi3oisIC 3CDtIIMyVVWfJ3mz7lTEDRngVCwCFme/x3eOqyw5eG63ENpcfX1lzGKIHamTVrfcVAAL PIFD4/Tb3xM6wnhzQMnrf6LaDFj5hrevgf+RBfkAb8Rw36oaQiVAUO0JuDFZKBnbgKL+ pY5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:autocrypt:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=EOALdvxiHqoaACfMtoifiqT35+z4bvJD1lbhLzO6lrk=; b=f5IG0OEjG1W1acVQx899MLHXN2G0MrLU7F94dGVCCv8mTDnAjVnj2OioQicj4/uX9M 4Tg6H7EO6wL5CelcFsL5ikCy0ohBSYXqSXXPTsJLJOcDq/zykQ+aqfQ3Xoejki4i+gif H6LZP3bw49whBSujR1Fo9XsM0hgfJYeobBUrdwbQ1uZk+FVEspgMCFzpw3c82VTPBRig zbynz5FsBtsUGr6ldBpfvfPfORTdF+KveMlE1hSfrgvI7musVqmFRa82fvC8Wp61n9O5 Zn6ACzum8wyQi2ys8gIJDO5Ii6OujeBvAxVBGXjcQ/t5/l+hzAf0lI1ughwlkNavNIZ4 2/DA== X-Gm-Message-State: AOAM531Z9gj+o4CktFoxPQqlX3KrkN/eVIxd4fGMg7QHzk+mhMUX/Ei0 3UMfGpaIuFA5n14xOZ3+82KNBLS6 X-Google-Smtp-Source: ABdhPJxpSTpmzoC5F6sTNrOU/l318RqhIe8AUGSQaTKZfmsuZt7a7xFNTJQYUQN70vFnbFevCgD9IQ== X-Received: by 2002:aed:2a36:: with SMTP id c51mr56496335qtd.264.1594627312638; Mon, 13 Jul 2020 01:01:52 -0700 (PDT) Received: from meimei.greshko.com (2001-b030-112f-0000-0000-0000-0000-140e.hinet-ip6.hinet.net. [2001:b030:112f::140e]) by smtp.gmail.com with ESMTPSA id x34sm17342960qtd.44.2020.07.13.01.01.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jul 2020 01:01:52 -0700 (PDT) From: Ed Greshko X-Google-Original-From: Ed Greshko Subject: Re: Unsupported Adapter? To: linux-bluetooth References: <5c552dc0-1ef8-ae35-b51a-b6889853d535@gmail.com> Autocrypt: addr=Ed.Greshko@gmail.com; prefer-encrypt=mutual; keydata= mQINBFib3RQBEADHZwYcxrZlzTh/QVzUYbWH2SfcJvVAIvonOunb0JudiPaBcW14+3WkQa3i xnT7VYcN8AzLL0q5Omsy8t/TsAMmZxLffZCBL+jY8uxgkIR5yZkqCH0zhKSiTz7LTdFXf370 +Q1LLnvEaZHpM9kwfCVi0uV+WpCfEY+HsaYjMIJnHk1xQVG18Fo3uzZY/dh2bMvo0JcFRugU 6nn3Te5mcVt42sU/+l63dqubq0/8yRC9Nnp1+iE2qjkz+JUROWidPrIKWyBgapTRCctSJTA5 9FCwMNAftde1HVL1sibY+n8xV4RmFGRwLllsFE8KLhi85p3FMRAOtbsjdsTeiuFJo5ROdoQN mS3KHrOXCD4Fxs6+NbGhocsYNxfWW2deZrE+C7YULDkf1rhsUQaEScxHA5WDKA8BqiDewK8b DXmYYEFXmqP3SrujuedTOLls62I0myfsPpY6bMJzsQB1CvaM9DhXjN1DMxdcJHXk68ioX5Kh gxj6F41xitMfXBxh6AC8KzrPlVPzKesskHD7+M3E5P0+Dr9/8ijeMWa5aU/cZ9GvefryDIBO Ckh4BZz/ISeXcRVgaVrQvhgmr8W23IZggLvqduo0BqCK56EPPqW8KuZzN/64g/HMvjrCP1Na 0Uc29bfp1ySXiUaPTIz60guqAohm2z6SbIxPJC/TfnqDM+3dPwARAQABtCFFZCBHcmVzaGtv IDxFZC5HcmVzaGtvQGdtYWlsLmNvbT6JAjcEEwEIACEFAlib3RQCGyMFCwkIBwIGFQgJCgsC BBYCAwECHgECF4AACgkQMNGK02s7QIHTdA//TACw2PqlRT53HcoDNZt1afVyCgH8jo9CBtOF rhqxni2wsp8wke9a+qghRPXO57s1Te6NEPo33EF/ORrDauOchQDffhIqlKBZsn0nub1Hj/OB ERXtIxtr0jU83sTeeHg6GFu+mnQ8l2nwgZOM65rTfP1voMOKSQToFONqhzj0FwZLuMJoxSMP lOJHIg5QO4uWBmLBIYoEqxDdsc4RYhC79apGnzbQW1fvSpNGMzYfzqeJnTZso+km7VgXCRgP UOb0RPpRIjvobniwOxevXs6wXiQtT62EXlnHr6yZISd7i6Ca1rGNaGMLb0pnhuIw6KwqcWJJ aAfiUUnorY9vpQnruwmb1JsU3eGRKv11B+0lwQxWGpJC3/0uKqauOUsmbWmgMnvK8DYvLBKr TDOXsYpXowYE2IgQLHktscyIMMJJoNtLc+HS6DpQ2ajBQqQR0RCZvB16mmgSqz/tN2t72ZVx 6Rd6M23aFzbwGXFyefLhVPMaN4T5OUUjCWzeWzPPxET+nbeBIn65oUTnO8TVay1LWdkEcGUx gy4L2m/jDQp1E7xl2CMDnaXbmuIiuwbXRfRWfT3txKixc14TA1RT9TClQ+p3ltv9wIcZLqWO 0Mqy+DbVtwQCeDJkuF+ofg3MdUwtHOwoXdTkyA/UYtFxnZkKRgaPGBNdQjJmQDxQkm/H27W5 Ag0EWJvdFAEQAJgDOGyuOKSm8o6ouML+j+gh+PH47/CypLpx/RCwdTGjzlPUXa3+nE5O237E tPZkun3LbIrALjLnkXr83jRnZDzKLFuk3+DjPZ59WPLNmrTGlavg9jR10tmaMfP4H/4YhdV1 WbfyB2e0tqA5pN+T5ODuJaaJcbDA98tB3s68xuGz/Tv5OduDCtSkQw0yUJpBPcMGQ0Pz6bOF fg5SetAT8/CgLuSI5CaMz1CYm1PDj+2UCVYazNox9VJjhdWQ74h3c9YQEk5X4rNNd9No5xDO XcRTZh8TOlHtwcEBAD0xbST2lnryydBsLezftpiB66bAA8X2OlnXgsSQ3OiMrwuU8aRu0HQ4 Op83t1fDO6Z8aFfBOVCTkvF/OoCVyDEj3PXHrU1a/yvA3qa04hwQB7hpmBes5alvbcl8QvgA SJJD3YGuz1UuG6CMzLB6ADRMIKcgR0bR7rqSJ7Cguz5RzlOp/80EK6gWTjVrpFlq7nf7mb8Y tN1XF6j+UERBVx7RTvTnu0ZTLPbw4HYHtS/f5LsWtEbuPgVA9JXzYJkGoJDBaSjK1yKP/Dck udg3NtHU6NgY1A4SET7N1uvlb9tV3zRwcd9Q1+3Vi7k0dBDg1JGqz9rTRzESaHJsTTjsna+P yfd+wNbJ7nr6PXNeyvjk0dLGzjxPNdwuvQXwJuW5Wk87RzVNABEBAAGJAh8EGAEIAAkFAlib 3RQCGwwACgkQMNGK02s7QIHNdw/+PByovfcsXIb3JLzz2MQj1Zz5aTOV5A34eYKXIm1jg17/ KLnPABQz9XX5vFbH89DCFLqWyaBncoZCR3bsCIuTLFzulHRFuKgTwOInDHEoJHmxV9SL2v0l FHQK3uCT3rEs45PGoDtNLdsCvlIvaTM1SQ0Irr1dmpL1esUiSepYfLKBp4DVc9P/YJOz6M7a JQVrPbdgMmwuALDw8//kKe28yz+ezIX/33jtzuL4H8woIOO+Q6BCWzLA7akUKvIol/wIvAE2 +l4NwNUGkKu4W1Bgk1L303lepRIe7PqRbfZNbXH1AwhaKLEO3ZIov3AjpUzKClkU8T9eLki9 OCsAbOkziG4UYJPddn7JnMSFamqPTxOliLyi+c0T4ThTtZLYKFsd4iRXdPOKoH1aRUsihXOZ qrTKAcZpgHKcVZ7FCXF6uBCzuLqmhgAYcudPVZ8KT23N3g4m3qb3evbJ3E7gJrH7i57elISk c9Dm6egzpCXuJs22DpkrOjhDlxM902ii4RmXnzYpbbSOwNBBvRAWnTJMIbxl0VgPjD0SzXGb miP4iWQyz5Q590zJT1sN4qUOcKQIpTIhJWkj0PVrcji3yS6xzgxJZXte6btvoKX1qarQh1sm zgCych1oCte93iAESL7peGjSPCQgGk325Rz8QwtMgrAqObTPP0wHw4XR0V5t2Go= Message-ID: <11921c7b-c498-38e8-c7cd-d79900803153@gmail.com> Date: Mon, 13 Jul 2020 16:01:48 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <5c552dc0-1ef8-ae35-b51a-b6889853d535@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 14 X-Rspamd-Score: 2.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4CB4CA245F X-Rspamd-UID: 153ad8 On 2020-07-13 08:58, Ed Greshko wrote: > I'm running the Fedora 32 disto and bluez-5.54-1.fc32 is installed. > > I have 2 bluetooth dongles.  One is recognized and the other isn't. > The one not recognized is shown in lsusb. > > The info is as below.  It there a process to get an adapter supported? If it helps, this is the end of the output from btmon when the device is inserted: < HCI Command: LE Read White List... (0x08|0x000f) plen 0  #57 [hci0] 12.838744 > HCI Event: Command Complete (0x0e) plen 5                #58 [hci0] 12.839681       LE Read White List Size (0x08|0x000f) ncmd 1         Status: Success (0x00)         Size: 6 < HCI Command: LE Clear White List (0x08|0x0010) plen 0    #59 [hci0] 12.839696 > HCI Event: Command Complete (0x0e) plen 4                #60 [hci0] 12.840678       LE Clear White List (0x08|0x0010) ncmd 1         Status: Success (0x00) < HCI Command: Delete Stored Link... (0x03|0x0012) plen 7  #61 [hci0] 12.840705         Address: 00:00:00:00:00:00 (OUI 00-00-00)         Delete all: 0x01 > HCI Event: Command Complete (0x0e) plen 6                #62 [hci0] 12.841706       Delete Stored Link Key (0x03|0x0012) ncmd 1         Status: Unsupported Feature or Parameter Value (0x11)         Num keys: 0 = Close Index: 00:1A:7D:DA:71:11                               [hci0] 12.841731 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4Gg2JhclDF96GQAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 11:10:47 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QF5WJBclDF/hhwAADc0bRg (envelope-from ); Mon, 13 Jul 2020 11:10:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 236E052BD6; Mon, 13 Jul 2020 11:10:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726991AbgGMJJQ (ORCPT + 1 other); Mon, 13 Jul 2020 05:09:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:50778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbgGMJJQ (ORCPT ); Mon, 13 Jul 2020 05:09:16 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B970D2067D; Mon, 13 Jul 2020 09:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594631355; bh=GWJ4TWqaSASCW4yY1XFImxdM8bpoL6n5FOX7VHDE+9w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V/sA9qNTSOJ5u9N1tHD1k/Yj93K/J5SXieiN+EsW2QdPmOIMk7UHQJ70GrxavW76p G7Gb7Cko3v8vJUw0P/41QcsaUKq5gjK/vfzUEqTH/ScfB4svq8VUXR/COtS9xVjA5+ LwIYxYXZPX5IoPjTkm09k6vfoEAiwevEjYzmLJ/o= Received: by pali.im (Postfix) id B1571857; Mon, 13 Jul 2020 11:09:13 +0200 (CEST) Date: Mon, 13 Jul 2020 11:09:13 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Marcel Holtmann Cc: Bluez mailing list , Luiz Augusto von Dentz , David Heidelberg Subject: Re: [PATCH] Install avinfo utility Message-ID: <20200713090913.6duirl4yhrjcyxoh@pali> References: <20200506193435.3746-1-pali@kernel.org> <20200610093306.zt3q3s2wmwp3almw@pali> <7672C0A0-AF6A-41B2-B50F-7836B3E5CC73@holtmann.org> <20200611125304.b4mxxuv7rupamfmg@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200611125304.b4mxxuv7rupamfmg@pali> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 236E052BD6 X-Rspamd-UID: 5e3a37 On Thursday 11 June 2020 14:53:04 Pali Rohár wrote: > On Wednesday 10 June 2020 19:31:47 Marcel Holtmann wrote: > > Hi Pali, > > > > >>> This utility is very useful for determining which A2DP codecs are supported > > >>> by remote side. So install it to system as part of bluez package. > > >>> --- > > >>> Makefile.tools | 4 ++-- > > >>> 1 file changed, 2 insertions(+), 2 deletions(-) > > >>> > > >>> diff --git a/Makefile.tools b/Makefile.tools > > >>> index 9b9236609..d52721612 100644 > > >>> --- a/Makefile.tools > > >>> +++ b/Makefile.tools > > >>> @@ -176,9 +176,9 @@ endif > > >>> if TOOLS > > >>> bin_PROGRAMS += tools/rctest tools/l2test tools/l2ping tools/bccmd \ > > >>> tools/bluemoon tools/hex2hcd tools/mpris-proxy \ > > >>> - tools/btattach > > >>> + tools/btattach tools/avinfo > > >>> > > >>> -noinst_PROGRAMS += tools/bdaddr tools/avinfo tools/avtest \ > > >>> +noinst_PROGRAMS += tools/bdaddr tools/avtest \ > > >>> tools/scotest tools/amptest tools/hwdb \ > > >>> tools/hcieventmask tools/hcisecfilter \ > > >>> tools/btinfo tools/btconfig \ > > >> > > >> I had no intention to install that tool since it is too limited > > > > > > Sorry, but I have not seen any limitations with this tool yet. I'm using > > > it very often. And also other people who use it have not mentioned any > > > limitations or problems. > > > > > > So could you be more specific what are those limitations? > > > > > > Also it is the first thing which I'm saying people that should run and > > > send me output of it if something related to A2DP does not work. > > > > > > And because linux distributions do not package this utility and bluez > > > developers (for me for unknown reasons) decided to not install it, > > > result is that people have to always compile bluez from source to run > > > this utility if their A2DP audio does not work or "remote" debugging of > > > A2DP is needed. > > > > > > So result is that who want to know why A2DP audio does not work is > > > forced to compile & install bluez from sources and not to use from > > > distribution package. And this probably not the expected state. > > > > > > In any case, nobody reported to me any limitation with one exception > > > that it cannot decode capabilities of some custom vendor codecs. But > > > most of them are already supported as I sent needed patches in past. > > > > > >> and makes too many assumption. > > > > > > For example which assumptions? > > > > that nothing else is happening right now. It backstabs the actual AVDTP and A2DP implementation. > > Marcel, but this is not a problem. For that one purpose which avinfo > provides it ideal and works fine. Personally I do not see any problem > with it. > > > >> In addition it has a bad name with no Bluetooth prefix. > > > > > > So, lets rename it. What about "btavinfo"? > > > > Lets extend btinfo with all sort of capabilities. Make the av portion just one of. I want to remove the multitudes of test utilities anyway. We have to many tiny utilities that are just scattered around and avinfo is just one of them. > > This looks like a not-so-trivial task and moreover independent of > providing current version of avinfo to users. > > avinfo already exists, is already part of bluez project, it is already > compiling during bluez build and is already used by me and lot of other > users and works for that one purpose as expected. > > > > > > >> If we think it is useful to have such a test utility, then we need to clean this up first > > > > > > What exactly to clean up first? > > > > > > Note that I have already done cleanup of this utility. > > > > > >> and put this into a larger btinfo work to gather appropriate information from a remote device for debug purposes. > > > > > > I do not see how btinfo can be used for A2DP purposes. Seems this is > > > utility for local controller info and not for remove A2DP. > > > > This needs a bit thinking, but pretty much simple things like this: > > > > btinfo local > > btinfo avdtp > > > > We can create a module handling system so that you can easily links existing tiny utilities into one. > > I'm not against this change. But this is additional work which needs to > be done. And it would not happen today or tomorrow unless you have > already patches which implement it. > > As I said avinfo is already there, implemented, it is working and is > part of bluez source code. And is basically the first step when > debugging issues with A2DP audio. > > So what is the real issue with not only compiling this avinfo tool > during building bluez but also installing it? Because nobody presented any real issue for more then month and I'm not aware of any, could be avinfo finally enabled during installation? Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MO+EMzaFDF9MyQAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 18:00:54 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aOAHMjaFDF/iIQAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 18:00:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 41DB253078; Mon, 13 Jul 2020 18:00:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730355AbgGMQAj (ORCPT + 1 other); Mon, 13 Jul 2020 12:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730258AbgGMQAi (ORCPT ); Mon, 13 Jul 2020 12:00:38 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE214C061755; Mon, 13 Jul 2020 09:00:38 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id b4so12647255qkn.11; Mon, 13 Jul 2020 09:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1ojmtWuhoXE+10Oa37xZFid38Sh0C/r73ASNaf7SWHQ=; b=BcFsCnGYuhwgC0vVkdD/AnoRcC7YBT5Yjs0ZBhG9O2O/o2aF4ReqQps/ZfiOOvBgqA 7TdbWPHptfqtgF9lXpYr4UxcFudH5gBaIH/lvw9V3sn3BS+xUBL02sVcjXSB2YuZKw4L Qg3Brl1eV+oFR0a/Suuw6b7G80waQicfv/86XRVeTZxW+RLHsvp0kR5BvFzhduGoQP4y DfgQ0jH1/4ZG5a8Rosa40+gmhV1/SyAP869DHnNzsAM6MKWO4WJlgqklInJV7BNe/yBt HaTlBYiY64hQcsMNoCWwXEJW8X72aeF7M4Dx9PXWA6r29kq2Of84dHw49ndrZklGetjK FQZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1ojmtWuhoXE+10Oa37xZFid38Sh0C/r73ASNaf7SWHQ=; b=sEHoXYHv084Pfzm1OaO/tPXb/S3puYfaR90/KmWbfABztkS5ZvUnUIIMlUvc9nvVMt XS+aPRgjYM9fvwabgwEq7/ckaLIWihTxqSsQ7LnjzOzjxnP3qkTSTBCEkUQP4Esoivc1 VBGMp27D8ZnPVpWc8OWafBglZY6mmHAKI15wFQTcTQ9OUD82eqgFFgZwhesrfHm/Yz5p yY4WxlUpMPbA1xzUqUkHXqRwfOaMyp/SmXU52z2ujBo8FwM2BuQKP5XA9TFyMjpYAWAt uyZt2aALJ12xVKlRLeEXC+VxLHfkDgVNtIyr8wJQWMDieJwU32OJ4LWgYBLt41bXKanA T32w== X-Gm-Message-State: AOAM5330HL44k6df1aB1NoqtVzW9ZIoZ8/k/wdWNakwC1V136TAAR4nl j2dxxm0G+YbHkDFM00JzpR8pGSMqg4eCwJrDZqw= X-Google-Smtp-Source: ABdhPJwhM3ZE0lj3C9bvbV7DNY7AXaVeMAwiOMd7/7ldDQfk666wq76gTljckR5j86QwsbuotoGufWvliS8VdCV7FaY= X-Received: by 2002:a05:620a:1674:: with SMTP id d20mr248343qko.131.1594656038015; Mon, 13 Jul 2020 09:00:38 -0700 (PDT) MIME-Version: 1.0 References: <20200705195110.405139-1-anarsoul@gmail.com> <20200705195110.405139-2-anarsoul@gmail.com> <70578F86-20D3-41C7-A968-83B0605D3526@holtmann.org> In-Reply-To: <70578F86-20D3-41C7-A968-83B0605D3526@holtmann.org> From: Vasily Khoruzhick Date: Mon, 13 Jul 2020 09:00:11 -0700 Message-ID: Subject: Re: [PATCH 1/3] Bluetooth: Add new quirk for broken local ext features max_page To: Marcel Holtmann Cc: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree , arm-linux , kernel list , linux-bluetooth , "open list:NETWORKING [GENERAL]" , Ondrej Jirman Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 41DB253078 X-Rspamd-UID: c216a3 On Sun, Jul 12, 2020 at 11:28 PM Marcel Holtmann wrote: Hi Marcel, > maybe just the read sync train params command is broken? Can you change the init code and not send it and see if the rest of the init phase proceeds. I would rather have the secure connections actually tested before dismissing it altogether. I don't think that I have any devices that support secure connections to test, I've got only a bluetooth mouse and headphones, both are from the 2.0 era. FWIW unofficial recommendation from Realtek to Pine64 was to avoid using any 4.1+ features on this chip. Unfortunately I don't have any contacts with Realtek, so I can't confirm that. > Mind you, there were broken Broadcom implementation of connectionless slave broadcast as well. Maybe this is similar. I'd prefer to stick to what works unless there's some comprehensive test that can figure out what's broken. Regards, Vasily Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aK4KJSONDF/68QAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 18:34:43 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ePtjIyONDF9rTQAADc0bRg (envelope-from ); Mon, 13 Jul 2020 18:34:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1B8A0A3247; Mon, 13 Jul 2020 18:34:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730554AbgGMQct convert rfc822-to-8bit (ORCPT + 1 other); Mon, 13 Jul 2020 12:32:49 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:48827 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730366AbgGMQco (ORCPT ); Mon, 13 Jul 2020 12:32:44 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 1EE46CECC9; Mon, 13 Jul 2020 18:42:40 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 1/3] Bluetooth: Add new quirk for broken local ext features max_page From: Marcel Holtmann In-Reply-To: Date: Mon, 13 Jul 2020 18:32:41 +0200 Cc: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Johan Hedberg , "David S. Miller" , Jakub Kicinski , devicetree , arm-linux , kernel list , linux-bluetooth , "open list:NETWORKING [GENERAL]" , Ondrej Jirman Content-Transfer-Encoding: 8BIT Message-Id: References: <20200705195110.405139-1-anarsoul@gmail.com> <20200705195110.405139-2-anarsoul@gmail.com> <70578F86-20D3-41C7-A968-83B0605D3526@holtmann.org> To: Vasily Khoruzhick X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 30 X-Rspamd-Score: 4.59 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1B8A0A3247 X-Rspamd-UID: cec236 Hi Vasily, >> maybe just the read sync train params command is broken? Can you change the init code and not send it and see if the rest of the init phase proceeds. I would rather have the secure connections actually tested before dismissing it altogether. > > I don't think that I have any devices that support secure connections > to test, I've got only a bluetooth mouse and headphones, both are from > the 2.0 era. > > FWIW unofficial recommendation from Realtek to Pine64 was to avoid > using any 4.1+ features on this chip. Unfortunately I don't have any > contacts with Realtek, so I can't confirm that. > >> Mind you, there were broken Broadcom implementation of connectionless slave broadcast as well. Maybe this is similar. > > I'd prefer to stick to what works unless there's some comprehensive > test that can figure out what's broken. check if removing the read sync trains params command makes the controller initialize and usable. Then we see about the rest. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UGqwNTaODF/68QAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 18:39:18 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 2GyqMzaODF8aTgAAlScrYA (envelope-from ); Mon, 13 Jul 2020 18:39:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AD72BA36CF; Mon, 13 Jul 2020 18:39:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730586AbgGMQgR (ORCPT + 1 other); Mon, 13 Jul 2020 12:36:17 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:38024 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729751AbgGMQgQ (ORCPT ); Mon, 13 Jul 2020 12:36:16 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 601A8CECCA; Mon, 13 Jul 2020 18:46:12 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2] Bluetooth: btusb: add Realtek 8822CE to usb_device_id table From: Marcel Holtmann In-Reply-To: <20200713154512.v2.1.I63705bf6abab9cb79c14f7959a59b201af2b8827@changeid> Date: Mon, 13 Jul 2020 18:36:14 +0200 Cc: Bluetooth Kernel Mailing List , Luiz Augusto von Dentz , chromeos-bluetooth-upstreaming , josephsih@google.com, Alain Michaud , Johan Hedberg , linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: References: <20200713154512.v2.1.I63705bf6abab9cb79c14f7959a59b201af2b8827@changeid> To: Joseph Hwang X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.90 / 15.00 / 200.00 X-Rspamd-Queue-Id: AD72BA36CF X-Rspamd-UID: 898fa9 Hi Joseph, > This patch adds the Realtek 8822CE controller to the usb_device_id > table to support the wideband speech capability. > > Reviewed-by: alainm@chromium.org > Signed-off-by: Joseph Hwang > --- > > Changes in v2: > - Fixed the commit subject and message body. > > drivers/bluetooth/btusb.c | 4 ++++ > 1 file changed, 4 insertions(+) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qFGRCw2PDF848AAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 18:42:53 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8Pn8CQ2PDF8KSgAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 18:42:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 81073A3247; Mon, 13 Jul 2020 18:42:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729854AbgGMQif (ORCPT + 1 other); Mon, 13 Jul 2020 12:38:35 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:47939 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730652AbgGMQid (ORCPT ); Mon, 13 Jul 2020 12:38:33 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 82B46CECC9; Mon, 13 Jul 2020 18:48:29 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v1] Bluetooth: hci_qca: Bug fixes for SSR From: Marcel Holtmann In-Reply-To: <1594467072-13332-1-git-send-email-gubbaven@codeaurora.org> Date: Mon, 13 Jul 2020 18:38:31 +0200 Cc: Johan Hedberg , Matthias Kaehlcke , kernel list , Bluetooth Kernel Mailing List , hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org Content-Transfer-Encoding: 7bit Message-Id: References: <1594467072-13332-1-git-send-email-gubbaven@codeaurora.org> To: Venkata Lakshmi Narayana Gubba X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: 0.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 81073A3247 X-Rspamd-UID: afbea3 Hi Venkata, > 1.During SSR for command time out if BT SoC goes to inresponsive > state, power cycling of BT SoC was not happening.Given the fix by > sending hw error event to reset the BT SoC. > > 2.If SSR is triggered then ignore the transmit data requests to > BT SoC until SSR is completed. > > Signed-off-by: Venkata Lakshmi Narayana Gubba > --- > drivers/bluetooth/hci_qca.c | 40 ++++++++++++++++++++++++++++++++++++---- > 1 file changed, 36 insertions(+), 4 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QH+yM6qPDF9MyQAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 18:45:30 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id EAjoMaqPDF9jHgEAgupzMw (envelope-from ); Mon, 13 Jul 2020 18:45:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6BD85A3542; Mon, 13 Jul 2020 18:45:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730575AbgGMQmJ (ORCPT + 1 other); Mon, 13 Jul 2020 12:42:09 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:42089 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729751AbgGMQmE (ORCPT ); Mon, 13 Jul 2020 12:42:04 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 581A5CECCA; Mon, 13 Jul 2020 18:52:00 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [Linux-kernel-mentees] [PATCH 2/2] net/bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi_evt() From: Marcel Holtmann In-Reply-To: <82c4e719b7615f5333444bdc2b5cc243a693eeb1.1594414498.git.yepeilin.cs@gmail.com> Date: Mon, 13 Jul 2020 18:42:02 +0200 Cc: Johan Hedberg , "David S. Miller" , Jakub Kicinski , Russell King , Greg KH , Bluetooth Kernel Mailing List , "open list:NETWORKING [GENERAL]" , linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <1B0C88A5-05B1-49FB-9B8C-8D833BA51AD9@holtmann.org> References: <3f69f09d6eb0bc1430cae2894c635252a1cb09e1.1594414498.git.yepeilin.cs@gmail.com> <82c4e719b7615f5333444bdc2b5cc243a693eeb1.1594414498.git.yepeilin.cs@gmail.com> To: Peilin Ye X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.37 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6BD85A3542 X-Rspamd-UID: aaa3ae Hi Peilin, > Check `num_rsp` before using it as for-loop counter. Add `unlock` label. > > Cc: stable@vger.kernel.org > Signed-off-by: Peilin Ye > --- > net/bluetooth/hci_event.c | 7 +++++++ > 1 file changed, 7 insertions(+) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UPLiG66PDF/68QAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 18:45:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UDN2Gq6PDF+rGAEAgupzMw (envelope-from ); Mon, 13 Jul 2020 18:45:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0009FA3802; Mon, 13 Jul 2020 18:45:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730455AbgGMQmE (ORCPT + 1 other); Mon, 13 Jul 2020 12:42:04 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:47865 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730298AbgGMQmC (ORCPT ); Mon, 13 Jul 2020 12:42:02 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 8F230CECC9; Mon, 13 Jul 2020 18:51:58 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [Linux-kernel-mentees] [PATCH 1/2] net/bluetooth: Prevent out-of-bounds read in hci_inquiry_result_evt() From: Marcel Holtmann In-Reply-To: <3f69f09d6eb0bc1430cae2894c635252a1cb09e1.1594414498.git.yepeilin.cs@gmail.com> Date: Mon, 13 Jul 2020 18:42:00 +0200 Cc: Johan Hedberg , "David S. Miller" , Jakub Kicinski , Russell King , Greg KH , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <72AE7F80-CE19-4051-85DB-60A3FD80D390@holtmann.org> References: <3f69f09d6eb0bc1430cae2894c635252a1cb09e1.1594414498.git.yepeilin.cs@gmail.com> To: Peilin Ye X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 7 X-Rspamd-Score: 1.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0009FA3802 X-Rspamd-UID: 5ba9f5 Hi Peilin, > Check `num_rsp` before using it as for-loop counter. > > Cc: stable@vger.kernel.org > Signed-off-by: Peilin Ye > --- > net/bluetooth/hci_event.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wDeaGNLADF95IQAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 22:15:14 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id IKPQFtLADF8PWAEAlScrYA (envelope-from ); Mon, 13 Jul 2020 22:15:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DB913A3740; Mon, 13 Jul 2020 22:15:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726599AbgGMUPF (ORCPT + 1 other); Mon, 13 Jul 2020 16:15:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgGMUPF (ORCPT ); Mon, 13 Jul 2020 16:15:05 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33E23C061755 for ; Mon, 13 Jul 2020 13:15:05 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id x8so5996026plm.10 for ; Mon, 13 Jul 2020 13:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FrBgPrgTeBiJc90yEeremeQlH6Tb4/9Y0eWkSBJnlyc=; b=W/KC/3P+fyNwficSIm+l9Hmg8NVivaEb7530aUaJRrF8v0fvEMPNKHiWbAGoa6KHMv Yy3VZbnx0qMhKRaco32m/D78T2/lNs9fqEeLqHa87JFIJqRHP/pRIr2Hvsx6bAcykWYN 3w7pCjEJSCvkV2P1vU3UiyX5MGKC+dfNFQVvw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FrBgPrgTeBiJc90yEeremeQlH6Tb4/9Y0eWkSBJnlyc=; b=PGyMOYsHPphvPIvXC21Ca6MKpXUqDcvghSyzy9QxHml0+TTBjItxPd90ajRG1HMnJl +/UlodLvArM//zOsJWe1+efUdsIjfNOt5jbFzMmxtS2HmAGCIlnnanF0NIGhVq6mhmHI Iyi+A+15R5aNVVPV2z0vMSRg4RSZq1WoN4ozdUDlR+pS+NIDrnm6LS/a3OUWlWPrsRmB FYBrun9D8OTFK7JlKMSTVZ1yesYqas8ImnaiB2x1FDWzFMFj2PoRoRRkdrCsGSyi7XYU No0f9JTinEsVArtyPmnNoJwNY6lyanlEDFnYvlBV6g++CAQRwYrhY2rPMqWuJTNNJUYb AU/Q== X-Gm-Message-State: AOAM5317Rw0MVodZsax2ERkUs+F/s9iw1cx06QU7vQcKFYcXOqoGxQcB pgoJHeRHLsxZSXMXDZcL0XlRjiAJfEI= X-Google-Smtp-Source: ABdhPJyqtBpD62gnyd+/pHFGD0fZhhtKH2c4YaEVXRMjvzu5/fjGcdn+So9cmZgkufLOC/cFBnF4Iw== X-Received: by 2002:a17:90a:bc98:: with SMTP id x24mr966653pjr.63.1594671304665; Mon, 13 Jul 2020 13:15:04 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id h18sm7866135pfr.186.2020.07.13.13.15.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jul 2020 13:15:04 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth-@vger.kernel.org, linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka , Alain Michaud Subject: [PATCH BlueZ 2/3] device: Add "AllowInternalProfiles" property to org.bluez.Device1 Date: Mon, 13 Jul 2020 13:14:40 -0700 Message-Id: <20200713201441.235959-3-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200713201441.235959-1-sonnysasaka@chromium.org> References: <20200713201441.235959-1-sonnysasaka@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 23 X-Rspamd-Score: 3.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: DB913A3740 X-Rspamd-UID: 08a61a Some clients want to have full control over all profiles for specific peer devices, for example to handle the GATT Battery profile. This patch adds an option via a property in org.bluez.Device1 interface. Setting to true will let BlueZ take control over internal profiles (such as A2DP, HOG, Battery), and setting to false will prevent BlueZ from handling all internal profiles, allowing the client to handle them. Reviewed-by: Alain Michaud --- src/device.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/hcid.h | 2 ++ src/main.c | 10 ++++++ src/main.conf | 4 +++ 4 files changed, 112 insertions(+) diff --git a/src/device.c b/src/device.c index 0deee2707..bd8c80032 100644 --- a/src/device.c +++ b/src/device.c @@ -275,6 +275,7 @@ struct btd_device { gboolean auto_connect; gboolean disable_auto_connect; gboolean general_connect; + gboolean allow_internal_profiles; bool legacy; int8_t rssi; @@ -294,6 +295,10 @@ static const uint16_t uuid_list[] = { static int device_browse_gatt(struct btd_device *device, DBusMessage *msg); static int device_browse_sdp(struct btd_device *device, DBusMessage *msg); +static void gatt_service_added(struct gatt_db_attribute *attr, void *user_data); +static void gatt_service_removed(struct gatt_db_attribute *attr, + void *user_data); + static struct bearer_state *get_state(struct btd_device *dev, uint8_t bdaddr_type) { @@ -436,6 +441,9 @@ static gboolean store_device_info_cb(gpointer user_data) g_key_file_set_boolean(key_file, "General", "Blocked", device->blocked); + g_key_file_set_boolean(key_file, "General", "AllowInternalProfiles", + device->allow_internal_profiles); + if (device->wake_override != WAKE_FLAG_DEFAULT) { g_key_file_set_boolean(key_file, "General", "WakeAllowed", device->wake_override == @@ -1468,6 +1476,71 @@ static gboolean dev_property_wake_allowed_exist( return device_get_wake_support(device); } +static gboolean +dev_property_get_allow_internal_profiles(const GDBusPropertyTable *property, + DBusMessageIter *iter, + void *data) +{ + struct btd_device *device = data; + dbus_bool_t allow_internal_profiles = device->allow_internal_profiles; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, + &allow_internal_profiles); + + return TRUE; +} + +static void +dev_property_set_allow_internal_profiles(const GDBusPropertyTable *property, + DBusMessageIter *value, + GDBusPendingPropertySet id, + void *data) +{ + struct btd_device *device = data; + dbus_bool_t b; + + if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN) { + g_dbus_pending_property_error( + id, ERROR_INTERFACE ".InvalidArguments", + "Invalid arguments in method call"); + return; + } + + if (device->le_state.connected || device->bredr_state.connected) { + g_dbus_pending_property_error(id, ERROR_INTERFACE ".Failed", + "Device is connected"); + return; + } + + dbus_message_iter_get_basic(value, &b); + + device->allow_internal_profiles = b; + + /* Remove GATT client cache */ + gatt_db_unregister(device->db, device->db_id); + btd_gatt_client_destroy(device->client_dbus); + gatt_db_unref(device->db); + + device->db = gatt_db_new(); + device->client_dbus = btd_gatt_client_new(device); + device->db_id = gatt_db_register(device->db, gatt_service_added, + gatt_service_removed, device, NULL); + + /* Re-probe all profiles */ + while (device->services != NULL) { + struct btd_service *service = device->services->data; + + device->services = g_slist_remove(device->services, service); + service_remove(service); + } + + device_probe_profiles(device, device->uuids); + + /* Update D-Bus property and reply client */ + g_dbus_emit_property_changed(dbus_conn, device->path, DEVICE_INTERFACE, + "AllowInternalProfiles"); + g_dbus_pending_property_success(id); +} static gboolean disconnect_all(gpointer user_data) { @@ -2944,6 +3017,9 @@ static const GDBusPropertyTable device_properties[] = { { "WakeAllowed", "b", dev_property_get_wake_allowed, dev_property_set_wake_allowed, dev_property_wake_allowed_exist }, + { "AllowInternalProfiles", "b", + dev_property_get_allow_internal_profiles, + dev_property_set_allow_internal_profiles }, { } }; @@ -3196,6 +3272,7 @@ static void load_info(struct btd_device *device, const char *local, char *str; gboolean store_needed = FALSE; gboolean blocked; + gboolean allow_internal_profiles; gboolean wake_allowed; char **uuids; int source, vendor, product, version; @@ -3283,6 +3360,20 @@ next: if (blocked) device_block(device, FALSE); + /* Load allow internal profiles */ + allow_internal_profiles = g_key_file_get_boolean( + key_file, "General", "AllowInternalProfiles", &gerr); + if (!gerr) { + device->allow_internal_profiles = allow_internal_profiles; + } else { + /* Old config doesn't contain this item, so set it to true to + * match the previous default behavior. + */ + device->allow_internal_profiles = true; + g_error_free(gerr); + gerr = NULL; + } + /* Load device profile list */ uuids = g_key_file_get_string_list(key_file, "General", "Services", NULL, NULL); @@ -3782,6 +3873,9 @@ static bool device_match_profile(struct btd_device *device, bt_uuid_strcmp) == NULL) return false; + if (!device->allow_internal_profiles && !profile->external) + return false; + return true; } @@ -4055,6 +4149,8 @@ static struct btd_device *device_new(struct btd_adapter *adapter, device->adapter = adapter; device->temporary = true; + device->allow_internal_profiles = + main_opts.default_allow_internal_profiles; device->db_id = gatt_db_register(device->db, gatt_service_added, gatt_service_removed, device, NULL); diff --git a/src/hcid.h b/src/hcid.h index c21ac9980..82ea0cb14 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -114,6 +114,8 @@ struct main_opts { uint8_t key_size; enum jw_repairing_t jw_repairing; + + gboolean default_allow_internal_profiles; }; extern struct main_opts main_opts; diff --git a/src/main.c b/src/main.c index bacb44197..30218f8d0 100644 --- a/src/main.c +++ b/src/main.c @@ -89,6 +89,7 @@ static const char *supported_options[] = { "FastConnectable", "Privacy", "JustWorksRepairing", + "DefaultAllowInternalProfiles", NULL }; @@ -615,6 +616,13 @@ static void parse_config(GKeyFile *config) else main_opts.fast_conn = boolean; + boolean = g_key_file_get_boolean(config, "General", + "DefaultAllowInternalProfiles", &err); + if (err) + g_clear_error(&err); + else + main_opts.default_allow_internal_profiles = boolean; + str = g_key_file_get_string(config, "GATT", "Cache", &err); if (err) { DBG("%s", err->message); @@ -691,6 +699,8 @@ static void init_defaults(void) main_opts.gatt_cache = BT_GATT_CACHE_ALWAYS; main_opts.gatt_mtu = BT_ATT_MAX_LE_MTU; main_opts.gatt_channels = 3; + + main_opts.default_allow_internal_profiles = true; } static void log_handler(const gchar *log_domain, GLogLevelFlags log_level, diff --git a/src/main.conf b/src/main.conf index 6a6f7d4b4..497394395 100644 --- a/src/main.conf +++ b/src/main.conf @@ -77,6 +77,10 @@ # Defaults to "never" #JustWorksRepairing = never +# The default value of "AllowInternalProfiles" property in org.bluez.Device1 +# interface. Defaults to 'true'. +#DefaultAllowInternalProfiles = true + [Controller] # The following values are used to load default adapter parameters. BlueZ loads # the values into the kernel before the adapter is powered if the kernel -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qGz5LdfADF95IQAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 22:15:19 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id sDmtLNfADF8guQEAgupzMw (envelope-from ); Mon, 13 Jul 2020 22:15:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 887CFA3CA4; Mon, 13 Jul 2020 22:15:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbgGMUPH (ORCPT + 1 other); Mon, 13 Jul 2020 16:15:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgGMUPG (ORCPT ); Mon, 13 Jul 2020 16:15:06 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD936C061755 for ; Mon, 13 Jul 2020 13:15:06 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id x9so6011109plr.2 for ; Mon, 13 Jul 2020 13:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xuwheI+yFoySeDdqiX9Di5PWt7znOMhM8gXI0aBJuic=; b=b/7kWF87GiyV5+sodQkD2ZHy+FdJZqCkfuZaSd1uqlzgW7ml0CZ9XglUjlVXBnJMiK d0KFLvkPWxdD5R1SOQmMUisRAhke4dLNgeAvXeZgWDLV3NomZCsUB2hXNzruEvP7dpEa 9iPbpZCLzw9OxR8OrfL4ZKWxfPUgbWRPGmnLE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xuwheI+yFoySeDdqiX9Di5PWt7znOMhM8gXI0aBJuic=; b=QimzKJ8tfkLkErcP0QVLk3PmrteXgKxJEmwt/D7sKUPI0c8HGo+yeBf0ECiY2S44+Y VGYIUL9U/Y+uRFF9VrXtkuCywfKQdEGXovzcepTaLEraZLctgzp+oVgG3mMMjdPivrx0 8soY+4PcmWiuY0M9rzuX9b2A33oKn6o27VFCvMcSpkxMDrmt3hluIo4H4grhru3gs07B iHbX+RKrzL1IdvQ6O7gFb+2JZwk5O1ChEi5VHvVroch8665VoYzI9qy1IfC8QFHtgyZg zltRsffTujcH3MkKKaeCEhtA1d49iQMvn+ZWK+ApGZVZB9WzCv6vy10EOeUfQlZBINCR A8xQ== X-Gm-Message-State: AOAM5308VlQj9O0Ar2hofcyxI1nlCuaGsL2LVSMtslz/J+Jp9zpNvrIY gcHho4HSPrUwJTTnqxaNhNaFXQ== X-Google-Smtp-Source: ABdhPJzFvaJiTeGC4CN3aVEEi1nv42e0gdZ8vE2aZ2MrS4fywWaBI9Oma5fj+MVBzF31gJIvfFVHLw== X-Received: by 2002:a17:90a:9d84:: with SMTP id k4mr1084380pjp.227.1594671306331; Mon, 13 Jul 2020 13:15:06 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id h18sm7866135pfr.186.2020.07.13.13.15.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jul 2020 13:15:05 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth-@vger.kernel.org, linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka , Alain Michaud Subject: [PATCH BlueZ 3/3] client: Add set-allow-internal-profiles command Date: Mon, 13 Jul 2020 13:14:41 -0700 Message-Id: <20200713201441.235959-4-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200713201441.235959-1-sonnysasaka@chromium.org> References: <20200713201441.235959-1-sonnysasaka@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 887CFA3CA4 X-Rspamd-UID: 0f18f6 Reviewed-by: Alain Michaud --- client/main.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/client/main.c b/client/main.c index 9abada69f..c2b6e21e4 100644 --- a/client/main.c +++ b/client/main.c @@ -1678,6 +1678,7 @@ static void cmd_info(int argc, char *argv[]) print_property(proxy, "Connected"); print_property(proxy, "WakeAllowed"); print_property(proxy, "LegacyPairing"); + print_property(proxy, "AllowInternalProfiles"); print_uuids(proxy); print_property(proxy, "Modalias"); print_property(proxy, "ManufacturerData"); @@ -1838,6 +1839,39 @@ static void cmd_unblock(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_FAILURE); } +static void cmd_set_allow_internal_profiles(int argc, char *argv[]) +{ + GDBusProxy *proxy; + dbus_bool_t allow_internal_profiles; + char *str; + + proxy = find_device(argc, argv); + if (!proxy) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (strcmp(argv[2], "true") != 0 && strcmp(argv[2], "false") != 0) { + bt_shell_printf("Invalid argument: %s\n", argv[2]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + allow_internal_profiles = strcmp(argv[2], "true") == 0 ? true : false; + + str = g_strdup_printf("%s allow internal profiles", + proxy_address(proxy)); + + if (g_dbus_proxy_set_property_basic(proxy, "AllowInternalProfiles", + DBUS_TYPE_BOOLEAN, + &allow_internal_profiles, + generic_callback, + str, + g_free) == TRUE) + return; + + g_free(str); + + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + static void remove_device_reply(DBusMessage *message, void *user_data) { DBusError error; @@ -2824,6 +2858,10 @@ static const struct bt_shell_menu main_menu = { dev_generator }, { "unblock", "[dev]", cmd_unblock, "Unblock device", dev_generator }, + { "set-allow-internal-profiles", " ", + cmd_set_allow_internal_profiles, + "Set allow internal profiles", + dev_generator }, { "remove", "", cmd_remove, "Remove device", dev_generator }, { "connect", "", cmd_connect, "Connect device", -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KCHsM82TDF8xBwEAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 19:03:09 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EJFjMs2TDF+iXAAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 19:03:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 929ED531BD; Mon, 13 Jul 2020 19:03:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729869AbgGMRDD (ORCPT + 1 other); Mon, 13 Jul 2020 13:03:03 -0400 Received: from fgw22-4.mail.saunalahti.fi ([62.142.5.109]:60056 "EHLO fgw22-4.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729751AbgGMRDD (ORCPT ); Mon, 13 Jul 2020 13:03:03 -0400 X-Greylist: delayed 962 seconds by postgrey-1.27 at vger.kernel.org; Mon, 13 Jul 2020 13:03:01 EDT Received: from ydin.reaktio.net (reaktio.net [85.76.255.15]) by fgw22.mail.saunalahti.fi (Halon) with ESMTP id 7720d933-c528-11ea-88ca-005056bdf889; Mon, 13 Jul 2020 19:46:58 +0300 (EEST) Received: by ydin.reaktio.net (Postfix, from userid 1001) id 94B1336C0F6; Mon, 13 Jul 2020 19:46:57 +0300 (EEST) Date: Mon, 13 Jul 2020 19:46:57 +0300 From: Pasi =?iso-8859-1?Q?K=E4rkk=E4inen?= To: Luiz Augusto von Dentz Cc: Pali =?iso-8859-1?Q?Roh=E1r?= , Ujjwal Sharma , Andrew Fuller , Aleksandar Kostadinov , David Heidelberg , Marcel Holtmann , Johan Hedberg , "linux-bluetooth@vger.kernel.org" , Pavel Machek , usharma@chromium.org Subject: Re: Bluetooth: Allow to use configure SCO socket codec parameters Message-ID: <20200713164657.GD12041@reaktio.net> References: <177c5794-1cd7-8f76-b66f-e9473ed37a31@redhat.com> <20200516075340.3z37ejs3fuhctunl@pali> <20200518165011.jfarrp5mtqoy3mqz@pali> <6da08b42-34d5-9d20-bfc1-161cc8d0f2ea@igalia.com> <20200604204343.eor47oe3fbzf6rbv@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200604204343.eor47oe3fbzf6rbv@pali> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.33 / 15.00 / 200.00 X-Rspamd-Queue-Id: 929ED531BD X-Rspamd-UID: 6240d5 Hello Luiz, On Thu, Jun 04, 2020 at 10:43:43PM +0200, Pali Rohr wrote: > On Wednesday 27 May 2020 21:54:18 Ujjwal Sharma wrote: > > Hi Luiz! > > > > Thanks for your response. > > > > On 5/27/20 9:18 PM, Luiz Augusto von Dentz wrote: > > > Hi Ujjwal, > > > ... > > > Testing is one thing but for production we would need a qualifyable > > > solution, that said I wouldn't oppose to have the socket option behind > > > a module options (runtime) or Kconfig (build-time) so people willing > > > to run this code can do on their own. > > > > 1. What do you think is lacking in this solution that would make it > > qualifyable for production? I believe there are multiple people in this > > thread including Pali who are willing to put in the extra effort. > > > > 2. I'd be happy with a runtime option which would allow me to test this > > as well. > > Have I missed something? setsockopt() solution which I described in > <20200419234937.4zozkqgpt557m3o6@pali> email is already runtime option. > Luiz: Please comment here.. what's missing from these patches? How can we get these merged? Pulseaudio support is pending this kernel support/patches.. Thanks a lot, -- Pasi Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QDIzMjWqDF84ZwEAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 20:38:45 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id kK3IMDWqDF9zJgAA0J78UA (envelope-from ); Mon, 13 Jul 2020 20:38:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 572D0A4B01; Mon, 13 Jul 2020 20:38:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726338AbgGMSih convert rfc822-to-8bit (ORCPT + 1 other); Mon, 13 Jul 2020 14:38:37 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:33722 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbgGMSih (ORCPT ); Mon, 13 Jul 2020 14:38:37 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 6ED94CECCB; Mon, 13 Jul 2020 20:48:34 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v3] Bluetooth: create CONFIG_BT_DEBUG_FEATURE_FUNC_NAME From: Marcel Holtmann In-Reply-To: <20200707195156.885137-1-alainm@chromium.org> Date: Mon, 13 Jul 2020 20:38:36 +0200 Cc: Bluetooth Kernel Mailing List , Archie Pusaka Content-Transfer-Encoding: 8BIT Message-Id: References: <20200707195156.885137-1-alainm@chromium.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: 572D0A4B01 X-Rspamd-UID: 825985 Hi Alain, > Creates a CONFIG_BT_DEBUG_FEATURE_FUNC_NAME option to include function names in > debug statements. > > Unlike other platforms __func__ isn't a string literal so it cannot be > automatically concatenated by the pre-processor. As a result, the > function name is passed as a parameter to the tracing function. Since > pr_debug is a function like macro, the normal expansion of BT_PREFIX_PARAM > does not work as it gets processed within the first parameter as well, > for this reason, BT_DBG is split into two versions. > > This patch was built tested with all 4 possible combinations of > CONFIG_BT_DEBUG_FUNC_NAME and CONFIG_BT_FEATURE_DEBUG configurations. you actually didn’t answer my question last time. Can we just always show the function names with CONFIG_BT_FEATURE_DEBUG and leave it as that. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qIHPKZmyDF+ZqgEAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 21:14:33 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id MH8yKJmyDF8qcwAA0J78UA (envelope-from ); Mon, 13 Jul 2020 21:14:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 88397A3EE6; Mon, 13 Jul 2020 21:14:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726347AbgGMTO0 convert rfc822-to-8bit (ORCPT + 1 other); Mon, 13 Jul 2020 15:14:26 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:59577 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgGMTO0 (ORCPT ); Mon, 13 Jul 2020 15:14:26 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id CA56CCECCC; Mon, 13 Jul 2020 21:24:21 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2 1/5] Bluetooth: btintel: Make controller version read generic From: Marcel Holtmann In-Reply-To: <20200703071212.17046-1-kiran.k@intel.com> Date: Mon, 13 Jul 2020 21:14:23 +0200 Cc: Bluetooth Kernel Mailing List , "Srivatsa, Ravishankar" , Chethan T N , kiraank@gmail.com, Amit K Bag , Raghuram Hegde Content-Transfer-Encoding: 8BIT Message-Id: <21E18541-08DD-4340-9E58-212FA126ADFA@holtmann.org> References: <20200703071212.17046-1-kiran.k@intel.com> To: Kiran K X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 88397A3EE6 X-Rspamd-UID: 5f12d4 Hi Kiran, > Make controller read vesion function more generic to support different > type of controllers. > > Signed-off-by: Kiran K > Signed-off-by: Amit K Bag > Signed-off-by: Raghuram Hegde > Reviewed-by: Chethan T N > Reviewed-by: Sathish Narasimman > Reviewed-by: Srivatsa Ravishankar > --- > > Changes in v2: None > Changes in v1: > - Make controller read version function generic > > drivers/bluetooth/btintel.c | 36 ++++++++++++++---- > drivers/bluetooth/btintel.h | 15 ++++++-- > drivers/bluetooth/btusb.c | 71 +++++++++++++++++++++++------------ > drivers/bluetooth/hci_ag6xx.c | 12 +++++- > drivers/bluetooth/hci_intel.c | 12 +++++- > 5 files changed, 106 insertions(+), 40 deletions(-) > > diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c > index 5fa5be3c5598..dea96c585ecb 100644 > --- a/drivers/bluetooth/btintel.c > +++ b/drivers/bluetooth/btintel.c > @@ -204,9 +204,15 @@ void btintel_hw_error(struct hci_dev *hdev, u8 code) > } > EXPORT_SYMBOL_GPL(btintel_hw_error); > > -void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver) > +void btintel_version_info(struct hci_dev *hdev, const struct btintel_version *version) > { so I am not fully on board with the new btintel_version struct and using it as union. Maybe it is better the function just returns allocated memory and a type indicator. I need to let this stew a little bit. > const char *variant; > + const struct intel_version *ver; > + > + if (version->is_tlv_supported) > + return; > + > + ver = &version->intel_version; > > switch (ver->fw_variant) { > case 0x06: > @@ -335,27 +341,41 @@ int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug) > } > EXPORT_SYMBOL_GPL(btintel_set_event_mask_mfg); > > -int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver) > +int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version) > { > struct sk_buff *skb; const u8 param[1] = 0xff; > + u8 *data, param, status, check_tlv; > + > + if (!version) > + return -EINVAL; > > - skb = __hci_cmd_sync(hdev, 0xfc05, 0, NULL, HCI_CMD_TIMEOUT); > + param = 0xFF; > + > + skb = __hci_cmd_sync(hdev, 0xfc05, 1, ¶m, HCI_CMD_TIMEOUT); > if (IS_ERR(skb)) { > bt_dev_err(hdev, "Reading Intel version information failed (%ld)", > PTR_ERR(skb)); > return PTR_ERR(skb); > } > > - if (skb->len != sizeof(*ver)) { > - bt_dev_err(hdev, "Intel version event size mismatch"); > + data = skb->data; > + status = *data; > + if (status) { > + bt_dev_err(hdev, "Intel Read Version command failed (%02x)", > + status); > kfree_skb(skb); > - return -EILSEQ; > + return -bt_to_errno(status); > } > > - memcpy(ver, skb->data, sizeof(*ver)); > + check_tlv = *(data + 1); Lets not introduce the data variable since it is pointless. And even check_tlv variable seems not really needed. > > + if (skb->len == sizeof(version->intel_version) && check_tlv == 0x37) { > + memcpy(&version->intel_version, skb->data, sizeof(version->intel_version)); > + version->is_tlv_supported = false; > + } else { > + version->is_tlv_supported = true; > + } > kfree_skb(skb); > - > return 0; > } > EXPORT_SYMBOL_GPL(btintel_read_version); > diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h > index 08e20606fb58..0865d2d4aca7 100644 > --- a/drivers/bluetooth/btintel.h > +++ b/drivers/bluetooth/btintel.h > @@ -66,6 +66,13 @@ struct intel_debug_features { > __u8 page1[16]; > } __packed; > > +struct btintel_version { > + bool is_tlv_supported; > + union { > + struct intel_version intel_version; /* legacy version */ > + }; > +} __packed; > + > #if IS_ENABLED(CONFIG_BT_INTEL) > > int btintel_check_bdaddr(struct hci_dev *hdev); > @@ -76,13 +83,13 @@ int btintel_set_diag(struct hci_dev *hdev, bool enable); > int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable); > void btintel_hw_error(struct hci_dev *hdev, u8 code); > > -void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver); > +void btintel_version_info(struct hci_dev *hdev, const struct btintel_version *version); This might be better done like this: void btintel_version_info(struct hci_dev *hdev, bool tlv_format, void *buf, u8 len); Depending on from where this is called and if we have existing knowledge of the format, we can keep the current one and just add btintel_version_tlv(.. I do like the latter better, but I would have to look at the whole call-chain first. > int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen, > const void *param); > int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name); > int btintel_set_event_mask(struct hci_dev *hdev, bool debug); > int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug); > -int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver); > +int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version); int btintel_read_version(struct hci_dev *hdev, u8 *buf, u8 *len, bool *tlv_format); > struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read, > u16 opcode_write); > @@ -133,7 +140,7 @@ static inline void btintel_hw_error(struct hci_dev *hdev, u8 code) > } > > static inline void btintel_version_info(struct hci_dev *hdev, > - struct intel_version *ver) > + struct btintel_version *version) > { > } > > @@ -160,7 +167,7 @@ static inline int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug) > } > > static inline int btintel_read_version(struct hci_dev *hdev, > - struct intel_version *ver) > + struct btintel_version *version) > { > return -EOPNOTSUPP; > } > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index faa863dd5d0a..d06c946f7810 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -1938,6 +1938,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) > const u8 *fw_ptr; > int disable_patch, err; > struct intel_version ver; > + struct btintel_version version; > > BT_DBG("%s", hdev->name); > > @@ -1963,10 +1964,16 @@ static int btusb_setup_intel(struct hci_dev *hdev) > * The returned information are hardware variant and revision plus > * firmware variant, revision and build number. > */ > - err = btintel_read_version(hdev, &ver); > + err = btintel_read_version(hdev, &version); > if (err) > return err; > > + if (version.is_tlv_supported) { > + bt_dev_err(hdev, "FW download in tlv format not supported"); > + return -EOPNOTSUPP; > + } > + ver = version.intel_version; > + > bt_dev_info(hdev, "read Intel version: %02x%02x%02x%02x%02x%02x%02x%02x%02x", > ver.hw_platform, ver.hw_variant, ver.hw_revision, > ver.fw_variant, ver.fw_revision, ver.fw_build_num, > @@ -2049,11 +2056,11 @@ static int btusb_setup_intel(struct hci_dev *hdev) > /* Need build number for downloaded fw patches in > * every power-on boot > */ > - err = btintel_read_version(hdev, &ver); > - if (err) > - return err; > - bt_dev_info(hdev, "Intel BT fw patch 0x%02x completed & activated", > - ver.fw_patch_num); > + err = btintel_read_version(hdev, &version); > + if (err) > + return err; > + bt_dev_info(hdev, "Intel BT fw patch 0x%02x completed & activated", > + version.intel_version.fw_patch_num); > > goto complete; > > @@ -2251,11 +2258,18 @@ static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb) > return -EILSEQ; > } > > -static bool btusb_setup_intel_new_get_fw_name(struct intel_version *ver, > - struct intel_boot_params *params, > - char *fw_name, size_t len, > - const char *suffix) > +static bool btusb_setup_intel_new_get_fw_name(const struct btintel_version *version, > + struct intel_boot_params *params, > + char *fw_name, size_t len, > + const char *suffix) So either we convert the required fields out of the TLV into intel_version or we might have provide them as parameters or an actual separate struct. > { > + const struct intel_version *ver; > + > + if (version->is_tlv_supported) > + return false; > + > + ver = &version->intel_version; > + > switch (ver->hw_variant) { > case 0x0b: /* SfP */ > case 0x0c: /* WsP */ > @@ -2281,18 +2295,21 @@ static bool btusb_setup_intel_new_get_fw_name(struct intel_version *ver, > } > > static int btusb_intel_download_firmware(struct hci_dev *hdev, > - struct intel_version *ver, > + struct btintel_version *version, > struct intel_boot_params *params) > { > const struct firmware *fw; > u32 boot_param; > char fwname[64]; > int err; > + const struct intel_version *ver; > struct btusb_data *data = hci_get_drvdata(hdev); > > - if (!ver || !params) > + if (!version || !params) > return -EINVAL; > > + ver = &version->intel_version; > + > /* The hardware platform number has a fixed value of 0x37 and > * for now only accept this single value. > */ > @@ -2322,8 +2339,6 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev, > return -EINVAL; > } > > - btintel_version_info(hdev, ver); > - I don’t like just removing this here. We add the print outs for a reason. > /* The firmware variant determines if the device is in bootloader > * mode or is running operational firmware. The value 0x06 identifies > * the bootloader and the value 0x23 identifies the operational > @@ -2398,7 +2413,7 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev, > * ibt---.sfi. > * > */ > - err = btusb_setup_intel_new_get_fw_name(ver, params, fwname, > + err = btusb_setup_intel_new_get_fw_name(version, params, fwname, > sizeof(fwname), "sfi"); > if (!err) { > bt_dev_err(hdev, "Unsupported Intel firmware naming"); > @@ -2483,6 +2498,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) > unsigned long long duration; > int err; > struct intel_debug_features features; > + struct btintel_version version; > > BT_DBG("%s", hdev->name); > > @@ -2494,21 +2510,28 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) > > calltime = ktime_get(); > > - /* Read the Intel version information to determine if the device > - * is in bootloader mode or if it already has operational firmware > - * loaded. > + /* Read controller version information and support of tlv format > */ I would leave the comment as is. > - err = btintel_read_version(hdev, &ver); > + err = btintel_read_version(hdev, &version); > if (err) { > - bt_dev_err(hdev, "Intel Read version failed (%d)", err); > + bt_dev_err(hdev, "Intel Read version new failed (%d)", err); Don’t add random “new” parts in the existing messages. > btintel_reset_to_bootloader(hdev); > return err; > } > > - err = btusb_intel_download_firmware(hdev, &ver, ¶ms); > + if (version.is_tlv_supported) { > + bt_dev_err(hdev, "Firmware download in tlv format is not supported"); > + return -EOPNOTSUPP; > + } Do we need this twice? > + > + btintel_version_info(hdev, &version); > + > + err = btusb_intel_download_firmware(hdev, &version, ¶ms); > if (err) > return err; > > + ver = version.intel_version; > + > /* controller is already having an operational firmware */ > if (ver.fw_variant == 0x23) > goto finish; > @@ -2562,7 +2585,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) > > clear_bit(BTUSB_BOOTLOADER, &data->flags); > > - err = btusb_setup_intel_new_get_fw_name(&ver, ¶ms, ddcname, > + err = btusb_setup_intel_new_get_fw_name(&version, ¶ms, ddcname, > sizeof(ddcname), "ddc"); > > if (!err) { > @@ -2586,11 +2609,11 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) > btintel_set_debug_features(hdev, &features); > > /* Read the Intel version information after loading the FW */ > - err = btintel_read_version(hdev, &ver); > + err = btintel_read_version(hdev, &version); > if (err) > return err; > > - btintel_version_info(hdev, &ver); > + btintel_version_info(hdev, &version); > > finish: > /* All Intel controllers that support the Microsoft vendor > diff --git a/drivers/bluetooth/hci_ag6xx.c b/drivers/bluetooth/hci_ag6xx.c > index 1f55df93e4ce..6f6a1e061972 100644 > --- a/drivers/bluetooth/hci_ag6xx.c > +++ b/drivers/bluetooth/hci_ag6xx.c > @@ -153,6 +153,7 @@ static int ag6xx_setup(struct hci_uart *hu) > struct hci_dev *hdev = hu->hdev; > struct sk_buff *skb; > struct intel_version ver; > + struct btintel_version version; > const struct firmware *fw; > const u8 *fw_ptr; > char fwname[64]; > @@ -166,11 +167,18 @@ static int ag6xx_setup(struct hci_uart *hu) > if (err) > return err; > > - err = btintel_read_version(hdev, &ver); > + err = btintel_read_version(hdev, &version); > if (err) > return err; > > - btintel_version_info(hdev, &ver); > + if (version.is_tlv_supported) { > + bt_dev_err(hdev, "Firmware download in tlv format over ag6xx is not supported"); > + return -EOPNOTSUPP; > + } > + > + btintel_version_info(hdev, &version); > + > + ver = version.intel_version; > > /* The hardware platform number has a fixed value of 0x37 and > * for now only accept this single value. > diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c > index f1299da6eed8..f30cbc66d48f 100644 > --- a/drivers/bluetooth/hci_intel.c > +++ b/drivers/bluetooth/hci_intel.c > @@ -532,6 +532,7 @@ static int intel_setup(struct hci_uart *hu) > struct hci_dev *hdev = hu->hdev; > struct sk_buff *skb; > struct intel_version ver; > + struct btintel_version version; > struct intel_boot_params params; > struct list_head *p; > const struct firmware *fw; > @@ -584,10 +585,17 @@ static int intel_setup(struct hci_uart *hu) > * is in bootloader mode or if it already has operational firmware > * loaded. > */ > - err = btintel_read_version(hdev, &ver); > + err = btintel_read_version(hdev, &version); > if (err) > return err; > > + if (version.is_tlv_supported) { > + /* firmware download in tlv format is not supported on UART transport */ > + bt_dev_err(hdev, "Firmware download in tlv format is not supported"); > + return -EOPNOTSUPP; > + } So now I wonder if we really want to send that 0xff even on UART. So maybe btintel_read_version needs to get an extra bool parameter for requesting TLV or not. > + ver = version.intel_version; > + > /* The hardware platform number has a fixed value of 0x37 and > * for now only accept this single value. > */ > @@ -614,7 +622,7 @@ static int intel_setup(struct hci_uart *hu) > return -EINVAL; > } > > - btintel_version_info(hdev, &ver); > + btintel_version_info(hdev, &version); I really think now that btintel_version_info and btintel_version_info_tlv are needed. If we don’t have this on UART, then we should try to change the UART code as less as possible. Or we first need to unify the UART and USB code a lot more into btintel.c so that it is all handled there. > > /* The firmware variant determines if the device is in bootloader > * mode or is running operational firmware. The value 0x06 identifies Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IIYqLwGzDF/dzAEAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 21:16:17 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id MGu+LQGzDF8qcwAA0J78UA (envelope-from ); Mon, 13 Jul 2020 21:16:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 78B3452227; Mon, 13 Jul 2020 21:16:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726510AbgGMTQM convert rfc822-to-8bit (ORCPT + 1 other); Mon, 13 Jul 2020 15:16:12 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:52459 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726347AbgGMTQL (ORCPT ); Mon, 13 Jul 2020 15:16:11 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 8D9E4CECCD; Mon, 13 Jul 2020 21:26:08 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2 3/5] Bluetooth: btintel: Refactor firmware payload download code From: Marcel Holtmann In-Reply-To: <20200703071212.17046-3-kiran.k@intel.com> Date: Mon, 13 Jul 2020 21:16:10 +0200 Cc: Bluetooth Kernel Mailing List , ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Amit K Bag , Raghuram Hegde Content-Transfer-Encoding: 8BIT Message-Id: <87AEDF27-8DE1-4A95-A669-F33BEED91880@holtmann.org> References: <20200703071212.17046-1-kiran.k@intel.com> <20200703071212.17046-3-kiran.k@intel.com> To: Kiran K X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 78B3452227 X-Rspamd-UID: 154a72 Hi Kiran, > Move firmware payload download code to a separate function to > enhance readability and reusability > > Signed-off-by: Kiran K > Signed-off-by: Amit K Bag > Signed-off-by: Raghuram Hegde > Reviewed-by: Chethan T N > Reviewed-by: Sathish Narasimman > Reviewed-by: Srivatsa Ravishankar > --- > > Changes in v2: > - Avoid exporting new public function for firmware download > - Move firmware payload download code to a new function > Changes in v1: > - Move firmware payload download code to a new function > > > drivers/bluetooth/btintel.c | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) > > diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c > index ffc888c4e9e3..2cb55a97598c 100644 > --- a/drivers/bluetooth/btintel.c > +++ b/drivers/bluetooth/btintel.c > @@ -19,6 +19,7 @@ > #define VERSION "0.1" > > #define BDADDR_INTEL (&(bdaddr_t) {{0x00, 0x8b, 0x9e, 0x19, 0x03, 0x00}}) > +#define RSA_HEADER_LEN 644 > > int btintel_check_bdaddr(struct hci_dev *hdev) > { > @@ -682,8 +683,9 @@ static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev, > return err; > } > > -int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, > - u32 *boot_param) > +static int btintel_download_firmware_payload(struct hci_dev *hdev, > + const struct firmware *fw, > + u32 *boot_param, size_t offset) > { > int err; > const u8 *fw_ptr; > @@ -693,8 +695,9 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, > if (err) > goto done; > > - fw_ptr = fw->data + 644; > + fw_ptr = fw->data + offset; > frag_len = 0; > + err = -EINVAL; > > while (fw_ptr - fw->data < fw->size) { > struct hci_command_hdr *cmd = (void *)(fw_ptr + frag_len); > @@ -740,6 +743,19 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, > done: > return err; > } > + > +int btintel_download_firmware(struct hci_dev *hdev, > + const struct firmware *fw, > + u32 *boot_param) > +{ > + int err; > + > + err = btintel_sfi_rsa_header_secure_send(hdev, fw); > + if (err) > + return err; > + > + return btintel_download_firmware_payload(hdev, fw, boot_param, RSA_HEADER_LEN); > +} > EXPORT_SYMBOL_GPL(btintel_download_firmware); > > void btintel_reset_to_bootloader(struct hci_dev *hdev) can we apply patch 1 and 2 independently from general TLV support? If so, then I would just try to get these two applied right away. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qCRODXyzDF+ZqgEAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 21:18:20 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +BV9C3yzDF/czAAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 21:18:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D853352EEA; Mon, 13 Jul 2020 21:18:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726356AbgGMTSO convert rfc822-to-8bit (ORCPT + 1 other); Mon, 13 Jul 2020 15:18:14 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:35879 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726347AbgGMTSO (ORCPT ); Mon, 13 Jul 2020 15:18:14 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 1791CCECCE; Mon, 13 Jul 2020 21:28:10 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2 4/5] Bluetooth: btintel: Define tlv structure for new generation Controllers From: Marcel Holtmann In-Reply-To: <20200703071212.17046-4-kiran.k@intel.com> Date: Mon, 13 Jul 2020 21:18:11 +0200 Cc: Bluetooth Kernel Mailing List , ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, kiraank@gmail.com, Amit K Bag , Raghuram Hegde Content-Transfer-Encoding: 8BIT Message-Id: <06420AF3-C3AE-44A3-95DC-0A99BE845FC5@holtmann.org> References: <20200703071212.17046-1-kiran.k@intel.com> <20200703071212.17046-4-kiran.k@intel.com> To: Kiran K X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: D853352EEA X-Rspamd-UID: b24c11 Hi Kiran, > Define structure used for reading controller information and > to downloading firmware in tlv format used for new generation > Intel controllers > > Signed-off-by: Kiran K > Signed-off-by: Amit K Bag > Signed-off-by: Raghuram Hegde > Reviewed-by: Chethan T N > Reviewed-by: Sathish Narasimman > Reviewed-by: Srivatsa Ravishankar > --- > > Changes in v2: None > Changes in v1: > - Add tlv structure definition > > > drivers/bluetooth/btintel.h | 85 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 85 insertions(+) > > diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h > index 0865d2d4aca7..20007da6b9bd 100644 > --- a/drivers/bluetooth/btintel.h > +++ b/drivers/bluetooth/btintel.h > @@ -6,6 +6,90 @@ > * Copyright (C) 2015 Intel Corporation > */ > > +/* List of tlv type */ > +enum { > + INTEL_TLV_CNVI_TOP = 0x10, > + INTEL_TLV_CNVR_TOP, > + INTEL_TLV_CNVI_BT, > + INTEL_TLV_CNVR_BT, > + INTEL_TLV_CNVI_OTP, > + INTEL_TLV_CNVR_OTP, > + INTEL_TLV_DEV_REV_ID, > + INTEL_TLV_USB_VENDOR_ID, > + INTEL_TLV_USB_PRODUCT_ID, > + INTEL_TLV_PCIE_VENDOR_ID, > + INTEL_TLV_PCIE_DEVICE_ID, > + INTEL_TLV_PCIE_SUBSYSTEM_ID, > + INTEL_TLV_IMAGE_TYPE, > + INTEL_TLV_TIME_STAMP, > + INTEL_TLV_BUILD_TYPE, > + INTEL_TLV_BUILD_NUM, > + INTEL_TLV_FW_BUILD_PRODUCT, > + INTEL_TLV_FW_BUILD_HW, > + INTEL_TLV_FW_STEP, > + INTEL_TLV_BT_SPEC, > + INTEL_TLV_MFG_NAME, > + INTEL_TLV_HCI_REV, > + INTEL_TLV_LMP_SUBVER, > + INTEL_TLV_OTP_PATCH_VER, > + INTEL_TLV_SECURE_BOOT, > + INTEL_TLV_KEY_FROM_HDR, > + INTEL_TLV_OTP_LOCK, > + INTEL_TLV_API_LOCK, > + INTEL_TLV_DEBUG_LOCK, > + INTEL_TLV_MIN_FW, > + INTEL_TLV_LIMITED_CCE, > + INTEL_TLV_SBE_TYPE, > + INTEL_TLV_OTP_BDADDR, > + INTEL_TLV_UNLOCKED_STATE > +}; > + > +struct intel_tlv { > + u8 type; > + u8 len; > + u8 val[0]; > +} __packed; > + > +struct intel_version_tlv { > + u8 status; > + u32 cnvi_top; > + u32 cnvr_top; > + u32 cnvi_bt; > + u32 cnvr_bt; > + u16 cnvi_otp; > + u16 cnvr_otp; > + u16 dev_rev_id; > + u16 usb_vid; > + u16 usb_pid; > + u16 pcie_vendor_id; > + u16 pcie_dev_id; > + u16 pcie_subsys_id; > + u8 img_type; > + u16 timestamp; > + u8 build_type; > + u32 build_num; > + u8 fw_build_prod; > + u8 fw_build_hw; > + u8 fw_build_step; > + u8 bt_spec_ver; > + u16 mfg_name; > + u16 hci_rev; > + u16 lmp_sub_ver; > + u8 otp_patch_ver; > + u8 secure_boot; > + u8 key_from_hdr; > + u8 otp_lock; > + u8 api_lock; > + u8 debug_lock; > + u8 min_fw_build_nn; > + u8 min_fw_build_cw; > + u8 min_fw_build_yy; > + u8 limited_cce; > + u8 sbe_type; > + bdaddr_t otp_bd_addr; > + u8 unlocked_state; > +} __packed; > + This is not required to be __packed. It is not a on-wire structure. In addition, I would just only include the data fields we currently require or want to show in dmesg. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QFIKMeq0DF/dzAEAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 21:24:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id MJ9WL+q0DF8q8wAADc0bRg (envelope-from ); Mon, 13 Jul 2020 21:24:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AEC5652B89; Mon, 13 Jul 2020 21:24:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726504AbgGMTYT (ORCPT + 1 other); Mon, 13 Jul 2020 15:24:19 -0400 Received: from mail-il1-f200.google.com ([209.85.166.200]:56955 "EHLO mail-il1-f200.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726374AbgGMTYS (ORCPT ); Mon, 13 Jul 2020 15:24:18 -0400 Received: by mail-il1-f200.google.com with SMTP id w81so3427757ilk.23 for ; Mon, 13 Jul 2020 12:24:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=V7Mn4NNEM06LP8L1Vm2er27FmjQm0mFjhBQQAteUK84=; b=g0MN37McfsNqPC5VNVpNF4w6HjDfImJgG/x/KS/T5F6Z1PF63dPvp7myZnTxMRC4wx EZsn+lirtWtQQ0bcZOdIRmMG2my1eoBqvyXcIkqPHgPd5wJY5Ze8+FTr4wabLWqvpxtf ShNOBhjKwr7IdvWjfEW8p0VFAn8sywWRGJAxv51zwghOIm28/EPjXUuL2YNIo2fMp6Bw U6/rmvNy8miS5wOU5ikcihy1jh47Z23LeJSqFdP/3v1X+8F969OQHYFwEUmdU/L8922R KdW4e8CPkhAawqUoSHP9vpgL8LPbVmKPn5s805y/AdVraGxInvYYAOcuWPNsCpa/C/Az 7C6A== X-Gm-Message-State: AOAM533FaOX0xnnZRoNgKYxBSHyUoXjMGSvG5mTlje4vVNeg7fdLS9ai lEIaMZjM5HgjsPrU3SBhRctMbYnjBOOJY1cA0/VuYjl2E0cb X-Google-Smtp-Source: ABdhPJzT+lWNu0VlZTNXdCmcr7/UEHNw/1fGt8Rft2zNTuf/VQoMNItCVH2ngRVbMDeKgr92CMYbVi+QiLb4ZNodGgTLo9o3VbTt MIME-Version: 1.0 X-Received: by 2002:a6b:7107:: with SMTP id q7mr1318729iog.86.1594668257740; Mon, 13 Jul 2020 12:24:17 -0700 (PDT) Date: Mon, 13 Jul 2020 12:24:17 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000098e7505aa57a3d5@google.com> Subject: KASAN: slab-out-of-bounds Read in hci_inquiry_result_with_rssi_evt From: syzbot To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@armlinux.org.uk, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.79 / 15.00 / 200.00 X-Rspamd-Queue-Id: AEC5652B89 X-Rspamd-UID: d2a0b6 Hello, syzbot found the following crash on: HEAD commit: a581387e Merge tag 'io_uring-5.8-2020-07-10' of git://git... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=173dd65d100000 kernel config: https://syzkaller.appspot.com/x/.config?x=66ad203c2bb6d8b dashboard link: https://syzkaller.appspot.com/bug?extid=3a430af182785b4c7360 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12badf8f100000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1000d6db100000 IMPORTANT: if you fix the bug, please add the following tag to the commit: Reported-by: syzbot+3a430af182785b4c7360@syzkaller.appspotmail.com ================================================================== BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:406 [inline] BUG: KASAN: slab-out-of-bounds in bacpy include/net/bluetooth/bluetooth.h:274 [inline] BUG: KASAN: slab-out-of-bounds in hci_inquiry_result_with_rssi_evt+0x230/0x6b0 net/bluetooth/hci_event.c:4169 Read of size 6 at addr ffff88809dbc85fb by task kworker/u5:0/1521 CPU: 1 PID: 1521 Comm: kworker/u5:0 Not tainted 5.8.0-rc4-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530 check_memory_region_inline mm/kasan/generic.c:186 [inline] check_memory_region+0x13d/0x180 mm/kasan/generic.c:192 memcpy+0x20/0x60 mm/kasan/common.c:105 memcpy include/linux/string.h:406 [inline] bacpy include/net/bluetooth/bluetooth.h:274 [inline] hci_inquiry_result_with_rssi_evt+0x230/0x6b0 net/bluetooth/hci_event.c:4169 hci_event_packet+0x1e8c/0x86f5 net/bluetooth/hci_event.c:6103 hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Allocated by task 6905: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494 __kmalloc_reserve net/core/skbuff.c:142 [inline] __alloc_skb+0xae/0x550 net/core/skbuff.c:210 alloc_skb include/linux/skbuff.h:1083 [inline] bt_skb_alloc include/net/bluetooth/bluetooth.h:377 [inline] vhci_get_user drivers/bluetooth/hci_vhci.c:165 [inline] vhci_write+0xbd/0x450 drivers/bluetooth/hci_vhci.c:285 call_write_iter include/linux/fs.h:1908 [inline] new_sync_write+0x422/0x650 fs/read_write.c:503 vfs_write+0x59d/0x6b0 fs/read_write.c:578 ksys_write+0x12d/0x250 fs/read_write.c:631 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 4921: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x103/0x2c0 mm/slab.c:3757 ep_eventpoll_release+0x41/0x60 fs/eventpoll.c:864 __fput+0x33c/0x880 fs/file_table.c:281 task_work_run+0xdd/0x190 kernel/task_work.c:135 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_usermode_loop arch/x86/entry/common.c:239 [inline] __prepare_exit_to_usermode+0x1e9/0x1f0 arch/x86/entry/common.c:269 do_syscall_64+0x6c/0xe0 arch/x86/entry/common.c:393 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff88809dbc8400 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 507 bytes inside of 512-byte region [ffff88809dbc8400, ffff88809dbc8600) The buggy address belongs to the page: page:ffffea000276f200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea000288bb48 ffffea0002877488 ffff8880aa000a80 raw: 0000000000000000 ffff88809dbc8000 0000000100000004 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809dbc8500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88809dbc8580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff88809dbc8600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff88809dbc8680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88809dbc8700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ================================================================== --- This bug is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this bug report. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this bug, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IEpNFlK1DF/faQEAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 21:26:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id GKvNFFK1DF9a5AAAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 21:26:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AEE58A3210; Mon, 13 Jul 2020 21:26:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726482AbgGMT0E convert rfc822-to-8bit (ORCPT + 1 other); Mon, 13 Jul 2020 15:26:04 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:40507 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726356AbgGMT0D (ORCPT ); Mon, 13 Jul 2020 15:26:03 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 12F53CECCF; Mon, 13 Jul 2020 21:36:00 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2 5/5] Bluetooth: btintel: Parse controller information present in TLV format From: Marcel Holtmann In-Reply-To: <20200703071212.17046-5-kiran.k@intel.com> Date: Mon, 13 Jul 2020 21:26:01 +0200 Cc: Bluetooth Kernel Mailing List , "Srivatsa, Ravishankar" , Chethan T N , kiraank@gmail.com, Amit K Bag , Raghuram Hegde Content-Transfer-Encoding: 8BIT Message-Id: References: <20200703071212.17046-1-kiran.k@intel.com> <20200703071212.17046-5-kiran.k@intel.com> To: Kiran K X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.82 / 15.00 / 200.00 X-Rspamd-Queue-Id: AEE58A3210 X-Rspamd-UID: 9668b4 Hi Kiran, > New generation Intel controllers returns controller information > in TLV format. Adding capability to parse and log it for debug purpose > > Signed-off-by: Kiran K > Signed-off-by: Amit K Bag > Signed-off-by: Raghuram Hegde > Reviewed-by: Chethan T N > Reviewed-by: Sathish Narasimman > Reviewed-by: Srivatsa Ravishankar > --- > > Changes in v2: > - Fix alignment for break statement > - Use get_unaligned_* > - Add empty line before goto label > > drivers/bluetooth/btintel.c | 144 ++++++++++++++++++++++++++++++++---- > drivers/bluetooth/btusb.c | 4 +- > 2 files changed, 133 insertions(+), 15 deletions(-) > > diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c > index 2cb55a97598c..d71dcef58a89 100644 > --- a/drivers/bluetooth/btintel.c > +++ b/drivers/bluetooth/btintel.c > @@ -209,27 +209,60 @@ void btintel_version_info(struct hci_dev *hdev, const struct btintel_version *ve > { > const char *variant; > const struct intel_version *ver; > + const struct intel_version_tlv *ver_tlv; > + > + if (!version->is_tlv_supported) { > + ver = &version->intel_version; > + > + switch (ver->fw_variant) { > + case 0x06: > + variant = "Bootloader"; > + break; > + case 0x23: > + variant = "Firmware"; > + break; > + default: > + goto done; > + } > > - if (version->is_tlv_supported) > - return; > + bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u", > + variant, ver->fw_revision >> 4, > + ver->fw_revision & 0x0f, ver->fw_build_num, > + ver->fw_build_ww, 2000 + ver->fw_build_yy); > + goto done; > + } > > - ver = &version->intel_version; > + ver_tlv = &version->intel_version_tlv; > > - switch (ver->fw_variant) { > - case 0x06: > + switch (ver_tlv->img_type) { > + case 0x01: > variant = "Bootloader"; > + bt_dev_info(hdev, "Device revision is %u", ver_tlv->dev_rev_id); > + bt_dev_info(hdev, "Secure boot is %s", > + ver_tlv->secure_boot ? "enabled" : "disabled"); > + bt_dev_info(hdev, "OTP lock is %s", > + ver_tlv->otp_lock ? "enabled" : "disabled"); > + bt_dev_info(hdev, "API lock is %s", > + ver_tlv->api_lock ? "enabled" : "disabled"); > + bt_dev_info(hdev, "Debug lock is %s", > + ver_tlv->debug_lock ? "enabled" : "disabled"); > + bt_dev_info(hdev, "Minimum firmware build %u week %u %u", > + ver_tlv->min_fw_build_nn, ver_tlv->min_fw_build_cw, > + 2000 + ver_tlv->min_fw_build_yy); > break; since we have everything stored in two independent data structures now, I have the feeling it is best to actually re-arrange the code around so that we gather all information we need. And once we are done, we handle the required print outs and logic in a common place. Duplicating these print outs now is not going to help since it creates hard to read code and if we have bugs we have to fix them in two places now. > - case 0x23: > + case 0x03: > variant = "Firmware"; > break; > default: > - return; > + goto done; > } > > - bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u", > - variant, ver->fw_revision >> 4, ver->fw_revision & 0x0f, > - ver->fw_build_num, ver->fw_build_ww, > - 2000 + ver->fw_build_yy); > + bt_dev_info(hdev, "%s timestamp %u.%u buildtype %u build %u", variant, > + 2000 + (ver_tlv->timestamp >> 8), ver_tlv->timestamp & 0xff, > + ver_tlv->build_type, ver_tlv->build_num); > + > +done: > + return; > } > EXPORT_SYMBOL_GPL(btintel_version_info); > > @@ -346,6 +379,8 @@ int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version) > { > struct sk_buff *skb; > u8 *data, param, status, check_tlv; > + struct intel_version_tlv *ver_tlv; > + struct intel_tlv *tlv; > > if (!version) > return -EINVAL; > @@ -373,9 +408,92 @@ int btintel_read_version(struct hci_dev *hdev, struct btintel_version *version) > if (skb->len == sizeof(version->intel_version) && check_tlv == 0x37) { > memcpy(&version->intel_version, skb->data, sizeof(version->intel_version)); > version->is_tlv_supported = false; > - } else { > - version->is_tlv_supported = true; > + goto done; > } > + > + bt_dev_info(hdev, "Supports tlv firmware download sequence"); > + version->is_tlv_supported = true; > + ver_tlv = &version->intel_version_tlv; > + > + /* Consume Command Complete Status field */ > + skb_pull(skb, 1); > + > + /* Event parameters contatin multiple TLVs. Read each of them > + * and only keep the required data. Also, it use existing legacy > + * version field like hw_platform, hw_variant, and fw_variant > + * to keep the existing setup flow > + */ > + while (skb->len) { Keep the scope of variables as local as possible. struct intel_tlv *tlv > + tlv = (struct intel_tlv *)skb->data; > + switch (tlv->type) { > + case INTEL_TLV_CNVI_TOP: > + ver_tlv->cnvi_top = get_unaligned_le32(tlv->val); > + break; > + case INTEL_TLV_CNVR_TOP: > + ver_tlv->cnvr_top = get_unaligned_le32(tlv->val); > + break; > + case INTEL_TLV_CNVI_BT: > + ver_tlv->cnvi_bt = get_unaligned_le32(tlv->val); > + break; > + case INTEL_TLV_CNVR_BT: > + ver_tlv->cnvr_bt = get_unaligned_le32(tlv->val); > + break; > + case INTEL_TLV_USB_VENDOR_ID: > + ver_tlv->usb_vid = get_unaligned_le16(tlv->val); > + break; > + case INTEL_TLV_USB_PRODUCT_ID: > + ver_tlv->usb_pid = get_unaligned_le16(tlv->val); > + break; > + case INTEL_TLV_IMAGE_TYPE: > + ver_tlv->img_type = tlv->val[0]; > + break; > + case INTEL_TLV_TIME_STAMP: > + ver_tlv->timestamp = get_unaligned_le16(tlv->val); > + break; > + case INTEL_TLV_BUILD_TYPE: > + ver_tlv->build_type = tlv->val[0]; > + break; > + case INTEL_TLV_BUILD_NUM: > + ver_tlv->build_num = get_unaligned_le32(tlv->val); > + break; > + case INTEL_TLV_SECURE_BOOT: > + ver_tlv->secure_boot = tlv->val[0]; > + break; > + case INTEL_TLV_KEY_FROM_HDR: > + ver_tlv->key_from_hdr = tlv->val[0]; > + break; > + case INTEL_TLV_OTP_LOCK: > + ver_tlv->otp_lock = tlv->val[0]; > + break; > + case INTEL_TLV_API_LOCK: > + ver_tlv->api_lock = tlv->val[0]; > + break; > + case INTEL_TLV_DEBUG_LOCK: > + ver_tlv->debug_lock = tlv->val[0]; > + break; > + case INTEL_TLV_MIN_FW: > + ver_tlv->min_fw_build_nn = tlv->val[0]; > + ver_tlv->min_fw_build_cw = tlv->val[1]; > + ver_tlv->min_fw_build_yy = tlv->val[2]; > + break; > + case INTEL_TLV_LIMITED_CCE: > + ver_tlv->limited_cce = tlv->val[0]; > + break; > + case INTEL_TLV_SBE_TYPE: > + ver_tlv->sbe_type = tlv->val[0]; > + break; > + case INTEL_TLV_OTP_BDADDR: > + memcpy(&ver_tlv->otp_bd_addr, tlv->val, tlv->len); > + break; > + default: > + /* Ignore rest of information */ > + break; > + } > + /* consume the current tlv and move to next*/ > + skb_pull(skb, tlv->len + sizeof(*tlv)); > + } > + > +done: > kfree_skb(skb); > return 0; > } > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index d06c946f7810..39f0e4522b06 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -2519,13 +2519,13 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) > return err; > } > > + btintel_version_info(hdev, &version); > + > if (version.is_tlv_supported) { > bt_dev_err(hdev, "Firmware download in tlv format is not supported"); > return -EOPNOTSUPP; > } > > - btintel_version_info(hdev, &version); > - > err = btusb_intel_download_firmware(hdev, &version, ¶ms); > if (err) > return err; Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oIQGG8bADF94IQAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 22:15:02 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gCkpGcbADF9OCgEADc0bRg (envelope-from ); Mon, 13 Jul 2020 22:15:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 32DA8A3147; Mon, 13 Jul 2020 22:14:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726400AbgGMUO4 (ORCPT + 1 other); Mon, 13 Jul 2020 16:14:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgGMUO4 (ORCPT ); Mon, 13 Jul 2020 16:14:56 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDB9DC061755 for ; Mon, 13 Jul 2020 13:14:55 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id cm21so424967pjb.3 for ; Mon, 13 Jul 2020 13:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0IW9qTSFXBwOuk1yrc6ynqLxslXbEquo65j1s7zEORQ=; b=d1Tad3VsvL+6WdpMhxDQv0AMjB5f/1N64Smmm0HX9k4VhGFykZAsnC9u0wZ5V1k8mB VvWV9xL/SS6EaSmu7jjP2+6Rcedd/xU2DazKTGlTe7+DOnuGkt6gvACINTgkC/IL6cXk E1vR9X3TohSqwYi1HfTkjg8PJIHYvDECsvHU0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0IW9qTSFXBwOuk1yrc6ynqLxslXbEquo65j1s7zEORQ=; b=VPZB2HDndKHAlJvlqAwsz4x4nVlsuRdiAlmR8XCWKk6/F5eOd8oQ0oiiWmxVic//v9 eivnnik5WUQ0MH7ILEXdzHgB0g7+38cnSyOXQEBwbhzfdWp5HOvifasJAmz5+63r6qmk t49jubzYpx88DD47e+ZSXEmHheaaPdMSsapYmTjo4eBbcdjtv30vQKoTPS3Ox4n8lm1j gvmePLZo6SGIKWBcgIWwo/hOGE8DRyyEHCyONxy3aaBLM9IXdmA5ycd2pEeA4HIRQiSy A+/n5o/EVkWFZOrrx5/osv47ZpijnQZB6UbZ9w+0XnE3O113m/dY7ZYszZE/vmlzNi1t OLhA== X-Gm-Message-State: AOAM530bqAdlxZAt0VT3WJecBm9jEzsEJ8yXpLPcUisYqoYkkXqsTBAj rJDQqnyKiw8oDCvpGf8O25zV3w== X-Google-Smtp-Source: ABdhPJxouI32B0DgPRih9vRINyL7FATmu49ZTjYgBEWEpG3PSqaUeNQhkXf4AsyNLA1BbBYTLfHzDg== X-Received: by 2002:a17:90a:db48:: with SMTP id u8mr975363pjx.169.1594671295378; Mon, 13 Jul 2020 13:14:55 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id h18sm7866135pfr.186.2020.07.13.13.14.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jul 2020 13:14:54 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth-@vger.kernel.org, linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka Subject: [PATCH BlueZ 0/3] Per-device option to enable/disable internal profiles Date: Mon, 13 Jul 2020 13:14:38 -0700 Message-Id: <20200713201441.235959-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 25 X-Rspamd-Score: 3.90 / 15.00 / 200.00 X-Rspamd-Queue-Id: 32DA8A3147 X-Rspamd-UID: 93291c This patch series adds a mechanism for clients to choose whether to enable BlueZ internal profiles (e.g. A2DP, Battery) for specific devices. The motivation behind this feature is that some applications (e.g. Web Bluetooth or Android apps) need to have control over all remove GATT services, like Battery service. With "battery" plugin being enabled on BlueZ, it becomes not possible for those apps to work properly because BlueZ "hides" the Battery-related attributes from its GATT Client API. Disabling the "battery" plugin won't solve the problem either, since we do also need to enable the plugin so that we can use org.bluez.Battery1 API. The solution that we propose is that clients can choose whether to enable internal profiles for each device. Clients know when to enable internal profiles (such as when a user chooses to pair/connect via a UI) and when to disable internal profiles (such as when the connection is initiated by a generic application). Sonny Sasaka (3): doc: Add "AllowInternalProfiles" property to org.bluez.Device1 device: Add "AllowInternalProfiles" property to org.bluez.Device1 client: Add set-allow-internal-profiles command client/main.c | 38 ++++++++++++++++++ doc/device-api.txt | 13 +++++++ src/device.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ src/hcid.h | 2 + src/main.c | 10 +++++ src/main.conf | 4 ++ 6 files changed, 163 insertions(+) -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yB2fL8zADF94IQAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 22:15:08 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8K7sLczADF/Z1AEAgupzMw (envelope-from ); Mon, 13 Jul 2020 22:15:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7D3F3A3740; Mon, 13 Jul 2020 22:15:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbgGMUPD (ORCPT + 1 other); Mon, 13 Jul 2020 16:15:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgGMUPC (ORCPT ); Mon, 13 Jul 2020 16:15:02 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3558C061755 for ; Mon, 13 Jul 2020 13:15:02 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id x9so6011016plr.2 for ; Mon, 13 Jul 2020 13:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zPLCESdS/Ve1h9h7+XMTn1nlcKJ28YFSVJfO0CW+h5Q=; b=eRfNJtywXo3LygM13DluPcmtp1uxJcCcbYpA/gcHHRI5glgbWwyrx+NWBYH/rJpA9y 7FxcYqbcwMLdYmGqly6KSs4Pf/CyU5c79QNQovyIT8BdT5DTxQ/WjAL5ipZ5Ns/ROKYj dmCfo9/h+AIcfu/x6tozDcUb6v4cGQfpIm7DY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zPLCESdS/Ve1h9h7+XMTn1nlcKJ28YFSVJfO0CW+h5Q=; b=cg3C4xfO4ZyV6zAcNarJJZti79JYizQa8Bsx/fClgm8QHjYB86pPAiIs+ObhsvNuBq AKMH/oe46v5Ndl3xDk5eos36j/Ua0YNkO8slezhiA7/gTdk5TFmsR2nBWv3slld1Ahq5 q0jr76swDZsJArPiZneYQD/novLCqdR7rHaC0uMtTdOCPBs3u1eTx0sfB9w9ye2nM+1e wh27lLpLtjPLyRJdkA/8jjQqMXcdUaWEBz0w22amniN3kEeUC4q60CfR8JUHrq6Q1TTV SlH2/FoAj4cfHi4r+G4Ebk2tD2GWpNhgs38D8tJmT8e0zbc5zy103ooUWkiErSMzILqX AXWA== X-Gm-Message-State: AOAM532IUW9cMdYwVGYeufs7p2xmkwbP53qxIcs/sVJGffymwY0I/Lwr RfgvGEr/HpOUMBQ0rgjTXJdXfQ== X-Google-Smtp-Source: ABdhPJx90lgXLXGMBM07VI7NfT+wBeZIIGLGjq10C5JzG2M/Udv0vGnBiPKT4cV4dBGJRVRhivlX6w== X-Received: by 2002:a17:90a:6948:: with SMTP id j8mr984297pjm.45.1594671302200; Mon, 13 Jul 2020 13:15:02 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id h18sm7866135pfr.186.2020.07.13.13.15.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jul 2020 13:15:01 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth-@vger.kernel.org, linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka , Alain Michaud Subject: [PATCH BlueZ 1/3] doc: Add "AllowInternalProfiles" property to org.bluez.Device1 Date: Mon, 13 Jul 2020 13:14:39 -0700 Message-Id: <20200713201441.235959-2-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200713201441.235959-1-sonnysasaka@chromium.org> References: <20200713201441.235959-1-sonnysasaka@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 24 X-Rspamd-Score: 3.63 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7D3F3A3740 X-Rspamd-UID: ed5525 Reviewed-by: Alain Michaud --- doc/device-api.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/device-api.txt b/doc/device-api.txt index 4e824d2de..5c2b2b26b 100644 --- a/doc/device-api.txt +++ b/doc/device-api.txt @@ -189,6 +189,19 @@ Properties string Address [readonly] drivers will also be removed and no new ones will be probed as long as the device is blocked. + boolean AllowInternalProfiles [readwrite] + + If set to true, connection to this device will activate + BlueZ internal profiles (e.g. A2DP, HOG, Battery). + If set to false, internal profiles will not be activated + allowing the client to handle profiles which would + otherwise be controlled by internal handlers. + The default is configurable in main.conf. + + Write operation to this property can only be accepted + when the device is not connected, otherwise + org.bluez.Error.Failed is returned. + boolean WakeAllowed [readwrite] If set to true this device will be allowed to wake the -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eBq8EKLFDF+FMgAAvsO+Rg (envelope-from ) for ; Mon, 13 Jul 2020 22:35:46 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UG8xD6LFDF+JGgEAlp8NpQ (envelope-from ); Mon, 13 Jul 2020 22:35:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E637C526D3; Mon, 13 Jul 2020 22:35:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726545AbgGMUfj (ORCPT + 1 other); Mon, 13 Jul 2020 16:35:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbgGMUfj (ORCPT ); Mon, 13 Jul 2020 16:35:39 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CC44C061755; Mon, 13 Jul 2020 13:35:39 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id h1so10583113otq.12; Mon, 13 Jul 2020 13:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nMz/znSoLz9ThqeCcpe4Ta7Jp3PPK8McYiisRlujivo=; b=hStsKtHDhzby1OziHm2z4ZQk+Kkfk9/Mcn796MrAlo/9drWdmxlAcPuTuicZD1grg8 gOUvemNn47pIFrqgyvq5RftLnHBTSYynDPES9gZSuekAexiFT9dShOwrZRuuhCsjdIqh ES7X8I3oQSjgC+hvYTE3PDBnuUSgpuzKNC8phve2H4f08dQFHIj3hqlFBB6+2e9U+RHa 8VhPOTCx0CBu1BhdtKziMQKKtcAVkMbsAVh3yBQsMHplFKxpnR0/w0t4VXU7HeH1n8fD Tlm1bW3dEU6cd7uCSqivbZGo3Nu/+d7fPAQATByu5Q5b5yNzHn1idjFVx5fSTz38CQVh xLLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nMz/znSoLz9ThqeCcpe4Ta7Jp3PPK8McYiisRlujivo=; b=lfDsDclCMtmmyowBjBM+YtoAWVCrWeOKIrxZD9k6a3wYTzapPhbS9mZ4U6MAY64sr0 5W29LMVglOwAqob1TYXqUtu3eTkxtzSWlxdH2x4bfPY9aGqsFBe6goB7XQU2viFcYkPS r1bXzcIWwtZwzIm5rA+/NqVbqUiiHf0RdHPCsgYjsxbP4zEXDt+bhh2qTl1s/v6/lAFa Zdjs7YNrR6CoiL4BPkrJNIRwjPw1dROIblwKRaIXahqKUIjAbvnGcq+F8qqAhXslhRBc 9YwUhENO0Y6F8ncg8GxIb7gtBooDc0CNKDvtloz6LWnQft1jy0dS7CodmMdbdMN8O3BH S0Ag== X-Gm-Message-State: AOAM533Lohmq9+kch1vq7HCtU4bNME7Y0MaU9h7jeGmRY8zqp6CpzzZe uwr4Z1PRvNVip0HCrXnQk+gJyxrfJ737BKxp2iE= X-Google-Smtp-Source: ABdhPJxAwXcETK2JBSmwcyZs2GuvhTSgKHjPRSVCcrg3mbOwWp1QuZ+rnU6DBdJFuhfZkIsMgRa2b/NB+zG/bhT6xxM= X-Received: by 2002:a05:6830:1bd3:: with SMTP id v19mr1233271ota.91.1594672538465; Mon, 13 Jul 2020 13:35:38 -0700 (PDT) MIME-Version: 1.0 References: <20200713201441.235959-1-sonnysasaka@chromium.org> In-Reply-To: <20200713201441.235959-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz Date: Mon, 13 Jul 2020 13:35:26 -0700 Message-ID: Subject: Re: [PATCH BlueZ 0/3] Per-device option to enable/disable internal profiles To: Sonny Sasaka Cc: linux-bluetooth-@vger.kernel.org, "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: E637C526D3 X-Rspamd-UID: 62a791 Hi Sonny, On Mon, Jul 13, 2020 at 1:18 PM Sonny Sasaka wrote: > > This patch series adds a mechanism for clients to choose whether to > enable BlueZ internal profiles (e.g. A2DP, Battery) for specific > devices. > > The motivation behind this feature is that some applications (e.g. Web > Bluetooth or Android apps) need to have control over all remove GATT > services, like Battery service. With "battery" plugin being enabled on > BlueZ, it becomes not possible for those apps to work properly because > BlueZ "hides" the Battery-related attributes from its GATT Client API. > Disabling the "battery" plugin won't solve the problem either, since we > do also need to enable the plugin so that we can use org.bluez.Battery1 > API. > > The solution that we propose is that clients can choose whether to > enable internal profiles for each device. Clients know when to enable > internal profiles (such as when a user chooses to pair/connect via a UI) > and when to disable internal profiles (such as when the connection is > initiated by a generic application). I wonder if it is not better to just have a flag indicating if the profile shall claim exclusive access (such as GAP and GATT services), so profiles that don't set that will have the services exposed so for battery we can probably just have it exposed by default since it doesn't appear to would be any conflicts on having it exposed. > Sonny Sasaka (3): > doc: Add "AllowInternalProfiles" property to org.bluez.Device1 > device: Add "AllowInternalProfiles" property to org.bluez.Device1 > client: Add set-allow-internal-profiles command > > client/main.c | 38 ++++++++++++++++++ > doc/device-api.txt | 13 +++++++ > src/device.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ > src/hcid.h | 2 + > src/main.c | 10 +++++ > src/main.conf | 4 ++ > 6 files changed, 163 insertions(+) > > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4GVdKozaDF+PkAAAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 00:05:00 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eLCQKIzaDF/bZQEAlp8NpQ (envelope-from ); Tue, 14 Jul 2020 00:05:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1E27EA5563; Tue, 14 Jul 2020 00:04:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726848AbgGMWEy (ORCPT + 1 other); Mon, 13 Jul 2020 18:04:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbgGMWEy (ORCPT ); Mon, 13 Jul 2020 18:04:54 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 552DFC061755 for ; Mon, 13 Jul 2020 15:04:54 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id w17so12307934oie.6 for ; Mon, 13 Jul 2020 15:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5oJFjl1usC9P8/dSSr34ahD/dcsG5PpeYskUUSdD9h0=; b=P9jIHHWQ3vUydM5wqFS7vJq3aTdZZdngSLodIE/tVCgzN6Ozroj8QUrwv62Bi9VmOa JaYT2G2HiOTtDZuZfDNZm3jVgDN2OHmeGlAnDTJft7gl8aPpuUzY2e5lTeXaPAJHtBMs ZgzsEcTALdaDDh/4FvReUR+zCdGPYWZnk4RFM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5oJFjl1usC9P8/dSSr34ahD/dcsG5PpeYskUUSdD9h0=; b=qQ7iGUas23Ew36GTVE7CSiBihCphnQthGrPhOBHfy3z2YrWgyk82o3U4tT9bCPFOKa /S5NxH7YIMYn98WFf9bTRpLB6VkJsAb4odl5SD9FyBK/DklxDl4hc1ZxMSxfiQOr0DFW HIQbK+7Cb58fzpZw+MWjaBGSZtgHKcLgX2r4Hg4Jtb1OXpgIMQmQgwQc0XTFU/WS4+ss 8iA0WjCY16YdrfbZnRK3bUVR4zN5gBCQjxqscS2An1DhwkzHOGuMVw5CHkph9kMIyNpn 9Gg8BhAMdI1JFWUns53H33pJ+ezrqqZlhKA0i3veWaAS5/wIHJGLNsDgqK9rSqepm1hx 1Meg== X-Gm-Message-State: AOAM530IwNXue3quCC5rtq7VgERf1zpRTllQ5n9kWcuzYZgYdOi73TDc YmqluPngjp4Sh6+6THPnbMDiB/x8/cnfLnIE4tjFtA== X-Google-Smtp-Source: ABdhPJzWS5tpHg22wJ+rmEqoqeyw5CerJrE59FWAl4xPvFNI6XxP5gInnQ6KdGb626qKL461UWmRuGEbh3RweEP7ReU= X-Received: by 2002:aca:c157:: with SMTP id r84mr1321069oif.136.1594677893693; Mon, 13 Jul 2020 15:04:53 -0700 (PDT) MIME-Version: 1.0 References: <20200713201441.235959-1-sonnysasaka@chromium.org> In-Reply-To: From: Sonny Sasaka Date: Mon, 13 Jul 2020 15:04:41 -0700 Message-ID: Subject: Re: [PATCH BlueZ 0/3] Per-device option to enable/disable internal profiles To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1E27EA5563 X-Rspamd-UID: 1fca52 Hi Luiz, I considered having such an approach that gives exception to some profile to not claim exclusive access. However, I think that this approach has a drawback that it can only be guaranteed to work correctly for profiles that contain only read-only attributes. Any profile that contains writable attributes, naturally, cannot be guaranteed to always work correctly (as is the case with the Battery profile). Therefore, the usefulness of that feature will be very limited. I also considered the benefits of the AllowInternalProfiles approach: * Applications can also have control over any profile, not just Battery profile. For example, if in the future BlueZ has more internal profiles, like (Blood Pressure Profile or any other profile that may contain writable attributes), we can guarantee that applications can still opt to have access to that profile, without relying on a profile being "safe" to be shared by both BlueZ's internal and external handlers. * This has an added security benefit: applications which operate on a specific GATT profile will not unintentionally activate internal profiles such as HOG (which is able to hijack input control of the host). This is the correct and expected behavior of Android apps that connect over GATT and get access to a GATT profile. Therefore I think that this approach, although more complex, has longer lasting benefits. Let me know if you have any objection to having such a feature. On Mon, Jul 13, 2020 at 1:35 PM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Mon, Jul 13, 2020 at 1:18 PM Sonny Sasaka wrote: > > > > This patch series adds a mechanism for clients to choose whether to > > enable BlueZ internal profiles (e.g. A2DP, Battery) for specific > > devices. > > > > The motivation behind this feature is that some applications (e.g. Web > > Bluetooth or Android apps) need to have control over all remove GATT > > services, like Battery service. With "battery" plugin being enabled on > > BlueZ, it becomes not possible for those apps to work properly because > > BlueZ "hides" the Battery-related attributes from its GATT Client API. > > Disabling the "battery" plugin won't solve the problem either, since we > > do also need to enable the plugin so that we can use org.bluez.Battery1 > > API. > > > > The solution that we propose is that clients can choose whether to > > enable internal profiles for each device. Clients know when to enable > > internal profiles (such as when a user chooses to pair/connect via a UI) > > and when to disable internal profiles (such as when the connection is > > initiated by a generic application). > > I wonder if it is not better to just have a flag indicating if the > profile shall claim exclusive access (such as GAP and GATT services), > so profiles that don't set that will have the services exposed so for > battery we can probably just have it exposed by default since it > doesn't appear to would be any conflicts on having it exposed. > > > Sonny Sasaka (3): > > doc: Add "AllowInternalProfiles" property to org.bluez.Device1 > > device: Add "AllowInternalProfiles" property to org.bluez.Device1 > > client: Add set-allow-internal-profiles command > > > > client/main.c | 38 ++++++++++++++++++ > > doc/device-api.txt | 13 +++++++ > > src/device.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ > > src/hcid.h | 2 + > > src/main.c | 10 +++++ > > src/main.conf | 4 ++ > > 6 files changed, 163 insertions(+) > > > > -- > > 2.26.2 > > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id /+hBEFTnDF9U0wAAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 00:59:32 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2CD0DVTnDF8QRgAAgupzMw (envelope-from ); Tue, 14 Jul 2020 00:59:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 15E955308B; Tue, 14 Jul 2020 00:59:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726670AbgGMW7Z (ORCPT + 1 other); Mon, 13 Jul 2020 18:59:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726505AbgGMW7Z (ORCPT ); Mon, 13 Jul 2020 18:59:25 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CBBBC061755 for ; Mon, 13 Jul 2020 15:59:25 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id j11so12379740oiw.12 for ; Mon, 13 Jul 2020 15:59:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3uWX86usec4UElqr/Gt1rS+RH2x17bKUqzxnoEy9810=; b=Uc/0mwbxKFJRKqDQKKzlT18vH/QkmehQ0aq1GPPd/2y+X8uA5MHA9tOTdNhgR5EXkO QhljYqOfKnHospjJ1stgLGo9McDr7I0jUMK/blPmwhgWUVYB/Bw9zW5UOSs0lOiCYVbs Kv8eTncXVOwHSkvsCfx9YDdrdXrX7wq5AaiDhtDNmBXrZNMjMMltpTn8mUQhstwdIlXs +vE8ciLTfi8R7qIZ6Uww4cjjZCwkWqigzIGXi27ZL8Mf1qTF/FSBvC7Kfyl7c/go1AVo e3aS5iwsVpdiVGfklQNTzbcaCsF2RHtx1CB1URvfJzpgs18isKJbCq5O6zHkZ0IopTTH 2arw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3uWX86usec4UElqr/Gt1rS+RH2x17bKUqzxnoEy9810=; b=AdJkX+o5lfu148T8Wotu1Ak1aiX55Jydjk3gbc1yk1HTzh8qJ+JQ73OUC/XST52DcZ Ik7l6lOSFN0aQ1zzu3YXdRspzQEBdLDqUfqpQ8rpqgfQ2V1zpbfnvNrM9ajtBgvjsLMx /iQQvEXn067E8MCxadxePECWGAWDwRBRXuy8JfHaWRliwc6Gvg6UUN7OGCLPVu+8wilZ UY68k3fVAVTsKM/AfmTAFXO8PNLEwrAGPW75mqDLSAt5VF6FNN8vf50pNnSfaPM1g78L PKzyPG5K95q4zE6k8f4uF/KfT555+83HlL+LjJKU3FQzFWsg+HL7nwpHqyesWIKLM4Gs M5Mg== X-Gm-Message-State: AOAM532hS2rq+406e9QDUSAhv4gkhxu3oanZ26Yd2hdB2KI9AxLraJ7i A1azRohpfWNg9BG0on+3MI4aqiTxXGPsXouMMcS46F8LuoY= X-Google-Smtp-Source: ABdhPJwU7z3rVj+MOtGXJXfC0cY81H2H92eRzFjLauVHiiuiq8w4Le104CdUhXV4vGXudNWue7CgN8Kxbk1q/lzr5Xk= X-Received: by 2002:aca:cf81:: with SMTP id f123mr1472803oig.137.1594681163923; Mon, 13 Jul 2020 15:59:23 -0700 (PDT) MIME-Version: 1.0 References: <20200713201441.235959-1-sonnysasaka@chromium.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Mon, 13 Jul 2020 15:59:12 -0700 Message-ID: Subject: Re: [PATCH BlueZ 0/3] Per-device option to enable/disable internal profiles To: Sonny Sasaka Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 15E955308B X-Rspamd-UID: 151f24 Hi Sonny, On Mon, Jul 13, 2020 at 3:04 PM Sonny Sasaka wrote: > > Hi Luiz, > > I considered having such an approach that gives exception to some > profile to not claim exclusive access. However, I think that this > approach has a drawback that it can only be guaranteed to work > correctly for profiles that contain only read-only attributes. Any > profile that contains writable attributes, naturally, cannot be > guaranteed to always work correctly (as is the case with the Battery > profile). Therefore, the usefulness of that feature will be very > limited. > > I also considered the benefits of the AllowInternalProfiles approach: > * Applications can also have control over any profile, not just > Battery profile. For example, if in the future BlueZ has more internal > profiles, like (Blood Pressure Profile or any other profile that may > contain writable attributes), we can guarantee that applications can > still opt to have access to that profile, without relying on a profile > being "safe" to be shared by both BlueZ's internal and external > handlers. > * This has an added security benefit: applications which operate on a > specific GATT profile will not unintentionally activate internal > profiles such as HOG (which is able to hijack input control of the > host). This is the correct and expected behavior of Android apps that > connect over GATT and get access to a GATT profile. Not sure I follow these arguments, it seems AllowInternalProfiles may actually enable hijacking the profiles so I wonder if you got this backwards as we can't let things like HoG be controlled by applications directly it would be too easy to implement something like a keylogger, or perhaps you are suggesting that there is another layer for implementing the profiles? Note that it is intended that plugins shall be used for profiles that need to be integrated system wide, D-Bus interface shall be restricted to only application specific profiles. Note that we do allow external profiles to be registered with use of: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/profile-api.txt And for GATT: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt#n366 We could perhaps make the assumption that once an application registers itself as supporting a given profile we check if against a blacklist of profiles that may have security implications, which perhaps could be defined via main.conf or some other file, if that is not the case the internal profile can be disabled and the D-Bus object would be accessible over D-Bus. Also note that we do offer clients the ability to have exclusive access with AcquireWrite and AcquireNotify. > Therefore I think that this approach, although more complex, has > longer lasting benefits. Let me know if you have any objection to > having such a feature. > > > On Mon, Jul 13, 2020 at 1:35 PM Luiz Augusto von Dentz > wrote: > > > > Hi Sonny, > > > > On Mon, Jul 13, 2020 at 1:18 PM Sonny Sasaka wrote: > > > > > > This patch series adds a mechanism for clients to choose whether to > > > enable BlueZ internal profiles (e.g. A2DP, Battery) for specific > > > devices. > > > > > > The motivation behind this feature is that some applications (e.g. Web > > > Bluetooth or Android apps) need to have control over all remove GATT > > > services, like Battery service. With "battery" plugin being enabled on > > > BlueZ, it becomes not possible for those apps to work properly because > > > BlueZ "hides" the Battery-related attributes from its GATT Client API. > > > Disabling the "battery" plugin won't solve the problem either, since we > > > do also need to enable the plugin so that we can use org.bluez.Battery1 > > > API. > > > > > > The solution that we propose is that clients can choose whether to > > > enable internal profiles for each device. Clients know when to enable > > > internal profiles (such as when a user chooses to pair/connect via a UI) > > > and when to disable internal profiles (such as when the connection is > > > initiated by a generic application). > > > > I wonder if it is not better to just have a flag indicating if the > > profile shall claim exclusive access (such as GAP and GATT services), > > so profiles that don't set that will have the services exposed so for > > battery we can probably just have it exposed by default since it > > doesn't appear to would be any conflicts on having it exposed. > > > > > Sonny Sasaka (3): > > > doc: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > device: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > client: Add set-allow-internal-profiles command > > > > > > client/main.c | 38 ++++++++++++++++++ > > > doc/device-api.txt | 13 +++++++ > > > src/device.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ > > > src/hcid.h | 2 + > > > src/main.c | 10 +++++ > > > src/main.conf | 4 ++ > > > 6 files changed, 163 insertions(+) > > > > > > -- > > > 2.26.2 > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GPWjEsDoDF8W3gAAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 01:05:36 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id uKLpEMDoDF94RQAAgupzMw (envelope-from ); Tue, 14 Jul 2020 01:05:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0C873530F5; Tue, 14 Jul 2020 01:05:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726748AbgGMXFa (ORCPT + 1 other); Mon, 13 Jul 2020 19:05:30 -0400 Received: from mga06.intel.com ([134.134.136.31]:39333 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726352AbgGMXFa (ORCPT ); Mon, 13 Jul 2020 19:05:30 -0400 IronPort-SDR: 62StNtStyf++ANDxVtnwWrAAV52EPDMHGqC/bBDWvh/rMEDESreFNEeaCXvR+hrNa0AE4uhTRL RtQgVQhMYPSA== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="210285807" X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="210285807" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2020 16:05:29 -0700 IronPort-SDR: 3VsUlibAzn2f3pvQ3VSnU/R7Rj+oUZgMHMgwZMLtTALiDpT4fQnyKmjoW970fzGlpAh1kjzlkX o3gUhmXBxjQw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="459465770" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.112.118]) by orsmga005.jf.intel.com with ESMTP; 13 Jul 2020 16:05:29 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 0/3] Code re-org and clean up Date: Mon, 13 Jul 2020 16:05:25 -0700 Message-Id: <20200713230528.107948-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0C873530F5 X-Rspamd-UID: ea6ce7 This patch set is part of the on-going clean up effort that targets some of more convoluted areas of meshd source code. The patchset provides better functional separation, smaller function granularity and better memory handling. Inga Stotland (3): mesh: Use static array to hold config server response mesh: Add size checks for every opcode in config server mesh: move model functionality out of node.c to model.c mesh/cfgmod-server.c | 99 ++++++----- mesh/cfgmod.h | 4 +- mesh/mesh-config-json.c | 5 +- mesh/model.c | 359 +++++++++++++++++++++++++++++++++------- mesh/model.h | 32 ++-- mesh/node.c | 286 ++++---------------------------- 6 files changed, 403 insertions(+), 382 deletions(-) -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6BG6LcXoDF8k5gAAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 01:05:41 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id GN0LLMXoDF8QRgAAgupzMw (envelope-from ); Tue, 14 Jul 2020 01:05:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 69303526D3; Tue, 14 Jul 2020 01:05:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726755AbgGMXFb (ORCPT + 1 other); Mon, 13 Jul 2020 19:05:31 -0400 Received: from mga06.intel.com ([134.134.136.31]:39333 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726734AbgGMXFa (ORCPT ); Mon, 13 Jul 2020 19:05:30 -0400 IronPort-SDR: EXHd1WoYKZiJkWy2vYXCtQI2crNu+ZdqGHOGo3rO2o7IPhAp+NH7ZMUx+9dQ9IeuWwdN2hlZLt Cn7y7IaJVTkw== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="210285811" X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="210285811" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2020 16:05:30 -0700 IronPort-SDR: 268xJKY2evXU6iepcid2z6Syo/nJBmKynY+JgsV4egcNvXRlmP/Qa+AF4sJIoe6dlXEh0k77Qt yuNrAypC30wA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="459465780" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.112.118]) by orsmga005.jf.intel.com with ESMTP; 13 Jul 2020 16:05:30 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 1/3] mesh: Use static array to hold config server response Date: Mon, 13 Jul 2020 16:05:26 -0700 Message-Id: <20200713230528.107948-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200713230528.107948-1-inga.stotland@intel.com> References: <20200713230528.107948-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 28 X-Rspamd-Score: 4.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: 69303526D3 X-Rspamd-UID: 867277 This eliminates dynamic allocation for long responses and local arrays for short responses. Instead, aclear text response from config server is written into a static buffer and then encoded into dynamically allocated messafe buffer to use in actual transmission. --- mesh/cfgmod-server.c | 53 +++++++++++++------------------------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 14b4a980e..08a74d014 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -32,21 +32,20 @@ #include "mesh/mesh-config.h" #include "mesh/cfgmod.h" -#define CFG_MAX_MSG_LEN 380 - /* Supported composition pages, sorted high to low */ /* Only page 0 is currently supported */ static const uint8_t supported_pages[] = { 0 }; +static uint8_t msg[MAX_MSG_LEN]; + static void send_pub_status(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t status, uint16_t ele_addr, uint32_t mod_id, uint16_t pub_addr, uint16_t idx, bool cred_flag, uint8_t ttl, uint8_t period, uint8_t retransmit) { - uint8_t msg[16]; size_t n; n = mesh_model_opcode_set(OP_CONFIG_MODEL_PUB_STATUS, msg); @@ -193,7 +192,6 @@ static void send_sub_status(struct mesh_node *node, uint16_t net_idx, uint8_t status, uint16_t ele_addr, uint16_t addr, uint32_t mod) { - uint8_t msg[12]; int n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); msg[n++] = status; @@ -224,7 +222,6 @@ static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, int status; uint8_t *msg_status; uint16_t buf_size; - uint8_t msg[5 + sizeof(uint16_t) * MAX_GRP_PER_MOD]; /* Incoming message has already been size-checked */ ele_addr = l_get_le16(pkt); @@ -430,7 +427,6 @@ static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, uint8_t status, uint16_t addr, uint32_t id, uint16_t idx) { - uint8_t msg[12]; size_t n = mesh_model_opcode_set(OP_MODEL_APP_STATUS, msg); msg[n++] = status; @@ -455,21 +451,14 @@ static void model_app_list(struct mesh_node *node, uint16_t net_idx, { uint16_t ele_addr; uint32_t mod_id = 0xffff; - uint8_t *msg = NULL; uint8_t *status; - uint16_t n, buf_size; + uint16_t n; int result; - buf_size = MAX_BINDINGS * sizeof(uint16_t); - msg = l_malloc(7 + buf_size); - if (!msg) - return; - ele_addr = l_get_le16(pkt); switch (size) { default: - l_free(msg); return; case 4: n = mesh_model_opcode_set(OP_MODEL_APP_LIST, msg); @@ -495,7 +484,7 @@ static void model_app_list(struct mesh_node *node, uint16_t net_idx, result = mesh_model_get_bindings(node, ele_addr, mod_id, msg + n, - buf_size, &size); + MAX_MSG_LEN - n, &size); n += size; if (result >= 0) { @@ -503,8 +492,6 @@ static void model_app_list(struct mesh_node *node, uint16_t net_idx, mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, false, msg, n); } - - l_free(msg); } static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, @@ -736,8 +723,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct timeval time_now; uint32_t opcode, tmp32; int b_res = MESH_STATUS_SUCCESS; - uint8_t msg[11]; - uint8_t *long_msg = NULL; struct mesh_net_heartbeat *hb; uint16_t n_idx, a_idx; uint8_t state, status; @@ -771,9 +756,8 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 1) return false; - long_msg = l_malloc(CFG_MAX_MSG_LEN); - n = mesh_model_opcode_set(OP_DEV_COMP_STATUS, long_msg); - n += get_composition(node, pkt[0], long_msg + n); + n = mesh_model_opcode_set(OP_DEV_COMP_STATUS, msg); + n += get_composition(node, pkt[0], msg + n); break; @@ -1040,14 +1024,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, n_idx = l_get_le16(pkt); - long_msg = l_malloc(CFG_MAX_MSG_LEN); - n = mesh_model_opcode_set(OP_APPKEY_LIST, long_msg); + n = mesh_model_opcode_set(OP_APPKEY_LIST, msg); - status = appkey_list(net, n_idx, long_msg + n + 3, - CFG_MAX_MSG_LEN - n - 3, &size); + status = appkey_list(net, n_idx, msg + n + 3, + MAX_MSG_LEN - n - 3, &size); - long_msg[n] = status; - l_put_le16(n_idx, long_msg + n + 1); + msg[n] = status; + l_put_le16(n_idx, msg + n + 1); n += (size + 3); break; @@ -1088,11 +1071,10 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_NETKEY_GET: - long_msg = l_malloc(CFG_MAX_MSG_LEN); - n = mesh_model_opcode_set(OP_NETKEY_LIST, long_msg); - size = CFG_MAX_MSG_LEN - n; + n = mesh_model_opcode_set(OP_NETKEY_LIST, msg); + size = MAX_MSG_LEN - n; - if (mesh_net_key_list_get(net, long_msg + n, &size)) + if (mesh_net_key_list_get(net, msg + n, &size)) n += size; else n = 0; @@ -1244,11 +1226,8 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, } if (n) - mesh_model_send(node, dst, src, - APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, false, - long_msg ? long_msg : msg, n); - - l_free(long_msg); + mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, + DEFAULT_TTL, false, msg, n); return true; } -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ANuuEcvoDF8k5gAAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 01:05:47 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id ULThD8voDF/EzAEAlScrYA (envelope-from ); Tue, 14 Jul 2020 01:05:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EE14753192; Tue, 14 Jul 2020 01:05:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbgGMXFc (ORCPT + 1 other); Mon, 13 Jul 2020 19:05:32 -0400 Received: from mga06.intel.com ([134.134.136.31]:39335 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726352AbgGMXFb (ORCPT ); Mon, 13 Jul 2020 19:05:31 -0400 IronPort-SDR: 4Q+q0twiCZfmSV/K2YvDX9WZp70E47yHDMDzvj84naVz5/UNbt2r74wx0GA3c93gOWDM+mhEkY GDfSaNbV6oeg== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="210285814" X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="210285814" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2020 16:05:31 -0700 IronPort-SDR: tMTv+b5dKee/Tq6WcIDvq5T1Uq7cxLU4/RIFuL+vXSFUhX4NCCdTbs4B6Cf4Co6ooEx4b38ljg BrytYOHcWpBg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="459465788" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.112.118]) by orsmga005.jf.intel.com with ESMTP; 13 Jul 2020 16:05:30 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 2/3] mesh: Add size checks for every opcode in config server Date: Mon, 13 Jul 2020 16:05:27 -0700 Message-Id: <20200713230528.107948-3-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200713230528.107948-1-inga.stotland@intel.com> References: <20200713230528.107948-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: EE14753192 X-Rspamd-UID: e58321 This adds missing size checks for the incoming config server messages. --- mesh/cfgmod-server.c | 46 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 08a74d014..9046a1ad9 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -754,7 +754,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_DEV_COMP_GET: if (size != 1) - return false; + return true; n = mesh_model_opcode_set(OP_DEV_COMP_STATUS, msg); n += get_composition(node, pkt[0], msg + n); @@ -770,6 +770,9 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall Through */ case OP_CONFIG_DEFAULT_TTL_GET: + if (opcode == OP_CONFIG_DEFAULT_TTL_GET && size != 0) + return true; + l_debug("Get/Set Default TTL"); n = mesh_model_opcode_set(OP_CONFIG_DEFAULT_TTL_STATUS, msg); @@ -792,6 +795,8 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_MODEL_PUB_GET: + if (size != 4 && size != 6) + return true; config_pub_get(node, net_idx, src, dst, pkt, size); break; @@ -832,6 +837,9 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall Through */ case OP_CONFIG_RELAY_GET: + if (opcode == OP_CONFIG_RELAY_GET && size != 0) + return true; + n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); msg[n++] = node_relay_mode_get(node, &count, &interval); @@ -853,6 +861,9 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall Through */ case OP_CONFIG_NETWORK_TRANSMIT_GET: + if (opcode == OP_CONFIG_NETWORK_TRANSMIT_GET && size != 0) + return true; + n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, msg); mesh_net_transmit_params_get(net, &count, &interval); @@ -869,6 +880,9 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall Through */ case OP_CONFIG_PROXY_GET: + if (opcode == OP_CONFIG_PROXY_GET && size != 0) + return true; + n = mesh_model_opcode_set(OP_CONFIG_PROXY_STATUS, msg); msg[n++] = node_proxy_mode_get(node); @@ -883,9 +897,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (n_idx > 0xfff) return true; - /* - * Currently no support for proxy: node identity not supported - */ + /* Currently setting node identity not supported */ /* Fall Through */ @@ -918,6 +930,9 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall Through */ case OP_CONFIG_BEACON_GET: + if (opcode == OP_CONFIG_BEACON_GET && size != 0) + return true; + n = mesh_model_opcode_set(OP_CONFIG_BEACON_STATUS, msg); msg[n++] = node_beacon_mode_get(node); @@ -932,6 +947,8 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall Through */ case OP_CONFIG_FRIEND_GET: + if (opcode == OP_CONFIG_FRIEND_GET && size != 0) + return true; n = mesh_model_opcode_set(OP_CONFIG_FRIEND_STATUS, msg); @@ -1071,13 +1088,14 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_NETKEY_GET: + if (size != 0) + return true; + n = mesh_model_opcode_set(OP_NETKEY_LIST, msg); size = MAX_MSG_LEN - n; if (mesh_net_key_list_get(net, msg + n, &size)) n += size; - else - n = 0; break; case OP_MODEL_APP_BIND: @@ -1089,21 +1107,22 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_VEND_MODEL_APP_GET: if (size != 6) return true; + model_app_list(node, net_idx, src, dst, pkt, size); break; case OP_MODEL_APP_GET: if (size != 4) return true; + model_app_list(node, net_idx, src, dst, pkt, size); break; case OP_CONFIG_HEARTBEAT_PUB_SET: l_debug("OP_CONFIG_HEARTBEAT_PUB_SET"); - if (size != 9) { - l_debug("bad size %d", size); + if (size != 9) return true; - } + if (pkt[2] > 0x11 || pkt[3] > 0x10 || pkt[4] > 0x7f) return true; else if (IS_VIRTUAL(l_get_le16(pkt))) @@ -1150,6 +1169,9 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_HEARTBEAT_PUB_GET: + if (size != 0) + return true; + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg); msg[n++] = b_res; l_put_le16(hb->pub_dst, msg + n); @@ -1179,6 +1201,9 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall through */ case OP_CONFIG_HEARTBEAT_SUB_GET: + if (opcode == OP_CONFIG_HEARTBEAT_SUB_GET && size != 0) + return true; + gettimeofday(&time_now, NULL); time_now.tv_sec -= hb->sub_start; @@ -1218,6 +1243,9 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_NODE_RESET: + if (size != 0) + return true; + n = mesh_model_opcode_set(OP_NODE_RESET_STATUS, msg); /* Delay node removal to give it a chance to send the status */ -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uBclONHoDF8k5gAAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 01:05:53 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id gBhjNtHoDF9VowEAlScrYA (envelope-from ); Tue, 14 Jul 2020 01:05:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 65CEE530BA; Tue, 14 Jul 2020 01:05:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbgGMXFe (ORCPT + 1 other); Mon, 13 Jul 2020 19:05:34 -0400 Received: from mga06.intel.com ([134.134.136.31]:39333 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726734AbgGMXFd (ORCPT ); Mon, 13 Jul 2020 19:05:33 -0400 IronPort-SDR: d55Ixte5Q+ZUQpLSPNfSCXlON9mGfMzLzyNVy9ywrTLuY34LZLN/vjefV2iNTdIDw7GrXQQyfP UF/hDbDMhv1Q== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="210285816" X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="210285816" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2020 16:05:31 -0700 IronPort-SDR: k9lYA9C4TgRLNbcs21v+JmALOH+EbH65Ntixkx5ABVAef3So4yxM+WvwCb13bMbt5qQxqA0EjA zx99U/Mef2Fw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="459465794" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.112.118]) by orsmga005.jf.intel.com with ESMTP; 13 Jul 2020 16:05:31 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 3/3] mesh: move model functionality out of node.c to model.c Date: Mon, 13 Jul 2020 16:05:28 -0700 Message-Id: <20200713230528.107948-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200713230528.107948-1-inga.stotland@intel.com> References: <20200713230528.107948-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 28 X-Rspamd-Score: 4.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: 65CEE530BA X-Rspamd-UID: 8d8d07 This moves the model related code out of node.c to model.c providing for better functional separation of modules. --- mesh/cfgmod.h | 4 +- mesh/mesh-config-json.c | 5 +- mesh/model.c | 359 +++++++++++++++++++++++++++++++++------- mesh/model.h | 32 ++-- mesh/node.c | 286 ++++---------------------------- 5 files changed, 350 insertions(+), 336 deletions(-) diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 383fdbf6b..0bfa71680 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -17,8 +17,8 @@ * */ -#define CONFIG_SRV_MODEL (VENDOR_ID_MASK | 0x0000) -#define CONFIG_CLI_MODEL (VENDOR_ID_MASK | 0x0001) +#define CONFIG_SRV_MODEL 0x0000 +#define CONFIG_CLI_MODEL 0x0001 /* New List */ #define OP_APPKEY_ADD 0x00 diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 88f715fc1..deb0019f9 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1126,18 +1126,15 @@ static bool parse_models(json_object *jmodels, struct mesh_config_element *ele) if (sscanf(str, "%04x", &id) != 1) goto fail; - id |= VENDOR_ID_MASK; } else if (len == 8) { if (sscanf(str, "%08x", &id) != 1) goto fail; + mod->vendor = true; } else goto fail; mod->id = id; - if (len == 8) - mod->vendor = true; - if (json_object_object_get_ex(jmodel, "bind", &jarray)) { if (json_object_get_type(jarray) != json_type_array || !parse_bindings(jarray, mod)) diff --git a/mesh/model.c b/mesh/model.c index afac6ec69..9aecd5b1d 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -137,6 +137,20 @@ static bool match_model_id(const void *a, const void *b) return (mesh_model_get_model_id(model) == id); } +static int compare_model_id(const void *a, const void *b, void *user_data) +{ + uint32_t a_id = mesh_model_get_model_id(a); + uint32_t b_id = mesh_model_get_model_id(b); + + if (a_id < b_id) + return -1; + + if (a_id > b_id) + return 1; + + return 0; +} + static struct mesh_model *get_model(struct mesh_node *node, uint8_t ele_idx, uint32_t id, int *status) { @@ -1023,9 +1037,8 @@ done: return result; } -int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, - uint16_t src, uint8_t ttl, - const void *msg, uint16_t msg_len) +static int model_publish(struct mesh_node *node, uint32_t id, uint16_t src, + uint8_t ttl, const void *msg, uint16_t msg_len) { struct mesh_net *net = node_get_net(node); struct mesh_model *mod; @@ -1041,14 +1054,14 @@ int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, if (src == 0) src = mesh_net_get_address(net); - mod = find_model(node, src, mod_id, &status); + mod = find_model(node, src, id, &status); if (!mod) { - l_debug("model %x not found", mod_id); + l_debug("model %x not found", id); return MESH_ERROR_NOT_FOUND; } if (!mod->pub) { - l_debug("publication doesn't exist (model %x)", mod_id); + l_debug("publication doesn't exist (model %x)", id); return MESH_ERROR_DOES_NOT_EXIST; } @@ -1069,6 +1082,24 @@ int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, return result ? MESH_ERROR_NONE : MESH_ERROR_FAILED; } +int mesh_model_publish(struct mesh_node *node, uint16_t mod_id, + uint16_t src, uint8_t ttl, + const void *msg, uint16_t msg_len) +{ + uint32_t id = mod_id | VENDOR_ID_MASK; + + return model_publish(node, id, src, ttl, msg, msg_len); +} + +int mesh_model_vendor_publish(struct mesh_node *node, uint16_t vendor_id, + uint16_t mod_id, uint16_t src, uint8_t ttl, + const void *msg, uint16_t msg_len) +{ + uint32_t id = mod_id | ((uint32_t)(vendor_id) << 16); + + return model_publish(node, id, src, ttl, msg, msg_len); +} + bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, uint8_t ttl, bool segmented, @@ -1173,7 +1204,21 @@ void mesh_model_free(void *data) l_free(mod); } -struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t id) +static void remove_subs(struct mesh_node *node, struct mesh_model *mod) +{ + const struct l_queue_entry *entry; + struct mesh_net *net = node_get_net(node); + + entry = l_queue_get_entries(mod->subs); + + for (; entry; entry = entry->next) + mesh_net_dst_unreg(net, (uint16_t) L_PTR_TO_UINT(entry->data)); + + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); +} + +static struct mesh_model *model_new(uint8_t ele_idx, uint32_t id) { struct mesh_model *mod = l_new(struct mesh_model, 1); @@ -1190,6 +1235,95 @@ struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t id) return mod; } +static void model_enable_pub(struct mesh_model *mod, bool enable) +{ + mod->pub_enabled = enable; + + if (!mod->pub_enabled && mod->pub) { + if (mod->pub->virt) + unref_virt(mod->pub->virt); + + l_free(mod->pub); + mod->pub = NULL; + } +} + +static void model_enable_sub(struct mesh_node *node, struct mesh_model *mod, + bool enable) +{ + mod->sub_enabled = enable; + + if (!mod->sub_enabled) + remove_subs(node, mod); +} + +static bool get_model_options(struct mesh_node *node, struct mesh_model *mod, + struct l_dbus_message_iter *opts) +{ + const char *key; + struct l_dbus_message_iter var; + bool opt; + + while (l_dbus_message_iter_next_entry(opts, &key, &var)) { + + if (!strcmp(key, "Publish")) { + if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) + return false; + + model_enable_pub(mod, opt); + } else if (!strcmp(key, "Subscribe")) { + if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) + return false; + + model_enable_sub(node, mod, opt); + } else + return false; + } + + return true; +} + +static bool add_model(struct mesh_node *node, uint8_t ele_idx, uint32_t id, + struct l_dbus_message_iter *opts) +{ + struct l_queue *mods; + struct mesh_model *mod; + + mods = node_get_element_models(node, ele_idx, NULL); + + /* Disallow duplicates */ + mod = l_queue_find(mods, match_model_id, L_UINT_TO_PTR(id)); + if (mod) + return false; + + mod = model_new(ele_idx, id); + + if (opts && !get_model_options(node, mod, opts)) { + mesh_model_free(mod); + return false; + } + + l_queue_insert(mods, mod, compare_model_id, NULL); + return true; +} + +bool mesh_model_add(struct mesh_node *node, uint8_t ele_idx, uint16_t mod_id, + struct l_dbus_message_iter *opts) +{ + uint32_t id = mod_id | VENDOR_ID_MASK; + + return add_model(node, ele_idx, id, opts); +} + +bool mesh_model_vendor_add(struct mesh_node *node, uint8_t ele_idx, + uint16_t vendor_id, uint16_t mod_id, + struct l_dbus_message_iter *opts) +{ + uint32_t id = mod_id | ((uint32_t)(vendor_id) << 16); + + return add_model(node, ele_idx, id, opts); +} + /* Internal models only */ static void restore_model_state(struct mesh_model *mod) { @@ -1220,17 +1354,18 @@ uint32_t mesh_model_get_model_id(const struct mesh_model *model) /* This registers an internal model, i.e. implemented within meshd */ bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, - uint32_t mod_id, + uint16_t mod_id, const struct mesh_model_ops *cbs, void *user_data) { struct mesh_model *mod; + uint32_t id; int status; /* Internal models are always SIG models */ - mod_id = VENDOR_ID_MASK | mod_id; + id = VENDOR_ID_MASK | mod_id; - mod = get_model(node, ele_idx, mod_id, &status); + mod = get_model(node, ele_idx, id, &status); if (!mod) return false; @@ -1487,20 +1622,6 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } -static void remove_subs(struct mesh_node *node, struct mesh_model *mod) -{ - const struct l_queue_entry *entry; - struct mesh_net *net = node_get_net(node); - - entry = l_queue_get_entries(mod->subs); - - for (; entry; entry = entry->next) - mesh_net_dst_unreg(net, (uint16_t) L_PTR_TO_UINT(entry->data)); - - l_queue_clear(mod->subs, NULL); - l_queue_clear(mod->virtuals, unref_virt); -} - int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) { int status; @@ -1522,12 +1643,10 @@ int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) return MESH_STATUS_SUCCESS; } -struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, - void *data) +static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, + struct mesh_config_model *db_mod) { - struct mesh_config_model *db_mod = data; struct mesh_model *mod; - struct mesh_net *net; struct mesh_config_pub *pub = db_mod->pub; uint32_t i; @@ -1537,7 +1656,7 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return NULL; } - mod = mesh_model_new(ele_idx, db_mod->vendor ? db_mod->id : + mod = model_new(ele_idx, db_mod->vendor ? db_mod->id : db_mod->id | VENDOR_ID_MASK); /* Implicitly bind config server model to device key */ @@ -1557,17 +1676,18 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return mod; } - net = node_get_net(node); - /* Add application key bindings if present */ if (db_mod->bindings) { mod->bindings = l_queue_new(); for (i = 0; i < db_mod->num_bindings; i++) - model_bind_idx(node, mod, db_mod->bindings[i]); + l_queue_push_tail(mod->bindings, + L_UINT_TO_PTR(db_mod->bindings[i])); } - /* Add publication if present */ - if (pub) { + mod->pub_enabled = db_mod->pub_enabled; + + /* Add publication if enabled and present */ + if (mod->pub_enabled && pub) { uint8_t retransmit = pub->count + ((pub->interval / 50 - 1) << 3); if (pub->virt) @@ -1579,8 +1699,10 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, pub->ttl, pub->period, retransmit); } - /* Add subscriptions if present */ - if (!db_mod->subs) + mod->sub_enabled = db_mod->sub_enabled; + + /* Add subscriptions if enabled and present */ + if (!db_mod->subs || !mod->sub_enabled) return mod; for (i = 0; i < db_mod->num_subs; i++) { @@ -1605,6 +1727,59 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return mod; } +bool mesh_model_add_from_storage(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *mods, struct l_queue *db_mods) +{ + struct mesh_net *net = node_get_net(node); + const struct l_queue_entry *entry; + + /* Allow empty elements */ + if (!db_mods) + return true; + + entry = l_queue_get_entries(db_mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod; + struct mesh_config_model *db_mod; + uint32_t id; + + db_mod = entry->data; + + id = db_mod->vendor ? db_mod->id : db_mod->id | VENDOR_ID_MASK; + + if (l_queue_find(mods, match_model_id, L_UINT_TO_PTR(id))) + return false; + + mod = model_setup(net, ele_idx, db_mod); + if (!mod) + return false; + + l_queue_insert(mods, mod, compare_model_id, NULL); + } + + return true; +} + +void mesh_model_convert_to_storage(struct l_queue *db_mods, + struct l_queue *mods) +{ + + const struct l_queue_entry *entry = l_queue_get_entries(mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + struct mesh_config_model *db_mod; + + db_mod = l_new(struct mesh_config_model, 1); + db_mod->id = mod->id; + db_mod->vendor = mod->id < VENDOR_ID_MASK; + db_mod->pub_enabled = mod->pub_enabled; + db_mod->sub_enabled = mod->sub_enabled; + l_queue_push_tail(db_mods, db_mod); + } +} + uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf) { if (opcode <= 0x7e) { @@ -1669,7 +1844,7 @@ bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, return true; } -void model_build_config(void *model, void *msg_builder) +void mesh_model_build_config(void *model, void *msg_builder) { struct l_dbus_message_builder *builder = msg_builder; struct mesh_model *mod = model; @@ -1715,36 +1890,44 @@ void model_build_config(void *model, void *msg_builder) l_dbus_message_builder_leave_struct(builder); } -void mesh_model_enable_pub(struct mesh_model *mod, bool enable) +void mesh_model_update_opts(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *curr, struct l_queue *updated) { - mod->pub_enabled = enable; + uint16_t primary; + const struct l_queue_entry *entry; - if (!mod->pub_enabled && mod->pub) { - if (mod->pub->virt) - unref_virt(mod->pub->virt); + primary = node_get_primary(node); + entry = l_queue_get_entries(curr); - l_free(mod->pub); - mod->pub = NULL; - } -} + for (; entry; entry = entry->next) { + struct mesh_model *mod, *updated_mod = entry->data; + uint32_t id = mesh_model_get_model_id(updated_mod); + bool updated_opt, vendor = id < VENDOR_ID_MASK; -bool mesh_model_is_pub_enabled(struct mesh_model *mod) -{ - return mod->pub_enabled; -} + mod = l_queue_find(curr, match_model_id, L_UINT_TO_PTR(id)); + if (!mod) + continue; -void mesh_model_enable_sub(struct mesh_node *node, struct mesh_model *mod, - bool enable) -{ - mod->sub_enabled = enable; + if (!vendor) + id &= ~VENDOR_ID_MASK; - if (!mod->sub_enabled) - remove_subs(node, mod); -} + updated_opt = updated_mod->pub_enabled; + if (mod->pub_enabled != updated_opt) { + model_enable_pub(mod, updated_opt); + mesh_config_model_pub_enable(node_config_get(node), + primary + ele_idx, id, + vendor, updated_opt); + } -bool mesh_model_is_sub_enabled(struct mesh_model *mod) -{ - return mod->sub_enabled; + updated_opt = updated_mod->sub_enabled; + + if (mod->pub_enabled != updated_opt) { + model_enable_sub(node, mod, updated_opt); + mesh_config_model_sub_enable(node_config_get(node), + primary + ele_idx, id, + vendor, updated_opt); + } + } } void mesh_model_init(void) @@ -1757,3 +1940,59 @@ void mesh_model_cleanup(void) l_queue_destroy(mesh_virtuals, l_free); mesh_virtuals = NULL; } + +/* Populate composition buffer with model IDs */ +uint16_t mesh_model_generate_composition(struct l_queue *mods, uint16_t buf_sz, + uint8_t *buf) +{ + const struct l_queue_entry *entry; + uint8_t num_s = 0, num_v = 0; + uint8_t *mod_buf; + uint16_t n; + + /* Store models IDs, store num_s and num_v later */ + mod_buf = buf; + n = 2; + + entry = l_queue_get_entries(mods); + + /* Get SIG models */ + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + + if (n + 2 > buf_sz) + goto done; + + if ((mod->id & VENDOR_ID_MASK) == VENDOR_ID_MASK) { + l_put_le16((uint16_t) (mod->id & 0xffff), buf + n); + n += 2; + num_s++; + } + } + + /* Get vendor models */ + entry = l_queue_get_entries(mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + uint16_t vendor; + + if (n + 4 > buf_sz) + goto done; + + if ((mod->id & VENDOR_ID_MASK) == VENDOR_ID_MASK) + continue; + + vendor = (uint16_t) (mod->id >> 16); + l_put_le16(vendor, buf + n); + n += 2; + l_put_le16((uint16_t) (mod->id & 0xffff), buf + n); + n += 2; + num_v++; + } + +done: + mod_buf[0] = num_s; + mod_buf[1] = num_v; + return n; +} diff --git a/mesh/model.h b/mesh/model.h index 0377d3fdd..09309c497 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -60,14 +60,20 @@ struct mesh_model_ops { mesh_model_sub_cb sub; }; -struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t mod_id); +bool mesh_model_add(struct mesh_node *node, uint8_t ele_idx, uint16_t mod_id, + struct l_dbus_message_iter *opts); +bool mesh_model_vendor_add(struct mesh_node *node, uint8_t ele_idx, + uint16_t vendor_id, uint16_t mod_id, + struct l_dbus_message_iter *opts); void mesh_model_free(void *data); uint32_t mesh_model_get_model_id(const struct mesh_model *model); bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, - uint32_t mod_id, const struct mesh_model_ops *cbs, + uint16_t mod_id, const struct mesh_model_ops *cbs, void *user_data); -struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, - void *data); +bool mesh_model_add_from_storage(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *mods, struct l_queue *db_mods); +void mesh_model_convert_to_storage(struct l_queue *db_mods, + struct l_queue *mods); struct mesh_model_pub *mesh_model_pub_get(struct mesh_node *node, uint16_t addr, uint32_t mod_id, int *status); int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, @@ -95,8 +101,11 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, uint8_t ttl, bool segmented, const void *msg, uint16_t msg_len); -int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, uint16_t src, +int mesh_model_publish(struct mesh_node *node, uint16_t mod_id, uint16_t src, uint8_t ttl, const void *msg, uint16_t msg_len); +int mesh_model_vendor_publish(struct mesh_node *node, uint16_t vendor_id, + uint16_t mod_id, uint16_t src, uint8_t ttl, + const void *msg, uint16_t msg_len); bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, uint32_t seq, uint32_t iv_index, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t key_aid, @@ -108,13 +117,10 @@ struct l_queue *mesh_model_get_appkeys(struct mesh_node *node); uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf); bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, uint32_t *opcode, uint16_t *n); -void model_build_config(void *model, void *msg_builder); - -void mesh_model_enable_pub(struct mesh_model *mod, bool enable); -bool mesh_model_is_pub_enabled(struct mesh_model *mod); -void mesh_model_enable_sub(struct mesh_node *node, struct mesh_model *mod, - bool enable); -bool mesh_model_is_sub_enabled(struct mesh_model *mod); - +void mesh_model_build_config(void *model, void *msg_builder); +void mesh_model_update_opts(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *curr, struct l_queue *updated); +uint16_t mesh_model_generate_composition(struct l_queue *mods, uint16_t buf_sz, + uint8_t *buf); void mesh_model_init(void); void mesh_model_cleanup(void); diff --git a/mesh/node.c b/mesh/node.c index c61167bda..46cf15d53 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -186,28 +186,6 @@ static bool match_element_path(const void *a, const void *b) return (!strcmp(element->path, path)); } -static bool match_model_id(const void *a, const void *b) -{ - const struct mesh_model *mod = a; - uint32_t mod_id = L_PTR_TO_UINT(b); - - return mesh_model_get_model_id(mod) == mod_id; -} - -static int compare_model_id(const void *a, const void *b, void *user_data) -{ - uint32_t a_id = mesh_model_get_model_id(a); - uint32_t b_id = mesh_model_get_model_id(b); - - if (a_id < b_id) - return -1; - - if (a_id > b_id) - return 1; - - return 0; -} - struct mesh_node *node_find_by_uuid(uint8_t uuid[16]) { return l_queue_find(nodes, match_device_uuid, uuid); @@ -225,25 +203,6 @@ uint8_t *node_uuid_get(struct mesh_node *node) return node->uuid; } -static void add_internal_model(struct mesh_node *node, uint32_t mod_id, - uint8_t ele_idx) -{ - struct node_element *ele; - struct mesh_model *mod; - - ele = l_queue_find(node->elements, match_element_idx, - L_UINT_TO_PTR(ele_idx)); - if (!ele) - return; - - if (l_queue_find(ele->models, match_model_id, L_UINT_TO_PTR(mod_id))) - return; - - mod = mesh_model_new(ele_idx, mod_id); - - l_queue_insert(ele->models, mod, compare_model_id, NULL); -} - static void set_defaults(struct mesh_node *node) { node->lpn = MESH_MODE_UNSUPPORTED; @@ -359,46 +318,6 @@ void node_remove(struct mesh_node *node) free_node_resources(node); } -static bool add_models_from_storage(struct mesh_node *node, - struct node_element *ele, - struct mesh_config_element *db_ele) -{ - const struct l_queue_entry *entry; - - if (!ele->models) - ele->models = l_queue_new(); - - entry = l_queue_get_entries(db_ele->models); - - for (; entry; entry = entry->next) { - struct mesh_model *mod; - struct mesh_config_model *db_mod; - uint32_t id; - - db_mod = entry->data; - - id = db_mod->vendor ? db_mod->id : db_mod->id | VENDOR_ID_MASK; - - if (l_queue_find(ele->models, match_model_id, - L_UINT_TO_PTR(id))) - return false; - - mod = mesh_model_setup(node, ele->idx, db_mod); - if (!mod) - return false; - - if (!db_mod->pub_enabled) - mesh_model_enable_pub(mod, false); - - if (!db_mod->sub_enabled) - mesh_model_enable_sub(node, mod, false); - - l_queue_insert(ele->models, mod, compare_model_id, NULL); - } - - return true; -} - static bool add_element_from_storage(struct mesh_node *node, struct mesh_config_element *db_ele) { @@ -411,7 +330,12 @@ static bool add_element_from_storage(struct mesh_node *node, ele->idx = db_ele->index; ele->location = db_ele->location; - if (!db_ele->models || !add_models_from_storage(node, ele, db_ele)) + + if (!ele->models) + ele->models = l_queue_new(); + + if (!mesh_model_add_from_storage(node, ele->idx, ele->models, + db_ele->models)) return false; l_queue_push_tail(node->elements, ele); @@ -424,12 +348,13 @@ static bool add_elements_from_storage(struct mesh_node *node, const struct l_queue_entry *entry; entry = l_queue_get_entries(db_node->elements); + for (; entry; entry = entry->next) if (!add_element_from_storage(node, entry->data)) return false; /* Add configuration server model on the primary element */ - add_internal_model(node, CONFIG_SRV_MODEL, PRIMARY_ELE_IDX); + mesh_model_add(node, PRIMARY_ELE_IDX, CONFIG_SRV_MODEL, NULL); return true; } @@ -888,9 +813,8 @@ uint8_t node_friend_mode_get(struct mesh_node *node) static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz) { - uint16_t n, features; - uint16_t num_ele = 0; - const struct l_queue_entry *ele_entry; + uint16_t n, features, num_ele = 0; + const struct l_queue_entry *entry; if (!node || sz < MIN_COMP_SIZE) return 0; @@ -920,12 +844,10 @@ static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, l_put_le16(features, buf + n); n += 2; - ele_entry = l_queue_get_entries(node->elements); - for (; ele_entry; ele_entry = ele_entry->next) { - struct node_element *ele = ele_entry->data; - const struct l_queue_entry *mod_entry; - uint8_t num_s = 0, num_v = 0; - uint8_t *mod_buf; + entry = l_queue_get_entries(node->elements); + + for (; entry; entry = entry->next) { + struct node_element *ele = entry->data; if (ele->idx != num_ele) return 0; @@ -939,59 +861,8 @@ static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, l_put_le16(ele->location, buf + n); n += 2; - /* Store models IDs, store num_s and num_v later */ - mod_buf = buf + n; - n += 2; - - /* Get SIG models */ - mod_entry = l_queue_get_entries(ele->models); - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - uint32_t mod_id; - - mod_id = mesh_model_get_model_id( - (const struct mesh_model *) mod); - - if ((mod_id & VENDOR_ID_MASK) == VENDOR_ID_MASK) { - if (n + 2 > sz) - goto element_done; - - l_put_le16((uint16_t) (mod_id & 0xffff), + n += mesh_model_generate_composition(ele->models, sz - n, buf + n); - n += 2; - num_s++; - } - } - - /* Get vendor models */ - mod_entry = l_queue_get_entries(ele->models); - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - uint32_t mod_id; - uint16_t vendor; - - mod_id = mesh_model_get_model_id( - (const struct mesh_model *) mod); - - vendor = (uint16_t) (mod_id >> 16); - if (vendor != 0xffff) { - if (n + 4 > sz) - goto element_done; - - l_put_le16(vendor, buf + n); - n += 2; - l_put_le16((uint16_t) (mod_id & 0xffff), - buf + n); - n += 2; - num_v++; - } - - } - -element_done: - mod_buf[0] = num_s; - mod_buf[1] = num_v; - } if (!num_ele) @@ -1128,52 +999,6 @@ static void app_disc_cb(struct l_dbus *bus, void *user_data) free_node_dbus_resources(node); } -static bool get_model_options(struct mesh_node *node, struct mesh_model *mod, - struct l_dbus_message_iter *opts) -{ - const char *key; - struct l_dbus_message_iter var; - bool opt; - - while (l_dbus_message_iter_next_entry(opts, &key, &var)) { - - if (!strcmp(key, "Publish")) { - if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) - return false; - mesh_model_enable_pub(mod, opt); - } else if (!strcmp(key, "Subscribe")) { - if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) - return false; - mesh_model_enable_sub(node, mod, opt); - } else - return false; - } - - return true; -} - -static bool generate_model(struct mesh_node *node, struct node_element *ele, - uint32_t id, struct l_dbus_message_iter *opts) -{ - struct mesh_model *mod; - - /* Disallow duplicates */ - if (l_queue_find(ele->models, match_model_id, - L_UINT_TO_PTR(id))) - return false; - - mod = mesh_model_new(ele->idx, id); - - if (!get_model_options(node, mod, opts)) { - l_free(mod); - return false; - } - - l_queue_insert(ele->models, mod, compare_model_id, NULL); - - return true; -} - static bool get_sig_models_from_properties(struct mesh_node *node, struct node_element *ele, struct l_dbus_message_iter *property) @@ -1189,13 +1014,12 @@ static bool get_sig_models_from_properties(struct mesh_node *node, /* Bluetooth SIG defined models */ while (l_dbus_message_iter_next_entry(&mods, &m_id, &var)) { - uint32_t id = m_id | VENDOR_ID_MASK; /* Allow Config Server Model only on the primary element */ - if (ele->idx != PRIMARY_ELE_IDX && id == CONFIG_SRV_MODEL) + if (ele->idx != PRIMARY_ELE_IDX && m_id == CONFIG_SRV_MODEL) return false; - if (!generate_model(node, ele, id, &var)) + if (!mesh_model_add(node, ele->idx, m_id, &var)) return false; } @@ -1217,9 +1041,7 @@ static bool get_vendor_models_from_properties(struct mesh_node *node, /* Vendor defined models */ while (l_dbus_message_iter_next_entry(&mods, &v_id, &m_id, &var)) { - uint32_t id = m_id | (v_id << 16); - - if (!generate_model(node, ele, id, &var)) + if (!mesh_model_vendor_add(node, ele->idx, v_id, m_id, &var)) return false; } @@ -1295,7 +1117,7 @@ static bool get_element_properties(struct mesh_node *node, const char *path, * the operation below will be a "no-op". */ if (ele->idx == PRIMARY_ELE_IDX) - add_internal_model(node, CONFIG_SRV_MODEL, PRIMARY_ELE_IDX); + mesh_model_add(node, PRIMARY_ELE_IDX, CONFIG_SRV_MODEL, NULL); return true; fail: @@ -1332,7 +1154,6 @@ static void convert_node_to_storage(struct mesh_node *node, for (; entry; entry = entry->next) { struct node_element *ele = entry->data; struct mesh_config_element *db_ele; - const struct l_queue_entry *mod_entry; db_ele = l_new(struct mesh_config_element, 1); @@ -1340,21 +1161,8 @@ static void convert_node_to_storage(struct mesh_node *node, db_ele->location = ele->location; db_ele->models = l_queue_new(); - mod_entry = l_queue_get_entries(ele->models); - - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - struct mesh_config_model *db_mod; - uint32_t mod_id = mesh_model_get_model_id(mod); + mesh_model_convert_to_storage(db_ele->models, ele->models); - db_mod = l_new(struct mesh_config_model, 1); - db_mod->id = mod_id; - db_mod->vendor = ((mod_id & VENDOR_ID_MASK) - != VENDOR_ID_MASK); - db_mod->pub_enabled = mesh_model_is_pub_enabled(mod); - db_mod->sub_enabled = mesh_model_is_sub_enabled(mod); - l_queue_push_tail(db_ele->models, db_mod); - } l_queue_push_tail(db_node->elements, db_ele); } @@ -1375,6 +1183,7 @@ static bool create_node_config(struct mesh_node *node, const uint8_t uuid[16]) /* Free temporarily allocated resources */ entry = l_queue_get_entries(db_node.elements); + for (; entry; entry = entry->next) { struct mesh_config_element *db_ele = entry->data; @@ -1517,7 +1326,6 @@ static void update_model_options(struct mesh_node *node, len = l_queue_length(node->elements); for (i = 0; i < len; i++) { - const struct l_queue_entry *entry; ele = l_queue_find(node->elements, match_element_idx, L_UINT_TO_PTR(i)); @@ -1526,42 +1334,8 @@ static void update_model_options(struct mesh_node *node, if (!ele || !ele_attach) continue; - entry = l_queue_get_entries(ele->models); - - for (; entry; entry = entry->next) { - struct mesh_model *mod, *updated_mod = entry->data; - uint32_t id = mesh_model_get_model_id(updated_mod); - bool opt, updated_opt; - bool vendor = id < VENDOR_ID_MASK; - - mod = l_queue_find(ele_attach->models, match_model_id, - L_UINT_TO_PTR(id)); - if (!mod) - continue; - - if (!vendor) - id &= ~VENDOR_ID_MASK; - - opt = mesh_model_is_pub_enabled(mod); - updated_opt = mesh_model_is_pub_enabled(updated_mod); - - if (updated_opt != opt) { - mesh_model_enable_pub(mod, updated_opt); - mesh_config_model_pub_enable(attach->cfg, - attach->primary + i, id, - vendor, updated_opt); - } - - opt = mesh_model_is_sub_enabled(mod); - updated_opt = mesh_model_is_sub_enabled(updated_mod); - - if (updated_opt != opt) { - mesh_model_enable_sub(node, mod, updated_opt); - mesh_config_model_sub_enable(attach->cfg, - attach->primary + i, id, - vendor, updated_opt); - } - } + mesh_model_update_opts(node, ele->idx, ele_attach->models, + ele->models); } } @@ -1964,7 +1738,7 @@ static void build_element_config(void *a, void *b) l_dbus_message_builder_enter_array(builder, "(qa{sv})"); /* Iterate over models */ - l_queue_foreach(ele->models, model_build_config, builder); + l_queue_foreach(ele->models, mesh_model_build_config, builder); l_dbus_message_builder_leave_array(builder); @@ -2243,7 +2017,7 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - result = mesh_model_publish(node, VENDOR_ID_MASK | mod_id, src, + result = mesh_model_publish(node, mod_id, src, mesh_net_get_default_ttl(node->net), data, len); if (result != MESH_ERROR_NONE) @@ -2260,8 +2034,7 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, const char *sender, *ele_path; struct l_dbus_message_iter iter_data; uint16_t src; - uint16_t model_id, vendor; - uint32_t vendor_mod_id; + uint16_t mod_id, vendor_id; struct node_element *ele; uint8_t *data = NULL; uint32_t len; @@ -2274,8 +2047,8 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &vendor, - &model_id, &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &vendor_id, + &mod_id, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); ele = l_queue_find(node->elements, match_element_path, ele_path); @@ -2290,8 +2063,7 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - vendor_mod_id = (vendor << 16) | model_id; - result = mesh_model_publish(node, vendor_mod_id, src, + result = mesh_model_vendor_publish(node, vendor_id, mod_id, src, mesh_net_get_default_ttl(node->net), data, len); if (result != MESH_ERROR_NONE) -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KHwhOjLzDF+QQgEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 01:50:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6FXAODLzDF+kwQEAlp8NpQ (envelope-from ); Tue, 14 Jul 2020 01:50:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9F33A501AF; Tue, 14 Jul 2020 01:50:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727826AbgGMXtP (ORCPT + 1 other); Mon, 13 Jul 2020 19:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727095AbgGMXst (ORCPT ); Mon, 13 Jul 2020 19:48:49 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 855BDC061755 for ; Mon, 13 Jul 2020 16:48:49 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id 18so11128919otv.6 for ; Mon, 13 Jul 2020 16:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=B3FnEyMXCyMjWIZc011broRSH16kPZ5lCcUamQmS3Xk=; b=jzuvwvt+xmjT2+N8izRgmG1JKSDrHN/k/n5DWA7b9VDulN/HMSXfRdwRtMG7s/tqZl 8MPk4PRcNIlyb/H2eHVJOF5P32g+uBI0+GKDgZMlh4Hlppcv/4IKV/09rkcI5kdOfhZc qQJN/xPDJq3HDn/Mdi6dv8xYz76TFPUl58gMA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=B3FnEyMXCyMjWIZc011broRSH16kPZ5lCcUamQmS3Xk=; b=pfUPIyAg2fqom6t6ImnEegalXiJRujws4ABZ+W1JcEpFhO3r6eXUIGHXbVyaPX+ncO 4U/KQrPt6xQU4zZcWHjt8eaX9CJXKHiEucOEXShN07AnVM3fu0uunDUt46ee0xU4PI6E MNsmqXJ3hLien00fSz2Trsvwh22lTW9wANhzUaG9uhpkCMEFLugyDmmqg0mhCnH5BO6v aBklYWOEPz17ul0qnMXwetlhDlIQKhc2sqaYfJHE+CrFtVEz8zRsaSWaGmzVOAIebLQ2 1VNDKAEGbaQKHmk9eVXpjRuBs5Ht/5VcdWpO/3cLGTq9cf+P2Eok8djUvJeEOFWNtb/K wrFQ== X-Gm-Message-State: AOAM533/Awau9jCHXCFcc0Lg97saLjVjeTzjS9DUsrydTr2Piz7yjtGk cs/iTaTuV8ZxtW/E0C6oWV+T3BTdp0aKgl3IEn9STbKH0GM= X-Google-Smtp-Source: ABdhPJyveyuIEQxaAUFvWpCIWLlqsiLTx2bcWpUkVi016ZLpUPKlCp1nSl+bUwSeRMYv+HW0a33p6b9WLabNmhAKihA= X-Received: by 2002:a9d:554d:: with SMTP id h13mr1660215oti.329.1594684128701; Mon, 13 Jul 2020 16:48:48 -0700 (PDT) MIME-Version: 1.0 References: <20200713201441.235959-1-sonnysasaka@chromium.org> In-Reply-To: From: Sonny Sasaka Date: Mon, 13 Jul 2020 16:48:36 -0700 Message-ID: Subject: Re: [PATCH BlueZ 0/3] Per-device option to enable/disable internal profiles To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9F33A501AF X-Rspamd-UID: ab6ca4 Hi Luiz, On Mon, Jul 13, 2020 at 3:59 PM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Mon, Jul 13, 2020 at 3:04 PM Sonny Sasaka wrote: > > > > Hi Luiz, > > > > I considered having such an approach that gives exception to some > > profile to not claim exclusive access. However, I think that this > > approach has a drawback that it can only be guaranteed to work > > correctly for profiles that contain only read-only attributes. Any > > profile that contains writable attributes, naturally, cannot be > > guaranteed to always work correctly (as is the case with the Battery > > profile). Therefore, the usefulness of that feature will be very > > limited. > > > > I also considered the benefits of the AllowInternalProfiles approach: > > * Applications can also have control over any profile, not just > > Battery profile. For example, if in the future BlueZ has more internal > > profiles, like (Blood Pressure Profile or any other profile that may > > contain writable attributes), we can guarantee that applications can > > still opt to have access to that profile, without relying on a profile > > being "safe" to be shared by both BlueZ's internal and external > > handlers. > > * This has an added security benefit: applications which operate on a > > specific GATT profile will not unintentionally activate internal > > profiles such as HOG (which is able to hijack input control of the > > host). This is the correct and expected behavior of Android apps that > > connect over GATT and get access to a GATT profile. > > Not sure I follow these arguments, it seems AllowInternalProfiles may > actually enable hijacking the profiles so I wonder if you got this > backwards as we can't let things like HoG be controlled by > applications directly it would be too easy to implement something like > a keylogger, or perhaps you are suggesting that there is another layer > for implementing the profiles? Note that it is intended that plugins > shall be used for profiles that need to be integrated system wide, > D-Bus interface shall be restricted to only application specific > profiles. I think you misunderstood my point about HOG hijacking. Consider the following case: 1. A legit application (not System UI) on a host computer scans and connects to a nearby peer. It makes a guess about the peer device based on its advertising data. It intends to operate on a specific GATT profile (not necessarily Battery). 2. The peer device turns out to be malicious. It runs HOG GATT server and triggers the host's HOG profile to be active. 3. The malicious peer device's HOG GATT server can now maliciously make mouse movements or enter keystrokes to the host. In this case the user is considered being attacked, because he/she doesn't consciously interact with the System UI to connect to a nearby mouse/keyboard. My example doesn't have to be HOG. It just happens to be a profile which is attackable at the moment. My point is that, for applications it's always safest to turn off all internal profiles to avoid such incident. There is no use case where applications want to trigger internal profiles. Note 1: By "applications", I mean things like Android apps or JavaScript apps which are not considered System's Bluetooth UI. > > Note that we do allow external profiles to be registered with use of: > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/profile-api.txt > > And for GATT: > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt#n366 > > We could perhaps make the assumption that once an application > registers itself as supporting a given profile we check if against a > blacklist of profiles that may have security implications, which > perhaps could be defined via main.conf or some other file, if that is > not the case the internal profile can be disabled and the D-Bus object > would be accessible over D-Bus. Also note that we do offer clients the > ability to have exclusive access with AcquireWrite and AcquireNotify. > > > Therefore I think that this approach, although more complex, has > > longer lasting benefits. Let me know if you have any objection to > > having such a feature. > > > > > > On Mon, Jul 13, 2020 at 1:35 PM Luiz Augusto von Dentz > > wrote: > > > > > > Hi Sonny, > > > > > > On Mon, Jul 13, 2020 at 1:18 PM Sonny Sasaka wrote: > > > > > > > > This patch series adds a mechanism for clients to choose whether to > > > > enable BlueZ internal profiles (e.g. A2DP, Battery) for specific > > > > devices. > > > > > > > > The motivation behind this feature is that some applications (e.g. Web > > > > Bluetooth or Android apps) need to have control over all remove GATT > > > > services, like Battery service. With "battery" plugin being enabled on > > > > BlueZ, it becomes not possible for those apps to work properly because > > > > BlueZ "hides" the Battery-related attributes from its GATT Client API. > > > > Disabling the "battery" plugin won't solve the problem either, since we > > > > do also need to enable the plugin so that we can use org.bluez.Battery1 > > > > API. > > > > > > > > The solution that we propose is that clients can choose whether to > > > > enable internal profiles for each device. Clients know when to enable > > > > internal profiles (such as when a user chooses to pair/connect via a UI) > > > > and when to disable internal profiles (such as when the connection is > > > > initiated by a generic application). > > > > > > I wonder if it is not better to just have a flag indicating if the > > > profile shall claim exclusive access (such as GAP and GATT services), > > > so profiles that don't set that will have the services exposed so for > > > battery we can probably just have it exposed by default since it > > > doesn't appear to would be any conflicts on having it exposed. > > > > > > > Sonny Sasaka (3): > > > > doc: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > device: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > client: Add set-allow-internal-profiles command > > > > > > > > client/main.c | 38 ++++++++++++++++++ > > > > doc/device-api.txt | 13 +++++++ > > > > src/device.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ > > > > src/hcid.h | 2 + > > > > src/main.c | 10 +++++ > > > > src/main.conf | 4 ++ > > > > 6 files changed, 163 insertions(+) > > > > > > > > -- > > > > 2.26.2 > > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0AxUH9X2DF82eAEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 02:05:41 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id QELYHdX2DF9cUQEA0J78UA (envelope-from ); Tue, 14 Jul 2020 02:05:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 091A5526D3; Tue, 14 Jul 2020 02:05:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726510AbgGNAFe (ORCPT + 1 other); Mon, 13 Jul 2020 20:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgGNAFd (ORCPT ); Mon, 13 Jul 2020 20:05:33 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66AE1C061755 for ; Mon, 13 Jul 2020 17:05:33 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id t198so12521405oie.7 for ; Mon, 13 Jul 2020 17:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rt1mhXPGHE83AVIN8DrCzJjKR7f6iw436AtFM0CwQtc=; b=CpXQf2m3hu5kk5IAt4urk1zMt3n0cGYyhahSYrt4xVoIkFxfq22g+hVjsGgChVlg/u t8mldv18/+xQcHgmPFFJb27+SCm3nEOKWmEWluXMcK8bZgyg+0APgjxYff4U4vnwI87H nXHczOYasYuUK0SfUGvLN7nLlLxAvidZr5E1VjxHD4SU2+PQ5eFcqfiDg707mi99Zrjs ufvcAag0p84eDyqVTyEOt5EsAunfHLNSZCx94MiMnzEnN58mvXQ0siQ9i/MYmewY9PTf 3kwbdNUphJcCR/U6RcUUtJsP9UGV2QzwHv5izxe8qjvwq6gUoJ6AyMbj4+YW1DBhl7Sj HEyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rt1mhXPGHE83AVIN8DrCzJjKR7f6iw436AtFM0CwQtc=; b=L18ZUVOkPXYiW0r7Kz88DHeH8SgjT4IyTVNfw9reKHC1fKJTRW2Dic7/f9RH40dPm5 s9yeWxUrmz65H+74Xbbod4Pt0RrpOA/vNECb/WzdHyQTpUiF50O2kaJRU8tOXPVD2sxO f2hlH1zYBq1UveyLwu2hY2tyGRAK9Y/Q2PZ2OYlN1irR6CveOS0MDXpHpvFDflCSfvas VXQVmXDDSBwuzanfIni5w030NMEsdP+cNwPMikp1QG5rarZ+WrLrCLEa2xjYe9htwt5j bJO7MB9eZd+hL0rKljcHb2mlxKgt8rQlLspk1jeg0kByj94c1Wxp7g7W3f7gMBkoGdXA jfNw== X-Gm-Message-State: AOAM531oBQgXjcDyH12/IIKBS0e6z3HMOXh0YOpmk8dcJPYsRNofnNEf sBnNdm33PTTqoVAoOQUN8b6PF8DEAv8zgFDRhIM= X-Google-Smtp-Source: ABdhPJzgtaVOI1IKch9rn+CPXnWt+GfRBOpgf3TwXbqCOc31+besFW8y2WWl9XD5W/5I782dKU0oZzQDKnB0tykqrcY= X-Received: by 2002:aca:2819:: with SMTP id 25mr1558792oix.48.1594685132425; Mon, 13 Jul 2020 17:05:32 -0700 (PDT) MIME-Version: 1.0 References: <20200711115031.123793-1-marijns95@gmail.com> In-Reply-To: <20200711115031.123793-1-marijns95@gmail.com> From: Luiz Augusto von Dentz Date: Mon, 13 Jul 2020 17:05:20 -0700 Message-ID: Subject: Re: [PATCH BlueZ] audio/avrcp: Always update transport volume regardless of player To: Marijn Suijten Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 091A5526D3 X-Rspamd-UID: 84ea37 Hi Marijn, On Sat, Jul 11, 2020 at 4:50 AM Marijn Suijten wrote: > > `Volume` is a special property that not only exists on players but also > on the transport (see org.bluez.MediaTransport1). A player is not > attached when the controller does not support FEATURE_CATEGORY_1, which > is common on headphones without media browsing capabilities. > > On such audio devices (headphones, in-ears and the like) Absolute Volume > is not available unless an external player is registered > (org.bluez.Media1.RegisterPlayer) and the device sends a volume event > back after that to set a2dp->volume in transport.c to a valid value > (causing volume_exists to finally return true). > > This [1] mail thread denoting the same issue has a solution to at least > request capabilities from the controller, but the proposed player object > is not created on category 2 devices. Any notifications received on > AVRCP_EVENT_VOLUME_CHANGED (avrcp_volume_changed) that is subsequently > registered, or handling the result of avrcp_set_volume in > avrcp_handle_set_volume will be ignored unless said player is present. > > This issue is not addressed by adding a fake player but instead dealing > with the fact that volume is "special" and available on the transport > regardless of the existence of a player. This is confirmed in > avrcp_get_capabilities_resp as well which requires a player to register > any event except AVRCP_EVENT_VOLUME_CHANGED. > > The applied solution moves media_transport_update_device_volume out of > the player and into avrcp_volume_changed/avrcp_handle_set_volume where > it is unconditionally called. These functions are the only users of > avrcp_player->set_volume. > > Note that the volume member of media_player is never used which seems a > result of updating from org.bluez.MediaPlayer1 to > org.mpris.MediaPlayer2.Player in > 15e421737ccc4696ed567edcc24d178aedb47854, where the volume property [2] > is left out. This is actually on purpose since the volume notification indicates the volume at the device side we don't want to change the player volume as well as it would most likely result in duplicating the volume change both at sink and source, note that the likes of handling the transport like pulseaudio would already notify the device volume level change without actually applying any change to the volume locally. > [1]: https://marc.info/?l=linux-bluetooth&m=145337574806153 > [2]: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Volume > > --- > Hi, > > This is is a resend from an earlier mail that didn't comply with the > contributor guidelines. Seeing that the topic of AVRCP volume is brought > up recently it is about time to repair it and hereby send it again. > > I still have an incomplete patch lying around that synchronizes Volume > on org.mpris.MediaPlayer2.Player back when this patch was written 6 > months ago. It'll require some time to get back in to it and finalize > it, let me know if that's desired. > > - Marijn Suijten > > profiles/audio/avrcp.c | 12 ++++++++---- > profiles/audio/media.c | 16 ---------------- > 2 files changed, 8 insertions(+), 20 deletions(-) > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > index e2428250e..8370c8a44 100644 > --- a/profiles/audio/avrcp.c > +++ b/profiles/audio/avrcp.c > @@ -3625,12 +3625,13 @@ static void avrcp_volume_changed(struct avrcp *session, > struct avrcp_player *player = target_get_player(session); > uint8_t volume; > > - if (!player) > - return; > - > volume = pdu->params[1] & 0x7F; > > - player->cb->set_volume(volume, session->dev, player->user_data); > + /* Always update the transport volume, which is separate from the player */ > + media_transport_update_device_volume(session->dev, volume); > + > + if (player) > + player->cb->set_volume(volume, session->dev, player->user_data); > } > > static void avrcp_status_changed(struct avrcp *session, > @@ -4378,6 +4379,9 @@ static gboolean avrcp_handle_set_volume(struct avctp *conn, uint8_t code, > > volume = pdu->params[0] & 0x7F; > > + /* Always update the transport volume, which is separate from the player */ > + media_transport_update_device_volume(session->dev, volume); > + > if (player != NULL) > player->cb->set_volume(volume, session->dev, player->user_data); > > diff --git a/profiles/audio/media.c b/profiles/audio/media.c > index 993ecb3b3..a0173fdd4 100644 > --- a/profiles/audio/media.c > +++ b/profiles/audio/media.c > @@ -1202,27 +1202,11 @@ static uint32_t get_duration(void *user_data) > static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) > { > struct media_player *mp = user_data; > - GSList *l; > > if (mp->volume == volume) > return; > > mp->volume = volume; > - > - for (l = mp->adapter->endpoints; l; l = l->next) { > - struct media_endpoint *endpoint = l->data; > - struct media_transport *transport; > - > - /* Volume is A2DP only */ > - if (endpoint->sep == NULL) > - continue; > - > - transport = find_device_transport(endpoint, dev); > - if (transport == NULL) > - continue; > - > - media_transport_update_volume(transport, volume); > - } > } > > static bool media_player_send(struct media_player *mp, const char *name) > -- > 2.27.0 > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8CORBRH3DF82eAEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 02:06:41 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 8Ow3BBH3DF9cUQEA0J78UA (envelope-from ); Tue, 14 Jul 2020 02:06:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D73FC52B99; Tue, 14 Jul 2020 02:06:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726432AbgGNAGe (ORCPT + 1 other); Mon, 13 Jul 2020 20:06:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgGNAGd (ORCPT ); Mon, 13 Jul 2020 20:06:33 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCAA3C061755 for ; Mon, 13 Jul 2020 17:06:33 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id 5so11143619oty.11 for ; Mon, 13 Jul 2020 17:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SQ3l4doeyUmx+JMK3G+1kNxMSGthKGgDrjcyPjOBTyg=; b=EhYPvviXqSCQUswVE4uzykuMhXDLWUEmQIptrvC2aoYHbqdqm8xHGByblxyud97Pob aaV4MJ7Q47kfUATrwyKaz6FjJpJrunvYilGkptUi99whTHmhAldFiLM2W0FuvkwPrRnz WJuQsDetGQfFQ1UuvkCgTjMcBa9UhUwTVFxLlOxbuJuq6BkUAIPhoNbAtxlIDvmLuQJV 4SwI0ZYEzcwlSkQH9+FgKlD249RTqdaVNgOlqItJo4bo70IjeXv2LOpbdb7QBxheirW0 fPEOBOkpdLFHFx0MZXifPaIjN/k4tdcAfTAjcXkDdO111WcomF4aj+y1J4DSLpX+QiEi LFOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SQ3l4doeyUmx+JMK3G+1kNxMSGthKGgDrjcyPjOBTyg=; b=IipPmJkilxw7jkTRrSOd4Qs05UPfg4VoclBw+YiYi55d9NNC1LKSABoDimfsGGFsQq X9mxaq29bwegO0i21HjzWK66WMc9XO64YQrECgKXZ2eopkMVDq8TkLqaxzHkaqX6Z58W 1dzNznD4pfukZghbSRz68axWCLdfGrIMmw/EpqL0cTHVUBZfwtN6M4uHzHRMO2hl0y0/ deuqZ4QXs9Ri+qh4wTiZyO+q6ii5ukc53mAKmITaeS8+a/5GpAyT7m/75gh5WPgQkZpQ fTKBopdS+Rr/vfQ+etuJqWofbHNO7/MZFHqKXz4g1MDxmADsKXEmpdTMMy5u4sfRvY19 RxZA== X-Gm-Message-State: AOAM530sWoyPPAc0ZXl+QvRK1JrFVR3Q5KtIhGI7w9DnOSuLk1M23gTU 6+Ypj2jJsWdjWsG5JYyrrd3Sb/3cA9T0NAkINFo= X-Google-Smtp-Source: ABdhPJyHcOi+dgzhLC72u0k6nDDUCHyz4XlmLN9sWqvfROiKg3DNKm7EKZ80f7BukArtBxoIb3ZNlW26gGRNacH58gM= X-Received: by 2002:a9d:5e18:: with SMTP id d24mr1850375oti.88.1594685193051; Mon, 13 Jul 2020 17:06:33 -0700 (PDT) MIME-Version: 1.0 References: <20200711115031.123793-1-marijns95@gmail.com> In-Reply-To: From: Luiz Augusto von Dentz Date: Mon, 13 Jul 2020 17:06:21 -0700 Message-ID: Subject: Re: [PATCH BlueZ] audio/avrcp: Always update transport volume regardless of player To: Marijn Suijten Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: D73FC52B99 X-Rspamd-UID: b382ec Hi Marijn, On Mon, Jul 13, 2020 at 5:05 PM Luiz Augusto von Dentz wrote: > > Hi Marijn, > > On Sat, Jul 11, 2020 at 4:50 AM Marijn Suijten wrote: > > > > `Volume` is a special property that not only exists on players but also > > on the transport (see org.bluez.MediaTransport1). A player is not > > attached when the controller does not support FEATURE_CATEGORY_1, which > > is common on headphones without media browsing capabilities. > > > > On such audio devices (headphones, in-ears and the like) Absolute Volume > > is not available unless an external player is registered > > (org.bluez.Media1.RegisterPlayer) and the device sends a volume event > > back after that to set a2dp->volume in transport.c to a valid value > > (causing volume_exists to finally return true). > > > > This [1] mail thread denoting the same issue has a solution to at least > > request capabilities from the controller, but the proposed player object > > is not created on category 2 devices. Any notifications received on > > AVRCP_EVENT_VOLUME_CHANGED (avrcp_volume_changed) that is subsequently > > registered, or handling the result of avrcp_set_volume in > > avrcp_handle_set_volume will be ignored unless said player is present. > > > > This issue is not addressed by adding a fake player but instead dealing > > with the fact that volume is "special" and available on the transport > > regardless of the existence of a player. This is confirmed in > > avrcp_get_capabilities_resp as well which requires a player to register > > any event except AVRCP_EVENT_VOLUME_CHANGED. > > > > The applied solution moves media_transport_update_device_volume out of > > the player and into avrcp_volume_changed/avrcp_handle_set_volume where > > it is unconditionally called. These functions are the only users of > > avrcp_player->set_volume. > > > > Note that the volume member of media_player is never used which seems a > > result of updating from org.bluez.MediaPlayer1 to > > org.mpris.MediaPlayer2.Player in > > 15e421737ccc4696ed567edcc24d178aedb47854, where the volume property [2] > > is left out. > > This is actually on purpose since the volume notification indicates > the volume at the device side we don't want to change the player > volume as well as it would most likely result in duplicating the > volume change both at sink and source, note that the likes of handling > the transport like pulseaudio would already notify the device volume > level change without actually applying any change to the volume > locally. > > > [1]: https://marc.info/?l=linux-bluetooth&m=145337574806153 > > [2]: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Volume > > > > --- > > Hi, > > > > This is is a resend from an earlier mail that didn't comply with the > > contributor guidelines. Seeing that the topic of AVRCP volume is brought > > up recently it is about time to repair it and hereby send it again. > > > > I still have an incomplete patch lying around that synchronizes Volume > > on org.mpris.MediaPlayer2.Player back when this patch was written 6 > > months ago. It'll require some time to get back in to it and finalize > > it, let me know if that's desired. > > > > - Marijn Suijten > > > > profiles/audio/avrcp.c | 12 ++++++++---- > > profiles/audio/media.c | 16 ---------------- > > 2 files changed, 8 insertions(+), 20 deletions(-) > > > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > > index e2428250e..8370c8a44 100644 > > --- a/profiles/audio/avrcp.c > > +++ b/profiles/audio/avrcp.c > > @@ -3625,12 +3625,13 @@ static void avrcp_volume_changed(struct avrcp *session, > > struct avrcp_player *player = target_get_player(session); > > uint8_t volume; > > > > - if (!player) > > - return; > > - > > volume = pdu->params[1] & 0x7F; > > > > - player->cb->set_volume(volume, session->dev, player->user_data); > > + /* Always update the transport volume, which is separate from the player */ > > + media_transport_update_device_volume(session->dev, volume); > > + > > + if (player) > > + player->cb->set_volume(volume, session->dev, player->user_data); > > } > > > > static void avrcp_status_changed(struct avrcp *session, > > @@ -4378,6 +4379,9 @@ static gboolean avrcp_handle_set_volume(struct avctp *conn, uint8_t code, > > > > volume = pdu->params[0] & 0x7F; > > > > + /* Always update the transport volume, which is separate from the player */ > > + media_transport_update_device_volume(session->dev, volume); > > + > > if (player != NULL) > > player->cb->set_volume(volume, session->dev, player->user_data); > > > > diff --git a/profiles/audio/media.c b/profiles/audio/media.c > > index 993ecb3b3..a0173fdd4 100644 > > --- a/profiles/audio/media.c > > +++ b/profiles/audio/media.c > > @@ -1202,27 +1202,11 @@ static uint32_t get_duration(void *user_data) > > static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) > > { > > struct media_player *mp = user_data; > > - GSList *l; > > > > if (mp->volume == volume) > > return; > > > > mp->volume = volume; > > - > > - for (l = mp->adapter->endpoints; l; l = l->next) { > > - struct media_endpoint *endpoint = l->data; > > - struct media_transport *transport; > > - > > - /* Volume is A2DP only */ > > - if (endpoint->sep == NULL) > > - continue; > > - > > - transport = find_device_transport(endpoint, dev); > > - if (transport == NULL) > > - continue; > > - > > - media_transport_update_volume(transport, volume); > > - } > > } > > > > static bool media_player_send(struct media_player *mp, const char *name) > > -- > > 2.27.0 > > Applied, Thanks. Note that I did fix some coding style problems. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wE8YLV76DF+aewEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 02:20:46 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id EKOKK176DF/v9wAA0J78UA (envelope-from ); Tue, 14 Jul 2020 02:20:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A8FAB5296A; Tue, 14 Jul 2020 02:20:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726364AbgGNAUj convert rfc822-to-8bit (ORCPT + 1 other); Mon, 13 Jul 2020 20:20:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:40880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbgGNAUj (ORCPT ); Mon, 13 Jul 2020 20:20:39 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 207629] BISECTED Bluetooth: hci0: command 0x2042 tx timeout - suspend fails - Dell XPS 9300, Dell XPS 7390, Dell Inspiron 7386, Intel NUC7JYB Date: Tue, 14 Jul 2020 00:20:38 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: todd.e.brandt@linux.intel.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: A8FAB5296A X-Rspamd-UID: 7f3163 https://bugzilla.kernel.org/show_bug.cgi?id=207629 --- Comment #26 from Todd Brandt (todd.e.brandt@linux.intel.com) --- Hi Pandit, I only used one patch on the 5.8.0-rc2 build, sorry. This time around a applied both patches and ran on 5.8.0-rc3 and 5.8.0-rc4 and am very happy to say the bug has completely disappeared! :) These are the machines that are now working (all that were affected): otcpl-dell-7386-whl otcpl-nuc-glk otcpl-cml-s-1 otcpl-dell-7390-cmlu otcpl-nuc-glk otcpl-cml-s-2 otcpl-cml-u So this fix is confirmed, thanks! -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2AZSBpo5DV88fgAAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 06:50:34 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id aEnMBJo5DV+GVgEAgupzMw (envelope-from ); Tue, 14 Jul 2020 06:50:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DBB1252C28; Tue, 14 Jul 2020 06:50:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725816AbgGNEuV (ORCPT + 1 other); Tue, 14 Jul 2020 00:50:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725306AbgGNEuV (ORCPT ); Tue, 14 Jul 2020 00:50:21 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD5F6C061755 for ; Mon, 13 Jul 2020 21:50:20 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id f2so19604089wrp.7 for ; Mon, 13 Jul 2020 21:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=37nDfESDIhoSwPGL6Glfvlv9L4EsPmHD+Xrex+aGhCw=; b=slrqG0LKVuw2+sgm/xQZ/zSENIZLGqfC9zsi2e658ICRh06VUviRn767AhOl4swsNI +hkNJ7K990qpd2rJ/bsn69rIxIj0pcxQb9t8mJRf7LkD8+rYYXmYHELfIf9dmfNPckFg HvoZJnjO3Z/TfU8vPMioLPET4gim6n/Z03Pd2FPbOYr6XNa6hJh/kwLs3+sHuabDYQwR kTJ5DI2TkraJSdSzglYiEakGXJec8KHzRUm+7NfqHqlGO0AJ58MzcxuTAhXMgT7TWPpC cs9/mUyfsThGu+WXaK8F87luPUT41aPfHZPpnlL1ib/nV7dqx5zQ3jnj5OxY3mmS79kk +r2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=37nDfESDIhoSwPGL6Glfvlv9L4EsPmHD+Xrex+aGhCw=; b=eJAYODPc/ORdGn548lOvP2XnJ0HYsxpSj7gNEDl3uGQLMBz3mlrU5bhj+1aiNWD10Q 8wEHiLNCcOStqTNfzGv1VXgJvtTQwDXI4viNsj6hvjH0PDoVYKGD9G7V5SJvIvGKX7eZ hHztTwmp0QGYQl3CeH+W+zNXOmrt45PwO3FqZVvrF6P5AEao9x0X8IL1zT/xigGuUypx k0PppUYFdMkzUWPZiR0kiD7ZIcesdcE//hVCfCEoXN54t4AwQeBc9vvTzcq10dYKjLc2 mIMTD2nNb0ad3zlc6uHiVETnosRwy4iNbDVC+OYa2jSHitLHhle5GsYITXGGhSJJ30f5 Aw8w== X-Gm-Message-State: AOAM533fYxJGLQKICxq++a/XqUkHvO206tNYJ2f5XhHiqlbjr7XJw0rv HsyVtvzVxcOEoHkj1Y07AsCGeHMjUZ6HGwYgMVdgww== X-Google-Smtp-Source: ABdhPJxFO0y0DYtljKyb41i+o7qC8yNnuOIHNUfcvvRxKBr/ZJdlzUvhU3CN/LMGNQGA8mEgP+k5ITQGggPQAouVj/w= X-Received: by 2002:a5d:6342:: with SMTP id b2mr2957173wrw.262.1594702219246; Mon, 13 Jul 2020 21:50:19 -0700 (PDT) MIME-Version: 1.0 References: <20200627235318.Bluez.v2.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> In-Reply-To: From: Archie Pusaka Date: Tue, 14 Jul 2020 12:50:08 +0800 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] device: add device_remove_bonding function To: Luiz Augusto von Dentz Cc: linux-bluetooth , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: DBB1252C28 X-Rspamd-UID: 2aaab9 [Sorry, re-sending in plain text] Hi Luiz, Can I have your opinion on this? Thanks, Archie On Wed, 8 Jul 2020 at 12:30, Archie Pusaka wrote: > > Hi Luiz, > > As far as the spec is concerned, we can also remove the device by > calling device_remove. However, I suppose it would be confusing for > end users if they can no longer find their HID device on the device > list just because the device previously sent a virtual cable > disconnection. > The HID 1.0 spec part 6.4.2 also gives an example of a possible > scenario when a virtually cabled device is removed: "Unplugged devices > shall be marked as known and put into a =E2=80=9Cmost recently used list= =E2=80=9D of > known devices to facilitate future re-connecting". > > Thanks, > Archie > > > On Wed, 8 Jul 2020 at 02:03, Luiz Augusto von Dentz > wrote: > > > > Hi Archie, > > > > On Sat, Jun 27, 2020 at 8:54 AM Archie Pusaka wrot= e: > > > > > > From: Archie Pusaka > > > > > > This patch splits the "bonding removal" function in device.c, > > > because we need to remove bonding information when receiving > > > "virtual cable unplug" in HID profile. > > > > > > Reviewed-by: Alain Michaud > > > --- > > > > > > Changes in v2: None > > > > > > src/device.c | 25 +++++++++++++++---------- > > > src/device.h | 1 + > > > 2 files changed, 16 insertions(+), 10 deletions(-) > > > > > > diff --git a/src/device.c b/src/device.c > > > index 7b0eb256e..9fb0e018c 100644 > > > --- a/src/device.c > > > +++ b/src/device.c > > > @@ -4162,6 +4162,17 @@ static void delete_folder_tree(const char *dir= name) > > > rmdir(dirname); > > > } > > > > > > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr= _type) > > > +{ > > > + if (bdaddr_type =3D=3D BDADDR_BREDR) > > > + device->bredr_state.bonded =3D false; > > > + else > > > + device->le_state.bonded =3D false; > > > + > > > + btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > > > + bdaddr_type); > > > +} > > > + > > > static void device_remove_stored(struct btd_device *device) > > > { > > > char device_addr[18]; > > > @@ -4170,17 +4181,11 @@ static void device_remove_stored(struct btd_d= evice *device) > > > char *data; > > > gsize length =3D 0; > > > > > > - if (device->bredr_state.bonded) { > > > - device->bredr_state.bonded =3D false; > > > - btd_adapter_remove_bonding(device->adapter, &device->= bdaddr, > > > - BDADD= R_BREDR); > > > - } > > > + if (device->bredr_state.bonded) > > > + device_remove_bonding(device, BDADDR_BREDR); > > > > > > - if (device->le_state.bonded) { > > > - device->le_state.bonded =3D false; > > > - btd_adapter_remove_bonding(device->adapter, &device->= bdaddr, > > > - device->bdadd= r_type); > > > - } > > > + if (device->le_state.bonded) > > > + device_remove_bonding(device, device->bdaddr_type); > > > > > > device->bredr_state.paired =3D false; > > > device->le_state.paired =3D false; > > > diff --git a/src/device.h b/src/device.h > > > index 06b100499..907c7c5c4 100644 > > > --- a/src/device.h > > > +++ b/src/device.h > > > @@ -49,6 +49,7 @@ uint16_t btd_device_get_vendor(struct btd_device *d= evice); > > > uint16_t btd_device_get_vendor_src(struct btd_device *device); > > > uint16_t btd_device_get_product(struct btd_device *device); > > > uint16_t btd_device_get_version(struct btd_device *device); > > > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr= _type); > > > void device_remove(struct btd_device *device, gboolean remove_stored= ); > > > > Is there any particular reason why device_remove is not enough here? I > > don't see any reason to leave the device object around after removing > > its bonding. > > > > > int device_address_cmp(gconstpointer a, gconstpointer b); > > > int device_bdaddr_cmp(gconstpointer a, gconstpointer b); > > > -- > > > 2.27.0.212.ge8ba1cc988-goog > > > > > > > > > -- > > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GDiyNHlCDV+ZrQAAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 07:28:25 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OHAVM3lCDV9RzgAADc0bRg (envelope-from ); Tue, 14 Jul 2020 07:28:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 59EA7A59E5; Tue, 14 Jul 2020 07:28:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725788AbgGNF2R (ORCPT + 1 other); Tue, 14 Jul 2020 01:28:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgGNF2R (ORCPT ); Tue, 14 Jul 2020 01:28:17 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FA48C061755 for ; Mon, 13 Jul 2020 22:28:17 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id w17so13000891oie.6 for ; Mon, 13 Jul 2020 22:28:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vNck8jTr4IDyVc41d1w3ipAipUYDAOgWf+jO0QBQkwU=; b=YJOpGcguktLTUc5nhkqbnw1bO25L060bP3Q9xToBO3siA9y50Iq/s2a6XJHaVjqzih zV6UnW+hK4XQ/OUKWT6dNACeujAZj1asxmBBpmusoSj8smrv+VDbiJqG0kIeFhDNp67I J+Qv5pRhCiAK7VUn2vcXu/0FM2jPLGvTOR16X6lE9ou195kbnXaLFzrkkqfkH0oJVPCm 8xWQageVgNxhIEoEUmLn+bBXatVyQ9bvlleiZC7956iy1eSgFxCQWZ1SE0FJwhUm1Cg2 7K8Y0NuRH/qraaIrNtnL4ikcacz7poU271yKVOcqm/Tt/ekloMbRg4dbsut2ZP3otCHh +rjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vNck8jTr4IDyVc41d1w3ipAipUYDAOgWf+jO0QBQkwU=; b=GcziryELx4AzCAi4viOKzTmiluP1Vwv/ezCt3K7bMYY9dVW5wEcXkULnXsmZ7L8mUK wjBRBWONROlV5gOT50tdFKI7iKkNxM+xJU+X7KjT1AgycRv+Lt5WUFddE5MG+Kp9dPDr i/ghnigv8+jsp7452bay4rZmvrsr6UUViZ3+jTEUnhi3o2OQPBOzpZx919ArAiOKHfbl IP3QFY5oMKZJ5v6scPV6mCRm9ZfYNhupHZ8kj4vIoQv+ztXiUbmm3GyY+OSHwQ9xnwJU wFNSVlU5BVzDVAKXhhkm7RozYrdKLkrCsRV/mmeIVdHWOXU2ib/LEp9XDAxIdoVIhzZa YvrQ== X-Gm-Message-State: AOAM531lJ23m5gj7arN/foy9PKoGpKA76b4M0FwYAgvqB/wSxZEPc8pm jgMjhYCA0NZM2yT6gata5zaH6jc65ya3AEhimGmsCwukaCg= X-Google-Smtp-Source: ABdhPJy5y0s9o7YKMwll3xqMUS/ChpDyIKzhYmGHR0G5m4GxQHhVIVb0MmCMDGtmH+ByJMMFRadNnwq/vSo57Rm2fPI= X-Received: by 2002:aca:cf81:: with SMTP id f123mr2434681oig.137.1594704496627; Mon, 13 Jul 2020 22:28:16 -0700 (PDT) MIME-Version: 1.0 References: <20200713201441.235959-1-sonnysasaka@chromium.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Mon, 13 Jul 2020 22:28:05 -0700 Message-ID: Subject: Re: [PATCH BlueZ 0/3] Per-device option to enable/disable internal profiles To: Sonny Sasaka Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 59EA7A59E5 X-Rspamd-UID: e7d558 Hi Sonny, On Mon, Jul 13, 2020 at 4:48 PM Sonny Sasaka wrote: > > Hi Luiz, > > On Mon, Jul 13, 2020 at 3:59 PM Luiz Augusto von Dentz > wrote: > > > > Hi Sonny, > > > > On Mon, Jul 13, 2020 at 3:04 PM Sonny Sasaka wrote: > > > > > > Hi Luiz, > > > > > > I considered having such an approach that gives exception to some > > > profile to not claim exclusive access. However, I think that this > > > approach has a drawback that it can only be guaranteed to work > > > correctly for profiles that contain only read-only attributes. Any > > > profile that contains writable attributes, naturally, cannot be > > > guaranteed to always work correctly (as is the case with the Battery > > > profile). Therefore, the usefulness of that feature will be very > > > limited. > > > > > > I also considered the benefits of the AllowInternalProfiles approach: > > > * Applications can also have control over any profile, not just > > > Battery profile. For example, if in the future BlueZ has more internal > > > profiles, like (Blood Pressure Profile or any other profile that may > > > contain writable attributes), we can guarantee that applications can > > > still opt to have access to that profile, without relying on a profile > > > being "safe" to be shared by both BlueZ's internal and external > > > handlers. > > > * This has an added security benefit: applications which operate on a > > > specific GATT profile will not unintentionally activate internal > > > profiles such as HOG (which is able to hijack input control of the > > > host). This is the correct and expected behavior of Android apps that > > > connect over GATT and get access to a GATT profile. > > > > Not sure I follow these arguments, it seems AllowInternalProfiles may > > actually enable hijacking the profiles so I wonder if you got this > > backwards as we can't let things like HoG be controlled by > > applications directly it would be too easy to implement something like > > a keylogger, or perhaps you are suggesting that there is another layer > > for implementing the profiles? Note that it is intended that plugins > > shall be used for profiles that need to be integrated system wide, > > D-Bus interface shall be restricted to only application specific > > profiles. > > I think you misunderstood my point about HOG hijacking. Consider the > following case: > 1. A legit application (not System UI) on a host computer scans and > connects to a nearby peer. It makes a guess about the peer device > based on its advertising data. It intends to operate on a specific > GATT profile (not necessarily Battery). > 2. The peer device turns out to be malicious. It runs HOG GATT server > and triggers the host's HOG profile to be active. > 3. The malicious peer device's HOG GATT server can now maliciously > make mouse movements or enter keystrokes to the host. I'm not sure how you would like to prevent that, we could in theory attempt to authorize every single profile before connecting, just like it is done for legacy, but Im sure system would not be asking the user what profiles to connect so they just end up trusting the device, alternatively we could make ConnectProfile to work also for LE so you can provide a UUID and nothing else would be exposed, but note that this guess on the AD may actually be wrong and the device may end up malfunctioning. > In this case the user is considered being attacked, because he/she > doesn't consciously interact with the System UI to connect to a nearby > mouse/keyboard. > My example doesn't have to be HOG. It just happens to be a profile > which is attackable at the moment. My point is that, for applications > it's always safest to turn off all internal profiles to avoid such > incident. There is no use case where applications want to trigger > internal profiles. > > Note 1: By "applications", I mean things like Android apps or > JavaScript apps which are not considered System's Bluetooth UI. Well that doesn't make my point moot, let's say we do enable connecting by UUID and the application try to connect HoG, it could be a malicious application trying to eavesdrop what the user is typing, so this problem of malicious goes both ways Im afraid, besides the performance penalty that one would have if we need to transport HID over D-Bus. More applications could be involved and then this all becomes a mess if they have to fight over AllowInternalProfiles, so instead of using a theoretical example we better find real apps and devices where conflicts happens and work out case by case, adding ConnectProfile should actually fix most of them if there is a single profile involved by we could also thing about an alternative to connect multiples. There is also the possibility of exposing the btd_service as objects, I've actually had this implemented for the car industry, that way AutoConnect property could actually be controlled on a per service basis instead of having just one switch for everything. > > > > Note that we do allow external profiles to be registered with use of: > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/profile-api.txt > > > > And for GATT: > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt#n366 > > > > We could perhaps make the assumption that once an application > > registers itself as supporting a given profile we check if against a > > blacklist of profiles that may have security implications, which > > perhaps could be defined via main.conf or some other file, if that is > > not the case the internal profile can be disabled and the D-Bus object > > would be accessible over D-Bus. Also note that we do offer clients the > > ability to have exclusive access with AcquireWrite and AcquireNotify. > > > > > Therefore I think that this approach, although more complex, has > > > longer lasting benefits. Let me know if you have any objection to > > > having such a feature. > > > > > > > > > On Mon, Jul 13, 2020 at 1:35 PM Luiz Augusto von Dentz > > > wrote: > > > > > > > > Hi Sonny, > > > > > > > > On Mon, Jul 13, 2020 at 1:18 PM Sonny Sasaka wrote: > > > > > > > > > > This patch series adds a mechanism for clients to choose whether to > > > > > enable BlueZ internal profiles (e.g. A2DP, Battery) for specific > > > > > devices. > > > > > > > > > > The motivation behind this feature is that some applications (e.g. Web > > > > > Bluetooth or Android apps) need to have control over all remove GATT > > > > > services, like Battery service. With "battery" plugin being enabled on > > > > > BlueZ, it becomes not possible for those apps to work properly because > > > > > BlueZ "hides" the Battery-related attributes from its GATT Client API. > > > > > Disabling the "battery" plugin won't solve the problem either, since we > > > > > do also need to enable the plugin so that we can use org.bluez.Battery1 > > > > > API. > > > > > > > > > > The solution that we propose is that clients can choose whether to > > > > > enable internal profiles for each device. Clients know when to enable > > > > > internal profiles (such as when a user chooses to pair/connect via a UI) > > > > > and when to disable internal profiles (such as when the connection is > > > > > initiated by a generic application). > > > > > > > > I wonder if it is not better to just have a flag indicating if the > > > > profile shall claim exclusive access (such as GAP and GATT services), > > > > so profiles that don't set that will have the services exposed so for > > > > battery we can probably just have it exposed by default since it > > > > doesn't appear to would be any conflicts on having it exposed. > > > > > > > > > Sonny Sasaka (3): > > > > > doc: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > device: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > client: Add set-allow-internal-profiles command > > > > > > > > > > client/main.c | 38 ++++++++++++++++++ > > > > > doc/device-api.txt | 13 +++++++ > > > > > src/device.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ > > > > > src/hcid.h | 2 + > > > > > src/main.c | 10 +++++ > > > > > src/main.conf | 4 ++ > > > > > 6 files changed, 163 insertions(+) > > > > > > > > > > -- > > > > > 2.26.2 > > > > > > > > > > > > > > > > > -- > > > > Luiz Augusto von Dentz > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AFQDEhaoDV/vhwEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 14:41:58 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YHBbEBaoDV94GwEAgupzMw (envelope-from ); Tue, 14 Jul 2020 14:41:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 530EAA30A9; Tue, 14 Jul 2020 14:41:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728066AbgGNMlX (ORCPT + 1 other); Tue, 14 Jul 2020 08:41:23 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:32916 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726354AbgGNMlX (ORCPT ); Tue, 14 Jul 2020 08:41:23 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id F1F208030809; Tue, 14 Jul 2020 12:41:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wvIaP-V6CogS; Tue, 14 Jul 2020 15:41:18 +0300 (MSK) From: Serge Semin To: Greg Kroah-Hartman , Jiri Slaby , Matthias Brugger CC: Serge Semin , Serge Semin , Daniel Winkler , Alexey Malahov , Aaron Sierra , Andy Shevchenko , Lukas Wunner , Vignesh Raghavendra , , , BlueZ , chromeos-bluetooth-upstreaming , , , , Subject: [PATCH] serial: 8250_mtk: Fix high-speed baud rates clamping Date: Tue, 14 Jul 2020 15:41:12 +0300 Message-ID: <20200714124113.20918-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 14 X-Rspamd-Score: 2.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 530EAA30A9 X-Rspamd-UID: b742da Commit 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 port") fixed limits of a baud rate setting for a generic 8250 port. In other words since that commit the baud rate has been permitted to be within [uartclk / 16 / UART_DIV_MAX; uartclk / 16], which is absolutely normal for a standard 8250 UART port. But there are custom 8250 ports, which provide extended baud rate limits. In particular the Mediatek 8250 port can work with baud rates up to "uartclk" speed. Normally that and any other peculiarity is supposed to be handled in a custom set_termios() callback implemented in the vendor-specific 8250-port glue-driver. Currently that is how it's done for the most of the vendor-specific 8250 ports, but for some reason for Mediatek a solution has been spread out to both the glue-driver and to the generic 8250-port code. Due to that a bug has been introduced, which permitted the extended baud rate limit for all even for standard 8250-ports. The bug has been fixed by the commit 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 port") by narrowing the baud rates limit back down to the normal bounds. Unfortunately by doing so we also broke the Mediatek-specific extended bauds feature. A fix of the problem described above is twofold. First since we can't get back the extended baud rate limits feature to the generic set_termios() function and that method supports only a standard baud rates range, the requested baud rate must be locally stored before calling it and then restored back to the new termios structure after the generic set_termios() finished its magic business. By doing so we still use the serial8250_do_set_termios() method to set the LCR/MCR/FCR/etc. registers, while the extended baud rate setting procedure will be performed later in the custom Mediatek-specific set_termios() callback. Second since a true baud rate is now fully calculated in the custom set_termios() method we need to locally update the port timeout by calling the uart_update_timeout() function. After the fixes described above are implemented in the 8250_mtk.c driver, the Mediatek 8250-port should get back to normally working with extended baud rates. Link: https://lore.kernel.org/linux-serial/20200701211337.3027448-1-danielwinkler@google.com Fixes: 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 port") Reported-by: Daniel Winkler Signed-off-by: Serge Semin --- Folks, sorry for a delay with the problem fix. A solution is turned out to be a bit more complicated than I originally thought in my comment to the Daniel revert-patch. Please also note, that I don't have a Mediatek hardware to test the solution suggested in the patch. The code is written as on so called the tip of the pen after digging into the 8250_mtk.c and 8250_port.c drivers code. So please Daniel or someone with Mediatek 8250-port available on a board test this patch first and report about the results in reply to this emailing thread. After that, if your conclusion is positive and there is no objection against the solution design the patch can be merged in. Cc: Alexey Malahov Cc: Daniel Winkler Cc: Aaron Sierra Cc: Andy Shevchenko Cc: Lukas Wunner Cc: Vignesh Raghavendra Cc: linux-serial@vger.kernel.org Cc: linux-mediatek@lists.infradead.org Cc: BlueZ Cc: chromeos-bluetooth-upstreaming Cc: abhishekpandit@chromium.org Cc: stable@vger.kernel.org --- drivers/tty/serial/8250/8250_mtk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c index f839380c2f4c..98b8a3e30733 100644 --- a/drivers/tty/serial/8250/8250_mtk.c +++ b/drivers/tty/serial/8250/8250_mtk.c @@ -306,8 +306,21 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, } #endif + /* + * Store the requested baud rate before calling the generic 8250 + * set_termios method. Standard 8250 port expects bauds to be + * no higher than (uartclk / 16) so the baud will be clamped if it + * gets out of that bound. Mediatek 8250 port supports speed + * higher than that, therefore we'll get original baud rate back + * after calling the generic set_termios method and recalculate + * the speed later in this method. + */ + baud = tty_termios_baud_rate(termios); + serial8250_do_set_termios(port, termios, old); + tty_termios_encode_baud_rate(termios, baud, baud); + /* * Mediatek UARTs use an extra highspeed register (MTK_UART_HIGHS) * @@ -339,6 +352,11 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, */ spin_lock_irqsave(&port->lock, flags); + /* + * Update the per-port timeout. + */ + uart_update_timeout(port, termios->c_cflag, baud); + /* set DLAB we have cval saved in up->lcr from the call to the core */ serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB); serial_dl_write(up, quot); -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6FLSAWXgDV98dQEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 18:42:13 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id MH1SAGXgDV9NhwEAlp8NpQ (envelope-from ); Tue, 14 Jul 2020 18:42:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E425FA590D; Tue, 14 Jul 2020 18:42:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728688AbgGNQlz (ORCPT + 1 other); Tue, 14 Jul 2020 12:41:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbgGNQlx (ORCPT ); Tue, 14 Jul 2020 12:41:53 -0400 Received: from mail-ua1-x942.google.com (mail-ua1-x942.google.com [IPv6:2607:f8b0:4864:20::942]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E9BC061755 for ; Tue, 14 Jul 2020 09:41:53 -0700 (PDT) Received: by mail-ua1-x942.google.com with SMTP id p6so5895403uaq.12 for ; Tue, 14 Jul 2020 09:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ab7n3z5mmwJTrVdm4I/Qk+EgWW2BK5sF3S4Gs9LC2pU=; b=VHZOUHrVRhNSrg3KXXZP+GAKYukKuZJqUkm5rQjUQ1ljdD3rJiZmHJ9JBEZxI/gQ78 LdVSaAcjIaGH2WHm3B6K1fnEsO+RpwuJIMwNVJZg0DwnljFT9vzkoAWDwNWe+zXSrjao IpMj2M0CS/PRNwwFHxaGEGojTVKjZxRItENog= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ab7n3z5mmwJTrVdm4I/Qk+EgWW2BK5sF3S4Gs9LC2pU=; b=OiPmz2hd34EoTtE+3hiXVe+CINBOlKMBwRnR29t4Ogv/7sCOgA6np2OSlywwTDjOaK d+XWruQ1OEkPiUBlc1McKC27dotbAMZbdUySJqVzEODwbC7tCX7jz7SUazvC6RfIRkFz cA6nDLukpF1219VY0TUWX0i/KffmBNN88TeapakRQuxpMIOso35lWTv+gC51koIfW2Ah kaPhcjdKtt0Iv93WgJ1UOGf5ISiD/i7rIO3kjrBAMpp/OoI058ufxbgu9s/OWcEI5qhR RD1FRDq9Kn5xZmxtyx9s5adr1kc50n8gSRqUq4wV74mn3fbh+1vF9BPQ/acvVhCWHB1j F0Xw== X-Gm-Message-State: AOAM53263dAbo3GyuwMRN4Cm3eq+I4AiRzOB0lDgICWmlRueTR5abqSN aolD+/9ye2DJcnXSk6uo2BvVeM05xI59eitHMKct3Q== X-Google-Smtp-Source: ABdhPJyXVJ/fLtTJ5u5u/TYEyFxPBC2v7sTjbhSHP3mdXvobPVLvPRM7juHvP/wKZQeY+BIpC4A3UhZVueVzzEMcOHI= X-Received: by 2002:ab0:6f0a:: with SMTP id r10mr4847028uah.100.1594744912382; Tue, 14 Jul 2020 09:41:52 -0700 (PDT) MIME-Version: 1.0 References: <20200706140715.v2.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> <20200714052941.GB3874@shao2-debian> In-Reply-To: <20200714052941.GB3874@shao2-debian> From: Abhishek Pandit-Subedi Date: Tue, 14 Jul 2020 09:41:41 -0700 Message-ID: Subject: Re: [power] 47b918cf9a: kmsg.power_supply_ADP1:Error_in_uevent_for_wakeup_sysfs_add To: kernel test robot Cc: Linux PM , Bluez mailing list , ChromeOS Bluetooth Upstreaming , Rafael Wysocki , Stephen Boyd , "Rafael J. Wysocki" , LKML , Len Brown , Greg Kroah-Hartman , Pavel Machek , lkp@lists.01.org, yu.c.chen@intel.com, "Zhang, Rui" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: E425FA590D X-Rspamd-UID: c9508a This version of the patch was not merged and the message above doesn't exist in the merged patch: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/commit/?h=bleeding-edge&id=9a3e9e6ff6d7f6b8ce7903893962d50adcbe82d2 The err log was emitted during boot as well and is innocuous since the power_supply initializes fully in the next line: kern :err : [ 5.918034] power_supply ADP1: Error in uevent for wakeup_sysfs_add: -11 kern :info : [ 5.918300] ACPI: AC Adapter [ADP1] (on-line) Abhishek On Mon, Jul 13, 2020 at 10:30 PM kernel test robot wrote: > > Greeting, > > FYI, we noticed the following commit (built with gcc-9): > > commit: 47b918cf9a1d2b6e36706fd2be2b91e65f490146 ("[PATCH v2 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove") > url: https://github.com/0day-ci/linux/commits/Abhishek-Pandit-Subedi/power-Emit-changed-uevent-on-wakeup_sysfs_add-remove/20200707-050912 > base: https://git.kernel.org/cgit/linux/kernel/git/rafael/linux-pm.git linux-next > > in testcase: suspend-stress > with following parameters: > > mode: freeze > iterations: 10 > > > > on test machine: 4 threads Ivy Bridge with 4G memory > > caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace): > > > > > If you fix the issue, kindly add following tag > Reported-by: kernel test robot > > > > kern :debug : [ 5.917685] calling acpi_ac_init+0x0/0xa3 @ 1 > kern :err : [ 5.918034] power_supply ADP1: Error in uevent for wakeup_sysfs_add: -11 > kern :info : [ 5.918300] ACPI: AC Adapter [ADP1] (on-line) > kern :debug : [ 5.918500] initcall acpi_ac_init+0x0/0xa3 returned 0 after 609 usecs > kern :debug : [ 5.918725] calling acpi_button_driver_init+0x0/0x53 @ 1 > kern :info : [ 5.919006] input: Power Button as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input0 > kern :info : [ 5.919367] ACPI: Power Button [PWRB] > kern :info : [ 5.919580] input: Lid Switch as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0D:00/input/input1 > kern :info : [ 5.919927] ACPI: Lid Switch [LID] > kern :info : [ 5.920131] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input2 > kern :info : [ 5.920455] ACPI: Power Button [PWRF] > kern :debug : [ 5.920644] initcall acpi_button_driver_init+0x0/0x53 returned 0 after 1669 usecs > kern :debug : [ 5.920944] calling acpi_fan_driver_init+0x0/0x13 @ 1 > kern :debug : [ 5.921155] initcall acpi_fan_driver_init+0x0/0x13 returned 0 after 11 usecs > kern :debug : [ 5.921388] calling acpi_processor_driver_init+0x0/0xb7 @ 1 > kern :debug : [ 5.921905] initcall acpi_processor_driver_init+0x0/0xb7 returned 0 after 299 usecs > kern :debug : [ 5.922203] calling acpi_thermal_init+0x0/0x82 @ 1 > kern :info : [ 5.922755] thermal LNXTHERM:00: registered as thermal_zone0 > kern :info : [ 5.922977] ACPI: Thermal Zone [TZ01] (16 C) > kern :debug : [ 5.923177] initcall acpi_thermal_init+0x0/0x82 returned 0 after 759 usecs > kern :debug : [ 5.923409] calling acpi_battery_init+0x0/0x39 @ 1 > kern :debug : [ 5.923606] initcall acpi_battery_init+0x0/0x39 returned 0 after 4 usecs > kern :debug : [ 5.923841] calling acpi_hed_driver_init+0x0/0x11 @ 1 > kern :debug : [ 5.924075] initcall acpi_hed_driver_init+0x0/0x11 returned 0 after 32 usecs > kern :info : [ 5.924178] battery: ACPI: Battery Slot [BAT1] (battery present) > kern :debug : [ 5.924309] calling bgrt_init+0x0/0xbe @ 1 > kern :debug : [ 5.924312] initcall bgrt_init+0x0/0xbe returned -19 after 0 usecs > kern :debug : [ 5.924928] calling erst_init+0x0/0x309 @ 1 > kern :debug : [ 5.925110] initcall erst_init+0x0/0x309 returned 0 after 0 usecs > kern :debug : [ 5.925325] calling ghes_init+0x0/0xe5 @ 1 > kern :debug : [ 5.925504] initcall ghes_init+0x0/0xe5 returned -19 after 0 usecs > kern :debug : [ 5.925721] calling erst_dbg_init+0x0/0x2c @ 1 > kern :info : [ 5.925912] ERST DBG: ERST support is disabled. > > > > To reproduce: > > git clone https://github.com/intel/lkp-tests.git > cd lkp-tests > bin/lkp install job.yaml # job file is attached in this email > bin/lkp run job.yaml > > > > Thanks, > Rong Chen > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aLtMK/nmDV9YnQEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 19:10:17 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AOCvKfnmDV/FJgAAgupzMw (envelope-from ); Tue, 14 Jul 2020 19:10:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3B631A296F; Tue, 14 Jul 2020 19:10:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727028AbgGNRKK (ORCPT + 1 other); Tue, 14 Jul 2020 13:10:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbgGNRKJ (ORCPT ); Tue, 14 Jul 2020 13:10:09 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA611C061755 for ; Tue, 14 Jul 2020 10:10:09 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id 18so13563679otv.6 for ; Tue, 14 Jul 2020 10:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=wZ225EF+OkAAsyxWL9/lOWbhPOMvqnQib3F5lTrCkho=; b=EwyPLZj1k8QMnRROeJbtHVgVX33zeKb6gZ7U1WCFLFR02ZYsZLX5HukLKpy0t9pAga VrHVNQUAJ7QPQvN1Xwp2yMQoecHM5P5oRg78LzWcpI5/Y93kGOvakdoM5KBlOHPIlv5M DtLsE2YVOyOZWeBE/nQPw4CIjtmiALYX065zvR2lytzTe0Z7BEY5zun6qFifl/rLyVSj S91LJI/b2XE2RpBreBAtB9qfmxJneal5g6wU2K0ON7sI+9HYhC8nW4pfyVjlvye6WGpD ztxWj/bH3I3DBC/gHXJQU6d/J3/8OHg359Qo1w/XFZXoJLhJiqoBRoeMUGwreoBaApMY kv5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=wZ225EF+OkAAsyxWL9/lOWbhPOMvqnQib3F5lTrCkho=; b=np9winhAMjc1xPh9FFV9tsSklVwnvZ+lxoMHPadF4Y9i9ttnAstSUXxz1caONxFbNA pPrQh7ODIUn+C69/TMRLakq4fY267OziDnesI6rWieqnnXcyzeziBF2VSH2eCN87VKSr TUX+7IJ7kVlvZAE3ScMs6qIYDKvFiGr4sq1Oidm9psJhCnDYRnGP1EaTqbgI91ECquIe 9W7hpdzcW5NvAa4gPRbhFo7X1meuJ6uHoaLcx76m4eyB7z/tdPiwx1BIyR+L1TWgD3Rj S2T/Wa01Rycpd8m5Ekk3Gnc53bdMc3CmMp4tux8phcmPIaGYYJfYkAQ5+zlpAAlLGWou nClQ== X-Gm-Message-State: AOAM531Qmo+d31VShzwmnIu5aLxe4H/mPqIwNpbWiktQ3hLgkkY2sEV9 hdBk+Gr66oqrFHJWlGOyDpmwEd7dD9dOezzO7QOWRqcZ X-Google-Smtp-Source: ABdhPJxBOMLainKilL0xte4NzLnpv3DXC6wbXjK7MKobehG/vHbACpUMUV6YTKVkijKj4BdAiigKLgs97g5UTBaG7d8= X-Received: by 2002:a05:6830:1bd3:: with SMTP id v19mr4954618ota.91.1594746609062; Tue, 14 Jul 2020 10:10:09 -0700 (PDT) MIME-Version: 1.0 References: <20200627235318.Bluez.v2.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> In-Reply-To: From: Luiz Augusto von Dentz Date: Tue, 14 Jul 2020 10:09:57 -0700 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] device: add device_remove_bonding function To: Archie Pusaka Cc: linux-bluetooth , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3B631A296F X-Rspamd-UID: 8b6558 Hi Archie, On Tue, Jul 7, 2020 at 9:30 PM Archie Pusaka wrote: > > Hi Luiz, > > As far as the spec is concerned, we can also remove the device by > calling device_remove. However, I suppose it would be confusing for > end users if they can no longer find their HID device on the device > list just because the device previously sent a virtual cable > disconnection. > The HID 1.0 spec part 6.4.2 also gives an example of a possible > scenario when a virtually cabled device is removed: "Unplugged devices > shall be marked as known and put into a =E2=80=9Cmost recently used list= =E2=80=9D of > known devices to facilitate future re-connecting". Then perhaps we shall have it marked as temporary as well, that said we do want to introduce disappearing logic so temporary devices are not left dangling for too long. > Thanks, > Archie > > > On Wed, 8 Jul 2020 at 02:03, Luiz Augusto von Dentz > wrote: > > > > Hi Archie, > > > > On Sat, Jun 27, 2020 at 8:54 AM Archie Pusaka wrot= e: > > > > > > From: Archie Pusaka > > > > > > This patch splits the "bonding removal" function in device.c, > > > because we need to remove bonding information when receiving > > > "virtual cable unplug" in HID profile. > > > > > > Reviewed-by: Alain Michaud > > > --- > > > > > > Changes in v2: None > > > > > > src/device.c | 25 +++++++++++++++---------- > > > src/device.h | 1 + > > > 2 files changed, 16 insertions(+), 10 deletions(-) > > > > > > diff --git a/src/device.c b/src/device.c > > > index 7b0eb256e..9fb0e018c 100644 > > > --- a/src/device.c > > > +++ b/src/device.c > > > @@ -4162,6 +4162,17 @@ static void delete_folder_tree(const char *dir= name) > > > rmdir(dirname); > > > } > > > > > > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr= _type) > > > +{ > > > + if (bdaddr_type =3D=3D BDADDR_BREDR) > > > + device->bredr_state.bonded =3D false; > > > + else > > > + device->le_state.bonded =3D false; > > > + > > > + btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > > > + bdaddr_type); > > > +} > > > + > > > static void device_remove_stored(struct btd_device *device) > > > { > > > char device_addr[18]; > > > @@ -4170,17 +4181,11 @@ static void device_remove_stored(struct btd_d= evice *device) > > > char *data; > > > gsize length =3D 0; > > > > > > - if (device->bredr_state.bonded) { > > > - device->bredr_state.bonded =3D false; > > > - btd_adapter_remove_bonding(device->adapter, &device->= bdaddr, > > > - BDADD= R_BREDR); > > > - } > > > + if (device->bredr_state.bonded) > > > + device_remove_bonding(device, BDADDR_BREDR); > > > > > > - if (device->le_state.bonded) { > > > - device->le_state.bonded =3D false; > > > - btd_adapter_remove_bonding(device->adapter, &device->= bdaddr, > > > - device->bdadd= r_type); > > > - } > > > + if (device->le_state.bonded) > > > + device_remove_bonding(device, device->bdaddr_type); > > > > > > device->bredr_state.paired =3D false; > > > device->le_state.paired =3D false; > > > diff --git a/src/device.h b/src/device.h > > > index 06b100499..907c7c5c4 100644 > > > --- a/src/device.h > > > +++ b/src/device.h > > > @@ -49,6 +49,7 @@ uint16_t btd_device_get_vendor(struct btd_device *d= evice); > > > uint16_t btd_device_get_vendor_src(struct btd_device *device); > > > uint16_t btd_device_get_product(struct btd_device *device); > > > uint16_t btd_device_get_version(struct btd_device *device); > > > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr= _type); > > > void device_remove(struct btd_device *device, gboolean remove_stored= ); > > > > Is there any particular reason why device_remove is not enough here? I > > don't see any reason to leave the device object around after removing > > its bonding. > > > > > int device_address_cmp(gconstpointer a, gconstpointer b); > > > int device_bdaddr_cmp(gconstpointer a, gconstpointer b); > > > -- > > > 2.27.0.212.ge8ba1cc988-goog > > > > > > > > > -- > > Luiz Augusto von Dentz --=20 Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2H3OMMgODl9oTAEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 22:00:08 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id UNvWL8gODl+smAEA0J78UA (envelope-from ); Tue, 14 Jul 2020 22:00:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CFE2853EF1; Tue, 14 Jul 2020 22:00:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729419AbgGNTvk (ORCPT + 1 other); Tue, 14 Jul 2020 15:51:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729203AbgGNTvj (ORCPT ); Tue, 14 Jul 2020 15:51:39 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECDC9C061755 for ; Tue, 14 Jul 2020 12:51:39 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id d1so2204136plr.8 for ; Tue, 14 Jul 2020 12:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VPwCP5Z0Rhdnq92HhIud0aSAxStvJXr6W4dUKLtLBOA=; b=YmYxRna25SgjM+JEwS0tqppDvfeBV/qU9QsX6CYlPCcHVV9leU80Cnyh0NEHhThURq eoexJTg9KAz2whnzYLk5ZmKVI0Z5A3Dvc/7RBHnmyMH01FXXUVEaBtL4jo451g0pIkF8 20c6LzLkW6kZvJLTRH9j2AZS9chKtTnrINLtA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VPwCP5Z0Rhdnq92HhIud0aSAxStvJXr6W4dUKLtLBOA=; b=qzkYseWRUCc/SaXHHHMqfttDKl+G87SmSMGjPZP4IPPQwlRljd9/Np0RQl9iaLEvk0 wuvS9QYyOjVIwf5txDXAznIFjCnbmo83lQ1J+iQP6i1Z4ViFdSEz03XiDYjr/ykxwpz8 7/R6VyIfNSQ8uwTTkB3Oph4LAggM8f+09I80RxbTlljTu8wFiI0CvDUi0k/oBd1Zi02i eW3rN5H4BzRsIVfKMJhAf2ctA+oN/dS0WPig0tZBHNS3Of6hMOXvx3ZgTpyeXJrTxUCS RfjuBQjAviqcmfd4F6rFeDdkPKrCHHqKXhezJuuSDDOxpiFccjdKpluTeTGuqFCanEiR 8dPg== X-Gm-Message-State: AOAM532rw/Y6cwyKtux2e66OlN1aQas3x16tCdGWVsRlNQQG43FIpsOX +sPOzhBI2zdR9VoZZwktDlDcwA== X-Google-Smtp-Source: ABdhPJwYPtlW44unqGfV01GTHWMUkecTDgeXt1t7arg3sjWlLPfO2Bqw+bL9pwJF2r5QmVDjXvLsrQ== X-Received: by 2002:a17:90a:3488:: with SMTP id p8mr6634739pjb.211.1594756299490; Tue, 14 Jul 2020 12:51:39 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 204sm30669pfx.3.2020.07.14.12.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 12:51:38 -0700 (PDT) From: Abhishek Pandit-Subedi To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi , Alain Michaud , Miao-chen Chou Subject: [Bluez PATCH v2] doc: Add Suspend and Resume events Date: Tue, 14 Jul 2020 12:51:31 -0700 Message-Id: <20200714125120.Bluez.v2.1.I9181af521cf0fba8f4315c9b89975848d437d6dd@changeid> X-Mailer: git-send-email 2.27.0.389.gc38d7665816-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 32 X-Rspamd-Score: 4.94 / 15.00 / 200.00 X-Rspamd-Queue-Id: CFE2853EF1 X-Rspamd-UID: f17f87 Add Controller Suspend Event and Controller Resume Event to identify suspend or resume of the Bluetooth stack has occurred. Also update Device Disconnected Event to indicate a new disconnect reason: "Connection terminated by local host for suspend" Reviewed-by: Alain Michaud Reviewed-by: Miao-chen Chou --- Changes in v2: - Moved Wake_Reason to first value - Reduced Wake_Reason to not Bluetooth, unexpected event and remote wake doc/mgmt-api.txt | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index ca0d38469..e7a713824 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -3834,6 +3834,7 @@ Device Disconnected Event 2 Connection terminated by local host 3 Connection terminated by remote host 4 Connection terminated due to authentication failure + 5 Connection terminated by local host for suspend Note that the local/remote distinction just determines which side terminated the low-level connection, regardless of the @@ -4577,3 +4578,50 @@ Advertisement Monitor Removed Event The event will only be sent to management sockets other than the one through which the command was sent. + + +Controller Suspend Event +======================== + + Event code: 0x002d + Controller Index: + Event Parameters: Suspend_State (1 octet) + + This event indicates that the controller is suspended for host suspend. + + Possible values for the Suspend_State parameter: + 0 Running (not disconnected) + 1 Disconnected and not scanning + 2 Page scanning and/or passive scanning. + + The value 0 is used for the running state and may be sent if the + controller could not be configured to suspend properly. + + This event will be sent to all management sockets. + + +Controller Resume Event +======================= + + Event code: 0x002e + Controller Index: + Event Parameters: Wake_Reason (1 octet) + Address (6 octets) + Address_Type (1 octet) + + This event indicates that the controller has resumed from suspend. + + Possible values for the Wake_Reason parameter: + 0 Resume from non-Bluetooth wake source + 1 Wake due to unexpected event + 2 Remote wake due to peer device connection + + Currently, we expect that only peer reconnections should wake us from + the suspended state. Any other events that occurred while the system + should have been suspended results in wake due to unexpected event. + + If the Wake_Reason is Remote wake due to connection, the address of the + peer device that caused the event will be shared in Address and + Address_Type. Otherwise, Address and Address_Type will both be zero. + + This event will be sent to all management sockets. -- 2.27.0.389.gc38d7665816-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mIPLLG4ZDl8ccAEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 22:45:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4OaAK24ZDl/C3QAAgupzMw (envelope-from ); Tue, 14 Jul 2020 22:45:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 81C77A5919; Tue, 14 Jul 2020 22:45:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727114AbgGNUpV (ORCPT + 1 other); Tue, 14 Jul 2020 16:45:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726634AbgGNUpP (ORCPT ); Tue, 14 Jul 2020 16:45:15 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49740C061755 for ; Tue, 14 Jul 2020 13:45:15 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id y10so24422394eje.1 for ; Tue, 14 Jul 2020 13:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Kqh1NBVBlHrZFE286BUwAHdoh8ntAaaIXSLlXQ7Bm6s=; b=dsDrvsXKwnz4Ec5AoGC7UzNnGr6HGFuQx0fMIrzZdpvzT8V+sMBjSseqibtKkUleNp YAQBi76uicXluskJd+hTeTsyWAg05jNYM0frcHY4PBAtEKlADxwqvaJdPcxxHuR6fSg4 Z8Av9Xw3kWBU7AcvAiZLJvP0ANAQYQY/1HRVk5m0U6KRDc+OtwfbXN0N1c0AAmeVdh96 7p0jLgi5ACnL+H0e8teJtGjWlj+U1ay7gVzmHsVYk1zN8dRbuaztcrZ66pzJ2Ok7zto2 EGMDow93S9QTHHgzoSZB16/uOQk9fIg12WPTEmg38d7cg2Gx2p4CpzISSSFIUXkbDAsr HC/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Kqh1NBVBlHrZFE286BUwAHdoh8ntAaaIXSLlXQ7Bm6s=; b=i0w1ntqnyd7CD9N48XmhbYXjbVWk/Jj+a3CyZGkizfz6re+Y0i+uljCwMySYoCw6Jp PfCyO21gk/qA8H2aLi1xErXGAvspfjxKx8LVxj+pkCRamIomO267ZGVY2xASoabCT5oC a3hq2oJO6VNZ35Y0MLGZrAKsWv05AwXAMvNfRlLePC0QYG2lVC1BjJbxpMHubUc+HRR6 XZ1aSUNv/mPB6JjgbtRzMtL8nx+SLx07heh/j7uCt7V7AYm/OVZoDJ085UDcCCJYa5zq yiyT9j6H/JAPJJMr4sci1s4Cvtx4N9DchS7V+aZngJgf2Ljg33FBlsTYG7o00ujsbAFG JUMw== X-Gm-Message-State: AOAM531J4ifNnbgUCKfwg3cVtGw48QtJKIlWsquoS9FmkwxeYFJ4PBgR 2V0wzt2R9mwpyiVA2aHDs7FU3XEW47EQK2bBw9/JpQ== X-Google-Smtp-Source: ABdhPJysUSBHVOa53sWJQjIcFkn4l3OgSNQEcR9y15L+mAV25fgE46PISgPYdobloPCBMeTthBtC00kZdSRclXpMQu0= X-Received: by 2002:a17:906:fa9b:: with SMTP id lt27mr6000034ejb.513.1594759512692; Tue, 14 Jul 2020 13:45:12 -0700 (PDT) MIME-Version: 1.0 References: <20200714124113.20918-1-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200714124113.20918-1-Sergey.Semin@baikalelectronics.ru> From: Daniel Winkler Date: Tue, 14 Jul 2020 13:45:01 -0700 Message-ID: Subject: Re: [PATCH] serial: 8250_mtk: Fix high-speed baud rates clamping To: Serge Semin , Claire Chang , Nicolas Boichat Cc: Greg Kroah-Hartman , Jiri Slaby , Matthias Brugger , Serge Semin , Alexey Malahov , Aaron Sierra , Andy Shevchenko , Lukas Wunner , Vignesh Raghavendra , linux-serial@vger.kernel.org, linux-mediatek@lists.infradead.org, BlueZ , chromeos-bluetooth-upstreaming , abhishekpandit@chromium.org, stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: 81C77A5919 X-Rspamd-UID: 8e7839 Thank you Sergey for looking into this. Adding folks working on this platform to perform validation of the proposed patch. Best, Daniel On Tue, Jul 14, 2020 at 5:41 AM Serge Semin wrote: > > Commit 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 > port") fixed limits of a baud rate setting for a generic 8250 port. > In other words since that commit the baud rate has been permitted to be > within [uartclk / 16 / UART_DIV_MAX; uartclk / 16], which is absolutely > normal for a standard 8250 UART port. But there are custom 8250 ports, > which provide extended baud rate limits. In particular the Mediatek 8250 > port can work with baud rates up to "uartclk" speed. > > Normally that and any other peculiarity is supposed to be handled in a > custom set_termios() callback implemented in the vendor-specific > 8250-port glue-driver. Currently that is how it's done for the most of > the vendor-specific 8250 ports, but for some reason for Mediatek a > solution has been spread out to both the glue-driver and to the generic > 8250-port code. Due to that a bug has been introduced, which permitted the > extended baud rate limit for all even for standard 8250-ports. The bug > has been fixed by the commit 7b668c064ec3 ("serial: 8250: Fix max baud > limit in generic 8250 port") by narrowing the baud rates limit back down to > the normal bounds. Unfortunately by doing so we also broke the > Mediatek-specific extended bauds feature. > > A fix of the problem described above is twofold. First since we can't get > back the extended baud rate limits feature to the generic set_termios() > function and that method supports only a standard baud rates range, the > requested baud rate must be locally stored before calling it and then > restored back to the new termios structure after the generic set_termios() > finished its magic business. By doing so we still use the > serial8250_do_set_termios() method to set the LCR/MCR/FCR/etc. registers, > while the extended baud rate setting procedure will be performed later in > the custom Mediatek-specific set_termios() callback. Second since a true > baud rate is now fully calculated in the custom set_termios() method we > need to locally update the port timeout by calling the > uart_update_timeout() function. After the fixes described above are > implemented in the 8250_mtk.c driver, the Mediatek 8250-port should > get back to normally working with extended baud rates. > > Link: https://lore.kernel.org/linux-serial/20200701211337.3027448-1-danielwinkler@google.com > > Fixes: 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 port") > Reported-by: Daniel Winkler > Signed-off-by: Serge Semin > > --- > > Folks, sorry for a delay with the problem fix. A solution is turned out to > be a bit more complicated than I originally thought in my comment to the > Daniel revert-patch. > > Please also note, that I don't have a Mediatek hardware to test the > solution suggested in the patch. The code is written as on so called > the tip of the pen after digging into the 8250_mtk.c and 8250_port.c > drivers code. So please Daniel or someone with Mediatek 8250-port > available on a board test this patch first and report about the results in > reply to this emailing thread. After that, if your conclusion is positive > and there is no objection against the solution design the patch can be > merged in. > > Cc: Alexey Malahov > Cc: Daniel Winkler > Cc: Aaron Sierra > Cc: Andy Shevchenko > Cc: Lukas Wunner > Cc: Vignesh Raghavendra > Cc: linux-serial@vger.kernel.org > Cc: linux-mediatek@lists.infradead.org > Cc: BlueZ > Cc: chromeos-bluetooth-upstreaming > Cc: abhishekpandit@chromium.org > Cc: stable@vger.kernel.org > --- > drivers/tty/serial/8250/8250_mtk.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c > index f839380c2f4c..98b8a3e30733 100644 > --- a/drivers/tty/serial/8250/8250_mtk.c > +++ b/drivers/tty/serial/8250/8250_mtk.c > @@ -306,8 +306,21 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, > } > #endif > > + /* > + * Store the requested baud rate before calling the generic 8250 > + * set_termios method. Standard 8250 port expects bauds to be > + * no higher than (uartclk / 16) so the baud will be clamped if it > + * gets out of that bound. Mediatek 8250 port supports speed > + * higher than that, therefore we'll get original baud rate back > + * after calling the generic set_termios method and recalculate > + * the speed later in this method. > + */ > + baud = tty_termios_baud_rate(termios); > + > serial8250_do_set_termios(port, termios, old); > > + tty_termios_encode_baud_rate(termios, baud, baud); > + > /* > * Mediatek UARTs use an extra highspeed register (MTK_UART_HIGHS) > * > @@ -339,6 +352,11 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, > */ > spin_lock_irqsave(&port->lock, flags); > > + /* > + * Update the per-port timeout. > + */ > + uart_update_timeout(port, termios->c_cflag, baud); > + > /* set DLAB we have cval saved in up->lcr from the call to the core */ > serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB); > serial_dl_write(up, quot); > -- > 2.26.2 > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aJaYDtYbDl88hQEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 22:55:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8PwoDdYbDl9vXwAAlp8NpQ (envelope-from ); Tue, 14 Jul 2020 22:55:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D3BEAA35A1; Tue, 14 Jul 2020 22:55:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728036AbgGNUzn (ORCPT + 1 other); Tue, 14 Jul 2020 16:55:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728002AbgGNUzm (ORCPT ); Tue, 14 Jul 2020 16:55:42 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8EA8C061755 for ; Tue, 14 Jul 2020 13:55:42 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id w17so67487oie.6 for ; Tue, 14 Jul 2020 13:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=71kwtVIvNO6pfD7j+0gcY3/TDmX9mKDOLZFCzqzfOEk=; b=Zu7BZBcD2AxCn1kOvIn+tRhaXY3zu1vemcrzsfoR+sVIzmB5jVDQQJtLBSrv4rTq3w Az1eWKJ3v9q5LRy/WgWvJI9oByL+dcLZlchxRXwiiHtoDmiUCWo1N1wHVcVCsKje8dMl b7t9JuXumk1f9XFORJW5uC7yVyfm6LNkkCSio= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=71kwtVIvNO6pfD7j+0gcY3/TDmX9mKDOLZFCzqzfOEk=; b=oattuxKucARHSyKKqrOsHIoLmMw5kKmRtZmLIsFdU0wZKzn1FCDF5yQtxKrztktTez +ubNQJ4qvogeME3EaJSXp/dAG8lEJDIQtnllTj+xVQwLIa3iaE8KCU9tjkGPEgtyZWBs kqKWkQNiErCxVQ1dFDeLJN+hPHVW6ZrvjUiXXsUyHDRfWup83va3/17odEe5BI42wHCb y7iOfLSf6sakcwwWqT3a96y2NLeiYwig6Sv/YqVBn0xUjDumPNwxAkVyfnjCokBZ1Xth nuLP6PBrHCOkJUVOCiVLVLbmjGJQRstLkqzqTgp9XCZtIH5JABKq3ejbdv4Fg5HxnkYd b4Rw== X-Gm-Message-State: AOAM53157ZTFFzp5nSWQYy8lCojWCgv3zpzoajjx7SyukUnJmcBIQWN1 KqjykuesnMPIMER5qbXK2FdAjF0IQS5n1PCJ4T1YRQ== X-Google-Smtp-Source: ABdhPJz5ikIqYRXJ3GAw1Uv5PJGRERav2bpqC3Z/eujhhM+G0unX/GknfczgfynTOWX1LqQd5mr/xZiewd7hfy46J5w= X-Received: by 2002:aca:4fd3:: with SMTP id d202mr5414262oib.142.1594760141714; Tue, 14 Jul 2020 13:55:41 -0700 (PDT) MIME-Version: 1.0 References: <20200713201441.235959-1-sonnysasaka@chromium.org> In-Reply-To: From: Sonny Sasaka Date: Tue, 14 Jul 2020 13:55:29 -0700 Message-ID: Subject: Re: [PATCH BlueZ 0/3] Per-device option to enable/disable internal profiles To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: D3BEAA35A1 X-Rspamd-UID: c2de07 Hi Luiz, On Mon, Jul 13, 2020 at 10:28 PM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Mon, Jul 13, 2020 at 4:48 PM Sonny Sasaka wrote: > > > > Hi Luiz, > > > > On Mon, Jul 13, 2020 at 3:59 PM Luiz Augusto von Dentz > > wrote: > > > > > > Hi Sonny, > > > > > > On Mon, Jul 13, 2020 at 3:04 PM Sonny Sasaka wrote: > > > > > > > > Hi Luiz, > > > > > > > > I considered having such an approach that gives exception to some > > > > profile to not claim exclusive access. However, I think that this > > > > approach has a drawback that it can only be guaranteed to work > > > > correctly for profiles that contain only read-only attributes. Any > > > > profile that contains writable attributes, naturally, cannot be > > > > guaranteed to always work correctly (as is the case with the Battery > > > > profile). Therefore, the usefulness of that feature will be very > > > > limited. > > > > > > > > I also considered the benefits of the AllowInternalProfiles approach: > > > > * Applications can also have control over any profile, not just > > > > Battery profile. For example, if in the future BlueZ has more internal > > > > profiles, like (Blood Pressure Profile or any other profile that may > > > > contain writable attributes), we can guarantee that applications can > > > > still opt to have access to that profile, without relying on a profile > > > > being "safe" to be shared by both BlueZ's internal and external > > > > handlers. > > > > * This has an added security benefit: applications which operate on a > > > > specific GATT profile will not unintentionally activate internal > > > > profiles such as HOG (which is able to hijack input control of the > > > > host). This is the correct and expected behavior of Android apps that > > > > connect over GATT and get access to a GATT profile. > > > > > > Not sure I follow these arguments, it seems AllowInternalProfiles may > > > actually enable hijacking the profiles so I wonder if you got this > > > backwards as we can't let things like HoG be controlled by > > > applications directly it would be too easy to implement something like > > > a keylogger, or perhaps you are suggesting that there is another layer > > > for implementing the profiles? Note that it is intended that plugins > > > shall be used for profiles that need to be integrated system wide, > > > D-Bus interface shall be restricted to only application specific > > > profiles. > > > > I think you misunderstood my point about HOG hijacking. Consider the > > following case: > > 1. A legit application (not System UI) on a host computer scans and > > connects to a nearby peer. It makes a guess about the peer device > > based on its advertising data. It intends to operate on a specific > > GATT profile (not necessarily Battery). > > 2. The peer device turns out to be malicious. It runs HOG GATT server > > and triggers the host's HOG profile to be active. > > 3. The malicious peer device's HOG GATT server can now maliciously > > make mouse movements or enter keystrokes to the host. > > I'm not sure how you would like to prevent that, we could in theory > attempt to authorize every single profile before connecting, just like > it is done for legacy, but Im sure system would not be asking the user > what profiles to connect so they just end up trusting the device, > alternatively we could make ConnectProfile to work also for LE so you > can provide a UUID and nothing else would be exposed, but note that > this guess on the AD may actually be wrong and the device may end up > malfunctioning. > > > In this case the user is considered being attacked, because he/she > > doesn't consciously interact with the System UI to connect to a nearby > > mouse/keyboard. > > My example doesn't have to be HOG. It just happens to be a profile > > which is attackable at the moment. My point is that, for applications > > it's always safest to turn off all internal profiles to avoid such > > incident. There is no use case where applications want to trigger > > internal profiles. > > > > Note 1: By "applications", I mean things like Android apps or > > JavaScript apps which are not considered System's Bluetooth UI. > > Well that doesn't make my point moot, let's say we do enable > connecting by UUID and the application try to connect HoG, it could be > a malicious application trying to eavesdrop what the user is typing, > so this problem of malicious goes both ways Im afraid, besides the > performance penalty that one would have if we need to transport HID > over D-Bus. If an application handles HOG, there will be nothing to eavesdrop because that application shouldn't have an access to UHID in the first place. If that malicious application had UHID access, that is already a problem to begin with regardless of whether there is Bluetooth or not. The security of this is handled above the Bluetooth layer. The operating system that uses this feature is responsible for higher layer security. For operating systems that don't need it I am okay with adding an option to disable this feature altogether. But I can see that there are systems that need it and I am not convinced that a general purpose Bluetooth stack should not support it. > > More applications could be involved and then this all becomes a mess > if they have to fight over AllowInternalProfiles, so instead of using > a theoretical example we better find real apps and devices where > conflicts happens and work out case by case, adding ConnectProfile > should actually fix most of them if there is a single profile involved > by we could also thing about an alternative to connect multiples. > There is also the possibility of exposing the btd_service as objects, > I've actually had this implemented for the car industry, that way > AutoConnect property could actually be controlled on a per service > basis instead of having just one switch for everything. To be clear, applications do not have direct access to AllowInternalProfiles. The higher layer operating system controls it. This is just the same case as the org.bluez.Adapter1.Powered property and many other examples where applications are not expected to have direct control of. Therefore there should be no problem of many things fighting over it if used correctly, just like many other properties. Again, I am okay with adding an option to disable this for operating systems that do not want it. Note: I have been using the term "operating system" to refer to high level components rather than the kernel. > > > > > > > Note that we do allow external profiles to be registered with use of: > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/profile-api.txt > > > > > > And for GATT: > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt#n366 > > > > > > We could perhaps make the assumption that once an application > > > registers itself as supporting a given profile we check if against a > > > blacklist of profiles that may have security implications, which > > > perhaps could be defined via main.conf or some other file, if that is > > > not the case the internal profile can be disabled and the D-Bus object > > > would be accessible over D-Bus. Also note that we do offer clients the > > > ability to have exclusive access with AcquireWrite and AcquireNotify. > > > > > > > Therefore I think that this approach, although more complex, has > > > > longer lasting benefits. Let me know if you have any objection to > > > > having such a feature. > > > > > > > > > > > > On Mon, Jul 13, 2020 at 1:35 PM Luiz Augusto von Dentz > > > > wrote: > > > > > > > > > > Hi Sonny, > > > > > > > > > > On Mon, Jul 13, 2020 at 1:18 PM Sonny Sasaka wrote: > > > > > > > > > > > > This patch series adds a mechanism for clients to choose whether to > > > > > > enable BlueZ internal profiles (e.g. A2DP, Battery) for specific > > > > > > devices. > > > > > > > > > > > > The motivation behind this feature is that some applications (e.g. Web > > > > > > Bluetooth or Android apps) need to have control over all remove GATT > > > > > > services, like Battery service. With "battery" plugin being enabled on > > > > > > BlueZ, it becomes not possible for those apps to work properly because > > > > > > BlueZ "hides" the Battery-related attributes from its GATT Client API. > > > > > > Disabling the "battery" plugin won't solve the problem either, since we > > > > > > do also need to enable the plugin so that we can use org.bluez.Battery1 > > > > > > API. > > > > > > > > > > > > The solution that we propose is that clients can choose whether to > > > > > > enable internal profiles for each device. Clients know when to enable > > > > > > internal profiles (such as when a user chooses to pair/connect via a UI) > > > > > > and when to disable internal profiles (such as when the connection is > > > > > > initiated by a generic application). > > > > > > > > > > I wonder if it is not better to just have a flag indicating if the > > > > > profile shall claim exclusive access (such as GAP and GATT services), > > > > > so profiles that don't set that will have the services exposed so for > > > > > battery we can probably just have it exposed by default since it > > > > > doesn't appear to would be any conflicts on having it exposed. > > > > > > > > > > > Sonny Sasaka (3): > > > > > > doc: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > > device: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > > client: Add set-allow-internal-profiles command > > > > > > > > > > > > client/main.c | 38 ++++++++++++++++++ > > > > > > doc/device-api.txt | 13 +++++++ > > > > > > src/device.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ > > > > > > src/hcid.h | 2 + > > > > > > src/main.c | 10 +++++ > > > > > > src/main.conf | 4 ++ > > > > > > 6 files changed, 163 insertions(+) > > > > > > > > > > > > -- > > > > > > 2.26.2 > > > > > > > > > > > > > > > > > > > > > -- > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6DCECKQgDl88hQEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 23:16:20 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id mMq+BqQgDl+zdAAAlScrYA (envelope-from ); Tue, 14 Jul 2020 23:16:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 79D58533BC; Tue, 14 Jul 2020 23:16:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728273AbgGNVQI (ORCPT + 1 other); Tue, 14 Jul 2020 17:16:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727941AbgGNVQG (ORCPT ); Tue, 14 Jul 2020 17:16:06 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF0B7C061794 for ; Tue, 14 Jul 2020 14:16:06 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id t7so318936ybk.2 for ; Tue, 14 Jul 2020 14:16:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=HzEMpeAsA85Ww9OWf319/ckjyVKaoI/djE5Efi8rzCg=; b=kSx6jbza4TcJaMQAaLz2/vObPEtYak6vZaux2wv9qmAAIQRRBlDC+teIjl3cw0m/El RydhEHRbnFzZbdocR+vyyCnrL0+snaVFtJwuIbJr1Clvdb4dkL/puff33XrndB51HnM1 8L89teW1qxyW/3BPCAvdY8PKR3oAIZBLVpmGMf/YqRkdruIdoga7xNRJ7d9vel/pjGzj 3OuvJv9jXDJnRD+AbHUMxLbwiR2l6LK5dQsWGrjilwCNtB2vDbGjfltynnmjXtxsuDPT iiEOwIpCtNF32NiYiKM18iBpXlKlAvkr9xqytJ7AxnblUX+myhWQvs8/bSh51uOPgVSb B9kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=HzEMpeAsA85Ww9OWf319/ckjyVKaoI/djE5Efi8rzCg=; b=bLV41TZ3gy9/GQCwtFwSe0su1xBzK6g11mLDge7xedPaMwVY06eqIj+U2NOTCLA7wx 4e/ZGf2v9X7T1XZlRHCi808H5nTxQWb7QgOJ4KqdimWVmVotSf+YVtISHnN/eOf4EAFr ni6NtMUupX9+3NfMirijwOKDuEW/SANSLpP3sfbap+zUu0o/s25XehPD03KQW/VA5mRH xDprysqrDOF409/knCP3pbnBCSukZXRqwgkFM28iNM50F/vV0BuKnkU3qjpbmqt64fWA v/THaeAqhXCDOgLSE1fAXPhUuMF85SOZHRe3ksAjPXgyPCVkepSAh6RZ/7qFkygD/goi DYFw== X-Gm-Message-State: AOAM531SXZ+ey1ZIziXU+hlr6pvixB7N1y505Ki99Agj1Phzv8TAYnSj eCyh6x9Eog+wyjLuldig1uezRlyjJVwwE/D2wicEXUgrRcl6H45N9/r3l7F6xmmVQU5dwr0c9X2 t0CuAFMCEKnHd7QBwmtLCHgFop9h5XPODbxDKadVxS7dpKCFU1yX0A9TxCvB7nQh6hNRdaTSnpy CPOhOqrMffSCa5zSF8 X-Google-Smtp-Source: ABdhPJzhQxfr7YmLnLQTuyAFMguLsPYwrYEipp4TVDG1jwjXWfgiFWmBYjDjwuyfzpGJzDHivCEfhKH77tKI4eUU13ro X-Received: by 2002:a25:2105:: with SMTP id h5mr10362528ybh.65.1594761365824; Tue, 14 Jul 2020 14:16:05 -0700 (PDT) Date: Tue, 14 Jul 2020 14:16:00 -0700 Message-Id: <20200714141547.v1.1.Icd35ad65fb4136d45dd701ef9022fa8f7c9e5d65@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.389.gc38d7665816-goog Subject: [PATCH v1] Bluetooth: Add per-instance adv disable/remove From: Daniel Winkler To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler , Shyh-In Hwang , Alain Michaud , "David S. Miller" , Jakub Kicinski , Johan Hedberg , Marcel Holtmann , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: 79D58533BC X-Rspamd-UID: 5141cc Add functionality to disable and remove advertising instances, and use that functionality in MGMT add/remove advertising calls. Signed-off-by: Daniel Winkler Reviewed-by: Shyh-In Hwang Reviewed-by: Alain Michaud --- net/bluetooth/hci_conn.c | 2 +- net/bluetooth/hci_request.c | 59 +++++++++++++++++++++++++++++++------ net/bluetooth/hci_request.h | 2 ++ net/bluetooth/mgmt.c | 6 ++++ 4 files changed, 59 insertions(+), 10 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 8805d68e65f2a..be67361ff2f00 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -931,7 +931,7 @@ static void hci_req_directed_advertising(struct hci_request *req, * So it is required to remove adv set for handle 0x00. since we use * instance 0 for directed adv. */ - hci_req_add(req, HCI_OP_LE_REMOVE_ADV_SET, sizeof(cp.handle), &cp.handle); + __hci_req_remove_ext_adv_instance(req, cp.handle); hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_PARAMS, sizeof(cp), &cp); diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 770b937581122..7c0c2fda04adf 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1179,13 +1179,8 @@ static u8 get_cur_adv_instance_scan_rsp_len(struct hci_dev *hdev) void __hci_req_disable_advertising(struct hci_request *req) { if (ext_adv_capable(req->hdev)) { - struct hci_cp_le_set_ext_adv_enable cp; + __hci_req_disable_ext_adv_instance(req, 0x00); - cp.enable = 0x00; - /* Disable all sets since we only support one set at the moment */ - cp.num_of_sets = 0x00; - - hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_ENABLE, sizeof(cp), &cp); } else { u8 enable = 0x00; @@ -1950,13 +1945,59 @@ int __hci_req_enable_ext_advertising(struct hci_request *req, u8 instance) return 0; } +int __hci_req_disable_ext_adv_instance(struct hci_request *req, u8 instance) +{ + struct hci_dev *hdev = req->hdev; + struct hci_cp_le_set_ext_adv_enable *cp; + struct hci_cp_ext_adv_set *adv_set; + u8 data[sizeof(*cp) + sizeof(*adv_set) * 1]; + u8 req_size; + + /* If request specifies an instance that doesn't exist, fail */ + if (instance > 0 && !hci_find_adv_instance(hdev, instance)) + return -EINVAL; + + memset(data, 0, sizeof(data)); + + cp = (void *)data; + adv_set = (void *)cp->data; + + /* Instance 0x00 indicates all advertising instances will be disabled */ + cp->num_of_sets = !!instance; + cp->enable = 0x00; + + adv_set->handle = instance; + + req_size = sizeof(*cp) + sizeof(*adv_set) * cp->num_of_sets; + hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_ENABLE, req_size, data); + + return 0; +} + +int __hci_req_remove_ext_adv_instance(struct hci_request *req, u8 instance) +{ + struct hci_dev *hdev = req->hdev; + + /* If request specifies an instance that doesn't exist, fail */ + if (instance > 0 && !hci_find_adv_instance(hdev, instance)) + return -EINVAL; + + hci_req_add(req, HCI_OP_LE_REMOVE_ADV_SET, sizeof(instance), &instance); + + return 0; +} + int __hci_req_start_ext_adv(struct hci_request *req, u8 instance) { struct hci_dev *hdev = req->hdev; + struct adv_info *adv_instance = hci_find_adv_instance(hdev, instance); int err; - if (hci_dev_test_flag(hdev, HCI_LE_ADV)) - __hci_req_disable_advertising(req); + /* If instance isn't pending, the chip knows about it, and it's safe to + * disable + */ + if (adv_instance && !adv_instance->pending) + __hci_req_disable_ext_adv_instance(req, instance); err = __hci_req_setup_ext_adv_instance(req, instance); if (err < 0) @@ -2104,7 +2145,7 @@ void hci_req_clear_adv_instance(struct hci_dev *hdev, struct sock *sk, hci_dev_test_flag(hdev, HCI_ADVERTISING)) return; - if (next_instance) + if (next_instance && !ext_adv_capable(hdev)) __hci_req_schedule_adv_instance(req, next_instance->instance, false); } diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index 0e81614d235e9..bbe892ab078ab 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -86,6 +86,8 @@ void hci_req_clear_adv_instance(struct hci_dev *hdev, struct sock *sk, int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance); int __hci_req_start_ext_adv(struct hci_request *req, u8 instance); int __hci_req_enable_ext_advertising(struct hci_request *req, u8 instance); +int __hci_req_disable_ext_adv_instance(struct hci_request *req, u8 instance); +int __hci_req_remove_ext_adv_instance(struct hci_request *req, u8 instance); void __hci_req_clear_ext_adv_sets(struct hci_request *req); int hci_get_random_address(struct hci_dev *hdev, bool require_privacy, bool use_rpa, struct adv_info *adv_instance, diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 686ef47928316..f45105d2de772 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -7504,6 +7504,12 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev, hci_req_init(&req, hdev); + /* If we use extended advertising, instance is disabled and removed */ + if (ext_adv_capable(hdev)) { + __hci_req_disable_ext_adv_instance(&req, cp->instance); + __hci_req_remove_ext_adv_instance(&req, cp->instance); + } + hci_req_clear_adv_instance(hdev, sk, &req, cp->instance, true); if (list_empty(&hdev->adv_instances)) -- 2.27.0.389.gc38d7665816-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gBKoAYUjDl9KoQEAvsO+Rg (envelope-from ) for ; Tue, 14 Jul 2020 23:28:37 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2IE4O4QjDl9l9AAAgupzMw (envelope-from ); Tue, 14 Jul 2020 23:28:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 594CBA3859; Tue, 14 Jul 2020 23:28:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728324AbgGNV2Z (ORCPT + 1 other); Tue, 14 Jul 2020 17:28:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727981AbgGNV2Y (ORCPT ); Tue, 14 Jul 2020 17:28:24 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 499F3C08C5C1 for ; Tue, 14 Jul 2020 14:28:24 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id u12so362960ybj.0 for ; Tue, 14 Jul 2020 14:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=5Behtcws30Pp0nDQ23hDNBtqNP5bqp4CSfxyj349GYE=; b=l38dTQyw2IrM5kbznrKVpPLablAiGcaqv+lkFFedxeNwW16nlKSBZdJAhX3/TV/Brm MvKr6yC3Gq4BiJIZq4CgxKwEaSknQXLkSggaBC7wGg7rLgA29O6Wi4fsisqlhv18s2LP WF/w1jNMYA8enA7rWZlwg4NIDV2y+gazD7a1IVsQa/VIKEYTkAly9Mfqp0RboPwfXt9w 6L2wfqEGoZ+oUtcRaJQs6g1ThE2GKuQjfqCXwwZkzTCs3UNqe5zXasjKdFaNdE/6E49H f+x0X+uXn3V88VHKuTu9rjhhu4WQmFA3PTgJorReU1jMrw23CaHbLF8ZORS9+KFdazK4 P3+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=5Behtcws30Pp0nDQ23hDNBtqNP5bqp4CSfxyj349GYE=; b=npyjwilNt+20+z4vbD3h46lC9IL95P4uXvQKU3gH5cClQvPvqEt6+YfOcoxxMuxNEs bjcb4gBV+s+leO36wYahFoe19dBoIPsBBkaqYOc3Vz7fuK0JL39UP9SBkfOVrCI2HCgF PsQuMScfMFQaDOcHL/PzkT0w2OajA4D10SKYcktpRzP3pmSYgA3w8j+MZj09dGUYHZC5 t62uLpEMBKh/bQ6gbS458egDWkEEBKbdM9J4PeabH3yCcYBh76iN/VpwUkZ7eAq9tZ+U pP1DhAePn9pcogiBjkc3AamoBVVmDObcwfeXplM/wx6I8DH85PYrBNKaucPn+jG9jzak 40hA== X-Gm-Message-State: AOAM53375VGzXgWnkXO3cG1Av6aRM8aPxSn8KMpmyONwmnIlAvJRTNeT SrAqw1Mikglg/4v5blzOwbsy2qt7TBEVU6qafnVrIc17lIdTPudfMWEMLA86q4tItZXSUmoCpc3 MWA/lCFEufMGaXdqedApNflxX+LZSvTGFMtUhg/pf3T2MryCPumYTvvrgg059ssCjHQAi7ZmLGM VTlK7pz/RnEtsqT1fa X-Google-Smtp-Source: ABdhPJzuhzn0stnH04Y0xmiGPJJI6ddjd4INyuVFCT9ZvtB9fwZLNAJ1DPmpkDN9PNJIDYgcFx+WfgfepQ4EHN++vCRa X-Received: by 2002:a25:b90e:: with SMTP id x14mr11855088ybj.8.1594762103396; Tue, 14 Jul 2020 14:28:23 -0700 (PDT) Date: Tue, 14 Jul 2020 14:28:17 -0700 Message-Id: <20200714142741.v2.1.Icd35ad65fb4136d45dd701ef9022fa8f7c9e5d65@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.389.gc38d7665816-goog Subject: [PATCH v2] Bluetooth: Add per-instance adv disable/remove From: Daniel Winkler To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler , Shyh-In Hwang , Alain Michaud , "David S. Miller" , Jakub Kicinski , Johan Hedberg , Marcel Holtmann , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: 594CBA3859 X-Rspamd-UID: a8e301 Add functionality to disable and remove advertising instances, and use that functionality in MGMT add/remove advertising calls. Signed-off-by: Daniel Winkler Reviewed-by: Shyh-In Hwang Reviewed-by: Alain Michaud --- Hi Maintainers, Currently, advertising is globally-disabled, i.e. all instances are disabled together, even if hardware offloading is available. This patch adds functionality to disable and remove individual adv instances, solving two issues: 1. On new advertisement registration, a global disable was done, and then only the new instance was enabled. This meant only the newest instance was actually enabled. 2. On advertisement removal, the structure was removed, but the instance was never disabled or removed, which is incorrect with hardware offload support. Patch has been tested on advertising test suite and with manual testing to verify instances are added/removed properly on kernel 4.19 on hatch chromebook. Best, Daniel Changes in v2: - Re-add commit notes net/bluetooth/hci_conn.c | 2 +- net/bluetooth/hci_request.c | 59 +++++++++++++++++++++++++++++++------ net/bluetooth/hci_request.h | 2 ++ net/bluetooth/mgmt.c | 6 ++++ 4 files changed, 59 insertions(+), 10 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 8805d68e65f2a..be67361ff2f00 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -931,7 +931,7 @@ static void hci_req_directed_advertising(struct hci_request *req, * So it is required to remove adv set for handle 0x00. since we use * instance 0 for directed adv. */ - hci_req_add(req, HCI_OP_LE_REMOVE_ADV_SET, sizeof(cp.handle), &cp.handle); + __hci_req_remove_ext_adv_instance(req, cp.handle); hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_PARAMS, sizeof(cp), &cp); diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 770b937581122..7c0c2fda04adf 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1179,13 +1179,8 @@ static u8 get_cur_adv_instance_scan_rsp_len(struct hci_dev *hdev) void __hci_req_disable_advertising(struct hci_request *req) { if (ext_adv_capable(req->hdev)) { - struct hci_cp_le_set_ext_adv_enable cp; + __hci_req_disable_ext_adv_instance(req, 0x00); - cp.enable = 0x00; - /* Disable all sets since we only support one set at the moment */ - cp.num_of_sets = 0x00; - - hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_ENABLE, sizeof(cp), &cp); } else { u8 enable = 0x00; @@ -1950,13 +1945,59 @@ int __hci_req_enable_ext_advertising(struct hci_request *req, u8 instance) return 0; } +int __hci_req_disable_ext_adv_instance(struct hci_request *req, u8 instance) +{ + struct hci_dev *hdev = req->hdev; + struct hci_cp_le_set_ext_adv_enable *cp; + struct hci_cp_ext_adv_set *adv_set; + u8 data[sizeof(*cp) + sizeof(*adv_set) * 1]; + u8 req_size; + + /* If request specifies an instance that doesn't exist, fail */ + if (instance > 0 && !hci_find_adv_instance(hdev, instance)) + return -EINVAL; + + memset(data, 0, sizeof(data)); + + cp = (void *)data; + adv_set = (void *)cp->data; + + /* Instance 0x00 indicates all advertising instances will be disabled */ + cp->num_of_sets = !!instance; + cp->enable = 0x00; + + adv_set->handle = instance; + + req_size = sizeof(*cp) + sizeof(*adv_set) * cp->num_of_sets; + hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_ENABLE, req_size, data); + + return 0; +} + +int __hci_req_remove_ext_adv_instance(struct hci_request *req, u8 instance) +{ + struct hci_dev *hdev = req->hdev; + + /* If request specifies an instance that doesn't exist, fail */ + if (instance > 0 && !hci_find_adv_instance(hdev, instance)) + return -EINVAL; + + hci_req_add(req, HCI_OP_LE_REMOVE_ADV_SET, sizeof(instance), &instance); + + return 0; +} + int __hci_req_start_ext_adv(struct hci_request *req, u8 instance) { struct hci_dev *hdev = req->hdev; + struct adv_info *adv_instance = hci_find_adv_instance(hdev, instance); int err; - if (hci_dev_test_flag(hdev, HCI_LE_ADV)) - __hci_req_disable_advertising(req); + /* If instance isn't pending, the chip knows about it, and it's safe to + * disable + */ + if (adv_instance && !adv_instance->pending) + __hci_req_disable_ext_adv_instance(req, instance); err = __hci_req_setup_ext_adv_instance(req, instance); if (err < 0) @@ -2104,7 +2145,7 @@ void hci_req_clear_adv_instance(struct hci_dev *hdev, struct sock *sk, hci_dev_test_flag(hdev, HCI_ADVERTISING)) return; - if (next_instance) + if (next_instance && !ext_adv_capable(hdev)) __hci_req_schedule_adv_instance(req, next_instance->instance, false); } diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index 0e81614d235e9..bbe892ab078ab 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -86,6 +86,8 @@ void hci_req_clear_adv_instance(struct hci_dev *hdev, struct sock *sk, int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance); int __hci_req_start_ext_adv(struct hci_request *req, u8 instance); int __hci_req_enable_ext_advertising(struct hci_request *req, u8 instance); +int __hci_req_disable_ext_adv_instance(struct hci_request *req, u8 instance); +int __hci_req_remove_ext_adv_instance(struct hci_request *req, u8 instance); void __hci_req_clear_ext_adv_sets(struct hci_request *req); int hci_get_random_address(struct hci_dev *hdev, bool require_privacy, bool use_rpa, struct adv_info *adv_instance, diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 686ef47928316..f45105d2de772 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -7504,6 +7504,12 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev, hci_req_init(&req, hdev); + /* If we use extended advertising, instance is disabled and removed */ + if (ext_adv_capable(hdev)) { + __hci_req_disable_ext_adv_instance(&req, cp->instance); + __hci_req_remove_ext_adv_instance(&req, cp->instance); + } + hci_req_clear_adv_instance(hdev, sk, &req, cp->instance, true); if (list_empty(&hdev->adv_instances)) -- 2.27.0.389.gc38d7665816-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EP4rIMk7Dl/DHgAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 01:12:09 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id AM53Hsk7Dl/M1AAAlp8NpQ (envelope-from ); Wed, 15 Jul 2020 01:12:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CAE95A593A; Wed, 15 Jul 2020 01:12:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726970AbgGNXMD (ORCPT + 1 other); Tue, 14 Jul 2020 19:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726446AbgGNXMD (ORCPT ); Tue, 14 Jul 2020 19:12:03 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FBA8C061755 for ; Tue, 14 Jul 2020 16:12:03 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id e8so72318pgc.5 for ; Tue, 14 Jul 2020 16:12:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=IlTzMdk+7M90bKP45e+XUoQ4Pa5aVbYqIXRRa78peiI=; b=BUDYAelpVEE+jj0hBMPWbsEOB3f8w3/1FKtKul+sgZHuY1+Aky/IfYQcRTZWsdJVFT yCNsMUO/y/etGzQ1s41YM6282aG5BipV6jNJ9v7kSuRU6Mrn/IKZHEJ90tqaysPcfP+J H+vmw6WuowhxdR6w2V6q3ICTw8q179VZYnece9JVFPOvSIZ1v8kpt3gPeGJh7VFEEOJY k9lxyTNjE0M1tiZn01C66R3ifJwRqxsG46oUv+9fBSmWfysxZ+U7PkwvVH5juq4JBqWn uY3nl15CHBxohQD8LSqlL05p6occOdy6ETk2MtG4MJq0Tb6iUBgnqpLmuGz+QyJcXQia /Lgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=IlTzMdk+7M90bKP45e+XUoQ4Pa5aVbYqIXRRa78peiI=; b=RA5Q4TsU/yVCU75ulSE/1v69+kofDImLHEwnLIgUrghrQ9HiFJGnLuG0XQxpf7UIJ4 uVHb+1cz3LLulX6tEB3AXalJtqVaQuKwfL8QsH3pHT/scnllMr6+e0ZlIEEuKHtcfu1M BpQdkjoN5vHhHJdVld7n2qmtoSJN/fqYgOq17SYVGezJrByGv9GhHzfRCsZtkxxKsOwm hvyABdk2SXxr2dS8nl+U3k3hRgJk2JBRGnj4Bo7CtiWvzjiTQgsN/Pc9QaZLnvPAGW+U AY+EInj85r3hlr8zrdENhcIibzvJWJHSlNitugNBCN1SWpppTO95gEYk3bDvOSxonz2X hnow== X-Gm-Message-State: AOAM532qp6qLJCBUP3V50PHdC3e9YG6KnfSsndBk3PjNaMjTsFhkZTdg c1X49qMIEw4SESBMSsNQQpEO5Jgwp+8= X-Google-Smtp-Source: ABdhPJz1ZofVq1FZzaYJVxyE+Lb4rj+mrTgDR1zAiOAVsDw1crGw1VnlQ4sa49EgiaLy4mpuDuBxIg== X-Received: by 2002:a63:531e:: with SMTP id h30mr5053980pgb.165.1594768322011; Tue, 14 Jul 2020 16:12:02 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id g10sm133608pjs.20.2020.07.14.16.12.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 16:12:01 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [RFC v2] Bluetooth: btusb: Add support for queuing during polling interval Date: Tue, 14 Jul 2020 16:12:00 -0700 Message-Id: <20200714231200.690268-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.25.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: CAE95A593A X-Rspamd-UID: 303405 From: Luiz Augusto von Dentz This makes btusb to queue ACL and events during a polling interval by using of a delayed work, with the interval working as a time window where frames received from different endpoints are considered to be arrived at same time and then attempt to resolve potential conflics by processing the events ahead of ACL packets. It worth noting though that priorizing events over ACL data may result in inverting the order compared to how they appeared over the air, for instance there may be packets received before a disconnect event that will be discarded and unencrypted packets received before encryption change which would considered encrypted, because of these potential changes on the order the support for queuing during the polling interval is not enabled by default so platforms have the following means to enable it: At build-time: CONFIG_BT_HCIBTUSB_INTERVAL=y At runtime with use of module option: enable_interval Signed-off-by: Luiz Augusto von Dentz --- drivers/bluetooth/Kconfig | 7 ++++ drivers/bluetooth/btusb.c | 88 ++++++++++++++++++++++++++++++++++----- 2 files changed, 84 insertions(+), 11 deletions(-) diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig index 4e73a531b377..2f20a853d946 100644 --- a/drivers/bluetooth/Kconfig +++ b/drivers/bluetooth/Kconfig @@ -41,6 +41,13 @@ config BT_HCIBTUSB_AUTOSUSPEND This can be overridden by passing btusb.enable_autosuspend=[y|n] on the kernel commandline. +config BT_HCIBTUSB_INTERVAL + bool "Enable notification of USB polling interval" + depends on BT_HCIBTUSB + help + Say Y here to enable notification of USB polling interval for + Bluetooth USB devices by default. + config BT_HCIBTUSB_BCM bool "Broadcom protocol support" depends on BT_HCIBTUSB diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index faa863dd5d0a..8fcf19bc5b36 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -30,7 +30,7 @@ static bool disable_scofix; static bool force_scofix; static bool enable_autosuspend = IS_ENABLED(CONFIG_BT_HCIBTUSB_AUTOSUSPEND); - +static bool enable_interval = IS_ENABLED(CONFIG_BT_HCIBTUSB_INTERVAL); static bool reset = true; static struct usb_driver btusb_driver; @@ -465,8 +465,12 @@ struct btusb_data { unsigned long flags; - struct work_struct work; - struct work_struct waker; + struct work_struct work; + struct work_struct waker; + struct delayed_work rx_work; + + struct sk_buff_head acl_q; + struct sk_buff_head evt_q; struct usb_anchor deferred; struct usb_anchor tx_anchor; @@ -503,7 +507,7 @@ struct btusb_data { int isoc_altsetting; int suspend_count; - int (*recv_event)(struct hci_dev *hdev, struct sk_buff *skb); + int (*recv_event)(struct btusb_data *data, struct sk_buff *skb); int (*recv_bulk)(struct btusb_data *data, void *buffer, int count); int (*setup_on_usb)(struct hci_dev *hdev); @@ -653,7 +657,7 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count) if (!hci_skb_expect(skb)) { /* Complete frame */ - data->recv_event(data->hdev, skb); + data->recv_event(data, skb); skb = NULL; } } @@ -664,6 +668,25 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count) return err; } +static int btusb_rx_queue(struct btusb_data *data, struct sk_buff *skb, + struct sk_buff_head *queue, unsigned int interval) +{ + skb_queue_tail(queue, skb); + + schedule_delayed_work(&data->rx_work, interval); + + return 0; +} + +static int btusb_recv_acl(struct btusb_data *data, struct sk_buff *skb) +{ + if (!enable_interval) + return hci_recv_frame(data->hdev, skb); + + /* TODO: Calculate polling interval based on endpoint bInterval? */ + return btusb_rx_queue(data, skb, &data->acl_q, msecs_to_jiffies(1)); +} + static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count) { struct sk_buff *skb; @@ -711,7 +734,7 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count) if (!hci_skb_expect(skb)) { /* Complete frame */ - hci_recv_frame(data->hdev, skb); + btusb_recv_acl(data, skb); skb = NULL; } } @@ -1329,9 +1352,13 @@ static int btusb_close(struct hci_dev *hdev) BT_DBG("%s", hdev->name); + cancel_delayed_work(&data->rx_work); cancel_work_sync(&data->work); cancel_work_sync(&data->waker); + skb_queue_purge(&data->acl_q); + skb_queue_purge(&data->evt_q); + clear_bit(BTUSB_ISOC_RUNNING, &data->flags); clear_bit(BTUSB_BULK_RUNNING, &data->flags); clear_bit(BTUSB_INTR_RUNNING, &data->flags); @@ -1363,6 +1390,11 @@ static int btusb_flush(struct hci_dev *hdev) BT_DBG("%s", hdev->name); + cancel_delayed_work(&data->rx_work); + + skb_queue_purge(&data->acl_q); + skb_queue_purge(&data->evt_q); + usb_kill_anchored_urbs(&data->tx_anchor); btusb_free_frags(data); @@ -1718,6 +1750,25 @@ static void btusb_waker(struct work_struct *work) usb_autopm_put_interface(data->intf); } +static void btusb_rx_dequeue(struct btusb_data *data, + struct sk_buff_head *queue) +{ + struct sk_buff *skb; + + while ((skb = skb_dequeue(queue))) + hci_recv_frame(data->hdev, skb); +} + +static void btusb_rx_work(struct work_struct *work) +{ + struct btusb_data *data = container_of(work, struct btusb_data, + rx_work.work); + + /* Process HCI event packets so states changes are synchronized first */ + btusb_rx_dequeue(data, &data->evt_q); + btusb_rx_dequeue(data, &data->acl_q); +} + static int btusb_setup_bcm92035(struct hci_dev *hdev) { struct sk_buff *skb; @@ -2155,10 +2206,8 @@ static void btusb_intel_secure_send_result(struct btusb_data *data, wake_up_bit(&data->flags, BTUSB_DOWNLOADING); } -static int btusb_recv_event_intel(struct hci_dev *hdev, struct sk_buff *skb) +static int btusb_recv_event_intel(struct btusb_data *data, struct sk_buff *skb) { - struct btusb_data *data = hci_get_drvdata(hdev); - if (test_bit(BTUSB_BOOTLOADER, &data->flags)) { struct hci_event_hdr *hdr = (void *)skb->data; @@ -2187,7 +2236,7 @@ static int btusb_recv_event_intel(struct hci_dev *hdev, struct sk_buff *skb) } } - return hci_recv_frame(hdev, skb); + return hci_recv_frame(data->hdev, skb); } static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb) @@ -3767,6 +3816,15 @@ static bool btusb_prevent_wake(struct hci_dev *hdev) return !device_may_wakeup(&data->udev->dev); } +static int btusb_recv_evt(struct btusb_data *data, struct sk_buff *skb) +{ + if (!enable_interval) + return hci_recv_frame(data->hdev, skb); + + /* Don't delay event processing */ + return btusb_rx_queue(data, skb, &data->evt_q, 0); +} + static int btusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { @@ -3850,6 +3908,11 @@ static int btusb_probe(struct usb_interface *intf, INIT_WORK(&data->work, btusb_work); INIT_WORK(&data->waker, btusb_waker); + INIT_DELAYED_WORK(&data->rx_work, btusb_rx_work); + + skb_queue_head_init(&data->acl_q); + skb_queue_head_init(&data->evt_q); + init_usb_anchor(&data->deferred); init_usb_anchor(&data->tx_anchor); spin_lock_init(&data->txlock); @@ -3866,7 +3929,7 @@ static int btusb_probe(struct usb_interface *intf, data->recv_bulk = btusb_recv_bulk_intel; set_bit(BTUSB_BOOTLOADER, &data->flags); } else { - data->recv_event = hci_recv_frame; + data->recv_event = btusb_recv_evt; data->recv_bulk = btusb_recv_bulk; } @@ -4335,6 +4398,9 @@ MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size"); module_param(enable_autosuspend, bool, 0644); MODULE_PARM_DESC(enable_autosuspend, "Enable USB autosuspend by default"); +module_param(enable_interval, bool, 0644); +MODULE_PARM_DESC(enable_interval, "Enable USB polling interval by default"); + module_param(reset, bool, 0644); MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); -- 2.25.3 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YN8QDz6XDl/JvAEAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 07:42:22 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id AAeWDT6XDl8QaQEA0J78UA (envelope-from ); Wed, 15 Jul 2020 07:42:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3E9EA5419E; Wed, 15 Jul 2020 07:42:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728207AbgGOFmN (ORCPT + 1 other); Wed, 15 Jul 2020 01:42:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbgGOFmM (ORCPT ); Wed, 15 Jul 2020 01:42:12 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A72EC061755 for ; Tue, 14 Jul 2020 22:42:12 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id f23so976987iof.6 for ; Tue, 14 Jul 2020 22:42:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FzipDiDAYZY58rqh2kzcXYBD7EF+tctB+0O3KKzLNz4=; b=d2SmiiK9RFir0tNVLiwsWneH8WEOVeZ1SBJW+gMYBzXE+LjnQ6p9R6IyK72TJZc/nr RQe0LtOvyt7j1XCc6EWFxN1UXLs4CCtGO6FbX+Nj9MTAzMJoid2s0rBvqfagAx5UbhfZ rGs7lWy/xi/JHmW8/b5gE9ZqzLzKFeM/1MIDU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FzipDiDAYZY58rqh2kzcXYBD7EF+tctB+0O3KKzLNz4=; b=OUPWQsW8Hplrk0EL12qYv3Lz5mL6TxbJzlzaKXu+tsaP6vSfInwkxciErqmWMfMg19 elJflxEx7M7MXp+hANTRnNVJRccaPz5AOVsZDRtt/zb+eq35fpeJp0e2iHqWcxfAGQoM 9OabicefYV/Fy/UsDyosSG6BKDMmVg2f6j6p35q0SBif8i61rKKZnM+HOusfYJM/npK0 ucpp9i7vunrtrx5h5jms75smf21ufwWDItr5xN77J4r0cgbfSLDTDiXn1RN6ON71Dtek 3fbzHm78e5kDEMc1wCq5VZqzpholGBDVi+lts5xKYEKAvUMDJCPSbWcgXOv3qfxX8Y9p l+yQ== X-Gm-Message-State: AOAM532nhYj7I+eGCR0FyfUUHyPwk/Jzmm2j2S2UeCavgiStUWLAuoPN lPj7WYfFzolJYc9OnkS51DD17XkJLgw= X-Google-Smtp-Source: ABdhPJweMzeavjylyzGXKy9KAb9T+rh7MBa+2E1v2SdlOz7fadFFkUrqobKwtASmbVJQfkbW2U6kaQ== X-Received: by 2002:a05:6602:154d:: with SMTP id h13mr8615816iow.210.1594791731233; Tue, 14 Jul 2020 22:42:11 -0700 (PDT) Received: from mail-io1-f54.google.com (mail-io1-f54.google.com. [209.85.166.54]) by smtp.gmail.com with ESMTPSA id p11sm608707ilb.55.2020.07.14.22.42.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jul 2020 22:42:10 -0700 (PDT) Received: by mail-io1-f54.google.com with SMTP id l17so977758iok.7 for ; Tue, 14 Jul 2020 22:42:10 -0700 (PDT) X-Received: by 2002:a05:6602:2008:: with SMTP id y8mr8441205iod.69.1594791376034; Tue, 14 Jul 2020 22:36:16 -0700 (PDT) MIME-Version: 1.0 References: <20200714124113.20918-1-Sergey.Semin@baikalelectronics.ru> In-Reply-To: From: Claire Chang Date: Wed, 15 Jul 2020 13:36:04 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] serial: 8250_mtk: Fix high-speed baud rates clamping To: Daniel Winkler Cc: Serge Semin , Nicolas Boichat , Greg Kroah-Hartman , Jiri Slaby , Matthias Brugger , Serge Semin , Alexey Malahov , Aaron Sierra , Andy Shevchenko , Lukas Wunner , Vignesh Raghavendra , linux-serial@vger.kernel.org, "moderated list:ARM/Mediatek SoC support" , BlueZ , chromeos-bluetooth-upstreaming , abhishekpandit@chromium.org, stable@vger.kernel.org, linux-arm Mailing List , lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3E9EA5419E X-Rspamd-UID: c87df7 On Wed, Jul 15, 2020 at 4:45 AM Daniel Winkler wrote: > > Thank you Sergey for looking into this. Adding folks working on this > platform to perform validation of the proposed patch. > > Best, > Daniel > > On Tue, Jul 14, 2020 at 5:41 AM Serge Semin > wrote: > > > > Commit 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 > > port") fixed limits of a baud rate setting for a generic 8250 port. > > In other words since that commit the baud rate has been permitted to be > > within [uartclk / 16 / UART_DIV_MAX; uartclk / 16], which is absolutely > > normal for a standard 8250 UART port. But there are custom 8250 ports, > > which provide extended baud rate limits. In particular the Mediatek 8250 > > port can work with baud rates up to "uartclk" speed. > > > > Normally that and any other peculiarity is supposed to be handled in a > > custom set_termios() callback implemented in the vendor-specific > > 8250-port glue-driver. Currently that is how it's done for the most of > > the vendor-specific 8250 ports, but for some reason for Mediatek a > > solution has been spread out to both the glue-driver and to the generic > > 8250-port code. Due to that a bug has been introduced, which permitted the > > extended baud rate limit for all even for standard 8250-ports. The bug > > has been fixed by the commit 7b668c064ec3 ("serial: 8250: Fix max baud > > limit in generic 8250 port") by narrowing the baud rates limit back down to > > the normal bounds. Unfortunately by doing so we also broke the > > Mediatek-specific extended bauds feature. > > > > A fix of the problem described above is twofold. First since we can't get > > back the extended baud rate limits feature to the generic set_termios() > > function and that method supports only a standard baud rates range, the > > requested baud rate must be locally stored before calling it and then > > restored back to the new termios structure after the generic set_termios() > > finished its magic business. By doing so we still use the > > serial8250_do_set_termios() method to set the LCR/MCR/FCR/etc. registers, > > while the extended baud rate setting procedure will be performed later in > > the custom Mediatek-specific set_termios() callback. Second since a true > > baud rate is now fully calculated in the custom set_termios() method we > > need to locally update the port timeout by calling the > > uart_update_timeout() function. After the fixes described above are > > implemented in the 8250_mtk.c driver, the Mediatek 8250-port should > > get back to normally working with extended baud rates. > > > > Link: https://lore.kernel.org/linux-serial/20200701211337.3027448-1-danielwinkler@google.com > > > > Fixes: 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 port") > > Reported-by: Daniel Winkler > > Signed-off-by: Serge Semin Tested-by: Claire Chang > > > > --- > > > > Folks, sorry for a delay with the problem fix. A solution is turned out to > > be a bit more complicated than I originally thought in my comment to the > > Daniel revert-patch. > > > > Please also note, that I don't have a Mediatek hardware to test the > > solution suggested in the patch. The code is written as on so called > > the tip of the pen after digging into the 8250_mtk.c and 8250_port.c > > drivers code. So please Daniel or someone with Mediatek 8250-port > > available on a board test this patch first and report about the results in > > reply to this emailing thread. After that, if your conclusion is positive > > and there is no objection against the solution design the patch can be > > merged in. I tested it with mt8183 + QCA6174. The UART Bluetooth works fine with this fix. Thanks! > > > > Cc: Alexey Malahov > > Cc: Daniel Winkler > > Cc: Aaron Sierra > > Cc: Andy Shevchenko > > Cc: Lukas Wunner > > Cc: Vignesh Raghavendra > > Cc: linux-serial@vger.kernel.org > > Cc: linux-mediatek@lists.infradead.org > > Cc: BlueZ > > Cc: chromeos-bluetooth-upstreaming > > Cc: abhishekpandit@chromium.org > > Cc: stable@vger.kernel.org > > --- > > drivers/tty/serial/8250/8250_mtk.c | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > > > > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c > > index f839380c2f4c..98b8a3e30733 100644 > > --- a/drivers/tty/serial/8250/8250_mtk.c > > +++ b/drivers/tty/serial/8250/8250_mtk.c > > @@ -306,8 +306,21 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, > > } > > #endif > > > > + /* > > + * Store the requested baud rate before calling the generic 8250 > > + * set_termios method. Standard 8250 port expects bauds to be > > + * no higher than (uartclk / 16) so the baud will be clamped if it > > + * gets out of that bound. Mediatek 8250 port supports speed > > + * higher than that, therefore we'll get original baud rate back > > + * after calling the generic set_termios method and recalculate > > + * the speed later in this method. > > + */ > > + baud = tty_termios_baud_rate(termios); > > + > > serial8250_do_set_termios(port, termios, old); > > > > + tty_termios_encode_baud_rate(termios, baud, baud); > > + > > /* > > * Mediatek UARTs use an extra highspeed register (MTK_UART_HIGHS) > > * > > @@ -339,6 +352,11 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, > > */ > > spin_lock_irqsave(&port->lock, flags); > > > > + /* > > + * Update the per-port timeout. > > + */ > > + uart_update_timeout(port, termios->c_cflag, baud); > > + > > /* set DLAB we have cval saved in up->lcr from the call to the core */ > > serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB); > > serial_dl_write(up, quot); > > -- > > 2.26.2 > > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YMt/BGDFDl9VHAEAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 10:59:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 6CHvAWDFDl8ZFwAA0J78UA (envelope-from ); Wed, 15 Jul 2020 10:59:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=pks.im header.b=mpAXdMG0; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=LCQWndut X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 85DEBA3099; Wed, 15 Jul 2020 10:59:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729966AbgGOI7G (ORCPT + 1 other); Wed, 15 Jul 2020 04:59:06 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:60363 "EHLO wout1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729952AbgGOI7F (ORCPT ); Wed, 15 Jul 2020 04:59:05 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 5F74A39C; Wed, 15 Jul 2020 04:59:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 15 Jul 2020 04:59:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:mime-version:content-type; s=fm1; bh=grCkdD2jWEA7onIL8+JQxWBTuTayEwlI232LXSaOf/A=; b=mpAXdMG0Axyw 7CSwPzMx88d7FkwpGytvD0Nt4qW176ehshE47ZlSjcAc14Sz9Fxr1oMuXTU/YQiY rZWJFyrr43saTgNYN641JBdeSWNUvY8aVAPia8hr+9sc6XN6mZde/wWk0DUQn1WO PLCbHnZr/K6JYZtMH65OHImiFrIm75iaU6tLBlHWK93WjrJK4maYObdp1DxmQtyl 6lsP3P7LE90eh82GX6myVgiZyHMd2CuSe7EiaVCtnm0FtVM15DYgpqX3A9S4DASG UVvGbTMiWOf4BAvogr+b/FSzQyVa9r+x55qipf7t9izza7dTm64UvORR3/AFeRIS ltofovgWiA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=grCkdD2jWEA7onIL8+JQxWBTuTayE wlI232LXSaOf/A=; b=LCQWndutDSHn1WlTEgvmfS7WvXTuzsVVioHxWFxGBwplK Nhu12F+I1Gh1d7yJdhAbbAqs3wnKMB90B7gmFfmu6Ly1h84lr0rxYsB0ug7Q0m9K ufvhue16B4ilVugY31y+VPp/62DCruRY60cMrEgCpMpVeVyV9fV9VQzjvgj0kdcV xdRXRnLfXdftu7L7+z9/jZsG4PquegYqiP6hWIUjpQZLE8/ls0FHq8jUVI8eyZHl 2Jc2OILFeajUWTSo9/YBy1WmjM0FUKBUR/b+EmnRhk1ePpJp8qFY42JFDYYyXhRT 3eit3M1nWTvUA5n4os/Gn94b5CTjXlzD3ia5DmB6A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrfedvgddutdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtugesghdtreertddtvdenucfhrhhomheprfgrthhrihgtkhcu ufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepje eifedvueelfffgjeduffdvgefhiefgjefgvddvfeduvefffeevfffhgfekieffnecukfhp peejkedrheehrdegkedrfedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Received: from vm-mail.pks.im (x4e37301f.dyn.telefonica.de [78.55.48.31]) by mail.messagingengine.com (Postfix) with ESMTPA id B4EFB30600B2; Wed, 15 Jul 2020 04:59:02 -0400 (EDT) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 4c2231ee (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 15 Jul 2020 08:58:58 +0000 (UTC) Date: Wed, 15 Jul 2020 10:59:47 +0200 From: Patrick Steinhardt To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Subject: [PATCH] Bluetooth: Fix updating connecton state in `hci_encrypt_cfm` Message-ID: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="eAbsdosE1cNLO4uF" Content-Disposition: inline Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.10 / 15.00 / 200.00 X-Rspamd-Queue-Id: 85DEBA3099 X-Rspamd-UID: 61b208 --eAbsdosE1cNLO4uF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Starting with the upgrade to v5.8-rc3, I've noticed I wasn't able to connect to my Bluetooth headset properly anymore. While connecting to the device would eventually succeed, bluetoothd seemed to be confused about the current connection state where the state was flapping hence and forth. Bisecting this issue led to commit 3ca44c16b0dc ("Bluetooth: Consolidate encryption handling in hci_encrypt_cfm"), which refactored `hci_encrypt_cfm` to also handle updating the connection state. The commit in question changed the code to call `hci_connect_cfm` inside `hci_encrypt_cfm` and updating the connection state. But the conversion didn't keep old behaviour of when the connection state is updated, which now causes us to not properly update it anymore. Fix the issue by adding another parameter to the function that allows callers to specify whether the connection state should be updated, which allows us to restore previous behaviour. Fixes: 3ca44c16b0dc ("Bluetooth: Consolidate encryption handling in hci_enc= rypt_cfm") Signed-off-by: Patrick Steinhardt --- include/net/bluetooth/hci_core.h | 4 ++-- net/bluetooth/hci_event.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_c= ore.h index cdd4f1db8670..9abcc4a89abc 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1381,13 +1381,13 @@ static inline void hci_auth_cfm(struct hci_conn *co= nn, __u8 status) conn->security_cfm_cb(conn, status); } =20 -static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status) +static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, __u= 8 update_state) { struct hci_cb *cb; __u8 encrypt; =20 if (conn->state =3D=3D BT_CONFIG) { - if (status) + if (update_state) conn->state =3D BT_CONNECTED; =20 hci_connect_cfm(conn, status); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index cfeaee347db3..483d35eda2f1 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2931,7 +2931,7 @@ static void hci_auth_complete_evt(struct hci_dev *hde= v, struct sk_buff *skb) &cp); } else { clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); - hci_encrypt_cfm(conn, ev->status); + hci_encrypt_cfm(conn, ev->status, 0); } } =20 @@ -3016,7 +3016,7 @@ static void read_enc_key_size_complete(struct hci_dev= *hdev, u8 status, conn->enc_key_size =3D rp->key_size; } =20 - hci_encrypt_cfm(conn, 0); + hci_encrypt_cfm(conn, 0, 1); =20 unlock: hci_dev_unlock(hdev); @@ -3134,7 +3134,7 @@ static void hci_encrypt_change_evt(struct hci_dev *hd= ev, struct sk_buff *skb) } =20 notify: - hci_encrypt_cfm(conn, ev->status); + hci_encrypt_cfm(conn, ev->status, !ev->status); =20 unlock: hci_dev_unlock(hdev); --=20 2.27.0 --eAbsdosE1cNLO4uF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAl8OxYIACgkQVbJhu7ck PpRjOxAAhU43UIvw1uWfrB0Sl/6And9SXbT580tLQWc33qgJrgKEAr4ec5bIX5c5 UsNgmtmzkmw2Ka1xgvBPr/g4TMC6UQOwdvi+nCYWVtjyDZ0cogkvAZQGyUg3Re74 xfrO/Ef9PMrpGE3RlnctiOlut2blCK6SyGM37KYFI7Ec/20GTlDmQlkBY0BkZlyL d4VcwQQ5jtRXaT6YQOPghJP7ksohNA18QxP9DfUKYStZT9J5FW2XybsQF9Um5R7B xPv3BtYIpmWB44/n1dhZCHd6Tk20uWnsLgD2L0/xRx4J8KMLVr4OtqhqijoVGL2O TFGZNKvwb9YAN8HTxlqPDEBMv1nu5bPEAI9LUTIjcQZDPMxiNMTq1xesjoPuHeKu g6sB8p9fDgT/n3FlcZZpshweechp1U5tFcqN/3wlsqWTBvk1cVrMsK6IHyMJH/WE LB47DtyjLtMG8T41B545kTPccMRClPoQPohoBmFWS5JriAS+1pFAxs+EkUp8dDwT u0H6QKfokFF0gyeYDlbz+YsdP68nq78YtWhjRb7fCmF7Vu7Q8AhUdosNRNcVgemM b0vl/L7rh+Dgj2kNVXSsrb7VWfjcntyua4EMjemW8M+5bFT2MFWtyfA5wSg40X5F QCSkF/HFKGy+0cTZHjQH/AVFeYMfkXxPoO9z8Jv5ROD5gn+4Zls= =q2aI -----END PGP SIGNATURE----- --eAbsdosE1cNLO4uF-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cA+tFHgBD1/jlQAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 15:15:36 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 4LhxE3gBD1/dHgEA0J78UA (envelope-from ); Wed, 15 Jul 2020 15:15:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BDBC6A5711; Wed, 15 Jul 2020 15:15:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731537AbgGONPY (ORCPT + 1 other); Wed, 15 Jul 2020 09:15:24 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:54968 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729900AbgGONPX (ORCPT ); Wed, 15 Jul 2020 09:15:23 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 1FBF5CECEE; Wed, 15 Jul 2020 15:25:19 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v1] Bluetooth: Add per-instance adv disable/remove From: Marcel Holtmann In-Reply-To: <20200714141547.v1.1.Icd35ad65fb4136d45dd701ef9022fa8f7c9e5d65@changeid> Date: Wed, 15 Jul 2020 15:15:20 +0200 Cc: Bluetooth Kernel Mailing List , chromeos-bluetooth-upstreaming , Shyh-In Hwang , Alain Michaud , "David S. Miller" , Jakub Kicinski , Johan Hedberg , kernel list , netdev@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <89CE3AFF-C04F-420A-9303-B3BA7A2C5F6E@holtmann.org> References: <20200714141547.v1.1.Icd35ad65fb4136d45dd701ef9022fa8f7c9e5d65@changeid> To: Daniel Winkler X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.03 / 15.00 / 200.00 X-Rspamd-Queue-Id: BDBC6A5711 X-Rspamd-UID: 814a3f Hi Daniel, > Add functionality to disable and remove advertising instances, > and use that functionality in MGMT add/remove advertising calls. > > Signed-off-by: Daniel Winkler > Reviewed-by: Shyh-In Hwang > Reviewed-by: Alain Michaud > --- > > net/bluetooth/hci_conn.c | 2 +- > net/bluetooth/hci_request.c | 59 +++++++++++++++++++++++++++++++------ > net/bluetooth/hci_request.h | 2 ++ > net/bluetooth/mgmt.c | 6 ++++ > 4 files changed, 59 insertions(+), 10 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WCP4DmgFD18atwEAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 15:32:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +EvlDWgFD19wSQEADc0bRg (envelope-from ); Wed, 15 Jul 2020 15:32:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CF634A4E64; Wed, 15 Jul 2020 15:32:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731694AbgGONcS convert rfc822-to-8bit (ORCPT + 1 other); Wed, 15 Jul 2020 09:32:18 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:46280 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731174AbgGONcS (ORCPT ); Wed, 15 Jul 2020 09:32:18 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 51D37CECEE; Wed, 15 Jul 2020 15:42:15 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [RFC v2] Bluetooth: btusb: Add support for queuing during polling interval From: Marcel Holtmann In-Reply-To: <20200714231200.690268-1-luiz.dentz@gmail.com> Date: Wed, 15 Jul 2020 15:32:16 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <6FFBD209-BAFB-4E06-B767-FB7618C19CC6@holtmann.org> References: <20200714231200.690268-1-luiz.dentz@gmail.com> To: Luiz Augusto von Dentz X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 20 X-Rspamd-Score: 3.11 / 15.00 / 200.00 X-Rspamd-Queue-Id: CF634A4E64 X-Rspamd-UID: 64c859 Hi Luiz, > This makes btusb to queue ACL and events during a polling interval > by using of a delayed work, with the interval working as a time window > where frames received from different endpoints are considered to be > arrived at same time and then attempt to resolve potential conflics by > processing the events ahead of ACL packets. > > It worth noting though that priorizing events over ACL data may result > in inverting the order compared to how they appeared over the air, for > instance there may be packets received before a disconnect event that > will be discarded and unencrypted packets received before encryption > change which would considered encrypted, because of these potential > changes on the order the support for queuing during the polling > interval is not enabled by default so platforms have the following > means to enable it: > > At build-time: > > CONFIG_BT_HCIBTUSB_INTERVAL=y > > At runtime with use of module option: > > enable_interval I like that this is confined into btusb.c, but now the question is if this is actually enough for handling this issue. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mK/jC8UND1/IdAAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 16:08:05 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id ILhZCsUND18vZwAAgupzMw (envelope-from ); Wed, 15 Jul 2020 16:08:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 72F1BA5A4D; Wed, 15 Jul 2020 16:08:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730013AbgGOOHt (ORCPT + 1 other); Wed, 15 Jul 2020 10:07:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729976AbgGOOHt (ORCPT ); Wed, 15 Jul 2020 10:07:49 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BEF2C08C5DD for ; Wed, 15 Jul 2020 07:07:48 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id d17so2770663ljl.3 for ; Wed, 15 Jul 2020 07:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GwtK5O+3Qx+AW5UZbEsmQwmztNE5Qtm0zrRpOgCDPDw=; b=Z50q0jva64kKnA9bHxbkza5a5OVSleUKldlv8Mv8wTlW4u+9mfkSq5rCs6yX2/4vQ8 5puB36UVAZ+fN8PbGHm08yBB6ZxUxUtbrXuHK/GPih8VC9gCKvdCZZFUXV8zqsWSEzlC 6XUnIeauibzUDnR4lNCvssVOIpwjQFnsaAUfUD0nTFZCHKzIOh70zfUDWcBrl6FEjrOm Z0aM4yWcntmALqXLajKUje1xqa9SuIJJ7LgEHQfLD1Ulsu8UUQwlAUVYWUsNW3vCLcZG HIcLaMYL4H/DcjXoQViMNLjqL4dVNMH976G2YBN0KsNAgnvdg7Ii2/DG6+1mk5ho5hlh DLsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=GwtK5O+3Qx+AW5UZbEsmQwmztNE5Qtm0zrRpOgCDPDw=; b=aSVR0beqjdkMB+Q7UdzDNDn0hJcJQDbHYKzF18frWoWG2nmdBMvZdpBcktYgK8IQeD AIYRUE3MpkDBrWGliQoJSJJ4hxahi/N5ovvQC4m3TEhapVoOBFkOXXXDAP3X0RpGU7Eo p4SrNt/Us6mgR6rjudUtvndsvtJWAj9gu/k6ln1xiSF0ARkiJgjWNx7eLf6k8mGkk31I Jznf/1l4+tzvBqa1Ex/VBEfXJSz8C/xFqNqA7IdTrNfyWtfC70b9XXDZ+EX6lrqj0Wjn R5Hfk8CdsNqRMZgjbwROHpjG2zbs6QVGilH5W3BnoV+6eoutxaffDEvajlqAJEeyt1Pe xYCA== X-Gm-Message-State: AOAM530CVTsQZLwNfDKbdQKslIFkn9tvUxwVYtzgAdVuI3hUamXfNRhd xyO0VwG1ZIcVCo1cQMdBb3sjqyaa+HPWIldsO8sLyg== X-Google-Smtp-Source: ABdhPJy2WUzzkfkT10PYJGKtS94RXc6kQXRSwbO/aYsMFwqVZXHCzcQxLFlgFleSif/e8ahKTdDig7VMSo2cJSutYKQ= X-Received: by 2002:a2e:80cc:: with SMTP id r12mr5410540ljg.344.1594822066627; Wed, 15 Jul 2020 07:07:46 -0700 (PDT) MIME-Version: 1.0 References: <20200627105437.453053-1-apusaka@google.com> <20200627185320.RFC.v1.1.Icea550bb064a24b89f2217cf19e35b4480a31afd@changeid> <91CFE951-262A-4E83-8550-25445AE84B5A@holtmann.org> <7BBB55E0-FBD9-40C0-80D9-D5E7FC9F80D2@holtmann.org> In-Reply-To: From: Alain Michaud Date: Wed, 15 Jul 2020 10:07:35 -0400 Message-ID: Subject: Re: [RFC PATCH v1 1/2] Bluetooth: queue ACL packets if no handle is found To: Marcel Holtmann Cc: Archie Pusaka , linux-bluetooth , chromeos-bluetooth-upstreaming , Abhishek Pandit-Subedi , "David S. Miller" , Jakub Kicinski , Johan Hedberg , kernel list , netdev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 72F1BA5A4D X-Rspamd-UID: a87235 Resending in plain text. On Wed, Jul 15, 2020 at 9:56 AM Alain Michaud wro= te: > > Hi Marcel, > > Sorry, just got around to this. > > On Tue, Jun 30, 2020 at 2:55 AM Marcel Holtmann wro= te: >> >> Hi Archie, >> >> >>> There is a possibility that an ACL packet is received before we >> >>> receive the HCI connect event for the corresponding handle. If this >> >>> happens, we discard the ACL packet. >> >>> >> >>> Rather than just ignoring them, this patch provides a queue for >> >>> incoming ACL packet without a handle. The queue is processed when >> >>> receiving a HCI connection event. If 2 seconds elapsed without >> >>> receiving the HCI connection event, assume something bad happened >> >>> and discard the queued packet. >> >>> >> >>> Signed-off-by: Archie Pusaka >> >>> Reviewed-by: Abhishek Pandit-Subedi >> >> >> >> so two things up front. I want to hide this behind a HCI_QUIRK_OUT_OF= _ORDER_ACL that a transport driver has to set first. Frankly if this kind o= f out-of-order happens on UART or SDIO transports, then something is obviou= sly going wrong. I have no plan to fix up after a fully serialized transpor= t. >> >> >> >> Secondly, if a transport sets HCI_QUIRK_OUT_OF_ORDER_ACL, then I want= this off by default. You can enable it via an experimental setting. The re= ason here is that we have to make it really hard and fail as often as possi= ble so that hardware manufactures and spec writers realize that something i= s fundamentally broken here. > > I don't have any objection to making this explicit enable to non serializ= ed transports. However, I do wonder what the intention is around making th= is off by default. We already know there is a race condition between the i= nterupt and bulk endpoints over USB, so this can and does happen. Hardware= manufaturers can't relly do much about this other than trying to pull the = interupt endpoint more often, but that's only a workaround, it can't avoid = it all together. > > IMO, this seems like a legitimate fix at the host level and I don't see a= ny obvious benefits to hide this fix under an experimental feature and make= it more difficult for the customers and system integrators to discover. > >> >> >> >> >> I have no problem in running the code and complaining loudly in case = the quirk has been set. Just injecting the packets can only happen if bluet= oothd explicitly enabled it. >> > >> > Got it. >> > >> >> >> >> >> >>> >> >>> --- >> >>> >> >>> include/net/bluetooth/hci_core.h | 8 +++ >> >>> net/bluetooth/hci_core.c | 84 +++++++++++++++++++++++++++++-= -- >> >>> net/bluetooth/hci_event.c | 2 + >> >>> 3 files changed, 88 insertions(+), 6 deletions(-) >> >>> >> >>> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetoot= h/hci_core.h >> >>> index 836dc997ff94..b69ecdd0d15a 100644 >> >>> --- a/include/net/bluetooth/hci_core.h >> >>> +++ b/include/net/bluetooth/hci_core.h >> >>> @@ -270,6 +270,9 @@ struct adv_monitor { >> >>> /* Default authenticated payload timeout 30s */ >> >>> #define DEFAULT_AUTH_PAYLOAD_TIMEOUT 0x0bb8 >> >>> >> >>> +/* Time to keep ACL packets without a corresponding handle queued (= 2s) */ >> >>> +#define PENDING_ACL_TIMEOUT msecs_to_jiffies(2000) >> >>> + >> >> >> >> Do we have some btmon traces with timestamps. Isn=E2=80=99t a second = enough? Actually 2 seconds is an awful long time. >> > >> > When this happens in the test lab, the HCI connect event is about >> > 0.002 second behind the first ACL packet. We can change this if >> > required. >> > >> >> >> >>> struct amp_assoc { >> >>> __u16 len; >> >>> __u16 offset; >> >>> @@ -538,6 +541,9 @@ struct hci_dev { >> >>> struct delayed_work rpa_expired; >> >>> bdaddr_t rpa; >> >>> >> >>> + struct delayed_work remove_pending_acl; >> >>> + struct sk_buff_head pending_acl_q; >> >>> + >> >> >> >> can we name this ooo_q and move it to the other queues in this struct= . Unless we want to add a Kconfig option around it, we don=E2=80=99t need t= o keep it here. >> > >> > Ack. >> > >> >> >> >>> #if IS_ENABLED(CONFIG_BT_LEDS) >> >>> struct led_trigger *power_led; >> >>> #endif >> >>> @@ -1773,6 +1779,8 @@ void hci_le_start_enc(struct hci_conn *conn, _= _le16 ediv, __le64 rand, >> >>> void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdadd= r, >> >>> u8 *bdaddr_type); >> >>> >> >>> +void hci_process_pending_acl(struct hci_dev *hdev, struct hci_conn = *conn); >> >>> + >> >>> #define SCO_AIRMODE_MASK 0x0003 >> >>> #define SCO_AIRMODE_CVSD 0x0000 >> >>> #define SCO_AIRMODE_TRANSP 0x0003 >> >>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c >> >>> index 7959b851cc63..30780242c267 100644 >> >>> --- a/net/bluetooth/hci_core.c >> >>> +++ b/net/bluetooth/hci_core.c >> >>> @@ -1786,6 +1786,7 @@ int hci_dev_do_close(struct hci_dev *hdev) >> >>> skb_queue_purge(&hdev->rx_q); >> >>> skb_queue_purge(&hdev->cmd_q); >> >>> skb_queue_purge(&hdev->raw_q); >> >>> + skb_queue_purge(&hdev->pending_acl_q); >> >>> >> >>> /* Drop last sent command */ >> >>> if (hdev->sent_cmd) { >> >>> @@ -3518,6 +3519,78 @@ static int hci_suspend_notifier(struct notifi= er_block *nb, unsigned long action, >> >>> return NOTIFY_STOP; >> >>> } >> >>> >> >>> +static void hci_add_pending_acl(struct hci_dev *hdev, struct sk_buf= f *skb) >> >>> +{ >> >>> + skb_queue_tail(&hdev->pending_acl_q, skb); >> >>> + >> >>> + queue_delayed_work(hdev->workqueue, &hdev->remove_pending_acl, >> >>> + PENDING_ACL_TIMEOUT); >> >>> +} >> >>> + >> >>> +void hci_process_pending_acl(struct hci_dev *hdev, struct hci_conn = *conn) >> >>> +{ >> >>> + struct sk_buff *skb, *tmp; >> >>> + struct hci_acl_hdr *hdr; >> >>> + u16 handle, flags; >> >>> + bool reset_timer =3D false; >> >>> + >> >>> + skb_queue_walk_safe(&hdev->pending_acl_q, skb, tmp) { >> >>> + hdr =3D (struct hci_acl_hdr *)skb->data; >> >>> + handle =3D __le16_to_cpu(hdr->handle); >> >>> + flags =3D hci_flags(handle); >> >>> + handle =3D hci_handle(handle); >> >>> + >> >>> + if (handle !=3D conn->handle) >> >>> + continue; >> >>> + >> >>> + __skb_unlink(skb, &hdev->pending_acl_q); >> >>> + skb_pull(skb, HCI_ACL_HDR_SIZE); >> >>> + >> >>> + l2cap_recv_acldata(conn, skb, flags); >> >>> + reset_timer =3D true; >> >>> + } >> >>> + >> >>> + if (reset_timer) >> >>> + mod_delayed_work(hdev->workqueue, &hdev->remove_pendin= g_acl, >> >>> + PENDING_ACL_TIMEOUT); >> >>> +} >> >>> + >> >>> +/* Remove the oldest pending ACL, and all pending ACLs with the sam= e handle */ >> >>> +static void hci_remove_pending_acl(struct work_struct *work) >> >>> +{ >> >>> + struct hci_dev *hdev; >> >>> + struct sk_buff *skb, *tmp; >> >>> + struct hci_acl_hdr *hdr; >> >>> + u16 handle, oldest_handle; >> >>> + >> >>> + hdev =3D container_of(work, struct hci_dev, remove_pending_acl= .work); >> >>> + skb =3D skb_dequeue(&hdev->pending_acl_q); >> >>> + >> >>> + if (!skb) >> >>> + return; >> >>> + >> >>> + hdr =3D (struct hci_acl_hdr *)skb->data; >> >>> + oldest_handle =3D hci_handle(__le16_to_cpu(hdr->handle)); >> >>> + kfree_skb(skb); >> >>> + >> >>> + bt_dev_err(hdev, "ACL packet for unknown connection handle %d"= , >> >>> + oldest_handle); >> >>> + >> >>> + skb_queue_walk_safe(&hdev->pending_acl_q, skb, tmp) { >> >>> + hdr =3D (struct hci_acl_hdr *)skb->data; >> >>> + handle =3D hci_handle(__le16_to_cpu(hdr->handle)); >> >>> + >> >>> + if (handle =3D=3D oldest_handle) { >> >>> + __skb_unlink(skb, &hdev->pending_acl_q); >> >>> + kfree_skb(skb); >> >>> + } >> >>> + } >> >>> + >> >>> + if (!skb_queue_empty(&hdev->pending_acl_q)) >> >>> + queue_delayed_work(hdev->workqueue, &hdev->remove_pend= ing_acl, >> >>> + PENDING_ACL_TIMEOUT); >> >>> +} >> >>> + >> >> >> >> So I am wondering if we make this too complicated. Since generally sp= eaking we can only have a single HCI connect complete anyway at a time. No = matter if the controller serializes it for us or we do it for the controlle= r. So hci_conn_add could just process the queue for packets with its handle= and then flush it. And it can flush it no matter what since whatever other= packets are in the queue, they can not be valid. >> >> >> >> That said, we wouldn=E2=80=99t even need to check the packet handles = at all. We just needed to flag them as already out-of-order queued once and= hand them back into the rx_q at the top. Then the would be processed as us= ual. Already ooo packets would cause the same error as before if it is for = a non-existing handle and others would end up being processed. >> >> >> >> For me this means we just need another queue to park the packets unti= l hci_conn_add gets called. I might have missed something, but I am looking= for the least invasive option for this and least code duplication. >> > >> > I'm not aware of the fact that we can only have a single HCI connect >> > complete event at any time. Is this also true even if two / more >> > peripherals connect at the same time? >> > I was under the impression that if we have device A and B both are >> > connecting to us at the same time, we might receive the packets in >> > this order: >> > (1) ACL A >> > (2) ACL B >> > (3) HCI conn evt B >> > (4) HCI conn evt A >> > Hence the queue and the handle check. >> >> my reading from the LL state machine is that once the first LL_Connect_R= eq is processes, the controller moves out of the advertising state. So no o= ther LL_Connect_Req can be processed. So that means that connection attempt= s are serialized. >> >> Now if you run AE and multiple instances, that might be different, but t= hen again, these instances are also offset in time and so I don=E2=80=99t s= ee how we can get more than one HCI_Connection_Complete event at a time (an= d with that a leading ACL packet). >> >> Regards >> >> Marcel >> >> -- >> You received this message because you are subscribed to the Google Group= s "ChromeOS Bluetooth Upstreaming" group. >> To unsubscribe from this group and stop receiving emails from it, send a= n email to chromeos-bluetooth-upstreaming+unsubscribe@chromium.org. >> To post to this group, send email to chromeos-bluetooth-upstreaming@chro= mium.org. >> To view this discussion on the web visit https://groups.google.com/a/chr= omium.org/d/msgid/chromeos-bluetooth-upstreaming/7BBB55E0-FBD9-40C0-80D9-D5= E7FC9F80D2%40holtmann.org. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ECugAfIPD1/aXgAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 16:17:22 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iC1kO/EPD1+g0QEADc0bRg (envelope-from ); Wed, 15 Jul 2020 16:17:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BD98D536A0; Wed, 15 Jul 2020 16:17:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726965AbgGOOPh (ORCPT + 1 other); Wed, 15 Jul 2020 10:15:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbgGOOPh (ORCPT ); Wed, 15 Jul 2020 10:15:37 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2AE6C061755 for ; Wed, 15 Jul 2020 07:15:36 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id j18so5770111wmi.3 for ; Wed, 15 Jul 2020 07:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=1ewJDA+uKRhpNjXIL8tsMezrJq68UXqo5kRUEl5auJs=; b=Fru6NuFPC3iRhBULRCMIXdcBJN/ZQLaLKB92qpZ17u/6fH04xPLPYJi4Kiio3F1gdI HixvMzkyiM9Iwzx/2JTVtWa24U9zk5+obGxY4yDYTsjOpE/Xw1ste2WnbI3qlPXF+N9k uEk1UViISOTlno6Q/mF8MeaBhytkGJQ+kwr2YQLO221CDQx5Dmrqy9INso/0xvNFT245 yWptLwHN1oA0VKVgBPsltf/PFwI8wb3QgXdw8xquUbN73/eP5DebexH4lJCty6bAFoJN sbRBnZAVR59NQUKoTasG3BuvHwcNuxHo3hJBVzMv6Z8/L7BsfSvgBD2v+ZzNjkffiDw3 mTPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=1ewJDA+uKRhpNjXIL8tsMezrJq68UXqo5kRUEl5auJs=; b=Rl9p7z8QEfehVHYb3K21gDSTM6xiBnGG+xQlwNXhFDPx9f4Wp/qmRlj2MN+9WHKLU6 YipvERfzEmHBrcHrAvfIKOJOvDOA1BONQrcATrn4TCpLv2wI2STrM5EL/Os4ku6mpfL1 iIM/zVRLvZemh4SlS1LL54LdeKFMjzEt3iydVJpwq6eNLVY9vT+vXrScOAvwbeb6H11X vyXAr1XdC75+UhdfK7CTSggYhfehmiHPcu/Yo+sYsAgYEQLGmT2YpEK2qQE8hUBRnygj z78eju0t2vG25W2ge3YRbHZAWbsCVbp979qpMHjwlclzTFwfT7d3HGMhIV/vPZMfJ7I/ k+Ew== X-Gm-Message-State: AOAM533/Eb+tznlwdY1DWBu17QMr7cjU3+l7/tEDJKCrKn0WRPG1xzWK /jyoqmIDMlVwgdIfbVcvS4ZvIV4EWc3v6Qz0TtUFnQ== X-Google-Smtp-Source: ABdhPJzrGwvzSR9TRYQjfx/W/2r9Vxcf1SZC4LAX1ZQ4PjsfbnnqWY/L4HscvKFL2s+gDQzn5WGx2IY0gNDdQV9K2ro= X-Received: by 2002:a7b:cf18:: with SMTP id l24mr8846396wmg.116.1594822534882; Wed, 15 Jul 2020 07:15:34 -0700 (PDT) MIME-Version: 1.0 References: <20200627235318.Bluez.v2.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> In-Reply-To: From: Archie Pusaka Date: Wed, 15 Jul 2020 22:15:23 +0800 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] device: add device_remove_bonding function To: Luiz Augusto von Dentz Cc: linux-bluetooth , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: BD98D536A0 X-Rspamd-UID: dba4ad Hi Luiz, If we mark it as temporary, then the device will immediately get deleted upon disconnection. https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/adapter.c#n6875 This is the same situation as directly calling device_remove. May I know the reason why we want to put the device as temporary? If we currently don't have a way to keep a "previously connected but no longer bonded" device, then removing the device perhaps is the next best option. It still makes the user scan for the virtually disconnected device though. Thanks, Archie On Wed, 15 Jul 2020 at 01:10, Luiz Augusto von Dentz wrote: > > Hi Archie, > > On Tue, Jul 7, 2020 at 9:30 PM Archie Pusaka wrote: > > > > Hi Luiz, > > > > As far as the spec is concerned, we can also remove the device by > > calling device_remove. However, I suppose it would be confusing for > > end users if they can no longer find their HID device on the device > > list just because the device previously sent a virtual cable > > disconnection. > > The HID 1.0 spec part 6.4.2 also gives an example of a possible > > scenario when a virtually cabled device is removed: "Unplugged devices > > shall be marked as known and put into a =E2=80=9Cmost recently used lis= t=E2=80=9D of > > known devices to facilitate future re-connecting". > > Then perhaps we shall have it marked as temporary as well, that said > we do want to introduce disappearing logic so temporary devices are > not left dangling for too long. > > > Thanks, > > Archie > > > > > > On Wed, 8 Jul 2020 at 02:03, Luiz Augusto von Dentz > > wrote: > > > > > > Hi Archie, > > > > > > On Sat, Jun 27, 2020 at 8:54 AM Archie Pusaka wr= ote: > > > > > > > > From: Archie Pusaka > > > > > > > > This patch splits the "bonding removal" function in device.c, > > > > because we need to remove bonding information when receiving > > > > "virtual cable unplug" in HID profile. > > > > > > > > Reviewed-by: Alain Michaud > > > > --- > > > > > > > > Changes in v2: None > > > > > > > > src/device.c | 25 +++++++++++++++---------- > > > > src/device.h | 1 + > > > > 2 files changed, 16 insertions(+), 10 deletions(-) > > > > > > > > diff --git a/src/device.c b/src/device.c > > > > index 7b0eb256e..9fb0e018c 100644 > > > > --- a/src/device.c > > > > +++ b/src/device.c > > > > @@ -4162,6 +4162,17 @@ static void delete_folder_tree(const char *d= irname) > > > > rmdir(dirname); > > > > } > > > > > > > > +void device_remove_bonding(struct btd_device *device, uint8_t bdad= dr_type) > > > > +{ > > > > + if (bdaddr_type =3D=3D BDADDR_BREDR) > > > > + device->bredr_state.bonded =3D false; > > > > + else > > > > + device->le_state.bonded =3D false; > > > > + > > > > + btd_adapter_remove_bonding(device->adapter, &device->bdaddr= , > > > > + bdaddr_type= ); > > > > +} > > > > + > > > > static void device_remove_stored(struct btd_device *device) > > > > { > > > > char device_addr[18]; > > > > @@ -4170,17 +4181,11 @@ static void device_remove_stored(struct btd= _device *device) > > > > char *data; > > > > gsize length =3D 0; > > > > > > > > - if (device->bredr_state.bonded) { > > > > - device->bredr_state.bonded =3D false; > > > > - btd_adapter_remove_bonding(device->adapter, &device= ->bdaddr, > > > > - BDA= DDR_BREDR); > > > > - } > > > > + if (device->bredr_state.bonded) > > > > + device_remove_bonding(device, BDADDR_BREDR); > > > > > > > > - if (device->le_state.bonded) { > > > > - device->le_state.bonded =3D false; > > > > - btd_adapter_remove_bonding(device->adapter, &device= ->bdaddr, > > > > - device->bda= ddr_type); > > > > - } > > > > + if (device->le_state.bonded) > > > > + device_remove_bonding(device, device->bdaddr_type); > > > > > > > > device->bredr_state.paired =3D false; > > > > device->le_state.paired =3D false; > > > > diff --git a/src/device.h b/src/device.h > > > > index 06b100499..907c7c5c4 100644 > > > > --- a/src/device.h > > > > +++ b/src/device.h > > > > @@ -49,6 +49,7 @@ uint16_t btd_device_get_vendor(struct btd_device = *device); > > > > uint16_t btd_device_get_vendor_src(struct btd_device *device); > > > > uint16_t btd_device_get_product(struct btd_device *device); > > > > uint16_t btd_device_get_version(struct btd_device *device); > > > > +void device_remove_bonding(struct btd_device *device, uint8_t bdad= dr_type); > > > > void device_remove(struct btd_device *device, gboolean remove_stor= ed); > > > > > > Is there any particular reason why device_remove is not enough here? = I > > > don't see any reason to leave the device object around after removing > > > its bonding. > > > > > > > int device_address_cmp(gconstpointer a, gconstpointer b); > > > > int device_bdaddr_cmp(gconstpointer a, gconstpointer b); > > > > -- > > > > 2.27.0.212.ge8ba1cc988-goog > > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ALF/GoAjD1827QAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 17:40:48 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 4E8gGYAjD1+gpgAAlp8NpQ (envelope-from ); Wed, 15 Jul 2020 17:40:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6B98052F40; Wed, 15 Jul 2020 17:40:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726675AbgGOP0N (ORCPT + 1 other); Wed, 15 Jul 2020 11:26:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726425AbgGOP0M (ORCPT ); Wed, 15 Jul 2020 11:26:12 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF99DC061755; Wed, 15 Jul 2020 08:26:11 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id 12so2509573oir.4; Wed, 15 Jul 2020 08:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=4u0MYE5Hv4MZlWDF0+ytXg/Vh8b5Piy9y2hJOynhogo=; b=YBmd4Z/FA3zV0n93TF3jJ85Cupe79N4fRRDu3keVic1IjVfEC2I2qRO1URuvKUxh81 uPXcz/CNeRcvb4Jlg+Ujq59fbYcXe86CQTAJrhJf838Z5ZQT4p/fbZnX0iDId0UX+70G VT4w6MPcUPZg1Qs7DfliKEbO2u/1vORQFraIRU2/SGxil8Ni5Tg/qnLCb3t7Gl7PAveq TixNPVrmORBGYetOV4E2wRlKko0Kp+rCAcYU2guLnJY7dg0Npmm7rODq+FOW+DWplPlt LJK/C7Q4Kl2aj/bm4mGa7njGcQdhtx48alzGH/eYYhus8Xek6vFoTVuako2jo6/5gItE GsnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=4u0MYE5Hv4MZlWDF0+ytXg/Vh8b5Piy9y2hJOynhogo=; b=OX0sex9V4OMjYcmFsCGG4yAogbKuCvOYEkx+334WnQ3P98KmfdmqNuMdqqJ7T0OtN5 D4fQ06tDfzzOCu319EW1gWEDj7sm69XJp3PLWxK8RxRM3qmPQUvoXdpTKmY1IFye1BzB 0AVK5zmDM18zWls9hbVadGXexORv2xSzECcNSBg9w5wmnad62TPsrPBXd50FewP3/LOZ 3AgJ5JiVAS7YVI12wiOfV8xqC5VYrvLEKSBKm64xui1xqXHr5l3KjWlGe+eZ7Ua4iRR/ pL/+cl4geTiWRFU9yzv2Yuvs91IegTUgrBwm+J7vqrVr98JjvEPxcZbgpDinYGy50bb3 cmew== X-Gm-Message-State: AOAM530h9sOS+lgHSwH7zKvSueKeEUsxclakhGa51Xe7kVpyZIU3GAIV WsLUIjwNsZlLwRxSypY9wEHa9ChJxGMF2s+QYtY= X-Google-Smtp-Source: ABdhPJyvP5/WOrJAQhh5gAFgy3OCO1l0+YuNhb0lE44rireuqmPWrg9uu4/Zd/ksXagftdMRIRBf2ykLxj9iBGqHWJc= X-Received: by 2002:aca:4a04:: with SMTP id x4mr205534oia.152.1594826770975; Wed, 15 Jul 2020 08:26:10 -0700 (PDT) MIME-Version: 1.0 References: <20200627105437.453053-1-apusaka@google.com> <20200627185320.RFC.v1.1.Icea550bb064a24b89f2217cf19e35b4480a31afd@changeid> <91CFE951-262A-4E83-8550-25445AE84B5A@holtmann.org> <7BBB55E0-FBD9-40C0-80D9-D5E7FC9F80D2@holtmann.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Wed, 15 Jul 2020 08:25:54 -0700 Message-ID: Subject: Re: [RFC PATCH v1 1/2] Bluetooth: queue ACL packets if no handle is found To: Alain Michaud Cc: Marcel Holtmann , Archie Pusaka , linux-bluetooth , chromeos-bluetooth-upstreaming , Abhishek Pandit-Subedi , "David S. Miller" , Jakub Kicinski , Johan Hedberg , kernel list , netdev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6B98052F40 X-Rspamd-UID: 667095 Hi Alain, On Wed, Jul 15, 2020 at 8:10 AM Alain Michaud wro= te: > > Resending in plain text. I've sent a RFC to work out the ordering, that should work out for any race where it process ACL before Events during a polling interval (1ms) so I hope that is enough to catch all these races, if that is not perhaps we could make the interval configurable. > > On Wed, Jul 15, 2020 at 9:56 AM Alain Michaud w= rote: > > > > Hi Marcel, > > > > Sorry, just got around to this. > > > > On Tue, Jun 30, 2020 at 2:55 AM Marcel Holtmann w= rote: > >> > >> Hi Archie, > >> > >> >>> There is a possibility that an ACL packet is received before we > >> >>> receive the HCI connect event for the corresponding handle. If thi= s > >> >>> happens, we discard the ACL packet. > >> >>> > >> >>> Rather than just ignoring them, this patch provides a queue for > >> >>> incoming ACL packet without a handle. The queue is processed when > >> >>> receiving a HCI connection event. If 2 seconds elapsed without > >> >>> receiving the HCI connection event, assume something bad happened > >> >>> and discard the queued packet. > >> >>> > >> >>> Signed-off-by: Archie Pusaka > >> >>> Reviewed-by: Abhishek Pandit-Subedi > >> >> > >> >> so two things up front. I want to hide this behind a HCI_QUIRK_OUT_= OF_ORDER_ACL that a transport driver has to set first. Frankly if this kind= of out-of-order happens on UART or SDIO transports, then something is obvi= ously going wrong. I have no plan to fix up after a fully serialized transp= ort. > >> >> > >> >> Secondly, if a transport sets HCI_QUIRK_OUT_OF_ORDER_ACL, then I wa= nt this off by default. You can enable it via an experimental setting. The = reason here is that we have to make it really hard and fail as often as pos= sible so that hardware manufactures and spec writers realize that something= is fundamentally broken here. > > > > I don't have any objection to making this explicit enable to non serial= ized transports. However, I do wonder what the intention is around making = this off by default. We already know there is a race condition between the= interupt and bulk endpoints over USB, so this can and does happen. Hardwa= re manufaturers can't relly do much about this other than trying to pull th= e interupt endpoint more often, but that's only a workaround, it can't avoi= d it all together. > > > > IMO, this seems like a legitimate fix at the host level and I don't see= any obvious benefits to hide this fix under an experimental feature and ma= ke it more difficult for the customers and system integrators to discover. > > > >> > >> >> > >> >> I have no problem in running the code and complaining loudly in cas= e the quirk has been set. Just injecting the packets can only happen if blu= etoothd explicitly enabled it. > >> > > >> > Got it. > >> > > >> >> > >> >> > >> >>> > >> >>> --- > >> >>> > >> >>> include/net/bluetooth/hci_core.h | 8 +++ > >> >>> net/bluetooth/hci_core.c | 84 ++++++++++++++++++++++++++++= +--- > >> >>> net/bluetooth/hci_event.c | 2 + > >> >>> 3 files changed, 88 insertions(+), 6 deletions(-) > >> >>> > >> >>> diff --git a/include/net/bluetooth/hci_core.h b/include/net/blueto= oth/hci_core.h > >> >>> index 836dc997ff94..b69ecdd0d15a 100644 > >> >>> --- a/include/net/bluetooth/hci_core.h > >> >>> +++ b/include/net/bluetooth/hci_core.h > >> >>> @@ -270,6 +270,9 @@ struct adv_monitor { > >> >>> /* Default authenticated payload timeout 30s */ > >> >>> #define DEFAULT_AUTH_PAYLOAD_TIMEOUT 0x0bb8 > >> >>> > >> >>> +/* Time to keep ACL packets without a corresponding handle queued= (2s) */ > >> >>> +#define PENDING_ACL_TIMEOUT msecs_to_jiffies(2000) > >> >>> + > >> >> > >> >> Do we have some btmon traces with timestamps. Isn=E2=80=99t a secon= d enough? Actually 2 seconds is an awful long time. > >> > > >> > When this happens in the test lab, the HCI connect event is about > >> > 0.002 second behind the first ACL packet. We can change this if > >> > required. > >> > > >> >> > >> >>> struct amp_assoc { > >> >>> __u16 len; > >> >>> __u16 offset; > >> >>> @@ -538,6 +541,9 @@ struct hci_dev { > >> >>> struct delayed_work rpa_expired; > >> >>> bdaddr_t rpa; > >> >>> > >> >>> + struct delayed_work remove_pending_acl; > >> >>> + struct sk_buff_head pending_acl_q; > >> >>> + > >> >> > >> >> can we name this ooo_q and move it to the other queues in this stru= ct. Unless we want to add a Kconfig option around it, we don=E2=80=99t need= to keep it here. > >> > > >> > Ack. > >> > > >> >> > >> >>> #if IS_ENABLED(CONFIG_BT_LEDS) > >> >>> struct led_trigger *power_led; > >> >>> #endif > >> >>> @@ -1773,6 +1779,8 @@ void hci_le_start_enc(struct hci_conn *conn,= __le16 ediv, __le64 rand, > >> >>> void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bda= ddr, > >> >>> u8 *bdaddr_type); > >> >>> > >> >>> +void hci_process_pending_acl(struct hci_dev *hdev, struct hci_con= n *conn); > >> >>> + > >> >>> #define SCO_AIRMODE_MASK 0x0003 > >> >>> #define SCO_AIRMODE_CVSD 0x0000 > >> >>> #define SCO_AIRMODE_TRANSP 0x0003 > >> >>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > >> >>> index 7959b851cc63..30780242c267 100644 > >> >>> --- a/net/bluetooth/hci_core.c > >> >>> +++ b/net/bluetooth/hci_core.c > >> >>> @@ -1786,6 +1786,7 @@ int hci_dev_do_close(struct hci_dev *hdev) > >> >>> skb_queue_purge(&hdev->rx_q); > >> >>> skb_queue_purge(&hdev->cmd_q); > >> >>> skb_queue_purge(&hdev->raw_q); > >> >>> + skb_queue_purge(&hdev->pending_acl_q); > >> >>> > >> >>> /* Drop last sent command */ > >> >>> if (hdev->sent_cmd) { > >> >>> @@ -3518,6 +3519,78 @@ static int hci_suspend_notifier(struct noti= fier_block *nb, unsigned long action, > >> >>> return NOTIFY_STOP; > >> >>> } > >> >>> > >> >>> +static void hci_add_pending_acl(struct hci_dev *hdev, struct sk_b= uff *skb) > >> >>> +{ > >> >>> + skb_queue_tail(&hdev->pending_acl_q, skb); > >> >>> + > >> >>> + queue_delayed_work(hdev->workqueue, &hdev->remove_pending_ac= l, > >> >>> + PENDING_ACL_TIMEOUT); > >> >>> +} > >> >>> + > >> >>> +void hci_process_pending_acl(struct hci_dev *hdev, struct hci_con= n *conn) > >> >>> +{ > >> >>> + struct sk_buff *skb, *tmp; > >> >>> + struct hci_acl_hdr *hdr; > >> >>> + u16 handle, flags; > >> >>> + bool reset_timer =3D false; > >> >>> + > >> >>> + skb_queue_walk_safe(&hdev->pending_acl_q, skb, tmp) { > >> >>> + hdr =3D (struct hci_acl_hdr *)skb->data; > >> >>> + handle =3D __le16_to_cpu(hdr->handle); > >> >>> + flags =3D hci_flags(handle); > >> >>> + handle =3D hci_handle(handle); > >> >>> + > >> >>> + if (handle !=3D conn->handle) > >> >>> + continue; > >> >>> + > >> >>> + __skb_unlink(skb, &hdev->pending_acl_q); > >> >>> + skb_pull(skb, HCI_ACL_HDR_SIZE); > >> >>> + > >> >>> + l2cap_recv_acldata(conn, skb, flags); > >> >>> + reset_timer =3D true; > >> >>> + } > >> >>> + > >> >>> + if (reset_timer) > >> >>> + mod_delayed_work(hdev->workqueue, &hdev->remove_pend= ing_acl, > >> >>> + PENDING_ACL_TIMEOUT); > >> >>> +} > >> >>> + > >> >>> +/* Remove the oldest pending ACL, and all pending ACLs with the s= ame handle */ > >> >>> +static void hci_remove_pending_acl(struct work_struct *work) > >> >>> +{ > >> >>> + struct hci_dev *hdev; > >> >>> + struct sk_buff *skb, *tmp; > >> >>> + struct hci_acl_hdr *hdr; > >> >>> + u16 handle, oldest_handle; > >> >>> + > >> >>> + hdev =3D container_of(work, struct hci_dev, remove_pending_a= cl.work); > >> >>> + skb =3D skb_dequeue(&hdev->pending_acl_q); > >> >>> + > >> >>> + if (!skb) > >> >>> + return; > >> >>> + > >> >>> + hdr =3D (struct hci_acl_hdr *)skb->data; > >> >>> + oldest_handle =3D hci_handle(__le16_to_cpu(hdr->handle)); > >> >>> + kfree_skb(skb); > >> >>> + > >> >>> + bt_dev_err(hdev, "ACL packet for unknown connection handle %= d", > >> >>> + oldest_handle); > >> >>> + > >> >>> + skb_queue_walk_safe(&hdev->pending_acl_q, skb, tmp) { > >> >>> + hdr =3D (struct hci_acl_hdr *)skb->data; > >> >>> + handle =3D hci_handle(__le16_to_cpu(hdr->handle)); > >> >>> + > >> >>> + if (handle =3D=3D oldest_handle) { > >> >>> + __skb_unlink(skb, &hdev->pending_acl_q); > >> >>> + kfree_skb(skb); > >> >>> + } > >> >>> + } > >> >>> + > >> >>> + if (!skb_queue_empty(&hdev->pending_acl_q)) > >> >>> + queue_delayed_work(hdev->workqueue, &hdev->remove_pe= nding_acl, > >> >>> + PENDING_ACL_TIMEOUT); > >> >>> +} > >> >>> + > >> >> > >> >> So I am wondering if we make this too complicated. Since generally = speaking we can only have a single HCI connect complete anyway at a time. N= o matter if the controller serializes it for us or we do it for the control= ler. So hci_conn_add could just process the queue for packets with its hand= le and then flush it. And it can flush it no matter what since whatever oth= er packets are in the queue, they can not be valid. > >> >> > >> >> That said, we wouldn=E2=80=99t even need to check the packet handle= s at all. We just needed to flag them as already out-of-order queued once a= nd hand them back into the rx_q at the top. Then the would be processed as = usual. Already ooo packets would cause the same error as before if it is fo= r a non-existing handle and others would end up being processed. > >> >> > >> >> For me this means we just need another queue to park the packets un= til hci_conn_add gets called. I might have missed something, but I am looki= ng for the least invasive option for this and least code duplication. > >> > > >> > I'm not aware of the fact that we can only have a single HCI connect > >> > complete event at any time. Is this also true even if two / more > >> > peripherals connect at the same time? > >> > I was under the impression that if we have device A and B both are > >> > connecting to us at the same time, we might receive the packets in > >> > this order: > >> > (1) ACL A > >> > (2) ACL B > >> > (3) HCI conn evt B > >> > (4) HCI conn evt A > >> > Hence the queue and the handle check. > >> > >> my reading from the LL state machine is that once the first LL_Connect= _Req is processes, the controller moves out of the advertising state. So no= other LL_Connect_Req can be processed. So that means that connection attem= pts are serialized. > >> > >> Now if you run AE and multiple instances, that might be different, but= then again, these instances are also offset in time and so I don=E2=80=99t= see how we can get more than one HCI_Connection_Complete event at a time (= and with that a leading ACL packet). > >> > >> Regards > >> > >> Marcel > >> > >> -- > >> You received this message because you are subscribed to the Google Gro= ups "ChromeOS Bluetooth Upstreaming" group. > >> To unsubscribe from this group and stop receiving emails from it, send= an email to chromeos-bluetooth-upstreaming+unsubscribe@chromium.org. > >> To post to this group, send email to chromeos-bluetooth-upstreaming@ch= romium.org. > >> To view this discussion on the web visit https://groups.google.com/a/c= hromium.org/d/msgid/chromeos-bluetooth-upstreaming/7BBB55E0-FBD9-40C0-80D9-= D5E7FC9F80D2%40holtmann.org. --=20 Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oKGUBhsoD1+qQQAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 18:00:27 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id eOdKBRsoD1/xSAAAlScrYA (envelope-from ); Wed, 15 Jul 2020 18:00:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3F8A85373A; Wed, 15 Jul 2020 18:00:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727112AbgGOPd5 (ORCPT + 1 other); Wed, 15 Jul 2020 11:33:57 -0400 Received: from mga07.intel.com ([134.134.136.100]:15051 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbgGOPd4 (ORCPT ); Wed, 15 Jul 2020 11:33:56 -0400 IronPort-SDR: Ew9cDXoe8RIC35gWL4WgkZSouaKRwvKeaRkRxPL8bOep1Jt72xp5YB4zT8E/9NZNjTDws4VguC 1By4zNBhZkCA== X-IronPort-AV: E=McAfee;i="6000,8403,9683"; a="213933017" X-IronPort-AV: E=Sophos;i="5.75,355,1589266800"; d="scan'208";a="213933017" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2020 08:33:56 -0700 IronPort-SDR: eQNlUEQMvMT1f+o2OMUIG0wx6IhBgNeVLv2KscmeswGVw/K/CO2LO8vHo2kHXD7sWghoyPdzSR NqfsoUCCQaPA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,355,1589266800"; d="scan'208";a="324861575" Received: from bgi1-mobl2.amr.corp.intel.com ([10.251.11.134]) by FMSMGA003.fm.intel.com with ESMTP; 15 Jul 2020 08:33:55 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com Subject: [PATCH BlueZ] mesh: Fix node composition change detection Date: Wed, 15 Jul 2020 08:33:43 -0700 Message-Id: <20200715153343.2115695-1-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 28 X-Rspamd-Score: 4.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3F8A85373A X-Rspamd-UID: f9fde7 This fixes a bug that caused disallowed composition changes from being detected and rejected. The only fields that are allowed to freely change are CID, PID, VID and CRPL. --- mesh/node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh/node.c b/mesh/node.c index c61167bda..9b97aa927 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -1579,7 +1579,7 @@ static bool check_req_node(struct managed_obj_request *req) node = req->node; node_comp = node_get_comp(node, 0, &node_len); - len = node_generate_comp(node, comp, sizeof(comp)); + len = node_generate_comp(req->node, comp, sizeof(comp)); /* If no page 0 exists, save it and return */ if (req->type != REQUEST_TYPE_ATTACH || !node_len || !node_comp) -- 2.25.4 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uPPXMCEqD1/eaAAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 18:09:05 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 0KyALyEqD190owEA0J78UA (envelope-from ); Wed, 15 Jul 2020 18:09:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 35B6853798; Wed, 15 Jul 2020 18:08:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726446AbgGOPkV (ORCPT + 1 other); Wed, 15 Jul 2020 11:40:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbgGOPkU (ORCPT ); Wed, 15 Jul 2020 11:40:20 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB7F8C061755 for ; Wed, 15 Jul 2020 08:40:19 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id c4so547390oou.6 for ; Wed, 15 Jul 2020 08:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5n8TYGp5vc2hXKBCFOAMT1bwN0hqgSluIwICLUpdYjU=; b=kHJE/ZuLR/YtlhVnRHj7qPqtjnNImMXGbqPJhuhzQD05rklspcMm5S8+CXCYfspkAb PWUFaVXP5iUff9elBfB0kuJsl2Y305jpguuJXQST7RvJiwqV0/E/j/3Gps6d39jad9bQ cPqAPLhIQ+GI1GUhdduSB9A1lgC0MjtOHutnQFsQQjjbxbQ496Kq+4QzwGZ1VPN2FSRE sItYRYK52kWHv8gknNgy/S/dR4XQSeH95bH6KGzRNmqIc1Otj6hmgrlal8v3tey8ONjw eW1pQ0lqLZfUslUICKbWqMD8y4n0Z0twAhPlc5KgB9kNRjUfeQf5BeUCBflXXOCFIwlp NzgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5n8TYGp5vc2hXKBCFOAMT1bwN0hqgSluIwICLUpdYjU=; b=jvgM9se5fnFGxO74Y1zrsx2DhGY90kcE+y8ImD0amxSCKE1HbyLAZlGEvAKzFyZ+3j IGjtAINYC2v59ZaxGER2qDkKhq2z+QtqM82Ouqko+TT55eUX3sQyGFMpi0HLhCSJcxHN t6MzUWSaM5UMmw68BBmDBYja3jCPnmrYERl4IaZZQO7YgqpvwKwYZOyCuftXB2MSqj3J 48hnTpsPBZ1Xtu0C+47phS6fhhPXYio0d9NrZ8DM5CHA32wy2LdPQFzJ7g3BOXgFczjH h3zFYDCMWu2S2oxl8BtMZX6G+8s0Dl5isKpiMGYRkuNCmIIRtzgzwyhWU0i6D5WXz3Sh 0fkg== X-Gm-Message-State: AOAM531lRIfNVt54TcVJhDVBnN0QWixZmpMWWRtVWHpHOljLloSkTJ7U 4OXf1RhhbFYxEadVCQ5yCKo6hLgk6D5f97d/f7g= X-Google-Smtp-Source: ABdhPJyKTSURCK/qkwjxm9Qv8gCGrqcVOxIOdOjya4ldV5COZBVp7TYLNj3dqNtFltv3gaGeHvsYvcjFDXO9HncpIHY= X-Received: by 2002:a4a:3405:: with SMTP id b5mr10065284ooa.9.1594827619020; Wed, 15 Jul 2020 08:40:19 -0700 (PDT) MIME-Version: 1.0 References: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> In-Reply-To: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> From: Luiz Augusto von Dentz Date: Wed, 15 Jul 2020 08:40:05 -0700 Message-ID: Subject: Re: [PATCH] Bluetooth: Fix updating connecton state in `hci_encrypt_cfm` To: Patrick Steinhardt Cc: "linux-bluetooth@vger.kernel.org" , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 1.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 35B6853798 X-Rspamd-UID: 528a7b Hi Patrick, On Wed, Jul 15, 2020 at 7:50 AM Patrick Steinhardt wrote: > > Starting with the upgrade to v5.8-rc3, I've noticed I wasn't able to > connect to my Bluetooth headset properly anymore. While connecting to > the device would eventually succeed, bluetoothd seemed to be confused > about the current connection state where the state was flapping hence > and forth. Bisecting this issue led to commit 3ca44c16b0dc ("Bluetooth: > Consolidate encryption handling in hci_encrypt_cfm"), which refactored > `hci_encrypt_cfm` to also handle updating the connection state. > > The commit in question changed the code to call `hci_connect_cfm` inside > `hci_encrypt_cfm` and updating the connection state. But the conversion > didn't keep old behaviour of when the connection state is updated, which > now causes us to not properly update it anymore. > > Fix the issue by adding another parameter to the function that allows > callers to specify whether the connection state should be updated, which > allows us to restore previous behaviour. > > Fixes: 3ca44c16b0dc ("Bluetooth: Consolidate encryption handling in hci_encrypt_cfm") > Signed-off-by: Patrick Steinhardt > --- > include/net/bluetooth/hci_core.h | 4 ++-- > net/bluetooth/hci_event.c | 6 +++--- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h > index cdd4f1db8670..9abcc4a89abc 100644 > --- a/include/net/bluetooth/hci_core.h > +++ b/include/net/bluetooth/hci_core.h > @@ -1381,13 +1381,13 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) > conn->security_cfm_cb(conn, status); > } > > -static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status) > +static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 update_state) > { > struct hci_cb *cb; > __u8 encrypt; > > if (conn->state == BT_CONFIG) { > - if (status) > + if (update_state) The intent was actually to have if (!status) as it means the encryption has succeeded the state can be considered connected, so I wonder if we really need to introduce another parameter. Anyway as it is broken we need to come up with a fix rather quickly. > conn->state = BT_CONNECTED; > > hci_connect_cfm(conn, status); > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index cfeaee347db3..483d35eda2f1 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -2931,7 +2931,7 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) > &cp); > } else { > clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); > - hci_encrypt_cfm(conn, ev->status); > + hci_encrypt_cfm(conn, ev->status, 0); > } > } > > @@ -3016,7 +3016,7 @@ static void read_enc_key_size_complete(struct hci_dev *hdev, u8 status, > conn->enc_key_size = rp->key_size; > } > > - hci_encrypt_cfm(conn, 0); > + hci_encrypt_cfm(conn, 0, 1); > > unlock: > hci_dev_unlock(hdev); > @@ -3134,7 +3134,7 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) > } > > notify: > - hci_encrypt_cfm(conn, ev->status); > + hci_encrypt_cfm(conn, ev->status, !ev->status); > > unlock: > hci_dev_unlock(hdev); > -- > 2.27.0 > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4Kw2MhQuD19TQgAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 18:25:56 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SMecMBQuD1+4xQAAgupzMw (envelope-from ); Wed, 15 Jul 2020 18:25:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 571FB53263; Wed, 15 Jul 2020 18:25:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725917AbgGOQZu (ORCPT + 1 other); Wed, 15 Jul 2020 12:25:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725798AbgGOQZt (ORCPT ); Wed, 15 Jul 2020 12:25:49 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 220B1C061755 for ; Wed, 15 Jul 2020 09:25:49 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id t198so2653362oie.7 for ; Wed, 15 Jul 2020 09:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yogsD9dOjvPh9IGQrxuVaesSOGnFu9UMXcOKMPJF33s=; b=V2T9EN1sa+lQpvuDcofGOFsxapQoYrJMZMGN/XcRDMc3Of2k7qkNoKLjaWLuhrxtvf V/nUfGEOgZjBnIFu5hIgFL/bgkQ16p3mK3m6DrlhKbStSBgfne5Mq/buMdmOb0xvRbYo rDnP9nnO81qXp+P//tCFYIaqtxVVi/h2vCjfSyR848BLm+R2aymo/yHMw6xFqufePjZL gOnD40tUuOBEdeR5b51mrTRh65WZZxJJmHIPcZYx9JxlIymzvtzVfzSCX2MONnT2HLuJ lmjJO+bLwxxxF0aYgCaJQli4SSRJoXZNkdB+zE2LgayV6CKEqABNQU8zE1ewPWOOgaKr wAiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yogsD9dOjvPh9IGQrxuVaesSOGnFu9UMXcOKMPJF33s=; b=ll6tF+y0nK37Vq8b9tperR5PrlBeOKc+IVvydNPk09B0KAfBSPTNcLrNKmPBsrvqi9 7MnCn4mxTE6iJD1wVZXFDdvOThCAplkakz5caETZLgV1WXLp0SAIbcMU+N1lX+o9rzU2 Q27ZAS5z28WohjF4VSSm6gNLnppji0mOylnQJs2asg+8Pj/0uD3pEI76qIOQ0MnoKBrQ 5F5Uj3+gCQfcPGDcd7NeaEyLDQCp59m/25xGXeMa757R+CrYfFAdod/pNyytze3PDGrE pYMJKQWfDXq0HdaZBnAv2gMcuYDkht+l4mjjvVYZce/9j56YIZrwdslC1Kvp7w1GwtjZ Ja0A== X-Gm-Message-State: AOAM532wo/B6HaHuyu2NEShQvdbEwYVzaFEs7Mxv0MMdwlgNIsPy4kH+ HNA+wsN8JVXzqteKv5Q02JuAqfh8IuV+HRMnWU4= X-Google-Smtp-Source: ABdhPJx6jFqi5nMHPd7WthOMfEUiob5q5ZYQ6YXBuXAUIj4BisqdY6QkQ14RYo4Y7nwx4/wUXBfAMGjOmcjLCceT5aM= X-Received: by 2002:aca:4a04:: with SMTP id x4mr421917oia.152.1594830348298; Wed, 15 Jul 2020 09:25:48 -0700 (PDT) MIME-Version: 1.0 References: <20200713201441.235959-1-sonnysasaka@chromium.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Wed, 15 Jul 2020 09:25:36 -0700 Message-ID: Subject: Re: [PATCH BlueZ 0/3] Per-device option to enable/disable internal profiles To: Sonny Sasaka Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 571FB53263 X-Rspamd-UID: 8dbc87 Hi Sonny, On Tue, Jul 14, 2020 at 1:55 PM Sonny Sasaka wrote: > > Hi Luiz, > > On Mon, Jul 13, 2020 at 10:28 PM Luiz Augusto von Dentz > wrote: > > > > Hi Sonny, > > > > On Mon, Jul 13, 2020 at 4:48 PM Sonny Sasaka wrote: > > > > > > Hi Luiz, > > > > > > On Mon, Jul 13, 2020 at 3:59 PM Luiz Augusto von Dentz > > > wrote: > > > > > > > > Hi Sonny, > > > > > > > > On Mon, Jul 13, 2020 at 3:04 PM Sonny Sasaka wrote: > > > > > > > > > > Hi Luiz, > > > > > > > > > > I considered having such an approach that gives exception to some > > > > > profile to not claim exclusive access. However, I think that this > > > > > approach has a drawback that it can only be guaranteed to work > > > > > correctly for profiles that contain only read-only attributes. Any > > > > > profile that contains writable attributes, naturally, cannot be > > > > > guaranteed to always work correctly (as is the case with the Battery > > > > > profile). Therefore, the usefulness of that feature will be very > > > > > limited. > > > > > > > > > > I also considered the benefits of the AllowInternalProfiles approach: > > > > > * Applications can also have control over any profile, not just > > > > > Battery profile. For example, if in the future BlueZ has more internal > > > > > profiles, like (Blood Pressure Profile or any other profile that may > > > > > contain writable attributes), we can guarantee that applications can > > > > > still opt to have access to that profile, without relying on a profile > > > > > being "safe" to be shared by both BlueZ's internal and external > > > > > handlers. > > > > > * This has an added security benefit: applications which operate on a > > > > > specific GATT profile will not unintentionally activate internal > > > > > profiles such as HOG (which is able to hijack input control of the > > > > > host). This is the correct and expected behavior of Android apps that > > > > > connect over GATT and get access to a GATT profile. > > > > > > > > Not sure I follow these arguments, it seems AllowInternalProfiles may > > > > actually enable hijacking the profiles so I wonder if you got this > > > > backwards as we can't let things like HoG be controlled by > > > > applications directly it would be too easy to implement something like > > > > a keylogger, or perhaps you are suggesting that there is another layer > > > > for implementing the profiles? Note that it is intended that plugins > > > > shall be used for profiles that need to be integrated system wide, > > > > D-Bus interface shall be restricted to only application specific > > > > profiles. > > > > > > I think you misunderstood my point about HOG hijacking. Consider the > > > following case: > > > 1. A legit application (not System UI) on a host computer scans and > > > connects to a nearby peer. It makes a guess about the peer device > > > based on its advertising data. It intends to operate on a specific > > > GATT profile (not necessarily Battery). > > > 2. The peer device turns out to be malicious. It runs HOG GATT server > > > and triggers the host's HOG profile to be active. > > > 3. The malicious peer device's HOG GATT server can now maliciously > > > make mouse movements or enter keystrokes to the host. > > > > I'm not sure how you would like to prevent that, we could in theory > > attempt to authorize every single profile before connecting, just like > > it is done for legacy, but Im sure system would not be asking the user > > what profiles to connect so they just end up trusting the device, > > alternatively we could make ConnectProfile to work also for LE so you > > can provide a UUID and nothing else would be exposed, but note that > > this guess on the AD may actually be wrong and the device may end up > > malfunctioning. > > > > > In this case the user is considered being attacked, because he/she > > > doesn't consciously interact with the System UI to connect to a nearby > > > mouse/keyboard. > > > My example doesn't have to be HOG. It just happens to be a profile > > > which is attackable at the moment. My point is that, for applications > > > it's always safest to turn off all internal profiles to avoid such > > > incident. There is no use case where applications want to trigger > > > internal profiles. > > > > > > Note 1: By "applications", I mean things like Android apps or > > > JavaScript apps which are not considered System's Bluetooth UI. > > > > Well that doesn't make my point moot, let's say we do enable > > connecting by UUID and the application try to connect HoG, it could be > > a malicious application trying to eavesdrop what the user is typing, > > so this problem of malicious goes both ways Im afraid, besides the > > performance penalty that one would have if we need to transport HID > > over D-Bus. > If an application handles HOG, there will be nothing to eavesdrop > because that application shouldn't have an access to UHID in the first > place. If that malicious application had UHID access, that is already > a problem to begin with regardless of whether there is Bluetooth or > not. The security of this is handled above the Bluetooth layer. The > operating system that uses this feature is responsible for higher > layer security. For operating systems that don't need it I am okay > with adding an option to disable this feature altogether. But I can > see that there are systems that need it and I am not convinced that a > general purpose Bluetooth stack should not support it. All a malicious application has to do is to subscribe to notification of HoG characteristic, then any input generate by the device would be notified back to the application and that doesn't matter if uHID is accessible or not the application may not even forward the events to the system, now perhaps you are imagining that applications don't have direct access to the attribute objects but that would be system specific which is rather tricky to define. > > > > More applications could be involved and then this all becomes a mess > > if they have to fight over AllowInternalProfiles, so instead of using > > a theoretical example we better find real apps and devices where > > conflicts happens and work out case by case, adding ConnectProfile > > should actually fix most of them if there is a single profile involved > > by we could also thing about an alternative to connect multiples. > > There is also the possibility of exposing the btd_service as objects, > > I've actually had this implemented for the car industry, that way > > AutoConnect property could actually be controlled on a per service > > basis instead of having just one switch for everything. > To be clear, applications do not have direct access to > AllowInternalProfiles. The higher layer operating system controls it. > This is just the same case as the org.bluez.Adapter1.Powered property > and many other examples where applications are not expected to have > direct control of. Therefore there should be no problem of many things > fighting over it if used correctly, just like many other properties. > Again, I am okay with adding an option to disable this for operating > systems that do not want it. I see, though you didn't comment on the idea of controlling this on a per-service basis, not just have everything disabled with AllowInternalProfiles, note though that there are some profiles we can't really disable like GAP and GATT as that involves things that bt_gatt_client itself does need to access in order to work properly. You can find the service_api commits in here: https://github.com/Vudentz/BlueZ/commits/service_api It does allow to control both the auto_connect logic as well a block: https://github.com/Vudentz/BlueZ/commit/9bd6dce59fe9978b3bf415fe74f89d72254b8075 https://github.com/Vudentz/BlueZ/commit/42a7e479d5beb641a3d94f724a2df60db0f8221c > Note: I have been using the term "operating system" to refer to high > level components rather than the kernel. > > > > > > > > > > > > Note that we do allow external profiles to be registered with use of: > > > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/profile-api.txt > > > > > > > > And for GATT: > > > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt#n366 > > > > > > > > We could perhaps make the assumption that once an application > > > > registers itself as supporting a given profile we check if against a > > > > blacklist of profiles that may have security implications, which > > > > perhaps could be defined via main.conf or some other file, if that is > > > > not the case the internal profile can be disabled and the D-Bus object > > > > would be accessible over D-Bus. Also note that we do offer clients the > > > > ability to have exclusive access with AcquireWrite and AcquireNotify. > > > > > > > > > Therefore I think that this approach, although more complex, has > > > > > longer lasting benefits. Let me know if you have any objection to > > > > > having such a feature. > > > > > > > > > > > > > > > On Mon, Jul 13, 2020 at 1:35 PM Luiz Augusto von Dentz > > > > > wrote: > > > > > > > > > > > > Hi Sonny, > > > > > > > > > > > > On Mon, Jul 13, 2020 at 1:18 PM Sonny Sasaka wrote: > > > > > > > > > > > > > > This patch series adds a mechanism for clients to choose whether to > > > > > > > enable BlueZ internal profiles (e.g. A2DP, Battery) for specific > > > > > > > devices. > > > > > > > > > > > > > > The motivation behind this feature is that some applications (e.g. Web > > > > > > > Bluetooth or Android apps) need to have control over all remove GATT > > > > > > > services, like Battery service. With "battery" plugin being enabled on > > > > > > > BlueZ, it becomes not possible for those apps to work properly because > > > > > > > BlueZ "hides" the Battery-related attributes from its GATT Client API. > > > > > > > Disabling the "battery" plugin won't solve the problem either, since we > > > > > > > do also need to enable the plugin so that we can use org.bluez.Battery1 > > > > > > > API. > > > > > > > > > > > > > > The solution that we propose is that clients can choose whether to > > > > > > > enable internal profiles for each device. Clients know when to enable > > > > > > > internal profiles (such as when a user chooses to pair/connect via a UI) > > > > > > > and when to disable internal profiles (such as when the connection is > > > > > > > initiated by a generic application). > > > > > > > > > > > > I wonder if it is not better to just have a flag indicating if the > > > > > > profile shall claim exclusive access (such as GAP and GATT services), > > > > > > so profiles that don't set that will have the services exposed so for > > > > > > battery we can probably just have it exposed by default since it > > > > > > doesn't appear to would be any conflicts on having it exposed. > > > > > > > > > > > > > Sonny Sasaka (3): > > > > > > > doc: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > > > device: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > > > client: Add set-allow-internal-profiles command > > > > > > > > > > > > > > client/main.c | 38 ++++++++++++++++++ > > > > > > > doc/device-api.txt | 13 +++++++ > > > > > > > src/device.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ > > > > > > > src/hcid.h | 2 + > > > > > > > src/main.c | 10 +++++ > > > > > > > src/main.conf | 4 ++ > > > > > > > 6 files changed, 163 insertions(+) > > > > > > > > > > > > > > -- > > > > > > > 2.26.2 > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > > > > > -- > > > > Luiz Augusto von Dentz > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sGCkInxwD18iogAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 23:09:16 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mJz6IHxwD1+DIQEADc0bRg (envelope-from ); Wed, 15 Jul 2020 23:09:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0A793A31F3; Wed, 15 Jul 2020 23:09:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726715AbgGOVJJ (ORCPT + 1 other); Wed, 15 Jul 2020 17:09:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbgGOVJH (ORCPT ); Wed, 15 Jul 2020 17:09:07 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49F01C061755 for ; Wed, 15 Jul 2020 14:09:07 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id 18so2571343otv.6 for ; Wed, 15 Jul 2020 14:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h7uwQtIogCwG16X6ZhukNUnEx6KkQAWIbeaodL+CMGs=; b=t36t6XEkwEoYZU9UFyyAP8kTAkihrt6Czg5tuKLSIXJIT6xmQQZu5D1YEe1Rw2cRjT tRFYXLwOTLiKMpYYKFnvgVR2sEnxh6DVgP2UdRxDSBfWqjzPFe5lM7h9oBXisrCnlCpk WbXhb7t+jyIk+3ZhBrBbo5G0SQtcj6/mGP5eAhJTwuTJ6exQO8G524UXvPcDIEZO5DKw /ngJtOpO/J6Fz6JKkUOKQuperRVTYTD0VZJu1m0/4trbchXcFBdPdCKNTXy+LvAadBGD 5HyEXcsE8M2HSbOF7CwVFgUi0O18s5084zCfh4hYKk7u2fQmrjXu0kzjt36hsI7pXDdT vsVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h7uwQtIogCwG16X6ZhukNUnEx6KkQAWIbeaodL+CMGs=; b=Efm77we8ny6fw3t2V9pL3G1DGzbj2N4wLlcCjtPlu4ntlq6NEx/PRN2ORPHPLg82Su M4v0aVGHi2fko08c2D7raer933uu+w7CSm8peTrs0lU6Pdccj1B92WDOxWlvwzdQaidZ XC3ZJwL0/Sc/SI+LfW+090X0/ysv30zCA64rPAlISWjBS+5RrYc0Px2/U7EkBnNu2c++ dqyZYRTijrTD9TzgzEBkKAWRq8aCvh851IUBJ5r4SG5IxGmau7mZuia9hoHyFUHFoJ6A fo7pBC+y2xOw3pTDhQU13voFYLqtGxbxxloOWW2Gw++KaRlhAg3DVrqctXACBO+d9Kbl /9fQ== X-Gm-Message-State: AOAM532mbEzytxduUg68z9F3MtyN4CLVbk2Qw+4Xg5dxx8i6aNBvi9Af iwYKbocbJtBm+f4UdqsIK/L3ox8qQDP2dJw8VAI= X-Google-Smtp-Source: ABdhPJx/ZaM5EEM69Sfj+5ES77HpoaLXRAESITS3ibvkHj+XrjIU8+05bRKaEslEqBcoMbg0E/z11Ag2VsXW+6j+GPc= X-Received: by 2002:a9d:6c09:: with SMTP id f9mr1445367otq.362.1594847345754; Wed, 15 Jul 2020 14:09:05 -0700 (PDT) MIME-Version: 1.0 References: <20200713201441.235959-1-sonnysasaka@chromium.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Wed, 15 Jul 2020 14:08:51 -0700 Message-ID: Subject: Re: [PATCH BlueZ 0/3] Per-device option to enable/disable internal profiles To: Sonny Sasaka Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0A793A31F3 X-Rspamd-UID: eb425e Hi Sonny, On Wed, Jul 15, 2020 at 1:13 PM Sonny Sasaka wrote: > > On Wed, Jul 15, 2020 at 9:25 AM Luiz Augusto von Dentz > wrote: > > > > Hi Sonny, > > > > On Tue, Jul 14, 2020 at 1:55 PM Sonny Sasaka wrote: > > > > > > Hi Luiz, > > > > > > On Mon, Jul 13, 2020 at 10:28 PM Luiz Augusto von Dentz > > > wrote: > > > > > > > > Hi Sonny, > > > > > > > > On Mon, Jul 13, 2020 at 4:48 PM Sonny Sasaka wrote: > > > > > > > > > > Hi Luiz, > > > > > > > > > > On Mon, Jul 13, 2020 at 3:59 PM Luiz Augusto von Dentz > > > > > wrote: > > > > > > > > > > > > Hi Sonny, > > > > > > > > > > > > On Mon, Jul 13, 2020 at 3:04 PM Sonny Sasaka wrote: > > > > > > > > > > > > > > Hi Luiz, > > > > > > > > > > > > > > I considered having such an approach that gives exception to some > > > > > > > profile to not claim exclusive access. However, I think that this > > > > > > > approach has a drawback that it can only be guaranteed to work > > > > > > > correctly for profiles that contain only read-only attributes. Any > > > > > > > profile that contains writable attributes, naturally, cannot be > > > > > > > guaranteed to always work correctly (as is the case with the Battery > > > > > > > profile). Therefore, the usefulness of that feature will be very > > > > > > > limited. > > > > > > > > > > > > > > I also considered the benefits of the AllowInternalProfiles approach: > > > > > > > * Applications can also have control over any profile, not just > > > > > > > Battery profile. For example, if in the future BlueZ has more internal > > > > > > > profiles, like (Blood Pressure Profile or any other profile that may > > > > > > > contain writable attributes), we can guarantee that applications can > > > > > > > still opt to have access to that profile, without relying on a profile > > > > > > > being "safe" to be shared by both BlueZ's internal and external > > > > > > > handlers. > > > > > > > * This has an added security benefit: applications which operate on a > > > > > > > specific GATT profile will not unintentionally activate internal > > > > > > > profiles such as HOG (which is able to hijack input control of the > > > > > > > host). This is the correct and expected behavior of Android apps that > > > > > > > connect over GATT and get access to a GATT profile. > > > > > > > > > > > > Not sure I follow these arguments, it seems AllowInternalProfiles may > > > > > > actually enable hijacking the profiles so I wonder if you got this > > > > > > backwards as we can't let things like HoG be controlled by > > > > > > applications directly it would be too easy to implement something like > > > > > > a keylogger, or perhaps you are suggesting that there is another layer > > > > > > for implementing the profiles? Note that it is intended that plugins > > > > > > shall be used for profiles that need to be integrated system wide, > > > > > > D-Bus interface shall be restricted to only application specific > > > > > > profiles. > > > > > > > > > > I think you misunderstood my point about HOG hijacking. Consider the > > > > > following case: > > > > > 1. A legit application (not System UI) on a host computer scans and > > > > > connects to a nearby peer. It makes a guess about the peer device > > > > > based on its advertising data. It intends to operate on a specific > > > > > GATT profile (not necessarily Battery). > > > > > 2. The peer device turns out to be malicious. It runs HOG GATT server > > > > > and triggers the host's HOG profile to be active. > > > > > 3. The malicious peer device's HOG GATT server can now maliciously > > > > > make mouse movements or enter keystrokes to the host. > > > > > > > > I'm not sure how you would like to prevent that, we could in theory > > > > attempt to authorize every single profile before connecting, just like > > > > it is done for legacy, but Im sure system would not be asking the user > > > > what profiles to connect so they just end up trusting the device, > > > > alternatively we could make ConnectProfile to work also for LE so you > > > > can provide a UUID and nothing else would be exposed, but note that > > > > this guess on the AD may actually be wrong and the device may end up > > > > malfunctioning. > > > > > > > > > In this case the user is considered being attacked, because he/she > > > > > doesn't consciously interact with the System UI to connect to a nearby > > > > > mouse/keyboard. > > > > > My example doesn't have to be HOG. It just happens to be a profile > > > > > which is attackable at the moment. My point is that, for applications > > > > > it's always safest to turn off all internal profiles to avoid such > > > > > incident. There is no use case where applications want to trigger > > > > > internal profiles. > > > > > > > > > > Note 1: By "applications", I mean things like Android apps or > > > > > JavaScript apps which are not considered System's Bluetooth UI. > > > > > > > > Well that doesn't make my point moot, let's say we do enable > > > > connecting by UUID and the application try to connect HoG, it could be > > > > a malicious application trying to eavesdrop what the user is typing, > > > > so this problem of malicious goes both ways Im afraid, besides the > > > > performance penalty that one would have if we need to transport HID > > > > over D-Bus. > > > If an application handles HOG, there will be nothing to eavesdrop > > > because that application shouldn't have an access to UHID in the first > > > place. If that malicious application had UHID access, that is already > > > a problem to begin with regardless of whether there is Bluetooth or > > > not. The security of this is handled above the Bluetooth layer. The > > > operating system that uses this feature is responsible for higher > > > layer security. For operating systems that don't need it I am okay > > > with adding an option to disable this feature altogether. But I can > > > see that there are systems that need it and I am not convinced that a > > > general purpose Bluetooth stack should not support it. > > > > All a malicious application has to do is to subscribe to notification > > of HoG characteristic, then any input generate by the device would be > > notified back to the application and that doesn't matter if uHID is > > accessible or not the application may not even forward the events to > > the system, now perhaps you are imagining that applications don't have > > direct access to the attribute objects but that would be system > > specific which is rather tricky to define. > When the HOG-related GATT object is available on D-Bus, that means the > internal HOG profile is not enabled in the first place, so there is > nothing to sniff anyway. Furthermore, the higher layer operating > system is also responsible to prevent this if it chooses to disable > BlueZ's internal HOG profile handler. If an operating system thinks > that it is safer to always enable internal HOG they can do just that, > as I mentioned I'm willing to add an option to always enable all > internal profiles. > > > > > > > > > > > More applications could be involved and then this all becomes a mess > > > > if they have to fight over AllowInternalProfiles, so instead of using > > > > a theoretical example we better find real apps and devices where > > > > conflicts happens and work out case by case, adding ConnectProfile > > > > should actually fix most of them if there is a single profile involved > > > > by we could also thing about an alternative to connect multiples. > > > > There is also the possibility of exposing the btd_service as objects, > > > > I've actually had this implemented for the car industry, that way > > > > AutoConnect property could actually be controlled on a per service > > > > basis instead of having just one switch for everything. > > > To be clear, applications do not have direct access to > > > AllowInternalProfiles. The higher layer operating system controls it. > > > This is just the same case as the org.bluez.Adapter1.Powered property > > > and many other examples where applications are not expected to have > > > direct control of. Therefore there should be no problem of many things > > > fighting over it if used correctly, just like many other properties. > > > Again, I am okay with adding an option to disable this for operating > > > systems that do not want it. > > > > I see, though you didn't comment on the idea of controlling this on a > > per-service basis, not just have everything disabled with > > AllowInternalProfiles, note though that there are some profiles we > > can't really disable like GAP and GATT as that involves things that > > bt_gatt_client itself does need to access in order to work properly. > Right, I missed that GAP should be an exception that it cannot be > disabled, I should've added that exception in my code. > > However, it seems that you still don't want a single switch to disable > all internal profiles (even with GAP exception). I'm willing to modify > this feature to be a blocklist of profiles per device (say > BlockedProfiles property on Device1 interface), and this feature can > be disabled altogether (all profiles always enabled) for operating > systems that do not want it. > > That idea is also similar to your service_api branch, so I will also > try to port your service_api branch on the master branch. I will test > this and I am okay with using this if it serves our purposes. > I do have a question, though: With this API design, the service > objects are not exposed until a remote profile is detected, and > sometimes a profile is not detected until connection takes place (if > the profile UUID is not in the advertisement). So, how does the BlueZ > client block certain profiles/services before connection takes place? > We can't wait until connection takes place because we already know > that we don't want certain profiles, and if we block a profile after > connection takes place would that work properly? I guess we still need > a way to block certain profiles in the Device1 API, and the blocked > profiles also need to be stored in store_device_info. That is a good point, but that would be a problem only for the very first time you connect since after that the blocked state should be recovered, we could however work out an API where one can enter the profiles to connect and to block but usually depends on the services being resolved so I wonder it wouldn't just be enough to block the service discovery and in the event the internal profile has already been connected it would just disconnect, the objects would only be exported after you had it blocked so that means there should be any race, but perhaps you want a dedicate Connect method where one can enumerate the profiles to auto-connect and to block, note though that it may not be possible to indicate a valid list in case the services have not been resolved. > > > > You can find the service_api commits in here: > > > > https://github.com/Vudentz/BlueZ/commits/service_api > > > > It does allow to control both the auto_connect logic as well a block: > > > > https://github.com/Vudentz/BlueZ/commit/9bd6dce59fe9978b3bf415fe74f89d72254b8075 > > https://github.com/Vudentz/BlueZ/commit/42a7e479d5beb641a3d94f724a2df60db0f8221c > > > > > Note: I have been using the term "operating system" to refer to high > > > level components rather than the kernel. > > > > > > > > > > > > > > > > > > > > > > Note that we do allow external profiles to be registered with use of: > > > > > > > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/profile-api.txt > > > > > > > > > > > > And for GATT: > > > > > > > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt#n366 > > > > > > > > > > > > We could perhaps make the assumption that once an application > > > > > > registers itself as supporting a given profile we check if against a > > > > > > blacklist of profiles that may have security implications, which > > > > > > perhaps could be defined via main.conf or some other file, if that is > > > > > > not the case the internal profile can be disabled and the D-Bus object > > > > > > would be accessible over D-Bus. Also note that we do offer clients the > > > > > > ability to have exclusive access with AcquireWrite and AcquireNotify. > > > > > > > > > > > > > Therefore I think that this approach, although more complex, has > > > > > > > longer lasting benefits. Let me know if you have any objection to > > > > > > > having such a feature. > > > > > > > > > > > > > > > > > > > > > On Mon, Jul 13, 2020 at 1:35 PM Luiz Augusto von Dentz > > > > > > > wrote: > > > > > > > > > > > > > > > > Hi Sonny, > > > > > > > > > > > > > > > > On Mon, Jul 13, 2020 at 1:18 PM Sonny Sasaka wrote: > > > > > > > > > > > > > > > > > > This patch series adds a mechanism for clients to choose whether to > > > > > > > > > enable BlueZ internal profiles (e.g. A2DP, Battery) for specific > > > > > > > > > devices. > > > > > > > > > > > > > > > > > > The motivation behind this feature is that some applications (e.g. Web > > > > > > > > > Bluetooth or Android apps) need to have control over all remove GATT > > > > > > > > > services, like Battery service. With "battery" plugin being enabled on > > > > > > > > > BlueZ, it becomes not possible for those apps to work properly because > > > > > > > > > BlueZ "hides" the Battery-related attributes from its GATT Client API. > > > > > > > > > Disabling the "battery" plugin won't solve the problem either, since we > > > > > > > > > do also need to enable the plugin so that we can use org.bluez.Battery1 > > > > > > > > > API. > > > > > > > > > > > > > > > > > > The solution that we propose is that clients can choose whether to > > > > > > > > > enable internal profiles for each device. Clients know when to enable > > > > > > > > > internal profiles (such as when a user chooses to pair/connect via a UI) > > > > > > > > > and when to disable internal profiles (such as when the connection is > > > > > > > > > initiated by a generic application). > > > > > > > > > > > > > > > > I wonder if it is not better to just have a flag indicating if the > > > > > > > > profile shall claim exclusive access (such as GAP and GATT services), > > > > > > > > so profiles that don't set that will have the services exposed so for > > > > > > > > battery we can probably just have it exposed by default since it > > > > > > > > doesn't appear to would be any conflicts on having it exposed. > > > > > > > > > > > > > > > > > Sonny Sasaka (3): > > > > > > > > > doc: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > > > > > device: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > > > > > client: Add set-allow-internal-profiles command > > > > > > > > > > > > > > > > > > client/main.c | 38 ++++++++++++++++++ > > > > > > > > > doc/device-api.txt | 13 +++++++ > > > > > > > > > src/device.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ > > > > > > > > > src/hcid.h | 2 + > > > > > > > > > src/main.c | 10 +++++ > > > > > > > > > src/main.conf | 4 ++ > > > > > > > > > 6 files changed, 163 insertions(+) > > > > > > > > > > > > > > > > > > -- > > > > > > > > > 2.26.2 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > > > > > -- > > > > Luiz Augusto von Dentz > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CCnxFOMuD198zgAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 18:29:23 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id WESWE+MuD194PgAAlScrYA (envelope-from ); Wed, 15 Jul 2020 18:29:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 49A7852CDD; Wed, 15 Jul 2020 18:29:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726907AbgGOQ3F (ORCPT + 1 other); Wed, 15 Jul 2020 12:29:05 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:37930 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbgGOQ3E (ORCPT ); Wed, 15 Jul 2020 12:29:04 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 1C2E980307C2; Wed, 15 Jul 2020 16:28:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R4yGKnKOMh8D; Wed, 15 Jul 2020 19:28:54 +0300 (MSK) Date: Wed, 15 Jul 2020 19:28:52 +0300 From: Serge Semin To: Claire Chang , Greg Kroah-Hartman , Jiri Slaby , Matthias Brugger CC: Daniel Winkler , Nicolas Boichat , Alexey Malahov , Aaron Sierra , Andy Shevchenko , Lukas Wunner , Vignesh Raghavendra , , "moderated list:ARM/Mediatek SoC support" , BlueZ , chromeos-bluetooth-upstreaming , , , linux-arm Mailing List , lkml Subject: Re: [PATCH] serial: 8250_mtk: Fix high-speed baud rates clamping Message-ID: <20200715162852.5ykgubvoc7tvbfhc@mobilestation> References: <20200714124113.20918-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.35 / 15.00 / 200.00 X-Rspamd-Queue-Id: 49A7852CDD X-Rspamd-UID: 681ce7 On Wed, Jul 15, 2020 at 01:36:04PM +0800, Claire Chang wrote: > On Wed, Jul 15, 2020 at 4:45 AM Daniel Winkler wrote: > > > > Thank you Sergey for looking into this. Adding folks working on this > > platform to perform validation of the proposed patch. > > > > Best, > > Daniel > > > > On Tue, Jul 14, 2020 at 5:41 AM Serge Semin > > wrote: > > > > > > Commit 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 > > > port") fixed limits of a baud rate setting for a generic 8250 port. > > > In other words since that commit the baud rate has been permitted to be > > > within [uartclk / 16 / UART_DIV_MAX; uartclk / 16], which is absolutely > > > normal for a standard 8250 UART port. But there are custom 8250 ports, > > > which provide extended baud rate limits. In particular the Mediatek 8250 > > > port can work with baud rates up to "uartclk" speed. > > > > > > Normally that and any other peculiarity is supposed to be handled in a > > > custom set_termios() callback implemented in the vendor-specific > > > 8250-port glue-driver. Currently that is how it's done for the most of > > > the vendor-specific 8250 ports, but for some reason for Mediatek a > > > solution has been spread out to both the glue-driver and to the generic > > > 8250-port code. Due to that a bug has been introduced, which permitted the > > > extended baud rate limit for all even for standard 8250-ports. The bug > > > has been fixed by the commit 7b668c064ec3 ("serial: 8250: Fix max baud > > > limit in generic 8250 port") by narrowing the baud rates limit back down to > > > the normal bounds. Unfortunately by doing so we also broke the > > > Mediatek-specific extended bauds feature. > > > > > > A fix of the problem described above is twofold. First since we can't get > > > back the extended baud rate limits feature to the generic set_termios() > > > function and that method supports only a standard baud rates range, the > > > requested baud rate must be locally stored before calling it and then > > > restored back to the new termios structure after the generic set_termios() > > > finished its magic business. By doing so we still use the > > > serial8250_do_set_termios() method to set the LCR/MCR/FCR/etc. registers, > > > while the extended baud rate setting procedure will be performed later in > > > the custom Mediatek-specific set_termios() callback. Second since a true > > > baud rate is now fully calculated in the custom set_termios() method we > > > need to locally update the port timeout by calling the > > > uart_update_timeout() function. After the fixes described above are > > > implemented in the 8250_mtk.c driver, the Mediatek 8250-port should > > > get back to normally working with extended baud rates. > > > > > > Link: https://lore.kernel.org/linux-serial/20200701211337.3027448-1-danielwinkler@google.com > > > > > > Fixes: 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250 port") > > > Reported-by: Daniel Winkler > > > Signed-off-by: Serge Semin > Tested-by: Claire Chang > > > > > > --- > > > > > > Folks, sorry for a delay with the problem fix. A solution is turned out to > > > be a bit more complicated than I originally thought in my comment to the > > > Daniel revert-patch. > > > > > > Please also note, that I don't have a Mediatek hardware to test the > > > solution suggested in the patch. The code is written as on so called > > > the tip of the pen after digging into the 8250_mtk.c and 8250_port.c > > > drivers code. So please Daniel or someone with Mediatek 8250-port > > > available on a board test this patch first and report about the results in > > > reply to this emailing thread. After that, if your conclusion is positive > > > and there is no objection against the solution design the patch can be > > > merged in. > I tested it with mt8183 + QCA6174. > The UART Bluetooth works fine with this fix. > Thanks! Great! Thanks. Greg, Jiri, Matthias since a test's showed the patch correctness you may now merge it in if you are ok with its design. It shall fix the problem Daniel reported. -Sergey > > > > > > Cc: Alexey Malahov > > > Cc: Daniel Winkler > > > Cc: Aaron Sierra > > > Cc: Andy Shevchenko > > > Cc: Lukas Wunner > > > Cc: Vignesh Raghavendra > > > Cc: linux-serial@vger.kernel.org > > > Cc: linux-mediatek@lists.infradead.org > > > Cc: BlueZ > > > Cc: chromeos-bluetooth-upstreaming > > > Cc: abhishekpandit@chromium.org > > > Cc: stable@vger.kernel.org > > > --- > > > drivers/tty/serial/8250/8250_mtk.c | 18 ++++++++++++++++++ > > > 1 file changed, 18 insertions(+) > > > > > > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c > > > index f839380c2f4c..98b8a3e30733 100644 > > > --- a/drivers/tty/serial/8250/8250_mtk.c > > > +++ b/drivers/tty/serial/8250/8250_mtk.c > > > @@ -306,8 +306,21 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, > > > } > > > #endif > > > > > > + /* > > > + * Store the requested baud rate before calling the generic 8250 > > > + * set_termios method. Standard 8250 port expects bauds to be > > > + * no higher than (uartclk / 16) so the baud will be clamped if it > > > + * gets out of that bound. Mediatek 8250 port supports speed > > > + * higher than that, therefore we'll get original baud rate back > > > + * after calling the generic set_termios method and recalculate > > > + * the speed later in this method. > > > + */ > > > + baud = tty_termios_baud_rate(termios); > > > + > > > serial8250_do_set_termios(port, termios, old); > > > > > > + tty_termios_encode_baud_rate(termios, baud, baud); > > > + > > > /* > > > * Mediatek UARTs use an extra highspeed register (MTK_UART_HIGHS) > > > * > > > @@ -339,6 +352,11 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, > > > */ > > > spin_lock_irqsave(&port->lock, flags); > > > > > > + /* > > > + * Update the per-port timeout. > > > + */ > > > + uart_update_timeout(port, termios->c_cflag, baud); > > > + > > > /* set DLAB we have cval saved in up->lcr from the call to the core */ > > > serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB); > > > serial_dl_write(up, quot); > > > -- > > > 2.26.2 > > > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WHHCADI8D1/3OAEAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 19:26:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WCyqOjE8D19e+AAAgupzMw (envelope-from ); Wed, 15 Jul 2020 19:26:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=pks.im header.b=aCQb6+Sc; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=irZhqlqu X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 567D1A5997; Wed, 15 Jul 2020 19:26:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726370AbgGOR0D (ORCPT + 1 other); Wed, 15 Jul 2020 13:26:03 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:33947 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726086AbgGOR0D (ORCPT ); Wed, 15 Jul 2020 13:26:03 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C528A5C00AB; Wed, 15 Jul 2020 13:25:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 15 Jul 2020 13:25:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=ZQI5LoCLf3kW9vPX1tZGQ/TqG6j hunp2LIK4dsOkaTA=; b=aCQb6+Sc6xn3Tje56M8sjEbcaIJSItsgz9PtvJ74z5P aXEFzYyYWQLol+xjzbP7lEriNFP/cyJLqvFvVSCD0xfSxgr9NHFErl7rCpERa1Dx SgR7aeeo+35X70HuHitLrAUuK2yHGqvUYGGNC59W8VhakospTKe5/rKn/yC6DuwZ Jdmbb2Tgp8Rs3LtzCKF8oSGVl1eTVaTVwohAzCk5CetQLUGPCacWCRYm6scPI9p3 IHF7s5dncZ2WRGfAxci8L07xqMc3gtbgtOM7SzrgWAEmJylTijhLBj8XZujMRT8c 8U3jtFgBLmpxoOZFtnghHYIxOwUkBFGZ3MLYn+N6/KQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=ZQI5Lo CLf3kW9vPX1tZGQ/TqG6jhunp2LIK4dsOkaTA=; b=irZhqlquZOHw0Di+KuJL0A BWHJuFc6Rvgtp7F+MqmzTPJ4Qj5TgbFnxwLzdyrwHKMyp1ruFXUTzUSJfMRiwZXX Fd2paJZFTnCj5tVS8/xxSfVUmGI8Njyh1lPEKKKFPrrCd78PAjefJspvrk82vPbX 7dVVJ95Ld/WmVZmFWxxrpmOnEcwv9Gj64vFNceAfuaCevGymPbxAYHXNnV0SOlO0 NGvMw3fG31sdQWMAJ/jqd+CA7Wx7ddqLWGyBUePOQG3kRDOBJ4PEB9QvNGL+Xcoe DvGLpsTYRxSKELRe7ShshmyGJHaT/Sf9CuEIFKE0giTVAYyM/uKqQ3CxaLSVpHTA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrfedvgdduudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeehgefhtdefueffheekgfffudelffejtdfhvdejkedthfehvdelgfetgfdvtedthfen ucfkphepjeekrdehhedrgeekrdefudenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: from vm-mail.pks.im (x4e37301f.dyn.telefonica.de [78.55.48.31]) by mail.messagingengine.com (Postfix) with ESMTPA id 3C72B30600B1; Wed, 15 Jul 2020 13:25:58 -0400 (EDT) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 77a62e29 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 15 Jul 2020 17:25:56 +0000 (UTC) Date: Wed, 15 Jul 2020 19:26:45 +0200 From: Patrick Steinhardt To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Subject: Re: [PATCH] Bluetooth: Fix updating connecton state in `hci_encrypt_cfm` Message-ID: <20200715172645.GA825@ncase> References: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="1yeeQ81UyVL57Vl7" Content-Disposition: inline In-Reply-To: Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.60 / 15.00 / 200.00 X-Rspamd-Queue-Id: 567D1A5997 X-Rspamd-UID: ccfc71 --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 15, 2020 at 08:40:05AM -0700, Luiz Augusto von Dentz wrote: > Hi Patrick, >=20 > On Wed, Jul 15, 2020 at 7:50 AM Patrick Steinhardt wrote: > > > > Starting with the upgrade to v5.8-rc3, I've noticed I wasn't able to > > connect to my Bluetooth headset properly anymore. While connecting to > > the device would eventually succeed, bluetoothd seemed to be confused > > about the current connection state where the state was flapping hence > > and forth. Bisecting this issue led to commit 3ca44c16b0dc ("Bluetooth: > > Consolidate encryption handling in hci_encrypt_cfm"), which refactored > > `hci_encrypt_cfm` to also handle updating the connection state. > > > > The commit in question changed the code to call `hci_connect_cfm` inside > > `hci_encrypt_cfm` and updating the connection state. But the conversion > > didn't keep old behaviour of when the connection state is updated, which > > now causes us to not properly update it anymore. > > > > Fix the issue by adding another parameter to the function that allows > > callers to specify whether the connection state should be updated, which > > allows us to restore previous behaviour. > > > > Fixes: 3ca44c16b0dc ("Bluetooth: Consolidate encryption handling in hci= _encrypt_cfm") > > Signed-off-by: Patrick Steinhardt > > --- > > include/net/bluetooth/hci_core.h | 4 ++-- > > net/bluetooth/hci_event.c | 6 +++--- > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/h= ci_core.h > > index cdd4f1db8670..9abcc4a89abc 100644 > > --- a/include/net/bluetooth/hci_core.h > > +++ b/include/net/bluetooth/hci_core.h > > @@ -1381,13 +1381,13 @@ static inline void hci_auth_cfm(struct hci_conn= *conn, __u8 status) > > conn->security_cfm_cb(conn, status); > > } > > > > -static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status) > > +static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,= __u8 update_state) > > { > > struct hci_cb *cb; > > __u8 encrypt; > > > > if (conn->state =3D=3D BT_CONFIG) { > > - if (status) > > + if (update_state) >=20 > The intent was actually to have if (!status) as it means the > encryption has succeeded the state can be considered connected, so I > wonder if we really need to introduce another parameter. Anyway as it > is broken we need to come up with a fix rather quickly. Yeah, I kind of figured that to be the case but wanted to go with the "safe" fix of restoring old behaviour first. I'll test whether `if (!status)` fixes the problem I'm seeing and will send a v2 in case it does. Patrick --1yeeQ81UyVL57Vl7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAl8PPFQACgkQVbJhu7ck PpQrNQ//d7HU+xTNhXl70rUrLEgRtk3kZg6N6wJEb72WLk6GgHEvmBj/uyuzl4cR Yc/aB6HHShQArmsDOh044Duc3GlTiaDQbZfzzW+EDhU9fcpZEgan1rSPtYi6faKe 1YgY/CklRuOv2FAK0I64+Vt4CYGHsONzm/0I9b5qf89GA1qjMGTvQgRxMm0+vNu7 2AvTeRcBlCqEfVUz+mfada25AeiaPVbf8Rdr+tQ8K28LxM4KJoJrbpDZ/cDE9U4R OVr13r2q7wTOnPKuXYMVwefL+w8EXMWC0H4HZP3GklrTUMWTyV3asmr/pLzyrKKo tlLnB+eaW/E6YrRBPFXUoxBnG7if/Rt/Ez+C8PKbF3gyr+C2COknVkbswiMnHaZU 7blAUMsHzplaUJGsKKYPnclUvjVhgGii1NdGgG2F/D1spT8a+s6UfiZ0/tajvAE6 Vv8aBKgMd3GyOG2v04aYw4gcqfbeBW2Q27SHuhK2YRmAypfi/QhzkQlG6H0lk3BH yZ1ZWOILa/qNpsd6nz/Q7Pl7GJ1WC9t3R9Oqj2D2nwhCqHlOElUpBIJtFLEIACTA DkJ4CFlCPcarsFdEasAesw+Pq4T4O/o7VDYUJ4ViTuxXFjP+nLPan4oVBuC2ZieK 9qB31qLwjW/GNfMs6Qvsz5OtTa/hKLnCkNC8Pgb/DUqRDeIwVpE= =G0oM -----END PGP SIGNATURE----- --1yeeQ81UyVL57Vl7-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aHZUNo09D19ecQEAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 19:31:57 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cFfbNI09D19cgwAADc0bRg (envelope-from ); Wed, 15 Jul 2020 19:31:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6A03F53717; Wed, 15 Jul 2020 19:31:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725881AbgGORbv (ORCPT + 1 other); Wed, 15 Jul 2020 13:31:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbgGORbu (ORCPT ); Wed, 15 Jul 2020 13:31:50 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6888AC061755 for ; Wed, 15 Jul 2020 10:31:50 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id z23so619935ood.8 for ; Wed, 15 Jul 2020 10:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=qM/ZiioFc4rdDTmDUJQeOmStFmzxuCXtcg1ziNREXcA=; b=nSGJIJn98mwsiM8Qrk3LaSPeqUB1r7j0gLAqpBo8ig+0eW/F51AadHNDvqbNuYXaI4 TkQrUwkkE39EHHSsNJZY+ZTFpeQ3lWyWbLBjRCswEk0K+aYKjGQdXUfNJCrRDxpb9dox EMCZDbLIr+1S6aQO6Nocbs0hK90DQ8YDah8iHkIPZPD1SyVuWcMZzomeU9yAxkImzcpW 4C1NnbmkfjL4RszXhWyuZQ07Mw3SigKx3MwdBcXVhLDKYcm+GbGKwBJ3ggSKjaF1g+xx i4wZqLjyCHQ5EptWI7LoQBHmY7TH2ugUDozz4nEuJ8Id/GQ2KnU3sFKt+UKH2FxU2PSI i3pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=qM/ZiioFc4rdDTmDUJQeOmStFmzxuCXtcg1ziNREXcA=; b=T480qXw/8iNWIr+hFDGzTSkaT9Y3YZHC8bA3I3CFKu711g5gzubod49mvjPYf/UJGU GayHJpSN9oIrG74lJrVRmG9T0RwCAjuldjM84jZ4/bqbB4div4L+r+lTbgUVLW5Z12vB 8FFVtvq1Pc3ehuF1iol19lvCMSwitIUdsK6AsJUvynfF3J9mym1x9oPb4wYMLNo9tsOd fMx2W5zqQ1e9yRIFqyttDWtoxNVGusjJakuwPOGf1QoLeqkXt90fQfg6svZqqpjlOFto NxEAxXTPgeeGjLwej9riGFP0aDX+SBX4IbduDbadZaFNeAh1dWG9NJfiKgjZUqHzQynb SwFg== X-Gm-Message-State: AOAM532gRinoBk3C6cCvMGfHba4Jg97nQSYI2jFO9dsK9goVw+RPavxf nDuR08aCxcbIMHkuo+gsDgfrqeXT0zUlzgtqNcY= X-Google-Smtp-Source: ABdhPJyX0A8uvkXCEe0gdLPGnMu6Fp09/FXMHvt6FMTz2hX1/Hosn4CTRzP5cb44nqI5C2zNxilEPUYw9cqVl5W7E0E= X-Received: by 2002:a4a:3405:: with SMTP id b5mr251603ooa.9.1594834309229; Wed, 15 Jul 2020 10:31:49 -0700 (PDT) MIME-Version: 1.0 References: <20200627235318.Bluez.v2.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> In-Reply-To: From: Luiz Augusto von Dentz Date: Wed, 15 Jul 2020 10:31:37 -0700 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] device: add device_remove_bonding function To: Archie Pusaka Cc: linux-bluetooth , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6A03F53717 X-Rspamd-UID: a4c01e Hi Archie, On Wed, Jul 15, 2020 at 7:15 AM Archie Pusaka wrote: > > Hi Luiz, > > If we mark it as temporary, then the device will immediately get > deleted upon disconnection. > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/adapter.c#n68= 75 > This is the same situation as directly calling device_remove. > > May I know the reason why we want to put the device as temporary? > > If we currently don't have a way to keep a "previously connected but > no longer bonded" device, then removing the device perhaps is the next > best option. It still makes the user scan for the virtually > disconnected device though. We keep a cache of previously known devices, but we only display them once they are actually found otherwise it may grow too big which is inconvenient, I wonder where this concept of "previously connected but no longer bonded" comes from though, we had the temporary to map devices that would not be persisted on the storage which I guess this is what it is about, that said we could perhaps have a timeout before setting it as temporary but we might want to integrate with the logic of detecting devices disappearing. > Thanks, > Archie > > On Wed, 15 Jul 2020 at 01:10, Luiz Augusto von Dentz > wrote: > > > > Hi Archie, > > > > On Tue, Jul 7, 2020 at 9:30 PM Archie Pusaka wrote= : > > > > > > Hi Luiz, > > > > > > As far as the spec is concerned, we can also remove the device by > > > calling device_remove. However, I suppose it would be confusing for > > > end users if they can no longer find their HID device on the device > > > list just because the device previously sent a virtual cable > > > disconnection. > > > The HID 1.0 spec part 6.4.2 also gives an example of a possible > > > scenario when a virtually cabled device is removed: "Unplugged device= s > > > shall be marked as known and put into a =E2=80=9Cmost recently used l= ist=E2=80=9D of > > > known devices to facilitate future re-connecting". > > > > Then perhaps we shall have it marked as temporary as well, that said > > we do want to introduce disappearing logic so temporary devices are > > not left dangling for too long. > > > > > Thanks, > > > Archie > > > > > > > > > On Wed, 8 Jul 2020 at 02:03, Luiz Augusto von Dentz > > > wrote: > > > > > > > > Hi Archie, > > > > > > > > On Sat, Jun 27, 2020 at 8:54 AM Archie Pusaka = wrote: > > > > > > > > > > From: Archie Pusaka > > > > > > > > > > This patch splits the "bonding removal" function in device.c, > > > > > because we need to remove bonding information when receiving > > > > > "virtual cable unplug" in HID profile. > > > > > > > > > > Reviewed-by: Alain Michaud > > > > > --- > > > > > > > > > > Changes in v2: None > > > > > > > > > > src/device.c | 25 +++++++++++++++---------- > > > > > src/device.h | 1 + > > > > > 2 files changed, 16 insertions(+), 10 deletions(-) > > > > > > > > > > diff --git a/src/device.c b/src/device.c > > > > > index 7b0eb256e..9fb0e018c 100644 > > > > > --- a/src/device.c > > > > > +++ b/src/device.c > > > > > @@ -4162,6 +4162,17 @@ static void delete_folder_tree(const char = *dirname) > > > > > rmdir(dirname); > > > > > } > > > > > > > > > > +void device_remove_bonding(struct btd_device *device, uint8_t bd= addr_type) > > > > > +{ > > > > > + if (bdaddr_type =3D=3D BDADDR_BREDR) > > > > > + device->bredr_state.bonded =3D false; > > > > > + else > > > > > + device->le_state.bonded =3D false; > > > > > + > > > > > + btd_adapter_remove_bonding(device->adapter, &device->bdad= dr, > > > > > + bdaddr_ty= pe); > > > > > +} > > > > > + > > > > > static void device_remove_stored(struct btd_device *device) > > > > > { > > > > > char device_addr[18]; > > > > > @@ -4170,17 +4181,11 @@ static void device_remove_stored(struct b= td_device *device) > > > > > char *data; > > > > > gsize length =3D 0; > > > > > > > > > > - if (device->bredr_state.bonded) { > > > > > - device->bredr_state.bonded =3D false; > > > > > - btd_adapter_remove_bonding(device->adapter, &devi= ce->bdaddr, > > > > > - B= DADDR_BREDR); > > > > > - } > > > > > + if (device->bredr_state.bonded) > > > > > + device_remove_bonding(device, BDADDR_BREDR); > > > > > > > > > > - if (device->le_state.bonded) { > > > > > - device->le_state.bonded =3D false; > > > > > - btd_adapter_remove_bonding(device->adapter, &devi= ce->bdaddr, > > > > > - device->b= daddr_type); > > > > > - } > > > > > + if (device->le_state.bonded) > > > > > + device_remove_bonding(device, device->bdaddr_type= ); > > > > > > > > > > device->bredr_state.paired =3D false; > > > > > device->le_state.paired =3D false; > > > > > diff --git a/src/device.h b/src/device.h > > > > > index 06b100499..907c7c5c4 100644 > > > > > --- a/src/device.h > > > > > +++ b/src/device.h > > > > > @@ -49,6 +49,7 @@ uint16_t btd_device_get_vendor(struct btd_devic= e *device); > > > > > uint16_t btd_device_get_vendor_src(struct btd_device *device); > > > > > uint16_t btd_device_get_product(struct btd_device *device); > > > > > uint16_t btd_device_get_version(struct btd_device *device); > > > > > +void device_remove_bonding(struct btd_device *device, uint8_t bd= addr_type); > > > > > void device_remove(struct btd_device *device, gboolean remove_st= ored); > > > > > > > > Is there any particular reason why device_remove is not enough here= ? I > > > > don't see any reason to leave the device object around after removi= ng > > > > its bonding. > > > > > > > > > int device_address_cmp(gconstpointer a, gconstpointer b); > > > > > int device_bdaddr_cmp(gconstpointer a, gconstpointer b); > > > > > -- > > > > > 2.27.0.212.ge8ba1cc988-goog > > > > > > > > > > > > > > > > > -- > > > > Luiz Augusto von Dentz > > > > > > > > -- > > Luiz Augusto von Dentz --=20 Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eKe0AyZAD1/+hQEAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 19:43:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SLlrASZAD19BIQEAgupzMw (envelope-from ); Wed, 15 Jul 2020 19:43:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=pks.im header.b=Uuj0l0Os; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=S2WOEQy/ X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 491FA5351C; Wed, 15 Jul 2020 19:42:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbgGORmu (ORCPT + 1 other); Wed, 15 Jul 2020 13:42:50 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:60933 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbgGORmt (ORCPT ); Wed, 15 Jul 2020 13:42:49 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id EA4875C00B0; Wed, 15 Jul 2020 13:42:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 15 Jul 2020 13:42:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=TN1IJMQQ46HiqWTYBvVUnq4EMwJ ndD8JhUy8i6D0BcM=; b=Uuj0l0Osoe2YhvGcaDY28ahp/25GdTrq9QA3OmIKC3/ GcAlqmdurAtp1DipmdOyCT88TrCXfqD1A5FZ12NCdPAaxTw9ghPtWDAoQv9ODhXM FOSH73UE4WKZNzDtplg3zbdsQaB4Unz/tU+imiFXQrWc9BaCZeSVwAv8uVclmo0b SCucYbgYKLMDVRm4DiSAa3c1dB1IH9DmNie8YERHgZungF8udAiJrY/scR4x9opy YtJ+PLhOYLn4ZCNA4/gFpwBC2esDwsS6l5D/vdvz5J398JKSsUnEqzdZfd62vgS2 6uiH+pEfdBB/9b9m/G3BgmyYaoHg3ODQo9weRtdcPNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=TN1IJM QQ46HiqWTYBvVUnq4EMwJndD8JhUy8i6D0BcM=; b=S2WOEQy/mPQsf1N5W1dq+E bb0GwMKa7s66gnoPTx07lyINu0F2EDVKpfK3p/GcaJO1kNHW7UiCvFPk7bWvvpC0 v8iHmCicXlW4PLkwcBHUyOeN8nyoyplrCSr7NIeEWVGq6mln2F22iZbBHfl6npFU WAAeWkBLB/raaPjzSVRPxPZHnkxF/+i1D5fEPk4QXEW78Kmj10RKtPQIW3dTXAbK ZEJtCvpQdbl6FzusjDkeS9VLg98QuimWZptm5C7ugK3aMLljWCwNUcLeZS4Yu+Hc pxvdi5gAaLtLQmufvxlb0uk7wyfFDFiN4qPiIj0+0Zuc6UrO1sDLb8bAZ5x8oHnw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrfedvgdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeehgefhtdefueffheekgfffudelffejtdfhvdejkedthfehvdelgfetgfdvtedthfen ucfkphepjeekrdehhedrgeekrdefudenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: from vm-mail.pks.im (x4e37301f.dyn.telefonica.de [78.55.48.31]) by mail.messagingengine.com (Postfix) with ESMTPA id B80EB30600A6; Wed, 15 Jul 2020 13:42:47 -0400 (EDT) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 0ae5c766 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 15 Jul 2020 17:42:44 +0000 (UTC) Date: Wed, 15 Jul 2020 19:43:33 +0200 From: Patrick Steinhardt To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Subject: [PATCH v2] Bluetooth: Fix update of connection state in `hci_encrypt_cfm` Message-ID: <50fd2c75ce196196f879f8373555cc30bfc75154.1594834970.git.ps@pks.im> References: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="XOIedfhf+7KOe/yw" Content-Disposition: inline In-Reply-To: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.82 / 15.00 / 200.00 X-Rspamd-Queue-Id: 491FA5351C X-Rspamd-UID: ca9090 --XOIedfhf+7KOe/yw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Starting with the upgrade to v5.8-rc3, I've noticed I wasn't able to connect to my Bluetooth headset properly anymore. While connecting to the device would eventually succeed, bluetoothd seemed to be confused about the current connection state where the state was flapping hence and forth. Bisecting this issue led to commit 3ca44c16b0dc (Bluetooth: Consolidate encryption handling in hci_encrypt_cfm, 2020-05-19), which refactored `hci_encrypt_cfm` to also handle updating the connection state. The commit in question changed the code to call `hci_connect_cfm` inside `hci_encrypt_cfm` and to change the connection state. But with the conversion, we now only update the connection state if a status was set already. In fact, the reverse should be true: the status should be updated if no status is yet set. So let's fix the isuse by reversing the condition. Fixes: 3ca44c16b0dc ("Bluetooth: Consolidate encryption handling in hci_enc= rypt_cfm") Signed-off-by: Patrick Steinhardt --- include/net/bluetooth/hci_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_c= ore.h index cdd4f1db8670..da3728871e85 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1387,7 +1387,7 @@ static inline void hci_encrypt_cfm(struct hci_conn *c= onn, __u8 status) __u8 encrypt; =20 if (conn->state =3D=3D BT_CONFIG) { - if (status) + if (!status) conn->state =3D BT_CONNECTED; =20 hci_connect_cfm(conn, status); --=20 2.27.0 --XOIedfhf+7KOe/yw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAl8PQEQACgkQVbJhu7ck PpS16g//UnlOVdhsGJy5NF7MOvpKO40nLapdxOc5qvJX37rTLkyE8GTfCKpkrHBf XxJ1DOZWLOhqEEb0RX32L/JjuOCb+wUjAwx6+y6o7vXswFKUxxUlHRxHOGDafq6n eD5NPcw9Lv1dSLvMzNfKVdD/hVgf1wy8Uj92SREcSob8Yzu48nrcovRYGHumhJ49 dg2XJ2a0UpnAxuwjPzcp87rChHCaAYb67yBrWokURVp34QHxjiBt4jM8hERMyD2O BBXiJb7aODo3Wa4BFTZcHMBGraEjpgsrDe1tURBnkrn2MxaAawigwNnz4Q+KJS0S dFUoOuhrcuNgzUGBNiY0efW7SbZ9pFO09hmCgcylb0TCxX28kpOfHX98ruxfdRbz Z/5ayYtmQNQVQojY8TWpz8hoeLArMC8sfrK5eP6B0lpouiDBUVh+LTBrCchs+3Hv OLe7HazD6pPPI6zX2uxLhbSzHld8aC9n088NUlwijCMENRXI30uQIYYioh2vJLsf natq/0YZbWety2hJL1sTp6Ai0lXVpZ2yGyrI6CK+WA8J6GH7Y9Q/JJHCFHr7vcAo 5nlM9gMB4I0Hrww+DlRjFSepX7vhnZz0agD02JWQEgseEtT2cEIJz4PUg12bTvem oe/ZHzjXUm8oKm5GI/7Z/sUEgzC77Et/IOjeyThNUkCQ3pyP7l4= =U4vV -----END PGP SIGNATURE----- --XOIedfhf+7KOe/yw-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UJrUBGFMD1+eSQEAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 20:35:13 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id wGRVA2FMD18y6wEA0J78UA (envelope-from ); Wed, 15 Jul 2020 20:35:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5DD1052EEA; Wed, 15 Jul 2020 20:35:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726960AbgGOSfG (ORCPT + 1 other); Wed, 15 Jul 2020 14:35:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726949AbgGOSfF (ORCPT ); Wed, 15 Jul 2020 14:35:05 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D33ADC061755 for ; Wed, 15 Jul 2020 11:35:05 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id g37so2226191otb.9 for ; Wed, 15 Jul 2020 11:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0eqcagrE5c8qsi0gBLE230gaYYz1327tuB+N9Gr+eeY=; b=ZHDzb8T6xX/0jc3o5jbYyiHR47vANcug8kpk09yFHIo566bE3eg2zVo8Yb01KsFLpo Hl/skSTpX8ThWz4SAmYPCz3TGa0dAiJpL1U7S3ONIwtx9SPAj7i45TsAIpbnTfrtrMj0 MUnb4F/4nsUv/OD6PbBaMbp/mLgy9XUt7XBpVB5h84FoYuR2VzYnLaHrsiAijkrGM/HL JIYRYqiG7U6BD9Sa2YKAf/ssHwqhjwjirt0yPkZe9oivt49YghF0UnlvVu6/OS2i+qnR T5QtkjHq/RUIRI62wOWAp68LG+flIYxVLgWdGuYyuAFNszNkN9AwDUDGREw7TDXPs9VG PJtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0eqcagrE5c8qsi0gBLE230gaYYz1327tuB+N9Gr+eeY=; b=oC63PGL0x/JOQxN6MkhLt2XimrmQA4go9vwhU48YZYgmLlXbTqvUxvaA+SHGJMI+w7 I+b/e7RsjcTDo+dxpUdtVp3acaI/UFjTMEK2NOTci9dhEtjnyCG6Wa7Fb8wnHvtntXQO uftG/BX/wog72DrSU2H59nCYuReSTfipEGfR/CtL5Oo/oIluAAHlyJMVsFqWLmd7PaNQ 50KHDaSA3EWwXLevOVGJ+TUSSfz23zZXJxatRDrun+f+k6uivVEU6uaGBtw8yHZAzs8V 8KPnMEzfJ8JSUK7b+dOtolRIj9aTqw+/PkNh71+kVNVV+7hSSMkKTVAC1aHnkm8e9Dug mcbQ== X-Gm-Message-State: AOAM530npZTHIS2U6H99fjzdabC5N9awhYu4P0Yoez/bYJmF06r8Z/RA zwkDumAe4SGBBB/UCWIBSWBRkqvJyH/FqzPLQcU= X-Google-Smtp-Source: ABdhPJyZAv5ZO4u/WzjgvfFAIwO/HOEMHFMtQbDsKy8VV30nadyS9Ml4EGwaN7bxlcByK+stPDoDYugk0zblqWXsINc= X-Received: by 2002:a9d:5e18:: with SMTP id d24mr944874oti.88.1594838105141; Wed, 15 Jul 2020 11:35:05 -0700 (PDT) MIME-Version: 1.0 References: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> <50fd2c75ce196196f879f8373555cc30bfc75154.1594834970.git.ps@pks.im> In-Reply-To: <50fd2c75ce196196f879f8373555cc30bfc75154.1594834970.git.ps@pks.im> From: Luiz Augusto von Dentz Date: Wed, 15 Jul 2020 11:34:53 -0700 Message-ID: Subject: Re: [PATCH v2] Bluetooth: Fix update of connection state in `hci_encrypt_cfm` To: Patrick Steinhardt Cc: "linux-bluetooth@vger.kernel.org" , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5DD1052EEA X-Rspamd-UID: cb1ebf Hi Patrick, On Wed, Jul 15, 2020 at 10:45 AM Patrick Steinhardt wrote: > > Starting with the upgrade to v5.8-rc3, I've noticed I wasn't able to > connect to my Bluetooth headset properly anymore. While connecting to > the device would eventually succeed, bluetoothd seemed to be confused > about the current connection state where the state was flapping hence > and forth. Bisecting this issue led to commit 3ca44c16b0dc (Bluetooth: > Consolidate encryption handling in hci_encrypt_cfm, 2020-05-19), which > refactored `hci_encrypt_cfm` to also handle updating the connection > state. > > The commit in question changed the code to call `hci_connect_cfm` inside > `hci_encrypt_cfm` and to change the connection state. But with the > conversion, we now only update the connection state if a status was set > already. In fact, the reverse should be true: the status should be > updated if no status is yet set. So let's fix the isuse by reversing the > condition. > > Fixes: 3ca44c16b0dc ("Bluetooth: Consolidate encryption handling in hci_encrypt_cfm") > Signed-off-by: Patrick Steinhardt Acked-by: Luiz Augusto von Dentz > --- > include/net/bluetooth/hci_core.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h > index cdd4f1db8670..da3728871e85 100644 > --- a/include/net/bluetooth/hci_core.h > +++ b/include/net/bluetooth/hci_core.h > @@ -1387,7 +1387,7 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status) > __u8 encrypt; > > if (conn->state == BT_CONFIG) { > - if (status) > + if (!status) > conn->state = BT_CONNECTED; > > hci_connect_cfm(conn, status); > -- > 2.27.0 > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eLFXLgNkD1+lXgAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 22:16:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id KPvILANkD19uBAEADc0bRg (envelope-from ); Wed, 15 Jul 2020 22:16:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6F5AB5382F; Wed, 15 Jul 2020 22:15:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726977AbgGOUNY (ORCPT + 1 other); Wed, 15 Jul 2020 16:13:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726715AbgGOUNW (ORCPT ); Wed, 15 Jul 2020 16:13:22 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B56ECC061755 for ; Wed, 15 Jul 2020 13:13:21 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id a21so2449843otq.8 for ; Wed, 15 Jul 2020 13:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SSlTaimKZUxhBpoV4QKb+X8m/qGL994wGzRZf2wz1Ec=; b=FSx5iuGZNJvLw6WIcKBgXrePeDt5zhHo0slMycgpYWXtue9nHCSgWF5xJFZ8G6TMls cHaT41TLU+Sb3+yBMTM0hblTViMaPSl1+V1ng3K3Tt2fEotN0I45O1lPjrM1W9j1dsiG hv6GeZ7FkhwNg8lGigsXO3RGjawfXponQFUs8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SSlTaimKZUxhBpoV4QKb+X8m/qGL994wGzRZf2wz1Ec=; b=ZRcqtyejBaSQ9BtLBh00Wqx27rW6/9tm31e1KHvWik53OJA22U0LseyWI/S+TE3Gw+ OMp9LAWR2zsFIivkApUxro5Xm2v8MxamRa1IB0h7252XMjn/XW6vr+vvaLzcOlcMAHNK i71WY6v6EX3JtpXHBfcBprRPoab7t4OjCjWK98VVcOSSWrn09yy5gd54D5cWF76myc7t 36PtWxWOjgQ4PRAyysu/vJZ0TkwsIGy5NkpVvP9PZ44EBurQlph2EDPK0NiNzg/Eo2du 708kX256EReVYkgD/2vIyJK7fa8S2iA5e9OzQi3LQ+ktbwuSABS7uKJ649BQz27z5caS rBEg== X-Gm-Message-State: AOAM533VavV/sNgJisk3x7BSY6T8HgC9n+azzZR6/mL3EXb1003e2imf cKdUUQABUlamlDRGo84t9Gy52j8i+pRV+UeVpHsZpA== X-Google-Smtp-Source: ABdhPJyPKoVceLOh7jcnvyWBFtuFM3g8EtKgAw5+01tRh6KpUvmQMuqY92wZV9aJmcO1IQxt/FRrFWZIyINGXXZvs0U= X-Received: by 2002:a9d:4908:: with SMTP id e8mr1253218otf.70.1594844000884; Wed, 15 Jul 2020 13:13:20 -0700 (PDT) MIME-Version: 1.0 References: <20200713201441.235959-1-sonnysasaka@chromium.org> In-Reply-To: From: Sonny Sasaka Date: Wed, 15 Jul 2020 13:13:08 -0700 Message-ID: Subject: Re: [PATCH BlueZ 0/3] Per-device option to enable/disable internal profiles To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6F5AB5382F X-Rspamd-UID: 527675 On Wed, Jul 15, 2020 at 9:25 AM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Tue, Jul 14, 2020 at 1:55 PM Sonny Sasaka wrote: > > > > Hi Luiz, > > > > On Mon, Jul 13, 2020 at 10:28 PM Luiz Augusto von Dentz > > wrote: > > > > > > Hi Sonny, > > > > > > On Mon, Jul 13, 2020 at 4:48 PM Sonny Sasaka wrote: > > > > > > > > Hi Luiz, > > > > > > > > On Mon, Jul 13, 2020 at 3:59 PM Luiz Augusto von Dentz > > > > wrote: > > > > > > > > > > Hi Sonny, > > > > > > > > > > On Mon, Jul 13, 2020 at 3:04 PM Sonny Sasaka wrote: > > > > > > > > > > > > Hi Luiz, > > > > > > > > > > > > I considered having such an approach that gives exception to some > > > > > > profile to not claim exclusive access. However, I think that this > > > > > > approach has a drawback that it can only be guaranteed to work > > > > > > correctly for profiles that contain only read-only attributes. Any > > > > > > profile that contains writable attributes, naturally, cannot be > > > > > > guaranteed to always work correctly (as is the case with the Battery > > > > > > profile). Therefore, the usefulness of that feature will be very > > > > > > limited. > > > > > > > > > > > > I also considered the benefits of the AllowInternalProfiles approach: > > > > > > * Applications can also have control over any profile, not just > > > > > > Battery profile. For example, if in the future BlueZ has more internal > > > > > > profiles, like (Blood Pressure Profile or any other profile that may > > > > > > contain writable attributes), we can guarantee that applications can > > > > > > still opt to have access to that profile, without relying on a profile > > > > > > being "safe" to be shared by both BlueZ's internal and external > > > > > > handlers. > > > > > > * This has an added security benefit: applications which operate on a > > > > > > specific GATT profile will not unintentionally activate internal > > > > > > profiles such as HOG (which is able to hijack input control of the > > > > > > host). This is the correct and expected behavior of Android apps that > > > > > > connect over GATT and get access to a GATT profile. > > > > > > > > > > Not sure I follow these arguments, it seems AllowInternalProfiles may > > > > > actually enable hijacking the profiles so I wonder if you got this > > > > > backwards as we can't let things like HoG be controlled by > > > > > applications directly it would be too easy to implement something like > > > > > a keylogger, or perhaps you are suggesting that there is another layer > > > > > for implementing the profiles? Note that it is intended that plugins > > > > > shall be used for profiles that need to be integrated system wide, > > > > > D-Bus interface shall be restricted to only application specific > > > > > profiles. > > > > > > > > I think you misunderstood my point about HOG hijacking. Consider the > > > > following case: > > > > 1. A legit application (not System UI) on a host computer scans and > > > > connects to a nearby peer. It makes a guess about the peer device > > > > based on its advertising data. It intends to operate on a specific > > > > GATT profile (not necessarily Battery). > > > > 2. The peer device turns out to be malicious. It runs HOG GATT server > > > > and triggers the host's HOG profile to be active. > > > > 3. The malicious peer device's HOG GATT server can now maliciously > > > > make mouse movements or enter keystrokes to the host. > > > > > > I'm not sure how you would like to prevent that, we could in theory > > > attempt to authorize every single profile before connecting, just like > > > it is done for legacy, but Im sure system would not be asking the user > > > what profiles to connect so they just end up trusting the device, > > > alternatively we could make ConnectProfile to work also for LE so you > > > can provide a UUID and nothing else would be exposed, but note that > > > this guess on the AD may actually be wrong and the device may end up > > > malfunctioning. > > > > > > > In this case the user is considered being attacked, because he/she > > > > doesn't consciously interact with the System UI to connect to a nearby > > > > mouse/keyboard. > > > > My example doesn't have to be HOG. It just happens to be a profile > > > > which is attackable at the moment. My point is that, for applications > > > > it's always safest to turn off all internal profiles to avoid such > > > > incident. There is no use case where applications want to trigger > > > > internal profiles. > > > > > > > > Note 1: By "applications", I mean things like Android apps or > > > > JavaScript apps which are not considered System's Bluetooth UI. > > > > > > Well that doesn't make my point moot, let's say we do enable > > > connecting by UUID and the application try to connect HoG, it could be > > > a malicious application trying to eavesdrop what the user is typing, > > > so this problem of malicious goes both ways Im afraid, besides the > > > performance penalty that one would have if we need to transport HID > > > over D-Bus. > > If an application handles HOG, there will be nothing to eavesdrop > > because that application shouldn't have an access to UHID in the first > > place. If that malicious application had UHID access, that is already > > a problem to begin with regardless of whether there is Bluetooth or > > not. The security of this is handled above the Bluetooth layer. The > > operating system that uses this feature is responsible for higher > > layer security. For operating systems that don't need it I am okay > > with adding an option to disable this feature altogether. But I can > > see that there are systems that need it and I am not convinced that a > > general purpose Bluetooth stack should not support it. > > All a malicious application has to do is to subscribe to notification > of HoG characteristic, then any input generate by the device would be > notified back to the application and that doesn't matter if uHID is > accessible or not the application may not even forward the events to > the system, now perhaps you are imagining that applications don't have > direct access to the attribute objects but that would be system > specific which is rather tricky to define. When the HOG-related GATT object is available on D-Bus, that means the internal HOG profile is not enabled in the first place, so there is nothing to sniff anyway. Furthermore, the higher layer operating system is also responsible to prevent this if it chooses to disable BlueZ's internal HOG profile handler. If an operating system thinks that it is safer to always enable internal HOG they can do just that, as I mentioned I'm willing to add an option to always enable all internal profiles. > > > > > > > More applications could be involved and then this all becomes a mess > > > if they have to fight over AllowInternalProfiles, so instead of using > > > a theoretical example we better find real apps and devices where > > > conflicts happens and work out case by case, adding ConnectProfile > > > should actually fix most of them if there is a single profile involved > > > by we could also thing about an alternative to connect multiples. > > > There is also the possibility of exposing the btd_service as objects, > > > I've actually had this implemented for the car industry, that way > > > AutoConnect property could actually be controlled on a per service > > > basis instead of having just one switch for everything. > > To be clear, applications do not have direct access to > > AllowInternalProfiles. The higher layer operating system controls it. > > This is just the same case as the org.bluez.Adapter1.Powered property > > and many other examples where applications are not expected to have > > direct control of. Therefore there should be no problem of many things > > fighting over it if used correctly, just like many other properties. > > Again, I am okay with adding an option to disable this for operating > > systems that do not want it. > > I see, though you didn't comment on the idea of controlling this on a > per-service basis, not just have everything disabled with > AllowInternalProfiles, note though that there are some profiles we > can't really disable like GAP and GATT as that involves things that > bt_gatt_client itself does need to access in order to work properly. Right, I missed that GAP should be an exception that it cannot be disabled, I should've added that exception in my code. However, it seems that you still don't want a single switch to disable all internal profiles (even with GAP exception). I'm willing to modify this feature to be a blocklist of profiles per device (say BlockedProfiles property on Device1 interface), and this feature can be disabled altogether (all profiles always enabled) for operating systems that do not want it. That idea is also similar to your service_api branch, so I will also try to port your service_api branch on the master branch. I will test this and I am okay with using this if it serves our purposes. I do have a question, though: With this API design, the service objects are not exposed until a remote profile is detected, and sometimes a profile is not detected until connection takes place (if the profile UUID is not in the advertisement). So, how does the BlueZ client block certain profiles/services before connection takes place? We can't wait until connection takes place because we already know that we don't want certain profiles, and if we block a profile after connection takes place would that work properly? I guess we still need a way to block certain profiles in the Device1 API, and the blocked profiles also need to be stored in store_device_info. > > You can find the service_api commits in here: > > https://github.com/Vudentz/BlueZ/commits/service_api > > It does allow to control both the auto_connect logic as well a block: > > https://github.com/Vudentz/BlueZ/commit/9bd6dce59fe9978b3bf415fe74f89d72254b8075 > https://github.com/Vudentz/BlueZ/commit/42a7e479d5beb641a3d94f724a2df60db0f8221c > > > Note: I have been using the term "operating system" to refer to high > > level components rather than the kernel. > > > > > > > > > > > > > > > > > Note that we do allow external profiles to be registered with use of: > > > > > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/profile-api.txt > > > > > > > > > > And for GATT: > > > > > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt#n366 > > > > > > > > > > We could perhaps make the assumption that once an application > > > > > registers itself as supporting a given profile we check if against a > > > > > blacklist of profiles that may have security implications, which > > > > > perhaps could be defined via main.conf or some other file, if that is > > > > > not the case the internal profile can be disabled and the D-Bus object > > > > > would be accessible over D-Bus. Also note that we do offer clients the > > > > > ability to have exclusive access with AcquireWrite and AcquireNotify. > > > > > > > > > > > Therefore I think that this approach, although more complex, has > > > > > > longer lasting benefits. Let me know if you have any objection to > > > > > > having such a feature. > > > > > > > > > > > > > > > > > > On Mon, Jul 13, 2020 at 1:35 PM Luiz Augusto von Dentz > > > > > > wrote: > > > > > > > > > > > > > > Hi Sonny, > > > > > > > > > > > > > > On Mon, Jul 13, 2020 at 1:18 PM Sonny Sasaka wrote: > > > > > > > > > > > > > > > > This patch series adds a mechanism for clients to choose whether to > > > > > > > > enable BlueZ internal profiles (e.g. A2DP, Battery) for specific > > > > > > > > devices. > > > > > > > > > > > > > > > > The motivation behind this feature is that some applications (e.g. Web > > > > > > > > Bluetooth or Android apps) need to have control over all remove GATT > > > > > > > > services, like Battery service. With "battery" plugin being enabled on > > > > > > > > BlueZ, it becomes not possible for those apps to work properly because > > > > > > > > BlueZ "hides" the Battery-related attributes from its GATT Client API. > > > > > > > > Disabling the "battery" plugin won't solve the problem either, since we > > > > > > > > do also need to enable the plugin so that we can use org.bluez.Battery1 > > > > > > > > API. > > > > > > > > > > > > > > > > The solution that we propose is that clients can choose whether to > > > > > > > > enable internal profiles for each device. Clients know when to enable > > > > > > > > internal profiles (such as when a user chooses to pair/connect via a UI) > > > > > > > > and when to disable internal profiles (such as when the connection is > > > > > > > > initiated by a generic application). > > > > > > > > > > > > > > I wonder if it is not better to just have a flag indicating if the > > > > > > > profile shall claim exclusive access (such as GAP and GATT services), > > > > > > > so profiles that don't set that will have the services exposed so for > > > > > > > battery we can probably just have it exposed by default since it > > > > > > > doesn't appear to would be any conflicts on having it exposed. > > > > > > > > > > > > > > > Sonny Sasaka (3): > > > > > > > > doc: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > > > > device: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > > > > client: Add set-allow-internal-profiles command > > > > > > > > > > > > > > > > client/main.c | 38 ++++++++++++++++++ > > > > > > > > doc/device-api.txt | 13 +++++++ > > > > > > > > src/device.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ > > > > > > > > src/hcid.h | 2 + > > > > > > > > src/main.c | 10 +++++ > > > > > > > > src/main.conf | 4 ++ > > > > > > > > 6 files changed, 163 insertions(+) > > > > > > > > > > > > > > > > -- > > > > > > > > 2.26.2 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > > > > > > > > > -- > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CIioIUFrD1+lXgAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 22:46:57 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id mPBvIEFrD1+PnwAA0J78UA (envelope-from ); Wed, 15 Jul 2020 22:46:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DAD5352EFC; Wed, 15 Jul 2020 22:46:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727043AbgGOUqi (ORCPT + 1 other); Wed, 15 Jul 2020 16:46:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726859AbgGOUqh (ORCPT ); Wed, 15 Jul 2020 16:46:37 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9B2EC061755 for ; Wed, 15 Jul 2020 13:46:37 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id cv18so2290883pjb.1 for ; Wed, 15 Jul 2020 13:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=QQRa/jrP5YMzzZg5j7p1SXibP/2/RV/6PXU6mTaicEo=; b=eXBsIRu5AQr+MLwNg4W8xgxDmLzL9FPZubP0zQrBIcHqy8Tfr26d24Ky/26EmuQ1xw oh5b0ymp8vN8XgQg0EOGCgs8n8V1ZLSueFaP//E6XRwdw2BQyu51eJqtzhZIQBfUN+wO rJIaY+X5+k1MEo1ZXJ1yEamaEKdL+iEBM3KBtpxcsX0wof33Q6NZ5Hwtp3JhNKykCiJt cb7mMgAVg9TV6zmNZKW6cocl3hIRCYv69gLlAPWm/ZjnK6EXZjWXqLgytPCV0tJcEW6W zNV+3docyDZd3ohq1svpOw9TVzXcE25m8+0pEgtW9qaoFYhTbOLKyAuz4z4E+E9/lhAo OMNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=QQRa/jrP5YMzzZg5j7p1SXibP/2/RV/6PXU6mTaicEo=; b=TE6a35S3CzzwJMNo7Y39nWY4+DVlJnEuInky/ac8kTBX4vvcIhrWRO9YqAHeY+nVIp djjhffHhyqytqnk3Xi18s/T60zidyKNpqQGANYQeA4Zs50JmwYHCoElUFIignYzHUvNm 5sAE/zJh6dxdG7hSijBGGA6Oya5QYDunycq/JotWYMbsGyiK7IR9pla0ACgTQIQ4FxUf 7AWZ06FfcLKIaCi/cOrFHpM7nJ54oq+Gf3E1237rK6qDPLCtA9U4U8qa1QjfuccX57zt iwjk3ucf8P5eqwqKTPrFQKhYsy9pCaOb3VKMjJTGe9ihsE126Hg0jzMcWLb7I991q29P ZLrg== X-Gm-Message-State: AOAM531eUO8LvgkD91Q8yCH1uvNX4ARgAovE5Cv8ztamAwuTp6LiW0+u 9GeX/WkKVQ1Y/0h9kvC+9Or2kUsg5QA= X-Google-Smtp-Source: ABdhPJwjhXp66SBfEkrA5ATqkn9+ZkKLOac0xe6yVGs06y74PQQRnnU7xbApkONuEz3ntiFtfbtMkw== X-Received: by 2002:a17:90b:70d:: with SMTP id s13mr1457601pjz.161.1594845996847; Wed, 15 Jul 2020 13:46:36 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id i125sm2901142pgd.21.2020.07.15.13.46.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2020 13:46:36 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/2] device: Add timer for removing temporary devices Date: Wed, 15 Jul 2020 13:46:34 -0700 Message-Id: <20200715204635.755599-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.25.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: DAD5352EFC X-Rspamd-UID: 8877bd From: Luiz Augusto von Dentz This adds a timer for how long to keep temporary devices, it is updated everytime the device is seen so devices will be removed even during an active discovery session which means the discovering for a long period will no longer just grow without removing devices that disappeared. --- src/device.c | 34 ++++++++++++++++++++++++++++++++++ src/hcid.h | 1 + src/main.c | 13 +++++++++++++ src/main.conf | 5 +++++ 4 files changed, 53 insertions(+) diff --git a/src/device.c b/src/device.c index 0deee2707..226216235 100644 --- a/src/device.c +++ b/src/device.c @@ -233,6 +233,7 @@ struct btd_device { bool connectable; guint disconn_timer; guint discov_timer; + guint temporary_timer; /* Temporary/disappear timer */ struct browse_req *browse; /* service discover request */ struct bonding_req *bonding; struct authentication_req *authr; /* authentication request */ @@ -698,6 +699,9 @@ static void device_free(gpointer user_data) if (device->discov_timer) g_source_remove(device->discov_timer); + if (device->temporary_timer) + g_source_remove(device->temporary_timer); + if (device->connect) dbus_message_unref(device->connect); @@ -4232,12 +4236,34 @@ void device_set_le_support(struct btd_device *device, uint8_t bdaddr_type) store_device_info(device); } +static gboolean device_disappeared(gpointer user_data) +{ + struct btd_device *dev = user_data; + + dev->temporary_timer = 0; + + btd_adapter_remove_device(dev->adapter, dev); + + return FALSE; +} + void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type) { if (bdaddr_type == BDADDR_BREDR) device->bredr_seen = time(NULL); else device->le_seen = time(NULL); + + if (!device_is_temporary(device)) + return; + + /* Restart temporary timer */ + if (device->temporary_timer) + g_source_remove(device->temporary_timer); + + device->temporary_timer = g_timeout_add_seconds(main_opts.tmpto, + device_disappeared, + device); } /* It is possible that we have two device objects for the same device in @@ -5610,10 +5636,18 @@ void btd_device_set_temporary(struct btd_device *device, bool temporary) device->temporary = temporary; + if (device->temporary_timer) { + g_source_remove(device->temporary_timer); + device->temporary_timer = 0; + } + if (temporary) { if (device->bredr) adapter_whitelist_remove(device->adapter, device); adapter_connect_list_remove(device->adapter, device); + device->temporary_timer = g_timeout_add_seconds(main_opts.tmpto, + device_disappeared, + device); return; } diff --git a/src/hcid.h b/src/hcid.h index c21ac9980..5f249ebf9 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -53,6 +53,7 @@ struct main_opts { gboolean pairable; uint32_t pairto; uint32_t discovto; + uint32_t tmpto; uint8_t privacy; struct { diff --git a/src/main.c b/src/main.c index bacb44197..ec7a9fbd7 100644 --- a/src/main.c +++ b/src/main.c @@ -67,6 +67,7 @@ #define DEFAULT_PAIRABLE_TIMEOUT 0 /* disabled */ #define DEFAULT_DISCOVERABLE_TIMEOUT 180 /* 3 minutes */ +#define DEFAULT_TEMPORARY_TIMEOUT 30 /* 30 seconds */ #define SHUTDOWN_GRACE_SECONDS 10 @@ -89,6 +90,7 @@ static const char *supported_options[] = { "FastConnectable", "Privacy", "JustWorksRepairing", + "TemporaryTimeout", NULL }; @@ -531,6 +533,16 @@ static void parse_config(GKeyFile *config) g_free(str); } + val = g_key_file_get_integer(config, "General", + "TemporaryTimeout", &err); + if (err) { + DBG("%s", err->message); + g_clear_error(&err); + } else { + DBG("tmpto=%d", val); + main_opts.tmpto = val; + } + str = g_key_file_get_string(config, "General", "Name", &err); if (err) { DBG("%s", err->message); @@ -672,6 +684,7 @@ static void init_defaults(void) main_opts.class = 0x000000; main_opts.pairto = DEFAULT_PAIRABLE_TIMEOUT; main_opts.discovto = DEFAULT_DISCOVERABLE_TIMEOUT; + main_opts.tmpto = DEFAULT_TEMPORARY_TIMEOUT; main_opts.reverse_discovery = TRUE; main_opts.name_resolv = TRUE; main_opts.debug_keys = FALSE; diff --git a/src/main.conf b/src/main.conf index 6a6f7d4b4..f41203b96 100644 --- a/src/main.conf +++ b/src/main.conf @@ -77,6 +77,11 @@ # Defaults to "never" #JustWorksRepairing = never +# How long to keep temporary devices around +# The value is in seconds. Default is 30. +# 0 = disable timer, i.e. never keep temporary devices +#TemporaryTimeout = 30 + [Controller] # The following values are used to load default adapter parameters. BlueZ loads # the values into the kernel before the adapter is powered if the kernel -- 2.25.3 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wA5FD1NrD1+lXgAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 22:47:15 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6F9zDVNrD19irQEAgupzMw (envelope-from ); Wed, 15 Jul 2020 22:47:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AC018531D5; Wed, 15 Jul 2020 22:46:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727795AbgGOUqk (ORCPT + 1 other); Wed, 15 Jul 2020 16:46:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726859AbgGOUqi (ORCPT ); Wed, 15 Jul 2020 16:46:38 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AC57C061755 for ; Wed, 15 Jul 2020 13:46:38 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id gc15so2292095pjb.0 for ; Wed, 15 Jul 2020 13:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qI7srOxReILXOvnMcKlZjOffQlZJcwTzr1eNxTALca4=; b=vgPkwNgHScNjq/+eA2pH424fLIHnwYDcFVmwqcMFlf4bFCB7LwjEvCIdjYSMwU4MYZ Wdg+Vn7ZVKMZQew9BIvtslzQuSxBe0GzfXouM13/p85cMYIabzRd8MELSSYTAj1J2tRS mLsvJxD6Ds9wT+GQmffhDreVmawxf9wQJ8EbFnSjCpk8JCRtS7znc7Eq1i1PpJPpglPQ YZRce/MpwHdD8D3Umno9ELFaJ2sCBUsMJq4bxNg4bzhjBK1u9E7GU82n0xP3p3kSu7E4 U4mfBbQ/c2bQD1t6XCZJuLl0os3A7DaYCJUsz3ObDVS3pFNqu1lsIvF2pyO4lKNoT9E3 WOqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qI7srOxReILXOvnMcKlZjOffQlZJcwTzr1eNxTALca4=; b=AEJtT8pVmbO+QFwUqnCgPYXzS/jH83kSNGMOpG2b3fdYB8jE4dAS7Nd/JTc3uwDGB9 T1eIvZ6oSguDwUHJVwlxPd3qj/wFBJ4/4k0TlbL6X+qpRC+qn7Q9b1XxVHnBqFWU7eEl +ZYjSAOc4/Y0jL3r0CUp8wqM7OurutYFV1qnknL4TWTtWb+7rHXdU525BJ1drSmOwT+F EzruKoY67wnZ/Tpzp31hBRCFAUdTzMKoHoqLdA9o7WrD+rXupAGSH7UV4oWJPm21WtmU M6m9iebb/P12PwvlK7U/Jn7UOe3r/ZyHGSgtzQElcGhImTverUw0NOz7S55wfYIW4PVO 0kgQ== X-Gm-Message-State: AOAM533EOCmGo5yJuoJ22iOB7s1w3vvX+cvDZgkCpWV9k4M9WNhQGDli 7ap3f8uYNrqTGEFAFtIhmctsZDyyvA0= X-Google-Smtp-Source: ABdhPJygIoHJJ+F+SXz8r7bL9DI3gLJtzwO3nxyjz6vR4y6meZRJztQHZT354i/hEFomuhFz/nMlWA== X-Received: by 2002:a17:90a:354d:: with SMTP id q71mr1559702pjb.216.1594845997632; Wed, 15 Jul 2020 13:46:37 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id i125sm2901142pgd.21.2020.07.15.13.46.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2020 13:46:37 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 2/2] adapter: Remove timer for removing temporary devices Date: Wed, 15 Jul 2020 13:46:35 -0700 Message-Id: <20200715204635.755599-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200715204635.755599-1-luiz.dentz@gmail.com> References: <20200715204635.755599-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: AC018531D5 X-Rspamd-UID: 9fe4cd From: Luiz Augusto von Dentz Now that each temporary device object can cleanup after it has detected that it has disappeared it is no longer necessary to keep this logic as well in the adapter. --- src/adapter.c | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 7a80554c5..c757447e2 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -258,7 +258,6 @@ struct btd_adapter { GSList *discovery_found; /* list of found devices */ guint discovery_idle_timeout; /* timeout between discovery runs */ guint passive_scan_timeout; /* timeout between passive scans */ - guint temp_devices_timeout; /* timeout for temporary devices */ guint pairable_timeout_id; /* pairable timeout id */ guint auth_idle_id; /* Pending authorization dequeue */ @@ -1484,27 +1483,6 @@ static void invalidate_rssi_and_tx_power(gpointer a) device_set_tx_power(dev, 127); } -static gboolean remove_temp_devices(gpointer user_data) -{ - struct btd_adapter *adapter = user_data; - GSList *l, *next; - - DBG("%s", adapter->path); - - adapter->temp_devices_timeout = 0; - - for (l = adapter->devices; l != NULL; l = next) { - struct btd_device *dev = l->data; - - next = g_slist_next(l); - - if (device_is_temporary(dev) && !btd_device_is_connected(dev)) - btd_adapter_remove_device(adapter, dev); - } - - return FALSE; -} - static void discovery_cleanup(struct btd_adapter *adapter, int timeout) { GSList *l, *next; @@ -1516,11 +1494,6 @@ static void discovery_cleanup(struct btd_adapter *adapter, int timeout) adapter->discovery_idle_timeout = 0; } - if (adapter->temp_devices_timeout > 0) { - g_source_remove(adapter->temp_devices_timeout); - adapter->temp_devices_timeout = 0; - } - g_slist_free_full(adapter->discovery_found, invalidate_rssi_and_tx_power); adapter->discovery_found = NULL; @@ -1536,9 +1509,6 @@ static void discovery_cleanup(struct btd_adapter *adapter, int timeout) if (device_is_temporary(dev) && !device_is_connectable(dev)) btd_adapter_remove_device(adapter, dev); } - - adapter->temp_devices_timeout = g_timeout_add_seconds(timeout, - remove_temp_devices, adapter); } static void discovery_free(void *user_data) -- 2.25.3 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ycKNDRdvD18iogAAvsO+Rg (envelope-from ) for ; Wed, 15 Jul 2020 23:03:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AEdECxdvD1+KDQEADc0bRg (envelope-from ); Wed, 15 Jul 2020 23:03:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 00D1E53683; Wed, 15 Jul 2020 23:03:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbgGOVDN (ORCPT + 1 other); Wed, 15 Jul 2020 17:03:13 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:40369 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbgGOVDN (ORCPT ); Wed, 15 Jul 2020 17:03:13 -0400 X-Originating-IP: 82.255.60.242 Received: from classic (lns-bzn-39-82-255-60-242.adsl.proxad.net [82.255.60.242]) (Authenticated sender: hadess@hadess.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 365C540004; Wed, 15 Jul 2020 21:03:11 +0000 (UTC) Message-ID: Subject: Re: [PATCH BlueZ 1/2] device: Add timer for removing temporary devices From: Bastien Nocera To: Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org Date: Wed, 15 Jul 2020 23:03:11 +0200 In-Reply-To: <20200715204635.755599-1-luiz.dentz@gmail.com> References: <20200715204635.755599-1-luiz.dentz@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: 00D1E53683 X-Rspamd-UID: dff345 On Wed, 2020-07-15 at 13:46 -0700, Luiz Augusto von Dentz wrote: > From: Luiz Augusto von Dentz > > This adds a timer for how long to keep temporary devices, it is > updated > everytime the device is seen so devices will be removed even during > an > active discovery session which means the discovering for a long > period > will no longer just grow without removing devices that disappeared. Both patches look good to me. Cheers Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ODfPIBCDD1+u7wAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 00:28:32 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iKknHxCDD1+KTAAAlp8NpQ (envelope-from ); Thu, 16 Jul 2020 00:28:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0329FA2FC8; Thu, 16 Jul 2020 00:28:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726968AbgGOW20 (ORCPT + 1 other); Wed, 15 Jul 2020 18:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726965AbgGOW2Z (ORCPT ); Wed, 15 Jul 2020 18:28:25 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAB2AC061755 for ; Wed, 15 Jul 2020 15:28:25 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id b92so3693153pjc.4 for ; Wed, 15 Jul 2020 15:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=D34xJWmipzmXVSNToY0e2bj92OfU6zmBJh4+b4kN3sw=; b=mL8hWUQHHP9QLJktTCRh3znAc0Ue/04VB/mlVT4TsQXNf8RVd4gDKfluKfQwyneFme v1uGg23w1BTN1eMEhfftWWjTLPD71wcqq33TqOk7PEVyS1tgtKQPoUnb91yHQFBJHcaL EOUbJOeYcx5S7mx/zBFVuYJkAgX1zqyNPsREw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=D34xJWmipzmXVSNToY0e2bj92OfU6zmBJh4+b4kN3sw=; b=cSyOhp2pdfuIIU7tBXsqbIAQnETcQu5k5o9N5WSKvHDAjTv0QSHxZBe2EbkeHgaszV qM+asG+O28cm0EKDbwkLk+Ust73AInmirXWyQsz7njWAeJPEuM0vTXC0rmKU689guyI7 pmKZxSA+21vg4IoJ3KfYDfzFp24LQvgCVTuemL8n7M22pXRG35rMGat+izOi29iM7gvN 4nT4ptVKEXti764bDSYTvm5ahns1rgJ34eLHAYCyhhFmkP9NdE1c959n0h2NpdY53RD/ TO7PZQ6uoWJ3rfLi2aUBGixqfXnVCwzsWjZ17PGY5HwLOReJeCx4L8WMIIu0r7WrOob3 diEA== X-Gm-Message-State: AOAM530EAbgW4WFghLI0XVqA7KgFQHJSwdW5o2NTsQFccTyhbJ7jLAFY v2MAUia8zJ0VQhSj3QHonDVMAfvIhkY= X-Google-Smtp-Source: ABdhPJzRS6GkFOfe9SCqYlQK5A+af1XuSqEIPb/xfX97y+t3d+uJ7yJUHNujA9d5r+I48MFAWIB1aw== X-Received: by 2002:a17:902:9a81:: with SMTP id w1mr1252766plp.186.1594852104960; Wed, 15 Jul 2020 15:28:24 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id 4sm2923774pgk.68.2020.07.15.15.28.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2020 15:28:24 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka Subject: [PATCH BlueZ] profile: Add exception from being claimed internally Date: Wed, 15 Jul 2020 15:28:12 -0700 Message-Id: <20200715222812.238172-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0329FA2FC8 X-Rspamd-UID: 3bde74 This adds a flag to give exception to profiles that are considered safe to be both handled internally and externally via GATT API. Currently this includes the battery profile. --- profiles/battery/battery.c | 1 + src/device.c | 2 +- src/profile.h | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c index 4da4355a1..20aa47727 100644 --- a/profiles/battery/battery.c +++ b/profiles/battery/battery.c @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = { .device_remove = batt_remove, .accept = batt_accept, .disconnect = batt_disconnect, + .claim_service_exception = true, }; static int batt_init(void) diff --git a/src/device.c b/src/device.c index 0deee2707..cfa52461f 100644 --- a/src/device.c +++ b/src/device.c @@ -3818,7 +3818,7 @@ done: profile = btd_service_get_profile(service); /* Claim attributes of internal profiles */ - if (!profile->external) { + if (!profile->external && !profile->claim_service_exception) { /* Mark the service as claimed by the existing profile. */ gatt_db_service_set_claimed(attr, true); } diff --git a/src/profile.h b/src/profile.h index 4448a2a6d..25e83381b 100644 --- a/src/profile.h +++ b/src/profile.h @@ -36,6 +36,11 @@ struct btd_profile { bool auto_connect; bool external; + /* Some profiles are considered safe to be handled internally and also + * be exposed in the GATT API. This flag give such profiles exception + * from being claimed internally. + */ + bool claim_service_exception; int (*device_probe) (struct btd_service *service); void (*device_remove) (struct btd_service *service); -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UFfDIW2DD19C/gAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 00:30:05 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id IEI8IG2DD182eAEAlScrYA (envelope-from ); Thu, 16 Jul 2020 00:30:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8A92CA2BA3; Thu, 16 Jul 2020 00:29:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726778AbgGOW36 (ORCPT + 1 other); Wed, 15 Jul 2020 18:29:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbgGOW35 (ORCPT ); Wed, 15 Jul 2020 18:29:57 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB107C061755 for ; Wed, 15 Jul 2020 15:29:57 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id t6so794637ooh.4 for ; Wed, 15 Jul 2020 15:29:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jVS5LRh2Fl5BQG8nixvJAmHU14gHVNgz+wTNqQ3dAnc=; b=NB78jEOsuk5blaz5tGx/BVzVasfRMjdWocBkybUajZAOChAoqAbwK+ArgF4OPHeXDA vcymqEgQ94F1dyFcK3P9ZH+NMsdZgvpfKkU0vgO0bbcokaPaOBdThd2z1u3CD7zKW9Db fNzb7by7VBGbJK4vIa3udF0QgNRvDY3WUo0rw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jVS5LRh2Fl5BQG8nixvJAmHU14gHVNgz+wTNqQ3dAnc=; b=olVzYPzrU/cdVhUuA7XlSCa+rV4TIyRn7f2gAbn4hJ8L3QeFNI70Dl4NNzAQWlu4R6 uGS4UUjGc2/k1W51f1yO2MkNFYuFOnZSHLjs06eOTf0RijdFB4sQkW1AzDgqee5waaTl YpqOiyRVS2yU3mMJd+W+tuTm7yvIGtdeQQe7LR8dAai74XsRBPw/f7/oKs9LOihBW/si DpVZn5przZQMdANox3sezXfast4IK8B2qs4nKBSJr1VsGejduz+Kab0jNqIqKTJl6q96 LWS9craj5/s7/YUCCcHxUCx8VvowVLjtauAgL3mCawRh+QM8A9XN8oolP0XGPQm7FzLp 96Ig== X-Gm-Message-State: AOAM533K8k9MP/tGNkKAqP9zUGj/n90JZ3vuqfMoeUrA2XtS3/A57k/8 rc0z+/UX4oUvMWkykAQ7VWFo1kHmIGblAEeDBkL+ow== X-Google-Smtp-Source: ABdhPJzZ/WFi1wbEeicwQr0ETlOjpsmTpSmQg26q34cdrku6R37aOqKx+V9ShAO728+a7UGPw1NOTfHKtEDRNWfmoW8= X-Received: by 2002:a4a:2459:: with SMTP id v25mr1375414oov.75.1594852196823; Wed, 15 Jul 2020 15:29:56 -0700 (PDT) MIME-Version: 1.0 References: <20200713201441.235959-1-sonnysasaka@chromium.org> In-Reply-To: From: Sonny Sasaka Date: Wed, 15 Jul 2020 15:29:44 -0700 Message-ID: Subject: Re: [PATCH BlueZ 0/3] Per-device option to enable/disable internal profiles To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8A92CA2BA3 X-Rspamd-UID: b28067 Hi Luiz, On Wed, Jul 15, 2020 at 2:09 PM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Wed, Jul 15, 2020 at 1:13 PM Sonny Sasaka wrote: > > > > On Wed, Jul 15, 2020 at 9:25 AM Luiz Augusto von Dentz > > wrote: > > > > > > Hi Sonny, > > > > > > On Tue, Jul 14, 2020 at 1:55 PM Sonny Sasaka wrote: > > > > > > > > Hi Luiz, > > > > > > > > On Mon, Jul 13, 2020 at 10:28 PM Luiz Augusto von Dentz > > > > wrote: > > > > > > > > > > Hi Sonny, > > > > > > > > > > On Mon, Jul 13, 2020 at 4:48 PM Sonny Sasaka wrote: > > > > > > > > > > > > Hi Luiz, > > > > > > > > > > > > On Mon, Jul 13, 2020 at 3:59 PM Luiz Augusto von Dentz > > > > > > wrote: > > > > > > > > > > > > > > Hi Sonny, > > > > > > > > > > > > > > On Mon, Jul 13, 2020 at 3:04 PM Sonny Sasaka wrote: > > > > > > > > > > > > > > > > Hi Luiz, > > > > > > > > > > > > > > > > I considered having such an approach that gives exception to some > > > > > > > > profile to not claim exclusive access. However, I think that this > > > > > > > > approach has a drawback that it can only be guaranteed to work > > > > > > > > correctly for profiles that contain only read-only attributes. Any > > > > > > > > profile that contains writable attributes, naturally, cannot be > > > > > > > > guaranteed to always work correctly (as is the case with the Battery > > > > > > > > profile). Therefore, the usefulness of that feature will be very > > > > > > > > limited. > > > > > > > > > > > > > > > > I also considered the benefits of the AllowInternalProfiles approach: > > > > > > > > * Applications can also have control over any profile, not just > > > > > > > > Battery profile. For example, if in the future BlueZ has more internal > > > > > > > > profiles, like (Blood Pressure Profile or any other profile that may > > > > > > > > contain writable attributes), we can guarantee that applications can > > > > > > > > still opt to have access to that profile, without relying on a profile > > > > > > > > being "safe" to be shared by both BlueZ's internal and external > > > > > > > > handlers. > > > > > > > > * This has an added security benefit: applications which operate on a > > > > > > > > specific GATT profile will not unintentionally activate internal > > > > > > > > profiles such as HOG (which is able to hijack input control of the > > > > > > > > host). This is the correct and expected behavior of Android apps that > > > > > > > > connect over GATT and get access to a GATT profile. > > > > > > > > > > > > > > Not sure I follow these arguments, it seems AllowInternalProfiles may > > > > > > > actually enable hijacking the profiles so I wonder if you got this > > > > > > > backwards as we can't let things like HoG be controlled by > > > > > > > applications directly it would be too easy to implement something like > > > > > > > a keylogger, or perhaps you are suggesting that there is another layer > > > > > > > for implementing the profiles? Note that it is intended that plugins > > > > > > > shall be used for profiles that need to be integrated system wide, > > > > > > > D-Bus interface shall be restricted to only application specific > > > > > > > profiles. > > > > > > > > > > > > I think you misunderstood my point about HOG hijacking. Consider the > > > > > > following case: > > > > > > 1. A legit application (not System UI) on a host computer scans and > > > > > > connects to a nearby peer. It makes a guess about the peer device > > > > > > based on its advertising data. It intends to operate on a specific > > > > > > GATT profile (not necessarily Battery). > > > > > > 2. The peer device turns out to be malicious. It runs HOG GATT server > > > > > > and triggers the host's HOG profile to be active. > > > > > > 3. The malicious peer device's HOG GATT server can now maliciously > > > > > > make mouse movements or enter keystrokes to the host. > > > > > > > > > > I'm not sure how you would like to prevent that, we could in theory > > > > > attempt to authorize every single profile before connecting, just like > > > > > it is done for legacy, but Im sure system would not be asking the user > > > > > what profiles to connect so they just end up trusting the device, > > > > > alternatively we could make ConnectProfile to work also for LE so you > > > > > can provide a UUID and nothing else would be exposed, but note that > > > > > this guess on the AD may actually be wrong and the device may end up > > > > > malfunctioning. > > > > > > > > > > > In this case the user is considered being attacked, because he/she > > > > > > doesn't consciously interact with the System UI to connect to a nearby > > > > > > mouse/keyboard. > > > > > > My example doesn't have to be HOG. It just happens to be a profile > > > > > > which is attackable at the moment. My point is that, for applications > > > > > > it's always safest to turn off all internal profiles to avoid such > > > > > > incident. There is no use case where applications want to trigger > > > > > > internal profiles. > > > > > > > > > > > > Note 1: By "applications", I mean things like Android apps or > > > > > > JavaScript apps which are not considered System's Bluetooth UI. > > > > > > > > > > Well that doesn't make my point moot, let's say we do enable > > > > > connecting by UUID and the application try to connect HoG, it could be > > > > > a malicious application trying to eavesdrop what the user is typing, > > > > > so this problem of malicious goes both ways Im afraid, besides the > > > > > performance penalty that one would have if we need to transport HID > > > > > over D-Bus. > > > > If an application handles HOG, there will be nothing to eavesdrop > > > > because that application shouldn't have an access to UHID in the first > > > > place. If that malicious application had UHID access, that is already > > > > a problem to begin with regardless of whether there is Bluetooth or > > > > not. The security of this is handled above the Bluetooth layer. The > > > > operating system that uses this feature is responsible for higher > > > > layer security. For operating systems that don't need it I am okay > > > > with adding an option to disable this feature altogether. But I can > > > > see that there are systems that need it and I am not convinced that a > > > > general purpose Bluetooth stack should not support it. > > > > > > All a malicious application has to do is to subscribe to notification > > > of HoG characteristic, then any input generate by the device would be > > > notified back to the application and that doesn't matter if uHID is > > > accessible or not the application may not even forward the events to > > > the system, now perhaps you are imagining that applications don't have > > > direct access to the attribute objects but that would be system > > > specific which is rather tricky to define. > > When the HOG-related GATT object is available on D-Bus, that means the > > internal HOG profile is not enabled in the first place, so there is > > nothing to sniff anyway. Furthermore, the higher layer operating > > system is also responsible to prevent this if it chooses to disable > > BlueZ's internal HOG profile handler. If an operating system thinks > > that it is safer to always enable internal HOG they can do just that, > > as I mentioned I'm willing to add an option to always enable all > > internal profiles. > > > > > > > > > > > > > > > More applications could be involved and then this all becomes a mess > > > > > if they have to fight over AllowInternalProfiles, so instead of using > > > > > a theoretical example we better find real apps and devices where > > > > > conflicts happens and work out case by case, adding ConnectProfile > > > > > should actually fix most of them if there is a single profile involved > > > > > by we could also thing about an alternative to connect multiples. > > > > > There is also the possibility of exposing the btd_service as objects, > > > > > I've actually had this implemented for the car industry, that way > > > > > AutoConnect property could actually be controlled on a per service > > > > > basis instead of having just one switch for everything. > > > > To be clear, applications do not have direct access to > > > > AllowInternalProfiles. The higher layer operating system controls it. > > > > This is just the same case as the org.bluez.Adapter1.Powered property > > > > and many other examples where applications are not expected to have > > > > direct control of. Therefore there should be no problem of many things > > > > fighting over it if used correctly, just like many other properties. > > > > Again, I am okay with adding an option to disable this for operating > > > > systems that do not want it. > > > > > > I see, though you didn't comment on the idea of controlling this on a > > > per-service basis, not just have everything disabled with > > > AllowInternalProfiles, note though that there are some profiles we > > > can't really disable like GAP and GATT as that involves things that > > > bt_gatt_client itself does need to access in order to work properly. > > Right, I missed that GAP should be an exception that it cannot be > > disabled, I should've added that exception in my code. > > > > However, it seems that you still don't want a single switch to disable > > all internal profiles (even with GAP exception). I'm willing to modify > > this feature to be a blocklist of profiles per device (say > > BlockedProfiles property on Device1 interface), and this feature can > > be disabled altogether (all profiles always enabled) for operating > > systems that do not want it. > > > > That idea is also similar to your service_api branch, so I will also > > try to port your service_api branch on the master branch. I will test > > this and I am okay with using this if it serves our purposes. > > I do have a question, though: With this API design, the service > > objects are not exposed until a remote profile is detected, and > > sometimes a profile is not detected until connection takes place (if > > the profile UUID is not in the advertisement). So, how does the BlueZ > > client block certain profiles/services before connection takes place? > > We can't wait until connection takes place because we already know > > that we don't want certain profiles, and if we block a profile after > > connection takes place would that work properly? I guess we still need > > a way to block certain profiles in the Device1 API, and the blocked > > profiles also need to be stored in store_device_info. > > That is a good point, but that would be a problem only for the very > first time you connect since after that the blocked state should be > recovered, we could however work out an API where one can enter the > profiles to connect and to block but usually depends on the services > being resolved so I wonder it wouldn't just be enough to block the > service discovery and in the event the internal profile has already > been connected it would just disconnect, the objects would only be > exported after you had it blocked so that means there should be any > race, but perhaps you want a dedicate Connect method where one can > enumerate the profiles to auto-connect and to block, note though that > it may not be possible to indicate a valid list in case the services > have not been resolved. Thanks for the input. In the meantime, I am okay with resolving the battery profile specifically by giving it an exception from being claimed internally. I have sent another patch for this. > > > > > > > You can find the service_api commits in here: > > > > > > https://github.com/Vudentz/BlueZ/commits/service_api > > > > > > It does allow to control both the auto_connect logic as well a block: > > > > > > https://github.com/Vudentz/BlueZ/commit/9bd6dce59fe9978b3bf415fe74f89d72254b8075 > > > https://github.com/Vudentz/BlueZ/commit/42a7e479d5beb641a3d94f724a2df60db0f8221c > > > > > > > Note: I have been using the term "operating system" to refer to high > > > > level components rather than the kernel. > > > > > > > > > > > > > > > > > > > > > > > > > > > Note that we do allow external profiles to be registered with use of: > > > > > > > > > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/profile-api.txt > > > > > > > > > > > > > > And for GATT: > > > > > > > > > > > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt#n366 > > > > > > > > > > > > > > We could perhaps make the assumption that once an application > > > > > > > registers itself as supporting a given profile we check if against a > > > > > > > blacklist of profiles that may have security implications, which > > > > > > > perhaps could be defined via main.conf or some other file, if that is > > > > > > > not the case the internal profile can be disabled and the D-Bus object > > > > > > > would be accessible over D-Bus. Also note that we do offer clients the > > > > > > > ability to have exclusive access with AcquireWrite and AcquireNotify. > > > > > > > > > > > > > > > Therefore I think that this approach, although more complex, has > > > > > > > > longer lasting benefits. Let me know if you have any objection to > > > > > > > > having such a feature. > > > > > > > > > > > > > > > > > > > > > > > > On Mon, Jul 13, 2020 at 1:35 PM Luiz Augusto von Dentz > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > Hi Sonny, > > > > > > > > > > > > > > > > > > On Mon, Jul 13, 2020 at 1:18 PM Sonny Sasaka wrote: > > > > > > > > > > > > > > > > > > > > This patch series adds a mechanism for clients to choose whether to > > > > > > > > > > enable BlueZ internal profiles (e.g. A2DP, Battery) for specific > > > > > > > > > > devices. > > > > > > > > > > > > > > > > > > > > The motivation behind this feature is that some applications (e.g. Web > > > > > > > > > > Bluetooth or Android apps) need to have control over all remove GATT > > > > > > > > > > services, like Battery service. With "battery" plugin being enabled on > > > > > > > > > > BlueZ, it becomes not possible for those apps to work properly because > > > > > > > > > > BlueZ "hides" the Battery-related attributes from its GATT Client API. > > > > > > > > > > Disabling the "battery" plugin won't solve the problem either, since we > > > > > > > > > > do also need to enable the plugin so that we can use org.bluez.Battery1 > > > > > > > > > > API. > > > > > > > > > > > > > > > > > > > > The solution that we propose is that clients can choose whether to > > > > > > > > > > enable internal profiles for each device. Clients know when to enable > > > > > > > > > > internal profiles (such as when a user chooses to pair/connect via a UI) > > > > > > > > > > and when to disable internal profiles (such as when the connection is > > > > > > > > > > initiated by a generic application). > > > > > > > > > > > > > > > > > > I wonder if it is not better to just have a flag indicating if the > > > > > > > > > profile shall claim exclusive access (such as GAP and GATT services), > > > > > > > > > so profiles that don't set that will have the services exposed so for > > > > > > > > > battery we can probably just have it exposed by default since it > > > > > > > > > doesn't appear to would be any conflicts on having it exposed. > > > > > > > > > > > > > > > > > > > Sonny Sasaka (3): > > > > > > > > > > doc: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > > > > > > device: Add "AllowInternalProfiles" property to org.bluez.Device1 > > > > > > > > > > client: Add set-allow-internal-profiles command > > > > > > > > > > > > > > > > > > > > client/main.c | 38 ++++++++++++++++++ > > > > > > > > > > doc/device-api.txt | 13 +++++++ > > > > > > > > > > src/device.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ > > > > > > > > > > src/hcid.h | 2 + > > > > > > > > > > src/main.c | 10 +++++ > > > > > > > > > > src/main.conf | 4 ++ > > > > > > > > > > 6 files changed, 163 insertions(+) > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > > 2.26.2 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > > > > > > > > > -- > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uFFrCMuFD18nBgEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 00:40:11 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WKypBsuFD1/L+wEAgupzMw (envelope-from ); Thu, 16 Jul 2020 00:40:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7D929A30EA; Thu, 16 Jul 2020 00:40:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727036AbgGOWkF (ORCPT + 1 other); Wed, 15 Jul 2020 18:40:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726986AbgGOWkF (ORCPT ); Wed, 15 Jul 2020 18:40:05 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB342C061755 for ; Wed, 15 Jul 2020 15:40:04 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id h17so3546668oie.3 for ; Wed, 15 Jul 2020 15:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QN6u4lUItqEbRecJZob9CnZ8D7gORmssXE47u/uPVag=; b=ByQyMjc/bt5tEsHpQlc/V1P6wi4kdox1kZnT7+Yic+JI61vo5UtKE1YKXmp+8pJpeY tF9ON/ldQ4OaMqy5SqqMOBth5w0Fg5wU6vNNxZqcGcJ9YonKgR+R3/dqyvMPbtOMgzfK cokdXxuB/sy68Lt1yt5/UYscb/mPcYOjMk93asThh9/YD4CfcCkontaXTcjzP80rXfwf WT5EackBPBxwe9om7H7moOuC3pImrSYERwwdb+p+oDfCh8rCdlinbSB4ndsHB0eXsHWk SlePQKN4FdyXbyDpDIuzNRWoeAewHpxiM3rsQkIk5eYzo1YlZFtZa4VvqtamnC2ePXI/ 8JSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QN6u4lUItqEbRecJZob9CnZ8D7gORmssXE47u/uPVag=; b=Tqx8ALx3SE9PO2Ht3T5zGgc1fc+nCiGKlWFEcYWyxSHlHohH1V8g+KZN9k07eVgPQF djqjFoHWCHIUhmYElE6b+kqWjw3oENdNfWyhTt9GQfDLJJsOechpWPvSw2v43KviSbvF jveqk0Uv5C28dPEfYyfIPCkAe+lWZ7CUD/e/JRgVk5QRm/wWfPIzi6NxUDq6dv+Q/dtH vYoEQOqmd/3MhabR6Mp8wi8SHhwARFcSiUVrSj88DzhuFYTxKGDXQKyKgxJv3L5k4dwX w1nGoshqezPLv45S8wsh19uDDEtqPqkBMlE4dsRVVrpHK3kgVgR3h9M1kDgd8nIUt5+E y4mw== X-Gm-Message-State: AOAM5321bm4yMQYgrbG+kervxqPz1yaH/QC+9f41LIXNyqkBq2EpF2ab aVVfpXt6HTRqO+Ub7Nt3QoLjpLL5liOWDpe0KkdHyql8 X-Google-Smtp-Source: ABdhPJxxvvCw8RUH2Z0KnOwwoDmBg/2mloHEld4N4CTprNQOmhVisEOYedaYgxiHI4bjSzRRKn6fauLuXMCvmiAnQDM= X-Received: by 2002:aca:cf81:: with SMTP id f123mr1673052oig.137.1594852804053; Wed, 15 Jul 2020 15:40:04 -0700 (PDT) MIME-Version: 1.0 References: <20200715222812.238172-1-sonnysasaka@chromium.org> In-Reply-To: <20200715222812.238172-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz Date: Wed, 15 Jul 2020 15:39:52 -0700 Message-ID: Subject: Re: [PATCH BlueZ] profile: Add exception from being claimed internally To: Sonny Sasaka Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7D929A30EA X-Rspamd-UID: 966d91 Hi Sonny, On Wed, Jul 15, 2020 at 3:32 PM Sonny Sasaka wrote: > > This adds a flag to give exception to profiles that are considered safe > to be both handled internally and externally via GATT API. Currently > this includes the battery profile. > > --- > profiles/battery/battery.c | 1 + > src/device.c | 2 +- > src/profile.h | 5 +++++ > 3 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c > index 4da4355a1..20aa47727 100644 > --- a/profiles/battery/battery.c > +++ b/profiles/battery/battery.c > @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = { > .device_remove = batt_remove, > .accept = batt_accept, > .disconnect = batt_disconnect, > + .claim_service_exception = true, > }; > > static int batt_init(void) > diff --git a/src/device.c b/src/device.c > index 0deee2707..cfa52461f 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -3818,7 +3818,7 @@ done: > profile = btd_service_get_profile(service); > > /* Claim attributes of internal profiles */ > - if (!profile->external) { > + if (!profile->external && !profile->claim_service_exception) { The external field was added exactly to allow it to be used externally. > /* Mark the service as claimed by the existing profile. */ > gatt_db_service_set_claimed(attr, true); > } > diff --git a/src/profile.h b/src/profile.h > index 4448a2a6d..25e83381b 100644 > --- a/src/profile.h > +++ b/src/profile.h > @@ -36,6 +36,11 @@ struct btd_profile { > > bool auto_connect; > bool external; > + /* Some profiles are considered safe to be handled internally and also > + * be exposed in the GATT API. This flag give such profiles exception > + * from being claimed internally. > + */ > + bool claim_service_exception; > > int (*device_probe) (struct btd_service *service); > void (*device_remove) (struct btd_service *service); > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oCfeBJuHD18nBgEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 00:47:55 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id yKYuA5uHD19UDAAAgupzMw (envelope-from ); Thu, 16 Jul 2020 00:47:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2D5E853325; Thu, 16 Jul 2020 00:47:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726778AbgGOWru (ORCPT + 1 other); Wed, 15 Jul 2020 18:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbgGOWrt (ORCPT ); Wed, 15 Jul 2020 18:47:49 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CF3DC061755 for ; Wed, 15 Jul 2020 15:47:49 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id a24so2752734pfc.10 for ; Wed, 15 Jul 2020 15:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=++vPA9shmpTlF5O/7b0gP8ujZV4/9yR96SMTiioulIU=; b=HiOTawzA8/3fr/88eg1BFPSfMZFgKgL5XmmCtVJ8n9z1YDX+qvi0PZBN21d4BZ+xPw pM5R5tAYaEhckuZz8Gt6pT5WK85bVOEVcss45MDQsM745ZelhzbVgs2mobHtK2KASKLe cCi2ESFXvsRvhxGVWQfFbIDlMFXiaZY0aD480= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=++vPA9shmpTlF5O/7b0gP8ujZV4/9yR96SMTiioulIU=; b=lbFkPu2LpiPbJaIsYIRAVzNxgncXsGYHpkVkIu7O5EYkAPVLX4zj3kF8+hR50wPIQt aOlQSypaTjWK9BSwYTPYan1jJdKbalc0AqMAP1QumzR9e8wmk7xekn0eKVWwAWMLlY1W LUrjecBWTmfgY9wh+tY3o6KhOJiZM9mouGqm+yn7Uigjb0oAxthQJWIqTJm3PJLI0/AW sDSxvLnY4kYbafOVu9uz26yt8lHLFzMt5GVhgNHLatG0rAn74bYNq/ZUmDYyxtwBGRBZ 79HliFqgiLC1BuPenzoAclE4vad4nbL20q8zgY0o+2gVtiioI+2JyTAbELnjNdTFHDLO DVNQ== X-Gm-Message-State: AOAM531cpZ5+pB/bgwr1WntVEDg+3Is8bEwdrtBA8+7kPzz4hsuhZM+E TUIfvPAWgb3TlDuExHJxRKdiCO9DMrM= X-Google-Smtp-Source: ABdhPJy80OCzPQe2FWAQ8mdEg1Zj6NK+dKGPKOFXpEafceXLm3YW5whplmMSjh2pupJ/iAgF8oi6vQ== X-Received: by 2002:a63:5220:: with SMTP id g32mr1656057pgb.78.1594853268828; Wed, 15 Jul 2020 15:47:48 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id u14sm3250471pfk.211.2020.07.15.15.47.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2020 15:47:48 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka Subject: [PATCH BlueZ v2] profile: Add exception to battery profile for external access Date: Wed, 15 Jul 2020 15:47:40 -0700 Message-Id: <20200715224740.238527-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2D5E853325 X-Rspamd-UID: 5453ec This gives exception to battery profile to be shared both internally and externally. --- profiles/battery/battery.c | 1 + src/profile.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c index 4da4355a1..c9a1af4b9 100644 --- a/profiles/battery/battery.c +++ b/profiles/battery/battery.c @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = { .device_remove = batt_remove, .accept = batt_accept, .disconnect = batt_disconnect, + .external = true, }; static int batt_init(void) diff --git a/src/profile.h b/src/profile.h index 4448a2a6d..95523e50a 100644 --- a/src/profile.h +++ b/src/profile.h @@ -35,6 +35,10 @@ struct btd_profile { const char *remote_uuid; bool auto_connect; + /* Some profiles are considered safe to be handled internally and also + * be exposed in the GATT API. This flag give such profiles exception + * from being claimed internally. + */ bool external; int (*device_probe) (struct btd_service *service); -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +HD/GfuHD18nBgEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 00:49:31 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id KA1EGPuHD19UDAAAgupzMw (envelope-from ); Thu, 16 Jul 2020 00:49:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8F46C53325; Thu, 16 Jul 2020 00:49:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726786AbgGOWt0 (ORCPT + 1 other); Wed, 15 Jul 2020 18:49:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbgGOWtZ (ORCPT ); Wed, 15 Jul 2020 18:49:25 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AE89C061755 for ; Wed, 15 Jul 2020 15:49:25 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id j11so3525509oiw.12 for ; Wed, 15 Jul 2020 15:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4udghYGtUYeaRoul7B0YgVKGSlph/H2QPmKSktA8esE=; b=ZHQfBgnoIyqczd+dSUqiH9XRQINki3vuivj2cPIrgNBXg49yYfDtSx8Bsf8G5X625/ mOptg48RQARzcQ+rkH/uxDWqdwae+2uxF2ifZ9Q3/iyD9Fmb+iR5XcBHgQATA/bPQjn1 /NTLL7bPw8se2pZ7UmNBotzg2w1+cViAYuvMw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4udghYGtUYeaRoul7B0YgVKGSlph/H2QPmKSktA8esE=; b=a+qlPV9ZasHf8smSdZyVFndm8GgkkzIhg6g2vrMQoRhCanfj+hj8eiQ4pd7fxqX7Om /6PjcWWEXyEJhwfk1bSyp9lRkY8xMAzMlH2tIEnLlYu/g+1+o8PQ5sBQweGnKBjVFCJ9 neE/T1rAlXrcV+8AWtYJQVjZceUvJ4SQwAIfFBtov+bP3hZ+FzL5Boc51A7DWdbgj8V8 p0DmCX1ApbBZERaEMv8PybO651dAmBIYThHRDioK/hlor6zQ6KmSHpqsnRYdmYtp+OKt dzGAANNUJHPAK7toTIRJ/VLLHIb8bqPc/cFWb3fNLp8aed8SDnrIH77vqWN75wG3FAGQ CHfQ== X-Gm-Message-State: AOAM532aX09nGRaOINduAWISwg2S3jjJ5uGXYsFAp2dbF3Zoam4Ntzro Y4ZdH5bUNW8GC3tPL+e6w4JavXbwZ2uftsZ33tKrDQ== X-Google-Smtp-Source: ABdhPJwcFR7XFKyRSgaTNd9FYUCmKeBGmYkbi9JVcxnn/3VbXuvYRGCZCXSEyQb/dYgjQertAM/zwyP7NQ216Wc1SYA= X-Received: by 2002:aca:4fd3:: with SMTP id d202mr1727356oib.142.1594853364963; Wed, 15 Jul 2020 15:49:24 -0700 (PDT) MIME-Version: 1.0 References: <20200715222812.238172-1-sonnysasaka@chromium.org> In-Reply-To: From: Sonny Sasaka Date: Wed, 15 Jul 2020 15:49:13 -0700 Message-ID: Subject: Re: [PATCH BlueZ] profile: Add exception from being claimed internally To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8F46C53325 X-Rspamd-UID: 53189e Hi Luiz, On Wed, Jul 15, 2020 at 3:40 PM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Wed, Jul 15, 2020 at 3:32 PM Sonny Sasaka wrote: > > > > This adds a flag to give exception to profiles that are considered safe > > to be both handled internally and externally via GATT API. Currently > > this includes the battery profile. > > > > --- > > profiles/battery/battery.c | 1 + > > src/device.c | 2 +- > > src/profile.h | 5 +++++ > > 3 files changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c > > index 4da4355a1..20aa47727 100644 > > --- a/profiles/battery/battery.c > > +++ b/profiles/battery/battery.c > > @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = { > > .device_remove = batt_remove, > > .accept = batt_accept, > > .disconnect = batt_disconnect, > > + .claim_service_exception = true, > > }; > > > > static int batt_init(void) > > diff --git a/src/device.c b/src/device.c > > index 0deee2707..cfa52461f 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -3818,7 +3818,7 @@ done: > > profile = btd_service_get_profile(service); > > > > /* Claim attributes of internal profiles */ > > - if (!profile->external) { > > + if (!profile->external && !profile->claim_service_exception) { > > The external field was added exactly to allow it to be used externally. Oh, I was misled by the field name, I thought it's to mark profiles which are not handled internally. I have sent another patch also clarifying the field with a comment. > > > /* Mark the service as claimed by the existing profile. */ > > gatt_db_service_set_claimed(attr, true); > > } > > diff --git a/src/profile.h b/src/profile.h > > index 4448a2a6d..25e83381b 100644 > > --- a/src/profile.h > > +++ b/src/profile.h > > @@ -36,6 +36,11 @@ struct btd_profile { > > > > bool auto_connect; > > bool external; > > + /* Some profiles are considered safe to be handled internally and also > > + * be exposed in the GATT API. This flag give such profiles exception > > + * from being claimed internally. > > + */ > > + bool claim_service_exception; > > > > int (*device_probe) (struct btd_service *service); > > void (*device_remove) (struct btd_service *service); > > -- > > 2.26.2 > > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eM60NsDhD18AswAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 07:12:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id sM/hNMDhD1+QigAAlScrYA (envelope-from ); Thu, 16 Jul 2020 07:12:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 16EB453683; Thu, 16 Jul 2020 07:12:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727829AbgGPFMX (ORCPT + 1 other); Thu, 16 Jul 2020 01:12:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbgGPFMT (ORCPT ); Thu, 16 Jul 2020 01:12:19 -0400 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2DA0C061755 for ; Wed, 15 Jul 2020 22:12:19 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id i18so3978122ilk.10 for ; Wed, 15 Jul 2020 22:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=46kz+Eza/6bwvKMNUgCo81wTzXHTZri/532QaxEYzzA=; b=n1kwjjjKlTqe9naWgY89IqF2JGWKl4Nxf8cbc4BuJjqhz0/aIdjEJWgEO7BeTuWQ0m jN+a2Dh8fI27J5hYiAXV+0MmUEPjsa4VWQT2fz61SvVmVnf2zu6M/Cpq3i9/kMRLFEd7 /eSM+Na+8VrUW02XpLq3/KMTJZGHldNb+2fXyZF04Tvkmh2GYaquNHDKJKw4kD64NQSS TluKXQbQX7xJvEGnwCdk8UwEBw/4MsqG0ZWXrmbf4pvrr6GQ+HpFGa6q7DeE2CqlgcpM OhQbu4uPoG4vapr09WgrdRaECrdibxZbNxpzKg04RWISCnbwMNzL1WnLp0eQ04Imhfbv EBOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=46kz+Eza/6bwvKMNUgCo81wTzXHTZri/532QaxEYzzA=; b=oWDYUlKkUs7QDWpl/DTzEsQl8fJ1/LjBYYd0bU/o80rlu2UCpAEe5Lcnodmd0Vt83K x+wZkOY9v1SFPcdFy4y6hfYs2jaDf3ixlLrNjwAbDlTZE+QOcc1iVabbSXCr4MizTom6 kZFTCqHsw7f9yvFwlZmqMIB/olvloHMQdO4ctsQEGqb1eYF9wHjF0HdgkWWj3AitLNJq TeRKqNfAGdfh5f784fdVrdcebOLBVArHB3AmQUpkLrsbNp66lcEvcyEne/Qk88KBRp47 a1X0N79hnz1Y/XEyvK75odCzSPMpAe7/5MnBBHxFR2AtcUxjAdSo23V7Vm6hZkN8dQu2 QNEw== X-Gm-Message-State: AOAM530UwyuDxABycP2TBO5aXalMSOeZJSpbg6BgDwQNT3ttuLUOnEOt eN74f2yPwWrbf+BRgixDuVnX/7a+tyqk0R7jprPCVRaA X-Google-Smtp-Source: ABdhPJyOeufne2bXodDR0ovoG8C2++5zaguX4Qziwm81ERMKZvVKEApI7CbttFtsrGauB345ogsB0A90T6RJswKAIvY= X-Received: by 2002:a92:4913:: with SMTP id w19mr2751990ila.185.1594876338875; Wed, 15 Jul 2020 22:12:18 -0700 (PDT) MIME-Version: 1.0 References: <20200713062213.3692-1-sathish.narasimman@intel.com> In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> From: Sathish Narasimman Date: Thu, 16 Jul 2020 10:42:07 +0530 Message-ID: Subject: Re: [PATCH v4 0/8] LL Privacy Support To: Bluez mailing list Cc: Sathish Narasimman , Sathish N , Chethan T N Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 3 X-Rspamd-Score: 0.59 / 15.00 / 200.00 X-Rspamd-Queue-Id: 16EB453683 X-Rspamd-UID: 4c0738 Hi Gentle reminder On Mon, Jul 13, 2020 at 11:48 AM Sathish Narasimman wrote: > > V4: patches are rebased > Added support to use set Experimental feature to enable controller > address resolution > > Marcel Holtmann (3): > Bluetooth: Translate additional address type correctly > Bluetooth: Configure controller address resolution if available > Bluetooth: Update resolving list when updating whitelist > > Sathish Narasimman (5): > Bluetooth: Translate additional address type during le_conn > Bluetooth: Let controller creates RPA during le create conn > Bluetooth: Enable/Disable address resolution during le create conn > Bluetooth: Enable RPA Timeout > Bluetooth: Enable controller RPA resolution using Experimental feature > > include/net/bluetooth/hci.h | 9 ++- > include/net/bluetooth/hci_core.h | 3 + > net/bluetooth/hci_conn.c | 7 +- > net/bluetooth/hci_core.c | 17 +++++ > net/bluetooth/hci_event.c | 21 ++++++ > net/bluetooth/hci_request.c | 120 ++++++++++++++++++++++++++----- > net/bluetooth/hci_request.h | 3 +- > net/bluetooth/mgmt.c | 54 +++++++++++++- > 8 files changed, 213 insertions(+), 21 deletions(-) > > -- > 2.17.1 > Regards Sathish N Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wPwWLHb2D19XNwEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 08:40:54 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8J3sKnb2D1877gEAlp8NpQ (envelope-from ); Thu, 16 Jul 2020 08:40:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A3831535A2; Thu, 16 Jul 2020 08:40:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728033AbgGPGkq convert rfc822-to-8bit (ORCPT + 1 other); Thu, 16 Jul 2020 02:40:46 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:37516 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727850AbgGPGkq (ORCPT ); Thu, 16 Jul 2020 02:40:46 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id B8F35CECFC; Thu, 16 Jul 2020 08:50:43 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2] Bluetooth: Fix update of connection state in `hci_encrypt_cfm` From: Marcel Holtmann In-Reply-To: <50fd2c75ce196196f879f8373555cc30bfc75154.1594834970.git.ps@pks.im> Date: Thu, 16 Jul 2020 08:40:44 +0200 Cc: Bluetooth Kernel Mailing List , Johan Hedberg , Luiz Augusto von Dentz Content-Transfer-Encoding: 8BIT Message-Id: References: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> <50fd2c75ce196196f879f8373555cc30bfc75154.1594834970.git.ps@pks.im> To: Patrick Steinhardt X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 2 X-Rspamd-Score: 0.38 / 15.00 / 200.00 X-Rspamd-Queue-Id: A3831535A2 X-Rspamd-UID: 597f8a Hi Patrick, > Starting with the upgrade to v5.8-rc3, I've noticed I wasn't able to > connect to my Bluetooth headset properly anymore. While connecting to > the device would eventually succeed, bluetoothd seemed to be confused > about the current connection state where the state was flapping hence > and forth. Bisecting this issue led to commit 3ca44c16b0dc (Bluetooth: > Consolidate encryption handling in hci_encrypt_cfm, 2020-05-19), which > refactored `hci_encrypt_cfm` to also handle updating the connection > state. > > The commit in question changed the code to call `hci_connect_cfm` inside > `hci_encrypt_cfm` and to change the connection state. But with the > conversion, we now only update the connection state if a status was set > already. In fact, the reverse should be true: the status should be > updated if no status is yet set. So let's fix the isuse by reversing the > condition. > > Fixes: 3ca44c16b0dc ("Bluetooth: Consolidate encryption handling in hci_encrypt_cfm") > Signed-off-by: Patrick Steinhardt > --- > include/net/bluetooth/hci_core.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2FyhLj3+D19yWQEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 09:14:05 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id EBiwLD3+D1+3gQEAgupzMw (envelope-from ); Thu, 16 Jul 2020 09:14:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 72F3051883; Thu, 16 Jul 2020 09:13:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728238AbgGPHN4 convert rfc822-to-8bit (ORCPT + 1 other); Thu, 16 Jul 2020 03:13:56 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:50343 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbgGPHN4 (ORCPT ); Thu, 16 Jul 2020 03:13:56 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 69384CECFD; Thu, 16 Jul 2020 09:23:52 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v4 8/8] Bluetooth: Enable controller RPA resolution using Experimental feature From: Marcel Holtmann In-Reply-To: <20200713062213.3692-9-sathish.narasimman@intel.com> Date: Thu, 16 Jul 2020 09:13:53 +0200 Cc: linux-bluetooth@vger.kernel.org, Sathish Narasimman Content-Transfer-Encoding: 8BIT Message-Id: <5CD116F7-EFB3-47A2-B8D5-0012657F10F9@holtmann.org> References: <20200713062213.3692-1-sathish.narasimman@intel.com> <20200713062213.3692-9-sathish.narasimman@intel.com> To: Sathish Narasimman X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: 72F3051883 X-Rspamd-UID: 54faf9 Hi Sathish, > This patch adds support to enable the use of RPA Address resolution > using expermental feature mgmt command. everything looks fine, except for this patch. I just prefer to only apply the others if we can apply this one as well. > Signed-off-by: Sathish Narasimman > --- > include/net/bluetooth/hci.h | 1 + > net/bluetooth/hci_event.c | 3 ++- > net/bluetooth/hci_request.c | 6 +++-- > net/bluetooth/mgmt.c | 52 +++++++++++++++++++++++++++++++++++++ > 4 files changed, 59 insertions(+), 3 deletions(-) > > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h > index 4ff2fc4498f3..cb284365b4c1 100644 > --- a/include/net/bluetooth/hci.h > +++ b/include/net/bluetooth/hci.h > @@ -307,6 +307,7 @@ enum { > HCI_FORCE_BREDR_SMP, > HCI_FORCE_STATIC_ADDR, > HCI_LL_RPA_RESOLUTION, > + HCI_ENABLE_RPA_RESOLUTION, I would call this ENABLE_LL_PRIVAY. It put its more in line with use_ll_privacy and clearly distinct from the LL_RPA_RESOLUTION with is a HCI operational mode. > HCI_CMD_PENDING, > HCI_FORCE_NO_MITM, > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 684c68cb5c76..c8a5e1e4dba2 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -5222,7 +5222,8 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, > le16_to_cpu(ev->latency), > le16_to_cpu(ev->supervision_timeout)); > > - if (use_ll_privacy(hdev) && > + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && > + use_ll_privacy(hdev) && > hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) I would leave use_ll_privacy at the top and add the new one after it. > hci_req_disable_address_resolution(hdev); > } > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > index c3193f7f9ff0..cb44b83539e6 100644 > --- a/net/bluetooth/hci_request.c > +++ b/net/bluetooth/hci_request.c > @@ -677,7 +677,8 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) > } > > /* Disable address resolution */ > - if (use_ll_privacy(hdev) && > + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && > + use_ll_privacy(hdev) && Same here. > hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { > __u8 enable = 0x00; > hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); > @@ -870,7 +871,8 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, > return; > } > > - if (use_ll_privacy(hdev) && addr_resolv) { > + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && > + use_ll_privacy(hdev) && addr_resolv) { And here. > u8 enable = 0x01; > hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); > } > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > index c292d5de4dc3..fbe02ab5fa05 100644 > --- a/net/bluetooth/mgmt.c > +++ b/net/bluetooth/mgmt.c > @@ -3759,6 +3759,12 @@ static const u8 simult_central_periph_uuid[16] = { > 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > }; > > +/* 15c0a148-c273-11ea-b3de-0242ac130004 */ > +static const u8 rpa_resolution_uuid[16] = { > + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, > + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, > +}; > + > static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > void *data, u16 data_len) > { > @@ -3795,6 +3801,17 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > idx++; > } > > + if (hdev) { If use_ll_privacy is not available, then we should also not expose this experimental feature. > + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION)) > + flags = BIT(0); > + else > + flags = 0; > + And since we only support the RPA resolution for central mode at the moment, we really now need to disable advertising support. So this one needs to indicate the the supported settings will change when enabled. > + memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); > + rp->features[idx].flags = cpu_to_le32(flags); > + idx++; > + } > + > rp->feature_count = cpu_to_le16(idx); > > /* After reading the experimental features information, enable > @@ -3895,6 +3912,41 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + if (!memcmp(cp->uuid, rpa_resolution_uuid, 16)) { > + bool val; > + int err; > + > + /* Parameters are limited to a single octet */ > + if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) > + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, > + MGMT_OP_SET_EXP_FEATURE, > + MGMT_STATUS_INVALID_PARAMS); > + > + /* Only boolean on/off is supported */ > + if (cp->param[0] != 0x00 && cp->param[0] != 0x01) > + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, > + MGMT_OP_SET_EXP_FEATURE, > + MGMT_STATUS_INVALID_PARAMS); > + > + val = !!cp->param[0]; > + > + if (val) > + hci_dev_set_flag(hdev, HCI_ENABLE_RPA_RESOLUTION); > + else > + hci_dev_clear_flag(hdev, HCI_ENABLE_RPA_RESOLUTION); > + > + memcpy(rp.uuid, rpa_resolution_uuid, 16); > + rp.flags = cpu_to_le32(val ? BIT(0) : 0); > + > + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); > + > + err = mgmt_cmd_complete(sk, MGMT_INDEX_NONE, > + MGMT_OP_SET_EXP_FEATURE, 0, > + &rp, sizeof(rp)); The exp_feature_changed event is missing. In addition you need to handle the ZERO_KEY branch which means it will reset all experimental features back to default. > + > + return err; > + } > + > return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, > MGMT_OP_SET_EXP_FEATURE, > MGMT_STATUS_NOT_SUPPORTED); Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aOrQLLQBEF8KewEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 09:28:52 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id sCe8KrQBEF9ZBQEAlScrYA (envelope-from ); Thu, 16 Jul 2020 09:28:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8023752C29; Thu, 16 Jul 2020 09:28:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728262AbgGPH2q (ORCPT + 1 other); Thu, 16 Jul 2020 03:28:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727768AbgGPH2p (ORCPT ); Thu, 16 Jul 2020 03:28:45 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 970F6C061755 for ; Thu, 16 Jul 2020 00:28:45 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id o2so10266384wmh.2 for ; Thu, 16 Jul 2020 00:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=VwEVcaUw3v/2qY3aPbUo4gTJ+U9r5Oqzgbzm9DK6XoU=; b=GPs6wigMsGSnzi70Vn3gAsuNeVbDKUfYx7IGCVSGY0VSxq0n9OT1tDkFlFOzAbYtD5 2uQ9ovIGXgS8s/4anKp6q6KZWobcXURAWtwNhI9lJHX+C6J4UUGKW82SHKrCcp3xsQQm QebuflIob+5ZAEt+htIpSwAOPXzQKf/MfgDWa2cQkl23cEuxIw5iVWfmIUuJgEJg6616 tAopYNmPI6ZGO+7P8ll3APzYeIP9SXy/pjuV0uizoRH/JaN967nmDej5P7q3Fu6XNb7b 3egp7nlwpDk7Rp9ZTTLedOlo707iEw3vW+pXHvz0KOTiNsU5+Xe7H1tm6LVUIUnzEQqu OzKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=VwEVcaUw3v/2qY3aPbUo4gTJ+U9r5Oqzgbzm9DK6XoU=; b=j/XjmZ642h/NdEfctzMK228CS1oz9gV68P+Ur1KatIm7yz6LVcV6OAu28LjrMdwKtW s5Ltm5aVP3TnXoGqFx01YXIKlE1Bf7xTDbJZ2UWc/dRQNjg8IMEWQwGInXGSa8m1vSBt A6j2SdonPJO46wGi0w7GgdtjxXXP++KvRC+z1FqPYThfk1dSf9EfowqFX1uF+lk92Dv/ ZhsBOMScLnhTe0COLynY14A73oYD9MYVepsYzHzlmxeCN2oPCEr6U/uEggF4hHPMqzTQ WgHJHInoFEpQeOkh6ZAeqk31piHPZsHvDh3xeLtwqGEhKjSHCU3mVriAXH/KJtsTia7Y p0IQ== X-Gm-Message-State: AOAM532NpP1Tg9mOpiEh9ywJogkwB8ilIzrW3PZbpMbYA7ZkGUDIj/S1 5hYfAf8pXx6VoWm5cpp8H0D+9BQcPywbkArJP8jkvw== X-Google-Smtp-Source: ABdhPJwlDSk7UZViDeHPn6wRtL99mpSy0b7jXQ+6FkSkIKX4Lhz7vj0IlYOd0EHP4NdlsXM9r5SV4v+I64JNWXlUAcc= X-Received: by 2002:a1c:b608:: with SMTP id g8mr3056156wmf.55.1594884523988; Thu, 16 Jul 2020 00:28:43 -0700 (PDT) MIME-Version: 1.0 References: <20200627235318.Bluez.v2.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> In-Reply-To: From: Archie Pusaka Date: Thu, 16 Jul 2020 15:28:32 +0800 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] device: add device_remove_bonding function To: Luiz Augusto von Dentz Cc: linux-bluetooth , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8023752C29 X-Rspamd-UID: 7aa947 Hi Luiz, I think spec writers' idea is to have a list of previously connected devices which is ordered by most recently connected. The size of this list may be limited to a number, meaning that the least recently connected device will be removed from the list. The devices in this list may or may not be bonded. This list is accessible to users, so they can easily reconnect to the most recently used device. I don't suppose we currently have this list, so I'm happy with just removing the virtually unplugged device. Thanks, Archie On Thu, 16 Jul 2020 at 01:31, Luiz Augusto von Dentz wrote: > > Hi Archie, > > On Wed, Jul 15, 2020 at 7:15 AM Archie Pusaka wrote: > > > > Hi Luiz, > > > > If we mark it as temporary, then the device will immediately get > > deleted upon disconnection. > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/adapter.c#n= 6875 > > This is the same situation as directly calling device_remove. > > > > May I know the reason why we want to put the device as temporary? > > > > If we currently don't have a way to keep a "previously connected but > > no longer bonded" device, then removing the device perhaps is the next > > best option. It still makes the user scan for the virtually > > disconnected device though. > > We keep a cache of previously known devices, but we only display them > once they are actually found otherwise it may grow too big which is > inconvenient, I wonder where this concept of "previously connected but > no longer bonded" comes from though, we had the temporary to map > devices that would not be persisted on the storage which I guess this > is what it is about, that said we could perhaps have a timeout before > setting it as temporary but we might want to integrate with the logic > of detecting devices disappearing. > > > Thanks, > > Archie > > > > On Wed, 15 Jul 2020 at 01:10, Luiz Augusto von Dentz > > wrote: > > > > > > Hi Archie, > > > > > > On Tue, Jul 7, 2020 at 9:30 PM Archie Pusaka wro= te: > > > > > > > > Hi Luiz, > > > > > > > > As far as the spec is concerned, we can also remove the device by > > > > calling device_remove. However, I suppose it would be confusing for > > > > end users if they can no longer find their HID device on the device > > > > list just because the device previously sent a virtual cable > > > > disconnection. > > > > The HID 1.0 spec part 6.4.2 also gives an example of a possible > > > > scenario when a virtually cabled device is removed: "Unplugged devi= ces > > > > shall be marked as known and put into a =E2=80=9Cmost recently used= list=E2=80=9D of > > > > known devices to facilitate future re-connecting". > > > > > > Then perhaps we shall have it marked as temporary as well, that said > > > we do want to introduce disappearing logic so temporary devices are > > > not left dangling for too long. > > > > > > > Thanks, > > > > Archie > > > > > > > > > > > > On Wed, 8 Jul 2020 at 02:03, Luiz Augusto von Dentz > > > > wrote: > > > > > > > > > > Hi Archie, > > > > > > > > > > On Sat, Jun 27, 2020 at 8:54 AM Archie Pusaka wrote: > > > > > > > > > > > > From: Archie Pusaka > > > > > > > > > > > > This patch splits the "bonding removal" function in device.c, > > > > > > because we need to remove bonding information when receiving > > > > > > "virtual cable unplug" in HID profile. > > > > > > > > > > > > Reviewed-by: Alain Michaud > > > > > > --- > > > > > > > > > > > > Changes in v2: None > > > > > > > > > > > > src/device.c | 25 +++++++++++++++---------- > > > > > > src/device.h | 1 + > > > > > > 2 files changed, 16 insertions(+), 10 deletions(-) > > > > > > > > > > > > diff --git a/src/device.c b/src/device.c > > > > > > index 7b0eb256e..9fb0e018c 100644 > > > > > > --- a/src/device.c > > > > > > +++ b/src/device.c > > > > > > @@ -4162,6 +4162,17 @@ static void delete_folder_tree(const cha= r *dirname) > > > > > > rmdir(dirname); > > > > > > } > > > > > > > > > > > > +void device_remove_bonding(struct btd_device *device, uint8_t = bdaddr_type) > > > > > > +{ > > > > > > + if (bdaddr_type =3D=3D BDADDR_BREDR) > > > > > > + device->bredr_state.bonded =3D false; > > > > > > + else > > > > > > + device->le_state.bonded =3D false; > > > > > > + > > > > > > + btd_adapter_remove_bonding(device->adapter, &device->bd= addr, > > > > > > + bdaddr_= type); > > > > > > +} > > > > > > + > > > > > > static void device_remove_stored(struct btd_device *device) > > > > > > { > > > > > > char device_addr[18]; > > > > > > @@ -4170,17 +4181,11 @@ static void device_remove_stored(struct= btd_device *device) > > > > > > char *data; > > > > > > gsize length =3D 0; > > > > > > > > > > > > - if (device->bredr_state.bonded) { > > > > > > - device->bredr_state.bonded =3D false; > > > > > > - btd_adapter_remove_bonding(device->adapter, &de= vice->bdaddr, > > > > > > - = BDADDR_BREDR); > > > > > > - } > > > > > > + if (device->bredr_state.bonded) > > > > > > + device_remove_bonding(device, BDADDR_BREDR); > > > > > > > > > > > > - if (device->le_state.bonded) { > > > > > > - device->le_state.bonded =3D false; > > > > > > - btd_adapter_remove_bonding(device->adapter, &de= vice->bdaddr, > > > > > > - device-= >bdaddr_type); > > > > > > - } > > > > > > + if (device->le_state.bonded) > > > > > > + device_remove_bonding(device, device->bdaddr_ty= pe); > > > > > > > > > > > > device->bredr_state.paired =3D false; > > > > > > device->le_state.paired =3D false; > > > > > > diff --git a/src/device.h b/src/device.h > > > > > > index 06b100499..907c7c5c4 100644 > > > > > > --- a/src/device.h > > > > > > +++ b/src/device.h > > > > > > @@ -49,6 +49,7 @@ uint16_t btd_device_get_vendor(struct btd_dev= ice *device); > > > > > > uint16_t btd_device_get_vendor_src(struct btd_device *device); > > > > > > uint16_t btd_device_get_product(struct btd_device *device); > > > > > > uint16_t btd_device_get_version(struct btd_device *device); > > > > > > +void device_remove_bonding(struct btd_device *device, uint8_t = bdaddr_type); > > > > > > void device_remove(struct btd_device *device, gboolean remove_= stored); > > > > > > > > > > Is there any particular reason why device_remove is not enough he= re? I > > > > > don't see any reason to leave the device object around after remo= ving > > > > > its bonding. > > > > > > > > > > > int device_address_cmp(gconstpointer a, gconstpointer b); > > > > > > int device_bdaddr_cmp(gconstpointer a, gconstpointer b); > > > > > > -- > > > > > > 2.27.0.212.ge8ba1cc988-goog > > > > > > > > > > > > > > > > > > > > > -- > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +NvrCC8PEF/n6QEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 10:26:23 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id eFZrBy8PEF841gAA0J78UA (envelope-from ); Thu, 16 Jul 2020 10:26:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 134FEA315E; Thu, 16 Jul 2020 10:26:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727025AbgGPI0K (ORCPT + 1 other); Thu, 16 Jul 2020 04:26:10 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:20887 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725965AbgGPI0J (ORCPT ); Thu, 16 Jul 2020 04:26:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594887964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=YRVg8J97Tt4EXW7W4Mn1ea2Qgve70ebQUiFqsfSVAXw=; b=BdJ3k4L0dogBLwcwZKChmmXeArQkBuHNwI6qVt+RM8p2ikrzBPOYAWbT5jeOh8iKW6KDv5 hotAVv0NGG3pOlTqJYy+IDTc+VaUPwUasaLRs8ZHx1k2RGiBieVhYTS1k8S/+QUGQcQla7 Hq1QhUZrz6vb/G7OQetFl44UhPwXtgo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-LSO3zknVNfa2ufaThKGhDg-1; Thu, 16 Jul 2020 04:25:59 -0400 X-MC-Unique: LSO3zknVNfa2ufaThKGhDg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFF10100AA23; Thu, 16 Jul 2020 08:25:57 +0000 (UTC) Received: from starship (unknown [10.35.206.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FB5E710A0; Thu, 16 Jul 2020 08:25:55 +0000 (UTC) Message-ID: <3635193ecd8c6034731387404825e998df2fd788.camel@redhat.com> Subject: Commit 'Bluetooth: Consolidate encryption handling in hci_encrypt_cfm' broke my JBL TUNE500BT headphones From: Maxim Levitsky To: linux-kernel@vger.kernel.org Cc: luiz.von.dentz@intel.com, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Date: Thu, 16 Jul 2020 11:25:54 +0300 Content-Type: multipart/mixed; boundary="=-wcGsDl5UGiQ0QHk64jS9" User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.98 / 15.00 / 200.00 X-Rspamd-Queue-Id: 134FEA315E X-Rspamd-UID: b8b814 --=-wcGsDl5UGiQ0QHk64jS9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Hi, Few days ago I bisected a recent regression in the 5.8 kernel: git bisect start # good: [3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162] Linux 5.7 git bisect good 3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162 # bad: [dcde237b9b0eb1d19306e6f48c0a4e058907619f] Merge tag 'perf-tools-fixes-2020-07-07' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux git bisect bad dcde237b9b0eb1d19306e6f48c0a4e058907619f # bad: [a0a4d17e02a80a74a63c7cbb7bc8cea2f0b7d8b1] Merge branch 'pcmcia-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux git bisect bad a0a4d17e02a80a74a63c7cbb7bc8cea2f0b7d8b1 # good: [09587a09ada2ed7c39aedfa2681152b5ac5641ee] arm64: mm: use ARCH_HAS_DEBUG_WX instead of arch defined git bisect good 09587a09ada2ed7c39aedfa2681152b5ac5641ee # good: [3248044ecf9f91900be5678919966715f1fb8834] Merge tag 'wireless-drivers-next-2020-05-25' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next git bisect good 3248044ecf9f91900be5678919966715f1fb8834 # bad: [cb8e59cc87201af93dfbb6c3dccc8fcad72a09c2] Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next git bisect bad cb8e59cc87201af93dfbb6c3dccc8fcad72a09c2 # bad: [b8215dce7dfd817ca38807f55165bf502146cd68] selftests/bpf, flow_dissector: Close TAP device FD after the test git bisect bad b8215dce7dfd817ca38807f55165bf502146cd68 # good: [b8ded9de8db34dd209a3dece94cf54fc414e78f7] net/smc: pre-fetch send buffer outside of send_lock git bisect good b8ded9de8db34dd209a3dece94cf54fc414e78f7 # good: [1079a34c56c535c3e27df8def0d3c5069d2de129] Merge tag 'mac80211-next-for-davem-2020-05-31' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next git bisect good 1079a34c56c535c3e27df8def0d3c5069d2de129 # bad: [f395b69f40f580491ef56f2395a98e3189baa53c] dpaa2-eth: Add PFC support through DCB ops git bisect bad f395b69f40f580491ef56f2395a98e3189baa53c # bad: [a74d19ba7c41b6c1e424ef4fb7d4600f43ff75e5] net: fec: disable correct clk in the err path of fec_enet_clk_enable git bisect bad a74d19ba7c41b6c1e424ef4fb7d4600f43ff75e5 # bad: [dafe2078a75af1abe4780313ef8dd8491ba8598f] ipv4: nexthop: Fix deadcode issue by performing a proper NULL check git bisect bad dafe2078a75af1abe4780313ef8dd8491ba8598f # bad: [feac90d756c03b03b83fabe83571bd88ecc96b78] Bluetooth: hci_qca: Fix suspend/resume functionality failure git bisect bad feac90d756c03b03b83fabe83571bd88ecc96b78 # good: [a228f7a410290d836f3a9f9b1ed5aef1aab25cc7] Bluetooth: hci_qca: Enable WBS support for wcn3991 git bisect good a228f7a410290d836f3a9f9b1ed5aef1aab25cc7 # bad: [755dfcbca83710fa967d0efa7c5bb601f871a747] Bluetooth: Fix assuming EIR flags can result in SSP authentication git bisect bad 755dfcbca83710fa967d0efa7c5bb601f871a747 # bad: [3ca44c16b0dcc764b641ee4ac226909f5c421aa3] Bluetooth: Consolidate encryption handling in hci_encrypt_cfm git bisect bad 3ca44c16b0dcc764b641ee4ac226909f5c421aa3 # first bad commit: [3ca44c16b0dcc764b641ee4ac226909f5c421aa3] Bluetooth: Consolidate encryption handling in hci_encrypt_cfm The sympthoms are that I am unable to pair the headphones, and even if I use an older kernel to pair them, and then switch to the new kernel, the connection is established only sometimes. Without this commit, I can pair the headphones 100% of the time. I am not familiar with bluetooth debugging but I am willing to provide any logs, do tests and try patches. I am running fedora 32 on the affected system which has built-in intel wireless/bluetooth card, PCI (wifi) part: 47:00.0 Network controller: Intel Corporation Wi-Fi 6 AX200 (rev 1a) USB (bluetooth) parrt: Bus 011 Device 004: ID 8087:0029 Intel Corp. My .config attached (custom built kernel) Best regards, Maxim Levitsky --=-wcGsDl5UGiQ0QHk64jS9 Content-Type: application/gzip; name=".config.gz" Content-Disposition: attachment; filename=".config.gz" Content-Transfer-Encoding: base64 H4sICIPaDV8AAy5jb25maWcAlDxdc9u2su/9FZr0JZ25yZEcx83pHT9AJCgiIgkWAGXJLxzVllNP /ZEj2z3Jv7+7AEgCIOjm9qGxdvG52G8s+PNPP8/Iy/Pj/f759mp/d/d99uXwcDjunw/Xs5vbu8P/ zlI+q7ia0ZSp99C4uH14+favb5/OZh/ff3o/f3e8Op2tD8eHw90seXy4uf3yAp1vHx9++vmnhFcZ W7VJ0m6okIxXraJbdf7my9XV7O0qSX6ZLebvF+8Xs5P5yXz+cf7r7K2AafP9s0W8W/zyxhmFyRZ6 nX/vQKth5PPFfL6YLzpMkfaIkw+nc/1fP1BBqlWPnjvjJ6RqC1athxkcYCsVUSzxcDmRLZFlu+KK RxGsgq50QDHxe3vBhTPDsmFFqlhJW0WWBW0lF2rAqlxQksIwGYf/QROJXYG0P89W+pjuZk+H55ev A7FZxVRLq01LBJCBlUydfziB5t3aeFkzmEZRqWa3T7OHx2ccoacbT0jRkebNm6Gfi2hJo3iks95K K0mhsKsF5mRD2zUVFS3a1SWrh725mCVgTuKo4rIkccz2cqoHn0KcDgh/Tf1G3QW5ewwb4LJew28v X+/NX0efRuib0ow0hdJH7FC4A+dcqoqU9PzN24fHh8MgOfKCOGSXO7lhdTIC4L+JKgZ4zSXbtuXv DW1oHDrqckFUkrdBj0RwKduSllzsWqIUSXKX4I2kBVtGtksa0DjBQRIB42sETk0KZ+4AqmUExG32 9PLH0/en58P9ICMrWlHBEi2NteBLZ7EuSub8Io6hWUYTxXBBWdaWRiqDdjWtUlZpkY8PUrKVAI0C ghZFs+ozzuGicyJSQEk40VZQCRP4miXlJWFVDNbmjAok3m48WSlZfJEWER1W43hZNhN7I0oAm8BR gN5QXMRb4R7ERtOgLXka6MmMi4SmVgUCJR2OrYmQdJqyKV02q0xqLjs8XM8ebwJOGEwBT9aSNzCR 4d2UO9NoZnObaMH7Huu8IQVLiaJtQaRqk11SRHhKa/nNiHE7tB6Pbmil5KvIdik4SROY6PVmJRw7 ST830XYll21T45I7WVG394fjU0xcwOqtW15RkAdnqIq3+SXak1KzaC/PAKxhDp6yJKriTD+WFjQi 8waZNS594B90G1olSLI2fOCYMx9nmGZ63siUOVvlyIn6eITHNCOSDKPVgtKyVjBqFdtHh97woqkU ETt30RbpdtMnkNTNv9T+6a/ZM8w728Manp73z0+z/dXV48vD8+3Dl+FMNkwAn9VNS5KEwxSefESQ ePLuGlBMND8OTWK0QZ0rkxzEkGw6VdaPYRAqp6IkBe5KykbEqLGUKerZBBrgfA4ThZh288FxfkCv otMlfRCId0F2wUAasY3AGPdJNJyCZD6f2EP/gVPoORNIzCQvOi2uT1EkzUxGhAgOvQXcsDz40dIt yIqzZOm10H0CENJEd7WiPEI1aWQeIGNRDMLqYCoKZyjpKlkWzNUUiMtIxRt1fnY6BrYFJdn54szH SGXELJiCJ0uklUt9s1gUW73aVru55TJ6Ij5FfW9zyaoThwZsbf44vw8hms08CVjnMCdIfNQNxvEz 8ABYps4Xn1w4HnpJti7+ZBB7VimIFEhGwzE+eDLVVNK6+1qGtNruGEhe/Xm4frk7HGc3h/3zy/Hw ZLSDdZcgfClrTb8osSK9PXsmm7qGEEO2VVOSdkkgGEo85aFbXZBKAVLp1TVVSWDGYtlmRSPzUaAD e16cfApG6OcJsVPz+vDeq6UV0slxdJKV4E3t6ISarGirJZw6fgb4m8kq+Bl4wga2hn8chVSs7Qzh jO2FYIouSbIeYfQhDtCMMNFGMUkG1ptU6QVLlecEg752OkQ40s5Us1SOphepGyFZYAa649IliIXn zYrCUTrwGjxwV8eioOBEFjMaIaUbltARGFr76rdbMhXZCLisM8+MdyOD3xbZvATp6NsQ5WwW4x3w BsF+DLAGmdu1GWjmXAAGO+5v2KXwALh593dFlfcbzihZ1xw4Gx0HcG8dalhrCRFyx0WDvdxJOP+U gqUEpzh6zAJNm8+NQG7teArX2cffpITRjP/pRIMiDcJsAATRNUD8oBoAbiyt8Tz4feruZMm5as3f MV5NWl4D1dklRX9McwAHH6HSXDMcetBMwh+xww9iTKM/Wbo480JYaAPWNKG1jia0YQn61Ims17Aa MNe4HIfKtcOgoUUOZipBJzFkGGdyECgMAduRZ28OfATOclABxSim7v1Pz5iEv9uqZM7SG0fH0SKD Q3GZcXrLBOIn383OGvCkg58gCc7wNfc2x1YVKTKHK/UGXIAORFyAzD1lS5jDZeCoNcK3ROmGSdrR TwbHqa0MnoS2E1naXviqfUmEYO45rXGQXSnHkNY7ngG6BN8OyIAMbNyXsIUmI8os5gI8AamztpBl zBcGzDh30dvczuxhs8862vTGBBAs9oLsJARkE6Njm24Y19tzaBXMjEZ8oBgsr0oCRoJw23P9tabW 0GisBWPRNI1qOCOKsJI2DHXrZDE/7Zwgm1GuD8ebx+P9/uHqMKN/Hx7ADyfg5yToiUNoNrjX/ojB OjUStt9uSp2RiDpOPzhjH2OVZrrO83A2IotmaWYOYNYJ0VrBD5oxLUvg1MU6Sk9ZkFiGDAf1DEzB 480Izi3ATbJ84XcCLHoL6P+3AlQTLycXMTTEXBREIGm8ad5kGXi32jXrk0ATozY6OIC2QjFSxC2A oqW2/Ji2ZxlLgrwZuCwZKzzloS2AttFeSO9nzbvGZ6dLN7Oz/XQGIO+3a3ulEo3OzAE5E566OgYi oxqCI23u1Pmbw93N2em7b5/O3p2d9hYafX1wAjoP2eERBc6lCYlGOC/TpoW2RKdcVBgCmWTP+cmn 1xqQLV4ERBt03NcNNDGO1wyGG6K/PvkmSes5ox3CkwUH2CvPVh+VJ0Zmcoj0rfVuszQZDwKKlC0F pt5S33fqNRsyF06zjeEIuGt4vUO1+xFpAXwFy2rrFfBYmI0G79g4uCbZAjGs6zOCG9ihtD6EoQQm B/PGvWHy2ml5iTYz62FLKiqTLwWfQbJlES5ZNhITz1NobWM06UgxDgUuOdABzu+D4yzqtLruPBXg WR0LS9eSHopRK8t6qmujs+/OmWfgB1Eiil2CKWHXV0h34OtjWj3fSZD/Isi61ysTTxeglMFV6DMW NkSVBE8Y5QuPkSYmJa0tTX18vDo8PT0eZ8/fv5qETyzu7mgT00/uBnHTGSWqEdREJz5qe0Jq5uUh EFrWOqMdVZArXqQZk3kUKagCr4xV8a44tOF+cI9FMdmGbhXwDPKhdRQnW6KMFm1Ry1jWBBuQchhl iBSHpAuXWVsu2UTvnjHsbRFE0kUzjq54CSyZQQDUqw1HMHcgTOA3QkCxaqib0QISE8yMuuvpYOPQ c9xE1qzSKf84dWjMH1uDmxAsw9wq1A1mwIE3C+W71fUmHy85TNVGWnQppH5Bn4F2OUevRy8gumiS iOoVdLn+FIfXMp7bL9FrjF+bgj3kMX+41+Oug92xmqjAvFolbfJoZ26TYjGNUzLQRElZb5N8Fdh1 vAnZ+BCwgKxsSi05GeicYudkQLGB5hWIN0vp8J3NYmMcSwuaeFyGIwFrG+mJBcwWD8IT65bvVr6z P2qRgCNKmriD1bW5zAnfshiT5jU1HOaKEcIoRLtoWYVyaJnq+HNQT+C2mZvAiWPfgnqM3fRoiyfR 4QSbt6QrdGDiSLzn/LgYITtfdjgci3EgRl/IUoUqpAy4Q9c3tFY3u1zII0BBBce4ELMWS8HXtDIZ EbybDXjJV38WhKnhgq5IsptUtKW+boyzS4c37BIA8bpU5mAzIvPaO+XRxZMb89w/Ptw+Px69yyYn uLIWQJC6OL93lKTTQpsAfkEDdrQO+MRc7jYWZyNvnMoaXINQdru7VMuoXkhgDq8u8H9Upz4GI/Rp HaEqOBcgwuYWemDfDjh5GEOLQHoHBByG0WYZSWIZLn06ri6xdpuNzvCjdm8mhkiZgMNtV0t0xWQ4 GjH1S1KxxPWx4azA1oKIJWJXe0orQIGt0H76ctcJXkyoG+38e2MgbGLF4BySpGajbvoqgPoapUMB QaXV972UG6dSu1BmxSTiGPfoIQb28Fprd44HViOE+RmLCgpGNEqnzNdo/EyF2xAsFijnReemYJ1A Q8/n364P++u5859/zDUuc6wg3PPEDDREYlxiokY09Zj5USOhd1B2Cx8amu6hTsNaDLy2ugD92VfF lUoIj6vhN3rTTEG4JCZWB1FiQCBwQyT46G1TaYMdJqBM1sFfkCxJ4FY3pV+qNTikw9EoUzPTruku 5qLSzE1oZgyEoln6kJJt3fVJmmDc686bX7aL+TyqugF18nES9cHv5Q03d2zvJVYz9kdgDFYusAzD yUHSLU2CnxisxmJYg6wbscI0jFeLYFAynscXROZt2rjhjWn/2YP1IRloGHCv598WfsElBN+YALJC OcQu+tAx+49p1FgRRTcuhPirCsY98YbNgb+LZhXeLA987zSIH4mJXP+xmc17bFIZq3o0chraIm+n YZMtr4q46Q9bTpSXJGWqcxawV7dQxkDP37w8/XH1eDy8/8/L7fGvp/P56cfDb/NfF//+7Y/Z7OvV 7aHdXz21j38fjsfb68P57fVvi/nJyW+L039f/U/34+Ov+9OZU//Zzcg3VAiWxhYFOpNlu7ZI1TjB rdMlBdiPGu+UB7gLGlyEVyLyEW+TNG0Dg6dxxgh0msGe8T+1EfDXxpEgjJ5M8t/YJB2OsFB72WFk XUBYWqP3o2wwFmmFSRed5omU/7ntVF57TYyj9vjfw3EGztP+y+H+8PCsaYMmdPb4FWuunYT4KGFk qh0cxWYyRSOAc3M8JGktSq5Zra8HonVUZi6M14oC78ndG5thIZ4mddYnK1JjhRlmDWLKoAT1kpos sbLVyQ6qoNTVSBZiUzODm1rqm1mNi89xQdZUB/neYD3UVlQvBi3kYVeJ280bIrgPwJWkG7wSTXuU u0ysz+7IPkENvcFg2FQvJyxkdKE60MOqnsWJu4fgwrSD+KEfQJPC4euL342jj/WwLGF0uL9yd4MB /sq6VLEyXy8jiMzsCMToV6chtTWB4+B83YTpRRCbXNlLQuxSu3ljDbE3Cmbx6BejT9mn3J30CLTV FF5FfR0zVp2IVgUep15p7UYxpq1lU38G9B4zOY6Z3DaCbnrdG0vuYhswzF3l672HIEkAWBIF3ugu hDZKgWDdB8tTrNpZUpkWU2vcwNp4MGZGqgCiSBpAUl9ZIkjnXgQF/pIyQA2JlkSf3CSapSMK9cgA 7rsS8eHIaiXoyhYzBxQyJZBTdEkaqThoAAmWUXtog+oazJghDWr+pgatn4ZLfw0XKAGz8ATZjYcc CH8rAoZ8igLGFk4gGQ+T14arlzFX2/Sk6ai5JUdJVc5jus3w4ioiioKmDSpMvHu8IBBsTfpRJqzM WCxIdUNOb60lCS94jPTUlE3B/WqMSPOh5SqncrQjjYGjomRa9HWbqYT40IKy6nMo9xqOt0mGQ3ps WqvMiPRI2iF8LfhEJhzvX3gNUsCmlYD521VBJqLtE4yDU5F51wBdCfQsOx7+83J4uPo+e7ra33mJ qE4tOD5vpyhWfIOPSzD9qibQYflrj0Q9EiZeNaIro8DeThXTZJ513AlpLIFlfrwLlmnokrYf78Kr lMLC4nfx0R6As08vNtH4ItZHx6GNYsUEef0yr2iLjhoT+H7rE/hun5PnO2xqoom7h57hbkKGm10f b/825SWRZEOtzc5k5rZO9GUGTjl1R2YtnM/JIQb+9Yo79NhIwIpftP7FjDtCmVqeppUER3nD1C4c BZxKmoIDZO4NBKvib9H0hKfmYqn0NbUmzNOf++Ph2ok83BL6iBT39GbXdwdfpn1T3UH0iRUQ4Hll rC6ypFUTCm6PVDS+L69RdwEXT9lYZHddN/VewO6oj1//MUrTpFi+PHWA2VuwAbPD89X7X5ysO1hw k9N1PHCAlaX5MUANBC+rFnOvrBibJ9XyZA67/b1hIpb3xpqNZeOWx5oiDrz38BPF1YgfsZQpXrM/ sTmz8duH/fH7jN6/3O2DqJWRDydT2fytW5ZgczJj0KgJXtI0mGnGJBIwjHsVZF8+9j2H5Y+WqFee 3R7v/wtcP0vHCoKmMWcmY6LUrgoYcC+hmZbMTSTAT1MYFoDw9XFJkhxzLxVEyZihzGx87Z4Gkwm+ yFtm8Zvc7KJNMlt6NlFlwFcF7Zc7EnaYd/aWfns+PDzd/nF3GCjBsCzuZn91+GUmX75+fTw+D6eJ i90Qt6YHIVS6hU1dG1SrXslhgOhNUQr86cU+2FDgvXgJVCZeeGWote6oH08It5Jnqst/x4e9EKSu abiR7uoac8i2RLvPkxXcz7Zge8xMGrh2wwUvBicJ8QmpZVP0fT0c5gMc766usbpO4NWWYr5fiRtR 5p3tGkJhxVZaluJ1mrjHhJ2Y6GKyiSW50Ujhs2crMf8fBunTa3rXtUunHuQX3elVQAgMYpq3+iZH hOdswwqJURZGygXxbwDMI8fDl+N+dtOtzdh513RNNOjQIwXghQXrjZPz6SB4KwzyO3r4bjBuLa4L b/GG2av06LGjqmoElqVbS40Qost43dL2foRShgENQvs6OXNZiaX0/oibLJyjkwAwU2qHt9r6GZe9 hvGbhtrZ2+xyVxMZFngjsuKtXx6DtS4NqPLLwEAg6Z1QBvuCqyR4LKrS1CmdLIQFgM+0CanahM/Q MVbfbD8uTjyQzMmirVgIO/l4FkJVTcDNPQ8+4rA/Xv15+3y4wiT3u+vDV2A3dBxGWV1zJePXZpsr GR/WReym8qEnCzeFsjGXX5O8ww8DdRAMdMMakXVYvYfXQuCwLfXV6RDn6e9m6Bs5vGXNJj49wWsV jmcnAL+/zYIE5ahyUK9/yEM2lbb3+BQnwQROkCLExD4+IAQRa5f+q7A11tQFg+sXQgBvRAUsqVjm PSzQUzOgPxbKRspER3Qy0Mg89hDi8FeoofFZU5m7T8338e8HbKifsRheUugRc87XARI9QbRWbNVw 10vsjR8cufamzTv9gM66gpaDjcp23VOlcQO0V6O8k4u0lQ2e/+Ss3HwjxVRltxc5U9R/ytpXvsq+ ilQ/DTY9wiFlialq+6mT8AwEXYH8402INq+Gt3xP2bSTbmjnHw9+mGWyY37RLmE75nVZgNM30w5a 6uUEjX6AVd1inTE3YHINQz79Hs+UygZv+IZBIvN3by2EJZF/fTycmqcrXsG6z2v6cKdpwanJqc27 6xurKBpfFseaWO4y0mCe69rywHAxVolY5sKLu6CF7WcKyCZwKW8mSrFtjIJBiPmmRfftnUhbLCMa 2seoZmsVbM26E+dMwJ2eeFYFMFaAHJVMd3bIllV7aH1b7cw60TfoBKTlIz/H7JopiHssH+ly35DZ kvGnIVz09HcQPM09/hRCKHgcGbsMXbVOb1ZYW4RGp7vb/dF2bd1Ex0Q8vlUKL7Y0G2gk3jKDfyGi U+l4Rrtko32kXTEUTfAZjSM0PG3wQg0NI74jRKmLaGON6uo2YnN7j05C67xlKm4m/F7DO5bIuM4j lKlB3CaRoSxaN8fKkzFT1bvOqKjRs0PDjfZ7L2PrCnRjphqgf8zjOFP4eSy2ste6zpcu7JIsngRm u891LJmp040RHtnFTOo4yxHYYFgVmG/VfXFKXGxdCZ1Ehd0N30S7x1DDemug1IeTrjbIN7W9iwZe gedVDXUy+CLceX8XvYBynjY6BY7G70745t0f+6fD9ewv8+7v6/Hx5tbeNgxZEWhmyfDaBLpZ5yib upfhwdkrM3lUwY/Zoc/OquiDtX+IELqhQOGV+HLX5Wr9SlXi08fha3dW3l2a2vPSX9DROYh4jQ+2 aSrET3Y26Hg9+OBaTQ8vRdJ/aq4oItME9WohGgUGv0bzWpv/o+zLeiPHkT/f91MY87DoBmZ2MpX3 Av1AHZnJsi6LysP1IrirPNPGuMoF2/Wf7m+/DFKUSCpC8g7g6cqInyiS4hEMxgG+ShcpUgkBu0IX R6DhmTJEQCp3yuWQlBP0PgsLe1kwS6eK1uIbJISuJRA49MvtRjlKeVMZWEqJVyV3rsdIH5NCTqb2 rspigV4kFAeUmPJwSIfj/aHiNRpooGU19XzWH5ANG5yg4uFTcrEs6jr1AuwMuWBcijktQ/tavVmn 27F4l7D2y227g0PsHTm1MTNZBxYVfofKQpvszm8L2APaOlib2rXeqQkMiaJEL/+BrQNAmuXHM39C AZ16d2im//D6/gTT/ab+68ej7fxsjKI6m6LfnIvmQp4FOgx+X86vEwhw3JooI5Nb1xSmZhXHMWY2 scgy8uonmYgL4TD6XhQxaChv1XEBn/I8l+0Tp3C8chDJqeKiNWEeQ55keUqrj77X7FFxhrUEyAOL L3EgeqV/Zaoi6k204DT1oW9ZlREfqUWALhXtZ7gtWW8nyrfmMYYyN2TeSHZWy4GqEKZJdgfa5wEN JHxbKQlkZXinwz8WfTgka7rI53ihrapjKeS5EVot5u19aKvhDTnc31kr4/6uMYuMCfbTj0zJpELb 9JEJnUp2U7qLL6eP8E68IzcGDhP5vP/VrifgrKj2YdmfTpzElq+kW80f46HPqkBI1MM2033aM/Sr C1DEVJkVYlNJLrrqci0rLo6Zktz6pBxHMNXbCF4nTaq4pHHvx9lDaI7/cHXBHx3QO+EQbu30fURZ wh7I4hhkk8YzdOgFaxN9owmTPfwHlCludEwLq83E2/upHtHb8Orbuz8fv/x8f4B7GYjpfKM8sN6t KRHyfJ/VcLwbHDswlvzh6ptVfUHV08ftkifFNsCaNT11WSKquH250JKlMGYZKkKRrfKov2Qi2qEa mT1+e3n96ybr790H6vNRJ5/eQyhj+YlhnJ6k3PZVMCC4iVNeSf5h2/ikQKDWGntNcgWD8wRjnfWF 5cCVaYDwlYwQgu9gC6DKbv0WTIXlAxBH2ppuuoZ2BEO7LLiuhDep4NO5MwApq3qX3tbWkd9dQB+m xvdhH+B90/zW2r7WOwZ4fS69h0KQsu1WtQQ9sLEztkdTKpoqgfXK0QkhlvuR0pA3XgAEcGBR872p /RAj2qu7cC0vQHM51NneCjsMQttjanToCK9x9dt6tVp03s/uOksZDg7ovdXLpSzkmMgRb9EWQei8 uhJQXZcOW/TB0uQUVMGfEAWYUK4R7p3NkBKlCdO+ZvaiKL+SB3MdD+XPkUgAHXePNQO4shFM/Lax +thVxvXRJKAa6Es+l0WBS7GfwxN+pv4shmGNWpa5pVExNcwdlV0ROZ6SqnI13MqWAbMUik1In6G+ tduSShWJ5ey9RkfPUOEgsLvHTK65HG6t7I8F4R3ORndsexorj3aIC4tbskB4QXmcOmaMiKak5Bsw HVbjBuyD0A/qNElpTJmj2aH3m36TGJojSZrKJpBJGcB1W4Iog7JPK+e2UtyGOjyHuY1SW13++P7f l9f/gKniYI+Ty9it/V79Ww5BZn0uOMC4v+SmnHkU9xFQhVo37PIn8kEddl2g3s57OxAd/GqK/b7V J9lUlh4Kj6QC71mVUETUtdqFyKMf2BFw3J8WEHpNT7z3YS7Tum5Hy74ZCIkoPQovld/oN/vz3ib3 7veWBOvVfaXjUgW9TFBFFHfGFS+1HOIGBJfUzr9IBSuoHN6eh3IS86Tx4iubwkCo0S42Dk+HPdAI Vh8RnhR0w8Ld8yWvzNEQEDDgS9enV9MOyt4rO13Jp5r6lOe29AY111Xwzbw7DgYea23JMyEFrTlG tMw/pMAu31ncenZYup7nGot1A7xT3DXCGSP74mQP8ZbUN5kaEc6YVARnTBpKN9msdxienEkR9qG4 bos7nhVRjXS/FYoz+D75YBHSuKjEyNA7iuyWWrELRgaSHDBwlWhNMCha/vNga8V8VsitI0dHjU6h E1nb0C/yFZeiiJFHjvJfGFkQ9PswZQj9nByYQOj5GSHC4U+dD4asFHvpOckLhHyf2EOnI/NUblRS EkRYcYS3KooPCDUMLS2KEWBNF9uSiGJIORBzszZsU+pvf/vy8/enL3+z35bFK2HbRcvpt7ZGivzV roVwKtu7uHb9ck9IiqGD1MIu0MQsdsfpejDr1sNptx6bd+upibcezjyoVcZLv23cHlH6UXJ+rnuq tVDLQvAFS7EErwdwSWvWFXZVpNh5LM/06vBY35eJ17GDegFRL39OS+klGipwCuHixScPV/yOOFHg cIHX70kO6ya9DLcdw5PyphtfXg2qMu0ewveBgblcVuJjQWIhcxQYc4Bk6201iiXPm+pSSW7qWYln dJDQzgrEfr4Nc2hWyqFj1svrI4id/3p6fn98pTJ99QUNBNme1UrAGEuH22rCise2FcXgWQiub7Eh 7HGeq0OJQ1Xh+j1poCXLgmLb2tMuA+1im68ddlFx08Gpb4vt1w5qX9tSos3hVURw+hQwOF82TwWH yQUBENx7aXcycaQRr9sP6UnKV7XTbTlzK5GDz4XXJKD5jQGaXwugycOo5/TSMjIm7k5J6/5qd7ie xmODvbl2U12N5qvSIb7dfHn59vvT98evN99eQP/+ho3kK7y5gm5xHn1/eP334zv1RM2qQ6JCpOdm MCHd2gNhPOMAt3uRR3OIPl5OYPb0C1pI1+2jKOsbjOI+1Gi5zmVC+B377eH9yx8jnwIyjIHSS20o ePka1K8JYyh9LByFaDfzb5bL19hiaJ0VwBX1m/tbBc4NVmuPGnL4iA0vB/iOk9le/C5TxS3weUew FEcKbOnu53F5Y+UpbShZKnBzpNXdS4dtUCySkUOA05EyxxhjPLqJkslBmzDgqrDX/ic9O0oRRVA7 PyoQAdPz1ddEuTppc7V50N5clmdx8/768P0NHGbAZOj95cvL883zy8PXm98fnh++fwHlz5vvcaWL A2upAqaX/x7NkGcrnMGOSnhFeSSDHXG6iOrSrLeqOW/mltOvblV5XdpchqQ0GoCGpH3hU4rzflBS OHwQaINXxkefIgaUbIhJYp+U35lFTnWEONJ9IQdgNxi21jPZyDOZfobncXJ1R9DDjx/PT1/UunTz x+Pzj+Gzzk7d1nYf1YNPmrR7dVv2//2ALLiHM1vFlCS8dHZzrdrSdHv7B7+H6/2QHsP1uk8EKY5V 5YA2AFYJXGN4tZDNkixeImof8KT1DKU1tdspPzn7pGY6+7SDx/ZMDchYfkgH1Ipd7M1mrLPbr/E/ 6499j77f10S/r7F+XxPducb63jmUrp1O9hl6d4Vn2thUPqD9DD6Z/A5rvFPXaK+OdRo6htfkeUCf VzALMMUAcBL6ndDyJAOk+VOdoKx60AkO0xl1Fmc7C5oFymEZKE9Qjj2ZLLqa971Ni83AtjkLoINl YWW60ofFKG9rV7CzeKLGK3hO7SBDbouqpEzvUWZM9R3UrcFZQyHZrh5VoCN7W3Qjlfd9W+qPjQsP cRT56lcgGX2oWguAcBNFPH4bLAO2kKKeA1hA5tyyUQtPnd8zJh+v91XUaCvUbu6Rleyb0CZjOT58 +Y9nkm0Kpg2qsAJsUS6qnQENv5s4PDRF+CnKsXtPjTB6S6XpV9oe0DfaPUPiwDsUt9ejniDiPir8 VA3G3mwPHv1yPXj6u9EYvaIHh6Nv9q8mk1OBuaKkoisz1sIjuip7VmfOjyZK3TXG0MD9l0do+HCA yGmfuAVlZcFcSlgF6+3SL1xT5Wgg51sauKMEfo9c/iu2nbtUEdyrLUVK6iP2XWurGw+wEPd2GvaP VjHmLyb8kMlxnRdF6dzJt1xYHttdxLfQ1gD5CsohWC0ywg3OrEnIE+pFcueZW0Z/Pa05nO2mWIxM M6ybgEi+BOvl1LqUkT8C97uyFL/vvwYrlJ6yMkQZ5bHwKtCx1mlxKRlu+8qTJIEWrbDk7XrGaQNR tZ7d/Xz8+SjXpn+21p/eOtfimyjEU2wZ/rHG29Dx90SuBgOQ82GUX1Ycj6NjAEqdPl7JisgTZfiD KDID/nj5dXKH28x0gHA/yo9CQp3b8pN6/PmaTXbTYaoTYkFarBiI/G8y/rXiCs8C0X2su8mKittw EhMdi1sizXaLuJv4ZJEfDnSAAOPpSVDEJuoxUY3jcfzDlny8eDBjnBg54yMLCaavl4Hnh7e3p3+1 p3d/ZYhSlXyQ01MbEHWkdAKjGHX0WI5C9pdR9mmBZ3zp3iDOuKmbDViP18BzHBoAtJX9KEQK15Pv 8HNWeBB1YGVEsDBlQ6EQo2Uw1KKyG61cXT/3W2GEJfSLc3D9F0V6ds2hQrmWM+UEhLvwlEl+Fhfu VdFsyK3BkbVFtxRjn9EV1DFSKXL4rkoGozwz+lK/EQxzQWcr4NVdk//SrEzpmZQT+bGOAhPuVG+r fnDvAEHJuwB9Daj/Nasr6a6q6cGRRwK7Na/sNNXVXqW4ty+Prza/dRSB4mD5RRlRyoSww4YpmxjI RS7uvUA54Z39o8smahFEXSUsG3jcKYMj8I3Up3fX4vDm/fHt3QnJqep7W4NbvWPGFFdF2cgPy8F+ 01K8DAryGLZNo/UdWVaxmNiUIoamQrUP46BjSWLbr1D22x6GngPSpKZ2XCPls3lSuoXlYE8fDfSE hqU14Aj3yGO3pKNw+Latv/oZu/xM7N0EI2HdxXy2BfsajbSjo+89/3x8f3l5/+Pm6+P/PH15tIJd 9k+rSJdukyOvq2qXf4x4WJ9E6KxHPVnHXSfjmdvIMMq8tnSsrMaWGhtR1enw4ROrcGm+fTLKgtkC 3yZbRMnms1HAXr58hH+WfxQ7q874jgIarPq48ERCE6GQ+ozd6XcvV4ZKndv7M1JLG1xRIQhl/C9X eMKNugPS9vLV9RZ1IpeP3tqjiViIwEa1Ojna+QuvktQxK7lA+A/XF0mRwETDWkL3BziYze2+yFNF UpH1wBMIM+lvH4O9IEkh2F5zYVUuT9FiWHYTQSw+k5u2KfITBgLnbtkIlT0bTHOTQxwiMPA4M+EX AKKiZyE4cCFiPSTmlRVc3Hqp/JGk6SlllVyCvBzJDkwHgAO9C5FNru8SrbUqUV+IHmXWpkFvVTEb prnt2BdnlctYZL6fR1EG+lU0hEoi+MfA2EpxbudK8xHUb3/79vT97f318bn54/1vA2CWiCPyvLt+ d2RkxbZLEsbFwjPhGoK1azpEwUU+QocSNTO37Fed5tbKN3XhkorJLvtbnlpLvP7ttagl8rw8OS76 IADscHE8YhyXw6OkPIKmmDCrwk86pWBSLqSPaHyPzeuhGZ+hgGDUU2PIw+v6EElZTE0lz28DhFm5 OVvKN3CsKs5OGM/6WBdFOrR/08FxehlNq8H1qh77m7MGc1cnB78pFZ7jNu3/aOIiY9yOvQLB6GFO Oo5pxl8PngCAC2f2qt0S2v3DriRwmiSqMD8l9ZRwUqa0FCyjSMcbD6/uwmCx+RAYj/NuN6LMkkHD 4pJqV1PWXrua8OJ+BScgZ0tQcan053F5KpCz8CpAXsQAr9KZmU1qIRDF/Mchhi3VL406LJywkyhw HQcSIIBLJuzSbS4Al8ntdKuq8Mpre8mcI44q0YsT1w9HfIy2eWP644PHa3iIq9FsYFRG2KHOhoij CsSmo3NI9JeX7++vL8/Pj69YCPlzNrSrjR/fnv79/QIhZaEAZVnWx1H2hthFpVaWNSDy9aqRkwgi 6MLYq7QD9cvvss5Pz8B+HFbFuL3RKF3jh6+PkNxTsfsOebOMlXpDuklsFzEC792u55PvX3+8PH33 Ow1yx6pYiWiPOA92Rb399+n9yx8T31J9/UurRaiTiCyfLs0uLGIVrhyuWMm9c28fOPbpS7s/3BS+ F+BJB8c6JqkXXtkiq2jKlrwopdw6K50Q5C1FHuRPubMES5kij1mKX1OWlX5NF/wcQq12Fx9dDGUw ZrMtkvaXYdhsJd+acqCuXQ06tI42qZuE9mGPxAJD9SCz1Q+jPbc17U4YTGW6OtsxCszZRoWVwnke 1brvAikurviZaEALSM5Vgh/GNEDlDNPFNNpdHlu+wCnZdmrvClGP66jRbSEq4CxShpWzW20mXkpU m30+pfIHC3nK20DlZmAnBy8ePtMRDWM5WvZ710EBmPskj7RYjOdhIGZEl2pBH5OdSZwdIemVQIuz H+lOJ4WUEd1glirzq46lalf4kFPRx2p8nhd7pJ/9bGY6SqifpawlYfMwt3Pi5WV3Xuhcj/Wi11qX 2k7EeenmXmuDeTm6lTa+V36SR4CQuHs1oD2mCIjiqnDCdhs0bHdCxLK3eLkIroTmpQWfsgRLLG/Y oKMetENRVfwEFT6wDxNp+NqMQT37zefFVWiZeMKvRp8kkZDLXSeFMdZQcYsPh45/xRK9GG7FsmHt IPOpbtR8jfHUAVAHjOjPXvAhQI0bxWdUYyNPkHCYgTPMQJMvC8eaJrtltGmVcL+rVjOfs2SYRwKo WskzaC2wLMUzABH3ZEU/XlxHIKDtWViBd7dbwj7yCI63o6YoG0SU2LijxuYMCzZ0+hn97l5NbveQ Ftue3r5gqxuLV8HqKg8mBS4tym0ou4dTBm7MEEIKAVxKLo9yAyxwXs33mfpWeKmR2C0CsZzh9lBy iU8LcQL9WFJBbAF8ET2WjTxc42rJMha77SxgxGURF2mwm80WI8wAzwIMCZWKSjS1BK2IHM8GEx7n m804RFV0RyiVj1m0Xqzwa9VYzNdbnCXk/CYPBkYSbvxbgQ51lZt0fm1EvPflWVPMuWQ5x3lR4G9C OvJUInfIzJH9zbdWHLm0BPjtc8sfpkH3ERm7rrcb3MSnhewW0RXXd7cAHtfNdncsE4HpwlpQksxn s6U9Gb3WWb0RbuazwTRoU5D8+fB2w0GZ+BOihryZRFq9u8fz0/fHm69yWj/9gH+6+Un+v58ejr2U i0XDg2hQNwa20A83+/LArBwoL//9rvxOtJPczS+Q2evp9VFWI4h+dVYcuO9icDYo8RsNk60dvwvp uPJvAlBfccRZnzfOWTTMLQiJaJ5vMjl+//fN6+Pzw7vsNWRcti+R8utANDTdGPE9yTxLuYKSKcdq YMmOSX65I5LxREd82YPQabL7I4jVT9w0KUhVi+sHENRl1pGFLGcNw58/wfU22nBni3K0k9z15vQy i6vvAkFxzSXXwOFJRczNCifsYsV4rHJBYuc8eKAXAtTjsZ0KVFGUVL/vBGRVg/bVOif5L3J+/efv N+8PPx7/fhPF/5CrgJW5rZPeHJkvOlaaionq3SOWwrh74IAWg1pxqOrLf8P53NbLKXpaHA6Ohaii qhxj6tzntLc2C8qb19sCMotC77pW1JKzj0a7vU1SZp51yoS0OmiZwEl5KP9DzEXAVOXwxd3g81vj dcklhcu9vk90JR2JT5MgHl6bo82vZHQ9hAsNo2sJoOUUKMyvwQgmTIIRZjuGFpfmKv+n5gH9pmMp GM2VZeyuxMHLAEa/CSNVWprNovHqMR5tRisAgN0EYLccA2Tn0RZk51M28qXiUh74Anw51u+HWAri fqyPqigTuMpH8RNZvwDnZ1IsUutcnlzkhjGOGZGhOsx4V5T1YgoQjE/RjFV1eTfSn6e9OEaj41Ue NvE7RT1zTkKub4R0qit5X+HbmuESO7qWKcrz+MwVlGTc7jHXxXw3H2nfXt/1kLuzAh3iGjd0M+vr yLO8HPk+EPKPMK8yfCal35Hm14ShqebeZ6tFtJWLEnFy0RUcmQt36uM282A7Uom7lE0tsHG02K3+ HJmTUNHdBj+TKMQl3sx3I22lDWK0bJFNrHxltp3NMK8dxW0jXvs7UOwNC3vv82QnS6lj7cKg4jk6 UfKB0oZz0ynFXJZK9WCLXUBUWW7RlgG3dF152sAy/a3Pf5/e/5Dc7/8Q+/3N94f3p/95vHky6SMt KUS96Rhxr/pZEUICjlTd+KqoDjOvAvCQukODG166nnKwR/N1QHxj3U65u6niaIzgKXG0Vdw9pvHN kOwKdqbCTC7mPE9Y5ZBgPM0GlPmQMgQtV2uH1ivPbKpSb947pCg9CdcvVV+feL/9eActtVXz9OEQ eiFGA/Q9BKSaF7WsJxqpvtPHZiaX37DzYjt2bubXRj2551bUAINpQ9Fn8rhzSCp1pe1dl3hInRcI sdqxXsULuO0WtrVzrAwOhGwlXJjFzpyUvBOYJvHSDikgqTqVjU0ROSvFsXCJKnuWPMqcOQQP5bbb LxTifi5DkTv1nUNVAd0N2G59EmKCPjAq5kEj4qIw7uK+2m8ET/I+FbzNgRHrED4nlfvxkPFrU+UO QTBE7dW5Zx3RE5v6/im79x6LTxQatlhn6OnLWIe0TxnECHWLlIswr3HxDT49ZdDf9qT6fsJpdZ8A xulLld6k9/I0IYwqJ76gfFrntHFokPmIFy6tVEdtO2RspCO4BkhljSfBQLHeHscMtV9iw7Kloh2z Pwlv0dA6oCRJbuaL3fLml/3T6+NF/v06VCrseZWAqWlfC0NpCmfb6ciyNgFCzt069/RC3KP79Wj9 LKkdVpm6EMf2ppYIfqXj89oWiNyqfJ74lrNhkcfuMgFXBP1PqPvhJHc+u1EdcUTwSe5Uzl7U0zbX 9yKOOV2d2DdbhqIC9qOhzxxAVZzyuJKyQE4iVAY7igth4M8JDMZTSWHAniBkKRiJOTapbigCINTM jdwIbq/pwg066DwEMWOZ43t8vqaExynctBP2bKE8s5xi/Lx0qHG6rK9IMDM22Xj5L1GkbsStlmay qjrf0PVGUV4ikmISn6e2kUd9yu1lx2m75DVnNVKrQogGTV18xm4lneBPeapdjLpiocRzhUlgyi/J Q8tzOuUPDN7kyBzUtl1Pb++vT7//BDWv0GZAzMri5pgVGRutDz7S3UxAmtM8GRjfyo0lLqpmERG3 dBaGxawcGDAhMCkG0Xa2BpSySIkLtA9ch6wTKkeUvkWoxfTrMvaZKMRB0X63BiLXp7zmuD7MxlXT /QRfpKA91QzsJKWeyffptW76G0pcxOLJ/gJMTsRJd2Bnfpp8pxQIUzHiJmxgcgOfBilrJLw7omsj xU/iCpuallbZ8fTYhhRQtON1C0qkQDjiS2tQn6Mjpx1RW9ShKA4jVust6nhiF+KqzELxbbC6UoHS DUa5c9kG45QuBxgjHGz55YfQ2r0OYWdo0d/qHMIzbvTPrwdcJQcM4hIQOFRxyxnxkGRQzxATYp/N Z/ig4Ad8RH0iri2tD5Gx6pyMOBAbmMSwvJgcbXLTrUYc5C1U8ZFhqYAiIbTeNvC+wjH7hKX5ZLVz Vn/kLRDtoKISzbm4qsiL6d7Pp1955vH0NlDc4gXJ3biYXGzafBxJfuA5Yd9io5NcgLQ6hbujdd82 6gR3xNnk2l7Fk0WBT0GdTK6alZRQqYsBGwbO4LR/dYsSLBMnwifKhiUJHfTBYCDXozxtT8s0glPS twOabKLIRgKxdLWK5HhPrpObmqjVXJ2EnaZrfp8XJXVLZeHq5HiqJ+fPNOI8Pb0u/PMH9nVtrYSv QnGM10OugYR+WjlxheTml8XySDGS7qY83lOua2VJXFqlHAu7BE7M2n9eHSrsYwiwpCSEjyJg3kp5 gbgfAnYJuSVOmK6g9ZzezleWhrgnBn4t5IzYbFGhA7jyz1N8mEax63Y73+AfzcXsmvlmi/m0GVgU R+rw49a35TRJkuGMPMqwimlRyyDGX9tkIUcLibPdmjBsNBBR7TbEELMg2ymIXEo2K+Jq2wbtpkCH dB3M8AlpIPJvPiMu3QymTCmLIYPIIrHZLmYjPVtBrgh9BYX0LfS7OIWCWBcM7LM8VxGGWV1J122w mM/8SGwD3C1LM2KtMpC7jDeXC7E7AOgo8CXaFCDl8tX8Sg8ZXh7Hqil4UsmTMrVYAuScricGU3Tc BRMQdhfN59iN5AU0V5agb/zzm0uMfwR4oFc8ZJQA4cCIDnAxGSEG26jR07QNHJxZEczgSMXLS0Cd qoBHdTK/pMvdGjdflbzFbrlCqiI5F763tLktwTho20XEZ2xFk4zsnA0LKEql4VRZ7VnlFaUQIWhf +4iCQ73X4+8///1vCOQycEszRfhR0G2y7YDWM2DrNddrto/W8GX4N1VZ4qQsN/nxx45oDg4CYH5k AFeMVC84sBGB2sER1g02hjDwtiGEpGZDPt/HhORuo5TqLMkJ7U0fp+EiOD7z3A3gQknbKmMqDIbB eEu+q4zAlyeIZPDLMI7QrzfvLxL9ePP+h0EhHp3UOn7OrrJ2uMPA/vSJ1+LUoNlHZLuW/g2QvpTx esISQa2oAf20EzEhxbvzujVy/vHznbSWNYEa7J96xfjm0vZ7SF6qQq14HNDigyOYR9apfm+dTCSa kzFIXN9yVB1Pb4+vzw9y+na2HW9eFcHfVCSev5nLgdAPaH5ADyaiKkny5vrbfBYsxzH3v23WWxfy qbhHGpuc0aolZ+/+y/oig3AO3rO3yX1YUBaTVnXJBsuaQooyJ2mRoTUsZ2mBn5t7zAJ/eQ8gDlUd ICpCQqXdQQ77AF/hekRF6KkcRJNNgU48TZOMcH3qYGpX8ELyDVGCx8kFQiniGooOV2eE3qR/n7Ka GsdcWFXxYuJVGTsoHeFExcGCoiCsHl1USMU17GHgMDzZBRceyx/joM/HJJcnronhJlazOS4adxiY nic0PnQHuZbMMmpwyHKV69dCl+NLUR23vBJXQB1iLzhbE0ptNVNVIgA0v7JmF6foqFck64q0J4JF Twmhptx0ozaCxZvtZodWwYGB1NxkhLbJRoYnKdrO8T1wgAum3wzKaMgIzaN8u5rhsq+Dv99Gdcbm S1yEdqF1LUraA3GIXX4MDJfcJaFys3FHlpXiyD9QYpIQQpgDOjCIyCWkqM3wCeqgr9GC0mHZuFZw mW6MXPkSfKm1YTzlARUgz8aJtbjfrPFJbeMOp/zzB/rvtt4H82AzDaQWShc0/W0vTB4fm4tvnzuC 9bzsUKQUSOfz7QeKzCK5Jn7g62aZmM9x01MHlqR7JiCT6Aew6sf0QMiTK3En7JR2u5njhuDOQpfk Ku7I9KeLIeXg6jrDfTxtqPp3BSEVPgaV2/50Pfk1IsLlOQMirreb69UfEghSKXqLrCwErx2rSx+k F4fJNyvlL8vllP8QdEF4dnswTgSOH1SyPlXh9JgA6MfmPSDjLGpqEc2nJ4OqavWx4auw8chBfFBh CHXC0ubjxR+KmvBi8ZGfIA7x9OqhuvgDa5fCBdMbDuA+38ONKv/gy2sIUrBcUSpgH/+xJUKVzMT9 x3pW/ZvXwQdkFDlq1G46XQWJDGaz6bVR46a3IcHThOGHLAdWzwMipLoLy/ZEbHkHdqo+IDWJ63a9 +kBLS7FezYgLHBv4OanXQTD9MarimLVS4zSY3wnc0qU9H3MRDQ/lUhaeL/EKa0Ao5UoinEN7rF9c Z7KOdY06IbRakUiUt67WRtcpY9vlaOlMLsyE7roF1KncpMM6JwJatCCuQj7VCT5wOiWDPOvlLXIM eK0/4VK8UQJdkipjo2XcJ7TeUyOibD7bkV160sqqQZeW0X67IvyzzCe/povRb84zIcvBxd8WcSeC 9Q4/opraM1LU1oi4Ogfr9UqeCEp5Mhz7fBq5GUVWGR+eVJQi6fjw+lVFauD/LG58j+3EiSWPRJQy iO5FitDw7WyJGeprrvz/NoOq91hUb4NoQ2zLGlJGvBSEG6ACpDwcB1QMzwahua396HgRkpt5aTf8 YqqILONEbyAHliV+JJTusgL7Un1wCERzqxWFfzy8PnyBLIV9lB+zPNqR6s92IOXWNLuuWC5SFZLa zuxQGwBGa0QqD31WZM0Liu7JTci140AfZzDn1922Ket7R0mhHZEVGRlaaayiWJwg7hbrwgWKx9en h2dMY6/PxM02cBdYHUjq5fs/FONNP65CNwyjR+gSbiF8dp5xfxZIFoSOT3mN6V1N41tLd//JT0Tw pJadgsExbqbUIkQU5VfCdsQg5msuNpSPuwa10+FTzQ5kHHwXOgkjVGAtuyrpiSfZeyEbX069Q6F4 vk+T6xRUlL7a3Di/uiNn8GCuw2TElNo9bw7EN8yLzwVlvwjR8GrCXUtFL5RyILEttvWCK4kQtdOR 5YIHYV5b0aN7WqMjWVhx3VpfiHak4htQmXG5F+RxinrnyEneect0z3TEpuYZrIR4BL4eZtJJICVQ 1vk9wrMYQ/i+RzQry5RTF/3ZhaGBMWWvy2Y40TpvHUJ+1vH2+h2ZXZConf3jbmj7Y5l4v0A6LBGS FfLasFh+iI4J6Nehw62PH8m/0rrFtz6NHU1b4bgYePMpquujp4E8iEasKmyUnKQ8p3w5bGB+Ohf1 CC4n7COBN14VrAoWO6pCv4nnGpzEIevxaLVFvVh8LoMlrcZL0gi8IVHmlafpPRULarip/69uWOnv V50g/Hx5smKm2hwIR9OFy9U3jbKSwyvfwE52Lj+DumaUPWZJhUAGfROrPdpRQp3rT0nMTldzkZv9 fH5/+vH8+KdsBbw8+uPpBxpSSz/WpHW0XBBKOoMpI7ZbLXFdqMFUCX6XafhZeo3KFN8URutst7ON kdwGS7cYLD0Uocpr3PV6J9dB1Ni+A9qQ0jciA/ofL2/vE1GldfF8vloQ9kCGvyYCGBr+dYSfxZsV /Q0kezsn7t1afpMRO7xaDihFtmIKQpejmRl6KyZZJedXJ4mrWk/UXSp2RlFcZcnfHOT88Z4TXKxW O7qDJX+9IM51mr1bE4dLyabsm1ued4Oko+5B0IxBFib1rijj9jh7++vt/fHbze8Qm1jjb375JofV 8183j99+f/z69fHrzT9b1D+kBPxFDu5f/QEWJ5B8Rse0GQuF4WOJWBcAS7LkTA+JAnYd4vgLHzdi 0xURPKOUocAeGoNry6A/5QL7XcqAEvNPPQsfvj78eKdnX8wLsG06Ees9QKoiLOr96fPnphBELhOA 1awQTXKmm1Tz/N6PtKeqU7z/oRentsrW5x6sqiMrHbkweT1LZX5QzJTKl6FHB8S/oIO9dhBYMicg ZMxEa1OznlsQRxAq/ExJiOtHwpquLIf+vGVd3nx5fvnyH2yPk8xmvtpum4E8YNuotX4CYPyUJ/Wl qG7BdUBJdfIokkH+ZttY7eHr1ycwYZMjWL347f/YzsLD+pi1Q5YT1ZVzKtW93DLwJmseKZEbfhaV wULMtqOgkN1D3JbxN0mRtqruzzzB1TkGlt7Lc/AwiYP/RinNUeJl90KWy0NfSuWM7WCJPBPK5QgX 6wwqTnIp+k+98pBkPOeTr+RRMon5xISUSCZhaXLhIjxVuIxkUOKUV1wk0/1a88PISw+lXDAJz5cL LgjobDzsjO8Imiv3C9REpsvkU6b3Tgx8i06nwrFBAyfVMmYaQQj6oh5hg6QMcYJYXK5mhIFDyOo6 qe6b6BLM5rj4YSCxCDaEy4UDGX+RguDbsoEIIu+1aQ/FN8+HdwEZpdFgwLxhMyMuoTwQXltTGwna 7ojY3QaTltsNYRJiILLSSykijzc8CxdLvBhT5QM7HRI40wQ74rzSvTDe7XZoVngvJr36KcXE2NWV ALHdaz0vXq3r1JHSUA1pG2xcnldOh1OF33gMUHgPd7B4sySsSxwIvkH0kGw+C/B+czH4VHEx+HnG xeAXWg5mMV2f+QYfFRZmFxCDvcfUsn8+gpmqj8SsKW2rhZmKRa8wE/0sFlOliGiznvqiV97sWW7C wIxib7d1Qpj5dpD5zMd4iM9JrlZt96ZK8/Ysm6+Ow1Xdr7M88YKZx+EeKwR0jYnIKI246ZqQDJ7Z QcokIaJCGkh9LdG4kC1f6SKhP7B6xmI9kdgAEgtMfL44SaXkQPiPGxBf3co+IyKtmq7fzLezFX54 sjHbYE+E0uxAq8VmRQQ2NRgRHQmZ1kAO6Wq+JS9sOkwwm8Js1oQ7pYUYn7BHflzPCf1D38WrieEE h7KJqcHr7caKoNlSP0XLABs/cpZU82BiCKnYlAdcUuwwasMcX2w0ZkOqXR3cbqJOdSR3+/FxDZiA kMkcTDD+7RRmum3LYD1d54AQIw0GJKb1jHAcdEDz8Z1PYdbjuzVgduMbn4Qs5puJgQu5OqYWGYVZ TNZ5vSakRQczkahFYT7UsIlRJg/Fiylxpo4oG6vuu2eEYrcHbCYBE8MvmxBgJGB8LKQZFYK5B0xV cjtVye1UJadmvZTCpgBTldytgsXU95IYQvh3MePtLaPtZjGxJgBmSZxsDCavowaCImRc1IQHUQeN ajnpx7sAMJuJ8SQx8qg63td5GWW0lYJp3n672mHiTZlBLuLBRmXIqJQeTNQ6TNKm3I9vVJABK9rv qajpBpWL8lRBcHU0E3oHqxarIJhj9ZWs7Ww9PtB4VYoVlTWrA4l0vZ0vpmZOsJqtx89LaludWgXq aLGd2DLbLWq8aXr7mWiaBAWzD2wuEjSx1evVfGL9AdByOXGKA23EejveS+U1kfvvREKxUixnywnJ QoJWizXh1GVApyjeUSaJNoYKRWAw17hM5hMV+pyup4404lhP7IgSsSBi8feIaKKMkeu87tySJVI0 GZ8YSRbNl4RyycIE82nMGjR845XORLTcZB8DTexkGhYuJsQYUddianLIo916QqJkcTQPtvF2Ur0j NttgAiN7ajsxQnjOgtn4qAfIxOYiIYtgUjqjkj4YwDGLJsTJOivnE3uhgoyPIAUZ7zoJmdoNADLV 5KxcER4TBnLmDGxQJjUxErfersePvud6HkxotM41BOcZhVy2i81mMa4VAMyWSrZiYciELDYm+ABm vBMVZHxaSUgqdyXCocNFrYkQeBZqHWyO49oVDUomUFdwcLIRmMHCcGJL/shlSQerb2dzd3NsEUqG Zc79ZUuCPAs1F76VvAdKsqSSNQdTY6hFsd/rWP1NJn6b+WBPB2/IEDcfPLUbSMAghvzWSK85FJDS LSmbCxcJVmMbuGe80mmu0Z7BHlHZzZWL/ugjdOkIcLS+AAhZflD/N1FQXzmsJAiZq0zPByNIZ0IE O4dvuG23zsIoiqiJa2EKxAeihC6Ws+tEaQDByulu00fL8itWRsfRwvD29aVcWB0d4wLrXgHOmoUQ PEydThWupUhLDaOMoXBgDPpLGb/96+f3L2BUYHwNBpZH2T42hqJdcUCTRa52M2KrVYB4t9rMs8uZ RLBrGcwGLrAOJAOTRiKYkGTHbDcjNKgdG1+NWzbl7KXYaU4XLeXDxXXov+tiymBNXDRJQbYpmeAR XTs9tu5OrLpVljFwuY5887SMGh5ZIe+BIGxCX1ha2iF8XLpap0lmGXF/ALRjP4uakAgaoVB3gsqd BOxPLP/cRFkREw40gLmV4oZv1WSxt1uVI2uCj2+4eohd58sVoQdrAZvNmtjVW8B2R7h8Kn69pvQ5 hk2I64qd5PtgHhKXSoA48xIyc1GeCwCpkhq/7gVmGe1Xcp7QDaziaBHM6a9Y1avZyOOCLzfrK20a pjDZihBhFff2fis/Ej4dWXhdzYb5ld0C7kVE2OYAu4ZUb4vF6gruu4yI2wPAtFzslnRLZTlpRgTS KIU8IxOGBqOutKpgBdjimhrz5nK7WUwUsZsHo0vWJZ0Hm8V4X6bZYjXyteu77DpS0fN1u6InI6v4 5yJn43XMtruddzqz7bmpLa0vBXLUSFmEUIpW0aD9LSdKIs9pQsX9U3SwJNIuHl1BipwQCQ9UGIZT KpIt4EhIxXguhbi4uPgwpwbm7fYabTPaAI14n7bAMK7OysJdJGniRsHS8sLj16cH06mQ+NiWEnQ/ sEyl/O66wuHquGNNfaYAMT9IKTsdQVQMQi8TTBFXFMtYFFN8ZdBlf0EznoZNtrriy8srElbvzONE hYcejJJimO0mPoe9dOW81ClcvfT89PXxZZk+ff/5pwlm6L/1vEytzFM9TTl+/IXQ4asn8quXjruj BrD4PJLFSWP2/JrILYrnKrRlfvAtu9smYVV3OrLzg+gb5o3Pvveg0/DZTxXWJuD599O7lL/rM/YS +BDgboW2FZg5aoKoHmPXNm9OJX6br21WmwtJd5Dj/Kq4CfinyBUCTkVNqlIaEYH5AH5KE+x7dMmC Bs2zZ+1ArFedquIGd8Ne4S+Pv395+DZ0Llbxg9U3j1ImBqHILZYdF5Fc1w6ijOh4yuUFXxHbt5Sc Ua7YYfO5WqypTM+qvfXtJQnlUkUjgoDYovT7JaY+D5ZH9v3h+eXf0P9gxt/3n/dwea4kH6++Rhxj iRnhywbM52sQeLKMkGk08FBsvEgkVkX/+bUfMKMVZqcZpbttP8c1WMyvQ3+LePIFalTD4MG7A9h1 DYDwFFO5/XoQldtHZEJHCarw4QglhEEUNOBfHBWl74bhAJnwdLrWpPk7NPWXB6d7fx3v3CQLtkjX iZd/vStPja+P/3r6/vj15vXh69MLVRQ0jvFKlLj/ooo9zqLbCtfutTtkxM1KgAtFauc1yxyyEqr2 hKd94ElIPR3ZnBQ9S7KiFOgTGUvTInLS3y3TfjdHcq05QFlyIP9GcfBRP1QgiBcffrMSKKhUcCaZ 480vXYbHX2+YdkUazA9IExnXZ3TNd9d2a7l/+P7l6fn54fUvauFndc2io1nz2U8YXV8fv7x8ldi/ 3/x4fZFD7O3l9U05p3x7+tOrmB689ZmdqIN7i4jZZkmEL+oQuy1xt9oiErZezldjG4KCENZoGpGJ crEklATtKiYWC+KexQBWC8JyowekiwDf1dqKpudFMGM8Chb4EtNuMDGbLwiDJo2QZyDKFqMHEGZT rfhXBhuRlfg+2W40RX7fhPW+GcCMlvRD40YNnCoWHXA4kgRj65V/e96+xHmyF4RHSpOC62ZOWLP0 iO1oB4f1lrCU6/iE32zHJ+wqNP9WzKhgle2ITbfr82a9HsPIbtvMCYMCGzH2ketosdpuCJ2Gmefl igqbZSEIVWqHkMLI6EpwCbZEfDUD2FH+HhZgrNMBMNpd5/K68Mxa/x9l19bjNq6k38+v8NNBBovB +G71LuaBlmSbsW4RJV/yYngSJ2mcbjvo7pyz2V+/VaQkUxSLygADTJr1maTIYlWRLFZpHIc8fW6x vJWTF1RSm8ZcmnUknr5PsnL75eps0clKEkE4uWgrhvDo1xF9dUycfCQRxDnqHTEjboVrxMPEe3AJ T7b1PDfHb4TXcXppTUAz2NoEPD6DdPv35flyfRvgS2rLTJRZMJ8OJyOXBlAYUzi1Wu+2dFfSfyjI pxtgQNLiKRfRGRSpi9l4Y9+QuytTNmiQD95+XGEb3WkBTSH0r+owRB1rx/ipskweXz9dwCi5Xm4Y /+Dy9N1WdTNFi4lzrcezMeWFqwDUCWK9h8JItzwwJVJtWNF9VZ09P19ezvCbKyg72rrf8JlTSfAY xtClZRAwcxklCCA8Ve4A9zjFh0lfHybO7XC6G8+dFhwCCC9hDdDTxKKnidmceKFXA0j373sNTgko Ae5OzuaEY0cNWIwJn6sGsCAuyxpA31Av+r5i0TeSntuySXcPfX146Bvq0cRzsvVOzOdjF1vHxUNM xd3WEM6tByKo4CYNIqOeATaIorcfxYiIb90gdlRyAw3R9y0797eIfDgZZj7hNaswSZomw1EfKp7F aURsfSUgfz+bJs6+zLZz5tKSEuAS/wCYhv7auXuZbWdLZj/zqBAxZ0Q+xup0pvDCrX1XYtcAUgVE UGbzO6nNk8XEKUaC/cOCeFHbALzh4rTzY2vPWs2r84an8+s3xwFfkI3mM9do440fcYHdAObTubU7 7caVZZHxrv6vTQeTZlzUlIl8vqm+4sfr2+358f8ueO4m7Q3LvYH8BUaMyYiYdzqsgI23GUGSAnqU Xu3gqHvdTsML4ga8DXzwiPcwLVzIZlRyhS6uv764GJPOPgaMcnUwYcQVchs2JnbRBmxESGkd9qEY DYndnw47+OMhcd7dhpHZF9qw6a/A4kME1RFPV7vABeFwowP96VR4hA3dAqIhT/h5d1mU8PTWgSt/ SKmzDoxwsDJh/V9R9a6/vvCX5mPlg939C9PmebmYQ4X981GU7IGyFNqSajya9a9HXjyMKGcPDZbD TvcXeOUQTYYj5/1AtYTiUTCCCSGOzjrQ5bATMr/WnxbZrQv118sAr3lXL7frG/zktQ6gJz08Xt/O 18/nl8+Dd6/nN9inPb5dfht80aBNj/AEXRTLofdg3+JUdPL1iqLvhg9D+8uUhk4Iloo+H43cFcwp 401eMMOaJ2SvJHteICbGOwLbYH2SUaf+a/B2eYH9/hvGw3UMW5Af7CGP5I1bpa/8cWB3OpPfxUnB IvudeN50QV/9KXr3q4D2u/i1qfcP4yl1QNrQiWQDsgvFhBApSP0YAdtM7PrpTncw3mwzoq4tasYa E2/KasalhFnzeyfjS8bsYXyajsZN5yjLYJIh5bRWV0C9bEf6LhSjA3FgKH9ficKATNV+RylWcHYW +kKvMpDfTimh6qe/VdHtgv3Oio7JgMXkEAKFAKuF/jUICNcQxUtvzhydVzPZNk+btVgM3v2aRBEZ WK6OL0Qy/YUwQGMqXfqdTq9WudqITXQl72hRFs2nVICt+/gQVyTSe+hQOJcqCBrCu7UWJBNihya7 zpc4vUSYFR1hPxOtEAtE9AFoDykAkA9OtUGi5RlbPVCmHpJDv09LT4iNjGKPYAzGkN2xpgFMR4ST JCLyIhp7xNHInU5PY0XH43O3zqSH6GMwAksNPcfSwLoY/UrNO5YhSlXPISvUPBGvBTUAPVNK8Vg8 jwoB/UtuL2/fBuz58vL46Xz9Y3t7uZyvg+IuQv7wpaESFDvHV8CKGg+JLINIT/MZ+cCwpo8ck7X0 48nMoRyjdVBMJo4OVADa/qkAxDtJhQBmcLA8SjTiPaxcT6U3G49PHe+RLmQ3tUffaloZdUU/F8Hf kf0PDoYCyeH1qqfxsOtJI/vQtgX/+Tc7VvgPwxnxvL2xQqcT2r1Na2Zwuz79rHYzf2RRZLaVEVl1 71YKjATo2T5bRqLap0/qYC30a/fX+sRt8OX2oixmi30/eTgc39Pclyw3RLy9hkwzH5Azx5RLMj3q GL1i6lg7ku6oXtFpCYWndzQ1WgtvHblWLtAdxhgrlrApc2gKkKDz+YzeEfLDeDac0ctWnjuMXUsG dSnxSAPJmzQvxYSWPEz4aTG2H5jK34eR7S2wf3t+vl3lg0eZyn3wLkxmw/F49FtPrPtaAQ9d2xUz 0Hz7KKFzYiDrL263p1eMogzr4fJ0+z64Xv7j2POWcXw8maFgWt52Xdc6Wcn65fz92+OnV1s0aLa2 RV7brdmJ5UvNLV8VSH/ydVZKX/KmDiSKPS8wSnJqewcY5FrijwBdFDOQ7ocmbYPue45UGUFUhNEK XRXt9Z22sagyH7SrxvLVsib9/EenXmg7Fpi9OkujdH085eFKtHEr+e6geRNsI6Y7zKaJ/p9gbbR7 rwBRyGTEbAxVYc05g1DMinEKAx6gJ2WMweuNDmf4sKZdVhTGWELBKcC3tWyNKZ7SqI1fh/FJbNDT 1DYku7j9t4A5DPRA/pW7yQAkNeUWgb9TSTjABif2aRVE8GhERNmpIckhkxcJDx4hw0yceSOihWOn Oq8Mvjxu3TvV3idacbvVnAX21C1IZHGgMjh0yuCj22NcFft8ay3Hl+pZkVtpa5YXio0lz9ZPywfv lLejf8tqL8ff4I/rl8evP17O+ODCnC8MFYo/tI3cr1VY2Rmv35/OPwfh9evj9dJp0mgw8DsfBWXw X2JKgIqyCcwu1hi5krdhnoTRyXwS2Tw6cfStiWMsGDZmtp+k5S5k9seSkgEfiIBSck2tQ2KnikSQ TzQx3q9XNNuvY2ZE09SIZdDKWyVHURDPEoAWr9maiq6E9A8HwhwE2jL1NzY3e/kJKpFXZy1kmDy0 Ztl6arLz9fLUWn0GRa9hmfNgbQhIWeud0qr8ruiXL4+fv146Mku9+eMH+Mdh4Zkmk9Ghbm3tysIi YTtOWEVA93kOVs3pQ0g8wVXzOxqXE2r3i4O7TA/yUpvSJzJrocnMReDgqXxE3CdWTEL3hUgfI7UI 2xnBVTtzluY8TAqpX08fSp5vG3m2ejk/XwZ//fjyBeR1YD71AtXuxwGGb71zApQlacFXR71IH4Va u0pda+kWVrrC5wxRlId+0aoZCX6aHeHnrEPgMXznMuLtnwjQ+k1dzwahqcsk3OvSljH2Ks1Dvk5O YRJwZlM/dYuthyorfHO0CvM8DE56XlUoj9MgrIwB0SIUPJIdKFSGzO5sfKuTtFisZBwRyeNWrgBq Ftu3VPjD4zLMyS0DAKhEjkgCmwLGxS7p5BSJgiSC5UqcLAMRVICw8/hKHlTZkv0BJVy13qsic1Lh 0dFOJZYYkNIsTOiERDjro0AG+qDoKrMURc35jqRxyg8PaFHoDWdEzEXkLlbkKdmlrg3VmsviSIkj RSVHwr6bREpHFLWonBzcJExhQXKS77bH3P66CGgTSuIi46RpkKYkP+wKb06cDeAKBU0X0rzOiEQw cvWRlfpg8vKEHqNY+GX7e7Q10rY6kHWWoMgOxZSK+43fCDZCacYj0jgoBA5K0pjsER65UYH05KSS /lTycxbmtWntDWZTPFLELc+f/vX0+PXb2+Cfg8gPzNzHmhQEavXQGDaB3LfpwCXzt5FMbK0DWxGR GgQGNcsJHryjZGT/HswHP41P+4gI3H/HCQZ7crtc0BoMMs8jDn8NFHFeeEehex5xD62BdrPxcBHZ NwN32DKYj4hYN1q3cv/gJ4mVBXomutk1BDIFc3WsdH29PYFKrAxFpRptvIHHJH43wW1tGsnjHd9M X90qhv9HZZyIP72hnZ6ne/HneNYs0JzFsFNarfCO2azZQgReLMBmwSy9McuPbmyeFsbxiL3Gyggp 2DbEUxM9hEXP2DVRo9K1ZsHgXxi/H9NngpiwEqRet1L8qCzG46nei87xWBPgLC2T4F6LSAItuHMS VCluW0WZH7cLNvsgzNpFIvxQL/pWec72MSjsduF74NtWF2RJFcbAODtDaioEHlxZGKzqnpmYV3Yy t3xKJz6ERsNjQFAbgfhzMm59WhXRJY2CKm6H3nie+qeVUdMOo0OJUBJXwvyaOxXTRlsXtuwqkUdL VhHDNtj8YDwvE2tg1XYxzEwJNpc5EnLCcJ11i6uR6yZCrgE4o6dwB0q7++PubGMpaMcuoXqubQyo L9oZVBCI/SSGAra7qcGL98ZatcRFxux7WdVLlXF+NJ9RYWaxjqw0Ir+2us7NuWbByPOIALqy84L0 jpR0wTdUTkUkF5xTOeobstwaEXlTEFR6HhUiuyJTaUcqMhUXHMl7Ihwv0JYF5XyCVJ8NR8S5qyTH nMqIKgXG4QhWBv1rMR0TziUVeU6FNEZycVjRTQcsj5hjxNYypjJJjtjR+XNVPREqua6eJqvqaToo HyKKMBKJfRfSQn+TUmGBE4xdGHAiCemdTEQ2uAMC+92pXgM9bXUVNCJMxIhMs9XQab5ZxVT2ZamP AkEvVSTSaxS06mjhmDUZGdI70D2vAXQT2zRfjyh3bsk5aUTPfnSYT+dTYlOvWOfAiEAnSE7iMfEE TsnVw4aIZYwWBs8K2EDS9DgkvE4q6gPdsqQSfmJKaRAOjEoNMY8MjX6n98hnua9MBb00dgcyLxJQ j/HKEJTSet8Ev8vLkPsZpOJCZhh6AVO80y1WNuBPszgPVUGXoqy7ZWj71Z0mR+MeJboGZBixV14t Vsa2QffhVz40zqIipE2qO1Idk/8CUPB1zGAAfgFqHB5bMXKT9UzV4DhrNIBpEh6o80EDyswo3w6g Y6FoQPnq4JfGbjK05t2sYdVJQJe5qlyxbBc2RujwvrdpmLc7xnnYrcxP4wzGKym6fJchx0QpdvWj wXUq2m6yMe1fVQ7i+lQxequ9UizbcBkqCoP2dHCqGG9GbeEKW0OK6JKNHMpFIsRhbD9MrBE+4+xD Tx2j8ZhmdoTMMUCSE7HhKypeujT8/IA8Fq+ryFIi7P+dvnEjCphyMrhWDdoxMPppCY1fund9rUiJ CGhAM2KyKrHLg278yg3XtuDwxz09cJGHybrYaBlqeQAb6vvfZee39yWlHNS+Xz6hnxw2bLnfwF+w aQHGm/UzJNn3yyItnYi8tI+hpJLneA2V25W7pAtCHkpiicuXJC/DaMvtmwBFLtLstLK/wZIAvl6G iQuhMqg7yBz+ctDTXDDHx/tpuWY0OWY+CC+6+ixPA74Nj/QAOiS5JMPwFrBFP4klyHH7gpW4I8hR QTcDPLtOZb5zEhKigxM90GHE6InE4Lmp3YBSZLvtJGkfYXxI6jqMl5yI8S3pq5xudh2lOU8d3LtJ SVtF/r6YexN68qHf7lW5PdKjXfroI2AXXUjfgxmV2jcrSN7xcC/SxFHB+ph3Mk+0ANxnge3AWNKK Vu4DLHrPlsT5PVKLPU82DgbZwsaNgyB19Cfy6YQpkk7cMShaku5s3guSCAON8rUtpevSU/CeIMAf mXas1ZSvVq0TYJ6X8TIKMxaMO6T1w3TYKdxvwjASqtiQJsARMTAszTYxsEXuGMSYHVcREzRP5qES BcRYxdzPYaezKszpj8EyCnPHSo3BQuTu9ZAU9jMbRcu5fTOAVDAiHOs0AzMc1ACsdppDsjCBkSXM dQUoWHRMaC2agSbBuxuSDgIS58ZIzGPoAx4Txo6aHKiAXJR56vusMzGgvlxjI1gsSmsWG0kF3ahZ xRj7sMuWMi93xBNHI0VIhBauqMDvYBIRhxMSUyZZ5JDUeUyzzjoPw4QJhxYVMcuL9+nR2QSoWVpL gSwWVHZySd+AdKOHoNjAprJQNwa0SkDD8pQRPgcSMV59DHNKzu0Z6GCTPfacx2lBC5QDh3VBUrE1 56B9PAZgezoEkkp1ddqU9nd60oaMzAyjdVwUi+UsTWeMCWy149XWJzAHIbN6Z1VgddnVqnd5A2T2 cnu7fbpZ0ynhT7dLOzsgzSLEq2/qacKEtYLho+tx+7ObRtFzecMDa5Pmz7T8Uxw0BVWj3GQDgK7X XkVzRKA3qY1NuvH5Cb3BorDyPdM2U63Y7FqhivvdLovw9jeX51ytwS+jjJ+Wpc2TVO75c9TtTJw2 ftCqsF27uknSf5ckoED88JSE++qetfEtbMfOw8nrJCtQ0bpVVjP0kOPC+EQ6br4ctcKuHSvaab8B NRBxwjO3Ri0j6a4gCnNBtodVyHFdhzkWVDk29JHAfBklqAV5RRqx45+/j/7R4v6k3vxKPr69vuGV fP0UJrCvJ3++OAyHOCtExw7IODhpz53SYLn2WdYeT0kwcjjp5aBtk1Awu2y7A6vo1yQqrHpFj/uh HI+Gm8wJ4iIbjeYHJ2YFMwg1uRvr603ZBxCRNxo5EbmHD7keFk4Q0FRA8NgwaBq2UJ5QA//p/Pra Ddkt+Ux3epBrEq/r9Vt0LNwHBqqIm7OXBFTffw9UBoQ0R4e9z5fv+AhqcLsOhC/44K8fb4NltMUF fRLB4Pn8s466cn56vQ3+ugyul8vny+f/gc5fWjVtLk/f5UvDZ8xa8nj9cmv3vsKZ7FcVO7KM6CjX cXqrNlawFbPrWB23AluJ2qnrOC4Cyotfh8G/GS1xapQIgpx4smvCiKCbOux9GWdik/Y3yyJWBnS+ jRqWJiG9bdGBW5bH/dVVJzEnmBC/fz5ABJ3K5dwIv6avVyZ0Wcqfz18fr1+pjAhx4FNp4SQZd3cO duIZnQVLiuggIaxTWbtc9wHhUi1V3J7I/VcR6QQnKB8Xbc/AZkzQwrALEOVQYpgXysnEb9zW2vOi qC7/SA3m8AjVUIznPuZR7cXl2wkVTUWDdc9ULV+3mUxHHcmjaNJS2ISudauAmJoKz57DiD7F19vM QDk5UtBUqGp5xHZ3bA0Zxllo27dqkFURcJiElPjSHRdEujMNxDPiPkbH9NYSButfGqQadyKOQvSP 80Zj4jKwjZoRMdF0fpau2P1Dse+FlPZnRhoEj7szlpwyl+xtQXthkegdrW265LAg/d4ZiP0C9tH9 Ayu9xXtBqVgsCFchA0Yl/NBhh/JXeChhu7h/0LJoTEUT11BpwedUWGIN9sFnxP2SDipZhPu0XqmZ +Zl3cCj6CsbMN+k2ARzmOcP7wYi6/dDRx3iZ2i+rNFT/ypTPitBdtg94AMnvMraqOcjIc3odFSc8 IfJBGZX5/bUd8FzmFPdWt4ft/TIlHnHoQytKKlCRziFF77Irs2DhrYaLCWUQ1coJzWfdMmpvwYkz mzDmROrkijqm1S8LysK5CHYipA36KFynBXm/IRGO3VStNf3jwidiyCqYTMlNW1EBfbsgd5ioT8mL PjkIeFkcgDUGu37LBEnyKV7x04qJAsMwdDdARFpjuXPLWeKHO77MyUSl8jPSPctz7kCY8R2MHbsI C7U5XfFDUToMXi7waceKVotH+DXNE+FHOaoHmuU2pcwGN56NDvRmYSO4j/+YzBwCvQZN50RCGTn2 PNmiA6oMguwYIpi5VFD3spIPihaXNasw+/bz9fHT+WkQnX/ao54kKtnc6eCHxLPm2t6fmM422tko 0U67kjUzM+hVxOKYha0Ma7LgVPiZLaKGIpa+0Hzn8a+T76+NkiqfuFHvJpgIYc2xg59S/Px++d1X cUu/P13+9/LyR3DR/hqI/zy+ffpmO6NV1WNCzYxPkEGGM9Ow0cbs7zZk9pA9vV1erue3yyC+fb50 d1yqNxiCJSqkC+Fzm6KejWpUW++IRnQNkOP7HxUXxty+IUlUR9d4fGflr5hKKx7GApTn1sICeOSL 56LaRS6ekqqsoFof7qWnzjWsDlnmKFcSFOmbPa62ZB0G9WEyXnRbFo78Icvs9rckyiTVdiV8p9tl UU2fE1GOJT3z2YO7AswUbpc+FX02IwJY3el2EdfQCf1d0T0qo/r9A4h05A1gTmyn1MQFY4+Itynp ivWEmFKnZ+p03WeY+twBiPzZAxX6tJnLdjAtg3fk0eRfT4/Xf70bqYSc+Xo5qJwoflwxfI3lfm3w 7n6b+VuH+5aoP+zmhaTH0cHPCP1eA3Lrpl5SMUKNLj1lYcL9hbd0jITKP2/JDNsMSPHy+PVrS1Tp dxzmoq6vPoz3bC0aWMR4BElQwT7aEqRNyPJiGTLqp81zUoLuZyVBYX7Bd7w4Un2qrp7kJZocmcfv bxhy8nXwpobnzhfJ5e3LI8phDGD25fHr4B2O4tv55evl7Tf7IErTTXDl4WvMT911mSidmvsalTGY cLIO2ABRCZaNWtB903ZI1h6z/2fsyprbxpX1X3Hl6d6qzJlYiyM/zAMXSELMzSS1OC8sjaMkqrEt l6zUmdxff9EAQWLppvyQRd0fVmJroJdWK7jLBG67qoqHPOGEUwAu/s54GGTYKxWLg0gcjXJ4xqui cmU8KUqW97QJ1H6blBjlawU8b9hmi5JJGSS2TND5blLT/lPVKI1vJhitEdJzXoo2fVHxuL3y2Ocp EZtJsvlsdPuZWE8VgPTA3LKpZVKx2fh6ELAd4zcXKvWUCn7asoerNqXkWcUWAiomoZa1+ILc+O5A SKPryc3seuZz9AHCIC2jOhcfHyVq894Pp/Pjpw8mQDDrfBnZqVqik6prCECoAQW8bC1ORHq1EISr g/ZVZKykABSb3rwbsC4dDHARsmNibNKbFWeNa2xs17pce/JLpyEBNUWOTzpdEIbTr4x4xuhBLP+K v1j1kO2MuO7WkLgSMgy+y5sQIpadAbkhIgZoSBpsbyin9RpTVtNofCEfXiViwuFzysYQ5k4atBUQ /IJPI4poPqPOehaGipljgcbvAb0HQ3j27zp6cl0TIVI0JLwfj/CLQY2oxCn89hN+Oa4x83R8TRzl uw8qxh9hVWRApoSRrZkL4fBWQ1g6/kTEWu1yWY+p+EE9ZEZF5uk6JhbTZeZNagiPZU9qc9EYgSUZ KCnyzuBC4CFs7TsWg1iI5YRAYwyLERVq1mr+rf18KYsrnnZncQ5/pusPyaM0r8xTiDHzR0QkCQNC xY41IYQffXOJmU2beZBywpjBQH4mRMQeMpoQV1Ddh67vrj/XwfCASSez+kLrATIeHrwAmQ6v5GmV 3owuNCq8n1ByXzcIimlECJ8aAsPEvwQ6vvwhjvWXhuq8Fv9zJnxn0FSpkHzoKIvToNdW67Ltqf4Z QLk7TAPfSx74t2DZwvKSBzR572XkDkorZSB6dhETKhOteqFgE35bNYAIUNGy86CmSiiSbUPxpNei JZTepAviFaTHoOx4A7kTsSUUr6H8Iwg+G8iXSbe7ESeM3sSZykncfbDo6bB/OVvjJ6gesqip6b6I wbgWOUsJeria+4qMMr85N13+VBtJNRQtVGJnwAlKk+Zr1npVpGoDMO2kGXUHqiBClC4qaxh2VHny ZSnBjNLAdNPjtNPoudWWfulYOVoHPG8ijltPAa+AKbxgGS8JZQOBicGZ8gVMwAilFMGrWBnl9sHW rEHEDctEK6GQqok3DEhXrqiXVcFN507M2pa3ngsmz9N0JS9/r3vpU3LWoo3z2CY6kCyXyQ1X4XPV CgcH7VovAh/XpKmpEtqRxcqxNQdmz1hgMr1kpyCuPHskz92SaFYTPhRw/5sGWbCw77PAj4D2uIOV JF3cGsUol7cpy8xeUES7Hzpa76nVZoVgYi21ct28U48mHQG41QZsSjgHWccFdq2zXuZVLcZAnYRG GUB0frotlDQxJl1YZb3AKNq6yqM7q7KSDEZMVatd3vaJt76lh8fT8e34/Xy1/P26P/2xvvrxa/92 xt5ZlmIIl861Uxc1fTiXPpNFyR5CyrVAHYhNFRPEt7ObTgfZ0DrXS5TYd5tNanSL+NGEaT63brUS zjLpp3ZDmdGsgg3jJFtttpB1FSbNfAOv9AFhVNJj6+Uqi8HRVkJEY9ymZIkFC+5J5pYHeUrXNohY uYzxtRh4zaC+iHrCXqTEUz9YQzdJUFDGmZI/XIBEEHVnjBXRUP5xFIeEznrMkqSp0pDnA/wyrPHX /ZZLeJFWWeczSrtUAuCjB8Qi0QEoM8756guvq9VQ2zWkBm1KfEwtirgpxJLAaiHNEFZJxfD3AT41 D8IUAlrhU1gaOlXg08I1Z2oR8KpyVwTSQf7QPJNW0WvKHavC5MFdXQYcr4qCrKkvXa1KcA7RjFsf H3lRsgWlgaTBRZmPm3BVUxa8aUVPyNYGcejTasg9caNR59WSh0ET1k05v+NETCGNWpKfoAXQS4dY T6O0wA9Z4MUkSIaakQw2shBHAmm0PdgTYIQ5xJdH28839CgCW8U6KIcygVsTabArxorAZjWnlvNU SFGDNjCtIEZ0uOKWhKpJ+1oK1pmCkrEIudGVRmbV637/TUi5T/vH81W9f/z5cnw6/vjd30jTFmzS ehXkCXBAKs1HfM8olkHb+8tyi1pJt9pgY3GvPckMNLtII1rbvoWsMi4qTQzHtn3RipQzDQTyCfWo TNWblXkmTuexPEM1hLgRLcs8ZV2uVAjvJAmyHB8/erEF/0JRYjyXih8yzk2e362M47sGgr+gIjAD 2qiH3zYTc662VLgdv53M8GsiA1bx6XiC3984qOl7UIQehAGK4oh9JhwsmjAZ9KohIpYsN1XBsyS3 1VbUNHg6Pv5zVR1/nR4RbR2RNVvX8IQ3HfedKX82kJ31RcIk7pC9l10sf50oFZtTmG/7XIoowm6I QttdoK6GlBx5vjbkOkWzvL8qUv+qqqJS7V8gyuKVZF4Vux97+c59VRkrhPbQewFql9PHx3HIrVGn kPpqMS9Wi6UHSY12QAwaR7TtSM16hFG9kkWGpToGmX2q78RSOxaIIZuWTMnE6klv/3w8719Px0f0 3pGB3Ti83qFrJZJYZfr6/PYDueou0mph3XEDQQbqwm9MJVtewS2k0mKJquYpWCc497WzamFurkIk cd1JqUcD0c7/qX6/nffPV/nLVfTz8Pq/V2+gIPNdDJDeZFWFRnoWO4IgV0f7ylYHOkLYKt2b2luI ZD5XeYk/HXffHo/PVDqUr8wft8Wf89N+//a4E6P6/nji91Qml6BKZeQ/6ZbKwONJ5v2v3ZOoGll3 lG9+r8jRx5eJt4enw8u/Xp6deChGzLZZRyt05GKJO48D7xoFxolOyuSw4ePS3BbONcTmmOaE3ypO iFBZjasIr8VOTF0sFBtfTxfuFyFemXVm0kcgl2dUqwAH4VRBJQOl6vbUk9hq7uopbPkg1tW/32Tn 9gtDeyUJIe2sUAVR2tzlWSCVo4GJt2750BTboBnNslQqQF9GQX4kSi2gzFMQbTvHbkK3sYEQpazP +76KE9aq1eBf3zYNVR0kTpfH0/PuReymz8eXw/l4wr7QEKxbFgPrrUf8hHh/2MVwFU70s2nw8u10 PHyz3g6yuMwJ7w8abgg/PMzWMU/RqISBdecq704JRzgtr1ni8Q21Vor5s1M+UQ9im6vzafcIZrKI VFDVQ3JMvUQbi2RpXEsURKydmhGWBRkHZR5pnkjeCJJ+lBOeUomkeINIUsaxcpVRLmjS3JXS9AOJ MtSPzXV9fhC7hJoI5vNgFERL1mzyMm5V6Yxr3SDhcGnYzCtxVCorU7dSkMSpxZ5CYu0cCQa1ro4d Xs+ZQCyAZ4sADj6FACLzNJTvFFZM4AqCtUWJz6pYtCqVUqVZ+ITUm/oSxiPzmAO/SbAoIA1ll1kn I8ZF5wge0fgvHkvve5LRNx1+36/y2jh7bvHmAtlUS4TfeQbB0Fw1RoMDchgvbZayyrJI4lTMSriN q6Uldn9TN6/I7wshG0hmWA90TsaTgaTzEZ3ya54xqmehZcHWGq/ooAExxDyma0oTgkTV5OZ7Jbyg SkFLBUXrxKYsBtunB4I/h1eNqHwonAgpJlnIVgtLn0Rw16x0NFo7nhviLnYJXBGUenZfZODFxmsp 7dQHLzcpr8RClhnNdgak/AmPPfKQ313PmANFOv1ogZugzJx3kg6nENRcU9y6ZMZr3f08rZv1tUsY GQRIFdWJU2FBUZeBxpwBpzjzyl58FM0izeVaZBAiQUBe29BxCHFukuDBSt/TwLcfh9iATWzOSwwQ JJtAhvZLknxjdrYB5llMmLYZoK0YHLKZl4ApE92WF/4zXLR7/GkFYqz0imgT4I2sto41mrHkVZ0v SsIDnUbR/lY0Ig/hvNa4TpT0dwIMTEpravXUgQIMEFFXfaOi+kL1S/xHmad/xutYbrbeXisOD7c3 N5+ssfAlTzgzxuRXATLXo1U8V/i+RLwUpQCSV3+KZftPtoW/sxqvh+BZdUgrkc6irF0I/Na3JqCy DhGm/5qMP2N8nsMdgZAt/vpweDvOZtPbP64NHWYTuqrnM/RI4JavKEgJv87fZ51adVbrqWtIYPOh 7yzZ5QY/RA11pjr/v+1/fTtefcc62QtxJAl30tm6TVunLdFYPzty+4AMwXyw6OwSKU6m1oIniTIG eJpnXGxNDita8iQuWeamAMd+4GkNpu3KqDkEV7aCNdl643VaeD+xzVYxtkFtRrRerhZiJwnNDFqS bIGxzTJ1w83EgdRYwrVnuAVfwJtI5KRS/6hR0e/xc74OyqY11tBCmv8tu6J5pdSn1EOOtaLlJRgC 0meUIB7gzanTC5MHA7vSmiR6oqqk7oFZjyWVlWCAO0hnWoQDVQ5p1kCqSKyQaAWq+1VQLe3iNU0d meRiO5BSodQ+aIxCzQUjmrRowFmxfbnqIuTzGS6hYUg4DUUFdi/bwZ3B3NG/WmYjHTn5OkGpOULd fkWb8rWqCQ/+GjGRntFC+aTxldBH1FiWhiyOGaZE1Xd+GSxSJs5z7Z4OMR/GxuFnS4+JlGdiEaAk hpROuCxo3n22nQxyb6ipULZF9tuKooAFH4ub8EEd+g3TF8kWx3OHXoAvMOb+hu0pAXEZhlDJbDPj FiK+dcfG77Q0bvJe3DJ6F3I2Gb0LBwMMBdowo43DneDHw3Ny6AAfvu2/P+3O+w8e0AlX2dLl+4RL nNelEkZsslicPBqIj/1QaIli3mA0+AMKhR/cygHvDl405Ly4mSBsiJAotq1KSH8jhF0Mp25bP4BQ Te4AptrBmpomq4E1vsypCSSEvk1e3jl7oWY6cwt+m4KZ/D12f9tHBEmb2JhqY+qEKkRz7VGMW6Ii 03uGkGTylaGVKDlqMtu0eSJOeVgKXV4j/calXaB6CNCQpwHP/vrwz/70sn/6z/H044OXKuWL0gmN 2vL0PZUoMWSJ241KoDLWDyCDHNramsYZ+n1aEBzYINxO5nwe565HkngFb5JCzih8W1cBiK2uiMUX 9b5YDJ/VJWCoiUMorFOlJMlv034DmwOqpChDfzqUOdDRCzlrxB7Pc6ORUL770605tK3rLGukuD6P q1VWFmakJvm7WVSVR4NNCLxKZGYdW549BQRFtAkyae7KcGqdqxRef1SeycaDz8oIdLrR41mbpB0a /XmOFUt8FYi4fZiD30rUHxHoBnSZN311XJVnidmwQCyGGzjNLx3WqoCYLQ7ROXtJmpQ6HJrfso6K Pyv1fCl1NW4wGAtG1Q6ZwkJuDmhRgFpyE3OKJMZuaUu+SdXJ5Y2Qy62lw+R9HuN2cTbo8xSvSg+Z TT+RZcyI2H8OCFfvcUDvqC0VftwB4RpADug9FSeMUh0QrkvkgC53880N3c03uJGcBbod49pKNoiI 3evk9I7OuZ28o06zz5j9CUB4lcN9UTOzx3yX8no0MOwEk/7GQRVxfqHUazdrzaAbrhH0kNAIejxo BD0fNIL+lBpBTxeNoL9P1w2XG3N9uTXXdHPucj5r8BfNjo0rtQMbrPSEYEaoimtExIQEjysX9JCs ZivCY2gHKnNxfrtU2EPJk+RCcYuAXYSUjPD0rBE8Al9/+A1Ah8lWHH9LtrrvUqPqVXnHUX9YgICb W+MBKrGimIifQ87SMx7hIXN43mzuzUs5681aKX3tH3+dDuffvpEjbNPmBIbfQu66X4HXQOqKqQ3r ANcbAl/ybGHlUUMMGBZTR4D2Aa8FmBem4oS+bHKRuzz8Oyz55sajjtUf3/RRNU5ZJRV06pJH2NOG 8crtUKyLWp1fK7hZFxKwZNbqmCgETC/wGJFFs52XKVJCEVgRF0H1dxmUMctYLF8h4SFJHgOjwLqQ 9kADrGYuMoBzsnXx6aGgZaSP4rk4s8ODZ5WvSiraJoh4kcwPvN4tWVIQ+hdd6ysxtTPC/KgHpZT/ 2Q5S52n+QAQt1pigKAJRsQs1gqC/BeE/ugM9BISBcV/nYA5aYq5CkV+aEJPyTdYkFa2qs3Dfs3tu GjStaACOIfKym3hhnmPDXz8E9RMmMEyZRSX++vB797z7+HTcfXs9vHx8233fi+SHbx/BJOAHLCAf 3/ZPh5df/358e949/vPxfHw+/j5+3L2+7k7Px9MHtdrcSdH+6ufu9G3/AqpE/aqjDBL3Agt2Bofz Yfd0+L8dcI0HP7AFEMMpuhNzPnMUfzl49lJTwnD1RfSeAkMoCBKrrRvxKmk23aJOodJdYXVrtuK7 SPncfC6XpuV2BGFFS1kaFQ8uVeThkop7l1IGPL6RMbENC1650sJFuXpqPf1+PR+vHiGOx/F09XP/ 9Lo/GZryEgxaFZbyuUUe+XQWxCjRh1Z3ES+WpnKFw/CTOHJtT/Shpak/0tNQoH+/qitO1iSgKn9X FD5aEP0c4PLWh2oDaoLuJ7D1U2x0d4shnQp4qMX8ejRLV4nHyFYJTvSLL+S/Hln+g4yEVb1kmWUS 0XJcZwzOkOCpn9kiWYkdUm4tYDDs8VuXHa2iZ/Hr76fD4x//7H9fPcqR/+O0e/352xvwZRV4OcX+ qGNR5E4sQYuX1q2OJpdxhW8SurdW5ZqNptPrW7oLeoxsrFZf/XX+uX85Hx535/23K/YimyaWnKv/ Hs4/r4K3t+PjQbLi3XnntTUyQw3pXo1S/2suxdkvGH0q8uThevxpiny/gC04OO4ZaqbGiP9UGW+q iqG3Xe0nZ/d8jXT7MhBLeRe7LpTWOM/Hb6Yyja51iA20aI6FANPM2p9LETJzWBR6tKTcIMXlQ8UV qoo2cYuUJ468m9LWFNWzcqk/itefA9BgTXjn1l8KXAjUK0wTWfdAVfG1HoXL3dtP6iOkgT9RlmmA tBvrjLVCKs2cw4/929kvoYzGIz+lIisFZ68CkoknER8lgTXRn8fb7ZKKMdsiwiS4YyPcXsGCoJeh FqCd5F4F6+tPMZ9jVVccXX1vsUT3TmNC4wzpieFm4vHTGKP5+aRcTFiWwL/+zpvGYjFAyTefMPJo 6i/ygjwe+ehqGVyjRDFLKjbGWCJ3mjm9Hg2mJNJg5DEyi6sUvzDSbNDgDHNMw1Nvn4vy+tYvblNg lZBjoZHjpMl4O0X0qfDw+tO2mNRrt78qCVpTI2dDVpnZOsxsFXIkqzKaeMNdnJQ3c44MW83wHotc PjF6wSlvknB/o9eMSwnbHUwso+9Hjmgo3K7gLQGeP6skdbj0qvbHpKQOJYuRjyxo44bFjEozxw+A d8vgKyIKVEFSBch81ScMkkEVD/GJEWJZKKfMKF3ulHSGCjPQTQbEyMaf09gVfXfc9QdfvcnR0d7S qSGi2URlbXYz3gQPJMZqs1oOjs+vp/3bmyWTdyNDqqn4ByFTGaulzSb+MmSpcvW0JXZqc3W2lNXt 7uXb8fkq+/X89/6kzJqd24Nu0YG4FQUmE8ZluHBcMZkc9KSiONh+KjnYIRIYHvELB3/dDIwHC/+j gGDXYLK3ZuBV6LikfN0hsP7omK0k729FAeqeTp/sYGfh2dy9ZXg6/H3anX5fnY6/zocX5JyY8BDd YyQd2xxatdU1k5D21OShDJ7hB47EXChFLUZoHRWrK4OGXCqiE/PQehpS4FBzLuSCrfNA7059pdSE ur4erCp5eLSyGuqRLge0Da7QiYGI09cSE8XAxLIIYtdrBAYL6hRMYiPCD4gLhFp8mmDu4AxoFPmX QC29iWOvdTI0bzGYSv2kUhYVJi92JSrnCpfadw8mA8vZ7fTfy30B2Gi8JeJ3uMAbwsU+Ufga92yG Ff9OqKjAZWTGxeK8baIsm063mM8OA2s4ZEA+SDBn24jhrnHMAZUm+YJHzWKbIKUF1UMKIRoFAF7B QCGpHx0Gs1iFSYupVqEN204/3TYRK9sHNNbbpfYPW3dRNQMTtDXwIReFwV7/BPRzq09PZfVZhR2j ImtVfAGPTwVTCodgtKef9rwtP9qfzuCVYHfev8lYL2+HHy+786/T/urx5/7xn8PLD9NnK+hXmi+Q pWVW6PMrQzu15bJtXQZmf3npPYTSI518ur3pkEz8Jw7Kh4uV6WPVX0bIzRb+B7XujZve0UU6y5Bn UClpbDjXW3ZC7tXqVcF8bdCUJmRZJA5L7gOpNOREhk0o5hUDj6BGd2qnCELazSJ4qizz1LneNiEJ ywhuxsAsiptqX5o151ks/ipF74kqWOtjXsaEboHonpQ12SoNcRem6oXaDLnc+XcAB6u55ZFVsxyy 3FpB8TRKi220VGqTJZs7CLDTgSCDyryiSLjZ/i4PsRCIM2+W1+7TeVRGYvUXx06LdH1jI/w7JlHd etXU5lajLtCMJQzuzrQDY3ShlACxLLHwYYYkVRzCf5SCBOWG8timEP9f2bHsto0kfyXHOewETtZw tAv4QJGUxBVF0k0ysnwhPInWMDJOAlteGPP1W48mu/pFZQ4B4q5Sv1hdr66qXhaRoa8sBdJWJ9NP Ili1WPr+xHQh0stvtdY9jaySKqt384uXmQOmZ2zlbBm7HVNfUIm2ras71tycVpkNYbeGepY5EVar yICwsUO93N5hs/u3fQej26hMSOPjFok0VXVjIsMiTFu3gZPnAVqQNX6/y/Q/Xht+E/MBzYKG9V0h TqAALAHwMQgp72RRKwGgXKMQfh1pF8sfWUIgtkNRGb+6rC3LX7ZiBM0iAoIBBYjyzD/jW7+YD252 KVEqOTBDkcpEW6cF8A9Q9gnBgJAHAfeS9Ui4iZ74trgatltlwCqaHpfPBwa+lhEvBKPi9ElDdqab pEg197NMDd1wdcns2+ONtcJMT0Dsqym0SIjQPVdmNp8EMNN6Q1Y4EGtdOiCaO98+HP97//rnCR8H Oz0+vOJzu08cJ3D/fLwHIfvX8d/CqsVwDNACht3yAPR3feEBWvSKM1DyQgnG5DnMllhHWJ7VVSRQ xUZKgiosbmsJShimZlwvRAwaApoiWl2gXZdMs4JZNv2gLBLIbqRcLOulXC7+Pcc3q9KOUC9VPziJ 8ml5hzFYgszVDRqWYtRdU1jJhHWRDVj8FbQIQdZ92n5ExcLSucjYHc/n56yt/VO7zjt8NK9eZfKQ yN/Qo3qDlMOrGr2QU66ICK2qgt4Vwl+8LZweFm9SdLdrh4KnU9FgtSDLlQQNXP42gN3rSharsm83 Ywh+DGmXomXjIFC8zj6RBS6pKcsb+XxgC2fYqX/D+x8kiUnB9fRTO85oNAKo9efz4/fTN3oY5+vT 8eXBj3kk3XdLn8hSXbkZ0xKCdk+qc8rAWitBkS2nGJJPUYybHssUXJpPwDaT18OEgZFb40QyTM4R p+pQJfjenpOOZDUPdqI8vwMPwFwpwJJvmRA2/PuMdctb3ge92dENnNzDj38efz89Pmnr4oVQv3D7 s7/dPJb2EBpOM7VitY4+jVTLFmijJD2P2YKWHA6Am1CyfaJWl5EJLbtV4NfrbIlVgorGrs6RVxRv s+vxSmeTB5/VXSnYfSrqcv3h4uOlTfwNSF6s7BWpLqvyJKMRkkiU4AYQwErhCseRgtG8uJZfP8TU /F3SpaEoZReFJo2VkA7OwR7rXDmvKfJALJM5N4kf8wwe61+mJaveqT722fGP14cHDMYrvr+cnl+f 9IMw41lL0KcCBrS6ETzQNE4Rgfz9ri/ePoSwwNospJnnwzBspQfFIxeOBL0LrSNViFNugY5Mu//X 2G06JfCa4GwEx16LISAmjDFr6ZQUyQTcWkNly5ktQOg2PyzrRGX2b+C/XVH1WH+gA6tU1c2mSI2y M0mLPFHlwWVWRpYs26QC664qOtRUOBPMxLojNEgxv0QD9lfgtE6fRrE+heds0nGgU7+yoB7Ffue3 XV61sSLy3DMikpIUdi1gN/W+ikRHE7ipC6yfHikAZUYB5hD2ZzKKquGAJrFAu+ljMPL+1hUPsmVy b3SY3Wfa+W9H7uhGU83XmRcXIIrUAyz75YgWCcRGjNilFJ0z/eFB4ymBBfnjj5A5Vkk8rm8dTXyc AjD6TOPkVcZ8P0Dm3Nfn3dCsvSLGI2xmEuaH5z8fuqL7JEDnGjAzDJdopXjpOXpjRo6mWnTjmcEl cHqDnA8BGN/lGBApLYOh/t0RQzGLAtXEqjZMA+xCp14E9RHijdQ3fa/rD17UtzntHhVsnDeqtF0I +O/qHz9f/vGu/PHl2+tPFlub++8PLzbHwDcQQJrWdXDPLDgK1D43nJSBZGf0HagNk0FUp9seD1cH Z0g6Dtp61fnAaTKoWjYJKCISkQYJOWujyO40MZPEGRVJZSUJYMKgc0Jrgm+xa4I483MXiOfn7iK7 c+ehhg0+yAHCbCsZIEvGCWQ+xMeL4LwmxF+Ylo3rzmp/A0oXqF5ZbSVg04UKryYoGuepktPAQMf6 +oqKlRRwFk9zBDY3uro7tXoc2ORCBIZxTxZu5zbPG0fG8W0EBvga0f7by8/H7xj0Cwt7ej0d347w n+Ppy/v37+Uj7Vh4kvpekznpW9qNwif5dKXJIKOjPnBdczIVHfFdfpuHxZfmG4GnClyme7aT/Z6R QODVe8wUm5vVvs0j9gMj0NLiSgkjjS+6l/BhzvSFe0whJ6H3C+0NhbPcYZKSb92PBD8tdNYH8Deo wrJUxto2Zjw0aWAvhr7CWDIgcHbozyx5yypLRBRwLZN3X+9P9+9QDf2CV2+WJNAbV0R2QEvYM/B2 Th3k9EjntsowKlKnBlIHQVdTfePetTp8JLIkd9QUbPccX9UpW29vVNqHFWmF77SAiIhTBGLEyEag oDpCNu/Ena8unE6U9waOgOY3wSqH49sK1vy903mjrVwVsG9tLwudAjAc8LY/Uq4aFrIB8VCy5kmF oOLP6uB1UJUenDePRtsJo7kM3QfK09QNb4tydLRVX7HtPw9dg2G5CeOMvii3nFQAOOyLboMuWddG DqHpYq7omXPRNdqOCn5T9ps0WAkFCz0SjSAmWFZV53WCAXkHpzHVvXHXBsgrp/pUzjJ5KqlTDQ05 5bJfreRu0atnhG+5nvGjI520sOrU32MPfzTKIoj+t195vBC1EvJV69+EnFcxujhDEjFqOE8Iv04D 0xRAuGMoiVSHyTqbJmXSQtUN6LQrDYkadx6B7+HYea34VqizvLGwGFNd6xFOW4EBtakt1cQBTbYW ljAKqZIgr4A+9Jq9LNmxXccDYEIw/SCibUzocEZCiOOgJZVIxHIDzoq30MMyZ6K2zTEJQPlT1R5D HtmW08c4aLPy2kbqcNtjs8A+9EywTrMqglUU5hnJeKKse672UAFhutPAyseAX6zXIIy9j6yP/syT GYZNmQibsAQznOUM5jhyUtJFK37tIN5Iul0CoreZEc9i5LPI0xGJozQqz3egkZBXFutoRzHFliP3 iyNK0pvHtL7XTAEONB+AdIZ6kxYf/vmvS7orjfpM2gQr351xlKSWo0Q4dOitj0JXAMutoGwubqFx PJ3rbXEVsu14//Et6jJZt75cYGetvnfqWxl6sbga9B0RyQr5VJ38lXUjInvLlusQC3NHHG4zO3cz XxXo/PJKOLt2ZLmkS8vYRhvqC1iEuDiM0MiQjoO2xygzak2YF7eLcNEngREsDDvB+/Faz/8p8vE5 PZLuBtGDEInhbQKvAjh9kKIzZ0Xsivmd4C2j242I0stvOaIpGY0i6Ks9Ft1XQ62sbz61830ZMUHX Ta6Vc5vQ5XVwd3w5oYGIvo/0x/+Oz/cPR2l9bPvYmR1NKLwurZXm0eECL5Pe4aAKNYBrrguAYbNJ UbZlEk4aRSD79j1rXWLskm0+1ulx+yYRzQZRfIgVWtwRsDXz6TJrzge9xaoTrs8WuBs0a+bTWF8a 8cOiBaQvqaOwLhK4eRUmM+B+UVfBLCV4NT04euD/ze9Y1x4vAgA= --=-wcGsDl5UGiQ0QHk64jS9-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wFq8AGgSEF/n6QEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 10:40:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8BBlOmcSEF/ocAAAlp8NpQ (envelope-from ); Thu, 16 Jul 2020 10:40:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8618952ACB; Thu, 16 Jul 2020 10:40:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726332AbgGPIkA (ORCPT + 1 other); Thu, 16 Jul 2020 04:40:00 -0400 Received: from mga06.intel.com ([134.134.136.31]:40635 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbgGPIj7 (ORCPT ); Thu, 16 Jul 2020 04:39:59 -0400 IronPort-SDR: j0g+K8vpftdLJYkRZ3XcTxXLv97uJIJTNxIJhe0d5WsHrWMkPc3o/EhGDMp7DE+jltoLjkbWd7 x58g1Qf/giyA== X-IronPort-AV: E=McAfee;i="6000,8403,9683"; a="210873151" X-IronPort-AV: E=Sophos;i="5.75,358,1589266800"; d="scan'208";a="210873151" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 01:39:58 -0700 IronPort-SDR: DO4grs1kzSEN8kymiXuKTbLJzHvkFMPRI5n3Pf99jjTXY0pCM8jBY35ovOtwhQ+9y6lsz7Aruk 1uNOBo5w8+kQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,358,1589266800"; d="scan'208";a="430421729" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga004.jf.intel.com with ESMTP; 16 Jul 2020 01:39:58 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 16 Jul 2020 01:39:58 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 16 Jul 2020 01:39:58 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.171) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 01:39:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=al+oJTUuGotkFuv2wHAw+872P8+2aS+8r+glg3hPfxEuGs8t0BJcQYZPVKz35bn8uVvkYAxenN9njTzadwdXsI9Dv2aDUnGUh73QYtYZN0KKjBgotJVkpjHAkrbhJ8DhASAe7yzs4yoRTuyWoLcmAwV+MPPxsgpGnqJfvNqnC58crU60y0ZlqVB9UQe47hl7AJhp0ouqrWKm+Mdxi22VDawtx/PIbq5nwXtub3I3g1eUsGdEqo7OF8VHPsJy5YzqMoOtgPrJy6juVl9xVTiqO+rzchPh/ONb1NFNB8je3jcRvNv/zjdWHjHLjInrAZ5/wvvdhPSbSVOVggSzqe/csA== 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-SenderADCheck; bh=XQE21eNy0iUx1ymkuQZ+uH7HhH5R4icOIWoVX1v/tLg=; b=Opz8boVl/26pcyE/bdYbK842rCIsSHKQZtXexCHJ/y1KStL6LRqgqOX/T/C9J25u5MEjy/Q6IWJHfJQC7Ytz/AoYP2VaGuENyiuMYLxJzX2ssza5OoUchCXY+WBp7ySrCzz/rmk0NhvZ7QHhC2W3AIeI5VytwCqIVpPLC0OQEXyZ5ys+rJ7bWpgr2r4BfIDEBKALnVwyZqmvc0zQBBHar78jNKOhIqQdhD0bR40srHBqZWIXh1wjAhViNmgs2XY9hY2mEnGwgcRd0olX3YQHIMsI2B0ykMjhF22GF2SVqnA+sTNb0GdBnk5tw4MpECWcrMKHm0AUPmQbL9xMPM/uCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XQE21eNy0iUx1ymkuQZ+uH7HhH5R4icOIWoVX1v/tLg=; b=BfzcJit1nWue6tTqgbOdJvNUylvP5GYssYyO1ULlfmUalhusLJmEVcAAYMOllHLCZfbz8S2JTCGzu7w0yP4XvRfetYK7mIQCAmux48FzEklZrXLyyqjPDjMhw9/Rmnx7Fn9dm4DtrB6r7ZAxpT37qlDAKsa/SU/M3ZtNThDTnPo= Received: from DM6PR11MB3369.namprd11.prod.outlook.com (2603:10b6:5:b::16) by DM6PR11MB2937.namprd11.prod.outlook.com (2603:10b6:5:62::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18; Thu, 16 Jul 2020 08:39:55 +0000 Received: from DM6PR11MB3369.namprd11.prod.outlook.com ([fe80::9064:3ba:cdd3:793b]) by DM6PR11MB3369.namprd11.prod.outlook.com ([fe80::9064:3ba:cdd3:793b%7]) with mapi id 15.20.3174.026; Thu, 16 Jul 2020 08:39:55 +0000 From: "Singh, AmitX K" To: Luiz Augusto von Dentz CC: "linux-bluetooth@vger.kernel.org" , "Panda, Bharat B" Subject: RE: [PATCH 1/2] bluez:load Generic access service Thread-Topic: [PATCH 1/2] bluez:load Generic access service Thread-Index: AQHWO0WRIU81EbuT4k+8k2uG05Vf0qjKP/IAgDzW7xA= Date: Thu, 16 Jul 2020 08:39:55 +0000 Message-ID: References: <20200605142541.28412-1-amitx.k.singh@intel.com> <20200605142541.28412-4-amitx.k.singh@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [49.207.200.9] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 843b46c9-1340-40f1-3b72-08d82963d0ff x-ms-traffictypediagnostic: DM6PR11MB2937: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: iVZuDbTvLQDcMG8BAKh5lca08LIIvhpg4TaErvxPDlVt7kX4Fu/7hWCEJ8ggCz/gMZwGqsOVPn6ueAXtHofvri5oH5SsSVxZdLtI8Fy4a53U4xEXrq/xOR1EZdyj8DFSzpImjipjtxxlIQ2YKrinu4VKYlHos+jOEGt7FGp2T+GBrFMwIrRFCZSFm3oeWZIgRC3kVoLRK3qeoyBXj/n/Hpvk795V2iQVSm8Gy8R8P1FApKaGF4kCPE7SAptii0mjNQhkPsRvYsh1m8zUWM5vBszGPtyNvjTjAQmYGsneYl1zVZnU0L1aqYgl2c1+sZBmWQGqvsxIGZW/UFKz/m0cp/3Z9fWEOM4l2e21I1W7m4z9XvQNalrEykbukpVmokPa x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB3369.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(39860400002)(396003)(376002)(346002)(366004)(6506007)(66476007)(64756008)(66556008)(26005)(54906003)(53546011)(6916009)(186003)(478600001)(7696005)(33656002)(66946007)(8936002)(8676002)(86362001)(5660300002)(9686003)(66446008)(55016002)(2906002)(71200400001)(76116006)(52536014)(4326008)(55236004)(107886003)(316002)(83380400001)(41533002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: jmXq9r3NsHpkQDiehkjWQnB+UlSbrVbXG1DG4vyYOQPjlzgnoitg1MIVW4Z7eNduo9RZe8zd97jeGFdAhTlsYZJ0Myo5FNnhwTP7PxhxYr34l9PD4MZkHf92+w5pzEQ9sbKQUCaRMKU3ZJulAPHqt2Tjvn0A8Cx/eNwM/RKuXoM9bgkwAVb0CdXDgSsvib6JQi+frUcrtYFkro+luDyyM/ugigUIPD/zlGGp2Wt7ujm+sUrxp0AL4TOd01Ovf+JLmwfA7qmVQHfnm5Me6j8+spNpmFVhSifggDBBYloa/x0FqcWPhEdIFp6r3nl4EvfEbWK3pw7TFMcu60Wm8vj7191cUW1rBUEhmbbbXz/QGs12vLznrOzCLQ7XBjVCUaDWnGUhu0aiqBNq9Nk/dl3vDDO4Jl/DV8sdOFQwxrp848h2JOBmrkuoBq3cp8gbXduY4zKmgybdMxYh0e1eM8DlZyDNAZ52ASnYsnVvteJTWC0= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB3369.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 843b46c9-1340-40f1-3b72-08d82963d0ff X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jul 2020 08:39:55.7354 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Z0yb8C8ZAIz5GT8nziJ8ZSFYasxpjFyr0LT+4kRy9lTk6FWpRdT7+3CA5cFUnaeiNvZPnpSeryy2UjImNmJT+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2937 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8618952ACB X-Rspamd-UID: 5934fd SGkgTHVpeiwNCg0KPiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBMdWl6IEF1 Z3VzdG8gdm9uIERlbnR6IDxsdWl6LmRlbnR6QGdtYWlsLmNvbT4NCj4gU2VudDogRnJpZGF5LCBK dW5lIDUsIDIwMjAgMTA6MzQgUE0NCj4gVG86IFNpbmdoLCBBbWl0WCBLIDxhbWl0eC5rLnNpbmdo QGludGVsLmNvbT4NCj4gQ2M6IGxpbnV4LWJsdWV0b290aEB2Z2VyLmtlcm5lbC5vcmcNCj4gU3Vi amVjdDogUmU6IFtQQVRDSCAxLzJdIGJsdWV6OmxvYWQgR2VuZXJpYyBhY2Nlc3Mgc2VydmljZQ0K PiANCj4gSGkgQW1pdCwNCj4gDQo+IE9uIEZyaSwgSnVuIDUsIDIwMjAgYXQgNzozMSBBTSBBbWl0 c2k1eCA8YW1pdHguay5zaW5naEBpbnRlbC5jb20+IHdyb3RlOg0KPiA+DQo+ID4gRnJvbTog4oCc QW1pdFNpbmdo4oCdIDxhbWl0eC5rLnNpbmdoQGludGVsLmNvbT4NCj4gPg0KPiA+IEl0IGFsbG93 IHRvIGxvYWQgZ2VuZXJpYyBhY2Nlc3Mgc2VydmljZSB0byBkYXRhYmFzZQ0KPiA+DQo+ID4gU2ln bmVkLW9mZi1ieTog4oCcQW1pdFNpbmdo4oCdIDxhbWl0eC5rLnNpbmdoQGludGVsLmNvbT4NCj4g PiAtLS0NCj4gPiAgc3JjL2dhdHQtY2xpZW50LmMgfCAzIC0tLQ0KPiA+ICAxIGZpbGUgY2hhbmdl ZCwgMyBkZWxldGlvbnMoLSkNCj4gPg0KPiA+IGRpZmYgLS1naXQgYS9zcmMvZ2F0dC1jbGllbnQu YyBiL3NyYy9nYXR0LWNsaWVudC5jIGluZGV4DQo+ID4gMjBjM2ZiZWMyLi4yYWUyNThkYTAgMTAw NjQ0DQo+ID4gLS0tIGEvc3JjL2dhdHQtY2xpZW50LmMNCj4gPiArKysgYi9zcmMvZ2F0dC1jbGll bnQuYw0KPiA+IEBAIC0yMDA5LDkgKzIwMDksNiBAQCBzdGF0aWMgdm9pZCBleHBvcnRfc2Vydmlj ZShzdHJ1Y3QNCj4gZ2F0dF9kYl9hdHRyaWJ1dGUgKmF0dHIsIHZvaWQgKnVzZXJfZGF0YSkNCj4g PiAgICAgICAgIHN0cnVjdCBidGRfZ2F0dF9jbGllbnQgKmNsaWVudCA9IHVzZXJfZGF0YTsNCj4g PiAgICAgICAgIHN0cnVjdCBzZXJ2aWNlICpzZXJ2aWNlOw0KPiA+DQo+ID4gLSAgICAgICBpZiAo Z2F0dF9kYl9zZXJ2aWNlX2dldF9jbGFpbWVkKGF0dHIpKQ0KPiA+IC0gICAgICAgICAgICAgICBy ZXR1cm47DQo+ID4gLQ0KPiANCj4gVGhpcyBpcyBhY3R1YWxseSBkb25lIG9uIHB1cnBvc2UgaW4g b3JkZXIgdG8gYXZvaWQgZXh0cmEgdHJhZmZpYyBzaW5jZSB0aGUNCj4gZGFlbW9uIGFscmVhZHkg ZXhwb3NlcyB0aGlzIGluZm9ybWF0aW9uIGluIG90aGVyIGludGVyZmFjZXMuDQo+IA0KDQpHQVAg c2VydmljZSBpcyBub3QgZ2V0dGluZyBzdG9yZWQgaXMgaGFzaCBkYXRhYmFzZSAuVG8gdmVyaWZ5 IHRoZSBQVFMgdGVzdCAgY2FzZSBHQVRUL0NML0dBRC9CVi0wMi1DIHdoaWNoIGlzIEdBUCBzZXJ2 aWNlIGRpc2NvdmVyeSB3aXRoICcxODAwJyBVVUlELCB2ZXJkaWN0cyBhcyAiSU5DT05DTFVTSVZF IiBhcyBpdCBkb2VzIG5vdCBmaW5kIHRoZSBHQVAgVVVJRCBpbiBwbGFjZQ0KDQo+ID4gICAgICAg ICBzZXJ2aWNlID0gc2VydmljZV9jcmVhdGUoYXR0ciwgY2xpZW50KTsNCj4gPiAgICAgICAgIGlm ICghc2VydmljZSkNCj4gPiAgICAgICAgICAgICAgICAgcmV0dXJuOw0KPiA+IC0tDQo+ID4gMi4x Ny4xDQo+IA0KPiAtLQ0KPiBMdWl6IEF1Z3VzdG8gdm9uIERlbnR6DQo= Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8GO0Ln8SEF+EKgAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 10:40:31 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UFwSLX8SEF/ocAAAlp8NpQ (envelope-from ); Thu, 16 Jul 2020 10:40:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E5F4352EC2; Thu, 16 Jul 2020 10:40:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726514AbgGPIkY (ORCPT + 1 other); Thu, 16 Jul 2020 04:40:24 -0400 Received: from mga14.intel.com ([192.55.52.115]:41393 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbgGPIkX (ORCPT ); Thu, 16 Jul 2020 04:40:23 -0400 IronPort-SDR: eYteHwnVFp7qnvFqOpIp6kVC68NPBND9FaieR6Uk0OjhQ04RQaC5IvdtXfdqnfiDDkDxGbaKti NAG2OwmnY1Nw== X-IronPort-AV: E=McAfee;i="6000,8403,9683"; a="148492488" X-IronPort-AV: E=Sophos;i="5.75,358,1589266800"; d="scan'208";a="148492488" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 01:40:23 -0700 IronPort-SDR: lWD+dpcfCCjzuCdHxcvtpIs3QM8GuLmWfXN3C0tbOqBwnt3Tyydrp19fdanfFrnf5MuarhImxE Su7XIkYP3xHQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,358,1589266800"; d="scan'208";a="391035638" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga001.fm.intel.com with ESMTP; 16 Jul 2020 01:40:23 -0700 Received: from fmsmsx126.amr.corp.intel.com (10.18.125.43) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 01:40:22 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by FMSMSX126.amr.corp.intel.com (10.18.125.43) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 01:40:22 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.169) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 01:40:22 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YbMLHaa0kMGDCyq+cB74UzLWr9DWKDaUZ+MI4+bigUT06ITrTSlL34XRpCxVXyQROIZnWhkixySbevUcPW+nz2NlLd41jYqlqzrdWjAf7TvMHRy63LT1/spG8sjsxO50UR/HrVpbSezLeOIqCmsl3B0FLGqfElgmmD16nWtmlLsQmf9lmu0O66cIAeZ4ZjaoFyUwkRzhSUxEbH//zqq+70SiP8ZomzKzQ8QKUETeUfmhMxOJD4Izv1KMwCqecbanMG8XcS4CutUP6oVs5bqZNV25WDKGe4J4NAquhc3jQ4RlusmWHS0OtYCKZ73W1SFIxPT/Jda3WyBtCz9Ece1OQA== 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-SenderADCheck; bh=+4cw7rpC0qCAMHoY/5HqxFqHL5DuLQY4t9FESOL/1zI=; b=Wgt+p0q2vDeTji4LBVriJFY7e3mwxVM7nxB77q8VAwyOwLeOW5eeWtDgJ9FPPT65V+70pb9Bq6WzCKHQGGkmlKnOnhXmUiJt6okaZY/8KaDuKso6aMXAH79pW21RvYOPDat+CF9Crnr/8BhYb/Vj+GHpqkMVrCGSfH4TFkRVl86ZDH1b5yPQw8xdRNwhsePNqJ/pgsA04incVIkECEZXPNKcRT3K1ZfEAO5HNQlDzB4Ah5ur0gtjFEn8gjQ7s27Mdt3AU4DAYZHLJnfUqWeTE6NSzSnYhH7f+NvfJzid4ElID/ej8qXZz3WWHK+2QxYx3yi6yOmM14Y6hyodFKpKZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+4cw7rpC0qCAMHoY/5HqxFqHL5DuLQY4t9FESOL/1zI=; b=lL1mM/wT+FzN7O9rsCvJK0oVvOqhrhc5X0LvsMkbjv2TAZ0k7f+uQoItYjiiX5HwgXE2lP7T1L292YiLDWo6KkTjQm6Qd7nAAmH8NaU65DiqkEfaEVSF528ht9gKNNN/ifIiEwgcRVbCSufmd5q9oK+glkUZe/Va0QdOldJLe/s= Received: from DM6PR11MB3369.namprd11.prod.outlook.com (2603:10b6:5:b::16) by DM6PR11MB2937.namprd11.prod.outlook.com (2603:10b6:5:62::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18; Thu, 16 Jul 2020 08:40:21 +0000 Received: from DM6PR11MB3369.namprd11.prod.outlook.com ([fe80::9064:3ba:cdd3:793b]) by DM6PR11MB3369.namprd11.prod.outlook.com ([fe80::9064:3ba:cdd3:793b%7]) with mapi id 15.20.3174.026; Thu, 16 Jul 2020 08:40:21 +0000 From: "Singh, AmitX K" To: Luiz Augusto von Dentz CC: "linux-bluetooth@vger.kernel.org" , "Panda, Bharat B" Subject: RE: [PATCH] bluez:update handle for large database Thread-Topic: [PATCH] bluez:update handle for large database Thread-Index: AQHWO0WTQMBYhmarxk+ML2/6wbSJqKjKQ4eAgDzUj4A= Date: Thu, 16 Jul 2020 08:40:21 +0000 Message-ID: References: <20200605142541.28412-1-amitx.k.singh@intel.com> <20200605142541.28412-5-amitx.k.singh@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [49.207.200.9] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f63a6cb2-1cb3-4bc0-e126-08d82963e01b x-ms-traffictypediagnostic: DM6PR11MB2937: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5516; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: QwbKcObPddTrZhzIJs8rEPXpo39PCwE08eApQNPQJCmztI+7VnXQA8UqE5uAszA6XfCm06nOEGfgQGB21GtyLutMEkqja1YAk+7+BeBvAV6tty1W86ZylJCj3AqBj5O4TDgaTqE4dWPbpvxXxsSL54PIDH1CJnnk5W9FvavCwKoMon783Si+CEAq4lvpvvr+b5AUG9ucOv1PpVZaQ+HeXkjaGu9rQxGbRek6/SEyetUwfCDjtK/9K4ySNaPkc6/kaE0uoP8vnzPbqqCfcjsy1QbF8V51+K4rtGkI6HLWHOjeKQE6jO8UvpL3Rb9fjjwgtsPzWeLLykwwqhqdhlEXkCQ0sF9ksUtvZ2Im9ElDyqL/gVamlweUjhRSLLFptEYS x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB3369.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(39860400002)(396003)(376002)(346002)(366004)(6506007)(66476007)(64756008)(66556008)(26005)(54906003)(53546011)(6916009)(186003)(478600001)(7696005)(33656002)(66946007)(8936002)(8676002)(86362001)(5660300002)(9686003)(66446008)(55016002)(2906002)(71200400001)(76116006)(15650500001)(52536014)(4326008)(55236004)(107886003)(316002)(83380400001)(130980200001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: s/v1751dwvaR3+hw/K0Kcf0t7jG8KKDe+XoFQemITEMAQslVUT2NZgRK1KLEOnsJF/BS39B4IY88a22rqVbeVQZJrhEjUKHe2LCnIqL4nwhOxfBEJpbNk1oaHZQJTK5TKrygxLvWZAD7icTcUgE2+GuIGYRYjjqB0rdsm8vWV+ibobouTOaFzAMxvjxdCQf6Qas9oQsExtEyAcUQmNL4tGmNMl5JXHBfpCT2aFMB0a+XqYjr/HyhCahpH2HsrmagpTsrSh36zYBMa8eT/BcgAR0a1IjF4KcuENEjIqPQl+/37hHw3g9Tx2TSVq7J6h6giLt3HB0Pjsq1hTUwIhmwWatTC8eUQM4xu1B7sVu3KEkp4+Flsvb0Oqz1ayozcLhG30YuQDmhK0IhGpGA+pxc6RNaDRgZiC0oj1Z5vDcaOiGIPC1fo6ZvvBabIeIxCZjjBiI6M0n9Bw/IIGTuSPxBHM/AWuxhDneY6HOuNtoTZ1g= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB3369.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f63a6cb2-1cb3-4bc0-e126-08d82963e01b X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jul 2020 08:40:21.0530 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Je1lBGLzn5DFRnA9YSdxFh2+/CwwCTKg14RfjWNKwzU4fMklxiNCwYjAHh8VU/exo0vntWqgsrvKbry3yzAX/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2937 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: E5F4352EC2 X-Rspamd-UID: 6d50bd SGkgTHVpeg0KDQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+IEZyb206IEx1aXogQXVn dXN0byB2b24gRGVudHogPGx1aXouZGVudHpAZ21haWwuY29tPg0KPiBTZW50OiBGcmlkYXksIEp1 bmUgNSwgMjAyMCAxMDo0NiBQTQ0KPiBUbzogU2luZ2gsIEFtaXRYIEsgPGFtaXR4Lmsuc2luZ2hA aW50ZWwuY29tPg0KPiBDYzogbGludXgtYmx1ZXRvb3RoQHZnZXIua2VybmVsLm9yZw0KPiBTdWJq ZWN0OiBSZTogW1BBVENIXSBibHVlejp1cGRhdGUgaGFuZGxlIGZvciBsYXJnZSBkYXRhYmFzZQ0K PiANCj4gSGkgQW1pdCwNCj4gDQo+IE9uIEZyaSwgSnVuIDUsIDIwMjAgYXQgNzozMCBBTSBBbWl0 c2k1eCA8YW1pdHguay5zaW5naEBpbnRlbC5jb20+IHdyb3RlOg0KPiA+DQo+ID4gRnJvbTogYW1p dCA8YW1pdHguay5zaW5naEBpbnRlbC5jb20+DQo+ID4NCj4gPiBVcGRhdGUgaGFuZGxlIGZvciBs YXJnZSBkYXRhYmFzZSBhbmQNCj4gPiBhZGRlZCBjb25kaXRpb24gYmVmb3JlIGZyZWUgdG8gYXZv aWQgZG91YmxlIGZyZWUNCj4gPg0KPiA+IFNpZ25lZC1vZmYtYnk6IGFtaXQgPGFtaXR4Lmsuc2lu Z2hAaW50ZWwuY29tPg0KPiA+IC0tLQ0KPiA+ICBzcmMvc2hhcmVkL2dhdHQtY2xpZW50LmMgfCAx MiArKysrKysrLS0tLS0NCj4gPiAgc3JjL3NoYXJlZC9nYXR0LWRiLmMgICAgIHwgMTUgKysrKysr KysrLS0tLS0tDQo+ID4gIDIgZmlsZXMgY2hhbmdlZCwgMTYgaW5zZXJ0aW9ucygrKSwgMTEgZGVs ZXRpb25zKC0pDQo+ID4NCj4gPiBkaWZmIC0tZ2l0IGEvc3JjL3NoYXJlZC9nYXR0LWNsaWVudC5j IGIvc3JjL3NoYXJlZC9nYXR0LWNsaWVudC5jIGluZGV4DQo+ID4gMTlmZjZhYjY1Li4zY2I2YWU0 NDMgMTAwNjQ0DQo+ID4gLS0tIGEvc3JjL3NoYXJlZC9nYXR0LWNsaWVudC5jDQo+ID4gKysrIGIv c3JjL3NoYXJlZC9nYXR0LWNsaWVudC5jDQo+ID4gQEAgLTExMzEsOCArMTEzMSw2IEBAIHN0YXRp YyB2b2lkIGRpc2NvdmVyX3NlY29uZGFyeV9jYihib29sIHN1Y2Nlc3MsDQo+IHVpbnQ4X3QgYXR0 X2Vjb2RlLA0KPiA+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzcyA9IGZh bHNlOw0KPiA+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ290byBkb25lOw0KPiA+ ICAgICAgICAgICAgICAgICAgICAgICAgIH0NCj4gPiAtICAgICAgICAgICAgICAgICAgICAgICAv KiBEYXRhYmFzZSBoYXMgY2hhbmdlZCBhZGp1c3QgbGFzdCBoYW5kbGUgKi8NCj4gPiAtICAgICAg ICAgICAgICAgICAgICAgICBvcC0+bGFzdCA9IGVuZDsNCj4gPiAgICAgICAgICAgICAgICAgfQ0K PiA+DQo+ID4gICAgICAgICAgICAgICAgIC8qIFVwZGF0ZSBwZW5kaW5nIGxpc3QgKi8gQEAgLTEz OTIsOSArMTM5MCwxMyBAQA0KPiA+IHN0YXRpYyB2b2lkIGRiX2hhc2hfcmVhZF9jYihib29sIHN1 Y2Nlc3MsIHVpbnQ4X3QgYXR0X2Vjb2RlLA0KPiA+ICAgICAgICAgdXRpbF9oZXhkdW1wKCcgJywg dmFsdWUsIGxlbiwgY2xpZW50LT5kZWJ1Z19jYWxsYmFjaywNCj4gPiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGllbnQtPmRlYnVnX2RhdGEpOw0KPiA+ DQo+ID4gLSAgICAgICAvKiBTdG9yZSBpdGhlIG5ldyBoYXNoIGluIHRoZSBkYiAqLw0KPiA+IC0g ICAgICAgZ2F0dF9kYl9hdHRyaWJ1dGVfd3JpdGUob3AtPmhhc2gsIDAsIHZhbHVlLCBsZW4sIDAs IE5VTEwsDQo+ID4gLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRiX2hh c2hfd3JpdGVfdmFsdWVfY2IsIGNsaWVudCk7DQo+ID4gKyAgICAgICAvKiBTdG9yZSB0aGUgbmV3 IGhhc2ggaW4gdGhlIGRiICovDQo+ID4gKyAgICAgICBpZihnYXR0X2RiX2F0dHJpYnV0ZV93cml0 ZShvcC0+aGFzaCwgMCwgdmFsdWUsIGxlbiwgMCwgTlVMTCwNCj4gPiArICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYl9oYXNoX3dyaXRlX3ZhbHVlX2NiLCBj bGllbnQpKSB7DQo+ID4gKyAgICAgICAgICAgICAgIHV0aWxfZGVidWcoY2xpZW50LT5kZWJ1Z19j YWxsYmFjaywgY2xpZW50LT5kZWJ1Z19kYXRhLCJEQiBIYXNoDQo+IG1hdGNoIHdyaXRlOiBza2lw cGluZyBkaXNjb3ZlcnkiKTsNCj4gPiArICAgICAgICAgICAgICAgcXVldWVfcmVtb3ZlX2FsbChv cC0+cGVuZGluZ19zdmNzLCBOVUxMLCBOVUxMLCBOVUxMKTsNCj4gDQo+IE5vdCBmb2xsb3dpbmcg dGhpcyBjaGFuZ2UsIGlmIHdlIGdvdCB0byB3cml0ZSB0aGUgZGIgaGFzaCB0aGF0IG1lYW5zIHRo ZSBvbGQNCj4gdmFsdWUgZGlkIG5vdCBtYXRjaC4NCj4gDQoNCldoZW4gd2UgdmVyaWZ5IHRoZSBQ VFMgdGVzdCBjYXNlIEdBVFQvQ0wvR0FEL0JWLTAyLUMgdGVzdCBjYXNlLCB0aGUgVGVzdCBjYXNl IGRlbWFuZHMgdG8gcGVyZm9ybSBtdWx0aXBsZSBjb25uZWN0aW9ucyB0byB0aGUgUFRTIGRldmlj ZSB3aXRoIGRpZmZlcmVudCBkYXRhYmFzZSB1cG9uIGVhY2ggY29ubmVjdGlvbiwgd2hlcmUgdGhl IGN1cnJlbnQgY29kZSBkb2VzIG5vdCB1cGRhdGUgdGhlIGRhdGFiYXNlIGhhc2ggb24gZWFjaCBj b25uZWN0IGl0ZXJhdGlvbiB0aGF0IHlpZWxkcyB0byBzZWcgZmF1bHQuDQpBZGRlZCBzdXBwb3J0 IGZvciByZW1vdmUgcGVuZGluZyBzZXJ2aWNlIGlmIGFueSBhZnRlciB1cGRhdGluZyBuZXcgaGFz aCBpbiBkYXRhYmFzZS4NCg0KPiA+ICsgICAgICAgfQ0KPiA+ICsNCj4gPg0KPiA+ICBkaXNjb3Zl cjoNCj4gPiAgICAgICAgIGlmICghb3AtPnN1Y2Nlc3MpIHsNCj4gPiBkaWZmIC0tZ2l0IGEvc3Jj L3NoYXJlZC9nYXR0LWRiLmMgYi9zcmMvc2hhcmVkL2dhdHQtZGIuYyBpbmRleA0KPiA+IGI0NGY3 YjVlOS4uMTVhZjRjMjBhIDEwMDY0NA0KPiA+IC0tLSBhL3NyYy9zaGFyZWQvZ2F0dC1kYi5jDQo+ ID4gKysrIGIvc3JjL3NoYXJlZC9nYXR0LWRiLmMNCj4gPiBAQCAtMzQ0LDEwICszNDQsMTUgQEAg c3RhdGljIGJvb2wgZGJfaGFzaF91cGRhdGUodm9pZCAqdXNlcl9kYXRhKQ0KPiA+ICAgICAgICAg Z2F0dF9kYl9mb3JlYWNoX3NlcnZpY2UoZGIsIE5VTEwsIHNlcnZpY2VfZ2VuX2hhc2hfbSwgJmhh c2gpOw0KPiA+ICAgICAgICAgYnRfY3J5cHRvX2dhdHRfaGFzaChkYi0+Y3J5cHRvLCBoYXNoLmlv diwgZGItPm5leHRfaGFuZGxlLA0KPiA+IGRiLT5oYXNoKTsNCj4gPg0KPiA+IC0gICAgICAgZm9y IChpID0gMDsgaSA8IGhhc2guaTsgaSsrKQ0KPiA+IC0gICAgICAgICAgICAgICBmcmVlKGhhc2gu aW92W2ldLmlvdl9iYXNlKTsNCj4gPiArICAgICAgIGZvciAoaSA9IDA7IGkgPCBoYXNoLmk7IGkr Kykgew0KPiA+ICsgICAgICAgICAgICAgICBpZihoYXNoLmlvdltpXS5pb3ZfYmFzZSkNCj4gPiAr ICAgICAgICAgICAgICAgICAgICAgICBmcmVlKGhhc2guaW92W2ldLmlvdl9iYXNlKTsNCj4gPiAr ICAgICAgIH0NCj4gPiArDQo+ID4gKyAgICAgICBpZihoYXNoLmlvdikNCj4gPiArICAgICAgICAg ICAgICAgZnJlZShoYXNoLmlvdik7DQo+ID4NCj4gPiAtICAgICAgIGZyZWUoaGFzaC5pb3YpOw0K PiA+ICsgICAgICAgaGFzaC5pb3YgPSBOVUxMOw0KPiANCj4gSSBiZWxpZXZlIHRoaXMgZXJyb3Ig d2FzIGFjdHVhbGx5IGludHJvZHVjZWQgYnkgeW91ciBjaGFuZ2VzIGFjdHVhbGx5LCBzZWUNCj4g YmVsb3cuDQo+IA0KPiA+ICAgICAgICAgcmV0dXJuIGZhbHNlOw0KPiA+ICB9DQo+ID4gQEAgLTY4 OSw3ICs2OTQsNyBAQCBzdHJ1Y3QgZ2F0dF9kYl9hdHRyaWJ1dGUNCj4gKmdhdHRfZGJfaW5zZXJ0 X3NlcnZpY2Uoc3RydWN0IGdhdHRfZGIgKmRiLA0KPiA+ICAgICAgICAgc2VydmljZS0+bnVtX2hh bmRsZXMgPSBudW1faGFuZGxlczsNCj4gPg0KPiA+ICAgICAgICAgLyogRmFzdC1mb3J3YXJkIG5l eHRfaGFuZGxlIGlmIHRoZSBuZXcgc2VydmljZSB3YXMgYWRkZWQgdG8gdGhlIGVuZA0KPiAqLw0K PiA+IC0gICAgICAgZGItPm5leHRfaGFuZGxlID0gTUFYKGhhbmRsZSArIG51bV9oYW5kbGVzLCBk Yi0+bmV4dF9oYW5kbGUpOw0KPiA+ICsgICAgICAgZGItPm5leHRfaGFuZGxlICs9IG51bV9oYW5k bGVzOw0KPiANCj4gTm90ZSB0aGF0IGlmIHRoZSBzZXJ2aWNlIHdhcyBub3QgYWRkZWQgdG8gdGhl IGVuZCB0aGlzIHN0YXJ0cyBhZGRpbmcgZ2FwcyBpbg0KPiBiZXR3ZWVuLCBzbyBJJ20gYWZyYWlk IEkgd2lsbCBoYXZlIHRvIG5hY2sgdGhpcyBjaGFuZ2UuDQo+IA0KPiA+ICAgICAgICAgcmV0dXJu IHNlcnZpY2UtPmF0dHJpYnV0ZXNbMF07DQo+ID4NCj4gPiBAQCAtODExLDggKzgxNiw2IEBAIHNl cnZpY2VfaW5zZXJ0X2NoYXJhY3RlcmlzdGljKHN0cnVjdCBnYXR0X2RiX3NlcnZpY2UNCj4gKnNl cnZpY2UsDQo+ID4gICAgICAgICAgKiBkZWNsYXJhdGlvbi4gQWxsIGNoYXJhY3RlcmlzdGljIGRl ZmluaXRpb25zIHNoYWxsIGhhdmUgYQ0KPiA+ICAgICAgICAgICogQ2hhcmFjdGVyaXN0aWMgVmFs dWUgZGVjbGFyYXRpb24uDQo+ID4gICAgICAgICAgKi8NCj4gPiAtICAgICAgIGlmIChoYW5kbGUg PT0gVUlOVDE2X01BWCkNCj4gPiAtICAgICAgICAgICAgICAgcmV0dXJuIE5VTEw7DQo+IA0KPiBU aGlzIHBlcmhhcHMgaXMgdGhlIHJlYWwgcmVhc29uLCBpdCBzZWVtcyB0byBtZSB0aGF0IHlvdSBo YXZlIG1vcmUgdGhhbg0KPiBVSU5UMTZfTUFYIGhhbmRsZXMgc28gdGhlIGhhbmRsZXMgbG9vcCBh cm91bmQgYW5kIHN0YXJ0IG92ZXIgZnJvbQ0KPiAwIHdoaWNoIGlzIGludmFsaWQgYW5kIHdpbGwg bW9zdCBsaWtlbHkgY2F1c2UgZG91YmxlIGZyZWVzIGV0YyBhbmQgdGhleSBjYW4gYmUNCj4gbXVs dGlwbGUgYXR0cmlidXRlcyBhc3NpZ25lZCB0byB0aGUgc2FtZSBoYW5kbGUuIEhvdyBiaWcgaXMg dGhlIGRhdGFiYXNlIHlvdQ0KPiBhcmUgdHJ5aW5nIHRvIHRlc3Q/IElmIHRoYXQgaXMgZ29pbmcg cGFzdCBVSU5UMTZfTUFYIGl0IGlzIHByb2JhYmx5IGJyb2tlbiBhbmQNCj4gbm90aGluZyBjYW4g YmUgZG9uZSB0byBmaXggaXQgb24gdGhlIGNsaWVudCBzaWRlIHdoaWNoIGlzIHdoeSB3ZSBzdG9w IGFkZGluZw0KPiBhdHRyaWJ1dGVzIGFmdGVyIGl0Lg0KPiANCg0KV2hlbiB3ZSB2ZXJpZnkgdGhl IFBUUyB0ZXN0IGNhc2UgR0FUVC9DTC9HQUQvQlYtMDItQyB0ZXN0IGNhc2UsIHRoZSBUQyBkZW1h bmRzIHRvIHBlcmZvcm0gbXVsdGlwbGUgY29ubmVjdGlvbnMgdG8gdGhlIFBUUyBkZXZpY2Ugd2l0 aCBkaWZmZXJlbnQgZGF0YWJhc2UgdXBvbiBlYWNoIGNvbm5lY3Rpb24uIA0KSW4gb25lIGNvbm5l Y3Rpb24gc2V0dXAgZGF0YWJhc2UgaGF2aW5nIGhhbmRsZSB2YWx1ZSBpcyBVSU5UMTZfTUFYLCAg d2hlcmUgdGhlIGN1cnJlbnQgY29kZSBkb2VzIG5vdCBhYmxlIHdoZW4gaGFuZGxlIGlzIG1heCAg Lg0KDQo+ID4gICAgICAgICBpID0gZ2V0X2F0dHJpYnV0ZV9pbmRleChzZXJ2aWNlLCAxKTsNCj4g PiAgICAgICAgIGlmICghaSkNCj4gPiAtLQ0KPiA+IDIuMTcuMQ0KPiA+DQo+IA0KPiANCj4gLS0N Cj4gTHVpeiBBdWd1c3RvIHZvbiBEZW50eg0K Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0KUNMQyDEF8WywAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 18:40:44 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sINlLwyDEF++PQEADc0bRg (envelope-from ); Thu, 16 Jul 2020 18:40:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4ECA852AF2; Thu, 16 Jul 2020 18:40:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728768AbgGPQkj (ORCPT + 1 other); Thu, 16 Jul 2020 12:40:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728182AbgGPQki (ORCPT ); Thu, 16 Jul 2020 12:40:38 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8147BC061755 for ; Thu, 16 Jul 2020 09:40:38 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id d4so4717387otk.2 for ; Thu, 16 Jul 2020 09:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6n3KBdXZLcYlTUDBbE+qyjqRLHqOsDbgzV4YLQ8w2+0=; b=oq5rXNPRcEaYasZkNUw3ngnZoR9HzeD+FCN7okAQDzU+h196n1oS70+htHPWe7LCZi Yqiohq9SSYtAGxSVgmA/ZOt4aX6pCXTztr8LXRSyzAyTBpxgRnAxP0avE+j+GoefX9WR SMweOs8MPGgDfyzwz7/qCjUBuNBqRvN/Z+9S4a5XvS40kQKrHRk0aFWZKOl/uNovbN8X 6/h8oq41ifjDUtZ3CS0EvnyfiVG/zd3K7n1ZVYvYs3DKRJw8LK7UMG6YylodgQcNEtyn TBPCFTEbvIVhAmzTEvFVVvr/cD0pLuZStp8in/YMX6HooXVQ8fVKy/unovprFRhwUZk+ b+IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6n3KBdXZLcYlTUDBbE+qyjqRLHqOsDbgzV4YLQ8w2+0=; b=VRTh2CwzhOs4vb/n3LZfVteBwXCV4r3K5sl2Jo3FtBAF7nA+Hre1oFnVQgpNkvFYbt 9dW32/9Y5sqVCdeEeasU2BFx37aSCMMcbFpDHfWjRxKtvBsw4CpSL8q1q5U26PU/Lb6P U04SIszsGEBInNw/t+uVGuA2TOFh8bftqYXU/xqBdrgYWdo19vsEBP3033ArwX6z7Lq3 dCt6rg1rWvAaG8fA/oOXz5q0OehXUEaU4d9Sn1XqqwUEvSarXmdKNM2HGJk3+Ohc9lnV VVRBiMg1XahiIzzu2kcuabPzBqzTtntrGSIDK2RVTJaTBeMe5QjjXXlCPGU7cF/kBYIj 7TqA== X-Gm-Message-State: AOAM532P5PI070d8+Zf8bDDXNjqB+1bX0KQrjj5rzBSRy0q77QZsoDS+ mlDuouWoDcRiC2lGPra4utqzat6uzWUNUN2TgO0= X-Google-Smtp-Source: ABdhPJyzPGmRhheXOVHTR45ypL8x9J8N936GfjuoEEooR1QUYMo1tb3x1OCV0iNo+mckNfTPeG3db0U740dIuD51nkk= X-Received: by 2002:a9d:6c09:: with SMTP id f9mr5130252otq.362.1594917636464; Thu, 16 Jul 2020 09:40:36 -0700 (PDT) MIME-Version: 1.0 References: <20200715204635.755599-1-luiz.dentz@gmail.com> In-Reply-To: From: Luiz Augusto von Dentz Date: Thu, 16 Jul 2020 09:40:25 -0700 Message-ID: Subject: Re: [PATCH BlueZ 1/2] device: Add timer for removing temporary devices To: Bastien Nocera Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4ECA852AF2 X-Rspamd-UID: f68673 Hi, On Wed, Jul 15, 2020 at 2:03 PM Bastien Nocera wrote: > > On Wed, 2020-07-15 at 13:46 -0700, Luiz Augusto von Dentz wrote: > > From: Luiz Augusto von Dentz > > > > This adds a timer for how long to keep temporary devices, it is > > updated > > everytime the device is seen so devices will be removed even during > > an > > active discovery session which means the discovering for a long > > period > > will no longer just grow without removing devices that disappeared. > > Both patches look good to me. Pushed. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WMwmFPWIEF+7CQEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 19:05:57 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EHmqEvWIEF+nYwEADc0bRg (envelope-from ); Thu, 16 Jul 2020 19:05:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D93AD524CA; Thu, 16 Jul 2020 19:05:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728885AbgGPRFv (ORCPT + 1 other); Thu, 16 Jul 2020 13:05:51 -0400 Received: from mga14.intel.com ([192.55.52.115]:37240 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728126AbgGPRFu (ORCPT ); Thu, 16 Jul 2020 13:05:50 -0400 IronPort-SDR: 2WWCDn9PF/SEB5FP9WrUPwf6je+PdFgUHVAWTZpAi+zbomREPUwAjvBbprYv99mG6TmuryxXiz r9tkhwdz4paA== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="148597777" X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="148597777" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 10:05:48 -0700 IronPort-SDR: 48zOnxxEzgGsdQ843lassJFlmQFTr5RXegU/Q6g/SeEIb5qMXlHt8thlK6VMpbXBdmg6o2fQ+m YM4tRuBdYiIQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="361097350" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga001.jf.intel.com with ESMTP; 16 Jul 2020 10:05:47 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 16 Jul 2020 10:05:47 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 16 Jul 2020 10:05:47 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.109) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 10:05:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hLnycaWKbLqExdngUHeW6m2DtpjXUyQlSlDUHGPF1C2PAlBD99J9ASdCSFoUJQZdsA26FLq/fzs6SqNrCGOCJjq636MmxSc0SD3pvPgYH1coTdAguNkJIIZhVi25hLIwS9XWYTlgDyrVq5wWpewP+qFqKvSwhBi0HQuFBi4mLDOQzkYjrjP6L0LIWzTYBU9Va7fdqGUFNHe7qf7ThCEZhOGpAlfMDbPgStX+bmQKuPvOSKfz+0chl0YkloSFWBMMIVOzV2NlfcXf7esT3lTGuHMZSh6YYhBYC1XHyTclPO33H2e4DtP1950nOJb2dg1RCmuUP9VBd+VcqzBdh+1Djg== 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-SenderADCheck; bh=5S3JII4ZWVoR0JOHlew5XVRUTCfVKY+eO3XGOEP8rbo=; b=Sb0szeyxyO9ooX6QSjmbHZenbyXO7SenntYsCbCwGcZfHrjOfdq6Oro4I0l2alkUUWJzpEKfuTB8C9uVhFIgTuEeJAuMfgpyluPeuBCzZw4FKvKZaNl+/rIV9yfgBEkcYJ0iicS+mb/ICyfEr5bPIO2ns70Tbu4OFqXaAZMkTb+dJaBrlp57SndGoqsVXQmwdKAC1ODBIbtDZcSLZPRots4F9uEo//yIDN8rNjjMPj3Zw9Ixz1ZHRq2hLj8Y99UUq2ykwn/dTcBOcbr7l8EKyv79Zg885hzb/jdi7LURzlPTCwIDWNMxuvmxfGipKTNrLaLmYtj7QJQk/1G4sxT9rg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5S3JII4ZWVoR0JOHlew5XVRUTCfVKY+eO3XGOEP8rbo=; b=Ar8ry7qnPfBitKbiiWphHp5/jMDrwD9RfvjUDxNNJsIq0ELWxQYtuRf/eyALu8lMGE3MLK7LvuHLnZVttaxXrKk6fvvrH+rDFlgeZYtkR5eGkt+bDd0h+Trx4J8qg9iE697FAW1SV4CWbcG3t3SX96GIIxP7UZovYSrGw/kCbZk= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4537.namprd11.prod.outlook.com (2603:10b6:303:5d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Thu, 16 Jul 2020 17:05:43 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%7]) with mapi id 15.20.3174.026; Thu, 16 Jul 2020 17:05:43 +0000 From: "Gix, Brian" To: "linux-bluetooth@vger.kernel.org" CC: "michal.lowas-rzechonek@silvair.com" Subject: Re: [PATCH BlueZ] mesh: Fix node composition change detection Thread-Topic: [PATCH BlueZ] mesh: Fix node composition change detection Thread-Index: AQHWWr1g1w50T/NzaE+SIikwN14EZKkKcS6A Date: Thu, 16 Jul 2020 17:05:42 +0000 Message-ID: <477c993f73e7bc81cb80bcd3d6e733d26415d68e.camel@intel.com> References: <20200715153343.2115695-1-brian.gix@intel.com> In-Reply-To: <20200715153343.2115695-1-brian.gix@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [134.134.137.73] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3af422f8-39df-4213-fb8c-08d829aa7971 x-ms-traffictypediagnostic: MW3PR11MB4537: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3631; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: RzJulGRUlGmCBIQMGkuLZxWYktwoSUHlIfCrxPHW8Mts9+BjBh7zF9BtWBl7d8RqX5+E7EcGvVVp/74rb8ZYVeoyMMvd5ccJcSaXsit6jrLkLbQ7317gXZAzP39yDVSybIesrgwhjUGlNnbToO5vB8PIIgun0MZBb6Nv3/e7WnU5o2ZhAyyQOgGtHNhsHGVVXoAYcMimSJ1v4ONaKRHqoYG1YtzNxJzlNtjsi7Xj3zbWZXFHvFlotgjTi+QdmqioTaNlXSKuM33inMFrHSQqeBDvpZvuBC/k9c2Jl+Zhq+j835nQKSb1uuwlr7gx5zrV x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(366004)(396003)(136003)(346002)(39860400002)(5660300002)(6486002)(71200400001)(4744005)(4326008)(316002)(66946007)(66446008)(83380400001)(6506007)(76116006)(64756008)(66556008)(36756003)(8676002)(8936002)(186003)(66476007)(6916009)(2616005)(2906002)(478600001)(26005)(86362001)(6512007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: W0XmlAbT4cy5kV7fgn9Qo/34M6xYHzqUwajZ1z5vZLVI6ItZ9dPZOUsa4E0e/qZ8S8pRQF+LY76nAEa5xw1hO5iL6TryF5CyXsn7NCALST5uoUVGU3C8f7JayDXkSTYtfqWRdlN9AR7wdf2/53QIYhvZUM60XzA3QFWO2LEjsQDt+tHKso41fyNxqgo6eVVB7QWEmYhj/YbtRFStdxZSn7ghzl+QTvOi3/vTlltRpV96RyA1zdl88vtBA5wKYd16UiIhsCD4Uwz6wYJgACLTmO+LlPKiAoQYbgV7HE9QAtIRH+JxhPmOtDgge5r2HQXCScN5Ygs/QQTVKu6U2XOgkMuBTDT962N+AafsQInKeey0GXAgDi4JlEbKVK1PpLugjB1GUv+kaBMUaGyAXBG39SRRv70GpughLVlesxLp7w5vcYmku0R+s1iw16ixPWpdPJCFU+kYcwzzOaC4eLAkgUlsDU0fi0mP+8fX7A0EK2RtlSA4/aNtmf0rAIzTqawS x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="utf-8" Content-ID: <269E032DA356414E865BDC7EC3CD5819@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3af422f8-39df-4213-fb8c-08d829aa7971 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jul 2020 17:05:42.9765 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zV+zZxJ1uILdzjJZ34HPnbSOO2qrDK01botimkSOi0fVYexix+26sN1waXH/696H/u/FiUf+Ih23EszjtsEXIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4537 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: D93AD524CA X-Rspamd-UID: 0b4174 QXBwbGllZA0KDQpPbiBXZWQsIDIwMjAtMDctMTUgYXQgMDg6MzMgLTA3MDAsIEJyaWFuIEdpeCB3 cm90ZToNCj4gVGhpcyBmaXhlcyBhIGJ1ZyB0aGF0IGNhdXNlZCBkaXNhbGxvd2VkIGNvbXBvc2l0 aW9uIGNoYW5nZXMgZnJvbSBiZWluZw0KPiBkZXRlY3RlZCBhbmQgcmVqZWN0ZWQuIFRoZSBvbmx5 IGZpZWxkcyB0aGF0IGFyZSBhbGxvd2VkIHRvIGZyZWVseSBjaGFuZ2UNCj4gYXJlIENJRCwgUElE LCBWSUQgYW5kIENSUEwuDQo+IC0tLQ0KPiAgbWVzaC9ub2RlLmMgfCAyICstDQo+ICAxIGZpbGUg Y2hhbmdlZCwgMSBpbnNlcnRpb24oKyksIDEgZGVsZXRpb24oLSkNCj4gDQo+IGRpZmYgLS1naXQg YS9tZXNoL25vZGUuYyBiL21lc2gvbm9kZS5jDQo+IGluZGV4IGM2MTE2N2JkYS4uOWI5N2FhOTI3 IDEwMDY0NA0KPiAtLS0gYS9tZXNoL25vZGUuYw0KPiArKysgYi9tZXNoL25vZGUuYw0KPiBAQCAt MTU3OSw3ICsxNTc5LDcgQEAgc3RhdGljIGJvb2wgY2hlY2tfcmVxX25vZGUoc3RydWN0IG1hbmFn ZWRfb2JqX3JlcXVlc3QgKnJlcSkNCj4gIAkJbm9kZSA9IHJlcS0+bm9kZTsNCj4gIA0KPiAgCW5v ZGVfY29tcCA9IG5vZGVfZ2V0X2NvbXAobm9kZSwgMCwgJm5vZGVfbGVuKTsNCj4gLQlsZW4gPSBu b2RlX2dlbmVyYXRlX2NvbXAobm9kZSwgY29tcCwgc2l6ZW9mKGNvbXApKTsNCj4gKwlsZW4gPSBu b2RlX2dlbmVyYXRlX2NvbXAocmVxLT5ub2RlLCBjb21wLCBzaXplb2YoY29tcCkpOw0KPiAgDQo+ ICAJLyogSWYgbm8gcGFnZSAwIGV4aXN0cywgc2F2ZSBpdCBhbmQgcmV0dXJuICovDQo+ICAJaWYg KHJlcS0+dHlwZSAhPSBSRVFVRVNUX1RZUEVfQVRUQUNIIHx8ICFub2RlX2xlbiB8fCAhbm9kZV9j b21wKQ0K Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iBRnFZgSEF+EKgAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 10:40:56 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id +CoFFJgSEF957wEAgupzMw (envelope-from ); Thu, 16 Jul 2020 10:40:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 17439526CF; Thu, 16 Jul 2020 10:40:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726742AbgGPIkt (ORCPT + 1 other); Thu, 16 Jul 2020 04:40:49 -0400 Received: from mga04.intel.com ([192.55.52.120]:58628 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbgGPIks (ORCPT ); Thu, 16 Jul 2020 04:40:48 -0400 IronPort-SDR: uUqL3QOuj3Yh0A0TFCzqKBWn0KidjR+TZXrezivZy4utdrzcLsu+NbWBRZSg5dhlNVLJg5+7VH vOIEbW4fmkGQ== X-IronPort-AV: E=McAfee;i="6000,8403,9683"; a="146853639" X-IronPort-AV: E=Sophos;i="5.75,358,1589266800"; d="scan'208";a="146853639" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 01:40:46 -0700 IronPort-SDR: XzhnR7+ZcBOQQ7/ghJ78CFnWTIV8EN2zMZQsJyOdEfAcI1J0FItijxUeK/R6bXOGwKuMto1+Wh Pd7KgissG1+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,358,1589266800"; d="scan'208";a="300181800" Received: from orsmsx110.amr.corp.intel.com ([10.22.240.8]) by orsmga002.jf.intel.com with ESMTP; 16 Jul 2020 01:40:46 -0700 Received: from orsmsx154.amr.corp.intel.com (10.22.226.12) by ORSMSX110.amr.corp.intel.com (10.22.240.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 01:40:46 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX154.amr.corp.intel.com (10.22.226.12) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 01:40:45 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 01:40:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EnbpBUp2X33myEfiWY2iSQEKZ1RKhOUWfad6bYKERE3AkEmk7oMFbLyW4A/CHUF9/AUtnTblofiknhZz09K1/PUdsIVulrTKReMVSP6E1GxXSUsBtrQKuTITYtI+VtdKYMjtWMYlQUC5CvCLWBdm2qdfrciiVdJTSacWp5ierBv9fAeYioTbslLO4+8w9Meka9e350zUHVqPo4uELLsviqhgrhQ2VPnmKcwms7xUyzPvAQV60BsFtI2Y2YOZkmEp7eabW+JyZD91s/8DaGiSC9xbOG8lFET5Ku9AYEnb+J6/8/R5kd8ym550n4HGAOfThQ1U7IU42xcbY8SaAMnksQ== 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-SenderADCheck; bh=Jo1ukTd5ZCHyim1J/y2eUmviQ/TWO5uvZsJbWPse8BQ=; b=MHOlKRuOyqDra4EZEvZzCicaMzvmzlqz3sT/UjRez+g1J2+miEFaGaJBWYZ2WG99nt6EvVnyehNIPiBL5nkoJ/wrt54NIYF6wyiFAgkGO0c4AYbuUE262mG3NdjOFps53ZdgPoH4Yo4UC7KlethpCTdQh76/GQBPg/aJmFcQAqKsM3ncSUkdmsnXPx7yqPWbwYJk4KHzc0PQwDn94jRePC/IgKEHorePA6HCyMCNeLmQeYOQBvAFyzXbdDpPwxT4MmVpAKRSJG5LgYAQ9BBXgTTK9pqD+iHfnp8Yb9hHlxlgECSb3wkCmv5TZTElO2lXqY2/yoO375pNICl08LLbKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Jo1ukTd5ZCHyim1J/y2eUmviQ/TWO5uvZsJbWPse8BQ=; b=T6B7G9KwHzIOGcDbu+pcE1V8l/xS2T/mP8mUZXfisTLVFqGXrB5cQdFN+ulybrg8wdNfF6DWgxB2BkAAQ3PKoS5jL+13h/guOtKZOx65n8tuJqVBTY4BJZJqBZmIGCWrXwEJDwIkY5jalgRrPCSjqj/+SSgCrjFzbI1WT4vNs78= Received: from DM6PR11MB3369.namprd11.prod.outlook.com (2603:10b6:5:b::16) by DM6PR11MB2937.namprd11.prod.outlook.com (2603:10b6:5:62::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18; Thu, 16 Jul 2020 08:40:44 +0000 Received: from DM6PR11MB3369.namprd11.prod.outlook.com ([fe80::9064:3ba:cdd3:793b]) by DM6PR11MB3369.namprd11.prod.outlook.com ([fe80::9064:3ba:cdd3:793b%7]) with mapi id 15.20.3174.026; Thu, 16 Jul 2020 08:40:44 +0000 From: "Singh, AmitX K" To: Luiz Augusto von Dentz CC: "linux-bluetooth@vger.kernel.org" , "Panda, Bharat B" Subject: RE: [PATCH] bluetoothctl:Add support for read characteristics value Thread-Topic: [PATCH] bluetoothctl:Add support for read characteristics value Thread-Index: AQHWO0WS9YqAd7ST3UyglNOrmzxAW6jKP4aAgDznkYA= Date: Thu, 16 Jul 2020 08:40:44 +0000 Message-ID: References: <20200605142541.28412-1-amitx.k.singh@intel.com> <20200605142541.28412-3-amitx.k.singh@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [49.207.200.9] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: acd02b5b-2080-4cb5-41eb-08d82963edf1 x-ms-traffictypediagnostic: DM6PR11MB2937: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:972; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Ye+t3es7LP2WLQbMNqEHcPFshl9prej+fYVpofFuOgMIBdpiwzf+fVERrzPmEZxtkvXbk2sYPk0xe6nCaaiMgcWUHEVkCIUzfcFRW+RzUpi/HNuXgPmNn2JD6Zn0YomY9HH1smifGE3z/FzuM1mNflMwniswLNJwajJcHqyQ6wYrWTzu81riFMRcA8FB7vEMN9fX0vcs/1FNAe1jRlXT8UdHUO5tpGB4XVV6NbZtObz7E06WJE10HIf4JjAc2/FwclA4Uh1OXFYeMHQpXNg7K27480RLYE0RcffMplog//wmMDsSYh42T4O0B83LNTFj/gstrJP9XwsRank0hBvoxw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB3369.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(39860400002)(396003)(376002)(346002)(366004)(6506007)(66476007)(64756008)(66556008)(26005)(54906003)(53546011)(6916009)(186003)(478600001)(7696005)(33656002)(66946007)(8936002)(8676002)(86362001)(5660300002)(9686003)(66446008)(55016002)(2906002)(71200400001)(76116006)(52536014)(4326008)(55236004)(107886003)(30864003)(316002)(83380400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: Nhqnxgq9e1ofMNUEhfpwkHudiYu8p9SLvrSnVuZ3PFiRs6pDzgwM9V+3TAz8TwVgXsEvuHl62gZfvpj4C5oA7RZk9ils5bCxvogiJtgeLlCGVG+ivE5WMMg6WictZ799f8biMuM3rlxV/5dOB+GqxGSct1IdCNg0ZEhrGHWcocAyqTLSkXmPpKic4vPrY8Q5MqnLyn5lEDc3WCGlwBD2Jz8+aZe9PnDH1rm17TEqReLco4bLUjIIUNYUijvmvunGXfn4gEeamjHoQgCGsA5FdrT8eymrlq+PMGqDaSh7bTj0Rq3usWh1bthVuGoSSr7D9Azt+uXurezIOls+u2fb6DFFYOj8m6GpfyjdPJo32BxLBHlTYFTm5pbWRYyWN6u7p47QXXU7hTaUTmTFvgtwIDR8YDdaXGgG0cpAPBN6C6qNAT518f6coHIBgaHKhix3sk4PbF4sHJc4C8sxErIp1IXtOGPkGtdL8IWvHxS0ROo= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB3369.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: acd02b5b-2080-4cb5-41eb-08d82963edf1 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jul 2020 08:40:44.2268 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: TJKsRABCIvuqciD/Nk1Fr2mV1yZONXcTL2KSv3O5uxiTWokRWrTvPtBP12foXNR8GHg9jbjunGJdaLMvorIbVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2937 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 17439526CF X-Rspamd-UID: 0d55f2 SGkgTHVpeiwNCg0KPiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBMdWl6IEF1 Z3VzdG8gdm9uIERlbnR6IDxsdWl6LmRlbnR6QGdtYWlsLmNvbT4NCj4gU2VudDogRnJpZGF5LCBK dW5lIDUsIDIwMjAgMTA6MzIgUE0NCj4gVG86IFNpbmdoLCBBbWl0WCBLIDxhbWl0eC5rLnNpbmdo QGludGVsLmNvbT4NCj4gQ2M6IGxpbnV4LWJsdWV0b290aEB2Z2VyLmtlcm5lbC5vcmcNCj4gU3Vi amVjdDogUmU6IFtQQVRDSF0gYmx1ZXRvb3RoY3RsOkFkZCBzdXBwb3J0IGZvciByZWFkIGNoYXJh Y3RlcmlzdGljcyB2YWx1ZQ0KPiANCj4gSGkgQW1pdCwNCj4gDQo+IE9uIEZyaSwgSnVuIDUsIDIw MjAgYXQgNzozMCBBTSBBbWl0c2k1eCA8YW1pdHguay5zaW5naEBpbnRlbC5jb20+IHdyb3RlOg0K PiA+DQo+ID4gRnJvbTogYW1pdCA8YW1pdHguay5zaW5naEBpbnRlbC5jb20+DQo+ID4NCj4gPiBD aGFuZ2VzIG1hZGUgdG8gYWRkIHN1cHBvcnQgZm9yIHJlYWQgY2hhcmF0ZXJpc3RpYyB2YWx1ZSBi eSB1dWlkIGluDQo+ID4gYmx1ZXRvb3RoY3RsLg0KPiA+DQo+ID4gU2lnbmVkLW9mZi1ieTogYW1p dCA8YW1pdHguay5zaW5naEBpbnRlbC5jb20+DQo+ID4gLS0tDQo+ID4gIGNsaWVudC9nYXR0LmMg ICAgICAgICAgICB8IDcwICsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrDQo+ID4gIGNs aWVudC9nYXR0LmggICAgICAgICAgICB8ICAxICsNCj4gPiAgY2xpZW50L21haW4uYyAgICAgICAg ICAgIHwgMTggKysrKysrKysrDQo+ID4gIHNyYy9nYXR0LWNsaWVudC5jICAgICAgICB8IDcwICsr KysrKysrKysrKysrKysrKysrKysrKysrKysrKysrDQo+ID4gIHNyYy9zaGFyZWQvZ2F0dC1jbGll bnQuYyB8IDg2DQo+ID4gKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrLQ0K PiA+ICBzcmMvc2hhcmVkL2dhdHQtY2xpZW50LmggfCAgNSArKysNCj4gPiAgNiBmaWxlcyBjaGFu Z2VkLCAyNDkgaW5zZXJ0aW9ucygrKSwgMSBkZWxldGlvbigtKQ0KPiA+DQo+ID4gZGlmZiAtLWdp dCBhL2NsaWVudC9nYXR0LmMgYi9jbGllbnQvZ2F0dC5jIGluZGV4IDUzZjg3NTA1MC4uOGMyODQ0 ZWQ2DQo+ID4gMTAwNjQ0DQo+ID4gLS0tIGEvY2xpZW50L2dhdHQuYw0KPiA+ICsrKyBiL2NsaWVu dC9nYXR0LmMNCj4gPiBAQCAtNjgxLDYgKzY4MSw3NiBAQCB2b2lkIGdhdHRfcmVhZF9hdHRyaWJ1 dGUoR0RCdXNQcm94eSAqcHJveHksIGludA0KPiBhcmdjLCBjaGFyICphcmd2W10pDQo+ID4gICAg ICAgICByZXR1cm4gYnRfc2hlbGxfbm9uaW50ZXJhY3RpdmVfcXVpdChFWElUX0ZBSUxVUkUpOw0K PiA+ICB9DQo+ID4NCj4gPiArc3RhdGljIHZvaWQgY2hhcnJlYWRieXV1aWRfcmVwbHkoREJ1c01l c3NhZ2UgKm1lc3NhZ2UsIHZvaWQNCj4gPiArKnVzZXJfZGF0YSkgew0KPiA+ICsgICAgICAgREJ1 c0Vycm9yIGVycm9yOw0KPiA+ICsgICAgICAgREJ1c01lc3NhZ2VJdGVyIGl0ZXIsIGFycmF5Ow0K PiA+ICsgICAgICAgdWludDhfdCAqdmFsdWU7DQo+ID4gKyAgICAgICBpbnQgbGVuOw0KPiA+ICsN Cj4gPiArICAgICAgIGRidXNfZXJyb3JfaW5pdCgmZXJyb3IpOw0KPiA+ICsNCj4gPiArICAgICAg IGlmIChkYnVzX3NldF9lcnJvcl9mcm9tX21lc3NhZ2UoJmVycm9yLCBtZXNzYWdlKSA9PSBUUlVF KSB7DQo+ID4gKyAgICAgICAgICAgICAgIGJ0X3NoZWxsX3ByaW50ZigiRmFpbGVkIHRvIHJlYWQ6 ICVzXG4iLCBlcnJvci5uYW1lKTsNCj4gPiArICAgICAgICAgICAgICAgZGJ1c19lcnJvcl9mcmVl KCZlcnJvcik7DQo+ID4gKyAgICAgICAgICAgICAgIHJldHVybiBidF9zaGVsbF9ub25pbnRlcmFj dGl2ZV9xdWl0KEVYSVRfRkFJTFVSRSk7DQo+ID4gKyAgICAgICB9DQo+ID4gKw0KPiA+ICsgICAg ICAgZGJ1c19tZXNzYWdlX2l0ZXJfaW5pdChtZXNzYWdlLCAmaXRlcik7DQo+ID4gKw0KPiA+ICsg ICAgICAgaWYgKGRidXNfbWVzc2FnZV9pdGVyX2dldF9hcmdfdHlwZSgmaXRlcikgIT0gREJVU19U WVBFX0FSUkFZKSB7DQo+ID4gKyAgICAgICAgICAgICAgIGJ0X3NoZWxsX3ByaW50ZigiSW52YWxp ZCByZXNwb25zZSB0byByZWFkXG4iKTsNCj4gPiArICAgICAgICAgICAgICAgcmV0dXJuIGJ0X3No ZWxsX25vbmludGVyYWN0aXZlX3F1aXQoRVhJVF9GQUlMVVJFKTsNCj4gPiArICAgICAgIH0NCj4g PiArDQo+ID4gKyAgICAgICBkYnVzX21lc3NhZ2VfaXRlcl9yZWN1cnNlKCZpdGVyLCAmYXJyYXkp Ow0KPiA+ICsgICAgICAgZGJ1c19tZXNzYWdlX2l0ZXJfZ2V0X2ZpeGVkX2FycmF5KCZhcnJheSwg JnZhbHVlLCAmbGVuKTsNCj4gPiArDQo+ID4gKyAgICAgICBpZiAobGVuIDwgMCkgew0KPiA+ICsg ICAgICAgICAgICAgICBidF9zaGVsbF9wcmludGYoIlVuYWJsZSB0byBwYXJzZSB2YWx1ZVxuIik7 DQo+ID4gKyAgICAgICAgICAgICAgIHJldHVybiBidF9zaGVsbF9ub25pbnRlcmFjdGl2ZV9xdWl0 KEVYSVRfRkFJTFVSRSk7DQo+ID4gKyAgICAgICB9DQo+ID4gKw0KPiA+ICsgICAgICAgYnRfc2hl bGxfaGV4ZHVtcCh2YWx1ZSwgbGVuKTsNCj4gPiArDQo+ID4gKyAgICAgICByZXR1cm4gYnRfc2hl bGxfbm9uaW50ZXJhY3RpdmVfcXVpdChFWElUX1NVQ0NFU1MpOw0KPiA+ICt9DQo+ID4gKw0KPiA+ ICtzdGF0aWMgdm9pZCBjaGFycmVhZGJ5dXVpZF9zZXR1cChEQnVzTWVzc2FnZUl0ZXIgKml0ZXIs IHZvaWQNCj4gPiArKnVzZXJfZGF0YSkgew0KPiA+ICsgICAgICAgY2hhciAqdXVpZCA9IHVzZXJf ZGF0YTsNCj4gPiArDQo+ID4gKyAgICAgICBkYnVzX21lc3NhZ2VfaXRlcl9hcHBlbmRfYmFzaWMo aXRlciwgREJVU19UWVBFX1NUUklORywgJnV1aWQpOw0KPiA+ICt9DQo+ID4gKw0KPiA+ICtzdGF0 aWMgdm9pZCBjaGFycmVhZGJ5dXVpZF9hdHRyaWJ1dGUoR0RCdXNQcm94eSAqcHJveHksIGNoYXIg KnV1aWQpIHsNCj4gPiArICAgICAgIGlmIChnX2RidXNfcHJveHlfbWV0aG9kX2NhbGwocHJveHks ICJDaGFyUmVhZEJ5VVVJRCIsDQo+IGNoYXJyZWFkYnl1dWlkX3NldHVwLCBjaGFycmVhZGJ5dXVp ZF9yZXBseSwNCj4gPiArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICB1dWlkLCBOVUxMKSA9PSBGQUxTRSkgew0KPiA+ICsgICAgICAgICAgICAgICBidF9zaGVs bF9wcmludGYoIkZhaWxlZCB0byBzZXQgdXVpZFxuIik7DQo+ID4gKyAgICAgICAgICAgICAgIHJl dHVybiBidF9zaGVsbF9ub25pbnRlcmFjdGl2ZV9xdWl0KEVYSVRfRkFJTFVSRSk7DQo+ID4gKyAg ICAgICB9DQo+ID4gKw0KPiA+ICsgICAgICAgYnRfc2hlbGxfcHJpbnRmKCJBdHRlbXB0aW5nIHRv IHJlYWQgc2VydmljZSBoYW5kbGUgJXNcbiIsDQo+ID4gK2dfZGJ1c19wcm94eV9nZXRfcGF0aChw cm94eSkpOyB9DQo+ID4gKw0KPiA+ICt2b2lkIGdhdHRfY2hhcnJlYWRieXV1aWRfYXR0cmlidXRl KEdEQnVzUHJveHkgKnByb3h5LCBpbnQgYXJnYywgY2hhcg0KPiA+ICsqYXJndltdKSB7DQo+ID4g KyAgICAgICBjb25zdCBjaGFyICppZmFjZTsNCj4gPiArDQo+ID4gKyAgICAgICBpZmFjZSA9IGdf ZGJ1c19wcm94eV9nZXRfaW50ZXJmYWNlKHByb3h5KTsNCj4gPiArDQo+ID4gKyAgICAgICBpZiAo IXN0cmNtcChpZmFjZSwgIm9yZy5ibHVlei5HYXR0Q2hhcmFjdGVyaXN0aWMxIikpIHsNCj4gPiAr ICAgICAgICAgICAgICAgY2hhcnJlYWRieXV1aWRfYXR0cmlidXRlKHByb3h5LCBhcmd2WzFdKTsN Cj4gPiArICAgICAgICAgICAgICAgcmV0dXJuOw0KPiA+ICsgICAgICAgfQ0KPiA+ICsNCj4gPiAr ICAgICAgIGJ0X3NoZWxsX3ByaW50ZigiVW5hYmxlIHRvIHJlYWQgYXR0cmlidXRlICVzXG4iLA0K PiA+ICsNCj4gPiArIGdfZGJ1c19wcm94eV9nZXRfcGF0aChwcm94eSkpOw0KPiA+ICsNCj4gPiAr ICAgICAgIHJldHVybiBidF9zaGVsbF9ub25pbnRlcmFjdGl2ZV9xdWl0KEVYSVRfRkFJTFVSRSk7 DQo+ID4gK30NCj4gPiArDQo+ID4gIHN0YXRpYyB2b2lkIGNoYXJieXV1aWRfcmVwbHkoREJ1c01l c3NhZ2UgKm1lc3NhZ2UsIHZvaWQgKnVzZXJfZGF0YSkNCj4gPiB7DQo+ID4gICAgICAgICBEQnVz RXJyb3IgZXJyb3I7DQo+ID4gZGlmZiAtLWdpdCBhL2NsaWVudC9nYXR0LmggYi9jbGllbnQvZ2F0 dC5oIGluZGV4IDY5MmZiNTc1OC4uOGY5NmQ4NjY1DQo+ID4gMTAwNjQ0DQo+ID4gLS0tIGEvY2xp ZW50L2dhdHQuaA0KPiA+ICsrKyBiL2NsaWVudC9nYXR0LmgNCj4gPiBAQCAtMzUsNiArMzUsNyBA QCBHREJ1c1Byb3h5ICpnYXR0X3NlbGVjdF9hdHRyaWJ1dGUoR0RCdXNQcm94eQ0KPiA+ICpwYXJl bnQsIGNvbnN0IGNoYXIgKnBhdGgpOyAgY2hhciAqZ2F0dF9hdHRyaWJ1dGVfZ2VuZXJhdG9yKGNv bnN0IGNoYXINCj4gPiAqdGV4dCwgaW50IHN0YXRlKTsgIHZvaWQgZ2F0dF9zZXJ2Ynl1dWlkX2F0 dHJpYnV0ZShHREJ1c1Byb3h5ICpwcm94eSwNCj4gPiBpbnQgYXJnYywgY2hhciAqYXJndltdKTsg IHZvaWQgZ2F0dF9jaGFyYnl1dWlkX2F0dHJpYnV0ZShHREJ1c1Byb3h5DQo+ID4gKnByb3h5LCBp bnQgYXJnYywgY2hhciAqYXJndltdKTsNCj4gPiArdm9pZCBnYXR0X2NoYXJyZWFkYnl1dWlkX2F0 dHJpYnV0ZShHREJ1c1Byb3h5ICpwcm94eSwgaW50IGFyZ2MsIGNoYXINCj4gPiArKmFyZ3ZbXSk7 DQo+ID4gIHZvaWQgZ2F0dF9yZWFkX2F0dHJpYnV0ZShHREJ1c1Byb3h5ICpwcm94eSwgaW50IGFy Z2MsIGNoYXIgKmFyZ3ZbXSk7DQo+ID4gdm9pZCBnYXR0X3dyaXRlX2F0dHJpYnV0ZShHREJ1c1By b3h5ICpwcm94eSwgaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSk7DQo+ID4gdm9pZCBnYXR0X25vdGlm eV9hdHRyaWJ1dGUoR0RCdXNQcm94eSAqcHJveHksIGJvb2wgZW5hYmxlKTsgZGlmZiAtLWdpdA0K PiA+IGEvY2xpZW50L21haW4uYyBiL2NsaWVudC9tYWluLmMgaW5kZXggMTBlNjRlMTdiLi40ZGQx ZTU5M2EgMTAwNjQ0DQo+ID4gLS0tIGEvY2xpZW50L21haW4uYw0KPiA+ICsrKyBiL2NsaWVudC9t YWluLmMNCj4gPiBAQCAtMjA3MSw2ICsyMDcxLDIyIEBAIHN0YXRpYyB2b2lkIGNtZF9hdHRyaWJ1 dGVfaW5mbyhpbnQgYXJnYywgY2hhcg0KPiAqYXJndltdKQ0KPiA+ICAgICAgICAgcmV0dXJuIGJ0 X3NoZWxsX25vbmludGVyYWN0aXZlX3F1aXQoRVhJVF9TVUNDRVNTKTsNCj4gPiAgfQ0KPiA+DQo+ ID4gK3N0YXRpYyB2b2lkIGNtZF9jaGFyX3JlYWRfYnlfdXVpZChpbnQgYXJnYywgY2hhciAqYXJn dltdKSB7DQo+ID4gKyAgICAgICBHREJ1c1Byb3h5ICpwcm94eTsNCj4gPiArDQo+ID4gKyAgICAg ICBwcm94eSA9IGZpbmRfYXR0cmlidXRlKGFyZ2MsIGFyZ3YpOw0KPiA+ICsNCj4gPiArICAgICAg IHNldF9kZWZhdWx0X2F0dHJpYnV0ZShwcm94eSk7DQo+ID4gKw0KPiA+ICsgICAgICAgaWYgKCFk ZWZhdWx0X2F0dHIpIHsNCj4gPiArICAgICAgICAgICAgICAgYnRfc2hlbGxfcHJpbnRmKCJObyBh dHRyaWJ1dGUgc2VsZWN0ZWRcbiIpOw0KPiA+ICsgICAgICAgICAgICAgICByZXR1cm4gYnRfc2hl bGxfbm9uaW50ZXJhY3RpdmVfcXVpdChFWElUX0ZBSUxVUkUpOw0KPiA+ICsgICAgICAgfQ0KPiA+ ICsNCj4gPiArICAgICAgIGdhdHRfY2hhcnJlYWRieXV1aWRfYXR0cmlidXRlKGRlZmF1bHRfYXR0 ciwgYXJnYywgYXJndik7IH0NCj4gPiArDQo+ID4gIHN0YXRpYyB2b2lkIGNtZF9jaGFyX2J5X3V1 aWQoaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkgIHsNCj4gPiAgICAgICAgIEdEQnVzUHJveHkgKnBy b3h5Ow0KPiA+IEBAIC0yNzE4LDYgKzI3MzQsOCBAQCBzdGF0aWMgY29uc3Qgc3RydWN0IGJ0X3No ZWxsX21lbnUgZ2F0dF9tZW51ID0gew0KPiA+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIkRpc2NvdmVyIFByaW1hcnkgU2VydmljZXMgYnkgVVVJRCIgfSwNCj4gPiAgICAgICAgIHsg ImNoYXItYnktdXVpZCIsICJbVVVJRF0iLCBjbWRfY2hhcl9ieV91dWlkLA0KPiA+ICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIkRpc2NvdmVyIENoYXJhY3RlcmlzdGljIFNlcnZpY2Vz IGJ5DQo+ID4gVVVJRCIgfSwNCj4gPiArICAgICAgIHsgImNoYXItcmVhZC1ieS11dWlkIiwgIltV VUlEXSIsIGNtZF9jaGFyX3JlYWRfYnlfdXVpZCwNCj4gPiArICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICJSZWFkIENoYXJhY3RlcmlzdGljIGJ5IFVVSUQiIH0sDQo+ID4gICAgICAgICB7 ICJzZWxlY3QtYXR0cmlidXRlIiwgIjxhdHRyaWJ1dGUvVVVJRD4iLCAgY21kX3NlbGVjdF9hdHRy aWJ1dGUsDQo+ID4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiU2VsZWN0IGF0dHJp YnV0ZSIsIGF0dHJpYnV0ZV9nZW5lcmF0b3IgfSwNCj4gPiAgICAgICAgIHsgImF0dHJpYnV0ZS1p bmZvIiwgIlthdHRyaWJ1dGUvVVVJRF0iLCAgY21kX2F0dHJpYnV0ZV9pbmZvLA0KPiA+IGRpZmYg LS1naXQgYS9zcmMvZ2F0dC1jbGllbnQuYyBiL3NyYy9nYXR0LWNsaWVudC5jIGluZGV4DQo+ID4g ZGE4MTFlYTRmLi5jZDZkNmRmZGUgMTAwNjQ0DQo+ID4gLS0tIGEvc3JjL2dhdHQtY2xpZW50LmMN Cj4gPiArKysgYi9zcmMvZ2F0dC1jbGllbnQuYw0KPiA+IEBAIC00NDQsNiArNDQ0LDI3IEBAIHN0 YXRpYyBzdHJ1Y3QgYXN5bmNfZGJ1c19vcA0KPiAqYXN5bmNfZGJ1c19vcF9uZXcoREJ1c01lc3Nh Z2UgKm1zZywgdm9pZCAqZGF0YSkNCj4gPiAgICAgICAgIHJldHVybiBvcDsNCj4gPiAgfQ0KPiA+ DQo+ID4gK3N0YXRpYyBzdHJ1Y3QgYXN5bmNfZGJ1c19vcCAqZmV0Y2hfY2hhcl9yZWFkX2J5X3V1 aWQoc3RydWN0DQo+IGJ0X2dhdHRfY2xpZW50ICpnYXR0LA0KPiA+ICsgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBEQnVzTWVzc2FnZSAqbXNnLA0KPiA+ICsgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFyICp1dWlkLA0KPiA+ICsgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidF9nYXR0X2NsaWVudF9jaGFyX2J5X3V1aWRf Y2FsbGJhY2tfdCBjYWxsYmFjaywNCj4gPiArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgdm9pZCAqZGF0YSkgew0KPiA+ICsgICAgICAgc3RydWN0IGFzeW5jX2RidXNfb3Ag Km9wOw0KPiA+ICsNCj4gPiArICAgICAgIG9wID0gYXN5bmNfZGJ1c19vcF9uZXcobXNnLCBkYXRh KTsNCj4gPiArICAgICAgIG9wLT5pZCA9IGJ0X2dhdHRfY2xpZW50X2NoYXJfcmVhZF9ieV91dWlk KGdhdHQsIHV1aWQsIGNhbGxiYWNrLA0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIGFzeW5jX2RidXNfb3BfcmVmKG9wKSwNCj4gPiArICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhc3luY19kYnVzX29wX3VucmVm KTsNCj4gPiArDQo+ID4gKyAgICAgICBpZiAob3AtPmlkKQ0KPiA+ICsgICAgICAgICAgICAgICBy ZXR1cm4gb3A7DQo+ID4gKw0KPiA+ICsgICAgICAgYXN5bmNfZGJ1c19vcF9mcmVlKG9wKTsNCj4g PiArDQo+ID4gKyAgICAgICByZXR1cm4gTlVMTDsNCj4gPiArfQ0KPiA+ICsNCj4gPiAgc3RhdGlj IHN0cnVjdCBhc3luY19kYnVzX29wICpmZXRjaF9jaGFyX2J5X3V1aWQoc3RydWN0IGJ0X2dhdHRf Y2xpZW50DQo+ICpnYXR0LA0KPiA+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICBEQnVzTWVzc2FnZSAqbXNnLA0KPiA+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICBjaGFyICp1dWlkLCBAQCAtOTcyLDYgKzk5Myw1Mg0KPiA+IEBAIGZhaWw6DQo+ ID4gICAgICAgICBjaHJjLT5yZWFkX29wID0gTlVMTDsNCj4gPiAgfQ0KPiA+DQo+ID4gK3N0YXRp YyB2b2lkIGNoYXJfcmVhZF9ieV91dWlkX2NiKGJvb2wgc3VjY2VzcywgdWludDhfdCBhdHRfZWNv ZGUsIGNvbnN0DQo+IHVpbnQ4X3QgKnZhbHVlLA0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICB1aW50MTZfdCBsZW5ndGgsIHZvaWQNCj4gPiArKnVzZXJfZGF0YSkg ew0KPiA+ICsgICAgICAgc3RydWN0IGFzeW5jX2RidXNfb3AgKm9wID0gdXNlcl9kYXRhOw0KPiA+ ICsgICAgICAgc3RydWN0IGNoYXJhY3RlcmlzdGljICpvcGNoYXIgPSBvcC0+ZGF0YTsNCj4gPiAr DQo+ID4gKyAgICAgICBpZiAoIXN1Y2Nlc3MpDQo+ID4gKyAgICAgICAgICAgICAgIGdvdG8gZmFp bDsNCj4gPiArDQo+ID4gKyAgICAgICBhc3luY19kYnVzX29wX3JlcGx5KG9wLCBhdHRfZWNvZGUs IHZhbHVlLCBsZW5ndGgpOw0KPiA+ICsNCj4gPiArICAgICAgIHJldHVybjsNCj4gPiArDQo+ID4g K2ZhaWw6DQo+ID4gKyAgICAgICBhc3luY19kYnVzX29wX3JlcGx5KG9wLCBhdHRfZWNvZGUsIE5V TEwsIDApOw0KPiA+ICsNCj4gPiArICAgICAgIG9wY2hhci0+dHlwZV9vcCA9IE5VTEw7DQo+ID4g K30NCj4gPiArDQo+ID4gK3N0YXRpYyBEQnVzTWVzc2FnZSAqY2hhcl9yZWFkX2J5X3V1aWQoREJ1 c0Nvbm5lY3Rpb24gKmNvbm4sDQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIERCdXNNZXNzYWdlICptc2csIHZvaWQNCj4gPiArKnVzZXJfZGF0YSkgew0KPiA+ICsg ICAgICAgc3RydWN0IGNoYXJhY3RlcmlzdGljICpjaGFyZGF0YSA9IHVzZXJfZGF0YTsNCj4gPiAr ICAgICAgIHN0cnVjdCBidF9nYXR0X2NsaWVudCAqZ2F0dCA9IGNoYXJkYXRhLT5zZXJ2aWNlLT5j bGllbnQtPmdhdHQ7DQo+ID4gKyAgICAgICBEQnVzTWVzc2FnZUl0ZXIgaXRlcjsNCj4gPiArDQo+ ID4gKyAgICAgICBjaGFyICp1dWlkID0gMDsNCj4gPiArDQo+ID4gKyAgICAgICBpZiAoIWdhdHQp DQo+ID4gKyAgICAgICAgICAgICAgIHJldHVybiBidGRfZXJyb3JfZmFpbGVkKG1zZywgIk5vdCBj b25uZWN0ZWQiKTsNCj4gPiArDQo+ID4gKyAgICAgICBkYnVzX21lc3NhZ2VfaXRlcl9pbml0KG1z ZywgJml0ZXIpOw0KPiA+ICsNCj4gPiArICAgICAgIGlmIChkYnVzX21lc3NhZ2VfaXRlcl9nZXRf YXJnX3R5cGUoJml0ZXIpID09IERCVVNfVFlQRV9TVFJJTkcpDQo+ID4gKyAgICAgICAgICAgICAg IGRidXNfbWVzc2FnZV9pdGVyX2dldF9iYXNpYygmaXRlciwmdXVpZCk7DQo+ID4gKyAgICAgICBl bHNlDQo+ID4gKyAgICAgICAgICAgICAgIHJldHVybiBOVUxMOw0KPiA+ICsNCj4gPiArICAgICAg IGNoYXJkYXRhLT50eXBlX29wID0gZmV0Y2hfY2hhcl9yZWFkX2J5X3V1aWQoZ2F0dCwgbXNnLHV1 aWQsDQo+ID4gKyBjaGFyX3JlYWRfYnlfdXVpZF9jYiwgY2hhcmRhdGEpOw0KPiA+ICsNCj4gPiAr ICAgICAgIGlmICghY2hhcmRhdGEtPnR5cGVfb3ApDQo+ID4gKyAgICAgICAgICAgICAgIHJldHVy biBidGRfZXJyb3JfZmFpbGVkKG1zZywgIkZhaWxlZCB0byBzZW5kIHJlYWQNCj4gPiArIHJlcXVl c3QiKTsNCj4gPiArDQo+ID4gKyAgICAgICByZXR1cm4gTlVMTDsNCj4gPiArfQ0KPiA+ICsNCj4g PiAgc3RhdGljIHZvaWQgY2hhcmFjdGVyaXN0aWNfYnlfdXVpZF9jYihib29sIHN1Y2Nlc3MsIHVp bnQ4X3QgYXR0X2Vjb2RlLA0KPiBjb25zdCB1aW50OF90ICp2YWx1ZSwNCj4gPiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDE2X3QgbGVuZ3RoLCB2b2lkDQo+ID4g KnVzZXJfZGF0YSkgIHsgQEAgLTE3ODYsNiArMTg1Myw5IEBAIHN0YXRpYyBjb25zdCBHREJ1c01l dGhvZFRhYmxlDQo+ID4gY2hhcmFjdGVyaXN0aWNfbWV0aG9kc1tdID0gew0KPiA+ICAgICAgICAg eyBHREJVU19BU1lOQ19NRVRIT0QoIkNoYXJCeVVVSUQiLCBHREJVU19BUkdTKHsgIm9wdGlvbnMi LA0KPiAicyIgfSksDQo+ID4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IEdEQlVTX0FSR1MoeyAidmFsdWUiLCAiYXkiIH0pLA0KPiA+ICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBjaGFyZGlzY292ZXJfYnlfdXVpZCkgfSwNCj4gPiArICAgICAg IHsgR0RCVVNfQVNZTkNfTUVUSE9EKCJDaGFyUmVhZEJ5VVVJRCIsIEdEQlVTX0FSR1Moew0KPiAi b3B0aW9ucyIsICJzIiB9KSwNCj4gPiArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgR0RCVVNfQVJHUyh7ICJ2YWx1ZSIsICJheSIgfSksDQo+ID4gKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJfcmVhZF9ieV91dWlkKSB9LA0KPiANCj4gSXQg d291bGQgaGF2ZSBoZWxwZWQgaWYgeW91IGhhZCBjb21tdW5pY2F0ZWQgdGhhdCB5b3Ugd291bGQg YmUgbG9va2luZw0KPiBpbnRvIGFkZCBzdXBwb3J0IGZvciB0aGlzIHR5cGUgb2Ygb3BlcmF0aW9u LCB0aGVzZSBwcm9jZWR1cmVzIG9idmlvdXNseQ0KPiBjYW5ub3QgYmUgcGFydCBvZiBDaGFyYWN0 ZXJpc3RpYyBpbnRlcmZhY2Ugc2luY2UgdGhhdCBpcyBvbmx5IGF2YWlsYWJsZSBhZnRlciB0aGUN Cj4gZGlzY292ZXJ5IHByb2NlZHVyZSB0aGVuIHlvdSBjYW4ganVzdCBsb29rdXAgaW50ZXJuYWxs eSBpbiB0aGUgY2FjaGUuIFNvIHRoaXMNCj4gdHlwZSBvZiBwcm9jZWR1cmUgd2lsbCBwcm9iYWJs eSBuZWVkIHRvIGJlIHVuZGVyIGEgRGV2aWNlIG9iamVjdCBhbmQgbGV0cw0KPiBwbGVhc2UgYWdy ZWUgb24gdGhlIGRvY3VtZW50YXRpb24gZmlyc3QgYmVmb3JlIHdlIG1vdmUgZm9yd2FyZC4NCj4g DQoNCldoZW4gd2UgdmVyaWZ5IHRoZSBQVFMgdGVzdCBjYXNlIEdBVFQvQ0wvR0FSL0JWLTAzLUMg IlJlYWQgdXNpbmcgY2hhcmFjdGVyaXNpdGljIFVVSUQiLCB0aGUgVGVzdCBjYXNlIGV4cGVjdCBy ZWFkIHJlcXVlc3QgZnJvbSBkZXZpY2UgLg0KQWRkZWQgYSBjb2RlIGZvciBzZW5kaW5nIHJlYWQg cmVxdWVzdCBmb3IgcmVhZGluZyBjaGFyYWN0ZXJpc3RpYyB2YWx1ZSB1c2luZyBVVUlEIG92ZXIg Y2hhcmFjdGVyaXN0aWMgaW50ZXJmYWNlDQoNCj4gPiAgICAgICAgIHsgR0RCVVNfQVNZTkNfTUVU SE9EKCJSZWFkVmFsdWUiLCBHREJVU19BUkdTKHsgIm9wdGlvbnMiLA0KPiAiYXtzdn0iIH0pLA0K PiA+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBHREJVU19BUkdTKHsg InZhbHVlIiwgImF5IiB9KSwNCj4gPiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgY2hhcmFjdGVyaXN0aWNfcmVhZF92YWx1ZSkgfSwNCj4gPiBkaWZmIC0tZ2l0IGEvc3Jj L3NoYXJlZC9nYXR0LWNsaWVudC5jIGIvc3JjL3NoYXJlZC9nYXR0LWNsaWVudC5jIGluZGV4DQo+ ID4gOGE2OTZjNzdmLi43YzlkMjVlYzMgMTAwNjQ0DQo+ID4gLS0tIGEvc3JjL3NoYXJlZC9nYXR0 LWNsaWVudC5jDQo+ID4gKysrIGIvc3JjL3NoYXJlZC9nYXR0LWNsaWVudC5jDQo+ID4gQEAgLTI3 MjUsNiArMjcyNSw5MCBAQCBkb25lOg0KPiA+ICAgICAgICAgICAgICAgICBvcC0+Y2FsbGJhY2so c3VjY2VzcywgYXR0X2Vjb2RlLCB2YWx1ZSwgbGVuZ3RoLA0KPiA+IG9wLT51c2VyX2RhdGEpOyAg fQ0KPiA+DQo+ID4gK3Vuc2lnbmVkIGludCBidF9nYXR0X2NsaWVudF9jaGFyX3JlYWRfYnlfdXVp ZChzdHJ1Y3QgYnRfZ2F0dF9jbGllbnQNCj4gKmNsaWVudCwNCj4gPiArICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFyICp1dWlkLA0KPiA+ICsgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ0X2dhdHRfY2xpZW50X2No YXJfYnlfdXVpZF9jYWxsYmFja190IGNhbGxiYWNrLA0KPiA+ICsgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvaWQgKnVzZXJfZGF0YSwNCj4gPiArDQo+ID4g K2J0X2dhdHRfY2xpZW50X2Rlc3Ryb3lfZnVuY190IGRlc3Ryb3kpIHsNCj4gPiArICAgICAgIHN0 cnVjdCByZXF1ZXN0ICpyZXE7DQo+ID4gKyAgICAgICBzdHJ1Y3QgY2hhcl9ieV91dWlkX29wICpv cDsNCj4gPiArICAgICAgIHVuc2lnbmVkIGNoYXIgKnBkdTsNCj4gPiArICAgICAgIHVpbnQxNl90 IGxlbiA7DQo+ID4gKyAgICAgICB1aW50MTZfdCBzdGFydF9oYW5kbGUgPSAweDAwMDE7DQo+ID4g KyAgICAgICB1aW50MTZfdCBlbmRfaGFuZGxlID0gMHhmZmZmOw0KPiA+ICsgICAgICAgYnRfdXVp ZF90IGJ0dXVpZDsNCj4gPiArICAgICAgIHVpbnQ4X3QgdXVpZDEyOFsxNl07DQo+ID4gKw0KPiA+ ICsgICAgICAgLyogTGVuZ3RoIG9mIHBkdSB3aWxsIGJlIHZhcnkgYWNjb3JkaW5nIHRvIHV1aWQg dHlwZQ0KPiA+ICsgICAgICAgZm9yIDIgYnl0ZSB1dWlkIHRvdGFsIGxlbmd0aCAgaXMgOCAoc3Rh cnQgaGFuZGxlKDIpICsgZW5kIGhhbmRsZSgyKSAgKw0KPiB1dWlkKDIpKQ0KPiA+ICsgICAgICAg Zm9yIDE2IGJ5dGUgdXVpZCB0b3RhbCBsZW5ndGggIGlzIDIyIChzdGFydCBoYW5kbGUoMikgKyBl bmQgaGFuZGxlKDIpICArDQo+IHV1aWQoMTYpKQ0KPiA+ICsgICAgICAgKi8NCj4gPiArICAgICAg IHVpbnQxNl90IHBkdV9sZW5fMTZiaXRfdXVpZCA9IDY7DQo+ID4gKyAgICAgICB1aW50MTZfdCBw ZHVfbGVuXzEyOGJpdF91dWlkID0gMjA7DQo+ID4gKw0KPiA+ICsgICAgICAgaWYgKGJ0X3N0cmlu Z190b191dWlkKCZidHV1aWQsIHV1aWQpIDwgMCkgew0KPiA+ICsgICAgICAgICAgICAgICByZXR1 cm4gMDsNCj4gPiArICAgICAgIH0NCj4gPiArDQo+ID4gKyAgICAgICBpZiAoYnR1dWlkLnR5cGUg PT0gQlRfVVVJRDE2KXsNCj4gPiArICAgICAgICAgICAgICAgcGR1ID0gKHVuc2lnbmVkIGNoYXIg KikgbWFsbG9jKHBkdV9sZW5fMTZiaXRfdXVpZCk7DQo+ID4gKyAgICAgICAgICAgICAgIGxlbiA9 IHBkdV9sZW5fMTZiaXRfdXVpZDsNCj4gPiArICAgICAgIH0gZWxzZSB7DQo+ID4gKyAgICAgICAg ICAgICAgIHBkdSA9ICh1bnNpZ25lZCBjaGFyICopIG1hbGxvYyhwZHVfbGVuXzEyOGJpdF91dWlk KTsNCj4gPiArICAgICAgICAgICAgICAgbGVuID0gcGR1X2xlbl8xMjhiaXRfdXVpZDsNCj4gPiAr ICAgICAgIH0NCj4gPiArDQo+ID4gKyAgICAgICBpZiAoIWNsaWVudCkNCj4gPiArICAgICAgICAg ICAgICAgcmV0dXJuIDA7DQo+ID4gKw0KPiA+ICsgICAgICAgb3AgPSBuZXcwKHN0cnVjdCBjaGFy X2J5X3V1aWRfb3AsIDEpOw0KPiA+ICsgICAgICAgcmVxID0gcmVxdWVzdF9jcmVhdGUoY2xpZW50 KTsNCj4gPiArICAgICAgIGlmICghcmVxKSB7DQo+ID4gKyAgICAgICAgICAgICAgIGZyZWUob3Ap Ow0KPiA+ICsgICAgICAgICAgICAgICByZXR1cm4gMDsNCj4gPiArICAgICAgIH0NCj4gPiArICAg ICAgIGlmICghY2xpZW50KQ0KPiA+ICsgICAgICAgICAgICAgICByZXR1cm4gMDsNCj4gPiArDQo+ ID4gKyAgICAgICBvcCA9IG5ldzAoc3RydWN0IGNoYXJfYnlfdXVpZF9vcCwgMSk7DQo+ID4gKyAg ICAgICByZXEgPSByZXF1ZXN0X2NyZWF0ZShjbGllbnQpOw0KPiA+ICsNCj4gPiArICAgICAgIGlm ICghcmVxKSB7DQo+ID4gKyAgICAgICAgICAgICAgIGZyZWUob3ApOw0KPiA+ICsgICAgICAgICAg ICAgICByZXR1cm4gMDsNCj4gPiArICAgICAgIH0NCj4gPiArDQo+ID4gKyAgICAgICBvcC0+Y2Fs bGJhY2sgPSBjYWxsYmFjazsNCj4gPiArICAgICAgIG9wLT51c2VyX2RhdGEgPSB1c2VyX2RhdGE7 DQo+ID4gKyAgICAgICBvcC0+ZGVzdHJveSA9IGRlc3Ryb3k7DQo+ID4gKyAgICAgICByZXEtPmRh dGEgPSBvcDsNCj4gPiArICAgICAgIHJlcS0+ZGVzdHJveSA9IGRlc3Ryb3lfY2hhcl9ieV91dWlk X29wOw0KPiA+ICsNCj4gPiArICAgICAgIHB1dF9sZTE2KHN0YXJ0X2hhbmRsZSwgcGR1KTsNCj4g PiArICAgICAgIHB1dF9sZTE2KGVuZF9oYW5kbGUsIHBkdSsyKTsNCj4gPiArDQo+ID4gKyAgICAg ICBpZiAoYnR1dWlkLnR5cGUgPT0gQlRfVVVJRDE2KQ0KPiA+ICsgICAgICAgICAgICAgICBwdXRf bGUxNihidHV1aWQudmFsdWUudTE2LCBwZHUrNCk7DQo+ID4gKyAgICAgICBlbHNlIHsNCj4gPiAr ICAgICAgICAgICAgICAgYnN3YXBfMTI4KCZidHV1aWQudmFsdWUudTEyOC5kYXRhWzBdLCAmdXVp ZDEyOFswXSk7DQo+ID4gKyAgICAgICAgICAgICAgIG1lbWNweShwZHUgKyA0LCB1dWlkMTI4LCAx Nik7DQo+ID4gKyAgICAgICB9DQo+ID4gKw0KPiA+ICsgICAgICAgcmVxLT5hdHRfaWQgPSBidF9h dHRfc2VuZChjbGllbnQtPmF0dCwNCj4gQlRfQVRUX09QX1JFQURfQllfVFlQRV9SRVEsDQo+ID4g KyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBw ZHUsIGxlbiwNCj4gPiArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIGNoYXJfYnlfdXVpZF9jYiwgcmVxLA0KPiA+ICsNCj4gPiArIHJlcXVlc3Rf dW5yZWYpOw0KPiA+ICsNCj4gPiArICAgICAgIGlmICghcmVxLT5hdHRfaWQpIHsNCj4gPiArICAg ICAgICAgICAgICAgb3AtPmRlc3Ryb3kgPSBOVUxMOw0KPiA+ICsgICAgICAgICAgICAgICByZXF1 ZXN0X3VucmVmKHJlcSk7DQo+ID4gKyAgICAgICAgICAgICAgIHJldHVybiAwOw0KPiA+ICsgICAg ICAgfQ0KPiA+ICsNCj4gPiArICAgICAgIHJldHVybiByZXEtPmlkOw0KPiA+ICt9DQo+ID4gKw0K PiA+ICB1bnNpZ25lZCBpbnQgYnRfZ2F0dF9jbGllbnRfY2hhcl9ieV91dWlkKHN0cnVjdCBidF9n YXR0X2NsaWVudCAqY2xpZW50LA0KPiA+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgY2hhciAqdXVpZCwNCj4gPg0KPiA+IGJ0X2dhdHRfY2xpZW50X2NoYXJf YnlfdXVpZF9jYWxsYmFja190IGNhbGxiYWNrLCBAQCAtMjc1NCw3ICsyODM4LDcgQEANCj4gdW5z aWduZWQgaW50IGJ0X2dhdHRfY2xpZW50X2NoYXJfYnlfdXVpZChzdHJ1Y3QgYnRfZ2F0dF9jbGll bnQgKmNsaWVudCwNCj4gPiAgICAgICAgIGlmIChidHV1aWQudHlwZSA9PSBCVF9VVUlEMTYpew0K PiA+ICAgICAgICAgICAgICAgICBwZHUgPSAodW5zaWduZWQgY2hhciAqKSBtYWxsb2MocGR1X2xl bl8xNmJpdF91dWlkKTsNCj4gPiAgICAgICAgICAgICAgICAgbGVuID0gcGR1X2xlbl8xNmJpdF91 dWlkOw0KPiA+IC0gICAgICAgfSBlbHNlIHsNCj4gPiArICAgICAgIH1lbHNlIHsNCj4gPiAgICAg ICAgICAgICAgICAgcGR1ID0gKHVuc2lnbmVkIGNoYXIgKikgbWFsbG9jKHBkdV9sZW5fMTI4Yml0 X3V1aWQpOw0KPiA+ICAgICAgICAgICAgICAgICBsZW4gPSBwZHVfbGVuXzEyOGJpdF91dWlkOw0K PiA+ICAgICAgICAgfQ0KPiA+IGRpZmYgLS1naXQgYS9zcmMvc2hhcmVkL2dhdHQtY2xpZW50Lmgg Yi9zcmMvc2hhcmVkL2dhdHQtY2xpZW50LmggaW5kZXgNCj4gPiBmNWQ1MTY5Y2UuLjUwODU5Y2U1 MiAxMDA2NDQNCj4gPiAtLS0gYS9zcmMvc2hhcmVkL2dhdHQtY2xpZW50LmgNCj4gPiArKysgYi9z cmMvc2hhcmVkL2dhdHQtY2xpZW50LmgNCj4gPiBAQCAtOTcsNiArOTcsMTEgQEAgdW5zaWduZWQg aW50IGJ0X2dhdHRfY2xpZW50X2NoYXJfYnlfdXVpZChzdHJ1Y3QNCj4gYnRfZ2F0dF9jbGllbnQg KmNsaWVudCwNCj4gPiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnRf Z2F0dF9jbGllbnRfcmVhZF9jYWxsYmFja190IGNhbGxiYWNrLA0KPiA+ICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICB2b2lkICp1c2VyX2RhdGEsDQo+ID4gICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ0X2dhdHRfY2xpZW50X2Rlc3Ryb3lfZnVu Y190DQo+ID4gZGVzdHJveSk7DQo+ID4gK3Vuc2lnbmVkIGludCBidF9nYXR0X2NsaWVudF9jaGFy X3JlYWRfYnlfdXVpZChzdHJ1Y3QgYnRfZ2F0dF9jbGllbnQNCj4gKmNsaWVudCwNCj4gPiArICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhciAqdXVpZCwNCj4gPiArICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnRfZ2F0dF9jbGllbnRfcmVhZF9j YWxsYmFja190IGNhbGxiYWNrLA0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICB2b2lkICp1c2VyX2RhdGEsDQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIGJ0X2dhdHRfY2xpZW50X2Rlc3Ryb3lfZnVuY190DQo+ID4gK2Rlc3Ryb3kp Ow0KPiA+ICB1bnNpZ25lZCBpbnQgYnRfZ2F0dF9jbGllbnRfcmVhZF92YWx1ZShzdHJ1Y3QgYnRf Z2F0dF9jbGllbnQgKmNsaWVudCwNCj4gPiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgdWludDE2X3QgdmFsdWVfaGFuZGxlLA0KPiA+ICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBidF9nYXR0X2NsaWVudF9yZWFkX2NhbGxiYWNrX3QNCj4gPiBj YWxsYmFjaywNCj4gPiAtLQ0KPiA+IDIuMTcuMQ0KPiA+DQo+IA0KPiANCj4gLS0NCj4gTHVpeiBB dWd1c3RvIHZvbiBEZW50eg0K Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ePPDL7OMEF+7CQEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 19:21:55 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id GJmxLrOMEF+TDAEA0J78UA (envelope-from ); Thu, 16 Jul 2020 19:21:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 74FBFA1B61; Thu, 16 Jul 2020 19:21:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729763AbgGPRUS (ORCPT + 1 other); Thu, 16 Jul 2020 13:20:18 -0400 Received: from mga14.intel.com ([192.55.52.115]:39260 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729745AbgGPRUO (ORCPT ); Thu, 16 Jul 2020 13:20:14 -0400 IronPort-SDR: n3W9hsnS89Fbwiwua7cX9fscNOtT4kcsjxq4UZFEA/iDWuEG6MF3hXHQZiWdfWUDaPKnldKE6Y ugOOVm0cUkkQ== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="148604663" X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="148604663" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 10:20:13 -0700 IronPort-SDR: eIe5sgMYOGT3b+obeqY4BJ1q63Zn8NAuq7ZKQ7FvtiIsPGPu9HXeb560hLfaQ7P2uF7AgeX3+8 Xelx4AepF7tg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="286550862" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga006.jf.intel.com with ESMTP; 16 Jul 2020 10:20:12 -0700 Received: from orsmsx605.amr.corp.intel.com (10.22.229.18) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 16 Jul 2020 10:20:10 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 16 Jul 2020 10:20:10 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.42) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 10:20:08 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tnn4aRrAnjGZGp1ocxoIa+tITgE0FuI6YNPpW7S/4DvocyO5Mr0a6MP/iqlgNlzCJttGCZ8dl1FAM50TYFCrnNdYZTrRneGg1/f/Rsy7yogElxh6z3BWtlHu4AXkvRFY6jko76zt+PYCBCpd8gB/knxCe6norsFDwumhdGFaISFxz9FJdL1O0b7X7cj2NFBsGpEbrz21/3XlqhOfuurVRJ6QPJBGvPKCTQi5dhWHvHoMWLzP7LBwZUwYOQ8fPlx+Z35a5ArU2IVbLjW8hhGR9oOErijLCbUr/HZVzJod17TpUXIMqrcvLm29/3ZvQ+CgY6ugku1nHUVMW/4yQ1ib8A== 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-SenderADCheck; bh=xnNNpqhfvBumIYTl80Z2HX4y0kVzcKFGYHY8JFu73Pk=; b=nRVGrwLkJVXlWZojBvUxRR7+4NKrd1+QSFjNIkUydiMAVncHE+5xvcUj/m70+120mv20aKLQkGoe25+8IcprfzzG1lgwwlFIynzF+MZDArjyooSnATVzcAHYD9ztE+MqCVghS1jXxTo/d0pjDSI/PC9iIOcupyR6z9PWw46Nlhm0tu8Z+vrvsgLte9aWLceQFyUfXJJsWN1is4ctsKfYplTobN+1yvot+7597cOWycAZfy7ak05os5nU4LlAg/fH1M3DJdfjoL91J6/rcCZ9FltRtocAa6FpKF76BbpRscSVPk/OBDT4liAt8O/J2vAPN4jCzPDuWEb/nPuzRhCFlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xnNNpqhfvBumIYTl80Z2HX4y0kVzcKFGYHY8JFu73Pk=; b=p14+9xz+OhJIXx9n2SM2AU73cZa5McmpfreBpsNkXti7n9to2QjEwYXgFVIYuAcQZCG6QKWq4JMhqZS4mUM1DQvChlo6v6WG2zxxuaRsPYOGo/75r9Z4gBYGYYYFs2rN4KnYzwpqqpiUtCyUdbm4w2m/0GbA7lTr13B9gP/kUQQ= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4620.namprd11.prod.outlook.com (2603:10b6:303:54::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.23; Thu, 16 Jul 2020 17:20:07 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%7]) with mapi id 15.20.3174.026; Thu, 16 Jul 2020 17:20:07 +0000 From: "Gix, Brian" To: "linux-bluetooth@vger.kernel.org" , "Stotland, Inga" Subject: Re: [PATCH BlueZ 0/3] Code re-org and clean up Thread-Topic: [PATCH BlueZ 0/3] Code re-org and clean up Thread-Index: AQHWWWoixoubjY9ol0mpy1g9EZK8vqkKd94A Date: Thu, 16 Jul 2020 17:20:07 +0000 Message-ID: References: <20200713230528.107948-1-inga.stotland@intel.com> In-Reply-To: <20200713230528.107948-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [134.134.137.73] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 90f42207-ae0f-4e14-3776-08d829ac7cb5 x-ms-traffictypediagnostic: MW3PR11MB4620: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: VpHAZYif3kvKfeeU1cZ8hdriQlrr6oi0jyBsFShL2wLfhJ1W8IJHZF1LKIypYkDz6uTJWAL7FNz/aYmcpCTWmOAW6NkJfdQWVg5+nToR5qZkwDe2AsHQqDzsAQ0xSessmWmwmUdD7J5dAMmHXJQuCydlT8Js9kYxf+3YCFgxSNkjtQ15iB7qRvw5x80p8ll/cqGm4RxktNw6SctwVxvCUHCjiMHlD5a8oP/T8eECbFHKIQMw7/Y4u1I+7Fxeee2DpuhuZ3jC2PuXBCC1w1N7ROn8cU19jzMlAqBSZIA0j/tWATOJ104jVPHXJarZ6VI8 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(376002)(39860400002)(396003)(366004)(71200400001)(316002)(110136005)(6506007)(83380400001)(6636002)(6486002)(36756003)(6512007)(2906002)(26005)(66946007)(86362001)(2616005)(66476007)(66446008)(4744005)(8676002)(478600001)(8936002)(186003)(76116006)(64756008)(66556008)(5660300002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: Dk+D1hqKmANdOjA5Z9reP8kK5S8okzfgAcBbbvK84rQhERNhOwLuQzqxwyfkD+rThvWZPVlAnKDXmbtRCHe7BLckVTkrj3gWedvSsZHs7XoDofNdn+0FYNc2T+DIrgfLAAusgisvBDnRaotCHDOCx1nCl91HOrTKc4Le9VvDt5T2FGRkYL6wr2PChBzp/kVKMDCS6EZnhtKtOKqOzFbwzv5v6dxqGIVzvnQKJC9hTvAzrjg6fIwXn5WqCTxXdU4Mz1x5TkO7yD68BvK8UPXUU7ZIkblq0p7XvjRYG970zaylO0BYaRCZQV/paqUD/jUZnjYZ5yQug47xqTFdIz4fnzWo0tML47daK0+u8zBJUSJtqVQb4btyNXcpmeFYlQyMsMK9603QZz+tO4zU8Vu88pRqK0cMtmH6knfo51PnnwxFx0HARbpu10QPuiAHuz0sIi4xyJmIqqRwEg4ouRrPLwkWSQmNfOwAvyRZhNcxdc6UDbf6FPu6JbV7f90PTbZH Content-Type: text/plain; charset="utf-8" Content-ID: Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90f42207-ae0f-4e14-3776-08d829ac7cb5 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jul 2020 17:20:07.4487 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: kbaCvYeblekwERB8/Ulp1Ysw054t9Q631FcjhzQekgNDxQmlVojeQfv5VsF3Y6cmOeWdTnZKbrzEYebZDIM35A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4620 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: 74FBFA1B61 X-Rspamd-UID: 939907 QXBwbGllZCBmaXJzdCB0d28gb2YgcGF0Y2hzZXQuDQoNCkhvbGRpbmcgb2ZmIG9uIHRoZSAzcmQg dW50aWwgSSBjYW4gbW9yZSB0ZXN0IG1vcmUgY29tcGxldGVseS4NCg0KT24gTW9uLCAyMDIwLTA3 LTEzIGF0IDE2OjA1IC0wNzAwLCBJbmdhIFN0b3RsYW5kIHdyb3RlOg0KPiBUaGlzIHBhdGNoIHNl dCBpcyBwYXJ0IG9mIHRoZSBvbi1nb2luZyAgY2xlYW4gdXAgZWZmb3J0IHRoYXQgdGFyZ2V0cyBz b21lDQo+IG9mIG1vcmUgY29udm9sdXRlZCBhcmVhcyBvZiBtZXNoZCBzb3VyY2UgY29kZS4NCj4g VGhlIHBhdGNoc2V0IHByb3ZpZGVzIGJldHRlciBmdW5jdGlvbmFsIHNlcGFyYXRpb24sIHNtYWxs ZXIgZnVuY3Rpb24NCj4gZ3JhbnVsYXJpdHkgYW5kIGJldHRlciBtZW1vcnkgaGFuZGxpbmcuDQo+ IA0KPiBJbmdhIFN0b3RsYW5kICgzKToNCj4gICBtZXNoOiBVc2Ugc3RhdGljIGFycmF5IHRvIGhv bGQgY29uZmlnIHNlcnZlciByZXNwb25zZQ0KPiAgIG1lc2g6IEFkZCBzaXplIGNoZWNrcyBmb3Ig ZXZlcnkgb3Bjb2RlIGluIGNvbmZpZyBzZXJ2ZXINCj4gICBtZXNoOiBtb3ZlIG1vZGVsIGZ1bmN0 aW9uYWxpdHkgb3V0IG9mIG5vZGUuYyB0byBtb2RlbC5jDQo+IA0KPiAgbWVzaC9jZmdtb2Qtc2Vy dmVyLmMgICAgfCAgOTkgKysrKysrLS0tLS0NCj4gIG1lc2gvY2ZnbW9kLmggICAgICAgICAgIHwg ICA0ICstDQo+ICBtZXNoL21lc2gtY29uZmlnLWpzb24uYyB8ICAgNSArLQ0KPiAgbWVzaC9tb2Rl bC5jICAgICAgICAgICAgfCAzNTkgKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrLS0t LS0tLQ0KPiAgbWVzaC9tb2RlbC5oICAgICAgICAgICAgfCAgMzIgKystLQ0KPiAgbWVzaC9ub2Rl LmMgICAgICAgICAgICAgfCAyODYgKysrKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0NCj4g IDYgZmlsZXMgY2hhbmdlZCwgNDAzIGluc2VydGlvbnMoKyksIDM4MiBkZWxldGlvbnMoLSkNCj4g DQo= Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ELk0FsSWEF+7CQEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 20:04:52 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EOqgFMSWEF+zNwEADc0bRg (envelope-from ); Thu, 16 Jul 2020 20:04:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 15A38527E2; Thu, 16 Jul 2020 20:04:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729306AbgGPSEq (ORCPT + 1 other); Thu, 16 Jul 2020 14:04:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbgGPSEq (ORCPT ); Thu, 16 Jul 2020 14:04:46 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC8BBC061755 for ; Thu, 16 Jul 2020 11:04:45 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id j4so3908605qvt.20 for ; Thu, 16 Jul 2020 11:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=5i6s9EyPlfxHx+66OfGFkRV1yvtiRhlOmgOMdROAJ5E=; b=RarlXJt2534WE+tm8kUm5giPC/u9gPQUYCeQIT2gsqzD9yXaOojFL4fbOejNQuwrxW GdbZiI323Yje6D3FpKTPts8AWyIhQ5TTQC6Oh6JdvP0hNa5ydvkZ6MmIn/b6eWkjZWQ3 z1+xAICplY0D5eV+RaQem9eYBvez7jvTqiPL44fgjC6FNSQiJnLPUCAVxkLHnFAqoZbk SligMV4jg5hru4IZlXMGk/zshLDlXMp7k8oiDNaX8czxCiPfHTajnTOjl2iLAZdrS6ym 7XsPRl2tB+R9jWinqe9ITAWWC1oFaSb0nVjuvv3ilDGyDQLFIi5Zm5nR4az7Oq/ku4YA fBdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=5i6s9EyPlfxHx+66OfGFkRV1yvtiRhlOmgOMdROAJ5E=; b=RL4/pbFE+vouMO6VEy4gY3ntIdLrKCS4RdBFcb+9bJEWhyRtK8KnzMtd7YsFvmxIWH +uGZOdWc1BdNr/BYI4puplIUWwJu1F3ChTUrZLClx/vgkZ4jo0w7QJHoi1CKhmFmYhiV CAxRadQ4Ddf2dy0ekXscm0fe/170J7e/5egH9UlhuXS/63Tq2oYLkQ2S14TLcY5pQYZS YL6CuAH2J2afndTFg21pnwMFTXe1b8GQ8wLU+0tjXtPaQQ4bx1mHXCTjPUziTc4bz9on LUBhnTY4edZlLwWLwj9WQCeZEi4I0hNd/5+nxbM9ikfDFouxtJUanz6Waxm4WHLelKF1 V0nw== X-Gm-Message-State: AOAM533gXjNzpDZLq4TdMt2/cX7Y4YkB7JEuwCTyXu4UO15mZnW44UdZ BcxOv5vclqWSallKo9bIIVdiGHBgvSd0LvVlOD8hUphaNLmyQ2MZh7YyxgkZOOaaGnzuB5QBEL3 SpKtm3yQp/yW/GOjjLoApOQag6YILxHe8ujnrv+aB1IUOOS/35s7BgSSSWPPxgsXgVRgbnmR1vs MH X-Google-Smtp-Source: ABdhPJxP7E3ud3LqcYh2fkpq0z88RuJ2AJ5SqCcSDXqz47n0AoN2/+LH8Lo7WcVVUUkyOIH5UDeLLAz8nXFM X-Received: by 2002:ad4:54e9:: with SMTP id k9mr5160647qvx.193.1594922684814; Thu, 16 Jul 2020 11:04:44 -0700 (PDT) Date: Fri, 17 Jul 2020 02:04:32 +0800 Message-Id: <20200717020332.Bluez.v3.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.389.gc38d7665816-goog Subject: [Bluez PATCH v3 1/2] device: add device_remove_bonding function From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 15A38527E2 X-Rspamd-UID: 273f38 From: Archie Pusaka This patch splits the "bonding removal" function in device.c, because we need to remove bonding information when receiving "virtual cable unplug" in HID profile. Reviewed-by: Alain Michaud --- Changes in v3: - Call device_set_temporary on device_remove_bonding Changes in v2: None src/device.c | 28 ++++++++++++++++++---------- src/device.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/device.c b/src/device.c index 226216235..b23ecb7fd 100644 --- a/src/device.c +++ b/src/device.c @@ -4356,6 +4356,20 @@ static void delete_folder_tree(const char *dirname) rmdir(dirname); } +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr_type) +{ + if (bdaddr_type == BDADDR_BREDR) + device->bredr_state.bonded = false; + else + device->le_state.bonded = false; + + if (!device->bredr_state.bonded && !device->le_state.bonded) + btd_device_set_temporary(device, true); + + btd_adapter_remove_bonding(device->adapter, &device->bdaddr, + bdaddr_type); +} + static void device_remove_stored(struct btd_device *device) { char device_addr[18]; @@ -4364,17 +4378,11 @@ static void device_remove_stored(struct btd_device *device) char *data; gsize length = 0; - if (device->bredr_state.bonded) { - device->bredr_state.bonded = false; - btd_adapter_remove_bonding(device->adapter, &device->bdaddr, - BDADDR_BREDR); - } + if (device->bredr_state.bonded) + device_remove_bonding(device, BDADDR_BREDR); - if (device->le_state.bonded) { - device->le_state.bonded = false; - btd_adapter_remove_bonding(device->adapter, &device->bdaddr, - device->bdaddr_type); - } + if (device->le_state.bonded) + device_remove_bonding(device, device->bdaddr_type); device->bredr_state.paired = false; device->le_state.paired = false; diff --git a/src/device.h b/src/device.h index cb8d884e8..956fec1ae 100644 --- a/src/device.h +++ b/src/device.h @@ -50,6 +50,7 @@ uint16_t btd_device_get_vendor(struct btd_device *device); uint16_t btd_device_get_vendor_src(struct btd_device *device); uint16_t btd_device_get_product(struct btd_device *device); uint16_t btd_device_get_version(struct btd_device *device); +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr_type); void device_remove(struct btd_device *device, gboolean remove_stored); int device_address_cmp(gconstpointer a, gconstpointer b); int device_bdaddr_cmp(gconstpointer a, gconstpointer b); -- 2.27.0.389.gc38d7665816-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GGISD8yWEF8gOQEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 20:05:00 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 4AhfDcyWEF8hmgEAlScrYA (envelope-from ); Thu, 16 Jul 2020 20:05:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F366A52D46; Thu, 16 Jul 2020 20:04:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729341AbgGPSEy (ORCPT + 1 other); Thu, 16 Jul 2020 14:04:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbgGPSEy (ORCPT ); Thu, 16 Jul 2020 14:04:54 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4494C061755 for ; Thu, 16 Jul 2020 11:04:53 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id g16so5951328pjz.3 for ; Thu, 16 Jul 2020 11:04:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=84ZnAl+Wl+nXgilPdMEdlwfyHxKc0sYcqxvvPLTxkKI=; b=RkJS67oZofXZ9bsHQs5EB5JBDC+D8Sm5WsrUL3WDnWovcsSdsNmH8lTqd2fq+XRigw pjBEVYFgZiC809mxuJoF24Bu676nvi3QhQzZQaz3BRppP/YfU15Xm+BHgNwB2t4Uu8Yb mdQc96JQTBR0UaQVu+PF8Lo0k51EzP/kFf0QjnNyvq2M7OW9w3eKsms7epj+j8zZLDCL +4/5H810nHpwDfHOugXPaZiDZMq1ydFJ7+fDCJto0G/xULiAHmMH+BDQZTPT+hWmdUoR ojUJfDAWFWXSn7jAlYOfpz6SP0+DdNuRI2PMfaW4cHE5M4blr+U8TD+luWDwNjxK0KNg vRbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=84ZnAl+Wl+nXgilPdMEdlwfyHxKc0sYcqxvvPLTxkKI=; b=uA6DIo5X1/nR4xhaQ8fBIQqvdOGEyz4RAKvygfXALdWN2KktNQyWgxJo02oei58b7n qpp1LXr/LQsq0kRSLH4zJuk7WSspx+dvfq1+nrovlHglgCAm8pLoH+2uIdacdoreV0zw 86UO6QbpSGZnNW7dDpNZa/Zrt+TLR2b2Exh6mNsipkoQJFGmGa+64L1SsnMSWQi5f/gy fOLULu8ZjiPQxWz2rIM5zN0sx8WQkuDXcXxydimeUI6A7uaw2z9ClGl3xnCKfFipPdat GPYomhyfy3qPiRqB1lJAaTUQ5M2yo4f8ETV0jr8+0ggBTy9zylfO7bhqbkoihgK+Cz2q 2FMA== X-Gm-Message-State: AOAM533M+O0Q18rnnYN98B2hI1nK0lIRESpaWzqjBGWCPm5X9FgxtFUC VUziC+NtVtQvQZc4Rymst2NMbmlNDIpT0hU4iniipv2WTj8h/AJ5uDoJ3YFFB5gV09gkNpChNvE Gv08iy1gk0LcwFzZ76mO7cYFGN+RrW8beaiXQ+z8okIU+ggAV9JOnmAGj9tF6JgTpvBdMNnAijv uT X-Google-Smtp-Source: ABdhPJzolNYZetJMgwDncfSJCYlU+EvegYSKOAQHxyBBm9tvK2BKTrGgFczjAaK1Nv+f4P1K4OrUnr47tuDJ X-Received: by 2002:a17:90b:30d0:: with SMTP id hi16mr6353887pjb.65.1594922693122; Thu, 16 Jul 2020 11:04:53 -0700 (PDT) Date: Fri, 17 Jul 2020 02:04:33 +0800 In-Reply-To: <20200717020332.Bluez.v3.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> Message-Id: <20200717020332.Bluez.v3.2.I16f38fd33617bbbf84d144605861b8391605a761@changeid> Mime-Version: 1.0 References: <20200717020332.Bluez.v3.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> X-Mailer: git-send-email 2.27.0.389.gc38d7665816-goog Subject: [Bluez PATCH v3 2/2] input: Remove bonding info when receiving virtual cable unplug From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: F366A52D46 X-Rspamd-UID: f3c180 From: Archie Pusaka From Bluetooth HID Profile 1.1 Spec: If a Virtual Cable is unplugged via a HID control Virtual Unplug command, then both the Bluetooth HID device and Bluetooth HID Host shall destroy or invalidate all Bluetooth bonding and Virtual Cable information that was previously stored in persistent memory for the respective Virtually Cabled devices and hosts. This patch removes the bonding information upon receiving and/or sending a "virtual cable unplug". Reviewed-by: Alain Michaud --- Changes in v3: None Changes in v2: - Properly pass the correct argument to device_remove_bonding - rename unbond_on_disconnect to virtual_cable_unplug profiles/input/device.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index 2dc2ecab2..8e29de391 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -88,6 +88,7 @@ struct input_device { uint8_t report_req_pending; guint report_req_timer; uint32_t report_rsp_id; + bool virtual_cable_unplug; }; static int idle_timeout = 0; @@ -148,6 +149,14 @@ static void input_device_free(struct input_device *idev) g_free(idev); } +static void virtual_cable_unplug(struct input_device *idev) +{ + device_remove_bonding(idev->device, + btd_device_get_bdaddr_type(idev->device)); + + idev->virtual_cable_unplug = false; +} + static bool hidp_send_message(GIOChannel *chan, uint8_t hdr, const uint8_t *data, size_t size) { @@ -188,6 +197,9 @@ static bool hidp_send_message(GIOChannel *chan, uint8_t hdr, static bool hidp_send_ctrl_message(struct input_device *idev, uint8_t hdr, const uint8_t *data, size_t size) { + if (hdr == (HIDP_TRANS_HID_CONTROL | HIDP_CTRL_VIRTUAL_CABLE_UNPLUG)) + idev->virtual_cable_unplug = true; + return hidp_send_message(idev->ctrl_io, hdr, data, size); } @@ -344,6 +356,9 @@ static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data /* Enter the auto-reconnect mode if needed */ input_device_enter_reconnect_mode(idev); + if (!idev->ctrl_io && idev->virtual_cable_unplug) + virtual_cable_unplug(idev); + return FALSE; } @@ -408,7 +423,7 @@ static void hidp_recv_ctrl_hid_control(struct input_device *idev, uint8_t param) DBG(""); if (param == HIDP_CTRL_VIRTUAL_CABLE_UNPLUG) - connection_disconnect(idev, 0); + connection_disconnect(idev, (1 << HIDP_VIRTUAL_CABLE_UNPLUG)); } static void hidp_recv_ctrl_data(struct input_device *idev, uint8_t param, @@ -532,6 +547,9 @@ static gboolean ctrl_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data if (idev->intr_io && !(cond & G_IO_NVAL)) g_io_channel_shutdown(idev->intr_io, TRUE, NULL); + if (!idev->intr_io && idev->virtual_cable_unplug) + virtual_cable_unplug(idev); + return FALSE; } @@ -1042,6 +1060,9 @@ static int connection_disconnect(struct input_device *idev, uint32_t flags) shutdown(sock, SHUT_WR); } + if (flags & (1 << HIDP_VIRTUAL_CABLE_UNPLUG)) + idev->virtual_cable_unplug = true; + if (idev->uhid) return 0; else -- 2.27.0.389.gc38d7665816-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +CUyHhohEF89CgEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 11:42:50 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wLzUHBohEF+ztAAAlp8NpQ (envelope-from ); Thu, 16 Jul 2020 11:42:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 225A2A2690; Thu, 16 Jul 2020 11:42:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726411AbgGPJml (ORCPT + 1 other); Thu, 16 Jul 2020 05:42:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbgGPJmk (ORCPT ); Thu, 16 Jul 2020 05:42:40 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50AB7C061755 for ; Thu, 16 Jul 2020 02:42:40 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id s9so6360022ljm.11 for ; Thu, 16 Jul 2020 02:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=kQ7kXhUoZLozn3MgHnFmBlQD8NJnsw2HeDSPeUP+UxY=; b=HRBM3ziZu7PceddomSG//rZdTzIqj9RAer61/nplBCC924TtEedDONC4GgQk/HXkzg YYBzkqfGIQsdEuNN7wto94A2uRhw+A/dVNCUO9g+wns71JHYx5ZV6JMxWt6GvabkbPkn gwlgu1e5Eqb55fcrwoUEMd19FicLqhLd6g6NNrDzmXEX5ffOH7BaacsUGumLJvDBG3Wn FDU/225BuGhP31sPRvq61wa7lP8KRvfw1fK86eFYaWbO2TGlzpsuStbx8cacn8aJn0cT 3geFQAxSEkml68KD+tWk1gSH0gjSzEmrXA1Isn20Q8HBklBuVncMkPhfcDkx4VFD6YRO T5fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=kQ7kXhUoZLozn3MgHnFmBlQD8NJnsw2HeDSPeUP+UxY=; b=E2BZkILts2bjknN19cOPrG24GLjXh3CeXzo3EIQYgif+icFBuA8G/bv/Q34eT++YCo RWgFnqdgsY1p1weAnF6I7Ku0k6wLXD1yXEgxgWZcTqoGMmhiWxNC978vtj+vqDGL05Yy UI0MS4gY0a3Lgcaa1nwWLdr2y3Wb33xOzmzAlaP26jwzfi0ZOfQDNpV1eLezEogBiJRe ZGYtENQycRbK/NAe547c1nbOEm22rH6V6mYE/Ztjsu44eOGdK+ooe2yTwYofTu0QEjt4 0klYettgJ03T8825TanJq1KRylVh3i0p4LTgZfy1ttNkxfVFmReXCkh5UA68vt4HARpF 52tA== X-Gm-Message-State: AOAM530MSpLvSSlZbP1usL5MEO2zZ9Aqq4+MNzM1rmUWQ0VrNa9fl/W2 H3DtlJwoDysVDAPMDLxWik0f0A== X-Google-Smtp-Source: ABdhPJzRjXHEMBXC9qnRa04p7Bs3QnjieNBDiJnegZuwyKDfdECh4bkv309gMRAvmxrk20jb0uGknA== X-Received: by 2002:a05:651c:550:: with SMTP id q16mr1550315ljp.188.1594892558686; Thu, 16 Jul 2020 02:42:38 -0700 (PDT) Received: from [192.168.52.103] ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id n7sm929720lji.97.2020.07.16.02.42.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Jul 2020 02:42:38 -0700 (PDT) Subject: Re: [PATCH BlueZ] mesh: Fix node composition change detection To: Brian Gix , linux-bluetooth@vger.kernel.org Cc: michal.lowas-rzechonek@silvair.com References: <20200715153343.2115695-1-brian.gix@intel.com> From: =?UTF-8?Q?Przemys=c5=82aw_Fierek?= Message-ID: Date: Thu, 16 Jul 2020 11:42:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200715153343.2115695-1-brian.gix@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 225A2A2690 X-Rspamd-UID: e5c6b2 LGTM and solves problem. Please merge it. /PF On 15.07.2020 17:33, Brian Gix wrote: > This fixes a bug that caused disallowed composition changes from being > detected and rejected. The only fields that are allowed to freely change > are CID, PID, VID and CRPL. > --- > mesh/node.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mesh/node.c b/mesh/node.c > index c61167bda..9b97aa927 100644 > --- a/mesh/node.c > +++ b/mesh/node.c > @@ -1579,7 +1579,7 @@ static bool check_req_node(struct managed_obj_request *req) > node = req->node; > > node_comp = node_get_comp(node, 0, &node_len); > - len = node_generate_comp(node, comp, sizeof(comp)); > + len = node_generate_comp(req->node, comp, sizeof(comp)); > > /* If no page 0 exists, save it and return */ > if (req->type != REQUEST_TYPE_ATTACH || !node_len || !node_comp) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iJI6GV83EF+nbAAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 13:17:51 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2HCBF183EF/iBgAADc0bRg (envelope-from ); Thu, 16 Jul 2020 13:17:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7C304400F9; Thu, 16 Jul 2020 13:17:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727081AbgGPLRo (ORCPT + 1 other); Thu, 16 Jul 2020 07:17:44 -0400 Received: from mxout03.lancloud.ru ([89.108.73.187]:33992 "EHLO mxout03.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbgGPLRo (ORCPT ); Thu, 16 Jul 2020 07:17:44 -0400 X-Greylist: delayed 579 seconds by postgrey-1.27 at vger.kernel.org; Thu, 16 Jul 2020 07:17:43 EDT Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout03.lancloud.ru 4E6132092F27 Received: from LanCloud Received: from LanCloud Received: from LanCloud From: Sergey Shtylyov Subject: [PATCH RFC] bluetooth: add support for some old headsets To: Marcel Holtmann , Johan Hedberg , CC: "David S. Miller" , Jakub Kicinski , Organization: Open Mobile Platform, LLC Message-ID: <6f461412-a6c0-aa53-5e74-394e278ee9b1@omprussia.ru> Date: Thu, 16 Jul 2020 14:08:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [213.87.162.13] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1908.lancloud.ru (fd00:f066::208) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 19 X-Rspamd-Score: 2.91 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7C304400F9 X-Rspamd-UID: f7c222 The MediaTek Bluetooth platform (MT6630 etc.) has a peculiar implementation for the eSCO/SCO connection via BT/EDR: the host controller returns error code 0x20 (LMP feature not supported) for HCI_Setup_Synchronous_Connection (0x0028) command without actually trying to setup connection with a remote device in case such device (like Digma BT-14 headset) didn't advertise its supported features. Even though this doesn't break compatibility with the Bluetooth standard it breaks the compatibility with the Hands-Free Profile (HFP). This patch returns the compatibility with the HFP profile and actually tries to check all available connection parameters despite of the specific MediaTek implementation. Without it one was unable to establish eSCO/SCO connection with some headsets. Based on the patch by Ildar Kamaletdinov . Signed-off-by: Sergey Shtylyov --- This patch is against the 'bluetooth-next.git' repo. net/bluetooth/hci_event.c | 8 ++++++++ 1 file changed, 8 insertions(+) Index: bluetooth-next/net/bluetooth/hci_event.c =================================================================== --- bluetooth-next.orig/net/bluetooth/hci_event.c +++ bluetooth-next/net/bluetooth/hci_event.c @@ -2187,6 +2187,13 @@ static void hci_cs_setup_sync_conn(struc if (acl) { sco = acl->link; if (sco) { + if (status == 0x20 && /* Unsupported LMP Parameter value */ + sco->out) { + sco->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | + (hdev->esco_type & EDR_ESCO_MASK); + if (hci_setup_sync(sco, sco->link->handle)) + goto unlock; + } sco->state = BT_CLOSED; hci_connect_cfm(sco, status); @@ -2194,6 +2201,7 @@ static void hci_cs_setup_sync_conn(struc } } +unlock: hci_dev_unlock(hdev); } Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mMQEOstSEF96QAEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 15:14:51 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id sLZlOMtSEF9SgAEAlp8NpQ (envelope-from ); Thu, 16 Jul 2020 15:14:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1739AA2CAA; Thu, 16 Jul 2020 15:14:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728374AbgGPNOe convert rfc822-to-8bit (ORCPT + 1 other); Thu, 16 Jul 2020 09:14:34 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:39948 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728260AbgGPNOd (ORCPT ); Thu, 16 Jul 2020 09:14:33 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 7A4F8CED01; Thu, 16 Jul 2020 15:24:30 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH RFC] bluetooth: add support for some old headsets From: Marcel Holtmann In-Reply-To: <6f461412-a6c0-aa53-5e74-394e278ee9b1@omprussia.ru> Date: Thu, 16 Jul 2020 15:14:31 +0200 Cc: Johan Hedberg , Bluetooth Kernel Mailing List , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <1834765D-52E6-45B8-9923-778C9182CFA9@holtmann.org> References: <6f461412-a6c0-aa53-5e74-394e278ee9b1@omprussia.ru> To: Sergey Shtylyov X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 20 X-Rspamd-Score: 3.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1739AA2CAA X-Rspamd-UID: 251938 Hi Sergey, > The MediaTek Bluetooth platform (MT6630 etc.) has a peculiar implementation > for the eSCO/SCO connection via BT/EDR: the host controller returns error > code 0x20 (LMP feature not supported) for HCI_Setup_Synchronous_Connection > (0x0028) command without actually trying to setup connection with a remote > device in case such device (like Digma BT-14 headset) didn't advertise its > supported features. Even though this doesn't break compatibility with the > Bluetooth standard it breaks the compatibility with the Hands-Free Profile > (HFP). > > This patch returns the compatibility with the HFP profile and actually > tries to check all available connection parameters despite of the specific > MediaTek implementation. Without it one was unable to establish eSCO/SCO > connection with some headsets. please include the parts of btmon output that show this issue. > Based on the patch by Ildar Kamaletdinov . > > Signed-off-by: Sergey Shtylyov > > --- > This patch is against the 'bluetooth-next.git' repo. > > net/bluetooth/hci_event.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > Index: bluetooth-next/net/bluetooth/hci_event.c > =================================================================== > --- bluetooth-next.orig/net/bluetooth/hci_event.c > +++ bluetooth-next/net/bluetooth/hci_event.c > @@ -2187,6 +2187,13 @@ static void hci_cs_setup_sync_conn(struc > if (acl) { > sco = acl->link; > if (sco) { > + if (status == 0x20 && /* Unsupported LMP Parameter value */ > + sco->out) { > + sco->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | > + (hdev->esco_type & EDR_ESCO_MASK); > + if (hci_setup_sync(sco, sco->link->handle)) > + goto unlock; > + } > sco->state = BT_CLOSED; since this is the command status event, I doubt that sco->out check is needed. And I would start with a switch statement right away. I also think that we need to re-structure this hci_cs_setup_sync_conn function a little to avoid the deep indentation. Make it look more like hci_sync_conn_complete_evt also use a switch statement even if right now we only have one entry. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sJr0GtFmEF9BMgAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 16:40:17 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id GAwOGdFmEF8D3wAAlScrYA (envelope-from ); Thu, 16 Jul 2020 16:40:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 878A252B89; Thu, 16 Jul 2020 16:40:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728807AbgGPOkM (ORCPT + 1 other); Thu, 16 Jul 2020 10:40:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:56532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728589AbgGPOkL (ORCPT ); Thu, 16 Jul 2020 10:40:11 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 83878206F4; Thu, 16 Jul 2020 14:40:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594910410; bh=ujNWegicnWC2dCz6IXVHu+Nito8lZ9bXxVj1ekSbGOI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZLoncI7YSBYprMk9rNo3VLbjTkx83nzUJtD4g/tPXoelyS0nCOnUoFWCYVYWIojnP dBXL0yedre4azI1E8s43qwulZPD2XG1/6AeOB+C3pmtecYqhGAWYCVQUY0R3yhqBq8 IVDDOAutDNjqBZZVFxJlr8v6a9TviTFpe+6oQOuw= Received: by pali.im (Postfix) id 62016E7A; Thu, 16 Jul 2020 16:40:08 +0200 (CEST) Date: Thu, 16 Jul 2020 16:40:08 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Szymon Janc Cc: linux-bluetooth@vger.kernel.org, Luiz Augusto von Dentz Subject: Re: [PATCH] sap: Improve error messages Message-ID: <20200716144008.fcgxcqmqfashnwam@pali> References: <20200604232433.4951-1-pali@kernel.org> <4237143.LvFx2qVVIh@ix> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4237143.LvFx2qVVIh@ix> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: 878A252B89 X-Rspamd-UID: 50f14f On Monday 15 June 2020 11:48:20 Szymon Janc wrote: > Hi, > > On Friday, 5 June 2020 01:24:33 CEST Pali Rohár wrote: > > When bluetoohd daemon is starting, it prints following error messages: > > > > bluetoothd[19117]: profiles/sap/server.c:sap_server_register() Sap driver > > initialization failed. bluetoothd[19117]: sap-server: Operation not > > permitted (1) > > > > Initialization is failing because sap server is enabled only when > > bluetoothd daemon is started with --experimental option. > > > > And "Operation not permitted" is result of returning error code -1. > > > > This patch improves error messages. When --experimental option is not used > > then bluetoothd prints more explaining error message. And in case function > > sap_init() fails then -EOPNOTSUPP "Operation not supported" is returned > > instead of -EPERM (-1). > > --- > > profiles/sap/server.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/profiles/sap/server.c b/profiles/sap/server.c > > index 5de682a33..99ff80297 100644 > > --- a/profiles/sap/server.c > > +++ b/profiles/sap/server.c > > @@ -1353,9 +1353,14 @@ int sap_server_register(struct btd_adapter *adapter) > > GIOChannel *io; > > struct sap_server *server; > > > > + if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) { > > + error("Sap driver is disabled without --experimental > option"); > > + return -EOPNOTSUPP; > > + } > > + > > Maybe just make sap_init() fail if experimental is not enabled in sap-dummy.c? I guess this is what is already happening. But failure of sap_init() means that bluetoothd daemon prints error message that initialization failed as I wrote in commit message. Therefore I added another check for experimental flag with printing different error message which contains information why it failed. > This driver is usable only for profile qualification tests and nothing more. > And TBH I'm not sure why distros are enabling SAP in first place... > > > if (sap_init() < 0) { > > error("Sap driver initialization failed."); > > - return -1; > > + return -EOPNOTSUPP; > > } > > > > record = create_sap_record(SAP_SERVER_CHANNEL); > > > -- > pozdrawiam > Szymon Janc > > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aH6sNeB8EF8WywAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 18:14:24 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id MBTnM+B8EF+jPQAAlp8NpQ (envelope-from ); Thu, 16 Jul 2020 18:14:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B4A6B52C27; Thu, 16 Jul 2020 18:14:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729158AbgGPQOS (ORCPT + 1 other); Thu, 16 Jul 2020 12:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728837AbgGPQOP (ORCPT ); Thu, 16 Jul 2020 12:14:15 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFC21C061755 for ; Thu, 16 Jul 2020 09:14:15 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id w17so4638516otl.4 for ; Thu, 16 Jul 2020 09:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=p/vg/EWDzWdxpzX57EsqsrVySq1WuKA72MFlaFDcFLo=; b=kL5hTGoWpc/i3943s+mgg1anlUDIV9rYKmKzckK5FNEaGpIV1hWMHgu7wM3BzbHSos A1fwP2fs9SDUT8UU/gxNrFPEuIXg1qqsJv2oWGqr9+kY09RXp8+ZmJcyrs8vO1gdDeEx CFHeDiwDQt55P3DWj5XNvE8ImG7sNNDRUDB8/tqyrdHWAMbJnkzTAr7aX9G84q23Es22 g5t1rhFcQ0xCx15g6hTCw5PP9Uck8Tktkn6rH5TrFbv73xvrI1dI2ZlASsBdPzuXmrSn M89sL5ZNdX3QM5IA8Sxc9BLMLrWmsCmQjwZFezXHe6I6gg0MRylEl3hkfO6HWElGOSvT MSYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=p/vg/EWDzWdxpzX57EsqsrVySq1WuKA72MFlaFDcFLo=; b=sh32kUEwVeBgu+YGaBbVkNfx8hz8vicBfjxSfbgJ703hN6EAEBdIN/aC3D5MD9gShZ 56P9Zjet/N6pGu2EEnKAedqL2665EP2+L9+eHTeORlkzVGyI+OYIQAQQ5804hLGxBvvD 9yrMKI72JtvjeUM643igcBx3xiek9JWsZPLW/dZ59krYU3iyGLCNLVzv9/JsoMTz4rlt WLGKAzahVbiERzPfggJWzanLJy/EJwmhfqT98EcJ52Yb7w1Zf2O2tB2rMF29exCnFhXE wG3nJOwYRTFzZLNh12qlvXGA2bSPIabbZC2cOnGvq9ykiDDhO4p/b+/o9EPEfruQ6PKu FJyw== X-Gm-Message-State: AOAM53218+4sl6n+rAWj0clJnFvJcjeu/gKUAHNpR7ENwRDR3zPEIWNW 5FD6MF0J1tQ//pm3k73Gt5Xj5MwIRKJOH3nZAc8= X-Google-Smtp-Source: ABdhPJwfNUpLakGMDwCO1Psv3iLZUn6Xzf8jSKMmOUFAm3dM+c/zPveOEU6QbV14sjcrattKXAl6U2b2MrT+8acqivs= X-Received: by 2002:a05:6830:1bd3:: with SMTP id v19mr5104262ota.91.1594916054886; Thu, 16 Jul 2020 09:14:14 -0700 (PDT) MIME-Version: 1.0 References: <20200627235318.Bluez.v2.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> In-Reply-To: From: Luiz Augusto von Dentz Date: Thu, 16 Jul 2020 09:14:03 -0700 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] device: add device_remove_bonding function To: Archie Pusaka Cc: linux-bluetooth , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: B4A6B52C27 X-Rspamd-UID: 935b31 Hi Archie, On Thu, Jul 16, 2020 at 12:28 AM Archie Pusaka wrote: > > Hi Luiz, > > I think spec writers' idea is to have a list of previously connected > devices which is ordered by most recently connected. The size of this > list may be limited to a number, meaning that the least recently > connected device will be removed from the list. The devices in this > list may or may not be bonded. This list is accessible to users, so > they can easily reconnect to the most recently used device. > > I don't suppose we currently have this list, so I'm happy with just > removing the virtually unplugged device. So with the latest developments Im leaning towards using device_set_temporary since that would trigger a timer to remove the device after it has expired. > Thanks, > Archie > > On Thu, 16 Jul 2020 at 01:31, Luiz Augusto von Dentz > wrote: > > > > Hi Archie, > > > > On Wed, Jul 15, 2020 at 7:15 AM Archie Pusaka wrot= e: > > > > > > Hi Luiz, > > > > > > If we mark it as temporary, then the device will immediately get > > > deleted upon disconnection. > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/adapter.c= #n6875 > > > This is the same situation as directly calling device_remove. > > > > > > May I know the reason why we want to put the device as temporary? > > > > > > If we currently don't have a way to keep a "previously connected but > > > no longer bonded" device, then removing the device perhaps is the nex= t > > > best option. It still makes the user scan for the virtually > > > disconnected device though. > > > > We keep a cache of previously known devices, but we only display them > > once they are actually found otherwise it may grow too big which is > > inconvenient, I wonder where this concept of "previously connected but > > no longer bonded" comes from though, we had the temporary to map > > devices that would not be persisted on the storage which I guess this > > is what it is about, that said we could perhaps have a timeout before > > setting it as temporary but we might want to integrate with the logic > > of detecting devices disappearing. > > > > > Thanks, > > > Archie > > > > > > On Wed, 15 Jul 2020 at 01:10, Luiz Augusto von Dentz > > > wrote: > > > > > > > > Hi Archie, > > > > > > > > On Tue, Jul 7, 2020 at 9:30 PM Archie Pusaka w= rote: > > > > > > > > > > Hi Luiz, > > > > > > > > > > As far as the spec is concerned, we can also remove the device by > > > > > calling device_remove. However, I suppose it would be confusing f= or > > > > > end users if they can no longer find their HID device on the devi= ce > > > > > list just because the device previously sent a virtual cable > > > > > disconnection. > > > > > The HID 1.0 spec part 6.4.2 also gives an example of a possible > > > > > scenario when a virtually cabled device is removed: "Unplugged de= vices > > > > > shall be marked as known and put into a =E2=80=9Cmost recently us= ed list=E2=80=9D of > > > > > known devices to facilitate future re-connecting". > > > > > > > > Then perhaps we shall have it marked as temporary as well, that sai= d > > > > we do want to introduce disappearing logic so temporary devices are > > > > not left dangling for too long. > > > > > > > > > Thanks, > > > > > Archie > > > > > > > > > > > > > > > On Wed, 8 Jul 2020 at 02:03, Luiz Augusto von Dentz > > > > > wrote: > > > > > > > > > > > > Hi Archie, > > > > > > > > > > > > On Sat, Jun 27, 2020 at 8:54 AM Archie Pusaka wrote: > > > > > > > > > > > > > > From: Archie Pusaka > > > > > > > > > > > > > > This patch splits the "bonding removal" function in device.c, > > > > > > > because we need to remove bonding information when receiving > > > > > > > "virtual cable unplug" in HID profile. > > > > > > > > > > > > > > Reviewed-by: Alain Michaud > > > > > > > --- > > > > > > > > > > > > > > Changes in v2: None > > > > > > > > > > > > > > src/device.c | 25 +++++++++++++++---------- > > > > > > > src/device.h | 1 + > > > > > > > 2 files changed, 16 insertions(+), 10 deletions(-) > > > > > > > > > > > > > > diff --git a/src/device.c b/src/device.c > > > > > > > index 7b0eb256e..9fb0e018c 100644 > > > > > > > --- a/src/device.c > > > > > > > +++ b/src/device.c > > > > > > > @@ -4162,6 +4162,17 @@ static void delete_folder_tree(const c= har *dirname) > > > > > > > rmdir(dirname); > > > > > > > } > > > > > > > > > > > > > > +void device_remove_bonding(struct btd_device *device, uint8_= t bdaddr_type) > > > > > > > +{ > > > > > > > + if (bdaddr_type =3D=3D BDADDR_BREDR) > > > > > > > + device->bredr_state.bonded =3D false; > > > > > > > + else > > > > > > > + device->le_state.bonded =3D false; > > > > > > > + > > > > > > > + btd_adapter_remove_bonding(device->adapter, &device->= bdaddr, > > > > > > > + bdadd= r_type); > > > > > > > +} > > > > > > > + > > > > > > > static void device_remove_stored(struct btd_device *device) > > > > > > > { > > > > > > > char device_addr[18]; > > > > > > > @@ -4170,17 +4181,11 @@ static void device_remove_stored(stru= ct btd_device *device) > > > > > > > char *data; > > > > > > > gsize length =3D 0; > > > > > > > > > > > > > > - if (device->bredr_state.bonded) { > > > > > > > - device->bredr_state.bonded =3D false; > > > > > > > - btd_adapter_remove_bonding(device->adapter, &= device->bdaddr, > > > > > > > - = BDADDR_BREDR); > > > > > > > - } > > > > > > > + if (device->bredr_state.bonded) > > > > > > > + device_remove_bonding(device, BDADDR_BREDR); > > > > > > > > > > > > > > - if (device->le_state.bonded) { > > > > > > > - device->le_state.bonded =3D false; > > > > > > > - btd_adapter_remove_bonding(device->adapter, &= device->bdaddr, > > > > > > > - devic= e->bdaddr_type); > > > > > > > - } > > > > > > > + if (device->le_state.bonded) > > > > > > > + device_remove_bonding(device, device->bdaddr_= type); > > > > > > > > > > > > > > device->bredr_state.paired =3D false; > > > > > > > device->le_state.paired =3D false; > > > > > > > diff --git a/src/device.h b/src/device.h > > > > > > > index 06b100499..907c7c5c4 100644 > > > > > > > --- a/src/device.h > > > > > > > +++ b/src/device.h > > > > > > > @@ -49,6 +49,7 @@ uint16_t btd_device_get_vendor(struct btd_d= evice *device); > > > > > > > uint16_t btd_device_get_vendor_src(struct btd_device *device= ); > > > > > > > uint16_t btd_device_get_product(struct btd_device *device); > > > > > > > uint16_t btd_device_get_version(struct btd_device *device); > > > > > > > +void device_remove_bonding(struct btd_device *device, uint8_= t bdaddr_type); > > > > > > > void device_remove(struct btd_device *device, gboolean remov= e_stored); > > > > > > > > > > > > Is there any particular reason why device_remove is not enough = here? I > > > > > > don't see any reason to leave the device object around after re= moving > > > > > > its bonding. > > > > > > > > > > > > > int device_address_cmp(gconstpointer a, gconstpointer b); > > > > > > > int device_bdaddr_cmp(gconstpointer a, gconstpointer b); > > > > > > > -- > > > > > > > 2.27.0.212.ge8ba1cc988-goog > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > > > > > -- > > > > Luiz Augusto von Dentz > > > > > > > > -- > > Luiz Augusto von Dentz --=20 Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KNgIC4x9EF/hwgAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 18:17:16 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 0NOiCYx9EF/yzgAA0J78UA (envelope-from ); Thu, 16 Jul 2020 18:17:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0BE5D52AF2; Thu, 16 Jul 2020 18:17:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729269AbgGPQRD (ORCPT + 1 other); Thu, 16 Jul 2020 12:17:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728837AbgGPQRC (ORCPT ); Thu, 16 Jul 2020 12:17:02 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93913C061755; Thu, 16 Jul 2020 09:17:02 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id e4so5546551oib.1; Thu, 16 Jul 2020 09:17:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X40K+wu84kv/mAn7oQZlyEv2lZtROdjFfXssqudkZyk=; b=CzQ7XtUl+MF8GX6TDg0e7SD3lj/qAvD2KStC71O3eWB9OfCW1BzsVvv/1iL8Y/mCQU fN4joOmmJ/0uBygZJGef06IoX4h0ZNXifm3VHogUnAyZF+JcP3a1A2oE0fy2dFP4kvGP xFwmr+MQ4KPFtF164bEtu/G5WF0V2aacWYR1UIw9DG6B9wXrAAKRf8fZMioRBck37MTT xDfVdarzCWeHMa0Mcm8G0uKITIWQrHyEZzqO/otpqo8m1gPlhSBO+cYLrrDuNmAXIUFr 7PyR6Ypsa5VwoAihahqLjZVDJJOgD0mwVwE889vQFE/8GYrGcOFoobKSzHwwFrV7pbIR o9Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=X40K+wu84kv/mAn7oQZlyEv2lZtROdjFfXssqudkZyk=; b=CykDlEcmT1kC2H2aWyojyiVqPNLX4xGvnAWSj6ivw4caP+btFOqHpOk7SZF0PtQMWG sheJrM6/xt7VAFOUAxRCfKcm6Wiau5JGQqoEeKjIUSPYoOBb1MlbLwzx2JDUifBnv7m/ 1kbb0SiI/9H1T644Q1oi2oKq/Y/1acXwOjwHpTkC4DBtzDgE8LmVqqNjwUL2XAdhNWJO mI0ESsGnUI2dHnvnINkMmhaEoz7fvRuL0uv4dA5URN9ZQUkqixJjYoHepmkjlgjfP+Rj n/cn09D4bb0AZbrsNerRFabWI0bRgSsa+AzjGPwU8t++HeLRC3/boYFNk7+aY8chbRu9 TfbQ== X-Gm-Message-State: AOAM533UAvdZIP7ou/bfURfOfdmI2I3BgZL4on2LjmFbbGWjkIZJel1X Ip4EDAkrcRN30O+zjhMMSqp+ErqpBjSHBJMxcug5waNjv+M= X-Google-Smtp-Source: ABdhPJyMB5in8yNJ9qyfWT0teHY8MlwUvugWwOfShB8Gk0BOZqaBFWTvfCAz9fPqJKDu2FcmeWO5eTMrRY/82Sq3lYQ= X-Received: by 2002:aca:cf81:: with SMTP id f123mr4528403oig.137.1594916221887; Thu, 16 Jul 2020 09:17:01 -0700 (PDT) MIME-Version: 1.0 References: <3635193ecd8c6034731387404825e998df2fd788.camel@redhat.com> In-Reply-To: <3635193ecd8c6034731387404825e998df2fd788.camel@redhat.com> From: Luiz Augusto von Dentz Date: Thu, 16 Jul 2020 09:16:50 -0700 Message-ID: Subject: Re: Commit 'Bluetooth: Consolidate encryption handling in hci_encrypt_cfm' broke my JBL TUNE500BT headphones To: Maxim Levitsky Cc: Linux Kernel Mailing List , Luiz Augusto Von Dentz , Marcel Holtmann , Johan Hedberg , "linux-bluetooth@vger.kernel.org" , "open list:NETWORKING [GENERAL]" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0BE5D52AF2 X-Rspamd-UID: 0e6415 Hi Maxim, On Thu, Jul 16, 2020 at 1:29 AM Maxim Levitsky wrote: > > Hi, > > Few days ago I bisected a recent regression in the 5.8 kernel: > > git bisect start > # good: [3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162] Linux 5.7 > git bisect good 3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162 > # bad: [dcde237b9b0eb1d19306e6f48c0a4e058907619f] Merge tag 'perf-tools-fixes-2020-07-07' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux > git bisect bad dcde237b9b0eb1d19306e6f48c0a4e058907619f > # bad: [a0a4d17e02a80a74a63c7cbb7bc8cea2f0b7d8b1] Merge branch 'pcmcia-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux > git bisect bad a0a4d17e02a80a74a63c7cbb7bc8cea2f0b7d8b1 > # good: [09587a09ada2ed7c39aedfa2681152b5ac5641ee] arm64: mm: use ARCH_HAS_DEBUG_WX instead of arch defined > git bisect good 09587a09ada2ed7c39aedfa2681152b5ac5641ee > # good: [3248044ecf9f91900be5678919966715f1fb8834] Merge tag 'wireless-drivers-next-2020-05-25' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next > git bisect good 3248044ecf9f91900be5678919966715f1fb8834 > # bad: [cb8e59cc87201af93dfbb6c3dccc8fcad72a09c2] Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next > git bisect bad cb8e59cc87201af93dfbb6c3dccc8fcad72a09c2 > # bad: [b8215dce7dfd817ca38807f55165bf502146cd68] selftests/bpf, flow_dissector: Close TAP device FD after the test > git bisect bad b8215dce7dfd817ca38807f55165bf502146cd68 > # good: [b8ded9de8db34dd209a3dece94cf54fc414e78f7] net/smc: pre-fetch send buffer outside of send_lock > git bisect good b8ded9de8db34dd209a3dece94cf54fc414e78f7 > # good: [1079a34c56c535c3e27df8def0d3c5069d2de129] Merge tag 'mac80211-next-for-davem-2020-05-31' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next > git bisect good 1079a34c56c535c3e27df8def0d3c5069d2de129 > # bad: [f395b69f40f580491ef56f2395a98e3189baa53c] dpaa2-eth: Add PFC support through DCB ops > git bisect bad f395b69f40f580491ef56f2395a98e3189baa53c > # bad: [a74d19ba7c41b6c1e424ef4fb7d4600f43ff75e5] net: fec: disable correct clk in the err path of fec_enet_clk_enable > git bisect bad a74d19ba7c41b6c1e424ef4fb7d4600f43ff75e5 > # bad: [dafe2078a75af1abe4780313ef8dd8491ba8598f] ipv4: nexthop: Fix deadcode issue by performing a proper NULL check > git bisect bad dafe2078a75af1abe4780313ef8dd8491ba8598f > # bad: [feac90d756c03b03b83fabe83571bd88ecc96b78] Bluetooth: hci_qca: Fix suspend/resume functionality failure > git bisect bad feac90d756c03b03b83fabe83571bd88ecc96b78 > # good: [a228f7a410290d836f3a9f9b1ed5aef1aab25cc7] Bluetooth: hci_qca: Enable WBS support for wcn3991 > git bisect good a228f7a410290d836f3a9f9b1ed5aef1aab25cc7 > # bad: [755dfcbca83710fa967d0efa7c5bb601f871a747] Bluetooth: Fix assuming EIR flags can result in SSP authentication > git bisect bad 755dfcbca83710fa967d0efa7c5bb601f871a747 > # bad: [3ca44c16b0dcc764b641ee4ac226909f5c421aa3] Bluetooth: Consolidate encryption handling in hci_encrypt_cfm > git bisect bad 3ca44c16b0dcc764b641ee4ac226909f5c421aa3 > # first bad commit: [3ca44c16b0dcc764b641ee4ac226909f5c421aa3] Bluetooth: Consolidate encryption handling in hci_encrypt_cfm We just merged a fix for that: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/commit/?id=339ddaa626995bc6218972ca241471f3717cc5f4 > The sympthoms are that I am unable to pair the headphones, and even if I use an older kernel > to pair them, and then switch to the new kernel, the connection is established only sometimes. > > Without this commit, I can pair the headphones 100% of the time. > > I am not familiar with bluetooth debugging but I am willing to provide > any logs, do tests and try patches. > > I am running fedora 32 on the affected system which has built-in intel wireless/bluetooth card, > > PCI (wifi) part: > 47:00.0 Network controller: Intel Corporation Wi-Fi 6 AX200 (rev 1a) > > USB (bluetooth) parrt: > Bus 011 Device 004: ID 8087:0029 Intel Corp. > > My .config attached (custom built kernel) > > Best regards, > Maxim Levitsky > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2KliJe5+EF/hwgAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 18:23:10 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qI/HI+5+EF8VOQEAlScrYA (envelope-from ); Thu, 16 Jul 2020 18:23:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B14D552E2C; Thu, 16 Jul 2020 18:23:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729027AbgGPQXF (ORCPT + 1 other); Thu, 16 Jul 2020 12:23:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728837AbgGPQXE (ORCPT ); Thu, 16 Jul 2020 12:23:04 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F51EC061755 for ; Thu, 16 Jul 2020 09:23:04 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id e90so4677735ote.1 for ; Thu, 16 Jul 2020 09:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=IZc2F918h2+FHFet26cGpwU2BaEtZt3mo3ssI9Dft3U=; b=YeqI6KJEcghpQRPuHbtZBrisGOPwUqHOE9ZD0Hzks+S1psI5yUN2pN0GYHAeGmRoRS fHl3UBQqoyoHtoJLzB+GEOyAev5E9FXY/zRdrmcHI0f9vihQPF/MNYdIoEEODLC/u9vu QV/KSIQevwTRFXam+M9pTFstFt5ZU+GPbLmg7rqmXEDcL4KH2h2tcM0P9xl5JTU6HepM dV/YWVoUaG6ziuVrju/Fzjv6lGlQXztu2p2h/4SIOuCVmaq1ibKW7ETZi95SnmyxrGaa FeQUDyozeC8cE0fLdq7p9B+oiV943vtBbCQLerQHacqBhJ6Joqu00ewPg4rsYGTSqFgw WlTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=IZc2F918h2+FHFet26cGpwU2BaEtZt3mo3ssI9Dft3U=; b=HD/Yle2K00RMubv4lZYs8FZgMIfOWozEkZ/9+MP1T5hQ6mHS0dBPQX478o3SFMEFa5 T1ToH7UsKgJuKuO01JUPBUvnZDNdPBQmPllFBFHnaQlu5eh+4xfx4VBZCtMgDB6MSHA3 zIcFX6OzsX4L91a0FQkj4iqZbVJvUSTfeZoLOO9Cdv2Mx96amx4ia8EkPAw/XBcxLIze iStE4yLZPsjUgQhSFzYhLFtTuLoOLsVo6MgWsGaT9W9lyPRE16H1OYaUdsA38XeKN4yL 6c4swvwmJc4o7rkpofVnqKwuTjBgK7Cvm0PasL8R38CswmDux3YztCoW9BxDwwDicFVc MDxw== X-Gm-Message-State: AOAM533vo1e4teSseJB8DBkLkgkOjgv7IRjoG4PzXpfSj0EWveq6P6hw vTk1/yXhwATbGCNxtycVLz5rgrXxm9k0qxie/ai0jyRjVy4= X-Google-Smtp-Source: ABdhPJwUuCmjoh1rO2VOnD+R3nJopK6weO4QH8X5fYth49o0hwgH0HO3CLcpFxkkWhZCB6IoUy525ECr2CxYKuJY6uI= X-Received: by 2002:a9d:6c09:: with SMTP id f9mr5056421otq.362.1594916583801; Thu, 16 Jul 2020 09:23:03 -0700 (PDT) MIME-Version: 1.0 References: <20200605142541.28412-1-amitx.k.singh@intel.com> <20200605142541.28412-4-amitx.k.singh@intel.com> In-Reply-To: From: Luiz Augusto von Dentz Date: Thu, 16 Jul 2020 09:22:52 -0700 Message-ID: Subject: Re: [PATCH 1/2] bluez:load Generic access service To: "Singh, AmitX K" Cc: "linux-bluetooth@vger.kernel.org" , "Panda, Bharat B" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -6.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: B14D552E2C X-Rspamd-UID: f86d2d Hi Amit, On Thu, Jul 16, 2020 at 1:40 AM Singh, AmitX K wr= ote: > > Hi Luiz, > > > -----Original Message----- > > From: Luiz Augusto von Dentz > > Sent: Friday, June 5, 2020 10:34 PM > > To: Singh, AmitX K > > Cc: linux-bluetooth@vger.kernel.org > > Subject: Re: [PATCH 1/2] bluez:load Generic access service > > > > Hi Amit, > > > > On Fri, Jun 5, 2020 at 7:31 AM Amitsi5x wrote= : > > > > > > From: =E2=80=9CAmitSingh=E2=80=9D > > > > > > It allow to load generic access service to database > > > > > > Signed-off-by: =E2=80=9CAmitSingh=E2=80=9D > > > --- > > > src/gatt-client.c | 3 --- > > > 1 file changed, 3 deletions(-) > > > > > > diff --git a/src/gatt-client.c b/src/gatt-client.c index > > > 20c3fbec2..2ae258da0 100644 > > > --- a/src/gatt-client.c > > > +++ b/src/gatt-client.c > > > @@ -2009,9 +2009,6 @@ static void export_service(struct > > gatt_db_attribute *attr, void *user_data) > > > struct btd_gatt_client *client =3D user_data; > > > struct service *service; > > > > > > - if (gatt_db_service_get_claimed(attr)) > > > - return; > > > - > > > > This is actually done on purpose in order to avoid extra traffic since = the > > daemon already exposes this information in other interfaces. > > > > GAP service is not getting stored is hash database .To verify the PTS tes= t case GATT/CL/GAD/BV-02-C which is GAP service discovery with '1800' UUID= , verdicts as "INCONCLUSIVE" as it does not find the GAP UUID in place BlueZ does perform the so-called discover all service procedure, perhaps you need to select the procedure correctly in order to pass this test. > > > service =3D service_create(attr, client); > > > if (!service) > > > return; > > > -- > > > 2.17.1 > > > > -- > > Luiz Augusto von Dentz --=20 Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KOB+BYR/EF8WywAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 18:25:40 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 6FqVBIR/EF/nzAAA0J78UA (envelope-from ); Thu, 16 Jul 2020 18:25:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=mg.codeaurora.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3FF0E52CF9; Thu, 16 Jul 2020 18:25:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729272AbgGPQZ2 (ORCPT + 1 other); Thu, 16 Jul 2020 12:25:28 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:36246 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729027AbgGPQZ1 (ORCPT ); Thu, 16 Jul 2020 12:25:27 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1594916727; h=Message-ID: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=OmL2KI53czE52TZ8+f9g2m5kzP3WpYA0NVG5N/4LwQ4=; b=A5HC3UkucmQB3RuyQOUSPAaavt81okTW5cV2lk9Vpzd7kJCTab6v8ND8CqZaBqqCDjzer/Gf rnoAK36Q+DgGYq7/+rmPRtZctG+y0YOwCa8av1k4yb6uOM9DGXcYuv9rDpBV9ST36Y2+LXIS 2ElhOdoGmUcxZTJfPhGaxRs85nM= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI2MTA3ZSIsICJsaW51eC1ibHVldG9vdGhAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n18.prod.us-west-2.postgun.com with SMTP id 5f107f70c9bd2efa2effe878 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 16 Jul 2020 16:25:20 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 3C60DC43395; Thu, 16 Jul 2020 16:25:20 +0000 (UTC) Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: bgodavar) by smtp.codeaurora.org (Postfix) with ESMTPSA id D70DEC433C6; Thu, 16 Jul 2020 16:25:19 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 16 Jul 2020 21:55:19 +0530 From: bgodavar@codeaurora.org To: linux-firmware@kernel.org, jwboyer@kernel.org Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, gubbaven@codeaurora.org, abhishekpandit@chromium.org Subject: QCA: Add correct bin file for WCN3991 Message-ID: <6abd991d5d7d5175f5b7c6b168af770b@codeaurora.org> X-Sender: bgodavar@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.63 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3FF0E52CF9 X-Rspamd-UID: 295a3f The following changes since commit 3d3a06f720856cb897a8541951edd0b8f6f54a98: linux-firmware: Update firmware file for Intel Bluetooth AX201 (2020-07-13 07:51:54 -0400) are available in the git repository at: https://github.com/bgodavar/qca_bt_fw/tree/qca_0714 for you to fetch changes up to 3882702815e4b88bfd2f20b7eb66a3e85cbbb9b9: QCA: Add correct bin file for WCN3991 (2020-07-14 11:00:13 +0530) ---------------------------------------------------------------- Balakrishna Godavarthi (1): QCA: Add correct bin file for WCN3991 qca/crnv32.bin | Bin 5299 -> 5299 bytes 1 file changed, 0 insertions(+), 0 deletions(-) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +BSkCOiWEF8gOQEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 20:05:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8JxcB+iWEF+hWgAAlp8NpQ (envelope-from ); Thu, 16 Jul 2020 20:05:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4CDF5A30CB; Thu, 16 Jul 2020 20:05:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729379AbgGPSFO (ORCPT + 1 other); Thu, 16 Jul 2020 14:05:14 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:50907 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728400AbgGPSFO (ORCPT ); Thu, 16 Jul 2020 14:05:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594922712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bid2o9xhItv8ji/omqfjaS5XC1iUfTcX7qDylksvkag=; b=ftQOUQs5M7bf5HDPv5kkva6f/FIHXxXCFVTCyA1WE07HGq6xBnIkt+zAP8I0edD+mGCrU4 SeaxIlPXV2VZPIOChGK2vpU4b37SP+RmNUq3UXPkGM1hKNb/3Zy4o+rA7ntMHbj8H4VI/L vIukWfK+Scgb6gU5H5vXMZsgI13p9cI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-pKAFVRVJPHa_-99xo-LAlQ-1; Thu, 16 Jul 2020 14:05:08 -0400 X-MC-Unique: pKAFVRVJPHa_-99xo-LAlQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C72D88014D4; Thu, 16 Jul 2020 18:05:06 +0000 (UTC) Received: from starship (unknown [10.35.206.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id A29F761982; Thu, 16 Jul 2020 18:05:04 +0000 (UTC) Message-ID: <616736b7d9433625a429bc37f0c5120115d02f44.camel@redhat.com> Subject: Re: Commit 'Bluetooth: Consolidate encryption handling in hci_encrypt_cfm' broke my JBL TUNE500BT headphones From: Maxim Levitsky To: Luiz Augusto von Dentz Cc: Linux Kernel Mailing List , Luiz Augusto Von Dentz , Marcel Holtmann , Johan Hedberg , "linux-bluetooth@vger.kernel.org" , "open list:NETWORKING [GENERAL]" Date: Thu, 16 Jul 2020 21:05:03 +0300 In-Reply-To: References: <3635193ecd8c6034731387404825e998df2fd788.camel@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4CDF5A30CB X-Rspamd-UID: 998cb1 On Thu, 2020-07-16 at 09:16 -0700, Luiz Augusto von Dentz wrote: > Hi Maxim, > > On Thu, Jul 16, 2020 at 1:29 AM Maxim Levitsky wrote: > > Hi, > > > > Few days ago I bisected a recent regression in the 5.8 kernel: > > > > git bisect start > > # good: [3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162] Linux 5.7 > > git bisect good 3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162 > > # bad: [dcde237b9b0eb1d19306e6f48c0a4e058907619f] Merge tag 'perf-tools-fixes-2020-07-07' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux > > git bisect bad dcde237b9b0eb1d19306e6f48c0a4e058907619f > > # bad: [a0a4d17e02a80a74a63c7cbb7bc8cea2f0b7d8b1] Merge branch 'pcmcia-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux > > git bisect bad a0a4d17e02a80a74a63c7cbb7bc8cea2f0b7d8b1 > > # good: [09587a09ada2ed7c39aedfa2681152b5ac5641ee] arm64: mm: use ARCH_HAS_DEBUG_WX instead of arch defined > > git bisect good 09587a09ada2ed7c39aedfa2681152b5ac5641ee > > # good: [3248044ecf9f91900be5678919966715f1fb8834] Merge tag 'wireless-drivers-next-2020-05-25' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next > > git bisect good 3248044ecf9f91900be5678919966715f1fb8834 > > # bad: [cb8e59cc87201af93dfbb6c3dccc8fcad72a09c2] Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next > > git bisect bad cb8e59cc87201af93dfbb6c3dccc8fcad72a09c2 > > # bad: [b8215dce7dfd817ca38807f55165bf502146cd68] selftests/bpf, flow_dissector: Close TAP device FD after the test > > git bisect bad b8215dce7dfd817ca38807f55165bf502146cd68 > > # good: [b8ded9de8db34dd209a3dece94cf54fc414e78f7] net/smc: pre-fetch send buffer outside of send_lock > > git bisect good b8ded9de8db34dd209a3dece94cf54fc414e78f7 > > # good: [1079a34c56c535c3e27df8def0d3c5069d2de129] Merge tag 'mac80211-next-for-davem-2020-05-31' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next > > git bisect good 1079a34c56c535c3e27df8def0d3c5069d2de129 > > # bad: [f395b69f40f580491ef56f2395a98e3189baa53c] dpaa2-eth: Add PFC support through DCB ops > > git bisect bad f395b69f40f580491ef56f2395a98e3189baa53c > > # bad: [a74d19ba7c41b6c1e424ef4fb7d4600f43ff75e5] net: fec: disable correct clk in the err path of fec_enet_clk_enable > > git bisect bad a74d19ba7c41b6c1e424ef4fb7d4600f43ff75e5 > > # bad: [dafe2078a75af1abe4780313ef8dd8491ba8598f] ipv4: nexthop: Fix deadcode issue by performing a proper NULL check > > git bisect bad dafe2078a75af1abe4780313ef8dd8491ba8598f > > # bad: [feac90d756c03b03b83fabe83571bd88ecc96b78] Bluetooth: hci_qca: Fix suspend/resume functionality failure > > git bisect bad feac90d756c03b03b83fabe83571bd88ecc96b78 > > # good: [a228f7a410290d836f3a9f9b1ed5aef1aab25cc7] Bluetooth: hci_qca: Enable WBS support for wcn3991 > > git bisect good a228f7a410290d836f3a9f9b1ed5aef1aab25cc7 > > # bad: [755dfcbca83710fa967d0efa7c5bb601f871a747] Bluetooth: Fix assuming EIR flags can result in SSP authentication > > git bisect bad 755dfcbca83710fa967d0efa7c5bb601f871a747 > > # bad: [3ca44c16b0dcc764b641ee4ac226909f5c421aa3] Bluetooth: Consolidate encryption handling in hci_encrypt_cfm > > git bisect bad 3ca44c16b0dcc764b641ee4ac226909f5c421aa3 > > # first bad commit: [3ca44c16b0dcc764b641ee4ac226909f5c421aa3] Bluetooth: Consolidate encryption handling in hci_encrypt_cfm > > We just merged a fix for that: > > https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/commit/?id=339ddaa626995bc6218972ca241471f3717cc5f4 Perfect. I tested the fix and it works well. Do you plan to send this for inclusion to 5.8 kernel? Best regards, Maxim Levitsky > > > The sympthoms are that I am unable to pair the headphones, and even if I use an older kernel > > to pair them, and then switch to the new kernel, the connection is established only sometimes. > > > > Without this commit, I can pair the headphones 100% of the time. > > > > I am not familiar with bluetooth debugging but I am willing to provide > > any logs, do tests and try patches. > > > > I am running fedora 32 on the affected system which has built-in intel wireless/bluetooth card, > > > > PCI (wifi) part: > > 47:00.0 Network controller: Intel Corporation Wi-Fi 6 AX200 (rev 1a) > > > > USB (bluetooth) parrt: > > Bus 011 Device 004: ID 8087:0029 Intel Corp. > > > > My .config attached (custom built kernel) > > > > Best regards, > > Maxim Levitsky > > > > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ENgVAhWYEF8bdQEAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 20:10:29 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id ABtPOxSYEF9PCwAAgupzMw (envelope-from ); Thu, 16 Jul 2020 20:10:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 68C1AA256D; Thu, 16 Jul 2020 20:10:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728257AbgGPSKW (ORCPT + 1 other); Thu, 16 Jul 2020 14:10:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728126AbgGPSKV (ORCPT ); Thu, 16 Jul 2020 14:10:21 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A65BC061755 for ; Thu, 16 Jul 2020 11:10:21 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id k6so8064842wrn.3 for ; Thu, 16 Jul 2020 11:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=O9TdJlKj2qkYgEi+QGiAjDMgJdfsZwXS6hAHdYU0AZw=; b=A2RqJ2A+8Yd1dAWaoTIYzj52RoMW05kf6qvDcYzBQ6y/UIKvU28qB2FMVNcwLMSVHC 6J/Ktn/WCF3wrhF4fmzEyAvt5ToImZTm4TCQK9yaCSgOaP3FE7kd77mrygvkE69QBMXs g/GcAMG2FFNyzctldU/dGRIwnmxkZdiiNV+6ytErVBLbGu/8GIordAvZXkST6A5GZoXj QKIdc9Km13LA9dlrnb2VCY0Jeej0dRGa10jJEzdw+FFHA6Kr84flvRRukBOcNHJlq0V2 noXRxSFDLRy0IHAKY9rrH72cbHg6ebPu8GSTjzBnJPvH/35UQY3vhL4NMU1wPqOsRGAO PT0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=O9TdJlKj2qkYgEi+QGiAjDMgJdfsZwXS6hAHdYU0AZw=; b=lOEhBjCdpl/A13PX5K9K/XSwDOGaCmhXRvEFCt1TJwRwlWzmBtU4+Z48p6DgGDOM99 8OjeXIHs8ctg+e0iWL9BI/vwU4skNWEqb8wcfC4woyejsbaUW4myJLERiNXs1HznPaHe Oi3FmMijBhAQM3eI/90zKt5w/tvby4U7D7yc2BqfljiQycxIFb6ZFrWDV1ufuR0r79VS Wr/QplZaRlSEAQCI3HAnnfzOwW7hhQ0BfJlNkbxbvxFQpczl+7R/gt6kWBnljeNp1mPS Xr3vswwTUGDmOmR/bD3wDsmTaP844HjhseCTX2eNmzJmObwi6+veRrurkyayS04rqTRV rEBw== X-Gm-Message-State: AOAM531qVBHKdUHHXeSidnkorogWgYeH44ZQOQRuWAw93fhqgOavsIVk qnl0KTusIfL6z5KSo1hu7JglnrW8+TOqBX2McrpiQA== X-Google-Smtp-Source: ABdhPJykLY/v5N/YKnpt2hfp/Z4GRYrtoV5ohON4KQO2+/zx02VjpZbVo5tiweKfYOUiPTrgi+xU84kYyg9ndXemSm4= X-Received: by 2002:adf:f10a:: with SMTP id r10mr6035408wro.406.1594923019857; Thu, 16 Jul 2020 11:10:19 -0700 (PDT) MIME-Version: 1.0 References: <20200627235318.Bluez.v2.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> In-Reply-To: From: Archie Pusaka Date: Fri, 17 Jul 2020 02:10:08 +0800 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] device: add device_remove_bonding function To: Luiz Augusto von Dentz Cc: linux-bluetooth , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 68C1AA256D X-Rspamd-UID: cdb46e Hi Luiz, I submitted a patch which calls device_set_temporary, but upon testing the device still immediately gets deleted after receiving virtual cable disconnect, since we delete temporary devices on adapter_remove_connection(). The timer doesn't make any difference this way. Thanks, Archie On Fri, 17 Jul 2020 at 00:14, Luiz Augusto von Dentz wrote: > > Hi Archie, > > On Thu, Jul 16, 2020 at 12:28 AM Archie Pusaka wrote= : > > > > Hi Luiz, > > > > I think spec writers' idea is to have a list of previously connected > > devices which is ordered by most recently connected. The size of this > > list may be limited to a number, meaning that the least recently > > connected device will be removed from the list. The devices in this > > list may or may not be bonded. This list is accessible to users, so > > they can easily reconnect to the most recently used device. > > > > I don't suppose we currently have this list, so I'm happy with just > > removing the virtually unplugged device. > > So with the latest developments Im leaning towards using > device_set_temporary since that would trigger a timer to remove the > device after it has expired. > > > Thanks, > > Archie > > > > On Thu, 16 Jul 2020 at 01:31, Luiz Augusto von Dentz > > wrote: > > > > > > Hi Archie, > > > > > > On Wed, Jul 15, 2020 at 7:15 AM Archie Pusaka wr= ote: > > > > > > > > Hi Luiz, > > > > > > > > If we mark it as temporary, then the device will immediately get > > > > deleted upon disconnection. > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/adapter= .c#n6875 > > > > This is the same situation as directly calling device_remove. > > > > > > > > May I know the reason why we want to put the device as temporary? > > > > > > > > If we currently don't have a way to keep a "previously connected bu= t > > > > no longer bonded" device, then removing the device perhaps is the n= ext > > > > best option. It still makes the user scan for the virtually > > > > disconnected device though. > > > > > > We keep a cache of previously known devices, but we only display them > > > once they are actually found otherwise it may grow too big which is > > > inconvenient, I wonder where this concept of "previously connected bu= t > > > no longer bonded" comes from though, we had the temporary to map > > > devices that would not be persisted on the storage which I guess this > > > is what it is about, that said we could perhaps have a timeout before > > > setting it as temporary but we might want to integrate with the logic > > > of detecting devices disappearing. > > > > > > > Thanks, > > > > Archie > > > > > > > > On Wed, 15 Jul 2020 at 01:10, Luiz Augusto von Dentz > > > > wrote: > > > > > > > > > > Hi Archie, > > > > > > > > > > On Tue, Jul 7, 2020 at 9:30 PM Archie Pusaka = wrote: > > > > > > > > > > > > Hi Luiz, > > > > > > > > > > > > As far as the spec is concerned, we can also remove the device = by > > > > > > calling device_remove. However, I suppose it would be confusing= for > > > > > > end users if they can no longer find their HID device on the de= vice > > > > > > list just because the device previously sent a virtual cable > > > > > > disconnection. > > > > > > The HID 1.0 spec part 6.4.2 also gives an example of a possible > > > > > > scenario when a virtually cabled device is removed: "Unplugged = devices > > > > > > shall be marked as known and put into a =E2=80=9Cmost recently = used list=E2=80=9D of > > > > > > known devices to facilitate future re-connecting". > > > > > > > > > > Then perhaps we shall have it marked as temporary as well, that s= aid > > > > > we do want to introduce disappearing logic so temporary devices a= re > > > > > not left dangling for too long. > > > > > > > > > > > Thanks, > > > > > > Archie > > > > > > > > > > > > > > > > > > On Wed, 8 Jul 2020 at 02:03, Luiz Augusto von Dentz > > > > > > wrote: > > > > > > > > > > > > > > Hi Archie, > > > > > > > > > > > > > > On Sat, Jun 27, 2020 at 8:54 AM Archie Pusaka wrote: > > > > > > > > > > > > > > > > From: Archie Pusaka > > > > > > > > > > > > > > > > This patch splits the "bonding removal" function in device.= c, > > > > > > > > because we need to remove bonding information when receivin= g > > > > > > > > "virtual cable unplug" in HID profile. > > > > > > > > > > > > > > > > Reviewed-by: Alain Michaud > > > > > > > > --- > > > > > > > > > > > > > > > > Changes in v2: None > > > > > > > > > > > > > > > > src/device.c | 25 +++++++++++++++---------- > > > > > > > > src/device.h | 1 + > > > > > > > > 2 files changed, 16 insertions(+), 10 deletions(-) > > > > > > > > > > > > > > > > diff --git a/src/device.c b/src/device.c > > > > > > > > index 7b0eb256e..9fb0e018c 100644 > > > > > > > > --- a/src/device.c > > > > > > > > +++ b/src/device.c > > > > > > > > @@ -4162,6 +4162,17 @@ static void delete_folder_tree(const= char *dirname) > > > > > > > > rmdir(dirname); > > > > > > > > } > > > > > > > > > > > > > > > > +void device_remove_bonding(struct btd_device *device, uint= 8_t bdaddr_type) > > > > > > > > +{ > > > > > > > > + if (bdaddr_type =3D=3D BDADDR_BREDR) > > > > > > > > + device->bredr_state.bonded =3D false; > > > > > > > > + else > > > > > > > > + device->le_state.bonded =3D false; > > > > > > > > + > > > > > > > > + btd_adapter_remove_bonding(device->adapter, &device= ->bdaddr, > > > > > > > > + bda= ddr_type); > > > > > > > > +} > > > > > > > > + > > > > > > > > static void device_remove_stored(struct btd_device *device= ) > > > > > > > > { > > > > > > > > char device_addr[18]; > > > > > > > > @@ -4170,17 +4181,11 @@ static void device_remove_stored(st= ruct btd_device *device) > > > > > > > > char *data; > > > > > > > > gsize length =3D 0; > > > > > > > > > > > > > > > > - if (device->bredr_state.bonded) { > > > > > > > > - device->bredr_state.bonded =3D false; > > > > > > > > - btd_adapter_remove_bonding(device->adapter,= &device->bdaddr, > > > > > > > > - = BDADDR_BREDR); > > > > > > > > - } > > > > > > > > + if (device->bredr_state.bonded) > > > > > > > > + device_remove_bonding(device, BDADDR_BREDR)= ; > > > > > > > > > > > > > > > > - if (device->le_state.bonded) { > > > > > > > > - device->le_state.bonded =3D false; > > > > > > > > - btd_adapter_remove_bonding(device->adapter,= &device->bdaddr, > > > > > > > > - dev= ice->bdaddr_type); > > > > > > > > - } > > > > > > > > + if (device->le_state.bonded) > > > > > > > > + device_remove_bonding(device, device->bdadd= r_type); > > > > > > > > > > > > > > > > device->bredr_state.paired =3D false; > > > > > > > > device->le_state.paired =3D false; > > > > > > > > diff --git a/src/device.h b/src/device.h > > > > > > > > index 06b100499..907c7c5c4 100644 > > > > > > > > --- a/src/device.h > > > > > > > > +++ b/src/device.h > > > > > > > > @@ -49,6 +49,7 @@ uint16_t btd_device_get_vendor(struct btd= _device *device); > > > > > > > > uint16_t btd_device_get_vendor_src(struct btd_device *devi= ce); > > > > > > > > uint16_t btd_device_get_product(struct btd_device *device)= ; > > > > > > > > uint16_t btd_device_get_version(struct btd_device *device)= ; > > > > > > > > +void device_remove_bonding(struct btd_device *device, uint= 8_t bdaddr_type); > > > > > > > > void device_remove(struct btd_device *device, gboolean rem= ove_stored); > > > > > > > > > > > > > > Is there any particular reason why device_remove is not enoug= h here? I > > > > > > > don't see any reason to leave the device object around after = removing > > > > > > > its bonding. > > > > > > > > > > > > > > > int device_address_cmp(gconstpointer a, gconstpointer b); > > > > > > > > int device_bdaddr_cmp(gconstpointer a, gconstpointer b); > > > > > > > > -- > > > > > > > > 2.27.0.212.ge8ba1cc988-goog > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > > > > > > > > > -- > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qBg+EKC7EF+ySQAAvsO+Rg (envelope-from ) for ; Thu, 16 Jul 2020 22:42:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id ENZ0DqC7EF/4bAAAgupzMw (envelope-from ); Thu, 16 Jul 2020 22:42:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 13DA9526C3; Thu, 16 Jul 2020 22:41:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726564AbgGPUlt (ORCPT + 1 other); Thu, 16 Jul 2020 16:41:49 -0400 Received: from mxout04.lancloud.ru ([89.108.124.63]:49028 "EHLO mxout04.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725926AbgGPUls (ORCPT ); Thu, 16 Jul 2020 16:41:48 -0400 X-Greylist: delayed 484 seconds by postgrey-1.27 at vger.kernel.org; Thu, 16 Jul 2020 16:41:47 EDT Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout04.lancloud.ru A7CC920F54B3 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH RFC] bluetooth: add support for some old headsets To: Marcel Holtmann CC: Johan Hedberg , Bluetooth Kernel Mailing List , "David S. Miller" , Jakub Kicinski , References: <6f461412-a6c0-aa53-5e74-394e278ee9b1@omprussia.ru> <1834765D-52E6-45B8-9923-778C9182CFA9@holtmann.org> From: Sergey Shtylyov Organization: Open Mobile Platform, LLC Message-ID: Date: Thu, 16 Jul 2020 23:33:40 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1834765D-52E6-45B8-9923-778C9182CFA9@holtmann.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [213.87.162.122] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1908.lancloud.ru (fd00:f066::208) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 14 X-Rspamd-Score: 2.12 / 15.00 / 200.00 X-Rspamd-Queue-Id: 13DA9526C3 X-Rspamd-UID: b6403e Hello! On 7/16/20 4:14 PM, Marcel Holtmann wrote: >> The MediaTek Bluetooth platform (MT6630 etc.) has a peculiar implementation >> for the eSCO/SCO connection via BT/EDR: the host controller returns error >> code 0x20 (LMP feature not supported) for HCI_Setup_Synchronous_Connection >> (0x0028) command without actually trying to setup connection with a remote >> device in case such device (like Digma BT-14 headset) didn't advertise its >> supported features. Even though this doesn't break compatibility with the >> Bluetooth standard it breaks the compatibility with the Hands-Free Profile >> (HFP). >> >> This patch returns the compatibility with the HFP profile and actually >> tries to check all available connection parameters despite of the specific >> MediaTek implementation. Without it one was unable to establish eSCO/SCO >> connection with some headsets. > > please include the parts of btmon output that show this issue. Funny, I had removed that part from the original patch. Here's that log: < HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17 #1 [hci0] 6.705320 Handle: 50 Transmit bandwidth: 8000 Receive bandwidth: 8000 Max latency: 10 Setting: 0x0060 Input Coding: Linear Input Data Format: 2's complement Input Sample Size: 16-bit of bits padding at MSB: 0 Air Coding Format: CVSD Retransmission effort: Optimize for power consumption (0x01) Packet type: 0x0380 3-EV3 may not be used 2-EV5 may not be used 3-EV5 may not be used > HCI Event: Command Status (0x0f) plen 4 #2 [hci0] 6.719598 Setup Synchronous Connection (0x01|0x0028) ncmd 1 Status: Unsupported LMP Parameter Value / Unsupported LL Parameter Value (0x20) >> Based on the patch by Ildar Kamaletdinov . >> >> Signed-off-by: Sergey Shtylyov >> >> --- >> This patch is against the 'bluetooth-next.git' repo. >> >> net/bluetooth/hci_event.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> Index: bluetooth-next/net/bluetooth/hci_event.c >> =================================================================== >> --- bluetooth-next.orig/net/bluetooth/hci_event.c >> +++ bluetooth-next/net/bluetooth/hci_event.c >> @@ -2187,6 +2187,13 @@ static void hci_cs_setup_sync_conn(struc >> if (acl) { >> sco = acl->link; >> if (sco) { >> + if (status == 0x20 && /* Unsupported LMP Parameter value */ >> + sco->out) { >> + sco->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | >> + (hdev->esco_type & EDR_ESCO_MASK); >> + if (hci_setup_sync(sco, sco->link->handle)) >> + goto unlock; >> + } >> sco->state = BT_CLOSED; > > since this is the command status event, I doubt that sco->out check is needed. Can't comment oin this, my BT fu is too weak... > And I would start with a switch statement right away. Funny, I had removed the *switch* statement from the original patch... :-) > I also think that we need to re-structure this hci_cs_setup_sync_conn function a little to avoid the deep indentation. > Make it look more like hci_sync_conn_complete_evt also use a switch statement even if right now we only have one > entry. Indeed, done now. :-) > Regards > > Marcel MBR, Sergey Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iB7oG27gEF963wAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 01:19:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 0MmRGm7gEF+mMQAA0J78UA (envelope-from ); Fri, 17 Jul 2020 01:19:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7DEEAA2F31; Fri, 17 Jul 2020 01:19:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726962AbgGPXTF (ORCPT + 1 other); Thu, 16 Jul 2020 19:19:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726113AbgGPXTD (ORCPT ); Thu, 16 Jul 2020 19:19:03 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5DB3C08C5DB for ; Thu, 16 Jul 2020 16:19:02 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id a24so4429633pfc.10 for ; Thu, 16 Jul 2020 16:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PDMHwDVtsDk5UMkcQwleT4i0giCi3Nlydh8pBuDrWH4=; b=eU/FMNwSC6iFYkrn6ugnLK6IWYy0FM1/D+KO46qIZ8kNgm1Ms9OKDEblKs5nS0LxY+ qvlw0uihm+6X5uvZjzWQEa+a/km1GAJT9Fcf8Fapyh/7ElYkXw3Z6vO2mwBb5w3f3vNL Ulh4uhhvzR+WJK4h6Wba+LgG/HhDKV/l0OMAUKU/vsU355q5zybNkT+xcNXlPVF0gUl2 1CQM1RjadXKwzqM9GBd3/6EEfZjykbOYNgRKdiSOwBb4C/dKo/jPPE4r4aHqTJT60Ssx Or+YOsSKRAvmccEYHo5jxkt6bUTmLor6fEuNZq49Ntgv0FvDfoPwj468SjyiaypbWTTo ugPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PDMHwDVtsDk5UMkcQwleT4i0giCi3Nlydh8pBuDrWH4=; b=ZpNOhLlam9SN60qAEm+1K7fZi8FhubmoAQjwBUWIOgnwCyTQ8VnB1P1P/3kZiyFFjS M8IsbeMop9L60+k32+fuUzN+3kV5lE99Fgj23KYKzvEMKrcIP3rpkz0n7zGnW1ovdPUf Ju1th8X6XDbXnxHEJAZvrgZMMz1m2C9G8HgnxszpOOAniyNZ2ZO9di6riBJDbuV36DGI o0xRRetVF5+HVf6OwdlKbIanBK6HBddsrlLedf4OZ+et2S6x9J293GLMp5jg7Cae5V+u mHbXq4vP2yjokFI597YhoY65+IwQ911ph5u2yOf72URdVcNmy5dRTF0X/d3Cb4PHmgsH 1xcg== X-Gm-Message-State: AOAM533PE8MzJWDXkJ1iy0JUbNRUnK/gmHEh8VC6lFW09fyh73KU0RUi R7qsAh/od4bHRlmZlWpnaDVTKc71Vrg= X-Google-Smtp-Source: ABdhPJwAcBI4xHNvuFN4ykd9hCIoZ/lS3nebdw3y0zL00Abf5QaTu2asFKNgLkThePTZgMwEvoXzRQ== X-Received: by 2002:a62:ce88:: with SMTP id y130mr5699199pfg.37.1594941541956; Thu, 16 Jul 2020 16:19:01 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id a2sm6024530pgf.53.2020.07.16.16.19.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 16:19:01 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 4/4] share/gatt-client: Don't remove active services Date: Thu, 16 Jul 2020 16:18:57 -0700 Message-Id: <20200716231857.934396-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200716231857.934396-1-luiz.dentz@gmail.com> References: <20200716231857.934396-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7DEEAA2F31 X-Rspamd-UID: 312a3f From: Luiz Augusto von Dentz Only remove services that have not been fetched completed as unsuccessful discovery may be the result of an aborted connection the attributes that have been fetched previously are likely to be valid. --- src/shared/gatt-client.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index e21aca1f0..5ba8e83ba 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -407,11 +407,17 @@ static void discovery_op_complete(struct discovery_op *op, bool success, gatt_db_unregister(op->client->db, op->db_id); op->db_id = 0; - /* Remove services pending */ + /* Remove staled services */ for (svc = queue_get_entries(op->pending_svcs); svc; svc = svc->next) { struct gatt_db_attribute *attr = svc->data; uint16_t start, end; + /* Don't remove services that already been marked as active + * previously. + */ + if (gatt_db_service_get_active(attr)) + continue; + gatt_db_attribute_get_service_data(attr, &start, &end, NULL, NULL); -- 2.25.3 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8EXjJ3PgEF/y+QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 01:19:15 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id iHgaJnPgEF/w/wAAgupzMw (envelope-from ); Fri, 17 Jul 2020 01:19:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8F659A1EE4; Fri, 17 Jul 2020 01:19:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726977AbgGPXTF (ORCPT + 1 other); Thu, 16 Jul 2020 19:19:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbgGPXTD (ORCPT ); Thu, 16 Jul 2020 19:19:03 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FC1FC08C5C0 for ; Thu, 16 Jul 2020 16:19:00 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id b92so5441967pjc.4 for ; Thu, 16 Jul 2020 16:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8usU1d9z6P0on7EH8VOSZKPN/Qf36pOKKeX7ZcAp564=; b=hOGI+TPsl3RU1UI4/IxdpjCKs1mdb22uSRHSLUxuJZoIjCdnAPiRhJUxcgqjK5oFPI kKqepTqY6QzQ1AEike/tEhONqEJp1nO18sblgWfqfnHIh/HEcCDUBzAgSAdETRpSO7h2 sQ4wNZwp18PD0X0iCiQlJMLnScdEQheJD23T4CZpDqH2zCvCHUU/9TIcDGOQzL0SHf40 HTKs4zWgF+xi7GmPFwPJZtUrmz2kRSoz4uTM36vZQptfts9mVoeGt7/mX5JO/i4u3lRx bwQsz/qGHMMDcm9RMNYIfLeHbT1eHGB4kMmef6kevYR23FwHe1Rw80YxlXva7NULrnum nV0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8usU1d9z6P0on7EH8VOSZKPN/Qf36pOKKeX7ZcAp564=; b=lV7kHfT2jssaWAQ7PR8NEOgUWLf++vqs1z4EE0dzaxOKViZu9zyTv11EacoVBwloM2 QkKk1h9GOlcdYBk9sqHyL1ryvOZW+EcdObwkFqspmO4k+QUgEu87jDATykSvSWXHWG3I 8YGNSGc8FXqXta3U1rMarqp9M9H30LU2C8ORzPZrC/zdigQwZt3oJX3E5vHtESN4bKwp pbzT0YxkpkKOD2JJ0/V66Dz68zcSKNBB7EdYrE5JLGwUdjJtSL4nIuCsoNOaIKcrscys ePfjIkK42MJsXq1fkqxeRzooE8fJS1uZX241oXDFkjOtUPJt2IotQaqYr+vE0AUdJX2J Tb6w== X-Gm-Message-State: AOAM531nWSLFVwb4i+kAJb59h56kRS13qMn3lvijl2dbaBRObfRxhrK0 9m8mKdlWtl5TDpQgGpK1gPaQHvn4y6s= X-Google-Smtp-Source: ABdhPJzYMPNoNHP9RTwTd2WT7XKzMeeZ58JmGjSk4IOsBjF0xjj9MPmI80sZbmxR/kk0QlhZ/O2vUA== X-Received: by 2002:a17:90b:3010:: with SMTP id hg16mr7268925pjb.69.1594941539458; Thu, 16 Jul 2020 16:18:59 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id a2sm6024530pgf.53.2020.07.16.16.18.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 16:18:59 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 2/4] shared/gatt-db: Add support for notifying attribute changes Date: Thu, 16 Jul 2020 16:18:55 -0700 Message-Id: <20200716231857.934396-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200716231857.934396-1-luiz.dentz@gmail.com> References: <20200716231857.934396-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8F659A1EE4 X-Rspamd-UID: cdcb0c From: Luiz Augusto von Dentz This enables to get notified when an attribute has been changed e.g. it is being removed so the code can detect changes changes at attribute level. --- src/shared/gatt-db.c | 103 +++++++++++++++++++++++++++++++++++++++++++ src/shared/gatt-db.h | 8 ++++ 2 files changed, 111 insertions(+) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index 5eccab3b9..e939ddc3a 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -81,6 +81,13 @@ struct notify { void *user_data; }; +struct attribute_notify { + unsigned int id; + gatt_db_attribute_cb_t removed; + gatt_db_destroy_func_t destroy; + void *user_data; +}; + struct pending_read { struct gatt_db_attribute *attrib; unsigned int id; @@ -114,6 +121,9 @@ struct gatt_db_attribute { unsigned int write_id; struct queue *pending_writes; + + unsigned int next_notify_id; + struct queue *notify_list; }; struct gatt_db_service { @@ -171,6 +181,16 @@ static void pending_write_free(void *data) pending_write_result(p, -ECANCELED); } +static void attribute_notify_destroy(void *data) +{ + struct attribute_notify *notify = data; + + if (notify->destroy) + notify->destroy(notify->user_data); + + free(notify); +} + static void attribute_destroy(struct gatt_db_attribute *attribute) { /* Attribute was not initialized by user */ @@ -179,6 +199,7 @@ static void attribute_destroy(struct gatt_db_attribute *attribute) queue_destroy(attribute->pending_reads, pending_read_free); queue_destroy(attribute->pending_writes, pending_write_free); + queue_destroy(attribute->notify_list, attribute_notify_destroy); free(attribute->value); free(attribute); @@ -208,6 +229,7 @@ static struct gatt_db_attribute *new_attribute(struct gatt_db_service *service, attribute->pending_reads = queue_new(); attribute->pending_writes = queue_new(); + attribute->notify_list = queue_new(); return attribute; @@ -352,12 +374,38 @@ static bool db_hash_update(void *user_data) return false; } +static void handle_attribute_notify(void *data, void *user_data) +{ + struct attribute_notify *notify = data; + struct gatt_db_attribute *attrib = user_data; + + if (notify->removed) + notify->removed(attrib, notify->user_data); +} + +static void notify_attribute_changed(struct gatt_db_service *service) +{ + int i; + + for (i = 0; i < service->num_handles; i++) { + struct gatt_db_attribute *attr = service->attributes[i]; + + if (!attr) + continue; + + queue_foreach(attr->notify_list, handle_attribute_notify, attr); + } +} + static void notify_service_changed(struct gatt_db *db, struct gatt_db_service *service, bool added) { struct notify_data data; + if (!added) + notify_attribute_changed(service); + if (queue_isempty(db->notify_list)) return; @@ -1993,3 +2041,58 @@ void *gatt_db_attribute_get_user_data(struct gatt_db_attribute *attrib) return attrib->user_data; } + +static bool match_attribute_notify_id(const void *a, const void *b) +{ + const struct attribute_notify *notify = a; + unsigned int id = PTR_TO_UINT(b); + + return notify->id == id; +} + +unsigned int gatt_db_attribute_register(struct gatt_db_attribute *attrib, + gatt_db_attribute_cb_t removed, + void *user_data, + gatt_db_destroy_func_t destroy) +{ + struct attribute_notify *notify; + + if (!attrib || !removed) + return 0; + + notify = new0(struct attribute_notify, 1); + notify->removed = removed; + notify->destroy = destroy; + notify->user_data = user_data; + + if (attrib->next_notify_id < 1) + attrib->next_notify_id = 1; + + notify->id = attrib->next_notify_id++; + + if (!queue_push_tail(attrib->notify_list, notify)) { + free(notify); + return 0; + } + + return notify->id; +} + +bool gatt_db_attribute_unregister(struct gatt_db_attribute *attrib, + unsigned int id) +{ + struct attribute_notify *notify; + + if (!attrib || !id) + return false; + + notify = queue_find(attrib->notify_list, match_attribute_notify_id, + UINT_TO_PTR(id)); + if (!notify) + return false; + + queue_remove(attrib->notify_list, notify); + attribute_notify_destroy(notify); + + return true; +} diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h index a0fd66c53..5bf19d302 100644 --- a/src/shared/gatt-db.h +++ b/src/shared/gatt-db.h @@ -281,3 +281,11 @@ bool gatt_db_attribute_write_result(struct gatt_db_attribute *attrib, bool gatt_db_attribute_reset(struct gatt_db_attribute *attrib); void *gatt_db_attribute_get_user_data(struct gatt_db_attribute *attrib); + +unsigned int gatt_db_attribute_register(struct gatt_db_attribute *attrib, + gatt_db_attribute_cb_t removed, + void *user_data, + gatt_db_destroy_func_t destroy); + +bool gatt_db_attribute_unregister(struct gatt_db_attribute *attrib, + unsigned int id); -- 2.25.3 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +HD4L3jgEF/y+QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 01:19:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QKf5LXjgEF+KDwEAgupzMw (envelope-from ); Fri, 17 Jul 2020 01:19:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BEC53A2F31; Fri, 17 Jul 2020 01:19:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726984AbgGPXTG (ORCPT + 1 other); Thu, 16 Jul 2020 19:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726189AbgGPXTD (ORCPT ); Thu, 16 Jul 2020 19:19:03 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAE64C061755 for ; Thu, 16 Jul 2020 16:18:59 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id gc15so3446068pjb.0 for ; Thu, 16 Jul 2020 16:18:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=CX74muhyV/pRHgal4c+5eAgaYcu9OhB2bqVlNBbpWPY=; b=tlWeZyYhdvELQRbBK2wYeh7v+/nzkmqiwAHHOdyaLkUS37fs0dgjxxcbJpTNI58iAi Qm1X21B1Agd53gndQSjM6T8dzuXT/kpLLGeGFVZxDQHn8yCQMWbhEGR3aFxt43BI5KHE ff+pYUKIW+00a80+W3A3jWpXMYPzNs/h8SxRbecftE8r/yTUSZgqAdJAW5bBVjwQCG0b g95Ae7W59/GjCO8+dhKw4EkYDeDdftNF/dwjfnw/ntm86aO9eHL3X6GUFDup1V4JrrJE 25e6X3DkgPmzewURI7x7UDneUkXDij1hxFvAlsTILd/fv6PyKDgFA4KGjbaU/Xh1ncwR IJPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=CX74muhyV/pRHgal4c+5eAgaYcu9OhB2bqVlNBbpWPY=; b=D3hpvgSfaxm90rSvEEZSiGb4iQmXL9kSZfZdt0kV2zR/vUuhBNMOX7LihCUoSNlf0e 9E7ODOCdvvH7Dst/U4N4B/dXtg5mw0SeTo2o/uMzfesaOED/wxu+h/H8yapkb/PiGfuf tV57IwOPeIR5PPcYVEUC5ddDYqrMqhFRXYS6Z+vxfnD6tqDi0cVsAvWh5Eif/YEJHBf5 mGqDCa38faeCpx+pUOJs6n1DxxREVA/faOSit5Jwk9jWafcD3RgaqasQfygaK5tgplVD Usk9cGIGjw4ko+FFHVGX/LjxX/M8El5fkuF4Tt/3W71UW+ZEsc4/xZRrA2WCs/1E3dSW D9+Q== X-Gm-Message-State: AOAM530v7ZHa7FF0PwZbtRlKNmmr38BYFbqPpZvfKmi4l8Rfg9IyzSu2 XYXeqiU0R67yLDOUp2E0Q4OJbIZkYKY= X-Google-Smtp-Source: ABdhPJxzCyao9FEV6ADUuVRH1cVu6hwwZhNukvJxA8Vnwb+9UtCL3xwz7ww8x7vTkRYsl8MJUze9eQ== X-Received: by 2002:a17:90a:d304:: with SMTP id p4mr7482109pju.153.1594941538736; Thu, 16 Jul 2020 16:18:58 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id a2sm6024530pgf.53.2020.07.16.16.18.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 16:18:58 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/4] shared/att: Fix possible crash on disconnect Date: Thu, 16 Jul 2020 16:18:54 -0700 Message-Id: <20200716231857.934396-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.25.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: BEC53A2F31 X-Rspamd-UID: 2cd61b From: Luiz Augusto von Dentz If there are pending request while disconnecting they would be notified but clients may endup being freed in the proccess which will then be calling bt_att_cancel to cancal its requests causing the following trace: Invalid read of size 4 at 0x1D894C: enable_ccc_callback (gatt-client.c:1627) by 0x1D247B: disc_att_send_op (att.c:417) by 0x1CCC17: queue_remove_all (queue.c:354) by 0x1D47B7: disconnect_cb (att.c:635) by 0x1E0707: watch_callback (io-glib.c:170) by 0x48E963B: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.6400.4) by 0x48E9AC7: ??? (in /usr/lib/libglib-2.0.so.0.6400.4) by 0x48E9ECF: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.6400.4) by 0x1E0E97: mainloop_run (mainloop-glib.c:79) by 0x1E13B3: mainloop_run_with_signal (mainloop-notify.c:201) by 0x12BC3B: main (main.c:770) Address 0x7d40a28 is 24 bytes inside a block of size 32 free'd at 0x484A2E0: free (vg_replace_malloc.c:540) by 0x1CCC17: queue_remove_all (queue.c:354) by 0x1CCC83: queue_destroy (queue.c:73) by 0x1D7DD7: bt_gatt_client_free (gatt-client.c:2209) by 0x16497B: batt_free (battery.c:77) by 0x16497B: batt_remove (battery.c:286) by 0x1A0013: service_remove (service.c:176) by 0x1A9B7B: device_remove_gatt_service (device.c:3691) by 0x1A9B7B: gatt_service_removed (device.c:3805) by 0x1CC90B: queue_foreach (queue.c:220) by 0x1DE27B: notify_service_changed.isra.0.part.0 (gatt-db.c:369) by 0x1DE387: notify_service_changed (gatt-db.c:361) by 0x1DE387: gatt_db_service_destroy (gatt-db.c:385) by 0x1DE3EF: gatt_db_remove_service (gatt-db.c:519) by 0x1D674F: discovery_op_complete (gatt-client.c:388) by 0x1D6877: discover_primary_cb (gatt-client.c:1260) by 0x1E220B: discovery_op_complete (gatt-helpers.c:628) by 0x1E249B: read_by_grp_type_cb (gatt-helpers.c:730) by 0x1D247B: disc_att_send_op (att.c:417) by 0x1CCC17: queue_remove_all (queue.c:354) by 0x1D47B7: disconnect_cb (att.c:635) --- src/shared/att.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/src/shared/att.c b/src/shared/att.c index ed3af2920..58f23dfcb 100644 --- a/src/shared/att.c +++ b/src/shared/att.c @@ -84,6 +84,7 @@ struct bt_att { struct queue *req_queue; /* Queued ATT protocol requests */ struct queue *ind_queue; /* Queued ATT protocol indications */ struct queue *write_queue; /* Queue of PDUs ready to send */ + bool in_disc; /* Cleanup queues on disconnect_cb */ bt_att_timeout_func_t timeout_callback; bt_att_destroy_func_t timeout_destroy; @@ -222,8 +223,10 @@ static void destroy_att_send_op(void *data) free(op); } -static void cancel_att_send_op(struct att_send_op *op) +static void cancel_att_send_op(void *data) { + struct att_send_op *op = data; + if (op->destroy) op->destroy(op->user_data); @@ -631,11 +634,6 @@ static bool disconnect_cb(struct io *io, void *user_data) /* Dettach channel */ queue_remove(att->chans, chan); - /* Notify request callbacks */ - queue_remove_all(att->req_queue, NULL, NULL, disc_att_send_op); - queue_remove_all(att->ind_queue, NULL, NULL, disc_att_send_op); - queue_remove_all(att->write_queue, NULL, NULL, disc_att_send_op); - if (chan->pending_req) { disc_att_send_op(chan->pending_req); chan->pending_req = NULL; @@ -654,6 +652,15 @@ static bool disconnect_cb(struct io *io, void *user_data) bt_att_ref(att); + att->in_disc = true; + + /* Notify request callbacks */ + queue_remove_all(att->req_queue, NULL, NULL, disc_att_send_op); + queue_remove_all(att->ind_queue, NULL, NULL, disc_att_send_op); + queue_remove_all(att->write_queue, NULL, NULL, disc_att_send_op); + + att->in_disc = false; + queue_foreach(att->disconn_list, disconn_handler, INT_TO_PTR(err)); bt_att_unregister_all(att); @@ -1574,6 +1581,30 @@ bool bt_att_chan_cancel(struct bt_att_chan *chan, unsigned int id) return true; } +static bool bt_att_disc_cancel(struct bt_att *att, unsigned int id) +{ + struct att_send_op *op; + + op = queue_find(att->req_queue, match_op_id, UINT_TO_PTR(id)); + if (op) + goto done; + + op = queue_find(att->ind_queue, match_op_id, UINT_TO_PTR(id)); + if (op) + goto done; + + op = queue_find(att->write_queue, match_op_id, UINT_TO_PTR(id)); + +done: + if (!op) + return false; + + /* Just cancel since disconnect_cb will be cleaning up */ + cancel_att_send_op(op); + + return true; +} + bool bt_att_cancel(struct bt_att *att, unsigned int id) { const struct queue_entry *entry; @@ -1591,6 +1622,9 @@ bool bt_att_cancel(struct bt_att *att, unsigned int id) return true; } + if (att->in_disc) + return bt_att_disc_cancel(att, id); + op = queue_remove_if(att->req_queue, match_op_id, UINT_TO_PTR(id)); if (op) goto done; -- 2.25.3 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iBUnMX3gEF/y+QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 01:19:25 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id GN5hL33gEF8WlgAADc0bRg (envelope-from ); Fri, 17 Jul 2020 01:19:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E36A2A1EE4; Fri, 17 Jul 2020 01:19:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727025AbgGPXTH (ORCPT + 1 other); Thu, 16 Jul 2020 19:19:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726846AbgGPXTD (ORCPT ); Thu, 16 Jul 2020 19:19:03 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3051C08C5CE for ; Thu, 16 Jul 2020 16:19:01 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id mn17so5591576pjb.4 for ; Thu, 16 Jul 2020 16:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HeZXwV8yLxbY3gUDwoAQlT9mAbB9u1/YqIhjlLCDDdI=; b=tUC56eiCD/aT0BlQDJwZ0AhSw+h5q5mTFpWNTIz9Rf8uY8xLQrMi/4B+z4F5nH097Q jStadvqIXBzoJH+0W/ngYmuAgVaRYZqYpTb9m2MwMTz5MUW8iyUFCVaAWSGz8KoN7Rep D1uJmI/WqsIvhEQrT2Qv3sYDgZWEwYC5gWAQTRUYGKbYDshj9p2ui+evxytb4pMgZR6Z V84I61+sSEw676t63oUPsOWZAmHNuJg3ZF9YcBMu9AXi6yw2Dn+7xV3u/PWYuEsbjXX0 aAUgZvYe9Fv3jfU4x3j5coVMk2mmPDHJCUZPw6oM5dMeKLspjNJyI/FqRWQnDUjmy5mA ZDcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HeZXwV8yLxbY3gUDwoAQlT9mAbB9u1/YqIhjlLCDDdI=; b=AUgnYFJ8ndK5z7pN9Y2qMhXTCCBSHpQXmTbL9bObx7BELl8ur51R8nTgQpmSP3NoTJ tOBPwQduR1l+/41fU/VYry0TCKcM+muBP5QjgXdAS1TJ2YxGG36tZqiSZ/88kjhc3esx /czAEjokQ+8mvkhInYSLE2Zi9Sm96gYp2FbV8Xr157rinprtc9BHjjXO+2/7x5eJCgVE AxlRbsqEnQSY0iYLjtMHANU2PzvEemkCbIPoSicx72q7JV4xPQqAbHW/ymFUlkeTUEqS D1pt1VJ/7G48VPhArIp1j1Tww+yziUkbOqiODIhchLoK6qJh+iwJ/W8MrSmmGfxwWd9p Q2rw== X-Gm-Message-State: AOAM533Wwy4EaCeUMco4e+YqSka6Ygl68rUTd0JsJdEvvtnG/Dykdsyt EYHNSLsO9csi4EM/8C/0xYH813KkDjI= X-Google-Smtp-Source: ABdhPJxkbMksebSnHK9DUdx7VczpcMEC+0UCKkIwmvynQN+3D7NfvEoUESbKWfFnTZJIGogSHHpt1A== X-Received: by 2002:a17:902:40a:: with SMTP id 10mr5429639ple.180.1594941540986; Thu, 16 Jul 2020 16:19:00 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id a2sm6024530pgf.53.2020.07.16.16.18.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 16:19:00 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 3/4] shared/gatt-client: Remove notification if its attribute is removed Date: Thu, 16 Jul 2020 16:18:56 -0700 Message-Id: <20200716231857.934396-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200716231857.934396-1-luiz.dentz@gmail.com> References: <20200716231857.934396-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: E36A2A1EE4 X-Rspamd-UID: baeab0 From: Luiz Augusto von Dentz If the attribute is being removed from the database it means the notification shall also be dropped, that way users don't have to cleanup its subscriptions themselves. --- src/shared/gatt-client.c | 70 +++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index 0b81a7a5c..e21aca1f0 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -174,9 +174,12 @@ static void request_unref(void *data) } struct notify_chrc { + struct bt_gatt_client *client; + struct gatt_db_attribute *attr; uint16_t value_handle; uint16_t ccc_handle; uint16_t properties; + unsigned int notify_id; int notify_count; /* Reference count of registered notify callbacks */ /* Pending calls to register_notify are queued here so that they can be @@ -235,6 +238,51 @@ static void find_ccc(struct gatt_db_attribute *attr, void *user_data) *ccc_ptr = attr; } +static bool match_notify_chrc(const void *data, const void *user_data) +{ + const struct notify_data *notify_data = data; + const struct notify_chrc *chrc = user_data; + + return notify_data->chrc == chrc; +} + +static void notify_data_cleanup(void *data) +{ + struct notify_data *notify_data = data; + + if (notify_data->att_id) + bt_att_cancel(notify_data->client->att, notify_data->att_id); + + notify_data_unref(notify_data); +} + +static void notify_chrc_free(void *data) +{ + struct notify_chrc *chrc = data; + + if (chrc->notify_id) + gatt_db_attribute_unregister(chrc->attr, chrc->notify_id); + + queue_destroy(chrc->reg_notify_queue, notify_data_unref); + free(chrc); +} + +static void chrc_removed(struct gatt_db_attribute *attr, void *user_data) +{ + struct notify_chrc *chrc = user_data; + struct bt_gatt_client *client = chrc->client; + struct notify_data *data; + + chrc->notify_id = 0; + + while ((data = queue_remove_if(client->notify_list, match_notify_chrc, + chrc))) + notify_data_cleanup(data); + + queue_remove(client->notify_chrcs, chrc); + notify_chrc_free(chrc); +} + static struct notify_chrc *notify_chrc_create(struct bt_gatt_client *client, uint16_t value_handle) { @@ -274,22 +322,18 @@ static struct notify_chrc *notify_chrc_create(struct bt_gatt_client *client, if (ccc) chrc->ccc_handle = gatt_db_attribute_get_handle(ccc); + chrc->client = client; + chrc->attr = attr; chrc->value_handle = value_handle; chrc->properties = properties; + chrc->notify_id = gatt_db_attribute_register(attr, chrc_removed, chrc, + NULL); queue_push_tail(client->notify_chrcs, chrc); return chrc; } -static void notify_chrc_free(void *data) -{ - struct notify_chrc *chrc = data; - - queue_destroy(chrc->reg_notify_queue, notify_data_unref); - free(chrc); -} - static bool match_notify_data_id(const void *a, const void *b) { const struct notify_data *notify_data = a; @@ -303,16 +347,6 @@ struct handle_range { uint16_t end; }; -static void notify_data_cleanup(void *data) -{ - struct notify_data *notify_data = data; - - if (notify_data->att_id) - bt_att_cancel(notify_data->client->att, notify_data->att_id); - - notify_data_unref(notify_data); -} - struct discovery_op; typedef void (*discovery_op_complete_func_t)(struct discovery_op *op, -- 2.25.3 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mPcMGFniEF963wAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 01:27:21 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aKujFlniEF9EpAEAlp8NpQ (envelope-from ); Fri, 17 Jul 2020 01:27:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 17D2352C27; Fri, 17 Jul 2020 01:27:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726907AbgGPX1M convert rfc822-to-8bit (ORCPT + 1 other); Thu, 16 Jul 2020 19:27:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:37308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726189AbgGPX1L (ORCPT ); Thu, 16 Jul 2020 19:27:11 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 208591] connecting to bluetooth Samsung earbuds freezes the system (kubuntu 20.04) with 5.8rc kernels. Hard reset needed. Date: Thu, 16 Jul 2020 23:27:11 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mkleinsoft@gmail.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.62 / 15.00 / 200.00 X-Rspamd-Queue-Id: 17D2352C27 X-Rspamd-UID: 882b57 https://bugzilla.kernel.org/show_bug.cgi?id=208591 --- Comment #3 from Marian Klein (mkleinsoft@gmail.com) --- For completeness. 1) I could connect to my phone Galaxy A50 5G via bluetooth before trying to connect to Earbuds. (see attached pic) 2) Bluetooth Widget in plasma shows Ear buds connected, but system is frozen anyway. 3) I can move cursor with touchpad, but it does not react to clicks after attempted connect. The only way to get out of this situation is to restart laptop. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4GNMH3dEEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:25:59 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EMDuHXdEEV80BwEAlp8NpQ (envelope-from ); Fri, 17 Jul 2020 08:25:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3C6B3A30AA; Fri, 17 Jul 2020 08:25:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727989AbgGQGZ1 (ORCPT + 1 other); Fri, 17 Jul 2020 02:25:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727873AbgGQGYg (ORCPT ); Fri, 17 Jul 2020 02:24:36 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C0E3C08C5C0; Thu, 16 Jul 2020 23:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=HWKUrMU7y7FykbOHZGTc2Y+JrTvxO4f9VIsHEh08/RU=; b=e48fLHcJwVEo+UkX1/mK0+z2I1 q+RKf9d8bw/O9G7YRI9XjTwtGqLI1nxSbt8EUvRL/5z3evvLG9xn/G/8mbLaT1oVQ8W5xlKnUC8OD ZXjLY2UFV35hrKq1Ut/uAK561ACk/iwosVMPfkl+tI37B4L3GBODPhNXVwoY9Yt2wDJXvYq9rOb3j YsUc/yCl0kLFu2A+Evy26MiwlWgrM+/+b9f8maHw7q1FqcXrNhX5eBWHXHmf/bxRtyMOuMyP0o+v7 Qyg/4mgDBAXYSTo3yuHFqtwKuY5rm/VmN8DBtnTepUaswPvSPwYpWhrN8Y0K1MzyhdzcQTprxKAnZ 6xo9agpA==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJnC-00055O-C8; Fri, 17 Jul 2020 06:24:23 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 17/22] net/ipv4: remove compat_ip_{get,set}sockopt Date: Fri, 17 Jul 2020 08:23:26 +0200 Message-Id: <20200717062331.691152-18-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3C6B3A30AA X-Rspamd-UID: e15d97 Handle the few cases that need special treatment in-line using in_compat_syscall(). Signed-off-by: Christoph Hellwig --- include/net/ip.h | 4 - net/dccp/ipv4.c | 4 - net/ipv4/ip_sockglue.c | 214 ++++++++++++----------------------------- net/ipv4/raw.c | 22 ----- net/ipv4/tcp_ipv4.c | 4 - net/ipv4/udp.c | 24 ----- net/ipv4/udp_impl.h | 6 -- net/ipv4/udplite.c | 4 - net/l2tp/l2tp_ip.c | 4 - net/sctp/protocol.c | 4 - 10 files changed, 61 insertions(+), 229 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index 862c9545833a95..3d34acc95ca825 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -727,10 +727,6 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen); int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); -int compat_ip_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); -int compat_ip_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen); int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct sock *)); diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 316cc5ac0da72b..b91373eb1c7974 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -913,10 +913,6 @@ static const struct inet_connection_sock_af_ops dccp_ipv4_af_ops = { .getsockopt = ip_getsockopt, .addr2sockaddr = inet_csk_addr2sockaddr, .sockaddr_len = sizeof(struct sockaddr_in), -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_ip_setsockopt, - .compat_getsockopt = compat_ip_getsockopt, -#endif }; static int dccp_v4_init_sock(struct sock *sk) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 73bb88fbe54661..86b3b9a7cea30d 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -679,20 +679,48 @@ static int set_mcast_msfilter(struct sock *sk, int ifindex, return -EADDRNOTAVAIL; } +static int copy_group_source_from_user(struct group_source_req *greqs, + void __user *optval, int optlen) +{ + if (in_compat_syscall()) { + struct compat_group_source_req gr32; + + if (optlen != sizeof(gr32)) + return -EINVAL; + if (copy_from_user(&gr32, optval, sizeof(gr32))) + return -EFAULT; + greqs->gsr_interface = gr32.gsr_interface; + greqs->gsr_group = gr32.gsr_group; + greqs->gsr_source = gr32.gsr_source; + } else { + if (optlen != sizeof(*greqs)) + return -EINVAL; + if (copy_from_user(greqs, optval, sizeof(*greqs))) + return -EFAULT; + } + + return 0; +} + static int do_mcast_group_source(struct sock *sk, int optname, - struct group_source_req *greqs) + void __user *optval, int optlen) { + struct group_source_req greqs; struct ip_mreq_source mreqs; struct sockaddr_in *psin; int omode, add, err; - if (greqs->gsr_group.ss_family != AF_INET || - greqs->gsr_source.ss_family != AF_INET) + err = copy_group_source_from_user(&greqs, optval, optlen); + if (err) + return err; + + if (greqs.gsr_group.ss_family != AF_INET || + greqs.gsr_source.ss_family != AF_INET) return -EADDRNOTAVAIL; - psin = (struct sockaddr_in *)&greqs->gsr_group; + psin = (struct sockaddr_in *)&greqs.gsr_group; mreqs.imr_multiaddr = psin->sin_addr.s_addr; - psin = (struct sockaddr_in *)&greqs->gsr_source; + psin = (struct sockaddr_in *)&greqs.gsr_source; mreqs.imr_sourceaddr = psin->sin_addr.s_addr; mreqs.imr_interface = 0; /* use index for mc_source */ @@ -705,21 +733,21 @@ static int do_mcast_group_source(struct sock *sk, int optname, } else if (optname == MCAST_JOIN_SOURCE_GROUP) { struct ip_mreqn mreq; - psin = (struct sockaddr_in *)&greqs->gsr_group; + psin = (struct sockaddr_in *)&greqs.gsr_group; mreq.imr_multiaddr = psin->sin_addr; mreq.imr_address.s_addr = 0; - mreq.imr_ifindex = greqs->gsr_interface; + mreq.imr_ifindex = greqs.gsr_interface; err = ip_mc_join_group_ssm(sk, &mreq, MCAST_INCLUDE); if (err && err != -EADDRINUSE) return err; - greqs->gsr_interface = mreq.imr_ifindex; + greqs.gsr_interface = mreq.imr_ifindex; omode = MCAST_INCLUDE; add = 1; } else /* MCAST_LEAVE_SOURCE_GROUP */ { omode = MCAST_INCLUDE; add = 0; } - return ip_mc_source(add, omode, sk, &mreqs, greqs->gsr_interface); + return ip_mc_source(add, omode, sk, &mreqs, greqs.gsr_interface); } static int ip_set_mcast_msfilter(struct sock *sk, void __user *optval, @@ -754,7 +782,6 @@ static int ip_set_mcast_msfilter(struct sock *sk, void __user *optval, return err; } -#ifdef CONFIG_COMPAT static int compat_ip_set_mcast_msfilter(struct sock *sk, void __user *optval, int optlen) { @@ -788,23 +815,16 @@ static int compat_ip_set_mcast_msfilter(struct sock *sk, void __user *optval, if (offsetof(struct compat_group_filter, gf_slist[n]) > optlen) goto out_free_gsf; - rtnl_lock(); - lock_sock(sk); - /* numsrc >= (4G-140)/128 overflow in 32 bits */ err = -ENOBUFS; if (n > sock_net(sk)->ipv4.sysctl_igmp_max_msf) - goto out_unlock; + goto out_free_gsf; err = set_mcast_msfilter(sk, gf32->gf_interface, n, gf32->gf_fmode, &gf32->gf_group, gf32->gf_slist); -out_unlock: - release_sock(sk); - rtnl_unlock(); out_free_gsf: kfree(p); return err; } -#endif static int ip_mcast_join_leave(struct sock *sk, int optname, void __user *optval, int optlen) @@ -828,14 +848,12 @@ static int ip_mcast_join_leave(struct sock *sk, int optname, return ip_mc_leave_group(sk, &mreq); } -#ifdef CONFIG_COMPAT static int compat_ip_mcast_join_leave(struct sock *sk, int optname, void __user *optval, int optlen) { struct compat_group_req greq; struct ip_mreqn mreq = { }; struct sockaddr_in *psin; - int err; if (optlen < sizeof(struct compat_group_req)) return -EINVAL; @@ -848,17 +866,10 @@ static int compat_ip_mcast_join_leave(struct sock *sk, int optname, mreq.imr_multiaddr = psin->sin_addr; mreq.imr_ifindex = greq.gr_interface; - rtnl_lock(); - lock_sock(sk); if (optname == MCAST_JOIN_GROUP) - err = ip_mc_join_group(sk, &mreq); - else - err = ip_mc_leave_group(sk, &mreq); - release_sock(sk); - rtnl_unlock(); - return err; + return ip_mc_join_group(sk, &mreq); + return ip_mc_leave_group(sk, &mreq); } -#endif static int do_ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) @@ -1265,26 +1276,23 @@ static int do_ip_setsockopt(struct sock *sk, int level, } case MCAST_JOIN_GROUP: case MCAST_LEAVE_GROUP: - err = ip_mcast_join_leave(sk, optname, optval, optlen); + if (in_compat_syscall()) + err = compat_ip_mcast_join_leave(sk, optname, optval, + optlen); + else + err = ip_mcast_join_leave(sk, optname, optval, optlen); break; case MCAST_JOIN_SOURCE_GROUP: case MCAST_LEAVE_SOURCE_GROUP: case MCAST_BLOCK_SOURCE: case MCAST_UNBLOCK_SOURCE: - { - struct group_source_req greqs; - - if (optlen != sizeof(struct group_source_req)) - goto e_inval; - if (copy_from_user(&greqs, optval, sizeof(greqs))) { - err = -EFAULT; - break; - } - err = do_mcast_group_source(sk, optname, &greqs); + err = do_mcast_group_source(sk, optname, optval, optlen); break; - } case MCAST_MSFILTER: - err = ip_set_mcast_msfilter(sk, optval, optlen); + if (in_compat_syscall()) + err = compat_ip_set_mcast_msfilter(sk, optval, optlen); + else + err = ip_set_mcast_msfilter(sk, optval, optlen); break; case IP_MULTICAST_ALL: if (optlen < 1) @@ -1410,62 +1418,6 @@ int ip_setsockopt(struct sock *sk, int level, } EXPORT_SYMBOL(ip_setsockopt); -#ifdef CONFIG_COMPAT -int compat_ip_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) -{ - int err; - - if (level != SOL_IP) - return -ENOPROTOOPT; - - switch (optname) { - case MCAST_JOIN_GROUP: - case MCAST_LEAVE_GROUP: - return compat_ip_mcast_join_leave(sk, optname, optval, optlen); - case MCAST_JOIN_SOURCE_GROUP: - case MCAST_LEAVE_SOURCE_GROUP: - case MCAST_BLOCK_SOURCE: - case MCAST_UNBLOCK_SOURCE: - { - struct compat_group_source_req __user *gsr32 = (void __user *)optval; - struct group_source_req greqs; - - if (optlen != sizeof(struct compat_group_source_req)) - return -EINVAL; - - if (get_user(greqs.gsr_interface, &gsr32->gsr_interface) || - copy_from_user(&greqs.gsr_group, &gsr32->gsr_group, - sizeof(greqs.gsr_group)) || - copy_from_user(&greqs.gsr_source, &gsr32->gsr_source, - sizeof(greqs.gsr_source))) - return -EFAULT; - - rtnl_lock(); - lock_sock(sk); - err = do_mcast_group_source(sk, optname, &greqs); - release_sock(sk); - rtnl_unlock(); - return err; - } - case MCAST_MSFILTER: - return compat_ip_set_mcast_msfilter(sk, optval, optlen); - } - - err = do_ip_setsockopt(sk, level, optname, optval, optlen); -#ifdef CONFIG_NETFILTER - /* we need to exclude all possible ENOPROTOOPTs except default case */ - if (err == -ENOPROTOOPT && optname != IP_HDRINCL && - optname != IP_IPSEC_POLICY && - optname != IP_XFRM_POLICY && - !ip_mroute_opt(optname)) - err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); -#endif - return err; -} -EXPORT_SYMBOL(compat_ip_setsockopt); -#endif - /* * Get the options. Note for future reference. The GET of IP options gets * the _received_ ones. The set sets the _sent_ ones. @@ -1507,22 +1459,18 @@ static int ip_get_mcast_msfilter(struct sock *sk, void __user *optval, return 0; } -#ifdef CONFIG_COMPAT static int compat_ip_get_mcast_msfilter(struct sock *sk, void __user *optval, - int __user *optlen) + int __user *optlen, int len) { const int size0 = offsetof(struct compat_group_filter, gf_slist); struct compat_group_filter __user *p = optval; struct compat_group_filter gf32; struct group_filter gf; - int len, err; int num; + int err; - if (get_user(len, optlen)) - return -EFAULT; if (len < size0) return -EINVAL; - if (copy_from_user(&gf32, p, size0)) return -EFAULT; @@ -1531,11 +1479,7 @@ static int compat_ip_get_mcast_msfilter(struct sock *sk, void __user *optval, num = gf.gf_numsrc = gf32.gf_numsrc; gf.gf_group = gf32.gf_group; - rtnl_lock(); - lock_sock(sk); err = ip_mc_gsfget(sk, &gf, p->gf_slist); - release_sock(sk); - rtnl_unlock(); if (err) return err; if (gf.gf_numsrc < num) @@ -1547,10 +1491,9 @@ static int compat_ip_get_mcast_msfilter(struct sock *sk, void __user *optval, return -EFAULT; return 0; } -#endif static int do_ip_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen, unsigned int flags) + char __user *optval, int __user *optlen) { struct inet_sock *inet = inet_sk(sk); bool needs_rtnl = getsockopt_needs_rtnl(optname); @@ -1707,7 +1650,11 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname, goto out; } case MCAST_MSFILTER: - err = ip_get_mcast_msfilter(sk, optval, optlen, len); + if (in_compat_syscall()) + err = compat_ip_get_mcast_msfilter(sk, optval, optlen, + len); + else + err = ip_get_mcast_msfilter(sk, optval, optlen, len); goto out; case IP_MULTICAST_ALL: val = inet->mc_all; @@ -1724,7 +1671,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname, msg.msg_control_is_user = true; msg.msg_control_user = optval; msg.msg_controllen = len; - msg.msg_flags = flags; + msg.msg_flags = in_compat_syscall() ? MSG_CMSG_COMPAT : 0; if (inet->cmsg_flags & IP_CMSG_PKTINFO) { struct in_pktinfo info; @@ -1788,45 +1735,7 @@ int ip_getsockopt(struct sock *sk, int level, { int err; - err = do_ip_getsockopt(sk, level, optname, optval, optlen, 0); -#if IS_ENABLED(CONFIG_BPFILTER_UMH) - if (optname >= BPFILTER_IPT_SO_GET_INFO && - optname < BPFILTER_IPT_GET_MAX) - err = bpfilter_ip_get_sockopt(sk, optname, optval, optlen); -#endif -#ifdef CONFIG_NETFILTER - /* we need to exclude all possible ENOPROTOOPTs except default case */ - if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS && - !ip_mroute_opt(optname)) { - int len; - - if (get_user(len, optlen)) - return -EFAULT; - - err = nf_getsockopt(sk, PF_INET, optname, optval, &len); - if (err >= 0) - err = put_user(len, optlen); - return err; - } -#endif - return err; -} -EXPORT_SYMBOL(ip_getsockopt); - -#ifdef CONFIG_COMPAT -int compat_ip_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen) -{ - int err; - - if (optname == MCAST_MSFILTER) { - if (level != SOL_IP) - return -EOPNOTSUPP; - return compat_ip_get_mcast_msfilter(sk, optval, optlen); - } - - err = do_ip_getsockopt(sk, level, optname, optval, optlen, - MSG_CMSG_COMPAT); + err = do_ip_getsockopt(sk, level, optname, optval, optlen); #if IS_ENABLED(CONFIG_BPFILTER_UMH) if (optname >= BPFILTER_IPT_SO_GET_INFO && @@ -1850,5 +1759,4 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname, #endif return err; } -EXPORT_SYMBOL(compat_ip_getsockopt); -#endif +EXPORT_SYMBOL(ip_getsockopt); diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 47665919048f9d..2a57d633b31e00 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -857,16 +857,6 @@ static int raw_setsockopt(struct sock *sk, int level, int optname, return do_raw_setsockopt(sk, level, optname, optval, optlen); } -#ifdef CONFIG_COMPAT -static int compat_raw_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) -{ - if (level != SOL_RAW) - return compat_ip_setsockopt(sk, level, optname, optval, optlen); - return do_raw_setsockopt(sk, level, optname, optval, optlen); -} -#endif - static int do_raw_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen) { @@ -887,16 +877,6 @@ static int raw_getsockopt(struct sock *sk, int level, int optname, return do_raw_getsockopt(sk, level, optname, optval, optlen); } -#ifdef CONFIG_COMPAT -static int compat_raw_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen) -{ - if (level != SOL_RAW) - return compat_ip_getsockopt(sk, level, optname, optval, optlen); - return do_raw_getsockopt(sk, level, optname, optval, optlen); -} -#endif - static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg) { switch (cmd) { @@ -980,8 +960,6 @@ struct proto raw_prot = { .usersize = sizeof_field(struct raw_sock, filter), .h.raw_hash = &raw_v4_hashinfo, #ifdef CONFIG_COMPAT - .compat_setsockopt = compat_raw_setsockopt, - .compat_getsockopt = compat_raw_getsockopt, .compat_ioctl = compat_raw_ioctl, #endif .diag_destroy = raw_abort, diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 116c11a0aaed62..e5b7ef9a288769 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2134,10 +2134,6 @@ const struct inet_connection_sock_af_ops ipv4_specific = { .getsockopt = ip_getsockopt, .addr2sockaddr = inet_csk_addr2sockaddr, .sockaddr_len = sizeof(struct sockaddr_in), -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_ip_setsockopt, - .compat_getsockopt = compat_ip_getsockopt, -#endif .mtu_reduced = tcp_v4_mtu_reduced, }; EXPORT_SYMBOL(ipv4_specific); diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 073d346f515c44..d4be4471c424e3 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2656,17 +2656,6 @@ int udp_setsockopt(struct sock *sk, int level, int optname, return ip_setsockopt(sk, level, optname, optval, optlen); } -#ifdef CONFIG_COMPAT -int compat_udp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) -{ - if (level == SOL_UDP || level == SOL_UDPLITE) - return udp_lib_setsockopt(sk, level, optname, optval, optlen, - udp_push_pending_frames); - return compat_ip_setsockopt(sk, level, optname, optval, optlen); -} -#endif - int udp_lib_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen) { @@ -2732,15 +2721,6 @@ int udp_getsockopt(struct sock *sk, int level, int optname, return ip_getsockopt(sk, level, optname, optval, optlen); } -#ifdef CONFIG_COMPAT -int compat_udp_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen) -{ - if (level == SOL_UDP || level == SOL_UDPLITE) - return udp_lib_getsockopt(sk, level, optname, optval, optlen); - return compat_ip_getsockopt(sk, level, optname, optval, optlen); -} -#endif /** * udp_poll - wait for a UDP event. * @file: - file struct @@ -2812,10 +2792,6 @@ struct proto udp_prot = { .sysctl_rmem_offset = offsetof(struct net, ipv4.sysctl_udp_rmem_min), .obj_size = sizeof(struct udp_sock), .h.udp_table = &udp_table, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_udp_setsockopt, - .compat_getsockopt = compat_udp_getsockopt, -#endif .diag_destroy = udp_abort, }; EXPORT_SYMBOL(udp_prot); diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h index 6b2fa77eeb1c3e..ab313702c87f30 100644 --- a/net/ipv4/udp_impl.h +++ b/net/ipv4/udp_impl.h @@ -17,12 +17,6 @@ int udp_setsockopt(struct sock *sk, int level, int optname, int udp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); -#ifdef CONFIG_COMPAT -int compat_udp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); -int compat_udp_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen); -#endif int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, int flags, int *addr_len); int udp_sendpage(struct sock *sk, struct page *page, int offset, size_t size, diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index 5936d66d1ce2f2..bd8773b49e72ed 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c @@ -56,10 +56,6 @@ struct proto udplite_prot = { .sysctl_mem = sysctl_udp_mem, .obj_size = sizeof(struct udp_sock), .h.udp_table = &udplite_table, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_udp_setsockopt, - .compat_getsockopt = compat_udp_getsockopt, -#endif }; EXPORT_SYMBOL(udplite_prot); diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c index f8d7412cfb3d37..2a3fd31fb589dc 100644 --- a/net/l2tp/l2tp_ip.c +++ b/net/l2tp/l2tp_ip.c @@ -612,10 +612,6 @@ static struct proto l2tp_ip_prot = { .hash = l2tp_ip_hash, .unhash = l2tp_ip_unhash, .obj_size = sizeof(struct l2tp_ip_sock), -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_ip_setsockopt, - .compat_getsockopt = compat_ip_getsockopt, -#endif }; static const struct proto_ops l2tp_ip_ops = { diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 8d25cc464efdf3..7ecaf7d575c097 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -1089,10 +1089,6 @@ static struct sctp_af sctp_af_inet = { .net_header_len = sizeof(struct iphdr), .sockaddr_len = sizeof(struct sockaddr_in), .ip_options_len = sctp_v4_ip_options_len, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_ip_setsockopt, - .compat_getsockopt = compat_ip_getsockopt, -#endif }; struct sctp_pf *sctp_get_pf_specific(sa_family_t family) -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id APPwL4JEEV/GzQAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:26:10 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sJBULoJEEV+12wEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:26:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 299A5A1AE0; Fri, 17 Jul 2020 08:26:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727834AbgGQGYe (ORCPT + 1 other); Fri, 17 Jul 2020 02:24:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbgGQGYb (ORCPT ); Fri, 17 Jul 2020 02:24:31 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AC31C061755; Thu, 16 Jul 2020 23:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5UhNspDdIml9tpfUfRWGkC9v9AOZv925n+e1F7He35A=; b=ngePkQgpsw8v14v2e2H1RuLUgP 0xqQQ043zu+gtXRpXV0bf1ADe/edoqtXj7z3kKW9mKK+iCMOqbmpx3giNOQFrEznviF1qfzoZwbDo xr7UnllY+pDKH2CH55FbdxZENM4P5ohmSYAJ0fRT7rs+qqeSNBf08yCPD3u4f/qFc5Y9NGvnoQNep Q1DsD4GKGED6DkS1FkzSoMqYpNOH/w2g4VpT16FR3tH0BYHZ8AioctdDH4k7C39SaqLi85vEZptIG vVRFnCSAKWjMPjLVXYuX97UKI3rDl+CoNmVE1f7b4ZTU02I8+ZHtLq4ucRfi35nEz/aA046/AsP0+ 9sdcqAzw==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJnA-00054z-MC; Fri, 17 Jul 2020 06:24:21 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 16/22] net/ipv4: factor out mcast join/leave setsockopt helpers Date: Fri, 17 Jul 2020 08:23:25 +0200 Message-Id: <20200717062331.691152-17-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 299A5A1AE0 X-Rspamd-UID: 04ee68 Factor out one helper each for setting the native and compat version of the MCAST_MSFILTER option. Signed-off-by: Christoph Hellwig --- net/ipv4/ip_sockglue.c | 109 +++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index b587dee006f882..73bb88fbe54661 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -806,6 +806,60 @@ static int compat_ip_set_mcast_msfilter(struct sock *sk, void __user *optval, } #endif +static int ip_mcast_join_leave(struct sock *sk, int optname, + void __user *optval, int optlen) +{ + struct ip_mreqn mreq = { }; + struct sockaddr_in *psin; + struct group_req greq; + + if (optlen < sizeof(struct group_req)) + return -EINVAL; + if (copy_from_user(&greq, optval, sizeof(greq))) + return -EFAULT; + + psin = (struct sockaddr_in *)&greq.gr_group; + if (psin->sin_family != AF_INET) + return -EINVAL; + mreq.imr_multiaddr = psin->sin_addr; + mreq.imr_ifindex = greq.gr_interface; + if (optname == MCAST_JOIN_GROUP) + return ip_mc_join_group(sk, &mreq); + return ip_mc_leave_group(sk, &mreq); +} + +#ifdef CONFIG_COMPAT +static int compat_ip_mcast_join_leave(struct sock *sk, int optname, + void __user *optval, int optlen) +{ + struct compat_group_req greq; + struct ip_mreqn mreq = { }; + struct sockaddr_in *psin; + int err; + + if (optlen < sizeof(struct compat_group_req)) + return -EINVAL; + if (copy_from_user(&greq, optval, sizeof(greq))) + return -EFAULT; + + psin = (struct sockaddr_in *)&greq.gr_group; + if (psin->sin_family != AF_INET) + return -EINVAL; + mreq.imr_multiaddr = psin->sin_addr; + mreq.imr_ifindex = greq.gr_interface; + + rtnl_lock(); + lock_sock(sk); + if (optname == MCAST_JOIN_GROUP) + err = ip_mc_join_group(sk, &mreq); + else + err = ip_mc_leave_group(sk, &mreq); + release_sock(sk); + rtnl_unlock(); + return err; +} +#endif + static int do_ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { @@ -1211,29 +1265,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, } case MCAST_JOIN_GROUP: case MCAST_LEAVE_GROUP: - { - struct group_req greq; - struct sockaddr_in *psin; - struct ip_mreqn mreq; - - if (optlen < sizeof(struct group_req)) - goto e_inval; - err = -EFAULT; - if (copy_from_user(&greq, optval, sizeof(greq))) - break; - psin = (struct sockaddr_in *)&greq.gr_group; - if (psin->sin_family != AF_INET) - goto e_inval; - memset(&mreq, 0, sizeof(mreq)); - mreq.imr_multiaddr = psin->sin_addr; - mreq.imr_ifindex = greq.gr_interface; - - if (optname == MCAST_JOIN_GROUP) - err = ip_mc_join_group(sk, &mreq); - else - err = ip_mc_leave_group(sk, &mreq); + err = ip_mcast_join_leave(sk, optname, optval, optlen); break; - } case MCAST_JOIN_SOURCE_GROUP: case MCAST_LEAVE_SOURCE_GROUP: case MCAST_BLOCK_SOURCE: @@ -1389,37 +1422,7 @@ int compat_ip_setsockopt(struct sock *sk, int level, int optname, switch (optname) { case MCAST_JOIN_GROUP: case MCAST_LEAVE_GROUP: - { - struct compat_group_req __user *gr32 = (void __user *)optval; - struct group_req greq; - struct sockaddr_in *psin = (struct sockaddr_in *)&greq.gr_group; - struct ip_mreqn mreq; - - if (optlen < sizeof(struct compat_group_req)) - return -EINVAL; - - if (get_user(greq.gr_interface, &gr32->gr_interface) || - copy_from_user(&greq.gr_group, &gr32->gr_group, - sizeof(greq.gr_group))) - return -EFAULT; - - if (psin->sin_family != AF_INET) - return -EINVAL; - - memset(&mreq, 0, sizeof(mreq)); - mreq.imr_multiaddr = psin->sin_addr; - mreq.imr_ifindex = greq.gr_interface; - - rtnl_lock(); - lock_sock(sk); - if (optname == MCAST_JOIN_GROUP) - err = ip_mc_join_group(sk, &mreq); - else - err = ip_mc_leave_group(sk, &mreq); - release_sock(sk); - rtnl_unlock(); - return err; - } + return compat_ip_mcast_join_leave(sk, optname, optval, optlen); case MCAST_JOIN_SOURCE_GROUP: case MCAST_LEAVE_SOURCE_GROUP: case MCAST_BLOCK_SOURCE: -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id BQiMOnHnEF8IewEAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 01:49:05 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UH70N3HnEF9oqwAADc0bRg (envelope-from ); Fri, 17 Jul 2020 01:49:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8E46052B89; Fri, 17 Jul 2020 01:48:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725980AbgGPXs6 (ORCPT + 1 other); Thu, 16 Jul 2020 19:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbgGPXs5 (ORCPT ); Thu, 16 Jul 2020 19:48:57 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94472C061755 for ; Thu, 16 Jul 2020 16:48:57 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id j80so7304087qke.0 for ; Thu, 16 Jul 2020 16:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=8NZbwJ+q0qt7nP7otXGqQ/bDUtTJDOQiBz+kZgwjkxQ=; b=YS3Rlpisc0dV46nf1TefjgkArU8iktOINSVdBLIu8QvVuePXuEKYLLnuJ1cIEBMa9e Tqg+YYLXU1QFAjhrY5qhqvCN/HDhy/XKiZ3ycLJVln7k1joCoaSPFG+Wionaf+KHv+LG jPdERZLlqR+7XwAuvc2LZbew4z+x3wcEx9OW4j4hHi0YLvpsIWpNmO7FEATJtEly/fVj fDfIjr27062RNmspLaL4G0yok1NqXJNx3vNNI/JUtqWj/V+rGp7Ngp8QxKyj0yOyck7I 5JELqE85MWyeUmNHiWTcdZMJm8aaZ5GRPJ80fUniwrtRG8nfMIIS68KvJFUCKaFyCUsu 8ptw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=8NZbwJ+q0qt7nP7otXGqQ/bDUtTJDOQiBz+kZgwjkxQ=; b=Mx0CohlHi2JZOBgfAHaJeajiylRd/mkVBzmBet4kaPk2X1A54RqJ+nsXVHb46ECA0D JtthSF/4jZk+0/RuyryCBqo+qARJ5hhx8mBWwoXRpvFDa3nxQvSioZJCa1hwpXI2D7IW QF8L1YtNUB229kmgEgr3HsAyM5YG/0ucF+0N9of1MjntSZHbfOpfr6mZi5ln5Srn5DZE 52Re5svKzLU1t5K99YYFaWQ3/aYsV+7MUrbLOZXZ1D+qqmzq3PHQBnLz8u9xPa5G3kpU 2BglbO2spt1PtuWWS9hKZyzeKqvfoeo+3Ww9XIhZ/mZarNGVXn0aAHoXAFSe5RqY/Obi wjBA== X-Gm-Message-State: AOAM530NLIQIFDf+M32oqrlsuyTBHeQJVWF8iqImBEBQX0TVypgPj09O H43uvL/Dh+kjyDUh77ANfD5jr44rgss= X-Google-Smtp-Source: ABdhPJyF+S5/olsweZG3kUnoelZTWBWI8VqcZN47JLEOVbZhKi1G+C2UN5//fl+tpAjy5Dt2KtH4JQ== X-Received: by 2002:a37:7a42:: with SMTP id v63mr6770262qkc.258.1594943336682; Thu, 16 Jul 2020 16:48:56 -0700 (PDT) Received: from [172.17.0.2] ([52.184.161.145]) by smtp.gmail.com with ESMTPSA id f16sm2806291qta.20.2020.07.16.16.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 16:48:56 -0700 (PDT) Message-ID: <5f10e768.1c69fb81.68390.b524@mx.google.com> Date: Thu, 16 Jul 2020 16:48:56 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============6301206506728767054==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com Subject: RE: [BlueZ,1/4] shared/att: Fix possible crash on disconnect Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200716231857.934396-1-luiz.dentz@gmail.com> References: <20200716231857.934396-1-luiz.dentz@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 36 X-Rspamd-Score: 5.46 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8E46052B89 X-Rspamd-UID: 9476d7 --===============6301206506728767054== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #17: by 0x48E963B: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.6400.4) - total: 0 errors, 1 warnings, 83 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============6301206506728767054==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0OVKLCHoEF8IewEAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 01:52:01 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SMoEKiHoEF8DHgEAgupzMw (envelope-from ); Fri, 17 Jul 2020 01:52:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4C7CAA2DE8; Fri, 17 Jul 2020 01:51:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726141AbgGPXvz (ORCPT + 1 other); Thu, 16 Jul 2020 19:51:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbgGPXvz (ORCPT ); Thu, 16 Jul 2020 19:51:55 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DBD9C061755 for ; Thu, 16 Jul 2020 16:51:55 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id w27so6370052qtb.7 for ; Thu, 16 Jul 2020 16:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=/MJnLkbJLE9mXLEnJaHh67UU5knjI7/nh0C4gIyYoGw=; b=aJ14j/Z/hhqRNNs+3t+uuqhJ3OUSRCEAmlJ2LKrSbbzaaZtLEt7byKINP8g5Z5ltsR iqzX1g7XTpgHGXshYKILzLbcQRYC9c5WTYVegjs8LZr5feNJ/Se5sT1D2TSeOnuVgvzq u9JSpdj9pRvsb/VxagHLXUyVB32q8FsrtTbUcbBff7aer2qPAwbImPq/2mpzqajE/fx4 SnTGvVUpXeXdFwgDjVPqs5UH/oNZo8rSjuzl2W/J3GHtWrmZCaALjU3YC9cwFe/Tu+2i CNbJX8E9LVD4ErAR/yWdXXMAFif9BhdAUeyru/UncQ7HDfjcpRDJgJPYrBTDVKRVX6iM KL4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=/MJnLkbJLE9mXLEnJaHh67UU5knjI7/nh0C4gIyYoGw=; b=F/8CxK0VMxG27p+OAiM78FXAL2XNJ5KVzJCzwYFRCRyDdsg8n4Gokc4qdFPM0t5Ams 0+7IP2zI99MgPOMtecwYP8TqLqFdXug2SQWTLEiBYjs4P3I0tv7AoYVDrleCC0BAw1SM H7dErL7KD/uxLWvgqqwntUSSZP+iPlwdTcFErdF/DRVgCy1esrHr/K38MBzD9Rvy7hJf zSv26PCXt19OtZmM/1OT0jBkfE2P50vWXlSOPhjUJZv1Qt54a+GHS8qI5N0iNxYlRdzf M4XXTCNXEqx+AtP5jQXPC/fu5GMKUNrXxHuMfJ0/HV3f39P1HrT9rV1syxKEf1YQkC3S w2LQ== X-Gm-Message-State: AOAM530C5lHZxEWe1UKHSHintBL+XaN2eqalgvu+74Srh8EERi509u5M UCaVQC1ImA+Dq9BoQoZoV8/R1sD6LJk= X-Google-Smtp-Source: ABdhPJyRqL2sGMMrHFTpS/2Lj/D76nVSB66KprlwG4Af7nlFDlr9envABBafj9+9sRUiF+7XxhIfIQ== X-Received: by 2002:ac8:108d:: with SMTP id a13mr7738078qtj.42.1594943514121; Thu, 16 Jul 2020 16:51:54 -0700 (PDT) Received: from [172.17.0.2] ([52.184.161.145]) by smtp.gmail.com with ESMTPSA id v10sm9566238qtk.14.2020.07.16.16.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 16:51:53 -0700 (PDT) Message-ID: <5f10e819.1c69fb81.2d00b.1b14@mx.google.com> Date: Thu, 16 Jul 2020 16:51:53 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3665026671272091068==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com Subject: RE: [BlueZ,1/4] shared/att: Fix possible crash on disconnect Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200716231857.934396-1-luiz.dentz@gmail.com> References: <20200716231857.934396-1-luiz.dentz@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 23 X-Rspamd-Score: 3.59 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4C7CAA2DE8 X-Rspamd-UID: 8592b5 --===============3665026671272091068== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: makecheck Failed Outputs: ./test-driver: line 107: 14798 Bus error (core dumped) "$@" > $log_file 2>&1 make[3]: *** [Makefile:9726: test-suite.log] Error 1 make[2]: *** [Makefile:9834: check-TESTS] Error 2 make[1]: *** [Makefile:10228: check-am] Error 2 make: *** [Makefile:10230: check] Error 2 --- Regards, Linux Bluetooth --===============3665026671272091068==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YDZSIST8EF8OvgEAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 03:17:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id iDr1HyT8EF+UZAEAgupzMw (envelope-from ); Fri, 17 Jul 2020 03:17:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1C290A1AE0; Fri, 17 Jul 2020 03:17:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726512AbgGQBRP convert rfc822-to-8bit (ORCPT + 1 other); Thu, 16 Jul 2020 21:17:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:60294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726238AbgGQBRP (ORCPT ); Thu, 16 Jul 2020 21:17:15 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 208591] connecting to bluetooth Samsung earbuds freezes the system (kubuntu 20.04) with 5.8rc kernels. Hard reset needed. Date: Fri, 17 Jul 2020 01:17:14 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mkleinsoft@gmail.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1C290A1AE0 X-Rspamd-UID: 960e8e https://bugzilla.kernel.org/show_bug.cgi?id=208591 --- Comment #5 from Marian Klein (mkleinsoft@gmail.com) --- Please provide pre-compiled kernel binaries x86_64 leading up to 5.8rc1 and I will try to bisect or narrow down the problem or to find a commit causing this problem. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +JHwJRxEEV993wAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:24:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id yLNLJBxEEV930QEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:24:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C581BA1664; Fri, 17 Jul 2020 08:24:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726975AbgGQGYU (ORCPT + 1 other); Fri, 17 Jul 2020 02:24:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726113AbgGQGYR (ORCPT ); Fri, 17 Jul 2020 02:24:17 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84C1AC08C5C0; Thu, 16 Jul 2020 23:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=15CB9V7QI/EJP4CEaWkoXbSz4JSBsbnp24tauy2SAlc=; b=aFcX2soSjBmLa8/cRhua5QBWnT 7gyYF7oDmYQFLRFdjsrPLADpoApsS91mlCTiDWBDRNpYne4Q4FB9+D+vEGKWN1fkd52ifFfy6y70i QlTP4pYrRVhtkusVcZaJS2BzoSvxYPXODbLDwD+yVF0u35uVyoBPGPUz/+ZRPXy/YWPyi7AOeziTG 7YpC4zg3wHYdi9UDxHVd4uXYngadXhSP8kWziNbYQAOp3wIfafvDQhe5UpxM4Cihj6hY6novUL7+a ZABKfMAt5UbDLVDUnDhPHh6vXC0yzJO/s4rgEjJ8e65eXAKEw5RyxAO+pdFtfHGSc/YmBJY0vT/q0 6nRGA/Eg==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJmv-00052k-DO; Fri, 17 Jul 2020 06:24:06 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 07/22] netfilter/arp_tables: clean up compat {get,set}sockopt handling Date: Fri, 17 Jul 2020 08:23:16 +0200 Message-Id: <20200717062331.691152-8-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: C581BA1664 X-Rspamd-UID: 231d81 Merge the native and compat {get,set}sockopt handlers using in_compat_syscall(). Signed-off-by: Christoph Hellwig --- net/ipv4/netfilter/arp_tables.c | 85 ++++++++------------------------- 1 file changed, 21 insertions(+), 64 deletions(-) diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index b167f4a5b68453..15807fb4a65f3e 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -787,8 +787,7 @@ static int compat_table_info(const struct xt_table_info *info, } #endif -static int get_info(struct net *net, void __user *user, - const int *len, int compat) +static int get_info(struct net *net, void __user *user, const int *len) { char name[XT_TABLE_MAXNAMELEN]; struct xt_table *t; @@ -802,7 +801,7 @@ static int get_info(struct net *net, void __user *user, name[XT_TABLE_MAXNAMELEN-1] = '\0'; #ifdef CONFIG_COMPAT - if (compat) + if (in_compat_syscall()) xt_compat_lock(NFPROTO_ARP); #endif t = xt_request_find_table_lock(net, NFPROTO_ARP, name); @@ -812,7 +811,7 @@ static int get_info(struct net *net, void __user *user, #ifdef CONFIG_COMPAT struct xt_table_info tmp; - if (compat) { + if (in_compat_syscall()) { ret = compat_table_info(private, &tmp); xt_compat_flush_offsets(NFPROTO_ARP); private = &tmp; @@ -837,7 +836,7 @@ static int get_info(struct net *net, void __user *user, } else ret = PTR_ERR(t); #ifdef CONFIG_COMPAT - if (compat) + if (in_compat_syscall()) xt_compat_unlock(NFPROTO_ARP); #endif return ret; @@ -998,7 +997,7 @@ static int do_replace(struct net *net, const void __user *user, } static int do_add_counters(struct net *net, const void __user *user, - unsigned int len, int compat) + unsigned int len) { unsigned int i; struct xt_counters_info tmp; @@ -1009,7 +1008,8 @@ static int do_add_counters(struct net *net, const void __user *user, struct arpt_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp, compat); + paddc = xt_copy_counters_from_user(user, len, &tmp, + in_compat_syscall()); if (IS_ERR(paddc)) return PTR_ERR(paddc); @@ -1294,30 +1294,6 @@ static int compat_do_replace(struct net *net, void __user *user, return ret; } -static int compat_do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, - unsigned int len) -{ - int ret; - - if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) - return -EPERM; - - switch (cmd) { - case ARPT_SO_SET_REPLACE: - ret = compat_do_replace(sock_net(sk), user, len); - break; - - case ARPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len, 1); - break; - - default: - ret = -EINVAL; - } - - return ret; -} - static int compat_copy_entry_to_user(struct arpt_entry *e, void __user **dstptr, compat_uint_t *size, struct xt_counters *counters, @@ -1425,29 +1401,6 @@ static int compat_get_entries(struct net *net, xt_compat_unlock(NFPROTO_ARP); return ret; } - -static int do_arpt_get_ctl(struct sock *, int, void __user *, int *); - -static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, - int *len) -{ - int ret; - - if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) - return -EPERM; - - switch (cmd) { - case ARPT_SO_GET_INFO: - ret = get_info(sock_net(sk), user, len, 1); - break; - case ARPT_SO_GET_ENTRIES: - ret = compat_get_entries(sock_net(sk), user, len); - break; - default: - ret = do_arpt_get_ctl(sk, cmd, user, len); - } - return ret; -} #endif static int do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) @@ -1459,11 +1412,16 @@ static int do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned switch (cmd) { case ARPT_SO_SET_REPLACE: - ret = do_replace(sock_net(sk), user, len); +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + ret = compat_do_replace(sock_net(sk), user, len); + else +#endif + ret = do_replace(sock_net(sk), user, len); break; case ARPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len, 0); + ret = do_add_counters(sock_net(sk), user, len); break; default: @@ -1482,11 +1440,16 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len switch (cmd) { case ARPT_SO_GET_INFO: - ret = get_info(sock_net(sk), user, len, 0); + ret = get_info(sock_net(sk), user, len); break; case ARPT_SO_GET_ENTRIES: - ret = get_entries(sock_net(sk), user, len); +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + ret = compat_get_entries(sock_net(sk), user, len); + else +#endif + ret = get_entries(sock_net(sk), user, len); break; case ARPT_SO_GET_REVISION_TARGET: { @@ -1610,15 +1573,9 @@ static struct nf_sockopt_ops arpt_sockopts = { .set_optmin = ARPT_BASE_CTL, .set_optmax = ARPT_SO_SET_MAX+1, .set = do_arpt_set_ctl, -#ifdef CONFIG_COMPAT - .compat_set = compat_do_arpt_set_ctl, -#endif .get_optmin = ARPT_BASE_CTL, .get_optmax = ARPT_SO_GET_MAX+1, .get = do_arpt_get_ctl, -#ifdef CONFIG_COMPAT - .compat_get = compat_do_arpt_get_ctl, -#endif .owner = THIS_MODULE, }; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gDcCLU1EEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:25:17 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yCShK01EEV/y3AEAlScrYA (envelope-from ); Fri, 17 Jul 2020 08:25:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1B39DA1664; Fri, 17 Jul 2020 08:25:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727950AbgGQGYo (ORCPT + 1 other); Fri, 17 Jul 2020 02:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbgGQGYn (ORCPT ); Fri, 17 Jul 2020 02:24:43 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94E0AC061755; Thu, 16 Jul 2020 23:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=gprtfGHH57kbYosRry7VIZLZevW2g4f/6blQ/81HjxI=; b=dJFHTMDh0B5sK4FzdAGWodS0Do CJt6Voat/rSpR8bsqwNLJ1mfQqEVmSggviOKyStmYokIKb3lk+8ykgRzchSOQKar4qWMrSs8iIf+X HKgGh+LLHzTRsy7BUSJcNquLY0h3V1qUfH3/wxljYe9M9Trzov9lqgWBY/SFtHgoHoRalAeW1EhTE TafdAT3NCkCR0N4UXVeYQh+51f1h/dwhz2bCuYxgA3sQqrCSEWGiOYC/4eQUOOEMIriQAZpUnnrcX LSb7g2N3fQvGyfe9r7TBrlLtK5lVf2z5Xsetf/8d3acExVTNlm0+gTmPy7Cje56sFU3ZQJtjhoWGJ Eb7ODvpQ==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJnK-00056h-Dd; Fri, 17 Jul 2020 06:24:31 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 21/22] net/ipv6: remove compat_ipv6_{get,set}sockopt Date: Fri, 17 Jul 2020 08:23:30 +0200 Message-Id: <20200717062331.691152-22-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1B39DA1664 X-Rspamd-UID: 3e18d8 Handle the few cases that need special treatment in-line using in_compat_syscall(). This also removes all the now unused compat_{get,set}sockopt methods. Signed-off-by: Christoph Hellwig --- include/net/inet_connection_sock.h | 13 -- include/net/ipv6.h | 4 - include/net/sctp/structs.h | 10 -- include/net/sock.h | 8 -- include/net/tcp.h | 4 - net/core/sock.c | 10 -- net/dccp/dccp.h | 6 - net/dccp/ipv4.c | 4 - net/dccp/ipv6.c | 12 -- net/dccp/proto.c | 26 ---- net/ipv4/inet_connection_sock.c | 28 ----- net/ipv4/tcp.c | 24 ---- net/ipv4/tcp_ipv4.c | 4 - net/ipv6/ipv6_sockglue.c | 183 ++++++++--------------------- net/ipv6/raw.c | 50 -------- net/ipv6/tcp_ipv6.c | 12 -- net/ipv6/udp.c | 25 ---- net/ipv6/udp_impl.h | 6 - net/ipv6/udplite.c | 4 - net/l2tp/l2tp_ip6.c | 4 - net/sctp/ipv6.c | 4 - 21 files changed, 51 insertions(+), 390 deletions(-) diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index e5b388f5fa2099..157c60cca0ca60 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -48,14 +48,6 @@ struct inet_connection_sock_af_ops { char __user *optval, unsigned int optlen); int (*getsockopt)(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); -#ifdef CONFIG_COMPAT - int (*compat_setsockopt)(struct sock *sk, - int level, int optname, - char __user *optval, unsigned int optlen); - int (*compat_getsockopt)(struct sock *sk, - int level, int optname, - char __user *optval, int __user *optlen); -#endif void (*addr2sockaddr)(struct sock *sk, struct sockaddr *); void (*mtu_reduced)(struct sock *sk); }; @@ -311,11 +303,6 @@ void inet_csk_listen_stop(struct sock *sk); void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); -int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen); -int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); - struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu); #define TCP_PINGPONG_THRESH 3 diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 5e65bf2fd32d09..262fc88dbd7e2f 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -1088,10 +1088,6 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen); int ipv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); -int compat_ipv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); -int compat_ipv6_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen); int __ip6_datagram_connect(struct sock *sk, struct sockaddr *addr, int addr_len); diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 9bbb2f60db9262..233bbf7df5d66c 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -438,16 +438,6 @@ struct sctp_af { int optname, char __user *optval, int __user *optlen); - int (*compat_setsockopt) (struct sock *sk, - int level, - int optname, - char __user *optval, - unsigned int optlen); - int (*compat_getsockopt) (struct sock *sk, - int level, - int optname, - char __user *optval, - int __user *optlen); void (*get_dst) (struct sctp_transport *t, union sctp_addr *saddr, struct flowi *fl, diff --git a/include/net/sock.h b/include/net/sock.h index 1fd7cf5fc7516c..3bd8bc578bf3e5 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1147,14 +1147,6 @@ struct proto { int __user *option); void (*keepalive)(struct sock *sk, int valbool); #ifdef CONFIG_COMPAT - int (*compat_setsockopt)(struct sock *sk, - int level, - int optname, char __user *optval, - unsigned int optlen); - int (*compat_getsockopt)(struct sock *sk, - int level, - int optname, char __user *optval, - int __user *option); int (*compat_ioctl)(struct sock *sk, unsigned int cmd, unsigned long arg); #endif diff --git a/include/net/tcp.h b/include/net/tcp.h index d62e24533518a7..9f7f7c0c110451 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -401,10 +401,6 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen); -int compat_tcp_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen); -int compat_tcp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); void tcp_set_keepalive(struct sock *sk, int val); void tcp_syn_ack_timeout(const struct request_sock *req); int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock, diff --git a/net/core/sock.c b/net/core/sock.c index 018404d1762682..48655d5c4cf37a 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3199,11 +3199,6 @@ int sock_common_getsockopt(struct socket *sock, int level, int optname, { struct sock *sk = sock->sk; -#ifdef CONFIG_COMPAT - if (in_compat_syscal() && sk->sk_prot->compat_getsockopt) - return sk->sk_prot->compat_getsockopt(sk, level, optname, - optval, optlen); -#endif return sk->sk_prot->getsockopt(sk, level, optname, optval, optlen); } EXPORT_SYMBOL(sock_common_getsockopt); @@ -3231,11 +3226,6 @@ int sock_common_setsockopt(struct socket *sock, int level, int optname, { struct sock *sk = sock->sk; -#ifdef CONFIG_COMPAT - if (in_compat_syscall() && sk->sk_prot->compat_setsockopt) - return sk->sk_prot->compat_setsockopt(sk, level, optname, - optval, optlen); -#endif return sk->sk_prot->setsockopt(sk, level, optname, optval, optlen); } EXPORT_SYMBOL(sock_common_setsockopt); diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 7dce4f6c70252d..434eea91b7679d 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h @@ -296,12 +296,6 @@ int dccp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); int dccp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen); -#ifdef CONFIG_COMPAT -int compat_dccp_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen); -int compat_dccp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); -#endif int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg); int dccp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size); int dccp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock, diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index b91373eb1c7974..9c28c825112533 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -959,10 +959,6 @@ static struct proto dccp_v4_prot = { .rsk_prot = &dccp_request_sock_ops, .twsk_prot = &dccp_timewait_sock_ops, .h.hashinfo = &dccp_hashinfo, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_dccp_setsockopt, - .compat_getsockopt = compat_dccp_getsockopt, -#endif }; static const struct net_protocol dccp_v4_protocol = { diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index b50f85a72cd5fc..ef4ab28cfde0e3 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -970,10 +970,6 @@ static const struct inet_connection_sock_af_ops dccp_ipv6_af_ops = { .getsockopt = ipv6_getsockopt, .addr2sockaddr = inet6_csk_addr2sockaddr, .sockaddr_len = sizeof(struct sockaddr_in6), -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_ipv6_setsockopt, - .compat_getsockopt = compat_ipv6_getsockopt, -#endif }; /* @@ -990,10 +986,6 @@ static const struct inet_connection_sock_af_ops dccp_ipv6_mapped = { .getsockopt = ipv6_getsockopt, .addr2sockaddr = inet6_csk_addr2sockaddr, .sockaddr_len = sizeof(struct sockaddr_in6), -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_ipv6_setsockopt, - .compat_getsockopt = compat_ipv6_getsockopt, -#endif }; /* NOTE: A lot of things set to zero explicitly by call to @@ -1049,10 +1041,6 @@ static struct proto dccp_v6_prot = { .rsk_prot = &dccp6_request_sock_ops, .twsk_prot = &dccp6_timewait_sock_ops, .h.hashinfo = &dccp_hashinfo, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_dccp_setsockopt, - .compat_getsockopt = compat_dccp_getsockopt, -#endif }; static const struct inet6_protocol dccp_v6_protocol = { diff --git a/net/dccp/proto.c b/net/dccp/proto.c index c13b6609474b65..fd92d3fe321f08 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -575,19 +575,6 @@ int dccp_setsockopt(struct sock *sk, int level, int optname, EXPORT_SYMBOL_GPL(dccp_setsockopt); -#ifdef CONFIG_COMPAT -int compat_dccp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) -{ - if (level != SOL_DCCP) - return inet_csk_compat_setsockopt(sk, level, optname, - optval, optlen); - return do_dccp_setsockopt(sk, level, optname, optval, optlen); -} - -EXPORT_SYMBOL_GPL(compat_dccp_setsockopt); -#endif - static int dccp_getsockopt_service(struct sock *sk, int len, __be32 __user *optval, int __user *optlen) @@ -696,19 +683,6 @@ int dccp_getsockopt(struct sock *sk, int level, int optname, EXPORT_SYMBOL_GPL(dccp_getsockopt); -#ifdef CONFIG_COMPAT -int compat_dccp_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen) -{ - if (level != SOL_DCCP) - return inet_csk_compat_getsockopt(sk, level, optname, - optval, optlen); - return do_dccp_getsockopt(sk, level, optname, optval, optlen); -} - -EXPORT_SYMBOL_GPL(compat_dccp_getsockopt); -#endif - static int dccp_msghdr_parse(struct msghdr *msg, struct sk_buff *skb) { struct cmsghdr *cmsg; diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 22b0e7336360f3..d1a3913eebe05f 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -1057,34 +1057,6 @@ void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr) } EXPORT_SYMBOL_GPL(inet_csk_addr2sockaddr); -#ifdef CONFIG_COMPAT -int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen) -{ - const struct inet_connection_sock *icsk = inet_csk(sk); - - if (icsk->icsk_af_ops->compat_getsockopt) - return icsk->icsk_af_ops->compat_getsockopt(sk, level, optname, - optval, optlen); - return icsk->icsk_af_ops->getsockopt(sk, level, optname, - optval, optlen); -} -EXPORT_SYMBOL_GPL(inet_csk_compat_getsockopt); - -int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) -{ - const struct inet_connection_sock *icsk = inet_csk(sk); - - if (icsk->icsk_af_ops->compat_setsockopt) - return icsk->icsk_af_ops->compat_setsockopt(sk, level, optname, - optval, optlen); - return icsk->icsk_af_ops->setsockopt(sk, level, optname, - optval, optlen); -} -EXPORT_SYMBOL_GPL(inet_csk_compat_setsockopt); -#endif - static struct dst_entry *inet_csk_rebuild_route(struct sock *sk, struct flowi *fl) { const struct inet_sock *inet = inet_sk(sk); diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 254b6a4cc95bd0..58ede3d62b2e2c 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3337,18 +3337,6 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, } EXPORT_SYMBOL(tcp_setsockopt); -#ifdef CONFIG_COMPAT -int compat_tcp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) -{ - if (level != SOL_TCP) - return inet_csk_compat_setsockopt(sk, level, optname, - optval, optlen); - return do_tcp_setsockopt(sk, level, optname, optval, optlen); -} -EXPORT_SYMBOL(compat_tcp_setsockopt); -#endif - static void tcp_get_info_chrono_stats(const struct tcp_sock *tp, struct tcp_info *info) { @@ -3896,18 +3884,6 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, } EXPORT_SYMBOL(tcp_getsockopt); -#ifdef CONFIG_COMPAT -int compat_tcp_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen) -{ - if (level != SOL_TCP) - return inet_csk_compat_getsockopt(sk, level, optname, - optval, optlen); - return do_tcp_getsockopt(sk, level, optname, optval, optlen); -} -EXPORT_SYMBOL(compat_tcp_getsockopt); -#endif - #ifdef CONFIG_TCP_MD5SIG static DEFINE_PER_CPU(struct tcp_md5sig_pool, tcp_md5sig_pool); static DEFINE_MUTEX(tcp_md5sig_mutex); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index e5b7ef9a288769..cd81b6e04efbfa 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2769,10 +2769,6 @@ struct proto tcp_prot = { .rsk_prot = &tcp_request_sock_ops, .h.hashinfo = &tcp_hashinfo, .no_autobind = true, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_tcp_setsockopt, - .compat_getsockopt = compat_tcp_getsockopt, -#endif .diag_destroy = tcp_abort, }; EXPORT_SYMBOL(tcp_prot); diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 1ea0cd12beaee9..add8f791229945 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -136,13 +136,42 @@ static bool setsockopt_needs_rtnl(int optname) return false; } +static int copy_group_source_from_user(struct group_source_req *greqs, + void __user *optval, int optlen) +{ + if (in_compat_syscall()) { + struct compat_group_source_req gr32; + + if (optlen < sizeof(gr32)) + return -EINVAL; + if (copy_from_user(&gr32, optval, sizeof(gr32))) + return -EFAULT; + greqs->gsr_interface = gr32.gsr_interface; + greqs->gsr_group = gr32.gsr_group; + greqs->gsr_source = gr32.gsr_source; + } else { + if (optlen < sizeof(*greqs)) + return -EINVAL; + if (copy_from_user(greqs, optval, sizeof(*greqs))) + return -EFAULT; + } + + return 0; +} + static int do_ipv6_mcast_group_source(struct sock *sk, int optname, - struct group_source_req *greqs) + void __user *optval, int optlen) { + struct group_source_req greqs; int omode, add; + int ret; + + ret = copy_group_source_from_user(&greqs, optval, optlen); + if (ret) + return ret; - if (greqs->gsr_group.ss_family != AF_INET6 || - greqs->gsr_source.ss_family != AF_INET6) + if (greqs.gsr_group.ss_family != AF_INET6 || + greqs.gsr_source.ss_family != AF_INET6) return -EADDRNOTAVAIL; if (optname == MCAST_BLOCK_SOURCE) { @@ -155,8 +184,8 @@ static int do_ipv6_mcast_group_source(struct sock *sk, int optname, struct sockaddr_in6 *psin6; int retv; - psin6 = (struct sockaddr_in6 *)&greqs->gsr_group; - retv = ipv6_sock_mc_join_ssm(sk, greqs->gsr_interface, + psin6 = (struct sockaddr_in6 *)&greqs.gsr_group; + retv = ipv6_sock_mc_join_ssm(sk, greqs.gsr_interface, &psin6->sin6_addr, MCAST_INCLUDE); /* prior join w/ different source is ok */ @@ -168,7 +197,7 @@ static int do_ipv6_mcast_group_source(struct sock *sk, int optname, omode = MCAST_INCLUDE; add = 0; } - return ip6_mc_source(add, omode, sk, greqs); + return ip6_mc_source(add, omode, sk, &greqs); } static int ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, @@ -202,7 +231,6 @@ static int ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, return ret; } -#ifdef CONFIG_COMPAT static int compat_ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, int optlen) { @@ -236,21 +264,16 @@ static int compat_ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, if (offsetof(struct compat_group_filter, gf_slist[n]) > optlen) goto out_free_p; - rtnl_lock(); - lock_sock(sk); ret = ip6_mc_msfilter(sk, &(struct group_filter){ .gf_interface = gf32->gf_interface, .gf_group = gf32->gf_group, .gf_fmode = gf32->gf_fmode, .gf_numsrc = gf32->gf_numsrc}, gf32->gf_slist); - release_sock(sk); - rtnl_unlock(); out_free_p: kfree(p); return ret; } -#endif static int ipv6_mcast_join_leave(struct sock *sk, int optname, void __user *optval, int optlen) @@ -272,13 +295,11 @@ static int ipv6_mcast_join_leave(struct sock *sk, int optname, return ipv6_sock_mc_drop(sk, greq.gr_interface, &psin6->sin6_addr); } -#ifdef CONFIG_COMPAT static int compat_ipv6_mcast_join_leave(struct sock *sk, int optname, void __user *optval, int optlen) { struct compat_group_req gr32; struct sockaddr_in6 *psin6; - int err; if (optlen < sizeof(gr32)) return -EINVAL; @@ -287,20 +308,12 @@ static int compat_ipv6_mcast_join_leave(struct sock *sk, int optname, if (gr32.gr_group.ss_family != AF_INET6) return -EADDRNOTAVAIL; - rtnl_lock(); - lock_sock(sk); psin6 = (struct sockaddr_in6 *)&gr32.gr_group; if (optname == MCAST_JOIN_GROUP) - err = ipv6_sock_mc_join(sk, gr32.gr_interface, + return ipv6_sock_mc_join(sk, gr32.gr_interface, &psin6->sin6_addr); - else - err = ipv6_sock_mc_drop(sk, gr32.gr_interface, - &psin6->sin6_addr); - release_sock(sk); - rtnl_unlock(); - return err; + return ipv6_sock_mc_drop(sk, gr32.gr_interface, &psin6->sin6_addr); } -#endif static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) @@ -853,26 +866,25 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, case MCAST_JOIN_GROUP: case MCAST_LEAVE_GROUP: - retv = ipv6_mcast_join_leave(sk, optname, optval, optlen); + if (in_compat_syscall()) + retv = compat_ipv6_mcast_join_leave(sk, optname, optval, + optlen); + else + retv = ipv6_mcast_join_leave(sk, optname, optval, + optlen); break; case MCAST_JOIN_SOURCE_GROUP: case MCAST_LEAVE_SOURCE_GROUP: case MCAST_BLOCK_SOURCE: case MCAST_UNBLOCK_SOURCE: - { - struct group_source_req greqs; - - if (optlen < sizeof(struct group_source_req)) - goto e_inval; - if (copy_from_user(&greqs, optval, sizeof(greqs))) { - retv = -EFAULT; - break; - } - retv = do_ipv6_mcast_group_source(sk, optname, &greqs); + retv = do_ipv6_mcast_group_source(sk, optname, optval, optlen); break; - } case MCAST_MSFILTER: - retv = ipv6_set_mcast_msfilter(sk, optval, optlen); + if (in_compat_syscall()) + retv = compat_ipv6_set_mcast_msfilter(sk, optval, + optlen); + else + retv = ipv6_set_mcast_msfilter(sk, optval, optlen); break; case IPV6_ROUTER_ALERT: if (optlen < sizeof(int)) @@ -989,64 +1001,6 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, } EXPORT_SYMBOL(ipv6_setsockopt); -#ifdef CONFIG_COMPAT -int compat_ipv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) -{ - int err; - - if (level == SOL_IP && sk->sk_type != SOCK_RAW) - return udp_prot.setsockopt(sk, level, optname, optval, optlen); - - if (level != SOL_IPV6) - return -ENOPROTOOPT; - - switch (optname) { - case MCAST_JOIN_GROUP: - case MCAST_LEAVE_GROUP: - return compat_ipv6_mcast_join_leave(sk, optname, optval, - optlen); - case MCAST_JOIN_SOURCE_GROUP: - case MCAST_LEAVE_SOURCE_GROUP: - case MCAST_BLOCK_SOURCE: - case MCAST_UNBLOCK_SOURCE: - { - struct compat_group_source_req __user *gsr32 = (void __user *)optval; - struct group_source_req greqs; - - if (optlen < sizeof(struct compat_group_source_req)) - return -EINVAL; - - if (get_user(greqs.gsr_interface, &gsr32->gsr_interface) || - copy_from_user(&greqs.gsr_group, &gsr32->gsr_group, - sizeof(greqs.gsr_group)) || - copy_from_user(&greqs.gsr_source, &gsr32->gsr_source, - sizeof(greqs.gsr_source))) - return -EFAULT; - - rtnl_lock(); - lock_sock(sk); - err = do_ipv6_mcast_group_source(sk, optname, &greqs); - release_sock(sk); - rtnl_unlock(); - return err; - } - case MCAST_MSFILTER: - return compat_ipv6_set_mcast_msfilter(sk, optval, optlen); - } - - err = do_ipv6_setsockopt(sk, level, optname, optval, optlen); -#ifdef CONFIG_NETFILTER - /* we need to exclude all possible ENOPROTOOPTs except default case */ - if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY && - optname != IPV6_XFRM_POLICY) - err = nf_setsockopt(sk, PF_INET6, optname, optval, optlen); -#endif - return err; -} -EXPORT_SYMBOL(compat_ipv6_setsockopt); -#endif - static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_txoptions *opt, int optname, char __user *optval, int len) { @@ -1110,7 +1064,6 @@ static int ipv6_get_msfilter(struct sock *sk, void __user *optval, return err; } -#ifdef CONFIG_COMPAT static int compat_ipv6_get_msfilter(struct sock *sk, void __user *optval, int __user *optlen) { @@ -1150,7 +1103,6 @@ static int compat_ipv6_get_msfilter(struct sock *sk, void __user *optval, return -EFAULT; return 0; } -#endif static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen, unsigned int flags) @@ -1175,6 +1127,8 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, val = sk->sk_family; break; case MCAST_MSFILTER: + if (in_compat_syscall()) + return compat_ipv6_get_msfilter(sk, optval, optlen); return ipv6_get_msfilter(sk, optval, optlen, len); case IPV6_2292PKTOPTIONS: { @@ -1523,38 +1477,3 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, return err; } EXPORT_SYMBOL(ipv6_getsockopt); - -#ifdef CONFIG_COMPAT -int compat_ipv6_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen) -{ - int err; - - if (level == SOL_IP && sk->sk_type != SOCK_RAW) - return udp_prot.getsockopt(sk, level, optname, optval, optlen); - - if (level != SOL_IPV6) - return -ENOPROTOOPT; - - if (optname == MCAST_MSFILTER) - return compat_ipv6_get_msfilter(sk, optval, optlen); - - err = do_ipv6_getsockopt(sk, level, optname, optval, optlen, - MSG_CMSG_COMPAT); -#ifdef CONFIG_NETFILTER - /* we need to exclude all possible ENOPROTOOPTs except default case */ - if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) { - int len; - - if (get_user(len, optlen)) - return -EFAULT; - - err = nf_getsockopt(sk, PF_INET6, optname, optval, &len); - if (err >= 0) - err = put_user(len, optlen); - } -#endif - return err; -} -EXPORT_SYMBOL(compat_ipv6_getsockopt); -#endif diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index e23c6b46175870..594e01ad670aa6 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -1084,30 +1084,6 @@ static int rawv6_setsockopt(struct sock *sk, int level, int optname, return do_rawv6_setsockopt(sk, level, optname, optval, optlen); } -#ifdef CONFIG_COMPAT -static int compat_rawv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) -{ - switch (level) { - case SOL_RAW: - break; - case SOL_ICMPV6: - if (inet_sk(sk)->inet_num != IPPROTO_ICMPV6) - return -EOPNOTSUPP; - return rawv6_seticmpfilter(sk, level, optname, optval, optlen); - case SOL_IPV6: - if (optname == IPV6_CHECKSUM || - optname == IPV6_HDRINCL) - break; - fallthrough; - default: - return compat_ipv6_setsockopt(sk, level, optname, - optval, optlen); - } - return do_rawv6_setsockopt(sk, level, optname, optval, optlen); -} -#endif - static int do_rawv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen) { @@ -1169,30 +1145,6 @@ static int rawv6_getsockopt(struct sock *sk, int level, int optname, return do_rawv6_getsockopt(sk, level, optname, optval, optlen); } -#ifdef CONFIG_COMPAT -static int compat_rawv6_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen) -{ - switch (level) { - case SOL_RAW: - break; - case SOL_ICMPV6: - if (inet_sk(sk)->inet_num != IPPROTO_ICMPV6) - return -EOPNOTSUPP; - return rawv6_geticmpfilter(sk, level, optname, optval, optlen); - case SOL_IPV6: - if (optname == IPV6_CHECKSUM || - optname == IPV6_HDRINCL) - break; - fallthrough; - default: - return compat_ipv6_getsockopt(sk, level, optname, - optval, optlen); - } - return do_rawv6_getsockopt(sk, level, optname, optval, optlen); -} -#endif - static int rawv6_ioctl(struct sock *sk, int cmd, unsigned long arg) { switch (cmd) { @@ -1297,8 +1249,6 @@ struct proto rawv6_prot = { .usersize = sizeof_field(struct raw6_sock, filter), .h.raw_hash = &raw_v6_hashinfo, #ifdef CONFIG_COMPAT - .compat_setsockopt = compat_rawv6_setsockopt, - .compat_getsockopt = compat_rawv6_getsockopt, .compat_ioctl = compat_rawv6_ioctl, #endif .diag_destroy = raw_abort, diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 4502db706f7534..c34b7834fd84a8 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1831,10 +1831,6 @@ const struct inet_connection_sock_af_ops ipv6_specific = { .getsockopt = ipv6_getsockopt, .addr2sockaddr = inet6_csk_addr2sockaddr, .sockaddr_len = sizeof(struct sockaddr_in6), -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_ipv6_setsockopt, - .compat_getsockopt = compat_ipv6_getsockopt, -#endif .mtu_reduced = tcp_v6_mtu_reduced, }; @@ -1861,10 +1857,6 @@ static const struct inet_connection_sock_af_ops ipv6_mapped = { .getsockopt = ipv6_getsockopt, .addr2sockaddr = inet6_csk_addr2sockaddr, .sockaddr_len = sizeof(struct sockaddr_in6), -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_ipv6_setsockopt, - .compat_getsockopt = compat_ipv6_getsockopt, -#endif .mtu_reduced = tcp_v4_mtu_reduced, }; @@ -2122,10 +2114,6 @@ struct proto tcpv6_prot = { .rsk_prot = &tcp6_request_sock_ops, .h.hashinfo = &tcp_hashinfo, .no_autobind = true, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_tcp_setsockopt, - .compat_getsockopt = compat_tcp_getsockopt, -#endif .diag_destroy = tcp_abort, }; EXPORT_SYMBOL_GPL(tcpv6_prot); diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 38c0d9350c6b8f..5aff0856a05b44 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1570,17 +1570,6 @@ int udpv6_setsockopt(struct sock *sk, int level, int optname, return ipv6_setsockopt(sk, level, optname, optval, optlen); } -#ifdef CONFIG_COMPAT -int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) -{ - if (level == SOL_UDP || level == SOL_UDPLITE) - return udp_lib_setsockopt(sk, level, optname, optval, optlen, - udp_v6_push_pending_frames); - return compat_ipv6_setsockopt(sk, level, optname, optval, optlen); -} -#endif - int udpv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen) { @@ -1589,16 +1578,6 @@ int udpv6_getsockopt(struct sock *sk, int level, int optname, return ipv6_getsockopt(sk, level, optname, optval, optlen); } -#ifdef CONFIG_COMPAT -int compat_udpv6_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen) -{ - if (level == SOL_UDP || level == SOL_UDPLITE) - return udp_lib_getsockopt(sk, level, optname, optval, optlen); - return compat_ipv6_getsockopt(sk, level, optname, optval, optlen); -} -#endif - /* thinking of making this const? Don't. * early_demux can change based on sysctl. */ @@ -1681,10 +1660,6 @@ struct proto udpv6_prot = { .sysctl_rmem_offset = offsetof(struct net, ipv4.sysctl_udp_rmem_min), .obj_size = sizeof(struct udp6_sock), .h.udp_table = &udp_table, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_udpv6_setsockopt, - .compat_getsockopt = compat_udpv6_getsockopt, -#endif .diag_destroy = udp_abort, }; diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h index 20e324b6f3584e..30dfb6f1b7622a 100644 --- a/net/ipv6/udp_impl.h +++ b/net/ipv6/udp_impl.h @@ -19,12 +19,6 @@ int udpv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); int udpv6_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen); -#ifdef CONFIG_COMPAT -int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); -int compat_udpv6_getsockopt(struct sock *sk, int level, int optname, - char __user *optval, int __user *optlen); -#endif int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len); int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, int flags, int *addr_len); diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c index bf7a7acd39b1d5..fbb700d3f437ee 100644 --- a/net/ipv6/udplite.c +++ b/net/ipv6/udplite.c @@ -52,10 +52,6 @@ struct proto udplitev6_prot = { .sysctl_mem = sysctl_udp_mem, .obj_size = sizeof(struct udp6_sock), .h.udp_table = &udplite_table, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_udpv6_setsockopt, - .compat_getsockopt = compat_udpv6_getsockopt, -#endif }; static struct inet_protosw udplite6_protosw = { diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c index 2cdc0b7a7a43c3..4799bec87b332f 100644 --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c @@ -745,10 +745,6 @@ static struct proto l2tp_ip6_prot = { .hash = l2tp_ip6_hash, .unhash = l2tp_ip6_unhash, .obj_size = sizeof(struct l2tp_ip6_sock), -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_ipv6_setsockopt, - .compat_getsockopt = compat_ipv6_getsockopt, -#endif }; static const struct proto_ops l2tp_ip6_ops = { diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index ebda31b7747d08..aea2a982984d02 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -1087,10 +1087,6 @@ static struct sctp_af sctp_af_inet6 = { .net_header_len = sizeof(struct ipv6hdr), .sockaddr_len = sizeof(struct sockaddr_in6), .ip_options_len = sctp_v6_ip_options_len, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_ipv6_setsockopt, - .compat_getsockopt = compat_ipv6_getsockopt, -#endif }; static struct sctp_pf sctp_pf_inet6 = { -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kPVSGFlEEV993wAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:25:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mFPaFllEEV+12wEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:25:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 26DACA23B0; Fri, 17 Jul 2020 08:25:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727820AbgGQGYy (ORCPT + 1 other); Fri, 17 Jul 2020 02:24:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726426AbgGQGYo (ORCPT ); Fri, 17 Jul 2020 02:24:44 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86202C08C5C0; Thu, 16 Jul 2020 23:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=kbGmHpM4oj2iSBg8afJLPvPTqr4Oo7etdmQf4Gx3p6g=; b=enqk4z7AtkWvVVT0ktmRixHxYG ZE6nr495nmVeqXTvqNhSZAk/LeaHFxGyOtXhcccmzRAlDjVvCGobT5rvHbv8NtqQVHaaC0xnJ3Hb9 Er4n5IYTU1mkuPplXbnndtuOcDytQpv+nxt2M2mW36ArSipGP+w85zBQ6rbtZjlLM/sDr+9hGxTHZ Qlr1OYczhUpJGuvEig/YgFx4M/upAXCRfjYxwDUMHdHL9JWNfSAGdJfBWwKwwpLzh7X4CsuKqjYrI r7j1ievIEPg0b6BeMmzWbCoFv1zqE/m3+gPFPm60upHtjdfqlSfIuBgAOyTb4MtC1WwSlbOkQ2ELx UAjW3v0A==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJnM-000576-Cm; Fri, 17 Jul 2020 06:24:33 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 22/22] net: make ->{get,set}sockopt in proto_ops optional Date: Fri, 17 Jul 2020 08:23:31 +0200 Message-Id: <20200717062331.691152-23-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 14 X-Rspamd-Score: 2.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 26DACA23B0 X-Rspamd-UID: 333e65 Just check for a NULL method instead of wiring up sock_no_{get,set}sockopt. Signed-off-by: Christoph Hellwig --- crypto/af_alg.c | 1 - crypto/algif_aead.c | 4 ---- crypto/algif_hash.c | 4 ---- crypto/algif_rng.c | 2 -- crypto/algif_skcipher.c | 4 ---- drivers/isdn/mISDN/socket.c | 2 -- drivers/net/ppp/pppoe.c | 2 -- drivers/net/ppp/pptp.c | 2 -- include/net/sock.h | 2 -- net/appletalk/ddp.c | 2 -- net/bluetooth/bnep/sock.c | 2 -- net/bluetooth/cmtp/sock.c | 2 -- net/bluetooth/hidp/sock.c | 2 -- net/caif/caif_socket.c | 2 -- net/can/bcm.c | 2 -- net/core/sock.c | 14 -------------- net/key/af_key.c | 2 -- net/nfc/llcp_sock.c | 2 -- net/nfc/rawsock.c | 4 ---- net/packet/af_packet.c | 2 -- net/phonet/socket.c | 2 -- net/qrtr/qrtr.c | 2 -- net/smc/af_smc.c | 9 +++++++-- net/socket.c | 4 ++++ net/unix/af_unix.c | 6 ------ net/vmw_vsock/af_vsock.c | 2 -- 26 files changed, 11 insertions(+), 73 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 28fc323e3fe304..29f71428520b4b 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -335,7 +335,6 @@ static const struct proto_ops alg_proto_ops = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .getsockopt = sock_no_getsockopt, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, .sendmsg = sock_no_sendmsg, diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c index 0ae000a61c7f5b..527d09a694627b 100644 --- a/crypto/algif_aead.c +++ b/crypto/algif_aead.c @@ -361,11 +361,9 @@ static struct proto_ops algif_aead_ops = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .getsockopt = sock_no_getsockopt, .mmap = sock_no_mmap, .bind = sock_no_bind, .accept = sock_no_accept, - .setsockopt = sock_no_setsockopt, .release = af_alg_release, .sendmsg = aead_sendmsg, @@ -454,11 +452,9 @@ static struct proto_ops algif_aead_ops_nokey = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .getsockopt = sock_no_getsockopt, .mmap = sock_no_mmap, .bind = sock_no_bind, .accept = sock_no_accept, - .setsockopt = sock_no_setsockopt, .release = af_alg_release, .sendmsg = aead_sendmsg_nokey, diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c index e71727c25a7db7..50f7b22f1b4825 100644 --- a/crypto/algif_hash.c +++ b/crypto/algif_hash.c @@ -279,10 +279,8 @@ static struct proto_ops algif_hash_ops = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .getsockopt = sock_no_getsockopt, .mmap = sock_no_mmap, .bind = sock_no_bind, - .setsockopt = sock_no_setsockopt, .release = af_alg_release, .sendmsg = hash_sendmsg, @@ -383,10 +381,8 @@ static struct proto_ops algif_hash_ops_nokey = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .getsockopt = sock_no_getsockopt, .mmap = sock_no_mmap, .bind = sock_no_bind, - .setsockopt = sock_no_setsockopt, .release = af_alg_release, .sendmsg = hash_sendmsg_nokey, diff --git a/crypto/algif_rng.c b/crypto/algif_rng.c index 087c0ad09d382b..6300e0566dc560 100644 --- a/crypto/algif_rng.c +++ b/crypto/algif_rng.c @@ -101,11 +101,9 @@ static struct proto_ops algif_rng_ops = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .getsockopt = sock_no_getsockopt, .mmap = sock_no_mmap, .bind = sock_no_bind, .accept = sock_no_accept, - .setsockopt = sock_no_setsockopt, .sendmsg = sock_no_sendmsg, .sendpage = sock_no_sendpage, diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index ec5567c87a6df4..c487887f46711e 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c @@ -188,11 +188,9 @@ static struct proto_ops algif_skcipher_ops = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .getsockopt = sock_no_getsockopt, .mmap = sock_no_mmap, .bind = sock_no_bind, .accept = sock_no_accept, - .setsockopt = sock_no_setsockopt, .release = af_alg_release, .sendmsg = skcipher_sendmsg, @@ -281,11 +279,9 @@ static struct proto_ops algif_skcipher_ops_nokey = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .getsockopt = sock_no_getsockopt, .mmap = sock_no_mmap, .bind = sock_no_bind, .accept = sock_no_accept, - .setsockopt = sock_no_setsockopt, .release = af_alg_release, .sendmsg = skcipher_sendmsg_nokey, diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c index dff4132b3702c6..1b2b91479107bc 100644 --- a/drivers/isdn/mISDN/socket.c +++ b/drivers/isdn/mISDN/socket.c @@ -738,8 +738,6 @@ static const struct proto_ops base_sock_ops = { .recvmsg = sock_no_recvmsg, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .connect = sock_no_connect, .socketpair = sock_no_socketpair, .accept = sock_no_accept, diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c index beedaad082551b..d7f50b835050d1 100644 --- a/drivers/net/ppp/pppoe.c +++ b/drivers/net/ppp/pppoe.c @@ -1110,8 +1110,6 @@ static const struct proto_ops pppoe_ops = { .poll = datagram_poll, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = pppoe_sendmsg, .recvmsg = pppoe_recvmsg, .mmap = sock_no_mmap, diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c index acccb747aedad6..ee5058445d06e2 100644 --- a/drivers/net/ppp/pptp.c +++ b/drivers/net/ppp/pptp.c @@ -618,8 +618,6 @@ static const struct proto_ops pptp_ops = { .getname = pptp_getname, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = sock_no_sendmsg, .recvmsg = sock_no_recvmsg, .mmap = sock_no_mmap, diff --git a/include/net/sock.h b/include/net/sock.h index 3bd8bc578bf3e5..62e18fc8ac9f96 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1714,8 +1714,6 @@ int sock_no_getname(struct socket *, struct sockaddr *, int); int sock_no_ioctl(struct socket *, unsigned int, unsigned long); int sock_no_listen(struct socket *, int); int sock_no_shutdown(struct socket *, int); -int sock_no_getsockopt(struct socket *, int , int, char __user *, int __user *); -int sock_no_setsockopt(struct socket *, int, int, char __user *, unsigned int); int sock_no_sendmsg(struct socket *, struct msghdr *, size_t); int sock_no_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t len); int sock_no_recvmsg(struct socket *, struct msghdr *, size_t, int); diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 15787e8c0629a0..1d48708c5a2eb5 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c @@ -1917,8 +1917,6 @@ static const struct proto_ops atalk_dgram_ops = { #endif .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = atalk_sendmsg, .recvmsg = atalk_recvmsg, .mmap = sock_no_mmap, diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c index cfd83c5521aecc..d515571b2afba9 100644 --- a/net/bluetooth/bnep/sock.c +++ b/net/bluetooth/bnep/sock.c @@ -182,8 +182,6 @@ static const struct proto_ops bnep_sock_ops = { .recvmsg = sock_no_recvmsg, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .connect = sock_no_connect, .socketpair = sock_no_socketpair, .accept = sock_no_accept, diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c index defdd4871919f3..96d49d9fae9643 100644 --- a/net/bluetooth/cmtp/sock.c +++ b/net/bluetooth/cmtp/sock.c @@ -185,8 +185,6 @@ static const struct proto_ops cmtp_sock_ops = { .recvmsg = sock_no_recvmsg, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .connect = sock_no_connect, .socketpair = sock_no_socketpair, .accept = sock_no_accept, diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index 03be6a4baef30e..595fb3c9d6c361 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c @@ -233,8 +233,6 @@ static const struct proto_ops hidp_sock_ops = { .recvmsg = sock_no_recvmsg, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .connect = sock_no_connect, .socketpair = sock_no_socketpair, .accept = sock_no_accept, diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c index ef14da50a98191..b94ecd931002e7 100644 --- a/net/caif/caif_socket.c +++ b/net/caif/caif_socket.c @@ -981,7 +981,6 @@ static const struct proto_ops caif_seqpacket_ops = { .listen = sock_no_listen, .shutdown = sock_no_shutdown, .setsockopt = setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = caif_seqpkt_sendmsg, .recvmsg = caif_seqpkt_recvmsg, .mmap = sock_no_mmap, @@ -1002,7 +1001,6 @@ static const struct proto_ops caif_stream_ops = { .listen = sock_no_listen, .shutdown = sock_no_shutdown, .setsockopt = setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = caif_stream_sendmsg, .recvmsg = caif_stream_recvmsg, .mmap = sock_no_mmap, diff --git a/net/can/bcm.c b/net/can/bcm.c index c96fa0f33db39c..d14ea12affb112 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c @@ -1648,8 +1648,6 @@ static const struct proto_ops bcm_ops = { .gettstamp = sock_gettstamp, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = bcm_sendmsg, .recvmsg = bcm_recvmsg, .mmap = sock_no_mmap, diff --git a/net/core/sock.c b/net/core/sock.c index 48655d5c4cf37a..d828bfe1c47dfa 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2783,20 +2783,6 @@ int sock_no_shutdown(struct socket *sock, int how) } EXPORT_SYMBOL(sock_no_shutdown); -int sock_no_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) -{ - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(sock_no_setsockopt); - -int sock_no_getsockopt(struct socket *sock, int level, int optname, - char __user *optval, int __user *optlen) -{ - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(sock_no_getsockopt); - int sock_no_sendmsg(struct socket *sock, struct msghdr *m, size_t len) { return -EOPNOTSUPP; diff --git a/net/key/af_key.c b/net/key/af_key.c index b67ed3a8486c25..f13626c1a98592 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -3734,8 +3734,6 @@ static const struct proto_ops pfkey_ops = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index 28604414dec1b7..6da1e2334bb697 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -921,8 +921,6 @@ static const struct proto_ops llcp_rawsock_ops = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = sock_no_sendmsg, .recvmsg = llcp_sock_recvmsg, .mmap = sock_no_mmap, diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c index ba5ffd3badd324..b2061b6746eaa6 100644 --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c @@ -276,8 +276,6 @@ static const struct proto_ops rawsock_ops = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = rawsock_sendmsg, .recvmsg = rawsock_recvmsg, .mmap = sock_no_mmap, @@ -296,8 +294,6 @@ static const struct proto_ops rawsock_raw_ops = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = sock_no_sendmsg, .recvmsg = rawsock_recvmsg, .mmap = sock_no_mmap, diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 35aee9e980536d..c240fb5de3f014 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -4503,8 +4503,6 @@ static const struct proto_ops packet_ops_spkt = { .gettstamp = sock_gettstamp, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = packet_sendmsg_spkt, .recvmsg = packet_recvmsg, .mmap = sock_no_mmap, diff --git a/net/phonet/socket.c b/net/phonet/socket.c index 87c60f83c18061..2599235d592e0b 100644 --- a/net/phonet/socket.c +++ b/net/phonet/socket.c @@ -439,8 +439,6 @@ const struct proto_ops phonet_dgram_ops = { .ioctl = pn_socket_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = pn_socket_sendmsg, .recvmsg = sock_common_recvmsg, .mmap = sock_no_mmap, diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 24a8c3c6da0dca..0cb4adfc6641da 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -1208,8 +1208,6 @@ static const struct proto_ops qrtr_proto_ops = { .gettstamp = sock_gettstamp, .poll = datagram_poll, .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .release = qrtr_release, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 9033215438384b..9711c9e0e515bf 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1742,8 +1742,11 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, /* generic setsockopts reaching us here always apply to the * CLC socket */ - rc = smc->clcsock->ops->setsockopt(smc->clcsock, level, optname, - optval, optlen); + if (unlikely(!smc->clcsock->ops->setsockopt)) + rc = -EOPNOTSUPP; + else + rc = smc->clcsock->ops->setsockopt(smc->clcsock, level, optname, + optval, optlen); if (smc->clcsock->sk->sk_err) { sk->sk_err = smc->clcsock->sk->sk_err; sk->sk_error_report(sk); @@ -1808,6 +1811,8 @@ static int smc_getsockopt(struct socket *sock, int level, int optname, smc = smc_sk(sock->sk); /* socket options apply to the CLC socket */ + if (unlikely(!smc->clcsock->ops->getsockopt)) + return -EOPNOTSUPP; return smc->clcsock->ops->getsockopt(smc->clcsock, level, optname, optval, optlen); } diff --git a/net/socket.c b/net/socket.c index dec345982abbb6..93846568c2fb7a 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2131,6 +2131,8 @@ int __sys_setsockopt(int fd, int level, int optname, char __user *optval, if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) err = sock_setsockopt(sock, level, optname, optval, optlen); + else if (unlikely(!sock->ops->setsockopt)) + err = -EOPNOTSUPP; else err = sock->ops->setsockopt(sock, level, optname, optval, optlen); @@ -2175,6 +2177,8 @@ int __sys_getsockopt(int fd, int level, int optname, char __user *optval, if (level == SOL_SOCKET) err = sock_getsockopt(sock, level, optname, optval, optlen); + else if (unlikely(!sock->ops->getsockopt)) + err = -EOPNOTSUPP; else err = sock->ops->getsockopt(sock, level, optname, optval, optlen); diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 3385a7a0b23133..181ea6fb56a617 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -714,8 +714,6 @@ static const struct proto_ops unix_stream_ops = { #endif .listen = unix_listen, .shutdown = unix_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = unix_stream_sendmsg, .recvmsg = unix_stream_recvmsg, .mmap = sock_no_mmap, @@ -741,8 +739,6 @@ static const struct proto_ops unix_dgram_ops = { #endif .listen = sock_no_listen, .shutdown = unix_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = unix_dgram_sendmsg, .recvmsg = unix_dgram_recvmsg, .mmap = sock_no_mmap, @@ -767,8 +763,6 @@ static const struct proto_ops unix_seqpacket_ops = { #endif .listen = unix_listen, .shutdown = unix_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = unix_seqpacket_sendmsg, .recvmsg = unix_seqpacket_recvmsg, .mmap = sock_no_mmap, diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 626bf9044418cc..df204c6761c453 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1202,8 +1202,6 @@ static const struct proto_ops vsock_dgram_ops = { .ioctl = sock_no_ioctl, .listen = sock_no_listen, .shutdown = vsock_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, .sendmsg = vsock_dgram_sendmsg, .recvmsg = vsock_dgram_recvmsg, .mmap = sock_no_mmap, -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gHaQHl1EEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:25:33 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id mOoFHV1EEV9LawEA0J78UA (envelope-from ); Fri, 17 Jul 2020 08:25:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CC766A3118; Fri, 17 Jul 2020 08:25:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728040AbgGQGZF (ORCPT + 1 other); Fri, 17 Jul 2020 02:25:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727924AbgGQGYj (ORCPT ); Fri, 17 Jul 2020 02:24:39 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A347C061755; Thu, 16 Jul 2020 23:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Gk0icm7W1l6PNEXjPOF00ZeKuwMt8n5bPcc1urfvli0=; b=kdONCNhzaytXfggMeiqE4liA5Y FXH+SFlM1+3qR6XQC2W1Oaf4xZKwcHTS280Wb7OjSJkro6ZKuR/1KAJwAq+qVtU0I9X6Q5O3435fo wYk5zHTb2J1M7DQwFjefr5Obsa64MfX857EgZzFtKqJtQdmNkd0gYhoJUUgEP2VdhXekZ2pyDGdve 9qda6eWKiRYoNjZCm81FOtLtE+KX4Ef4Qlj62tsEQap1zg8E7qJcPXwGv/7kGhdcwVVNY/3Aj98Y7 laS1Ayw6MYPKpXY2HJCzp5OopcEewXMcxqL8ZWmyG+Y5Ky3TmP1U++jo12psasWq/z5SF90tdWKSj 3++RRymw==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJnH-000569-E3; Fri, 17 Jul 2020 06:24:27 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 19/22] net/ipv6: factor out MCAST_MSFILTER setsockopt helpers Date: Fri, 17 Jul 2020 08:23:28 +0200 Message-Id: <20200717062331.691152-20-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: CC766A3118 X-Rspamd-UID: 324eb2 Factor out one helper each for setting the native and compat version of the MCAST_MSFILTER option. Signed-off-by: Christoph Hellwig --- net/ipv6/ipv6_sockglue.c | 159 ++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 76 deletions(-) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index ef5656f876ac05..6aa49495d7bc0b 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -171,6 +171,87 @@ static int do_ipv6_mcast_group_source(struct sock *sk, int optname, return ip6_mc_source(add, omode, sk, greqs); } +static int ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, + int optlen) +{ + struct group_filter *gsf; + int ret; + + if (optlen < GROUP_FILTER_SIZE(0)) + return -EINVAL; + if (optlen > sysctl_optmem_max) + return -ENOBUFS; + + gsf = memdup_user(optval, optlen); + if (IS_ERR(gsf)) + return PTR_ERR(gsf); + + /* numsrc >= (4G-140)/128 overflow in 32 bits */ + ret = -ENOBUFS; + if (gsf->gf_numsrc >= 0x1ffffffU || + gsf->gf_numsrc > sysctl_mld_max_msf) + goto out_free_gsf; + + ret = -EINVAL; + if (GROUP_FILTER_SIZE(gsf->gf_numsrc) > optlen) + goto out_free_gsf; + + ret = ip6_mc_msfilter(sk, gsf, gsf->gf_slist); +out_free_gsf: + kfree(gsf); + return ret; +} + +#ifdef CONFIG_COMPAT +static int compat_ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, + int optlen) +{ + const int size0 = offsetof(struct compat_group_filter, gf_slist); + struct compat_group_filter *gf32; + void *p; + int ret; + int n; + + if (optlen < size0) + return -EINVAL; + if (optlen > sysctl_optmem_max - 4) + return -ENOBUFS; + + p = kmalloc(optlen + 4, GFP_KERNEL); + if (!p) + return -ENOMEM; + + gf32 = p + 4; /* we want ->gf_group and ->gf_slist aligned */ + ret = -EFAULT; + if (copy_from_user(gf32, optval, optlen)) + goto out_free_p; + + /* numsrc >= (4G-140)/128 overflow in 32 bits */ + ret = -ENOBUFS; + n = gf32->gf_numsrc; + if (n >= 0x1ffffffU || n > sysctl_mld_max_msf) + goto out_free_p; + + ret = -EINVAL; + if (offsetof(struct compat_group_filter, gf_slist[n]) > optlen) + goto out_free_p; + + rtnl_lock(); + lock_sock(sk); + ret = ip6_mc_msfilter(sk, &(struct group_filter){ + .gf_interface = gf32->gf_interface, + .gf_group = gf32->gf_group, + .gf_fmode = gf32->gf_fmode, + .gf_numsrc = gf32->gf_numsrc}, gf32->gf_slist); + release_sock(sk); + rtnl_unlock(); + +out_free_p: + kfree(p); + return ret; +} +#endif + static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { @@ -762,37 +843,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, break; } case MCAST_MSFILTER: - { - struct group_filter *gsf; - - if (optlen < GROUP_FILTER_SIZE(0)) - goto e_inval; - if (optlen > sysctl_optmem_max) { - retv = -ENOBUFS; - break; - } - gsf = memdup_user(optval, optlen); - if (IS_ERR(gsf)) { - retv = PTR_ERR(gsf); - break; - } - /* numsrc >= (4G-140)/128 overflow in 32 bits */ - if (gsf->gf_numsrc >= 0x1ffffffU || - gsf->gf_numsrc > sysctl_mld_max_msf) { - kfree(gsf); - retv = -ENOBUFS; - break; - } - if (GROUP_FILTER_SIZE(gsf->gf_numsrc) > optlen) { - kfree(gsf); - retv = -EINVAL; - break; - } - retv = ip6_mc_msfilter(sk, gsf, gsf->gf_slist); - kfree(gsf); - + retv = ipv6_set_mcast_msfilter(sk, optval, optlen); break; - } case IPV6_ROUTER_ALERT: if (optlen < sizeof(int)) goto e_inval; @@ -977,52 +1029,7 @@ int compat_ipv6_setsockopt(struct sock *sk, int level, int optname, return err; } case MCAST_MSFILTER: - { - const int size0 = offsetof(struct compat_group_filter, gf_slist); - struct compat_group_filter *gf32; - void *p; - int n; - - if (optlen < size0) - return -EINVAL; - if (optlen > sysctl_optmem_max - 4) - return -ENOBUFS; - - p = kmalloc(optlen + 4, GFP_KERNEL); - if (!p) - return -ENOMEM; - - gf32 = p + 4; /* we want ->gf_group and ->gf_slist aligned */ - if (copy_from_user(gf32, optval, optlen)) { - err = -EFAULT; - goto mc_msf_out; - } - - n = gf32->gf_numsrc; - /* numsrc >= (4G-140)/128 overflow in 32 bits */ - if (n >= 0x1ffffffU || - n > sysctl_mld_max_msf) { - err = -ENOBUFS; - goto mc_msf_out; - } - if (offsetof(struct compat_group_filter, gf_slist[n]) > optlen) { - err = -EINVAL; - goto mc_msf_out; - } - - rtnl_lock(); - lock_sock(sk); - err = ip6_mc_msfilter(sk, &(struct group_filter){ - .gf_interface = gf32->gf_interface, - .gf_group = gf32->gf_group, - .gf_fmode = gf32->gf_fmode, - .gf_numsrc = gf32->gf_numsrc}, gf32->gf_slist); - release_sock(sk); - rtnl_unlock(); -mc_msf_out: - kfree(p); - return err; - } + return compat_ipv6_set_mcast_msfilter(sk, optval, optlen); } err = do_ipv6_setsockopt(sk, level, optname, optval, optlen); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QAIHEW9EEV993wAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:25:51 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id uL0vD29EEV920QEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:25:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AB8C9A1B5C; Fri, 17 Jul 2020 08:25:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728025AbgGQGZF (ORCPT + 1 other); Fri, 17 Jul 2020 02:25:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727062AbgGQGYj (ORCPT ); Fri, 17 Jul 2020 02:24:39 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F05AC08C5C0; Thu, 16 Jul 2020 23:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=9ZecB7FYVOCdT8M0yq4Vnm4XxQvstglvD++Sjp0mO9k=; b=nF1demlo+MqDH7bOQoZ3yEEJGM mmGwDFKzdv4Q7lwgj3FQqO3JqEFYl+LBMa7TcvxYneP1omyk0IB9fsqurTQw8xa/QQLKiPxuO8rOy ZuM1qwf5/DPFY0TQkVsg0IO3T/4rsP0U/l7kHohmHCy6+1XCJO0wsVaBJo8P85GaYsqsXJ+O8DVek J03r4uWE25idyw13uhWSCmJMtIi79rpe7yJVZ3gGdjIJVV0dK8276gefNlukGjXRIgIhHBqKmZ5BU EzK0LeU+/P3HRiOsdwwxWCisjW91vPIlX5QVymdg5WZ6g0pOzpXgG71EHfgb9TlGWjzQghkdw6aXf zKGGhw/w==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJnI-00056M-Ul; Fri, 17 Jul 2020 06:24:29 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 20/22] net/ipv6: factor out mcast join/leave setsockopt helpers Date: Fri, 17 Jul 2020 08:23:29 +0200 Message-Id: <20200717062331.691152-21-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: AB8C9A1B5C X-Rspamd-UID: 9649e1 Factor out one helper each for setting the native and compat version of the MCAST_MSFILTER option. Signed-off-by: Christoph Hellwig --- net/ipv6/ipv6_sockglue.c | 103 ++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 6aa49495d7bc0b..1ea0cd12beaee9 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -252,6 +252,56 @@ static int compat_ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, } #endif +static int ipv6_mcast_join_leave(struct sock *sk, int optname, + void __user *optval, int optlen) +{ + struct sockaddr_in6 *psin6; + struct group_req greq; + + if (optlen < sizeof(greq)) + return -EINVAL; + if (copy_from_user(&greq, optval, sizeof(greq))) + return -EFAULT; + + if (greq.gr_group.ss_family != AF_INET6) + return -EADDRNOTAVAIL; + psin6 = (struct sockaddr_in6 *)&greq.gr_group; + if (optname == MCAST_JOIN_GROUP) + return ipv6_sock_mc_join(sk, greq.gr_interface, + &psin6->sin6_addr); + return ipv6_sock_mc_drop(sk, greq.gr_interface, &psin6->sin6_addr); +} + +#ifdef CONFIG_COMPAT +static int compat_ipv6_mcast_join_leave(struct sock *sk, int optname, + void __user *optval, int optlen) +{ + struct compat_group_req gr32; + struct sockaddr_in6 *psin6; + int err; + + if (optlen < sizeof(gr32)) + return -EINVAL; + if (copy_from_user(&gr32, optval, sizeof(gr32))) + return -EFAULT; + + if (gr32.gr_group.ss_family != AF_INET6) + return -EADDRNOTAVAIL; + rtnl_lock(); + lock_sock(sk); + psin6 = (struct sockaddr_in6 *)&gr32.gr_group; + if (optname == MCAST_JOIN_GROUP) + err = ipv6_sock_mc_join(sk, gr32.gr_interface, + &psin6->sin6_addr); + else + err = ipv6_sock_mc_drop(sk, gr32.gr_interface, + &psin6->sin6_addr); + release_sock(sk); + rtnl_unlock(); + return err; +} +#endif + static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { @@ -803,29 +853,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, case MCAST_JOIN_GROUP: case MCAST_LEAVE_GROUP: - { - struct group_req greq; - struct sockaddr_in6 *psin6; - - if (optlen < sizeof(struct group_req)) - goto e_inval; - - retv = -EFAULT; - if (copy_from_user(&greq, optval, sizeof(struct group_req))) - break; - if (greq.gr_group.ss_family != AF_INET6) { - retv = -EADDRNOTAVAIL; - break; - } - psin6 = (struct sockaddr_in6 *)&greq.gr_group; - if (optname == MCAST_JOIN_GROUP) - retv = ipv6_sock_mc_join(sk, greq.gr_interface, - &psin6->sin6_addr); - else - retv = ipv6_sock_mc_drop(sk, greq.gr_interface, - &psin6->sin6_addr); + retv = ipv6_mcast_join_leave(sk, optname, optval, optlen); break; - } case MCAST_JOIN_SOURCE_GROUP: case MCAST_LEAVE_SOURCE_GROUP: case MCAST_BLOCK_SOURCE: @@ -975,34 +1004,8 @@ int compat_ipv6_setsockopt(struct sock *sk, int level, int optname, switch (optname) { case MCAST_JOIN_GROUP: case MCAST_LEAVE_GROUP: - { - struct compat_group_req __user *gr32 = (void __user *)optval; - struct group_req greq; - struct sockaddr_in6 *psin6 = (struct sockaddr_in6 *)&greq.gr_group; - - if (optlen < sizeof(struct compat_group_req)) - return -EINVAL; - - if (get_user(greq.gr_interface, &gr32->gr_interface) || - copy_from_user(&greq.gr_group, &gr32->gr_group, - sizeof(greq.gr_group))) - return -EFAULT; - - if (greq.gr_group.ss_family != AF_INET6) - return -EADDRNOTAVAIL; - - rtnl_lock(); - lock_sock(sk); - if (optname == MCAST_JOIN_GROUP) - err = ipv6_sock_mc_join(sk, greq.gr_interface, - &psin6->sin6_addr); - else - err = ipv6_sock_mc_drop(sk, greq.gr_interface, - &psin6->sin6_addr); - release_sock(sk); - rtnl_unlock(); - return err; - } + return compat_ipv6_mcast_join_leave(sk, optname, optval, + optlen); case MCAST_JOIN_SOURCE_GROUP: case MCAST_LEAVE_SOURCE_GROUP: case MCAST_BLOCK_SOURCE: -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cF/oAXNEEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:25:55 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gNVPAHNEEV930QEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:25:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6334FA1B5C; Fri, 17 Jul 2020 08:25:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727898AbgGQGYi (ORCPT + 1 other); Fri, 17 Jul 2020 02:24:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbgGQGYg (ORCPT ); Fri, 17 Jul 2020 02:24:36 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A609C061755; Thu, 16 Jul 2020 23:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=k5yQBitoGWXMKzL90RG9It8CNBRgSDbu+ST1qozOxcg=; b=I7SHVD7hAhxU4bZhk/TnoFHv8I mweL+ngm4waQsZgn9BZqx9QCIDWOOhHZkUUhnKTHXLfRXD+XcUY39nprJvwyaV3TVJnn5sV6VwrS0 8C50wvbprT5TDcMBlh6fvKu+tXJpVg72nngnk8L9qtwkZCCHexObDmmNGN5xeg5Mul9TV0+1DMrly 3iId4mJWLY6X9xmycGdC8DldGNUCkf6HV6un8H03Pj8r2Pnq6Nf7lCigNg81DqJp/yull4144LvuQ 37mENqc7Vu7Z1FY4+uDNOG2Rl5PJQO0GulW2n9TbIE0o1yhKjQuIxHw+g0xiWrQJL0Ytv6PDEg/4u kVrHfyEA==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJnF-00055t-2o; Fri, 17 Jul 2020 06:24:26 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 18/22] net/ipv6: factor out MCAST_MSFILTER getsockopt helpers Date: Fri, 17 Jul 2020 08:23:27 +0200 Message-Id: <20200717062331.691152-19-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6334FA1B5C X-Rspamd-UID: 74124c Factor out one helper each for getting the native and compat version of the MCAST_MSFILTER option. Signed-off-by: Christoph Hellwig --- net/ipv6/ipv6_sockglue.c | 139 +++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 65 deletions(-) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 6adfbdcb7979bd..ef5656f876ac05 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -1071,6 +1071,77 @@ static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_txoptions *opt, return len; } +static int ipv6_get_msfilter(struct sock *sk, void __user *optval, + int __user *optlen, int len) +{ + const int size0 = offsetof(struct group_filter, gf_slist); + struct group_filter __user *p = optval; + struct group_filter gsf; + int num; + int err; + + if (len < size0) + return -EINVAL; + if (copy_from_user(&gsf, p, size0)) + return -EFAULT; + if (gsf.gf_group.ss_family != AF_INET6) + return -EADDRNOTAVAIL; + num = gsf.gf_numsrc; + lock_sock(sk); + err = ip6_mc_msfget(sk, &gsf, p->gf_slist); + if (!err) { + if (num > gsf.gf_numsrc) + num = gsf.gf_numsrc; + if (put_user(GROUP_FILTER_SIZE(num), optlen) || + copy_to_user(p, &gsf, size0)) + err = -EFAULT; + } + release_sock(sk); + return err; +} + +#ifdef CONFIG_COMPAT +static int compat_ipv6_get_msfilter(struct sock *sk, void __user *optval, + int __user *optlen) +{ + const int size0 = offsetof(struct compat_group_filter, gf_slist); + struct compat_group_filter __user *p = optval; + struct compat_group_filter gf32; + struct group_filter gf; + int len, err; + int num; + + if (get_user(len, optlen)) + return -EFAULT; + if (len < size0) + return -EINVAL; + + if (copy_from_user(&gf32, p, size0)) + return -EFAULT; + gf.gf_interface = gf32.gf_interface; + gf.gf_fmode = gf32.gf_fmode; + num = gf.gf_numsrc = gf32.gf_numsrc; + gf.gf_group = gf32.gf_group; + + if (gf.gf_group.ss_family != AF_INET6) + return -EADDRNOTAVAIL; + + lock_sock(sk); + err = ip6_mc_msfget(sk, &gf, p->gf_slist); + release_sock(sk); + if (err) + return err; + if (num > gf.gf_numsrc) + num = gf.gf_numsrc; + len = GROUP_FILTER_SIZE(num) - (sizeof(gf)-sizeof(gf32)); + if (put_user(len, optlen) || + put_user(gf.gf_fmode, &p->gf_fmode) || + put_user(gf.gf_numsrc, &p->gf_numsrc)) + return -EFAULT; + return 0; +} +#endif + static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen, unsigned int flags) { @@ -1094,33 +1165,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, val = sk->sk_family; break; case MCAST_MSFILTER: - { - struct group_filter __user *p = (void __user *)optval; - struct group_filter gsf; - const int size0 = offsetof(struct group_filter, gf_slist); - int num; - int err; - - if (len < size0) - return -EINVAL; - if (copy_from_user(&gsf, p, size0)) - return -EFAULT; - if (gsf.gf_group.ss_family != AF_INET6) - return -EADDRNOTAVAIL; - num = gsf.gf_numsrc; - lock_sock(sk); - err = ip6_mc_msfget(sk, &gsf, p->gf_slist); - if (!err) { - if (num > gsf.gf_numsrc) - num = gsf.gf_numsrc; - if (put_user(GROUP_FILTER_SIZE(num), optlen) || - copy_to_user(p, &gsf, size0)) - err = -EFAULT; - } - release_sock(sk); - return err; - } - + return ipv6_get_msfilter(sk, optval, optlen, len); case IPV6_2292PKTOPTIONS: { struct msghdr msg; @@ -1481,44 +1526,8 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname, if (level != SOL_IPV6) return -ENOPROTOOPT; - if (optname == MCAST_MSFILTER) { - const int size0 = offsetof(struct compat_group_filter, gf_slist); - struct compat_group_filter __user *p = (void __user *)optval; - struct compat_group_filter gf32; - struct group_filter gf; - int ulen, err; - int num; - - if (get_user(ulen, optlen)) - return -EFAULT; - - if (ulen < size0) - return -EINVAL; - - if (copy_from_user(&gf32, p, size0)) - return -EFAULT; - - gf.gf_interface = gf32.gf_interface; - gf.gf_fmode = gf32.gf_fmode; - num = gf.gf_numsrc = gf32.gf_numsrc; - gf.gf_group = gf32.gf_group; - - if (gf.gf_group.ss_family != AF_INET6) - return -EADDRNOTAVAIL; - lock_sock(sk); - err = ip6_mc_msfget(sk, &gf, p->gf_slist); - release_sock(sk); - if (err) - return err; - if (num > gf.gf_numsrc) - num = gf.gf_numsrc; - ulen = GROUP_FILTER_SIZE(num) - (sizeof(gf)-sizeof(gf32)); - if (put_user(ulen, optlen) || - put_user(gf.gf_fmode, &p->gf_fmode) || - put_user(gf.gf_numsrc, &p->gf_numsrc)) - return -EFAULT; - return 0; - } + if (optname == MCAST_MSFILTER) + return compat_ipv6_get_msfilter(sk, optval, optlen); err = do_ipv6_getsockopt(sk, level, optname, optval, optlen, MSG_CMSG_COMPAT); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aC8MAo5EEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:26:22 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id mN3KAI5EEV8ZfQEA0J78UA (envelope-from ); Fri, 17 Jul 2020 08:26:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 493D8A26DE; Fri, 17 Jul 2020 08:26:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726893AbgGQGZo (ORCPT + 1 other); Fri, 17 Jul 2020 02:25:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbgGQGYa (ORCPT ); Fri, 17 Jul 2020 02:24:30 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D0FAC061755; Thu, 16 Jul 2020 23:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=j6gd4Pw6hNpVEHfOF2IcEGR8joZO+dN7+wdCSBqFWjw=; b=TlVmg/K9KqvbS9luWHYPdSlF+l IcakB40GrVEKZU1uOXxCMHY2uiRi5CPgQsFlRmxCIWfSu8v9JpryhcQTQ7ddwbqY1BLqFIdFnla/0 2yiO0R39cliys55aKmgvAGAEZh3eTUgdy+bn3FaBXvQBMRzB/jmuHJd5PvC8Z1SCazEqL3YFqWadF FeOIAyjwWhg4kYInkSG4P0pUQbXrtwcAc3e5AkQrZoMKITl15xLX8UjXxTx2YnZXruvjFIIrl1mI4 YnVS6v8LNWj8ottBkTWh310+p6myZ4LOFZVTTtAB7oAITAgs2I5hAFcShk4dMrkvRiewZDX0XYENX wxNZb2tw==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJn9-00054j-2U; Fri, 17 Jul 2020 06:24:19 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 15/22] net/ipv4: factor out MCAST_MSFILTER setsockopt helpers Date: Fri, 17 Jul 2020 08:23:24 +0200 Message-Id: <20200717062331.691152-16-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 493D8A26DE X-Rspamd-UID: 07233b Factor out one helper each for setting the native and compat version of the MCAST_MSFILTER option. Signed-off-by: Christoph Hellwig --- net/ipv4/ip_sockglue.c | 162 ++++++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 76 deletions(-) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 70d32c9476a2e3..b587dee006f882 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -722,6 +722,90 @@ static int do_mcast_group_source(struct sock *sk, int optname, return ip_mc_source(add, omode, sk, &mreqs, greqs->gsr_interface); } +static int ip_set_mcast_msfilter(struct sock *sk, void __user *optval, + int optlen) +{ + struct group_filter *gsf = NULL; + int err; + + if (optlen < GROUP_FILTER_SIZE(0)) + return -EINVAL; + if (optlen > sysctl_optmem_max) + return -ENOBUFS; + + gsf = memdup_user(optval, optlen); + if (IS_ERR(gsf)) + return PTR_ERR(gsf); + + /* numsrc >= (4G-140)/128 overflow in 32 bits */ + err = -ENOBUFS; + if (gsf->gf_numsrc >= 0x1ffffff || + gsf->gf_numsrc > sock_net(sk)->ipv4.sysctl_igmp_max_msf) + goto out_free_gsf; + + err = -EINVAL; + if (GROUP_FILTER_SIZE(gsf->gf_numsrc) > optlen) + goto out_free_gsf; + + err = set_mcast_msfilter(sk, gsf->gf_interface, gsf->gf_numsrc, + gsf->gf_fmode, &gsf->gf_group, gsf->gf_slist); +out_free_gsf: + kfree(gsf); + return err; +} + +#ifdef CONFIG_COMPAT +static int compat_ip_set_mcast_msfilter(struct sock *sk, void __user *optval, + int optlen) +{ + const int size0 = offsetof(struct compat_group_filter, gf_slist); + struct compat_group_filter *gf32; + unsigned int n; + void *p; + int err; + + if (optlen < size0) + return -EINVAL; + if (optlen > sysctl_optmem_max - 4) + return -ENOBUFS; + + p = kmalloc(optlen + 4, GFP_KERNEL); + if (!p) + return -ENOMEM; + gf32 = p + 4; /* we want ->gf_group and ->gf_slist aligned */ + + err = -EFAULT; + if (copy_from_user(gf32, optval, optlen)) + goto out_free_gsf; + + /* numsrc >= (4G-140)/128 overflow in 32 bits */ + n = gf32->gf_numsrc; + err = -ENOBUFS; + if (n >= 0x1ffffff) + goto out_free_gsf; + + err = -EINVAL; + if (offsetof(struct compat_group_filter, gf_slist[n]) > optlen) + goto out_free_gsf; + + rtnl_lock(); + lock_sock(sk); + + /* numsrc >= (4G-140)/128 overflow in 32 bits */ + err = -ENOBUFS; + if (n > sock_net(sk)->ipv4.sysctl_igmp_max_msf) + goto out_unlock; + err = set_mcast_msfilter(sk, gf32->gf_interface, n, gf32->gf_fmode, + &gf32->gf_group, gf32->gf_slist); +out_unlock: + release_sock(sk); + rtnl_unlock(); +out_free_gsf: + kfree(p); + return err; +} +#endif + static int do_ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { @@ -1167,37 +1251,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, break; } case MCAST_MSFILTER: - { - struct group_filter *gsf = NULL; - - if (optlen < GROUP_FILTER_SIZE(0)) - goto e_inval; - if (optlen > sysctl_optmem_max) { - err = -ENOBUFS; - break; - } - gsf = memdup_user(optval, optlen); - if (IS_ERR(gsf)) { - err = PTR_ERR(gsf); - break; - } - /* numsrc >= (4G-140)/128 overflow in 32 bits */ - if (gsf->gf_numsrc >= 0x1ffffff || - gsf->gf_numsrc > net->ipv4.sysctl_igmp_max_msf) { - err = -ENOBUFS; - goto mc_msf_out; - } - if (GROUP_FILTER_SIZE(gsf->gf_numsrc) > optlen) { - err = -EINVAL; - goto mc_msf_out; - } - err = set_mcast_msfilter(sk, gsf->gf_interface, - gsf->gf_numsrc, gsf->gf_fmode, - &gsf->gf_group, gsf->gf_slist); -mc_msf_out: - kfree(gsf); + err = ip_set_mcast_msfilter(sk, optval, optlen); break; - } case IP_MULTICAST_ALL: if (optlen < 1) goto e_inval; @@ -1391,52 +1446,7 @@ int compat_ip_setsockopt(struct sock *sk, int level, int optname, return err; } case MCAST_MSFILTER: - { - const int size0 = offsetof(struct compat_group_filter, gf_slist); - struct compat_group_filter *gf32; - unsigned int n; - void *p; - - if (optlen < size0) - return -EINVAL; - if (optlen > sysctl_optmem_max - 4) - return -ENOBUFS; - - p = kmalloc(optlen + 4, GFP_KERNEL); - if (!p) - return -ENOMEM; - gf32 = p + 4; /* we want ->gf_group and ->gf_slist aligned */ - if (copy_from_user(gf32, optval, optlen)) { - err = -EFAULT; - goto mc_msf_out; - } - - n = gf32->gf_numsrc; - /* numsrc >= (4G-140)/128 overflow in 32 bits */ - if (n >= 0x1ffffff) { - err = -ENOBUFS; - goto mc_msf_out; - } - if (offsetof(struct compat_group_filter, gf_slist[n]) > optlen) { - err = -EINVAL; - goto mc_msf_out; - } - - rtnl_lock(); - lock_sock(sk); - /* numsrc >= (4G-140)/128 overflow in 32 bits */ - if (n > sock_net(sk)->ipv4.sysctl_igmp_max_msf) - err = -ENOBUFS; - else - err = set_mcast_msfilter(sk, gf32->gf_interface, - n, gf32->gf_fmode, - &gf32->gf_group, gf32->gf_slist); - release_sock(sk); - rtnl_unlock(); -mc_msf_out: - kfree(p); - return err; - } + return compat_ip_set_mcast_msfilter(sk, optval, optlen); } err = do_ip_setsockopt(sk, level, optname, optval, optlen); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IM7jI+ZEEV993wAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:27:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id QMRRIuZEEV88DgEAlp8NpQ (envelope-from ); Fri, 17 Jul 2020 08:27:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7D11BA1FE5; Fri, 17 Jul 2020 08:27:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727815AbgGQG0z (ORCPT + 1 other); Fri, 17 Jul 2020 02:26:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726665AbgGQGYM (ORCPT ); Fri, 17 Jul 2020 02:24:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3AA5C08C5DD; Thu, 16 Jul 2020 23:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=n2ODUYKF6/KbpzWzYvYsX0GmzUVJvLLKJNQfebeWuwA=; b=lXo2xnKUT2Zz9SodyFhrLMjmwS VsBB6iza3jroWdP5Sn+p2coUEpc32Tto0/NdonV2GZjjjUJnZLETAW3WTnagM/jxob5TZcgU+hzbC HBISjz1Y5i4/wF0ozC7HeooMkN7FAMd0Y4jhnbjoPpt4Ogg8KV+nfXWVILf8I4xn/BdcvhbNjRsu1 cPnwWdGNBM1POBS/rtQa/muCTLCz27XU1JsRtKuKYcIuY5l4x10POJ5OPwtPvqn58fQvtcxG+pzZJ As7pZmVBUqITScc1cuBvkoDpFDT3bNTUTeT2PRKmG/D9lFTHcT++szLQhUxkig3T6vQrGWEmS+ybo /sfdf1DA==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJmq-00052J-2X; Fri, 17 Jul 2020 06:24:01 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 05/22] net: remove compat_sock_common_{get,set}sockopt Date: Fri, 17 Jul 2020 08:23:14 +0200 Message-Id: <20200717062331.691152-6-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7D11BA1FE5 X-Rspamd-UID: 971174 Add the compat handling to sock_common_{get,set}sockopt instead, keyed of in_compat_syscall(). This allow to remove the now unused ->compat_{get,set}sockopt methods from struct proto_ops. Signed-off-by: Christoph Hellwig --- include/linux/net.h | 6 ------ include/net/sock.h | 4 ---- net/core/sock.c | 30 ++++++------------------------ net/dccp/ipv4.c | 4 ---- net/dccp/ipv6.c | 2 -- net/ieee802154/socket.c | 8 -------- net/ipv4/af_inet.c | 6 ------ net/ipv6/af_inet6.c | 4 ---- net/ipv6/ipv6_sockglue.c | 12 ++---------- net/ipv6/raw.c | 2 -- net/l2tp/l2tp_ip.c | 4 ---- net/l2tp/l2tp_ip6.c | 2 -- net/mptcp/protocol.c | 6 ------ net/phonet/socket.c | 8 -------- net/sctp/ipv6.c | 2 -- net/sctp/protocol.c | 4 ---- 16 files changed, 8 insertions(+), 96 deletions(-) diff --git a/include/linux/net.h b/include/linux/net.h index 016a9c5faa3479..858ff1d981540d 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -165,12 +165,6 @@ struct proto_ops { int optname, char __user *optval, unsigned int optlen); int (*getsockopt)(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen); -#ifdef CONFIG_COMPAT - int (*compat_setsockopt)(struct socket *sock, int level, - int optname, char __user *optval, unsigned int optlen); - int (*compat_getsockopt)(struct socket *sock, int level, - int optname, char __user *optval, int __user *optlen); -#endif void (*show_fdinfo)(struct seq_file *m, struct socket *sock); int (*sendmsg) (struct socket *sock, struct msghdr *m, size_t total_len); diff --git a/include/net/sock.h b/include/net/sock.h index 4bf8841651486d..1fd7cf5fc7516c 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1744,10 +1744,6 @@ int sock_common_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, int flags); int sock_common_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen); -int compat_sock_common_getsockopt(struct socket *sock, int level, - int optname, char __user *optval, int __user *optlen); -int compat_sock_common_setsockopt(struct socket *sock, int level, - int optname, char __user *optval, unsigned int optlen); void sk_common_release(struct sock *sk); diff --git a/net/core/sock.c b/net/core/sock.c index e085df79482520..018404d1762682 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3199,23 +3199,14 @@ int sock_common_getsockopt(struct socket *sock, int level, int optname, { struct sock *sk = sock->sk; - return sk->sk_prot->getsockopt(sk, level, optname, optval, optlen); -} -EXPORT_SYMBOL(sock_common_getsockopt); - #ifdef CONFIG_COMPAT -int compat_sock_common_getsockopt(struct socket *sock, int level, int optname, - char __user *optval, int __user *optlen) -{ - struct sock *sk = sock->sk; - - if (sk->sk_prot->compat_getsockopt != NULL) + if (in_compat_syscal() && sk->sk_prot->compat_getsockopt) return sk->sk_prot->compat_getsockopt(sk, level, optname, optval, optlen); +#endif return sk->sk_prot->getsockopt(sk, level, optname, optval, optlen); } -EXPORT_SYMBOL(compat_sock_common_getsockopt); -#endif +EXPORT_SYMBOL(sock_common_getsockopt); int sock_common_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, int flags) @@ -3240,23 +3231,14 @@ int sock_common_setsockopt(struct socket *sock, int level, int optname, { struct sock *sk = sock->sk; - return sk->sk_prot->setsockopt(sk, level, optname, optval, optlen); -} -EXPORT_SYMBOL(sock_common_setsockopt); - #ifdef CONFIG_COMPAT -int compat_sock_common_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) -{ - struct sock *sk = sock->sk; - - if (sk->sk_prot->compat_setsockopt != NULL) + if (in_compat_syscall() && sk->sk_prot->compat_setsockopt) return sk->sk_prot->compat_setsockopt(sk, level, optname, optval, optlen); +#endif return sk->sk_prot->setsockopt(sk, level, optname, optval, optlen); } -EXPORT_SYMBOL(compat_sock_common_setsockopt); -#endif +EXPORT_SYMBOL(sock_common_setsockopt); void sk_common_release(struct sock *sk) { diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index a7e989919c5307..316cc5ac0da72b 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -999,10 +999,6 @@ static const struct proto_ops inet_dccp_ops = { .recvmsg = sock_common_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, -#endif }; static struct inet_protosw dccp_v4_protosw = { diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 650187d688519c..b50f85a72cd5fc 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -1083,8 +1083,6 @@ static const struct proto_ops inet6_dccp_ops = { .sendpage = sock_no_sendpage, #ifdef CONFIG_COMPAT .compat_ioctl = inet6_compat_ioctl, - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, #endif }; diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c index d93d4531aa9bc5..94ae9662133e30 100644 --- a/net/ieee802154/socket.c +++ b/net/ieee802154/socket.c @@ -423,10 +423,6 @@ static const struct proto_ops ieee802154_raw_ops = { .recvmsg = sock_common_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, -#endif }; /* DGRAM Sockets (802.15.4 dataframes) */ @@ -986,10 +982,6 @@ static const struct proto_ops ieee802154_dgram_ops = { .recvmsg = sock_common_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, -#endif }; /* Create a socket. Initialise the socket, blank the addresses diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index ff141d630bdf09..4307503a6f0b41 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1043,8 +1043,6 @@ const struct proto_ops inet_stream_ops = { .sendpage_locked = tcp_sendpage_locked, .peek_len = tcp_peek_len, #ifdef CONFIG_COMPAT - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, .compat_ioctl = inet_compat_ioctl, #endif .set_rcvlowat = tcp_set_rcvlowat, @@ -1073,8 +1071,6 @@ const struct proto_ops inet_dgram_ops = { .sendpage = inet_sendpage, .set_peek_off = sk_set_peek_off, #ifdef CONFIG_COMPAT - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, .compat_ioctl = inet_compat_ioctl, #endif }; @@ -1105,8 +1101,6 @@ static const struct proto_ops inet_sockraw_ops = { .mmap = sock_no_mmap, .sendpage = inet_sendpage, #ifdef CONFIG_COMPAT - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, .compat_ioctl = inet_compat_ioctl, #endif }; diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index b304b882e0312f..0306509ab06374 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -688,8 +688,6 @@ const struct proto_ops inet6_stream_ops = { .peek_len = tcp_peek_len, #ifdef CONFIG_COMPAT .compat_ioctl = inet6_compat_ioctl, - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, #endif .set_rcvlowat = tcp_set_rcvlowat, }; @@ -717,8 +715,6 @@ const struct proto_ops inet6_dgram_ops = { .set_peek_off = sk_set_peek_off, #ifdef CONFIG_COMPAT .compat_ioctl = inet6_compat_ioctl, - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, #endif }; diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 20576e87a5f7e8..6ab44ec2c369da 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -914,12 +914,8 @@ int compat_ipv6_setsockopt(struct sock *sk, int level, int optname, { int err; - if (level == SOL_IP && sk->sk_type != SOCK_RAW) { - if (udp_prot.compat_setsockopt != NULL) - return udp_prot.compat_setsockopt(sk, level, optname, - optval, optlen); + if (level == SOL_IP && sk->sk_type != SOCK_RAW) return udp_prot.setsockopt(sk, level, optname, optval, optlen); - } if (level != SOL_IPV6) return -ENOPROTOOPT; @@ -1480,12 +1476,8 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname, { int err; - if (level == SOL_IP && sk->sk_type != SOCK_RAW) { - if (udp_prot.compat_getsockopt != NULL) - return udp_prot.compat_getsockopt(sk, level, optname, - optval, optlen); + if (level == SOL_IP && sk->sk_type != SOCK_RAW) return udp_prot.getsockopt(sk, level, optname, optval, optlen); - } if (level != SOL_IPV6) return -ENOPROTOOPT; diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 8ef5a7b30524fd..e23c6b46175870 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -1378,8 +1378,6 @@ const struct proto_ops inet6_sockraw_ops = { .sendpage = sock_no_sendpage, #ifdef CONFIG_COMPAT .compat_ioctl = inet6_compat_ioctl, - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, #endif }; diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c index 955662a6dee754..f8d7412cfb3d37 100644 --- a/net/l2tp/l2tp_ip.c +++ b/net/l2tp/l2tp_ip.c @@ -638,10 +638,6 @@ static const struct proto_ops l2tp_ip_ops = { .recvmsg = sock_common_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, -#endif }; static struct inet_protosw l2tp_ip_protosw = { diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c index 526ed2c24dd5e0..2cdc0b7a7a43c3 100644 --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c @@ -773,8 +773,6 @@ static const struct proto_ops l2tp_ip6_ops = { .sendpage = sock_no_sendpage, #ifdef CONFIG_COMPAT .compat_ioctl = inet6_compat_ioctl, - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, #endif }; diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index dbe43e0cd734e4..f0b0b503c2628d 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2166,10 +2166,6 @@ static const struct proto_ops mptcp_stream_ops = { .recvmsg = inet_recvmsg, .mmap = sock_no_mmap, .sendpage = inet_sendpage, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, -#endif }; static struct inet_protosw mptcp_protosw = { @@ -2222,8 +2218,6 @@ static const struct proto_ops mptcp_v6_stream_ops = { .sendpage = inet_sendpage, #ifdef CONFIG_COMPAT .compat_ioctl = inet6_compat_ioctl, - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, #endif }; diff --git a/net/phonet/socket.c b/net/phonet/socket.c index 76d499f6af9ab3..87c60f83c18061 100644 --- a/net/phonet/socket.c +++ b/net/phonet/socket.c @@ -441,10 +441,6 @@ const struct proto_ops phonet_dgram_ops = { .shutdown = sock_no_shutdown, .setsockopt = sock_no_setsockopt, .getsockopt = sock_no_getsockopt, -#ifdef CONFIG_COMPAT - .compat_setsockopt = sock_no_setsockopt, - .compat_getsockopt = sock_no_getsockopt, -#endif .sendmsg = pn_socket_sendmsg, .recvmsg = sock_common_recvmsg, .mmap = sock_no_mmap, @@ -466,10 +462,6 @@ const struct proto_ops phonet_stream_ops = { .shutdown = sock_no_shutdown, .setsockopt = sock_common_setsockopt, .getsockopt = sock_common_getsockopt, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, -#endif .sendmsg = pn_socket_sendmsg, .recvmsg = sock_common_recvmsg, .mmap = sock_no_mmap, diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index ccfa0ab3e7f481..ebda31b7747d08 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -1033,8 +1033,6 @@ static const struct proto_ops inet6_seqpacket_ops = { .mmap = sock_no_mmap, #ifdef CONFIG_COMPAT .compat_ioctl = inet6_compat_ioctl, - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, #endif }; diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index cde29f3c7fb3c4..8d25cc464efdf3 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -1036,10 +1036,6 @@ static const struct proto_ops inet_seqpacket_ops = { .recvmsg = inet_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_sock_common_setsockopt, - .compat_getsockopt = compat_sock_common_getsockopt, -#endif }; /* Registration with AF_INET family. */ -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2BXfN/lEEV993wAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:28:09 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OAqRNvlEEV9PrgEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:28:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DCBD1A3126; Fri, 17 Jul 2020 08:28:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728263AbgGQG1F (ORCPT + 1 other); Fri, 17 Jul 2020 02:27:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbgGQGYK (ORCPT ); Fri, 17 Jul 2020 02:24:10 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80AA2C08C5DB; Thu, 16 Jul 2020 23:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=XLDR6JRuZhw83glApraWcLsuJCMjSCYHZGg/pZATLIo=; b=Nf98KMypoxCbppeY5fN+Qt92XU hTMrLQeon5LpLZPfzFNQuIZltX3/Ouc9JvkDakKTGfFnnMDOIop7OwHtVySWjh73+HNXAiynH+y2g 9B1DFZb1E3TTo52fImVbl4rdp37dK4moxyFvSiwJU3CcRDbsoyzt+0o26P7ZfPkw7BFcUXeuDFtJ7 e+O5aJ09EWLw/reqbRXN7xLVPsr0Nzj0fkLsVDabnwZOnmAi0rbVK49jM2ZS6k88x8vpCNeiNM3l8 QVDR8jmy11u+t1+NQ+egYZcrN4efUA5Lv9p9Bb28X6ugcwZoX3XuqoN+YatgYwI/NDOEpFI7+bfN/ QdU3/4Sg==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJmZ-00051G-Hx; Fri, 17 Jul 2020 06:23:50 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 01/22] net/atm: remove the atmdev_ops {get,set}sockopt methods Date: Fri, 17 Jul 2020 08:23:10 +0200 Message-Id: <20200717062331.691152-2-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: DCBD1A3126 X-Rspamd-UID: 08437d All implementations of these two methods are dummies that always return -EINVAL. Signed-off-by: Christoph Hellwig --- drivers/atm/eni.c | 17 ----------------- drivers/atm/firestream.c | 2 -- drivers/atm/fore200e.c | 27 --------------------------- drivers/atm/horizon.c | 40 ---------------------------------------- drivers/atm/iphase.c | 16 ---------------- drivers/atm/lanai.c | 2 -- drivers/atm/solos-pci.c | 2 -- drivers/atm/zatm.c | 16 ---------------- include/linux/atmdev.h | 9 --------- net/atm/common.c | 14 ++------------ 10 files changed, 2 insertions(+), 143 deletions(-) diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c index 17d47ad03ab79e..b3d8e00e76716c 100644 --- a/drivers/atm/eni.c +++ b/drivers/atm/eni.c @@ -2027,21 +2027,6 @@ static int eni_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg) return dev->phy->ioctl(dev,cmd,arg); } - -static int eni_getsockopt(struct atm_vcc *vcc,int level,int optname, - void __user *optval,int optlen) -{ - return -EINVAL; -} - - -static int eni_setsockopt(struct atm_vcc *vcc,int level,int optname, - void __user *optval,unsigned int optlen) -{ - return -EINVAL; -} - - static int eni_send(struct atm_vcc *vcc,struct sk_buff *skb) { enum enq_res res; @@ -2215,8 +2200,6 @@ static const struct atmdev_ops ops = { .open = eni_open, .close = eni_close, .ioctl = eni_ioctl, - .getsockopt = eni_getsockopt, - .setsockopt = eni_setsockopt, .send = eni_send, .phy_put = eni_phy_put, .phy_get = eni_phy_get, diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c index cc87004d5e2d62..2ca9ec80273429 100644 --- a/drivers/atm/firestream.c +++ b/drivers/atm/firestream.c @@ -1277,8 +1277,6 @@ static const struct atmdev_ops ops = { .send = fs_send, .owner = THIS_MODULE, /* ioctl: fs_ioctl, */ - /* getsockopt: fs_getsockopt, */ - /* setsockopt: fs_setsockopt, */ /* change_qos: fs_change_qos, */ /* For now implement these internally here... */ diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index f4ad7ce25ae8d1..a81bc49c14acc6 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c @@ -1710,31 +1710,6 @@ fore200e_getstats(struct fore200e* fore200e) return 0; } - -static int -fore200e_getsockopt(struct atm_vcc* vcc, int level, int optname, void __user *optval, int optlen) -{ - /* struct fore200e* fore200e = FORE200E_DEV(vcc->dev); */ - - DPRINTK(2, "getsockopt %d.%d.%d, level = %d, optname = 0x%x, optval = 0x%p, optlen = %d\n", - vcc->itf, vcc->vpi, vcc->vci, level, optname, optval, optlen); - - return -EINVAL; -} - - -static int -fore200e_setsockopt(struct atm_vcc* vcc, int level, int optname, void __user *optval, unsigned int optlen) -{ - /* struct fore200e* fore200e = FORE200E_DEV(vcc->dev); */ - - DPRINTK(2, "setsockopt %d.%d.%d, level = %d, optname = 0x%x, optval = 0x%p, optlen = %d\n", - vcc->itf, vcc->vpi, vcc->vci, level, optname, optval, optlen); - - return -EINVAL; -} - - #if 0 /* currently unused */ static int fore200e_get_oc3(struct fore200e* fore200e, struct oc3_regs* regs) @@ -3026,8 +3001,6 @@ static const struct atmdev_ops fore200e_ops = { .open = fore200e_open, .close = fore200e_close, .ioctl = fore200e_ioctl, - .getsockopt = fore200e_getsockopt, - .setsockopt = fore200e_setsockopt, .send = fore200e_send, .change_qos = fore200e_change_qos, .proc_read = fore200e_proc_read, diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c index e5da51f907a25d..4f2951cbe69c08 100644 --- a/drivers/atm/horizon.c +++ b/drivers/atm/horizon.c @@ -2527,46 +2527,6 @@ static void hrz_close (struct atm_vcc * atm_vcc) { clear_bit(ATM_VF_ADDR,&atm_vcc->flags); } -#if 0 -static int hrz_getsockopt (struct atm_vcc * atm_vcc, int level, int optname, - void *optval, int optlen) { - hrz_dev * dev = HRZ_DEV(atm_vcc->dev); - PRINTD (DBG_FLOW|DBG_VCC, "hrz_getsockopt"); - switch (level) { - case SOL_SOCKET: - switch (optname) { -// case SO_BCTXOPT: -// break; -// case SO_BCRXOPT: -// break; - default: - return -ENOPROTOOPT; - }; - break; - } - return -EINVAL; -} - -static int hrz_setsockopt (struct atm_vcc * atm_vcc, int level, int optname, - void *optval, unsigned int optlen) { - hrz_dev * dev = HRZ_DEV(atm_vcc->dev); - PRINTD (DBG_FLOW|DBG_VCC, "hrz_setsockopt"); - switch (level) { - case SOL_SOCKET: - switch (optname) { -// case SO_BCTXOPT: -// break; -// case SO_BCRXOPT: -// break; - default: - return -ENOPROTOOPT; - }; - break; - } - return -EINVAL; -} -#endif - #if 0 static int hrz_ioctl (struct atm_dev * atm_dev, unsigned int cmd, void *arg) { hrz_dev * dev = HRZ_DEV(atm_dev); diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c index 8c7a996d1f16cf..eef637fd90b323 100644 --- a/drivers/atm/iphase.c +++ b/drivers/atm/iphase.c @@ -2880,20 +2880,6 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg) return 0; } -static int ia_getsockopt(struct atm_vcc *vcc, int level, int optname, - void __user *optval, int optlen) -{ - IF_EVENT(printk(">ia_getsockopt\n");) - return -EINVAL; -} - -static int ia_setsockopt(struct atm_vcc *vcc, int level, int optname, - void __user *optval, unsigned int optlen) -{ - IF_EVENT(printk(">ia_setsockopt\n");) - return -EINVAL; -} - static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) { IADEV *iadev; struct dle *wr_ptr; @@ -3164,8 +3150,6 @@ static const struct atmdev_ops ops = { .open = ia_open, .close = ia_close, .ioctl = ia_ioctl, - .getsockopt = ia_getsockopt, - .setsockopt = ia_setsockopt, .send = ia_send, .phy_put = ia_phy_put, .phy_get = ia_phy_get, diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c index 645a6bc1df8886..986c1313694c66 100644 --- a/drivers/atm/lanai.c +++ b/drivers/atm/lanai.c @@ -2537,8 +2537,6 @@ static const struct atmdev_ops ops = { .dev_close = lanai_dev_close, .open = lanai_open, .close = lanai_close, - .getsockopt = NULL, - .setsockopt = NULL, .send = lanai_send, .phy_put = NULL, .phy_get = NULL, diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c index b7646ae55942e6..94fbc3abe60e6a 100644 --- a/drivers/atm/solos-pci.c +++ b/drivers/atm/solos-pci.c @@ -1179,8 +1179,6 @@ static const struct atmdev_ops fpga_ops = { .open = popen, .close = pclose, .ioctl = NULL, - .getsockopt = NULL, - .setsockopt = NULL, .send = psend, .send_oam = NULL, .phy_put = NULL, diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c index 57f97b95a4531c..2788b985edbe48 100644 --- a/drivers/atm/zatm.c +++ b/drivers/atm/zatm.c @@ -1515,20 +1515,6 @@ static int zatm_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg) } } - -static int zatm_getsockopt(struct atm_vcc *vcc,int level,int optname, - void __user *optval,int optlen) -{ - return -EINVAL; -} - - -static int zatm_setsockopt(struct atm_vcc *vcc,int level,int optname, - void __user *optval,unsigned int optlen) -{ - return -EINVAL; -} - static int zatm_send(struct atm_vcc *vcc,struct sk_buff *skb) { int error; @@ -1582,8 +1568,6 @@ static const struct atmdev_ops ops = { .open = zatm_open, .close = zatm_close, .ioctl = zatm_ioctl, - .getsockopt = zatm_getsockopt, - .setsockopt = zatm_setsockopt, .send = zatm_send, .phy_put = zatm_phy_put, .phy_get = zatm_phy_get, diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h index 8124815eb1218b..5d5ff2203fa220 100644 --- a/include/linux/atmdev.h +++ b/include/linux/atmdev.h @@ -176,11 +176,6 @@ struct atm_dev { #define ATM_OF_IMMED 1 /* Attempt immediate delivery */ #define ATM_OF_INRATE 2 /* Attempt in-rate delivery */ - -/* - * ioctl, getsockopt, and setsockopt are optional and can be set to NULL. - */ - struct atmdev_ops { /* only send is required */ void (*dev_close)(struct atm_dev *dev); int (*open)(struct atm_vcc *vcc); @@ -190,10 +185,6 @@ struct atmdev_ops { /* only send is required */ int (*compat_ioctl)(struct atm_dev *dev,unsigned int cmd, void __user *arg); #endif - int (*getsockopt)(struct atm_vcc *vcc,int level,int optname, - void __user *optval,int optlen); - int (*setsockopt)(struct atm_vcc *vcc,int level,int optname, - void __user *optval,unsigned int optlen); int (*send)(struct atm_vcc *vcc,struct sk_buff *skb); int (*send_oam)(struct atm_vcc *vcc,void *cell,int flags); void (*phy_put)(struct atm_dev *dev,unsigned char value, diff --git a/net/atm/common.c b/net/atm/common.c index 8575f5d52087d3..9b28f1fb3c69c8 100644 --- a/net/atm/common.c +++ b/net/atm/common.c @@ -782,13 +782,8 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, vcc->atm_options &= ~ATM_ATMOPT_CLP; return 0; default: - if (level == SOL_SOCKET) - return -EINVAL; - break; - } - if (!vcc->dev || !vcc->dev->ops->setsockopt) return -EINVAL; - return vcc->dev->ops->setsockopt(vcc, level, optname, optval, optlen); + } } int vcc_getsockopt(struct socket *sock, int level, int optname, @@ -826,13 +821,8 @@ int vcc_getsockopt(struct socket *sock, int level, int optname, return copy_to_user(optval, &pvc, sizeof(pvc)) ? -EFAULT : 0; } default: - if (level == SOL_SOCKET) - return -EINVAL; - break; - } - if (!vcc->dev || !vcc->dev->ops->getsockopt) return -EINVAL; - return vcc->dev->ops->getsockopt(vcc, level, optname, optval, len); + } } int register_atmdevice_notifier(struct notifier_block *nb) -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AKeMJv1EEV/GzQAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:28:13 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id oM2jJf1EEV9BhwEA0J78UA (envelope-from ); Fri, 17 Jul 2020 08:28:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 12D94A3049; Fri, 17 Jul 2020 08:28:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727927AbgGQG1E (ORCPT + 1 other); Fri, 17 Jul 2020 02:27:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726635AbgGQGYK (ORCPT ); Fri, 17 Jul 2020 02:24:10 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B515C08C5CE; Thu, 16 Jul 2020 23:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=51LUd0SvoR+n6SohN5Sodlx7y79ij0S/XRUh9Hk9k/E=; b=nvZ6F7vo++iceOmLkAGswI4yK1 dN/jJBIgk1kmqjzbzRQLYzB00lmetgml707o/ROIFgH8ThKG9kfWAbnxcSbHVegAZ+fkXfzOP2ciD HJ7ZmAMX/Wj3aubE/GXDFzkCnGQQgD7rgHE14n/7A82ro+ME6LubXjKOC1Q0x68iaWMz19OK4jaUb gLt2uTJFiLtDbUibTI+HQZ+r+9Y1iraHIOSW2gdgleYLY1D5OQl3+HF3xddqnxQcenZZ9sCZz7h5T DgKbvNL6/5PgAng3xBJXnBv43b5eNyWINxeRPdgjL16ddqssTf+g3zKmNRQ5v6Hnr0TaedUOHle9b 1jGLhcEQ==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJmO-00050u-Ag; Fri, 17 Jul 2020 06:23:42 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: sockopt cleanups Date: Fri, 17 Jul 2020 08:23:09 +0200 Message-Id: <20200717062331.691152-1-hch@lst.de> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 12D94A3049 X-Rspamd-UID: 8c3a2b Hi Dave, this series cleans up various lose ends in the sockopt code, most importantly removing the compat_{get,set}sockopt infrastructure in favor of just using in_compat_syscall() in the few places that care. Diffstat: arch/arm64/include/asm/unistd32.h | 4 arch/mips/kernel/syscalls/syscall_n32.tbl | 4 arch/mips/kernel/syscalls/syscall_o32.tbl | 4 arch/parisc/kernel/syscalls/syscall.tbl | 4 arch/powerpc/kernel/syscalls/syscall.tbl | 4 arch/s390/kernel/syscalls/syscall.tbl | 4 arch/sparc/kernel/sys32.S | 12 arch/sparc/kernel/syscalls/syscall.tbl | 4 arch/x86/entry/syscall_x32.c | 7 arch/x86/entry/syscalls/syscall_32.tbl | 4 arch/x86/entry/syscalls/syscall_64.tbl | 4 crypto/af_alg.c | 1 crypto/algif_aead.c | 4 crypto/algif_hash.c | 4 crypto/algif_rng.c | 2 crypto/algif_skcipher.c | 4 drivers/atm/eni.c | 17 drivers/atm/firestream.c | 2 drivers/atm/fore200e.c | 27 - drivers/atm/horizon.c | 40 - drivers/atm/iphase.c | 16 drivers/atm/lanai.c | 2 drivers/atm/solos-pci.c | 2 drivers/atm/zatm.c | 16 drivers/isdn/mISDN/socket.c | 2 drivers/net/ppp/pppoe.c | 2 drivers/net/ppp/pptp.c | 2 include/linux/atmdev.h | 9 include/linux/compat.h | 4 include/linux/filter.h | 4 include/linux/net.h | 6 include/linux/netfilter.h | 14 include/linux/netfilter/x_tables.h | 2 include/linux/syscalls.h | 4 include/net/compat.h | 1 include/net/inet_connection_sock.h | 13 include/net/ip.h | 4 include/net/ipv6.h | 4 include/net/sctp/structs.h | 10 include/net/sock.h | 14 include/net/tcp.h | 4 include/uapi/asm-generic/unistd.h | 4 net/appletalk/ddp.c | 2 net/atm/common.c | 14 net/bluetooth/bnep/sock.c | 2 net/bluetooth/cmtp/sock.c | 2 net/bluetooth/hidp/sock.c | 2 net/bridge/netfilter/ebtables.c | 214 +++----- net/caif/caif_socket.c | 2 net/can/bcm.c | 2 net/compat.c | 122 ---- net/core/filter.c | 23 net/core/sock.c | 72 -- net/dccp/dccp.h | 6 net/dccp/ipv4.c | 12 net/dccp/ipv6.c | 14 net/dccp/proto.c | 26 - net/ieee802154/socket.c | 8 net/ipv4/af_inet.c | 6 net/ipv4/inet_connection_sock.c | 28 - net/ipv4/ip_sockglue.c | 541 +++++++++------------ net/ipv4/netfilter/arp_tables.c | 84 --- net/ipv4/netfilter/ip_tables.c | 85 --- net/ipv4/raw.c | 22 net/ipv4/tcp.c | 24 net/ipv4/tcp_ipv4.c | 8 net/ipv4/udp.c | 24 net/ipv4/udp_impl.h | 6 net/ipv4/udplite.c | 4 net/ipv6/af_inet6.c | 4 net/ipv6/ipv6_sockglue.c | 537 +++++++++----------- net/ipv6/netfilter/ip6_tables.c | 86 --- net/ipv6/raw.c | 52 -- net/ipv6/tcp_ipv6.c | 12 net/ipv6/udp.c | 25 net/ipv6/udp_impl.h | 6 net/ipv6/udplite.c | 4 net/key/af_key.c | 2 net/l2tp/l2tp_ip.c | 8 net/l2tp/l2tp_ip6.c | 6 net/mptcp/protocol.c | 6 net/netfilter/nf_sockopt.c | 60 -- net/netfilter/x_tables.c | 9 net/nfc/llcp_sock.c | 2 net/nfc/rawsock.c | 4 net/packet/af_packet.c | 35 - net/phonet/socket.c | 10 net/qrtr/qrtr.c | 2 net/sctp/ipv6.c | 6 net/sctp/protocol.c | 8 net/smc/af_smc.c | 9 net/socket.c | 103 ++- net/unix/af_unix.c | 6 net/vmw_vsock/af_vsock.c | 2 tools/include/uapi/asm-generic/unistd.h | 4 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl | 4 tools/perf/arch/s390/entry/syscalls/syscall.tbl | 4 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl | 4 98 files changed, 786 insertions(+), 1884 deletions(-) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +L2JLphEEV/GzQAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:26:32 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mCpILJhEEV9PrgEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:26:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 196E8A2DE8; Fri, 17 Jul 2020 08:26:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727946AbgGQGZz (ORCPT + 1 other); Fri, 17 Jul 2020 02:25:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727120AbgGQGY2 (ORCPT ); Fri, 17 Jul 2020 02:24:28 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00602C08C5C0; Thu, 16 Jul 2020 23:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=BxwV+i4M9dMYv3ix2RxTH/SE9PWeFAnJ7WfQx79PzsM=; b=HMWPgKy6ASCOQhneUeP8wL4gbq 4sXtZndqI/NnrmJJETGgiAbydLY8svLFNzrDlvnm6W7hUUvsPHg8wGgmcXgsPbtzoIW6clQOI0Jfn uRkBl9hyjrr9dVbVszIoiMSe1wEPXQ1hjs8rQQMuk+jDaVC9hs6iH2RAqFAdZUmz0oYVSXlxFJibQ e9xyctjJ2Lqg3VeF8z1xJGu6ErG8rGosAQdMEQiqOljsCa7NsaoI1Y2JyjZPq0I5YR9Z7bB66obNE 3/fiRv+uTl+7YhsefZujPhBh3+f7u2B6ErHptiTjsMdJE831BSrqgIcbiPvpXImGrQ1D46OPa8W6Q 6GOaXnEw==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJn7-00054Y-ER; Fri, 17 Jul 2020 06:24:18 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 14/22] net/ipv4: factor out MCAST_MSFILTER getsockopt helpers Date: Fri, 17 Jul 2020 08:23:23 +0200 Message-Id: <20200717062331.691152-15-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 196E8A2DE8 X-Rspamd-UID: 6043bf Factor out one helper each for getting the native and compat version of the MCAST_MSFILTER option. Signed-off-by: Christoph Hellwig --- net/ipv4/ip_sockglue.c | 131 ++++++++++++++++++++++------------------- 1 file changed, 70 insertions(+), 61 deletions(-) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 95f4248c6fc5ed..70d32c9476a2e3 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1468,6 +1468,74 @@ static bool getsockopt_needs_rtnl(int optname) return false; } +static int ip_get_mcast_msfilter(struct sock *sk, void __user *optval, + int __user *optlen, int len) +{ + const int size0 = offsetof(struct group_filter, gf_slist); + struct group_filter __user *p = optval; + struct group_filter gsf; + int num; + int err; + + if (len < size0) + return -EINVAL; + if (copy_from_user(&gsf, p, size0)) + return -EFAULT; + + num = gsf.gf_numsrc; + err = ip_mc_gsfget(sk, &gsf, p->gf_slist); + if (err) + return err; + if (gsf.gf_numsrc < num) + num = gsf.gf_numsrc; + if (put_user(GROUP_FILTER_SIZE(num), optlen) || + copy_to_user(p, &gsf, size0)) + return -EFAULT; + return 0; +} + +#ifdef CONFIG_COMPAT +static int compat_ip_get_mcast_msfilter(struct sock *sk, void __user *optval, + int __user *optlen) +{ + const int size0 = offsetof(struct compat_group_filter, gf_slist); + struct compat_group_filter __user *p = optval; + struct compat_group_filter gf32; + struct group_filter gf; + int len, err; + int num; + + if (get_user(len, optlen)) + return -EFAULT; + if (len < size0) + return -EINVAL; + + if (copy_from_user(&gf32, p, size0)) + return -EFAULT; + + gf.gf_interface = gf32.gf_interface; + gf.gf_fmode = gf32.gf_fmode; + num = gf.gf_numsrc = gf32.gf_numsrc; + gf.gf_group = gf32.gf_group; + + rtnl_lock(); + lock_sock(sk); + err = ip_mc_gsfget(sk, &gf, p->gf_slist); + release_sock(sk); + rtnl_unlock(); + if (err) + return err; + if (gf.gf_numsrc < num) + num = gf.gf_numsrc; + len = GROUP_FILTER_SIZE(num) - (sizeof(gf) - sizeof(gf32)); + if (put_user(len, optlen) || + put_user(gf.gf_fmode, &p->gf_fmode) || + put_user(gf.gf_numsrc, &p->gf_numsrc)) + return -EFAULT; + return 0; +} +#endif + static int do_ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen, unsigned int flags) { @@ -1626,31 +1694,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname, goto out; } case MCAST_MSFILTER: - { - struct group_filter __user *p = (void __user *)optval; - struct group_filter gsf; - const int size0 = offsetof(struct group_filter, gf_slist); - int num; - - if (len < size0) { - err = -EINVAL; - goto out; - } - if (copy_from_user(&gsf, p, size0)) { - err = -EFAULT; - goto out; - } - num = gsf.gf_numsrc; - err = ip_mc_gsfget(sk, &gsf, p->gf_slist); - if (err) - goto out; - if (gsf.gf_numsrc < num) - num = gsf.gf_numsrc; - if (put_user(GROUP_FILTER_SIZE(num), optlen) || - copy_to_user(p, &gsf, size0)) - err = -EFAULT; + err = ip_get_mcast_msfilter(sk, optval, optlen, len); goto out; - } case IP_MULTICAST_ALL: val = inet->mc_all; break; @@ -1762,45 +1807,9 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname, int err; if (optname == MCAST_MSFILTER) { - const int size0 = offsetof(struct compat_group_filter, gf_slist); - struct compat_group_filter __user *p = (void __user *)optval; - struct compat_group_filter gf32; - struct group_filter gf; - int ulen, err; - int num; - if (level != SOL_IP) return -EOPNOTSUPP; - - if (get_user(ulen, optlen)) - return -EFAULT; - - if (ulen < size0) - return -EINVAL; - - if (copy_from_user(&gf32, p, size0)) - return -EFAULT; - - gf.gf_interface = gf32.gf_interface; - gf.gf_fmode = gf32.gf_fmode; - num = gf.gf_numsrc = gf32.gf_numsrc; - gf.gf_group = gf32.gf_group; - - rtnl_lock(); - lock_sock(sk); - err = ip_mc_gsfget(sk, &gf, p->gf_slist); - release_sock(sk); - rtnl_unlock(); - if (err) - return err; - if (gf.gf_numsrc < num) - num = gf.gf_numsrc; - ulen = GROUP_FILTER_SIZE(num) - (sizeof(gf) - sizeof(gf32)); - if (put_user(ulen, optlen) || - put_user(gf.gf_fmode, &p->gf_fmode) || - put_user(gf.gf_numsrc, &p->gf_numsrc)) - return -EFAULT; - return 0; + return compat_ip_get_mcast_msfilter(sk, optval, optlen); } err = do_ip_getsockopt(sk, level, optname, optval, optlen, -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CLNXFRFFEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:28:33 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mCIJFBFFEV9PrgEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:28:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 565AEA2429; Fri, 17 Jul 2020 08:28:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728017AbgGQG1Y (ORCPT + 1 other); Fri, 17 Jul 2020 02:27:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbgGQGYK (ORCPT ); Fri, 17 Jul 2020 02:24:10 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4BBBC08C5DC; Thu, 16 Jul 2020 23:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=WmIks9a/wTCxBPMm3mUIfDve+aMKbFTuVLjUhhuXkXc=; b=nof+laVGHZXP6VygkDkDi1sX2z Mk8QWBGUizyyZ08eiROiRxQMquusa4e6/lJj2qbGiP4AoZGX9IibG3S/FG/NaMX99/JgP0ITNi8sa DkuxO72q+UdcdP1AApoBqnu83WPf3wLeVDxzDPJ/LCqW4IShRc4kh6BFVhiiIOC0OKDXnYCmAWNLt 29AF8h6c87CJ0kelQay90KhSZli451wfXXgBVKhGEzQxj3ufGXCo0dlzS4ofOZPMVJVNiI22i0VtT JNJyXNlzEB6kS5PBA5zsLOteduzRmslRru/pM6xkSqZaXbe65M5pwQaq91g7RffKtF+nyl4X994dh dsrkuolQ==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJmm-00051x-2i; Fri, 17 Jul 2020 06:23:59 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 04/22] net: simplify cBPF setsockopt compat handling Date: Fri, 17 Jul 2020 08:23:13 +0200 Message-Id: <20200717062331.691152-5-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 565AEA2429 X-Rspamd-UID: dcc332 Add a helper that copies either a native or compat bpf_fprog from userspace after verifying the length, and remove the compat setsockopt handlers that now aren't required. Signed-off-by: Christoph Hellwig --- include/linux/filter.h | 4 ++-- include/net/compat.h | 1 - net/compat.c | 45 +----------------------------------------- net/core/filter.c | 23 +++++++++++++++++++++ net/core/sock.c | 30 ++++++++++------------------ net/packet/af_packet.c | 33 ++++--------------------------- 6 files changed, 40 insertions(+), 96 deletions(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index 0b0144752d780a..4d049c8e1fbeaa 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -502,13 +502,11 @@ static inline bool insn_is_zext(const struct bpf_insn *insn) offsetof(TYPE, MEMBER); \ }) -#ifdef CONFIG_COMPAT /* A struct sock_filter is architecture independent. */ struct compat_sock_fprog { u16 len; compat_uptr_t filter; /* struct sock_filter * */ }; -#endif struct sock_fprog_kern { u16 len; @@ -1278,4 +1276,6 @@ struct bpf_sockopt_kern { s32 retval; }; +int copy_bpf_fprog_from_user(struct sock_fprog *dst, void __user *src, int len); + #endif /* __LINUX_FILTER_H__ */ diff --git a/include/net/compat.h b/include/net/compat.h index f241666117d88c..745db0d605b62b 100644 --- a/include/net/compat.h +++ b/include/net/compat.h @@ -61,7 +61,6 @@ int __get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg, compat_size_t *len); int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *, struct sockaddr __user **, struct iovec **); -struct sock_fprog __user *get_compat_bpf_fprog(char __user *optval); int put_cmsg_compat(struct msghdr*, int, int, int, void *); int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *, diff --git a/net/compat.c b/net/compat.c index 5e3041a2c37d4d..3e6c2c5ff2609c 100644 --- a/net/compat.c +++ b/net/compat.c @@ -335,49 +335,6 @@ void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm) __scm_destroy(scm); } -/* allocate a 64-bit sock_fprog on the user stack for duration of syscall. */ -struct sock_fprog __user *get_compat_bpf_fprog(char __user *optval) -{ - struct compat_sock_fprog __user *fprog32 = (struct compat_sock_fprog __user *)optval; - struct sock_fprog __user *kfprog = compat_alloc_user_space(sizeof(struct sock_fprog)); - struct compat_sock_fprog f32; - struct sock_fprog f; - - if (copy_from_user(&f32, fprog32, sizeof(*fprog32))) - return NULL; - memset(&f, 0, sizeof(f)); - f.len = f32.len; - f.filter = compat_ptr(f32.filter); - if (copy_to_user(kfprog, &f, sizeof(struct sock_fprog))) - return NULL; - - return kfprog; -} -EXPORT_SYMBOL_GPL(get_compat_bpf_fprog); - -static int do_set_attach_filter(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) -{ - struct sock_fprog __user *kfprog; - - kfprog = get_compat_bpf_fprog(optval); - if (!kfprog) - return -EFAULT; - - return sock_setsockopt(sock, level, optname, (char __user *)kfprog, - sizeof(struct sock_fprog)); -} - -static int compat_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) -{ - if (optname == SO_ATTACH_FILTER || - optname == SO_ATTACH_REUSEPORT_CBPF) - return do_set_attach_filter(sock, level, optname, - optval, optlen); - return sock_setsockopt(sock, level, optname, optval, optlen); -} - static int __compat_sys_setsockopt(int fd, int level, int optname, char __user *optval, unsigned int optlen) { @@ -396,7 +353,7 @@ static int __compat_sys_setsockopt(int fd, int level, int optname, } if (level == SOL_SOCKET) - err = compat_sock_setsockopt(sock, level, + err = sock_setsockopt(sock, level, optname, optval, optlen); else if (sock->ops->compat_setsockopt) err = sock->ops->compat_setsockopt(sock, level, diff --git a/net/core/filter.c b/net/core/filter.c index bdd2382e655d85..2bf6624796d86f 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -77,6 +77,29 @@ #include #include +int copy_bpf_fprog_from_user(struct sock_fprog *dst, void __user *src, int len) +{ + if (in_compat_syscall()) { + struct compat_sock_fprog f32; + + if (len != sizeof(f32)) + return -EINVAL; + if (copy_from_user(&f32, src, sizeof(f32))) + return -EFAULT; + memset(dst, 0, sizeof(*dst)); + dst->len = f32.len; + dst->filter = compat_ptr(f32.filter); + } else { + if (len != sizeof(*dst)) + return -EINVAL; + if (copy_from_user(dst, src, sizeof(*dst))) + return -EFAULT; + } + + return 0; +} +EXPORT_SYMBOL_GPL(copy_bpf_fprog_from_user); + /** * sk_filter_trim_cap - run a packet through a socket filter * @sk: sock associated with &sk_buff diff --git a/net/core/sock.c b/net/core/sock.c index 11d6f77dd56207..e085df79482520 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1059,19 +1059,14 @@ int sock_setsockopt(struct socket *sock, int level, int optname, ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen, optname == SO_SNDTIMEO_OLD); break; - case SO_ATTACH_FILTER: - ret = -EINVAL; - if (optlen == sizeof(struct sock_fprog)) { - struct sock_fprog fprog; - - ret = -EFAULT; - if (copy_from_user(&fprog, optval, sizeof(fprog))) - break; + case SO_ATTACH_FILTER: { + struct sock_fprog fprog; + ret = copy_bpf_fprog_from_user(&fprog, optval, optlen); + if (!ret) ret = sk_attach_filter(&fprog, sk); - } break; - + } case SO_ATTACH_BPF: ret = -EINVAL; if (optlen == sizeof(u32)) { @@ -1085,19 +1080,14 @@ int sock_setsockopt(struct socket *sock, int level, int optname, } break; - case SO_ATTACH_REUSEPORT_CBPF: - ret = -EINVAL; - if (optlen == sizeof(struct sock_fprog)) { - struct sock_fprog fprog; - - ret = -EFAULT; - if (copy_from_user(&fprog, optval, sizeof(fprog))) - break; + case SO_ATTACH_REUSEPORT_CBPF: { + struct sock_fprog fprog; + ret = copy_bpf_fprog_from_user(&fprog, optval, optlen); + if (!ret) ret = sk_reuseport_attach_filter(&fprog, sk); - } break; - + } case SO_ATTACH_REUSEPORT_EBPF: ret = -EINVAL; if (optlen == sizeof(u32)) { diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 781fee93b7d5e3..35aee9e980536d 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1545,10 +1545,10 @@ static int fanout_set_data_cbpf(struct packet_sock *po, char __user *data, if (sock_flag(&po->sk, SOCK_FILTER_LOCKED)) return -EPERM; - if (len != sizeof(fprog)) - return -EINVAL; - if (copy_from_user(&fprog, data, len)) - return -EFAULT; + + ret = copy_bpf_fprog_from_user(&fprog, data, len); + if (ret) + return ret; ret = bpf_prog_create_from_user(&new, &fprog, NULL, false); if (ret) @@ -4040,28 +4040,6 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, return 0; } - -#ifdef CONFIG_COMPAT -static int compat_packet_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) -{ - struct packet_sock *po = pkt_sk(sock->sk); - - if (level != SOL_PACKET) - return -ENOPROTOOPT; - - if (optname == PACKET_FANOUT_DATA && - po->fanout && po->fanout->type == PACKET_FANOUT_CBPF) { - optval = (char __user *)get_compat_bpf_fprog(optval); - if (!optval) - return -EFAULT; - optlen = sizeof(struct sock_fprog); - } - - return packet_setsockopt(sock, level, optname, optval, optlen); -} -#endif - static int packet_notifier(struct notifier_block *this, unsigned long msg, void *ptr) { @@ -4549,9 +4527,6 @@ static const struct proto_ops packet_ops = { .shutdown = sock_no_shutdown, .setsockopt = packet_setsockopt, .getsockopt = packet_getsockopt, -#ifdef CONFIG_COMPAT - .compat_setsockopt = compat_packet_setsockopt, -#endif .sendmsg = packet_sendmsg, .recvmsg = packet_recvmsg, .mmap = packet_mmap, -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MG4OKyJFEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:28:50 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8I8kKSJFEV9PrgEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:28:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 26B0BA1EE4; Fri, 17 Jul 2020 08:28:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726809AbgGQG1X (ORCPT + 1 other); Fri, 17 Jul 2020 02:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726056AbgGQGYK (ORCPT ); Fri, 17 Jul 2020 02:24:10 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FC16C061755; Thu, 16 Jul 2020 23:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=f8sxF6lqgSOtJgTg8maQxOEGY1f8ZNeToFNAXuRekpY=; b=ZEqOtR7YleQvC92xGmKC91Kk8L WTEXAQTf/mF9q9Sr6E1umt3uL5isI+jl33iT6B+NTWGjBQCHmj5vR2cqc1gH3RLw87ZBI2KJCyK4j OsS524C9XTPJYGNJrzCJ0VEVOeyFwAvP/JchrRtBr8ED8bo6wbJFPIQWRaekV0RZYb5LDDC0UrqeR Kus4x/xm2hTJTg5FJATe/2UhIbHHDHlA3jUWlAv1s3QZx4Q0PEQpxDBuCxzrE9R/3L9T6dPjNnTit /CDWgXJrbMMzBa/1e6cziI38mK/P6j9Kyif5s6YoYnAzkO1g0wtsXDHyWgAfdl3/mbxZnLS51qNWF JN+mKrIg==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJmi-00051X-6v; Fri, 17 Jul 2020 06:23:53 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 02/22] net: streamline __sys_setsockopt Date: Fri, 17 Jul 2020 08:23:11 +0200 Message-Id: <20200717062331.691152-3-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 26B0BA1EE4 X-Rspamd-UID: 6c7cff Return early when sockfd_lookup_light fails to reduce a level of indentation for most of the function body. Signed-off-by: Christoph Hellwig --- net/socket.c | 57 +++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/net/socket.c b/net/socket.c index 770503c4ca76c9..49a6daf0293b83 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2107,43 +2107,40 @@ static int __sys_setsockopt(int fd, int level, int optname, return -EINVAL; sock = sockfd_lookup_light(fd, &err, &fput_needed); - if (sock != NULL) { - err = security_socket_setsockopt(sock, level, optname); - if (err) - goto out_put; + if (!sock) + return err; - err = BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock->sk, &level, - &optname, optval, &optlen, - &kernel_optval); + err = security_socket_setsockopt(sock, level, optname); + if (err) + goto out_put; - if (err < 0) { - goto out_put; - } else if (err > 0) { - err = 0; - goto out_put; - } + err = BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock->sk, &level, &optname, + optval, &optlen, &kernel_optval); + if (err < 0) + goto out_put; + if (err > 0) { + err = 0; + goto out_put; + } - if (kernel_optval) { - set_fs(KERNEL_DS); - optval = (char __user __force *)kernel_optval; - } + if (kernel_optval) { + set_fs(KERNEL_DS); + optval = (char __user __force *)kernel_optval; + } - if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) - err = - sock_setsockopt(sock, level, optname, optval, + if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) + err = sock_setsockopt(sock, level, optname, optval, optlen); + else + err = sock->ops->setsockopt(sock, level, optname, optval, optlen); - else - err = - sock->ops->setsockopt(sock, level, optname, optval, - optlen); - if (kernel_optval) { - set_fs(oldfs); - kfree(kernel_optval); - } -out_put: - fput_light(sock->file, fput_needed); + if (kernel_optval) { + set_fs(oldfs); + kfree(kernel_optval); } + +out_put: + fput_light(sock->file, fput_needed); return err; } -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mELyD5pKEV993wAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:52:10 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SKEhDppKEV9iVAAAgupzMw (envelope-from ); Fri, 17 Jul 2020 08:52:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 88FEC52B89; Fri, 17 Jul 2020 08:52:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727891AbgGQGv6 convert rfc822-to-8bit (ORCPT + 1 other); Fri, 17 Jul 2020 02:51:58 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:40187 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbgGQGv5 (ORCPT ); Fri, 17 Jul 2020 02:51:57 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id E391ECED0F; Fri, 17 Jul 2020 09:01:54 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [RFC PATCH v1 1/2] Bluetooth: queue ACL packets if no handle is found From: Marcel Holtmann In-Reply-To: Date: Fri, 17 Jul 2020 08:51:55 +0200 Cc: Archie Pusaka , linux-bluetooth , chromeos-bluetooth-upstreaming , Abhishek Pandit-Subedi , "David S. Miller" , Jakub Kicinski , Johan Hedberg , kernel list , netdev Content-Transfer-Encoding: 8BIT Message-Id: References: <20200627105437.453053-1-apusaka@google.com> <20200627185320.RFC.v1.1.Icea550bb064a24b89f2217cf19e35b4480a31afd@changeid> <91CFE951-262A-4E83-8550-25445AE84B5A@holtmann.org> <7BBB55E0-FBD9-40C0-80D9-D5E7FC9F80D2@holtmann.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 12 X-Rspamd-Score: 1.93 / 15.00 / 200.00 X-Rspamd-Queue-Id: 88FEC52B89 X-Rspamd-UID: 83b7b7 Hi Alain, > >>> There is a possibility that an ACL packet is received before we > >>> receive the HCI connect event for the corresponding handle. If this > >>> happens, we discard the ACL packet. > >>> > >>> Rather than just ignoring them, this patch provides a queue for > >>> incoming ACL packet without a handle. The queue is processed when > >>> receiving a HCI connection event. If 2 seconds elapsed without > >>> receiving the HCI connection event, assume something bad happened > >>> and discard the queued packet. > >>> > >>> Signed-off-by: Archie Pusaka > >>> Reviewed-by: Abhishek Pandit-Subedi > >> > >> so two things up front. I want to hide this behind a HCI_QUIRK_OUT_OF_ORDER_ACL that a transport driver has to set first. Frankly if this kind of out-of-order happens on UART or SDIO transports, then something is obviously going wrong. I have no plan to fix up after a fully serialized transport. > >> > >> Secondly, if a transport sets HCI_QUIRK_OUT_OF_ORDER_ACL, then I want this off by default. You can enable it via an experimental setting. The reason here is that we have to make it really hard and fail as often as possible so that hardware manufactures and spec writers realize that something is fundamentally broken here. > I don't have any objection to making this explicit enable to non serialized transports. However, I do wonder what the intention is around making this off by default. We already know there is a race condition between the interupt and bulk endpoints over USB, so this can and does happen. Hardware manufaturers can't relly do much about this other than trying to pull the interupt endpoint more often, but that's only a workaround, it can't avoid it all together. > > IMO, this seems like a legitimate fix at the host level and I don't see any obvious benefits to hide this fix under an experimental feature and make it more difficult for the customers and system integrators to discover. the problem is that this is not a fix. It is papering over a hole and at best a workaround with both eyes closed and hoping for the best. I am not looking forward for the first security researcher to figure out that they have a chance to inject an unencrypted packet since we are waiting 2 seconds for the USB transport to get its act together. In addition, I think that Luiz attempt to align with the poll intervals inside the USB transport directly is a cleaner and more self-contained approach. It also reduces the window of opportunity for any attacker since we actually align the USB transport specific intervals with each other. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uN9pNWlMEV993wAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:59:53 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wCHMM2lMEV/3QAEAlp8NpQ (envelope-from ); Fri, 17 Jul 2020 08:59:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D0998A26DE; Fri, 17 Jul 2020 08:59:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727989AbgGQG7q convert rfc822-to-8bit (ORCPT + 1 other); Fri, 17 Jul 2020 02:59:46 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:45345 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727901AbgGQG7q (ORCPT ); Fri, 17 Jul 2020 02:59:46 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 81F2ECED0F; Fri, 17 Jul 2020 09:09:43 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH RFC] bluetooth: add support for some old headsets From: Marcel Holtmann In-Reply-To: Date: Fri, 17 Jul 2020 08:59:44 +0200 Cc: Johan Hedberg , Bluetooth Kernel Mailing List , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <848144D3-85F9-47F8-8CDA-02457FA7530F@holtmann.org> References: <6f461412-a6c0-aa53-5e74-394e278ee9b1@omprussia.ru> <1834765D-52E6-45B8-9923-778C9182CFA9@holtmann.org> To: Sergey Shtylyov X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 5 X-Rspamd-Score: 0.87 / 15.00 / 200.00 X-Rspamd-Queue-Id: D0998A26DE X-Rspamd-UID: 6f2a02 Hi Sergey, >>> The MediaTek Bluetooth platform (MT6630 etc.) has a peculiar implementation >>> for the eSCO/SCO connection via BT/EDR: the host controller returns error >>> code 0x20 (LMP feature not supported) for HCI_Setup_Synchronous_Connection >>> (0x0028) command without actually trying to setup connection with a remote >>> device in case such device (like Digma BT-14 headset) didn't advertise its >>> supported features. Even though this doesn't break compatibility with the >>> Bluetooth standard it breaks the compatibility with the Hands-Free Profile >>> (HFP). >>> >>> This patch returns the compatibility with the HFP profile and actually >>> tries to check all available connection parameters despite of the specific >>> MediaTek implementation. Without it one was unable to establish eSCO/SCO >>> connection with some headsets. >> >> please include the parts of btmon output that show this issue. > > Funny, I had removed that part from the original patch. Here's that log: > > < HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17 #1 [hci0] 6.705320 > Handle: 50 > Transmit bandwidth: 8000 > Receive bandwidth: 8000 > Max latency: 10 > Setting: 0x0060 > Input Coding: Linear > Input Data Format: 2's complement > Input Sample Size: 16-bit > of bits padding at MSB: 0 > Air Coding Format: CVSD > Retransmission effort: Optimize for power consumption (0x01) > Packet type: 0x0380 > 3-EV3 may not be used > 2-EV5 may not be used > 3-EV5 may not be used >> HCI Event: Command Status (0x0f) plen 4 #2 [hci0] 6.719598 > Setup Synchronous Connection (0x01|0x0028) ncmd 1 > Status: Unsupported LMP Parameter Value / Unsupported LL Parameter Value (0x20) I double check with the specification and it is not precise that errors should be reported via sync conn complete events. My assumption would be that your headset only supports SCO and thus the controller realizes that eSCO request can not be completed anyway. So the controller opts for quickest path to get out of this. > >>> Based on the patch by Ildar Kamaletdinov . >>> >>> Signed-off-by: Sergey Shtylyov >>> >>> --- >>> This patch is against the 'bluetooth-next.git' repo. >>> >>> net/bluetooth/hci_event.c | 8 ++++++++ >>> 1 file changed, 8 insertions(+) >>> >>> Index: bluetooth-next/net/bluetooth/hci_event.c >>> =================================================================== >>> --- bluetooth-next.orig/net/bluetooth/hci_event.c >>> +++ bluetooth-next/net/bluetooth/hci_event.c >>> @@ -2187,6 +2187,13 @@ static void hci_cs_setup_sync_conn(struc >>> if (acl) { >>> sco = acl->link; >>> if (sco) { >>> + if (status == 0x20 && /* Unsupported LMP Parameter value */ >>> + sco->out) { >>> + sco->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | >>> + (hdev->esco_type & EDR_ESCO_MASK); >>> + if (hci_setup_sync(sco, sco->link->handle)) >>> + goto unlock; >>> + } >>> sco->state = BT_CLOSED; >> >> since this is the command status event, I doubt that sco->out check is needed. > > Can't comment oin this, my BT fu is too weak... It is the case. Command status is only local to command we issued and thus in this case it is the connection creation attempt from our side. Meaning it is always outgoing. Regards Marcel Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wFtYIhhbEV8+dAEAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 10:02:32 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id GPy2IBhbEV8NPwAAlScrYA (envelope-from ); Fri, 17 Jul 2020 10:02:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6DAAD530F5; Fri, 17 Jul 2020 10:02:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728256AbgGQICP (ORCPT + 1 other); Fri, 17 Jul 2020 04:02:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728234AbgGQICO (ORCPT ); Fri, 17 Jul 2020 04:02:14 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FA2DC061755 for ; Fri, 17 Jul 2020 01:02:13 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jwLJO-0000MA-Fl; Fri, 17 Jul 2020 10:01:42 +0200 Received: from [IPv6:2a03:f580:87bc:d400:6150:3c6e:283b:b7f7] (unknown [IPv6:2a03:f580:87bc:d400:6150:3c6e:283b:b7f7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mkl@blackshift.org", Issuer "StartCom Class 1 Client CA" (not verified)) (Authenticated sender: mkl@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id AE488532E22; Fri, 17 Jul 2020 08:01:30 +0000 (UTC) Subject: Re: [PATCH 22/22] net: make ->{get,set}sockopt in proto_ops optional To: Christoph Hellwig , "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org References: <20200717062331.691152-1-hch@lst.de> <20200717062331.691152-23-hch@lst.de> From: Marc Kleine-Budde Autocrypt: addr=mkl@pengutronix.de; prefer-encrypt=mutual; keydata= mQINBFFVq30BEACtnSvtXHoeHJxG6nRULcvlkW6RuNwHKmrqoksispp43X8+nwqIFYgb8UaX zu8T6kZP2wEIpM9RjEL3jdBjZNCsjSS6x1qzpc2+2ivjdiJsqeaagIgvy2JWy7vUa4/PyGfx QyUeXOxdj59DvLwAx8I6hOgeHx2X/ntKAMUxwawYfPZpP3gwTNKc27dJWSomOLgp+gbmOmgc 6U5KwhAxPTEb3CsT5RicsC+uQQFumdl5I6XS+pbeXZndXwnj5t84M+HEj7RN6bUfV2WZO/AB Xt5+qFkC/AVUcj/dcHvZwQJlGeZxoi4veCoOT2MYqfR0ax1MmN+LVRvKm29oSyD4Ts/97cbs XsZDRxnEG3z/7Winiv0ZanclA7v7CQwrzsbpCv+oj+zokGuKasofzKdpywkjAfSE1zTyF+8K nxBAmzwEqeQ3iKqBc3AcCseqSPX53mPqmwvNVS2GqBpnOfY7Mxr1AEmxdEcRYbhG6Xdn+ACq Dq0Db3A++3PhMSaOu125uIAIwMXRJIzCXYSqXo8NIeo9tobk0C/9w3fUfMTrBDtSviLHqlp8 eQEP8+TDSmRP/CwmFHv36jd+XGmBHzW5I7qw0OORRwNFYBeEuiOIgxAfjjbLGHh9SRwEqXAL kw+WVTwh0MN1k7I9/CDVlGvc3yIKS0sA+wudYiselXzgLuP5cQARAQABtCZNYXJjIEtsZWlu ZS1CdWRkZSA8bWtsQHBlbmd1dHJvbml4LmRlPokCVAQTAQoAPgIbAwIeAQIXgAULCQgHAwUV CgkICwUWAgMBABYhBMFAC6CzmJ5vvH1bXCte4hHFiupUBQJcUsSbBQkM366zAAoJECte4hHF iupUgkAP/2RdxKPZ3GMqag33jKwKAbn/fRqAFWqUH9TCsRH3h6+/uEPnZdzhkL4a9p/6OeJn Z6NXqgsyRAOTZsSFcwlfxLNHVxBWm8pMwrBecdt4lzrjSt/3ws2GqxPsmza1Gs61lEdYvLST Ix2vPbB4FAfE0kizKAjRZzlwOyuHOr2ilujDsKTpFtd8lV1nBNNn6HBIBR5ShvJnwyUdzuby tOsSt7qJEvF1x3y49bHCy3uy+MmYuoEyG6zo9udUzhVsKe3hHYC2kfB16ZOBjFC3lH2U5An+ yQYIIPZrSWXUeKjeMaKGvbg6W9Oi4XEtrwpzUGhbewxCZZCIrzAH2hz0dUhacxB201Y/faY6 BdTS75SPs+zjTYo8yE9Y9eG7x/lB60nQjJiZVNvZ88QDfVuLl/heuIq+fyNajBbqbtBT5CWf mOP4Dh4xjm3Vwlz8imWW/drEVJZJrPYqv0HdPbY8jVMpqoe5jDloyVn3prfLdXSbKPexlJaW 5tnPd4lj8rqOFShRnLFCibpeHWIumqrIqIkiRA9kFW3XMgtU6JkIrQzhJb6Tc6mZg2wuYW0d Wo2qvdziMgPkMFiWJpsxM9xPk9BBVwR+uojNq5LzdCsXQ2seG0dhaOTaaIDWVS8U/V8Nqjrl 6bGG2quo5YzJuXKjtKjZ4R6k762pHJ3tnzI/jnlc1sXz Message-ID: <5f88e695-d787-2191-feef-883a067788ed@pengutronix.de> Date: Fri, 17 Jul 2020 10:01:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200717062331.691152-23-hch@lst.de> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-bluetooth@vger.kernel.org Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6DAAD530F5 X-Rspamd-UID: b7b851 On 7/17/20 8:23 AM, Christoph Hellwig wrote: > Just check for a NULL method instead of wiring up > sock_no_{get,set}sockopt. > > Signed-off-by: Christoph Hellwig > --- > net/can/bcm.c | 2 -- > net/core/sock.c | 14 -------------- For the CAN part: Acked-by: Marc Kleine-Budde Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AJPvHeJsEV9W/QEAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 11:18:26 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +C6BG+JsEV/gggAADc0bRg (envelope-from ); Fri, 17 Jul 2020 11:18:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=tessares-net.20150623.gappssmtp.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D4A2EA1EE4; Fri, 17 Jul 2020 11:18:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726446AbgGQJST (ORCPT + 1 other); Fri, 17 Jul 2020 05:18:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgGQJSL (ORCPT ); Fri, 17 Jul 2020 05:18:11 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BABFC08C5DB for ; Fri, 17 Jul 2020 02:18:11 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id a21so10004713ejj.10 for ; Fri, 17 Jul 2020 02:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares-net.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ABtoKcunWta1zPd9OAU4HivGakSrvH6t7PoGrVg1IHw=; b=xR7/TE9+zWjcsvx6d03jd1AgLl1RxCF+57iDGUw8QqO8NNJiU5y/1PDhMHyK6SBPD0 Tu9kE2ltrVcgIGDsEFYeGOdvGGs9gXhWrY0fvfmRtJuRWzhuLiSsJxij8VwijPfHjTPS 3aRzO2LOdNynO+M1Cxqg8LEaNT7+cWaMS9ZleuZy42uIKF7zbE+VVsfyNZHqDLg2WCO5 2IhHaXOEiidwv/4zssU9rGm6ibTKTyOzBFUfh4ZlLc65xFj4ZNu5VWofuJadgyUIYj5C Y93p7sEtG5rh/7aWXf9IEREZyDETtvRRffJXB7kNBwNCJiHJc9kale3U3Oqjmxgbkhyq rtqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ABtoKcunWta1zPd9OAU4HivGakSrvH6t7PoGrVg1IHw=; b=nobI79ooZ3eePO2Xp0mFxE/TOrCtTObZZbAEDjFaNFjdVFFe+PU+6hZ91P5VETwcRK Vff5JB75Mj6/EtG4SrfhzkWxf76/gbSu4bF/McZJ1bHjpUjmcaND8FfLIcZPuAGbn5ix 0N74u82lZwa5ijrhNrcKkXkmkH3ulE116WsMX5cfQTKz0HrajTXVEBSn7O/df4TxSLJ6 96F+jyYSd8Fy1YuBbbpGKYt7ncLWYi+FAu1NBo+oOl2vqaTu24xxqc7BzEI6JwAr+f3p 1nUUARcR/0cqVfoEQv+assa/9HAh8AhxloLlQi3jupFjQVuT+ZnQTTB+hHAj1ki1t562 sX/w== X-Gm-Message-State: AOAM533aqoiByuz5aszaXDWkk46koO/4srzD0o5H8UIFg//KqgDZ9GeQ S0fQGIA5x7swvTDcTfABta1rQg== X-Google-Smtp-Source: ABdhPJwKJni/XUuyRKR8S/sAchcIII3C/3Gdc/GCPUNVX6T8sPkuUFzqwgJFnhzYtCojkw18DlkE7Q== X-Received: by 2002:a17:907:426c:: with SMTP id nx20mr7604495ejb.548.1594977490002; Fri, 17 Jul 2020 02:18:10 -0700 (PDT) Received: from tsr-lap-08.nix.tessares.net ([81.246.10.41]) by smtp.gmail.com with ESMTPSA id p4sm7541372eji.123.2020.07.17.02.18.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Jul 2020 02:18:08 -0700 (PDT) Subject: Re: [MPTCP] [PATCH 05/22] net: remove compat_sock_common_{get,set}sockopt To: Christoph Hellwig , "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org References: <20200717062331.691152-1-hch@lst.de> <20200717062331.691152-6-hch@lst.de> From: Matthieu Baerts Message-ID: <203f5f41-1de0-575e-864b-53a9412d97f6@tessares.net> Date: Fri, 17 Jul 2020 11:18:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200717062331.691152-6-hch@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.98 / 15.00 / 200.00 X-Rspamd-Queue-Id: D4A2EA1EE4 X-Rspamd-UID: ed53c1 Hi Christoph, On 17/07/2020 08:23, Christoph Hellwig wrote: > Add the compat handling to sock_common_{get,set}sockopt instead, > keyed of in_compat_syscall(). This allow to remove the now unused > ->compat_{get,set}sockopt methods from struct proto_ops. > > Signed-off-by: Christoph Hellwig > --- > include/linux/net.h | 6 ------ > include/net/sock.h | 4 ---- > net/core/sock.c | 30 ++++++------------------------ > net/mptcp/protocol.c | 6 ------ Thank you for looking at that! For MPTCP-related code: Acked-by: Matthieu Baerts Cheers, Matt -- Tessares | Belgium | Hybrid Access Solutions www.tessares.net Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KAPgIfBwEV+DlQAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 11:35:44 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id MM5AIPBwEV/enAAADc0bRg (envelope-from ); Fri, 17 Jul 2020 11:35:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E39EF52618; Fri, 17 Jul 2020 11:35:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726563AbgGQJfX (ORCPT + 1 other); Fri, 17 Jul 2020 05:35:23 -0400 Received: from proxima.lasnet.de ([78.47.171.185]:53924 "EHLO proxima.lasnet.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbgGQJfX (ORCPT ); Fri, 17 Jul 2020 05:35:23 -0400 X-Greylist: delayed 522 seconds by postgrey-1.27 at vger.kernel.org; Fri, 17 Jul 2020 05:35:19 EDT Received: from localhost.localdomain (p200300e9d737160bc31b0c5d63306033.dip0.t-ipconnect.de [IPv6:2003:e9:d737:160b:c31b:c5d:6330:6033]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: stefan@datenfreihafen.org) by proxima.lasnet.de (Postfix) with ESMTPSA id B77EDC0617; Fri, 17 Jul 2020 11:26:35 +0200 (CEST) Subject: Re: [PATCH 05/22] net: remove compat_sock_common_{get,set}sockopt To: Christoph Hellwig , "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org References: <20200717062331.691152-1-hch@lst.de> <20200717062331.691152-6-hch@lst.de> From: Stefan Schmidt Message-ID: <52d031f9-70c2-89c1-941f-c8187a6a2b68@datenfreihafen.org> Date: Fri, 17 Jul 2020 11:26:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200717062331.691152-6-hch@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.55 / 15.00 / 200.00 X-Rspamd-Queue-Id: E39EF52618 X-Rspamd-UID: 664acb Hello. On 17.07.20 08:23, Christoph Hellwig wrote: > Add the compat handling to sock_common_{get,set}sockopt instead, > keyed of in_compat_syscall(). This allow to remove the now unused > ->compat_{get,set}sockopt methods from struct proto_ops. > > Signed-off-by: Christoph Hellwig > --- > include/linux/net.h | 6 ------ > include/net/sock.h | 4 ---- > net/core/sock.c | 30 ++++++------------------------ > net/dccp/ipv4.c | 4 ---- > net/dccp/ipv6.c | 2 -- > net/ieee802154/socket.c | 8 -------- > net/ipv4/af_inet.c | 6 ------ > net/ipv6/af_inet6.c | 4 ---- > net/ipv6/ipv6_sockglue.c | 12 ++---------- > net/ipv6/raw.c | 2 -- > net/l2tp/l2tp_ip.c | 4 ---- > net/l2tp/l2tp_ip6.c | 2 -- > net/mptcp/protocol.c | 6 ------ > net/phonet/socket.c | 8 -------- > net/sctp/ipv6.c | 2 -- > net/sctp/protocol.c | 4 ---- > 16 files changed, 8 insertions(+), 96 deletions(-) > > diff --git a/include/linux/net.h b/include/linux/net.h > index 016a9c5faa3479..858ff1d981540d 100644 > --- a/include/linux/net.h > +++ b/include/linux/net.h > @@ -165,12 +165,6 @@ struct proto_ops { > int optname, char __user *optval, unsigned int optlen); > int (*getsockopt)(struct socket *sock, int level, > int optname, char __user *optval, int __user *optlen); > -#ifdef CONFIG_COMPAT > - int (*compat_setsockopt)(struct socket *sock, int level, > - int optname, char __user *optval, unsigned int optlen); > - int (*compat_getsockopt)(struct socket *sock, int level, > - int optname, char __user *optval, int __user *optlen); > -#endif > void (*show_fdinfo)(struct seq_file *m, struct socket *sock); > int (*sendmsg) (struct socket *sock, struct msghdr *m, > size_t total_len); > diff --git a/include/net/sock.h b/include/net/sock.h > index 4bf8841651486d..1fd7cf5fc7516c 100644 > --- a/include/net/sock.h > +++ b/include/net/sock.h > @@ -1744,10 +1744,6 @@ int sock_common_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, > int flags); > int sock_common_setsockopt(struct socket *sock, int level, int optname, > char __user *optval, unsigned int optlen); > -int compat_sock_common_getsockopt(struct socket *sock, int level, > - int optname, char __user *optval, int __user *optlen); > -int compat_sock_common_setsockopt(struct socket *sock, int level, > - int optname, char __user *optval, unsigned int optlen); > > void sk_common_release(struct sock *sk); > > diff --git a/net/core/sock.c b/net/core/sock.c > index e085df79482520..018404d1762682 100644 > --- a/net/core/sock.c > +++ b/net/core/sock.c > @@ -3199,23 +3199,14 @@ int sock_common_getsockopt(struct socket *sock, int level, int optname, > { > struct sock *sk = sock->sk; > > - return sk->sk_prot->getsockopt(sk, level, optname, optval, optlen); > -} > -EXPORT_SYMBOL(sock_common_getsockopt); > - > #ifdef CONFIG_COMPAT > -int compat_sock_common_getsockopt(struct socket *sock, int level, int optname, > - char __user *optval, int __user *optlen) > -{ > - struct sock *sk = sock->sk; > - > - if (sk->sk_prot->compat_getsockopt != NULL) > + if (in_compat_syscal() && sk->sk_prot->compat_getsockopt) > return sk->sk_prot->compat_getsockopt(sk, level, optname, > optval, optlen); > +#endif > return sk->sk_prot->getsockopt(sk, level, optname, optval, optlen); > } > -EXPORT_SYMBOL(compat_sock_common_getsockopt); > -#endif > +EXPORT_SYMBOL(sock_common_getsockopt); > > int sock_common_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, > int flags) > @@ -3240,23 +3231,14 @@ int sock_common_setsockopt(struct socket *sock, int level, int optname, > { > struct sock *sk = sock->sk; > > - return sk->sk_prot->setsockopt(sk, level, optname, optval, optlen); > -} > -EXPORT_SYMBOL(sock_common_setsockopt); > - > #ifdef CONFIG_COMPAT > -int compat_sock_common_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen) > -{ > - struct sock *sk = sock->sk; > - > - if (sk->sk_prot->compat_setsockopt != NULL) > + if (in_compat_syscall() && sk->sk_prot->compat_setsockopt) > return sk->sk_prot->compat_setsockopt(sk, level, optname, > optval, optlen); > +#endif > return sk->sk_prot->setsockopt(sk, level, optname, optval, optlen); > } > -EXPORT_SYMBOL(compat_sock_common_setsockopt); > -#endif > +EXPORT_SYMBOL(sock_common_setsockopt); > > void sk_common_release(struct sock *sk) > { > diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c > index a7e989919c5307..316cc5ac0da72b 100644 > --- a/net/dccp/ipv4.c > +++ b/net/dccp/ipv4.c > @@ -999,10 +999,6 @@ static const struct proto_ops inet_dccp_ops = { > .recvmsg = sock_common_recvmsg, > .mmap = sock_no_mmap, > .sendpage = sock_no_sendpage, > -#ifdef CONFIG_COMPAT > - .compat_setsockopt = compat_sock_common_setsockopt, > - .compat_getsockopt = compat_sock_common_getsockopt, > -#endif > }; > > static struct inet_protosw dccp_v4_protosw = { > diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c > index 650187d688519c..b50f85a72cd5fc 100644 > --- a/net/dccp/ipv6.c > +++ b/net/dccp/ipv6.c > @@ -1083,8 +1083,6 @@ static const struct proto_ops inet6_dccp_ops = { > .sendpage = sock_no_sendpage, > #ifdef CONFIG_COMPAT > .compat_ioctl = inet6_compat_ioctl, > - .compat_setsockopt = compat_sock_common_setsockopt, > - .compat_getsockopt = compat_sock_common_getsockopt, > #endif > }; > > diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c > index d93d4531aa9bc5..94ae9662133e30 100644 > --- a/net/ieee802154/socket.c > +++ b/net/ieee802154/socket.c > @@ -423,10 +423,6 @@ static const struct proto_ops ieee802154_raw_ops = { > .recvmsg = sock_common_recvmsg, > .mmap = sock_no_mmap, > .sendpage = sock_no_sendpage, > -#ifdef CONFIG_COMPAT > - .compat_setsockopt = compat_sock_common_setsockopt, > - .compat_getsockopt = compat_sock_common_getsockopt, > -#endif > }; > > /* DGRAM Sockets (802.15.4 dataframes) */ > @@ -986,10 +982,6 @@ static const struct proto_ops ieee802154_dgram_ops = { > .recvmsg = sock_common_recvmsg, > .mmap = sock_no_mmap, > .sendpage = sock_no_sendpage, > -#ifdef CONFIG_COMPAT > - .compat_setsockopt = compat_sock_common_setsockopt, > - .compat_getsockopt = compat_sock_common_getsockopt, > -#endif For the ieee802154 part: Acked-by: Stefan Schmidt regards Stefan Schmidt Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6Nf6CKNEEV993wAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:26:43 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aNg6B6NEEV80BwEAlp8NpQ (envelope-from ); Fri, 17 Jul 2020 08:26:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9A0C9A2765; Fri, 17 Jul 2020 08:26:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727094AbgGQG0G (ORCPT + 1 other); Fri, 17 Jul 2020 02:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbgGQGY1 (ORCPT ); Fri, 17 Jul 2020 02:24:27 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53601C061755; Thu, 16 Jul 2020 23:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ke6IxwSs5p7KD2PfPxkYUwJA5rYh272J6EZhbIQy4kY=; b=MxaBf8IdG4oPd47UVm2tZXLlpY Lj0kUlQbB1ZRjYfxYtQJbE06uDcQv69Ai/DLwk1bpkRfuf/Jq2/MAFkOdGdxJ7JwVqrTQ6cHzbbES UpuJYyT7FeWfdFe32t9OAbw443Y8bublO9rfbU+CPORFb/g2qc+AjGx3JIwnE+HGZpVuzkFNCu/TT BWIKQP4tO2HncJuy0u9oLDaTS42Z+rtg9RxsA4/Po+C8o5jRFn7lUt0oFhBTgcPr6Le1Bsj9sY6G9 kTZ7bSAsM4ou68NnoUCrRR1I/mOtGV8h6aLpoiA3nDRrdKTCaI6dqv7MW45Lkr00tnDxSDW82t9zb q7aZii2Q==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJn6-00054N-1B; Fri, 17 Jul 2020 06:24:16 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 13/22] netfilter: split nf_sockopt Date: Fri, 17 Jul 2020 08:23:22 +0200 Message-Id: <20200717062331.691152-14-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9A0C9A2765 X-Rspamd-UID: 9e6f27 Split nf_sockopt into a getsockopt and setsockopt side as they share very little code. Signed-off-by: Christoph Hellwig --- net/netfilter/nf_sockopt.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c index 02870993d335c9..90469b1f628a8e 100644 --- a/net/netfilter/nf_sockopt.c +++ b/net/netfilter/nf_sockopt.c @@ -89,36 +89,32 @@ static struct nf_sockopt_ops *nf_sockopt_find(struct sock *sk, u_int8_t pf, return ops; } -/* Call get/setsockopt() */ -static int nf_sockopt(struct sock *sk, u_int8_t pf, int val, - char __user *opt, int *len, int get) +int nf_setsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt, + unsigned int len) { struct nf_sockopt_ops *ops; int ret; - ops = nf_sockopt_find(sk, pf, val, get); + ops = nf_sockopt_find(sk, pf, val, 0); if (IS_ERR(ops)) return PTR_ERR(ops); - - if (get) - ret = ops->get(sk, val, opt, len); - else - ret = ops->set(sk, val, opt, *len); - + ret = ops->set(sk, val, opt, len); module_put(ops->owner); return ret; } - -int nf_setsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt, - unsigned int len) -{ - return nf_sockopt(sk, pf, val, opt, &len, 0); -} EXPORT_SYMBOL(nf_setsockopt); int nf_getsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt, int *len) { - return nf_sockopt(sk, pf, val, opt, len, 1); + struct nf_sockopt_ops *ops; + int ret; + + ops = nf_sockopt_find(sk, pf, val, 1); + if (IS_ERR(ops)) + return PTR_ERR(ops); + ret = ops->get(sk, val, opt, len); + module_put(ops->owner); + return ret; } EXPORT_SYMBOL(nf_getsockopt); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sI+8NaZEEV/GzQAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:26:46 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iDkPNKZEEV930QEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:26:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4A914A1B5C; Fri, 17 Jul 2020 08:26:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727067AbgGQGY1 (ORCPT + 1 other); Fri, 17 Jul 2020 02:24:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727065AbgGQGYZ (ORCPT ); Fri, 17 Jul 2020 02:24:25 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF9F7C08C5C0; Thu, 16 Jul 2020 23:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=milvAVOJM4QLrRIHrecFW2GQRin+zd5F1vYyEysY7aY=; b=cLAkMx61vS6bwmd5Zd6uLyOfjO FgVzMLW/0vRlJLKn+atJQKqBiPdF+U5ARr5iGTBorAQzgeqPKzY3EOx2DDiJuc7ouc222OqWynkYB nlUfxQqT+4SONem/13J3C/tjq+V1QbpfmaLCfbOge+hsPTsTNjjZ2uiesF3elNxm9AeTZUBLIT4Oy HHHI4r01Su6AMPqsIEs9/fhoWHJnuCf7dAw6AhPjjRuT+wkFL12TSZF8rp40ZzOkKwQCwPbC3q8zv FoAxxR8D1oGS0Cmdx+S2JiPfNyC4SIkkWqK3Zotj8YceIpSQN/r2Vt2xbXJhixo8cW2/PSLlivkw9 LJyzhv2g==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJn4-000545-1S; Fri, 17 Jul 2020 06:24:15 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 12/22] netfilter: remove the compat argument to xt_copy_counters_from_user Date: Fri, 17 Jul 2020 08:23:21 +0200 Message-Id: <20200717062331.691152-13-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4A914A1B5C X-Rspamd-UID: 3f170b Lift the in_compat_syscall() from the callers instead. Signed-off-by: Christoph Hellwig --- include/linux/netfilter/x_tables.h | 2 +- net/ipv4/netfilter/arp_tables.c | 3 +-- net/ipv4/netfilter/ip_tables.c | 3 +-- net/ipv6/netfilter/ip6_tables.c | 3 +-- net/netfilter/x_tables.c | 9 ++++----- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index 5da88451853b28..b8b943ee7b8b66 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h @@ -302,7 +302,7 @@ int xt_data_to_user(void __user *dst, const void *src, int usersize, int size, int aligned_size); void *xt_copy_counters_from_user(const void __user *user, unsigned int len, - struct xt_counters_info *info, bool compat); + struct xt_counters_info *info); struct xt_counters *xt_counters_alloc(unsigned int counters); struct xt_table *xt_register_table(struct net *net, diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 15807fb4a65f3e..2c8a4dad39d748 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -1008,8 +1008,7 @@ static int do_add_counters(struct net *net, const void __user *user, struct arpt_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp, - in_compat_syscall()); + paddc = xt_copy_counters_from_user(user, len, &tmp); if (IS_ERR(paddc)) return PTR_ERR(paddc); diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index fbfad38f397949..161901dd1cae7f 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -1163,8 +1163,7 @@ do_add_counters(struct net *net, const void __user *user, struct ipt_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp, - in_compat_syscall()); + paddc = xt_copy_counters_from_user(user, len, &tmp); if (IS_ERR(paddc)) return PTR_ERR(paddc); diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 96c48e91e6c7f7..fd1f8f93123188 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -1179,8 +1179,7 @@ do_add_counters(struct net *net, const void __user *user, unsigned int len) struct ip6t_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp, - in_compat_syscall()); + paddc = xt_copy_counters_from_user(user, len, &tmp); if (IS_ERR(paddc)) return PTR_ERR(paddc); t = xt_find_table_lock(net, AF_INET6, tmp.name); diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 99a468be4a59fb..32bab45af7e415 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1033,15 +1033,14 @@ EXPORT_SYMBOL_GPL(xt_check_target); * @user: src pointer to userspace memory * @len: alleged size of userspace memory * @info: where to store the xt_counters_info metadata - * @compat: true if we setsockopt call is done by 32bit task on 64bit kernel * * Copies counter meta data from @user and stores it in @info. * * vmallocs memory to hold the counters, then copies the counter data * from @user to the new memory and returns a pointer to it. * - * If @compat is true, @info gets converted automatically to the 64bit - * representation. + * If called from a compat syscall, @info gets converted automatically to the + * 64bit representation. * * The metadata associated with the counters is stored in @info. * @@ -1049,13 +1048,13 @@ EXPORT_SYMBOL_GPL(xt_check_target); * If IS_ERR is false, caller has to vfree the pointer. */ void *xt_copy_counters_from_user(const void __user *user, unsigned int len, - struct xt_counters_info *info, bool compat) + struct xt_counters_info *info) { void *mem; u64 size; #ifdef CONFIG_COMPAT - if (compat) { + if (in_compat_syscall()) { /* structures only differ in size due to alignment */ struct compat_xt_counters_info compat_tmp; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SKOKNKpEEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:26:50 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EEVAM6pEEV9PrgEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:26:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 09CE8A2429; Fri, 17 Jul 2020 08:26:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727086AbgGQGY0 (ORCPT + 1 other); Fri, 17 Jul 2020 02:24:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbgGQGYZ (ORCPT ); Fri, 17 Jul 2020 02:24:25 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D77CC061755; Thu, 16 Jul 2020 23:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=hTVOd3UZredsxZyfKUM3xddwhLoRQHrm4mrO/1PLzMY=; b=ddaAJJead2QuCg8AEy4hqxQ947 pYgOj7htGBfdPViQwK0s0Vw8MrYBgAvSHG2QfBVCuIb8m7J9H5KoNFX1OM67AI2yDKNOYXn07f8WN VASvMsJRwd6ugDo9abPx3J8v3xJ+Gwtq8xRfI6WJRA3+Jwdix5gvgoLm/72Y9Qp18kBgaR0LrvxiJ apAqoAoJ0teV8HW4EFrM0bJBw9zVGN+nUohIDxEKdymjzfarx00DmA+eAMwLy7QdaYBsmlJYE5fB1 0nH3dfU9kXdg5kuqTzgKjGj+c7qVx9HbYNApA0JC0ONocXO2Cp746qhMENQQVOaj+X9jGFtJBpnLe unpW/dIw==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJn2-00053o-Dz; Fri, 17 Jul 2020 06:24:13 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 11/22] netfilter: remove the compat_{get,set} methods Date: Fri, 17 Jul 2020 08:23:20 +0200 Message-Id: <20200717062331.691152-12-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 09CE8A2429 X-Rspamd-UID: ffccae All instances handle compat sockopts via in_compat_syscall() now, so remove the compat_{get,set} methods as well as the compat_nf_{get,set}sockopt wrappers. Signed-off-by: Christoph Hellwig --- include/linux/netfilter.h | 14 ------------- net/ipv4/ip_sockglue.c | 5 ++--- net/ipv6/ipv6_sockglue.c | 5 ++--- net/netfilter/nf_sockopt.c | 42 -------------------------------------- 4 files changed, 4 insertions(+), 62 deletions(-) diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index eb312e7ca36ee5..711b4d4486f042 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h @@ -164,17 +164,9 @@ struct nf_sockopt_ops { int set_optmin; int set_optmax; int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len); -#ifdef CONFIG_COMPAT - int (*compat_set)(struct sock *sk, int optval, - void __user *user, unsigned int len); -#endif int get_optmin; int get_optmax; int (*get)(struct sock *sk, int optval, void __user *user, int *len); -#ifdef CONFIG_COMPAT - int (*compat_get)(struct sock *sk, int optval, - void __user *user, int *len); -#endif /* Use the module struct to lock set/get code in place */ struct module *owner; }; @@ -350,12 +342,6 @@ int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt, unsigned int len); int nf_getsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt, int *len); -#ifdef CONFIG_COMPAT -int compat_nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, - char __user *opt, unsigned int len); -int compat_nf_getsockopt(struct sock *sk, u_int8_t pf, int optval, - char __user *opt, int *len); -#endif struct flowi; struct nf_queue_entry; diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 84ec3703c90916..95f4248c6fc5ed 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1446,8 +1446,7 @@ int compat_ip_setsockopt(struct sock *sk, int level, int optname, optname != IP_IPSEC_POLICY && optname != IP_XFRM_POLICY && !ip_mroute_opt(optname)) - err = compat_nf_setsockopt(sk, PF_INET, optname, optval, - optlen); + err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); #endif return err; } @@ -1821,7 +1820,7 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname, if (get_user(len, optlen)) return -EFAULT; - err = compat_nf_getsockopt(sk, PF_INET, optname, optval, &len); + err = nf_getsockopt(sk, PF_INET, optname, optval, &len); if (err >= 0) err = put_user(len, optlen); return err; diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 6ab44ec2c369da..6adfbdcb7979bd 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -1030,8 +1030,7 @@ int compat_ipv6_setsockopt(struct sock *sk, int level, int optname, /* we need to exclude all possible ENOPROTOOPTs except default case */ if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY && optname != IPV6_XFRM_POLICY) - err = compat_nf_setsockopt(sk, PF_INET6, optname, optval, - optlen); + err = nf_setsockopt(sk, PF_INET6, optname, optval, optlen); #endif return err; } @@ -1531,7 +1530,7 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname, if (get_user(len, optlen)) return -EFAULT; - err = compat_nf_getsockopt(sk, PF_INET6, optname, optval, &len); + err = nf_getsockopt(sk, PF_INET6, optname, optval, &len); if (err >= 0) err = put_user(len, optlen); } diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c index 46cb3786e0ec5c..02870993d335c9 100644 --- a/net/netfilter/nf_sockopt.c +++ b/net/netfilter/nf_sockopt.c @@ -122,45 +122,3 @@ int nf_getsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt, return nf_sockopt(sk, pf, val, opt, len, 1); } EXPORT_SYMBOL(nf_getsockopt); - -#ifdef CONFIG_COMPAT -static int compat_nf_sockopt(struct sock *sk, u_int8_t pf, int val, - char __user *opt, int *len, int get) -{ - struct nf_sockopt_ops *ops; - int ret; - - ops = nf_sockopt_find(sk, pf, val, get); - if (IS_ERR(ops)) - return PTR_ERR(ops); - - if (get) { - if (ops->compat_get) - ret = ops->compat_get(sk, val, opt, len); - else - ret = ops->get(sk, val, opt, len); - } else { - if (ops->compat_set) - ret = ops->compat_set(sk, val, opt, *len); - else - ret = ops->set(sk, val, opt, *len); - } - - module_put(ops->owner); - return ret; -} - -int compat_nf_setsockopt(struct sock *sk, u_int8_t pf, - int val, char __user *opt, unsigned int len) -{ - return compat_nf_sockopt(sk, pf, val, opt, &len, 0); -} -EXPORT_SYMBOL(compat_nf_setsockopt); - -int compat_nf_getsockopt(struct sock *sk, u_int8_t pf, - int val, char __user *opt, int *len) -{ - return compat_nf_sockopt(sk, pf, val, opt, len, 1); -} -EXPORT_SYMBOL(compat_nf_getsockopt); -#endif -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IPSVKLVEEV/GzQAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:27:01 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WOPFJrVEEV9PrgEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:27:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EABCFA1AE0; Fri, 17 Jul 2020 08:26:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727891AbgGQG0T (ORCPT + 1 other); Fri, 17 Jul 2020 02:26:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727043AbgGQGYX (ORCPT ); Fri, 17 Jul 2020 02:24:23 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D1A9C061755; Thu, 16 Jul 2020 23:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=onGMObakYuJolqNUDGEoKH222TJ4CRvXciqCD06UH/4=; b=Uc0ddcNECGZcu9NFgN8NW/9NDo 9YsTXvgLnALfkSMrgDoBURQ9+dpcHCrJcbgqduNESwel2WYvkDDv4y9m/FOkibo8xgGZF2kGOlddN OLGEJiOxYSHPni5Byri9LJSVIvsPNGVWp83iGMhpqCLTfcwiBtGEvW2miEfaCHx6CvEoEub4Xo0XE 5A7p2ZxvckF66jQI0VYWK99tE+Dag48jDYcBYr+d9WCkh+GsOG7NmwGIitI4Eb/a+aGKIbnsA5oSv YWSuCicEdqvh2HaWOmLeKUKgzFx/TFWPLtAVsUuU4RKtOxpgsrrlbjybpWo6GtLB0QqCeYUHC08qr mK+F0ICg==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJn0-00053W-6X; Fri, 17 Jul 2020 06:24:10 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 10/22] netfilter/ebtables: clean up compat {get,set}sockopt handling Date: Fri, 17 Jul 2020 08:23:19 +0200 Message-Id: <20200717062331.691152-11-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: EABCFA1AE0 X-Rspamd-UID: 351435 Merge the native and compat {get,set}sockopt handlers using in_compat_syscall(). Note that this required moving a fair amout of code around to be done sanely. Signed-off-by: Christoph Hellwig --- net/bridge/netfilter/ebtables.c | 214 +++++++++++++++----------------- 1 file changed, 98 insertions(+), 116 deletions(-) diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index c83ffe9121639c..fe13108af1f542 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1451,86 +1451,6 @@ static int copy_everything_to_user(struct ebt_table *t, void __user *user, ebt_entry_to_user, entries, tmp.entries); } -static int do_ebt_set_ctl(struct sock *sk, - int cmd, void __user *user, unsigned int len) -{ - int ret; - struct net *net = sock_net(sk); - - if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) - return -EPERM; - - switch (cmd) { - case EBT_SO_SET_ENTRIES: - ret = do_replace(net, user, len); - break; - case EBT_SO_SET_COUNTERS: - ret = update_counters(net, user, len); - break; - default: - ret = -EINVAL; - } - return ret; -} - -static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) -{ - int ret; - struct ebt_replace tmp; - struct ebt_table *t; - struct net *net = sock_net(sk); - - if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) - return -EPERM; - - if (copy_from_user(&tmp, user, sizeof(tmp))) - return -EFAULT; - - tmp.name[sizeof(tmp.name) - 1] = '\0'; - - t = find_table_lock(net, tmp.name, &ret, &ebt_mutex); - if (!t) - return ret; - - switch (cmd) { - case EBT_SO_GET_INFO: - case EBT_SO_GET_INIT_INFO: - if (*len != sizeof(struct ebt_replace)) { - ret = -EINVAL; - mutex_unlock(&ebt_mutex); - break; - } - if (cmd == EBT_SO_GET_INFO) { - tmp.nentries = t->private->nentries; - tmp.entries_size = t->private->entries_size; - tmp.valid_hooks = t->valid_hooks; - } else { - tmp.nentries = t->table->nentries; - tmp.entries_size = t->table->entries_size; - tmp.valid_hooks = t->table->valid_hooks; - } - mutex_unlock(&ebt_mutex); - if (copy_to_user(user, &tmp, *len) != 0) { - ret = -EFAULT; - break; - } - ret = 0; - break; - - case EBT_SO_GET_ENTRIES: - case EBT_SO_GET_INIT_ENTRIES: - ret = copy_everything_to_user(t, user, len, cmd); - mutex_unlock(&ebt_mutex); - break; - - default: - mutex_unlock(&ebt_mutex); - ret = -EINVAL; - } - - return ret; -} - #ifdef CONFIG_COMPAT /* 32 bit-userspace compatibility definitions. */ struct compat_ebt_replace { @@ -2314,28 +2234,6 @@ static int compat_update_counters(struct net *net, void __user *user, hlp.num_counters, user, len); } -static int compat_do_ebt_set_ctl(struct sock *sk, - int cmd, void __user *user, unsigned int len) -{ - int ret; - struct net *net = sock_net(sk); - - if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) - return -EPERM; - - switch (cmd) { - case EBT_SO_SET_ENTRIES: - ret = compat_do_replace(net, user, len); - break; - case EBT_SO_SET_COUNTERS: - ret = compat_update_counters(net, user, len); - break; - default: - ret = -EINVAL; - } - return ret; -} - static int compat_do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) { @@ -2344,14 +2242,6 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd, struct ebt_table *t; struct net *net = sock_net(sk); - if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) - return -EPERM; - - /* try real handler in case userland supplied needed padding */ - if ((cmd == EBT_SO_GET_INFO || - cmd == EBT_SO_GET_INIT_INFO) && *len != sizeof(tmp)) - return do_ebt_get_ctl(sk, cmd, user, len); - if (copy_from_user(&tmp, user, sizeof(tmp))) return -EFAULT; @@ -2413,20 +2303,112 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd, } #endif +static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) +{ + struct net *net = sock_net(sk); + struct ebt_replace tmp; + struct ebt_table *t; + int ret; + + if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) + return -EPERM; + +#ifdef CONFIG_COMPAT + /* try real handler in case userland supplied needed padding */ + if (in_compat_syscall() && + ((cmd != EBT_SO_GET_INFO && cmd != EBT_SO_GET_INIT_INFO) || + *len != sizeof(tmp))) + return compat_do_ebt_get_ctl(sk, cmd, user, len); +#endif + + if (copy_from_user(&tmp, user, sizeof(tmp))) + return -EFAULT; + + tmp.name[sizeof(tmp.name) - 1] = '\0'; + + t = find_table_lock(net, tmp.name, &ret, &ebt_mutex); + if (!t) + return ret; + + switch (cmd) { + case EBT_SO_GET_INFO: + case EBT_SO_GET_INIT_INFO: + if (*len != sizeof(struct ebt_replace)) { + ret = -EINVAL; + mutex_unlock(&ebt_mutex); + break; + } + if (cmd == EBT_SO_GET_INFO) { + tmp.nentries = t->private->nentries; + tmp.entries_size = t->private->entries_size; + tmp.valid_hooks = t->valid_hooks; + } else { + tmp.nentries = t->table->nentries; + tmp.entries_size = t->table->entries_size; + tmp.valid_hooks = t->table->valid_hooks; + } + mutex_unlock(&ebt_mutex); + if (copy_to_user(user, &tmp, *len) != 0) { + ret = -EFAULT; + break; + } + ret = 0; + break; + + case EBT_SO_GET_ENTRIES: + case EBT_SO_GET_INIT_ENTRIES: + ret = copy_everything_to_user(t, user, len, cmd); + mutex_unlock(&ebt_mutex); + break; + + default: + mutex_unlock(&ebt_mutex); + ret = -EINVAL; + } + + return ret; +} + +static int do_ebt_set_ctl(struct sock *sk, int cmd, void __user *user, + unsigned int len) +{ + struct net *net = sock_net(sk); + int ret; + + if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) + return -EPERM; + + switch (cmd) { + case EBT_SO_SET_ENTRIES: +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + ret = compat_do_replace(net, user, len); + else +#endif + ret = do_replace(net, user, len); + break; + case EBT_SO_SET_COUNTERS: +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + ret = compat_update_counters(net, user, len); + else +#endif + ret = update_counters(net, user, len); + break; + default: + ret = -EINVAL; + } + return ret; +} + static struct nf_sockopt_ops ebt_sockopts = { .pf = PF_INET, .set_optmin = EBT_BASE_CTL, .set_optmax = EBT_SO_SET_MAX + 1, .set = do_ebt_set_ctl, -#ifdef CONFIG_COMPAT - .compat_set = compat_do_ebt_set_ctl, -#endif .get_optmin = EBT_BASE_CTL, .get_optmax = EBT_SO_GET_MAX + 1, .get = do_ebt_get_ctl, -#ifdef CONFIG_COMPAT - .compat_get = compat_do_ebt_get_ctl, -#endif .owner = THIS_MODULE, }; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aNy0OMBEEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:27:12 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id KCztNsBEEV+12wEADc0bRg (envelope-from ); Fri, 17 Jul 2020 08:27:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 483E5A1664; Fri, 17 Jul 2020 08:27:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726970AbgGQG0d (ORCPT + 1 other); Fri, 17 Jul 2020 02:26:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbgGQGYU (ORCPT ); Fri, 17 Jul 2020 02:24:20 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FD59C08C5C0; Thu, 16 Jul 2020 23:24:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=+VCp+M6LeW8FDpyr7wpNvWuI4BNWqFi7JKzfYrQ+dWQ=; b=IEnHLxbUNi0NH0s9vaRENCbsa+ lBdonIkz1Nun86rXP17mfcn8S1Gp4G7dumaPNbR/siTumrDztawUGl3e6Lbedg3rirHAl4Gr4kg8O d/dcYnbAeJnp+If+j1Z+Ywmlsi2Ci6FbgaXTge5bbuxTrTHFEdPLmhynLvPNSREVBQk/MQ3G1C55u KB3I+6T1FzXXobd920GAKfbnaYa3k4EJKiUNjv3KrZX+wpVlK0THIUyLK3ZkRlx4LcWM1i+yavQaE ELVoAcO0zAJ4c4oZ7ntQOzwzodRfKpqdrhowInfpopZzTX+loc3w5bzbHEp+q+4mmXUZ/nRu9VA56 RuIFd8+A==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJmy-00053D-S0; Fri, 17 Jul 2020 06:24:09 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 09/22] netfilter/ip6_tables: clean up compat {get,set}sockopt handling Date: Fri, 17 Jul 2020 08:23:18 +0200 Message-Id: <20200717062331.691152-10-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 483E5A1664 X-Rspamd-UID: ffa9cb Merge the native and compat {get,set}sockopt handlers using in_compat_syscall(). Signed-off-by: Christoph Hellwig --- net/ipv6/netfilter/ip6_tables.c | 87 ++++++++------------------------- 1 file changed, 21 insertions(+), 66 deletions(-) diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index e96a431549bcc9..96c48e91e6c7f7 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -960,8 +960,7 @@ static int compat_table_info(const struct xt_table_info *info, } #endif -static int get_info(struct net *net, void __user *user, - const int *len, int compat) +static int get_info(struct net *net, void __user *user, const int *len) { char name[XT_TABLE_MAXNAMELEN]; struct xt_table *t; @@ -975,7 +974,7 @@ static int get_info(struct net *net, void __user *user, name[XT_TABLE_MAXNAMELEN-1] = '\0'; #ifdef CONFIG_COMPAT - if (compat) + if (in_compat_syscall()) xt_compat_lock(AF_INET6); #endif t = xt_request_find_table_lock(net, AF_INET6, name); @@ -985,7 +984,7 @@ static int get_info(struct net *net, void __user *user, #ifdef CONFIG_COMPAT struct xt_table_info tmp; - if (compat) { + if (in_compat_syscall()) { ret = compat_table_info(private, &tmp); xt_compat_flush_offsets(AF_INET6); private = &tmp; @@ -1011,7 +1010,7 @@ static int get_info(struct net *net, void __user *user, } else ret = PTR_ERR(t); #ifdef CONFIG_COMPAT - if (compat) + if (in_compat_syscall()) xt_compat_unlock(AF_INET6); #endif return ret; @@ -1169,8 +1168,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) } static int -do_add_counters(struct net *net, const void __user *user, unsigned int len, - int compat) +do_add_counters(struct net *net, const void __user *user, unsigned int len) { unsigned int i; struct xt_counters_info tmp; @@ -1181,7 +1179,8 @@ do_add_counters(struct net *net, const void __user *user, unsigned int len, struct ip6t_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp, compat); + paddc = xt_copy_counters_from_user(user, len, &tmp, + in_compat_syscall()); if (IS_ERR(paddc)) return PTR_ERR(paddc); t = xt_find_table_lock(net, AF_INET6, tmp.name); @@ -1543,31 +1542,6 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) return ret; } -static int -compat_do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, - unsigned int len) -{ - int ret; - - if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) - return -EPERM; - - switch (cmd) { - case IP6T_SO_SET_REPLACE: - ret = compat_do_replace(sock_net(sk), user, len); - break; - - case IP6T_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len, 1); - break; - - default: - ret = -EINVAL; - } - - return ret; -} - struct compat_ip6t_get_entries { char name[XT_TABLE_MAXNAMELEN]; compat_uint_t size; @@ -1643,29 +1617,6 @@ compat_get_entries(struct net *net, struct compat_ip6t_get_entries __user *uptr, xt_compat_unlock(AF_INET6); return ret; } - -static int do_ip6t_get_ctl(struct sock *, int, void __user *, int *); - -static int -compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) -{ - int ret; - - if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) - return -EPERM; - - switch (cmd) { - case IP6T_SO_GET_INFO: - ret = get_info(sock_net(sk), user, len, 1); - break; - case IP6T_SO_GET_ENTRIES: - ret = compat_get_entries(sock_net(sk), user, len); - break; - default: - ret = do_ip6t_get_ctl(sk, cmd, user, len); - } - return ret; -} #endif static int @@ -1678,11 +1629,16 @@ do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) switch (cmd) { case IP6T_SO_SET_REPLACE: - ret = do_replace(sock_net(sk), user, len); +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + ret = compat_do_replace(sock_net(sk), user, len); + else +#endif + ret = do_replace(sock_net(sk), user, len); break; case IP6T_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len, 0); + ret = do_add_counters(sock_net(sk), user, len); break; default: @@ -1702,11 +1658,16 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) switch (cmd) { case IP6T_SO_GET_INFO: - ret = get_info(sock_net(sk), user, len, 0); + ret = get_info(sock_net(sk), user, len); break; case IP6T_SO_GET_ENTRIES: - ret = get_entries(sock_net(sk), user, len); +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + ret = compat_get_entries(sock_net(sk), user, len); + else +#endif + ret = get_entries(sock_net(sk), user, len); break; case IP6T_SO_GET_REVISION_MATCH: @@ -1897,15 +1858,9 @@ static struct nf_sockopt_ops ip6t_sockopts = { .set_optmin = IP6T_BASE_CTL, .set_optmax = IP6T_SO_SET_MAX+1, .set = do_ip6t_set_ctl, -#ifdef CONFIG_COMPAT - .compat_set = compat_do_ip6t_set_ctl, -#endif .get_optmin = IP6T_BASE_CTL, .get_optmax = IP6T_SO_GET_MAX+1, .get = do_ip6t_get_ctl, -#ifdef CONFIG_COMPAT - .compat_get = compat_do_ip6t_get_ctl, -#endif .owner = THIS_MODULE, }; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UHF9JdJEEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:27:30 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gJ96JNJEEV+sAAEAlp8NpQ (envelope-from ); Fri, 17 Jul 2020 08:27:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id ED652A26DE; Fri, 17 Jul 2020 08:27:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727817AbgGQG0n (ORCPT + 1 other); Fri, 17 Jul 2020 02:26:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726959AbgGQGYT (ORCPT ); Fri, 17 Jul 2020 02:24:19 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE660C061755; Thu, 16 Jul 2020 23:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=wr5cOSCBypjWaa13QpyMI0Pyh05kUAwvudFuTMkZyns=; b=s3rvm7cVFffHZaEfGTg7ZfxVZj x98j/y1+kfHZpWI0o1XmAwtMIa3yqk+Mc35fICVgr5SELYyL2RJfoDIKDIQSXFAsXM2VTe8QKHi5F Ms4N6XlX6SrfF4CMde/BUp9r4z8dZzORk9rMPY4AUlCe5u/SKvMCnl4dBlfzkl2VAmFEIm+GFY8lZ QShVpd2XFETG8G+PSNHUayBUaUWpvUXP1w8ZOTIXN90+oLvpDE6atTMlyXW8e9cOsrgX/OhVi9zFr aJKInlOHEuN74IWoQ+LsKSCMq945wnFRGiPbMkMVSCsxQnG2UWG2tAf67VXI8o56QRe+iexrykVXk 6aCu719g==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJmx-00052z-Gw; Fri, 17 Jul 2020 06:24:07 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 08/22] netfilter/ip_tables: clean up compat {get,set}sockopt handling Date: Fri, 17 Jul 2020 08:23:17 +0200 Message-Id: <20200717062331.691152-9-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: ED652A26DE X-Rspamd-UID: c6ff05 Merge the native and compat {get,set}sockopt handlers using in_compat_syscall(). Signed-off-by: Christoph Hellwig --- net/ipv4/netfilter/ip_tables.c | 86 +++++++++------------------------- 1 file changed, 21 insertions(+), 65 deletions(-) diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 5bf9fa06aee0be..fbfad38f397949 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -944,8 +944,7 @@ static int compat_table_info(const struct xt_table_info *info, } #endif -static int get_info(struct net *net, void __user *user, - const int *len, int compat) +static int get_info(struct net *net, void __user *user, const int *len) { char name[XT_TABLE_MAXNAMELEN]; struct xt_table *t; @@ -959,7 +958,7 @@ static int get_info(struct net *net, void __user *user, name[XT_TABLE_MAXNAMELEN-1] = '\0'; #ifdef CONFIG_COMPAT - if (compat) + if (in_compat_syscall()) xt_compat_lock(AF_INET); #endif t = xt_request_find_table_lock(net, AF_INET, name); @@ -969,7 +968,7 @@ static int get_info(struct net *net, void __user *user, #ifdef CONFIG_COMPAT struct xt_table_info tmp; - if (compat) { + if (in_compat_syscall()) { ret = compat_table_info(private, &tmp); xt_compat_flush_offsets(AF_INET); private = &tmp; @@ -995,7 +994,7 @@ static int get_info(struct net *net, void __user *user, } else ret = PTR_ERR(t); #ifdef CONFIG_COMPAT - if (compat) + if (in_compat_syscall()) xt_compat_unlock(AF_INET); #endif return ret; @@ -1153,7 +1152,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) static int do_add_counters(struct net *net, const void __user *user, - unsigned int len, int compat) + unsigned int len) { unsigned int i; struct xt_counters_info tmp; @@ -1164,7 +1163,8 @@ do_add_counters(struct net *net, const void __user *user, struct ipt_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp, compat); + paddc = xt_copy_counters_from_user(user, len, &tmp, + in_compat_syscall()); if (IS_ERR(paddc)) return PTR_ERR(paddc); @@ -1534,31 +1534,6 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) return ret; } -static int -compat_do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, - unsigned int len) -{ - int ret; - - if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) - return -EPERM; - - switch (cmd) { - case IPT_SO_SET_REPLACE: - ret = compat_do_replace(sock_net(sk), user, len); - break; - - case IPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len, 1); - break; - - default: - ret = -EINVAL; - } - - return ret; -} - struct compat_ipt_get_entries { char name[XT_TABLE_MAXNAMELEN]; compat_uint_t size; @@ -1634,29 +1609,6 @@ compat_get_entries(struct net *net, struct compat_ipt_get_entries __user *uptr, xt_compat_unlock(AF_INET); return ret; } - -static int do_ipt_get_ctl(struct sock *, int, void __user *, int *); - -static int -compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) -{ - int ret; - - if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) - return -EPERM; - - switch (cmd) { - case IPT_SO_GET_INFO: - ret = get_info(sock_net(sk), user, len, 1); - break; - case IPT_SO_GET_ENTRIES: - ret = compat_get_entries(sock_net(sk), user, len); - break; - default: - ret = do_ipt_get_ctl(sk, cmd, user, len); - } - return ret; -} #endif static int @@ -1669,11 +1621,16 @@ do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) switch (cmd) { case IPT_SO_SET_REPLACE: - ret = do_replace(sock_net(sk), user, len); +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + ret = compat_do_replace(sock_net(sk), user, len); + else +#endif + ret = do_replace(sock_net(sk), user, len); break; case IPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len, 0); + ret = do_add_counters(sock_net(sk), user, len); break; default: @@ -1693,11 +1650,16 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) switch (cmd) { case IPT_SO_GET_INFO: - ret = get_info(sock_net(sk), user, len, 0); + ret = get_info(sock_net(sk), user, len); break; case IPT_SO_GET_ENTRIES: - ret = get_entries(sock_net(sk), user, len); +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + ret = compat_get_entries(sock_net(sk), user, len); + else +#endif + ret = get_entries(sock_net(sk), user, len); break; case IPT_SO_GET_REVISION_MATCH: @@ -1886,15 +1848,9 @@ static struct nf_sockopt_ops ipt_sockopts = { .set_optmin = IPT_BASE_CTL, .set_optmax = IPT_SO_SET_MAX+1, .set = do_ipt_set_ctl, -#ifdef CONFIG_COMPAT - .compat_set = compat_do_ipt_set_ctl, -#endif .get_optmin = IPT_BASE_CTL, .get_optmax = IPT_SO_GET_MAX+1, .get = do_ipt_get_ctl, -#ifdef CONFIG_COMPAT - .compat_get = compat_do_ipt_get_ctl, -#endif .owner = THIS_MODULE, }; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IIxkOtZEEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:27:34 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2JJWOdZEEV80BwEAlp8NpQ (envelope-from ); Fri, 17 Jul 2020 08:27:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BAD7CA179F; Fri, 17 Jul 2020 08:27:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726954AbgGQGYT (ORCPT + 1 other); Fri, 17 Jul 2020 02:24:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726944AbgGQGYR (ORCPT ); Fri, 17 Jul 2020 02:24:17 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45B5EC061755; Thu, 16 Jul 2020 23:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=VxyQD+hRQLQr4UhdB5aW45Kx+pCOC8uUSj3q2fzaJeo=; b=kuLOak4LimTxHkua24j0bXUJDB aupbdH01Cd+p3yeUiP4wPe4e2tI60umZ1RqNsAXS0Yqs6sE+5Z93ZJ22Wlm9k/GVDzO1XWklnaNTs fhzGZpl1jAYWvgzVqo8CZbTXRXIYMQyYuA7OC4MStaVdtPF15ztFgdPijNSi4Fzd+Ic211S7X8S5G D7szhFcFC2FgHYRyhkCQYXrSwGn432EckjZYIxk5iN44Bp9GEvktSSzvSrUSibHyhxbTqqh/GE39E BxUK6VK6HTha1JRSeEMkANJ5fVU2BUKx1qifozT+dnmpeF6pMhjBjhOL7RDJ5vefZISGMspeIZaSA /SAEjDmQ==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJms-00052U-8q; Fri, 17 Jul 2020 06:24:04 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 06/22] net: remove compat_sys_{get,set}sockopt Date: Fri, 17 Jul 2020 08:23:15 +0200 Message-Id: <20200717062331.691152-7-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: BAD7CA179F X-Rspamd-UID: c86977 Now that the ->compat_{get,set}sockopt proto_ops methods are gone there is no good reason left to keep the compat syscalls separate. This fixes the odd use of unsigned int for the compat_setsockopt optlen and the missing sock_use_custom_sol_socket. It would also easily allow running the eBPF hooks for the compat syscalls, but such a large change in behavior does not belong into a consolidation patch like this one. Signed-off-by: Christoph Hellwig --- arch/arm64/include/asm/unistd32.h | 4 +- arch/mips/kernel/syscalls/syscall_n32.tbl | 4 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 4 +- arch/parisc/kernel/syscalls/syscall.tbl | 4 +- arch/powerpc/kernel/syscalls/syscall.tbl | 4 +- arch/s390/kernel/syscalls/syscall.tbl | 4 +- arch/sparc/kernel/sys32.S | 12 +-- arch/sparc/kernel/syscalls/syscall.tbl | 4 +- arch/x86/entry/syscall_x32.c | 7 ++ arch/x86/entry/syscalls/syscall_32.tbl | 4 +- arch/x86/entry/syscalls/syscall_64.tbl | 4 +- include/linux/compat.h | 4 - include/linux/syscalls.h | 4 + include/uapi/asm-generic/unistd.h | 4 +- net/compat.c | 79 +------------------ net/socket.c | 25 +++--- tools/include/uapi/asm-generic/unistd.h | 4 +- .../arch/powerpc/entry/syscalls/syscall.tbl | 4 +- .../perf/arch/s390/entry/syscalls/syscall.tbl | 4 +- .../arch/x86/entry/syscalls/syscall_64.tbl | 4 +- 20 files changed, 62 insertions(+), 125 deletions(-) diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h index 6d95d0c8bf2f47..166e369031108a 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -599,9 +599,9 @@ __SYSCALL(__NR_recvfrom, compat_sys_recvfrom) #define __NR_shutdown 293 __SYSCALL(__NR_shutdown, sys_shutdown) #define __NR_setsockopt 294 -__SYSCALL(__NR_setsockopt, compat_sys_setsockopt) +__SYSCALL(__NR_setsockopt, sys_setsockopt) #define __NR_getsockopt 295 -__SYSCALL(__NR_getsockopt, compat_sys_getsockopt) +__SYSCALL(__NR_getsockopt, sys_getsockopt) #define __NR_sendmsg 296 __SYSCALL(__NR_sendmsg, compat_sys_sendmsg) #define __NR_recvmsg 297 diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl index f777141f52568f..8488b0d0a99e2a 100644 --- a/arch/mips/kernel/syscalls/syscall_n32.tbl +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl @@ -60,8 +60,8 @@ 50 n32 getsockname sys_getsockname 51 n32 getpeername sys_getpeername 52 n32 socketpair sys_socketpair -53 n32 setsockopt compat_sys_setsockopt -54 n32 getsockopt compat_sys_getsockopt +53 n32 setsockopt sys_setsockopt +54 n32 getsockopt sys_getsockopt 55 n32 clone __sys_clone 56 n32 fork __sys_fork 57 n32 execve compat_sys_execve diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl index 13280625d312e9..b20522f813f9d7 100644 --- a/arch/mips/kernel/syscalls/syscall_o32.tbl +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl @@ -184,7 +184,7 @@ 170 o32 connect sys_connect 171 o32 getpeername sys_getpeername 172 o32 getsockname sys_getsockname -173 o32 getsockopt sys_getsockopt compat_sys_getsockopt +173 o32 getsockopt sys_getsockopt sys_getsockopt 174 o32 listen sys_listen 175 o32 recv sys_recv compat_sys_recv 176 o32 recvfrom sys_recvfrom compat_sys_recvfrom @@ -192,7 +192,7 @@ 178 o32 send sys_send 179 o32 sendmsg sys_sendmsg compat_sys_sendmsg 180 o32 sendto sys_sendto -181 o32 setsockopt sys_setsockopt compat_sys_setsockopt +181 o32 setsockopt sys_setsockopt sys_setsockopt 182 o32 shutdown sys_shutdown 183 o32 socket sys_socket 184 o32 socketpair sys_socketpair diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl index 5a758fa6ec5242..3494e4fa1a1768 100644 --- a/arch/parisc/kernel/syscalls/syscall.tbl +++ b/arch/parisc/kernel/syscalls/syscall.tbl @@ -198,8 +198,8 @@ 178 common rt_sigqueueinfo sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo 179 common rt_sigsuspend sys_rt_sigsuspend compat_sys_rt_sigsuspend 180 common chown sys_chown -181 common setsockopt sys_setsockopt compat_sys_setsockopt -182 common getsockopt sys_getsockopt compat_sys_getsockopt +181 common setsockopt sys_setsockopt sys_setsockopt +182 common getsockopt sys_getsockopt sys_getsockopt 183 common sendmsg sys_sendmsg compat_sys_sendmsg 184 common recvmsg sys_recvmsg compat_sys_recvmsg 185 common semop sys_semop diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl index f833a319082247..94eb5b27ef65e3 100644 --- a/arch/powerpc/kernel/syscalls/syscall.tbl +++ b/arch/powerpc/kernel/syscalls/syscall.tbl @@ -433,8 +433,8 @@ 336 common recv sys_recv compat_sys_recv 337 common recvfrom sys_recvfrom compat_sys_recvfrom 338 common shutdown sys_shutdown -339 common setsockopt sys_setsockopt compat_sys_setsockopt -340 common getsockopt sys_getsockopt compat_sys_getsockopt +339 common setsockopt sys_setsockopt sys_setsockopt +340 common getsockopt sys_getsockopt sys_getsockopt 341 common sendmsg sys_sendmsg compat_sys_sendmsg 342 common recvmsg sys_recvmsg compat_sys_recvmsg 343 32 recvmmsg sys_recvmmsg_time32 compat_sys_recvmmsg_time32 diff --git a/arch/s390/kernel/syscalls/syscall.tbl b/arch/s390/kernel/syscalls/syscall.tbl index bfdcb763395735..0d63c71fc54440 100644 --- a/arch/s390/kernel/syscalls/syscall.tbl +++ b/arch/s390/kernel/syscalls/syscall.tbl @@ -372,8 +372,8 @@ 362 common connect sys_connect sys_connect 363 common listen sys_listen sys_listen 364 common accept4 sys_accept4 sys_accept4 -365 common getsockopt sys_getsockopt compat_sys_getsockopt -366 common setsockopt sys_setsockopt compat_sys_setsockopt +365 common getsockopt sys_getsockopt sys_getsockopt +366 common setsockopt sys_setsockopt sys_setsockopt 367 common getsockname sys_getsockname sys_getsockname 368 common getpeername sys_getpeername sys_getpeername 369 common sendto sys_sendto sys_sendto diff --git a/arch/sparc/kernel/sys32.S b/arch/sparc/kernel/sys32.S index 489ffab918a835..a45f0f31fe51ab 100644 --- a/arch/sparc/kernel/sys32.S +++ b/arch/sparc/kernel/sys32.S @@ -157,22 +157,22 @@ do_sys_shutdown: /* sys_shutdown(int, int) */ nop nop nop -do_sys_setsockopt: /* compat_sys_setsockopt(int, int, int, char *, int) */ +do_sys_setsockopt: /* sys_setsockopt(int, int, int, char *, int) */ 47: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(compat_sys_setsockopt), %g1 + sethi %hi(sys_setsockopt), %g1 48: ldswa [%o1 + 0x8] %asi, %o2 49: lduwa [%o1 + 0xc] %asi, %o3 50: ldswa [%o1 + 0x10] %asi, %o4 - jmpl %g1 + %lo(compat_sys_setsockopt), %g0 + jmpl %g1 + %lo(sys_setsockopt), %g0 51: ldswa [%o1 + 0x4] %asi, %o1 nop -do_sys_getsockopt: /* compat_sys_getsockopt(int, int, int, u32, u32) */ +do_sys_getsockopt: /* sys_getsockopt(int, int, int, u32, u32) */ 52: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(compat_sys_getsockopt), %g1 + sethi %hi(sys_getsockopt), %g1 53: ldswa [%o1 + 0x8] %asi, %o2 54: lduwa [%o1 + 0xc] %asi, %o3 55: lduwa [%o1 + 0x10] %asi, %o4 - jmpl %g1 + %lo(compat_sys_getsockopt), %g0 + jmpl %g1 + %lo(sys_getsockopt), %g0 56: ldswa [%o1 + 0x4] %asi, %o1 nop do_sys_sendmsg: /* compat_sys_sendmsg(int, struct compat_msghdr *, unsigned int) */ diff --git a/arch/sparc/kernel/syscalls/syscall.tbl b/arch/sparc/kernel/syscalls/syscall.tbl index 8004a276cb74be..c59b37965add7e 100644 --- a/arch/sparc/kernel/syscalls/syscall.tbl +++ b/arch/sparc/kernel/syscalls/syscall.tbl @@ -147,7 +147,7 @@ 115 32 getgroups32 sys_getgroups 116 common gettimeofday sys_gettimeofday compat_sys_gettimeofday 117 common getrusage sys_getrusage compat_sys_getrusage -118 common getsockopt sys_getsockopt compat_sys_getsockopt +118 common getsockopt sys_getsockopt sys_getsockopt 119 common getcwd sys_getcwd 120 common readv sys_readv compat_sys_readv 121 common writev sys_writev compat_sys_writev @@ -425,7 +425,7 @@ 352 common userfaultfd sys_userfaultfd 353 common bind sys_bind 354 common listen sys_listen -355 common setsockopt sys_setsockopt compat_sys_setsockopt +355 common setsockopt sys_setsockopt sys_setsockopt 356 common mlock2 sys_mlock2 357 common copy_file_range sys_copy_file_range 358 common preadv2 sys_preadv2 compat_sys_preadv2 diff --git a/arch/x86/entry/syscall_x32.c b/arch/x86/entry/syscall_x32.c index 3d8d70d3896c87..1583831f61a9df 100644 --- a/arch/x86/entry/syscall_x32.c +++ b/arch/x86/entry/syscall_x32.c @@ -8,6 +8,13 @@ #include #include +/* + * Reuse the 64-bit entry points for the x32 versions that occupy different + * slots in the syscall table. + */ +#define __x32_sys_getsockopt __x64_sys_getsockopt +#define __x32_sys_setsockopt __x64_sys_setsockopt + #define __SYSCALL_64(nr, sym) #define __SYSCALL_X32(nr, sym) extern long __x32_##sym(const struct pt_regs *); diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl index d8f8a1a69ed11f..43742a69dba13a 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl @@ -376,8 +376,8 @@ 362 i386 connect sys_connect 363 i386 listen sys_listen 364 i386 accept4 sys_accept4 -365 i386 getsockopt sys_getsockopt compat_sys_getsockopt -366 i386 setsockopt sys_setsockopt compat_sys_setsockopt +365 i386 getsockopt sys_getsockopt sys_getsockopt +366 i386 setsockopt sys_setsockopt sys_setsockopt 367 i386 getsockname sys_getsockname 368 i386 getpeername sys_getpeername 369 i386 sendto sys_sendto diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl index 78847b32e1370f..e008d638e6417f 100644 --- a/arch/x86/entry/syscalls/syscall_64.tbl +++ b/arch/x86/entry/syscalls/syscall_64.tbl @@ -396,8 +396,8 @@ 538 x32 sendmmsg compat_sys_sendmmsg 539 x32 process_vm_readv compat_sys_process_vm_readv 540 x32 process_vm_writev compat_sys_process_vm_writev -541 x32 setsockopt compat_sys_setsockopt -542 x32 getsockopt compat_sys_getsockopt +541 x32 setsockopt sys_setsockopt +542 x32 getsockopt sys_getsockopt 543 x32 io_setup compat_sys_io_setup 544 x32 io_submit compat_sys_io_submit 545 x32 execveat compat_sys_execveat diff --git a/include/linux/compat.h b/include/linux/compat.h index e90100c0de72e4..c4255d8a4a8aea 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -737,10 +737,6 @@ asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg); asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, compat_size_t len, unsigned flags, struct sockaddr __user *addr, int __user *addrlen); -asmlinkage long compat_sys_setsockopt(int fd, int level, int optname, - char __user *optval, unsigned int optlen); -asmlinkage long compat_sys_getsockopt(int fd, int level, int optname, - char __user *optval, int __user *optlen); asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags); asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index b951a87da9877c..aa46825c6f9d78 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -1424,4 +1424,8 @@ long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems, unsigned int nsops, const struct old_timespec32 __user *timeout); +int __sys_getsockopt(int fd, int level, int optname, char __user *optval, + int __user *optlen); +int __sys_setsockopt(int fd, int level, int optname, char __user *optval, + int optlen); #endif diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index f4a01305d9a65c..c8c189a5f0a6bd 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -606,9 +606,9 @@ __SYSCALL(__NR_sendto, sys_sendto) #define __NR_recvfrom 207 __SC_COMP(__NR_recvfrom, sys_recvfrom, compat_sys_recvfrom) #define __NR_setsockopt 208 -__SC_COMP(__NR_setsockopt, sys_setsockopt, compat_sys_setsockopt) +__SC_COMP(__NR_setsockopt, sys_setsockopt, sys_setsockopt) #define __NR_getsockopt 209 -__SC_COMP(__NR_getsockopt, sys_getsockopt, compat_sys_getsockopt) +__SC_COMP(__NR_getsockopt, sys_getsockopt, sys_getsockopt) #define __NR_shutdown 210 __SYSCALL(__NR_shutdown, sys_shutdown) #define __NR_sendmsg 211 diff --git a/net/compat.c b/net/compat.c index 3e6c2c5ff2609c..091875bd621048 100644 --- a/net/compat.c +++ b/net/compat.c @@ -335,77 +335,6 @@ void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm) __scm_destroy(scm); } -static int __compat_sys_setsockopt(int fd, int level, int optname, - char __user *optval, unsigned int optlen) -{ - int err; - struct socket *sock; - - if (optlen > INT_MAX) - return -EINVAL; - - sock = sockfd_lookup(fd, &err); - if (sock) { - err = security_socket_setsockopt(sock, level, optname); - if (err) { - sockfd_put(sock); - return err; - } - - if (level == SOL_SOCKET) - err = sock_setsockopt(sock, level, - optname, optval, optlen); - else if (sock->ops->compat_setsockopt) - err = sock->ops->compat_setsockopt(sock, level, - optname, optval, optlen); - else - err = sock->ops->setsockopt(sock, level, - optname, optval, optlen); - sockfd_put(sock); - } - return err; -} - -COMPAT_SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname, - char __user *, optval, unsigned int, optlen) -{ - return __compat_sys_setsockopt(fd, level, optname, optval, optlen); -} - -static int __compat_sys_getsockopt(int fd, int level, int optname, - char __user *optval, - int __user *optlen) -{ - int err; - struct socket *sock = sockfd_lookup(fd, &err); - - if (sock) { - err = security_socket_getsockopt(sock, level, optname); - if (err) { - sockfd_put(sock); - return err; - } - - if (level == SOL_SOCKET) - err = sock_getsockopt(sock, level, - optname, optval, optlen); - else if (sock->ops->compat_getsockopt) - err = sock->ops->compat_getsockopt(sock, level, - optname, optval, optlen); - else - err = sock->ops->getsockopt(sock, level, - optname, optval, optlen); - sockfd_put(sock); - } - return err; -} - -COMPAT_SYSCALL_DEFINE5(getsockopt, int, fd, int, level, int, optname, - char __user *, optval, int __user *, optlen) -{ - return __compat_sys_getsockopt(fd, level, optname, optval, optlen); -} - /* Argument list sizes for compat_sys_socketcall */ #define AL(x) ((x) * sizeof(u32)) static unsigned char nas[21] = { @@ -565,13 +494,11 @@ COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args) ret = __sys_shutdown(a0, a1); break; case SYS_SETSOCKOPT: - ret = __compat_sys_setsockopt(a0, a1, a[2], - compat_ptr(a[3]), a[4]); + ret = __sys_setsockopt(a0, a1, a[2], compat_ptr(a[3]), a[4]); break; case SYS_GETSOCKOPT: - ret = __compat_sys_getsockopt(a0, a1, a[2], - compat_ptr(a[3]), - compat_ptr(a[4])); + ret = __sys_getsockopt(a0, a1, a[2], compat_ptr(a[3]), + compat_ptr(a[4])); break; case SYS_SENDMSG: ret = __compat_sys_sendmsg(a0, compat_ptr(a1), a[2]); diff --git a/net/socket.c b/net/socket.c index b79376b17b45b7..dec345982abbb6 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2094,9 +2094,8 @@ static bool sock_use_custom_sol_socket(const struct socket *sock) * Set a socket option. Because we don't know the option lengths we have * to pass the user mode parameter for the protocols to sort out. */ - -static int __sys_setsockopt(int fd, int level, int optname, - char __user *optval, int optlen) +int __sys_setsockopt(int fd, int level, int optname, char __user *optval, + int optlen) { mm_segment_t oldfs = get_fs(); char *kernel_optval = NULL; @@ -2114,8 +2113,10 @@ static int __sys_setsockopt(int fd, int level, int optname, if (err) goto out_put; - err = BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock->sk, &level, &optname, - optval, &optlen, &kernel_optval); + if (!in_compat_syscall()) + err = BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock->sk, &level, &optname, + optval, &optlen, + &kernel_optval); if (err < 0) goto out_put; if (err > 0) { @@ -2154,9 +2155,8 @@ SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname, * Get a socket option. Because we don't know the option lengths we have * to pass a user mode parameter for the protocols to sort out. */ - -static int __sys_getsockopt(int fd, int level, int optname, - char __user *optval, int __user *optlen) +int __sys_getsockopt(int fd, int level, int optname, char __user *optval, + int __user *optlen) { int err, fput_needed; struct socket *sock; @@ -2170,7 +2170,8 @@ static int __sys_getsockopt(int fd, int level, int optname, if (err) goto out_put; - max_optlen = BPF_CGROUP_GETSOCKOPT_MAX_OPTLEN(optlen); + if (!in_compat_syscall()) + max_optlen = BPF_CGROUP_GETSOCKOPT_MAX_OPTLEN(optlen); if (level == SOL_SOCKET) err = sock_getsockopt(sock, level, optname, optval, optlen); @@ -2178,8 +2179,10 @@ static int __sys_getsockopt(int fd, int level, int optname, err = sock->ops->getsockopt(sock, level, optname, optval, optlen); - err = BPF_CGROUP_RUN_PROG_GETSOCKOPT(sock->sk, level, optname, optval, - optlen, max_optlen, err); + if (!in_compat_syscall()) + err = BPF_CGROUP_RUN_PROG_GETSOCKOPT(sock->sk, level, optname, + optval, optlen, max_optlen, + err); out_put: fput_light(sock->file, fput_needed); return err; diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h index f4a01305d9a65c..c8c189a5f0a6bd 100644 --- a/tools/include/uapi/asm-generic/unistd.h +++ b/tools/include/uapi/asm-generic/unistd.h @@ -606,9 +606,9 @@ __SYSCALL(__NR_sendto, sys_sendto) #define __NR_recvfrom 207 __SC_COMP(__NR_recvfrom, sys_recvfrom, compat_sys_recvfrom) #define __NR_setsockopt 208 -__SC_COMP(__NR_setsockopt, sys_setsockopt, compat_sys_setsockopt) +__SC_COMP(__NR_setsockopt, sys_setsockopt, sys_setsockopt) #define __NR_getsockopt 209 -__SC_COMP(__NR_getsockopt, sys_getsockopt, compat_sys_getsockopt) +__SC_COMP(__NR_getsockopt, sys_getsockopt, sys_getsockopt) #define __NR_shutdown 210 __SYSCALL(__NR_shutdown, sys_shutdown) #define __NR_sendmsg 211 diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl index 35b61bfc1b1ae9..b190f2eb2611b3 100644 --- a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl @@ -427,8 +427,8 @@ 336 common recv sys_recv compat_sys_recv 337 common recvfrom sys_recvfrom compat_sys_recvfrom 338 common shutdown sys_shutdown -339 common setsockopt sys_setsockopt compat_sys_setsockopt -340 common getsockopt sys_getsockopt compat_sys_getsockopt +339 common setsockopt sys_setsockopt sys_setsockopt +340 common getsockopt sys_getsockopt sys_getsockopt 341 common sendmsg sys_sendmsg compat_sys_sendmsg 342 common recvmsg sys_recvmsg compat_sys_recvmsg 343 32 recvmmsg sys_recvmmsg_time32 compat_sys_recvmmsg_time32 diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl b/tools/perf/arch/s390/entry/syscalls/syscall.tbl index b38d48464368dc..56ae24b6e4be6e 100644 --- a/tools/perf/arch/s390/entry/syscalls/syscall.tbl +++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl @@ -372,8 +372,8 @@ 362 common connect sys_connect compat_sys_connect 363 common listen sys_listen sys_listen 364 common accept4 sys_accept4 compat_sys_accept4 -365 common getsockopt sys_getsockopt compat_sys_getsockopt -366 common setsockopt sys_setsockopt compat_sys_setsockopt +365 common getsockopt sys_getsockopt sys_getsockopt +366 common setsockopt sys_setsockopt sys_setsockopt 367 common getsockname sys_getsockname compat_sys_getsockname 368 common getpeername sys_getpeername compat_sys_getpeername 369 common sendto sys_sendto compat_sys_sendto diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl index 78847b32e1370f..e008d638e6417f 100644 --- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl +++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl @@ -396,8 +396,8 @@ 538 x32 sendmmsg compat_sys_sendmmsg 539 x32 process_vm_readv compat_sys_process_vm_readv 540 x32 process_vm_writev compat_sys_process_vm_writev -541 x32 setsockopt compat_sys_setsockopt -542 x32 getsockopt compat_sys_getsockopt +541 x32 setsockopt sys_setsockopt +542 x32 getsockopt sys_getsockopt 543 x32 io_setup compat_sys_io_setup 544 x32 io_submit compat_sys_io_submit 545 x32 execveat compat_sys_execveat -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UA3bJtpEEV+X4QAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 08:27:38 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id oGMOJdpEEV/nywEAlScrYA (envelope-from ); Fri, 17 Jul 2020 08:27:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1E641A1FE5; Fri, 17 Jul 2020 08:27:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726836AbgGQGYM (ORCPT + 1 other); Fri, 17 Jul 2020 02:24:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726656AbgGQGYK (ORCPT ); Fri, 17 Jul 2020 02:24:10 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75F00C08C5C0; Thu, 16 Jul 2020 23:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=/E3yYoXC157551h6xowHq2pNR018OFBhJ9Arvav070Y=; b=o6zhOep28KSjcnYm3J9aHcpkgm O2Fcz0+9OvZMn6mbYHPBFH/fhpi9DoauQT0ncpn5viSfaoFF6bLsJITCRXjgfdyqFLmf4LW5Djzbq mVD4a9wW/2LPyab9lB73mzm+FvayvQ+EgI8+vOBPzlrpsBjPVCB3G88FaBPOFgmA9Mu2nVuQYxlZH 5LqOFVBqwVr859Q4epbLvsmne1egzV1tTu7+l4QNJED3wUW/yW3Y/QVQJEeAZPJymdlnG4fe6WTAC BSzIX9qF0b7Pb8owGsYurQp2qXY/WMlbn+gcpCALS7U1mCseHNtxJKPafipfiMwCKx140COitXOWS xalq63Mw==; Received: from [2001:4bb8:105:4a81:3772:912d:640:e6c6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwJmk-00051o-Jr; Fri, 17 Jul 2020 06:23:55 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Alexei Starovoitov , Daniel Borkmann , Chas Williams <3chas3@gmail.com>, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: [PATCH 03/22] net: streamline __sys_getsockopt Date: Fri, 17 Jul 2020 08:23:12 +0200 Message-Id: <20200717062331.691152-4-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1E641A1FE5 X-Rspamd-UID: 87bffc Return early when sockfd_lookup_light fails to reduce a level of indentation for most of the function body. Signed-off-by: Christoph Hellwig --- net/socket.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/net/socket.c b/net/socket.c index 49a6daf0293b83..b79376b17b45b7 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2163,28 +2163,25 @@ static int __sys_getsockopt(int fd, int level, int optname, int max_optlen; sock = sockfd_lookup_light(fd, &err, &fput_needed); - if (sock != NULL) { - err = security_socket_getsockopt(sock, level, optname); - if (err) - goto out_put; + if (!sock) + return err; - max_optlen = BPF_CGROUP_GETSOCKOPT_MAX_OPTLEN(optlen); + err = security_socket_getsockopt(sock, level, optname); + if (err) + goto out_put; - if (level == SOL_SOCKET) - err = - sock_getsockopt(sock, level, optname, optval, + max_optlen = BPF_CGROUP_GETSOCKOPT_MAX_OPTLEN(optlen); + + if (level == SOL_SOCKET) + err = sock_getsockopt(sock, level, optname, optval, optlen); + else + err = sock->ops->getsockopt(sock, level, optname, optval, optlen); - else - err = - sock->ops->getsockopt(sock, level, optname, optval, - optlen); - err = BPF_CGROUP_RUN_PROG_GETSOCKOPT(sock->sk, level, optname, - optval, optlen, - max_optlen, err); + err = BPF_CGROUP_RUN_PROG_GETSOCKOPT(sock->sk, level, optname, optval, + optlen, max_optlen, err); out_put: - fput_light(sock->file, fput_needed); - } + fput_light(sock->file, fput_needed); return err; } -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yIKMHhmlEV/XFAAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 15:18:17 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sBuVHBmlEV8KgQEADc0bRg (envelope-from ); Fri, 17 Jul 2020 15:18:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 41E6A4C48A; Fri, 17 Jul 2020 15:18:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726848AbgGQNSE (ORCPT + 1 other); Fri, 17 Jul 2020 09:18:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbgGQNSD (ORCPT ); Fri, 17 Jul 2020 09:18:03 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11476C08C5CE for ; Fri, 17 Jul 2020 06:18:03 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id h19so12534448ljg.13 for ; Fri, 17 Jul 2020 06:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=YM/u3gjvM4q2JWx7UhekKDRsr2AbTo4qfrXy3xVIS9k=; b=sf/T5sXRhkN8YEk+EOhFcH7el1N/kDRdyYraixUm9LORleyvBRdP8ykec29CpkXDZ0 XdWo4qDS1Eb3DhdzVwzo3n7xUQVm7CNj//prYhxniDyOhmZgnDxQq2loH/Q1zmNqNpw1 lB8Qmjes7B8dWb1K+U5rZm9CwsCECVIpnOt3TWQ8DL4f4muqq9Bsc8cf06KfSeuQYX50 2IbpMhKO+GSpgked7oB5bNy8GmbF/7mxtbN+DMyEhnj92oIcfQPJ53kNUUSYjZMYWn8V FX0kTIWd/AuJ37dNa7Ivap7Qnqg8eIGtZoFy5rLiFsUVU4H+aiD9jnatv4aor2jp97pk MGKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=YM/u3gjvM4q2JWx7UhekKDRsr2AbTo4qfrXy3xVIS9k=; b=K9+BLaEtZkEHaSnoMZ8TjiToVetnk4fKOVP48eitTDqSVmCnvrE4p8+wnugiRTaMkx Ut76zbMQC9wBfkRaUYe85mx5VAJr6W9g6r/wXE8wmAo0xVRmOG7zzOqQq6QQZ+bdHtgy 7pkRaxPBAiw3/M8hyrSP5XaY6VDlR5uWkhSNMSWAH38Qt8EgddOzCf64KHTKw9Gu0NgY GZR7t11MDlZs2aqEaDKWgNfjC+DdjblL0dInO/fJx54tKuspdt2fXf1FAx/+/KLx0nIN vHq+Nt44dRa+f5atSVkLsVS5wbXQ1ScLfpvD06VRX9BxalFF1SXD21MSMzMOdgcPPtDt 8slQ== X-Gm-Message-State: AOAM530DB5jJ3AEDboBJObO4PIqplGVo4X+7dXDnOBj7LJm4uDifp5Jv 1PZ71BKa+Y725iKCwnKUOkhiW1a8Bo8iQ5VHOsABaA== X-Google-Smtp-Source: ABdhPJzyiKZ2NKZx86wa+HGnmDvLl67Vrz1HhWzCdoYhwu2nhGboSac3BbZ6dVMwxJ5PgjdsgB9Ac7A5V093fgDDewk= X-Received: by 2002:a2e:910c:: with SMTP id m12mr4340344ljg.274.1594991881148; Fri, 17 Jul 2020 06:18:01 -0700 (PDT) MIME-Version: 1.0 References: <20200627105437.453053-1-apusaka@google.com> <20200627185320.RFC.v1.1.Icea550bb064a24b89f2217cf19e35b4480a31afd@changeid> <91CFE951-262A-4E83-8550-25445AE84B5A@holtmann.org> <7BBB55E0-FBD9-40C0-80D9-D5E7FC9F80D2@holtmann.org> In-Reply-To: From: Alain Michaud Date: Fri, 17 Jul 2020 09:17:49 -0400 Message-ID: Subject: Re: [RFC PATCH v1 1/2] Bluetooth: queue ACL packets if no handle is found To: Marcel Holtmann Cc: Archie Pusaka , linux-bluetooth , chromeos-bluetooth-upstreaming , Abhishek Pandit-Subedi , "David S. Miller" , Jakub Kicinski , Johan Hedberg , kernel list , netdev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 41E6A4C48A X-Rspamd-UID: 7fa4b4 Hi Marcel, On Fri, Jul 17, 2020 at 2:51 AM Marcel Holtmann wrote= : > > Hi Alain, > > > >>> There is a possibility that an ACL packet is received before we > > >>> receive the HCI connect event for the corresponding handle. If this > > >>> happens, we discard the ACL packet. > > >>> > > >>> Rather than just ignoring them, this patch provides a queue for > > >>> incoming ACL packet without a handle. The queue is processed when > > >>> receiving a HCI connection event. If 2 seconds elapsed without > > >>> receiving the HCI connection event, assume something bad happened > > >>> and discard the queued packet. > > >>> > > >>> Signed-off-by: Archie Pusaka > > >>> Reviewed-by: Abhishek Pandit-Subedi > > >> > > >> so two things up front. I want to hide this behind a HCI_QUIRK_OUT_O= F_ORDER_ACL that a transport driver has to set first. Frankly if this kind = of out-of-order happens on UART or SDIO transports, then something is obvio= usly going wrong. I have no plan to fix up after a fully serialized transpo= rt. > > >> > > >> Secondly, if a transport sets HCI_QUIRK_OUT_OF_ORDER_ACL, then I wan= t this off by default. You can enable it via an experimental setting. The r= eason here is that we have to make it really hard and fail as often as poss= ible so that hardware manufactures and spec writers realize that something = is fundamentally broken here. > > I don't have any objection to making this explicit enable to non serial= ized transports. However, I do wonder what the intention is around making = this off by default. We already know there is a race condition between the= interupt and bulk endpoints over USB, so this can and does happen. Hardwa= re manufaturers can't relly do much about this other than trying to pull th= e interupt endpoint more often, but that's only a workaround, it can't avoi= d it all together. > > > > IMO, this seems like a legitimate fix at the host level and I don't see= any obvious benefits to hide this fix under an experimental feature and ma= ke it more difficult for the customers and system integrators to discover. > > the problem is that this is not a fix. It is papering over a hole and at = best a workaround with both eyes closed and hoping for the best. I am not l= ooking forward for the first security researcher to figure out that they ha= ve a chance to inject an unencrypted packet since we are waiting 2 seconds = for the USB transport to get its act together. I don't think this is the right characterization but I agree, 2 seconds would be too long, it would ideally be no longer than the USB polling interval diff. > > In addition, I think that Luiz attempt to align with the poll intervals i= nside the USB transport directly is a cleaner and more self-contained appro= ach. It also reduces the window of opportunity for any attacker since we ac= tually align the USB transport specific intervals with each other. I'll have to look at Luiz's patch and think through if this really eliminates the problem. If may indeed be a more practical approach to this problem. > > Regards > > Marcel > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GOvhAeiqEV8qOAAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 15:43:04 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aKyVAOiqEV83zgAAlp8NpQ (envelope-from ); Fri, 17 Jul 2020 15:43:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 51F7840873; Fri, 17 Jul 2020 15:42:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726210AbgGQNm5 (ORCPT + 1 other); Fri, 17 Jul 2020 09:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbgGQNm5 (ORCPT ); Fri, 17 Jul 2020 09:42:57 -0400 Received: from mail-vs1-xe36.google.com (mail-vs1-xe36.google.com [IPv6:2607:f8b0:4864:20::e36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E9D2C061755 for ; Fri, 17 Jul 2020 06:42:57 -0700 (PDT) Received: by mail-vs1-xe36.google.com with SMTP id o184so4883202vsc.0 for ; Fri, 17 Jul 2020 06:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GGV1wbj0653P2xg+RLSu9dXMV9pkHnXxYlofmrHKvcc=; b=WeuJSBRc31y8MSyH7T1a0bhW+jM124fD+aojzvjSwvpGXIolPgVXtJD4nwdJZ2a25z +jIUyUrNqxnL48bKJW7FJHqLxIB+dmaHHi4Njk+/mjPrOUuTiQioveu8Vo+I48JhqZnP PC1nm0ke1huFdTbtwfXwTDUwuI6HujDtmtSpA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GGV1wbj0653P2xg+RLSu9dXMV9pkHnXxYlofmrHKvcc=; b=SLOSaAcejGL4Ikq7LTFCw4CiGw6MxXc3nIvoVrsoUzMcbt+9ZmLSikXqOaYGgfDai2 tDbxngfi+c/GU9mLsEdhReIrgOReEsuqeHYaddVSxRBeAub2hgnWWANuIYe5AtuOAYZ4 Hkzu0nsn//qMFLmtMznv5bc7MqSWngcpzTK+etXibcnn4wDPi8bMLqHzIiW1lvXz5F6L c+WX+N2dDo8vhaCJAebxNIIchYsMguODbra0WLG7GYBQmaReLrm+g0WjcqNv54Qb/v95 hmwVQXk5mXoixiJNDQSnEUt5V3T89vzgaTuEZaQX5HutqMMDuLtkI2hly3h7xC1KyhPF Hy+A== X-Gm-Message-State: AOAM531BWTKH2utWRVXGnO2pLOO4negmDUvy96mh2bksZHN8DzXIAvJV H/DgE5pPL3db5JoGTZYb9WFwYOH+img= X-Google-Smtp-Source: ABdhPJydS4102D2m3mKfJ/ZoyExOuZGC68+yR+0z60/EnqvDLx9QUGX6QtUafv51qXSL6bplDBYB2g== X-Received: by 2002:a67:f50e:: with SMTP id u14mr7026446vsn.240.1594993375512; Fri, 17 Jul 2020 06:42:55 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id q11sm1283385vkn.47.2020.07.17.06.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 06:42:54 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud , Miao-chen Chou Subject: [Bluez PATCH] gatt: Support DeviceInfo Service when vid/pid is specified Date: Fri, 17 Jul 2020 13:42:51 +0000 Message-Id: <20200717134251.3148686-1-alainm@chromium.org> X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 51F7840873 X-Rspamd-UID: eca622 This patch adds support for the PNPID characteristic when configured in main.conf. This was validated as read correclty both by manually reading the valud and confirming in the Ellisys Analyzer. ATT Read (PnP ID: Source=Bluetooth ID, Vendor=224, Product=50181, ATT Read Response Packet (Source=Bluetooth ID, Vendor=224, Product=50181, Version=86) | OK | 7 bytes (01 E0 00 05 C4 56 00) Reviewed-by: Miao-chen Chou Signed-off-by: Alain Michaud --- I admit I don't know how to quantify the compatibility risk with adding the Device Info Service if the DeviceID is specified. I can see that some system may be configured with an app to publish the DIS and this may break it. If the community feels it is necessary, I can include a DeviceIdOverLE configuration which defaults to false in main.conf to address this compatibility risk. peripheral/gatt.c | 28 +++++++++++++++++++++++++++- src/gatt-database.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/peripheral/gatt.c b/peripheral/gatt.c index bbbf3f59f..aeb286563 100644 --- a/peripheral/gatt.c +++ b/peripheral/gatt.c @@ -41,11 +41,13 @@ #include "src/shared/gatt-db.h" #include "src/shared/gatt-server.h" #include "src/shared/gatt-client.h" +#include "src/hcid.h" #include "peripheral/gatt.h" #define ATT_CID 4 #define UUID_GAP 0x1800 +#define UUID_DIS 0x180a struct gatt_conn { struct bt_att *att; @@ -229,14 +231,38 @@ static void populate_gap_service(struct gatt_db *db) gatt_db_service_set_active(service, true); } +static void device_info_read_pnp_id_cb(struct gatt_db_attribute *attrib, + unsigned int id, uint16_t offset, + uint8_t opcode, struct bt_att *att, + void *user_data) +{ + uint8_t pdu[7]; + + pdu[0] = main_opts.did_source; + put_le16(main_opts.did_vendor, &pdu[1]); + put_le16(main_opts.did_product, &pdu[3]); + put_le16(main_opts.did_version, &pdu[5]); + + gatt_db_attribute_read_result(attrib, id, 0, pdu, sizeof(pdu)); +} + static void populate_devinfo_service(struct gatt_db *db) { struct gatt_db_attribute *service; bt_uuid_t uuid; - bt_uuid16_create(&uuid, 0x180a); + bt_uuid16_create(&uuid, UUID_DIS); service = gatt_db_add_service(db, &uuid, true, 17); + if (main_opts.did_source > 0) { + bt_uuid16_create(&uuid, GATT_CHARAC_PNP_ID); + gatt_db_service_add_characteristic(service, &uuid, + BT_ATT_PERM_READ, + BT_GATT_CHRC_PROP_READ, + device_info_read_pnp_id_cb, + NULL, NULL); + } + gatt_db_service_set_active(service, true); } diff --git a/src/gatt-database.c b/src/gatt-database.c index 95ba39897..07d567078 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -57,6 +57,7 @@ #define UUID_GAP 0x1800 #define UUID_GATT 0x1801 +#define UUID_DIS 0x180a #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -1233,11 +1234,51 @@ static void populate_gatt_service(struct btd_gatt_database *database) database_add_record(database, service); } +static void device_info_read_pnp_id_cb(struct gatt_db_attribute *attrib, + unsigned int id, uint16_t offset, + uint8_t opcode, struct bt_att *att, + void *user_data) +{ + uint8_t pdu[7]; + + pdu[0] = main_opts.did_source; + put_le16(main_opts.did_vendor, &pdu[1]); + put_le16(main_opts.did_product, &pdu[3]); + put_le16(main_opts.did_version, &pdu[5]); + + gatt_db_attribute_read_result(attrib, id, 0, pdu, sizeof(pdu)); +} + +static void populate_devinfo_service(struct btd_gatt_database *database) +{ + struct gatt_db_attribute *service; + bt_uuid_t uuid; + + bt_uuid16_create(&uuid, UUID_DIS); + service = gatt_db_add_service(database->db, &uuid, true, 3); + + if (main_opts.did_source > 0) { + bt_uuid16_create(&uuid, GATT_CHARAC_PNP_ID); + gatt_db_service_add_characteristic(service, &uuid, + BT_ATT_PERM_READ, + BT_GATT_CHRC_PROP_READ, + device_info_read_pnp_id_cb, + NULL, database); + } + + gatt_db_service_set_active(service, true); + + database_add_record(database, service); +} static void register_core_services(struct btd_gatt_database *database) { populate_gap_service(database); populate_gatt_service(database); + + if (main_opts.did_source > 0) + populate_devinfo_service(database); + } static void conf_cb(void *user_data) -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MLx6AoOsEV8qOAAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 15:49:55 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id GPD7AIOsEV8/NAEA0J78UA (envelope-from ); Fri, 17 Jul 2020 15:49:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B13EBA1230; Fri, 17 Jul 2020 15:49:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726210AbgGQNtt (ORCPT + 1 other); Fri, 17 Jul 2020 09:49:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726090AbgGQNts (ORCPT ); Fri, 17 Jul 2020 09:49:48 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEF60C0619D2 for ; Fri, 17 Jul 2020 06:49:48 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id t11so4252584qvk.1 for ; Fri, 17 Jul 2020 06:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=nnuXue4VpiaVRfmSKwPcfaE5TO3Q1PfHQRTDKc6/neo=; b=pTno8HzbMur81prIPrhO1FIZ2hqnsFdpcfs2FlKtQ3xOqAWBANNcpsdA3I2EZHSs5/ 03IUtdsy6UVDGP1Tha4xW0Cg3g8vmazf91+wFaQUjkHpr/KzEyBaPiL4VzqJgF1qu+Ue K/oYf3bTbQCVgT/ISb7qMh+D+6DJcBam0SNl1W0Kj8FRQUCuJBm9uXNvDBORbU8cpDgW WgpR5L5H3C0BZKDDdOjZbVXvT74IZYNCWi31H3rzaMpBxtvt8cOwyztDgDDydTwGj0eS 2W1l1CAwbY3uAW4othxmx7/uGyr15+HbvBcdn5O70CRfFXYEvCf5Nhy2ofyBPK9yfAhV 5fnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=nnuXue4VpiaVRfmSKwPcfaE5TO3Q1PfHQRTDKc6/neo=; b=g/bfwJhdgmL3GRSywPLGggarCzUxHXwZ/bBOEMcfhRodILaB4rnwJWya595gloOv1z FEsMWPy31FjEZRmxfWo4VtrKmYEO4S5khRy/mjyYh1fJqLOrEKLh7GBDW4RcDMzV5+8C VSRwrwBnln26G7NlL5pfWbUwmrSAzW5JZzdKX0GUX80PrxlLLcKFCe5TpBCT1qbe/Y53 7IkMMBNXU0HR4w/loIKMrsrdUZi0ycKADZMU8UBc8jud9to6IXTeu5ggRvEPHi/NjOSq oXcO4U/qrXx0zHDlNC8/EeroBMtbQV7OLgUdwhFtd4aEN6Ft0VZEDoHWmJIBSYH7jGr4 yT9Q== X-Gm-Message-State: AOAM532vS/eX+avaLDgzg8WagVHf3k4L7x2HUmjuihHU1mqnfwMGZsR6 0b+PJVTZOtQq23z9/usvT8udlUcUqts= X-Google-Smtp-Source: ABdhPJy3O6eDXut/VYnCg9PTpu3AfB7bu9hx9OcDZvozaxXJCV/xlklIz8gsF/O2ANMEelzQssB7FQ== X-Received: by 2002:ad4:4903:: with SMTP id bh3mr9182562qvb.17.1594993787836; Fri, 17 Jul 2020 06:49:47 -0700 (PDT) Received: from [172.17.0.2] ([52.225.230.214]) by smtp.gmail.com with ESMTPSA id g1sm11779544qko.70.2020.07.17.06.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 06:49:47 -0700 (PDT) Message-ID: <5f11ac7b.1c69fb81.2b25.91a8@mx.google.com> Date: Fri, 17 Jul 2020 06:49:47 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============0820563623741101674==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, alainm@chromium.org Subject: RE: [Bluez] gatt: Support DeviceInfo Service when vid/pid is specified Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200717134251.3148686-1-alainm@chromium.org> References: <20200717134251.3148686-1-alainm@chromium.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 40 X-Rspamd-Score: 6.13 / 15.00 / 200.00 X-Rspamd-Queue-Id: B13EBA1230 X-Rspamd-UID: 9e5e9a --===============0820563623741101674== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCkluIGZpbGUgaW5jbHVkZWQgZnJvbSBwZXJpcGhlcmFsL2dhdHQuYzo0 NDoKLi9zcmMvaGNpZC5oOjUzOjI6IGVycm9yOiB1bmtub3duIHR5cGUgbmFtZSDigJhnYm9vbGVh buKAmQogICA1MyB8ICBnYm9vbGVhbiBwYWlyYWJsZTsKICAgICAgfCAgXn5+fn5+fn4KLi9zcmMv aGNpZC5oOjk5OjI6IGVycm9yOiB1bmtub3duIHR5cGUgbmFtZSDigJhnYm9vbGVhbuKAmQogICA5 OSB8ICBnYm9vbGVhbiByZXZlcnNlX2Rpc2NvdmVyeTsKICAgICAgfCAgXn5+fn5+fn4KLi9zcmMv aGNpZC5oOjEwMDoyOiBlcnJvcjogdW5rbm93biB0eXBlIG5hbWUg4oCYZ2Jvb2xlYW7igJkKICAx MDAgfCAgZ2Jvb2xlYW4gbmFtZV9yZXNvbHY7CiAgICAgIHwgIF5+fn5+fn5+Ci4vc3JjL2hjaWQu aDoxMDE6MjogZXJyb3I6IHVua25vd24gdHlwZSBuYW1lIOKAmGdib29sZWFu4oCZCiAgMTAxIHwg IGdib29sZWFuIGRlYnVnX2tleXM7CiAgICAgIHwgIF5+fn5+fn5+Ci4vc3JjL2hjaWQuaDoxMDI6 MjogZXJyb3I6IHVua25vd24gdHlwZSBuYW1lIOKAmGdib29sZWFu4oCZCiAgMTAyIHwgIGdib29s ZWFuIGZhc3RfY29ubjsKICAgICAgfCAgXn5+fn5+fn4KLi9zcmMvaGNpZC5oOjEyMjoxOiBlcnJv cjogdW5rbm93biB0eXBlIG5hbWUg4oCYZ2Jvb2xlYW7igJkKICAxMjIgfCBnYm9vbGVhbiBwbHVn aW5faW5pdChjb25zdCBjaGFyICplbmFibGUsIGNvbnN0IGNoYXIgKmRpc2FibGUpOwogICAgICB8 IF5+fn5+fn5+Ci4vc3JjL2hjaWQuaDoxMjg6MTogZXJyb3I6IHVua25vd24gdHlwZSBuYW1lIOKA mEdLZXlGaWxl4oCZCiAgMTI4IHwgR0tleUZpbGUgKmJ0ZF9nZXRfbWFpbl9jb25mKHZvaWQpOwog ICAgICB8IF5+fn5+fn5+Cm1ha2VbMV06ICoqKiBbTWFrZWZpbGU6Njc5MTogcGVyaXBoZXJhbC9n YXR0Lm9dIEVycm9yIDEKbWFrZTogKioqIFtNYWtlZmlsZTo0MDEwOiBhbGxdIEVycm9yIDIKCgoK LS0tClJlZ2FyZHMsCkxpbnV4IEJsdWV0b290aAo= --===============0820563623741101674==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yOcaCMK7EV9hmQAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 16:54:58 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wKgIB8K7EV8v9gAAlp8NpQ (envelope-from ); Fri, 17 Jul 2020 16:54:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7861040B7A; Fri, 17 Jul 2020 16:54:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726691AbgGQOkN (ORCPT + 1 other); Fri, 17 Jul 2020 10:40:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726429AbgGQOkM (ORCPT ); Fri, 17 Jul 2020 10:40:12 -0400 Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B55C4C0619D2 for ; Fri, 17 Jul 2020 07:40:12 -0700 (PDT) Received: by mail-vs1-xe33.google.com with SMTP id q15so4968758vso.9 for ; Fri, 17 Jul 2020 07:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZjUlDVuPtPdSCx+f/FpW9ivNQqmi/K/CqsiUpmcooyw=; b=d28AYG6k+lZi39HwDNYPvF7uULiV5EDpThgcn1pcvl8g5BDJr4dF858+vgDprun91l OeN7tM1d9JEHbZea8mYcpZ5VHTPTCPADLue85ZVtUnnQtWXnf/D4vblPQVSkF88oGl0I aH0YfyCtPEgLGp8Quuvas797NM0ESRvX4bz3c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZjUlDVuPtPdSCx+f/FpW9ivNQqmi/K/CqsiUpmcooyw=; b=jVA6Zwf0D3/Ct9d9+G/jG4xAVhppww+KJPBOl5Nj9M+o9S5KqPfly3I50uEE3Doo2r VGpuqlEJWk82FCNTXjEZFsxY5fs/mXQAhDONyg6XUv0d3gbr8OeVakPGvbjSn9QV1zWQ ofF9+eEvJeLTa/AESW7l69Bf2XK4ozthMXqo0dvXE9DVoeAYDHtfvhjthHsreoBgqE4i y3eCXuUfTFK5t++ZLauHokumDI6BDaN2jbvQYXu3nq7Yn9W84qOr9Ho3MhavFL6PXylV y5noTwsAYUU3/CpRRoYaD0SLz2uH7E96AQJMv0SEpaDYYMv0MgvBo8Apu0wh9IHKOxlh mwxA== X-Gm-Message-State: AOAM530DtS4ZDiANwgyDjZGeScgY2qZJ8yv5/aAoscL3sr9llmu99dHO /3cTo34YE9r88OOJVOtfLPIABhAIIRM= X-Google-Smtp-Source: ABdhPJyaNo5h4VZSx0cj1tXHlgthFAXiKKM1297/45YNRzmLc4pcXcZi0zpvrfvfAmc8XbjNzQ3fFg== X-Received: by 2002:a67:cb03:: with SMTP id b3mr7815318vsl.214.1594996811360; Fri, 17 Jul 2020 07:40:11 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id 132sm1206123vkb.2.2020.07.17.07.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 07:40:10 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud , Miao-chen Chou Subject: [Bluez PATCH v2] gatt: Support DeviceInfo Service when vid/pid is specified Date: Fri, 17 Jul 2020 14:40:07 +0000 Message-Id: <20200717144007.3160721-1-alainm@chromium.org> X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 23 X-Rspamd-Score: 3.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7861040B7A X-Rspamd-UID: d1d9d0 This patch adds support for the PNPID characteristic when configured in main.conf. This was validated as read correclty both by manually reading the valud and confirming in the Ellisys Analyzer. ATT Read (PnP ID: Source=Bluetooth ID, Vendor=224, Product=50181, ATT Read Response Packet (Source=Bluetooth ID, Vendor=224, Product=50181, Version=86) | OK | 7 bytes (01 E0 00 05 C4 56 00) Reviewed-by: Miao-chen Chou Signed-off-by: Alain Michaud --- I admit I don't know how to quantify the compatibility risk with adding the Device Info Service if the DeviceID is specified. I can see that some system may be configured with an app to publish the DIS and this may break it. If the community feels it is necessary, I can include a DeviceIdOverLE configuration which defaults to false in main.conf to address this compatibility risk. Changes in v2: - Removing file I didn't intend to commit (peripheral/gatt.c) src/gatt-database.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/gatt-database.c b/src/gatt-database.c index 95ba39897..07d567078 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -57,6 +57,7 @@ #define UUID_GAP 0x1800 #define UUID_GATT 0x1801 +#define UUID_DIS 0x180a #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -1233,11 +1234,51 @@ static void populate_gatt_service(struct btd_gatt_database *database) database_add_record(database, service); } +static void device_info_read_pnp_id_cb(struct gatt_db_attribute *attrib, + unsigned int id, uint16_t offset, + uint8_t opcode, struct bt_att *att, + void *user_data) +{ + uint8_t pdu[7]; + + pdu[0] = main_opts.did_source; + put_le16(main_opts.did_vendor, &pdu[1]); + put_le16(main_opts.did_product, &pdu[3]); + put_le16(main_opts.did_version, &pdu[5]); + + gatt_db_attribute_read_result(attrib, id, 0, pdu, sizeof(pdu)); +} + +static void populate_devinfo_service(struct btd_gatt_database *database) +{ + struct gatt_db_attribute *service; + bt_uuid_t uuid; + + bt_uuid16_create(&uuid, UUID_DIS); + service = gatt_db_add_service(database->db, &uuid, true, 3); + + if (main_opts.did_source > 0) { + bt_uuid16_create(&uuid, GATT_CHARAC_PNP_ID); + gatt_db_service_add_characteristic(service, &uuid, + BT_ATT_PERM_READ, + BT_GATT_CHRC_PROP_READ, + device_info_read_pnp_id_cb, + NULL, database); + } + + gatt_db_service_set_active(service, true); + + database_add_record(database, service); +} static void register_core_services(struct btd_gatt_database *database) { populate_gap_service(database); populate_gatt_service(database); + + if (main_opts.did_source > 0) + populate_devinfo_service(database); + } static void conf_cb(void *user_data) -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KKqlACv4EV+4wQEAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 21:12:43 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id aCdeOir4EV/UpwAADc0bRg (envelope-from ); Fri, 17 Jul 2020 21:12:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F2C5AA1306; Fri, 17 Jul 2020 21:12:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728729AbgGQTMQ (ORCPT + 1 other); Fri, 17 Jul 2020 15:12:16 -0400 Received: from mxout04.lancloud.ru ([89.108.124.63]:33434 "EHLO mxout04.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728706AbgGQTMO (ORCPT ); Fri, 17 Jul 2020 15:12:14 -0400 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout04.lancloud.ru 688C520F54C0 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH RFC] bluetooth: add support for some old headsets To: Marcel Holtmann CC: Johan Hedberg , Bluetooth Kernel Mailing List , "David S. Miller" , Jakub Kicinski , , "Ildar Kamaletdinov" References: <6f461412-a6c0-aa53-5e74-394e278ee9b1@omprussia.ru> <1834765D-52E6-45B8-9923-778C9182CFA9@holtmann.org> <848144D3-85F9-47F8-8CDA-02457FA7530F@holtmann.org> From: Sergey Shtylyov Organization: Open Mobile Platform, LLC Message-ID: <0c2a8da1-6071-6597-d0d1-32ce1490aba7@omprussia.ru> Date: Fri, 17 Jul 2020 22:12:09 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <848144D3-85F9-47F8-8CDA-02457FA7530F@holtmann.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [213.87.156.29] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1908.lancloud.ru (fd00:f066::208) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 20 X-Rspamd-Score: 3.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: F2C5AA1306 X-Rspamd-UID: 9f93d5 On 7/17/20 9:59 AM, Marcel Holtmann wrote: >>>> The MediaTek Bluetooth platform (MT6630 etc.) has a peculiar implementation >>>> for the eSCO/SCO connection via BT/EDR: the host controller returns error >>>> code 0x20 (LMP feature not supported) for HCI_Setup_Synchronous_Connection >>>> (0x0028) command without actually trying to setup connection with a remote >>>> device in case such device (like Digma BT-14 headset) didn't advertise its >>>> supported features. Even though this doesn't break compatibility with the >>>> Bluetooth standard it breaks the compatibility with the Hands-Free Profile >>>> (HFP). >>>> >>>> This patch returns the compatibility with the HFP profile and actually >>>> tries to check all available connection parameters despite of the specific >>>> MediaTek implementation. Without it one was unable to establish eSCO/SCO >>>> connection with some headsets. >>> >>> please include the parts of btmon output that show this issue. >> >> Funny, I had removed that part from the original patch. Here's that log: >> >> < HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17 #1 [hci0] 6.705320 >> Handle: 50 >> Transmit bandwidth: 8000 >> Receive bandwidth: 8000 >> Max latency: 10 >> Setting: 0x0060 >> Input Coding: Linear >> Input Data Format: 2's complement >> Input Sample Size: 16-bit >> of bits padding at MSB: 0 >> Air Coding Format: CVSD >> Retransmission effort: Optimize for power consumption (0x01) >> Packet type: 0x0380 >> 3-EV3 may not be used >> 2-EV5 may not be used >> 3-EV5 may not be used >>> HCI Event: Command Status (0x0f) plen 4 #2 [hci0] 6.719598 >> Setup Synchronous Connection (0x01|0x0028) ncmd 1 >> Status: Unsupported LMP Parameter Value / Unsupported LL Parameter Value (0x20) > I double check with the specification and it is not precise that errors should be reported > via sync conn complete events. My assumption would be that your headset only supports SCO and > thus the controller realizes that eSCO request can not be completed anyway. So the controller > opts for quickest path to get out of this. >>>> Based on the patch by Ildar Kamaletdinov . Adding him to CC... >>>> >>>> Signed-off-by: Sergey Shtylyov >>>> >>>> --- >>>> This patch is against the 'bluetooth-next.git' repo. >>>> >>>> net/bluetooth/hci_event.c | 8 ++++++++ >>>> 1 file changed, 8 insertions(+) >>>> >>>> Index: bluetooth-next/net/bluetooth/hci_event.c >>>> =================================================================== >>>> --- bluetooth-next.orig/net/bluetooth/hci_event.c >>>> +++ bluetooth-next/net/bluetooth/hci_event.c >>>> @@ -2187,6 +2187,13 @@ static void hci_cs_setup_sync_conn(struc >>>> if (acl) { >>>> sco = acl->link; >>>> if (sco) { >>>> + if (status == 0x20 && /* Unsupported LMP Parameter value */ >>>> + sco->out) { Actually, I was expecting that you'd tell me to create a HCI quirk for this situation. I have a patch doing that but I haven't been able to locate the driver in which to set this quirk flag... >>>> + sco->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | >>>> + (hdev->esco_type & EDR_ESCO_MASK); >>>> + if (hci_setup_sync(sco, sco->link->handle)) >>>> + goto unlock; >>>> + } >>>> sco->state = BT_CLOSED; >>> >>> since this is the command status event, I doubt that sco->out check is needed. >> >> Can't comment oin this, my BT fu is too weak... > It is the case. Command status is only local to command we issued and thus in this case it > is the connection creation attempt from our side. Meaning it is always outgoing. Ildar, what do you think? > Regards > > Marcel MBR, Sergei Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GAGuEM74EV9mCgAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 21:15:26 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 0EoDD874EV/UpwAADc0bRg (envelope-from ); Fri, 17 Jul 2020 21:15:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 58556A17F8; Fri, 17 Jul 2020 21:15:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgGQTPS (ORCPT + 1 other); Fri, 17 Jul 2020 15:15:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbgGQTPS (ORCPT ); Fri, 17 Jul 2020 15:15:18 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5091AC0619D2 for ; Fri, 17 Jul 2020 12:15:18 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id ch3so6979603pjb.5 for ; Fri, 17 Jul 2020 12:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ofcSy59ESp8nBAyKdvQXxbumDxZMg6HeTOxTvE1Riuw=; b=GCvz0vrAe6peAes71/uhyAz4RxWuVIZ6EJVpFx1bpx0QH2ajnjswhEyEPoXFUROncO UWERIRfXVaF6ccdX/rGWLNkrQcgB+JpvTofCeVzF0gyIQ4BQoX+7oDV0sCeGUHYpDfeE 6g2Bus9RC30tromji8Fb39/GiCBm2DFY17leGo6DqH70X/nHfGXb1L8SNfxeO1SkWcEs zdidIoZEXKmWBOEI/dxiA/lX22eMeGiytVTUhCbx3TeSZwDMB6hHVA8NMLhVZ3f3zjJn UyYR7KhvPSkgVM6wDGVNRRA4xdpmP7MEjUJ3d8z9IdzOlKPryvkkMXbaVmm8yfEfa6eX VScg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ofcSy59ESp8nBAyKdvQXxbumDxZMg6HeTOxTvE1Riuw=; b=NC8QU44RbwaMKqQ6QeVHi0z27Hc3douw+YOLFSSruinVvsfy4SHgBxtJbvDfB1/E27 KNr7ghIv0bHYI+4NP05XLC486QoALZtZ5SsFfBYDtJXgSCf0/ZRTUOa020N/6lTDh9xr /qMwbpA8XebZoNLmdrQzz/s9B1WyqLvJpQRIlQWTPx9ghIJYKSUB0CwqaA0dQXt3VHRo 5i4PKYn62jXz1bvQgq7W2xiJjyVTXFWx5BeODO8jiPjQbq//xawRLRKZ+WXV0Lsz12sj kXW8U+Bgn3uPv13QY07QOQWyACXkhAI7B5KiDx08c3wwMxylWwKW7ElepVfikAM7Ft4s zBrQ== X-Gm-Message-State: AOAM530ooA14wO0dk35Z4H9rYtUemUTCAxLlfVKBjDGAFXaMbg2Hutk5 KtViNnx7AP/pAM2Ue58zTnvW893A/qI= X-Google-Smtp-Source: ABdhPJx/sGMBavpUlFB5fLaeOBrNdy3bilHEaO8dnIRw/UVQ6yaIX0A2p++GJWZjpEIRchuDrszixw== X-Received: by 2002:a17:90a:cc03:: with SMTP id b3mr10444585pju.80.1595013317189; Fri, 17 Jul 2020 12:15:17 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id p9sm6488334pgc.77.2020.07.17.12.15.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 12:15:16 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/5] shared/att: Fix possible crash on disconnect Date: Fri, 17 Jul 2020 12:15:11 -0700 Message-Id: <20200717191515.220621-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 58556A17F8 X-Rspamd-UID: bdb646 From: Luiz Augusto von Dentz If there are pending request while disconnecting they would be notified but clients may endup being freed in the proccess which will then be calling bt_att_cancel to cancal its requests causing the following trace: Invalid read of size 4 at 0x1D894C: enable_ccc_callback (gatt-client.c:1627) by 0x1D247B: disc_att_send_op (att.c:417) by 0x1CCC17: queue_remove_all (queue.c:354) by 0x1D47B7: disconnect_cb (att.c:635) by 0x1E0707: watch_callback (io-glib.c:170) by 0x48E963B: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.6400.4) by 0x48E9AC7: ??? (in /usr/lib/libglib-2.0.so.0.6400.4) by 0x48E9ECF: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.6400.4) by 0x1E0E97: mainloop_run (mainloop-glib.c:79) by 0x1E13B3: mainloop_run_with_signal (mainloop-notify.c:201) by 0x12BC3B: main (main.c:770) Address 0x7d40a28 is 24 bytes inside a block of size 32 free'd at 0x484A2E0: free (vg_replace_malloc.c:540) by 0x1CCC17: queue_remove_all (queue.c:354) by 0x1CCC83: queue_destroy (queue.c:73) by 0x1D7DD7: bt_gatt_client_free (gatt-client.c:2209) by 0x16497B: batt_free (battery.c:77) by 0x16497B: batt_remove (battery.c:286) by 0x1A0013: service_remove (service.c:176) by 0x1A9B7B: device_remove_gatt_service (device.c:3691) by 0x1A9B7B: gatt_service_removed (device.c:3805) by 0x1CC90B: queue_foreach (queue.c:220) by 0x1DE27B: notify_service_changed.isra.0.part.0 (gatt-db.c:369) by 0x1DE387: notify_service_changed (gatt-db.c:361) by 0x1DE387: gatt_db_service_destroy (gatt-db.c:385) by 0x1DE3EF: gatt_db_remove_service (gatt-db.c:519) by 0x1D674F: discovery_op_complete (gatt-client.c:388) by 0x1D6877: discover_primary_cb (gatt-client.c:1260) by 0x1E220B: discovery_op_complete (gatt-helpers.c:628) by 0x1E249B: read_by_grp_type_cb (gatt-helpers.c:730) by 0x1D247B: disc_att_send_op (att.c:417) by 0x1CCC17: queue_remove_all (queue.c:354) by 0x1D47B7: disconnect_cb (att.c:635) --- src/shared/att.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/src/shared/att.c b/src/shared/att.c index ed3af2920..58f23dfcb 100644 --- a/src/shared/att.c +++ b/src/shared/att.c @@ -84,6 +84,7 @@ struct bt_att { struct queue *req_queue; /* Queued ATT protocol requests */ struct queue *ind_queue; /* Queued ATT protocol indications */ struct queue *write_queue; /* Queue of PDUs ready to send */ + bool in_disc; /* Cleanup queues on disconnect_cb */ bt_att_timeout_func_t timeout_callback; bt_att_destroy_func_t timeout_destroy; @@ -222,8 +223,10 @@ static void destroy_att_send_op(void *data) free(op); } -static void cancel_att_send_op(struct att_send_op *op) +static void cancel_att_send_op(void *data) { + struct att_send_op *op = data; + if (op->destroy) op->destroy(op->user_data); @@ -631,11 +634,6 @@ static bool disconnect_cb(struct io *io, void *user_data) /* Dettach channel */ queue_remove(att->chans, chan); - /* Notify request callbacks */ - queue_remove_all(att->req_queue, NULL, NULL, disc_att_send_op); - queue_remove_all(att->ind_queue, NULL, NULL, disc_att_send_op); - queue_remove_all(att->write_queue, NULL, NULL, disc_att_send_op); - if (chan->pending_req) { disc_att_send_op(chan->pending_req); chan->pending_req = NULL; @@ -654,6 +652,15 @@ static bool disconnect_cb(struct io *io, void *user_data) bt_att_ref(att); + att->in_disc = true; + + /* Notify request callbacks */ + queue_remove_all(att->req_queue, NULL, NULL, disc_att_send_op); + queue_remove_all(att->ind_queue, NULL, NULL, disc_att_send_op); + queue_remove_all(att->write_queue, NULL, NULL, disc_att_send_op); + + att->in_disc = false; + queue_foreach(att->disconn_list, disconn_handler, INT_TO_PTR(err)); bt_att_unregister_all(att); @@ -1574,6 +1581,30 @@ bool bt_att_chan_cancel(struct bt_att_chan *chan, unsigned int id) return true; } +static bool bt_att_disc_cancel(struct bt_att *att, unsigned int id) +{ + struct att_send_op *op; + + op = queue_find(att->req_queue, match_op_id, UINT_TO_PTR(id)); + if (op) + goto done; + + op = queue_find(att->ind_queue, match_op_id, UINT_TO_PTR(id)); + if (op) + goto done; + + op = queue_find(att->write_queue, match_op_id, UINT_TO_PTR(id)); + +done: + if (!op) + return false; + + /* Just cancel since disconnect_cb will be cleaning up */ + cancel_att_send_op(op); + + return true; +} + bool bt_att_cancel(struct bt_att *att, unsigned int id) { const struct queue_entry *entry; @@ -1591,6 +1622,9 @@ bool bt_att_cancel(struct bt_att *att, unsigned int id) return true; } + if (att->in_disc) + return bt_att_disc_cancel(att, id); + op = queue_remove_if(att->req_queue, match_op_id, UINT_TO_PTR(id)); if (op) goto done; -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cFsMCtT4EV9mCgAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 21:15:32 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qB9YCNT4EV8FlQAAlScrYA (envelope-from ); Fri, 17 Jul 2020 21:15:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D87B7A17F8; Fri, 17 Jul 2020 21:15:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728209AbgGQTPU (ORCPT + 1 other); Fri, 17 Jul 2020 15:15:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbgGQTPU (ORCPT ); Fri, 17 Jul 2020 15:15:20 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FB3BC0619D2 for ; Fri, 17 Jul 2020 12:15:20 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id 207so5860653pfu.3 for ; Fri, 17 Jul 2020 12:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Q9H7Dmvj+o5rqZS7a9SM6wIi9VBpMGGwPN+3ZrU8m10=; b=dC81Zl+9VTGrL7AkP6HTC9WEGMwXKRb3Vj+ck/pu4M0S47xj8/fJap9oC8/vjC+cAz zA5B/2lQvOekItjKUy3r8YqjVQ1eW/BbWw21Q/y0VEiJY6wYMxUwOwmgbpTcTY+5c25T qMKAMHkK10rJU6BGjZqXtV8KvUNV5Qrd6/5/Ntd1WgaGK5hV4mH4lCUol4wHfX3aGHPb khLWjnDvmnp70FevaNX8kzEh9QWZjP95fLJoE0Inr1uTMVhuLCLNwZ7O2JiUov6fpBKp lF85udH9yhxBuEeGuI5/dKMJcfqqAn62DA8KLvCDY+ud3Ni8Atp32U1gA4b46mnzktY3 Liaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q9H7Dmvj+o5rqZS7a9SM6wIi9VBpMGGwPN+3ZrU8m10=; b=ojgHF7Pi1mrjdMp/IuDq6r4DguqRTPoH8p3Oc8DvLU99b3suASI7t3mikjJ+Q/wH1W wuw86rJ9qjWvbqLJDm9mVb/xM6EyZp/qspixWrPoTMYD1fSS2PZugqtrhaW0xlsvnfAu If7rjVON1RxoB3ADW/1WRTLyQ/TJacj+moQS3wrw/Yzo4od6dfMgVSrml/Ysz8d5DpzF 0hXIjL0JF6DIuqKDbuHrPmv+67KB/fdw3dXyLeguas4DUU5b/LR/z4W5jNJ9vWcUc1aF 6LhoguPghMer20HTGXS7LYT6f7wEuI75wpazBuPftK19QepmbcKH7RARwfTJr3G8cr3O WGdw== X-Gm-Message-State: AOAM530BYbyfDIrEifBlz8STNgcqYnQKqQEuEty8Qlph3vF8gl3egoyf G6iXPzwea7Y4Mbjpe5jkXKDVinNpLAA= X-Google-Smtp-Source: ABdhPJybdTArBWSGRRs9r2Rw2wXC9SD26Xnp4l2efKvY4Yc4Ffmq2sWO3feUcW/6HCiBWKutTbBbxQ== X-Received: by 2002:a05:6a00:84e:: with SMTP id q14mr9299793pfk.309.1595013319293; Fri, 17 Jul 2020 12:15:19 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id p9sm6488334pgc.77.2020.07.17.12.15.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 12:15:18 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 3/5] shared/gatt-client: Remove notification if its attribute is removed Date: Fri, 17 Jul 2020 12:15:13 -0700 Message-Id: <20200717191515.220621-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200717191515.220621-1-luiz.dentz@gmail.com> References: <20200717191515.220621-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: D87B7A17F8 X-Rspamd-UID: 90771a From: Luiz Augusto von Dentz If the attribute is being removed from the database it means the notification shall also be dropped, that way users don't have to cleanup its subscriptions themselves. --- src/shared/gatt-client.c | 70 +++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index 0b81a7a5c..e21aca1f0 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -174,9 +174,12 @@ static void request_unref(void *data) } struct notify_chrc { + struct bt_gatt_client *client; + struct gatt_db_attribute *attr; uint16_t value_handle; uint16_t ccc_handle; uint16_t properties; + unsigned int notify_id; int notify_count; /* Reference count of registered notify callbacks */ /* Pending calls to register_notify are queued here so that they can be @@ -235,6 +238,51 @@ static void find_ccc(struct gatt_db_attribute *attr, void *user_data) *ccc_ptr = attr; } +static bool match_notify_chrc(const void *data, const void *user_data) +{ + const struct notify_data *notify_data = data; + const struct notify_chrc *chrc = user_data; + + return notify_data->chrc == chrc; +} + +static void notify_data_cleanup(void *data) +{ + struct notify_data *notify_data = data; + + if (notify_data->att_id) + bt_att_cancel(notify_data->client->att, notify_data->att_id); + + notify_data_unref(notify_data); +} + +static void notify_chrc_free(void *data) +{ + struct notify_chrc *chrc = data; + + if (chrc->notify_id) + gatt_db_attribute_unregister(chrc->attr, chrc->notify_id); + + queue_destroy(chrc->reg_notify_queue, notify_data_unref); + free(chrc); +} + +static void chrc_removed(struct gatt_db_attribute *attr, void *user_data) +{ + struct notify_chrc *chrc = user_data; + struct bt_gatt_client *client = chrc->client; + struct notify_data *data; + + chrc->notify_id = 0; + + while ((data = queue_remove_if(client->notify_list, match_notify_chrc, + chrc))) + notify_data_cleanup(data); + + queue_remove(client->notify_chrcs, chrc); + notify_chrc_free(chrc); +} + static struct notify_chrc *notify_chrc_create(struct bt_gatt_client *client, uint16_t value_handle) { @@ -274,22 +322,18 @@ static struct notify_chrc *notify_chrc_create(struct bt_gatt_client *client, if (ccc) chrc->ccc_handle = gatt_db_attribute_get_handle(ccc); + chrc->client = client; + chrc->attr = attr; chrc->value_handle = value_handle; chrc->properties = properties; + chrc->notify_id = gatt_db_attribute_register(attr, chrc_removed, chrc, + NULL); queue_push_tail(client->notify_chrcs, chrc); return chrc; } -static void notify_chrc_free(void *data) -{ - struct notify_chrc *chrc = data; - - queue_destroy(chrc->reg_notify_queue, notify_data_unref); - free(chrc); -} - static bool match_notify_data_id(const void *a, const void *b) { const struct notify_data *notify_data = a; @@ -303,16 +347,6 @@ struct handle_range { uint16_t end; }; -static void notify_data_cleanup(void *data) -{ - struct notify_data *notify_data = data; - - if (notify_data->att_id) - bt_att_cancel(notify_data->client->att, notify_data->att_id); - - notify_data_unref(notify_data); -} - struct discovery_op; typedef void (*discovery_op_complete_func_t)(struct discovery_op *op, -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GPDtLNn4EV9mCgAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 21:15:37 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 0EgOKdn4EV9KnAAAlScrYA (envelope-from ); Fri, 17 Jul 2020 21:15:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4ADBAA1230; Fri, 17 Jul 2020 21:15:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728238AbgGQTPV (ORCPT + 1 other); Fri, 17 Jul 2020 15:15:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728202AbgGQTPU (ORCPT ); Fri, 17 Jul 2020 15:15:20 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AE26C0619D2 for ; Fri, 17 Jul 2020 12:15:20 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id gc9so6980696pjb.2 for ; Fri, 17 Jul 2020 12:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=gNYmXc4mJEmOu5CETp29vjI9I1CoKaM9O5sbDcmH11I=; b=iub5c/007xX6B3c843zs99TwrWVioltW41PZQX6AbfGcdi6SgxY120mV5CDc++qhbk yTszbsp6O675hDh5kYegPxk/7W3h1XEnTSD/0Q9yspPWFDxC4W2TGrbpXVM6pthuNIoW V7Tl5s6Zck3RlEfEHyovFt6dqlOpTNEnLyH6qUGpuhPrf2ebE28SfILLvzVUZ5Zq06n3 /cvRUsKw4rJL7d18zfmT9podkQUh4NnsJ8MzRb79nAP4m7W33AIEtdXp9/PjAl9MKs9H weOvCM8/yGxZcbyNfdW9mNRrs9wMgvwwRrrdxHDzGOJ17B9+jjDhIcFTVlsvooskUrHj EMGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gNYmXc4mJEmOu5CETp29vjI9I1CoKaM9O5sbDcmH11I=; b=VK3iwBd6SIQ5uUaJO1cChZUJxQj1SMcUe8zrg8qwzVHGGLrOPq4pKeZlkM0czFn8G7 1OqkPzfHm1wfcCd2HAIKMdnNrVOvTfu3kBXHbYbeXyRuiwFN5zRbOLyMyaM2THTtmy6d hK4JGvCbUpSUlC22zEkvPjJdOliptNSfYY1hMVKpdY8m6+NFCKllryctiv0XPLYy4WIM XWM9DtqgOSDaePHkaSvyZkzVnV0d9yAHcPVp7NdEO/jWW3o/vRoKZA2ozWr9xkr268oC o/gtFlenCxzqA8iVnYAJw4KzewHBT5adbJ1xyl4Q53uRLTSrmmO5DC7pH5EkgeTMIg9X SpwA== X-Gm-Message-State: AOAM532XGCqAbe6XvldFvdh9HpZAdkO4G/R83HKBhuvN/OHivDQNJ+MD 2lEYYMqCx1JExDQ9fr/ai1lIOm79WM0= X-Google-Smtp-Source: ABdhPJwAbT2zm+o2JO3CRnlgp9Dtf7KOk/A2akVkwzWFCw3/VVSf9NxriJUqRCRFxwtUbjAlinwPoA== X-Received: by 2002:a17:90a:a783:: with SMTP id f3mr11466177pjq.142.1595013318353; Fri, 17 Jul 2020 12:15:18 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id p9sm6488334pgc.77.2020.07.17.12.15.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 12:15:17 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 2/5] shared/gatt-db: Add support for notifying attribute changes Date: Fri, 17 Jul 2020 12:15:12 -0700 Message-Id: <20200717191515.220621-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200717191515.220621-1-luiz.dentz@gmail.com> References: <20200717191515.220621-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4ADBAA1230 X-Rspamd-UID: 56bfd1 From: Luiz Augusto von Dentz This enables to get notified when an attribute has been changed e.g. it is being removed so the code can detect changes changes at attribute level. --- src/shared/gatt-db.c | 103 +++++++++++++++++++++++++++++++++++++++++++ src/shared/gatt-db.h | 8 ++++ 2 files changed, 111 insertions(+) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index 5eccab3b9..e939ddc3a 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -81,6 +81,13 @@ struct notify { void *user_data; }; +struct attribute_notify { + unsigned int id; + gatt_db_attribute_cb_t removed; + gatt_db_destroy_func_t destroy; + void *user_data; +}; + struct pending_read { struct gatt_db_attribute *attrib; unsigned int id; @@ -114,6 +121,9 @@ struct gatt_db_attribute { unsigned int write_id; struct queue *pending_writes; + + unsigned int next_notify_id; + struct queue *notify_list; }; struct gatt_db_service { @@ -171,6 +181,16 @@ static void pending_write_free(void *data) pending_write_result(p, -ECANCELED); } +static void attribute_notify_destroy(void *data) +{ + struct attribute_notify *notify = data; + + if (notify->destroy) + notify->destroy(notify->user_data); + + free(notify); +} + static void attribute_destroy(struct gatt_db_attribute *attribute) { /* Attribute was not initialized by user */ @@ -179,6 +199,7 @@ static void attribute_destroy(struct gatt_db_attribute *attribute) queue_destroy(attribute->pending_reads, pending_read_free); queue_destroy(attribute->pending_writes, pending_write_free); + queue_destroy(attribute->notify_list, attribute_notify_destroy); free(attribute->value); free(attribute); @@ -208,6 +229,7 @@ static struct gatt_db_attribute *new_attribute(struct gatt_db_service *service, attribute->pending_reads = queue_new(); attribute->pending_writes = queue_new(); + attribute->notify_list = queue_new(); return attribute; @@ -352,12 +374,38 @@ static bool db_hash_update(void *user_data) return false; } +static void handle_attribute_notify(void *data, void *user_data) +{ + struct attribute_notify *notify = data; + struct gatt_db_attribute *attrib = user_data; + + if (notify->removed) + notify->removed(attrib, notify->user_data); +} + +static void notify_attribute_changed(struct gatt_db_service *service) +{ + int i; + + for (i = 0; i < service->num_handles; i++) { + struct gatt_db_attribute *attr = service->attributes[i]; + + if (!attr) + continue; + + queue_foreach(attr->notify_list, handle_attribute_notify, attr); + } +} + static void notify_service_changed(struct gatt_db *db, struct gatt_db_service *service, bool added) { struct notify_data data; + if (!added) + notify_attribute_changed(service); + if (queue_isempty(db->notify_list)) return; @@ -1993,3 +2041,58 @@ void *gatt_db_attribute_get_user_data(struct gatt_db_attribute *attrib) return attrib->user_data; } + +static bool match_attribute_notify_id(const void *a, const void *b) +{ + const struct attribute_notify *notify = a; + unsigned int id = PTR_TO_UINT(b); + + return notify->id == id; +} + +unsigned int gatt_db_attribute_register(struct gatt_db_attribute *attrib, + gatt_db_attribute_cb_t removed, + void *user_data, + gatt_db_destroy_func_t destroy) +{ + struct attribute_notify *notify; + + if (!attrib || !removed) + return 0; + + notify = new0(struct attribute_notify, 1); + notify->removed = removed; + notify->destroy = destroy; + notify->user_data = user_data; + + if (attrib->next_notify_id < 1) + attrib->next_notify_id = 1; + + notify->id = attrib->next_notify_id++; + + if (!queue_push_tail(attrib->notify_list, notify)) { + free(notify); + return 0; + } + + return notify->id; +} + +bool gatt_db_attribute_unregister(struct gatt_db_attribute *attrib, + unsigned int id) +{ + struct attribute_notify *notify; + + if (!attrib || !id) + return false; + + notify = queue_find(attrib->notify_list, match_attribute_notify_id, + UINT_TO_PTR(id)); + if (!notify) + return false; + + queue_remove(attrib->notify_list, notify); + attribute_notify_destroy(notify); + + return true; +} diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h index a0fd66c53..5bf19d302 100644 --- a/src/shared/gatt-db.h +++ b/src/shared/gatt-db.h @@ -281,3 +281,11 @@ bool gatt_db_attribute_write_result(struct gatt_db_attribute *attrib, bool gatt_db_attribute_reset(struct gatt_db_attribute *attrib); void *gatt_db_attribute_get_user_data(struct gatt_db_attribute *attrib); + +unsigned int gatt_db_attribute_register(struct gatt_db_attribute *attrib, + gatt_db_attribute_cb_t removed, + void *user_data, + gatt_db_destroy_func_t destroy); + +bool gatt_db_attribute_unregister(struct gatt_db_attribute *attrib, + unsigned int id); -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4GefGOwNEl+QFAAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 22:45:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yLMiFuwNEl9n7wAAlScrYA (envelope-from ); Fri, 17 Jul 2020 22:45:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 28AD240873; Fri, 17 Jul 2020 22:45:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728620AbgGQUp0 (ORCPT + 1 other); Fri, 17 Jul 2020 16:45:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbgGQUp0 (ORCPT ); Fri, 17 Jul 2020 16:45:26 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18D37C0619D2 for ; Fri, 17 Jul 2020 13:45:26 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id e90so7830136ote.1 for ; Fri, 17 Jul 2020 13:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RiBb+mdLL6rzhG0+D8n+DKEw2YOa8UurDsxESXSu3Ac=; b=uTtb245Ug6NNNy7NXe2I+OInAdayH7r5u7+Bx9Y+TnqAOI9ybumsqVdfJ7BKnA4w1y ZOtG0lwOnLYVQTTNWLeS8DwfbMJBtL6nPfgp5ZZUms7kWjtO0nskfdI+3rZl4IfbTC+P jIb2XRrB4NXjNmyEAhcrQ4tOqNtYUvb5eq+KtKqpx42hKB5BtUr3oSpGxxk2saoQB+u9 ecAZtpG0D1urf9tL8aKLrWiTyvP4nc9v61/qZ8qJ/NUey9N4Co+fz0QdizwOcg+UueqL +Fk8cMYnPsxRaTbOeI58Eb6/lxr8RK35WrTBhDCTaL8cp6qOdrrCKnUQIw5B/7jSiNEF ftiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RiBb+mdLL6rzhG0+D8n+DKEw2YOa8UurDsxESXSu3Ac=; b=R65Geq03m4P6uoAQDFGCwrgY5PTfxqplZbnzYdrbN7vpYf7osNjHsiYt32cFvwJgrJ O39qNcbn912HYykjloxlwzFoFKLYODqf2O1M/59Xaq5csyrmGKgzaGhiTAddcvud1END u1ajnavA2Y6RNeY82COg0qZGKcbzYy6/XsIdmZVAyBgIv+otQmxyn7hQ130KHCRrnIpc DWmksuNfCj6WTsmZ9UgI/DEEBKMq1v9wYv4iI4T3wMUHNZQPzD/E4U4q4QSEvmfj9oEg y3vzlMh+2KTlfxwK6WpGExCx1Blh+J5S5hwvOdMRXUue00WAnpaaPtD/lOeFbv01/7JZ BBnQ== X-Gm-Message-State: AOAM532gTXRgVTaTG+RlGEGI7Y6wnBVhVkbzpRzHV0Njs2i5TgH4IncM ET/MV3PTiUWbgr6SZ7SB1kBFLBZgT1y8jTFQ0DU= X-Google-Smtp-Source: ABdhPJxEn3kSFfy/OgdCJyKOStq9do2MDt23v7y6taXeUpPw+vDDt0iBiekxI0X6RkvusVjgSjzN/7H4FUCWzQnw3Ls= X-Received: by 2002:a9d:5e18:: with SMTP id d24mr10146226oti.88.1595018725153; Fri, 17 Jul 2020 13:45:25 -0700 (PDT) MIME-Version: 1.0 References: <20200717191515.220621-1-luiz.dentz@gmail.com> <5f11facb.1c69fb81.6f815.57f7@mx.google.com> In-Reply-To: From: Luiz Augusto von Dentz Date: Fri, 17 Jul 2020 13:45:14 -0700 Message-ID: Subject: Re: [BlueZ,1/5] shared/att: Fix possible crash on disconnect To: Tedd Ho-Jeong An Cc: "Von Dentz, Luiz" , "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 28AD240873 X-Rspamd-UID: 585b99 Hi Tedd, On Fri, Jul 17, 2020 at 1:35 PM Tedd Ho-Jeong An wrote: > > Hi Luiz, > > The failure is from test-gatt > > DEBUG :FAIL: unit/test-gatt > > I will update the CI to include the test result. > > Regards, > Tedd > > On Fri, 2020-07-17 at 12:23 -0700, bluez.test.bot@gmail.com wrote: > > This is automated email and please do not reply to this email! > > > > Dear submitter, > > > > Thank you for submitting the patches to the linux bluetooth mailing list. > > While we are preparing for reviewing the patches, we found the following > > issue/warning. > > > > Test Result: > > makecheck Failed > > > > Outputs: > > ./test-driver: line 107: 14830 Bus error (core dumped) "$@" > > > $log_file 2>&1 > > make[3]: *** [Makefile:9726: test-suite.log] Error 1 > > make[2]: *** [Makefile:9834: check-TESTS] Error 2 > > make[1]: *** [Makefile:10228: check-am] Error 2 > > make: *** [Makefile:10230: check] Error 2 Weird, it start failing for me as well but it doesn't seems to be causing any test to fail: Total: 192, Passed: 192 (100.0%), Failed: 0, Not Run: 0 Overall execution time: 0.849 seconds FAIL unit/test-gatt (exit status: 1) > > > > > > > > --- > > Regards, > > Linux Bluetooth > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8AHXHQkaEl+YnQAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 23:37:13 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WMqdHAkaEl9FFwEADc0bRg (envelope-from ); Fri, 17 Jul 2020 23:37:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1C40FA1717; Fri, 17 Jul 2020 23:37:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726923AbgGQVhH (ORCPT + 1 other); Fri, 17 Jul 2020 17:37:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726204AbgGQVhH (ORCPT ); Fri, 17 Jul 2020 17:37:07 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27C4EC0619D2 for ; Fri, 17 Jul 2020 14:37:07 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id y22so9153963oie.8 for ; Fri, 17 Jul 2020 14:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hhUmSQousSwz/kbvYQi3hzGQnX8co6XG7O0Zkp3kB1A=; b=LRjJl1x2q8I/pT1qsGnVN9LXx33CVQsx8ys9MGgHR9an0Ew5mFwK3KdkU8bq+WADe1 KItMid9hqU6FBTU9CUW0nhEGxUDUCfBCKEidCzO6HMoAQjmKKkLcu/wAh6o+oL+bErHg iXJuFTUKSNbf9NK/5dEuQLZU9iRXKZ9iYWFrw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hhUmSQousSwz/kbvYQi3hzGQnX8co6XG7O0Zkp3kB1A=; b=KrXAxql/oCJpE5trlMOjmM0DnEBmZ6hyLCO0kooig2+VYcN12oR8t1Tl+0m1EKvSxp MclKuoesskG6xO+krFn6zl2a4+W8Pn5x7IAX2HchxNmyy+FUw2YPAGoPmLpzA5jKKa9T rjF9qeTnq7AaWn9DqDhXrXlobUAACgmmxysiyn6PYeLxLqLcBZ9CodGIS7igVS5pp0Fy 8LYp6TDQiuI47TZJE6QUGxfKDg1SGPmtQMyzg2umH0ebJw6cc9PVJJxFW2A2Shyu7S+j 2WnCqptpZ66wzyxubv5hQk2FVRy6GAOdXSpG6+9N/4+0n5Dsf9fPVxhndtMKA7Cy++Y6 bnzA== X-Gm-Message-State: AOAM531Fmlb97OVUHWft9mXrteYAeBJ7mT2KHDjj2AtzsKw2rafcdh2a pFNvynv2Ykl7VwcBGjZnbwez9jxyaqqeI/aauJfIhg== X-Google-Smtp-Source: ABdhPJxNTsm+y6J7JnJufGgddi/8Kn0pN0G+IAhW8StZoBitgdHcufaYywAVWa4r7o2DWsM74SSfaxRM7jlSqJwVEU8= X-Received: by 2002:aca:3043:: with SMTP id w64mr9074257oiw.27.1595021826525; Fri, 17 Jul 2020 14:37:06 -0700 (PDT) MIME-Version: 1.0 References: <20200715224740.238527-1-sonnysasaka@chromium.org> In-Reply-To: From: Sonny Sasaka Date: Fri, 17 Jul 2020 14:36:54 -0700 Message-ID: Subject: Re: [PATCH BlueZ v2] profile: Add exception to battery profile for external access To: Luiz Augusto von Dentz Cc: BlueZ Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1C40FA1717 X-Rspamd-UID: e810dc Thanks, Luiz. On Fri, Jul 17, 2020 at 1:38 PM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Fri, Jul 17, 2020 at 1:33 PM Luiz Augusto von Dentz > wrote: > > > > Hi Sonny, > > > > On Fri, Jul 17, 2020 at 1:17 PM Sonny Sasaka wrote: > > > > > > Friendly ping on this simple patch. > > > > > > On Wed, Jul 15, 2020 at 3:47 PM Sonny Sasaka wrote: > > > > > > > > This gives exception to battery profile to be shared both internally and > > > > externally. > > > > > > > > --- > > > > profiles/battery/battery.c | 1 + > > > > src/profile.h | 4 ++++ > > > > 2 files changed, 5 insertions(+) > > > > > > > > diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c > > > > index 4da4355a1..c9a1af4b9 100644 > > > > --- a/profiles/battery/battery.c > > > > +++ b/profiles/battery/battery.c > > > > @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = { > > > > .device_remove = batt_remove, > > > > .accept = batt_accept, > > > > .disconnect = batt_disconnect, > > > > + .external = true, > > > > }; > > > > > > > > static int batt_init(void) > > > > diff --git a/src/profile.h b/src/profile.h > > > > index 4448a2a6d..95523e50a 100644 > > > > --- a/src/profile.h > > > > +++ b/src/profile.h > > > > @@ -35,6 +35,10 @@ struct btd_profile { > > > > const char *remote_uuid; > > > > > > > > bool auto_connect; > > > > + /* Some profiles are considered safe to be handled internally and also > > > > + * be exposed in the GATT API. This flag give such profiles exception > > > > + * from being claimed internally. > > > > + */ > > > > bool external; > > > > > > > > int (*device_probe) (struct btd_service *service); > > > > -- > > > > 2.26.2 > > > > > > > > I've might have forgotten to announce it on the mailing list but this > > has been applied for a while: > > > > commit 0509a4a217256ac46020b957a6532dc150729748 (HEAD -> master) > > Author: Sonny Sasaka > > Date: Wed Jul 15 15:47:40 2020 -0700 > > > > profile: Add exception to battery profile for external access > > > > This gives exception to battery profile to be shared both internally and > > externally. > > Nevermind, it was just in my local tree for some reason, now I've applied it. > > -- > Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KIv4Nd74EV+4wQEAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 21:15:42 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id kMcFNN74EV+nlgAAlScrYA (envelope-from ); Fri, 17 Jul 2020 21:15:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B5A38A1664; Fri, 17 Jul 2020 21:15:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728312AbgGQTPV (ORCPT + 1 other); Fri, 17 Jul 2020 15:15:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728202AbgGQTPV (ORCPT ); Fri, 17 Jul 2020 15:15:21 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05D38C0619D2 for ; Fri, 17 Jul 2020 12:15:21 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id md7so6852863pjb.1 for ; Fri, 17 Jul 2020 12:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ATkHjHvmlTIlEcbg7ocsMTKN2/DIf8EdCBGX5pPpsu0=; b=plKj0A5+0+pIQ5vMicUPmk9ttxFrwTUGYF8Xu/pS1rQl5/Og4uvrMV4/pUyatNu/Rm w9++F9MlP4p48IqyQqDmFZS590VNPq97qfr39iwycqZEFEI0uAvRBOMjLqy+nE9mfJ4P a80Nw/3OA1L2J8DZwNnbq+JbC807pZfCt06ljRP7xo33S9BSO4Zyze9pNdUBtoGSRUuC ooNn5aQq2V3Qv8KmzB9OVA/Vcs2IkP/AtdhhBV/Q0Y6wHVk1vhBPo/W8SBhPuWrUUFOV Q5SR1tksMlKdZXEJQs7HGAgwCWO+yPEna1o5LHJJMXueYMhxDDO+u4ZP0ebNSDlMrqAo taLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ATkHjHvmlTIlEcbg7ocsMTKN2/DIf8EdCBGX5pPpsu0=; b=SPRZUQWElscndWwOSiOBfal+AoYUez2UcywOrRJ3onjYceVF6Ue4BllhZOpHqM+TDr Y4AH3GtVa2FAi5RCPynVoHLfcf0P/P+s9dB47Zc4f263TGRf1OdiExgAUXt8XnpLBsr4 6bme2a/7gQDKhTHRZhEFtKZQ1NmNbhJMCCkNQtyup2EFRIsny5nULDuFCArDQ75HFpzt EVRvu/N1flYVSs9FX0sn/KJGWwG+7I6DnTrGsXAMmTsbyVbVAMg/uAQcY6pYfq68U5Ft h6BCDQz3Epe5D5MJIxX9nCN2xHyvvctYOluAt1XnBcz5IPx5kpllyOBv6jrkmEr0n8wG deAQ== X-Gm-Message-State: AOAM532dl0mcT4Ajdn8/NE/7bxsMy5EB8GNzRN9YSTyf2VCNshRgdrbx 53pNLeLxUhMFoTkeOSI9bNR+Uj2EWn4= X-Google-Smtp-Source: ABdhPJyw49NmFaXrDTbQS4uSKs61ZibUHgBozKcj+P/SioV7SyLcuo36bh7yxaTEioXdaj5xl0c+Sw== X-Received: by 2002:a17:90a:c28f:: with SMTP id f15mr11555127pjt.72.1595013320253; Fri, 17 Jul 2020 12:15:20 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id p9sm6488334pgc.77.2020.07.17.12.15.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 12:15:19 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 4/5] shared/gatt-client: Don't remove active services Date: Fri, 17 Jul 2020 12:15:14 -0700 Message-Id: <20200717191515.220621-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200717191515.220621-1-luiz.dentz@gmail.com> References: <20200717191515.220621-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: B5A38A1664 X-Rspamd-UID: 2eacb5 From: Luiz Augusto von Dentz If discovery was aborted (i.e due to a disconnect) check if pending services were active so only staled services which were not completed fetched are removed. --- src/shared/gatt-client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index e21aca1f0..409a3ee57 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -412,6 +412,10 @@ static void discovery_op_complete(struct discovery_op *op, bool success, struct gatt_db_attribute *attr = svc->data; uint16_t start, end; + /* Leave active services if operation was aborted */ + if ((!success && err == 0) && gatt_db_service_get_active(attr)) + continue; + gatt_db_attribute_get_service_data(attr, &start, &end, NULL, NULL); -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AL0qE7EdEl+YnQAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 23:52:49 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id AEN0EbEdEl/hhQAAlp8NpQ (envelope-from ); Fri, 17 Jul 2020 23:52:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7B83740016; Fri, 17 Jul 2020 23:52:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbgGQVwo (ORCPT + 1 other); Fri, 17 Jul 2020 17:52:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726793AbgGQVwn (ORCPT ); Fri, 17 Jul 2020 17:52:43 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3F90C0619D2 for ; Fri, 17 Jul 2020 14:52:43 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id k4so9220228oik.2 for ; Fri, 17 Jul 2020 14:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HM65dzyo59lndgA/bc5swjwlUj2IqjCWZFL5dFvIYZQ=; b=PO+sWNW/asCK96pjlUtTRg01ehPfMQfWl111aTegNAFUvKqUaIqpEfjwmC651+lRIA K64vgyXJZC4Kc/mtoB0nnxyBnjlfHMYu0bYO9OTMi2ACvEeZ2vZgweZswCIE+oMJJqHM IaUW8g85s6aGFmfSrj3Jenj4LIZRyelM46uaqWI5yUSVMncYKhHSosTiGlyx7iNcXxK8 Ems4PDtJiUHzT9pbccMr/kaMCUCEyXdwe17FlvuIH/o0e4r+7ZDqIDFXAfzAUAAW7Q1B zH4MrAlY4ptZKRkTpuzwcYHYeebCmtqOsD54q3QwkANZaNAx2dU3rNsOGyKGLoO8BbYN iNNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HM65dzyo59lndgA/bc5swjwlUj2IqjCWZFL5dFvIYZQ=; b=sfrCPBMaGh/JpiQKO79AZELqzgSF1yS+WwiK0IRcpNveYVnNm4SxCl1cSU/83iLw6E rHu/ifVLGTN8xL72+OEB7IT/yHen83RmLnxnei1EUMVTKTLw3Mb34WwfSE5BUS5QNjSg 0nWpAFTizSmGhP4+VPomh1oPghx1sMQwhRhEPKUx0IG8qGl4V8X0OEtC9aFJR4PC5I2U BWEyJvfvDGjSGt4YtAotAfARfyrmMPZxBzgFNxFflq2ItBr+tEPFwdAp4PmGqWxI3FEM ChPm34vkY2Tf8rXY4GNYigBLoAqdS9FtVUmAzBtR9MU8RtVKrSPFOdWtU4G6yv4afEgR 6Uhw== X-Gm-Message-State: AOAM533BHSdABWvIZltgSMoVMudVzmWdXofdGt3J3V2RiuYHWZwpo6Of OSXgnY7ab9srbhKCvNBQJhTo34GOMlW+rx/pSnuGpGEW X-Google-Smtp-Source: ABdhPJwFgbsl69Z0K9FU7CbNMuVM/3Kb2peBwYBn0nBxjpxCXgyBpqcpIV4ASCD9bxJtlHOoq37caUjDM7wZ4rqt8uw= X-Received: by 2002:aca:cf81:: with SMTP id f123mr9527980oig.137.1595022762823; Fri, 17 Jul 2020 14:52:42 -0700 (PDT) MIME-Version: 1.0 References: <20200717191515.220621-1-luiz.dentz@gmail.com> <5f11facb.1c69fb81.6f815.57f7@mx.google.com> In-Reply-To: From: Luiz Augusto von Dentz Date: Fri, 17 Jul 2020 14:52:31 -0700 Message-ID: Subject: Re: [BlueZ,1/5] shared/att: Fix possible crash on disconnect To: Tedd Ho-Jeong An Cc: "Von Dentz, Luiz" , "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7B83740016 X-Rspamd-UID: f57248 Hi Tedd, On Fri, Jul 17, 2020 at 1:45 PM Luiz Augusto von Dentz wrote: > > Hi Tedd, > > On Fri, Jul 17, 2020 at 1:35 PM Tedd Ho-Jeong An > wrote: > > > > Hi Luiz, > > > > The failure is from test-gatt > > > > DEBUG :FAIL: unit/test-gatt > > > > I will update the CI to include the test result. > > > > Regards, > > Tedd > > > > On Fri, 2020-07-17 at 12:23 -0700, bluez.test.bot@gmail.com wrote: > > > This is automated email and please do not reply to this email! > > > > > > Dear submitter, > > > > > > Thank you for submitting the patches to the linux bluetooth mailing list. > > > While we are preparing for reviewing the patches, we found the following > > > issue/warning. > > > > > > Test Result: > > > makecheck Failed > > > > > > Outputs: > > > ./test-driver: line 107: 14830 Bus error (core dumped) "$@" > > > > $log_file 2>&1 > > > make[3]: *** [Makefile:9726: test-suite.log] Error 1 > > > make[2]: *** [Makefile:9834: check-TESTS] Error 2 > > > make[1]: *** [Makefile:10228: check-am] Error 2 > > > make: *** [Makefile:10230: check] Error 2 > > Weird, it start failing for me as well but it doesn't seems to be > causing any test to fail: > > Total: 192, Passed: 192 (100.0%), Failed: 0, Not Run: 0 > Overall execution time: 0.849 seconds > FAIL unit/test-gatt (exit status: 1) Ive send a fix for it, there was a crash detected by valgrind which don't make the test to fail but it actually shows in the logs, there might be a way to detect the crash and make the test fail to make this more obvious. > > > > > > > > > > > > > --- > > > Regards, > > > Linux Bluetooth > > > > > -- > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cIBaN+b4EV9mCgAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 21:15:50 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QNisNeb4EV9xDAEAgupzMw (envelope-from ); Fri, 17 Jul 2020 21:15:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 06FF7A10B1; Fri, 17 Jul 2020 21:15:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728346AbgGQTPW (ORCPT + 1 other); Fri, 17 Jul 2020 15:15:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728202AbgGQTPV (ORCPT ); Fri, 17 Jul 2020 15:15:21 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEE81C0619D2 for ; Fri, 17 Jul 2020 12:15:21 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id z5so7137182pgb.6 for ; Fri, 17 Jul 2020 12:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9CGEiPF9wLML97aLDtUYlsZfnzcMXSIYdV6ccazgttk=; b=QEzvugMW3rA8H/hC61bH5KXTPgjAxuP1722fOdVyFEjhHCc4GzcHWSIC93EOC3LuZi r6we0pvaCPKQZXKcL6NVsRecO4MDz2Zy+thz1nf9HdF3AR5egnBmyTrCoJ57LtuwzzX2 6LYK727UJVvCxOMnjB0GMhXbpf3qNleD9pDyaiF5S8yPzgh7DJgVdR0BVrlQ6IF2A3mg qGTfjaJpaTsB3BqZq2aEdAMz/kQOM9xAXEnxxyTcTwVXc0XWa8ZMnmzCFMG0JLNdPyt1 V3Us5Jo1t2Rw7TRaY6aDvVNpIb7Wehvctt0l4stjs7wvvymnCvC1P0sSFZraqFu0X990 KfWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9CGEiPF9wLML97aLDtUYlsZfnzcMXSIYdV6ccazgttk=; b=T2X0JcmbMwpCLIOP1DSMG2XwlIvt3sQp5TazGca/ePyM5zPWMpWwQzYS+dT/AoQv+0 TBsGKra9xGQcJTABm3A5dV03hTwct8yhMHC9RFvqTDZwWJ65cGdfCs7LULGA2I4KZgt1 ex5RmyVDj7k6MEh7rfBmWk/EZwy727doATvyNrschYKev33PB/AmuprLjqhe2CVF8dH1 DPnkT/0C/LCGcnhzfi4d1c8IVtymrwH+pl2dnXmWkqKC2mqjx5CdNpPR4QHDO/j1Kesx WE/sw2XQds1QswIY3DmlXpDPYRQ9B34iwgguTyaX5QL+E6PLGnQtEH999JgjFjLp/mxx joZA== X-Gm-Message-State: AOAM533GXqM1AnZQwXbmWckMosNXXrpaIFwFPBnJ5iHbQ55HBaji0e1Y cilIkIizSLXgvgK+449Kfp3G//3MDcc= X-Google-Smtp-Source: ABdhPJxE/kSuEPzqBxwJlkkjCaqfKc/JiIsh92nF0YkFH7s8pgVSHeKGGpieTucKHVjYaJBDueSXCw== X-Received: by 2002:a05:6a00:78a:: with SMTP id g10mr9473873pfu.0.1595013321219; Fri, 17 Jul 2020 12:15:21 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id p9sm6488334pgc.77.2020.07.17.12.15.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 12:15:20 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 5/5] shared/gatt-client: Fix handling of service changed Date: Fri, 17 Jul 2020 12:15:15 -0700 Message-Id: <20200717191515.220621-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200717191515.220621-1-luiz.dentz@gmail.com> References: <20200717191515.220621-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 06FF7A10B1 X-Rspamd-UID: 959720 From: Luiz Augusto von Dentz When handling multiple service changed multiple discovery operations would be performed but at the end of each one the hash would be read which not only would create extra traffic but also prevents the code to properly detection services disappering. --- src/shared/gatt-client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index 409a3ee57..f6cff5014 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -1460,8 +1460,10 @@ static bool read_db_hash(struct discovery_op *op) struct bt_gatt_client *client = op->client; bt_uuid_t uuid; - /* Check if hash was already read */ - if (op->hash) + /* Check if hash was already been read or there are more services to + * process. + */ + if (op->hash || !queue_isempty(client->svc_chngd_queue)) return false; bt_uuid16_create(&uuid, GATT_CHARAC_DB_HASH); -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qAvAEw76EV9GDwAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 21:20:46 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id kNuqEQ76EV/IJAEAgupzMw (envelope-from ); Fri, 17 Jul 2020 21:20:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F25D6A1E22; Fri, 17 Jul 2020 21:20:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728592AbgGQTUg (ORCPT + 1 other); Fri, 17 Jul 2020 15:20:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728188AbgGQTUe (ORCPT ); Fri, 17 Jul 2020 15:20:34 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDB79C0619D2 for ; Fri, 17 Jul 2020 12:20:33 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id b185so9792988qkg.1 for ; Fri, 17 Jul 2020 12:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=u5hRoThFh+STXopp9GkDd8ZQnBsDrBPQnBCJRE9Iqp0=; b=iw5B9sVSI2FUImHMkCOYLWlb5NgjsoKyXgL9/pr2H0q4p4aDtxhtVzAPsQUOXdlHV4 1hRVg0e3XVEPSE6pM3Zcn90/UMUZvX9VeIKC5UQMNwwiAgsbJauoJB5/qn+IiVlM9mAI gJc7nvdHWIXuWjf65Ep2kRnsK4v1fU7u4mfSfq9K759F8P/idP+Hty+6VTcWCINlNY7V 2RXIp2gwNCl1qVkMoPxrgUaqY53NXxuinYRYCcQ6falki19aDEyDn5GIM/fO+BVFp5l8 17+64jfktp4uytO2bv+v0XGR+BhsxKRaeCa3ix/dAoAR0xOBGKX2k/9S6DKSWHt2kV7o rHCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=u5hRoThFh+STXopp9GkDd8ZQnBsDrBPQnBCJRE9Iqp0=; b=IWzAvfOFRcG3rGpgWZL3YN+EIBJg0NKNYomfjwCEWnYoAM8mbhXhwP+cqblcd9zan0 2wwCGxfrp9JqwXdErleXnBXLevBqCwRF+kYzn6UtNTqzSUksCmPhzdHsrI1VeUnz33IR MoJgsie2tWpwba8i/ApkUnJrx16XS4y8jcEFnjRQqEGn71SW7gqW+PaWXKBr4ZUU4opt OdcoXxFhXqX6DewXIeAl3SkJAlksDHPZMIExX3K7vyuf63HKE9Wq7v7LrBCRvqBabuFe qTvHpXhYxZ7FfcYD+1tO0YEoT+giRhzJ3CrYdILl1kQVuoOTZeGfV3TgDY4R45cngO5M UEeQ== X-Gm-Message-State: AOAM530HaPlNP/aNc/tB4KxbWYp+dUkfgMj6wHsUglklInNhxi71u27C R2YeNfAoX5L8F86e6A0wTC24focTV0g= X-Google-Smtp-Source: ABdhPJwd/e0TIDIrHl/xVK0PIU6JjP7ALhoOyXssIXUPy9D9MHa92PCLNkp4kbE5oyIMN/iyQcQx5w== X-Received: by 2002:a37:9dd3:: with SMTP id g202mr9972585qke.432.1595013632766; Fri, 17 Jul 2020 12:20:32 -0700 (PDT) Received: from [172.17.0.2] ([52.254.1.183]) by smtp.gmail.com with ESMTPSA id r18sm11840457qtf.62.2020.07.17.12.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 12:20:32 -0700 (PDT) Message-ID: <5f11fa00.1c69fb81.e4b2b.c619@mx.google.com> Date: Fri, 17 Jul 2020 12:20:32 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============2169838713756071571==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com Subject: RE: [BlueZ,1/5] shared/att: Fix possible crash on disconnect Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200717191515.220621-1-luiz.dentz@gmail.com> References: <20200717191515.220621-1-luiz.dentz@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 4.03 / 15.00 / 200.00 X-Rspamd-Queue-Id: F25D6A1E22 X-Rspamd-UID: 1219e2 --===============2169838713756071571== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #17: by 0x48E963B: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.6400.4) - total: 0 errors, 1 warnings, 83 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============2169838713756071571==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +AqsANP6EV9GDwAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 21:24:03 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gKSHOtL6EV8+pQAADc0bRg (envelope-from ); Fri, 17 Jul 2020 21:24:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BB8AF4086D; Fri, 17 Jul 2020 21:23:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgGQTX5 (ORCPT + 1 other); Fri, 17 Jul 2020 15:23:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727999AbgGQTX5 (ORCPT ); Fri, 17 Jul 2020 15:23:57 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3852C0619D2 for ; Fri, 17 Jul 2020 12:23:56 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id e11so9789702qkm.3 for ; Fri, 17 Jul 2020 12:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=L1YHYdUHVzgnkj9au54L/SIq6grLodhZXXb3pQoKLck=; b=JtyIn7f0kwcUBnflhCkzX6F1D/rifT/AvuXvo4Muq/9Jxr7iouX+yAM0OLCB1AT5Qb aPu9BB4muQxTgJ/ngekszTPFu70yZZ11xa8f/POgIdhlHJ1tRt4k99HDElRSsADW469M 1W5Rx1CgmuuAJAkaEglW6C53GijcEIRIlxAWenys+7Vmt3KAl0ye7TIpCWL9GqucOvxl AikYHVU14B1HGG8fWsF9JXzGasQrFdewCsrRk1jq8YXPFrGbH9bQwDwZ17aRvykkce25 bSXz2Mrw2sTlM8N7+J2Pnj6E0CbhrpLCNqAYxFUw+x+kS2vV2p3d2kgdK89Dd5zNqH0w vEMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=L1YHYdUHVzgnkj9au54L/SIq6grLodhZXXb3pQoKLck=; b=LpM3LzUaOMD2G11rBwFauoHLCwH71+JhJAMG70q4C3AsaUatWxkNCgohmFOZsifMiC rzPVe+WXevVz/6EA8SS3AbC0mLaEVOHMQ/vsEqjR3s9p1qEXabpoWKNuROSUD4BV+Zdh ktNqYdUeEwew9HFMGNFOQhecnbl167Lo/8Bfo08ks3b9mdrckkfF7CJoXPF0nfI8HhQT IqlZs78Uoz+jit4O10duMBz3ypedKwwl2p7LKo5AlK65QZkgM1wjDi2K3jtQWX+cp5rP QSxxlOhWMNOg0hHFa0ikf+AoDMywz1VVha4RCAKgLqpPB4bVtGs31Sh/ObuFBVBGujQM NwNg== X-Gm-Message-State: AOAM5306DZH0rxtlS98nrxaW7/p2T8Q7B5m879146nR6vXGmidDI5s6b vKXkqtcQ1PYr06DwWf1OBiqC4Wvo0F8= X-Google-Smtp-Source: ABdhPJy9Q/sMhoel8A5AESzEKSVg19OeRK4BaYE9scLR5mdi7dWEXx6/Dy9LQmE8g7Zs4y8jeh+www== X-Received: by 2002:ae9:e212:: with SMTP id c18mr10544877qkc.348.1595013835838; Fri, 17 Jul 2020 12:23:55 -0700 (PDT) Received: from [172.17.0.2] ([52.254.1.183]) by smtp.gmail.com with ESMTPSA id o18sm9991034qkk.91.2020.07.17.12.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 12:23:55 -0700 (PDT) Message-ID: <5f11facb.1c69fb81.6f815.57f7@mx.google.com> Date: Fri, 17 Jul 2020 12:23:55 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============4762856199470095268==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com Subject: RE: [BlueZ,1/5] shared/att: Fix possible crash on disconnect Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200717191515.220621-1-luiz.dentz@gmail.com> References: <20200717191515.220621-1-luiz.dentz@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 35 X-Rspamd-Score: 5.39 / 15.00 / 200.00 X-Rspamd-Queue-Id: BB8AF4086D X-Rspamd-UID: b1d03a --===============4762856199470095268== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: makecheck Failed Outputs: ./test-driver: line 107: 14830 Bus error (core dumped) "$@" > $log_file 2>&1 make[3]: *** [Makefile:9726: test-suite.log] Error 1 make[2]: *** [Makefile:9834: check-TESTS] Error 2 make[1]: *** [Makefile:10228: check-am] Error 2 make: *** [Makefile:10230: check] Error 2 --- Regards, Linux Bluetooth --===============4762856199470095268==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4IhEB4oGEl8qNwAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 22:14:02 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id ONyaBYoGEl88SQEAgupzMw (envelope-from ); Fri, 17 Jul 2020 22:14:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 35A99A017C; Fri, 17 Jul 2020 22:13:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728432AbgGQUN5 (ORCPT + 1 other); Fri, 17 Jul 2020 16:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727871AbgGQUN4 (ORCPT ); Fri, 17 Jul 2020 16:13:56 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97044C0619D2 for ; Fri, 17 Jul 2020 13:13:56 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id c25so7754821otf.7 for ; Fri, 17 Jul 2020 13:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=wnVFsN0Fi5deQ7siuUTnPpQvD4/RnQHeHH1eSFWHzW8=; b=ENOqu9KM9VOKT1NQzZu9nQAF5iWeaHC/x92DzXH4mvfUoi9KSW44U+JNSNmpOXtOsK P9DrTwctLkQtXwiDKLPNmyxXFDu9KXMKIKKwAKLckpMCAvDahPR+9Eif/WsccURRMV48 L2sIWPn7HC4eBHzQeRfeunZBiVNUV99bgA2RE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=wnVFsN0Fi5deQ7siuUTnPpQvD4/RnQHeHH1eSFWHzW8=; b=jRWBztC2yiPhvKPtde7Qu5MlejAAHl5yytSJTh8zJlcK4gb6QuE4bZK1Eq9Jpe4DFy 89D3bvPMAKvM1ePM239iaqlqmhk2hKfCFrisb1vAzU/9se+i6HjAjVP2MlL2f3UyjlHE zJO4PgpgeivLcZhvNXZCWMuq2kXkRVbRJeHUnI+c2iVslSqUWM00S+t3cZ9ueQIIYnRq osEnlwkN2Z7+EUYbN6lMJNrFbp55GkdrbaFbOXjudvY4j8Ki8ugP/G9DxbHCJQkJ2304 xhwU+GYs0Dz4yRg5I72bLgq/n0tcYaaot9/IaLCO/9qkA0vDApaHpqHBZq3VQPWKIJhN Z3ZA== X-Gm-Message-State: AOAM5307NtLImZ4hOcP8cyBoPEbMBwbesW4UhtKdLiXcKxtac4t7JfHw 6ND8al6JrsdUvhez+bz8WXNxeifuos3EfzTrPhLiTAbJ5dM= X-Google-Smtp-Source: ABdhPJy53/cgClluap7XHPqI1ltOGT6BGJmscXjVyLIMN7qVysDp5UXuAEbhF6JeMd1C1DvyLOmr/Jb7JUOMA22Eb04= X-Received: by 2002:a9d:554d:: with SMTP id h13mr9638517oti.329.1595016835648; Fri, 17 Jul 2020 13:13:55 -0700 (PDT) MIME-Version: 1.0 References: <20200715224740.238527-1-sonnysasaka@chromium.org> In-Reply-To: <20200715224740.238527-1-sonnysasaka@chromium.org> From: Sonny Sasaka Date: Fri, 17 Jul 2020 13:13:44 -0700 Message-ID: Subject: Re: [PATCH BlueZ v2] profile: Add exception to battery profile for external access To: BlueZ Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 35A99A017C X-Rspamd-UID: 62beab Friendly ping on this simple patch. On Wed, Jul 15, 2020 at 3:47 PM Sonny Sasaka wrote: > > This gives exception to battery profile to be shared both internally and > externally. > > --- > profiles/battery/battery.c | 1 + > src/profile.h | 4 ++++ > 2 files changed, 5 insertions(+) > > diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c > index 4da4355a1..c9a1af4b9 100644 > --- a/profiles/battery/battery.c > +++ b/profiles/battery/battery.c > @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = { > .device_remove = batt_remove, > .accept = batt_accept, > .disconnect = batt_disconnect, > + .external = true, > }; > > static int batt_init(void) > diff --git a/src/profile.h b/src/profile.h > index 4448a2a6d..95523e50a 100644 > --- a/src/profile.h > +++ b/src/profile.h > @@ -35,6 +35,10 @@ struct btd_profile { > const char *remote_uuid; > > bool auto_connect; > + /* Some profiles are considered safe to be handled internally and also > + * be exposed in the GATT API. This flag give such profiles exception > + * from being claimed internally. > + */ > bool external; > > int (*device_probe) (struct btd_service *service); > -- > 2.26.2 > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8L3/H/EKEl+QFAAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 22:32:49 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4JCJHvEKEl9WYQEAgupzMw (envelope-from ); Fri, 17 Jul 2020 22:32:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5308DA1911; Fri, 17 Jul 2020 22:32:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726815AbgGQUcn (ORCPT + 1 other); Fri, 17 Jul 2020 16:32:43 -0400 Received: from mga14.intel.com ([192.55.52.115]:2113 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726510AbgGQUcm (ORCPT ); Fri, 17 Jul 2020 16:32:42 -0400 IronPort-SDR: 7tO5FxpnGBEJmCtfVfz7C0jw+AMlBHKKxK8EEQuDTlyNZlRV27Of4CsumHgCOl0z7EOqsEEV2s G5JmUoQFObCA== X-IronPort-AV: E=McAfee;i="6000,8403,9685"; a="148838010" X-IronPort-AV: E=Sophos;i="5.75,364,1589266800"; d="scan'208";a="148838010" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 13:32:42 -0700 IronPort-SDR: jUqe6VIU5KO2Csf6fLCX273pxhcYanHtlVNrJLROxKK4V3ubSsWQv7GIQFTu4gGvd5HdFyrFaa r99teEklcoWA== X-IronPort-AV: E=Sophos;i="5.75,364,1589266800"; d="scan'208";a="325524639" Received: from han1-mobl3.jf.intel.com ([10.254.113.127]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 13:32:42 -0700 Message-ID: Subject: Re: [BlueZ,1/5] shared/att: Fix possible crash on disconnect From: Tedd Ho-Jeong An To: "Von Dentz, Luiz" Cc: linux-bluetooth@vger.kernel.org Date: Fri, 17 Jul 2020 13:32:41 -0700 In-Reply-To: <5f11facb.1c69fb81.6f815.57f7@mx.google.com> References: <20200717191515.220621-1-luiz.dentz@gmail.com> <5f11facb.1c69fb81.6f815.57f7@mx.google.com> Organization: Intel Corporation Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 3 X-Rspamd-Score: 0.46 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5308DA1911 X-Rspamd-UID: fbf1c0 Hi Luiz, The failure is from test-gatt DEBUG :FAIL: unit/test-gatt I will update the CI to include the test result. Regards, Tedd On Fri, 2020-07-17 at 12:23 -0700, bluez.test.bot@gmail.com wrote: > This is automated email and please do not reply to this email! > > Dear submitter, > > Thank you for submitting the patches to the linux bluetooth mailing list. > While we are preparing for reviewing the patches, we found the following > issue/warning. > > Test Result: > makecheck Failed > > Outputs: > ./test-driver: line 107: 14830 Bus error (core dumped) "$@" > > $log_file 2>&1 > make[3]: *** [Makefile:9726: test-suite.log] Error 1 > make[2]: *** [Makefile:9834: check-TESTS] Error 2 > make[1]: *** [Makefile:10228: check-am] Error 2 > make: *** [Makefile:10230: check] Error 2 > > > > --- > Regards, > Linux Bluetooth Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wNGvLCgLEl+QFAAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 22:33:44 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id GOIlKygLEl/AlgAA0J78UA (envelope-from ); Fri, 17 Jul 2020 22:33:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 74CC9A10B1; Fri, 17 Jul 2020 22:33:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728238AbgGQUdi (ORCPT + 1 other); Fri, 17 Jul 2020 16:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726815AbgGQUdi (ORCPT ); Fri, 17 Jul 2020 16:33:38 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71486C0619D2 for ; Fri, 17 Jul 2020 13:33:38 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id z23so2080619ood.8 for ; Fri, 17 Jul 2020 13:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5UUkbXvkZXe8NVtarmx0b2nzNEqKIGpAHjV6phStybs=; b=plsU2H2y1UC8eAFJkrx9Nkehhw57sbGZako2KFikz7fGYYHFqnrWkG4SASw9NJ/tzs Z6ofXqdJrlir93bhOxznrWZ8d7ve9C7l53Z0d6uIDxssDTLePGDBW1rYRkEu6lNFZDhS RkUJ567ngqStRGep4hdsePk83YC4p+/hCjBqgAiAcJtZLa08EXk4NoOjDFAqv6Sw0nut KOm+ncGVVzbW5QZH/MCJP2Rmz623UkSKzciyIVOPmUNWZe3pk0uDx2VDA2IFePSh5rb6 Oxk0tyvDdyq2JsibvQZAWYNs8Wj6MyzzhXkwygo3uEg6P+1hp2uKGIHfcdn9e8qBINnH vJUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5UUkbXvkZXe8NVtarmx0b2nzNEqKIGpAHjV6phStybs=; b=qd70vBaMgKt2zro5qdLdKYdEn51ZzOPMmj5mvzV4vhBrxyfjjCArLOUq4ulOSjidD0 BvPvXnIsImziLYiZEK/ELZDbuYhRojQAxE4E24QAGF7MLF0+8cf23f5Wnl/BDs6JUKi9 9SbApURwbVvdY7aQlzOQ4xN2BtC87du0geKHBeXtLiwAqkE8a5WwV0b7TkHd2/JGZdhX 7qUCnok9IJQdsklbh/mAu2czPuc0qus0328e/ztkM6jh2xUEqp3kWV+zU4sONauXLr6w VVu1Gnhk9RqsDmoLGXjfGLNyzRz/g2B5HZ/ix5OnYBeWRZfmZs4mAHNbx0AeqvngOFTN pw0A== X-Gm-Message-State: AOAM532mgJKsBs4Lq6XWoI4NU9bc+DiNoutCXPLALdXK0yTGVnyGN4xl NBCyHYy6EQQRwDSX8Ifw6z9JcTu+G/4UjtkMoY0= X-Google-Smtp-Source: ABdhPJyw9DdsfIzgING4tcvorhTkZGQpZ1sU0YxTQ04a0aCgcmlTSqQF4LQ9c6TcysB2AeE8Rt/PxRrz+OjJaPuh66o= X-Received: by 2002:a4a:a21d:: with SMTP id m29mr10094897ool.17.1595018017594; Fri, 17 Jul 2020 13:33:37 -0700 (PDT) MIME-Version: 1.0 References: <20200715224740.238527-1-sonnysasaka@chromium.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Fri, 17 Jul 2020 13:33:26 -0700 Message-ID: Subject: Re: [PATCH BlueZ v2] profile: Add exception to battery profile for external access To: Sonny Sasaka Cc: BlueZ Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 74CC9A10B1 X-Rspamd-UID: 193e77 Hi Sonny, On Fri, Jul 17, 2020 at 1:17 PM Sonny Sasaka wrote: > > Friendly ping on this simple patch. > > On Wed, Jul 15, 2020 at 3:47 PM Sonny Sasaka wrote: > > > > This gives exception to battery profile to be shared both internally and > > externally. > > > > --- > > profiles/battery/battery.c | 1 + > > src/profile.h | 4 ++++ > > 2 files changed, 5 insertions(+) > > > > diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c > > index 4da4355a1..c9a1af4b9 100644 > > --- a/profiles/battery/battery.c > > +++ b/profiles/battery/battery.c > > @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = { > > .device_remove = batt_remove, > > .accept = batt_accept, > > .disconnect = batt_disconnect, > > + .external = true, > > }; > > > > static int batt_init(void) > > diff --git a/src/profile.h b/src/profile.h > > index 4448a2a6d..95523e50a 100644 > > --- a/src/profile.h > > +++ b/src/profile.h > > @@ -35,6 +35,10 @@ struct btd_profile { > > const char *remote_uuid; > > > > bool auto_connect; > > + /* Some profiles are considered safe to be handled internally and also > > + * be exposed in the GATT API. This flag give such profiles exception > > + * from being claimed internally. > > + */ > > bool external; > > > > int (*device_probe) (struct btd_service *service); > > -- > > 2.26.2 > > I've might have forgotten to announce it on the mailing list but this has been applied for a while: commit 0509a4a217256ac46020b957a6532dc150729748 (HEAD -> master) Author: Sonny Sasaka Date: Wed Jul 15 15:47:40 2020 -0700 profile: Add exception to battery profile for external access This gives exception to battery profile to be shared both internally and externally. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uHpsHyQMEl+QFAAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 22:37:56 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id uAcdHiQMEl9WYQEAgupzMw (envelope-from ); Fri, 17 Jul 2020 22:37:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0FCD9A1AE0; Fri, 17 Jul 2020 22:37:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726771AbgGQUhu (ORCPT + 1 other); Fri, 17 Jul 2020 16:37:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbgGQUht (ORCPT ); Fri, 17 Jul 2020 16:37:49 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7481AC0619D2 for ; Fri, 17 Jul 2020 13:37:49 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id k22so9073037oib.0 for ; Fri, 17 Jul 2020 13:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nZjXVG2l5i2DD6yPzZJAldfDn0pgvSL/sEGJegxml2o=; b=slDYTtmTpopQryS4SlnBDOTING9sZQM/98abNQfvFBU8/TG+rJPXdoVoq7dMoVhvu0 CiC/9DZNQ8EcSx9/hJp8ZuT0GQPh5Wf7kSfoKceVSOjc8pDiN4kxyFCS9jNqo5LYjiLz gPl09vcS0ckr6l/kYNXvL3F6HEhgn0sZ4ACpY7mXkZx3i8sW+mApA4JUnqQrOnxR61Xe RvBK9qs1OHZBWAhrvCsrwXfHO6vaDaIwmNP8jHdRgT/ttfXSfeu1zeGHhv+mCdGkJB8r F8UNrAwdM3c3Fi4ANbe6U5n5OsVsTHx0vmR1obpnxaMiTS0uXIGkqZIx+jypowy/pQLH V4gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nZjXVG2l5i2DD6yPzZJAldfDn0pgvSL/sEGJegxml2o=; b=q9evJTZM3gh3F7X0MK5KEKTL1nE8kTQdIKib/+rc39zLP+GLNrrf3mHvqK/H1Dmtyn KNZsHZmZFEVF3NQhueSj/vRPkI2iGweM48KCSFJ94s2sUWFbr2bho7od9ByRohoC+ync Gs/w5Zqam/N+VdVpPIenUicY0APCsxRamYxcHKFDPDtPwKoqehemBxXijTHstbFMsVdT n2qFOtSKCMnPvWIsWSIecAg+rK4ii3x1mBHhRCAPCe/85QvoDFtNZ4ZHgcqmtRiVA7CP hnaJiS8nHRWfAgpxZSfraTBqHdDE+JQD0g9bKO98V//e5jcszAHXbKi7Var0KuSDPW8L iJGg== X-Gm-Message-State: AOAM531Xy3hK6Nyhj3p9St8ERWeX2fETO8lhVMe3L6HQfD8AR9qaWC8N bpbk1RFiLFXZ/nVMgmqhJNwOQOCbNSOsoj+AMIrCTxE9 X-Google-Smtp-Source: ABdhPJzkHNUUGITwy+5Ut2LM8hnwNgSMb5m4Pi3B3+d7R4DMcqdoLz6oaYu3Np6O5Rr1f9K9pxgWjAhJ1qVOU50Nvd4= X-Received: by 2002:aca:cf81:: with SMTP id f123mr9339587oig.137.1595018268595; Fri, 17 Jul 2020 13:37:48 -0700 (PDT) MIME-Version: 1.0 References: <20200717144007.3160721-1-alainm@chromium.org> In-Reply-To: <20200717144007.3160721-1-alainm@chromium.org> From: Luiz Augusto von Dentz Date: Fri, 17 Jul 2020 13:37:37 -0700 Message-ID: Subject: Re: [Bluez PATCH v2] gatt: Support DeviceInfo Service when vid/pid is specified To: Alain Michaud Cc: "linux-bluetooth@vger.kernel.org" , Miao-chen Chou Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0FCD9A1AE0 X-Rspamd-UID: c6bce7 Hi Alain, On Fri, Jul 17, 2020 at 7:43 AM Alain Michaud wrote: > > This patch adds support for the PNPID characteristic when configured in > main.conf. > > This was validated as read correclty both by manually reading the valud > and confirming in the Ellisys Analyzer. > > ATT Read (PnP ID: Source=Bluetooth ID, Vendor=224, Product=50181, > ATT Read Response Packet (Source=Bluetooth ID, Vendor=224, > Product=50181, Version=86) | OK | 7 bytes (01 E0 00 05 C4 56 00) > > Reviewed-by: Miao-chen Chou > Signed-off-by: Alain Michaud > --- > I admit I don't know how to quantify the compatibility risk with adding > the Device Info Service if the DeviceID is specified. I can see that > some system may be configured with an app to publish the DIS and this > may break it. > > If the community feels it is necessary, I can include a DeviceIdOverLE > configuration which defaults to false in main.conf to address this > compatibility risk. > > Changes in v2: > - Removing file I didn't intend to commit (peripheral/gatt.c) > > src/gatt-database.c | 41 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > > diff --git a/src/gatt-database.c b/src/gatt-database.c > index 95ba39897..07d567078 100644 > --- a/src/gatt-database.c > +++ b/src/gatt-database.c > @@ -57,6 +57,7 @@ > > #define UUID_GAP 0x1800 > #define UUID_GATT 0x1801 > +#define UUID_DIS 0x180a > > #ifndef MIN > #define MIN(a, b) ((a) < (b) ? (a) : (b)) > @@ -1233,11 +1234,51 @@ static void populate_gatt_service(struct btd_gatt_database *database) > database_add_record(database, service); > } > > +static void device_info_read_pnp_id_cb(struct gatt_db_attribute *attrib, > + unsigned int id, uint16_t offset, > + uint8_t opcode, struct bt_att *att, > + void *user_data) > +{ > + uint8_t pdu[7]; > + > + pdu[0] = main_opts.did_source; > + put_le16(main_opts.did_vendor, &pdu[1]); > + put_le16(main_opts.did_product, &pdu[3]); > + put_le16(main_opts.did_version, &pdu[5]); > + > + gatt_db_attribute_read_result(attrib, id, 0, pdu, sizeof(pdu)); > +} > + > +static void populate_devinfo_service(struct btd_gatt_database *database) > +{ > + struct gatt_db_attribute *service; > + bt_uuid_t uuid; > + > + bt_uuid16_create(&uuid, UUID_DIS); > + service = gatt_db_add_service(database->db, &uuid, true, 3); > + > + if (main_opts.did_source > 0) { > + bt_uuid16_create(&uuid, GATT_CHARAC_PNP_ID); > + gatt_db_service_add_characteristic(service, &uuid, > + BT_ATT_PERM_READ, > + BT_GATT_CHRC_PROP_READ, > + device_info_read_pnp_id_cb, > + NULL, database); > + } > + > + gatt_db_service_set_active(service, true); > + > + database_add_record(database, service); > +} > > static void register_core_services(struct btd_gatt_database *database) > { > populate_gap_service(database); > populate_gatt_service(database); > + > + if (main_opts.did_source > 0) > + populate_devinfo_service(database); > + > } > > static void conf_cb(void *user_data) > -- > 2.28.0.rc0.105.gf9edc3c819-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cLVKEmQMEl9tXAAAvsO+Rg (envelope-from ) for ; Fri, 17 Jul 2020 22:39:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id IXiHEGQMEl8C7gAAlScrYA (envelope-from ); Fri, 17 Jul 2020 22:39:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EBB4DA1A52; Fri, 17 Jul 2020 22:38:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728202AbgGQUiy (ORCPT + 1 other); Fri, 17 Jul 2020 16:38:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbgGQUiy (ORCPT ); Fri, 17 Jul 2020 16:38:54 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5CAAC0619D2 for ; Fri, 17 Jul 2020 13:38:53 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id a21so7786082otq.8 for ; Fri, 17 Jul 2020 13:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=S0O2m/tF6hZ3t+aiG7c6/NvWqpwmmFtehL2XgyEwNsw=; b=G3uyfWjdaQlFYGx7RcQ0aJ37BGyR9TbOq2bKNgJZVT1lNk8xrRDJRRLjkAcoVCMJnv oNq8KdZLBXeJS/o2ArgB54zewfxT67gOLzLRqhqd3f3yycdmQAiNZdGNDZZiqCijknUy Np0TCu117x9JQBbQmg4Yxz8uD3T57vA/BWCq+LhMjSNMGBDNBcpqYJSMe+DPcAUUYK0e EOKyVNb+xOfrREkE8Zk6XWx7MnV8dvNs33Gdj7VTB7Wzb5qBZjmjf48F6bBVlbepsNbp jHCnhw4gnUOk6G4CqryiRtgcZ2PCL06kC+XGFGka1IbJCKfBkJDEdi75DZyS7DzduEha osYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=S0O2m/tF6hZ3t+aiG7c6/NvWqpwmmFtehL2XgyEwNsw=; b=lk9xlqvSVA5ZI7SS9uTxWpAJ9AkU9EEI+0hd81JKVhMdkIrataK/oG7T+GNzABbLiF 6sdJ25vniFyf28k6aaz/h9AdfPiYxzFFZO9F/OlwfjCPSt23UvwwK0s8G44Fsl6NKyLZ m7dVNERAHmztMw2YcFo0r8WeeJpo5sbZrNmkKckIiIdCjNN5Wm2F3CKvGtCPprZR2N+E oR+tpqaGVNR0olQj7AtVyd2vwqFrNetDuFpx3SATnfVqlQQcjF3pLvgvyuTqLvvDffAo tNHGlS+mBgLHe0cvfGnEgemnRKzmu/A34oKUMd5h3AwwNKJ4p7I0aFLXzoKFj5CBoojG DIbw== X-Gm-Message-State: AOAM531HXdajwZhuKdmvJNuXFcDSuUtfo6RGYmWkRYiNixjU2sigfx3x SH2jZ+Pj0Zpr1Y4cB++p7YbHxtza94SMyNL4aCU= X-Google-Smtp-Source: ABdhPJyERsMC38bR31BgWPiVTMRh9g1ryzrobHlxG9tMQGP75I1OBNEzvBuA96OLwBxHpkmdUpz/CcFDjX/AqnfnoDE= X-Received: by 2002:a9d:6c09:: with SMTP id f9mr10088176otq.362.1595018333289; Fri, 17 Jul 2020 13:38:53 -0700 (PDT) MIME-Version: 1.0 References: <20200715224740.238527-1-sonnysasaka@chromium.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Fri, 17 Jul 2020 13:38:42 -0700 Message-ID: Subject: Re: [PATCH BlueZ v2] profile: Add exception to battery profile for external access To: Sonny Sasaka Cc: BlueZ Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: EBB4DA1A52 X-Rspamd-UID: 80fbcb Hi Sonny, On Fri, Jul 17, 2020 at 1:33 PM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Fri, Jul 17, 2020 at 1:17 PM Sonny Sasaka wrote: > > > > Friendly ping on this simple patch. > > > > On Wed, Jul 15, 2020 at 3:47 PM Sonny Sasaka wrote: > > > > > > This gives exception to battery profile to be shared both internally and > > > externally. > > > > > > --- > > > profiles/battery/battery.c | 1 + > > > src/profile.h | 4 ++++ > > > 2 files changed, 5 insertions(+) > > > > > > diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c > > > index 4da4355a1..c9a1af4b9 100644 > > > --- a/profiles/battery/battery.c > > > +++ b/profiles/battery/battery.c > > > @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = { > > > .device_remove = batt_remove, > > > .accept = batt_accept, > > > .disconnect = batt_disconnect, > > > + .external = true, > > > }; > > > > > > static int batt_init(void) > > > diff --git a/src/profile.h b/src/profile.h > > > index 4448a2a6d..95523e50a 100644 > > > --- a/src/profile.h > > > +++ b/src/profile.h > > > @@ -35,6 +35,10 @@ struct btd_profile { > > > const char *remote_uuid; > > > > > > bool auto_connect; > > > + /* Some profiles are considered safe to be handled internally and also > > > + * be exposed in the GATT API. This flag give such profiles exception > > > + * from being claimed internally. > > > + */ > > > bool external; > > > > > > int (*device_probe) (struct btd_service *service); > > > -- > > > 2.26.2 > > > > > I've might have forgotten to announce it on the mailing list but this > has been applied for a while: > > commit 0509a4a217256ac46020b957a6532dc150729748 (HEAD -> master) > Author: Sonny Sasaka > Date: Wed Jul 15 15:47:40 2020 -0700 > > profile: Add exception to battery profile for external access > > This gives exception to battery profile to be shared both internally and > externally. Nevermind, it was just in my local tree for some reason, now I've applied it. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GIX8Kc0wEl9eFwEAvsO+Rg (envelope-from ) for ; Sat, 18 Jul 2020 01:14:21 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id iOmNKM0wEl+E+wAA0J78UA (envelope-from ); Sat, 18 Jul 2020 01:14:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BF07BA1965; Sat, 18 Jul 2020 01:14:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728068AbgGQXOP (ORCPT + 1 other); Fri, 17 Jul 2020 19:14:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgGQXOO (ORCPT ); Fri, 17 Jul 2020 19:14:14 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77F4BC0619D2 for ; Fri, 17 Jul 2020 16:14:14 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id 1so6080802pfn.9 for ; Fri, 17 Jul 2020 16:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nppnqGQdyrmLaloqOb/xJexNPUqspC/+yZWe6iO5RTQ=; b=aoxHqdmwYI7Z90ufEZxMQKhdT6c+XESjhWndlCQ/JSBs13ECudKa815QwXEjJNb0E5 xG6En0nujGh8LVft4r2rK3FguSqE9GnKdLA8uB+ZzVT4YpfNnfvHIazuKjbWbJ/3j/qS 4Cw91GVmnxYvtO/Kam1jsIn4f0IgJxHobjYnA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nppnqGQdyrmLaloqOb/xJexNPUqspC/+yZWe6iO5RTQ=; b=cBC3Eo+TVuD+hR0aDgGRWBA2fdX6QAyu//RsO5XS5U+NDYSd9QBvpVrhzHjE90HBQ+ Toa8dtDWgESKDrfwdMYufzZp97D0EPwsCJClSd6BLWkuqR5XaYyWiu+87enkVfINuw66 NmniuzA9M3GOiQiypnkyKakUJN8NaT770IA4dNMOGtXviXOo7tkTS+LXU4jDyvwhbFL4 /P8Sy7g2JuFlodnC6y0pGQ60cAh3dOxW4GVO9fGbMF4k08TY7Sh+/LIp569dRo1zkKZk xDDY7Or5kKUITtaxyOoMEGlh+gY7F3R7aqZwuucLRjPSJ7B/lJgUj6hatYgc/dbrVQ5J h3ZQ== X-Gm-Message-State: AOAM531pc8t0MDLYTS+mlAlnx0edUDfoCiiXDDdcmv81pnw0KO23eByc DQ+h3dbKFHxad1Zy9HW0VK6WJ/7I0lY= X-Google-Smtp-Source: ABdhPJy+6q9UdEAcO4FZHXj1i01vCDUktucECy54qdSNsqHF1xDvfZDGQZH3QCLU6tpWmPZrWXt5GA== X-Received: by 2002:a62:e30f:: with SMTP id g15mr9583406pfh.203.1595027653675; Fri, 17 Jul 2020 16:14:13 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id y7sm8194469pgk.93.2020.07.17.16.14.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jul 2020 16:14:13 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka Subject: [PATCH BlueZ] Add a presubmit configuration file for Chromium OS repo Date: Fri, 17 Jul 2020 16:14:04 -0700 Message-Id: <20200717231404.240644-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 5 X-Rspamd-Score: 0.85 / 15.00 / 200.00 X-Rspamd-Queue-Id: BF07BA1965 X-Rspamd-UID: 2ea202 Chromium OS developers use gerrit and repo in their workflow. (https://gerrit.googlesource.com/git-repo/). This configuration file makes it easier when uploading patches to gerrit with the repo tool. --- PRESUBMIT.cfg | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 PRESUBMIT.cfg diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg new file mode 100644 index 000000000..10f89b741 --- /dev/null +++ b/PRESUBMIT.cfg @@ -0,0 +1,8 @@ +# This is a configuration for Chromium OS repo pre-upload hooks. +# repohooks doc: https://chromium.googlesource.com/chromiumos/repohooks/ +# Chromium OS BlueZ git repo: https://chromium.googlesource.com/chromiumos/third_party/bluez/ + +[Hook Overrides] +cros_license_check: false +tab_check: false +checkpatch_check: true -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IIpmF1xHEl/jwAEAvsO+Rg (envelope-from ) for ; Sat, 18 Jul 2020 02:50:36 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id GPx1FlxHEl9JUgEA0J78UA (envelope-from ); Sat, 18 Jul 2020 02:50:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E94E340B7A; Sat, 18 Jul 2020 02:50:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727815AbgGRAua (ORCPT + 1 other); Fri, 17 Jul 2020 20:50:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726665AbgGRAu3 (ORCPT ); Fri, 17 Jul 2020 20:50:29 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D13CEC0619D2 for ; Fri, 17 Jul 2020 17:50:29 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id x72so6168510pfc.6 for ; Fri, 17 Jul 2020 17:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=5GN+UF/OVH85cGnmTzEejhlhnPvnuzxXelkhe3E6ra0=; b=Ry8FcUpioW+1jRpRmyo+54fL2NGxk/5aFtP//8fgVFisxtZKuCM0H42+0H8bZ5lLFa hzBN8oT5lpdB/ocPxopWECqYEkT3Jt3VffyWf9izZXy/7OlKaKnrBCeYhHI/6SI9XBSP kI2LlETw8L6qxOmDDsv16y/8dMvsp3Z0HpMoUKN9oI7JLV4QXahpr8qtPUCO4xeaUn9v rKdp5EAY+/xWMwHT9VLUzVBbL8bHSeI7B4Siq+DFNzkuOos8gvdoWJhi6t3sjofzc7BQ I5OZsX1beNsiy9Cy4C2dI5UsZYt7HPL64f8GjKVELFwgAlK1WFM4l9WC0BbJluQ0hFqC 4RSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=5GN+UF/OVH85cGnmTzEejhlhnPvnuzxXelkhe3E6ra0=; b=M3Ee2mC+vJogbSCi4Rh32eYNkcjS/9il4F5Odo2vKmJV89y/4rNw1vOXHsmCRnSxvP KLRkGTm7C0E0mLUaGXdKjP6IVfRp5iNvzG2FW+Brsdq3AqRDHJnB4NH1IoLLOMFWNMjM Y69D8Pcvqoxbw8xIfujiwNT+NI0tYgi1T9Csga3Q/J7in8XTKKOO6xj8CytYkYEQ9NLH slE4m/guOnljbOny9EtLsRWFzHdxezRl+n0xW1UfPObTkETkqjOcK6RKkPL4P9woC3wH 1vsiohJE7h+fZ2lAtQgzCCbBtNwIzy9xayshGJHfqDunumnrZCzAO9iUys4YFYuzB9Hf iB5Q== X-Gm-Message-State: AOAM533ImXgQCIn/bS/zlf5ANw1H6DQOKmG8PM//Nxf6mmgzFFq3He2m PvvCQIn152EnbxbQ60UYROweGPmccdg= X-Google-Smtp-Source: ABdhPJz/SWB/F8XqiI8LVzAV3GpDutsEBrfXYLgGCeIfGC35ldnEFq+zuV1m34fPlOKcDV0h4ASeVw== X-Received: by 2002:a63:df03:: with SMTP id u3mr10342709pgg.84.1595033429067; Fri, 17 Jul 2020 17:50:29 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id h15sm4007266pjc.14.2020.07.17.17.50.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 17:50:28 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] adapter: Don't remove temporary devices on disconnect Date: Fri, 17 Jul 2020 17:49:42 -0700 Message-Id: <20200718004942.326261-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: E94E340B7A X-Rspamd-UID: 25b17c From: Luiz Augusto von Dentz This makes the disconnect logic just update last seen field of the device so in case it is temporary it would trigger its timer and be removed after the timeout which is consistent with the discovery session givin a grace time for application to react to such events. --- src/adapter.c | 7 ------- src/device.c | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index c757447e2..5e896a9f0 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6837,13 +6837,6 @@ static void adapter_remove_connection(struct btd_adapter *adapter, return; adapter->connections = g_slist_remove(adapter->connections, device); - - if (device_is_temporary(device) && !device_is_retrying(device)) { - const char *path = device_get_path(device); - - DBG("Removing temporary device %s", path); - btd_adapter_remove_device(adapter, device); - } } static void adapter_stop(struct btd_adapter *adapter) diff --git a/src/device.c b/src/device.c index 470596ee4..2237a7670 100644 --- a/src/device.c +++ b/src/device.c @@ -3039,6 +3039,8 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) if (device->bredr_state.connected || device->le_state.connected) return; + device_update_last_seen(device, bdaddr_type); + g_dbus_emit_property_changed(dbus_conn, device->path, DEVICE_INTERFACE, "Connected"); } -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2OTBF9hKE19ujwAAvsO+Rg (envelope-from ) for ; Sat, 18 Jul 2020 21:17:44 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id cCn2FdhKE18h1QAAlScrYA (envelope-from ); Sat, 18 Jul 2020 21:17:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 83FD7A1A21; Sat, 18 Jul 2020 21:17:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbgGRTRB convert rfc822-to-8bit (ORCPT + 1 other); Sat, 18 Jul 2020 15:17:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:37100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726346AbgGRTRB (ORCPT ); Sat, 18 Jul 2020 15:17:01 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Sat, 18 Jul 2020 19:16:59 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: zuurveldt@outlook.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: 83FD7A1A21 X-Rspamd-UID: b29b25 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #102 from Real Name (zuurveldt@outlook.com) --- (In reply to AndreyTarkovsky from comment #101) > Unfortunately I can not say the same. Using Arch Linux here and tried a lot > of patches on kernel 5.7.7 and 5.7.8 as showed on my forum post here > https://bbs.archlinux.org/viewtopic.php?pid=1915544#p1915544 Did you try running 'sudo hciconfig hci0 up'? Unless Arch does something different to their kernels. I patched a stock Fedora kernel (built from source RPM). -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oFOtBANsE1+SgAEAvsO+Rg (envelope-from ) for ; Sat, 18 Jul 2020 23:39:15 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kHnBAgNsE19MFgEAlp8NpQ (envelope-from ); Sat, 18 Jul 2020 23:39:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C601E40B7A; Sat, 18 Jul 2020 23:39:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727042AbgGRVjF convert rfc822-to-8bit (ORCPT + 1 other); Sat, 18 Jul 2020 17:39:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:55602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726416AbgGRVjF (ORCPT ); Sat, 18 Jul 2020 17:39:05 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Sat, 18 Jul 2020 21:39:03 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gustavoyaraujo@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.59 / 15.00 / 200.00 X-Rspamd-Queue-Id: C601E40B7A X-Rspamd-UID: e6a636 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #103 from AndreyTarkovsky (gustavoyaraujo@gmail.com) --- (In reply to Real Name from comment #102) > (In reply to AndreyTarkovsky from comment #101) > > Unfortunately I can not say the same. Using Arch Linux here and tried a lot > > of patches on kernel 5.7.7 and 5.7.8 as showed on my forum post here > > https://bbs.archlinux.org/viewtopic.php?pid=1915544#p1915544 > > Did you try running 'sudo hciconfig hci0 up'? Unless Arch does something > different to their kernels. I patched a stock Fedora kernel (built from > source RPM). hciconfig dev hci0: Type: Primary Bus: USB BD Address: 00:1A:7D:DA:71:10 ACL MTU: 640:4 SCO MTU: 64:8 DOWN RX bytes:1084 acl:0 sco:0 events:50 errors:0 TX bytes:662 acl:0 sco:0 commands:50 errors:0 sudo hciconfig hci0 up Can't init device hci0: Invalid request code (56) Looks like there is something special on my dongle. dmesg showed it was recognized as a CSR clone: [ 194.023832] Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds... [ 194.032848] debugfs: File 'dut_mode' in directory 'hci0' already present! [ 194.077761] audit: type=1106 audit(1595108086.134:91): pid=1605 uid=0 auid=1000 ses=3 msg='op=PAM:session_close grantors=pam_limits,pam_unix,pam_permit acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success' [ 194.077970] audit: type=1104 audit(1595108086.134:92): pid=1605 uid=0 auid=1000 ses=3 msg='op=PAM:setcred grantors=pam_unix,pam_permit,pam_env acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success' -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IE7nGAGnE1+pzgAAvsO+Rg (envelope-from ) for ; Sun, 19 Jul 2020 03:50:57 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id sHCQFwGnE1+YuQEA0J78UA (envelope-from ); Sun, 19 Jul 2020 03:50:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2ED9940873; Sun, 19 Jul 2020 03:50:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726412AbgGSBuu convert rfc822-to-8bit (ORCPT + 1 other); Sat, 18 Jul 2020 21:50:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:52792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726256AbgGSBuu (ORCPT ); Sat, 18 Jul 2020 21:50:50 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Sun, 19 Jul 2020 01:50:46 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gustavoyaraujo@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.52 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2ED9940873 X-Rspamd-UID: 2b576c https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #106 from AndreyTarkovsky (gustavoyaraujo@gmail.com) --- (In reply to Real Name from comment #105) > (In reply to AndreyTarkovsky from comment #104) > > [ 307.982384] usb 1-2: new full-speed USB device number 3 using ohci-pci > > [ 308.475005] usb 1-2: New USB device found, idVendor=0a12, > idProduct=0001, > > bcdDevice=25.20 > > [ 308.475008] usb 1-2: New USB device strings: Mfr=0, Product=2, > > SerialNumber=0 > > [ 308.475010] usb 1-2: Product: CSR8510 A10 > > Looks exactly like mine. Post the output of 'sudo lsusb -vd 0a12:0001'. Here: sudo lsusb -vd 0a12:0001 Bus 001 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 224 Wireless bDeviceSubClass 1 Radio Frequency bDeviceProtocol 1 Bluetooth bMaxPacketSize0 64 idVendor 0x0a12 Cambridge Silicon Radio, Ltd idProduct 0x0001 Bluetooth Dongle (HCI mode) bcdDevice 25.20 iManufacturer 0 iProduct 2 CSR8510 A10 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x00b1 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 1 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 2 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 3 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 4 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 5 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 can't get device qualifier: Resource temporarily unavailable can't get debug descriptor: Resource temporarily unavailable Device Status: 0x0000 (Bus Powered) -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YC5rJJTwFF+/SwEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 03:17:08 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 4KyWIpTwFF94TQAAlScrYA (envelope-from ); Mon, 20 Jul 2020 03:17:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 29E2FA1E62; Mon, 20 Jul 2020 03:17:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727780AbgGTBRB (ORCPT + 1 other); Sun, 19 Jul 2020 21:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726531AbgGTBRB (ORCPT ); Sun, 19 Jul 2020 21:17:01 -0400 Received: from shards.monkeyblade.net (shards.monkeyblade.net [IPv6:2620:137:e000::1:9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AAE1C0619D2; Sun, 19 Jul 2020 18:17:01 -0700 (PDT) Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 1B85F1284AF6B; Sun, 19 Jul 2020 18:17:00 -0700 (PDT) Date: Sun, 19 Jul 2020 18:16:59 -0700 (PDT) Message-Id: <20200719.181659.1807927650741641565.davem@davemloft.net> To: hch@lst.de Cc: ast@kernel.org, daniel@iogearbox.net, 3chas3@gmail.com, pablo@netfilter.org, kadlec@netfilter.org, fw@strlen.de, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-sctp@vger.kernel.org, linux-arch@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.01.org Subject: Re: sockopt cleanups From: David Miller In-Reply-To: <20200717062331.691152-1-hch@lst.de> References: <20200717062331.691152-1-hch@lst.de> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sun, 19 Jul 2020 18:17:00 -0700 (PDT) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 0.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 29E2FA1E62 X-Rspamd-UID: ccfead From: Christoph Hellwig Date: Fri, 17 Jul 2020 08:23:09 +0200 > this series cleans up various lose ends in the sockopt code, most > importantly removing the compat_{get,set}sockopt infrastructure in favor > of just using in_compat_syscall() in the few places that care. Series applied to net-next, thanks. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ICndM5CSFV+c4QEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:48:16 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id CIWBMpCSFV84+gAADc0bRg (envelope-from ); Mon, 20 Jul 2020 14:48:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4C5CEA1230; Mon, 20 Jul 2020 14:48:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728784AbgGTMsK (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728074AbgGTMsJ (ORCPT ); Mon, 20 Jul 2020 08:48:09 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EED7C061794; Mon, 20 Jul 2020 05:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=v9KgsOSWea1bJKFDijg05Yu/Lxnc3rcc50PR6ELHK4E=; b=MadyBZx0Wf8x+2kw7O1nJxOIOd FbU4MH1JyD5v78V7lQ/HRw45yXpPVs9JO/G+kH4DiN1QWFmw0WGQv/S2d22ogQPe/4gqcuswjDMxD UA+RyowobKCKhwuLpSB8o4bKj8XVpqEmqj4r0KjhkUO/Xe3omvaNi1zO6Mu7Ul5xJ63b84wq7p4uE igF3dMEhdDGLmF1UIoeXtgDt60qeorgzwuf6irI/HPydWG6GGi42y2nO3TPoyuU57ddcRPRbw8sYq A124JUfae++O65R5yqh735FbvAIm2bAY6i4tx8g4ymy/GWe+BCXCPTa9ItoQv2rd6m2uecW1hKmJ+ VToa8WXQ==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVCt-0004Wa-Pp; Mon, 20 Jul 2020 12:47:49 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 03/24] net: add a new sockptr_t type Date: Mon, 20 Jul 2020 14:47:16 +0200 Message-Id: <20200720124737.118617-4-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4C5CEA1230 X-Rspamd-UID: 8b3251 Add a uptr_t type that can hold a pointer to either a user or kernel memory region, and simply helpers to copy to and from it. For architectures like x86 that have non-overlapping user and kernel address space it just is a union and uses a TASK_SIZE check to select the proper copy routine. For architectures with overlapping address spaces a flag to indicate the address space is used instead. Signed-off-by: Christoph Hellwig --- include/linux/sockptr.h | 121 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 include/linux/sockptr.h diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h new file mode 100644 index 00000000000000..e41dfa52555dec --- /dev/null +++ b/include/linux/sockptr.h @@ -0,0 +1,121 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2020 Christoph Hellwig. + * + * Support for "universal" pointers that can point to either kernel or userspace + * memory. + */ +#ifndef _LINUX_SOCKPTR_H +#define _LINUX_SOCKPTR_H + +#include +#include + +#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE +typedef union { + void *kernel; + void __user *user; +} sockptr_t; + +static inline bool sockptr_is_kernel(sockptr_t sockptr) +{ + return (unsigned long)sockptr.kernel >= TASK_SIZE; +} + +static inline sockptr_t KERNEL_SOCKPTR(void *p) +{ + return (sockptr_t) { .kernel = p }; +} +#else /* CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE */ +typedef struct { + union { + void *kernel; + void __user *user; + }; + bool is_kernel : 1; +} sockptr_t; + +static inline bool sockptr_is_kernel(sockptr_t sockptr) +{ + return sockptr.is_kernel; +} + +static inline sockptr_t KERNEL_SOCKPTR(void *p) +{ + return (sockptr_t) { .kernel = p, .is_kernel = true }; +} +#endif /* CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE */ + +static inline sockptr_t USER_SOCKPTR(void __user *p) +{ + return (sockptr_t) { .user = p }; +} + +static inline bool sockptr_is_null(sockptr_t sockptr) +{ + return !sockptr.user && !sockptr.kernel; +} + +static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) +{ + if (!sockptr_is_kernel(src)) + return copy_from_user(dst, src.user, size); + memcpy(dst, src.kernel, size); + return 0; +} + +static inline int copy_to_sockptr(sockptr_t dst, const void *src, size_t size) +{ + if (!sockptr_is_kernel(dst)) + return copy_to_user(dst.user, src, size); + memcpy(dst.kernel, src, size); + return 0; +} + +static inline void *memdup_sockptr(sockptr_t src, size_t len) +{ + void *p = kmalloc_track_caller(len, GFP_USER | __GFP_NOWARN); + + if (!p) + return ERR_PTR(-ENOMEM); + if (copy_from_sockptr(p, src, len)) { + kfree(p); + return ERR_PTR(-EFAULT); + } + return p; +} + +static inline void *memdup_sockptr_nul(sockptr_t src, size_t len) +{ + char *p = kmalloc_track_caller(len + 1, GFP_KERNEL); + + if (!p) + return ERR_PTR(-ENOMEM); + if (copy_from_sockptr(p, src, len)) { + kfree(p); + return ERR_PTR(-EFAULT); + } + p[len] = '\0'; + return p; +} + +static inline void sockptr_advance(sockptr_t sockptr, size_t len) +{ + if (sockptr_is_kernel(sockptr)) + sockptr.kernel += len; + else + sockptr.user += len; +} + +static inline long strncpy_from_sockptr(char *dst, sockptr_t src, size_t count) +{ + if (sockptr_is_kernel(src)) { + size_t len = min(strnlen(src.kernel, count - 1) + 1, count); + + memcpy(dst, src.kernel, len); + return len; + } + return strncpy_from_user(dst, src.user, count); +} + +#endif /* _LINUX_SOCKPTR_H */ -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OFcQOLqSFV/s0AEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:48:58 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QFspNrqSFV8MzQAADc0bRg (envelope-from ); Mon, 20 Jul 2020 14:48:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3D755A273D; Mon, 20 Jul 2020 14:48:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729124AbgGTMsh (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729115AbgGTMsh (ORCPT ); Mon, 20 Jul 2020 08:48:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8032C0619D2; Mon, 20 Jul 2020 05:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=QrqaYh4fSMgupA4iEFhXoiD4XEjtKBO+4D3VptAqYus=; b=ntmx7D73LLj+uTB59c9zHRIOSX xEW8E4FWTGHmBCvYZi2UqKVvuxDf0jPb/q85g0z2q2I15UWLuFU8u38IVwJiFwRmsWyurCX4qXsTJ r+O7HRjgn3mf2tbLbvSLz2UWR0rt/gMZv/RvFpa1ZKuycjF6bWEoP39CPRV5NdG3FWD2SKQM6bd3u 1iaFtUNPmn4WCwSDH+MHrU3kLxlPutFkK6aOn/Z65PtdOhtwBCUmA1J5GeB540tc1ZdwTZaoL6eXW 36WDX17j0QZzNn355gpFGedMkrl/ZAg+56MPbVmo75W62H1SiH5TILDszh4y8sRy0qvvB3qyS1km6 +00DCqMQ==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDU-0004ax-1b; Mon, 20 Jul 2020 12:48:24 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 16/24] net/ipv6: switch ip6_mroute_setsockopt to sockptr_t Date: Mon, 20 Jul 2020 14:47:29 +0200 Message-Id: <20200720124737.118617-17-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3D755A273D X-Rspamd-UID: 85f896 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/linux/mroute6.h | 8 ++++---- net/ipv6/ip6mr.c | 17 +++++++++-------- net/ipv6/ipv6_sockglue.c | 3 ++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/linux/mroute6.h b/include/linux/mroute6.h index c4a45859f586d4..bc351a85ce9b9c 100644 --- a/include/linux/mroute6.h +++ b/include/linux/mroute6.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #ifdef CONFIG_IPV6_MROUTE @@ -25,7 +26,7 @@ static inline int ip6_mroute_opt(int opt) struct sock; #ifdef CONFIG_IPV6_MROUTE -extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); +extern int ip6_mroute_setsockopt(struct sock *, int, sockptr_t, unsigned int); extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *); extern int ip6_mr_input(struct sk_buff *skb); extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg); @@ -33,9 +34,8 @@ extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *ar extern int ip6_mr_init(void); extern void ip6_mr_cleanup(void); #else -static inline -int ip6_mroute_setsockopt(struct sock *sock, - int optname, char __user *optval, unsigned int optlen) +static inline int ip6_mroute_setsockopt(struct sock *sock, int optname, + sockptr_t optval, unsigned int optlen) { return -ENOPROTOOPT; } diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 1f4d20e97c07f9..06b0d2c329b94b 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1629,7 +1629,8 @@ EXPORT_SYMBOL(mroute6_is_socket); * MOSPF/PIM router set up we can clean this up. */ -int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, unsigned int optlen) +int ip6_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, + unsigned int optlen) { int ret, parent = 0; struct mif6ctl vif; @@ -1665,7 +1666,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns case MRT6_ADD_MIF: if (optlen < sizeof(vif)) return -EINVAL; - if (copy_from_user(&vif, optval, sizeof(vif))) + if (copy_from_sockptr(&vif, optval, sizeof(vif))) return -EFAULT; if (vif.mif6c_mifi >= MAXMIFS) return -ENFILE; @@ -1678,7 +1679,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns case MRT6_DEL_MIF: if (optlen < sizeof(mifi_t)) return -EINVAL; - if (copy_from_user(&mifi, optval, sizeof(mifi_t))) + if (copy_from_sockptr(&mifi, optval, sizeof(mifi_t))) return -EFAULT; rtnl_lock(); ret = mif6_delete(mrt, mifi, 0, NULL); @@ -1697,7 +1698,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns case MRT6_DEL_MFC_PROXY: if (optlen < sizeof(mfc)) return -EINVAL; - if (copy_from_user(&mfc, optval, sizeof(mfc))) + if (copy_from_sockptr(&mfc, optval, sizeof(mfc))) return -EFAULT; if (parent == 0) parent = mfc.mf6cc_parent; @@ -1718,7 +1719,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns if (optlen != sizeof(flags)) return -EINVAL; - if (get_user(flags, (int __user *)optval)) + if (copy_from_sockptr(&flags, optval, sizeof(flags))) return -EFAULT; rtnl_lock(); mroute_clean_tables(mrt, flags); @@ -1735,7 +1736,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns if (optlen != sizeof(v)) return -EINVAL; - if (get_user(v, (int __user *)optval)) + if (copy_from_sockptr(&v, optval, sizeof(v))) return -EFAULT; mrt->mroute_do_assert = v; return 0; @@ -1748,7 +1749,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns if (optlen != sizeof(v)) return -EINVAL; - if (get_user(v, (int __user *)optval)) + if (copy_from_sockptr(&v, optval, sizeof(v))) return -EFAULT; v = !!v; rtnl_lock(); @@ -1769,7 +1770,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns if (optlen != sizeof(u32)) return -EINVAL; - if (get_user(v, (u32 __user *)optval)) + if (copy_from_sockptr(&v, optval, sizeof(v))) return -EFAULT; /* "pim6reg%u" should not exceed 16 bytes (IFNAMSIZ) */ if (v != RT_TABLE_DEFAULT && v >= 100000000) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 85892b35cff7b3..119dfaf5f4bb26 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -337,7 +337,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, valbool = (val != 0); if (ip6_mroute_opt(optname)) - return ip6_mroute_setsockopt(sk, optname, optval, optlen); + return ip6_mroute_setsockopt(sk, optname, USER_SOCKPTR(optval), + optlen); if (needs_rtnl) rtnl_lock(); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wPnCBcmSFV/s0AEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:49:13 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 8L4VBMmSFV99qAAAlScrYA (envelope-from ); Mon, 20 Jul 2020 14:49:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0342AA134A; Mon, 20 Jul 2020 14:49:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729161AbgGTMso (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728779AbgGTMsm (ORCPT ); Mon, 20 Jul 2020 08:48:42 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6C4DC061794; Mon, 20 Jul 2020 05:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=oYVq7NIRWqvX/f/cel/N+xePG7N1PJ2B3QTLRfoiAMQ=; b=Q2M2BbM8skgQsbz+9IFT9+SRS8 wOn0jWnTATVFcYirebkCBwKq5mT6Ub4JpyN3kocyPSwcZ9qxddqTIFOBWgt5cHn7Fiaq/A/rTr1Ny NJlv7iQ0FqlWOI2nLC8g9bDpVaGGUDRAPFvWzldUjdv+qtqUMGw9bRqAhBQHXLOTF8PBI5+b8YJ0f lSUkjWJUoqeS7o7xpPt8jkfJjaD/qpK37PcCQGm6fR3w9Ve3Av+OXeSmQz1Fcz1KSaLMTuFeT0L3h aoUfH/3lOromCbJGjPXv7nZzZc+/eTbity/L2HIf00Ca7AS8k5/AiW+/D9KsSdwaT+vKgWaf2mC9R XUUDuXUg==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDW-0004bj-37; Mon, 20 Jul 2020 12:48:27 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 17/24] net/ipv6: split up ipv6_flowlabel_opt Date: Mon, 20 Jul 2020 14:47:30 +0200 Message-Id: <20200720124737.118617-18-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0342AA134A X-Rspamd-UID: 45ceaa Split ipv6_flowlabel_opt into a subfunction for each action and a small wrapper. Signed-off-by: Christoph Hellwig --- net/ipv6/ip6_flowlabel.c | 311 +++++++++++++++++++++------------------ 1 file changed, 167 insertions(+), 144 deletions(-) diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index ce4fbba4acce7e..27ee6de9beffc4 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c @@ -533,187 +533,210 @@ int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq, return -ENOENT; } -int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen) +#define socklist_dereference(__sflp) \ + rcu_dereference_protected(__sflp, lockdep_is_held(&ip6_sk_fl_lock)) + +static int ipv6_flowlabel_put(struct sock *sk, struct in6_flowlabel_req *freq) { - int uninitialized_var(err); - struct net *net = sock_net(sk); struct ipv6_pinfo *np = inet6_sk(sk); - struct in6_flowlabel_req freq; - struct ipv6_fl_socklist *sfl1 = NULL; - struct ipv6_fl_socklist *sfl; struct ipv6_fl_socklist __rcu **sflp; - struct ip6_flowlabel *fl, *fl1 = NULL; - + struct ipv6_fl_socklist *sfl; - if (optlen < sizeof(freq)) - return -EINVAL; + if (freq->flr_flags & IPV6_FL_F_REFLECT) { + if (sk->sk_protocol != IPPROTO_TCP) + return -ENOPROTOOPT; + if (!np->repflow) + return -ESRCH; + np->flow_label = 0; + np->repflow = 0; + return 0; + } - if (copy_from_user(&freq, optval, sizeof(freq))) - return -EFAULT; + spin_lock_bh(&ip6_sk_fl_lock); + for (sflp = &np->ipv6_fl_list; + (sfl = socklist_dereference(*sflp)) != NULL; + sflp = &sfl->next) { + if (sfl->fl->label == freq->flr_label) + goto found; + } + spin_unlock_bh(&ip6_sk_fl_lock); + return -ESRCH; +found: + if (freq->flr_label == (np->flow_label & IPV6_FLOWLABEL_MASK)) + np->flow_label &= ~IPV6_FLOWLABEL_MASK; + *sflp = sfl->next; + spin_unlock_bh(&ip6_sk_fl_lock); + fl_release(sfl->fl); + kfree_rcu(sfl, rcu); + return 0; +} + +static int ipv6_flowlabel_renew(struct sock *sk, struct in6_flowlabel_req *freq) +{ + struct ipv6_pinfo *np = inet6_sk(sk); + struct net *net = sock_net(sk); + struct ipv6_fl_socklist *sfl; + int err; - switch (freq.flr_action) { - case IPV6_FL_A_PUT: - if (freq.flr_flags & IPV6_FL_F_REFLECT) { - if (sk->sk_protocol != IPPROTO_TCP) - return -ENOPROTOOPT; - if (!np->repflow) - return -ESRCH; - np->flow_label = 0; - np->repflow = 0; - return 0; - } - spin_lock_bh(&ip6_sk_fl_lock); - for (sflp = &np->ipv6_fl_list; - (sfl = rcu_dereference_protected(*sflp, - lockdep_is_held(&ip6_sk_fl_lock))) != NULL; - sflp = &sfl->next) { - if (sfl->fl->label == freq.flr_label) { - if (freq.flr_label == (np->flow_label&IPV6_FLOWLABEL_MASK)) - np->flow_label &= ~IPV6_FLOWLABEL_MASK; - *sflp = sfl->next; - spin_unlock_bh(&ip6_sk_fl_lock); - fl_release(sfl->fl); - kfree_rcu(sfl, rcu); - return 0; - } + rcu_read_lock_bh(); + for_each_sk_fl_rcu(np, sfl) { + if (sfl->fl->label == freq->flr_label) { + err = fl6_renew(sfl->fl, freq->flr_linger, + freq->flr_expires); + rcu_read_unlock_bh(); + return err; } - spin_unlock_bh(&ip6_sk_fl_lock); - return -ESRCH; + } + rcu_read_unlock_bh(); - case IPV6_FL_A_RENEW: - rcu_read_lock_bh(); - for_each_sk_fl_rcu(np, sfl) { - if (sfl->fl->label == freq.flr_label) { - err = fl6_renew(sfl->fl, freq.flr_linger, freq.flr_expires); - rcu_read_unlock_bh(); - return err; - } - } - rcu_read_unlock_bh(); + if (freq->flr_share == IPV6_FL_S_NONE && + ns_capable(net->user_ns, CAP_NET_ADMIN)) { + struct ip6_flowlabel *fl = fl_lookup(net, freq->flr_label); - if (freq.flr_share == IPV6_FL_S_NONE && - ns_capable(net->user_ns, CAP_NET_ADMIN)) { - fl = fl_lookup(net, freq.flr_label); - if (fl) { - err = fl6_renew(fl, freq.flr_linger, freq.flr_expires); - fl_release(fl); - return err; - } + if (fl) { + err = fl6_renew(fl, freq->flr_linger, + freq->flr_expires); + fl_release(fl); + return err; } - return -ESRCH; - - case IPV6_FL_A_GET: - if (freq.flr_flags & IPV6_FL_F_REFLECT) { - struct net *net = sock_net(sk); - if (net->ipv6.sysctl.flowlabel_consistency) { - net_info_ratelimited("Can not set IPV6_FL_F_REFLECT if flowlabel_consistency sysctl is enable\n"); - return -EPERM; - } + } + return -ESRCH; +} - if (sk->sk_protocol != IPPROTO_TCP) - return -ENOPROTOOPT; +static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, + void __user *optval, int optlen) +{ + struct ipv6_fl_socklist *sfl, *sfl1 = NULL; + struct ip6_flowlabel *fl, *fl1 = NULL; + struct ipv6_pinfo *np = inet6_sk(sk); + struct net *net = sock_net(sk); + int uninitialized_var(err); - np->repflow = 1; - return 0; + if (freq->flr_flags & IPV6_FL_F_REFLECT) { + if (net->ipv6.sysctl.flowlabel_consistency) { + net_info_ratelimited("Can not set IPV6_FL_F_REFLECT if flowlabel_consistency sysctl is enable\n"); + return -EPERM; } - if (freq.flr_label & ~IPV6_FLOWLABEL_MASK) - return -EINVAL; + if (sk->sk_protocol != IPPROTO_TCP) + return -ENOPROTOOPT; + np->repflow = 1; + return 0; + } - if (net->ipv6.sysctl.flowlabel_state_ranges && - (freq.flr_label & IPV6_FLOWLABEL_STATELESS_FLAG)) - return -ERANGE; + if (freq->flr_label & ~IPV6_FLOWLABEL_MASK) + return -EINVAL; + if (net->ipv6.sysctl.flowlabel_state_ranges && + (freq->flr_label & IPV6_FLOWLABEL_STATELESS_FLAG)) + return -ERANGE; - fl = fl_create(net, sk, &freq, optval, optlen, &err); - if (!fl) - return err; - sfl1 = kmalloc(sizeof(*sfl1), GFP_KERNEL); + fl = fl_create(net, sk, freq, optval, optlen, &err); + if (!fl) + return err; - if (freq.flr_label) { - err = -EEXIST; - rcu_read_lock_bh(); - for_each_sk_fl_rcu(np, sfl) { - if (sfl->fl->label == freq.flr_label) { - if (freq.flr_flags&IPV6_FL_F_EXCL) { - rcu_read_unlock_bh(); - goto done; - } - fl1 = sfl->fl; - if (!atomic_inc_not_zero(&fl1->users)) - fl1 = NULL; - break; + sfl1 = kmalloc(sizeof(*sfl1), GFP_KERNEL); + + if (freq->flr_label) { + err = -EEXIST; + rcu_read_lock_bh(); + for_each_sk_fl_rcu(np, sfl) { + if (sfl->fl->label == freq->flr_label) { + if (freq->flr_flags & IPV6_FL_F_EXCL) { + rcu_read_unlock_bh(); + goto done; } + fl1 = sfl->fl; + if (!atomic_inc_not_zero(&fl1->users)) + fl1 = NULL; + break; } - rcu_read_unlock_bh(); + } + rcu_read_unlock_bh(); - if (!fl1) - fl1 = fl_lookup(net, freq.flr_label); - if (fl1) { + if (!fl1) + fl1 = fl_lookup(net, freq->flr_label); + if (fl1) { recheck: - err = -EEXIST; - if (freq.flr_flags&IPV6_FL_F_EXCL) - goto release; - err = -EPERM; - if (fl1->share == IPV6_FL_S_EXCL || - fl1->share != fl->share || - ((fl1->share == IPV6_FL_S_PROCESS) && - (fl1->owner.pid != fl->owner.pid)) || - ((fl1->share == IPV6_FL_S_USER) && - !uid_eq(fl1->owner.uid, fl->owner.uid))) - goto release; - - err = -ENOMEM; - if (!sfl1) - goto release; - if (fl->linger > fl1->linger) - fl1->linger = fl->linger; - if ((long)(fl->expires - fl1->expires) > 0) - fl1->expires = fl->expires; - fl_link(np, sfl1, fl1); - fl_free(fl); - return 0; + err = -EEXIST; + if (freq->flr_flags&IPV6_FL_F_EXCL) + goto release; + err = -EPERM; + if (fl1->share == IPV6_FL_S_EXCL || + fl1->share != fl->share || + ((fl1->share == IPV6_FL_S_PROCESS) && + (fl1->owner.pid != fl->owner.pid)) || + ((fl1->share == IPV6_FL_S_USER) && + !uid_eq(fl1->owner.uid, fl->owner.uid))) + goto release; + + err = -ENOMEM; + if (!sfl1) + goto release; + if (fl->linger > fl1->linger) + fl1->linger = fl->linger; + if ((long)(fl->expires - fl1->expires) > 0) + fl1->expires = fl->expires; + fl_link(np, sfl1, fl1); + fl_free(fl); + return 0; release: - fl_release(fl1); - goto done; - } - } - err = -ENOENT; - if (!(freq.flr_flags&IPV6_FL_F_CREATE)) + fl_release(fl1); goto done; + } + } + err = -ENOENT; + if (!(freq->flr_flags & IPV6_FL_F_CREATE)) + goto done; - err = -ENOMEM; - if (!sfl1) - goto done; + err = -ENOMEM; + if (!sfl1) + goto done; - err = mem_check(sk); - if (err != 0) - goto done; + err = mem_check(sk); + if (err != 0) + goto done; - fl1 = fl_intern(net, fl, freq.flr_label); - if (fl1) - goto recheck; + fl1 = fl_intern(net, fl, freq->flr_label); + if (fl1) + goto recheck; - if (!freq.flr_label) { - if (copy_to_user(&((struct in6_flowlabel_req __user *) optval)->flr_label, - &fl->label, sizeof(fl->label))) { - /* Intentionally ignore fault. */ - } + if (!freq->flr_label) { + if (copy_to_user(&((struct in6_flowlabel_req __user *) optval)->flr_label, + &fl->label, sizeof(fl->label))) { + /* Intentionally ignore fault. */ } - - fl_link(np, sfl1, fl); - return 0; - - default: - return -EINVAL; } + fl_link(np, sfl1, fl); + return 0; done: fl_free(fl); kfree(sfl1); return err; } +int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen) +{ + struct in6_flowlabel_req freq; + + if (optlen < sizeof(freq)) + return -EINVAL; + if (copy_from_user(&freq, optval, sizeof(freq))) + return -EFAULT; + + switch (freq.flr_action) { + case IPV6_FL_A_PUT: + return ipv6_flowlabel_put(sk, &freq); + case IPV6_FL_A_RENEW: + return ipv6_flowlabel_renew(sk, &freq); + case IPV6_FL_A_GET: + return ipv6_flowlabel_get(sk, &freq, optval, optlen); + default: + return -EINVAL; + } +} + #ifdef CONFIG_PROC_FS struct ip6fl_iter_state { -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MEMOBt6SFV+c4QEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:49:34 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +O2DBN6SFV/j2gAADc0bRg (envelope-from ); Mon, 20 Jul 2020 14:49:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8CD13A26F7; Mon, 20 Jul 2020 14:49:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729261AbgGTMsz (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729253AbgGTMsx (ORCPT ); Mon, 20 Jul 2020 08:48:53 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BA45C061794; Mon, 20 Jul 2020 05:48:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=XFgdEhn2vLmThLShP1o7gYGDYV3zgNoNH4PA05fsJS8=; b=Wkzy9EJDG4l7lgluY2A4k1gkzk dHXnUTdC/Nhh1WIcSPASdHtlIMwcRj8ffKYWkm/ND2HeOF9pwAr6W0kFtq++kQkmsFbDKkGph29TG mLxMkHP/KhFXpyNQnHvKtgkdUiKmemflpUt39osjFaqvvF/EFGdVXCXHfwu5HIh/q2IOaC35QPVM6 DUvpfkRYCdoLNG0Zz72Bb7JVAWpDKbATSgbOwnqvggK4gHxNhJVnpZGhEV0mRP+mMAL7ub9tuTAvU xQHw+/y8tgti6Qyzdrzl2hUUfwrzU7JnbzMGgsdbBO4RfqCvdlUEEmDH0RkjxN+ICaczwlL2GumfX JoHLgVXw==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDk-0004dj-69; Mon, 20 Jul 2020 12:48:42 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 22/24] net/tcp: switch ->md5_parse to sockptr_t Date: Mon, 20 Jul 2020 14:47:35 +0200 Message-Id: <20200720124737.118617-23-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8CD13A26F7 X-Rspamd-UID: a12137 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/net/tcp.h | 2 +- net/ipv4/tcp.c | 3 ++- net/ipv4/tcp_ipv4.c | 4 ++-- net/ipv6/tcp_ipv6.c | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 9f7f7c0c110451..e3c8e1d820214c 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2002,7 +2002,7 @@ struct tcp_sock_af_ops { const struct sk_buff *skb); int (*md5_parse)(struct sock *sk, int optname, - char __user *optval, + sockptr_t optval, int optlen); #endif }; diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 58ede3d62b2e2c..49bf15c27deac7 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3249,7 +3249,8 @@ static int do_tcp_setsockopt(struct sock *sk, int level, #ifdef CONFIG_TCP_MD5SIG case TCP_MD5SIG: case TCP_MD5SIG_EXT: - err = tp->af_specific->md5_parse(sk, optname, optval, optlen); + err = tp->af_specific->md5_parse(sk, optname, + USER_SOCKPTR(optval), optlen); break; #endif case TCP_USER_TIMEOUT: diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index cd81b6e04efbfa..a03e70b3af2e6c 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1194,7 +1194,7 @@ static void tcp_clear_md5_list(struct sock *sk) } static int tcp_v4_parse_md5_keys(struct sock *sk, int optname, - char __user *optval, int optlen) + sockptr_t optval, int optlen) { struct tcp_md5sig cmd; struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr; @@ -1205,7 +1205,7 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, int optname, if (optlen < sizeof(cmd)) return -EINVAL; - if (copy_from_user(&cmd, optval, sizeof(cmd))) + if (copy_from_sockptr(&cmd, optval, sizeof(cmd))) return -EFAULT; if (sin->sin_family != AF_INET) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index c34b7834fd84a8..305870a72352d6 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -567,7 +567,7 @@ static struct tcp_md5sig_key *tcp_v6_md5_lookup(const struct sock *sk, } static int tcp_v6_parse_md5_keys(struct sock *sk, int optname, - char __user *optval, int optlen) + sockptr_t optval, int optlen) { struct tcp_md5sig cmd; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&cmd.tcpm_addr; @@ -577,7 +577,7 @@ static int tcp_v6_parse_md5_keys(struct sock *sk, int optname, if (optlen < sizeof(cmd)) return -EINVAL; - if (copy_from_user(&cmd, optval, sizeof(cmd))) + if (copy_from_sockptr(&cmd, optval, sizeof(cmd))) return -EFAULT; if (sin6->sin6_family != AF_INET6) -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SJXzFfuSFV+c4QEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:50:03 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 6GwyFPuSFV8MzQAADc0bRg (envelope-from ); Mon, 20 Jul 2020 14:50:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 889EAA010E; Mon, 20 Jul 2020 14:49:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729323AbgGTMtJ (ORCPT + 1 other); Mon, 20 Jul 2020 08:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729304AbgGTMtE (ORCPT ); Mon, 20 Jul 2020 08:49:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90CDDC061794; Mon, 20 Jul 2020 05:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=1rnPvvPPecmSNTNnxYXIswE+KjAHjGp1wPZw9d1lRuE=; b=IFMqt8wlpOji34hocDEPM6oed0 pvd6FCQxTDtRIlVnyQpR7z6BtMiOeI4twLsXMlluYfYJAF21LBZzmJw+y6h+1yBhV71TpMhE3XQK2 Boy2R++HB6bXj6P6VxIAXYPajjp19GwTH3AQtY0rUg7XQkfFQEe9IRSdecu2MXCuy0i8CzLCJMPS/ eestCvCbndy2CkSkBc1PCkpauY7Ow/OWi86eAEHYDkyg15ky1xxm9vTCOrd3Z2tmPbiUcbqhM/T55 SeGLz3R/YXhDiPpD8SVVpCWXv35NPIsDQzhRkb1MI+P17fE2XiEnXtd9DXnei0uhaClMC9sxnLmZ+ qFdVS77Q==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDp-0004fB-Uz; Mon, 20 Jul 2020 12:48:47 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 24/24] net: pass a sockptr_t into ->setsockopt Date: Mon, 20 Jul 2020 14:47:37 +0200 Message-Id: <20200720124737.118617-25-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 889EAA010E X-Rspamd-UID: fcacea Rework the remaining setsockopt code to pass a sockptr_t instead of a plain user pointer. This removes the last remaining set_fs(KERNEL_DS) outside of architecture specific code. Signed-off-by: Christoph Hellwig --- crypto/af_alg.c | 7 ++-- drivers/crypto/chelsio/chtls/chtls_main.c | 18 ++++++----- drivers/isdn/mISDN/socket.c | 4 +-- include/linux/net.h | 4 ++- include/net/inet_connection_sock.h | 3 +- include/net/ip.h | 2 +- include/net/ipv6.h | 4 +-- include/net/sctp/structs.h | 2 +- include/net/sock.h | 4 +-- include/net/tcp.h | 4 +-- net/atm/common.c | 6 ++-- net/atm/common.h | 2 +- net/atm/pvc.c | 2 +- net/atm/svc.c | 6 ++-- net/ax25/af_ax25.c | 6 ++-- net/bluetooth/hci_sock.c | 8 ++--- net/bluetooth/l2cap_sock.c | 22 ++++++------- net/bluetooth/rfcomm/sock.c | 12 ++++--- net/bluetooth/sco.c | 6 ++-- net/caif/caif_socket.c | 8 ++--- net/can/j1939/socket.c | 12 +++---- net/can/raw.c | 16 +++++----- net/core/sock.c | 2 +- net/dccp/dccp.h | 2 +- net/dccp/proto.c | 20 ++++++------ net/decnet/af_decnet.c | 16 ++++++---- net/ieee802154/socket.c | 6 ++-- net/ipv4/ip_sockglue.c | 13 +++----- net/ipv4/raw.c | 8 ++--- net/ipv4/tcp.c | 5 ++- net/ipv4/udp.c | 6 ++-- net/ipv4/udp_impl.h | 4 +-- net/ipv6/ipv6_sockglue.c | 10 +++--- net/ipv6/raw.c | 10 +++--- net/ipv6/udp.c | 6 ++-- net/ipv6/udp_impl.h | 4 +-- net/iucv/af_iucv.c | 4 +-- net/kcm/kcmsock.c | 6 ++-- net/l2tp/l2tp_ppp.c | 4 +-- net/llc/af_llc.c | 4 +-- net/mptcp/protocol.c | 14 ++++---- net/netlink/af_netlink.c | 4 +-- net/netrom/af_netrom.c | 4 +-- net/nfc/llcp_sock.c | 6 ++-- net/packet/af_packet.c | 39 ++++++++++++----------- net/phonet/pep.c | 4 +-- net/rds/af_rds.c | 30 ++++++++--------- net/rds/rdma.c | 14 ++++---- net/rds/rds.h | 6 ++-- net/rose/af_rose.c | 4 +-- net/rxrpc/af_rxrpc.c | 8 ++--- net/rxrpc/ar-internal.h | 4 +-- net/rxrpc/key.c | 9 +++--- net/sctp/socket.c | 4 +-- net/smc/af_smc.c | 4 +-- net/socket.c | 23 ++++--------- net/tipc/socket.c | 8 ++--- net/tls/tls_main.c | 17 +++++----- net/vmw_vsock/af_vsock.c | 4 +-- net/x25/af_x25.c | 4 +-- net/xdp/xsk.c | 8 ++--- 61 files changed, 248 insertions(+), 258 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 29f71428520b4b..892242a42c3ec9 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -197,8 +197,7 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) return err; } -static int alg_setkey(struct sock *sk, char __user *ukey, - unsigned int keylen) +static int alg_setkey(struct sock *sk, sockptr_t ukey, unsigned int keylen) { struct alg_sock *ask = alg_sk(sk); const struct af_alg_type *type = ask->type; @@ -210,7 +209,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey, return -ENOMEM; err = -EFAULT; - if (copy_from_user(key, ukey, keylen)) + if (copy_from_sockptr(key, ukey, keylen)) goto out; err = type->setkey(ask->private, key, keylen); @@ -222,7 +221,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey, } static int alg_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct alg_sock *ask = alg_sk(sk); diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c b/drivers/crypto/chelsio/chtls/chtls_main.c index d98b89d0fa6eeb..c3058dcdb33c5c 100644 --- a/drivers/crypto/chelsio/chtls/chtls_main.c +++ b/drivers/crypto/chelsio/chtls/chtls_main.c @@ -488,7 +488,7 @@ static int chtls_getsockopt(struct sock *sk, int level, int optname, } static int do_chtls_setsockopt(struct sock *sk, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct tls_crypto_info *crypto_info, tmp_crypto_info; struct chtls_sock *csk; @@ -498,12 +498,12 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, csk = rcu_dereference_sk_user_data(sk); - if (!optval || optlen < sizeof(*crypto_info)) { + if (sockptr_is_null(optval) || optlen < sizeof(*crypto_info)) { rc = -EINVAL; goto out; } - rc = copy_from_user(&tmp_crypto_info, optval, sizeof(*crypto_info)); + rc = copy_from_sockptr(&tmp_crypto_info, optval, sizeof(*crypto_info)); if (rc) { rc = -EFAULT; goto out; @@ -525,8 +525,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, /* Obtain version and type from previous copy */ crypto_info[0] = tmp_crypto_info; /* Now copy the following data */ - rc = copy_from_user((char *)crypto_info + sizeof(*crypto_info), - optval + sizeof(*crypto_info), + sockptr_advance(optval, sizeof(*crypto_info)); + rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), + optval, sizeof(struct tls12_crypto_info_aes_gcm_128) - sizeof(*crypto_info)); @@ -541,8 +542,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, } case TLS_CIPHER_AES_GCM_256: { crypto_info[0] = tmp_crypto_info; - rc = copy_from_user((char *)crypto_info + sizeof(*crypto_info), - optval + sizeof(*crypto_info), + sockptr_advance(optval, sizeof(*crypto_info)); + rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), + optval, sizeof(struct tls12_crypto_info_aes_gcm_256) - sizeof(*crypto_info)); @@ -565,7 +567,7 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, } static int chtls_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct tls_context *ctx = tls_get_ctx(sk); diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c index 1b2b91479107bc..2835daae9e9f3a 100644 --- a/drivers/isdn/mISDN/socket.c +++ b/drivers/isdn/mISDN/socket.c @@ -401,7 +401,7 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) } static int data_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int len) + sockptr_t optval, unsigned int len) { struct sock *sk = sock->sk; int err = 0, opt = 0; @@ -414,7 +414,7 @@ static int data_sock_setsockopt(struct socket *sock, int level, int optname, switch (optname) { case MISDN_TIME_STAMP: - if (get_user(opt, (int __user *)optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(int))) { err = -EFAULT; break; } diff --git a/include/linux/net.h b/include/linux/net.h index 858ff1d981540d..d48ff11808794c 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -162,7 +163,8 @@ struct proto_ops { int (*listen) (struct socket *sock, int len); int (*shutdown) (struct socket *sock, int flags); int (*setsockopt)(struct socket *sock, int level, - int optname, char __user *optval, unsigned int optlen); + int optname, sockptr_t optval, + unsigned int optlen); int (*getsockopt)(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen); void (*show_fdinfo)(struct seq_file *m, struct socket *sock); diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 157c60cca0ca60..1e209ce7d1bd1b 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -45,7 +46,7 @@ struct inet_connection_sock_af_ops { u16 net_frag_header_len; u16 sockaddr_len; int (*setsockopt)(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); + sockptr_t optval, unsigned int optlen); int (*getsockopt)(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); void (*addr2sockaddr)(struct sock *sk, struct sockaddr *); diff --git a/include/net/ip.h b/include/net/ip.h index d66ad3a9522081..b09c48d862cc10 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -722,7 +722,7 @@ void ip_cmsg_recv_offset(struct msghdr *msg, struct sock *sk, struct sk_buff *skb, int tlen, int offset); int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc, bool allow_ipv6); -int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, +int ip_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, unsigned int optlen); int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 4c9d89b5d73268..bd1f396cc9c729 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -1084,8 +1084,8 @@ struct in6_addr *fl6_update_dst(struct flowi6 *fl6, * socket options (ipv6_sockglue.c) */ -int ipv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); +int ipv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen); int ipv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 233bbf7df5d66c..b33f1aefad0989 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -431,7 +431,7 @@ struct sctp_af { int (*setsockopt) (struct sock *sk, int level, int optname, - char __user *optval, + sockptr_t optval, unsigned int optlen); int (*getsockopt) (struct sock *sk, int level, diff --git a/include/net/sock.h b/include/net/sock.h index bfb2fe2fc36876..2cc3ba667908de 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1141,7 +1141,7 @@ struct proto { void (*destroy)(struct sock *sk); void (*shutdown)(struct sock *sk, int how); int (*setsockopt)(struct sock *sk, int level, - int optname, char __user *optval, + int optname, sockptr_t optval, unsigned int optlen); int (*getsockopt)(struct sock *sk, int level, int optname, char __user *optval, @@ -1734,7 +1734,7 @@ int sock_common_getsockopt(struct socket *sock, int level, int optname, int sock_common_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, int flags); int sock_common_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen); + sockptr_t optval, unsigned int optlen); void sk_common_release(struct sock *sk); diff --git a/include/net/tcp.h b/include/net/tcp.h index e3c8e1d820214c..e0c35d56091f22 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -399,8 +399,8 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, struct poll_table_struct *wait); int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); -int tcp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); +int tcp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen); void tcp_set_keepalive(struct sock *sk, int val); void tcp_syn_ack_timeout(const struct request_sock *req); int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock, diff --git a/net/atm/common.c b/net/atm/common.c index 9b28f1fb3c69c8..84367b844b1473 100644 --- a/net/atm/common.c +++ b/net/atm/common.c @@ -745,7 +745,7 @@ static int check_qos(const struct atm_qos *qos) } int vcc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct atm_vcc *vcc; unsigned long value; @@ -760,7 +760,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, { struct atm_qos qos; - if (copy_from_user(&qos, optval, sizeof(qos))) + if (copy_from_sockptr(&qos, optval, sizeof(qos))) return -EFAULT; error = check_qos(&qos); if (error) @@ -774,7 +774,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, return 0; } case SO_SETCLP: - if (get_user(value, (unsigned long __user *)optval)) + if (copy_from_sockptr(&value, optval, sizeof(value))) return -EFAULT; if (value) vcc->atm_options |= ATM_ATMOPT_CLP; diff --git a/net/atm/common.h b/net/atm/common.h index 5850649068bb29..a1e56e8de698a3 100644 --- a/net/atm/common.h +++ b/net/atm/common.h @@ -21,7 +21,7 @@ __poll_t vcc_poll(struct file *file, struct socket *sock, poll_table *wait); int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); int vcc_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); int vcc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen); + sockptr_t optval, unsigned int optlen); int vcc_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen); void vcc_process_recv_queue(struct atm_vcc *vcc); diff --git a/net/atm/pvc.c b/net/atm/pvc.c index 02bd2a436bdf9e..53e7d3f39e26cc 100644 --- a/net/atm/pvc.c +++ b/net/atm/pvc.c @@ -63,7 +63,7 @@ static int pvc_connect(struct socket *sock, struct sockaddr *sockaddr, } static int pvc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; int error; diff --git a/net/atm/svc.c b/net/atm/svc.c index ba144d035e3d41..4a02bcaad279f8 100644 --- a/net/atm/svc.c +++ b/net/atm/svc.c @@ -451,7 +451,7 @@ int svc_change_qos(struct atm_vcc *vcc, struct atm_qos *qos) } static int svc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct atm_vcc *vcc = ATM_SD(sock); @@ -464,7 +464,7 @@ static int svc_setsockopt(struct socket *sock, int level, int optname, error = -EINVAL; goto out; } - if (copy_from_user(&vcc->sap, optval, optlen)) { + if (copy_from_sockptr(&vcc->sap, optval, optlen)) { error = -EFAULT; goto out; } @@ -475,7 +475,7 @@ static int svc_setsockopt(struct socket *sock, int level, int optname, error = -EINVAL; goto out; } - if (get_user(value, (int __user *)optval)) { + if (copy_from_sockptr(&value, optval, sizeof(int))) { error = -EFAULT; goto out; } diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index fd91cd34f25e03..17bf31a8969284 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -528,7 +528,7 @@ ax25_cb *ax25_create_cb(void) */ static int ax25_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; ax25_cb *ax25; @@ -543,7 +543,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(unsigned int)) return -EINVAL; - if (get_user(opt, (unsigned int __user *)optval)) + if (copy_from_sockptr(&opt, optval, sizeof(unsigned int))) return -EFAULT; lock_sock(sk); @@ -640,7 +640,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, memset(devname, 0, sizeof(devname)); - if (copy_from_user(devname, optval, optlen)) { + if (copy_from_sockptr(devname, optval, optlen)) { res = -EFAULT; break; } diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index caf38a8ea6a8ba..d5eff27d5b1e17 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -1842,7 +1842,7 @@ static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg, } static int hci_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int len) + sockptr_t optval, unsigned int len) { struct hci_ufilter uf = { .opcode = 0 }; struct sock *sk = sock->sk; @@ -1862,7 +1862,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, switch (optname) { case HCI_DATA_DIR: - if (get_user(opt, (int __user *)optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(opt))) { err = -EFAULT; break; } @@ -1874,7 +1874,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, break; case HCI_TIME_STAMP: - if (get_user(opt, (int __user *)optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(opt))) { err = -EFAULT; break; } @@ -1896,7 +1896,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, } len = min_t(unsigned int, len, sizeof(uf)); - if (copy_from_user(&uf, optval, len)) { + if (copy_from_sockptr(&uf, optval, len)) { err = -EFAULT; break; } diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index a995d2c51fa7f1..a3d104123f38dd 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -703,7 +703,7 @@ static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu) } static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; @@ -736,7 +736,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, opts.txwin_size = chan->tx_win; len = min_t(unsigned int, sizeof(opts), optlen); - if (copy_from_user((char *) &opts, optval, len)) { + if (copy_from_sockptr(&opts, optval, len)) { err = -EFAULT; break; } @@ -782,7 +782,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, break; case L2CAP_LM: - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -859,7 +859,7 @@ static int l2cap_set_mode(struct l2cap_chan *chan, u8 mode) } static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; @@ -891,7 +891,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, sec.level = BT_SECURITY_LOW; len = min_t(unsigned int, sizeof(sec), optlen); - if (copy_from_user((char *) &sec, optval, len)) { + if (copy_from_sockptr(&sec, optval, len)) { err = -EFAULT; break; } @@ -939,7 +939,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -954,7 +954,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; case BT_FLUSHABLE: - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -990,7 +990,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, pwr.force_active = BT_POWER_FORCE_ACTIVE_ON; len = min_t(unsigned int, sizeof(pwr), optlen); - if (copy_from_user((char *) &pwr, optval, len)) { + if (copy_from_sockptr(&pwr, optval, len)) { err = -EFAULT; break; } @@ -1002,7 +1002,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; case BT_CHANNEL_POLICY: - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -1050,7 +1050,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u16 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u16))) { err = -EFAULT; break; } @@ -1081,7 +1081,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u8 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u8))) { err = -EFAULT; break; } diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index df14eebe80da8b..dba4ea0e1b0dc7 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -644,7 +644,8 @@ static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg, return len; } -static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen) +static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; int err = 0; @@ -656,7 +657,7 @@ static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __u switch (optname) { case RFCOMM_LM: - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -685,7 +686,8 @@ static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __u return err; } -static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) +static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct bt_security sec; @@ -713,7 +715,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c sec.level = BT_SECURITY_LOW; len = min_t(unsigned int, sizeof(sec), optlen); - if (copy_from_user((char *) &sec, optval, len)) { + if (copy_from_sockptr(&sec, optval, len)) { err = -EFAULT; break; } @@ -732,7 +734,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c break; } - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index c8c3d38cdc7b56..37260baf71507b 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -791,7 +791,7 @@ static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg, } static int sco_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; int len, err = 0; @@ -810,7 +810,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -831,7 +831,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, voice.setting = sco_pi(sk)->setting; len = min_t(unsigned int, sizeof(voice), optlen); - if (copy_from_user((char *)&voice, optval, len)) { + if (copy_from_sockptr(&voice, optval, len)) { err = -EFAULT; break; } diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c index b94ecd931002e7..3ad0a1df671283 100644 --- a/net/caif/caif_socket.c +++ b/net/caif/caif_socket.c @@ -669,8 +669,8 @@ static int caif_stream_sendmsg(struct socket *sock, struct msghdr *msg, return sent ? : err; } -static int setsockopt(struct socket *sock, - int lvl, int opt, char __user *ov, unsigned int ol) +static int setsockopt(struct socket *sock, int lvl, int opt, sockptr_t ov, + unsigned int ol) { struct sock *sk = sock->sk; struct caifsock *cf_sk = container_of(sk, struct caifsock, sk); @@ -685,7 +685,7 @@ static int setsockopt(struct socket *sock, return -EINVAL; if (lvl != SOL_CAIF) goto bad_sol; - if (copy_from_user(&linksel, ov, sizeof(int))) + if (copy_from_sockptr(&linksel, ov, sizeof(int))) return -EINVAL; lock_sock(&(cf_sk->sk)); cf_sk->conn_req.link_selector = linksel; @@ -699,7 +699,7 @@ static int setsockopt(struct socket *sock, return -ENOPROTOOPT; lock_sock(&(cf_sk->sk)); if (ol > sizeof(cf_sk->conn_req.param.data) || - copy_from_user(&cf_sk->conn_req.param.data, ov, ol)) { + copy_from_sockptr(&cf_sk->conn_req.param.data, ov, ol)) { release_sock(&cf_sk->sk); return -EINVAL; } diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c index f7587428febdd2..78ff9b3f1d40c7 100644 --- a/net/can/j1939/socket.c +++ b/net/can/j1939/socket.c @@ -627,14 +627,14 @@ static int j1939_sk_release(struct socket *sock) return 0; } -static int j1939_sk_setsockopt_flag(struct j1939_sock *jsk, char __user *optval, +static int j1939_sk_setsockopt_flag(struct j1939_sock *jsk, sockptr_t optval, unsigned int optlen, int flag) { int tmp; if (optlen != sizeof(tmp)) return -EINVAL; - if (copy_from_user(&tmp, optval, optlen)) + if (copy_from_sockptr(&tmp, optval, optlen)) return -EFAULT; lock_sock(&jsk->sk); if (tmp) @@ -646,7 +646,7 @@ static int j1939_sk_setsockopt_flag(struct j1939_sock *jsk, char __user *optval, } static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct j1939_sock *jsk = j1939_sk(sk); @@ -658,7 +658,7 @@ static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, switch (optname) { case SO_J1939_FILTER: - if (optval) { + if (!sockptr_is_null(optval)) { struct j1939_filter *f; int c; @@ -670,7 +670,7 @@ static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, return -EINVAL; count = optlen / sizeof(*filters); - filters = memdup_user(optval, optlen); + filters = memdup_sockptr(optval, optlen); if (IS_ERR(filters)) return PTR_ERR(filters); @@ -703,7 +703,7 @@ static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, case SO_J1939_SEND_PRIO: if (optlen != sizeof(tmp)) return -EINVAL; - if (copy_from_user(&tmp, optval, optlen)) + if (copy_from_sockptr(&tmp, optval, optlen)) return -EFAULT; if (tmp < 0 || tmp > 7) return -EDOM; diff --git a/net/can/raw.c b/net/can/raw.c index 59c039d73c6d58..94a9405658dc61 100644 --- a/net/can/raw.c +++ b/net/can/raw.c @@ -485,7 +485,7 @@ static int raw_getname(struct socket *sock, struct sockaddr *uaddr, } static int raw_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct raw_sock *ro = raw_sk(sk); @@ -511,11 +511,11 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (count > 1) { /* filter does not fit into dfilter => alloc space */ - filter = memdup_user(optval, optlen); + filter = memdup_sockptr(optval, optlen); if (IS_ERR(filter)) return PTR_ERR(filter); } else if (count == 1) { - if (copy_from_user(&sfilter, optval, sizeof(sfilter))) + if (copy_from_sockptr(&sfilter, optval, sizeof(sfilter))) return -EFAULT; } @@ -568,7 +568,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(err_mask)) return -EINVAL; - if (copy_from_user(&err_mask, optval, optlen)) + if (copy_from_sockptr(&err_mask, optval, optlen)) return -EFAULT; err_mask &= CAN_ERR_MASK; @@ -607,7 +607,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(ro->loopback)) return -EINVAL; - if (copy_from_user(&ro->loopback, optval, optlen)) + if (copy_from_sockptr(&ro->loopback, optval, optlen)) return -EFAULT; break; @@ -616,7 +616,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(ro->recv_own_msgs)) return -EINVAL; - if (copy_from_user(&ro->recv_own_msgs, optval, optlen)) + if (copy_from_sockptr(&ro->recv_own_msgs, optval, optlen)) return -EFAULT; break; @@ -625,7 +625,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(ro->fd_frames)) return -EINVAL; - if (copy_from_user(&ro->fd_frames, optval, optlen)) + if (copy_from_sockptr(&ro->fd_frames, optval, optlen)) return -EFAULT; break; @@ -634,7 +634,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(ro->join_filters)) return -EINVAL; - if (copy_from_user(&ro->join_filters, optval, optlen)) + if (copy_from_sockptr(&ro->join_filters, optval, optlen)) return -EFAULT; break; diff --git a/net/core/sock.c b/net/core/sock.c index 9cf8318bc51de4..ff22629f10ce92 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3210,7 +3210,7 @@ EXPORT_SYMBOL(sock_common_recvmsg); * Set socket options on an inet socket. */ int sock_common_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 434eea91b7679d..9cc9d1ee6cdb9a 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h @@ -295,7 +295,7 @@ int dccp_disconnect(struct sock *sk, int flags); int dccp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); int dccp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); + sockptr_t optval, unsigned int optlen); int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg); int dccp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size); int dccp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock, diff --git a/net/dccp/proto.c b/net/dccp/proto.c index fd92d3fe321f08..9e58787047f197 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -402,7 +402,7 @@ int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg) EXPORT_SYMBOL_GPL(dccp_ioctl); static int dccp_setsockopt_service(struct sock *sk, const __be32 service, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct dccp_sock *dp = dccp_sk(sk); struct dccp_service_list *sl = NULL; @@ -417,9 +417,9 @@ static int dccp_setsockopt_service(struct sock *sk, const __be32 service, return -ENOMEM; sl->dccpsl_nr = optlen / sizeof(u32) - 1; - if (copy_from_user(sl->dccpsl_list, - optval + sizeof(service), - optlen - sizeof(service)) || + sockptr_advance(optval, sizeof(service)); + if (copy_from_sockptr(sl->dccpsl_list, optval, + optlen - sizeof(service)) || dccp_list_has_service(sl, DCCP_SERVICE_INVALID_VALUE)) { kfree(sl); return -EFAULT; @@ -473,7 +473,7 @@ static int dccp_setsockopt_cscov(struct sock *sk, int cscov, bool rx) } static int dccp_setsockopt_ccid(struct sock *sk, int type, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { u8 *val; int rc = 0; @@ -481,7 +481,7 @@ static int dccp_setsockopt_ccid(struct sock *sk, int type, if (optlen < 1 || optlen > DCCP_FEAT_MAX_SP_VALS) return -EINVAL; - val = memdup_user(optval, optlen); + val = memdup_sockptr(optval, optlen); if (IS_ERR(val)) return PTR_ERR(val); @@ -498,7 +498,7 @@ static int dccp_setsockopt_ccid(struct sock *sk, int type, } static int do_dccp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct dccp_sock *dp = dccp_sk(sk); int val, err = 0; @@ -520,7 +520,7 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname, if (optlen < (int)sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; if (optname == DCCP_SOCKOPT_SERVICE) @@ -563,8 +563,8 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname, return err; } -int dccp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) +int dccp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen) { if (level != SOL_DCCP) return inet_csk(sk)->icsk_af_ops->setsockopt(sk, level, diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index 7d51ab608fb3f1..3b53d766789d47 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c @@ -150,7 +150,8 @@ static struct hlist_head dn_sk_hash[DN_SK_HASH_SIZE]; static struct hlist_head dn_wild_sk; static atomic_long_t decnet_memory_allocated; -static int __dn_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen, int flags); +static int __dn_setsockopt(struct socket *sock, int level, int optname, + sockptr_t optval, unsigned int optlen, int flags); static int __dn_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen, int flags); static struct hlist_head *dn_find_list(struct sock *sk) @@ -1320,7 +1321,8 @@ static int dn_shutdown(struct socket *sock, int how) return err; } -static int dn_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) +static int dn_setsockopt(struct socket *sock, int level, int optname, + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; int err; @@ -1332,14 +1334,14 @@ static int dn_setsockopt(struct socket *sock, int level, int optname, char __use /* we need to exclude all possible ENOPROTOOPTs except default case */ if (err == -ENOPROTOOPT && optname != DSO_LINKINFO && optname != DSO_STREAM && optname != DSO_SEQPACKET) - err = nf_setsockopt(sk, PF_DECnet, optname, - USER_SOCKPTR(optval), optlen); + err = nf_setsockopt(sk, PF_DECnet, optname, optval, optlen); #endif return err; } -static int __dn_setsockopt(struct socket *sock, int level,int optname, char __user *optval, unsigned int optlen, int flags) +static int __dn_setsockopt(struct socket *sock, int level, int optname, + sockptr_t optval, unsigned int optlen, int flags) { struct sock *sk = sock->sk; struct dn_scp *scp = DN_SK(sk); @@ -1355,13 +1357,13 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us } u; int err; - if (optlen && !optval) + if (optlen && sockptr_is_null(optval)) return -EINVAL; if (optlen > sizeof(u)) return -EINVAL; - if (copy_from_user(&u, optval, optlen)) + if (copy_from_sockptr(&u, optval, optlen)) return -EFAULT; switch (optname) { diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c index 94ae9662133e30..a45a0401adc50b 100644 --- a/net/ieee802154/socket.c +++ b/net/ieee802154/socket.c @@ -382,7 +382,7 @@ static int raw_getsockopt(struct sock *sk, int level, int optname, } static int raw_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { return -EOPNOTSUPP; } @@ -872,7 +872,7 @@ static int dgram_getsockopt(struct sock *sk, int level, int optname, } static int dgram_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct dgram_sock *ro = dgram_sk(sk); struct net *net = sock_net(sk); @@ -882,7 +882,7 @@ static int dgram_setsockopt(struct sock *sk, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; lock_sock(sk); diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index f7f1507b89fe24..8dc027e54c5bfb 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1401,21 +1401,19 @@ void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb) skb_dst_drop(skb); } -int ip_setsockopt(struct sock *sk, int level, - int optname, char __user *optval, unsigned int optlen) +int ip_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen) { int err; if (level != SOL_IP) return -ENOPROTOOPT; - err = do_ip_setsockopt(sk, level, optname, USER_SOCKPTR(optval), - optlen); + err = do_ip_setsockopt(sk, level, optname, optval, optlen); #if IS_ENABLED(CONFIG_BPFILTER_UMH) if (optname >= BPFILTER_IPT_SO_SET_REPLACE && optname < BPFILTER_IPT_SET_MAX) - err = bpfilter_ip_set_sockopt(sk, optname, USER_SOCKPTR(optval), - optlen); + err = bpfilter_ip_set_sockopt(sk, optname, optval, optlen); #endif #ifdef CONFIG_NETFILTER /* we need to exclude all possible ENOPROTOOPTs except default case */ @@ -1423,8 +1421,7 @@ int ip_setsockopt(struct sock *sk, int level, optname != IP_IPSEC_POLICY && optname != IP_XFRM_POLICY && !ip_mroute_opt(optname)) - err = nf_setsockopt(sk, PF_INET, optname, USER_SOCKPTR(optval), - optlen); + err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); #endif return err; } diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 2a57d633b31e00..6fd4330287c279 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -809,11 +809,11 @@ static int raw_sk_init(struct sock *sk) return 0; } -static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen) +static int raw_seticmpfilter(struct sock *sk, sockptr_t optval, int optlen) { if (optlen > sizeof(struct icmp_filter)) optlen = sizeof(struct icmp_filter); - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen)) + if (copy_from_sockptr(&raw_sk(sk)->filter, optval, optlen)) return -EFAULT; return 0; } @@ -838,7 +838,7 @@ out: return ret; } static int do_raw_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { if (optname == ICMP_FILTER) { if (inet_sk(sk)->inet_num != IPPROTO_ICMP) @@ -850,7 +850,7 @@ static int do_raw_setsockopt(struct sock *sk, int level, int optname, } static int raw_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { if (level != SOL_RAW) return ip_setsockopt(sk, level, optname, optval, optlen); diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 71cbc61c335f71..27de9380ed140e 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3323,7 +3323,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, int optname, return err; } -int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, +int tcp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, unsigned int optlen) { const struct inet_connection_sock *icsk = inet_csk(sk); @@ -3331,8 +3331,7 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, if (level != SOL_TCP) return icsk->icsk_af_ops->setsockopt(sk, level, optname, optval, optlen); - return do_tcp_setsockopt(sk, level, optname, USER_SOCKPTR(optval), - optlen); + return do_tcp_setsockopt(sk, level, optname, optval, optlen); } EXPORT_SYMBOL(tcp_setsockopt); diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 641303aa17d3dd..00b794a1035ce1 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2647,12 +2647,12 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, } EXPORT_SYMBOL(udp_lib_setsockopt); -int udp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) +int udp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen) { if (level == SOL_UDP || level == SOL_UDPLITE) return udp_lib_setsockopt(sk, level, optname, - USER_SOCKPTR(optval), optlen, + optval, optlen, udp_push_pending_frames); return ip_setsockopt(sk, level, optname, optval, optlen); } diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h index ab313702c87f30..2878d8285cafe7 100644 --- a/net/ipv4/udp_impl.h +++ b/net/ipv4/udp_impl.h @@ -12,8 +12,8 @@ int __udp4_lib_err(struct sk_buff *, u32, struct udp_table *); int udp_v4_get_port(struct sock *sk, unsigned short snum); void udp_v4_rehash(struct sock *sk); -int udp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); +int udp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen); int udp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index dcd000a5a9b124..d2282f5c9760f9 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -980,8 +980,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, return -EINVAL; } -int ipv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) +int ipv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen) { int err; @@ -991,14 +991,12 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, if (level != SOL_IPV6) return -ENOPROTOOPT; - err = do_ipv6_setsockopt(sk, level, optname, USER_SOCKPTR(optval), - optlen); + err = do_ipv6_setsockopt(sk, level, optname, optval, optlen); #ifdef CONFIG_NETFILTER /* we need to exclude all possible ENOPROTOOPTs except default case */ if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY && optname != IPV6_XFRM_POLICY) - err = nf_setsockopt(sk, PF_INET6, optname, USER_SOCKPTR(optval), - optlen); + err = nf_setsockopt(sk, PF_INET6, optname, optval, optlen); #endif return err; } diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 594e01ad670aa6..874f01cd7aec42 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -972,13 +972,13 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) } static int rawv6_seticmpfilter(struct sock *sk, int level, int optname, - char __user *optval, int optlen) + sockptr_t optval, int optlen) { switch (optname) { case ICMPV6_FILTER: if (optlen > sizeof(struct icmp6_filter)) optlen = sizeof(struct icmp6_filter); - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen)) + if (copy_from_sockptr(&raw6_sk(sk)->filter, optval, optlen)) return -EFAULT; return 0; default: @@ -1015,12 +1015,12 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname, static int do_rawv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct raw6_sock *rp = raw6_sk(sk); int val; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; switch (optname) { @@ -1062,7 +1062,7 @@ static int do_rawv6_setsockopt(struct sock *sk, int level, int optname, } static int rawv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { switch (level) { case SOL_RAW: diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 05353b31fa07bc..85238620541c3e 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1561,12 +1561,12 @@ void udpv6_destroy_sock(struct sock *sk) /* * Socket option code for UDP */ -int udpv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) +int udpv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen) { if (level == SOL_UDP || level == SOL_UDPLITE) return udp_lib_setsockopt(sk, level, optname, - USER_SOCKPTR(optval), optlen, + optval, optlen, udp_v6_push_pending_frames); return ipv6_setsockopt(sk, level, optname, optval, optlen); } diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h index 30dfb6f1b7622a..b2fcc46c1630e0 100644 --- a/net/ipv6/udp_impl.h +++ b/net/ipv6/udp_impl.h @@ -17,8 +17,8 @@ void udp_v6_rehash(struct sock *sk); int udpv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); -int udpv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); +int udpv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen); int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len); int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, int flags, int *addr_len); diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index ee0add15497d96..6ee9851ac7c680 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -1494,7 +1494,7 @@ static int iucv_sock_release(struct socket *sock) /* getsockopt and setsockopt */ static int iucv_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct iucv_sock *iucv = iucv_sk(sk); @@ -1507,7 +1507,7 @@ static int iucv_sock_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *) optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; rc = 0; diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index 56fac24a627a54..56dad9565bc93b 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -1265,7 +1265,7 @@ static void kcm_recv_enable(struct kcm_sock *kcm) } static int kcm_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct kcm_sock *kcm = kcm_sk(sock->sk); int val, valbool; @@ -1277,8 +1277,8 @@ static int kcm_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) - return -EINVAL; + if (copy_from_sockptr(&val, optval, sizeof(int))) + return -EFAULT; valbool = val ? 1 : 0; diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index c54cb59593ef81..c8842b2317409a 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -1244,7 +1244,7 @@ static int pppol2tp_session_setsockopt(struct sock *sk, * session or the special tunnel type. */ static int pppol2tp_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct l2tp_session *session; @@ -1258,7 +1258,7 @@ static int pppol2tp_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; err = -ENOTCONN; diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index 6140a3e46c26f1..7180979114e494 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -1053,7 +1053,7 @@ static int llc_ui_ioctl(struct socket *sock, unsigned int cmd, * Set various connection specific parameters. */ static int llc_ui_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct llc_sock *llc = llc_sk(sk); @@ -1063,7 +1063,7 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname, lock_sock(sk); if (unlikely(level != SOL_LLC || optlen != sizeof(int))) goto out; - rc = get_user(opt, (int __user *)optval); + rc = copy_from_sockptr(&opt, optval, sizeof(opt)); if (rc) goto out; rc = -EINVAL; diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 27b6f250b87dfd..30a8e697b9db9c 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1627,7 +1627,7 @@ static void mptcp_destroy(struct sock *sk) } static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = (struct sock *)msk; struct socket *ssock; @@ -1643,8 +1643,8 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, return -EINVAL; } - ret = sock_setsockopt(ssock, SOL_SOCKET, optname, - USER_SOCKPTR(optval), optlen); + ret = sock_setsockopt(ssock, SOL_SOCKET, optname, optval, + optlen); if (ret == 0) { if (optname == SO_REUSEPORT) sk->sk_reuseport = ssock->sk->sk_reuseport; @@ -1655,12 +1655,12 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, return ret; } - return sock_setsockopt(sk->sk_socket, SOL_SOCKET, optname, - USER_SOCKPTR(optval), optlen); + return sock_setsockopt(sk->sk_socket, SOL_SOCKET, optname, optval, + optlen); } static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = (struct sock *)msk; int ret = -EOPNOTSUPP; @@ -1687,7 +1687,7 @@ static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, } static int mptcp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct mptcp_sock *msk = mptcp_sk(sk); struct sock *ssk; diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 4f2c3b14ddbfa3..1d9750068cd65b 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1620,7 +1620,7 @@ static void netlink_update_socket_mc(struct netlink_sock *nlk, } static int netlink_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct netlink_sock *nlk = nlk_sk(sk); @@ -1631,7 +1631,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname, return -ENOPROTOOPT; if (optlen >= sizeof(int) && - get_user(val, (unsigned int __user *)optval)) + copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; switch (optname) { diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index f90ef6934b8f4d..6d16e1ab1a8aba 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -294,7 +294,7 @@ void nr_destroy_socket(struct sock *sk) */ static int nr_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct nr_sock *nr = nr_sk(sk); @@ -306,7 +306,7 @@ static int nr_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(unsigned int)) return -EINVAL; - if (get_user(opt, (unsigned int __user *)optval)) + if (copy_from_sockptr(&opt, optval, sizeof(unsigned int))) return -EFAULT; switch (optname) { diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index 6da1e2334bb697..d257ed3b732ae3 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -218,7 +218,7 @@ static int llcp_sock_listen(struct socket *sock, int backlog) } static int nfc_llcp_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); @@ -241,7 +241,7 @@ static int nfc_llcp_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -263,7 +263,7 @@ static int nfc_llcp_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index d8d4f78f78e451..0b8160d1a6e06d 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1558,7 +1558,7 @@ static int fanout_set_data_cbpf(struct packet_sock *po, sockptr_t data, return 0; } -static int fanout_set_data_ebpf(struct packet_sock *po, char __user *data, +static int fanout_set_data_ebpf(struct packet_sock *po, sockptr_t data, unsigned int len) { struct bpf_prog *new; @@ -1568,7 +1568,7 @@ static int fanout_set_data_ebpf(struct packet_sock *po, char __user *data, return -EPERM; if (len != sizeof(fd)) return -EINVAL; - if (copy_from_user(&fd, data, len)) + if (copy_from_sockptr(&fd, data, len)) return -EFAULT; new = bpf_prog_get_type(fd, BPF_PROG_TYPE_SOCKET_FILTER); @@ -1579,12 +1579,12 @@ static int fanout_set_data_ebpf(struct packet_sock *po, char __user *data, return 0; } -static int fanout_set_data(struct packet_sock *po, char __user *data, +static int fanout_set_data(struct packet_sock *po, sockptr_t data, unsigned int len) { switch (po->fanout->type) { case PACKET_FANOUT_CBPF: - return fanout_set_data_cbpf(po, USER_SOCKPTR(data), len); + return fanout_set_data_cbpf(po, data, len); case PACKET_FANOUT_EBPF: return fanout_set_data_ebpf(po, data, len); default: @@ -3652,7 +3652,8 @@ static void packet_flush_mclist(struct sock *sk) } static int -packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) +packet_setsockopt(struct socket *sock, int level, int optname, sockptr_t optval, + unsigned int optlen) { struct sock *sk = sock->sk; struct packet_sock *po = pkt_sk(sk); @@ -3672,7 +3673,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv return -EINVAL; if (len > sizeof(mreq)) len = sizeof(mreq); - if (copy_from_user(&mreq, optval, len)) + if (copy_from_sockptr(&mreq, optval, len)) return -EFAULT; if (len < (mreq.mr_alen + offsetof(struct packet_mreq, mr_address))) return -EINVAL; @@ -3703,7 +3704,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen < len) { ret = -EINVAL; } else { - if (copy_from_user(&req_u.req, optval, len)) + if (copy_from_sockptr(&req_u.req, optval, len)) ret = -EFAULT; else ret = packet_set_ring(sk, &req_u, 0, @@ -3718,7 +3719,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; pkt_sk(sk)->copy_thresh = val; @@ -3730,7 +3731,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; switch (val) { case TPACKET_V1: @@ -3756,7 +3757,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; if (val > INT_MAX) return -EINVAL; @@ -3776,7 +3777,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3795,7 +3796,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen < sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3809,7 +3810,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen < sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3825,7 +3826,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv return -EINVAL; if (optlen < sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3844,7 +3845,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; po->tp_tstamp = val; @@ -3856,7 +3857,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; return fanout_add(sk, val & 0xffff, val >> 16); @@ -3874,7 +3875,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; if (val < 0 || val > 1) return -EINVAL; @@ -3888,7 +3889,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3907,7 +3908,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; po->xmit = val ? packet_direct_xmit : dev_queue_xmit; diff --git a/net/phonet/pep.c b/net/phonet/pep.c index 4577e43cb77782..e47d09aca4af46 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c @@ -975,7 +975,7 @@ static int pep_init(struct sock *sk) } static int pep_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct pep_sock *pn = pep_sk(sk); int val = 0, err = 0; @@ -983,7 +983,7 @@ static int pep_setsockopt(struct sock *sk, int level, int optname, if (level != SOL_PNPIPE) return -ENOPROTOOPT; if (optlen >= sizeof(int)) { - if (get_user(val, (int __user *) optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; } diff --git a/net/rds/af_rds.c b/net/rds/af_rds.c index 1a5bf3fa4578b8..b239120dd9ca69 100644 --- a/net/rds/af_rds.c +++ b/net/rds/af_rds.c @@ -290,8 +290,7 @@ static int rds_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return 0; } -static int rds_cancel_sent_to(struct rds_sock *rs, char __user *optval, - int len) +static int rds_cancel_sent_to(struct rds_sock *rs, sockptr_t optval, int len) { struct sockaddr_in6 sin6; struct sockaddr_in sin; @@ -308,14 +307,15 @@ static int rds_cancel_sent_to(struct rds_sock *rs, char __user *optval, goto out; } else if (len < sizeof(struct sockaddr_in6)) { /* Assume IPv4 */ - if (copy_from_user(&sin, optval, sizeof(struct sockaddr_in))) { + if (copy_from_sockptr(&sin, optval, + sizeof(struct sockaddr_in))) { ret = -EFAULT; goto out; } ipv6_addr_set_v4mapped(sin.sin_addr.s_addr, &sin6.sin6_addr); sin6.sin6_port = sin.sin_port; } else { - if (copy_from_user(&sin6, optval, + if (copy_from_sockptr(&sin6, optval, sizeof(struct sockaddr_in6))) { ret = -EFAULT; goto out; @@ -327,21 +327,20 @@ static int rds_cancel_sent_to(struct rds_sock *rs, char __user *optval, return ret; } -static int rds_set_bool_option(unsigned char *optvar, char __user *optval, +static int rds_set_bool_option(unsigned char *optvar, sockptr_t optval, int optlen) { int value; if (optlen < sizeof(int)) return -EINVAL; - if (get_user(value, (int __user *) optval)) + if (copy_from_sockptr(&value, optval, sizeof(int))) return -EFAULT; *optvar = !!value; return 0; } -static int rds_cong_monitor(struct rds_sock *rs, char __user *optval, - int optlen) +static int rds_cong_monitor(struct rds_sock *rs, sockptr_t optval, int optlen) { int ret; @@ -358,8 +357,7 @@ static int rds_cong_monitor(struct rds_sock *rs, char __user *optval, return ret; } -static int rds_set_transport(struct rds_sock *rs, char __user *optval, - int optlen) +static int rds_set_transport(struct rds_sock *rs, sockptr_t optval, int optlen) { int t_type; @@ -369,7 +367,7 @@ static int rds_set_transport(struct rds_sock *rs, char __user *optval, if (optlen != sizeof(int)) return -EINVAL; - if (copy_from_user(&t_type, (int __user *)optval, sizeof(t_type))) + if (copy_from_sockptr(&t_type, optval, sizeof(t_type))) return -EFAULT; if (t_type < 0 || t_type >= RDS_TRANS_COUNT) @@ -380,7 +378,7 @@ static int rds_set_transport(struct rds_sock *rs, char __user *optval, return rs->rs_transport ? 0 : -ENOPROTOOPT; } -static int rds_enable_recvtstamp(struct sock *sk, char __user *optval, +static int rds_enable_recvtstamp(struct sock *sk, sockptr_t optval, int optlen, int optname) { int val, valbool; @@ -388,7 +386,7 @@ static int rds_enable_recvtstamp(struct sock *sk, char __user *optval, if (optlen != sizeof(int)) return -EFAULT; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; valbool = val ? 1 : 0; @@ -404,7 +402,7 @@ static int rds_enable_recvtstamp(struct sock *sk, char __user *optval, return 0; } -static int rds_recv_track_latency(struct rds_sock *rs, char __user *optval, +static int rds_recv_track_latency(struct rds_sock *rs, sockptr_t optval, int optlen) { struct rds_rx_trace_so trace; @@ -413,7 +411,7 @@ static int rds_recv_track_latency(struct rds_sock *rs, char __user *optval, if (optlen != sizeof(struct rds_rx_trace_so)) return -EFAULT; - if (copy_from_user(&trace, optval, sizeof(trace))) + if (copy_from_sockptr(&trace, optval, sizeof(trace))) return -EFAULT; if (trace.rx_traces > RDS_MSG_RX_DGRAM_TRACE_MAX) @@ -432,7 +430,7 @@ static int rds_recv_track_latency(struct rds_sock *rs, char __user *optval, } static int rds_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct rds_sock *rs = rds_sk_to_rs(sock->sk); int ret; diff --git a/net/rds/rdma.c b/net/rds/rdma.c index a7ae11846cd7f5..ccdd304eae0a0a 100644 --- a/net/rds/rdma.c +++ b/net/rds/rdma.c @@ -353,21 +353,20 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args, return ret; } -int rds_get_mr(struct rds_sock *rs, char __user *optval, int optlen) +int rds_get_mr(struct rds_sock *rs, sockptr_t optval, int optlen) { struct rds_get_mr_args args; if (optlen != sizeof(struct rds_get_mr_args)) return -EINVAL; - if (copy_from_user(&args, (struct rds_get_mr_args __user *)optval, - sizeof(struct rds_get_mr_args))) + if (copy_from_sockptr(&args, optval, sizeof(struct rds_get_mr_args))) return -EFAULT; return __rds_rdma_map(rs, &args, NULL, NULL, NULL); } -int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen) +int rds_get_mr_for_dest(struct rds_sock *rs, sockptr_t optval, int optlen) { struct rds_get_mr_for_dest_args args; struct rds_get_mr_args new_args; @@ -375,7 +374,7 @@ int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen) if (optlen != sizeof(struct rds_get_mr_for_dest_args)) return -EINVAL; - if (copy_from_user(&args, (struct rds_get_mr_for_dest_args __user *)optval, + if (copy_from_sockptr(&args, optval, sizeof(struct rds_get_mr_for_dest_args))) return -EFAULT; @@ -394,7 +393,7 @@ int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen) /* * Free the MR indicated by the given R_Key */ -int rds_free_mr(struct rds_sock *rs, char __user *optval, int optlen) +int rds_free_mr(struct rds_sock *rs, sockptr_t optval, int optlen) { struct rds_free_mr_args args; struct rds_mr *mr; @@ -403,8 +402,7 @@ int rds_free_mr(struct rds_sock *rs, char __user *optval, int optlen) if (optlen != sizeof(struct rds_free_mr_args)) return -EINVAL; - if (copy_from_user(&args, (struct rds_free_mr_args __user *)optval, - sizeof(struct rds_free_mr_args))) + if (copy_from_sockptr(&args, optval, sizeof(struct rds_free_mr_args))) return -EFAULT; /* Special case - a null cookie means flush all unused MRs */ diff --git a/net/rds/rds.h b/net/rds/rds.h index 106e862996b94d..d35d1fc3980766 100644 --- a/net/rds/rds.h +++ b/net/rds/rds.h @@ -924,9 +924,9 @@ int rds_send_pong(struct rds_conn_path *cp, __be16 dport); /* rdma.c */ void rds_rdma_unuse(struct rds_sock *rs, u32 r_key, int force); -int rds_get_mr(struct rds_sock *rs, char __user *optval, int optlen); -int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen); -int rds_free_mr(struct rds_sock *rs, char __user *optval, int optlen); +int rds_get_mr(struct rds_sock *rs, sockptr_t optval, int optlen); +int rds_get_mr_for_dest(struct rds_sock *rs, sockptr_t optval, int optlen); +int rds_free_mr(struct rds_sock *rs, sockptr_t optval, int optlen); void rds_rdma_drop_keys(struct rds_sock *rs); int rds_rdma_extra_size(struct rds_rdma_args *args, struct rds_iov_vector *iov); diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index ce85656ac9c159..cf7d974e0f619a 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -365,7 +365,7 @@ void rose_destroy_socket(struct sock *sk) */ static int rose_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct rose_sock *rose = rose_sk(sk); @@ -377,7 +377,7 @@ static int rose_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(opt, (int __user *)optval)) + if (copy_from_sockptr(&opt, optval, sizeof(int))) return -EFAULT; switch (optname) { diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c index cd7d0d204c7498..e6725a6de015fb 100644 --- a/net/rxrpc/af_rxrpc.c +++ b/net/rxrpc/af_rxrpc.c @@ -588,7 +588,7 @@ EXPORT_SYMBOL(rxrpc_sock_set_min_security_level); * set RxRPC socket options */ static int rxrpc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct rxrpc_sock *rx = rxrpc_sk(sock->sk); unsigned int min_sec_level; @@ -639,8 +639,8 @@ static int rxrpc_setsockopt(struct socket *sock, int level, int optname, ret = -EISCONN; if (rx->sk.sk_state != RXRPC_UNBOUND) goto error; - ret = get_user(min_sec_level, - (unsigned int __user *) optval); + ret = copy_from_sockptr(&min_sec_level, optval, + sizeof(unsigned int)); if (ret < 0) goto error; ret = -EINVAL; @@ -658,7 +658,7 @@ static int rxrpc_setsockopt(struct socket *sock, int level, int optname, if (rx->sk.sk_state != RXRPC_SERVER_BOUND2) goto error; ret = -EFAULT; - if (copy_from_user(service_upgrade, optval, + if (copy_from_sockptr(service_upgrade, optval, sizeof(service_upgrade)) != 0) goto error; ret = -EINVAL; diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h index 9a2139ebd67d73..6d29a3603a3e6e 100644 --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h @@ -909,8 +909,8 @@ extern const struct rxrpc_security rxrpc_no_security; extern struct key_type key_type_rxrpc; extern struct key_type key_type_rxrpc_s; -int rxrpc_request_key(struct rxrpc_sock *, char __user *, int); -int rxrpc_server_keyring(struct rxrpc_sock *, char __user *, int); +int rxrpc_request_key(struct rxrpc_sock *, sockptr_t , int); +int rxrpc_server_keyring(struct rxrpc_sock *, sockptr_t, int); int rxrpc_get_server_data_key(struct rxrpc_connection *, const void *, time64_t, u32); diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c index 0c98313dd7a8cb..94c3df392651b9 100644 --- a/net/rxrpc/key.c +++ b/net/rxrpc/key.c @@ -896,7 +896,7 @@ static void rxrpc_describe(const struct key *key, struct seq_file *m) /* * grab the security key for a socket */ -int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen) +int rxrpc_request_key(struct rxrpc_sock *rx, sockptr_t optval, int optlen) { struct key *key; char *description; @@ -906,7 +906,7 @@ int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen) if (optlen <= 0 || optlen > PAGE_SIZE - 1) return -EINVAL; - description = memdup_user_nul(optval, optlen); + description = memdup_sockptr_nul(optval, optlen); if (IS_ERR(description)) return PTR_ERR(description); @@ -926,8 +926,7 @@ int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen) /* * grab the security keyring for a server socket */ -int rxrpc_server_keyring(struct rxrpc_sock *rx, char __user *optval, - int optlen) +int rxrpc_server_keyring(struct rxrpc_sock *rx, sockptr_t optval, int optlen) { struct key *key; char *description; @@ -937,7 +936,7 @@ int rxrpc_server_keyring(struct rxrpc_sock *rx, char __user *optval, if (optlen <= 0 || optlen > PAGE_SIZE - 1) return -EINVAL; - description = memdup_user_nul(optval, optlen); + description = memdup_sockptr_nul(optval, optlen); if (IS_ERR(description)) return PTR_ERR(description); diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 9a767f35971865..144808dfea9ee8 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4429,7 +4429,7 @@ static int sctp_setsockopt_pf_expose(struct sock *sk, * optlen - the size of the buffer. */ static int sctp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { void *kopt = NULL; int retval = 0; @@ -4449,7 +4449,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, } if (optlen > 0) { - kopt = memdup_user(optval, optlen); + kopt = memdup_sockptr(optval, optlen); if (IS_ERR(kopt)) return PTR_ERR(kopt); } diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 9711c9e0e515bf..4ac1d4de667691 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1731,7 +1731,7 @@ static int smc_shutdown(struct socket *sock, int how) } static int smc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct smc_sock *smc; @@ -1754,7 +1754,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; lock_sock(sk); diff --git a/net/socket.c b/net/socket.c index c97f83d879ae75..e44b8ac47f6f46 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2094,10 +2094,10 @@ static bool sock_use_custom_sol_socket(const struct socket *sock) * Set a socket option. Because we don't know the option lengths we have * to pass the user mode parameter for the protocols to sort out. */ -int __sys_setsockopt(int fd, int level, int optname, char __user *optval, +int __sys_setsockopt(int fd, int level, int optname, char __user *user_optval, int optlen) { - mm_segment_t oldfs = get_fs(); + sockptr_t optval = USER_SOCKPTR(user_optval); char *kernel_optval = NULL; int err, fput_needed; struct socket *sock; @@ -2115,7 +2115,7 @@ int __sys_setsockopt(int fd, int level, int optname, char __user *optval, if (!in_compat_syscall()) err = BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock->sk, &level, &optname, - optval, &optlen, + user_optval, &optlen, &kernel_optval); if (err < 0) goto out_put; @@ -2124,25 +2124,16 @@ int __sys_setsockopt(int fd, int level, int optname, char __user *optval, goto out_put; } - if (kernel_optval) { - set_fs(KERNEL_DS); - optval = (char __user __force *)kernel_optval; - } - + if (kernel_optval) + optval = KERNEL_SOCKPTR(kernel_optval); if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) - err = sock_setsockopt(sock, level, optname, - USER_SOCKPTR(optval), optlen); + err = sock_setsockopt(sock, level, optname, optval, optlen); else if (unlikely(!sock->ops->setsockopt)) err = -EOPNOTSUPP; else err = sock->ops->setsockopt(sock, level, optname, optval, optlen); - - if (kernel_optval) { - set_fs(oldfs); - kfree(kernel_optval); - } - + kfree(kernel_optval); out_put: fput_light(sock->file, fput_needed); return err; diff --git a/net/tipc/socket.c b/net/tipc/socket.c index fc388cef64715c..07419f36116a84 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -3103,7 +3103,7 @@ static int tipc_sk_leave(struct tipc_sock *tsk) * Returns 0 on success, errno otherwise */ static int tipc_setsockopt(struct socket *sock, int lvl, int opt, - char __user *ov, unsigned int ol) + sockptr_t ov, unsigned int ol) { struct sock *sk = sock->sk; struct tipc_sock *tsk = tipc_sk(sk); @@ -3124,17 +3124,17 @@ static int tipc_setsockopt(struct socket *sock, int lvl, int opt, case TIPC_NODELAY: if (ol < sizeof(value)) return -EINVAL; - if (get_user(value, (u32 __user *)ov)) + if (copy_from_sockptr(&value, ov, sizeof(u32))) return -EFAULT; break; case TIPC_GROUP_JOIN: if (ol < sizeof(mreq)) return -EINVAL; - if (copy_from_user(&mreq, ov, sizeof(mreq))) + if (copy_from_sockptr(&mreq, ov, sizeof(mreq))) return -EFAULT; break; default: - if (ov || ol) + if (!sockptr_is_null(ov) || ol) return -EINVAL; } diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index ec10041c6b7d41..d77f7d821130db 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -450,7 +450,7 @@ static int tls_getsockopt(struct sock *sk, int level, int optname, return do_tls_getsockopt(sk, optname, optval, optlen); } -static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, +static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval, unsigned int optlen, int tx) { struct tls_crypto_info *crypto_info; @@ -460,7 +460,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, int rc = 0; int conf; - if (!optval || (optlen < sizeof(*crypto_info))) { + if (sockptr_is_null(optval) || (optlen < sizeof(*crypto_info))) { rc = -EINVAL; goto out; } @@ -479,7 +479,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, goto out; } - rc = copy_from_user(crypto_info, optval, sizeof(*crypto_info)); + rc = copy_from_sockptr(crypto_info, optval, sizeof(*crypto_info)); if (rc) { rc = -EFAULT; goto err_crypto_info; @@ -522,8 +522,9 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, goto err_crypto_info; } - rc = copy_from_user(crypto_info + 1, optval + sizeof(*crypto_info), - optlen - sizeof(*crypto_info)); + sockptr_advance(optval, sizeof(*crypto_info)); + rc = copy_from_sockptr(crypto_info + 1, optval, + optlen - sizeof(*crypto_info)); if (rc) { rc = -EFAULT; goto err_crypto_info; @@ -579,8 +580,8 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, return rc; } -static int do_tls_setsockopt(struct sock *sk, int optname, - char __user *optval, unsigned int optlen) +static int do_tls_setsockopt(struct sock *sk, int optname, sockptr_t optval, + unsigned int optlen) { int rc = 0; @@ -600,7 +601,7 @@ static int do_tls_setsockopt(struct sock *sk, int optname, } static int tls_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct tls_context *ctx = tls_get_ctx(sk); diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index df204c6761c453..27bbcfad9c1738 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1517,7 +1517,7 @@ static void vsock_update_buffer_size(struct vsock_sock *vsk, static int vsock_stream_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, + sockptr_t optval, unsigned int optlen) { int err; @@ -1535,7 +1535,7 @@ static int vsock_stream_setsockopt(struct socket *sock, err = -EINVAL; \ goto exit; \ } \ - if (copy_from_user(&_v, optval, sizeof(_v)) != 0) { \ + if (copy_from_sockptr(&_v, optval, sizeof(_v)) != 0) { \ err = -EFAULT; \ goto exit; \ } \ diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index d5b09bbff3754f..0bbb283f23c96f 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -431,7 +431,7 @@ void x25_destroy_socket_from_timer(struct sock *sk) */ static int x25_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { int opt; struct sock *sk = sock->sk; @@ -445,7 +445,7 @@ static int x25_setsockopt(struct socket *sock, int level, int optname, goto out; rc = -EFAULT; - if (get_user(opt, (int __user *)optval)) + if (copy_from_sockptr(&opt, optval, sizeof(int))) goto out; if (opt) diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index 26e3bba8c204a7..2e94a7e94671b6 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -702,7 +702,7 @@ struct xdp_umem_reg_v1 { }; static int xsk_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct xdp_sock *xs = xdp_sk(sk); @@ -720,7 +720,7 @@ static int xsk_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(entries)) return -EINVAL; - if (copy_from_user(&entries, optval, sizeof(entries))) + if (copy_from_sockptr(&entries, optval, sizeof(entries))) return -EFAULT; mutex_lock(&xs->mutex); @@ -747,7 +747,7 @@ static int xsk_setsockopt(struct socket *sock, int level, int optname, else if (optlen < sizeof(mr)) mr_size = sizeof(struct xdp_umem_reg_v1); - if (copy_from_user(&mr, optval, mr_size)) + if (copy_from_sockptr(&mr, optval, mr_size)) return -EFAULT; mutex_lock(&xs->mutex); @@ -774,7 +774,7 @@ static int xsk_setsockopt(struct socket *sock, int level, int optname, struct xsk_queue **q; int entries; - if (copy_from_user(&entries, optval, sizeof(entries))) + if (copy_from_sockptr(&entries, optval, sizeof(entries))) return -EFAULT; mutex_lock(&xs->mutex); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cC6qJROTFV+c4QEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:50:27 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id YEX/IxOTFV95qAAAlScrYA (envelope-from ); Mon, 20 Jul 2020 14:50:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C7EB1A242B; Mon, 20 Jul 2020 14:50:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729292AbgGTMtD (ORCPT + 1 other); Mon, 20 Jul 2020 08:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729253AbgGTMs7 (ORCPT ); Mon, 20 Jul 2020 08:48:59 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 909C9C061794; Mon, 20 Jul 2020 05:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=UdgYuJlmWZokLcAOPnfw8PlZRvn7vjQf/6iOObq/cjM=; b=EfUGSmzo7JZGI9afLsF3hj93gp QeNRk2gv3i8Hoju2rKxXXOQ7hvEKK425CCZZyEdBci6lYUq4rQaAHbmte7SNnXyiJS9soDWzLyWBr 1eSEuF32k+WC25/DhWE0nkJ5/IbviztWQd93XhkSL16adqxpGtIjnUIlufFuvsjvqNZsEKE3RYMxy U7ILlkYTn4ZxA/W+g6bDJEQPpZCXLQMYef1VVDAXqofiySh6PmEXMK23jP2R7ufxhsWEcn82qNrxQ o52QjpqV8rtLGFNsCgq1hoSL/yUeCUeFmoBRrf1Z0JsRh0j9nlzvbf0qWgM/Z+dfhUzBQn2UaTUQj nOKADpyQ==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDn-0004em-Tn; Mon, 20 Jul 2020 12:48:44 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 23/24] net/tcp: switch do_tcp_setsockopt to sockptr_t Date: Mon, 20 Jul 2020 14:47:36 +0200 Message-Id: <20200720124737.118617-24-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: C7EB1A242B X-Rspamd-UID: 1665e8 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- net/ipv4/tcp.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 49bf15c27deac7..71cbc61c335f71 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2764,7 +2764,7 @@ static inline bool tcp_can_repair_sock(const struct sock *sk) (sk->sk_state != TCP_LISTEN); } -static int tcp_repair_set_window(struct tcp_sock *tp, char __user *optbuf, int len) +static int tcp_repair_set_window(struct tcp_sock *tp, sockptr_t optbuf, int len) { struct tcp_repair_window opt; @@ -2774,7 +2774,7 @@ static int tcp_repair_set_window(struct tcp_sock *tp, char __user *optbuf, int l if (len != sizeof(opt)) return -EINVAL; - if (copy_from_user(&opt, optbuf, sizeof(opt))) + if (copy_from_sockptr(&opt, optbuf, sizeof(opt))) return -EFAULT; if (opt.max_window < opt.snd_wnd) @@ -2796,17 +2796,17 @@ static int tcp_repair_set_window(struct tcp_sock *tp, char __user *optbuf, int l return 0; } -static int tcp_repair_options_est(struct sock *sk, - struct tcp_repair_opt __user *optbuf, unsigned int len) +static int tcp_repair_options_est(struct sock *sk, sockptr_t optbuf, + unsigned int len) { struct tcp_sock *tp = tcp_sk(sk); struct tcp_repair_opt opt; while (len >= sizeof(opt)) { - if (copy_from_user(&opt, optbuf, sizeof(opt))) + if (copy_from_sockptr(&opt, optbuf, sizeof(opt))) return -EFAULT; - optbuf++; + sockptr_advance(optbuf, sizeof(opt)); len -= sizeof(opt); switch (opt.opt_code) { @@ -3020,8 +3020,8 @@ EXPORT_SYMBOL(tcp_sock_set_keepcnt); /* * Socket option code for TCP. */ -static int do_tcp_setsockopt(struct sock *sk, int level, - int optname, char __user *optval, unsigned int optlen) +static int do_tcp_setsockopt(struct sock *sk, int level, int optname, + sockptr_t optval, unsigned int optlen) { struct tcp_sock *tp = tcp_sk(sk); struct inet_connection_sock *icsk = inet_csk(sk); @@ -3037,7 +3037,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, if (optlen < 1) return -EINVAL; - val = strncpy_from_user(name, optval, + val = strncpy_from_sockptr(name, optval, min_t(long, TCP_CA_NAME_MAX-1, optlen)); if (val < 0) return -EFAULT; @@ -3056,7 +3056,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, if (optlen < 1) return -EINVAL; - val = strncpy_from_user(name, optval, + val = strncpy_from_sockptr(name, optval, min_t(long, TCP_ULP_NAME_MAX - 1, optlen)); if (val < 0) @@ -3079,7 +3079,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, optlen != TCP_FASTOPEN_KEY_BUF_LENGTH) return -EINVAL; - if (copy_from_user(key, optval, optlen)) + if (copy_from_sockptr(key, optval, optlen)) return -EFAULT; if (optlen == TCP_FASTOPEN_KEY_BUF_LENGTH) @@ -3095,7 +3095,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3174,9 +3174,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, if (!tp->repair) err = -EINVAL; else if (sk->sk_state == TCP_ESTABLISHED) - err = tcp_repair_options_est(sk, - (struct tcp_repair_opt __user *)optval, - optlen); + err = tcp_repair_options_est(sk, optval, optlen); else err = -EPERM; break; @@ -3249,8 +3247,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, #ifdef CONFIG_TCP_MD5SIG case TCP_MD5SIG: case TCP_MD5SIG_EXT: - err = tp->af_specific->md5_parse(sk, optname, - USER_SOCKPTR(optval), optlen); + err = tp->af_specific->md5_parse(sk, optname, optval, optlen); break; #endif case TCP_USER_TIMEOUT: @@ -3334,7 +3331,8 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, if (level != SOL_TCP) return icsk->icsk_af_ops->setsockopt(sk, level, optname, optval, optlen); - return do_tcp_setsockopt(sk, level, optname, optval, optlen); + return do_tcp_setsockopt(sk, level, optname, USER_SOCKPTR(optval), + optlen); } EXPORT_SYMBOL(tcp_setsockopt); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CHf2ES2TFV9rrwEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:50:53 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2EyxEC2TFV9bzwAAlp8NpQ (envelope-from ); Mon, 20 Jul 2020 14:50:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BEC05A24FC; Mon, 20 Jul 2020 14:50:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728959AbgGTMta (ORCPT + 1 other); Mon, 20 Jul 2020 08:49:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729236AbgGTMsw (ORCPT ); Mon, 20 Jul 2020 08:48:52 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4740AC061794; Mon, 20 Jul 2020 05:48:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=JqWr7BncnAaw1KsTe15pYPZ3Aib5oHtxDPbe0sMml/w=; b=uWZ6jCpzKP3knqB1HbYIqdAFmE JG/8kt3ysyB2oyx6jw5vOzeoluSO+BWwt8WMZAh30P3716tRc/lq2aNq+FR4nWuq5scmQO2/ZsF9y CVYkp2Iu/+kj9A4Kb4LI3X/qjbklr889G2byiZTkmSQIOWbj30FBvtgbYw5bY+zCbho9KixHprDAM q6OmvoWuRk884tf85LS/cT3lh+ONS4oBVU/5escrUuBJGq32mUZirYyqwG0yKxXqwnLQC1bES8v8p Fr5SZi1XZZOaC5Y2wZ1QlzVqibyGLKDzTbblN474UGSM/VJ3FCsD8yLKMPVyxA0znelhoXpI5VlIZ Fnf4QKzw==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDh-0004dA-FX; Mon, 20 Jul 2020 12:48:38 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 21/24] net/udp: switch udp_lib_setsockopt to sockptr_t Date: Mon, 20 Jul 2020 14:47:34 +0200 Message-Id: <20200720124737.118617-22-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: BEC05A24FC X-Rspamd-UID: 63d98e Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/net/udp.h | 2 +- net/ipv4/udp.c | 7 ++++--- net/ipv6/udp.c | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/net/udp.h b/include/net/udp.h index 17a9e86a807638..295d52a7359827 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -306,7 +306,7 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, int udp_lib_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); int udp_lib_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen, + sockptr_t optval, unsigned int optlen, int (*push_pending_frames)(struct sock *)); struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, __be32 daddr, __be16 dport, int dif); diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index d4be4471c424e3..641303aa17d3dd 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2532,7 +2532,7 @@ void udp_destroy_sock(struct sock *sk) * Socket option code for UDP */ int udp_lib_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen, + sockptr_t optval, unsigned int optlen, int (*push_pending_frames)(struct sock *)) { struct udp_sock *up = udp_sk(sk); @@ -2543,7 +2543,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; valbool = val ? 1 : 0; @@ -2651,7 +2651,8 @@ int udp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { if (level == SOL_UDP || level == SOL_UDPLITE) - return udp_lib_setsockopt(sk, level, optname, optval, optlen, + return udp_lib_setsockopt(sk, level, optname, + USER_SOCKPTR(optval), optlen, udp_push_pending_frames); return ip_setsockopt(sk, level, optname, optval, optlen); } diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 5aff0856a05b44..05353b31fa07bc 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1565,7 +1565,8 @@ int udpv6_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { if (level == SOL_UDP || level == SOL_UDPLITE) - return udp_lib_setsockopt(sk, level, optname, optval, optlen, + return udp_lib_setsockopt(sk, level, optname, + USER_SOCKPTR(optval), optlen, udp_v6_push_pending_frames); return ipv6_setsockopt(sk, level, optname, optval, optlen); } -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CNSRAEOTFV+c4QEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:51:15 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id uPDaOkKTFV8S9wAAgupzMw (envelope-from ); Mon, 20 Jul 2020 14:51:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2E1A3A2609; Mon, 20 Jul 2020 14:51:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729207AbgGTMst (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729195AbgGTMss (ORCPT ); Mon, 20 Jul 2020 08:48:48 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DC15C061794; Mon, 20 Jul 2020 05:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=GQn0sG9CSctd3r9tXWfKFi/perePeGXKxZIJGtFsY+Q=; b=X4uzGeNPKo0XSGnzu8xCZ3ILFx iP7gt8StBF43AdVui2+PI+2wBcc0BcoqL9vxrZK9N086yxeXTTJi78IQHFStqzejrTuE+I+nhvoOT /n+yUed61AqqNbJgATD4DKCx/smgC26qET+TTVoCPrs5AYQeeav5DV7eArEey1VDOtdwQqvmlspBs xzEHXl4tpNjCHuy4HSTnaq1aWriYa9Z+1en44osAOEnhFvn3QIP2g0iRqAr6xArrnxApqpwgk1hce VZIxsGdRbHT6hHUymppaqrolyeIfWBAw7o4OrPUbgreSDeDAF5FBRPm98nX11NZMT6xMw2JqQrJJR P/dOnE8w==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDf-0004ct-DY; Mon, 20 Jul 2020 12:48:36 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 20/24] net/ipv6: switch do_ipv6_setsockopt to sockptr_t Date: Mon, 20 Jul 2020 14:47:33 +0200 Message-Id: <20200720124737.118617-21-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2E1A3A2609 X-Rspamd-UID: 020c21 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- net/ipv6/ipv6_sockglue.c | 66 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 90442c8366dff2..dcd000a5a9b124 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -136,15 +136,15 @@ static bool setsockopt_needs_rtnl(int optname) return false; } -static int copy_group_source_from_user(struct group_source_req *greqs, - void __user *optval, int optlen) +static int copy_group_source_from_sockptr(struct group_source_req *greqs, + sockptr_t optval, int optlen) { if (in_compat_syscall()) { struct compat_group_source_req gr32; if (optlen < sizeof(gr32)) return -EINVAL; - if (copy_from_user(&gr32, optval, sizeof(gr32))) + if (copy_from_sockptr(&gr32, optval, sizeof(gr32))) return -EFAULT; greqs->gsr_interface = gr32.gsr_interface; greqs->gsr_group = gr32.gsr_group; @@ -152,7 +152,7 @@ static int copy_group_source_from_user(struct group_source_req *greqs, } else { if (optlen < sizeof(*greqs)) return -EINVAL; - if (copy_from_user(greqs, optval, sizeof(*greqs))) + if (copy_from_sockptr(greqs, optval, sizeof(*greqs))) return -EFAULT; } @@ -160,13 +160,13 @@ static int copy_group_source_from_user(struct group_source_req *greqs, } static int do_ipv6_mcast_group_source(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct group_source_req greqs; int omode, add; int ret; - ret = copy_group_source_from_user(&greqs, optval, optlen); + ret = copy_group_source_from_sockptr(&greqs, optval, optlen); if (ret) return ret; @@ -200,7 +200,7 @@ static int do_ipv6_mcast_group_source(struct sock *sk, int optname, return ip6_mc_source(add, omode, sk, &greqs); } -static int ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, +static int ipv6_set_mcast_msfilter(struct sock *sk, sockptr_t optval, int optlen) { struct group_filter *gsf; @@ -211,7 +211,7 @@ static int ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, if (optlen > sysctl_optmem_max) return -ENOBUFS; - gsf = memdup_user(optval, optlen); + gsf = memdup_sockptr(optval, optlen); if (IS_ERR(gsf)) return PTR_ERR(gsf); @@ -231,7 +231,7 @@ static int ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, return ret; } -static int compat_ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, +static int compat_ipv6_set_mcast_msfilter(struct sock *sk, sockptr_t optval, int optlen) { const int size0 = offsetof(struct compat_group_filter, gf_slist); @@ -251,7 +251,7 @@ static int compat_ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, gf32 = p + 4; /* we want ->gf_group and ->gf_slist aligned */ ret = -EFAULT; - if (copy_from_user(gf32, optval, optlen)) + if (copy_from_sockptr(gf32, optval, optlen)) goto out_free_p; /* numsrc >= (4G-140)/128 overflow in 32 bits */ @@ -276,14 +276,14 @@ static int compat_ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, } static int ipv6_mcast_join_leave(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct sockaddr_in6 *psin6; struct group_req greq; if (optlen < sizeof(greq)) return -EINVAL; - if (copy_from_user(&greq, optval, sizeof(greq))) + if (copy_from_sockptr(&greq, optval, sizeof(greq))) return -EFAULT; if (greq.gr_group.ss_family != AF_INET6) @@ -296,14 +296,14 @@ static int ipv6_mcast_join_leave(struct sock *sk, int optname, } static int compat_ipv6_mcast_join_leave(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct compat_group_req gr32; struct sockaddr_in6 *psin6; if (optlen < sizeof(gr32)) return -EINVAL; - if (copy_from_user(&gr32, optval, sizeof(gr32))) + if (copy_from_sockptr(&gr32, optval, sizeof(gr32))) return -EFAULT; if (gr32.gr_group.ss_family != AF_INET6) @@ -315,7 +315,7 @@ static int compat_ipv6_mcast_join_leave(struct sock *sk, int optname, return ipv6_sock_mc_drop(sk, gr32.gr_interface, &psin6->sin6_addr); } -static int ipv6_set_opt_hdr(struct sock *sk, int optname, void __user *optval, +static int ipv6_set_opt_hdr(struct sock *sk, int optname, sockptr_t optval, int optlen) { struct ipv6_pinfo *np = inet6_sk(sk); @@ -332,14 +332,14 @@ static int ipv6_set_opt_hdr(struct sock *sk, int optname, void __user *optval, * length, per RFC3542. */ if (optlen > 0) { - if (!optval) + if (sockptr_is_null(optval)) return -EINVAL; if (optlen < sizeof(struct ipv6_opt_hdr) || optlen & 0x7 || optlen > 8 * 255) return -EINVAL; - new = memdup_user(optval, optlen); + new = memdup_sockptr(optval, optlen); if (IS_ERR(new)) return PTR_ERR(new); if (unlikely(ipv6_optlen(new) > optlen)) { @@ -390,7 +390,7 @@ static int ipv6_set_opt_hdr(struct sock *sk, int optname, void __user *optval, } static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct ipv6_pinfo *np = inet6_sk(sk); struct net *net = sock_net(sk); @@ -398,11 +398,11 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, int retv = -ENOPROTOOPT; bool needs_rtnl = setsockopt_needs_rtnl(optname); - if (!optval) + if (sockptr_is_null(optval)) val = 0; else { if (optlen >= sizeof(int)) { - if (get_user(val, (int __user *) optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; } else val = 0; @@ -411,8 +411,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, valbool = (val != 0); if (ip6_mroute_opt(optname)) - return ip6_mroute_setsockopt(sk, optname, USER_SOCKPTR(optval), - optlen); + return ip6_mroute_setsockopt(sk, optname, optval, optlen); if (needs_rtnl) rtnl_lock(); @@ -663,12 +662,13 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, if (optlen == 0) goto e_inval; - else if (optlen < sizeof(struct in6_pktinfo) || !optval) + else if (optlen < sizeof(struct in6_pktinfo) || + sockptr_is_null(optval)) goto e_inval; - if (copy_from_user(&pkt, optval, sizeof(struct in6_pktinfo))) { - retv = -EFAULT; - break; + if (copy_from_sockptr(&pkt, optval, sizeof(pkt))) { + retv = -EFAULT; + break; } if (!sk_dev_equal_l3scope(sk, pkt.ipi6_ifindex)) goto e_inval; @@ -709,7 +709,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, refcount_set(&opt->refcnt, 1); opt->tot_len = sizeof(*opt) + optlen; retv = -EFAULT; - if (copy_from_user(opt+1, optval, optlen)) + if (copy_from_sockptr(opt + 1, optval, optlen)) goto done; msg.msg_controllen = optlen; @@ -831,7 +831,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, break; retv = -EFAULT; - if (copy_from_user(&mreq, optval, sizeof(struct ipv6_mreq))) + if (copy_from_sockptr(&mreq, optval, sizeof(struct ipv6_mreq))) break; if (optname == IPV6_ADD_MEMBERSHIP) @@ -849,7 +849,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, goto e_inval; retv = -EFAULT; - if (copy_from_user(&mreq, optval, sizeof(struct ipv6_mreq))) + if (copy_from_sockptr(&mreq, optval, sizeof(struct ipv6_mreq))) break; if (optname == IPV6_JOIN_ANYCAST) @@ -929,15 +929,14 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, retv = 0; break; case IPV6_FLOWLABEL_MGR: - retv = ipv6_flowlabel_opt(sk, USER_SOCKPTR(optval), optlen); + retv = ipv6_flowlabel_opt(sk, optval, optlen); break; case IPV6_IPSEC_POLICY: case IPV6_XFRM_POLICY: retv = -EPERM; if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) break; - retv = xfrm_user_policy(sk, optname, USER_SOCKPTR(optval), - optlen); + retv = xfrm_user_policy(sk, optname, optval, optlen); break; case IPV6_ADDR_PREFERENCES: @@ -992,7 +991,8 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, if (level != SOL_IPV6) return -ENOPROTOOPT; - err = do_ipv6_setsockopt(sk, level, optname, optval, optlen); + err = do_ipv6_setsockopt(sk, level, optname, USER_SOCKPTR(optval), + optlen); #ifdef CONFIG_NETFILTER /* we need to exclude all possible ENOPROTOOPTs except default case */ if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY && -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IGpTIlCTFV9rrwEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:51:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ACwDIVCTFV8MzQAADc0bRg (envelope-from ); Mon, 20 Jul 2020 14:51:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F3349A242B; Mon, 20 Jul 2020 14:51:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729380AbgGTMty (ORCPT + 1 other); Mon, 20 Jul 2020 08:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729162AbgGTMso (ORCPT ); Mon, 20 Jul 2020 08:48:44 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 529D9C0619D2; Mon, 20 Jul 2020 05:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=QlF9uAsII4M+JCuvUaS+q9mzPBlfDSxuvtjJe160dNk=; b=LJuEzTHbCizIReQ+vQ6tM/yCQW kGzqCUOZ35A+PNtrII7WOhLPz+10DxnasJInH0Sm2USAoyzaAXewdZ2FJxvHWuhOw4PziPZL3AbUB cKMt8/u3Tlt6vvsQmEkiEHXxqrlK8jfGWfzlKyuHo2w6+jKrW8isTlY+qWPNc5BHGsJc2SZQz8izG yiCcsbRejjr36L5X45bHYd2QBWULO3Uo/pXme/kHQ4/eLGLQ6Oyj1SiJhvk4qAjgHhjiDprBJ0PEI SLq9SY7N1kdGtT2W6kUbfNpXS3supYKhgOR/bM1x53RY/QVHM+LFmeoeoULO3luDSJ8/COEwEstXU 1aYg1YaQ==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDa-0004cL-SR; Mon, 20 Jul 2020 12:48:31 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 18/24] net/ipv6: switch ipv6_flowlabel_opt to sockptr_t Date: Mon, 20 Jul 2020 14:47:31 +0200 Message-Id: <20200720124737.118617-19-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: F3349A242B X-Rspamd-UID: f6a920 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Note that the get case is pretty weird in that it actually copies data back to userspace from setsockopt. Signed-off-by: Christoph Hellwig --- include/net/ipv6.h | 2 +- net/ipv6/ip6_flowlabel.c | 16 +++++++++------- net/ipv6/ipv6_sockglue.c | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 262fc88dbd7e2f..4c9d89b5d73268 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -406,7 +406,7 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space, struct ip6_flowlabel *fl, struct ipv6_txoptions *fopt); void fl6_free_socklist(struct sock *sk); -int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen); +int ipv6_flowlabel_opt(struct sock *sk, sockptr_t optval, int optlen); int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq, int flags); int ip6_flowlabel_init(void); diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index 27ee6de9beffc4..6b3c315f3d461a 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c @@ -371,7 +371,7 @@ static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned lo static struct ip6_flowlabel * fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, - char __user *optval, int optlen, int *err_p) + sockptr_t optval, int optlen, int *err_p) { struct ip6_flowlabel *fl = NULL; int olen; @@ -401,7 +401,8 @@ fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, memset(fl->opt, 0, sizeof(*fl->opt)); fl->opt->tot_len = sizeof(*fl->opt) + olen; err = -EFAULT; - if (copy_from_user(fl->opt+1, optval+CMSG_ALIGN(sizeof(*freq)), olen)) + sockptr_advance(optval, CMSG_ALIGN(sizeof(*freq))); + if (copy_from_sockptr(fl->opt + 1, optval, olen)) goto done; msg.msg_controllen = olen; @@ -604,7 +605,7 @@ static int ipv6_flowlabel_renew(struct sock *sk, struct in6_flowlabel_req *freq) } static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct ipv6_fl_socklist *sfl, *sfl1 = NULL; struct ip6_flowlabel *fl, *fl1 = NULL; @@ -702,8 +703,9 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, goto recheck; if (!freq->flr_label) { - if (copy_to_user(&((struct in6_flowlabel_req __user *) optval)->flr_label, - &fl->label, sizeof(fl->label))) { + sockptr_advance(optval, + offsetof(struct in6_flowlabel_req, flr_label)); + if (copy_to_sockptr(optval, &fl->label, sizeof(fl->label))) { /* Intentionally ignore fault. */ } } @@ -716,13 +718,13 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, return err; } -int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen) +int ipv6_flowlabel_opt(struct sock *sk, sockptr_t optval, int optlen) { struct in6_flowlabel_req freq; if (optlen < sizeof(freq)) return -EINVAL; - if (copy_from_user(&freq, optval, sizeof(freq))) + if (copy_from_sockptr(&freq, optval, sizeof(freq))) return -EFAULT; switch (freq.flr_action) { diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 119dfaf5f4bb26..3897fb55372d38 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -929,7 +929,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, retv = 0; break; case IPV6_FLOWLABEL_MGR: - retv = ipv6_flowlabel_opt(sk, optval, optlen); + retv = ipv6_flowlabel_opt(sk, USER_SOCKPTR(optval), optlen); break; case IPV6_IPSEC_POLICY: case IPV6_XFRM_POLICY: -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uCUBDUeTFV+c4QEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:51:19 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mHRbC0eTFV/j2gAADc0bRg (envelope-from ); Mon, 20 Jul 2020 14:51:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1E668A010E; Mon, 20 Jul 2020 14:51:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729196AbgGTMss (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729189AbgGTMsq (ORCPT ); Mon, 20 Jul 2020 08:48:46 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72F94C061794; Mon, 20 Jul 2020 05:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=mHiWtESnfpmKOGnGR9J/VvKy447qDpvbyAZDADMp9hY=; b=PEIxnuYKVsyL4VbGipt5/qeMxh hdLo1McwTpyeTRwLfRW8ZgnD8c7KxJu0KZ/qM4WKOnDjX1k53poojoKl8WDY9mRYwM12pb/UJH4Ua CjyNfvuUsmPtIdMkbXPySDCjC9omPKaUZTa4ecBGlbbyDsIipip7l9Xd+wV4Z2UN9foVgIgX+4hsa KANIuyKJjP0qKJA+oPLGsnhL2kIOPH9R7JhwnddXENJ3aLzrcjP+UlS8SO64LU6yvSOrerU+9833A Vh5Nitqyj536Ahxvaz9eEXy0pVwRw0YrrEuyg//N9bEQT+EfyRUcSOFTCy0UWfNW7ClrBPHCvB1de bSeAcmkA==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDd-0004cd-10; Mon, 20 Jul 2020 12:48:33 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 19/24] net/ipv6: factor out a ipv6_set_opt_hdr helper Date: Mon, 20 Jul 2020 14:47:32 +0200 Message-Id: <20200720124737.118617-20-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1E668A010E X-Rspamd-UID: 509249 Factour out a helper to set the IPv6 option headers from do_ipv6_setsockopt. Signed-off-by: Christoph Hellwig --- net/ipv6/ipv6_sockglue.c | 150 +++++++++++++++++++-------------------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 3897fb55372d38..90442c8366dff2 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -315,6 +315,80 @@ static int compat_ipv6_mcast_join_leave(struct sock *sk, int optname, return ipv6_sock_mc_drop(sk, gr32.gr_interface, &psin6->sin6_addr); } +static int ipv6_set_opt_hdr(struct sock *sk, int optname, void __user *optval, + int optlen) +{ + struct ipv6_pinfo *np = inet6_sk(sk); + struct ipv6_opt_hdr *new = NULL; + struct net *net = sock_net(sk); + struct ipv6_txoptions *opt; + int err; + + /* hop-by-hop / destination options are privileged option */ + if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW)) + return -EPERM; + + /* remove any sticky options header with a zero option + * length, per RFC3542. + */ + if (optlen > 0) { + if (!optval) + return -EINVAL; + if (optlen < sizeof(struct ipv6_opt_hdr) || + optlen & 0x7 || + optlen > 8 * 255) + return -EINVAL; + + new = memdup_user(optval, optlen); + if (IS_ERR(new)) + return PTR_ERR(new); + if (unlikely(ipv6_optlen(new) > optlen)) { + kfree(new); + return -EINVAL; + } + } + + opt = rcu_dereference_protected(np->opt, lockdep_sock_is_held(sk)); + opt = ipv6_renew_options(sk, opt, optname, new); + kfree(new); + if (IS_ERR(opt)) + return PTR_ERR(opt); + + /* routing header option needs extra check */ + err = -EINVAL; + if (optname == IPV6_RTHDR && opt && opt->srcrt) { + struct ipv6_rt_hdr *rthdr = opt->srcrt; + switch (rthdr->type) { +#if IS_ENABLED(CONFIG_IPV6_MIP6) + case IPV6_SRCRT_TYPE_2: + if (rthdr->hdrlen != 2 || rthdr->segments_left != 1) + goto sticky_done; + break; +#endif + case IPV6_SRCRT_TYPE_4: + { + struct ipv6_sr_hdr *srh = + (struct ipv6_sr_hdr *)opt->srcrt; + + if (!seg6_validate_srh(srh, optlen, false)) + goto sticky_done; + break; + } + default: + goto sticky_done; + } + } + + err = 0; + opt = ipv6_update_options(sk, opt); +sticky_done: + if (opt) { + atomic_sub(opt->tot_len, &sk->sk_omem_alloc); + txopt_put(opt); + } + return err; +} + static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { @@ -580,82 +654,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, case IPV6_RTHDRDSTOPTS: case IPV6_RTHDR: case IPV6_DSTOPTS: - { - struct ipv6_txoptions *opt; - struct ipv6_opt_hdr *new = NULL; - - /* hop-by-hop / destination options are privileged option */ - retv = -EPERM; - if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW)) - break; - - /* remove any sticky options header with a zero option - * length, per RFC3542. - */ - if (optlen == 0) - optval = NULL; - else if (!optval) - goto e_inval; - else if (optlen < sizeof(struct ipv6_opt_hdr) || - optlen & 0x7 || optlen > 8 * 255) - goto e_inval; - else { - new = memdup_user(optval, optlen); - if (IS_ERR(new)) { - retv = PTR_ERR(new); - break; - } - if (unlikely(ipv6_optlen(new) > optlen)) { - kfree(new); - goto e_inval; - } - } - - opt = rcu_dereference_protected(np->opt, - lockdep_sock_is_held(sk)); - opt = ipv6_renew_options(sk, opt, optname, new); - kfree(new); - if (IS_ERR(opt)) { - retv = PTR_ERR(opt); - break; - } - - /* routing header option needs extra check */ - retv = -EINVAL; - if (optname == IPV6_RTHDR && opt && opt->srcrt) { - struct ipv6_rt_hdr *rthdr = opt->srcrt; - switch (rthdr->type) { -#if IS_ENABLED(CONFIG_IPV6_MIP6) - case IPV6_SRCRT_TYPE_2: - if (rthdr->hdrlen != 2 || - rthdr->segments_left != 1) - goto sticky_done; - - break; -#endif - case IPV6_SRCRT_TYPE_4: - { - struct ipv6_sr_hdr *srh = (struct ipv6_sr_hdr *) - opt->srcrt; - - if (!seg6_validate_srh(srh, optlen, false)) - goto sticky_done; - break; - } - default: - goto sticky_done; - } - } - - retv = 0; - opt = ipv6_update_options(sk, opt); -sticky_done: - if (opt) { - atomic_sub(opt->tot_len, &sk->sk_omem_alloc); - txopt_put(opt); - } + retv = ipv6_set_opt_hdr(sk, optname, optval, optlen); break; - } case IPV6_PKTINFO: { -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kHLdAXmTFV+c4QEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:52:09 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gCFtAHmTFV9c5AAAlp8NpQ (envelope-from ); Mon, 20 Jul 2020 14:52:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 462F1A1E62; Mon, 20 Jul 2020 14:52:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729414AbgGTMuM (ORCPT + 1 other); Mon, 20 Jul 2020 08:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729107AbgGTMsg (ORCPT ); Mon, 20 Jul 2020 08:48:36 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5054C061794; Mon, 20 Jul 2020 05:48:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=7JpGBoLpaFE7Jf5UF2pDwmquZJ8aXq1cjTXF4rce5nE=; b=hAMc08cozMAgVleWk1wHKD65fu ptY3ODDkMeGCI4wRiloAet4W3rGFVobPmNnfeM2CYGjvYry//YsnknbaBjHfO01JGItPZj12eehh7 CfGurwNP56ZGrn4X7fIWv0ADG/wMEMM3QZnb6PrlPKOU+l0wQcMLEHuXgaz/uRMlYki5MfbUtzqm/ 4MlBe9Cb8lKAiR7c+sPTy8SVEbHVUPdMYTC12An1m0w3q6SejOfdpW/gwp+bxIcWG6z2+8Vicn1i3 QrkhVu5Xh4yX7HCC25Ig7sLUjrvdKpvL7vNwbTMeT04/36AFPZPCYyUcb9rSX4wY3Nko/pdb7u/qW FcNEhNQw==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDO-0004a6-Pf; Mon, 20 Jul 2020 12:48:20 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 15/24] net/ipv4: switch do_ip_setsockopt to sockptr_t Date: Mon, 20 Jul 2020 14:47:28 +0200 Message-Id: <20200720124737.118617-16-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 462F1A1E62 X-Rspamd-UID: efae5f Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- net/ipv4/ip_sockglue.c | 68 ++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index b12f39b52008a3..f7f1507b89fe24 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -683,15 +683,15 @@ static int set_mcast_msfilter(struct sock *sk, int ifindex, return -EADDRNOTAVAIL; } -static int copy_group_source_from_user(struct group_source_req *greqs, - void __user *optval, int optlen) +static int copy_group_source_from_sockptr(struct group_source_req *greqs, + sockptr_t optval, int optlen) { if (in_compat_syscall()) { struct compat_group_source_req gr32; if (optlen != sizeof(gr32)) return -EINVAL; - if (copy_from_user(&gr32, optval, sizeof(gr32))) + if (copy_from_sockptr(&gr32, optval, sizeof(gr32))) return -EFAULT; greqs->gsr_interface = gr32.gsr_interface; greqs->gsr_group = gr32.gsr_group; @@ -699,7 +699,7 @@ static int copy_group_source_from_user(struct group_source_req *greqs, } else { if (optlen != sizeof(*greqs)) return -EINVAL; - if (copy_from_user(greqs, optval, sizeof(*greqs))) + if (copy_from_sockptr(greqs, optval, sizeof(*greqs))) return -EFAULT; } @@ -707,14 +707,14 @@ static int copy_group_source_from_user(struct group_source_req *greqs, } static int do_mcast_group_source(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct group_source_req greqs; struct ip_mreq_source mreqs; struct sockaddr_in *psin; int omode, add, err; - err = copy_group_source_from_user(&greqs, optval, optlen); + err = copy_group_source_from_sockptr(&greqs, optval, optlen); if (err) return err; @@ -754,8 +754,7 @@ static int do_mcast_group_source(struct sock *sk, int optname, return ip_mc_source(add, omode, sk, &mreqs, greqs.gsr_interface); } -static int ip_set_mcast_msfilter(struct sock *sk, void __user *optval, - int optlen) +static int ip_set_mcast_msfilter(struct sock *sk, sockptr_t optval, int optlen) { struct group_filter *gsf = NULL; int err; @@ -765,7 +764,7 @@ static int ip_set_mcast_msfilter(struct sock *sk, void __user *optval, if (optlen > sysctl_optmem_max) return -ENOBUFS; - gsf = memdup_user(optval, optlen); + gsf = memdup_sockptr(optval, optlen); if (IS_ERR(gsf)) return PTR_ERR(gsf); @@ -786,7 +785,7 @@ static int ip_set_mcast_msfilter(struct sock *sk, void __user *optval, return err; } -static int compat_ip_set_mcast_msfilter(struct sock *sk, void __user *optval, +static int compat_ip_set_mcast_msfilter(struct sock *sk, sockptr_t optval, int optlen) { const int size0 = offsetof(struct compat_group_filter, gf_slist); @@ -806,7 +805,7 @@ static int compat_ip_set_mcast_msfilter(struct sock *sk, void __user *optval, gf32 = p + 4; /* we want ->gf_group and ->gf_slist aligned */ err = -EFAULT; - if (copy_from_user(gf32, optval, optlen)) + if (copy_from_sockptr(gf32, optval, optlen)) goto out_free_gsf; /* numsrc >= (4G-140)/128 overflow in 32 bits */ @@ -831,7 +830,7 @@ static int compat_ip_set_mcast_msfilter(struct sock *sk, void __user *optval, } static int ip_mcast_join_leave(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct ip_mreqn mreq = { }; struct sockaddr_in *psin; @@ -839,7 +838,7 @@ static int ip_mcast_join_leave(struct sock *sk, int optname, if (optlen < sizeof(struct group_req)) return -EINVAL; - if (copy_from_user(&greq, optval, sizeof(greq))) + if (copy_from_sockptr(&greq, optval, sizeof(greq))) return -EFAULT; psin = (struct sockaddr_in *)&greq.gr_group; @@ -853,7 +852,7 @@ static int ip_mcast_join_leave(struct sock *sk, int optname, } static int compat_ip_mcast_join_leave(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct compat_group_req greq; struct ip_mreqn mreq = { }; @@ -861,7 +860,7 @@ static int compat_ip_mcast_join_leave(struct sock *sk, int optname, if (optlen < sizeof(struct compat_group_req)) return -EINVAL; - if (copy_from_user(&greq, optval, sizeof(greq))) + if (copy_from_sockptr(&greq, optval, sizeof(greq))) return -EFAULT; psin = (struct sockaddr_in *)&greq.gr_group; @@ -875,8 +874,8 @@ static int compat_ip_mcast_join_leave(struct sock *sk, int optname, return ip_mc_leave_group(sk, &mreq); } -static int do_ip_setsockopt(struct sock *sk, int level, - int optname, char __user *optval, unsigned int optlen) +static int do_ip_setsockopt(struct sock *sk, int level, int optname, + sockptr_t optval, unsigned int optlen) { struct inet_sock *inet = inet_sk(sk); struct net *net = sock_net(sk); @@ -910,12 +909,12 @@ static int do_ip_setsockopt(struct sock *sk, int level, case IP_RECVFRAGSIZE: case IP_RECVERR_RFC4884: if (optlen >= sizeof(int)) { - if (get_user(val, (int __user *) optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; } else if (optlen >= sizeof(char)) { unsigned char ucval; - if (get_user(ucval, (unsigned char __user *) optval)) + if (copy_from_sockptr(&ucval, optval, sizeof(ucval))) return -EFAULT; val = (int) ucval; } @@ -926,8 +925,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, if (optname == IP_ROUTER_ALERT) return ip_ra_control(sk, val ? 1 : 0, NULL); if (ip_mroute_opt(optname)) - return ip_mroute_setsockopt(sk, optname, USER_SOCKPTR(optval), - optlen); + return ip_mroute_setsockopt(sk, optname, optval, optlen); err = 0; if (needs_rtnl) @@ -941,8 +939,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, if (optlen > 40) goto e_inval; - err = ip_options_get(sock_net(sk), &opt, USER_SOCKPTR(optval), - optlen); + err = ip_options_get(sock_net(sk), &opt, optval, optlen); if (err) break; old = rcu_dereference_protected(inet->inet_opt, @@ -1140,17 +1137,17 @@ static int do_ip_setsockopt(struct sock *sk, int level, err = -EFAULT; if (optlen >= sizeof(struct ip_mreqn)) { - if (copy_from_user(&mreq, optval, sizeof(mreq))) + if (copy_from_sockptr(&mreq, optval, sizeof(mreq))) break; } else { memset(&mreq, 0, sizeof(mreq)); if (optlen >= sizeof(struct ip_mreq)) { - if (copy_from_user(&mreq, optval, - sizeof(struct ip_mreq))) + if (copy_from_sockptr(&mreq, optval, + sizeof(struct ip_mreq))) break; } else if (optlen >= sizeof(struct in_addr)) { - if (copy_from_user(&mreq.imr_address, optval, - sizeof(struct in_addr))) + if (copy_from_sockptr(&mreq.imr_address, optval, + sizeof(struct in_addr))) break; } } @@ -1202,11 +1199,12 @@ static int do_ip_setsockopt(struct sock *sk, int level, goto e_inval; err = -EFAULT; if (optlen >= sizeof(struct ip_mreqn)) { - if (copy_from_user(&mreq, optval, sizeof(mreq))) + if (copy_from_sockptr(&mreq, optval, sizeof(mreq))) break; } else { memset(&mreq, 0, sizeof(mreq)); - if (copy_from_user(&mreq, optval, sizeof(struct ip_mreq))) + if (copy_from_sockptr(&mreq, optval, + sizeof(struct ip_mreq))) break; } @@ -1226,7 +1224,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, err = -ENOBUFS; break; } - msf = memdup_user(optval, optlen); + msf = memdup_sockptr(optval, optlen); if (IS_ERR(msf)) { err = PTR_ERR(msf); break; @@ -1257,7 +1255,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, if (optlen != sizeof(struct ip_mreq_source)) goto e_inval; - if (copy_from_user(&mreqs, optval, sizeof(mreqs))) { + if (copy_from_sockptr(&mreqs, optval, sizeof(mreqs))) { err = -EFAULT; break; } @@ -1324,8 +1322,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, err = -EPERM; if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) break; - err = xfrm_user_policy(sk, optname, USER_SOCKPTR(optval), - optlen); + err = xfrm_user_policy(sk, optname, optval, optlen); break; case IP_TRANSPARENT: @@ -1412,7 +1409,8 @@ int ip_setsockopt(struct sock *sk, int level, if (level != SOL_IP) return -ENOPROTOOPT; - err = do_ip_setsockopt(sk, level, optname, optval, optlen); + err = do_ip_setsockopt(sk, level, optname, USER_SOCKPTR(optval), + optlen); #if IS_ENABLED(CONFIG_BPFILTER_UMH) if (optname >= BPFILTER_IPT_SO_SET_REPLACE && optname < BPFILTER_IPT_SET_MAX) -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0EdwMXyTFV9rrwEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:52:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id uEt2MHyTFV/XeQAA0J78UA (envelope-from ); Mon, 20 Jul 2020 14:52:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 33E34A2609; Mon, 20 Jul 2020 14:52:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729082AbgGTMse (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729032AbgGTMsb (ORCPT ); Mon, 20 Jul 2020 08:48:31 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CB2BC061794; Mon, 20 Jul 2020 05:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=AgSxP7iVdXVEFS4IDrHx6ue4s0yWgQSmSEoUvewskkk=; b=RnnEltcg+Ve0KXQ0POUmdkEhpX m1Bl97bPCoO6r8RFt3Qske527Eq14kMVg1fs39zlPOUd4EYJigbO4Grlx3xLvXvF/prk8LOYGc74j 84J6ZYEYeCJ6WnSwdoqcDax+ytfD8QfFPptmk3pPk2rgk63lkp3rVsJd/oLkg8eVQ8LAWdk6WadIU TxEKdrHInirGIMTBUfhY+V3RnTL3IgLtMkANfP2k2NKs8zOygnqI+NbkmgzymdFFSSBwv1aoemFbk KnC1dodsQVRGQmoqbDS0Kim0fWLF5oTQJG5uoeTUk9C0GAa1c9wqcFgAdQdaU3pMfzuzdi4NCqnIt WVPrsBWA==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDM-0004Zn-DD; Mon, 20 Jul 2020 12:48:17 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 14/24] net/ipv4: merge ip_options_get and ip_options_get_from_user Date: Mon, 20 Jul 2020 14:47:27 +0200 Message-Id: <20200720124737.118617-15-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 33E34A2609 X-Rspamd-UID: 8dc61d Use the sockptr_t type to merge the versions. Signed-off-by: Christoph Hellwig --- include/net/ip.h | 5 ++--- net/ipv4/ip_options.c | 43 +++++++++++------------------------------- net/ipv4/ip_sockglue.c | 7 ++++--- 3 files changed, 17 insertions(+), 38 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index 3d34acc95ca825..d66ad3a9522081 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -707,9 +708,7 @@ int __ip_options_compile(struct net *net, struct ip_options *opt, int ip_options_compile(struct net *net, struct ip_options *opt, struct sk_buff *skb); int ip_options_get(struct net *net, struct ip_options_rcu **optp, - unsigned char *data, int optlen); -int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp, - unsigned char __user *data, int optlen); + sockptr_t data, int optlen); void ip_options_undo(struct ip_options *opt); void ip_forward_options(struct sk_buff *skb); int ip_options_rcv_srr(struct sk_buff *skb, struct net_device *dev); diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index ddaa01ec2bce82..948747aac4e2d0 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -519,15 +519,20 @@ void ip_options_undo(struct ip_options *opt) } } -static struct ip_options_rcu *ip_options_get_alloc(const int optlen) +int ip_options_get(struct net *net, struct ip_options_rcu **optp, + sockptr_t data, int optlen) { - return kzalloc(sizeof(struct ip_options_rcu) + ((optlen + 3) & ~3), + struct ip_options_rcu *opt; + + opt = kzalloc(sizeof(struct ip_options_rcu) + ((optlen + 3) & ~3), GFP_KERNEL); -} + if (!opt) + return -ENOMEM; + if (optlen && copy_from_sockptr(opt->opt.__data, data, optlen)) { + kfree(opt); + return -EFAULT; + } -static int ip_options_get_finish(struct net *net, struct ip_options_rcu **optp, - struct ip_options_rcu *opt, int optlen) -{ while (optlen & 3) opt->opt.__data[optlen++] = IPOPT_END; opt->opt.optlen = optlen; @@ -540,32 +545,6 @@ static int ip_options_get_finish(struct net *net, struct ip_options_rcu **optp, return 0; } -int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp, - unsigned char __user *data, int optlen) -{ - struct ip_options_rcu *opt = ip_options_get_alloc(optlen); - - if (!opt) - return -ENOMEM; - if (optlen && copy_from_user(opt->opt.__data, data, optlen)) { - kfree(opt); - return -EFAULT; - } - return ip_options_get_finish(net, optp, opt, optlen); -} - -int ip_options_get(struct net *net, struct ip_options_rcu **optp, - unsigned char *data, int optlen) -{ - struct ip_options_rcu *opt = ip_options_get_alloc(optlen); - - if (!opt) - return -ENOMEM; - if (optlen) - memcpy(opt->opt.__data, data, optlen); - return ip_options_get_finish(net, optp, opt, optlen); -} - void ip_forward_options(struct sk_buff *skb) { struct ip_options *opt = &(IPCB(skb)->opt); diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index ac495b0cff8ffb..b12f39b52008a3 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -280,7 +280,8 @@ int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc, err = cmsg->cmsg_len - sizeof(struct cmsghdr); /* Our caller is responsible for freeing ipc->opt */ - err = ip_options_get(net, &ipc->opt, CMSG_DATA(cmsg), + err = ip_options_get(net, &ipc->opt, + KERNEL_SOCKPTR(CMSG_DATA(cmsg)), err < 40 ? err : 40); if (err) return err; @@ -940,8 +941,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, if (optlen > 40) goto e_inval; - err = ip_options_get_from_user(sock_net(sk), &opt, - optval, optlen); + err = ip_options_get(sock_net(sk), &opt, USER_SOCKPTR(optval), + optlen); if (err) break; old = rcu_dereference_protected(inet->inet_opt, -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8H5nBpCTFV+c4QEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:52:32 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id OIoBBZCTFV927gAAlp8NpQ (envelope-from ); Mon, 20 Jul 2020 14:52:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7CA74A207B; Mon, 20 Jul 2020 14:52:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729030AbgGTMsb (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728985AbgGTMs2 (ORCPT ); Mon, 20 Jul 2020 08:48:28 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 784B4C061794; Mon, 20 Jul 2020 05:48:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=3imfOAwuDTlb5YTszhgUXl+QpResNZl5INQAts7FDyw=; b=Ut0l44CFA54d4E1NP9YTRY3nZH rB1WsrhZdhD676gx5CTQxXzgJza4+zNMlCTFiZtYiZguvuZJeKCQH6hHSnMDfv9t3QhoJdHJizsON IfnubErBJ4rbUnZpM95nKJMr1slACF21eLDALHC5911LsdnVJEuMfyFNGDFPvYOvtGbJ71c4R/JJt xFnqPSeJyepxaPCzhDOGd8zc2RxMo5rRBW9qnSkipnrKMlngeTvvEr1QfpatbiGmfuVQzYx0JBT7J qCiLjQ2nguzdobsGUxVco81qotZbGQ87K7anNuwMSSbgU8r3Ek2sIKVFhad4HuGFQ5Xst2Txu6LUg EBZ5oaWg==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDK-0004ZO-F9; Mon, 20 Jul 2020 12:48:15 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 13/24] net/ipv4: switch ip_mroute_setsockopt to sockptr_t Date: Mon, 20 Jul 2020 14:47:26 +0200 Message-Id: <20200720124737.118617-14-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7CA74A207B X-Rspamd-UID: 967ca2 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/linux/mroute.h | 5 +++-- net/ipv4/ip_sockglue.c | 3 ++- net/ipv4/ipmr.c | 14 +++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/linux/mroute.h b/include/linux/mroute.h index 9a36fad9e068f6..6cbbfe94348cee 100644 --- a/include/linux/mroute.h +++ b/include/linux/mroute.h @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef CONFIG_IP_MROUTE static inline int ip_mroute_opt(int opt) @@ -15,7 +16,7 @@ static inline int ip_mroute_opt(int opt) return opt >= MRT_BASE && opt <= MRT_MAX; } -int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); +int ip_mroute_setsockopt(struct sock *, int, sockptr_t, unsigned int); int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); @@ -23,7 +24,7 @@ int ip_mr_init(void); bool ipmr_rule_default(const struct fib_rule *rule); #else static inline int ip_mroute_setsockopt(struct sock *sock, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { return -ENOPROTOOPT; } diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 36f746e01741f6..ac495b0cff8ffb 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -925,7 +925,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, if (optname == IP_ROUTER_ALERT) return ip_ra_control(sk, val ? 1 : 0, NULL); if (ip_mroute_opt(optname)) - return ip_mroute_setsockopt(sk, optname, optval, optlen); + return ip_mroute_setsockopt(sk, optname, USER_SOCKPTR(optval), + optlen); err = 0; if (needs_rtnl) diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 678639c01e4882..cdf3a40f9ff5fc 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -1341,7 +1341,7 @@ static void mrtsock_destruct(struct sock *sk) * MOSPF/PIM router set up we can clean this up. */ -int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, +int ip_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen) { struct net *net = sock_net(sk); @@ -1413,7 +1413,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (copy_from_user(&vif, optval, sizeof(vif))) { + if (copy_from_sockptr(&vif, optval, sizeof(vif))) { ret = -EFAULT; break; } @@ -1441,7 +1441,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (copy_from_user(&mfc, optval, sizeof(mfc))) { + if (copy_from_sockptr(&val, optval, sizeof(val))) { ret = -EFAULT; break; } @@ -1459,7 +1459,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (get_user(val, (int __user *)optval)) { + if (copy_from_sockptr(&val, optval, sizeof(val))) { ret = -EFAULT; break; } @@ -1471,7 +1471,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (get_user(val, (int __user *)optval)) { + if (copy_from_sockptr(&val, optval, sizeof(val))) { ret = -EFAULT; break; } @@ -1486,7 +1486,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (get_user(val, (int __user *)optval)) { + if (copy_from_sockptr(&val, optval, sizeof(val))) { ret = -EFAULT; break; } @@ -1508,7 +1508,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (get_user(uval, (u32 __user *)optval)) { + if (copy_from_sockptr(&uval, optval, sizeof(uval))) { ret = -EFAULT; break; } -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kCZIFZ6TFV/s0AEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:52:46 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id EH64E56TFV8XlAAA0J78UA (envelope-from ); Mon, 20 Jul 2020 14:52:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 95826A21F5; Mon, 20 Jul 2020 14:52:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729015AbgGTMsa (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728971AbgGTMs1 (ORCPT ); Mon, 20 Jul 2020 08:48:27 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3B34C061794; Mon, 20 Jul 2020 05:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=+GvvL8q4oszQFmBGqA8ndhgAauPjYMp2YX20se2Rz14=; b=W/SFxvtjkpSbdCe3dGLDpwJysW Kf4mT9bppvn0bssZdcjZ5n0WRzHADU80XMa/3Y59SzGPudsLo+1rn4dGwK3m37MREE/JLRpPK/xr1 UojjBq5qMtyBaoa+1AhydjHBQCM62nWZQFpfq76FY5SIXZ/oa4NZKGkB3UknnUnERbor1KGqfxaDa OnMIIRS/5shvCVa0wpTtP7NbwnkKSvPnPraxFDVCyejDWY23QLiHJ/unihJrffXuaOuSE+ZY/M8WP 5Q684yLCTG6auKnTJjrd4V2q+y5dRCZjY5nTzujW1+uNfnmVlc7heVlcKQqkDHBDZEEG/Xxh2qDj6 mbDMFwGg==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDI-0004Z2-7X; Mon, 20 Jul 2020 12:48:13 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 12/24] bpfilter: switch bpfilter_ip_set_sockopt to sockptr_t Date: Mon, 20 Jul 2020 14:47:25 +0200 Message-Id: <20200720124737.118617-13-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 95826A21F5 X-Rspamd-UID: 8d5e56 This is mostly to prepare for cleaning up the callers, as bpfilter by design can't handle kernel pointers. Signed-off-by: Christoph Hellwig --- include/linux/bpfilter.h | 6 +++--- net/bpfilter/bpfilter_kern.c | 8 ++++---- net/ipv4/bpfilter/sockopt.c | 8 ++++---- net/ipv4/ip_sockglue.c | 3 ++- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/linux/bpfilter.h b/include/linux/bpfilter.h index 9b114c718a7617..2ae3c8e1d83c43 100644 --- a/include/linux/bpfilter.h +++ b/include/linux/bpfilter.h @@ -4,9 +4,10 @@ #include #include +#include struct sock; -int bpfilter_ip_set_sockopt(struct sock *sk, int optname, char __user *optval, +int bpfilter_ip_set_sockopt(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen); int bpfilter_ip_get_sockopt(struct sock *sk, int optname, char __user *optval, int __user *optlen); @@ -16,8 +17,7 @@ struct bpfilter_umh_ops { struct umd_info info; /* since ip_getsockopt() can run in parallel, serialize access to umh */ struct mutex lock; - int (*sockopt)(struct sock *sk, int optname, - char __user *optval, + int (*sockopt)(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen, bool is_set); int (*start)(void); }; diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c index 713b4b3d02005d..52f8d0bc3f6b29 100644 --- a/net/bpfilter/bpfilter_kern.c +++ b/net/bpfilter/bpfilter_kern.c @@ -32,7 +32,7 @@ static void __stop_umh(void) } static int __bpfilter_process_sockopt(struct sock *sk, int optname, - char __user *optval, + sockptr_t optval, unsigned int optlen, bool is_set) { struct mbox_request req; @@ -41,7 +41,7 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname, ssize_t n; int ret = -EFAULT; - if (uaccess_kernel()) { + if (uaccess_kernel() || sockptr_is_kernel(optval)) { pr_err("kernel access not supported\n"); return -EFAULT; } @@ -49,7 +49,7 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname, req.is_set = is_set; req.pid = current->pid; req.cmd = optname; - req.addr = (__force long)optval; + req.addr = (__force long)optval.user; req.len = optlen; if (!bpfilter_ops.info.tgid) goto out; @@ -87,7 +87,7 @@ static int start_umh(void) pr_info("Loaded bpfilter_umh pid %d\n", pid_nr(bpfilter_ops.info.tgid)); /* health check that usermode process started correctly */ - if (__bpfilter_process_sockopt(NULL, 0, NULL, 0, 0) != 0) { + if (__bpfilter_process_sockopt(NULL, 0, USER_SOCKPTR(NULL), 0, 0)) { shutdown_umh(); return -EFAULT; } diff --git a/net/ipv4/bpfilter/sockopt.c b/net/ipv4/bpfilter/sockopt.c index 9063c6767d3410..1b34cb9a7708ec 100644 --- a/net/ipv4/bpfilter/sockopt.c +++ b/net/ipv4/bpfilter/sockopt.c @@ -21,8 +21,7 @@ void bpfilter_umh_cleanup(struct umd_info *info) } EXPORT_SYMBOL_GPL(bpfilter_umh_cleanup); -static int bpfilter_mbox_request(struct sock *sk, int optname, - char __user *optval, +static int bpfilter_mbox_request(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen, bool is_set) { int err; @@ -52,7 +51,7 @@ static int bpfilter_mbox_request(struct sock *sk, int optname, return err; } -int bpfilter_ip_set_sockopt(struct sock *sk, int optname, char __user *optval, +int bpfilter_ip_set_sockopt(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen) { return bpfilter_mbox_request(sk, optname, optval, optlen, true); @@ -66,7 +65,8 @@ int bpfilter_ip_get_sockopt(struct sock *sk, int optname, char __user *optval, if (get_user(len, optlen)) return -EFAULT; - return bpfilter_mbox_request(sk, optname, optval, len, false); + return bpfilter_mbox_request(sk, optname, USER_SOCKPTR(optval), len, + false); } static int __init bpfilter_sockopt_init(void) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 42befbf12846c0..36f746e01741f6 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1414,7 +1414,8 @@ int ip_setsockopt(struct sock *sk, int level, #if IS_ENABLED(CONFIG_BPFILTER_UMH) if (optname >= BPFILTER_IPT_SO_SET_REPLACE && optname < BPFILTER_IPT_SET_MAX) - err = bpfilter_ip_set_sockopt(sk, optname, optval, optlen); + err = bpfilter_ip_set_sockopt(sk, optname, USER_SOCKPTR(optval), + optlen); #endif #ifdef CONFIG_NETFILTER /* we need to exclude all possible ENOPROTOOPTs except default case */ -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MJKMFbyTFV/s0AEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:53:16 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id gFwAFLyTFV99qAAAlScrYA (envelope-from ); Mon, 20 Jul 2020 14:53:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2AAE5A242B; Mon, 20 Jul 2020 14:53:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728970AbgGTMs0 (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728326AbgGTMs0 (ORCPT ); Mon, 20 Jul 2020 08:48:26 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94823C061794; Mon, 20 Jul 2020 05:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=j0L+Qk7oKcxnlURXcCS3zaGErKnPf8jGdSz60eAGoas=; b=vyrInRSyjxBFp85JGDgEM1ey+x daOmTnQbxCCmRJK79FDhI8s2c5wUUbLLvuDX/5bjs5jhEYnmAixNtjVRp4/CJq+CyaKPTJdNJRxuH zTcn1wAlhVOHZ3ZgDc/+fyyHfE4qg/oy5qTe7NwbiNh4BfopzS/Jp08OFUBQXXgzQrSY7H/gKPuMt FOK/Y+dKVbUlSUJZVtJSrdYbxHNGve2tepskRLMvKUneEYv0WMdU7/XsvOmJEfUYrUl7ecZrAsSEc dIrYupB04Sc6sqHzIjogh01kWAtZEFjVpMbIZF+l47h+SDrLM8Fub0pjnnI0oDD1Rg5xfH8SnJkFj E0ibMt0w==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDF-0004Yg-Ct; Mon, 20 Jul 2020 12:48:10 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 11/24] netfilter: switch nf_setsockopt to sockptr_t Date: Mon, 20 Jul 2020 14:47:24 +0200 Message-Id: <20200720124737.118617-12-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2AAE5A242B X-Rspamd-UID: 7154b9 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/linux/netfilter.h | 6 ++++-- net/bridge/netfilter/ebtables.c | 37 +++++++++++++++------------------ net/decnet/af_decnet.c | 3 ++- net/ipv4/ip_sockglue.c | 3 ++- net/ipv4/netfilter/arp_tables.c | 28 ++++++++++++------------- net/ipv4/netfilter/ip_tables.c | 24 ++++++++++----------- net/ipv6/ipv6_sockglue.c | 3 ++- net/ipv6/netfilter/ip6_tables.c | 24 ++++++++++----------- net/netfilter/ipvs/ip_vs_ctl.c | 4 ++-- net/netfilter/nf_sockopt.c | 2 +- 10 files changed, 68 insertions(+), 66 deletions(-) diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index 711b4d4486f042..0101747de54936 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h @@ -13,6 +13,7 @@ #include #include #include +#include #include static inline int NF_DROP_GETERR(int verdict) @@ -163,7 +164,8 @@ struct nf_sockopt_ops { /* Non-inclusive ranges: use 0/0/NULL to never get called. */ int set_optmin; int set_optmax; - int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len); + int (*set)(struct sock *sk, int optval, sockptr_t arg, + unsigned int len); int get_optmin; int get_optmax; int (*get)(struct sock *sk, int optval, void __user *user, int *len); @@ -338,7 +340,7 @@ NF_HOOK_LIST(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk, } /* Call setsockopt() */ -int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt, +int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, sockptr_t opt, unsigned int len); int nf_getsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt, int *len); diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 12f8929667bf43..d35173e803d3fe 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1063,14 +1063,13 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl, } /* replace the table */ -static int do_replace(struct net *net, const void __user *user, - unsigned int len) +static int do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret, countersize; struct ebt_table_info *newinfo; struct ebt_replace tmp; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; if (len != sizeof(tmp) + tmp.entries_size) @@ -1286,12 +1285,11 @@ static int do_update_counters(struct net *net, const char *name, return ret; } -static int update_counters(struct net *net, const void __user *user, - unsigned int len) +static int update_counters(struct net *net, sockptr_t arg, unsigned int len) { struct ebt_replace hlp; - if (copy_from_user(&hlp, user, sizeof(hlp))) + if (copy_from_sockptr(&hlp, arg, sizeof(hlp))) return -EFAULT; if (len != sizeof(hlp) + hlp.num_counters * sizeof(struct ebt_counter)) @@ -2079,7 +2077,7 @@ static int compat_copy_entries(unsigned char *data, unsigned int size_user, static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl, - void __user *user, unsigned int len) + sockptr_t arg, unsigned int len) { struct compat_ebt_replace tmp; int i; @@ -2087,7 +2085,7 @@ static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl, if (len < sizeof(tmp)) return -EINVAL; - if (copy_from_user(&tmp, user, sizeof(tmp))) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp))) return -EFAULT; if (len != sizeof(tmp) + tmp.entries_size) @@ -2114,8 +2112,7 @@ static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl, return 0; } -static int compat_do_replace(struct net *net, void __user *user, - unsigned int len) +static int compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret, i, countersize, size64; struct ebt_table_info *newinfo; @@ -2123,10 +2120,10 @@ static int compat_do_replace(struct net *net, void __user *user, struct ebt_entries_buf_state state; void *entries_tmp; - ret = compat_copy_ebt_replace_from_user(&tmp, user, len); + ret = compat_copy_ebt_replace_from_user(&tmp, arg, len); if (ret) { /* try real handler in case userland supplied needed padding */ - if (ret == -EINVAL && do_replace(net, user, len) == 0) + if (ret == -EINVAL && do_replace(net, arg, len) == 0) ret = 0; return ret; } @@ -2217,17 +2214,17 @@ static int compat_do_replace(struct net *net, void __user *user, goto free_entries; } -static int compat_update_counters(struct net *net, void __user *user, +static int compat_update_counters(struct net *net, sockptr_t arg, unsigned int len) { struct compat_ebt_replace hlp; - if (copy_from_user(&hlp, user, sizeof(hlp))) + if (copy_from_sockptr(&hlp, arg, sizeof(hlp))) return -EFAULT; /* try real handler in case userland supplied needed padding */ if (len != sizeof(hlp) + hlp.num_counters * sizeof(struct ebt_counter)) - return update_counters(net, user, len); + return update_counters(net, arg, len); return do_update_counters(net, hlp.name, compat_ptr(hlp.counters), hlp.num_counters, len); @@ -2368,7 +2365,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) return ret; } -static int do_ebt_set_ctl(struct sock *sk, int cmd, void __user *user, +static int do_ebt_set_ctl(struct sock *sk, int cmd, sockptr_t arg, unsigned int len) { struct net *net = sock_net(sk); @@ -2381,18 +2378,18 @@ static int do_ebt_set_ctl(struct sock *sk, int cmd, void __user *user, case EBT_SO_SET_ENTRIES: #ifdef CONFIG_COMPAT if (in_compat_syscall()) - ret = compat_do_replace(net, user, len); + ret = compat_do_replace(net, arg, len); else #endif - ret = do_replace(net, user, len); + ret = do_replace(net, arg, len); break; case EBT_SO_SET_COUNTERS: #ifdef CONFIG_COMPAT if (in_compat_syscall()) - ret = compat_update_counters(net, user, len); + ret = compat_update_counters(net, arg, len); else #endif - ret = update_counters(net, user, len); + ret = update_counters(net, arg, len); break; default: ret = -EINVAL; diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index 7d7ae2dd69b8ad..7d51ab608fb3f1 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c @@ -1332,7 +1332,8 @@ static int dn_setsockopt(struct socket *sock, int level, int optname, char __use /* we need to exclude all possible ENOPROTOOPTs except default case */ if (err == -ENOPROTOOPT && optname != DSO_LINKINFO && optname != DSO_STREAM && optname != DSO_SEQPACKET) - err = nf_setsockopt(sk, PF_DECnet, optname, optval, optlen); + err = nf_setsockopt(sk, PF_DECnet, optname, + USER_SOCKPTR(optval), optlen); #endif return err; diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index da933f99b5d517..42befbf12846c0 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1422,7 +1422,8 @@ int ip_setsockopt(struct sock *sk, int level, optname != IP_IPSEC_POLICY && optname != IP_XFRM_POLICY && !ip_mroute_opt(optname)) - err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); + err = nf_setsockopt(sk, PF_INET, optname, USER_SOCKPTR(optval), + optlen); #endif return err; } diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 6d24b686c7f00a..f5b26ef1782001 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0-only + /* * Packet matching code for ARP packets. * @@ -947,8 +947,7 @@ static int __do_replace(struct net *net, const char *name, return ret; } -static int do_replace(struct net *net, const void __user *user, - unsigned int len) +static int do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct arpt_replace tmp; @@ -956,7 +955,7 @@ static int do_replace(struct net *net, const void __user *user, void *loc_cpu_entry; struct arpt_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -972,8 +971,8 @@ static int do_replace(struct net *net, const void __user *user, return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), - tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1244,8 +1243,7 @@ static int translate_compat_table(struct net *net, return ret; } -static int compat_do_replace(struct net *net, void __user *user, - unsigned int len) +static int compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct compat_arpt_replace tmp; @@ -1253,7 +1251,7 @@ static int compat_do_replace(struct net *net, void __user *user, void *loc_cpu_entry; struct arpt_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -1269,7 +1267,8 @@ static int compat_do_replace(struct net *net, void __user *user, return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1401,7 +1400,8 @@ static int compat_get_entries(struct net *net, } #endif -static int do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) +static int do_arpt_set_ctl(struct sock *sk, int cmd, sockptr_t arg, + unsigned int len) { int ret; @@ -1412,14 +1412,14 @@ static int do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned case ARPT_SO_SET_REPLACE: #ifdef CONFIG_COMPAT if (in_compat_syscall()) - ret = compat_do_replace(sock_net(sk), user, len); + ret = compat_do_replace(sock_net(sk), arg, len); else #endif - ret = do_replace(sock_net(sk), user, len); + ret = do_replace(sock_net(sk), arg, len); break; case ARPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); + ret = do_add_counters(sock_net(sk), arg, len); break; default: diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 4697d09c98dc3e..f2a9680303d8c0 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -1102,7 +1102,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks, } static int -do_replace(struct net *net, const void __user *user, unsigned int len) +do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct ipt_replace tmp; @@ -1110,7 +1110,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) void *loc_cpu_entry; struct ipt_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -1126,8 +1126,8 @@ do_replace(struct net *net, const void __user *user, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), - tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1484,7 +1484,7 @@ translate_compat_table(struct net *net, } static int -compat_do_replace(struct net *net, void __user *user, unsigned int len) +compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct compat_ipt_replace tmp; @@ -1492,7 +1492,7 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) void *loc_cpu_entry; struct ipt_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -1508,8 +1508,8 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), - tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1610,7 +1610,7 @@ compat_get_entries(struct net *net, struct compat_ipt_get_entries __user *uptr, #endif static int -do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) +do_ipt_set_ctl(struct sock *sk, int cmd, sockptr_t arg, unsigned int len) { int ret; @@ -1621,14 +1621,14 @@ do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) case IPT_SO_SET_REPLACE: #ifdef CONFIG_COMPAT if (in_compat_syscall()) - ret = compat_do_replace(sock_net(sk), user, len); + ret = compat_do_replace(sock_net(sk), arg, len); else #endif - ret = do_replace(sock_net(sk), user, len); + ret = do_replace(sock_net(sk), arg, len); break; case IPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); + ret = do_add_counters(sock_net(sk), arg, len); break; default: diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 56a74707c61741..85892b35cff7b3 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -996,7 +996,8 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, /* we need to exclude all possible ENOPROTOOPTs except default case */ if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY && optname != IPV6_XFRM_POLICY) - err = nf_setsockopt(sk, PF_INET6, optname, optval, optlen); + err = nf_setsockopt(sk, PF_INET6, optname, USER_SOCKPTR(optval), + optlen); #endif return err; } diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index a787aba30e2db7..1d52957a413f4a 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -1119,7 +1119,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks, } static int -do_replace(struct net *net, const void __user *user, unsigned int len) +do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct ip6t_replace tmp; @@ -1127,7 +1127,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) void *loc_cpu_entry; struct ip6t_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -1143,8 +1143,8 @@ do_replace(struct net *net, const void __user *user, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), - tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1493,7 +1493,7 @@ translate_compat_table(struct net *net, } static int -compat_do_replace(struct net *net, void __user *user, unsigned int len) +compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct compat_ip6t_replace tmp; @@ -1501,7 +1501,7 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) void *loc_cpu_entry; struct ip6t_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -1517,8 +1517,8 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), - tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1619,7 +1619,7 @@ compat_get_entries(struct net *net, struct compat_ip6t_get_entries __user *uptr, #endif static int -do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) +do_ip6t_set_ctl(struct sock *sk, int cmd, sockptr_t arg, unsigned int len) { int ret; @@ -1630,14 +1630,14 @@ do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) case IP6T_SO_SET_REPLACE: #ifdef CONFIG_COMPAT if (in_compat_syscall()) - ret = compat_do_replace(sock_net(sk), user, len); + ret = compat_do_replace(sock_net(sk), arg, len); else #endif - ret = do_replace(sock_net(sk), user, len); + ret = do_replace(sock_net(sk), arg, len); break; case IP6T_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); + ret = do_add_counters(sock_net(sk), arg, len); break; default: diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index 4af83f466dfc2c..bcac316addabe8 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -2434,7 +2434,7 @@ static void ip_vs_copy_udest_compat(struct ip_vs_dest_user_kern *udest, } static int -do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) +do_ip_vs_set_ctl(struct sock *sk, int cmd, sockptr_t ptr, unsigned int len) { struct net *net = sock_net(sk); int ret; @@ -2458,7 +2458,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) return -EINVAL; } - if (copy_from_user(arg, user, len) != 0) + if (copy_from_sockptr(arg, ptr, len) != 0) return -EFAULT; /* Handle daemons since they have another lock */ diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c index 90469b1f628a8e..34afcd03b6f60e 100644 --- a/net/netfilter/nf_sockopt.c +++ b/net/netfilter/nf_sockopt.c @@ -89,7 +89,7 @@ static struct nf_sockopt_ops *nf_sockopt_find(struct sock *sk, u_int8_t pf, return ops; } -int nf_setsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt, +int nf_setsockopt(struct sock *sk, u_int8_t pf, int val, sockptr_t opt, unsigned int len) { struct nf_sockopt_ops *ops; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6DcaFsOTFV/s0AEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:53:23 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 8PB9FMOTFV/btQAAlScrYA (envelope-from ); Mon, 20 Jul 2020 14:53:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AAD41A2601; Mon, 20 Jul 2020 14:53:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729471AbgGTMvK (ORCPT + 1 other); Mon, 20 Jul 2020 08:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728738AbgGTMsV (ORCPT ); Mon, 20 Jul 2020 08:48:21 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B3B8C061794; Mon, 20 Jul 2020 05:48:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=BXIWlOxxLGAwEkybRtLTw7LIxC9f35ukkZ5P3mQ+S3I=; b=kknbEvF359Bd6tXs5m6v0Bn7Ko vYBhFcZbo5m2EyzEZQSROToEVfvd7U8AhbFyTHl9tBHPHBpn+o06EGL26u8zK84fwOqTG2nwOTyuy /ww4G31fRlSvc8af//hFPJZq9EbHojgpRpTqOszBhMu0hLLrSpMAT8x41hg8Ewk86gOq82WD5rvCA gXK0QpfDMrdhD2r7iYAIAAkoDis+eFcYhp8PGOQVSN5RkG7Mk0F6HEa0t8a0MydisW7a9HUhiIFoo Z7pExtU3rAtnoGUKv+TyOO/Cf/7kDtzI9zMIITcsA5ywQPTi+jPfu4KWisp4vKX5fqHM0Ji5cy75r T85wpX2w==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDD-0004YK-02; Mon, 20 Jul 2020 12:48:08 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 10/24] netfilter: switch xt_copy_counters to sockptr_t Date: Mon, 20 Jul 2020 14:47:23 +0200 Message-Id: <20200720124737.118617-11-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: AAD41A2601 X-Rspamd-UID: 4976a6 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/linux/netfilter/x_tables.h | 4 ++-- net/ipv4/netfilter/arp_tables.c | 7 +++---- net/ipv4/netfilter/ip_tables.c | 7 +++---- net/ipv6/netfilter/ip6_tables.c | 6 +++--- net/netfilter/x_tables.c | 20 ++++++++++---------- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index b8b943ee7b8b66..5deb099d156dcb 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h @@ -301,8 +301,8 @@ int xt_target_to_user(const struct xt_entry_target *t, int xt_data_to_user(void __user *dst, const void *src, int usersize, int size, int aligned_size); -void *xt_copy_counters_from_user(const void __user *user, unsigned int len, - struct xt_counters_info *info); +void *xt_copy_counters(sockptr_t arg, unsigned int len, + struct xt_counters_info *info); struct xt_counters *xt_counters_alloc(unsigned int counters); struct xt_table *xt_register_table(struct net *net, diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 2c8a4dad39d748..6d24b686c7f00a 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -996,8 +996,7 @@ static int do_replace(struct net *net, const void __user *user, return ret; } -static int do_add_counters(struct net *net, const void __user *user, - unsigned int len) +static int do_add_counters(struct net *net, sockptr_t arg, unsigned int len) { unsigned int i; struct xt_counters_info tmp; @@ -1008,7 +1007,7 @@ static int do_add_counters(struct net *net, const void __user *user, struct arpt_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp); + paddc = xt_copy_counters(arg, len, &tmp); if (IS_ERR(paddc)) return PTR_ERR(paddc); @@ -1420,7 +1419,7 @@ static int do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned break; case ARPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len); + ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); break; default: diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 161901dd1cae7f..4697d09c98dc3e 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -1151,8 +1151,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) } static int -do_add_counters(struct net *net, const void __user *user, - unsigned int len) +do_add_counters(struct net *net, sockptr_t arg, unsigned int len) { unsigned int i; struct xt_counters_info tmp; @@ -1163,7 +1162,7 @@ do_add_counters(struct net *net, const void __user *user, struct ipt_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp); + paddc = xt_copy_counters(arg, len, &tmp); if (IS_ERR(paddc)) return PTR_ERR(paddc); @@ -1629,7 +1628,7 @@ do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) break; case IPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len); + ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); break; default: diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index fd1f8f93123188..a787aba30e2db7 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -1168,7 +1168,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) } static int -do_add_counters(struct net *net, const void __user *user, unsigned int len) +do_add_counters(struct net *net, sockptr_t arg, unsigned int len) { unsigned int i; struct xt_counters_info tmp; @@ -1179,7 +1179,7 @@ do_add_counters(struct net *net, const void __user *user, unsigned int len) struct ip6t_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp); + paddc = xt_copy_counters(arg, len, &tmp); if (IS_ERR(paddc)) return PTR_ERR(paddc); t = xt_find_table_lock(net, AF_INET6, tmp.name); @@ -1637,7 +1637,7 @@ do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) break; case IP6T_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len); + ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); break; default: diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 32bab45af7e415..b97eb4b538fd4e 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1028,9 +1028,9 @@ int xt_check_target(struct xt_tgchk_param *par, EXPORT_SYMBOL_GPL(xt_check_target); /** - * xt_copy_counters_from_user - copy counters and metadata from userspace + * xt_copy_counters - copy counters and metadata from a sockptr_t * - * @user: src pointer to userspace memory + * @arg: src sockptr * @len: alleged size of userspace memory * @info: where to store the xt_counters_info metadata * @@ -1047,8 +1047,8 @@ EXPORT_SYMBOL_GPL(xt_check_target); * Return: returns pointer that caller has to test via IS_ERR(). * If IS_ERR is false, caller has to vfree the pointer. */ -void *xt_copy_counters_from_user(const void __user *user, unsigned int len, - struct xt_counters_info *info) +void *xt_copy_counters(sockptr_t arg, unsigned int len, + struct xt_counters_info *info) { void *mem; u64 size; @@ -1062,12 +1062,12 @@ void *xt_copy_counters_from_user(const void __user *user, unsigned int len, return ERR_PTR(-EINVAL); len -= sizeof(compat_tmp); - if (copy_from_user(&compat_tmp, user, sizeof(compat_tmp)) != 0) + if (copy_from_sockptr(&compat_tmp, arg, sizeof(compat_tmp)) != 0) return ERR_PTR(-EFAULT); memcpy(info->name, compat_tmp.name, sizeof(info->name) - 1); info->num_counters = compat_tmp.num_counters; - user += sizeof(compat_tmp); + sockptr_advance(arg, sizeof(compat_tmp)); } else #endif { @@ -1075,10 +1075,10 @@ void *xt_copy_counters_from_user(const void __user *user, unsigned int len, return ERR_PTR(-EINVAL); len -= sizeof(*info); - if (copy_from_user(info, user, sizeof(*info)) != 0) + if (copy_from_sockptr(info, arg, sizeof(*info)) != 0) return ERR_PTR(-EFAULT); - user += sizeof(*info); + sockptr_advance(arg, sizeof(*info)); } info->name[sizeof(info->name) - 1] = '\0'; @@ -1092,13 +1092,13 @@ void *xt_copy_counters_from_user(const void __user *user, unsigned int len, if (!mem) return ERR_PTR(-ENOMEM); - if (copy_from_user(mem, user, len) == 0) + if (copy_from_sockptr(mem, arg, len) == 0) return mem; vfree(mem); return ERR_PTR(-EFAULT); } -EXPORT_SYMBOL_GPL(xt_copy_counters_from_user); +EXPORT_SYMBOL_GPL(xt_copy_counters); #ifdef CONFIG_COMPAT int xt_compat_target_offset(const struct xt_target *target) -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kDyvHxmoFV+N2wAAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 16:20:09 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id +FhoHhmoFV8D7QAA0J78UA (envelope-from ); Mon, 20 Jul 2020 16:20:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B3089A2625; Mon, 20 Jul 2020 16:20:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728533AbgGTOTs (ORCPT + 1 other); Mon, 20 Jul 2020 10:19:48 -0400 Received: from proxima.lasnet.de ([78.47.171.185]:47092 "EHLO proxima.lasnet.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbgGTOTr (ORCPT ); Mon, 20 Jul 2020 10:19:47 -0400 Received: from localhost.localdomain (p200300e9d7371614ec13d59c95910a08.dip0.t-ipconnect.de [IPv6:2003:e9:d737:1614:ec13:d59c:9591:a08]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: stefan@datenfreihafen.org) by proxima.lasnet.de (Postfix) with ESMTPSA id 2321BC0D06; Mon, 20 Jul 2020 16:19:38 +0200 (CEST) Subject: Re: [PATCH 24/24] net: pass a sockptr_t into ->setsockopt To: Christoph Hellwig , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-25-hch@lst.de> From: Stefan Schmidt Message-ID: Date: Mon, 20 Jul 2020 16:19:38 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200720124737.118617-25-hch@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: B3089A2625 X-Rspamd-UID: 1eed4b Hello. On 20.07.20 14:47, Christoph Hellwig wrote: > Rework the remaining setsockopt code to pass a sockptr_t instead of a > plain user pointer. This removes the last remaining set_fs(KERNEL_DS) > outside of architecture specific code. > > Signed-off-by: Christoph Hellwig > --- > crypto/af_alg.c | 7 ++-- > drivers/crypto/chelsio/chtls/chtls_main.c | 18 ++++++----- > drivers/isdn/mISDN/socket.c | 4 +-- > include/linux/net.h | 4 ++- > include/net/inet_connection_sock.h | 3 +- > include/net/ip.h | 2 +- > include/net/ipv6.h | 4 +-- > include/net/sctp/structs.h | 2 +- > include/net/sock.h | 4 +-- > include/net/tcp.h | 4 +-- > net/atm/common.c | 6 ++-- > net/atm/common.h | 2 +- > net/atm/pvc.c | 2 +- > net/atm/svc.c | 6 ++-- > net/ax25/af_ax25.c | 6 ++-- > net/bluetooth/hci_sock.c | 8 ++--- > net/bluetooth/l2cap_sock.c | 22 ++++++------- > net/bluetooth/rfcomm/sock.c | 12 ++++--- > net/bluetooth/sco.c | 6 ++-- > net/caif/caif_socket.c | 8 ++--- > net/can/j1939/socket.c | 12 +++---- > net/can/raw.c | 16 +++++----- > net/core/sock.c | 2 +- > net/dccp/dccp.h | 2 +- > net/dccp/proto.c | 20 ++++++------ > net/decnet/af_decnet.c | 16 ++++++---- > net/ieee802154/socket.c | 6 ++-- > net/ipv4/ip_sockglue.c | 13 +++----- > net/ipv4/raw.c | 8 ++--- > net/ipv4/tcp.c | 5 ++- > net/ipv4/udp.c | 6 ++-- > net/ipv4/udp_impl.h | 4 +-- > net/ipv6/ipv6_sockglue.c | 10 +++--- > net/ipv6/raw.c | 10 +++--- > net/ipv6/udp.c | 6 ++-- > net/ipv6/udp_impl.h | 4 +-- > net/iucv/af_iucv.c | 4 +-- > net/kcm/kcmsock.c | 6 ++-- > net/l2tp/l2tp_ppp.c | 4 +-- > net/llc/af_llc.c | 4 +-- > net/mptcp/protocol.c | 14 ++++---- > net/netlink/af_netlink.c | 4 +-- > net/netrom/af_netrom.c | 4 +-- > net/nfc/llcp_sock.c | 6 ++-- > net/packet/af_packet.c | 39 ++++++++++++----------- > net/phonet/pep.c | 4 +-- > net/rds/af_rds.c | 30 ++++++++--------- > net/rds/rdma.c | 14 ++++---- > net/rds/rds.h | 6 ++-- > net/rose/af_rose.c | 4 +-- > net/rxrpc/af_rxrpc.c | 8 ++--- > net/rxrpc/ar-internal.h | 4 +-- > net/rxrpc/key.c | 9 +++--- > net/sctp/socket.c | 4 +-- > net/smc/af_smc.c | 4 +-- > net/socket.c | 23 ++++--------- > net/tipc/socket.c | 8 ++--- > net/tls/tls_main.c | 17 +++++----- > net/vmw_vsock/af_vsock.c | 4 +-- > net/x25/af_x25.c | 4 +-- > net/xdp/xsk.c | 8 ++--- > 61 files changed, 248 insertions(+), 258 deletions(-) > > diff --git a/crypto/af_alg.c b/crypto/af_alg.c > index 29f71428520b4b..892242a42c3ec9 100644 > --- a/crypto/af_alg.c > +++ b/crypto/af_alg.c > @@ -197,8 +197,7 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) > return err; > } > > -static int alg_setkey(struct sock *sk, char __user *ukey, > - unsigned int keylen) > +static int alg_setkey(struct sock *sk, sockptr_t ukey, unsigned int keylen) > { > struct alg_sock *ask = alg_sk(sk); > const struct af_alg_type *type = ask->type; > @@ -210,7 +209,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey, > return -ENOMEM; > > err = -EFAULT; > - if (copy_from_user(key, ukey, keylen)) > + if (copy_from_sockptr(key, ukey, keylen)) > goto out; > > err = type->setkey(ask->private, key, keylen); > @@ -222,7 +221,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey, > } > > static int alg_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > struct alg_sock *ask = alg_sk(sk); > diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c b/drivers/crypto/chelsio/chtls/chtls_main.c > index d98b89d0fa6eeb..c3058dcdb33c5c 100644 > --- a/drivers/crypto/chelsio/chtls/chtls_main.c > +++ b/drivers/crypto/chelsio/chtls/chtls_main.c > @@ -488,7 +488,7 @@ static int chtls_getsockopt(struct sock *sk, int level, int optname, > } > > static int do_chtls_setsockopt(struct sock *sk, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct tls_crypto_info *crypto_info, tmp_crypto_info; > struct chtls_sock *csk; > @@ -498,12 +498,12 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, > > csk = rcu_dereference_sk_user_data(sk); > > - if (!optval || optlen < sizeof(*crypto_info)) { > + if (sockptr_is_null(optval) || optlen < sizeof(*crypto_info)) { > rc = -EINVAL; > goto out; > } > > - rc = copy_from_user(&tmp_crypto_info, optval, sizeof(*crypto_info)); > + rc = copy_from_sockptr(&tmp_crypto_info, optval, sizeof(*crypto_info)); > if (rc) { > rc = -EFAULT; > goto out; > @@ -525,8 +525,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, > /* Obtain version and type from previous copy */ > crypto_info[0] = tmp_crypto_info; > /* Now copy the following data */ > - rc = copy_from_user((char *)crypto_info + sizeof(*crypto_info), > - optval + sizeof(*crypto_info), > + sockptr_advance(optval, sizeof(*crypto_info)); > + rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), > + optval, > sizeof(struct tls12_crypto_info_aes_gcm_128) > - sizeof(*crypto_info)); > > @@ -541,8 +542,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, > } > case TLS_CIPHER_AES_GCM_256: { > crypto_info[0] = tmp_crypto_info; > - rc = copy_from_user((char *)crypto_info + sizeof(*crypto_info), > - optval + sizeof(*crypto_info), > + sockptr_advance(optval, sizeof(*crypto_info)); > + rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), > + optval, > sizeof(struct tls12_crypto_info_aes_gcm_256) > - sizeof(*crypto_info)); > > @@ -565,7 +567,7 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, > } > > static int chtls_setsockopt(struct sock *sk, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct tls_context *ctx = tls_get_ctx(sk); > > diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c > index 1b2b91479107bc..2835daae9e9f3a 100644 > --- a/drivers/isdn/mISDN/socket.c > +++ b/drivers/isdn/mISDN/socket.c > @@ -401,7 +401,7 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) > } > > static int data_sock_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int len) > + sockptr_t optval, unsigned int len) > { > struct sock *sk = sock->sk; > int err = 0, opt = 0; > @@ -414,7 +414,7 @@ static int data_sock_setsockopt(struct socket *sock, int level, int optname, > > switch (optname) { > case MISDN_TIME_STAMP: > - if (get_user(opt, (int __user *)optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(int))) { > err = -EFAULT; > break; > } > diff --git a/include/linux/net.h b/include/linux/net.h > index 858ff1d981540d..d48ff11808794c 100644 > --- a/include/linux/net.h > +++ b/include/linux/net.h > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > > #include > > @@ -162,7 +163,8 @@ struct proto_ops { > int (*listen) (struct socket *sock, int len); > int (*shutdown) (struct socket *sock, int flags); > int (*setsockopt)(struct socket *sock, int level, > - int optname, char __user *optval, unsigned int optlen); > + int optname, sockptr_t optval, > + unsigned int optlen); > int (*getsockopt)(struct socket *sock, int level, > int optname, char __user *optval, int __user *optlen); > void (*show_fdinfo)(struct seq_file *m, struct socket *sock); > diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h > index 157c60cca0ca60..1e209ce7d1bd1b 100644 > --- a/include/net/inet_connection_sock.h > +++ b/include/net/inet_connection_sock.h > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -45,7 +46,7 @@ struct inet_connection_sock_af_ops { > u16 net_frag_header_len; > u16 sockaddr_len; > int (*setsockopt)(struct sock *sk, int level, int optname, > - char __user *optval, unsigned int optlen); > + sockptr_t optval, unsigned int optlen); > int (*getsockopt)(struct sock *sk, int level, int optname, > char __user *optval, int __user *optlen); > void (*addr2sockaddr)(struct sock *sk, struct sockaddr *); > diff --git a/include/net/ip.h b/include/net/ip.h > index d66ad3a9522081..b09c48d862cc10 100644 > --- a/include/net/ip.h > +++ b/include/net/ip.h > @@ -722,7 +722,7 @@ void ip_cmsg_recv_offset(struct msghdr *msg, struct sock *sk, > struct sk_buff *skb, int tlen, int offset); > int ip_cmsg_send(struct sock *sk, struct msghdr *msg, > struct ipcm_cookie *ipc, bool allow_ipv6); > -int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, > +int ip_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, > unsigned int optlen); > int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, > int __user *optlen); > diff --git a/include/net/ipv6.h b/include/net/ipv6.h > index 4c9d89b5d73268..bd1f396cc9c729 100644 > --- a/include/net/ipv6.h > +++ b/include/net/ipv6.h > @@ -1084,8 +1084,8 @@ struct in6_addr *fl6_update_dst(struct flowi6 *fl6, > * socket options (ipv6_sockglue.c) > */ > > -int ipv6_setsockopt(struct sock *sk, int level, int optname, > - char __user *optval, unsigned int optlen); > +int ipv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, > + unsigned int optlen); > int ipv6_getsockopt(struct sock *sk, int level, int optname, > char __user *optval, int __user *optlen); > > diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h > index 233bbf7df5d66c..b33f1aefad0989 100644 > --- a/include/net/sctp/structs.h > +++ b/include/net/sctp/structs.h > @@ -431,7 +431,7 @@ struct sctp_af { > int (*setsockopt) (struct sock *sk, > int level, > int optname, > - char __user *optval, > + sockptr_t optval, > unsigned int optlen); > int (*getsockopt) (struct sock *sk, > int level, > diff --git a/include/net/sock.h b/include/net/sock.h > index bfb2fe2fc36876..2cc3ba667908de 100644 > --- a/include/net/sock.h > +++ b/include/net/sock.h > @@ -1141,7 +1141,7 @@ struct proto { > void (*destroy)(struct sock *sk); > void (*shutdown)(struct sock *sk, int how); > int (*setsockopt)(struct sock *sk, int level, > - int optname, char __user *optval, > + int optname, sockptr_t optval, > unsigned int optlen); > int (*getsockopt)(struct sock *sk, int level, > int optname, char __user *optval, > @@ -1734,7 +1734,7 @@ int sock_common_getsockopt(struct socket *sock, int level, int optname, > int sock_common_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, > int flags); > int sock_common_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen); > + sockptr_t optval, unsigned int optlen); > > void sk_common_release(struct sock *sk); > > diff --git a/include/net/tcp.h b/include/net/tcp.h > index e3c8e1d820214c..e0c35d56091f22 100644 > --- a/include/net/tcp.h > +++ b/include/net/tcp.h > @@ -399,8 +399,8 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, > struct poll_table_struct *wait); > int tcp_getsockopt(struct sock *sk, int level, int optname, > char __user *optval, int __user *optlen); > -int tcp_setsockopt(struct sock *sk, int level, int optname, > - char __user *optval, unsigned int optlen); > +int tcp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, > + unsigned int optlen); > void tcp_set_keepalive(struct sock *sk, int val); > void tcp_syn_ack_timeout(const struct request_sock *req); > int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock, > diff --git a/net/atm/common.c b/net/atm/common.c > index 9b28f1fb3c69c8..84367b844b1473 100644 > --- a/net/atm/common.c > +++ b/net/atm/common.c > @@ -745,7 +745,7 @@ static int check_qos(const struct atm_qos *qos) > } > > int vcc_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct atm_vcc *vcc; > unsigned long value; > @@ -760,7 +760,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, > { > struct atm_qos qos; > > - if (copy_from_user(&qos, optval, sizeof(qos))) > + if (copy_from_sockptr(&qos, optval, sizeof(qos))) > return -EFAULT; > error = check_qos(&qos); > if (error) > @@ -774,7 +774,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, > return 0; > } > case SO_SETCLP: > - if (get_user(value, (unsigned long __user *)optval)) > + if (copy_from_sockptr(&value, optval, sizeof(value))) > return -EFAULT; > if (value) > vcc->atm_options |= ATM_ATMOPT_CLP; > diff --git a/net/atm/common.h b/net/atm/common.h > index 5850649068bb29..a1e56e8de698a3 100644 > --- a/net/atm/common.h > +++ b/net/atm/common.h > @@ -21,7 +21,7 @@ __poll_t vcc_poll(struct file *file, struct socket *sock, poll_table *wait); > int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); > int vcc_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); > int vcc_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen); > + sockptr_t optval, unsigned int optlen); > int vcc_getsockopt(struct socket *sock, int level, int optname, > char __user *optval, int __user *optlen); > void vcc_process_recv_queue(struct atm_vcc *vcc); > diff --git a/net/atm/pvc.c b/net/atm/pvc.c > index 02bd2a436bdf9e..53e7d3f39e26cc 100644 > --- a/net/atm/pvc.c > +++ b/net/atm/pvc.c > @@ -63,7 +63,7 @@ static int pvc_connect(struct socket *sock, struct sockaddr *sockaddr, > } > > static int pvc_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > int error; > diff --git a/net/atm/svc.c b/net/atm/svc.c > index ba144d035e3d41..4a02bcaad279f8 100644 > --- a/net/atm/svc.c > +++ b/net/atm/svc.c > @@ -451,7 +451,7 @@ int svc_change_qos(struct atm_vcc *vcc, struct atm_qos *qos) > } > > static int svc_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > struct atm_vcc *vcc = ATM_SD(sock); > @@ -464,7 +464,7 @@ static int svc_setsockopt(struct socket *sock, int level, int optname, > error = -EINVAL; > goto out; > } > - if (copy_from_user(&vcc->sap, optval, optlen)) { > + if (copy_from_sockptr(&vcc->sap, optval, optlen)) { > error = -EFAULT; > goto out; > } > @@ -475,7 +475,7 @@ static int svc_setsockopt(struct socket *sock, int level, int optname, > error = -EINVAL; > goto out; > } > - if (get_user(value, (int __user *)optval)) { > + if (copy_from_sockptr(&value, optval, sizeof(int))) { > error = -EFAULT; > goto out; > } > diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c > index fd91cd34f25e03..17bf31a8969284 100644 > --- a/net/ax25/af_ax25.c > +++ b/net/ax25/af_ax25.c > @@ -528,7 +528,7 @@ ax25_cb *ax25_create_cb(void) > */ > > static int ax25_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > ax25_cb *ax25; > @@ -543,7 +543,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, > if (optlen < sizeof(unsigned int)) > return -EINVAL; > > - if (get_user(opt, (unsigned int __user *)optval)) > + if (copy_from_sockptr(&opt, optval, sizeof(unsigned int))) > return -EFAULT; > > lock_sock(sk); > @@ -640,7 +640,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, > > memset(devname, 0, sizeof(devname)); > > - if (copy_from_user(devname, optval, optlen)) { > + if (copy_from_sockptr(devname, optval, optlen)) { > res = -EFAULT; > break; > } > diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c > index caf38a8ea6a8ba..d5eff27d5b1e17 100644 > --- a/net/bluetooth/hci_sock.c > +++ b/net/bluetooth/hci_sock.c > @@ -1842,7 +1842,7 @@ static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg, > } > > static int hci_sock_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int len) > + sockptr_t optval, unsigned int len) > { > struct hci_ufilter uf = { .opcode = 0 }; > struct sock *sk = sock->sk; > @@ -1862,7 +1862,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, > > switch (optname) { > case HCI_DATA_DIR: > - if (get_user(opt, (int __user *)optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(opt))) { > err = -EFAULT; > break; > } > @@ -1874,7 +1874,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, > break; > > case HCI_TIME_STAMP: > - if (get_user(opt, (int __user *)optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(opt))) { > err = -EFAULT; > break; > } > @@ -1896,7 +1896,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, > } > > len = min_t(unsigned int, len, sizeof(uf)); > - if (copy_from_user(&uf, optval, len)) { > + if (copy_from_sockptr(&uf, optval, len)) { > err = -EFAULT; > break; > } > diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c > index a995d2c51fa7f1..a3d104123f38dd 100644 > --- a/net/bluetooth/l2cap_sock.c > +++ b/net/bluetooth/l2cap_sock.c > @@ -703,7 +703,7 @@ static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu) > } > > static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > struct l2cap_chan *chan = l2cap_pi(sk)->chan; > @@ -736,7 +736,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, > opts.txwin_size = chan->tx_win; > > len = min_t(unsigned int, sizeof(opts), optlen); > - if (copy_from_user((char *) &opts, optval, len)) { > + if (copy_from_sockptr(&opts, optval, len)) { > err = -EFAULT; > break; > } > @@ -782,7 +782,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, > break; > > case L2CAP_LM: > - if (get_user(opt, (u32 __user *) optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { > err = -EFAULT; > break; > } > @@ -859,7 +859,7 @@ static int l2cap_set_mode(struct l2cap_chan *chan, u8 mode) > } > > static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > struct l2cap_chan *chan = l2cap_pi(sk)->chan; > @@ -891,7 +891,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, > sec.level = BT_SECURITY_LOW; > > len = min_t(unsigned int, sizeof(sec), optlen); > - if (copy_from_user((char *) &sec, optval, len)) { > + if (copy_from_sockptr(&sec, optval, len)) { > err = -EFAULT; > break; > } > @@ -939,7 +939,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, > break; > } > > - if (get_user(opt, (u32 __user *) optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { > err = -EFAULT; > break; > } > @@ -954,7 +954,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, > break; > > case BT_FLUSHABLE: > - if (get_user(opt, (u32 __user *) optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { > err = -EFAULT; > break; > } > @@ -990,7 +990,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, > pwr.force_active = BT_POWER_FORCE_ACTIVE_ON; > > len = min_t(unsigned int, sizeof(pwr), optlen); > - if (copy_from_user((char *) &pwr, optval, len)) { > + if (copy_from_sockptr(&pwr, optval, len)) { > err = -EFAULT; > break; > } > @@ -1002,7 +1002,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, > break; > > case BT_CHANNEL_POLICY: > - if (get_user(opt, (u32 __user *) optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { > err = -EFAULT; > break; > } > @@ -1050,7 +1050,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, > break; > } > > - if (get_user(opt, (u16 __user *) optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(u16))) { > err = -EFAULT; > break; > } > @@ -1081,7 +1081,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, > break; > } > > - if (get_user(opt, (u8 __user *) optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(u8))) { > err = -EFAULT; > break; > } > diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c > index df14eebe80da8b..dba4ea0e1b0dc7 100644 > --- a/net/bluetooth/rfcomm/sock.c > +++ b/net/bluetooth/rfcomm/sock.c > @@ -644,7 +644,8 @@ static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg, > return len; > } > > -static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen) > +static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > int err = 0; > @@ -656,7 +657,7 @@ static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __u > > switch (optname) { > case RFCOMM_LM: > - if (get_user(opt, (u32 __user *) optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { > err = -EFAULT; > break; > } > @@ -685,7 +686,8 @@ static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __u > return err; > } > > -static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) > +static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > struct bt_security sec; > @@ -713,7 +715,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c > sec.level = BT_SECURITY_LOW; > > len = min_t(unsigned int, sizeof(sec), optlen); > - if (copy_from_user((char *) &sec, optval, len)) { > + if (copy_from_sockptr(&sec, optval, len)) { > err = -EFAULT; > break; > } > @@ -732,7 +734,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c > break; > } > > - if (get_user(opt, (u32 __user *) optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { > err = -EFAULT; > break; > } > diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c > index c8c3d38cdc7b56..37260baf71507b 100644 > --- a/net/bluetooth/sco.c > +++ b/net/bluetooth/sco.c > @@ -791,7 +791,7 @@ static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg, > } > > static int sco_sock_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > int len, err = 0; > @@ -810,7 +810,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, > break; > } > > - if (get_user(opt, (u32 __user *) optval)) { > + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { > err = -EFAULT; > break; > } > @@ -831,7 +831,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, > voice.setting = sco_pi(sk)->setting; > > len = min_t(unsigned int, sizeof(voice), optlen); > - if (copy_from_user((char *)&voice, optval, len)) { > + if (copy_from_sockptr(&voice, optval, len)) { > err = -EFAULT; > break; > } > diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c > index b94ecd931002e7..3ad0a1df671283 100644 > --- a/net/caif/caif_socket.c > +++ b/net/caif/caif_socket.c > @@ -669,8 +669,8 @@ static int caif_stream_sendmsg(struct socket *sock, struct msghdr *msg, > return sent ? : err; > } > > -static int setsockopt(struct socket *sock, > - int lvl, int opt, char __user *ov, unsigned int ol) > +static int setsockopt(struct socket *sock, int lvl, int opt, sockptr_t ov, > + unsigned int ol) > { > struct sock *sk = sock->sk; > struct caifsock *cf_sk = container_of(sk, struct caifsock, sk); > @@ -685,7 +685,7 @@ static int setsockopt(struct socket *sock, > return -EINVAL; > if (lvl != SOL_CAIF) > goto bad_sol; > - if (copy_from_user(&linksel, ov, sizeof(int))) > + if (copy_from_sockptr(&linksel, ov, sizeof(int))) > return -EINVAL; > lock_sock(&(cf_sk->sk)); > cf_sk->conn_req.link_selector = linksel; > @@ -699,7 +699,7 @@ static int setsockopt(struct socket *sock, > return -ENOPROTOOPT; > lock_sock(&(cf_sk->sk)); > if (ol > sizeof(cf_sk->conn_req.param.data) || > - copy_from_user(&cf_sk->conn_req.param.data, ov, ol)) { > + copy_from_sockptr(&cf_sk->conn_req.param.data, ov, ol)) { > release_sock(&cf_sk->sk); > return -EINVAL; > } > diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c > index f7587428febdd2..78ff9b3f1d40c7 100644 > --- a/net/can/j1939/socket.c > +++ b/net/can/j1939/socket.c > @@ -627,14 +627,14 @@ static int j1939_sk_release(struct socket *sock) > return 0; > } > > -static int j1939_sk_setsockopt_flag(struct j1939_sock *jsk, char __user *optval, > +static int j1939_sk_setsockopt_flag(struct j1939_sock *jsk, sockptr_t optval, > unsigned int optlen, int flag) > { > int tmp; > > if (optlen != sizeof(tmp)) > return -EINVAL; > - if (copy_from_user(&tmp, optval, optlen)) > + if (copy_from_sockptr(&tmp, optval, optlen)) > return -EFAULT; > lock_sock(&jsk->sk); > if (tmp) > @@ -646,7 +646,7 @@ static int j1939_sk_setsockopt_flag(struct j1939_sock *jsk, char __user *optval, > } > > static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > struct j1939_sock *jsk = j1939_sk(sk); > @@ -658,7 +658,7 @@ static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, > > switch (optname) { > case SO_J1939_FILTER: > - if (optval) { > + if (!sockptr_is_null(optval)) { > struct j1939_filter *f; > int c; > > @@ -670,7 +670,7 @@ static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, > return -EINVAL; > > count = optlen / sizeof(*filters); > - filters = memdup_user(optval, optlen); > + filters = memdup_sockptr(optval, optlen); > if (IS_ERR(filters)) > return PTR_ERR(filters); > > @@ -703,7 +703,7 @@ static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, > case SO_J1939_SEND_PRIO: > if (optlen != sizeof(tmp)) > return -EINVAL; > - if (copy_from_user(&tmp, optval, optlen)) > + if (copy_from_sockptr(&tmp, optval, optlen)) > return -EFAULT; > if (tmp < 0 || tmp > 7) > return -EDOM; > diff --git a/net/can/raw.c b/net/can/raw.c > index 59c039d73c6d58..94a9405658dc61 100644 > --- a/net/can/raw.c > +++ b/net/can/raw.c > @@ -485,7 +485,7 @@ static int raw_getname(struct socket *sock, struct sockaddr *uaddr, > } > > static int raw_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > struct raw_sock *ro = raw_sk(sk); > @@ -511,11 +511,11 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, > > if (count > 1) { > /* filter does not fit into dfilter => alloc space */ > - filter = memdup_user(optval, optlen); > + filter = memdup_sockptr(optval, optlen); > if (IS_ERR(filter)) > return PTR_ERR(filter); > } else if (count == 1) { > - if (copy_from_user(&sfilter, optval, sizeof(sfilter))) > + if (copy_from_sockptr(&sfilter, optval, sizeof(sfilter))) > return -EFAULT; > } > > @@ -568,7 +568,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, > if (optlen != sizeof(err_mask)) > return -EINVAL; > > - if (copy_from_user(&err_mask, optval, optlen)) > + if (copy_from_sockptr(&err_mask, optval, optlen)) > return -EFAULT; > > err_mask &= CAN_ERR_MASK; > @@ -607,7 +607,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, > if (optlen != sizeof(ro->loopback)) > return -EINVAL; > > - if (copy_from_user(&ro->loopback, optval, optlen)) > + if (copy_from_sockptr(&ro->loopback, optval, optlen)) > return -EFAULT; > > break; > @@ -616,7 +616,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, > if (optlen != sizeof(ro->recv_own_msgs)) > return -EINVAL; > > - if (copy_from_user(&ro->recv_own_msgs, optval, optlen)) > + if (copy_from_sockptr(&ro->recv_own_msgs, optval, optlen)) > return -EFAULT; > > break; > @@ -625,7 +625,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, > if (optlen != sizeof(ro->fd_frames)) > return -EINVAL; > > - if (copy_from_user(&ro->fd_frames, optval, optlen)) > + if (copy_from_sockptr(&ro->fd_frames, optval, optlen)) > return -EFAULT; > > break; > @@ -634,7 +634,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, > if (optlen != sizeof(ro->join_filters)) > return -EINVAL; > > - if (copy_from_user(&ro->join_filters, optval, optlen)) > + if (copy_from_sockptr(&ro->join_filters, optval, optlen)) > return -EFAULT; > > break; > diff --git a/net/core/sock.c b/net/core/sock.c > index 9cf8318bc51de4..ff22629f10ce92 100644 > --- a/net/core/sock.c > +++ b/net/core/sock.c > @@ -3210,7 +3210,7 @@ EXPORT_SYMBOL(sock_common_recvmsg); > * Set socket options on an inet socket. > */ > int sock_common_setsockopt(struct socket *sock, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > > diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h > index 434eea91b7679d..9cc9d1ee6cdb9a 100644 > --- a/net/dccp/dccp.h > +++ b/net/dccp/dccp.h > @@ -295,7 +295,7 @@ int dccp_disconnect(struct sock *sk, int flags); > int dccp_getsockopt(struct sock *sk, int level, int optname, > char __user *optval, int __user *optlen); > int dccp_setsockopt(struct sock *sk, int level, int optname, > - char __user *optval, unsigned int optlen); > + sockptr_t optval, unsigned int optlen); > int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg); > int dccp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size); > int dccp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock, > diff --git a/net/dccp/proto.c b/net/dccp/proto.c > index fd92d3fe321f08..9e58787047f197 100644 > --- a/net/dccp/proto.c > +++ b/net/dccp/proto.c > @@ -402,7 +402,7 @@ int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg) > EXPORT_SYMBOL_GPL(dccp_ioctl); > > static int dccp_setsockopt_service(struct sock *sk, const __be32 service, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct dccp_sock *dp = dccp_sk(sk); > struct dccp_service_list *sl = NULL; > @@ -417,9 +417,9 @@ static int dccp_setsockopt_service(struct sock *sk, const __be32 service, > return -ENOMEM; > > sl->dccpsl_nr = optlen / sizeof(u32) - 1; > - if (copy_from_user(sl->dccpsl_list, > - optval + sizeof(service), > - optlen - sizeof(service)) || > + sockptr_advance(optval, sizeof(service)); > + if (copy_from_sockptr(sl->dccpsl_list, optval, > + optlen - sizeof(service)) || > dccp_list_has_service(sl, DCCP_SERVICE_INVALID_VALUE)) { > kfree(sl); > return -EFAULT; > @@ -473,7 +473,7 @@ static int dccp_setsockopt_cscov(struct sock *sk, int cscov, bool rx) > } > > static int dccp_setsockopt_ccid(struct sock *sk, int type, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > u8 *val; > int rc = 0; > @@ -481,7 +481,7 @@ static int dccp_setsockopt_ccid(struct sock *sk, int type, > if (optlen < 1 || optlen > DCCP_FEAT_MAX_SP_VALS) > return -EINVAL; > > - val = memdup_user(optval, optlen); > + val = memdup_sockptr(optval, optlen); > if (IS_ERR(val)) > return PTR_ERR(val); > > @@ -498,7 +498,7 @@ static int dccp_setsockopt_ccid(struct sock *sk, int type, > } > > static int do_dccp_setsockopt(struct sock *sk, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct dccp_sock *dp = dccp_sk(sk); > int val, err = 0; > @@ -520,7 +520,7 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname, > if (optlen < (int)sizeof(int)) > return -EINVAL; > > - if (get_user(val, (int __user *)optval)) > + if (copy_from_sockptr(&val, optval, sizeof(int))) > return -EFAULT; > > if (optname == DCCP_SOCKOPT_SERVICE) > @@ -563,8 +563,8 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname, > return err; > } > > -int dccp_setsockopt(struct sock *sk, int level, int optname, > - char __user *optval, unsigned int optlen) > +int dccp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, > + unsigned int optlen) > { > if (level != SOL_DCCP) > return inet_csk(sk)->icsk_af_ops->setsockopt(sk, level, > diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c > index 7d51ab608fb3f1..3b53d766789d47 100644 > --- a/net/decnet/af_decnet.c > +++ b/net/decnet/af_decnet.c > @@ -150,7 +150,8 @@ static struct hlist_head dn_sk_hash[DN_SK_HASH_SIZE]; > static struct hlist_head dn_wild_sk; > static atomic_long_t decnet_memory_allocated; > > -static int __dn_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen, int flags); > +static int __dn_setsockopt(struct socket *sock, int level, int optname, > + sockptr_t optval, unsigned int optlen, int flags); > static int __dn_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen, int flags); > > static struct hlist_head *dn_find_list(struct sock *sk) > @@ -1320,7 +1321,8 @@ static int dn_shutdown(struct socket *sock, int how) > return err; > } > > -static int dn_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) > +static int dn_setsockopt(struct socket *sock, int level, int optname, > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = sock->sk; > int err; > @@ -1332,14 +1334,14 @@ static int dn_setsockopt(struct socket *sock, int level, int optname, char __use > /* we need to exclude all possible ENOPROTOOPTs except default case */ > if (err == -ENOPROTOOPT && optname != DSO_LINKINFO && > optname != DSO_STREAM && optname != DSO_SEQPACKET) > - err = nf_setsockopt(sk, PF_DECnet, optname, > - USER_SOCKPTR(optval), optlen); > + err = nf_setsockopt(sk, PF_DECnet, optname, optval, optlen); > #endif > > return err; > } > > -static int __dn_setsockopt(struct socket *sock, int level,int optname, char __user *optval, unsigned int optlen, int flags) > +static int __dn_setsockopt(struct socket *sock, int level, int optname, > + sockptr_t optval, unsigned int optlen, int flags) > { > struct sock *sk = sock->sk; > struct dn_scp *scp = DN_SK(sk); > @@ -1355,13 +1357,13 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us > } u; > int err; > > - if (optlen && !optval) > + if (optlen && sockptr_is_null(optval)) > return -EINVAL; > > if (optlen > sizeof(u)) > return -EINVAL; > > - if (copy_from_user(&u, optval, optlen)) > + if (copy_from_sockptr(&u, optval, optlen)) > return -EFAULT; > > switch (optname) { > diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c > index 94ae9662133e30..a45a0401adc50b 100644 > --- a/net/ieee802154/socket.c > +++ b/net/ieee802154/socket.c > @@ -382,7 +382,7 @@ static int raw_getsockopt(struct sock *sk, int level, int optname, > } > > static int raw_setsockopt(struct sock *sk, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > return -EOPNOTSUPP; > } > @@ -872,7 +872,7 @@ static int dgram_getsockopt(struct sock *sk, int level, int optname, > } > > static int dgram_setsockopt(struct sock *sk, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct dgram_sock *ro = dgram_sk(sk); > struct net *net = sock_net(sk); > @@ -882,7 +882,7 @@ static int dgram_setsockopt(struct sock *sk, int level, int optname, > if (optlen < sizeof(int)) > return -EINVAL; > > - if (get_user(val, (int __user *)optval)) > + if (copy_from_sockptr(&val, optval, sizeof(int))) > return -EFAULT; > For the ieee802154 part: Acked-by: Stefan Schmidt regards Stefan Schmidt Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6A6VFAjbFV+9SQAAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 19:57:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id kE9iEwjbFV96OwAAgupzMw (envelope-from ); Mon, 20 Jul 2020 19:57:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D8B19A1306; Mon, 20 Jul 2020 19:57:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388831AbgGTQhw (ORCPT + 1 other); Mon, 20 Jul 2020 12:37:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:50816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730889AbgGTQhv (ORCPT ); Mon, 20 Jul 2020 12:37:51 -0400 Received: from gmail.com (unknown [104.132.1.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9248320734; Mon, 20 Jul 2020 16:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595263070; bh=smDDaCk04kMr6EUzVkdVBl94CFmKvpleITLelmvA8+8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JJC8sbphJDydEPEmQ9bsAOdVV0pki83XX29vWiTOyf6AsmPXVOTyRrnnrci7D6Bhd g+Lq7h/M7GIp2Q3yjvb33D7hXLYV7+QkF/cJUlgxrp5Jsp6dTPG3ALVp7AD8PFZTTR fVVidPSEdf7dnCSggZDPP0jvSNjJIbQpG4SHFy4k= Date: Mon, 20 Jul 2020 09:37:48 -0700 From: Eric Biggers To: Christoph Hellwig Cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 03/24] net: add a new sockptr_t type Message-ID: <20200720163748.GA1292162@gmail.com> References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-4-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720124737.118617-4-hch@lst.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -6.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: D8B19A1306 X-Rspamd-UID: a13a74 On Mon, Jul 20, 2020 at 02:47:16PM +0200, Christoph Hellwig wrote: > Add a uptr_t type that can hold a pointer to either a user or kernel > memory region, and simply helpers to copy to and from it. For > architectures like x86 that have non-overlapping user and kernel > address space it just is a union and uses a TASK_SIZE check to > select the proper copy routine. For architectures with overlapping > address spaces a flag to indicate the address space is used instead. > > Signed-off-by: Christoph Hellwig > --- > include/linux/sockptr.h | 121 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 121 insertions(+) > create mode 100644 include/linux/sockptr.h > > diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h > new file mode 100644 > index 00000000000000..e41dfa52555dec > --- /dev/null > +++ b/include/linux/sockptr.h > @@ -0,0 +1,121 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright (c) 2020 Christoph Hellwig. > + * > + * Support for "universal" pointers that can point to either kernel or userspace > + * memory. > + */ > +#ifndef _LINUX_SOCKPTR_H > +#define _LINUX_SOCKPTR_H > + > +#include > +#include > + > +#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE > +typedef union { > + void *kernel; > + void __user *user; > +} sockptr_t; > + > +static inline bool sockptr_is_kernel(sockptr_t sockptr) > +{ > + return (unsigned long)sockptr.kernel >= TASK_SIZE; > +} > + > +static inline sockptr_t KERNEL_SOCKPTR(void *p) > +{ > + return (sockptr_t) { .kernel = p }; > +} > +#else /* CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE */ > +typedef struct { > + union { > + void *kernel; > + void __user *user; > + }; > + bool is_kernel : 1; > +} sockptr_t; > + > +static inline bool sockptr_is_kernel(sockptr_t sockptr) > +{ > + return sockptr.is_kernel; > +} > + > +static inline sockptr_t KERNEL_SOCKPTR(void *p) > +{ > + return (sockptr_t) { .kernel = p, .is_kernel = true }; > +} > +#endif /* CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE */ > + > +static inline sockptr_t USER_SOCKPTR(void __user *p) > +{ > + return (sockptr_t) { .user = p }; > +} > + > +static inline bool sockptr_is_null(sockptr_t sockptr) > +{ > + return !sockptr.user && !sockptr.kernel; > +} > + > +static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) > +{ > + if (!sockptr_is_kernel(src)) > + return copy_from_user(dst, src.user, size); > + memcpy(dst, src.kernel, size); > + return 0; > +} How does this not introduce a massive security hole when CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE? AFAICS, userspace can pass in a pointer >= TASK_SIZE, and this code makes it be treated as a kernel pointer. - Eric Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OOauMlrbFV+9SQAAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 19:58:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id MM+/MVrbFV9ttwEA0J78UA (envelope-from ); Mon, 20 Jul 2020 19:58:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C45DBA134A; Mon, 20 Jul 2020 19:58:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389039AbgGTQil (ORCPT + 1 other); Mon, 20 Jul 2020 12:38:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:51538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732718AbgGTQik (ORCPT ); Mon, 20 Jul 2020 12:38:40 -0400 Received: from gmail.com (unknown [104.132.1.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2634122CBB; Mon, 20 Jul 2020 16:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595263119; bh=wlqo7kAx+og7PtKyjy/9X5uYlujAIR96QYTi8/c6yXY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KedFP10soudJd9FGCXk2UQ6mwGYV9FfLgr9Jehpfqo3DeBMYh9Cg2T64ka4vLb/9E yZE0kTEtUh1mwFGolpaTN3qJTAigCNeN60HjhesQSQimi39aadhKkQmY9ZpzWdIGAc DM8CICk2pF95QKtAIcFlAv4SRPp0hIAXO+8S+9xE= Date: Mon, 20 Jul 2020 09:38:36 -0700 From: Eric Biggers To: Christoph Hellwig Cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: get rid of the address_space override in setsockopt Message-ID: <20200720163836.GB1292162@gmail.com> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720124737.118617-1-hch@lst.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.46 / 15.00 / 200.00 X-Rspamd-Queue-Id: C45DBA134A X-Rspamd-UID: 938be9 On Mon, Jul 20, 2020 at 02:47:13PM +0200, Christoph Hellwig wrote: > Hi Dave, > > setsockopt is the last place in architecture-independ code that still > uses set_fs to force the uaccess routines to operate on kernel pointers. > > This series adds a new sockptr_t type that can contained either a kernel > or user pointer, and which has accessors that do the right thing, and > then uses it for setsockopt, starting by refactoring some low-level > helpers and moving them over to it before finally doing the main > setsockopt method. > > Note that I could not get the eBPF selftests to work, so this has been > tested with a testing patch that always copies the data first and passes > a kernel pointer. This is something that works for most common sockopts > (and is something that the ePBF support relies on), but unfortunately > in various corner cases we either don't use the passed in length, or in > one case actually copy data back from setsockopt, so we unfortunately > can't just always do the copy in the highlevel code, which would have > been much nicer. > Please mention what git tree your patchset applies to. - Eric Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UEQXGOSTFV/s0AEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:53:56 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id mLF3FuSTFV/pKAEAgupzMw (envelope-from ); Mon, 20 Jul 2020 14:53:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 283D0A1E62; Mon, 20 Jul 2020 14:53:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728913AbgGTMsU (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728326AbgGTMsS (ORCPT ); Mon, 20 Jul 2020 08:48:18 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 800C6C061794; Mon, 20 Jul 2020 05:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=AjKHhDGZLqL4OuQUXI3ghPRn4d0K9eK+41+WmsKDw4s=; b=k3y37M70YtZbLcMSJtaJ6aJfv6 FlaYELE99elj9mqWglDhPbGX298hMSKaT4Og2bZ6lhxjbZk+9qi4Owp8eOZHyph4qQLu0xwBjeTn4 Q9/6GCGjLDko3UtPSm3rwhrlgfgvxnhol02maJcxiVXjr09qiFP9lNDTpGTa5JKa2H/PtWuT/lUkc R228K4JItBb6gJYS2iIl7C3DtS2UviGLWdNTDJZjCzmn6FlLtFDTsXWMTry+Y6N3gMP8nx+JIg1mr RY/0Hk8eX971yd+wZ8qOKs80pvDVJHmFQ2tMTbzxy4eJ0V9IYGZmkfVXZt1h7xwKh0OLb2gXX5NdS CSgGubQw==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVDA-0004Y9-NY; Mon, 20 Jul 2020 12:48:05 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 09/24] netfilter: remove the unused user argument to do_update_counters Date: Mon, 20 Jul 2020 14:47:22 +0200 Message-Id: <20200720124737.118617-10-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 283D0A1E62 X-Rspamd-UID: 20cdf6 Signed-off-by: Christoph Hellwig --- net/bridge/netfilter/ebtables.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index fe13108af1f542..12f8929667bf43 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1242,9 +1242,8 @@ void ebt_unregister_table(struct net *net, struct ebt_table *table, /* userspace just supplied us with counters */ static int do_update_counters(struct net *net, const char *name, - struct ebt_counter __user *counters, - unsigned int num_counters, - const void __user *user, unsigned int len) + struct ebt_counter __user *counters, + unsigned int num_counters, unsigned int len) { int i, ret; struct ebt_counter *tmp; @@ -1299,7 +1298,7 @@ static int update_counters(struct net *net, const void __user *user, return -EINVAL; return do_update_counters(net, hlp.name, hlp.counters, - hlp.num_counters, user, len); + hlp.num_counters, len); } static inline int ebt_obj_to_user(char __user *um, const char *_name, @@ -2231,7 +2230,7 @@ static int compat_update_counters(struct net *net, void __user *user, return update_counters(net, user, len); return do_update_counters(net, hlp.name, compat_ptr(hlp.counters), - hlp.num_counters, user, len); + hlp.num_counters, len); } static int compat_do_ebt_get_ctl(struct sock *sk, int cmd, -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yGaELlXjFV95hAAAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 20:32:53 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id yEY8LVXjFV8D6wEA0J78UA (envelope-from ); Mon, 20 Jul 2020 20:32:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8A9E5A1911; Mon, 20 Jul 2020 20:32:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729723AbgGTRn3 (ORCPT + 1 other); Mon, 20 Jul 2020 13:43:29 -0400 Received: from verein.lst.de ([213.95.11.211]:48463 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728966AbgGTRn2 (ORCPT ); Mon, 20 Jul 2020 13:43:28 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id ED8356736F; Mon, 20 Jul 2020 19:43:22 +0200 (CEST) Date: Mon, 20 Jul 2020 19:43:22 +0200 From: Christoph Hellwig To: Eric Biggers Cc: Christoph Hellwig , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 03/24] net: add a new sockptr_t type Message-ID: <20200720174322.GA21785@lst.de> References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-4-hch@lst.de> <20200720163748.GA1292162@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720163748.GA1292162@gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8A9E5A1911 X-Rspamd-UID: 6efc58 On Mon, Jul 20, 2020 at 09:37:48AM -0700, Eric Biggers wrote: > How does this not introduce a massive security hole when > CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE? > > AFAICS, userspace can pass in a pointer >= TASK_SIZE, > and this code makes it be treated as a kernel pointer. Yeah, we'll need to validate that before initializing the pointer. But thinking this a little further: doesn't this mean any set_fs(KERNEL_DS) that has other user pointers than the one it is intended for has the same issue? Pretty much all of these are gone in mainline now, but in older stable kernels there might be some interesting cases, especially in the compat ioctl handlers. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6DEaK2HjFV+sYgAAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 20:33:05 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id cFtMKWHjFV+D5AEAlScrYA (envelope-from ); Mon, 20 Jul 2020 20:33:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B7FB5A1B5E; Mon, 20 Jul 2020 20:33:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389154AbgGTRno (ORCPT + 1 other); Mon, 20 Jul 2020 13:43:44 -0400 Received: from verein.lst.de ([213.95.11.211]:48476 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728324AbgGTRno (ORCPT ); Mon, 20 Jul 2020 13:43:44 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 1A82868AFE; Mon, 20 Jul 2020 19:43:39 +0200 (CEST) Date: Mon, 20 Jul 2020 19:43:38 +0200 From: Christoph Hellwig To: Eric Biggers Cc: Christoph Hellwig , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: get rid of the address_space override in setsockopt Message-ID: <20200720174338.GB21785@lst.de> References: <20200720124737.118617-1-hch@lst.de> <20200720163836.GB1292162@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720163836.GB1292162@gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: B7FB5A1B5E X-Rspamd-UID: e1559c On Mon, Jul 20, 2020 at 09:38:36AM -0700, Eric Biggers wrote: > Please mention what git tree your patchset applies to. net-next/master Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yLt0FszjFV+sYgAAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 20:34:52 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0CoOFczjFV/ENgAAlp8NpQ (envelope-from ); Mon, 20 Jul 2020 20:34:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4744BA1664; Mon, 20 Jul 2020 20:34:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729123AbgGTRzr (ORCPT + 1 other); Mon, 20 Jul 2020 13:55:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:56244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726486AbgGTRzq (ORCPT ); Mon, 20 Jul 2020 13:55:46 -0400 Received: from gmail.com (unknown [104.132.1.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D81D920709; Mon, 20 Jul 2020 17:55:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595267745; bh=gKIze89vWBzrFx6zTW6q8+6OGOi2eEHSp9M1U5xgK5Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IVyIlrMN24MPKjy4d8SMWaW7uCiUcpLg3yjCC0C2S6ZfKpknKzmS2DwkqaZUR6kcj eH3tVcf8T0FWz3MgsFZPKw/95GZuUU1R6RXP6YgHYNC1Xrh1jm83A8jQXDelAkEKiB ufMchI7Ce61Y9ZnRUJK/bZ/+BU6OKViPemeOOMWQ= Date: Mon, 20 Jul 2020 10:55:43 -0700 From: Eric Biggers To: Christoph Hellwig Cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 03/24] net: add a new sockptr_t type Message-ID: <20200720175543.GF1292162@gmail.com> References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-4-hch@lst.de> <20200720163748.GA1292162@gmail.com> <20200720174322.GA21785@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720174322.GA21785@lst.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4744BA1664 X-Rspamd-UID: d99b6b On Mon, Jul 20, 2020 at 07:43:22PM +0200, Christoph Hellwig wrote: > On Mon, Jul 20, 2020 at 09:37:48AM -0700, Eric Biggers wrote: > > How does this not introduce a massive security hole when > > CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE? > > > > AFAICS, userspace can pass in a pointer >= TASK_SIZE, > > and this code makes it be treated as a kernel pointer. > > Yeah, we'll need to validate that before initializing the pointer. > > But thinking this a little further: doesn't this mean any > set_fs(KERNEL_DS) that has other user pointers than the one it is > intended for has the same issue? Pretty much all of these are gone > in mainline now, but in older stable kernels there might be some > interesting cases, especially in the compat ioctl handlers. Yes. I thought that eliminating that class of bug is one of the main motivations for your "remove set_fs" work. See commit 128394eff343 ("sg_write()/bsg_write() is not fit to be called under KERNEL_DS") for a case where this type of bug was fixed. Are you aware of any specific cases that weren't already fixed? If there are any, they need to be urgently fixed. - Eric Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qO3tIeD3FV8BBwEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 22:00:32 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gPbCIOD3FV/ToQAAgupzMw (envelope-from ); Mon, 20 Jul 2020 22:00:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 78889A193B; Mon, 20 Jul 2020 22:00:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731117AbgGTUAW (ORCPT + 1 other); Mon, 20 Jul 2020 16:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726095AbgGTUAV (ORCPT ); Mon, 20 Jul 2020 16:00:21 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B82CCC061794 for ; Mon, 20 Jul 2020 13:00:21 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id d4so13237126otk.2 for ; Mon, 20 Jul 2020 13:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xsxQnXTkDVwEn2yORiSe88zGHIEKrGVneUBiXY4K0PY=; b=C7VQ60S8+/zm3V+ddFjdF5hfdUHSEIWgEOzDfzyTduJLZae7IecfY55q71QBn0ugwK TDffYAIRbMJdOmDwH0hqIGZiomqwaTwKVWI+F50YQMC+Qn4ID5A8K5SKdg3txuwTejf9 wHe8n1Ew4Wj88kqEf9k16ybs0QzbWs0GemW2twy+ReKaQ3IVu23aLr43FR6qKGL8kcqt zMoobyQFNnONm4I1QUBPAcjsN34YpSBcOVi8nHclVdBDyUK5nJlt97A/268CuhC5RL/x DaIsK/bp0RA7UzuqneqRVDlt2ot1sjrRd5TzFz0eklnYi8bQJx9mnzagRGZ3tveteyTo /hTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xsxQnXTkDVwEn2yORiSe88zGHIEKrGVneUBiXY4K0PY=; b=U7Dvndvh1jJfyMc79jAEEMZjeuZ0gjOyRKHtp7i6T5Zn2aUkfAqGsGjQrIUmaedEc2 9QuPalYcQSkO/ETmMhyYH0bH6D7BdUSVXqcxIjkUylLyeuofTQOfpLpybWVzt+pgU11O fD181dWUEUwq/rMNf2oCYxW2ff+Gctw8LaZGm7GTYmrId+GC2I1gEf6YS95Zz4i+k8tB d5Z+LGWUL7XHmcVSY89bemPo9RXL0cOZkbtZZjgl0p7VNJ41842fBb3rBDgu3F+2TqHs yDYCWZ/FplYMnyYftsNWsbmyqCKqarvGdyA6iRTnYMbeph9t0vrQcl/J5f/ohXr3noLv jNLQ== X-Gm-Message-State: AOAM530QtSPvfaXJqrRaYomIoZM2ilSRI6wj4sJ7IYe6nQIJ9FQkxevU pbBles/YJGVbV8gkST5WW7iXhMLc2dJj/1XW878= X-Google-Smtp-Source: ABdhPJxoOkpinX4uGwK+saiucfaF8NNALFwIf8W8zAbEy4shWl61kmgbXt7SszDjy9ATepBss/TEFE7NRBqBZBu3fUw= X-Received: by 2002:a9d:68d1:: with SMTP id i17mr20967711oto.182.1595275220569; Mon, 20 Jul 2020 13:00:20 -0700 (PDT) MIME-Version: 1.0 References: <20200711115031.123793-1-marijns95@gmail.com> In-Reply-To: From: Marijn Suijten Date: Mon, 20 Jul 2020 22:00:07 +0200 Message-ID: Subject: Re: [PATCH BlueZ] audio/avrcp: Always update transport volume regardless of player To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 78889A193B X-Rspamd-UID: 166023 Hi Luiz, On Tue, 14 Jul 2020 at 02:06, Luiz Augusto von Dentz wrote: > > Hi Marijn, > > On Mon, Jul 13, 2020 at 5:05 PM Luiz Augusto von Dentz > wrote: > > > > Hi Marijn, > > > > On Sat, Jul 11, 2020 at 4:50 AM Marijn Suijten wrote: > > > > > > `Volume` is a special property that not only exists on players but also > > > on the transport (see org.bluez.MediaTransport1). A player is not > > > attached when the controller does not support FEATURE_CATEGORY_1, which > > > is common on headphones without media browsing capabilities. > > > > > > On such audio devices (headphones, in-ears and the like) Absolute Volume > > > is not available unless an external player is registered > > > (org.bluez.Media1.RegisterPlayer) and the device sends a volume event > > > back after that to set a2dp->volume in transport.c to a valid value > > > (causing volume_exists to finally return true). > > > > > > This [1] mail thread denoting the same issue has a solution to at least > > > request capabilities from the controller, but the proposed player object > > > is not created on category 2 devices. Any notifications received on > > > AVRCP_EVENT_VOLUME_CHANGED (avrcp_volume_changed) that is subsequently > > > registered, or handling the result of avrcp_set_volume in > > > avrcp_handle_set_volume will be ignored unless said player is present. > > > > > > This issue is not addressed by adding a fake player but instead dealing > > > with the fact that volume is "special" and available on the transport > > > regardless of the existence of a player. This is confirmed in > > > avrcp_get_capabilities_resp as well which requires a player to register > > > any event except AVRCP_EVENT_VOLUME_CHANGED. > > > > > > The applied solution moves media_transport_update_device_volume out of > > > the player and into avrcp_volume_changed/avrcp_handle_set_volume where > > > it is unconditionally called. These functions are the only users of > > > avrcp_player->set_volume. > > > > > > Note that the volume member of media_player is never used which seems a > > > result of updating from org.bluez.MediaPlayer1 to > > > org.mpris.MediaPlayer2.Player in > > > 15e421737ccc4696ed567edcc24d178aedb47854, where the volume property [2] > > > is left out. > > > > This is actually on purpose since the volume notification indicates > > the volume at the device side we don't want to change the player > > volume as well as it would most likely result in duplicating the > > volume change both at sink and source, note that the likes of handling > > the transport like pulseaudio would already notify the device volume > > level change without actually applying any change to the volume > > locally. I might have wrongfully assumed that a player registers a MediaPlayer2 with BlueZ to stay in sync with the playback endpoint, including Volume. In which case the application should be aware that attenuation is applied at the sink (hence not feasible). The other way around mpris-proxy "re-exports" the transport volume over the MediaPlayer2 interface. As for pulseaudio it currently doesn't do anything with the transport volume and always applies attenuation based on a local gain. My attempt to change that [1] is what ended up in submitting this patch to make it possible. > > > [1]: https://marc.info/?l=linux-bluetooth&m=145337574806153 > > > [2]: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Volume > > > > > > --- > > > Hi, > > > > > > This is is a resend from an earlier mail that didn't comply with the > > > contributor guidelines. Seeing that the topic of AVRCP volume is brought > > > up recently it is about time to repair it and hereby send it again. > > > > > > I still have an incomplete patch lying around that synchronizes Volume > > > on org.mpris.MediaPlayer2.Player back when this patch was written 6 > > > months ago. It'll require some time to get back in to it and finalize > > > it, let me know if that's desired. > > > > > > - Marijn Suijten > > > > > > profiles/audio/avrcp.c | 12 ++++++++---- > > > profiles/audio/media.c | 16 ---------------- > > > 2 files changed, 8 insertions(+), 20 deletions(-) > > > > > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > > > index e2428250e..8370c8a44 100644 > > > --- a/profiles/audio/avrcp.c > > > +++ b/profiles/audio/avrcp.c > > > @@ -3625,12 +3625,13 @@ static void avrcp_volume_changed(struct avrcp *session, > > > struct avrcp_player *player = target_get_player(session); > > > uint8_t volume; > > > > > > - if (!player) > > > - return; > > > - > > > volume = pdu->params[1] & 0x7F; > > > > > > - player->cb->set_volume(volume, session->dev, player->user_data); > > > + /* Always update the transport volume, which is separate from the player */ > > > + media_transport_update_device_volume(session->dev, volume); > > > + > > > + if (player) > > > + player->cb->set_volume(volume, session->dev, player->user_data); > > > } > > > > > > static void avrcp_status_changed(struct avrcp *session, > > > @@ -4378,6 +4379,9 @@ static gboolean avrcp_handle_set_volume(struct avctp *conn, uint8_t code, > > > > > > volume = pdu->params[0] & 0x7F; > > > > > > + /* Always update the transport volume, which is separate from the player */ > > > + media_transport_update_device_volume(session->dev, volume); > > > + > > > if (player != NULL) > > > player->cb->set_volume(volume, session->dev, player->user_data); > > > > > > diff --git a/profiles/audio/media.c b/profiles/audio/media.c > > > index 993ecb3b3..a0173fdd4 100644 > > > --- a/profiles/audio/media.c > > > +++ b/profiles/audio/media.c > > > @@ -1202,27 +1202,11 @@ static uint32_t get_duration(void *user_data) > > > static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) > > > { > > > struct media_player *mp = user_data; > > > - GSList *l; > > > > > > if (mp->volume == volume) > > > return; > > > > > > mp->volume = volume; > > > - > > > - for (l = mp->adapter->endpoints; l; l = l->next) { > > > - struct media_endpoint *endpoint = l->data; > > > - struct media_transport *transport; > > > - > > > - /* Volume is A2DP only */ > > > - if (endpoint->sep == NULL) > > > - continue; > > > - > > > - transport = find_device_transport(endpoint, dev); > > > - if (transport == NULL) > > > - continue; > > > - > > > - media_transport_update_volume(transport, volume); > > > - } > > > } > > > > > > static bool media_player_send(struct media_player *mp, const char *name) > > > -- > > > 2.27.0 > > > > > Applied, Thanks. Note that I did fix some coding style problems. Thanks, I wasn't sure about submitting a v2 to merely trim the comments or remove them altogether. Note that the link to the mail thread referenced with `[1]` inadvertently disappeared too. > -- > Luiz Augusto von Dentz - Marijn [1]: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/239 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SOdpB6YBFl+8TQEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 22:42:14 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id SJ/+BaYBFl/lVgAA0J78UA (envelope-from ); Mon, 20 Jul 2020 22:42:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B5EE440676; Mon, 20 Jul 2020 22:42:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728001AbgGTUmI (ORCPT + 1 other); Mon, 20 Jul 2020 16:42:08 -0400 Received: from mga18.intel.com ([134.134.136.126]:45380 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726046AbgGTUmH (ORCPT ); Mon, 20 Jul 2020 16:42:07 -0400 IronPort-SDR: ij/qqMOazJTzpOx8VIIzOGMDCMohGB72QcdslAAmapablGsG8hFsHSDH+f6WE9eb1fHY3QjL05 V6QAz4vQpK8A== X-IronPort-AV: E=McAfee;i="6000,8403,9688"; a="137492271" X-IronPort-AV: E=Sophos;i="5.75,375,1589266800"; d="scan'208";a="137492271" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 13:42:07 -0700 IronPort-SDR: I6Vr1MJopZ4DUVQohuhuZLU1t6WKGK6fnBdJurZJ4XZtfYgrhu34zKfTFmcsGttfFmJccbfBdD CB+DNOCsKXiw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,375,1589266800"; d="scan'208";a="283636787" Received: from aukiwe-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.77.52]) by orsmga003.jf.intel.com with ESMTP; 20 Jul 2020 13:42:07 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ] tools/mesh-cfgclient: Fix segfault on remote node reset Date: Mon, 20 Jul 2020 13:42:06 -0700 Message-Id: <20200720204206.226761-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 18 X-Rspamd-Score: 2.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: B5EE440676 X-Rspamd-UID: 1eb9d0 This fixes a segfault that is caused by freeeing non-allocated memory. Happens upon the removal of a remote node when remote's net key and/or app key queues are destroyed. __GI___libc_free (mem=0x1) at malloc.c:3102 destroy=destroy@entry=0x55761f63a3b0 ) at ell/queue.c:107 destroy=destroy@entry=0x55761f63a3b0 ) at ell/queue.c:82 at tools/mesh/remote.c:140 at tools/mesh/cfgcli.c:764 at tools/mesh/cfgcli.c:764 msg=0x5576213aa6f0, user_data=) at tools/mesh-cfgclient.c:1522 dbus=dbus@entry=0x55762132f860, message=message@entry=0x5576213aa6f0) at ell/dbus-service.c:1793 user_data=0x55762132f860) at ell/dbus.c:285 user_data=0x55762132f940) at ell/io.c:126 --- tools/mesh/remote.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/mesh/remote.c b/tools/mesh/remote.c index 2a8f747d6..c74f0bec1 100644 --- a/tools/mesh/remote.c +++ b/tools/mesh/remote.c @@ -134,10 +134,11 @@ uint8_t remote_del_node(uint16_t unicast) l_queue_destroy(rmt->els[i], NULL); remote_add_blacklisted_address(unicast + i, iv_index, true); } + l_free(rmt->els); - l_queue_destroy(rmt->net_keys, l_free); - l_queue_destroy(rmt->app_keys, l_free); + l_queue_destroy(rmt->net_keys, NULL); + l_queue_destroy(rmt->app_keys, NULL); l_free(rmt); mesh_db_del_node(unicast); -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sCJyM+qTFV+c4QEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:54:02 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MJfyMeqTFV9/LQEAgupzMw (envelope-from ); Mon, 20 Jul 2020 14:54:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 38DFDA1911; Mon, 20 Jul 2020 14:53:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728899AbgGTMsT (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728874AbgGTMsP (ORCPT ); Mon, 20 Jul 2020 08:48:15 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCD61C0619D2; Mon, 20 Jul 2020 05:48:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=VrJsDbKvFjfbSXAuB6qr8lwEWZVDG/rFKzbYqdXTQsw=; b=YLVw7zkAKjTv3IGYFSz+Y5hnjy Mvg5nzJe+f6RLbr17FreulcNlPa/3tva7Hcq4TnkiegyTM7VB07RS3DW/f7M4kny34j81uZj0lqE9 1WZMmlhCDNNPD2CeOV0XtKV0xTg00HWidTw7ryT5sxt2ZTMTiflfU1O8hCH320Rv1IbXtilvlOqva FND0AMDpxmiYWtSsupQow/oRZIWPBKol1iCO4x/tsZbmXGvRBcMWh+wnQBolSEWlrhOb9lSnLAAgU T9tPf5mRSDzGq0T8A/H8wC3NGjD4LqqqNH9SAHJ6FNqb3Kv2r3OsODXHdi4ep6fnIUSDRPs2oMz4f Gong/w1g==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVD7-0004Xu-UL; Mon, 20 Jul 2020 12:48:03 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 08/24] net/xfrm: switch xfrm_user_policy to sockptr_t Date: Mon, 20 Jul 2020 14:47:21 +0200 Message-Id: <20200720124737.118617-9-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 38DFDA1911 X-Rspamd-UID: b18ea1 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/net/xfrm.h | 8 +++++--- net/ipv4/ip_sockglue.c | 3 ++- net/ipv6/ipv6_sockglue.c | 3 ++- net/xfrm/xfrm_state.c | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index f9e1fda82ddfc0..5e81868b574a73 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -1609,10 +1610,11 @@ int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, void xfrm6_local_rxpmtu(struct sk_buff *skb, u32 mtu); int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); int xfrm6_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); -int xfrm_user_policy(struct sock *sk, int optname, - u8 __user *optval, int optlen); +int xfrm_user_policy(struct sock *sk, int optname, sockptr_t optval, + int optlen); #else -static inline int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen) +static inline int xfrm_user_policy(struct sock *sk, int optname, + sockptr_t optval, int optlen) { return -ENOPROTOOPT; } diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index a5ea02d7a183eb..da933f99b5d517 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1322,7 +1322,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, err = -EPERM; if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) break; - err = xfrm_user_policy(sk, optname, optval, optlen); + err = xfrm_user_policy(sk, optname, USER_SOCKPTR(optval), + optlen); break; case IP_TRANSPARENT: diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index add8f791229945..56a74707c61741 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -935,7 +935,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, retv = -EPERM; if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) break; - retv = xfrm_user_policy(sk, optname, optval, optlen); + retv = xfrm_user_policy(sk, optname, USER_SOCKPTR(optval), + optlen); break; case IPV6_ADDR_PREFERENCES: diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 8be2d926acc21d..69520ad3d83bfb 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -2264,7 +2264,7 @@ static bool km_is_alive(const struct km_event *c) return is_alive; } -int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen) +int xfrm_user_policy(struct sock *sk, int optname, sockptr_t optval, int optlen) { int err; u8 *data; @@ -2274,7 +2274,7 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen if (in_compat_syscall()) return -EOPNOTSUPP; - if (!optval && !optlen) { + if (sockptr_is_null(optval) && !optlen) { xfrm_sk_policy_insert(sk, XFRM_POLICY_IN, NULL); xfrm_sk_policy_insert(sk, XFRM_POLICY_OUT, NULL); __sk_dst_reset(sk); @@ -2284,7 +2284,7 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen if (optlen <= 0 || optlen > PAGE_SIZE) return -EMSGSIZE; - data = memdup_user(optval, optlen); + data = memdup_sockptr(optval, optlen); if (IS_ERR(data)) return PTR_ERR(data); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AOGxOvqTFV/s0AEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:54:18 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 2J8/OfqTFV9LrgAA0J78UA (envelope-from ); Mon, 20 Jul 2020 14:54:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4D708A1911; Mon, 20 Jul 2020 14:54:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729209AbgGTMvl (ORCPT + 1 other); Mon, 20 Jul 2020 08:51:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728074AbgGTMsO (ORCPT ); Mon, 20 Jul 2020 08:48:14 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAC52C061794; Mon, 20 Jul 2020 05:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=hs9nFYNbsiTuomEFW34Dm2rpOGJinL2S6O7KpsAcjME=; b=BBUuvJzBpBC1aFyeauCvglQq8E P5vbTaYJrzOfSVzV+SnJRcTwCUYxG4LLKMglWHnZPFl2XzAnXhasz+8O8V4/wM8oVj2zhW/9O1+qZ hmf4RhbXBF5UaoXK2YWIDefTrbZTJ6fLFJ2SwmMOzYkT/XKWIiv80if02d+k3RWh3VYotpm3hna49 lefSoaeUyLwuYQGuHzhU9GiWeklaIMyjmuGpBKAdiFpdk7xOmG9puBEoym1BV0/rPgqn2GZLkJJVy j1+mmHWSYRaL4KreN8pZa8tqW6AzjeLOsrQRC4/C8nBrCRn4k0JnDb6Cq/EnirnC6aihy0mJk0wBk f6Osp7Og==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVD5-0004Xj-Ih; Mon, 20 Jul 2020 12:48:00 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 07/24] net: switch sock_set_timeout to sockptr_t Date: Mon, 20 Jul 2020 14:47:20 +0200 Message-Id: <20200720124737.118617-8-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4D708A1911 X-Rspamd-UID: 452130 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/net/sock.h | 3 ++- net/core/sock.c | 26 ++++++++++++-------------- net/mptcp/protocol.c | 6 ++++-- net/socket.c | 3 ++- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index 62e18fc8ac9f96..bfb2fe2fc36876 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -59,6 +59,7 @@ #include #include #include +#include #include #include @@ -1669,7 +1670,7 @@ void sock_pfree(struct sk_buff *skb); #endif int sock_setsockopt(struct socket *sock, int level, int op, - char __user *optval, unsigned int optlen); + sockptr_t optval, unsigned int optlen); int sock_getsockopt(struct socket *sock, int level, int op, char __user *optval, int __user *optlen); diff --git a/net/core/sock.c b/net/core/sock.c index d45bb1c2c36abf..9cf8318bc51de4 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -825,7 +825,7 @@ EXPORT_SYMBOL(sock_set_rcvbuf); */ int sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock_txtime sk_txtime; struct sock *sk = sock->sk; @@ -839,12 +839,12 @@ int sock_setsockopt(struct socket *sock, int level, int optname, */ if (optname == SO_BINDTODEVICE) - return sock_setbindtodevice(sk, USER_SOCKPTR(optval), optlen); + return sock_setbindtodevice(sk, optval, optlen); if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; valbool = val ? 1 : 0; @@ -957,7 +957,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, ret = -EINVAL; /* 1003.1g */ break; } - if (copy_from_user(&ling, optval, sizeof(ling))) { + if (copy_from_sockptr(&ling, optval, sizeof(ling))) { ret = -EFAULT; break; } @@ -1051,21 +1051,20 @@ int sock_setsockopt(struct socket *sock, int level, int optname, case SO_RCVTIMEO_OLD: case SO_RCVTIMEO_NEW: - ret = sock_set_timeout(&sk->sk_rcvtimeo, USER_SOCKPTR(optval), + ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen, optname == SO_RCVTIMEO_OLD); break; case SO_SNDTIMEO_OLD: case SO_SNDTIMEO_NEW: - ret = sock_set_timeout(&sk->sk_sndtimeo, USER_SOCKPTR(optval), + ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen, optname == SO_SNDTIMEO_OLD); break; case SO_ATTACH_FILTER: { struct sock_fprog fprog; - ret = copy_bpf_fprog_from_user(&fprog, USER_SOCKPTR(optval), - optlen); + ret = copy_bpf_fprog_from_user(&fprog, optval, optlen); if (!ret) ret = sk_attach_filter(&fprog, sk); break; @@ -1076,7 +1075,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, u32 ufd; ret = -EFAULT; - if (copy_from_user(&ufd, optval, sizeof(ufd))) + if (copy_from_sockptr(&ufd, optval, sizeof(ufd))) break; ret = sk_attach_bpf(ufd, sk); @@ -1086,8 +1085,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, case SO_ATTACH_REUSEPORT_CBPF: { struct sock_fprog fprog; - ret = copy_bpf_fprog_from_user(&fprog, USER_SOCKPTR(optval), - optlen); + ret = copy_bpf_fprog_from_user(&fprog, optval, optlen); if (!ret) ret = sk_reuseport_attach_filter(&fprog, sk); break; @@ -1098,7 +1096,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, u32 ufd; ret = -EFAULT; - if (copy_from_user(&ufd, optval, sizeof(ufd))) + if (copy_from_sockptr(&ufd, optval, sizeof(ufd))) break; ret = sk_reuseport_attach_bpf(ufd, sk); @@ -1178,7 +1176,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, if (sizeof(ulval) != sizeof(val) && optlen >= sizeof(ulval) && - get_user(ulval, (unsigned long __user *)optval)) { + copy_from_sockptr(&ulval, optval, sizeof(ulval))) { ret = -EFAULT; break; } @@ -1221,7 +1219,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(struct sock_txtime)) { ret = -EINVAL; break; - } else if (copy_from_user(&sk_txtime, optval, + } else if (copy_from_sockptr(&sk_txtime, optval, sizeof(struct sock_txtime))) { ret = -EFAULT; break; diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index f0b0b503c2628d..27b6f250b87dfd 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1643,7 +1643,8 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, return -EINVAL; } - ret = sock_setsockopt(ssock, SOL_SOCKET, optname, optval, optlen); + ret = sock_setsockopt(ssock, SOL_SOCKET, optname, + USER_SOCKPTR(optval), optlen); if (ret == 0) { if (optname == SO_REUSEPORT) sk->sk_reuseport = ssock->sk->sk_reuseport; @@ -1654,7 +1655,8 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, return ret; } - return sock_setsockopt(sk->sk_socket, SOL_SOCKET, optname, optval, optlen); + return sock_setsockopt(sk->sk_socket, SOL_SOCKET, optname, + USER_SOCKPTR(optval), optlen); } static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, diff --git a/net/socket.c b/net/socket.c index 93846568c2fb7a..c97f83d879ae75 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2130,7 +2130,8 @@ int __sys_setsockopt(int fd, int level, int optname, char __user *optval, } if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) - err = sock_setsockopt(sock, level, optname, optval, optlen); + err = sock_setsockopt(sock, level, optname, + USER_SOCKPTR(optval), optlen); else if (unlikely(!sock->ops->setsockopt)) err = -EOPNOTSUPP; else -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GKldBCCUFV/s0AEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:54:56 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id aFGtAiCUFV95qAAAlScrYA (envelope-from ); Mon, 20 Jul 2020 14:54:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6884DA2637; Mon, 20 Jul 2020 14:54:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728828AbgGTMsM (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728590AbgGTMsJ (ORCPT ); Mon, 20 Jul 2020 08:48:09 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F818C0619D5; Mon, 20 Jul 2020 05:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=sKdt4hAbq/6qTa3tcNwXdqjggNwHsw7uOZ08Rf6czhk=; b=f5LLAO7/F+nm+9Gl7hfXp/Kox6 sXYuhXb2vkgDyYkwVEurXeRexxngk9Z2EHCb20Vm6cwQC0KkAdtVybwIWUYKPlRMRbsnYlZua+VzZ Flsm7I6zi4O+te18djow1qkD4y6zW7eB+vdqOWXQqe40sAYXmcza0z+HCA79DX9OmZGLOhLwGhUFN CkZ0dvcn3v1XJU220Xc46sbrIANYMzqY/4cDFUBrys3agNAh/rnUNwi19G0yCy4iST/MAWBuDJTgy eAg7vhunPFR2F7DJnQOtye3bthglFnmml2ORTej2iPJzY9HBiUQo5UMJaII7PCL4D2XJQPwFgvOnM oJ/gmolA==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVCl-0004WH-1J; Mon, 20 Jul 2020 12:47:39 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: get rid of the address_space override in setsockopt Date: Mon, 20 Jul 2020 14:47:13 +0200 Message-Id: <20200720124737.118617-1-hch@lst.de> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6884DA2637 X-Rspamd-UID: 34a8f1 Hi Dave, setsockopt is the last place in architecture-independ code that still uses set_fs to force the uaccess routines to operate on kernel pointers. This series adds a new sockptr_t type that can contained either a kernel or user pointer, and which has accessors that do the right thing, and then uses it for setsockopt, starting by refactoring some low-level helpers and moving them over to it before finally doing the main setsockopt method. Note that I could not get the eBPF selftests to work, so this has been tested with a testing patch that always copies the data first and passes a kernel pointer. This is something that works for most common sockopts (and is something that the ePBF support relies on), but unfortunately in various corner cases we either don't use the passed in length, or in one case actually copy data back from setsockopt, so we unfortunately can't just always do the copy in the highlevel code, which would have been much nicer. Diffstt: crypto/af_alg.c | 7 drivers/crypto/chelsio/chtls/chtls_main.c | 18 - drivers/isdn/mISDN/socket.c | 4 include/linux/bpfilter.h | 6 include/linux/filter.h | 3 include/linux/mroute.h | 5 include/linux/mroute6.h | 8 include/linux/net.h | 4 include/linux/netfilter.h | 6 include/linux/netfilter/x_tables.h | 4 include/linux/sockptr.h | 121 +++++++++++ include/net/inet_connection_sock.h | 3 include/net/ip.h | 7 include/net/ipv6.h | 6 include/net/sctp/structs.h | 2 include/net/sock.h | 7 include/net/tcp.h | 6 include/net/udp.h | 2 include/net/xfrm.h | 8 net/atm/common.c | 6 net/atm/common.h | 2 net/atm/pvc.c | 2 net/atm/svc.c | 6 net/ax25/af_ax25.c | 6 net/bluetooth/hci_sock.c | 8 net/bluetooth/l2cap_sock.c | 22 +- net/bluetooth/rfcomm/sock.c | 12 - net/bluetooth/sco.c | 6 net/bpfilter/bpfilter_kern.c | 11 - net/bridge/netfilter/ebtables.c | 46 +--- net/caif/caif_socket.c | 8 net/can/j1939/socket.c | 12 - net/can/raw.c | 16 - net/core/filter.c | 6 net/core/sock.c | 36 +-- net/dccp/dccp.h | 2 net/dccp/proto.c | 20 - net/decnet/af_decnet.c | 13 - net/ieee802154/socket.c | 6 net/ipv4/bpfilter/sockopt.c | 8 net/ipv4/ip_options.c | 43 +--- net/ipv4/ip_sockglue.c | 66 +++--- net/ipv4/ipmr.c | 14 - net/ipv4/netfilter/arp_tables.c | 33 +-- net/ipv4/netfilter/ip_tables.c | 29 +- net/ipv4/raw.c | 8 net/ipv4/tcp.c | 30 +- net/ipv4/tcp_ipv4.c | 4 net/ipv4/udp.c | 11 - net/ipv4/udp_impl.h | 4 net/ipv6/ip6_flowlabel.c | 317 ++++++++++++++++-------------- net/ipv6/ip6mr.c | 17 - net/ipv6/ipv6_sockglue.c | 203 +++++++++---------- net/ipv6/netfilter/ip6_tables.c | 28 +- net/ipv6/raw.c | 10 net/ipv6/tcp_ipv6.c | 4 net/ipv6/udp.c | 7 net/ipv6/udp_impl.h | 4 net/iucv/af_iucv.c | 4 net/kcm/kcmsock.c | 6 net/l2tp/l2tp_ppp.c | 4 net/llc/af_llc.c | 4 net/mptcp/protocol.c | 12 - net/netfilter/ipvs/ip_vs_ctl.c | 4 net/netfilter/nf_sockopt.c | 2 net/netfilter/x_tables.c | 20 - net/netlink/af_netlink.c | 4 net/netrom/af_netrom.c | 4 net/nfc/llcp_sock.c | 6 net/packet/af_packet.c | 39 +-- net/phonet/pep.c | 4 net/rds/af_rds.c | 30 +- net/rds/rdma.c | 14 - net/rds/rds.h | 6 net/rose/af_rose.c | 4 net/rxrpc/af_rxrpc.c | 8 net/rxrpc/ar-internal.h | 4 net/rxrpc/key.c | 9 net/sctp/socket.c | 4 net/smc/af_smc.c | 4 net/socket.c | 20 - net/tipc/socket.c | 8 net/tls/tls_main.c | 17 - net/vmw_vsock/af_vsock.c | 4 net/x25/af_x25.c | 4 net/xdp/xsk.c | 8 net/xfrm/xfrm_state.c | 6 87 files changed, 855 insertions(+), 721 deletions(-) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OIf8OTmUFV9rrwEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:55:21 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id cPHZNzmUFV99qAAAlScrYA (envelope-from ); Mon, 20 Jul 2020 14:55:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6E7B5A21B1; Mon, 20 Jul 2020 14:55:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729126AbgGTMwK (ORCPT + 1 other); Mon, 20 Jul 2020 08:52:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728816AbgGTMsL (ORCPT ); Mon, 20 Jul 2020 08:48:11 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23789C061794; Mon, 20 Jul 2020 05:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=sgYWyMfm87Lwp87OiHiXBGeztL7pp9vtxgWCGygwlyQ=; b=ohlAv+VYwEBD8MZ2GI6LDCZyTj +2dygLPuHwB4q01kC05RSq3Dr+sPFXczHgi0nOgfC+b4SmHYTZerQFRXvPa1y1h6Sb7yBJMpgPxPj bIHqMKdY+yDXM0FeLNQFGLH3ZmDZd56XNZ3dvQL19CJPxySpKLErEfzKmf8uwwXZkotGjvEn82DsQ Rlao5M7ezXGmItEie2BE4Bm1hJ+YyoD/PaGZSNZTz+x5KM+oXsP+ygCRk2ia3dvcXL43IdfFFl00j Is5pnhTz2uV8XvZlYuMUCO8iRi6faULVlv2d0g7DJVpQ/ayBLUp13B2uyjGIPQdVR/lCd8rsoQmNG KqzoRfXQ==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVD3-0004XQ-2H; Mon, 20 Jul 2020 12:47:58 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 06/24] net: switch sock_set_timeout to sockptr_t Date: Mon, 20 Jul 2020 14:47:19 +0200 Message-Id: <20200720124737.118617-7-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6E7B5A21B1 X-Rspamd-UID: c07bfb Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- net/core/sock.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index bd20fc5cce0850..d45bb1c2c36abf 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -360,7 +360,8 @@ static int sock_get_timeout(long timeo, void *optval, bool old_timeval) return sizeof(tv); } -static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool old_timeval) +static int sock_set_timeout(long *timeo_p, sockptr_t optval, int optlen, + bool old_timeval) { struct __kernel_sock_timeval tv; @@ -370,7 +371,7 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool if (optlen < sizeof(tv32)) return -EINVAL; - if (copy_from_user(&tv32, optval, sizeof(tv32))) + if (copy_from_sockptr(&tv32, optval, sizeof(tv32))) return -EFAULT; tv.tv_sec = tv32.tv_sec; tv.tv_usec = tv32.tv_usec; @@ -379,14 +380,14 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool if (optlen < sizeof(old_tv)) return -EINVAL; - if (copy_from_user(&old_tv, optval, sizeof(old_tv))) + if (copy_from_sockptr(&old_tv, optval, sizeof(old_tv))) return -EFAULT; tv.tv_sec = old_tv.tv_sec; tv.tv_usec = old_tv.tv_usec; } else { if (optlen < sizeof(tv)) return -EINVAL; - if (copy_from_user(&tv, optval, sizeof(tv))) + if (copy_from_sockptr(&tv, optval, sizeof(tv))) return -EFAULT; } if (tv.tv_usec < 0 || tv.tv_usec >= USEC_PER_SEC) @@ -1050,12 +1051,14 @@ int sock_setsockopt(struct socket *sock, int level, int optname, case SO_RCVTIMEO_OLD: case SO_RCVTIMEO_NEW: - ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen, optname == SO_RCVTIMEO_OLD); + ret = sock_set_timeout(&sk->sk_rcvtimeo, USER_SOCKPTR(optval), + optlen, optname == SO_RCVTIMEO_OLD); break; case SO_SNDTIMEO_OLD: case SO_SNDTIMEO_NEW: - ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen, optname == SO_SNDTIMEO_OLD); + ret = sock_set_timeout(&sk->sk_sndtimeo, USER_SOCKPTR(optval), + optlen, optname == SO_SNDTIMEO_OLD); break; case SO_ATTACH_FILTER: { -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6EuxH0WUFV9rrwEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:55:33 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id eGhhHUWUFV/UoAAAlScrYA (envelope-from ); Mon, 20 Jul 2020 14:55:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E2574A010E; Mon, 20 Jul 2020 14:55:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728805AbgGTMsL (ORCPT + 1 other); Mon, 20 Jul 2020 08:48:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728460AbgGTMsJ (ORCPT ); Mon, 20 Jul 2020 08:48:09 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6859FC0619D2; Mon, 20 Jul 2020 05:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=qqSXdt/0/kfIYmhxAmEpiFRzMh1TsKqQoMELThw3G/I=; b=Ri8VLRhEKVWjMNRsh2yUT4emOf P0lFd6B/MInuauhmUppRaPEzw+xKr6XUx6WvwDMMh/NpYwTIXe6n71llcDe5D034yUkVOJMgRZ7fE oYodq0FEjAIe16P8s1uZzQtrVelmOgzfm9QKf3ls5XzHPbpsURnLhMYphR1+d4ZSXJSspJijbjQ+2 uoCZR6U+CnU3OhLHwnGxvwMvVRPbWYbRCZCzvAc+3EZy0qljIJfZPYF9RuiboWVvp2GQlI62qnWjg UmnNlPHh+sDoTHE4iUPtCkCKAZlMc8cgMmuX43OGc60EjnJ9a1S9bNgzrAzfIO/f+DhRWM5Ni3XIw JNzeulWQ==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVCx-0004Wh-JK; Mon, 20 Jul 2020 12:47:53 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 04/24] net: switch copy_bpf_fprog_from_user to sockptr_t Date: Mon, 20 Jul 2020 14:47:17 +0200 Message-Id: <20200720124737.118617-5-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: E2574A010E X-Rspamd-UID: 6f957b Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/linux/filter.h | 3 ++- net/core/filter.c | 6 +++--- net/core/sock.c | 6 ++++-- net/packet/af_packet.c | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index 4d049c8e1fbeaa..87954ef126df77 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -1276,6 +1277,6 @@ struct bpf_sockopt_kern { s32 retval; }; -int copy_bpf_fprog_from_user(struct sock_fprog *dst, void __user *src, int len); +int copy_bpf_fprog_from_user(struct sock_fprog *dst, sockptr_t src, int len); #endif /* __LINUX_FILTER_H__ */ diff --git a/net/core/filter.c b/net/core/filter.c index 2bf6624796d86f..4cc1d381a273fd 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -77,14 +77,14 @@ #include #include -int copy_bpf_fprog_from_user(struct sock_fprog *dst, void __user *src, int len) +int copy_bpf_fprog_from_user(struct sock_fprog *dst, sockptr_t src, int len) { if (in_compat_syscall()) { struct compat_sock_fprog f32; if (len != sizeof(f32)) return -EINVAL; - if (copy_from_user(&f32, src, sizeof(f32))) + if (copy_from_sockptr(&f32, src, sizeof(f32))) return -EFAULT; memset(dst, 0, sizeof(*dst)); dst->len = f32.len; @@ -92,7 +92,7 @@ int copy_bpf_fprog_from_user(struct sock_fprog *dst, void __user *src, int len) } else { if (len != sizeof(*dst)) return -EINVAL; - if (copy_from_user(dst, src, sizeof(*dst))) + if (copy_from_sockptr(dst, src, sizeof(*dst))) return -EFAULT; } diff --git a/net/core/sock.c b/net/core/sock.c index d828bfe1c47dfa..91224709869389 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1062,7 +1062,8 @@ int sock_setsockopt(struct socket *sock, int level, int optname, case SO_ATTACH_FILTER: { struct sock_fprog fprog; - ret = copy_bpf_fprog_from_user(&fprog, optval, optlen); + ret = copy_bpf_fprog_from_user(&fprog, USER_SOCKPTR(optval), + optlen); if (!ret) ret = sk_attach_filter(&fprog, sk); break; @@ -1083,7 +1084,8 @@ int sock_setsockopt(struct socket *sock, int level, int optname, case SO_ATTACH_REUSEPORT_CBPF: { struct sock_fprog fprog; - ret = copy_bpf_fprog_from_user(&fprog, optval, optlen); + ret = copy_bpf_fprog_from_user(&fprog, USER_SOCKPTR(optval), + optlen); if (!ret) ret = sk_reuseport_attach_filter(&fprog, sk); break; diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index c240fb5de3f014..d8d4f78f78e451 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1536,7 +1536,7 @@ static void __fanout_set_data_bpf(struct packet_fanout *f, struct bpf_prog *new) } } -static int fanout_set_data_cbpf(struct packet_sock *po, char __user *data, +static int fanout_set_data_cbpf(struct packet_sock *po, sockptr_t data, unsigned int len) { struct bpf_prog *new; @@ -1584,7 +1584,7 @@ static int fanout_set_data(struct packet_sock *po, char __user *data, { switch (po->fanout->type) { case PACKET_FANOUT_CBPF: - return fanout_set_data_cbpf(po, data, len); + return fanout_set_data_cbpf(po, USER_SOCKPTR(data), len); case PACKET_FANOUT_EBPF: return fanout_set_data_ebpf(po, data, len); default: -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UK5NE2yUFV/s0AEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:56:12 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id yxF2EWyUFV/3NAEAgupzMw (envelope-from ); Mon, 20 Jul 2020 14:56:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 89E09A1F84; Mon, 20 Jul 2020 14:56:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729234AbgGTMwg (ORCPT + 1 other); Mon, 20 Jul 2020 08:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728703AbgGTMsK (ORCPT ); Mon, 20 Jul 2020 08:48:10 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8A97C061794; Mon, 20 Jul 2020 05:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=NOaRlO8PH56EoeQ6wPKZ+NHx4xWBn4wtfdyd3UU7j5Q=; b=r3wFqS6HvDtdd0R6F6qyrxhLxQ 0UmwqQvsG/ORHCNVtcyBkrRyN8Jl7NMUK+kN9rgMr7dJqvgRbNpsmGad7MyMT0Cslsg7ne9Zs1UlE /RwPyLdiHDpNgBjCzw/HmZWsORXbrednhTKLDHU0qAnYKNBOOFKeNoZ82aOb0D1SeYW1aLzwzDOBP heWVXUEQRk3EcbcAs4HVrc9bFRGjDJl3iUtWA6BGC9ZrXLSjvOE0L6VJHRbQKC45uIe6QuMjN7Gk/ O53gfIacoSmqnhrDUA7vy0qZZc0gL1aupHUgKPNVJamV2BJZVG7ttr+EMAYA95puN7nmqMY+irCXk KTg4Ltzw==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVD0-0004Ww-Nu; Mon, 20 Jul 2020 12:47:55 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 05/24] net: switch sock_setbindtodevice to sockptr_t Date: Mon, 20 Jul 2020 14:47:18 +0200 Message-Id: <20200720124737.118617-6-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 89E09A1F84 X-Rspamd-UID: e678d8 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- net/core/sock.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index 91224709869389..bd20fc5cce0850 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -608,8 +608,7 @@ int sock_bindtoindex(struct sock *sk, int ifindex, bool lock_sk) } EXPORT_SYMBOL(sock_bindtoindex); -static int sock_setbindtodevice(struct sock *sk, char __user *optval, - int optlen) +static int sock_setbindtodevice(struct sock *sk, sockptr_t optval, int optlen) { int ret = -ENOPROTOOPT; #ifdef CONFIG_NETDEVICES @@ -631,7 +630,7 @@ static int sock_setbindtodevice(struct sock *sk, char __user *optval, memset(devname, 0, sizeof(devname)); ret = -EFAULT; - if (copy_from_user(devname, optval, optlen)) + if (copy_from_sockptr(devname, optval, optlen)) goto out; index = 0; @@ -839,7 +838,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, */ if (optname == SO_BINDTODEVICE) - return sock_setbindtodevice(sk, optval, optlen); + return sock_setbindtodevice(sk, USER_SOCKPTR(optval), optlen); if (optlen < sizeof(int)) return -EINVAL; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8EqeIXWUFV/s0AEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:56:21 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id EGOtIHWUFV/MoQAA0J78UA (envelope-from ); Mon, 20 Jul 2020 14:56:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EC691A2637; Mon, 20 Jul 2020 14:56:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729553AbgGTMw5 (ORCPT + 1 other); Mon, 20 Jul 2020 08:52:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728639AbgGTMsJ (ORCPT ); Mon, 20 Jul 2020 08:48:09 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93D01C0619D6; Mon, 20 Jul 2020 05:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=KEtThMnZn1T5ZTjfnNtMK17c9WUSVU4JmbBC5GmCo8k=; b=b3r2mKtIMupzynpcKcbswq0IqO x3CWNt0l1PaHzJxn2EcCC+srtF/Mq7HfV7lip1uXJnLFShlYH6QJQY2jSIkrIhnf3sVEJDkDqNjCk V9gH3mJH8SwG877l7uoU1FWRwM1GLEq8XtvlkXitbXzib9XAND6UehTN8tWUA9fqsXsKJmKc92eZP 41LRqgsw0A7LsuqS0rj5uDt0YAbFizVFlTTXyAufbzXcu0u4npMvicFmVcDeqbg1ysEaqfgYRNkAX lniUhrynXQcYhppU4L4hxBrdsYQ3Wipg5bJvAirZt9QkqUN7wtobU7Ll7F9/YFeTzKA4LaNkLx22I ibp2wKgg==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVCp-0004WT-Jf; Mon, 20 Jul 2020 12:47:46 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 02/24] bpfilter: fix up a sparse annotation Date: Mon, 20 Jul 2020 14:47:15 +0200 Message-Id: <20200720124737.118617-3-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: EC691A2637 X-Rspamd-UID: dfe434 The __user doesn't make sense when casting to an integer type. Signed-off-by: Christoph Hellwig --- net/bpfilter/bpfilter_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c index 977e9dad72ca4f..713b4b3d02005d 100644 --- a/net/bpfilter/bpfilter_kern.c +++ b/net/bpfilter/bpfilter_kern.c @@ -49,7 +49,7 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname, req.is_set = is_set; req.pid = current->pid; req.cmd = optname; - req.addr = (long __force __user)optval; + req.addr = (__force long)optval; req.len = optlen; if (!bpfilter_ops.info.tgid) goto out; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OMXyMoaUFV/s0AEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 14:56:38 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 2F16MYaUFV99qAAAlScrYA (envelope-from ); Mon, 20 Jul 2020 14:56:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 54EFDA207B; Mon, 20 Jul 2020 14:56:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729260AbgGTMw6 (ORCPT + 1 other); Mon, 20 Jul 2020 08:52:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728487AbgGTMsJ (ORCPT ); Mon, 20 Jul 2020 08:48:09 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EAE9C0619D4; Mon, 20 Jul 2020 05:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=BjAfLkPDE3yZtg4lK7QhOgoW888N1+wDiCi2cbIh45M=; b=HIM07y0S6HWIwmCN7WHloUTyD/ 90NWYxEF7A8OOMt+yg4W0FNSTev46GNQHm0M10gQP0DPfw41j+camChNVNUSzdAS2+W9B6xEJFxj0 4n2KStvYzNC3b3fLRhUHbpg0C1h1bH+rhr3+ykUcvcbFAUG565FRK+y1r6zNQk9xHx3nUtlG0xpfa R4b3lYzoJn2Vsv07mi0Lr720W4t4f2K5zuJDLvkLLB7iLOadFMXPV1+OtITvRH1r7qcG7E4NGoir+ m5wZVdfOiGPje1P9oONZz0Y/9ohF3QfiJ1TkC//hfbo3TJ3Y4xN43vztrFOMr/5DT0r0fJAP1prMs TGHdbaAg==; Received: from [2001:4bb8:105:4a81:2a8f:15b1:2c3:7be7] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxVCm-0004WM-TP; Mon, 20 Jul 2020 12:47:41 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 01/24] bpfilter: reject kernel addresses Date: Mon, 20 Jul 2020 14:47:14 +0200 Message-Id: <20200720124737.118617-2-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720124737.118617-1-hch@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 54EFDA207B X-Rspamd-UID: 31472f When feeding addresses to userspace we can't support kernel addresses that were fed under set_fs(KERNEL_DS) from bpf-cgroup. Signed-off-by: Christoph Hellwig --- net/bpfilter/bpfilter_kern.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c index 2c31e82cb953af..977e9dad72ca4f 100644 --- a/net/bpfilter/bpfilter_kern.c +++ b/net/bpfilter/bpfilter_kern.c @@ -41,6 +41,11 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname, ssize_t n; int ret = -EFAULT; + if (uaccess_kernel()) { + pr_err("kernel access not supported\n"); + return -EFAULT; + } + req.is_set = is_set; req.pid = current->pid; req.cmd = optname; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kNb1Fr8CFl+8TQEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 22:46:55 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id QE90Fb8CFl/SowAAlp8NpQ (envelope-from ); Mon, 20 Jul 2020 22:46:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5E5C14AD68; Mon, 20 Jul 2020 22:46:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726658AbgGTUqq (ORCPT + 1 other); Mon, 20 Jul 2020 16:46:46 -0400 Received: from mga18.intel.com ([134.134.136.126]:45818 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgGTUqp (ORCPT ); Mon, 20 Jul 2020 16:46:45 -0400 IronPort-SDR: pVZhd7zXUkODSkuPO1HGIn+wgzUdNc+4d3n/DZXrXE4EBykRzs53J3LIG/e1ERs8+SqaggYDHZ rMHzWqiGQZqA== X-IronPort-AV: E=McAfee;i="6000,8403,9688"; a="137492772" X-IronPort-AV: E=Sophos;i="5.75,375,1589266800"; d="scan'208";a="137492772" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 13:46:43 -0700 IronPort-SDR: S0PIA5lqpRIrlU79H14GWSQ1tPTz1i0QqN9+fp8ALPC48lQodU7KjVSbuwPC2/Kc5O1FrwyUe+ 6mU270N6XYww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,375,1589266800"; d="scan'208";a="327652404" Received: from aukiwe-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.77.52]) by orsmga007.jf.intel.com with ESMTP; 20 Jul 2020 13:46:43 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ v2] mesh: Move model functionality out of node.c to model.c Date: Mon, 20 Jul 2020 13:46:42 -0700 Message-Id: <20200720204642.227014-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 28 X-Rspamd-Score: 4.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5E5C14AD68 X-Rspamd-UID: e01c5f This moves the model related code out of node.c to model.c providing for better functional separation of modules. --- mesh/cfgmod.h | 4 +- mesh/mesh-config-json.c | 5 +- mesh/model.c | 548 +++++++++++++++++++++++++++++----------- mesh/model.h | 37 +-- mesh/node.c | 304 +++------------------- mesh/node.h | 4 +- 6 files changed, 454 insertions(+), 448 deletions(-) diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 383fdbf6b..0bfa71680 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -17,8 +17,8 @@ * */ -#define CONFIG_SRV_MODEL (VENDOR_ID_MASK | 0x0000) -#define CONFIG_CLI_MODEL (VENDOR_ID_MASK | 0x0001) +#define CONFIG_SRV_MODEL 0x0000 +#define CONFIG_CLI_MODEL 0x0001 /* New List */ #define OP_APPKEY_ADD 0x00 diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 88f715fc1..deb0019f9 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1126,18 +1126,15 @@ static bool parse_models(json_object *jmodels, struct mesh_config_element *ele) if (sscanf(str, "%04x", &id) != 1) goto fail; - id |= VENDOR_ID_MASK; } else if (len == 8) { if (sscanf(str, "%08x", &id) != 1) goto fail; + mod->vendor = true; } else goto fail; mod->id = id; - if (len == 8) - mod->vendor = true; - if (json_object_object_get_ex(jmodel, "bind", &jarray)) { if (json_object_get_type(jarray) != json_type_array || !parse_bindings(jarray, mod)) diff --git a/mesh/model.c b/mesh/model.c index afac6ec69..eac8c8b5b 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -54,7 +54,6 @@ struct mesh_model { bool sub_enabled; bool pub_enabled; uint32_t id; - uint8_t ele_idx; }; struct mesh_virtual { @@ -131,44 +130,42 @@ static bool find_virt_by_label(const void *a, const void *b) static bool match_model_id(const void *a, const void *b) { - const struct mesh_model *model = a; + const struct mesh_model *mod = a; uint32_t id = L_PTR_TO_UINT(b); - return (mesh_model_get_model_id(model) == id); + return (mod->id == id); } -static struct mesh_model *get_model(struct mesh_node *node, uint8_t ele_idx, - uint32_t id, int *status) +static int compare_model_id(const void *a, const void *b, void *user_data) { - struct l_queue *models; - struct mesh_model *model; - - models = node_get_element_models(node, ele_idx, status); - if (!models) { - *status = MESH_STATUS_INVALID_MODEL; - return NULL; - } + const struct mesh_model *mod_a = a; + const struct mesh_model *mod_b = b; - model = l_queue_find(models, match_model_id, L_UINT_TO_PTR(id)); + if (mod_a->id < mod_b->id) + return -1; - *status = (model) ? MESH_STATUS_SUCCESS : MESH_STATUS_INVALID_MODEL; + if (mod_a->id > mod_b->id) + return 1; - return model; + return 0; } -static struct mesh_model *find_model(struct mesh_node *node, uint16_t addr, - uint32_t mod_id, int *status) +static struct mesh_model *get_model(struct mesh_node *node, uint8_t ele_idx, + uint32_t id) { - int ele_idx; - - ele_idx = node_get_element_idx(node, addr); + struct l_queue *mods; + struct mesh_model *mod; - if (ele_idx < 0) { - *status = MESH_STATUS_INVALID_ADDRESS; + mods = node_get_element_models(node, ele_idx); + if (!mods) return NULL; - } - return get_model(node, (uint8_t) ele_idx, mod_id, status); + mod = l_queue_find(mods, match_model_id, L_UINT_TO_PTR(id)); + + if (!mod) + l_debug("Model not found"); + + return mod; } static uint32_t pub_period_to_ms(uint8_t pub_period) @@ -268,15 +265,14 @@ static void append_dict_uint16_array(struct l_dbus_message_builder *builder, l_dbus_message_builder_leave_dict(builder); } -static void config_update_model_bindings(struct mesh_node *node, +static void cfg_update_mod_bindings(struct mesh_node *node, uint16_t ele_idx, struct mesh_model *mod) { struct l_dbus *dbus = dbus_get_bus(); struct l_dbus_message *msg; struct l_dbus_message_builder *builder; - msg = create_config_update_msg(node, mod->ele_idx, mod->id, - &builder); + msg = create_config_update_msg(node, ele_idx, mod->id, &builder); if (!msg) return; @@ -331,15 +327,14 @@ done: l_dbus_message_builder_leave_dict(builder); } -static void config_update_model_subscriptions(struct mesh_node *node, +static void cfg_update_model_subs(struct mesh_node *node, uint16_t ele_idx, struct mesh_model *mod) { struct l_dbus *dbus = dbus_get_bus(); struct l_dbus_message *msg; struct l_dbus_message_builder *builder; - msg = create_config_update_msg(node, mod->ele_idx, mod->id, - &builder); + msg = create_config_update_msg(node, ele_idx, mod->id, &builder); if (!msg) return; @@ -572,7 +567,8 @@ done: return ret; } -static void remove_pub(struct mesh_node *node, struct mesh_model *mod) +static void remove_pub(struct mesh_node *node, uint16_t ele_idx, + struct mesh_model *mod) { if (mod->pub) { if (mod->pub->virt) @@ -584,31 +580,31 @@ static void remove_pub(struct mesh_node *node, struct mesh_model *mod) if (!mod->cbs) /* External models */ - config_update_model_pub_period(node, mod->ele_idx, mod->id, 0); + config_update_model_pub_period(node, ele_idx, mod->id, 0); else if (mod->cbs && mod->cbs->pub) /* Internal models */ mod->cbs->pub(NULL); } -static void model_unbind_idx(struct mesh_node *node, struct mesh_model *mod, - uint16_t idx) +static void model_unbind_idx(struct mesh_node *node, uint16_t ele_idx, + struct mesh_model *mod, uint16_t idx) { l_queue_remove(mod->bindings, L_UINT_TO_PTR(idx)); if (!mod->cbs) /* External model */ - config_update_model_bindings(node, mod); + cfg_update_mod_bindings(node, ele_idx, mod); else if (mod->cbs->bind) /* Internal model */ mod->cbs->bind(idx, ACTION_DELETE); /* Remove model publication if the publication key is unbound */ if (mod->pub && idx == mod->pub->idx) - remove_pub(node, mod); + remove_pub(node, ele_idx, mod); } -static void model_bind_idx(struct mesh_node *node, struct mesh_model *mod, - uint16_t idx) +static void model_bind_idx(struct mesh_node *node, uint16_t ele_idx, + struct mesh_model *mod, uint16_t idx) { if (!mod->bindings) mod->bindings = l_queue_new(); @@ -619,7 +615,7 @@ static void model_bind_idx(struct mesh_node *node, struct mesh_model *mod, if (!mod->cbs) /* External model */ - config_update_model_bindings(node, mod); + cfg_update_mod_bindings(node, ele_idx, mod); else if (mod->cbs->bind) /* Internal model */ mod->cbs->bind(idx, ACTION_ADD); @@ -628,14 +624,16 @@ static void model_bind_idx(struct mesh_node *node, struct mesh_model *mod, static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, uint16_t app_idx, bool unbind) { - int status; struct mesh_model *mod; bool is_present, is_vendor; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) { - l_debug("Model not found"); - return status; + return MESH_STATUS_INVALID_MODEL; } is_vendor = id < VENDOR_ID_MASK && id > 0xffff; @@ -656,7 +654,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; if (unbind) { - model_unbind_idx(node, mod, app_idx); + model_unbind_idx(node, ele_idx, mod, app_idx); if (!mesh_config_model_binding_del(node_config_get(node), addr, is_vendor, id, app_idx)) return MESH_STATUS_STORAGE_FAIL; @@ -672,7 +670,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, addr, is_vendor, id, app_idx)) return MESH_STATUS_STORAGE_FAIL; - model_bind_idx(node, mod, app_idx); + model_bind_idx(node, ele_idx, mod, app_idx); return MESH_STATUS_SUCCESS; @@ -964,7 +962,6 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, is_subscription = !(IS_UNICAST(dst)); - for (i = 0; i < num_ele; i++) { struct l_queue *models; @@ -974,7 +971,7 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, forward.unicast = addr + i; forward.has_dst = false; - models = node_get_element_models(node, i, NULL); + models = node_get_element_models(node, i); /* Internal models */ l_queue_foreach(models, forward_model, &forward); @@ -1023,16 +1020,15 @@ done: return result; } -int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, - uint16_t src, uint8_t ttl, - const void *msg, uint16_t msg_len) +static int model_publish(struct mesh_node *node, uint32_t id, uint16_t src, + uint8_t ttl, const void *msg, uint16_t msg_len) { struct mesh_net *net = node_get_net(node); struct mesh_model *mod; uint8_t *label = NULL; uint16_t net_idx; bool result; - int status; + int ele_idx; if (!net || msg_len > 380) return MESH_ERROR_INVALID_ARGS; @@ -1041,14 +1037,16 @@ int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, if (src == 0) src = mesh_net_get_address(net); - mod = find_model(node, src, mod_id, &status); - if (!mod) { - l_debug("model %x not found", mod_id); + ele_idx = node_get_element_idx(node, src); + if (ele_idx < 0) + return MESH_ERROR_NOT_FOUND; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) return MESH_ERROR_NOT_FOUND; - } if (!mod->pub) { - l_debug("publication doesn't exist (model %x)", mod_id); + l_debug("publication doesn't exist (model %x)", id); return MESH_ERROR_DOES_NOT_EXIST; } @@ -1069,6 +1067,24 @@ int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, return result ? MESH_ERROR_NONE : MESH_ERROR_FAILED; } +int mesh_model_publish(struct mesh_node *node, uint16_t mod_id, + uint16_t src, uint8_t ttl, + const void *msg, uint16_t msg_len) +{ + uint32_t id = mod_id | VENDOR_ID_MASK; + + return model_publish(node, id, src, ttl, msg, msg_len); +} + +int mesh_model_vendor_publish(struct mesh_node *node, uint16_t vendor_id, + uint16_t mod_id, uint16_t src, uint8_t ttl, + const void *msg, uint16_t msg_len) +{ + uint32_t id = mod_id | ((uint32_t)(vendor_id) << 16); + + return model_publish(node, id, src, ttl, msg, msg_len); +} + bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, uint8_t ttl, bool segmented, @@ -1093,11 +1109,14 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, bool is_virt, uint16_t *dst) { struct mesh_model *mod; - int status; + int status, ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->pub_enabled || (mod->cbs && !(mod->cbs->pub))) return MESH_STATUS_INVALID_PUB_PARAM; @@ -1110,7 +1129,7 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, * remove the publication */ if (!is_virt && IS_UNASSIGNED(l_get_le16(pub_addr))) { - remove_pub(node, mod); + remove_pub(node, ele_idx, mod); return MESH_STATUS_SUCCESS; } @@ -1134,7 +1153,7 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External model */ - config_update_model_pub_period(node, mod->ele_idx, id, + config_update_model_pub_period(node, ele_idx, id, pub_period_to_ms(period)); else { /* Internal model, call registered callbacks */ @@ -1149,10 +1168,18 @@ struct mesh_model_pub *mesh_model_pub_get(struct mesh_node *node, uint16_t addr, uint32_t mod_id, int *status) { struct mesh_model *mod; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, mod_id, status); - if (!mod) + if (ele_idx < 0) { + *status = MESH_STATUS_INVALID_ADDRESS; return NULL; + } + + mod = get_model(node, (uint8_t) ele_idx, mod_id); + if (!mod) { + *status = MESH_STATUS_INVALID_MODEL; + return NULL; + } if (!mod->pub_enabled || (mod->cbs && !(mod->cbs->pub))) *status = MESH_STATUS_INVALID_PUB_PARAM; @@ -1173,12 +1200,25 @@ void mesh_model_free(void *data) l_free(mod); } -struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t id) +static void remove_subs(struct mesh_node *node, struct mesh_model *mod) +{ + const struct l_queue_entry *entry; + struct mesh_net *net = node_get_net(node); + + entry = l_queue_get_entries(mod->subs); + + for (; entry; entry = entry->next) + mesh_net_dst_unreg(net, (uint16_t) L_PTR_TO_UINT(entry->data)); + + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); +} + +static struct mesh_model *model_new(uint32_t id) { struct mesh_model *mod = l_new(struct mesh_model, 1); mod->id = id; - mod->ele_idx = ele_idx; mod->virtuals = l_queue_new(); /* @@ -1190,6 +1230,92 @@ struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t id) return mod; } +static void model_enable_pub(struct mesh_model *mod, bool enable) +{ + mod->pub_enabled = enable; + + if (!mod->pub_enabled && mod->pub) { + if (mod->pub->virt) + unref_virt(mod->pub->virt); + + l_free(mod->pub); + mod->pub = NULL; + } +} + +static void model_enable_sub(struct mesh_node *node, struct mesh_model *mod, + bool enable) +{ + mod->sub_enabled = enable; + + if (!mod->sub_enabled) + remove_subs(node, mod); +} + +static bool get_model_options(struct mesh_model *mod, + struct l_dbus_message_iter *opts) +{ + const char *key; + struct l_dbus_message_iter var; + bool opt; + + while (l_dbus_message_iter_next_entry(opts, &key, &var)) { + + if (!strcmp(key, "Publish")) { + if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) + return false; + + mod->pub_enabled = opt; + } else if (!strcmp(key, "Subscribe")) { + if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) + return false; + + mod->sub_enabled = opt; + } else + return false; + } + + return true; +} + +static bool add_model(struct mesh_node *node, struct l_queue *mods, uint32_t id, + struct l_dbus_message_iter *opts) +{ + struct mesh_model *mod; + + /* Disallow duplicates */ + mod = l_queue_find(mods, match_model_id, L_UINT_TO_PTR(id)); + if (mod) + return false; + + mod = model_new(id); + + if (opts && !get_model_options(mod, opts)) { + mesh_model_free(mod); + return false; + } + + l_queue_insert(mods, mod, compare_model_id, NULL); + return true; +} + +bool mesh_model_add(struct mesh_node *node, struct l_queue *mods, + uint16_t mod_id, struct l_dbus_message_iter *opts) +{ + uint32_t id = mod_id | VENDOR_ID_MASK; + + return add_model(node, mods, id, opts); +} + +bool mesh_model_vendor_add(struct mesh_node *node, struct l_queue *mods, + uint16_t vendor_id, uint16_t mod_id, + struct l_dbus_message_iter *opts) +{ + uint32_t id = mod_id | ((uint32_t)(vendor_id) << 16); + + return add_model(node, mods, id, opts); +} + /* Internal models only */ static void restore_model_state(struct mesh_model *mod) { @@ -1213,26 +1339,21 @@ static void restore_model_state(struct mesh_model *mod) } -uint32_t mesh_model_get_model_id(const struct mesh_model *model) -{ - return model->id; -} - /* This registers an internal model, i.e. implemented within meshd */ bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, - uint32_t mod_id, + uint16_t mod_id, const struct mesh_model_ops *cbs, void *user_data) { struct mesh_model *mod; - int status; + uint32_t id; /* Internal models are always SIG models */ - mod_id = VENDOR_ID_MASK | mod_id; + id = VENDOR_ID_MASK | mod_id; - mod = get_model(node, ele_idx, mod_id, &status); + mod = get_model(node, ele_idx, id); if (!mod) - return false; + return MESH_STATUS_INVALID_MODEL; mod->cbs = cbs; mod->user_data = user_data; @@ -1242,15 +1363,15 @@ bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, return true; } -void mesh_model_app_key_delete(struct mesh_node *node, struct l_queue *models, - uint16_t app_idx) +void mesh_model_app_key_delete(struct mesh_node *node, uint16_t ele_idx, + struct l_queue *models, uint16_t app_idx) { const struct l_queue_entry *entry = l_queue_get_entries(models); for (; entry; entry = entry->next) { - struct mesh_model *model = entry->data; + struct mesh_model *mod = entry->data; - model_unbind_idx(node, model, app_idx); + model_unbind_idx(node, ele_idx, mod, app_idx); } } @@ -1269,18 +1390,20 @@ int mesh_model_binding_add(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_get_bindings(struct mesh_node *node, uint16_t addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size) { - int status; struct mesh_model *mod; const struct l_queue_entry *entry; uint16_t n; uint32_t idx_pair; - int i; + int i, ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) { *size = 0; - return status; + return MESH_STATUS_INVALID_MODEL; } entry = l_queue_get_entries(mod->bindings); @@ -1325,14 +1448,17 @@ done: int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size) { - int status; int16_t n; struct mesh_model *mod; const struct l_queue_entry *entry; + int ele_idx = node_get_element_idx(node, addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; - mod = find_model(node, addr, id, &status); + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1370,12 +1496,15 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *group, bool is_virt, uint16_t *dst) { - int status; struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1387,7 +1516,7 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); return MESH_STATUS_SUCCESS; } @@ -1395,13 +1524,16 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *group, bool is_virt, uint16_t *dst) { - int status; struct l_queue *virtuals, *subs; struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; - mod = find_model(node, addr, id, &status); + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1439,7 +1571,7 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); return status; } @@ -1447,13 +1579,16 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *group, bool is_virt, uint16_t *dst) { - int status; uint16_t grp; struct mesh_model *mod; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1481,34 +1616,23 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); } return MESH_STATUS_SUCCESS; } -static void remove_subs(struct mesh_node *node, struct mesh_model *mod) -{ - const struct l_queue_entry *entry; - struct mesh_net *net = node_get_net(node); - - entry = l_queue_get_entries(mod->subs); - - for (; entry; entry = entry->next) - mesh_net_dst_unreg(net, (uint16_t) L_PTR_TO_UINT(entry->data)); - - l_queue_clear(mod->subs, NULL); - l_queue_clear(mod->virtuals, unref_virt); -} - int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) { - int status; struct mesh_model *mod; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1517,17 +1641,15 @@ int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); return MESH_STATUS_SUCCESS; } -struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, - void *data) +static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, + struct mesh_config_model *db_mod) { - struct mesh_config_model *db_mod = data; struct mesh_model *mod; - struct mesh_net *net; struct mesh_config_pub *pub = db_mod->pub; uint32_t i; @@ -1537,7 +1659,7 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return NULL; } - mod = mesh_model_new(ele_idx, db_mod->vendor ? db_mod->id : + mod = model_new(db_mod->vendor ? db_mod->id : db_mod->id | VENDOR_ID_MASK); /* Implicitly bind config server model to device key */ @@ -1557,17 +1679,18 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return mod; } - net = node_get_net(node); - /* Add application key bindings if present */ if (db_mod->bindings) { mod->bindings = l_queue_new(); for (i = 0; i < db_mod->num_bindings; i++) - model_bind_idx(node, mod, db_mod->bindings[i]); + l_queue_push_tail(mod->bindings, + L_UINT_TO_PTR(db_mod->bindings[i])); } - /* Add publication if present */ - if (pub) { + mod->pub_enabled = db_mod->pub_enabled; + + /* Add publication if enabled and present */ + if (mod->pub_enabled && pub) { uint8_t retransmit = pub->count + ((pub->interval / 50 - 1) << 3); if (pub->virt) @@ -1579,8 +1702,10 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, pub->ttl, pub->period, retransmit); } - /* Add subscriptions if present */ - if (!db_mod->subs) + mod->sub_enabled = db_mod->sub_enabled; + + /* Add subscriptions if enabled and present */ + if (!db_mod->subs || !mod->sub_enabled) return mod; for (i = 0; i < db_mod->num_subs; i++) { @@ -1605,6 +1730,59 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return mod; } +bool mesh_model_add_from_storage(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *mods, struct l_queue *db_mods) +{ + struct mesh_net *net = node_get_net(node); + const struct l_queue_entry *entry; + + /* Allow empty elements */ + if (!db_mods) + return true; + + entry = l_queue_get_entries(db_mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod; + struct mesh_config_model *db_mod; + uint32_t id; + + db_mod = entry->data; + + id = db_mod->vendor ? db_mod->id : db_mod->id | VENDOR_ID_MASK; + + if (l_queue_find(mods, match_model_id, L_UINT_TO_PTR(id))) + return false; + + mod = model_setup(net, ele_idx, db_mod); + if (!mod) + return false; + + l_queue_insert(mods, mod, compare_model_id, NULL); + } + + return true; +} + +void mesh_model_convert_to_storage(struct l_queue *db_mods, + struct l_queue *mods) +{ + + const struct l_queue_entry *entry = l_queue_get_entries(mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + struct mesh_config_model *db_mod; + + db_mod = l_new(struct mesh_config_model, 1); + db_mod->id = mod->id; + db_mod->vendor = mod->id < VENDOR_ID_MASK; + db_mod->pub_enabled = mod->pub_enabled; + db_mod->sub_enabled = mod->sub_enabled; + l_queue_push_tail(db_mods, db_mod); + } +} + uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf) { if (opcode <= 0x7e) { @@ -1669,7 +1847,7 @@ bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, return true; } -void model_build_config(void *model, void *msg_builder) +void mesh_model_build_config(void *model, void *msg_builder) { struct l_dbus_message_builder *builder = msg_builder; struct mesh_model *mod = model; @@ -1715,36 +1893,44 @@ void model_build_config(void *model, void *msg_builder) l_dbus_message_builder_leave_struct(builder); } -void mesh_model_enable_pub(struct mesh_model *mod, bool enable) +void mesh_model_update_opts(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *curr, struct l_queue *updated) { - mod->pub_enabled = enable; + uint16_t primary; + const struct l_queue_entry *entry; - if (!mod->pub_enabled && mod->pub) { - if (mod->pub->virt) - unref_virt(mod->pub->virt); + primary = node_get_primary(node); + entry = l_queue_get_entries(curr); - l_free(mod->pub); - mod->pub = NULL; - } -} + for (; entry; entry = entry->next) { + struct mesh_model *mod, *updated_mod = entry->data; + uint32_t id = updated_mod->id; + bool updated_opt, vendor = id < VENDOR_ID_MASK; -bool mesh_model_is_pub_enabled(struct mesh_model *mod) -{ - return mod->pub_enabled; -} + mod = l_queue_find(curr, match_model_id, L_UINT_TO_PTR(id)); + if (!mod) + continue; -void mesh_model_enable_sub(struct mesh_node *node, struct mesh_model *mod, - bool enable) -{ - mod->sub_enabled = enable; + if (!vendor) + id &= ~VENDOR_ID_MASK; - if (!mod->sub_enabled) - remove_subs(node, mod); -} + updated_opt = updated_mod->pub_enabled; + if (mod->pub_enabled != updated_opt) { + model_enable_pub(mod, updated_opt); + mesh_config_model_pub_enable(node_config_get(node), + primary + ele_idx, id, + vendor, updated_opt); + } -bool mesh_model_is_sub_enabled(struct mesh_model *mod) -{ - return mod->sub_enabled; + updated_opt = updated_mod->sub_enabled; + + if (mod->pub_enabled != updated_opt) { + model_enable_sub(node, mod, updated_opt); + mesh_config_model_sub_enable(node_config_get(node), + primary + ele_idx, id, + vendor, updated_opt); + } + } } void mesh_model_init(void) @@ -1757,3 +1943,59 @@ void mesh_model_cleanup(void) l_queue_destroy(mesh_virtuals, l_free); mesh_virtuals = NULL; } + +/* Populate composition buffer with model IDs */ +uint16_t mesh_model_generate_composition(struct l_queue *mods, uint16_t buf_sz, + uint8_t *buf) +{ + const struct l_queue_entry *entry; + uint8_t num_s = 0, num_v = 0; + uint8_t *mod_buf; + uint16_t n; + + /* Store models IDs, store num_s and num_v later */ + mod_buf = buf; + n = 2; + + entry = l_queue_get_entries(mods); + + /* Get SIG models */ + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + + if (n + 2 > buf_sz) + goto done; + + if ((mod->id & VENDOR_ID_MASK) == VENDOR_ID_MASK) { + l_put_le16((uint16_t) (mod->id & 0xffff), buf + n); + n += 2; + num_s++; + } + } + + /* Get vendor models */ + entry = l_queue_get_entries(mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + uint16_t vendor; + + if (n + 4 > buf_sz) + goto done; + + if ((mod->id & VENDOR_ID_MASK) == VENDOR_ID_MASK) + continue; + + vendor = (uint16_t) (mod->id >> 16); + l_put_le16(vendor, buf + n); + n += 2; + l_put_le16((uint16_t) (mod->id & 0xffff), buf + n); + n += 2; + num_v++; + } + +done: + mod_buf[0] = num_s; + mod_buf[1] = num_v; + return n; +} diff --git a/mesh/model.h b/mesh/model.h index 0377d3fdd..b425fd66a 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -60,14 +60,19 @@ struct mesh_model_ops { mesh_model_sub_cb sub; }; -struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t mod_id); +bool mesh_model_add(struct mesh_node *node, struct l_queue *mods, + uint16_t mod_id, struct l_dbus_message_iter *opts); +bool mesh_model_vendor_add(struct mesh_node *node, struct l_queue *mods, + uint16_t vendor_id, uint16_t mod_id, + struct l_dbus_message_iter *opts); void mesh_model_free(void *data); -uint32_t mesh_model_get_model_id(const struct mesh_model *model); bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, - uint32_t mod_id, const struct mesh_model_ops *cbs, + uint16_t mod_id, const struct mesh_model_ops *cbs, void *user_data); -struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, - void *data); +bool mesh_model_add_from_storage(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *mods, struct l_queue *db_mods); +void mesh_model_convert_to_storage(struct l_queue *db_mods, + struct l_queue *mods); struct mesh_model_pub *mesh_model_pub_get(struct mesh_node *node, uint16_t addr, uint32_t mod_id, int *status); int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, @@ -95,26 +100,26 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, uint8_t ttl, bool segmented, const void *msg, uint16_t msg_len); -int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, uint16_t src, +int mesh_model_publish(struct mesh_node *node, uint16_t mod_id, uint16_t src, uint8_t ttl, const void *msg, uint16_t msg_len); +int mesh_model_vendor_publish(struct mesh_node *node, uint16_t vendor_id, + uint16_t mod_id, uint16_t src, uint8_t ttl, + const void *msg, uint16_t msg_len); bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, uint32_t seq, uint32_t iv_index, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t key_aid, const uint8_t *data, uint16_t size); void mesh_model_app_key_generate_new(struct mesh_node *node, uint16_t net_idx); -void mesh_model_app_key_delete(struct mesh_node *node, struct l_queue *models, - uint16_t idx); +void mesh_model_app_key_delete(struct mesh_node *node, uint16_t ele_idx, + struct l_queue *models, uint16_t app_idx); struct l_queue *mesh_model_get_appkeys(struct mesh_node *node); uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf); bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, uint32_t *opcode, uint16_t *n); -void model_build_config(void *model, void *msg_builder); - -void mesh_model_enable_pub(struct mesh_model *mod, bool enable); -bool mesh_model_is_pub_enabled(struct mesh_model *mod); -void mesh_model_enable_sub(struct mesh_node *node, struct mesh_model *mod, - bool enable); -bool mesh_model_is_sub_enabled(struct mesh_model *mod); - +void mesh_model_build_config(void *model, void *msg_builder); +void mesh_model_update_opts(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *curr, struct l_queue *updated); +uint16_t mesh_model_generate_composition(struct l_queue *mods, uint16_t buf_sz, + uint8_t *buf); void mesh_model_init(void); void mesh_model_cleanup(void); diff --git a/mesh/node.c b/mesh/node.c index 9b97aa927..93020c93d 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -186,28 +186,6 @@ static bool match_element_path(const void *a, const void *b) return (!strcmp(element->path, path)); } -static bool match_model_id(const void *a, const void *b) -{ - const struct mesh_model *mod = a; - uint32_t mod_id = L_PTR_TO_UINT(b); - - return mesh_model_get_model_id(mod) == mod_id; -} - -static int compare_model_id(const void *a, const void *b, void *user_data) -{ - uint32_t a_id = mesh_model_get_model_id(a); - uint32_t b_id = mesh_model_get_model_id(b); - - if (a_id < b_id) - return -1; - - if (a_id > b_id) - return 1; - - return 0; -} - struct mesh_node *node_find_by_uuid(uint8_t uuid[16]) { return l_queue_find(nodes, match_device_uuid, uuid); @@ -225,25 +203,6 @@ uint8_t *node_uuid_get(struct mesh_node *node) return node->uuid; } -static void add_internal_model(struct mesh_node *node, uint32_t mod_id, - uint8_t ele_idx) -{ - struct node_element *ele; - struct mesh_model *mod; - - ele = l_queue_find(node->elements, match_element_idx, - L_UINT_TO_PTR(ele_idx)); - if (!ele) - return; - - if (l_queue_find(ele->models, match_model_id, L_UINT_TO_PTR(mod_id))) - return; - - mod = mesh_model_new(ele_idx, mod_id); - - l_queue_insert(ele->models, mod, compare_model_id, NULL); -} - static void set_defaults(struct mesh_node *node) { node->lpn = MESH_MODE_UNSUPPORTED; @@ -359,46 +318,6 @@ void node_remove(struct mesh_node *node) free_node_resources(node); } -static bool add_models_from_storage(struct mesh_node *node, - struct node_element *ele, - struct mesh_config_element *db_ele) -{ - const struct l_queue_entry *entry; - - if (!ele->models) - ele->models = l_queue_new(); - - entry = l_queue_get_entries(db_ele->models); - - for (; entry; entry = entry->next) { - struct mesh_model *mod; - struct mesh_config_model *db_mod; - uint32_t id; - - db_mod = entry->data; - - id = db_mod->vendor ? db_mod->id : db_mod->id | VENDOR_ID_MASK; - - if (l_queue_find(ele->models, match_model_id, - L_UINT_TO_PTR(id))) - return false; - - mod = mesh_model_setup(node, ele->idx, db_mod); - if (!mod) - return false; - - if (!db_mod->pub_enabled) - mesh_model_enable_pub(mod, false); - - if (!db_mod->sub_enabled) - mesh_model_enable_sub(node, mod, false); - - l_queue_insert(ele->models, mod, compare_model_id, NULL); - } - - return true; -} - static bool add_element_from_storage(struct mesh_node *node, struct mesh_config_element *db_ele) { @@ -411,7 +330,12 @@ static bool add_element_from_storage(struct mesh_node *node, ele->idx = db_ele->index; ele->location = db_ele->location; - if (!db_ele->models || !add_models_from_storage(node, ele, db_ele)) + + if (!ele->models) + ele->models = l_queue_new(); + + if (!mesh_model_add_from_storage(node, ele->idx, ele->models, + db_ele->models)) return false; l_queue_push_tail(node->elements, ele); @@ -424,12 +348,13 @@ static bool add_elements_from_storage(struct mesh_node *node, const struct l_queue_entry *entry; entry = l_queue_get_entries(db_node->elements); + for (; entry; entry = entry->next) if (!add_element_from_storage(node, entry->data)) return false; /* Add configuration server model on the primary element */ - add_internal_model(node, CONFIG_SRV_MODEL, PRIMARY_ELE_IDX); + mesh_model_add(node, PRIMARY_ELE_IDX, CONFIG_SRV_MODEL, NULL); return true; } @@ -628,7 +553,7 @@ void node_app_key_delete(struct mesh_node *node, uint16_t net_idx, for (; entry; entry = entry->next) { struct node_element *ele = entry->data; - mesh_model_app_key_delete(node, ele->models, app_idx); + mesh_model_app_key_delete(node, ele->idx, ele->models, app_idx); } } @@ -666,27 +591,17 @@ uint8_t node_get_num_elements(struct mesh_node *node) return node->num_ele; } -struct l_queue *node_get_element_models(struct mesh_node *node, - uint8_t ele_idx, int *status) +struct l_queue *node_get_element_models(struct mesh_node *node, uint8_t ele_idx) { struct node_element *ele; - if (!node) { - if (status) - *status = MESH_STATUS_INVALID_ADDRESS; + if (!node) return NULL; - } ele = l_queue_find(node->elements, match_element_idx, L_UINT_TO_PTR(ele_idx)); - if (!ele) { - if (status) - *status = MESH_STATUS_INVALID_ADDRESS; + if (!ele) return NULL; - } - - if (status) - *status = MESH_STATUS_SUCCESS; return ele->models; } @@ -888,9 +803,8 @@ uint8_t node_friend_mode_get(struct mesh_node *node) static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz) { - uint16_t n, features; - uint16_t num_ele = 0; - const struct l_queue_entry *ele_entry; + uint16_t n, features, num_ele = 0; + const struct l_queue_entry *entry; if (!node || sz < MIN_COMP_SIZE) return 0; @@ -920,12 +834,10 @@ static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, l_put_le16(features, buf + n); n += 2; - ele_entry = l_queue_get_entries(node->elements); - for (; ele_entry; ele_entry = ele_entry->next) { - struct node_element *ele = ele_entry->data; - const struct l_queue_entry *mod_entry; - uint8_t num_s = 0, num_v = 0; - uint8_t *mod_buf; + entry = l_queue_get_entries(node->elements); + + for (; entry; entry = entry->next) { + struct node_element *ele = entry->data; if (ele->idx != num_ele) return 0; @@ -939,59 +851,8 @@ static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, l_put_le16(ele->location, buf + n); n += 2; - /* Store models IDs, store num_s and num_v later */ - mod_buf = buf + n; - n += 2; - - /* Get SIG models */ - mod_entry = l_queue_get_entries(ele->models); - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - uint32_t mod_id; - - mod_id = mesh_model_get_model_id( - (const struct mesh_model *) mod); - - if ((mod_id & VENDOR_ID_MASK) == VENDOR_ID_MASK) { - if (n + 2 > sz) - goto element_done; - - l_put_le16((uint16_t) (mod_id & 0xffff), + n += mesh_model_generate_composition(ele->models, sz - n, buf + n); - n += 2; - num_s++; - } - } - - /* Get vendor models */ - mod_entry = l_queue_get_entries(ele->models); - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - uint32_t mod_id; - uint16_t vendor; - - mod_id = mesh_model_get_model_id( - (const struct mesh_model *) mod); - - vendor = (uint16_t) (mod_id >> 16); - if (vendor != 0xffff) { - if (n + 4 > sz) - goto element_done; - - l_put_le16(vendor, buf + n); - n += 2; - l_put_le16((uint16_t) (mod_id & 0xffff), - buf + n); - n += 2; - num_v++; - } - - } - -element_done: - mod_buf[0] = num_s; - mod_buf[1] = num_v; - } if (!num_ele) @@ -1128,52 +989,6 @@ static void app_disc_cb(struct l_dbus *bus, void *user_data) free_node_dbus_resources(node); } -static bool get_model_options(struct mesh_node *node, struct mesh_model *mod, - struct l_dbus_message_iter *opts) -{ - const char *key; - struct l_dbus_message_iter var; - bool opt; - - while (l_dbus_message_iter_next_entry(opts, &key, &var)) { - - if (!strcmp(key, "Publish")) { - if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) - return false; - mesh_model_enable_pub(mod, opt); - } else if (!strcmp(key, "Subscribe")) { - if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) - return false; - mesh_model_enable_sub(node, mod, opt); - } else - return false; - } - - return true; -} - -static bool generate_model(struct mesh_node *node, struct node_element *ele, - uint32_t id, struct l_dbus_message_iter *opts) -{ - struct mesh_model *mod; - - /* Disallow duplicates */ - if (l_queue_find(ele->models, match_model_id, - L_UINT_TO_PTR(id))) - return false; - - mod = mesh_model_new(ele->idx, id); - - if (!get_model_options(node, mod, opts)) { - l_free(mod); - return false; - } - - l_queue_insert(ele->models, mod, compare_model_id, NULL); - - return true; -} - static bool get_sig_models_from_properties(struct mesh_node *node, struct node_element *ele, struct l_dbus_message_iter *property) @@ -1189,13 +1004,12 @@ static bool get_sig_models_from_properties(struct mesh_node *node, /* Bluetooth SIG defined models */ while (l_dbus_message_iter_next_entry(&mods, &m_id, &var)) { - uint32_t id = m_id | VENDOR_ID_MASK; /* Allow Config Server Model only on the primary element */ - if (ele->idx != PRIMARY_ELE_IDX && id == CONFIG_SRV_MODEL) + if (ele->idx != PRIMARY_ELE_IDX && m_id == CONFIG_SRV_MODEL) return false; - if (!generate_model(node, ele, id, &var)) + if (!mesh_model_add(node, ele->models, m_id, &var)) return false; } @@ -1217,9 +1031,7 @@ static bool get_vendor_models_from_properties(struct mesh_node *node, /* Vendor defined models */ while (l_dbus_message_iter_next_entry(&mods, &v_id, &m_id, &var)) { - uint32_t id = m_id | (v_id << 16); - - if (!generate_model(node, ele, id, &var)) + if (!mesh_model_vendor_add(node, ele->models, v_id, m_id, &var)) return false; } @@ -1295,7 +1107,7 @@ static bool get_element_properties(struct mesh_node *node, const char *path, * the operation below will be a "no-op". */ if (ele->idx == PRIMARY_ELE_IDX) - add_internal_model(node, CONFIG_SRV_MODEL, PRIMARY_ELE_IDX); + mesh_model_add(node, ele->models, CONFIG_SRV_MODEL, NULL); return true; fail: @@ -1332,7 +1144,6 @@ static void convert_node_to_storage(struct mesh_node *node, for (; entry; entry = entry->next) { struct node_element *ele = entry->data; struct mesh_config_element *db_ele; - const struct l_queue_entry *mod_entry; db_ele = l_new(struct mesh_config_element, 1); @@ -1340,21 +1151,8 @@ static void convert_node_to_storage(struct mesh_node *node, db_ele->location = ele->location; db_ele->models = l_queue_new(); - mod_entry = l_queue_get_entries(ele->models); + mesh_model_convert_to_storage(db_ele->models, ele->models); - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - struct mesh_config_model *db_mod; - uint32_t mod_id = mesh_model_get_model_id(mod); - - db_mod = l_new(struct mesh_config_model, 1); - db_mod->id = mod_id; - db_mod->vendor = ((mod_id & VENDOR_ID_MASK) - != VENDOR_ID_MASK); - db_mod->pub_enabled = mesh_model_is_pub_enabled(mod); - db_mod->sub_enabled = mesh_model_is_sub_enabled(mod); - l_queue_push_tail(db_ele->models, db_mod); - } l_queue_push_tail(db_node->elements, db_ele); } @@ -1375,6 +1173,7 @@ static bool create_node_config(struct mesh_node *node, const uint8_t uuid[16]) /* Free temporarily allocated resources */ entry = l_queue_get_entries(db_node.elements); + for (; entry; entry = entry->next) { struct mesh_config_element *db_ele = entry->data; @@ -1517,7 +1316,6 @@ static void update_model_options(struct mesh_node *node, len = l_queue_length(node->elements); for (i = 0; i < len; i++) { - const struct l_queue_entry *entry; ele = l_queue_find(node->elements, match_element_idx, L_UINT_TO_PTR(i)); @@ -1526,42 +1324,8 @@ static void update_model_options(struct mesh_node *node, if (!ele || !ele_attach) continue; - entry = l_queue_get_entries(ele->models); - - for (; entry; entry = entry->next) { - struct mesh_model *mod, *updated_mod = entry->data; - uint32_t id = mesh_model_get_model_id(updated_mod); - bool opt, updated_opt; - bool vendor = id < VENDOR_ID_MASK; - - mod = l_queue_find(ele_attach->models, match_model_id, - L_UINT_TO_PTR(id)); - if (!mod) - continue; - - if (!vendor) - id &= ~VENDOR_ID_MASK; - - opt = mesh_model_is_pub_enabled(mod); - updated_opt = mesh_model_is_pub_enabled(updated_mod); - - if (updated_opt != opt) { - mesh_model_enable_pub(mod, updated_opt); - mesh_config_model_pub_enable(attach->cfg, - attach->primary + i, id, - vendor, updated_opt); - } - - opt = mesh_model_is_sub_enabled(mod); - updated_opt = mesh_model_is_sub_enabled(updated_mod); - - if (updated_opt != opt) { - mesh_model_enable_sub(node, mod, updated_opt); - mesh_config_model_sub_enable(attach->cfg, - attach->primary + i, id, - vendor, updated_opt); - } - } + mesh_model_update_opts(node, ele->idx, ele_attach->models, + ele->models); } } @@ -1964,7 +1728,7 @@ static void build_element_config(void *a, void *b) l_dbus_message_builder_enter_array(builder, "(qa{sv})"); /* Iterate over models */ - l_queue_foreach(ele->models, model_build_config, builder); + l_queue_foreach(ele->models, mesh_model_build_config, builder); l_dbus_message_builder_leave_array(builder); @@ -2243,7 +2007,7 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - result = mesh_model_publish(node, VENDOR_ID_MASK | mod_id, src, + result = mesh_model_publish(node, mod_id, src, mesh_net_get_default_ttl(node->net), data, len); if (result != MESH_ERROR_NONE) @@ -2260,8 +2024,7 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, const char *sender, *ele_path; struct l_dbus_message_iter iter_data; uint16_t src; - uint16_t model_id, vendor; - uint32_t vendor_mod_id; + uint16_t mod_id, vendor_id; struct node_element *ele; uint8_t *data = NULL; uint32_t len; @@ -2274,8 +2037,8 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &vendor, - &model_id, &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &vendor_id, + &mod_id, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); ele = l_queue_find(node->elements, match_element_path, ele_path); @@ -2290,8 +2053,7 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - vendor_mod_id = (vendor << 16) | model_id; - result = mesh_model_publish(node, vendor_mod_id, src, + result = mesh_model_vendor_publish(node, vendor_id, mod_id, src, mesh_net_get_default_ttl(node->net), data, len); if (result != MESH_ERROR_NONE) diff --git a/mesh/node.h b/mesh/node.h index df058458a..47c998530 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -58,8 +58,8 @@ bool node_default_ttl_set(struct mesh_node *node, uint8_t ttl); bool node_set_sequence_number(struct mesh_node *node, uint32_t seq); uint32_t node_get_sequence_number(struct mesh_node *node); int node_get_element_idx(struct mesh_node *node, uint16_t ele_addr); -struct l_queue *node_get_element_models(struct mesh_node *node, uint8_t ele_idx, - int *status); +struct l_queue *node_get_element_models(struct mesh_node *node, + uint8_t ele_idx); uint16_t node_get_crpl(struct mesh_node *node); bool node_init_from_storage(struct mesh_node *node, const uint8_t uuid[16], struct mesh_config_node *db_node); -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SIwaLwsDFl+OdwEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 22:48:11 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id YCQNLQsDFl+uVQAAlScrYA (envelope-from ); Mon, 20 Jul 2020 22:48:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2F42E49516; Mon, 20 Jul 2020 22:48:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbgGTUsC (ORCPT + 1 other); Mon, 20 Jul 2020 16:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726012AbgGTUsB (ORCPT ); Mon, 20 Jul 2020 16:48:01 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3549C061794; Mon, 20 Jul 2020 13:48:01 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id md7so536206pjb.1; Mon, 20 Jul 2020 13:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=W3gFxb9MTLvTnCe3A+iabUWXBAu7mA9HyhZHWgTOkUw=; b=OGmrrLECo+9bEWcObjspsB7mZd1Knz6TplGXozOrISTfqD7/NX21SXnbWcSkV3fL4v rTtVk5lWAA2Zu7uZ6u1mrfxhancqzyg3QAj3aPjlEycGVWZJlozkhUGEvXA8Lh3Zhd9y MI2pFWCUVAw0qhoczi2fzDR5o+9jsXf0u50JS+cFIfuTYX6fdThXqy7BkTGCK/dg3wkY mbds6x2z1GfwvAA0D5GwOBd9MLDFeCqWgb4tYptazoXAosQDHX7Ytsgw6xoiVQCij+q6 LhYcFToAHR8FWmsf1prWh4sudrDF50FXVoAgPYMNb7eWHKWg9zXFnQitJW8+uw6BZBn8 8EhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=W3gFxb9MTLvTnCe3A+iabUWXBAu7mA9HyhZHWgTOkUw=; b=NmiT+9oS9uGFkHRMP8aKc0bdouhlF+z3N5dmTZmMvJTuQlavya2QOjW9QZluOBDMSN Bf8iOVH8ZwsENeYxwjEQZujdZFojbyI5o/gyN8uqRyJGsRUd4CmnulXJhw4+Gy1N/tQM 4ju/0yxyaquisGWKaNo8IDmPDegmXL1hE7sGBPd37CAuuHg4bE7IRXJLKd5HezY+6rbI 57Abyx0O6OS1c4sJpbqMwZFxec+2L4ngp4CDZv566S1w3ZjoKKvtWYtElQPsITi+GpaX QeoAbDjDDjufLbC3qeDlBil3FMgGdXH7tdt3RJ0ZPfbGcZ8VCfWS6QkfnGtmwRWsDlu/ 2GXQ== X-Gm-Message-State: AOAM532xzswQCE9EmiTk87sBNFqaRV6lXN9+OTa+JTpTX2JXZ3mv7RA8 Lqgsib0ge2mJ4jEvgoQdL6o= X-Google-Smtp-Source: ABdhPJznKJm/ctwfQ0zEUlKph93VMIYlrMPvmwUzvON4KJd0PPoASWmZCQzIIZBDlRvR10ywRtQVEg== X-Received: by 2002:a17:902:a50d:: with SMTP id s13mr19573067plq.149.1595278081037; Mon, 20 Jul 2020 13:48:01 -0700 (PDT) Received: from ast-mbp.dhcp.thefacebook.com ([2620:10d:c090:400::5:e3b]) by smtp.gmail.com with ESMTPSA id m31sm455776pjb.52.2020.07.20.13.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 13:47:59 -0700 (PDT) Date: Mon, 20 Jul 2020 13:47:56 -0700 From: Alexei Starovoitov To: Christoph Hellwig Cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: get rid of the address_space override in setsockopt Message-ID: <20200720204756.iengwcguikj2yrxt@ast-mbp.dhcp.thefacebook.com> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720124737.118617-1-hch@lst.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 3 X-Rspamd-Score: 0.46 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2F42E49516 X-Rspamd-UID: 2b2e9b On Mon, Jul 20, 2020 at 02:47:13PM +0200, Christoph Hellwig wrote: > Hi Dave, > > setsockopt is the last place in architecture-independ code that still > uses set_fs to force the uaccess routines to operate on kernel pointers. > > This series adds a new sockptr_t type that can contained either a kernel > or user pointer, and which has accessors that do the right thing, and > then uses it for setsockopt, starting by refactoring some low-level > helpers and moving them over to it before finally doing the main > setsockopt method. > > Note that I could not get the eBPF selftests to work, so this has been > tested with a testing patch that always copies the data first and passes > a kernel pointer. This is something that works for most common sockopts > (and is something that the ePBF support relies on), but unfortunately > in various corner cases we either don't use the passed in length, or in > one case actually copy data back from setsockopt, so we unfortunately > can't just always do the copy in the highlevel code, which would have > been much nicer. could you rebase on bpf-next tree and we can route it this way then? we'll also test the whole thing before applying. sounds like v2 is needed anyway to address Eric's addr space concern? Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4BZpBAUJFl/ikQEAvsO+Rg (envelope-from ) for ; Mon, 20 Jul 2020 23:13:41 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id yHC6AgUJFl922wAAgupzMw (envelope-from ); Mon, 20 Jul 2020 23:13:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0558140033; Mon, 20 Jul 2020 23:13:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726530AbgGTVNe convert rfc822-to-8bit (ORCPT + 1 other); Mon, 20 Jul 2020 17:13:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:44102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726012AbgGTVNe (ORCPT ); Mon, 20 Jul 2020 17:13:34 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 20 Jul 2020 21:13:31 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: b.brahim.oussama@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0558140033 X-Rspamd-UID: 42eebc https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #108 from Oussama BEN BRAHIM (b.brahim.oussama@gmail.com) --- many thanks @Swyter.It works like a charm. This is my first time patching and building a custom kernel. It's quite fancy experience. this is lsusb output if it can help. #lsusb -vd 0a12:0001 Bus 003 Device 007: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 224 Wireless bDeviceSubClass 1 Radio Frequency bDeviceProtocol 1 Bluetooth bMaxPacketSize0 64 idVendor 0x0a12 Cambridge Silicon Radio, Ltd idProduct 0x0001 Bluetooth Dongle (HCI mode) bcdDevice 88.91 iManufacturer 0 iProduct 2 (error) iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x00b1 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 1 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 2 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 3 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 4 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 5 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 can't get debug descriptor: Resource temporarily unavailable Device Status: 0x0000 (Bus Powered) -- You are receiving this mail because: You are the assignee for the bug. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sKlCGLwmFl8oMAAAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 01:20:28 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4FGFFrwmFl8+DAEADc0bRg (envelope-from ); Tue, 21 Jul 2020 01:20:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1388140873; Tue, 21 Jul 2020 01:20:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbgGTXUW (ORCPT + 1 other); Mon, 20 Jul 2020 19:20:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726021AbgGTXUV (ORCPT ); Mon, 20 Jul 2020 19:20:21 -0400 Received: from shards.monkeyblade.net (shards.monkeyblade.net [IPv6:2620:137:e000::1:9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7C65C061794; Mon, 20 Jul 2020 16:20:21 -0700 (PDT) Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 0E8A811E8EC0A; Mon, 20 Jul 2020 16:20:16 -0700 (PDT) Date: Mon, 20 Jul 2020 16:20:13 -0700 (PDT) Message-Id: <20200720.162013.456211151711627380.davem@davemloft.net> To: stefan@datenfreihafen.org Cc: hch@lst.de, kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, edumazet@google.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 24/24] net: pass a sockptr_t into ->setsockopt From: David Miller In-Reply-To: References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-25-hch@lst.de> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 20 Jul 2020 16:20:17 -0700 (PDT) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 14 X-Rspamd-Score: 2.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1388140873 X-Rspamd-UID: d6b279 From: Stefan Schmidt Date: Mon, 20 Jul 2020 16:19:38 +0200 > For the ieee802154 part: > > Acked-by: Stefan Schmidt Please do not quote an entire patch just to add an ACK, trim it just to the commit message, or even less. Thank you. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6MdWCAVVFl/FLAEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 04:37:57 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id aKQZBwVVFl+fYQEAlScrYA (envelope-from ); Tue, 21 Jul 2020 04:37:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A382640676; Tue, 21 Jul 2020 04:37:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727991AbgGUChe (ORCPT + 1 other); Mon, 20 Jul 2020 22:37:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbgGUChd (ORCPT ); Mon, 20 Jul 2020 22:37:33 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A65E7C061794 for ; Mon, 20 Jul 2020 19:37:33 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id w2so11229545pgg.10 for ; Mon, 20 Jul 2020 19:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7iFj+VYGc+pNg7a3sKnrHzO0tOtNEDnzb7gZ2GZVQs8=; b=noElnCmRRcf07/EwPZXseNlTjLl7oyF5hncD1UoH/a7QU9ljzes9KOXJQPW87AG8oJ 35HwfsZuhrgIrCJPNU2o0mgDT9nhrM7OHmgQbsUHAPPv6rjVJptumWmlZb5aCkcmG9wp UVVRUS3MO+8/cFaXKzHgNabWiaZzRRLLUfogo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7iFj+VYGc+pNg7a3sKnrHzO0tOtNEDnzb7gZ2GZVQs8=; b=PCvXLesLasvlawCveoMrQDMlv16r5fJA4wkGsDlm99KxgSIjeinytiOYREg24QVEhC BSJ/fCijEPnvpovvRPpqXpCBAmRYMEG7tcy1kPQxXN9WRNy+IayWUTvbYQC8TYnAtaNV 3/aZunRHELIoJGRfXybstrxg8t7wcgi2QWwGmkBr9xbZ9FV3rb/Uv/aUrZka9ulh1tXx WRC/plJpz2xK2Rj8SDnPCxbkZzHzpR32ajl+DMzOwQVSYWxbQm87dDiiB2O34KnPFro5 Zi1WS47qFHF9GbtmeaNfK3PVmLAyZ9KggowY/XOP5YR0AZwljsHsXvXwoL9H1pOSOzyw MAOw== X-Gm-Message-State: AOAM532nX4hI+8q+WIJIL1NtQMV5U7u5gBqoJctGWTmRIG/aHIAAP4WY GIbnGb7ZlTVzym4Qww7auqru3Q== X-Google-Smtp-Source: ABdhPJybp2k+BYGwk3hoadcZotDg0bccX+mZOYTZdEOKiuC6mz/d1aDLcwfDGdDWCJ1he1lkB8yNGA== X-Received: by 2002:a63:e017:: with SMTP id e23mr20944311pgh.125.1595299052135; Mon, 20 Jul 2020 19:37:32 -0700 (PDT) Received: from drinkcat2.tpe.corp.google.com ([2401:fa00:1:b:7220:84ff:fe09:41dc]) by smtp.gmail.com with ESMTPSA id z6sm17888266pfn.173.2020.07.20.19.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 19:37:31 -0700 (PDT) From: Nicolas Boichat To: Marcel Holtmann Cc: Nicolas Boichat , Hans de Goede , Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] Bluetooth: hci_h5: Set HCI_UART_RESET_ON_INIT to correct flags Date: Tue, 21 Jul 2020 10:37:15 +0800 Message-Id: <20200721103652.1.Idbc7eddf1f24f750a8bbcbc8e06743736ae3be31@changeid> X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: A382640676 X-Rspamd-UID: 806b44 HCI_UART_RESET_ON_INIT belongs in hdev_flags, not flags. Fixes: ce945552fde4a09 ("Bluetooth: hci_h5: Add support for serdev enumerated devices") Signed-off-by: Nicolas Boichat --- drivers/bluetooth/hci_h5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index e60b2e0773db110..e41854e0d79aae2 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c @@ -793,7 +793,7 @@ static int h5_serdev_probe(struct serdev_device *serdev) if (!h5) return -ENOMEM; - set_bit(HCI_UART_RESET_ON_INIT, &h5->serdev_hu.flags); + set_bit(HCI_UART_RESET_ON_INIT, &h5->serdev_hu.hdev_flags); h5->hu = &h5->serdev_hu; h5->serdev_hu.serdev = serdev; -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4EkVGw9VFl/FLAEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 04:38:07 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MIqfGQ9VFl/R0QEAgupzMw (envelope-from ); Tue, 21 Jul 2020 04:38:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F3AA541C0A; Tue, 21 Jul 2020 04:38:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728307AbgGUChh (ORCPT + 1 other); Mon, 20 Jul 2020 22:37:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbgGUChg (ORCPT ); Mon, 20 Jul 2020 22:37:36 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6689AC0619D5 for ; Mon, 20 Jul 2020 19:37:36 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a9so828236pjd.3 for ; Mon, 20 Jul 2020 19:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TY8XfCON4S0JDepfGrFgWfYRJOwnBuFe9fcLJ+y+GUE=; b=MT9XwQvk7j9jaVTNDu33PSB3paK7rMOToCBADL8lAhj8gfTegZZY0dRfXMdKpbwIsl WT2qUkCmWI5WetdDngau1iznOVAqPUFe3M1Pbnsy34yKF3EDeLkJcL1uG1E1EZs5d1jr 6GJgb8m8HGh1IC//kNuLNntIXuRVewVb4EtGA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TY8XfCON4S0JDepfGrFgWfYRJOwnBuFe9fcLJ+y+GUE=; b=eVp5m+16+SVN6QgMC/v1rEcK3780PIdCI0/wHuFQ0AYLNSS3OZ+foMUNjnqiTgcaDS felMw4bBPkIB9ivAw387FeoLyd1X8k43pCf663Q3kJ+i19lvhm/0PUwmR7OEHxgFTsuA TQZGrFqCt58LPhWjjYE2uKbCsbWu1tUYnRmHTWekHLQcU4CBwnp+S16VXYntvIQ4y+k/ ThRqw4P9wMsKzE+NQL6Eb4eZI0nPQ6/8M9Zsxcmu2WxnIxeNhiqlXk6gCVFDSsvW5HM3 LlehwIxGVfzWEEzaBoJbotleZdAVaK7g7eXYjXSN42K67eieBPmM5vIfodlUWd/wfF+2 p1Ww== X-Gm-Message-State: AOAM531yNhGdvDkMO64zclw3lW6IN3r7WXoQj6Wdqk/AndrrNqTl2lXE iFfpOot7ek4TK/qUnK9+tCMTWQ== X-Google-Smtp-Source: ABdhPJwifeShuy9aax97sR/LrIOKU8AKLyOW/DZJQT86QH8j0OfGEcNJxiqcAH9HAEPFwoFMNFLi9A== X-Received: by 2002:a17:902:547:: with SMTP id 65mr20764059plf.256.1595299055940; Mon, 20 Jul 2020 19:37:35 -0700 (PDT) Received: from drinkcat2.tpe.corp.google.com ([2401:fa00:1:b:7220:84ff:fe09:41dc]) by smtp.gmail.com with ESMTPSA id z6sm17888266pfn.173.2020.07.20.19.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 19:37:35 -0700 (PDT) From: Nicolas Boichat To: Marcel Holtmann Cc: Nicolas Boichat , Ian Molton , Johan Hedberg , Sebastian Reichel , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] Bluetooth: hci_serdev: Only unregister device if it was registered Date: Tue, 21 Jul 2020 10:37:16 +0800 Message-Id: <20200721103652.2.I8a2fdad30d42399fa5afc15d66b460d1738c3946@changeid> X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog In-Reply-To: <20200721103652.1.Idbc7eddf1f24f750a8bbcbc8e06743736ae3be31@changeid> References: <20200721103652.1.Idbc7eddf1f24f750a8bbcbc8e06743736ae3be31@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 29 X-Rspamd-Score: 4.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: F3AA541C0A X-Rspamd-UID: d3db8c We should not call hci_unregister_dev if the device was not successfully registered. Fixes: c34dc3bfa7642fd ("Bluetooth: hci_serdev: Introduce hci_uart_unregister_device()") Signed-off-by: Nicolas Boichat --- drivers/bluetooth/hci_serdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index 599855e4c57c13d..7b233312e723fb2 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -355,7 +355,8 @@ void hci_uart_unregister_device(struct hci_uart *hu) struct hci_dev *hdev = hu->hdev; clear_bit(HCI_UART_PROTO_READY, &hu->flags); - hci_unregister_dev(hdev); + if (test_bit(HCI_UART_REGISTERED, &hu->flags)) + hci_unregister_dev(hdev); hci_free_dev(hdev); cancel_work_sync(&hu->write_work); -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uBYBA6lVFl/FLAEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 04:40:41 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yGwaAalVFl/SWwEAlScrYA (envelope-from ); Tue, 21 Jul 2020 04:40:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 72602A0FCC; Tue, 21 Jul 2020 04:40:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727818AbgGUCkV (ORCPT + 1 other); Mon, 20 Jul 2020 22:40:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbgGUCkU (ORCPT ); Mon, 20 Jul 2020 22:40:20 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BA0CC061794; Mon, 20 Jul 2020 19:40:20 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id o18so20085596eje.7; Mon, 20 Jul 2020 19:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=uGJfiXXxVHM7zniHW3sl0xVltZ7h7OdT0FRQ5H6GgQM=; b=OeoCW/0tbvMmfJG3/GXVxS0sf0NU1F3vv5ek0RwSeUB4oL3xBRF4212opG/Qca2oMt w/LznXXPQ/9latRxVyAN7HoUeXaNxvpuCBnCtE8R4VgfJiFrlJWGUZ3AudCWWBSFASY5 rHitPZwk5CzwZGC9yY+cINRMFHfhNoff5Hs0bqMLp86BM3TNE6gCd0fujLU9Jp1gGqkn fbgcZ3ejttQ6DUlGWTOX05MbhnYkq6NEeVjuv6BJvSSMm0lLza1F8vnXHY24yVrWhuUw mE4fVqq6wL70udwjlBJkWv9YZBUUfIIT74p06ZRe0yu4iR7nwWtzJQYm2S7oIsa47DMh Anhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uGJfiXXxVHM7zniHW3sl0xVltZ7h7OdT0FRQ5H6GgQM=; b=GHjMlunOBJHywoda8QvnUbXzKcpxcToPi5q96IB0nS8SV/0w9n9vzOTdLuLBkJfa66 Wx+so/SDt0UFrPX51D8RnHdX40HSdnl6kE/k6vZO4s9ue44FnSEti2xAj4QsHxi1ZuS8 n8bgQ5tsoUDpMlL93DF5xblWvbQ3H5eghxR0Mtzi2I4CAj6rrdbmLsCHl38hninxxXoX 76ZXWvblM4Uf1Fxl+4ZiPTOjHMLC4IbkIchoKtoGeeZKJjpz15SvX2Oa5LjhyljEa0fI 5MhVKEix35nP+fLDc3sQBkgL5fxi5KKKVrhwepSVfiwSc8W9UIKYcgBLIIbj4vBZqYxE R3cw== X-Gm-Message-State: AOAM530XQWjOFj5xGhVnLVxnH6MpDNXehwO5Bs0Rwte4hqLm1r0Q6JKr qlYP/tURkjHiGQun4RSN6ds= X-Google-Smtp-Source: ABdhPJxwHHfj4AzpvPUUwMsSPbeGFb02Lr8Q1E98GpxaDKbKNy5p2S/jP2546lXFLYroLU3vdKdQBA== X-Received: by 2002:a17:906:c41:: with SMTP id t1mr23432470ejf.18.1595299219166; Mon, 20 Jul 2020 19:40:19 -0700 (PDT) Received: from ltop.local ([2a02:a03f:a7fb:e200:d978:aa6c:4528:f5b1]) by smtp.gmail.com with ESMTPSA id y22sm15676844ejj.67.2020.07.20.19.40.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 19:40:18 -0700 (PDT) Date: Tue, 21 Jul 2020 04:40:16 +0200 From: Luc Van Oostenryck To: Christoph Hellwig Cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 02/24] bpfilter: fix up a sparse annotation Message-ID: <20200721024016.2talwdt5hjqvirr6@ltop.local> References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-3-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720124737.118617-3-hch@lst.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 72602A0FCC X-Rspamd-UID: 5c65f4 On Mon, Jul 20, 2020 at 02:47:15PM +0200, Christoph Hellwig wrote: > The __user doesn't make sense when casting to an integer type. > > Signed-off-by: Christoph Hellwig > --- > net/bpfilter/bpfilter_kern.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c > index 977e9dad72ca4f..713b4b3d02005d 100644 > --- a/net/bpfilter/bpfilter_kern.c > +++ b/net/bpfilter/bpfilter_kern.c > @@ -49,7 +49,7 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname, > req.is_set = is_set; > req.pid = current->pid; > req.cmd = optname; > - req.addr = (long __force __user)optval; > + req.addr = (__force long)optval; For casts to integers, even '__force' is not needed (since integers can't be dereferenced, the concept of address-space is meaningless for them, so it's never useful to warn when it's dropped and '__force' is thus not needed). -- Luc Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CN/2HOd7Fl/SxgEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 07:23:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id GPFEG+d7Fl+LXQAAlp8NpQ (envelope-from ); Tue, 21 Jul 2020 07:23:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8D3E84DDF1; Tue, 21 Jul 2020 07:23:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726677AbgGUFXc (ORCPT + 1 other); Tue, 21 Jul 2020 01:23:32 -0400 Received: from verein.lst.de ([213.95.11.211]:50572 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbgGUFXc (ORCPT ); Tue, 21 Jul 2020 01:23:32 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id B86216736F; Tue, 21 Jul 2020 07:23:26 +0200 (CEST) Date: Tue, 21 Jul 2020 07:23:26 +0200 From: Christoph Hellwig To: Luc Van Oostenryck Cc: Christoph Hellwig , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 02/24] bpfilter: fix up a sparse annotation Message-ID: <20200721052326.GA10071@lst.de> References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-3-hch@lst.de> <20200721024016.2talwdt5hjqvirr6@ltop.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200721024016.2talwdt5hjqvirr6@ltop.local> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 22 X-Rspamd-Score: 3.35 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8D3E84DDF1 X-Rspamd-UID: a369e2 On Tue, Jul 21, 2020 at 04:40:16AM +0200, Luc Van Oostenryck wrote: > > req.pid = current->pid; > > req.cmd = optname; > > - req.addr = (long __force __user)optval; > > + req.addr = (__force long)optval; > > For casts to integers, even '__force' is not needed (since integers > can't be dereferenced, the concept of address-space is meaningless > for them, so it's never useful to warn when it's dropped and > '__force' is thus not needed). That's what I thought. but if I remove it here I actually do get a warning: CHECK net/bpfilter/bpfilter_kern.c net/bpfilter/bpfilter_kern.c:52:21: warning: cast removes address space '__user' of expression Using this recent sparse build: hch@brick:~/work/linux$ sparse --version v0.6.2-49-g707c5017 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0MCOOjh9Fl+A1gEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 07:29:28 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cKnfODh9Fl96QQAADc0bRg (envelope-from ); Tue, 21 Jul 2020 07:29:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 061DAA21F5; Tue, 21 Jul 2020 07:29:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726981AbgGUF3K (ORCPT + 1 other); Tue, 21 Jul 2020 01:29:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725294AbgGUF3K (ORCPT ); Tue, 21 Jul 2020 01:29:10 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F002FC061794; Mon, 20 Jul 2020 22:29:09 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxkpB-00H0WY-9x; Tue, 21 Jul 2020 05:28:21 +0000 Date: Tue, 21 Jul 2020 06:28:21 +0100 From: Al Viro To: Christoph Hellwig Cc: Luc Van Oostenryck , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 02/24] bpfilter: fix up a sparse annotation Message-ID: <20200721052821.GS2786714@ZenIV.linux.org.uk> References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-3-hch@lst.de> <20200721024016.2talwdt5hjqvirr6@ltop.local> <20200721052326.GA10071@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200721052326.GA10071@lst.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 5 X-Rspamd-Score: 0.79 / 15.00 / 200.00 X-Rspamd-Queue-Id: 061DAA21F5 X-Rspamd-UID: 7b3df3 On Tue, Jul 21, 2020 at 07:23:26AM +0200, Christoph Hellwig wrote: > On Tue, Jul 21, 2020 at 04:40:16AM +0200, Luc Van Oostenryck wrote: > > > req.pid = current->pid; > > > req.cmd = optname; > > > - req.addr = (long __force __user)optval; > > > + req.addr = (__force long)optval; > > > > For casts to integers, even '__force' is not needed (since integers > > can't be dereferenced, the concept of address-space is meaningless > > for them, so it's never useful to warn when it's dropped and > > '__force' is thus not needed). > > That's what I thought. but if I remove it here I actually do get a > warning: > > CHECK net/bpfilter/bpfilter_kern.c > net/bpfilter/bpfilter_kern.c:52:21: warning: cast removes address space '__user' of expression Cast to unsigned long. Or to uintptr_t if you want to be fancy. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SABtLEqpFl85LgEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 10:37:30 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id cEyBK0qpFl/XpwAA0J78UA (envelope-from ); Tue, 21 Jul 2020 10:37:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0A68C4AB0B; Tue, 21 Jul 2020 10:37:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728825AbgGUIhO convert rfc822-to-8bit (ORCPT + 1 other); Tue, 21 Jul 2020 04:37:14 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:33734 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728275AbgGUIhC (ORCPT ); Tue, 21 Jul 2020 04:37:02 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-210-Hj1lpiGkPReD_62cmwnEEw-1; Tue, 21 Jul 2020 09:36:58 +0100 X-MC-Unique: Hj1lpiGkPReD_62cmwnEEw-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 21 Jul 2020 09:36:57 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 21 Jul 2020 09:36:57 +0100 From: David Laight To: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , "Daniel Borkmann" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet CC: "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: RE: [PATCH 12/24] bpfilter: switch bpfilter_ip_set_sockopt to sockptr_t Thread-Topic: [PATCH 12/24] bpfilter: switch bpfilter_ip_set_sockopt to sockptr_t Thread-Index: AQHWXznUwerjSVAdx0W80SUXvcknn6kRtZIA Date: Tue, 21 Jul 2020 08:36:57 +0000 Message-ID: References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-13-hch@lst.de> In-Reply-To: <20200720124737.118617-13-hch@lst.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 28 X-Rspamd-Score: 4.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0A68C4AB0B X-Rspamd-UID: b6c5f8 From: Christoph Hellwig > Sent: 20 July 2020 13:47 > > This is mostly to prepare for cleaning up the callers, as bpfilter by > design can't handle kernel pointers. ^^^ user ?? David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qCEhH2q4Fl+ZiQEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 11:42:02 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id qGmeHWq4Fl+AogAA0J78UA (envelope-from ); Tue, 21 Jul 2020 11:42:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BA4E1A19E1; Tue, 21 Jul 2020 11:41:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728818AbgGUJii convert rfc822-to-8bit (ORCPT + 1 other); Tue, 21 Jul 2020 05:38:38 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:57945 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727038AbgGUJi3 (ORCPT ); Tue, 21 Jul 2020 05:38:29 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-217-o-9Oq5ZpNDO7uw1k_-mRfA-1; Tue, 21 Jul 2020 10:38:24 +0100 X-MC-Unique: o-9Oq5ZpNDO7uw1k_-mRfA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 21 Jul 2020 10:38:23 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 21 Jul 2020 10:38:23 +0100 From: David Laight To: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , "Daniel Borkmann" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet CC: "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: RE: get rid of the address_space override in setsockopt Thread-Topic: get rid of the address_space override in setsockopt Thread-Index: AQHWXznU7Ce8ImOXV0WGgKrMes+hhakRxpwA Date: Tue, 21 Jul 2020 09:38:23 +0000 Message-ID: <60c52e31e9f240718fcda0dd5c2faeca@AcuMS.aculab.com> References: <20200720124737.118617-1-hch@lst.de> In-Reply-To: <20200720124737.118617-1-hch@lst.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: BA4E1A19E1 X-Rspamd-UID: 4adaef From: Christoph Hellwig > Sent: 20 July 2020 13:47 > > setsockopt is the last place in architecture-independ code that still > uses set_fs to force the uaccess routines to operate on kernel pointers. > > This series adds a new sockptr_t type that can contained either a kernel > or user pointer, and which has accessors that do the right thing, and > then uses it for setsockopt, starting by refactoring some low-level > helpers and moving them over to it before finally doing the main > setsockopt method. Are you planning to make the equivalent change to getsockopt()? Having mismatched interfaces would be very strange. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AApjC6e7Fl+ViQEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 11:55:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iDmUCae7Fl+vrwAAlScrYA (envelope-from ); Tue, 21 Jul 2020 11:55:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8C8A84E6C3; Tue, 21 Jul 2020 11:55:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726531AbgGUJz1 convert rfc822-to-8bit (ORCPT + 1 other); Tue, 21 Jul 2020 05:55:27 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:28619 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGUJzZ (ORCPT ); Tue, 21 Jul 2020 05:55:25 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-262-05FU3YgoN0uQBLOw_0F_FQ-1; Tue, 21 Jul 2020 10:55:21 +0100 X-MC-Unique: 05FU3YgoN0uQBLOw_0F_FQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 21 Jul 2020 10:55:20 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 21 Jul 2020 10:55:20 +0100 From: David Laight To: 'Eric Biggers' , Christoph Hellwig CC: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: RE: [PATCH 03/24] net: add a new sockptr_t type Thread-Topic: [PATCH 03/24] net: add a new sockptr_t type Thread-Index: AQHWXrQmuUX3yUokMEqukKul+fTtiakRycQA Date: Tue, 21 Jul 2020 09:55:20 +0000 Message-ID: <9b7ae3245bad474db2a3889bc1c1a329@AcuMS.aculab.com> References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-4-hch@lst.de> <20200720163748.GA1292162@gmail.com> In-Reply-To: <20200720163748.GA1292162@gmail.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.52 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8C8A84E6C3 X-Rspamd-UID: 162e5b From: Eric Biggers > Sent: 20 July 2020 17:38 ... > How does this not introduce a massive security hole when > CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE? > > AFAICS, userspace can pass in a pointer >= TASK_SIZE, > and this code makes it be treated as a kernel pointer. One thought I've had is that on 64-bit architectures there is almost always some part of the KVA that can never be valid and is larger than the maximum size of a user VA. If the user address is offset into this invalid area then it can always be distinguished from a kernel address. Indeed it may be worth considering offsetting kernel addresses as well. This forces code to use the correct accessors. It doesn't solve the problem for 32bit systems with CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE since they are likely to have all 32bit addresses available to both use and kernel. If you end up with a 'fat pointer' then it may be worth adding the length and making it a 'buffer descriptor'. This can then be passed by address and the reduced number of parameters will probably offset the cost of the extra indirection. The read/write functions could then take the 'buffer descriptor', offset and length as parameters. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kJLWJKfAFl951gEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 12:17:11 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EGVxI6fAFl/ucgEAlp8NpQ (envelope-from ); Tue, 21 Jul 2020 12:17:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8A259A193B; Tue, 21 Jul 2020 12:16:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729144AbgGUKOZ convert rfc822-to-8bit (ORCPT + 1 other); Tue, 21 Jul 2020 06:14:25 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:43147 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729051AbgGUKOY (ORCPT ); Tue, 21 Jul 2020 06:14:24 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-138-nfvRhVVmO1WenzQxH6ebBA-1; Tue, 21 Jul 2020 11:14:21 +0100 X-MC-Unique: nfvRhVVmO1WenzQxH6ebBA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 21 Jul 2020 11:14:20 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 21 Jul 2020 11:14:20 +0100 From: David Laight To: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , "Daniel Borkmann" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet CC: "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: RE: [PATCH 03/24] net: add a new sockptr_t type Thread-Topic: [PATCH 03/24] net: add a new sockptr_t type Thread-Index: AQHWXznVP/p0ivee+U2FmRNemPQri6kRzhiA Date: Tue, 21 Jul 2020 10:14:20 +0000 Message-ID: <6727969f2f6e467fa2d43f9773cefa27@AcuMS.aculab.com> References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-4-hch@lst.de> In-Reply-To: <20200720124737.118617-4-hch@lst.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8A259A193B X-Rspamd-UID: dec458 From: Christoph Hellwig > Sent: 20 July 2020 13:47 > > Add a uptr_t type that can hold a pointer to either a user or kernel > memory region, and simply helpers to copy to and from it. For > architectures like x86 that have non-overlapping user and kernel > address space it just is a union and uses a TASK_SIZE check to > select the proper copy routine. For architectures with overlapping > address spaces a flag to indicate the address space is used instead. > ... > +#else /* CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE */ > +typedef struct { > + union { > + void *kernel; > + void __user *user; > + }; > + bool is_kernel : 1; > +} sockptr_t; If you need to do that you might as well make it a struct where either the kernel or user address is defined. Far safer for all architectures. Indeed you could add the length (to save passing an extra parameter through the layers). The system call code could even copy the code into a kernel buffer (setting both pointers). So that code that didn't need to access beyond the end of the implied buffer (most of it) could just access the kernel buffer. For getsockopt() you'd need some way of supressing the 'default' copy back of the user buffer. This would also allow some of the sctp getsockopt to read (usually 4 bytes) from the 'user' buffer without the wrapper code always having to read in the entire user buffer. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yFJHFpvDFl951gEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 12:29:47 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AOPuFJvDFl/xPQEADc0bRg (envelope-from ); Tue, 21 Jul 2020 12:29:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A1981A26DA; Tue, 21 Jul 2020 12:29:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729216AbgGUK1F convert rfc822-to-8bit (ORCPT + 1 other); Tue, 21 Jul 2020 06:27:05 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:43926 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728005AbgGUK1E (ORCPT ); Tue, 21 Jul 2020 06:27:04 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-165-VkETpnrTNNiCTn0jftGBVw-1; Tue, 21 Jul 2020 11:27:00 +0100 X-MC-Unique: VkETpnrTNNiCTn0jftGBVw-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 21 Jul 2020 11:26:58 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 21 Jul 2020 11:26:58 +0100 From: David Laight To: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , "Daniel Borkmann" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet CC: "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: RE: get rid of the address_space override in setsockopt Thread-Topic: get rid of the address_space override in setsockopt Thread-Index: AQHWXznU7Ce8ImOXV0WGgKrMes+hhakR08Lg Date: Tue, 21 Jul 2020 10:26:58 +0000 Message-ID: References: <20200720124737.118617-1-hch@lst.de> In-Reply-To: <20200720124737.118617-1-hch@lst.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 28 X-Rspamd-Score: 4.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: A1981A26DA X-Rspamd-UID: 667a9a From: Christoph Hellwig > Sent: 20 July 2020 13:47 > > setsockopt is the last place in architecture-independ code that still > uses set_fs to force the uaccess routines to operate on kernel pointers. > > This series adds a new sockptr_t type that can contained either a kernel > or user pointer, and which has accessors that do the right thing, and > then uses it for setsockopt, starting by refactoring some low-level > helpers and moving them over to it before finally doing the main > setsockopt method. Another 'gotcha' ... On an least some architectures (possibly only m68k) IIRC all structures are actually passed by reference. (This used to be true for sparc - but it may have changed in the last 30 years.) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yKVHLHARF1+WuAEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 18:01:52 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 0ALkKnARF18RkwAADc0bRg (envelope-from ); Tue, 21 Jul 2020 18:01:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CF90540AD3; Tue, 21 Jul 2020 18:01:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727860AbgGUQBp (ORCPT + 1 other); Tue, 21 Jul 2020 12:01:45 -0400 Received: from mga04.intel.com ([192.55.52.120]:42328 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbgGUQBp (ORCPT ); Tue, 21 Jul 2020 12:01:45 -0400 IronPort-SDR: BXz0qh4F/JVHoelj0Pkr+5De/XkzYC6gB0YFbvZL8788LvW9E3PEzGtpPeKAaeHcf8/D9VlfLO Ym+xeF23izzA== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="147663262" X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="147663262" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 09:01:44 -0700 IronPort-SDR: K1wXDL88bkwSwOTc3TfhUavD4gBxCTqVeaZ8l4un6GWIvNhCeE2QY6JSMFQ91fQCGDNEoXZod3 /BcNPf5LGi8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="326412860" Received: from orsmsx101.amr.corp.intel.com ([10.22.225.128]) by FMSMGA003.fm.intel.com with ESMTP; 21 Jul 2020 09:01:44 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX101.amr.corp.intel.com (10.22.225.128) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 21 Jul 2020 09:01:44 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 21 Jul 2020 09:01:43 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 21 Jul 2020 09:01:43 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.48) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 21 Jul 2020 09:01:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hF/oRY/s//oTxojQrbtJvjyMBoKFJDOYXb9UEfmf5RUw3rUWZSBt2l/989Qr4bEGZR8UC1v58E7iO2gJ+ClTkB15h9cxo9EXK+0oG1rK74BrksyTAFBp2X+I/t2u0T+CnsicPXocF/z+4s6V7Oho37opTmI1Z2W35Vwt1uAMADa8e/oW8DnRa14MBNxxryeVzD9dvg52dLE6z/4bGixV3oJ40oyZfied7O/veRCj/vkOVddUvWjZrSB4Y1EgaZy7NXAemZH40YNYp9NtEPxKCui8Ylx4X5R9ZvdsI5Ss+ag32oteZwWrVzA99hMwiqUgLEY6CEWgptLjc8790yfgUQ== 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-SenderADCheck; bh=PBJiqsqmro1IOFMzZ2zTsqfgaTYtJDcr5PXr9+WTo6o=; b=KKsO9TyiVZGT7CD9L86cB97ORCeFCBJGAVcIqpDRR2aue+BAdKekaQc8IMRWeJ75HrCEhdqIFa71MRPD0MupBow53w7RYdGRKVCXLTXSeopVOi+qOZqQyvIjoM2YWyqT31Ej992jThz0qv3CmaSzyHc0xj/y9sk5BHbOyUfWIBCrtUKlvNgPFqcUXcZDfYfAabpG3qGfFd5CaMrF1gsIPZ8H7RPQ7CYkdbxHpiO9Hcz3LwpdmaRRN7q2xR1XXCalluy2QXjBsQmEmdf/Kdyy6ci4EIQ2VI56V4Pv3Gj+iNAcgWf+yyeo0ObgFYwUKO2TwieYeLymllNweapNNfdnXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PBJiqsqmro1IOFMzZ2zTsqfgaTYtJDcr5PXr9+WTo6o=; b=hySFkPddMEO2uPIloanCLnAP574Z4uWJvJ3Uk90l7vngRQOJqGJGlzPyzmKrbwhlMN+WUIoBrhBz7QT52Uacty3GLMVmHwhGlpeCD24rSFXV2lSC65E3dL2DsKBp2JxnkntjuTV83pF+adVmafFfjV4UejOypAAsKdMRD3TfTco= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1376.namprd11.prod.outlook.com (2603:10b6:300:1d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.23; Tue, 21 Jul 2020 16:01:41 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3216.020; Tue, 21 Jul 2020 16:01:41 +0000 From: "Gix, Brian" To: "linux-bluetooth@vger.kernel.org" , "Stotland, Inga" Subject: Re: [PATCH BlueZ] tools/mesh-cfgclient: Fix segfault on remote node reset Thread-Topic: [PATCH BlueZ] tools/mesh-cfgclient: Fix segfault on remote node reset Thread-Index: AQHWXtZDXFR1ETe+P0KWJmGsKkycbKkSMsQA Date: Tue, 21 Jul 2020 16:01:41 +0000 Message-ID: <8c8c7b2470be83516d4868b52ff655bab9646a13.camel@intel.com> References: <20200720204206.226761-1-inga.stotland@intel.com> In-Reply-To: <20200720204206.226761-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.39] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 233c4920-67bc-41f5-d73f-08d82d8f5b93 x-ms-traffictypediagnostic: MWHPR11MB1376: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:114; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: peqIcGExNIoTPHXHWN5pimFuQjdItGC/Tb0lVsh14erz8qq9VbCljWABLKNnEwxwMTo2i6DSt9BczlWQ0LO5c93JRbz3pQVnnUjA85N6CQf8ozHFl3jD9Kb7sCtxerIYXcirScXfp8udMFIxaQQwOiPHLb7r9jQP6lBttdwtwjWU5eHAelOMXZU71MoYPglYyTa70oDfXBPlAHibPYUfxQPQyrtw606ATEQv5DI20mjzUihE1+v0A7RLLlsefxFS89tWOieypu5RjHkH0vqPyvLuO4x6+oCd3s6ZzOWPfG8erhAXf4CDqWv8N+jqpCgUA//SL8ofTTVdaEHTJ+6UdA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(366004)(396003)(376002)(39860400002)(6506007)(26005)(186003)(5660300002)(478600001)(316002)(110136005)(71200400001)(2906002)(86362001)(36756003)(6486002)(66446008)(64756008)(66476007)(76116006)(91956017)(66946007)(2616005)(66556008)(8676002)(6512007)(83380400001)(8936002)(6636002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: zF42h4cysN7XmTj91YdDQc3ECph9T/uXxpdRZkzXWhs7bJPVTGu7O3S6MjX87bBKJ7XlKZydXBsbjOrd7/PUinl9DzkNYb7Ig48tXR9v2py4VKWHJ4Y0jz3zrY4+W42u9DcW7hWgTyFZgo8GYexuq+Pu2HB5L/qZeHPisOOWDhXQLlzCc6y5TWeL87yBMJqZPGSvYRiuhyyjuyC1sEDW2oeSo4170yo8/lEARv3myUQSEXxjObUOtOmKMIOkQWiK7zJRzWwx7uH3tpL0HhSKHT3MCmR01WXqeJdvw0OXBiIfCtjhHOBx8eDaUIgWhxGS7WxL+cHjnWAtMYH8vDH+aCik0uX3PC5+XBwW0Dn25CqFbUUSG5nrGpI+fLj0AopxJgxBvFJg9qiR9izTNi0M/pvNjEYgNMhV273jSxpa/UCSsPHLmFr6Ov71It3AfS6Fi3Q88u2ocOT0JX3M8wng/iHY6RMThN9YGylidTq/uII= Content-Type: text/plain; charset="utf-8" Content-ID: <218A2629E8A289419571B3D8CF53C6A9@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 233c4920-67bc-41f5-d73f-08d82d8f5b93 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jul 2020 16:01:41.0922 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Y2nQNTVs8pMVdCwjIl+lvAsVN1iIa/Su9V7UzJHOCdsMiQjdVPTnQTk8uXLqzdvVzGzMfdxaeqZI/aMvhXPffg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1376 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 10 X-Rspamd-Score: 1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: CF90540AD3 X-Rspamd-UID: 253de0 QXBwbGllZA0KT24gTW9uLCAyMDIwLTA3LTIwIGF0IDEzOjQyIC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBUaGlzIGZpeGVzIGEgc2VnZmF1bHQgdGhhdCBpcyBjYXVzZWQgYnkgZnJlZWVp bmcgbm9uLWFsbG9jYXRlZCBtZW1vcnkuDQo+IEhhcHBlbnMgdXBvbiB0aGUgcmVtb3ZhbCBvZiBh IHJlbW90ZSBub2RlIHdoZW4gcmVtb3RlJ3MgbmV0IGtleSBhbmQvb3INCj4gYXBwIGtleSBxdWV1 ZXMgYXJlIGRlc3Ryb3llZC4NCj4gDQo+IF9fR0lfX19saWJjX2ZyZWUgKG1lbT0weDEpIGF0IG1h bGxvYy5jOjMxMDINCj4gICAgIGRlc3Ryb3k9ZGVzdHJveUBlbnRyeT0weDU1NzYxZjYzYTNiMCA8 bF9mcmVlPikgYXQgZWxsL3F1ZXVlLmM6MTA3DQo+ICAgICBkZXN0cm95PWRlc3Ryb3lAZW50cnk9 MHg1NTc2MWY2M2EzYjAgPGxfZnJlZT4pIGF0IGVsbC9xdWV1ZS5jOjgyDQo+ICAgICBhdCB0b29s cy9tZXNoL3JlbW90ZS5jOjE0MA0KPiAgICAgYXQgdG9vbHMvbWVzaC9jZmdjbGkuYzo3NjQNCj4g ICAgIGF0IHRvb2xzL21lc2gvY2ZnY2xpLmM6NzY0DQo+ICAgICBtc2c9MHg1NTc2MjEzYWE2ZjAs IHVzZXJfZGF0YT08b3B0aW1pemVkIG91dD4pDQo+ICAgICBhdCB0b29scy9tZXNoLWNmZ2NsaWVu dC5jOjE1MjINCj4gICAgIGRidXM9ZGJ1c0BlbnRyeT0weDU1NzYyMTMyZjg2MCwgbWVzc2FnZT1t ZXNzYWdlQGVudHJ5PTB4NTU3NjIxM2FhNmYwKQ0KPiAgICAgYXQgZWxsL2RidXMtc2VydmljZS5j OjE3OTMNCj4gICAgIHVzZXJfZGF0YT0weDU1NzYyMTMyZjg2MCkgYXQgZWxsL2RidXMuYzoyODUN Cj4gICAgIHVzZXJfZGF0YT0weDU1NzYyMTMyZjk0MCkgYXQgZWxsL2lvLmM6MTI2DQo+IC0tLQ0K PiAgdG9vbHMvbWVzaC9yZW1vdGUuYyB8IDUgKysrLS0NCj4gIDEgZmlsZSBjaGFuZ2VkLCAzIGlu c2VydGlvbnMoKyksIDIgZGVsZXRpb25zKC0pDQo+IA0KPiBkaWZmIC0tZ2l0IGEvdG9vbHMvbWVz aC9yZW1vdGUuYyBiL3Rvb2xzL21lc2gvcmVtb3RlLmMNCj4gaW5kZXggMmE4Zjc0N2Q2Li5jNzRm MGJlYzEgMTAwNjQ0DQo+IC0tLSBhL3Rvb2xzL21lc2gvcmVtb3RlLmMNCj4gKysrIGIvdG9vbHMv bWVzaC9yZW1vdGUuYw0KPiBAQCAtMTM0LDEwICsxMzQsMTEgQEAgdWludDhfdCByZW1vdGVfZGVs X25vZGUodWludDE2X3QgdW5pY2FzdCkNCj4gIAkJbF9xdWV1ZV9kZXN0cm95KHJtdC0+ZWxzW2ld LCBOVUxMKTsNCj4gIAkJcmVtb3RlX2FkZF9ibGFja2xpc3RlZF9hZGRyZXNzKHVuaWNhc3QgKyBp LCBpdl9pbmRleCwgdHJ1ZSk7DQo+ICAJfQ0KPiArDQo+ICAJbF9mcmVlKHJtdC0+ZWxzKTsNCj4g IA0KPiAtCWxfcXVldWVfZGVzdHJveShybXQtPm5ldF9rZXlzLCBsX2ZyZWUpOw0KPiAtCWxfcXVl dWVfZGVzdHJveShybXQtPmFwcF9rZXlzLCBsX2ZyZWUpOw0KPiArCWxfcXVldWVfZGVzdHJveShy bXQtPm5ldF9rZXlzLCBOVUxMKTsNCj4gKwlsX3F1ZXVlX2Rlc3Ryb3kocm10LT5hcHBfa2V5cywg TlVMTCk7DQo+ICAJbF9mcmVlKHJtdCk7DQo+ICANCj4gIAltZXNoX2RiX2RlbF9ub2RlKHVuaWNh c3QpOw0K Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WAxME2I6F189kAAAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 20:56:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 0MCKEWI6F19y0wAA0J78UA (envelope-from ); Tue, 21 Jul 2020 20:56:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 94AF8A0110; Tue, 21 Jul 2020 20:56:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730464AbgGUS40 (ORCPT + 1 other); Tue, 21 Jul 2020 14:56:26 -0400 Received: from mxout03.lancloud.ru ([89.108.73.187]:44372 "EHLO mxout03.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726499AbgGUS4Z (ORCPT ); Tue, 21 Jul 2020 14:56:25 -0400 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout03.lancloud.ru 9268F21BD66F Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH RFC] bluetooth: add support for some old headsets From: Sergey Shtylyov To: Marcel Holtmann CC: Johan Hedberg , Bluetooth Kernel Mailing List , "David S. Miller" , Jakub Kicinski , , "Ildar Kamaletdinov" References: <6f461412-a6c0-aa53-5e74-394e278ee9b1@omprussia.ru> <1834765D-52E6-45B8-9923-778C9182CFA9@holtmann.org> <848144D3-85F9-47F8-8CDA-02457FA7530F@holtmann.org> <0c2a8da1-6071-6597-d0d1-32ce1490aba7@omprussia.ru> Organization: Open Mobile Platform, LLC Message-ID: <6f271bf7-04ee-c971-9c69-de3f696769ed@omprussia.ru> Date: Tue, 21 Jul 2020 21:56:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <0c2a8da1-6071-6597-d0d1-32ce1490aba7@omprussia.ru> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [213.87.161.224] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1908.lancloud.ru (fd00:f066::208) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 3 X-Rspamd-Score: 0.55 / 15.00 / 200.00 X-Rspamd-Queue-Id: 94AF8A0110 X-Rspamd-UID: 489e52 Hello! On 7/17/20 10:12 PM, Sergey Shtylyov wrote: >>>>> The MediaTek Bluetooth platform (MT6630 etc.) has a peculiar implementation >>>>> for the eSCO/SCO connection via BT/EDR: the host controller returns error >>>>> code 0x20 (LMP feature not supported) for HCI_Setup_Synchronous_Connection >>>>> (0x0028) command without actually trying to setup connection with a remote >>>>> device in case such device (like Digma BT-14 headset) didn't advertise its >>>>> supported features. Even though this doesn't break compatibility with the >>>>> Bluetooth standard it breaks the compatibility with the Hands-Free Profile >>>>> (HFP). >>>>> >>>>> This patch returns the compatibility with the HFP profile and actually >>>>> tries to check all available connection parameters despite of the specific >>>>> MediaTek implementation. Without it one was unable to establish eSCO/SCO >>>>> connection with some headsets. [...] >>>>> Signed-off-by: Sergey Shtylyov >>>>> >>>>> --- >>>>> This patch is against the 'bluetooth-next.git' repo. >>>>> >>>>> net/bluetooth/hci_event.c | 8 ++++++++ >>>>> 1 file changed, 8 insertions(+) >>>>> >>>>> Index: bluetooth-next/net/bluetooth/hci_event.c >>>>> =================================================================== >>>>> --- bluetooth-next.orig/net/bluetooth/hci_event.c >>>>> +++ bluetooth-next/net/bluetooth/hci_event.c >>>>> @@ -2187,6 +2187,13 @@ static void hci_cs_setup_sync_conn(struc >>>>> if (acl) { >>>>> sco = acl->link; >>>>> if (sco) { >>>>> + if (status == 0x20 && /* Unsupported LMP Parameter value */ >>>>> + sco->out) { > > Actually, I was expecting that you'd tell me to create a HCI quirk for this situation. > I have a patch doing that but I haven't been able to locate the driver in which to set this > quirk flag... And that's no wonder! The BT driver that needs this patch is out-of-tree (and not even open source, it seems) as we have finally ascertained with Ildar... Is there any interest in the "preparatory" patch that lowers the indentation levels in hci_cs_setup_sync_conn()? [...] MBR, Sergei Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aCuPD1hGF19l0gAAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 21:47:36 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id IOfRDVhGF19bcAEAgupzMw (envelope-from ); Tue, 21 Jul 2020 21:47:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0B57E40017; Tue, 21 Jul 2020 21:47:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730937AbgGUTra (ORCPT + 1 other); Tue, 21 Jul 2020 15:47:30 -0400 Received: from mga17.intel.com ([192.55.52.151]:39317 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728683AbgGUTra (ORCPT ); Tue, 21 Jul 2020 15:47:30 -0400 IronPort-SDR: hOJlr7WdZ/u1336KoBUTByjGS1iAk8XRJccq1UpvhKILELXzZzjp5GfPY5t5h+CI3uxY4hXNef Yh0xuk4DO1zQ== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="130302173" X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="130302173" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 12:47:29 -0700 IronPort-SDR: HzoQ2ZMwb6biFBrO8qdJzCR27jjM7JykOxhu0AmiGiS65w6DPhUB7yEXVCMqScsKlPU31J/4wb LD7tYuMQ5Jrg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="362476037" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.78.200]) by orsmga001.jf.intel.com with ESMTP; 21 Jul 2020 12:47:29 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ] mesh: Fix memory leak on provisioning timeout Date: Tue, 21 Jul 2020 12:47:24 -0700 Message-Id: <20200721194724.230809-1-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0B57E40017 X-Rspamd-UID: b83b7d If the Provision Acceptor times out without completing successfully, the timer it was using was never freed. --- mesh/prov-acceptor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mesh/prov-acceptor.c b/mesh/prov-acceptor.c index 5231616ee..96f7e15ad 100644 --- a/mesh/prov-acceptor.c +++ b/mesh/prov-acceptor.c @@ -143,6 +143,7 @@ static void prov_to(struct l_timeout *timeout, void *user_data) if (rx_prov != prov) return; + l_timeout_remove(prov->timeout); prov->timeout = NULL; if (prov->cmplt && prov->trans_tx) { -- 2.25.4 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OIy5CQt6F1897wEAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 01:28:11 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 4BVmCAt6F1+bHwAAlp8NpQ (envelope-from ); Wed, 22 Jul 2020 01:28:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DFA30A0183; Wed, 22 Jul 2020 01:28:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731423AbgGUX15 (ORCPT + 1 other); Tue, 21 Jul 2020 19:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbgGUX15 (ORCPT ); Tue, 21 Jul 2020 19:27:57 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07831C061794 for ; Tue, 21 Jul 2020 16:27:56 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id k4so252485oik.2 for ; Tue, 21 Jul 2020 16:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hPMF/rjSnUxtFQsQFf+E5YjSvyjHemQzNNUjLowFP0U=; b=tPw7zqlHX6OVd3pgkjh4d3OX7yPN/1czEGNZ8SYAQiYQsbFTzjzg5TwBNHRnuQXgok lm683FCiirtCFNptfx8x4XtoIE9ePJjQcwvTXVpFrbl5l9Y/zd+wPM6MOshQj586OMhb FDr6yyA01vN5cGAiqHfG/Lv0mgJA32ZfC92pfJ4ATK2XNm0NEAubrdb7edZF14/9FJcy WjEk+md+MrFP0fXLcJlPG1CjyPLk46Is7JTttn3BAFjiaQTcVh8UXmbHI9Xd0eMnpXxw LMyA2Rur1/aAui4qPUFaYSxU3oGqL39EwIMeTsr+Z67DZt1TZU/lX4vQWGR4GxMnToiW RFVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hPMF/rjSnUxtFQsQFf+E5YjSvyjHemQzNNUjLowFP0U=; b=Sf8ew95VJ4ZtSnxBx51+C1EcGIIOR3DKdZc3KlpuQ1oKwU8YurzO9b4wnB5x+UHPyL fo9xdWXhymio47YiWSpuXKN9aSgov3y0+v29oqONqYNsfyv0YT+2pxWEdcmOLbiQ0diT dJ4XtshGlflYx+QkR0hm8RFIMOoCfTSqUVaF19xYdx4st78k+04z4hXh17IMCI+6rigp 21BeQ22XAKP1BxF39hZBpMF+xyMxDreaQHh5BdJ+BP210bMVO/xFaM/oXXSivvlseqHX 3CSAJVGoUZpJEkQlSlnrvP6zOu/mWwPbz75V22JUJt3x90yc5ChOzpcEgx1yMG/kBKmh wgDA== X-Gm-Message-State: AOAM532U23IPFV47i+S4FBKGd7qizLX1mxZsbSCa39t2iop9GxTw8mNr ee83AT89ufolkFP3FXBN16TFQgavUN/yIli5E+M= X-Google-Smtp-Source: ABdhPJwu193y3SsRMvO3NGHV+Wthzdnl/vCdX9HFkBOseMhcy/v5Z5Ijy2QRtDPiIPY1Fr00A8n2b5JgFgk6tcvocn0= X-Received: by 2002:aca:2819:: with SMTP id 25mr4732728oix.48.1595374076109; Tue, 21 Jul 2020 16:27:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Luiz Augusto von Dentz Date: Tue, 21 Jul 2020 16:27:44 -0700 Message-ID: Subject: Re: Networking - NetworkServer1 To: Barry Byford <31baz66@gmail.com> Cc: Bluez mailing list Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: DFA30A0183 X-Rspamd-UID: 0f0587 Hi Barry, On Tue, Jul 21, 2020 at 2:45 PM Barry Byford <31baz66@gmail.com> wrote: > > I am trying to get Bluetooth networking to happen between a couple of > Raspberry Pi's running the latest Raspberry Pi OS and BlueZ 5.50 > > $ uname -a > Linux raspberry 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 > armv7l GNU/Linux > $ bluetoothctl --version > bluetoothctl: 5.50 > > I have been able to use the Network1 interface to Connect to my > Android phone using Bluetooth tethering. > > However, when I use the NetworkServer1 interface to register a profile > I have not had success in getting two devices to communicate. I have > paired and trusted the two devices. This allows the Bluetooth to > connect but not for the networking interface to be created as can be > seen in the logs: > > e.g. bluetoothd: BNEP server cannot be added > > A search for that error message didn't seem to turn up anything actionable. > > ``` > > ACL Data RX: Handle 11 flags 0x02 dlen 44 #50 [hci0] 21:54:01.130545 > Channel: 64 len 40 [PSM 15 mode 0] {chan 0} > BNEP: Control (0x01|0) > Filter MultAddr Set (0x05) > Length: 0x0024 > ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff > 33:33:00:00:00:01 - 33:33:00:00:00:01 > 01:00:5e:00:00:01 - 01:00:5e:00:00:01 > < ACL Data TX: Handle 11 flags 0x00 dlen 8 > #51 [hci0] 21:54:01.131140 > Channel: 64 len 4 [PSM 15 mode 0] {chan 0} > BNEP: Control (0x01|0) > Filter MultAddr Rsp (0x06) > Rsp msg: Operation Successful(0x0000) > > ACL Data RX: Handle 11 flags 0x02 dlen 56 #52 [hci0] 21:54:01.131800 > Channel: 64 len 52 [PSM 15 mode 0] {chan 0} > BNEP: Control (0x01|0) > Filter MultAddr Set (0x05) > Length: 0x0030 > ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff > 33:33:00:00:00:01 - 33:33:00:00:00:01 > 01:00:5e:00:00:01 - 01:00:5e:00:00:01 > 33:33:ff:d1:14:7e - 33:33:ff:d1:14:7e > < ACL Data TX: Handle 11 flags 0x00 dlen 8 > #53 [hci0] 21:54:01.131912 > Channel: 64 len 4 [PSM 15 mode 0] {chan 0} > BNEP: Control (0x01|0) > Filter MultAddr Rsp (0x06) > Rsp msg: Operation Successful(0x0000) > > HCI Event: Number of Completed Packets (0x13) plen 5 #54 [hci0] 21:54:01.132894 > Num handles: 1 > Handle: 11 > Count: 2 > > HCI Event: Number of Completed Packets (0x13) plen 5 #55 [hci0] 21:54:01.135075 > Num handles: 1 > Handle: 11 > Count: 2 > = bluetoothd: bnep: Can't add bnep0 to the bridge tether: No such > device(19) 21:54:01.138304 Well it looks like the bridge (tether) does not exist so we can't add the bnep interface, perhaps the idea is not to have it attached to any bridge in case of GN, PAN and just bring the interface up when an empty string is given as bridge. > = bluetoothd: BNEP server cannot be added > 21:54:01.138429 > > ACL Data RX: Handle 11 flags 0x02 dlen 89 #56 [hci0] 21:54:01.158957 > Channel: 64 len 85 [PSM 15 mode 0] {chan 0} > BNEP: Compressed Ethernet DestOnly (0x04|0) > dst 33:33:00:00:00:16 [proto 0x86dd] > 60 00 00 00 00 24 00 01 00 00 00 00 00 00 00 00 `....$.......... > 00 00 00 00 00 00 00 00 ff 02 00 00 00 00 00 00 ................ > 00 00 00 00 00 00 00 16 3a 00 05 02 00 00 01 00 ........:....... > 8f 00 5a 3b 00 00 00 01 04 00 00 00 ff 02 00 00 ..Z;............ > 00 00 00 00 00 00 00 01 ff d1 14 7e ...........~ > > ACL Data RX: Handle 11 flags 0x02 dlen 68 #57 [hci0] 21:54:01.265654 > Channel: 64 len 64 [PSM 15 mode 0] {chan 0} > BNEP: Control (0x01|0) > Filter MultAddr Set (0x05) > Length: 0x003c > ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff > 33:33:00:00:00:01 - 33:33:00:00:00:01 > 01:00:5e:00:00:01 - 01:00:5e:00:00:01 > 33:33:ff:d1:14:7e - 33:33:ff:d1:14:7e > 33:33:00:00:00:fb - 33:33:00:00:00:fb > ``` > The client seems to be created correctly. > > I have been searching around and I cannot find any working solutions > being reported for GN or PANU using the tools that are currently > available. > > There is this thread but it seems to have ended without conclusion > https://marc.info/?l=linux-bluetooth&m=149129850001348&w=2 > > I have added org.bluez.Network1 and org.bluez.NetworkServer1 to my > /etc/dbus-1/system.d/bluetooth.conf for both server and client. > > Are there any other configuration files that need editing? > > Any help or guidance gratefully received. Pointers to a tutorial or > the steps required would be good also as there appears to be some step > I'm missing. > > Thanks, > Barry -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EKwKDIlgF18EdgEAvsO+Rg (envelope-from ) for ; Tue, 21 Jul 2020 23:39:21 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0LAQColgF1+V9QEAlp8NpQ (envelope-from ); Tue, 21 Jul 2020 23:39:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4CFF0A0D27; Tue, 21 Jul 2020 23:39:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731183AbgGUVjO (ORCPT + 1 other); Tue, 21 Jul 2020 17:39:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726555AbgGUVjO (ORCPT ); Tue, 21 Jul 2020 17:39:14 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C356AC061794 for ; Tue, 21 Jul 2020 14:39:13 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id k17so151247lfg.3 for ; Tue, 21 Jul 2020 14:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ITLa5KsgjkvocWnqtKgbMwAzWNbO2EQZpxksrmEUcbM=; b=IdgJGviA4kEEP2CrsI6w9RMd6/0xRSq47+gOCLm46BYnFO4EsbVjl/ln6iEspjDAE7 jbvmcC4OrT4xpuesHGL8GWGT0SBm+uTbZ8fdW4TdmzmXoikk56/oEOIo/wDwTo9hYzAT 6DF9SWPWwQED5tW1grmFs+KCiKpmdRPAHx70CLaFi3dD7k5FCy1Pr+kfFikxBk0/d+6j 8eBp+RJmeSlBk348CnQIjEgx4uAnA9M2sM5IQHv52CzLx/QfeVWAfnUItS6nSg/IhPOm o9fk2kK+/oXHeFhT+4mLUxN/aHita5cRC/V42MLW8HfgfjR2o+PcuuZFVgiWrTjEMKiT poRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ITLa5KsgjkvocWnqtKgbMwAzWNbO2EQZpxksrmEUcbM=; b=BGDsTuw2TP97zkcK3qlsO34nsSHzSZkh62ybDpqpfRo3D7JD8QohUO9q8mX2TWg1nq FKk+PJkyLjmYinPGdkPxZ3l6s+yPRBhbyUNWLhgEeGIRtcQpeWNOXgGLamzwzA18EWUz 5JnYWk4Ev/50ZnUx0IYemaPE8lV0Ym1gROgPaFmZrtYtlzpa0aVlSBrzUT4RGGlSNQoN vCn57xcv5HNd9sCPCcVJPMNbh9bksfP21LaoumXiZLspg0UItPnzfeR1bFdDwOH1PVJl sIRQTlIMKnBPB+jnaRkWew5Y80ipVwPiX1C1sYzFHux2ZMSXFzX4etbJp2zGFpqdgD2L u4Fw== X-Gm-Message-State: AOAM531tVdiNGycqVFjKqS3rfq1rTvATZbntZiK4B+uzALxNIu+plczK 9nTqBjAf4JkXhbi2eNCZDLMta10Y51bWVarZIm8/au2s9+Y= X-Google-Smtp-Source: ABdhPJxuuTiC7VG0TtVTycbwEMqlMG23YS0TL2mIT0fS9f/CKhxYPigS4jFiRiZyIQfkehQtvwY1gYefYr9e13rccng= X-Received: by 2002:a19:c68b:: with SMTP id w133mr10532695lff.189.1595367551520; Tue, 21 Jul 2020 14:39:11 -0700 (PDT) MIME-Version: 1.0 From: Barry Byford <31baz66@gmail.com> Date: Tue, 21 Jul 2020 22:38:59 +0100 Message-ID: Subject: Networking - NetworkServer1 To: Bluez mailing list Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4CFF0A0D27 X-Rspamd-UID: f2d78d I am trying to get Bluetooth networking to happen between a couple of Raspberry Pi's running the latest Raspberry Pi OS and BlueZ 5.50 $ uname -a Linux raspberry 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 armv7l GNU/Linux $ bluetoothctl --version bluetoothctl: 5.50 I have been able to use the Network1 interface to Connect to my Android phone using Bluetooth tethering. However, when I use the NetworkServer1 interface to register a profile I have not had success in getting two devices to communicate. I have paired and trusted the two devices. This allows the Bluetooth to connect but not for the networking interface to be created as can be seen in the logs: e.g. bluetoothd: BNEP server cannot be added A search for that error message didn't seem to turn up anything actionable. ``` > ACL Data RX: Handle 11 flags 0x02 dlen 44 #50 [hci0] 21:54:01.130545 Channel: 64 len 40 [PSM 15 mode 0] {chan 0} BNEP: Control (0x01|0) Filter MultAddr Set (0x05) Length: 0x0024 ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff 33:33:00:00:00:01 - 33:33:00:00:00:01 01:00:5e:00:00:01 - 01:00:5e:00:00:01 < ACL Data TX: Handle 11 flags 0x00 dlen 8 #51 [hci0] 21:54:01.131140 Channel: 64 len 4 [PSM 15 mode 0] {chan 0} BNEP: Control (0x01|0) Filter MultAddr Rsp (0x06) Rsp msg: Operation Successful(0x0000) > ACL Data RX: Handle 11 flags 0x02 dlen 56 #52 [hci0] 21:54:01.131800 Channel: 64 len 52 [PSM 15 mode 0] {chan 0} BNEP: Control (0x01|0) Filter MultAddr Set (0x05) Length: 0x0030 ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff 33:33:00:00:00:01 - 33:33:00:00:00:01 01:00:5e:00:00:01 - 01:00:5e:00:00:01 33:33:ff:d1:14:7e - 33:33:ff:d1:14:7e < ACL Data TX: Handle 11 flags 0x00 dlen 8 #53 [hci0] 21:54:01.131912 Channel: 64 len 4 [PSM 15 mode 0] {chan 0} BNEP: Control (0x01|0) Filter MultAddr Rsp (0x06) Rsp msg: Operation Successful(0x0000) > HCI Event: Number of Completed Packets (0x13) plen 5 #54 [hci0] 21:54:01.132894 Num handles: 1 Handle: 11 Count: 2 > HCI Event: Number of Completed Packets (0x13) plen 5 #55 [hci0] 21:54:01.135075 Num handles: 1 Handle: 11 Count: 2 = bluetoothd: bnep: Can't add bnep0 to the bridge tether: No such device(19) 21:54:01.138304 = bluetoothd: BNEP server cannot be added 21:54:01.138429 > ACL Data RX: Handle 11 flags 0x02 dlen 89 #56 [hci0] 21:54:01.158957 Channel: 64 len 85 [PSM 15 mode 0] {chan 0} BNEP: Compressed Ethernet DestOnly (0x04|0) dst 33:33:00:00:00:16 [proto 0x86dd] 60 00 00 00 00 24 00 01 00 00 00 00 00 00 00 00 `....$.......... 00 00 00 00 00 00 00 00 ff 02 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 16 3a 00 05 02 00 00 01 00 ........:....... 8f 00 5a 3b 00 00 00 01 04 00 00 00 ff 02 00 00 ..Z;............ 00 00 00 00 00 00 00 01 ff d1 14 7e ...........~ > ACL Data RX: Handle 11 flags 0x02 dlen 68 #57 [hci0] 21:54:01.265654 Channel: 64 len 64 [PSM 15 mode 0] {chan 0} BNEP: Control (0x01|0) Filter MultAddr Set (0x05) Length: 0x003c ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff 33:33:00:00:00:01 - 33:33:00:00:00:01 01:00:5e:00:00:01 - 01:00:5e:00:00:01 33:33:ff:d1:14:7e - 33:33:ff:d1:14:7e 33:33:00:00:00:fb - 33:33:00:00:00:fb ``` The client seems to be created correctly. I have been searching around and I cannot find any working solutions being reported for GN or PANU using the tools that are currently available. There is this thread but it seems to have ended without conclusion https://marc.info/?l=linux-bluetooth&m=149129850001348&w=2 I have added org.bluez.Network1 and org.bluez.NetworkServer1 to my /etc/dbus-1/system.d/bluetooth.conf for both server and client. Are there any other configuration files that need editing? Any help or guidance gratefully received. Pointers to a tutorial or the steps required would be good also as there appears to be some step I'm missing. Thanks, Barry Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sP+HGOStF1+BFwEAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 05:09:24 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id aEAdF+StF19YWwAA0J78UA (envelope-from ); Wed, 22 Jul 2020 05:09:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate:hard: -4.6 X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E032E40014; Wed, 22 Jul 2020 05:09:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731856AbgGVDJR (ORCPT + 1 other); Tue, 21 Jul 2020 23:09:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731781AbgGVDJQ (ORCPT ); Tue, 21 Jul 2020 23:09:16 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81D5EC061794 for ; Tue, 21 Jul 2020 20:09:16 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id v10so603866qvm.17 for ; Tue, 21 Jul 2020 20:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=iY8AyA2O6tzg8oy/MrYk3RwynF4LaPQeshdQFRLW5VY=; b=HPAWocSXoFAWJVXBU3KyGDGMCXPGR4lH+ZD2T9R3lKM4wRXZz6Avow5yx/nKROwmAQ FoX81vx5w9Kb65IN7yTi5UxP5GIiXAjrCnG1flwR5F1iLzq+gtbo29jozXDSVbdOBMJa UzpeaBTUQTzrBHO8HPG4Y5V8UYNBXqt0w1YOfHyeAc6RIV228xi6Oo0mCm3CxnJ2Y7RL zBGS6TjuizeQ1Rq8emKEi8+4dLzqc+PGIt2V7q6YSH2H3o5u5keQSgEMpKiPPjzPe0uQ wjoYA67ey9TGCe3pbNM9GvWohsahqtPTvopD4uk9e6h3B1W6tyfBa3oYse9+Ln7yLneF iZeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=iY8AyA2O6tzg8oy/MrYk3RwynF4LaPQeshdQFRLW5VY=; b=ph5hrYPAo3aiJbKdcp9bbfJ7JbZEON/Fx2s4+ZpxHrHTSC13WXcAED/NlOsFb5nz9p wd6TsoPt5qfVDo2cD3kOwT1cR9oEGcFJRrpZaCjbjzg8CTr4xkdknDlZycymLz+iZBu9 qaF39Ir3gR7EJE5tyxgPxyp+1JWxS2eDiQyZ4gNZtKA+KH+aSNSbFig4nimcTeM9m1RM GAlnKcIte+dQxLw1zlL/TwsZAF2k2+pX5Y2HScD8m9bKuh0+5R12MKMsA5ol3QdkvUip NN5PkIPkMn/djY3Rg7WMzxp4OfUNriFSY6+BHr08X3++iCXNFKi9WSyrbHpCfJFg2+fQ 2glA== X-Gm-Message-State: AOAM530lo2aGZ4A6xndYPh5/9x8QzvPYDCc+G2beQIDTr/ILipoo5PzX KNyp83bJ6wct8mkj2HSaNahidKV4KXUhMEVPkHhYTwbgAPENxRqtVuZHmE6Hjs02SsZYDXAclz8 14W8aHqj05z9VH3kszP93quhCoSvchM7U5jQYJ3lT5h1JzvqdzqBDRKqGM8zg1bukEQ6H2vSGkl ST X-Google-Smtp-Source: ABdhPJw1mI7mc9uIHQXWJrxQZ40BL7WX/2tCvmQXRRIWy2X3Oq0QjEmnBh1MBTMSoHiCZhfO6XN0tcLUzsiz X-Received: by 2002:a05:6214:925:: with SMTP id dk5mr30152105qvb.183.1595387355376; Tue, 21 Jul 2020 20:09:15 -0700 (PDT) Date: Wed, 22 Jul 2020 11:09:01 +0800 Message-Id: <20200722110826.Bluez.v2.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog Subject: [Bluez PATCH v2 1/2] audio/transport: change volume to 8bit From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Michael Sun Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 0.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: E032E40014 X-Rspamd-UID: c38d52 From: Archie Pusaka The valid range of volume is 0 - 127, yet it is stored in 16bit data type. This patch modifies it so we use 8bit data type to store volume instead. Furthermore, this patch introduces helper function and defined values to check for volume validity, to prevent numbers scattered all over. Reviewed-by: Michael Sun --- Changes in v2: None profiles/audio/avrcp.c | 2 +- profiles/audio/avrcp.h | 1 - profiles/audio/transport.c | 46 ++++++++++++++++++++++---------------- profiles/audio/transport.h | 3 ++- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 1bf85041e..b312b70b9 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -1660,7 +1660,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, break; case AVRCP_EVENT_VOLUME_CHANGED: pdu->params[1] = media_transport_get_device_volume(dev); - if (pdu->params[1] > 127) + if (!media_transport_volume_valid(pdu->params[1])) goto err; len = 2; diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index 86d310c73..3fd74e18a 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -114,6 +114,5 @@ void avrcp_unregister_player(struct avrcp_player *player); void avrcp_player_event(struct avrcp_player *player, uint8_t id, const void *data); - size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands); size_t avrcp_browsing_general_reject(uint8_t *operands); diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 48fabba9b..a32073380 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -55,6 +55,8 @@ #define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1" +#define UNINITIALIZED_VOLUME_VALUE 128 + typedef enum { TRANSPORT_STATE_IDLE, /* Not acquired and suspended */ TRANSPORT_STATE_PENDING, /* Playing but not acquired */ @@ -86,7 +88,7 @@ struct media_owner { struct a2dp_transport { struct avdtp *session; uint16_t delay; - uint16_t volume; + uint8_t volume; }; struct media_transport { @@ -634,7 +636,7 @@ static gboolean volume_exists(const GDBusPropertyTable *property, void *data) struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; - return a2dp->volume <= 127; + return media_transport_volume_valid(a2dp->volume); } static gboolean get_volume(const GDBusPropertyTable *property, @@ -654,24 +656,20 @@ static void set_volume(const GDBusPropertyTable *property, { struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; - uint16_t volume; + uint16_t arg; + uint8_t volume; bool notify; - if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) { - g_dbus_pending_property_error(id, - ERROR_INTERFACE ".InvalidArguments", - "Invalid arguments in method call"); - return; - } + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) + goto error; - dbus_message_iter_get_basic(iter, &volume); + dbus_message_iter_get_basic(iter, &arg); + if (arg > UINT8_MAX) + goto error; - if (volume > 127) { - g_dbus_pending_property_error(id, - ERROR_INTERFACE ".InvalidArguments", - "Invalid arguments in method call"); - return; - } + volume = (uint8_t)arg; + if (!media_transport_volume_valid(volume)) + goto error; g_dbus_pending_property_success(id); @@ -688,6 +686,11 @@ static void set_volume(const GDBusPropertyTable *property, "Volume"); avrcp_set_volume(transport->device, volume, notify); + return; + +error: + g_dbus_pending_property_error(id, ERROR_INTERFACE ".InvalidArguments", + "Invalid arguments in method call"); } static gboolean endpoint_exists(const GDBusPropertyTable *property, void *data) @@ -824,7 +827,7 @@ static int media_transport_init_source(struct media_transport *transport) transport->data = a2dp; transport->destroy = destroy_a2dp; - a2dp->volume = -1; + a2dp->volume = UNINITIALIZED_VOLUME_VALUE; transport->sink_watch = sink_add_state_cb(service, sink_state_changed, transport); @@ -931,7 +934,7 @@ struct btd_device *media_transport_get_dev(struct media_transport *transport) return transport->device; } -uint16_t media_transport_get_volume(struct media_transport *transport) +uint8_t media_transport_get_volume(struct media_transport *transport) { struct a2dp_transport *a2dp = transport->data; return a2dp->volume; @@ -958,7 +961,7 @@ uint8_t media_transport_get_device_volume(struct btd_device *dev) GSList *l; if (dev == NULL) - return 128; + return UNINITIALIZED_VOLUME_VALUE; for (l = transports; l; l = l->next) { struct media_transport *transport = l->data; @@ -991,3 +994,8 @@ void media_transport_update_device_volume(struct btd_device *dev, media_transport_update_volume(transport, volume); } } + +bool media_transport_volume_valid(uint8_t volume) +{ + return volume < 128; +} diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index ac542bf6c..c430515f2 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -32,7 +32,7 @@ struct media_transport *media_transport_create(struct btd_device *device, void media_transport_destroy(struct media_transport *transport); const char *media_transport_get_path(struct media_transport *transport); struct btd_device *media_transport_get_dev(struct media_transport *transport); -uint16_t media_transport_get_volume(struct media_transport *transport); +uint8_t media_transport_get_volume(struct media_transport *transport); void media_transport_update_delay(struct media_transport *transport, uint16_t delay); void media_transport_update_volume(struct media_transport *transport, @@ -43,3 +43,4 @@ void transport_get_properties(struct media_transport *transport, uint8_t media_transport_get_device_volume(struct btd_device *dev); void media_transport_update_device_volume(struct btd_device *dev, uint8_t volume); +bool media_transport_volume_valid(uint8_t volume); -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ONF/MPKtF197HQEAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 05:09:38 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id mCnOLvKtF18nzAAAlp8NpQ (envelope-from ); Wed, 22 Jul 2020 05:09:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate:hard: -4.6 X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5F4CC40675; Wed, 22 Jul 2020 05:09:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731908AbgGVDJb (ORCPT + 1 other); Tue, 21 Jul 2020 23:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731781AbgGVDJa (ORCPT ); Tue, 21 Jul 2020 23:09:30 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91C88C061794 for ; Tue, 21 Jul 2020 20:09:30 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id w15so466590qti.21 for ; Tue, 21 Jul 2020 20:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=oBnqQ7NXBBZjR/OqQ7gnqZvTGW0gC9+kuF9l/hYUZtU=; b=iqFrs89HtHvZSDj+iYmFCFyBhRd+lrWfnaoP8Zs+Pk3cFSzRetpFWbWn7H+bfZ4cr6 U8u5Fxi181Nxe3/d4MoLSF6Wp6vtnrHZFqkdmkmHpOl1vfXkM487/Lk9L4buK2MCCgtf kOpyLC6zyVSkRUJTUbyu9ozTh3IwfruVshoAoTHw8hCsF3eZ/rC4WwZCXKrqkREDJggv S2ftSf/JNmO/sv7U8/VQf2e1vEachZy06G8/I3zPv0ZGxsbACa430+yiKjS2q905duzn E/e2aTMMbFPFMKepPjaQaz3FCaiu00KPkwkseJEWoHvu85q1MiOWiqDVQXqfdl+QGisk m15g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=oBnqQ7NXBBZjR/OqQ7gnqZvTGW0gC9+kuF9l/hYUZtU=; b=D8i3wqTBDC4V0I3PY1nWiOXTW2Ud32073RTP4vj47nllojQTLF0urC6gzKBfZPprAr b6k4ax0FfZHFrZuFpC2jG5Mm6R/dLmmDFjLTbZkQGUeyDWhri5p761SNMXzjp6ORM3aY 0v1WVBpZgJX3xll4Ll+kayA0g3685IMMGMbJnrvzdqjqVihcplmTOZDK9w5WPOjVjHjN O0bNajCJNHhlIIX+LhIlt1ICvkDKOEhZ+0l1rXlzvwRD31hNgrM7K8/sfuHYGbsNCgdr CWSFhVXyP4ZFTy1S+a89VnKox9LQr6qu660vUufWyIq8rlXPurMaOssrPsuGG3TxnIgW tmGA== X-Gm-Message-State: AOAM530CnRPevoL1FA5jTTHmyt2wfq9GszrsW5V4VJb6Z2RLlpK7GocR JbX6gmsCL0EABDhZ5/djcXqdPvevRQMCpckYSZrkmAH0v3hx/8z+WQQ9MMxqd3Ir2U1nDJL2sit Fw364QURmSvI6E+P3dZeqI5fG7qWyxfP08xcHUBmi3AMtLdAxnUl1XKdoWLp3j4L35v4xKbQy0i T9 X-Google-Smtp-Source: ABdhPJzF4nfSbi8dK1n13yC8L2COQ2kOYZC8iiH9f8F/b7w+PjyqLgfSSV73HveXwpp1ruo7iOFs9if4dHbL X-Received: by 2002:a05:6214:1882:: with SMTP id cx2mr30068208qvb.240.1595387369624; Tue, 21 Jul 2020 20:09:29 -0700 (PDT) Date: Wed, 22 Jul 2020 11:09:02 +0800 In-Reply-To: <20200722110826.Bluez.v2.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Message-Id: <20200722110826.Bluez.v2.2.Ic16589fde45fac0c496dfca2fa27672059114c3b@changeid> Mime-Version: 1.0 References: <20200722110826.Bluez.v2.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog Subject: [Bluez PATCH v2 2/2] audio/transport: supply volume on transport init From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Yu Liu Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 0.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5F4CC40675 X-Rspamd-UID: fb667b From: Archie Pusaka Sometimes the response of RegisterNotification for volume change event came before we create the transport for the corresponding device. If that happens, the volume will be stuck to an uninitialized invalid value. The property Volume of MediaTransport1 will also be left unaccessible. This patch supplies the initial volume when creating a new transport. The value is obtained from the media_player object. However, since the avrcp session might not be created by the time the transport is created, we also try to initialize the volume when creating avrcp session. Reviewed-by: Yu Liu --- Changes in v2: -Get the volume from media_player instead of from separate list profiles/audio/avrcp.c | 26 ++++++++++++++++- profiles/audio/avrcp.h | 2 ++ profiles/audio/media.c | 60 +++++++++++++++++++++++++++++--------- profiles/audio/media.h | 2 ++ profiles/audio/transport.c | 4 +-- profiles/audio/transport.h | 2 ++ 6 files changed, 78 insertions(+), 18 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index b312b70b9..f53020bd7 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -1701,7 +1701,6 @@ static uint8_t avrcp_handle_request_continuing(struct avrcp *session, if (pending->pdu_id != pdu->params[0]) goto err; - len = 0; pending->attr_ids = player_fill_media_attribute(player, pending->attr_ids, @@ -4037,8 +4036,12 @@ static void target_init(struct avrcp *session) player = g_slist_nth_data(server->players, 0); if (player != NULL) { + uint8_t init_volume; target->player = player; player->sessions = g_slist_prepend(player->sessions, session); + + init_volume = media_player_get_device_volume(session->dev); + media_transport_update_device_volume(session->dev, init_volume); } session->supported_events |= (1 << AVRCP_EVENT_STATUS_CHANGED) | @@ -4473,6 +4476,27 @@ int avrcp_set_volume(struct btd_device *dev, uint8_t volume, bool notify) avrcp_handle_set_volume, session); } +struct avrcp_player *avrcp_get_target_player_by_device(struct btd_device *dev) +{ + struct avrcp_server *server; + struct avrcp *session; + struct avrcp_data *target; + + server = find_server(servers, device_get_adapter(dev)); + if (server == NULL) + return NULL; + + session = find_session(server->sessions, dev); + if (session == NULL) + return NULL; + + target = session->target; + if (target == NULL) + return NULL; + + return target->player; +} + static int avrcp_connect(struct btd_service *service) { struct btd_device *dev = btd_service_get_device(service); diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index 3fd74e18a..a9964f4fa 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -116,3 +116,5 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands); size_t avrcp_browsing_general_reject(uint8_t *operands); + +struct avrcp_player *avrcp_get_target_player_by_device(struct btd_device *dev); diff --git a/profiles/audio/media.c b/profiles/audio/media.c index a0173fdd4..4ae936556 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -239,6 +239,20 @@ static void media_endpoint_exit(DBusConnection *connection, void *user_data) media_endpoint_remove(endpoint); } +static struct media_adapter *find_adapter(struct btd_device *device) +{ + GSList *l; + + for (l = adapters; l; l = l->next) { + struct media_adapter *adapter = l->data; + + if (adapter->btd_adapter == device_get_adapter(device)) + return adapter; + } + + return NULL; +} + static void clear_configuration(struct media_endpoint *endpoint, struct media_transport *transport) { @@ -426,6 +440,33 @@ struct a2dp_config_data { a2dp_endpoint_config_t cb; }; +uint8_t media_player_get_device_volume(struct btd_device *device) +{ + struct avrcp_player *target_player; + struct media_adapter *adapter; + GSList *l; + + if (!device) + return UNINITIALIZED_VOLUME_VALUE; + + target_player = avrcp_get_target_player_by_device(device); + if (!target_player) + return UNINITIALIZED_VOLUME_VALUE; + + adapter = find_adapter(device); + if (!adapter) + return UNINITIALIZED_VOLUME_VALUE; + + for (l = adapter->players; l; l = l->next) { + struct media_player *mp = l->data; + + if (mp->player == target_player) + return mp->volume; + } + + return UNINITIALIZED_VOLUME_VALUE; +} + static gboolean set_configuration(struct media_endpoint *endpoint, uint8_t *configuration, size_t size, media_endpoint_cb_t cb, @@ -439,6 +480,7 @@ static gboolean set_configuration(struct media_endpoint *endpoint, const char *path; DBusMessageIter iter; struct media_transport *transport; + uint8_t init_volume; transport = find_device_transport(endpoint, device); @@ -451,6 +493,9 @@ static gboolean set_configuration(struct media_endpoint *endpoint, if (transport == NULL) return FALSE; + init_volume = media_player_get_device_volume(device); + media_transport_update_volume(transport, init_volume); + msg = dbus_message_new_method_call(endpoint->sender, endpoint->path, MEDIA_ENDPOINT_INTERFACE, "SetConfiguration"); @@ -646,20 +691,6 @@ static gboolean endpoint_init_a2dp_sink(struct media_endpoint *endpoint, return TRUE; } -static struct media_adapter *find_adapter(struct btd_device *device) -{ - GSList *l; - - for (l = adapters; l; l = l->next) { - struct media_adapter *adapter = l->data; - - if (adapter->btd_adapter == device_get_adapter(device)) - return adapter; - } - - return NULL; -} - static bool endpoint_properties_exists(const char *uuid, struct btd_device *dev, void *user_data) @@ -1779,6 +1810,7 @@ static struct media_player *media_player_create(struct media_adapter *adapter, mp->sender = g_strdup(sender); mp->path = g_strdup(path); mp->timer = g_timer_new(); + mp->volume = UNINITIALIZED_VOLUME_VALUE; mp->watch = g_dbus_add_disconnect_watch(conn, sender, media_player_exit, mp, diff --git a/profiles/audio/media.h b/profiles/audio/media.h index dd630d432..f84f36d61 100644 --- a/profiles/audio/media.h +++ b/profiles/audio/media.h @@ -33,3 +33,5 @@ void media_unregister(struct btd_adapter *btd_adapter); struct a2dp_sep *media_endpoint_get_sep(struct media_endpoint *endpoint); const char *media_endpoint_get_uuid(struct media_endpoint *endpoint); uint8_t media_endpoint_get_codec(struct media_endpoint *endpoint); + +uint8_t media_player_get_device_volume(struct btd_device *device); diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index a32073380..285bfb714 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -55,8 +55,6 @@ #define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1" -#define UNINITIALIZED_VOLUME_VALUE 128 - typedef enum { TRANSPORT_STATE_IDLE, /* Not acquired and suspended */ TRANSPORT_STATE_PENDING, /* Playing but not acquired */ @@ -981,7 +979,7 @@ void media_transport_update_device_volume(struct btd_device *dev, { GSList *l; - if (dev == NULL) + if (dev == NULL || !media_transport_volume_valid(volume)) return; for (l = transports; l; l = l->next) { diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index c430515f2..46a9c91bd 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -22,6 +22,8 @@ * */ +#define UNINITIALIZED_VOLUME_VALUE 128 + struct media_transport; struct media_transport *media_transport_create(struct btd_device *device, -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iISaOiywF18rJwEAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 05:19:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id kIDeOCywF19awQAAgupzMw (envelope-from ); Wed, 22 Jul 2020 05:19:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7927740675; Wed, 22 Jul 2020 05:19:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731857AbgGVDTD (ORCPT + 1 other); Tue, 21 Jul 2020 23:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731621AbgGVDTD (ORCPT ); Tue, 21 Jul 2020 23:19:03 -0400 Received: from mail-vs1-xe43.google.com (mail-vs1-xe43.google.com [IPv6:2607:f8b0:4864:20::e43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDF36C061794 for ; Tue, 21 Jul 2020 20:19:02 -0700 (PDT) Received: by mail-vs1-xe43.google.com with SMTP id k7so398752vso.2 for ; Tue, 21 Jul 2020 20:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=msnUWH+TlT3OvBHqrc8dcTnpYvjDPCiZd6MOKcGt6yo=; b=fhLZ/Ya/fXEsadc4ZkOXfRtFfbH45MVSgVTu4fDNgzstBzSQPgo1YCiCINjEGIM5z8 HCHiXzfBnDzNR79ddpJTDmqO/SxZVHdVUtGxIvFRIb5J0Zwo5IMd+0+GF87MX5+ueRjy kMAlcep8sMJkzaGILuwtv4bNFh1Ow83dwTVyg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=msnUWH+TlT3OvBHqrc8dcTnpYvjDPCiZd6MOKcGt6yo=; b=P4vSAN6dOXs3ogTmd3BcZtT/HCSYG24MEIndnQGzLE9S2u9KyZm78FYn8hYsF+zSwM GLuFvBfXT4G9hFRO6Du/Qq1s567oR3N3P1XiYDPz+6LYhMDBAdGifHubXImTBjZrm1qw uusXNHQzNXwM427ORg9rxrC7gurHJRqJveABI5aXt5KFj0NgqafFwBUjMcYPGTcitBzS T/YM13E5SFvhtzizi2iLymthV9KpxEww0/ESHz6uCHBO8ZvYkYmSV5PssTi/mB5oZCDg XwXi/TpCBce4SoS4IB1qAEbyq2GWm2At0Vlw8RUC1ewD0Mrnbfv2R9o9axSLpCOWFm8c wvhA== X-Gm-Message-State: AOAM530xWicId4WmfQb/4CfItr+RtoOc4E+Tuh0XNc4ecZ+2w9i3wWNr /KHk0f7FHIiY2rsYtAoxzcgFo5/P2EITbZ6jr0l99Q== X-Google-Smtp-Source: ABdhPJwXGOpkro1pNwYymoO3cxCJfjOkPDDFv8cui6cm35shb30xdtYO/HxpSfooij9etavppczVU3cmkYIbRa2l3IA= X-Received: by 2002:a67:fd0b:: with SMTP id f11mr21027225vsr.93.1595387942008; Tue, 21 Jul 2020 20:19:02 -0700 (PDT) MIME-Version: 1.0 References: <20200714125120.Bluez.v2.1.I9181af521cf0fba8f4315c9b89975848d437d6dd@changeid> In-Reply-To: <20200714125120.Bluez.v2.1.I9181af521cf0fba8f4315c9b89975848d437d6dd@changeid> From: Abhishek Pandit-Subedi Date: Tue, 21 Jul 2020 20:18:50 -0700 Message-ID: Subject: Re: [Bluez PATCH v2] doc: Add Suspend and Resume events To: Marcel Holtmann , Luiz Augusto von Dentz Cc: ChromeOS Bluetooth Upstreaming , Bluez mailing list , Alain Michaud , Miao-chen Chou Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.98 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7927740675 X-Rspamd-UID: 744e73 Hi Marcel, Please take a look at this v2 patch. Thanks Abhishek On Tue, Jul 14, 2020 at 12:51 PM Abhishek Pandit-Subedi wrote: > > Add Controller Suspend Event and Controller Resume Event to identify > suspend or resume of the Bluetooth stack has occurred. > > Also update Device Disconnected Event to indicate a new disconnect > reason: "Connection terminated by local host for suspend" > > Reviewed-by: Alain Michaud > Reviewed-by: Miao-chen Chou > --- > > Changes in v2: > - Moved Wake_Reason to first value > - Reduced Wake_Reason to not Bluetooth, unexpected event and remote wake > > doc/mgmt-api.txt | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 48 insertions(+) > > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt > index ca0d38469..e7a713824 100644 > --- a/doc/mgmt-api.txt > +++ b/doc/mgmt-api.txt > @@ -3834,6 +3834,7 @@ Device Disconnected Event > 2 Connection terminated by local host > 3 Connection terminated by remote host > 4 Connection terminated due to authentication failure > + 5 Connection terminated by local host for suspend > > Note that the local/remote distinction just determines which side > terminated the low-level connection, regardless of the > @@ -4577,3 +4578,50 @@ Advertisement Monitor Removed Event > > The event will only be sent to management sockets other than the > one through which the command was sent. > + > + > +Controller Suspend Event > +======================== > + > + Event code: 0x002d > + Controller Index: > + Event Parameters: Suspend_State (1 octet) > + > + This event indicates that the controller is suspended for host suspend. > + > + Possible values for the Suspend_State parameter: > + 0 Running (not disconnected) > + 1 Disconnected and not scanning > + 2 Page scanning and/or passive scanning. > + > + The value 0 is used for the running state and may be sent if the > + controller could not be configured to suspend properly. > + > + This event will be sent to all management sockets. > + > + > +Controller Resume Event > +======================= > + > + Event code: 0x002e > + Controller Index: > + Event Parameters: Wake_Reason (1 octet) > + Address (6 octets) > + Address_Type (1 octet) > + > + This event indicates that the controller has resumed from suspend. > + > + Possible values for the Wake_Reason parameter: > + 0 Resume from non-Bluetooth wake source > + 1 Wake due to unexpected event > + 2 Remote wake due to peer device connection > + > + Currently, we expect that only peer reconnections should wake us from > + the suspended state. Any other events that occurred while the system > + should have been suspended results in wake due to unexpected event. > + > + If the Wake_Reason is Remote wake due to connection, the address of the > + peer device that caused the event will be shared in Address and > + Address_Type. Otherwise, Address and Address_Type will both be zero. > + > + This event will be sent to all management sockets. > -- > 2.27.0.389.gc38d7665816-goog > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id pt0nBHWxF1/DKwEAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 05:24:37 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YBrtAXWxF1/bwgAAgupzMw (envelope-from ); Wed, 22 Jul 2020 05:24:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7F10FA0110; Wed, 22 Jul 2020 05:24:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731846AbgGVDY1 (ORCPT + 1 other); Tue, 21 Jul 2020 23:24:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731781AbgGVDY0 (ORCPT ); Tue, 21 Jul 2020 23:24:26 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89DB7C061794 for ; Tue, 21 Jul 2020 20:24:26 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id g26so742905qka.3 for ; Tue, 21 Jul 2020 20:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=LWn+HwHtQaf83JNo/tsGsWvrHjJ4Qq+hBu+FHi2HB0Y=; b=eAHibwp7nDxIRZ1KamqQQkwpHoy3692yCLS4oE3IvlnUoghVR2iFseXtJe1MMIMmAW 3e9nRIDbZZr1KwAZalc92k4vBYylttGsfS0gv6NWeaD8X7lQ5l+eFtZRY1iGWEJybnhm Ks2qw7sfeWSb10UdztGeYKEUQhWBUojJrdu8AByIaOgHzsNTsW5WH/T2TwhFjUnbMKg9 IXe2FQq5L7HWdbmIOxiaf/d8VRPbJca02FmChUTivob+O3jY4ITgSEElU5vBSpViSzoK ABHzNvhzcS+JmjY12b7uCah6wFUxFyLYHqfdxPugKPT0StYRK1CZPVLVIrSeilWnc41J wdcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=LWn+HwHtQaf83JNo/tsGsWvrHjJ4Qq+hBu+FHi2HB0Y=; b=POw+DPC9dM1TXlg7gqNAXQ8jn5hkV7McyKoR8ZPwekUVOh5I9DJjmp1qlXoa9NzeM2 EEUy8Oc+HmpM3D0qGEMlxHCAYNNvZ9MxbU1/KWl7XqO5EQvMtV/jHsp62uKm5GecYkc7 WXtYsV88qA4klYCOLmYzEjcWZ1CMmOaGhKMJXWTSfp6RwWABINxicQYKAlrD2fELXTQl ts9IJN6nArgCXIxHDJ/qSNRzBx3hoOYuLGDDg5qSgTWQJ1I4bqd+o9nnZH51uHTnQ3Zk hBvzT1CrlbQyMyWGZ55z0BnlJHlCXbbY+gxfghsbLp5oF4b5Y1Md/fPRd3JOb8/MWxrR E+yg== X-Gm-Message-State: AOAM530UjXk26Ke4bFbbr8I+VQz55/Nr2WCssnDNIqkmNhd7svO9lMnB g1cIwrBS8Pv0SuZlvUNFv1P42VNpSi0= X-Google-Smtp-Source: ABdhPJwaSuxeTC4g8AysuhqZtDkVQc2OOpiz1YQ8sx+9/zo38FOcCz55Uo2SGnumOYInfi8gEgzKtQ== X-Received: by 2002:a37:4ca:: with SMTP id 193mr10993367qke.198.1595388265720; Tue, 21 Jul 2020 20:24:25 -0700 (PDT) Received: from [172.17.0.2] ([20.190.246.123]) by smtp.gmail.com with ESMTPSA id z36sm24518238qtd.22.2020.07.21.20.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 20:24:25 -0700 (PDT) Message-ID: <5f17b169.1c69fb81.6abc4.5625@mx.google.com> Date: Tue, 21 Jul 2020 20:24:25 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============4596658088273435016==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, apusaka@google.com Subject: RE: [Bluez,v2,1/2] audio/transport: change volume to 8bit Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200722110826.Bluez.v2.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> References: <20200722110826.Bluez.v2.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 35 X-Rspamd-Score: 5.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7F10FA0110 X-Rspamd-UID: 5ada81 --===============4596658088273435016== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnByb2ZpbGVzL2F1ZGlvL2F2cmNwLmM6IEluIGZ1bmN0aW9uIOKAmHRh cmdldF9pbml04oCZOgpwcm9maWxlcy9hdWRpby9hdnJjcC5jOjQwNDM6MTc6IGVycm9yOiBpbXBs aWNpdCBkZWNsYXJhdGlvbiBvZiBmdW5jdGlvbiDigJhtZWRpYV9wbGF5ZXJfZ2V0X2RldmljZV92 b2x1bWXigJk7IGRpZCB5b3UgbWVhbiDigJhtZWRpYV90cmFuc3BvcnRfZ2V0X2RldmljZV92b2x1 bWXigJk/IFstV2Vycm9yPWltcGxpY2l0LWZ1bmN0aW9uLWRlY2xhcmF0aW9uXQogNDA0MyB8ICAg aW5pdF92b2x1bWUgPSBtZWRpYV9wbGF5ZXJfZ2V0X2RldmljZV92b2x1bWUoc2Vzc2lvbi0+ZGV2 KTsKICAgICAgfCAgICAgICAgICAgICAgICAgXn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+ CiAgICAgIHwgICAgICAgICAgICAgICAgIG1lZGlhX3RyYW5zcG9ydF9nZXRfZGV2aWNlX3ZvbHVt ZQpjYzE6IGFsbCB3YXJuaW5ncyBiZWluZyB0cmVhdGVkIGFzIGVycm9ycwptYWtlWzFdOiAqKiog W01ha2VmaWxlOjg0Njc6IHByb2ZpbGVzL2F1ZGlvL2JsdWV0b290aGQtYXZyY3Aub10gRXJyb3Ig MQptYWtlOiAqKiogW01ha2VmaWxlOjQwMTA6IGFsbF0gRXJyb3IgMgoKCgotLS0KUmVnYXJkcywK TGludXggQmx1ZXRvb3RoCg== --===============4596658088273435016==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ULd5AWi0F18MNwEAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 05:37:12 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id MIETO2e0F19ZvQAADc0bRg (envelope-from ); Wed, 22 Jul 2020 05:37:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4E57740872; Wed, 22 Jul 2020 05:37:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731922AbgGVDhG (ORCPT + 1 other); Tue, 21 Jul 2020 23:37:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731781AbgGVDhF (ORCPT ); Tue, 21 Jul 2020 23:37:05 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDE50C061794 for ; Tue, 21 Jul 2020 20:37:05 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id h2so623413pgc.19 for ; Tue, 21 Jul 2020 20:37:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=q6GOxmnZxvMuRWp1Be88fRKnZLqubwTjD+MVU6pdfjk=; b=Kh1OPDr3tp5Gbb680tWUkDKVXULq2Z7X8TtiI8XgdL4jOA0go6rBSRL320O7o0DMyo PBrWFLulFaX2aI8I9UiZy7UfDSdjy592fn+iUvBnJ7P+iHqHZEqMQQsxkX7XV+z70Ojn X/2RVp5+zxkSUtzGNCRFI3s1p1IFTWEy5AujZaSdFyFp/JydUZdFZKloGpS4Z3ZBhZpH krPJlp4CYOICsno0XokKC6/Z5daY0hL0HbkTbHQte0b8Pym5Fd9v4HIsVzRde10N/8EL lpSv/kC7MLagoCjPbyKJvrRAVFjbqIswL/6kGoVyf6KIno/gnUPL6q1g8TpTstszF2V1 KzNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=q6GOxmnZxvMuRWp1Be88fRKnZLqubwTjD+MVU6pdfjk=; b=sYoPWv3u9TjJr7ZwmNUIeqhrcHsDjAIW2uOTiK5nFDPE7NI0izkWd5+c8FnjzdKovD QrE31NHX7KhiFqaFKnlZqzBzUgyLHB2FH334EFV5UPIyP5O+dyLnMfPFrkXqFiVqjWlX F/ZC6zd4Nc525eNsa6vYutdyTA9HPUYczw8f0+GNNlet8L+ceNx7XxMjDPpZFj9sLiIR 0UcC2Q4PPVxEK+r5s0ZnD5Qr1YtvKI0JOjdLyJ7NWefAH2kxpODjVttMrxlkt3RHdwq8 wTUl3//MHTZg5DNo3vIfUDHn/o6DagySxgSaQppVfTKAluNe+jzgl7i/lw1HUrgIAh85 ahTQ== X-Gm-Message-State: AOAM530T4Kmk9dj5x2kQJJ3q7ipn7MqIDJ4tawU3v7ntQx6nPjVtarqa nCGmzfWhS6PfmZvCzmXQ7ILOV7TBCSXEygRyuJJh9Pp9FapMHNrifhRZ7ra9JylnDjflxVCcju7 +gobOhcFQopPbUOQk7htiwaheBRQu4eNintqiatU3OS/v3tHJWeDThyu33RrRqsrV0SXnx8wA5v Yr X-Google-Smtp-Source: ABdhPJxa0o6mLpqFgviuvEf3cJ43pvELV35bXcW8HI3xvzEARXmqCxrRRr7DACXkFa4ei70fMQjMgT9m5Qvl X-Received: by 2002:a17:90a:1fcb:: with SMTP id z11mr825759pjz.1.1595389024702; Tue, 21 Jul 2020 20:37:04 -0700 (PDT) Date: Wed, 22 Jul 2020 11:36:58 +0800 Message-Id: <20200722113644.Bluez.v3.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog Subject: [Bluez PATCH v3 1/2] audio/transport: change volume to 8bit From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Michael Sun Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 0.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4E57740872 X-Rspamd-UID: 8b3a07 From: Archie Pusaka The valid range of volume is 0 - 127, yet it is stored in 16bit data type. This patch modifies it so we use 8bit data type to store volume instead. Furthermore, this patch introduces helper function and defined values to check for volume validity, to prevent numbers scattered all over. Reviewed-by: Michael Sun --- Changes in v3: None Changes in v2: None profiles/audio/avrcp.c | 2 +- profiles/audio/avrcp.h | 1 - profiles/audio/transport.c | 46 ++++++++++++++++++++++---------------- profiles/audio/transport.h | 3 ++- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 1bf85041e..b312b70b9 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -1660,7 +1660,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, break; case AVRCP_EVENT_VOLUME_CHANGED: pdu->params[1] = media_transport_get_device_volume(dev); - if (pdu->params[1] > 127) + if (!media_transport_volume_valid(pdu->params[1])) goto err; len = 2; diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index 86d310c73..3fd74e18a 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -114,6 +114,5 @@ void avrcp_unregister_player(struct avrcp_player *player); void avrcp_player_event(struct avrcp_player *player, uint8_t id, const void *data); - size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands); size_t avrcp_browsing_general_reject(uint8_t *operands); diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 48fabba9b..a32073380 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -55,6 +55,8 @@ #define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1" +#define UNINITIALIZED_VOLUME_VALUE 128 + typedef enum { TRANSPORT_STATE_IDLE, /* Not acquired and suspended */ TRANSPORT_STATE_PENDING, /* Playing but not acquired */ @@ -86,7 +88,7 @@ struct media_owner { struct a2dp_transport { struct avdtp *session; uint16_t delay; - uint16_t volume; + uint8_t volume; }; struct media_transport { @@ -634,7 +636,7 @@ static gboolean volume_exists(const GDBusPropertyTable *property, void *data) struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; - return a2dp->volume <= 127; + return media_transport_volume_valid(a2dp->volume); } static gboolean get_volume(const GDBusPropertyTable *property, @@ -654,24 +656,20 @@ static void set_volume(const GDBusPropertyTable *property, { struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; - uint16_t volume; + uint16_t arg; + uint8_t volume; bool notify; - if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) { - g_dbus_pending_property_error(id, - ERROR_INTERFACE ".InvalidArguments", - "Invalid arguments in method call"); - return; - } + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) + goto error; - dbus_message_iter_get_basic(iter, &volume); + dbus_message_iter_get_basic(iter, &arg); + if (arg > UINT8_MAX) + goto error; - if (volume > 127) { - g_dbus_pending_property_error(id, - ERROR_INTERFACE ".InvalidArguments", - "Invalid arguments in method call"); - return; - } + volume = (uint8_t)arg; + if (!media_transport_volume_valid(volume)) + goto error; g_dbus_pending_property_success(id); @@ -688,6 +686,11 @@ static void set_volume(const GDBusPropertyTable *property, "Volume"); avrcp_set_volume(transport->device, volume, notify); + return; + +error: + g_dbus_pending_property_error(id, ERROR_INTERFACE ".InvalidArguments", + "Invalid arguments in method call"); } static gboolean endpoint_exists(const GDBusPropertyTable *property, void *data) @@ -824,7 +827,7 @@ static int media_transport_init_source(struct media_transport *transport) transport->data = a2dp; transport->destroy = destroy_a2dp; - a2dp->volume = -1; + a2dp->volume = UNINITIALIZED_VOLUME_VALUE; transport->sink_watch = sink_add_state_cb(service, sink_state_changed, transport); @@ -931,7 +934,7 @@ struct btd_device *media_transport_get_dev(struct media_transport *transport) return transport->device; } -uint16_t media_transport_get_volume(struct media_transport *transport) +uint8_t media_transport_get_volume(struct media_transport *transport) { struct a2dp_transport *a2dp = transport->data; return a2dp->volume; @@ -958,7 +961,7 @@ uint8_t media_transport_get_device_volume(struct btd_device *dev) GSList *l; if (dev == NULL) - return 128; + return UNINITIALIZED_VOLUME_VALUE; for (l = transports; l; l = l->next) { struct media_transport *transport = l->data; @@ -991,3 +994,8 @@ void media_transport_update_device_volume(struct btd_device *dev, media_transport_update_volume(transport, volume); } } + +bool media_transport_volume_valid(uint8_t volume) +{ + return volume < 128; +} diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index ac542bf6c..c430515f2 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -32,7 +32,7 @@ struct media_transport *media_transport_create(struct btd_device *device, void media_transport_destroy(struct media_transport *transport); const char *media_transport_get_path(struct media_transport *transport); struct btd_device *media_transport_get_dev(struct media_transport *transport); -uint16_t media_transport_get_volume(struct media_transport *transport); +uint8_t media_transport_get_volume(struct media_transport *transport); void media_transport_update_delay(struct media_transport *transport, uint16_t delay); void media_transport_update_volume(struct media_transport *transport, @@ -43,3 +43,4 @@ void transport_get_properties(struct media_transport *transport, uint8_t media_transport_get_device_volume(struct btd_device *dev); void media_transport_update_device_volume(struct btd_device *dev, uint8_t volume); +bool media_transport_volume_valid(uint8_t volume); -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eEHVKm20F18MNwEAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 05:37:17 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kGmqKW20F18ZEAEAlp8NpQ (envelope-from ); Wed, 22 Jul 2020 05:37:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 20F93400FA; Wed, 22 Jul 2020 05:37:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731943AbgGVDhL (ORCPT + 1 other); Tue, 21 Jul 2020 23:37:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731923AbgGVDhL (ORCPT ); Tue, 21 Jul 2020 23:37:11 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D24F0C061794 for ; Tue, 21 Jul 2020 20:37:10 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id k3so642611qvm.11 for ; Tue, 21 Jul 2020 20:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=9UZr8lVBu9yu6MjFSQdTaOLx7CZsgJFttBxe7lF4F1k=; b=FrM0T9NI+ZISYLb4EczjLjO2IBAE+rqK+2ZEDhN/seaFeAUJEJRfoMJA5BqWnOLhJl phXPTziFAd60sJiPfn+zIiHWsnIs5UMiiu0mGBGxTV9IXXvM1monTCqhlBiiT4fGmeR5 R7szw2tKffrnsR6oRghdrExYnkghKhDHziE3e/bEVRyxTuoT3i3hKC6ZmQwsAw1e9sa4 xZBH9XRZTPvk1ELjsAR6kAGwK29ChxE+nFLNUbiCQEzEbXx0pcWUXHpCIDpYP6d2dvxF RZb0DzCc8ANFX8XqVNjxogheYHh3RqSqnOZP106Ys+H7KhRtEcI+sKCFKriI//EDAGPO 3ryA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=9UZr8lVBu9yu6MjFSQdTaOLx7CZsgJFttBxe7lF4F1k=; b=QZNexVxc+tDxaMB6hYngtnidOoZ1wBTJDH0bSikvCmjAgyLqkZfe4Xb1QaW6q9IJt/ ltiMF2HzIydfFNOcGoHk7S4GcCcMZ+R8UOscUp/42h+n1eCfA6hbwhx8ImfnzckArpY7 XQafe69pJK+kl7N/+79TI5iiO8lQZ0QuBoy1ZStHupB967lIGdjBxQEK0LUWOb1YWht4 LReFtuM9aprD2FpyT+BdVwLqMqtfD2TEKMS+h7bndJXgZzEDgupfZonYI67P09QjNnQd RZr/8GIdEetlGMDtyur/rOh0B2te/b91nORUK8jL8ZeZvNNLe20SE2320vKAnSJ13MG3 +86w== X-Gm-Message-State: AOAM531SqRTy7E8vfjz/KP/VeZGpIV0shfXHR6Zw42BgnNhtgjPJKmEV 5xUt3OjC1UivVZe0h0gUK+Q5kAzJJNoYWckfS2r+FU8B/FKu85UKOhBeSpfg7LsVZbPVQ5zCelJ T/C9/Zs+yxVMirh7H23qUJDH5WIo+Y17NUqBCvua11yb6cmIK+5pYyoC9iAK++ATpv8Ozp+b37s VO X-Google-Smtp-Source: ABdhPJwI/PPW0oPMw1M23EpwZ5kUG+ETXNviUILCtR3X1eD+pvCaJeMeJ4oDRN2q/2LU8RomNT6sOwcAFAb+ X-Received: by 2002:ad4:4d04:: with SMTP id l4mr29133664qvl.245.1595389029917; Tue, 21 Jul 2020 20:37:09 -0700 (PDT) Date: Wed, 22 Jul 2020 11:36:59 +0800 In-Reply-To: <20200722113644.Bluez.v3.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Message-Id: <20200722113644.Bluez.v3.2.Ic16589fde45fac0c496dfca2fa27672059114c3b@changeid> Mime-Version: 1.0 References: <20200722113644.Bluez.v3.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog Subject: [Bluez PATCH v3 2/2] audio/transport: supply volume on transport init From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Yu Liu Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 20F93400FA X-Rspamd-UID: 7da1db From: Archie Pusaka Sometimes the response of RegisterNotification for volume change event came before we create the transport for the corresponding device. If that happens, the volume will be stuck to an uninitialized invalid value. The property Volume of MediaTransport1 will also be left unaccessible. This patch supplies the initial volume when creating a new transport. The value is obtained from the media_player object. However, since the avrcp session might not be created by the time the transport is created, we also try to initialize the volume when creating avrcp session. Reviewed-by: Yu Liu --- Changes in v3: -Add missing library Changes in v2: -Get the volume from media_player instead of from separate list profiles/audio/avrcp.c | 27 ++++++++++++++++- profiles/audio/avrcp.h | 2 ++ profiles/audio/media.c | 60 +++++++++++++++++++++++++++++--------- profiles/audio/media.h | 2 ++ profiles/audio/transport.c | 4 +-- profiles/audio/transport.h | 2 ++ 6 files changed, 79 insertions(+), 18 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index b312b70b9..f59d1cace 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -64,6 +64,7 @@ #include "avctp.h" #include "avrcp.h" #include "control.h" +#include "media.h" #include "player.h" #include "transport.h" @@ -1701,7 +1702,6 @@ static uint8_t avrcp_handle_request_continuing(struct avrcp *session, if (pending->pdu_id != pdu->params[0]) goto err; - len = 0; pending->attr_ids = player_fill_media_attribute(player, pending->attr_ids, @@ -4037,8 +4037,12 @@ static void target_init(struct avrcp *session) player = g_slist_nth_data(server->players, 0); if (player != NULL) { + uint8_t init_volume; target->player = player; player->sessions = g_slist_prepend(player->sessions, session); + + init_volume = media_player_get_device_volume(session->dev); + media_transport_update_device_volume(session->dev, init_volume); } session->supported_events |= (1 << AVRCP_EVENT_STATUS_CHANGED) | @@ -4473,6 +4477,27 @@ int avrcp_set_volume(struct btd_device *dev, uint8_t volume, bool notify) avrcp_handle_set_volume, session); } +struct avrcp_player *avrcp_get_target_player_by_device(struct btd_device *dev) +{ + struct avrcp_server *server; + struct avrcp *session; + struct avrcp_data *target; + + server = find_server(servers, device_get_adapter(dev)); + if (server == NULL) + return NULL; + + session = find_session(server->sessions, dev); + if (session == NULL) + return NULL; + + target = session->target; + if (target == NULL) + return NULL; + + return target->player; +} + static int avrcp_connect(struct btd_service *service) { struct btd_device *dev = btd_service_get_device(service); diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index 3fd74e18a..a9964f4fa 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -116,3 +116,5 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands); size_t avrcp_browsing_general_reject(uint8_t *operands); + +struct avrcp_player *avrcp_get_target_player_by_device(struct btd_device *dev); diff --git a/profiles/audio/media.c b/profiles/audio/media.c index a0173fdd4..4ae936556 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -239,6 +239,20 @@ static void media_endpoint_exit(DBusConnection *connection, void *user_data) media_endpoint_remove(endpoint); } +static struct media_adapter *find_adapter(struct btd_device *device) +{ + GSList *l; + + for (l = adapters; l; l = l->next) { + struct media_adapter *adapter = l->data; + + if (adapter->btd_adapter == device_get_adapter(device)) + return adapter; + } + + return NULL; +} + static void clear_configuration(struct media_endpoint *endpoint, struct media_transport *transport) { @@ -426,6 +440,33 @@ struct a2dp_config_data { a2dp_endpoint_config_t cb; }; +uint8_t media_player_get_device_volume(struct btd_device *device) +{ + struct avrcp_player *target_player; + struct media_adapter *adapter; + GSList *l; + + if (!device) + return UNINITIALIZED_VOLUME_VALUE; + + target_player = avrcp_get_target_player_by_device(device); + if (!target_player) + return UNINITIALIZED_VOLUME_VALUE; + + adapter = find_adapter(device); + if (!adapter) + return UNINITIALIZED_VOLUME_VALUE; + + for (l = adapter->players; l; l = l->next) { + struct media_player *mp = l->data; + + if (mp->player == target_player) + return mp->volume; + } + + return UNINITIALIZED_VOLUME_VALUE; +} + static gboolean set_configuration(struct media_endpoint *endpoint, uint8_t *configuration, size_t size, media_endpoint_cb_t cb, @@ -439,6 +480,7 @@ static gboolean set_configuration(struct media_endpoint *endpoint, const char *path; DBusMessageIter iter; struct media_transport *transport; + uint8_t init_volume; transport = find_device_transport(endpoint, device); @@ -451,6 +493,9 @@ static gboolean set_configuration(struct media_endpoint *endpoint, if (transport == NULL) return FALSE; + init_volume = media_player_get_device_volume(device); + media_transport_update_volume(transport, init_volume); + msg = dbus_message_new_method_call(endpoint->sender, endpoint->path, MEDIA_ENDPOINT_INTERFACE, "SetConfiguration"); @@ -646,20 +691,6 @@ static gboolean endpoint_init_a2dp_sink(struct media_endpoint *endpoint, return TRUE; } -static struct media_adapter *find_adapter(struct btd_device *device) -{ - GSList *l; - - for (l = adapters; l; l = l->next) { - struct media_adapter *adapter = l->data; - - if (adapter->btd_adapter == device_get_adapter(device)) - return adapter; - } - - return NULL; -} - static bool endpoint_properties_exists(const char *uuid, struct btd_device *dev, void *user_data) @@ -1779,6 +1810,7 @@ static struct media_player *media_player_create(struct media_adapter *adapter, mp->sender = g_strdup(sender); mp->path = g_strdup(path); mp->timer = g_timer_new(); + mp->volume = UNINITIALIZED_VOLUME_VALUE; mp->watch = g_dbus_add_disconnect_watch(conn, sender, media_player_exit, mp, diff --git a/profiles/audio/media.h b/profiles/audio/media.h index dd630d432..f84f36d61 100644 --- a/profiles/audio/media.h +++ b/profiles/audio/media.h @@ -33,3 +33,5 @@ void media_unregister(struct btd_adapter *btd_adapter); struct a2dp_sep *media_endpoint_get_sep(struct media_endpoint *endpoint); const char *media_endpoint_get_uuid(struct media_endpoint *endpoint); uint8_t media_endpoint_get_codec(struct media_endpoint *endpoint); + +uint8_t media_player_get_device_volume(struct btd_device *device); diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index a32073380..285bfb714 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -55,8 +55,6 @@ #define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1" -#define UNINITIALIZED_VOLUME_VALUE 128 - typedef enum { TRANSPORT_STATE_IDLE, /* Not acquired and suspended */ TRANSPORT_STATE_PENDING, /* Playing but not acquired */ @@ -981,7 +979,7 @@ void media_transport_update_device_volume(struct btd_device *dev, { GSList *l; - if (dev == NULL) + if (dev == NULL || !media_transport_volume_valid(volume)) return; for (l = transports; l; l = l->next) { diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index c430515f2..46a9c91bd 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -22,6 +22,8 @@ * */ +#define UNINITIALIZED_VOLUME_VALUE 128 + struct media_transport; struct media_transport *media_transport_create(struct btd_device *device, -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wMQlMkXxF1/UZAAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 09:56:53 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id oN/bMEXxF18zYQEA0J78UA (envelope-from ); Wed, 22 Jul 2020 09:56:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E467E40012; Wed, 22 Jul 2020 09:56:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728244AbgGVH4a (ORCPT + 1 other); Wed, 22 Jul 2020 03:56:30 -0400 Received: from verein.lst.de ([213.95.11.211]:55291 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726153AbgGVH4a (ORCPT ); Wed, 22 Jul 2020 03:56:30 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id E5D696736F; Wed, 22 Jul 2020 09:56:20 +0200 (CEST) Date: Wed, 22 Jul 2020 09:56:20 +0200 From: Christoph Hellwig To: Eric Biggers Cc: Christoph Hellwig , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 03/24] net: add a new sockptr_t type Message-ID: <20200722075620.GA26554@lst.de> References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-4-hch@lst.de> <20200720163748.GA1292162@gmail.com> <20200720174322.GA21785@lst.de> <20200720175543.GF1292162@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720175543.GF1292162@gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 14 X-Rspamd-Score: 2.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: E467E40012 X-Rspamd-UID: 657f44 On Mon, Jul 20, 2020 at 10:55:43AM -0700, Eric Biggers wrote: > On Mon, Jul 20, 2020 at 07:43:22PM +0200, Christoph Hellwig wrote: > > On Mon, Jul 20, 2020 at 09:37:48AM -0700, Eric Biggers wrote: > > > How does this not introduce a massive security hole when > > > CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE? > > > > > > AFAICS, userspace can pass in a pointer >= TASK_SIZE, > > > and this code makes it be treated as a kernel pointer. > > > > Yeah, we'll need to validate that before initializing the pointer. > > > > But thinking this a little further: doesn't this mean any > > set_fs(KERNEL_DS) that has other user pointers than the one it is > > intended for has the same issue? Pretty much all of these are gone > > in mainline now, but in older stable kernels there might be some > > interesting cases, especially in the compat ioctl handlers. > > Yes. I thought that eliminating that class of bug is one of the main > motivations for your "remove set_fs" work. See commit 128394eff343 > ("sg_write()/bsg_write() is not fit to be called under KERNEL_DS") for a case > where this type of bug was fixed. > > Are you aware of any specific cases that weren't already fixed? If there are > any, they need to be urgently fixed. current mainline has almost no set_fs left, and setsockopt seems pretty much safe. But if we go back a long term stable release or two I bet I'd find one or two. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wGPDCV/xF18begAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 09:57:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id uIJOCF/xF19jmwEAgupzMw (envelope-from ); Wed, 22 Jul 2020 09:57:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0A96740675; Wed, 22 Jul 2020 09:57:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727042AbgGVH5C (ORCPT + 1 other); Wed, 22 Jul 2020 03:57:02 -0400 Received: from verein.lst.de ([213.95.11.211]:55305 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726807AbgGVH5C (ORCPT ); Wed, 22 Jul 2020 03:57:02 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id B7D966736F; Wed, 22 Jul 2020 09:56:57 +0200 (CEST) Date: Wed, 22 Jul 2020 09:56:57 +0200 From: Christoph Hellwig To: Alexei Starovoitov Cc: Christoph Hellwig , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: get rid of the address_space override in setsockopt Message-ID: <20200722075657.GB26554@lst.de> References: <20200720124737.118617-1-hch@lst.de> <20200720204756.iengwcguikj2yrxt@ast-mbp.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720204756.iengwcguikj2yrxt@ast-mbp.dhcp.thefacebook.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 13 X-Rspamd-Score: 1.97 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0A96740675 X-Rspamd-UID: 2a46c5 On Mon, Jul 20, 2020 at 01:47:56PM -0700, Alexei Starovoitov wrote: > > a kernel pointer. This is something that works for most common sockopts > > (and is something that the ePBF support relies on), but unfortunately > > in various corner cases we either don't use the passed in length, or in > > one case actually copy data back from setsockopt, so we unfortunately > > can't just always do the copy in the highlevel code, which would have > > been much nicer. > > could you rebase on bpf-next tree and we can route it this way then? > we'll also test the whole thing before applying. The bpf-next tree is missing all my previous setsockopt cleanups, so there series won't apply. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eH5RJjnyF1+vNQAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 10:00:57 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id aMfxJDnyF1+xqgEAgupzMw (envelope-from ); Wed, 22 Jul 2020 10:00:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8878DA192B; Wed, 22 Jul 2020 10:00:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbgGVIAg (ORCPT + 1 other); Wed, 22 Jul 2020 04:00:36 -0400 Received: from verein.lst.de ([213.95.11.211]:55326 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726153AbgGVIAg (ORCPT ); Wed, 22 Jul 2020 04:00:36 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id A465468B05; Wed, 22 Jul 2020 10:00:24 +0200 (CEST) Date: Wed, 22 Jul 2020 10:00:23 +0200 From: 'Christoph Hellwig' To: David Laight Cc: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: Re: [PATCH 12/24] bpfilter: switch bpfilter_ip_set_sockopt to sockptr_t Message-ID: <20200722080023.GC26554@lst.de> References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-13-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8878DA192B X-Rspamd-UID: ed5cb6 On Tue, Jul 21, 2020 at 08:36:57AM +0000, David Laight wrote: > From: Christoph Hellwig > > Sent: 20 July 2020 13:47 > > > > This is mostly to prepare for cleaning up the callers, as bpfilter by > > design can't handle kernel pointers. > ^^^ user ?? No, it can't handle user pointers. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EPHoLnHyF1+vNQAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 10:01:53 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id INm6LXHyF1+luwEAgupzMw (envelope-from ); Wed, 22 Jul 2020 10:01:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D6C0FA013F; Wed, 22 Jul 2020 10:01:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727818AbgGVIBs (ORCPT + 1 other); Wed, 22 Jul 2020 04:01:48 -0400 Received: from verein.lst.de ([213.95.11.211]:55344 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbgGVIBr (ORCPT ); Wed, 22 Jul 2020 04:01:47 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 92E6A6736F; Wed, 22 Jul 2020 10:01:42 +0200 (CEST) Date: Wed, 22 Jul 2020 10:01:42 +0200 From: 'Christoph Hellwig' To: David Laight Cc: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: Re: [PATCH 12/24] bpfilter: switch bpfilter_ip_set_sockopt to sockptr_t Message-ID: <20200722080142.GA26841@lst.de> References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-13-hch@lst.de> <20200722080023.GC26554@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200722080023.GC26554@lst.de> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: D6C0FA013F X-Rspamd-UID: a9770c On Wed, Jul 22, 2020 at 10:00:23AM +0200, 'Christoph Hellwig' wrote: > On Tue, Jul 21, 2020 at 08:36:57AM +0000, David Laight wrote: > > From: Christoph Hellwig > > > Sent: 20 July 2020 13:47 > > > > > > This is mostly to prepare for cleaning up the callers, as bpfilter by > > > design can't handle kernel pointers. > > ^^^ user ?? > > No, it can't handle user pointers. Err, I mean it can only handle user pointers. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YA6NO6zzF1+vNQAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 10:07:08 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id YBfWOazzF19/pAEADc0bRg (envelope-from ); Wed, 22 Jul 2020 10:07:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DC6B4A013F; Wed, 22 Jul 2020 10:07:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728574AbgGVIGy (ORCPT + 1 other); Wed, 22 Jul 2020 04:06:54 -0400 Received: from verein.lst.de ([213.95.11.211]:55384 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727034AbgGVIGy (ORCPT ); Wed, 22 Jul 2020 04:06:54 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 2A1836736F; Wed, 22 Jul 2020 10:06:47 +0200 (CEST) Date: Wed, 22 Jul 2020 10:06:46 +0200 From: 'Christoph Hellwig' To: David Laight Cc: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: Re: get rid of the address_space override in setsockopt Message-ID: <20200722080646.GA26864@lst.de> References: <20200720124737.118617-1-hch@lst.de> <60c52e31e9f240718fcda0dd5c2faeca@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <60c52e31e9f240718fcda0dd5c2faeca@AcuMS.aculab.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.38 / 15.00 / 200.00 X-Rspamd-Queue-Id: DC6B4A013F X-Rspamd-UID: e619b8 On Tue, Jul 21, 2020 at 09:38:23AM +0000, David Laight wrote: > From: Christoph Hellwig > > Sent: 20 July 2020 13:47 > > > > setsockopt is the last place in architecture-independ code that still > > uses set_fs to force the uaccess routines to operate on kernel pointers. > > > > This series adds a new sockptr_t type that can contained either a kernel > > or user pointer, and which has accessors that do the right thing, and > > then uses it for setsockopt, starting by refactoring some low-level > > helpers and moving them over to it before finally doing the main > > setsockopt method. > > Are you planning to make the equivalent change to getsockopt()? No. Only setsockopt can be fed kernel addresses from bpf-cgroup. There is no point in complicating the read side interface when it doesn't have that problem. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WENkCtXzF18begAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 10:07:49 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6IXeCNXzF18t9QEAlp8NpQ (envelope-from ); Wed, 22 Jul 2020 10:07:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B0E75A1A49; Wed, 22 Jul 2020 10:07:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729241AbgGVIHa (ORCPT + 1 other); Wed, 22 Jul 2020 04:07:30 -0400 Received: from verein.lst.de ([213.95.11.211]:55401 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726945AbgGVIHa (ORCPT ); Wed, 22 Jul 2020 04:07:30 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 2537A6736F; Wed, 22 Jul 2020 10:07:25 +0200 (CEST) Date: Wed, 22 Jul 2020 10:07:24 +0200 From: 'Christoph Hellwig' To: David Laight Cc: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: Re: get rid of the address_space override in setsockopt Message-ID: <20200722080724.GB26864@lst.de> References: <20200720124737.118617-1-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 10 X-Rspamd-Score: 1.63 / 15.00 / 200.00 X-Rspamd-Queue-Id: B0E75A1A49 X-Rspamd-UID: a41ed6 On Tue, Jul 21, 2020 at 10:26:58AM +0000, David Laight wrote: > From: Christoph Hellwig > > Sent: 20 July 2020 13:47 > > > > setsockopt is the last place in architecture-independ code that still > > uses set_fs to force the uaccess routines to operate on kernel pointers. > > > > This series adds a new sockptr_t type that can contained either a kernel > > or user pointer, and which has accessors that do the right thing, and > > then uses it for setsockopt, starting by refactoring some low-level > > helpers and moving them over to it before finally doing the main > > setsockopt method. > > Another 'gotcha' ... > > On an least some architectures (possibly only m68k) IIRC all structures > are actually passed by reference. > (This used to be true for sparc - but it may have changed in the > last 30 years.) Tough luck for ABIs wit suboptimal calling conventions. At least we can do the right thing for those that do not have the problem. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iG+dBhr3F1/mvQAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 10:21:46 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id uAG0BRr3F18jRwEA0J78UA (envelope-from ); Wed, 22 Jul 2020 10:21:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6326140F43; Wed, 22 Jul 2020 10:21:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729295AbgGVIV2 convert rfc822-to-8bit (ORCPT + 1 other); Wed, 22 Jul 2020 04:21:28 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:60904 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726930AbgGVIV1 (ORCPT ); Wed, 22 Jul 2020 04:21:27 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-223-GOCHn8gEMPq2t1xF6Q8jCw-1; Wed, 22 Jul 2020 09:21:22 +0100 X-MC-Unique: GOCHn8gEMPq2t1xF6Q8jCw-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 22 Jul 2020 09:21:21 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Wed, 22 Jul 2020 09:21:21 +0100 From: David Laight To: 'Christoph Hellwig' CC: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: RE: get rid of the address_space override in setsockopt Thread-Topic: get rid of the address_space override in setsockopt Thread-Index: AQHWXznU7Ce8ImOXV0WGgKrMes+hhakRxpwAgAFoQgCAABQIEA== Date: Wed, 22 Jul 2020 08:21:21 +0000 Message-ID: References: <20200720124737.118617-1-hch@lst.de> <60c52e31e9f240718fcda0dd5c2faeca@AcuMS.aculab.com> <20200722080646.GA26864@lst.de> In-Reply-To: <20200722080646.GA26864@lst.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.37 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6326140F43 X-Rspamd-UID: 00d238 From: 'Christoph Hellwig' > Sent: 22 July 2020 09:07 > On Tue, Jul 21, 2020 at 09:38:23AM +0000, David Laight wrote: > > From: Christoph Hellwig > > > Sent: 20 July 2020 13:47 > > > > > > setsockopt is the last place in architecture-independ code that still > > > uses set_fs to force the uaccess routines to operate on kernel pointers. > > > > > > This series adds a new sockptr_t type that can contained either a kernel > > > or user pointer, and which has accessors that do the right thing, and > > > then uses it for setsockopt, starting by refactoring some low-level > > > helpers and moving them over to it before finally doing the main > > > setsockopt method. > > > > Are you planning to make the equivalent change to getsockopt()? > > No. Only setsockopt can be fed kernel addresses from bpf-cgroup. > There is no point in complicating the read side interface when it > doesn't have that problem. You realise that one of the SCTP getsockopt() is actually a command! It is one of the requests that changes state and should probably have been a separate system call. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kGx9Jlv4F1/rvQAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 10:27:07 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cCdDJVv4F19vxAEADc0bRg (envelope-from ); Wed, 22 Jul 2020 10:27:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=tessares-net.20150623.gappssmtp.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3ECFFA17D2; Wed, 22 Jul 2020 10:27:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729196AbgGVI0u (ORCPT + 1 other); Wed, 22 Jul 2020 04:26:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728599AbgGVI0s (ORCPT ); Wed, 22 Jul 2020 04:26:48 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B10DFC0619E8 for ; Wed, 22 Jul 2020 01:26:46 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id dm19so969238edb.13 for ; Wed, 22 Jul 2020 01:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares-net.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ijnpSqTzlWs7OuuIHaz94zTqsgZ4TkbrlxGL7rF8SvM=; b=xFRbFe5eYCppxJ62qFkLFv33fQa9ER4RHEl34g5WwIC4xdcR+4tivo7mnn1S+rNlbS cMN8QwQ1eW0avv9rFxBRIQMUktSGW06zNgKrNWQvq5F25hq8QLzdYCQ1hmqL4iSIvq09 Szc8YdqC97qHUqKRHbhQr8/oguhWktZDZtVMGTavTEfzVAENBpjq7LQbsQSFC/Qb56AS G/7MNxNktsXQmENPoH9ousqNoZVBW0eyiSYtxkhGP/mapdbBWtSCpZCTmHbB+1rtyqO0 wY2Oxf7ffMMplrOPj5lpx8Ya/rpegVFUOFLBmwqnjZVN6pLS4eW+iRKkCxAtMw4/FDqK d09g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ijnpSqTzlWs7OuuIHaz94zTqsgZ4TkbrlxGL7rF8SvM=; b=i2o0oG5/ieC2XQbXx9UqvpbL76I/atiyLXiGIWm4eO1N5qiEzIjES1ooapLtCFKY/0 LUWtsjmvbfSyTw2RC/xSd1GUf/wNDSQ6akaTSWROgz4ufnDjdDWfjXoZsMUVnYnHxtuD 61bAwoUOftTkpn62ttRmaAbHcXVnvHjj22cFm2ehVwc9REqs9VLfqFuxgh+1gkIBHGEA znLQNk2xLfbLq1MV8AOB/HSAOjH7Bm43e1Y9eZ70iTJgJVMRDuRrBlY9z3kAyhc0sgyQ nmbO2G9DD8kMYoVjwdhCzzVsBL3buZbc4ui123jaFd94fKVEzXozQTd/BfLfnAWMydrL /zKA== X-Gm-Message-State: AOAM533K6D5pD+GGVA4kaEUg8jHGaxLciZnbNhdEdhjrlT3YtHz9T3Ht E99Syo/sFrsGUSHd4j+rtw8X4A== X-Google-Smtp-Source: ABdhPJxnWSvai+9iaNos8sJtXdeBHraQbZUkyduEvMUxv8nKJJQfjOWUUSDiYYhu744BzkT/PRbBSQ== X-Received: by 2002:aa7:d341:: with SMTP id m1mr28525320edr.50.1595406404862; Wed, 22 Jul 2020 01:26:44 -0700 (PDT) Received: from tsr-lap-08.nix.tessares.net ([79.132.248.22]) by smtp.gmail.com with ESMTPSA id x16sm19025267edr.52.2020.07.22.01.26.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jul 2020 01:26:44 -0700 (PDT) Subject: Re: [MPTCP] [PATCH 24/24] net: pass a sockptr_t into ->setsockopt To: Christoph Hellwig Cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org References: <20200720124737.118617-1-hch@lst.de> <20200720124737.118617-25-hch@lst.de> From: Matthieu Baerts Message-ID: Date: Wed, 22 Jul 2020 10:26:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200720124737.118617-25-hch@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 3 X-Rspamd-Score: 0.50 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3ECFFA17D2 X-Rspamd-UID: e47136 Hi Christoph, On 20/07/2020 14:47, Christoph Hellwig wrote: > Rework the remaining setsockopt code to pass a sockptr_t instead of a > plain user pointer. This removes the last remaining set_fs(KERNEL_DS) > outside of architecture specific code. > > Signed-off-by: Christoph Hellwig > --- ... > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c > index 27b6f250b87dfd..30a8e697b9db9c 100644 > --- a/net/mptcp/protocol.c > +++ b/net/mptcp/protocol.c > @@ -1627,7 +1627,7 @@ static void mptcp_destroy(struct sock *sk) > } > > static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct sock *sk = (struct sock *)msk; > struct socket *ssock; > @@ -1643,8 +1643,8 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, > return -EINVAL; > } > > - ret = sock_setsockopt(ssock, SOL_SOCKET, optname, > - USER_SOCKPTR(optval), optlen); > + ret = sock_setsockopt(ssock, SOL_SOCKET, optname, optval, > + optlen); A very small detail related to the modifications in MPTCP code, only if you have to send a v2 and if you don't mind: may you move "optlen" to the previous line like it was before your patch 7/24. Same below at the end of the function. That would reduce the global diff in MPTCP files to function signatures only. Cheers, Matt -- Tessares | Belgium | Hybrid Access Solutions www.tessares.net Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4MofNeT5F1/rvQAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 10:33:40 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id YGZbM+T5F18kwgEADc0bRg (envelope-from ); Wed, 22 Jul 2020 10:33:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2907DA1BD0; Wed, 22 Jul 2020 10:33:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730846AbgGVIcq (ORCPT + 1 other); Wed, 22 Jul 2020 04:32:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730308AbgGVIcp (ORCPT ); Wed, 22 Jul 2020 04:32:45 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15C10C0619DC for ; Wed, 22 Jul 2020 01:32:45 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id h22so1561888lji.9 for ; Wed, 22 Jul 2020 01:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=IMVVJQQuxuEV0PUj8MxtntHQHgLdO4Fa98kN1mhXpqs=; b=onzlud5VX/igA7rZHiE3FOxPFG/rs9p6WvI+ksOXg876vfHHljJQzKnjQ5ysI2ZS2y reyGRYdFKcd0aGuAebfqlSnCjiq1M5DTds3AmonOQjPpF3SCoNZdWMXyr9R15jncfL5j 2cD9zgwtI6yzL20ZkBHbwbBndtznr21Nef9AMzFfaKRn1DU1Gggwi+5Am5pcoWbi1h9p Qu+RxGM+eJdXNSKBEzWS3ZXLQ3p5Fwi+sk8yRriggD8xc8qI0oi0S+AZBusuCN39Q/aQ Nj8EzHvhy1+dOC86TSHrnaDRqiPL2LtwfF3qlA5NzWe9BO6CIHKN+K5KWunAUdZw/Puo qg6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=IMVVJQQuxuEV0PUj8MxtntHQHgLdO4Fa98kN1mhXpqs=; b=Bq23M18tVk7VmhDmzlwjtXYgeqUAYaczWsqhftSG05H6c9pi+ick6jlvFidfi78duM 95ceG5Zq1CTN2PmAHGGyoqpvrmAhsfGj3RLRC6wz05lehNXypIcUyPWYQEWEprpNk1Vf /9MsBZ701Spvudsj6O2k7kT9W23+P77RfHlGsdxmryulPrsz+Vi+JS54UEqeYfwrJMQ4 woeXDZAcymny/9FnsRmio+B+qGI5ZlhpFiV9TzU9MQU9t9mIr7ITtHpMgkvCLpqUyxy/ oAnleDdlULecnmkDObeDGNTnw8sbyb1Wur4XPiNrzbiT9u25b3S+lv6UvhK5YoEl1rqx 2XlQ== X-Gm-Message-State: AOAM532zxpnxVLKu/cCM91P5nCWxbjoG4MnyvDErJlPhT8gVEIcwVpIP AsAi2LhMMceQiZT60VtyNYssfSsYBbOVipFbCBGAY+RsGL0= X-Google-Smtp-Source: ABdhPJymKqHSvC96L7W6mkTFM2zTw6gldpTrylO/EzhIHxk6+O3M7C0IzjrQgYTkUMxHyIA3SnYb704exkfgDnBaSeg= X-Received: by 2002:a05:651c:8c:: with SMTP id 12mr13432655ljq.420.1595406762356; Wed, 22 Jul 2020 01:32:42 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Barry Byford <31baz66@gmail.com> Date: Wed, 22 Jul 2020 09:32:30 +0100 Message-ID: Subject: Re: Networking - NetworkServer1 To: Bluez mailing list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2907DA1BD0 X-Rspamd-UID: f1d4b3 Hi Luiz, Thanks for the quick response. Very much appreciated. On Wed, 22 Jul 2020 at 00:27, Luiz Augusto von Dentz wrote: > > =3D bluetoothd: bnep: Can't add bnep0 to the bridge tether: No such > > device(19) 21:54:01.138304 > > Well it looks like the bridge (tether) does not exist so we can't add > the bnep interface, perhaps the idea is not to have it attached to any > bridge in case of GN, PAN and just bring the interface up when an > empty string is given as bridge. > An empty string also produced the error. However, I created a bridge using the bridge utilities package $ sudo apt install bridge-utils $ sudo brctl addbr bluez And then used server.Register('panu', 'bluez') This enabled the connection to be accepted from the client to happen without error. $ service bluetooth status =E2=97=8F bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2020-07-21 09:27:49 BST; 24h ago Docs: man:bluetoothd(8) Main PID: 625 (bluetoothd) Status: "Running" Tasks: 1 (limit: 2200) Memory: 3.3M CGroup: /system.slice/bluetooth.service =E2=94=94=E2=94=80625 /usr/lib/bluetooth/bluetoothd --experiment= al Jul 22 07:27:43 raspberrypi bluetoothd[625]: bnep: bridge bluez: interface bnep0 added I think the bridge probably needs more refinement as there does not appear to be a route between the two devices still. Any pointers on that appreciated. Thanks again for your help on this Luiz. Regards, Barry $ brctl show bridge name bridge id STP enabled interfaces bluez 8000.b827eb2257e0 no bnep0 $ brctl showstp bluez bluez bridge id 8000.b827eb2257e0 designated root 8000.b827eb2257e0 root port 0 path cost = 0 max age 20.00 bridge max age 2= 0.00 hello time 2.00 bridge hello time = 2.00 forward delay 15.00 bridge forward delay 1= 5.00 ageing time 300.00 hello timer 0.00 tcn timer = 0.00 topology change timer 0.00 gc timer = 0.00 flags bnep0 (1) port id 8001 state disa= bled designated root 8000.b827eb2257e0 path cost 10= 0 designated bridge 8000.b827eb2257e0 message age timer = 0.00 designated port 8001 forward delay timer = 0.00 designated cost 0 hold timer = 0.00 flags $ ifconfig bluez bluez: flags=3D4098 mtu 1500 ether b8:27:eb:22:57:e0 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 $ ifconfig bnep0 bnep0: flags=3D4163 mtu 1500 inet 169.254.91.109 netmask 255.255.0.0 broadcast 169.254.255.255 inet6 fe80::ba27:ebff:fe22:57e0 prefixlen 64 scopeid 0x20 inet6 fe80::64d6:60a1:4a0d:3e4 prefixlen 64 scopeid 0x20 ether b8:27:eb:22:57:e0 txqueuelen 1000 (Ethernet) RX packets 111 bytes 20669 (20.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 57 bytes 16084 (15.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 $ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Ifa= ce 0.0.0.0 192.168.1.254 0.0.0.0 UG 202 0 0 eth= 0 169.254.0.0 0.0.0.0 255.255.0.0 U 233 0 0 bne= p0 192.168.1.0 0.0.0.0 255.255.255.0 U 202 0 0 eth= 0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cL92O2BnGF/6uwEAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 18:20:48 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id KB4HOmBnGF+BPQEA0J78UA (envelope-from ); Wed, 22 Jul 2020 18:20:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 73BADA17D2; Wed, 22 Jul 2020 18:20:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728821AbgGVQUn (ORCPT + 1 other); Wed, 22 Jul 2020 12:20:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726649AbgGVQUm (ORCPT ); Wed, 22 Jul 2020 12:20:42 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A23A8C0619DC for ; Wed, 22 Jul 2020 09:20:42 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id i3so1791478qkf.0 for ; Wed, 22 Jul 2020 09:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=qs3lYzmo9cqp4fumqX6CW3QqvW1CbWYAHI9HVd1WRcQ=; b=kNNujD3czFwvnsHM5188PpNTRjXV7Oe6kT441O/ElcuN+jKR4nSu+JcbMxp4fkXjfw JCpqdGrTHPmiYnolYX2KjfJiC9jnsDd3XffsW7RGGDeDgr0ag5ImFGGjeS3WJjvHxbz+ z9sGRZsMv9bAcoiGenBoP1et03dhezjCscVyEEychL01H2XsMfBfvqeSIydjiKLAddLC e0YEa24KB3qydo5aUxvozQ0wO1wc2G6YoEmrBaPQGgtoyA3vM+U9508fggi+Hkn4Ryi8 DD6g3y2NOtAgpVXzqFRg7O93O5usX5YE8WmzH2OSHqYwhp63lBKEuR2h7+NTK+hulQzq xZYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=qs3lYzmo9cqp4fumqX6CW3QqvW1CbWYAHI9HVd1WRcQ=; b=fWBcxYh02V8Ky+4Yp/w58jJjrb59/ZC/tK4vCnignJxyyUG7nFQ5xUtYbEmcONcJLn aPiPECEcWTfoGDi112jjZAnOuCfH4NRe2hhh9yQAzg4TpK1IQXoTyXuOR2iE2UyrSiYy 7QXJGwwUh6+ORJ3zgEo7HAjYCvkv/1/svLemQmvJF/F2lVuf41WJREhTm9+4Qagz3Prw fGNi5hLUu4z1tGA9XT8o1sq/fPnvUQeSGUoSma1LNQAso8sKOlEXnE+KEXkAHvadygaV vkuroagWin2n717m7iZ+OLZ0gXKb9dEPyiGsnYj0aMQusk5sH0UFCX3/2eFNyhFtKeQ/ aYMA== X-Gm-Message-State: AOAM533jNsRQe0HXV/pj4CNl9j+Y38ovCzYkarxU8f22ySd6YCJlScuO V3L2zhizTBzZfNPIhIJrSDfEh1lzeAcpP8A+Y6jaBGcwKbvhGhzKr2WiJ8ZSfUdSAQ5CtmyUiLR DmZz0mxGUL1BiHJ8kf0VKVMLFAA2kBVkS2r1ZEugMT8QdvDizEqGf25HMrPwRHofBHhut1xxYoU p3 X-Google-Smtp-Source: ABdhPJwO+WDirnSZBnQSyTLPIFKLheKCmBQRZhMupwopyfOuYutTRZDzdJed4rr4pTXOgvHRjQAzYlvMqbiP X-Received: by 2002:a0c:9e52:: with SMTP id z18mr737177qve.59.1595434841622; Wed, 22 Jul 2020 09:20:41 -0700 (PDT) Date: Thu, 23 Jul 2020 00:20:32 +0800 Message-Id: <20200723002022.Bluez.v1.1.I45e09d196073f099e1b67d2d69efd5cd20237ad1@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog Subject: [Bluez PATCH v1 1/2] input: authenticate when connecting to a bonded device From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 73BADA17D2 X-Rspamd-UID: 8c7a86 From: Archie Pusaka According to bluetooth HID1.1 spec, part 5.4.3.4.3: If the Bluetooth HID Host is bonded to a Bluetooth HID device: If encryption is not already enabled, the Bluetooth HID Host shall enable encryption with the Bluetooth HID device before sending an L2CAP Connect Request to open the HID L2CAP Control channel. When creating connection, this patch checks whether the target device is bonded, if yes then we use the medium security level instead of the low one to enable encryption. Reviewed-by: Alain Michaud --- profiles/input/device.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index 2dc2ecab2..9f89f4459 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -112,6 +112,12 @@ void input_set_classic_bonded_only(bool state) static void input_device_enter_reconnect_mode(struct input_device *idev); static int connection_disconnect(struct input_device *idev, uint32_t flags); +static bool input_device_bonded(struct input_device *idev) +{ + return device_is_bonded(idev->device, + btd_device_get_bdaddr_type(idev->device)); +} + static void input_device_free(struct input_device *idev) { bt_uhid_unref(idev->uhid); @@ -979,8 +985,7 @@ static int hidp_add_connection(struct input_device *idev) device_get_name(idev->device, req->name, sizeof(req->name)); /* Make sure the device is bonded if required */ - if (classic_bonded_only && !device_is_bonded(idev->device, - btd_device_get_bdaddr_type(idev->device))) { + if (classic_bonded_only && !input_device_bonded(idev)) { error("Rejected connection from !bonded device %s", dst_addr); goto cleanup; } @@ -1153,16 +1158,23 @@ static int dev_connect(struct input_device *idev) { GError *err = NULL; GIOChannel *io; + BtIOSecLevel sec_level; if (idev->disable_sdp) bt_clear_cached_session(&idev->src, &idev->dst); + /* encrypt connection if device is bonded */ + if (input_device_bonded(idev)) + sec_level = BT_IO_SEC_MEDIUM; + else + sec_level = BT_IO_SEC_LOW; + io = bt_io_connect(control_connect_cb, idev, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, &idev->src, BT_IO_OPT_DEST_BDADDR, &idev->dst, BT_IO_OPT_PSM, L2CAP_PSM_HIDP_CTRL, - BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, + BT_IO_OPT_SEC_LEVEL, sec_level, BT_IO_OPT_INVALID); idev->ctrl_io = io; @@ -1227,8 +1239,7 @@ static void input_device_enter_reconnect_mode(struct input_device *idev) reconnect_mode_to_string(idev->reconnect_mode)); /* Make sure the device is bonded if required */ - if (classic_bonded_only && !device_is_bonded(idev->device, - btd_device_get_bdaddr_type(idev->device))) + if (classic_bonded_only && !input_device_bonded(idev)) return; /* Only attempt an auto-reconnect when the device is required to -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2JETHm5nGF+mowEAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 18:21:02 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AGtVHG5nGF+AkAEAgupzMw (envelope-from ); Wed, 22 Jul 2020 18:21:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3A385A1A52; Wed, 22 Jul 2020 18:20:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726938AbgGVQU4 (ORCPT + 1 other); Wed, 22 Jul 2020 12:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726535AbgGVQU4 (ORCPT ); Wed, 22 Jul 2020 12:20:56 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD100C0619DC for ; Wed, 22 Jul 2020 09:20:55 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id i203so2900635yba.9 for ; Wed, 22 Jul 2020 09:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=6O+2S1vqoOM1pGQ5IMq7IrTBnWEmCGoXKJEKgM6sXHM=; b=sK7DmyvvTRqoxviUC1rV/Pptdlgh1q1QSx548MbzXrWeGvVvKSXgv2ahNhnvhhI417 pJ8BdU2jiCpzY34TzRQgzG4gWkgKKPlTydYF+WgFeAmJMF78miVY6SGAeCUJg8+glMgi p+wPxP3gbNTtJjKdKiIkGgQRYy53MdbeBGz0ZVbuqAPChNhqzU35ZvqVqfJWJmXTSgEX GyaOVgs59yMCqTjKUgnBI3nSbuAIg2ZAyDN2iMNTgImNiKUlawzpo3wfs1+atNbOZwqs 3i4K3BnXmHP0+cIjMFMdx5kt4xPyjMu+mbzP/49NLHxZUKgIfNaHArlXOrDkc4h9GJUq NIaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=6O+2S1vqoOM1pGQ5IMq7IrTBnWEmCGoXKJEKgM6sXHM=; b=JOnSPKTBY5jZgVWw08sepsgF0Flg+b0f23fT9+B+48VwxsXWXiEsGx2RMiCX2R3qQ4 lY2AeHLuS0fDsl5TY7N7YSyVvSOFIQCQCYuVe46Pz8P6eUi8MsvfI94czWFnVbSITwJu JgtcJj0UPRDvNFz/jkCluEOBypbk/ULAC/1b5JX8fIUrVlNKGBMY2JkQEQ3tEQPa9cY2 9IN4AKI2PDi3DI5xitdfJQrhpOT+f+a0fU2d1SzTSUYmE1N48KNafGEpQIj+EGk2sALI 60BcW5lRQ2I4hcaYW1J66aV5J1tgi2RXm/nm6LNnmh43EXlS6uxw5y/gZuvdE/N2A71b LGhw== X-Gm-Message-State: AOAM532T/CsACk4Zqo+1hFNqA0A+MwJYgEEv3zkhNwOp1HfwvI0JqWcj /dgIExbYt8g/rInLV1fJQ8eubFM1jZGbnxmKCb+Fdg7KoMh4AV3CCxGzsB2VqA/aIsSZUfAYDOY ab33rZBwovt3u1DQFgXz1wQd/1jGx/f/qVfGn5ZTCAmH53paXW5ylQfI6DQe0xdvtLObFlqWWhQ 1+ X-Google-Smtp-Source: ABdhPJymqBv14YTpqNe5yOj3F0sSyhXYwnojkSGVh7/9DwCiGVkUNyKtiFd3933ip2hTUWbGkG5i3VE5dLkq X-Received: by 2002:a25:618e:: with SMTP id v136mr185735ybb.432.1595434854998; Wed, 22 Jul 2020 09:20:54 -0700 (PDT) Date: Thu, 23 Jul 2020 00:20:33 +0800 In-Reply-To: <20200723002022.Bluez.v1.1.I45e09d196073f099e1b67d2d69efd5cd20237ad1@changeid> Message-Id: <20200723002022.Bluez.v1.2.If59e157d622b3f90c4b92919567a4662a2137806@changeid> Mime-Version: 1.0 References: <20200723002022.Bluez.v1.1.I45e09d196073f099e1b67d2d69efd5cd20237ad1@changeid> X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog Subject: [Bluez PATCH v1 2/2] input: encrypt on receive conn req if classic_bonded_only From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3A385A1A52 X-Rspamd-UID: 75c573 From: Archie Pusaka According to bluetooth HID1.1 spec, section 5.4.3.5.3: If the Bluetooth HID Host is bonded to a Bluetooth HID device: If encryption is not already enabled, the Bluetooth HID Host shall enable encryption with the Bluetooth HID device before sending an L2CAP Connect Response with a result code of =E2=80=9CConnection Successful= =E2=80=9D (0x0000) after an L2CAP Connect Request is received. This patch raises the security level to medium when listening for incoming connection if the flag classic_bonded_only is set, effectively starting encryption. Reviewed-by: Alain Michaud --- profiles/input/device.c | 5 +++++ profiles/input/device.h | 1 + profiles/input/server.c | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index 9f89f4459..6ec0a4c63 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -109,6 +109,11 @@ void input_set_classic_bonded_only(bool state) classic_bonded_only =3D state; } =20 +bool input_get_classic_bonded_only(void) +{ + return classic_bonded_only; +} + static void input_device_enter_reconnect_mode(struct input_device *idev); static int connection_disconnect(struct input_device *idev, uint32_t flags= ); =20 diff --git a/profiles/input/device.h b/profiles/input/device.h index 5a077f92a..f61e8a558 100644 --- a/profiles/input/device.h +++ b/profiles/input/device.h @@ -30,6 +30,7 @@ struct input_conn; void input_set_idle_timeout(int timeout); void input_enable_userspace_hid(bool state); void input_set_classic_bonded_only(bool state); +bool input_get_classic_bonded_only(void); void input_set_auto_sec(bool state); =20 int input_device_register(struct btd_service *service); diff --git a/profiles/input/server.c b/profiles/input/server.c index f2c8c0f70..2bd5e92e4 100644 --- a/profiles/input/server.c +++ b/profiles/input/server.c @@ -283,6 +283,8 @@ int server_start(const bdaddr_t *src) { struct input_server *server; GError *err =3D NULL; + BtIOSecLevel sec_level =3D input_get_classic_bonded_only() ? + BT_IO_SEC_MEDIUM : BT_IO_SEC_LOW; =20 server =3D g_new0(struct input_server, 1); bacpy(&server->src, src); @@ -291,7 +293,7 @@ int server_start(const bdaddr_t *src) server, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, src, BT_IO_OPT_PSM, L2CAP_PSM_HIDP_CTRL, - BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, + BT_IO_OPT_SEC_LEVEL, sec_level, BT_IO_OPT_INVALID); if (!server->ctrl) { error("Failed to listen on control channel"); @@ -304,7 +306,7 @@ int server_start(const bdaddr_t *src) server, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, src, BT_IO_OPT_PSM, L2CAP_PSM_HIDP_INTR, - BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, + BT_IO_OPT_SEC_LEVEL, sec_level, BT_IO_OPT_INVALID); if (!server->intr) { error("Failed to listen on interrupt channel"); --=20 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sCW3HfdyGF/4BAAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 19:10:15 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2Mh+HPdyGF/9EwAAlp8NpQ (envelope-from ); Wed, 22 Jul 2020 19:10:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A37CDA1664; Wed, 22 Jul 2020 19:10:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730381AbgGVRJz (ORCPT + 1 other); Wed, 22 Jul 2020 13:09:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbgGVRJz (ORCPT ); Wed, 22 Jul 2020 13:09:55 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBCACC0619DC; Wed, 22 Jul 2020 10:09:54 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id h19so3257561ljg.13; Wed, 22 Jul 2020 10:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nqelWpCqH7nOe0oSyngzrBNpGRC3PyDyz91JHpls3Xk=; b=QbFOpYWq197fvdaI4E7hogiJ5z6DhlnMwFbSAyObyOYxQk/ojAWvAxU5xeCwIzRoyp bGpv6okHRbaDCk3F5IJgGXS3Wesi1t0HKLxD0rWbntKFa+o4FEuZ/aNqddB2gT9rJhFi ekTLt46VwAAqYYSOS+Ti6gpiM2sULyDbPlDxrV2EC1wYfvYmkCiCMfUA2sia4+eUOZSm DpKqJKTrsnJtuquGnG9/42hXesw1S5DhQmqbpijEy6OLbaHF8RyBbV+paN+wC914K+DB Om2JyFGEZL8bVoXG7xFZFOn3b/hxnJAALpQKOVax/+9YzLSzmIzDLinAT6/sMjMDDXxC pBiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nqelWpCqH7nOe0oSyngzrBNpGRC3PyDyz91JHpls3Xk=; b=k3wIByikShOaLkMc1Od1tLGwmab7hG9iKbyDULD2uOU+twM7jxZwJn7IWxMKu4MHdb 2Um8GRz1pnUx6Or1zrBKsXK1VsWCVoqGK+g00uoLdXwN0ZIjQs2SY1NcE1kAF8LDVTbU yec/VCQcloskNDtE/ZzYq3LleNJ4xRU3nJ3wI0s/geljdUP2TUb94FrsAN6b/v2V85qz Jc8CdA/0064dg3bpth9PgXEMbwg5daPhBpS5N9zJpR/T9aF3Yn/Utf8++olez5sBFyLk PhS8JcXdC8vjOKTUaUQOoc6YRUqpWtVVYj0gjyhYOFPmkN984ejeamHM/Bn02+cBPon8 gMPw== X-Gm-Message-State: AOAM531Eo1Acr/3nE2b3iA/QDxbQGbfSLq/pJjtA4rrQ+YuHqM+38kBs PxMKDcJqZcbVcOCj/Ts6eT4QBe1XJMs+YgpX9dqBNA== X-Google-Smtp-Source: ABdhPJzXtI3YBeORsJYQmEu28fVJCUtGV7rd5sI5b8tsC3G9617tl0t2hP5zU+hEdegWolMtC+F/64n4emjrett5jt8= X-Received: by 2002:a2e:90da:: with SMTP id o26mr95292ljg.91.1595437793253; Wed, 22 Jul 2020 10:09:53 -0700 (PDT) MIME-Version: 1.0 References: <20200720124737.118617-1-hch@lst.de> <20200720204756.iengwcguikj2yrxt@ast-mbp.dhcp.thefacebook.com> <20200722075657.GB26554@lst.de> In-Reply-To: <20200722075657.GB26554@lst.de> From: Alexei Starovoitov Date: Wed, 22 Jul 2020 10:09:41 -0700 Message-ID: Subject: Re: get rid of the address_space override in setsockopt To: Christoph Hellwig Cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , Linux Crypto Mailing List , LKML , Network Development , bpf , netfilter-devel , coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, "moderated list:ETHERNET BRIDGE" , linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390 , mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: A37CDA1664 X-Rspamd-UID: e5a32e On Wed, Jul 22, 2020 at 12:56 AM Christoph Hellwig wrote: > > On Mon, Jul 20, 2020 at 01:47:56PM -0700, Alexei Starovoitov wrote: > > > a kernel pointer. This is something that works for most common sockopts > > > (and is something that the ePBF support relies on), but unfortunately > > > in various corner cases we either don't use the passed in length, or in > > > one case actually copy data back from setsockopt, so we unfortunately > > > can't just always do the copy in the highlevel code, which would have > > > been much nicer. > > > > could you rebase on bpf-next tree and we can route it this way then? > > we'll also test the whole thing before applying. > > The bpf-next tree is missing all my previous setsockopt cleanups, so > there series won't apply. Right. I've realized that after sending that email two days ago. Now bpf-next->net-next PR is pending and as soon as it's merged bpf-next will have all the recent bits. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AExSDC2CGF/2JgAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 20:15:09 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id kBxcCy2CGF+2hgEA0J78UA (envelope-from ); Wed, 22 Jul 2020 20:15:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 64CAE40012; Wed, 22 Jul 2020 20:15:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732281AbgGVSPA (ORCPT + 1 other); Wed, 22 Jul 2020 14:15:00 -0400 Received: from mga04.intel.com ([192.55.52.120]:11447 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbgGVSO7 (ORCPT ); Wed, 22 Jul 2020 14:14:59 -0400 IronPort-SDR: QIflQCchklT5IrYu1Wn3z78uP4zEacvDFwBt/uxjnosPXOgdTfVMuB8tErLAFw06bjmwGVW6Zc UNyREPrypiuQ== X-IronPort-AV: E=McAfee;i="6000,8403,9690"; a="147896368" X-IronPort-AV: E=Sophos;i="5.75,383,1589266800"; d="scan'208";a="147896368" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2020 11:14:50 -0700 IronPort-SDR: MbZ+ZZfxQKuGbKFhJCcPRMFbHv27Wlc7vz1uYgX+WXWvqBNsk81nMJuFGbkC4Bk1RdryFf+WAn 8lWfOp9558OA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,383,1589266800"; d="scan'208";a="392761750" Received: from preetima-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.114.67]) by fmsmga001.fm.intel.com with ESMTP; 22 Jul 2020 11:14:49 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ v3] mesh: Move model functionality out of node.c to model.c Date: Wed, 22 Jul 2020 11:14:49 -0700 Message-Id: <20200722181449.314370-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 64CAE40012 X-Rspamd-UID: 751053 This moves the model related code out of node.c to model.c providing for better functional separation of modules. Also, use the value of 0xFFFF for internal representation of vendor ID for BT SIG defined models. This allows to maintain a single internal vendor ID / model ID space. --- mesh/cfgmod-server.c | 185 +++++++------- mesh/cfgmod.h | 4 +- mesh/mesh-config-json.c | 5 +- mesh/model.c | 543 +++++++++++++++++++++++++++------------- mesh/model.h | 74 +++--- mesh/node.c | 318 ++++------------------- mesh/node.h | 4 +- 7 files changed, 555 insertions(+), 578 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 9046a1ad9..e98782484 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -2,7 +2,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. + * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * * This library is free software; you can redistribute it and/or @@ -42,7 +42,7 @@ static uint8_t msg[MAX_MSG_LEN]; static void send_pub_status(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, uint32_t mod_id, + uint8_t status, uint16_t ele_addr, uint32_t id, uint16_t pub_addr, uint16_t idx, bool cred_flag, uint8_t ttl, uint8_t period, uint8_t retransmit) { @@ -59,12 +59,12 @@ static void send_pub_status(struct mesh_node *node, uint16_t net_idx, msg[n++] = period; msg[n++] = retransmit; - if (mod_id >= VENDOR_ID_MASK) { - l_put_le16(mod_id, msg + n); + if (!IS_VENDOR(id)) { + l_put_le16(MODEL_ID(id), msg + n); n += 2; } else { - l_put_le16(mod_id >> 16, msg + n); - l_put_le16(mod_id, msg + n + 2); + l_put_le16(VENDOR_ID(id), msg + n); + l_put_le16(MODEL_ID(id), msg + n + 2); n += 4; } @@ -76,37 +76,37 @@ static void config_pub_get(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, const uint8_t *pkt, uint16_t size) { - uint32_t mod_id; + uint32_t id; uint16_t ele_addr; struct mesh_model_pub *pub; int status; if (size == 4) { - mod_id = l_get_le16(pkt + 2); - mod_id |= VENDOR_ID_MASK; + id = l_get_le16(pkt + 2); + id |= SIG_VENDOR; } else if (size == 6) { - mod_id = l_get_le16(pkt + 2) << 16; - mod_id |= l_get_le16(pkt + 4); + id = l_get_le16(pkt + 2) << 16; + id |= l_get_le16(pkt + 4); } else return; ele_addr = l_get_le16(pkt); - pub = mesh_model_pub_get(node, ele_addr, mod_id, &status); + pub = mesh_model_pub_get(node, ele_addr, id, &status); if (pub && status == MESH_STATUS_SUCCESS) send_pub_status(node, net_idx, src, dst, status, ele_addr, - mod_id, pub->addr, pub->idx, pub->credential, + id, pub->addr, pub->idx, pub->credential, pub->ttl, pub->period, pub->retransmit); else send_pub_status(node, net_idx, src, dst, status, ele_addr, - mod_id, 0, 0, 0, 0, 0, 0); + id, 0, 0, 0, 0, 0, 0); } static void config_pub_set(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, const uint8_t *pkt, bool virt, bool vendor) { - uint32_t mod_id; + uint32_t id; uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; const uint8_t *pub_addr; uint16_t test_addr; @@ -124,12 +124,12 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, ttl = pkt[6]; period = pkt[7]; retransmit = pkt[8]; - mod_id = l_get_le16(pkt + 9); + id = l_get_le16(pkt + 9); if (!vendor) - mod_id |= VENDOR_ID_MASK; + id |= SIG_VENDOR; else - mod_id = (mod_id << 16) | l_get_le16(pkt + 11); + id = SET_ID(id, l_get_le16(pkt + 11)); /* Don't accept virtual seeming addresses */ test_addr = l_get_le16(pub_addr); @@ -139,16 +139,16 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, cred_flag = !!(CREDFLAG_MASK & idx); idx &= APP_IDX_MASK; - status = mesh_model_pub_set(node, ele_addr, mod_id, pub_addr, idx, + status = mesh_model_pub_set(node, ele_addr, id, pub_addr, idx, cred_flag, ttl, period, retransmit, virt, &ota); l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, mod: %x, idx: %3.3x", - status, ele_addr, ota, mod_id, idx); + status, ele_addr, ota, id, idx); if (status != MESH_STATUS_SUCCESS) { send_pub_status(node, net_idx, src, dst, status, ele_addr, - mod_id, 0, 0, 0, 0, 0, 0); + id, 0, 0, 0, 0, 0, 0); return; } @@ -158,7 +158,7 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, /* Remove model publication from config file */ if (!mesh_config_model_pub_del(node_config_get(node), ele_addr, - vendor ? mod_id : mod_id & ~VENDOR_ID_MASK, + vendor ? id : MODEL_ID(id), vendor)) status = MESH_STATUS_STORAGE_FAIL; } else { @@ -178,19 +178,19 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, /* Save model publication to config file */ if (!mesh_config_model_pub_add(node_config_get(node), ele_addr, - vendor ? mod_id : mod_id & ~VENDOR_ID_MASK, - vendor, &db_pub)) + vendor ? id : MODEL_ID(id), + vendor, &db_pub)) status = MESH_STATUS_STORAGE_FAIL; } - send_pub_status(node, net_idx, src, dst, status, ele_addr, mod_id, ota, + send_pub_status(node, net_idx, src, dst, status, ele_addr, id, ota, idx, cred_flag, ttl, period, retransmit); } static void send_sub_status(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t status, uint16_t ele_addr, - uint16_t addr, uint32_t mod) + uint16_t addr, uint32_t id) { int n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); @@ -199,12 +199,13 @@ static void send_sub_status(struct mesh_node *node, uint16_t net_idx, n += 2; l_put_le16(addr, msg + n); n += 2; - if (mod >= 0x10000 && mod < VENDOR_ID_MASK) { - l_put_le16(mod >> 16, msg + n); - l_put_le16(mod, msg + n + 2); + + if (IS_VENDOR(id)) { + l_put_le16(VENDOR_ID(id), msg + n); + l_put_le16(MODEL_ID(id), msg + n + 2); n += 4; } else { - l_put_le16(mod, msg + n); + l_put_le16(MODEL_ID(id), msg + n); n += 2; } @@ -217,7 +218,7 @@ static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, const uint8_t *pkt, uint16_t size) { uint16_t ele_addr; - uint32_t mod_id; + uint32_t id; uint16_t n = 0; int status; uint8_t *msg_status; @@ -232,34 +233,34 @@ static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, return false; case 4: - mod_id = l_get_le16(pkt + 2); + id = l_get_le16(pkt + 2); n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_LIST, msg); msg_status = msg + n; msg[n++] = 0; l_put_le16(ele_addr, msg + n); n += 2; - l_put_le16(mod_id, msg + n); + l_put_le16(id, msg + n); n += 2; - mod_id |= VENDOR_ID_MASK; + id |= SIG_VENDOR; break; case 6: - mod_id = l_get_le16(pkt + 2) << 16; - mod_id |= l_get_le16(pkt + 4); + id = l_get_le16(pkt + 2) << 16; + id |= l_get_le16(pkt + 4); n = mesh_model_opcode_set(OP_CONFIG_VEND_MODEL_SUB_LIST, msg); msg_status = msg + n; msg[n++] = 0; l_put_le16(ele_addr, msg + n); n += 2; - l_put_le16(mod_id >> 16, msg + n); + l_put_le16(VENDOR_ID(id), msg + n); n += 2; - l_put_le16(mod_id, msg + n); + l_put_le16(MODEL_ID(id), msg + n); n += 2; break; } buf_size = sizeof(uint16_t) * MAX_GRP_PER_MOD; - status = mesh_model_sub_get(node, ele_addr, mod_id, msg + n, buf_size, + status = mesh_model_sub_get(node, ele_addr, id, msg + n, buf_size, &size); if (status == MESH_STATUS_SUCCESS) @@ -273,7 +274,7 @@ static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, } static bool save_config_sub(struct mesh_node *node, uint16_t ele_addr, - uint32_t mod_id, bool vendor, + uint32_t id, bool vendor, const uint8_t *addr, bool virt, uint16_t grp, uint32_t opcode) { @@ -287,20 +288,18 @@ static bool save_config_sub(struct mesh_node *node, uint16_t ele_addr, if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE || opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) - mesh_config_model_sub_del_all(node_config_get(node), - ele_addr, vendor ? mod_id : mod_id & 0x0000ffff, + mesh_config_model_sub_del_all(node_config_get(node), ele_addr, + vendor ? id : MODEL_ID(id), vendor); if (opcode != OP_CONFIG_MODEL_SUB_VIRT_DELETE && opcode != OP_CONFIG_MODEL_SUB_DELETE) return mesh_config_model_sub_add(node_config_get(node), - ele_addr, - vendor ? mod_id : mod_id & 0x0000ffff, + ele_addr, vendor ? id : MODEL_ID(id), vendor, &db_sub); else return mesh_config_model_sub_del(node_config_get(node), - ele_addr, - vendor ? mod_id : mod_id & 0x0000ffff, + ele_addr, vendor ? id : MODEL_ID(id), vendor, &db_sub); } @@ -310,7 +309,7 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, bool virt, uint32_t opcode) { uint16_t grp, ele_addr; - uint32_t mod_id; + uint32_t id; const uint8_t *addr = NULL; int status = MESH_STATUS_SUCCESS; bool vendor = false; @@ -322,40 +321,47 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, case 4: if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) return; - mod_id = l_get_le16(pkt + 2); - mod_id |= VENDOR_ID_MASK; + + id = l_get_le16(pkt + 2); + id |= SIG_VENDOR; break; case 6: if (virt) return; + if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - mod_id = l_get_le16(pkt + 4); - mod_id |= VENDOR_ID_MASK; + id = l_get_le16(pkt + 4); + id |= SIG_VENDOR; } else { - mod_id = l_get_le16(pkt + 2) << 16; - mod_id |= l_get_le16(pkt + 4); + id = l_get_le16(pkt + 2) << 16; + id |= l_get_le16(pkt + 4); vendor = true; } + break; case 8: if (virt) return; - mod_id = l_get_le16(pkt + 4) << 16; - mod_id |= l_get_le16(pkt + 6); + + id = l_get_le16(pkt + 4) << 16; + id |= l_get_le16(pkt + 6); vendor = true; break; case 20: if (!virt) return; - mod_id = l_get_le16(pkt + 18); - mod_id |= VENDOR_ID_MASK; + + id = l_get_le16(pkt + 18); + id |= SIG_VENDOR; break; case 22: if (!virt) return; + vendor = true; - mod_id = l_get_le16(pkt + 18) << 16; - mod_id |= l_get_le16(pkt + 20); + id = l_get_le16(pkt + 18) << 16; + id |= l_get_le16(pkt + 20); + break; } @@ -373,11 +379,11 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, return; case OP_CONFIG_MODEL_SUB_DELETE_ALL: - status = mesh_model_sub_del_all(node, ele_addr, mod_id); + status = mesh_model_sub_del_all(node, ele_addr, id); if (status == MESH_STATUS_SUCCESS) mesh_config_model_sub_del_all(node_config_get(node), - ele_addr, vendor ? mod_id : mod_id & 0x0000ffff, + ele_addr, vendor ? id : MODEL_ID(id), vendor); break; @@ -385,22 +391,22 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, grp = UNASSIGNED_ADDRESS; /* Fall Through */ case OP_CONFIG_MODEL_SUB_OVERWRITE: - status = mesh_model_sub_ovr(node, ele_addr, mod_id, + status = mesh_model_sub_ovr(node, ele_addr, id, addr, virt, &grp); if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, mod_id, vendor, addr, + save_config_sub(node, ele_addr, id, vendor, addr, virt, grp, opcode); break; case OP_CONFIG_MODEL_SUB_VIRT_ADD: grp = UNASSIGNED_ADDRESS; /* Fall Through */ case OP_CONFIG_MODEL_SUB_ADD: - status = mesh_model_sub_add(node, ele_addr, mod_id, + status = mesh_model_sub_add(node, ele_addr, id, addr, virt, &grp); if (status == MESH_STATUS_SUCCESS && - !save_config_sub(node, ele_addr, mod_id, vendor, + !save_config_sub(node, ele_addr, id, vendor, addr, virt, grp, opcode)) status = MESH_STATUS_STORAGE_FAIL; @@ -409,17 +415,17 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, grp = UNASSIGNED_ADDRESS; /* Fall Through */ case OP_CONFIG_MODEL_SUB_DELETE: - status = mesh_model_sub_del(node, ele_addr, mod_id, addr, virt, + status = mesh_model_sub_del(node, ele_addr, id, addr, virt, &grp); if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, mod_id, vendor, addr, + save_config_sub(node, ele_addr, id, vendor, addr, virt, grp, opcode); break; } - send_sub_status(node, net_idx, src, dst, status, ele_addr, grp, mod_id); + send_sub_status(node, net_idx, src, dst, status, ele_addr, grp, id); } static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, @@ -434,11 +440,13 @@ static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, n += 2; l_put_le16(idx, msg + n); n += 2; - if (id >= 0x10000 && id < VENDOR_ID_MASK) { - l_put_le16(id >> 16, msg + n); + + if (IS_VENDOR(id)) { + l_put_le16(VENDOR_ID(id), msg + n); n += 2; } - l_put_le16(id, msg + n); + + l_put_le16(MODEL_ID(id), msg + n); n += 2; mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, @@ -450,7 +458,7 @@ static void model_app_list(struct mesh_node *node, uint16_t net_idx, const uint8_t *pkt, uint16_t size) { uint16_t ele_addr; - uint32_t mod_id = 0xffff; + uint32_t id; uint8_t *status; uint16_t n; int result; @@ -463,27 +471,26 @@ static void model_app_list(struct mesh_node *node, uint16_t net_idx, case 4: n = mesh_model_opcode_set(OP_MODEL_APP_LIST, msg); status = msg + n; - mod_id = l_get_le16(pkt + 2); + id = l_get_le16(pkt + 2); l_put_le16(ele_addr, msg + 1 + n); - l_put_le16(mod_id, msg + 3 + n); - mod_id |= VENDOR_ID_MASK; + l_put_le16((uint16_t) id, msg + 3 + n); + id |= SIG_VENDOR; n += 5; break; case 6: n = mesh_model_opcode_set(OP_VEND_MODEL_APP_LIST, msg); status = msg + n; - mod_id = l_get_le16(pkt + 2) << 16; - mod_id |= l_get_le16(pkt + 4); + id = l_get_le16(pkt + 2) << 16; + id |= l_get_le16(pkt + 4); l_put_le16(ele_addr, msg + 1 + n); - l_put_le16(mod_id >> 16, msg + 3 + n); - l_put_le16(mod_id, msg + 5 + n); + l_put_le16((uint16_t) VENDOR_ID(id), msg + 3 + n); + l_put_le16((uint16_t) MODEL_ID(id), msg + 5 + n); n += 7; break; } - - result = mesh_model_get_bindings(node, ele_addr, mod_id, msg + n, + result = mesh_model_get_bindings(node, ele_addr, id, msg + n, MAX_MSG_LEN - n, &size); n += size; @@ -500,7 +507,7 @@ static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, bool unbind) { uint16_t ele_addr; - uint32_t mod_id; + uint32_t id; uint16_t idx; int result; @@ -509,12 +516,12 @@ static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, return false; case 6: - mod_id = l_get_le16(pkt + 4); - mod_id |= VENDOR_ID_MASK; + id = l_get_le16(pkt + 4); + id |= SIG_VENDOR; break; case 8: - mod_id = l_get_le16(pkt + 4) << 16; - mod_id |= l_get_le16(pkt + 6); + id = l_get_le16(pkt + 4) << 16; + id |= l_get_le16(pkt + 6); break; } @@ -525,12 +532,12 @@ static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, return false; if (unbind) - result = mesh_model_binding_del(node, ele_addr, mod_id, idx); + result = mesh_model_binding_del(node, ele_addr, id, idx); else - result = mesh_model_binding_add(node, ele_addr, mod_id, idx); + result = mesh_model_binding_add(node, ele_addr, id, idx); send_model_app_status(node, net_idx, src, dst, result, ele_addr, - mod_id, idx); + id, idx); return true; } diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 383fdbf6b..9759b01ea 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -17,8 +17,8 @@ * */ -#define CONFIG_SRV_MODEL (VENDOR_ID_MASK | 0x0000) -#define CONFIG_CLI_MODEL (VENDOR_ID_MASK | 0x0001) +#define CONFIG_SRV_MODEL (0x0000 | SIG_VENDOR) +#define CONFIG_CLI_MODEL (0x0001 | SIG_VENDOR) /* New List */ #define OP_APPKEY_ADD 0x00 diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 88f715fc1..deb0019f9 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1126,18 +1126,15 @@ static bool parse_models(json_object *jmodels, struct mesh_config_element *ele) if (sscanf(str, "%04x", &id) != 1) goto fail; - id |= VENDOR_ID_MASK; } else if (len == 8) { if (sscanf(str, "%08x", &id) != 1) goto fail; + mod->vendor = true; } else goto fail; mod->id = id; - if (len == 8) - mod->vendor = true; - if (json_object_object_get_ex(jmodel, "bind", &jarray)) { if (json_object_get_type(jarray) != json_type_array || !parse_bindings(jarray, mod)) diff --git a/mesh/model.c b/mesh/model.c index afac6ec69..ca1009d8a 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -2,7 +2,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. + * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * * This library is free software; you can redistribute it and/or @@ -54,7 +54,6 @@ struct mesh_model { bool sub_enabled; bool pub_enabled; uint32_t id; - uint8_t ele_idx; }; struct mesh_virtual { @@ -131,44 +130,42 @@ static bool find_virt_by_label(const void *a, const void *b) static bool match_model_id(const void *a, const void *b) { - const struct mesh_model *model = a; + const struct mesh_model *mod = a; uint32_t id = L_PTR_TO_UINT(b); - return (mesh_model_get_model_id(model) == id); + return (mod->id == id); } -static struct mesh_model *get_model(struct mesh_node *node, uint8_t ele_idx, - uint32_t id, int *status) +static int compare_model_id(const void *a, const void *b, void *user_data) { - struct l_queue *models; - struct mesh_model *model; + const struct mesh_model *mod_a = a; + const struct mesh_model *mod_b = b; - models = node_get_element_models(node, ele_idx, status); - if (!models) { - *status = MESH_STATUS_INVALID_MODEL; - return NULL; - } - - model = l_queue_find(models, match_model_id, L_UINT_TO_PTR(id)); + if (mod_a->id < mod_b->id) + return -1; - *status = (model) ? MESH_STATUS_SUCCESS : MESH_STATUS_INVALID_MODEL; + if (mod_a->id > mod_b->id) + return 1; - return model; + return 0; } -static struct mesh_model *find_model(struct mesh_node *node, uint16_t addr, - uint32_t mod_id, int *status) +static struct mesh_model *get_model(struct mesh_node *node, uint8_t ele_idx, + uint32_t id) { - int ele_idx; - - ele_idx = node_get_element_idx(node, addr); + struct l_queue *mods; + struct mesh_model *mod; - if (ele_idx < 0) { - *status = MESH_STATUS_INVALID_ADDRESS; + mods = node_get_element_models(node, ele_idx); + if (!mods) return NULL; - } - return get_model(node, (uint8_t) ele_idx, mod_id, status); + mod = l_queue_find(mods, match_model_id, L_UINT_TO_PTR(id)); + + if (!mod) + l_debug("Model not found"); + + return mod; } static uint32_t pub_period_to_ms(uint8_t pub_period) @@ -212,15 +209,17 @@ static struct l_dbus_message *create_config_update_msg(struct mesh_node *node, *builder = l_dbus_message_builder_new(msg); - model_id = (uint16_t) id; + model_id = (uint16_t) MODEL_ID(id); l_dbus_message_builder_append_basic(*builder, 'q', &model_id); l_dbus_message_builder_enter_array(*builder, "{sv}"); - if ((id & VENDOR_ID_MASK) != VENDOR_ID_MASK) { - uint16_t vendor = id >> 16; - dbus_append_dict_entry_basic(*builder, "Vendor", "q", &vendor); + if (IS_VENDOR(id)) { + uint16_t vendor_id = (uint16_t) VENDOR_ID(id); + + dbus_append_dict_entry_basic(*builder, "Vendor", "q", + &vendor_id); } return msg; @@ -268,15 +267,14 @@ static void append_dict_uint16_array(struct l_dbus_message_builder *builder, l_dbus_message_builder_leave_dict(builder); } -static void config_update_model_bindings(struct mesh_node *node, +static void cfg_update_mod_bindings(struct mesh_node *node, uint16_t ele_idx, struct mesh_model *mod) { struct l_dbus *dbus = dbus_get_bus(); struct l_dbus_message *msg; struct l_dbus_message_builder *builder; - msg = create_config_update_msg(node, mod->ele_idx, mod->id, - &builder); + msg = create_config_update_msg(node, ele_idx, mod->id, &builder); if (!msg) return; @@ -331,15 +329,14 @@ done: l_dbus_message_builder_leave_dict(builder); } -static void config_update_model_subscriptions(struct mesh_node *node, +static void cfg_update_model_subs(struct mesh_node *node, uint16_t ele_idx, struct mesh_model *mod) { struct l_dbus *dbus = dbus_get_bus(); struct l_dbus_message *msg; struct l_dbus_message_builder *builder; - msg = create_config_update_msg(node, mod->ele_idx, mod->id, - &builder); + msg = create_config_update_msg(node, ele_idx, mod->id, &builder); if (!msg) return; @@ -572,7 +569,8 @@ done: return ret; } -static void remove_pub(struct mesh_node *node, struct mesh_model *mod) +static void remove_pub(struct mesh_node *node, uint16_t ele_idx, + struct mesh_model *mod) { if (mod->pub) { if (mod->pub->virt) @@ -584,31 +582,31 @@ static void remove_pub(struct mesh_node *node, struct mesh_model *mod) if (!mod->cbs) /* External models */ - config_update_model_pub_period(node, mod->ele_idx, mod->id, 0); + config_update_model_pub_period(node, ele_idx, mod->id, 0); else if (mod->cbs && mod->cbs->pub) /* Internal models */ mod->cbs->pub(NULL); } -static void model_unbind_idx(struct mesh_node *node, struct mesh_model *mod, - uint16_t idx) +static void model_unbind_idx(struct mesh_node *node, uint16_t ele_idx, + struct mesh_model *mod, uint16_t idx) { l_queue_remove(mod->bindings, L_UINT_TO_PTR(idx)); if (!mod->cbs) /* External model */ - config_update_model_bindings(node, mod); + cfg_update_mod_bindings(node, ele_idx, mod); else if (mod->cbs->bind) /* Internal model */ mod->cbs->bind(idx, ACTION_DELETE); /* Remove model publication if the publication key is unbound */ if (mod->pub && idx == mod->pub->idx) - remove_pub(node, mod); + remove_pub(node, ele_idx, mod); } -static void model_bind_idx(struct mesh_node *node, struct mesh_model *mod, - uint16_t idx) +static void model_bind_idx(struct mesh_node *node, uint16_t ele_idx, + struct mesh_model *mod, uint16_t idx) { if (!mod->bindings) mod->bindings = l_queue_new(); @@ -619,7 +617,7 @@ static void model_bind_idx(struct mesh_node *node, struct mesh_model *mod, if (!mod->cbs) /* External model */ - config_update_model_bindings(node, mod); + cfg_update_mod_bindings(node, ele_idx, mod); else if (mod->cbs->bind) /* Internal model */ mod->cbs->bind(idx, ACTION_ADD); @@ -628,19 +626,18 @@ static void model_bind_idx(struct mesh_node *node, struct mesh_model *mod, static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, uint16_t app_idx, bool unbind) { - int status; struct mesh_model *mod; - bool is_present, is_vendor; + bool is_present; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) { - l_debug("Model not found"); - return status; + return MESH_STATUS_INVALID_MODEL; } - is_vendor = id < VENDOR_ID_MASK && id > 0xffff; - id = !is_vendor ? (id & 0xffff) : id; - if (id == CONFIG_SRV_MODEL || id == CONFIG_CLI_MODEL) return MESH_STATUS_INVALID_MODEL; @@ -656,9 +653,10 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; if (unbind) { - model_unbind_idx(node, mod, app_idx); + model_unbind_idx(node, ele_idx, mod, app_idx); if (!mesh_config_model_binding_del(node_config_get(node), - addr, is_vendor, id, app_idx)) + addr, IS_VENDOR(id), + id, app_idx)) return MESH_STATUS_STORAGE_FAIL; l_debug("Unbind key %4.4x to model %8.8x", app_idx, mod->id); @@ -668,11 +666,11 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, if (l_queue_length(mod->bindings) >= MAX_BINDINGS) return MESH_STATUS_INSUFF_RESOURCES; - if (!mesh_config_model_binding_add(node_config_get(node), - addr, is_vendor, id, app_idx)) + if (!mesh_config_model_binding_add(node_config_get(node), addr, + IS_VENDOR(id), id, app_idx)) return MESH_STATUS_STORAGE_FAIL; - model_bind_idx(node, mod, app_idx); + model_bind_idx(node, ele_idx, mod, app_idx); return MESH_STATUS_SUCCESS; @@ -964,7 +962,6 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, is_subscription = !(IS_UNICAST(dst)); - for (i = 0; i < num_ele; i++) { struct l_queue *models; @@ -974,7 +971,7 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, forward.unicast = addr + i; forward.has_dst = false; - models = node_get_element_models(node, i, NULL); + models = node_get_element_models(node, i); /* Internal models */ l_queue_foreach(models, forward_model, &forward); @@ -1023,16 +1020,15 @@ done: return result; } -int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, - uint16_t src, uint8_t ttl, - const void *msg, uint16_t msg_len) +int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, + uint8_t ttl, const void *msg, uint16_t msg_len) { struct mesh_net *net = node_get_net(node); struct mesh_model *mod; uint8_t *label = NULL; uint16_t net_idx; bool result; - int status; + int ele_idx; if (!net || msg_len > 380) return MESH_ERROR_INVALID_ARGS; @@ -1041,14 +1037,16 @@ int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, if (src == 0) src = mesh_net_get_address(net); - mod = find_model(node, src, mod_id, &status); - if (!mod) { - l_debug("model %x not found", mod_id); + ele_idx = node_get_element_idx(node, src); + if (ele_idx < 0) + return MESH_ERROR_NOT_FOUND; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) return MESH_ERROR_NOT_FOUND; - } if (!mod->pub) { - l_debug("publication doesn't exist (model %x)", mod_id); + l_debug("publication doesn't exist (model %x)", id); return MESH_ERROR_DOES_NOT_EXIST; } @@ -1093,11 +1091,14 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, bool is_virt, uint16_t *dst) { struct mesh_model *mod; - int status; + int status, ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->pub_enabled || (mod->cbs && !(mod->cbs->pub))) return MESH_STATUS_INVALID_PUB_PARAM; @@ -1110,7 +1111,7 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, * remove the publication */ if (!is_virt && IS_UNASSIGNED(l_get_le16(pub_addr))) { - remove_pub(node, mod); + remove_pub(node, ele_idx, mod); return MESH_STATUS_SUCCESS; } @@ -1134,7 +1135,7 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External model */ - config_update_model_pub_period(node, mod->ele_idx, id, + config_update_model_pub_period(node, ele_idx, id, pub_period_to_ms(period)); else { /* Internal model, call registered callbacks */ @@ -1149,10 +1150,18 @@ struct mesh_model_pub *mesh_model_pub_get(struct mesh_node *node, uint16_t addr, uint32_t mod_id, int *status) { struct mesh_model *mod; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, mod_id, status); - if (!mod) + if (ele_idx < 0) { + *status = MESH_STATUS_INVALID_ADDRESS; + return NULL; + } + + mod = get_model(node, (uint8_t) ele_idx, mod_id); + if (!mod) { + *status = MESH_STATUS_INVALID_MODEL; return NULL; + } if (!mod->pub_enabled || (mod->cbs && !(mod->cbs->pub))) *status = MESH_STATUS_INVALID_PUB_PARAM; @@ -1173,12 +1182,25 @@ void mesh_model_free(void *data) l_free(mod); } -struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t id) +static void remove_subs(struct mesh_node *node, struct mesh_model *mod) +{ + const struct l_queue_entry *entry; + struct mesh_net *net = node_get_net(node); + + entry = l_queue_get_entries(mod->subs); + + for (; entry; entry = entry->next) + mesh_net_dst_unreg(net, (uint16_t) L_PTR_TO_UINT(entry->data)); + + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); +} + +static struct mesh_model *model_new(uint32_t id) { struct mesh_model *mod = l_new(struct mesh_model, 1); mod->id = id; - mod->ele_idx = ele_idx; mod->virtuals = l_queue_new(); /* @@ -1190,6 +1212,75 @@ struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t id) return mod; } +static void model_enable_pub(struct mesh_model *mod, bool enable) +{ + mod->pub_enabled = enable; + + if (!mod->pub_enabled && mod->pub) { + if (mod->pub->virt) + unref_virt(mod->pub->virt); + + l_free(mod->pub); + mod->pub = NULL; + } +} + +static void model_enable_sub(struct mesh_node *node, struct mesh_model *mod, + bool enable) +{ + mod->sub_enabled = enable; + + if (!mod->sub_enabled) + remove_subs(node, mod); +} + +static bool get_model_options(struct mesh_model *mod, + struct l_dbus_message_iter *opts) +{ + const char *key; + struct l_dbus_message_iter var; + bool opt; + + while (l_dbus_message_iter_next_entry(opts, &key, &var)) { + + if (!strcmp(key, "Publish")) { + if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) + return false; + + mod->pub_enabled = opt; + } else if (!strcmp(key, "Subscribe")) { + if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) + return false; + + mod->sub_enabled = opt; + } else + return false; + } + + return true; +} + +bool mesh_model_add(struct mesh_node *node, struct l_queue *mods, + uint32_t id, struct l_dbus_message_iter *opts) +{ + struct mesh_model *mod; + + /* Disallow duplicates */ + mod = l_queue_find(mods, match_model_id, L_UINT_TO_PTR(id)); + if (mod) + return false; + + mod = model_new(id); + + if (opts && !get_model_options(mod, opts)) { + mesh_model_free(mod); + return false; + } + + l_queue_insert(mods, mod, compare_model_id, NULL); + return true; +} + /* Internal models only */ static void restore_model_state(struct mesh_model *mod) { @@ -1213,26 +1304,16 @@ static void restore_model_state(struct mesh_model *mod) } -uint32_t mesh_model_get_model_id(const struct mesh_model *model) -{ - return model->id; -} - /* This registers an internal model, i.e. implemented within meshd */ -bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, - uint32_t mod_id, +bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, uint32_t id, const struct mesh_model_ops *cbs, void *user_data) { struct mesh_model *mod; - int status; - - /* Internal models are always SIG models */ - mod_id = VENDOR_ID_MASK | mod_id; - mod = get_model(node, ele_idx, mod_id, &status); + mod = get_model(node, ele_idx, id); if (!mod) - return false; + return MESH_STATUS_INVALID_MODEL; mod->cbs = cbs; mod->user_data = user_data; @@ -1242,15 +1323,15 @@ bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, return true; } -void mesh_model_app_key_delete(struct mesh_node *node, struct l_queue *models, - uint16_t app_idx) +void mesh_model_app_key_delete(struct mesh_node *node, uint16_t ele_idx, + struct l_queue *models, uint16_t app_idx) { const struct l_queue_entry *entry = l_queue_get_entries(models); for (; entry; entry = entry->next) { - struct mesh_model *model = entry->data; + struct mesh_model *mod = entry->data; - model_unbind_idx(node, model, app_idx); + model_unbind_idx(node, ele_idx, mod, app_idx); } } @@ -1269,18 +1350,20 @@ int mesh_model_binding_add(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_get_bindings(struct mesh_node *node, uint16_t addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size) { - int status; struct mesh_model *mod; const struct l_queue_entry *entry; uint16_t n; uint32_t idx_pair; - int i; + int i, ele_idx = node_get_element_idx(node, addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; - mod = find_model(node, addr, id, &status); + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) { *size = 0; - return status; + return MESH_STATUS_INVALID_MODEL; } entry = l_queue_get_entries(mod->bindings); @@ -1325,14 +1408,17 @@ done: int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size) { - int status; int16_t n; struct mesh_model *mod; const struct l_queue_entry *entry; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1370,12 +1456,15 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *group, bool is_virt, uint16_t *dst) { - int status; struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; - mod = find_model(node, addr, id, &status); + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1387,7 +1476,7 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); return MESH_STATUS_SUCCESS; } @@ -1395,13 +1484,16 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *group, bool is_virt, uint16_t *dst) { - int status; struct l_queue *virtuals, *subs; struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; - mod = find_model(node, addr, id, &status); + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1439,7 +1531,7 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); return status; } @@ -1447,13 +1539,16 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *group, bool is_virt, uint16_t *dst) { - int status; uint16_t grp; struct mesh_model *mod; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1481,34 +1576,23 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); } return MESH_STATUS_SUCCESS; } -static void remove_subs(struct mesh_node *node, struct mesh_model *mod) -{ - const struct l_queue_entry *entry; - struct mesh_net *net = node_get_net(node); - - entry = l_queue_get_entries(mod->subs); - - for (; entry; entry = entry->next) - mesh_net_dst_unreg(net, (uint16_t) L_PTR_TO_UINT(entry->data)); - - l_queue_clear(mod->subs, NULL); - l_queue_clear(mod->virtuals, unref_virt); -} - int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) { - int status; struct mesh_model *mod; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1517,17 +1601,15 @@ int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); return MESH_STATUS_SUCCESS; } -struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, - void *data) +static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, + struct mesh_config_model *db_mod) { - struct mesh_config_model *db_mod = data; struct mesh_model *mod; - struct mesh_net *net; struct mesh_config_pub *pub = db_mod->pub; uint32_t i; @@ -1537,8 +1619,8 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return NULL; } - mod = mesh_model_new(ele_idx, db_mod->vendor ? db_mod->id : - db_mod->id | VENDOR_ID_MASK); + mod = model_new(db_mod->vendor ? db_mod->id : + db_mod->id | SIG_VENDOR); /* Implicitly bind config server model to device key */ if (db_mod->id == CONFIG_SRV_MODEL) { @@ -1557,17 +1639,18 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return mod; } - net = node_get_net(node); - /* Add application key bindings if present */ if (db_mod->bindings) { mod->bindings = l_queue_new(); for (i = 0; i < db_mod->num_bindings; i++) - model_bind_idx(node, mod, db_mod->bindings[i]); + l_queue_push_tail(mod->bindings, + L_UINT_TO_PTR(db_mod->bindings[i])); } - /* Add publication if present */ - if (pub) { + mod->pub_enabled = db_mod->pub_enabled; + + /* Add publication if enabled and present */ + if (mod->pub_enabled && pub) { uint8_t retransmit = pub->count + ((pub->interval / 50 - 1) << 3); if (pub->virt) @@ -1579,8 +1662,10 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, pub->ttl, pub->period, retransmit); } - /* Add subscriptions if present */ - if (!db_mod->subs) + mod->sub_enabled = db_mod->sub_enabled; + + /* Add subscriptions if enabled and present */ + if (!db_mod->subs || !mod->sub_enabled) return mod; for (i = 0; i < db_mod->num_subs; i++) { @@ -1605,6 +1690,59 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return mod; } +bool mesh_model_add_from_storage(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *mods, struct l_queue *db_mods) +{ + struct mesh_net *net = node_get_net(node); + const struct l_queue_entry *entry; + + /* Allow empty elements */ + if (!db_mods) + return true; + + entry = l_queue_get_entries(db_mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod; + struct mesh_config_model *db_mod; + uint32_t id; + + db_mod = entry->data; + + id = db_mod->vendor ? db_mod->id : db_mod->id | SIG_VENDOR; + + if (l_queue_find(mods, match_model_id, L_UINT_TO_PTR(id))) + return false; + + mod = model_setup(net, ele_idx, db_mod); + if (!mod) + return false; + + l_queue_insert(mods, mod, compare_model_id, NULL); + } + + return true; +} + +void mesh_model_convert_to_storage(struct l_queue *db_mods, + struct l_queue *mods) +{ + + const struct l_queue_entry *entry = l_queue_get_entries(mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + struct mesh_config_model *db_mod; + + db_mod = l_new(struct mesh_config_model, 1); + db_mod->id = mod->id; + db_mod->vendor = IS_VENDOR(mod->id); + db_mod->pub_enabled = mod->pub_enabled; + db_mod->sub_enabled = mod->sub_enabled; + l_queue_push_tail(db_mods, db_mod); + } +} + uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf) { if (opcode <= 0x7e) { @@ -1669,7 +1807,7 @@ bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, return true; } -void model_build_config(void *model, void *msg_builder) +void mesh_model_build_config(void *model, void *msg_builder) { struct l_dbus_message_builder *builder = msg_builder; struct mesh_model *mod = model; @@ -1685,14 +1823,14 @@ void model_build_config(void *model, void *msg_builder) l_dbus_message_builder_enter_struct(builder, "qa{sv}"); /* Model id */ - id = mod->id & 0xffff; + id = MODEL_ID(mod->id); l_dbus_message_builder_append_basic(builder, 'q', &id); l_dbus_message_builder_enter_array(builder, "{sv}"); /* For vendor models, add vendor id */ - if ((mod->id & VENDOR_ID_MASK) != VENDOR_ID_MASK) { - uint16_t vendor = mod->id >> 16; + if (IS_VENDOR(mod->id)) { + uint16_t vendor = VENDOR_ID(mod->id); dbus_append_dict_entry_basic(builder, "Vendor", "q", &vendor); } @@ -1715,36 +1853,101 @@ void model_build_config(void *model, void *msg_builder) l_dbus_message_builder_leave_struct(builder); } -void mesh_model_enable_pub(struct mesh_model *mod, bool enable) +void mesh_model_update_opts(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *curr, struct l_queue *updated) { - mod->pub_enabled = enable; + uint16_t primary; + const struct l_queue_entry *entry; - if (!mod->pub_enabled && mod->pub) { - if (mod->pub->virt) - unref_virt(mod->pub->virt); + primary = node_get_primary(node); + entry = l_queue_get_entries(curr); - l_free(mod->pub); - mod->pub = NULL; - } -} + for (; entry; entry = entry->next) { + struct mesh_model *mod, *updated_mod = entry->data; + uint32_t id = updated_mod->id; + bool updated_opt, vendor = IS_VENDOR(id); -bool mesh_model_is_pub_enabled(struct mesh_model *mod) -{ - return mod->pub_enabled; -} + mod = l_queue_find(curr, match_model_id, L_UINT_TO_PTR(id)); + if (!mod) + continue; -void mesh_model_enable_sub(struct mesh_node *node, struct mesh_model *mod, - bool enable) -{ - mod->sub_enabled = enable; + if (!vendor) + id = MODEL_ID(id); - if (!mod->sub_enabled) - remove_subs(node, mod); + updated_opt = updated_mod->pub_enabled; + if (mod->pub_enabled != updated_opt) { + model_enable_pub(mod, updated_opt); + mesh_config_model_pub_enable(node_config_get(node), + primary + ele_idx, id, + vendor, updated_opt); + } + + updated_opt = updated_mod->sub_enabled; + + if (mod->pub_enabled != updated_opt) { + model_enable_sub(node, mod, updated_opt); + mesh_config_model_sub_enable(node_config_get(node), + primary + ele_idx, id, + vendor, updated_opt); + } + } } -bool mesh_model_is_sub_enabled(struct mesh_model *mod) +/* Populate composition buffer with model IDs */ +uint16_t mesh_model_generate_composition(struct l_queue *mods, uint16_t buf_sz, + uint8_t *buf) { - return mod->sub_enabled; + const struct l_queue_entry *entry; + uint8_t num_s = 0, num_v = 0; + uint8_t *mod_buf; + uint16_t n; + + /* Store models IDs, store num_s and num_v later */ + mod_buf = buf; + n = 2; + + entry = l_queue_get_entries(mods); + + /* Get SIG models */ + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + + if (n + 2 > buf_sz) + goto done; + + if (IS_VENDOR(mod->id)) + continue; + + l_put_le16((uint16_t) (MODEL_ID(mod->id)), buf + n); + n += 2; + num_s++; + } + + /* Get vendor models */ + entry = l_queue_get_entries(mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + uint16_t vendor_id; + + if (n + 4 > buf_sz) + goto done; + + if (!IS_VENDOR(mod->id)) + continue; + + vendor_id = (uint16_t) (VENDOR_ID(mod->id)); + l_put_le16(vendor_id, buf + n); + n += 2; + l_put_le16((uint16_t) (MODEL_ID(mod->id)), buf + n); + n += 2; + num_v++; + } + +done: + mod_buf[0] = num_s; + mod_buf[1] = num_v; + return n; } void mesh_model_init(void) diff --git a/mesh/model.h b/mesh/model.h index 0377d3fdd..fe5a0e736 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -2,7 +2,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright (C) 2018 Intel Corporation. All rights reserved. + * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * * This library is free software; you can redistribute it and/or @@ -22,14 +22,17 @@ struct mesh_model; #define MAX_BINDINGS 10 #define MAX_GRP_PER_MOD 10 -#define OP_MODEL_TEST 0x8000fffe -#define OP_MODEL_INVALID 0x8000ffff +#define ACTION_ADD 1 +#define ACTION_UPDATE 2 +#define ACTION_DELETE 3 -#define USE_PUB_VALUE 0x00 +/* For internal representation of SIG defined models */ +#define SIG_VENDOR 0xFFFF0000 -#define ACTION_ADD 1 -#define ACTION_UPDATE 2 -#define ACTION_DELETE 3 +#define IS_VENDOR(x) ((x) < SIG_VENDOR) +#define SET_ID(v, m) ((((uint32_t) (v)) << 16) | (m)) +#define MODEL_ID(x) ((x) & ~VENDOR_ID_MASK) +#define VENDOR_ID(x) ((x) >> 16) struct mesh_virtual; @@ -60,61 +63,62 @@ struct mesh_model_ops { mesh_model_sub_cb sub; }; -struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t mod_id); +bool mesh_model_add(struct mesh_node *node, struct l_queue *mods, + uint32_t id, struct l_dbus_message_iter *opts); void mesh_model_free(void *data); -uint32_t mesh_model_get_model_id(const struct mesh_model *model); bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, - uint32_t mod_id, const struct mesh_model_ops *cbs, + uint32_t id, const struct mesh_model_ops *cbs, void *user_data); -struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, - void *data); +bool mesh_model_add_from_storage(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *mods, struct l_queue *db_mods); +void mesh_model_convert_to_storage(struct l_queue *db_mods, + struct l_queue *mods); struct mesh_model_pub *mesh_model_pub_get(struct mesh_node *node, - uint16_t addr, uint32_t mod_id, int *status); -int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *pub_addr, uint16_t idx, bool cred_flag, + uint16_t ele_addr, + uint32_t id, int *status); +int mesh_model_pub_set(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + const uint8_t *addr, uint16_t idx, bool cred_flag, uint8_t ttl, uint8_t period, uint8_t retransmit, bool is_virt, uint16_t *dst); -int mesh_model_binding_add(struct mesh_node *node, uint16_t addr, uint32_t id, - uint16_t idx); -int mesh_model_binding_del(struct mesh_node *node, uint16_t addr, uint32_t id, - uint16_t idx); -int mesh_model_get_bindings(struct mesh_node *node, uint16_t addr, uint32_t id, - uint8_t *buf, uint16_t buf_len, uint16_t *size); -int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, +int mesh_model_binding_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, uint16_t idx); +int mesh_model_binding_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, uint16_t idx); +int mesh_model_get_bindings(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, uint8_t *buf, uint16_t buf_sz, + uint16_t *len); +int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, const uint8_t *grp, bool b_virt, uint16_t *dst); -int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, +int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, const uint8_t *grp, bool b_virt, uint16_t *dst); int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id); int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *grp, bool b_virt, uint16_t *dst); -int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, +int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size); uint16_t mesh_model_cfg_blk(uint8_t *pkt); bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, uint8_t ttl, bool segmented, const void *msg, uint16_t msg_len); -int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, uint16_t src, +int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, uint8_t ttl, const void *msg, uint16_t msg_len); bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, uint32_t seq, uint32_t iv_index, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t key_aid, const uint8_t *data, uint16_t size); void mesh_model_app_key_generate_new(struct mesh_node *node, uint16_t net_idx); -void mesh_model_app_key_delete(struct mesh_node *node, struct l_queue *models, - uint16_t idx); +void mesh_model_app_key_delete(struct mesh_node *node, uint16_t ele_idx, + struct l_queue *models, uint16_t app_idx); struct l_queue *mesh_model_get_appkeys(struct mesh_node *node); uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf); bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, uint32_t *opcode, uint16_t *n); -void model_build_config(void *model, void *msg_builder); - -void mesh_model_enable_pub(struct mesh_model *mod, bool enable); -bool mesh_model_is_pub_enabled(struct mesh_model *mod); -void mesh_model_enable_sub(struct mesh_node *node, struct mesh_model *mod, - bool enable); -bool mesh_model_is_sub_enabled(struct mesh_model *mod); - +void mesh_model_build_config(void *model, void *msg_builder); +void mesh_model_update_opts(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *curr, struct l_queue *updated); +uint16_t mesh_model_generate_composition(struct l_queue *mods, uint16_t buf_sz, + uint8_t *buf); void mesh_model_init(void); void mesh_model_cleanup(void); diff --git a/mesh/node.c b/mesh/node.c index 9b97aa927..395b7d3c4 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -2,7 +2,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright (C) 2017-2019 Intel Corporation. All rights reserved. + * Copyright (C) 2017-2020 Intel Corporation. All rights reserved. * * * This library is free software; you can redistribute it and/or @@ -186,28 +186,6 @@ static bool match_element_path(const void *a, const void *b) return (!strcmp(element->path, path)); } -static bool match_model_id(const void *a, const void *b) -{ - const struct mesh_model *mod = a; - uint32_t mod_id = L_PTR_TO_UINT(b); - - return mesh_model_get_model_id(mod) == mod_id; -} - -static int compare_model_id(const void *a, const void *b, void *user_data) -{ - uint32_t a_id = mesh_model_get_model_id(a); - uint32_t b_id = mesh_model_get_model_id(b); - - if (a_id < b_id) - return -1; - - if (a_id > b_id) - return 1; - - return 0; -} - struct mesh_node *node_find_by_uuid(uint8_t uuid[16]) { return l_queue_find(nodes, match_device_uuid, uuid); @@ -225,25 +203,6 @@ uint8_t *node_uuid_get(struct mesh_node *node) return node->uuid; } -static void add_internal_model(struct mesh_node *node, uint32_t mod_id, - uint8_t ele_idx) -{ - struct node_element *ele; - struct mesh_model *mod; - - ele = l_queue_find(node->elements, match_element_idx, - L_UINT_TO_PTR(ele_idx)); - if (!ele) - return; - - if (l_queue_find(ele->models, match_model_id, L_UINT_TO_PTR(mod_id))) - return; - - mod = mesh_model_new(ele_idx, mod_id); - - l_queue_insert(ele->models, mod, compare_model_id, NULL); -} - static void set_defaults(struct mesh_node *node) { node->lpn = MESH_MODE_UNSUPPORTED; @@ -359,46 +318,6 @@ void node_remove(struct mesh_node *node) free_node_resources(node); } -static bool add_models_from_storage(struct mesh_node *node, - struct node_element *ele, - struct mesh_config_element *db_ele) -{ - const struct l_queue_entry *entry; - - if (!ele->models) - ele->models = l_queue_new(); - - entry = l_queue_get_entries(db_ele->models); - - for (; entry; entry = entry->next) { - struct mesh_model *mod; - struct mesh_config_model *db_mod; - uint32_t id; - - db_mod = entry->data; - - id = db_mod->vendor ? db_mod->id : db_mod->id | VENDOR_ID_MASK; - - if (l_queue_find(ele->models, match_model_id, - L_UINT_TO_PTR(id))) - return false; - - mod = mesh_model_setup(node, ele->idx, db_mod); - if (!mod) - return false; - - if (!db_mod->pub_enabled) - mesh_model_enable_pub(mod, false); - - if (!db_mod->sub_enabled) - mesh_model_enable_sub(node, mod, false); - - l_queue_insert(ele->models, mod, compare_model_id, NULL); - } - - return true; -} - static bool add_element_from_storage(struct mesh_node *node, struct mesh_config_element *db_ele) { @@ -411,7 +330,12 @@ static bool add_element_from_storage(struct mesh_node *node, ele->idx = db_ele->index; ele->location = db_ele->location; - if (!db_ele->models || !add_models_from_storage(node, ele, db_ele)) + + if (!ele->models) + ele->models = l_queue_new(); + + if (!mesh_model_add_from_storage(node, ele->idx, ele->models, + db_ele->models)) return false; l_queue_push_tail(node->elements, ele); @@ -424,12 +348,13 @@ static bool add_elements_from_storage(struct mesh_node *node, const struct l_queue_entry *entry; entry = l_queue_get_entries(db_node->elements); + for (; entry; entry = entry->next) if (!add_element_from_storage(node, entry->data)) return false; /* Add configuration server model on the primary element */ - add_internal_model(node, CONFIG_SRV_MODEL, PRIMARY_ELE_IDX); + mesh_model_add(node, PRIMARY_ELE_IDX, CONFIG_SRV_MODEL, NULL); return true; } @@ -628,7 +553,7 @@ void node_app_key_delete(struct mesh_node *node, uint16_t net_idx, for (; entry; entry = entry->next) { struct node_element *ele = entry->data; - mesh_model_app_key_delete(node, ele->models, app_idx); + mesh_model_app_key_delete(node, ele->idx, ele->models, app_idx); } } @@ -666,27 +591,17 @@ uint8_t node_get_num_elements(struct mesh_node *node) return node->num_ele; } -struct l_queue *node_get_element_models(struct mesh_node *node, - uint8_t ele_idx, int *status) +struct l_queue *node_get_element_models(struct mesh_node *node, uint8_t ele_idx) { struct node_element *ele; - if (!node) { - if (status) - *status = MESH_STATUS_INVALID_ADDRESS; + if (!node) return NULL; - } ele = l_queue_find(node->elements, match_element_idx, L_UINT_TO_PTR(ele_idx)); - if (!ele) { - if (status) - *status = MESH_STATUS_INVALID_ADDRESS; + if (!ele) return NULL; - } - - if (status) - *status = MESH_STATUS_SUCCESS; return ele->models; } @@ -888,9 +803,8 @@ uint8_t node_friend_mode_get(struct mesh_node *node) static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz) { - uint16_t n, features; - uint16_t num_ele = 0; - const struct l_queue_entry *ele_entry; + uint16_t n, features, num_ele = 0; + const struct l_queue_entry *entry; if (!node || sz < MIN_COMP_SIZE) return 0; @@ -920,12 +834,10 @@ static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, l_put_le16(features, buf + n); n += 2; - ele_entry = l_queue_get_entries(node->elements); - for (; ele_entry; ele_entry = ele_entry->next) { - struct node_element *ele = ele_entry->data; - const struct l_queue_entry *mod_entry; - uint8_t num_s = 0, num_v = 0; - uint8_t *mod_buf; + entry = l_queue_get_entries(node->elements); + + for (; entry; entry = entry->next) { + struct node_element *ele = entry->data; if (ele->idx != num_ele) return 0; @@ -939,59 +851,8 @@ static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, l_put_le16(ele->location, buf + n); n += 2; - /* Store models IDs, store num_s and num_v later */ - mod_buf = buf + n; - n += 2; - - /* Get SIG models */ - mod_entry = l_queue_get_entries(ele->models); - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - uint32_t mod_id; - - mod_id = mesh_model_get_model_id( - (const struct mesh_model *) mod); - - if ((mod_id & VENDOR_ID_MASK) == VENDOR_ID_MASK) { - if (n + 2 > sz) - goto element_done; - - l_put_le16((uint16_t) (mod_id & 0xffff), - buf + n); - n += 2; - num_s++; - } - } - - /* Get vendor models */ - mod_entry = l_queue_get_entries(ele->models); - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - uint32_t mod_id; - uint16_t vendor; - - mod_id = mesh_model_get_model_id( - (const struct mesh_model *) mod); - - vendor = (uint16_t) (mod_id >> 16); - if (vendor != 0xffff) { - if (n + 4 > sz) - goto element_done; - - l_put_le16(vendor, buf + n); - n += 2; - l_put_le16((uint16_t) (mod_id & 0xffff), + n += mesh_model_generate_composition(ele->models, sz - n, buf + n); - n += 2; - num_v++; - } - - } - -element_done: - mod_buf[0] = num_s; - mod_buf[1] = num_v; - } if (!num_ele) @@ -1128,52 +989,6 @@ static void app_disc_cb(struct l_dbus *bus, void *user_data) free_node_dbus_resources(node); } -static bool get_model_options(struct mesh_node *node, struct mesh_model *mod, - struct l_dbus_message_iter *opts) -{ - const char *key; - struct l_dbus_message_iter var; - bool opt; - - while (l_dbus_message_iter_next_entry(opts, &key, &var)) { - - if (!strcmp(key, "Publish")) { - if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) - return false; - mesh_model_enable_pub(mod, opt); - } else if (!strcmp(key, "Subscribe")) { - if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) - return false; - mesh_model_enable_sub(node, mod, opt); - } else - return false; - } - - return true; -} - -static bool generate_model(struct mesh_node *node, struct node_element *ele, - uint32_t id, struct l_dbus_message_iter *opts) -{ - struct mesh_model *mod; - - /* Disallow duplicates */ - if (l_queue_find(ele->models, match_model_id, - L_UINT_TO_PTR(id))) - return false; - - mod = mesh_model_new(ele->idx, id); - - if (!get_model_options(node, mod, opts)) { - l_free(mod); - return false; - } - - l_queue_insert(ele->models, mod, compare_model_id, NULL); - - return true; -} - static bool get_sig_models_from_properties(struct mesh_node *node, struct node_element *ele, struct l_dbus_message_iter *property) @@ -1189,13 +1004,13 @@ static bool get_sig_models_from_properties(struct mesh_node *node, /* Bluetooth SIG defined models */ while (l_dbus_message_iter_next_entry(&mods, &m_id, &var)) { - uint32_t id = m_id | VENDOR_ID_MASK; + uint32_t id = SIG_VENDOR | m_id; /* Allow Config Server Model only on the primary element */ if (ele->idx != PRIMARY_ELE_IDX && id == CONFIG_SRV_MODEL) return false; - if (!generate_model(node, ele, id, &var)) + if (!mesh_model_add(node, ele->models, id, &var)) return false; } @@ -1217,9 +1032,9 @@ static bool get_vendor_models_from_properties(struct mesh_node *node, /* Vendor defined models */ while (l_dbus_message_iter_next_entry(&mods, &v_id, &m_id, &var)) { - uint32_t id = m_id | (v_id << 16); + uint32_t id = SET_ID(v_id, m_id); - if (!generate_model(node, ele, id, &var)) + if (!mesh_model_add(node, ele->models, id, &var)) return false; } @@ -1295,7 +1110,7 @@ static bool get_element_properties(struct mesh_node *node, const char *path, * the operation below will be a "no-op". */ if (ele->idx == PRIMARY_ELE_IDX) - add_internal_model(node, CONFIG_SRV_MODEL, PRIMARY_ELE_IDX); + mesh_model_add(node, ele->models, CONFIG_SRV_MODEL, NULL); return true; fail: @@ -1332,7 +1147,6 @@ static void convert_node_to_storage(struct mesh_node *node, for (; entry; entry = entry->next) { struct node_element *ele = entry->data; struct mesh_config_element *db_ele; - const struct l_queue_entry *mod_entry; db_ele = l_new(struct mesh_config_element, 1); @@ -1340,21 +1154,8 @@ static void convert_node_to_storage(struct mesh_node *node, db_ele->location = ele->location; db_ele->models = l_queue_new(); - mod_entry = l_queue_get_entries(ele->models); + mesh_model_convert_to_storage(db_ele->models, ele->models); - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - struct mesh_config_model *db_mod; - uint32_t mod_id = mesh_model_get_model_id(mod); - - db_mod = l_new(struct mesh_config_model, 1); - db_mod->id = mod_id; - db_mod->vendor = ((mod_id & VENDOR_ID_MASK) - != VENDOR_ID_MASK); - db_mod->pub_enabled = mesh_model_is_pub_enabled(mod); - db_mod->sub_enabled = mesh_model_is_sub_enabled(mod); - l_queue_push_tail(db_ele->models, db_mod); - } l_queue_push_tail(db_node->elements, db_ele); } @@ -1375,6 +1176,7 @@ static bool create_node_config(struct mesh_node *node, const uint8_t uuid[16]) /* Free temporarily allocated resources */ entry = l_queue_get_entries(db_node.elements); + for (; entry; entry = entry->next) { struct mesh_config_element *db_ele = entry->data; @@ -1517,7 +1319,6 @@ static void update_model_options(struct mesh_node *node, len = l_queue_length(node->elements); for (i = 0; i < len; i++) { - const struct l_queue_entry *entry; ele = l_queue_find(node->elements, match_element_idx, L_UINT_TO_PTR(i)); @@ -1526,42 +1327,8 @@ static void update_model_options(struct mesh_node *node, if (!ele || !ele_attach) continue; - entry = l_queue_get_entries(ele->models); - - for (; entry; entry = entry->next) { - struct mesh_model *mod, *updated_mod = entry->data; - uint32_t id = mesh_model_get_model_id(updated_mod); - bool opt, updated_opt; - bool vendor = id < VENDOR_ID_MASK; - - mod = l_queue_find(ele_attach->models, match_model_id, - L_UINT_TO_PTR(id)); - if (!mod) - continue; - - if (!vendor) - id &= ~VENDOR_ID_MASK; - - opt = mesh_model_is_pub_enabled(mod); - updated_opt = mesh_model_is_pub_enabled(updated_mod); - - if (updated_opt != opt) { - mesh_model_enable_pub(mod, updated_opt); - mesh_config_model_pub_enable(attach->cfg, - attach->primary + i, id, - vendor, updated_opt); - } - - opt = mesh_model_is_sub_enabled(mod); - updated_opt = mesh_model_is_sub_enabled(updated_mod); - - if (updated_opt != opt) { - mesh_model_enable_sub(node, mod, updated_opt); - mesh_config_model_sub_enable(attach->cfg, - attach->primary + i, id, - vendor, updated_opt); - } - } + mesh_model_update_opts(node, ele->idx, ele_attach->models, + ele->models); } } @@ -1964,7 +1731,7 @@ static void build_element_config(void *a, void *b) l_dbus_message_builder_enter_array(builder, "(qa{sv})"); /* Iterate over models */ - l_queue_foreach(ele->models, model_build_config, builder); + l_queue_foreach(ele->models, mesh_model_build_config, builder); l_dbus_message_builder_leave_array(builder); @@ -2216,8 +1983,8 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, struct l_dbus_message_iter iter_data; uint16_t mod_id, src; struct node_element *ele; - uint8_t *data; - uint32_t len; + uint8_t *data, ttl; + uint32_t len, id; int result; l_debug("Publish"); @@ -2243,8 +2010,9 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - result = mesh_model_publish(node, VENDOR_ID_MASK | mod_id, src, - mesh_net_get_default_ttl(node->net), data, len); + ttl = mesh_net_get_default_ttl(node->net); + id = SIG_VENDOR | mod_id; + result = mesh_model_publish(node, id, src, ttl, data, len); if (result != MESH_ERROR_NONE) return dbus_error(msg, result, NULL); @@ -2259,11 +2027,9 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, struct mesh_node *node = user_data; const char *sender, *ele_path; struct l_dbus_message_iter iter_data; - uint16_t src; - uint16_t model_id, vendor; - uint32_t vendor_mod_id; + uint16_t src, mod_id, vendor_id; struct node_element *ele; - uint8_t *data = NULL; + uint8_t ttl, *data = NULL; uint32_t len; int result; @@ -2274,8 +2040,8 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &vendor, - &model_id, &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &vendor_id, + &mod_id, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); ele = l_queue_find(node->elements, match_element_path, ele_path); @@ -2290,9 +2056,9 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - vendor_mod_id = (vendor << 16) | model_id; - result = mesh_model_publish(node, vendor_mod_id, src, - mesh_net_get_default_ttl(node->net), data, len); + ttl = mesh_net_get_default_ttl(node->net); + result = mesh_model_publish(node, SET_ID(vendor_id, mod_id), src, ttl, + data, len); if (result != MESH_ERROR_NONE) return dbus_error(msg, result, NULL); diff --git a/mesh/node.h b/mesh/node.h index df058458a..47c998530 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -58,8 +58,8 @@ bool node_default_ttl_set(struct mesh_node *node, uint8_t ttl); bool node_set_sequence_number(struct mesh_node *node, uint32_t seq); uint32_t node_get_sequence_number(struct mesh_node *node); int node_get_element_idx(struct mesh_node *node, uint16_t ele_addr); -struct l_queue *node_get_element_models(struct mesh_node *node, uint8_t ele_idx, - int *status); +struct l_queue *node_get_element_models(struct mesh_node *node, + uint8_t ele_idx); uint16_t node_get_crpl(struct mesh_node *node); bool node_init_from_storage(struct mesh_node *node, const uint8_t uuid[16], struct mesh_config_node *db_node); -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4MEIBZ2MGF/RoAAAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 20:59:41 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id SFlvA52MGF9wxQEA0J78UA (envelope-from ); Wed, 22 Jul 2020 20:59:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F20624014E; Wed, 22 Jul 2020 20:59:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728821AbgGVS7f (ORCPT + 1 other); Wed, 22 Jul 2020 14:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbgGVS7e (ORCPT ); Wed, 22 Jul 2020 14:59:34 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 826C0C0619DC for ; Wed, 22 Jul 2020 11:59:34 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id c25so2561232otf.7 for ; Wed, 22 Jul 2020 11:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GdB12dnoTOawpzluSOuk/ROLKi6hRVx1l8xfty7YSoY=; b=XRwl1Nxi5JhBrFY3yuaiYsy/P4jUuJtaCKDVQtFPw0eW8yFCoEISB3Zx0w2v9UW68H LYQw3La8KB/Ht8jAg2sit9iC0aaRNQj+ajJEtZStyGfiod/w7/giTMD3mSTdVrYLmqLH GcG1rbnKrjRvTPhD4500CfSD9uBHibN+VYyRszP4H7vh27c00TyrORkVTRvgU+yVT4j0 ebnhDTgY19J2/JuNX2TosKurglmVM36C2VDg78QApHfYOZch+JSOGakrB4DHP7ODhgyg GFomMbUcGJWLYaEJnqHm4y8NGjFLktN7kFodlu7MB30PMeepnqTs7tdQmZYoQGpByOjj cc+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GdB12dnoTOawpzluSOuk/ROLKi6hRVx1l8xfty7YSoY=; b=KPVs8Rp/5wPKOkb2vB2OFEHzxhgPXovoM1ZHw9dn56YdKNnLWSJyX2jI0J0/WJ4UA6 WbevGQ9el1jQSXqYmZdGvLd959HK270ANE8nU5dUiKKyYQskUkr73cqn+ViC51J0MCO1 PBntpy/53BDzP9BlFWFlAghEzZJKUu54NI14KBgrvY6ZdIW2Fd7oB3N/ygBihhWEeNXC ecab/wJtYAfRWbJP8Mie9V57VdjWgmvxvYb9LrC5YbJ8URbntLuuV/+RLIgZ/MA7kPpd ghvd0ZkcSwfDiap5ERMAACNf+uKbmJay6auI7XRGIAYpqHwhjiR6E8tIpUXXE6BtiMAh ArNA== X-Gm-Message-State: AOAM531n5Fxxt8oHaXm1Hb0AJEWDEgd/Kp3oNorzwux7vshrH0M1rStr Om+sUFhKPlrxAtAOLlSLE76/K3u7U/OuaxZl+qQ= X-Google-Smtp-Source: ABdhPJzMGfzHa7uxB7qsLd6PO/Pk5SiMUAmSTQ0VLdBjO+tD/tMh8HOLPDKd+7+C+IpCjnHXIlhdUlrxIvJeIpw61Bc= X-Received: by 2002:a9d:5e18:: with SMTP id d24mr1228166oti.88.1595444373802; Wed, 22 Jul 2020 11:59:33 -0700 (PDT) MIME-Version: 1.0 References: <20200722113644.Bluez.v3.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> In-Reply-To: <20200722113644.Bluez.v3.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> From: Luiz Augusto von Dentz Date: Wed, 22 Jul 2020 11:59:22 -0700 Message-ID: Subject: Re: [Bluez PATCH v3 1/2] audio/transport: change volume to 8bit To: Archie Pusaka Cc: linux-bluetooth , Archie Pusaka , Michael Sun Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: F20624014E X-Rspamd-UID: a272c5 Hi Archie, On Tue, Jul 21, 2020 at 8:37 PM Archie Pusaka wrote: > > From: Archie Pusaka > > The valid range of volume is 0 - 127, yet it is stored in 16bit > data type. This patch modifies it so we use 8bit data type to > store volume instead. > > Furthermore, this patch introduces helper function and defined > values to check for volume validity, to prevent numbers > scattered all over. > > Reviewed-by: Michael Sun > --- > > Changes in v3: None > Changes in v2: None > > profiles/audio/avrcp.c | 2 +- > profiles/audio/avrcp.h | 1 - > profiles/audio/transport.c | 46 ++++++++++++++++++++++---------------- > profiles/audio/transport.h | 3 ++- > 4 files changed, 30 insertions(+), 22 deletions(-) > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > index 1bf85041e..b312b70b9 100644 > --- a/profiles/audio/avrcp.c > +++ b/profiles/audio/avrcp.c > @@ -1660,7 +1660,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > break; > case AVRCP_EVENT_VOLUME_CHANGED: > pdu->params[1] = media_transport_get_device_volume(dev); > - if (pdu->params[1] > 127) > + if (!media_transport_volume_valid(pdu->params[1])) > goto err; > > len = 2; > diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h > index 86d310c73..3fd74e18a 100644 > --- a/profiles/audio/avrcp.h > +++ b/profiles/audio/avrcp.h > @@ -114,6 +114,5 @@ void avrcp_unregister_player(struct avrcp_player *player); > void avrcp_player_event(struct avrcp_player *player, uint8_t id, > const void *data); > > - > size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands); > size_t avrcp_browsing_general_reject(uint8_t *operands); > diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c > index 48fabba9b..a32073380 100644 > --- a/profiles/audio/transport.c > +++ b/profiles/audio/transport.c > @@ -55,6 +55,8 @@ > > #define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1" > > +#define UNINITIALIZED_VOLUME_VALUE 128 > + > typedef enum { > TRANSPORT_STATE_IDLE, /* Not acquired and suspended */ > TRANSPORT_STATE_PENDING, /* Playing but not acquired */ > @@ -86,7 +88,7 @@ struct media_owner { > struct a2dp_transport { > struct avdtp *session; > uint16_t delay; > - uint16_t volume; > + uint8_t volume; It might be simpler to just have it as int8_t so we can keep the current logic of negative means invalid. > }; > > struct media_transport { > @@ -634,7 +636,7 @@ static gboolean volume_exists(const GDBusPropertyTable *property, void *data) > struct media_transport *transport = data; > struct a2dp_transport *a2dp = transport->data; > > - return a2dp->volume <= 127; > + return media_transport_volume_valid(a2dp->volume); > } > > static gboolean get_volume(const GDBusPropertyTable *property, > @@ -654,24 +656,20 @@ static void set_volume(const GDBusPropertyTable *property, > { > struct media_transport *transport = data; > struct a2dp_transport *a2dp = transport->data; > - uint16_t volume; > + uint16_t arg; > + uint8_t volume; > bool notify; > > - if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) { > - g_dbus_pending_property_error(id, > - ERROR_INTERFACE ".InvalidArguments", > - "Invalid arguments in method call"); > - return; > - } > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) > + goto error; > > - dbus_message_iter_get_basic(iter, &volume); > + dbus_message_iter_get_basic(iter, &arg); > + if (arg > UINT8_MAX) > + goto error; > > - if (volume > 127) { > - g_dbus_pending_property_error(id, > - ERROR_INTERFACE ".InvalidArguments", > - "Invalid arguments in method call"); > - return; > - } > + volume = (uint8_t)arg; > + if (!media_transport_volume_valid(volume)) > + goto error; > > g_dbus_pending_property_success(id); > > @@ -688,6 +686,11 @@ static void set_volume(const GDBusPropertyTable *property, > "Volume"); > > avrcp_set_volume(transport->device, volume, notify); > + return; > + > +error: > + g_dbus_pending_property_error(id, ERROR_INTERFACE ".InvalidArguments", > + "Invalid arguments in method call"); > } > > static gboolean endpoint_exists(const GDBusPropertyTable *property, void *data) > @@ -824,7 +827,7 @@ static int media_transport_init_source(struct media_transport *transport) > transport->data = a2dp; > transport->destroy = destroy_a2dp; > > - a2dp->volume = -1; > + a2dp->volume = UNINITIALIZED_VOLUME_VALUE; > transport->sink_watch = sink_add_state_cb(service, sink_state_changed, > transport); > > @@ -931,7 +934,7 @@ struct btd_device *media_transport_get_dev(struct media_transport *transport) > return transport->device; > } > > -uint16_t media_transport_get_volume(struct media_transport *transport) > +uint8_t media_transport_get_volume(struct media_transport *transport) > { > struct a2dp_transport *a2dp = transport->data; > return a2dp->volume; > @@ -958,7 +961,7 @@ uint8_t media_transport_get_device_volume(struct btd_device *dev) > GSList *l; > > if (dev == NULL) > - return 128; > + return UNINITIALIZED_VOLUME_VALUE; > > for (l = transports; l; l = l->next) { > struct media_transport *transport = l->data; > @@ -991,3 +994,8 @@ void media_transport_update_device_volume(struct btd_device *dev, > media_transport_update_volume(transport, volume); > } > } > + > +bool media_transport_volume_valid(uint8_t volume) > +{ > + return volume < 128; > +} > diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h > index ac542bf6c..c430515f2 100644 > --- a/profiles/audio/transport.h > +++ b/profiles/audio/transport.h > @@ -32,7 +32,7 @@ struct media_transport *media_transport_create(struct btd_device *device, > void media_transport_destroy(struct media_transport *transport); > const char *media_transport_get_path(struct media_transport *transport); > struct btd_device *media_transport_get_dev(struct media_transport *transport); > -uint16_t media_transport_get_volume(struct media_transport *transport); > +uint8_t media_transport_get_volume(struct media_transport *transport); > void media_transport_update_delay(struct media_transport *transport, > uint16_t delay); > void media_transport_update_volume(struct media_transport *transport, > @@ -43,3 +43,4 @@ void transport_get_properties(struct media_transport *transport, > uint8_t media_transport_get_device_volume(struct btd_device *dev); > void media_transport_update_device_volume(struct btd_device *dev, > uint8_t volume); > +bool media_transport_volume_valid(uint8_t volume); > -- > 2.28.0.rc0.105.gf9edc3c819-goog > -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OCQ7EwKjGF+yDwEAvsO+Rg (envelope-from ) for ; Wed, 22 Jul 2020 22:35:14 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id QE22EQKjGF+cGQAA0J78UA (envelope-from ); Wed, 22 Jul 2020 22:35:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 336C8A19A1; Wed, 22 Jul 2020 22:35:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726685AbgGVUfG (ORCPT + 1 other); Wed, 22 Jul 2020 16:35:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726447AbgGVUfG (ORCPT ); Wed, 22 Jul 2020 16:35:06 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 184DFC0619DC for ; Wed, 22 Jul 2020 13:35:06 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id k4so3055071oik.2 for ; Wed, 22 Jul 2020 13:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=kIbGa1vclUuVgKVZJGdjVCXz2snjXal04BZ3OTVrcM0=; b=n0L+MCSTm2USDi0KGIOYXFAkRM8zL+XgUNvtV3GoOSt5Q+dCam0iDKzyHeMH8h2xnt Qs3f4MolMXyx9nnCR+dKoiG5VvjM4sBtkqoH/eSMP3QGiFdN55leu3qaEIoxIRcKARqv MR6ha+Uy5QG1la1Bs8FuMYCdcl5V9gdRtzZTM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=kIbGa1vclUuVgKVZJGdjVCXz2snjXal04BZ3OTVrcM0=; b=cRF0Uo0TCxp2m5dhnTyKdOnJlQfEwPESm2O3+kDlHvl78A/82rJzy413tc5BLI4Kix Yc8W+B7NxzYKwdApcnL/ck5kf0WZAP9nU6tbNQ0++L0S8RRlSJcxKbW0xjBlCOtjYTgX zEAlyskJ033Er00IEWWf2H2ThS+6g4tIeACfusgVM6Asmix8hTmln2rm9TOZkXM7mchX 89V4wjhUZoUx6N0dg4XiBFqSX/ZpqAGQ+3s5+j+P87yr0YbIt4IV98Lx8C+wmXjJ8Pyc CqfUFFlX0AlUZcR8mwXPl16XI2ZB1KOG3yZ/pP6X3Kgw0neatCq+9wP+1cnvPC1klSXG BNLg== X-Gm-Message-State: AOAM530kXNcINWPAQQeFGJ9vBgOGzc9aU/2ppZHp9o83EXccP4TqAMsD /VlgYLbPkHbDlPEGmR4z17f8C0y6yRvKFEZkLFn0nYHoIQU= X-Google-Smtp-Source: ABdhPJwxmEDU4PYWcgBb2mVbOyVZRxSty0hCqHq96QTzBKYdS9p7PedGWjjIDi3VxFrKBK5F2Tv3c9FJl6ulvJj2Od8= X-Received: by 2002:aca:3043:: with SMTP id w64mr1191342oiw.27.1595450105052; Wed, 22 Jul 2020 13:35:05 -0700 (PDT) MIME-Version: 1.0 References: <20200717231404.240644-1-sonnysasaka@chromium.org> In-Reply-To: <20200717231404.240644-1-sonnysasaka@chromium.org> From: Sonny Sasaka Date: Wed, 22 Jul 2020 13:34:53 -0700 Message-ID: Subject: Re: [PATCH BlueZ] Add a presubmit configuration file for Chromium OS repo To: BlueZ Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.52 / 15.00 / 200.00 X-Rspamd-Queue-Id: 336C8A19A1 X-Rspamd-UID: 6532d1 Maintainers, could you take a look at this? We started using a mirror of upstream in chromium repo, so we can not apply this PRESUBMIT.cfg file as our own commit. It'd be great if this file can be submitted upstream as well to help Chromium OS developers' workflow. On Fri, Jul 17, 2020 at 4:14 PM Sonny Sasaka wrote: > > Chromium OS developers use gerrit and repo in their workflow. > (https://gerrit.googlesource.com/git-repo/). This configuration file > makes it easier when uploading patches to gerrit with the repo tool. > > --- > PRESUBMIT.cfg | 8 ++++++++ > 1 file changed, 8 insertions(+) > create mode 100644 PRESUBMIT.cfg > > diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg > new file mode 100644 > index 000000000..10f89b741 > --- /dev/null > +++ b/PRESUBMIT.cfg > @@ -0,0 +1,8 @@ > +# This is a configuration for Chromium OS repo pre-upload hooks. > +# repohooks doc: https://chromium.googlesource.com/chromiumos/repohooks/ > +# Chromium OS BlueZ git repo: https://chromium.googlesource.com/chromiumos/third_party/bluez/ > + > +[Hook Overrides] > +cros_license_check: false > +tab_check: false > +checkpatch_check: true > -- > 2.26.2 > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OCXGIvYaGV+HUAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 07:07:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OOwZIfYaGV8y3wEAgupzMw (envelope-from ); Thu, 23 Jul 2020 07:07:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9A08040875; Thu, 23 Jul 2020 07:06:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726108AbgGWFG5 (ORCPT + 1 other); Thu, 23 Jul 2020 01:06:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgGWFG5 (ORCPT ); Thu, 23 Jul 2020 01:06:57 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D11A8C0619E1 for ; Wed, 22 Jul 2020 22:06:56 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id h17so3946534oie.3 for ; Wed, 22 Jul 2020 22:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=AeHRv/0sB5DW1ivWHhxc5xKHLhyP/6NIUxodWKVPFA0=; b=vH9z2S1k3nHSoqUGdkmoiY+PFZS6bkSvJMbLrELOT1ouLEphhm7areNuea2yE7hKRJ 9WIIKdXA6KEygDYWZOGj+XXmnl1XpONsLOnGjLxCzKzqTqtNr17i/MX0h/jf/Qb1A/Gv zUFE6wvfjIA3xQsGn+J+t5i+/Fhzm3Iv05lK1GqFhDqr1RMzxawm8Dww4v9zjjh5yaho jBsaO94P4wEJvK3riZrzD40WuWPW2dKfaZV2Z23u1UFyP2HZN8lAQOwC17osGxq6Tuif ROn7nu6TAsDV7FLrcl9bjjZir8eg0+eDDdNO1lYv7halI1Pbjd2SKlrl4x9cEXkR/aQE GUiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=AeHRv/0sB5DW1ivWHhxc5xKHLhyP/6NIUxodWKVPFA0=; b=bauK45ZMV5C780wJRo7hFSydGlqNJAt5Ow2qr6BE2kcsf50EZ9LpE+dB43ZdkYk08w e27gHoUNMwEGlG5uMu0f0j/Jgq0C5owteQ/XVO5OcD/qT9FWNmjnR3BaTB/9Ldz3pqml nzfbTtEp6/0sypgGeLWDILWC8QqjDGEQAlxk2PiQ2UtYYGjo9VQRk8kWVo7U0g5jeNHS PiUO0aaKIAoZn1kb0HqlsyS/KzcuKaoYVw32tlA6eWPFIc/u7UOMRuVv7lwjdmcGqg1j v9WO4hWqQx9E5xS1rb+UqdnlIyvzV8BRel7ua11jk1lcMTVIvwwMSOUmYjU+MipF11MT PCow== X-Gm-Message-State: AOAM530YDnkS/bbGIT3QTzzWZVXscrSLtde8NtavE/GvaoPsnUJ3dXjw lLFl8qkovEd1ojAfNZvSQEnqc4gPfVypUpcXmAwXPMA= X-Google-Smtp-Source: ABdhPJwCckgW1CXt1ZynFqtlCQTt0kprxlTI4HEcCSgVvGnb/gIpO4wpJkaSUXhZMkOjVF3OaEZ9oy7GL/gDsN++Sq8= X-Received: by 2002:aca:3357:: with SMTP id z84mr2453615oiz.100.1595480816110; Wed, 22 Jul 2020 22:06:56 -0700 (PDT) MIME-Version: 1.0 From: Click2 work Date: Thu, 23 Jul 2020 10:36:42 +0530 Message-ID: Subject: BlueZ host To: linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.39 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9A08040875 X-Rspamd-UID: 139ec3 Hi, I want to use the BlueZ host stack with one of the controller which supports the latest Bluetooth 5.2 features. I want to know whether BlueZ supports latest BT 5.2 or 5.1 or 5.0 features?.Looking forward to hearing from you. Thanks in advance. Regards, Sridhar Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aFjeC7YpGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:09:58 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wBcjCrYpGV+QCQAADc0bRg (envelope-from ); Thu, 23 Jul 2020 08:09:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 06D2440676; Thu, 23 Jul 2020 08:09:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbgGWGJh (ORCPT + 1 other); Thu, 23 Jul 2020 02:09:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgGWGJg (ORCPT ); Thu, 23 Jul 2020 02:09:36 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26629C0619DC; Wed, 22 Jul 2020 23:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=AjKHhDGZLqL4OuQUXI3ghPRn4d0K9eK+41+WmsKDw4s=; b=CNu8wX7/4AaScPiP+yKasX/Nuq 00LHKTXAD3IquBRcEMSnRF8bNgMD1cvHh+U+oC9aYlopzyBcHDT20XOh1UxeZFqfjZgeBbGvE1wB6 /V6nQUH0PdaU2g+5JOnd1u9l8C/s6uwbv4KhpIhdxBK8oLO0ZwY+sqyTh4ne0vagAIgh4N5VQBGx0 JHE6q8bbDMTkx2eOaxshkvfo9rjtP0ncEN/z4VwN6Hb6/0xYri2cf1nNOzgptOsfvtMuA7wmNkOac QLJGCjm4BB8DbTIK1mpqQYiSCZNmMlsC+Vd1KrBSfphtSKPM32mRgHArgFrIC0MlfCF8txHO3F2DP u7/I0W5g==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUPz-0003lF-6z; Thu, 23 Jul 2020 06:09:23 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 10/26] netfilter: remove the unused user argument to do_update_counters Date: Thu, 23 Jul 2020 08:08:52 +0200 Message-Id: <20200723060908.50081-11-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 06D2440676 X-Rspamd-UID: 9d3946 Signed-off-by: Christoph Hellwig --- net/bridge/netfilter/ebtables.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index fe13108af1f542..12f8929667bf43 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1242,9 +1242,8 @@ void ebt_unregister_table(struct net *net, struct ebt_table *table, /* userspace just supplied us with counters */ static int do_update_counters(struct net *net, const char *name, - struct ebt_counter __user *counters, - unsigned int num_counters, - const void __user *user, unsigned int len) + struct ebt_counter __user *counters, + unsigned int num_counters, unsigned int len) { int i, ret; struct ebt_counter *tmp; @@ -1299,7 +1298,7 @@ static int update_counters(struct net *net, const void __user *user, return -EINVAL; return do_update_counters(net, hlp.name, hlp.counters, - hlp.num_counters, user, len); + hlp.num_counters, len); } static inline int ebt_obj_to_user(char __user *um, const char *_name, @@ -2231,7 +2230,7 @@ static int compat_update_counters(struct net *net, void __user *user, return update_counters(net, user, len); return do_update_counters(net, hlp.name, compat_ptr(hlp.counters), - hlp.num_counters, user, len); + hlp.num_counters, len); } static int compat_do_ebt_get_ctl(struct sock *sk, int cmd, -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KD56H8cpGV80bgEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:10:15 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id OEW1HccpGV8blAEAlScrYA (envelope-from ); Thu, 23 Jul 2020 08:10:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8E9C14AA22; Thu, 23 Jul 2020 08:10:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727022AbgGWGJv (ORCPT + 1 other); Thu, 23 Jul 2020 02:09:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726982AbgGWGJt (ORCPT ); Thu, 23 Jul 2020 02:09:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB438C0619E3; Wed, 22 Jul 2020 23:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=oYVq7NIRWqvX/f/cel/N+xePG7N1PJ2B3QTLRfoiAMQ=; b=RmS+yof9oOWACLzdO26AX0uvn/ wDiM3OtnYGKll0k7V7EEhs4h13147H5vXBTkLjApiEE7c2uKTZSFyO4x4GL348FhVTbWDpILohbSo cBkUCd/tpSzjo2rHYMxoLok4j+mlk3gd/kM12ANxEJtjEfY7gB+/CfbIkXZ7qkQyjHJE1L20fDqWN ci1Kri+UWaOL5Rr5mlx8jFaaQnl0mNoIi82p9ICnX1kU+pMrwVVKsSSHtBvXGpiZidpQky2908IqH pyh4iVL9I1l+vvct9nOY0bjp9ijfrIYfa3cycmVYL7P/WWMOnYE0MGHGrzsKRyRPgb36hKUw55sKp 2hccLDLw==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQB-0003nH-07; Thu, 23 Jul 2020 06:09:35 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 18/26] net/ipv6: split up ipv6_flowlabel_opt Date: Thu, 23 Jul 2020 08:09:00 +0200 Message-Id: <20200723060908.50081-19-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8E9C14AA22 X-Rspamd-UID: 7770c0 Split ipv6_flowlabel_opt into a subfunction for each action and a small wrapper. Signed-off-by: Christoph Hellwig --- net/ipv6/ip6_flowlabel.c | 311 +++++++++++++++++++++------------------ 1 file changed, 167 insertions(+), 144 deletions(-) diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index ce4fbba4acce7e..27ee6de9beffc4 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c @@ -533,187 +533,210 @@ int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq, return -ENOENT; } -int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen) +#define socklist_dereference(__sflp) \ + rcu_dereference_protected(__sflp, lockdep_is_held(&ip6_sk_fl_lock)) + +static int ipv6_flowlabel_put(struct sock *sk, struct in6_flowlabel_req *freq) { - int uninitialized_var(err); - struct net *net = sock_net(sk); struct ipv6_pinfo *np = inet6_sk(sk); - struct in6_flowlabel_req freq; - struct ipv6_fl_socklist *sfl1 = NULL; - struct ipv6_fl_socklist *sfl; struct ipv6_fl_socklist __rcu **sflp; - struct ip6_flowlabel *fl, *fl1 = NULL; - + struct ipv6_fl_socklist *sfl; - if (optlen < sizeof(freq)) - return -EINVAL; + if (freq->flr_flags & IPV6_FL_F_REFLECT) { + if (sk->sk_protocol != IPPROTO_TCP) + return -ENOPROTOOPT; + if (!np->repflow) + return -ESRCH; + np->flow_label = 0; + np->repflow = 0; + return 0; + } - if (copy_from_user(&freq, optval, sizeof(freq))) - return -EFAULT; + spin_lock_bh(&ip6_sk_fl_lock); + for (sflp = &np->ipv6_fl_list; + (sfl = socklist_dereference(*sflp)) != NULL; + sflp = &sfl->next) { + if (sfl->fl->label == freq->flr_label) + goto found; + } + spin_unlock_bh(&ip6_sk_fl_lock); + return -ESRCH; +found: + if (freq->flr_label == (np->flow_label & IPV6_FLOWLABEL_MASK)) + np->flow_label &= ~IPV6_FLOWLABEL_MASK; + *sflp = sfl->next; + spin_unlock_bh(&ip6_sk_fl_lock); + fl_release(sfl->fl); + kfree_rcu(sfl, rcu); + return 0; +} + +static int ipv6_flowlabel_renew(struct sock *sk, struct in6_flowlabel_req *freq) +{ + struct ipv6_pinfo *np = inet6_sk(sk); + struct net *net = sock_net(sk); + struct ipv6_fl_socklist *sfl; + int err; - switch (freq.flr_action) { - case IPV6_FL_A_PUT: - if (freq.flr_flags & IPV6_FL_F_REFLECT) { - if (sk->sk_protocol != IPPROTO_TCP) - return -ENOPROTOOPT; - if (!np->repflow) - return -ESRCH; - np->flow_label = 0; - np->repflow = 0; - return 0; - } - spin_lock_bh(&ip6_sk_fl_lock); - for (sflp = &np->ipv6_fl_list; - (sfl = rcu_dereference_protected(*sflp, - lockdep_is_held(&ip6_sk_fl_lock))) != NULL; - sflp = &sfl->next) { - if (sfl->fl->label == freq.flr_label) { - if (freq.flr_label == (np->flow_label&IPV6_FLOWLABEL_MASK)) - np->flow_label &= ~IPV6_FLOWLABEL_MASK; - *sflp = sfl->next; - spin_unlock_bh(&ip6_sk_fl_lock); - fl_release(sfl->fl); - kfree_rcu(sfl, rcu); - return 0; - } + rcu_read_lock_bh(); + for_each_sk_fl_rcu(np, sfl) { + if (sfl->fl->label == freq->flr_label) { + err = fl6_renew(sfl->fl, freq->flr_linger, + freq->flr_expires); + rcu_read_unlock_bh(); + return err; } - spin_unlock_bh(&ip6_sk_fl_lock); - return -ESRCH; + } + rcu_read_unlock_bh(); - case IPV6_FL_A_RENEW: - rcu_read_lock_bh(); - for_each_sk_fl_rcu(np, sfl) { - if (sfl->fl->label == freq.flr_label) { - err = fl6_renew(sfl->fl, freq.flr_linger, freq.flr_expires); - rcu_read_unlock_bh(); - return err; - } - } - rcu_read_unlock_bh(); + if (freq->flr_share == IPV6_FL_S_NONE && + ns_capable(net->user_ns, CAP_NET_ADMIN)) { + struct ip6_flowlabel *fl = fl_lookup(net, freq->flr_label); - if (freq.flr_share == IPV6_FL_S_NONE && - ns_capable(net->user_ns, CAP_NET_ADMIN)) { - fl = fl_lookup(net, freq.flr_label); - if (fl) { - err = fl6_renew(fl, freq.flr_linger, freq.flr_expires); - fl_release(fl); - return err; - } + if (fl) { + err = fl6_renew(fl, freq->flr_linger, + freq->flr_expires); + fl_release(fl); + return err; } - return -ESRCH; - - case IPV6_FL_A_GET: - if (freq.flr_flags & IPV6_FL_F_REFLECT) { - struct net *net = sock_net(sk); - if (net->ipv6.sysctl.flowlabel_consistency) { - net_info_ratelimited("Can not set IPV6_FL_F_REFLECT if flowlabel_consistency sysctl is enable\n"); - return -EPERM; - } + } + return -ESRCH; +} - if (sk->sk_protocol != IPPROTO_TCP) - return -ENOPROTOOPT; +static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, + void __user *optval, int optlen) +{ + struct ipv6_fl_socklist *sfl, *sfl1 = NULL; + struct ip6_flowlabel *fl, *fl1 = NULL; + struct ipv6_pinfo *np = inet6_sk(sk); + struct net *net = sock_net(sk); + int uninitialized_var(err); - np->repflow = 1; - return 0; + if (freq->flr_flags & IPV6_FL_F_REFLECT) { + if (net->ipv6.sysctl.flowlabel_consistency) { + net_info_ratelimited("Can not set IPV6_FL_F_REFLECT if flowlabel_consistency sysctl is enable\n"); + return -EPERM; } - if (freq.flr_label & ~IPV6_FLOWLABEL_MASK) - return -EINVAL; + if (sk->sk_protocol != IPPROTO_TCP) + return -ENOPROTOOPT; + np->repflow = 1; + return 0; + } - if (net->ipv6.sysctl.flowlabel_state_ranges && - (freq.flr_label & IPV6_FLOWLABEL_STATELESS_FLAG)) - return -ERANGE; + if (freq->flr_label & ~IPV6_FLOWLABEL_MASK) + return -EINVAL; + if (net->ipv6.sysctl.flowlabel_state_ranges && + (freq->flr_label & IPV6_FLOWLABEL_STATELESS_FLAG)) + return -ERANGE; - fl = fl_create(net, sk, &freq, optval, optlen, &err); - if (!fl) - return err; - sfl1 = kmalloc(sizeof(*sfl1), GFP_KERNEL); + fl = fl_create(net, sk, freq, optval, optlen, &err); + if (!fl) + return err; - if (freq.flr_label) { - err = -EEXIST; - rcu_read_lock_bh(); - for_each_sk_fl_rcu(np, sfl) { - if (sfl->fl->label == freq.flr_label) { - if (freq.flr_flags&IPV6_FL_F_EXCL) { - rcu_read_unlock_bh(); - goto done; - } - fl1 = sfl->fl; - if (!atomic_inc_not_zero(&fl1->users)) - fl1 = NULL; - break; + sfl1 = kmalloc(sizeof(*sfl1), GFP_KERNEL); + + if (freq->flr_label) { + err = -EEXIST; + rcu_read_lock_bh(); + for_each_sk_fl_rcu(np, sfl) { + if (sfl->fl->label == freq->flr_label) { + if (freq->flr_flags & IPV6_FL_F_EXCL) { + rcu_read_unlock_bh(); + goto done; } + fl1 = sfl->fl; + if (!atomic_inc_not_zero(&fl1->users)) + fl1 = NULL; + break; } - rcu_read_unlock_bh(); + } + rcu_read_unlock_bh(); - if (!fl1) - fl1 = fl_lookup(net, freq.flr_label); - if (fl1) { + if (!fl1) + fl1 = fl_lookup(net, freq->flr_label); + if (fl1) { recheck: - err = -EEXIST; - if (freq.flr_flags&IPV6_FL_F_EXCL) - goto release; - err = -EPERM; - if (fl1->share == IPV6_FL_S_EXCL || - fl1->share != fl->share || - ((fl1->share == IPV6_FL_S_PROCESS) && - (fl1->owner.pid != fl->owner.pid)) || - ((fl1->share == IPV6_FL_S_USER) && - !uid_eq(fl1->owner.uid, fl->owner.uid))) - goto release; - - err = -ENOMEM; - if (!sfl1) - goto release; - if (fl->linger > fl1->linger) - fl1->linger = fl->linger; - if ((long)(fl->expires - fl1->expires) > 0) - fl1->expires = fl->expires; - fl_link(np, sfl1, fl1); - fl_free(fl); - return 0; + err = -EEXIST; + if (freq->flr_flags&IPV6_FL_F_EXCL) + goto release; + err = -EPERM; + if (fl1->share == IPV6_FL_S_EXCL || + fl1->share != fl->share || + ((fl1->share == IPV6_FL_S_PROCESS) && + (fl1->owner.pid != fl->owner.pid)) || + ((fl1->share == IPV6_FL_S_USER) && + !uid_eq(fl1->owner.uid, fl->owner.uid))) + goto release; + + err = -ENOMEM; + if (!sfl1) + goto release; + if (fl->linger > fl1->linger) + fl1->linger = fl->linger; + if ((long)(fl->expires - fl1->expires) > 0) + fl1->expires = fl->expires; + fl_link(np, sfl1, fl1); + fl_free(fl); + return 0; release: - fl_release(fl1); - goto done; - } - } - err = -ENOENT; - if (!(freq.flr_flags&IPV6_FL_F_CREATE)) + fl_release(fl1); goto done; + } + } + err = -ENOENT; + if (!(freq->flr_flags & IPV6_FL_F_CREATE)) + goto done; - err = -ENOMEM; - if (!sfl1) - goto done; + err = -ENOMEM; + if (!sfl1) + goto done; - err = mem_check(sk); - if (err != 0) - goto done; + err = mem_check(sk); + if (err != 0) + goto done; - fl1 = fl_intern(net, fl, freq.flr_label); - if (fl1) - goto recheck; + fl1 = fl_intern(net, fl, freq->flr_label); + if (fl1) + goto recheck; - if (!freq.flr_label) { - if (copy_to_user(&((struct in6_flowlabel_req __user *) optval)->flr_label, - &fl->label, sizeof(fl->label))) { - /* Intentionally ignore fault. */ - } + if (!freq->flr_label) { + if (copy_to_user(&((struct in6_flowlabel_req __user *) optval)->flr_label, + &fl->label, sizeof(fl->label))) { + /* Intentionally ignore fault. */ } - - fl_link(np, sfl1, fl); - return 0; - - default: - return -EINVAL; } + fl_link(np, sfl1, fl); + return 0; done: fl_free(fl); kfree(sfl1); return err; } +int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen) +{ + struct in6_flowlabel_req freq; + + if (optlen < sizeof(freq)) + return -EINVAL; + if (copy_from_user(&freq, optval, sizeof(freq))) + return -EFAULT; + + switch (freq.flr_action) { + case IPV6_FL_A_PUT: + return ipv6_flowlabel_put(sk, &freq); + case IPV6_FL_A_RENEW: + return ipv6_flowlabel_renew(sk, &freq); + case IPV6_FL_A_GET: + return ipv6_flowlabel_get(sk, &freq, optval, optlen); + default: + return -EINVAL; + } +} + #ifdef CONFIG_PROC_FS struct ip6fl_iter_state { -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EOaOJc0pGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:10:21 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AAj3I80pGV+dHQAADc0bRg (envelope-from ); Thu, 23 Jul 2020 08:10:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 456A840876; Thu, 23 Jul 2020 08:10:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727038AbgGWGJv (ORCPT + 1 other); Thu, 23 Jul 2020 02:09:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbgGWGJt (ORCPT ); Thu, 23 Jul 2020 02:09:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1133BC0619E4; Wed, 22 Jul 2020 23:09:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=QlF9uAsII4M+JCuvUaS+q9mzPBlfDSxuvtjJe160dNk=; b=uZpwgVyKUu+sHnxI+GopWTiL6d DflWs0zNQjkIouFC0PpLfgVqeceaXeebrBT5Hvgv+9HSYM4TyCMCIZGNx0+eYeBh9Tk5DjZoJE2ro UJGhbM7n/58Y745F6R/Sl5/zL7mwtLqnrhlHyFj6SCbQnnMskl3ihsH7pO2q9RweF/QQgtU+/UtiD nZj8xRqnjHonqyiSEDEzjBQjJvsw20nWfWc6j5DF0O44Txm+ejF4IsqcMx+w2BErUSkUFBMz1LlXR 2i8tmMsDMWhw3zS9ExTIp/pb+BbFtV9/+PhOtPC2fO6cdMLW1zjwttIWVfyd6a0qDsrPXfM7heqhE v40/SZRw==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQC-0003nc-G6; Thu, 23 Jul 2020 06:09:36 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 19/26] net/ipv6: switch ipv6_flowlabel_opt to sockptr_t Date: Thu, 23 Jul 2020 08:09:01 +0200 Message-Id: <20200723060908.50081-20-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 456A840876 X-Rspamd-UID: 6fef52 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Note that the get case is pretty weird in that it actually copies data back to userspace from setsockopt. Signed-off-by: Christoph Hellwig --- include/net/ipv6.h | 2 +- net/ipv6/ip6_flowlabel.c | 16 +++++++++------- net/ipv6/ipv6_sockglue.c | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 262fc88dbd7e2f..4c9d89b5d73268 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -406,7 +406,7 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space, struct ip6_flowlabel *fl, struct ipv6_txoptions *fopt); void fl6_free_socklist(struct sock *sk); -int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen); +int ipv6_flowlabel_opt(struct sock *sk, sockptr_t optval, int optlen); int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq, int flags); int ip6_flowlabel_init(void); diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index 27ee6de9beffc4..6b3c315f3d461a 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c @@ -371,7 +371,7 @@ static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned lo static struct ip6_flowlabel * fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, - char __user *optval, int optlen, int *err_p) + sockptr_t optval, int optlen, int *err_p) { struct ip6_flowlabel *fl = NULL; int olen; @@ -401,7 +401,8 @@ fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, memset(fl->opt, 0, sizeof(*fl->opt)); fl->opt->tot_len = sizeof(*fl->opt) + olen; err = -EFAULT; - if (copy_from_user(fl->opt+1, optval+CMSG_ALIGN(sizeof(*freq)), olen)) + sockptr_advance(optval, CMSG_ALIGN(sizeof(*freq))); + if (copy_from_sockptr(fl->opt + 1, optval, olen)) goto done; msg.msg_controllen = olen; @@ -604,7 +605,7 @@ static int ipv6_flowlabel_renew(struct sock *sk, struct in6_flowlabel_req *freq) } static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct ipv6_fl_socklist *sfl, *sfl1 = NULL; struct ip6_flowlabel *fl, *fl1 = NULL; @@ -702,8 +703,9 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, goto recheck; if (!freq->flr_label) { - if (copy_to_user(&((struct in6_flowlabel_req __user *) optval)->flr_label, - &fl->label, sizeof(fl->label))) { + sockptr_advance(optval, + offsetof(struct in6_flowlabel_req, flr_label)); + if (copy_to_sockptr(optval, &fl->label, sizeof(fl->label))) { /* Intentionally ignore fault. */ } } @@ -716,13 +718,13 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, return err; } -int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen) +int ipv6_flowlabel_opt(struct sock *sk, sockptr_t optval, int optlen) { struct in6_flowlabel_req freq; if (optlen < sizeof(freq)) return -EINVAL; - if (copy_from_user(&freq, optval, sizeof(freq))) + if (copy_from_sockptr(&freq, optval, sizeof(freq))) return -EFAULT; switch (freq.flr_action) { diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 119dfaf5f4bb26..3897fb55372d38 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -929,7 +929,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, retv = 0; break; case IPV6_FLOWLABEL_MGR: - retv = ipv6_flowlabel_opt(sk, optval, optlen); + retv = ipv6_flowlabel_opt(sk, USER_SOCKPTR(optval), optlen); break; case IPV6_IPSEC_POLICY: case IPV6_XFRM_POLICY: -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cKfmKZQqGV99mAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:13:40 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wLuhKJQqGV/CmQAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 08:13:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2CF37404BB; Thu, 23 Jul 2020 08:13:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726990AbgGWGJu (ORCPT + 1 other); Thu, 23 Jul 2020 02:09:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726649AbgGWGJp (ORCPT ); Thu, 23 Jul 2020 02:09:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22A5DC0619DC; Wed, 22 Jul 2020 23:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=7JpGBoLpaFE7Jf5UF2pDwmquZJ8aXq1cjTXF4rce5nE=; b=if/Qegv4brr1NXoBiud4NJcKIp V7zYS2WTQuFNMlIeqML7By9MKB8BvXuzZYn/xCkWhSa63kU6Rl63ePHIdT8VvpiDZV8tJl9S6jbeV iSeG9VgSbS1Ld1QuuPrqeu562yQRRnU0tKUBhgdN5cqchwPyXO1pgzYvgNbRFZNbk39h1InTlUdB9 XMqzDab2vgcAazMkysGnZWsSl4JlgdoBNR8lP/9CVu3XXew+u7ghJRJENmwh6sgXq4erH5QxcLlyN E2M3yh0TCRU+aNENg8H8W9YAc6M4/B8vxXE/N4ONqP61HGCG9h8KGpQ0wQ4sdmlw9KE8QSa9Igv56 8a0ehEqg==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQ8-0003mj-AB; Thu, 23 Jul 2020 06:09:32 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 16/26] net/ipv4: switch do_ip_setsockopt to sockptr_t Date: Thu, 23 Jul 2020 08:08:58 +0200 Message-Id: <20200723060908.50081-17-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2CF37404BB X-Rspamd-UID: f5179f Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- net/ipv4/ip_sockglue.c | 68 ++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index b12f39b52008a3..f7f1507b89fe24 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -683,15 +683,15 @@ static int set_mcast_msfilter(struct sock *sk, int ifindex, return -EADDRNOTAVAIL; } -static int copy_group_source_from_user(struct group_source_req *greqs, - void __user *optval, int optlen) +static int copy_group_source_from_sockptr(struct group_source_req *greqs, + sockptr_t optval, int optlen) { if (in_compat_syscall()) { struct compat_group_source_req gr32; if (optlen != sizeof(gr32)) return -EINVAL; - if (copy_from_user(&gr32, optval, sizeof(gr32))) + if (copy_from_sockptr(&gr32, optval, sizeof(gr32))) return -EFAULT; greqs->gsr_interface = gr32.gsr_interface; greqs->gsr_group = gr32.gsr_group; @@ -699,7 +699,7 @@ static int copy_group_source_from_user(struct group_source_req *greqs, } else { if (optlen != sizeof(*greqs)) return -EINVAL; - if (copy_from_user(greqs, optval, sizeof(*greqs))) + if (copy_from_sockptr(greqs, optval, sizeof(*greqs))) return -EFAULT; } @@ -707,14 +707,14 @@ static int copy_group_source_from_user(struct group_source_req *greqs, } static int do_mcast_group_source(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct group_source_req greqs; struct ip_mreq_source mreqs; struct sockaddr_in *psin; int omode, add, err; - err = copy_group_source_from_user(&greqs, optval, optlen); + err = copy_group_source_from_sockptr(&greqs, optval, optlen); if (err) return err; @@ -754,8 +754,7 @@ static int do_mcast_group_source(struct sock *sk, int optname, return ip_mc_source(add, omode, sk, &mreqs, greqs.gsr_interface); } -static int ip_set_mcast_msfilter(struct sock *sk, void __user *optval, - int optlen) +static int ip_set_mcast_msfilter(struct sock *sk, sockptr_t optval, int optlen) { struct group_filter *gsf = NULL; int err; @@ -765,7 +764,7 @@ static int ip_set_mcast_msfilter(struct sock *sk, void __user *optval, if (optlen > sysctl_optmem_max) return -ENOBUFS; - gsf = memdup_user(optval, optlen); + gsf = memdup_sockptr(optval, optlen); if (IS_ERR(gsf)) return PTR_ERR(gsf); @@ -786,7 +785,7 @@ static int ip_set_mcast_msfilter(struct sock *sk, void __user *optval, return err; } -static int compat_ip_set_mcast_msfilter(struct sock *sk, void __user *optval, +static int compat_ip_set_mcast_msfilter(struct sock *sk, sockptr_t optval, int optlen) { const int size0 = offsetof(struct compat_group_filter, gf_slist); @@ -806,7 +805,7 @@ static int compat_ip_set_mcast_msfilter(struct sock *sk, void __user *optval, gf32 = p + 4; /* we want ->gf_group and ->gf_slist aligned */ err = -EFAULT; - if (copy_from_user(gf32, optval, optlen)) + if (copy_from_sockptr(gf32, optval, optlen)) goto out_free_gsf; /* numsrc >= (4G-140)/128 overflow in 32 bits */ @@ -831,7 +830,7 @@ static int compat_ip_set_mcast_msfilter(struct sock *sk, void __user *optval, } static int ip_mcast_join_leave(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct ip_mreqn mreq = { }; struct sockaddr_in *psin; @@ -839,7 +838,7 @@ static int ip_mcast_join_leave(struct sock *sk, int optname, if (optlen < sizeof(struct group_req)) return -EINVAL; - if (copy_from_user(&greq, optval, sizeof(greq))) + if (copy_from_sockptr(&greq, optval, sizeof(greq))) return -EFAULT; psin = (struct sockaddr_in *)&greq.gr_group; @@ -853,7 +852,7 @@ static int ip_mcast_join_leave(struct sock *sk, int optname, } static int compat_ip_mcast_join_leave(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct compat_group_req greq; struct ip_mreqn mreq = { }; @@ -861,7 +860,7 @@ static int compat_ip_mcast_join_leave(struct sock *sk, int optname, if (optlen < sizeof(struct compat_group_req)) return -EINVAL; - if (copy_from_user(&greq, optval, sizeof(greq))) + if (copy_from_sockptr(&greq, optval, sizeof(greq))) return -EFAULT; psin = (struct sockaddr_in *)&greq.gr_group; @@ -875,8 +874,8 @@ static int compat_ip_mcast_join_leave(struct sock *sk, int optname, return ip_mc_leave_group(sk, &mreq); } -static int do_ip_setsockopt(struct sock *sk, int level, - int optname, char __user *optval, unsigned int optlen) +static int do_ip_setsockopt(struct sock *sk, int level, int optname, + sockptr_t optval, unsigned int optlen) { struct inet_sock *inet = inet_sk(sk); struct net *net = sock_net(sk); @@ -910,12 +909,12 @@ static int do_ip_setsockopt(struct sock *sk, int level, case IP_RECVFRAGSIZE: case IP_RECVERR_RFC4884: if (optlen >= sizeof(int)) { - if (get_user(val, (int __user *) optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; } else if (optlen >= sizeof(char)) { unsigned char ucval; - if (get_user(ucval, (unsigned char __user *) optval)) + if (copy_from_sockptr(&ucval, optval, sizeof(ucval))) return -EFAULT; val = (int) ucval; } @@ -926,8 +925,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, if (optname == IP_ROUTER_ALERT) return ip_ra_control(sk, val ? 1 : 0, NULL); if (ip_mroute_opt(optname)) - return ip_mroute_setsockopt(sk, optname, USER_SOCKPTR(optval), - optlen); + return ip_mroute_setsockopt(sk, optname, optval, optlen); err = 0; if (needs_rtnl) @@ -941,8 +939,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, if (optlen > 40) goto e_inval; - err = ip_options_get(sock_net(sk), &opt, USER_SOCKPTR(optval), - optlen); + err = ip_options_get(sock_net(sk), &opt, optval, optlen); if (err) break; old = rcu_dereference_protected(inet->inet_opt, @@ -1140,17 +1137,17 @@ static int do_ip_setsockopt(struct sock *sk, int level, err = -EFAULT; if (optlen >= sizeof(struct ip_mreqn)) { - if (copy_from_user(&mreq, optval, sizeof(mreq))) + if (copy_from_sockptr(&mreq, optval, sizeof(mreq))) break; } else { memset(&mreq, 0, sizeof(mreq)); if (optlen >= sizeof(struct ip_mreq)) { - if (copy_from_user(&mreq, optval, - sizeof(struct ip_mreq))) + if (copy_from_sockptr(&mreq, optval, + sizeof(struct ip_mreq))) break; } else if (optlen >= sizeof(struct in_addr)) { - if (copy_from_user(&mreq.imr_address, optval, - sizeof(struct in_addr))) + if (copy_from_sockptr(&mreq.imr_address, optval, + sizeof(struct in_addr))) break; } } @@ -1202,11 +1199,12 @@ static int do_ip_setsockopt(struct sock *sk, int level, goto e_inval; err = -EFAULT; if (optlen >= sizeof(struct ip_mreqn)) { - if (copy_from_user(&mreq, optval, sizeof(mreq))) + if (copy_from_sockptr(&mreq, optval, sizeof(mreq))) break; } else { memset(&mreq, 0, sizeof(mreq)); - if (copy_from_user(&mreq, optval, sizeof(struct ip_mreq))) + if (copy_from_sockptr(&mreq, optval, + sizeof(struct ip_mreq))) break; } @@ -1226,7 +1224,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, err = -ENOBUFS; break; } - msf = memdup_user(optval, optlen); + msf = memdup_sockptr(optval, optlen); if (IS_ERR(msf)) { err = PTR_ERR(msf); break; @@ -1257,7 +1255,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, if (optlen != sizeof(struct ip_mreq_source)) goto e_inval; - if (copy_from_user(&mreqs, optval, sizeof(mreqs))) { + if (copy_from_sockptr(&mreqs, optval, sizeof(mreqs))) { err = -EFAULT; break; } @@ -1324,8 +1322,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, err = -EPERM; if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) break; - err = xfrm_user_policy(sk, optname, USER_SOCKPTR(optval), - optlen); + err = xfrm_user_policy(sk, optname, optval, optlen); break; case IP_TRANSPARENT: @@ -1412,7 +1409,8 @@ int ip_setsockopt(struct sock *sk, int level, if (level != SOL_IP) return -ENOPROTOOPT; - err = do_ip_setsockopt(sk, level, optname, optval, optlen); + err = do_ip_setsockopt(sk, level, optname, USER_SOCKPTR(optval), + optlen); #if IS_ENABLED(CONFIG_BPFILTER_UMH) if (optname >= BPFILTER_IPT_SO_SET_REPLACE && optname < BPFILTER_IPT_SET_MAX) -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yMlHK5oqGV80bgEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:13:46 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WNthKZoqGV/cpQAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 08:13:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5A63740CB4; Thu, 23 Jul 2020 08:13:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726928AbgGWGJm (ORCPT + 1 other); Thu, 23 Jul 2020 02:09:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726893AbgGWGJk (ORCPT ); Thu, 23 Jul 2020 02:09:40 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85FE1C0619E2; Wed, 22 Jul 2020 23:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=3imfOAwuDTlb5YTszhgUXl+QpResNZl5INQAts7FDyw=; b=M7RnAinpaLM4eSKoNueJTZaeo9 xQz5y9wsoeHOdq2TGheKnDq0/6j8YL+ThgZWZpFDvyGYOkWCB0h5HGD6ni1PC6mIBRGAGDJyz7udz GcPGu7/cKpowyaVML6P2o9lpoLifRNA0nWhM96SVzw5voPGm6ChHpSFSnBOGT+G5Zg6ddxEJo4ypU 94WtHfJf6WMX09KAbnlynr7Z/ayxufNzzrQPhg3hXArQOLiRg5CU1zA6Dwx75j4CbEkE/71dkns9Q gjzgU9orKnM45m/Hgh5b9gybV+nWbR3539y8h8wZGG4igNXNXLNJxdnmlJlDeWDJ7mOA/8XktKPuv qTOIHZHQ==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQ4-0003m2-L9; Thu, 23 Jul 2020 06:09:28 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 14/26] net/ipv4: switch ip_mroute_setsockopt to sockptr_t Date: Thu, 23 Jul 2020 08:08:56 +0200 Message-Id: <20200723060908.50081-15-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5A63740CB4 X-Rspamd-UID: b85855 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/linux/mroute.h | 5 +++-- net/ipv4/ip_sockglue.c | 3 ++- net/ipv4/ipmr.c | 14 +++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/linux/mroute.h b/include/linux/mroute.h index 9a36fad9e068f6..6cbbfe94348cee 100644 --- a/include/linux/mroute.h +++ b/include/linux/mroute.h @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef CONFIG_IP_MROUTE static inline int ip_mroute_opt(int opt) @@ -15,7 +16,7 @@ static inline int ip_mroute_opt(int opt) return opt >= MRT_BASE && opt <= MRT_MAX; } -int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); +int ip_mroute_setsockopt(struct sock *, int, sockptr_t, unsigned int); int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); @@ -23,7 +24,7 @@ int ip_mr_init(void); bool ipmr_rule_default(const struct fib_rule *rule); #else static inline int ip_mroute_setsockopt(struct sock *sock, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { return -ENOPROTOOPT; } diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 36f746e01741f6..ac495b0cff8ffb 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -925,7 +925,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, if (optname == IP_ROUTER_ALERT) return ip_ra_control(sk, val ? 1 : 0, NULL); if (ip_mroute_opt(optname)) - return ip_mroute_setsockopt(sk, optname, optval, optlen); + return ip_mroute_setsockopt(sk, optname, USER_SOCKPTR(optval), + optlen); err = 0; if (needs_rtnl) diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 678639c01e4882..cdf3a40f9ff5fc 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -1341,7 +1341,7 @@ static void mrtsock_destruct(struct sock *sk) * MOSPF/PIM router set up we can clean this up. */ -int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, +int ip_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen) { struct net *net = sock_net(sk); @@ -1413,7 +1413,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (copy_from_user(&vif, optval, sizeof(vif))) { + if (copy_from_sockptr(&vif, optval, sizeof(vif))) { ret = -EFAULT; break; } @@ -1441,7 +1441,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (copy_from_user(&mfc, optval, sizeof(mfc))) { + if (copy_from_sockptr(&val, optval, sizeof(val))) { ret = -EFAULT; break; } @@ -1459,7 +1459,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (get_user(val, (int __user *)optval)) { + if (copy_from_sockptr(&val, optval, sizeof(val))) { ret = -EFAULT; break; } @@ -1471,7 +1471,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (get_user(val, (int __user *)optval)) { + if (copy_from_sockptr(&val, optval, sizeof(val))) { ret = -EFAULT; break; } @@ -1486,7 +1486,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (get_user(val, (int __user *)optval)) { + if (copy_from_sockptr(&val, optval, sizeof(val))) { ret = -EFAULT; break; } @@ -1508,7 +1508,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ret = -EINVAL; break; } - if (get_user(uval, (u32 __user *)optval)) { + if (copy_from_sockptr(&uval, optval, sizeof(uval))) { ret = -EFAULT; break; } -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yMJBBuwpGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:10:52 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id EKIMBewpGV9l0gEA0J78UA (envelope-from ); Thu, 23 Jul 2020 08:10:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9A5E040873; Thu, 23 Jul 2020 08:10:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727886AbgGWGKD (ORCPT + 1 other); Thu, 23 Jul 2020 02:10:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727871AbgGWGKA (ORCPT ); Thu, 23 Jul 2020 02:10:00 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA58CC0619DC; Wed, 22 Jul 2020 23:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=WZEyzaS1ykzyi+yQ2LS2wMvQkwL8k8wAtqvtWngMf9k=; b=GkQOrco1ZkuQcjMqhyS87SJRGD de3B5cw7G5yO9PMtzI5w0X5s2yopJqUiVbmSr+As98wWMXn6Xl8y79CmwAlaI3j3ebpY9UAteT4Cn 4frKKigvk1Di9ljBzfXFKftGwds+aPPL5GLXVJjbCp6Lfwgns5RMwKcigxjHrK7cICgV+R/NKR37U SMOd4Y2ouS0ew7sS3pWavsl7KIbbei8X3CRKa1fmzw0vOVSoAqB/W9Ie3NBqoKgOKk97nUpIMcDP1 iQ+w1wBnm6LrsYc5mEgaq6c5MgkmC+YhQvxGnziaBnG3fCFxlBnwCMxWkRXbiG0+qq3YlYZUO7b8q DOf9lBbQ==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQN-0003qJ-36; Thu, 23 Jul 2020 06:09:47 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 26/26] net: optimize the sockptr_t for unified kernel/user address spaces Date: Thu, 23 Jul 2020 08:09:08 +0200 Message-Id: <20200723060908.50081-27-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9A5E040873 X-Rspamd-UID: 5df472 For architectures like x86 and arm64 we don't need the separate bit to indicate that a pointer is a kernel pointer as the address spaces are unified. That way the sockptr_t can be reduced to a union of two pointers, which leads to nicer calling conventions. The only caveat is that we need to check that users don't pass in kernel address and thus gain access to kernel memory. Thus the USER_SOCKPTR helper is replaced with a init_user_sockptr function that does this check and returns an error if it fails. Signed-off-by: Christoph Hellwig --- include/linux/sockptr.h | 32 ++++++++++++++++++++++++++++++-- net/ipv4/bpfilter/sockopt.c | 14 ++++++++------ net/socket.c | 6 +++++- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h index 700856e13ea0c4..7d5cdb2b30b5f0 100644 --- a/include/linux/sockptr.h +++ b/include/linux/sockptr.h @@ -8,9 +8,34 @@ #ifndef _LINUX_SOCKPTR_H #define _LINUX_SOCKPTR_H +#include #include #include +#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE +typedef union { + void *kernel; + void __user *user; +} sockptr_t; + +static inline bool sockptr_is_kernel(sockptr_t sockptr) +{ + return (unsigned long)sockptr.kernel >= TASK_SIZE; +} + +static inline sockptr_t KERNEL_SOCKPTR(void *p) +{ + return (sockptr_t) { .kernel = p }; +} + +static inline int __must_check init_user_sockptr(sockptr_t *sp, void __user *p) +{ + if ((unsigned long)p >= TASK_SIZE) + return -EFAULT; + sp->user = p; + return 0; +} +#else /* CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE */ typedef struct { union { void *kernel; @@ -29,10 +54,13 @@ static inline sockptr_t KERNEL_SOCKPTR(void *p) return (sockptr_t) { .kernel = p, .is_kernel = true }; } -static inline sockptr_t USER_SOCKPTR(void __user *p) +static inline int __must_check init_user_sockptr(sockptr_t *sp, void __user *p) { - return (sockptr_t) { .user = p }; + sp->user = p; + sp->is_kernel = false; + return 0; } +#endif /* CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE */ static inline bool sockptr_is_null(sockptr_t sockptr) { diff --git a/net/ipv4/bpfilter/sockopt.c b/net/ipv4/bpfilter/sockopt.c index 1b34cb9a7708ec..94f18d2352d007 100644 --- a/net/ipv4/bpfilter/sockopt.c +++ b/net/ipv4/bpfilter/sockopt.c @@ -57,16 +57,18 @@ int bpfilter_ip_set_sockopt(struct sock *sk, int optname, sockptr_t optval, return bpfilter_mbox_request(sk, optname, optval, optlen, true); } -int bpfilter_ip_get_sockopt(struct sock *sk, int optname, char __user *optval, - int __user *optlen) +int bpfilter_ip_get_sockopt(struct sock *sk, int optname, + char __user *user_optval, int __user *optlen) { - int len; + sockptr_t optval; + int err, len; if (get_user(len, optlen)) return -EFAULT; - - return bpfilter_mbox_request(sk, optname, USER_SOCKPTR(optval), len, - false); + err = init_user_sockptr(&optval, user_optval); + if (err) + return err; + return bpfilter_mbox_request(sk, optname, optval, len, false); } static int __init bpfilter_sockopt_init(void) diff --git a/net/socket.c b/net/socket.c index e44b8ac47f6f46..94ca4547cd7c53 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2097,7 +2097,7 @@ static bool sock_use_custom_sol_socket(const struct socket *sock) int __sys_setsockopt(int fd, int level, int optname, char __user *user_optval, int optlen) { - sockptr_t optval = USER_SOCKPTR(user_optval); + sockptr_t optval; char *kernel_optval = NULL; int err, fput_needed; struct socket *sock; @@ -2105,6 +2105,10 @@ int __sys_setsockopt(int fd, int level, int optname, char __user *user_optval, if (optlen < 0) return -EINVAL; + err = init_user_sockptr(&optval, user_optval); + if (err) + return err; + sock = sockfd_lookup_light(fd, &err, &fput_needed); if (!sock) return err; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YNxbDaMqGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:13:55 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wK9XC6MqGV9skgEAlScrYA (envelope-from ); Thu, 23 Jul 2020 08:13:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E156040CB7; Thu, 23 Jul 2020 08:13:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726887AbgGWGLy (ORCPT + 1 other); Thu, 23 Jul 2020 02:11:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbgGWGJk (ORCPT ); Thu, 23 Jul 2020 02:09:40 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EED8CC0619E3; Wed, 22 Jul 2020 23:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=FYcs44yoYK35f4AWKo/oBKg4WT6Lxy2mEQ4X9UWOEVM=; b=sGtRnqYdkZcPfYZRzM5+T6BC7g mhzEiZfizA260w/TsQecExreOl8sSzsN1E3mIXeoxHZU36ivBxA2nf5wopiR6Xmx/cQvYW2P/ynSC Xe1nrgJEf8JieAdBjc+O1SmiuDErWv514IwyHESk6utAUAijDnTteN+yeaXikk8ne4xYjJ8zHfG6u opDvToneN0P5tYC+PE7YvJfTgEyM3HlKL9UuVCORhwsrhnbMPetCBFN6bdXX0rq5XUUW7YFejw1P+ xHdieh/2tilcdHvGOXeaSMCYhuDDkM89QNbs529lpilLHSQLeMBqu6mV+cHiTQTFRT5zNKUXz2iEt SkT72xJg==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQ3-0003ll-36; Thu, 23 Jul 2020 06:09:27 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 13/26] bpfilter: switch bpfilter_ip_set_sockopt to sockptr_t Date: Thu, 23 Jul 2020 08:08:55 +0200 Message-Id: <20200723060908.50081-14-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: E156040CB7 X-Rspamd-UID: 67b712 This is mostly to prepare for cleaning up the callers, as bpfilter by design can't handle kernel pointers. Signed-off-by: Christoph Hellwig --- include/linux/bpfilter.h | 6 +++--- net/bpfilter/bpfilter_kern.c | 6 +++--- net/ipv4/bpfilter/sockopt.c | 8 ++++---- net/ipv4/ip_sockglue.c | 3 ++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/linux/bpfilter.h b/include/linux/bpfilter.h index 9b114c718a7617..2ae3c8e1d83c43 100644 --- a/include/linux/bpfilter.h +++ b/include/linux/bpfilter.h @@ -4,9 +4,10 @@ #include #include +#include struct sock; -int bpfilter_ip_set_sockopt(struct sock *sk, int optname, char __user *optval, +int bpfilter_ip_set_sockopt(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen); int bpfilter_ip_get_sockopt(struct sock *sk, int optname, char __user *optval, int __user *optlen); @@ -16,8 +17,7 @@ struct bpfilter_umh_ops { struct umd_info info; /* since ip_getsockopt() can run in parallel, serialize access to umh */ struct mutex lock; - int (*sockopt)(struct sock *sk, int optname, - char __user *optval, + int (*sockopt)(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen, bool is_set); int (*start)(void); }; diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c index 00540457e5f4d3..f580c3344cb3ac 100644 --- a/net/bpfilter/bpfilter_kern.c +++ b/net/bpfilter/bpfilter_kern.c @@ -60,17 +60,17 @@ static int bpfilter_send_req(struct mbox_request *req) } static int bpfilter_process_sockopt(struct sock *sk, int optname, - char __user *optval, unsigned int optlen, + sockptr_t optval, unsigned int optlen, bool is_set) { struct mbox_request req = { .is_set = is_set, .pid = current->pid, .cmd = optname, - .addr = (uintptr_t)optval, + .addr = (uintptr_t)optval.user, .len = optlen, }; - if (uaccess_kernel()) { + if (uaccess_kernel() || sockptr_is_kernel(optval)) { pr_err("kernel access not supported\n"); return -EFAULT; } diff --git a/net/ipv4/bpfilter/sockopt.c b/net/ipv4/bpfilter/sockopt.c index 9063c6767d3410..1b34cb9a7708ec 100644 --- a/net/ipv4/bpfilter/sockopt.c +++ b/net/ipv4/bpfilter/sockopt.c @@ -21,8 +21,7 @@ void bpfilter_umh_cleanup(struct umd_info *info) } EXPORT_SYMBOL_GPL(bpfilter_umh_cleanup); -static int bpfilter_mbox_request(struct sock *sk, int optname, - char __user *optval, +static int bpfilter_mbox_request(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen, bool is_set) { int err; @@ -52,7 +51,7 @@ static int bpfilter_mbox_request(struct sock *sk, int optname, return err; } -int bpfilter_ip_set_sockopt(struct sock *sk, int optname, char __user *optval, +int bpfilter_ip_set_sockopt(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen) { return bpfilter_mbox_request(sk, optname, optval, optlen, true); @@ -66,7 +65,8 @@ int bpfilter_ip_get_sockopt(struct sock *sk, int optname, char __user *optval, if (get_user(len, optlen)) return -EFAULT; - return bpfilter_mbox_request(sk, optname, optval, len, false); + return bpfilter_mbox_request(sk, optname, USER_SOCKPTR(optval), len, + false); } static int __init bpfilter_sockopt_init(void) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 42befbf12846c0..36f746e01741f6 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1414,7 +1414,8 @@ int ip_setsockopt(struct sock *sk, int level, #if IS_ENABLED(CONFIG_BPFILTER_UMH) if (optname >= BPFILTER_IPT_SO_SET_REPLACE && optname < BPFILTER_IPT_SET_MAX) - err = bpfilter_ip_set_sockopt(sk, optname, optval, optlen); + err = bpfilter_ip_set_sockopt(sk, optname, USER_SOCKPTR(optval), + optlen); #endif #ifdef CONFIG_NETFILTER /* we need to exclude all possible ENOPROTOOPTs except default case */ -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4GHhIrsqGV80bgEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:14:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oKSzILsqGV/3rwAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 08:14:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8DA0840872; Thu, 23 Jul 2020 08:14:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727851AbgGWGML (ORCPT + 1 other); Thu, 23 Jul 2020 02:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgGWGJi (ORCPT ); Thu, 23 Jul 2020 02:09:38 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7AC6C0619DC; Wed, 22 Jul 2020 23:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=j0L+Qk7oKcxnlURXcCS3zaGErKnPf8jGdSz60eAGoas=; b=lN7eNWaZOu87atnMUbHzJWJqYx 9VTfl4XKyJyRq2G2wIu5vUI1c2L12GBaNkg5vkoMmwImwuBROayVj9IqpKq9w5zKGwrB0eZXo5Ab6 S2lA51FcN9YpI3h0t9BU0w5tHX+bPhXHIzRD9E1b1IyHd93urFmI5TG1OgKJB+jlMZ8u2bj4EO6wE 3jDO3ESfOheqx/FWCkGzRua78BfYztAyCTvWSY558wY6SM8z3AX7s7E1LI72WTakoSjplNHYPp1tV s+sKGiJuDkhC3K2JqnMU5vyfM5BlbqICGEWXhYIp4QfJT6DKNN1YdPUdrHPCRLzf7Wz6t2huOZ11H aa4l/SMQ==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQ1-0003lc-PN; Thu, 23 Jul 2020 06:09:26 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 12/26] netfilter: switch nf_setsockopt to sockptr_t Date: Thu, 23 Jul 2020 08:08:54 +0200 Message-Id: <20200723060908.50081-13-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8DA0840872 X-Rspamd-UID: 3ddb37 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/linux/netfilter.h | 6 ++++-- net/bridge/netfilter/ebtables.c | 37 +++++++++++++++------------------ net/decnet/af_decnet.c | 3 ++- net/ipv4/ip_sockglue.c | 3 ++- net/ipv4/netfilter/arp_tables.c | 28 ++++++++++++------------- net/ipv4/netfilter/ip_tables.c | 24 ++++++++++----------- net/ipv6/ipv6_sockglue.c | 3 ++- net/ipv6/netfilter/ip6_tables.c | 24 ++++++++++----------- net/netfilter/ipvs/ip_vs_ctl.c | 4 ++-- net/netfilter/nf_sockopt.c | 2 +- 10 files changed, 68 insertions(+), 66 deletions(-) diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index 711b4d4486f042..0101747de54936 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h @@ -13,6 +13,7 @@ #include #include #include +#include #include static inline int NF_DROP_GETERR(int verdict) @@ -163,7 +164,8 @@ struct nf_sockopt_ops { /* Non-inclusive ranges: use 0/0/NULL to never get called. */ int set_optmin; int set_optmax; - int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len); + int (*set)(struct sock *sk, int optval, sockptr_t arg, + unsigned int len); int get_optmin; int get_optmax; int (*get)(struct sock *sk, int optval, void __user *user, int *len); @@ -338,7 +340,7 @@ NF_HOOK_LIST(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk, } /* Call setsockopt() */ -int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt, +int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, sockptr_t opt, unsigned int len); int nf_getsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt, int *len); diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 12f8929667bf43..d35173e803d3fe 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1063,14 +1063,13 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl, } /* replace the table */ -static int do_replace(struct net *net, const void __user *user, - unsigned int len) +static int do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret, countersize; struct ebt_table_info *newinfo; struct ebt_replace tmp; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; if (len != sizeof(tmp) + tmp.entries_size) @@ -1286,12 +1285,11 @@ static int do_update_counters(struct net *net, const char *name, return ret; } -static int update_counters(struct net *net, const void __user *user, - unsigned int len) +static int update_counters(struct net *net, sockptr_t arg, unsigned int len) { struct ebt_replace hlp; - if (copy_from_user(&hlp, user, sizeof(hlp))) + if (copy_from_sockptr(&hlp, arg, sizeof(hlp))) return -EFAULT; if (len != sizeof(hlp) + hlp.num_counters * sizeof(struct ebt_counter)) @@ -2079,7 +2077,7 @@ static int compat_copy_entries(unsigned char *data, unsigned int size_user, static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl, - void __user *user, unsigned int len) + sockptr_t arg, unsigned int len) { struct compat_ebt_replace tmp; int i; @@ -2087,7 +2085,7 @@ static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl, if (len < sizeof(tmp)) return -EINVAL; - if (copy_from_user(&tmp, user, sizeof(tmp))) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp))) return -EFAULT; if (len != sizeof(tmp) + tmp.entries_size) @@ -2114,8 +2112,7 @@ static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl, return 0; } -static int compat_do_replace(struct net *net, void __user *user, - unsigned int len) +static int compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret, i, countersize, size64; struct ebt_table_info *newinfo; @@ -2123,10 +2120,10 @@ static int compat_do_replace(struct net *net, void __user *user, struct ebt_entries_buf_state state; void *entries_tmp; - ret = compat_copy_ebt_replace_from_user(&tmp, user, len); + ret = compat_copy_ebt_replace_from_user(&tmp, arg, len); if (ret) { /* try real handler in case userland supplied needed padding */ - if (ret == -EINVAL && do_replace(net, user, len) == 0) + if (ret == -EINVAL && do_replace(net, arg, len) == 0) ret = 0; return ret; } @@ -2217,17 +2214,17 @@ static int compat_do_replace(struct net *net, void __user *user, goto free_entries; } -static int compat_update_counters(struct net *net, void __user *user, +static int compat_update_counters(struct net *net, sockptr_t arg, unsigned int len) { struct compat_ebt_replace hlp; - if (copy_from_user(&hlp, user, sizeof(hlp))) + if (copy_from_sockptr(&hlp, arg, sizeof(hlp))) return -EFAULT; /* try real handler in case userland supplied needed padding */ if (len != sizeof(hlp) + hlp.num_counters * sizeof(struct ebt_counter)) - return update_counters(net, user, len); + return update_counters(net, arg, len); return do_update_counters(net, hlp.name, compat_ptr(hlp.counters), hlp.num_counters, len); @@ -2368,7 +2365,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) return ret; } -static int do_ebt_set_ctl(struct sock *sk, int cmd, void __user *user, +static int do_ebt_set_ctl(struct sock *sk, int cmd, sockptr_t arg, unsigned int len) { struct net *net = sock_net(sk); @@ -2381,18 +2378,18 @@ static int do_ebt_set_ctl(struct sock *sk, int cmd, void __user *user, case EBT_SO_SET_ENTRIES: #ifdef CONFIG_COMPAT if (in_compat_syscall()) - ret = compat_do_replace(net, user, len); + ret = compat_do_replace(net, arg, len); else #endif - ret = do_replace(net, user, len); + ret = do_replace(net, arg, len); break; case EBT_SO_SET_COUNTERS: #ifdef CONFIG_COMPAT if (in_compat_syscall()) - ret = compat_update_counters(net, user, len); + ret = compat_update_counters(net, arg, len); else #endif - ret = update_counters(net, user, len); + ret = update_counters(net, arg, len); break; default: ret = -EINVAL; diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index 7d7ae2dd69b8ad..7d51ab608fb3f1 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c @@ -1332,7 +1332,8 @@ static int dn_setsockopt(struct socket *sock, int level, int optname, char __use /* we need to exclude all possible ENOPROTOOPTs except default case */ if (err == -ENOPROTOOPT && optname != DSO_LINKINFO && optname != DSO_STREAM && optname != DSO_SEQPACKET) - err = nf_setsockopt(sk, PF_DECnet, optname, optval, optlen); + err = nf_setsockopt(sk, PF_DECnet, optname, + USER_SOCKPTR(optval), optlen); #endif return err; diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index da933f99b5d517..42befbf12846c0 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1422,7 +1422,8 @@ int ip_setsockopt(struct sock *sk, int level, optname != IP_IPSEC_POLICY && optname != IP_XFRM_POLICY && !ip_mroute_opt(optname)) - err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); + err = nf_setsockopt(sk, PF_INET, optname, USER_SOCKPTR(optval), + optlen); #endif return err; } diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 6d24b686c7f00a..f5b26ef1782001 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0-only + /* * Packet matching code for ARP packets. * @@ -947,8 +947,7 @@ static int __do_replace(struct net *net, const char *name, return ret; } -static int do_replace(struct net *net, const void __user *user, - unsigned int len) +static int do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct arpt_replace tmp; @@ -956,7 +955,7 @@ static int do_replace(struct net *net, const void __user *user, void *loc_cpu_entry; struct arpt_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -972,8 +971,8 @@ static int do_replace(struct net *net, const void __user *user, return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), - tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1244,8 +1243,7 @@ static int translate_compat_table(struct net *net, return ret; } -static int compat_do_replace(struct net *net, void __user *user, - unsigned int len) +static int compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct compat_arpt_replace tmp; @@ -1253,7 +1251,7 @@ static int compat_do_replace(struct net *net, void __user *user, void *loc_cpu_entry; struct arpt_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -1269,7 +1267,8 @@ static int compat_do_replace(struct net *net, void __user *user, return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1401,7 +1400,8 @@ static int compat_get_entries(struct net *net, } #endif -static int do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) +static int do_arpt_set_ctl(struct sock *sk, int cmd, sockptr_t arg, + unsigned int len) { int ret; @@ -1412,14 +1412,14 @@ static int do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned case ARPT_SO_SET_REPLACE: #ifdef CONFIG_COMPAT if (in_compat_syscall()) - ret = compat_do_replace(sock_net(sk), user, len); + ret = compat_do_replace(sock_net(sk), arg, len); else #endif - ret = do_replace(sock_net(sk), user, len); + ret = do_replace(sock_net(sk), arg, len); break; case ARPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); + ret = do_add_counters(sock_net(sk), arg, len); break; default: diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 4697d09c98dc3e..f2a9680303d8c0 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -1102,7 +1102,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks, } static int -do_replace(struct net *net, const void __user *user, unsigned int len) +do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct ipt_replace tmp; @@ -1110,7 +1110,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) void *loc_cpu_entry; struct ipt_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -1126,8 +1126,8 @@ do_replace(struct net *net, const void __user *user, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), - tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1484,7 +1484,7 @@ translate_compat_table(struct net *net, } static int -compat_do_replace(struct net *net, void __user *user, unsigned int len) +compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct compat_ipt_replace tmp; @@ -1492,7 +1492,7 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) void *loc_cpu_entry; struct ipt_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -1508,8 +1508,8 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), - tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1610,7 +1610,7 @@ compat_get_entries(struct net *net, struct compat_ipt_get_entries __user *uptr, #endif static int -do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) +do_ipt_set_ctl(struct sock *sk, int cmd, sockptr_t arg, unsigned int len) { int ret; @@ -1621,14 +1621,14 @@ do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) case IPT_SO_SET_REPLACE: #ifdef CONFIG_COMPAT if (in_compat_syscall()) - ret = compat_do_replace(sock_net(sk), user, len); + ret = compat_do_replace(sock_net(sk), arg, len); else #endif - ret = do_replace(sock_net(sk), user, len); + ret = do_replace(sock_net(sk), arg, len); break; case IPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); + ret = do_add_counters(sock_net(sk), arg, len); break; default: diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 56a74707c61741..85892b35cff7b3 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -996,7 +996,8 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, /* we need to exclude all possible ENOPROTOOPTs except default case */ if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY && optname != IPV6_XFRM_POLICY) - err = nf_setsockopt(sk, PF_INET6, optname, optval, optlen); + err = nf_setsockopt(sk, PF_INET6, optname, USER_SOCKPTR(optval), + optlen); #endif return err; } diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index a787aba30e2db7..1d52957a413f4a 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -1119,7 +1119,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks, } static int -do_replace(struct net *net, const void __user *user, unsigned int len) +do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct ip6t_replace tmp; @@ -1127,7 +1127,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) void *loc_cpu_entry; struct ip6t_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -1143,8 +1143,8 @@ do_replace(struct net *net, const void __user *user, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), - tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1493,7 +1493,7 @@ translate_compat_table(struct net *net, } static int -compat_do_replace(struct net *net, void __user *user, unsigned int len) +compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) { int ret; struct compat_ip6t_replace tmp; @@ -1501,7 +1501,7 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) void *loc_cpu_entry; struct ip6t_entry *iter; - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ @@ -1517,8 +1517,8 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), - tmp.size) != 0) { + sockptr_advance(arg, sizeof(tmp)); + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1619,7 +1619,7 @@ compat_get_entries(struct net *net, struct compat_ip6t_get_entries __user *uptr, #endif static int -do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) +do_ip6t_set_ctl(struct sock *sk, int cmd, sockptr_t arg, unsigned int len) { int ret; @@ -1630,14 +1630,14 @@ do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) case IP6T_SO_SET_REPLACE: #ifdef CONFIG_COMPAT if (in_compat_syscall()) - ret = compat_do_replace(sock_net(sk), user, len); + ret = compat_do_replace(sock_net(sk), arg, len); else #endif - ret = do_replace(sock_net(sk), user, len); + ret = do_replace(sock_net(sk), arg, len); break; case IP6T_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); + ret = do_add_counters(sock_net(sk), arg, len); break; default: diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index 4af83f466dfc2c..bcac316addabe8 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -2434,7 +2434,7 @@ static void ip_vs_copy_udest_compat(struct ip_vs_dest_user_kern *udest, } static int -do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) +do_ip_vs_set_ctl(struct sock *sk, int cmd, sockptr_t ptr, unsigned int len) { struct net *net = sock_net(sk); int ret; @@ -2458,7 +2458,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) return -EINVAL; } - if (copy_from_user(arg, user, len) != 0) + if (copy_from_sockptr(arg, ptr, len) != 0) return -EFAULT; /* Handle daemons since they have another lock */ diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c index 90469b1f628a8e..34afcd03b6f60e 100644 --- a/net/netfilter/nf_sockopt.c +++ b/net/netfilter/nf_sockopt.c @@ -89,7 +89,7 @@ static struct nf_sockopt_ops *nf_sockopt_find(struct sock *sk, u_int8_t pf, return ops; } -int nf_setsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt, +int nf_setsockopt(struct sock *sk, u_int8_t pf, int val, sockptr_t opt, unsigned int len) { struct nf_sockopt_ops *ops; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IFMlEsIqGV99mAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:14:26 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UPKnEMIqGV9KBAAADc0bRg (envelope-from ); Thu, 23 Jul 2020 08:14:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C866A4000F; Thu, 23 Jul 2020 08:14:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728223AbgGWGML (ORCPT + 1 other); Thu, 23 Jul 2020 02:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726852AbgGWGJi (ORCPT ); Thu, 23 Jul 2020 02:09:38 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDAA2C0619E2; Wed, 22 Jul 2020 23:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=BXIWlOxxLGAwEkybRtLTw7LIxC9f35ukkZ5P3mQ+S3I=; b=kkjnzCasd1GS1SWzGhJegyrZpR +VfalNFJE7E4SdMPRTagIx5hwuzbGFMNreic5aeOahY3bOhrHbE3q5LS+A+qxs4f482fiuoOgYwF1 Gbudn5vnqxjNqormxDO5zPHCQ/dy65Wu5ZGcvd9mornUSJOffIaX1pv5bl6+2uBRhQetAt+HAWVLk xHUaxwGq/hjfKCX8JQ1iW1zuAWbBdzg93ympxDOGXbyS4pchcbLCP/HHFBcTpZ6XDaGKVXHPFQuO+ Za1hOCwgkj0JI2o7Zt7jncDIfQeDQub97JNn4HlYFeqQIjdCCVJocZuJYofsMQ3aUZ2+eYlShYGfR 6Xs24t2w==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQ0-0003lO-FO; Thu, 23 Jul 2020 06:09:24 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 11/26] netfilter: switch xt_copy_counters to sockptr_t Date: Thu, 23 Jul 2020 08:08:53 +0200 Message-Id: <20200723060908.50081-12-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 20 X-Rspamd-Score: 3.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: C866A4000F X-Rspamd-UID: b5ef1d Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/linux/netfilter/x_tables.h | 4 ++-- net/ipv4/netfilter/arp_tables.c | 7 +++---- net/ipv4/netfilter/ip_tables.c | 7 +++---- net/ipv6/netfilter/ip6_tables.c | 6 +++--- net/netfilter/x_tables.c | 20 ++++++++++---------- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index b8b943ee7b8b66..5deb099d156dcb 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h @@ -301,8 +301,8 @@ int xt_target_to_user(const struct xt_entry_target *t, int xt_data_to_user(void __user *dst, const void *src, int usersize, int size, int aligned_size); -void *xt_copy_counters_from_user(const void __user *user, unsigned int len, - struct xt_counters_info *info); +void *xt_copy_counters(sockptr_t arg, unsigned int len, + struct xt_counters_info *info); struct xt_counters *xt_counters_alloc(unsigned int counters); struct xt_table *xt_register_table(struct net *net, diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 2c8a4dad39d748..6d24b686c7f00a 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -996,8 +996,7 @@ static int do_replace(struct net *net, const void __user *user, return ret; } -static int do_add_counters(struct net *net, const void __user *user, - unsigned int len) +static int do_add_counters(struct net *net, sockptr_t arg, unsigned int len) { unsigned int i; struct xt_counters_info tmp; @@ -1008,7 +1007,7 @@ static int do_add_counters(struct net *net, const void __user *user, struct arpt_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp); + paddc = xt_copy_counters(arg, len, &tmp); if (IS_ERR(paddc)) return PTR_ERR(paddc); @@ -1420,7 +1419,7 @@ static int do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned break; case ARPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len); + ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); break; default: diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 161901dd1cae7f..4697d09c98dc3e 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -1151,8 +1151,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) } static int -do_add_counters(struct net *net, const void __user *user, - unsigned int len) +do_add_counters(struct net *net, sockptr_t arg, unsigned int len) { unsigned int i; struct xt_counters_info tmp; @@ -1163,7 +1162,7 @@ do_add_counters(struct net *net, const void __user *user, struct ipt_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp); + paddc = xt_copy_counters(arg, len, &tmp); if (IS_ERR(paddc)) return PTR_ERR(paddc); @@ -1629,7 +1628,7 @@ do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) break; case IPT_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len); + ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); break; default: diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index fd1f8f93123188..a787aba30e2db7 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -1168,7 +1168,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) } static int -do_add_counters(struct net *net, const void __user *user, unsigned int len) +do_add_counters(struct net *net, sockptr_t arg, unsigned int len) { unsigned int i; struct xt_counters_info tmp; @@ -1179,7 +1179,7 @@ do_add_counters(struct net *net, const void __user *user, unsigned int len) struct ip6t_entry *iter; unsigned int addend; - paddc = xt_copy_counters_from_user(user, len, &tmp); + paddc = xt_copy_counters(arg, len, &tmp); if (IS_ERR(paddc)) return PTR_ERR(paddc); t = xt_find_table_lock(net, AF_INET6, tmp.name); @@ -1637,7 +1637,7 @@ do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) break; case IP6T_SO_SET_ADD_COUNTERS: - ret = do_add_counters(sock_net(sk), user, len); + ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); break; default: diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 32bab45af7e415..b97eb4b538fd4e 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1028,9 +1028,9 @@ int xt_check_target(struct xt_tgchk_param *par, EXPORT_SYMBOL_GPL(xt_check_target); /** - * xt_copy_counters_from_user - copy counters and metadata from userspace + * xt_copy_counters - copy counters and metadata from a sockptr_t * - * @user: src pointer to userspace memory + * @arg: src sockptr * @len: alleged size of userspace memory * @info: where to store the xt_counters_info metadata * @@ -1047,8 +1047,8 @@ EXPORT_SYMBOL_GPL(xt_check_target); * Return: returns pointer that caller has to test via IS_ERR(). * If IS_ERR is false, caller has to vfree the pointer. */ -void *xt_copy_counters_from_user(const void __user *user, unsigned int len, - struct xt_counters_info *info) +void *xt_copy_counters(sockptr_t arg, unsigned int len, + struct xt_counters_info *info) { void *mem; u64 size; @@ -1062,12 +1062,12 @@ void *xt_copy_counters_from_user(const void __user *user, unsigned int len, return ERR_PTR(-EINVAL); len -= sizeof(compat_tmp); - if (copy_from_user(&compat_tmp, user, sizeof(compat_tmp)) != 0) + if (copy_from_sockptr(&compat_tmp, arg, sizeof(compat_tmp)) != 0) return ERR_PTR(-EFAULT); memcpy(info->name, compat_tmp.name, sizeof(info->name) - 1); info->num_counters = compat_tmp.num_counters; - user += sizeof(compat_tmp); + sockptr_advance(arg, sizeof(compat_tmp)); } else #endif { @@ -1075,10 +1075,10 @@ void *xt_copy_counters_from_user(const void __user *user, unsigned int len, return ERR_PTR(-EINVAL); len -= sizeof(*info); - if (copy_from_user(info, user, sizeof(*info)) != 0) + if (copy_from_sockptr(info, arg, sizeof(*info)) != 0) return ERR_PTR(-EFAULT); - user += sizeof(*info); + sockptr_advance(arg, sizeof(*info)); } info->name[sizeof(info->name) - 1] = '\0'; @@ -1092,13 +1092,13 @@ void *xt_copy_counters_from_user(const void __user *user, unsigned int len, if (!mem) return ERR_PTR(-ENOMEM); - if (copy_from_user(mem, user, len) == 0) + if (copy_from_sockptr(mem, arg, len) == 0) return mem; vfree(mem); return ERR_PTR(-EFAULT); } -EXPORT_SYMBOL_GPL(xt_copy_counters_from_user); +EXPORT_SYMBOL_GPL(xt_copy_counters); #ifdef CONFIG_COMPAT int xt_compat_target_offset(const struct xt_target *target) -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kFzYOvEqGV/YgAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:15:13 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id EH1mOfEqGV+U2AEA0J78UA (envelope-from ); Thu, 23 Jul 2020 08:15:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 98E1740F3D; Thu, 23 Jul 2020 08:15:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726791AbgGWGMo (ORCPT + 1 other); Thu, 23 Jul 2020 02:12:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726715AbgGWGJd (ORCPT ); Thu, 23 Jul 2020 02:09:33 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8741DC0619DC; Wed, 22 Jul 2020 23:09:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=VrJsDbKvFjfbSXAuB6qr8lwEWZVDG/rFKzbYqdXTQsw=; b=BP2oJ8tmQCVBRqYWPgYFfXA/Y8 +UEX3HDqU2bE68GKhF4gxLgUh3K90E6HXjo3xxAu8f+fTE1u6uOwoflRlGluSprC0/tDh5CECAmXR ws4kYNpIyKMNwer1y8FRw1cD5icaCR8dVtbqxbspNg1AiGDVRQVlBv+UUby3a2Y1aglZB+CXzSwEN iNRgmgjn4qlBww0328UUAjaiq4EUtqFlaPlQspwfU+5HMPLcPYZNClmMAu25fdwhdHRVemjN0VGSo 5YIKCegLfUy/7d148BCjp248Ceg9Vjn8wg07F2omLkNve4wrisyahYpjR+3kjpLRDforAv1Kuolp0 9zjpLCpg==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUPx-0003l6-Tv; Thu, 23 Jul 2020 06:09:22 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 09/26] net/xfrm: switch xfrm_user_policy to sockptr_t Date: Thu, 23 Jul 2020 08:08:51 +0200 Message-Id: <20200723060908.50081-10-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 98E1740F3D X-Rspamd-UID: b41c2c Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/net/xfrm.h | 8 +++++--- net/ipv4/ip_sockglue.c | 3 ++- net/ipv6/ipv6_sockglue.c | 3 ++- net/xfrm/xfrm_state.c | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index f9e1fda82ddfc0..5e81868b574a73 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -1609,10 +1610,11 @@ int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, void xfrm6_local_rxpmtu(struct sk_buff *skb, u32 mtu); int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); int xfrm6_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); -int xfrm_user_policy(struct sock *sk, int optname, - u8 __user *optval, int optlen); +int xfrm_user_policy(struct sock *sk, int optname, sockptr_t optval, + int optlen); #else -static inline int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen) +static inline int xfrm_user_policy(struct sock *sk, int optname, + sockptr_t optval, int optlen) { return -ENOPROTOOPT; } diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index a5ea02d7a183eb..da933f99b5d517 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1322,7 +1322,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, err = -EPERM; if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) break; - err = xfrm_user_policy(sk, optname, optval, optlen); + err = xfrm_user_policy(sk, optname, USER_SOCKPTR(optval), + optlen); break; case IP_TRANSPARENT: diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index add8f791229945..56a74707c61741 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -935,7 +935,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, retv = -EPERM; if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) break; - retv = xfrm_user_policy(sk, optname, optval, optlen); + retv = xfrm_user_policy(sk, optname, USER_SOCKPTR(optval), + optlen); break; case IPV6_ADDR_PREFERENCES: diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 8be2d926acc21d..69520ad3d83bfb 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -2264,7 +2264,7 @@ static bool km_is_alive(const struct km_event *c) return is_alive; } -int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen) +int xfrm_user_policy(struct sock *sk, int optname, sockptr_t optval, int optlen) { int err; u8 *data; @@ -2274,7 +2274,7 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen if (in_compat_syscall()) return -EOPNOTSUPP; - if (!optval && !optlen) { + if (sockptr_is_null(optval) && !optlen) { xfrm_sk_policy_insert(sk, XFRM_POLICY_IN, NULL); xfrm_sk_policy_insert(sk, XFRM_POLICY_OUT, NULL); __sk_dst_reset(sk); @@ -2284,7 +2284,7 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen if (optlen <= 0 || optlen > PAGE_SIZE) return -EMSGSIZE; - data = memdup_user(optval, optlen); + data = memdup_sockptr(optval, optlen); if (IS_ERR(data)) return PTR_ERR(data); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WFqFMfkqGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:15:21 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id GD5MMPkqGV/cpQAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 08:15:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9D91B40180; Thu, 23 Jul 2020 08:15:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726680AbgGWGJd (ORCPT + 1 other); Thu, 23 Jul 2020 02:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgGWGJb (ORCPT ); Thu, 23 Jul 2020 02:09:31 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFF00C0619E2; Wed, 22 Jul 2020 23:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=tMSRX19x4iZFav/RhfRomxQNPhw3MkRzM2UG4zJNYUs=; b=ZjRkbKsN32Y9td9wz3fQ2PPjcg tNWB2b1T7UhAxfZr9U5bMy8pRw41tA+BEuacHybHFtOtya84/t+vp9s4fVF0g64fIHo2cAfUni18L STKIAbJ+vR2wfiAkEB3Bx9u1lh4K1aKD28lXbDznVgv0IbGEm9oeUwmwmwB90s+bH3+0vjtCEYzIs L9uZxeSzuaPHmKq5fGMICl8C3Ivesl8yoyuBUgcrzCB1w5Xlr7UJwTmGQINzFPF2GhqbHAE6NOOqe jRg/utPjWC/MgowE0Ga66W6lNrRV1vFCriVpF7Tel/0HVKMC6xDMjjfnpYf/p9nuQBvUjarss4Xf6 wrY8TEmQ==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUPt-0003ka-LB; Thu, 23 Jul 2020 06:09:18 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 06/26] net: switch sock_setbindtodevice to sockptr_t Date: Thu, 23 Jul 2020 08:08:48 +0200 Message-Id: <20200723060908.50081-7-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9D91B40180 X-Rspamd-UID: 876c9b Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- net/core/sock.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index 71fc7e4ddd0648..5b55bc9397f282 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -609,8 +609,7 @@ int sock_bindtoindex(struct sock *sk, int ifindex, bool lock_sk) } EXPORT_SYMBOL(sock_bindtoindex); -static int sock_setbindtodevice(struct sock *sk, char __user *optval, - int optlen) +static int sock_setbindtodevice(struct sock *sk, sockptr_t optval, int optlen) { int ret = -ENOPROTOOPT; #ifdef CONFIG_NETDEVICES @@ -632,7 +631,7 @@ static int sock_setbindtodevice(struct sock *sk, char __user *optval, memset(devname, 0, sizeof(devname)); ret = -EFAULT; - if (copy_from_user(devname, optval, optlen)) + if (copy_from_sockptr(devname, optval, optlen)) goto out; index = 0; @@ -840,7 +839,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, */ if (optname == SO_BINDTODEVICE) - return sock_setbindtodevice(sk, optval, optlen); + return sock_setbindtodevice(sk, USER_SOCKPTR(optval), optlen); if (optlen < sizeof(int)) return -EINVAL; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GMsWARQrGV/YgAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:15:48 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 6FcTORMrGV9l0gEA0J78UA (envelope-from ); Thu, 23 Jul 2020 08:15:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 75B5E40873; Thu, 23 Jul 2020 08:15:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727922AbgGWGM6 (ORCPT + 1 other); Thu, 23 Jul 2020 02:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgGWGJc (ORCPT ); Thu, 23 Jul 2020 02:09:32 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73365C0619DC; Wed, 22 Jul 2020 23:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ZbaJkXWVN54EM1K0IjLK/oyuu3Tpcri68ikiwEZNL0s=; b=ozcJ0wsQEslO4La3bQUX6OU+Cz 8pczSeXCR7dPiFmrdbV6hqz1jToFTwdsQVD00rmxyGfc1KCpBtBRkume8dkG57UOd0Ixrnbi9rEBa VBF3IKgFtQl0BBXYBqvlSL++rXXwqPGmZe2ojYnDm02kKBmZBLkzf0PWpW2CCmB/iQfCPmRyINreB MajlSt0APNmOlRTW9/uRkWP9HG2HOu2csT5ThOww4L4lQ/3nvVYHVv/hn1uW+NzIx/WFp9kbGf40V DA3DSzN1ZjvDNPff8JGYhHf2LoiyAGpyjLft4I0kEjN5/fnjV0F5g1rFC+7bD/wj1S/l/zZEGuxSa VQUYh0Qw==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUPw-0003ku-Bn; Thu, 23 Jul 2020 06:09:20 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 08/26] net: switch sock_set_timeout to sockptr_t Date: Thu, 23 Jul 2020 08:08:50 +0200 Message-Id: <20200723060908.50081-9-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 75B5E40873 X-Rspamd-UID: a19ce0 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/net/sock.h | 3 ++- net/core/sock.c | 26 ++++++++++++-------------- net/mptcp/protocol.c | 6 ++++-- net/socket.c | 3 ++- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index 62e18fc8ac9f96..bfb2fe2fc36876 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -59,6 +59,7 @@ #include #include #include +#include #include #include @@ -1669,7 +1670,7 @@ void sock_pfree(struct sk_buff *skb); #endif int sock_setsockopt(struct socket *sock, int level, int op, - char __user *optval, unsigned int optlen); + sockptr_t optval, unsigned int optlen); int sock_getsockopt(struct socket *sock, int level, int op, char __user *optval, int __user *optlen); diff --git a/net/core/sock.c b/net/core/sock.c index 8b9eddaff868a5..1444d7d53ba2fd 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -826,7 +826,7 @@ EXPORT_SYMBOL(sock_set_rcvbuf); */ int sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock_txtime sk_txtime; struct sock *sk = sock->sk; @@ -840,12 +840,12 @@ int sock_setsockopt(struct socket *sock, int level, int optname, */ if (optname == SO_BINDTODEVICE) - return sock_setbindtodevice(sk, USER_SOCKPTR(optval), optlen); + return sock_setbindtodevice(sk, optval, optlen); if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; valbool = val ? 1 : 0; @@ -958,7 +958,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, ret = -EINVAL; /* 1003.1g */ break; } - if (copy_from_user(&ling, optval, sizeof(ling))) { + if (copy_from_sockptr(&ling, optval, sizeof(ling))) { ret = -EFAULT; break; } @@ -1052,21 +1052,20 @@ int sock_setsockopt(struct socket *sock, int level, int optname, case SO_RCVTIMEO_OLD: case SO_RCVTIMEO_NEW: - ret = sock_set_timeout(&sk->sk_rcvtimeo, USER_SOCKPTR(optval), + ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen, optname == SO_RCVTIMEO_OLD); break; case SO_SNDTIMEO_OLD: case SO_SNDTIMEO_NEW: - ret = sock_set_timeout(&sk->sk_sndtimeo, USER_SOCKPTR(optval), + ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen, optname == SO_SNDTIMEO_OLD); break; case SO_ATTACH_FILTER: { struct sock_fprog fprog; - ret = copy_bpf_fprog_from_user(&fprog, USER_SOCKPTR(optval), - optlen); + ret = copy_bpf_fprog_from_user(&fprog, optval, optlen); if (!ret) ret = sk_attach_filter(&fprog, sk); break; @@ -1077,7 +1076,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, u32 ufd; ret = -EFAULT; - if (copy_from_user(&ufd, optval, sizeof(ufd))) + if (copy_from_sockptr(&ufd, optval, sizeof(ufd))) break; ret = sk_attach_bpf(ufd, sk); @@ -1087,8 +1086,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, case SO_ATTACH_REUSEPORT_CBPF: { struct sock_fprog fprog; - ret = copy_bpf_fprog_from_user(&fprog, USER_SOCKPTR(optval), - optlen); + ret = copy_bpf_fprog_from_user(&fprog, optval, optlen); if (!ret) ret = sk_reuseport_attach_filter(&fprog, sk); break; @@ -1099,7 +1097,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, u32 ufd; ret = -EFAULT; - if (copy_from_user(&ufd, optval, sizeof(ufd))) + if (copy_from_sockptr(&ufd, optval, sizeof(ufd))) break; ret = sk_reuseport_attach_bpf(ufd, sk); @@ -1179,7 +1177,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, if (sizeof(ulval) != sizeof(val) && optlen >= sizeof(ulval) && - get_user(ulval, (unsigned long __user *)optval)) { + copy_from_sockptr(&ulval, optval, sizeof(ulval))) { ret = -EFAULT; break; } @@ -1222,7 +1220,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(struct sock_txtime)) { ret = -EINVAL; break; - } else if (copy_from_user(&sk_txtime, optval, + } else if (copy_from_sockptr(&sk_txtime, optval, sizeof(struct sock_txtime))) { ret = -EFAULT; break; diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index f0b0b503c2628d..27b6f250b87dfd 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1643,7 +1643,8 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, return -EINVAL; } - ret = sock_setsockopt(ssock, SOL_SOCKET, optname, optval, optlen); + ret = sock_setsockopt(ssock, SOL_SOCKET, optname, + USER_SOCKPTR(optval), optlen); if (ret == 0) { if (optname == SO_REUSEPORT) sk->sk_reuseport = ssock->sk->sk_reuseport; @@ -1654,7 +1655,8 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, return ret; } - return sock_setsockopt(sk->sk_socket, SOL_SOCKET, optname, optval, optlen); + return sock_setsockopt(sk->sk_socket, SOL_SOCKET, optname, + USER_SOCKPTR(optval), optlen); } static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, diff --git a/net/socket.c b/net/socket.c index 93846568c2fb7a..c97f83d879ae75 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2130,7 +2130,8 @@ int __sys_setsockopt(int fd, int level, int optname, char __user *optval, } if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) - err = sock_setsockopt(sock, level, optname, optval, optlen); + err = sock_setsockopt(sock, level, optname, + USER_SOCKPTR(optval), optlen); else if (unlikely(!sock->ops->setsockopt)) err = -EOPNOTSUPP; else -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +HWpARwrGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:15:56 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2BJ0ABwrGV81uwAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 08:15:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9007A40F3D; Thu, 23 Jul 2020 08:15:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727854AbgGWGM5 (ORCPT + 1 other); Thu, 23 Jul 2020 02:12:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726652AbgGWGJc (ORCPT ); Thu, 23 Jul 2020 02:09:32 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 798F8C0619E2; Wed, 22 Jul 2020 23:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=xqGJvoPJ0+pH4qYG06e/7bN83cyQPL98EGqqjHTTiVQ=; b=tp0Qjqxv0RF9S9VMvHxOQakmQ+ NHHCC0pZ4D54ej/cePwKmpeQERvhgixf2rr+yFCMAku4YwZ7qHeZ23zUko4Runxz4X2FA51oNK9RB G71rtpRMLN+TsNxoueQ+MRUu2h3xtmBHPMKP/izudC5N1oy/s4c0lP2BwaH2EI/Tr0TB9gDhdqJ6a rycFr/S96lGHvxszuLGeDv20/dHJLbjMO/W0HRsKz2fbUItwUz/GhoTeBU/3lzVe84kUEMznjTO9R ZoRl8WaL9OyZSPxjaiWAD5kw4pVGMaXBipOjPZoChto8wAEpQi6Fg9FEFIqXI5trxbLidsCIfPpe2 WB6TV97Q==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUPv-0003kl-1X; Thu, 23 Jul 2020 06:09:19 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 07/26] net: switch sock_set_timeout to sockptr_t Date: Thu, 23 Jul 2020 08:08:49 +0200 Message-Id: <20200723060908.50081-8-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9007A40F3D X-Rspamd-UID: 4d3811 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- net/core/sock.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index 5b55bc9397f282..8b9eddaff868a5 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -361,7 +361,8 @@ static int sock_get_timeout(long timeo, void *optval, bool old_timeval) return sizeof(tv); } -static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool old_timeval) +static int sock_set_timeout(long *timeo_p, sockptr_t optval, int optlen, + bool old_timeval) { struct __kernel_sock_timeval tv; @@ -371,7 +372,7 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool if (optlen < sizeof(tv32)) return -EINVAL; - if (copy_from_user(&tv32, optval, sizeof(tv32))) + if (copy_from_sockptr(&tv32, optval, sizeof(tv32))) return -EFAULT; tv.tv_sec = tv32.tv_sec; tv.tv_usec = tv32.tv_usec; @@ -380,14 +381,14 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool if (optlen < sizeof(old_tv)) return -EINVAL; - if (copy_from_user(&old_tv, optval, sizeof(old_tv))) + if (copy_from_sockptr(&old_tv, optval, sizeof(old_tv))) return -EFAULT; tv.tv_sec = old_tv.tv_sec; tv.tv_usec = old_tv.tv_usec; } else { if (optlen < sizeof(tv)) return -EINVAL; - if (copy_from_user(&tv, optval, sizeof(tv))) + if (copy_from_sockptr(&tv, optval, sizeof(tv))) return -EFAULT; } if (tv.tv_usec < 0 || tv.tv_usec >= USEC_PER_SEC) @@ -1051,12 +1052,14 @@ int sock_setsockopt(struct socket *sock, int level, int optname, case SO_RCVTIMEO_OLD: case SO_RCVTIMEO_NEW: - ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen, optname == SO_RCVTIMEO_OLD); + ret = sock_set_timeout(&sk->sk_rcvtimeo, USER_SOCKPTR(optval), + optlen, optname == SO_RCVTIMEO_OLD); break; case SO_SNDTIMEO_OLD: case SO_SNDTIMEO_NEW: - ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen, optname == SO_SNDTIMEO_OLD); + ret = sock_set_timeout(&sk->sk_sndtimeo, USER_SOCKPTR(optval), + optlen, optname == SO_SNDTIMEO_OLD); break; case SO_ATTACH_FILTER: { -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2G+JLiErGV99mAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:16:01 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id wNppLSErGV/F4QEA0J78UA (envelope-from ); Thu, 23 Jul 2020 08:16:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8C3AA40676; Thu, 23 Jul 2020 08:15:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727804AbgGWGM4 (ORCPT + 1 other); Thu, 23 Jul 2020 02:12:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbgGWGJc (ORCPT ); Thu, 23 Jul 2020 02:09:32 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84706C0619E3; Wed, 22 Jul 2020 23:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=F+BrwTbjEUImolj5beS1BIuUXc5PZLOrZP3HablW5rQ=; b=NzYZw+FjLfFD0JRnn0zvrsEGla OpCplG7VAlrQMRrrAptI8HlY36sdp/bQUwvI85NfsYGTWTrzqd0OtBgyHoxTz2+6W4uOK8qfoaK9G AabbZVEw0A3ckIbqpAejosSfpzclsHm09SqSs1MfIJjEQmvsARHc9VrCnCp93k6HJsEBs752xvDTq MEkESJuAraQOrq+EuuSuMQcP8Zlgr0/Cs8uO9VzXB8m9ITyZkg+I7JTS0fyfLD0tWYXg7MBduKZDx wLxCjFvBpb2yPtqLFfWnpDKDISyiVskkGGIO0oTHM7QMde4I1Zb4SAKuo6nf88HRBbYNA3r33TDOq x96KWjLg==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUPm-0003jf-TZ; Thu, 23 Jul 2020 06:09:11 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 01/26] bpfilter: fix up a sparse annotation Date: Thu, 23 Jul 2020 08:08:43 +0200 Message-Id: <20200723060908.50081-2-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8C3AA40676 X-Rspamd-UID: cc2744 The __user doesn't make sense when casting to an integer type, just switch to a uintptr_t cast which also removes the need for the __force. Signed-off-by: Christoph Hellwig --- net/bpfilter/bpfilter_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c index 2c31e82cb953af..3bac5820062af1 100644 --- a/net/bpfilter/bpfilter_kern.c +++ b/net/bpfilter/bpfilter_kern.c @@ -44,7 +44,7 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname, req.is_set = is_set; req.pid = current->pid; req.cmd = optname; - req.addr = (long __force __user)optval; + req.addr = (uintptr_t)optval; req.len = optlen; if (!bpfilter_ops.info.tgid) goto out; -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cNvSHQ0qGV/YgAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:11:25 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sDirGw0qGV+dHQAADc0bRg (envelope-from ); Thu, 23 Jul 2020 08:11:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A651C40872; Thu, 23 Jul 2020 08:11:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727924AbgGWGKM (ORCPT + 1 other); Thu, 23 Jul 2020 02:10:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727882AbgGWGKC (ORCPT ); Thu, 23 Jul 2020 02:10:02 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ECADC0619DC; Wed, 22 Jul 2020 23:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=k+OM1rQAT4HcodoYmBQcUjl8Na3tQsWupFaDKWdvMt4=; b=r/JKnUudQzQHw1GHr6G78jqFAx th/rMLJUsP9myAW0S/3q+e4A2F11VjRfxCaos2haqi1NPo+6/Nfv+5DTO9o9deuYqjy3fQWDYhfNZ 8jdVY3UJVppZmQUAn2I0Sx2JinuO/xQpBB+t8LmGrBuavyBZCeZ0XwCqoUYG8dIKWVBp4vtLbGfVN jj33/Dao4Sii0UaU9qPxaI5UvlucVdJh1d80twJLqtN9H9G9nFcY1bwtmwD12ic5lrPTsk0qWpUU1 WA8GQLjbQEnCGSJkquLQdDFzejWZb/cstd2RSDcBfRuDQ7xCt1uKCgb6lJMZHW6PDulQi57hDsLaw 35Q5Ldbw==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQK-0003pi-MK; Thu, 23 Jul 2020 06:09:45 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org, Stefan Schmidt Subject: [PATCH 25/26] net: pass a sockptr_t into ->setsockopt Date: Thu, 23 Jul 2020 08:09:07 +0200 Message-Id: <20200723060908.50081-26-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 19 X-Rspamd-Score: 2.94 / 15.00 / 200.00 X-Rspamd-Queue-Id: A651C40872 X-Rspamd-UID: c8511c Rework the remaining setsockopt code to pass a sockptr_t instead of a plain user pointer. This removes the last remaining set_fs(KERNEL_DS) outside of architecture specific code. Signed-off-by: Christoph Hellwig Acked-by: Stefan Schmidt [ieee802154] --- crypto/af_alg.c | 7 ++-- drivers/crypto/chelsio/chtls/chtls_main.c | 18 ++++++----- drivers/isdn/mISDN/socket.c | 4 +-- include/linux/net.h | 4 ++- include/net/inet_connection_sock.h | 3 +- include/net/ip.h | 2 +- include/net/ipv6.h | 4 +-- include/net/sctp/structs.h | 2 +- include/net/sock.h | 4 +-- include/net/tcp.h | 4 +-- net/atm/common.c | 6 ++-- net/atm/common.h | 2 +- net/atm/pvc.c | 2 +- net/atm/svc.c | 6 ++-- net/ax25/af_ax25.c | 6 ++-- net/bluetooth/hci_sock.c | 8 ++--- net/bluetooth/l2cap_sock.c | 22 ++++++------- net/bluetooth/rfcomm/sock.c | 12 ++++--- net/bluetooth/sco.c | 6 ++-- net/caif/caif_socket.c | 8 ++--- net/can/j1939/socket.c | 12 +++---- net/can/raw.c | 16 +++++----- net/core/sock.c | 2 +- net/dccp/dccp.h | 2 +- net/dccp/proto.c | 20 ++++++------ net/decnet/af_decnet.c | 16 ++++++---- net/ieee802154/socket.c | 6 ++-- net/ipv4/ip_sockglue.c | 13 +++----- net/ipv4/raw.c | 8 ++--- net/ipv4/tcp.c | 5 ++- net/ipv4/udp.c | 6 ++-- net/ipv4/udp_impl.h | 4 +-- net/ipv6/ipv6_sockglue.c | 10 +++--- net/ipv6/raw.c | 10 +++--- net/ipv6/udp.c | 6 ++-- net/ipv6/udp_impl.h | 4 +-- net/iucv/af_iucv.c | 4 +-- net/kcm/kcmsock.c | 6 ++-- net/l2tp/l2tp_ppp.c | 4 +-- net/llc/af_llc.c | 4 +-- net/mptcp/protocol.c | 12 +++---- net/netlink/af_netlink.c | 4 +-- net/netrom/af_netrom.c | 4 +-- net/nfc/llcp_sock.c | 6 ++-- net/packet/af_packet.c | 39 ++++++++++++----------- net/phonet/pep.c | 4 +-- net/rds/af_rds.c | 30 ++++++++--------- net/rds/rdma.c | 14 ++++---- net/rds/rds.h | 6 ++-- net/rose/af_rose.c | 4 +-- net/rxrpc/af_rxrpc.c | 8 ++--- net/rxrpc/ar-internal.h | 4 +-- net/rxrpc/key.c | 9 +++--- net/sctp/socket.c | 4 +-- net/smc/af_smc.c | 4 +-- net/socket.c | 23 ++++--------- net/tipc/socket.c | 8 ++--- net/tls/tls_main.c | 17 +++++----- net/vmw_vsock/af_vsock.c | 4 +-- net/x25/af_x25.c | 4 +-- net/xdp/xsk.c | 8 ++--- 61 files changed, 246 insertions(+), 258 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 29f71428520b4b..892242a42c3ec9 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -197,8 +197,7 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) return err; } -static int alg_setkey(struct sock *sk, char __user *ukey, - unsigned int keylen) +static int alg_setkey(struct sock *sk, sockptr_t ukey, unsigned int keylen) { struct alg_sock *ask = alg_sk(sk); const struct af_alg_type *type = ask->type; @@ -210,7 +209,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey, return -ENOMEM; err = -EFAULT; - if (copy_from_user(key, ukey, keylen)) + if (copy_from_sockptr(key, ukey, keylen)) goto out; err = type->setkey(ask->private, key, keylen); @@ -222,7 +221,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey, } static int alg_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct alg_sock *ask = alg_sk(sk); diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c b/drivers/crypto/chelsio/chtls/chtls_main.c index d98b89d0fa6eeb..c3058dcdb33c5c 100644 --- a/drivers/crypto/chelsio/chtls/chtls_main.c +++ b/drivers/crypto/chelsio/chtls/chtls_main.c @@ -488,7 +488,7 @@ static int chtls_getsockopt(struct sock *sk, int level, int optname, } static int do_chtls_setsockopt(struct sock *sk, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct tls_crypto_info *crypto_info, tmp_crypto_info; struct chtls_sock *csk; @@ -498,12 +498,12 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, csk = rcu_dereference_sk_user_data(sk); - if (!optval || optlen < sizeof(*crypto_info)) { + if (sockptr_is_null(optval) || optlen < sizeof(*crypto_info)) { rc = -EINVAL; goto out; } - rc = copy_from_user(&tmp_crypto_info, optval, sizeof(*crypto_info)); + rc = copy_from_sockptr(&tmp_crypto_info, optval, sizeof(*crypto_info)); if (rc) { rc = -EFAULT; goto out; @@ -525,8 +525,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, /* Obtain version and type from previous copy */ crypto_info[0] = tmp_crypto_info; /* Now copy the following data */ - rc = copy_from_user((char *)crypto_info + sizeof(*crypto_info), - optval + sizeof(*crypto_info), + sockptr_advance(optval, sizeof(*crypto_info)); + rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), + optval, sizeof(struct tls12_crypto_info_aes_gcm_128) - sizeof(*crypto_info)); @@ -541,8 +542,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, } case TLS_CIPHER_AES_GCM_256: { crypto_info[0] = tmp_crypto_info; - rc = copy_from_user((char *)crypto_info + sizeof(*crypto_info), - optval + sizeof(*crypto_info), + sockptr_advance(optval, sizeof(*crypto_info)); + rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), + optval, sizeof(struct tls12_crypto_info_aes_gcm_256) - sizeof(*crypto_info)); @@ -565,7 +567,7 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, } static int chtls_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct tls_context *ctx = tls_get_ctx(sk); diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c index 1b2b91479107bc..2835daae9e9f3a 100644 --- a/drivers/isdn/mISDN/socket.c +++ b/drivers/isdn/mISDN/socket.c @@ -401,7 +401,7 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) } static int data_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int len) + sockptr_t optval, unsigned int len) { struct sock *sk = sock->sk; int err = 0, opt = 0; @@ -414,7 +414,7 @@ static int data_sock_setsockopt(struct socket *sock, int level, int optname, switch (optname) { case MISDN_TIME_STAMP: - if (get_user(opt, (int __user *)optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(int))) { err = -EFAULT; break; } diff --git a/include/linux/net.h b/include/linux/net.h index 858ff1d981540d..d48ff11808794c 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -162,7 +163,8 @@ struct proto_ops { int (*listen) (struct socket *sock, int len); int (*shutdown) (struct socket *sock, int flags); int (*setsockopt)(struct socket *sock, int level, - int optname, char __user *optval, unsigned int optlen); + int optname, sockptr_t optval, + unsigned int optlen); int (*getsockopt)(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen); void (*show_fdinfo)(struct seq_file *m, struct socket *sock); diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 157c60cca0ca60..1e209ce7d1bd1b 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -45,7 +46,7 @@ struct inet_connection_sock_af_ops { u16 net_frag_header_len; u16 sockaddr_len; int (*setsockopt)(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); + sockptr_t optval, unsigned int optlen); int (*getsockopt)(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); void (*addr2sockaddr)(struct sock *sk, struct sockaddr *); diff --git a/include/net/ip.h b/include/net/ip.h index d66ad3a9522081..b09c48d862cc10 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -722,7 +722,7 @@ void ip_cmsg_recv_offset(struct msghdr *msg, struct sock *sk, struct sk_buff *skb, int tlen, int offset); int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc, bool allow_ipv6); -int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, +int ip_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, unsigned int optlen); int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 4c9d89b5d73268..bd1f396cc9c729 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -1084,8 +1084,8 @@ struct in6_addr *fl6_update_dst(struct flowi6 *fl6, * socket options (ipv6_sockglue.c) */ -int ipv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); +int ipv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen); int ipv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 233bbf7df5d66c..b33f1aefad0989 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -431,7 +431,7 @@ struct sctp_af { int (*setsockopt) (struct sock *sk, int level, int optname, - char __user *optval, + sockptr_t optval, unsigned int optlen); int (*getsockopt) (struct sock *sk, int level, diff --git a/include/net/sock.h b/include/net/sock.h index bfb2fe2fc36876..2cc3ba667908de 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1141,7 +1141,7 @@ struct proto { void (*destroy)(struct sock *sk); void (*shutdown)(struct sock *sk, int how); int (*setsockopt)(struct sock *sk, int level, - int optname, char __user *optval, + int optname, sockptr_t optval, unsigned int optlen); int (*getsockopt)(struct sock *sk, int level, int optname, char __user *optval, @@ -1734,7 +1734,7 @@ int sock_common_getsockopt(struct socket *sock, int level, int optname, int sock_common_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, int flags); int sock_common_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen); + sockptr_t optval, unsigned int optlen); void sk_common_release(struct sock *sk); diff --git a/include/net/tcp.h b/include/net/tcp.h index e3c8e1d820214c..e0c35d56091f22 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -399,8 +399,8 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, struct poll_table_struct *wait); int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); -int tcp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); +int tcp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen); void tcp_set_keepalive(struct sock *sk, int val); void tcp_syn_ack_timeout(const struct request_sock *req); int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock, diff --git a/net/atm/common.c b/net/atm/common.c index 9b28f1fb3c69c8..84367b844b1473 100644 --- a/net/atm/common.c +++ b/net/atm/common.c @@ -745,7 +745,7 @@ static int check_qos(const struct atm_qos *qos) } int vcc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct atm_vcc *vcc; unsigned long value; @@ -760,7 +760,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, { struct atm_qos qos; - if (copy_from_user(&qos, optval, sizeof(qos))) + if (copy_from_sockptr(&qos, optval, sizeof(qos))) return -EFAULT; error = check_qos(&qos); if (error) @@ -774,7 +774,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, return 0; } case SO_SETCLP: - if (get_user(value, (unsigned long __user *)optval)) + if (copy_from_sockptr(&value, optval, sizeof(value))) return -EFAULT; if (value) vcc->atm_options |= ATM_ATMOPT_CLP; diff --git a/net/atm/common.h b/net/atm/common.h index 5850649068bb29..a1e56e8de698a3 100644 --- a/net/atm/common.h +++ b/net/atm/common.h @@ -21,7 +21,7 @@ __poll_t vcc_poll(struct file *file, struct socket *sock, poll_table *wait); int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); int vcc_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); int vcc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen); + sockptr_t optval, unsigned int optlen); int vcc_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen); void vcc_process_recv_queue(struct atm_vcc *vcc); diff --git a/net/atm/pvc.c b/net/atm/pvc.c index 02bd2a436bdf9e..53e7d3f39e26cc 100644 --- a/net/atm/pvc.c +++ b/net/atm/pvc.c @@ -63,7 +63,7 @@ static int pvc_connect(struct socket *sock, struct sockaddr *sockaddr, } static int pvc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; int error; diff --git a/net/atm/svc.c b/net/atm/svc.c index ba144d035e3d41..4a02bcaad279f8 100644 --- a/net/atm/svc.c +++ b/net/atm/svc.c @@ -451,7 +451,7 @@ int svc_change_qos(struct atm_vcc *vcc, struct atm_qos *qos) } static int svc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct atm_vcc *vcc = ATM_SD(sock); @@ -464,7 +464,7 @@ static int svc_setsockopt(struct socket *sock, int level, int optname, error = -EINVAL; goto out; } - if (copy_from_user(&vcc->sap, optval, optlen)) { + if (copy_from_sockptr(&vcc->sap, optval, optlen)) { error = -EFAULT; goto out; } @@ -475,7 +475,7 @@ static int svc_setsockopt(struct socket *sock, int level, int optname, error = -EINVAL; goto out; } - if (get_user(value, (int __user *)optval)) { + if (copy_from_sockptr(&value, optval, sizeof(int))) { error = -EFAULT; goto out; } diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index fd91cd34f25e03..17bf31a8969284 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -528,7 +528,7 @@ ax25_cb *ax25_create_cb(void) */ static int ax25_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; ax25_cb *ax25; @@ -543,7 +543,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(unsigned int)) return -EINVAL; - if (get_user(opt, (unsigned int __user *)optval)) + if (copy_from_sockptr(&opt, optval, sizeof(unsigned int))) return -EFAULT; lock_sock(sk); @@ -640,7 +640,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, memset(devname, 0, sizeof(devname)); - if (copy_from_user(devname, optval, optlen)) { + if (copy_from_sockptr(devname, optval, optlen)) { res = -EFAULT; break; } diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index caf38a8ea6a8ba..d5eff27d5b1e17 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -1842,7 +1842,7 @@ static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg, } static int hci_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int len) + sockptr_t optval, unsigned int len) { struct hci_ufilter uf = { .opcode = 0 }; struct sock *sk = sock->sk; @@ -1862,7 +1862,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, switch (optname) { case HCI_DATA_DIR: - if (get_user(opt, (int __user *)optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(opt))) { err = -EFAULT; break; } @@ -1874,7 +1874,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, break; case HCI_TIME_STAMP: - if (get_user(opt, (int __user *)optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(opt))) { err = -EFAULT; break; } @@ -1896,7 +1896,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, } len = min_t(unsigned int, len, sizeof(uf)); - if (copy_from_user(&uf, optval, len)) { + if (copy_from_sockptr(&uf, optval, len)) { err = -EFAULT; break; } diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index a995d2c51fa7f1..a3d104123f38dd 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -703,7 +703,7 @@ static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu) } static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; @@ -736,7 +736,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, opts.txwin_size = chan->tx_win; len = min_t(unsigned int, sizeof(opts), optlen); - if (copy_from_user((char *) &opts, optval, len)) { + if (copy_from_sockptr(&opts, optval, len)) { err = -EFAULT; break; } @@ -782,7 +782,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, break; case L2CAP_LM: - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -859,7 +859,7 @@ static int l2cap_set_mode(struct l2cap_chan *chan, u8 mode) } static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; @@ -891,7 +891,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, sec.level = BT_SECURITY_LOW; len = min_t(unsigned int, sizeof(sec), optlen); - if (copy_from_user((char *) &sec, optval, len)) { + if (copy_from_sockptr(&sec, optval, len)) { err = -EFAULT; break; } @@ -939,7 +939,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -954,7 +954,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; case BT_FLUSHABLE: - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -990,7 +990,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, pwr.force_active = BT_POWER_FORCE_ACTIVE_ON; len = min_t(unsigned int, sizeof(pwr), optlen); - if (copy_from_user((char *) &pwr, optval, len)) { + if (copy_from_sockptr(&pwr, optval, len)) { err = -EFAULT; break; } @@ -1002,7 +1002,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; case BT_CHANNEL_POLICY: - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -1050,7 +1050,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u16 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u16))) { err = -EFAULT; break; } @@ -1081,7 +1081,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u8 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u8))) { err = -EFAULT; break; } diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index df14eebe80da8b..dba4ea0e1b0dc7 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -644,7 +644,8 @@ static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg, return len; } -static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen) +static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; int err = 0; @@ -656,7 +657,7 @@ static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __u switch (optname) { case RFCOMM_LM: - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -685,7 +686,8 @@ static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __u return err; } -static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) +static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct bt_security sec; @@ -713,7 +715,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c sec.level = BT_SECURITY_LOW; len = min_t(unsigned int, sizeof(sec), optlen); - if (copy_from_user((char *) &sec, optval, len)) { + if (copy_from_sockptr(&sec, optval, len)) { err = -EFAULT; break; } @@ -732,7 +734,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c break; } - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index c8c3d38cdc7b56..37260baf71507b 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -791,7 +791,7 @@ static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg, } static int sco_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; int len, err = 0; @@ -810,7 +810,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -831,7 +831,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, voice.setting = sco_pi(sk)->setting; len = min_t(unsigned int, sizeof(voice), optlen); - if (copy_from_user((char *)&voice, optval, len)) { + if (copy_from_sockptr(&voice, optval, len)) { err = -EFAULT; break; } diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c index b94ecd931002e7..3ad0a1df671283 100644 --- a/net/caif/caif_socket.c +++ b/net/caif/caif_socket.c @@ -669,8 +669,8 @@ static int caif_stream_sendmsg(struct socket *sock, struct msghdr *msg, return sent ? : err; } -static int setsockopt(struct socket *sock, - int lvl, int opt, char __user *ov, unsigned int ol) +static int setsockopt(struct socket *sock, int lvl, int opt, sockptr_t ov, + unsigned int ol) { struct sock *sk = sock->sk; struct caifsock *cf_sk = container_of(sk, struct caifsock, sk); @@ -685,7 +685,7 @@ static int setsockopt(struct socket *sock, return -EINVAL; if (lvl != SOL_CAIF) goto bad_sol; - if (copy_from_user(&linksel, ov, sizeof(int))) + if (copy_from_sockptr(&linksel, ov, sizeof(int))) return -EINVAL; lock_sock(&(cf_sk->sk)); cf_sk->conn_req.link_selector = linksel; @@ -699,7 +699,7 @@ static int setsockopt(struct socket *sock, return -ENOPROTOOPT; lock_sock(&(cf_sk->sk)); if (ol > sizeof(cf_sk->conn_req.param.data) || - copy_from_user(&cf_sk->conn_req.param.data, ov, ol)) { + copy_from_sockptr(&cf_sk->conn_req.param.data, ov, ol)) { release_sock(&cf_sk->sk); return -EINVAL; } diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c index f7587428febdd2..78ff9b3f1d40c7 100644 --- a/net/can/j1939/socket.c +++ b/net/can/j1939/socket.c @@ -627,14 +627,14 @@ static int j1939_sk_release(struct socket *sock) return 0; } -static int j1939_sk_setsockopt_flag(struct j1939_sock *jsk, char __user *optval, +static int j1939_sk_setsockopt_flag(struct j1939_sock *jsk, sockptr_t optval, unsigned int optlen, int flag) { int tmp; if (optlen != sizeof(tmp)) return -EINVAL; - if (copy_from_user(&tmp, optval, optlen)) + if (copy_from_sockptr(&tmp, optval, optlen)) return -EFAULT; lock_sock(&jsk->sk); if (tmp) @@ -646,7 +646,7 @@ static int j1939_sk_setsockopt_flag(struct j1939_sock *jsk, char __user *optval, } static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct j1939_sock *jsk = j1939_sk(sk); @@ -658,7 +658,7 @@ static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, switch (optname) { case SO_J1939_FILTER: - if (optval) { + if (!sockptr_is_null(optval)) { struct j1939_filter *f; int c; @@ -670,7 +670,7 @@ static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, return -EINVAL; count = optlen / sizeof(*filters); - filters = memdup_user(optval, optlen); + filters = memdup_sockptr(optval, optlen); if (IS_ERR(filters)) return PTR_ERR(filters); @@ -703,7 +703,7 @@ static int j1939_sk_setsockopt(struct socket *sock, int level, int optname, case SO_J1939_SEND_PRIO: if (optlen != sizeof(tmp)) return -EINVAL; - if (copy_from_user(&tmp, optval, optlen)) + if (copy_from_sockptr(&tmp, optval, optlen)) return -EFAULT; if (tmp < 0 || tmp > 7) return -EDOM; diff --git a/net/can/raw.c b/net/can/raw.c index 59c039d73c6d58..94a9405658dc61 100644 --- a/net/can/raw.c +++ b/net/can/raw.c @@ -485,7 +485,7 @@ static int raw_getname(struct socket *sock, struct sockaddr *uaddr, } static int raw_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct raw_sock *ro = raw_sk(sk); @@ -511,11 +511,11 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (count > 1) { /* filter does not fit into dfilter => alloc space */ - filter = memdup_user(optval, optlen); + filter = memdup_sockptr(optval, optlen); if (IS_ERR(filter)) return PTR_ERR(filter); } else if (count == 1) { - if (copy_from_user(&sfilter, optval, sizeof(sfilter))) + if (copy_from_sockptr(&sfilter, optval, sizeof(sfilter))) return -EFAULT; } @@ -568,7 +568,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(err_mask)) return -EINVAL; - if (copy_from_user(&err_mask, optval, optlen)) + if (copy_from_sockptr(&err_mask, optval, optlen)) return -EFAULT; err_mask &= CAN_ERR_MASK; @@ -607,7 +607,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(ro->loopback)) return -EINVAL; - if (copy_from_user(&ro->loopback, optval, optlen)) + if (copy_from_sockptr(&ro->loopback, optval, optlen)) return -EFAULT; break; @@ -616,7 +616,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(ro->recv_own_msgs)) return -EINVAL; - if (copy_from_user(&ro->recv_own_msgs, optval, optlen)) + if (copy_from_sockptr(&ro->recv_own_msgs, optval, optlen)) return -EFAULT; break; @@ -625,7 +625,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(ro->fd_frames)) return -EINVAL; - if (copy_from_user(&ro->fd_frames, optval, optlen)) + if (copy_from_sockptr(&ro->fd_frames, optval, optlen)) return -EFAULT; break; @@ -634,7 +634,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, if (optlen != sizeof(ro->join_filters)) return -EINVAL; - if (copy_from_user(&ro->join_filters, optval, optlen)) + if (copy_from_sockptr(&ro->join_filters, optval, optlen)) return -EFAULT; break; diff --git a/net/core/sock.c b/net/core/sock.c index 1444d7d53ba2fd..2c5dd139777541 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3211,7 +3211,7 @@ EXPORT_SYMBOL(sock_common_recvmsg); * Set socket options on an inet socket. */ int sock_common_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 434eea91b7679d..9cc9d1ee6cdb9a 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h @@ -295,7 +295,7 @@ int dccp_disconnect(struct sock *sk, int flags); int dccp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); int dccp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); + sockptr_t optval, unsigned int optlen); int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg); int dccp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size); int dccp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock, diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 9e453611107f16..2e9e8449698fb4 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -411,7 +411,7 @@ int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg) EXPORT_SYMBOL_GPL(dccp_ioctl); static int dccp_setsockopt_service(struct sock *sk, const __be32 service, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct dccp_sock *dp = dccp_sk(sk); struct dccp_service_list *sl = NULL; @@ -426,9 +426,9 @@ static int dccp_setsockopt_service(struct sock *sk, const __be32 service, return -ENOMEM; sl->dccpsl_nr = optlen / sizeof(u32) - 1; - if (copy_from_user(sl->dccpsl_list, - optval + sizeof(service), - optlen - sizeof(service)) || + sockptr_advance(optval, sizeof(service)); + if (copy_from_sockptr(sl->dccpsl_list, optval, + optlen - sizeof(service)) || dccp_list_has_service(sl, DCCP_SERVICE_INVALID_VALUE)) { kfree(sl); return -EFAULT; @@ -482,7 +482,7 @@ static int dccp_setsockopt_cscov(struct sock *sk, int cscov, bool rx) } static int dccp_setsockopt_ccid(struct sock *sk, int type, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { u8 *val; int rc = 0; @@ -490,7 +490,7 @@ static int dccp_setsockopt_ccid(struct sock *sk, int type, if (optlen < 1 || optlen > DCCP_FEAT_MAX_SP_VALS) return -EINVAL; - val = memdup_user(optval, optlen); + val = memdup_sockptr(optval, optlen); if (IS_ERR(val)) return PTR_ERR(val); @@ -507,7 +507,7 @@ static int dccp_setsockopt_ccid(struct sock *sk, int type, } static int do_dccp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct dccp_sock *dp = dccp_sk(sk); int val, err = 0; @@ -529,7 +529,7 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname, if (optlen < (int)sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; if (optname == DCCP_SOCKOPT_SERVICE) @@ -572,8 +572,8 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname, return err; } -int dccp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) +int dccp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen) { if (level != SOL_DCCP) return inet_csk(sk)->icsk_af_ops->setsockopt(sk, level, diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index 7d51ab608fb3f1..3b53d766789d47 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c @@ -150,7 +150,8 @@ static struct hlist_head dn_sk_hash[DN_SK_HASH_SIZE]; static struct hlist_head dn_wild_sk; static atomic_long_t decnet_memory_allocated; -static int __dn_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen, int flags); +static int __dn_setsockopt(struct socket *sock, int level, int optname, + sockptr_t optval, unsigned int optlen, int flags); static int __dn_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen, int flags); static struct hlist_head *dn_find_list(struct sock *sk) @@ -1320,7 +1321,8 @@ static int dn_shutdown(struct socket *sock, int how) return err; } -static int dn_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) +static int dn_setsockopt(struct socket *sock, int level, int optname, + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; int err; @@ -1332,14 +1334,14 @@ static int dn_setsockopt(struct socket *sock, int level, int optname, char __use /* we need to exclude all possible ENOPROTOOPTs except default case */ if (err == -ENOPROTOOPT && optname != DSO_LINKINFO && optname != DSO_STREAM && optname != DSO_SEQPACKET) - err = nf_setsockopt(sk, PF_DECnet, optname, - USER_SOCKPTR(optval), optlen); + err = nf_setsockopt(sk, PF_DECnet, optname, optval, optlen); #endif return err; } -static int __dn_setsockopt(struct socket *sock, int level,int optname, char __user *optval, unsigned int optlen, int flags) +static int __dn_setsockopt(struct socket *sock, int level, int optname, + sockptr_t optval, unsigned int optlen, int flags) { struct sock *sk = sock->sk; struct dn_scp *scp = DN_SK(sk); @@ -1355,13 +1357,13 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us } u; int err; - if (optlen && !optval) + if (optlen && sockptr_is_null(optval)) return -EINVAL; if (optlen > sizeof(u)) return -EINVAL; - if (copy_from_user(&u, optval, optlen)) + if (copy_from_sockptr(&u, optval, optlen)) return -EFAULT; switch (optname) { diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c index 94ae9662133e30..a45a0401adc50b 100644 --- a/net/ieee802154/socket.c +++ b/net/ieee802154/socket.c @@ -382,7 +382,7 @@ static int raw_getsockopt(struct sock *sk, int level, int optname, } static int raw_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { return -EOPNOTSUPP; } @@ -872,7 +872,7 @@ static int dgram_getsockopt(struct sock *sk, int level, int optname, } static int dgram_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct dgram_sock *ro = dgram_sk(sk); struct net *net = sock_net(sk); @@ -882,7 +882,7 @@ static int dgram_setsockopt(struct sock *sk, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; lock_sock(sk); diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index f7f1507b89fe24..8dc027e54c5bfb 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1401,21 +1401,19 @@ void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb) skb_dst_drop(skb); } -int ip_setsockopt(struct sock *sk, int level, - int optname, char __user *optval, unsigned int optlen) +int ip_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen) { int err; if (level != SOL_IP) return -ENOPROTOOPT; - err = do_ip_setsockopt(sk, level, optname, USER_SOCKPTR(optval), - optlen); + err = do_ip_setsockopt(sk, level, optname, optval, optlen); #if IS_ENABLED(CONFIG_BPFILTER_UMH) if (optname >= BPFILTER_IPT_SO_SET_REPLACE && optname < BPFILTER_IPT_SET_MAX) - err = bpfilter_ip_set_sockopt(sk, optname, USER_SOCKPTR(optval), - optlen); + err = bpfilter_ip_set_sockopt(sk, optname, optval, optlen); #endif #ifdef CONFIG_NETFILTER /* we need to exclude all possible ENOPROTOOPTs except default case */ @@ -1423,8 +1421,7 @@ int ip_setsockopt(struct sock *sk, int level, optname != IP_IPSEC_POLICY && optname != IP_XFRM_POLICY && !ip_mroute_opt(optname)) - err = nf_setsockopt(sk, PF_INET, optname, USER_SOCKPTR(optval), - optlen); + err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); #endif return err; } diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 2a57d633b31e00..6fd4330287c279 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -809,11 +809,11 @@ static int raw_sk_init(struct sock *sk) return 0; } -static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen) +static int raw_seticmpfilter(struct sock *sk, sockptr_t optval, int optlen) { if (optlen > sizeof(struct icmp_filter)) optlen = sizeof(struct icmp_filter); - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen)) + if (copy_from_sockptr(&raw_sk(sk)->filter, optval, optlen)) return -EFAULT; return 0; } @@ -838,7 +838,7 @@ out: return ret; } static int do_raw_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { if (optname == ICMP_FILTER) { if (inet_sk(sk)->inet_num != IPPROTO_ICMP) @@ -850,7 +850,7 @@ static int do_raw_setsockopt(struct sock *sk, int level, int optname, } static int raw_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { if (level != SOL_RAW) return ip_setsockopt(sk, level, optname, optval, optlen); diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 71cbc61c335f71..27de9380ed140e 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3323,7 +3323,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, int optname, return err; } -int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, +int tcp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, unsigned int optlen) { const struct inet_connection_sock *icsk = inet_csk(sk); @@ -3331,8 +3331,7 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, if (level != SOL_TCP) return icsk->icsk_af_ops->setsockopt(sk, level, optname, optval, optlen); - return do_tcp_setsockopt(sk, level, optname, USER_SOCKPTR(optval), - optlen); + return do_tcp_setsockopt(sk, level, optname, optval, optlen); } EXPORT_SYMBOL(tcp_setsockopt); diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index c6cb2d09dbc75e..5a6a2f6d86b99d 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2703,12 +2703,12 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, } EXPORT_SYMBOL(udp_lib_setsockopt); -int udp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) +int udp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen) { if (level == SOL_UDP || level == SOL_UDPLITE) return udp_lib_setsockopt(sk, level, optname, - USER_SOCKPTR(optval), optlen, + optval, optlen, udp_push_pending_frames); return ip_setsockopt(sk, level, optname, optval, optlen); } diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h index ab313702c87f30..2878d8285cafe7 100644 --- a/net/ipv4/udp_impl.h +++ b/net/ipv4/udp_impl.h @@ -12,8 +12,8 @@ int __udp4_lib_err(struct sk_buff *, u32, struct udp_table *); int udp_v4_get_port(struct sock *sk, unsigned short snum); void udp_v4_rehash(struct sock *sk); -int udp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); +int udp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen); int udp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index dcd000a5a9b124..d2282f5c9760f9 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -980,8 +980,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, return -EINVAL; } -int ipv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) +int ipv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen) { int err; @@ -991,14 +991,12 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, if (level != SOL_IPV6) return -ENOPROTOOPT; - err = do_ipv6_setsockopt(sk, level, optname, USER_SOCKPTR(optval), - optlen); + err = do_ipv6_setsockopt(sk, level, optname, optval, optlen); #ifdef CONFIG_NETFILTER /* we need to exclude all possible ENOPROTOOPTs except default case */ if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY && optname != IPV6_XFRM_POLICY) - err = nf_setsockopt(sk, PF_INET6, optname, USER_SOCKPTR(optval), - optlen); + err = nf_setsockopt(sk, PF_INET6, optname, optval, optlen); #endif return err; } diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 594e01ad670aa6..874f01cd7aec42 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -972,13 +972,13 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) } static int rawv6_seticmpfilter(struct sock *sk, int level, int optname, - char __user *optval, int optlen) + sockptr_t optval, int optlen) { switch (optname) { case ICMPV6_FILTER: if (optlen > sizeof(struct icmp6_filter)) optlen = sizeof(struct icmp6_filter); - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen)) + if (copy_from_sockptr(&raw6_sk(sk)->filter, optval, optlen)) return -EFAULT; return 0; default: @@ -1015,12 +1015,12 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname, static int do_rawv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct raw6_sock *rp = raw6_sk(sk); int val; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; switch (optname) { @@ -1062,7 +1062,7 @@ static int do_rawv6_setsockopt(struct sock *sk, int level, int optname, } static int rawv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { switch (level) { case SOL_RAW: diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 2df1e6c9d7cbf6..15818e18655d71 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1618,12 +1618,12 @@ void udpv6_destroy_sock(struct sock *sk) /* * Socket option code for UDP */ -int udpv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) +int udpv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen) { if (level == SOL_UDP || level == SOL_UDPLITE) return udp_lib_setsockopt(sk, level, optname, - USER_SOCKPTR(optval), optlen, + optval, optlen, udp_v6_push_pending_frames); return ipv6_setsockopt(sk, level, optname, optval, optlen); } diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h index 30dfb6f1b7622a..b2fcc46c1630e0 100644 --- a/net/ipv6/udp_impl.h +++ b/net/ipv6/udp_impl.h @@ -17,8 +17,8 @@ void udp_v6_rehash(struct sock *sk); int udpv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); -int udpv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen); +int udpv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, + unsigned int optlen); int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len); int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, int flags, int *addr_len); diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index ee0add15497d96..6ee9851ac7c680 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -1494,7 +1494,7 @@ static int iucv_sock_release(struct socket *sock) /* getsockopt and setsockopt */ static int iucv_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct iucv_sock *iucv = iucv_sk(sk); @@ -1507,7 +1507,7 @@ static int iucv_sock_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *) optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; rc = 0; diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index 56fac24a627a54..56dad9565bc93b 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -1265,7 +1265,7 @@ static void kcm_recv_enable(struct kcm_sock *kcm) } static int kcm_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct kcm_sock *kcm = kcm_sk(sock->sk); int val, valbool; @@ -1277,8 +1277,8 @@ static int kcm_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) - return -EINVAL; + if (copy_from_sockptr(&val, optval, sizeof(int))) + return -EFAULT; valbool = val ? 1 : 0; diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index f894dc27539399..f91ed2efa86909 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -1245,7 +1245,7 @@ static int pppol2tp_session_setsockopt(struct sock *sk, * session or the special tunnel type. */ static int pppol2tp_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct l2tp_session *session; @@ -1259,7 +1259,7 @@ static int pppol2tp_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; err = -ENOTCONN; diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index 6140a3e46c26f1..7180979114e494 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -1053,7 +1053,7 @@ static int llc_ui_ioctl(struct socket *sock, unsigned int cmd, * Set various connection specific parameters. */ static int llc_ui_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct llc_sock *llc = llc_sk(sk); @@ -1063,7 +1063,7 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname, lock_sock(sk); if (unlikely(level != SOL_LLC || optlen != sizeof(int))) goto out; - rc = get_user(opt, (int __user *)optval); + rc = copy_from_sockptr(&opt, optval, sizeof(opt)); if (rc) goto out; rc = -EINVAL; diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 27b6f250b87dfd..a16b08343d4f58 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1627,7 +1627,7 @@ static void mptcp_destroy(struct sock *sk) } static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = (struct sock *)msk; struct socket *ssock; @@ -1643,8 +1643,7 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, return -EINVAL; } - ret = sock_setsockopt(ssock, SOL_SOCKET, optname, - USER_SOCKPTR(optval), optlen); + ret = sock_setsockopt(ssock, SOL_SOCKET, optname, optval, optlen); if (ret == 0) { if (optname == SO_REUSEPORT) sk->sk_reuseport = ssock->sk->sk_reuseport; @@ -1655,12 +1654,11 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, return ret; } - return sock_setsockopt(sk->sk_socket, SOL_SOCKET, optname, - USER_SOCKPTR(optval), optlen); + return sock_setsockopt(sk->sk_socket, SOL_SOCKET, optname, optval, optlen); } static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = (struct sock *)msk; int ret = -EOPNOTSUPP; @@ -1687,7 +1685,7 @@ static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, } static int mptcp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct mptcp_sock *msk = mptcp_sk(sk); struct sock *ssk; diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 3cd58f0c2de436..d8921b8337445b 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1621,7 +1621,7 @@ static void netlink_update_socket_mc(struct netlink_sock *nlk, } static int netlink_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct netlink_sock *nlk = nlk_sk(sk); @@ -1632,7 +1632,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname, return -ENOPROTOOPT; if (optlen >= sizeof(int) && - get_user(val, (unsigned int __user *)optval)) + copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; switch (optname) { diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index f90ef6934b8f4d..6d16e1ab1a8aba 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -294,7 +294,7 @@ void nr_destroy_socket(struct sock *sk) */ static int nr_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct nr_sock *nr = nr_sk(sk); @@ -306,7 +306,7 @@ static int nr_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(unsigned int)) return -EINVAL; - if (get_user(opt, (unsigned int __user *)optval)) + if (copy_from_sockptr(&opt, optval, sizeof(unsigned int))) return -EFAULT; switch (optname) { diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index 6da1e2334bb697..d257ed3b732ae3 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -218,7 +218,7 @@ static int llcp_sock_listen(struct socket *sock, int backlog) } static int nfc_llcp_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); @@ -241,7 +241,7 @@ static int nfc_llcp_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } @@ -263,7 +263,7 @@ static int nfc_llcp_setsockopt(struct socket *sock, int level, int optname, break; } - if (get_user(opt, (u32 __user *) optval)) { + if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; } diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index d8d4f78f78e451..0b8160d1a6e06d 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1558,7 +1558,7 @@ static int fanout_set_data_cbpf(struct packet_sock *po, sockptr_t data, return 0; } -static int fanout_set_data_ebpf(struct packet_sock *po, char __user *data, +static int fanout_set_data_ebpf(struct packet_sock *po, sockptr_t data, unsigned int len) { struct bpf_prog *new; @@ -1568,7 +1568,7 @@ static int fanout_set_data_ebpf(struct packet_sock *po, char __user *data, return -EPERM; if (len != sizeof(fd)) return -EINVAL; - if (copy_from_user(&fd, data, len)) + if (copy_from_sockptr(&fd, data, len)) return -EFAULT; new = bpf_prog_get_type(fd, BPF_PROG_TYPE_SOCKET_FILTER); @@ -1579,12 +1579,12 @@ static int fanout_set_data_ebpf(struct packet_sock *po, char __user *data, return 0; } -static int fanout_set_data(struct packet_sock *po, char __user *data, +static int fanout_set_data(struct packet_sock *po, sockptr_t data, unsigned int len) { switch (po->fanout->type) { case PACKET_FANOUT_CBPF: - return fanout_set_data_cbpf(po, USER_SOCKPTR(data), len); + return fanout_set_data_cbpf(po, data, len); case PACKET_FANOUT_EBPF: return fanout_set_data_ebpf(po, data, len); default: @@ -3652,7 +3652,8 @@ static void packet_flush_mclist(struct sock *sk) } static int -packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) +packet_setsockopt(struct socket *sock, int level, int optname, sockptr_t optval, + unsigned int optlen) { struct sock *sk = sock->sk; struct packet_sock *po = pkt_sk(sk); @@ -3672,7 +3673,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv return -EINVAL; if (len > sizeof(mreq)) len = sizeof(mreq); - if (copy_from_user(&mreq, optval, len)) + if (copy_from_sockptr(&mreq, optval, len)) return -EFAULT; if (len < (mreq.mr_alen + offsetof(struct packet_mreq, mr_address))) return -EINVAL; @@ -3703,7 +3704,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen < len) { ret = -EINVAL; } else { - if (copy_from_user(&req_u.req, optval, len)) + if (copy_from_sockptr(&req_u.req, optval, len)) ret = -EFAULT; else ret = packet_set_ring(sk, &req_u, 0, @@ -3718,7 +3719,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; pkt_sk(sk)->copy_thresh = val; @@ -3730,7 +3731,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; switch (val) { case TPACKET_V1: @@ -3756,7 +3757,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; if (val > INT_MAX) return -EINVAL; @@ -3776,7 +3777,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3795,7 +3796,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen < sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3809,7 +3810,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen < sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3825,7 +3826,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv return -EINVAL; if (optlen < sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3844,7 +3845,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; po->tp_tstamp = val; @@ -3856,7 +3857,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; return fanout_add(sk, val & 0xffff, val >> 16); @@ -3874,7 +3875,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; if (val < 0 || val > 1) return -EINVAL; @@ -3888,7 +3889,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3907,7 +3908,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv if (optlen != sizeof(val)) return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; po->xmit = val ? packet_direct_xmit : dev_queue_xmit; diff --git a/net/phonet/pep.c b/net/phonet/pep.c index 4577e43cb77782..e47d09aca4af46 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c @@ -975,7 +975,7 @@ static int pep_init(struct sock *sk) } static int pep_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct pep_sock *pn = pep_sk(sk); int val = 0, err = 0; @@ -983,7 +983,7 @@ static int pep_setsockopt(struct sock *sk, int level, int optname, if (level != SOL_PNPIPE) return -ENOPROTOOPT; if (optlen >= sizeof(int)) { - if (get_user(val, (int __user *) optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; } diff --git a/net/rds/af_rds.c b/net/rds/af_rds.c index 1a5bf3fa4578b8..b239120dd9ca69 100644 --- a/net/rds/af_rds.c +++ b/net/rds/af_rds.c @@ -290,8 +290,7 @@ static int rds_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return 0; } -static int rds_cancel_sent_to(struct rds_sock *rs, char __user *optval, - int len) +static int rds_cancel_sent_to(struct rds_sock *rs, sockptr_t optval, int len) { struct sockaddr_in6 sin6; struct sockaddr_in sin; @@ -308,14 +307,15 @@ static int rds_cancel_sent_to(struct rds_sock *rs, char __user *optval, goto out; } else if (len < sizeof(struct sockaddr_in6)) { /* Assume IPv4 */ - if (copy_from_user(&sin, optval, sizeof(struct sockaddr_in))) { + if (copy_from_sockptr(&sin, optval, + sizeof(struct sockaddr_in))) { ret = -EFAULT; goto out; } ipv6_addr_set_v4mapped(sin.sin_addr.s_addr, &sin6.sin6_addr); sin6.sin6_port = sin.sin_port; } else { - if (copy_from_user(&sin6, optval, + if (copy_from_sockptr(&sin6, optval, sizeof(struct sockaddr_in6))) { ret = -EFAULT; goto out; @@ -327,21 +327,20 @@ static int rds_cancel_sent_to(struct rds_sock *rs, char __user *optval, return ret; } -static int rds_set_bool_option(unsigned char *optvar, char __user *optval, +static int rds_set_bool_option(unsigned char *optvar, sockptr_t optval, int optlen) { int value; if (optlen < sizeof(int)) return -EINVAL; - if (get_user(value, (int __user *) optval)) + if (copy_from_sockptr(&value, optval, sizeof(int))) return -EFAULT; *optvar = !!value; return 0; } -static int rds_cong_monitor(struct rds_sock *rs, char __user *optval, - int optlen) +static int rds_cong_monitor(struct rds_sock *rs, sockptr_t optval, int optlen) { int ret; @@ -358,8 +357,7 @@ static int rds_cong_monitor(struct rds_sock *rs, char __user *optval, return ret; } -static int rds_set_transport(struct rds_sock *rs, char __user *optval, - int optlen) +static int rds_set_transport(struct rds_sock *rs, sockptr_t optval, int optlen) { int t_type; @@ -369,7 +367,7 @@ static int rds_set_transport(struct rds_sock *rs, char __user *optval, if (optlen != sizeof(int)) return -EINVAL; - if (copy_from_user(&t_type, (int __user *)optval, sizeof(t_type))) + if (copy_from_sockptr(&t_type, optval, sizeof(t_type))) return -EFAULT; if (t_type < 0 || t_type >= RDS_TRANS_COUNT) @@ -380,7 +378,7 @@ static int rds_set_transport(struct rds_sock *rs, char __user *optval, return rs->rs_transport ? 0 : -ENOPROTOOPT; } -static int rds_enable_recvtstamp(struct sock *sk, char __user *optval, +static int rds_enable_recvtstamp(struct sock *sk, sockptr_t optval, int optlen, int optname) { int val, valbool; @@ -388,7 +386,7 @@ static int rds_enable_recvtstamp(struct sock *sk, char __user *optval, if (optlen != sizeof(int)) return -EFAULT; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; valbool = val ? 1 : 0; @@ -404,7 +402,7 @@ static int rds_enable_recvtstamp(struct sock *sk, char __user *optval, return 0; } -static int rds_recv_track_latency(struct rds_sock *rs, char __user *optval, +static int rds_recv_track_latency(struct rds_sock *rs, sockptr_t optval, int optlen) { struct rds_rx_trace_so trace; @@ -413,7 +411,7 @@ static int rds_recv_track_latency(struct rds_sock *rs, char __user *optval, if (optlen != sizeof(struct rds_rx_trace_so)) return -EFAULT; - if (copy_from_user(&trace, optval, sizeof(trace))) + if (copy_from_sockptr(&trace, optval, sizeof(trace))) return -EFAULT; if (trace.rx_traces > RDS_MSG_RX_DGRAM_TRACE_MAX) @@ -432,7 +430,7 @@ static int rds_recv_track_latency(struct rds_sock *rs, char __user *optval, } static int rds_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct rds_sock *rs = rds_sk_to_rs(sock->sk); int ret; diff --git a/net/rds/rdma.c b/net/rds/rdma.c index a7ae11846cd7f5..ccdd304eae0a0a 100644 --- a/net/rds/rdma.c +++ b/net/rds/rdma.c @@ -353,21 +353,20 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args, return ret; } -int rds_get_mr(struct rds_sock *rs, char __user *optval, int optlen) +int rds_get_mr(struct rds_sock *rs, sockptr_t optval, int optlen) { struct rds_get_mr_args args; if (optlen != sizeof(struct rds_get_mr_args)) return -EINVAL; - if (copy_from_user(&args, (struct rds_get_mr_args __user *)optval, - sizeof(struct rds_get_mr_args))) + if (copy_from_sockptr(&args, optval, sizeof(struct rds_get_mr_args))) return -EFAULT; return __rds_rdma_map(rs, &args, NULL, NULL, NULL); } -int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen) +int rds_get_mr_for_dest(struct rds_sock *rs, sockptr_t optval, int optlen) { struct rds_get_mr_for_dest_args args; struct rds_get_mr_args new_args; @@ -375,7 +374,7 @@ int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen) if (optlen != sizeof(struct rds_get_mr_for_dest_args)) return -EINVAL; - if (copy_from_user(&args, (struct rds_get_mr_for_dest_args __user *)optval, + if (copy_from_sockptr(&args, optval, sizeof(struct rds_get_mr_for_dest_args))) return -EFAULT; @@ -394,7 +393,7 @@ int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen) /* * Free the MR indicated by the given R_Key */ -int rds_free_mr(struct rds_sock *rs, char __user *optval, int optlen) +int rds_free_mr(struct rds_sock *rs, sockptr_t optval, int optlen) { struct rds_free_mr_args args; struct rds_mr *mr; @@ -403,8 +402,7 @@ int rds_free_mr(struct rds_sock *rs, char __user *optval, int optlen) if (optlen != sizeof(struct rds_free_mr_args)) return -EINVAL; - if (copy_from_user(&args, (struct rds_free_mr_args __user *)optval, - sizeof(struct rds_free_mr_args))) + if (copy_from_sockptr(&args, optval, sizeof(struct rds_free_mr_args))) return -EFAULT; /* Special case - a null cookie means flush all unused MRs */ diff --git a/net/rds/rds.h b/net/rds/rds.h index 106e862996b94d..d35d1fc3980766 100644 --- a/net/rds/rds.h +++ b/net/rds/rds.h @@ -924,9 +924,9 @@ int rds_send_pong(struct rds_conn_path *cp, __be16 dport); /* rdma.c */ void rds_rdma_unuse(struct rds_sock *rs, u32 r_key, int force); -int rds_get_mr(struct rds_sock *rs, char __user *optval, int optlen); -int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen); -int rds_free_mr(struct rds_sock *rs, char __user *optval, int optlen); +int rds_get_mr(struct rds_sock *rs, sockptr_t optval, int optlen); +int rds_get_mr_for_dest(struct rds_sock *rs, sockptr_t optval, int optlen); +int rds_free_mr(struct rds_sock *rs, sockptr_t optval, int optlen); void rds_rdma_drop_keys(struct rds_sock *rs); int rds_rdma_extra_size(struct rds_rdma_args *args, struct rds_iov_vector *iov); diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index ce85656ac9c159..cf7d974e0f619a 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -365,7 +365,7 @@ void rose_destroy_socket(struct sock *sk) */ static int rose_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct rose_sock *rose = rose_sk(sk); @@ -377,7 +377,7 @@ static int rose_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(opt, (int __user *)optval)) + if (copy_from_sockptr(&opt, optval, sizeof(int))) return -EFAULT; switch (optname) { diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c index cd7d0d204c7498..e6725a6de015fb 100644 --- a/net/rxrpc/af_rxrpc.c +++ b/net/rxrpc/af_rxrpc.c @@ -588,7 +588,7 @@ EXPORT_SYMBOL(rxrpc_sock_set_min_security_level); * set RxRPC socket options */ static int rxrpc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct rxrpc_sock *rx = rxrpc_sk(sock->sk); unsigned int min_sec_level; @@ -639,8 +639,8 @@ static int rxrpc_setsockopt(struct socket *sock, int level, int optname, ret = -EISCONN; if (rx->sk.sk_state != RXRPC_UNBOUND) goto error; - ret = get_user(min_sec_level, - (unsigned int __user *) optval); + ret = copy_from_sockptr(&min_sec_level, optval, + sizeof(unsigned int)); if (ret < 0) goto error; ret = -EINVAL; @@ -658,7 +658,7 @@ static int rxrpc_setsockopt(struct socket *sock, int level, int optname, if (rx->sk.sk_state != RXRPC_SERVER_BOUND2) goto error; ret = -EFAULT; - if (copy_from_user(service_upgrade, optval, + if (copy_from_sockptr(service_upgrade, optval, sizeof(service_upgrade)) != 0) goto error; ret = -EINVAL; diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h index 9a2139ebd67d73..6d29a3603a3e6e 100644 --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h @@ -909,8 +909,8 @@ extern const struct rxrpc_security rxrpc_no_security; extern struct key_type key_type_rxrpc; extern struct key_type key_type_rxrpc_s; -int rxrpc_request_key(struct rxrpc_sock *, char __user *, int); -int rxrpc_server_keyring(struct rxrpc_sock *, char __user *, int); +int rxrpc_request_key(struct rxrpc_sock *, sockptr_t , int); +int rxrpc_server_keyring(struct rxrpc_sock *, sockptr_t, int); int rxrpc_get_server_data_key(struct rxrpc_connection *, const void *, time64_t, u32); diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c index 0c98313dd7a8cb..94c3df392651b9 100644 --- a/net/rxrpc/key.c +++ b/net/rxrpc/key.c @@ -896,7 +896,7 @@ static void rxrpc_describe(const struct key *key, struct seq_file *m) /* * grab the security key for a socket */ -int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen) +int rxrpc_request_key(struct rxrpc_sock *rx, sockptr_t optval, int optlen) { struct key *key; char *description; @@ -906,7 +906,7 @@ int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen) if (optlen <= 0 || optlen > PAGE_SIZE - 1) return -EINVAL; - description = memdup_user_nul(optval, optlen); + description = memdup_sockptr_nul(optval, optlen); if (IS_ERR(description)) return PTR_ERR(description); @@ -926,8 +926,7 @@ int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen) /* * grab the security keyring for a server socket */ -int rxrpc_server_keyring(struct rxrpc_sock *rx, char __user *optval, - int optlen) +int rxrpc_server_keyring(struct rxrpc_sock *rx, sockptr_t optval, int optlen) { struct key *key; char *description; @@ -937,7 +936,7 @@ int rxrpc_server_keyring(struct rxrpc_sock *rx, char __user *optval, if (optlen <= 0 || optlen > PAGE_SIZE - 1) return -EINVAL; - description = memdup_user_nul(optval, optlen); + description = memdup_sockptr_nul(optval, optlen); if (IS_ERR(description)) return PTR_ERR(description); diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 9a767f35971865..144808dfea9ee8 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4429,7 +4429,7 @@ static int sctp_setsockopt_pf_expose(struct sock *sk, * optlen - the size of the buffer. */ static int sctp_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { void *kopt = NULL; int retval = 0; @@ -4449,7 +4449,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, } if (optlen > 0) { - kopt = memdup_user(optval, optlen); + kopt = memdup_sockptr(optval, optlen); if (IS_ERR(kopt)) return PTR_ERR(kopt); } diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 9711c9e0e515bf..4ac1d4de667691 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1731,7 +1731,7 @@ static int smc_shutdown(struct socket *sock, int how) } static int smc_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct smc_sock *smc; @@ -1754,7 +1754,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(int))) return -EFAULT; lock_sock(sk); diff --git a/net/socket.c b/net/socket.c index c97f83d879ae75..e44b8ac47f6f46 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2094,10 +2094,10 @@ static bool sock_use_custom_sol_socket(const struct socket *sock) * Set a socket option. Because we don't know the option lengths we have * to pass the user mode parameter for the protocols to sort out. */ -int __sys_setsockopt(int fd, int level, int optname, char __user *optval, +int __sys_setsockopt(int fd, int level, int optname, char __user *user_optval, int optlen) { - mm_segment_t oldfs = get_fs(); + sockptr_t optval = USER_SOCKPTR(user_optval); char *kernel_optval = NULL; int err, fput_needed; struct socket *sock; @@ -2115,7 +2115,7 @@ int __sys_setsockopt(int fd, int level, int optname, char __user *optval, if (!in_compat_syscall()) err = BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock->sk, &level, &optname, - optval, &optlen, + user_optval, &optlen, &kernel_optval); if (err < 0) goto out_put; @@ -2124,25 +2124,16 @@ int __sys_setsockopt(int fd, int level, int optname, char __user *optval, goto out_put; } - if (kernel_optval) { - set_fs(KERNEL_DS); - optval = (char __user __force *)kernel_optval; - } - + if (kernel_optval) + optval = KERNEL_SOCKPTR(kernel_optval); if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) - err = sock_setsockopt(sock, level, optname, - USER_SOCKPTR(optval), optlen); + err = sock_setsockopt(sock, level, optname, optval, optlen); else if (unlikely(!sock->ops->setsockopt)) err = -EOPNOTSUPP; else err = sock->ops->setsockopt(sock, level, optname, optval, optlen); - - if (kernel_optval) { - set_fs(oldfs); - kfree(kernel_optval); - } - + kfree(kernel_optval); out_put: fput_light(sock->file, fput_needed); return err; diff --git a/net/tipc/socket.c b/net/tipc/socket.c index fc388cef64715c..07419f36116a84 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -3103,7 +3103,7 @@ static int tipc_sk_leave(struct tipc_sock *tsk) * Returns 0 on success, errno otherwise */ static int tipc_setsockopt(struct socket *sock, int lvl, int opt, - char __user *ov, unsigned int ol) + sockptr_t ov, unsigned int ol) { struct sock *sk = sock->sk; struct tipc_sock *tsk = tipc_sk(sk); @@ -3124,17 +3124,17 @@ static int tipc_setsockopt(struct socket *sock, int lvl, int opt, case TIPC_NODELAY: if (ol < sizeof(value)) return -EINVAL; - if (get_user(value, (u32 __user *)ov)) + if (copy_from_sockptr(&value, ov, sizeof(u32))) return -EFAULT; break; case TIPC_GROUP_JOIN: if (ol < sizeof(mreq)) return -EINVAL; - if (copy_from_user(&mreq, ov, sizeof(mreq))) + if (copy_from_sockptr(&mreq, ov, sizeof(mreq))) return -EFAULT; break; default: - if (ov || ol) + if (!sockptr_is_null(ov) || ol) return -EINVAL; } diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index ec10041c6b7d41..d77f7d821130db 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -450,7 +450,7 @@ static int tls_getsockopt(struct sock *sk, int level, int optname, return do_tls_getsockopt(sk, optname, optval, optlen); } -static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, +static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval, unsigned int optlen, int tx) { struct tls_crypto_info *crypto_info; @@ -460,7 +460,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, int rc = 0; int conf; - if (!optval || (optlen < sizeof(*crypto_info))) { + if (sockptr_is_null(optval) || (optlen < sizeof(*crypto_info))) { rc = -EINVAL; goto out; } @@ -479,7 +479,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, goto out; } - rc = copy_from_user(crypto_info, optval, sizeof(*crypto_info)); + rc = copy_from_sockptr(crypto_info, optval, sizeof(*crypto_info)); if (rc) { rc = -EFAULT; goto err_crypto_info; @@ -522,8 +522,9 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, goto err_crypto_info; } - rc = copy_from_user(crypto_info + 1, optval + sizeof(*crypto_info), - optlen - sizeof(*crypto_info)); + sockptr_advance(optval, sizeof(*crypto_info)); + rc = copy_from_sockptr(crypto_info + 1, optval, + optlen - sizeof(*crypto_info)); if (rc) { rc = -EFAULT; goto err_crypto_info; @@ -579,8 +580,8 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, return rc; } -static int do_tls_setsockopt(struct sock *sk, int optname, - char __user *optval, unsigned int optlen) +static int do_tls_setsockopt(struct sock *sk, int optname, sockptr_t optval, + unsigned int optlen) { int rc = 0; @@ -600,7 +601,7 @@ static int do_tls_setsockopt(struct sock *sk, int optname, } static int tls_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct tls_context *ctx = tls_get_ctx(sk); diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index df204c6761c453..27bbcfad9c1738 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1517,7 +1517,7 @@ static void vsock_update_buffer_size(struct vsock_sock *vsk, static int vsock_stream_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, + sockptr_t optval, unsigned int optlen) { int err; @@ -1535,7 +1535,7 @@ static int vsock_stream_setsockopt(struct socket *sock, err = -EINVAL; \ goto exit; \ } \ - if (copy_from_user(&_v, optval, sizeof(_v)) != 0) { \ + if (copy_from_sockptr(&_v, optval, sizeof(_v)) != 0) { \ err = -EFAULT; \ goto exit; \ } \ diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index d5b09bbff3754f..0bbb283f23c96f 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -431,7 +431,7 @@ void x25_destroy_socket_from_timer(struct sock *sk) */ static int x25_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { int opt; struct sock *sk = sock->sk; @@ -445,7 +445,7 @@ static int x25_setsockopt(struct socket *sock, int level, int optname, goto out; rc = -EFAULT; - if (get_user(opt, (int __user *)optval)) + if (copy_from_sockptr(&opt, optval, sizeof(int))) goto out; if (opt) diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index 26e3bba8c204a7..2e94a7e94671b6 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -702,7 +702,7 @@ struct xdp_umem_reg_v1 { }; static int xsk_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct sock *sk = sock->sk; struct xdp_sock *xs = xdp_sk(sk); @@ -720,7 +720,7 @@ static int xsk_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(entries)) return -EINVAL; - if (copy_from_user(&entries, optval, sizeof(entries))) + if (copy_from_sockptr(&entries, optval, sizeof(entries))) return -EFAULT; mutex_lock(&xs->mutex); @@ -747,7 +747,7 @@ static int xsk_setsockopt(struct socket *sock, int level, int optname, else if (optlen < sizeof(mr)) mr_size = sizeof(struct xdp_umem_reg_v1); - if (copy_from_user(&mr, optval, mr_size)) + if (copy_from_sockptr(&mr, optval, mr_size)) return -EFAULT; mutex_lock(&xs->mutex); @@ -774,7 +774,7 @@ static int xsk_setsockopt(struct socket *sock, int level, int optname, struct xsk_queue **q; int entries; - if (copy_from_user(&entries, optval, sizeof(entries))) + if (copy_from_sockptr(&entries, optval, sizeof(entries))) return -EFAULT; mutex_lock(&xs->mutex); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2GyqMyQqGV/YgAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:11:48 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +LnLMSQqGV9/qQEAlScrYA (envelope-from ); Thu, 23 Jul 2020 08:11:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9414640876; Thu, 23 Jul 2020 08:11:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727949AbgGWGKf (ORCPT + 1 other); Thu, 23 Jul 2020 02:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727808AbgGWGJz (ORCPT ); Thu, 23 Jul 2020 02:09:55 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 910CCC0619DC; Wed, 22 Jul 2020 23:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=UdgYuJlmWZokLcAOPnfw8PlZRvn7vjQf/6iOObq/cjM=; b=aIaMhclEEnD1ULwrKvn78xfvE4 8LhP29U8BKD5dCx/PZ4xzwjJk056rLJlvUegZOy3Vu6Yef9on/jdjTYZDrYzfTZl8bVQbbTop0UWR M8Yx1TSJ9NA/9mJk31ud6h2bSkcvPf+C2+x6wKPLcYNdkFZ6us0Lb3ds14cqloxiLsw3vi7XqwMx5 hpYczsqWiGeLGvsYypY38x3+nsPb17XruzF454E+faRyBokX2ig/VaOf+Jyic1oOFiasUFAxiY5zh h3Y5fDzIOIWdfMwKL7ZrXjv5DnfDd7AZWh3ZQ4AiSNMLsHjYpJvbeUT3B/4GZ+BqlGh21EpzBzSK+ 4fcp8kXw==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQJ-0003pG-7a; Thu, 23 Jul 2020 06:09:43 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 24/26] net/tcp: switch do_tcp_setsockopt to sockptr_t Date: Thu, 23 Jul 2020 08:09:06 +0200 Message-Id: <20200723060908.50081-25-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9414640876 X-Rspamd-UID: aa7454 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- net/ipv4/tcp.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 49bf15c27deac7..71cbc61c335f71 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2764,7 +2764,7 @@ static inline bool tcp_can_repair_sock(const struct sock *sk) (sk->sk_state != TCP_LISTEN); } -static int tcp_repair_set_window(struct tcp_sock *tp, char __user *optbuf, int len) +static int tcp_repair_set_window(struct tcp_sock *tp, sockptr_t optbuf, int len) { struct tcp_repair_window opt; @@ -2774,7 +2774,7 @@ static int tcp_repair_set_window(struct tcp_sock *tp, char __user *optbuf, int l if (len != sizeof(opt)) return -EINVAL; - if (copy_from_user(&opt, optbuf, sizeof(opt))) + if (copy_from_sockptr(&opt, optbuf, sizeof(opt))) return -EFAULT; if (opt.max_window < opt.snd_wnd) @@ -2796,17 +2796,17 @@ static int tcp_repair_set_window(struct tcp_sock *tp, char __user *optbuf, int l return 0; } -static int tcp_repair_options_est(struct sock *sk, - struct tcp_repair_opt __user *optbuf, unsigned int len) +static int tcp_repair_options_est(struct sock *sk, sockptr_t optbuf, + unsigned int len) { struct tcp_sock *tp = tcp_sk(sk); struct tcp_repair_opt opt; while (len >= sizeof(opt)) { - if (copy_from_user(&opt, optbuf, sizeof(opt))) + if (copy_from_sockptr(&opt, optbuf, sizeof(opt))) return -EFAULT; - optbuf++; + sockptr_advance(optbuf, sizeof(opt)); len -= sizeof(opt); switch (opt.opt_code) { @@ -3020,8 +3020,8 @@ EXPORT_SYMBOL(tcp_sock_set_keepcnt); /* * Socket option code for TCP. */ -static int do_tcp_setsockopt(struct sock *sk, int level, - int optname, char __user *optval, unsigned int optlen) +static int do_tcp_setsockopt(struct sock *sk, int level, int optname, + sockptr_t optval, unsigned int optlen) { struct tcp_sock *tp = tcp_sk(sk); struct inet_connection_sock *icsk = inet_csk(sk); @@ -3037,7 +3037,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, if (optlen < 1) return -EINVAL; - val = strncpy_from_user(name, optval, + val = strncpy_from_sockptr(name, optval, min_t(long, TCP_CA_NAME_MAX-1, optlen)); if (val < 0) return -EFAULT; @@ -3056,7 +3056,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, if (optlen < 1) return -EINVAL; - val = strncpy_from_user(name, optval, + val = strncpy_from_sockptr(name, optval, min_t(long, TCP_ULP_NAME_MAX - 1, optlen)); if (val < 0) @@ -3079,7 +3079,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, optlen != TCP_FASTOPEN_KEY_BUF_LENGTH) return -EINVAL; - if (copy_from_user(key, optval, optlen)) + if (copy_from_sockptr(key, optval, optlen)) return -EFAULT; if (optlen == TCP_FASTOPEN_KEY_BUF_LENGTH) @@ -3095,7 +3095,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; lock_sock(sk); @@ -3174,9 +3174,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, if (!tp->repair) err = -EINVAL; else if (sk->sk_state == TCP_ESTABLISHED) - err = tcp_repair_options_est(sk, - (struct tcp_repair_opt __user *)optval, - optlen); + err = tcp_repair_options_est(sk, optval, optlen); else err = -EPERM; break; @@ -3249,8 +3247,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, #ifdef CONFIG_TCP_MD5SIG case TCP_MD5SIG: case TCP_MD5SIG_EXT: - err = tp->af_specific->md5_parse(sk, optname, - USER_SOCKPTR(optval), optlen); + err = tp->af_specific->md5_parse(sk, optname, optval, optlen); break; #endif case TCP_USER_TIMEOUT: @@ -3334,7 +3331,8 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, if (level != SOL_TCP) return icsk->icsk_af_ops->setsockopt(sk, level, optname, optval, optlen); - return do_tcp_setsockopt(sk, level, optname, optval, optlen); + return do_tcp_setsockopt(sk, level, optname, USER_SOCKPTR(optval), + optlen); } EXPORT_SYMBOL(tcp_setsockopt); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oO2rB0cqGV/YgAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:12:23 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 8DfhBUcqGV8blAEAlScrYA (envelope-from ); Thu, 23 Jul 2020 08:12:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DF3AB41D7B; Thu, 23 Jul 2020 08:12:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728031AbgGWGKv (ORCPT + 1 other); Thu, 23 Jul 2020 02:10:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727779AbgGWGJy (ORCPT ); Thu, 23 Jul 2020 02:09:54 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 845FAC0619E2; Wed, 22 Jul 2020 23:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=B8ko5pqj9E5RJoiDMAT4LWCptgAPGsTT9yGUOg+zWgY=; b=MjJqnKULSWCVH3PByQuNM/qNXX HtMB9dNpDBTWgJugcO7sE/5ko9tHLFvQQR2XB+seIcDgNTq0BIUT+jAS9YnxntKaMacKvA3QzLDz+ zGlGK28S4DDyYfe4AW2lZ7egTVp764ymWynHmgHFOMbVH5dRl56eBZKRzkiXR6tj4nh5pm3fHpJ0C D7KIViHus2vbs8lwyCCqFoTyuA7CUg8gUDjDutcOgepeoe8H4V4VclrD+KVF5iFtHs5JYWGRp57sI ctRlfcOu0L+2rfrA9FFOOVRguL7CObocmaxk45GM10m0ZW5jysNmi0VmrX1q8LwS7ICnZPKjKkGuJ piwC5ebg==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQG-0003oW-J1; Thu, 23 Jul 2020 06:09:41 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 22/26] net/udp: switch udp_lib_setsockopt to sockptr_t Date: Thu, 23 Jul 2020 08:09:04 +0200 Message-Id: <20200723060908.50081-23-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: DF3AB41D7B X-Rspamd-UID: 29ef71 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/net/udp.h | 2 +- net/ipv4/udp.c | 7 ++++--- net/ipv6/udp.c | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/net/udp.h b/include/net/udp.h index 17a9e86a807638..295d52a7359827 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -306,7 +306,7 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, int udp_lib_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); int udp_lib_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen, + sockptr_t optval, unsigned int optlen, int (*push_pending_frames)(struct sock *)); struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, __be32 daddr, __be16 dport, int dif); diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index bb95cddcb040a6..c6cb2d09dbc75e 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2588,7 +2588,7 @@ void udp_destroy_sock(struct sock *sk) * Socket option code for UDP */ int udp_lib_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen, + sockptr_t optval, unsigned int optlen, int (*push_pending_frames)(struct sock *)) { struct udp_sock *up = udp_sk(sk); @@ -2599,7 +2599,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; valbool = val ? 1 : 0; @@ -2707,7 +2707,8 @@ int udp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { if (level == SOL_UDP || level == SOL_UDPLITE) - return udp_lib_setsockopt(sk, level, optname, optval, optlen, + return udp_lib_setsockopt(sk, level, optname, + USER_SOCKPTR(optval), optlen, udp_push_pending_frames); return ip_setsockopt(sk, level, optname, optval, optlen); } diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 7c1143feb2bf7e..2df1e6c9d7cbf6 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1622,7 +1622,8 @@ int udpv6_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { if (level == SOL_UDP || level == SOL_UDPLITE) - return udp_lib_setsockopt(sk, level, optname, optval, optlen, + return udp_lib_setsockopt(sk, level, optname, + USER_SOCKPTR(optval), optlen, udp_v6_push_pending_frames); return ipv6_setsockopt(sk, level, optname, optval, optlen); } -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gMctDU8qGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:12:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cPz6C08qGV+QCQAADc0bRg (envelope-from ); Thu, 23 Jul 2020 08:12:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CD79C40675; Thu, 23 Jul 2020 08:12:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728014AbgGWGKu (ORCPT + 1 other); Thu, 23 Jul 2020 02:10:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726858AbgGWGJy (ORCPT ); Thu, 23 Jul 2020 02:09:54 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53E40C0619DC; Wed, 22 Jul 2020 23:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=W9DCuh+32aeos/novSkbFq+x7P6ru3xc8ujj+xYmqPk=; b=fJ+b1K7ZCdgn1uMZIKEm5HMeBR 0cIOSj/xV0MndLXB38ioamT2fc/m1Ax6l0HP5ni25UAb3ciFwPAFvcfK8iMgJOTrnPfJ4a+lPRZbr sGPRZxDlz2wnHW2sr7HnoERsDkThHWPxehSVn1fdikFweIgYpxItFOdf/kTtrgpueInOcKg4K/XT+ fzkHXbim1yQAU8DDym+kUNqF2vH76iCHONXu2eXi1quSbjcmU8oPbYyYJV7RbFsry7z90ak2XM3Pr fdoogmLDYgKBNbdv7llf8EKbFsoHvSRq/nBvwBkhuKQUifvS0NA745IiONvfik2+SRxgIN6Ddwzra qMFG8L5Q==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQH-0003p4-T5; Thu, 23 Jul 2020 06:09:42 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 23/26] net/tcp: switch ->md5_parse to sockptr_t Date: Thu, 23 Jul 2020 08:09:05 +0200 Message-Id: <20200723060908.50081-24-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: CD79C40675 X-Rspamd-UID: 97ed47 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/net/tcp.h | 2 +- net/ipv4/tcp.c | 3 ++- net/ipv4/tcp_ipv4.c | 4 ++-- net/ipv6/tcp_ipv6.c | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 9f7f7c0c110451..e3c8e1d820214c 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2002,7 +2002,7 @@ struct tcp_sock_af_ops { const struct sk_buff *skb); int (*md5_parse)(struct sock *sk, int optname, - char __user *optval, + sockptr_t optval, int optlen); #endif }; diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 58ede3d62b2e2c..49bf15c27deac7 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3249,7 +3249,8 @@ static int do_tcp_setsockopt(struct sock *sk, int level, #ifdef CONFIG_TCP_MD5SIG case TCP_MD5SIG: case TCP_MD5SIG_EXT: - err = tp->af_specific->md5_parse(sk, optname, optval, optlen); + err = tp->af_specific->md5_parse(sk, optname, + USER_SOCKPTR(optval), optlen); break; #endif case TCP_USER_TIMEOUT: diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index daa39d33702b13..f8913923a6c05e 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1195,7 +1195,7 @@ static void tcp_clear_md5_list(struct sock *sk) } static int tcp_v4_parse_md5_keys(struct sock *sk, int optname, - char __user *optval, int optlen) + sockptr_t optval, int optlen) { struct tcp_md5sig cmd; struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr; @@ -1206,7 +1206,7 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, int optname, if (optlen < sizeof(cmd)) return -EINVAL; - if (copy_from_user(&cmd, optval, sizeof(cmd))) + if (copy_from_sockptr(&cmd, optval, sizeof(cmd))) return -EFAULT; if (sin->sin_family != AF_INET) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index c34b7834fd84a8..305870a72352d6 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -567,7 +567,7 @@ static struct tcp_md5sig_key *tcp_v6_md5_lookup(const struct sock *sk, } static int tcp_v6_parse_md5_keys(struct sock *sk, int optname, - char __user *optval, int optlen) + sockptr_t optval, int optlen) { struct tcp_md5sig cmd; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&cmd.tcpm_addr; @@ -577,7 +577,7 @@ static int tcp_v6_parse_md5_keys(struct sock *sk, int optname, if (optlen < sizeof(cmd)) return -EINVAL; - if (copy_from_user(&cmd, optval, sizeof(cmd))) + if (copy_from_sockptr(&cmd, optval, sizeof(cmd))) return -EFAULT; if (sin6->sin6_family != AF_INET6) -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gL1XKWMqGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:12:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WGmAJ2MqGV/9BgAAgupzMw (envelope-from ); Thu, 23 Jul 2020 08:12:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5B7E640873; Thu, 23 Jul 2020 08:12:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727058AbgGWGJw (ORCPT + 1 other); Thu, 23 Jul 2020 02:09:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726929AbgGWGJm (ORCPT ); Thu, 23 Jul 2020 02:09:42 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21D86C0619DC; Wed, 22 Jul 2020 23:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=AgSxP7iVdXVEFS4IDrHx6ue4s0yWgQSmSEoUvewskkk=; b=UubGJx5UZwlfDZKlY0aminCkgD TkOTjy6IQbG5S2CEEDBygCyqeSmFkmj050BgX/zCO7ZQhoijKBeefKdIYxudTh+C8mO8wrlBjkkdc CNAQqLasagTDFNnE8YJX420qR8hR+zVHIihD5njNfOM1haYOm78uiHJZCD2fJk/pHLXt8cJwzck2G d9T/mnVxBvuzPP+bsp721z5n9lnXCWiykSYhCnIy/x6+dGK6dwI9GOXv9d05ZojqKq522p8klLoU/ qzRiBLYFytH94kjENFy3YjMg30MfbSZRFnPejzFB/dvpRHoO2rOz932v79OqbUsmd5ii7pjIoA9EI TL3hATzg==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQ6-0003mG-1B; Thu, 23 Jul 2020 06:09:31 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 15/26] net/ipv4: merge ip_options_get and ip_options_get_from_user Date: Thu, 23 Jul 2020 08:08:57 +0200 Message-Id: <20200723060908.50081-16-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5B7E640873 X-Rspamd-UID: 8b0db2 Use the sockptr_t type to merge the versions. Signed-off-by: Christoph Hellwig --- include/net/ip.h | 5 ++--- net/ipv4/ip_options.c | 43 +++++++++++------------------------------- net/ipv4/ip_sockglue.c | 7 ++++--- 3 files changed, 17 insertions(+), 38 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index 3d34acc95ca825..d66ad3a9522081 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -707,9 +708,7 @@ int __ip_options_compile(struct net *net, struct ip_options *opt, int ip_options_compile(struct net *net, struct ip_options *opt, struct sk_buff *skb); int ip_options_get(struct net *net, struct ip_options_rcu **optp, - unsigned char *data, int optlen); -int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp, - unsigned char __user *data, int optlen); + sockptr_t data, int optlen); void ip_options_undo(struct ip_options *opt); void ip_forward_options(struct sk_buff *skb); int ip_options_rcv_srr(struct sk_buff *skb, struct net_device *dev); diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index ddaa01ec2bce82..948747aac4e2d0 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -519,15 +519,20 @@ void ip_options_undo(struct ip_options *opt) } } -static struct ip_options_rcu *ip_options_get_alloc(const int optlen) +int ip_options_get(struct net *net, struct ip_options_rcu **optp, + sockptr_t data, int optlen) { - return kzalloc(sizeof(struct ip_options_rcu) + ((optlen + 3) & ~3), + struct ip_options_rcu *opt; + + opt = kzalloc(sizeof(struct ip_options_rcu) + ((optlen + 3) & ~3), GFP_KERNEL); -} + if (!opt) + return -ENOMEM; + if (optlen && copy_from_sockptr(opt->opt.__data, data, optlen)) { + kfree(opt); + return -EFAULT; + } -static int ip_options_get_finish(struct net *net, struct ip_options_rcu **optp, - struct ip_options_rcu *opt, int optlen) -{ while (optlen & 3) opt->opt.__data[optlen++] = IPOPT_END; opt->opt.optlen = optlen; @@ -540,32 +545,6 @@ static int ip_options_get_finish(struct net *net, struct ip_options_rcu **optp, return 0; } -int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp, - unsigned char __user *data, int optlen) -{ - struct ip_options_rcu *opt = ip_options_get_alloc(optlen); - - if (!opt) - return -ENOMEM; - if (optlen && copy_from_user(opt->opt.__data, data, optlen)) { - kfree(opt); - return -EFAULT; - } - return ip_options_get_finish(net, optp, opt, optlen); -} - -int ip_options_get(struct net *net, struct ip_options_rcu **optp, - unsigned char *data, int optlen) -{ - struct ip_options_rcu *opt = ip_options_get_alloc(optlen); - - if (!opt) - return -ENOMEM; - if (optlen) - memcpy(opt->opt.__data, data, optlen); - return ip_options_get_finish(net, optp, opt, optlen); -} - void ip_forward_options(struct sk_buff *skb) { struct ip_options *opt = &(IPCB(skb)->opt); diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index ac495b0cff8ffb..b12f39b52008a3 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -280,7 +280,8 @@ int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc, err = cmsg->cmsg_len - sizeof(struct cmsghdr); /* Our caller is responsible for freeing ipc->opt */ - err = ip_options_get(net, &ipc->opt, CMSG_DATA(cmsg), + err = ip_options_get(net, &ipc->opt, + KERNEL_SOCKPTR(CMSG_DATA(cmsg)), err < 40 ? err : 40); if (err) return err; @@ -940,8 +941,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, if (optlen > 40) goto e_inval; - err = ip_options_get_from_user(sock_net(sk), &opt, - optval, optlen); + err = ip_options_get(sock_net(sk), &opt, USER_SOCKPTR(optval), + optlen); if (err) break; old = rcu_dereference_protected(inet->inet_opt, -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CFd9LXMqGV99mAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:13:07 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id APe0K3MqGV/3rwAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 08:13:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 019DE40875; Thu, 23 Jul 2020 08:13:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726317AbgGWGLX (ORCPT + 1 other); Thu, 23 Jul 2020 02:11:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727048AbgGWGJw (ORCPT ); Thu, 23 Jul 2020 02:09:52 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8380C0619E2; Wed, 22 Jul 2020 23:09:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=GQn0sG9CSctd3r9tXWfKFi/perePeGXKxZIJGtFsY+Q=; b=QX5kiNG9Mwf67jSYnc8F3JQRuj eD5Jx3XocBRQdOwUIvmulA1hMowdYmmsUZnlu3lCF7Y6mibi44Y4iDm4Zi7BOrQA6e86Pj+JHpy8/ I6Mes3/vFGcEWZxIX8zdXJ+R38hmzbfD3PVIDhM9ohhK4YQo+mcf+zDCdHvKXG5lyVxlKNw+al3kb siGjFJH0RvHtOFMdBa2rF5n8Tw+Smc04NJFYwA2Pb3LYk1X9InpguI9jkCIWFJuFZSHECQ6AaAkU2 lg/BxDDv30z3HCW4Grph5mBkzmMBR0eM0vYsJEzLIwWHzG8ep5/ecDlliCWVgjFAqGMqHjwYFaUjr LRdbOWgQ==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQF-0003oA-3l; Thu, 23 Jul 2020 06:09:39 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 21/26] net/ipv6: switch do_ipv6_setsockopt to sockptr_t Date: Thu, 23 Jul 2020 08:09:03 +0200 Message-Id: <20200723060908.50081-22-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 019DE40875 X-Rspamd-UID: 64cdc6 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- net/ipv6/ipv6_sockglue.c | 66 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 90442c8366dff2..dcd000a5a9b124 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -136,15 +136,15 @@ static bool setsockopt_needs_rtnl(int optname) return false; } -static int copy_group_source_from_user(struct group_source_req *greqs, - void __user *optval, int optlen) +static int copy_group_source_from_sockptr(struct group_source_req *greqs, + sockptr_t optval, int optlen) { if (in_compat_syscall()) { struct compat_group_source_req gr32; if (optlen < sizeof(gr32)) return -EINVAL; - if (copy_from_user(&gr32, optval, sizeof(gr32))) + if (copy_from_sockptr(&gr32, optval, sizeof(gr32))) return -EFAULT; greqs->gsr_interface = gr32.gsr_interface; greqs->gsr_group = gr32.gsr_group; @@ -152,7 +152,7 @@ static int copy_group_source_from_user(struct group_source_req *greqs, } else { if (optlen < sizeof(*greqs)) return -EINVAL; - if (copy_from_user(greqs, optval, sizeof(*greqs))) + if (copy_from_sockptr(greqs, optval, sizeof(*greqs))) return -EFAULT; } @@ -160,13 +160,13 @@ static int copy_group_source_from_user(struct group_source_req *greqs, } static int do_ipv6_mcast_group_source(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct group_source_req greqs; int omode, add; int ret; - ret = copy_group_source_from_user(&greqs, optval, optlen); + ret = copy_group_source_from_sockptr(&greqs, optval, optlen); if (ret) return ret; @@ -200,7 +200,7 @@ static int do_ipv6_mcast_group_source(struct sock *sk, int optname, return ip6_mc_source(add, omode, sk, &greqs); } -static int ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, +static int ipv6_set_mcast_msfilter(struct sock *sk, sockptr_t optval, int optlen) { struct group_filter *gsf; @@ -211,7 +211,7 @@ static int ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, if (optlen > sysctl_optmem_max) return -ENOBUFS; - gsf = memdup_user(optval, optlen); + gsf = memdup_sockptr(optval, optlen); if (IS_ERR(gsf)) return PTR_ERR(gsf); @@ -231,7 +231,7 @@ static int ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, return ret; } -static int compat_ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, +static int compat_ipv6_set_mcast_msfilter(struct sock *sk, sockptr_t optval, int optlen) { const int size0 = offsetof(struct compat_group_filter, gf_slist); @@ -251,7 +251,7 @@ static int compat_ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, gf32 = p + 4; /* we want ->gf_group and ->gf_slist aligned */ ret = -EFAULT; - if (copy_from_user(gf32, optval, optlen)) + if (copy_from_sockptr(gf32, optval, optlen)) goto out_free_p; /* numsrc >= (4G-140)/128 overflow in 32 bits */ @@ -276,14 +276,14 @@ static int compat_ipv6_set_mcast_msfilter(struct sock *sk, void __user *optval, } static int ipv6_mcast_join_leave(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct sockaddr_in6 *psin6; struct group_req greq; if (optlen < sizeof(greq)) return -EINVAL; - if (copy_from_user(&greq, optval, sizeof(greq))) + if (copy_from_sockptr(&greq, optval, sizeof(greq))) return -EFAULT; if (greq.gr_group.ss_family != AF_INET6) @@ -296,14 +296,14 @@ static int ipv6_mcast_join_leave(struct sock *sk, int optname, } static int compat_ipv6_mcast_join_leave(struct sock *sk, int optname, - void __user *optval, int optlen) + sockptr_t optval, int optlen) { struct compat_group_req gr32; struct sockaddr_in6 *psin6; if (optlen < sizeof(gr32)) return -EINVAL; - if (copy_from_user(&gr32, optval, sizeof(gr32))) + if (copy_from_sockptr(&gr32, optval, sizeof(gr32))) return -EFAULT; if (gr32.gr_group.ss_family != AF_INET6) @@ -315,7 +315,7 @@ static int compat_ipv6_mcast_join_leave(struct sock *sk, int optname, return ipv6_sock_mc_drop(sk, gr32.gr_interface, &psin6->sin6_addr); } -static int ipv6_set_opt_hdr(struct sock *sk, int optname, void __user *optval, +static int ipv6_set_opt_hdr(struct sock *sk, int optname, sockptr_t optval, int optlen) { struct ipv6_pinfo *np = inet6_sk(sk); @@ -332,14 +332,14 @@ static int ipv6_set_opt_hdr(struct sock *sk, int optname, void __user *optval, * length, per RFC3542. */ if (optlen > 0) { - if (!optval) + if (sockptr_is_null(optval)) return -EINVAL; if (optlen < sizeof(struct ipv6_opt_hdr) || optlen & 0x7 || optlen > 8 * 255) return -EINVAL; - new = memdup_user(optval, optlen); + new = memdup_sockptr(optval, optlen); if (IS_ERR(new)) return PTR_ERR(new); if (unlikely(ipv6_optlen(new) > optlen)) { @@ -390,7 +390,7 @@ static int ipv6_set_opt_hdr(struct sock *sk, int optname, void __user *optval, } static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, - char __user *optval, unsigned int optlen) + sockptr_t optval, unsigned int optlen) { struct ipv6_pinfo *np = inet6_sk(sk); struct net *net = sock_net(sk); @@ -398,11 +398,11 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, int retv = -ENOPROTOOPT; bool needs_rtnl = setsockopt_needs_rtnl(optname); - if (!optval) + if (sockptr_is_null(optval)) val = 0; else { if (optlen >= sizeof(int)) { - if (get_user(val, (int __user *) optval)) + if (copy_from_sockptr(&val, optval, sizeof(val))) return -EFAULT; } else val = 0; @@ -411,8 +411,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, valbool = (val != 0); if (ip6_mroute_opt(optname)) - return ip6_mroute_setsockopt(sk, optname, USER_SOCKPTR(optval), - optlen); + return ip6_mroute_setsockopt(sk, optname, optval, optlen); if (needs_rtnl) rtnl_lock(); @@ -663,12 +662,13 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, if (optlen == 0) goto e_inval; - else if (optlen < sizeof(struct in6_pktinfo) || !optval) + else if (optlen < sizeof(struct in6_pktinfo) || + sockptr_is_null(optval)) goto e_inval; - if (copy_from_user(&pkt, optval, sizeof(struct in6_pktinfo))) { - retv = -EFAULT; - break; + if (copy_from_sockptr(&pkt, optval, sizeof(pkt))) { + retv = -EFAULT; + break; } if (!sk_dev_equal_l3scope(sk, pkt.ipi6_ifindex)) goto e_inval; @@ -709,7 +709,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, refcount_set(&opt->refcnt, 1); opt->tot_len = sizeof(*opt) + optlen; retv = -EFAULT; - if (copy_from_user(opt+1, optval, optlen)) + if (copy_from_sockptr(opt + 1, optval, optlen)) goto done; msg.msg_controllen = optlen; @@ -831,7 +831,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, break; retv = -EFAULT; - if (copy_from_user(&mreq, optval, sizeof(struct ipv6_mreq))) + if (copy_from_sockptr(&mreq, optval, sizeof(struct ipv6_mreq))) break; if (optname == IPV6_ADD_MEMBERSHIP) @@ -849,7 +849,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, goto e_inval; retv = -EFAULT; - if (copy_from_user(&mreq, optval, sizeof(struct ipv6_mreq))) + if (copy_from_sockptr(&mreq, optval, sizeof(struct ipv6_mreq))) break; if (optname == IPV6_JOIN_ANYCAST) @@ -929,15 +929,14 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, retv = 0; break; case IPV6_FLOWLABEL_MGR: - retv = ipv6_flowlabel_opt(sk, USER_SOCKPTR(optval), optlen); + retv = ipv6_flowlabel_opt(sk, optval, optlen); break; case IPV6_IPSEC_POLICY: case IPV6_XFRM_POLICY: retv = -EPERM; if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) break; - retv = xfrm_user_policy(sk, optname, USER_SOCKPTR(optval), - optlen); + retv = xfrm_user_policy(sk, optname, optval, optlen); break; case IPV6_ADDR_PREFERENCES: @@ -992,7 +991,8 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, if (level != SOL_IPV6) return -ENOPROTOOPT; - err = do_ipv6_setsockopt(sk, level, optname, optval, optlen); + err = do_ipv6_setsockopt(sk, level, optname, USER_SOCKPTR(optval), + optlen); #ifdef CONFIG_NETFILTER /* we need to exclude all possible ENOPROTOOPTs except default case */ if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY && -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MNeKCXwqGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:13:16 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id wEvTB3wqGV/9BgAAgupzMw (envelope-from ); Thu, 23 Jul 2020 08:13:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CAF8E40033; Thu, 23 Jul 2020 08:13:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728123AbgGWGLf (ORCPT + 1 other); Thu, 23 Jul 2020 02:11:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbgGWGJv (ORCPT ); Thu, 23 Jul 2020 02:09:51 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA999C0619DC; Wed, 22 Jul 2020 23:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=mHiWtESnfpmKOGnGR9J/VvKy447qDpvbyAZDADMp9hY=; b=Gi7Go2u+fkcKAHjWWVRHPnv63N Y5wm/NGJ3YEIP3H54J9Y/ypxMj150A7NMUhmNveZRtZJ2pYVYRsZcmgKhuKhxVxC7Redsbb+O/81i fGIlQ9tNAWdl1Hkfeec2Meb64han1DNgmxuwAULfzNG3E1PnD5gz87po+HuwjTdg6MQ4V5S64kIX1 XjSOF9i0AgfaeyNKUKwaUo7i9Of3zyl20novryBp7FE/7CQWJUWOhkuRXXwHIX/ieM/X8HDOQJicd xfvPqnpZUvvRe7IhEIkxmwLayvXHLpSIjLSDPErKJIV6SzuPGnPxa5f+mzZafn/nkGGcW4k3MkZvM w6+b9nNQ==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQD-0003np-OJ; Thu, 23 Jul 2020 06:09:38 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 20/26] net/ipv6: factor out a ipv6_set_opt_hdr helper Date: Thu, 23 Jul 2020 08:09:02 +0200 Message-Id: <20200723060908.50081-21-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: CAF8E40033 X-Rspamd-UID: 6ce30c Factour out a helper to set the IPv6 option headers from do_ipv6_setsockopt. Signed-off-by: Christoph Hellwig --- net/ipv6/ipv6_sockglue.c | 150 +++++++++++++++++++-------------------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 3897fb55372d38..90442c8366dff2 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -315,6 +315,80 @@ static int compat_ipv6_mcast_join_leave(struct sock *sk, int optname, return ipv6_sock_mc_drop(sk, gr32.gr_interface, &psin6->sin6_addr); } +static int ipv6_set_opt_hdr(struct sock *sk, int optname, void __user *optval, + int optlen) +{ + struct ipv6_pinfo *np = inet6_sk(sk); + struct ipv6_opt_hdr *new = NULL; + struct net *net = sock_net(sk); + struct ipv6_txoptions *opt; + int err; + + /* hop-by-hop / destination options are privileged option */ + if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW)) + return -EPERM; + + /* remove any sticky options header with a zero option + * length, per RFC3542. + */ + if (optlen > 0) { + if (!optval) + return -EINVAL; + if (optlen < sizeof(struct ipv6_opt_hdr) || + optlen & 0x7 || + optlen > 8 * 255) + return -EINVAL; + + new = memdup_user(optval, optlen); + if (IS_ERR(new)) + return PTR_ERR(new); + if (unlikely(ipv6_optlen(new) > optlen)) { + kfree(new); + return -EINVAL; + } + } + + opt = rcu_dereference_protected(np->opt, lockdep_sock_is_held(sk)); + opt = ipv6_renew_options(sk, opt, optname, new); + kfree(new); + if (IS_ERR(opt)) + return PTR_ERR(opt); + + /* routing header option needs extra check */ + err = -EINVAL; + if (optname == IPV6_RTHDR && opt && opt->srcrt) { + struct ipv6_rt_hdr *rthdr = opt->srcrt; + switch (rthdr->type) { +#if IS_ENABLED(CONFIG_IPV6_MIP6) + case IPV6_SRCRT_TYPE_2: + if (rthdr->hdrlen != 2 || rthdr->segments_left != 1) + goto sticky_done; + break; +#endif + case IPV6_SRCRT_TYPE_4: + { + struct ipv6_sr_hdr *srh = + (struct ipv6_sr_hdr *)opt->srcrt; + + if (!seg6_validate_srh(srh, optlen, false)) + goto sticky_done; + break; + } + default: + goto sticky_done; + } + } + + err = 0; + opt = ipv6_update_options(sk, opt); +sticky_done: + if (opt) { + atomic_sub(opt->tot_len, &sk->sk_omem_alloc); + txopt_put(opt); + } + return err; +} + static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { @@ -580,82 +654,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, case IPV6_RTHDRDSTOPTS: case IPV6_RTHDR: case IPV6_DSTOPTS: - { - struct ipv6_txoptions *opt; - struct ipv6_opt_hdr *new = NULL; - - /* hop-by-hop / destination options are privileged option */ - retv = -EPERM; - if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW)) - break; - - /* remove any sticky options header with a zero option - * length, per RFC3542. - */ - if (optlen == 0) - optval = NULL; - else if (!optval) - goto e_inval; - else if (optlen < sizeof(struct ipv6_opt_hdr) || - optlen & 0x7 || optlen > 8 * 255) - goto e_inval; - else { - new = memdup_user(optval, optlen); - if (IS_ERR(new)) { - retv = PTR_ERR(new); - break; - } - if (unlikely(ipv6_optlen(new) > optlen)) { - kfree(new); - goto e_inval; - } - } - - opt = rcu_dereference_protected(np->opt, - lockdep_sock_is_held(sk)); - opt = ipv6_renew_options(sk, opt, optname, new); - kfree(new); - if (IS_ERR(opt)) { - retv = PTR_ERR(opt); - break; - } - - /* routing header option needs extra check */ - retv = -EINVAL; - if (optname == IPV6_RTHDR && opt && opt->srcrt) { - struct ipv6_rt_hdr *rthdr = opt->srcrt; - switch (rthdr->type) { -#if IS_ENABLED(CONFIG_IPV6_MIP6) - case IPV6_SRCRT_TYPE_2: - if (rthdr->hdrlen != 2 || - rthdr->segments_left != 1) - goto sticky_done; - - break; -#endif - case IPV6_SRCRT_TYPE_4: - { - struct ipv6_sr_hdr *srh = (struct ipv6_sr_hdr *) - opt->srcrt; - - if (!seg6_validate_srh(srh, optlen, false)) - goto sticky_done; - break; - } - default: - goto sticky_done; - } - } - - retv = 0; - opt = ipv6_update_options(sk, opt); -sticky_done: - if (opt) { - atomic_sub(opt->tot_len, &sk->sk_omem_alloc); - txopt_put(opt); - } + retv = ipv6_set_opt_hdr(sk, optname, optval, optlen); break; - } case IPV6_PKTINFO: { -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UGi3Jo0qGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:13:33 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id KL2vJI0qGV95qgAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 08:13:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4888B40869; Thu, 23 Jul 2020 08:13:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726997AbgGWGJu (ORCPT + 1 other); Thu, 23 Jul 2020 02:09:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726893AbgGWGJr (ORCPT ); Thu, 23 Jul 2020 02:09:47 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 808EDC0619E2; Wed, 22 Jul 2020 23:09:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=QrqaYh4fSMgupA4iEFhXoiD4XEjtKBO+4D3VptAqYus=; b=IgVGLyqCozX/nHw3MIQ3FpanQV jLXIw5Td5nt6zIvvCqGUnFabfrveTd++UbO9scS2aRy/PoKQeztwbLyv6jvpJEEtyLYhY/m6rTBL6 xKVVcTbM5bzajlkFK+OMU/FCH/VUQb3QOSfT60/o0JP8TjPIteycrNbr+PR78U+fooJ7APKnL+yYS LnZShKyk4tzuP+1iFVKpCOrQNDU1b9MW81GHnHJhLWwat6fM0aDFsEEbWZC8tBP1kpjEiRUmCTv9j fB/bPDia78CQ2+QlSJR5h2YA0Ym1SepAIfAmUqUk8+ueyWBGAtskROW4abUO80BOV+yb8+9iuyose 7pSKeTKQ==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUQ9-0003n1-PK; Thu, 23 Jul 2020 06:09:34 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 17/26] net/ipv6: switch ip6_mroute_setsockopt to sockptr_t Date: Thu, 23 Jul 2020 08:08:59 +0200 Message-Id: <20200723060908.50081-18-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4888B40869 X-Rspamd-UID: a88ce4 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/linux/mroute6.h | 8 ++++---- net/ipv6/ip6mr.c | 17 +++++++++-------- net/ipv6/ipv6_sockglue.c | 3 ++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/linux/mroute6.h b/include/linux/mroute6.h index c4a45859f586d4..bc351a85ce9b9c 100644 --- a/include/linux/mroute6.h +++ b/include/linux/mroute6.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #ifdef CONFIG_IPV6_MROUTE @@ -25,7 +26,7 @@ static inline int ip6_mroute_opt(int opt) struct sock; #ifdef CONFIG_IPV6_MROUTE -extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); +extern int ip6_mroute_setsockopt(struct sock *, int, sockptr_t, unsigned int); extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *); extern int ip6_mr_input(struct sk_buff *skb); extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg); @@ -33,9 +34,8 @@ extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *ar extern int ip6_mr_init(void); extern void ip6_mr_cleanup(void); #else -static inline -int ip6_mroute_setsockopt(struct sock *sock, - int optname, char __user *optval, unsigned int optlen) +static inline int ip6_mroute_setsockopt(struct sock *sock, int optname, + sockptr_t optval, unsigned int optlen) { return -ENOPROTOOPT; } diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 1f4d20e97c07f9..06b0d2c329b94b 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1629,7 +1629,8 @@ EXPORT_SYMBOL(mroute6_is_socket); * MOSPF/PIM router set up we can clean this up. */ -int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, unsigned int optlen) +int ip6_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, + unsigned int optlen) { int ret, parent = 0; struct mif6ctl vif; @@ -1665,7 +1666,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns case MRT6_ADD_MIF: if (optlen < sizeof(vif)) return -EINVAL; - if (copy_from_user(&vif, optval, sizeof(vif))) + if (copy_from_sockptr(&vif, optval, sizeof(vif))) return -EFAULT; if (vif.mif6c_mifi >= MAXMIFS) return -ENFILE; @@ -1678,7 +1679,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns case MRT6_DEL_MIF: if (optlen < sizeof(mifi_t)) return -EINVAL; - if (copy_from_user(&mifi, optval, sizeof(mifi_t))) + if (copy_from_sockptr(&mifi, optval, sizeof(mifi_t))) return -EFAULT; rtnl_lock(); ret = mif6_delete(mrt, mifi, 0, NULL); @@ -1697,7 +1698,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns case MRT6_DEL_MFC_PROXY: if (optlen < sizeof(mfc)) return -EINVAL; - if (copy_from_user(&mfc, optval, sizeof(mfc))) + if (copy_from_sockptr(&mfc, optval, sizeof(mfc))) return -EFAULT; if (parent == 0) parent = mfc.mf6cc_parent; @@ -1718,7 +1719,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns if (optlen != sizeof(flags)) return -EINVAL; - if (get_user(flags, (int __user *)optval)) + if (copy_from_sockptr(&flags, optval, sizeof(flags))) return -EFAULT; rtnl_lock(); mroute_clean_tables(mrt, flags); @@ -1735,7 +1736,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns if (optlen != sizeof(v)) return -EINVAL; - if (get_user(v, (int __user *)optval)) + if (copy_from_sockptr(&v, optval, sizeof(v))) return -EFAULT; mrt->mroute_do_assert = v; return 0; @@ -1748,7 +1749,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns if (optlen != sizeof(v)) return -EINVAL; - if (get_user(v, (int __user *)optval)) + if (copy_from_sockptr(&v, optval, sizeof(v))) return -EFAULT; v = !!v; rtnl_lock(); @@ -1769,7 +1770,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns if (optlen != sizeof(u32)) return -EINVAL; - if (get_user(v, (u32 __user *)optval)) + if (copy_from_sockptr(&v, optval, sizeof(v))) return -EFAULT; /* "pim6reg%u" should not exceed 16 bytes (IFNAMSIZ) */ if (v != RT_TABLE_DEFAULT && v >= 100000000) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 85892b35cff7b3..119dfaf5f4bb26 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -337,7 +337,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, valbool = (val != 0); if (ip6_mroute_opt(optname)) - return ip6_mroute_setsockopt(sk, optname, optval, optlen); + return ip6_mroute_setsockopt(sk, optname, USER_SOCKPTR(optval), + optlen); if (needs_rtnl) rtnl_lock(); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ePQNNSkrGV/YgAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:16:09 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IEsHMykrGV/CmQAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 08:16:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 87DE540CB4; Thu, 23 Jul 2020 08:16:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726639AbgGWGJc (ORCPT + 1 other); Thu, 23 Jul 2020 02:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726535AbgGWGJb (ORCPT ); Thu, 23 Jul 2020 02:09:31 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12214C0619DC; Wed, 22 Jul 2020 23:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=gIo3u97zH0JSQ3GhoDfa3dDtIgYeQtsIRo6GTGYyy+8=; b=mnzygY2xIJOplQLdTA5DuEH0ik I+dSofdIWj5h6Q6sJXrxRQQH9lr8q8RznRktaWQgsjSk6tKhswT8dDrOuAKoDyVoNvpwziRMDygs5 V4f5W2mIHJSUYcOuW1p5Ir6U67Prk8VRUBRy8hjQ53gk5FH2pKOrOAD/RP/H1dTADr2OmbTj+6npM 7vG9oWid8LWVlZMGnM3G1KLxrq+C33rTvftxBYoCfkRRZmUpij+cYvZefhDKfixG8mJiKhqsX7AnE al8lhKCsReWSNohktTvtZM7aCBVtmd7q9BjtTavU2c+SGMWI34+tsLChaRrBdfoinRvNTW8QTALA1 h8FbOCKA==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUPl-0003jb-F1; Thu, 23 Jul 2020 06:09:09 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: get rid of the address_space override in setsockopt v2 Date: Thu, 23 Jul 2020 08:08:42 +0200 Message-Id: <20200723060908.50081-1-hch@lst.de> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 87DE540CB4 X-Rspamd-UID: e749c7 Hi Dave, setsockopt is the last place in architecture-independ code that still uses set_fs to force the uaccess routines to operate on kernel pointers. This series adds a new sockptr_t type that can contained either a kernel or user pointer, and which has accessors that do the right thing, and then uses it for setsockopt, starting by refactoring some low-level helpers and moving them over to it before finally doing the main setsockopt method. Note that apparently the eBPF selftests do not even cover this path, so the series has been tested with a testing patch that always copies the data first and passes a kernel pointer. This is something that works for most common sockopts (and is something that the ePBF support relies on), but unfortunately in various corner cases we either don't use the passed in length, or in one case actually copy data back from setsockopt, or in case of bpfilter straight out do not work with kernel pointers at all. Against net-next/master. Changes since v1: - check that users don't pass in kernel addresses - more bpfilter cleanups - cosmetic mptcp tweak Diffstat: crypto/af_alg.c | 7 drivers/crypto/chelsio/chtls/chtls_main.c | 18 - drivers/isdn/mISDN/socket.c | 4 include/linux/bpfilter.h | 6 include/linux/filter.h | 3 include/linux/mroute.h | 5 include/linux/mroute6.h | 8 include/linux/net.h | 4 include/linux/netfilter.h | 6 include/linux/netfilter/x_tables.h | 4 include/linux/sockptr.h | 132 ++++++++++++ include/net/inet_connection_sock.h | 3 include/net/ip.h | 7 include/net/ipv6.h | 6 include/net/sctp/structs.h | 2 include/net/sock.h | 7 include/net/tcp.h | 6 include/net/udp.h | 2 include/net/xfrm.h | 8 net/atm/common.c | 6 net/atm/common.h | 2 net/atm/pvc.c | 2 net/atm/svc.c | 6 net/ax25/af_ax25.c | 6 net/bluetooth/hci_sock.c | 8 net/bluetooth/l2cap_sock.c | 22 +- net/bluetooth/rfcomm/sock.c | 12 - net/bluetooth/sco.c | 6 net/bpfilter/bpfilter_kern.c | 55 ++--- net/bridge/netfilter/ebtables.c | 46 +--- net/caif/caif_socket.c | 8 net/can/j1939/socket.c | 12 - net/can/raw.c | 16 - net/core/filter.c | 6 net/core/sock.c | 36 +-- net/dccp/dccp.h | 2 net/dccp/proto.c | 20 - net/decnet/af_decnet.c | 13 - net/ieee802154/socket.c | 6 net/ipv4/bpfilter/sockopt.c | 16 - net/ipv4/ip_options.c | 43 +--- net/ipv4/ip_sockglue.c | 66 +++--- net/ipv4/ipmr.c | 14 - net/ipv4/netfilter/arp_tables.c | 33 +-- net/ipv4/netfilter/ip_tables.c | 29 +- net/ipv4/raw.c | 8 net/ipv4/tcp.c | 30 +- net/ipv4/tcp_ipv4.c | 4 net/ipv4/udp.c | 11 - net/ipv4/udp_impl.h | 4 net/ipv6/ip6_flowlabel.c | 317 ++++++++++++++++-------------- net/ipv6/ip6mr.c | 17 - net/ipv6/ipv6_sockglue.c | 203 +++++++++---------- net/ipv6/netfilter/ip6_tables.c | 28 +- net/ipv6/raw.c | 10 net/ipv6/tcp_ipv6.c | 4 net/ipv6/udp.c | 7 net/ipv6/udp_impl.h | 4 net/iucv/af_iucv.c | 4 net/kcm/kcmsock.c | 6 net/l2tp/l2tp_ppp.c | 4 net/llc/af_llc.c | 4 net/mptcp/protocol.c | 6 net/netfilter/ipvs/ip_vs_ctl.c | 4 net/netfilter/nf_sockopt.c | 2 net/netfilter/x_tables.c | 20 - net/netlink/af_netlink.c | 4 net/netrom/af_netrom.c | 4 net/nfc/llcp_sock.c | 6 net/packet/af_packet.c | 39 +-- net/phonet/pep.c | 4 net/rds/af_rds.c | 30 +- net/rds/rdma.c | 14 - net/rds/rds.h | 6 net/rose/af_rose.c | 4 net/rxrpc/af_rxrpc.c | 8 net/rxrpc/ar-internal.h | 4 net/rxrpc/key.c | 9 net/sctp/socket.c | 4 net/smc/af_smc.c | 4 net/socket.c | 24 -- net/tipc/socket.c | 8 net/tls/tls_main.c | 17 - net/vmw_vsock/af_vsock.c | 4 net/x25/af_x25.c | 4 net/xdp/xsk.c | 8 net/xfrm/xfrm_state.c | 6 87 files changed, 894 insertions(+), 743 deletions(-) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +Lu0GRw7GV+J4gEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 09:24:12 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0HeHFxw7GV/W6QAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 09:24:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 992E14081F; Thu, 23 Jul 2020 09:24:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726811AbgGWHYG (ORCPT + 1 other); Thu, 23 Jul 2020 03:24:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgGWHYF (ORCPT ); Thu, 23 Jul 2020 03:24:05 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90573C0619DC for ; Thu, 23 Jul 2020 00:24:05 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 8so5415273ybc.23 for ; Thu, 23 Jul 2020 00:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=1rFc2C3qEBkJLZQMUjy1a4YyM/Q6zmD4hR1Vcd0sfoA=; b=tRAQ051TyxfBb//V59tSUWLYb9FqA0qXeRphnre5QkValRd1KQzPf2yQLjXt9jlvgo dCijSgkJ2iQ7UiV0ACAmUgQfMzbkG1/QsRHS/4Hn0mJXeHT1rGFL+7Z8Sjugh1hGAkmU TeSvPlFxMkgQG/0uZcIdWIZc4vgF8YiLwE4oJv7I6cRWyArFEoSGCbtSOB5zPKHmT9ra TELzNVXIhDBorBH5/oG1ZavfzfiTfCN/EjZVAvlbiihdl7S+pV1qbhRkt4v5x9aCBe8r pgJsmDaKRF69N4QLSexsEBjNN7vFonGg1v+BNi534oenSaf7NYM1E0OCINxxKeYltDs4 WlYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=1rFc2C3qEBkJLZQMUjy1a4YyM/Q6zmD4hR1Vcd0sfoA=; b=sVAfvB2OE+4fV95XXXoRCqZRAtLfWXXuOZvM5Wkjk1FhjMMjjaOavXaPEaWwRUebck DGhize/omj3yM2XzVwnzaDcefRYn7AOA0aKbrstaURZFS4rNeGTNZE9rbxuTKcydr9lO PTdtLltsi/S27Dad+6DdkRXXIalEjpNML0I2ugGB1bcqoZ8xAy6YB+hh0VlWY8rtvbg6 +87RXBbhLpS+i5SCN8Izm9j8SY2bwbpd2l9AH0zptvFnSHicUUbOhIZ9RJ9yrHcJjY4q jTvqwOk/1YnDtDBNUd2tnZtVXLC1SCWR5z+7O6571Dv13qANB8q7V6HY91/op8KOU8ID hDfw== X-Gm-Message-State: AOAM532V0pQwy8McUY9kTuUpYE48PEei0B2YffOi3Vli+wJGa3w6PZyA RtBCtrS21YwLZ9ndFej05BC35mg+araToYhrFYPKklrkVCZ7mxbd8cMbi/PQTeMGNJn/shghhWQ aLLExoWBKKYpnqVRT8XBRZy0Qwj+RmXMpqYlWUf5XqXeQc18Q2xZ9pJ+6blvv+K9lg8AfCMdcg/ FI X-Google-Smtp-Source: ABdhPJxkZlhBfr0rV78I6MeBBh99ABYE0QJ2SgQVi+A4P2fK4OpxD7E7HNa9PLNaxJjLXZ7Rym0uoTNB+zou X-Received: by 2002:a25:d94d:: with SMTP id q74mr5187261ybg.387.1595489044783; Thu, 23 Jul 2020 00:24:04 -0700 (PDT) Date: Thu, 23 Jul 2020 15:23:40 +0800 In-Reply-To: <20200723152327.Bluez.v5.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Message-Id: <20200723152327.Bluez.v5.2.Ic16589fde45fac0c496dfca2fa27672059114c3b@changeid> Mime-Version: 1.0 References: <20200723152327.Bluez.v5.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog Subject: [Bluez PATCH v5 2/2] audio/transport: supply volume on transport init From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Yu Liu Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 992E14081F X-Rspamd-UID: af081b From: Archie Pusaka Sometimes the response of RegisterNotification for volume change event came before we create the transport for the corresponding device. If that happens, the volume will be stuck to an uninitialized invalid value. The property Volume of MediaTransport1 will also be left unaccessible. This patch supplies the initial volume when creating a new transport. The value is obtained from the media_player object. However, since the avrcp session might not be created by the time the transport is created, we also try to initialize the volume when creating avrcp session. Reviewed-by: Yu Liu --- Changes in v5: None Changes in v4: None Changes in v3: -Add missing library Changes in v2: -Get the volume from media_player instead of from separate list profiles/audio/avrcp.c | 27 ++++++++++++++++- profiles/audio/avrcp.h | 2 ++ profiles/audio/media.c | 60 +++++++++++++++++++++++++++++--------- profiles/audio/media.h | 2 ++ profiles/audio/transport.c | 2 +- 5 files changed, 77 insertions(+), 16 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 7a06c8353..4e7ff75c0 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -64,6 +64,7 @@ #include "avctp.h" #include "avrcp.h" #include "control.h" +#include "media.h" #include "player.h" #include "transport.h" @@ -1703,7 +1704,6 @@ static uint8_t avrcp_handle_request_continuing(struct avrcp *session, if (pending->pdu_id != pdu->params[0]) goto err; - len = 0; pending->attr_ids = player_fill_media_attribute(player, pending->attr_ids, @@ -4039,8 +4039,12 @@ static void target_init(struct avrcp *session) player = g_slist_nth_data(server->players, 0); if (player != NULL) { + int8_t init_volume; target->player = player; player->sessions = g_slist_prepend(player->sessions, session); + + init_volume = media_player_get_device_volume(session->dev); + media_transport_update_device_volume(session->dev, init_volume); } session->supported_events |= (1 << AVRCP_EVENT_STATUS_CHANGED) | @@ -4478,6 +4482,27 @@ int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify) avrcp_handle_set_volume, session); } +struct avrcp_player *avrcp_get_target_player_by_device(struct btd_device *dev) +{ + struct avrcp_server *server; + struct avrcp *session; + struct avrcp_data *target; + + server = find_server(servers, device_get_adapter(dev)); + if (server == NULL) + return NULL; + + session = find_session(server->sessions, dev); + if (session == NULL) + return NULL; + + target = session->target; + if (target == NULL) + return NULL; + + return target->player; +} + static int avrcp_connect(struct btd_service *service) { struct btd_device *dev = btd_service_get_device(service); diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index a08e7325e..159ccf846 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -116,3 +116,5 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands); size_t avrcp_browsing_general_reject(uint8_t *operands); + +struct avrcp_player *avrcp_get_target_player_by_device(struct btd_device *dev); diff --git a/profiles/audio/media.c b/profiles/audio/media.c index d4d58ec86..02bf82a49 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -239,6 +239,20 @@ static void media_endpoint_exit(DBusConnection *connection, void *user_data) media_endpoint_remove(endpoint); } +static struct media_adapter *find_adapter(struct btd_device *device) +{ + GSList *l; + + for (l = adapters; l; l = l->next) { + struct media_adapter *adapter = l->data; + + if (adapter->btd_adapter == device_get_adapter(device)) + return adapter; + } + + return NULL; +} + static void clear_configuration(struct media_endpoint *endpoint, struct media_transport *transport) { @@ -426,6 +440,33 @@ struct a2dp_config_data { a2dp_endpoint_config_t cb; }; +int8_t media_player_get_device_volume(struct btd_device *device) +{ + struct avrcp_player *target_player; + struct media_adapter *adapter; + GSList *l; + + if (!device) + return -1; + + target_player = avrcp_get_target_player_by_device(device); + if (!target_player) + return -1; + + adapter = find_adapter(device); + if (!adapter) + return -1; + + for (l = adapter->players; l; l = l->next) { + struct media_player *mp = l->data; + + if (mp->player == target_player) + return mp->volume; + } + + return -1; +} + static gboolean set_configuration(struct media_endpoint *endpoint, uint8_t *configuration, size_t size, media_endpoint_cb_t cb, @@ -439,6 +480,7 @@ static gboolean set_configuration(struct media_endpoint *endpoint, const char *path; DBusMessageIter iter; struct media_transport *transport; + int8_t init_volume; transport = find_device_transport(endpoint, device); @@ -451,6 +493,9 @@ static gboolean set_configuration(struct media_endpoint *endpoint, if (transport == NULL) return FALSE; + init_volume = media_player_get_device_volume(device); + media_transport_update_volume(transport, init_volume); + msg = dbus_message_new_method_call(endpoint->sender, endpoint->path, MEDIA_ENDPOINT_INTERFACE, "SetConfiguration"); @@ -646,20 +691,6 @@ static gboolean endpoint_init_a2dp_sink(struct media_endpoint *endpoint, return TRUE; } -static struct media_adapter *find_adapter(struct btd_device *device) -{ - GSList *l; - - for (l = adapters; l; l = l->next) { - struct media_adapter *adapter = l->data; - - if (adapter->btd_adapter == device_get_adapter(device)) - return adapter; - } - - return NULL; -} - static bool endpoint_properties_exists(const char *uuid, struct btd_device *dev, void *user_data) @@ -1779,6 +1810,7 @@ static struct media_player *media_player_create(struct media_adapter *adapter, mp->sender = g_strdup(sender); mp->path = g_strdup(path); mp->timer = g_timer_new(); + mp->volume = -1; mp->watch = g_dbus_add_disconnect_watch(conn, sender, media_player_exit, mp, diff --git a/profiles/audio/media.h b/profiles/audio/media.h index dd630d432..53694f4c6 100644 --- a/profiles/audio/media.h +++ b/profiles/audio/media.h @@ -33,3 +33,5 @@ void media_unregister(struct btd_adapter *btd_adapter); struct a2dp_sep *media_endpoint_get_sep(struct media_endpoint *endpoint); const char *media_endpoint_get_uuid(struct media_endpoint *endpoint); uint8_t media_endpoint_get_codec(struct media_endpoint *endpoint); + +int8_t media_player_get_device_volume(struct btd_device *device); diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 2ae5118c4..a2c4f7dfb 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -977,7 +977,7 @@ void media_transport_update_device_volume(struct btd_device *dev, { GSList *l; - if (dev == NULL) + if (dev == NULL || volume < 0) return; for (l = transports; l; l = l->next) { -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WK9dHe9MGV8XSAAAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 10:40:15 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OFItG+9MGV/VqgAADc0bRg (envelope-from ); Thu, 23 Jul 2020 10:40:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=tessares-net.20150623.gappssmtp.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CC01F4086A; Thu, 23 Jul 2020 10:40:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727776AbgGWIkB (ORCPT + 1 other); Thu, 23 Jul 2020 04:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbgGWIjz (ORCPT ); Thu, 23 Jul 2020 04:39:55 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D384C08C5C1 for ; Thu, 23 Jul 2020 01:39:55 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id by13so3876363edb.11 for ; Thu, 23 Jul 2020 01:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares-net.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=t34u4KAm1gK/f1oDA6+0ZgZ3T1IDP3Ad7b21M8jn9IE=; b=CNsYMCaC5YFx1sCHrUnGTyxK55+RElxWw1Y4CgVq4WviDSpLe5tvZRQNhbw/o8NHkS 5lNPKTvPIJgzELza08HXzETuGDGqESAjMwaETk5Mmah7A76FYju7HEJcSxVz2Z68Ez32 Fe8bkyg3EIliyQfIE0WUqAFYcrQUJWfpZsNbAdl/ll0KB40GMQt1yoxZTtepzlC4KdnZ GnSg5TjVpPWt7FlYOZYnnYqZEV4wmhNftYUlMk2HjS0eEZRDa0Aihb7OonspbY3XBKmu gfkANWXjINxT44g2wwmEPqLtqbE4VWM7CM7H0NR7+q8PAGIse1jhucMrcCJVf3oeSFy2 TE7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=t34u4KAm1gK/f1oDA6+0ZgZ3T1IDP3Ad7b21M8jn9IE=; b=LD4ZTwIGDML7RWzsKMTWjtjsrTJLRE9J/kCqku82lBArNPTh8Mgm8csabVwwSpRBbC 4mVVXXViR0qHCkvqvXhDom+dC37moeOM41SwuFaL/6xZWx4tEAmmXAogbhJEU7MA+Ju9 LWfua+00+Glioe1eW3f27F/R9ZWCqzBwMgPVy9uVxL5PorW9OKHpWRAipuhSUVoCWnWn DyHmF+tmAuvGXynkC1O6no/0cgR9xvClP4xF/F/e0np5E+6Oghe0AuWlS8/8Olbi3uem 3trPjcFamykEaQ/lRVAKD/pVWM359TO4PGBy4u9DfoW3jBWKiQAh80TRMT828Mcli5gh Ccnw== X-Gm-Message-State: AOAM533ITk04a6uMUT+cmQkERuVwhEpMUCzSa8CZ0E5iptAapqGgWJ6s DSARSRqmVYFR1nGI1EZPPHEX0A== X-Google-Smtp-Source: ABdhPJwbyZj4th/Ks5mvB+ElB/xiz0sHXiy/UKIrJCc8QLLBnJl9HfUHFNhTU1trrZNOtrIehMUs+A== X-Received: by 2002:aa7:da4c:: with SMTP id w12mr3098522eds.122.1595493593384; Thu, 23 Jul 2020 01:39:53 -0700 (PDT) Received: from tsr-lap-08.nix.tessares.net ([79.132.248.22]) by smtp.gmail.com with ESMTPSA id q7sm1560608eja.69.2020.07.23.01.39.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jul 2020 01:39:52 -0700 (PDT) Subject: Re: [MPTCP] [PATCH 08/26] net: switch sock_set_timeout to sockptr_t To: Christoph Hellwig , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-9-hch@lst.de> From: Matthieu Baerts Message-ID: <092368db-122f-60bc-6a32-3cd5c70727da@tessares.net> Date: Thu, 23 Jul 2020 10:39:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200723060908.50081-9-hch@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.64 / 15.00 / 200.00 X-Rspamd-Queue-Id: CC01F4086A X-Rspamd-UID: b707fd Hi Christoph, On 23/07/2020 08:08, Christoph Hellwig wrote: > Pass a sockptr_t to prepare for set_fs-less handling of the kernel > pointer from bpf-cgroup. > > Signed-off-by: Christoph Hellwig > --- > net/mptcp/protocol.c | 6 ++++-- Thank you for looking at that! For MPTCP-related code: Acked-by: Matthieu Baerts Cheers, Matt -- Tessares | Belgium | Hybrid Access Solutions www.tessares.net Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GFACJy8rGV99mAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:16:15 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CN/AJS8rGV/CmQAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 08:16:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6A32F404BB; Thu, 23 Jul 2020 08:16:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726603AbgGWGJc (ORCPT + 1 other); Thu, 23 Jul 2020 02:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726522AbgGWGJb (ORCPT ); Thu, 23 Jul 2020 02:09:31 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F31CEC0619E3; Wed, 22 Jul 2020 23:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=jnNftkdWuHutn0l5/V2Gz6Qvt1s8tXbdDMQLxkwuHBo=; b=AHWMVgl+gZI3ppeRUJG22CnuN2 mXsqGUtHr7hHIshIeM0BR3FDFu7P8hUJdDKWEDjaeFBPFzHAKS1/J2NqqrgVWAiWy0PDBIJV6MaAk gPot77jPYt8McodlLqHe4rYj1xwXIh3dwL7d5dP2a47D69tnzjzBjxRqbyL4qtqPcLy6LsSPLTz8/ YOabKmimQamGM4cxDNfekHWNUuwVnDebo84hbzn4arDbH1CmgtyNxmN2OFQxyAhRHpoT37cldfrc6 Ax/DteamlOzerpb/bK5cMQkwL7vWGfqduGUdI9Ez5lzvt3eBZC1+o7Ayqr6UYOa2Jd5AGGDGAZ45S 4D3R2EfQ==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUPo-0003jj-5f; Thu, 23 Jul 2020 06:09:12 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 02/26] net/bpfilter: split __bpfilter_process_sockopt Date: Thu, 23 Jul 2020 08:08:44 +0200 Message-Id: <20200723060908.50081-3-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 44 X-Rspamd-Score: 6.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6A32F404BB X-Rspamd-UID: a9ebfa Split __bpfilter_process_sockopt into a low-level send request routine and the actual setsockopt hook to split the init time ping from the actual setsockopt processing. Signed-off-by: Christoph Hellwig --- net/bpfilter/bpfilter_kern.c | 51 +++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c index 3bac5820062af1..78d561f2c54da7 100644 --- a/net/bpfilter/bpfilter_kern.c +++ b/net/bpfilter/bpfilter_kern.c @@ -31,48 +31,51 @@ static void __stop_umh(void) shutdown_umh(); } -static int __bpfilter_process_sockopt(struct sock *sk, int optname, - char __user *optval, - unsigned int optlen, bool is_set) +static int bpfilter_send_req(struct mbox_request *req) { - struct mbox_request req; struct mbox_reply reply; loff_t pos; ssize_t n; - int ret = -EFAULT; - req.is_set = is_set; - req.pid = current->pid; - req.cmd = optname; - req.addr = (uintptr_t)optval; - req.len = optlen; if (!bpfilter_ops.info.tgid) - goto out; + return -EFAULT; pos = 0; - n = kernel_write(bpfilter_ops.info.pipe_to_umh, &req, sizeof(req), + n = kernel_write(bpfilter_ops.info.pipe_to_umh, req, sizeof(*req), &pos); - if (n != sizeof(req)) { + if (n != sizeof(*req)) { pr_err("write fail %zd\n", n); - __stop_umh(); - ret = -EFAULT; - goto out; + goto stop; } pos = 0; n = kernel_read(bpfilter_ops.info.pipe_from_umh, &reply, sizeof(reply), &pos); if (n != sizeof(reply)) { pr_err("read fail %zd\n", n); - __stop_umh(); - ret = -EFAULT; - goto out; + goto stop; } - ret = reply.status; -out: - return ret; + return reply.status; +stop: + __stop_umh(); + return -EFAULT; +} + +static int bpfilter_process_sockopt(struct sock *sk, int optname, + char __user *optval, unsigned int optlen, + bool is_set) +{ + struct mbox_request req = { + .is_set = is_set, + .pid = current->pid, + .cmd = optname, + .addr = (uintptr_t)optval, + .len = optlen, + }; + return bpfilter_send_req(&req); } static int start_umh(void) { + struct mbox_request req = { .pid = current->pid }; int err; /* fork usermode process */ @@ -82,7 +85,7 @@ static int start_umh(void) pr_info("Loaded bpfilter_umh pid %d\n", pid_nr(bpfilter_ops.info.tgid)); /* health check that usermode process started correctly */ - if (__bpfilter_process_sockopt(NULL, 0, NULL, 0, 0) != 0) { + if (bpfilter_send_req(&req) != 0) { shutdown_umh(); return -EFAULT; } @@ -103,7 +106,7 @@ static int __init load_umh(void) mutex_lock(&bpfilter_ops.lock); err = start_umh(); if (!err && IS_ENABLED(CONFIG_INET)) { - bpfilter_ops.sockopt = &__bpfilter_process_sockopt; + bpfilter_ops.sockopt = &bpfilter_process_sockopt; bpfilter_ops.start = &start_umh; } mutex_unlock(&bpfilter_ops.lock); -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8EouCv1MGV8MfwAAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 10:40:29 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WNeBCP1MGV8hMQEAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 10:40:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=tessares-net.20150623.gappssmtp.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A825240677; Thu, 23 Jul 2020 10:40:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728046AbgGWIkF (ORCPT + 1 other); Thu, 23 Jul 2020 04:40:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728005AbgGWIkC (ORCPT ); Thu, 23 Jul 2020 04:40:02 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 082A8C0619E8 for ; Thu, 23 Jul 2020 01:40:01 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id f12so5472171eja.9 for ; Thu, 23 Jul 2020 01:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares-net.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=GBFjr2NO+tPwRt48f6bV0DAq1xVraB+4JvlLFlRB/+g=; b=rGyvMeQ+RAXj0neMlTzU8uPVoGP++MmPyXW9rehNveFQBhF8dyYxv6AjBxtstq4TFV 4fm/sT4fngoHPtNhHHFkRlNaBXaqxFcoxzVPV4jnyhOEIxpE+8WP3v6Ys+mZIZHxnElm 3+HlzqlN3TTCQNBXVwfzvcuNngRHeRTj8yDoqfrZmGsvdvEkoWCKJ4G7hKyFMO63jS/1 vJu6u48QBIkiTQUHfssZnDO3TKFO/LYe7iUYcCJScMS5N6nkTfO2ZkCaQ5+U85Bpfz5I QzSiZ0n35L2/+Xm7/99AiElI31daRjEc7Mt7bFjI3zXI8qtconQ7jAfr+lIgPePAz6Ta OZpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=GBFjr2NO+tPwRt48f6bV0DAq1xVraB+4JvlLFlRB/+g=; b=CCYu8x1S9U2YE+DwAcy0G06pDZyerP2/GdJfmcMt3h0O57IdBxwNhVGQ3OhkVngaEv j7plEmlOfdr1uKS2xXPzl540SO64FjAsfyUfZThLCsIwVRlz7h/hlMb4kGg2xvZBkrVz 6rgVHDap/9yBg0roj4/AyFk0ljMBzVVbrz6tCXo65cB191hg+oiK7wDYneKuctLI1NvI YvzfVq8wx5Jokb2+bTVzQhPBQXrzt1XYKeIXhYF0kpFBquuTWgV0l5hvHvVYXeCI8ff6 1Tlbd0ybkepmMc7F/vMS/CfJVs/xs+yhKjwF7fK41feg+00HZLTjllf7oAH6pFypgdV0 pvBQ== X-Gm-Message-State: AOAM5303hDTQY42UdYNcnQFrKBCNm3bgm+1lPeC+mfxKCyzxCEMRhpu0 QUQKidz8wHidQYTqs9WKTy0NMw== X-Google-Smtp-Source: ABdhPJxCoyR6XAi+VAaWwhsRGBR37Zk2lE1XCLCzXK9C/pnGAxIlGjt4DDu+Ll1G6Qz23LuzpAwjkw== X-Received: by 2002:a17:906:b0d3:: with SMTP id bk19mr3489955ejb.167.1595493599663; Thu, 23 Jul 2020 01:39:59 -0700 (PDT) Received: from tsr-lap-08.nix.tessares.net ([79.132.248.22]) by smtp.gmail.com with ESMTPSA id z22sm1634990edx.72.2020.07.23.01.39.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jul 2020 01:39:59 -0700 (PDT) Subject: Re: [MPTCP] [PATCH 25/26] net: pass a sockptr_t into ->setsockopt To: Christoph Hellwig , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org, Stefan Schmidt References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-26-hch@lst.de> From: Matthieu Baerts Message-ID: <1056b902-fd25-1c13-758d-cd4341dd403b@tessares.net> Date: Thu, 23 Jul 2020 10:39:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200723060908.50081-26-hch@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.89 / 15.00 / 200.00 X-Rspamd-Queue-Id: A825240677 X-Rspamd-UID: c7b818 Hi Christoph, On 23/07/2020 08:09, Christoph Hellwig wrote: > Rework the remaining setsockopt code to pass a sockptr_t instead of a > plain user pointer. This removes the last remaining set_fs(KERNEL_DS) > outside of architecture specific code. > > Signed-off-by: Christoph Hellwig > Acked-by: Stefan Schmidt [ieee802154] > --- > net/mptcp/protocol.c | 12 +++---- Thank you for the v2! For MPTCP-related code: Acked-by: Matthieu Baerts Cheers, Matt -- Tessares | Belgium | Hybrid Access Solutions www.tessares.net Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OLG0L0krGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:16:41 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gEw3LkkrGV/FBgAADc0bRg (envelope-from ); Thu, 23 Jul 2020 08:16:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 80E974000F; Thu, 23 Jul 2020 08:16:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725774AbgGWGNe (ORCPT + 1 other); Thu, 23 Jul 2020 02:13:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726304AbgGWGJa (ORCPT ); Thu, 23 Jul 2020 02:09:30 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45CABC0619DC; Wed, 22 Jul 2020 23:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=4ol6++ZHLzLW7TDwHlZddqUginEv5bBRSa0jVjvGkxw=; b=LQ4n46+A9hpfp8zwc4fmkS7cJo d5IqR7Kl4e0TO036FT8xWuGybCPl2s2InAIro23/53LCinHbTKiq/Tnub5/sgbeB8OvtVn2Fb8T3x cy//cs6JjumkNHaZgsjWuneXbSE3bV91ZNenOTCXKvvKVo3iMbNIfcuHEHy0jL/1haCANgajZtHlM OmyzXP8bHeIwV24m5r6zEtVXEFNxvWUQym3x+LwR2wkRgHMMnIbpuUfNlwS4BNr+jYwxsADZ+QZcp nqi2JyfZ3TNmf2p6KSTQP4wHWgQxfvy5ytYsalHed/VoVuESlHAkZj1jRhA4Bsr7iHZTdGZ+FlzSQ Hvfa7s1g==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUPq-0003k4-Pf; Thu, 23 Jul 2020 06:09:15 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 04/26] net: add a new sockptr_t type Date: Thu, 23 Jul 2020 08:08:46 +0200 Message-Id: <20200723060908.50081-5-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 80E974000F X-Rspamd-UID: b82e63 Add a uptr_t type that can hold a pointer to either a user or kernel memory region, and simply helpers to copy to and from it. Signed-off-by: Christoph Hellwig --- include/linux/sockptr.h | 104 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 include/linux/sockptr.h diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h new file mode 100644 index 00000000000000..700856e13ea0c4 --- /dev/null +++ b/include/linux/sockptr.h @@ -0,0 +1,104 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2020 Christoph Hellwig. + * + * Support for "universal" pointers that can point to either kernel or userspace + * memory. + */ +#ifndef _LINUX_SOCKPTR_H +#define _LINUX_SOCKPTR_H + +#include +#include + +typedef struct { + union { + void *kernel; + void __user *user; + }; + bool is_kernel : 1; +} sockptr_t; + +static inline bool sockptr_is_kernel(sockptr_t sockptr) +{ + return sockptr.is_kernel; +} + +static inline sockptr_t KERNEL_SOCKPTR(void *p) +{ + return (sockptr_t) { .kernel = p, .is_kernel = true }; +} + +static inline sockptr_t USER_SOCKPTR(void __user *p) +{ + return (sockptr_t) { .user = p }; +} + +static inline bool sockptr_is_null(sockptr_t sockptr) +{ + return !sockptr.user && !sockptr.kernel; +} + +static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) +{ + if (!sockptr_is_kernel(src)) + return copy_from_user(dst, src.user, size); + memcpy(dst, src.kernel, size); + return 0; +} + +static inline int copy_to_sockptr(sockptr_t dst, const void *src, size_t size) +{ + if (!sockptr_is_kernel(dst)) + return copy_to_user(dst.user, src, size); + memcpy(dst.kernel, src, size); + return 0; +} + +static inline void *memdup_sockptr(sockptr_t src, size_t len) +{ + void *p = kmalloc_track_caller(len, GFP_USER | __GFP_NOWARN); + + if (!p) + return ERR_PTR(-ENOMEM); + if (copy_from_sockptr(p, src, len)) { + kfree(p); + return ERR_PTR(-EFAULT); + } + return p; +} + +static inline void *memdup_sockptr_nul(sockptr_t src, size_t len) +{ + char *p = kmalloc_track_caller(len + 1, GFP_KERNEL); + + if (!p) + return ERR_PTR(-ENOMEM); + if (copy_from_sockptr(p, src, len)) { + kfree(p); + return ERR_PTR(-EFAULT); + } + p[len] = '\0'; + return p; +} + +static inline void sockptr_advance(sockptr_t sockptr, size_t len) +{ + if (sockptr_is_kernel(sockptr)) + sockptr.kernel += len; + else + sockptr.user += len; +} + +static inline long strncpy_from_sockptr(char *dst, sockptr_t src, size_t count) +{ + if (sockptr_is_kernel(src)) { + size_t len = min(strnlen(src.kernel, count - 1) + 1, count); + + memcpy(dst, src.kernel, len); + return len; + } + return strncpy_from_user(dst, src.user, count); +} + +#endif /* _LINUX_SOCKPTR_H */ -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QGYBK08rGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:16:47 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id EFsfKk8rGV9B0QEA0J78UA (envelope-from ); Thu, 23 Jul 2020 08:16:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7DECB40675; Thu, 23 Jul 2020 08:16:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725911AbgGWGJa (ORCPT + 1 other); Thu, 23 Jul 2020 02:09:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgGWGJ3 (ORCPT ); Thu, 23 Jul 2020 02:09:29 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49A30C0619DC; Wed, 22 Jul 2020 23:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=oT1TzeBCiE7PYsKY3KaZ4zyLReXEZMRen8bFjdM9v/g=; b=V0YG7V4rx5A1qxxjwpwI1a6uuM HduyTdraT6ektr3EgWlWMGz0vGlHlbYPwfQQDUrhGndXtCF7Ushl0XM427AsckNecE4SZY8H6Gj6t 1J6QRv06PoKrwom/lYsLRBb+Zxhi9iAvOJ6uF7iqbAWuHkbaBJHUaC+w9atEfs3y7AiQuNIo8FcW8 Vxh2iQacihv7RJDO2nzPMS3hCbItupEWN4AWE/eDraKBNott6suYIUDVqeV8CB8hxS1xFsCHEc2nX S0MGXj1LmMc/GCEyFvGL0MRc0Hp7dLKkAwEkA4lbfPNdLiXxLHfp06GwUz+10rsGW1yVMIDkvb7SW EsRGr+aA==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUPs-0003kH-8u; Thu, 23 Jul 2020 06:09:16 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 05/26] net: switch copy_bpf_fprog_from_user to sockptr_t Date: Thu, 23 Jul 2020 08:08:47 +0200 Message-Id: <20200723060908.50081-6-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7DECB40675 X-Rspamd-UID: bda6c2 Pass a sockptr_t to prepare for set_fs-less handling of the kernel pointer from bpf-cgroup. Signed-off-by: Christoph Hellwig --- include/linux/filter.h | 3 ++- net/core/filter.c | 6 +++--- net/core/sock.c | 6 ++++-- net/packet/af_packet.c | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index 1c6b6d982bf498..d07a6e973a7d6f 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -1276,7 +1277,7 @@ struct bpf_sockopt_kern { s32 retval; }; -int copy_bpf_fprog_from_user(struct sock_fprog *dst, void __user *src, int len); +int copy_bpf_fprog_from_user(struct sock_fprog *dst, sockptr_t src, int len); struct bpf_sk_lookup_kern { u16 family; diff --git a/net/core/filter.c b/net/core/filter.c index 3fa16b8c0d616a..29e3455122f772 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -77,14 +77,14 @@ #include #include -int copy_bpf_fprog_from_user(struct sock_fprog *dst, void __user *src, int len) +int copy_bpf_fprog_from_user(struct sock_fprog *dst, sockptr_t src, int len) { if (in_compat_syscall()) { struct compat_sock_fprog f32; if (len != sizeof(f32)) return -EINVAL; - if (copy_from_user(&f32, src, sizeof(f32))) + if (copy_from_sockptr(&f32, src, sizeof(f32))) return -EFAULT; memset(dst, 0, sizeof(*dst)); dst->len = f32.len; @@ -92,7 +92,7 @@ int copy_bpf_fprog_from_user(struct sock_fprog *dst, void __user *src, int len) } else { if (len != sizeof(*dst)) return -EINVAL; - if (copy_from_user(dst, src, sizeof(*dst))) + if (copy_from_sockptr(dst, src, sizeof(*dst))) return -EFAULT; } diff --git a/net/core/sock.c b/net/core/sock.c index 6da54eac2b3456..71fc7e4ddd0648 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1063,7 +1063,8 @@ int sock_setsockopt(struct socket *sock, int level, int optname, case SO_ATTACH_FILTER: { struct sock_fprog fprog; - ret = copy_bpf_fprog_from_user(&fprog, optval, optlen); + ret = copy_bpf_fprog_from_user(&fprog, USER_SOCKPTR(optval), + optlen); if (!ret) ret = sk_attach_filter(&fprog, sk); break; @@ -1084,7 +1085,8 @@ int sock_setsockopt(struct socket *sock, int level, int optname, case SO_ATTACH_REUSEPORT_CBPF: { struct sock_fprog fprog; - ret = copy_bpf_fprog_from_user(&fprog, optval, optlen); + ret = copy_bpf_fprog_from_user(&fprog, USER_SOCKPTR(optval), + optlen); if (!ret) ret = sk_reuseport_attach_filter(&fprog, sk); break; diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index c240fb5de3f014..d8d4f78f78e451 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1536,7 +1536,7 @@ static void __fanout_set_data_bpf(struct packet_fanout *f, struct bpf_prog *new) } } -static int fanout_set_data_cbpf(struct packet_sock *po, char __user *data, +static int fanout_set_data_cbpf(struct packet_sock *po, sockptr_t data, unsigned int len) { struct bpf_prog *new; @@ -1584,7 +1584,7 @@ static int fanout_set_data(struct packet_sock *po, char __user *data, { switch (po->fanout->type) { case PACKET_FANOUT_CBPF: - return fanout_set_data_cbpf(po, data, len); + return fanout_set_data_cbpf(po, USER_SOCKPTR(data), len); case PACKET_FANOUT_EBPF: return fanout_set_data_ebpf(po, data, len); default: -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iMWfJnwrGV99mAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:17:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UEndJHwrGV/CmQAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 08:17:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=infradead.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5B16940F3F; Thu, 23 Jul 2020 08:17:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727111AbgGWGNt (ORCPT + 1 other); Thu, 23 Jul 2020 02:13:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725846AbgGWGJ3 (ORCPT ); Thu, 23 Jul 2020 02:09:29 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83229C0619E2; Wed, 22 Jul 2020 23:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=gCUb2KALoHVqEKu8rEH+C8lWt+ULTZIwW5IcTvAPZOE=; b=ATPIX3sYRFhC7WaiE9BzREZuc5 cG3sYs1eD725v8winTFEqlUitrKu3d6dcE2QNeb9tLQS/xlmm+Lwc0xkgmGNIgb7JCD4ezErd4DBn 9p9aTwTzEYw6D+be9JrRR3QEczOkzAWwyArehyn1eSvNMr3ISxeuRa3IuGi295j1EfVowQZ2UjQ6Z wd/YxGdW+I/jDCW8g89M+AqOLZGJjGXcpB6wuML4/ZE+SDzzAPZHP5kRGWH+QfxuKxtAkaxPtP+/f DwmcusSufm/WG/k6lNStK4mo9aHpGpQgKtHqEHIsnJOzGYTQzluUkSiXxr4PmmMJafDnLDnRNxnsh i+hp3mvg==; Received: from [2001:4bb8:18c:2acc:91df:aae8:fa3b:de9c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyUPp-0003jz-GJ; Thu, 23 Jul 2020 06:09:13 +0000 From: Christoph Hellwig To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: [PATCH 03/26] bpfilter: reject kernel addresses Date: Thu, 23 Jul 2020 08:08:45 +0200 Message-Id: <20200723060908.50081-4-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 26 X-Rspamd-Score: 3.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5B16940F3F X-Rspamd-UID: cc82f2 The bpfilter user mode helper processes the optval address using process_vm_readv. Don't send it kernel addresses fed under set_fs(KERNEL_DS) as that won't work. Signed-off-by: Christoph Hellwig --- net/bpfilter/bpfilter_kern.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c index 78d561f2c54da7..00540457e5f4d3 100644 --- a/net/bpfilter/bpfilter_kern.c +++ b/net/bpfilter/bpfilter_kern.c @@ -70,6 +70,10 @@ static int bpfilter_process_sockopt(struct sock *sk, int optname, .addr = (uintptr_t)optval, .len = optlen, }; + if (uaccess_kernel()) { + pr_err("kernel access not supported\n"); + return -EFAULT; + } return bpfilter_send_req(&req); } -- 2.27.0 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GH8yNs4sGV99mAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:23:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id eAWjNM4sGV/9BgAAgupzMw (envelope-from ); Thu, 23 Jul 2020 08:23:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8482B4014E; Thu, 23 Jul 2020 08:23:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726676AbgGWGW6 (ORCPT + 1 other); Thu, 23 Jul 2020 02:22:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbgGWGW5 (ORCPT ); Thu, 23 Jul 2020 02:22:57 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B443C0619DC for ; Wed, 22 Jul 2020 23:22:57 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id h194so5272625ybg.22 for ; Wed, 22 Jul 2020 23:22:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=pPmurDfzfjymgNCEkMBG2J5hgnz27ka1eET+Y8/bzG0=; b=MtMPvLebdTqWOB4FBBRmpWHfr33d6OeJMXWRV+2z718oXF8YA4+ROmKf1CMzXmKyip LwaitnDE9S+6SVtRZfp0mhGROdRs34nHj3kB7HDGI5C+tpz9mQxe0pVLAQcDYWPx8UdX +3+NRPGxZLP0rGt9tM9i/NJYpVwLSr+gNPIcnPN8toMlTpGGLEF3NYUro76KL9X/C/RT deX8j4Gp6Jkn6M1x1NmRUglgTspqSAt2j3qIjyYJfDCQ0vLHeW74C9Wbhy/xSw0Xdjjk 0wSLy7UWwCMSPE0QQXUUY0Lmrv4yVg6pWxBh7ItiIIxGdAMJhMN2X7oOmvnlfvq0yVRC KNvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=pPmurDfzfjymgNCEkMBG2J5hgnz27ka1eET+Y8/bzG0=; b=Kq6j/LZrxphyr4Lo5t09qEC0+XrANqQw027imUzoQQl5XrkrCTew98HXLtG0lWzK2h pMDp8bqfCJF50+ZwPxDY52PuoRF9yXQoI3cyFyt8POYvc/6itbsjzck2NW72gygkTM/E uaqOlC0CipGU6BD1rRtQOJu6iQw3IV7J1MvkTspVFf8mfQm178Gv5VudllkvNoI8DeTI 7rwnj2fbJQMdZ8lg+5XWFAfk0q85sWC8mFD+C7OzRufLn3MXRJkK9p69dEsi0qHXiqEu 5Je2mR1zAdttTfwkLsE4/EdxT/VhBKASAWM8j0pXoCwbUFdKQbmjyn7KUG38/ZB2iAzV rkig== X-Gm-Message-State: AOAM531INI5El4ebLPhw9oCWTHn0P0sWNZYmn1IK/D7CQesnBH1oI0JW aQimn9vKKWd8qIqZWjMJ0Y1hbeIAX+tqHU2V2frdfP1vOshYBeC0CMLlc5pYieJHvaoOmAcm6jW 9l3WYLfIWDcvlJ9jvsvY9fuqayRrjvUNwK0lc4D2I7zAsmZ1pAS038qPPDArJlnvAP+UvswlsAK U/ X-Google-Smtp-Source: ABdhPJxdF0l8qYmqjeYBuDkp0gHUcfshHeNGTId9I9l8+PmaeFdfh3iFT6YoM8Bj6eo2bzsQ/436V7AxdDQq X-Received: by 2002:a25:cc12:: with SMTP id l18mr4159405ybf.480.1595485376691; Wed, 22 Jul 2020 23:22:56 -0700 (PDT) Date: Thu, 23 Jul 2020 14:22:49 +0800 Message-Id: <20200723142128.Bluez.v4.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog Subject: [Bluez PATCH v4 1/2] audio/transport: change volume to 8bit From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Michael Sun Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 0.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8482B4014E X-Rspamd-UID: 3d7fc4 From: Archie Pusaka The valid range of volume is 0 - 127, yet it is stored in 16bit data type. This patch modifies it so we use 8bit data type to store volume instead. Furthermore we also use signed type, so negative values can be used to indicate invalid volume. Reviewed-by: Michael Sun --- Changes in v4: -Use int8_t instead of uint8_t Changes in v3: None Changes in v2: None profiles/audio/avrcp.c | 13 ++++++----- profiles/audio/avrcp.h | 5 ++--- profiles/audio/media.c | 4 ++-- profiles/audio/transport.c | 45 +++++++++++++++++++------------------- profiles/audio/transport.h | 8 +++---- 5 files changed, 38 insertions(+), 37 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 1bf85041e..d2d1d9dae 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -1660,7 +1660,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, break; case AVRCP_EVENT_VOLUME_CHANGED: pdu->params[1] = media_transport_get_device_volume(dev); - if (pdu->params[1] > 127) + if (pdu->params[1] < 0) goto err; len = 2; @@ -1757,7 +1757,7 @@ static uint8_t avrcp_handle_set_absolute_volume(struct avrcp *session, uint8_t transaction) { uint16_t len = ntohs(pdu->params_len); - uint8_t volume; + int8_t volume; if (len != 1) goto err; @@ -3623,7 +3623,7 @@ static void avrcp_volume_changed(struct avrcp *session, struct avrcp_header *pdu) { struct avrcp_player *player = target_get_player(session); - uint8_t volume; + int8_t volume; volume = pdu->params[1] & 0x7F; @@ -4371,7 +4371,7 @@ static gboolean avrcp_handle_set_volume(struct avctp *conn, uint8_t code, struct avrcp *session = user_data; struct avrcp_player *player = target_get_player(session); struct avrcp_header *pdu = (void *) operands; - uint8_t volume; + int8_t volume; if (code == AVC_CTYPE_REJECTED || code == AVC_CTYPE_NOT_IMPLEMENTED || pdu == NULL) @@ -4434,13 +4434,16 @@ static int avrcp_event(struct avrcp *session, uint8_t id, const void *data) return err; } -int avrcp_set_volume(struct btd_device *dev, uint8_t volume, bool notify) +int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify) { struct avrcp_server *server; struct avrcp *session; uint8_t buf[AVRCP_HEADER_LENGTH + 1]; struct avrcp_header *pdu = (void *) buf; + if (volume < 0) + return -EINVAL; + server = find_server(servers, device_get_adapter(dev)); if (server == NULL) return -EINVAL; diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index 86d310c73..026a820f5 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -94,7 +94,7 @@ struct avrcp_player_cb { uint32_t (*get_position) (void *user_data); uint32_t (*get_duration) (void *user_data); const char *(*get_name) (void *user_data); - void (*set_volume) (uint8_t volume, struct btd_device *dev, + void (*set_volume) (int8_t volume, struct btd_device *dev, void *user_data); bool (*play) (void *user_data); bool (*stop) (void *user_data); @@ -103,7 +103,7 @@ struct avrcp_player_cb { bool (*previous) (void *user_data); }; -int avrcp_set_volume(struct btd_device *dev, uint8_t volume, bool notify); +int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify); struct avrcp_player *avrcp_register_player(struct btd_adapter *adapter, struct avrcp_player_cb *cb, @@ -114,6 +114,5 @@ void avrcp_unregister_player(struct avrcp_player *player); void avrcp_player_event(struct avrcp_player *player, uint8_t id, const void *data); - size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands); size_t avrcp_browsing_general_reject(uint8_t *operands); diff --git a/profiles/audio/media.c b/profiles/audio/media.c index a0173fdd4..d4d58ec86 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -120,7 +120,7 @@ struct media_player { char *status; uint32_t position; uint32_t duration; - uint8_t volume; + int8_t volume; GTimer *timer; bool play; bool pause; @@ -1199,7 +1199,7 @@ static uint32_t get_duration(void *user_data) return mp->duration; } -static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) +static void set_volume(int8_t volume, struct btd_device *dev, void *user_data) { struct media_player *mp = user_data; diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 48fabba9b..2ae5118c4 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -86,7 +86,7 @@ struct media_owner { struct a2dp_transport { struct avdtp *session; uint16_t delay; - uint16_t volume; + int8_t volume; }; struct media_transport { @@ -634,7 +634,7 @@ static gboolean volume_exists(const GDBusPropertyTable *property, void *data) struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; - return a2dp->volume <= 127; + return a2dp->volume >= 0; } static gboolean get_volume(const GDBusPropertyTable *property, @@ -642,8 +642,9 @@ static gboolean get_volume(const GDBusPropertyTable *property, { struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; + uint16_t volume = (uint16_t)a2dp->volume; - dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &a2dp->volume); + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &volume); return TRUE; } @@ -654,27 +655,20 @@ static void set_volume(const GDBusPropertyTable *property, { struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; - uint16_t volume; + uint16_t arg; + int8_t volume; bool notify; - if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) { - g_dbus_pending_property_error(id, - ERROR_INTERFACE ".InvalidArguments", - "Invalid arguments in method call"); - return; - } + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) + goto error; - dbus_message_iter_get_basic(iter, &volume); - - if (volume > 127) { - g_dbus_pending_property_error(id, - ERROR_INTERFACE ".InvalidArguments", - "Invalid arguments in method call"); - return; - } + dbus_message_iter_get_basic(iter, &arg); + if (arg > INT8_MAX) + goto error; g_dbus_pending_property_success(id); + volume = (int8_t)arg; if (a2dp->volume == volume) return; @@ -688,6 +682,11 @@ static void set_volume(const GDBusPropertyTable *property, "Volume"); avrcp_set_volume(transport->device, volume, notify); + return; + +error: + g_dbus_pending_property_error(id, ERROR_INTERFACE ".InvalidArguments", + "Invalid arguments in method call"); } static gboolean endpoint_exists(const GDBusPropertyTable *property, void *data) @@ -931,14 +930,14 @@ struct btd_device *media_transport_get_dev(struct media_transport *transport) return transport->device; } -uint16_t media_transport_get_volume(struct media_transport *transport) +int8_t media_transport_get_volume(struct media_transport *transport) { struct a2dp_transport *a2dp = transport->data; return a2dp->volume; } void media_transport_update_volume(struct media_transport *transport, - uint8_t volume) + int8_t volume) { struct a2dp_transport *a2dp = transport->data; @@ -953,12 +952,12 @@ void media_transport_update_volume(struct media_transport *transport, MEDIA_TRANSPORT_INTERFACE, "Volume"); } -uint8_t media_transport_get_device_volume(struct btd_device *dev) +int8_t media_transport_get_device_volume(struct btd_device *dev) { GSList *l; if (dev == NULL) - return 128; + return -1; for (l = transports; l; l = l->next) { struct media_transport *transport = l->data; @@ -974,7 +973,7 @@ uint8_t media_transport_get_device_volume(struct btd_device *dev) } void media_transport_update_device_volume(struct btd_device *dev, - uint8_t volume) + int8_t volume) { GSList *l; diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index ac542bf6c..78024372f 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -32,14 +32,14 @@ struct media_transport *media_transport_create(struct btd_device *device, void media_transport_destroy(struct media_transport *transport); const char *media_transport_get_path(struct media_transport *transport); struct btd_device *media_transport_get_dev(struct media_transport *transport); -uint16_t media_transport_get_volume(struct media_transport *transport); +int8_t media_transport_get_volume(struct media_transport *transport); void media_transport_update_delay(struct media_transport *transport, uint16_t delay); void media_transport_update_volume(struct media_transport *transport, - uint8_t volume); + int8_t volume); void transport_get_properties(struct media_transport *transport, DBusMessageIter *iter); -uint8_t media_transport_get_device_volume(struct btd_device *dev); +int8_t media_transport_get_device_volume(struct btd_device *dev); void media_transport_update_device_volume(struct btd_device *dev, - uint8_t volume); + int8_t volume); -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SHciD9QsGV9YegEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:23:16 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cIxaDdQsGV+QCQAADc0bRg (envelope-from ); Thu, 23 Jul 2020 08:23:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0C9C440012; Thu, 23 Jul 2020 08:23:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbgGWGXD (ORCPT + 1 other); Thu, 23 Jul 2020 02:23:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbgGWGXC (ORCPT ); Thu, 23 Jul 2020 02:23:02 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82B95C0619E2 for ; Wed, 22 Jul 2020 23:23:02 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id d202so5306544ybh.12 for ; Wed, 22 Jul 2020 23:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WADh6ZvhdBEhj4v8Bh0vTejKQyp+42zGkpP8WL38NHo=; b=F7awYNCSiaMvQBlusOuoLyQabgbbOxRGC6K6h4LAnXaoNYXXQP/pBt9SpjZpg481CT e0sYZ2RKy/trnlwHFD4coTiDrMpExdcRNQLvRO6YnckO+75bxIRIEa5zoU/+G9rxsyA1 wcx69F8iSYr0bggZq1GVeI7qrtYTD0mi6LCvgRQsdjIFfyLogchx6BKMDAqklk+C11dl EMc4OScc3MmnQYZH+FqogNRgB45LK8RG4/zUo8YbvmIiFljFVt5rbm/rM8D2oje08yHL arxd6F+1SXn/hIm15iJeiFMZXJTSbd2yS9783k5ZRhiqjOcvFHt/BfxLi74lpEw8hQOh btGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WADh6ZvhdBEhj4v8Bh0vTejKQyp+42zGkpP8WL38NHo=; b=ECSci2eLqUNt/Avqx4Rw3F5777lgEpu/kXWBu6eXq8dFnVYwNMOmoXnSRy/1P/p3fB Yw12sIF6PhWO86rkdBfhMhCN3vBvsE73eQcR5OKUy/utAXCqqcAacE4kMHpWll6v1hzI UcMxBjSY2v4RZJg5ayvAqQj3gMgAXagX0hLoGt2jCODioqd1LFeAalrv8SEBsJJnDSYe dVz83m8gZxByq3yapVUqjw1nc97gfBHSnFOqgD8OoPw1N4xomunxbRSGPOsIQIhHsDSa OUfRQZMdx3GTmOmBLNtsYc3YNToWvEnPN2QncV07jZZqeIVq0CFiLLzEpEr46jvaNKSr zXKg== X-Gm-Message-State: AOAM531lE08YuHFSP8NUwfbByGL1BMZGrq3ORLB6/xTPmC9Vg2Za5ttr NegTj4SaxNR49/tXN5TEOIegr5hblExWVN5zDNCcmlWVCedOTk0BbSyG8efsjf7HtUmnc5ypiJ7 oRspF7gmKzFA730k5XkZp3gxx5aagKXvv7/+pZiYF9IV3qh7rR/Z+MjqfELKdkxXH8EKL+84UG6 sT X-Google-Smtp-Source: ABdhPJxUmr2i+eQbUWRBqJETR1ggD0F+dQjQzlKbcxf65IZMhO7nzFfXCzwuLtVclJuGjchHwquyCMv8Wo50 X-Received: by 2002:a25:bbd2:: with SMTP id c18mr4196310ybk.495.1595485381655; Wed, 22 Jul 2020 23:23:01 -0700 (PDT) Date: Thu, 23 Jul 2020 14:22:50 +0800 In-Reply-To: <20200723142128.Bluez.v4.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Message-Id: <20200723142128.Bluez.v4.2.Ic16589fde45fac0c496dfca2fa27672059114c3b@changeid> Mime-Version: 1.0 References: <20200723142128.Bluez.v4.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog Subject: [Bluez PATCH v4 2/2] audio/transport: supply volume on transport init From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Yu Liu Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0C9C440012 X-Rspamd-UID: 9143d1 From: Archie Pusaka Sometimes the response of RegisterNotification for volume change event came before we create the transport for the corresponding device. If that happens, the volume will be stuck to an uninitialized invalid value. The property Volume of MediaTransport1 will also be left unaccessible. This patch supplies the initial volume when creating a new transport. The value is obtained from the media_player object. However, since the avrcp session might not be created by the time the transport is created, we also try to initialize the volume when creating avrcp session. Reviewed-by: Yu Liu --- Changes in v4: None Changes in v3: -Add missing library Changes in v2: -Get the volume from media_player instead of from separate list profiles/audio/avrcp.c | 27 ++++++++++++++++- profiles/audio/avrcp.h | 2 ++ profiles/audio/media.c | 60 +++++++++++++++++++++++++++++--------- profiles/audio/media.h | 2 ++ profiles/audio/transport.c | 2 +- 5 files changed, 77 insertions(+), 16 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index d2d1d9dae..0ea66c671 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -64,6 +64,7 @@ #include "avctp.h" #include "avrcp.h" #include "control.h" +#include "media.h" #include "player.h" #include "transport.h" @@ -1701,7 +1702,6 @@ static uint8_t avrcp_handle_request_continuing(struct avrcp *session, if (pending->pdu_id != pdu->params[0]) goto err; - len = 0; pending->attr_ids = player_fill_media_attribute(player, pending->attr_ids, @@ -4037,8 +4037,12 @@ static void target_init(struct avrcp *session) player = g_slist_nth_data(server->players, 0); if (player != NULL) { + int8_t init_volume; target->player = player; player->sessions = g_slist_prepend(player->sessions, session); + + init_volume = media_player_get_device_volume(session->dev); + media_transport_update_device_volume(session->dev, init_volume); } session->supported_events |= (1 << AVRCP_EVENT_STATUS_CHANGED) | @@ -4476,6 +4480,27 @@ int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify) avrcp_handle_set_volume, session); } +struct avrcp_player *avrcp_get_target_player_by_device(struct btd_device *dev) +{ + struct avrcp_server *server; + struct avrcp *session; + struct avrcp_data *target; + + server = find_server(servers, device_get_adapter(dev)); + if (server == NULL) + return NULL; + + session = find_session(server->sessions, dev); + if (session == NULL) + return NULL; + + target = session->target; + if (target == NULL) + return NULL; + + return target->player; +} + static int avrcp_connect(struct btd_service *service) { struct btd_device *dev = btd_service_get_device(service); diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index 026a820f5..702d57442 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -116,3 +116,5 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands); size_t avrcp_browsing_general_reject(uint8_t *operands); + +struct avrcp_player *avrcp_get_target_player_by_device(struct btd_device *dev); diff --git a/profiles/audio/media.c b/profiles/audio/media.c index d4d58ec86..02bf82a49 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -239,6 +239,20 @@ static void media_endpoint_exit(DBusConnection *connection, void *user_data) media_endpoint_remove(endpoint); } +static struct media_adapter *find_adapter(struct btd_device *device) +{ + GSList *l; + + for (l = adapters; l; l = l->next) { + struct media_adapter *adapter = l->data; + + if (adapter->btd_adapter == device_get_adapter(device)) + return adapter; + } + + return NULL; +} + static void clear_configuration(struct media_endpoint *endpoint, struct media_transport *transport) { @@ -426,6 +440,33 @@ struct a2dp_config_data { a2dp_endpoint_config_t cb; }; +int8_t media_player_get_device_volume(struct btd_device *device) +{ + struct avrcp_player *target_player; + struct media_adapter *adapter; + GSList *l; + + if (!device) + return -1; + + target_player = avrcp_get_target_player_by_device(device); + if (!target_player) + return -1; + + adapter = find_adapter(device); + if (!adapter) + return -1; + + for (l = adapter->players; l; l = l->next) { + struct media_player *mp = l->data; + + if (mp->player == target_player) + return mp->volume; + } + + return -1; +} + static gboolean set_configuration(struct media_endpoint *endpoint, uint8_t *configuration, size_t size, media_endpoint_cb_t cb, @@ -439,6 +480,7 @@ static gboolean set_configuration(struct media_endpoint *endpoint, const char *path; DBusMessageIter iter; struct media_transport *transport; + int8_t init_volume; transport = find_device_transport(endpoint, device); @@ -451,6 +493,9 @@ static gboolean set_configuration(struct media_endpoint *endpoint, if (transport == NULL) return FALSE; + init_volume = media_player_get_device_volume(device); + media_transport_update_volume(transport, init_volume); + msg = dbus_message_new_method_call(endpoint->sender, endpoint->path, MEDIA_ENDPOINT_INTERFACE, "SetConfiguration"); @@ -646,20 +691,6 @@ static gboolean endpoint_init_a2dp_sink(struct media_endpoint *endpoint, return TRUE; } -static struct media_adapter *find_adapter(struct btd_device *device) -{ - GSList *l; - - for (l = adapters; l; l = l->next) { - struct media_adapter *adapter = l->data; - - if (adapter->btd_adapter == device_get_adapter(device)) - return adapter; - } - - return NULL; -} - static bool endpoint_properties_exists(const char *uuid, struct btd_device *dev, void *user_data) @@ -1779,6 +1810,7 @@ static struct media_player *media_player_create(struct media_adapter *adapter, mp->sender = g_strdup(sender); mp->path = g_strdup(path); mp->timer = g_timer_new(); + mp->volume = -1; mp->watch = g_dbus_add_disconnect_watch(conn, sender, media_player_exit, mp, diff --git a/profiles/audio/media.h b/profiles/audio/media.h index dd630d432..53694f4c6 100644 --- a/profiles/audio/media.h +++ b/profiles/audio/media.h @@ -33,3 +33,5 @@ void media_unregister(struct btd_adapter *btd_adapter); struct a2dp_sep *media_endpoint_get_sep(struct media_endpoint *endpoint); const char *media_endpoint_get_uuid(struct media_endpoint *endpoint); uint8_t media_endpoint_get_codec(struct media_endpoint *endpoint); + +int8_t media_player_get_device_volume(struct btd_device *device); diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 2ae5118c4..a2c4f7dfb 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -977,7 +977,7 @@ void media_transport_update_device_volume(struct btd_device *dev, { GSList *l; - if (dev == NULL) + if (dev == NULL || volume < 0) return; for (l = transports; l; l = l->next) { -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mEq1EvwyGV99mAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:49:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ODMGEfwyGV8FzgAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 08:49:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E0A574086C; Thu, 23 Jul 2020 08:49:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725858AbgGWGt0 (ORCPT + 1 other); Thu, 23 Jul 2020 02:49:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbgGWGt0 (ORCPT ); Thu, 23 Jul 2020 02:49:26 -0400 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CF50C0619DC for ; Wed, 22 Jul 2020 23:49:26 -0700 (PDT) Received: by mail-qv1-xf2e.google.com with SMTP id el4so2127294qvb.13 for ; Wed, 22 Jul 2020 23:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=CDMWFz/zPWYOXKwOA7M2SkB3diPkvKSPOO6Fv8ZhAz0=; b=bZxU6ZGzPkLyRlzy4JOxyNc9wX5qRPS6mHVQ2cqa9RPQFMwP+rDsvzKb3Zd6phl1Qo qWgtsr/UYrtoojhrx40XIUkfRSxQXkg9v/PvbSiChpYJTG4rKWgjySB7GqhkTmqH3nV/ XUHTFMlPnlrRxLCd2UM/02PJqeuRiuUCf4WKsociAZ0BLKLx10oMDqjD6HpKA6gV1nz7 s+SkVgAIrbss8b45+23QDvzQzvQ0gBUimA32qc+C+xblLL5Gs3Zqvyms4TBTUXt+YCdm VEoFpBhmhv0JjcxF3A0ZdxhD8dLjeyAjxSIcqaTvUPea8OIeR11NQwZZ8RBtB6Ct0tyl MjVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=CDMWFz/zPWYOXKwOA7M2SkB3diPkvKSPOO6Fv8ZhAz0=; b=mWHRPzRDeJRsVYGqL03Y9Qc8rZ9HWwHUDSJTVQ3olNFD1BJxZ3geq7moP53+TJRWmC wf8CccR67AbX3cSiLY2JUDgg9NKVG6LNW6drDT0NilSaD9XXYOjIDjsCQCI6v160Dl4o KZpsfoEtqUB7taJ/Bh25GVnTwEyaPtZ2YsFDPXYBUUjUZMLkUnI68cPpMzf+JmqMF0ig nzmfmEltwS5RIenOxRi5ZzNaX8ZmTP1BzBhtq0ycL3tQhZ8cNDqRwu8xa3vv61cN009g +NhUUBNYwgxOTapMEzHBBtGte6ILRkzJ6J5Oi6jDjrd7rfSpQN2isw0LXHAIQRFkiXSo Rzlw== X-Gm-Message-State: AOAM531uU52vDGYjoH0xsiR15/6tOUU9Z4MzTuFeUmjOqU9p63TZZB8h xFDetu62NGKXw1znP2qv4rpfxjrG7d0= X-Google-Smtp-Source: ABdhPJx9eRJXtlW0FgcJ9A34TNgOLYJivLuYrTP2JOKuY4Y6sWCiYzNOKJ6DzNuu6eBWP/KyTAqTfQ== X-Received: by 2002:a0c:b5d8:: with SMTP id o24mr3529503qvf.214.1595486965112; Wed, 22 Jul 2020 23:49:25 -0700 (PDT) Received: from [172.17.0.2] ([40.75.66.140]) by smtp.gmail.com with ESMTPSA id k48sm1972511qtc.14.2020.07.22.23.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 23:49:24 -0700 (PDT) Message-ID: <5f1932f4.1c69fb81.79bf5.abb4@mx.google.com> Date: Wed, 22 Jul 2020 23:49:24 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============7789159536542965512==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, apusaka@google.com Subject: RE: [Bluez,v4,1/2] audio/transport: change volume to 8bit Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200723142128.Bluez.v4.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> References: <20200723142128.Bluez.v4.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 40 X-Rspamd-Score: 6.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: E0A574086C X-Rspamd-UID: fea188 --===============7789159536542965512== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPACING: Unnecessary space before function pointer arguments #80: FILE: profiles/audio/avrcp.h:97: + void (*set_volume) (int8_t volume, struct btd_device *dev, - total: 0 errors, 1 warnings, 215 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============7789159536542965512==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UEIWNJAzGV/EzwEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 08:52:00 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cM7oMpAzGV/VOQAADc0bRg (envelope-from ); Thu, 23 Jul 2020 08:52:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9557D40869; Thu, 23 Jul 2020 08:51:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726092AbgGWGvz (ORCPT + 1 other); Thu, 23 Jul 2020 02:51:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725846AbgGWGvy (ORCPT ); Thu, 23 Jul 2020 02:51:54 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 851E1C0619DC for ; Wed, 22 Jul 2020 23:51:54 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id h7so4429860qkk.7 for ; Wed, 22 Jul 2020 23:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=fE90wEWs5slYKWbuMXkCnUUgmzD/w8ZaNrHXVRulRpg=; b=bieLwvVcJ40/Lnoj52/yCCLNU+Fz6hkNdfoGMNnRByYdbbhPVD8nxW6WCgFHQ72IdY OhYkmP9b3x6iuTYU2cA4anBMIc/2VWMaONwJTscWtxYrWQjRVX9dsNz/f4uR94JMNWgC EaNEgOJfuquNNcJkBigW/+ORBUp1tgL3X8efcOxjrgbw0TMwgmxSroXaZtUwmxuJRc70 0ZYlEeUEvKYbnmNwHO/JbASy//j5Mk+lKBkB14RXZ9A1hRCH+qWD4QBrSqCgEhoGVtle LIAQ0IphGabhObmmUf+jp8C+T02Y7smWijEgL07FL5JEsG7Fq2XbVdoebt2wcxvYkbXg Kcqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=fE90wEWs5slYKWbuMXkCnUUgmzD/w8ZaNrHXVRulRpg=; b=BN41Z8Ha+k0PsG4cVoULwAbPaBO/2fqPm/vGFL6X6eYHiy0YFCqcY09re22Bhw86st /dkMyV2B4JhXnILlv9tdE0wTv/xQVDaJhXJuwfEGiOdBmyPX6U9TzYJKZ+6V9yr0Xx/p Dpf5qXFcy7XI6EpwBW01SYH+rIPVD+6l2vF1RP/F7StvQxDiLHyKylkZO11Tk3xPl8cj OxgaOLfNZBCaVBYaVpwwHgTIYxwNs9scGN7zOZ8FNEtYWzHP//aAEnWbNkagaXXJeQ7V RejmDz4ArqPnwcdy6XRQgwJq4YMv83zGg/NKeoqzCrUZO7Ew+4iRhqdDpTuh3V2UVkUn FQQA== X-Gm-Message-State: AOAM531Ry6/A0nuB0Wmh7kroYNo0MK3CXqw+R1ky7iunr102ksO1/kv9 akB2+gsSD2c/CQbxU4nc8+riJcXHoiY= X-Google-Smtp-Source: ABdhPJzG96qfoI62lf9kcY4weEcD9YmSNMtXgBbFzdFmjfcajRPkTo+Y3TbTk9KXR5AX/RJ7N1F3Uw== X-Received: by 2002:a37:b987:: with SMTP id j129mr3858100qkf.120.1595487113657; Wed, 22 Jul 2020 23:51:53 -0700 (PDT) Received: from [172.17.0.2] ([40.75.66.140]) by smtp.gmail.com with ESMTPSA id r18sm1707280qtf.62.2020.07.22.23.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 23:51:53 -0700 (PDT) Message-ID: <5f193389.1c69fb81.a79b1.9a7f@mx.google.com> Date: Wed, 22 Jul 2020 23:51:53 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============2522545925444341057==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, apusaka@google.com Subject: RE: [Bluez,v4,1/2] audio/transport: change volume to 8bit Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200723142128.Bluez.v4.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> References: <20200723142128.Bluez.v4.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 36 X-Rspamd-Score: 5.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9557D40869 X-Rspamd-UID: 7d518e --===============2522545925444341057== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnByb2ZpbGVzL2F1ZGlvL2F2cmNwLmM6IEluIGZ1bmN0aW9uIOKAmGF2 cmNwX2hhbmRsZV9yZWdpc3Rlcl9ub3RpZmljYXRpb27igJk6CnByb2ZpbGVzL2F1ZGlvL2F2cmNw LmM6MTY2NDoyMjogZXJyb3I6IGNvbXBhcmlzb24gaXMgYWx3YXlzIGZhbHNlIGR1ZSB0byBsaW1p dGVkIHJhbmdlIG9mIGRhdGEgdHlwZSBbLVdlcnJvcj10eXBlLWxpbWl0c10KIDE2NjQgfCAgIGlm IChwZHUtPnBhcmFtc1sxXSA8IDApCiAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgXgpjYzE6 IGFsbCB3YXJuaW5ncyBiZWluZyB0cmVhdGVkIGFzIGVycm9ycwptYWtlWzFdOiAqKiogW01ha2Vm aWxlOjg0Njc6IHByb2ZpbGVzL2F1ZGlvL2JsdWV0b290aGQtYXZyY3Aub10gRXJyb3IgMQptYWtl OiAqKiogW01ha2VmaWxlOjQwMTA6IGFsbF0gRXJyb3IgMgoKCgotLS0KUmVnYXJkcywKTGludXgg Qmx1ZXRvb3RoCg== --===============2522545925444341057==-- Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yNLvLhU7GV8K/gEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 09:24:05 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id QON4LBU7GV+F7gAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 09:24:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BC61D40012; Thu, 23 Jul 2020 09:24:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726739AbgGWHX7 (ORCPT + 1 other); Thu, 23 Jul 2020 03:23:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgGWHX7 (ORCPT ); Thu, 23 Jul 2020 03:23:59 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D64CEC0619DC for ; Thu, 23 Jul 2020 00:23:58 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id l17so5457021ybe.18 for ; Thu, 23 Jul 2020 00:23:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=ieW6mPLtHmE2rU2masBC39qKPkR6xDlE2Y6UKNuuw6U=; b=NXIv14w5kRl3elr5TkpoSF1nOHWXNhFZ0Zg3+K5qJwLIHrxGhtezaeX3f1jJfL6SU0 owSlDs0Nyi7rDZfJy2BbBem3EJL/i+d60FfzWR1ctaXm16J3OG/mWPu8d2y0ApkTjNHF 9IcWsLzriuSVZN3rCjJ6Krti4V7EaeErEfa/mGvM25rGUAxDOERxgSSvaPY+qI/lxwcJ pU8NSG+TycmWIV6jQbLKjT4fy812+cdpg3+VtgI277FMc8frAGnaJ8CZNQlzUY03xKmo jV9ZQXD0F0Vs3CaeBzI/IkSolwUjto+mVcol8EJ7vdHEhxN3b3z3a+qRQKq+m+/vx8Q/ e/KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=ieW6mPLtHmE2rU2masBC39qKPkR6xDlE2Y6UKNuuw6U=; b=pw3YXBag0buFWnHnSwQsPeTvjWJW5cQ8062yTNVQtSgk/NJzIdpr84uc/wuBvmYYr8 adaMF9omjpl9+fg51pMKDxLhthfk9hzNVNqpJu7X43qVBGRKFuriGV4Q+d2/JEkMjR63 ux/0+UnStoB3Vn+ps3twxurlNVBfYFOUhjzSfwzja/5yK7pPvx1NRT+dag1jUUsGno1Z /WV2ZpKemARlKTxTCATxVQFKagr3DZTiRQUeM3Cew4Mp3oNCClFVbIDF67AJSISpmstX pStN04kjEv/Fj4sy7jbCF7E85PETs0Wp5Hn5T9yKSrk8Ko8u5wl3tWlSzz4bLVRGTF6h 7/Cw== X-Gm-Message-State: AOAM532RFvZEuB/mIhM7TtlHQIfdpA6e51l4Aokrmx4Ap866/H+hLWO4 QqKdD3iYI4KNH1cOw9e+xwfHjAKKzfPnDa4Y6gEMCXRygyJQ8Xk8++Mf4QKm1HFKab1JNeRxgCr 2xfOb0I/QIsOZ+iY2qch92Ci1lmK6z5RpPIESk2WbCfoB1ufJoUqF3Jd/6628C+bllF+eC9gnV2 iX X-Google-Smtp-Source: ABdhPJyNZGQSOB+iV2qs45HP/f0bPV2sxL7oRJTtxaa+TofZm8yaSUcqvRpJV16s77b5fvfsgzyMCu7zVtVD X-Received: by 2002:a25:8206:: with SMTP id q6mr5012329ybk.388.1595489038032; Thu, 23 Jul 2020 00:23:58 -0700 (PDT) Date: Thu, 23 Jul 2020 15:23:39 +0800 Message-Id: <20200723152327.Bluez.v5.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog Subject: [Bluez PATCH v5 1/2] audio/transport: change volume to 8bit From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka , Michael Sun Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 0.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: BC61D40012 X-Rspamd-UID: c54828 From: Archie Pusaka The valid range of volume is 0 - 127, yet it is stored in 16bit data type. This patch modifies it so we use 8bit data type to store volume instead. Furthermore we also use signed type, so negative values can be used to indicate invalid volume. Reviewed-by: Michael Sun --- Changes in v5: -Fix coding style and conversion error Changes in v4: -Use int8_t instead of uint8_t Changes in v3: None Changes in v2: None profiles/audio/avrcp.c | 17 +++++++++----- profiles/audio/avrcp.h | 35 ++++++++++++++--------------- profiles/audio/media.c | 4 ++-- profiles/audio/transport.c | 45 +++++++++++++++++++------------------- profiles/audio/transport.h | 8 +++---- 5 files changed, 56 insertions(+), 53 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 1bf85041e..7a06c8353 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -1595,6 +1595,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, struct btd_device *dev = session->dev; uint16_t len = ntohs(pdu->params_len); uint64_t uid; + int8_t volume; GList *settings; /* @@ -1659,10 +1660,11 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, len = 1; break; case AVRCP_EVENT_VOLUME_CHANGED: - pdu->params[1] = media_transport_get_device_volume(dev); - if (pdu->params[1] > 127) + volume = media_transport_get_device_volume(dev); + if (volume < 0) goto err; + pdu->params[1] = volume; len = 2; break; @@ -1757,7 +1759,7 @@ static uint8_t avrcp_handle_set_absolute_volume(struct avrcp *session, uint8_t transaction) { uint16_t len = ntohs(pdu->params_len); - uint8_t volume; + int8_t volume; if (len != 1) goto err; @@ -3623,7 +3625,7 @@ static void avrcp_volume_changed(struct avrcp *session, struct avrcp_header *pdu) { struct avrcp_player *player = target_get_player(session); - uint8_t volume; + int8_t volume; volume = pdu->params[1] & 0x7F; @@ -4371,7 +4373,7 @@ static gboolean avrcp_handle_set_volume(struct avctp *conn, uint8_t code, struct avrcp *session = user_data; struct avrcp_player *player = target_get_player(session); struct avrcp_header *pdu = (void *) operands; - uint8_t volume; + int8_t volume; if (code == AVC_CTYPE_REJECTED || code == AVC_CTYPE_NOT_IMPLEMENTED || pdu == NULL) @@ -4434,13 +4436,16 @@ static int avrcp_event(struct avrcp *session, uint8_t id, const void *data) return err; } -int avrcp_set_volume(struct btd_device *dev, uint8_t volume, bool notify) +int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify) { struct avrcp_server *server; struct avrcp *session; uint8_t buf[AVRCP_HEADER_LENGTH + 1]; struct avrcp_header *pdu = (void *) buf; + if (volume < 0) + return -EINVAL; + server = find_server(servers, device_get_adapter(dev)); if (server == NULL) return -EINVAL; diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index 86d310c73..a08e7325e 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -83,27 +83,27 @@ #define AVRCP_EVENT_LAST AVRCP_EVENT_VOLUME_CHANGED struct avrcp_player_cb { - GList *(*list_settings) (void *user_data); - const char *(*get_setting) (const char *key, void *user_data); - int (*set_setting) (const char *key, const char *value, + GList *(*list_settings)(void *user_data); + const char *(*get_setting)(const char *key, void *user_data); + int (*set_setting)(const char *key, const char *value, void *user_data); - uint64_t (*get_uid) (void *user_data); - const char *(*get_metadata) (const char *key, void *user_data); - GList *(*list_metadata) (void *user_data); - const char *(*get_status) (void *user_data); - uint32_t (*get_position) (void *user_data); - uint32_t (*get_duration) (void *user_data); - const char *(*get_name) (void *user_data); - void (*set_volume) (uint8_t volume, struct btd_device *dev, + uint64_t (*get_uid)(void *user_data); + const char *(*get_metadata)(const char *key, void *user_data); + GList *(*list_metadata)(void *user_data); + const char *(*get_status)(void *user_data); + uint32_t (*get_position)(void *user_data); + uint32_t (*get_duration)(void *user_data); + const char *(*get_name)(void *user_data); + void (*set_volume)(int8_t volume, struct btd_device *dev, void *user_data); - bool (*play) (void *user_data); - bool (*stop) (void *user_data); - bool (*pause) (void *user_data); - bool (*next) (void *user_data); - bool (*previous) (void *user_data); + bool (*play)(void *user_data); + bool (*stop)(void *user_data); + bool (*pause)(void *user_data); + bool (*next)(void *user_data); + bool (*previous)(void *user_data); }; -int avrcp_set_volume(struct btd_device *dev, uint8_t volume, bool notify); +int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify); struct avrcp_player *avrcp_register_player(struct btd_adapter *adapter, struct avrcp_player_cb *cb, @@ -114,6 +114,5 @@ void avrcp_unregister_player(struct avrcp_player *player); void avrcp_player_event(struct avrcp_player *player, uint8_t id, const void *data); - size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands); size_t avrcp_browsing_general_reject(uint8_t *operands); diff --git a/profiles/audio/media.c b/profiles/audio/media.c index a0173fdd4..d4d58ec86 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -120,7 +120,7 @@ struct media_player { char *status; uint32_t position; uint32_t duration; - uint8_t volume; + int8_t volume; GTimer *timer; bool play; bool pause; @@ -1199,7 +1199,7 @@ static uint32_t get_duration(void *user_data) return mp->duration; } -static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) +static void set_volume(int8_t volume, struct btd_device *dev, void *user_data) { struct media_player *mp = user_data; diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 48fabba9b..2ae5118c4 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -86,7 +86,7 @@ struct media_owner { struct a2dp_transport { struct avdtp *session; uint16_t delay; - uint16_t volume; + int8_t volume; }; struct media_transport { @@ -634,7 +634,7 @@ static gboolean volume_exists(const GDBusPropertyTable *property, void *data) struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; - return a2dp->volume <= 127; + return a2dp->volume >= 0; } static gboolean get_volume(const GDBusPropertyTable *property, @@ -642,8 +642,9 @@ static gboolean get_volume(const GDBusPropertyTable *property, { struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; + uint16_t volume = (uint16_t)a2dp->volume; - dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &a2dp->volume); + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &volume); return TRUE; } @@ -654,27 +655,20 @@ static void set_volume(const GDBusPropertyTable *property, { struct media_transport *transport = data; struct a2dp_transport *a2dp = transport->data; - uint16_t volume; + uint16_t arg; + int8_t volume; bool notify; - if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) { - g_dbus_pending_property_error(id, - ERROR_INTERFACE ".InvalidArguments", - "Invalid arguments in method call"); - return; - } + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) + goto error; - dbus_message_iter_get_basic(iter, &volume); - - if (volume > 127) { - g_dbus_pending_property_error(id, - ERROR_INTERFACE ".InvalidArguments", - "Invalid arguments in method call"); - return; - } + dbus_message_iter_get_basic(iter, &arg); + if (arg > INT8_MAX) + goto error; g_dbus_pending_property_success(id); + volume = (int8_t)arg; if (a2dp->volume == volume) return; @@ -688,6 +682,11 @@ static void set_volume(const GDBusPropertyTable *property, "Volume"); avrcp_set_volume(transport->device, volume, notify); + return; + +error: + g_dbus_pending_property_error(id, ERROR_INTERFACE ".InvalidArguments", + "Invalid arguments in method call"); } static gboolean endpoint_exists(const GDBusPropertyTable *property, void *data) @@ -931,14 +930,14 @@ struct btd_device *media_transport_get_dev(struct media_transport *transport) return transport->device; } -uint16_t media_transport_get_volume(struct media_transport *transport) +int8_t media_transport_get_volume(struct media_transport *transport) { struct a2dp_transport *a2dp = transport->data; return a2dp->volume; } void media_transport_update_volume(struct media_transport *transport, - uint8_t volume) + int8_t volume) { struct a2dp_transport *a2dp = transport->data; @@ -953,12 +952,12 @@ void media_transport_update_volume(struct media_transport *transport, MEDIA_TRANSPORT_INTERFACE, "Volume"); } -uint8_t media_transport_get_device_volume(struct btd_device *dev) +int8_t media_transport_get_device_volume(struct btd_device *dev) { GSList *l; if (dev == NULL) - return 128; + return -1; for (l = transports; l; l = l->next) { struct media_transport *transport = l->data; @@ -974,7 +973,7 @@ uint8_t media_transport_get_device_volume(struct btd_device *dev) } void media_transport_update_device_volume(struct btd_device *dev, - uint8_t volume) + int8_t volume) { GSList *l; diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index ac542bf6c..78024372f 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -32,14 +32,14 @@ struct media_transport *media_transport_create(struct btd_device *device, void media_transport_destroy(struct media_transport *transport); const char *media_transport_get_path(struct media_transport *transport); struct btd_device *media_transport_get_dev(struct media_transport *transport); -uint16_t media_transport_get_volume(struct media_transport *transport); +int8_t media_transport_get_volume(struct media_transport *transport); void media_transport_update_delay(struct media_transport *transport, uint16_t delay); void media_transport_update_volume(struct media_transport *transport, - uint8_t volume); + int8_t volume); void transport_get_properties(struct media_transport *transport, DBusMessageIter *iter); -uint8_t media_transport_get_device_volume(struct btd_device *dev); +int8_t media_transport_get_device_volume(struct btd_device *dev); void media_transport_update_device_volume(struct btd_device *dev, - uint8_t volume); + int8_t volume); -- 2.28.0.rc0.105.gf9edc3c819-goog Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8On/AvlqGV8cSQEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 12:48:25 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id UILqAflqGV/OswAA0J78UA (envelope-from ); Thu, 23 Jul 2020 12:48:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F1FBA408B4; Thu, 23 Jul 2020 12:48:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728426AbgGWKsM (ORCPT + 1 other); Thu, 23 Jul 2020 06:48:12 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:58667 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbgGWKsL (ORCPT ); Thu, 23 Jul 2020 06:48:11 -0400 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.69 with qID 06NAlmzJ7027604, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexmb06.realtek.com.tw[172.21.6.99]) by rtits2.realtek.com.tw (8.15.2/2.66/5.86) with ESMTPS id 06NAlmzJ7027604 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Thu, 23 Jul 2020 18:47:48 +0800 Received: from RTEXMB03.realtek.com.tw (172.21.6.96) by RTEXMB06.realtek.com.tw (172.21.6.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Thu, 23 Jul 2020 18:47:47 +0800 Received: from localhost.localdomain (172.21.83.110) by RTEXMB03.realtek.com.tw (172.21.6.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Thu, 23 Jul 2020 18:47:47 +0800 From: To: , , , CC: , , , , , Subject: [PATCH] Bluetooth: Return NOTIFY_DONE for hci_suspend_notifier Date: Thu, 23 Jul 2020 18:47:42 +0800 Message-ID: <20200723104742.19780-1-max.chou@realtek.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.83.110] X-ClientProxiedBy: RTEXMB03.realtek.com.tw (172.21.6.96) To RTEXMB03.realtek.com.tw (172.21.6.96) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: F1FBA408B4 X-Rspamd-UID: c93745 From: Max Chou The original return is NOTIFY_STOP, but notifier_call_chain would stop the future call for register_pm_notifier even registered on other Kernel modules with the same priority which value is zero. Signed-off-by: Max Chou --- net/bluetooth/hci_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6509f785dd14..3ce06347216a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3513,7 +3513,7 @@ static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action, bt_dev_err(hdev, "Suspend notifier action (%lu) failed: %d", action, ret); - return NOTIFY_STOP; + return NOTIFY_DONE; } /* Alloc HCI device */ -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cIfCIpZxGV8idAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 13:16:38 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6P6cIZZxGV84RwEAgupzMw (envelope-from ); Thu, 23 Jul 2020 13:16:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EBFFC40B7A; Thu, 23 Jul 2020 13:16:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728543AbgGWLQZ convert rfc822-to-8bit (ORCPT + 1 other); Thu, 23 Jul 2020 07:16:25 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:60741 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727940AbgGWLQY (ORCPT ); Thu, 23 Jul 2020 07:16:24 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mtapsc-1-ViGpBrHmNJOPXyJW7yMjBg-2; Thu, 23 Jul 2020 12:16:19 +0100 X-MC-Unique: ViGpBrHmNJOPXyJW7yMjBg-2 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 23 Jul 2020 12:16:16 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 23 Jul 2020 12:16:16 +0100 From: David Laight To: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , "Eric Dumazet" CC: "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: RE: [PATCH 13/26] bpfilter: switch bpfilter_ip_set_sockopt to sockptr_t Thread-Topic: [PATCH 13/26] bpfilter: switch bpfilter_ip_set_sockopt to sockptr_t Thread-Index: AQHWYOJf8qVR0zowd02v8gaMoEO9+6kVA2RQ Date: Thu, 23 Jul 2020 11:16:16 +0000 Message-ID: <621e193e4af74d8198ed87d6a9ce8260@AcuMS.aculab.com> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-14-hch@lst.de> In-Reply-To: <20200723060908.50081-14-hch@lst.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.55 / 15.00 / 200.00 X-Rspamd-Queue-Id: EBFFC40B7A X-Rspamd-UID: 2af15a From: Christoph Hellwig > Sent: 23 July 2020 07:09 > > This is mostly to prepare for cleaning up the callers, as bpfilter by > design can't handle kernel pointers. You've failed to fix the sense of the above... David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WCC0Dz5xGV8gdAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 13:15:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id QFo0Dj5xGV/t9gAA0J78UA (envelope-from ); Thu, 23 Jul 2020 13:15:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BDE5A4086A; Thu, 23 Jul 2020 13:15:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728531AbgGWLOw (ORCPT + 1 other); Thu, 23 Jul 2020 07:14:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726867AbgGWLOw (ORCPT ); Thu, 23 Jul 2020 07:14:52 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB255C0619DC; Thu, 23 Jul 2020 04:14:51 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id y10so5980718eje.1; Thu, 23 Jul 2020 04:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=vdYyoECOJpkvRW+iDSJN0RIdv+nH41NS293U/5tTNzU=; b=B5vDCuMK34uIsnpD9z3FcIKsP+ARgUC68tC2JBNii294ZVz92X5OyPMGm1cnHIYPvl 3DKQSNa/jdlu0biVdgVy3X/Usw30FobXy8VPbwfs9mZO4hgKFIB5Q6ou4++0iHZWcmIg rfstWtDzaQOlAHrnGsoBfnDZMJ2kD6uwV1y2oKkj2sr770VnwjwNmw0Za18fcxNwyhPN PX5gNfWd5bOhXJY1Kvg+SfF57+CLOAPlOGTBbqcVuFCBHygW7tXdpNSN+uznlRCislSc n2D4vVeaN2C63ZjJ8LYUcP4YwR3kpvL7IT5R8VKRAe3yBJewccDUsJmVY4TugCpk7vZl wX7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=vdYyoECOJpkvRW+iDSJN0RIdv+nH41NS293U/5tTNzU=; b=OSvvl4od8qhpj0fbhiA5979OI0+nto4RcDPfbflf+CsAatqxszOPd30p2nbgNR+IfU Hd4Ap9iZqCDKpgUp/3NGF5K7lQtcFWmFg7DLFnZ6EUXBh/VXovuO6fj16efUU0UZJB56 /yZaiZovVILBMf1WY2kqzsc28Xlbo1UNKEuIIMVN9CcfLJ94OEb+/LRhUFn+19ynMxmr k+mdHaryMe5vp8ozuKPKGl1b+kojsES1aVxBo8FD/TjgQC+XFj3r/D/vvcvm8xuVF0i+ 9ryHfVoYSCkW38tTAwIW5BkJD0WHLiwdFF/WScJ0DlHUbTehhAEeCth11uxc5MqgI1dW srSg== X-Gm-Message-State: AOAM530tjR5YjkGijVHLCXbqdpcgxRzpeQ+0qqsNcCysFIF6kxanE7VZ 6AArdUThi60tVzU3ctXj05E= X-Google-Smtp-Source: ABdhPJz4rM+z9eQOHfGGUF+Hj1F0q1VizoeW8bUipy1mWLCV1z/2+oZlfysZjxBFObbrbyKXQkFElw== X-Received: by 2002:a17:906:1187:: with SMTP id n7mr3696742eja.161.1595502890446; Thu, 23 Jul 2020 04:14:50 -0700 (PDT) Received: from ltop.local ([2a02:a03f:a7fb:e200:f109:49dc:4e2a:ea12]) by smtp.gmail.com with ESMTPSA id y22sm1817552ejj.67.2020.07.23.04.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 04:14:49 -0700 (PDT) Date: Thu, 23 Jul 2020 13:14:47 +0200 From: Luc Van Oostenryck To: Christoph Hellwig Cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 01/26] bpfilter: fix up a sparse annotation Message-ID: <20200723111447.3xj7cidlsspofsja@ltop.local> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-2-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200723060908.50081-2-hch@lst.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: 0.11 / 15.00 / 200.00 X-Rspamd-Queue-Id: BDE5A4086A X-Rspamd-UID: 1dfff4 On Thu, Jul 23, 2020 at 08:08:43AM +0200, Christoph Hellwig wrote: > The __user doesn't make sense when casting to an integer type, just > switch to a uintptr_t cast which also removes the need for the __force. Feel free to add my: Reviewed-by: Luc Van Oostenryck -- Luc Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8Nd4GVB4GV8MsgEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 13:45:20 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0GfdF1B4GV9VUQEAgupzMw (envelope-from ); Thu, 23 Jul 2020 13:45:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C886AA1974; Thu, 23 Jul 2020 13:45:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728853AbgGWLpF (ORCPT + 1 other); Thu, 23 Jul 2020 07:45:05 -0400 Received: from verein.lst.de ([213.95.11.211]:59827 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGWLpE (ORCPT ); Thu, 23 Jul 2020 07:45:04 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 82EBD68AFE; Thu, 23 Jul 2020 13:44:58 +0200 (CEST) Date: Thu, 23 Jul 2020 13:44:58 +0200 From: 'Christoph Hellwig' To: David Laight Cc: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: Re: [PATCH 13/26] bpfilter: switch bpfilter_ip_set_sockopt to sockptr_t Message-ID: <20200723114458.GA31363@lst.de> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-14-hch@lst.de> <621e193e4af74d8198ed87d6a9ce8260@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <621e193e4af74d8198ed87d6a9ce8260@AcuMS.aculab.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.62 / 15.00 / 200.00 X-Rspamd-Queue-Id: C886AA1974 X-Rspamd-UID: b3fad3 On Thu, Jul 23, 2020 at 11:16:16AM +0000, David Laight wrote: > From: Christoph Hellwig > > Sent: 23 July 2020 07:09 > > > > This is mostly to prepare for cleaning up the callers, as bpfilter by > > design can't handle kernel pointers. > > You've failed to fix the sense of the above... The sense still is correct. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QGhbFVuBGV8WzAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 14:23:55 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id GG2EFFuBGV+ZSQEA0J78UA (envelope-from ); Thu, 23 Jul 2020 14:23:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 80DDDA1306; Thu, 23 Jul 2020 14:23:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728560AbgGWMXt (ORCPT + 1 other); Thu, 23 Jul 2020 08:23:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728180AbgGWMXs (ORCPT ); Thu, 23 Jul 2020 08:23:48 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD226C0619DC for ; Thu, 23 Jul 2020 05:23:48 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id k23so5934598iom.10 for ; Thu, 23 Jul 2020 05:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Iv6dW36f0DeH7DIBoLdlpy5elzONC1wAzuaEdOBW3IY=; b=O1lyPZNeLdshpd0e6XEA0u+WC/UrBjCftbWJ2C5eU3SwKFT08V2zk3h6ZXg3gVHccS dne5iTeCzV2j93eDtmz/6w85tHlimNYd50nv6Amcpq3oPWNhERuhJcL90M/EukxS5WBD jTMwYvbBiWSFY8D03vzOfU6wpzLdVT4SXx5q8/z5LrIgpdJqmh8q5eY4DrGA0oPD8HJn hQbAIf2zcp3vhCcPLHtm2ef+2YWk2d/QqcRCVT3bb3NbMpLGVHh/JAlw4Yg6aMmtjskd wbPcS2+Zqbm6d5FMIJ7HhBQUhED8AJzuFahpbtFzxsSZM2/JibSdTiTg5Vl/w4Tqj62P jarg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Iv6dW36f0DeH7DIBoLdlpy5elzONC1wAzuaEdOBW3IY=; b=TFEwzExQ0GkPX64GvZcAZ5ixLMiHuXDpzUvzuLSLt8V0JxGiSfnNKBV3fiq+kXf+d4 CVjhgD+lwVnr4IulQwtIWrqAdC/7S40fr/KzOvIRcKd3TwLPj3jElG23n8x8CoUQzGXw 4zakwkhlXap2iaZr/zjz8hZ6LB2He5HjoOYszd9D5gj33xbcRWr+AxmDkLmqWaWzNe06 RrW4mopEM339NyHBC+Z4tB0OfC71ESJcBx6N4i4ZOsjun5nEQMoe5SSd2CiDbR7tNTkT NP+UuoJPCzaMJ5PN5f0W1ZVgHl0stnE/wkCnK8/GGarYDgj5Zm6zH4FBbSGnR8K6O25m OTQA== X-Gm-Message-State: AOAM533LT1mymThRTMxPhM3G5w5PmvnyBIra6ot8kprvp/3/rB/TSmjU CZ+JFwvso1/4MgM05XXUiUYnVEqA4GVC7/+m4J9PNoTn0H8= X-Google-Smtp-Source: ABdhPJx04CJClwGF+92qzMIgsFrJDYCSVmp1EJzQ54zSp/VPtn7Yn9IvSCrWyISeUzj/sscakOQlHDa54CODDLzf+Xk= X-Received: by 2002:a02:3f41:: with SMTP id c1mr4502945jaf.29.1595507027851; Thu, 23 Jul 2020 05:23:47 -0700 (PDT) MIME-Version: 1.0 References: <20200713062213.3692-1-sathish.narasimman@intel.com> <20200713062213.3692-9-sathish.narasimman@intel.com> <5CD116F7-EFB3-47A2-B8D5-0012657F10F9@holtmann.org> In-Reply-To: <5CD116F7-EFB3-47A2-B8D5-0012657F10F9@holtmann.org> From: Sathish Narasimman Date: Thu, 23 Jul 2020 17:53:33 +0530 Message-ID: Subject: Re: [PATCH v4 8/8] Bluetooth: Enable controller RPA resolution using Experimental feature To: Marcel Holtmann Cc: Bluez mailing list , Sathish Narasimman Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: 80DDDA1306 X-Rspamd-UID: 3931d7 Hi Marcel On Thu, Jul 16, 2020 at 12:43 PM Marcel Holtmann wrote: > > Hi Sathish, > > > This patch adds support to enable the use of RPA Address resolution > > using expermental feature mgmt command. > > everything looks fine, except for this patch. I just prefer to only apply the others if we can apply this one as well. > > > Signed-off-by: Sathish Narasimman > > --- > > include/net/bluetooth/hci.h | 1 + > > net/bluetooth/hci_event.c | 3 ++- > > net/bluetooth/hci_request.c | 6 +++-- > > net/bluetooth/mgmt.c | 52 +++++++++++++++++++++++++++++++++++++ > > 4 files changed, 59 insertions(+), 3 deletions(-) > > > > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h > > index 4ff2fc4498f3..cb284365b4c1 100644 > > --- a/include/net/bluetooth/hci.h > > +++ b/include/net/bluetooth/hci.h > > @@ -307,6 +307,7 @@ enum { > > HCI_FORCE_BREDR_SMP, > > HCI_FORCE_STATIC_ADDR, > > HCI_LL_RPA_RESOLUTION, > > + HCI_ENABLE_RPA_RESOLUTION, > > I would call this ENABLE_LL_PRIVAY. It put its more in line with use_ll_privacy and clearly distinct from the LL_RPA_RESOLUTION with is a HCI operational mode. > Will change it > > HCI_CMD_PENDING, > > HCI_FORCE_NO_MITM, > > > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > index 684c68cb5c76..c8a5e1e4dba2 100644 > > --- a/net/bluetooth/hci_event.c > > +++ b/net/bluetooth/hci_event.c > > @@ -5222,7 +5222,8 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, > > le16_to_cpu(ev->latency), > > le16_to_cpu(ev->supervision_timeout)); > > > > - if (use_ll_privacy(hdev) && > > + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && > > + use_ll_privacy(hdev) && > > hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) > > I would leave use_ll_privacy at the top and add the new one after it. > > > hci_req_disable_address_resolution(hdev); > > } > > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > > index c3193f7f9ff0..cb44b83539e6 100644 > > --- a/net/bluetooth/hci_request.c > > +++ b/net/bluetooth/hci_request.c > > @@ -677,7 +677,8 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) > > } > > > > /* Disable address resolution */ > > - if (use_ll_privacy(hdev) && > > + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && > > + use_ll_privacy(hdev) && > > Same here. > > > hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { > > __u8 enable = 0x00; > > hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); > > @@ -870,7 +871,8 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, > > return; > > } > > > > - if (use_ll_privacy(hdev) && addr_resolv) { > > + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && > > + use_ll_privacy(hdev) && addr_resolv) { > > And here. > > > u8 enable = 0x01; > > hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); > > } > > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > > index c292d5de4dc3..fbe02ab5fa05 100644 > > --- a/net/bluetooth/mgmt.c > > +++ b/net/bluetooth/mgmt.c > > @@ -3759,6 +3759,12 @@ static const u8 simult_central_periph_uuid[16] = { > > 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > > }; > > > > +/* 15c0a148-c273-11ea-b3de-0242ac130004 */ > > +static const u8 rpa_resolution_uuid[16] = { > > + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, > > + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, > > +}; > > + > > static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > > void *data, u16 data_len) > > { > > @@ -3795,6 +3801,17 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > > idx++; > > } > > > > + if (hdev) { > > If use_ll_privacy is not available, then we should also not expose this experimental feature. > > > + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION)) > > + flags = BIT(0); > > + else > > + flags = 0; > > + > > And since we only support the RPA resolution for central mode at the moment, we really now need to disable advertising support. So this one needs to indicate the the supported settings will change when enabled. > Does disable advertising support means clearing HCI_ADVERTISING flag? Or __hci_req_disable_advertising Please review the next version of the changes where i updated clearing the flag > > + memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); > > + rp->features[idx].flags = cpu_to_le32(flags); > > + idx++; > > + } > > + > > rp->feature_count = cpu_to_le16(idx); > > > > /* After reading the experimental features information, enable > > @@ -3895,6 +3912,41 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, > > } > > #endif > > > > + if (!memcmp(cp->uuid, rpa_resolution_uuid, 16)) { > > + bool val; > > + int err; > > + > > + /* Parameters are limited to a single octet */ > > + if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) > > + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, > > + MGMT_OP_SET_EXP_FEATURE, > > + MGMT_STATUS_INVALID_PARAMS); > > + > > + /* Only boolean on/off is supported */ > > + if (cp->param[0] != 0x00 && cp->param[0] != 0x01) > > + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, > > + MGMT_OP_SET_EXP_FEATURE, > > + MGMT_STATUS_INVALID_PARAMS); > > + > > + val = !!cp->param[0]; > > + > > + if (val) > > + hci_dev_set_flag(hdev, HCI_ENABLE_RPA_RESOLUTION); > > + else > > + hci_dev_clear_flag(hdev, HCI_ENABLE_RPA_RESOLUTION); > > + > > + memcpy(rp.uuid, rpa_resolution_uuid, 16); > > + rp.flags = cpu_to_le32(val ? BIT(0) : 0); > > + > > + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); > > + > > + err = mgmt_cmd_complete(sk, MGMT_INDEX_NONE, > > + MGMT_OP_SET_EXP_FEATURE, 0, > > + &rp, sizeof(rp)); > > The exp_feature_changed event is missing. In addition you need to handle the ZERO_KEY branch which means it will reset all experimental features back to default. Changes done please help to review version 5 > > > + > > + return err; > > + } > > + > > return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, > > MGMT_OP_SET_EXP_FEATURE, > > MGMT_STATUS_NOT_SUPPORTED); > > Regards > > Marcel > Regards Sathish N Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UNMBMASEGV8WzAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 14:35:16 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UKMVLgSEGV9zOQAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 14:35:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6D2E0A179F; Thu, 23 Jul 2020 14:35:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728787AbgGWMfL (ORCPT + 1 other); Thu, 23 Jul 2020 08:35:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGWMfK (ORCPT ); Thu, 23 Jul 2020 08:35:10 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A881AC0619DC for ; Thu, 23 Jul 2020 05:35:10 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id 1so2940276pfn.9 for ; Thu, 23 Jul 2020 05:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=xSub10RztAkAVkR7dQ1tuib+ohmh4r9LyvxXZPcSzms=; b=t54Jm1miiYNTB34tY64pYv+E9aKT8h/8GNbf10lz/YcAJZPt/KM7p7Z5oktdRwSDug fo6RPfuSHjheWzwfNEjlR72nyFjwIwfSTu5LAVGepzfIqHxMmLPoUxxQdmkO6n5+j4eq K/0wuKl7c0ewyMAcAaBP27nJ7p9U5REeYYTJD6Q2n9oaP6Icj3Kw8JRDu4sHWyy5sJOH j6z12sx0loPkTNuHRskcsqhBFxzNyGyGMe1lww7S1QdX32lnSPxN3WeOGqDFYJrsJXd9 BxB2YUCDpr3wx9ByG0RdWU4ndmCUIbi4THWd+2NhCoSFaJChtUgi0EUWv0SpDBvOivtL Hfkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xSub10RztAkAVkR7dQ1tuib+ohmh4r9LyvxXZPcSzms=; b=X+Wh/0jVu/ICm2CpB9KHLK75kaRMGT7E6XzzF8qwatNZmdDl/NH878K26Y3sZ1D0dn 2RNLM1IuKIMsxImBDVFa1zUfYy+guvzWlOUe6/+kwP5LwyKJ/DDnR6J84xUdk2xKi3jt NDu9N1GJv3VVtZNh/nG+u+ieVx7LBUQLNS2Xi5GV7TE46oYQmO5e7oNelUKaqrqgMhFh shkkjdg/z2/emu4liTiCHfLp0U2FdrEtHuxQ5xEYUXgx2sc/yYAwTb6ct3p69Uv4lM7v 2q+tecflb4pr+EStLPdt0SEGpEzgg98ZxXfghgCFkLBaH30cbjueUAqDEKtDm0HaMKg7 PypA== X-Gm-Message-State: AOAM533SVCGD18Mox+qhylwaxpt/QJtHY/iHR6dtFbR4W3qZwVx5iBhw zuo5avbmtUtnZGxh+fyu742bWXJwWhY= X-Google-Smtp-Source: ABdhPJySZiGS7k6bdZiOmiFZxrcilAlnr37VheiGYs7PRAwVtzPB0RXtUSsr7kFcZrdUMPmzY2y7zw== X-Received: by 2002:a65:5502:: with SMTP id f2mr3857382pgr.375.1595507709769; Thu, 23 Jul 2020 05:35:09 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id z11sm2849823pfr.71.2020.07.23.05.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 05:35:09 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v5 1/8] Bluetooth: Translate additional address type correctly Date: Thu, 23 Jul 2020 18:08:56 +0530 Message-Id: <20200723123903.29337-1-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6D2E0A179F X-Rspamd-UID: 83f083 From: Marcel Holtmann When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci.h | 6 ++++-- net/bluetooth/hci_core.c | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 1f18f71363e9..abab8b5981a7 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -2268,8 +2268,10 @@ struct hci_ev_le_conn_complete { #define LE_EXT_ADV_SCAN_RSP 0x0008 #define LE_EXT_ADV_LEGACY_PDU 0x0010 -#define ADDR_LE_DEV_PUBLIC 0x00 -#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC 0x00 +#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC_RESOLVED 0x02 +#define ADDR_LE_DEV_RANDOM_RESOLVED 0x03 #define HCI_EV_LE_ADVERTISING_REPORT 0x02 struct hci_ev_le_advertising_info { diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6509f785dd14..4af208b82138 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3290,6 +3290,15 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list, { struct hci_conn_params *param; + switch (addr_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + addr_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + addr_type = ADDR_LE_DEV_RANDOM; + break; + } + list_for_each_entry(param, list, action) { if (bacmp(¶m->addr, addr) == 0 && param->addr_type == addr_type) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QKJLHQ6EGV9K4QEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 14:35:26 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id yAUbHA6EGV/6lAEAgupzMw (envelope-from ); Thu, 23 Jul 2020 14:35:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0455EA122C; Thu, 23 Jul 2020 14:35:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728789AbgGWMfU (ORCPT + 1 other); Thu, 23 Jul 2020 08:35:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGWMfU (ORCPT ); Thu, 23 Jul 2020 08:35:20 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DE89C0619DC for ; Thu, 23 Jul 2020 05:35:20 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id g67so3030272pgc.8 for ; Thu, 23 Jul 2020 05:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VUqS07gPBeyv2W2P3TCEcoo0Bx0MtNnbq5B59KDRGS0=; b=Z1wM4DfvsvCcG6fWY8jGCPVJsVfd2JgZ+Tcw1MTcd1kYzfgVrWzNJUgjsV+jTYZ5nY Ky8UvuOTf6uCB+oKnM9UCGVWxDvrS6xZWLqMcLFn+0OSR/AH9iLcD8H5EEnPbffWPuGD 2Ephum5uOS1pDfxZmSjeKS4K8KADNAWqT5hxPBK+AddN6mRVbSrgGAAqFx4T3VxYbh9D +twN9nxnfthtLSs4nYQNXCLZVHDSjU3T0o6TdNlsSlmcccEX6Te+SaA+zWT5TizlOZe2 jhXw3bOFZxkTpy7kX/ktQjFB06wn19l9mYUNqOJtBHk7uyP93P7svUySWKSHoCTkLzl0 zM7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VUqS07gPBeyv2W2P3TCEcoo0Bx0MtNnbq5B59KDRGS0=; b=HezUaCw1ABVh+/X1ndHiN3Ljru/jeGf6IV+E2npTRpl4W33RWQIA20+C0QO/ZY6b8q W/hCoVm5HOQWkycKN2b+hjmvCaOzpqjetcw/718E4mKMjysqAAwcn/BxCvq1ryOi2W2C /Cq62/wcmKO9Unu6jWxyPEZyZPgjuJ+D/WkVwgGs6fUY0ewgdHZpgQ0yw3Gtb1SBLxF8 n0EW2NtYKh4Xcf5NNWsao4z1wucPI5TzBOMj+2EvU+qQYcwcux3KDRNdy1p1ILoRWPrz xQ6BSr3Ha8ZssJSrJ9x4aH0DhG0W15LJ1xNRG5YxmDzrPp/uArNO1DbOiwa4Urs7Bn9A KRzg== X-Gm-Message-State: AOAM532aK7nNQ713NnLkGpTVplNXRX7qSIBrwK7ic4Cy/hyDDdO9h/Me RBZ6JIMRB0hfXOSc9uiOE3WPaI8UKtrCZA== X-Google-Smtp-Source: ABdhPJwsFiIvl6hBeNIO+87VkviFkdqsIAWzys49mPcqOUS48DMnGOEPw+PbZLYshfUdmbKo5XMe3Q== X-Received: by 2002:a63:6ca:: with SMTP id 193mr4036706pgg.269.1595507719475; Thu, 23 Jul 2020 05:35:19 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id z11sm2849823pfr.71.2020.07.23.05.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 05:35:19 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v5 2/8] Bluetooth: Configure controller address resolution if available Date: Thu, 23 Jul 2020 18:08:57 +0530 Message-Id: <20200723123903.29337-2-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200723123903.29337-1-sathish.narasimman@intel.com> References: <20200723123903.29337-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0455EA122C X-Rspamd-UID: 4d883d From: Marcel Holtmann When the LL Privacy support is available, then as part of enabling or disabling passive background scanning, it is required to set up the controller based address resolution as well. Since only passive background scanning is utilizing the whitelist, the address resolution is now bound to the whitelist and passive background scanning. All other resolution can be easily done by the host stack. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_request.c | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index bee1b4778ccc..8caac20556b4 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1359,6 +1359,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn); #define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \ ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED)) +/* Use LL Privacy based address resolution if supported */ +#define use_ll_privacy(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY) + /* Use ext scanning if set ext scan param and ext scan enable is supported */ #define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \ ((dev)->commands[37] & 0x40)) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 7c0c2fda04ad..7d0ba53ffed0 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -675,6 +675,12 @@ void hci_req_add_le_scan_disable(struct hci_request *req) cp.enable = LE_SCAN_DISABLE; hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + __u8 enable = 0x00; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } } static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, @@ -816,7 +822,8 @@ static bool scan_use_rpa(struct hci_dev *hdev) } static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, - u16 window, u8 own_addr_type, u8 filter_policy) + u16 window, u8 own_addr_type, u8 filter_policy, + bool addr_resolv) { struct hci_dev *hdev = req->hdev; @@ -825,6 +832,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } + if (use_ll_privacy(hdev) && addr_resolv) { + u8 enable = 0x01; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } + /* Use ext scanning if set ext scan param and ext scan enable is * supported */ @@ -898,12 +910,18 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, } } +/* Ensure to call hci_req_add_le_scan_disable() first to disable the + * controller based address resolution to be able to reconfigure + * resolving list. + */ void hci_req_add_le_passive_scan(struct hci_request *req) { struct hci_dev *hdev = req->hdev; u8 own_addr_type; u8 filter_policy; u16 window, interval; + /* Background scanning should run with address resolution */ + bool addr_resolv = true; if (hdev->scanning_paused) { bt_dev_dbg(hdev, "Scanning is paused for suspend"); @@ -949,7 +967,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) bt_dev_dbg(hdev, "LE passive scan with whitelist = %d", filter_policy); hci_req_start_scan(req, LE_SCAN_PASSIVE, interval, window, - own_addr_type, filter_policy); + own_addr_type, filter_policy, addr_resolv); } static u8 get_adv_instance_scan_rsp_len(struct hci_dev *hdev, u8 instance) @@ -2789,6 +2807,8 @@ static int active_scan(struct hci_request *req, unsigned long opt) u8 own_addr_type; /* White list is not used for discovery */ u8 filter_policy = 0x00; + /* Discovery doesn't require controller address resolution */ + bool addr_resolv = false; int err; BT_DBG("%s", hdev->name); @@ -2811,7 +2831,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, hdev->le_scan_window_discovery, own_addr_type, - filter_policy); + filter_policy, addr_resolv); return 0; } -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CEM1AhSEGV8WzAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 14:35:32 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cKuOABSEGV+dZgAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 14:35:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9B066A0FCC; Thu, 23 Jul 2020 14:35:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728791AbgGWMfY (ORCPT + 1 other); Thu, 23 Jul 2020 08:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGWMfX (ORCPT ); Thu, 23 Jul 2020 08:35:23 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDB68C0619DC for ; Thu, 23 Jul 2020 05:35:23 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id g67so3030343pgc.8 for ; Thu, 23 Jul 2020 05:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sagG6XzvqD+5UW5Prg99qLND7K39EzY9lxq7YJmMj5Q=; b=ueAuxZRVROtqPGEVGJ7NwIauUFNArra6i37gxwfBGbgcuMNiGOy+5bnZcqdjybOo4J 0D9zDvFvG0Fx+ADL7PahKmUgNAoM0O8UFhuUKMrFAU0gDUPC/K8KU6s3xcpT7zs3D/kN IqhV3MttPce7B9zbdcbPOhQq/J/NM1wntvuoK2ZJuEx3rJH1L7cw9rhB5ks3JzUusTOh ZXGtlFpLKS5hfFGNnI3eEO1J3Pvm29NTjgSuvJ6rXHooZHDUj+RIYlcNATDd9qXlaNQY xzAAlU8SVVrPwUuezalsH+PNLmMS0kOBvkFnVtMVCviWUUXS4EftRj4dzkUte4mY4MGo T9tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sagG6XzvqD+5UW5Prg99qLND7K39EzY9lxq7YJmMj5Q=; b=fvkDjM6F3020WNfh5eimWLuhkwFAVvxmnx6WpT+OqOcaT75nclQ3dOS2MqAKBOBA6E +5RJwRIDFyiAoiuuSn1fxQDt0nBDLlrGXxNghHZVr2O4O4M9hQgPi7WLyhUifxC91KqL e7IQoHABVF0y63WN1LtJxxVVaA5fMhL3CCIAwXqvI0z/LEXL1aHMOMbyvGCxfwRqUyzw aaT1mwfSi1/CvxsfOs1HWfzgri80pxvyhQWiUi+v2LPJORMKM8jUSLUYfWTVzlEqC2kc W6oQUElWK0MCD1upg9as3jRVIaYVIcof6ynZuahKew2BQ8tXlqwtYoBluNjhIZ6RVAaT dAOg== X-Gm-Message-State: AOAM530w2AMPlixRfDbBHBPj9bQDOLeAm+Bi1kAwQ4XZCN0hRWDYMH9N OgNWyTTzkM+8e+5NMaqJ5ZqdiXHedtkbsQ== X-Google-Smtp-Source: ABdhPJzbyaP61Sycn73zd2NzweTw9CHvEnFjTM1VPt6jA5L0jfMPrkgJZeh/z8ja/wrYHLgih2cNKw== X-Received: by 2002:a62:1d90:: with SMTP id d138mr4001072pfd.159.1595507723125; Thu, 23 Jul 2020 05:35:23 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id z11sm2849823pfr.71.2020.07.23.05.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 05:35:22 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v5 3/8] Bluetooth: Update resolving list when updating whitelist Date: Thu, 23 Jul 2020 18:08:58 +0530 Message-Id: <20200723123903.29337-3-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200723123903.29337-1-sathish.narasimman@intel.com> References: <20200723123903.29337-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9B066A0FCC X-Rspamd-UID: d82f9e From: Marcel Holtmann When the whitelist is updated, then also update the entries of the resolving list for devices where IRKs are available. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- net/bluetooth/hci_request.c | 41 +++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 7d0ba53ffed0..85de1f356610 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -694,6 +694,21 @@ static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, bt_dev_dbg(req->hdev, "Remove %pMR (0x%x) from whitelist", &cp.bdaddr, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST, sizeof(cp), &cp); + + if (use_ll_privacy(req->hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(req->hdev, bdaddr, bdaddr_type); + if (irk) { + struct hci_cp_le_del_from_resolv_list cp; + + cp.bdaddr_type = bdaddr_type; + bacpy(&cp.bdaddr, bdaddr); + + hci_req_add(req, HCI_OP_LE_DEL_FROM_RESOLV_LIST, + sizeof(cp), &cp); + } + } } /* Adds connection to white list if needed. On error, returns -1. */ @@ -714,7 +729,7 @@ static int add_to_white_list(struct hci_request *req, return -1; /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, ¶ms->addr, params->addr_type)) { return -1; } @@ -732,6 +747,28 @@ static int add_to_white_list(struct hci_request *req, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_ADD_TO_WHITE_LIST, sizeof(cp), &cp); + if (use_ll_privacy(hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(hdev, ¶ms->addr, + params->addr_type); + if (irk) { + struct hci_cp_le_add_to_resolv_list cp; + + cp.bdaddr_type = params->addr_type; + bacpy(&cp.bdaddr, ¶ms->addr); + memcpy(cp.peer_irk, irk->val, 16); + + if (hci_dev_test_flag(hdev, HCI_PRIVACY)) + memcpy(cp.local_irk, hdev->irk, 16); + else + memset(cp.local_irk, 0, 16); + + hci_req_add(req, HCI_OP_LE_ADD_TO_RESOLV_LIST, + sizeof(cp), &cp); + } + } + return 0; } @@ -772,7 +809,7 @@ static u8 update_white_list(struct hci_request *req) } /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, &b->bdaddr, b->bdaddr_type)) { return 0x00; } -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aE1xGhmEGV/G9gEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 14:35:37 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id oF1XGRmEGV/LSgEA0J78UA (envelope-from ); Thu, 23 Jul 2020 14:35:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 286D9A1B5C; Thu, 23 Jul 2020 14:35:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728792AbgGWMf1 (ORCPT + 1 other); Thu, 23 Jul 2020 08:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGWMf0 (ORCPT ); Thu, 23 Jul 2020 08:35:26 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94590C0619DC for ; Thu, 23 Jul 2020 05:35:26 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id l6so2499204plt.7 for ; Thu, 23 Jul 2020 05:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bwkuLTs6JjWfQ9Oc/vq1HcUJ3U5T2anKNWaBV3h5b4U=; b=t34FZrqpJguHXObyN++EfG8CiEe1r70HOONJmln+mbhgRW+GbH4f1buS8rMj9fSW+g RcOp6eK4BVKBwGlh+a+Smq6qeIg4F4XLDal6X2VUVhn9SJDeoGo4FhB+8UCX7F18pD5u B+aJG9kybl/3NJi8FA+p2Rct5dVLWhHkkfwRG5ds/k3U4T/v+kLijxZwDeuFgXtkfmRo dSZ03ZBSCrjmSTfWM3FiNUVKQDwaDdJcQkiOwKCoK1r1lHBWe1CUEZySpBp91ZyD4O1z 7iY0LST6wt2rGB91SPlsyDoRxBCZmXlsCuTgfVzcnLb05XoHniB9AH9j3Cd3/40V5al9 ZutA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bwkuLTs6JjWfQ9Oc/vq1HcUJ3U5T2anKNWaBV3h5b4U=; b=oQ1ZXZfJTfhJvhYmULIZoJUDoFlacyf+CZod1k04sbTbvCyIqPIiznx5nL1HBQ4eyS lv5ojT2NE1WoqLQgSpy8NbRu4yF3Cs2YtxUdPwk8NIYUI924mrn+LmsPwTjwVHSVRp7N kpPdE0oxgRgooCHGyMTRBJKMgJZE4bhlQV37mxoYgssQijWwI/3mxGVvtfeV7pkqFzAV jE4HrSLLjognxrieNV7Kl1XgknWuWd37maEE4GbPZcLYsh0pXqC+H7gry3ZjFtsQDPNJ Rt4b1mrmZngjXO37nzv1mQpiSC3OnHAmqkZRkfMMEwabnk0dEi8ZbnZGWNi1v9mG9pVR DumQ== X-Gm-Message-State: AOAM531Oybrn5QLp2eiXgtIOxMhtITo85IF9UYCdqm9+MJKFWV6FGR5t yaSN4C7j2R1sX3MPY7Wwy0jr1CAEPMADDA== X-Google-Smtp-Source: ABdhPJwgU9AyjfneBLNPjhnm1MnH0AufFjYwpW6dkFZFaII5j4d2y7Y6obC+Y/K/Vt32vhcjIxLwwg== X-Received: by 2002:a17:902:322:: with SMTP id 31mr3626123pld.33.1595507725921; Thu, 23 Jul 2020 05:35:25 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id z11sm2849823pfr.71.2020.07.23.05.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 05:35:25 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v5 4/8] Bluetooth: Translate additional address type during le_conn Date: Thu, 23 Jul 2020 18:08:59 +0530 Message-Id: <20200723123903.29337-4-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200723123903.29337-1-sathish.narasimman@intel.com> References: <20200723123903.29337-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.98 / 15.00 / 200.00 X-Rspamd-Queue-Id: 286D9A1B5C X-Rspamd-UID: cf230e When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. This patch is specially during LE_CREATE_CONN if using own_add_type as 0x02 or 0x03. Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_event.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 61f8c4d12028..6388fb55b4d2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2296,6 +2296,22 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, if (!conn) return; + /* When using controller based address resolution, then the new + * address types 0x02 and 0x03 are used. These types need to be + * converted back into either public address or random address type + */ + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + switch (own_address_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + own_address_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + own_address_type = ADDR_LE_DEV_RANDOM; + break; + } + } + /* Store the initiator and responder address information which * is needed for SMP. These values will not change during the * lifetime of the connection. -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QBkdJYe9GV9roAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 18:40:39 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id kJ5dI4e9GV/0gQAAgupzMw (envelope-from ); Thu, 23 Jul 2020 18:40:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5916FA1A2D; Thu, 23 Jul 2020 18:40:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727052AbgGWQkc (ORCPT + 1 other); Thu, 23 Jul 2020 12:40:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726632AbgGWQkc (ORCPT ); Thu, 23 Jul 2020 12:40:32 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2355C0619DC for ; Thu, 23 Jul 2020 09:40:31 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id 18so4824416otv.6 for ; Thu, 23 Jul 2020 09:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ouNzipy81VDKHRD/Hley2+glw2YbYm9pUqqBsTFWElI=; b=vfZz4ymzUKQGejUDc3+nS8EBKa+0TP/o438cRGCEeRocmDVF6TeBLGnd0pV3uo5WTf oGDF5XxAhayKJ10yVkdJJRyF3BVa4D/DiPl2TNGKvVZeSKCmsaBEg2QuyilNk2o14oye M117JsrjN4qPfhxHXts8QXeybvf0iKa7JDigoaloPEqaTWBX1zhCi7sPGpQsaJay9TS8 zYFx7ULWRo0mH2ZGj6hFS+6qHCL3LRDUQkXz+kQa7uqJt6UN1p2kVivZH9fD2Os9ih10 aHq8i5AA3VhO9LgfaIXg4vQF6Lv3FtTWSJpeUw6WHMpIT+U1mqkB/Ma72WDod+mGteXA ZyBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ouNzipy81VDKHRD/Hley2+glw2YbYm9pUqqBsTFWElI=; b=q0tLrPIxtm8bdE7rBy7dpB8pBZI//PQhVGhkt6E8XKx144eANcYpgUbvNnFcQyud/7 IIWR06BnUaNEKc/P51oCFpbC4dYUgZCIDYrWUooGGQRpXhlXlC75iRWSN7JyIE5Cbuvh Y5riHdpqppcfpHxAq2YEk6aLrMhWW+ANS7TXxpi8L/y0q65hcu4Pk7Z9xJGJl2CaM+hi 3QSZXdd62auZwegK/Q6o3z9Hp49JHE3bf9l72ewiuTsLYY1iVwhTl/CZ0lWuUvKAO279 gIObcZFEPWQ2Bn1l5ix7Li5VSIH8FpWuTDtVbgV+b61rlyA8b/bLCofZorjwev7rMU2K Xxew== X-Gm-Message-State: AOAM533NmjTFJdhDppJxYqitdLgE8yKJMeXHc712YEMLLR2FiWlfoN0f Zs3OHQ5pTCsvg24fFbTQnXfCidPwyTs+LCUnOTh+MEX3 X-Google-Smtp-Source: ABdhPJy4jN9ju0iX3BUAYz9UrC8x0T0HKv8vScgNOMNM6zsM+KCSY7ZDHkyevG/AwFvdZ5zuO/1nX2M4JQCiMLz9xRA= X-Received: by 2002:a9d:5e18:: with SMTP id d24mr4853740oti.88.1595522431086; Thu, 23 Jul 2020 09:40:31 -0700 (PDT) MIME-Version: 1.0 References: <20200723152327.Bluez.v5.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> In-Reply-To: <20200723152327.Bluez.v5.1.I667fa0ebcc3056a21c22fdaf476a56dd72aff38d@changeid> From: Luiz Augusto von Dentz Date: Thu, 23 Jul 2020 09:40:19 -0700 Message-ID: Subject: Re: [Bluez PATCH v5 1/2] audio/transport: change volume to 8bit To: Archie Pusaka Cc: linux-bluetooth , Archie Pusaka , Michael Sun Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5916FA1A2D X-Rspamd-UID: 047f88 Hi Archie, On Thu, Jul 23, 2020 at 12:23 AM Archie Pusaka wrote: > > From: Archie Pusaka > > The valid range of volume is 0 - 127, yet it is stored in 16bit > data type. This patch modifies it so we use 8bit data type to > store volume instead. Furthermore we also use signed type, so > negative values can be used to indicate invalid volume. > > Reviewed-by: Michael Sun > --- > > Changes in v5: > -Fix coding style and conversion error > > Changes in v4: > -Use int8_t instead of uint8_t > > Changes in v3: None > Changes in v2: None > > profiles/audio/avrcp.c | 17 +++++++++----- > profiles/audio/avrcp.h | 35 ++++++++++++++--------------- > profiles/audio/media.c | 4 ++-- > profiles/audio/transport.c | 45 +++++++++++++++++++------------------- > profiles/audio/transport.h | 8 +++---- > 5 files changed, 56 insertions(+), 53 deletions(-) > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > index 1bf85041e..7a06c8353 100644 > --- a/profiles/audio/avrcp.c > +++ b/profiles/audio/avrcp.c > @@ -1595,6 +1595,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > struct btd_device *dev = session->dev; > uint16_t len = ntohs(pdu->params_len); > uint64_t uid; > + int8_t volume; > GList *settings; > > /* > @@ -1659,10 +1660,11 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > len = 1; > break; > case AVRCP_EVENT_VOLUME_CHANGED: > - pdu->params[1] = media_transport_get_device_volume(dev); > - if (pdu->params[1] > 127) > + volume = media_transport_get_device_volume(dev); > + if (volume < 0) > goto err; > > + pdu->params[1] = volume; > len = 2; > > break; > @@ -1757,7 +1759,7 @@ static uint8_t avrcp_handle_set_absolute_volume(struct avrcp *session, > uint8_t transaction) > { > uint16_t len = ntohs(pdu->params_len); > - uint8_t volume; > + int8_t volume; > > if (len != 1) > goto err; > @@ -3623,7 +3625,7 @@ static void avrcp_volume_changed(struct avrcp *session, > struct avrcp_header *pdu) > { > struct avrcp_player *player = target_get_player(session); > - uint8_t volume; > + int8_t volume; > > volume = pdu->params[1] & 0x7F; > > @@ -4371,7 +4373,7 @@ static gboolean avrcp_handle_set_volume(struct avctp *conn, uint8_t code, > struct avrcp *session = user_data; > struct avrcp_player *player = target_get_player(session); > struct avrcp_header *pdu = (void *) operands; > - uint8_t volume; > + int8_t volume; > > if (code == AVC_CTYPE_REJECTED || code == AVC_CTYPE_NOT_IMPLEMENTED || > pdu == NULL) > @@ -4434,13 +4436,16 @@ static int avrcp_event(struct avrcp *session, uint8_t id, const void *data) > return err; > } > > -int avrcp_set_volume(struct btd_device *dev, uint8_t volume, bool notify) > +int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify) > { > struct avrcp_server *server; > struct avrcp *session; > uint8_t buf[AVRCP_HEADER_LENGTH + 1]; > struct avrcp_header *pdu = (void *) buf; > > + if (volume < 0) > + return -EINVAL; > + > server = find_server(servers, device_get_adapter(dev)); > if (server == NULL) > return -EINVAL; > diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h > index 86d310c73..a08e7325e 100644 > --- a/profiles/audio/avrcp.h > +++ b/profiles/audio/avrcp.h > @@ -83,27 +83,27 @@ > #define AVRCP_EVENT_LAST AVRCP_EVENT_VOLUME_CHANGED > > struct avrcp_player_cb { > - GList *(*list_settings) (void *user_data); > - const char *(*get_setting) (const char *key, void *user_data); > - int (*set_setting) (const char *key, const char *value, > + GList *(*list_settings)(void *user_data); > + const char *(*get_setting)(const char *key, void *user_data); > + int (*set_setting)(const char *key, const char *value, > void *user_data); > - uint64_t (*get_uid) (void *user_data); > - const char *(*get_metadata) (const char *key, void *user_data); > - GList *(*list_metadata) (void *user_data); > - const char *(*get_status) (void *user_data); > - uint32_t (*get_position) (void *user_data); > - uint32_t (*get_duration) (void *user_data); > - const char *(*get_name) (void *user_data); > - void (*set_volume) (uint8_t volume, struct btd_device *dev, > + uint64_t (*get_uid)(void *user_data); > + const char *(*get_metadata)(const char *key, void *user_data); > + GList *(*list_metadata)(void *user_data); > + const char *(*get_status)(void *user_data); > + uint32_t (*get_position)(void *user_data); > + uint32_t (*get_duration)(void *user_data); > + const char *(*get_name)(void *user_data); > + void (*set_volume)(int8_t volume, struct btd_device *dev, > void *user_data); > - bool (*play) (void *user_data); > - bool (*stop) (void *user_data); > - bool (*pause) (void *user_data); > - bool (*next) (void *user_data); > - bool (*previous) (void *user_data); > + bool (*play)(void *user_data); > + bool (*stop)(void *user_data); > + bool (*pause)(void *user_data); > + bool (*next)(void *user_data); > + bool (*previous)(void *user_data); > }; > > -int avrcp_set_volume(struct btd_device *dev, uint8_t volume, bool notify); > +int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify); > > struct avrcp_player *avrcp_register_player(struct btd_adapter *adapter, > struct avrcp_player_cb *cb, > @@ -114,6 +114,5 @@ void avrcp_unregister_player(struct avrcp_player *player); > void avrcp_player_event(struct avrcp_player *player, uint8_t id, > const void *data); > > - > size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands); > size_t avrcp_browsing_general_reject(uint8_t *operands); > diff --git a/profiles/audio/media.c b/profiles/audio/media.c > index a0173fdd4..d4d58ec86 100644 > --- a/profiles/audio/media.c > +++ b/profiles/audio/media.c > @@ -120,7 +120,7 @@ struct media_player { > char *status; > uint32_t position; > uint32_t duration; > - uint8_t volume; > + int8_t volume; > GTimer *timer; > bool play; > bool pause; > @@ -1199,7 +1199,7 @@ static uint32_t get_duration(void *user_data) > return mp->duration; > } > > -static void set_volume(uint8_t volume, struct btd_device *dev, void *user_data) > +static void set_volume(int8_t volume, struct btd_device *dev, void *user_data) > { > struct media_player *mp = user_data; > > diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c > index 48fabba9b..2ae5118c4 100644 > --- a/profiles/audio/transport.c > +++ b/profiles/audio/transport.c > @@ -86,7 +86,7 @@ struct media_owner { > struct a2dp_transport { > struct avdtp *session; > uint16_t delay; > - uint16_t volume; > + int8_t volume; > }; > > struct media_transport { > @@ -634,7 +634,7 @@ static gboolean volume_exists(const GDBusPropertyTable *property, void *data) > struct media_transport *transport = data; > struct a2dp_transport *a2dp = transport->data; > > - return a2dp->volume <= 127; > + return a2dp->volume >= 0; > } > > static gboolean get_volume(const GDBusPropertyTable *property, > @@ -642,8 +642,9 @@ static gboolean get_volume(const GDBusPropertyTable *property, > { > struct media_transport *transport = data; > struct a2dp_transport *a2dp = transport->data; > + uint16_t volume = (uint16_t)a2dp->volume; > > - dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &a2dp->volume); > + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &volume); > > return TRUE; > } > @@ -654,27 +655,20 @@ static void set_volume(const GDBusPropertyTable *property, > { > struct media_transport *transport = data; > struct a2dp_transport *a2dp = transport->data; > - uint16_t volume; > + uint16_t arg; > + int8_t volume; > bool notify; > > - if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) { > - g_dbus_pending_property_error(id, > - ERROR_INTERFACE ".InvalidArguments", > - "Invalid arguments in method call"); > - return; > - } > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16) > + goto error; > > - dbus_message_iter_get_basic(iter, &volume); > - > - if (volume > 127) { > - g_dbus_pending_property_error(id, > - ERROR_INTERFACE ".InvalidArguments", > - "Invalid arguments in method call"); > - return; > - } > + dbus_message_iter_get_basic(iter, &arg); > + if (arg > INT8_MAX) > + goto error; > > g_dbus_pending_property_success(id); > > + volume = (int8_t)arg; > if (a2dp->volume == volume) > return; > > @@ -688,6 +682,11 @@ static void set_volume(const GDBusPropertyTable *property, > "Volume"); > > avrcp_set_volume(transport->device, volume, notify); > + return; > + > +error: > + g_dbus_pending_property_error(id, ERROR_INTERFACE ".InvalidArguments", > + "Invalid arguments in method call"); > } > > static gboolean endpoint_exists(const GDBusPropertyTable *property, void *data) > @@ -931,14 +930,14 @@ struct btd_device *media_transport_get_dev(struct media_transport *transport) > return transport->device; > } > > -uint16_t media_transport_get_volume(struct media_transport *transport) > +int8_t media_transport_get_volume(struct media_transport *transport) > { > struct a2dp_transport *a2dp = transport->data; > return a2dp->volume; > } > > void media_transport_update_volume(struct media_transport *transport, > - uint8_t volume) > + int8_t volume) > { > struct a2dp_transport *a2dp = transport->data; > > @@ -953,12 +952,12 @@ void media_transport_update_volume(struct media_transport *transport, > MEDIA_TRANSPORT_INTERFACE, "Volume"); > } > > -uint8_t media_transport_get_device_volume(struct btd_device *dev) > +int8_t media_transport_get_device_volume(struct btd_device *dev) > { > GSList *l; > > if (dev == NULL) > - return 128; > + return -1; > > for (l = transports; l; l = l->next) { > struct media_transport *transport = l->data; > @@ -974,7 +973,7 @@ uint8_t media_transport_get_device_volume(struct btd_device *dev) > } > > void media_transport_update_device_volume(struct btd_device *dev, > - uint8_t volume) > + int8_t volume) > { > GSList *l; > > diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h > index ac542bf6c..78024372f 100644 > --- a/profiles/audio/transport.h > +++ b/profiles/audio/transport.h > @@ -32,14 +32,14 @@ struct media_transport *media_transport_create(struct btd_device *device, > void media_transport_destroy(struct media_transport *transport); > const char *media_transport_get_path(struct media_transport *transport); > struct btd_device *media_transport_get_dev(struct media_transport *transport); > -uint16_t media_transport_get_volume(struct media_transport *transport); > +int8_t media_transport_get_volume(struct media_transport *transport); > void media_transport_update_delay(struct media_transport *transport, > uint16_t delay); > void media_transport_update_volume(struct media_transport *transport, > - uint8_t volume); > + int8_t volume); > void transport_get_properties(struct media_transport *transport, > DBusMessageIter *iter); > > -uint8_t media_transport_get_device_volume(struct btd_device *dev); > +int8_t media_transport_get_device_volume(struct btd_device *dev); > void media_transport_update_device_volume(struct btd_device *dev, > - uint8_t volume); > + int8_t volume); > -- > 2.28.0.rc0.105.gf9edc3c819-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IDAtI5O9GV9roAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 18:40:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2Jf6IZO9GV/vQAAAgupzMw (envelope-from ); Thu, 23 Jul 2020 18:40:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BD1264081F; Thu, 23 Jul 2020 18:40:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728093AbgGWQkk (ORCPT + 1 other); Thu, 23 Jul 2020 12:40:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729849AbgGWQkj (ORCPT ); Thu, 23 Jul 2020 12:40:39 -0400 Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 986E9C0619E3 for ; Thu, 23 Jul 2020 09:40:39 -0700 (PDT) Received: by mail-yb1-xb41.google.com with SMTP id n141so965851ybf.3 for ; Thu, 23 Jul 2020 09:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gMZVcJy5uwQT4vGlr1ERHcQqosY3c4kI9divmT2Lqpo=; b=gwjAdDF942fvpXcwvyR0uuIMKC72vX+1xaZmY+P/HlmQuhIFDMmqtrrmpEAYoODFls 2whE4wMib2QcLaOVE4J+SdVBQ6P2JsY+v8YTFDd3JbEzache4FI5T4xBht2IkLXzQ/Sy 1WIGux4f/lVv0pdf+puWJ2nV8J8wAU2lYqlJCRbXSl2WNeWZR9h1y1lVklRZc/KIqgKe Aj/ehWw+f2o0CsdkKfDY/zbJ5hlw20DhQPkwOJEN7mcdPxjJE6/p+eukZAHUXZngVbCf sdt5+ZH+ulKqsBPsP5u7/dtuM4Y4W/S7rVtNSNPkcxfWu5kl7dPPev0Qj6brKbcngU4o aoNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gMZVcJy5uwQT4vGlr1ERHcQqosY3c4kI9divmT2Lqpo=; b=TF254k0d8J/TugHed7rzWvVPrQ62+5hu6W7tV+qmYemuAwJaiwxVaD2BOOPR4zNnKW quBlcLqaBe1o5zUX5c2LQGqNofJ0bbKiqOGx8Rll9F93bplY+4F//x39VnxBEJpAaMXv 9o9P5K21E8RvBGFRap84L6UUPt398QiKGlsO7Eoea/a4ziHawRb6ZibMLQDEJvADM2Vy Xm4STuxXb/yH4jyh0rknXKuz4hiYsuWgiGg9dXJuxYxL7y5WF0Z5l8CoprR3ZAGidN2C nv8c9Iei5U3MLPODvv/HWYIbJkB+IrXTk+aba/ER70DpWvG5J9VBaTJkM299VuPAOZMe XMsg== X-Gm-Message-State: AOAM533YEABJT0uii6pxibXCH+bcroGq0UKJuWH2JotNFNiQWBPMF95N DukLo6WPuVva+UFms1p7Si41+oEvulzQ08H81b6/jA== X-Google-Smtp-Source: ABdhPJwjoH5EQjleheyC3y94ZN3qZdobs4/50/anePotqNf3BbB0YqTnucY8g4u2RzRMw5fRhYkM1LWDXZ+gqUBrIW0= X-Received: by 2002:a25:a121:: with SMTP id z30mr8500302ybh.408.1595522438544; Thu, 23 Jul 2020 09:40:38 -0700 (PDT) MIME-Version: 1.0 References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-5-hch@lst.de> In-Reply-To: <20200723060908.50081-5-hch@lst.de> From: Eric Dumazet Date: Thu, 23 Jul 2020 09:40:27 -0700 Message-ID: Subject: Re: [PATCH 04/26] net: add a new sockptr_t type To: Christoph Hellwig Cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , LKML , netdev , bpf , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: BD1264081F X-Rspamd-UID: e3c597 On Wed, Jul 22, 2020 at 11:09 PM Christoph Hellwig wrote: > > Add a uptr_t type that can hold a pointer to either a user or kernel > memory region, and simply helpers to copy to and from it. > > Signed-off-by: Christoph Hellwig > --- > include/linux/sockptr.h | 104 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 104 insertions(+) > create mode 100644 include/linux/sockptr.h > > diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h > new file mode 100644 > index 00000000000000..700856e13ea0c4 > --- /dev/null > +++ b/include/linux/sockptr.h > @@ -0,0 +1,104 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright (c) 2020 Christoph Hellwig. > + * > + * Support for "universal" pointers that can point to either kernel or userspace > + * memory. > + */ > +#ifndef _LINUX_SOCKPTR_H > +#define _LINUX_SOCKPTR_H > + > +#include > +#include > + > +typedef struct { > + union { > + void *kernel; > + void __user *user; > + }; > + bool is_kernel : 1; > +} sockptr_t; > I am not sure why you chose sockptr_t for something that really seems generic. Or is it really meant to be exclusive to setsockopt() and/or getsockopt() ? If the first user of this had been futex code, we would have used futexptr_t, I guess. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eF9HLFy+GV9roAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 18:44:12 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id uNFaKly+GV+DCwAAlScrYA (envelope-from ); Thu, 23 Jul 2020 18:44:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9C7CB40AD3; Thu, 23 Jul 2020 18:44:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729834AbgGWQoH (ORCPT + 1 other); Thu, 23 Jul 2020 12:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729841AbgGWQoH (ORCPT ); Thu, 23 Jul 2020 12:44:07 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB440C0619DC for ; Thu, 23 Jul 2020 09:44:06 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id a21so4816836otq.8 for ; Thu, 23 Jul 2020 09:44:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GOMz2Q/47nTESPFdNOKAcr/LxRDSdhzbZLCJhwBaSMA=; b=vV70HGOZovZX99Smj9azcQDxBVh1TDvfFt9NvqSj1PD8BWAEL2iXUxh1yuZZby7PPL oMjMFuM5YJHmzrkGUY1Ph/TqRGP0olm9MjJz3/HYiuGog2nqz2Z3ZTBWptKLsWUwsp7I 5TrOlvVN6cecTDmtIWbFQyNzhiC1rLfV5WwUViAbTmKf86k4hAaKtDrKTqRAz0Kwp61P xIlCOpX/gA26tmtes/dMMuLSwLPg5bI1TSyMaZ0MAqHsaQjQVOI4jPX0BLVTmtY30BBg bmMNd5EzddPwx1NnMr8HyovrCbS8niKtIb6GR6nw7djnxUB151rM1nVUk3Ob/Y1GLPJj qgYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GOMz2Q/47nTESPFdNOKAcr/LxRDSdhzbZLCJhwBaSMA=; b=gEdk3SOQzq6dH/eZMbN4B4Scp6fP+VNiBVo1lteuboF0VJI6tBGKdrLOFxiEhOSPAV 2Rh3RiUvFoJTPGr1FlUsQGVFg6yucxQJATbeX6YePx/eRT2iwx+BiJjJtnjg6990lLoN ua9i6rENwk1r3uLvR3EtD4acuYyX1Zzxgy5jGnTMkTK0rYtFwoh4YQrE3DuDX5E7vR8P iUiA6Y3fNEy8HCcyYFnYWQgg/TbZ1HC6aQXtKAth96fwDy7yF8ozjpN0dusVm9dZrQjK J4cJg5r1TU+i982UIjmjZ8m+9zVxvNxpZdBEYtaQ3AaTAJ8uHZ5rR+kd5IPDUQ5p5GQ3 0YfQ== X-Gm-Message-State: AOAM532YGnKkRqDUmm5tKRukpI9pglWTr0YgfkDdCdHIlgYgwP8d5roU JH5yhXMpFVYjfQCg8tcU15Hcq0iwiPNqGCbt66kfnezH X-Google-Smtp-Source: ABdhPJziKIVFQZZyGAc19wkoW8k4tTThOGnjlMwwbLjGzJvYykpLjFytDjQepmXpfbFy9m0D/iU2m46wZui/FcOuteM= X-Received: by 2002:a05:6830:1bd3:: with SMTP id v19mr4937480ota.91.1595522646286; Thu, 23 Jul 2020 09:44:06 -0700 (PDT) MIME-Version: 1.0 References: <20200723002022.Bluez.v1.1.I45e09d196073f099e1b67d2d69efd5cd20237ad1@changeid> In-Reply-To: <20200723002022.Bluez.v1.1.I45e09d196073f099e1b67d2d69efd5cd20237ad1@changeid> From: Luiz Augusto von Dentz Date: Thu, 23 Jul 2020 09:43:55 -0700 Message-ID: Subject: Re: [Bluez PATCH v1 1/2] input: authenticate when connecting to a bonded device To: Archie Pusaka Cc: linux-bluetooth , CrosBT Upstreaming , Archie Pusaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9C7CB40AD3 X-Rspamd-UID: ccced2 Hi Archie, On Wed, Jul 22, 2020 at 9:20 AM Archie Pusaka wrote: > > From: Archie Pusaka > > According to bluetooth HID1.1 spec, part 5.4.3.4.3: > If the Bluetooth HID Host is bonded to a Bluetooth HID device: > If encryption is not already enabled, the Bluetooth HID Host shall > enable encryption with the Bluetooth HID device before sending an > L2CAP Connect Request to open the HID L2CAP Control channel. > > When creating connection, this patch checks whether the target > device is bonded, if yes then we use the medium security level > instead of the low one to enable encryption. > > Reviewed-by: Alain Michaud > --- > > profiles/input/device.c | 21 ++++++++++++++++----- > 1 file changed, 16 insertions(+), 5 deletions(-) > > diff --git a/profiles/input/device.c b/profiles/input/device.c > index 2dc2ecab2..9f89f4459 100644 > --- a/profiles/input/device.c > +++ b/profiles/input/device.c > @@ -112,6 +112,12 @@ void input_set_classic_bonded_only(bool state) > static void input_device_enter_reconnect_mode(struct input_device *idev); > static int connection_disconnect(struct input_device *idev, uint32_t flags); > > +static bool input_device_bonded(struct input_device *idev) > +{ > + return device_is_bonded(idev->device, > + btd_device_get_bdaddr_type(idev->device)); > +} > + > static void input_device_free(struct input_device *idev) > { > bt_uhid_unref(idev->uhid); > @@ -979,8 +985,7 @@ static int hidp_add_connection(struct input_device *idev) > device_get_name(idev->device, req->name, sizeof(req->name)); > > /* Make sure the device is bonded if required */ > - if (classic_bonded_only && !device_is_bonded(idev->device, > - btd_device_get_bdaddr_type(idev->device))) { > + if (classic_bonded_only && !input_device_bonded(idev)) { > error("Rejected connection from !bonded device %s", dst_addr); > goto cleanup; > } > @@ -1153,16 +1158,23 @@ static int dev_connect(struct input_device *idev) > { > GError *err = NULL; > GIOChannel *io; > + BtIOSecLevel sec_level; > > if (idev->disable_sdp) > bt_clear_cached_session(&idev->src, &idev->dst); > > + /* encrypt connection if device is bonded */ > + if (input_device_bonded(idev)) > + sec_level = BT_IO_SEC_MEDIUM; > + else > + sec_level = BT_IO_SEC_LOW; > + > io = bt_io_connect(control_connect_cb, idev, > NULL, &err, > BT_IO_OPT_SOURCE_BDADDR, &idev->src, > BT_IO_OPT_DEST_BDADDR, &idev->dst, > BT_IO_OPT_PSM, L2CAP_PSM_HIDP_CTRL, > - BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, > + BT_IO_OPT_SEC_LEVEL, sec_level, > BT_IO_OPT_INVALID); > idev->ctrl_io = io; > > @@ -1227,8 +1239,7 @@ static void input_device_enter_reconnect_mode(struct input_device *idev) > reconnect_mode_to_string(idev->reconnect_mode)); > > /* Make sure the device is bonded if required */ > - if (classic_bonded_only && !device_is_bonded(idev->device, > - btd_device_get_bdaddr_type(idev->device))) > + if (classic_bonded_only && !input_device_bonded(idev)) > return; > > /* Only attempt an auto-reconnect when the device is required to > -- > 2.28.0.rc0.105.gf9edc3c819-goog > Applied, thanks. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0BNKHXy+GV/kuAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 18:44:44 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id IIELHHy+GV+PhQAAgupzMw (envelope-from ); Thu, 23 Jul 2020 18:44:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 55B174081B; Thu, 23 Jul 2020 18:44:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729810AbgGWQoi (ORCPT + 1 other); Thu, 23 Jul 2020 12:44:38 -0400 Received: from verein.lst.de ([213.95.11.211]:60887 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgGWQoi (ORCPT ); Thu, 23 Jul 2020 12:44:38 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 8C74368AFE; Thu, 23 Jul 2020 18:44:32 +0200 (CEST) Date: Thu, 23 Jul 2020 18:44:32 +0200 From: Christoph Hellwig To: Eric Dumazet Cc: Christoph Hellwig , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , LKML , netdev , bpf , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 04/26] net: add a new sockptr_t type Message-ID: <20200723164432.GA20917@lst.de> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-5-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 14 X-Rspamd-Score: 2.13 / 15.00 / 200.00 X-Rspamd-Queue-Id: 55B174081B X-Rspamd-UID: f9c400 On Thu, Jul 23, 2020 at 09:40:27AM -0700, Eric Dumazet wrote: > I am not sure why you chose sockptr_t for something that really seems generic. > > Or is it really meant to be exclusive to setsockopt() and/or getsockopt() ? > > If the first user of this had been futex code, we would have used > futexptr_t, I guess. It was originally intended to be generic and called uptr_t, based on me misunderstanding that Linus wanted a file operation for it, which he absolutely didn't and hate with passion. So the plan is to only use it for setsockopt for now, although there are some arguments for also using it in sendmsg/recvmsg. There is no need to use it for getsockopt. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KGmUFszXGV86IwAAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 20:32:44 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id EPcGFczXGV9iRAAA0J78UA (envelope-from ); Thu, 23 Jul 2020 20:32:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CA1F7A1A2D; Thu, 23 Jul 2020 20:32:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727043AbgGWScc (ORCPT + 1 other); Thu, 23 Jul 2020 14:32:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:49126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726349AbgGWScc (ORCPT ); Thu, 23 Jul 2020 14:32:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4F8DA20709; Thu, 23 Jul 2020 18:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595529151; bh=ZDU+EEnAEQWEflbNqthke0jssQz/wTzJgnUV5q4keqw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lPrTsHDb+D4Ge6NG31U0z3PeggId4zb7RAYTrqQ0uoyp9RS8ZBkoNO5NnXx3xRSkJ 38R+0QYeLVuKc4sOTvJ2+xSXaOLxzaDKj0teqXKCYAHZGZnXnVVQTWjpx2bglXS14p yGIN2/GGK/3PmuUAbZbaLBaP1J4ApF0cF2AlLvFs= Date: Thu, 23 Jul 2020 20:32:35 +0200 From: Greg Kroah-Hartman To: Abhishek Pandit-Subedi , rafael.j.wysocki@intel.com Cc: linux-pm@vger.kernel.org, linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, swboyd@chromium.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Pavel Machek Subject: Re: [PATCH v5 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove Message-ID: <20200723183235.GA3445384@kroah.com> References: <20200707172845.4177903-1-abhishekpandit@chromium.org> <20200707102823.v5.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707102823.v5.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.60 / 15.00 / 200.00 X-Rspamd-Queue-Id: CA1F7A1A2D X-Rspamd-UID: 9b7f00 On Tue, Jul 07, 2020 at 10:28:44AM -0700, Abhishek Pandit-Subedi wrote: > Udev rules that depend on the power/wakeup attribute don't get triggered > correctly if device_set_wakeup_capable is called after the device is > created. This can happen for several reasons (driver sets wakeup after > device is created, wakeup is changed on parent device, etc) and it seems > reasonable to emit a changed event when adding or removing attributes on > the device. > > Signed-off-by: Abhishek Pandit-Subedi Rafael, any objection to this? Do you want me to take it through my tree, or are you going to take it through yours? Either is fine for me. thanks, greg k-h Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eItjNB6EGV9K4QEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 14:35:42 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id GJHEMh6EGV9/LwEA0J78UA (envelope-from ); Thu, 23 Jul 2020 14:35:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8F5A9A010E; Thu, 23 Jul 2020 14:35:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728797AbgGWMf3 (ORCPT + 1 other); Thu, 23 Jul 2020 08:35:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGWMf3 (ORCPT ); Thu, 23 Jul 2020 08:35:29 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75D0CC0619DC for ; Thu, 23 Jul 2020 05:35:29 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id 72so2507329ple.0 for ; Thu, 23 Jul 2020 05:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6RSAZAZCD/2zvtqQwxc8kimw5YBb8FQUpkwthAppgoM=; b=qal8nDsq0om4u2aaDE6pcQwPdv763EX+ngNdNXdmJc/QkMTCc4pM3LoKF2mUiPaav8 4TfWVAAnVYwmrKRrYWcLAo8LQum3tq1iq8cOt0SgpntLPpz4g/t86iO5QXTasYYUrEK2 WZKpCQvaJgwShVkNlilQBh/mQSIjVHEkYnSi858k81NGVYECAfmTASzCJRd0unb6Pn1B 7QCKT+nNCRNO3tvKkypFdBhYDDZoqr0cT3UG9hOZJzpF8++19hIIV0XJU/einrC8iv9F oSQfUM2Dg6zAfOGJ0ralWP8prXhi4IsXpmwuTabYHmC52WVki0u8wMHxh014pk/2t+R+ wlqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6RSAZAZCD/2zvtqQwxc8kimw5YBb8FQUpkwthAppgoM=; b=AwYc16AyqNs4IDscbTIs68w3oGUbKQyi4FrFZKx28BX3/ADwXcOt9xC+9dINc19hjS LchmpVLM5oFBXgflWrSY2a7+iVk5oUgjckbg8BVxNeZXMM9DKEyG5fg0U/0kWOz3xCly lrF0V3sbPHs7S1c1ogY4EweaBCGQk2v43RSsX0t/C86zhUiKHJwvROLnI5S93y/XnUd6 Cg94jS0UOVcleDJdxsLhNAPvdw2xICDCxOsN3LSN4DvY4RJqXg70WM2N4KYFktwd3se8 55FNs4DZVVgEfqNha4GhOWYfxmcylRFKNKK0Z+hGCsrvuyWogrsXv9mS9qPoSiKS59xo hcmA== X-Gm-Message-State: AOAM531pMBFFGkuBkleoqFrfl5YgAVk/etQfotVsP4jDqVS0C+YyTSSx O4ekQK+u9OaOEZqQV1FoerjeHAkBqUppCw== X-Google-Smtp-Source: ABdhPJz78QFN8ZkZLfp1Cze+RNjKlr4DkYy2DTbdaRcpSPZSVg8EMVaPbRHDUqt146KMLZ18i7hYJg== X-Received: by 2002:a17:90a:7487:: with SMTP id p7mr178809pjk.233.1595507728801; Thu, 23 Jul 2020 05:35:28 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id z11sm2849823pfr.71.2020.07.23.05.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 05:35:28 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v5 5/8] Bluetooth: Let controller creates RPA during le create conn Date: Thu, 23 Jul 2020 18:09:00 +0530 Message-Id: <20200723123903.29337-5-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200723123903.29337-1-sathish.narasimman@intel.com> References: <20200723123903.29337-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8F5A9A010E X-Rspamd-UID: c0cdae When address resolution is enabled and set_privacy is enabled let's use own address type as 0x03 Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_request.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 85de1f356610..e48f0945a417 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2242,7 +2242,13 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, if (use_rpa) { int to; - *own_addr_type = ADDR_LE_DEV_RANDOM; + /* If Controller supports LL Privacy use own address type is + * 0x03 + */ + if (use_ll_privacy(hdev)) + *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED; + else + *own_addr_type = ADDR_LE_DEV_RANDOM; if (!hci_dev_test_and_clear_flag(hdev, HCI_RPA_EXPIRED) && !bacmp(&hdev->random_addr, &hdev->rpa)) -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iO42JSSEGV/G9gEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 14:35:48 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oIu6IySEGV/lMwAAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 14:35:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F2F98A1B5C; Thu, 23 Jul 2020 14:35:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728804AbgGWMfd (ORCPT + 1 other); Thu, 23 Jul 2020 08:35:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGWMfc (ORCPT ); Thu, 23 Jul 2020 08:35:32 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F81CC0619DC for ; Thu, 23 Jul 2020 05:35:32 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id o1so2510939plk.1 for ; Thu, 23 Jul 2020 05:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fOhhEhAN0IQXzOutjvj87FBSYs5c2PC/vUaHzKbtuME=; b=gWgmwkiqxjY1LBLcBYL63OpWnSKuddqA3k/VwMvNEB+C/c9azazT59YSRKKDi7zPVU 8y0uGnp0nfPM7FZvSd7IkbNm6shcJKR2mU1cWP+iQfaeiQzOWTTNQ/iECb8+rs4n1w3N 0KektuqbaBghuUvk6kWcAIMl8NV758FVLBYPamw8JPmV5P5cePilneoeBcWSxIArE+5q jQ68hikY7ruflElCNapElVM7+fjCQANj/hGQYuddrYuluk1LroCdq+rs7XGO7snoc3jp Y9eP6zkvwkxD1KHLr/Uq2fQec4xQ/Gfh/udXm0XueyObQ8p6G679ZI/mGZyOACG2K4r7 Hzuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fOhhEhAN0IQXzOutjvj87FBSYs5c2PC/vUaHzKbtuME=; b=aEl60jESOQsFxRG7SNuSizkrLYiaNCwNRwruNyaoyBKC9UlCX+slL9PJ3qubhZeX0u ptvWye/VjpT/yvZtOuZX9KODYYsl2lQO1q90s1mHBdW3lz/mjTMkknpuKEK99Jvt4oQw Wmzk0ZahZeTGEtl9iuPRflCq3hCTlLHfIHaXZESSG7pIVimgABTZL3LT+WHHvmrZ22Fj vAHI9EEi6GdZ8wmW412SKBUxImCM8V4X0Y2Sq4+9GFhNAdRTU1PAYIWG4q1Zgehm+Vda DG8LaNsfqf6EsuD06rb5kyVPqTz87R+wwYMWzkTBbQ/JbUDtn9zric/aBZ+jTadsgap8 EwfQ== X-Gm-Message-State: AOAM533C8JICkNnxTW0eW9sYL9ANtBcw7yWAdFbV1cY1Yrd0FzTfYrlT EoT17NoDSqL8Bouu43DpnHcbeFVMlA3AXA== X-Google-Smtp-Source: ABdhPJzn/yQDMH5oi/Wjf5PzbLjwDMFoe+LtHBuhw2WGryi2iVsV72s3oHuRQ/GO1nzTvzkLFDVyOg== X-Received: by 2002:a17:90a:e602:: with SMTP id j2mr200480pjy.200.1595507731910; Thu, 23 Jul 2020 05:35:31 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id z11sm2849823pfr.71.2020.07.23.05.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 05:35:31 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v5 6/8] Bluetooth: Enable/Disable address resolution during le create conn Date: Thu, 23 Jul 2020 18:09:01 +0530 Message-Id: <20200723123903.29337-6-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200723123903.29337-1-sathish.narasimman@intel.com> References: <20200723123903.29337-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: F2F98A1B5C X-Rspamd-UID: 893f08 In this patch if le_create_conn process is started restrict to disable address resolution and same is disabled during le_enh_connection_complete Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_conn.c | 7 +++++- net/bluetooth/hci_event.c | 4 ++++ net/bluetooth/hci_request.c | 45 ++++++++++++++++++++++++++++--------- net/bluetooth/hci_request.h | 3 ++- net/bluetooth/mgmt.c | 2 +- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index be67361ff2f0..9832f8445d43 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1003,6 +1003,11 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, struct hci_request req; int err; + /* This ensures that during disable le_scan address resolution + * will not be disabled if it is followed by le_create_conn + */ + bool rpa_le_conn = true; + /* Let's make sure that le is enabled.*/ if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { if (lmp_le_capable(hdev)) @@ -1103,7 +1108,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, * state. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, rpa_le_conn); hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED); } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 6388fb55b4d2..628831b15c0a 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5228,6 +5228,10 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->interval), le16_to_cpu(ev->latency), le16_to_cpu(ev->supervision_timeout)); + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + hci_req_disable_address_resolution(hdev); } static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index e48f0945a417..70e077cc7dfa 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -428,7 +428,7 @@ static void __hci_update_background_scan(struct hci_request *req) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) return; - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); BT_DBG("%s stopping background scanning", hdev->name); } else { @@ -447,7 +447,7 @@ static void __hci_update_background_scan(struct hci_request *req) * don't miss any advertising (due to duplicates filter). */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); hci_req_add_le_passive_scan(req); @@ -652,7 +652,7 @@ void __hci_req_update_eir(struct hci_request *req) hci_req_add(req, HCI_OP_WRITE_EIR, sizeof(cp), &cp); } -void hci_req_add_le_scan_disable(struct hci_request *req) +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) { struct hci_dev *hdev = req->hdev; @@ -676,8 +676,9 @@ void hci_req_add_le_scan_disable(struct hci_request *req) hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + /* Disable address resolution */ if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { __u8 enable = 0x00; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } @@ -1072,7 +1073,7 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) { /* Before changing params disable scan if enabled */ if (hci_dev_test_flag(req->hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ hci_req_add_le_passive_scan(req); @@ -1140,7 +1141,7 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) /* Disable LE passive scan if enabled */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); @@ -1696,6 +1697,28 @@ int hci_req_update_adv_data(struct hci_dev *hdev, u8 instance) return hci_req_run(&req, NULL); } +static void enable_addr_resolution_complete(struct hci_dev *hdev, u8 status, + u16 opcode) +{ + BT_DBG("%s status %u", hdev->name, status); +} + +void hci_req_disable_address_resolution(struct hci_dev *hdev) +{ + struct hci_request req; + __u8 enable = 0x00; + + if (!use_ll_privacy(hdev) && + !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + return; + + hci_req_init(&req, hdev); + + hci_req_add(&req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + + hci_req_run(&req, enable_addr_resolution_complete); +} + static void adv_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode) { BT_DBG("%s status %u", hdev->name, status); @@ -2667,7 +2690,7 @@ static void bg_scan_update(struct work_struct *work) static int le_scan_disable(struct hci_request *req, unsigned long opt) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); return 0; } @@ -2770,7 +2793,7 @@ static int le_scan_restart(struct hci_request *req, unsigned long opt) return 0; } - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); if (use_ext_scan(hdev)) { struct hci_cp_le_set_ext_scan_enable ext_enable_cp; @@ -2861,7 +2884,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) * discovery scanning parameters. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable @@ -2976,14 +2999,14 @@ bool hci_req_stop_discovery(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { cancel_delayed_work(&hdev->le_scan_disable); - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); } ret = true; } else { /* Passive scanning */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); ret = true; } } diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index bbe892ab078a..6a12e84c66c4 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -65,11 +65,12 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable); void __hci_req_update_name(struct hci_request *req); void __hci_req_update_eir(struct hci_request *req); -void hci_req_add_le_scan_disable(struct hci_request *req); +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn); void hci_req_add_le_passive_scan(struct hci_request *req); void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next); +void hci_req_disable_address_resolution(struct hci_dev *hdev); void hci_req_reenable_advertising(struct hci_dev *hdev); void __hci_req_enable_advertising(struct hci_request *req); void __hci_req_disable_advertising(struct hci_request *req); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index f45105d2de77..47bcfe2fb14c 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -5226,7 +5226,7 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev, hci_req_init(&req, hdev); - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); hci_req_add_le_passive_scan(&req); hci_req_run(&req, NULL); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uONBBCqEGV8WzAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 14:35:54 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id SBS/AiqEGV/HSgEA0J78UA (envelope-from ); Thu, 23 Jul 2020 14:35:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B60E2A1C74; Thu, 23 Jul 2020 14:35:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728820AbgGWMff (ORCPT + 1 other); Thu, 23 Jul 2020 08:35:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGWMff (ORCPT ); Thu, 23 Jul 2020 08:35:35 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44600C0619DC for ; Thu, 23 Jul 2020 05:35:35 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id md7so3001651pjb.1 for ; Thu, 23 Jul 2020 05:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PK9IFrqGA8tYf+eWNXSfj5UIMsffCcBtO2fOhU2TTN4=; b=dFRzsf1dtJ5p3hfGbld7FnwiV7O43cPZARtjXsGsdizh1lJyrpqfrGxBUbiNOnTvqT 9/Pn56r33XsbHvFLfBBmLtnUXF3rfyhMDnzUG4Svu+h8CsdQAvU4zxDP0dsEzNPpOBeo au4WPYmWQ5T++DmrKur/z+rJxYYc7Fo6A38oVHQfdb9d8XS8ZPEmB+cuFQWbIiyud2C6 +PnIMn9b4PVz7M9oM2QChdLr9Oy9yU/sH2WQzyLTaFebu4yq02sXUIDjsjVT68EerR1p EZen6NzAzCL4DdyIHfDzxmX2BqKtO+bnKtCQRu0fjM3CcY/1KmbZuLmuNecPQXqQ77Vb Zj2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PK9IFrqGA8tYf+eWNXSfj5UIMsffCcBtO2fOhU2TTN4=; b=lItbP/XdrV9Wy0U3MwknDLV2ls/DjrUtlbsHbkfjo8jldYGPbXZc5e+iemcxHMSFwE 3cD2PzEX+OQXhw0GW/o1vbnOOeOzuxWq8YpEBOdmiL96JZvHf8IoXtZ/rAoh9/xROB+k FLdBfmXVnNqNti/HnsUj286dNKwLXIABZWdTE4Mz5BV/freywpifrZ44JgWA+hxoCkUG fiK1RqZvyamVwHe+uX0q/8Ow4uQx4AAWpbbS+tjmACr+dCZYQ0+icACycqNP56SMtxkt gZHmE5kFVz+vwW9v1sIsMWX54ZgDA419Laa6EQ+yjKSexdTHDZKOdTOpPWfPPaksGyZq 3i9A== X-Gm-Message-State: AOAM532bUbdSvMI9eddl/M82EDtngtNFnPYmOkn9NDBIFw0K9b7nLHf6 txNHuW/+GF2JSxfJK9rNAMidxspi2MDwNA== X-Google-Smtp-Source: ABdhPJwg0oMH2ei7aOXDJJOrLjMJeU6NykB9GOZPJityNhfQwu2vRE/9WRj+ch7l9/53LyWzQxpkhw== X-Received: by 2002:a17:90a:c295:: with SMTP id f21mr214701pjt.208.1595507734661; Thu, 23 Jul 2020 05:35:34 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id z11sm2849823pfr.71.2020.07.23.05.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 05:35:34 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v5 7/8] Bluetooth: Enable RPA Timeout Date: Thu, 23 Jul 2020 18:09:02 +0530 Message-Id: <20200723123903.29337-7-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200723123903.29337-1-sathish.narasimman@intel.com> References: <20200723123903.29337-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: B60E2A1C74 X-Rspamd-UID: f7e314 Enable RPA timeout during bluetooth initialization. The RPA timeout value is used from hdev, which initialized from debug_fs Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 2 ++ net/bluetooth/hci_core.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index abab8b5981a7..4ff2fc4498f3 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1637,6 +1637,8 @@ struct hci_rp_le_read_resolv_list_size { #define HCI_OP_LE_SET_ADDR_RESOLV_ENABLE 0x202d +#define HCI_OP_LE_SET_RPA_TIMEOUT 0x202e + #define HCI_OP_LE_READ_MAX_DATA_LEN 0x202f struct hci_rp_le_read_max_data_len { __u8 status; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 4af208b82138..2030536cc5d8 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -762,6 +762,14 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt) hci_req_add(req, HCI_OP_LE_CLEAR_RESOLV_LIST, 0, NULL); } + if (hdev->commands[35] & 0x40) { + __le16 rpa_timeout = cpu_to_le16(hdev->rpa_timeout); + + /* Set RPA timeout */ + hci_req_add(req, HCI_OP_LE_SET_RPA_TIMEOUT, 2, + &rpa_timeout); + } + if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) { /* Read LE Maximum Data Length */ hci_req_add(req, HCI_OP_LE_READ_MAX_DATA_LEN, 0, NULL); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AOT9DjCEGV9K4QEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 14:36:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 8EkrDjCEGV/LSgEA0J78UA (envelope-from ); Thu, 23 Jul 2020 14:36:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 31A13A190F; Thu, 23 Jul 2020 14:35:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728824AbgGWMfi (ORCPT + 1 other); Thu, 23 Jul 2020 08:35:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGWMfi (ORCPT ); Thu, 23 Jul 2020 08:35:38 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FB09C0619DC for ; Thu, 23 Jul 2020 05:35:38 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id t6so3045814pgq.1 for ; Thu, 23 Jul 2020 05:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Cu/75K3lWYeUyKuqT51YSaA/+7LYwDoT1W120nqRIs=; b=hn1nOYbly6tmPQdjT3TVUn/PN1teCiDYOjV376GsjOYZYsLBcijPfp8EMvrPNR9HTD wMZT84IRM0cq/leX0uboSHeBpiqZA+49sxApeD2PmPQKWSU5FjMHbrYBMv5Vngy/30h8 Ehe18QZAyRt6ymUMDzij6coaCvCqYYb2CQD6fcOWJuJkGlQTWvtMa2usQH9mD9I4vPHV H1enKQqa9NCJeAPmClQZQ6XCgJ+jSPP/JysNwsHSyTrsGmBtsQyxsa29t4F1EdtB2Px6 ihPvZPt4o9cyrSXF/GebaGhmfjxhl616B69ReUKmv7nEW19ia3rGY/UBduhcvHoJ2vyQ OE9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0Cu/75K3lWYeUyKuqT51YSaA/+7LYwDoT1W120nqRIs=; b=MHFPIKNCC0bik/6lvMICH5B9exOwcHMH0QKe/51XFt3xnpyFnvS7dkUwhsxWSZiKNi gzT0KHiWazcWqWnabxwA4+bPpXljHcCR36YnJ5Yf4ExxeYHQuDwshPcMj2drZAKeqRWy G7Kpg/qHlTiNroljadBNzTEhDj+JN4hXd0sko8x2DAexioii87/0337yX14tzAtIGCvH GL/febrVcJfJWj7DXdeQK0v/PD8aNWBgsDdRFPcHDhDy8MSGqG7U4Nd9xzzwrdBxaO7i K9C4k7lkZcd47MielI5IT9tU+t5RSpl80DPA7tqQy2TbfMisERsoqth3UPQGKL8UaIPD gXLw== X-Gm-Message-State: AOAM530rbmVnSjT0F+DBuDU+/Xkw7u9BAe4kIbYcnCbMhaRUcsTuvrsY uyQG7Hm+6r94kqB6tPjMxiuMo41XgZg7Xg== X-Google-Smtp-Source: ABdhPJwZ+rnaYcxKI5mpspMN6aYKRKpe0HUc7eXO4pIawMa4JYUNbTUiYkoCw1DKaxRfQgDoBSQAkA== X-Received: by 2002:aa7:970a:: with SMTP id a10mr4107521pfg.319.1595507737452; Thu, 23 Jul 2020 05:35:37 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id z11sm2849823pfr.71.2020.07.23.05.35.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 05:35:37 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v5 8/8] Bluetooth: Enable controller RPA resolution using Experimental feature Date: Thu, 23 Jul 2020 18:09:03 +0530 Message-Id: <20200723123903.29337-8-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200723123903.29337-1-sathish.narasimman@intel.com> References: <20200723123903.29337-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 31A13A190F X-Rspamd-UID: 8dce65 This patch adds support to enable the use of RPA Address resolution using expermental feature mgmt command. Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_event.c | 1 + net/bluetooth/hci_request.c | 7 ++- net/bluetooth/mgmt.c | 112 ++++++++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 4ff2fc4498f3..55205d805c22 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -307,6 +307,7 @@ enum { HCI_FORCE_BREDR_SMP, HCI_FORCE_STATIC_ADDR, HCI_LL_RPA_RESOLUTION, + HCI_ENABLE_LL_PRIVACY, HCI_CMD_PENDING, HCI_FORCE_NO_MITM, diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 628831b15c0a..33d8458fdd4a 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5230,6 +5230,7 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->supervision_timeout)); if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) hci_req_disable_address_resolution(hdev); } diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 70e077cc7dfa..435400a43a78 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -678,8 +678,10 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) /* Disable address resolution */ if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { __u8 enable = 0x00; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } } @@ -870,8 +872,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } - if (use_ll_privacy(hdev) && addr_resolv) { + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && + addr_resolv) { u8 enable = 0x01; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 47bcfe2fb14c..adde92cf015d 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3759,6 +3759,12 @@ static const u8 simult_central_periph_uuid[16] = { 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, }; +/* 15c0a148-c273-11ea-b3de-0242ac130004 */ +static const u8 rpa_resolution_uuid[16] = { + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, +}; + static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { @@ -3795,6 +3801,21 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, idx++; } + if (use_ll_privacy(hdev)) { + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) { + flags = BIT(0); + if (!hci_dev_test_flag(hdev, HCI_ADVERTISING)) + flags |= BIT(1); + } else + flags = 0; + + memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); + rp->features[idx].flags = cpu_to_le32(flags); + idx++; + + new_settings(hdev, sk); + } + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable @@ -3807,6 +3828,27 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, 0, rp, sizeof(*rp) + (20 * idx)); } +static int exp_ll_privacy_feature_changed(bool enabled, struct sock *skip) +{ + struct mgmt_ev_exp_feature_changed ev; + u32 flags; + + memset(&ev, 0, sizeof(ev)); + memcpy(ev.uuid, rpa_resolution_uuid, 16); + + if (enabled) + flags = 0x03; + else + flags = 0; + + ev.flags = cpu_to_le32(flags); + + return mgmt_limited_event(MGMT_EV_EXP_FEATURE_CHANGED, NULL, + &ev, sizeof(ev), + HCI_MGMT_EXP_FEATURE_EVENTS, skip); + +} + #ifdef CONFIG_BT_FEATURE_DEBUG static int exp_debug_feature_changed(bool enabled, struct sock *skip) { @@ -3845,6 +3887,18 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, } #endif + if (use_ll_privacy(hdev)) { + bool changed; + + changed = hci_dev_test_flag(hdev, + HCI_ENABLE_LL_PRIVACY); + + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); + + if (changed) + exp_ll_privacy_feature_changed(false, sk); + } + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); return mgmt_cmd_complete(sk, hdev ? hdev->id : MGMT_INDEX_NONE, @@ -3895,6 +3949,64 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, } #endif + if (!memcmp(cp->uuid, rpa_resolution_uuid, 16)) { + bool val, changed; + int err; + u32 flags; + + /* Parameters are limited to a single octet */ + if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + /* Only boolean on/off is supported */ + if (cp->param[0] != 0x00 && cp->param[0] != 0x01) + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + val = !!cp->param[0]; + + if (val) { + changed = !hci_dev_test_flag(hdev, + HCI_ENABLE_LL_PRIVACY); + + hci_dev_set_flag(hdev, HCI_ENABLE_LL_PRIVACY); + + /* Enable LL privacy */ + flags = BIT(0); + /* Disable HCI_ADVERTISING flag */ + flags |= BIT(1); + + hci_dev_clear_flag(hdev, HCI_ADVERTISING); + + } else { + changed = hci_dev_test_flag(hdev, + HCI_ENABLE_LL_PRIVACY); + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); + + flags = 0; + } + + memcpy(rp.uuid, rpa_resolution_uuid, 16); + + rp.flags = cpu_to_le32(flags); + + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); + + err = mgmt_cmd_complete(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, 0, + &rp, sizeof(rp)); + + if (changed) { + exp_ll_privacy_feature_changed(val, sk); + new_settings(hdev, sk); + } + + return err; + } + return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, MGMT_OP_SET_EXP_FEATURE, MGMT_STATUS_NOT_SUPPORTED); -- 2.17.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aHe8NtChGV89rQAAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 16:42:24 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id +OhDNdChGV+cjwEAgupzMw (envelope-from ); Thu, 23 Jul 2020 16:42:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 378E0A19A1; Thu, 23 Jul 2020 16:42:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728553AbgGWOmR convert rfc822-to-8bit (ORCPT + 1 other); Thu, 23 Jul 2020 10:42:17 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:23234 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726761AbgGWOmR (ORCPT ); Thu, 23 Jul 2020 10:42:17 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-258-XYagsueXN0qZRmxt_6g0lA-1; Thu, 23 Jul 2020 15:42:13 +0100 X-MC-Unique: XYagsueXN0qZRmxt_6g0lA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 23 Jul 2020 15:42:12 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 23 Jul 2020 15:42:12 +0100 From: David Laight To: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , "Daniel Borkmann" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet CC: "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: RE: [PATCH 03/26] bpfilter: reject kernel addresses Thread-Topic: [PATCH 03/26] bpfilter: reject kernel addresses Thread-Index: AQHWYLhxJPyZOJNDGEen8+LVytPg86kVPIvA Date: Thu, 23 Jul 2020 14:42:11 +0000 Message-ID: References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-4-hch@lst.de> In-Reply-To: <20200723060908.50081-4-hch@lst.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 5 X-Rspamd-Score: 0.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: 378E0A19A1 X-Rspamd-UID: cf4ec5 From: Christoph Hellwig > Sent: 23 July 2020 07:09 > > The bpfilter user mode helper processes the optval address using > process_vm_readv. Don't send it kernel addresses fed under > set_fs(KERNEL_DS) as that won't work. What sort of operations is the bpf filter doing on the sockopt buffers? Any attempts to reject some requests can be thwarted by a second application thread modifying the buffer after the bpf filter has checked that it allowed. You can't do security by reading a user buffer twice. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4MK3Dn+iGV9V/wAAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 16:45:19 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id KEgUDX+iGV/CEAAAgupzMw (envelope-from ); Thu, 23 Jul 2020 16:45:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2E125A1D3F; Thu, 23 Jul 2020 16:45:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728310AbgGWOpC (ORCPT + 1 other); Thu, 23 Jul 2020 10:45:02 -0400 Received: from verein.lst.de ([213.95.11.211]:60533 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726761AbgGWOpC (ORCPT ); Thu, 23 Jul 2020 10:45:02 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 7138C68AFE; Thu, 23 Jul 2020 16:44:55 +0200 (CEST) Date: Thu, 23 Jul 2020 16:44:55 +0200 From: 'Christoph Hellwig' To: David Laight Cc: 'Christoph Hellwig' , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: Re: [PATCH 03/26] bpfilter: reject kernel addresses Message-ID: <20200723144455.GA12280@lst.de> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-4-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 5 X-Rspamd-Score: 0.78 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2E125A1D3F X-Rspamd-UID: cabbce On Thu, Jul 23, 2020 at 02:42:11PM +0000, David Laight wrote: > From: Christoph Hellwig > > Sent: 23 July 2020 07:09 > > > > The bpfilter user mode helper processes the optval address using > > process_vm_readv. Don't send it kernel addresses fed under > > set_fs(KERNEL_DS) as that won't work. > > What sort of operations is the bpf filter doing on the sockopt buffers? > > Any attempts to reject some requests can be thwarted by a second > application thread modifying the buffer after the bpf filter has > checked that it allowed. > > You can't do security by reading a user buffer twice. I'm not saying that I approve of the design, but the current bpfilter design uses process_vm_readv to access the buffer, which obviously does not work with kernel buffers. Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oLAjDjKlGV89rQAAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 16:56:50 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id YOYGDTKlGV/xUgEA0J78UA (envelope-from ); Thu, 23 Jul 2020 16:56:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id ADA50A1B9D; Thu, 23 Jul 2020 16:56:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728946AbgGWO4n convert rfc822-to-8bit (ORCPT + 1 other); Thu, 23 Jul 2020 10:56:43 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:49807 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728629AbgGWO4i (ORCPT ); Thu, 23 Jul 2020 10:56:38 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-82-SdYRZOb-OAyxxDdIZA3c_Q-1; Thu, 23 Jul 2020 15:56:34 +0100 X-MC-Unique: SdYRZOb-OAyxxDdIZA3c_Q-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 23 Jul 2020 15:56:33 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 23 Jul 2020 15:56:33 +0100 From: David Laight To: 'Christoph Hellwig' CC: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "linux-sctp@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-bluetooth@vger.kernel.org" , "bridge@lists.linux-foundation.org" , "linux-can@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-decnet-user@lists.sourceforge.net" , "linux-wpan@vger.kernel.org" , "linux-s390@vger.kernel.org" , "mptcp@lists.01.org" , "lvs-devel@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-afs@lists.infradead.org" , "tipc-discussion@lists.sourceforge.net" , "linux-x25@vger.kernel.org" Subject: RE: [PATCH 03/26] bpfilter: reject kernel addresses Thread-Topic: [PATCH 03/26] bpfilter: reject kernel addresses Thread-Index: AQHWYLhxJPyZOJNDGEen8+LVytPg86kVPIvA///w6YCAABGh0A== Date: Thu, 23 Jul 2020 14:56:33 +0000 Message-ID: <5fc6b1716f1b4534bda95bab49512754@AcuMS.aculab.com> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-4-hch@lst.de> <20200723144455.GA12280@lst.de> In-Reply-To: <20200723144455.GA12280@lst.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 24 X-Rspamd-Score: 3.67 / 15.00 / 200.00 X-Rspamd-Queue-Id: ADA50A1B9D X-Rspamd-UID: 40dfa7 From: 'Christoph Hellwig' > Sent: 23 July 2020 15:45 > > On Thu, Jul 23, 2020 at 02:42:11PM +0000, David Laight wrote: > > From: Christoph Hellwig > > > Sent: 23 July 2020 07:09 > > > > > > The bpfilter user mode helper processes the optval address using > > > process_vm_readv. Don't send it kernel addresses fed under > > > set_fs(KERNEL_DS) as that won't work. > > > > What sort of operations is the bpf filter doing on the sockopt buffers? > > > > Any attempts to reject some requests can be thwarted by a second > > application thread modifying the buffer after the bpf filter has > > checked that it allowed. > > > > You can't do security by reading a user buffer twice. > > I'm not saying that I approve of the design, but the current bpfilter > design uses process_vm_readv to access the buffer, which obviously does > not work with kernel buffers. Is this a different bit of bpf that that which used to directly intercept setsockopt() requests and pass them down from a kernel buffer? I can't held feeling that bpf is getting 'too big for its boots' and will have a local-user privilege escalation hiding in it somewhere. I've had to fix my 'out of tree' driver to remove the [sg]etsockopt() calls. Some of the replacements will go badly wrong if I've accidentally lost track of the socket type. I do have a daemon process sleeping in the driver - so I can wake it up and make the requests from it with a user buffer. I may have to implement that to get the negotiated number of 'ostreams' to an SCTP connection. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0G8QMqavGV8kMgEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 17:41:26 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AAe+MKavGV/lQAAAgupzMw (envelope-from ); Thu, 23 Jul 2020 17:41:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 41718A0183; Thu, 23 Jul 2020 17:41:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729632AbgGWPlE (ORCPT + 1 other); Thu, 23 Jul 2020 11:41:04 -0400 Received: from a3.inai.de ([88.198.85.195]:44866 "EHLO a3.inai.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729551AbgGWPlC (ORCPT ); Thu, 23 Jul 2020 11:41:02 -0400 Received: by a3.inai.de (Postfix, from userid 25121) id 049975872C746; Thu, 23 Jul 2020 17:40:49 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by a3.inai.de (Postfix) with ESMTP id 038D360C4009F; Thu, 23 Jul 2020 17:40:49 +0200 (CEST) Date: Thu, 23 Jul 2020 17:40:49 +0200 (CEST) From: Jan Engelhardt To: Christoph Hellwig cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , Eric Dumazet , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Netfilter Developer Mailing List , coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 04/26] net: add a new sockptr_t type In-Reply-To: <20200723060908.50081-5-hch@lst.de> Message-ID: References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-5-hch@lst.de> User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 24 X-Rspamd-Score: 3.65 / 15.00 / 200.00 X-Rspamd-Queue-Id: 41718A0183 X-Rspamd-UID: b0ae87 On Thursday 2020-07-23 08:08, Christoph Hellwig wrote: >+typedef struct { >+ union { >+ void *kernel; >+ void __user *user; >+ }; >+ bool is_kernel : 1; >+} sockptr_t; >+ >+static inline bool sockptr_is_null(sockptr_t sockptr) >+{ >+ return !sockptr.user && !sockptr.kernel; >+} """If the member used to access the contents of a union is not the same as the member last used to store a value, the object representation of the value that was stored is reinterpreted as an object representation of the new type (this is known as type punning). If the size of the new type is larger than the size of the last-written type, the contents of the excess bytes are unspecified (and may be a trap representation)""" As I am not too versed with the consequences of trap representations, I will just point out that a future revision of the C standard may introduce (proposal N2362) stronger C++-like requirements; as for union, that would imply a simple: """It's undefined behavior to read from the member of the union that wasn't most recently written.""" [cppreference.com] So, in the spirit of copy_from/to_sockptr, the is_null function should read { return sockptr.is_kernel ? !sockptr.user : !sockptr.kernel; } Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YMXHDSm9GV9roAEAvsO+Rg (envelope-from ) for ; Thu, 23 Jul 2020 18:39:05 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id SJJuDCm9GV/aDwEAlp8NpQ (envelope-from ); Thu, 23 Jul 2020 18:39:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E73CEA179F; Thu, 23 Jul 2020 18:39:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729831AbgGWQi7 (ORCPT + 1 other); Thu, 23 Jul 2020 12:38:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726970AbgGWQi7 (ORCPT ); Thu, 23 Jul 2020 12:38:59 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61E4FC0619DC for ; Thu, 23 Jul 2020 09:38:59 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id h1so4796748otq.12 for ; Thu, 23 Jul 2020 09:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=+k6tAPdKA8egZIakYW/hwYr6S0mppD43czoiEEi8acU=; b=cu9oMjvNZ71JgITrfgZlh270OiNQtK3s9LOS/AwIDumEYpY1JUukyvG4/P43fE1aTL 7OQvQGtAPBzdBPnsT9Q3OB/el4BunVwP2HD4FE6LYwd9ydqIwOCKUV9sPdLgiVXzk8YQ 5o97kum+N5CcuS7ANtJ56WV8GG0J+6o5LVDfrDN0oA2k4aSr9GAYIuXH6zyBEN1nBr7o dHIhelYRJ4ONAOSwiS1h6YobE5PANWUqDCy9C57zG4Yh6ky1lKk7CUgq8NrhA2M5FVnO HQNBeIPlrl92WGCy3wYHiTh++qH/vKc+EuPwWmmhWmvDLKlkWMHYzBoi9ipyoa5Qhg4O NCmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=+k6tAPdKA8egZIakYW/hwYr6S0mppD43czoiEEi8acU=; b=Lf8aZdF9EtI2zXLqh3ui3oiQJm3lCrNf1Pq9GxtucZw1R7Er5KV5xe8IEjqR7EHsFq K/EkkCFfY61VpbhA3xLEnVQjdFM6c4hEgI0qoe3cR7plUkv7PzMPDmGNKvTdBhhSFDbs dnUu6eWZcubxcEQ5VJ8rIgwGD/vW2lnCFd8w2rbTDpN5HY74zNY+thEDdU69jEabMDLL FoW2kzV+1gt9sSORyBMSwS7sOAwM9m8WQdYy8GGcwQGpwrTmjAkoFz9v/Dv3y9+IZvWc ApUkEexWEH609GDfETfcn/Pgj7z6uZ9nxP7DKv3UKa57+HTaVe3TB3DtJmC3WB+z9hLS vTtA== X-Gm-Message-State: AOAM5335rKplJS8ncCcWsh/R5/+bDzqWil8Py7sVZmZfhZlV20/HSSrX cdhYrN8wkEElDwRvJX39pPNJsmTYVWSi3CeRM9cXzJrc X-Google-Smtp-Source: ABdhPJwcdBgpmLx2yLjiHwjN/peSZ4TxQ8ZLd+8DMD5bFWg9g9CXKzcZlq8iRfUePsOJbWYftWqlnMyHXNxcceeUCQQ= X-Received: by 2002:a9d:5e18:: with SMTP id d24mr4848377oti.88.1595522338476; Thu, 23 Jul 2020 09:38:58 -0700 (PDT) MIME-Version: 1.0 References: <20200718004942.326261-1-luiz.dentz@gmail.com> In-Reply-To: <20200718004942.326261-1-luiz.dentz@gmail.com> From: Luiz Augusto von Dentz Date: Thu, 23 Jul 2020 09:38:47 -0700 Message-ID: Subject: Re: [PATCH BlueZ] adapter: Don't remove temporary devices on disconnect To: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: E73CEA179F X-Rspamd-UID: ee18ea Hi, On Fri, Jul 17, 2020 at 5:50 PM Luiz Augusto von Dentz wrote: > > From: Luiz Augusto von Dentz > > This makes the disconnect logic just update last seen field of the > device so in case it is temporary it would trigger its timer and be > removed after the timeout which is consistent with the discovery > session givin a grace time for application to react to such events. > --- > src/adapter.c | 7 ------- > src/device.c | 2 ++ > 2 files changed, 2 insertions(+), 7 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index c757447e2..5e896a9f0 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -6837,13 +6837,6 @@ static void adapter_remove_connection(struct btd_adapter *adapter, > return; > > adapter->connections = g_slist_remove(adapter->connections, device); > - > - if (device_is_temporary(device) && !device_is_retrying(device)) { > - const char *path = device_get_path(device); > - > - DBG("Removing temporary device %s", path); > - btd_adapter_remove_device(adapter, device); > - } > } > > static void adapter_stop(struct btd_adapter *adapter) > diff --git a/src/device.c b/src/device.c > index 470596ee4..2237a7670 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -3039,6 +3039,8 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > if (device->bredr_state.connected || device->le_state.connected) > return; > > + device_update_last_seen(device, bdaddr_type); > + > g_dbus_emit_property_changed(dbus_conn, device->path, > DEVICE_INTERFACE, "Connected"); > } > -- > 2.26.2 Applied. -- Luiz Augusto von Dentz Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UKK7AZwOGl+QWAEAvsO+Rg (envelope-from ) for ; Fri, 24 Jul 2020 00:26:36 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 4IaYAJwOGl8gawEA0J78UA (envelope-from ); Fri, 24 Jul 2020 00:26:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 769954000F; Fri, 24 Jul 2020 00:26:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727075AbgGWW02 (ORCPT + 1 other); Thu, 23 Jul 2020 18:26:28 -0400 Received: from mga17.intel.com ([192.55.52.151]:50824 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbgGWW01 (ORCPT ); Thu, 23 Jul 2020 18:26:27 -0400 IronPort-SDR: KgyFU5Owulk3GVml5kC/TvZqvo/Js3MpVFWbePdr81sjTSEZGKm1qJl6qrUGuPAdynCDmRQX/0 PW+tB4FDyf5Q== X-IronPort-AV: E=McAfee;i="6000,8403,9691"; a="130703914" X-IronPort-AV: E=Sophos;i="5.75,388,1589266800"; d="scan'208";a="130703914" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jul 2020 15:00:23 -0700 IronPort-SDR: XxJNZD5VawdcHW8W68dPSLh3KmQcC8aCwn2hT24NtCu/I3U1w//7AT5550hFrAWaT5oVkl0Vp9 obHYMcKQ0oow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,388,1589266800"; d="scan'208";a="463012199" Received: from ncpatra-mobl2.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.73]) by orsmga005.jf.intel.com with ESMTP; 23 Jul 2020 15:00:22 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ v4] mesh: Move model functionality out of node.c to model.c Date: Thu, 23 Jul 2020 15:00:21 -0700 Message-Id: <20200723220021.370600-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 769954000F X-Rspamd-UID: 8a38a8 This moves the model related code out of node.c to model.c providing for better functional separation of modules. Also, use the value of 0xFFFF for internal representation of vendor ID for BT SIG defined models. This allows to maintain a single internal vendor ID / model ID space. --- mesh/cfgmod-server.c | 172 ++++++------- mesh/cfgmod.h | 4 +- mesh/mesh-config-json.c | 5 +- mesh/model.c | 544 +++++++++++++++++++++++++++------------- mesh/model.h | 74 +++--- mesh/node.c | 319 ++++------------------- mesh/node.h | 4 +- 7 files changed, 544 insertions(+), 578 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 9046a1ad9..7672ad3b6 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -2,7 +2,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. + * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * * This library is free software; you can redistribute it and/or @@ -42,7 +42,7 @@ static uint8_t msg[MAX_MSG_LEN]; static void send_pub_status(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, uint32_t mod_id, + uint8_t status, uint16_t ele_addr, uint32_t id, uint16_t pub_addr, uint16_t idx, bool cred_flag, uint8_t ttl, uint8_t period, uint8_t retransmit) { @@ -59,12 +59,12 @@ static void send_pub_status(struct mesh_node *node, uint16_t net_idx, msg[n++] = period; msg[n++] = retransmit; - if (mod_id >= VENDOR_ID_MASK) { - l_put_le16(mod_id, msg + n); + if (!IS_VENDOR(id)) { + l_put_le16(MODEL_ID(id), msg + n); n += 2; } else { - l_put_le16(mod_id >> 16, msg + n); - l_put_le16(mod_id, msg + n + 2); + l_put_le16(VENDOR_ID(id), msg + n); + l_put_le16(MODEL_ID(id), msg + n + 2); n += 4; } @@ -76,37 +76,35 @@ static void config_pub_get(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, const uint8_t *pkt, uint16_t size) { - uint32_t mod_id; + uint32_t id; uint16_t ele_addr; struct mesh_model_pub *pub; int status; if (size == 4) { - mod_id = l_get_le16(pkt + 2); - mod_id |= VENDOR_ID_MASK; + id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); } else if (size == 6) { - mod_id = l_get_le16(pkt + 2) << 16; - mod_id |= l_get_le16(pkt + 4); + id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); } else return; ele_addr = l_get_le16(pkt); - pub = mesh_model_pub_get(node, ele_addr, mod_id, &status); + pub = mesh_model_pub_get(node, ele_addr, id, &status); if (pub && status == MESH_STATUS_SUCCESS) send_pub_status(node, net_idx, src, dst, status, ele_addr, - mod_id, pub->addr, pub->idx, pub->credential, + id, pub->addr, pub->idx, pub->credential, pub->ttl, pub->period, pub->retransmit); else send_pub_status(node, net_idx, src, dst, status, ele_addr, - mod_id, 0, 0, 0, 0, 0, 0); + id, 0, 0, 0, 0, 0, 0); } static void config_pub_set(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, const uint8_t *pkt, bool virt, bool vendor) { - uint32_t mod_id; + uint32_t id; uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; const uint8_t *pub_addr; uint16_t test_addr; @@ -124,12 +122,12 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, ttl = pkt[6]; period = pkt[7]; retransmit = pkt[8]; - mod_id = l_get_le16(pkt + 9); + id = l_get_le16(pkt + 9); if (!vendor) - mod_id |= VENDOR_ID_MASK; + id = SET_ID(SIG_VENDOR, id); else - mod_id = (mod_id << 16) | l_get_le16(pkt + 11); + id = SET_ID(id, l_get_le16(pkt + 11)); /* Don't accept virtual seeming addresses */ test_addr = l_get_le16(pub_addr); @@ -139,16 +137,16 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, cred_flag = !!(CREDFLAG_MASK & idx); idx &= APP_IDX_MASK; - status = mesh_model_pub_set(node, ele_addr, mod_id, pub_addr, idx, + status = mesh_model_pub_set(node, ele_addr, id, pub_addr, idx, cred_flag, ttl, period, retransmit, virt, &ota); l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, mod: %x, idx: %3.3x", - status, ele_addr, ota, mod_id, idx); + status, ele_addr, ota, id, idx); if (status != MESH_STATUS_SUCCESS) { send_pub_status(node, net_idx, src, dst, status, ele_addr, - mod_id, 0, 0, 0, 0, 0, 0); + id, 0, 0, 0, 0, 0, 0); return; } @@ -158,7 +156,7 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, /* Remove model publication from config file */ if (!mesh_config_model_pub_del(node_config_get(node), ele_addr, - vendor ? mod_id : mod_id & ~VENDOR_ID_MASK, + vendor ? id : MODEL_ID(id), vendor)) status = MESH_STATUS_STORAGE_FAIL; } else { @@ -178,19 +176,19 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, /* Save model publication to config file */ if (!mesh_config_model_pub_add(node_config_get(node), ele_addr, - vendor ? mod_id : mod_id & ~VENDOR_ID_MASK, - vendor, &db_pub)) + vendor ? id : MODEL_ID(id), + vendor, &db_pub)) status = MESH_STATUS_STORAGE_FAIL; } - send_pub_status(node, net_idx, src, dst, status, ele_addr, mod_id, ota, + send_pub_status(node, net_idx, src, dst, status, ele_addr, id, ota, idx, cred_flag, ttl, period, retransmit); } static void send_sub_status(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t status, uint16_t ele_addr, - uint16_t addr, uint32_t mod) + uint16_t addr, uint32_t id) { int n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); @@ -199,12 +197,13 @@ static void send_sub_status(struct mesh_node *node, uint16_t net_idx, n += 2; l_put_le16(addr, msg + n); n += 2; - if (mod >= 0x10000 && mod < VENDOR_ID_MASK) { - l_put_le16(mod >> 16, msg + n); - l_put_le16(mod, msg + n + 2); + + if (IS_VENDOR(id)) { + l_put_le16(VENDOR_ID(id), msg + n); + l_put_le16(MODEL_ID(id), msg + n + 2); n += 4; } else { - l_put_le16(mod, msg + n); + l_put_le16(MODEL_ID(id), msg + n); n += 2; } @@ -217,7 +216,7 @@ static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, const uint8_t *pkt, uint16_t size) { uint16_t ele_addr; - uint32_t mod_id; + uint32_t id; uint16_t n = 0; int status; uint8_t *msg_status; @@ -232,34 +231,33 @@ static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, return false; case 4: - mod_id = l_get_le16(pkt + 2); + id = l_get_le16(pkt + 2); n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_LIST, msg); msg_status = msg + n; msg[n++] = 0; l_put_le16(ele_addr, msg + n); n += 2; - l_put_le16(mod_id, msg + n); + l_put_le16(id, msg + n); n += 2; - mod_id |= VENDOR_ID_MASK; + id = SET_ID(SIG_VENDOR, id); break; case 6: - mod_id = l_get_le16(pkt + 2) << 16; - mod_id |= l_get_le16(pkt + 4); + id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); n = mesh_model_opcode_set(OP_CONFIG_VEND_MODEL_SUB_LIST, msg); msg_status = msg + n; msg[n++] = 0; l_put_le16(ele_addr, msg + n); n += 2; - l_put_le16(mod_id >> 16, msg + n); + l_put_le16(VENDOR_ID(id), msg + n); n += 2; - l_put_le16(mod_id, msg + n); + l_put_le16(MODEL_ID(id), msg + n); n += 2; break; } buf_size = sizeof(uint16_t) * MAX_GRP_PER_MOD; - status = mesh_model_sub_get(node, ele_addr, mod_id, msg + n, buf_size, + status = mesh_model_sub_get(node, ele_addr, id, msg + n, buf_size, &size); if (status == MESH_STATUS_SUCCESS) @@ -273,7 +271,7 @@ static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, } static bool save_config_sub(struct mesh_node *node, uint16_t ele_addr, - uint32_t mod_id, bool vendor, + uint32_t id, bool vendor, const uint8_t *addr, bool virt, uint16_t grp, uint32_t opcode) { @@ -287,20 +285,18 @@ static bool save_config_sub(struct mesh_node *node, uint16_t ele_addr, if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE || opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) - mesh_config_model_sub_del_all(node_config_get(node), - ele_addr, vendor ? mod_id : mod_id & 0x0000ffff, + mesh_config_model_sub_del_all(node_config_get(node), ele_addr, + vendor ? id : MODEL_ID(id), vendor); if (opcode != OP_CONFIG_MODEL_SUB_VIRT_DELETE && opcode != OP_CONFIG_MODEL_SUB_DELETE) return mesh_config_model_sub_add(node_config_get(node), - ele_addr, - vendor ? mod_id : mod_id & 0x0000ffff, + ele_addr, vendor ? id : MODEL_ID(id), vendor, &db_sub); else return mesh_config_model_sub_del(node_config_get(node), - ele_addr, - vendor ? mod_id : mod_id & 0x0000ffff, + ele_addr, vendor ? id : MODEL_ID(id), vendor, &db_sub); } @@ -310,7 +306,7 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, bool virt, uint32_t opcode) { uint16_t grp, ele_addr; - uint32_t mod_id; + uint32_t id; const uint8_t *addr = NULL; int status = MESH_STATUS_SUCCESS; bool vendor = false; @@ -322,40 +318,40 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, case 4: if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) return; - mod_id = l_get_le16(pkt + 2); - mod_id |= VENDOR_ID_MASK; + + id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); break; case 6: if (virt) return; + if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - mod_id = l_get_le16(pkt + 4); - mod_id |= VENDOR_ID_MASK; + id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); } else { - mod_id = l_get_le16(pkt + 2) << 16; - mod_id |= l_get_le16(pkt + 4); + id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); vendor = true; } + break; case 8: if (virt) return; - mod_id = l_get_le16(pkt + 4) << 16; - mod_id |= l_get_le16(pkt + 6); + + id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); vendor = true; break; case 20: if (!virt) return; - mod_id = l_get_le16(pkt + 18); - mod_id |= VENDOR_ID_MASK; + + id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 18)); break; case 22: if (!virt) return; + vendor = true; - mod_id = l_get_le16(pkt + 18) << 16; - mod_id |= l_get_le16(pkt + 20); + id = SET_ID(l_get_le16(pkt + 18), l_get_le16(pkt + 20)); break; } @@ -373,11 +369,11 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, return; case OP_CONFIG_MODEL_SUB_DELETE_ALL: - status = mesh_model_sub_del_all(node, ele_addr, mod_id); + status = mesh_model_sub_del_all(node, ele_addr, id); if (status == MESH_STATUS_SUCCESS) mesh_config_model_sub_del_all(node_config_get(node), - ele_addr, vendor ? mod_id : mod_id & 0x0000ffff, + ele_addr, vendor ? id : MODEL_ID(id), vendor); break; @@ -385,22 +381,22 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, grp = UNASSIGNED_ADDRESS; /* Fall Through */ case OP_CONFIG_MODEL_SUB_OVERWRITE: - status = mesh_model_sub_ovr(node, ele_addr, mod_id, + status = mesh_model_sub_ovr(node, ele_addr, id, addr, virt, &grp); if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, mod_id, vendor, addr, + save_config_sub(node, ele_addr, id, vendor, addr, virt, grp, opcode); break; case OP_CONFIG_MODEL_SUB_VIRT_ADD: grp = UNASSIGNED_ADDRESS; /* Fall Through */ case OP_CONFIG_MODEL_SUB_ADD: - status = mesh_model_sub_add(node, ele_addr, mod_id, + status = mesh_model_sub_add(node, ele_addr, id, addr, virt, &grp); if (status == MESH_STATUS_SUCCESS && - !save_config_sub(node, ele_addr, mod_id, vendor, + !save_config_sub(node, ele_addr, id, vendor, addr, virt, grp, opcode)) status = MESH_STATUS_STORAGE_FAIL; @@ -409,17 +405,17 @@ static void config_sub_set(struct mesh_node *node, uint16_t net_idx, grp = UNASSIGNED_ADDRESS; /* Fall Through */ case OP_CONFIG_MODEL_SUB_DELETE: - status = mesh_model_sub_del(node, ele_addr, mod_id, addr, virt, + status = mesh_model_sub_del(node, ele_addr, id, addr, virt, &grp); if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, mod_id, vendor, addr, + save_config_sub(node, ele_addr, id, vendor, addr, virt, grp, opcode); break; } - send_sub_status(node, net_idx, src, dst, status, ele_addr, grp, mod_id); + send_sub_status(node, net_idx, src, dst, status, ele_addr, grp, id); } static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, @@ -434,11 +430,13 @@ static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, n += 2; l_put_le16(idx, msg + n); n += 2; - if (id >= 0x10000 && id < VENDOR_ID_MASK) { - l_put_le16(id >> 16, msg + n); + + if (IS_VENDOR(id)) { + l_put_le16(VENDOR_ID(id), msg + n); n += 2; } - l_put_le16(id, msg + n); + + l_put_le16(MODEL_ID(id), msg + n); n += 2; mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, @@ -450,7 +448,7 @@ static void model_app_list(struct mesh_node *node, uint16_t net_idx, const uint8_t *pkt, uint16_t size) { uint16_t ele_addr; - uint32_t mod_id = 0xffff; + uint32_t id; uint8_t *status; uint16_t n; int result; @@ -463,27 +461,25 @@ static void model_app_list(struct mesh_node *node, uint16_t net_idx, case 4: n = mesh_model_opcode_set(OP_MODEL_APP_LIST, msg); status = msg + n; - mod_id = l_get_le16(pkt + 2); + id = l_get_le16(pkt + 2); l_put_le16(ele_addr, msg + 1 + n); - l_put_le16(mod_id, msg + 3 + n); - mod_id |= VENDOR_ID_MASK; + l_put_le16((uint16_t) id, msg + 3 + n); + id = SET_ID(SIG_VENDOR, id); n += 5; break; case 6: n = mesh_model_opcode_set(OP_VEND_MODEL_APP_LIST, msg); status = msg + n; - mod_id = l_get_le16(pkt + 2) << 16; - mod_id |= l_get_le16(pkt + 4); + id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); l_put_le16(ele_addr, msg + 1 + n); - l_put_le16(mod_id >> 16, msg + 3 + n); - l_put_le16(mod_id, msg + 5 + n); + l_put_le16((uint16_t) VENDOR_ID(id), msg + 3 + n); + l_put_le16((uint16_t) MODEL_ID(id), msg + 5 + n); n += 7; break; } - - result = mesh_model_get_bindings(node, ele_addr, mod_id, msg + n, + result = mesh_model_get_bindings(node, ele_addr, id, msg + n, MAX_MSG_LEN - n, &size); n += size; @@ -500,7 +496,7 @@ static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, bool unbind) { uint16_t ele_addr; - uint32_t mod_id; + uint32_t id; uint16_t idx; int result; @@ -509,12 +505,10 @@ static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, return false; case 6: - mod_id = l_get_le16(pkt + 4); - mod_id |= VENDOR_ID_MASK; + id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); break; case 8: - mod_id = l_get_le16(pkt + 4) << 16; - mod_id |= l_get_le16(pkt + 6); + id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); break; } @@ -525,12 +519,12 @@ static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, return false; if (unbind) - result = mesh_model_binding_del(node, ele_addr, mod_id, idx); + result = mesh_model_binding_del(node, ele_addr, id, idx); else - result = mesh_model_binding_add(node, ele_addr, mod_id, idx); + result = mesh_model_binding_add(node, ele_addr, id, idx); send_model_app_status(node, net_idx, src, dst, result, ele_addr, - mod_id, idx); + id, idx); return true; } diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 383fdbf6b..7b6a95807 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -17,8 +17,8 @@ * */ -#define CONFIG_SRV_MODEL (VENDOR_ID_MASK | 0x0000) -#define CONFIG_CLI_MODEL (VENDOR_ID_MASK | 0x0001) +#define CONFIG_SRV_MODEL SET_ID(SIG_VENDOR, 0x0000) +#define CONFIG_CLI_MODEL SET_ID(SIG_VENDOR, 0x0001) /* New List */ #define OP_APPKEY_ADD 0x00 diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 88f715fc1..deb0019f9 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1126,18 +1126,15 @@ static bool parse_models(json_object *jmodels, struct mesh_config_element *ele) if (sscanf(str, "%04x", &id) != 1) goto fail; - id |= VENDOR_ID_MASK; } else if (len == 8) { if (sscanf(str, "%08x", &id) != 1) goto fail; + mod->vendor = true; } else goto fail; mod->id = id; - if (len == 8) - mod->vendor = true; - if (json_object_object_get_ex(jmodel, "bind", &jarray)) { if (json_object_get_type(jarray) != json_type_array || !parse_bindings(jarray, mod)) diff --git a/mesh/model.c b/mesh/model.c index afac6ec69..31197b363 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -2,7 +2,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. + * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * * This library is free software; you can redistribute it and/or @@ -54,7 +54,6 @@ struct mesh_model { bool sub_enabled; bool pub_enabled; uint32_t id; - uint8_t ele_idx; }; struct mesh_virtual { @@ -131,44 +130,42 @@ static bool find_virt_by_label(const void *a, const void *b) static bool match_model_id(const void *a, const void *b) { - const struct mesh_model *model = a; + const struct mesh_model *mod = a; uint32_t id = L_PTR_TO_UINT(b); - return (mesh_model_get_model_id(model) == id); + return (mod->id == id); } -static struct mesh_model *get_model(struct mesh_node *node, uint8_t ele_idx, - uint32_t id, int *status) +static int compare_model_id(const void *a, const void *b, void *user_data) { - struct l_queue *models; - struct mesh_model *model; + const struct mesh_model *mod_a = a; + const struct mesh_model *mod_b = b; - models = node_get_element_models(node, ele_idx, status); - if (!models) { - *status = MESH_STATUS_INVALID_MODEL; - return NULL; - } - - model = l_queue_find(models, match_model_id, L_UINT_TO_PTR(id)); + if (mod_a->id < mod_b->id) + return -1; - *status = (model) ? MESH_STATUS_SUCCESS : MESH_STATUS_INVALID_MODEL; + if (mod_a->id > mod_b->id) + return 1; - return model; + return 0; } -static struct mesh_model *find_model(struct mesh_node *node, uint16_t addr, - uint32_t mod_id, int *status) +static struct mesh_model *get_model(struct mesh_node *node, uint8_t ele_idx, + uint32_t id) { - int ele_idx; - - ele_idx = node_get_element_idx(node, addr); + struct l_queue *mods; + struct mesh_model *mod; - if (ele_idx < 0) { - *status = MESH_STATUS_INVALID_ADDRESS; + mods = node_get_element_models(node, ele_idx); + if (!mods) return NULL; - } - return get_model(node, (uint8_t) ele_idx, mod_id, status); + mod = l_queue_find(mods, match_model_id, L_UINT_TO_PTR(id)); + + if (!mod) + l_debug("Model not found"); + + return mod; } static uint32_t pub_period_to_ms(uint8_t pub_period) @@ -212,15 +209,17 @@ static struct l_dbus_message *create_config_update_msg(struct mesh_node *node, *builder = l_dbus_message_builder_new(msg); - model_id = (uint16_t) id; + model_id = (uint16_t) MODEL_ID(id); l_dbus_message_builder_append_basic(*builder, 'q', &model_id); l_dbus_message_builder_enter_array(*builder, "{sv}"); - if ((id & VENDOR_ID_MASK) != VENDOR_ID_MASK) { - uint16_t vendor = id >> 16; - dbus_append_dict_entry_basic(*builder, "Vendor", "q", &vendor); + if (IS_VENDOR(id)) { + uint16_t vendor_id = (uint16_t) VENDOR_ID(id); + + dbus_append_dict_entry_basic(*builder, "Vendor", "q", + &vendor_id); } return msg; @@ -268,15 +267,14 @@ static void append_dict_uint16_array(struct l_dbus_message_builder *builder, l_dbus_message_builder_leave_dict(builder); } -static void config_update_model_bindings(struct mesh_node *node, +static void cfg_update_mod_bindings(struct mesh_node *node, uint16_t ele_idx, struct mesh_model *mod) { struct l_dbus *dbus = dbus_get_bus(); struct l_dbus_message *msg; struct l_dbus_message_builder *builder; - msg = create_config_update_msg(node, mod->ele_idx, mod->id, - &builder); + msg = create_config_update_msg(node, ele_idx, mod->id, &builder); if (!msg) return; @@ -331,15 +329,14 @@ done: l_dbus_message_builder_leave_dict(builder); } -static void config_update_model_subscriptions(struct mesh_node *node, +static void cfg_update_model_subs(struct mesh_node *node, uint16_t ele_idx, struct mesh_model *mod) { struct l_dbus *dbus = dbus_get_bus(); struct l_dbus_message *msg; struct l_dbus_message_builder *builder; - msg = create_config_update_msg(node, mod->ele_idx, mod->id, - &builder); + msg = create_config_update_msg(node, ele_idx, mod->id, &builder); if (!msg) return; @@ -572,7 +569,8 @@ done: return ret; } -static void remove_pub(struct mesh_node *node, struct mesh_model *mod) +static void remove_pub(struct mesh_node *node, uint16_t ele_idx, + struct mesh_model *mod) { if (mod->pub) { if (mod->pub->virt) @@ -584,31 +582,31 @@ static void remove_pub(struct mesh_node *node, struct mesh_model *mod) if (!mod->cbs) /* External models */ - config_update_model_pub_period(node, mod->ele_idx, mod->id, 0); + config_update_model_pub_period(node, ele_idx, mod->id, 0); else if (mod->cbs && mod->cbs->pub) /* Internal models */ mod->cbs->pub(NULL); } -static void model_unbind_idx(struct mesh_node *node, struct mesh_model *mod, - uint16_t idx) +static void model_unbind_idx(struct mesh_node *node, uint16_t ele_idx, + struct mesh_model *mod, uint16_t idx) { l_queue_remove(mod->bindings, L_UINT_TO_PTR(idx)); if (!mod->cbs) /* External model */ - config_update_model_bindings(node, mod); + cfg_update_mod_bindings(node, ele_idx, mod); else if (mod->cbs->bind) /* Internal model */ mod->cbs->bind(idx, ACTION_DELETE); /* Remove model publication if the publication key is unbound */ if (mod->pub && idx == mod->pub->idx) - remove_pub(node, mod); + remove_pub(node, ele_idx, mod); } -static void model_bind_idx(struct mesh_node *node, struct mesh_model *mod, - uint16_t idx) +static void model_bind_idx(struct mesh_node *node, uint16_t ele_idx, + struct mesh_model *mod, uint16_t idx) { if (!mod->bindings) mod->bindings = l_queue_new(); @@ -619,7 +617,7 @@ static void model_bind_idx(struct mesh_node *node, struct mesh_model *mod, if (!mod->cbs) /* External model */ - config_update_model_bindings(node, mod); + cfg_update_mod_bindings(node, ele_idx, mod); else if (mod->cbs->bind) /* Internal model */ mod->cbs->bind(idx, ACTION_ADD); @@ -628,19 +626,18 @@ static void model_bind_idx(struct mesh_node *node, struct mesh_model *mod, static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, uint16_t app_idx, bool unbind) { - int status; struct mesh_model *mod; - bool is_present, is_vendor; + bool is_present; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) { - l_debug("Model not found"); - return status; + return MESH_STATUS_INVALID_MODEL; } - is_vendor = id < VENDOR_ID_MASK && id > 0xffff; - id = !is_vendor ? (id & 0xffff) : id; - if (id == CONFIG_SRV_MODEL || id == CONFIG_CLI_MODEL) return MESH_STATUS_INVALID_MODEL; @@ -656,9 +653,10 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; if (unbind) { - model_unbind_idx(node, mod, app_idx); + model_unbind_idx(node, ele_idx, mod, app_idx); if (!mesh_config_model_binding_del(node_config_get(node), - addr, is_vendor, id, app_idx)) + addr, IS_VENDOR(id), + id, app_idx)) return MESH_STATUS_STORAGE_FAIL; l_debug("Unbind key %4.4x to model %8.8x", app_idx, mod->id); @@ -668,11 +666,11 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, if (l_queue_length(mod->bindings) >= MAX_BINDINGS) return MESH_STATUS_INSUFF_RESOURCES; - if (!mesh_config_model_binding_add(node_config_get(node), - addr, is_vendor, id, app_idx)) + if (!mesh_config_model_binding_add(node_config_get(node), addr, + IS_VENDOR(id), id, app_idx)) return MESH_STATUS_STORAGE_FAIL; - model_bind_idx(node, mod, app_idx); + model_bind_idx(node, ele_idx, mod, app_idx); return MESH_STATUS_SUCCESS; @@ -964,7 +962,6 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, is_subscription = !(IS_UNICAST(dst)); - for (i = 0; i < num_ele; i++) { struct l_queue *models; @@ -974,7 +971,7 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, forward.unicast = addr + i; forward.has_dst = false; - models = node_get_element_models(node, i, NULL); + models = node_get_element_models(node, i); /* Internal models */ l_queue_foreach(models, forward_model, &forward); @@ -1023,16 +1020,15 @@ done: return result; } -int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, - uint16_t src, uint8_t ttl, - const void *msg, uint16_t msg_len) +int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, + uint8_t ttl, const void *msg, uint16_t msg_len) { struct mesh_net *net = node_get_net(node); struct mesh_model *mod; uint8_t *label = NULL; uint16_t net_idx; bool result; - int status; + int ele_idx; if (!net || msg_len > 380) return MESH_ERROR_INVALID_ARGS; @@ -1041,14 +1037,16 @@ int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, if (src == 0) src = mesh_net_get_address(net); - mod = find_model(node, src, mod_id, &status); - if (!mod) { - l_debug("model %x not found", mod_id); + ele_idx = node_get_element_idx(node, src); + if (ele_idx < 0) + return MESH_ERROR_NOT_FOUND; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) return MESH_ERROR_NOT_FOUND; - } if (!mod->pub) { - l_debug("publication doesn't exist (model %x)", mod_id); + l_debug("publication doesn't exist (model %x)", id); return MESH_ERROR_DOES_NOT_EXIST; } @@ -1093,11 +1091,14 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, bool is_virt, uint16_t *dst) { struct mesh_model *mod; - int status; + int status, ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->pub_enabled || (mod->cbs && !(mod->cbs->pub))) return MESH_STATUS_INVALID_PUB_PARAM; @@ -1110,7 +1111,7 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, * remove the publication */ if (!is_virt && IS_UNASSIGNED(l_get_le16(pub_addr))) { - remove_pub(node, mod); + remove_pub(node, ele_idx, mod); return MESH_STATUS_SUCCESS; } @@ -1134,7 +1135,7 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External model */ - config_update_model_pub_period(node, mod->ele_idx, id, + config_update_model_pub_period(node, ele_idx, id, pub_period_to_ms(period)); else { /* Internal model, call registered callbacks */ @@ -1149,10 +1150,18 @@ struct mesh_model_pub *mesh_model_pub_get(struct mesh_node *node, uint16_t addr, uint32_t mod_id, int *status) { struct mesh_model *mod; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, mod_id, status); - if (!mod) + if (ele_idx < 0) { + *status = MESH_STATUS_INVALID_ADDRESS; + return NULL; + } + + mod = get_model(node, (uint8_t) ele_idx, mod_id); + if (!mod) { + *status = MESH_STATUS_INVALID_MODEL; return NULL; + } if (!mod->pub_enabled || (mod->cbs && !(mod->cbs->pub))) *status = MESH_STATUS_INVALID_PUB_PARAM; @@ -1173,12 +1182,25 @@ void mesh_model_free(void *data) l_free(mod); } -struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t id) +static void remove_subs(struct mesh_node *node, struct mesh_model *mod) +{ + const struct l_queue_entry *entry; + struct mesh_net *net = node_get_net(node); + + entry = l_queue_get_entries(mod->subs); + + for (; entry; entry = entry->next) + mesh_net_dst_unreg(net, (uint16_t) L_PTR_TO_UINT(entry->data)); + + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); +} + +static struct mesh_model *model_new(uint32_t id) { struct mesh_model *mod = l_new(struct mesh_model, 1); mod->id = id; - mod->ele_idx = ele_idx; mod->virtuals = l_queue_new(); /* @@ -1190,6 +1212,75 @@ struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t id) return mod; } +static void model_enable_pub(struct mesh_model *mod, bool enable) +{ + mod->pub_enabled = enable; + + if (!mod->pub_enabled && mod->pub) { + if (mod->pub->virt) + unref_virt(mod->pub->virt); + + l_free(mod->pub); + mod->pub = NULL; + } +} + +static void model_enable_sub(struct mesh_node *node, struct mesh_model *mod, + bool enable) +{ + mod->sub_enabled = enable; + + if (!mod->sub_enabled) + remove_subs(node, mod); +} + +static bool get_model_options(struct mesh_model *mod, + struct l_dbus_message_iter *opts) +{ + const char *key; + struct l_dbus_message_iter var; + bool opt; + + while (l_dbus_message_iter_next_entry(opts, &key, &var)) { + + if (!strcmp(key, "Publish")) { + if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) + return false; + + mod->pub_enabled = opt; + } else if (!strcmp(key, "Subscribe")) { + if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) + return false; + + mod->sub_enabled = opt; + } else + return false; + } + + return true; +} + +bool mesh_model_add(struct mesh_node *node, struct l_queue *mods, + uint32_t id, struct l_dbus_message_iter *opts) +{ + struct mesh_model *mod; + + /* Disallow duplicates */ + mod = l_queue_find(mods, match_model_id, L_UINT_TO_PTR(id)); + if (mod) + return false; + + mod = model_new(id); + + if (opts && !get_model_options(mod, opts)) { + mesh_model_free(mod); + return false; + } + + l_queue_insert(mods, mod, compare_model_id, NULL); + return true; +} + /* Internal models only */ static void restore_model_state(struct mesh_model *mod) { @@ -1213,26 +1304,16 @@ static void restore_model_state(struct mesh_model *mod) } -uint32_t mesh_model_get_model_id(const struct mesh_model *model) -{ - return model->id; -} - /* This registers an internal model, i.e. implemented within meshd */ -bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, - uint32_t mod_id, +bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, uint32_t id, const struct mesh_model_ops *cbs, void *user_data) { struct mesh_model *mod; - int status; - - /* Internal models are always SIG models */ - mod_id = VENDOR_ID_MASK | mod_id; - mod = get_model(node, ele_idx, mod_id, &status); + mod = get_model(node, ele_idx, id); if (!mod) - return false; + return MESH_STATUS_INVALID_MODEL; mod->cbs = cbs; mod->user_data = user_data; @@ -1242,15 +1323,15 @@ bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, return true; } -void mesh_model_app_key_delete(struct mesh_node *node, struct l_queue *models, - uint16_t app_idx) +void mesh_model_app_key_delete(struct mesh_node *node, uint16_t ele_idx, + struct l_queue *models, uint16_t app_idx) { const struct l_queue_entry *entry = l_queue_get_entries(models); for (; entry; entry = entry->next) { - struct mesh_model *model = entry->data; + struct mesh_model *mod = entry->data; - model_unbind_idx(node, model, app_idx); + model_unbind_idx(node, ele_idx, mod, app_idx); } } @@ -1269,18 +1350,20 @@ int mesh_model_binding_add(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_get_bindings(struct mesh_node *node, uint16_t addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size) { - int status; struct mesh_model *mod; const struct l_queue_entry *entry; uint16_t n; uint32_t idx_pair; - int i; + int i, ele_idx = node_get_element_idx(node, addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; - mod = find_model(node, addr, id, &status); + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) { *size = 0; - return status; + return MESH_STATUS_INVALID_MODEL; } entry = l_queue_get_entries(mod->bindings); @@ -1325,14 +1408,17 @@ done: int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size) { - int status; int16_t n; struct mesh_model *mod; const struct l_queue_entry *entry; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1370,12 +1456,15 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *group, bool is_virt, uint16_t *dst) { - int status; struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; - mod = find_model(node, addr, id, &status); + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1387,7 +1476,7 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); return MESH_STATUS_SUCCESS; } @@ -1395,13 +1484,16 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *group, bool is_virt, uint16_t *dst) { - int status; struct l_queue *virtuals, *subs; struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; - mod = find_model(node, addr, id, &status); + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1439,7 +1531,7 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); return status; } @@ -1447,13 +1539,16 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *group, bool is_virt, uint16_t *dst) { - int status; uint16_t grp; struct mesh_model *mod; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1481,34 +1576,23 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); } return MESH_STATUS_SUCCESS; } -static void remove_subs(struct mesh_node *node, struct mesh_model *mod) -{ - const struct l_queue_entry *entry; - struct mesh_net *net = node_get_net(node); - - entry = l_queue_get_entries(mod->subs); - - for (; entry; entry = entry->next) - mesh_net_dst_unreg(net, (uint16_t) L_PTR_TO_UINT(entry->data)); - - l_queue_clear(mod->subs, NULL); - l_queue_clear(mod->virtuals, unref_virt); -} - int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) { - int status; struct mesh_model *mod; + int ele_idx = node_get_element_idx(node, addr); - mod = find_model(node, addr, id, &status); + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); if (!mod) - return status; + return MESH_STATUS_INVALID_MODEL; if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; @@ -1517,17 +1601,15 @@ int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) if (!mod->cbs) /* External models */ - config_update_model_subscriptions(node, mod); + cfg_update_model_subs(node, ele_idx, mod); return MESH_STATUS_SUCCESS; } -struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, - void *data) +static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, + struct mesh_config_model *db_mod) { - struct mesh_config_model *db_mod = data; struct mesh_model *mod; - struct mesh_net *net; struct mesh_config_pub *pub = db_mod->pub; uint32_t i; @@ -1537,8 +1619,8 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return NULL; } - mod = mesh_model_new(ele_idx, db_mod->vendor ? db_mod->id : - db_mod->id | VENDOR_ID_MASK); + mod = model_new(db_mod->vendor ? db_mod->id : + SET_ID(SIG_VENDOR, db_mod->id)); /* Implicitly bind config server model to device key */ if (db_mod->id == CONFIG_SRV_MODEL) { @@ -1557,17 +1639,18 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return mod; } - net = node_get_net(node); - /* Add application key bindings if present */ if (db_mod->bindings) { mod->bindings = l_queue_new(); for (i = 0; i < db_mod->num_bindings; i++) - model_bind_idx(node, mod, db_mod->bindings[i]); + l_queue_push_tail(mod->bindings, + L_UINT_TO_PTR(db_mod->bindings[i])); } - /* Add publication if present */ - if (pub) { + mod->pub_enabled = db_mod->pub_enabled; + + /* Add publication if enabled and present */ + if (mod->pub_enabled && pub) { uint8_t retransmit = pub->count + ((pub->interval / 50 - 1) << 3); if (pub->virt) @@ -1579,8 +1662,10 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, pub->ttl, pub->period, retransmit); } - /* Add subscriptions if present */ - if (!db_mod->subs) + mod->sub_enabled = db_mod->sub_enabled; + + /* Add subscriptions if enabled and present */ + if (!db_mod->subs || !mod->sub_enabled) return mod; for (i = 0; i < db_mod->num_subs; i++) { @@ -1605,6 +1690,60 @@ struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, return mod; } +bool mesh_model_add_from_storage(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *mods, struct l_queue *db_mods) +{ + struct mesh_net *net = node_get_net(node); + const struct l_queue_entry *entry; + + /* Allow empty elements */ + if (!db_mods) + return true; + + entry = l_queue_get_entries(db_mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod; + struct mesh_config_model *db_mod; + uint32_t id; + + db_mod = entry->data; + + id = db_mod->vendor ? db_mod->id : + SET_ID(SIG_VENDOR, db_mod->id); + + if (l_queue_find(mods, match_model_id, L_UINT_TO_PTR(id))) + return false; + + mod = model_setup(net, ele_idx, db_mod); + if (!mod) + return false; + + l_queue_insert(mods, mod, compare_model_id, NULL); + } + + return true; +} + +void mesh_model_convert_to_storage(struct l_queue *db_mods, + struct l_queue *mods) +{ + + const struct l_queue_entry *entry = l_queue_get_entries(mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + struct mesh_config_model *db_mod; + + db_mod = l_new(struct mesh_config_model, 1); + db_mod->id = mod->id; + db_mod->vendor = IS_VENDOR(mod->id); + db_mod->pub_enabled = mod->pub_enabled; + db_mod->sub_enabled = mod->sub_enabled; + l_queue_push_tail(db_mods, db_mod); + } +} + uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf) { if (opcode <= 0x7e) { @@ -1669,7 +1808,7 @@ bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, return true; } -void model_build_config(void *model, void *msg_builder) +void mesh_model_build_config(void *model, void *msg_builder) { struct l_dbus_message_builder *builder = msg_builder; struct mesh_model *mod = model; @@ -1685,14 +1824,14 @@ void model_build_config(void *model, void *msg_builder) l_dbus_message_builder_enter_struct(builder, "qa{sv}"); /* Model id */ - id = mod->id & 0xffff; + id = MODEL_ID(mod->id); l_dbus_message_builder_append_basic(builder, 'q', &id); l_dbus_message_builder_enter_array(builder, "{sv}"); /* For vendor models, add vendor id */ - if ((mod->id & VENDOR_ID_MASK) != VENDOR_ID_MASK) { - uint16_t vendor = mod->id >> 16; + if (IS_VENDOR(mod->id)) { + uint16_t vendor = VENDOR_ID(mod->id); dbus_append_dict_entry_basic(builder, "Vendor", "q", &vendor); } @@ -1715,36 +1854,101 @@ void model_build_config(void *model, void *msg_builder) l_dbus_message_builder_leave_struct(builder); } -void mesh_model_enable_pub(struct mesh_model *mod, bool enable) +void mesh_model_update_opts(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *curr, struct l_queue *updated) { - mod->pub_enabled = enable; + uint16_t primary; + const struct l_queue_entry *entry; - if (!mod->pub_enabled && mod->pub) { - if (mod->pub->virt) - unref_virt(mod->pub->virt); + primary = node_get_primary(node); + entry = l_queue_get_entries(curr); - l_free(mod->pub); - mod->pub = NULL; - } -} + for (; entry; entry = entry->next) { + struct mesh_model *mod, *updated_mod = entry->data; + uint32_t id = updated_mod->id; + bool updated_opt, vendor = IS_VENDOR(id); -bool mesh_model_is_pub_enabled(struct mesh_model *mod) -{ - return mod->pub_enabled; -} + mod = l_queue_find(curr, match_model_id, L_UINT_TO_PTR(id)); + if (!mod) + continue; -void mesh_model_enable_sub(struct mesh_node *node, struct mesh_model *mod, - bool enable) -{ - mod->sub_enabled = enable; + if (!vendor) + id = MODEL_ID(id); - if (!mod->sub_enabled) - remove_subs(node, mod); + updated_opt = updated_mod->pub_enabled; + if (mod->pub_enabled != updated_opt) { + model_enable_pub(mod, updated_opt); + mesh_config_model_pub_enable(node_config_get(node), + primary + ele_idx, id, + vendor, updated_opt); + } + + updated_opt = updated_mod->sub_enabled; + + if (mod->pub_enabled != updated_opt) { + model_enable_sub(node, mod, updated_opt); + mesh_config_model_sub_enable(node_config_get(node), + primary + ele_idx, id, + vendor, updated_opt); + } + } } -bool mesh_model_is_sub_enabled(struct mesh_model *mod) +/* Populate composition buffer with model IDs */ +uint16_t mesh_model_generate_composition(struct l_queue *mods, uint16_t buf_sz, + uint8_t *buf) { - return mod->sub_enabled; + const struct l_queue_entry *entry; + uint8_t num_s = 0, num_v = 0; + uint8_t *mod_buf; + uint16_t n; + + /* Store models IDs, store num_s and num_v later */ + mod_buf = buf; + n = 2; + + entry = l_queue_get_entries(mods); + + /* Get SIG models */ + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + + if (n + 2 > buf_sz) + goto done; + + if (IS_VENDOR(mod->id)) + continue; + + l_put_le16((uint16_t) (MODEL_ID(mod->id)), buf + n); + n += 2; + num_s++; + } + + /* Get vendor models */ + entry = l_queue_get_entries(mods); + + for (; entry; entry = entry->next) { + struct mesh_model *mod = entry->data; + uint16_t vendor_id; + + if (n + 4 > buf_sz) + goto done; + + if (!IS_VENDOR(mod->id)) + continue; + + vendor_id = (uint16_t) (VENDOR_ID(mod->id)); + l_put_le16(vendor_id, buf + n); + n += 2; + l_put_le16((uint16_t) (MODEL_ID(mod->id)), buf + n); + n += 2; + num_v++; + } + +done: + mod_buf[0] = num_s; + mod_buf[1] = num_v; + return n; } void mesh_model_init(void) diff --git a/mesh/model.h b/mesh/model.h index 0377d3fdd..0d8dddf92 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -2,7 +2,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright (C) 2018 Intel Corporation. All rights reserved. + * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * * This library is free software; you can redistribute it and/or @@ -22,14 +22,17 @@ struct mesh_model; #define MAX_BINDINGS 10 #define MAX_GRP_PER_MOD 10 -#define OP_MODEL_TEST 0x8000fffe -#define OP_MODEL_INVALID 0x8000ffff +#define ACTION_ADD 1 +#define ACTION_UPDATE 2 +#define ACTION_DELETE 3 -#define USE_PUB_VALUE 0x00 +/* For internal representation of SIG defined models */ +#define SIG_VENDOR 0xFFFF -#define ACTION_ADD 1 -#define ACTION_UPDATE 2 -#define ACTION_DELETE 3 +#define IS_VENDOR(x) ((x) < ((uint32_t)(SIG_VENDOR) << 16)) +#define SET_ID(v, m) ((((uint32_t) (v)) << 16) | (m)) +#define MODEL_ID(x) ((x) & ~VENDOR_ID_MASK) +#define VENDOR_ID(x) ((x) >> 16) struct mesh_virtual; @@ -60,61 +63,62 @@ struct mesh_model_ops { mesh_model_sub_cb sub; }; -struct mesh_model *mesh_model_new(uint8_t ele_idx, uint32_t mod_id); +bool mesh_model_add(struct mesh_node *node, struct l_queue *mods, + uint32_t id, struct l_dbus_message_iter *opts); void mesh_model_free(void *data); -uint32_t mesh_model_get_model_id(const struct mesh_model *model); bool mesh_model_register(struct mesh_node *node, uint8_t ele_idx, - uint32_t mod_id, const struct mesh_model_ops *cbs, + uint32_t id, const struct mesh_model_ops *cbs, void *user_data); -struct mesh_model *mesh_model_setup(struct mesh_node *node, uint8_t ele_idx, - void *data); +bool mesh_model_add_from_storage(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *mods, struct l_queue *db_mods); +void mesh_model_convert_to_storage(struct l_queue *db_mods, + struct l_queue *mods); struct mesh_model_pub *mesh_model_pub_get(struct mesh_node *node, - uint16_t addr, uint32_t mod_id, int *status); -int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *pub_addr, uint16_t idx, bool cred_flag, + uint16_t ele_addr, + uint32_t id, int *status); +int mesh_model_pub_set(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + const uint8_t *addr, uint16_t idx, bool cred_flag, uint8_t ttl, uint8_t period, uint8_t retransmit, bool is_virt, uint16_t *dst); -int mesh_model_binding_add(struct mesh_node *node, uint16_t addr, uint32_t id, - uint16_t idx); -int mesh_model_binding_del(struct mesh_node *node, uint16_t addr, uint32_t id, - uint16_t idx); -int mesh_model_get_bindings(struct mesh_node *node, uint16_t addr, uint32_t id, - uint8_t *buf, uint16_t buf_len, uint16_t *size); -int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, +int mesh_model_binding_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, uint16_t idx); +int mesh_model_binding_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, uint16_t idx); +int mesh_model_get_bindings(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, uint8_t *buf, uint16_t buf_sz, + uint16_t *len); +int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, const uint8_t *grp, bool b_virt, uint16_t *dst); -int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, +int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, const uint8_t *grp, bool b_virt, uint16_t *dst); int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id); int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *grp, bool b_virt, uint16_t *dst); -int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, +int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size); uint16_t mesh_model_cfg_blk(uint8_t *pkt); bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, uint8_t ttl, bool segmented, const void *msg, uint16_t msg_len); -int mesh_model_publish(struct mesh_node *node, uint32_t mod_id, uint16_t src, +int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, uint8_t ttl, const void *msg, uint16_t msg_len); bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, uint32_t seq, uint32_t iv_index, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t key_aid, const uint8_t *data, uint16_t size); void mesh_model_app_key_generate_new(struct mesh_node *node, uint16_t net_idx); -void mesh_model_app_key_delete(struct mesh_node *node, struct l_queue *models, - uint16_t idx); +void mesh_model_app_key_delete(struct mesh_node *node, uint16_t ele_idx, + struct l_queue *models, uint16_t app_idx); struct l_queue *mesh_model_get_appkeys(struct mesh_node *node); uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf); bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, uint32_t *opcode, uint16_t *n); -void model_build_config(void *model, void *msg_builder); - -void mesh_model_enable_pub(struct mesh_model *mod, bool enable); -bool mesh_model_is_pub_enabled(struct mesh_model *mod); -void mesh_model_enable_sub(struct mesh_node *node, struct mesh_model *mod, - bool enable); -bool mesh_model_is_sub_enabled(struct mesh_model *mod); - +void mesh_model_build_config(void *model, void *msg_builder); +void mesh_model_update_opts(struct mesh_node *node, uint8_t ele_idx, + struct l_queue *curr, struct l_queue *updated); +uint16_t mesh_model_generate_composition(struct l_queue *mods, uint16_t buf_sz, + uint8_t *buf); void mesh_model_init(void); void mesh_model_cleanup(void); diff --git a/mesh/node.c b/mesh/node.c index 9b97aa927..3dca73cef 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -2,7 +2,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright (C) 2017-2019 Intel Corporation. All rights reserved. + * Copyright (C) 2017-2020 Intel Corporation. All rights reserved. * * * This library is free software; you can redistribute it and/or @@ -186,28 +186,6 @@ static bool match_element_path(const void *a, const void *b) return (!strcmp(element->path, path)); } -static bool match_model_id(const void *a, const void *b) -{ - const struct mesh_model *mod = a; - uint32_t mod_id = L_PTR_TO_UINT(b); - - return mesh_model_get_model_id(mod) == mod_id; -} - -static int compare_model_id(const void *a, const void *b, void *user_data) -{ - uint32_t a_id = mesh_model_get_model_id(a); - uint32_t b_id = mesh_model_get_model_id(b); - - if (a_id < b_id) - return -1; - - if (a_id > b_id) - return 1; - - return 0; -} - struct mesh_node *node_find_by_uuid(uint8_t uuid[16]) { return l_queue_find(nodes, match_device_uuid, uuid); @@ -225,25 +203,6 @@ uint8_t *node_uuid_get(struct mesh_node *node) return node->uuid; } -static void add_internal_model(struct mesh_node *node, uint32_t mod_id, - uint8_t ele_idx) -{ - struct node_element *ele; - struct mesh_model *mod; - - ele = l_queue_find(node->elements, match_element_idx, - L_UINT_TO_PTR(ele_idx)); - if (!ele) - return; - - if (l_queue_find(ele->models, match_model_id, L_UINT_TO_PTR(mod_id))) - return; - - mod = mesh_model_new(ele_idx, mod_id); - - l_queue_insert(ele->models, mod, compare_model_id, NULL); -} - static void set_defaults(struct mesh_node *node) { node->lpn = MESH_MODE_UNSUPPORTED; @@ -359,46 +318,6 @@ void node_remove(struct mesh_node *node) free_node_resources(node); } -static bool add_models_from_storage(struct mesh_node *node, - struct node_element *ele, - struct mesh_config_element *db_ele) -{ - const struct l_queue_entry *entry; - - if (!ele->models) - ele->models = l_queue_new(); - - entry = l_queue_get_entries(db_ele->models); - - for (; entry; entry = entry->next) { - struct mesh_model *mod; - struct mesh_config_model *db_mod; - uint32_t id; - - db_mod = entry->data; - - id = db_mod->vendor ? db_mod->id : db_mod->id | VENDOR_ID_MASK; - - if (l_queue_find(ele->models, match_model_id, - L_UINT_TO_PTR(id))) - return false; - - mod = mesh_model_setup(node, ele->idx, db_mod); - if (!mod) - return false; - - if (!db_mod->pub_enabled) - mesh_model_enable_pub(mod, false); - - if (!db_mod->sub_enabled) - mesh_model_enable_sub(node, mod, false); - - l_queue_insert(ele->models, mod, compare_model_id, NULL); - } - - return true; -} - static bool add_element_from_storage(struct mesh_node *node, struct mesh_config_element *db_ele) { @@ -411,7 +330,12 @@ static bool add_element_from_storage(struct mesh_node *node, ele->idx = db_ele->index; ele->location = db_ele->location; - if (!db_ele->models || !add_models_from_storage(node, ele, db_ele)) + + if (!ele->models) + ele->models = l_queue_new(); + + if (!mesh_model_add_from_storage(node, ele->idx, ele->models, + db_ele->models)) return false; l_queue_push_tail(node->elements, ele); @@ -424,12 +348,13 @@ static bool add_elements_from_storage(struct mesh_node *node, const struct l_queue_entry *entry; entry = l_queue_get_entries(db_node->elements); + for (; entry; entry = entry->next) if (!add_element_from_storage(node, entry->data)) return false; /* Add configuration server model on the primary element */ - add_internal_model(node, CONFIG_SRV_MODEL, PRIMARY_ELE_IDX); + mesh_model_add(node, PRIMARY_ELE_IDX, CONFIG_SRV_MODEL, NULL); return true; } @@ -628,7 +553,7 @@ void node_app_key_delete(struct mesh_node *node, uint16_t net_idx, for (; entry; entry = entry->next) { struct node_element *ele = entry->data; - mesh_model_app_key_delete(node, ele->models, app_idx); + mesh_model_app_key_delete(node, ele->idx, ele->models, app_idx); } } @@ -666,27 +591,17 @@ uint8_t node_get_num_elements(struct mesh_node *node) return node->num_ele; } -struct l_queue *node_get_element_models(struct mesh_node *node, - uint8_t ele_idx, int *status) +struct l_queue *node_get_element_models(struct mesh_node *node, uint8_t ele_idx) { struct node_element *ele; - if (!node) { - if (status) - *status = MESH_STATUS_INVALID_ADDRESS; + if (!node) return NULL; - } ele = l_queue_find(node->elements, match_element_idx, L_UINT_TO_PTR(ele_idx)); - if (!ele) { - if (status) - *status = MESH_STATUS_INVALID_ADDRESS; + if (!ele) return NULL; - } - - if (status) - *status = MESH_STATUS_SUCCESS; return ele->models; } @@ -888,9 +803,8 @@ uint8_t node_friend_mode_get(struct mesh_node *node) static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz) { - uint16_t n, features; - uint16_t num_ele = 0; - const struct l_queue_entry *ele_entry; + uint16_t n, features, num_ele = 0; + const struct l_queue_entry *entry; if (!node || sz < MIN_COMP_SIZE) return 0; @@ -920,12 +834,10 @@ static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, l_put_le16(features, buf + n); n += 2; - ele_entry = l_queue_get_entries(node->elements); - for (; ele_entry; ele_entry = ele_entry->next) { - struct node_element *ele = ele_entry->data; - const struct l_queue_entry *mod_entry; - uint8_t num_s = 0, num_v = 0; - uint8_t *mod_buf; + entry = l_queue_get_entries(node->elements); + + for (; entry; entry = entry->next) { + struct node_element *ele = entry->data; if (ele->idx != num_ele) return 0; @@ -939,59 +851,8 @@ static uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, l_put_le16(ele->location, buf + n); n += 2; - /* Store models IDs, store num_s and num_v later */ - mod_buf = buf + n; - n += 2; - - /* Get SIG models */ - mod_entry = l_queue_get_entries(ele->models); - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - uint32_t mod_id; - - mod_id = mesh_model_get_model_id( - (const struct mesh_model *) mod); - - if ((mod_id & VENDOR_ID_MASK) == VENDOR_ID_MASK) { - if (n + 2 > sz) - goto element_done; - - l_put_le16((uint16_t) (mod_id & 0xffff), - buf + n); - n += 2; - num_s++; - } - } - - /* Get vendor models */ - mod_entry = l_queue_get_entries(ele->models); - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - uint32_t mod_id; - uint16_t vendor; - - mod_id = mesh_model_get_model_id( - (const struct mesh_model *) mod); - - vendor = (uint16_t) (mod_id >> 16); - if (vendor != 0xffff) { - if (n + 4 > sz) - goto element_done; - - l_put_le16(vendor, buf + n); - n += 2; - l_put_le16((uint16_t) (mod_id & 0xffff), + n += mesh_model_generate_composition(ele->models, sz - n, buf + n); - n += 2; - num_v++; - } - - } - -element_done: - mod_buf[0] = num_s; - mod_buf[1] = num_v; - } if (!num_ele) @@ -1128,52 +989,6 @@ static void app_disc_cb(struct l_dbus *bus, void *user_data) free_node_dbus_resources(node); } -static bool get_model_options(struct mesh_node *node, struct mesh_model *mod, - struct l_dbus_message_iter *opts) -{ - const char *key; - struct l_dbus_message_iter var; - bool opt; - - while (l_dbus_message_iter_next_entry(opts, &key, &var)) { - - if (!strcmp(key, "Publish")) { - if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) - return false; - mesh_model_enable_pub(mod, opt); - } else if (!strcmp(key, "Subscribe")) { - if (!l_dbus_message_iter_get_variant(&var, "b", &opt)) - return false; - mesh_model_enable_sub(node, mod, opt); - } else - return false; - } - - return true; -} - -static bool generate_model(struct mesh_node *node, struct node_element *ele, - uint32_t id, struct l_dbus_message_iter *opts) -{ - struct mesh_model *mod; - - /* Disallow duplicates */ - if (l_queue_find(ele->models, match_model_id, - L_UINT_TO_PTR(id))) - return false; - - mod = mesh_model_new(ele->idx, id); - - if (!get_model_options(node, mod, opts)) { - l_free(mod); - return false; - } - - l_queue_insert(ele->models, mod, compare_model_id, NULL); - - return true; -} - static bool get_sig_models_from_properties(struct mesh_node *node, struct node_element *ele, struct l_dbus_message_iter *property) @@ -1189,13 +1004,13 @@ static bool get_sig_models_from_properties(struct mesh_node *node, /* Bluetooth SIG defined models */ while (l_dbus_message_iter_next_entry(&mods, &m_id, &var)) { - uint32_t id = m_id | VENDOR_ID_MASK; + uint32_t id = SET_ID(SIG_VENDOR, m_id); /* Allow Config Server Model only on the primary element */ if (ele->idx != PRIMARY_ELE_IDX && id == CONFIG_SRV_MODEL) return false; - if (!generate_model(node, ele, id, &var)) + if (!mesh_model_add(node, ele->models, id, &var)) return false; } @@ -1217,9 +1032,9 @@ static bool get_vendor_models_from_properties(struct mesh_node *node, /* Vendor defined models */ while (l_dbus_message_iter_next_entry(&mods, &v_id, &m_id, &var)) { - uint32_t id = m_id | (v_id << 16); + uint32_t id = SET_ID(v_id, m_id); - if (!generate_model(node, ele, id, &var)) + if (!mesh_model_add(node, ele->models, id, &var)) return false; } @@ -1295,7 +1110,7 @@ static bool get_element_properties(struct mesh_node *node, const char *path, * the operation below will be a "no-op". */ if (ele->idx == PRIMARY_ELE_IDX) - add_internal_model(node, CONFIG_SRV_MODEL, PRIMARY_ELE_IDX); + mesh_model_add(node, ele->models, CONFIG_SRV_MODEL, NULL); return true; fail: @@ -1332,7 +1147,6 @@ static void convert_node_to_storage(struct mesh_node *node, for (; entry; entry = entry->next) { struct node_element *ele = entry->data; struct mesh_config_element *db_ele; - const struct l_queue_entry *mod_entry; db_ele = l_new(struct mesh_config_element, 1); @@ -1340,21 +1154,8 @@ static void convert_node_to_storage(struct mesh_node *node, db_ele->location = ele->location; db_ele->models = l_queue_new(); - mod_entry = l_queue_get_entries(ele->models); - - for (; mod_entry; mod_entry = mod_entry->next) { - struct mesh_model *mod = mod_entry->data; - struct mesh_config_model *db_mod; - uint32_t mod_id = mesh_model_get_model_id(mod); + mesh_model_convert_to_storage(db_ele->models, ele->models); - db_mod = l_new(struct mesh_config_model, 1); - db_mod->id = mod_id; - db_mod->vendor = ((mod_id & VENDOR_ID_MASK) - != VENDOR_ID_MASK); - db_mod->pub_enabled = mesh_model_is_pub_enabled(mod); - db_mod->sub_enabled = mesh_model_is_sub_enabled(mod); - l_queue_push_tail(db_ele->models, db_mod); - } l_queue_push_tail(db_node->elements, db_ele); } @@ -1375,6 +1176,7 @@ static bool create_node_config(struct mesh_node *node, const uint8_t uuid[16]) /* Free temporarily allocated resources */ entry = l_queue_get_entries(db_node.elements); + for (; entry; entry = entry->next) { struct mesh_config_element *db_ele = entry->data; @@ -1517,7 +1319,6 @@ static void update_model_options(struct mesh_node *node, len = l_queue_length(node->elements); for (i = 0; i < len; i++) { - const struct l_queue_entry *entry; ele = l_queue_find(node->elements, match_element_idx, L_UINT_TO_PTR(i)); @@ -1526,42 +1327,8 @@ static void update_model_options(struct mesh_node *node, if (!ele || !ele_attach) continue; - entry = l_queue_get_entries(ele->models); - - for (; entry; entry = entry->next) { - struct mesh_model *mod, *updated_mod = entry->data; - uint32_t id = mesh_model_get_model_id(updated_mod); - bool opt, updated_opt; - bool vendor = id < VENDOR_ID_MASK; - - mod = l_queue_find(ele_attach->models, match_model_id, - L_UINT_TO_PTR(id)); - if (!mod) - continue; - - if (!vendor) - id &= ~VENDOR_ID_MASK; - - opt = mesh_model_is_pub_enabled(mod); - updated_opt = mesh_model_is_pub_enabled(updated_mod); - - if (updated_opt != opt) { - mesh_model_enable_pub(mod, updated_opt); - mesh_config_model_pub_enable(attach->cfg, - attach->primary + i, id, - vendor, updated_opt); - } - - opt = mesh_model_is_sub_enabled(mod); - updated_opt = mesh_model_is_sub_enabled(updated_mod); - - if (updated_opt != opt) { - mesh_model_enable_sub(node, mod, updated_opt); - mesh_config_model_sub_enable(attach->cfg, - attach->primary + i, id, - vendor, updated_opt); - } - } + mesh_model_update_opts(node, ele->idx, ele_attach->models, + ele->models); } } @@ -1964,7 +1731,7 @@ static void build_element_config(void *a, void *b) l_dbus_message_builder_enter_array(builder, "(qa{sv})"); /* Iterate over models */ - l_queue_foreach(ele->models, model_build_config, builder); + l_queue_foreach(ele->models, mesh_model_build_config, builder); l_dbus_message_builder_leave_array(builder); @@ -2216,8 +1983,8 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, struct l_dbus_message_iter iter_data; uint16_t mod_id, src; struct node_element *ele; - uint8_t *data; - uint32_t len; + uint8_t *data, ttl; + uint32_t len, id; int result; l_debug("Publish"); @@ -2243,8 +2010,10 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - result = mesh_model_publish(node, VENDOR_ID_MASK | mod_id, src, - mesh_net_get_default_ttl(node->net), data, len); + ttl = mesh_net_get_default_ttl(node->net); + + id = SET_ID(SIG_VENDOR, mod_id); + result = mesh_model_publish(node, id, src, ttl, data, len); if (result != MESH_ERROR_NONE) return dbus_error(msg, result, NULL); @@ -2259,11 +2028,9 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, struct mesh_node *node = user_data; const char *sender, *ele_path; struct l_dbus_message_iter iter_data; - uint16_t src; - uint16_t model_id, vendor; - uint32_t vendor_mod_id; + uint16_t src, mod_id, vendor_id; struct node_element *ele; - uint8_t *data = NULL; + uint8_t ttl, *data = NULL; uint32_t len; int result; @@ -2274,8 +2041,8 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &vendor, - &model_id, &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &vendor_id, + &mod_id, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); ele = l_queue_find(node->elements, match_element_path, ele_path); @@ -2290,9 +2057,9 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - vendor_mod_id = (vendor << 16) | model_id; - result = mesh_model_publish(node, vendor_mod_id, src, - mesh_net_get_default_ttl(node->net), data, len); + ttl = mesh_net_get_default_ttl(node->net); + result = mesh_model_publish(node, SET_ID(vendor_id, mod_id), src, ttl, + data, len); if (result != MESH_ERROR_NONE) return dbus_error(msg, result, NULL); diff --git a/mesh/node.h b/mesh/node.h index df058458a..47c998530 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -58,8 +58,8 @@ bool node_default_ttl_set(struct mesh_node *node, uint8_t ttl); bool node_set_sequence_number(struct mesh_node *node, uint32_t seq); uint32_t node_get_sequence_number(struct mesh_node *node); int node_get_element_idx(struct mesh_node *node, uint16_t ele_addr); -struct l_queue *node_get_element_models(struct mesh_node *node, uint8_t ele_idx, - int *status); +struct l_queue *node_get_element_models(struct mesh_node *node, + uint8_t ele_idx); uint16_t node_get_crpl(struct mesh_node *node); bool node_init_from_storage(struct mesh_node *node, const uint8_t uuid[16], struct mesh_config_node *db_node); -- 2.26.2 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sPaSDIN0Gl/CNgEAvsO+Rg (envelope-from ) for ; Fri, 24 Jul 2020 07:41:23 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SAIPC4N0Gl/N1gAAgupzMw (envelope-from ); Fri, 24 Jul 2020 07:41:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B30624086A; Fri, 24 Jul 2020 07:41:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726607AbgGXFlR (ORCPT + 1 other); Fri, 24 Jul 2020 01:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbgGXFlR (ORCPT ); Fri, 24 Jul 2020 01:41:17 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3B00C0619D3 for ; Thu, 23 Jul 2020 22:41:16 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id g7so449431ejw.12 for ; Thu, 23 Jul 2020 22:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=ni/bslctWqoe3AamxXYjt+xMiBuKfxjdPfgujWLM3fI=; b=wP6ZaW7Ysf9t2w8NQxpKWB3uSs/oKLLZWZhl4pu+NWA6XWzbsAdTx9RUiPKx1axfDR Uy25g8hnPQpALpnXgXG6Mot68vVIxSYyncvM3RzIqJXJEEtt59yNjYdgYgD0G9HRICic VlGhIUC+NAtdhxl3NsujuwcfLZKQTgWjrHfvrPy9XMMDSld7FWgr/jVyBgYrrpxi101/ 6mPA6iTqEP/bz23KIDtvjkHRm/u7IXOfE6AdQytZ5STPr4gn0EFT+q0gYeGNGgCjGhsN 4ErO6AJS/Q24kMDk/Hp7pSc0StbWNiUL30A0W7l1qdLC3etHaW/zgUoqWiR2P2pGl5xZ fP/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=ni/bslctWqoe3AamxXYjt+xMiBuKfxjdPfgujWLM3fI=; b=ED0jUS6eeYEGlYmeYA9rrN+aaaosjtlKGSc0P0oK9ytuHARRW/Q1JbpffPDn0KdwqW xzNKsLz5z1jJD6IXmt8p2vwwT1PMjoJDOIX9gKZ2EWaR5iqcTgi4it+ADGcsxromsbg0 /t6SNI4NOMDDqgLy9lz4QxLhh3A0Sf52pFrreWwiibUOk6U8wEoZ/jBpfaJVPSVqsihm zWIDVkeBqZecq9rTlOcbyNCcQQ+fRCJS7TYtK2nVk/yV8jB8szVJlmHDkYTT87iaSn+I zPAJ1gTWbfI5lejh+jnMDXracBKujjU+5OeMMyy6R1+ZM2HyeZblNQvWkZBFEAizQDq1 Rr7w== X-Gm-Message-State: AOAM530lCpuLeru8yi9Xye5ydyAEgiXBx4P2xPxzPJewIi4CjU/tWvM5 sVtpLm/m/nwAE/TWlHjLYDZvtirqPyMK3vrWYhvSDwO/uSy7zQ== X-Google-Smtp-Source: ABdhPJyP19B/oIry0JfCJBkdBQpAI5pWgWggGgO/ylXYUHO4mBvGUxx0IWjuH24wIykQIooKuaHnk/vvvH+v3M9qqjo= X-Received: by 2002:a17:907:2170:: with SMTP id rl16mr8006251ejb.422.1595569274883; Thu, 23 Jul 2020 22:41:14 -0700 (PDT) MIME-Version: 1.0 From: Yun-hao Chung Date: Fri, 24 Jul 2020 13:41:03 +0800 Message-ID: Subject: Advertisement monitor interface in bluetoothctl plan To: Bluez mailing list , Luiz Augusto von Dentz Cc: Miao-chen Chou , Manish Mandlik Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.68 / 15.00 / 200.00 X-Rspamd-Queue-Id: B30624086A X-Rspamd-UID: cd2b43 Hi linux-bluetooth, We plan to implement the advertisement monitor interface in bluetoothctl, here is the plan. All the commands will be put under a new sub menu 'advertisement monitor'. New commands: add-pattern-monitor //where the structure of a pattern: (start_position, AD_data_type, content) remove-pattern-monitor list-pattern-monitors //list all monitors with their id and attributes get-supported-feature //get SupportedMonitorTypes and SupportedFeatures in AdvertisementMonitorManager What do you think about this plan? Thanks! Howard Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gAEGGQDLGl/vMwEAvsO+Rg (envelope-from ) for ; Fri, 24 Jul 2020 13:50:24 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CCliFwDLGl9LOAAAgupzMw (envelope-from ); Fri, 24 Jul 2020 13:50:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CA2A840866; Fri, 24 Jul 2020 13:50:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726768AbgGXLuE (ORCPT + 1 other); Fri, 24 Jul 2020 07:50:04 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41020 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726411AbgGXLuC (ORCPT ); Fri, 24 Jul 2020 07:50:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595591400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6+ChtD0GXCo4LLqaKWKmtcOwT0zGgtGTIGQjamaPLVU=; b=KMOE2zapcVtqQ8kwm8oQF4efmW+DJhXLyTo5cedOfeQSHblAOQmHEA3a8n/5eSd2fAPHu/ 1JyAfaWAkUXzUAK0SVmlDaV9B6JyCccRILiQfTPETpL8SZOy+TQnFWlpwqtFZA2JUCyLyP XkbUki9fEBVdx3gQ9t0Q19Cgeve/F7A= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-URbMgH0nPSOJnCqFBofrug-1; Fri, 24 Jul 2020 07:49:59 -0400 X-MC-Unique: URbMgH0nPSOJnCqFBofrug-1 Received: by mail-wm1-f70.google.com with SMTP id v4so1755616wmh.3 for ; Fri, 24 Jul 2020 04:49:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6+ChtD0GXCo4LLqaKWKmtcOwT0zGgtGTIGQjamaPLVU=; b=o72AZuyE6qm3pppcCKN/nURd+OBGpyFNOQESUR5mo3n7jDQYi62r+Ql9DyrcqPtFGP Midx5I5UIuUfU7WwRMHdC1Rx40kivMXNxOOvVq7n1IfacvO2CkPGQHi9MedJ4jWmsWKw LrHDznt1gU7kN5mr6wMRZf3hhaTdxM9Zx+h+zADpwrRxUyYpuNfX2qrPYutKYorHnHTz e5iDDXhjDXL72G1Zy4GPLi2B19R54+817A4OQMPXJuLodowlD8NbYrEntJCUYQRmnb8e ugThlm75TMdRZHiicyEkD43SG4LzWuhEVezZ8E2qhlL+msHnwPOgjMGbwBkjwYSBWfsh 3A1A== X-Gm-Message-State: AOAM530A05ERfQp8ZlBoh57MmKyy1l22OhnIslEnNrE5HZPK3g3cf0Ob KdLJ5aRCix6iZyBAosrRNTCgquJrBSWvNZa1AGVrQjvCgUEzkWxLspiHMCj0bPjrILELKrZDwpU BT8H73OUGIf6gRPbyFAitHlyW0/3q X-Received: by 2002:a1c:f616:: with SMTP id w22mr8057670wmc.44.1595591397782; Fri, 24 Jul 2020 04:49:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA9RMYWdAPaTFDYdlul0e8hCah4d4e5ddH+g/hUNmfx6ovHLama1NPhon8tgbN52ktZUIM6Q== X-Received: by 2002:a1c:f616:: with SMTP id w22mr8057655wmc.44.1595591397515; Fri, 24 Jul 2020 04:49:57 -0700 (PDT) Received: from x1.localdomain ([2a0e:5700:4:11:334c:7e36:8d57:40cb]) by smtp.gmail.com with ESMTPSA id u10sm6595252wml.29.2020.07.24.04.49.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Jul 2020 04:49:56 -0700 (PDT) Subject: Re: [PATCH 1/2] Bluetooth: hci_h5: Set HCI_UART_RESET_ON_INIT to correct flags To: Nicolas Boichat , Marcel Holtmann Cc: Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200721103652.1.Idbc7eddf1f24f750a8bbcbc8e06743736ae3be31@changeid> From: Hans de Goede Message-ID: <6c76582e-5e5d-0977-37b6-82bc84bd81c9@redhat.com> Date: Fri, 24 Jul 2020 13:49:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200721103652.1.Idbc7eddf1f24f750a8bbcbc8e06743736ae3be31@changeid> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: CA2A840866 X-Rspamd-UID: 3d85de Hi, On 7/21/20 4:37 AM, Nicolas Boichat wrote: > HCI_UART_RESET_ON_INIT belongs in hdev_flags, not flags. > > Fixes: ce945552fde4a09 ("Bluetooth: hci_h5: Add support for serdev enumerated devices") > Signed-off-by: Nicolas Boichat Patch looks good to me: Reviewed-by: Hans de Goede Regards, Hans > > --- > > drivers/bluetooth/hci_h5.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c > index e60b2e0773db110..e41854e0d79aae2 100644 > --- a/drivers/bluetooth/hci_h5.c > +++ b/drivers/bluetooth/hci_h5.c > @@ -793,7 +793,7 @@ static int h5_serdev_probe(struct serdev_device *serdev) > if (!h5) > return -ENOMEM; > > - set_bit(HCI_UART_RESET_ON_INIT, &h5->serdev_hu.flags); > + set_bit(HCI_UART_RESET_ON_INIT, &h5->serdev_hu.hdev_flags); > > h5->hu = &h5->serdev_hu; > h5->serdev_hu.serdev = serdev; > Return-Path: Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aNzBISzSGl9OuAEAvsO+Rg (envelope-from ) for ; Fri, 24 Jul 2020 14:21:00 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 2LzlICzSGl8bRgAA0J78UA (envelope-from ); Fri, 24 Jul 2020 14:21:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CC22140033; Fri, 24 Jul 2020 14:20:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726329AbgGXMUy (ORCPT + 1 other); Fri, 24 Jul 2020 08:20:54 -0400 Received: from lucky1.263xmail.com ([211.157.147.134]:47410 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726258AbgGXMUy (ORCPT ); Fri, 24 Jul 2020 08:20:54 -0400 Received: from localhost (unknown [192.168.167.209]) by lucky1.263xmail.com (Postfix) with ESMTP id F2AC9C0907 for ; Fri, 24 Jul 2020 20:20:44 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED: 0 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [113.57.152.160]) by smtp.263.net (postfix) whith ESMTP id P20417T140494254360320S1595593245635670_; Fri, 24 Jul 2020 20:20:46 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <4363d5b6be41cca5a42b152a2cef72e2> X-RL-SENDER: chengbo@uniontech.com X-SENDER: chengbo@uniontech.com X-LOGIN-NAME: chengbo@uniontech.com X-FST-TO: linux-bluetooth@vger.kernel.org X-SENDER-IP: 113.57.152.160 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: chengbo <515672508@qq.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] src: Event callback registration optimization Date: Fri, 24 Jul 2020 20:20:45 +0800 Message-Id: <20200724122045.17245-1-515672508@qq.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.35 / 15.00 / 200.00 X-Rspamd-Queue-Id: CC22140033 X-Rspamd-UID: 7924eb After read info complete,too many event registration functions are not conducive to subsequent expansion. --- ...ent-callback-registration-optimizati.patch | 187 ++++++++++++++++++ src/adapter.c | 143 ++++---------- 2 files changed, 229 insertions(+), 101 deletions(-) create mode 100644 0001-src-adapter.c-Event-callback-registration-optimizati.patch diff --git a/0001-src-adapter.c-Event-callback-registration-optimizati.patch b/0001-src-adapter.c-Event-callback-registration-optimizati.patch new file mode 100644 index 000000000..d0f4804c6 --- /dev/null +++ b/0001-src-adapter.c-Event-callback-registration-optimizati.patch @@ -0,0 +1,187 @@ +From c2bf3d643c8f2eb7b97c0ede4396f879ba6febf8 Mon Sep 17 00:00:00 2001 +From: mac fanqiang +Date: Fri, 24 Jul 2020 17:42:37 +0800 +Subject: [PATCH] src/adapter.c : Event callback registration optimization + After read info complete,too many event registration functions are not + conducive to subsequent expansion. If we want to add a new event, + according to the previous logic, we must add an event registration function, + the code is too redundant. Therefore, I added a global time callback + registration in this submission. If you want to add event registration + later, you only need to add the new event and event callback function to the + global table. + +--- + src/adapter.c | 143 +++++++++++++++----------------------------------- + 1 file changed, 42 insertions(+), 101 deletions(-) + +diff --git a/src/adapter.c b/src/adapter.c +index 5e896a9f0..7afb4509d 100644 +--- a/src/adapter.c ++++ b/src/adapter.c +@@ -298,6 +298,11 @@ struct btd_adapter { + bool le_simult_roles_supported; + }; + ++struct mgmt_callback{ ++ uint16_t event; ++ mgmt_notify_func_t callback; ++}; ++ + typedef enum { + ADAPTER_AUTHORIZE_DISCONNECTED = 0, + ADAPTER_AUTHORIZE_CHECK_CONNECTED +@@ -9163,6 +9168,41 @@ static void read_exp_features(struct btd_adapter *adapter) + btd_error(adapter->dev_id, "Failed to read exp features info"); + } + ++static struct mgmt_callback g_mgmt_callback_table[] = { ++ {MGMT_EV_NEW_SETTINGS, new_settings_callback}, ++ {MGMT_EV_CLASS_OF_DEV_CHANGED, dev_class_changed_callback}, ++ {MGMT_EV_LOCAL_NAME_CHANGED, local_name_changed_callback}, ++ {MGMT_EV_DISCOVERING, discovering_callback}, ++ {MGMT_EV_DEVICE_FOUND, device_found_callback}, ++ {MGMT_EV_DEVICE_DISCONNECTED, disconnected_callback}, ++ {MGMT_EV_DEVICE_CONNECTED, connected_callback}, ++ {MGMT_EV_CONNECT_FAILED, connect_failed_callback}, ++ {MGMT_EV_DEVICE_UNPAIRED, unpaired_callback}, ++ {MGMT_EV_AUTH_FAILED, auth_failed_callback}, ++ {MGMT_EV_NEW_LINK_KEY, new_link_key_callback}, ++ {MGMT_EV_NEW_LONG_TERM_KEY, new_long_term_key_callback}, ++ {MGMT_EV_NEW_CSRK, new_csrk_callback}, ++ {MGMT_EV_NEW_IRK, new_irk_callback}, ++ {MGMT_EV_NEW_CONN_PARAM, new_conn_param}, ++ {MGMT_EV_DEVICE_BLOCKED, device_blocked_callback}, ++ {MGMT_EV_DEVICE_UNBLOCKED, device_unblocked_callback}, ++ {MGMT_EV_PIN_CODE_REQUEST, pin_code_request_callback}, ++ {MGMT_EV_USER_CONFIRM_REQUEST, user_confirm_request_callback}, ++ {MGMT_EV_USER_PASSKEY_REQUEST, user_passkey_request_callback}, ++ {MGMT_EV_PASSKEY_NOTIFY, user_passkey_notify_callback} ++}; ++ ++static void mgmt_event_register(struct btd_adapter *adapter) ++{ ++ int len = sizeof(g_mgmt_callback_table)/sizeof(g_mgmt_callback_table[0]); ++ ++ for (int i = 0; i < len; i++) { ++ mgmt_register(adapter->mgmt, g_mgmt_callback_table[i].event, ++ adapter->dev_id, g_mgmt_callback_table[i].callback, ++ adapter, NULL); ++ } ++} ++ + static void read_info_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) + { +@@ -9288,107 +9328,8 @@ static void read_info_complete(uint8_t status, uint16_t length, + * controller info. From now on they can track updates and + * notifications. + */ +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_SETTINGS, adapter->dev_id, +- new_settings_callback, adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_CLASS_OF_DEV_CHANGED, +- adapter->dev_id, +- dev_class_changed_callback, +- adapter, NULL); +- mgmt_register(adapter->mgmt, MGMT_EV_LOCAL_NAME_CHANGED, +- adapter->dev_id, +- local_name_changed_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DISCOVERING, +- adapter->dev_id, +- discovering_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_FOUND, +- adapter->dev_id, +- device_found_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_DISCONNECTED, +- adapter->dev_id, +- disconnected_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_CONNECTED, +- adapter->dev_id, +- connected_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_CONNECT_FAILED, +- adapter->dev_id, +- connect_failed_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_UNPAIRED, +- adapter->dev_id, +- unpaired_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_AUTH_FAILED, +- adapter->dev_id, +- auth_failed_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_LINK_KEY, +- adapter->dev_id, +- new_link_key_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_LONG_TERM_KEY, +- adapter->dev_id, +- new_long_term_key_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_CSRK, +- adapter->dev_id, +- new_csrk_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_IRK, +- adapter->dev_id, +- new_irk_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_CONN_PARAM, +- adapter->dev_id, +- new_conn_param, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_BLOCKED, +- adapter->dev_id, +- device_blocked_callback, +- adapter, NULL); +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_UNBLOCKED, +- adapter->dev_id, +- device_unblocked_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_PIN_CODE_REQUEST, +- adapter->dev_id, +- pin_code_request_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_USER_CONFIRM_REQUEST, +- adapter->dev_id, +- user_confirm_request_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_USER_PASSKEY_REQUEST, +- adapter->dev_id, +- user_passkey_request_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_PASSKEY_NOTIFY, +- adapter->dev_id, +- user_passkey_notify_callback, +- adapter, NULL); +- ++ mgmt_event_register(adapter); ++ + set_dev_class(adapter); + + set_name(adapter, btd_adapter_get_name(adapter)); +-- +2.20.1 + diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..7afb4509d 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -298,6 +298,11 @@ struct btd_adapter { bool le_simult_roles_supported; }; +struct mgmt_callback{ + uint16_t event; + mgmt_notify_func_t callback; +}; + typedef enum { ADAPTER_AUTHORIZE_DISCONNECTED = 0, ADAPTER_AUTHORIZE_CHECK_CONNECTED @@ -9163,6 +9168,41 @@ static void read_exp_features(struct btd_adapter *adapter) btd_error(adapter->dev_id, "Failed to read exp features info"); } +static struct mgmt_callback g_mgmt_callback_table[] = { + {MGMT_EV_NEW_SETTINGS, new_settings_callback}, + {MGMT_EV_CLASS_OF_DEV_CHANGED, dev_class_changed_callback}, + {MGMT_EV_LOCAL_NAME_CHANGED, local_name_changed_callback}, + {MGMT_EV_DISCOVERING, discovering_callback}, + {MGMT_EV_DEVICE_FOUND, device_found_callback}, + {MGMT_EV_DEVICE_DISCONNECTED, disconnected_callback}, + {MGMT_EV_DEVICE_CONNECTED, connected_callback}, + {MGMT_EV_CONNECT_FAILED, connect_failed_callback}, + {MGMT_EV_DEVICE_UNPAIRED, unpaired_callback}, + {MGMT_EV_AUTH_FAILED, auth_failed_callback}, + {MGMT_EV_NEW_LINK_KEY, new_link_key_callback}, + {MGMT_EV_NEW_LONG_TERM_KEY, new_long_term_key_callback}, + {MGMT_EV_NEW_CSRK, new_csrk_callback}, + {MGMT_EV_NEW_IRK, new_irk_callback}, + {MGMT_EV_NEW_CONN_PARAM, new_conn_param}, + {MGMT_EV_DEVICE_BLOCKED, device_blocked_callback}, + {MGMT_EV_DEVICE_UNBLOCKED, device_unblocked_callback}, + {MGMT_EV_PIN_CODE_REQUEST, pin_code_request_callback}, + {MGMT_EV_USER_CONFIRM_REQUEST, user_confirm_request_callback}, + {MGMT_EV_USER_PASSKEY_REQUEST, user_passkey_request_callback}, + {MGMT_EV_PASSKEY_NOTIFY, user_passkey_notify_callback} +}; + +static void mgmt_event_register(struct btd_adapter *adapter) +{ + int len = sizeof(g_mgmt_callback_table)/sizeof(g_mgmt_callback_table[0]); + + for (int i = 0; i < len; i++) { + mgmt_register(adapter->mgmt, g_mgmt_callback_table[i].event, + adapter->dev_id, g_mgmt_callback_table[i].callback, + adapter, NULL); + } +} + static void read_info_complete(uint8_t status, uint16_t length, const void *param, void *user_data) { @@ -9288,107 +9328,8 @@ static void read_info_complete(uint8_t status, uint16_t length, * controller info. From now on they can track updates and * notifications. */ - mgmt_register(adapter->mgmt, MGMT_EV_NEW_SETTINGS, adapter->dev_id, - new_settings_callback, adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_CLASS_OF_DEV_CHANGED, - adapter->dev_id, - dev_class_changed_callback, - adapter, NULL); - mgmt_register(adapter->mgmt, MGMT_EV_LOCAL_NAME_CHANGED, - adapter->dev_id, - local_name_changed_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DISCOVERING, - adapter->dev_id, - discovering_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_FOUND, - adapter->dev_id, - device_found_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_DISCONNECTED, - adapter->dev_id, - disconnected_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_CONNECTED, - adapter->dev_id, - connected_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_CONNECT_FAILED, - adapter->dev_id, - connect_failed_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_UNPAIRED, - adapter->dev_id, - unpaired_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_AUTH_FAILED, - adapter->dev_id, - auth_failed_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_NEW_LINK_KEY, - adapter->dev_id, - new_link_key_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_NEW_LONG_TERM_KEY, - adapter->dev_id, - new_long_term_key_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_NEW_CSRK, - adapter->dev_id, - new_csrk_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_NEW_IRK, - adapter->dev_id, - new_irk_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_NEW_CONN_PARAM, - adapter->dev_id, - new_conn_param, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_BLOCKED, - adapter->dev_id, - device_blocked_callback, - adapter, NULL); - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_UNBLOCKED, - adapter->dev_id, - device_unblocked_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_PIN_CODE_REQUEST, - adapter->dev_id, - pin_code_request_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_USER_CONFIRM_REQUEST, - adapter->dev_id, - user_confirm_request_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_USER_PASSKEY_REQUEST, - adapter->dev_id, - user_passkey_request_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_PASSKEY_NOTIFY, - adapter->dev_id, - user_passkey_notify_callback, - adapter, NULL); - + mgmt_event_register(adapter); + set_dev_class(adapter); set_name(adapter, btd_adapter_get_name(adapter)); -- 2.20.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qN64CznSGl9OuAEAvsO+Rg (envelope-from ) for ; Fri, 24 Jul 2020 14:21:13 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id cGu2CTnSGl9BzwEAlScrYA (envelope-from ); Fri, 24 Jul 2020 14:21:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4D12640014; Fri, 24 Jul 2020 14:21:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726381AbgGXMVJ (ORCPT + 1 other); Fri, 24 Jul 2020 08:21:09 -0400 Received: from lucky1.263xmail.com ([211.157.147.134]:47542 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726258AbgGXMVI (ORCPT ); Fri, 24 Jul 2020 08:21:08 -0400 Received: from localhost (unknown [192.168.167.139]) by lucky1.263xmail.com (Postfix) with ESMTP id 8B7C1C09FF for ; Fri, 24 Jul 2020 20:21:01 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED: 0 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [113.57.152.160]) by smtp.263.net (postfix) whith ESMTP id P25385T139645017696000S1595593261558820_; Fri, 24 Jul 2020 20:21:02 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: X-RL-SENDER: chengbo@uniontech.com X-SENDER: chengbo@uniontech.com X-LOGIN-NAME: chengbo@uniontech.com X-FST-TO: linux-bluetooth@vger.kernel.org X-SENDER-IP: 113.57.152.160 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: chengbo <515672508@qq.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] src: Event callback registration optimization Date: Fri, 24 Jul 2020 20:21:01 +0800 Message-Id: <20200724122101.17300-1-515672508@qq.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 10 X-Rspamd-Score: 1.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4D12640014 X-Rspamd-UID: c59a79 After read info complete,too many event registration functions are not conducive to subsequent expansion. --- ...ent-callback-registration-optimizati.patch | 187 ++++++++++++++++++ src/adapter.c | 143 ++++---------- 2 files changed, 229 insertions(+), 101 deletions(-) create mode 100644 0001-src-adapter.c-Event-callback-registration-optimizati.patch diff --git a/0001-src-adapter.c-Event-callback-registration-optimizati.patch b/0001-src-adapter.c-Event-callback-registration-optimizati.patch new file mode 100644 index 000000000..d0f4804c6 --- /dev/null +++ b/0001-src-adapter.c-Event-callback-registration-optimizati.patch @@ -0,0 +1,187 @@ +From c2bf3d643c8f2eb7b97c0ede4396f879ba6febf8 Mon Sep 17 00:00:00 2001 +From: mac fanqiang +Date: Fri, 24 Jul 2020 17:42:37 +0800 +Subject: [PATCH] src/adapter.c : Event callback registration optimization + After read info complete,too many event registration functions are not + conducive to subsequent expansion. If we want to add a new event, + according to the previous logic, we must add an event registration function, + the code is too redundant. Therefore, I added a global time callback + registration in this submission. If you want to add event registration + later, you only need to add the new event and event callback function to the + global table. + +--- + src/adapter.c | 143 +++++++++++++++----------------------------------- + 1 file changed, 42 insertions(+), 101 deletions(-) + +diff --git a/src/adapter.c b/src/adapter.c +index 5e896a9f0..7afb4509d 100644 +--- a/src/adapter.c ++++ b/src/adapter.c +@@ -298,6 +298,11 @@ struct btd_adapter { + bool le_simult_roles_supported; + }; + ++struct mgmt_callback{ ++ uint16_t event; ++ mgmt_notify_func_t callback; ++}; ++ + typedef enum { + ADAPTER_AUTHORIZE_DISCONNECTED = 0, + ADAPTER_AUTHORIZE_CHECK_CONNECTED +@@ -9163,6 +9168,41 @@ static void read_exp_features(struct btd_adapter *adapter) + btd_error(adapter->dev_id, "Failed to read exp features info"); + } + ++static struct mgmt_callback g_mgmt_callback_table[] = { ++ {MGMT_EV_NEW_SETTINGS, new_settings_callback}, ++ {MGMT_EV_CLASS_OF_DEV_CHANGED, dev_class_changed_callback}, ++ {MGMT_EV_LOCAL_NAME_CHANGED, local_name_changed_callback}, ++ {MGMT_EV_DISCOVERING, discovering_callback}, ++ {MGMT_EV_DEVICE_FOUND, device_found_callback}, ++ {MGMT_EV_DEVICE_DISCONNECTED, disconnected_callback}, ++ {MGMT_EV_DEVICE_CONNECTED, connected_callback}, ++ {MGMT_EV_CONNECT_FAILED, connect_failed_callback}, ++ {MGMT_EV_DEVICE_UNPAIRED, unpaired_callback}, ++ {MGMT_EV_AUTH_FAILED, auth_failed_callback}, ++ {MGMT_EV_NEW_LINK_KEY, new_link_key_callback}, ++ {MGMT_EV_NEW_LONG_TERM_KEY, new_long_term_key_callback}, ++ {MGMT_EV_NEW_CSRK, new_csrk_callback}, ++ {MGMT_EV_NEW_IRK, new_irk_callback}, ++ {MGMT_EV_NEW_CONN_PARAM, new_conn_param}, ++ {MGMT_EV_DEVICE_BLOCKED, device_blocked_callback}, ++ {MGMT_EV_DEVICE_UNBLOCKED, device_unblocked_callback}, ++ {MGMT_EV_PIN_CODE_REQUEST, pin_code_request_callback}, ++ {MGMT_EV_USER_CONFIRM_REQUEST, user_confirm_request_callback}, ++ {MGMT_EV_USER_PASSKEY_REQUEST, user_passkey_request_callback}, ++ {MGMT_EV_PASSKEY_NOTIFY, user_passkey_notify_callback} ++}; ++ ++static void mgmt_event_register(struct btd_adapter *adapter) ++{ ++ int len = sizeof(g_mgmt_callback_table)/sizeof(g_mgmt_callback_table[0]); ++ ++ for (int i = 0; i < len; i++) { ++ mgmt_register(adapter->mgmt, g_mgmt_callback_table[i].event, ++ adapter->dev_id, g_mgmt_callback_table[i].callback, ++ adapter, NULL); ++ } ++} ++ + static void read_info_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) + { +@@ -9288,107 +9328,8 @@ static void read_info_complete(uint8_t status, uint16_t length, + * controller info. From now on they can track updates and + * notifications. + */ +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_SETTINGS, adapter->dev_id, +- new_settings_callback, adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_CLASS_OF_DEV_CHANGED, +- adapter->dev_id, +- dev_class_changed_callback, +- adapter, NULL); +- mgmt_register(adapter->mgmt, MGMT_EV_LOCAL_NAME_CHANGED, +- adapter->dev_id, +- local_name_changed_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DISCOVERING, +- adapter->dev_id, +- discovering_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_FOUND, +- adapter->dev_id, +- device_found_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_DISCONNECTED, +- adapter->dev_id, +- disconnected_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_CONNECTED, +- adapter->dev_id, +- connected_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_CONNECT_FAILED, +- adapter->dev_id, +- connect_failed_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_UNPAIRED, +- adapter->dev_id, +- unpaired_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_AUTH_FAILED, +- adapter->dev_id, +- auth_failed_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_LINK_KEY, +- adapter->dev_id, +- new_link_key_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_LONG_TERM_KEY, +- adapter->dev_id, +- new_long_term_key_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_CSRK, +- adapter->dev_id, +- new_csrk_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_IRK, +- adapter->dev_id, +- new_irk_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_NEW_CONN_PARAM, +- adapter->dev_id, +- new_conn_param, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_BLOCKED, +- adapter->dev_id, +- device_blocked_callback, +- adapter, NULL); +- mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_UNBLOCKED, +- adapter->dev_id, +- device_unblocked_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_PIN_CODE_REQUEST, +- adapter->dev_id, +- pin_code_request_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_USER_CONFIRM_REQUEST, +- adapter->dev_id, +- user_confirm_request_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_USER_PASSKEY_REQUEST, +- adapter->dev_id, +- user_passkey_request_callback, +- adapter, NULL); +- +- mgmt_register(adapter->mgmt, MGMT_EV_PASSKEY_NOTIFY, +- adapter->dev_id, +- user_passkey_notify_callback, +- adapter, NULL); +- ++ mgmt_event_register(adapter); ++ + set_dev_class(adapter); + + set_name(adapter, btd_adapter_get_name(adapter)); +-- +2.20.1 + diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..7afb4509d 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -298,6 +298,11 @@ struct btd_adapter { bool le_simult_roles_supported; }; +struct mgmt_callback{ + uint16_t event; + mgmt_notify_func_t callback; +}; + typedef enum { ADAPTER_AUTHORIZE_DISCONNECTED = 0, ADAPTER_AUTHORIZE_CHECK_CONNECTED @@ -9163,6 +9168,41 @@ static void read_exp_features(struct btd_adapter *adapter) btd_error(adapter->dev_id, "Failed to read exp features info"); } +static struct mgmt_callback g_mgmt_callback_table[] = { + {MGMT_EV_NEW_SETTINGS, new_settings_callback}, + {MGMT_EV_CLASS_OF_DEV_CHANGED, dev_class_changed_callback}, + {MGMT_EV_LOCAL_NAME_CHANGED, local_name_changed_callback}, + {MGMT_EV_DISCOVERING, discovering_callback}, + {MGMT_EV_DEVICE_FOUND, device_found_callback}, + {MGMT_EV_DEVICE_DISCONNECTED, disconnected_callback}, + {MGMT_EV_DEVICE_CONNECTED, connected_callback}, + {MGMT_EV_CONNECT_FAILED, connect_failed_callback}, + {MGMT_EV_DEVICE_UNPAIRED, unpaired_callback}, + {MGMT_EV_AUTH_FAILED, auth_failed_callback}, + {MGMT_EV_NEW_LINK_KEY, new_link_key_callback}, + {MGMT_EV_NEW_LONG_TERM_KEY, new_long_term_key_callback}, + {MGMT_EV_NEW_CSRK, new_csrk_callback}, + {MGMT_EV_NEW_IRK, new_irk_callback}, + {MGMT_EV_NEW_CONN_PARAM, new_conn_param}, + {MGMT_EV_DEVICE_BLOCKED, device_blocked_callback}, + {MGMT_EV_DEVICE_UNBLOCKED, device_unblocked_callback}, + {MGMT_EV_PIN_CODE_REQUEST, pin_code_request_callback}, + {MGMT_EV_USER_CONFIRM_REQUEST, user_confirm_request_callback}, + {MGMT_EV_USER_PASSKEY_REQUEST, user_passkey_request_callback}, + {MGMT_EV_PASSKEY_NOTIFY, user_passkey_notify_callback} +}; + +static void mgmt_event_register(struct btd_adapter *adapter) +{ + int len = sizeof(g_mgmt_callback_table)/sizeof(g_mgmt_callback_table[0]); + + for (int i = 0; i < len; i++) { + mgmt_register(adapter->mgmt, g_mgmt_callback_table[i].event, + adapter->dev_id, g_mgmt_callback_table[i].callback, + adapter, NULL); + } +} + static void read_info_complete(uint8_t status, uint16_t length, const void *param, void *user_data) { @@ -9288,107 +9328,8 @@ static void read_info_complete(uint8_t status, uint16_t length, * controller info. From now on they can track updates and * notifications. */ - mgmt_register(adapter->mgmt, MGMT_EV_NEW_SETTINGS, adapter->dev_id, - new_settings_callback, adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_CLASS_OF_DEV_CHANGED, - adapter->dev_id, - dev_class_changed_callback, - adapter, NULL); - mgmt_register(adapter->mgmt, MGMT_EV_LOCAL_NAME_CHANGED, - adapter->dev_id, - local_name_changed_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DISCOVERING, - adapter->dev_id, - discovering_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_FOUND, - adapter->dev_id, - device_found_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_DISCONNECTED, - adapter->dev_id, - disconnected_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_CONNECTED, - adapter->dev_id, - connected_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_CONNECT_FAILED, - adapter->dev_id, - connect_failed_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_UNPAIRED, - adapter->dev_id, - unpaired_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_AUTH_FAILED, - adapter->dev_id, - auth_failed_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_NEW_LINK_KEY, - adapter->dev_id, - new_link_key_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_NEW_LONG_TERM_KEY, - adapter->dev_id, - new_long_term_key_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_NEW_CSRK, - adapter->dev_id, - new_csrk_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_NEW_IRK, - adapter->dev_id, - new_irk_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_NEW_CONN_PARAM, - adapter->dev_id, - new_conn_param, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_BLOCKED, - adapter->dev_id, - device_blocked_callback, - adapter, NULL); - mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_UNBLOCKED, - adapter->dev_id, - device_unblocked_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_PIN_CODE_REQUEST, - adapter->dev_id, - pin_code_request_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_USER_CONFIRM_REQUEST, - adapter->dev_id, - user_confirm_request_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_USER_PASSKEY_REQUEST, - adapter->dev_id, - user_passkey_request_callback, - adapter, NULL); - - mgmt_register(adapter->mgmt, MGMT_EV_PASSKEY_NOTIFY, - adapter->dev_id, - user_passkey_notify_callback, - adapter, NULL); - + mgmt_event_register(adapter); + set_dev_class(adapter); set_name(adapter, btd_adapter_get_name(adapter)); -- 2.20.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qLwPNi/TGl+M7wEAvsO+Rg (envelope-from ) for ; Fri, 24 Jul 2020 14:25:19 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +PyZNC/TGl9s1wEAlp8NpQ (envelope-from ); Fri, 24 Jul 2020 14:25:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9E366A1D7B; Fri, 24 Jul 2020 14:25:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726485AbgGXMZO (ORCPT + 1 other); Fri, 24 Jul 2020 08:25:14 -0400 Received: from lucky1.263xmail.com ([211.157.147.131]:39376 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726280AbgGXMZN (ORCPT ); Fri, 24 Jul 2020 08:25:13 -0400 Received: from localhost (unknown [192.168.167.235]) by lucky1.263xmail.com (Postfix) with ESMTP id 7A3FDB01C6 for ; Fri, 24 Jul 2020 20:25:11 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [113.57.152.160]) by smtp.263.net (postfix) whith ESMTP id P30362T140065527297792S1595593511218582_; Fri, 24 Jul 2020 20:25:11 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <9caa455dffd2153fa76e1e41fd427b7c> X-RL-SENDER: luokai@uniontech.com X-SENDER: luokai@uniontech.com X-LOGIN-NAME: luokai@uniontech.com X-FST-TO: linux-bluetooth@vger.kernel.org X-SENDER-IP: 113.57.152.160 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: luokai <454728735@qq.com> To: linux-bluetooth@vger.kernel.org Cc: luokai Subject: [PATCH BlueZ 1/1] src/agent.c : parse_io_capability Function optimization Date: Fri, 24 Jul 2020 20:25:07 +0800 Message-Id: <20200724122507.27671-1-454728735@qq.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 28 X-Rspamd-Score: 4.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9E366A1D7B X-Rspamd-UID: 60d14e From: luokai --- src/agent.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/agent.c b/src/agent.c index e0ffcd22f..82baf608f 100644 --- a/src/agent.c +++ b/src/agent.c @@ -957,20 +957,24 @@ static void agent_destroy(gpointer data) agent_unref(agent); } +static struct capability g_cap[] = { + {"", IO_CAPABILITY_KEYBOARDDISPLAY}, + {"DisplayOnly", IO_CAPABILITY_DISPLAYONLY}, + {"DisplayYesNo", IO_CAPABILITY_DISPLAYYESNO}, + {"KeyboardOnly", IO_CAPABILITY_KEYBOARDONLY}, + {"NoInputNoOutput", IO_CAPABILITY_NOINPUTNOOUTPUT}, + {"KeyboardDisplay", IO_CAPABILITY_KEYBOARDDISPLAY} +}; + static uint8_t parse_io_capability(const char *capability) { - if (g_str_equal(capability, "")) - return IO_CAPABILITY_KEYBOARDDISPLAY; - if (g_str_equal(capability, "DisplayOnly")) - return IO_CAPABILITY_DISPLAYONLY; - if (g_str_equal(capability, "DisplayYesNo")) - return IO_CAPABILITY_DISPLAYYESNO; - if (g_str_equal(capability, "KeyboardOnly")) - return IO_CAPABILITY_KEYBOARDONLY; - if (g_str_equal(capability, "NoInputNoOutput")) - return IO_CAPABILITY_NOINPUTNOOUTPUT; - if (g_str_equal(capability, "KeyboardDisplay")) - return IO_CAPABILITY_KEYBOARDDISPLAY; + size_t count = sizeof(g_cap) / sizeof(g_cap[0]); + for (size_t i = 0; i < count; i++) + { + if(g_str_equal(capability, g_cap[i].cap)) { + return g_cap[i].parse_capability; + } + } return IO_CAPABILITY_INVALID; } -- 2.20.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IFtGL/veGl8hKwAAvsO+Rg (envelope-from ) for ; Fri, 24 Jul 2020 15:15:39 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UGl4LfveGl8WfgAADc0bRg (envelope-from ); Fri, 24 Jul 2020 15:15:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=heine.so X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2000EA1856; Fri, 24 Jul 2020 15:15:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727775AbgGXNPA (ORCPT + 1 other); Fri, 24 Jul 2020 09:15:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727045AbgGXNO5 (ORCPT ); Fri, 24 Jul 2020 09:14:57 -0400 X-Greylist: delayed 311 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 24 Jul 2020 06:14:57 PDT Received: from mail.heine.tech (mail.heine.tech [IPv6:2a01:4f8:1c0c:5073::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93809C0619D3 for ; Fri, 24 Jul 2020 06:14:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B152518195B; Fri, 24 Jul 2020 15:09:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heine.so; s=dkim; t=1595596181; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=oUDJqp4U9kelY2xZptaoZ5P+NEJJM4T0cxyXAqFjZ14=; b=H+Nxlk98oJjxZZVHIF+mLH2gaSfLDB6KWx8jID58Y7X6Er2g6TY3Aisi9XWBABM2RSi0j/ 1qJZiRnzZEYlEdj7cuLwB/uoxCbRBi+W4cn0LY8RT2B/L+2sIBu2dsenLsj75WmIAeZQ45 g6o9r8+m2Zm2q8qM7gruf+MiVDnEmVY= From: Michael Nosthoff To: linux-bluetooth@vger.kernel.org Cc: Michael Nosthoff Subject: [PATCH BlueZ] main: add missing comma after AlwaysPairable Date: Fri, 24 Jul 2020 15:09:03 +0200 Message-Id: <20200724130903.110903-1-committed@heine.so> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2000EA1856 X-Rspamd-UID: 67ce6e Commit 1880b2990866598 added a new key to supported_options but didn't add a comma. This leads to the following error message on startup if the key 'PairableTimeout' is present: Unknown key PairableTimeout for group General in /etc/bluetooth/main.conf This probably also leads to ignoring the setting. Fixes: 1880b2990866598 ("core: Add AlwaysPairable to main.conf") --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index ec7a9fbd7..2c083de67 100644 --- a/src/main.c +++ b/src/main.c @@ -79,7 +79,7 @@ static const char *supported_options[] = { "Name", "Class", "DiscoverableTimeout", - "AlwaysPairable" + "AlwaysPairable", "PairableTimeout", "DeviceID", "ReverseServiceDiscovery", -- 2.25.1 Return-Path: Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eHbcFoTgGl8hKwAAvsO+Rg (envelope-from ) for ; Fri, 24 Jul 2020 15:22:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2HNOFYTgGl9OLAAAlp8NpQ (envelope-from ); Fri, 24 Jul 2020 15:22:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CCF91A1F82; Fri, 24 Jul 2020 15:22:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726455AbgGXNWG (ORCPT + 1 other); Fri, 24 Jul 2020 09:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726182AbgGXNWG (ORCPT ); Fri, 24 Jul 2020 09:22:06 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB81AC0619D3 for ; Fri, 24 Jul 2020 06:22:05 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id h21so444088qtp.11 for ; Fri, 24 Jul 2020 06:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=BBfsvEPqNiBOfV6lXndiApKNU8ZzRGIx5wkt8sT23CM=; b=ai207q0tq1y/Z4KAUcawy6OZD/jMHM/URn1wgX2cwd0Z0cOo3rIB2hWOmqovX0JP0W hqkp00C3iin9jMqALWyj+TrcOKM7Uk8WGIp1579TCNKlTSKwJAcx70x1atA8ylsqEvxW vN7i1f2/DuJgTYFVEiEU3PyCDPu6GWtgPC54HuY3vvmxRtlspFYV/yaLQgbJ8TjGZDy9 gHdgyPrlHtKnt0dX3n2VwAvzqlFvH3L34m/li9GPP9dPx5vOa1b4j2crltzF6s/8nLEz 8FfcUeQeEWgrIVH936q/8lxxfLOpOtLHdAZjfKTZqUCYSPqtoVVD3hO9V1+gQYCccea9 BMvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=BBfsvEPqNiBOfV6lXndiApKNU8ZzRGIx5wkt8sT23CM=; b=RuCdCc/t6J5cTErqwpMS9r8EOe4kdT7JgSUNcx7DEp54OZt/j94Ey2LHYID+W3N5IU rwpD4cdyHGIZUHIqmV54BfRPI8UbjWKtW2ViOHTpfT4Qbe1KJnInwuWQRTmDaEoK+tau 17nnWDVv83xxPhT+ukqYhSzVPA1gkBjK8nBnkXLgSCWgID4oImpBuCsY/hCk2+0R1BRR m8F/kaxY1gyMDO/MDSP0gnz0ex4lQsy+r3K8wNPevm9U5cgXO0dmQrg0p93YHXX755AU ktjmgY6nsptasiRmyZ8hcmAWVUsrctUY55Z5Of63p+XvLGIYeDtWXlK22EZRC3NovzHf LO4g== X-Gm-Message-State: AOAM530PsmsR2wNizW5Xbbd+CUn6EiNalsNeGLQi+0ORad7xKWyHg1WF vSO6VM7CHpoceW4wLNcCfJOxJGAsh4s= X-Google-Smtp-Source: ABdhPJxeD2q8gXXjexiSjW3xVwN+mJy9pPP+s0b4AOCrRDtWrTo6ygM2/kbUJ0P5FsEbccX0bVFxKg== X-Received: by 2002:ac8:27c9:: with SMTP id x9mr9536760qtx.172.1595596924773; Fri, 24 Jul 2020 06:22:04 -0700 (PDT) Received: from [172.17.0.2] ([52.179.211.51]) by smtp.gmail.com with ESMTPSA id d16sm6233463qkk.106.2020.07.24.06.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 06:22:04 -0700 (PDT) Message-ID: <5f1ae07c.1c69fb81.7a649.ac60@mx.google.com> Date: Fri, 24 Jul 2020 06:22:04 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============6427513465486341450==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, committed@heine.so Subject: RE: [BlueZ] main: add missing comma after AlwaysPairable Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200724130903.110903-1-committed@heine.so> References: <20200724130903.110903-1-committed@heine.so> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 31 X-Rspamd-Score: 4.71 / 15.00 / 200.00 X-Rspamd-Queue-Id: CCF91A1F82 X-Rspamd-UID: fca677 --===============6427513465486341450== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("")' - ie: 'Commit 1880b2990866 ("core: Add AlwaysPairable to main.conf")' #6: Commit 1880b2990866598 added a new key to supported_options but didn't - total: 1 errors, 0 warnings, 8 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============6427513465486341450==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SLgIFTzqGl9KrAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 24 Jul 2020 16:03:40 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +A37EjzqGl9VagAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 24 Jul 2020 16:03:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=heine.so X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 30CCEA0A11; Fri, 24 Jul 2020 16:03:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726639AbgGXODe (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 24 Jul 2020 10:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726503AbgGXODe (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 24 Jul 2020 10:03:34 -0400 Received: from mail.heine.tech (mail.heine.tech [IPv6:2a01:4f8:1c0c:5073::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FAE6C0619D3 for <linux-bluetooth@vger.kernel.org>; Fri, 24 Jul 2020 07:03:34 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9CF6F18195B; Fri, 24 Jul 2020 16:03:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heine.so; s=dkim; t=1595599412; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=cEfrmMdVZeDh7tMtlkG2VgNmjYIH82n1oXbtmmXnWH0=; b=uDjBSJ1tAN7zYO8hP+Wl/lIAP/XPUo9hEbhX2QaAKYTiUSiifceShxCy48CAgdw/xFfW7z 8arwTjPqPi9+dVoLuST93TbV3Saf73sw+SCmMTTO0FjClSaFV6GoFlosGOzN7xcsOWe8xJ 4ef8YHy6+wahy4Dl6qsuBTtYMwNShOA= From: Michael Nosthoff <committed@heine.so> To: linux-bluetooth@vger.kernel.org Cc: Michael Nosthoff <committed@heine.so> Subject: [PATCH BlueZ v2] main: add missing comma after AlwaysPairable Date: Fri, 24 Jul 2020 16:03:06 +0200 Message-Id: <20200724140305.111507-1-committed@heine.so> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 23 X-Rspamd-Score: 3.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 30CCEA0A11 X-Rspamd-UID: 866d53 Commit 1880b2990866 ("core: Add AlwaysPairable to main.conf") added a new key to supported_options but didn't add a comma. This leads to the following error message on startup if the key 'PairableTimeout' is pesent: Unknown key PairableTimeout for group General in /etc/bluetooth/main.conf This probably also leads to ignoring the setting. Fixes: 1880b2990866 ("core: Add AlwaysPairable to main.conf") --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index ec7a9fbd7..2c083de67 100644 --- a/src/main.c +++ b/src/main.c @@ -79,7 +79,7 @@ static const char *supported_options[] = { "Name", "Class", "DiscoverableTimeout", - "AlwaysPairable" + "AlwaysPairable", "PairableTimeout", "DeviceID", "ReverseServiceDiscovery", -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6LKQM60BG1/UGgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 24 Jul 2020 17:43:41 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id +OYCMq0BG18iJAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 24 Jul 2020 17:43:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9163B40873; Fri, 24 Jul 2020 17:43:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726455AbgGXPne convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 24 Jul 2020 11:43:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:53158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbgGXPne (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 24 Jul 2020 11:43:34 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Fri, 24 Jul 2020 15:43:29 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: albin.linux-kernel@kauff.org X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-60824-62941-EQITacEWct@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9163B40873 X-Rspamd-UID: 4755bb https://bugzilla.kernel.org/show_bug.cgi?id=60824 Albin Kauffmann (albin.linux-kernel@kauff.org) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |albin.linux-kernel@kauff.or | |g --- Comment #109 from Albin Kauffmann (albin.linux-kernel@kauff.org) --- Hi, Like Andrey, with patch v3 and reset=0 + enable_autosuspend=0, I can't make my Bluetooth adapter work :-/ I am also using an ArchLinux kernel (patched). Here is my lsusb, if it can help: sudo lsusb -vd 0a12:0001 Bus 001 Device 014: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 224 Wireless bDeviceSubClass 1 Radio Frequency bDeviceProtocol 1 Bluetooth bMaxPacketSize0 64 idVendor 0x0a12 Cambridge Silicon Radio, Ltd idProduct 0x0001 Bluetooth Dongle (HCI mode) bcdDevice 88.91 iManufacturer 0 iProduct 2 BT DONGLE10 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x00b1 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 (Bus Powered) MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 1 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 2 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 3 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 4 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 5 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 can't get device qualifier: Resource temporarily unavailable can't get debug descriptor: Resource temporarily unavailable Device Status: 0x0000 (Bus Powered) Many thanks! -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sLemAHcCG1+2PgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 24 Jul 2020 17:47:03 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id oCPoOnYCG18GfQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 24 Jul 2020 17:47:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DBF68A10B1; Fri, 24 Jul 2020 17:46:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726728AbgGXPq4 convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 24 Jul 2020 11:46:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:54776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726381AbgGXPq4 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 24 Jul 2020 11:46:56 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Fri, 24 Jul 2020 15:46:53 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: albin.linux-kernel@kauff.org X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-c62QY3zQmo@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: DBF68A10B1 X-Rspamd-UID: 442ae1 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #110 from Albin Kauffmann (albin.linux-kernel@kauff.org) --- Oh, I should have added that btmon gives me the following error when plugging the USB dongle: < HCI Command: Read Current IAC LAP (0x03|0x0039) plen 0 #21 [hci0] 39.239547 > HCI Event: Command Complete (0x0e) plen 8 > > #22 [hci0] > 39.241502 Read Current IAC LAP (0x03|0x0039) ncmd 1 Status: Success (0x00) Number of IAC: 1 Access code: 0x9e8b33 (General Inquiry) < HCI Command: Set Event Filter (0x03|0x0005) plen 1 #23 [hci0] 39.241510 Type: Clear All Filters (0x00) > HCI Event: Command Complete (0x0e) plen 4 > > #24 [hci0] > 39.243501 Set Event Filter (0x03|0x0005) ncmd 1 Status: Invalid HCI Command Parameters (0x12) = Close Index: 00:1A:7D:DA:71:12 -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qHCxKzVkG1/tJQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 25 Jul 2020 00:44:05 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WBI+KjVkG19enwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 25 Jul 2020 00:44:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CB34C40866; Sat, 25 Jul 2020 00:44:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726503AbgGXWnq (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 24 Jul 2020 18:43:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbgGXWnq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 24 Jul 2020 18:43:46 -0400 Received: from shards.monkeyblade.net (shards.monkeyblade.net [IPv6:2620:137:e000::1:9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27EDEC0619D3; Fri, 24 Jul 2020 15:43:46 -0700 (PDT) Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 7C0081274F734; Fri, 24 Jul 2020 15:26:58 -0700 (PDT) Date: Fri, 24 Jul 2020 15:43:42 -0700 (PDT) Message-Id: <20200724.154342.1433271593505001306.davem@davemloft.net> To: hch@lst.de Cc: kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, edumazet@google.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: get rid of the address_space override in setsockopt v2 From: David Miller <davem@davemloft.net> In-Reply-To: <20200723060908.50081-1-hch@lst.de> References: <20200723060908.50081-1-hch@lst.de> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Fri, 24 Jul 2020 15:26:59 -0700 (PDT) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: CB34C40866 X-Rspamd-UID: 64a2a9 From: Christoph Hellwig <hch@lst.de> Date: Thu, 23 Jul 2020 08:08:42 +0200 > setsockopt is the last place in architecture-independ code that still > uses set_fs to force the uaccess routines to operate on kernel pointers. > > This series adds a new sockptr_t type that can contained either a kernel > or user pointer, and which has accessors that do the right thing, and > then uses it for setsockopt, starting by refactoring some low-level > helpers and moving them over to it before finally doing the main > setsockopt method. > > Note that apparently the eBPF selftests do not even cover this path, so > the series has been tested with a testing patch that always copies the > data first and passes a kernel pointer. This is something that works for > most common sockopts (and is something that the ePBF support relies on), > but unfortunately in various corner cases we either don't use the passed > in length, or in one case actually copy data back from setsockopt, or in > case of bpfilter straight out do not work with kernel pointers at all. > > Against net-next/master. > > Changes since v1: > - check that users don't pass in kernel addresses > - more bpfilter cleanups > - cosmetic mptcp tweak Series applied to net-next, I'm build testing and will push this out when that is done. Thanks. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aGdULM8qHV8S3gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 26 Jul 2020 09:03:43 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id GB4cK88qHV95aAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 26 Jul 2020 09:03:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 13ADA4E6D1; Sun, 26 Jul 2020 09:03:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726145AbgGZHDT (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 26 Jul 2020 03:03:19 -0400 Received: from verein.lst.de ([213.95.11.211]:39756 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725789AbgGZHDS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 26 Jul 2020 03:03:18 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 2AB2768B05; Sun, 26 Jul 2020 09:03:12 +0200 (CEST) Date: Sun, 26 Jul 2020 09:03:11 +0200 From: Christoph Hellwig <hch@lst.de> To: David Miller <davem@davemloft.net> Cc: hch@lst.de, kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, edumazet@google.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: get rid of the address_space override in setsockopt v2 Message-ID: <20200726070311.GA16687@lst.de> References: <20200723060908.50081-1-hch@lst.de> <20200724.154342.1433271593505001306.davem@davemloft.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200724.154342.1433271593505001306.davem@davemloft.net> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: 13ADA4E6D1 X-Rspamd-UID: 9a565b On Fri, Jul 24, 2020 at 03:43:42PM -0700, David Miller wrote: > > Changes since v1: > > - check that users don't pass in kernel addresses > > - more bpfilter cleanups > > - cosmetic mptcp tweak > > Series applied to net-next, I'm build testing and will push this out when > that is done. The buildbot found one warning with the isdn debug code after a few days, here is what I think is the best fix: --- From 6601732f7a54db5f04efba08f7e9224e5b757112 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig <hch@lst.de> Date: Sun, 26 Jul 2020 09:00:09 +0200 Subject: mISDN: remove a debug printk in data_sock_setsockopt The %p won't work with the new sockptr_t type. But in the times of ftrace, bpftrace and co these kinds of debug printks are pretty anyway, so just remove the whole debug printk. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/isdn/mISDN/socket.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c index 1b2b91479107bc..2c58a6fe6d129e 100644 --- a/drivers/isdn/mISDN/socket.c +++ b/drivers/isdn/mISDN/socket.c @@ -406,10 +406,6 @@ static int data_sock_setsockopt(struct socket *sock, int level, int optname, struct sock *sk = sock->sk; int err = 0, opt = 0; - if (*debug & DEBUG_SOCKET) - printk(KERN_DEBUG "%s(%p, %d, %x, %p, %d)\n", __func__, sock, - level, optname, optval, len); - lock_sock(sk); switch (optname) { -- 2.27.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +OM1NB0sHV/CzQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 26 Jul 2020 09:09:17 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id MEKSMh0sHV+rNQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 26 Jul 2020 09:09:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C4E284081F; Sun, 26 Jul 2020 09:09:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726782AbgGZHJA (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 26 Jul 2020 03:09:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbgGZHI7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 26 Jul 2020 03:08:59 -0400 Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58577C0619D2; Sun, 26 Jul 2020 00:08:59 -0700 (PDT) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4BDvDf0Trdz1rrLW; Sun, 26 Jul 2020 09:08:46 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4BDvDY4g2Xz1qrDX; Sun, 26 Jul 2020 09:08:45 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id M61H8ekLgDni; Sun, 26 Jul 2020 09:08:43 +0200 (CEST) X-Auth-Info: ObXr7NKuP/ed3aOqUP2DwRSFWg3CkaF7qmUDKZFNiwlgCHly/bMVI0yUZSDe+Kon Received: from hase.home (ppp-46-244-174-182.dynamic.mnet-online.de [46.244.174.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 26 Jul 2020 09:08:43 +0200 (CEST) Received: by hase.home (Postfix, from userid 1000) id C79E21028BD; Sun, 26 Jul 2020 09:08:42 +0200 (CEST) From: Andreas Schwab <schwab@linux-m68k.org> To: Christoph Hellwig <hch@lst.de> Cc: David Miller <davem@davemloft.net>, kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, edumazet@google.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: get rid of the address_space override in setsockopt v2 References: <20200723060908.50081-1-hch@lst.de> <20200724.154342.1433271593505001306.davem@davemloft.net> <20200726070311.GA16687@lst.de> X-Yow: -- I can do ANYTHING ... I can even ... SHOPLIFT!! Date: Sun, 26 Jul 2020 09:08:42 +0200 In-Reply-To: <20200726070311.GA16687@lst.de> (Christoph Hellwig's message of "Sun, 26 Jul 2020 09:03:11 +0200") Message-ID: <87imea3g91.fsf@linux-m68k.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: C4E284081F X-Rspamd-UID: 759979 On Jul 26 2020, Christoph Hellwig wrote: > From 6601732f7a54db5f04efba08f7e9224e5b757112 Mon Sep 17 00:00:00 2001 > From: Christoph Hellwig <hch@lst.de> > Date: Sun, 26 Jul 2020 09:00:09 +0200 > Subject: mISDN: remove a debug printk in data_sock_setsockopt > > The %p won't work with the new sockptr_t type. But in the times of > ftrace, bpftrace and co these kinds of debug printks are pretty anyway, I think there is a word missing after pretty. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aH8VIf00HV+HAwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 26 Jul 2020 09:47:09 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id uEbIH/00HV+rNQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 26 Jul 2020 09:47:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1E388A1D3F; Sun, 26 Jul 2020 09:47:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726879AbgGZHqv (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 26 Jul 2020 03:46:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725789AbgGZHqv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 26 Jul 2020 03:46:51 -0400 Received: from shards.monkeyblade.net (shards.monkeyblade.net [IPv6:2620:137:e000::1:9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCC30C0619D2; Sun, 26 Jul 2020 00:46:50 -0700 (PDT) Received: from localhost (unknown [IPv6:2601:601:9f00:477::460]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 9C3271277D61E; Sun, 26 Jul 2020 00:30:02 -0700 (PDT) Date: Sun, 26 Jul 2020 00:46:44 -0700 (PDT) Message-Id: <20200726.004644.71243023033363639.davem@davemloft.net> To: hch@lst.de Cc: kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, edumazet@google.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: get rid of the address_space override in setsockopt v2 From: David Miller <davem@davemloft.net> In-Reply-To: <20200726070311.GA16687@lst.de> References: <20200723060908.50081-1-hch@lst.de> <20200724.154342.1433271593505001306.davem@davemloft.net> <20200726070311.GA16687@lst.de> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sun, 26 Jul 2020 00:30:03 -0700 (PDT) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 16 X-Rspamd-Score: 2.40 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1E388A1D3F X-Rspamd-UID: e1bd6c From: Christoph Hellwig <hch@lst.de> Date: Sun, 26 Jul 2020 09:03:11 +0200 > On Fri, Jul 24, 2020 at 03:43:42PM -0700, David Miller wrote: >> > Changes since v1: >> > - check that users don't pass in kernel addresses >> > - more bpfilter cleanups >> > - cosmetic mptcp tweak >> >> Series applied to net-next, I'm build testing and will push this out when >> that is done. > > The buildbot found one warning with the isdn debug code after a few > days, here is what I think is the best fix: I already fixed this in net-next. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cHtNIcrxHV9ztgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 26 Jul 2020 23:12:42 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yEukH8rxHV8GegAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 26 Jul 2020 23:12:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7277040017; Sun, 26 Jul 2020 23:12:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbgGZVMd (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 26 Jul 2020 17:12:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbgGZVMc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 26 Jul 2020 17:12:32 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85A8CC0619D2 for <linux-bluetooth@vger.kernel.org>; Sun, 26 Jul 2020 14:12:32 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id a15so12903706wrh.10 for <linux-bluetooth@vger.kernel.org>; Sun, 26 Jul 2020 14:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=8tWWy7CL8KthsmlZ1i0YYOB5ajQt3yNa3kK4+sda0s8=; b=RtCnhYOdbtuBmbO4gwfaai9jlnPizsipIW3kpEjFBWX4fs7cC8gJWxwOskPxjyVMX1 VMehiTLw61yYEYqJ0vLokcOLz6pxxvuG643dQFauiitk7oGGMKoOahNweoqjkHg7fIyi 68xyPdc3VVl8MOCmtxFWdXF6m2Gjo6rQ5oQ4fnnBuZZLV259KZhwhC05gARR9DJy3bnW kb84qDPyiJyvnTm25dxhPwOv/ghhkvA9nIp+tQ9pUhL+FEIL0HkHX35iXeKTDdcEhMVc 5Zl1LcsXnFbSrkJxYmL6a0N9E5lIdaRXmkH/bz30ab8ourNR5J39RoJR0ioY/ufoJMvO CQ2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=8tWWy7CL8KthsmlZ1i0YYOB5ajQt3yNa3kK4+sda0s8=; b=n/2OVdtEB2KG7GVHpUTHydiYGLzE9xX37u7xpRUPRvqp/cN32nV6eEO3+nFFZW2WKc GGffo5aQtwKLDYDpfAqeO6dOaobGzH42lZC/LIuNSBFzBnecmZw+I8btB5/lJ+ZAx0bc iCV9NsDMOZAAOqZPUtikeTENa4MWBB+1F7Xjry3jzYv/3fwfVqG0598UuSovW98ypLdk R9RdgqLEEfXzp/TluwfIZQIQ8Ih09nlNiGENlZ6pRK8p67VtmmIe4BDjkKKI/XyiOQmB 4FED8KhcBZ4/D3wHstHV8x0Dco7ouQD2uFMI9mTrOeQMRU5aErtHxOIJ/dFMN+OSbar3 Qw+Q== X-Gm-Message-State: AOAM531pEaPGCnuK7LMT0GC2EmZk1DlHalBndIEdsbqG22acTahi5O2s ecdZrSumR8U1nu5cnYTYaBE= X-Google-Smtp-Source: ABdhPJylt9f1JrMRK5lrnONN2Hp6n30lXdpTs4PdmWUIZQfLR0+e1yhe4T7W8crbzC5//qoby0k38w== X-Received: by 2002:adf:f812:: with SMTP id s18mr8292300wrp.96.1595797950983; Sun, 26 Jul 2020 14:12:30 -0700 (PDT) Received: from 168.52.45.77 (201.ip-51-68-45.eu. [51.68.45.201]) by smtp.gmail.com with ESMTPSA id p15sm9138173wrj.61.2020.07.26.14.12.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 26 Jul 2020 14:12:30 -0700 (PDT) From: Ismael Ferreras Morezuelas <swyterzone@gmail.com> Subject: [PATCH v4] Bluetooth: btusb: Fix and detect most of the Chinese Bluetooth controllers To: BlueZ <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Message-ID: <0bba3f22-a232-3c07-1b05-73e6d38dab8a@gmail.com> Date: Sun, 26 Jul 2020 23:12:28 +0200 User-Agent: nano 6.4 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.59 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7277040017 X-Rspamd-UID: e5853b For some reason they tend to squat on the very first CSR/ Cambridge Silicon Radio VID/PID instead of paying fees. This is an extremely common problem; the issue goes as back as 2013 and these devices are only getting more popular, even rebranded by reputable vendors and sold by retailers everywhere. So, at this point in time there are hundreds of modern dongles reusing the ID of what originally was an early Bluetooth 1.1 controller. Linux is the only place where they don't work due to spotty checks in our detection code. It only covered a minimum subset. So what's the big idea? Take advantage of the fact that all CSR chips report the same internal version as both the LMP sub-version and HCI revision number. It always matches, couple that with the manufacturer code, that rarely lies, and we now have a good idea of who is who. Additionally, by compiling a list of user-reported HCI/lsusb dumps, and searching around for legit CSR dongles in similar product ranges we can find what CSR BlueCore firmware supported which Bluetooth versions. That way we can narrow down ranges of fakes for each of them. e.g. Real CSR dongles with LMP subversion 0x73 are old enough that support BT 1.1 only; so it's a dead giveaway when some third-party BT 4.0 dongle reuses it. So, to sum things up; there are multiple classes of fake controllers reusing the same 0A12:0001 VID/PID. This has been broken for a while. Known 'fake' bcdDevices: 0x0100, 0x0134, 0x1915, 0x2520, 0x7558, 0x8891 IC markings on 0x7558: FR3191AHAL 749H15143 (???) https://bugzilla.kernel.org/show_bug.cgi?id=60824 Fixes: 81cac64ba258ae (Deal with USB devices that are faking CSR vendor) Reported-by: Michał Wiśniewski <brylozketrzyn@gmail.com> Tested-by: Mike Johnson <yuyuyak@gmail.com> Tested-by: Ricardo Rodrigues <ekatonb@gmail.com> Tested-by: M.Hanny Sabbagh <mhsabbagh@outlook.com> Tested-by: Oussama BEN BRAHIM <b.brahim.oussama@gmail.com> Tested-by: Ismael Ferreras Morezuelas <swyterzone@gmail.com> Signed-off-by: Ismael Ferreras Morezuelas <swyterzone@gmail.com> --- Changes in v4: * Chain the is_fake conditions with else ifs. * Properly use le16_to_cpu() when needed. Changes in v3: * Find an even better-er way of detecting which type is which; use the best parts of v1 and v2 and combine them with previous feedback. * Additionally, detect fakes by comparing against real BlueCore firmware numbers and their supported protocol versions. * Introduce HCI_QUIRK_BROKEN_ERR_DATA_REPORTING and use it on all fake chips. It doesn't seem to cause any drawback, and if we make it too specific a lot of these chips won't work at all, so it's probably better than nothing. Other user reported being able to finally pair with their stereo A2DP speaker with this fix. * Limit the use of btusb_setup_csr() only to cover 0A12:0001. * Use bt_dev_warn for the fake detection notice. * Remove all other noisy bt_dev_info() calls. Changes in v2: * Find a better way of detecting which type is which; scrap the wonky >=Bluetooth 1.2 protocol check and instead do what's described above. * Move all the quirk logic to btusb_setup_csr(), simplify it a bit. * Use a switch statement and list all the known broken bcdDevice instead of trying to penalize the real CSR devices. * Add two bt_dev_info() prints because this may be important in the future, given the amount of variables we are playing with here. * Try to keep my comments within a 80-column limit. Now I'm able to pair with Android devices, A2DP headphones, DS4 controllers and more; whereas previously set up failed and userland software couldn't even scan with it. This patch probably uncovers other quirks in some of these previously *unusable* dongles, so it's probably a good start point so that other fixes can be implemented on top. Looking forward to fine-tune these checks in the future. Let me know what you think. drivers/bluetooth/btusb.c | 74 ++++++++++++++++++++++++++----- include/net/bluetooth/bluetooth.h | 2 + include/net/bluetooth/hci.h | 11 +++++ net/bluetooth/hci_core.c | 6 ++- 4 files changed, 81 insertions(+), 12 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 5f022e9cf..5b8cf9ba9 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -1720,6 +1720,7 @@ static int btusb_setup_csr(struct hci_dev *hdev) { struct hci_rp_read_local_version *rp; struct sk_buff *skb; + bool is_fake = false; BT_DBG("%s", hdev->name); @@ -1739,18 +1740,69 @@ static int btusb_setup_csr(struct hci_dev *hdev) rp = (struct hci_rp_read_local_version *)skb->data; - /* Detect controllers which aren't real CSR ones. */ + /* Detect a wide host of Chinese controllers that aren't CSR. + * + * Known fake bcdDevices: 0x0100, 0x0134, 0x1915, 0x2520, 0x7558, 0x8891 + * + * The main thing they have in common is that these are really popular low-cost + * options that support newer Bluetooth versions but rely on heavy VID/PID + * squatting of this poor old Bluetooth 1.1 device. Even sold as such. + * + * We detect actual CSR devices by checking that the HCI manufacturer code + * is Cambridge Silicon Radio (10) and ensuring that LMP sub-version and + * HCI rev values always match. As they both store the firmware number. + */ if (le16_to_cpu(rp->manufacturer) != 10 || - le16_to_cpu(rp->lmp_subver) == 0x0c5c) { + le16_to_cpu(rp->hci_rev) != le16_to_cpu(rp->lmp_subver)) + is_fake = true; + + /* Known legit CSR firmware build numbers and their supported BT versions: + * - 1.1 (0x1) -> 0x0073, 0x020d, 0x033c, 0x034e + * - 1.2 (0x2) -> 0x04d9, 0x0529 + * - 2.0 (0x3) -> 0x07a6, 0x07ad, 0x0c5c + * - 2.1 (0x4) -> 0x149c, 0x1735, 0x1899 (0x1899 is a BlueCore4-External) + * - 4.0 (0x6) -> 0x1d86, 0x2031, 0x22bb + * + * e.g. Real CSR dongles with LMP subversion 0x73 are old enough that + * support BT 1.1 only; so it's a dead giveaway when some + * third-party BT 4.0 dongle reuses it. + */ + else if (le16_to_cpu(rp->lmp_subver) <= 0x034e && + le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_1_1) + is_fake = true; + + else if (le16_to_cpu(rp->lmp_subver) <= 0x0529 && + le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_1_2) + is_fake = true; + + else if (le16_to_cpu(rp->lmp_subver) <= 0x0c5c && + le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_2_0) + is_fake = true; + + else if (le16_to_cpu(rp->lmp_subver) <= 0x1899 && + le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_2_1) + is_fake = true; + + else if (le16_to_cpu(rp->lmp_subver) <= 0x22bb && + le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_4_0) + is_fake = true; + + if (is_fake) { + bt_dev_warn(hdev, "CSR: Unbranded CSR clone detected; adding workarounds..."); + + /* Generally these clones have big discrepancies between + * advertised features and what's actually supported. + * Probably will need to be expanded in the future; + * without these the controller will lock up. + */ + set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks); + set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks); + /* Clear the reset quirk since this is not an actual * early Bluetooth 1.1 device from CSR. */ clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); - - /* These fake CSR controllers have all a broken - * stored link key handling and so just disable it. - */ - set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks); + clear_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); } kfree_skb(skb); @@ -4001,11 +4053,13 @@ static int btusb_probe(struct usb_interface *intf, if (bcdDevice < 0x117) set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); + /* This must be set first in case we disable it for fakes */ + set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); + /* Fake CSR devices with broken commands */ - if (bcdDevice <= 0x100 || bcdDevice == 0x134) + if (le16_to_cpu(udev->descriptor.idVendor) == 0x0a12 && + le16_to_cpu(udev->descriptor.idProduct) == 0x0001) hdev->setup = btusb_setup_csr; - - set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); } if (id->driver_info & BTUSB_SNIFFER) { diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 181900553..155019220 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -41,6 +41,8 @@ #define BLUETOOTH_VER_1_1 1 #define BLUETOOTH_VER_1_2 2 #define BLUETOOTH_VER_2_0 3 +#define BLUETOOTH_VER_2_1 4 +#define BLUETOOTH_VER_4_0 6 /* Reserv for core and drivers use */ #define BT_SKB_RESERVE 8 diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 16ab6ce87..1c321b6d1 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -227,6 +227,17 @@ enum { * supported. */ HCI_QUIRK_VALID_LE_STATES, + + /* When this quirk is set, then erroneous data reporting + * is ignored. This is mainly due to the fact that the HCI + * Read Default Erroneous Data Reporting command is advertised, + * but not supported; these controllers often reply with unknown + * command and tend to lock up randomly. Needing a hard reset. + * + * This quirk can be set before hci_register_dev is called or + * during the hdev->setup vendor callback. + */ + HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, }; /* HCI device flags */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index dbe2d79f2..48d7c7e23 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -606,7 +606,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt) if (hdev->commands[8] & 0x01) hci_req_add(req, HCI_OP_READ_PAGE_SCAN_ACTIVITY, 0, NULL); - if (hdev->commands[18] & 0x04) + if (hdev->commands[18] & 0x04 && + !test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks)) hci_req_add(req, HCI_OP_READ_DEF_ERR_DATA_REPORTING, 0, NULL); /* Some older Broadcom based Bluetooth 1.2 controllers do not @@ -851,7 +852,8 @@ static int hci_init4_req(struct hci_request *req, unsigned long opt) /* Set erroneous data reporting if supported to the wideband speech * setting value */ - if (hdev->commands[18] & 0x08) { + if (hdev->commands[18] & 0x08 && + !test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks)) { bool enabled = hci_dev_test_flag(hdev, HCI_WIDEBAND_SPEECH_ENABLED); -- 2.22.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gCPtNzrIHV+DGAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 26 Jul 2020 20:15:22 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UHvCNTrIHV/wHwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 26 Jul 2020 20:15:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A534BA1B14; Sun, 26 Jul 2020 20:15:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726043AbgGZSPM (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 26 Jul 2020 14:15:12 -0400 Received: from mga11.intel.com ([192.55.52.93]:1932 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbgGZSPL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 26 Jul 2020 14:15:11 -0400 IronPort-SDR: akxNx2+wLokEIUvcLuZMO0ZFUJYCNwcUYn4kPBdRNgmES+fnrHZxmnAjdmmMmx1TMpWTIAkJZY QfKILSp67jzQ== X-IronPort-AV: E=McAfee;i="6000,8403,9694"; a="148802152" X-IronPort-AV: E=Sophos;i="5.75,399,1589266800"; d="scan'208";a="148802152" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2020 10:31:29 -0700 IronPort-SDR: 6rBbUXjeDjYaR/fcnj9Sdag5lXyo3vfEYmKkJcO3at+1ccWkkv9hz9GRFvD2E8Anc21LnEuXju vC7YAo/vSnlg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,399,1589266800"; d="scan'208";a="319811647" Received: from orsmsx103.amr.corp.intel.com ([10.22.225.130]) by orsmga008.jf.intel.com with ESMTP; 26 Jul 2020 10:31:28 -0700 Received: from orsmsx158.amr.corp.intel.com (10.22.240.20) by ORSMSX103.amr.corp.intel.com (10.22.225.130) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 26 Jul 2020 10:31:28 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX158.amr.corp.intel.com (10.22.240.20) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 26 Jul 2020 10:31:28 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.172) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 26 Jul 2020 10:31:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hPd0DPDVAYDZaRoxZZsef9437uObrCP16bGWwW5uE9/kuQdm11yDlDa8t2Q7D7HwKlz7RAuz5g/jiDaExYx5CU5VbyEh1ECTLj1ySayPEZ+D6KJrn9WaHCGzFnl4WulpCB36ObP9ROHia0KmhB2uYCTeRZtVi3Bcc4l/MQTQyCDaIP03sA5Ap7jXE+BJKuRxiXsS7ubSYwlJ3DYFHXyHxelTxOrcgAjpDVSR69siU8B+dWMBqytn4w5uuzSkiP4sYHm7FbO9ZIkwMNnjIik/OQetHWPaxzQ8ppKVZYiO3v637k4OeWPxxoMMl2TMqkin4ibqfKf/69LRojFN59lXtg== 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-SenderADCheck; bh=3a555j+BAAYOhpek7/DFe2JPJu3qdoB9Kmq/LKTgqxs=; b=C0xHMiCfyfqVy7i5tS9EaXpZoIEgxf40BbQG0iHqFQj6Bbp41Lq5lWciVttiVQz/5oBPhfcg/rVuCaCc3AqhT+1DfFKNHjxpHFpe2cwDgInE00Y5HUzCTWl/oxib6wkrFocxIaMhauAAs7hGDGKw8fCWPUb6Kr+GUZOw17oa/GGleDaE/iZjiN7aDYt+micppMA687sdNuLB6BvBCHmAxv/FhKSyYLjh49cJ33ayl5XHTWFfuMhaWcugFqkThtKkN77qn45CPfOA11HWiBqMPUIY523pd9+aWdDnb+MJuIt3HcXxpNqbEn9yVimd1/lGg1US7j6helgJsDT58WkbZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3a555j+BAAYOhpek7/DFe2JPJu3qdoB9Kmq/LKTgqxs=; b=t4dCZ1QMdIw8K4xtml+BAusSKJQZwhRA2tjtbBCYL/bY9kZWYXSKwyHsD9uOWfFXygwh8+goq5pr2B/RF7tvoJxqBA0IKO3saKEQI/BbruuWzAIewbX6FusyP3rPjJXxNNBiEJv5nEgZ4YUN95gywiwJ0oBLsJ3W0wVQcL6mILg= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4540.namprd11.prod.outlook.com (2603:10b6:303:56::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.20; Sun, 26 Jul 2020 17:31:26 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3216.031; Sun, 26 Jul 2020 17:31:26 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ v4] mesh: Move model functionality out of node.c to model.c Thread-Topic: [PATCH BlueZ v4] mesh: Move model functionality out of node.c to model.c Thread-Index: AQHWYTzEIRlpY0mKG0i8Xx4mNVDAnqkaIrKA Date: Sun, 26 Jul 2020 17:31:25 +0000 Message-ID: <25fe2ef248b9f458dde1c5c4645ce1d2a1b97731.camel@intel.com> References: <20200723220021.370600-1-inga.stotland@intel.com> In-Reply-To: <20200723220021.370600-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.39] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2d6d28c8-e475-433a-a3be-08d83189b94a x-ms-traffictypediagnostic: MW3PR11MB4540: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MW3PR11MB4540171BD15C423524A70D63E1750@MW3PR11MB4540.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: mfBTFRLK3vR9W7QdcrY2oNXBwRMU7vmL0Xbif1B0tIJUWpPMKhX5RZD8Sxrkj2iQeV9dTcHyaIUhO0mW4V7PVd4Q6IPRQ7c9lOIYRVaCBjkVj2O45ekSKW/lCOxgJEgHlEFSq2KS77cKwd0sBdcwFfigW2zPNnrHLRbtbp3QivhL7Ix64M4VcwfSO0UjrHSm76eq6MS72WtHX9PIChswwumms0hyrSqYUiqghhPfLGHdjkaDhZTgm2g8txsmUE7dx2bnQnecb+KLnK0XoPeStnyQBlV1RJhgcOK+EeNZ9FrtniLolGcsMWseI9uZRRrvlKf3MjPQTYkADvS2GQjkKQr38UVwQjCqqCHEaaTPTXE2VmFjJslzws3Z7jyc70FX x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(39860400002)(366004)(136003)(346002)(396003)(64756008)(86362001)(71200400001)(36756003)(76116006)(2616005)(66476007)(66556008)(66446008)(478600001)(91956017)(5660300002)(8936002)(6486002)(30864003)(66946007)(8676002)(2906002)(316002)(83380400001)(6636002)(6506007)(6512007)(26005)(186003)(110136005)(2004002)(579004)(559001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: Gp6ysl8RgFO5hwaLsadcuK5HTlbET42DTjcvlZDwpsJrimn4k5gX5+CWkO+ZZW78mlj4LE60GwOYbb5CFGM/OCTYoH4+154fUgcacYm/Sh1mVsvRca0dgnee0RtWD85xHqU5FcyMcNaIXmO7d5dReEnSrFcI07LWkGGri+gzq+5QpAo5A3xH0G14HaPANaprbmkFuXady+d8Jg9DOsdOvu7dcshOwMT6JyGAFGZdNx6FTn6swI+Dn3SqzLdMzWxXYuNs2IYq8+U3hLm4VRamqkfgxgmHYdmms44IjIEDnPwZIdU56TUwUEtAcNDLmbxBSd0XyyH4VK2FzPwqgtkd3/+mUpMfvB2QZnABrFZ28Fnsu7F4ONtWEsiEap8I7PRUSN2PoA9UyzHBFLhdTBLEnBpxqkxIN49Zk9Rybaa2WdJbNjj9yp99Cd5CzsN9GWHht7pb70boS1wl4RP+OFSckb2RG215ziVpfuQnYm0GD5o= Content-Type: text/plain; charset="utf-8" Content-ID: <E61CF27C61F02E429523FD4EA1900188@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d6d28c8-e475-433a-a3be-08d83189b94a X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jul 2020 17:31:25.9841 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: xicDlFvMOFe6W9eKUzxc7aaKZzKSbD/7lH1nK8VLPRDvcLsJdkH+hG9zKKpnb75YLzV6uxmXqOaWf58UJWS7MQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4540 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: A534BA1B14 X-Rspamd-UID: 93ae5a QXBwbGllZA0KT24gVGh1LCAyMDIwLTA3LTIzIGF0IDE1OjAwIC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBUaGlzIG1vdmVzIHRoZSBtb2RlbCByZWxhdGVkIGNvZGUgb3V0IG9mIG5vZGUu YyB0byBtb2RlbC5jIHByb3ZpZGluZw0KPiBmb3IgYmV0dGVyIGZ1bmN0aW9uYWwgc2VwYXJhdGlv biBvZiBtb2R1bGVzLg0KPiANCj4gQWxzbywgdXNlIHRoZSB2YWx1ZSBvZiAweEZGRkYgZm9yIGlu dGVybmFsIHJlcHJlc2VudGF0aW9uIG9mIHZlbmRvciBJRA0KPiBmb3IgQlQgU0lHIGRlZmluZWQg bW9kZWxzLiBUaGlzIGFsbG93cyB0byBtYWludGFpbiBhIHNpbmdsZSBpbnRlcm5hbA0KPiB2ZW5k b3IgSUQgLyBtb2RlbCBJRCBzcGFjZS4NCj4gLS0tDQo+ICBtZXNoL2NmZ21vZC1zZXJ2ZXIuYyAg ICB8IDE3MiArKysrKystLS0tLS0tDQo+ICBtZXNoL2NmZ21vZC5oICAgICAgICAgICB8ICAgNCAr LQ0KPiAgbWVzaC9tZXNoLWNvbmZpZy1qc29uLmMgfCAgIDUgKy0NCj4gIG1lc2gvbW9kZWwuYyAg ICAgICAgICAgIHwgNTQ0ICsrKysrKysrKysrKysrKysrKysrKysrKysrKy0tLS0tLS0tLS0tLS0N Cj4gIG1lc2gvbW9kZWwuaCAgICAgICAgICAgIHwgIDc0ICsrKy0tLQ0KPiAgbWVzaC9ub2RlLmMg ICAgICAgICAgICAgfCAzMTkgKysrKy0tLS0tLS0tLS0tLS0tLS0tLS0NCj4gIG1lc2gvbm9kZS5o ICAgICAgICAgICAgIHwgICA0ICstDQo+ICA3IGZpbGVzIGNoYW5nZWQsIDU0NCBpbnNlcnRpb25z KCspLCA1NzggZGVsZXRpb25zKC0pDQo+IA0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9jZmdtb2Qtc2Vy dmVyLmMgYi9tZXNoL2NmZ21vZC1zZXJ2ZXIuYw0KPiBpbmRleCA5MDQ2YTFhZDkuLjc2NzJhZDNi NiAxMDA2NDQNCj4gLS0tIGEvbWVzaC9jZmdtb2Qtc2VydmVyLmMNCj4gKysrIGIvbWVzaC9jZmdt b2Qtc2VydmVyLmMNCj4gQEAgLTIsNyArMiw3IEBADQo+ICAgKg0KPiAgICogIEJsdWVaIC0gQmx1 ZXRvb3RoIHByb3RvY29sIHN0YWNrIGZvciBMaW51eA0KPiAgICoNCj4gLSAqICBDb3B5cmlnaHQg KEMpIDIwMTgtMjAxOSAgSW50ZWwgQ29ycG9yYXRpb24uIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQo+ ICsgKiAgQ29weXJpZ2h0IChDKSAyMDE4LTIwMjAgIEludGVsIENvcnBvcmF0aW9uLiBBbGwgcmln aHRzIHJlc2VydmVkLg0KPiAgICoNCj4gICAqDQo+ICAgKiAgVGhpcyBsaWJyYXJ5IGlzIGZyZWUg c29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmlidXRlIGl0IGFuZC9vcg0KPiBAQCAtNDIsNyArNDIs NyBAQCBzdGF0aWMgdWludDhfdCBtc2dbTUFYX01TR19MRU5dOw0KPiAgDQo+ICBzdGF0aWMgdm9p ZCBzZW5kX3B1Yl9zdGF0dXMoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgbmV0X2lk eCwNCj4gIAkJCXVpbnQxNl90IHNyYywgdWludDE2X3QgZHN0LA0KPiAtCQkJdWludDhfdCBzdGF0 dXMsIHVpbnQxNl90IGVsZV9hZGRyLCB1aW50MzJfdCBtb2RfaWQsDQo+ICsJCQl1aW50OF90IHN0 YXR1cywgdWludDE2X3QgZWxlX2FkZHIsIHVpbnQzMl90IGlkLA0KPiAgCQkJdWludDE2X3QgcHVi X2FkZHIsIHVpbnQxNl90IGlkeCwgYm9vbCBjcmVkX2ZsYWcsDQo+ICAJCQl1aW50OF90IHR0bCwg dWludDhfdCBwZXJpb2QsIHVpbnQ4X3QgcmV0cmFuc21pdCkNCj4gIHsNCj4gQEAgLTU5LDEyICs1 OSwxMiBAQCBzdGF0aWMgdm9pZCBzZW5kX3B1Yl9zdGF0dXMoc3RydWN0IG1lc2hfbm9kZSAqbm9k ZSwgdWludDE2X3QgbmV0X2lkeCwNCj4gIAltc2dbbisrXSA9IHBlcmlvZDsNCj4gIAltc2dbbisr XSA9IHJldHJhbnNtaXQ7DQo+ICANCj4gLQlpZiAobW9kX2lkID49IFZFTkRPUl9JRF9NQVNLKSB7 DQo+IC0JCWxfcHV0X2xlMTYobW9kX2lkLCBtc2cgKyBuKTsNCj4gKwlpZiAoIUlTX1ZFTkRPUihp ZCkpIHsNCj4gKwkJbF9wdXRfbGUxNihNT0RFTF9JRChpZCksIG1zZyArIG4pOw0KPiAgCQluICs9 IDI7DQo+ICAJfSBlbHNlIHsNCj4gLQkJbF9wdXRfbGUxNihtb2RfaWQgPj4gMTYsIG1zZyArIG4p Ow0KPiAtCQlsX3B1dF9sZTE2KG1vZF9pZCwgbXNnICsgbiArIDIpOw0KPiArCQlsX3B1dF9sZTE2 KFZFTkRPUl9JRChpZCksIG1zZyArIG4pOw0KPiArCQlsX3B1dF9sZTE2KE1PREVMX0lEKGlkKSwg bXNnICsgbiArIDIpOw0KPiAgCQluICs9IDQ7DQo+ICAJfQ0KPiAgDQo+IEBAIC03NiwzNyArNzYs MzUgQEAgc3RhdGljIHZvaWQgY29uZmlnX3B1Yl9nZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwg dWludDE2X3QgbmV0X2lkeCwNCj4gIAkJCQkJdWludDE2X3Qgc3JjLCB1aW50MTZfdCBkc3QsDQo+ ICAJCQkJCWNvbnN0IHVpbnQ4X3QgKnBrdCwgdWludDE2X3Qgc2l6ZSkNCj4gIHsNCj4gLQl1aW50 MzJfdCBtb2RfaWQ7DQo+ICsJdWludDMyX3QgaWQ7DQo+ICAJdWludDE2X3QgZWxlX2FkZHI7DQo+ ICAJc3RydWN0IG1lc2hfbW9kZWxfcHViICpwdWI7DQo+ICAJaW50IHN0YXR1czsNCj4gIA0KPiAg CWlmIChzaXplID09IDQpIHsNCj4gLQkJbW9kX2lkID0gbF9nZXRfbGUxNihwa3QgKyAyKTsNCj4g LQkJbW9kX2lkIHw9IFZFTkRPUl9JRF9NQVNLOw0KPiArCQlpZCA9IFNFVF9JRChTSUdfVkVORE9S LCBsX2dldF9sZTE2KHBrdCArIDIpKTsNCj4gIAl9IGVsc2UgaWYgKHNpemUgPT0gNikgew0KPiAt CQltb2RfaWQgPSBsX2dldF9sZTE2KHBrdCArIDIpIDw8IDE2Ow0KPiAtCQltb2RfaWQgfD0gbF9n ZXRfbGUxNihwa3QgKyA0KTsNCj4gKwkJaWQgPSBTRVRfSUQobF9nZXRfbGUxNihwa3QgKyAyKSwg bF9nZXRfbGUxNihwa3QgKyA0KSk7DQo+ICAJfSBlbHNlDQo+ICAJCXJldHVybjsNCj4gIA0KPiAg CWVsZV9hZGRyID0gbF9nZXRfbGUxNihwa3QpOw0KPiAtCXB1YiA9IG1lc2hfbW9kZWxfcHViX2dl dChub2RlLCBlbGVfYWRkciwgbW9kX2lkLCAmc3RhdHVzKTsNCj4gKwlwdWIgPSBtZXNoX21vZGVs X3B1Yl9nZXQobm9kZSwgZWxlX2FkZHIsIGlkLCAmc3RhdHVzKTsNCj4gIA0KPiAgCWlmIChwdWIg JiYgc3RhdHVzID09IE1FU0hfU1RBVFVTX1NVQ0NFU1MpDQo+ICAJCXNlbmRfcHViX3N0YXR1cyhu b2RlLCBuZXRfaWR4LCBzcmMsIGRzdCwgc3RhdHVzLCBlbGVfYWRkciwNCj4gLQkJCQltb2RfaWQs IHB1Yi0+YWRkciwgcHViLT5pZHgsIHB1Yi0+Y3JlZGVudGlhbCwNCj4gKwkJCQlpZCwgcHViLT5h ZGRyLCBwdWItPmlkeCwgcHViLT5jcmVkZW50aWFsLA0KPiAgCQkJCXB1Yi0+dHRsLCBwdWItPnBl cmlvZCwgcHViLT5yZXRyYW5zbWl0KTsNCj4gIAllbHNlDQo+ICAJCXNlbmRfcHViX3N0YXR1cyhu b2RlLCBuZXRfaWR4LCBzcmMsIGRzdCwgc3RhdHVzLCBlbGVfYWRkciwNCj4gLQkJCQltb2RfaWQs IDAsIDAsIDAsIDAsIDAsIDApOw0KPiArCQkJCWlkLCAwLCAwLCAwLCAwLCAwLCAwKTsNCj4gIH0N Cj4gIA0KPiAgc3RhdGljIHZvaWQgY29uZmlnX3B1Yl9zZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9k ZSwgdWludDE2X3QgbmV0X2lkeCwNCj4gIAkJCQl1aW50MTZfdCBzcmMsIHVpbnQxNl90IGRzdCwN Cj4gIAkJCQljb25zdCB1aW50OF90ICpwa3QsIGJvb2wgdmlydCwgYm9vbCB2ZW5kb3IpDQo+ICB7 DQo+IC0JdWludDMyX3QgbW9kX2lkOw0KPiArCXVpbnQzMl90IGlkOw0KPiAgCXVpbnQxNl90IGVs ZV9hZGRyLCBpZHgsIG90YSA9IFVOQVNTSUdORURfQUREUkVTUzsNCj4gIAljb25zdCB1aW50OF90 ICpwdWJfYWRkcjsNCj4gIAl1aW50MTZfdCB0ZXN0X2FkZHI7DQo+IEBAIC0xMjQsMTIgKzEyMiwx MiBAQCBzdGF0aWMgdm9pZCBjb25maWdfcHViX3NldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1 aW50MTZfdCBuZXRfaWR4LA0KPiAgCXR0bCA9IHBrdFs2XTsNCj4gIAlwZXJpb2QgPSBwa3RbN107 DQo+ICAJcmV0cmFuc21pdCA9IHBrdFs4XTsNCj4gLQltb2RfaWQgPSBsX2dldF9sZTE2KHBrdCAr IDkpOw0KPiArCWlkID0gbF9nZXRfbGUxNihwa3QgKyA5KTsNCj4gIA0KPiAgCWlmICghdmVuZG9y KQ0KPiAtCQltb2RfaWQgfD0gVkVORE9SX0lEX01BU0s7DQo+ICsJCWlkID0gU0VUX0lEKFNJR19W RU5ET1IsIGlkKTsNCj4gIAllbHNlDQo+IC0JCW1vZF9pZCA9IChtb2RfaWQgPDwgMTYpIHwgbF9n ZXRfbGUxNihwa3QgKyAxMSk7DQo+ICsJCWlkID0gU0VUX0lEKGlkLCBsX2dldF9sZTE2KHBrdCAr IDExKSk7DQo+ICANCj4gIAkvKiBEb24ndCBhY2NlcHQgdmlydHVhbCBzZWVtaW5nIGFkZHJlc3Nl cyAqLw0KPiAgCXRlc3RfYWRkciA9IGxfZ2V0X2xlMTYocHViX2FkZHIpOw0KPiBAQCAtMTM5LDE2 ICsxMzcsMTYgQEAgc3RhdGljIHZvaWQgY29uZmlnX3B1Yl9zZXQoc3RydWN0IG1lc2hfbm9kZSAq bm9kZSwgdWludDE2X3QgbmV0X2lkeCwNCj4gIAljcmVkX2ZsYWcgPSAhIShDUkVERkxBR19NQVNL ICYgaWR4KTsNCj4gIAlpZHggJj0gQVBQX0lEWF9NQVNLOw0KPiAgDQo+IC0Jc3RhdHVzID0gbWVz aF9tb2RlbF9wdWJfc2V0KG5vZGUsIGVsZV9hZGRyLCBtb2RfaWQsIHB1Yl9hZGRyLCBpZHgsDQo+ ICsJc3RhdHVzID0gbWVzaF9tb2RlbF9wdWJfc2V0KG5vZGUsIGVsZV9hZGRyLCBpZCwgcHViX2Fk ZHIsIGlkeCwNCj4gIAkJCQkJY3JlZF9mbGFnLCB0dGwsIHBlcmlvZCwgcmV0cmFuc21pdCwNCj4g IAkJCQkJdmlydCwgJm90YSk7DQo+ICANCj4gIAlsX2RlYnVnKCJwdWJfc2V0OiBzdGF0dXMgJWQs IGVhICU0LjR4LCBvdGE6ICU0LjR4LCBtb2Q6ICV4LCBpZHg6ICUzLjN4IiwNCj4gLQkJCQkJc3Rh dHVzLCBlbGVfYWRkciwgb3RhLCBtb2RfaWQsIGlkeCk7DQo+ICsJCQkJCXN0YXR1cywgZWxlX2Fk ZHIsIG90YSwgaWQsIGlkeCk7DQo+ICANCj4gIAlpZiAoc3RhdHVzICE9IE1FU0hfU1RBVFVTX1NV Q0NFU1MpIHsNCj4gIAkJc2VuZF9wdWJfc3RhdHVzKG5vZGUsIG5ldF9pZHgsIHNyYywgZHN0LCBz dGF0dXMsIGVsZV9hZGRyLA0KPiAtCQkJCQkJbW9kX2lkLCAwLCAwLCAwLCAwLCAwLCAwKTsNCj4g KwkJCQkJCWlkLCAwLCAwLCAwLCAwLCAwLCAwKTsNCj4gIA0KPiAgCQlyZXR1cm47DQo+ICAJfQ0K PiBAQCAtMTU4LDcgKzE1Niw3IEBAIHN0YXRpYyB2b2lkIGNvbmZpZ19wdWJfc2V0KHN0cnVjdCBt ZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+ICANCj4gIAkJLyogUmVtb3ZlIG1v ZGVsIHB1YmxpY2F0aW9uIGZyb20gY29uZmlnIGZpbGUgKi8NCj4gIAkJaWYgKCFtZXNoX2NvbmZp Z19tb2RlbF9wdWJfZGVsKG5vZGVfY29uZmlnX2dldChub2RlKSwgZWxlX2FkZHIsDQo+IC0JCQkJ dmVuZG9yID8gbW9kX2lkIDogbW9kX2lkICYgflZFTkRPUl9JRF9NQVNLLA0KPiArCQkJCQkJdmVu ZG9yID8gaWQgOiBNT0RFTF9JRChpZCksDQo+ICAJCQkJCQkJCQl2ZW5kb3IpKQ0KPiAgCQkJc3Rh dHVzID0gTUVTSF9TVEFUVVNfU1RPUkFHRV9GQUlMOw0KPiAgCX0gZWxzZSB7DQo+IEBAIC0xNzgs MTkgKzE3NiwxOSBAQCBzdGF0aWMgdm9pZCBjb25maWdfcHViX3NldChzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlLCB1aW50MTZfdCBuZXRfaWR4LA0KPiAgDQo+ICAJCS8qIFNhdmUgbW9kZWwgcHVibGlj YXRpb24gdG8gY29uZmlnIGZpbGUgKi8NCj4gIAkJaWYgKCFtZXNoX2NvbmZpZ19tb2RlbF9wdWJf YWRkKG5vZGVfY29uZmlnX2dldChub2RlKSwgZWxlX2FkZHIsDQo+IC0JCQkJdmVuZG9yID8gbW9k X2lkIDogbW9kX2lkICYgflZFTkRPUl9JRF9NQVNLLA0KPiAtCQkJCQl2ZW5kb3IsICZkYl9wdWIp KQ0KPiArCQkJCQkJdmVuZG9yID8gaWQgOiBNT0RFTF9JRChpZCksDQo+ICsJCQkJCQkJdmVuZG9y LCAmZGJfcHViKSkNCj4gIAkJCXN0YXR1cyA9IE1FU0hfU1RBVFVTX1NUT1JBR0VfRkFJTDsNCj4g IAl9DQo+ICANCj4gLQlzZW5kX3B1Yl9zdGF0dXMobm9kZSwgbmV0X2lkeCwgc3JjLCBkc3QsIHN0 YXR1cywgZWxlX2FkZHIsIG1vZF9pZCwgb3RhLA0KPiArCXNlbmRfcHViX3N0YXR1cyhub2RlLCBu ZXRfaWR4LCBzcmMsIGRzdCwgc3RhdHVzLCBlbGVfYWRkciwgaWQsIG90YSwNCj4gIAkJCQlpZHgs IGNyZWRfZmxhZywgdHRsLCBwZXJpb2QsIHJldHJhbnNtaXQpOw0KPiAgfQ0KPiAgDQo+ICBzdGF0 aWMgdm9pZCBzZW5kX3N1Yl9zdGF0dXMoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3Qg bmV0X2lkeCwNCj4gIAkJCQkJdWludDE2X3Qgc3JjLCB1aW50MTZfdCBkc3QsDQo+ICAJCQkJCXVp bnQ4X3Qgc3RhdHVzLCB1aW50MTZfdCBlbGVfYWRkciwNCj4gLQkJCQkJdWludDE2X3QgYWRkciwg dWludDMyX3QgbW9kKQ0KPiArCQkJCQl1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCkNCj4gIHsN Cj4gIAlpbnQgbiA9IG1lc2hfbW9kZWxfb3Bjb2RlX3NldChPUF9DT05GSUdfTU9ERUxfU1VCX1NU QVRVUywgbXNnKTsNCj4gIA0KPiBAQCAtMTk5LDEyICsxOTcsMTMgQEAgc3RhdGljIHZvaWQgc2Vu ZF9zdWJfc3RhdHVzKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+ ICAJbiArPSAyOw0KPiAgCWxfcHV0X2xlMTYoYWRkciwgbXNnICsgbik7DQo+ICAJbiArPSAyOw0K PiAtCWlmIChtb2QgPj0gMHgxMDAwMCAmJiBtb2QgPCBWRU5ET1JfSURfTUFTSykgew0KPiAtCQls X3B1dF9sZTE2KG1vZCA+PiAxNiwgbXNnICsgbik7DQo+IC0JCWxfcHV0X2xlMTYobW9kLCBtc2cg KyBuICsgMik7DQo+ICsNCj4gKwlpZiAoSVNfVkVORE9SKGlkKSkgew0KPiArCQlsX3B1dF9sZTE2 KFZFTkRPUl9JRChpZCksIG1zZyArIG4pOw0KPiArCQlsX3B1dF9sZTE2KE1PREVMX0lEKGlkKSwg bXNnICsgbiArIDIpOw0KPiAgCQluICs9IDQ7DQo+ICAJfSBlbHNlIHsNCj4gLQkJbF9wdXRfbGUx Nihtb2QsIG1zZyArIG4pOw0KPiArCQlsX3B1dF9sZTE2KE1PREVMX0lEKGlkKSwgbXNnICsgbik7 DQo+ICAJCW4gKz0gMjsNCj4gIAl9DQo+ICANCj4gQEAgLTIxNyw3ICsyMTYsNyBAQCBzdGF0aWMg Ym9vbCBjb25maWdfc3ViX2dldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBuZXRf aWR4LA0KPiAgCQkJCQljb25zdCB1aW50OF90ICpwa3QsIHVpbnQxNl90IHNpemUpDQo+ICB7DQo+ ICAJdWludDE2X3QgZWxlX2FkZHI7DQo+IC0JdWludDMyX3QgbW9kX2lkOw0KPiArCXVpbnQzMl90 IGlkOw0KPiAgCXVpbnQxNl90IG4gPSAwOw0KPiAgCWludCBzdGF0dXM7DQo+ICAJdWludDhfdCAq bXNnX3N0YXR1czsNCj4gQEAgLTIzMiwzNCArMjMxLDMzIEBAIHN0YXRpYyBib29sIGNvbmZpZ19z dWJfZ2V0KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+ICAJCXJl dHVybiBmYWxzZTsNCj4gIA0KPiAgCWNhc2UgNDoNCj4gLQkJbW9kX2lkID0gbF9nZXRfbGUxNihw a3QgKyAyKTsNCj4gKwkJaWQgPSBsX2dldF9sZTE2KHBrdCArIDIpOw0KPiAgCQluID0gbWVzaF9t b2RlbF9vcGNvZGVfc2V0KE9QX0NPTkZJR19NT0RFTF9TVUJfTElTVCwgbXNnKTsNCj4gIAkJbXNn X3N0YXR1cyA9IG1zZyArIG47DQo+ICAJCW1zZ1tuKytdID0gMDsNCj4gIAkJbF9wdXRfbGUxNihl bGVfYWRkciwgbXNnICsgbik7DQo+ICAJCW4gKz0gMjsNCj4gLQkJbF9wdXRfbGUxNihtb2RfaWQs IG1zZyArIG4pOw0KPiArCQlsX3B1dF9sZTE2KGlkLCBtc2cgKyBuKTsNCj4gIAkJbiArPSAyOw0K PiAtCQltb2RfaWQgfD0gVkVORE9SX0lEX01BU0s7DQo+ICsJCWlkID0gU0VUX0lEKFNJR19WRU5E T1IsIGlkKTsNCj4gIAkJYnJlYWs7DQo+ICANCj4gIAljYXNlIDY6DQo+IC0JCW1vZF9pZCA9IGxf Z2V0X2xlMTYocGt0ICsgMikgPDwgMTY7DQo+IC0JCW1vZF9pZCB8PSBsX2dldF9sZTE2KHBrdCAr IDQpOw0KPiArCQlpZCA9IFNFVF9JRChsX2dldF9sZTE2KHBrdCArIDIpLCBsX2dldF9sZTE2KHBr dCArIDQpKTsNCj4gIAkJbiA9IG1lc2hfbW9kZWxfb3Bjb2RlX3NldChPUF9DT05GSUdfVkVORF9N T0RFTF9TVUJfTElTVCwgbXNnKTsNCj4gIAkJbXNnX3N0YXR1cyA9IG1zZyArIG47DQo+ICAJCW1z Z1tuKytdID0gMDsNCj4gIAkJbF9wdXRfbGUxNihlbGVfYWRkciwgbXNnICsgbik7DQo+ICAJCW4g Kz0gMjsNCj4gLQkJbF9wdXRfbGUxNihtb2RfaWQgPj4gMTYsIG1zZyArIG4pOw0KPiArCQlsX3B1 dF9sZTE2KFZFTkRPUl9JRChpZCksIG1zZyArIG4pOw0KPiAgCQluICs9IDI7DQo+IC0JCWxfcHV0 X2xlMTYobW9kX2lkLCBtc2cgKyBuKTsNCj4gKwkJbF9wdXRfbGUxNihNT0RFTF9JRChpZCksIG1z ZyArIG4pOw0KPiAgCQluICs9IDI7DQo+ICAJCWJyZWFrOw0KPiAgCX0NCj4gIA0KPiAgCWJ1Zl9z aXplID0gc2l6ZW9mKHVpbnQxNl90KSAqIE1BWF9HUlBfUEVSX01PRDsNCj4gLQlzdGF0dXMgPSBt ZXNoX21vZGVsX3N1Yl9nZXQobm9kZSwgZWxlX2FkZHIsIG1vZF9pZCwgbXNnICsgbiwgYnVmX3Np emUsDQo+ICsJc3RhdHVzID0gbWVzaF9tb2RlbF9zdWJfZ2V0KG5vZGUsIGVsZV9hZGRyLCBpZCwg bXNnICsgbiwgYnVmX3NpemUsDQo+ICAJCQkJCQkJCQkmc2l6ZSk7DQo+ICANCj4gIAlpZiAoc3Rh dHVzID09IE1FU0hfU1RBVFVTX1NVQ0NFU1MpDQo+IEBAIC0yNzMsNyArMjcxLDcgQEAgc3RhdGlj IGJvb2wgY29uZmlnX3N1Yl9nZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgbmV0 X2lkeCwNCj4gIH0NCj4gIA0KPiAgc3RhdGljIGJvb2wgc2F2ZV9jb25maWdfc3ViKHN0cnVjdCBt ZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IGVsZV9hZGRyLA0KPiAtCQkJCQl1aW50MzJfdCBtb2Rf aWQsIGJvb2wgdmVuZG9yLA0KPiArCQkJCQl1aW50MzJfdCBpZCwgYm9vbCB2ZW5kb3IsDQo+ICAJ CQkJCWNvbnN0IHVpbnQ4X3QgKmFkZHIsIGJvb2wgdmlydCwNCj4gIAkJCQkJdWludDE2X3QgZ3Jw LCB1aW50MzJfdCBvcGNvZGUpDQo+ICB7DQo+IEBAIC0yODcsMjAgKzI4NSwxOCBAQCBzdGF0aWMg Ym9vbCBzYXZlX2NvbmZpZ19zdWIoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgZWxl X2FkZHIsDQo+ICANCj4gIAlpZiAob3Bjb2RlID09IE9QX0NPTkZJR19NT0RFTF9TVUJfVklSVF9P VkVSV1JJVEUgfHwNCj4gIAkJCQkJb3Bjb2RlID09IE9QX0NPTkZJR19NT0RFTF9TVUJfT1ZFUldS SVRFKQ0KPiAtCQltZXNoX2NvbmZpZ19tb2RlbF9zdWJfZGVsX2FsbChub2RlX2NvbmZpZ19nZXQo bm9kZSksDQo+IC0JCQkJZWxlX2FkZHIsIHZlbmRvciA/IG1vZF9pZCA6IG1vZF9pZCAmIDB4MDAw MGZmZmYsDQo+ICsJCW1lc2hfY29uZmlnX21vZGVsX3N1Yl9kZWxfYWxsKG5vZGVfY29uZmlnX2dl dChub2RlKSwgZWxlX2FkZHIsDQo+ICsJCQkJCQl2ZW5kb3IgPyBpZCA6IE1PREVMX0lEKGlkKSwN Cj4gIAkJCQkJCQkJCXZlbmRvcik7DQo+ICANCj4gIAlpZiAob3Bjb2RlICE9IE9QX0NPTkZJR19N T0RFTF9TVUJfVklSVF9ERUxFVEUgJiYNCj4gIAkJCW9wY29kZSAhPSBPUF9DT05GSUdfTU9ERUxf U1VCX0RFTEVURSkNCj4gIAkJcmV0dXJuIG1lc2hfY29uZmlnX21vZGVsX3N1Yl9hZGQobm9kZV9j b25maWdfZ2V0KG5vZGUpLA0KPiAtCQkJCQllbGVfYWRkciwNCj4gLQkJCQkJdmVuZG9yID8gbW9k X2lkIDogbW9kX2lkICYgMHgwMDAwZmZmZiwNCj4gKwkJCQkJZWxlX2FkZHIsIHZlbmRvciA/IGlk IDogTU9ERUxfSUQoaWQpLA0KPiAgCQkJCQl2ZW5kb3IsICZkYl9zdWIpOw0KPiAgCWVsc2UNCj4g IAkJcmV0dXJuIG1lc2hfY29uZmlnX21vZGVsX3N1Yl9kZWwobm9kZV9jb25maWdfZ2V0KG5vZGUp LA0KPiAtCQkJCQllbGVfYWRkciwNCj4gLQkJCQkJdmVuZG9yID8gbW9kX2lkIDogbW9kX2lkICYg MHgwMDAwZmZmZiwNCj4gKwkJCQkJZWxlX2FkZHIsIHZlbmRvciA/IGlkIDogTU9ERUxfSUQoaWQp LA0KPiAgCQkJCQl2ZW5kb3IsICZkYl9zdWIpOw0KPiAgfQ0KPiAgDQo+IEBAIC0zMTAsNyArMzA2 LDcgQEAgc3RhdGljIHZvaWQgY29uZmlnX3N1Yl9zZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwg dWludDE2X3QgbmV0X2lkeCwNCj4gIAkJCQkJYm9vbCB2aXJ0LCB1aW50MzJfdCBvcGNvZGUpDQo+ ICB7DQo+ICAJdWludDE2X3QgZ3JwLCBlbGVfYWRkcjsNCj4gLQl1aW50MzJfdCBtb2RfaWQ7DQo+ ICsJdWludDMyX3QgaWQ7DQo+ICAJY29uc3QgdWludDhfdCAqYWRkciA9IE5VTEw7DQo+ICAJaW50 IHN0YXR1cyA9IE1FU0hfU1RBVFVTX1NVQ0NFU1M7DQo+ICAJYm9vbCB2ZW5kb3IgPSBmYWxzZTsN Cj4gQEAgLTMyMiw0MCArMzE4LDQwIEBAIHN0YXRpYyB2b2lkIGNvbmZpZ19zdWJfc2V0KHN0cnVj dCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+ICAJY2FzZSA0Og0KPiAgCQlp ZiAob3Bjb2RlICE9IE9QX0NPTkZJR19NT0RFTF9TVUJfREVMRVRFX0FMTCkNCj4gIAkJCXJldHVy bjsNCj4gLQkJbW9kX2lkID0gbF9nZXRfbGUxNihwa3QgKyAyKTsNCj4gLQkJbW9kX2lkIHw9IFZF TkRPUl9JRF9NQVNLOw0KPiArDQo+ICsJCWlkID0gU0VUX0lEKFNJR19WRU5ET1IsIGxfZ2V0X2xl MTYocGt0ICsgMikpOw0KPiAgCQlicmVhazsNCj4gIAljYXNlIDY6DQo+ICAJCWlmICh2aXJ0KQ0K PiAgCQkJcmV0dXJuOw0KPiArDQo+ICAJCWlmIChvcGNvZGUgIT0gT1BfQ09ORklHX01PREVMX1NV Ql9ERUxFVEVfQUxMKSB7DQo+IC0JCQltb2RfaWQgPSBsX2dldF9sZTE2KHBrdCArIDQpOw0KPiAt CQkJbW9kX2lkIHw9IFZFTkRPUl9JRF9NQVNLOw0KPiArCQkJaWQgPSBTRVRfSUQoU0lHX1ZFTkRP UiwgbF9nZXRfbGUxNihwa3QgKyA0KSk7DQo+ICAJCX0gZWxzZSB7DQo+IC0JCQltb2RfaWQgPSBs X2dldF9sZTE2KHBrdCArIDIpIDw8IDE2Ow0KPiAtCQkJbW9kX2lkIHw9IGxfZ2V0X2xlMTYocGt0 ICsgNCk7DQo+ICsJCQlpZCA9IFNFVF9JRChsX2dldF9sZTE2KHBrdCArIDIpLCBsX2dldF9sZTE2 KHBrdCArIDQpKTsNCj4gIAkJCXZlbmRvciA9IHRydWU7DQo+ICAJCX0NCj4gKw0KPiAgCQlicmVh azsNCj4gIAljYXNlIDg6DQo+ICAJCWlmICh2aXJ0KQ0KPiAgCQkJcmV0dXJuOw0KPiAtCQltb2Rf aWQgPSBsX2dldF9sZTE2KHBrdCArIDQpIDw8IDE2Ow0KPiAtCQltb2RfaWQgfD0gbF9nZXRfbGUx Nihwa3QgKyA2KTsNCj4gKw0KPiArCQlpZCA9IFNFVF9JRChsX2dldF9sZTE2KHBrdCArIDQpLCBs X2dldF9sZTE2KHBrdCArIDYpKTsNCj4gIAkJdmVuZG9yID0gdHJ1ZTsNCj4gIAkJYnJlYWs7DQo+ ICAJY2FzZSAyMDoNCj4gIAkJaWYgKCF2aXJ0KQ0KPiAgCQkJcmV0dXJuOw0KPiAtCQltb2RfaWQg PSBsX2dldF9sZTE2KHBrdCArIDE4KTsNCj4gLQkJbW9kX2lkIHw9IFZFTkRPUl9JRF9NQVNLOw0K PiArDQo+ICsJCWlkID0gU0VUX0lEKFNJR19WRU5ET1IsIGxfZ2V0X2xlMTYocGt0ICsgMTgpKTsN Cj4gIAkJYnJlYWs7DQo+ICAJY2FzZSAyMjoNCj4gIAkJaWYgKCF2aXJ0KQ0KPiAgCQkJcmV0dXJu Ow0KPiArDQo+ICAJCXZlbmRvciA9IHRydWU7DQo+IC0JCW1vZF9pZCA9IGxfZ2V0X2xlMTYocGt0 ICsgMTgpIDw8IDE2Ow0KPiAtCQltb2RfaWQgfD0gbF9nZXRfbGUxNihwa3QgKyAyMCk7DQo+ICsJ CWlkID0gU0VUX0lEKGxfZ2V0X2xlMTYocGt0ICsgMTgpLCBsX2dldF9sZTE2KHBrdCArIDIwKSk7 DQo+ICAJCWJyZWFrOw0KPiAgCX0NCj4gIA0KPiBAQCAtMzczLDExICszNjksMTEgQEAgc3RhdGlj IHZvaWQgY29uZmlnX3N1Yl9zZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgbmV0 X2lkeCwNCj4gIAkJcmV0dXJuOw0KPiAgDQo+ICAJY2FzZSBPUF9DT05GSUdfTU9ERUxfU1VCX0RF TEVURV9BTEw6DQo+IC0JCXN0YXR1cyA9IG1lc2hfbW9kZWxfc3ViX2RlbF9hbGwobm9kZSwgZWxl X2FkZHIsIG1vZF9pZCk7DQo+ICsJCXN0YXR1cyA9IG1lc2hfbW9kZWxfc3ViX2RlbF9hbGwobm9k ZSwgZWxlX2FkZHIsIGlkKTsNCj4gIA0KPiAgCQlpZiAoc3RhdHVzID09IE1FU0hfU1RBVFVTX1NV Q0NFU1MpDQo+ICAJCQltZXNoX2NvbmZpZ19tb2RlbF9zdWJfZGVsX2FsbChub2RlX2NvbmZpZ19n ZXQobm9kZSksDQo+IC0JCQkJZWxlX2FkZHIsIHZlbmRvciA/IG1vZF9pZCA6IG1vZF9pZCAmIDB4 MDAwMGZmZmYsDQo+ICsJCQkJCWVsZV9hZGRyLCB2ZW5kb3IgPyBpZCA6IE1PREVMX0lEKGlkKSwN Cj4gIAkJCQkJCQkJCXZlbmRvcik7DQo+ICAJCWJyZWFrOw0KPiAgDQo+IEBAIC0zODUsMjIgKzM4 MSwyMiBAQCBzdGF0aWMgdm9pZCBjb25maWdfc3ViX3NldChzdHJ1Y3QgbWVzaF9ub2RlICpub2Rl LCB1aW50MTZfdCBuZXRfaWR4LA0KPiAgCQlncnAgPSBVTkFTU0lHTkVEX0FERFJFU1M7DQo+ICAJ CS8qIEZhbGwgVGhyb3VnaCAqLw0KPiAgCWNhc2UgT1BfQ09ORklHX01PREVMX1NVQl9PVkVSV1JJ VEU6DQo+IC0JCXN0YXR1cyA9IG1lc2hfbW9kZWxfc3ViX292cihub2RlLCBlbGVfYWRkciwgbW9k X2lkLA0KPiArCQlzdGF0dXMgPSBtZXNoX21vZGVsX3N1Yl9vdnIobm9kZSwgZWxlX2FkZHIsIGlk LA0KPiAgCQkJCQkJCWFkZHIsIHZpcnQsICZncnApOw0KPiAgDQo+ICAJCWlmIChzdGF0dXMgPT0g TUVTSF9TVEFUVVNfU1VDQ0VTUykNCj4gLQkJCXNhdmVfY29uZmlnX3N1Yihub2RlLCBlbGVfYWRk ciwgbW9kX2lkLCB2ZW5kb3IsIGFkZHIsDQo+ICsJCQlzYXZlX2NvbmZpZ19zdWIobm9kZSwgZWxl X2FkZHIsIGlkLCB2ZW5kb3IsIGFkZHIsDQo+ICAJCQkJCQkJdmlydCwgZ3JwLCBvcGNvZGUpOw0K PiAgCQlicmVhazsNCj4gIAljYXNlIE9QX0NPTkZJR19NT0RFTF9TVUJfVklSVF9BREQ6DQo+ICAJ CWdycCA9IFVOQVNTSUdORURfQUREUkVTUzsNCj4gIAkJLyogRmFsbCBUaHJvdWdoICovDQo+ICAJ Y2FzZSBPUF9DT05GSUdfTU9ERUxfU1VCX0FERDoNCj4gLQkJc3RhdHVzID0gbWVzaF9tb2RlbF9z dWJfYWRkKG5vZGUsIGVsZV9hZGRyLCBtb2RfaWQsDQo+ICsJCXN0YXR1cyA9IG1lc2hfbW9kZWxf c3ViX2FkZChub2RlLCBlbGVfYWRkciwgaWQsDQo+ICAJCQkJCQkJYWRkciwgdmlydCwgJmdycCk7 DQo+ICANCj4gIAkJaWYgKHN0YXR1cyA9PSBNRVNIX1NUQVRVU19TVUNDRVNTICYmDQo+IC0JCQkJ IXNhdmVfY29uZmlnX3N1Yihub2RlLCBlbGVfYWRkciwgbW9kX2lkLCB2ZW5kb3IsDQo+ICsJCQkJ IXNhdmVfY29uZmlnX3N1Yihub2RlLCBlbGVfYWRkciwgaWQsIHZlbmRvciwNCj4gIAkJCQkJCWFk ZHIsIHZpcnQsIGdycCwgb3Bjb2RlKSkNCj4gIAkJCXN0YXR1cyA9IE1FU0hfU1RBVFVTX1NUT1JB R0VfRkFJTDsNCj4gIA0KPiBAQCAtNDA5LDE3ICs0MDUsMTcgQEAgc3RhdGljIHZvaWQgY29uZmln X3N1Yl9zZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgbmV0X2lkeCwNCj4gIAkJ Z3JwID0gVU5BU1NJR05FRF9BRERSRVNTOw0KPiAgCQkvKiBGYWxsIFRocm91Z2ggKi8NCj4gIAlj YXNlIE9QX0NPTkZJR19NT0RFTF9TVUJfREVMRVRFOg0KPiAtCQlzdGF0dXMgPSBtZXNoX21vZGVs X3N1Yl9kZWwobm9kZSwgZWxlX2FkZHIsIG1vZF9pZCwgYWRkciwgdmlydCwNCj4gKwkJc3RhdHVz ID0gbWVzaF9tb2RlbF9zdWJfZGVsKG5vZGUsIGVsZV9hZGRyLCBpZCwgYWRkciwgdmlydCwNCj4g IAkJCQkJCQkJCSZncnApOw0KPiAgDQo+ICAJCWlmIChzdGF0dXMgPT0gTUVTSF9TVEFUVVNfU1VD Q0VTUykNCj4gLQkJCXNhdmVfY29uZmlnX3N1Yihub2RlLCBlbGVfYWRkciwgbW9kX2lkLCB2ZW5k b3IsIGFkZHIsDQo+ICsJCQlzYXZlX2NvbmZpZ19zdWIobm9kZSwgZWxlX2FkZHIsIGlkLCB2ZW5k b3IsIGFkZHIsDQo+ICAJCQkJCQkJdmlydCwgZ3JwLCBvcGNvZGUpOw0KPiAgDQo+ICAJCWJyZWFr Ow0KPiAgCX0NCj4gIA0KPiAtCXNlbmRfc3ViX3N0YXR1cyhub2RlLCBuZXRfaWR4LCBzcmMsIGRz dCwgc3RhdHVzLCBlbGVfYWRkciwgZ3JwLCBtb2RfaWQpOw0KPiArCXNlbmRfc3ViX3N0YXR1cyhu b2RlLCBuZXRfaWR4LCBzcmMsIGRzdCwgc3RhdHVzLCBlbGVfYWRkciwgZ3JwLCBpZCk7DQo+ICB9 DQo+ICANCj4gIHN0YXRpYyB2b2lkIHNlbmRfbW9kZWxfYXBwX3N0YXR1cyhzdHJ1Y3QgbWVzaF9u b2RlICpub2RlLCB1aW50MTZfdCBuZXRfaWR4LA0KPiBAQCAtNDM0LDExICs0MzAsMTMgQEAgc3Rh dGljIHZvaWQgc2VuZF9tb2RlbF9hcHBfc3RhdHVzKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVp bnQxNl90IG5ldF9pZHgsDQo+ICAJbiArPSAyOw0KPiAgCWxfcHV0X2xlMTYoaWR4LCBtc2cgKyBu KTsNCj4gIAluICs9IDI7DQo+IC0JaWYgKGlkID49IDB4MTAwMDAgJiYgaWQgPCBWRU5ET1JfSURf TUFTSykgew0KPiAtCQlsX3B1dF9sZTE2KGlkID4+IDE2LCBtc2cgKyBuKTsNCj4gKw0KPiArCWlm IChJU19WRU5ET1IoaWQpKSB7DQo+ICsJCWxfcHV0X2xlMTYoVkVORE9SX0lEKGlkKSwgbXNnICsg bik7DQo+ICAJCW4gKz0gMjsNCj4gIAl9DQo+IC0JbF9wdXRfbGUxNihpZCwgbXNnICsgbik7DQo+ ICsNCj4gKwlsX3B1dF9sZTE2KE1PREVMX0lEKGlkKSwgbXNnICsgbik7DQo+ICAJbiArPSAyOw0K PiAgDQo+ICAJbWVzaF9tb2RlbF9zZW5kKG5vZGUsIGRzdCwgc3JjLCBBUFBfSURYX0RFVl9MT0NB TCwgbmV0X2lkeCwgREVGQVVMVF9UVEwsDQo+IEBAIC00NTAsNyArNDQ4LDcgQEAgc3RhdGljIHZv aWQgbW9kZWxfYXBwX2xpc3Qoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgbmV0X2lk eCwNCj4gIAkJCQkJY29uc3QgdWludDhfdCAqcGt0LCB1aW50MTZfdCBzaXplKQ0KPiAgew0KPiAg CXVpbnQxNl90IGVsZV9hZGRyOw0KPiAtCXVpbnQzMl90IG1vZF9pZCA9IDB4ZmZmZjsNCj4gKwl1 aW50MzJfdCBpZDsNCj4gIAl1aW50OF90ICpzdGF0dXM7DQo+ICAJdWludDE2X3QgbjsNCj4gIAlp bnQgcmVzdWx0Ow0KPiBAQCAtNDYzLDI3ICs0NjEsMjUgQEAgc3RhdGljIHZvaWQgbW9kZWxfYXBw X2xpc3Qoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgbmV0X2lkeCwNCj4gIAljYXNl IDQ6DQo+ICAJCW4gPSBtZXNoX21vZGVsX29wY29kZV9zZXQoT1BfTU9ERUxfQVBQX0xJU1QsIG1z Zyk7DQo+ICAJCXN0YXR1cyA9IG1zZyArIG47DQo+IC0JCW1vZF9pZCA9IGxfZ2V0X2xlMTYocGt0 ICsgMik7DQo+ICsJCWlkID0gbF9nZXRfbGUxNihwa3QgKyAyKTsNCj4gIAkJbF9wdXRfbGUxNihl bGVfYWRkciwgbXNnICsgMSArIG4pOw0KPiAtCQlsX3B1dF9sZTE2KG1vZF9pZCwgbXNnICsgMyAr IG4pOw0KPiAtCQltb2RfaWQgfD0gVkVORE9SX0lEX01BU0s7DQo+ICsJCWxfcHV0X2xlMTYoKHVp bnQxNl90KSBpZCwgbXNnICsgMyArIG4pOw0KPiArCQlpZCA9IFNFVF9JRChTSUdfVkVORE9SLCBp ZCk7DQo+ICAJCW4gKz0gNTsNCj4gIAkJYnJlYWs7DQo+ICAJY2FzZSA2Og0KPiAgCQluID0gbWVz aF9tb2RlbF9vcGNvZGVfc2V0KE9QX1ZFTkRfTU9ERUxfQVBQX0xJU1QsIG1zZyk7DQo+ICAJCXN0 YXR1cyA9IG1zZyArIG47DQo+IC0JCW1vZF9pZCA9IGxfZ2V0X2xlMTYocGt0ICsgMikgPDwgMTY7 DQo+IC0JCW1vZF9pZCB8PSBsX2dldF9sZTE2KHBrdCArIDQpOw0KPiArCQlpZCA9IFNFVF9JRChs X2dldF9sZTE2KHBrdCArIDIpLCBsX2dldF9sZTE2KHBrdCArIDQpKTsNCj4gIA0KPiAgCQlsX3B1 dF9sZTE2KGVsZV9hZGRyLCBtc2cgKyAxICsgbik7DQo+IC0JCWxfcHV0X2xlMTYobW9kX2lkID4+ IDE2LCBtc2cgKyAzICsgbik7DQo+IC0JCWxfcHV0X2xlMTYobW9kX2lkLCBtc2cgKyA1ICsgbik7 DQo+ICsJCWxfcHV0X2xlMTYoKHVpbnQxNl90KSBWRU5ET1JfSUQoaWQpLCBtc2cgKyAzICsgbik7 DQo+ICsJCWxfcHV0X2xlMTYoKHVpbnQxNl90KSBNT0RFTF9JRChpZCksIG1zZyArIDUgKyBuKTsN Cj4gIAkJbiArPSA3Ow0KPiAgCQlicmVhazsNCj4gIAl9DQo+ICANCj4gLQ0KPiAtCXJlc3VsdCA9 IG1lc2hfbW9kZWxfZ2V0X2JpbmRpbmdzKG5vZGUsIGVsZV9hZGRyLCBtb2RfaWQsIG1zZyArIG4s DQo+ICsJcmVzdWx0ID0gbWVzaF9tb2RlbF9nZXRfYmluZGluZ3Mobm9kZSwgZWxlX2FkZHIsIGlk LCBtc2cgKyBuLA0KPiAgCQkJCQkJTUFYX01TR19MRU4gLSBuLCAmc2l6ZSk7DQo+ICAJbiArPSBz aXplOw0KPiAgDQo+IEBAIC01MDAsNyArNDk2LDcgQEAgc3RhdGljIGJvb2wgbW9kZWxfYXBwX2Jp bmQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgbmV0X2lkeCwNCj4gIAkJCQkJYm9v bCB1bmJpbmQpDQo+ICB7DQo+ICAJdWludDE2X3QgZWxlX2FkZHI7DQo+IC0JdWludDMyX3QgbW9k X2lkOw0KPiArCXVpbnQzMl90IGlkOw0KPiAgCXVpbnQxNl90IGlkeDsNCj4gIAlpbnQgcmVzdWx0 Ow0KPiAgDQo+IEBAIC01MDksMTIgKzUwNSwxMCBAQCBzdGF0aWMgYm9vbCBtb2RlbF9hcHBfYmlu ZChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBuZXRfaWR4LA0KPiAgCQlyZXR1cm4g ZmFsc2U7DQo+ICANCj4gIAljYXNlIDY6DQo+IC0JCW1vZF9pZCA9IGxfZ2V0X2xlMTYocGt0ICsg NCk7DQo+IC0JCW1vZF9pZCB8PSBWRU5ET1JfSURfTUFTSzsNCj4gKwkJaWQgPSBTRVRfSUQoU0lH X1ZFTkRPUiwgbF9nZXRfbGUxNihwa3QgKyA0KSk7DQo+ICAJCWJyZWFrOw0KPiAgCWNhc2UgODoN Cj4gLQkJbW9kX2lkID0gbF9nZXRfbGUxNihwa3QgKyA0KSA8PCAxNjsNCj4gLQkJbW9kX2lkIHw9 IGxfZ2V0X2xlMTYocGt0ICsgNik7DQo+ICsJCWlkID0gU0VUX0lEKGxfZ2V0X2xlMTYocGt0ICsg NCksIGxfZ2V0X2xlMTYocGt0ICsgNikpOw0KPiAgCQlicmVhazsNCj4gIAl9DQo+ICANCj4gQEAg LTUyNSwxMiArNTE5LDEyIEBAIHN0YXRpYyBib29sIG1vZGVsX2FwcF9iaW5kKHN0cnVjdCBtZXNo X25vZGUgKm5vZGUsIHVpbnQxNl90IG5ldF9pZHgsDQo+ICAJCXJldHVybiBmYWxzZTsNCj4gIA0K PiAgCWlmICh1bmJpbmQpDQo+IC0JCXJlc3VsdCA9IG1lc2hfbW9kZWxfYmluZGluZ19kZWwobm9k ZSwgZWxlX2FkZHIsIG1vZF9pZCwgaWR4KTsNCj4gKwkJcmVzdWx0ID0gbWVzaF9tb2RlbF9iaW5k aW5nX2RlbChub2RlLCBlbGVfYWRkciwgaWQsIGlkeCk7DQo+ICAJZWxzZQ0KPiAtCQlyZXN1bHQg PSBtZXNoX21vZGVsX2JpbmRpbmdfYWRkKG5vZGUsIGVsZV9hZGRyLCBtb2RfaWQsIGlkeCk7DQo+ ICsJCXJlc3VsdCA9IG1lc2hfbW9kZWxfYmluZGluZ19hZGQobm9kZSwgZWxlX2FkZHIsIGlkLCBp ZHgpOw0KPiAgDQo+ICAJc2VuZF9tb2RlbF9hcHBfc3RhdHVzKG5vZGUsIG5ldF9pZHgsIHNyYywg ZHN0LCByZXN1bHQsIGVsZV9hZGRyLA0KPiAtCQkJCQkJCQltb2RfaWQsIGlkeCk7DQo+ICsJCQkJ CQkJCWlkLCBpZHgpOw0KPiAgDQo+ICAJcmV0dXJuIHRydWU7DQo+ICB9DQo+IGRpZmYgLS1naXQg YS9tZXNoL2NmZ21vZC5oIGIvbWVzaC9jZmdtb2QuaA0KPiBpbmRleCAzODNmZGJmNmIuLjdiNmE5 NTgwNyAxMDA2NDQNCj4gLS0tIGEvbWVzaC9jZmdtb2QuaA0KPiArKysgYi9tZXNoL2NmZ21vZC5o DQo+IEBAIC0xNyw4ICsxNyw4IEBADQo+ICAgKg0KPiAgICovDQo+ICANCj4gLSNkZWZpbmUgQ09O RklHX1NSVl9NT0RFTAkoVkVORE9SX0lEX01BU0sgfCAweDAwMDApDQo+IC0jZGVmaW5lIENPTkZJ R19DTElfTU9ERUwJKFZFTkRPUl9JRF9NQVNLIHwgMHgwMDAxKQ0KPiArI2RlZmluZSBDT05GSUdf U1JWX01PREVMCVNFVF9JRChTSUdfVkVORE9SLCAweDAwMDApDQo+ICsjZGVmaW5lIENPTkZJR19D TElfTU9ERUwJU0VUX0lEKFNJR19WRU5ET1IsIDB4MDAwMSkNCj4gIA0KPiAgLyogTmV3IExpc3Qg Ki8NCj4gICNkZWZpbmUgT1BfQVBQS0VZX0FERAkJCQkweDAwDQo+IGRpZmYgLS1naXQgYS9tZXNo L21lc2gtY29uZmlnLWpzb24uYyBiL21lc2gvbWVzaC1jb25maWctanNvbi5jDQo+IGluZGV4IDg4 ZjcxNWZjMS4uZGViMDAxOWY5IDEwMDY0NA0KPiAtLS0gYS9tZXNoL21lc2gtY29uZmlnLWpzb24u Yw0KPiArKysgYi9tZXNoL21lc2gtY29uZmlnLWpzb24uYw0KPiBAQCAtMTEyNiwxOCArMTEyNiwx NSBAQCBzdGF0aWMgYm9vbCBwYXJzZV9tb2RlbHMoanNvbl9vYmplY3QgKmptb2RlbHMsIHN0cnVj dCBtZXNoX2NvbmZpZ19lbGVtZW50ICplbGUpDQo+ICAJCQlpZiAoc3NjYW5mKHN0ciwgIiUwNHgi LCAmaWQpICE9IDEpDQo+ICAJCQkJZ290byBmYWlsOw0KPiAgDQo+IC0JCQlpZCB8PSBWRU5ET1Jf SURfTUFTSzsNCj4gIAkJfSBlbHNlIGlmIChsZW4gPT0gOCkgew0KPiAgCQkJaWYgKHNzY2FuZihz dHIsICIlMDh4IiwgJmlkKSAhPSAxKQ0KPiAgCQkJCWdvdG8gZmFpbDsNCj4gKwkJCW1vZC0+dmVu ZG9yID0gdHJ1ZTsNCj4gIAkJfSBlbHNlDQo+ICAJCQlnb3RvIGZhaWw7DQo+ICANCj4gIAkJbW9k LT5pZCA9IGlkOw0KPiAgDQo+IC0JCWlmIChsZW4gPT0gOCkNCj4gLQkJCW1vZC0+dmVuZG9yID0g dHJ1ZTsNCj4gLQ0KPiAgCQlpZiAoanNvbl9vYmplY3Rfb2JqZWN0X2dldF9leChqbW9kZWwsICJi aW5kIiwgJmphcnJheSkpIHsNCj4gIAkJCWlmIChqc29uX29iamVjdF9nZXRfdHlwZShqYXJyYXkp ICE9IGpzb25fdHlwZV9hcnJheSB8fA0KPiAgCQkJCQkhcGFyc2VfYmluZGluZ3MoamFycmF5LCBt b2QpKQ0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9tb2RlbC5jIGIvbWVzaC9tb2RlbC5jDQo+IGluZGV4 IGFmYWM2ZWM2OS4uMzExOTdiMzYzIDEwMDY0NA0KPiAtLS0gYS9tZXNoL21vZGVsLmMNCj4gKysr IGIvbWVzaC9tb2RlbC5jDQo+IEBAIC0yLDcgKzIsNyBAQA0KPiAgICoNCj4gICAqICBCbHVlWiAt IEJsdWV0b290aCBwcm90b2NvbCBzdGFjayBmb3IgTGludXgNCj4gICAqDQo+IC0gKiAgQ29weXJp Z2h0IChDKSAyMDE4LTIwMTkgIEludGVsIENvcnBvcmF0aW9uLiBBbGwgcmlnaHRzIHJlc2VydmVk Lg0KPiArICogIENvcHlyaWdodCAoQykgMjAxOC0yMDIwICBJbnRlbCBDb3Jwb3JhdGlvbi4gQWxs IHJpZ2h0cyByZXNlcnZlZC4NCj4gICAqDQo+ICAgKg0KPiAgICogIFRoaXMgbGlicmFyeSBpcyBm cmVlIHNvZnR3YXJlOyB5b3UgY2FuIHJlZGlzdHJpYnV0ZSBpdCBhbmQvb3INCj4gQEAgLTU0LDcg KzU0LDYgQEAgc3RydWN0IG1lc2hfbW9kZWwgew0KPiAgCWJvb2wgc3ViX2VuYWJsZWQ7DQo+ICAJ Ym9vbCBwdWJfZW5hYmxlZDsNCj4gIAl1aW50MzJfdCBpZDsNCj4gLQl1aW50OF90IGVsZV9pZHg7 DQo+ICB9Ow0KPiAgDQo+ICBzdHJ1Y3QgbWVzaF92aXJ0dWFsIHsNCj4gQEAgLTEzMSw0NCArMTMw LDQyIEBAIHN0YXRpYyBib29sIGZpbmRfdmlydF9ieV9sYWJlbChjb25zdCB2b2lkICphLCBjb25z dCB2b2lkICpiKQ0KPiAgDQo+ICBzdGF0aWMgYm9vbCBtYXRjaF9tb2RlbF9pZChjb25zdCB2b2lk ICphLCBjb25zdCB2b2lkICpiKQ0KPiAgew0KPiAtCWNvbnN0IHN0cnVjdCBtZXNoX21vZGVsICpt b2RlbCA9IGE7DQo+ICsJY29uc3Qgc3RydWN0IG1lc2hfbW9kZWwgKm1vZCA9IGE7DQo+ICAJdWlu dDMyX3QgaWQgPSBMX1BUUl9UT19VSU5UKGIpOw0KPiAgDQo+IC0JcmV0dXJuIChtZXNoX21vZGVs X2dldF9tb2RlbF9pZChtb2RlbCkgPT0gaWQpOw0KPiArCXJldHVybiAobW9kLT5pZCA9PSBpZCk7 DQo+ICB9DQo+ICANCj4gLXN0YXRpYyBzdHJ1Y3QgbWVzaF9tb2RlbCAqZ2V0X21vZGVsKHN0cnVj dCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgZWxlX2lkeCwNCj4gLQkJCQkJCXVpbnQzMl90IGlk LCBpbnQgKnN0YXR1cykNCj4gK3N0YXRpYyBpbnQgY29tcGFyZV9tb2RlbF9pZChjb25zdCB2b2lk ICphLCBjb25zdCB2b2lkICpiLCB2b2lkICp1c2VyX2RhdGEpDQo+ICB7DQo+IC0Jc3RydWN0IGxf cXVldWUgKm1vZGVsczsNCj4gLQlzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kZWw7DQo+ICsJY29uc3Qg c3RydWN0IG1lc2hfbW9kZWwgKm1vZF9hID0gYTsNCj4gKwljb25zdCBzdHJ1Y3QgbWVzaF9tb2Rl bCAqbW9kX2IgPSBiOw0KPiAgDQo+IC0JbW9kZWxzID0gbm9kZV9nZXRfZWxlbWVudF9tb2RlbHMo bm9kZSwgZWxlX2lkeCwgc3RhdHVzKTsNCj4gLQlpZiAoIW1vZGVscykgew0KPiAtCQkqc3RhdHVz ID0gTUVTSF9TVEFUVVNfSU5WQUxJRF9NT0RFTDsNCj4gLQkJcmV0dXJuIE5VTEw7DQo+IC0JfQ0K PiAtDQo+IC0JbW9kZWwgPSBsX3F1ZXVlX2ZpbmQobW9kZWxzLCBtYXRjaF9tb2RlbF9pZCwgTF9V SU5UX1RPX1BUUihpZCkpOw0KPiArCWlmIChtb2RfYS0+aWQgPCBtb2RfYi0+aWQpDQo+ICsJCXJl dHVybiAtMTsNCj4gIA0KPiAtCSpzdGF0dXMgPSAobW9kZWwpID8gTUVTSF9TVEFUVVNfU1VDQ0VT UyA6IE1FU0hfU1RBVFVTX0lOVkFMSURfTU9ERUw7DQo+ICsJaWYgKG1vZF9hLT5pZCA+IG1vZF9i LT5pZCkNCj4gKwkJcmV0dXJuIDE7DQo+ICANCj4gLQlyZXR1cm4gbW9kZWw7DQo+ICsJcmV0dXJu IDA7DQo+ICB9DQo+ICANCj4gLXN0YXRpYyBzdHJ1Y3QgbWVzaF9tb2RlbCAqZmluZF9tb2RlbChz dHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBhZGRyLA0KPiAtCQkJCQkJdWludDMyX3Qg bW9kX2lkLCBpbnQgKnN0YXR1cykNCj4gK3N0YXRpYyBzdHJ1Y3QgbWVzaF9tb2RlbCAqZ2V0X21v ZGVsKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgZWxlX2lkeCwNCj4gKwkJCQkJCQkJ dWludDMyX3QgaWQpDQo+ICB7DQo+IC0JaW50IGVsZV9pZHg7DQo+IC0NCj4gLQllbGVfaWR4ID0g bm9kZV9nZXRfZWxlbWVudF9pZHgobm9kZSwgYWRkcik7DQo+ICsJc3RydWN0IGxfcXVldWUgKm1v ZHM7DQo+ICsJc3RydWN0IG1lc2hfbW9kZWwgKm1vZDsNCj4gIA0KPiAtCWlmIChlbGVfaWR4IDwg MCkgew0KPiAtCQkqc3RhdHVzID0gTUVTSF9TVEFUVVNfSU5WQUxJRF9BRERSRVNTOw0KPiArCW1v ZHMgPSBub2RlX2dldF9lbGVtZW50X21vZGVscyhub2RlLCBlbGVfaWR4KTsNCj4gKwlpZiAoIW1v ZHMpDQo+ICAJCXJldHVybiBOVUxMOw0KPiAtCX0NCj4gIA0KPiAtCXJldHVybiBnZXRfbW9kZWwo bm9kZSwgKHVpbnQ4X3QpIGVsZV9pZHgsIG1vZF9pZCwgc3RhdHVzKTsNCj4gKwltb2QgPSBsX3F1 ZXVlX2ZpbmQobW9kcywgbWF0Y2hfbW9kZWxfaWQsIExfVUlOVF9UT19QVFIoaWQpKTsNCj4gKw0K PiArCWlmICghbW9kKQ0KPiArCQlsX2RlYnVnKCJNb2RlbCBub3QgZm91bmQiKTsNCj4gKw0KPiAr CXJldHVybiBtb2Q7DQo+ICB9DQo+ICANCj4gIHN0YXRpYyB1aW50MzJfdCBwdWJfcGVyaW9kX3Rv X21zKHVpbnQ4X3QgcHViX3BlcmlvZCkNCj4gQEAgLTIxMiwxNSArMjA5LDE3IEBAIHN0YXRpYyBz dHJ1Y3QgbF9kYnVzX21lc3NhZ2UgKmNyZWF0ZV9jb25maWdfdXBkYXRlX21zZyhzdHJ1Y3QgbWVz aF9ub2RlICpub2RlLA0KPiAgDQo+ICAJKmJ1aWxkZXIgPSBsX2RidXNfbWVzc2FnZV9idWlsZGVy X25ldyhtc2cpOw0KPiAgDQo+IC0JbW9kZWxfaWQgPSAodWludDE2X3QpIGlkOw0KPiArCW1vZGVs X2lkID0gKHVpbnQxNl90KSBNT0RFTF9JRChpZCk7DQo+ICANCj4gIAlsX2RidXNfbWVzc2FnZV9i dWlsZGVyX2FwcGVuZF9iYXNpYygqYnVpbGRlciwgJ3EnLCAmbW9kZWxfaWQpOw0KPiAgDQo+ICAJ bF9kYnVzX21lc3NhZ2VfYnVpbGRlcl9lbnRlcl9hcnJheSgqYnVpbGRlciwgIntzdn0iKTsNCj4g IA0KPiAtCWlmICgoaWQgJiBWRU5ET1JfSURfTUFTSykgIT0gVkVORE9SX0lEX01BU0spIHsNCj4g LQkJdWludDE2X3QgdmVuZG9yID0gaWQgPj4gMTY7DQo+IC0JCWRidXNfYXBwZW5kX2RpY3RfZW50 cnlfYmFzaWMoKmJ1aWxkZXIsICJWZW5kb3IiLCAicSIsICZ2ZW5kb3IpOw0KPiArCWlmIChJU19W RU5ET1IoaWQpKSB7DQo+ICsJCXVpbnQxNl90IHZlbmRvcl9pZCA9ICh1aW50MTZfdCkgVkVORE9S X0lEKGlkKTsNCj4gKw0KPiArCQlkYnVzX2FwcGVuZF9kaWN0X2VudHJ5X2Jhc2ljKCpidWlsZGVy LCAiVmVuZG9yIiwgInEiLA0KPiArCQkJCQkJCQkmdmVuZG9yX2lkKTsNCj4gIAl9DQo+ICANCj4g IAlyZXR1cm4gbXNnOw0KPiBAQCAtMjY4LDE1ICsyNjcsMTQgQEAgc3RhdGljIHZvaWQgYXBwZW5k X2RpY3RfdWludDE2X2FycmF5KHN0cnVjdCBsX2RidXNfbWVzc2FnZV9idWlsZGVyICpidWlsZGVy LA0KPiAgCWxfZGJ1c19tZXNzYWdlX2J1aWxkZXJfbGVhdmVfZGljdChidWlsZGVyKTsNCj4gIH0N Cj4gIA0KPiAtc3RhdGljIHZvaWQgY29uZmlnX3VwZGF0ZV9tb2RlbF9iaW5kaW5ncyhzdHJ1Y3Qg bWVzaF9ub2RlICpub2RlLA0KPiArc3RhdGljIHZvaWQgY2ZnX3VwZGF0ZV9tb2RfYmluZGluZ3Mo c3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgZWxlX2lkeCwNCj4gIAkJCQkJCQlzdHJ1 Y3QgbWVzaF9tb2RlbCAqbW9kKQ0KPiAgew0KPiAgCXN0cnVjdCBsX2RidXMgKmRidXMgPSBkYnVz X2dldF9idXMoKTsNCj4gIAlzdHJ1Y3QgbF9kYnVzX21lc3NhZ2UgKm1zZzsNCj4gIAlzdHJ1Y3Qg bF9kYnVzX21lc3NhZ2VfYnVpbGRlciAqYnVpbGRlcjsNCj4gIA0KPiAtCW1zZyA9IGNyZWF0ZV9j b25maWdfdXBkYXRlX21zZyhub2RlLCBtb2QtPmVsZV9pZHgsIG1vZC0+aWQsDQo+IC0JCQkJCQkJ CSZidWlsZGVyKTsNCj4gKwltc2cgPSBjcmVhdGVfY29uZmlnX3VwZGF0ZV9tc2cobm9kZSwgZWxl X2lkeCwgbW9kLT5pZCwgJmJ1aWxkZXIpOw0KPiAgCWlmICghbXNnKQ0KPiAgCQlyZXR1cm47DQo+ ICANCj4gQEAgLTMzMSwxNSArMzI5LDE0IEBAIGRvbmU6DQo+ICAJbF9kYnVzX21lc3NhZ2VfYnVp bGRlcl9sZWF2ZV9kaWN0KGJ1aWxkZXIpOw0KPiAgfQ0KPiAgDQo+IC1zdGF0aWMgdm9pZCBjb25m aWdfdXBkYXRlX21vZGVsX3N1YnNjcmlwdGlvbnMoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwNCj4g K3N0YXRpYyB2b2lkIGNmZ191cGRhdGVfbW9kZWxfc3VicyhzdHJ1Y3QgbWVzaF9ub2RlICpub2Rl LCB1aW50MTZfdCBlbGVfaWR4LA0KPiAgCQkJCQkJCXN0cnVjdCBtZXNoX21vZGVsICptb2QpDQo+ ICB7DQo+ICAJc3RydWN0IGxfZGJ1cyAqZGJ1cyA9IGRidXNfZ2V0X2J1cygpOw0KPiAgCXN0cnVj dCBsX2RidXNfbWVzc2FnZSAqbXNnOw0KPiAgCXN0cnVjdCBsX2RidXNfbWVzc2FnZV9idWlsZGVy ICpidWlsZGVyOw0KPiAgDQo+IC0JbXNnID0gY3JlYXRlX2NvbmZpZ191cGRhdGVfbXNnKG5vZGUs IG1vZC0+ZWxlX2lkeCwgbW9kLT5pZCwNCj4gLQkJCQkJCQkJJmJ1aWxkZXIpOw0KPiArCW1zZyA9 IGNyZWF0ZV9jb25maWdfdXBkYXRlX21zZyhub2RlLCBlbGVfaWR4LCBtb2QtPmlkLCAmYnVpbGRl cik7DQo+ICAJaWYgKCFtc2cpDQo+ICAJCXJldHVybjsNCj4gIA0KPiBAQCAtNTcyLDcgKzU2OSw4 IEBAIGRvbmU6DQo+ICAJcmV0dXJuIHJldDsNCj4gIH0NCj4gIA0KPiAtc3RhdGljIHZvaWQgcmVt b3ZlX3B1YihzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCBzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kKQ0K PiArc3RhdGljIHZvaWQgcmVtb3ZlX3B1YihzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZf dCBlbGVfaWR4LA0KPiArCQkJCQkJCXN0cnVjdCBtZXNoX21vZGVsICptb2QpDQo+ICB7DQo+ICAJ aWYgKG1vZC0+cHViKSB7DQo+ICAJCWlmIChtb2QtPnB1Yi0+dmlydCkNCj4gQEAgLTU4NCwzMSAr NTgyLDMxIEBAIHN0YXRpYyB2b2lkIHJlbW92ZV9wdWIoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwg c3RydWN0IG1lc2hfbW9kZWwgKm1vZCkNCj4gIA0KPiAgCWlmICghbW9kLT5jYnMpDQo+ICAJCS8q IEV4dGVybmFsIG1vZGVscyAqLw0KPiAtCQljb25maWdfdXBkYXRlX21vZGVsX3B1Yl9wZXJpb2Qo bm9kZSwgbW9kLT5lbGVfaWR4LCBtb2QtPmlkLCAwKTsNCj4gKwkJY29uZmlnX3VwZGF0ZV9tb2Rl bF9wdWJfcGVyaW9kKG5vZGUsIGVsZV9pZHgsIG1vZC0+aWQsIDApOw0KPiAgCWVsc2UgaWYgKG1v ZC0+Y2JzICYmIG1vZC0+Y2JzLT5wdWIpDQo+ICAJCS8qIEludGVybmFsIG1vZGVscyAqLw0KPiAg CQltb2QtPmNicy0+cHViKE5VTEwpOw0KPiAgfQ0KPiAgDQo+IC1zdGF0aWMgdm9pZCBtb2RlbF91 bmJpbmRfaWR4KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHN0cnVjdCBtZXNoX21vZGVsICptb2Qs DQo+IC0JCQkJCQkJCXVpbnQxNl90IGlkeCkNCj4gK3N0YXRpYyB2b2lkIG1vZGVsX3VuYmluZF9p ZHgoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgZWxlX2lkeCwNCj4gKwkJCQkJc3Ry dWN0IG1lc2hfbW9kZWwgKm1vZCwgdWludDE2X3QgaWR4KQ0KPiAgew0KPiAgCWxfcXVldWVfcmVt b3ZlKG1vZC0+YmluZGluZ3MsIExfVUlOVF9UT19QVFIoaWR4KSk7DQo+ICANCj4gIAlpZiAoIW1v ZC0+Y2JzKQ0KPiAgCQkvKiBFeHRlcm5hbCBtb2RlbCAqLw0KPiAtCQljb25maWdfdXBkYXRlX21v ZGVsX2JpbmRpbmdzKG5vZGUsIG1vZCk7DQo+ICsJCWNmZ191cGRhdGVfbW9kX2JpbmRpbmdzKG5v ZGUsIGVsZV9pZHgsIG1vZCk7DQo+ICAJZWxzZSBpZiAobW9kLT5jYnMtPmJpbmQpDQo+ICAJCS8q IEludGVybmFsIG1vZGVsICovDQo+ICAJCW1vZC0+Y2JzLT5iaW5kKGlkeCwgQUNUSU9OX0RFTEVU RSk7DQo+ICANCj4gIAkvKiBSZW1vdmUgbW9kZWwgcHVibGljYXRpb24gaWYgdGhlIHB1YmxpY2F0 aW9uIGtleSBpcyB1bmJvdW5kICovDQo+ICAJaWYgKG1vZC0+cHViICYmIGlkeCA9PSBtb2QtPnB1 Yi0+aWR4KQ0KPiAtCQlyZW1vdmVfcHViKG5vZGUsIG1vZCk7DQo+ICsJCXJlbW92ZV9wdWIobm9k ZSwgZWxlX2lkeCwgbW9kKTsNCj4gIH0NCj4gIA0KPiAtc3RhdGljIHZvaWQgbW9kZWxfYmluZF9p ZHgoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgc3RydWN0IG1lc2hfbW9kZWwgKm1vZCwNCj4gLQkJ CQkJCQkJdWludDE2X3QgaWR4KQ0KPiArc3RhdGljIHZvaWQgbW9kZWxfYmluZF9pZHgoc3RydWN0 IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgZWxlX2lkeCwNCj4gKwkJCQkJc3RydWN0IG1lc2hf bW9kZWwgKm1vZCwgdWludDE2X3QgaWR4KQ0KPiAgew0KPiAgCWlmICghbW9kLT5iaW5kaW5ncykN Cj4gIAkJbW9kLT5iaW5kaW5ncyA9IGxfcXVldWVfbmV3KCk7DQo+IEBAIC02MTksNyArNjE3LDcg QEAgc3RhdGljIHZvaWQgbW9kZWxfYmluZF9pZHgoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgc3Ry dWN0IG1lc2hfbW9kZWwgKm1vZCwNCj4gIA0KPiAgCWlmICghbW9kLT5jYnMpDQo+ICAJCS8qIEV4 dGVybmFsIG1vZGVsICovDQo+IC0JCWNvbmZpZ191cGRhdGVfbW9kZWxfYmluZGluZ3Mobm9kZSwg bW9kKTsNCj4gKwkJY2ZnX3VwZGF0ZV9tb2RfYmluZGluZ3Mobm9kZSwgZWxlX2lkeCwgbW9kKTsN Cj4gIAllbHNlIGlmIChtb2QtPmNicy0+YmluZCkNCj4gIAkJLyogSW50ZXJuYWwgbW9kZWwgKi8N Cj4gIAkJbW9kLT5jYnMtPmJpbmQoaWR4LCBBQ1RJT05fQUREKTsNCj4gQEAgLTYyOCwxOSArNjI2 LDE4IEBAIHN0YXRpYyB2b2lkIG1vZGVsX2JpbmRfaWR4KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUs IHN0cnVjdCBtZXNoX21vZGVsICptb2QsDQo+ICBzdGF0aWMgaW50IHVwZGF0ZV9iaW5kaW5nKHN0 cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IGFkZHIsIHVpbnQzMl90IGlkLA0KPiAgCQkJ CQkJdWludDE2X3QgYXBwX2lkeCwgYm9vbCB1bmJpbmQpDQo+ICB7DQo+IC0JaW50IHN0YXR1czsN Cj4gIAlzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kOw0KPiAtCWJvb2wgaXNfcHJlc2VudCwgaXNfdmVu ZG9yOw0KPiArCWJvb2wgaXNfcHJlc2VudDsNCj4gKwlpbnQgZWxlX2lkeCA9IG5vZGVfZ2V0X2Vs ZW1lbnRfaWR4KG5vZGUsIGFkZHIpOw0KPiAgDQo+IC0JbW9kID0gZmluZF9tb2RlbChub2RlLCBh ZGRyLCBpZCwgJnN0YXR1cyk7DQo+ICsJaWYgKGVsZV9pZHggPCAwKQ0KPiArCQlyZXR1cm4gTUVT SF9TVEFUVVNfSU5WQUxJRF9BRERSRVNTOw0KPiArDQo+ICsJbW9kID0gZ2V0X21vZGVsKG5vZGUs ICh1aW50OF90KSBlbGVfaWR4LCBpZCk7DQo+ICAJaWYgKCFtb2QpIHsNCj4gLQkJbF9kZWJ1Zygi TW9kZWwgbm90IGZvdW5kIik7DQo+IC0JCXJldHVybiBzdGF0dXM7DQo+ICsJCXJldHVybiBNRVNI X1NUQVRVU19JTlZBTElEX01PREVMOw0KPiAgCX0NCj4gIA0KPiAtCWlzX3ZlbmRvciA9IGlkIDwg VkVORE9SX0lEX01BU0sgJiYgaWQgPiAweGZmZmY7DQo+IC0JaWQgPSAhaXNfdmVuZG9yID8gKGlk ICYgMHhmZmZmKSA6IGlkOw0KPiAtDQo+ICAJaWYgKGlkID09IENPTkZJR19TUlZfTU9ERUwgfHwg aWQgPT0gQ09ORklHX0NMSV9NT0RFTCkNCj4gIAkJcmV0dXJuIE1FU0hfU1RBVFVTX0lOVkFMSURf TU9ERUw7DQo+ICANCj4gQEAgLTY1Niw5ICs2NTMsMTAgQEAgc3RhdGljIGludCB1cGRhdGVfYmlu ZGluZyhzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCwN Cj4gIAkJcmV0dXJuIE1FU0hfU1RBVFVTX1NVQ0NFU1M7DQo+ICANCj4gIAlpZiAodW5iaW5kKSB7 DQo+IC0JCW1vZGVsX3VuYmluZF9pZHgobm9kZSwgbW9kLCBhcHBfaWR4KTsNCj4gKwkJbW9kZWxf dW5iaW5kX2lkeChub2RlLCBlbGVfaWR4LCBtb2QsIGFwcF9pZHgpOw0KPiAgCQlpZiAoIW1lc2hf Y29uZmlnX21vZGVsX2JpbmRpbmdfZGVsKG5vZGVfY29uZmlnX2dldChub2RlKSwNCj4gLQkJCQkJ YWRkciwgaXNfdmVuZG9yLCBpZCwgYXBwX2lkeCkpDQo+ICsJCQkJCQkJYWRkciwgSVNfVkVORE9S KGlkKSwNCj4gKwkJCQkJCQlpZCwgYXBwX2lkeCkpDQo+ICAJCQlyZXR1cm4gTUVTSF9TVEFUVVNf U1RPUkFHRV9GQUlMOw0KPiAgDQo+ICAJCWxfZGVidWcoIlVuYmluZCBrZXkgJTQuNHggdG8gbW9k ZWwgJTguOHgiLCBhcHBfaWR4LCBtb2QtPmlkKTsNCj4gQEAgLTY2OCwxMSArNjY2LDExIEBAIHN0 YXRpYyBpbnQgdXBkYXRlX2JpbmRpbmcoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3Qg YWRkciwgdWludDMyX3QgaWQsDQo+ICAJaWYgKGxfcXVldWVfbGVuZ3RoKG1vZC0+YmluZGluZ3Mp ID49IE1BWF9CSU5ESU5HUykNCj4gIAkJcmV0dXJuIE1FU0hfU1RBVFVTX0lOU1VGRl9SRVNPVVJD RVM7DQo+ICANCj4gLQlpZiAoIW1lc2hfY29uZmlnX21vZGVsX2JpbmRpbmdfYWRkKG5vZGVfY29u ZmlnX2dldChub2RlKSwNCj4gLQkJCQkJYWRkciwgaXNfdmVuZG9yLCBpZCwgYXBwX2lkeCkpDQo+ ICsJaWYgKCFtZXNoX2NvbmZpZ19tb2RlbF9iaW5kaW5nX2FkZChub2RlX2NvbmZpZ19nZXQobm9k ZSksIGFkZHIsDQo+ICsJCQkJCQlJU19WRU5ET1IoaWQpLCBpZCwgYXBwX2lkeCkpDQo+ICAJCXJl dHVybiBNRVNIX1NUQVRVU19TVE9SQUdFX0ZBSUw7DQo+ICANCj4gLQltb2RlbF9iaW5kX2lkeChu b2RlLCBtb2QsIGFwcF9pZHgpOw0KPiArCW1vZGVsX2JpbmRfaWR4KG5vZGUsIGVsZV9pZHgsIG1v ZCwgYXBwX2lkeCk7DQo+ICANCj4gIAlyZXR1cm4gTUVTSF9TVEFUVVNfU1VDQ0VTUzsNCj4gIA0K PiBAQCAtOTY0LDcgKzk2Miw2IEBAIGJvb2wgbWVzaF9tb2RlbF9yeChzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlLCBib29sIHN6bWljdCwgdWludDMyX3Qgc2VxMCwNCj4gIA0KPiAgCWlzX3N1YnNjcmlw dGlvbiA9ICEoSVNfVU5JQ0FTVChkc3QpKTsNCj4gIA0KPiAtDQo+ICAJZm9yIChpID0gMDsgaSA8 IG51bV9lbGU7IGkrKykgew0KPiAgCQlzdHJ1Y3QgbF9xdWV1ZSAqbW9kZWxzOw0KPiAgDQo+IEBA IC05NzQsNyArOTcxLDcgQEAgYm9vbCBtZXNoX21vZGVsX3J4KHN0cnVjdCBtZXNoX25vZGUgKm5v ZGUsIGJvb2wgc3ptaWN0LCB1aW50MzJfdCBzZXEwLA0KPiAgCQlmb3J3YXJkLnVuaWNhc3QgPSBh ZGRyICsgaTsNCj4gIAkJZm9yd2FyZC5oYXNfZHN0ID0gZmFsc2U7DQo+ICANCj4gLQkJbW9kZWxz ID0gbm9kZV9nZXRfZWxlbWVudF9tb2RlbHMobm9kZSwgaSwgTlVMTCk7DQo+ICsJCW1vZGVscyA9 IG5vZGVfZ2V0X2VsZW1lbnRfbW9kZWxzKG5vZGUsIGkpOw0KPiAgDQo+ICAJCS8qIEludGVybmFs IG1vZGVscyAqLw0KPiAgCQlsX3F1ZXVlX2ZvcmVhY2gobW9kZWxzLCBmb3J3YXJkX21vZGVsLCAm Zm9yd2FyZCk7DQo+IEBAIC0xMDIzLDE2ICsxMDIwLDE1IEBAIGRvbmU6DQo+ICAJcmV0dXJuIHJl c3VsdDsNCj4gIH0NCj4gIA0KPiAtaW50IG1lc2hfbW9kZWxfcHVibGlzaChzdHJ1Y3QgbWVzaF9u b2RlICpub2RlLCB1aW50MzJfdCBtb2RfaWQsDQo+IC0JCQkJdWludDE2X3Qgc3JjLCB1aW50OF90 IHR0bCwNCj4gLQkJCQljb25zdCB2b2lkICptc2csIHVpbnQxNl90IG1zZ19sZW4pDQo+ICtpbnQg bWVzaF9tb2RlbF9wdWJsaXNoKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQzMl90IGlkLCB1 aW50MTZfdCBzcmMsDQo+ICsJCQkJdWludDhfdCB0dGwsIGNvbnN0IHZvaWQgKm1zZywgdWludDE2 X3QgbXNnX2xlbikNCj4gIHsNCj4gIAlzdHJ1Y3QgbWVzaF9uZXQgKm5ldCA9IG5vZGVfZ2V0X25l dChub2RlKTsNCj4gIAlzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kOw0KPiAgCXVpbnQ4X3QgKmxhYmVs ID0gTlVMTDsNCj4gIAl1aW50MTZfdCBuZXRfaWR4Ow0KPiAgCWJvb2wgcmVzdWx0Ow0KPiAtCWlu dCBzdGF0dXM7DQo+ICsJaW50IGVsZV9pZHg7DQo+ICANCj4gIAlpZiAoIW5ldCB8fCBtc2dfbGVu ID4gMzgwKQ0KPiAgCQlyZXR1cm4gTUVTSF9FUlJPUl9JTlZBTElEX0FSR1M7DQo+IEBAIC0xMDQx LDE0ICsxMDM3LDE2IEBAIGludCBtZXNoX21vZGVsX3B1Ymxpc2goc3RydWN0IG1lc2hfbm9kZSAq bm9kZSwgdWludDMyX3QgbW9kX2lkLA0KPiAgCWlmIChzcmMgPT0gMCkNCj4gIAkJc3JjID0gbWVz aF9uZXRfZ2V0X2FkZHJlc3MobmV0KTsNCj4gIA0KPiAtCW1vZCA9IGZpbmRfbW9kZWwobm9kZSwg c3JjLCBtb2RfaWQsICZzdGF0dXMpOw0KPiAtCWlmICghbW9kKSB7DQo+IC0JCWxfZGVidWcoIm1v ZGVsICV4IG5vdCBmb3VuZCIsIG1vZF9pZCk7DQo+ICsJZWxlX2lkeCA9IG5vZGVfZ2V0X2VsZW1l bnRfaWR4KG5vZGUsIHNyYyk7DQo+ICsJaWYgKGVsZV9pZHggPCAwKQ0KPiArCQlyZXR1cm4gTUVT SF9FUlJPUl9OT1RfRk9VTkQ7DQo+ICsNCj4gKwltb2QgPSBnZXRfbW9kZWwobm9kZSwgKHVpbnQ4 X3QpIGVsZV9pZHgsIGlkKTsNCj4gKwlpZiAoIW1vZCkNCj4gIAkJcmV0dXJuIE1FU0hfRVJST1Jf Tk9UX0ZPVU5EOw0KPiAtCX0NCj4gIA0KPiAgCWlmICghbW9kLT5wdWIpIHsNCj4gLQkJbF9kZWJ1 ZygicHVibGljYXRpb24gZG9lc24ndCBleGlzdCAobW9kZWwgJXgpIiwgbW9kX2lkKTsNCj4gKwkJ bF9kZWJ1ZygicHVibGljYXRpb24gZG9lc24ndCBleGlzdCAobW9kZWwgJXgpIiwgaWQpOw0KPiAg CQlyZXR1cm4gTUVTSF9FUlJPUl9ET0VTX05PVF9FWElTVDsNCj4gIAl9DQo+ICANCj4gQEAgLTEw OTMsMTEgKzEwOTEsMTQgQEAgaW50IG1lc2hfbW9kZWxfcHViX3NldChzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCwNCj4gIAkJCWJvb2wgaXNfdmlydCwg dWludDE2X3QgKmRzdCkNCj4gIHsNCj4gIAlzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kOw0KPiAtCWlu dCBzdGF0dXM7DQo+ICsJaW50IHN0YXR1cywgZWxlX2lkeCA9IG5vZGVfZ2V0X2VsZW1lbnRfaWR4 KG5vZGUsIGFkZHIpOw0KPiAgDQo+IC0JbW9kID0gZmluZF9tb2RlbChub2RlLCBhZGRyLCBpZCwg JnN0YXR1cyk7DQo+ICsJaWYgKGVsZV9pZHggPCAwKQ0KPiArCQlyZXR1cm4gTUVTSF9TVEFUVVNf SU5WQUxJRF9BRERSRVNTOw0KPiArDQo+ICsJbW9kID0gZ2V0X21vZGVsKG5vZGUsICh1aW50OF90 KSBlbGVfaWR4LCBpZCk7DQo+ICAJaWYgKCFtb2QpDQo+IC0JCXJldHVybiBzdGF0dXM7DQo+ICsJ CXJldHVybiBNRVNIX1NUQVRVU19JTlZBTElEX01PREVMOw0KPiAgDQo+ICAJaWYgKCFtb2QtPnB1 Yl9lbmFibGVkIHx8IChtb2QtPmNicyAmJiAhKG1vZC0+Y2JzLT5wdWIpKSkNCj4gIAkJcmV0dXJu IE1FU0hfU1RBVFVTX0lOVkFMSURfUFVCX1BBUkFNOw0KPiBAQCAtMTExMCw3ICsxMTExLDcgQEAg aW50IG1lc2hfbW9kZWxfcHViX3NldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBh ZGRyLCB1aW50MzJfdCBpZCwNCj4gIAkgKiByZW1vdmUgdGhlIHB1YmxpY2F0aW9uDQo+ICAJICov DQo+ICAJaWYgKCFpc192aXJ0ICYmIElTX1VOQVNTSUdORUQobF9nZXRfbGUxNihwdWJfYWRkcikp KSB7DQo+IC0JCXJlbW92ZV9wdWIobm9kZSwgbW9kKTsNCj4gKwkJcmVtb3ZlX3B1Yihub2RlLCBl bGVfaWR4LCBtb2QpOw0KPiAgCQlyZXR1cm4gTUVTSF9TVEFUVVNfU1VDQ0VTUzsNCj4gIAl9DQo+ ICANCj4gQEAgLTExMzQsNyArMTEzNSw3IEBAIGludCBtZXNoX21vZGVsX3B1Yl9zZXQoc3RydWN0 IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgYWRkciwgdWludDMyX3QgaWQsDQo+ICANCj4gIAlp ZiAoIW1vZC0+Y2JzKQ0KPiAgCQkvKiBFeHRlcm5hbCBtb2RlbCAqLw0KPiAtCQljb25maWdfdXBk YXRlX21vZGVsX3B1Yl9wZXJpb2Qobm9kZSwgbW9kLT5lbGVfaWR4LCBpZCwNCj4gKwkJY29uZmln X3VwZGF0ZV9tb2RlbF9wdWJfcGVyaW9kKG5vZGUsIGVsZV9pZHgsIGlkLA0KPiAgCQkJCQkJcHVi X3BlcmlvZF90b19tcyhwZXJpb2QpKTsNCj4gIAllbHNlIHsNCj4gIAkJLyogSW50ZXJuYWwgbW9k ZWwsIGNhbGwgcmVnaXN0ZXJlZCBjYWxsYmFja3MgKi8NCj4gQEAgLTExNDksMTAgKzExNTAsMTgg QEAgc3RydWN0IG1lc2hfbW9kZWxfcHViICptZXNoX21vZGVsX3B1Yl9nZXQoc3RydWN0IG1lc2hf bm9kZSAqbm9kZSwgdWludDE2X3QgYWRkciwNCj4gIAkJCQkJCXVpbnQzMl90IG1vZF9pZCwgaW50 ICpzdGF0dXMpDQo+ICB7DQo+ICAJc3RydWN0IG1lc2hfbW9kZWwgKm1vZDsNCj4gKwlpbnQgZWxl X2lkeCA9IG5vZGVfZ2V0X2VsZW1lbnRfaWR4KG5vZGUsIGFkZHIpOw0KPiAgDQo+IC0JbW9kID0g ZmluZF9tb2RlbChub2RlLCBhZGRyLCBtb2RfaWQsIHN0YXR1cyk7DQo+IC0JaWYgKCFtb2QpDQo+ ICsJaWYgKGVsZV9pZHggPCAwKSB7DQo+ICsJCSpzdGF0dXMgPSBNRVNIX1NUQVRVU19JTlZBTElE X0FERFJFU1M7DQo+ICsJCXJldHVybiBOVUxMOw0KPiArCX0NCj4gKw0KPiArCW1vZCA9IGdldF9t b2RlbChub2RlLCAodWludDhfdCkgZWxlX2lkeCwgbW9kX2lkKTsNCj4gKwlpZiAoIW1vZCkgew0K PiArCQkqc3RhdHVzID0gTUVTSF9TVEFUVVNfSU5WQUxJRF9NT0RFTDsNCj4gIAkJcmV0dXJuIE5V TEw7DQo+ICsJfQ0KPiAgDQo+ICAJaWYgKCFtb2QtPnB1Yl9lbmFibGVkIHx8IChtb2QtPmNicyAm JiAhKG1vZC0+Y2JzLT5wdWIpKSkNCj4gIAkJKnN0YXR1cyA9IE1FU0hfU1RBVFVTX0lOVkFMSURf UFVCX1BBUkFNOw0KPiBAQCAtMTE3MywxMiArMTE4MiwyNSBAQCB2b2lkIG1lc2hfbW9kZWxfZnJl ZSh2b2lkICpkYXRhKQ0KPiAgCWxfZnJlZShtb2QpOw0KPiAgfQ0KPiAgDQo+IC1zdHJ1Y3QgbWVz aF9tb2RlbCAqbWVzaF9tb2RlbF9uZXcodWludDhfdCBlbGVfaWR4LCB1aW50MzJfdCBpZCkNCj4g K3N0YXRpYyB2b2lkIHJlbW92ZV9zdWJzKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHN0cnVjdCBt ZXNoX21vZGVsICptb2QpDQo+ICt7DQo+ICsJY29uc3Qgc3RydWN0IGxfcXVldWVfZW50cnkgKmVu dHJ5Ow0KPiArCXN0cnVjdCBtZXNoX25ldCAqbmV0ID0gbm9kZV9nZXRfbmV0KG5vZGUpOw0KPiAr DQo+ICsJZW50cnkgPSBsX3F1ZXVlX2dldF9lbnRyaWVzKG1vZC0+c3Vicyk7DQo+ICsNCj4gKwlm b3IgKDsgZW50cnk7IGVudHJ5ID0gZW50cnktPm5leHQpDQo+ICsJCW1lc2hfbmV0X2RzdF91bnJl ZyhuZXQsICh1aW50MTZfdCkgTF9QVFJfVE9fVUlOVChlbnRyeS0+ZGF0YSkpOw0KPiArDQo+ICsJ bF9xdWV1ZV9jbGVhcihtb2QtPnN1YnMsIE5VTEwpOw0KPiArCWxfcXVldWVfY2xlYXIobW9kLT52 aXJ0dWFscywgdW5yZWZfdmlydCk7DQo+ICt9DQo+ICsNCj4gK3N0YXRpYyBzdHJ1Y3QgbWVzaF9t b2RlbCAqbW9kZWxfbmV3KHVpbnQzMl90IGlkKQ0KPiAgew0KPiAgCXN0cnVjdCBtZXNoX21vZGVs ICptb2QgPSBsX25ldyhzdHJ1Y3QgbWVzaF9tb2RlbCwgMSk7DQo+ICANCj4gIAltb2QtPmlkID0g aWQ7DQo+IC0JbW9kLT5lbGVfaWR4ID0gZWxlX2lkeDsNCj4gIAltb2QtPnZpcnR1YWxzID0gbF9x dWV1ZV9uZXcoKTsNCj4gIA0KPiAgCS8qDQo+IEBAIC0xMTkwLDYgKzEyMTIsNzUgQEAgc3RydWN0 IG1lc2hfbW9kZWwgKm1lc2hfbW9kZWxfbmV3KHVpbnQ4X3QgZWxlX2lkeCwgdWludDMyX3QgaWQp DQo+ICAJcmV0dXJuIG1vZDsNCj4gIH0NCj4gIA0KPiArc3RhdGljIHZvaWQgbW9kZWxfZW5hYmxl X3B1YihzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kLCBib29sIGVuYWJsZSkNCj4gK3sNCj4gKwltb2Qt PnB1Yl9lbmFibGVkID0gZW5hYmxlOw0KPiArDQo+ICsJaWYgKCFtb2QtPnB1Yl9lbmFibGVkICYm IG1vZC0+cHViKSB7DQo+ICsJCWlmIChtb2QtPnB1Yi0+dmlydCkNCj4gKwkJCXVucmVmX3ZpcnQo bW9kLT5wdWItPnZpcnQpOw0KPiArDQo+ICsJCWxfZnJlZShtb2QtPnB1Yik7DQo+ICsJCW1vZC0+ cHViID0gTlVMTDsNCj4gKwl9DQo+ICt9DQo+ICsNCj4gK3N0YXRpYyB2b2lkIG1vZGVsX2VuYWJs ZV9zdWIoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgc3RydWN0IG1lc2hfbW9kZWwgKm1vZCwNCj4g KwkJCQkJCQkJYm9vbCBlbmFibGUpDQo+ICt7DQo+ICsJbW9kLT5zdWJfZW5hYmxlZCA9IGVuYWJs ZTsNCj4gKw0KPiArCWlmICghbW9kLT5zdWJfZW5hYmxlZCkNCj4gKwkJcmVtb3ZlX3N1YnMobm9k ZSwgbW9kKTsNCj4gK30NCj4gKw0KPiArc3RhdGljIGJvb2wgZ2V0X21vZGVsX29wdGlvbnMoc3Ry dWN0IG1lc2hfbW9kZWwgKm1vZCwNCj4gKwkJCQkJc3RydWN0IGxfZGJ1c19tZXNzYWdlX2l0ZXIg Km9wdHMpDQo+ICt7DQo+ICsJY29uc3QgY2hhciAqa2V5Ow0KPiArCXN0cnVjdCBsX2RidXNfbWVz c2FnZV9pdGVyIHZhcjsNCj4gKwlib29sIG9wdDsNCj4gKw0KPiArCXdoaWxlIChsX2RidXNfbWVz c2FnZV9pdGVyX25leHRfZW50cnkob3B0cywgJmtleSwgJnZhcikpIHsNCj4gKw0KPiArCQlpZiAo IXN0cmNtcChrZXksICJQdWJsaXNoIikpIHsNCj4gKwkJCWlmICghbF9kYnVzX21lc3NhZ2VfaXRl cl9nZXRfdmFyaWFudCgmdmFyLCAiYiIsICZvcHQpKQ0KPiArCQkJCXJldHVybiBmYWxzZTsNCj4g Kw0KPiArCQkJbW9kLT5wdWJfZW5hYmxlZCA9IG9wdDsNCj4gKwkJfSBlbHNlIGlmICghc3RyY21w KGtleSwgIlN1YnNjcmliZSIpKSB7DQo+ICsJCQlpZiAoIWxfZGJ1c19tZXNzYWdlX2l0ZXJfZ2V0 X3ZhcmlhbnQoJnZhciwgImIiLCAmb3B0KSkNCj4gKwkJCQlyZXR1cm4gZmFsc2U7DQo+ICsNCj4g KwkJCW1vZC0+c3ViX2VuYWJsZWQgPSBvcHQ7DQo+ICsJCX0gZWxzZQ0KPiArCQkJcmV0dXJuIGZh bHNlOw0KPiArCX0NCj4gKw0KPiArCXJldHVybiB0cnVlOw0KPiArfQ0KPiArDQo+ICtib29sIG1l c2hfbW9kZWxfYWRkKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHN0cnVjdCBsX3F1ZXVlICptb2Rz LA0KPiArCQkJdWludDMyX3QgaWQsIHN0cnVjdCBsX2RidXNfbWVzc2FnZV9pdGVyICpvcHRzKQ0K PiArew0KPiArCXN0cnVjdCBtZXNoX21vZGVsICptb2Q7DQo+ICsNCj4gKwkvKiBEaXNhbGxvdyBk dXBsaWNhdGVzICovDQo+ICsJbW9kID0gbF9xdWV1ZV9maW5kKG1vZHMsIG1hdGNoX21vZGVsX2lk LCBMX1VJTlRfVE9fUFRSKGlkKSk7DQo+ICsJaWYgKG1vZCkNCj4gKwkJcmV0dXJuIGZhbHNlOw0K PiArDQo+ICsJbW9kID0gbW9kZWxfbmV3KGlkKTsNCj4gKw0KPiArCWlmIChvcHRzICYmICFnZXRf bW9kZWxfb3B0aW9ucyhtb2QsIG9wdHMpKSB7DQo+ICsJCW1lc2hfbW9kZWxfZnJlZShtb2QpOw0K PiArCQlyZXR1cm4gZmFsc2U7DQo+ICsJfQ0KPiArDQo+ICsJbF9xdWV1ZV9pbnNlcnQobW9kcywg bW9kLCBjb21wYXJlX21vZGVsX2lkLCBOVUxMKTsNCj4gKwlyZXR1cm4gdHJ1ZTsNCj4gK30NCj4g Kw0KPiAgLyogSW50ZXJuYWwgbW9kZWxzIG9ubHkgKi8NCj4gIHN0YXRpYyB2b2lkIHJlc3RvcmVf bW9kZWxfc3RhdGUoc3RydWN0IG1lc2hfbW9kZWwgKm1vZCkNCj4gIHsNCj4gQEAgLTEyMTMsMjYg KzEzMDQsMTYgQEAgc3RhdGljIHZvaWQgcmVzdG9yZV9tb2RlbF9zdGF0ZShzdHJ1Y3QgbWVzaF9t b2RlbCAqbW9kKQ0KPiAgDQo+ICB9DQo+ICANCj4gLXVpbnQzMl90IG1lc2hfbW9kZWxfZ2V0X21v ZGVsX2lkKGNvbnN0IHN0cnVjdCBtZXNoX21vZGVsICptb2RlbCkNCj4gLXsNCj4gLQlyZXR1cm4g bW9kZWwtPmlkOw0KPiAtfQ0KPiAtDQo+ICAvKiBUaGlzIHJlZ2lzdGVycyBhbiBpbnRlcm5hbCBt b2RlbCwgaS5lLiBpbXBsZW1lbnRlZCB3aXRoaW4gbWVzaGQgKi8NCj4gLWJvb2wgbWVzaF9tb2Rl bF9yZWdpc3RlcihzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50OF90IGVsZV9pZHgsDQo+IC0J CQkJCXVpbnQzMl90IG1vZF9pZCwNCj4gK2Jvb2wgbWVzaF9tb2RlbF9yZWdpc3RlcihzdHJ1Y3Qg bWVzaF9ub2RlICpub2RlLCB1aW50OF90IGVsZV9pZHgsIHVpbnQzMl90IGlkLA0KPiAgCQkJCQlj b25zdCBzdHJ1Y3QgbWVzaF9tb2RlbF9vcHMgKmNicywNCj4gIAkJCQkJdm9pZCAqdXNlcl9kYXRh KQ0KPiAgew0KPiAgCXN0cnVjdCBtZXNoX21vZGVsICptb2Q7DQo+IC0JaW50IHN0YXR1czsNCj4g LQ0KPiAtCS8qIEludGVybmFsIG1vZGVscyBhcmUgYWx3YXlzIFNJRyBtb2RlbHMgKi8NCj4gLQlt b2RfaWQgPSBWRU5ET1JfSURfTUFTSyB8IG1vZF9pZDsNCj4gIA0KPiAtCW1vZCA9IGdldF9tb2Rl bChub2RlLCBlbGVfaWR4LCBtb2RfaWQsICZzdGF0dXMpOw0KPiArCW1vZCA9IGdldF9tb2RlbChu b2RlLCBlbGVfaWR4LCBpZCk7DQo+ICAJaWYgKCFtb2QpDQo+IC0JCXJldHVybiBmYWxzZTsNCj4g KwkJcmV0dXJuIE1FU0hfU1RBVFVTX0lOVkFMSURfTU9ERUw7DQo+ICANCj4gIAltb2QtPmNicyA9 IGNiczsNCj4gIAltb2QtPnVzZXJfZGF0YSA9IHVzZXJfZGF0YTsNCj4gQEAgLTEyNDIsMTUgKzEz MjMsMTUgQEAgYm9vbCBtZXNoX21vZGVsX3JlZ2lzdGVyKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUs IHVpbnQ4X3QgZWxlX2lkeCwNCj4gIAlyZXR1cm4gdHJ1ZTsNCj4gIH0NCj4gIA0KPiAtdm9pZCBt ZXNoX21vZGVsX2FwcF9rZXlfZGVsZXRlKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHN0cnVjdCBs X3F1ZXVlICptb2RlbHMsDQo+IC0JCQkJCQkJdWludDE2X3QgYXBwX2lkeCkNCj4gK3ZvaWQgbWVz aF9tb2RlbF9hcHBfa2V5X2RlbGV0ZShzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBl bGVfaWR4LA0KPiArCQkJCXN0cnVjdCBsX3F1ZXVlICptb2RlbHMsIHVpbnQxNl90IGFwcF9pZHgp DQo+ICB7DQo+ICAJY29uc3Qgc3RydWN0IGxfcXVldWVfZW50cnkgKmVudHJ5ID0gbF9xdWV1ZV9n ZXRfZW50cmllcyhtb2RlbHMpOw0KPiAgDQo+ICAJZm9yICg7IGVudHJ5OyBlbnRyeSA9IGVudHJ5 LT5uZXh0KSB7DQo+IC0JCXN0cnVjdCBtZXNoX21vZGVsICptb2RlbCA9IGVudHJ5LT5kYXRhOw0K PiArCQlzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kID0gZW50cnktPmRhdGE7DQo+ICANCj4gLQkJbW9k ZWxfdW5iaW5kX2lkeChub2RlLCBtb2RlbCwgYXBwX2lkeCk7DQo+ICsJCW1vZGVsX3VuYmluZF9p ZHgobm9kZSwgZWxlX2lkeCwgbW9kLCBhcHBfaWR4KTsNCj4gIAl9DQo+ICB9DQo+ICANCj4gQEAg LTEyNjksMTggKzEzNTAsMjAgQEAgaW50IG1lc2hfbW9kZWxfYmluZGluZ19hZGQoc3RydWN0IG1l c2hfbm9kZSAqbm9kZSwgdWludDE2X3QgYWRkciwgdWludDMyX3QgaWQsDQo+ICBpbnQgbWVzaF9t b2RlbF9nZXRfYmluZGluZ3Moc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgYWRkciwg dWludDMyX3QgaWQsDQo+ICAJCQkJdWludDhfdCAqYnVmLCB1aW50MTZfdCBidWZfc2l6ZSwgdWlu dDE2X3QgKnNpemUpDQo+ICB7DQo+IC0JaW50IHN0YXR1czsNCj4gIAlzdHJ1Y3QgbWVzaF9tb2Rl bCAqbW9kOw0KPiAgCWNvbnN0IHN0cnVjdCBsX3F1ZXVlX2VudHJ5ICplbnRyeTsNCj4gIAl1aW50 MTZfdCBuOw0KPiAgCXVpbnQzMl90IGlkeF9wYWlyOw0KPiAtCWludCBpOw0KPiArCWludCBpLCBl bGVfaWR4ID0gbm9kZV9nZXRfZWxlbWVudF9pZHgobm9kZSwgYWRkcik7DQo+ICsNCj4gKwlpZiAo ZWxlX2lkeCA8IDApDQo+ICsJCXJldHVybiBNRVNIX1NUQVRVU19JTlZBTElEX0FERFJFU1M7DQo+ ICANCj4gLQltb2QgPSBmaW5kX21vZGVsKG5vZGUsIGFkZHIsIGlkLCAmc3RhdHVzKTsNCj4gKwlt b2QgPSBnZXRfbW9kZWwobm9kZSwgKHVpbnQ4X3QpIGVsZV9pZHgsIGlkKTsNCj4gIA0KPiAgCWlm ICghbW9kKSB7DQo+ICAJCSpzaXplID0gMDsNCj4gLQkJcmV0dXJuIHN0YXR1czsNCj4gKwkJcmV0 dXJuIE1FU0hfU1RBVFVTX0lOVkFMSURfTU9ERUw7DQo+ICAJfQ0KPiAgDQo+ICAJZW50cnkgPSBs X3F1ZXVlX2dldF9lbnRyaWVzKG1vZC0+YmluZGluZ3MpOw0KPiBAQCAtMTMyNSwxNCArMTQwOCwx NyBAQCBkb25lOg0KPiAgaW50IG1lc2hfbW9kZWxfc3ViX2dldChzdHJ1Y3QgbWVzaF9ub2RlICpu b2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCwNCj4gIAkJCXVpbnQ4X3QgKmJ1ZiwgdWlu dDE2X3QgYnVmX3NpemUsIHVpbnQxNl90ICpzaXplKQ0KPiAgew0KPiAtCWludCBzdGF0dXM7DQo+ ICAJaW50MTZfdCBuOw0KPiAgCXN0cnVjdCBtZXNoX21vZGVsICptb2Q7DQo+ICAJY29uc3Qgc3Ry dWN0IGxfcXVldWVfZW50cnkgKmVudHJ5Ow0KPiArCWludCBlbGVfaWR4ID0gbm9kZV9nZXRfZWxl bWVudF9pZHgobm9kZSwgYWRkcik7DQo+ICANCj4gLQltb2QgPSBmaW5kX21vZGVsKG5vZGUsIGFk ZHIsIGlkLCAmc3RhdHVzKTsNCj4gKwlpZiAoZWxlX2lkeCA8IDApDQo+ICsJCXJldHVybiBNRVNI X1NUQVRVU19JTlZBTElEX0FERFJFU1M7DQo+ICsNCj4gKwltb2QgPSBnZXRfbW9kZWwobm9kZSwg KHVpbnQ4X3QpIGVsZV9pZHgsIGlkKTsNCj4gIAlpZiAoIW1vZCkNCj4gLQkJcmV0dXJuIHN0YXR1 czsNCj4gKwkJcmV0dXJuIE1FU0hfU1RBVFVTX0lOVkFMSURfTU9ERUw7DQo+ICANCj4gIAlpZiAo IW1vZC0+c3ViX2VuYWJsZWQgfHwgKG1vZC0+Y2JzICYmICEobW9kLT5jYnMtPnN1YikpKQ0KPiAg CQlyZXR1cm4gTUVTSF9TVEFUVVNfTk9UX1NVQl9NT0Q7DQo+IEBAIC0xMzcwLDEyICsxNDU2LDE1 IEBAIGludCBtZXNoX21vZGVsX3N1Yl9nZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2 X3QgYWRkciwgdWludDMyX3QgaWQsDQo+ICBpbnQgbWVzaF9tb2RlbF9zdWJfYWRkKHN0cnVjdCBt ZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IGFkZHIsIHVpbnQzMl90IGlkLA0KPiAgCQkJY29uc3Qg dWludDhfdCAqZ3JvdXAsIGJvb2wgaXNfdmlydCwgdWludDE2X3QgKmRzdCkNCj4gIHsNCj4gLQlp bnQgc3RhdHVzOw0KPiAgCXN0cnVjdCBtZXNoX21vZGVsICptb2Q7DQo+ICsJaW50IHN0YXR1cywg ZWxlX2lkeCA9IG5vZGVfZ2V0X2VsZW1lbnRfaWR4KG5vZGUsIGFkZHIpOw0KPiArDQo+ICsJaWYg KGVsZV9pZHggPCAwKQ0KPiArCQlyZXR1cm4gTUVTSF9TVEFUVVNfSU5WQUxJRF9BRERSRVNTOw0K PiAgDQo+IC0JbW9kID0gZmluZF9tb2RlbChub2RlLCBhZGRyLCBpZCwgJnN0YXR1cyk7DQo+ICsJ bW9kID0gZ2V0X21vZGVsKG5vZGUsICh1aW50OF90KSBlbGVfaWR4LCBpZCk7DQo+ICAJaWYgKCFt b2QpDQo+IC0JCXJldHVybiBzdGF0dXM7DQo+ICsJCXJldHVybiBNRVNIX1NUQVRVU19JTlZBTElE X01PREVMOw0KPiAgDQo+ICAJaWYgKCFtb2QtPnN1Yl9lbmFibGVkIHx8IChtb2QtPmNicyAmJiAh KG1vZC0+Y2JzLT5zdWIpKSkNCj4gIAkJcmV0dXJuIE1FU0hfU1RBVFVTX05PVF9TVUJfTU9EOw0K PiBAQCAtMTM4Nyw3ICsxNDc2LDcgQEAgaW50IG1lc2hfbW9kZWxfc3ViX2FkZChzdHJ1Y3QgbWVz aF9ub2RlICpub2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCwNCj4gIA0KPiAgCWlmICgh bW9kLT5jYnMpDQo+ICAJCS8qIEV4dGVybmFsIG1vZGVscyAqLw0KPiAtCQljb25maWdfdXBkYXRl X21vZGVsX3N1YnNjcmlwdGlvbnMobm9kZSwgbW9kKTsNCj4gKwkJY2ZnX3VwZGF0ZV9tb2RlbF9z dWJzKG5vZGUsIGVsZV9pZHgsIG1vZCk7DQo+ICANCj4gIAlyZXR1cm4gTUVTSF9TVEFUVVNfU1VD Q0VTUzsNCj4gIH0NCj4gQEAgLTEzOTUsMTMgKzE0ODQsMTYgQEAgaW50IG1lc2hfbW9kZWxfc3Vi X2FkZChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCwN Cj4gIGludCBtZXNoX21vZGVsX3N1Yl9vdnIoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2 X3QgYWRkciwgdWludDMyX3QgaWQsDQo+ICAJCQljb25zdCB1aW50OF90ICpncm91cCwgYm9vbCBp c192aXJ0LCB1aW50MTZfdCAqZHN0KQ0KPiAgew0KPiAtCWludCBzdGF0dXM7DQo+ICAJc3RydWN0 IGxfcXVldWUgKnZpcnR1YWxzLCAqc3ViczsNCj4gIAlzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kOw0K PiArCWludCBzdGF0dXMsIGVsZV9pZHggPSBub2RlX2dldF9lbGVtZW50X2lkeChub2RlLCBhZGRy KTsNCj4gKw0KPiArCWlmIChlbGVfaWR4IDwgMCkNCj4gKwkJcmV0dXJuIE1FU0hfU1RBVFVTX0lO VkFMSURfQUREUkVTUzsNCj4gIA0KPiAtCW1vZCA9IGZpbmRfbW9kZWwobm9kZSwgYWRkciwgaWQs ICZzdGF0dXMpOw0KPiArCW1vZCA9IGdldF9tb2RlbChub2RlLCAodWludDhfdCkgZWxlX2lkeCwg aWQpOw0KPiAgCWlmICghbW9kKQ0KPiAtCQlyZXR1cm4gc3RhdHVzOw0KPiArCQlyZXR1cm4gTUVT SF9TVEFUVVNfSU5WQUxJRF9NT0RFTDsNCj4gIA0KPiAgCWlmICghbW9kLT5zdWJfZW5hYmxlZCB8 fCAobW9kLT5jYnMgJiYgIShtb2QtPmNicy0+c3ViKSkpDQo+ICAJCXJldHVybiBNRVNIX1NUQVRV U19OT1RfU1VCX01PRDsNCj4gQEAgLTE0MzksNyArMTUzMSw3IEBAIGludCBtZXNoX21vZGVsX3N1 Yl9vdnIoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgYWRkciwgdWludDMyX3QgaWQs DQo+ICANCj4gIAlpZiAoIW1vZC0+Y2JzKQ0KPiAgCQkvKiBFeHRlcm5hbCBtb2RlbHMgKi8NCj4g LQkJY29uZmlnX3VwZGF0ZV9tb2RlbF9zdWJzY3JpcHRpb25zKG5vZGUsIG1vZCk7DQo+ICsJCWNm Z191cGRhdGVfbW9kZWxfc3Vicyhub2RlLCBlbGVfaWR4LCBtb2QpOw0KPiAgDQo+ICAJcmV0dXJu IHN0YXR1czsNCj4gIH0NCj4gQEAgLTE0NDcsMTMgKzE1MzksMTYgQEAgaW50IG1lc2hfbW9kZWxf c3ViX292cihzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBp ZCwNCj4gIGludCBtZXNoX21vZGVsX3N1Yl9kZWwoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWlu dDE2X3QgYWRkciwgdWludDMyX3QgaWQsDQo+ICAJCQljb25zdCB1aW50OF90ICpncm91cCwgYm9v bCBpc192aXJ0LCB1aW50MTZfdCAqZHN0KQ0KPiAgew0KPiAtCWludCBzdGF0dXM7DQo+ICAJdWlu dDE2X3QgZ3JwOw0KPiAgCXN0cnVjdCBtZXNoX21vZGVsICptb2Q7DQo+ICsJaW50IGVsZV9pZHgg PSBub2RlX2dldF9lbGVtZW50X2lkeChub2RlLCBhZGRyKTsNCj4gIA0KPiAtCW1vZCA9IGZpbmRf bW9kZWwobm9kZSwgYWRkciwgaWQsICZzdGF0dXMpOw0KPiArCWlmIChlbGVfaWR4IDwgMCkNCj4g KwkJcmV0dXJuIE1FU0hfU1RBVFVTX0lOVkFMSURfQUREUkVTUzsNCj4gKw0KPiArCW1vZCA9IGdl dF9tb2RlbChub2RlLCAodWludDhfdCkgZWxlX2lkeCwgaWQpOw0KPiAgCWlmICghbW9kKQ0KPiAt CQlyZXR1cm4gc3RhdHVzOw0KPiArCQlyZXR1cm4gTUVTSF9TVEFUVVNfSU5WQUxJRF9NT0RFTDsN Cj4gIA0KPiAgCWlmICghbW9kLT5zdWJfZW5hYmxlZCB8fCAobW9kLT5jYnMgJiYgIShtb2QtPmNi cy0+c3ViKSkpDQo+ICAJCXJldHVybiBNRVNIX1NUQVRVU19OT1RfU1VCX01PRDsNCj4gQEAgLTE0 ODEsMzQgKzE1NzYsMjMgQEAgaW50IG1lc2hfbW9kZWxfc3ViX2RlbChzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCwNCj4gIA0KPiAgCQlpZiAoIW1vZC0+ Y2JzKQ0KPiAgCQkJLyogRXh0ZXJuYWwgbW9kZWxzICovDQo+IC0JCQljb25maWdfdXBkYXRlX21v ZGVsX3N1YnNjcmlwdGlvbnMobm9kZSwgbW9kKTsNCj4gKwkJCWNmZ191cGRhdGVfbW9kZWxfc3Vi cyhub2RlLCBlbGVfaWR4LCBtb2QpOw0KPiAgCX0NCj4gIA0KPiAgCXJldHVybiBNRVNIX1NUQVRV U19TVUNDRVNTOw0KPiAgfQ0KPiAgDQo+IC1zdGF0aWMgdm9pZCByZW1vdmVfc3VicyhzdHJ1Y3Qg bWVzaF9ub2RlICpub2RlLCBzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kKQ0KPiAtew0KPiAtCWNvbnN0 IHN0cnVjdCBsX3F1ZXVlX2VudHJ5ICplbnRyeTsNCj4gLQlzdHJ1Y3QgbWVzaF9uZXQgKm5ldCA9 IG5vZGVfZ2V0X25ldChub2RlKTsNCj4gLQ0KPiAtCWVudHJ5ID0gbF9xdWV1ZV9nZXRfZW50cmll cyhtb2QtPnN1YnMpOw0KPiAtDQo+IC0JZm9yICg7IGVudHJ5OyBlbnRyeSA9IGVudHJ5LT5uZXh0 KQ0KPiAtCQltZXNoX25ldF9kc3RfdW5yZWcobmV0LCAodWludDE2X3QpIExfUFRSX1RPX1VJTlQo ZW50cnktPmRhdGEpKTsNCj4gLQ0KPiAtCWxfcXVldWVfY2xlYXIobW9kLT5zdWJzLCBOVUxMKTsN Cj4gLQlsX3F1ZXVlX2NsZWFyKG1vZC0+dmlydHVhbHMsIHVucmVmX3ZpcnQpOw0KPiAtfQ0KPiAt DQo+ICBpbnQgbWVzaF9tb2RlbF9zdWJfZGVsX2FsbChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1 aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCkNCj4gIHsNCj4gLQlpbnQgc3RhdHVzOw0KPiAgCXN0 cnVjdCBtZXNoX21vZGVsICptb2Q7DQo+ICsJaW50IGVsZV9pZHggPSBub2RlX2dldF9lbGVtZW50 X2lkeChub2RlLCBhZGRyKTsNCj4gIA0KPiAtCW1vZCA9IGZpbmRfbW9kZWwobm9kZSwgYWRkciwg aWQsICZzdGF0dXMpOw0KPiArCWlmIChlbGVfaWR4IDwgMCkNCj4gKwkJcmV0dXJuIE1FU0hfU1RB VFVTX0lOVkFMSURfQUREUkVTUzsNCj4gKw0KPiArCW1vZCA9IGdldF9tb2RlbChub2RlLCAodWlu dDhfdCkgZWxlX2lkeCwgaWQpOw0KPiAgCWlmICghbW9kKQ0KPiAtCQlyZXR1cm4gc3RhdHVzOw0K PiArCQlyZXR1cm4gTUVTSF9TVEFUVVNfSU5WQUxJRF9NT0RFTDsNCj4gIA0KPiAgCWlmICghbW9k LT5zdWJfZW5hYmxlZCB8fCAobW9kLT5jYnMgJiYgIShtb2QtPmNicy0+c3ViKSkpDQo+ICAJCXJl dHVybiBNRVNIX1NUQVRVU19OT1RfU1VCX01PRDsNCj4gQEAgLTE1MTcsMTcgKzE2MDEsMTUgQEAg aW50IG1lc2hfbW9kZWxfc3ViX2RlbF9hbGwoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2 X3QgYWRkciwgdWludDMyX3QgaWQpDQo+ICANCj4gIAlpZiAoIW1vZC0+Y2JzKQ0KPiAgCQkvKiBF eHRlcm5hbCBtb2RlbHMgKi8NCj4gLQkJY29uZmlnX3VwZGF0ZV9tb2RlbF9zdWJzY3JpcHRpb25z KG5vZGUsIG1vZCk7DQo+ICsJCWNmZ191cGRhdGVfbW9kZWxfc3Vicyhub2RlLCBlbGVfaWR4LCBt b2QpOw0KPiAgDQo+ICAJcmV0dXJuIE1FU0hfU1RBVFVTX1NVQ0NFU1M7DQo+ICB9DQo+ICANCj4g LXN0cnVjdCBtZXNoX21vZGVsICptZXNoX21vZGVsX3NldHVwKHN0cnVjdCBtZXNoX25vZGUgKm5v ZGUsIHVpbnQ4X3QgZWxlX2lkeCwNCj4gLQkJCQkJCQkJdm9pZCAqZGF0YSkNCj4gK3N0YXRpYyBz dHJ1Y3QgbWVzaF9tb2RlbCAqbW9kZWxfc2V0dXAoc3RydWN0IG1lc2hfbmV0ICpuZXQsIHVpbnQ4 X3QgZWxlX2lkeCwNCj4gKwkJCQkJc3RydWN0IG1lc2hfY29uZmlnX21vZGVsICpkYl9tb2QpDQo+ ICB7DQo+IC0Jc3RydWN0IG1lc2hfY29uZmlnX21vZGVsICpkYl9tb2QgPSBkYXRhOw0KPiAgCXN0 cnVjdCBtZXNoX21vZGVsICptb2Q7DQo+IC0Jc3RydWN0IG1lc2hfbmV0ICpuZXQ7DQo+ICAJc3Ry dWN0IG1lc2hfY29uZmlnX3B1YiAqcHViID0gZGJfbW9kLT5wdWI7DQo+ICAJdWludDMyX3QgaTsN Cj4gIA0KPiBAQCAtMTUzNyw4ICsxNjE5LDggQEAgc3RydWN0IG1lc2hfbW9kZWwgKm1lc2hfbW9k ZWxfc2V0dXAoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDhfdCBlbGVfaWR4LA0KPiAgCQly ZXR1cm4gTlVMTDsNCj4gIAl9DQo+ICANCj4gLQltb2QgPSBtZXNoX21vZGVsX25ldyhlbGVfaWR4 LCBkYl9tb2QtPnZlbmRvciA/IGRiX21vZC0+aWQgOg0KPiAtCQkJCQkJZGJfbW9kLT5pZCB8IFZF TkRPUl9JRF9NQVNLKTsNCj4gKwltb2QgPSBtb2RlbF9uZXcoZGJfbW9kLT52ZW5kb3IgPyBkYl9t b2QtPmlkIDoNCj4gKwkJCQkJCVNFVF9JRChTSUdfVkVORE9SLCBkYl9tb2QtPmlkKSk7DQo+ICAN Cj4gIAkvKiBJbXBsaWNpdGx5IGJpbmQgY29uZmlnIHNlcnZlciBtb2RlbCB0byBkZXZpY2Uga2V5 ICovDQo+ICAJaWYgKGRiX21vZC0+aWQgPT0gQ09ORklHX1NSVl9NT0RFTCkgew0KPiBAQCAtMTU1 NywxNyArMTYzOSwxOCBAQCBzdHJ1Y3QgbWVzaF9tb2RlbCAqbWVzaF9tb2RlbF9zZXR1cChzdHJ1 Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50OF90IGVsZV9pZHgsDQo+ICAJCXJldHVybiBtb2Q7DQo+ ICAJfQ0KPiAgDQo+IC0JbmV0ID0gbm9kZV9nZXRfbmV0KG5vZGUpOw0KPiAtDQo+ICAJLyogQWRk IGFwcGxpY2F0aW9uIGtleSBiaW5kaW5ncyBpZiBwcmVzZW50ICovDQo+ICAJaWYgKGRiX21vZC0+ YmluZGluZ3MpIHsNCj4gIAkJbW9kLT5iaW5kaW5ncyA9IGxfcXVldWVfbmV3KCk7DQo+ICAJCWZv ciAoaSA9IDA7IGkgPCBkYl9tb2QtPm51bV9iaW5kaW5nczsgaSsrKQ0KPiAtCQkJbW9kZWxfYmlu ZF9pZHgobm9kZSwgbW9kLCBkYl9tb2QtPmJpbmRpbmdzW2ldKTsNCj4gKwkJCWxfcXVldWVfcHVz aF90YWlsKG1vZC0+YmluZGluZ3MsDQo+ICsJCQkJCUxfVUlOVF9UT19QVFIoZGJfbW9kLT5iaW5k aW5nc1tpXSkpOw0KPiAgCX0NCj4gIA0KPiAtCS8qIEFkZCBwdWJsaWNhdGlvbiBpZiBwcmVzZW50 ICovDQo+IC0JaWYgKHB1Yikgew0KPiArCW1vZC0+cHViX2VuYWJsZWQgPSBkYl9tb2QtPnB1Yl9l bmFibGVkOw0KPiArDQo+ICsJLyogQWRkIHB1YmxpY2F0aW9uIGlmIGVuYWJsZWQgYW5kIHByZXNl bnQgKi8NCj4gKwlpZiAobW9kLT5wdWJfZW5hYmxlZCAmJiBwdWIpIHsNCj4gIAkJdWludDhfdCBy ZXRyYW5zbWl0ID0gcHViLT5jb3VudCArDQo+ICAJCQkJCSgocHViLT5pbnRlcnZhbCAvIDUwIC0g MSkgPDwgMyk7DQo+ICAJCWlmIChwdWItPnZpcnQpDQo+IEBAIC0xNTc5LDggKzE2NjIsMTAgQEAg c3RydWN0IG1lc2hfbW9kZWwgKm1lc2hfbW9kZWxfc2V0dXAoc3RydWN0IG1lc2hfbm9kZSAqbm9k ZSwgdWludDhfdCBlbGVfaWR4LA0KPiAgCQkJCXB1Yi0+dHRsLCBwdWItPnBlcmlvZCwgcmV0cmFu c21pdCk7DQo+ICAJfQ0KPiAgDQo+IC0JLyogQWRkIHN1YnNjcmlwdGlvbnMgaWYgcHJlc2VudCAq Lw0KPiAtCWlmICghZGJfbW9kLT5zdWJzKQ0KPiArCW1vZC0+c3ViX2VuYWJsZWQgPSBkYl9tb2Qt PnN1Yl9lbmFibGVkOw0KPiArDQo+ICsJLyogQWRkIHN1YnNjcmlwdGlvbnMgaWYgZW5hYmxlZCBh bmQgcHJlc2VudCAqLw0KPiArCWlmICghZGJfbW9kLT5zdWJzIHx8ICFtb2QtPnN1Yl9lbmFibGVk KQ0KPiAgCQlyZXR1cm4gbW9kOw0KPiAgDQo+ICAJZm9yIChpID0gMDsgaSA8IGRiX21vZC0+bnVt X3N1YnM7IGkrKykgew0KPiBAQCAtMTYwNSw2ICsxNjkwLDYwIEBAIHN0cnVjdCBtZXNoX21vZGVs ICptZXNoX21vZGVsX3NldHVwKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgZWxlX2lk eCwNCj4gIAlyZXR1cm4gbW9kOw0KPiAgfQ0KPiAgDQo+ICtib29sIG1lc2hfbW9kZWxfYWRkX2Zy b21fc3RvcmFnZShzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50OF90IGVsZV9pZHgsDQo+ICsJ CQkJc3RydWN0IGxfcXVldWUgKm1vZHMsIHN0cnVjdCBsX3F1ZXVlICpkYl9tb2RzKQ0KPiArew0K PiArCXN0cnVjdCBtZXNoX25ldCAqbmV0ID0gbm9kZV9nZXRfbmV0KG5vZGUpOw0KPiArCWNvbnN0 IHN0cnVjdCBsX3F1ZXVlX2VudHJ5ICplbnRyeTsNCj4gKw0KPiArCS8qIEFsbG93IGVtcHR5IGVs ZW1lbnRzICovDQo+ICsJaWYgKCFkYl9tb2RzKQ0KPiArCQlyZXR1cm4gdHJ1ZTsNCj4gKw0KPiAr CWVudHJ5ID0gbF9xdWV1ZV9nZXRfZW50cmllcyhkYl9tb2RzKTsNCj4gKw0KPiArCWZvciAoOyBl bnRyeTsgZW50cnkgPSBlbnRyeS0+bmV4dCkgew0KPiArCQlzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9k Ow0KPiArCQlzdHJ1Y3QgbWVzaF9jb25maWdfbW9kZWwgKmRiX21vZDsNCj4gKwkJdWludDMyX3Qg aWQ7DQo+ICsNCj4gKwkJZGJfbW9kID0gZW50cnktPmRhdGE7DQo+ICsNCj4gKwkJaWQgPSBkYl9t b2QtPnZlbmRvciA/IGRiX21vZC0+aWQgOg0KPiArCQkJCQkJU0VUX0lEKFNJR19WRU5ET1IsIGRi X21vZC0+aWQpOw0KPiArDQo+ICsJCWlmIChsX3F1ZXVlX2ZpbmQobW9kcywgbWF0Y2hfbW9kZWxf aWQsIExfVUlOVF9UT19QVFIoaWQpKSkNCj4gKwkJCXJldHVybiBmYWxzZTsNCj4gKw0KPiArCQlt b2QgPSBtb2RlbF9zZXR1cChuZXQsIGVsZV9pZHgsIGRiX21vZCk7DQo+ICsJCWlmICghbW9kKQ0K PiArCQkJcmV0dXJuIGZhbHNlOw0KPiArDQo+ICsJCWxfcXVldWVfaW5zZXJ0KG1vZHMsIG1vZCwg Y29tcGFyZV9tb2RlbF9pZCwgTlVMTCk7DQo+ICsJfQ0KPiArDQo+ICsJcmV0dXJuIHRydWU7DQo+ ICt9DQo+ICsNCj4gK3ZvaWQgbWVzaF9tb2RlbF9jb252ZXJ0X3RvX3N0b3JhZ2Uoc3RydWN0IGxf cXVldWUgKmRiX21vZHMsDQo+ICsJCQkJCQkJc3RydWN0IGxfcXVldWUgKm1vZHMpDQo+ICt7DQo+ ICsNCj4gKwljb25zdCBzdHJ1Y3QgbF9xdWV1ZV9lbnRyeSAqZW50cnkgPSBsX3F1ZXVlX2dldF9l bnRyaWVzKG1vZHMpOw0KPiArDQo+ICsJZm9yICg7IGVudHJ5OyBlbnRyeSA9IGVudHJ5LT5uZXh0 KSB7DQo+ICsJCXN0cnVjdCBtZXNoX21vZGVsICptb2QgPSBlbnRyeS0+ZGF0YTsNCj4gKwkJc3Ry dWN0IG1lc2hfY29uZmlnX21vZGVsICpkYl9tb2Q7DQo+ICsNCj4gKwkJZGJfbW9kID0gbF9uZXco c3RydWN0IG1lc2hfY29uZmlnX21vZGVsLCAxKTsNCj4gKwkJZGJfbW9kLT5pZCA9IG1vZC0+aWQ7 DQo+ICsJCWRiX21vZC0+dmVuZG9yID0gSVNfVkVORE9SKG1vZC0+aWQpOw0KPiArCQlkYl9tb2Qt PnB1Yl9lbmFibGVkID0gbW9kLT5wdWJfZW5hYmxlZDsNCj4gKwkJZGJfbW9kLT5zdWJfZW5hYmxl ZCA9IG1vZC0+c3ViX2VuYWJsZWQ7DQo+ICsJCWxfcXVldWVfcHVzaF90YWlsKGRiX21vZHMsIGRi X21vZCk7DQo+ICsJfQ0KPiArfQ0KPiArDQo+ICB1aW50MTZfdCBtZXNoX21vZGVsX29wY29kZV9z ZXQodWludDMyX3Qgb3Bjb2RlLCB1aW50OF90ICpidWYpDQo+ICB7DQo+ICAJaWYgKG9wY29kZSA8 PSAweDdlKSB7DQo+IEBAIC0xNjY5LDcgKzE4MDgsNyBAQCBib29sIG1lc2hfbW9kZWxfb3Bjb2Rl X2dldChjb25zdCB1aW50OF90ICpidWYsIHVpbnQxNl90IHNpemUsDQo+ICAJcmV0dXJuIHRydWU7 DQo+ICB9DQo+ICANCj4gLXZvaWQgbW9kZWxfYnVpbGRfY29uZmlnKHZvaWQgKm1vZGVsLCB2b2lk ICptc2dfYnVpbGRlcikNCj4gK3ZvaWQgbWVzaF9tb2RlbF9idWlsZF9jb25maWcodm9pZCAqbW9k ZWwsIHZvaWQgKm1zZ19idWlsZGVyKQ0KPiAgew0KPiAgCXN0cnVjdCBsX2RidXNfbWVzc2FnZV9i dWlsZGVyICpidWlsZGVyID0gbXNnX2J1aWxkZXI7DQo+ICAJc3RydWN0IG1lc2hfbW9kZWwgKm1v ZCA9IG1vZGVsOw0KPiBAQCAtMTY4NSwxNCArMTgyNCwxNCBAQCB2b2lkIG1vZGVsX2J1aWxkX2Nv bmZpZyh2b2lkICptb2RlbCwgdm9pZCAqbXNnX2J1aWxkZXIpDQo+ICAJbF9kYnVzX21lc3NhZ2Vf YnVpbGRlcl9lbnRlcl9zdHJ1Y3QoYnVpbGRlciwgInFhe3N2fSIpOw0KPiAgDQo+ICAJLyogTW9k ZWwgaWQgKi8NCj4gLQlpZCA9IG1vZC0+aWQgJiAweGZmZmY7DQo+ICsJaWQgPSBNT0RFTF9JRCht b2QtPmlkKTsNCj4gIAlsX2RidXNfbWVzc2FnZV9idWlsZGVyX2FwcGVuZF9iYXNpYyhidWlsZGVy LCAncScsICZpZCk7DQo+ICANCj4gIAlsX2RidXNfbWVzc2FnZV9idWlsZGVyX2VudGVyX2FycmF5 KGJ1aWxkZXIsICJ7c3Z9Iik7DQo+ICANCj4gIAkvKiBGb3IgdmVuZG9yIG1vZGVscywgYWRkIHZl bmRvciBpZCAqLw0KPiAtCWlmICgobW9kLT5pZCAmIFZFTkRPUl9JRF9NQVNLKSAhPSBWRU5ET1Jf SURfTUFTSykgew0KPiAtCQl1aW50MTZfdCB2ZW5kb3IgPSBtb2QtPmlkID4+IDE2Ow0KPiArCWlm IChJU19WRU5ET1IobW9kLT5pZCkpIHsNCj4gKwkJdWludDE2X3QgdmVuZG9yID0gVkVORE9SX0lE KG1vZC0+aWQpOw0KPiAgCQlkYnVzX2FwcGVuZF9kaWN0X2VudHJ5X2Jhc2ljKGJ1aWxkZXIsICJW ZW5kb3IiLCAicSIsICZ2ZW5kb3IpOw0KPiAgCX0NCj4gIA0KPiBAQCAtMTcxNSwzNiArMTg1NCwx MDEgQEAgdm9pZCBtb2RlbF9idWlsZF9jb25maWcodm9pZCAqbW9kZWwsIHZvaWQgKm1zZ19idWls ZGVyKQ0KPiAgCWxfZGJ1c19tZXNzYWdlX2J1aWxkZXJfbGVhdmVfc3RydWN0KGJ1aWxkZXIpOw0K PiAgfQ0KPiAgDQo+IC12b2lkIG1lc2hfbW9kZWxfZW5hYmxlX3B1YihzdHJ1Y3QgbWVzaF9tb2Rl bCAqbW9kLCBib29sIGVuYWJsZSkNCj4gK3ZvaWQgbWVzaF9tb2RlbF91cGRhdGVfb3B0cyhzdHJ1 Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50OF90IGVsZV9pZHgsDQo+ICsJCQkJc3RydWN0IGxfcXVl dWUgKmN1cnIsIHN0cnVjdCBsX3F1ZXVlICp1cGRhdGVkKQ0KPiAgew0KPiAtCW1vZC0+cHViX2Vu YWJsZWQgPSBlbmFibGU7DQo+ICsJdWludDE2X3QgcHJpbWFyeTsNCj4gKwljb25zdCBzdHJ1Y3Qg bF9xdWV1ZV9lbnRyeSAqZW50cnk7DQo+ICANCj4gLQlpZiAoIW1vZC0+cHViX2VuYWJsZWQgJiYg bW9kLT5wdWIpIHsNCj4gLQkJaWYgKG1vZC0+cHViLT52aXJ0KQ0KPiAtCQkJdW5yZWZfdmlydCht b2QtPnB1Yi0+dmlydCk7DQo+ICsJcHJpbWFyeSA9IG5vZGVfZ2V0X3ByaW1hcnkobm9kZSk7DQo+ ICsJZW50cnkgPSBsX3F1ZXVlX2dldF9lbnRyaWVzKGN1cnIpOw0KPiAgDQo+IC0JCWxfZnJlZSht b2QtPnB1Yik7DQo+IC0JCW1vZC0+cHViID0gTlVMTDsNCj4gLQl9DQo+IC19DQo+ICsJZm9yICg7 IGVudHJ5OyBlbnRyeSA9IGVudHJ5LT5uZXh0KSB7DQo+ICsJCXN0cnVjdCBtZXNoX21vZGVsICpt b2QsICp1cGRhdGVkX21vZCA9IGVudHJ5LT5kYXRhOw0KPiArCQl1aW50MzJfdCBpZCA9IHVwZGF0 ZWRfbW9kLT5pZDsNCj4gKwkJYm9vbCB1cGRhdGVkX29wdCwgdmVuZG9yID0gSVNfVkVORE9SKGlk KTsNCj4gIA0KPiAtYm9vbCBtZXNoX21vZGVsX2lzX3B1Yl9lbmFibGVkKHN0cnVjdCBtZXNoX21v ZGVsICptb2QpDQo+IC17DQo+IC0JcmV0dXJuIG1vZC0+cHViX2VuYWJsZWQ7DQo+IC19DQo+ICsJ CW1vZCA9IGxfcXVldWVfZmluZChjdXJyLCBtYXRjaF9tb2RlbF9pZCwgTF9VSU5UX1RPX1BUUihp ZCkpOw0KPiArCQlpZiAoIW1vZCkNCj4gKwkJCWNvbnRpbnVlOw0KPiAgDQo+IC12b2lkIG1lc2hf bW9kZWxfZW5hYmxlX3N1YihzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCBzdHJ1Y3QgbWVzaF9tb2Rl bCAqbW9kLA0KPiAtCQkJCQkJCQlib29sIGVuYWJsZSkNCj4gLXsNCj4gLQltb2QtPnN1Yl9lbmFi bGVkID0gZW5hYmxlOw0KPiArCQlpZiAoIXZlbmRvcikNCj4gKwkJCWlkID0gTU9ERUxfSUQoaWQp Ow0KPiAgDQo+IC0JaWYgKCFtb2QtPnN1Yl9lbmFibGVkKQ0KPiAtCQlyZW1vdmVfc3Vicyhub2Rl LCBtb2QpOw0KPiArCQl1cGRhdGVkX29wdCA9IHVwZGF0ZWRfbW9kLT5wdWJfZW5hYmxlZDsNCj4g KwkJaWYgKG1vZC0+cHViX2VuYWJsZWQgIT0gdXBkYXRlZF9vcHQpIHsNCj4gKwkJCW1vZGVsX2Vu YWJsZV9wdWIobW9kLCB1cGRhdGVkX29wdCk7DQo+ICsJCQltZXNoX2NvbmZpZ19tb2RlbF9wdWJf ZW5hYmxlKG5vZGVfY29uZmlnX2dldChub2RlKSwNCj4gKwkJCQkJCQlwcmltYXJ5ICsgZWxlX2lk eCwgaWQsDQo+ICsJCQkJCQkJdmVuZG9yLCB1cGRhdGVkX29wdCk7DQo+ICsJCX0NCj4gKw0KPiAr CQl1cGRhdGVkX29wdCA9IHVwZGF0ZWRfbW9kLT5zdWJfZW5hYmxlZDsNCj4gKw0KPiArCQlpZiAo bW9kLT5wdWJfZW5hYmxlZCAhPSB1cGRhdGVkX29wdCkgew0KPiArCQkJbW9kZWxfZW5hYmxlX3N1 Yihub2RlLCBtb2QsIHVwZGF0ZWRfb3B0KTsNCj4gKwkJCW1lc2hfY29uZmlnX21vZGVsX3N1Yl9l bmFibGUobm9kZV9jb25maWdfZ2V0KG5vZGUpLA0KPiArCQkJCQkJCXByaW1hcnkgKyBlbGVfaWR4 LCBpZCwNCj4gKwkJCQkJCQl2ZW5kb3IsIHVwZGF0ZWRfb3B0KTsNCj4gKwkJCX0NCj4gKwkJfQ0K PiAgfQ0KPiAgDQo+IC1ib29sIG1lc2hfbW9kZWxfaXNfc3ViX2VuYWJsZWQoc3RydWN0IG1lc2hf bW9kZWwgKm1vZCkNCj4gKy8qIFBvcHVsYXRlIGNvbXBvc2l0aW9uIGJ1ZmZlciB3aXRoIG1vZGVs IElEcyAqLw0KPiArdWludDE2X3QgbWVzaF9tb2RlbF9nZW5lcmF0ZV9jb21wb3NpdGlvbihzdHJ1 Y3QgbF9xdWV1ZSAqbW9kcywgdWludDE2X3QgYnVmX3N6LA0KPiArCQkJCQkJCQl1aW50OF90ICpi dWYpDQo+ICB7DQo+IC0JcmV0dXJuIG1vZC0+c3ViX2VuYWJsZWQ7DQo+ICsJY29uc3Qgc3RydWN0 IGxfcXVldWVfZW50cnkgKmVudHJ5Ow0KPiArCXVpbnQ4X3QgbnVtX3MgPSAwLCBudW1fdiA9IDA7 DQo+ICsJdWludDhfdCAqbW9kX2J1ZjsNCj4gKwl1aW50MTZfdCBuOw0KPiArDQo+ICsJLyogU3Rv cmUgbW9kZWxzIElEcywgc3RvcmUgbnVtX3MgYW5kIG51bV92IGxhdGVyICovDQo+ICsJbW9kX2J1 ZiA9IGJ1ZjsNCj4gKwluID0gMjsNCj4gKw0KPiArCWVudHJ5ID0gbF9xdWV1ZV9nZXRfZW50cmll cyhtb2RzKTsNCj4gKw0KPiArCS8qIEdldCBTSUcgbW9kZWxzICovDQo+ICsJZm9yICg7IGVudHJ5 OyBlbnRyeSA9IGVudHJ5LT5uZXh0KSB7DQo+ICsJCXN0cnVjdCBtZXNoX21vZGVsICptb2QgPSBl bnRyeS0+ZGF0YTsNCj4gKw0KPiArCQlpZiAobiArIDIgPiBidWZfc3opDQo+ICsJCQlnb3RvIGRv bmU7DQo+ICsNCj4gKwkJaWYgKElTX1ZFTkRPUihtb2QtPmlkKSkNCj4gKwkJCWNvbnRpbnVlOw0K PiArDQo+ICsJCWxfcHV0X2xlMTYoKHVpbnQxNl90KSAoTU9ERUxfSUQobW9kLT5pZCkpLCBidWYg KyBuKTsNCj4gKwkJbiArPSAyOw0KPiArCQludW1fcysrOw0KPiArCX0NCj4gKw0KPiArCS8qIEdl dCB2ZW5kb3IgbW9kZWxzICovDQo+ICsJZW50cnkgPSBsX3F1ZXVlX2dldF9lbnRyaWVzKG1vZHMp Ow0KPiArDQo+ICsJZm9yICg7IGVudHJ5OyBlbnRyeSA9IGVudHJ5LT5uZXh0KSB7DQo+ICsJCXN0 cnVjdCBtZXNoX21vZGVsICptb2QgPSBlbnRyeS0+ZGF0YTsNCj4gKwkJdWludDE2X3QgdmVuZG9y X2lkOw0KPiArDQo+ICsJCWlmIChuICsgNCA+IGJ1Zl9zeikNCj4gKwkJCWdvdG8gZG9uZTsNCj4g Kw0KPiArCQlpZiAoIUlTX1ZFTkRPUihtb2QtPmlkKSkNCj4gKwkJCWNvbnRpbnVlOw0KPiArDQo+ ICsJCXZlbmRvcl9pZCA9ICh1aW50MTZfdCkgKFZFTkRPUl9JRChtb2QtPmlkKSk7DQo+ICsJCWxf cHV0X2xlMTYodmVuZG9yX2lkLCBidWYgKyBuKTsNCj4gKwkJbiArPSAyOw0KPiArCQlsX3B1dF9s ZTE2KCh1aW50MTZfdCkgKE1PREVMX0lEKG1vZC0+aWQpKSwgYnVmICsgbik7DQo+ICsJCW4gKz0g MjsNCj4gKwkJbnVtX3YrKzsNCj4gKwl9DQo+ICsNCj4gK2RvbmU6DQo+ICsJbW9kX2J1ZlswXSA9 IG51bV9zOw0KPiArCW1vZF9idWZbMV0gPSBudW1fdjsNCj4gKwlyZXR1cm4gbjsNCj4gIH0NCj4g IA0KPiAgdm9pZCBtZXNoX21vZGVsX2luaXQodm9pZCkNCj4gZGlmZiAtLWdpdCBhL21lc2gvbW9k ZWwuaCBiL21lc2gvbW9kZWwuaA0KPiBpbmRleCAwMzc3ZDNmZGQuLjBkOGRkZGY5MiAxMDA2NDQN Cj4gLS0tIGEvbWVzaC9tb2RlbC5oDQo+ICsrKyBiL21lc2gvbW9kZWwuaA0KPiBAQCAtMiw3ICsy LDcgQEANCj4gICAqDQo+ICAgKiAgQmx1ZVogLSBCbHVldG9vdGggcHJvdG9jb2wgc3RhY2sgZm9y IExpbnV4DQo+ICAgKg0KPiAtICogIENvcHlyaWdodCAoQykgMjAxOCAgSW50ZWwgQ29ycG9yYXRp b24uIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQo+ICsgKiAgQ29weXJpZ2h0IChDKSAyMDE4LTIwMjAg IEludGVsIENvcnBvcmF0aW9uLiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KPiAgICoNCj4gICAqDQo+ ICAgKiAgVGhpcyBsaWJyYXJ5IGlzIGZyZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmlidXRl IGl0IGFuZC9vcg0KPiBAQCAtMjIsMTQgKzIyLDE3IEBAIHN0cnVjdCBtZXNoX21vZGVsOw0KPiAg I2RlZmluZSBNQVhfQklORElOR1MJMTANCj4gICNkZWZpbmUgTUFYX0dSUF9QRVJfTU9ECTEwDQo+ ICANCj4gLSNkZWZpbmUgT1BfTU9ERUxfVEVTVAkJCTB4ODAwMGZmZmUNCj4gLSNkZWZpbmUgT1Bf TU9ERUxfSU5WQUxJRAkJMHg4MDAwZmZmZg0KPiArI2RlZmluZSBBQ1RJT05fQURECTENCj4gKyNk ZWZpbmUgQUNUSU9OX1VQREFURQkyDQo+ICsjZGVmaW5lIEFDVElPTl9ERUxFVEUJMw0KPiAgDQo+ IC0jZGVmaW5lIFVTRV9QVUJfVkFMVUUJCQkweDAwDQo+ICsvKiBGb3IgaW50ZXJuYWwgcmVwcmVz ZW50YXRpb24gb2YgU0lHIGRlZmluZWQgbW9kZWxzICovDQo+ICsjZGVmaW5lIFNJR19WRU5ET1IJ MHhGRkZGDQo+ICANCj4gLSNkZWZpbmUgQUNUSU9OX0FERAkJMQ0KPiAtI2RlZmluZSBBQ1RJT05f VVBEQVRFCQkyDQo+IC0jZGVmaW5lIEFDVElPTl9ERUxFVEUJCTMNCj4gKyNkZWZpbmUgSVNfVkVO RE9SKHgpCSgoeCkgPCAoKHVpbnQzMl90KShTSUdfVkVORE9SKSA8PCAxNikpDQo+ICsjZGVmaW5l IFNFVF9JRCh2LCBtKQkoKCgodWludDMyX3QpICh2KSkgPDwgMTYpIHwgKG0pKQ0KPiArI2RlZmlu ZSBNT0RFTF9JRCh4KQkoKHgpICYgflZFTkRPUl9JRF9NQVNLKQ0KPiArI2RlZmluZSBWRU5ET1Jf SUQoeCkJKCh4KSA+PiAxNikNCj4gIA0KPiAgc3RydWN0IG1lc2hfdmlydHVhbDsNCj4gIA0KPiBA QCAtNjAsNjEgKzYzLDYyIEBAIHN0cnVjdCBtZXNoX21vZGVsX29wcyB7DQo+ICAJbWVzaF9tb2Rl bF9zdWJfY2Igc3ViOw0KPiAgfTsNCj4gIA0KPiAtc3RydWN0IG1lc2hfbW9kZWwgKm1lc2hfbW9k ZWxfbmV3KHVpbnQ4X3QgZWxlX2lkeCwgdWludDMyX3QgbW9kX2lkKTsNCj4gK2Jvb2wgbWVzaF9t b2RlbF9hZGQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgc3RydWN0IGxfcXVldWUgKm1vZHMsDQo+ ICsJCQl1aW50MzJfdCBpZCwgc3RydWN0IGxfZGJ1c19tZXNzYWdlX2l0ZXIgKm9wdHMpOw0KPiAg dm9pZCBtZXNoX21vZGVsX2ZyZWUodm9pZCAqZGF0YSk7DQo+IC11aW50MzJfdCBtZXNoX21vZGVs X2dldF9tb2RlbF9pZChjb25zdCBzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kZWwpOw0KPiAgYm9vbCBt ZXNoX21vZGVsX3JlZ2lzdGVyKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgZWxlX2lk eCwNCj4gLQkJCXVpbnQzMl90IG1vZF9pZCwgY29uc3Qgc3RydWN0IG1lc2hfbW9kZWxfb3BzICpj YnMsDQo+ICsJCQl1aW50MzJfdCBpZCwgY29uc3Qgc3RydWN0IG1lc2hfbW9kZWxfb3BzICpjYnMs DQo+ICAJCQkJCQkJdm9pZCAqdXNlcl9kYXRhKTsNCj4gLXN0cnVjdCBtZXNoX21vZGVsICptZXNo X21vZGVsX3NldHVwKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgZWxlX2lkeCwNCj4g LQkJCQkJCQkJdm9pZCAqZGF0YSk7DQo+ICtib29sIG1lc2hfbW9kZWxfYWRkX2Zyb21fc3RvcmFn ZShzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50OF90IGVsZV9pZHgsDQo+ICsJCQkJc3RydWN0 IGxfcXVldWUgKm1vZHMsIHN0cnVjdCBsX3F1ZXVlICpkYl9tb2RzKTsNCj4gK3ZvaWQgbWVzaF9t b2RlbF9jb252ZXJ0X3RvX3N0b3JhZ2Uoc3RydWN0IGxfcXVldWUgKmRiX21vZHMsDQo+ICsJCQkJ CQkJc3RydWN0IGxfcXVldWUgKm1vZHMpOw0KPiAgc3RydWN0IG1lc2hfbW9kZWxfcHViICptZXNo X21vZGVsX3B1Yl9nZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwNCj4gLQkJCQl1aW50MTZfdCBh ZGRyLCB1aW50MzJfdCBtb2RfaWQsIGludCAqc3RhdHVzKTsNCj4gLWludCBtZXNoX21vZGVsX3B1 Yl9zZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgYWRkciwgdWludDMyX3QgaWQs DQo+IC0JCQljb25zdCB1aW50OF90ICpwdWJfYWRkciwgdWludDE2X3QgaWR4LCBib29sIGNyZWRf ZmxhZywNCj4gKwkJCQkJCXVpbnQxNl90IGVsZV9hZGRyLA0KPiArCQkJCQkJdWludDMyX3QgaWQs IGludCAqc3RhdHVzKTsNCj4gK2ludCBtZXNoX21vZGVsX3B1Yl9zZXQoc3RydWN0IG1lc2hfbm9k ZSAqbm9kZSwgdWludDE2X3QgZWxlX2FkZHIsIHVpbnQzMl90IGlkLA0KPiArCQkJY29uc3QgdWlu dDhfdCAqYWRkciwgdWludDE2X3QgaWR4LCBib29sIGNyZWRfZmxhZywNCj4gIAkJCXVpbnQ4X3Qg dHRsLCB1aW50OF90IHBlcmlvZCwgdWludDhfdCByZXRyYW5zbWl0LA0KPiAgCQkJYm9vbCBpc192 aXJ0LCB1aW50MTZfdCAqZHN0KTsNCj4gIA0KPiAtaW50IG1lc2hfbW9kZWxfYmluZGluZ19hZGQo c3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgYWRkciwgdWludDMyX3QgaWQsDQo+IC0J CQkJCQkJCXVpbnQxNl90IGlkeCk7DQo+IC1pbnQgbWVzaF9tb2RlbF9iaW5kaW5nX2RlbChzdHJ1 Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCwNCj4gLQkJCQkJ CQkJdWludDE2X3QgaWR4KTsNCj4gLWludCBtZXNoX21vZGVsX2dldF9iaW5kaW5ncyhzdHJ1Y3Qg bWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCwNCj4gLQkJCQl1aW50 OF90ICpidWYsIHVpbnQxNl90IGJ1Zl9sZW4sIHVpbnQxNl90ICpzaXplKTsNCj4gLWludCBtZXNo X21vZGVsX3N1Yl9hZGQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgYWRkciwgdWlu dDMyX3QgaWQsDQo+ICtpbnQgbWVzaF9tb2RlbF9iaW5kaW5nX2FkZChzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlLCB1aW50MTZfdCBlbGVfYWRkciwNCj4gKwkJCQkJCXVpbnQzMl90IGlkLCB1aW50MTZf dCBpZHgpOw0KPiAraW50IG1lc2hfbW9kZWxfYmluZGluZ19kZWwoc3RydWN0IG1lc2hfbm9kZSAq bm9kZSwgdWludDE2X3QgZWxlX2FkZHIsDQo+ICsJCQkJCQl1aW50MzJfdCBpZCwgdWludDE2X3Qg aWR4KTsNCj4gK2ludCBtZXNoX21vZGVsX2dldF9iaW5kaW5ncyhzdHJ1Y3QgbWVzaF9ub2RlICpu b2RlLCB1aW50MTZfdCBlbGVfYWRkciwNCj4gKwkJCQl1aW50MzJfdCBpZCwgdWludDhfdCAqYnVm LCB1aW50MTZfdCBidWZfc3osDQo+ICsJCQkJCQkJCXVpbnQxNl90ICpsZW4pOw0KPiAraW50IG1l c2hfbW9kZWxfc3ViX2FkZChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBlbGVfYWRk ciwgdWludDMyX3QgaWQsDQo+ICAJCQkJY29uc3QgdWludDhfdCAqZ3JwLCBib29sIGJfdmlydCwg dWludDE2X3QgKmRzdCk7DQo+IC1pbnQgbWVzaF9tb2RlbF9zdWJfZGVsKHN0cnVjdCBtZXNoX25v ZGUgKm5vZGUsIHVpbnQxNl90IGFkZHIsIHVpbnQzMl90IGlkLA0KPiAraW50IG1lc2hfbW9kZWxf c3ViX2RlbChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBlbGVfYWRkciwgdWludDMy X3QgaWQsDQo+ICAJCQkJY29uc3QgdWludDhfdCAqZ3JwLCBib29sIGJfdmlydCwgdWludDE2X3Qg KmRzdCk7DQo+ICBpbnQgbWVzaF9tb2RlbF9zdWJfZGVsX2FsbChzdHJ1Y3QgbWVzaF9ub2RlICpu b2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCk7DQo+ICBpbnQgbWVzaF9tb2RlbF9zdWJf b3ZyKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IGFkZHIsIHVpbnQzMl90IGlkLA0K PiAgCQkJCWNvbnN0IHVpbnQ4X3QgKmdycCwgYm9vbCBiX3ZpcnQsIHVpbnQxNl90ICpkc3QpOw0K PiAtaW50IG1lc2hfbW9kZWxfc3ViX2dldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZf dCBhZGRyLCB1aW50MzJfdCBpZCwNCj4gK2ludCBtZXNoX21vZGVsX3N1Yl9nZXQoc3RydWN0IG1l c2hfbm9kZSAqbm9kZSwgdWludDE2X3QgZWxlX2FkZHIsIHVpbnQzMl90IGlkLA0KPiAgCQkJdWlu dDhfdCAqYnVmLCB1aW50MTZfdCBidWZfc2l6ZSwgdWludDE2X3QgKnNpemUpOw0KPiAgdWludDE2 X3QgbWVzaF9tb2RlbF9jZmdfYmxrKHVpbnQ4X3QgKnBrdCk7DQo+ICBib29sIG1lc2hfbW9kZWxf c2VuZChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBzcmMsIHVpbnQxNl90IGRzdCwN Cj4gIAkJCQkJdWludDE2X3QgYXBwX2lkeCwgdWludDE2X3QgbmV0X2lkeCwNCj4gIAkJCQkJdWlu dDhfdCB0dGwsIGJvb2wgc2VnbWVudGVkLA0KPiAgCQkJCQljb25zdCB2b2lkICptc2csIHVpbnQx Nl90IG1zZ19sZW4pOw0KPiAtaW50IG1lc2hfbW9kZWxfcHVibGlzaChzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlLCB1aW50MzJfdCBtb2RfaWQsIHVpbnQxNl90IHNyYywNCj4gK2ludCBtZXNoX21vZGVs X3B1Ymxpc2goc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDMyX3QgaWQsIHVpbnQxNl90IHNy YywNCj4gIAkJCQl1aW50OF90IHR0bCwgY29uc3Qgdm9pZCAqbXNnLCB1aW50MTZfdCBtc2dfbGVu KTsNCj4gIGJvb2wgbWVzaF9tb2RlbF9yeChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCBib29sIHN6 bWljdCwgdWludDMyX3Qgc2VxMCwNCj4gIAkJCXVpbnQzMl90IHNlcSwgdWludDMyX3QgaXZfaW5k ZXgsIHVpbnQxNl90IG5ldF9pZHgsDQo+ICAJCQl1aW50MTZfdCBzcmMsIHVpbnQxNl90IGRzdCwg dWludDhfdCBrZXlfYWlkLA0KPiAgCQkJY29uc3QgdWludDhfdCAqZGF0YSwgdWludDE2X3Qgc2l6 ZSk7DQo+ICB2b2lkIG1lc2hfbW9kZWxfYXBwX2tleV9nZW5lcmF0ZV9uZXcoc3RydWN0IG1lc2hf bm9kZSAqbm9kZSwgdWludDE2X3QgbmV0X2lkeCk7DQo+IC12b2lkIG1lc2hfbW9kZWxfYXBwX2tl eV9kZWxldGUoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgc3RydWN0IGxfcXVldWUgKm1vZGVscywN Cj4gLQkJCQkJCQkJdWludDE2X3QgaWR4KTsNCj4gK3ZvaWQgbWVzaF9tb2RlbF9hcHBfa2V5X2Rl bGV0ZShzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBlbGVfaWR4LA0KPiArCQkJCXN0 cnVjdCBsX3F1ZXVlICptb2RlbHMsIHVpbnQxNl90IGFwcF9pZHgpOw0KPiAgc3RydWN0IGxfcXVl dWUgKm1lc2hfbW9kZWxfZ2V0X2FwcGtleXMoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSk7DQo+ICB1 aW50MTZfdCBtZXNoX21vZGVsX29wY29kZV9zZXQodWludDMyX3Qgb3Bjb2RlLCB1aW50OF90ICpi dWYpOw0KPiAgYm9vbCBtZXNoX21vZGVsX29wY29kZV9nZXQoY29uc3QgdWludDhfdCAqYnVmLCB1 aW50MTZfdCBzaXplLCB1aW50MzJfdCAqb3Bjb2RlLA0KPiAgCQkJCQkJCQl1aW50MTZfdCAqbik7 DQo+IC12b2lkIG1vZGVsX2J1aWxkX2NvbmZpZyh2b2lkICptb2RlbCwgdm9pZCAqbXNnX2J1aWxk ZXIpOw0KPiAtDQo+IC12b2lkIG1lc2hfbW9kZWxfZW5hYmxlX3B1YihzdHJ1Y3QgbWVzaF9tb2Rl bCAqbW9kLCBib29sIGVuYWJsZSk7DQo+IC1ib29sIG1lc2hfbW9kZWxfaXNfcHViX2VuYWJsZWQo c3RydWN0IG1lc2hfbW9kZWwgKm1vZCk7DQo+IC12b2lkIG1lc2hfbW9kZWxfZW5hYmxlX3N1Yihz dHJ1Y3QgbWVzaF9ub2RlICpub2RlLCBzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kLA0KPiAtCQkJCQkJ CQlib29sIGVuYWJsZSk7DQo+IC1ib29sIG1lc2hfbW9kZWxfaXNfc3ViX2VuYWJsZWQoc3RydWN0 IG1lc2hfbW9kZWwgKm1vZCk7DQo+IC0NCj4gK3ZvaWQgbWVzaF9tb2RlbF9idWlsZF9jb25maWco dm9pZCAqbW9kZWwsIHZvaWQgKm1zZ19idWlsZGVyKTsNCj4gK3ZvaWQgbWVzaF9tb2RlbF91cGRh dGVfb3B0cyhzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50OF90IGVsZV9pZHgsDQo+ICsJCQkJ c3RydWN0IGxfcXVldWUgKmN1cnIsIHN0cnVjdCBsX3F1ZXVlICp1cGRhdGVkKTsNCj4gK3VpbnQx Nl90IG1lc2hfbW9kZWxfZ2VuZXJhdGVfY29tcG9zaXRpb24oc3RydWN0IGxfcXVldWUgKm1vZHMs IHVpbnQxNl90IGJ1Zl9zeiwNCj4gKwkJCQkJCQkJdWludDhfdCAqYnVmKTsNCj4gIHZvaWQgbWVz aF9tb2RlbF9pbml0KHZvaWQpOw0KPiAgdm9pZCBtZXNoX21vZGVsX2NsZWFudXAodm9pZCk7DQo+ IGRpZmYgLS1naXQgYS9tZXNoL25vZGUuYyBiL21lc2gvbm9kZS5jDQo+IGluZGV4IDliOTdhYTky Ny4uM2RjYTczY2VmIDEwMDY0NA0KPiAtLS0gYS9tZXNoL25vZGUuYw0KPiArKysgYi9tZXNoL25v ZGUuYw0KPiBAQCAtMiw3ICsyLDcgQEANCj4gICAqDQo+ICAgKiAgQmx1ZVogLSBCbHVldG9vdGgg cHJvdG9jb2wgc3RhY2sgZm9yIExpbnV4DQo+ICAgKg0KPiAtICogIENvcHlyaWdodCAoQykgMjAx Ny0yMDE5ICBJbnRlbCBDb3Jwb3JhdGlvbi4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCj4gKyAqICBD b3B5cmlnaHQgKEMpIDIwMTctMjAyMCAgSW50ZWwgQ29ycG9yYXRpb24uIEFsbCByaWdodHMgcmVz ZXJ2ZWQuDQo+ICAgKg0KPiAgICoNCj4gICAqICBUaGlzIGxpYnJhcnkgaXMgZnJlZSBzb2Z0d2Fy ZTsgeW91IGNhbiByZWRpc3RyaWJ1dGUgaXQgYW5kL29yDQo+IEBAIC0xODYsMjggKzE4Niw2IEBA IHN0YXRpYyBib29sIG1hdGNoX2VsZW1lbnRfcGF0aChjb25zdCB2b2lkICphLCBjb25zdCB2b2lk ICpiKQ0KPiAgCXJldHVybiAoIXN0cmNtcChlbGVtZW50LT5wYXRoLCBwYXRoKSk7DQo+ICB9DQo+ ICANCj4gLXN0YXRpYyBib29sIG1hdGNoX21vZGVsX2lkKGNvbnN0IHZvaWQgKmEsIGNvbnN0IHZv aWQgKmIpDQo+IC17DQo+IC0JY29uc3Qgc3RydWN0IG1lc2hfbW9kZWwgKm1vZCA9IGE7DQo+IC0J dWludDMyX3QgbW9kX2lkID0gTF9QVFJfVE9fVUlOVChiKTsNCj4gLQ0KPiAtCXJldHVybiBtZXNo X21vZGVsX2dldF9tb2RlbF9pZChtb2QpID09IG1vZF9pZDsNCj4gLX0NCj4gLQ0KPiAtc3RhdGlj IGludCBjb21wYXJlX21vZGVsX2lkKGNvbnN0IHZvaWQgKmEsIGNvbnN0IHZvaWQgKmIsIHZvaWQg KnVzZXJfZGF0YSkNCj4gLXsNCj4gLQl1aW50MzJfdCBhX2lkID0gbWVzaF9tb2RlbF9nZXRfbW9k ZWxfaWQoYSk7DQo+IC0JdWludDMyX3QgYl9pZCA9IG1lc2hfbW9kZWxfZ2V0X21vZGVsX2lkKGIp Ow0KPiAtDQo+IC0JaWYgKGFfaWQgPCBiX2lkKQ0KPiAtCQlyZXR1cm4gLTE7DQo+IC0NCj4gLQlp ZiAoYV9pZCA+IGJfaWQpDQo+IC0JCXJldHVybiAxOw0KPiAtDQo+IC0JcmV0dXJuIDA7DQo+IC19 DQo+IC0NCj4gIHN0cnVjdCBtZXNoX25vZGUgKm5vZGVfZmluZF9ieV91dWlkKHVpbnQ4X3QgdXVp ZFsxNl0pDQo+ICB7DQo+ICAJcmV0dXJuIGxfcXVldWVfZmluZChub2RlcywgbWF0Y2hfZGV2aWNl X3V1aWQsIHV1aWQpOw0KPiBAQCAtMjI1LDI1ICsyMDMsNiBAQCB1aW50OF90ICpub2RlX3V1aWRf Z2V0KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUpDQo+ICAJcmV0dXJuIG5vZGUtPnV1aWQ7DQo+ICB9 DQo+ICANCj4gLXN0YXRpYyB2b2lkIGFkZF9pbnRlcm5hbF9tb2RlbChzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlLCB1aW50MzJfdCBtb2RfaWQsDQo+IC0JCQkJCQkJCXVpbnQ4X3QgZWxlX2lkeCkNCj4g LXsNCj4gLQlzdHJ1Y3Qgbm9kZV9lbGVtZW50ICplbGU7DQo+IC0Jc3RydWN0IG1lc2hfbW9kZWwg Km1vZDsNCj4gLQ0KPiAtCWVsZSA9IGxfcXVldWVfZmluZChub2RlLT5lbGVtZW50cywgbWF0Y2hf ZWxlbWVudF9pZHgsDQo+IC0JCQkJCQkJTF9VSU5UX1RPX1BUUihlbGVfaWR4KSk7DQo+IC0JaWYg KCFlbGUpDQo+IC0JCXJldHVybjsNCj4gLQ0KPiAtCWlmIChsX3F1ZXVlX2ZpbmQoZWxlLT5tb2Rl bHMsIG1hdGNoX21vZGVsX2lkLCBMX1VJTlRfVE9fUFRSKG1vZF9pZCkpKQ0KPiAtCQlyZXR1cm47 DQo+IC0NCj4gLQltb2QgPSBtZXNoX21vZGVsX25ldyhlbGVfaWR4LCBtb2RfaWQpOw0KPiAtDQo+ IC0JbF9xdWV1ZV9pbnNlcnQoZWxlLT5tb2RlbHMsIG1vZCwgY29tcGFyZV9tb2RlbF9pZCwgTlVM TCk7DQo+IC19DQo+IC0NCj4gIHN0YXRpYyB2b2lkIHNldF9kZWZhdWx0cyhzdHJ1Y3QgbWVzaF9u b2RlICpub2RlKQ0KPiAgew0KPiAgCW5vZGUtPmxwbiA9IE1FU0hfTU9ERV9VTlNVUFBPUlRFRDsN Cj4gQEAgLTM1OSw0NiArMzE4LDYgQEAgdm9pZCBub2RlX3JlbW92ZShzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlKQ0KPiAgCWZyZWVfbm9kZV9yZXNvdXJjZXMobm9kZSk7DQo+ICB9DQo+ICANCj4gLXN0 YXRpYyBib29sIGFkZF9tb2RlbHNfZnJvbV9zdG9yYWdlKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUs DQo+IC0JCQkJCXN0cnVjdCBub2RlX2VsZW1lbnQgKmVsZSwNCj4gLQkJCQkJc3RydWN0IG1lc2hf Y29uZmlnX2VsZW1lbnQgKmRiX2VsZSkNCj4gLXsNCj4gLQljb25zdCBzdHJ1Y3QgbF9xdWV1ZV9l bnRyeSAqZW50cnk7DQo+IC0NCj4gLQlpZiAoIWVsZS0+bW9kZWxzKQ0KPiAtCQllbGUtPm1vZGVs cyA9IGxfcXVldWVfbmV3KCk7DQo+IC0NCj4gLQllbnRyeSA9IGxfcXVldWVfZ2V0X2VudHJpZXMo ZGJfZWxlLT5tb2RlbHMpOw0KPiAtDQo+IC0JZm9yICg7IGVudHJ5OyBlbnRyeSA9IGVudHJ5LT5u ZXh0KSB7DQo+IC0JCXN0cnVjdCBtZXNoX21vZGVsICptb2Q7DQo+IC0JCXN0cnVjdCBtZXNoX2Nv bmZpZ19tb2RlbCAqZGJfbW9kOw0KPiAtCQl1aW50MzJfdCBpZDsNCj4gLQ0KPiAtCQlkYl9tb2Qg PSBlbnRyeS0+ZGF0YTsNCj4gLQ0KPiAtCQlpZCA9IGRiX21vZC0+dmVuZG9yID8gZGJfbW9kLT5p ZCA6IGRiX21vZC0+aWQgfCBWRU5ET1JfSURfTUFTSzsNCj4gLQ0KPiAtCQlpZiAobF9xdWV1ZV9m aW5kKGVsZS0+bW9kZWxzLCBtYXRjaF9tb2RlbF9pZCwNCj4gLQkJCQkJCQlMX1VJTlRfVE9fUFRS KGlkKSkpDQo+IC0JCQlyZXR1cm4gZmFsc2U7DQo+IC0NCj4gLQkJbW9kID0gbWVzaF9tb2RlbF9z ZXR1cChub2RlLCBlbGUtPmlkeCwgZGJfbW9kKTsNCj4gLQkJaWYgKCFtb2QpDQo+IC0JCQlyZXR1 cm4gZmFsc2U7DQo+IC0NCj4gLQkJaWYgKCFkYl9tb2QtPnB1Yl9lbmFibGVkKQ0KPiAtCQkJbWVz aF9tb2RlbF9lbmFibGVfcHViKG1vZCwgZmFsc2UpOw0KPiAtDQo+IC0JCWlmICghZGJfbW9kLT5z dWJfZW5hYmxlZCkNCj4gLQkJCW1lc2hfbW9kZWxfZW5hYmxlX3N1Yihub2RlLCBtb2QsIGZhbHNl KTsNCj4gLQ0KPiAtCQlsX3F1ZXVlX2luc2VydChlbGUtPm1vZGVscywgbW9kLCBjb21wYXJlX21v ZGVsX2lkLCBOVUxMKTsNCj4gLQl9DQo+IC0NCj4gLQlyZXR1cm4gdHJ1ZTsNCj4gLX0NCj4gLQ0K PiAgc3RhdGljIGJvb2wgYWRkX2VsZW1lbnRfZnJvbV9zdG9yYWdlKHN0cnVjdCBtZXNoX25vZGUg Km5vZGUsDQo+ICAJCQkJCXN0cnVjdCBtZXNoX2NvbmZpZ19lbGVtZW50ICpkYl9lbGUpDQo+ICB7 DQo+IEBAIC00MTEsNyArMzMwLDEyIEBAIHN0YXRpYyBib29sIGFkZF9lbGVtZW50X2Zyb21fc3Rv cmFnZShzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLA0KPiAgCWVsZS0+aWR4ID0gZGJfZWxlLT5pbmRl eDsNCj4gIAllbGUtPmxvY2F0aW9uID0gZGJfZWxlLT5sb2NhdGlvbjsNCj4gIA0KPiAtCWlmICgh ZGJfZWxlLT5tb2RlbHMgfHwgIWFkZF9tb2RlbHNfZnJvbV9zdG9yYWdlKG5vZGUsIGVsZSwgZGJf ZWxlKSkNCj4gKw0KPiArCWlmICghZWxlLT5tb2RlbHMpDQo+ICsJCWVsZS0+bW9kZWxzID0gbF9x dWV1ZV9uZXcoKTsNCj4gKw0KPiArCWlmICghbWVzaF9tb2RlbF9hZGRfZnJvbV9zdG9yYWdlKG5v ZGUsIGVsZS0+aWR4LCBlbGUtPm1vZGVscywNCj4gKwkJCQkJCQlkYl9lbGUtPm1vZGVscykpDQo+ ICAJCXJldHVybiBmYWxzZTsNCj4gIA0KPiAgCWxfcXVldWVfcHVzaF90YWlsKG5vZGUtPmVsZW1l bnRzLCBlbGUpOw0KPiBAQCAtNDI0LDEyICszNDgsMTMgQEAgc3RhdGljIGJvb2wgYWRkX2VsZW1l bnRzX2Zyb21fc3RvcmFnZShzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLA0KPiAgCWNvbnN0IHN0cnVj dCBsX3F1ZXVlX2VudHJ5ICplbnRyeTsNCj4gIA0KPiAgCWVudHJ5ID0gbF9xdWV1ZV9nZXRfZW50 cmllcyhkYl9ub2RlLT5lbGVtZW50cyk7DQo+ICsNCj4gIAlmb3IgKDsgZW50cnk7IGVudHJ5ID0g ZW50cnktPm5leHQpDQo+ICAJCWlmICghYWRkX2VsZW1lbnRfZnJvbV9zdG9yYWdlKG5vZGUsIGVu dHJ5LT5kYXRhKSkNCj4gIAkJCXJldHVybiBmYWxzZTsNCj4gIA0KPiAgCS8qIEFkZCBjb25maWd1 cmF0aW9uIHNlcnZlciBtb2RlbCBvbiB0aGUgcHJpbWFyeSBlbGVtZW50ICovDQo+IC0JYWRkX2lu dGVybmFsX21vZGVsKG5vZGUsIENPTkZJR19TUlZfTU9ERUwsIFBSSU1BUllfRUxFX0lEWCk7DQo+ ICsJbWVzaF9tb2RlbF9hZGQobm9kZSwgUFJJTUFSWV9FTEVfSURYLCBDT05GSUdfU1JWX01PREVM LCBOVUxMKTsNCj4gIA0KPiAgCXJldHVybiB0cnVlOw0KPiAgfQ0KPiBAQCAtNjI4LDcgKzU1Myw3 IEBAIHZvaWQgbm9kZV9hcHBfa2V5X2RlbGV0ZShzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50 MTZfdCBuZXRfaWR4LA0KPiAgCWZvciAoOyBlbnRyeTsgZW50cnkgPSBlbnRyeS0+bmV4dCkgew0K PiAgCQlzdHJ1Y3Qgbm9kZV9lbGVtZW50ICplbGUgPSBlbnRyeS0+ZGF0YTsNCj4gIA0KPiAtCQlt ZXNoX21vZGVsX2FwcF9rZXlfZGVsZXRlKG5vZGUsIGVsZS0+bW9kZWxzLCBhcHBfaWR4KTsNCj4g KwkJbWVzaF9tb2RlbF9hcHBfa2V5X2RlbGV0ZShub2RlLCBlbGUtPmlkeCwgZWxlLT5tb2RlbHMs IGFwcF9pZHgpOw0KPiAgCX0NCj4gIH0NCj4gIA0KPiBAQCAtNjY2LDI3ICs1OTEsMTcgQEAgdWlu dDhfdCBub2RlX2dldF9udW1fZWxlbWVudHMoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSkNCj4gIAly ZXR1cm4gbm9kZS0+bnVtX2VsZTsNCj4gIH0NCj4gIA0KPiAtc3RydWN0IGxfcXVldWUgKm5vZGVf Z2V0X2VsZW1lbnRfbW9kZWxzKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsDQo+IC0JCQkJCQl1aW50 OF90IGVsZV9pZHgsIGludCAqc3RhdHVzKQ0KPiArc3RydWN0IGxfcXVldWUgKm5vZGVfZ2V0X2Vs ZW1lbnRfbW9kZWxzKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgZWxlX2lkeCkNCj4g IHsNCj4gIAlzdHJ1Y3Qgbm9kZV9lbGVtZW50ICplbGU7DQo+ICANCj4gLQlpZiAoIW5vZGUpIHsN Cj4gLQkJaWYgKHN0YXR1cykNCj4gLQkJCSpzdGF0dXMgPSBNRVNIX1NUQVRVU19JTlZBTElEX0FE RFJFU1M7DQo+ICsJaWYgKCFub2RlKQ0KPiAgCQlyZXR1cm4gTlVMTDsNCj4gLQl9DQo+ICANCj4g IAllbGUgPSBsX3F1ZXVlX2ZpbmQobm9kZS0+ZWxlbWVudHMsIG1hdGNoX2VsZW1lbnRfaWR4LA0K PiAgCQkJCQkJCUxfVUlOVF9UT19QVFIoZWxlX2lkeCkpOw0KPiAtCWlmICghZWxlKSB7DQo+IC0J CWlmIChzdGF0dXMpDQo+IC0JCQkqc3RhdHVzID0gTUVTSF9TVEFUVVNfSU5WQUxJRF9BRERSRVNT Ow0KPiArCWlmICghZWxlKQ0KPiAgCQlyZXR1cm4gTlVMTDsNCj4gLQl9DQo+IC0NCj4gLQlpZiAo c3RhdHVzKQ0KPiAtCQkqc3RhdHVzID0gTUVTSF9TVEFUVVNfU1VDQ0VTUzsNCj4gIA0KPiAgCXJl dHVybiBlbGUtPm1vZGVsczsNCj4gIH0NCj4gQEAgLTg4OCw5ICs4MDMsOCBAQCB1aW50OF90IG5v ZGVfZnJpZW5kX21vZGVfZ2V0KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUpDQo+ICBzdGF0aWMgdWlu dDE2X3Qgbm9kZV9nZW5lcmF0ZV9jb21wKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3Qg KmJ1ZiwNCj4gIAkJCQkJCQkJdWludDE2X3Qgc3opDQo+ICB7DQo+IC0JdWludDE2X3QgbiwgZmVh dHVyZXM7DQo+IC0JdWludDE2X3QgbnVtX2VsZSA9IDA7DQo+IC0JY29uc3Qgc3RydWN0IGxfcXVl dWVfZW50cnkgKmVsZV9lbnRyeTsNCj4gKwl1aW50MTZfdCBuLCBmZWF0dXJlcywgbnVtX2VsZSA9 IDA7DQo+ICsJY29uc3Qgc3RydWN0IGxfcXVldWVfZW50cnkgKmVudHJ5Ow0KPiAgDQo+ICAJaWYg KCFub2RlIHx8IHN6IDwgTUlOX0NPTVBfU0laRSkNCj4gIAkJcmV0dXJuIDA7DQo+IEBAIC05MjAs MTIgKzgzNCwxMCBAQCBzdGF0aWMgdWludDE2X3Qgbm9kZV9nZW5lcmF0ZV9jb21wKHN0cnVjdCBt ZXNoX25vZGUgKm5vZGUsIHVpbnQ4X3QgKmJ1ZiwNCj4gIAlsX3B1dF9sZTE2KGZlYXR1cmVzLCBi dWYgKyBuKTsNCj4gIAluICs9IDI7DQo+ICANCj4gLQllbGVfZW50cnkgPSBsX3F1ZXVlX2dldF9l bnRyaWVzKG5vZGUtPmVsZW1lbnRzKTsNCj4gLQlmb3IgKDsgZWxlX2VudHJ5OyBlbGVfZW50cnkg PSBlbGVfZW50cnktPm5leHQpIHsNCj4gLQkJc3RydWN0IG5vZGVfZWxlbWVudCAqZWxlID0gZWxl X2VudHJ5LT5kYXRhOw0KPiAtCQljb25zdCBzdHJ1Y3QgbF9xdWV1ZV9lbnRyeSAqbW9kX2VudHJ5 Ow0KPiAtCQl1aW50OF90IG51bV9zID0gMCwgbnVtX3YgPSAwOw0KPiAtCQl1aW50OF90ICptb2Rf YnVmOw0KPiArCWVudHJ5ID0gbF9xdWV1ZV9nZXRfZW50cmllcyhub2RlLT5lbGVtZW50cyk7DQo+ ICsNCj4gKwlmb3IgKDsgZW50cnk7IGVudHJ5ID0gZW50cnktPm5leHQpIHsNCj4gKwkJc3RydWN0 IG5vZGVfZWxlbWVudCAqZWxlID0gZW50cnktPmRhdGE7DQo+ICANCj4gIAkJaWYgKGVsZS0+aWR4 ICE9IG51bV9lbGUpDQo+ICAJCQlyZXR1cm4gMDsNCj4gQEAgLTkzOSw1OSArODUxLDggQEAgc3Rh dGljIHVpbnQxNl90IG5vZGVfZ2VuZXJhdGVfY29tcChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1 aW50OF90ICpidWYsDQo+ICAJCWxfcHV0X2xlMTYoZWxlLT5sb2NhdGlvbiwgYnVmICsgbik7DQo+ ICAJCW4gKz0gMjsNCj4gIA0KPiAtCQkvKiBTdG9yZSBtb2RlbHMgSURzLCBzdG9yZSBudW1fcyBh bmQgbnVtX3YgbGF0ZXIgKi8NCj4gLQkJbW9kX2J1ZiA9IGJ1ZiArIG47DQo+IC0JCW4gKz0gMjsN Cj4gLQ0KPiAtCQkvKiBHZXQgU0lHIG1vZGVscyAqLw0KPiAtCQltb2RfZW50cnkgPSBsX3F1ZXVl X2dldF9lbnRyaWVzKGVsZS0+bW9kZWxzKTsNCj4gLQkJZm9yICg7IG1vZF9lbnRyeTsgbW9kX2Vu dHJ5ID0gbW9kX2VudHJ5LT5uZXh0KSB7DQo+IC0JCQlzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kID0g bW9kX2VudHJ5LT5kYXRhOw0KPiAtCQkJdWludDMyX3QgbW9kX2lkOw0KPiAtDQo+IC0JCQltb2Rf aWQgPSBtZXNoX21vZGVsX2dldF9tb2RlbF9pZCgNCj4gLQkJCQkJKGNvbnN0IHN0cnVjdCBtZXNo X21vZGVsICopIG1vZCk7DQo+IC0NCj4gLQkJCWlmICgobW9kX2lkICYgVkVORE9SX0lEX01BU0sp ID09IFZFTkRPUl9JRF9NQVNLKSB7DQo+IC0JCQkJaWYgKG4gKyAyID4gc3opDQo+IC0JCQkJCWdv dG8gZWxlbWVudF9kb25lOw0KPiAtDQo+IC0JCQkJbF9wdXRfbGUxNigodWludDE2X3QpIChtb2Rf aWQgJiAweGZmZmYpLA0KPiAtCQkJCQkJCQlidWYgKyBuKTsNCj4gLQkJCQluICs9IDI7DQo+IC0J CQkJbnVtX3MrKzsNCj4gLQkJCX0NCj4gLQkJfQ0KPiAtDQo+IC0JCS8qIEdldCB2ZW5kb3IgbW9k ZWxzICovDQo+IC0JCW1vZF9lbnRyeSA9IGxfcXVldWVfZ2V0X2VudHJpZXMoZWxlLT5tb2RlbHMp Ow0KPiAtCQlmb3IgKDsgbW9kX2VudHJ5OyBtb2RfZW50cnkgPSBtb2RfZW50cnktPm5leHQpIHsN Cj4gLQkJCXN0cnVjdCBtZXNoX21vZGVsICptb2QgPSBtb2RfZW50cnktPmRhdGE7DQo+IC0JCQl1 aW50MzJfdCBtb2RfaWQ7DQo+IC0JCQl1aW50MTZfdCB2ZW5kb3I7DQo+IC0NCj4gLQkJCW1vZF9p ZCA9IG1lc2hfbW9kZWxfZ2V0X21vZGVsX2lkKA0KPiAtCQkJCQkoY29uc3Qgc3RydWN0IG1lc2hf bW9kZWwgKikgbW9kKTsNCj4gLQ0KPiAtCQkJdmVuZG9yID0gKHVpbnQxNl90KSAobW9kX2lkID4+ IDE2KTsNCj4gLQkJCWlmICh2ZW5kb3IgIT0gMHhmZmZmKSB7DQo+IC0JCQkJaWYgKG4gKyA0ID4g c3opDQo+IC0JCQkJCWdvdG8gZWxlbWVudF9kb25lOw0KPiAtDQo+IC0JCQkJbF9wdXRfbGUxNih2 ZW5kb3IsIGJ1ZiArIG4pOw0KPiAtCQkJCW4gKz0gMjsNCj4gLQkJCQlsX3B1dF9sZTE2KCh1aW50 MTZfdCkgKG1vZF9pZCAmIDB4ZmZmZiksDQo+ICsJCW4gKz0gbWVzaF9tb2RlbF9nZW5lcmF0ZV9j b21wb3NpdGlvbihlbGUtPm1vZGVscywgc3ogLSBuLA0KPiAgCQkJCQkJCQlidWYgKyBuKTsNCj4g LQkJCQluICs9IDI7DQo+IC0JCQkJbnVtX3YrKzsNCj4gLQkJCX0NCj4gLQ0KPiAtCQl9DQo+IC0N Cj4gLWVsZW1lbnRfZG9uZToNCj4gLQkJbW9kX2J1ZlswXSA9IG51bV9zOw0KPiAtCQltb2RfYnVm WzFdID0gbnVtX3Y7DQo+IC0NCj4gIAl9DQo+ICANCj4gIAlpZiAoIW51bV9lbGUpDQo+IEBAIC0x MTI4LDUyICs5ODksNiBAQCBzdGF0aWMgdm9pZCBhcHBfZGlzY19jYihzdHJ1Y3QgbF9kYnVzICpi dXMsIHZvaWQgKnVzZXJfZGF0YSkNCj4gIAlmcmVlX25vZGVfZGJ1c19yZXNvdXJjZXMobm9kZSk7 DQo+ICB9DQo+ICANCj4gLXN0YXRpYyBib29sIGdldF9tb2RlbF9vcHRpb25zKHN0cnVjdCBtZXNo X25vZGUgKm5vZGUsIHN0cnVjdCBtZXNoX21vZGVsICptb2QsDQo+IC0JCQkJCXN0cnVjdCBsX2Ri dXNfbWVzc2FnZV9pdGVyICpvcHRzKQ0KPiAtew0KPiAtCWNvbnN0IGNoYXIgKmtleTsNCj4gLQlz dHJ1Y3QgbF9kYnVzX21lc3NhZ2VfaXRlciB2YXI7DQo+IC0JYm9vbCBvcHQ7DQo+IC0NCj4gLQl3 aGlsZSAobF9kYnVzX21lc3NhZ2VfaXRlcl9uZXh0X2VudHJ5KG9wdHMsICZrZXksICZ2YXIpKSB7 DQo+IC0NCj4gLQkJaWYgKCFzdHJjbXAoa2V5LCAiUHVibGlzaCIpKSB7DQo+IC0JCQlpZiAoIWxf ZGJ1c19tZXNzYWdlX2l0ZXJfZ2V0X3ZhcmlhbnQoJnZhciwgImIiLCAmb3B0KSkNCj4gLQkJCQly ZXR1cm4gZmFsc2U7DQo+IC0JCQltZXNoX21vZGVsX2VuYWJsZV9wdWIobW9kLCBvcHQpOw0KPiAt CQl9IGVsc2UgaWYgKCFzdHJjbXAoa2V5LCAiU3Vic2NyaWJlIikpIHsNCj4gLQkJCWlmICghbF9k YnVzX21lc3NhZ2VfaXRlcl9nZXRfdmFyaWFudCgmdmFyLCAiYiIsICZvcHQpKQ0KPiAtCQkJCXJl dHVybiBmYWxzZTsNCj4gLQkJCW1lc2hfbW9kZWxfZW5hYmxlX3N1Yihub2RlLCBtb2QsIG9wdCk7 DQo+IC0JCX0gZWxzZQ0KPiAtCQkJcmV0dXJuIGZhbHNlOw0KPiAtCX0NCj4gLQ0KPiAtCXJldHVy biB0cnVlOw0KPiAtfQ0KPiAtDQo+IC1zdGF0aWMgYm9vbCBnZW5lcmF0ZV9tb2RlbChzdHJ1Y3Qg bWVzaF9ub2RlICpub2RlLCBzdHJ1Y3Qgbm9kZV9lbGVtZW50ICplbGUsDQo+IC0JCQkJdWludDMy X3QgaWQsIHN0cnVjdCBsX2RidXNfbWVzc2FnZV9pdGVyICpvcHRzKQ0KPiAtew0KPiAtCXN0cnVj dCBtZXNoX21vZGVsICptb2Q7DQo+IC0NCj4gLQkvKiBEaXNhbGxvdyBkdXBsaWNhdGVzICovDQo+ IC0JaWYgKGxfcXVldWVfZmluZChlbGUtPm1vZGVscywgbWF0Y2hfbW9kZWxfaWQsDQo+IC0JCQkg TF9VSU5UX1RPX1BUUihpZCkpKQ0KPiAtCQlyZXR1cm4gZmFsc2U7DQo+IC0NCj4gLQltb2QgPSBt ZXNoX21vZGVsX25ldyhlbGUtPmlkeCwgaWQpOw0KPiAtDQo+IC0JaWYgKCFnZXRfbW9kZWxfb3B0 aW9ucyhub2RlLCBtb2QsIG9wdHMpKSB7DQo+IC0JCWxfZnJlZShtb2QpOw0KPiAtCQlyZXR1cm4g ZmFsc2U7DQo+IC0JfQ0KPiAtDQo+IC0JbF9xdWV1ZV9pbnNlcnQoZWxlLT5tb2RlbHMsIG1vZCwg Y29tcGFyZV9tb2RlbF9pZCwgTlVMTCk7DQo+IC0NCj4gLQlyZXR1cm4gdHJ1ZTsNCj4gLX0NCj4g LQ0KPiAgc3RhdGljIGJvb2wgZ2V0X3NpZ19tb2RlbHNfZnJvbV9wcm9wZXJ0aWVzKHN0cnVjdCBt ZXNoX25vZGUgKm5vZGUsDQo+ICAJCQkJCXN0cnVjdCBub2RlX2VsZW1lbnQgKmVsZSwNCj4gIAkJ CQkJc3RydWN0IGxfZGJ1c19tZXNzYWdlX2l0ZXIgKnByb3BlcnR5KQ0KPiBAQCAtMTE4OSwxMyAr MTAwNCwxMyBAQCBzdGF0aWMgYm9vbCBnZXRfc2lnX21vZGVsc19mcm9tX3Byb3BlcnRpZXMoc3Ry dWN0IG1lc2hfbm9kZSAqbm9kZSwNCj4gIA0KPiAgCS8qIEJsdWV0b290aCBTSUcgZGVmaW5lZCBt b2RlbHMgKi8NCj4gIAl3aGlsZSAobF9kYnVzX21lc3NhZ2VfaXRlcl9uZXh0X2VudHJ5KCZtb2Rz LCAmbV9pZCwgJnZhcikpIHsNCj4gLQkJdWludDMyX3QgaWQgPSBtX2lkIHwgVkVORE9SX0lEX01B U0s7DQo+ICsJCXVpbnQzMl90IGlkID0gU0VUX0lEKFNJR19WRU5ET1IsIG1faWQpOw0KPiAgDQo+ ICAJCS8qIEFsbG93IENvbmZpZyBTZXJ2ZXIgTW9kZWwgb25seSBvbiB0aGUgcHJpbWFyeSBlbGVt ZW50ICovDQo+ICAJCWlmIChlbGUtPmlkeCAhPSBQUklNQVJZX0VMRV9JRFggJiYgaWQgPT0gQ09O RklHX1NSVl9NT0RFTCkNCj4gIAkJCXJldHVybiBmYWxzZTsNCj4gIA0KPiAtCQlpZiAoIWdlbmVy YXRlX21vZGVsKG5vZGUsIGVsZSwgaWQsICZ2YXIpKQ0KPiArCQlpZiAoIW1lc2hfbW9kZWxfYWRk KG5vZGUsIGVsZS0+bW9kZWxzLCBpZCwgJnZhcikpDQo+ICAJCQlyZXR1cm4gZmFsc2U7DQo+ICAJ fQ0KPiAgDQo+IEBAIC0xMjE3LDkgKzEwMzIsOSBAQCBzdGF0aWMgYm9vbCBnZXRfdmVuZG9yX21v ZGVsc19mcm9tX3Byb3BlcnRpZXMoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwNCj4gIA0KPiAgCS8q IFZlbmRvciBkZWZpbmVkIG1vZGVscyAqLw0KPiAgCXdoaWxlIChsX2RidXNfbWVzc2FnZV9pdGVy X25leHRfZW50cnkoJm1vZHMsICZ2X2lkLCAmbV9pZCwgJnZhcikpIHsNCj4gLQkJdWludDMyX3Qg aWQgPSBtX2lkIHwgKHZfaWQgPDwgMTYpOw0KPiArCQl1aW50MzJfdCBpZCA9IFNFVF9JRCh2X2lk LCBtX2lkKTsNCj4gIA0KPiAtCQlpZiAoIWdlbmVyYXRlX21vZGVsKG5vZGUsIGVsZSwgaWQsICZ2 YXIpKQ0KPiArCQlpZiAoIW1lc2hfbW9kZWxfYWRkKG5vZGUsIGVsZS0+bW9kZWxzLCBpZCwgJnZh cikpDQo+ICAJCQlyZXR1cm4gZmFsc2U7DQo+ICAJfQ0KPiAgDQo+IEBAIC0xMjk1LDcgKzExMTAs NyBAQCBzdGF0aWMgYm9vbCBnZXRfZWxlbWVudF9wcm9wZXJ0aWVzKHN0cnVjdCBtZXNoX25vZGUg Km5vZGUsIGNvbnN0IGNoYXIgKnBhdGgsDQo+ICAJICogdGhlIG9wZXJhdGlvbiBiZWxvdyB3aWxs IGJlIGEgIm5vLW9wIi4NCj4gIAkgKi8NCj4gIAlpZiAoZWxlLT5pZHggPT0gUFJJTUFSWV9FTEVf SURYKQ0KPiAtCQlhZGRfaW50ZXJuYWxfbW9kZWwobm9kZSwgQ09ORklHX1NSVl9NT0RFTCwgUFJJ TUFSWV9FTEVfSURYKTsNCj4gKwkJbWVzaF9tb2RlbF9hZGQobm9kZSwgZWxlLT5tb2RlbHMsIENP TkZJR19TUlZfTU9ERUwsIE5VTEwpOw0KPiAgDQo+ICAJcmV0dXJuIHRydWU7DQo+ICBmYWlsOg0K PiBAQCAtMTMzMiw3ICsxMTQ3LDYgQEAgc3RhdGljIHZvaWQgY29udmVydF9ub2RlX3RvX3N0b3Jh Z2Uoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwNCj4gIAlmb3IgKDsgZW50cnk7IGVudHJ5ID0gZW50 cnktPm5leHQpIHsNCj4gIAkJc3RydWN0IG5vZGVfZWxlbWVudCAqZWxlID0gZW50cnktPmRhdGE7 DQo+ICAJCXN0cnVjdCBtZXNoX2NvbmZpZ19lbGVtZW50ICpkYl9lbGU7DQo+IC0JCWNvbnN0IHN0 cnVjdCBsX3F1ZXVlX2VudHJ5ICptb2RfZW50cnk7DQo+ICANCj4gIAkJZGJfZWxlID0gbF9uZXco c3RydWN0IG1lc2hfY29uZmlnX2VsZW1lbnQsIDEpOw0KPiAgDQo+IEBAIC0xMzQwLDIxICsxMTU0 LDggQEAgc3RhdGljIHZvaWQgY29udmVydF9ub2RlX3RvX3N0b3JhZ2Uoc3RydWN0IG1lc2hfbm9k ZSAqbm9kZSwNCj4gIAkJZGJfZWxlLT5sb2NhdGlvbiA9IGVsZS0+bG9jYXRpb247DQo+ICAJCWRi X2VsZS0+bW9kZWxzID0gbF9xdWV1ZV9uZXcoKTsNCj4gIA0KPiAtCQltb2RfZW50cnkgPSBsX3F1 ZXVlX2dldF9lbnRyaWVzKGVsZS0+bW9kZWxzKTsNCj4gLQ0KPiAtCQlmb3IgKDsgbW9kX2VudHJ5 OyBtb2RfZW50cnkgPSBtb2RfZW50cnktPm5leHQpIHsNCj4gLQkJCXN0cnVjdCBtZXNoX21vZGVs ICptb2QgPSBtb2RfZW50cnktPmRhdGE7DQo+IC0JCQlzdHJ1Y3QgbWVzaF9jb25maWdfbW9kZWwg KmRiX21vZDsNCj4gLQkJCXVpbnQzMl90IG1vZF9pZCA9IG1lc2hfbW9kZWxfZ2V0X21vZGVsX2lk KG1vZCk7DQo+ICsJCW1lc2hfbW9kZWxfY29udmVydF90b19zdG9yYWdlKGRiX2VsZS0+bW9kZWxz LCBlbGUtPm1vZGVscyk7DQo+ICANCj4gLQkJCWRiX21vZCA9IGxfbmV3KHN0cnVjdCBtZXNoX2Nv bmZpZ19tb2RlbCwgMSk7DQo+IC0JCQlkYl9tb2QtPmlkID0gbW9kX2lkOw0KPiAtCQkJZGJfbW9k LT52ZW5kb3IgPSAoKG1vZF9pZCAmIFZFTkRPUl9JRF9NQVNLKQ0KPiAtCQkJCQkJCSE9IFZFTkRP Ul9JRF9NQVNLKTsNCj4gLQkJCWRiX21vZC0+cHViX2VuYWJsZWQgPSBtZXNoX21vZGVsX2lzX3B1 Yl9lbmFibGVkKG1vZCk7DQo+IC0JCQlkYl9tb2QtPnN1Yl9lbmFibGVkID0gbWVzaF9tb2RlbF9p c19zdWJfZW5hYmxlZChtb2QpOw0KPiAtCQkJbF9xdWV1ZV9wdXNoX3RhaWwoZGJfZWxlLT5tb2Rl bHMsIGRiX21vZCk7DQo+IC0JCX0NCj4gIAkJbF9xdWV1ZV9wdXNoX3RhaWwoZGJfbm9kZS0+ZWxl bWVudHMsIGRiX2VsZSk7DQo+ICAJfQ0KPiAgDQo+IEBAIC0xMzc1LDYgKzExNzYsNyBAQCBzdGF0 aWMgYm9vbCBjcmVhdGVfbm9kZV9jb25maWcoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgY29uc3Qg dWludDhfdCB1dWlkWzE2XSkNCj4gIA0KPiAgCS8qIEZyZWUgdGVtcG9yYXJpbHkgYWxsb2NhdGVk IHJlc291cmNlcyAqLw0KPiAgCWVudHJ5ID0gbF9xdWV1ZV9nZXRfZW50cmllcyhkYl9ub2RlLmVs ZW1lbnRzKTsNCj4gKw0KPiAgCWZvciAoOyBlbnRyeTsgZW50cnkgPSBlbnRyeS0+bmV4dCkgew0K PiAgCQlzdHJ1Y3QgbWVzaF9jb25maWdfZWxlbWVudCAqZGJfZWxlID0gZW50cnktPmRhdGE7DQo+ ICANCj4gQEAgLTE1MTcsNyArMTMxOSw2IEBAIHN0YXRpYyB2b2lkIHVwZGF0ZV9tb2RlbF9vcHRp b25zKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsDQo+ICAJbGVuID0gbF9xdWV1ZV9sZW5ndGgobm9k ZS0+ZWxlbWVudHMpOw0KPiAgDQo+ICAJZm9yIChpID0gMDsgaSA8IGxlbjsgaSsrKSB7DQo+IC0J CWNvbnN0IHN0cnVjdCBsX3F1ZXVlX2VudHJ5ICplbnRyeTsNCj4gIA0KPiAgCQllbGUgPSBsX3F1 ZXVlX2ZpbmQobm9kZS0+ZWxlbWVudHMsIG1hdGNoX2VsZW1lbnRfaWR4LA0KPiAgCQkJCQkJCUxf VUlOVF9UT19QVFIoaSkpOw0KPiBAQCAtMTUyNiw0MiArMTMyNyw4IEBAIHN0YXRpYyB2b2lkIHVw ZGF0ZV9tb2RlbF9vcHRpb25zKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsDQo+ICAJCWlmICghZWxl IHx8ICFlbGVfYXR0YWNoKQ0KPiAgCQkJY29udGludWU7DQo+ICANCj4gLQkJZW50cnkgPSBsX3F1 ZXVlX2dldF9lbnRyaWVzKGVsZS0+bW9kZWxzKTsNCj4gLQ0KPiAtCQlmb3IgKDsgZW50cnk7IGVu dHJ5ID0gZW50cnktPm5leHQpIHsNCj4gLQkJCXN0cnVjdCBtZXNoX21vZGVsICptb2QsICp1cGRh dGVkX21vZCA9IGVudHJ5LT5kYXRhOw0KPiAtCQkJdWludDMyX3QgaWQgPSBtZXNoX21vZGVsX2dl dF9tb2RlbF9pZCh1cGRhdGVkX21vZCk7DQo+IC0JCQlib29sIG9wdCwgdXBkYXRlZF9vcHQ7DQo+ IC0JCQlib29sIHZlbmRvciA9IGlkIDwgVkVORE9SX0lEX01BU0s7DQo+IC0NCj4gLQkJCW1vZCA9 IGxfcXVldWVfZmluZChlbGVfYXR0YWNoLT5tb2RlbHMsIG1hdGNoX21vZGVsX2lkLA0KPiAtCQkJ CQkJCUxfVUlOVF9UT19QVFIoaWQpKTsNCj4gLQkJCWlmICghbW9kKQ0KPiAtCQkJCWNvbnRpbnVl Ow0KPiAtDQo+IC0JCQlpZiAoIXZlbmRvcikNCj4gLQkJCQlpZCAmPSB+VkVORE9SX0lEX01BU0s7 DQo+IC0NCj4gLQkJCW9wdCA9IG1lc2hfbW9kZWxfaXNfcHViX2VuYWJsZWQobW9kKTsNCj4gLQkJ CXVwZGF0ZWRfb3B0ID0gbWVzaF9tb2RlbF9pc19wdWJfZW5hYmxlZCh1cGRhdGVkX21vZCk7DQo+ IC0NCj4gLQkJCWlmICh1cGRhdGVkX29wdCAhPSBvcHQpIHsNCj4gLQkJCQltZXNoX21vZGVsX2Vu YWJsZV9wdWIobW9kLCB1cGRhdGVkX29wdCk7DQo+IC0JCQkJbWVzaF9jb25maWdfbW9kZWxfcHVi X2VuYWJsZShhdHRhY2gtPmNmZywNCj4gLQkJCQkJCQlhdHRhY2gtPnByaW1hcnkgKyBpLCBpZCwN Cj4gLQkJCQkJCQl2ZW5kb3IsIHVwZGF0ZWRfb3B0KTsNCj4gLQkJCX0NCj4gLQ0KPiAtCQkJb3B0 ID0gbWVzaF9tb2RlbF9pc19zdWJfZW5hYmxlZChtb2QpOw0KPiAtCQkJdXBkYXRlZF9vcHQgPSBt ZXNoX21vZGVsX2lzX3N1Yl9lbmFibGVkKHVwZGF0ZWRfbW9kKTsNCj4gLQ0KPiAtCQkJaWYgKHVw ZGF0ZWRfb3B0ICE9IG9wdCkgew0KPiAtCQkJCW1lc2hfbW9kZWxfZW5hYmxlX3N1Yihub2RlLCBt b2QsIHVwZGF0ZWRfb3B0KTsNCj4gLQkJCQltZXNoX2NvbmZpZ19tb2RlbF9zdWJfZW5hYmxlKGF0 dGFjaC0+Y2ZnLA0KPiAtCQkJCQkJCWF0dGFjaC0+cHJpbWFyeSArIGksIGlkLA0KPiAtCQkJCQkJ CXZlbmRvciwgdXBkYXRlZF9vcHQpOw0KPiAtCQkJfQ0KPiAtCQl9DQo+ICsJCW1lc2hfbW9kZWxf dXBkYXRlX29wdHMobm9kZSwgZWxlLT5pZHgsIGVsZV9hdHRhY2gtPm1vZGVscywNCj4gKwkJCQkJ CQkJZWxlLT5tb2RlbHMpOw0KPiAgCX0NCj4gIH0NCj4gIA0KPiBAQCAtMTk2NCw3ICsxNzMxLDcg QEAgc3RhdGljIHZvaWQgYnVpbGRfZWxlbWVudF9jb25maWcodm9pZCAqYSwgdm9pZCAqYikNCj4g IAlsX2RidXNfbWVzc2FnZV9idWlsZGVyX2VudGVyX2FycmF5KGJ1aWxkZXIsICIocWF7c3Z9KSIp Ow0KPiAgDQo+ICAJLyogSXRlcmF0ZSBvdmVyIG1vZGVscyAqLw0KPiAtCWxfcXVldWVfZm9yZWFj aChlbGUtPm1vZGVscywgbW9kZWxfYnVpbGRfY29uZmlnLCBidWlsZGVyKTsNCj4gKwlsX3F1ZXVl X2ZvcmVhY2goZWxlLT5tb2RlbHMsIG1lc2hfbW9kZWxfYnVpbGRfY29uZmlnLCBidWlsZGVyKTsN Cj4gIA0KPiAgCWxfZGJ1c19tZXNzYWdlX2J1aWxkZXJfbGVhdmVfYXJyYXkoYnVpbGRlcik7DQo+ ICANCj4gQEAgLTIyMTYsOCArMTk4Myw4IEBAIHN0YXRpYyBzdHJ1Y3QgbF9kYnVzX21lc3NhZ2Ug KnB1Ymxpc2hfY2FsbChzdHJ1Y3QgbF9kYnVzICpkYnVzLA0KPiAgCXN0cnVjdCBsX2RidXNfbWVz c2FnZV9pdGVyIGl0ZXJfZGF0YTsNCj4gIAl1aW50MTZfdCBtb2RfaWQsIHNyYzsNCj4gIAlzdHJ1 Y3Qgbm9kZV9lbGVtZW50ICplbGU7DQo+IC0JdWludDhfdCAqZGF0YTsNCj4gLQl1aW50MzJfdCBs ZW47DQo+ICsJdWludDhfdCAqZGF0YSwgdHRsOw0KPiArCXVpbnQzMl90IGxlbiwgaWQ7DQo+ICAJ aW50IHJlc3VsdDsNCj4gIA0KPiAgCWxfZGVidWcoIlB1Ymxpc2giKTsNCj4gQEAgLTIyNDMsOCAr MjAxMCwxMCBAQCBzdGF0aWMgc3RydWN0IGxfZGJ1c19tZXNzYWdlICpwdWJsaXNoX2NhbGwoc3Ry dWN0IGxfZGJ1cyAqZGJ1cywNCj4gIAkJcmV0dXJuIGRidXNfZXJyb3IobXNnLCBNRVNIX0VSUk9S X0lOVkFMSURfQVJHUywNCj4gIAkJCQkJCQkiSW5jb3JyZWN0IGRhdGEiKTsNCj4gIA0KPiAtCXJl c3VsdCA9IG1lc2hfbW9kZWxfcHVibGlzaChub2RlLCBWRU5ET1JfSURfTUFTSyB8IG1vZF9pZCwg c3JjLA0KPiAtCQkJCW1lc2hfbmV0X2dldF9kZWZhdWx0X3R0bChub2RlLT5uZXQpLCBkYXRhLCBs ZW4pOw0KPiArCXR0bCA9IG1lc2hfbmV0X2dldF9kZWZhdWx0X3R0bChub2RlLT5uZXQpOw0KPiAr DQo+ICsJaWQgPSBTRVRfSUQoU0lHX1ZFTkRPUiwgbW9kX2lkKTsNCj4gKwlyZXN1bHQgPSBtZXNo X21vZGVsX3B1Ymxpc2gobm9kZSwgaWQsIHNyYywgdHRsLCBkYXRhLCBsZW4pOw0KPiAgDQo+ICAJ aWYgKHJlc3VsdCAhPSBNRVNIX0VSUk9SX05PTkUpDQo+ICAJCXJldHVybiBkYnVzX2Vycm9yKG1z ZywgcmVzdWx0LCBOVUxMKTsNCj4gQEAgLTIyNTksMTEgKzIwMjgsOSBAQCBzdGF0aWMgc3RydWN0 IGxfZGJ1c19tZXNzYWdlICp2ZW5kb3JfcHVibGlzaF9jYWxsKHN0cnVjdCBsX2RidXMgKmRidXMs DQo+ICAJc3RydWN0IG1lc2hfbm9kZSAqbm9kZSA9IHVzZXJfZGF0YTsNCj4gIAljb25zdCBjaGFy ICpzZW5kZXIsICplbGVfcGF0aDsNCj4gIAlzdHJ1Y3QgbF9kYnVzX21lc3NhZ2VfaXRlciBpdGVy X2RhdGE7DQo+IC0JdWludDE2X3Qgc3JjOw0KPiAtCXVpbnQxNl90IG1vZGVsX2lkLCB2ZW5kb3I7 DQo+IC0JdWludDMyX3QgdmVuZG9yX21vZF9pZDsNCj4gKwl1aW50MTZfdCBzcmMsIG1vZF9pZCwg dmVuZG9yX2lkOw0KPiAgCXN0cnVjdCBub2RlX2VsZW1lbnQgKmVsZTsNCj4gLQl1aW50OF90ICpk YXRhID0gTlVMTDsNCj4gKwl1aW50OF90IHR0bCwgKmRhdGEgPSBOVUxMOw0KPiAgCXVpbnQzMl90 IGxlbjsNCj4gIAlpbnQgcmVzdWx0Ow0KPiAgDQo+IEBAIC0yMjc0LDggKzIwNDEsOCBAQCBzdGF0 aWMgc3RydWN0IGxfZGJ1c19tZXNzYWdlICp2ZW5kb3JfcHVibGlzaF9jYWxsKHN0cnVjdCBsX2Ri dXMgKmRidXMsDQo+ICAJaWYgKHN0cmNtcChzZW5kZXIsIG5vZGUtPm93bmVyKSkNCj4gIAkJcmV0 dXJuIGRidXNfZXJyb3IobXNnLCBNRVNIX0VSUk9SX05PVF9BVVRIT1JJWkVELCBOVUxMKTsNCj4g IA0KPiAtCWlmICghbF9kYnVzX21lc3NhZ2VfZ2V0X2FyZ3VtZW50cyhtc2csICJvcXFheSIsICZl bGVfcGF0aCwgJnZlbmRvciwNCj4gLQkJCQkJCQkmbW9kZWxfaWQsICZpdGVyX2RhdGEpKQ0KPiAr CWlmICghbF9kYnVzX21lc3NhZ2VfZ2V0X2FyZ3VtZW50cyhtc2csICJvcXFheSIsICZlbGVfcGF0 aCwgJnZlbmRvcl9pZCwNCj4gKwkJCQkJCQkmbW9kX2lkLCAmaXRlcl9kYXRhKSkNCj4gIAkJcmV0 dXJuIGRidXNfZXJyb3IobXNnLCBNRVNIX0VSUk9SX0lOVkFMSURfQVJHUywgTlVMTCk7DQo+ICAN Cj4gIAllbGUgPSBsX3F1ZXVlX2ZpbmQobm9kZS0+ZWxlbWVudHMsIG1hdGNoX2VsZW1lbnRfcGF0 aCwgZWxlX3BhdGgpOw0KPiBAQCAtMjI5MCw5ICsyMDU3LDkgQEAgc3RhdGljIHN0cnVjdCBsX2Ri dXNfbWVzc2FnZSAqdmVuZG9yX3B1Ymxpc2hfY2FsbChzdHJ1Y3QgbF9kYnVzICpkYnVzLA0KPiAg CQlyZXR1cm4gZGJ1c19lcnJvcihtc2csIE1FU0hfRVJST1JfSU5WQUxJRF9BUkdTLA0KPiAgCQkJ CQkJCSJJbmNvcnJlY3QgZGF0YSIpOw0KPiAgDQo+IC0JdmVuZG9yX21vZF9pZCA9ICh2ZW5kb3Ig PDwgMTYpIHwgbW9kZWxfaWQ7DQo+IC0JcmVzdWx0ID0gbWVzaF9tb2RlbF9wdWJsaXNoKG5vZGUs IHZlbmRvcl9tb2RfaWQsIHNyYywNCj4gLQkJCQltZXNoX25ldF9nZXRfZGVmYXVsdF90dGwobm9k ZS0+bmV0KSwgZGF0YSwgbGVuKTsNCj4gKwl0dGwgPSBtZXNoX25ldF9nZXRfZGVmYXVsdF90dGwo bm9kZS0+bmV0KTsNCj4gKwlyZXN1bHQgPSBtZXNoX21vZGVsX3B1Ymxpc2gobm9kZSwgU0VUX0lE KHZlbmRvcl9pZCwgbW9kX2lkKSwgc3JjLCB0dGwsDQo+ICsJCQkJCQkJCWRhdGEsIGxlbik7DQo+ ICANCj4gIAlpZiAocmVzdWx0ICE9IE1FU0hfRVJST1JfTk9ORSkNCj4gIAkJcmV0dXJuIGRidXNf ZXJyb3IobXNnLCByZXN1bHQsIE5VTEwpOw0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9ub2RlLmggYi9t ZXNoL25vZGUuaA0KPiBpbmRleCBkZjA1ODQ1OGEuLjQ3Yzk5ODUzMCAxMDA2NDQNCj4gLS0tIGEv bWVzaC9ub2RlLmgNCj4gKysrIGIvbWVzaC9ub2RlLmgNCj4gQEAgLTU4LDggKzU4LDggQEAgYm9v bCBub2RlX2RlZmF1bHRfdHRsX3NldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50OF90IHR0 bCk7DQo+ICBib29sIG5vZGVfc2V0X3NlcXVlbmNlX251bWJlcihzdHJ1Y3QgbWVzaF9ub2RlICpu b2RlLCB1aW50MzJfdCBzZXEpOw0KPiAgdWludDMyX3Qgbm9kZV9nZXRfc2VxdWVuY2VfbnVtYmVy KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUpOw0KPiAgaW50IG5vZGVfZ2V0X2VsZW1lbnRfaWR4KHN0 cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IGVsZV9hZGRyKTsNCj4gLXN0cnVjdCBsX3F1 ZXVlICpub2RlX2dldF9lbGVtZW50X21vZGVscyhzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50 OF90IGVsZV9pZHgsDQo+IC0JCQkJCQkJCWludCAqc3RhdHVzKTsNCj4gK3N0cnVjdCBsX3F1ZXVl ICpub2RlX2dldF9lbGVtZW50X21vZGVscyhzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLA0KPiArCQkJ CQkJCXVpbnQ4X3QgZWxlX2lkeCk7DQo+ICB1aW50MTZfdCBub2RlX2dldF9jcnBsKHN0cnVjdCBt ZXNoX25vZGUgKm5vZGUpOw0KPiAgYm9vbCBub2RlX2luaXRfZnJvbV9zdG9yYWdlKHN0cnVjdCBt ZXNoX25vZGUgKm5vZGUsIGNvbnN0IHVpbnQ4X3QgdXVpZFsxNl0sDQo+ICAJCQkJCXN0cnVjdCBt ZXNoX2NvbmZpZ19ub2RlICpkYl9ub2RlKTsNCg== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0Ot0EE71HV+y4QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 26 Jul 2020 23:27:42 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mJqWDk71HV/B/QAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 26 Jul 2020 23:27:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 65DAC404BB; Sun, 26 Jul 2020 23:27:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726682AbgGZV0u convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 26 Jul 2020 17:26:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:52546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726467AbgGZV0u (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 26 Jul 2020 17:26:50 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Sun, 26 Jul 2020 21:26:47 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: swyterzone@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-b4YEgPSpdT@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 65DAC404BB X-Rspamd-UID: 6752c3 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #111 from Swyter (swyterzone@gmail.com) --- Just submitted v4 for kernel review. Its behavior should be identical to v3, it only contains a few minor technical changes and logic flow tweaks, to appease the BlueZ gods. Nothing new. We'll see if they like this one. If it needs to be trimmed down and submitted as a tiny patch series then I can also do that. As long as it gets mainlined in some shape or form: https://patchwork.kernel.org/patch/11686157/ Thanks again for your comments and reports. I have credited some of you with a Tested-By line, hope you guys don't mind. Just let me know. ¯\_(ツ)_/¯ -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QHZAJzpVHl93wwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 06:16:58 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id WNzhJTpVHl+SHgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 06:16:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 866C541763; Mon, 27 Jul 2020 06:16:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726064AbgG0EQv convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 00:16:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:42868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725787AbgG0EQv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 00:16:51 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 27 Jul 2020 04:16:48 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gustavoyaraujo@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-DUSR7X2kCA@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: 866C541763 X-Rspamd-UID: 0aae74 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #114 from AndreyTarkovsky (gustavoyaraujo@gmail.com) --- it still does not work here on Arch Linux, kernel 5.7.9. Interesting that on Linux Mint 20, trying it in a VM, Mint recognized my dongle on bluetoothctl as showed here http://ix.io/2sq3 (this output was catched when I unplugged and plugged again the dongle)but didn't work either. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gCh/I8drHl+SIgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 07:53:11 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6IvEIcdrHl8pYgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 07:53:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 29EDB40AE5; Mon, 27 Jul 2020 07:53:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726124AbgG0FxE convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 01:53:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:33148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726006AbgG0FxD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 01:53:03 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 27 Jul 2020 05:53:00 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: markus@daeschler.name X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-60824-62941-hDkw9vLQ9c@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: 29EDB40AE5 X-Rspamd-UID: ad6e0d https://bugzilla.kernel.org/show_bug.cgi?id=60824 markus@daeschler.name changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |markus@daeschler.name --- Comment #115 from markus@daeschler.name --- Thanks for the patch! I tested with v3 in kernel 5.7.10-1-MANJARO. It works for me with following issues: - connecting worked not so well until I enabled USB port over sysfs completely with setting power/control to "on" (enable_autosuspend=0 seems not to be sufficient in my case) - dongle doesn't support more as one simultan connection. But I think this is a firmware problem and not a driver one My lsusb output: Bus 004 Device 017: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 224 Wireless bDeviceSubClass 1 Radio Frequency bDeviceProtocol 1 Bluetooth bMaxPacketSize0 64 idVendor 0x0a12 Cambridge Silicon Radio, Ltd idProduct 0x0001 Bluetooth Dongle (HCI mode) bcdDevice 88.91 iManufacturer 0 iProduct 2 USB1.1-A䀹嘔 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x00b1 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 1 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 2 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 3 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 4 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 5 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x003f 1x 63 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x003f 1x 63 bytes bInterval 1 can't get debug descriptor: Resource temporarily unavailable Device Status: 0x0000 (Bus Powered) -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OJyHA8ujHl9ozwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 11:52:11 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cGc6AsujHl/T/gEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 11:52:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 50626A2CD0; Mon, 27 Jul 2020 11:52:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727886AbgG0Jvw convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 05:51:52 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:23867 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727840AbgG0Jvv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 05:51:51 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-157-rSG2T3OdNGGcdmdBioAAVQ-1; Mon, 27 Jul 2020 10:51:47 +0100 X-MC-Unique: rSG2T3OdNGGcdmdBioAAVQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 27 Jul 2020 10:51:45 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Mon, 27 Jul 2020 10:51:45 +0100 From: David Laight <David.Laight@ACULAB.COM> To: 'David Miller' <davem@davemloft.net>, "hch@lst.de" <hch@lst.de> CC: "kuba@kernel.org" <kuba@kernel.org>, "ast@kernel.org" <ast@kernel.org>, "daniel@iogearbox.net" <daniel@iogearbox.net>, "kuznet@ms2.inr.ac.ru" <kuznet@ms2.inr.ac.ru>, "yoshfuji@linux-ipv6.org" <yoshfuji@linux-ipv6.org>, "edumazet@google.com" <edumazet@google.com>, "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "bpf@vger.kernel.org" <bpf@vger.kernel.org>, "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>, "coreteam@netfilter.org" <coreteam@netfilter.org>, "linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>, "linux-hams@vger.kernel.org" <linux-hams@vger.kernel.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "bridge@lists.linux-foundation.org" <bridge@lists.linux-foundation.org>, "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>, "dccp@vger.kernel.org" <dccp@vger.kernel.org>, "linux-decnet-user@lists.sourceforge.net" <linux-decnet-user@lists.sourceforge.net>, "linux-wpan@vger.kernel.org" <linux-wpan@vger.kernel.org>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, "mptcp@lists.01.org" <mptcp@lists.01.org>, "lvs-devel@vger.kernel.org" <lvs-devel@vger.kernel.org>, "rds-devel@oss.oracle.com" <rds-devel@oss.oracle.com>, "linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>, "tipc-discussion@lists.sourceforge.net" <tipc-discussion@lists.sourceforge.net>, "linux-x25@vger.kernel.org" <linux-x25@vger.kernel.org> Subject: RE: get rid of the address_space override in setsockopt v2 Thread-Topic: get rid of the address_space override in setsockopt v2 Thread-Index: AQHWYgvqDt5Xt3HFu0u82UKLVqcKxKkbLTEQ Date: Mon, 27 Jul 2020 09:51:45 +0000 Message-ID: <8ae792c27f144d4bb5cbea0c1cce4eed@AcuMS.aculab.com> References: <20200723060908.50081-1-hch@lst.de> <20200724.154342.1433271593505001306.davem@davemloft.net> In-Reply-To: <20200724.154342.1433271593505001306.davem@davemloft.net> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 22 X-Rspamd-Score: 3.39 / 15.00 / 200.00 X-Rspamd-Queue-Id: 50626A2CD0 X-Rspamd-UID: 9f62ab From: David Miller > Sent: 24 July 2020 23:44 > > From: Christoph Hellwig <hch@lst.de> > Date: Thu, 23 Jul 2020 08:08:42 +0200 > > > setsockopt is the last place in architecture-independ code that still > > uses set_fs to force the uaccess routines to operate on kernel pointers. > > > > This series adds a new sockptr_t type that can contained either a kernel > > or user pointer, and which has accessors that do the right thing, and > > then uses it for setsockopt, starting by refactoring some low-level > > helpers and moving them over to it before finally doing the main > > setsockopt method. > > > > Note that apparently the eBPF selftests do not even cover this path, so > > the series has been tested with a testing patch that always copies the > > data first and passes a kernel pointer. This is something that works for > > most common sockopts (and is something that the ePBF support relies on), > > but unfortunately in various corner cases we either don't use the passed > > in length, or in one case actually copy data back from setsockopt, or in > > case of bpfilter straight out do not work with kernel pointers at all. > > > > Against net-next/master. > > > > Changes since v1: > > - check that users don't pass in kernel addresses > > - more bpfilter cleanups > > - cosmetic mptcp tweak > > Series applied to net-next, I'm build testing and will push this out when > that is done. Hmmm... this code does: int __sys_setsockopt(int fd, int level, int optname, char __user *user_optval, int optlen) { sockptr_t optval; char *kernel_optval = NULL; int err, fput_needed; struct socket *sock; if (optlen < 0) return -EINVAL; err = init_user_sockptr(&optval, user_optval); if (err) return err; And the called code does: if (copy_from_sockptr(&opt, optbuf, sizeof(opt))) return -EFAULT; Which means that only the base of the user's buffer is checked for being in userspace. I'm sure there is code that processes options in chunks. This probably means it is possible to put a chunk boundary at the end of userspace and continue processing the very start of kernel memory. At best this faults on the kernel copy code and crashes the system. Maybe there wasn't any code that actually incremented the user address. But it is hardly robust. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IL94Fqe+Hl+sgwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 13:46:47 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id MAZQFae+Hl+NYgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 13:46:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BF16141747; Mon, 27 Jul 2020 13:46:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726976AbgG0Lqi (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 07:46:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726599AbgG0Lqh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 07:46:37 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85FD7C061794 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 04:46:37 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id w12so2975089iom.4 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 04:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6QSdUN1soPfoKeCyvOxy1GyQLEauSujDq0FyNrkcHWA=; b=bXFEeaXt2ImEDBc4MBatUQhKoruNN4D4UjrdIhrwkWvLTAxubjHi6ufBPkbL0rZUQ4 2D8wmvP1zK4fIu/33pP2iYiq0sGxNB+EQDRzmztNd7ZRNnFrScIFE7mCJZbr6mEAE36K bNznDH4BRhqWYF+go6zxX4J2+7BPgt5xQHhb+2s9KxozQrOoxlabBqSiiP8razNngwUH oaJcqgaHm8OmcC2dWe3IuHo+5jQYISxy/DFqu+TWUFq4beVNUeZ0PkHSZXbzJBQTDCr2 6Z7dI3iovUe+fkQy1vP8D5go8I6h1g80PQZCPx9bVPa5NygeHHwQx3y54WceDjT/juQo YYqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6QSdUN1soPfoKeCyvOxy1GyQLEauSujDq0FyNrkcHWA=; b=BghW9U2x+Pez+kON5ArGQ+1Ij+YrODbh3OT4LVJVMA0LprsDE/ZuQYr1GXB7PaLZK5 yv72xxHRaaBFYsesHw0egHx+ued7j/SHS4TwssePmaaesjvqXSeJJAhRSENMzSYEfJzE 6yLA2fdOfGu8/zqHAORiq9hjkeaBgeQ83BqLkVa4u5otbIhJRXe8iTpNLFFYDTezAPEt aH/2MPYbg93y+W/0QT3FqMVcekcTHvJx0m6kGfGKQOz8ZHnatmr1nM8bTXRQ7ieW53UB aN47wOnkrgRXSYivTVO8PISRAa8LIwEtkAlwvrIMmcNjLg2uyZhQ0wgBrS+DbACxKkJ9 fnvw== X-Gm-Message-State: AOAM532ocqvGYLBMMfHUIr2ijF97qb3+N7clL2jgLY0eOJl+ovBDXDDB 4veGwgmNCY2S/F1trybtrbbzYI0i9CUvXH7IkLCYc0Ye X-Google-Smtp-Source: ABdhPJy8Dio1s81m6+q53V/OlPgKtsqthJhrC2hV7/hCx7pa7FjgiSung7+dkExaG42/MFFsfq2rOMySmgBLI7h15LE= X-Received: by 2002:a05:6602:220f:: with SMTP id n15mr23649656ion.103.1595850396605; Mon, 27 Jul 2020 04:46:36 -0700 (PDT) MIME-Version: 1.0 References: <20200723123903.29337-1-sathish.narasimman@intel.com> <20200723123903.29337-8-sathish.narasimman@intel.com> In-Reply-To: <20200723123903.29337-8-sathish.narasimman@intel.com> From: Sathish Narasimman <nsathish41@gmail.com> Date: Mon, 27 Jul 2020 17:16:25 +0530 Message-ID: <CAOVXEJ+=Y+e4bSmysA-_j6j4GsVseazOzpNxnGRKGDL25+86jw@mail.gmail.com> Subject: Re: [PATCH v5 8/8] Bluetooth: Enable controller RPA resolution using Experimental feature To: Bluez mailing list <linux-bluetooth@vger.kernel.org>, Chethan T N <chethan.tumkur.narayan@intel.com>, Marcel Holtmann <marcel@holtmann.org> Cc: Sathish Narasimman <sathish.narasimman@intel.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: BF16141747 X-Rspamd-UID: 3b6acd Hi gentle reminder On Thu, Jul 23, 2020 at 6:05 PM Sathish Narasimman <nsathish41@gmail.com> wrote: > > This patch adds support to enable the use of RPA Address resolution > using expermental feature mgmt command. > > Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com> > --- > include/net/bluetooth/hci.h | 1 + > net/bluetooth/hci_event.c | 1 + > net/bluetooth/hci_request.c | 7 ++- > net/bluetooth/mgmt.c | 112 ++++++++++++++++++++++++++++++++++++ > 4 files changed, 120 insertions(+), 1 deletion(-) > > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h > index 4ff2fc4498f3..55205d805c22 100644 > --- a/include/net/bluetooth/hci.h > +++ b/include/net/bluetooth/hci.h > @@ -307,6 +307,7 @@ enum { > HCI_FORCE_BREDR_SMP, > HCI_FORCE_STATIC_ADDR, > HCI_LL_RPA_RESOLUTION, > + HCI_ENABLE_LL_PRIVACY, > HCI_CMD_PENDING, > HCI_FORCE_NO_MITM, > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 628831b15c0a..33d8458fdd4a 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -5230,6 +5230,7 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, > le16_to_cpu(ev->supervision_timeout)); > > if (use_ll_privacy(hdev) && > + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && > hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) > hci_req_disable_address_resolution(hdev); > } > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > index 70e077cc7dfa..435400a43a78 100644 > --- a/net/bluetooth/hci_request.c > +++ b/net/bluetooth/hci_request.c > @@ -678,8 +678,10 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) > > /* Disable address resolution */ > if (use_ll_privacy(hdev) && > + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && > hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { > __u8 enable = 0x00; > + > hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); > } > } > @@ -870,8 +872,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, > return; > } > > - if (use_ll_privacy(hdev) && addr_resolv) { > + if (use_ll_privacy(hdev) && > + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && > + addr_resolv) { > u8 enable = 0x01; > + > hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); > } > > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > index 47bcfe2fb14c..adde92cf015d 100644 > --- a/net/bluetooth/mgmt.c > +++ b/net/bluetooth/mgmt.c > @@ -3759,6 +3759,12 @@ static const u8 simult_central_periph_uuid[16] = { > 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > }; > > +/* 15c0a148-c273-11ea-b3de-0242ac130004 */ > +static const u8 rpa_resolution_uuid[16] = { > + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, > + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, > +}; > + > static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > void *data, u16 data_len) > { > @@ -3795,6 +3801,21 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > idx++; > } > > + if (use_ll_privacy(hdev)) { > + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) { > + flags = BIT(0); > + if (!hci_dev_test_flag(hdev, HCI_ADVERTISING)) > + flags |= BIT(1); > + } else > + flags = 0; > + > + memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); > + rp->features[idx].flags = cpu_to_le32(flags); > + idx++; > + > + new_settings(hdev, sk); > + } > + > rp->feature_count = cpu_to_le16(idx); > > /* After reading the experimental features information, enable > @@ -3807,6 +3828,27 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > 0, rp, sizeof(*rp) + (20 * idx)); > } > > +static int exp_ll_privacy_feature_changed(bool enabled, struct sock *skip) > +{ > + struct mgmt_ev_exp_feature_changed ev; > + u32 flags; > + > + memset(&ev, 0, sizeof(ev)); > + memcpy(ev.uuid, rpa_resolution_uuid, 16); > + > + if (enabled) > + flags = 0x03; > + else > + flags = 0; > + > + ev.flags = cpu_to_le32(flags); > + > + return mgmt_limited_event(MGMT_EV_EXP_FEATURE_CHANGED, NULL, > + &ev, sizeof(ev), > + HCI_MGMT_EXP_FEATURE_EVENTS, skip); > + > +} > + > #ifdef CONFIG_BT_FEATURE_DEBUG > static int exp_debug_feature_changed(bool enabled, struct sock *skip) > { > @@ -3845,6 +3887,18 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + if (use_ll_privacy(hdev)) { > + bool changed; > + > + changed = hci_dev_test_flag(hdev, > + HCI_ENABLE_LL_PRIVACY); > + > + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); > + > + if (changed) > + exp_ll_privacy_feature_changed(false, sk); > + } > + > hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); > > return mgmt_cmd_complete(sk, hdev ? hdev->id : MGMT_INDEX_NONE, > @@ -3895,6 +3949,64 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + if (!memcmp(cp->uuid, rpa_resolution_uuid, 16)) { > + bool val, changed; > + int err; > + u32 flags; > + > + /* Parameters are limited to a single octet */ > + if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) > + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, > + MGMT_OP_SET_EXP_FEATURE, > + MGMT_STATUS_INVALID_PARAMS); > + > + /* Only boolean on/off is supported */ > + if (cp->param[0] != 0x00 && cp->param[0] != 0x01) > + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, > + MGMT_OP_SET_EXP_FEATURE, > + MGMT_STATUS_INVALID_PARAMS); > + > + val = !!cp->param[0]; > + > + if (val) { > + changed = !hci_dev_test_flag(hdev, > + HCI_ENABLE_LL_PRIVACY); > + > + hci_dev_set_flag(hdev, HCI_ENABLE_LL_PRIVACY); > + > + /* Enable LL privacy */ > + flags = BIT(0); > + /* Disable HCI_ADVERTISING flag */ > + flags |= BIT(1); > + > + hci_dev_clear_flag(hdev, HCI_ADVERTISING); > + > + } else { > + changed = hci_dev_test_flag(hdev, > + HCI_ENABLE_LL_PRIVACY); > + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); > + > + flags = 0; > + } > + > + memcpy(rp.uuid, rpa_resolution_uuid, 16); > + > + rp.flags = cpu_to_le32(flags); > + > + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); > + > + err = mgmt_cmd_complete(sk, MGMT_INDEX_NONE, > + MGMT_OP_SET_EXP_FEATURE, 0, > + &rp, sizeof(rp)); > + > + if (changed) { > + exp_ll_privacy_feature_changed(val, sk); > + new_settings(hdev, sk); > + } > + > + return err; > + } > + > return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, > MGMT_OP_SET_EXP_FEATURE, > MGMT_STATUS_NOT_SUPPORTED); > -- > 2.17.1 > Regards Sathish N Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SPWDJWPFHl8ttgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 14:15:31 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uFgqJGPFHl+WjgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 14:15:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=messagingengine.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C5F26A1717; Mon, 27 Jul 2020 14:15:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728129AbgG0MPO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 08:15:14 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:43557 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726555AbgG0MPN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 08:15:13 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 858ED580626; Mon, 27 Jul 2020 08:15:11 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 27 Jul 2020 08:15:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=zQ5cK+ UyqnfJ5Bs5mc2l5CGTYqkVGioSJ7/rqh6pAKo=; b=cz67FKlM5wTYH6ZHs8cumN 6Lloe5U6Wof104VdSstoZvBZVPQWGdAx/fMZfPQxIwG0p8iESwpGeuM7tUbH7y0c 5nwF6SEQIGjZVO/5CmL/kqzdqg9Btv1iK/m/DFBcSQvbdxe/OqRzITPeS2TcH/Y+ Rprx9Vp4fYTO6goik0AFPtlzp/RTh1KyjaQJAaV4CWXK+yEGSMO73vw2Bvs3jvH/ xn05lT9HilG+7jY3vY3UhaljUx6pT7HHVwgspZ5cqQnXh6v+NBrjfYm4b9qLqHRM BmrV61GpLVJpu1JgeZoeM7zuzyCKx+b8Xqsjra7JohU70SIOprEe6DltCaWHoeSQ == X-ME-Sender: <xms:TcUeX_6kVxk3W7PFyY8aD2OpbpNtNrYvJvqdVELMLD3-WQTkXX8Hmg> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedriedtgdehtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepkfguohcuufgt hhhimhhmvghluceoihguohhstghhsehiughoshgthhdrohhrgheqnecuggftrfgrthhtvg hrnheptdffkeekfeduffevgeeujeffjefhtefgueeugfevtdeiheduueeukefhudehleet necukfhppeejledrudekuddrvddrudejleenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehiughoshgthhesihguohhstghhrdhorhhg X-ME-Proxy: <xmx:TcUeX06Qqy5aEJFW6Jpg_LZa1dJ4eY6nkkQcVlz4XOtHLjqmQNDxTw> <xmx:TcUeX2fd-qWfehY8_YaMTYqQAxXos584gd2IyW8HI9rJNz3B9JOvMg> <xmx:TcUeXwI7ksA1oOAl1pVV8mG18oLCDmnkFZDN6_zUljX6iXpa1GFghA> <xmx:T8UeXw5_98Jq_Ux1_bj8TbKmStoIGlRImlxpRg8bsqiWWADoZ6hKgA> Received: from localhost (bzq-79-181-2-179.red.bezeqint.net [79.181.2.179]) by mail.messagingengine.com (Postfix) with ESMTPA id 80C84328005D; Mon, 27 Jul 2020 08:15:08 -0400 (EDT) Date: Mon, 27 Jul 2020 15:15:05 +0300 From: Ido Schimmel <idosch@idosch.org> To: Christoph Hellwig <hch@lst.de> Cc: "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 19/26] net/ipv6: switch ipv6_flowlabel_opt to sockptr_t Message-ID: <20200727121505.GA1804864@shredder> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-20-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200723060908.50081-20-hch@lst.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 0.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: C5F26A1717 X-Rspamd-UID: 9d39ba On Thu, Jul 23, 2020 at 08:09:01AM +0200, Christoph Hellwig wrote: > Pass a sockptr_t to prepare for set_fs-less handling of the kernel > pointer from bpf-cgroup. > > Note that the get case is pretty weird in that it actually copies data > back to userspace from setsockopt. > > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > include/net/ipv6.h | 2 +- > net/ipv6/ip6_flowlabel.c | 16 +++++++++------- > net/ipv6/ipv6_sockglue.c | 2 +- > 3 files changed, 11 insertions(+), 9 deletions(-) > > diff --git a/include/net/ipv6.h b/include/net/ipv6.h > index 262fc88dbd7e2f..4c9d89b5d73268 100644 > --- a/include/net/ipv6.h > +++ b/include/net/ipv6.h > @@ -406,7 +406,7 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space, > struct ip6_flowlabel *fl, > struct ipv6_txoptions *fopt); > void fl6_free_socklist(struct sock *sk); > -int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen); > +int ipv6_flowlabel_opt(struct sock *sk, sockptr_t optval, int optlen); > int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq, > int flags); > int ip6_flowlabel_init(void); > diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c > index 27ee6de9beffc4..6b3c315f3d461a 100644 > --- a/net/ipv6/ip6_flowlabel.c > +++ b/net/ipv6/ip6_flowlabel.c > @@ -371,7 +371,7 @@ static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned lo > > static struct ip6_flowlabel * > fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, > - char __user *optval, int optlen, int *err_p) > + sockptr_t optval, int optlen, int *err_p) > { > struct ip6_flowlabel *fl = NULL; > int olen; > @@ -401,7 +401,8 @@ fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, > memset(fl->opt, 0, sizeof(*fl->opt)); > fl->opt->tot_len = sizeof(*fl->opt) + olen; > err = -EFAULT; > - if (copy_from_user(fl->opt+1, optval+CMSG_ALIGN(sizeof(*freq)), olen)) > + sockptr_advance(optval, CMSG_ALIGN(sizeof(*freq))); > + if (copy_from_sockptr(fl->opt + 1, optval, olen)) > goto done; > > msg.msg_controllen = olen; > @@ -604,7 +605,7 @@ static int ipv6_flowlabel_renew(struct sock *sk, struct in6_flowlabel_req *freq) > } > > static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, > - void __user *optval, int optlen) > + sockptr_t optval, int optlen) > { > struct ipv6_fl_socklist *sfl, *sfl1 = NULL; > struct ip6_flowlabel *fl, *fl1 = NULL; > @@ -702,8 +703,9 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, > goto recheck; > > if (!freq->flr_label) { > - if (copy_to_user(&((struct in6_flowlabel_req __user *) optval)->flr_label, > - &fl->label, sizeof(fl->label))) { > + sockptr_advance(optval, > + offsetof(struct in6_flowlabel_req, flr_label)); Christoph, I see a regression with IPv6 flowlabel that I bisected to this patch. When passing '-F 0' to 'ping' the flow label should be random, yet it's the same every time after this patch. It seems that the pointer is never advanced after the call to sockptr_advance() because it is passed by value and not by reference. Even if you were to pass it by reference I think you would later need to call sockptr_decrease() or something similar. Otherwise it is very error-prone. Maybe adding an offset to copy_to_sockptr() and copy_from_sockptr() is better? Thanks > + if (copy_to_sockptr(optval, &fl->label, sizeof(fl->label))) { > /* Intentionally ignore fault. */ > } > } > @@ -716,13 +718,13 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, > return err; > } > > -int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen) > +int ipv6_flowlabel_opt(struct sock *sk, sockptr_t optval, int optlen) > { > struct in6_flowlabel_req freq; > > if (optlen < sizeof(freq)) > return -EINVAL; > - if (copy_from_user(&freq, optval, sizeof(freq))) > + if (copy_from_sockptr(&freq, optval, sizeof(freq))) > return -EFAULT; > > switch (freq.flr_action) { > diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c > index 119dfaf5f4bb26..3897fb55372d38 100644 > --- a/net/ipv6/ipv6_sockglue.c > +++ b/net/ipv6/ipv6_sockglue.c > @@ -929,7 +929,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, > retv = 0; > break; > case IPV6_FLOWLABEL_MGR: > - retv = ipv6_flowlabel_opt(sk, optval, optlen); > + retv = ipv6_flowlabel_opt(sk, USER_SOCKPTR(optval), optlen); > break; > case IPV6_IPSEC_POLICY: > case IPV6_XFRM_POLICY: > -- > 2.27.0 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qJj/D7bVHl+PEwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 15:25:10 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iDn5DbbVHl8gfQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 15:25:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EADADA2C03; Mon, 27 Jul 2020 15:25:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728640AbgG0NY4 convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 09:24:56 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:28284 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726313AbgG0NYw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 09:24:52 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-193-MlZusWDpPT2OM9ZpGGXrfQ-1; Mon, 27 Jul 2020 14:24:47 +0100 X-MC-Unique: MlZusWDpPT2OM9ZpGGXrfQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 27 Jul 2020 14:24:45 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Mon, 27 Jul 2020 14:24:45 +0100 From: David Laight <David.Laight@ACULAB.COM> To: 'Ido Schimmel' <idosch@idosch.org>, Christoph Hellwig <hch@lst.de> CC: "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "bpf@vger.kernel.org" <bpf@vger.kernel.org>, "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>, "coreteam@netfilter.org" <coreteam@netfilter.org>, "linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>, "linux-hams@vger.kernel.org" <linux-hams@vger.kernel.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "bridge@lists.linux-foundation.org" <bridge@lists.linux-foundation.org>, "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>, "dccp@vger.kernel.org" <dccp@vger.kernel.org>, "linux-decnet-user@lists.sourceforge.net" <linux-decnet-user@lists.sourceforge.net>, "linux-wpan@vger.kernel.org" <linux-wpan@vger.kernel.org>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, "mptcp@lists.01.org" <mptcp@lists.01.org>, "lvs-devel@vger.kernel.org" <lvs-devel@vger.kernel.org>, "rds-devel@oss.oracle.com" <rds-devel@oss.oracle.com>, "linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>, "tipc-discussion@lists.sourceforge.net" <tipc-discussion@lists.sourceforge.net>, "linux-x25@vger.kernel.org" <linux-x25@vger.kernel.org> Subject: RE: [PATCH 19/26] net/ipv6: switch ipv6_flowlabel_opt to sockptr_t Thread-Topic: [PATCH 19/26] net/ipv6: switch ipv6_flowlabel_opt to sockptr_t Thread-Index: AQHWZA+bicrTMJDvYkuXLSSepOLT0qkbaJEw Date: Mon, 27 Jul 2020 13:24:45 +0000 Message-ID: <8c747034a5b641d18734de5f4d3a7507@AcuMS.aculab.com> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-20-hch@lst.de> <20200727121505.GA1804864@shredder> In-Reply-To: <20200727121505.GA1804864@shredder> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: EADADA2C03 X-Rspamd-UID: 8a8ad7 From: Ido Schimmel > Sent: 27 July 2020 13:15 > On Thu, Jul 23, 2020 at 08:09:01AM +0200, Christoph Hellwig wrote: > > Pass a sockptr_t to prepare for set_fs-less handling of the kernel > > pointer from bpf-cgroup. > > > > Note that the get case is pretty weird in that it actually copies data > > back to userspace from setsockopt. > > > > Signed-off-by: Christoph Hellwig <hch@lst.de> > > --- > > include/net/ipv6.h | 2 +- > > net/ipv6/ip6_flowlabel.c | 16 +++++++++------- > > net/ipv6/ipv6_sockglue.c | 2 +- > > 3 files changed, 11 insertions(+), 9 deletions(-) > > > > diff --git a/include/net/ipv6.h b/include/net/ipv6.h > > index 262fc88dbd7e2f..4c9d89b5d73268 100644 > > --- a/include/net/ipv6.h > > +++ b/include/net/ipv6.h > > @@ -406,7 +406,7 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space, > > struct ip6_flowlabel *fl, > > struct ipv6_txoptions *fopt); > > void fl6_free_socklist(struct sock *sk); > > -int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen); > > +int ipv6_flowlabel_opt(struct sock *sk, sockptr_t optval, int optlen); > > int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq, > > int flags); > > int ip6_flowlabel_init(void); > > diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c > > index 27ee6de9beffc4..6b3c315f3d461a 100644 > > --- a/net/ipv6/ip6_flowlabel.c > > +++ b/net/ipv6/ip6_flowlabel.c > > @@ -371,7 +371,7 @@ static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned lo > > > > static struct ip6_flowlabel * > > fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, > > - char __user *optval, int optlen, int *err_p) > > + sockptr_t optval, int optlen, int *err_p) > > { > > struct ip6_flowlabel *fl = NULL; > > int olen; > > @@ -401,7 +401,8 @@ fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, > > memset(fl->opt, 0, sizeof(*fl->opt)); > > fl->opt->tot_len = sizeof(*fl->opt) + olen; > > err = -EFAULT; > > - if (copy_from_user(fl->opt+1, optval+CMSG_ALIGN(sizeof(*freq)), olen)) > > + sockptr_advance(optval, CMSG_ALIGN(sizeof(*freq))); > > + if (copy_from_sockptr(fl->opt + 1, optval, olen)) > > goto done; > > > > msg.msg_controllen = olen; > > @@ -604,7 +605,7 @@ static int ipv6_flowlabel_renew(struct sock *sk, struct in6_flowlabel_req *freq) > > } > > > > static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, > > - void __user *optval, int optlen) > > + sockptr_t optval, int optlen) > > { > > struct ipv6_fl_socklist *sfl, *sfl1 = NULL; > > struct ip6_flowlabel *fl, *fl1 = NULL; > > @@ -702,8 +703,9 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, > > goto recheck; > > > > if (!freq->flr_label) { > > - if (copy_to_user(&((struct in6_flowlabel_req __user *) optval)->flr_label, > > - &fl->label, sizeof(fl->label))) { > > + sockptr_advance(optval, > > + offsetof(struct in6_flowlabel_req, flr_label)); > > Christoph, > > I see a regression with IPv6 flowlabel that I bisected to this patch. > When passing '-F 0' to 'ping' the flow label should be random, yet it's > the same every time after this patch. > > It seems that the pointer is never advanced after the call to > sockptr_advance() because it is passed by value and not by reference. > Even if you were to pass it by reference I think you would later need to > call sockptr_decrease() or something similar. Otherwise it is very > error-prone. Depending on the other checks you may also be able to cross from user addresses to kernel ones. At the minimum sockptr_advance() has to fail if the boundary would be crossed. > Maybe adding an offset to copy_to_sockptr() and copy_from_sockptr() is > better? The 'is this a kernel or user copy' needs to use the base address from the system call. So you do need the offset passed in to copy_to/from_sockptr(). Clearly churn can be reduced by using a #define or static inline for the common case. The alternative is to pass a 'fat pointer' through than can contain an offset as well as the user/kernel bases and expected length. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KL0IKwjQHl/bAAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 15:00:56 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id +NPNKQjQHl/HMgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 15:00:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 621DFA1DC8; Mon, 27 Jul 2020 15:00:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728503AbgG0NAf (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 09:00:35 -0400 Received: from verein.lst.de ([213.95.11.211]:43383 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728141AbgG0NAf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 09:00:35 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 8046868C4E; Mon, 27 Jul 2020 15:00:29 +0200 (CEST) Date: Mon, 27 Jul 2020 15:00:29 +0200 From: Christoph Hellwig <hch@lst.de> To: Ido Schimmel <idosch@idosch.org> Cc: Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 19/26] net/ipv6: switch ipv6_flowlabel_opt to sockptr_t Message-ID: <20200727130029.GA26393@lst.de> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-20-hch@lst.de> <20200727121505.GA1804864@shredder> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200727121505.GA1804864@shredder> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.60 / 15.00 / 200.00 X-Rspamd-Queue-Id: 621DFA1DC8 X-Rspamd-UID: 554b23 On Mon, Jul 27, 2020 at 03:15:05PM +0300, Ido Schimmel wrote: > I see a regression with IPv6 flowlabel that I bisected to this patch. > When passing '-F 0' to 'ping' the flow label should be random, yet it's > the same every time after this patch. Can you send a reproducer? > > It seems that the pointer is never advanced after the call to > sockptr_advance() because it is passed by value and not by reference. > Even if you were to pass it by reference I think you would later need to > call sockptr_decrease() or something similar. Otherwise it is very > error-prone. > > Maybe adding an offset to copy_to_sockptr() and copy_from_sockptr() is > better? We could do that, although I wouldn't add it to the existing functions to avoid the churns and instead add copy_to_sockptr_offset or something like that. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QEUpBsjXHl87OAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 15:34:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id iI96BMjXHl9CTgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 15:34:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=messagingengine.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 32CEDA2BC5; Mon, 27 Jul 2020 15:33:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728939AbgG0Ndk (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 09:33:40 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:37971 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728322AbgG0Ndk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 09:33:40 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 0448158053F; Mon, 27 Jul 2020 09:33:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 27 Jul 2020 09:33:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=YgsMZx 5pwgpEVAvT6XOgIf4w7AHitJHDyTwwU4qEatA=; b=jQRpjra5a+K9eBy0w+s+Vz mPB94ZBosBduEWOnSjljw+8hpjEzFFC904sOPmp7ARDe+7b/eXgsCKJmhtNyicBZ zCPwwjkkb05K0YfGiAlA2DjbQ1tDLUZN+JjPw3S7qjVj1grZEX4aHI1AiVsE9Io+ bNlBAGI/fkhfHIPXd+03GrSnOlle3YkzFc7ppSc0/mjvP7Ug0ymP/jml3M2cNzpZ 3nqHV1F7F7FdVxhEmwJMcva5WUKD1OYbGuvTFkmIgufIhR4Y72HrPEITOBAe68Cd fvWvVqG/K7r5+3fgppYIz90IWY9h/aEu1muFU3O5nc5cERR4JMg31zdbbJgisnTQ == X-ME-Sender: <xms:rtceXy0qPafjj9qpXmjj6TnMvhnN8iqgYqZd1rJD6mGA9-PBCQUb-w> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedriedtgdeijecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepkfguohcuufgt hhhimhhmvghluceoihguohhstghhsehiughoshgthhdrohhrgheqnecuggftrfgrthhtvg hrnheptdffkeekfeduffevgeeujeffjefhtefgueeugfevtdeiheduueeukefhudehleet necukfhppeejledrudekuddrvddrudejleenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehiughoshgthhesihguohhstghhrdhorhhg X-ME-Proxy: <xmx:rtceX1F_YViw2fDAyMCnC7fGnfljQba279q87vXUcjjPowXNi_Cqsg> <xmx:rtceX65T8s2wLqXjs6IFdWVooA4TqBK23wtFXT8C9ITPngl1WqSE7w> <xmx:rtceXz1hp7RD7fUx415E-Em3LUMy8FS0rLa4p_YYh0paweRCsdWclA> <xmx:stceX9WkosEn1T_dUOgyyDuWyUiT95rC7CZ-5r4WjPh7lQcldUdW1g> Received: from localhost (bzq-79-181-2-179.red.bezeqint.net [79.181.2.179]) by mail.messagingengine.com (Postfix) with ESMTPA id 9886A3280064; Mon, 27 Jul 2020 09:33:33 -0400 (EDT) Date: Mon, 27 Jul 2020 16:33:31 +0300 From: Ido Schimmel <idosch@idosch.org> To: Christoph Hellwig <hch@lst.de> Cc: "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 19/26] net/ipv6: switch ipv6_flowlabel_opt to sockptr_t Message-ID: <20200727133331.GA1851348@shredder> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-20-hch@lst.de> <20200727121505.GA1804864@shredder> <20200727130029.GA26393@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200727130029.GA26393@lst.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 32CEDA2BC5 X-Rspamd-UID: 3a659b On Mon, Jul 27, 2020 at 03:00:29PM +0200, Christoph Hellwig wrote: > On Mon, Jul 27, 2020 at 03:15:05PM +0300, Ido Schimmel wrote: > > I see a regression with IPv6 flowlabel that I bisected to this patch. > > When passing '-F 0' to 'ping' the flow label should be random, yet it's > > the same every time after this patch. > > Can you send a reproducer? ``` #!/bin/bash ip link add name dummy10 up type dummy ping -q -F 0 -I dummy10 ff02::1 &> /dev/null & tcpdump -nne -e -i dummy10 -vvv -c 1 dst host ff02::1 pkill ping echo ping -F 0 -I dummy10 ff02::1 &> /dev/null & tcpdump -nne -e -i dummy10 -vvv -c 1 dst host ff02::1 pkill ping ip link del dev dummy10 ``` Output with commit ff6a4cf214ef ("net/ipv6: split up ipv6_flowlabel_opt"): ``` dropped privs to tcpdump tcpdump: listening on dummy10, link-type EN10MB (Ethernet), capture size 262144 bytes 16:26:27.072559 62:80:34:1d:b4:b8 > 33:33:00:00:00:01, ethertype IPv6 (0x86dd), length 118: (flowlabel 0x920cf, hlim 1, next-header ICMPv6 (58) payload length: 64) fe80::6080:34ff:fe1d:b4b8 > ff02::1: [icmp6 sum ok] ICMP6, echo request, seq 2 1 packet captured 1 packet received by filter 0 packets dropped by kernel dropped privs to tcpdump tcpdump: listening on dummy10, link-type EN10MB (Ethernet), capture size 262144 bytes 16:26:28.352528 62:80:34:1d:b4:b8 > 33:33:00:00:00:01, ethertype IPv6 (0x86dd), length 118: (flowlabel 0xcdd97, hlim 1, next-header ICMPv6 (58) payload length: 64) fe80::6080:34ff:fe1d:b4b8 > ff02::1: [icmp6 sum ok] ICMP6, echo request, seq 2 1 packet captured 1 packet received by filter 0 packets dropped by kernel ``` Output with commit 86298285c9ae ("net/ipv6: switch ipv6_flowlabel_opt to sockptr_t"): ``` dropped privs to tcpdump tcpdump: listening on dummy10, link-type EN10MB (Ethernet), capture size 262144 bytes 16:32:17.848517 f2:9a:05:ff:cb:25 > 33:33:00:00:00:01, ethertype IPv6 (0x86dd), length 118: (flowlabel 0xfab36, hlim 1, next-header ICMPv6 (58) payload length: 64) fe80::f09a:5ff:feff:cb25 > ff02::1: [icmp6 sum ok] ICMP6, echo request, seq 2 1 packet captured 1 packet received by filter 0 packets dropped by kernel dropped privs to tcpdump tcpdump: listening on dummy10, link-type EN10MB (Ethernet), capture size 262144 bytes 16:32:19.000779 f2:9a:05:ff:cb:25 > 33:33:00:00:00:01, ethertype IPv6 (0x86dd), length 118: (flowlabel 0xfab36, hlim 1, next-header ICMPv6 (58) payload length: 64) fe80::f09 a:5ff:feff:cb25 > ff02::1: [icmp6 sum ok] ICMP6, echo request, seq 2 1 packet captured 1 packet received by filter 0 packets dropped by kernel ``` > > > > > It seems that the pointer is never advanced after the call to > > sockptr_advance() because it is passed by value and not by reference. > > Even if you were to pass it by reference I think you would later need to > > call sockptr_decrease() or something similar. Otherwise it is very > > error-prone. > > > > Maybe adding an offset to copy_to_sockptr() and copy_from_sockptr() is > > better? > > We could do that, although I wouldn't add it to the existing functions > to avoid the churns and instead add copy_to_sockptr_offset or something > like that. Sounds good Thanks Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +FqXJE0AH19kFgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 18:26:53 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id YOQpI00AH1/q9AAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 18:26:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=zx2c4.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0426BA1996; Mon, 27 Jul 2020 18:26:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729948AbgG0Q0j (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 12:26:39 -0400 Received: from mail.zx2c4.com ([192.95.5.64]:33953 "EHLO mail.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728398AbgG0Q0h (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 12:26:37 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 5699ce70; Mon, 27 Jul 2020 16:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=sL2Z6xHv+s9MbkLOrzrOQhZ0af0=; b=LPJ9Zm YaVP8dj/BNE/oIXgMWXiR9QsHqFZvwCmHPKj+CmUXFfwgS5UAfubyxSnjCOeB3lH +Bwl3c/LXHT8AL+CVDzRG2OK1cEcjnn6j5K88A3sTuzlJ1dUUjpVk7flYaQ4QGix Ecxfzo8V4C3PxkkFXeejI0nZXIneDreaOSL3OidJycl2/vpcTM+O2E6XDAeWvr3E tB8pcRvqEps3l/ljGAs19y1wXHZ7w+rG2v1ljZBPNElpYUKnkx/tuqhwCYKGaRY5 Bbz1DI7O2FDM7F1t3/7RwKiXc55u/gnkaJERPhZq+gFkn2OnNwRWbrI7HXF8tJm3 qsI9245bR4dyy8nw== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 40084fe1 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 27 Jul 2020 16:03:14 +0000 (UTC) Received: by mail-io1-xd32.google.com with SMTP id l1so17561135ioh.5; Mon, 27 Jul 2020 09:26:33 -0700 (PDT) X-Gm-Message-State: AOAM53044uf8Ct5bu+iCXpyL1Q3s2ZbWvgQfnnBJh4HPwu7P7eKiMLHl WLLXTQVAwgqKyAkb6O+01EdlKR8Kz7IMUoEaY0Q= X-Google-Smtp-Source: ABdhPJzHnH4n8LVUhc9laLi7Gjj4KPIYdTCtAFjGI/NzItWJYWKwmRT1E1P7HjXOfS7ZwU4o5uqkgWm85XGW2/o5gRY= X-Received: by 2002:a05:6638:1027:: with SMTP id n7mr14068670jan.86.1595866892746; Mon, 27 Jul 2020 09:21:32 -0700 (PDT) MIME-Version: 1.0 References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-13-hch@lst.de> <20200727150310.GA1632472@zx2c4.com> <20200727161615.GB7817@lst.de> In-Reply-To: <20200727161615.GB7817@lst.de> From: "Jason A. Donenfeld" <Jason@zx2c4.com> Date: Mon, 27 Jul 2020 18:21:21 +0200 X-Gmail-Original-Message-ID: <CAHmME9oU9+5Pbm6pUkOqaxQyYLr9JhAkwV55+P7AWR601WW-nA@mail.gmail.com> Message-ID: <CAHmME9oU9+5Pbm6pUkOqaxQyYLr9JhAkwV55+P7AWR601WW-nA@mail.gmail.com> Subject: Re: [PATCH 12/26] netfilter: switch nf_setsockopt to sockptr_t To: Christoph Hellwig <hch@lst.de> Cc: "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, Linux Crypto Mailing List <linux-crypto@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Netdev <netdev@vger.kernel.org>, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0426BA1996 X-Rspamd-UID: 022c3b > From cce2d2e1b43ecee5f4af7cf116808b74b330080f Mon Sep 17 00:00:00 2001 > From: Christoph Hellwig <hch@lst.de> > Date: Mon, 27 Jul 2020 17:42:27 +0200 > Subject: net: remove sockptr_advance > > sockptr_advance never properly worked. Replace it with _offset variants > of copy_from_sockptr and copy_to_sockptr. > > Fixes: ba423fdaa589 ("net: add a new sockptr_t type") > Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> > Reported-by: Ido Schimmel <idosch@idosch.org> > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > drivers/crypto/chelsio/chtls/chtls_main.c | 12 +++++----- > include/linux/sockptr.h | 27 +++++++++++------------ > net/dccp/proto.c | 5 ++--- > net/ipv4/netfilter/arp_tables.c | 8 +++---- > net/ipv4/netfilter/ip_tables.c | 8 +++---- > net/ipv4/tcp.c | 5 +++-- > net/ipv6/ip6_flowlabel.c | 11 ++++----- > net/ipv6/netfilter/ip6_tables.c | 8 +++---- > net/netfilter/x_tables.c | 7 +++--- > net/tls/tls_main.c | 6 ++--- > 10 files changed, 49 insertions(+), 48 deletions(-) > > diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c b/drivers/crypto/chelsio/chtls/chtls_main.c > index c3058dcdb33c5c..66d247efd5615b 100644 > --- a/drivers/crypto/chelsio/chtls/chtls_main.c > +++ b/drivers/crypto/chelsio/chtls/chtls_main.c > @@ -525,9 +525,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, > /* Obtain version and type from previous copy */ > crypto_info[0] = tmp_crypto_info; > /* Now copy the following data */ > - sockptr_advance(optval, sizeof(*crypto_info)); > - rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), > - optval, > + rc = copy_from_sockptr_offset((char *)crypto_info + > + sizeof(*crypto_info), > + optval, sizeof(*crypto_info), > sizeof(struct tls12_crypto_info_aes_gcm_128) > - sizeof(*crypto_info)); > > @@ -542,9 +542,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, > } > case TLS_CIPHER_AES_GCM_256: { > crypto_info[0] = tmp_crypto_info; > - sockptr_advance(optval, sizeof(*crypto_info)); > - rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), > - optval, > + rc = copy_from_sockptr_offset((char *)crypto_info + > + sizeof(*crypto_info), > + optval, sizeof(*crypto_info), > sizeof(struct tls12_crypto_info_aes_gcm_256) > - sizeof(*crypto_info)); > > diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h > index b13ea1422f93a5..9e6c81d474cba8 100644 > --- a/include/linux/sockptr.h > +++ b/include/linux/sockptr.h > @@ -69,19 +69,26 @@ static inline bool sockptr_is_null(sockptr_t sockptr) > return !sockptr.user; > } > > -static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) > +static inline int copy_from_sockptr_offset(void *dst, sockptr_t src, > + size_t offset, size_t size) > { > if (!sockptr_is_kernel(src)) > - return copy_from_user(dst, src.user, size); > - memcpy(dst, src.kernel, size); > + return copy_from_user(dst, src.user + offset, size); > + memcpy(dst, src.kernel + offset, size); > return 0; > } > > -static inline int copy_to_sockptr(sockptr_t dst, const void *src, size_t size) > +static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) > +{ > + return copy_from_sockptr_offset(dst, src, 0, size); > +} > + > +static inline int copy_to_sockptr_offset(sockptr_t dst, size_t offset, > + const void *src, size_t size) > { > if (!sockptr_is_kernel(dst)) > - return copy_to_user(dst.user, src, size); > - memcpy(dst.kernel, src, size); > + return copy_to_user(dst.user + offset, src, size); > + memcpy(dst.kernel + offset, src, size); > return 0; > } > > @@ -112,14 +119,6 @@ static inline void *memdup_sockptr_nul(sockptr_t src, size_t len) > return p; > } > > -static inline void sockptr_advance(sockptr_t sockptr, size_t len) > -{ > - if (sockptr_is_kernel(sockptr)) > - sockptr.kernel += len; > - else > - sockptr.user += len; > -} > - > static inline long strncpy_from_sockptr(char *dst, sockptr_t src, size_t count) > { > if (sockptr_is_kernel(src)) { > diff --git a/net/dccp/proto.c b/net/dccp/proto.c > index 2e9e8449698fb4..d148ab1530e57b 100644 > --- a/net/dccp/proto.c > +++ b/net/dccp/proto.c > @@ -426,9 +426,8 @@ static int dccp_setsockopt_service(struct sock *sk, const __be32 service, > return -ENOMEM; > > sl->dccpsl_nr = optlen / sizeof(u32) - 1; > - sockptr_advance(optval, sizeof(service)); > - if (copy_from_sockptr(sl->dccpsl_list, optval, > - optlen - sizeof(service)) || > + if (copy_from_sockptr_offset(sl->dccpsl_list, optval, > + sizeof(service), optlen - sizeof(service)) || > dccp_list_has_service(sl, DCCP_SERVICE_INVALID_VALUE)) { > kfree(sl); > return -EFAULT; > diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c > index 9a1567dbc022b6..d1e04d2b5170ec 100644 > --- a/net/ipv4/netfilter/arp_tables.c > +++ b/net/ipv4/netfilter/arp_tables.c > @@ -971,8 +971,8 @@ static int do_replace(struct net *net, sockptr_t arg, unsigned int len) > return -ENOMEM; > > loc_cpu_entry = newinfo->entries; > - sockptr_advance(arg, sizeof(tmp)); > - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { > + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), > + tmp.size) != 0) { > ret = -EFAULT; > goto free_newinfo; > } > @@ -1267,8 +1267,8 @@ static int compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) > return -ENOMEM; > > loc_cpu_entry = newinfo->entries; > - sockptr_advance(arg, sizeof(tmp)); > - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { > + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), > + tmp.size) != 0) { > ret = -EFAULT; > goto free_newinfo; > } > diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c > index f2a9680303d8c0..f15bc21d730164 100644 > --- a/net/ipv4/netfilter/ip_tables.c > +++ b/net/ipv4/netfilter/ip_tables.c > @@ -1126,8 +1126,8 @@ do_replace(struct net *net, sockptr_t arg, unsigned int len) > return -ENOMEM; > > loc_cpu_entry = newinfo->entries; > - sockptr_advance(arg, sizeof(tmp)); > - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { > + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), > + tmp.size) != 0) { > ret = -EFAULT; > goto free_newinfo; > } > @@ -1508,8 +1508,8 @@ compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) > return -ENOMEM; > > loc_cpu_entry = newinfo->entries; > - sockptr_advance(arg, sizeof(tmp)); > - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { > + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), > + tmp.size) != 0) { > ret = -EFAULT; > goto free_newinfo; > } > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c > index 27de9380ed140e..4afec552f211b9 100644 > --- a/net/ipv4/tcp.c > +++ b/net/ipv4/tcp.c > @@ -2801,12 +2801,13 @@ static int tcp_repair_options_est(struct sock *sk, sockptr_t optbuf, > { > struct tcp_sock *tp = tcp_sk(sk); > struct tcp_repair_opt opt; > + size_t offset = 0; > > while (len >= sizeof(opt)) { > - if (copy_from_sockptr(&opt, optbuf, sizeof(opt))) > + if (copy_from_sockptr_offset(&opt, optbuf, offset, sizeof(opt))) > return -EFAULT; > > - sockptr_advance(optbuf, sizeof(opt)); > + offset += sizeof(opt); > len -= sizeof(opt); > > switch (opt.opt_code) { > diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c > index 215b6f5e733ec9..2d655260dedc75 100644 > --- a/net/ipv6/ip6_flowlabel.c > +++ b/net/ipv6/ip6_flowlabel.c > @@ -401,8 +401,8 @@ fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, > memset(fl->opt, 0, sizeof(*fl->opt)); > fl->opt->tot_len = sizeof(*fl->opt) + olen; > err = -EFAULT; > - sockptr_advance(optval, CMSG_ALIGN(sizeof(*freq))); > - if (copy_from_sockptr(fl->opt + 1, optval, olen)) > + if (copy_from_sockptr_offset(fl->opt + 1, optval, > + CMSG_ALIGN(sizeof(*freq)), olen)) > goto done; > > msg.msg_controllen = olen; > @@ -703,9 +703,10 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, > goto recheck; > > if (!freq->flr_label) { > - sockptr_advance(optval, > - offsetof(struct in6_flowlabel_req, flr_label)); > - if (copy_to_sockptr(optval, &fl->label, sizeof(fl->label))) { > + size_t offset = offsetof(struct in6_flowlabel_req, flr_label); > + > + if (copy_to_sockptr_offset(optval, offset, &fl->label, > + sizeof(fl->label))) { > /* Intentionally ignore fault. */ > } > } > diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c > index 1d52957a413f4a..2e2119bfcf1373 100644 > --- a/net/ipv6/netfilter/ip6_tables.c > +++ b/net/ipv6/netfilter/ip6_tables.c > @@ -1143,8 +1143,8 @@ do_replace(struct net *net, sockptr_t arg, unsigned int len) > return -ENOMEM; > > loc_cpu_entry = newinfo->entries; > - sockptr_advance(arg, sizeof(tmp)); > - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { > + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), > + tmp.size) != 0) { > ret = -EFAULT; > goto free_newinfo; > } > @@ -1517,8 +1517,8 @@ compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) > return -ENOMEM; > > loc_cpu_entry = newinfo->entries; > - sockptr_advance(arg, sizeof(tmp)); > - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { > + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), > + tmp.size) != 0) { > ret = -EFAULT; > goto free_newinfo; > } > diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c > index b97eb4b538fd4e..91bf6635ea9ee4 100644 > --- a/net/netfilter/x_tables.c > +++ b/net/netfilter/x_tables.c > @@ -1050,6 +1050,7 @@ EXPORT_SYMBOL_GPL(xt_check_target); > void *xt_copy_counters(sockptr_t arg, unsigned int len, > struct xt_counters_info *info) > { > + size_t offset; > void *mem; > u64 size; > > @@ -1067,7 +1068,7 @@ void *xt_copy_counters(sockptr_t arg, unsigned int len, > > memcpy(info->name, compat_tmp.name, sizeof(info->name) - 1); > info->num_counters = compat_tmp.num_counters; > - sockptr_advance(arg, sizeof(compat_tmp)); > + offset = sizeof(compat_tmp); > } else > #endif > { > @@ -1078,7 +1079,7 @@ void *xt_copy_counters(sockptr_t arg, unsigned int len, > if (copy_from_sockptr(info, arg, sizeof(*info)) != 0) > return ERR_PTR(-EFAULT); > > - sockptr_advance(arg, sizeof(*info)); > + offset = sizeof(*info); > } > info->name[sizeof(info->name) - 1] = '\0'; > > @@ -1092,7 +1093,7 @@ void *xt_copy_counters(sockptr_t arg, unsigned int len, > if (!mem) > return ERR_PTR(-ENOMEM); > > - if (copy_from_sockptr(mem, arg, len) == 0) > + if (copy_from_sockptr_offset(mem, arg, offset, len) == 0) > return mem; > > vfree(mem); > diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c > index d77f7d821130db..bbc52b088d2968 100644 > --- a/net/tls/tls_main.c > +++ b/net/tls/tls_main.c > @@ -522,9 +522,9 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval, > goto err_crypto_info; > } > > - sockptr_advance(optval, sizeof(*crypto_info)); > - rc = copy_from_sockptr(crypto_info + 1, optval, > - optlen - sizeof(*crypto_info)); > + rc = copy_from_sockptr_offset(crypto_info + 1, optval, > + sizeof(*crypto_info), > + optlen - sizeof(*crypto_info)); > if (rc) { > rc = -EFAULT; > goto err_crypto_info; > -- > 2.27.0 Getting rid of sockptr_advance entirely seems like the right decision here. You still might want to make sure the addition in copy_from_sockptr_offset doesn't overflow, and return -EFAULT if it does. But this indeed fixes the bug, so: Acked-by: Jason A. Donenfeld <Jason@zx2c4.com> Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oC6RIukQH1+rhQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 19:37:45 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 0BocIekQH18PjQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 19:37:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 019F6418A1; Mon, 27 Jul 2020 19:37:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731422AbgG0Rh2 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 13:37:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726897AbgG0Rh0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 13:37:26 -0400 Received: from mail-ua1-x944.google.com (mail-ua1-x944.google.com [IPv6:2607:f8b0:4864:20::944]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A69AC061794 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 10:37:26 -0700 (PDT) Received: by mail-ua1-x944.google.com with SMTP id p27so1415683uaa.12 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 10:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KqTJWlghm8hbSrvYH/wSR/fzYgdbbuaChV5qjhwMteM=; b=b0rAu1U014sI2AO2VeWvQFnUBn6TnTZR3eBNUHZyWLUcznS+S+K7K+3jS0vxB0zM0m +5DstfFBT1WJWQ3Fae6TqfmQZyfjyEA4Tx3Rw+LDAgAoqXr6Cn8DAca7WLPxn3TCETDD f+jaEmN0isWObVLBp0l4GfrGM43cZMqDYAQEM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KqTJWlghm8hbSrvYH/wSR/fzYgdbbuaChV5qjhwMteM=; b=tu+0PcRD9qTpD/FvszByx55bX4UYZW71QiGpMLC1nePW/ocRHnH3tQ2PvXvCtwAjQR TGjfYz3bWzDMXII3jedpjC1mXhyGwbJO9wKetBVJYwyYc/11nXjeu3y0LoUWrUv76hKH Z+eY1K7tnKNVjHMdirjp95WR7l1Mnu3smMzpE0S58zbjE0mrmDDWVT9ntGI742c8Xkgk 6RsUbWU0L2t0bLtSVAf4T8jUz+STMzD9s0+tWBkUrN0GskXb3AWcEr6alFuo0LiwxLju iCmEGR84sk0yfK9DrZ0HUDR+HhLNuAMGfBXJKLyr63xTL7uS3rSsf6tc7A7sq5VqVmKP qL7Q== X-Gm-Message-State: AOAM532zHvl9sL9PNGw62FcRFE7cnDoz3DgN692VB4XKfWUGMAJa/IKc RcVy9OCbEZPMwJBGdIe3GYgCV/cgmt4= X-Google-Smtp-Source: ABdhPJwNcP00H7/7LJ6F8gCbYxeN7Xw4B2GCZ9W17fXO7hnMKOXzKgnX/6JNbZep6QdaxLE1nG9/+Q== X-Received: by 2002:ab0:1846:: with SMTP id j6mr7090989uag.130.1595871444718; Mon, 27 Jul 2020 10:37:24 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id s25sm2870871vsj.13.2020.07.27.10.37.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 10:37:23 -0700 (PDT) From: Alain Michaud <alainm@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud <alainm@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Subject: [Bluez PATCH] main: adding configurable eir_max_name_len Date: Mon, 27 Jul 2020 17:37:20 +0000 Message-Id: <20200727173720.2700327-1-alainm@chromium.org> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 019F6418A1 X-Rspamd-UID: 7ab32f This change adds support for a configurable eir_max_name_len for platforms which requires a larger than 48 bytes complete name in EIR. From bluetoothctl: [bluetooth]# system-alias 012345678901234567890123456789012345678901234567890123456789 Changing 012345678901234567890123456789012345678901234567890123456789 succeeded [CHG] Controller DC:71:96:69:02:89 Alias: 012345678901234567890123456789012345678901234567890123456789 From btmon: < HCI Command: Write Local Name (0x03|0x0013) plen 248             #109 [hci0] 88.567990         Name: 012345678901234567890123456789012345678901234567890123456789 > HCI Event: Command Complete (0x0e) plen 4                                 #110 [hci0] 88.663854       Write Local Name (0x03|0x0013) ncmd 1         Status: Success (0x00) @ MGMT Event: Local Name Changed (0x0008) plen 260                {0x0004} [hci0] 88.663948         Name: 012345678901234567890123456789012345678901234567890123456789         Short name: < HCI Command: Write Extended Inquiry Response (0x03|0x0052) plen 241          FEC: Not required (0x00)         Name (complete): 012345678901234567890123456789012345678901234567890123456789         TX power: 12 dBm         Device ID: Bluetooth SIG assigned (0x0001)           Vendor: Google (224)           Product: 0xc405           Version: 0.5.6 (0x0056)         16-bit Service UUIDs (complete): 7 entries           Generic Access Profile (0x1800)           Generic Attribute Profile (0x1801)           Device Information (0x180a)           A/V Remote Control (0x110e)           A/V Remote Control Target (0x110c)           Handsfree Audio Gateway (0x111f)           Audio Source (0x110a) > HCI Event: Command Complete (0x0e) plen 4                                  Write Extended Inquiry Response (0x03|0x0052) ncmd 1         Status: Success (0x00) Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Alain Michaud <alainm@chromium.org> --- doc/mgmt-api.txt | 1 + src/adapter.c | 10 +++++++++- src/hcid.h | 1 + src/main.c | 5 +++++ src/main.conf | 5 +++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index ca0d38469..1bc0f0c12 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -3279,6 +3279,7 @@ Read Default System Configuration Command 0x0019 LE Connection Latency 0x001a LE Connection Supervision Timeout 0x001b LE Autoconnect Timeout + 0x001c Max EIR Name Length This command can be used at any time and will return a list of supported default parameters as well as their current value. diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..3adc67b63 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2375,7 +2375,7 @@ static bool parse_pathloss(DBusMessageIter *value, return true; } -static bool parse_transport(DBusMessageIter *value, +static bool parse_transport(DBusMessageIter *value, struct discovery_filter *filter) { char *transport_str; @@ -4435,6 +4435,14 @@ static void load_default_system_params(struct btd_adapter *adapter) len += sizeof(params[i].u16); } + if (main_opts.default_params.eir_max_name_len) { + params[i].entry.type = 0x001c; + params[i].entry.length = sizeof(params[i].u16); + params[i].u16 = main_opts.default_params.eir_max_name_len; + ++i; + len += sizeof(params[i].u16); + } + err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG, adapter->dev_id, len, params, NULL, NULL, NULL); if (!err) diff --git a/src/hcid.h b/src/hcid.h index 5f249ebf9..c9b59a374 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -93,6 +93,7 @@ struct main_opts { uint16_t le_conn_latency; uint16_t le_conn_lsto; uint16_t le_autoconnect_timeout; + uint16_t eir_max_name_len; } default_params; diff --git a/src/main.c b/src/main.c index ec7a9fbd7..74876e01d 100644 --- a/src/main.c +++ b/src/main.c @@ -123,6 +123,7 @@ static const char *controller_options[] = { "LEConnectionLatency", "LEConnectionSupervisionTimeout", "LEAutoconnecttimeout", + "EirMaxNameLength", NULL }; @@ -433,6 +434,10 @@ static void parse_controller_config(GKeyFile *config) &main_opts.default_params.le_autoconnect_timeout, 0x0001, 0x4000}, + { "EirMaxNameLength", + &main_opts.default_params.eir_max_name_len, + 0x0001, + 0x00EE}, }; uint16_t i; diff --git a/src/main.conf b/src/main.conf index f41203b96..7ecac5930 100644 --- a/src/main.conf +++ b/src/main.conf @@ -148,6 +148,11 @@ #LEConnectionSupervisionTimeout= #LEAutoconnecttimeout= +# EIR Max Name. This is the maximum length for the COMPLETE_NAME EIR section. +# If the name length exceeds this size, a SHORT_NAME section is used. +# Default: 48 +#EirMaxNameLength = 48 + [GATT] # GATT attribute cache. # Possible values: -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AOvxNi0TH19zvgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 19:47:25 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WNsZNS0TH19iWwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 19:47:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1F345A2B76; Mon, 27 Jul 2020 19:47:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728552AbgG0RrN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 13:47:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728173AbgG0RrN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 13:47:13 -0400 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCBDBC061794 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 10:47:12 -0700 (PDT) Received: by mail-vs1-xe42.google.com with SMTP id k7so8772130vso.2 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 10:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5lJtU6tIb4qc05hk/HqBeTb40P07YFQMzDtjotddUIA=; b=W4Z+QvcZK8hVtozQVJVEeUUeIWZkYzFafoprj907pyEgUutRDX0+OuEA5sx9Qbyckb GKd02jdXaaYlPDpIkqrjYqNI2BUULcIrFw0GrrYQ/kurt0k6Ir99ObZdBZyWrvURxG18 T1oxG300Uji2O1fiMqbrh55rWaFHPRjawUdos= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5lJtU6tIb4qc05hk/HqBeTb40P07YFQMzDtjotddUIA=; b=ldugNwyZsxEQt6ZjPB2LfWzPuvpxJcB7yZ1L7Zu02sp+qPWh6Dw2RSr+oIAnEM6Pop JtfzV6qgJMOcbC++OqTK/crgsg2qMbgP14lhqSQ+TYGACeeACDvwWTD4cx9Bb0F3UFfL +rrv8d5u4YZhMdi5qX2VrFQ5xC7LHB4Igeyh4cMEXAKfOTLdBnFoH9PHOfXZPSsnlQi8 mwUEnKgN1vSxa6DW3AY2ckMSMExGFhgb6F9DAoB1x49tbHIwplS139Py5mFWkIUx+u3s lO7Lix6w0kymT98mZ1bHw6v0nBR5DhiapJfBEmZPrJlUa/zI0sNXRXU770frJWlkBvgj ng1Q== X-Gm-Message-State: AOAM530ArNuY7j2wrPP4y42krxn95lw8er23CR4Bj6rqUOZqGFVCnuVk nLesHIS1wSeNaZF3TE77JhXD25LVbss= X-Google-Smtp-Source: ABdhPJwK0d1+XgQY8hRAD76G1ZgOzJlMDXUSF/CexIuzCaKYqPRUEQ8Bxgf49m4MMMxZ7o+IGFEMhQ== X-Received: by 2002:a67:f3cd:: with SMTP id j13mr17583373vsn.40.1595872031459; Mon, 27 Jul 2020 10:47:11 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id t67sm2718040vkd.38.2020.07.27.10.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 10:47:10 -0700 (PDT) From: Alain Michaud <alainm@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud <alainm@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [PATCH] Bluetooth: adding configurable eir_max_name_len Date: Mon, 27 Jul 2020 17:47:05 +0000 Message-Id: <20200727174641.1.Ic2cb84fb029a345c9e3901378717d1ab4e9246ab@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1F345A2B76 X-Rspamd-UID: 89b882 This change adds support for a configurable eir_max_name_len for platforms which requires a larger than 48 bytes complete name in EIR. From bluetoothctl: [bluetooth]# system-alias 012345678901234567890123456789012345678901234567890123456789 Changing 012345678901234567890123456789012345678901234567890123456789 succeeded [CHG] Controller DC:71:96:69:02:89 Alias: 012345678901234567890123456789012345678901234567890123456789 From btmon: < HCI Command: Write Local Name (0x03|0x0013) plen 248     #109 [hci0] 88.567990         Name: 012345678901234567890123456789012345678901234567890123456789 > HCI Event: Command Complete (0x0e) plen 4  #110 [hci0] 88.663854       Write Local Name (0x03|0x0013) ncmd 1         Status: Success (0x00) @ MGMT Event: Local Name Changed (0x0008) plen 260                {0x0004} [hci0] 88.663948         Name: 012345678901234567890123456789012345678901234567890123456789         Short name: < HCI Command: Write Extended Inquiry Response (0x03|0x0052) plen 241 #111 [hci0] 88.663977         FEC: Not required (0x00)         Name (complete): 012345678901234567890123456789012345678901234567890123456789         TX power: 12 dBm         Device ID: Bluetooth SIG assigned (0x0001)           Vendor: Google (224)           Product: 0xc405           Version: 0.5.6 (0x0056)         16-bit Service UUIDs (complete): 7 entries           Generic Access Profile (0x1800)           Generic Attribute Profile (0x1801)           Device Information (0x180a)           A/V Remote Control (0x110e)           A/V Remote Control Target (0x110c)           Handsfree Audio Gateway (0x111f)           Audio Source (0x110a) > HCI Event: Command Complete (0x0e) plen 4 #112 [hci0] 88.664874       Write Extended Inquiry Response (0x03|0x0052) ncmd 1         Status: Success (0x00) Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Signed-off-by: Alain Michaud <alainm@chromium.org> --- include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 1 + net/bluetooth/hci_request.c | 29 +++++++++++++++++++++-------- net/bluetooth/mgmt_config.c | 5 +++++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index bee1b4778ccc..e08f92e7a9ca 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -298,6 +298,7 @@ struct hci_dev { __u8 dev_name[HCI_MAX_NAME_LENGTH]; __u8 short_name[HCI_MAX_SHORT_NAME_LENGTH]; __u8 eir[HCI_MAX_EIR_LENGTH]; + __u16 eir_max_name_len; __u16 appearance; __u8 dev_class[3]; __u8 major_class; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6509f785dd14..b2507bd6613a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3536,6 +3536,7 @@ struct hci_dev *hci_alloc_dev(void) hdev->adv_instance_cnt = 0; hdev->cur_adv_instance = 0x00; hdev->adv_instance_timeout = 0; + hdev->eir_max_name_len = 48; hdev->sniff_max_interval = 800; hdev->sniff_min_interval = 80; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 7c0c2fda04ad..f4714370b7e7 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -578,17 +578,21 @@ static u8 *create_uuid128_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len) static void create_eir(struct hci_dev *hdev, u8 *data) { u8 *ptr = data; + u8 size_remaining = HCI_MAX_EIR_LENGTH; size_t name_len; name_len = strlen(hdev->dev_name); if (name_len > 0) { /* EIR Data type */ - if (name_len > 48) { - name_len = 48; + if (name_len > min_t(u16, (HCI_MAX_EIR_LENGTH - 2), + hdev->eir_max_name_len)) { + name_len = min_t(u16, (HCI_MAX_EIR_LENGTH - 2), + hdev->eir_max_name_len); ptr[1] = EIR_NAME_SHORT; - } else + } else { ptr[1] = EIR_NAME_COMPLETE; + } /* EIR Data length */ ptr[0] = name_len + 1; @@ -596,17 +600,21 @@ static void create_eir(struct hci_dev *hdev, u8 *data) memcpy(ptr + 2, hdev->dev_name, name_len); ptr += (name_len + 2); + size_remaining -= (name_len + 2); } - if (hdev->inq_tx_power != HCI_TX_POWER_INVALID) { + if (hdev->inq_tx_power != HCI_TX_POWER_INVALID && + size_remaining >= 3) { ptr[0] = 2; ptr[1] = EIR_TX_POWER; ptr[2] = (u8) hdev->inq_tx_power; ptr += 3; + size_remaining -= 3; } - if (hdev->devid_source > 0) { + if (hdev->devid_source > 0 && + size_remaining >= 10) { ptr[0] = 9; ptr[1] = EIR_DEVICE_ID; @@ -616,11 +624,16 @@ static void create_eir(struct hci_dev *hdev, u8 *data) put_unaligned_le16(hdev->devid_version, ptr + 8); ptr += 10; + size_remaining -= 10; } - ptr = create_uuid16_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data)); - ptr = create_uuid32_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data)); - ptr = create_uuid128_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data)); + ptr = create_uuid16_list(hdev, ptr, size_remaining); + size_remaining = HCI_MAX_EIR_LENGTH - (ptr - data); + + ptr = create_uuid32_list(hdev, ptr, size_remaining); + size_remaining = HCI_MAX_EIR_LENGTH - (ptr - data); + + ptr = create_uuid128_list(hdev, ptr, size_remaining); } void __hci_req_update_eir(struct hci_request *req) diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index b30b571f8caf..420ea322a5b7 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -67,6 +67,7 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, HDEV_PARAM_U16(0x001a, le_supv_timeout), HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b, def_le_autoconnect_timeout), + HDEV_PARAM_U16(0x001c, eir_max_name_len), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -138,6 +139,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x0019: case 0x001a: case 0x001b: + case 0x001c: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -251,6 +253,9 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, hdev->def_le_autoconnect_timeout = msecs_to_jiffies(TLV_GET_LE16(buffer)); break; + case 0x0001c: + hdev->eir_max_name_len = TLV_GET_LE16(buffer); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8J2kNs/YHl+OSQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 15:38:23 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id cISPNc/YHl9JQAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 15:38:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AE87C41750; Mon, 27 Jul 2020 15:38:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727067AbgG0NiP (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 09:38:15 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:42994 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726298AbgG0NiO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 09:38:14 -0400 Received: by mail-ot1-f68.google.com with SMTP id v21so5038867otj.9; Mon, 27 Jul 2020 06:38:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GDgvxbFtjoqaUGPEDtkInSIpJVJqkW3IcV+Wtsu5ITc=; b=jhprwpJIoQNfyotKw7z1LMzWKpQo7AV2X/QKY3t2H76Hwhu7eN/1HnzYjb2qh0HDI4 CplFkvXn/D3yoviIItBgSxzuAmpst3iBWRHn6zp0WsOVFbvBnXCkpvt4oqP5Vb8LqFnl NQSkw33fARMF841U/77bLsva5Yom0l/k01jZPZPyPQ/T11Cn5s05mYcuoB2faXzUDyPd eIMLFblkpv2PWkmoMarPoJrGoj/Md1oAtrMCx5lxktzoG3wMItCwW4TkFQ7FKdk4wWPI ijV0lWpKg/wzFSCWjj9DPla0Y5ypTH1dbwxubJUYASwrTNHFQbmAwePk9PmOeGvhZfok lmAA== X-Gm-Message-State: AOAM5329GVgf1plMyji0Aph1G7BKFPeOmoxxUSeevX50toVbMWXTXEm5 Ms5rvLHWvDFB3XCPmzl4w8xXD6iqxbdsSIie1Ys= X-Google-Smtp-Source: ABdhPJy3txxI99b+fWzbhQVo+HWM4RYjrP2BIU1Ci2RDTj9GPs21eK4gnxtDjDTfKgLqwvw2gVDmbZ5VIuYYJXomKTc= X-Received: by 2002:a05:6830:1e5c:: with SMTP id e28mr2285084otj.118.1595857093698; Mon, 27 Jul 2020 06:38:13 -0700 (PDT) MIME-Version: 1.0 References: <20200707172845.4177903-1-abhishekpandit@chromium.org> <20200707102823.v5.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> <20200723183235.GA3445384@kroah.com> In-Reply-To: <20200723183235.GA3445384@kroah.com> From: "Rafael J. Wysocki" <rafael@kernel.org> Date: Mon, 27 Jul 2020 15:38:02 +0200 Message-ID: <CAJZ5v0jXcfO3YiMgkc7u=qqZy+jyT=RGagF3yAFnAhiJfyfcuQ@mail.gmail.com> Subject: Re: [PATCH v5 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Rafael Wysocki <rafael.j.wysocki@intel.com>, Linux PM <linux-pm@vger.kernel.org>, "open list:BLUETOOTH DRIVERS" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Stephen Boyd <swboyd@chromium.org>, "Rafael J. Wysocki" <rjw@rjwysocki.net>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: AE87C41750 X-Rspamd-UID: 9351b2 On Thu, Jul 23, 2020 at 8:32 PM Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote: > > On Tue, Jul 07, 2020 at 10:28:44AM -0700, Abhishek Pandit-Subedi wrote: > > Udev rules that depend on the power/wakeup attribute don't get triggered > > correctly if device_set_wakeup_capable is called after the device is > > created. This can happen for several reasons (driver sets wakeup after > > device is created, wakeup is changed on parent device, etc) and it seems > > reasonable to emit a changed event when adding or removing attributes on > > the device. > > > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > Rafael, any objection to this? Do you want me to take it through my > tree, or are you going to take it through yours? Either is fine for me. It's already there in my tree with the R-by tag from you. Cheers! Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ADybI1/bHl99ZgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 15:49:19 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id eMdIIl/bHl8wNQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 15:49:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2EA9A4178E; Mon, 27 Jul 2020 15:49:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729165AbgG0NtN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 09:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729032AbgG0NtM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 09:49:12 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BDD9C0619D2; Mon, 27 Jul 2020 06:49:12 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1k03UE-003g0B-15; Mon, 27 Jul 2020 13:48:14 +0000 Date: Mon, 27 Jul 2020 14:48:14 +0100 From: Al Viro <viro@zeniv.linux.org.uk> To: David Laight <David.Laight@aculab.com> Cc: 'David Miller' <davem@davemloft.net>, "hch@lst.de" <hch@lst.de>, "kuba@kernel.org" <kuba@kernel.org>, "ast@kernel.org" <ast@kernel.org>, "daniel@iogearbox.net" <daniel@iogearbox.net>, "kuznet@ms2.inr.ac.ru" <kuznet@ms2.inr.ac.ru>, "yoshfuji@linux-ipv6.org" <yoshfuji@linux-ipv6.org>, "edumazet@google.com" <edumazet@google.com>, "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "bpf@vger.kernel.org" <bpf@vger.kernel.org>, "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>, "coreteam@netfilter.org" <coreteam@netfilter.org>, "linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>, "linux-hams@vger.kernel.org" <linux-hams@vger.kernel.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "bridge@lists.linux-foundation.org" <bridge@lists.linux-foundation.org>, "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>, "dccp@vger.kernel.org" <dccp@vger.kernel.org>, "linux-decnet-user@lists.sourceforge.net" <linux-decnet-user@lists.sourceforge.net>, "linux-wpan@vger.kernel.org" <linux-wpan@vger.kernel.org>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, "mptcp@lists.01.org" <mptcp@lists.01.org>, "lvs-devel@vger.kernel.org" <lvs-devel@vger.kernel.org>, "rds-devel@oss.oracle.com" <rds-devel@oss.oracle.com>, "linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>, "tipc-discussion@lists.sourceforge.net" <tipc-discussion@lists.sourceforge.net>, "linux-x25@vger.kernel.org" <linux-x25@vger.kernel.org> Subject: Re: get rid of the address_space override in setsockopt v2 Message-ID: <20200727134814.GD794331@ZenIV.linux.org.uk> References: <20200723060908.50081-1-hch@lst.de> <20200724.154342.1433271593505001306.davem@davemloft.net> <8ae792c27f144d4bb5cbea0c1cce4eed@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8ae792c27f144d4bb5cbea0c1cce4eed@AcuMS.aculab.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.68 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2EA9A4178E X-Rspamd-UID: 864469 On Mon, Jul 27, 2020 at 09:51:45AM +0000, David Laight wrote: > I'm sure there is code that processes options in chunks. > This probably means it is possible to put a chunk boundary > at the end of userspace and continue processing the very start > of kernel memory. > > At best this faults on the kernel copy code and crashes the system. Really? Care to provide some details, or is it another of your "I can't be possibly arsed to check what I'm saying, but it stands for reason that..." specials? Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aMTkBy/3Hl+LtQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 17:47:59 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id cLB+Bi/3Hl94pQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 17:47:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6139B41873; Mon, 27 Jul 2020 17:47:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733031AbgG0OkS convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 10:40:18 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:31879 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729583AbgG0OJP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 10:09:15 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-250-GXr1mpTxOlmxyosLYcC-jw-1; Mon, 27 Jul 2020 15:09:11 +0100 X-MC-Unique: GXr1mpTxOlmxyosLYcC-jw-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 27 Jul 2020 15:09:10 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Mon, 27 Jul 2020 15:09:10 +0100 From: David Laight <David.Laight@ACULAB.COM> To: 'Al Viro' <viro@zeniv.linux.org.uk> CC: 'David Miller' <davem@davemloft.net>, "hch@lst.de" <hch@lst.de>, "kuba@kernel.org" <kuba@kernel.org>, "ast@kernel.org" <ast@kernel.org>, "daniel@iogearbox.net" <daniel@iogearbox.net>, "kuznet@ms2.inr.ac.ru" <kuznet@ms2.inr.ac.ru>, "yoshfuji@linux-ipv6.org" <yoshfuji@linux-ipv6.org>, "edumazet@google.com" <edumazet@google.com>, "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "bpf@vger.kernel.org" <bpf@vger.kernel.org>, "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>, "coreteam@netfilter.org" <coreteam@netfilter.org>, "linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>, "linux-hams@vger.kernel.org" <linux-hams@vger.kernel.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "bridge@lists.linux-foundation.org" <bridge@lists.linux-foundation.org>, "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>, "dccp@vger.kernel.org" <dccp@vger.kernel.org>, "linux-decnet-user@lists.sourceforge.net" <linux-decnet-user@lists.sourceforge.net>, "linux-wpan@vger.kernel.org" <linux-wpan@vger.kernel.org>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, "mptcp@lists.01.org" <mptcp@lists.01.org>, "lvs-devel@vger.kernel.org" <lvs-devel@vger.kernel.org>, "rds-devel@oss.oracle.com" <rds-devel@oss.oracle.com>, "linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>, "tipc-discussion@lists.sourceforge.net" <tipc-discussion@lists.sourceforge.net>, "linux-x25@vger.kernel.org" <linux-x25@vger.kernel.org> Subject: RE: get rid of the address_space override in setsockopt v2 Thread-Topic: get rid of the address_space override in setsockopt v2 Thread-Index: AQHWYgvqDt5Xt3HFu0u82UKLVqcKxKkbLTEQgAA3GQCAABNbQA== Date: Mon, 27 Jul 2020 14:09:09 +0000 Message-ID: <5d958e937db54849b4ef9046e7e12277@AcuMS.aculab.com> References: <20200723060908.50081-1-hch@lst.de> <20200724.154342.1433271593505001306.davem@davemloft.net> <8ae792c27f144d4bb5cbea0c1cce4eed@AcuMS.aculab.com> <20200727134814.GD794331@ZenIV.linux.org.uk> In-Reply-To: <20200727134814.GD794331@ZenIV.linux.org.uk> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.33 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6139B41873 X-Rspamd-UID: d78982 From: Al Viro > Sent: 27 July 2020 14:48 > > On Mon, Jul 27, 2020 at 09:51:45AM +0000, David Laight wrote: > > > I'm sure there is code that processes options in chunks. > > This probably means it is possible to put a chunk boundary > > at the end of userspace and continue processing the very start > > of kernel memory. > > > > At best this faults on the kernel copy code and crashes the system. > > Really? Care to provide some details, or is it another of your "I can't > be possibly arsed to check what I'm saying, but it stands for reason > that..." specials? I did more 'homework' than sometimes :-) Slightly difficult without a searchable net-next tree. However, as has been pointed out is a different thread this code is used to update IPv6 flow labels: > > - if (copy_from_user(fl->opt+1, optval+CMSG_ALIGN(sizeof(*freq)), olen)) > > + sockptr_advance(optval, CMSG_ALIGN(sizeof(*freq))); > > + if (copy_from_sockptr(fl->opt + 1, optval, olen)) > > goto done; and doesn't work because the advances are no longer cumulative. Now access_ok() has to take the base address and length to stop 'running into' kernel space, but the code above can advance from a valid user pointer (which won't fault) to a kernel address. If there were always an unmapped 'guard' page in the user address space the access_ok() check prior to copy_to/from_user() wouldn't need the length. So I surmise that no such guard page exists and so the above can advance from user addresses into kernel ones. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UFNlFfn5Hl+pIQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 17:59:53 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4MOEE/n5Hl+RqwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 17:59:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=zx2c4.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 88F9741763; Mon, 27 Jul 2020 17:59:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730246AbgG0PDW (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 11:03:22 -0400 Received: from mail.zx2c4.com ([192.95.5.64]:33657 "EHLO mail.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728933AbgG0PDV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 11:03:21 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 58010e7b; Mon, 27 Jul 2020 14:39:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=date:from:to :cc:subject:message-id:references:mime-version:content-type :in-reply-to; s=mail; bh=e4Ncj5PqOxuE3ONaroBLzrHpd+c=; b=Qoh5rxw E4ipK+7oF4FAXGvGyQT6VIu5cnzAaedp87/f4nZ24qqbi4r0S6rLuYQVbXudh+xO 99wZVZdEftTfV3U58Qyas4D20X9oLmF3+ZOrRcoZGGPBMtw/UBnS5mDFlX53nwQ3 4y+YK+0Lf0FJU2nN2lAvRlVBPPTMG6w4amUbqly/mlHgyL1B4Nf9kT64IIu53y9T u5hByM6CogNFuzrdCCHYLAOIub3eMmAcMs5HlyJpDmEpP3aYT0/5fhT9mzv6s3tJ e3sjwNkGyyDF3HX5B00L9mYUMASGIdL1UuQ+tbrvm+L6NQ0CP4GaybSPFSC1SlZS k03jp9ulXwzPOkw== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 6d99ea56 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 27 Jul 2020 14:39:58 +0000 (UTC) Date: Mon, 27 Jul 2020 17:03:10 +0200 From: "Jason A. Donenfeld" <Jason@zx2c4.com> To: Christoph Hellwig <hch@lst.de> Cc: "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 12/26] netfilter: switch nf_setsockopt to sockptr_t Message-ID: <20200727150310.GA1632472@zx2c4.com> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-13-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200723060908.50081-13-hch@lst.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 88F9741763 X-Rspamd-UID: 7a9340 Hi Christoph, On Thu, Jul 23, 2020 at 08:08:54AM +0200, Christoph Hellwig wrote: > diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c > index da933f99b5d517..42befbf12846c0 100644 > --- a/net/ipv4/ip_sockglue.c > +++ b/net/ipv4/ip_sockglue.c > @@ -1422,7 +1422,8 @@ int ip_setsockopt(struct sock *sk, int level, > optname != IP_IPSEC_POLICY && > optname != IP_XFRM_POLICY && > !ip_mroute_opt(optname)) > - err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); > + err = nf_setsockopt(sk, PF_INET, optname, USER_SOCKPTR(optval), > + optlen); > #endif > return err; > } > diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c > index 4697d09c98dc3e..f2a9680303d8c0 100644 > --- a/net/ipv4/netfilter/ip_tables.c > +++ b/net/ipv4/netfilter/ip_tables.c > @@ -1102,7 +1102,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks, > } > > static int > -do_replace(struct net *net, const void __user *user, unsigned int len) > +do_replace(struct net *net, sockptr_t arg, unsigned int len) > { > int ret; > struct ipt_replace tmp; > @@ -1110,7 +1110,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) > void *loc_cpu_entry; > struct ipt_entry *iter; > > - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) > + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) > return -EFAULT; > > /* overflow check */ > @@ -1126,8 +1126,8 @@ do_replace(struct net *net, const void __user *user, unsigned int len) > return -ENOMEM; > > loc_cpu_entry = newinfo->entries; > - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), > - tmp.size) != 0) { > + sockptr_advance(arg, sizeof(tmp)); > + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { > ret = -EFAULT; > goto free_newinfo; > } Something along this path seems to have broken with this patch. An invocation of `iptables -A INPUT -m length --length 1360 -j DROP` now fails, with nf_setsockopt->do_replace->translate_table->check_entry_size_and_hooks: (unsigned char *)e + e->next_offset > limit ==> TRUE resulting in the whole call chain returning -EINVAL. It bisects back to this commit. This is on net-next. Jason Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mKMOGkL6Hl9kFgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 18:01:06 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SO1/GEL6Hl9QPAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 18:01:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D7550418A9; Mon, 27 Jul 2020 18:01:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730683AbgG0PGK (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 11:06:10 -0400 Received: from verein.lst.de ([213.95.11.211]:44011 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729630AbgG0PGJ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 11:06:09 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 8445868B05; Mon, 27 Jul 2020 17:06:01 +0200 (CEST) Date: Mon, 27 Jul 2020 17:06:01 +0200 From: Christoph Hellwig <hch@lst.de> To: "Jason A. Donenfeld" <Jason@zx2c4.com> Cc: Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 12/26] netfilter: switch nf_setsockopt to sockptr_t Message-ID: <20200727150601.GA3447@lst.de> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-13-hch@lst.de> <20200727150310.GA1632472@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200727150310.GA1632472@zx2c4.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: D7550418A9 X-Rspamd-UID: 33eb32 On Mon, Jul 27, 2020 at 05:03:10PM +0200, Jason A. Donenfeld wrote: > Hi Christoph, > > On Thu, Jul 23, 2020 at 08:08:54AM +0200, Christoph Hellwig wrote: > > diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c > > index da933f99b5d517..42befbf12846c0 100644 > > --- a/net/ipv4/ip_sockglue.c > > +++ b/net/ipv4/ip_sockglue.c > > @@ -1422,7 +1422,8 @@ int ip_setsockopt(struct sock *sk, int level, > > optname != IP_IPSEC_POLICY && > > optname != IP_XFRM_POLICY && > > !ip_mroute_opt(optname)) > > - err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); > > + err = nf_setsockopt(sk, PF_INET, optname, USER_SOCKPTR(optval), > > + optlen); > > #endif > > return err; > > } > > diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c > > index 4697d09c98dc3e..f2a9680303d8c0 100644 > > --- a/net/ipv4/netfilter/ip_tables.c > > +++ b/net/ipv4/netfilter/ip_tables.c > > @@ -1102,7 +1102,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks, > > } > > > > static int > > -do_replace(struct net *net, const void __user *user, unsigned int len) > > +do_replace(struct net *net, sockptr_t arg, unsigned int len) > > { > > int ret; > > struct ipt_replace tmp; > > @@ -1110,7 +1110,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) > > void *loc_cpu_entry; > > struct ipt_entry *iter; > > > > - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) > > + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) > > return -EFAULT; > > > > /* overflow check */ > > @@ -1126,8 +1126,8 @@ do_replace(struct net *net, const void __user *user, unsigned int len) > > return -ENOMEM; > > > > loc_cpu_entry = newinfo->entries; > > - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), > > - tmp.size) != 0) { > > + sockptr_advance(arg, sizeof(tmp)); > > + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { > > ret = -EFAULT; > > goto free_newinfo; > > } > > Something along this path seems to have broken with this patch. An > invocation of `iptables -A INPUT -m length --length 1360 -j DROP` now > fails, with > > nf_setsockopt->do_replace->translate_table->check_entry_size_and_hooks: > (unsigned char *)e + e->next_offset > limit ==> TRUE > > resulting in the whole call chain returning -EINVAL. It bisects back to > this commit. This is on net-next. This is another use o sockptr_advance that Ido already found a problem in. I'm looking into this at the moment.. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SFIwJtP9Hl+pIQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 18:16:19 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id yGcoJdP9Hl920QAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 18:16:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5DAA541760; Mon, 27 Jul 2020 18:16:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728722AbgG0QQB (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 12:16:01 -0400 Received: from verein.lst.de ([213.95.11.211]:44295 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726728AbgG0QQB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 12:16:01 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 4880068B05; Mon, 27 Jul 2020 18:15:55 +0200 (CEST) Date: Mon, 27 Jul 2020 18:15:55 +0200 From: Christoph Hellwig <hch@lst.de> To: Ido Schimmel <idosch@idosch.org> Cc: Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 19/26] net/ipv6: switch ipv6_flowlabel_opt to sockptr_t Message-ID: <20200727161555.GA7817@lst.de> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-20-hch@lst.de> <20200727121505.GA1804864@shredder> <20200727130029.GA26393@lst.de> <20200727133331.GA1851348@shredder> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200727133331.GA1851348@shredder> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.07 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5DAA541760 X-Rspamd-UID: 928737 I have to admit I didn't spot the difference between the good and the bad output even after trying hard.. But can you try the patch below? --- From cce2d2e1b43ecee5f4af7cf116808b74b330080f Mon Sep 17 00:00:00 2001 From: Christoph Hellwig <hch@lst.de> Date: Mon, 27 Jul 2020 17:42:27 +0200 Subject: net: remove sockptr_advance sockptr_advance never properly worked. Replace it with _offset variants of copy_from_sockptr and copy_to_sockptr. Fixes: ba423fdaa589 ("net: add a new sockptr_t type") Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> Reported-by: Ido Schimmel <idosch@idosch.org> Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/crypto/chelsio/chtls/chtls_main.c | 12 +++++----- include/linux/sockptr.h | 27 +++++++++++------------ net/dccp/proto.c | 5 ++--- net/ipv4/netfilter/arp_tables.c | 8 +++---- net/ipv4/netfilter/ip_tables.c | 8 +++---- net/ipv4/tcp.c | 5 +++-- net/ipv6/ip6_flowlabel.c | 11 ++++----- net/ipv6/netfilter/ip6_tables.c | 8 +++---- net/netfilter/x_tables.c | 7 +++--- net/tls/tls_main.c | 6 ++--- 10 files changed, 49 insertions(+), 48 deletions(-) diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c b/drivers/crypto/chelsio/chtls/chtls_main.c index c3058dcdb33c5c..66d247efd5615b 100644 --- a/drivers/crypto/chelsio/chtls/chtls_main.c +++ b/drivers/crypto/chelsio/chtls/chtls_main.c @@ -525,9 +525,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, /* Obtain version and type from previous copy */ crypto_info[0] = tmp_crypto_info; /* Now copy the following data */ - sockptr_advance(optval, sizeof(*crypto_info)); - rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), - optval, + rc = copy_from_sockptr_offset((char *)crypto_info + + sizeof(*crypto_info), + optval, sizeof(*crypto_info), sizeof(struct tls12_crypto_info_aes_gcm_128) - sizeof(*crypto_info)); @@ -542,9 +542,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, } case TLS_CIPHER_AES_GCM_256: { crypto_info[0] = tmp_crypto_info; - sockptr_advance(optval, sizeof(*crypto_info)); - rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), - optval, + rc = copy_from_sockptr_offset((char *)crypto_info + + sizeof(*crypto_info), + optval, sizeof(*crypto_info), sizeof(struct tls12_crypto_info_aes_gcm_256) - sizeof(*crypto_info)); diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h index b13ea1422f93a5..9e6c81d474cba8 100644 --- a/include/linux/sockptr.h +++ b/include/linux/sockptr.h @@ -69,19 +69,26 @@ static inline bool sockptr_is_null(sockptr_t sockptr) return !sockptr.user; } -static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) +static inline int copy_from_sockptr_offset(void *dst, sockptr_t src, + size_t offset, size_t size) { if (!sockptr_is_kernel(src)) - return copy_from_user(dst, src.user, size); - memcpy(dst, src.kernel, size); + return copy_from_user(dst, src.user + offset, size); + memcpy(dst, src.kernel + offset, size); return 0; } -static inline int copy_to_sockptr(sockptr_t dst, const void *src, size_t size) +static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) +{ + return copy_from_sockptr_offset(dst, src, 0, size); +} + +static inline int copy_to_sockptr_offset(sockptr_t dst, size_t offset, + const void *src, size_t size) { if (!sockptr_is_kernel(dst)) - return copy_to_user(dst.user, src, size); - memcpy(dst.kernel, src, size); + return copy_to_user(dst.user + offset, src, size); + memcpy(dst.kernel + offset, src, size); return 0; } @@ -112,14 +119,6 @@ static inline void *memdup_sockptr_nul(sockptr_t src, size_t len) return p; } -static inline void sockptr_advance(sockptr_t sockptr, size_t len) -{ - if (sockptr_is_kernel(sockptr)) - sockptr.kernel += len; - else - sockptr.user += len; -} - static inline long strncpy_from_sockptr(char *dst, sockptr_t src, size_t count) { if (sockptr_is_kernel(src)) { diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 2e9e8449698fb4..d148ab1530e57b 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -426,9 +426,8 @@ static int dccp_setsockopt_service(struct sock *sk, const __be32 service, return -ENOMEM; sl->dccpsl_nr = optlen / sizeof(u32) - 1; - sockptr_advance(optval, sizeof(service)); - if (copy_from_sockptr(sl->dccpsl_list, optval, - optlen - sizeof(service)) || + if (copy_from_sockptr_offset(sl->dccpsl_list, optval, + sizeof(service), optlen - sizeof(service)) || dccp_list_has_service(sl, DCCP_SERVICE_INVALID_VALUE)) { kfree(sl); return -EFAULT; diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 9a1567dbc022b6..d1e04d2b5170ec 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -971,8 +971,8 @@ static int do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1267,8 +1267,8 @@ static int compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index f2a9680303d8c0..f15bc21d730164 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -1126,8 +1126,8 @@ do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1508,8 +1508,8 @@ compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 27de9380ed140e..4afec552f211b9 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2801,12 +2801,13 @@ static int tcp_repair_options_est(struct sock *sk, sockptr_t optbuf, { struct tcp_sock *tp = tcp_sk(sk); struct tcp_repair_opt opt; + size_t offset = 0; while (len >= sizeof(opt)) { - if (copy_from_sockptr(&opt, optbuf, sizeof(opt))) + if (copy_from_sockptr_offset(&opt, optbuf, offset, sizeof(opt))) return -EFAULT; - sockptr_advance(optbuf, sizeof(opt)); + offset += sizeof(opt); len -= sizeof(opt); switch (opt.opt_code) { diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index 215b6f5e733ec9..2d655260dedc75 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c @@ -401,8 +401,8 @@ fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, memset(fl->opt, 0, sizeof(*fl->opt)); fl->opt->tot_len = sizeof(*fl->opt) + olen; err = -EFAULT; - sockptr_advance(optval, CMSG_ALIGN(sizeof(*freq))); - if (copy_from_sockptr(fl->opt + 1, optval, olen)) + if (copy_from_sockptr_offset(fl->opt + 1, optval, + CMSG_ALIGN(sizeof(*freq)), olen)) goto done; msg.msg_controllen = olen; @@ -703,9 +703,10 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, goto recheck; if (!freq->flr_label) { - sockptr_advance(optval, - offsetof(struct in6_flowlabel_req, flr_label)); - if (copy_to_sockptr(optval, &fl->label, sizeof(fl->label))) { + size_t offset = offsetof(struct in6_flowlabel_req, flr_label); + + if (copy_to_sockptr_offset(optval, offset, &fl->label, + sizeof(fl->label))) { /* Intentionally ignore fault. */ } } diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 1d52957a413f4a..2e2119bfcf1373 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -1143,8 +1143,8 @@ do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1517,8 +1517,8 @@ compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index b97eb4b538fd4e..91bf6635ea9ee4 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1050,6 +1050,7 @@ EXPORT_SYMBOL_GPL(xt_check_target); void *xt_copy_counters(sockptr_t arg, unsigned int len, struct xt_counters_info *info) { + size_t offset; void *mem; u64 size; @@ -1067,7 +1068,7 @@ void *xt_copy_counters(sockptr_t arg, unsigned int len, memcpy(info->name, compat_tmp.name, sizeof(info->name) - 1); info->num_counters = compat_tmp.num_counters; - sockptr_advance(arg, sizeof(compat_tmp)); + offset = sizeof(compat_tmp); } else #endif { @@ -1078,7 +1079,7 @@ void *xt_copy_counters(sockptr_t arg, unsigned int len, if (copy_from_sockptr(info, arg, sizeof(*info)) != 0) return ERR_PTR(-EFAULT); - sockptr_advance(arg, sizeof(*info)); + offset = sizeof(*info); } info->name[sizeof(info->name) - 1] = '\0'; @@ -1092,7 +1093,7 @@ void *xt_copy_counters(sockptr_t arg, unsigned int len, if (!mem) return ERR_PTR(-ENOMEM); - if (copy_from_sockptr(mem, arg, len) == 0) + if (copy_from_sockptr_offset(mem, arg, offset, len) == 0) return mem; vfree(mem); diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index d77f7d821130db..bbc52b088d2968 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -522,9 +522,9 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval, goto err_crypto_info; } - sockptr_advance(optval, sizeof(*crypto_info)); - rc = copy_from_sockptr(crypto_info + 1, optval, - optlen - sizeof(*crypto_info)); + rc = copy_from_sockptr_offset(crypto_info + 1, optval, + sizeof(*crypto_info), + optlen - sizeof(*crypto_info)); if (rc) { rc = -EFAULT; goto err_crypto_info; -- 2.27.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uGZwEd39Hl/1NgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 18:16:29 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id iCYLD939Hl+GugAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 18:16:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 443A54175E; Mon, 27 Jul 2020 18:16:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731222AbgG0QQW (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 12:16:22 -0400 Received: from verein.lst.de ([213.95.11.211]:44311 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726728AbgG0QQU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 12:16:20 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 3EEBF68C4E; Mon, 27 Jul 2020 18:16:15 +0200 (CEST) Date: Mon, 27 Jul 2020 18:16:15 +0200 From: Christoph Hellwig <hch@lst.de> To: "Jason A. Donenfeld" <Jason@zx2c4.com> Cc: Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 12/26] netfilter: switch nf_setsockopt to sockptr_t Message-ID: <20200727161615.GB7817@lst.de> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-13-hch@lst.de> <20200727150310.GA1632472@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200727150310.GA1632472@zx2c4.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.07 / 15.00 / 200.00 X-Rspamd-Queue-Id: 443A54175E X-Rspamd-UID: ed0419 Can you try the patch below? --- From cce2d2e1b43ecee5f4af7cf116808b74b330080f Mon Sep 17 00:00:00 2001 From: Christoph Hellwig <hch@lst.de> Date: Mon, 27 Jul 2020 17:42:27 +0200 Subject: net: remove sockptr_advance sockptr_advance never properly worked. Replace it with _offset variants of copy_from_sockptr and copy_to_sockptr. Fixes: ba423fdaa589 ("net: add a new sockptr_t type") Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> Reported-by: Ido Schimmel <idosch@idosch.org> Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/crypto/chelsio/chtls/chtls_main.c | 12 +++++----- include/linux/sockptr.h | 27 +++++++++++------------ net/dccp/proto.c | 5 ++--- net/ipv4/netfilter/arp_tables.c | 8 +++---- net/ipv4/netfilter/ip_tables.c | 8 +++---- net/ipv4/tcp.c | 5 +++-- net/ipv6/ip6_flowlabel.c | 11 ++++----- net/ipv6/netfilter/ip6_tables.c | 8 +++---- net/netfilter/x_tables.c | 7 +++--- net/tls/tls_main.c | 6 ++--- 10 files changed, 49 insertions(+), 48 deletions(-) diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c b/drivers/crypto/chelsio/chtls/chtls_main.c index c3058dcdb33c5c..66d247efd5615b 100644 --- a/drivers/crypto/chelsio/chtls/chtls_main.c +++ b/drivers/crypto/chelsio/chtls/chtls_main.c @@ -525,9 +525,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, /* Obtain version and type from previous copy */ crypto_info[0] = tmp_crypto_info; /* Now copy the following data */ - sockptr_advance(optval, sizeof(*crypto_info)); - rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), - optval, + rc = copy_from_sockptr_offset((char *)crypto_info + + sizeof(*crypto_info), + optval, sizeof(*crypto_info), sizeof(struct tls12_crypto_info_aes_gcm_128) - sizeof(*crypto_info)); @@ -542,9 +542,9 @@ static int do_chtls_setsockopt(struct sock *sk, int optname, } case TLS_CIPHER_AES_GCM_256: { crypto_info[0] = tmp_crypto_info; - sockptr_advance(optval, sizeof(*crypto_info)); - rc = copy_from_sockptr((char *)crypto_info + sizeof(*crypto_info), - optval, + rc = copy_from_sockptr_offset((char *)crypto_info + + sizeof(*crypto_info), + optval, sizeof(*crypto_info), sizeof(struct tls12_crypto_info_aes_gcm_256) - sizeof(*crypto_info)); diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h index b13ea1422f93a5..9e6c81d474cba8 100644 --- a/include/linux/sockptr.h +++ b/include/linux/sockptr.h @@ -69,19 +69,26 @@ static inline bool sockptr_is_null(sockptr_t sockptr) return !sockptr.user; } -static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) +static inline int copy_from_sockptr_offset(void *dst, sockptr_t src, + size_t offset, size_t size) { if (!sockptr_is_kernel(src)) - return copy_from_user(dst, src.user, size); - memcpy(dst, src.kernel, size); + return copy_from_user(dst, src.user + offset, size); + memcpy(dst, src.kernel + offset, size); return 0; } -static inline int copy_to_sockptr(sockptr_t dst, const void *src, size_t size) +static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) +{ + return copy_from_sockptr_offset(dst, src, 0, size); +} + +static inline int copy_to_sockptr_offset(sockptr_t dst, size_t offset, + const void *src, size_t size) { if (!sockptr_is_kernel(dst)) - return copy_to_user(dst.user, src, size); - memcpy(dst.kernel, src, size); + return copy_to_user(dst.user + offset, src, size); + memcpy(dst.kernel + offset, src, size); return 0; } @@ -112,14 +119,6 @@ static inline void *memdup_sockptr_nul(sockptr_t src, size_t len) return p; } -static inline void sockptr_advance(sockptr_t sockptr, size_t len) -{ - if (sockptr_is_kernel(sockptr)) - sockptr.kernel += len; - else - sockptr.user += len; -} - static inline long strncpy_from_sockptr(char *dst, sockptr_t src, size_t count) { if (sockptr_is_kernel(src)) { diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 2e9e8449698fb4..d148ab1530e57b 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -426,9 +426,8 @@ static int dccp_setsockopt_service(struct sock *sk, const __be32 service, return -ENOMEM; sl->dccpsl_nr = optlen / sizeof(u32) - 1; - sockptr_advance(optval, sizeof(service)); - if (copy_from_sockptr(sl->dccpsl_list, optval, - optlen - sizeof(service)) || + if (copy_from_sockptr_offset(sl->dccpsl_list, optval, + sizeof(service), optlen - sizeof(service)) || dccp_list_has_service(sl, DCCP_SERVICE_INVALID_VALUE)) { kfree(sl); return -EFAULT; diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 9a1567dbc022b6..d1e04d2b5170ec 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -971,8 +971,8 @@ static int do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1267,8 +1267,8 @@ static int compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index f2a9680303d8c0..f15bc21d730164 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -1126,8 +1126,8 @@ do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1508,8 +1508,8 @@ compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 27de9380ed140e..4afec552f211b9 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2801,12 +2801,13 @@ static int tcp_repair_options_est(struct sock *sk, sockptr_t optbuf, { struct tcp_sock *tp = tcp_sk(sk); struct tcp_repair_opt opt; + size_t offset = 0; while (len >= sizeof(opt)) { - if (copy_from_sockptr(&opt, optbuf, sizeof(opt))) + if (copy_from_sockptr_offset(&opt, optbuf, offset, sizeof(opt))) return -EFAULT; - sockptr_advance(optbuf, sizeof(opt)); + offset += sizeof(opt); len -= sizeof(opt); switch (opt.opt_code) { diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index 215b6f5e733ec9..2d655260dedc75 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c @@ -401,8 +401,8 @@ fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, memset(fl->opt, 0, sizeof(*fl->opt)); fl->opt->tot_len = sizeof(*fl->opt) + olen; err = -EFAULT; - sockptr_advance(optval, CMSG_ALIGN(sizeof(*freq))); - if (copy_from_sockptr(fl->opt + 1, optval, olen)) + if (copy_from_sockptr_offset(fl->opt + 1, optval, + CMSG_ALIGN(sizeof(*freq)), olen)) goto done; msg.msg_controllen = olen; @@ -703,9 +703,10 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, goto recheck; if (!freq->flr_label) { - sockptr_advance(optval, - offsetof(struct in6_flowlabel_req, flr_label)); - if (copy_to_sockptr(optval, &fl->label, sizeof(fl->label))) { + size_t offset = offsetof(struct in6_flowlabel_req, flr_label); + + if (copy_to_sockptr_offset(optval, offset, &fl->label, + sizeof(fl->label))) { /* Intentionally ignore fault. */ } } diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 1d52957a413f4a..2e2119bfcf1373 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -1143,8 +1143,8 @@ do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } @@ -1517,8 +1517,8 @@ compat_do_replace(struct net *net, sockptr_t arg, unsigned int len) return -ENOMEM; loc_cpu_entry = newinfo->entries; - sockptr_advance(arg, sizeof(tmp)); - if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { + if (copy_from_sockptr_offset(loc_cpu_entry, arg, sizeof(tmp), + tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index b97eb4b538fd4e..91bf6635ea9ee4 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1050,6 +1050,7 @@ EXPORT_SYMBOL_GPL(xt_check_target); void *xt_copy_counters(sockptr_t arg, unsigned int len, struct xt_counters_info *info) { + size_t offset; void *mem; u64 size; @@ -1067,7 +1068,7 @@ void *xt_copy_counters(sockptr_t arg, unsigned int len, memcpy(info->name, compat_tmp.name, sizeof(info->name) - 1); info->num_counters = compat_tmp.num_counters; - sockptr_advance(arg, sizeof(compat_tmp)); + offset = sizeof(compat_tmp); } else #endif { @@ -1078,7 +1079,7 @@ void *xt_copy_counters(sockptr_t arg, unsigned int len, if (copy_from_sockptr(info, arg, sizeof(*info)) != 0) return ERR_PTR(-EFAULT); - sockptr_advance(arg, sizeof(*info)); + offset = sizeof(*info); } info->name[sizeof(info->name) - 1] = '\0'; @@ -1092,7 +1093,7 @@ void *xt_copy_counters(sockptr_t arg, unsigned int len, if (!mem) return ERR_PTR(-ENOMEM); - if (copy_from_sockptr(mem, arg, len) == 0) + if (copy_from_sockptr_offset(mem, arg, offset, len) == 0) return mem; vfree(mem); diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index d77f7d821130db..bbc52b088d2968 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -522,9 +522,9 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval, goto err_crypto_info; } - sockptr_advance(optval, sizeof(*crypto_info)); - rc = copy_from_sockptr(crypto_info + 1, optval, - optlen - sizeof(*crypto_info)); + rc = copy_from_sockptr_offset(crypto_info + 1, optval, + sizeof(*crypto_info), + optlen - sizeof(*crypto_info)); if (rc) { rc = -EFAULT; goto err_crypto_info; -- 2.27.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gEVxKEz+Hl+pIQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 18:18:20 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 6G2rJkz+Hl/cEgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 18:18:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=zx2c4.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E68F1418AE; Mon, 27 Jul 2020 18:18:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731438AbgG0QQv (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 12:16:51 -0400 Received: from mail.zx2c4.com ([192.95.5.64]:46879 "EHLO mail.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731402AbgG0QQu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 12:16:50 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 09880da9; Mon, 27 Jul 2020 15:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=yZ9s7iESSXllw2jFppVGJgSQSDc=; b=T8Sn3a 8QgZwT7OBLiEk39YllHL8AHxegeWoSsgukQldc9TiwR4eHH+81jI/awj0HrXtBrg Y5UPc9Cc5BZJ8GrAprgs5NcK5vubz31d4jsM4x0gMeFEgDrVjUrRX41udJBHMNld d/Bx9892A78N/q/07Gl0nQui+mlF/IAoZIyvrYwHlA6vlD8ytQ/RkS4Lp/JjiVOo r0KIpueIg+d9HaYHBQI6Nj9saKViVpoxMt0rA2Xtk8fEZ2Ajc735rEzlQ3Gn8yTu 4eFoXmxypskbeYUzua5Dmfrj+eDOvtFDSR0ScqE+ZC5nUsdiFsBW9DfS1UvXfi+f sWCgYlvemIgM0Wvg== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 0a17c61b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 27 Jul 2020 15:53:25 +0000 (UTC) Received: by mail-il1-f177.google.com with SMTP id b18so8376992ilo.12; Mon, 27 Jul 2020 09:16:45 -0700 (PDT) X-Gm-Message-State: AOAM533rlfDKOj1/MijCyDrrjZl1Y0z0jvOzAJm+qXdBUOMQqOTGi589 KPMgNaN1bCfszWgnF/gQXlrFJS0cH133ROVNtAs= X-Google-Smtp-Source: ABdhPJxpUhiuwtuwnEaez1P/c+ZU0pwKxKQezmeTGc12hGP8McAl6Imm8qRtlhHrSqvTuhro7sF5xCj0r6Sl8qXVeP8= X-Received: by 2002:a92:c804:: with SMTP id v4mr15897355iln.207.1595866604002; Mon, 27 Jul 2020 09:16:44 -0700 (PDT) MIME-Version: 1.0 References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-13-hch@lst.de> <20200727150310.GA1632472@zx2c4.com> <20200727150601.GA3447@lst.de> In-Reply-To: <20200727150601.GA3447@lst.de> From: "Jason A. Donenfeld" <Jason@zx2c4.com> Date: Mon, 27 Jul 2020 18:16:32 +0200 X-Gmail-Original-Message-ID: <CAHmME9ric=chLJayn7Erve7WBa+qCKn-+Gjri=zqydoY6623aA@mail.gmail.com> Message-ID: <CAHmME9ric=chLJayn7Erve7WBa+qCKn-+Gjri=zqydoY6623aA@mail.gmail.com> Subject: Re: [PATCH 12/26] netfilter: switch nf_setsockopt to sockptr_t To: Christoph Hellwig <hch@lst.de> Cc: "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, Linux Crypto Mailing List <linux-crypto@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Netdev <netdev@vger.kernel.org>, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org, Kernel Hardening <kernel-hardening@lists.openwall.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: E68F1418AE X-Rspamd-UID: 945850 On Mon, Jul 27, 2020 at 5:06 PM Christoph Hellwig <hch@lst.de> wrote: > > On Mon, Jul 27, 2020 at 05:03:10PM +0200, Jason A. Donenfeld wrote: > > Hi Christoph, > > > > On Thu, Jul 23, 2020 at 08:08:54AM +0200, Christoph Hellwig wrote: > > > diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c > > > index da933f99b5d517..42befbf12846c0 100644 > > > --- a/net/ipv4/ip_sockglue.c > > > +++ b/net/ipv4/ip_sockglue.c > > > @@ -1422,7 +1422,8 @@ int ip_setsockopt(struct sock *sk, int level, > > > optname != IP_IPSEC_POLICY && > > > optname != IP_XFRM_POLICY && > > > !ip_mroute_opt(optname)) > > > - err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); > > > + err = nf_setsockopt(sk, PF_INET, optname, USER_SOCKPTR(optval), > > > + optlen); > > > #endif > > > return err; > > > } > > > diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c > > > index 4697d09c98dc3e..f2a9680303d8c0 100644 > > > --- a/net/ipv4/netfilter/ip_tables.c > > > +++ b/net/ipv4/netfilter/ip_tables.c > > > @@ -1102,7 +1102,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks, > > > } > > > > > > static int > > > -do_replace(struct net *net, const void __user *user, unsigned int len) > > > +do_replace(struct net *net, sockptr_t arg, unsigned int len) > > > { > > > int ret; > > > struct ipt_replace tmp; > > > @@ -1110,7 +1110,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) > > > void *loc_cpu_entry; > > > struct ipt_entry *iter; > > > > > > - if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) > > > + if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0) > > > return -EFAULT; > > > > > > /* overflow check */ > > > @@ -1126,8 +1126,8 @@ do_replace(struct net *net, const void __user *user, unsigned int len) > > > return -ENOMEM; > > > > > > loc_cpu_entry = newinfo->entries; > > > - if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), > > > - tmp.size) != 0) { > > > + sockptr_advance(arg, sizeof(tmp)); > > > + if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) { > > > ret = -EFAULT; > > > goto free_newinfo; > > > } > > > > Something along this path seems to have broken with this patch. An > > invocation of `iptables -A INPUT -m length --length 1360 -j DROP` now > > fails, with > > > > nf_setsockopt->do_replace->translate_table->check_entry_size_and_hooks: > > (unsigned char *)e + e->next_offset > limit ==> TRUE > > > > resulting in the whole call chain returning -EINVAL. It bisects back to > > this commit. This is on net-next. > > This is another use o sockptr_advance that Ido already found a problem > in. I'm looking into this at the moment.. I haven't seen Ido's patch, but it seems clear the issue is that you want to call `sockptr_advance(&arg, sizeof(tmp))`, and adjust sockptr_advance to take a pointer. Slight concern about the whole concept: Things are defined as typedef union { void *kernel; void __user *user; } sockptr_t; static inline bool sockptr_is_kernel(sockptr_t sockptr) { return (unsigned long)sockptr.kernel >= TASK_SIZE; } So what happens if we have some code like: sockptr_t sp; init_user_sockptr(&sp, user_controlled_struct.extra_user_ptr); sockptr_advance(&sp, user_controlled_struct.some_big_offset); copy_to_sockptr(&sp, user_controlled_struct.a_few_bytes, sizeof(user_controlled_struct.a_few_bytes)); With the user controlling some_big_offset, he can convert the user sockptr into a kernel sockptr, causing the subsequent copy_to_sockptr to be a vanilla memcpy, after which a security disaster ensues. Maybe sockptr_advance should have some safety checks and sometimes return -EFAULT? Or you should always use the implementation where being a kernel address is an explicit bit of sockptr_t, rather than being implicit? Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ofo8CLf/Hl/uUAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 18:24:23 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id iI/xBbf/Hl/r9AAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 18:24:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8746440990; Mon, 27 Jul 2020 18:24:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728764AbgG0QYF (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 12:24:05 -0400 Received: from verein.lst.de ([213.95.11.211]:44350 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728716AbgG0QYF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 12:24:05 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 213DF68B05; Mon, 27 Jul 2020 18:23:58 +0200 (CEST) Date: Mon, 27 Jul 2020 18:23:57 +0200 From: Christoph Hellwig <hch@lst.de> To: "Jason A. Donenfeld" <Jason@zx2c4.com> Cc: Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, Linux Crypto Mailing List <linux-crypto@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Netdev <netdev@vger.kernel.org>, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org, Kernel Hardening <kernel-hardening@lists.openwall.com> Subject: Re: [PATCH 12/26] netfilter: switch nf_setsockopt to sockptr_t Message-ID: <20200727162357.GA8022@lst.de> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-13-hch@lst.de> <20200727150310.GA1632472@zx2c4.com> <20200727150601.GA3447@lst.de> <CAHmME9ric=chLJayn7Erve7WBa+qCKn-+Gjri=zqydoY6623aA@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <CAHmME9ric=chLJayn7Erve7WBa+qCKn-+Gjri=zqydoY6623aA@mail.gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.08 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8746440990 X-Rspamd-UID: 293975 On Mon, Jul 27, 2020 at 06:16:32PM +0200, Jason A. Donenfeld wrote: > Maybe sockptr_advance should have some safety checks and sometimes > return -EFAULT? Or you should always use the implementation where > being a kernel address is an explicit bit of sockptr_t, rather than > being implicit? I already have a patch to use access_ok to check the whole range in init_user_sockptr. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wKYODaAbH1+60QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 20:23:28 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EG1ZC6AbH18seQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 20:23:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=messagingengine.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 790924174E; Mon, 27 Jul 2020 20:23:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729941AbgG0SXI (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 14:23:08 -0400 Received: from wnew2-smtp.messagingengine.com ([64.147.123.27]:46683 "EHLO wnew2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729205AbgG0SXH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 14:23:07 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id D24DDE02; Mon, 27 Jul 2020 14:23:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 27 Jul 2020 14:23:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=Afhna7 9fjG2N/ESpGlT1yod24pbovs9kG7jTtRp8uec=; b=pxd6lnhAQY6lq36Rw0t2Wr FNTj7Aqv7utLvfCSPVSKK7zYkP/Oi6k9NUUf7rFRtAgNJ4ISpkANzMes5KPdO5xP uQhBAs0exKeEZWKHlguK1wyxAhd7/2StnncNBaDA+r1X7J3jOA/5IUqtqukcS8Zy 6b1F7WsC7K7Gxls+h+LpTkFCZf/cBDkEzEii5uRHhbH0he4RqOm0VhtaaNhJ0ONh sA1OegTDCQaheFhFJspfeBf1dkuokHpdFLa9JDtSfErlJ23gF/vUAREvveiVNSbI s2U0p/YcHBpouuo2EToObgfipcm60uYWCoTDshKh/Ld62ZeuhBlR0923rp/WSgug == X-ME-Sender: <xms:hhsfXw256bt5Qvmk7qwJktXsYXMYpGtJEPiP9Uh0o4S3z4J60JG_Ug> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedriedtgdduvdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefkughoucfu tghhihhmmhgvlhcuoehiughoshgthhesihguohhstghhrdhorhhgqeenucggtffrrghtth gvrhhnpedtffekkeefudffveegueejffejhfetgfeuuefgvedtieehudeuueekhfduheel teenucfkphepjeelrddukedurddvrddujeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepihguohhstghhsehiughoshgthhdrohhrgh X-ME-Proxy: <xmx:hhsfX7GUtyQL-qzWlnNrDA6BRLNqA_sVqs6SkDPZ3OFYz2rLpuLPKA> <xmx:hhsfX46tTRqe9_4re0uj3hKI21pc6E5kOG5GBQ_4I2GbhCEFmzhFVQ> <xmx:hhsfX53ly2RhKyVXpSc-AP7Py8h3bUEfu3XyInk15A9EOdXPwhk-DQ> <xmx:iBsfX7VuEFOpnGbNFKVSKt3rokiDITnfnJBSqLDGQ8efu7Vwr-9kkM4RTJM> Received: from localhost (bzq-79-181-2-179.red.bezeqint.net [79.181.2.179]) by mail.messagingengine.com (Postfix) with ESMTPA id BA5ED328005D; Mon, 27 Jul 2020 14:23:01 -0400 (EDT) Date: Mon, 27 Jul 2020 21:22:59 +0300 From: Ido Schimmel <idosch@idosch.org> To: Christoph Hellwig <hch@lst.de> Cc: "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Subject: Re: [PATCH 19/26] net/ipv6: switch ipv6_flowlabel_opt to sockptr_t Message-ID: <20200727182259.GA1931870@shredder> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-20-hch@lst.de> <20200727121505.GA1804864@shredder> <20200727130029.GA26393@lst.de> <20200727133331.GA1851348@shredder> <20200727161555.GA7817@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200727161555.GA7817@lst.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: 790924174E X-Rspamd-UID: 555675 On Mon, Jul 27, 2020 at 06:15:55PM +0200, Christoph Hellwig wrote: > I have to admit I didn't spot the difference between the good and the > bad output even after trying hard.. > > But can you try the patch below? > > --- > From cce2d2e1b43ecee5f4af7cf116808b74b330080f Mon Sep 17 00:00:00 2001 > From: Christoph Hellwig <hch@lst.de> > Date: Mon, 27 Jul 2020 17:42:27 +0200 > Subject: net: remove sockptr_advance > > sockptr_advance never properly worked. Replace it with _offset variants > of copy_from_sockptr and copy_to_sockptr. > > Fixes: ba423fdaa589 ("net: add a new sockptr_t type") > Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> > Reported-by: Ido Schimmel <idosch@idosch.org> > Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Ido Schimmel <idosch@mellanox.com> Thanks! Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uETJEb5FH18Q7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 27 Jul 2020 23:23:10 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id oCNtEL5FH18T5QEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 27 Jul 2020 23:23:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4455A40990; Mon, 27 Jul 2020 23:23:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbgG0VW5 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 17:22:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbgG0VW4 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 17:22:56 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40EBAC0619D2 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 14:22:55 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id u185so9805577pfu.1 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 14:22:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=utU3ypLjQOA4QshSQAJBKI2d0qo7ScTec5y8sMLYM0s=; b=fjyHM/wYzqCrthuAjiCo7Q8zcYcjLGiRwhJ9AljY6LotLvI/TAxBVCdeEe8o82dTpu tAQph9QJ9ehJ+T+sZ50ioIJNGYQLk/rmG7SS6tiJG87XqLQzDfo7o5TzX6VpcTPqW1E3 kU68mv5gn2cE+FeTMwF5kOkLrUOCCS0svLBeI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=utU3ypLjQOA4QshSQAJBKI2d0qo7ScTec5y8sMLYM0s=; b=gfUej9JRJ8bAfxomcosUChbo10A6B6APtOlRDgXciYlpGAnaflvJc3lb+xAFgL7p96 qUUYoMWAPNscTC9KTOnP0AYPjj4xcERx6VXNjSULGvZB/Kpfryvw2SoUn0bkMbY/Ewv0 wtzJZUM/dWdCqsSiuXGqtBqsdCCbObw4ywvYqRXSHD8oGj0+kkzFA5+IcwIE/Rzj6Vyc mO68bluXRMXMtPPXqgm2TUP+UOW8BgyEHnTRQy2ovPCyrp6fmxCi1ehNw90jmzV1sYZD V9f2euTRw7OIjLS5mAVMT2h3Ec/KX6cIxsGRPJfACtpE4QKQHZ3EuXSJEUMofxHepZc9 LOBQ== X-Gm-Message-State: AOAM531aEBTPn2Hm+u8zkjKxf+ucvITDxubPE5spoUGYt60A2jehB5qD RHrBXtW/4l7TR3J6zC+QaUfzmqBOPmo= X-Google-Smtp-Source: ABdhPJxWhcqwAmUemUB9Vs0QMZ9njkmN/7vQG5K6xg/Cea8uqkvrdRSDIdxbslAIlaOTnxtWhXg4Ow== X-Received: by 2002:a63:e442:: with SMTP id i2mr21886170pgk.105.1595884974482; Mon, 27 Jul 2020 14:22:54 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id u14sm15601968pgf.51.2020.07.27.14.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 14:22:53 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH] Bluetooth: Fix suspend notifier race Date: Mon, 27 Jul 2020 14:22:47 -0700 Message-Id: <20200727142231.1.I7ebe9eaf684ddb07ae28634cb4d28cf7754641f1@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4455A40990 X-Rspamd-UID: c71e6b Unregister from suspend notifications and cancel suspend preparations before running hci_dev_do_close. Otherwise, the suspend notifier may race with unregister and cause cmd_timeout even after hdev has been freed. Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Hi Marcel, This fixes a race between hci_unregister_dev and the suspend notifier. Without these changes, we encountered the following kernel panic when a USB disconnect (with btusb) occurred on resume: [ 832.578518] Bluetooth: hci_core.c:hci_cmd_timeout() hci0: command 0x0c05 tx timeout [ 832.586200] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 832.586203] #PF: supervisor read access in kernel mode [ 832.586205] #PF: error_code(0x0000) - not-present page [ 832.586206] PGD 0 P4D 0 [ 832.586210] PM: suspend exit [ 832.608870] Oops: 0000 [#1] PREEMPT SMP NOPTI [ 832.613232] CPU: 3 PID: 10755 Comm: kworker/3:7 Not tainted 5.4.44-04894-g1e9dbb96a161 #1 [ 832.630036] Workqueue: events hci_cmd_timeout [bluetooth] [ 832.630046] RIP: 0010:__queue_work+0xf0/0x374 [ 832.630051] RSP: 0018:ffff9b5285f1fdf8 EFLAGS: 00010046 [ 832.674033] RAX: ffff8a97681bac00 RBX: 0000000000000000 RCX: ffff8a976a000600 [ 832.681162] RDX: 0000000000000000 RSI: 0000000000000009 RDI: ffff8a976a000748 [ 832.688289] RBP: ffff9b5285f1fe38 R08: 0000000000000000 R09: ffff8a97681bac00 [ 832.695418] R10: 0000000000000002 R11: ffff8a976a0006d8 R12: ffff8a9745107600 [ 832.698045] usb 1-6: new full-speed USB device number 119 using xhci_hcd [ 832.702547] R13: ffff8a9673658850 R14: 0000000000000040 R15: 000000000000001e [ 832.702549] FS: 0000000000000000(0000) GS:ffff8a976af80000(0000) knlGS:0000000000000000 [ 832.702550] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 832.702550] CR2: 0000000000000000 CR3: 000000010415a000 CR4: 00000000003406e0 [ 832.702551] Call Trace: [ 832.702558] queue_work_on+0x3f/0x68 [ 832.702562] process_one_work+0x1db/0x396 [ 832.747397] worker_thread+0x216/0x375 [ 832.751147] kthread+0x138/0x140 [ 832.754377] ? pr_cont_work+0x58/0x58 [ 832.758037] ? kthread_blkcg+0x2e/0x2e [ 832.761787] ret_from_fork+0x22/0x40 [ 832.846191] ---[ end trace fa93f466da517212 ]--- The suspend notifier handler seemed to be scheduling commands even after it was cleaned up and this was resulting in a panic in cmd_timeout (when it tries to requeue the cmd_timer). This was tested on 5.4 kernel with a suspend+resume stress test for 500+ iterations. I also confirmed that after a usb disconnect, the suspend notifier times out before the USB device is probed again (fixing the original race between the usb_disconnect + probe and the notifier). Thanks Abhishek net/bluetooth/hci_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6509f785dd1481..97221d1fa883d1 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3765,9 +3765,10 @@ void hci_unregister_dev(struct hci_dev *hdev) cancel_work_sync(&hdev->power_on); - hci_dev_do_close(hdev); - unregister_pm_notifier(&hdev->suspend_notifier); + cancel_work_sync(&hdev->suspend_prepare); + + hci_dev_do_close(hdev); if (!test_bit(HCI_INIT, &hdev->flags) && !hci_dev_test_flag(hdev, HCI_SETUP) && -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mDhSI51ZH18VRQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 00:47:57 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 4PMoIZ1ZH1/Y3AAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 00:47:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=mnmoran.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5C6CDA1CB4; Tue, 28 Jul 2020 00:47:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726455AbgG0Wrv (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 18:47:51 -0400 Received: from hoster906.com ([192.252.156.27]:57740 "EHLO hoster906.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbgG0Wru (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 18:47:50 -0400 X-Greylist: delayed 402 seconds by postgrey-1.27 at vger.kernel.org; Mon, 27 Jul 2020 18:47:50 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mnmoran.org; h=to:from :subject:message-id:date:mime-version:content-type :content-transfer-encoding; s=dkim; bh=aIGtX9zi9W5zjNuLkOa3D3TfS XfE3Ezgda+99Ph+dbA=; b=Oru7qi/6pyDtuCs8GkpFgKrW2v5viAKQGh+lstEEa 1Gm1FkhIx8av2EtdRuQr3OtVb3Ch8R90JEtqffx6NZYierdkYCOeqgYyOhveObq9 wJIKc7RH944zG0hoMw+cSOWTWULzmm7NxjF1sewAr+fj8QP6eZKP/wgWSd1IZp1Q uY= Received: (qmail 13785 invoked by uid 503); 27 Jul 2020 22:41:08 -0000 Received: from unknown (HELO ?192.168.254.79?) (pop-before-smtp@162.39.210.203) by hoster906.com with ESMTPA; 27 Jul 2020 22:41:08 -0000 To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> From: "Michael N. Moran" <mike@mnmoran.org> Subject: Mesh: Continuous Transaction Acknowledgment Message-ID: <20d1abee-8400-19a9-6f15-d3011a8a3d0a@mnmoran.org> Date: Mon, 27 Jul 2020 18:41:02 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.21 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5C6CDA1CB4 X-Rspamd-UID: 866807 I'm using a clone of bluez master on a Fedora 32 system. I was using the Fedora 32 bluez-5.54 and bluez-mesh-5.54-1 packages, but there are some issues when using mesh-test where opcodes are using the wrong byte-order that has been fixed in master. Otherwise, mesh was working OK and I was able to provision and configure my device using mesh-cfgclient. However, running the master branch code I am having a problem where provisioning does not complete and in the end, a Transaction Acknowledgment for my Random PDU is sent endlessly. The bluetooth-meshd does not seem to be sending a LE Set Advertise Enable to DISABLE advertising. I assume that bluetooth-meshd has a timer that that fires that should disable the advertisement after some period of time (150ms), but the code is a bit opaque to my eyes. I have a btmon trace the shows the problem if needed. Also, the btmon trace shows that there are two LE Set Advertise Enable (DISABLE) HCI commands in a row just before the LE Set Advertising Data is issued for the offending Transaction Acknowledgment. Thoughts? -- Michael N. Moran (h) 770 704 9751 218 Wilshire Terrace (c) 678 521 5460 White, GA, USA 30184 http://mnmoran.org Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SI2WAjVgH18VRQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 01:16:05 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id mAtqATVgH1+wJwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 01:16:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C0ECE41432; Tue, 28 Jul 2020 01:15:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726620AbgG0XP5 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 19:15:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726313AbgG0XP5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 19:15:57 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29531C061794 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 16:15:57 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id w17so13599763otl.4 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 16:15:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ECEwATKpjiwoPaJQLx1KlRnXodk6DB4h6BgLx+5ivDk=; b=FDuyQSMKy83wjoyim0KV9XMuuPl+hg/lut29FbVqXzwcxXB83DfzCIkwHlgt+DoYag rNx/10nYH6RXmWhMQUz/IKqGJ/ezqKUsPaHAa0lXG+7xyQ8VZp+n+xZ9h2L7hj7XVe2c rH9sToVNXip0xOu0JNmgd2wS96ZyqCkoMVrgl8mLOeCzITHq4szxFJXPP8jnGp7GrQlT wIDG53xsfxqZytIZjvtTnwcMUE0AFCGV7PmS4nPa4vuVDncEO6FJtHxKqb2oTEAotQ9N HAdBBWQ7YggXqkkPzuGur99oLuwzBJDswwUak8h2Gz4W86H5UyWFDbGzyWLzN2ZtTlAr MnVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ECEwATKpjiwoPaJQLx1KlRnXodk6DB4h6BgLx+5ivDk=; b=YyvRQeZTCQGlPtOaLQeV+kjyq7cYL111i1D3GmFSXlK0mljsl9YysPVMoVLeLOz3Ff j38WrDwRoX2wSjfKXhpeJIfIiyJHkZhM0Pyjgug2awhBKn9vnYyK7Xl16ZDGYITaKIBN xkvRTxXLXt/oWHoUhTRTDoaSfQ98oCzHqo7uKbiJ/EihFWuN/jc96wwkecFXhjNNkuEl M5mBuwcqkrFwbKriw3fs9O0cyqYnVUkQWz4r/RL4LEavstWCqHJ7uChA1nD/7GFpPGoH LXYhGGqzahEinzsVF+4E7FSeH+5xzyJ42nb1VJZaoyxnEgU1WOdy57fe4GSFB+51gU42 TO8w== X-Gm-Message-State: AOAM5307ZdxGeM8uBn6xiQaVFYSwtHhgKo33K1JSWt5AExj90xakaGFe syJ8vUNlY9WbxJ9PZzL/YSJpaswgnYpW9dVm1qHfSqfE X-Google-Smtp-Source: ABdhPJxK8zKSnlollauZNCo6kafSUoY2Gh2k/1G0iO1oNMJ/ytYznEdKCcDGX9cQPK2ULOI2iXwmhjcCTENc3m8WeaI= X-Received: by 2002:a9d:5e18:: with SMTP id d24mr21585329oti.88.1595891756491; Mon, 27 Jul 2020 16:15:56 -0700 (PDT) MIME-Version: 1.0 References: <20200724140305.111507-1-committed@heine.so> In-Reply-To: <20200724140305.111507-1-committed@heine.so> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 27 Jul 2020 16:15:46 -0700 Message-ID: <CABBYNZL-gxf1TJr4Ckt9Zot4v5ZfKHXUS_tWEwndB==AUB24_A@mail.gmail.com> Subject: Re: [PATCH BlueZ v2] main: add missing comma after AlwaysPairable To: committed@heine.so Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: C0ECE41432 X-Rspamd-UID: ab447c Hi, On Fri, Jul 24, 2020 at 7:08 AM Michael Nosthoff <committed@heine.so> wrote: > > Commit 1880b2990866 ("core: Add AlwaysPairable to main.conf") added a new > key to supported_options but didn't add a comma. This leads to the > following error message on startup if the key 'PairableTimeout' is pesent: > > Unknown key PairableTimeout for group General in /etc/bluetooth/main.conf > > This probably also leads to ignoring the setting. > > Fixes: 1880b2990866 ("core: Add AlwaysPairable to main.conf") > --- > src/main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/main.c b/src/main.c > index ec7a9fbd7..2c083de67 100644 > --- a/src/main.c > +++ b/src/main.c > @@ -79,7 +79,7 @@ static const char *supported_options[] = { > "Name", > "Class", > "DiscoverableTimeout", > - "AlwaysPairable" > + "AlwaysPairable", > "PairableTimeout", > "DeviceID", > "ReverseServiceDiscovery", > -- > 2.25.1 Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IM+TGJVhH19iUwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 01:21:57 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SITbFpVhH18EZAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 01:21:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 66DC1A1974; Tue, 28 Jul 2020 01:21:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726538AbgG0XVw (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 27 Jul 2020 19:21:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbgG0XVw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 27 Jul 2020 19:21:52 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 093DFC061794 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 16:21:52 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id p26so3465623oos.7 for <linux-bluetooth@vger.kernel.org>; Mon, 27 Jul 2020 16:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Czxsi1VLXDgZxl/6xdZpf6T03KJMWWKGdnz2cw9JQjA=; b=DJ0md3KmCxQU0G1sQfXHC1CzY72SBjgLd6ggNhcocKbdQq33FtSFRBy/Sc8xrF8HTW hi4hjm4AhxrW8cn4EJDN6u6x0grShYwGyFIkBEJaz3EGkwt1O7zrcELFqcAiu8DXIEr5 fVexlO04+IJJXaFr2dpaMaStzbWzOPkCZ8SdHcaAVjBIcMJ2WGwWCaWS1CHd1cjM4gRx 1tNKhobY6Z9kKePL4oBHJ7TPk2Q7GPaUjNRpvcg2JcPgf+cKvUi/80rffPVXSex3KNlw f3jaLV+B/F8/SbbPKWmnWLYxIWDO3Zs7X5WUnIHGWxj3HXNyRTEkLFkIgYZKn/FbXoH9 njag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Czxsi1VLXDgZxl/6xdZpf6T03KJMWWKGdnz2cw9JQjA=; b=hxwb3vtuJ2S6yOZ8xlO5KLe4I2xEhqrX2fEgxcPN6xYZFpXLVcyP0ZZ0GpXSDLSrhB nVzGo0+jaGmqwibSCk6ljmpC4PTZVvcL4edfluUYTKt07WAqYwHr85zCA9sRl+rbykus CsLBVbBBODnYb00w7O8Cj3psawfIYtWnxBrC6vHv5IqJdditGH2vK4s6/ZWx9aAHc75N 4Pm65p3XdH3r5P8WaXAqdqEaRedOT+gi77ceZj2h2ea/JiaXojzrVNLl1OtS+hswpg1L bjpWQzvB4oZk4eKYUnf0K6i38yzWAwBL4mzSPhryksXdZcqam86wUWi9nID4Efmy8azj nVPQ== X-Gm-Message-State: AOAM5322ltu9Bsbtm3YSCRUzoDxQQbSkiOZdJmRsiSBmedzN+B7x4fU8 YYzFOIDkM7yLn1B/wwetHB7TAMWpB04W7V8084o= X-Google-Smtp-Source: ABdhPJzsmn8MPvl+4kEstmiHxkwTXAAQW8e/lSK2Yy5KFSHDAGmYoCtFTCIGJdWIH+LEBGpsr/QUbpqrsSyUDokAsuU= X-Received: by 2002:a4a:924b:: with SMTP id g11mr726214ooh.9.1595892111409; Mon, 27 Jul 2020 16:21:51 -0700 (PDT) MIME-Version: 1.0 References: <20200724122507.27671-1-454728735@qq.com> In-Reply-To: <20200724122507.27671-1-454728735@qq.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 27 Jul 2020 16:21:40 -0700 Message-ID: <CABBYNZ+7DuiuNZQ8AZnvSoGPQXD8pG0sVMqwy=xoGp2EWYQLPw@mail.gmail.com> Subject: Re: [PATCH BlueZ 1/1] src/agent.c : parse_io_capability Function optimization To: luokai <454728735@qq.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, luokai <luokai@uniontech.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 66DC1A1974 X-Rspamd-UID: c437fd Hi, On Fri, Jul 24, 2020 at 5:27 AM luokai <454728735@qq.com> wrote: > > From: luokai <luokai@uniontech.com> > > --- > src/agent.c | 28 ++++++++++++++++------------ > 1 file changed, 16 insertions(+), 12 deletions(-) > > diff --git a/src/agent.c b/src/agent.c > index e0ffcd22f..82baf608f 100644 > --- a/src/agent.c > +++ b/src/agent.c > @@ -957,20 +957,24 @@ static void agent_destroy(gpointer data) > agent_unref(agent); > } > > +static struct capability g_cap[] = { > + {"", IO_CAPABILITY_KEYBOARDDISPLAY}, > + {"DisplayOnly", IO_CAPABILITY_DISPLAYONLY}, > + {"DisplayYesNo", IO_CAPABILITY_DISPLAYYESNO}, > + {"KeyboardOnly", IO_CAPABILITY_KEYBOARDONLY}, > + {"NoInputNoOutput", IO_CAPABILITY_NOINPUTNOOUTPUT}, > + {"KeyboardDisplay", IO_CAPABILITY_KEYBOARDDISPLAY} We usually spaces after { and before }. > +}; > + > static uint8_t parse_io_capability(const char *capability) > { > - if (g_str_equal(capability, "")) > - return IO_CAPABILITY_KEYBOARDDISPLAY; > - if (g_str_equal(capability, "DisplayOnly")) > - return IO_CAPABILITY_DISPLAYONLY; > - if (g_str_equal(capability, "DisplayYesNo")) > - return IO_CAPABILITY_DISPLAYYESNO; > - if (g_str_equal(capability, "KeyboardOnly")) > - return IO_CAPABILITY_KEYBOARDONLY; > - if (g_str_equal(capability, "NoInputNoOutput")) > - return IO_CAPABILITY_NOINPUTNOOUTPUT; > - if (g_str_equal(capability, "KeyboardDisplay")) > - return IO_CAPABILITY_KEYBOARDDISPLAY; > + size_t count = sizeof(g_cap) / sizeof(g_cap[0]); If I recall correctly we do have macros for ARRAY_SIZE, check src/shared/util.h, btw there also seems to be a problem with the formatting on the above line: Applying: src/agent.c : parse_io_capability Function optimization .git/rebase-apply/patch:36: trailing whitespace. size_t count = sizeof(g_cap) / sizeof(g_cap[0]); error: 1 line adds whitespace errors. > + for (size_t i = 0; i < count; i++) > + { > + if(g_str_equal(capability, g_cap[i].cap)) { > + return g_cap[i].parse_capability; > + } > + } > return IO_CAPABILITY_INVALID; > } > > -- > 2.20.1 > > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sCwfCaDMH1+EQQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 08:58:40 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QCN8B6DMH1+nWgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 08:58:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 29D9FA1EE4; Tue, 28 Jul 2020 08:58:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727001AbgG1G6b convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 02:58:31 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:48544 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726967AbgG1G6b (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 02:58:31 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 56BFCCECCC; Tue, 28 Jul 2020 09:08:31 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [Bluez PATCH] main: adding configurable eir_max_name_len From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200727173720.2700327-1-alainm@chromium.org> Date: Tue, 28 Jul 2020 08:58:29 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Transfer-Encoding: 8BIT Message-Id: <17DA93F5-AB77-4C40-A5F2-38D8FE6C98A3@holtmann.org> References: <20200727173720.2700327-1-alainm@chromium.org> To: Alain Michaud <alainm@chromium.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: 29D9FA1EE4 X-Rspamd-UID: 10c020 Hi Alain, > This change adds support for a configurable eir_max_name_len for > platforms which requires a larger than 48 bytes complete name in EIR. > > From bluetoothctl: > [bluetooth]# system-alias > 012345678901234567890123456789012345678901234567890123456789 > Changing 012345678901234567890123456789012345678901234567890123456789 > succeeded > [CHG] Controller DC:71:96:69:02:89 Alias: > 012345678901234567890123456789012345678901234567890123456789 > > From btmon: > < HCI Command: Write Local Name (0x03|0x0013) plen 248 #109 > [hci0] 88.567990 > Name: > 012345678901234567890123456789012345678901234567890123456789 >> HCI Event: Command Complete (0x0e) plen 4 > #110 [hci0] 88.663854 > Write Local Name (0x03|0x0013) ncmd 1 > Status: Success (0x00) > @ MGMT Event: Local Name Changed (0x0008) plen 260 > {0x0004} [hci0] 88.663948 > Name: > 012345678901234567890123456789012345678901234567890123456789 > Short name: > < HCI Command: Write Extended Inquiry Response (0x03|0x0052) plen 241 > FEC: Not required (0x00) > Name (complete): > 012345678901234567890123456789012345678901234567890123456789 > TX power: 12 dBm > Device ID: Bluetooth SIG assigned (0x0001) > Vendor: Google (224) > Product: 0xc405 > Version: 0.5.6 (0x0056) > 16-bit Service UUIDs (complete): 7 entries > Generic Access Profile (0x1800) > Generic Attribute Profile (0x1801) > Device Information (0x180a) > A/V Remote Control (0x110e) > A/V Remote Control Target (0x110c) > Handsfree Audio Gateway (0x111f) > Audio Source (0x110a) >> HCI Event: Command Complete (0x0e) plen 4 > Write Extended Inquiry Response (0x03|0x0052) ncmd 1 > Status: Success (0x00) > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > Signed-off-by: Alain Michaud <alainm@chromium.org> > --- > > doc/mgmt-api.txt | 1 + > src/adapter.c | 10 +++++++++- > src/hcid.h | 1 + > src/main.c | 5 +++++ > src/main.conf | 5 +++++ > 5 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt > index ca0d38469..1bc0f0c12 100644 > --- a/doc/mgmt-api.txt > +++ b/doc/mgmt-api.txt > @@ -3279,6 +3279,7 @@ Read Default System Configuration Command > 0x0019 LE Connection Latency > 0x001a LE Connection Supervision Timeout > 0x001b LE Autoconnect Timeout > + 0x001c Max EIR Name Length we can certainly do this, but I prefer that do this for LE and BR/EDR and name it that way as well. > > This command can be used at any time and will return a list of > supported default parameters as well as their current value. > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..3adc67b63 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -2375,7 +2375,7 @@ static bool parse_pathloss(DBusMessageIter *value, > return true; > } > > -static bool parse_transport(DBusMessageIter *value, > +static bool parse_transport(DBusMessageIter *value, > struct discovery_filter *filter) > { > char *transport_str; > @@ -4435,6 +4435,14 @@ static void load_default_system_params(struct btd_adapter *adapter) > len += sizeof(params[i].u16); > } > > + if (main_opts.default_params.eir_max_name_len) { > + params[i].entry.type = 0x001c; > + params[i].entry.length = sizeof(params[i].u16); > + params[i].u16 = main_opts.default_params.eir_max_name_len; > + ++i; > + len += sizeof(params[i].u16); > + } > + Do you really want to keep it as uint16_t or is that just laziness since changing the kernel to support anything other than uint16_t is complicated? On a side note, you need to provide a uint16_t value in little endian to the MGMT wire protocol. > err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG, > adapter->dev_id, len, params, NULL, NULL, NULL); > if (!err) > diff --git a/src/hcid.h b/src/hcid.h > index 5f249ebf9..c9b59a374 100644 > --- a/src/hcid.h > +++ b/src/hcid.h > @@ -93,6 +93,7 @@ struct main_opts { > uint16_t le_conn_latency; > uint16_t le_conn_lsto; > uint16_t le_autoconnect_timeout; > + uint16_t eir_max_name_len; > } default_params; > > > diff --git a/src/main.c b/src/main.c > index ec7a9fbd7..74876e01d 100644 > --- a/src/main.c > +++ b/src/main.c > @@ -123,6 +123,7 @@ static const char *controller_options[] = { > "LEConnectionLatency", > "LEConnectionSupervisionTimeout", > "LEAutoconnecttimeout", > + "EirMaxNameLength", > NULL > }; > > @@ -433,6 +434,10 @@ static void parse_controller_config(GKeyFile *config) > &main_opts.default_params.le_autoconnect_timeout, > 0x0001, > 0x4000}, > + { "EirMaxNameLength", > + &main_opts.default_params.eir_max_name_len, > + 0x0001, > + 0x00EE}, > }; > uint16_t i; > > diff --git a/src/main.conf b/src/main.conf > index f41203b96..7ecac5930 100644 > --- a/src/main.conf > +++ b/src/main.conf > @@ -148,6 +148,11 @@ > #LEConnectionSupervisionTimeout= > #LEAutoconnecttimeout= > > +# EIR Max Name. This is the maximum length for the COMPLETE_NAME EIR section. > +# If the name length exceeds this size, a SHORT_NAME section is used. > +# Default: 48 > +#EirMaxNameLength = 48 > + > [GATT] > # GATT attribute cache. > # Possible values: Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cDhcD+jNH1/7igAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 09:04:08 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id ODQDDujNH19juQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 09:04:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CD8C4A2C9A; Tue, 28 Jul 2020 09:04:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727037AbgG1HEA convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 03:04:00 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:60583 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbgG1HEA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 03:04:00 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 9E87ACECCC; Tue, 28 Jul 2020 09:13:59 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Bluetooth: adding configurable eir_max_name_len From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200727174641.1.Ic2cb84fb029a345c9e3901378717d1ab4e9246ab@changeid> Date: Tue, 28 Jul 2020 09:03:57 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Transfer-Encoding: 8BIT Message-Id: <A475AABF-D0C9-4D22-9FCC-5D1DD346247E@holtmann.org> References: <20200727174641.1.Ic2cb84fb029a345c9e3901378717d1ab4e9246ab@changeid> To: Alain Michaud <alainm@chromium.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: CD8C4A2C9A X-Rspamd-UID: c84a6d Hi Alain, > This change adds support for a configurable eir_max_name_len for > platforms which requires a larger than 48 bytes complete name in EIR. > > From bluetoothctl: > [bluetooth]# system-alias > 012345678901234567890123456789012345678901234567890123456789 > Changing 012345678901234567890123456789012345678901234567890123456789 > succeeded > [CHG] Controller DC:71:96:69:02:89 Alias: > 012345678901234567890123456789012345678901234567890123456789 > > From btmon: > < HCI Command: Write Local Name (0x03|0x0013) plen 248 #109 > [hci0] 88.567990 > Name: > 012345678901234567890123456789012345678901234567890123456789 >> HCI Event: Command Complete (0x0e) plen 4 #110 [hci0] 88.663854 > Write Local Name (0x03|0x0013) ncmd 1 > Status: Success (0x00) > @ MGMT Event: Local Name Changed (0x0008) plen 260 > {0x0004} [hci0] 88.663948 > Name: > 012345678901234567890123456789012345678901234567890123456789 > Short name: > < HCI Command: Write Extended Inquiry Response (0x03|0x0052) plen 241 > #111 [hci0] 88.663977 > FEC: Not required (0x00) > Name (complete): > 012345678901234567890123456789012345678901234567890123456789 > TX power: 12 dBm > Device ID: Bluetooth SIG assigned (0x0001) > Vendor: Google (224) > Product: 0xc405 > Version: 0.5.6 (0x0056) > 16-bit Service UUIDs (complete): 7 entries > Generic Access Profile (0x1800) > Generic Attribute Profile (0x1801) > Device Information (0x180a) > A/V Remote Control (0x110e) > A/V Remote Control Target (0x110c) > Handsfree Audio Gateway (0x111f) > Audio Source (0x110a) >> HCI Event: Command Complete (0x0e) plen 4 #112 [hci0] 88.664874 > Write Extended Inquiry Response (0x03|0x0052) ncmd 1 > Status: Success (0x00) > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Signed-off-by: Alain Michaud <alainm@chromium.org> > > --- > > include/net/bluetooth/hci_core.h | 1 + > net/bluetooth/hci_core.c | 1 + > net/bluetooth/hci_request.c | 29 +++++++++++++++++++++-------- > net/bluetooth/mgmt_config.c | 5 +++++ > 4 files changed, 28 insertions(+), 8 deletions(-) > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h > index bee1b4778ccc..e08f92e7a9ca 100644 > --- a/include/net/bluetooth/hci_core.h > +++ b/include/net/bluetooth/hci_core.h > @@ -298,6 +298,7 @@ struct hci_dev { > __u8 dev_name[HCI_MAX_NAME_LENGTH]; > __u8 short_name[HCI_MAX_SHORT_NAME_LENGTH]; > __u8 eir[HCI_MAX_EIR_LENGTH]; > + __u16 eir_max_name_len; > __u16 appearance; > __u8 dev_class[3]; > __u8 major_class; > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index 6509f785dd14..b2507bd6613a 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -3536,6 +3536,7 @@ struct hci_dev *hci_alloc_dev(void) > hdev->adv_instance_cnt = 0; > hdev->cur_adv_instance = 0x00; > hdev->adv_instance_timeout = 0; > + hdev->eir_max_name_len = 48; > > hdev->sniff_max_interval = 800; > hdev->sniff_min_interval = 80; > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > index 7c0c2fda04ad..f4714370b7e7 100644 > --- a/net/bluetooth/hci_request.c > +++ b/net/bluetooth/hci_request.c > @@ -578,17 +578,21 @@ static u8 *create_uuid128_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len) > static void create_eir(struct hci_dev *hdev, u8 *data) > { > u8 *ptr = data; > + u8 size_remaining = HCI_MAX_EIR_LENGTH; > size_t name_len; > > name_len = strlen(hdev->dev_name); > > if (name_len > 0) { > /* EIR Data type */ > - if (name_len > 48) { > - name_len = 48; > + if (name_len > min_t(u16, (HCI_MAX_EIR_LENGTH - 2), > + hdev->eir_max_name_len)) { > + name_len = min_t(u16, (HCI_MAX_EIR_LENGTH - 2), > + hdev->eir_max_name_len); if we have proper input validation we could just skip this hard to read code. > ptr[1] = EIR_NAME_SHORT; > - } else > + } else { > ptr[1] = EIR_NAME_COMPLETE; > + } > > /* EIR Data length */ > ptr[0] = name_len + 1; > @@ -596,17 +600,21 @@ static void create_eir(struct hci_dev *hdev, u8 *data) > memcpy(ptr + 2, hdev->dev_name, name_len); > > ptr += (name_len + 2); > + size_remaining -= (name_len + 2); > } > > - if (hdev->inq_tx_power != HCI_TX_POWER_INVALID) { > + if (hdev->inq_tx_power != HCI_TX_POWER_INVALID && > + size_remaining >= 3) { > ptr[0] = 2; > ptr[1] = EIR_TX_POWER; > ptr[2] = (u8) hdev->inq_tx_power; > > ptr += 3; > + size_remaining -= 3; > } > > - if (hdev->devid_source > 0) { > + if (hdev->devid_source > 0 && > + size_remaining >= 10) { > ptr[0] = 9; > ptr[1] = EIR_DEVICE_ID; > > @@ -616,11 +624,16 @@ static void create_eir(struct hci_dev *hdev, u8 *data) > put_unaligned_le16(hdev->devid_version, ptr + 8); > > ptr += 10; > + size_remaining -= 10; > } > > - ptr = create_uuid16_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data)); > - ptr = create_uuid32_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data)); > - ptr = create_uuid128_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data)); > + ptr = create_uuid16_list(hdev, ptr, size_remaining); > + size_remaining = HCI_MAX_EIR_LENGTH - (ptr - data); > + > + ptr = create_uuid32_list(hdev, ptr, size_remaining); > + size_remaining = HCI_MAX_EIR_LENGTH - (ptr - data); > + > + ptr = create_uuid128_list(hdev, ptr, size_remaining); > } > > void __hci_req_update_eir(struct hci_request *req) > diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c > index b30b571f8caf..420ea322a5b7 100644 > --- a/net/bluetooth/mgmt_config.c > +++ b/net/bluetooth/mgmt_config.c > @@ -67,6 +67,7 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > HDEV_PARAM_U16(0x001a, le_supv_timeout), > HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b, > def_le_autoconnect_timeout), > + HDEV_PARAM_U16(0x001c, eir_max_name_len), We should really have range validation for these parameters. And we should document ranges in mgmt-api.txt as well. > }; > struct mgmt_rp_read_def_system_config *rp = (void *)params; > > @@ -138,6 +139,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > case 0x0019: > case 0x001a: > case 0x001b: > + case 0x001c: > if (len != sizeof(u16)) { > bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", > len, sizeof(u16), type); > @@ -251,6 +253,9 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > hdev->def_le_autoconnect_timeout = > msecs_to_jiffies(TLV_GET_LE16(buffer)); > break; > + case 0x0001c: > + hdev->eir_max_name_len = TLV_GET_LE16(buffer); > + break; > default: > bt_dev_warn(hdev, "unsupported parameter %u", type); > break; Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gDjtLAXOH1/5MQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 09:04:37 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id AITiKgXOH1+hDgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 09:04:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C0AB3418A1; Tue, 28 Jul 2020 09:04:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727051AbgG1HEb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 03:04:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbgG1HEb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 03:04:31 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB039C061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 00:04:30 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id b186so126810pfb.9 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 00:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=k3Tti1y5Bjyb7ZPVuwuxQs125pNEWWZEmzoggkjoZa4=; b=OxureNHLzRTRL7rzDdsYfLiC/VdrBDAwKeB/qltP4XNeNMs4TzRmRys7sokkueEbwo v6z+c125itwltj24UbvPz5aBPqWcBBwrB9DspFhR4Ub6EI8cETjHDlUy6BdsDNS2bKLM ZmdtaCs3dBoVtIbPcotQ9OjQRJBmg7vhyaG2zPTKz+wDv9z+iwvFvLBJNSwzlvpkKxkX FBaZUs3kpGv+YklVVUJxQIuqliCge1icGEKqosIYQl4UD+mNUNA9vYa3PtgTkwjF0OxX n2GUj3sr14zH0YNG0xkTU8+8Mg2OgUole1u05Tky3nT1d6TPNFUmnXlSDONc4pFkykNG hC2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=k3Tti1y5Bjyb7ZPVuwuxQs125pNEWWZEmzoggkjoZa4=; b=Ll7PG7vAX8++2qM3N4swI/u1Xaoq0o/4vc5IAlDMyVRLIh93so9eHp0d2y45L75HxF lL3bkcF1FvXcy0Pv6c9QRRLHPZ3UyBRQVb9AGcmB01sc/5ohntQsU6c6tGGk4aEcbiql x0xLlISm/rv3MBjurvxDKxqZztzs1SqlGK0BnIUCCWGP22RhdaXZCmoTQH8NaPJ08mQK UA9dkD1CcRuwvgarWHM4o2lrToZglj4pdjVj1wlGVAfDPizNS5ZkuU8ZLNREwvRXK36A gG7tYX7KigPcdpc/8FIzCNDagvwoFRu1EkcGT8QxLysqiCQWVOE98fvVQ1l6EpNRZkyX gyEg== X-Gm-Message-State: AOAM532mWApc9l9usltN6GDJ9HMHnPZSl5UuHKRDjG8bqwDc6u0hufOC 1uhZL5ikHLsPMkRYKtj/iIfaFPJR8sI= X-Google-Smtp-Source: ABdhPJzi9m740DPVDsOJ9O6zjBNCwwBy0aLqXjCE3Jc+yvGzBJPAEB9wEIEbX6jUDn8WM4EkE8J6oA== X-Received: by 2002:a05:6a00:2ba:: with SMTP id q26mr23935437pfs.135.1595919869832; Tue, 28 Jul 2020 00:04:29 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id n2sm17624389pfq.140.2020.07.28.00.04.29 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 00:04:29 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [RFC] Bluetooth: L2CAP: Fix to handling fragmented header Date: Tue, 28 Jul 2020 00:04:28 -0700 Message-Id: <20200728070428.1754257-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: C0AB3418A1 X-Rspamd-UID: d40686 From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Bluetooth Core Specification v5.2, Vol. 3, Part A, section 1.4, table 1.1: 'Start Fragments always either begin with the first octet of the Basic L2CAP header of a PDU or they have a length of zero (see [Vol 2] Part B, Section 6.6.2).' This text has been changed recently as it previously stated: 'Start Fragments always begin with the Basic L2CAP header of a PDU.' Apparently this was changed by the following errata: https://www.bluetooth.org/tse/errata_view.cfm?errata_id=10216 In past this has not been a problem but it seems new controllers are apparently doing it as it has been reported in Zephyr: https://github.com/zephyrproject-rtos/zephyr/issues/26900 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> --- net/bluetooth/l2cap_core.c | 104 +++++++++++++++++++++++++++++-------- 1 file changed, 83 insertions(+), 21 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index ade83e224567..193bea314222 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -8269,6 +8269,63 @@ static void l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) mutex_unlock(&conn->chan_lock); } +/* Append fragment into frame respecting the maximum len of rx_skb */ +static int l2cap_recv_frag(struct l2cap_conn *conn, struct sk_buff *skb, + u16 len) +{ + if (!conn->rx_skb) { + /* Allocate skb for the complete frame (with header) */ + conn->rx_skb = bt_skb_alloc(len, GFP_KERNEL); + if (!conn->rx_skb) + return -ENOMEM; + /* Init rx_len */ + conn->rx_len = len; + } + + /* Copy as much as the rx_skb can hold */ + len = min_t(u16, len, skb->len); + skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, len), len); + skb_pull(skb, len); + conn->rx_len -= len; + + return len; +} + +static int l2cap_recv_header(struct l2cap_conn *conn, struct sk_buff *skb) +{ + struct l2cap_hdr *hdr; + struct sk_buff *rx_skb; + int len; + + /* Append just enough to complete the header */ + len = l2cap_recv_frag(conn, skb, L2CAP_HDR_SIZE - conn->rx_skb->len); + + /* If header could not be read just continue */ + if (len < 0 || conn->rx_skb->len < L2CAP_HDR_SIZE) + return len; + + rx_skb = conn->rx_skb; + conn->rx_skb = NULL; + + hdr = (struct l2cap_hdr *) rx_skb->data; + + /* Append existing rx_skb as that allocates only enough for the + * headers. + */ + len = l2cap_recv_frag(conn, rx_skb, + __le16_to_cpu(hdr->len) + L2CAP_HDR_SIZE); + kfree_skb(rx_skb); + + return len; +} + +static void l2cap_recv_reset(struct l2cap_conn *conn) +{ + kfree_skb(conn->rx_skb); + conn->rx_skb = NULL; + conn->rx_len = 0; +} + void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) { struct l2cap_conn *conn = hcon->l2cap_data; @@ -8291,19 +8348,19 @@ void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) case ACL_START: case ACL_START_NO_FLUSH: case ACL_COMPLETE: - if (conn->rx_len) { + if (conn->rx_skb) { BT_ERR("Unexpected start frame (len %d)", skb->len); - kfree_skb(conn->rx_skb); - conn->rx_skb = NULL; - conn->rx_len = 0; + l2cap_recv_reset(conn); l2cap_conn_unreliable(conn, ECOMM); } - /* Start fragment always begin with Basic L2CAP header */ + /* Start fragment may not contain the L2CAP header so just + * copy the initial byte when that happens. + */ if (skb->len < L2CAP_HDR_SIZE) { - BT_ERR("Frame is too short (len %d)", skb->len); - l2cap_conn_unreliable(conn, ECOMM); - goto drop; + if (l2cap_recv_frag(conn, skb, L2CAP_HDR_SIZE) < 0) + goto drop; + return; } hdr = (struct l2cap_hdr *) skb->data; @@ -8324,38 +8381,43 @@ void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) goto drop; } - /* Allocate skb for the complete frame (with header) */ - conn->rx_skb = bt_skb_alloc(len, GFP_KERNEL); - if (!conn->rx_skb) + /* Append fragment into frame (with header) */ + if (l2cap_recv_frag(conn, skb, len) < 0) goto drop; - skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), - skb->len); - conn->rx_len = len - skb->len; break; case ACL_CONT: BT_DBG("Cont: frag len %d (expecting %d)", skb->len, conn->rx_len); - if (!conn->rx_len) { + if (!conn->rx_skb) { BT_ERR("Unexpected continuation frame (len %d)", skb->len); l2cap_conn_unreliable(conn, ECOMM); goto drop; } + /* Complete the L2CAP header if it has not been read */ + if (conn->rx_skb->len < L2CAP_HDR_SIZE) { + if (l2cap_recv_header(conn, skb) < 0) { + l2cap_conn_unreliable(conn, ECOMM); + goto drop; + } + + /* Header still could not be read just continue */ + if (conn->rx_skb->len < L2CAP_HDR_SIZE) + return; + } + if (skb->len > conn->rx_len) { BT_ERR("Fragment is too long (len %d, expected %d)", skb->len, conn->rx_len); - kfree_skb(conn->rx_skb); - conn->rx_skb = NULL; - conn->rx_len = 0; + l2cap_recv_reset(conn); l2cap_conn_unreliable(conn, ECOMM); goto drop; } - skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), - skb->len); - conn->rx_len -= skb->len; + /* Append fragment into frame (with header) */ + l2cap_recv_frag(conn, skb, skb->len); if (!conn->rx_len) { /* Complete frame received. l2cap_recv_frame -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QEz5M2fOH1+EQQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 09:06:15 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0CauMmfOH18GfgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 09:06:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0F95940507; Tue, 28 Jul 2020 09:06:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727087AbgG1HGC convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 03:06:02 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:57429 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726874AbgG1HGC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 03:06:02 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 8AD33CECCC; Tue, 28 Jul 2020 09:16:01 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Bluetooth: Fix suspend notifier race From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200727142231.1.I7ebe9eaf684ddb07ae28634cb4d28cf7754641f1@changeid> Date: Tue, 28 Jul 2020 09:05:59 +0200 Cc: chromeos-bluetooth-upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev <netdev@vger.kernel.org>, kernel list <linux-kernel@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org> Content-Transfer-Encoding: 8BIT Message-Id: <534A8246-5B96-487F-A042-43F717A1CA24@holtmann.org> References: <20200727142231.1.I7ebe9eaf684ddb07ae28634cb4d28cf7754641f1@changeid> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0F95940507 X-Rspamd-UID: 9ceedd Hi Abhishek, > Unregister from suspend notifications and cancel suspend preparations > before running hci_dev_do_close. Otherwise, the suspend notifier may > race with unregister and cause cmd_timeout even after hdev has been > freed. > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > --- > Hi Marcel, > > This fixes a race between hci_unregister_dev and the suspend notifier. > Without these changes, we encountered the following kernel panic when > a USB disconnect (with btusb) occurred on resume: > > [ 832.578518] Bluetooth: hci_core.c:hci_cmd_timeout() hci0: command 0x0c05 tx timeout > [ 832.586200] BUG: kernel NULL pointer dereference, address: 0000000000000000 > [ 832.586203] #PF: supervisor read access in kernel mode > [ 832.586205] #PF: error_code(0x0000) - not-present page > [ 832.586206] PGD 0 P4D 0 > [ 832.586210] PM: suspend exit > [ 832.608870] Oops: 0000 [#1] PREEMPT SMP NOPTI > [ 832.613232] CPU: 3 PID: 10755 Comm: kworker/3:7 Not tainted 5.4.44-04894-g1e9dbb96a161 #1 > [ 832.630036] Workqueue: events hci_cmd_timeout [bluetooth] > [ 832.630046] RIP: 0010:__queue_work+0xf0/0x374 > [ 832.630051] RSP: 0018:ffff9b5285f1fdf8 EFLAGS: 00010046 > [ 832.674033] RAX: ffff8a97681bac00 RBX: 0000000000000000 RCX: ffff8a976a000600 > [ 832.681162] RDX: 0000000000000000 RSI: 0000000000000009 RDI: ffff8a976a000748 > [ 832.688289] RBP: ffff9b5285f1fe38 R08: 0000000000000000 R09: ffff8a97681bac00 > [ 832.695418] R10: 0000000000000002 R11: ffff8a976a0006d8 R12: ffff8a9745107600 > [ 832.698045] usb 1-6: new full-speed USB device number 119 using xhci_hcd > [ 832.702547] R13: ffff8a9673658850 R14: 0000000000000040 R15: 000000000000001e > [ 832.702549] FS: 0000000000000000(0000) GS:ffff8a976af80000(0000) knlGS:0000000000000000 > [ 832.702550] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [ 832.702550] CR2: 0000000000000000 CR3: 000000010415a000 CR4: 00000000003406e0 > [ 832.702551] Call Trace: > [ 832.702558] queue_work_on+0x3f/0x68 > [ 832.702562] process_one_work+0x1db/0x396 > [ 832.747397] worker_thread+0x216/0x375 > [ 832.751147] kthread+0x138/0x140 > [ 832.754377] ? pr_cont_work+0x58/0x58 > [ 832.758037] ? kthread_blkcg+0x2e/0x2e > [ 832.761787] ret_from_fork+0x22/0x40 > [ 832.846191] ---[ end trace fa93f466da517212 ]--- > > The suspend notifier handler seemed to be scheduling commands even after > it was cleaned up and this was resulting in a panic in cmd_timeout (when > it tries to requeue the cmd_timer). > > This was tested on 5.4 kernel with a suspend+resume stress test for 500+ > iterations. I also confirmed that after a usb disconnect, the suspend > notifier times out before the USB device is probed again (fixing the > original race between the usb_disconnect + probe and the notifier). Can you please structure the commit message so that the oops is included. It is valuable information Everything after --- is a personal note to the maintainer. And we might want to include a Fixes tag as well. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gNaeGWbPH1/IlgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 09:10:30 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UBZyGGbPH19Y3gEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 09:10:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7B40041763; Tue, 28 Jul 2020 09:10:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727078AbgG1HKX convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 03:10:23 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:45014 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgG1HKW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 03:10:22 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id AD970CECCD; Tue, 28 Jul 2020 09:20:22 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v4] Bluetooth: btusb: Fix and detect most of the Chinese Bluetooth controllers From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <0bba3f22-a232-3c07-1b05-73e6d38dab8a@gmail.com> Date: Tue, 28 Jul 2020 09:10:20 +0200 Cc: BlueZ <linux-bluetooth@vger.kernel.org>, Johan Hedberg <johan.hedberg@gmail.com> Content-Transfer-Encoding: 8BIT Message-Id: <BB91A6AF-35AD-4BFF-BD1A-49292C064A43@holtmann.org> References: <0bba3f22-a232-3c07-1b05-73e6d38dab8a@gmail.com> To: Ismael Ferreras Morezuelas <swyterzone@gmail.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.89 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7B40041763 X-Rspamd-UID: 76d1fd Hi Ismael, > For some reason they tend to squat on the very first CSR/ > Cambridge Silicon Radio VID/PID instead of paying fees. > > This is an extremely common problem; the issue goes as back as 2013 > and these devices are only getting more popular, even rebranded by > reputable vendors and sold by retailers everywhere. > > So, at this point in time there are hundreds of modern dongles reusing > the ID of what originally was an early Bluetooth 1.1 controller. > > Linux is the only place where they don't work due to spotty checks > in our detection code. It only covered a minimum subset. > > So what's the big idea? Take advantage of the fact that all CSR > chips report the same internal version as both the LMP sub-version and > HCI revision number. It always matches, couple that with the manufacturer > code, that rarely lies, and we now have a good idea of who is who. > > Additionally, by compiling a list of user-reported HCI/lsusb dumps, and > searching around for legit CSR dongles in similar product ranges we can > find what CSR BlueCore firmware supported which Bluetooth versions. > > That way we can narrow down ranges of fakes for each of them. > > e.g. Real CSR dongles with LMP subversion 0x73 are old enough that > support BT 1.1 only; so it's a dead giveaway when some > third-party BT 4.0 dongle reuses it. > > So, to sum things up; there are multiple classes of fake controllers > reusing the same 0A12:0001 VID/PID. This has been broken for a while. > > Known 'fake' bcdDevices: 0x0100, 0x0134, 0x1915, 0x2520, 0x7558, 0x8891 > IC markings on 0x7558: FR3191AHAL 749H15143 (???) > > https://bugzilla.kernel.org/show_bug.cgi?id=60824 > > Fixes: 81cac64ba258ae (Deal with USB devices that are faking CSR vendor) > Reported-by: Michał Wiśniewski <brylozketrzyn@gmail.com> > Tested-by: Mike Johnson <yuyuyak@gmail.com> > Tested-by: Ricardo Rodrigues <ekatonb@gmail.com> > Tested-by: M.Hanny Sabbagh <mhsabbagh@outlook.com> > Tested-by: Oussama BEN BRAHIM <b.brahim.oussama@gmail.com> > Tested-by: Ismael Ferreras Morezuelas <swyterzone@gmail.com> > Signed-off-by: Ismael Ferreras Morezuelas <swyterzone@gmail.com> > --- > > Changes in v4: > * Chain the is_fake conditions with else ifs. > * Properly use le16_to_cpu() when needed. > > Changes in v3: > * Find an even better-er way of detecting which type is which; use the > best parts of v1 and v2 and combine them with previous feedback. > * Additionally, detect fakes by comparing against real BlueCore > firmware numbers and their supported protocol versions. > * Introduce HCI_QUIRK_BROKEN_ERR_DATA_REPORTING and use it on all > fake chips. It doesn't seem to cause any drawback, and if we > make it too specific a lot of these chips won't work at all, > so it's probably better than nothing. Other user reported > being able to finally pair with their stereo A2DP speaker > with this fix. > * Limit the use of btusb_setup_csr() only to cover 0A12:0001. > * Use bt_dev_warn for the fake detection notice. > * Remove all other noisy bt_dev_info() calls. > > Changes in v2: > * Find a better way of detecting which type is which; scrap the wonky >> =Bluetooth 1.2 protocol check and instead do what's described above. > * Move all the quirk logic to btusb_setup_csr(), simplify it a bit. > * Use a switch statement and list all the known broken bcdDevice > instead of trying to penalize the real CSR devices. > * Add two bt_dev_info() prints because this may be important in the > future, given the amount of variables we are playing with here. > * Try to keep my comments within a 80-column limit. > > Now I'm able to pair with Android devices, A2DP headphones, > DS4 controllers and more; whereas previously set up failed > and userland software couldn't even scan with it. > > This patch probably uncovers other quirks in some of these > previously *unusable* dongles, so it's probably a good start > point so that other fixes can be implemented on top. > > Looking forward to fine-tune these checks in the future. > Let me know what you think. > > drivers/bluetooth/btusb.c | 74 ++++++++++++++++++++++++++----- > include/net/bluetooth/bluetooth.h | 2 + > include/net/bluetooth/hci.h | 11 +++++ > net/bluetooth/hci_core.c | 6 ++- > 4 files changed, 81 insertions(+), 12 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qLKbGNbPH1/7igAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 09:12:22 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wH4sF9bPH19y7gEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 09:12:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E3CD4A1A52; Tue, 28 Jul 2020 09:12:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727854AbgG1HMI convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 03:12:08 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:50874 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgG1HMI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 03:12:08 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 93A20CECCD; Tue, 28 Jul 2020 09:22:07 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 1/2] Bluetooth: hci_h5: Set HCI_UART_RESET_ON_INIT to correct flags From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200721103652.1.Idbc7eddf1f24f750a8bbcbc8e06743736ae3be31@changeid> Date: Tue, 28 Jul 2020 09:12:05 +0200 Cc: Hans de Goede <hdegoede@redhat.com>, Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <BE8271CC-D9F4-4CE1-80A3-92E2F878B2B0@holtmann.org> References: <20200721103652.1.Idbc7eddf1f24f750a8bbcbc8e06743736ae3be31@changeid> To: Nicolas Boichat <drinkcat@chromium.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.07 / 15.00 / 200.00 X-Rspamd-Queue-Id: E3CD4A1A52 X-Rspamd-UID: a6cb93 Hi Nicolas, > HCI_UART_RESET_ON_INIT belongs in hdev_flags, not flags. > > Fixes: ce945552fde4a09 ("Bluetooth: hci_h5: Add support for serdev enumerated devices") > Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> > > --- > > drivers/bluetooth/hci_h5.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eLOfGxLQH1/7igAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 09:13:22 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gFDeGRLQH19ThAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 09:13:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B6372418A7; Tue, 28 Jul 2020 09:13:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727798AbgG1HNK (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 03:13:10 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:49209 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgG1HNJ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 03:13:09 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id D2B49CECCD; Tue, 28 Jul 2020 09:23:09 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Bluetooth: Return NOTIFY_DONE for hci_suspend_notifier From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200723104742.19780-1-max.chou@realtek.com> Date: Tue, 28 Jul 2020 09:13:08 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, netdev <netdev@vger.kernel.org>, linux-kernel@vger.kernel.org, alex_lu@realsil.com.cn, hildawu@realtek.com Content-Transfer-Encoding: 7bit Message-Id: <818B8B6F-F093-40DC-9B02-CFF0B9C9DE08@holtmann.org> References: <20200723104742.19780-1-max.chou@realtek.com> To: max.chou@realtek.com X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.55 / 15.00 / 200.00 X-Rspamd-Queue-Id: B6372418A7 X-Rspamd-UID: bcd2f7 Hi Max, > The original return is NOTIFY_STOP, but notifier_call_chain would stop > the future call for register_pm_notifier even registered on other Kernel > modules with the same priority which value is zero. > > Signed-off-by: Max Chou <max.chou@realtek.com> > --- > net/bluetooth/hci_core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aJaLJbrQH1/IlgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 09:16:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mMbhI7rQH18C1wEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 09:16:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 00A5D40507; Tue, 28 Jul 2020 09:16:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727858AbgG1HQE convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 03:16:04 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:55604 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727097AbgG1HQE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 03:16:04 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 70898CECCD; Tue, 28 Jul 2020 09:26:03 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [Bluez PATCH v2] doc: Add Suspend and Resume events From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200714125120.Bluez.v2.1.I9181af521cf0fba8f4315c9b89975848d437d6dd@changeid> Date: Tue, 28 Jul 2020 09:16:01 +0200 Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>, chromeos-bluetooth-upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, linux-bluetooth@vger.kernel.org, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Content-Transfer-Encoding: 8BIT Message-Id: <7E48B539-556A-4C34-B5B6-092422FCC87D@holtmann.org> References: <20200714125120.Bluez.v2.1.I9181af521cf0fba8f4315c9b89975848d437d6dd@changeid> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: 00A5D40507 X-Rspamd-UID: 349d35 Hi Abhishek, > Add Controller Suspend Event and Controller Resume Event to identify > suspend or resume of the Bluetooth stack has occurred. > > Also update Device Disconnected Event to indicate a new disconnect > reason: "Connection terminated by local host for suspend" > > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > --- > > Changes in v2: > - Moved Wake_Reason to first value > - Reduced Wake_Reason to not Bluetooth, unexpected event and remote wake > > doc/mgmt-api.txt | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 48 insertions(+) > > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt > index ca0d38469..e7a713824 100644 > --- a/doc/mgmt-api.txt > +++ b/doc/mgmt-api.txt > @@ -3834,6 +3834,7 @@ Device Disconnected Event > 2 Connection terminated by local host > 3 Connection terminated by remote host > 4 Connection terminated due to authentication failure > + 5 Connection terminated by local host for suspend > > Note that the local/remote distinction just determines which side > terminated the low-level connection, regardless of the > @@ -4577,3 +4578,50 @@ Advertisement Monitor Removed Event > > The event will only be sent to management sockets other than the > one through which the command was sent. > + > + > +Controller Suspend Event > +======================== > + > + Event code: 0x002d > + Controller Index: <controller_id> > + Event Parameters: Suspend_State (1 octet) > + > + This event indicates that the controller is suspended for host suspend. > + > + Possible values for the Suspend_State parameter: > + 0 Running (not disconnected) > + 1 Disconnected and not scanning > + 2 Page scanning and/or passive scanning. > + > + The value 0 is used for the running state and may be sent if the > + controller could not be configured to suspend properly. > + > + This event will be sent to all management sockets. > + > + > +Controller Resume Event > +======================= > + > + Event code: 0x002e > + Controller Index: <controller_id> > + Event Parameters: Wake_Reason (1 octet) > + Address (6 octets) > + Address_Type (1 octet) > + > + This event indicates that the controller has resumed from suspend. > + > + Possible values for the Wake_Reason parameter: > + 0 Resume from non-Bluetooth wake source > + 1 Wake due to unexpected event > + 2 Remote wake due to peer device connection > + > + Currently, we expect that only peer reconnections should wake us from > + the suspended state. Any other events that occurred while the system > + should have been suspended results in wake due to unexpected event. > + > + If the Wake_Reason is Remote wake due to connection, the address of the > + peer device that caused the event will be shared in Address and > + Address_Type. Otherwise, Address and Address_Type will both be zero. > + > + This event will be sent to all management sockets. so far so good. I am going to have second look once you have RFC implementation to review. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4EsJFkQqIF/QGQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 15:38:12 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iKwqFEQqIF9agwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 15:38:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8C4DF40AE5; Tue, 28 Jul 2020 15:38:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730025AbgG1Nh6 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 09:37:58 -0400 Received: from mxout03.lancloud.ru ([89.108.73.187]:43812 "EHLO mxout03.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729986AbgG1Nhz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 09:37:55 -0400 X-Greylist: delayed 594 seconds by postgrey-1.27 at vger.kernel.org; Tue, 28 Jul 2020 09:37:51 EDT Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout03.lancloud.ru E6499214C034 Received: from LanCloud Received: from LanCloud Received: from LanCloud Received: from LanCloud From: Ildar Kamaletdinov <i.kamaletdinov@omprussia.ru> To: Marcel Holtmann <marcel@holtmann.org>, Sergey Shtylyov <s.shtylyov@omprussia.ru> CC: Johan Hedberg <johan.hedberg@gmail.com>, Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, "netdev@vger.kernel.org" <netdev@vger.kernel.org> Subject: Re: [PATCH RFC] bluetooth: add support for some old headsets Thread-Topic: [PATCH RFC] bluetooth: add support for some old headsets Thread-Index: AQHWXG4sjdOYdGBw+0mZjynHmJYWq6kSNhiAgAo864CAAGeiAA== Date: Tue, 28 Jul 2020 13:27:54 +0000 Message-ID: <d9ebfb9e-5abb-0898-b5e1-0ff55a07d79d@omprussia.ru> References: <6f461412-a6c0-aa53-5e74-394e278ee9b1@omprussia.ru> <1834765D-52E6-45B8-9923-778C9182CFA9@holtmann.org> <e9f32310-2728-60a2-adc7-3a7418ce54e3@omprussia.ru> <848144D3-85F9-47F8-8CDA-02457FA7530F@holtmann.org> <0c2a8da1-6071-6597-d0d1-32ce1490aba7@omprussia.ru> <6f271bf7-04ee-c971-9c69-de3f696769ed@omprussia.ru> <97E2381A-219D-46AF-962F-CBCD63B911AD@holtmann.org> In-Reply-To: <97E2381A-219D-46AF-962F-CBCD63B911AD@holtmann.org> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [192.168.11.147] Content-Type: text/plain; charset="utf-8" Content-ID: <3B3EF73FAE4B34449100261C10242FD5@lancloud.ru> Content-Transfer-Encoding: base64 MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 5 X-Rspamd-Score: 0.85 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8C4DF40AE5 X-Rspamd-UID: 98430e SGVsbG8gZXZlcnlvbmUsDQoNCkxldCBtZSBhZGQgYSBsaXR0bGUgYml0IG1vcmUgZGV0YWlscyBy ZWxhdGVkIHRvIHRoaXMgcGF0Y2guDQoNCkFjY29yZGluZyB0byBCbHVldG9vdGggQ29yZSBTcGVj aWZpY2F0aW9uIFZvbCAyIHBhcnQgRiBwYWdlIDc3NiBhbmTCoCBCbHVldG9vdGggQ29yZSBTcGVj aWZpY2F0aW9uIFZvbDQgUGFydCBFIHBhZ2UgMTk3OCBhZnRlciBgSENJX1NldHVwX1N5bmNocm9u b3VzX0Nvbm5lY3Rpb24oKWAgd2FzIHNlbnQgYEhDSV9Db21tYW5kX1N0YXR1cygpYCBtdXN0IGJl IHJlY2VpdmVkIGZyb20gQkRSL0VEUiBjb250cm9sbGVyLg0KDQpBY2NvcmRpbmcgdG8gQmx1ZXRv b3RoIENvcmUgU3BlY2lmaWNhdGlvbiBWb2wgMiBwYXJ0IEYgcGFnZSAzNjQgSENJX0NvbW1hbmRf U3RhdHVzIGRlc2NyaXB0aW9uOg0KDQoiU29tZSBIQ0kgY29tbWFuZHMgbWF5IGdlbmVyYXRlIGVy cm9ycyB0aGF0IG5lZWQgdG8gYmUgcmVwb3J0ZWQgdG8gdGhlIEhvc3QsIGJ1dCB0aGVyZSBpcyBp bnN1ZmZpY2llbnQgaW5mb3JtYXRpb24gdG8gZGV0ZXJtaW5lIGhvdyB0aGUgY29tbWFuZCB3b3Vs ZCBub3JtYWxseSBiZSBwcm9jZXNzZWQuIEluIHRoaXMgY2FzZSwgdHdvIGV2ZW50cyBjYW4gYmUg dXNlZCB0byBpbmRpY2F0ZSB0aGlzIHRvIHRoZSBIb3N0LCB0aGUgSENJX0NvbW1hbmRfQ29tcGxl dGUgZXZlbnQgYW5kIEhDSV9Db21tYW5kX1N0YXR1cyBldmVudHMuIFdoaWNoIG9mIHRoZSB0d28g ZXZlbnRzIGlzIHVzZWQgaXMgaW1wbGVtZW50YXRpb24tZGVwZW5kZW50LiINCg0KTWVkaWF0ZWsn cyBpbXBsZW1lbnRhdGlvbiByZXBvcnRzIGVycm9yIGBVbnN1cHBvcnRlZCBMTVAgZmVhdHVyZWAg aW4gYEhDSV9Db21tYW5kX1N0YXR1cygpYCBldmVudCAobm90IGluIGBIQ0lfQ29tbWFuZF9Db21w bGV0ZSgpYCBldmVudCBhcyBpbiBvdGhlciBpbXBsZW1lbnRhdGlvbnMpLg0KU28gdGhhdCBiZWhh dmlvciBpcyBhIGxpdHRsZSBiaXQgb2RkIGJ1dCBkb24ndCBicmVhayBjb21wYXRpYmlsaXR5IHdp dGggQmx1ZXRvb3RoIENvcmUgU3BlY2lmaWNhdGlvbi4gQWN0dWFsbHkgTWVkaWF0ZWsncyBCRFIv RURSIGNvbnRyb2xsZXIgcmVwb3J0cyBlcnJvciB3aXRob3V0IHRyeWluZyB0byBhY3R1YWxseSBz ZXR1cCBjb25uZWN0aW9uIHdpdGggaGVhZHNldC4NCg0KQnV0IGFjY29yZGluZyB0byBIYW5kcy1G cmVlIHByb2ZpbGUgc3BlY2lmaWNhdGlvbiAxLjggcC4gMTEzIFN5bmNocm9ub3VzIENvbm5lY3Rp b24gSW50ZXJvcGVyYWJpbGl0eSBSZXF1aXJlbWVudHMgQmx1ZXRvb3RoIEhvc3QgTVVTVCB0cnkg YWxsIGZlYXR1cmVzIFQxLT5UMi0+UzEtPlMyLT5EMCBvciBEMSBiZWZvcmUgY29uc2lkZXJpbmcg Y29ubmVjdGlvbiBhcyBgZmFpbGVkYC4gQW5kIGl0IGlzIHRydWUgaWYgZXJyb3IgaXMgcmVwb3J0 ZWQgaW4gYEhDSV9Db21tYW5kX0NvbXBsZXRlKClgIGV2ZW50Lg0KRXZlbnR1YWxseSBJZiBlcnJv ciBpcyByZXBvcnRlZCBpbiBgSENJX0NvbW1hbmRfU3RhdHVzKClgIGV2ZW50IGNvbm5lY3Rpb24g Y29uc2lkZXJlZCBhcyAnZmFpbGVkJyBqdXN0IGFmdGVyIGZpcnN0IGVycm9yIHdoaWNoIGJyZWFr cyBjb21wYXRpYmlsaXR5IHdpdGggSEZQIHByb2ZpbGUgc3BlY2lmaWNhdGlvbiB2MS44IGluIExp bnV4IEtlcm5lbC4gVGhhdCBsZWFkcyB0byBwcm9ibGVtcyB3aGVuIFNDby9lU0NPIGNvbm5lY3Rp b24gY291bGQgbm90IGJlIGVzdGFibGlzaGVkIHdoZW4gdXNpbmcgTWVkaWF0ZWsncyBCRFIvRURS IGNvbnRyb2xsZXJzLg0KDQpTbyB0aGF0IHBhdGNoIHNob3VsZCBhZGQgc3VwcG9ydCBmb3IgY29y cmVjdCBTQ08vZVNDTyBjb25uZWN0aW9uIGJlaGF2aW9yIHdoZW4gd29yayB3aXRoIGF0IGxlYXN0 IE1lZGlhdGVrIGNvbnRyb2xsZXJzLiAoYSBsaXR0bGUgYml0IHBlY3VsaWFyIGJlaGF2aW9yIGJ1 dCBjb21wYXRpYmxlIHdpdGggQmx1ZXRvb3RoIENvcmUgc3BlYykuDQoNCklmIGFueSBvYmplY3Rp b25zIG9yIHF1ZXN0aW9ucyBwbGVhc2UgZmlsbCBmcmVlIHRvIGNvbnRhY3QgbWUgb3IgU2VyZ2V5 IGFueXRpbWUuDQo+IEhpIFNlcmdleSwNCj4NCj4+Pj4+Pj4gVGhlIE1lZGlhVGVrIEJsdWV0b290 aCBwbGF0Zm9ybSAoTVQ2NjMwIGV0Yy4pIGhhcyBhIHBlY3VsaWFyIGltcGxlbWVudGF0aW9uDQo+ Pj4+Pj4+IGZvciB0aGUgZVNDTy9TQ08gY29ubmVjdGlvbiB2aWEgQlQvRURSOiB0aGUgaG9zdCBj b250cm9sbGVyIHJldHVybnMgZXJyb3INCj4+Pj4+Pj4gY29kZSAweDIwIChMTVAgZmVhdHVyZSBu b3Qgc3VwcG9ydGVkKSBmb3IgSENJX1NldHVwX1N5bmNocm9ub3VzX0Nvbm5lY3Rpb24NCj4+Pj4+ Pj4gKDB4MDAyOCkgY29tbWFuZCB3aXRob3V0IGFjdHVhbGx5IHRyeWluZyB0byBzZXR1cCBjb25u ZWN0aW9uIHdpdGggYSByZW1vdGUNCj4+Pj4+Pj4gZGV2aWNlIGluIGNhc2Ugc3VjaCBkZXZpY2Ug KGxpa2UgRGlnbWEgQlQtMTQgaGVhZHNldCkgZGlkbid0IGFkdmVydGlzZSBpdHMNCj4+Pj4+Pj4g c3VwcG9ydGVkIGZlYXR1cmVzLiAgRXZlbiB0aG91Z2ggdGhpcyBkb2Vzbid0IGJyZWFrIGNvbXBh dGliaWxpdHkgd2l0aCB0aGUNCj4+Pj4+Pj4gQmx1ZXRvb3RoIHN0YW5kYXJkIGl0IGJyZWFrcyB0 aGUgY29tcGF0aWJpbGl0eSB3aXRoIHRoZSBIYW5kcy1GcmVlIFByb2ZpbGUNCj4+Pj4+Pj4gKEhG UCkuDQo+Pj4+Pj4+DQo+Pj4+Pj4+IFRoaXMgcGF0Y2ggcmV0dXJucyB0aGUgY29tcGF0aWJpbGl0 eSB3aXRoIHRoZSBIRlAgcHJvZmlsZSBhbmQgYWN0dWFsbHkNCj4+Pj4+Pj4gdHJpZXMgdG8gY2hl Y2sgYWxsIGF2YWlsYWJsZSBjb25uZWN0aW9uIHBhcmFtZXRlcnMgZGVzcGl0ZSBvZiB0aGUgc3Bl Y2lmaWMNCj4+Pj4+Pj4gTWVkaWFUZWsgaW1wbGVtZW50YXRpb24uIFdpdGhvdXQgaXQgb25lIHdh cyB1bmFibGUgdG8gZXN0YWJsaXNoIGVTQ08vU0NPDQo+Pj4+Pj4+IGNvbm5lY3Rpb24gd2l0aCBz b21lIGhlYWRzZXRzLg0KPj4gWy4uLl0NCj4+Pj4+Pj4gU2lnbmVkLW9mZi1ieTogU2VyZ2V5IFNo dHlseW92IDxzLnNodHlseW92QG9tcHJ1c3NpYS5ydT4NCj4+Pj4+Pj4NCj4+Pj4+Pj4gLS0tDQo+ Pj4+Pj4+IFRoaXMgcGF0Y2ggaXMgYWdhaW5zdCB0aGUgJ2JsdWV0b290aC1uZXh0LmdpdCcgcmVw by4NCj4+Pj4+Pj4NCj4+Pj4+Pj4gbmV0L2JsdWV0b290aC9oY2lfZXZlbnQuYyB8ICAgIDggKysr KysrKysNCj4+Pj4+Pj4gMSBmaWxlIGNoYW5nZWQsIDggaW5zZXJ0aW9ucygrKQ0KPj4+Pj4+Pg0K Pj4+Pj4+PiBJbmRleDogYmx1ZXRvb3RoLW5leHQvbmV0L2JsdWV0b290aC9oY2lfZXZlbnQuYw0K Pj4+Pj4+PiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09DQo+Pj4+Pj4+IC0tLSBibHVldG9vdGgtbmV4dC5vcmlnL25ldC9i bHVldG9vdGgvaGNpX2V2ZW50LmMNCj4+Pj4+Pj4gKysrIGJsdWV0b290aC1uZXh0L25ldC9ibHVl dG9vdGgvaGNpX2V2ZW50LmMNCj4+Pj4+Pj4gQEAgLTIxODcsNiArMjE4NywxMyBAQCBzdGF0aWMg dm9pZCBoY2lfY3Nfc2V0dXBfc3luY19jb25uKHN0cnVjDQo+Pj4+Pj4+IAlpZiAoYWNsKSB7DQo+ Pj4+Pj4+IAkJc2NvID0gYWNsLT5saW5rOw0KPj4+Pj4+PiAJCWlmIChzY28pIHsNCj4+Pj4+Pj4g KwkJCWlmIChzdGF0dXMgPT0gMHgyMCAmJiAvKiBVbnN1cHBvcnRlZCBMTVAgUGFyYW1ldGVyIHZh bHVlICovDQo+Pj4+Pj4+ICsJCQkgICAgc2NvLT5vdXQpIHsNCj4+PiAgICBBY3R1YWxseSwgSSB3 YXMgZXhwZWN0aW5nIHRoYXQgeW91J2QgdGVsbCBtZSB0byBjcmVhdGUgYSBIQ0kgcXVpcmsgZm9y IHRoaXMgc2l0dWF0aW9uLg0KPj4+IEkgaGF2ZSBhIHBhdGNoIGRvaW5nIHRoYXQgYnV0IEkgaGF2 ZW4ndCBiZWVuIGFibGUgdG8gbG9jYXRlIHRoZSBkcml2ZXIgaW4gd2hpY2ggdG8gc2V0IHRoaXMN Cj4+PiBxdWlyayBmbGFnLi4uDQo+PiAgIEFuZCB0aGF0J3Mgbm8gd29uZGVyISBUaGUgQlQgZHJp dmVyIHRoYXQgbmVlZHMgdGhpcyBwYXRjaCBpcyBvdXQtb2YtdHJlZSAoYW5kIG5vdCBldmVuIG9w ZW4NCj4+IHNvdXJjZSwgaXQgc2VlbXMpIGFzIHdlIGhhdmUgZmluYWxseSBhc2NlcnRhaW5lZCB3 aXRoIElsZGFyLi4uIElzIHRoZXJlIGFueSBpbnRlcmVzdCBpbiB0aGUNCj4+ICJwcmVwYXJhdG9y eSIgcGF0Y2ggdGhhdCBsb3dlcnMgdGhlIGluZGVudGF0aW9uIGxldmVscyBpbiBoY2lfY3Nfc2V0 dXBfc3luY19jb25uKCk/DQo+IGhvdyBpcyBpdCBwb3NzaWJsZSB0aGF0IHRoZXJlIGlzIGFuIG91 dC1vZi10cmVlIEJsdWV0b290aCBkcml2ZXIuIFNlZW1zIG9kZC4gTWF5YmUgd2FudCB0byBzdWJt aXQgdGhhdCB1cHN0cmVhbSBmaXJzdC4NCj4NCj4gUmVnYXJkcw0KPg0KPiBNYXJjZWwNCj4NCg0K Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OAMyCwVKIF8mAwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 17:53:41 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id eOBICQVKIF9ufwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 17:53:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B9CFEA1035; Tue, 28 Jul 2020 17:53:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731118AbgG1Px1 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 11:53:27 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:28797 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730977AbgG1Px1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 11:53:27 -0400 Received: from ironmsg07-lv.qualcomm.com (HELO ironmsg07-lv.qulacomm.com) ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 28 Jul 2020 08:53:26 -0700 Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg07-lv.qulacomm.com with ESMTP/TLS/AES256-SHA; 28 Jul 2020 08:53:24 -0700 Received: from gubbaven-linux.qualcomm.com ([10.206.64.32]) by ironmsg02-blr.qualcomm.com with ESMTP; 28 Jul 2020 21:23:01 +0530 Received: by gubbaven-linux.qualcomm.com (Postfix, from userid 2365015) id ECC9621A2A; Tue, 28 Jul 2020 21:23:00 +0530 (IST) From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org, Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Subject: [PATCH v1] Bluetooth: hci_qca: Stop collecting memdump again for command timeout during SSR Date: Tue, 28 Jul 2020 21:23:00 +0530 Message-Id: <1595951580-16724-1-git-send-email-gubbaven@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: B9CFEA1035 X-Rspamd-UID: 90a70e Setting memdump state to idle prior to setting of callback function pointer for command timeout to NULL,causing the issue.Now moved the initialisation of memdump state to qca_setup(). Fixes: d841502c79e3 ("Bluetooth: hci_qca: Collect controller memory dump during SSR") Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> --- drivers/bluetooth/hci_qca.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 3d13002..20e1ded 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -1668,6 +1668,8 @@ static int qca_setup(struct hci_uart *hu) bt_dev_info(hdev, "setting up %s", qca_is_wcn399x(soc_type) ? "wcn399x" : "ROME/QCA6390"); + qca->memdump_state = QCA_MEMDUMP_IDLE; + retry: ret = qca_power_on(hdev); if (ret) @@ -1817,9 +1819,6 @@ static void qca_power_shutdown(struct hci_uart *hu) qca_flush(hu); spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); - hu->hdev->hw_error = NULL; - hu->hdev->cmd_timeout = NULL; - /* Non-serdev device usually is powered by external power * and don't need additional action in driver for power down */ @@ -1841,6 +1840,9 @@ static int qca_power_off(struct hci_dev *hdev) struct qca_data *qca = hu->priv; enum qca_btsoc_type soc_type = qca_soc_type(hu); + hu->hdev->hw_error = NULL; + hu->hdev->cmd_timeout = NULL; + /* Stop sending shutdown command if soc crashes. */ if (soc_type != QCA_ROME && qca->memdump_state == QCA_MEMDUMP_IDLE) { @@ -1848,7 +1850,6 @@ static int qca_power_off(struct hci_dev *hdev) usleep_range(8000, 10000); } - qca->memdump_state = QCA_MEMDUMP_IDLE; qca_power_shutdown(hu); return 0; } -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +OT4EN5UIF9RNgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 18:39:58 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0CUeD95UIF+ypQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 18:39:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 444BF40507; Tue, 28 Jul 2020 18:39:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731416AbgG1Qjr (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 12:39:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731273AbgG1Qjr (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 12:39:47 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED86AC061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 09:39:46 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id a26so6542809otf.1 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 09:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5JI0PpX5piIkrPFc0swt1AfEbX9CKzSRpIM3HPlDLtQ=; b=u9Z78vi+0peDj221Xa4YOQHr8pckB5dprkWcL2jrumqhE6VugTqlaOnXrkEg22k0jv cloYC91LL87VDOI1UDw0KuHyKyZJQ7iIROWkBfNujcfup0RP0Oa3B2mCe+lK0oE7PeD2 296qfWPexqGTPe6Zk3LL8McvYkELx1km1JrfJutmjMUaek6kC2SyWmdNkmuBec6fMkrs AjNXossC7eH1KOrbjDRvIy/gSJD6jlVeV6X+QqS4womqeGMu/ONyXdSLokn6iv1pq/B1 U95CmiN1W4yPGT39C5lNdz+qZXwoMGfNV2q259eEDT5dwXRnJcFK/png1yAglawledYX andQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5JI0PpX5piIkrPFc0swt1AfEbX9CKzSRpIM3HPlDLtQ=; b=WTz0xinUmfrsNUG21xmko58yke6NC5LLq8IhRdOH1chQFcXGK+QgdhIBKzNxsX0BTK yhPFfU9e3TJivT6FDq4GUIV8wNDj00V4VDAk2vnlzutC6IdUNsbZdnulivUULUYJSFGu 3jVGsayOF+2jnU3XkkV71cZf944yiN/OVaZNw5BwUT15qjQ4QcQ4lPv5CUAfdh6oq6F9 zT1NAMJsmM4lcUycB4YniSgbJMfutJGt+2zF7t1BevmUB06Tk97xjI/gD6KDKEo5QLO4 s2qr0vU5OzSJUZdgyzly6qESEGd+0M1nAe2xswR+acV6nJi0hBtogDGm26IB4r4qlm+d 8KBw== X-Gm-Message-State: AOAM531dBo+UFueDKYPIceNOLZc7L3MIKPRqfxrK9Pmd5woFNtYKDZJd H1+/hx83GyJsuxU0i0vgKIMEWt+B7A9OYvs2jshyBGoPtP4= X-Google-Smtp-Source: ABdhPJxZpMfkk/kWbnT4PVJt1weLnhNP51L4W+IyBJbOK+KiC5AiJLZVDNH+hb2QUamrjDi7aaodsGeo+2hXvmu7gvo= X-Received: by 2002:a9d:6053:: with SMTP id v19mr5743839otj.362.1595954386257; Tue, 28 Jul 2020 09:39:46 -0700 (PDT) MIME-Version: 1.0 References: <20200728070428.1754257-1-luiz.dentz@gmail.com> <80073DFD-564E-4B4E-9F23-02ED4075321D@holtmann.org> In-Reply-To: <80073DFD-564E-4B4E-9F23-02ED4075321D@holtmann.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 28 Jul 2020 09:39:37 -0700 Message-ID: <CABBYNZKJLcyJsCe9yZB6RAdtiCkpi-oMYPsJzWV_r19CJVT_Ww@mail.gmail.com> Subject: Re: [RFC] Bluetooth: L2CAP: Fix to handling fragmented header To: Marcel Holtmann <marcel@holtmann.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.87 / 15.00 / 200.00 X-Rspamd-Queue-Id: 444BF40507 X-Rspamd-UID: ef5126 Hi Marcel, On Tue, Jul 28, 2020 at 12:22 AM Marcel Holtmann <marcel@holtmann.org> wrote: > > Hi Luiz, > > > Bluetooth Core Specification v5.2, Vol. 3, Part A, section 1.4, table > > 1.1: > > > > 'Start Fragments always either begin with the first octet of the Basic > > L2CAP header of a PDU or they have a length of zero (see [Vol 2] Part > > B, Section 6.6.2).' > > > > This text has been changed recently as it previously stated: > > > > 'Start Fragments always begin with the Basic L2CAP header of a PDU.' > > > > Apparently this was changed by the following errata: > > > > https://www.bluetooth.org/tse/errata_view.cfm?errata_id=10216 > > > > In past this has not been a problem but it seems new controllers are > > apparently doing it as it has been reported in Zephyr: > > > > https://github.com/zephyrproject-rtos/zephyr/issues/26900 > > > > Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > --- > > net/bluetooth/l2cap_core.c | 104 +++++++++++++++++++++++++++++-------- > > 1 file changed, 83 insertions(+), 21 deletions(-) > > > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > > index ade83e224567..193bea314222 100644 > > --- a/net/bluetooth/l2cap_core.c > > +++ b/net/bluetooth/l2cap_core.c > > @@ -8269,6 +8269,63 @@ static void l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) > > mutex_unlock(&conn->chan_lock); > > } > > > > +/* Append fragment into frame respecting the maximum len of rx_skb */ > > +static int l2cap_recv_frag(struct l2cap_conn *conn, struct sk_buff *skb, > > + u16 len) > > +{ > > + if (!conn->rx_skb) { > > + /* Allocate skb for the complete frame (with header) */ > > + conn->rx_skb = bt_skb_alloc(len, GFP_KERNEL); > > + if (!conn->rx_skb) > > + return -ENOMEM; > > + /* Init rx_len */ > > + conn->rx_len = len; > > + } > > + > > + /* Copy as much as the rx_skb can hold */ > > + len = min_t(u16, len, skb->len); > > + skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, len), len); > > + skb_pull(skb, len); > > + conn->rx_len -= len; > > + > > + return len; > > +} > > + > > +static int l2cap_recv_header(struct l2cap_conn *conn, struct sk_buff *skb) > > +{ > > + struct l2cap_hdr *hdr; > > + struct sk_buff *rx_skb; > > + int len; > > + > > + /* Append just enough to complete the header */ > > + len = l2cap_recv_frag(conn, skb, L2CAP_HDR_SIZE - conn->rx_skb->len); > > + > > + /* If header could not be read just continue */ > > + if (len < 0 || conn->rx_skb->len < L2CAP_HDR_SIZE) > > + return len; > > + > > + rx_skb = conn->rx_skb; > > + conn->rx_skb = NULL; > > + > > + hdr = (struct l2cap_hdr *) rx_skb->data; > > so I think it is pointless to insist on getting the complete header. We really just need the first 2 octets. > > struct l2cap_hdr { > __le16 len; > __le16 cid; > } __packed; Indeed, I've totally forgotten about the cid so I will change this to not use L2CAP_HDR_SIZE but 2 instead. > Once we have received at least 2 octets, we can get_unaligned_le16(rx_skb->data) and then just continue. Sure, I was trying to figure out if there is any way to grow the the rx_skb since I will be just allocating 2 bytes for it if the header is not available, we could perhaps take a different approach and always allocate based on the conn->mtu that way we don't have to wait the length to received to allocate a second skb and copy over the length into it, obviously that would only be done if length was fragmented. > Regards > > Marcel > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CBDCIEnQH1/9nAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 09:14:17 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id aPPkHknQH1+vhgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 09:14:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C6F914175E; Tue, 28 Jul 2020 09:14:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727088AbgG1HOL convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 03:14:11 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:35475 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgG1HOK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 03:14:10 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 3DC9FCECCD; Tue, 28 Jul 2020 09:24:11 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH BlueZ] Add a presubmit configuration file for Chromium OS repo From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200717231404.240644-1-sonnysasaka@chromium.org> Date: Tue, 28 Jul 2020 09:14:09 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <8E0368F4-1F53-403B-8EDC-51533108E54A@holtmann.org> References: <20200717231404.240644-1-sonnysasaka@chromium.org> To: Sonny Sasaka <sonnysasaka@chromium.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: C6F914175E X-Rspamd-UID: 81d4ae Hi Sonny, > Chromium OS developers use gerrit and repo in their workflow. > (https://gerrit.googlesource.com/git-repo/). This configuration file > makes it easier when uploading patches to gerrit with the repo tool. > > --- > PRESUBMIT.cfg | 8 ++++++++ > 1 file changed, 8 insertions(+) > create mode 100644 PRESUBMIT.cfg > > diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg > new file mode 100644 > index 000000000..10f89b741 > --- /dev/null > +++ b/PRESUBMIT.cfg > @@ -0,0 +1,8 @@ > +# This is a configuration for Chromium OS repo pre-upload hooks. > +# repohooks doc: https://chromium.googlesource.com/chromiumos/repohooks/ > +# Chromium OS BlueZ git repo: https://chromium.googlesource.com/chromiumos/third_party/bluez/ > + > +[Hook Overrides] > +cros_license_check: false > +tab_check: false > +checkpatch_check: true I am not in favor of adding anything in the top-level directory that is not for for the BlueZ upstream usage. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WGh5AvTQH1/IlgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 09:17:08 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id IB/tAPTQH1+nWgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 09:17:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B3C29A1EAC; Tue, 28 Jul 2020 09:17:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbgG1HRB convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 03:17:01 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:41332 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgG1HRA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 03:17:00 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id B94B2CECCD; Tue, 28 Jul 2020 09:27:00 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH RFC] bluetooth: add support for some old headsets From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <6f271bf7-04ee-c971-9c69-de3f696769ed@omprussia.ru> Date: Tue, 28 Jul 2020 09:16:59 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, netdev@vger.kernel.org, Ildar Kamaletdinov <i.kamaletdinov@omprussia.ru> Content-Transfer-Encoding: 8BIT Message-Id: <97E2381A-219D-46AF-962F-CBCD63B911AD@holtmann.org> References: <6f461412-a6c0-aa53-5e74-394e278ee9b1@omprussia.ru> <1834765D-52E6-45B8-9923-778C9182CFA9@holtmann.org> <e9f32310-2728-60a2-adc7-3a7418ce54e3@omprussia.ru> <848144D3-85F9-47F8-8CDA-02457FA7530F@holtmann.org> <0c2a8da1-6071-6597-d0d1-32ce1490aba7@omprussia.ru> <6f271bf7-04ee-c971-9c69-de3f696769ed@omprussia.ru> To: Sergey Shtylyov <s.shtylyov@omprussia.ru> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 23 X-Rspamd-Score: 3.48 / 15.00 / 200.00 X-Rspamd-Queue-Id: B3C29A1EAC X-Rspamd-UID: 6ac75e Hi Sergey, >>>>>> The MediaTek Bluetooth platform (MT6630 etc.) has a peculiar implementation >>>>>> for the eSCO/SCO connection via BT/EDR: the host controller returns error >>>>>> code 0x20 (LMP feature not supported) for HCI_Setup_Synchronous_Connection >>>>>> (0x0028) command without actually trying to setup connection with a remote >>>>>> device in case such device (like Digma BT-14 headset) didn't advertise its >>>>>> supported features. Even though this doesn't break compatibility with the >>>>>> Bluetooth standard it breaks the compatibility with the Hands-Free Profile >>>>>> (HFP). >>>>>> >>>>>> This patch returns the compatibility with the HFP profile and actually >>>>>> tries to check all available connection parameters despite of the specific >>>>>> MediaTek implementation. Without it one was unable to establish eSCO/SCO >>>>>> connection with some headsets. > [...] >>>>>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru> >>>>>> >>>>>> --- >>>>>> This patch is against the 'bluetooth-next.git' repo. >>>>>> >>>>>> net/bluetooth/hci_event.c | 8 ++++++++ >>>>>> 1 file changed, 8 insertions(+) >>>>>> >>>>>> Index: bluetooth-next/net/bluetooth/hci_event.c >>>>>> =================================================================== >>>>>> --- bluetooth-next.orig/net/bluetooth/hci_event.c >>>>>> +++ bluetooth-next/net/bluetooth/hci_event.c >>>>>> @@ -2187,6 +2187,13 @@ static void hci_cs_setup_sync_conn(struc >>>>>> if (acl) { >>>>>> sco = acl->link; >>>>>> if (sco) { >>>>>> + if (status == 0x20 && /* Unsupported LMP Parameter value */ >>>>>> + sco->out) { >> >> Actually, I was expecting that you'd tell me to create a HCI quirk for this situation. >> I have a patch doing that but I haven't been able to locate the driver in which to set this >> quirk flag... > > And that's no wonder! The BT driver that needs this patch is out-of-tree (and not even open > source, it seems) as we have finally ascertained with Ildar... Is there any interest in the > "preparatory" patch that lowers the indentation levels in hci_cs_setup_sync_conn()? how is it possible that there is an out-of-tree Bluetooth driver. Seems odd. Maybe want to submit that upstream first. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uNwxNCfRH1/5MQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 09:17:59 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id gONuMifRH19IEAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 09:17:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 47ED2417BB; Tue, 28 Jul 2020 09:17:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbgG1HRs convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 03:17:48 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:53580 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgG1HRs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 03:17:48 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id A4312CECCE; Tue, 28 Jul 2020 09:27:47 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 2/2] Bluetooth: hci_serdev: Only unregister device if it was registered From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200721103652.2.I8a2fdad30d42399fa5afc15d66b460d1738c3946@changeid> Date: Tue, 28 Jul 2020 09:17:46 +0200 Cc: Ian Molton <ian@mnementh.co.uk>, Johan Hedberg <johan.hedberg@gmail.com>, Sebastian Reichel <sre@kernel.org>, Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <1D8C4C03-727F-4CC4-9FC9-6355A6C778FC@holtmann.org> References: <20200721103652.1.Idbc7eddf1f24f750a8bbcbc8e06743736ae3be31@changeid> <20200721103652.2.I8a2fdad30d42399fa5afc15d66b460d1738c3946@changeid> To: Nicolas Boichat <drinkcat@chromium.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: 47ED2417BB X-Rspamd-UID: c219a2 Hi Nicolas, > We should not call hci_unregister_dev if the device was not > successfully registered. > > Fixes: c34dc3bfa7642fd ("Bluetooth: hci_serdev: Introduce hci_uart_unregister_device()") > Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> > > --- > > drivers/bluetooth/hci_serdev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oMBKDlDSH193qwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 09:22:56 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id wCimDFDSH19ZjQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 09:22:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 08F08A1856; Tue, 28 Jul 2020 09:22:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727863AbgG1HWt convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 03:22:49 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:48954 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727072AbgG1HWs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 03:22:48 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id C8441CECCD; Tue, 28 Jul 2020 09:32:48 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [RFC] Bluetooth: L2CAP: Fix to handling fragmented header From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200728070428.1754257-1-luiz.dentz@gmail.com> Date: Tue, 28 Jul 2020 09:22:46 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <80073DFD-564E-4B4E-9F23-02ED4075321D@holtmann.org> References: <20200728070428.1754257-1-luiz.dentz@gmail.com> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.41 / 15.00 / 200.00 X-Rspamd-Queue-Id: 08F08A1856 X-Rspamd-UID: b02f0c Hi Luiz, > Bluetooth Core Specification v5.2, Vol. 3, Part A, section 1.4, table > 1.1: > > 'Start Fragments always either begin with the first octet of the Basic > L2CAP header of a PDU or they have a length of zero (see [Vol 2] Part > B, Section 6.6.2).' > > This text has been changed recently as it previously stated: > > 'Start Fragments always begin with the Basic L2CAP header of a PDU.' > > Apparently this was changed by the following errata: > > https://www.bluetooth.org/tse/errata_view.cfm?errata_id=10216 > > In past this has not been a problem but it seems new controllers are > apparently doing it as it has been reported in Zephyr: > > https://github.com/zephyrproject-rtos/zephyr/issues/26900 > > Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > --- > net/bluetooth/l2cap_core.c | 104 +++++++++++++++++++++++++++++-------- > 1 file changed, 83 insertions(+), 21 deletions(-) > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > index ade83e224567..193bea314222 100644 > --- a/net/bluetooth/l2cap_core.c > +++ b/net/bluetooth/l2cap_core.c > @@ -8269,6 +8269,63 @@ static void l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) > mutex_unlock(&conn->chan_lock); > } > > +/* Append fragment into frame respecting the maximum len of rx_skb */ > +static int l2cap_recv_frag(struct l2cap_conn *conn, struct sk_buff *skb, > + u16 len) > +{ > + if (!conn->rx_skb) { > + /* Allocate skb for the complete frame (with header) */ > + conn->rx_skb = bt_skb_alloc(len, GFP_KERNEL); > + if (!conn->rx_skb) > + return -ENOMEM; > + /* Init rx_len */ > + conn->rx_len = len; > + } > + > + /* Copy as much as the rx_skb can hold */ > + len = min_t(u16, len, skb->len); > + skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, len), len); > + skb_pull(skb, len); > + conn->rx_len -= len; > + > + return len; > +} > + > +static int l2cap_recv_header(struct l2cap_conn *conn, struct sk_buff *skb) > +{ > + struct l2cap_hdr *hdr; > + struct sk_buff *rx_skb; > + int len; > + > + /* Append just enough to complete the header */ > + len = l2cap_recv_frag(conn, skb, L2CAP_HDR_SIZE - conn->rx_skb->len); > + > + /* If header could not be read just continue */ > + if (len < 0 || conn->rx_skb->len < L2CAP_HDR_SIZE) > + return len; > + > + rx_skb = conn->rx_skb; > + conn->rx_skb = NULL; > + > + hdr = (struct l2cap_hdr *) rx_skb->data; so I think it is pointless to insist on getting the complete header. We really just need the first 2 octets. struct l2cap_hdr { __le16 len; __le16 cid; } __packed; Once we have received at least 2 octets, we can get_unaligned_le16(rx_skb->data) and then just continue. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IMMRLrrcH1/48QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 10:07:22 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 8NUwLLrcH19SNgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 10:07:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 635C3A0D15; Tue, 28 Jul 2020 10:07:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727950AbgG1IHQ convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 04:07:16 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:55110 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727940AbgG1IHQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 04:07:16 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-122-o5x9Q9SyNzqkeSG6S-qBgw-1; Tue, 28 Jul 2020 09:07:12 +0100 X-MC-Unique: o5x9Q9SyNzqkeSG6S-qBgw-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 28 Jul 2020 09:07:11 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 28 Jul 2020 09:07:11 +0100 From: David Laight <David.Laight@ACULAB.COM> To: 'Christoph Hellwig' <hch@lst.de>, "Jason A. Donenfeld" <Jason@zx2c4.com> CC: "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, "Linux Crypto Mailing List" <linux-crypto@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Netdev <netdev@vger.kernel.org>, "bpf@vger.kernel.org" <bpf@vger.kernel.org>, "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>, "coreteam@netfilter.org" <coreteam@netfilter.org>, "linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>, "linux-hams@vger.kernel.org" <linux-hams@vger.kernel.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "bridge@lists.linux-foundation.org" <bridge@lists.linux-foundation.org>, "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>, "dccp@vger.kernel.org" <dccp@vger.kernel.org>, "linux-decnet-user@lists.sourceforge.net" <linux-decnet-user@lists.sourceforge.net>, "linux-wpan@vger.kernel.org" <linux-wpan@vger.kernel.org>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, "mptcp@lists.01.org" <mptcp@lists.01.org>, "lvs-devel@vger.kernel.org" <lvs-devel@vger.kernel.org>, "rds-devel@oss.oracle.com" <rds-devel@oss.oracle.com>, "linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>, "tipc-discussion@lists.sourceforge.net" <tipc-discussion@lists.sourceforge.net>, "linux-x25@vger.kernel.org" <linux-x25@vger.kernel.org>, Kernel Hardening <kernel-hardening@lists.openwall.com> Subject: RE: [PATCH 12/26] netfilter: switch nf_setsockopt to sockptr_t Thread-Topic: [PATCH 12/26] netfilter: switch nf_setsockopt to sockptr_t Thread-Index: AQHWZDJbUYsuJ1QOc0ujZBN9RDfEqKkcofVA Date: Tue, 28 Jul 2020 08:07:11 +0000 Message-ID: <908ed73081cc42d58a5b01e0c97dbe47@AcuMS.aculab.com> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-13-hch@lst.de> <20200727150310.GA1632472@zx2c4.com> <20200727150601.GA3447@lst.de> <CAHmME9ric=chLJayn7Erve7WBa+qCKn-+Gjri=zqydoY6623aA@mail.gmail.com> <20200727162357.GA8022@lst.de> In-Reply-To: <20200727162357.GA8022@lst.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 6 X-Rspamd-Score: 0.93 / 15.00 / 200.00 X-Rspamd-Queue-Id: 635C3A0D15 X-Rspamd-UID: a849f8 From: Christoph Hellwig > Sent: 27 July 2020 17:24 > > On Mon, Jul 27, 2020 at 06:16:32PM +0200, Jason A. Donenfeld wrote: > > Maybe sockptr_advance should have some safety checks and sometimes > > return -EFAULT? Or you should always use the implementation where > > being a kernel address is an explicit bit of sockptr_t, rather than > > being implicit? > > I already have a patch to use access_ok to check the whole range in > init_user_sockptr. That doesn't make (much) difference to the code paths that ignore the user-supplied length. OTOH doing the user/kernel check on the base address (not an incremented one) means that the correct copy function is always selected. Perhaps the functions should all be passed a 'const sockptr_t'. The typedef could be made 'const' - requiring non-const items explicitly use the union/struct itself. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SIbrNkDfH19WBAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 10:18:08 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iDVdNUDfH18WXAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 10:18:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=zx2c4.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5B3D5418B5; Tue, 28 Jul 2020 10:18:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728033AbgG1IRr (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 04:17:47 -0400 Received: from mail.zx2c4.com ([192.95.5.64]:36909 "EHLO mail.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727916AbgG1IRq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 04:17:46 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 1f508000; Tue, 28 Jul 2020 07:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=K4YAt33ilBR3hd1+7JojCPxtvSA=; b=nEjdWp cUQVj0KWRd87puFx0fk1HADPVt/5ckkL0vcSiVAoyePGSTncp+KafcroE0itJJAR hvCKOHIgNqwby+4I13HG5z9ibnxBmqHfVx+jKtrPfvHTnJrmPNg1WsagEKVyYT8s 0wLLBcv/NIyWIJ2xwHqa/F7Ekuot/H5qUld6hDSAXP06OIRI6q+V7cdk8Ye2E95N oE2iYHJELOZGqN2H10I58K4qjsUNSGzPFklfgHdPIOfnKUBe2eF7SiuhT2DW4gmx Zlh/4Lwi80eH4MYYZz1R0kvQtczs/XnszWGNGZW6geww/y9D6tsJ0FqJg7QkrUqh r9lHeJJo9aIu1+DA== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id d27e76da (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 28 Jul 2020 07:54:16 +0000 (UTC) Received: by mail-io1-f54.google.com with SMTP id a5so4613572ioa.13; Tue, 28 Jul 2020 01:17:41 -0700 (PDT) X-Gm-Message-State: AOAM5326njdztPe3VkZjU3njFuLXGQOjJ86c1ItnwgBvIww26i5yBNmp mf7+bJPIr4+tDgdochtGaglyFVJWyqL1zhmrfeY= X-Google-Smtp-Source: ABdhPJwruWEMSl6lI3SS18Iq/8cGmq7nVWSaRamLRaM9jzUJiajMF+UBN6XkUtAb0UlYhZIkk+zlhZ92oa7Pvf4Iz8s= X-Received: by 2002:a05:6638:250f:: with SMTP id v15mr8210865jat.75.1595924260418; Tue, 28 Jul 2020 01:17:40 -0700 (PDT) MIME-Version: 1.0 References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-13-hch@lst.de> <20200727150310.GA1632472@zx2c4.com> <20200727150601.GA3447@lst.de> <CAHmME9ric=chLJayn7Erve7WBa+qCKn-+Gjri=zqydoY6623aA@mail.gmail.com> <20200727162357.GA8022@lst.de> <908ed73081cc42d58a5b01e0c97dbe47@AcuMS.aculab.com> In-Reply-To: <908ed73081cc42d58a5b01e0c97dbe47@AcuMS.aculab.com> From: "Jason A. Donenfeld" <Jason@zx2c4.com> Date: Tue, 28 Jul 2020 10:17:28 +0200 X-Gmail-Original-Message-ID: <CAHmME9pUbRmJq1Qcj10eENt15cuQHkiXJNKrUDmmC18n2mLKDA@mail.gmail.com> Message-ID: <CAHmME9pUbRmJq1Qcj10eENt15cuQHkiXJNKrUDmmC18n2mLKDA@mail.gmail.com> Subject: Re: [PATCH 12/26] netfilter: switch nf_setsockopt to sockptr_t To: David Laight <David.Laight@aculab.com> Cc: Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, Linux Crypto Mailing List <linux-crypto@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Netdev <netdev@vger.kernel.org>, "bpf@vger.kernel.org" <bpf@vger.kernel.org>, "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>, "coreteam@netfilter.org" <coreteam@netfilter.org>, "linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>, "linux-hams@vger.kernel.org" <linux-hams@vger.kernel.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "bridge@lists.linux-foundation.org" <bridge@lists.linux-foundation.org>, "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>, "dccp@vger.kernel.org" <dccp@vger.kernel.org>, "linux-decnet-user@lists.sourceforge.net" <linux-decnet-user@lists.sourceforge.net>, "linux-wpan@vger.kernel.org" <linux-wpan@vger.kernel.org>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, "mptcp@lists.01.org" <mptcp@lists.01.org>, "lvs-devel@vger.kernel.org" <lvs-devel@vger.kernel.org>, "rds-devel@oss.oracle.com" <rds-devel@oss.oracle.com>, "linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>, "tipc-discussion@lists.sourceforge.net" <tipc-discussion@lists.sourceforge.net>, "linux-x25@vger.kernel.org" <linux-x25@vger.kernel.org>, Kernel Hardening <kernel-hardening@lists.openwall.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5B3D5418B5 X-Rspamd-UID: 834acd On Tue, Jul 28, 2020 at 10:07 AM David Laight <David.Laight@aculab.com> wrote: > > From: Christoph Hellwig > > Sent: 27 July 2020 17:24 > > > > On Mon, Jul 27, 2020 at 06:16:32PM +0200, Jason A. Donenfeld wrote: > > > Maybe sockptr_advance should have some safety checks and sometimes > > > return -EFAULT? Or you should always use the implementation where > > > being a kernel address is an explicit bit of sockptr_t, rather than > > > being implicit? > > > > I already have a patch to use access_ok to check the whole range in > > init_user_sockptr. > > That doesn't make (much) difference to the code paths that ignore > the user-supplied length. > OTOH doing the user/kernel check on the base address (not an > incremented one) means that the correct copy function is always > selected. Right, I had the same reaction in reading this, but actually, his code gets rid of the sockptr_advance stuff entirely and never mutates, so even though my point about attacking those pointers was missed, the code does the better thing now -- checking the base address and never mutating the pointer. So I think we're good. > > Perhaps the functions should all be passed a 'const sockptr_t'. > The typedef could be made 'const' - requiring non-const items > explicitly use the union/struct itself. I was thinking the same, but just by making the pointers inside the struct const. However, making the whole struct const via the typedef is a much better idea. That'd probably require changing the signature of init_user_sockptr a bit, which would be fine, but indeed I think this would be a very positive change. Jason Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6CAxOeIjIF+vwAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 15:10:58 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EOh1N+IjIF87zgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 15:10:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4DD55A2BCA; Tue, 28 Jul 2020 15:10:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729853AbgG1NKx (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 09:10:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729126AbgG1NKw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 09:10:52 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54BB6C061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 06:10:52 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id g6so8440936ljn.11 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 06:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=95kCl3s1NaB859WYZDS/Y6NEC7rOR7/y+2QJzEZMpfw=; b=I1mxrPliI5MxlTjT8QMHRt6r7t60UdvQYsDbtivwVphfSDVQ27kJKcReDTUn1RYi4j C6cZsodc7tfCGfzcLIiTJsHChjdyo0rqBNlqy7Oe3TvttgnIjuoDGE6pgG1llYfQEsOH zNDxI7ido9gsmQ0evJpJ1cuKxGUYNq1Xm85LHrCWTNBStwqHDGYV1g/9bFAAgo1jsVkx tyakQI03zp+gXu7aMrC7wFQBuk2/Smw04vwy7SFu6/kCIfWle+mcoBo/fulczgTP6DY+ 1G+f39zBXhqwMsyMgqluJcM/ri0bs7oPmZVNs3OK/NeKPM+yPZCYJX7NUx6tg5JrZnHO jQsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=95kCl3s1NaB859WYZDS/Y6NEC7rOR7/y+2QJzEZMpfw=; b=epO6TXprYf1l8zoyo5dVDAuiIqyNq6eNDHb8kreimWy0sUkgQkltPh4G2bpl+NFdav jLSxvKmhT/Wwx2l/yN0TGqptZD6/Fr6JHGLk3fIV91ZyNUSYhptHMtpZl4Z2V+9n2gs5 KC88Kk/q1Zy+PBO77jFyGMViHARtfqbSa5Tbjqk1Cx2GtSLXvs5iQtRQQL2H+4rnzfq2 S8HEPcAU7NfxSL5x6uySmGuZpfqL0WO+nF3qNhf3ZtHs+l3rt2dkHXKHT+/PC0FcOjtC 4X0HGCfc2VQdXuQ2EHy9rjbkbgQDVUnM0Y2KOdrFpOJeRp6j1e/8DqhNAwwdyFpuDH/5 JI2w== X-Gm-Message-State: AOAM531h+ln5b9oLtA3sz7LctF1MIkfDsjRp3oMUyukk31hjoWbgD8E+ SOGg1tiy7/meDTRLY75NeyiycUMxZQXPtSTNTJAuPg== X-Google-Smtp-Source: ABdhPJx1c66cOnWZhvbkeO9iArCizfuVk6pyEYQ4en5MCSyTGq6LafLgcc4YOM2mryqHHHNMj64LuftfAiSsi81EfHw= X-Received: by 2002:a05:651c:11c7:: with SMTP id z7mr11933053ljo.39.1595941850432; Tue, 28 Jul 2020 06:10:50 -0700 (PDT) MIME-Version: 1.0 References: <20200727173720.2700327-1-alainm@chromium.org> <17DA93F5-AB77-4C40-A5F2-38D8FE6C98A3@holtmann.org> In-Reply-To: <17DA93F5-AB77-4C40-A5F2-38D8FE6C98A3@holtmann.org> From: Alain Michaud <alainmichaud@google.com> Date: Tue, 28 Jul 2020 09:10:39 -0400 Message-ID: <CALWDO_Wo23ev9DcpvUoDdfWQYqVRcSXp-mMysRgzpcC8auf3gQ@mail.gmail.com> Subject: Re: [Bluez PATCH] main: adding configurable eir_max_name_len To: Marcel Holtmann <marcel@holtmann.org> Cc: Alain Michaud <alainm@chromium.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.78 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4DD55A2BCA X-Rspamd-UID: eda313 On Tue, Jul 28, 2020 at 2:58 AM Marcel Holtmann <marcel@holtmann.org> wrote: > > Hi Alain, > > > This change adds support for a configurable eir_max_name_len for > > platforms which requires a larger than 48 bytes complete name in EIR. > > > > From bluetoothctl: > > [bluetooth]# system-alias > > 012345678901234567890123456789012345678901234567890123456789 > > Changing 012345678901234567890123456789012345678901234567890123456789 > > succeeded > > [CHG] Controller DC:71:96:69:02:89 Alias: > > 012345678901234567890123456789012345678901234567890123456789 > > > > From btmon: > > < HCI Command: Write Local Name (0x03|0x0013) plen 248 #109 > > [hci0] 88.567990 > > Name: > > 012345678901234567890123456789012345678901234567890123456789 > >> HCI Event: Command Complete (0x0e) plen 4 > > #110 [hci0] 88.663854 > > Write Local Name (0x03|0x0013) ncmd 1 > > Status: Success (0x00) > > @ MGMT Event: Local Name Changed (0x0008) plen 260 > > {0x0004} [hci0] 88.663948 > > Name: > > 012345678901234567890123456789012345678901234567890123456789 > > Short name: > > < HCI Command: Write Extended Inquiry Response (0x03|0x0052) plen 241 > > FEC: Not required (0x00) > > Name (complete): > > 012345678901234567890123456789012345678901234567890123456789 > > TX power: 12 dBm > > Device ID: Bluetooth SIG assigned (0x0001) > > Vendor: Google (224) > > Product: 0xc405 > > Version: 0.5.6 (0x0056) > > 16-bit Service UUIDs (complete): 7 entries > > Generic Access Profile (0x1800) > > Generic Attribute Profile (0x1801) > > Device Information (0x180a) > > A/V Remote Control (0x110e) > > A/V Remote Control Target (0x110c) > > Handsfree Audio Gateway (0x111f) > > Audio Source (0x110a) > >> HCI Event: Command Complete (0x0e) plen 4 > > Write Extended Inquiry Response (0x03|0x0052) ncmd 1 > > Status: Success (0x00) > > > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > Signed-off-by: Alain Michaud <alainm@chromium.org> > > --- > > > > doc/mgmt-api.txt | 1 + > > src/adapter.c | 10 +++++++++- > > src/hcid.h | 1 + > > src/main.c | 5 +++++ > > src/main.conf | 5 +++++ > > 5 files changed, 21 insertions(+), 1 deletion(-) > > > > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt > > index ca0d38469..1bc0f0c12 100644 > > --- a/doc/mgmt-api.txt > > +++ b/doc/mgmt-api.txt > > @@ -3279,6 +3279,7 @@ Read Default System Configuration Command > > 0x0019 LE Connection Latency > > 0x001a LE Connection Supervision Timeout > > 0x001b LE Autoconnect Timeout > > + 0x001c Max EIR Name Length > > we can certainly do this, but I prefer that do this for LE and BR/EDR and name it that way as well. I do think that we need distinct values for br/edr and le since the available space is different. I don't think a single value makes sense for both transports. > > > > > This command can be used at any time and will return a list of > > supported default parameters as well as their current value. > > diff --git a/src/adapter.c b/src/adapter.c > > index 5e896a9f0..3adc67b63 100644 > > --- a/src/adapter.c > > +++ b/src/adapter.c > > @@ -2375,7 +2375,7 @@ static bool parse_pathloss(DBusMessageIter *value, > > return true; > > } > > > > -static bool parse_transport(DBusMessageIter *value, > > +static bool parse_transport(DBusMessageIter *value, > > struct discovery_filter *filter) > > { > > char *transport_str; > > @@ -4435,6 +4435,14 @@ static void load_default_system_params(struct btd_adapter *adapter) > > len += sizeof(params[i].u16); > > } > > > > + if (main_opts.default_params.eir_max_name_len) { > > + params[i].entry.type = 0x001c; > > + params[i].entry.length = sizeof(params[i].u16); > > + params[i].u16 = main_opts.default_params.eir_max_name_len; > > + ++i; > > + len += sizeof(params[i].u16); > > + } > > + > > Do you really want to keep it as uint16_t or is that just laziness since changing the kernel to support anything other than uint16_t is complicated? Yes, this is to re-use the existing infra without complicating the buffer structure. There are a couple more values that are effectively uint8_t but use uint16_t above (like page scan type). > > On a side note, you need to provide a uint16_t value in little endian to the MGMT wire protocol. Sounds like this is a separate issue that needs to be fixed for all values then. I'd rather keep that as a separate patch. > > > err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG, > > adapter->dev_id, len, params, NULL, NULL, NULL); > > if (!err) > > diff --git a/src/hcid.h b/src/hcid.h > > index 5f249ebf9..c9b59a374 100644 > > --- a/src/hcid.h > > +++ b/src/hcid.h > > @@ -93,6 +93,7 @@ struct main_opts { > > uint16_t le_conn_latency; > > uint16_t le_conn_lsto; > > uint16_t le_autoconnect_timeout; > > + uint16_t eir_max_name_len; > > } default_params; > > > > > > diff --git a/src/main.c b/src/main.c > > index ec7a9fbd7..74876e01d 100644 > > --- a/src/main.c > > +++ b/src/main.c > > @@ -123,6 +123,7 @@ static const char *controller_options[] = { > > "LEConnectionLatency", > > "LEConnectionSupervisionTimeout", > > "LEAutoconnecttimeout", > > + "EirMaxNameLength", > > NULL > > }; > > > > @@ -433,6 +434,10 @@ static void parse_controller_config(GKeyFile *config) > > &main_opts.default_params.le_autoconnect_timeout, > > 0x0001, > > 0x4000}, > > + { "EirMaxNameLength", > > + &main_opts.default_params.eir_max_name_len, > > + 0x0001, > > + 0x00EE}, > > }; > > uint16_t i; > > > > diff --git a/src/main.conf b/src/main.conf > > index f41203b96..7ecac5930 100644 > > --- a/src/main.conf > > +++ b/src/main.conf > > @@ -148,6 +148,11 @@ > > #LEConnectionSupervisionTimeout= > > #LEAutoconnecttimeout= > > > > +# EIR Max Name. This is the maximum length for the COMPLETE_NAME EIR section. > > +# If the name length exceeds this size, a SHORT_NAME section is used. > > +# Default: 48 > > +#EirMaxNameLength = 48 > > + > > [GATT] > > # GATT attribute cache. > > # Possible values: > > Regards > > Marcel > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UMkiDyolIF+vwAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 15:16:26 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id KKyqDSolIF90BQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 15:16:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7F131A0183; Tue, 28 Jul 2020 15:16:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729986AbgG1NQT (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 09:16:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729815AbgG1NQT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 09:16:19 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA3DEC061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 06:16:18 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id m15so10314110lfp.7 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 06:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h9A1NGOkr8rJIfzH8kuXgXF4QNKwsKAISrSFoMryNSg=; b=DzQiS492lRQ6hXDe3NJt0c4qe9KoRNl0uY/U3nvuvlTL5VmIRwSUmEHuR3y2BcBkLM tiW5THiuRvGDxEDcGfKriM6z+A9wXmNBZD3N17B81lVhlw2ee+42WW4hmyhQigL+kfA6 HFka2ppvG3fRyc3fvyAOqhWyuUf14ai6+P5jpLWStixAl72ljvcLIa96HfK8SR6SKN8M 0wmab40eVKMBxNyBGiirnf/BE/3GjVk07kr/qLkvp1wJLm4LSndK2pS5uh2geuV2QXKe /XNc+1rQCCLsueyDluwn+SZU57JIxv9duNun+x0X1VsnuJNZVql6kyFWSHaUyP2gP1yB tcOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h9A1NGOkr8rJIfzH8kuXgXF4QNKwsKAISrSFoMryNSg=; b=cfPMgJz7h0lH+Y0CTu2onNfK2iYNfonVcbo0hLIq5dvfikmgxfB1lqrcZsrKz4yjsI gWvDVh/8i1utr8v1Qcm2yiqVbMLPCmnTJCLl0905W+LRomYdFgnOt4k60SQaX4Lnf/93 V9OT44XO0ksndXcfmD8C1HYyzPjK9M0d+3mVJh/1GuPXvze7YI12mJ5txkv369aAsCxY U83LTnjsEV5RR0NK3MuHnHxTJO7JK7R2lc/c3PklAGy/4S4tDfzBlPFboMKezfCRCVN5 XRAg7i7SqLhny5ISpo0IcIxU4rSkRCEQ46WhQT+0mSF2KiFqjuM9a1Z+O+EToEMZYrwv v/4g== X-Gm-Message-State: AOAM531qCTjpMfOhEYPz/fcIas3h/Q52ikGsq5xkpf9SIClLXP8IW+5v CRp7dzKzHS85ru0UsvIiVQ4vQ1jIgTY3tYfQoMLsoFzB X-Google-Smtp-Source: ABdhPJxHaIvBAwXj5wyb6lP6uj+Rnz2sxrCd2f+UUfJDGntpXEfAwL436/850/ttGnZCRUoqkUmAxFFAyEXuAlEOmBE= X-Received: by 2002:a19:e45:: with SMTP id 66mr14522189lfo.82.1595942177114; Tue, 28 Jul 2020 06:16:17 -0700 (PDT) MIME-Version: 1.0 References: <20200727174641.1.Ic2cb84fb029a345c9e3901378717d1ab4e9246ab@changeid> <A475AABF-D0C9-4D22-9FCC-5D1DD346247E@holtmann.org> In-Reply-To: <A475AABF-D0C9-4D22-9FCC-5D1DD346247E@holtmann.org> From: Alain Michaud <alainmichaud@google.com> Date: Tue, 28 Jul 2020 09:16:05 -0400 Message-ID: <CALWDO_VDe6vKXQFhfTPOY7U+Act5N3W4yhTGb0=otpMiudNBvQ@mail.gmail.com> Subject: Re: [PATCH] Bluetooth: adding configurable eir_max_name_len To: Marcel Holtmann <marcel@holtmann.org> Cc: Alain Michaud <alainm@chromium.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7F131A0183 X-Rspamd-UID: 066987 On Tue, Jul 28, 2020 at 3:04 AM Marcel Holtmann <marcel@holtmann.org> wrote: > > Hi Alain, > > > This change adds support for a configurable eir_max_name_len for > > platforms which requires a larger than 48 bytes complete name in EIR. > > > > From bluetoothctl: > > [bluetooth]# system-alias > > 012345678901234567890123456789012345678901234567890123456789 > > Changing 012345678901234567890123456789012345678901234567890123456789 > > succeeded > > [CHG] Controller DC:71:96:69:02:89 Alias: > > 012345678901234567890123456789012345678901234567890123456789 > > > > From btmon: > > < HCI Command: Write Local Name (0x03|0x0013) plen 248 #109 > > [hci0] 88.567990 > > Name: > > 012345678901234567890123456789012345678901234567890123456789 > >> HCI Event: Command Complete (0x0e) plen 4 #110 [hci0] 88.663854 > > Write Local Name (0x03|0x0013) ncmd 1 > > Status: Success (0x00) > > @ MGMT Event: Local Name Changed (0x0008) plen 260 > > {0x0004} [hci0] 88.663948 > > Name: > > 012345678901234567890123456789012345678901234567890123456789 > > Short name: > > < HCI Command: Write Extended Inquiry Response (0x03|0x0052) plen 241 > > #111 [hci0] 88.663977 > > FEC: Not required (0x00) > > Name (complete): > > 012345678901234567890123456789012345678901234567890123456789 > > TX power: 12 dBm > > Device ID: Bluetooth SIG assigned (0x0001) > > Vendor: Google (224) > > Product: 0xc405 > > Version: 0.5.6 (0x0056) > > 16-bit Service UUIDs (complete): 7 entries > > Generic Access Profile (0x1800) > > Generic Attribute Profile (0x1801) > > Device Information (0x180a) > > A/V Remote Control (0x110e) > > A/V Remote Control Target (0x110c) > > Handsfree Audio Gateway (0x111f) > > Audio Source (0x110a) > >> HCI Event: Command Complete (0x0e) plen 4 #112 [hci0] 88.664874 > > Write Extended Inquiry Response (0x03|0x0052) ncmd 1 > > Status: Success (0x00) > > > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > Signed-off-by: Alain Michaud <alainm@chromium.org> > > > > --- > > > > include/net/bluetooth/hci_core.h | 1 + > > net/bluetooth/hci_core.c | 1 + > > net/bluetooth/hci_request.c | 29 +++++++++++++++++++++-------- > > net/bluetooth/mgmt_config.c | 5 +++++ > > 4 files changed, 28 insertions(+), 8 deletions(-) > > > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h > > index bee1b4778ccc..e08f92e7a9ca 100644 > > --- a/include/net/bluetooth/hci_core.h > > +++ b/include/net/bluetooth/hci_core.h > > @@ -298,6 +298,7 @@ struct hci_dev { > > __u8 dev_name[HCI_MAX_NAME_LENGTH]; > > __u8 short_name[HCI_MAX_SHORT_NAME_LENGTH]; > > __u8 eir[HCI_MAX_EIR_LENGTH]; > > + __u16 eir_max_name_len; > > __u16 appearance; > > __u8 dev_class[3]; > > __u8 major_class; > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > > index 6509f785dd14..b2507bd6613a 100644 > > --- a/net/bluetooth/hci_core.c > > +++ b/net/bluetooth/hci_core.c > > @@ -3536,6 +3536,7 @@ struct hci_dev *hci_alloc_dev(void) > > hdev->adv_instance_cnt = 0; > > hdev->cur_adv_instance = 0x00; > > hdev->adv_instance_timeout = 0; > > + hdev->eir_max_name_len = 48; > > > > hdev->sniff_max_interval = 800; > > hdev->sniff_min_interval = 80; > > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > > index 7c0c2fda04ad..f4714370b7e7 100644 > > --- a/net/bluetooth/hci_request.c > > +++ b/net/bluetooth/hci_request.c > > @@ -578,17 +578,21 @@ static u8 *create_uuid128_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len) > > static void create_eir(struct hci_dev *hdev, u8 *data) > > { > > u8 *ptr = data; > > + u8 size_remaining = HCI_MAX_EIR_LENGTH; > > size_t name_len; > > > > name_len = strlen(hdev->dev_name); > > > > if (name_len > 0) { > > /* EIR Data type */ > > - if (name_len > 48) { > > - name_len = 48; > > + if (name_len > min_t(u16, (HCI_MAX_EIR_LENGTH - 2), > > + hdev->eir_max_name_len)) { > > + name_len = min_t(u16, (HCI_MAX_EIR_LENGTH - 2), > > + hdev->eir_max_name_len); > > if we have proper input validation we could just skip this hard to read code. I could just use a variable name if you believe this would make it more readable. > > > ptr[1] = EIR_NAME_SHORT; > > - } else > > + } else { > > ptr[1] = EIR_NAME_COMPLETE; > > + } > > > > /* EIR Data length */ > > ptr[0] = name_len + 1; > > @@ -596,17 +600,21 @@ static void create_eir(struct hci_dev *hdev, u8 *data) > > memcpy(ptr + 2, hdev->dev_name, name_len); > > > > ptr += (name_len + 2); > > + size_remaining -= (name_len + 2); > > } > > > > - if (hdev->inq_tx_power != HCI_TX_POWER_INVALID) { > > + if (hdev->inq_tx_power != HCI_TX_POWER_INVALID && > > + size_remaining >= 3) { > > ptr[0] = 2; > > ptr[1] = EIR_TX_POWER; > > ptr[2] = (u8) hdev->inq_tx_power; > > > > ptr += 3; > > + size_remaining -= 3; > > } > > > > - if (hdev->devid_source > 0) { > > + if (hdev->devid_source > 0 && > > + size_remaining >= 10) { > > ptr[0] = 9; > > ptr[1] = EIR_DEVICE_ID; > > > > @@ -616,11 +624,16 @@ static void create_eir(struct hci_dev *hdev, u8 *data) > > put_unaligned_le16(hdev->devid_version, ptr + 8); > > > > ptr += 10; > > + size_remaining -= 10; > > } > > > > - ptr = create_uuid16_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data)); > > - ptr = create_uuid32_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data)); > > - ptr = create_uuid128_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data)); > > + ptr = create_uuid16_list(hdev, ptr, size_remaining); > > + size_remaining = HCI_MAX_EIR_LENGTH - (ptr - data); > > + > > + ptr = create_uuid32_list(hdev, ptr, size_remaining); > > + size_remaining = HCI_MAX_EIR_LENGTH - (ptr - data); > > + > > + ptr = create_uuid128_list(hdev, ptr, size_remaining); > > } > > > > void __hci_req_update_eir(struct hci_request *req) > > diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c > > index b30b571f8caf..420ea322a5b7 100644 > > --- a/net/bluetooth/mgmt_config.c > > +++ b/net/bluetooth/mgmt_config.c > > @@ -67,6 +67,7 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > > HDEV_PARAM_U16(0x001a, le_supv_timeout), > > HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b, > > def_le_autoconnect_timeout), > > + HDEV_PARAM_U16(0x001c, eir_max_name_len), > > We should really have range validation for these parameters. And we should document ranges in mgmt-api.txt as well. I recall you had given me feedback about not overly validating parameters at the kernel mgmt interface with the premise that the kernel will accept invalid configurations and it's just the responsibility of the bluez configuration to be done correctly. I'm happy to move the validations I've implemented in bluez here, please advise... > > > }; > > struct mgmt_rp_read_def_system_config *rp = (void *)params; > > > > @@ -138,6 +139,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > > case 0x0019: > > case 0x001a: > > case 0x001b: > > + case 0x001c: > > if (len != sizeof(u16)) { > > bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", > > len, sizeof(u16), type); > > @@ -251,6 +253,9 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > > hdev->def_le_autoconnect_timeout = > > msecs_to_jiffies(TLV_GET_LE16(buffer)); > > break; > > + case 0x0001c: > > + hdev->eir_max_name_len = TLV_GET_LE16(buffer); > > + break; > > default: > > bt_dev_warn(hdev, "unsupported parameter %u", type); > > break; > > Regards > > Marcel > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mJtMAtclIF/AcAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 15:19:19 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QJB/ANclIF9A2AAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 15:19:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate:hard: -4.6 X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 40EEF418B2; Tue, 28 Jul 2020 15:19:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729989AbgG1NTG (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 09:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729688AbgG1NTF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 09:19:05 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 114AEC061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 06:19:05 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id q7so21099885ljm.1 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 06:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rHyjrA+5bTHGOMjecP6wQzfdSf8jJn8fGl2/bDi+ny4=; b=WHKpKu2yFN3kOV1u5Da9POVyeeIw0r/VFUYpd7Xp79gqtuHCS4R8F5ZndJEEHgaG9l Vbbwc7UkU67GHo/AGc40v0xDg7uMKo16Zm9INxR1JZZdZ18U4QHAvqs5p5rFatJiF/b4 SZAWvLp8uzQPMa6PRmJaqR+jOcmytjGeo8HCSACQlxYv2ODQXkQ5vWbHJ4cv7w5js9L4 2E5D+QyI7ZxrPzkyVOBkyWZUTYdl+n0QXsWbEO1VnM/5sCEx1K/9omNY4z79hbmtENh3 QPl4Du2PyDIk4VFkKisq43nQKzhH2JWoWNaVfnzX4fWJWpdPhiPqL+1O32l8GIj6waU0 cQXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rHyjrA+5bTHGOMjecP6wQzfdSf8jJn8fGl2/bDi+ny4=; b=OpKmql7e0GokiRm2aPHGw+QjJd6JnY05Q1O18rkBZVvnS+vE3XotOkwKvQHvs+1KHk eZ8w4krIb+ZewMJ80/mzEcDy70hJ0doVHoQqH5rvggw1xBmXMy5GMP4JnlyEkC6cOIRq 7aDk77YB6Wl1Uwu5jdiTeq+oYTD68ixI1lD2n/5SRsgQKP10umGk6LYLTv12jZrdQCYp uU0bNspzCCCceWnrMawUkOuItnEIIo8nv7fQ4XUfuvxxadj5Yb7/ek015eGqo0GcqNST QY0W0DMDjH3cwsCKo6UEUAj7wdI+mdCHGL9mKjQtP9dSGFcLjk0eQcv/aLMJ2iXCEh93 IKlw== X-Gm-Message-State: AOAM531FiYrqQiViengZ3k/sqibmxakgLTJYbh61PC2nFaFQB9sWBvwj aKro0BqIGNkUVjqXtSBmg7rBjeikG84+OZ/CN+HjwA== X-Google-Smtp-Source: ABdhPJxi0k7kH39QUMobzIvOkUJDJ5bKx1N7wCtfX2/pIt3G1drs62J1umYbZfi51HEJvmI4HE2GGG4hjFr7Kb9l+Nk= X-Received: by 2002:a2e:80cc:: with SMTP id r12mr13833054ljg.344.1595942343232; Tue, 28 Jul 2020 06:19:03 -0700 (PDT) MIME-Version: 1.0 References: <20200717020332.Bluez.v3.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> In-Reply-To: <20200717020332.Bluez.v3.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> From: Alain Michaud <alainmichaud@google.com> Date: Tue, 28 Jul 2020 09:18:52 -0400 Message-ID: <CALWDO_UsrzyLFkmxcnE59zaZPjP8ByN3sSOLDse6LwwpTA=ZsQ@mail.gmail.com> Subject: Re: [Bluez PATCH v3 1/2] device: add device_remove_bonding function To: Archie Pusaka <apusaka@google.com>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: 40EEF418B2 X-Rspamd-UID: c2f61f Friendly ping to maintainers on this one. Thanks, Alain On Thu, Jul 16, 2020 at 2:04 PM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > This patch splits the "bonding removal" function in device.c, > because we need to remove bonding information when receiving > "virtual cable unplug" in HID profile. > > Reviewed-by: Alain Michaud <alainm@chromium.org> > --- > > Changes in v3: > - Call device_set_temporary on device_remove_bonding > > Changes in v2: None > > src/device.c | 28 ++++++++++++++++++---------- > src/device.h | 1 + > 2 files changed, 19 insertions(+), 10 deletions(-) > > diff --git a/src/device.c b/src/device.c > index 226216235..b23ecb7fd 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -4356,6 +4356,20 @@ static void delete_folder_tree(const char *dirname) > rmdir(dirname); > } > > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr_type) > +{ > + if (bdaddr_type == BDADDR_BREDR) > + device->bredr_state.bonded = false; > + else > + device->le_state.bonded = false; > + > + if (!device->bredr_state.bonded && !device->le_state.bonded) > + btd_device_set_temporary(device, true); > + > + btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > + bdaddr_type); > +} > + > static void device_remove_stored(struct btd_device *device) > { > char device_addr[18]; > @@ -4364,17 +4378,11 @@ static void device_remove_stored(struct btd_device *device) > char *data; > gsize length = 0; > > - if (device->bredr_state.bonded) { > - device->bredr_state.bonded = false; > - btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > - BDADDR_BREDR); > - } > + if (device->bredr_state.bonded) > + device_remove_bonding(device, BDADDR_BREDR); > > - if (device->le_state.bonded) { > - device->le_state.bonded = false; > - btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > - device->bdaddr_type); > - } > + if (device->le_state.bonded) > + device_remove_bonding(device, device->bdaddr_type); > > device->bredr_state.paired = false; > device->le_state.paired = false; > diff --git a/src/device.h b/src/device.h > index cb8d884e8..956fec1ae 100644 > --- a/src/device.h > +++ b/src/device.h > @@ -50,6 +50,7 @@ uint16_t btd_device_get_vendor(struct btd_device *device); > uint16_t btd_device_get_vendor_src(struct btd_device *device); > uint16_t btd_device_get_product(struct btd_device *device); > uint16_t btd_device_get_version(struct btd_device *device); > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr_type); > void device_remove(struct btd_device *device, gboolean remove_stored); > int device_address_cmp(gconstpointer a, gconstpointer b); > int device_bdaddr_cmp(gconstpointer a, gconstpointer b); > -- > 2.27.0.389.gc38d7665816-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kFElKxFYIF8mAwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 18:53:37 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id uMZNKRFYIF/WGwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 18:53:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2B580A1580; Tue, 28 Jul 2020 18:53:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731579AbgG1QxI (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 12:53:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731564AbgG1QxH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 12:53:07 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AEEEC0619D4 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 09:53:07 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id u10so676394plr.7 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 09:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=c/duvw4ZsYECTtG6428ayDqRJqh3goK3mMqdqJUrMoU=; b=gVV9OWXDpMds2AkkWUJ+GF2FLPtzrkTaNNzO3ZIwNLNMM0hmyEQY/lP55zh2SQxl9J L2LrJelirzgwf5PpbUOfrjbfTp6DX3zVGHGaxB2d/U5AyDNS9zEkPuCS1JEARyw/npaR DBxTul+A2hkoQmpfVdgXQKeyy+75UhkvP1fP4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=c/duvw4ZsYECTtG6428ayDqRJqh3goK3mMqdqJUrMoU=; b=ZvEZMdlcBma07dHThuCtQzEtN0aLXEWM3XQeNkVwuWnAOvpYMyAyXr7GeMenRCw4jK spYJ4sIC/D97hNzipS+PqOaEKN9LLofuXAIWj2VW2RU8u9lX+wL3m5cknclt7hqtMLRH V/bDydAPKHAmG+IDAM4BlNCf67bZOaS6zEzNHCXP3ZjXpnK0jGoCkP5fuGW0SzidSYYJ 0CBpPN7m/9z1+B+OX1X2BjdirFX8RHypFk0AmfFx1pZdWIjRq/VTe3w0k244RQSyIs8u eFZSA+zUi1tVCTdq2BQOrjJ7E8hd4/b1Yque86FQYZPVzin4u6E7ZYfCbLC7bPjyOBwK 2jHw== X-Gm-Message-State: AOAM533Gf/IAayo1ux9auxWZR8xTl73ZqNcjc782Q/O3BFuObhUWtd7f dm4jdza/cV5+YTQdbmDSQQ5Hsw== X-Google-Smtp-Source: ABdhPJz2on+N9OZ7VdHSCS4SV747vSQ9SlmLB7XVuvrM+WNfCNKTOGslexQhOO4L+PNl+3TPz6kXnA== X-Received: by 2002:a17:90b:380e:: with SMTP id mq14mr5169794pjb.1.1595955186855; Tue, 28 Jul 2020 09:53:06 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id n22sm3407940pjq.25.2020.07.28.09.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 09:53:06 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH v2] Bluetooth: Fix suspend notifier race Date: Tue, 28 Jul 2020 09:52:59 -0700 Message-Id: <20200728095253.v2.1.I7ebe9eaf684ddb07ae28634cb4d28cf7754641f1@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2B580A1580 X-Rspamd-UID: 227f56 Unregister from suspend notifications and cancel suspend preparations before running hci_dev_do_close. Otherwise, the suspend notifier may race with unregister and cause cmd_timeout even after hdev has been freed. Below is the trace from when this panic was seen: [ 832.578518] Bluetooth: hci_core.c:hci_cmd_timeout() hci0: command 0x0c05 tx timeout [ 832.586200] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 832.586203] #PF: supervisor read access in kernel mode [ 832.586205] #PF: error_code(0x0000) - not-present page [ 832.586206] PGD 0 P4D 0 [ 832.586210] PM: suspend exit [ 832.608870] Oops: 0000 [#1] PREEMPT SMP NOPTI [ 832.613232] CPU: 3 PID: 10755 Comm: kworker/3:7 Not tainted 5.4.44-04894-g1e9dbb96a161 #1 [ 832.630036] Workqueue: events hci_cmd_timeout [bluetooth] [ 832.630046] RIP: 0010:__queue_work+0xf0/0x374 [ 832.630051] RSP: 0018:ffff9b5285f1fdf8 EFLAGS: 00010046 [ 832.674033] RAX: ffff8a97681bac00 RBX: 0000000000000000 RCX: ffff8a976a000600 [ 832.681162] RDX: 0000000000000000 RSI: 0000000000000009 RDI: ffff8a976a000748 [ 832.688289] RBP: ffff9b5285f1fe38 R08: 0000000000000000 R09: ffff8a97681bac00 [ 832.695418] R10: 0000000000000002 R11: ffff8a976a0006d8 R12: ffff8a9745107600 [ 832.698045] usb 1-6: new full-speed USB device number 119 using xhci_hcd [ 832.702547] R13: ffff8a9673658850 R14: 0000000000000040 R15: 000000000000001e [ 832.702549] FS: 0000000000000000(0000) GS:ffff8a976af80000(0000) knlGS:0000000000000000 [ 832.702550] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 832.702550] CR2: 0000000000000000 CR3: 000000010415a000 CR4: 00000000003406e0 [ 832.702551] Call Trace: [ 832.702558] queue_work_on+0x3f/0x68 [ 832.702562] process_one_work+0x1db/0x396 [ 832.747397] worker_thread+0x216/0x375 [ 832.751147] kthread+0x138/0x140 [ 832.754377] ? pr_cont_work+0x58/0x58 [ 832.758037] ? kthread_blkcg+0x2e/0x2e [ 832.761787] ret_from_fork+0x22/0x40 [ 832.846191] ---[ end trace fa93f466da517212 ]--- Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Hi Marcel, This fixes a race between hci_unregister_dev and the suspend notifier. The suspend notifier handler seemed to be scheduling commands even after it was cleaned up and this was resulting in a panic in cmd_timeout (when it tries to requeue the cmd_timer). This was tested on 5.4 kernel with a suspend+resume stress test for 500+ iterations. I also confirmed that after a usb disconnect, the suspend notifier times out before the USB device is probed again (fixing the original race between the usb_disconnect + probe and the notifier). Thanks Abhishek Changes in v2: * Moved oops into commit message net/bluetooth/hci_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 5394ab56c915a9..4ba23b821cbf4a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3767,9 +3767,10 @@ void hci_unregister_dev(struct hci_dev *hdev) cancel_work_sync(&hdev->power_on); - hci_dev_do_close(hdev); - unregister_pm_notifier(&hdev->suspend_notifier); + cancel_work_sync(&hdev->suspend_prepare); + + hci_dev_do_close(hdev); if (!test_bit(HCI_INIT, &hdev->flags) && !hci_dev_test_flag(hdev, HCI_SETUP) && -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mE9jIypYIF8PaAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 18:54:02 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id IDphISpYIF9EMQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 18:54:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4F3C141760; Tue, 28 Jul 2020 18:53:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731622AbgG1Qxv (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 12:53:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731573AbgG1Qxv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 12:53:51 -0400 Received: from mail-ua1-x943.google.com (mail-ua1-x943.google.com [IPv6:2607:f8b0:4864:20::943]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC2C5C0619D2 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 09:53:50 -0700 (PDT) Received: by mail-ua1-x943.google.com with SMTP id i24so6703709uak.3 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 09:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Yvpeg2Hti/Lz6KJkvcbKXpV9L6rmb3s/f9V+aV3VkrA=; b=OlTI5XA+ZU7Eo568gSfdlWA6MNxaxKrClrzkgduxaM/FEXkDPxXZvNQnLBmu+3IxLU acAo2NhLc2fnCjvigk781R0yc19BV8juQIEXZ0HFT+sQbOqIfYMHzhnLZ/ng8ZWap5+1 X14YoTNoMOybWBoUNlj+U9K+rSVqb4ofqZWRI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Yvpeg2Hti/Lz6KJkvcbKXpV9L6rmb3s/f9V+aV3VkrA=; b=smgCIg8PFPfIR8GCfyK+wYMyrKQSIJZT4kj9tuTfuXVq6+gFRqFu0oOjyBEJPZmV1V lSBnNEx8aI5QlG7Zi7PLdgx2zjnYwE0p8Wn0+XrB8FToPLmESpl274QwyIrzMSlNoaLU V2Nz+r9W48AVp51YJqjBBhsN6BDi4mGmUMB2nl1h9Qd7w+xhNAmve6tJ3jJLqz7+nxv4 b1lW1cMkNV++Sdobq+twl331o7mYPefF7aTY3qle4cfs+Z10bJBgLWQpyetXwd/SN/uo TO9IWZ928zxkbGf8jQc4BSJMjtY8TyemSK9HM9du24cgPuLFZ/04YfFEpkE5sikFHd/4 8oTw== X-Gm-Message-State: AOAM532gpZP+pyFJgLe9T+HeZKajcwtjVrddJuIGGr2dw2nZnzFr9CaE X3AfjYvR3bIk/kWZ3Y3kzGF1J7WpjvxCqA+XPSThkw== X-Google-Smtp-Source: ABdhPJz8G6Fxjs1PqttEWpFqjr3j1q3Jg+4zJ9wdpz3qudY9juV0OmietcvOJPOBkBwrKuQbpn9Oj2Y49/sEf5+FtdM= X-Received: by 2002:a9f:2197:: with SMTP id 23mr10603446uac.60.1595955229872; Tue, 28 Jul 2020 09:53:49 -0700 (PDT) MIME-Version: 1.0 References: <20200728095253.v2.1.I7ebe9eaf684ddb07ae28634cb4d28cf7754641f1@changeid> In-Reply-To: <20200728095253.v2.1.I7ebe9eaf684ddb07ae28634cb4d28cf7754641f1@changeid> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Tue, 28 Jul 2020 09:53:37 -0700 Message-ID: <CANFp7mUYSJi5WWZ5nEkxyJd-LXgOzJ_gfgWJC2tPkrswtXu-0w@mail.gmail.com> Subject: Re: [PATCH v2] Bluetooth: Fix suspend notifier race To: Marcel Holtmann <marcel@holtmann.org> Cc: ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev <netdev@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4F3C141760 X-Rspamd-UID: 4afbba I sent this a bit too quick without a Fixes tag. Please disregard. v3 coming up. On Tue, Jul 28, 2020 at 9:53 AM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Unregister from suspend notifications and cancel suspend preparations > before running hci_dev_do_close. Otherwise, the suspend notifier may > race with unregister and cause cmd_timeout even after hdev has been > freed. > > Below is the trace from when this panic was seen: > > [ 832.578518] Bluetooth: hci_core.c:hci_cmd_timeout() hci0: command 0x0c05 tx timeout > [ 832.586200] BUG: kernel NULL pointer dereference, address: 0000000000000000 > [ 832.586203] #PF: supervisor read access in kernel mode > [ 832.586205] #PF: error_code(0x0000) - not-present page > [ 832.586206] PGD 0 P4D 0 > [ 832.586210] PM: suspend exit > [ 832.608870] Oops: 0000 [#1] PREEMPT SMP NOPTI > [ 832.613232] CPU: 3 PID: 10755 Comm: kworker/3:7 Not tainted 5.4.44-04894-g1e9dbb96a161 #1 > [ 832.630036] Workqueue: events hci_cmd_timeout [bluetooth] > [ 832.630046] RIP: 0010:__queue_work+0xf0/0x374 > [ 832.630051] RSP: 0018:ffff9b5285f1fdf8 EFLAGS: 00010046 > [ 832.674033] RAX: ffff8a97681bac00 RBX: 0000000000000000 RCX: ffff8a976a000600 > [ 832.681162] RDX: 0000000000000000 RSI: 0000000000000009 RDI: ffff8a976a000748 > [ 832.688289] RBP: ffff9b5285f1fe38 R08: 0000000000000000 R09: ffff8a97681bac00 > [ 832.695418] R10: 0000000000000002 R11: ffff8a976a0006d8 R12: ffff8a9745107600 > [ 832.698045] usb 1-6: new full-speed USB device number 119 using xhci_hcd > [ 832.702547] R13: ffff8a9673658850 R14: 0000000000000040 R15: 000000000000001e > [ 832.702549] FS: 0000000000000000(0000) GS:ffff8a976af80000(0000) knlGS:0000000000000000 > [ 832.702550] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [ 832.702550] CR2: 0000000000000000 CR3: 000000010415a000 CR4: 00000000003406e0 > [ 832.702551] Call Trace: > [ 832.702558] queue_work_on+0x3f/0x68 > [ 832.702562] process_one_work+0x1db/0x396 > [ 832.747397] worker_thread+0x216/0x375 > [ 832.751147] kthread+0x138/0x140 > [ 832.754377] ? pr_cont_work+0x58/0x58 > [ 832.758037] ? kthread_blkcg+0x2e/0x2e > [ 832.761787] ret_from_fork+0x22/0x40 > [ 832.846191] ---[ end trace fa93f466da517212 ]--- > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > --- > Hi Marcel, > > This fixes a race between hci_unregister_dev and the suspend notifier. > > The suspend notifier handler seemed to be scheduling commands even after > it was cleaned up and this was resulting in a panic in cmd_timeout (when > it tries to requeue the cmd_timer). > > This was tested on 5.4 kernel with a suspend+resume stress test for 500+ > iterations. I also confirmed that after a usb disconnect, the suspend > notifier times out before the USB device is probed again (fixing the > original race between the usb_disconnect + probe and the notifier). > > Thanks > Abhishek > > > Changes in v2: > * Moved oops into commit message > > net/bluetooth/hci_core.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index 5394ab56c915a9..4ba23b821cbf4a 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -3767,9 +3767,10 @@ void hci_unregister_dev(struct hci_dev *hdev) > > cancel_work_sync(&hdev->power_on); > > - hci_dev_do_close(hdev); > - > unregister_pm_notifier(&hdev->suspend_notifier); > + cancel_work_sync(&hdev->suspend_prepare); > + > + hci_dev_do_close(hdev); > > if (!test_bit(HCI_INIT, &hdev->flags) && > !hci_dev_test_flag(hdev, HCI_SETUP) && > -- > 2.28.0.rc0.142.g3c755180ce-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kINMMTJZIF9RNgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 18:58:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QEEELzJZIF+ypQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 18:58:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4E8DE4081A; Tue, 28 Jul 2020 18:58:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731677AbgG1Q6O (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 12:58:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731502AbgG1Q6N (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 12:58:13 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D4CAC061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 09:58:13 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id f193so850600pfa.12 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 09:58:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mwrIihuJNbQiyPto1EhLxqXOv3Ti56A9zl8lU/r4aiE=; b=ZQHUO2+CroLHpqPo+Cj3B3HT8//zhHljYnkiDIsNcb7XPWLQIwuTYDaWAcAzQVBKq/ JUlAduT+8Ty1m0zBRGSatQuHVY+Clnh3yX5gb+YaYyOUjdWHfQjKgHRiV83ZjDgQxanX yBWBUToCoLajNehMHXapzmxqp7WH90xU7V2Ts= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mwrIihuJNbQiyPto1EhLxqXOv3Ti56A9zl8lU/r4aiE=; b=tHrkguboDgePO6q6+yS15ZiSkB9Kny5Mj5tv7CYOT+5qFqkdQy69t8rnK5ny+uV60a BhA0xSbouL7yAxmv7OVXENzUPhuW8Uoqp0dHeCnLD99ua400fK1m1NRcejaS7o2miFzh a+hSudojZlHs7DIdQuSyy9yh5FF7yqAUHeKgx3x0uJ5h7guB49IcKtE/QIpeVpD2EL5b 3gdpRs4IXYx4RPXYGYVlLZvJFXHPWRsXfa+5MWV+v5dGrPzZAus7P2wL1UYZUhbr7BWI 6aUG88jj84PuoiHnu2EPhgnEpnBiUfRcEdyi8wtmdCgAiFZw50CyDtiwJerMPKXYtumA DDNQ== X-Gm-Message-State: AOAM532F5pqQXtNH5gjW/zSkmOacILja0ObW28+FN97P1rkgaL/ggO3T Sjx5mxmeqe1Vjl4gOidm8KJeWsvOk+0= X-Google-Smtp-Source: ABdhPJw+nSCGDiE1Ny04kjNuD3elgR8BcdAawE5hI5v4ATe2zTuJ9cQo1efaE0+gcHzHeSLDftFV8w== X-Received: by 2002:a63:b511:: with SMTP id y17mr24919808pge.425.1595955492765; Tue, 28 Jul 2020 09:58:12 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id z67sm10032403pfc.162.2020.07.28.09.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 09:58:12 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH v3] Bluetooth: Fix suspend notifier race Date: Tue, 28 Jul 2020 09:58:07 -0700 Message-Id: <20200728095711.v3.1.I7ebe9eaf684ddb07ae28634cb4d28cf7754641f1@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4E8DE4081A X-Rspamd-UID: 026774 Unregister from suspend notifications and cancel suspend preparations before running hci_dev_do_close. Otherwise, the suspend notifier may race with unregister and cause cmd_timeout even after hdev has been freed. Below is the trace from when this panic was seen: [ 832.578518] Bluetooth: hci_core.c:hci_cmd_timeout() hci0: command 0x0c05 tx timeout [ 832.586200] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 832.586203] #PF: supervisor read access in kernel mode [ 832.586205] #PF: error_code(0x0000) - not-present page [ 832.586206] PGD 0 P4D 0 [ 832.586210] PM: suspend exit [ 832.608870] Oops: 0000 [#1] PREEMPT SMP NOPTI [ 832.613232] CPU: 3 PID: 10755 Comm: kworker/3:7 Not tainted 5.4.44-04894-g1e9dbb96a161 #1 [ 832.630036] Workqueue: events hci_cmd_timeout [bluetooth] [ 832.630046] RIP: 0010:__queue_work+0xf0/0x374 [ 832.630051] RSP: 0018:ffff9b5285f1fdf8 EFLAGS: 00010046 [ 832.674033] RAX: ffff8a97681bac00 RBX: 0000000000000000 RCX: ffff8a976a000600 [ 832.681162] RDX: 0000000000000000 RSI: 0000000000000009 RDI: ffff8a976a000748 [ 832.688289] RBP: ffff9b5285f1fe38 R08: 0000000000000000 R09: ffff8a97681bac00 [ 832.695418] R10: 0000000000000002 R11: ffff8a976a0006d8 R12: ffff8a9745107600 [ 832.698045] usb 1-6: new full-speed USB device number 119 using xhci_hcd [ 832.702547] R13: ffff8a9673658850 R14: 0000000000000040 R15: 000000000000001e [ 832.702549] FS: 0000000000000000(0000) GS:ffff8a976af80000(0000) knlGS:0000000000000000 [ 832.702550] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 832.702550] CR2: 0000000000000000 CR3: 000000010415a000 CR4: 00000000003406e0 [ 832.702551] Call Trace: [ 832.702558] queue_work_on+0x3f/0x68 [ 832.702562] process_one_work+0x1db/0x396 [ 832.747397] worker_thread+0x216/0x375 [ 832.751147] kthread+0x138/0x140 [ 832.754377] ? pr_cont_work+0x58/0x58 [ 832.758037] ? kthread_blkcg+0x2e/0x2e [ 832.761787] ret_from_fork+0x22/0x40 [ 832.846191] ---[ end trace fa93f466da517212 ]--- Fixes: 9952d90ea2885 ("Bluetooth: Handle PM_SUSPEND_PREPARE and PM_POST_SUSPEND") Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Hi Marcel, This fixes a race between hci_unregister_dev and the suspend notifier. The suspend notifier handler seemed to be scheduling commands even after it was cleaned up and this was resulting in a panic in cmd_timeout (when it tries to requeue the cmd_timer). This was tested on 5.4 kernel with a suspend+resume stress test for 500+ iterations. I also confirmed that after a usb disconnect, the suspend notifier times out before the USB device is probed again (fixing the original race between the usb_disconnect + probe and the notifier). Thanks Abhishek Changes in v3: * Added fixes tag Changes in v2: * Moved oops into commit message net/bluetooth/hci_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 5394ab56c915a9..4ba23b821cbf4a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3767,9 +3767,10 @@ void hci_unregister_dev(struct hci_dev *hdev) cancel_work_sync(&hdev->power_on); - hci_dev_do_close(hdev); - unregister_pm_notifier(&hdev->suspend_notifier); + cancel_work_sync(&hdev->suspend_prepare); + + hci_dev_do_close(hdev); if (!test_bit(HCI_INIT, &hdev->flags) && !hci_dev_test_flag(hdev, HCI_SETUP) && -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qP6OH41oIF+LsAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 20:03:57 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id iMDBHY1oIF/y8AEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 20:03:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate:hard: -4.6 X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BFBB74166F; Tue, 28 Jul 2020 20:03:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732141AbgG1SDr (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 14:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728598AbgG1SDq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 14:03:46 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E628C061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 11:03:46 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id v13so1651587oiv.13 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 11:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dv3Q/pRdkfZQAIG5khmRSqIaEoGwwBiiMrsb7/J0js4=; b=XeIATN/iLIc/qj7tkzIxlpfFkjtij9WDXMlB2dtCqqe38hVV8r0kjNVCVgatec6OUG I3STQ94HnuFK8AF5a+Th9pTZ7mi1ndUolhON+3LpzYPC3uUwxDg6M6bgOoMa/ZSI3Ghs bKjTH6aIqqtF/OkhQp/3wwmFV2HLhlMTphOp2CUuntHunUN21yjOFTrHPF5cL4gMImsR pEhl9NkoD8wPxHGoB1Vjd3HlCqMvVe3JcR7BPKALmrMyJvnSMvuJZl9xJqBvvKkzxaHa //1nSxHwCfUvce649mRm1vnd5Cepksp9C4sqrrLf3kAhdvSsNuyFh6qHrZyXMLyKjnwN GHVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dv3Q/pRdkfZQAIG5khmRSqIaEoGwwBiiMrsb7/J0js4=; b=cOnn5NxCArF09H9JmVpFVX8IPQM4qFqErYqQffnaKbQR5Ns2uwHNBFWI/TBPsvJ0Eu HaqfzV1cFVMHEanzgsYs7nsd5kEBs89wYqLAJyOFOqp081n1Lt5nz43q4OhHzlu7YkTm nzyBCGg2xpANOgwZCK8u0OHM7sezfONEKGGLCB1Ym2wTFzK70T8c1W0nfkI93ZFdFmnX rfQsUxW47epL8FKdreVI1b1kWubiM16TQVog59M3UL/wUQyr7imP+3FLPab1eF1A+Uku RwSDVj15uEq6RH1uRce6B5IIczPEsMZ0pIuopGwGJ47jqPrIUBTSKXjrkzM9kT7DvNWL XKOA== X-Gm-Message-State: AOAM5333IhzbuHkDQ+sG6ApMF4dv/hmsggYuK3n/vxIoqFosWCnQLLyh e3IZcDagCIoSlbC4rVfUKCWqI3SIdr38nIvoNiA= X-Google-Smtp-Source: ABdhPJwpGkAxIF9u5LUtT0+EBcB0ZZlrJEnNDZLI4eWWNeb4xPKldIpI+xwq2MgnLdBduDPuRlWe4a6BDOrqpFSpdVE= X-Received: by 2002:aca:2819:: with SMTP id 25mr4304488oix.48.1595959425884; Tue, 28 Jul 2020 11:03:45 -0700 (PDT) MIME-Version: 1.0 References: <20200717020332.Bluez.v3.1.I1322f6745fa50365c1c88de3e2c50c9c5962c094@changeid> <CALWDO_UsrzyLFkmxcnE59zaZPjP8ByN3sSOLDse6LwwpTA=ZsQ@mail.gmail.com> In-Reply-To: <CALWDO_UsrzyLFkmxcnE59zaZPjP8ByN3sSOLDse6LwwpTA=ZsQ@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 28 Jul 2020 11:03:36 -0700 Message-ID: <CABBYNZK5aqhLXttAz6qie3LN5SnzmwuLFt8VtzQURjC+5UNXaQ@mail.gmail.com> Subject: Re: [Bluez PATCH v3 1/2] device: add device_remove_bonding function To: Alain Michaud <alainmichaud@google.com> Cc: Archie Pusaka <apusaka@google.com>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: BFBB74166F X-Rspamd-UID: 7b800f Hi, On Tue, Jul 28, 2020 at 6:19 AM Alain Michaud <alainmichaud@google.com> wrote: > > Friendly ping to maintainers on this one. > > Thanks, > Alain > > On Thu, Jul 16, 2020 at 2:04 PM Archie Pusaka <apusaka@google.com> wrote: > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > This patch splits the "bonding removal" function in device.c, > > because we need to remove bonding information when receiving > > "virtual cable unplug" in HID profile. > > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > --- > > > > Changes in v3: > > - Call device_set_temporary on device_remove_bonding > > > > Changes in v2: None > > > > src/device.c | 28 ++++++++++++++++++---------- > > src/device.h | 1 + > > 2 files changed, 19 insertions(+), 10 deletions(-) > > > > diff --git a/src/device.c b/src/device.c > > index 226216235..b23ecb7fd 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -4356,6 +4356,20 @@ static void delete_folder_tree(const char *dirname) > > rmdir(dirname); > > } > > > > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr_type) > > +{ > > + if (bdaddr_type == BDADDR_BREDR) > > + device->bredr_state.bonded = false; > > + else > > + device->le_state.bonded = false; > > + > > + if (!device->bredr_state.bonded && !device->le_state.bonded) > > + btd_device_set_temporary(device, true); > > + > > + btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > > + bdaddr_type); > > +} > > + > > static void device_remove_stored(struct btd_device *device) > > { > > char device_addr[18]; > > @@ -4364,17 +4378,11 @@ static void device_remove_stored(struct btd_device *device) > > char *data; > > gsize length = 0; > > > > - if (device->bredr_state.bonded) { > > - device->bredr_state.bonded = false; > > - btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > > - BDADDR_BREDR); > > - } > > + if (device->bredr_state.bonded) > > + device_remove_bonding(device, BDADDR_BREDR); > > > > - if (device->le_state.bonded) { > > - device->le_state.bonded = false; > > - btd_adapter_remove_bonding(device->adapter, &device->bdaddr, > > - device->bdaddr_type); > > - } > > + if (device->le_state.bonded) > > + device_remove_bonding(device, device->bdaddr_type); > > > > device->bredr_state.paired = false; > > device->le_state.paired = false; > > diff --git a/src/device.h b/src/device.h > > index cb8d884e8..956fec1ae 100644 > > --- a/src/device.h > > +++ b/src/device.h > > @@ -50,6 +50,7 @@ uint16_t btd_device_get_vendor(struct btd_device *device); > > uint16_t btd_device_get_vendor_src(struct btd_device *device); > > uint16_t btd_device_get_product(struct btd_device *device); > > uint16_t btd_device_get_version(struct btd_device *device); > > +void device_remove_bonding(struct btd_device *device, uint8_t bdaddr_type); > > void device_remove(struct btd_device *device, gboolean remove_stored); > > int device_address_cmp(gconstpointer a, gconstpointer b); > > int device_bdaddr_cmp(gconstpointer a, gconstpointer b); > > -- > > 2.27.0.389.gc38d7665816-goog > > Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aMuSETNqIF+LsAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 20:10:59 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id OPcVEDNqIF+LNwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 20:10:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0FA69A2CB7; Tue, 28 Jul 2020 20:10:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732239AbgG1SKx (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 14:10:53 -0400 Received: from mga07.intel.com ([134.134.136.100]:19385 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728834AbgG1SKx (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 14:10:53 -0400 IronPort-SDR: WmWiqBpKZ97LzAmNOCWdSkirne2J1FrSpqZTUfK/UITGqhUt9qjI9ZhL6d188/JIfCL2lepYgP 0smzNtvjHG0w== X-IronPort-AV: E=McAfee;i="6000,8403,9696"; a="215796103" X-IronPort-AV: E=Sophos;i="5.75,406,1589266800"; d="scan'208";a="215796103" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2020 11:10:52 -0700 IronPort-SDR: A6qK79H71M9Uxr+9EIltU83hE1/D66iPcYDMVG2RCIe0ZZBh2586bD4zeWucOOzVEevKqoabhf aOfFMTaLTVaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,406,1589266800"; d="scan'208";a="364586885" Received: from rmangham-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.114.251]) by orsmga001.jf.intel.com with ESMTP; 28 Jul 2020 11:10:52 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] mesh: Fix calculation of model publication period Date: Tue, 28 Jul 2020 11:10:51 -0700 Message-Id: <20200728181051.22075-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.64 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0FA69A2CB7 X-Rspamd-UID: 6bf436 This fixes the extraction of bit fields from model publication period octet received as part of Congif Publication Set message. The step resolution field is extracted as upper 2 bits (shift by 6) and the number of steps field is extracted by masking lower 6 bits. --- mesh/model.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mesh/model.c b/mesh/model.c index 31197b363..ef7668147 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -170,20 +170,21 @@ static struct mesh_model *get_model(struct mesh_node *node, uint8_t ele_idx, static uint32_t pub_period_to_ms(uint8_t pub_period) { - int n; + int step_res, num_steps; - n = pub_period >> 2; + step_res = pub_period >> 6; + num_steps = pub_period & 0x3f; - switch (pub_period & 0x3) { + switch (step_res) { default: - return n * 100; + return num_steps * 100; case 2: - n *= 10; + num_steps *= 10; /* Fall Through */ case 1: - return n * 1000; + return num_steps * 1000; case 3: - return n * 10 * 60 * 1000; + return num_steps * 10 * 60 * 1000; } } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QP/NJGxuIF8a1AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 20:29:00 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 4B9pI2xuIF+yVwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 20:29:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate:hard: -4.6 X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 47C3341752; Tue, 28 Jul 2020 20:28:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732417AbgG1S2p convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 14:28:45 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:57641 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728179AbgG1S2o (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 14:28:44 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id BD006CECD6; Tue, 28 Jul 2020 20:38:43 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v3] Bluetooth: Fix suspend notifier race From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200728095711.v3.1.I7ebe9eaf684ddb07ae28634cb4d28cf7754641f1@changeid> Date: Tue, 28 Jul 2020 20:28:41 +0200 Cc: chromeos-bluetooth-upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev <netdev@vger.kernel.org>, kernel list <linux-kernel@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org> Content-Transfer-Encoding: 8BIT Message-Id: <D320E0AF-EFF1-47BD-85F6-59168B170F65@holtmann.org> References: <20200728095711.v3.1.I7ebe9eaf684ddb07ae28634cb4d28cf7754641f1@changeid> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: 47C3341752 X-Rspamd-UID: 843f00 Hi Abhishek, > Unregister from suspend notifications and cancel suspend preparations > before running hci_dev_do_close. Otherwise, the suspend notifier may > race with unregister and cause cmd_timeout even after hdev has been > freed. > > Below is the trace from when this panic was seen: > > [ 832.578518] Bluetooth: hci_core.c:hci_cmd_timeout() hci0: command 0x0c05 tx timeout > [ 832.586200] BUG: kernel NULL pointer dereference, address: 0000000000000000 > [ 832.586203] #PF: supervisor read access in kernel mode > [ 832.586205] #PF: error_code(0x0000) - not-present page > [ 832.586206] PGD 0 P4D 0 > [ 832.586210] PM: suspend exit > [ 832.608870] Oops: 0000 [#1] PREEMPT SMP NOPTI > [ 832.613232] CPU: 3 PID: 10755 Comm: kworker/3:7 Not tainted 5.4.44-04894-g1e9dbb96a161 #1 > [ 832.630036] Workqueue: events hci_cmd_timeout [bluetooth] > [ 832.630046] RIP: 0010:__queue_work+0xf0/0x374 > [ 832.630051] RSP: 0018:ffff9b5285f1fdf8 EFLAGS: 00010046 > [ 832.674033] RAX: ffff8a97681bac00 RBX: 0000000000000000 RCX: ffff8a976a000600 > [ 832.681162] RDX: 0000000000000000 RSI: 0000000000000009 RDI: ffff8a976a000748 > [ 832.688289] RBP: ffff9b5285f1fe38 R08: 0000000000000000 R09: ffff8a97681bac00 > [ 832.695418] R10: 0000000000000002 R11: ffff8a976a0006d8 R12: ffff8a9745107600 > [ 832.698045] usb 1-6: new full-speed USB device number 119 using xhci_hcd > [ 832.702547] R13: ffff8a9673658850 R14: 0000000000000040 R15: 000000000000001e > [ 832.702549] FS: 0000000000000000(0000) GS:ffff8a976af80000(0000) knlGS:0000000000000000 > [ 832.702550] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [ 832.702550] CR2: 0000000000000000 CR3: 000000010415a000 CR4: 00000000003406e0 > [ 832.702551] Call Trace: > [ 832.702558] queue_work_on+0x3f/0x68 > [ 832.702562] process_one_work+0x1db/0x396 > [ 832.747397] worker_thread+0x216/0x375 > [ 832.751147] kthread+0x138/0x140 > [ 832.754377] ? pr_cont_work+0x58/0x58 > [ 832.758037] ? kthread_blkcg+0x2e/0x2e > [ 832.761787] ret_from_fork+0x22/0x40 > [ 832.846191] ---[ end trace fa93f466da517212 ]--- > > Fixes: 9952d90ea2885 ("Bluetooth: Handle PM_SUSPEND_PREPARE and PM_POST_SUSPEND") > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > --- > Hi Marcel, > > This fixes a race between hci_unregister_dev and the suspend notifier. > > The suspend notifier handler seemed to be scheduling commands even after > it was cleaned up and this was resulting in a panic in cmd_timeout (when > it tries to requeue the cmd_timer). > > This was tested on 5.4 kernel with a suspend+resume stress test for 500+ > iterations. I also confirmed that after a usb disconnect, the suspend > notifier times out before the USB device is probed again (fixing the > original race between the usb_disconnect + probe and the notifier). > > Thanks > Abhishek > > > Changes in v3: > * Added fixes tag > > Changes in v2: > * Moved oops into commit message > > net/bluetooth/hci_core.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sO5ADM5uIF9w2wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 28 Jul 2020 20:30:38 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id AFQzCs5uIF/7mgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 28 Jul 2020 20:30:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate:hard: -4.6 X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7C1674014C; Tue, 28 Jul 2020 20:30:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732442AbgG1SaY convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 14:30:24 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:39362 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732429AbgG1SaY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 14:30:24 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id A31F8CECD6; Tue, 28 Jul 2020 20:40:23 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v1] Bluetooth: hci_qca: Stop collecting memdump again for command timeout during SSR From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <1595951580-16724-1-git-send-email-gubbaven@codeaurora.org> Date: Tue, 28 Jul 2020 20:30:21 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, Matthias Kaehlcke <mka@chromium.org>, kernel list <linux-kernel@vger.kernel.org>, Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Hemantg <hemantg@codeaurora.org>, MSM <linux-arm-msm@vger.kernel.org>, Balakrishna Godavarthi <bgodavar@codeaurora.org>, Rocky Liao <rjliao@codeaurora.org>, hbandi@codeaurora.org, abhishekpandit@chromium.org Content-Transfer-Encoding: 8BIT Message-Id: <44CF30D5-CBD7-4979-8BF4-50565D21FA39@holtmann.org> References: <1595951580-16724-1-git-send-email-gubbaven@codeaurora.org> To: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7C1674014C X-Rspamd-UID: ddf3ca Hi Venkata, > Setting memdump state to idle prior to setting of callback function > pointer for command timeout to NULL,causing the issue.Now moved the > initialisation of memdump state to qca_setup(). > > Fixes: d841502c79e3 ("Bluetooth: hci_qca: Collect controller memory dump during SSR") > Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> > --- > drivers/bluetooth/hci_qca.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eOgpByDUIF+CEQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 03:42:56 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id OK9jBSDUIF9CuQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 03:42:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 21ED2A1A49; Wed, 29 Jul 2020 03:42:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730581AbgG2Bmk (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 21:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730436AbgG2Bmj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 21:42:39 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C8BDC0619D4 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:42:39 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id y206so1797501pfb.10 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2JREyKdWiZay/mV18M1Axh+euiqXpqs5sXmHMc+iAKQ=; b=mv5ftazHEBjQoDdXHQUpaVOF1CD/lzXNM9zfmJde18RJxukAT2Wx8L0bZBp7YGKNbx e9uphKZyPXLxsThr5ua9lbNWsAvEOrbDPDh4SnRUsxEj3KepOa5d2jGbyXpTAdsRCcXu 1xfJpH55O0nvsvyiDtieZSWOaXnVXd5BD95m0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2JREyKdWiZay/mV18M1Axh+euiqXpqs5sXmHMc+iAKQ=; b=LTYqa2JZNexIe+klDrezaNCDdL703vhu5nDLi+vWvrkmWWOjeyawvkBWp079AH/cIO 9Ho/PWlxUmzdRtuslrQIQ7uw0ancVFw5gT8gEF9/hChhDJUHT8lnB9a25TRZBfIJcpqv H3SS/KW24KPfFjOwSDPhVJ+2LAQltjRGmCUZwov7Vgfy+/bwlLlDp80O0dHwuWpBZYTr saprdhIJtdxd7LiVshESExQf/HanWIi3PZloucOOMTDNoCbamvWuPgUSJY2ozTEqT2lT DCNy+iht+jiz9EhWwxy9SvBhK/nlPCsUxe6YUwwlL6gRIYdtWp5hFlSl3nCUWINkFxTo UbxQ== X-Gm-Message-State: AOAM531udwwNg1i5ZuhzuiJiQxLU8IfesLsOUxqT2+4cYLdn+cdZAm9H kteUD1GWY8ToZ2IHADQ1yne23Q== X-Google-Smtp-Source: ABdhPJyCZXaEbxMk/vJPZ4nalToz0Wmy+riDDLOIm88MjiSUydfptFoj2rCEtzKrzaZTiG7rhBHK9g== X-Received: by 2002:a63:935c:: with SMTP id w28mr26269597pgm.174.1595986958935; Tue, 28 Jul 2020 18:42:38 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id e124sm280678pfe.176.2020.07.28.18.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 18:42:38 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH 0/3] Bluetooth: Emit events for suspend/resume Date: Tue, 28 Jul 2020 18:42:22 -0700 Message-Id: <20200729014225.1842177-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: 21ED2A1A49 X-Rspamd-UID: 7a4b08 Hi Marcel, This series adds the suspend/resume events suggested in https://patchwork.kernel.org/patch/11663455/. I have tested it with some userspace changes that monitors the controller resumed event to trigger audio device reconnection and verified that the events are correctly emitted. Please take a look. Abhishek Abhishek Pandit-Subedi (3): Bluetooth: Add mgmt suspend and resume events Bluetooth: Add suspend reason for device disconnect Bluetooth: Emit controller suspend and resume events include/net/bluetooth/hci_core.h | 6 +++ include/net/bluetooth/mgmt.h | 16 +++++++ net/bluetooth/hci_core.c | 26 +++++++++++- net/bluetooth/hci_event.c | 73 ++++++++++++++++++++++++++++++++ net/bluetooth/mgmt.c | 28 ++++++++++++ 5 files changed, 148 insertions(+), 1 deletion(-) -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IGzuFirUIF+NGAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 03:43:06 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 6JYlFSrUIF8d4wAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 03:43:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E52A9A0D28; Wed, 29 Jul 2020 03:43:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730769AbgG2Bmn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 21:42:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730712AbgG2Bmm (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 21:42:42 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C555C0619D4 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:42:42 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id m8so5227370pfh.3 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nBfnuzv8V/FS7CoKVmoMtrjti5jBBE6yafdUJVDo5Po=; b=XAIKwqvY7po1TDCttQKQqO/e8Ma4OJJxW1T7PIH7joYSz1wRad0wSNfTy589TpD044 Y/YZjJnATRIfGlCUGLFIT6eh/4FfuiICRwEPHELE/uCuNCoonPbraCn+Uta4RZKvu/Lp eXHEnZkEU2hePZ5Tn8pUOcG4eaydYHRI0kR/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nBfnuzv8V/FS7CoKVmoMtrjti5jBBE6yafdUJVDo5Po=; b=TEcUr3Jecz4DIZy7Xr+iyoBCjCMaGI3Qvu5vjgBrEuE9m6RtLXLPHDnheToiBhnMxl ZF2g/o0MdBb1gR9maSPWidMKwSXgEY4pdxon9lGIVefc6e1QJCr0d6d2PXy6HjvphfhS mKOM/q8a6X+0hJqC4mYaAJdAAK387qcHRCInIF+fpsNcjdsZvwwqWKrMgH0HT9GC2j5q 7HkR+bi/YtOAAxpdBBSg7fRVcgwLHNIvaJChSWUgDn95rtioDu4yM4lxoFYYKSnjOSOu 8VwTMzuIeyVowta0Lfeaq+W0i9E1klP4jIaDh46uGYRauG+6O4SyPHNNABkSRGOYI/Bz ZUXQ== X-Gm-Message-State: AOAM5325SBsHsUWmVzG59iw9drrX+qiTPijLNNEINeKNM4rXBh6VTjG2 Da3l6BdUxBDdyIPPo/QBcIsNZQ== X-Google-Smtp-Source: ABdhPJxYRdtAaml7y8yAJ+rrQl2TGi33yo+vrV97Qz+dt2ids7LCidVHdRJ93RKUkmsFGZ3RSn/e6Q== X-Received: by 2002:a63:2482:: with SMTP id k124mr6002008pgk.332.1595986961855; Tue, 28 Jul 2020 18:42:41 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id e124sm280678pfe.176.2020.07.28.18.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 18:42:41 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH 2/3] Bluetooth: Add suspend reason for device disconnect Date: Tue, 28 Jul 2020 18:42:24 -0700 Message-Id: <20200728184205.2.Ib9bb75b65362d32104df86ffad479761680bb2cb@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200729014225.1842177-1-abhishekpandit@chromium.org> References: <20200729014225.1842177-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: E52A9A0D28 X-Rspamd-UID: f8d3af Update device disconnect event with reason 0x5 to indicate that device disconnected because the controller is suspending. Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- include/net/bluetooth/mgmt.h | 1 + net/bluetooth/mgmt.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index d9a88cab379555..1a98f836aad126 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -840,6 +840,7 @@ struct mgmt_ev_device_connected { #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 #define MGMT_DEV_DISCONN_REMOTE 0x03 #define MGMT_DEV_DISCONN_AUTH_FAILURE 0x04 +#define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND 0x05 #define MGMT_EV_DEVICE_DISCONNECTED 0x000C struct mgmt_ev_device_disconnected { diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 1c89ae819207ac..fcda479134c756 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -8124,6 +8124,10 @@ void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, ev.addr.type = link_to_bdaddr(link_type, addr_type); ev.reason = reason; + /* Report disconnects due to suspend */ + if (hdev->suspended) + ev.reason = MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND; + mgmt_event(MGMT_EV_DEVICE_DISCONNECTED, hdev, &ev, sizeof(ev), sk); if (sk) -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +I3sCjjUIF+CEQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 03:43:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id KKMCCjjUIF83ogEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 03:43:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 82396A158F; Wed, 29 Jul 2020 03:43:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730867AbgG2Bmq (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 21:42:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730807AbgG2Bmp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 21:42:45 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE6E5C0619D4 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:42:44 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id f193so1676826pfa.12 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TTWGYBvqA0FGBCBxpUVNcj7EdtNcrKdKGjNiWmgR93Y=; b=U2MIefGuIXd13cnSb0ZAFli4kl4ZOOR8ESIZZM35Xu6end7x/RZIhzk2AB1jw7Tya3 c+kEyj5sx3+PWUHz3h1ddt1JKTWHqFyY7djoFc1Kt+ztjb7HCk5uh96R5Ix7d94NXgEw rirq+arwB4xxA8aQUpmNRPyxa3TNqFtT3wS/Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TTWGYBvqA0FGBCBxpUVNcj7EdtNcrKdKGjNiWmgR93Y=; b=LLJkeELVFC6JzUCw3izTNPItyhDtj9zKvrOIs5oYfMEFouYjOu+IOyY+1HzrWgpRfO UIQWEo96iNZTXbhTJy7/4ORVF0y/l9IJcpMEciBdrnH5DSUsbsAZelwJdQdsw5QGILPg rWYu9Tuw70AIgv+5FjS84aeooEoGMMIIWtwzediZjGHb+rSYu5YC1sMWXpL5GDDsMDSW xpB4Ilsi6ER5U4TH5iUhW0vPMoXsd2mkhbJ/U0mliXMCczD1OdNqAjFZt8rBhb4k/cAU bBZzoKRDTkVA9VFXDPuVTgFn9qYuzuOEXCaHrEpYvWPV3rSHn48OGa26khzAdM75kMGD zX7w== X-Gm-Message-State: AOAM532Y/qCddJgOdITsYkZmG98j6h0QzLwwKaXkEPUaYv0hX/OyGi/8 1fL3QPsh4JSSPkwMzzK04oMIyA== X-Google-Smtp-Source: ABdhPJwxlR53Zt2NE7zO6R6YwgjRkRxgrjeVb59NedA9DKp000Hg/dnFnwY6rUOYxeUcxo+iWLrFTw== X-Received: by 2002:a63:2223:: with SMTP id i35mr27980589pgi.64.1595986964426; Tue, 28 Jul 2020 18:42:44 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id e124sm280678pfe.176.2020.07.28.18.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 18:42:42 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH 3/3] Bluetooth: Emit controller suspend and resume events Date: Tue, 28 Jul 2020 18:42:25 -0700 Message-Id: <20200728184205.3.I905caec7d7bf0eb7a3ed9899b5afb9aebaf6f8a8@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200729014225.1842177-1-abhishekpandit@chromium.org> References: <20200729014225.1842177-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 82396A158F X-Rspamd-UID: c4d053 Emit controller suspend and resume events when we are ready for suspend and we've resumed from suspend. The controller suspend event will report whatever suspend state was successfully entered. The controller resume event will check the first HCI event that was received after we finished preparing for suspend and, if it was a connection event, store the address of the peer that caused the event. If it was not a connection event, we mark the wake reason as an unexpected event. Here is a sample btmon trace with these events: @ MGMT Event: Controller Suspended (0x002d) plen 1 Suspend state: Page scanning and/or passive scanning (2) @ MGMT Event: Controller Resumed (0x002e) plen 8 Wake reason: Remote wake due to peer device connection (2) LE Address: CD:F3:CD:13:C5:9A (OUI CD-F3-CD) Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- include/net/bluetooth/hci_core.h | 3 ++ include/net/bluetooth/mgmt.h | 4 ++ net/bluetooth/hci_core.c | 26 +++++++++++- net/bluetooth/hci_event.c | 73 ++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 1b336e6ebe66aa..7314798e47c3d6 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -484,6 +484,9 @@ struct hci_dev { enum suspended_state suspend_state; bool scanning_paused; bool suspended; + u8 wake_reason; + bdaddr_t wake_addr; + u8 wake_addr_type; wait_queue_head_t suspend_wait_q; DECLARE_BITMAP(suspend_tasks, __SUSPEND_NUM_TASKS); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 1a98f836aad126..052fe443484112 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -1040,3 +1040,7 @@ struct mgmt_ev_controller_resume { __u8 wake_reason; struct mgmt_addr_info addr; } __packed; + +#define MGMT_WAKE_REASON_NON_BT_WAKE 0x0 +#define MGMT_WAKE_REASON_UNEXPECTED 0x1 +#define MGMT_WAKE_REASON_REMOTE_WAKE 0x2 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 4ba23b821cbf4a..2cc121731d6a7e 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3470,12 +3470,24 @@ static int hci_change_suspend_state(struct hci_dev *hdev, return hci_suspend_wait_event(hdev); } +static void hci_clear_wake_reason(struct hci_dev *hdev) +{ + hci_dev_lock(hdev); + + hdev->wake_reason = 0; + bacpy(&hdev->wake_addr, BDADDR_ANY); + hdev->wake_addr_type = 0; + + hci_dev_unlock(hdev); +} + static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action, void *data) { struct hci_dev *hdev = container_of(nb, struct hci_dev, suspend_notifier); int ret = 0; + u8 state = BT_RUNNING; /* If powering down, wait for completion. */ if (mgmt_powering_down(hdev)) { @@ -3496,15 +3508,27 @@ static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action, * - Second, program event filter/whitelist and enable scan */ ret = hci_change_suspend_state(hdev, BT_SUSPEND_DISCONNECT); + if (!ret) + state = BT_SUSPEND_DISCONNECT; /* Only configure whitelist if disconnect succeeded and wake * isn't being prevented. */ - if (!ret && !(hdev->prevent_wake && hdev->prevent_wake(hdev))) + if (!ret && !(hdev->prevent_wake && hdev->prevent_wake(hdev))) { ret = hci_change_suspend_state(hdev, BT_SUSPEND_CONFIGURE_WAKE); + if (!ret) + state = BT_SUSPEND_CONFIGURE_WAKE; + } + + hci_clear_wake_reason(hdev); + mgmt_suspending(hdev, state); + } else if (action == PM_POST_SUSPEND) { ret = hci_change_suspend_state(hdev, BT_RUNNING); + + mgmt_resuming(hdev, hdev->wake_reason, &hdev->wake_addr, + hdev->wake_addr_type); } done: diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 61f8c4d1202823..e92311ead456e5 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5979,6 +5979,76 @@ static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, return true; } +static void hci_store_wake_reason(struct hci_dev *hdev, u8 event, + struct sk_buff *skb) +{ + struct hci_ev_le_advertising_info *adv; + struct hci_ev_le_direct_adv_info *direct_adv; + struct hci_ev_le_ext_adv_report *ext_adv; + const struct hci_ev_conn_complete *conn_complete = (void *)skb->data; + const struct hci_ev_conn_request *conn_request = (void *)skb->data; + + hci_dev_lock(hdev); + + /* If we are currently suspended and this is the first BT event seen, + * save the wake reason associated with the event. + */ + if (!hdev->suspended || hdev->wake_reason) + goto unlock; + + /* Default to remote wake. Values for wake_reason are documented in the + * Bluez mgmt api docs. + */ + hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; + + /* Once configured for remote wakeup, we should only wake up for + * reconnections. It's useful to see which device is waking us up so + * keep track of the bdaddr of the connection event that woke us up. + */ + if (event == HCI_EV_CONN_REQUEST) { + bacpy(&hdev->wake_addr, &conn_complete->bdaddr); + hdev->wake_addr_type = BDADDR_BREDR; + } else if (event == HCI_EV_CONN_COMPLETE) { + bacpy(&hdev->wake_addr, &conn_request->bdaddr); + hdev->wake_addr_type = BDADDR_BREDR; + } else if (event == HCI_EV_LE_META) { + struct hci_ev_le_meta *le_ev = (void *)skb->data; + u8 subevent = le_ev->subevent; + u8 *ptr = &skb->data[sizeof(*le_ev)]; + u8 num_reports = *ptr; + + if ((subevent == HCI_EV_LE_ADVERTISING_REPORT || + subevent == HCI_EV_LE_DIRECT_ADV_REPORT || + subevent == HCI_EV_LE_EXT_ADV_REPORT) && + num_reports) { + adv = (void *)(ptr + 1); + direct_adv = (void *)(ptr + 1); + ext_adv = (void *)(ptr + 1); + + switch (subevent) { + case HCI_EV_LE_ADVERTISING_REPORT: + bacpy(&hdev->wake_addr, &adv->bdaddr); + hdev->wake_addr_type = adv->bdaddr_type; + break; + + case HCI_EV_LE_DIRECT_ADV_REPORT: + bacpy(&hdev->wake_addr, &direct_adv->bdaddr); + hdev->wake_addr_type = direct_adv->bdaddr_type; + break; + case HCI_EV_LE_EXT_ADV_REPORT: + bacpy(&hdev->wake_addr, &ext_adv->bdaddr); + hdev->wake_addr_type = ext_adv->bdaddr_type; + break; + } + } + } else { + hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; + } + +unlock: + hci_dev_unlock(hdev); +} + void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_event_hdr *hdr = (void *) skb->data; @@ -6012,6 +6082,9 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) skb_pull(skb, HCI_EVENT_HDR_SIZE); + /* Store wake reason if we're suspended */ + hci_store_wake_reason(hdev, event, skb); + switch (event) { case HCI_EV_INQUIRY_COMPLETE: hci_inquiry_complete_evt(hdev, skb); -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cKY9H0LUIF+CEQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 03:43:30 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eCqVHULUIF9CuQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 03:43:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EE847A19E0; Wed, 29 Jul 2020 03:43:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730620AbgG2Bml (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 21:42:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730594AbgG2Bml (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 21:42:41 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8AB5C061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:42:40 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id l63so13366222pge.12 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eSNl5guPVSTVFb6xmLUiPtvBabfXpb7A/lKPqGtlYVE=; b=Z1OP5tnvZFehixnm5/zklBzayLRLEJOr/wpWZHZdO9CCj3RzpX4aCf8laptB3LXr7m mMxRRhYsJ9NYel6WVmcmi2xleu2s/YC3hcavNYO2HFM3zX68h7M2aB3KB289JeVoCtd2 RT8YAS/tfcxMD+qySCgNPwM64IvQtPQo3uvdA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eSNl5guPVSTVFb6xmLUiPtvBabfXpb7A/lKPqGtlYVE=; b=mMuDDahuUJjx7SsBXgJ38pVpbbmbuneKaF0fnlqmCzAmBrZKA/iiIgO85QukzIKQ3h faeTi/YiopKOvf8x0MroC8nMhn9iwBr0/CTXeTmX4Jj/EBiKRNYVjPTNhkS9WImxYrog 9vtr/Vi9SfclfjKaF6fJSxcHnJNYLb9TitQo9TMEAY7oXJ+euF3DOnxPBPKONRxJ4nHT L7TZlJZ2yL2rYcg0BLWE17Fck47TAP8Zq44Puq4DQJZKsB4FtWxOA6wp2JGs3Bpe/GQX /ULtZz5MSP99GewUFkQ4+uXJjPekAYXpKetulLGrH9hv3hcSC/2D7EgjVm23jixYQ91q Ewlw== X-Gm-Message-State: AOAM530A4+/ZTu6PWFwSsRuj+CrfrqgktV6PTk1rXEcq33o/Vrjb8IZ2 VUOyVCPEUjQYEmuUhonuYHcAyQ== X-Google-Smtp-Source: ABdhPJxmMzqdfhSy+5r+Shhpe9Koc5HP/8a+PhUzDBJ2QPDK9IcuRsnWyLnvvshaymFwOpCL7O2t1g== X-Received: by 2002:a63:454d:: with SMTP id u13mr5805629pgk.309.1595986960385; Tue, 28 Jul 2020 18:42:40 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id e124sm280678pfe.176.2020.07.28.18.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 18:42:39 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH 1/3] Bluetooth: Add mgmt suspend and resume events Date: Tue, 28 Jul 2020 18:42:23 -0700 Message-Id: <20200728184205.1.I1b721ef9da5c79d8515018d806801da4eacaf563@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200729014225.1842177-1-abhishekpandit@chromium.org> References: <20200729014225.1842177-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: EE847A19E0 X-Rspamd-UID: ca346d Add the controller suspend and resume events, which will signal when Bluetooth has completed preparing for suspend and when it's ready for resume. Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- include/net/bluetooth/hci_core.h | 3 +++ include/net/bluetooth/mgmt.h | 11 +++++++++++ net/bluetooth/mgmt.c | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index bee1b4778ccc96..1b336e6ebe66aa 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1747,6 +1747,9 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, s8 rssi, u8 *name, u8 name_len); void mgmt_discovering(struct hci_dev *hdev, u8 discovering); +void mgmt_suspending(struct hci_dev *hdev, u8 state); +void mgmt_resuming(struct hci_dev *hdev, u8 reason, bdaddr_t *bdaddr, + u8 addr_type); bool mgmt_powering_down(struct hci_dev *hdev); void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent); void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk, bool persistent); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index beae5c3980f03b..d9a88cab379555 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -1028,3 +1028,14 @@ struct mgmt_ev_adv_monitor_added { struct mgmt_ev_adv_monitor_removed { __le16 monitor_handle; } __packed; + +#define MGMT_EV_CONTROLLER_SUSPEND 0x002d +struct mgmt_ev_controller_suspend { + __u8 suspend_state; +} __packed; + +#define MGMT_EV_CONTROLLER_RESUME 0x002e +struct mgmt_ev_controller_resume { + __u8 wake_reason; + struct mgmt_addr_info addr; +} __packed; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index f45105d2de7722..1c89ae819207ac 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -8730,6 +8730,30 @@ void mgmt_discovering(struct hci_dev *hdev, u8 discovering) mgmt_event(MGMT_EV_DISCOVERING, hdev, &ev, sizeof(ev), NULL); } +void mgmt_suspending(struct hci_dev *hdev, u8 state) +{ + struct mgmt_ev_controller_suspend ev; + + ev.suspend_state = state; + mgmt_event(MGMT_EV_CONTROLLER_SUSPEND, hdev, &ev, sizeof(ev), NULL); +} + +void mgmt_resuming(struct hci_dev *hdev, u8 reason, bdaddr_t *bdaddr, + u8 addr_type) +{ + struct mgmt_ev_controller_resume ev; + + ev.wake_reason = reason; + if (bdaddr) { + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = addr_type; + } else { + memset(&ev.addr, 0, sizeof(ev.addr)); + } + + mgmt_event(MGMT_EV_CONTROLLER_RESUME, hdev, &ev, sizeof(ev), NULL); +} + static struct hci_mgmt_chan chan = { .channel = HCI_CHANNEL_CONTROL, .handler_count = ARRAY_SIZE(mgmt_handlers), -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eAZTKSrXIF+hHwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 03:55:54 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 4EudJyrXIF/gZAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 03:55:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 924684081A; Wed, 29 Jul 2020 03:55:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730428AbgG2Bzr (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 21:55:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728401AbgG2Bzr (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 21:55:47 -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 6E0E8C061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:55:47 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id t6so11071436plo.3 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:55:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0mg8uMGqdODjV0twVLdps/ZZK7k46XwhUkh9iWxwZlk=; b=aTzRitfxz9zopfIM5sf1aA962vCcQ41AV5sAyCoKScsjH8DBz42gqa7qT0+4acAQTl O3gUENOJcN6Nj3BNQpvAtljk8vlMT+RkpJZv0/+UjMvCGDOBNW1m5yQXB2JsFh8UfJnG 8G0Uubw1tHMZJ/KXSOTNZI2GR2BWt4JnO5tP8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0mg8uMGqdODjV0twVLdps/ZZK7k46XwhUkh9iWxwZlk=; b=aTQdo0V6m3isXEtheAdw56nF3rCTxMp2tpNREgQEkQdRhLFMOuqxtrHbzyt6VmW0R2 BkQRQrNrz9GAGBXN84D36WU2sdiaIL4IC240d9Tmu7Umll/nVw1ovAFxccr3U629bfWo dB+lwpN2KmX/157gLXU1H6F3zViLJfej0JYUyKRBOBNu3apcHecrQNvcC6gbaMWJSPDu xci1rZ5p2Lt78pdxskQ1afCBRes2K0dproxfUgp27K8x5JVQ0OyHmuMXav9PjdSh2G0K dfMSht6XxH9fCuaKaGbxy8M7UeGYfDZOTm99tiRxcBL1f+hwg4oqgU/e5GE0miNA2F+9 B6GA== X-Gm-Message-State: AOAM533MDdlJs3eFuaeHWU9rvPfLfVHZR+qfsqarMmfB8c23Xe84Mk7K HCed7m9fcGPzfSrpL3eXpr2T5g== X-Google-Smtp-Source: ABdhPJxhkc0GWRy4AcCb9BdoANI6K3BqmozunmTWCY/XpstZW0eebZ82Nhp2Ej8T4dNGEWBGxeFHOA== X-Received: by 2002:a17:90a:d30e:: with SMTP id p14mr7466443pju.72.1595987746779; Tue, 28 Jul 2020 18:55:46 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id lr1sm371128pjb.27.2020.07.28.18.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 18:55:46 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [RFC Bluez PATCH 0/3] adapter: Reconnect audio when resuming from suspend Date: Tue, 28 Jul 2020 18:55:37 -0700 Message-Id: <20200729015540.1848987-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 924684081A X-Rspamd-UID: 3caeea Hi Luiz and Marcel, This is a quality of life improvement for the behavior of audio devices during system suspend. This depends on a kernel change that emits suspend/resume events: https://patchwork.kernel.org/project/bluetooth/list/?series=325771 Right now, audio devices will be disconnected as part of suspend but won't be reconnected when the system resumes without user interaction. This is annoying to some users as it causes an interruption to their normal work flow. This change reconnects audio devices that were disconnected for suspend using the following logic: * In the Device Disconnected management event, if the disconnect reason was 0x5 (Disconnected by Local Host for Suspend) and the device is an audio sink (implements major services Audio + Rendering), then it is queued for reconnect. * When the Controller Resumed management event is seen, we check if an audio device needs to be reconnected. If yes, we queue a delayed callback to do the reconnection. The delay is 5s by default and is meant to allow sufficient time for any Wi-Fi activity that may occur during resume (since Bluetooth connect may adversely affect that). A reconnect is only attempted once after the controller resumes and the delay between resume and reconnect is configurable via the ReconnectAudioDelay key in the General settings. The 5s delay was chosen arbitrarily and I think anywhere up to 10s is probably ok. A longer delay is better to account for spurious wakeups and Wi-Fi reconnection time (avoiding any co-ex issues) at the downside of reconnection speed. Here are the tests I have done with this: - Single suspend and verified the headphones reconnect - Suspend stress test for 25 iterations and verify both Wi-Fi and Bluetooth audio reconnect on resume. (Ran with wake minimum time of 10s) - Suspend test with wake time < 5s to verify that BT reconnect isn't attempted. Ran 5 iterations with low wake time and then let it stay awake to confirm reconnect finally completed after 5s+ wake time. - Suspend test with wake time between 3s - 6s. Ran with 5 iterations and verified it wasn't connected at the end. A connection attempt was made but not completed due to suspend. A reconnect attempt was not made afterwards, which is by design. Luiz@ Marcel@: Does this sound ok (give up after an attempt)? I've tested this on a Pixelbook Go (AC-9260 controller) and HP Chromebook 14a (RTL8822CE controller) with GID6B headset. I'm hoping to test this with a few more headsets to make sure this is ok and I'm looking for some early feedback. Thanks Abhishek Abhishek Pandit-Subedi (3): mgmt: Add controller suspend and resume events monitor: Add btmon support for Suspend and Resume events adapter: Reconnect audio on controller resume lib/mgmt.h | 14 +++++++++ monitor/packet.c | 55 ++++++++++++++++++++++++++++++++ src/adapter.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ src/device.c | 27 ++++++++++++++++ src/device.h | 2 ++ src/main.conf | 6 ++++ 6 files changed, 186 insertions(+) -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QC8JBTDXIF+hHwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 03:56:00 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YI+PAzDXIF/gZAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 03:56:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C40D84014C; Wed, 29 Jul 2020 03:55:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730482AbgG2Bzs (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 21:55:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728401AbgG2Bzs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 21:55:48 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57872C061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:55:48 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id s15so1848680pgc.8 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:from:to:cc:subject:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=mXBex8ZJ0TICmkQfoN/8o5iy8D64BOqXLNddA9sjDq8=; b=elU2pB4w6l8NTNQ8tqJ2kEzg4xDmwAL8+1maA4Slfxu7cyz9VngP0uJtJpIznk+2fv 0k5MqcPTC40I2HxxMITY36t7bCF0lTuFnQensM6ZL9CjGD7Jntl97FUGJWEnMCYelcbZ cKycQHPv1TpPtzwfua/HQJQJFW4EgZQ+OwE+M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=mXBex8ZJ0TICmkQfoN/8o5iy8D64BOqXLNddA9sjDq8=; b=THaBB8R6osE6HjDZqTHmwYyySp3cCiADrsKTbAwVJhAFCnDp4DnLbPhyA2T6tnD0Q3 RQilZdAS1Y2pJr/Tzpk8E6D6oSisjjo/p2J0sfFi4D2/omuHxKhr+Nbn8lWAweG14Iyj Wo75XfmQYRw7syoGErIqWzXOKzPtXtI40d2oycYs5JGS+r6ykx3+rHY92NaBVYTeEvua eUpAQX0LG+cPPWv2kwaOhinMjtS9gZ2bF9q0AYWpO0GS83ozm42ZykugrKXJn6BlBpG3 lCpK7YvdgkJiwLmKYU2V5wQryYdVKDfMiQAjPJo4X3e/W2yvpxBw9+cXGbkBTvpVQEQr q04g== X-Gm-Message-State: AOAM530flA4dJLeyyc6a32cJudwjJ2eIO0QCg1WRWeFk8rFiiusYGJG1 m031UMlwyBDMZG1E++d5A1zjPA== X-Google-Smtp-Source: ABdhPJz9LYxlcp5C/TfScjy1fOZGGswITMRqpZXXvhMArKghXZPtYx8J39bcSAgRUuzzTekt20JaYQ== X-Received: by 2002:a63:7c42:: with SMTP id l2mr27943153pgn.35.1595987747888; Tue, 28 Jul 2020 18:55:47 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id lr1sm371128pjb.27.2020.07.28.18.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 18:55:47 -0700 (PDT) Message-ID: <5f20d723.1c69fb81.6d882.1d20@mx.google.com> X-Google-Original-Message-ID: <20200728185415.RFC Bluez.1.I14a96397d181666c124e1c413b834428faf3db7a@changeid> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Subject: [RFC Bluez PATCH 1/3] mgmt: Add controller suspend and resume events Date: Tue, 28 Jul 2020 18:55:38 -0700 X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200729015540.1848987-1-abhishekpandit@chromium.org> References: <20200729015540.1848987-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 8 X-Rspamd-Score: 1.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: C40D84014C X-Rspamd-UID: fe22cf Add the controller suspend and resume events. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- lib/mgmt.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index a800bcab4..46d894ae9 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -772,6 +772,7 @@ struct mgmt_ev_device_connected { #define MGMT_DEV_DISCONN_TIMEOUT 0x01 #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 #define MGMT_DEV_DISCONN_REMOTE 0x03 +#define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND 0x05 #define MGMT_EV_DEVICE_DISCONNECTED 0x000C struct mgmt_ev_device_disconnected { @@ -959,6 +960,17 @@ struct mgmt_ev_adv_monitor_removed { uint16_t monitor_handle; } __packed; +#define MGMT_EV_CONTROLLER_SUSPEND 0x002d +struct mgmt_ev_controller_suspend { + uint8_t suspend_state; +} __packed; + +#define MGMT_EV_CONTROLLER_RESUME 0x002e +struct mgmt_ev_controller_resume { + struct mgmt_addr_info addr; + uint8_t wake_reason; +} __packed; + static const char *mgmt_op[] = { "<0x0000>", "Read Version", @@ -1088,6 +1100,8 @@ static const char *mgmt_ev[] = { "Device Flags Changed", "Advertisement Monitor Added", /* 0x002b */ "Advertisement Monitor Removed", + "Controller Suspend", + "Controller Resume", }; static const char *mgmt_status[] = { -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aB8kNjbXIF+hHwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 03:56:06 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id qOJoNDbXIF+iZwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 03:56:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 311084175B; Wed, 29 Jul 2020 03:56:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730505AbgG2Bzu (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 21:55:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728401AbgG2Bzt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 21:55:49 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76E02C061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:55:49 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id 74so3839285pfx.13 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:from:to:cc:subject:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=o9tHOYGHXDOyo1QrY3O2NS3y2FvJoyL66dBlAcJ/QoY=; b=SC7rQlSepHJSQg0tfeCHKAL2xOxdBJRzRWmpwTSwYph0EzU1FYxVeP+IkmPYkJ6j1z ClgcP2EqO4V+KfW24Hz+sJCROAQkBP5D6W/r5CuTc5aptzyf+XftKPQOgG8xjMULBlva IWBUfTLjQxhfSmSOdNhA1Ho/1UuUskTjTPl0w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=o9tHOYGHXDOyo1QrY3O2NS3y2FvJoyL66dBlAcJ/QoY=; b=s5i80hoMZmeEvH4EeStGfKeQzctVIMx1lrYtQgJsKA4BLd8p4wMBbuWzsF6sJZR4T2 YUJlwAZCstz5BvLAuihDomv1U5jCKQFRMOh0CjQxONS/O5gp+/5FkZFZelKwedIXfE8y hXRj0GGs6jBKBggVWLe4d31f3aRu0gE3kuGa0XTz+1TwGfl0XMLnatS+6VyGLhAqI70z XpVM2Fs+NGiexkIeuWluwjOeFUr7s3NJMl1k50YmPh53u6iJzZFTAO+4NIVRFg3vTzII 3Xd1Z5mYcIFyg2PN5Hcfnj8Kw8gWfpqvmDU3Zqqxflu/oOQbHpzh7P4k0wZEntNDae/G LiGA== X-Gm-Message-State: AOAM53313JSqEJIOXx6YWHUPTsV755g7YQ5cUGJc2jzSwAA+F4V1FCNk lWv2s2noOO9hcMelNQqGBQ6JqA== X-Google-Smtp-Source: ABdhPJxr9zkj1C+DCF+5a6tg3zWzxJbC2CqLzGKdoccE1LI8M3A2pjItwUtmx7kQUMEn0FMOAkwPRw== X-Received: by 2002:a65:67d9:: with SMTP id b25mr27592188pgs.311.1595987749068; Tue, 28 Jul 2020 18:55:49 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id lr1sm371128pjb.27.2020.07.28.18.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 18:55:48 -0700 (PDT) Message-ID: <5f20d724.1c69fb81.6d882.1d21@mx.google.com> X-Google-Original-Message-ID: <20200728185415.RFC Bluez.2.Id78b98210807c1326ee2c187af73a325fc97f1e1@changeid> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [RFC Bluez PATCH 2/3] monitor: Add btmon support for Suspend and Resume events Date: Tue, 28 Jul 2020 18:55:39 -0700 X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200729015540.1848987-1-abhishekpandit@chromium.org> References: <20200729015540.1848987-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 8 X-Rspamd-Score: 1.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 311084175B X-Rspamd-UID: fdfeb1 Add support to pretty print Suspend and Resume mgmt events in btmon. Example: @ MGMT Event: Controller Suspended (0x002d) plen 1 Suspend state: Page scanning and/or passive scanning (2) @ MGMT Event: Controller Resumed (0x002e) plen 8 Wake reason: Remote wake due to peer device connection (2) LE Address: CD:F3:CD:13:C5:9A (OUI CD-F3-CD) Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- monitor/packet.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 431a39b66..451630e04 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -13555,6 +13555,9 @@ static void mgmt_device_disconnected_evt(const void *data, uint16_t size) case 0x04: str = "Connection terminated due to authentication failure"; break; + case 0x05: + str = "Connection terminated by local host for suspend"; + break; default: str = "Reserved"; break; @@ -13782,6 +13785,54 @@ static void mgmt_device_flags_changed_evt(const void *data, uint16_t size) mgmt_print_added_device_flags("Current Flags", current_flags); } +static void mgmt_controller_suspend_evt(const void *data, uint16_t size) +{ + uint8_t state = get_u8(data); + char *str; + + switch (state) { + case 0x0: + str = "Controller running (failed to suspend)"; + break; + case 0x1: + str = "Disconnected and not scanning"; + break; + case 0x2: + str = "Page scanning and/or passive scanning"; + break; + default: + str = "Unknown suspend state"; + break; + } + + print_field("Suspend state: %s (%d)", str, state); +} + +static void mgmt_controller_resume_evt(const void *data, uint16_t size) +{ + uint8_t addr_type = get_u8(data + 6); + uint8_t wake_reason = get_u8(data + 7); + char *str; + + switch (wake_reason) { + case 0x0: + str = "Resume from non-Bluetooth wake source"; + break; + case 0x1: + str = "Wake due to unexpected event"; + break; + case 0x2: + str = "Remote wake due to peer device connection"; + break; + default: + str = "Unknown wake reason"; + break; + } + + print_field("Wake reason: %s (%d)", str, wake_reason); + mgmt_print_address(data, addr_type); +} + static const struct mgmt_data mgmt_event_table[] = { { 0x0001, "Command Complete", mgmt_command_complete_evt, 3, false }, @@ -13863,6 +13914,10 @@ static const struct mgmt_data mgmt_event_table[] = { mgmt_exp_feature_changed_evt, 20, true }, { 0x002a, "Device Flags Changed", mgmt_device_flags_changed_evt, 15, true }, + { 0x002d, "Controller Suspended", + mgmt_controller_suspend_evt, 1, true }, + { 0x002e, "Controller Resumed", + mgmt_controller_resume_evt, 8, true }, { } }; -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mOykOj3XIF+hHwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 03:56:13 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6LjuOD3XIF8SaQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 03:56:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate:hard: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 063A14175B; Wed, 29 Jul 2020 03:56:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730606AbgG2Bzv (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 28 Jul 2020 21:55:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728401AbgG2Bzu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 28 Jul 2020 21:55:50 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0A18C061794 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:55:50 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id f9so1229277pju.4 for <linux-bluetooth@vger.kernel.org>; Tue, 28 Jul 2020 18:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:from:to:cc:subject:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=GkBGom0kNJrInlOojf2VwPg2+QuyqNzHj434JUEo+vc=; b=mra8ZtvIPjdBL6EOOTZZV+Q8V4DtI5hGE2jPu2xSXfqQt/EcUN4Dh2b79xRoykHNBx /krCywRfj9f5skUDzjTvv2F+UfmzIwT0KeQuuT2srGJu40wcIwxNBzYO9X+mulnhWfJQ ims0dc9Rv8A0VNBSMOqyDRsCxyryDAorMtbto= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=GkBGom0kNJrInlOojf2VwPg2+QuyqNzHj434JUEo+vc=; b=jsE7kgFa9vmi7GxnSMUWdlzy0rh8AxbtUhxqChyuKf241pl0rQF80TJ8GTG4ahi3lT gl+l5RqfrjRCEsVMEIfYU7y0cghnFvRfSNI0q/4hzYph9qXNPteezhMvrHnNqTH1yVlu 2eDhZdcNCNq7RmUX19GV2umooTktSx/RqRziRFPbnnI4/SG4zQtlX01ND9xkOO7qOwmm NbNoZyohRKwJp2P8nq/qKfn9wIiw8tlgw4jYG4xrqhAm3iI7yRf2viRZxlh7Xt3Llefd HLVwePYhDFpEoj8iNNBW/d+3Hu77HyLh9K2CgcSB+RSLQUmnGzybCLOpgf0IsCBP7QmS ZiVw== X-Gm-Message-State: AOAM533EBa0TxAcK3Er5Kbx+nhIMjlIjgj7aFGGk3OhSb94tUQrejI1K +eEjQ6XuXGhmbCUsxLmBXevA3A== X-Google-Smtp-Source: ABdhPJxwIB+zVpWeYk6IurTKLIfueM4HwUsnvTOR5HumMW7ZEs+7/VZ8xlX9HL10NjlwRBnJTpn1Mg== X-Received: by 2002:a17:90a:b63:: with SMTP id 90mr7548074pjq.47.1595987750180; Tue, 28 Jul 2020 18:55:50 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id lr1sm371128pjb.27.2020.07.28.18.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 18:55:49 -0700 (PDT) Message-ID: <5f20d725.1c69fb81.6d882.1d23@mx.google.com> X-Google-Original-Message-ID: <20200728185415.RFC Bluez.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Subject: [RFC Bluez PATCH 3/3] adapter: Reconnect audio on controller resume Date: Tue, 28 Jul 2020 18:55:40 -0700 X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200729015540.1848987-1-abhishekpandit@chromium.org> References: <20200729015540.1848987-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 8 X-Rspamd-Score: 1.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 063A14175B X-Rspamd-UID: 1b39cb During system suspend, all peer devices are disconnected. On resume, HID devices will reconnect but audio devices stay disconnected. As a quality of life improvement, keep track of the last audio device disconnected during suspend and try to reconnect when the controller resumes from suspend. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- Hey Luiz, On our internal review, two things stood out in this commit that we weren't able to come to a consensus on internally: * Is it better to use the audio device class or should we compare to the A2DP, HFP and HSP uuids? * Constructing the dbus message internally before calling dev_connect looks a bit weird. I couldn't figure out how to internally trigger this function (since it seems to require a msg to respond to on success/failure). Any thoughts? src/adapter.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/device.c | 27 +++++++++++++++++ src/device.h | 2 ++ src/main.conf | 6 ++++ 4 files changed, 117 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..b1073c439 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -90,6 +90,7 @@ #define IDLE_DISCOV_TIMEOUT (5) #define TEMP_DEV_TIMEOUT (3 * 60) #define BONDING_TIMEOUT (2 * 60) +#define RECONNECT_AUDIO_DELAY (5) #define SCAN_TYPE_BREDR (1 << BDADDR_BREDR) #define SCAN_TYPE_LE ((1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM)) @@ -269,6 +270,15 @@ struct btd_adapter { struct btd_device *connect_le; /* LE device waiting to be connected */ sdp_list_t *services; /* Services associated to adapter */ + /* audio device to reconnect after resuming from suspend */ + struct reconnect_audio_info { + bdaddr_t addr; + uint8_t addr_type; + bool reconnect; + } reconnect_audio; + guint reconnect_audio_timeout; /* timeout for reconnect on resume */ + uint32_t reconnect_audio_delay; /* delay reconnect after resume */ + struct btd_gatt_database *database; struct btd_adv_manager *adv_manager; @@ -6256,6 +6266,7 @@ static void load_config(struct btd_adapter *adapter) /* Get discoverable mode */ adapter->stored_discoverable = g_key_file_get_boolean(key_file, "General", "Discoverable", &gerr); + if (gerr) { adapter->stored_discoverable = false; g_error_free(gerr); @@ -6271,6 +6282,16 @@ static void load_config(struct btd_adapter *adapter) gerr = NULL; } + /* Get audio reconnect delay */ + adapter->reconnect_audio_delay = g_key_file_get_integer( + key_file, "General", "ReconnectAudioDelay", &gerr); + + if (gerr) { + adapter->reconnect_audio_delay = RECONNECT_AUDIO_DELAY; + g_error_free(gerr); + gerr = NULL; + } + g_key_file_free(key_file); } @@ -7820,6 +7841,15 @@ static void dev_disconnected(struct btd_adapter *adapter, if (device) { adapter_remove_connection(adapter, device, addr->type); disconnect_notify(device, reason); + + if (reason == MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND && + device_class_is_audio(device)) { + adapter->reconnect_audio.reconnect = true; + adapter->reconnect_audio.addr_type = + btd_device_get_bdaddr_type(device); + bacpy(&adapter->reconnect_audio.addr, + device_get_address(device)); + } } bonding_attempt_complete(adapter, &addr->bdaddr, addr->type, @@ -8766,6 +8796,53 @@ static void connected_callback(uint16_t index, uint16_t length, eir_data_free(&eir_data); } +static gboolean reconnect_audio_timeout(gpointer user_data) +{ + struct btd_adapter *adapter = user_data; + + adapter->reconnect_audio_timeout = 0; + + if (adapter->reconnect_audio.reconnect) { + struct btd_device *dev = btd_adapter_find_device( + adapter, &adapter->reconnect_audio.addr, + adapter->reconnect_audio.addr_type); + + adapter->reconnect_audio.reconnect = false; + + if (!dev || btd_device_is_connected(dev)) + return FALSE; + + device_internal_connect(dev); + } + + return FALSE; +} + +static void controller_resume_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_ev_controller_resume *ev = param; + struct btd_adapter *adapter = user_data; + + if (length < sizeof(*ev)) { + btd_error(adapter->dev_id, "Too small device resume event"); + return; + } + + DBG("Controller resume with wake event 0x%x", ev->wake_reason); + + if (adapter->reconnect_audio_timeout > 0) { + g_source_remove(adapter->reconnect_audio_timeout); + adapter->reconnect_audio_timeout = 0; + } + + if (adapter->reconnect_audio.reconnect) { + adapter->reconnect_audio_timeout = + g_timeout_add_seconds(adapter->reconnect_audio_delay, + reconnect_audio_timeout, adapter); + } +} + static void device_blocked_callback(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9389,6 +9466,11 @@ static void read_info_complete(uint8_t status, uint16_t length, user_passkey_notify_callback, adapter, NULL); + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, + adapter->dev_id, + controller_resume_callback, + adapter, NULL); + set_dev_class(adapter); set_name(adapter, btd_adapter_get_name(adapter)); diff --git a/src/device.c b/src/device.c index bb8e07e8f..8b165ffa4 100644 --- a/src/device.c +++ b/src/device.c @@ -747,6 +747,12 @@ gboolean device_is_trusted(struct btd_device *device) return device->trusted; } +bool device_class_is_audio(struct btd_device *device) +{ + /* Look for major service classes Audio (0x20) + Rendering (0x4) */ + return ((device->class >> 16) & 0x24) == 0x24; +} + static gboolean dev_property_get_address(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -6853,6 +6859,27 @@ struct btd_service *btd_device_get_service(struct btd_device *dev, return NULL; } +/* Internal function to connect to a device. This fakes the dbus message used to + * call the "Connect" api on the device so that the same function can be called + * by bluez internally. + */ +bool device_internal_connect(struct btd_device *dev) +{ + DBusMessage *msg; + + if (!device_is_connectable(dev)) + return false; + + msg = dbus_message_new_method_call("org.bluez", + device_get_path(dev), + DEVICE_INTERFACE, + "Connect"); + /* Sending the message usually sets serial. Fake it here. */ + dbus_message_set_serial(msg, 1); + + dev_connect(dbus_conn, msg, dev); +} + void btd_device_init(void) { dbus_conn = btd_get_dbus_connection(); diff --git a/src/device.h b/src/device.h index 956fec1ae..82f97b5bd 100644 --- a/src/device.h +++ b/src/device.h @@ -98,6 +98,7 @@ bool device_is_connectable(struct btd_device *device); bool device_is_paired(struct btd_device *device, uint8_t bdaddr_type); bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type); gboolean device_is_trusted(struct btd_device *device); +bool device_class_is_audio(struct btd_device *device); void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type); void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type); void btd_device_set_temporary(struct btd_device *device, bool temporary); @@ -186,6 +187,7 @@ int btd_device_connect_services(struct btd_device *dev, GSList *services); uint32_t btd_device_get_current_flags(struct btd_device *dev); void btd_device_flags_changed(struct btd_device *dev, uint32_t supported_flags, uint32_t current_flags); +bool device_internal_connect(struct btd_device *dev); void btd_device_init(void); void btd_device_cleanup(void); diff --git a/src/main.conf b/src/main.conf index f41203b96..c6bb78a84 100644 --- a/src/main.conf +++ b/src/main.conf @@ -82,6 +82,12 @@ # 0 = disable timer, i.e. never keep temporary devices #TemporaryTimeout = 30 +# How long to wait after controller resume before reconnecting to last used +# audio device. +# The value is in seconds. +# Default: 5 +#ReconnectAudioDelay = 5 + [Controller] # The following values are used to load default adapter parameters. BlueZ loads # the values into the kernel before the adapter is powered if the kernel -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kIZcD1oiIV9rXAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 09:16:42 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QCH/DVoiIV/J8AAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 09:16:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 55DDBA2CB7; Wed, 29 Jul 2020 09:16:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726907AbgG2HQg (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 29 Jul 2020 03:16:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726476AbgG2HQg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 29 Jul 2020 03:16:36 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97321C061794 for <linux-bluetooth@vger.kernel.org>; Wed, 29 Jul 2020 00:16:35 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id a21so23200359ejj.10 for <linux-bluetooth@vger.kernel.org>; Wed, 29 Jul 2020 00:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/5ABK+eA36c0ZVESFTkjpcE0rr+cIOhB5EPocStv7k0=; b=kzoKD1v7bqKf1htaxYKCzZpk1oJXbqeDaRnGRhBXNT1QfhYnUEtXBLkPIRcKR/B5i5 mFo/8Oee7oPHws+x2UOZeK0DBJI4y8s//M9lpWs52NYUzMttIHRNRl5Ce4Kg+dPYNAlL b/7pIv41ehMuXOvbwQTuuaLkemCHMn95Z086EwXClFwbvf/X5QmNDWG8llAxoVog0929 Kw0juE1tu4tdKB4AbF1ajkmklzlM6W97FMUyR/Qi8NPpFZ+txO0VpD4SmhrwQDDhqwAM niW1/wkpgvRaT5KRahgpD3mcrMO/ziDLTXIwgT15SxCh6Wa+FmG4OwWWbMDgQYwYvYYL QrBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/5ABK+eA36c0ZVESFTkjpcE0rr+cIOhB5EPocStv7k0=; b=YX0CPE5EkE0ni+bfqBDMzyNHMoJWDWuClrqo4PwJou+raLjAn0mLEuZ/4PlYiZGsd2 h0l/orn4Y4iAqf5QOuyaKqMcbKHj6p74Lbaxg0uFz3gOe1MSNPb9G/Rrso+117LFJycw XBifNm7TrorM4kRUpXHe4kGTxqtoZwEPjRSB35zxLxoE5+LdwOpwCgQP+ot1wMF9F5XL P7dTJ9JqSol3jX4v2IaPsVkG7qJqs9HH5nZXWWTMNwmOcZWX7vyPHQYNlbJvmxdvrYRI KGhGtZ6j6oMzVvsgS+Tl0WO7QiT0PmSh97TCbHSa9ZkQZq0tVd7eM3295OR2z3D6WBh+ K3LQ== X-Gm-Message-State: AOAM533HtPMTUNJ6oVHuXrdpVIMVXaaYpL5VzMJjtGmFdPEP00o//Fyb Jd/1N1wVWl/Fbf/t9UUXyO1czERG4sY= X-Google-Smtp-Source: ABdhPJwYjjzKxuUn70nbK8GCVjgcPZ9eGfobET2BnmBTw3WEspN12Hy9KnuoTHoYYYBKq2Uu+izfjA== X-Received: by 2002:a17:906:c56:: with SMTP id t22mr30617962ejf.50.1596006993978; Wed, 29 Jul 2020 00:16:33 -0700 (PDT) Received: from niels-laptop.telenet.be (ptr-usc1wvbea8yt39w15k.18120a2.ip6.access.telenet.be. [2a02:1810:1c80:7200:d1cb:60bc:b806:b2d8]) by smtp.gmail.com with ESMTPSA id cf10sm867853ejb.4.2020.07.29.00.16.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2020 00:16:33 -0700 (PDT) From: Niels Avonds <niels.avonds@gmail.com> X-Google-Original-From: Niels Avonds <niels@nobi.life> To: linux-bluetooth@vger.kernel.org Cc: Niels Avonds <niels@nobi.life> Subject: [PATCH BlueZ] device: Don't mark services resolved on error Date: Wed, 29 Jul 2020 09:16:02 +0200 Message-Id: <20200729071602.12868-1-niels@nobi.life> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 5 X-Rspamd-Score: 0.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 55DDBA2CB7 X-Rspamd-UID: de2e69 This fixes a bug where the service UUIDs were not rediscovered after a failed bonding attempt because the svc_resolved flag remained set even though the uuids list was empty. --- src/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index bb8e07e8f..e20c2d240 100644 --- a/src/device.c +++ b/src/device.c @@ -2591,7 +2591,8 @@ static void device_svc_resolved(struct btd_device *dev, uint8_t browse_type, DBG("%s err %d", dev->path, err); - state->svc_resolved = true; + if (err == 0) + state->svc_resolved = true; /* Disconnection notification can happen before this function * gets called, so don't set svc_refreshed for a disconnected -- 2.18.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8BAfHMGMIV+NVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 16:50:41 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id KCCdGsGMIV+fpgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 16:50:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AE623A158F; Wed, 29 Jul 2020 16:50:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726883AbgG2Ouf (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 29 Jul 2020 10:50:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbgG2Oue (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 29 Jul 2020 10:50:34 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73116C061794 for <linux-bluetooth@vger.kernel.org>; Wed, 29 Jul 2020 07:50:34 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id d1so962946qvs.21 for <linux-bluetooth@vger.kernel.org>; Wed, 29 Jul 2020 07:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=YvbErX2MFgIDhjr2U06aFl5vOTCHhwTRMvY1z+vdWBk=; b=lo97V4tDZzdQqQgY9yByqEp0gIw+uqRJ55+2wtH2yhcQVeNgXC/E8RenWTPdQWOt+t cBmSfmaWT8O+HK5xyHYoOp4gQ1gX9mWLIb2gq53LRF/MVnRrbXzHzoFurj662gBZdHeY +dKkBcj0u5Jq3eXTtOOggxcwxL3k3vANKD4A37MU967JEmRqOkvDl3g6ZNhp+BveJ4WI g1WXLIG9WjvvINe8oJFKUJWtChiWo0U1p1Ip87QKu4GRrtL8ibT3Sno9CM7rNjX8q5eo dbzyO250RBWW2o8KqPciz4GJDTaVpHdIt1bMc988YF+rxodYRiNKVkHykIirkDRS9+9W ktVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=YvbErX2MFgIDhjr2U06aFl5vOTCHhwTRMvY1z+vdWBk=; b=Y1lnxxEAlcEOskDQcfYNBrGm1O/wmUZqPxLt+tw0VJd2fxf7Rclqh0zqZ3UIKcPPvp sZJ/HVv7VYf1E5CZbKgblXyND8Cv93ugyYMhgQ+7/51MMPQr5U0Nu+OLhz/H9Nnb9F7V HegW1uGIs0tMhqZ8hX1oneC5EbjknyUGXev90h3zgbCCwZ2kgx9eqTAYz6x7Gogg8h5+ pkafymHgdt73tDD5arenTaMaS2PmbZhfBU08UvQVQHuuVSplLVSNrshtKy8KuXhjD51E npV0w9ULnv9EoOY5Fe+7+NfRSByJ+OfwUoR4AhTajEOaiFW+ODajbgytNobZXFQP+IUV hQ5g== X-Gm-Message-State: AOAM532X+VeXCvEpRnk8RScaolvYWXzHUitIucjNAZr58C7uvqLosQoB ERrf5hrzUthCQSf9ywEKKtd48GNeVCNPnXXAYKXOQ5GPWh3/jVy0WQIEeLE0QnUoh32ZQs4MH4B cCQuCyimdIrT7C1DWnROhPMRBCnxrdCXcAdVAV2qRv6GWdA0z7iO+m98JZmh7JRCM7aG2uVe0A0 Hb X-Google-Smtp-Source: ABdhPJzou/VuEvRxdQfWa6US/i+gDJFXnlkOifi2cAHQ53qug3a3K8J8u+OoAYBIb3zVDruWqmrAKTRMKisx X-Received: by 2002:a0c:e5cc:: with SMTP id u12mr32971585qvm.54.1596034232862; Wed, 29 Jul 2020 07:50:32 -0700 (PDT) Date: Wed, 29 Jul 2020 22:50:19 +0800 Message-Id: <20200729224945.Bluez.v1.1.If7e0a0d17cf6c6508f68f1505fa5864af624a4b7@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog Subject: [Bluez PATCH v1] input/device: Implement handle for UHID_SET_REPORT From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: AE623A158F X-Rspamd-UID: 7ce6ad From: Archie Pusaka <apusaka@chromium.org> This patch listens to UHID_SET_REPORT event and forwards this message to the hid device. Upon reply, we also send a report back to the kernel as UHID_SET_REPORT_REPLY. Furthermore, this patch also send UHID_DESTROY upon disconnection, and replaces the obsolete UHID_FEATURE with the compatible UHID_GET_REPORT. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- profiles/input/device.c | 166 +++++++++++++++++++++++++++---------- profiles/input/hidp_defs.h | 2 +- 2 files changed, 124 insertions(+), 44 deletions(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index ee0b2404a..8fc04be37 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -117,6 +117,7 @@ bool input_get_classic_bonded_only(void) static void input_device_enter_reconnect_mode(struct input_device *idev); static int connection_disconnect(struct input_device *idev, uint32_t flags); +static int uhid_disconnect(struct input_device *idev); static bool input_device_bonded(struct input_device *idev) { @@ -220,7 +221,7 @@ static bool hidp_send_intr_message(struct input_device *idev, uint8_t hdr, return hidp_send_message(idev->intr_io, hdr, data, size); } -static bool uhid_send_feature_answer(struct input_device *idev, +static bool uhid_send_get_report_reply(struct input_device *idev, const uint8_t *data, size_t size, uint32_t id, uint16_t err) { @@ -230,8 +231,8 @@ static bool uhid_send_feature_answer(struct input_device *idev, if (data == NULL) size = 0; - if (size > sizeof(ev.u.feature_answer.data)) - size = sizeof(ev.u.feature_answer.data); + if (size > sizeof(ev.u.get_report_reply.data)) + size = sizeof(ev.u.get_report_reply.data); if (!idev->uhid_created) { DBG("HID report (%zu bytes) dropped", size); @@ -239,13 +240,13 @@ static bool uhid_send_feature_answer(struct input_device *idev, } memset(&ev, 0, sizeof(ev)); - ev.type = UHID_FEATURE_ANSWER; - ev.u.feature_answer.id = id; - ev.u.feature_answer.err = err; - ev.u.feature_answer.size = size; + ev.type = UHID_GET_REPORT_REPLY; + ev.u.get_report_reply.id = id; + ev.u.get_report_reply.err = err; + ev.u.get_report_reply.size = size; if (size > 0) - memcpy(ev.u.feature_answer.data, data, size); + memcpy(ev.u.get_report_reply.data, data, size); ret = bt_uhid_send(idev->uhid, &ev); if (ret < 0) { @@ -258,6 +259,29 @@ static bool uhid_send_feature_answer(struct input_device *idev, return true; } +static bool uhid_send_set_report_reply(struct input_device *idev, + uint32_t id, uint16_t err) +{ + struct uhid_event ev; + int ret; + + if (!idev->uhid_created) + return false; + + memset(&ev, 0, sizeof(ev)); + ev.type = UHID_SET_REPORT_REPLY; + ev.u.set_report_reply.id = id; + ev.u.set_report_reply.err = err; + + ret = bt_uhid_send(idev->uhid, &ev); + if (ret < 0) { + error("bt_uhid_send: %s (%d)", strerror(-ret), -ret); + return false; + } + + return true; +} + static bool uhid_send_input_report(struct input_device *idev, const uint8_t *data, size_t size) { @@ -370,6 +394,10 @@ static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data if (!idev->ctrl_io && idev->virtual_cable_unplug) virtual_cable_unplug(idev); + /* If connection abruptly ended, uhid might be not yet disconnected */ + if (idev->uhid_created) + uhid_disconnect(idev); + return FALSE; } @@ -399,11 +427,13 @@ static void hidp_recv_ctrl_handshake(struct input_device *idev, uint8_t param) case HIDP_HSHK_ERR_FATAL: if (pending_req_type == HIDP_TRANS_GET_REPORT) { DBG("GET_REPORT failed (%u)", param); - uhid_send_feature_answer(idev, NULL, 0, + uhid_send_get_report_reply(idev, NULL, 0, idev->report_rsp_id, EIO); pending_req_complete = true; } else if (pending_req_type == HIDP_TRANS_SET_REPORT) { DBG("SET_REPORT failed (%u)", param); + uhid_send_set_report_reply(idev, idev->report_rsp_id, + EIO); pending_req_complete = true; } else DBG("Spurious HIDP_HSHK_ERR"); @@ -446,7 +476,8 @@ static void hidp_recv_ctrl_data(struct input_device *idev, uint8_t param, DBG(""); pending_req_type = idev->report_req_pending & HIDP_HEADER_TRANS_MASK; - if (pending_req_type != HIDP_TRANS_GET_REPORT) { + if (pending_req_type != HIDP_TRANS_GET_REPORT && + pending_req_type != HIDP_TRANS_SET_REPORT) { DBG("Spurious DATA on control channel"); return; } @@ -460,9 +491,13 @@ static void hidp_recv_ctrl_data(struct input_device *idev, uint8_t param, switch (param) { case HIDP_DATA_RTYPE_FEATURE: case HIDP_DATA_RTYPE_INPUT: - case HIDP_DATA_RTYPE_OUPUT: - uhid_send_feature_answer(idev, data + 1, size - 1, + case HIDP_DATA_RTYPE_OUTPUT: + if (pending_req_type == HIDP_TRANS_GET_REPORT) + uhid_send_get_report_reply(idev, data + 1, size - 1, idev->report_rsp_id, 0); + else + uhid_send_set_report_reply(idev, idev->report_rsp_id, + 0); break; case HIDP_DATA_RTYPE_OTHER: @@ -579,9 +614,13 @@ static gboolean hidp_report_req_timeout(gpointer data) switch (pending_req_type) { case HIDP_TRANS_GET_REPORT: req_type_str = "GET_REPORT"; + uhid_send_get_report_reply(idev, NULL, 0, idev->report_rsp_id, + ETIMEDOUT); break; case HIDP_TRANS_SET_REPORT: req_type_str = "SET_REPORT"; + uhid_send_set_report_reply(idev, idev->report_rsp_id, + ETIMEDOUT); break; default: /* Should never happen */ @@ -598,6 +637,17 @@ static gboolean hidp_report_req_timeout(gpointer data) return FALSE; } +static void hidp_send_output(struct uhid_event *ev, void *user_data) +{ + struct input_device *idev = user_data; + uint8_t hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUTPUT; + + DBG(""); + + hidp_send_intr_message(idev, hdr, ev->u.output.data, + ev->u.output.size); +} + static void hidp_send_set_report(struct uhid_event *ev, void *user_data) { struct input_device *idev = user_data; @@ -606,34 +656,37 @@ static void hidp_send_set_report(struct uhid_event *ev, void *user_data) DBG(""); - switch (ev->u.output.rtype) { + switch (ev->u.set_report.rtype) { case UHID_FEATURE_REPORT: - /* Send SET_REPORT on control channel */ - if (idev->report_req_pending) { - DBG("Old GET_REPORT or SET_REPORT still pending"); - return; - } - hdr = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE; - sent = hidp_send_ctrl_message(idev, hdr, ev->u.output.data, - ev->u.output.size); - if (sent) { - idev->report_req_pending = hdr; - idev->report_req_timer = - g_timeout_add_seconds(REPORT_REQ_TIMEOUT, - hidp_report_req_timeout, idev); - } + break; + case UHID_INPUT_REPORT: + hdr = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_INPUT; break; case UHID_OUTPUT_REPORT: - /* Send DATA on interrupt channel */ - hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT; - hidp_send_intr_message(idev, hdr, ev->u.output.data, - ev->u.output.size); + hdr = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_OUTPUT; break; default: - DBG("Unsupported HID report type %u", ev->u.output.rtype); + DBG("Unsupported HID report type %u", ev->u.set_report.rtype); return; } + + if (idev->report_req_pending) { + DBG("Old GET_REPORT or SET_REPORT still pending"); + uhid_send_set_report_reply(idev, ev->u.set_report.id, EBUSY); + return; + } + + sent = hidp_send_ctrl_message(idev, hdr, ev->u.set_report.data, + ev->u.set_report.size); + if (sent) { + idev->report_req_pending = hdr; + idev->report_req_timer = + g_timeout_add_seconds(REPORT_REQ_TIMEOUT, + hidp_report_req_timeout, idev); + idev->report_rsp_id = ev->u.set_report.id; + } else + uhid_send_set_report_reply(idev, ev->u.set_report.id, EIO); } static void hidp_send_get_report(struct uhid_event *ev, void *user_data) @@ -646,13 +699,13 @@ static void hidp_send_get_report(struct uhid_event *ev, void *user_data) if (idev->report_req_pending) { DBG("Old GET_REPORT or SET_REPORT still pending"); - uhid_send_feature_answer(idev, NULL, 0, ev->u.feature.id, + uhid_send_get_report_reply(idev, NULL, 0, ev->u.get_report.id, EBUSY); return; } /* Send GET_REPORT on control channel */ - switch (ev->u.feature.rtype) { + switch (ev->u.get_report.rtype) { case UHID_FEATURE_REPORT: hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_FEATURE; break; @@ -660,22 +713,24 @@ static void hidp_send_get_report(struct uhid_event *ev, void *user_data) hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_INPUT; break; case UHID_OUTPUT_REPORT: - hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_OUPUT; + hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_OUTPUT; break; default: - DBG("Unsupported HID report type %u", ev->u.feature.rtype); + DBG("Unsupported HID report type %u", ev->u.get_report.rtype); return; } - sent = hidp_send_ctrl_message(idev, hdr, &ev->u.feature.rnum, - sizeof(ev->u.feature.rnum)); + sent = hidp_send_ctrl_message(idev, hdr, &ev->u.get_report.rnum, + sizeof(ev->u.get_report.rnum)); if (sent) { idev->report_req_pending = hdr; idev->report_req_timer = g_timeout_add_seconds(REPORT_REQ_TIMEOUT, hidp_report_req_timeout, idev); - idev->report_rsp_id = ev->u.feature.id; - } + idev->report_rsp_id = ev->u.get_report.id; + } else + uhid_send_get_report_reply(idev, NULL, 0, ev->u.get_report.id, + EIO); } static void epox_endian_quirk(unsigned char *data, int size) @@ -908,14 +963,39 @@ static int uhid_connadd(struct input_device *idev, struct hidp_connadd_req *req) return err; } - bt_uhid_register(idev->uhid, UHID_OUTPUT, hidp_send_set_report, idev); - bt_uhid_register(idev->uhid, UHID_FEATURE, hidp_send_get_report, idev); + bt_uhid_register(idev->uhid, UHID_OUTPUT, hidp_send_output, idev); + bt_uhid_register(idev->uhid, UHID_GET_REPORT, hidp_send_get_report, + idev); + bt_uhid_register(idev->uhid, UHID_SET_REPORT, hidp_send_set_report, + idev); idev->uhid_created = true; return err; } +static int uhid_disconnect(struct input_device *idev) +{ + int err; + struct uhid_event ev; + + if (!idev->uhid_created) + return 0; + + memset(&ev, 0, sizeof(ev)); + ev.type = UHID_DESTROY; + + err = bt_uhid_send(idev->uhid, &ev); + if (err < 0) { + error("bt_uhid_send: %s", strerror(-err)); + return err; + } + + idev->uhid_created = false; + + return err; +} + static gboolean encrypt_notify(GIOChannel *io, GIOCondition condition, gpointer data) { @@ -1074,7 +1154,7 @@ static int connection_disconnect(struct input_device *idev, uint32_t flags) idev->virtual_cable_unplug = true; if (idev->uhid) - return 0; + return uhid_disconnect(idev); else return ioctl_disconnect(idev, flags); } diff --git a/profiles/input/hidp_defs.h b/profiles/input/hidp_defs.h index 5dc479acf..bb9231dbb 100644 --- a/profiles/input/hidp_defs.h +++ b/profiles/input/hidp_defs.h @@ -63,7 +63,7 @@ #define HIDP_DATA_RSRVD_MASK 0x0c #define HIDP_DATA_RTYPE_OTHER 0x00 #define HIDP_DATA_RTYPE_INPUT 0x01 -#define HIDP_DATA_RTYPE_OUPUT 0x02 +#define HIDP_DATA_RTYPE_OUTPUT 0x02 #define HIDP_DATA_RTYPE_FEATURE 0x03 /* HIDP protocol header parameters */ -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qITSHkOPIV//fAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 17:01:23 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id uIhMHUOPIV+LqgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 17:01:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C2C49A2CAA; Wed, 29 Jul 2020 17:01:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726502AbgG2PBK (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 29 Jul 2020 11:01:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbgG2PBJ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 29 Jul 2020 11:01:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BF74E207E8; Wed, 29 Jul 2020 15:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596034869; bh=ESM/C4n2/9SZm7+Qrh9WZ3Nyo1d10BOHwjAtSu+wytc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ikyk9lb/olM7+v7ejcklpKjX1TxtamqCPeSAIp0xtA7IAEt7QEM0UDxkzNNNzosw5 MCyBjrZyd2YJiyUU+L9hfpqZs5ckGC9TZlWwHF+E19ZIUB6GkdXNlCNzYrpWoB2/7e dLVnnd5jKRn8M2XhUaGgKUY4DCLzQD3Mik1d2VL0= Date: Wed, 29 Jul 2020 17:01:00 +0200 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: "Rafael J. Wysocki" <rafael@kernel.org> Cc: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Rafael Wysocki <rafael.j.wysocki@intel.com>, Linux PM <linux-pm@vger.kernel.org>, "open list:BLUETOOTH DRIVERS" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Stephen Boyd <swboyd@chromium.org>, "Rafael J. Wysocki" <rjw@rjwysocki.net>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz> Subject: Re: [PATCH v5 1/1] power: Emit changed uevent on wakeup_sysfs_add/remove Message-ID: <20200729150100.GA3508555@kroah.com> References: <20200707172845.4177903-1-abhishekpandit@chromium.org> <20200707102823.v5.1.I51f5a0be89595b73c4dc17e6cf4cc6f26dc7f2fc@changeid> <20200723183235.GA3445384@kroah.com> <CAJZ5v0jXcfO3YiMgkc7u=qqZy+jyT=RGagF3yAFnAhiJfyfcuQ@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <CAJZ5v0jXcfO3YiMgkc7u=qqZy+jyT=RGagF3yAFnAhiJfyfcuQ@mail.gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: C2C49A2CAA X-Rspamd-UID: bd309f On Mon, Jul 27, 2020 at 03:38:02PM +0200, Rafael J. Wysocki wrote: > On Thu, Jul 23, 2020 at 8:32 PM Greg Kroah-Hartman > <gregkh@linuxfoundation.org> wrote: > > > > On Tue, Jul 07, 2020 at 10:28:44AM -0700, Abhishek Pandit-Subedi wrote: > > > Udev rules that depend on the power/wakeup attribute don't get triggered > > > correctly if device_set_wakeup_capable is called after the device is > > > created. This can happen for several reasons (driver sets wakeup after > > > device is created, wakeup is changed on parent device, etc) and it seems > > > reasonable to emit a changed event when adding or removing attributes on > > > the device. > > > > > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > > > Rafael, any objection to this? Do you want me to take it through my > > tree, or are you going to take it through yours? Either is fine for me. > > It's already there in my tree with the R-by tag from you. {sigh} Sorry for the noise. greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qGTGE1KbIV+swAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 17:52:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id yHDdEVKbIV8Y3AEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 17:52:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0155BA1A52; Wed, 29 Jul 2020 17:52:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726449AbgG2Pwo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 29 Jul 2020 11:52:44 -0400 Received: from mga11.intel.com ([192.55.52.93]:63644 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726341AbgG2Pwo (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 29 Jul 2020 11:52:44 -0400 IronPort-SDR: jsfo0hs3NWOczz6wZw+AUjnj70/cbXiIqtLO+zbXxJhP6yFphSclJoLfwsEOkV5ffOp7ojS48e GEAZePiVxO/Q== X-IronPort-AV: E=McAfee;i="6000,8403,9697"; a="149283067" X-IronPort-AV: E=Sophos;i="5.75,410,1589266800"; d="scan'208";a="149283067" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2020 08:52:43 -0700 IronPort-SDR: MvvlNpOmdFWKilwNfBISpyZB4Rf0AMkkzQNWe4WoRGlP3pP9kPrE8JjtxPbbbbALyGom0T5R8d 0TXsUzks3+ow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,410,1589266800"; d="scan'208";a="330443559" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.114.231]) by orsmga007.jf.intel.com with ESMTP; 29 Jul 2020 08:52:42 -0700 From: Brian Gix <brian.gix@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, inga.stotland@intel.com, mike@mnmoran.org Subject: [PATCH BlueZ] mesh: Add guard against wedging outbound queue Date: Wed, 29 Jul 2020 08:52:34 -0700 Message-Id: <20200729155234.547679-1-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0155BA1A52 X-Rspamd-UID: 2c466b When using HCI command chains, the first packet send that starts an outbound sequence needs to still exist when command chain completes, or the outbound queue will wedge. The simplest solution is to send packets at least twice on an empty queue, if there is a chance it could be canceled. --- mesh/mesh-io-generic.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c index 86952516e..4b26b1181 100644 --- a/mesh/mesh-io-generic.c +++ b/mesh/mesh-io-generic.c @@ -714,6 +714,14 @@ static bool send_tx(struct mesh_io *io, struct mesh_io_send_info *info, sending = !l_queue_isempty(pvt->tx_pkts); l_queue_push_tail(pvt->tx_pkts, tx); + + /* + * If transmitter is idle, send packets at least twice to + * guard against in-line cancelation of HCI command chain. + */ + if (info->type == MESH_IO_TIMING_TYPE_GENERAL && !sending && + tx->info.u.gen.cnt == 1) + tx->info.u.gen.cnt++; } if (!sending) { -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gDE/I0zHIV+N9gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 21:00:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id WGZmIUzHIV8aeQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 21:00:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CA322A1B61; Wed, 29 Jul 2020 21:00:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726476AbgG2TAW (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 29 Jul 2020 15:00:22 -0400 Received: from mga18.intel.com ([134.134.136.126]:43521 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2TAV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 29 Jul 2020 15:00:21 -0400 IronPort-SDR: n9upjyvRNFOQ76IexNv6WYtpPs+y31X29J5CHbB3BecT+WfhIRlASkBigR9Ae4UsUakoGoBDUg yoM5wXueaMVw== X-IronPort-AV: E=McAfee;i="6000,8403,9697"; a="139012151" X-IronPort-AV: E=Sophos;i="5.75,411,1589266800"; d="scan'208";a="139012151" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2020 12:00:20 -0700 IronPort-SDR: VR4hlc29uoHnLLljoMlXCp0JTTR87mEC+47lDO3m8QebynPgyFBpFwVlKKlrWVtgCl1bCG+n/K 8CP6Ggo1pKwA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,411,1589266800"; d="scan'208";a="364936755" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 29 Jul 2020 12:00:20 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 29 Jul 2020 12:00:14 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 29 Jul 2020 12:00:11 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 29 Jul 2020 12:00:11 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.36.57) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 29 Jul 2020 12:00:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T5YiF8timS+0JZksA8QpdP3mrKMbG3GaaCClDb8rpgE9rE5G4mHTvob31hEEX6xFuOSn0Jvvk43YE8WG0jDfhTwLZATaflCl+Bg/o7vLxAb9CcVH+nrSJpiZtcZTEyz1jzP3WQNqY6ZbBw0IG8DWMbYVTjxfjndTg+H7KOqnd0i/vBGG6KcNdOoJZMlv3tM1umcO1aehGhboajqV+0te4H4gLLr289iFbAhItGEXXFdXHn50vgK/mRyT3PtQrI/DlcGoATV/odH7AZkmGlo21LAO7ARZqTVvxlWN+UiPrf4XKIBaSPG8ePh9m6e/8OfDisgsHrmZXHMdGPdOMnPqxQ== 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-SenderADCheck; bh=BMGSaUZv+GwxbM75J8qwHnvLuqkL59Ol4IizClQbXNU=; b=FEXLMMYNMFegwrQJWUnvanLmK1zdKK5KEek+VFSTicBToQyDisHfxi/aVSIcQQxev8bOTf8IRN2GojYp1kT4ZhsWDxnQwSL9FTRARCwYQCz/COeqPtTk41eaARelc2AcbwQlJfaRx3L+SCwU4h3CzwnKLVnYyeek3Tifl676HvIDF5sVtuCcHEPbXAHn68/JUutxs2HeVHWrbcInQuP5csvwAH8IW4ozS/1Gv9Iuw4XJszg+oTEiEnE5h85/kn02pDKcqtB7DtGJWkeVLr3RR+Sbx/UIxa3Azoj7kmj9USCXJknAdGp4UQCYzzfw+qIVtTq7wSyRVa6nQeIzupke9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BMGSaUZv+GwxbM75J8qwHnvLuqkL59Ol4IizClQbXNU=; b=IzqVh0O3t6Nt8mQ6Mqh0D3us4JJ1tl/v5NoeLUfKl6kVbp0VRfMvnR/kuSpW0Y6pLGFcctAkJqDt3rCGMe8VRsdH3Th9V4sM4kqWi3sZb10OPOCS2edNBp3ecDYI6pPmPOyhCNrT1gqL2ooCpltqIGJcIuUla1iu+DNA/HHAUMc= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1792.namprd11.prod.outlook.com (2603:10b6:300:10b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23; Wed, 29 Jul 2020 19:00:06 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3239.017; Wed, 29 Jul 2020 19:00:05 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: Fix calculation of model publication period Thread-Topic: [PATCH BlueZ] mesh: Fix calculation of model publication period Thread-Index: AQHWZQp4nxpLU+HfMEalOO9lNtaAUqke6toA Date: Wed, 29 Jul 2020 19:00:05 +0000 Message-ID: <c0cacac96a78fbc11162df2fea419c9d48d01524.camel@intel.com> References: <20200728181051.22075-1-inga.stotland@intel.com> In-Reply-To: <20200728181051.22075-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [134.134.139.74] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 625592b1-7dff-4cf8-7a54-08d833f19b5f x-ms-traffictypediagnostic: MWHPR11MB1792: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR11MB1792C9EAE325C0ECC8640C82E1700@MWHPR11MB1792.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: G0uC+nGiY0l+uRhL01UTGolagSR9EDGwJOitX7DN+I6WDhVL/goTicqPDOkFJjgVvwPbm14VrEyZbrSe/hJWFH2mLGK5R2nZfZyZMQQyiCY39foHJPIuBiZF3vDiEh10OpPx60Yg+j+WfnIepEidxS/+IpGNmafVsIke0WImujdrHl/zHQ9QJIyqsM32BCo0tl6GQqz4opVNSSMPJA3PI70lyvBOCsjd1hHazhXQzhbmdupoPrZJghysq/bujB3F5Nppird4sD5EWNjaMyUFTFoHTZAOA1nviYE4WAhUNdVQ25VTfUPJ5P6guMpq5hB3V9QUaz1umY+2MVR11CJrKg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(83380400001)(26005)(71200400001)(6486002)(478600001)(186003)(36756003)(5660300002)(2616005)(6636002)(64756008)(76116006)(316002)(2906002)(6506007)(6512007)(110136005)(66476007)(66556008)(86362001)(66946007)(66446008)(8936002)(8676002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: Kz9CklAf6OOXbJIZrXTpWslvW5eTnaY20Lz0OUHXo6prdKroobOeppTzKLb41dIxtvGq3nCscN7CsVln+eqz5FLrZtrQVOfAfi7w97/gKiLFRNmlnbpmKa6BCKsAp+LgOlsaoGaalxnazijE9A8TQyQcuM7G20j4+OeGieTgY7rugcKuwRDtFQ7UtTIk8Fz0UbCMrkr6iPI2cWcuhM1FVJVfkSLVq3M6vY5X3CB26dnz8IHWCK9A7xXBa5+ohswuzLBwP6dRkkiFgUHUlU4xn/rSdQ4vFC1huOrQcrSkxRAVooztjzISWiXGXKD5RZAW9T+Zc4WqL1x0Kr6xfIN8f+wh9YwXfw0r8Uzu3BKx4TNhGQBoMYKd1W1B9D71A32X6f9Pr1Yy9RJo955zDS2z/r8OzP7A1cFTrIChUwa929s1iNAj5ivYKSwXMOnQsj0H2aPa6VfmIIo00kmGpCMjd6Y1O+o2y/OPfiRdn6hAM4aMSzbGOj8SbooIyVl5k72h Content-Type: text/plain; charset="utf-8" Content-ID: <50B7FBDDB810A648AFFCDC382286C825@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 625592b1-7dff-4cf8-7a54-08d833f19b5f X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jul 2020 19:00:05.7764 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Ra95I4nVuWTRT2vficIahqeoFr+s7o5j3YctT1dYdNz+ywgqJzvPKoeHNRYu2tnRlht48IS/CVoD50bhgjd3Pg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1792 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.44 / 15.00 / 200.00 X-Rspamd-Queue-Id: CA322A1B61 X-Rspamd-UID: 58f533 QXBwbGllZA0KT24gVHVlLCAyMDIwLTA3LTI4IGF0IDExOjEwIC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBUaGlzIGZpeGVzIHRoZSBleHRyYWN0aW9uIG9mIGJpdCBmaWVsZHMgZnJvbSBt b2RlbCBwdWJsaWNhdGlvbg0KPiBwZXJpb2Qgb2N0ZXQgcmVjZWl2ZWQgYXMgcGFydCBvZiBDb25n aWYgUHVibGljYXRpb24gU2V0IG1lc3NhZ2UuDQo+IA0KPiBUaGUgc3RlcCByZXNvbHV0aW9uIGZp ZWxkIGlzIGV4dHJhY3RlZCBhcyB1cHBlciAyIGJpdHMgKHNoaWZ0IGJ5IDYpDQo+IGFuZCB0aGUg bnVtYmVyIG9mIHN0ZXBzIGZpZWxkIGlzIGV4dHJhY3RlZCBieSBtYXNraW5nIGxvd2VyIDYgYml0 cy4NCj4gLS0tDQo+ICBtZXNoL21vZGVsLmMgfCAxNSArKysrKysrKy0tLS0tLS0NCj4gIDEgZmls ZSBjaGFuZ2VkLCA4IGluc2VydGlvbnMoKyksIDcgZGVsZXRpb25zKC0pDQo+IA0KPiBkaWZmIC0t Z2l0IGEvbWVzaC9tb2RlbC5jIGIvbWVzaC9tb2RlbC5jDQo+IGluZGV4IDMxMTk3YjM2My4uZWY3 NjY4MTQ3IDEwMDY0NA0KPiAtLS0gYS9tZXNoL21vZGVsLmMNCj4gKysrIGIvbWVzaC9tb2RlbC5j DQo+IEBAIC0xNzAsMjAgKzE3MCwyMSBAQCBzdGF0aWMgc3RydWN0IG1lc2hfbW9kZWwgKmdldF9t b2RlbChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50OF90IGVsZV9pZHgsDQo+ICANCj4gIHN0 YXRpYyB1aW50MzJfdCBwdWJfcGVyaW9kX3RvX21zKHVpbnQ4X3QgcHViX3BlcmlvZCkNCj4gIHsN Cj4gLQlpbnQgbjsNCj4gKwlpbnQgc3RlcF9yZXMsIG51bV9zdGVwczsNCj4gIA0KPiAtCW4gPSBw dWJfcGVyaW9kID4+IDI7DQo+ICsJc3RlcF9yZXMgPSBwdWJfcGVyaW9kID4+IDY7DQo+ICsJbnVt X3N0ZXBzID0gcHViX3BlcmlvZCAmIDB4M2Y7DQo+ICANCj4gLQlzd2l0Y2ggKHB1Yl9wZXJpb2Qg JiAweDMpIHsNCj4gKwlzd2l0Y2ggKHN0ZXBfcmVzKSB7DQo+ICAJZGVmYXVsdDoNCj4gLQkJcmV0 dXJuIG4gKiAxMDA7DQo+ICsJCXJldHVybiBudW1fc3RlcHMgKiAxMDA7DQo+ICAJY2FzZSAyOg0K PiAtCQluICo9IDEwOw0KPiArCQludW1fc3RlcHMgKj0gMTA7DQo+ICAJCS8qIEZhbGwgVGhyb3Vn aCAqLw0KPiAgCWNhc2UgMToNCj4gLQkJcmV0dXJuIG4gKiAxMDAwOw0KPiArCQlyZXR1cm4gbnVt X3N0ZXBzICogMTAwMDsNCj4gIAljYXNlIDM6DQo+IC0JCXJldHVybiBuICogMTAgKiA2MCAqIDEw MDA7DQo+ICsJCXJldHVybiBudW1fc3RlcHMgKiAxMCAqIDYwICogMTAwMDsNCj4gIAl9DQo+ICB9 DQo+ICANCg== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sNKEOWnHIV8S9AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 29 Jul 2020 21:00:57 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qLjaN2nHIV9nkgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 29 Jul 2020 21:00:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 70965A1BEA; Wed, 29 Jul 2020 21:00:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726535AbgG2TAp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 29 Jul 2020 15:00:45 -0400 Received: from mga05.intel.com ([192.55.52.43]:4796 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2TAp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 29 Jul 2020 15:00:45 -0400 IronPort-SDR: AH3RaXai0HZKSAApKq96ihB48Gy8dlEmpzxg0Te1RCihrGHza+YjqkAYWlLzzxjvTLSOuWOgfL Adlo64wAaimg== X-IronPort-AV: E=McAfee;i="6000,8403,9697"; a="236346927" X-IronPort-AV: E=Sophos;i="5.75,411,1589266800"; d="scan'208";a="236346927" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2020 12:00:44 -0700 IronPort-SDR: 0p4Gtb4BrK2T3iWCmzgsTLcmUTDia0HvAxE91b00OY7mhB6gfyCF0TO1UKZm5awUTIlaUqt+EK PLGU6swjs0cQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,411,1589266800"; d="scan'208";a="364936883" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga001.jf.intel.com with ESMTP; 29 Jul 2020 12:00:44 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 29 Jul 2020 12:00:44 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 29 Jul 2020 12:00:44 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.36.54) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 29 Jul 2020 12:00:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g72IoD1ye225Ne1QUXZb4j6Fi56k2i/pyl/oQR7uccRdpE4/wRJZO7PhPWBmXsAz1Uo5i9WGrtBcXOup6gb3XcoE9bb8WFhlysJqb3jcU0e0sIf4bZEtm8PGSmXE8ctI8QbhlcvzeyGXmtV5Fbdj77jdV7KM+qP6X0JQFqhIvzBWX3uFCqAjTpFlVGx1nBDcXSU5mS2B0WsdN+1iiNku9ANFJOoyLOXAFjV/iUYxizKLsyaiF00X2yyEbdeYTDBRldpN8YHcl509s1eaK4qr7jkTrsq3mMsOoe2nbiEnPJqAnbxwEnKuVI7EmlXmyUg3975uQhkuKCSSyZKzpc04AQ== 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-SenderADCheck; bh=Zkf8KVjbJkwXRkX51n1K74y/9B7gRqxO3OFw7gsHYu8=; b=IEDLPfMYkylplSvKHBF0ft66GiJUG08slSpuKRYw6tgjPH41JVxILp4BgZj+m69g3vy2Q8fbzWbk4XSaFWV9s9gdGXq6KBvQyFo5vdDpNrqCzDJHeh2nKzPW/OX20Cw4qZvikc2OXACYHZDU+kRLbC37wBG518Z3Igks5nMaBjD76yVcR38VxaHQPcsMI7/Ypsb+Z6vnbFVYX33VCzCbLleQxi5t736sP+RI7YR5VmjwB745Xl3Dye/nSD3MRrVTRJ44a2q9JAcrwwfxCNW1lquPPmEpl8Lavx/D9Zx1p55Ogm6Ecf6VZ+VF6PZGFs67IpKIx383c9vMRMabd72/7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zkf8KVjbJkwXRkX51n1K74y/9B7gRqxO3OFw7gsHYu8=; b=G+4Czq6CUIBg/E/9OWs1kUsZP23kY8EIP3fAwvHrET/+g7xvWwywrJ8xNuTM1CDzYKlA+Gty0q6MxEkWQrVxFqbT6+spf2h6QQY2ztLelV4TgwT64I8d9ChYIdyMcGppDsWLIKSz5OKEB57rL+Y2Cs3+roj14b/XHnRXWo+Nvvg= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1792.namprd11.prod.outlook.com (2603:10b6:300:10b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23; Wed, 29 Jul 2020 19:00:37 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3239.017; Wed, 29 Jul 2020 19:00:37 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> CC: "mike@mnmoran.org" <mike@mnmoran.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: Add guard against wedging outbound queue Thread-Topic: [PATCH BlueZ] mesh: Add guard against wedging outbound queue Thread-Index: AQHWZcBQu+oUh0kTcUuSK+nyNK6OMKke6ZaA Date: Wed, 29 Jul 2020 19:00:37 +0000 Message-ID: <c5550c4c6d3009e6f0c76c709baf82c9522dfa11.camel@intel.com> References: <20200729155234.547679-1-brian.gix@intel.com> In-Reply-To: <20200729155234.547679-1-brian.gix@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [134.134.139.74] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f0eb9780-2534-47a3-9f14-08d833f1ae5a x-ms-traffictypediagnostic: MWHPR11MB1792: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR11MB1792BE300936EB8ED1A215BFE1700@MWHPR11MB1792.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Fkb9zefRTChxduZ0p0nYDI3TLlaKxjclf776CsOdyDqigY2RHSBLQN53RirxCGB7MAkKnPkm5A8qnT8a6rhrvICYBnTt/efKOXa8d2xC49035lrnnm0VlUYGzgaQAvMtasZXqFJlqvhytom6jgTfmHFdJkih1uQlLBOuXa7zGGM9SYg6jpDElAHrsfFWEmfm5JXzOEdn8Ak41VC6Yhl0Y9WKgsO7RAFjQtG6gJry5MC5CsjOTwY5dJehEMcnwViI7g2OImoaGA2RSwGd3j5jE5eV4b2hJ82WhDvt20ew1YUBNIg95PCnYq8g8riU+mgufGe7njxd1ZRmNmbfqUKpZQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(6916009)(107886003)(26005)(71200400001)(6486002)(478600001)(186003)(36756003)(5660300002)(4326008)(2616005)(64756008)(76116006)(316002)(2906002)(6506007)(6512007)(66476007)(66556008)(86362001)(66946007)(66446008)(54906003)(8936002)(8676002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: /SdYcro9P776J9/8PAHIEBlS8+WSqEKno7d+pWhEHkbff/uWERsFE6IPaqNPUM/n4/Fteyl/fpR4X5DolJdJwn4TTIJAQcq3UNHc7t0ehcVc/XukG7BhEOwvUU7wqOgiwobctblwzcz/zIMZKabJJGJTRxYm5XeZMF26Wj7DUIjbNT7ulUqiAaxKbvGyfTUxGCl27KDthIw+9M2Rw8iSuT5JlSLmf6n/xcUjQXVJc6ACTlV9kDqPjm6GYfEv+P0GE2tA8PJbTxSgYBYQTIed8YHLs7yYyX7K7Bre4VYOU03fA7rzytAZY5VF6QLnOiBi4EjD4O1UsJi8LcZpUJiS292I3PrRL2FyenoD7Jyo0BFpyGLbDB3+no6nqbMetKPw8qercx2ut18q4VU6Pl/dEDIhjI6a1L1yKJq0+lc+q47vVwtU0ch8AlNSCs9BDkgPPL6zBbDV1JYIsUhQNfSjhA9WeaO2E71sh8px7Wt6q1X/zxcIMVOthEssHTTU6fRq Content-Type: text/plain; charset="utf-8" Content-ID: <90FD69813994594D84792F88B2C205DE@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0eb9780-2534-47a3-9f14-08d833f1ae5a X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jul 2020 19:00:37.6183 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: dPGcMxCSqjufStQ1Gbethu131l5UA1hQUYDSYb0bWnmeaSp2+s62Z6/rP2N+cTwvY14gu1N5yK3SNjfUuFihAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1792 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 70965A1BEA X-Rspamd-UID: b6ebed QXBwbGllZA0KT24gV2VkLCAyMDIwLTA3LTI5IGF0IDA4OjUyIC0wNzAwLCBCcmlhbiBHaXggd3Jv dGU6DQo+IFdoZW4gdXNpbmcgSENJIGNvbW1hbmQgY2hhaW5zLCB0aGUgZmlyc3QgcGFja2V0IHNl bmQgdGhhdCBzdGFydHMgYW4NCj4gb3V0Ym91bmQgc2VxdWVuY2UgbmVlZHMgdG8gc3RpbGwgZXhp c3Qgd2hlbiBjb21tYW5kIGNoYWluIGNvbXBsZXRlcywgb3INCj4gdGhlIG91dGJvdW5kIHF1ZXVl IHdpbGwgd2VkZ2UuICBUaGUgc2ltcGxlc3Qgc29sdXRpb24gaXMgdG8gc2VuZCBwYWNrZXRzDQo+ IGF0IGxlYXN0IHR3aWNlIG9uIGFuIGVtcHR5IHF1ZXVlLCBpZiB0aGVyZSBpcyBhIGNoYW5jZSBp dCBjb3VsZCBiZSBjYW5jZWxlZC4NCj4gLS0tDQo+ICBtZXNoL21lc2gtaW8tZ2VuZXJpYy5jIHwg OCArKysrKysrKw0KPiAgMSBmaWxlIGNoYW5nZWQsIDggaW5zZXJ0aW9ucygrKQ0KPiANCj4gZGlm ZiAtLWdpdCBhL21lc2gvbWVzaC1pby1nZW5lcmljLmMgYi9tZXNoL21lc2gtaW8tZ2VuZXJpYy5j DQo+IGluZGV4IDg2OTUyNTE2ZS4uNGIyNmIxMTgxIDEwMDY0NA0KPiAtLS0gYS9tZXNoL21lc2gt aW8tZ2VuZXJpYy5jDQo+ICsrKyBiL21lc2gvbWVzaC1pby1nZW5lcmljLmMNCj4gQEAgLTcxNCw2 ICs3MTQsMTQgQEAgc3RhdGljIGJvb2wgc2VuZF90eChzdHJ1Y3QgbWVzaF9pbyAqaW8sIHN0cnVj dCBtZXNoX2lvX3NlbmRfaW5mbyAqaW5mbywNCj4gIAkJCXNlbmRpbmcgPSAhbF9xdWV1ZV9pc2Vt cHR5KHB2dC0+dHhfcGt0cyk7DQo+ICANCj4gIAkJbF9xdWV1ZV9wdXNoX3RhaWwocHZ0LT50eF9w a3RzLCB0eCk7DQo+ICsNCj4gKwkJLyoNCj4gKwkJICogSWYgdHJhbnNtaXR0ZXIgaXMgaWRsZSwg c2VuZCBwYWNrZXRzIGF0IGxlYXN0IHR3aWNlIHRvDQo+ICsJCSAqIGd1YXJkIGFnYWluc3QgaW4t bGluZSBjYW5jZWxhdGlvbiBvZiBIQ0kgY29tbWFuZCBjaGFpbi4NCj4gKwkJICovDQo+ICsJCWlm IChpbmZvLT50eXBlID09IE1FU0hfSU9fVElNSU5HX1RZUEVfR0VORVJBTCAmJiAhc2VuZGluZyAm Jg0KPiArCQkJCQkJCXR4LT5pbmZvLnUuZ2VuLmNudCA9PSAxKQ0KPiArCQkJdHgtPmluZm8udS5n ZW4uY250Kys7DQo+ICAJfQ0KPiAgDQo+ICAJaWYgKCFzZW5kaW5nKSB7DQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8DTuN6sDIl9JIAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 01:18:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cKVFNqsDIl9UXQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 01:18:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C755040676; Thu, 30 Jul 2020 01:17:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728045AbgG2XRv (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 29 Jul 2020 19:17:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727087AbgG2XRu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 29 Jul 2020 19:17:50 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC7A3C061794 for <linux-bluetooth@vger.kernel.org>; Wed, 29 Jul 2020 16:17:50 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id d188so7881027pfd.2 for <linux-bluetooth@vger.kernel.org>; Wed, 29 Jul 2020 16:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=R9HgHOXqVNgKdIpZbWbUHoQKwYNiPIQ6hR37SC3F4W0=; b=F0/twXqvlLuXWYfAcB2/sK2KH7Vo0KM8YEPTPxzUM+c2KUAX7hft542jNg7au6To8O 8PuIdaDMGVV5WZp/uxoUnbVtdsAVB/RUeKN8N5AUFaYRbM5lwNU1YrcS1zzoGccQpTVY MZ40lheu2dCFtdbdnR6bI6mqIJPN7Cj2Gfroc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=R9HgHOXqVNgKdIpZbWbUHoQKwYNiPIQ6hR37SC3F4W0=; b=Th6rNpDuHCsok8Uv8XCmxALf54x5Rb+p78LBuavCE+cCKUEoMs08r9fYGMIfH3kEw3 SNa/NJWCPyL2gGv8IToiJ6/aBzQ1FGFrqbYMN1eUjnxbbkXN+4u6NBkqWj/OEzhLk01U 4W7hbdSv4B06/FeIMGUxDncpx7BtBm2JyAJDIifPZvkdRWN48bW6JNexwdLaUa0fWCMd grXCp7u3tgfLuW33ZULWoL7a1aZe9A7EP7NTM10uiF6FCV2Rm9bD2zkPmG7kvJdMUI/x 2tma7Mev7Lt9TT4+LQfRE5xQcMiQPtg+og0cx4Mr+Owaaq3EKxsDLAFSTOmLXlmSjds/ hiUA== X-Gm-Message-State: AOAM531QG9eQF79yrinNHZsO5lLwf0oBGTe7DAxGXsRpef37qS8Tkjgo GF74+wjMz5PFiXYyrS+5g8AumA== X-Google-Smtp-Source: ABdhPJxHKfvbjFH/RI2aP1uExJ+na8MkvlhpokW2aSYM8Li6Xk9CijHIwGwIwEeK6WqpBK5kymCzJQ== X-Received: by 2002:aa7:93a6:: with SMTP id x6mr377357pff.37.1596064670156; Wed, 29 Jul 2020 16:17:50 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id x18sm3538093pfc.93.2020.07.29.16.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2020 16:17:49 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Kai-Heng Feng <kai.heng.feng@canonical.com>, linux-bluetooth@vger.kernel.org, Alex Lu <alex_lu@realsil.com.cn>, linux-pm@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org Subject: [PATCH] Revert "Bluetooth: btusb: Disable runtime suspend on Realtek devices" Date: Wed, 29 Jul 2020 16:17:43 -0700 Message-Id: <20200729161740.1.Ib03d0827c8e48fc3df887fec698f79fa335c9274@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.62 / 15.00 / 200.00 X-Rspamd-Queue-Id: C755040676 X-Rspamd-UID: fd79c9 This reverts commit 7ecacafc240638148567742cca41aa7144b4fe1e. Testing this change on a board with RTL8822CE, I found that enabling autosuspend has no effect on the stability of the system. The board continued working after autosuspend, suspend and reboot. The original commit makes it impossible to enable autosuspend on working systems so it should be reverted. Disabling autosuspend should be done via module param or udev in userspace instead. Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- We have a few Chromebooks using the RTL 8822CE part over USB and they are running without problems with autosuspend enabled. While bringing up a new board, I found some power regressions that I was able to narrow down to this change so I'm requesting a revert. I tested this on Hp Chromebook 14a (running 4.14 kernel and 5.4 kernel) with this revert: * Enabled autosuspend, used it normally with a HID device * Suspended the Chromebook and verified it worked normally on resume * Rebooted the Chromebook and verified Bluetooth was working on next boot I didn't see the issue that was originally reported with this fix. For the original reporter, if you're still seeing this issue, there are other ways to disable autosuspend for your device: * set module param: enable_autosuspend=0 * change your kconfig so BT_HCIBTUSB_AUTOSUSPEND=n * use a udev rule to disable autosuspend for specific vid:pid Keeping this change in the kernel makes it impossible to enable autosuspend so it should be reverted. drivers/bluetooth/btusb.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 1f51494f581812..8d2608ddfd0875 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -4086,10 +4086,6 @@ static int btusb_probe(struct usb_interface *intf, set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); else bt_dev_err(hdev, "Device does not support ALT setting 1"); - - err = usb_autopm_get_interface(intf); - if (err < 0) - goto out_free_dev; } if (!reset) -- 2.28.0.rc0.142.g3c755180ce-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KAg9AVBJIl/KcQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 06:15:12 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id KH9ZO09JIl9WQwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 06:15:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EBB5F41747; Thu, 30 Jul 2020 06:15:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727966AbgG3EPB convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 00:15:01 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:59811 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726194AbgG3EPB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 00:15:01 -0400 Received: from mail-pl1-f198.google.com ([209.85.214.198]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from <kai.heng.feng@canonical.com>) id 1k0zy6-0003Uj-Lc for linux-bluetooth@vger.kernel.org; Thu, 30 Jul 2020 04:14:58 +0000 Received: by mail-pl1-f198.google.com with SMTP id y9so15784080plr.9 for <linux-bluetooth@vger.kernel.org>; Wed, 29 Jul 2020 21:14:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=5cMoLJ8ubMqndVw9m4PPR4lyGXii7QUn7MzeOw06kcg=; b=UW74EcVtzB0UgGt5ZxqpwFj2ake7kOCfFKQvgIqtF7H+MAR/qoEg8oW8UE2/1yfL3H wrsCddMR2XPuVOSF0iZWwBIz13hJrRG/hYt4WOUeK1M4V2gv5lWQF8oNQpPrtd19Pca9 U5mXWXst05rB3t0YT1HuBWD4w+1euIS+uSGTzEIJ7rIlCHd6+wjVSdpLXzd106taAkQY 5rnNQjdWY4ctuZDvVmItOOoSJtojWbVNqucG5BF5wfXOrcPnb9HWPhMThgOz7EMt+AxY Y2FPXcgiQA76PzuZ5BwH2o7lNQmS1CeRUxOoQNL0YBuG9xX9Y9fPzcLPT8aSFsVf4x5k 3Puw== X-Gm-Message-State: AOAM533FBTUtzAfDGTlEuKVEKzStMOgRnWNxxK4Ai4j5Wg6yAVu1vPSv ROHIr++w6eGFGVDlSD0zmCJKYY6PRPhFMP7WHsJLCdUkgSyQbULV5TLm3uwNK/5K/fwk9PIavor klT/6THKdig1npgY3O9efmrs2EOXn/x1OIeRdp49NrUQhCg== X-Received: by 2002:a17:90b:1b08:: with SMTP id nu8mr1251782pjb.190.1596082497057; Wed, 29 Jul 2020 21:14:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHqxgRcJVzZxTqIEzl11Z+pJEA4N4b+XBeqOzZNX+oq5PUFsnaJHeYA005ToKEdz5KDXYSDA== X-Received: by 2002:a17:90b:1b08:: with SMTP id nu8mr1251748pjb.190.1596082496693; Wed, 29 Jul 2020 21:14:56 -0700 (PDT) Received: from [192.168.1.208] (220-133-187-190.HINET-IP.hinet.net. [220.133.187.190]) by smtp.gmail.com with ESMTPSA id b12sm4257122pga.87.2020.07.29.21.14.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jul 2020 21:14:45 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Revert "Bluetooth: btusb: Disable runtime suspend on Realtek devices" From: Kai-Heng Feng <kai.heng.feng@canonical.com> In-Reply-To: <20200729161740.1.Ib03d0827c8e48fc3df887fec698f79fa335c9274@changeid> Date: Thu, 30 Jul 2020 12:14:42 +0800 Cc: marcel@holtmann.org, chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Alex Lu <alex_lu@realsil.com.cn>, linux-pm@vger.kernel.org, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <8DFB5D1A-AA7E-4960-9937-4FD00827937B@canonical.com> References: <20200729161740.1.Ib03d0827c8e48fc3df887fec698f79fa335c9274@changeid> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.86 / 15.00 / 200.00 X-Rspamd-Queue-Id: EBB5F41747 X-Rspamd-UID: c0fb2d Hi Abhishek, > On Jul 30, 2020, at 07:17, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > This reverts commit 7ecacafc240638148567742cca41aa7144b4fe1e. > > Testing this change on a board with RTL8822CE, I found that enabling > autosuspend has no effect on the stability of the system. The board > continued working after autosuspend, suspend and reboot. The original issue was found on 8723DE. Do you have one to test with? The rtw88 codebase has changed a lot and maybe it's already fixed in mainline. Let me do some test and I'll report back. > > The original commit makes it impossible to enable autosuspend on working > systems so it should be reverted. Disabling autosuspend should be done > via module param or udev in userspace instead. > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > We have a few Chromebooks using the RTL 8822CE part over USB and they > are running without problems with autosuspend enabled. While bringing up > a new board, I found some power regressions that I was able to narrow > down to this change so I'm requesting a revert. > > I tested this on Hp Chromebook 14a (running 4.14 kernel and 5.4 kernel) > with this revert: > * Enabled autosuspend, used it normally with a HID device > * Suspended the Chromebook and verified it worked normally on resume > * Rebooted the Chromebook and verified Bluetooth was working on next > boot > > I didn't see the issue that was originally reported with this fix. For > the original reporter, if you're still seeing this issue, there are > other ways to disable autosuspend for your device: > * set module param: enable_autosuspend=0 > * change your kconfig so BT_HCIBTUSB_AUTOSUSPEND=n > * use a udev rule to disable autosuspend for specific vid:pid > > Keeping this change in the kernel makes it impossible to enable > autosuspend so it should be reverted. It's apparently a driver/firmware/hardware issue, so the fix should keep inside the kernel. However, the fix can be more precise and target only 8723DE. Kai-Heng > > drivers/bluetooth/btusb.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index 1f51494f581812..8d2608ddfd0875 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -4086,10 +4086,6 @@ static int btusb_probe(struct usb_interface *intf, > set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); > else > bt_dev_err(hdev, "Device does not support ALT setting 1"); > - > - err = usb_autopm_get_interface(intf); > - if (err < 0) > - goto out_free_dev; > } > > if (!reset) > -- > 2.28.0.rc0.142.g3c755180ce-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kKWEBJcKIl86XQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 01:47:35 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 6HzFApcKIl+YagEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 01:47:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1697BA013F; Thu, 30 Jul 2020 01:47:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728104AbgG2XrY (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 29 Jul 2020 19:47:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726876AbgG2XrX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 29 Jul 2020 19:47:23 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41A84C061794 for <linux-bluetooth@vger.kernel.org>; Wed, 29 Jul 2020 16:47:23 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id l26so2260813otj.4 for <linux-bluetooth@vger.kernel.org>; Wed, 29 Jul 2020 16:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EZ9V/dr7oFsukaxirn8jisC+9O+yg0YZbygWnIx9yC0=; b=H3d6erupdQYZFeermYxF9Rh9QNyl+2CzuSItPDI71wVsOGfbY2QZr9cFTQOzI/Uj/e 98ObK+R0m8lzVi3M9Z/5IX++9osnB06uBbWa3a/G0ttjahCnK35GjMQh2QIlA9T48uEB PFEPA//5Uqp8aGAi1sOljP9DXpIBSEh0D1UdT16p6UqcgqwzdKVFEQDQcYfeSKOqoYsN +J2NjNA7X+OkbR2BDCOEfvrZjOyj+rzzlc8w8Irzgt+glYugpRb1OIWx/9DB6+3xYL0R eyVHBHBvqz0KZiRukdk5igEbhxYGIJzydHk3tQxUDsuTl6WVjSCaKItDtQ3scC5vT/Yv 0e0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EZ9V/dr7oFsukaxirn8jisC+9O+yg0YZbygWnIx9yC0=; b=GZeQKxbhCtJHh1ae/r7aN0Hfd4V74+Y6NaYZ10WMc4Auq5sMcZLje8vcwLdjgyVLJK fkVbFu2FgtseZuMWFsHRQ8XUCleQOdsLC9cy5KRrI8076wcmkaptXP/j+qyOx6yw8nQh kXbY1xYRi/FpUyW4owNLApvMIFbKq1LIuVykUe+YGKvbIanVMln/haPiVOU3ep/hza9U pShpLrC5RFENzRMGd6+x/2iMsFiBgO6Od5L6aI7YZEAdnuZgAivIzMwRlx75YCZ5yjuG kmIzjsKBC516kD3ZG2o74mdit4kdc0BcsbmHIWNrbd3Lb/W1FqKKpb4dIBlrpsHmYZsi k6iw== X-Gm-Message-State: AOAM530rn36fHQ+sqbc78eBAxSGMZhEp4Pl344S0LKlk8F3h/TA2ZWhE cbSEpXZ0Ua/DqhOJYJxQdTY4IZbBHnHmSRDq7hA= X-Google-Smtp-Source: ABdhPJzt6y60cRjAP1zHHvCJcEZkDpYWNZYnqPZpjMcx3yP1yhB/Jv998TT915Fuk87Ylbe8tMIHmEtE+Fdltr3Anyw= X-Received: by 2002:a9d:6053:: with SMTP id v19mr285126otj.362.1596066442350; Wed, 29 Jul 2020 16:47:22 -0700 (PDT) MIME-Version: 1.0 References: <20200729224945.Bluez.v1.1.If7e0a0d17cf6c6508f68f1505fa5864af624a4b7@changeid> In-Reply-To: <20200729224945.Bluez.v1.1.If7e0a0d17cf6c6508f68f1505fa5864af624a4b7@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 29 Jul 2020 16:47:13 -0700 Message-ID: <CABBYNZLoA=greXWaBBNJ9pkmtckfRZQZuho1+9A_GNffrw=S7w@mail.gmail.com> Subject: Re: [Bluez PATCH v1] input/device: Implement handle for UHID_SET_REPORT To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.60 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1697BA013F X-Rspamd-UID: 2cc655 Hi Archie, On Wed, Jul 29, 2020 at 7:50 AM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > This patch listens to UHID_SET_REPORT event and forwards this > message to the hid device. Upon reply, we also send a report back > to the kernel as UHID_SET_REPORT_REPLY. > > Furthermore, this patch also send UHID_DESTROY upon disconnection, > and replaces the obsolete UHID_FEATURE with the compatible > UHID_GET_REPORT. Lets have the replace of UHID_FEATURE with UHID_GET_REPORT, use of UHID_DESTROY and handing of UHID_SET_REPORT_REPLY each as separate patch, it would also be nice to get some more description on how this needs to be done if in the future this causes some problem we can just look at the history. > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > > profiles/input/device.c | 166 +++++++++++++++++++++++++++---------- > profiles/input/hidp_defs.h | 2 +- > 2 files changed, 124 insertions(+), 44 deletions(-) > > diff --git a/profiles/input/device.c b/profiles/input/device.c > index ee0b2404a..8fc04be37 100644 > --- a/profiles/input/device.c > +++ b/profiles/input/device.c > @@ -117,6 +117,7 @@ bool input_get_classic_bonded_only(void) > > static void input_device_enter_reconnect_mode(struct input_device *idev); > static int connection_disconnect(struct input_device *idev, uint32_t flags); > +static int uhid_disconnect(struct input_device *idev); > > static bool input_device_bonded(struct input_device *idev) > { > @@ -220,7 +221,7 @@ static bool hidp_send_intr_message(struct input_device *idev, uint8_t hdr, > return hidp_send_message(idev->intr_io, hdr, data, size); > } > > -static bool uhid_send_feature_answer(struct input_device *idev, > +static bool uhid_send_get_report_reply(struct input_device *idev, > const uint8_t *data, size_t size, > uint32_t id, uint16_t err) > { > @@ -230,8 +231,8 @@ static bool uhid_send_feature_answer(struct input_device *idev, > if (data == NULL) > size = 0; > > - if (size > sizeof(ev.u.feature_answer.data)) > - size = sizeof(ev.u.feature_answer.data); > + if (size > sizeof(ev.u.get_report_reply.data)) > + size = sizeof(ev.u.get_report_reply.data); > > if (!idev->uhid_created) { > DBG("HID report (%zu bytes) dropped", size); > @@ -239,13 +240,13 @@ static bool uhid_send_feature_answer(struct input_device *idev, > } > > memset(&ev, 0, sizeof(ev)); > - ev.type = UHID_FEATURE_ANSWER; > - ev.u.feature_answer.id = id; > - ev.u.feature_answer.err = err; > - ev.u.feature_answer.size = size; > + ev.type = UHID_GET_REPORT_REPLY; > + ev.u.get_report_reply.id = id; > + ev.u.get_report_reply.err = err; > + ev.u.get_report_reply.size = size; > > if (size > 0) > - memcpy(ev.u.feature_answer.data, data, size); > + memcpy(ev.u.get_report_reply.data, data, size); > > ret = bt_uhid_send(idev->uhid, &ev); > if (ret < 0) { > @@ -258,6 +259,29 @@ static bool uhid_send_feature_answer(struct input_device *idev, > return true; > } > > +static bool uhid_send_set_report_reply(struct input_device *idev, > + uint32_t id, uint16_t err) > +{ > + struct uhid_event ev; > + int ret; > + > + if (!idev->uhid_created) > + return false; > + > + memset(&ev, 0, sizeof(ev)); > + ev.type = UHID_SET_REPORT_REPLY; > + ev.u.set_report_reply.id = id; > + ev.u.set_report_reply.err = err; > + > + ret = bt_uhid_send(idev->uhid, &ev); > + if (ret < 0) { > + error("bt_uhid_send: %s (%d)", strerror(-ret), -ret); > + return false; > + } > + > + return true; > +} > + > static bool uhid_send_input_report(struct input_device *idev, > const uint8_t *data, size_t size) > { > @@ -370,6 +394,10 @@ static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data > if (!idev->ctrl_io && idev->virtual_cable_unplug) > virtual_cable_unplug(idev); > > + /* If connection abruptly ended, uhid might be not yet disconnected */ > + if (idev->uhid_created) > + uhid_disconnect(idev); > + > return FALSE; > } > > @@ -399,11 +427,13 @@ static void hidp_recv_ctrl_handshake(struct input_device *idev, uint8_t param) > case HIDP_HSHK_ERR_FATAL: > if (pending_req_type == HIDP_TRANS_GET_REPORT) { > DBG("GET_REPORT failed (%u)", param); > - uhid_send_feature_answer(idev, NULL, 0, > + uhid_send_get_report_reply(idev, NULL, 0, > idev->report_rsp_id, EIO); > pending_req_complete = true; > } else if (pending_req_type == HIDP_TRANS_SET_REPORT) { > DBG("SET_REPORT failed (%u)", param); > + uhid_send_set_report_reply(idev, idev->report_rsp_id, > + EIO); > pending_req_complete = true; > } else > DBG("Spurious HIDP_HSHK_ERR"); > @@ -446,7 +476,8 @@ static void hidp_recv_ctrl_data(struct input_device *idev, uint8_t param, > DBG(""); > > pending_req_type = idev->report_req_pending & HIDP_HEADER_TRANS_MASK; > - if (pending_req_type != HIDP_TRANS_GET_REPORT) { > + if (pending_req_type != HIDP_TRANS_GET_REPORT && > + pending_req_type != HIDP_TRANS_SET_REPORT) { > DBG("Spurious DATA on control channel"); > return; > } > @@ -460,9 +491,13 @@ static void hidp_recv_ctrl_data(struct input_device *idev, uint8_t param, > switch (param) { > case HIDP_DATA_RTYPE_FEATURE: > case HIDP_DATA_RTYPE_INPUT: > - case HIDP_DATA_RTYPE_OUPUT: > - uhid_send_feature_answer(idev, data + 1, size - 1, > + case HIDP_DATA_RTYPE_OUTPUT: > + if (pending_req_type == HIDP_TRANS_GET_REPORT) > + uhid_send_get_report_reply(idev, data + 1, size - 1, > idev->report_rsp_id, 0); > + else > + uhid_send_set_report_reply(idev, idev->report_rsp_id, > + 0); > break; > > case HIDP_DATA_RTYPE_OTHER: > @@ -579,9 +614,13 @@ static gboolean hidp_report_req_timeout(gpointer data) > switch (pending_req_type) { > case HIDP_TRANS_GET_REPORT: > req_type_str = "GET_REPORT"; > + uhid_send_get_report_reply(idev, NULL, 0, idev->report_rsp_id, > + ETIMEDOUT); > break; > case HIDP_TRANS_SET_REPORT: > req_type_str = "SET_REPORT"; > + uhid_send_set_report_reply(idev, idev->report_rsp_id, > + ETIMEDOUT); > break; > default: > /* Should never happen */ > @@ -598,6 +637,17 @@ static gboolean hidp_report_req_timeout(gpointer data) > return FALSE; > } > > +static void hidp_send_output(struct uhid_event *ev, void *user_data) > +{ > + struct input_device *idev = user_data; > + uint8_t hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUTPUT; > + > + DBG(""); > + > + hidp_send_intr_message(idev, hdr, ev->u.output.data, > + ev->u.output.size); > +} > + > static void hidp_send_set_report(struct uhid_event *ev, void *user_data) > { > struct input_device *idev = user_data; > @@ -606,34 +656,37 @@ static void hidp_send_set_report(struct uhid_event *ev, void *user_data) > > DBG(""); > > - switch (ev->u.output.rtype) { > + switch (ev->u.set_report.rtype) { > case UHID_FEATURE_REPORT: > - /* Send SET_REPORT on control channel */ > - if (idev->report_req_pending) { > - DBG("Old GET_REPORT or SET_REPORT still pending"); > - return; > - } > - > hdr = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE; > - sent = hidp_send_ctrl_message(idev, hdr, ev->u.output.data, > - ev->u.output.size); > - if (sent) { > - idev->report_req_pending = hdr; > - idev->report_req_timer = > - g_timeout_add_seconds(REPORT_REQ_TIMEOUT, > - hidp_report_req_timeout, idev); > - } > + break; > + case UHID_INPUT_REPORT: > + hdr = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_INPUT; > break; > case UHID_OUTPUT_REPORT: > - /* Send DATA on interrupt channel */ > - hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT; > - hidp_send_intr_message(idev, hdr, ev->u.output.data, > - ev->u.output.size); > + hdr = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_OUTPUT; > break; > default: > - DBG("Unsupported HID report type %u", ev->u.output.rtype); > + DBG("Unsupported HID report type %u", ev->u.set_report.rtype); > return; > } > + > + if (idev->report_req_pending) { > + DBG("Old GET_REPORT or SET_REPORT still pending"); > + uhid_send_set_report_reply(idev, ev->u.set_report.id, EBUSY); > + return; > + } > + > + sent = hidp_send_ctrl_message(idev, hdr, ev->u.set_report.data, > + ev->u.set_report.size); > + if (sent) { > + idev->report_req_pending = hdr; > + idev->report_req_timer = > + g_timeout_add_seconds(REPORT_REQ_TIMEOUT, > + hidp_report_req_timeout, idev); > + idev->report_rsp_id = ev->u.set_report.id; > + } else > + uhid_send_set_report_reply(idev, ev->u.set_report.id, EIO); > } > > static void hidp_send_get_report(struct uhid_event *ev, void *user_data) > @@ -646,13 +699,13 @@ static void hidp_send_get_report(struct uhid_event *ev, void *user_data) > > if (idev->report_req_pending) { > DBG("Old GET_REPORT or SET_REPORT still pending"); > - uhid_send_feature_answer(idev, NULL, 0, ev->u.feature.id, > + uhid_send_get_report_reply(idev, NULL, 0, ev->u.get_report.id, > EBUSY); > return; > } > > /* Send GET_REPORT on control channel */ > - switch (ev->u.feature.rtype) { > + switch (ev->u.get_report.rtype) { > case UHID_FEATURE_REPORT: > hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_FEATURE; > break; > @@ -660,22 +713,24 @@ static void hidp_send_get_report(struct uhid_event *ev, void *user_data) > hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_INPUT; > break; > case UHID_OUTPUT_REPORT: > - hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_OUPUT; > + hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_OUTPUT; > break; > default: > - DBG("Unsupported HID report type %u", ev->u.feature.rtype); > + DBG("Unsupported HID report type %u", ev->u.get_report.rtype); > return; > } > > - sent = hidp_send_ctrl_message(idev, hdr, &ev->u.feature.rnum, > - sizeof(ev->u.feature.rnum)); > + sent = hidp_send_ctrl_message(idev, hdr, &ev->u.get_report.rnum, > + sizeof(ev->u.get_report.rnum)); > if (sent) { > idev->report_req_pending = hdr; > idev->report_req_timer = > g_timeout_add_seconds(REPORT_REQ_TIMEOUT, > hidp_report_req_timeout, idev); > - idev->report_rsp_id = ev->u.feature.id; > - } > + idev->report_rsp_id = ev->u.get_report.id; > + } else > + uhid_send_get_report_reply(idev, NULL, 0, ev->u.get_report.id, > + EIO); > } > > static void epox_endian_quirk(unsigned char *data, int size) > @@ -908,14 +963,39 @@ static int uhid_connadd(struct input_device *idev, struct hidp_connadd_req *req) > return err; > } > > - bt_uhid_register(idev->uhid, UHID_OUTPUT, hidp_send_set_report, idev); > - bt_uhid_register(idev->uhid, UHID_FEATURE, hidp_send_get_report, idev); > + bt_uhid_register(idev->uhid, UHID_OUTPUT, hidp_send_output, idev); > + bt_uhid_register(idev->uhid, UHID_GET_REPORT, hidp_send_get_report, > + idev); > + bt_uhid_register(idev->uhid, UHID_SET_REPORT, hidp_send_set_report, > + idev); > > idev->uhid_created = true; > > return err; > } > > +static int uhid_disconnect(struct input_device *idev) > +{ > + int err; > + struct uhid_event ev; > + > + if (!idev->uhid_created) > + return 0; > + > + memset(&ev, 0, sizeof(ev)); > + ev.type = UHID_DESTROY; > + > + err = bt_uhid_send(idev->uhid, &ev); > + if (err < 0) { > + error("bt_uhid_send: %s", strerror(-err)); > + return err; > + } > + > + idev->uhid_created = false; > + > + return err; > +} > + > static gboolean encrypt_notify(GIOChannel *io, GIOCondition condition, > gpointer data) > { > @@ -1074,7 +1154,7 @@ static int connection_disconnect(struct input_device *idev, uint32_t flags) > idev->virtual_cable_unplug = true; > > if (idev->uhid) > - return 0; > + return uhid_disconnect(idev); > else > return ioctl_disconnect(idev, flags); > } > diff --git a/profiles/input/hidp_defs.h b/profiles/input/hidp_defs.h > index 5dc479acf..bb9231dbb 100644 > --- a/profiles/input/hidp_defs.h > +++ b/profiles/input/hidp_defs.h > @@ -63,7 +63,7 @@ > #define HIDP_DATA_RSRVD_MASK 0x0c > #define HIDP_DATA_RTYPE_OTHER 0x00 > #define HIDP_DATA_RTYPE_INPUT 0x01 > -#define HIDP_DATA_RTYPE_OUPUT 0x02 > +#define HIDP_DATA_RTYPE_OUTPUT 0x02 > #define HIDP_DATA_RTYPE_FEATURE 0x03 > > /* HIDP protocol header parameters */ > -- > 2.28.0.rc0.142.g3c755180ce-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wBJ6DeVdIl/ChAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 07:43:01 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id KEzGC+VdIl/rFgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 07:43:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E4E254166F; Thu, 30 Jul 2020 07:42:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728613AbgG3Fmz (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 01:42:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728195AbgG3Fmy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 01:42:54 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BEDBC061794 for <linux-bluetooth@vger.kernel.org>; Wed, 29 Jul 2020 22:42:53 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id a14so23668810wra.5 for <linux-bluetooth@vger.kernel.org>; Wed, 29 Jul 2020 22:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=LBeaeuqxaxtoO45G9AbSfGvRf/xh3V9TYQgiS7rKYcE=; b=keZRLbt6VbOZ+cZZmB4mr9wkxV/jmXV2gzCpXtRcoqmeVJX63A4ABe4c4RTUUgJ+Fk fe4lB1YNkR7utnYmMMUwmNq9OhwQEQL55WfnpRoTixM2bxA3bzKjUPNF8yv1LoQkphtv slTZyvcTAaX8WJzokfaqSV4yCf9hP77ivIYphBDxJ9clPJMJS85a2BcLycu0mudSPVCW xcC+r1V/mw1HUEkCbG34VWHmVxKBaSs79+tER5pAsegXCIgO/KP8TEqkyG1XZwgB9zeo h35/ezO6HEBGzFaGXagFcZzCMnH+RGBYtwlN66zofO5ORLmjvpshpKW/EnwdpEASytca ld0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=LBeaeuqxaxtoO45G9AbSfGvRf/xh3V9TYQgiS7rKYcE=; b=BEFhZq6OhdpzXa3FClAMvCC4PiwEww/wn3UOfJt33RTWmEhQb4MjkEnDPye1A3mEuK xhAYNDfxOaBcs14v9TMiCWysWpzlE94qV1CuXaSl+/BLqIqbZGwfyVRYkWACRE4T8blF A+mLKYQIKprCG0NYZVLvzKQIeJOPw2Q4zQBtKXAFujQnL+VAc6iWiOKKAh4usxk7uWEw oSWREWSUz2GoF8wYuZiATmQwQNRBgJS4Xbr42mUX/zt0PO9y7zwSYR+gCBfDDxkPcqDl IIaTnckd1Uy+9odCGxRWJzT2rj0QGI9uy3fDKXiq9OylL8wNmVlZHKAk75B+pTjyJbF6 9uaQ== X-Gm-Message-State: AOAM533m/a3JJVPggr79K0+OO6X1tFSC7+XPPfro3CVPn//pIA7+0rFS 4rnEeQDo52pGR85/GuRhIt8= X-Google-Smtp-Source: ABdhPJwrJttMz9TjwYhlt5uervKTZeoihmVmNBILdpeRgvrprdpDDxejbSJ0lA9r8k++IWReR222cw== X-Received: by 2002:a5d:6692:: with SMTP id l18mr32388720wru.211.1596087772327; Wed, 29 Jul 2020 22:42:52 -0700 (PDT) Received: from 168.52.45.77 (201.ip-51-68-45.eu. [51.68.45.201]) by smtp.gmail.com with ESMTPSA id c14sm8061106wrw.85.2020.07.29.22.42.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jul 2020 22:42:51 -0700 (PDT) Subject: Re: [PATCH v4] Bluetooth: btusb: Fix and detect most of the Chinese Bluetooth controllers To: Marcel Holtmann <marcel@holtmann.org> Cc: BlueZ <linux-bluetooth@vger.kernel.org>, Johan Hedberg <johan.hedberg@gmail.com> References: <0bba3f22-a232-3c07-1b05-73e6d38dab8a@gmail.com> <BB91A6AF-35AD-4BFF-BD1A-49292C064A43@holtmann.org> From: Ismael Ferreras Morezuelas <swyterzone@gmail.com> Message-ID: <7ece308a-4890-bb70-bc20-41e89508c12e@gmail.com> Date: Thu, 30 Jul 2020 07:42:47 +0200 User-Agent: nano 6.4 MIME-Version: 1.0 In-Reply-To: <BB91A6AF-35AD-4BFF-BD1A-49292C064A43@holtmann.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: E4E254166F X-Rspamd-UID: 4b69b1 On 28/07/2020 9:10, Marcel Holtmann wrote: > Hi Ismael, > > patch has been applied to bluetooth-next tree. > > Regards > > Marcel > Thanks, Marcel! And sorry for the missing quotes in the 'Fixes' line. Seems like the scripts still don't check for those. I'll keep it in mind. It's been a cool experience, that's for sure. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mO2QJRN3Il9fUgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 09:30:27 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +AwnJBN3Il8KEwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 09:30:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5CD8CA190F; Thu, 30 Jul 2020 09:30:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728961AbgG3HaU convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 03:30:20 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:47807 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726194AbgG3HaU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 03:30:20 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 7D0B8CECF1; Thu, 30 Jul 2020 09:40:19 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Revert "Bluetooth: btusb: Disable runtime suspend on Realtek devices" From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <8DFB5D1A-AA7E-4960-9937-4FD00827937B@canonical.com> Date: Thu, 30 Jul 2020 09:30:16 +0200 Cc: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, chromeos-bluetooth-upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alex Lu <alex_lu@realsil.com.cn>, linux-pm@vger.kernel.org, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <E52C04D8-67C6-4949-B988-A61F6FCD1434@holtmann.org> References: <20200729161740.1.Ib03d0827c8e48fc3df887fec698f79fa335c9274@changeid> <8DFB5D1A-AA7E-4960-9937-4FD00827937B@canonical.com> To: Kai-Heng Feng <kai.heng.feng@canonical.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 11 X-Rspamd-Score: 1.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5CD8CA190F X-Rspamd-UID: 5e896f Hi Kai-Heng, >> On Jul 30, 2020, at 07:17, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: >> >> This reverts commit 7ecacafc240638148567742cca41aa7144b4fe1e. >> >> Testing this change on a board with RTL8822CE, I found that enabling >> autosuspend has no effect on the stability of the system. The board >> continued working after autosuspend, suspend and reboot. > > The original issue was found on 8723DE. Do you have one to test with? > The rtw88 codebase has changed a lot and maybe it's already fixed in mainline. > Let me do some test and I'll report back. > >> >> The original commit makes it impossible to enable autosuspend on working >> systems so it should be reverted. Disabling autosuspend should be done >> via module param or udev in userspace instead. >> >> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> >> --- >> We have a few Chromebooks using the RTL 8822CE part over USB and they >> are running without problems with autosuspend enabled. While bringing up >> a new board, I found some power regressions that I was able to narrow >> down to this change so I'm requesting a revert. >> >> I tested this on Hp Chromebook 14a (running 4.14 kernel and 5.4 kernel) >> with this revert: >> * Enabled autosuspend, used it normally with a HID device >> * Suspended the Chromebook and verified it worked normally on resume >> * Rebooted the Chromebook and verified Bluetooth was working on next >> boot >> >> I didn't see the issue that was originally reported with this fix. For >> the original reporter, if you're still seeing this issue, there are >> other ways to disable autosuspend for your device: >> * set module param: enable_autosuspend=0 >> * change your kconfig so BT_HCIBTUSB_AUTOSUSPEND=n >> * use a udev rule to disable autosuspend for specific vid:pid >> >> Keeping this change in the kernel makes it impossible to enable >> autosuspend so it should be reverted. > > It's apparently a driver/firmware/hardware issue, so the fix should keep inside the kernel. > However, the fix can be more precise and target only 8723DE. lets do that and lets do it quickly since the merge window is close. Otherwise I really have to revert that patch. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OIxOBh6PIl+i0QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:13:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eLHWBB6PIl9dfAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:13:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4AF9440507; Thu, 30 Jul 2020 11:12:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728775AbgG3JMy convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:12:54 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:53207 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726819AbgG3JMx (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:12:53 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 3FD16CECF2; Thu, 30 Jul 2020 11:22:53 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v5 8/8] Bluetooth: Enable controller RPA resolution using Experimental feature From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200723123903.29337-8-sathish.narasimman@intel.com> Date: Thu, 30 Jul 2020 11:12:50 +0200 Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Sathish Narasimman <sathish.narasimman@intel.com> Content-Transfer-Encoding: 8BIT Message-Id: <1F0277AF-FC7E-4200-8274-A13B590154AA@holtmann.org> References: <20200723123903.29337-1-sathish.narasimman@intel.com> <20200723123903.29337-8-sathish.narasimman@intel.com> To: Sathish Narasimman <nsathish41@gmail.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4AF9440507 X-Rspamd-UID: 95bdee Hi Sathish, > This patch adds support to enable the use of RPA Address resolution > using expermental feature mgmt command. > > Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com> > --- > include/net/bluetooth/hci.h | 1 + > net/bluetooth/hci_event.c | 1 + > net/bluetooth/hci_request.c | 7 ++- > net/bluetooth/mgmt.c | 112 ++++++++++++++++++++++++++++++++++++ > 4 files changed, 120 insertions(+), 1 deletion(-) > > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h > index 4ff2fc4498f3..55205d805c22 100644 > --- a/include/net/bluetooth/hci.h > +++ b/include/net/bluetooth/hci.h > @@ -307,6 +307,7 @@ enum { > HCI_FORCE_BREDR_SMP, > HCI_FORCE_STATIC_ADDR, > HCI_LL_RPA_RESOLUTION, > + HCI_ENABLE_LL_PRIVACY, > HCI_CMD_PENDING, > HCI_FORCE_NO_MITM, > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 628831b15c0a..33d8458fdd4a 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -5230,6 +5230,7 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, > le16_to_cpu(ev->supervision_timeout)); > > if (use_ll_privacy(hdev) && > + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && > hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) > hci_req_disable_address_resolution(hdev); > } > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > index 70e077cc7dfa..435400a43a78 100644 > --- a/net/bluetooth/hci_request.c > +++ b/net/bluetooth/hci_request.c > @@ -678,8 +678,10 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) > > /* Disable address resolution */ > if (use_ll_privacy(hdev) && > + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && > hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { > __u8 enable = 0x00; > + > hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); > } > } > @@ -870,8 +872,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, > return; > } > > - if (use_ll_privacy(hdev) && addr_resolv) { > + if (use_ll_privacy(hdev) && > + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && > + addr_resolv) { > u8 enable = 0x01; > + > hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); > } > > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > index 47bcfe2fb14c..adde92cf015d 100644 > --- a/net/bluetooth/mgmt.c > +++ b/net/bluetooth/mgmt.c > @@ -3759,6 +3759,12 @@ static const u8 simult_central_periph_uuid[16] = { > 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > }; > > +/* 15c0a148-c273-11ea-b3de-0242ac130004 */ > +static const u8 rpa_resolution_uuid[16] = { > + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, > + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, > +}; > + > static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > void *data, u16 data_len) > { > @@ -3795,6 +3801,21 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > idx++; > } > > + if (use_ll_privacy(hdev)) { this function can be called with hdev and !hdev and you need to handle this correctly. if (hdev && use_ll_privacy(hdev)) { > + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) { > + flags = BIT(0); > + if (!hci_dev_test_flag(hdev, HCI_ADVERTISING)) > + flags |= BIT(1); > + } else > + flags = 0; I think that I should have explained this in a bit more detail. The BIT(1) needs to be always set when the feature can change settings. It means that bluetoothd needs to re-read controller information to get the new settings. > + > + memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); > + rp->features[idx].flags = cpu_to_le32(flags); > + idx++; > + > + new_settings(hdev, sk); > + } > + > rp->feature_count = cpu_to_le16(idx); I prefer also to extend the buffer to 62 bytes so that it can potentially fit 3 options. > > /* After reading the experimental features information, enable > @@ -3807,6 +3828,27 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > 0, rp, sizeof(*rp) + (20 * idx)); > } > > +static int exp_ll_privacy_feature_changed(bool enabled, struct sock *skip) > +{ > + struct mgmt_ev_exp_feature_changed ev; > + u32 flags; > + > + memset(&ev, 0, sizeof(ev)); > + memcpy(ev.uuid, rpa_resolution_uuid, 16); > + > + if (enabled) > + flags = 0x03; > + else > + flags = 0; > + > + ev.flags = cpu_to_le32(flags); > + > + return mgmt_limited_event(MGMT_EV_EXP_FEATURE_CHANGED, NULL, > + &ev, sizeof(ev), > + HCI_MGMT_EXP_FEATURE_EVENTS, skip); This needs to be send to hdev and not NULL. > + > +} > + > #ifdef CONFIG_BT_FEATURE_DEBUG > static int exp_debug_feature_changed(bool enabled, struct sock *skip) > { > @@ -3845,6 +3887,18 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + if (use_ll_privacy(hdev)) { The experimental setting mgmt might not always be used with a hdev. In addition this feature change must be limited to controller that are powered off. if (hdev && use_ll_privacy(hdev) && !hdev_is_powered(hdev)) { > + bool changed; > + > + changed = hci_dev_test_flag(hdev, > + HCI_ENABLE_LL_PRIVACY); > + > + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); > + > + if (changed) > + exp_ll_privacy_feature_changed(false, sk); > + } > + > hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); > > return mgmt_cmd_complete(sk, hdev ? hdev->id : MGMT_INDEX_NONE, > @@ -3895,6 +3949,64 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + if (!memcmp(cp->uuid, rpa_resolution_uuid, 16)) { > + bool val, changed; > + int err; > + u32 flags; > + /* Command requires to use the controller index */ if (!hdev) return mgmt_cmd_status(sk, MGMT_INDEX_NONE, MGMT_OP_SET_EXP_FEATURE, MGMT_STATUS_INVALID_INDEX); /* Changes can only be made when controller is powered down */ if (hdev_is_powered(hdev)) return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_EXP_FEATURE, MGMT_STATUS_NOT_POWERED); > + /* Parameters are limited to a single octet */ > + if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) > + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, Need to be hdev->id instead of MGMT_INDEX_NONE. > + MGMT_OP_SET_EXP_FEATURE, > + MGMT_STATUS_INVALID_PARAMS); > + > + /* Only boolean on/off is supported */ > + if (cp->param[0] != 0x00 && cp->param[0] != 0x01) > + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, Same as above. > + MGMT_OP_SET_EXP_FEATURE, > + MGMT_STATUS_INVALID_PARAMS); > + > + val = !!cp->param[0]; > + > + if (val) { > + changed = !hci_dev_test_flag(hdev, > + HCI_ENABLE_LL_PRIVACY); > + > + hci_dev_set_flag(hdev, HCI_ENABLE_LL_PRIVACY); > + > + /* Enable LL privacy */ > + flags = BIT(0); > + /* Disable HCI_ADVERTISING flag */ > + flags |= BIT(1); > + > + hci_dev_clear_flag(hdev, HCI_ADVERTISING); > + > + } else { > + changed = hci_dev_test_flag(hdev, > + HCI_ENABLE_LL_PRIVACY); > + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); > + > + flags = 0; BIT(1) needs to be set all the time to indicate that supported settings changed. > + } > + > + memcpy(rp.uuid, rpa_resolution_uuid, 16); > + > + rp.flags = cpu_to_le32(flags); > + > + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); > + > + err = mgmt_cmd_complete(sk, MGMT_INDEX_NONE, Here also we have to use hdev->id and not MGMT_INDEX_NONE. > + MGMT_OP_SET_EXP_FEATURE, 0, > + &rp, sizeof(rp)); > + > + if (changed) { > + exp_ll_privacy_feature_changed(val, sk); > + new_settings(hdev, sk); The new_settings is not helpful. The BIT(1) will already indicate that bluetoothd has to re-read the controller info to get the actual supported settings. > + } > + > + return err; > + } > + > return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, > MGMT_OP_SET_EXP_FEATURE, > MGMT_STATUS_NOT_SUPPORTED); So I fixed these all up and hopefully didn’t make a mistake. I am re-sending the whole series with the fixes. Please review. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wO4lHHqPIl8GDgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:14:34 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6E6WGXqPIl/fXwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:14:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0CC4741D2D; Thu, 30 Jul 2020 11:14:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729209AbgG3JO2 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:14:28 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:39358 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729117AbgG3JO1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:14:27 -0400 Received: from localhost.localdomain (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 7D9FCCECF4 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 11:24:28 +0200 (CEST) From: Marcel Holtmann <marcel@holtmann.org> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 3/8] Bluetooth: Update resolving list when updating whitelist Date: Thu, 30 Jul 2020 11:14:16 +0200 Message-Id: <20200730091421.48847-3-marcel@holtmann.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 2 X-Rspamd-Score: 0.41 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0CC4741D2D X-Rspamd-UID: 1063b2 When the whitelist is updated, then also update the entries of the resolving list for devices where IRKs are available. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sathish Narsimman <sathish.narasimman@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> --- net/bluetooth/hci_request.c | 41 +++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 7d0ba53ffed0..85de1f356610 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -694,6 +694,21 @@ static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, bt_dev_dbg(req->hdev, "Remove %pMR (0x%x) from whitelist", &cp.bdaddr, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST, sizeof(cp), &cp); + + if (use_ll_privacy(req->hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(req->hdev, bdaddr, bdaddr_type); + if (irk) { + struct hci_cp_le_del_from_resolv_list cp; + + cp.bdaddr_type = bdaddr_type; + bacpy(&cp.bdaddr, bdaddr); + + hci_req_add(req, HCI_OP_LE_DEL_FROM_RESOLV_LIST, + sizeof(cp), &cp); + } + } } /* Adds connection to white list if needed. On error, returns -1. */ @@ -714,7 +729,7 @@ static int add_to_white_list(struct hci_request *req, return -1; /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, ¶ms->addr, params->addr_type)) { return -1; } @@ -732,6 +747,28 @@ static int add_to_white_list(struct hci_request *req, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_ADD_TO_WHITE_LIST, sizeof(cp), &cp); + if (use_ll_privacy(hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(hdev, ¶ms->addr, + params->addr_type); + if (irk) { + struct hci_cp_le_add_to_resolv_list cp; + + cp.bdaddr_type = params->addr_type; + bacpy(&cp.bdaddr, ¶ms->addr); + memcpy(cp.peer_irk, irk->val, 16); + + if (hci_dev_test_flag(hdev, HCI_PRIVACY)) + memcpy(cp.local_irk, hdev->irk, 16); + else + memset(cp.local_irk, 0, 16); + + hci_req_add(req, HCI_OP_LE_ADD_TO_RESOLV_LIST, + sizeof(cp), &cp); + } + } + return 0; } @@ -772,7 +809,7 @@ static u8 update_white_list(struct hci_request *req) } /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, &b->bdaddr, b->bdaddr_type)) { return 0x00; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gP4/BYCPIl8GDgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:14:40 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id YLBLA4CPIl8sUAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:14:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8CDD3418A1; Thu, 30 Jul 2020 11:14:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729213AbgG3JO2 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:14:28 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:43649 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728815AbgG3JO1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:14:27 -0400 Received: from localhost.localdomain (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 626DDCECF3 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 11:24:28 +0200 (CEST) From: Marcel Holtmann <marcel@holtmann.org> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 2/8] Bluetooth: Configure controller address resolution if available Date: Thu, 30 Jul 2020 11:14:15 +0200 Message-Id: <20200730091421.48847-2-marcel@holtmann.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 2 X-Rspamd-Score: 0.41 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8CDD3418A1 X-Rspamd-UID: 79d655 When the LL Privacy support is available, then as part of enabling or disabling passive background scanning, it is required to set up the controller based address resolution as well. Since only passive background scanning is utilizing the whitelist, the address resolution is now bound to the whitelist and passive background scanning. All other resolution can be easily done by the host stack. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sathish Narsimman <sathish.narasimman@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> --- include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_request.c | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index bee1b4778ccc..8caac20556b4 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1359,6 +1359,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn); #define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \ ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED)) +/* Use LL Privacy based address resolution if supported */ +#define use_ll_privacy(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY) + /* Use ext scanning if set ext scan param and ext scan enable is supported */ #define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \ ((dev)->commands[37] & 0x40)) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 7c0c2fda04ad..7d0ba53ffed0 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -675,6 +675,12 @@ void hci_req_add_le_scan_disable(struct hci_request *req) cp.enable = LE_SCAN_DISABLE; hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + __u8 enable = 0x00; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } } static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, @@ -816,7 +822,8 @@ static bool scan_use_rpa(struct hci_dev *hdev) } static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, - u16 window, u8 own_addr_type, u8 filter_policy) + u16 window, u8 own_addr_type, u8 filter_policy, + bool addr_resolv) { struct hci_dev *hdev = req->hdev; @@ -825,6 +832,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } + if (use_ll_privacy(hdev) && addr_resolv) { + u8 enable = 0x01; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } + /* Use ext scanning if set ext scan param and ext scan enable is * supported */ @@ -898,12 +910,18 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, } } +/* Ensure to call hci_req_add_le_scan_disable() first to disable the + * controller based address resolution to be able to reconfigure + * resolving list. + */ void hci_req_add_le_passive_scan(struct hci_request *req) { struct hci_dev *hdev = req->hdev; u8 own_addr_type; u8 filter_policy; u16 window, interval; + /* Background scanning should run with address resolution */ + bool addr_resolv = true; if (hdev->scanning_paused) { bt_dev_dbg(hdev, "Scanning is paused for suspend"); @@ -949,7 +967,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) bt_dev_dbg(hdev, "LE passive scan with whitelist = %d", filter_policy); hci_req_start_scan(req, LE_SCAN_PASSIVE, interval, window, - own_addr_type, filter_policy); + own_addr_type, filter_policy, addr_resolv); } static u8 get_adv_instance_scan_rsp_len(struct hci_dev *hdev, u8 instance) @@ -2789,6 +2807,8 @@ static int active_scan(struct hci_request *req, unsigned long opt) u8 own_addr_type; /* White list is not used for discovery */ u8 filter_policy = 0x00; + /* Discovery doesn't require controller address resolution */ + bool addr_resolv = false; int err; BT_DBG("%s", hdev->name); @@ -2811,7 +2831,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, hdev->le_scan_window_discovery, own_addr_type, - filter_policy); + filter_policy, addr_resolv); return 0; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SIPAHoWPIl8GDgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:14:45 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 4JNQHYWPIl+GfwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:14:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3C63241750; Thu, 30 Jul 2020 11:14:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729256AbgG3JO3 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:14:29 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:59838 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729126AbgG3JO1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:14:27 -0400 Received: from localhost.localdomain (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id B2A7DCECF6 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 11:24:28 +0200 (CEST) From: Marcel Holtmann <marcel@holtmann.org> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 5/8] Bluetooth: Let controller creates RPA during le create conn Date: Thu, 30 Jul 2020 11:14:18 +0200 Message-Id: <20200730091421.48847-5-marcel@holtmann.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.47 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3C63241750 X-Rspamd-UID: 2a76dd From: Sathish Narasimman <nsathish41@gmail.com> When address resolution is enabled and set_privacy is enabled let's use own address type as 0x03 Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> --- net/bluetooth/hci_request.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 85de1f356610..e48f0945a417 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2242,7 +2242,13 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, if (use_rpa) { int to; - *own_addr_type = ADDR_LE_DEV_RANDOM; + /* If Controller supports LL Privacy use own address type is + * 0x03 + */ + if (use_ll_privacy(hdev)) + *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED; + else + *own_addr_type = ADDR_LE_DEV_RANDOM; if (!hci_dev_test_and_clear_flag(hdev, HCI_RPA_EXPIRED) && !bacmp(&hdev->random_addr, &hdev->rpa)) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OCYhOoqPIl++HgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:14:50 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CNq3OIqPIl/uuAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:14:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9A11640134; Thu, 30 Jul 2020 11:14:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729262AbgG3JO3 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:14:29 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:38402 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726819AbgG3JO1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:14:27 -0400 Received: from localhost.localdomain (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 42B6FCECF2 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 11:24:28 +0200 (CEST) From: Marcel Holtmann <marcel@holtmann.org> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 1/8] Bluetooth: Translate additional address type correctly Date: Thu, 30 Jul 2020 11:14:14 +0200 Message-Id: <20200730091421.48847-1-marcel@holtmann.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 1 X-Rspamd-Score: 0.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9A11640134 X-Rspamd-UID: a7c01a When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sathish Narsimman <sathish.narasimman@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> --- include/net/bluetooth/hci.h | 6 ++++-- net/bluetooth/hci_core.c | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 1317dfd8f962..c36dccd6718e 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -2279,8 +2279,10 @@ struct hci_ev_le_conn_complete { #define LE_EXT_ADV_SCAN_RSP 0x0008 #define LE_EXT_ADV_LEGACY_PDU 0x0010 -#define ADDR_LE_DEV_PUBLIC 0x00 -#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC 0x00 +#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC_RESOLVED 0x02 +#define ADDR_LE_DEV_RANDOM_RESOLVED 0x03 #define HCI_EV_LE_ADVERTISING_REPORT 0x02 struct hci_ev_le_advertising_info { diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 4ba23b821cbf..3f89bd639860 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3292,6 +3292,15 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list, { struct hci_conn_params *param; + switch (addr_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + addr_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + addr_type = ADDR_LE_DEV_RANDOM; + break; + } + list_for_each_entry(param, list, action) { if (bacmp(¶m->addr, addr) == 0 && param->addr_type == addr_type) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ME4sGZCPIl++HgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:14:56 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WAnwF5CPIl+GfwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:14:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1DDFB41747; Thu, 30 Jul 2020 11:14:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729275AbgG3JOa (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:14:30 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:58139 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729119AbgG3JO1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:14:27 -0400 Received: from localhost.localdomain (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 98838CECF5 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 11:24:28 +0200 (CEST) From: Marcel Holtmann <marcel@holtmann.org> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 4/8] Bluetooth: Translate additional address type during le_conn Date: Thu, 30 Jul 2020 11:14:17 +0200 Message-Id: <20200730091421.48847-4-marcel@holtmann.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 2 X-Rspamd-Score: 0.44 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1DDFB41747 X-Rspamd-UID: 8f9f76 From: Sathish Narasimman <nsathish41@gmail.com> When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. This patch is specially during LE_CREATE_CONN if using own_add_type as 0x02 or 0x03. Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> --- net/bluetooth/hci_event.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 61f8c4d12028..6388fb55b4d2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2296,6 +2296,22 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, if (!conn) return; + /* When using controller based address resolution, then the new + * address types 0x02 and 0x03 are used. These types need to be + * converted back into either public address or random address type + */ + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + switch (own_address_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + own_address_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + own_address_type = ADDR_LE_DEV_RANDOM; + break; + } + } + /* Store the initiator and responder address information which * is needed for SMP. These values will not change during the * lifetime of the connection. -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sGJMAJaPIl+tFwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:15:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id mOrOOpWPIl/uuAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:15:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8658241757; Thu, 30 Jul 2020 11:14:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729291AbgG3JOb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:14:31 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:57558 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729224AbgG3JO3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:14:29 -0400 Received: from localhost.localdomain (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id F1D29CECF8 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 11:24:28 +0200 (CEST) From: Marcel Holtmann <marcel@holtmann.org> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 7/8] Bluetooth: Enable RPA Timeout Date: Thu, 30 Jul 2020 11:14:20 +0200 Message-Id: <20200730091421.48847-7-marcel@holtmann.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8658241757 X-Rspamd-UID: 5faa5b From: Sathish Narasimman <nsathish41@gmail.com> Enable RPA timeout during bluetooth initialization. The RPA timeout value is used from hdev, which initialized from debug_fs Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> --- include/net/bluetooth/hci.h | 2 ++ net/bluetooth/hci_core.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index c36dccd6718e..dd82cce77a7a 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1648,6 +1648,8 @@ struct hci_rp_le_read_resolv_list_size { #define HCI_OP_LE_SET_ADDR_RESOLV_ENABLE 0x202d +#define HCI_OP_LE_SET_RPA_TIMEOUT 0x202e + #define HCI_OP_LE_READ_MAX_DATA_LEN 0x202f struct hci_rp_le_read_max_data_len { __u8 status; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 3f89bd639860..68bfe57b6625 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -763,6 +763,14 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt) hci_req_add(req, HCI_OP_LE_CLEAR_RESOLV_LIST, 0, NULL); } + if (hdev->commands[35] & 0x40) { + __le16 rpa_timeout = cpu_to_le16(hdev->rpa_timeout); + + /* Set RPA timeout */ + hci_req_add(req, HCI_OP_LE_SET_RPA_TIMEOUT, 2, + &rpa_timeout); + } + if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) { /* Read LE Maximum Data Length */ hci_req_add(req, HCI_OP_LE_READ_MAX_DATA_LEN, 0, NULL); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uJH5NJuPIl+tFwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:15:07 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id QDBXM5uPIl+GfwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:15:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 36E22418AD; Thu, 30 Jul 2020 11:15:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729292AbgG3JOb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:14:31 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:47057 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728815AbgG3JOa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:14:30 -0400 Received: from localhost.localdomain (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id D1CB3CECF7 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 11:24:28 +0200 (CEST) From: Marcel Holtmann <marcel@holtmann.org> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 6/8] Bluetooth: Enable/Disable address resolution during le create conn Date: Thu, 30 Jul 2020 11:14:19 +0200 Message-Id: <20200730091421.48847-6-marcel@holtmann.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 36E22418AD X-Rspamd-UID: 4d14f1 From: Sathish Narasimman <nsathish41@gmail.com> In this patch if le_create_conn process is started restrict to disable address resolution and same is disabled during le_enh_connection_complete Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> --- net/bluetooth/hci_conn.c | 7 +++++- net/bluetooth/hci_event.c | 4 ++++ net/bluetooth/hci_request.c | 45 ++++++++++++++++++++++++++++--------- net/bluetooth/hci_request.h | 3 ++- net/bluetooth/mgmt.c | 2 +- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index be67361ff2f0..9832f8445d43 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1003,6 +1003,11 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, struct hci_request req; int err; + /* This ensures that during disable le_scan address resolution + * will not be disabled if it is followed by le_create_conn + */ + bool rpa_le_conn = true; + /* Let's make sure that le is enabled.*/ if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { if (lmp_le_capable(hdev)) @@ -1103,7 +1108,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, * state. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, rpa_le_conn); hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED); } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 6388fb55b4d2..628831b15c0a 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5228,6 +5228,10 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->interval), le16_to_cpu(ev->latency), le16_to_cpu(ev->supervision_timeout)); + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + hci_req_disable_address_resolution(hdev); } static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index e48f0945a417..70e077cc7dfa 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -428,7 +428,7 @@ static void __hci_update_background_scan(struct hci_request *req) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) return; - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); BT_DBG("%s stopping background scanning", hdev->name); } else { @@ -447,7 +447,7 @@ static void __hci_update_background_scan(struct hci_request *req) * don't miss any advertising (due to duplicates filter). */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); hci_req_add_le_passive_scan(req); @@ -652,7 +652,7 @@ void __hci_req_update_eir(struct hci_request *req) hci_req_add(req, HCI_OP_WRITE_EIR, sizeof(cp), &cp); } -void hci_req_add_le_scan_disable(struct hci_request *req) +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) { struct hci_dev *hdev = req->hdev; @@ -676,8 +676,9 @@ void hci_req_add_le_scan_disable(struct hci_request *req) hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + /* Disable address resolution */ if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { __u8 enable = 0x00; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } @@ -1072,7 +1073,7 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) { /* Before changing params disable scan if enabled */ if (hci_dev_test_flag(req->hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ hci_req_add_le_passive_scan(req); @@ -1140,7 +1141,7 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) /* Disable LE passive scan if enabled */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); @@ -1696,6 +1697,28 @@ int hci_req_update_adv_data(struct hci_dev *hdev, u8 instance) return hci_req_run(&req, NULL); } +static void enable_addr_resolution_complete(struct hci_dev *hdev, u8 status, + u16 opcode) +{ + BT_DBG("%s status %u", hdev->name, status); +} + +void hci_req_disable_address_resolution(struct hci_dev *hdev) +{ + struct hci_request req; + __u8 enable = 0x00; + + if (!use_ll_privacy(hdev) && + !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + return; + + hci_req_init(&req, hdev); + + hci_req_add(&req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + + hci_req_run(&req, enable_addr_resolution_complete); +} + static void adv_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode) { BT_DBG("%s status %u", hdev->name, status); @@ -2667,7 +2690,7 @@ static void bg_scan_update(struct work_struct *work) static int le_scan_disable(struct hci_request *req, unsigned long opt) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); return 0; } @@ -2770,7 +2793,7 @@ static int le_scan_restart(struct hci_request *req, unsigned long opt) return 0; } - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); if (use_ext_scan(hdev)) { struct hci_cp_le_set_ext_scan_enable ext_enable_cp; @@ -2861,7 +2884,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) * discovery scanning parameters. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable @@ -2976,14 +2999,14 @@ bool hci_req_stop_discovery(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { cancel_delayed_work(&hdev->le_scan_disable); - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); } ret = true; } else { /* Passive scanning */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); ret = true; } } diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index bbe892ab078a..6a12e84c66c4 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -65,11 +65,12 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable); void __hci_req_update_name(struct hci_request *req); void __hci_req_update_eir(struct hci_request *req); -void hci_req_add_le_scan_disable(struct hci_request *req); +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn); void hci_req_add_le_passive_scan(struct hci_request *req); void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next); +void hci_req_disable_address_resolution(struct hci_dev *hdev); void hci_req_reenable_advertising(struct hci_dev *hdev); void __hci_req_enable_advertising(struct hci_request *req); void __hci_req_disable_advertising(struct hci_request *req); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index f45105d2de77..47bcfe2fb14c 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -5226,7 +5226,7 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev, hci_req_init(&req, hdev); - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); hci_req_add_le_passive_scan(&req); hci_req_run(&req, NULL); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sKSSMaGPIl8GDgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:15:13 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id CPUnMKGPIl8sUAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:15:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0A5D641D2D; Thu, 30 Jul 2020 11:15:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729313AbgG3JOc (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:14:32 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:39750 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729231AbgG3JOb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:14:31 -0400 Received: from localhost.localdomain (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 1E670CECF9 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 11:24:29 +0200 (CEST) From: Marcel Holtmann <marcel@holtmann.org> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 8/8] Bluetooth: Enable controller RPA resolution using Experimental feature Date: Thu, 30 Jul 2020 11:14:21 +0200 Message-Id: <20200730091421.48847-8-marcel@holtmann.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0A5D641D2D X-Rspamd-UID: 8551ed From: Sathish Narasimman <nsathish41@gmail.com> This patch adds support to enable the use of RPA Address resolution using expermental feature mgmt command. Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_event.c | 1 + net/bluetooth/hci_request.c | 7 +- net/bluetooth/mgmt.c | 142 +++++++++++++++++++++++++++++++++++- 4 files changed, 148 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index dd82cce77a7a..c8e67042a3b1 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -318,6 +318,7 @@ enum { HCI_FORCE_BREDR_SMP, HCI_FORCE_STATIC_ADDR, HCI_LL_RPA_RESOLUTION, + HCI_ENABLE_LL_PRIVACY, HCI_CMD_PENDING, HCI_FORCE_NO_MITM, diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 628831b15c0a..33d8458fdd4a 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5230,6 +5230,7 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->supervision_timeout)); if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) hci_req_disable_address_resolution(hdev); } diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 70e077cc7dfa..435400a43a78 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -678,8 +678,10 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) /* Disable address resolution */ if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { __u8 enable = 0x00; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } } @@ -870,8 +872,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } - if (use_ll_privacy(hdev) && addr_resolv) { + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && + addr_resolv) { u8 enable = 0x01; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 47bcfe2fb14c..4ec0fee80344 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -795,10 +795,15 @@ static u32 get_supported_settings(struct hci_dev *hdev) if (lmp_le_capable(hdev)) { settings |= MGMT_SETTING_LE; - settings |= MGMT_SETTING_ADVERTISING; settings |= MGMT_SETTING_SECURE_CONN; settings |= MGMT_SETTING_PRIVACY; settings |= MGMT_SETTING_STATIC_ADDRESS; + + /* When the experimental feature for LL Privacy support is + * enabled, then advertising is no longer supported. + */ + if (!hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) + settings |= MGMT_SETTING_ADVERTISING; } if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) || @@ -3759,10 +3764,16 @@ static const u8 simult_central_periph_uuid[16] = { 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, }; +/* 15c0a148-c273-11ea-b3de-0242ac130004 */ +static const u8 rpa_resolution_uuid[16] = { + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, +}; + static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { - char buf[44]; + char buf[62]; /* Enough space for 3 features */ struct mgmt_rp_read_exp_features_info *rp = (void *)buf; u16 idx = 0; u32 flags; @@ -3795,6 +3806,17 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, idx++; } + if (hdev && use_ll_privacy(hdev)) { + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) + flags = BIT(0) | BIT(1); + else + flags = BIT(1); + + memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); + rp->features[idx].flags = cpu_to_le32(flags); + idx++; + } + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable @@ -3807,6 +3829,21 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, 0, rp, sizeof(*rp) + (20 * idx)); } +static int exp_ll_privacy_feature_changed(bool enabled, struct hci_dev *hdev, + struct sock *skip) +{ + struct mgmt_ev_exp_feature_changed ev; + + memset(&ev, 0, sizeof(ev)); + memcpy(ev.uuid, rpa_resolution_uuid, 16); + ev.flags = cpu_to_le32((enabled ? BIT(0) : 0) | BIT(1)); + + return mgmt_limited_event(MGMT_EV_EXP_FEATURE_CHANGED, hdev, + &ev, sizeof(ev), + HCI_MGMT_EXP_FEATURE_EVENTS, skip); + +} + #ifdef CONFIG_BT_FEATURE_DEBUG static int exp_debug_feature_changed(bool enabled, struct sock *skip) { @@ -3845,6 +3882,16 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, } #endif + if (hdev && use_ll_privacy(hdev) && !hdev_is_powered(hdev)) { + bool changed = hci_dev_test_flag(hdev, + HCI_ENABLE_LL_PRIVACY); + + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); + + if (changed) + exp_ll_privacy_feature_changed(false, hdev, sk); + } + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); return mgmt_cmd_complete(sk, hdev ? hdev->id : MGMT_INDEX_NONE, @@ -3895,6 +3942,69 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, } #endif + if (!memcmp(cp->uuid, rpa_resolution_uuid, 16)) { + bool val, changed; + int err; + u32 flags; + + /* Command requires to use the controller index */ + if (!hdev) + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_INDEX); + + /* Changes can only be made when controller is powered down */ + if (hdev_is_powered(hdev)) + return mgmt_cmd_status(sk, hdev->id, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_NOT_POWERED); + + /* Parameters are limited to a single octet */ + if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) + return mgmt_cmd_status(sk, hdev->id, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + /* Only boolean on/off is supported */ + if (cp->param[0] != 0x00 && cp->param[0] != 0x01) + return mgmt_cmd_status(sk, hdev->id, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + val = !!cp->param[0]; + + if (val) { + changed = !hci_dev_test_flag(hdev, + HCI_ENABLE_LL_PRIVACY); + hci_dev_set_flag(hdev, HCI_ENABLE_LL_PRIVACY); + hci_dev_clear_flag(hdev, HCI_ADVERTISING); + + /* Enable LL privacy + supported settings changed */ + flags = BIT(0) | BIT(1); + } else { + changed = hci_dev_test_flag(hdev, + HCI_ENABLE_LL_PRIVACY); + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); + + /* Disable LL privacy + supported settings changed */ + flags = BIT(1); + } + + memcpy(rp.uuid, rpa_resolution_uuid, 16); + rp.flags = cpu_to_le32(flags); + + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); + + err = mgmt_cmd_complete(sk, hdev->id, + MGMT_OP_SET_EXP_FEATURE, 0, + &rp, sizeof(rp)); + + if (changed) + exp_ll_privacy_feature_changed(val, hdev, sk); + + return err; + } + return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, MGMT_OP_SET_EXP_FEATURE, MGMT_STATUS_NOT_SUPPORTED); @@ -5040,6 +5150,13 @@ static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, status); + /* Enabling the experimental LL Privay support disables support for + * advertising. + */ + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, + MGMT_STATUS_NOT_SUPPORTED); + if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02) return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, MGMT_STATUS_INVALID_PARAMS); @@ -7112,6 +7229,13 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_READ_ADV_FEATURES, MGMT_STATUS_REJECTED); + /* Enabling the experimental LL Privay support disables support for + * advertising. + */ + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, + MGMT_STATUS_NOT_SUPPORTED); + hci_dev_lock(hdev); rp_len = sizeof(*rp) + hdev->adv_instance_cnt; @@ -7315,6 +7439,13 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, status); + /* Enabling the experimental LL Privay support disables support for + * advertising. + */ + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, + MGMT_STATUS_NOT_SUPPORTED); + if (cp->instance < 1 || cp->instance > HCI_MAX_ADV_INSTANCES) return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, MGMT_STATUS_INVALID_PARAMS); @@ -7479,6 +7610,13 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev, bt_dev_dbg(hdev, "sock %p", sk); + /* Enabling the experimental LL Privay support disables support for + * advertising. + */ + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, + MGMT_STATUS_NOT_SUPPORTED); + hci_dev_lock(hdev); if (cp->instance && !hci_find_adv_instance(hdev, cp->instance)) { -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aNH3ALGRIl+3KgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:24:01 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id KLw6O7CRIl83HgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:24:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 214C641870; Thu, 30 Jul 2020 11:23:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728902AbgG3JXy (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:23:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726774AbgG3JXx (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:23:53 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1659C061794 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 02:23:52 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id l17so27514898iok.7 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 02:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=z7iOKki394HYHSjYxJseFmBbtv9pKfq6xXxqX0cqic8=; b=akssUkca0WT2jsr6JpHNQShrEGfViRLM8iWxgfI+Hi5aMnjiuyfeuhwMRXNucqLj/O F6PigCnaQhsn2a84MDw52Q5IQxIKnVC3CcRdH65LdBWyjXxE3FjMdJh2Hv0P0IRNgPNT OPOupXMbhj4szn8xC4ArXKguWNb2f+CRT5FfnKcVTXj3mEUzRKtflEWqulr2UQHhZQk2 dk3EX4pg6mv8v0JzD4L+9dbM5OVIiY7hJyyFl9Kr5kYXhi4hs3+B9cVp8Dgn4GofYi5F bGeCGlByKvilJ3CGS9hCNaoJ0xlqrhtAjNzCtUlj0utgPdpcKhItFpaimg+aScZzW9oj m2fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z7iOKki394HYHSjYxJseFmBbtv9pKfq6xXxqX0cqic8=; b=tr+Rh/8sgNkBCS61rnWOiclw0nAEfBIL/t0H0R6Ow249C8e7j4VoM/gVnXkQ9viJ+F 8yd5vMirAsyw3p6IqfG1s8uNmrRbWpwMPEqDkKq+Z7wyrSXxyOzrJNBRimrfMJwNC3jS E9iqg9hfcrpD9/Bg6ch+jxEl+b+f22X1j5Jztr6ttci7iFWHBJ0Kkpotae2PZRbLilMb m6CnvdQycNU7wksUR2/AwPtngbn3t71nZ9WvyE8J0cw9aTXxoA9H4t/0KrrIz3e9uJQq E5ljGCN9Rlla41TPJ6VmacjBY7Q6Ic7oP8M+fYgSYgF/lYnGYZknqsNnGO8kxOn1sUb/ YGTA== X-Gm-Message-State: AOAM5317Qb9KWd+EGEQSpOUSrH0HxSKboc7l9csWuBWCfazHe13/1H54 PEkflS73H+b9lon22MZ0M6eMH5fiHXLoJweZcMYU1yF2 X-Google-Smtp-Source: ABdhPJwasN/rddnoVn1WVrIHtIgL2NEBGusiXF2Kc4gVxtZhSPaStuo1g0uTT+iPdEW/gl41a7bm3yXx8TnhWc6eAVQ= X-Received: by 2002:a5e:9247:: with SMTP id z7mr28958242iop.1.1596101031923; Thu, 30 Jul 2020 02:23:51 -0700 (PDT) MIME-Version: 1.0 References: <20200730091421.48847-8-marcel@holtmann.org> In-Reply-To: <20200730091421.48847-8-marcel@holtmann.org> From: Sathish Narasimman <nsathish41@gmail.com> Date: Thu, 30 Jul 2020 14:53:40 +0530 Message-ID: <CAOVXEJ+hz7j9MnYU1hWrvM5itg_xumjWgyYTTYOQazEG9Y17gQ@mail.gmail.com> Subject: Re: [PATCH 8/8] Bluetooth: Enable controller RPA resolution using Experimental feature To: Marcel Holtmann <marcel@holtmann.org> Cc: Bluez mailing list <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -6.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: 214C641870 X-Rspamd-UID: 932c13 Hi Marcel I am ok with your changes. Including all the patches On Thu, Jul 30, 2020 at 2:48 PM Marcel Holtmann <marcel@holtmann.org> wrote: > > From: Sathish Narasimman <nsathish41@gmail.com> > > This patch adds support to enable the use of RPA Address resolution > using expermental feature mgmt command. > > Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com> > Signed-off-by: Marcel Holtmann <marcel@holtmann.org> > --- > include/net/bluetooth/hci.h | 1 + > net/bluetooth/hci_event.c | 1 + > net/bluetooth/hci_request.c | 7 +- > net/bluetooth/mgmt.c | 142 +++++++++++++++++++++++++++++++++++- > 4 files changed, 148 insertions(+), 3 deletions(-) > > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h > index dd82cce77a7a..c8e67042a3b1 100644 > --- a/include/net/bluetooth/hci.h > +++ b/include/net/bluetooth/hci.h > @@ -318,6 +318,7 @@ enum { > HCI_FORCE_BREDR_SMP, > HCI_FORCE_STATIC_ADDR, > HCI_LL_RPA_RESOLUTION, > + HCI_ENABLE_LL_PRIVACY, > HCI_CMD_PENDING, > HCI_FORCE_NO_MITM, > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 628831b15c0a..33d8458fdd4a 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -5230,6 +5230,7 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, > le16_to_cpu(ev->supervision_timeout)); > > if (use_ll_privacy(hdev) && > + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && > hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) > hci_req_disable_address_resolution(hdev); > } > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > index 70e077cc7dfa..435400a43a78 100644 > --- a/net/bluetooth/hci_request.c > +++ b/net/bluetooth/hci_request.c > @@ -678,8 +678,10 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) > > /* Disable address resolution */ > if (use_ll_privacy(hdev) && > + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && > hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { > __u8 enable = 0x00; > + > hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); > } > } > @@ -870,8 +872,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, > return; > } > > - if (use_ll_privacy(hdev) && addr_resolv) { > + if (use_ll_privacy(hdev) && > + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) && > + addr_resolv) { > u8 enable = 0x01; > + > hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); > } > > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > index 47bcfe2fb14c..4ec0fee80344 100644 > --- a/net/bluetooth/mgmt.c > +++ b/net/bluetooth/mgmt.c > @@ -795,10 +795,15 @@ static u32 get_supported_settings(struct hci_dev *hdev) > > if (lmp_le_capable(hdev)) { > settings |= MGMT_SETTING_LE; > - settings |= MGMT_SETTING_ADVERTISING; > settings |= MGMT_SETTING_SECURE_CONN; > settings |= MGMT_SETTING_PRIVACY; > settings |= MGMT_SETTING_STATIC_ADDRESS; > + > + /* When the experimental feature for LL Privacy support is > + * enabled, then advertising is no longer supported. > + */ > + if (!hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) > + settings |= MGMT_SETTING_ADVERTISING; > } > > if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) || > @@ -3759,10 +3764,16 @@ static const u8 simult_central_periph_uuid[16] = { > 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > }; > > +/* 15c0a148-c273-11ea-b3de-0242ac130004 */ > +static const u8 rpa_resolution_uuid[16] = { > + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, > + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, > +}; > + > static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > void *data, u16 data_len) > { > - char buf[44]; > + char buf[62]; /* Enough space for 3 features */ > struct mgmt_rp_read_exp_features_info *rp = (void *)buf; > u16 idx = 0; > u32 flags; > @@ -3795,6 +3806,17 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > idx++; > } > > + if (hdev && use_ll_privacy(hdev)) { > + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) > + flags = BIT(0) | BIT(1); > + else > + flags = BIT(1); > + > + memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); > + rp->features[idx].flags = cpu_to_le32(flags); > + idx++; > + } > + > rp->feature_count = cpu_to_le16(idx); > > /* After reading the experimental features information, enable > @@ -3807,6 +3829,21 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > 0, rp, sizeof(*rp) + (20 * idx)); > } > > +static int exp_ll_privacy_feature_changed(bool enabled, struct hci_dev *hdev, > + struct sock *skip) > +{ > + struct mgmt_ev_exp_feature_changed ev; > + > + memset(&ev, 0, sizeof(ev)); > + memcpy(ev.uuid, rpa_resolution_uuid, 16); > + ev.flags = cpu_to_le32((enabled ? BIT(0) : 0) | BIT(1)); > + > + return mgmt_limited_event(MGMT_EV_EXP_FEATURE_CHANGED, hdev, > + &ev, sizeof(ev), > + HCI_MGMT_EXP_FEATURE_EVENTS, skip); > + > +} > + > #ifdef CONFIG_BT_FEATURE_DEBUG > static int exp_debug_feature_changed(bool enabled, struct sock *skip) > { > @@ -3845,6 +3882,16 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + if (hdev && use_ll_privacy(hdev) && !hdev_is_powered(hdev)) { > + bool changed = hci_dev_test_flag(hdev, > + HCI_ENABLE_LL_PRIVACY); > + > + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); > + > + if (changed) > + exp_ll_privacy_feature_changed(false, hdev, sk); > + } > + > hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); > > return mgmt_cmd_complete(sk, hdev ? hdev->id : MGMT_INDEX_NONE, > @@ -3895,6 +3942,69 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + if (!memcmp(cp->uuid, rpa_resolution_uuid, 16)) { > + bool val, changed; > + int err; > + u32 flags; > + > + /* Command requires to use the controller index */ > + if (!hdev) > + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, > + MGMT_OP_SET_EXP_FEATURE, > + MGMT_STATUS_INVALID_INDEX); > + > + /* Changes can only be made when controller is powered down */ > + if (hdev_is_powered(hdev)) > + return mgmt_cmd_status(sk, hdev->id, > + MGMT_OP_SET_EXP_FEATURE, > + MGMT_STATUS_NOT_POWERED); > + > + /* Parameters are limited to a single octet */ > + if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) > + return mgmt_cmd_status(sk, hdev->id, > + MGMT_OP_SET_EXP_FEATURE, > + MGMT_STATUS_INVALID_PARAMS); > + > + /* Only boolean on/off is supported */ > + if (cp->param[0] != 0x00 && cp->param[0] != 0x01) > + return mgmt_cmd_status(sk, hdev->id, > + MGMT_OP_SET_EXP_FEATURE, > + MGMT_STATUS_INVALID_PARAMS); > + > + val = !!cp->param[0]; > + > + if (val) { > + changed = !hci_dev_test_flag(hdev, > + HCI_ENABLE_LL_PRIVACY); > + hci_dev_set_flag(hdev, HCI_ENABLE_LL_PRIVACY); > + hci_dev_clear_flag(hdev, HCI_ADVERTISING); > + > + /* Enable LL privacy + supported settings changed */ > + flags = BIT(0) | BIT(1); > + } else { > + changed = hci_dev_test_flag(hdev, > + HCI_ENABLE_LL_PRIVACY); > + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); > + > + /* Disable LL privacy + supported settings changed */ > + flags = BIT(1); > + } > + > + memcpy(rp.uuid, rpa_resolution_uuid, 16); > + rp.flags = cpu_to_le32(flags); > + > + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); > + > + err = mgmt_cmd_complete(sk, hdev->id, > + MGMT_OP_SET_EXP_FEATURE, 0, > + &rp, sizeof(rp)); > + > + if (changed) > + exp_ll_privacy_feature_changed(val, hdev, sk); > + > + return err; > + } > + > return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, > MGMT_OP_SET_EXP_FEATURE, > MGMT_STATUS_NOT_SUPPORTED); > @@ -5040,6 +5150,13 @@ static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data, > return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, > status); > > + /* Enabling the experimental LL Privay support disables support for > + * advertising. > + */ > + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) > + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, > + MGMT_STATUS_NOT_SUPPORTED); > + > if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02) > return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, > MGMT_STATUS_INVALID_PARAMS); > @@ -7112,6 +7229,13 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev, > return mgmt_cmd_status(sk, hdev->id, MGMT_OP_READ_ADV_FEATURES, > MGMT_STATUS_REJECTED); > > + /* Enabling the experimental LL Privay support disables support for > + * advertising. > + */ > + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) > + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, > + MGMT_STATUS_NOT_SUPPORTED); > + > hci_dev_lock(hdev); > > rp_len = sizeof(*rp) + hdev->adv_instance_cnt; > @@ -7315,6 +7439,13 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, > return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, > status); > > + /* Enabling the experimental LL Privay support disables support for > + * advertising. > + */ > + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) > + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, > + MGMT_STATUS_NOT_SUPPORTED); > + > if (cp->instance < 1 || cp->instance > HCI_MAX_ADV_INSTANCES) > return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, > MGMT_STATUS_INVALID_PARAMS); > @@ -7479,6 +7610,13 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev, > > bt_dev_dbg(hdev, "sock %p", sk); > > + /* Enabling the experimental LL Privay support disables support for > + * advertising. > + */ > + if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) > + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, > + MGMT_STATUS_NOT_SUPPORTED); > + > hci_dev_lock(hdev); > > if (cp->instance && !hci_find_adv_instance(hdev, cp->instance)) { > -- > 2.26.2 > Regards Sathish N Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2KWfFAqYIl+tSQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:51:06 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id UBJnEwqYIl/rNgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:51:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3E4B641750; Thu, 30 Jul 2020 11:51:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726925AbgG3Ju6 convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:50:58 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:44788 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726868AbgG3Ju5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:50:57 -0400 Received: from mail-pj1-f69.google.com ([209.85.216.69]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from <kai.heng.feng@canonical.com>) id 1k15DC-0001oX-EB for linux-bluetooth@vger.kernel.org; Thu, 30 Jul 2020 09:50:54 +0000 Received: by mail-pj1-f69.google.com with SMTP id cp23so1883458pjb.9 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 02:50:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=z6azR+BaptW7sOFFycRZIdapi2fWCVCt97iunL8FEoU=; b=ZhS/UExQYhyFCNYFdrp+o5ry0jFAADi2Q92GpmTimUbqkDGASrY/dx+vCeuujy21jn cOx7mzxO+yFprqseq+kHwUMiGZwxRUIhP+ZfHWVSFbx06krhELjfbNVQXLK9B9211fGZ jxVx+zwnipqmXtCk4OBoWtEzRlUQxAReHIGpdKFeghVHBgG6nGYgfpMfFKdvN7Ht5HNK KJ59oq9kGHG5jYH8xhPObJnN8P9wHmaxdY3tRwGe3eY7dOua1uaEu/S7Ytz8EsC/CtbH sacn1M1y5kxftlLhNAC4LK+hXZU6YOd5sRWf4PirQei2nQmhiF9627/0JvyiDjQ0IrFG aVjg== X-Gm-Message-State: AOAM5328+yA/IyB9cR4N5StMLbZ4CH2a0r6yXjd8AYiy/Gur+GkbkP62 RqzcUnIhZJ4esrWt82DHIRYvn7JYx9D7nfqOIx/S9evvz0Mf9SqC2TgLHqpk/e3Ztx4Ui3s3mL5 PDxnZIrNYadbxI7jLOdimlxN790kIUGzD4+jBjONHTeDAaA== X-Received: by 2002:a63:6dc1:: with SMTP id i184mr33887098pgc.345.1596102653022; Thu, 30 Jul 2020 02:50:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKPYOcNGUX0wVpj3tYWG+1sKAG3lC10wGIaPj/zNketX0viNGp0xJCXBhZ48tuwR0IqtKHtg== X-Received: by 2002:a63:6dc1:: with SMTP id i184mr33887060pgc.345.1596102652602; Thu, 30 Jul 2020 02:50:52 -0700 (PDT) Received: from [192.168.1.208] (220-133-187-190.HINET-IP.hinet.net. [220.133.187.190]) by smtp.gmail.com with ESMTPSA id q17sm5410652pfh.32.2020.07.30.02.50.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jul 2020 02:50:52 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Revert "Bluetooth: btusb: Disable runtime suspend on Realtek devices" From: Kai-Heng Feng <kai.heng.feng@canonical.com> In-Reply-To: <E52C04D8-67C6-4949-B988-A61F6FCD1434@holtmann.org> Date: Thu, 30 Jul 2020 17:50:48 +0800 Cc: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, chromeos-bluetooth-upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alex Lu <alex_lu@realsil.com.cn>, linux-pm@vger.kernel.org, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <8FE329BB-706A-4D16-950C-A7571FE0B40A@canonical.com> References: <20200729161740.1.Ib03d0827c8e48fc3df887fec698f79fa335c9274@changeid> <8DFB5D1A-AA7E-4960-9937-4FD00827937B@canonical.com> <E52C04D8-67C6-4949-B988-A61F6FCD1434@holtmann.org> To: Marcel Holtmann <marcel@holtmann.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3E4B641750 X-Rspamd-UID: 797e44 > On Jul 30, 2020, at 15:30, Marcel Holtmann <marcel@holtmann.org> wrote: > > Hi Kai-Heng, > >>> On Jul 30, 2020, at 07:17, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: >>> >>> This reverts commit 7ecacafc240638148567742cca41aa7144b4fe1e. >>> >>> Testing this change on a board with RTL8822CE, I found that enabling >>> autosuspend has no effect on the stability of the system. The board >>> continued working after autosuspend, suspend and reboot. >> >> The original issue was found on 8723DE. Do you have one to test with? >> The rtw88 codebase has changed a lot and maybe it's already fixed in mainline. >> Let me do some test and I'll report back. >> >>> >>> The original commit makes it impossible to enable autosuspend on working >>> systems so it should be reverted. Disabling autosuspend should be done >>> via module param or udev in userspace instead. >>> >>> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> >>> --- >>> We have a few Chromebooks using the RTL 8822CE part over USB and they >>> are running without problems with autosuspend enabled. While bringing up >>> a new board, I found some power regressions that I was able to narrow >>> down to this change so I'm requesting a revert. >>> >>> I tested this on Hp Chromebook 14a (running 4.14 kernel and 5.4 kernel) >>> with this revert: >>> * Enabled autosuspend, used it normally with a HID device >>> * Suspended the Chromebook and verified it worked normally on resume >>> * Rebooted the Chromebook and verified Bluetooth was working on next >>> boot >>> >>> I didn't see the issue that was originally reported with this fix. For >>> the original reporter, if you're still seeing this issue, there are >>> other ways to disable autosuspend for your device: >>> * set module param: enable_autosuspend=0 >>> * change your kconfig so BT_HCIBTUSB_AUTOSUSPEND=n >>> * use a udev rule to disable autosuspend for specific vid:pid >>> >>> Keeping this change in the kernel makes it impossible to enable >>> autosuspend so it should be reverted. >> >> It's apparently a driver/firmware/hardware issue, so the fix should keep inside the kernel. >> However, the fix can be more precise and target only 8723DE. > > lets do that and lets do it quickly since the merge window is close. Otherwise I really have to revert that patch. Ok, I no longer observe the original issue with the patch reverted. Acked-by: Kai-Heng Feng <kai.heng.feng@canonical.com> > > Regards > > Marcel > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SBQqBjaZIl8YVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:56:06 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gOXbBDaZIl9v4AEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:56:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 65A4641432; Thu, 30 Jul 2020 11:56:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729483AbgG3Jzy (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:55:54 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:35882 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726790AbgG3Jzy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:55:54 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 6647FCECF2; Thu, 30 Jul 2020 12:05:53 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Revert "Bluetooth: btusb: Disable runtime suspend on Realtek devices" From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200729161740.1.Ib03d0827c8e48fc3df887fec698f79fa335c9274@changeid> Date: Thu, 30 Jul 2020 11:55:51 +0200 Cc: chromeos-bluetooth-upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Kai-Heng Feng <kai.heng.feng@canonical.com>, Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alex Lu <alex_lu@realsil.com.cn>, linux-pm@vger.kernel.org, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <C006448A-9FE3-4F83-AB67-68973709C0C2@holtmann.org> References: <20200729161740.1.Ib03d0827c8e48fc3df887fec698f79fa335c9274@changeid> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 7 X-Rspamd-Score: 1.10 / 15.00 / 200.00 X-Rspamd-Queue-Id: 65A4641432 X-Rspamd-UID: 988e7e Hi Abhishek, > This reverts commit 7ecacafc240638148567742cca41aa7144b4fe1e. > > Testing this change on a board with RTL8822CE, I found that enabling > autosuspend has no effect on the stability of the system. The board > continued working after autosuspend, suspend and reboot. > > The original commit makes it impossible to enable autosuspend on working > systems so it should be reverted. Disabling autosuspend should be done > via module param or udev in userspace instead. > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > We have a few Chromebooks using the RTL 8822CE part over USB and they > are running without problems with autosuspend enabled. While bringing up > a new board, I found some power regressions that I was able to narrow > down to this change so I'm requesting a revert. > > I tested this on Hp Chromebook 14a (running 4.14 kernel and 5.4 kernel) > with this revert: > * Enabled autosuspend, used it normally with a HID device > * Suspended the Chromebook and verified it worked normally on resume > * Rebooted the Chromebook and verified Bluetooth was working on next > boot > > I didn't see the issue that was originally reported with this fix. For > the original reporter, if you're still seeing this issue, there are > other ways to disable autosuspend for your device: > * set module param: enable_autosuspend=0 > * change your kconfig so BT_HCIBTUSB_AUTOSUSPEND=n > * use a udev rule to disable autosuspend for specific vid:pid > > Keeping this change in the kernel makes it impossible to enable > autosuspend so it should be reverted. > > drivers/bluetooth/btusb.c | 4 ---- > 1 file changed, 4 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ICMKA1+ZIl+tSQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 11:56:47 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id AFa8AV+ZIl+XnwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 11:56:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DB41DA1CB4; Thu, 30 Jul 2020 11:56:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728693AbgG3J4h (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 05:56:37 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:57345 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726946AbgG3J4h (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 05:56:37 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 31140CECF2; Thu, 30 Jul 2020 12:06:38 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 8/8] Bluetooth: Enable controller RPA resolution using Experimental feature From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <CAOVXEJ+hz7j9MnYU1hWrvM5itg_xumjWgyYTTYOQazEG9Y17gQ@mail.gmail.com> Date: Thu, 30 Jul 2020 11:56:36 +0200 Cc: Bluez mailing list <linux-bluetooth@vger.kernel.org> Content-Transfer-Encoding: 7bit Message-Id: <E88DC211-F19B-4E67-B706-DD9DF0DFCFBD@holtmann.org> References: <20200730091421.48847-8-marcel@holtmann.org> <CAOVXEJ+hz7j9MnYU1hWrvM5itg_xumjWgyYTTYOQazEG9Y17gQ@mail.gmail.com> To: Sathish Narasimman <nsathish41@gmail.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.03 / 15.00 / 200.00 X-Rspamd-Queue-Id: DB41DA1CB4 X-Rspamd-UID: 19cf60 Hi Satish, > I am ok with your changes. > Including all the patches ok, all 8 patches have been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +B8tH0AGI1/fQAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 19:41:20 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6ItfHUAGI1/njQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 19:41:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D299941432; Thu, 30 Jul 2020 19:40:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgG3RkS (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 13:40:18 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:51233 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726275AbgG3RkR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 13:40:17 -0400 Received: from localhost.localdomain (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 597B9CECFC for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 19:50:17 +0200 (CEST) From: Marcel Holtmann <marcel@holtmann.org> To: linux-bluetooth@vger.kernel.org Subject: [PATCH] Bluetooth: Increment management interface revision Date: Thu, 30 Jul 2020 19:40:11 +0200 Message-Id: <20200730174011.71784-1-marcel@holtmann.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: D299941432 X-Rspamd-UID: de60df Increment the mgmt revision due to the recently added new commands. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> --- net/bluetooth/mgmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 4ec0fee80344..5bbe71002fb9 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -40,7 +40,7 @@ #include "msft.h" #define MGMT_VERSION 1 -#define MGMT_REVISION 17 +#define MGMT_REVISION 18 static const u16 mgmt_commands[] = { MGMT_OP_READ_INDEX_LIST, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KHqyFOQvI1+WwAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 22:39:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8HzGEuQvI188KwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 22:39:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 76CCEA1AA5; Thu, 30 Jul 2020 22:38:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728565AbgG3Uiy (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 16:38:54 -0400 Received: from mga01.intel.com ([192.55.52.88]:35025 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726977AbgG3Uix (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 16:38:53 -0400 IronPort-SDR: ZLJFCJmEXNSdqti77Gkp/CBi4rNpRj6l0jzY1a3NwEi8i1pdPcvtG/z4VwqmN4+FpESPpQaxOR ESEziYAA+/dg== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="169803084" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="169803084" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 13:38:52 -0700 IronPort-SDR: Peh0QPxfNF13JYDqdHy/1Tj2qXIlWpFDkta8EL9FQNkvPoSanhIKYHCMGQJPGdpr5McemLaXQ/ FsJ11N8FrUFQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="330864943" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2020 13:38:52 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 00/10] Clean up Config Server Date: Thu, 30 Jul 2020 13:38:41 -0700 Message-Id: <20200730203851.32043-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 18 X-Rspamd-Score: 2.79 / 15.00 / 200.00 X-Rspamd-Queue-Id: 76CCEA1AA5 X-Rspamd-UID: c4ba51 This patch set cleans up implementation of config server. Specifically, all the response status messages are sent from a single point. Along the way, some behavioral inconsistencies are fixed like ignoring more malformed messages, returning correct error status codes. Inga Stotland (10): mesh: Clean up handling of config subscription messages mesh: Clean up handling of config model binding messages mesh: Clean up handling of config node identity message mesh: Clean up handling of config publication messages mesh: Clean up handling of config net and app key messages mesh: Clean up handling of config relay messages mesh: Clean up handling of config poll timeout message mesh: Clean up handling of config net transmit messages mesh: Clean up handling of config KR phase messages mesh: Refactor heartbeat pub/sub mesh/cfgmod-server.c | 1149 ++++++++++++++++----------------------- mesh/cfgmod.h | 2 +- mesh/mesh-config-json.c | 12 +- mesh/mesh-config.h | 6 +- mesh/model.c | 227 ++++---- mesh/model.h | 21 +- mesh/net.c | 273 +++++++--- mesh/net.h | 48 +- 8 files changed, 851 insertions(+), 887 deletions(-) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wJPeGOovI18ttwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 22:39:06 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EOMnF+ovI1++0QAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 22:39:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 70AE1A1C74; Thu, 30 Jul 2020 22:39:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728800AbgG3Ui7 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 16:38:59 -0400 Received: from mga01.intel.com ([192.55.52.88]:35035 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728586AbgG3Ui6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 16:38:58 -0400 IronPort-SDR: BEs/t8hxZHPtsgA1tPXuwgb3tsG00AdkfroC+blSYwdMYFwYQ6QtS3Oi09sge78Sf8+1xFPgLt tLPxndyCgMMg== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="169803098" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="169803098" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 13:38:57 -0700 IronPort-SDR: r/xF+Ufcky/+dtRbGi6YWSvVRC+tIn1NIfwzPDbas0aMofR52nzzOtieHUB7pA7lIAYqqvewwz lwDRsBqFLmVg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="330864954" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2020 13:38:56 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 02/10] mesh: Clean up handling of config model binding messages Date: Thu, 30 Jul 2020 13:38:43 -0700 Message-Id: <20200730203851.32043-3-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200730203851.32043-1-inga.stotland@intel.com> References: <20200730203851.32043-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 70AE1A1C74 X-Rspamd-UID: b7a8cf This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 128 +++++++++++-------------------------------- mesh/model.c | 16 +----- 2 files changed, 35 insertions(+), 109 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 73cf66ffd..6621d0935 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -112,8 +112,7 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; const uint8_t *pub_addr; uint16_t test_addr; - uint8_t ttl, period; - uint8_t retransmit; + uint8_t ttl, period, retransmit; int status; bool cred_flag; @@ -363,115 +362,52 @@ static uint16_t config_sub_del_all(struct mesh_node *node, const uint8_t *pkt, return n; } -static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t addr, - uint32_t id, uint16_t idx) -{ - size_t n = mesh_model_opcode_set(OP_MODEL_APP_STATUS, msg); - - msg[n++] = status; - l_put_le16(addr, msg + n); - n += 2; - l_put_le16(idx, msg + n); - n += 2; - - if (IS_VENDOR(id)) { - l_put_le16(VENDOR_ID(id), msg + n); - n += 2; - } - - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); -} - -static void model_app_list(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, +static uint16_t model_app_list(struct mesh_node *node, const uint8_t *pkt, uint16_t size) { - uint16_t ele_addr; + uint16_t ele_addr, n, bnd_len; uint32_t id; - uint8_t *status; - uint16_t n; - int result; + int opcode; + opcode = (size == 4) ? OP_MODEL_APP_LIST : OP_VEND_MODEL_APP_LIST; ele_addr = l_get_le16(pkt); - switch (size) { - default: - return; - case 4: - n = mesh_model_opcode_set(OP_MODEL_APP_LIST, msg); - status = msg + n; - id = l_get_le16(pkt + 2); - l_put_le16(ele_addr, msg + 1 + n); - l_put_le16((uint16_t) id, msg + 3 + n); - id = SET_ID(SIG_VENDOR, id); - n += 5; - break; - case 6: - n = mesh_model_opcode_set(OP_VEND_MODEL_APP_LIST, msg); - status = msg + n; - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); + n = mesh_model_opcode_set(opcode, msg); + memcpy(msg + n + 1, pkt, size); - l_put_le16(ele_addr, msg + 1 + n); - l_put_le16((uint16_t) VENDOR_ID(id), msg + 3 + n); - l_put_le16((uint16_t) MODEL_ID(id), msg + 5 + n); - n += 7; - break; - } + id = CFG_SET_ID(size == 6, pkt + 2); - result = mesh_model_get_bindings(node, ele_addr, id, msg + n, - MAX_MSG_LEN - n, &size); - n += size; + msg[n] = mesh_model_get_bindings(node, ele_addr, id, msg + n + 1 + size, + MAX_MSG_LEN - (n + 1 + size), &bnd_len); - if (result >= 0) { - *status = result; - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, - DEFAULT_TTL, false, msg, n); - } + if (msg[n] == MESH_STATUS_SUCCESS) + n += bnd_len; + + n += (size + 1); + return n; } -static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size, - bool unbind) +static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt, + uint16_t size, bool unbind) { - uint16_t ele_addr; + uint16_t ele_addr, idx, n; uint32_t id; - uint16_t idx; - int result; - - switch (size) { - default: - return false; - - case 6: - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); - break; - case 8: - id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); - break; - } ele_addr = l_get_le16(pkt); idx = l_get_le16(pkt + 2); + id = CFG_SET_ID(size == 8, pkt + 4); - if (idx > 0xfff) - return false; + n = mesh_model_opcode_set(OP_MODEL_APP_STATUS, msg); if (unbind) - result = mesh_model_binding_del(node, ele_addr, id, idx); + msg[n] = mesh_model_binding_del(node, ele_addr, id, idx); else - result = mesh_model_binding_add(node, ele_addr, id, idx); + msg[n] = mesh_model_binding_add(node, ele_addr, id, idx); - send_model_app_status(node, net_idx, src, dst, result, ele_addr, - id, idx); + memcpy(msg + n + 1, pkt, size); + n += (size + 1); - return true; + return n; } static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) @@ -704,8 +640,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 1 || pkt[0] > TTL_MASK || pkt[0] == 1) return true; - if (pkt[0] <= TTL_MASK) - node_default_ttl_set(node, pkt[0]); + node_default_ttl_set(node, pkt[0]); /* Fall Through */ case OP_CONFIG_DEFAULT_TTL_GET: @@ -1049,22 +984,25 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_MODEL_APP_BIND: case OP_MODEL_APP_UNBIND: - model_app_bind(node, net_idx, src, dst, pkt, size, - opcode != OP_MODEL_APP_BIND); + if (size != 6 && size != 8) + return true; + + n = model_app_bind(node, pkt, size, + opcode != OP_MODEL_APP_BIND); break; case OP_VEND_MODEL_APP_GET: if (size != 6) return true; - model_app_list(node, net_idx, src, dst, pkt, size); + n = model_app_list(node, pkt, size); break; case OP_MODEL_APP_GET: if (size != 4) return true; - model_app_list(node, net_idx, src, dst, pkt, size); + n = model_app_list(node, pkt, size); break; case OP_CONFIG_HEARTBEAT_PUB_SET: diff --git a/mesh/model.c b/mesh/model.c index 3c9b6577a..e2cadfe36 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -111,13 +111,7 @@ static bool simple_match(const void *a, const void *b) static bool has_binding(struct l_queue *bindings, uint16_t idx) { - const struct l_queue_entry *l; - - for (l = l_queue_get_entries(bindings); l; l = l->next) { - if (L_PTR_TO_UINT(l->data) == idx) - return true; - } - return false; + return l_queue_find(bindings, simple_match, L_UINT_TO_PTR(idx)) != NULL; } static bool find_virt_by_label(const void *a, const void *b) @@ -628,7 +622,6 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, uint16_t app_idx, bool unbind) { struct mesh_model *mod; - bool is_present; int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) @@ -645,12 +638,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, if (!appkey_have_key(node_get_net(node), app_idx)) return MESH_STATUS_INVALID_APPKEY; - is_present = has_binding(mod->bindings, app_idx); - - if (!is_present && unbind) - return MESH_STATUS_SUCCESS; - - if (is_present && !unbind) + if (unbind ^ has_binding(mod->bindings, app_idx)) return MESH_STATUS_SUCCESS; if (unbind) { -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CDt2KPAvI1/5zAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 22:39:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id qFz8JvAvI1/0pwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 22:39:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 82AD7A2F75; Thu, 30 Jul 2020 22:39:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728824AbgG3Ui7 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 16:38:59 -0400 Received: from mga01.intel.com ([192.55.52.88]:35025 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726977AbgG3Ui5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 16:38:57 -0400 IronPort-SDR: uratPcXSXAfl3HjeyI1gmR4EC90rxL78iYMlLTpQwpJ0ZXCLgKl5oRGIPYO8WH3ZpzNuZX5DiM eEPS20hvCEnw== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="169803094" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="169803094" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 13:38:56 -0700 IronPort-SDR: 5jJPcShYKN9qzadPstf4bidMSAeJrcnJdusrBovAhkGwEwLhUIK2e4zf71SdfFwUqOpW30Qxet D6OH5pmLOzCQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="330864949" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2020 13:38:53 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 01/10] mesh: Clean up handling of config subscription messages Date: Thu, 30 Jul 2020 13:38:42 -0700 Message-Id: <20200730203851.32043-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200730203851.32043-1-inga.stotland@intel.com> References: <20200730203851.32043-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 82AD7A2F75 X-Rspamd-UID: 06ca08 This provides better functional grouping based on whether a group or a virtual label is used for the subscription address. Also, use a single point for sending out the composed Config Server status messages. --- mesh/cfgmod-server.c | 341 +++++++++++++++++----------------------- mesh/mesh-config-json.c | 12 +- mesh/mesh-config.h | 6 +- mesh/model.c | 211 ++++++++++++++----------- mesh/model.h | 21 ++- 5 files changed, 295 insertions(+), 296 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 7672ad3b6..73cf66ffd 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -32,6 +32,10 @@ #include "mesh/mesh-config.h" #include "mesh/cfgmod.h" +#define CFG_SET_ID(vendor, pkt) ((vendor) ? \ + (SET_ID(l_get_le16((pkt)), l_get_le16((pkt) + 2))) : \ + (SET_ID(SIG_VENDOR, l_get_le16(pkt)))) + /* Supported composition pages, sorted high to low */ /* Only page 0 is currently supported */ static const uint8_t supported_pages[] = { @@ -185,237 +189,178 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, idx, cred_flag, ttl, period, retransmit); } -static void send_sub_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, - uint16_t addr, uint32_t id) -{ - int n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - - msg[n++] = status; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(addr, msg + n); - n += 2; - - if (IS_VENDOR(id)) { - l_put_le16(VENDOR_ID(id), msg + n); - l_put_le16(MODEL_ID(id), msg + n + 2); - n += 4; - } else { - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - } - - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); -} - -static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, +static uint16_t cfg_sub_get_msg(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, const uint8_t *pkt, uint16_t size) { - uint16_t ele_addr; + uint16_t ele_addr, n, sub_len; uint32_t id; - uint16_t n = 0; - int status; - uint8_t *msg_status; - uint16_t buf_size; + int opcode; + bool vendor = (size == 6); - /* Incoming message has already been size-checked */ ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); + opcode = vendor ? OP_CONFIG_VEND_MODEL_SUB_LIST : + OP_CONFIG_MODEL_SUB_LIST; + n = mesh_model_opcode_set(opcode, msg); + memcpy(msg + n + 1, pkt, size); - switch (size) { - default: - l_debug("Bad length %d", size); - return false; + msg[n] = mesh_model_sub_get(node, ele_addr, id, msg + n + 1 + size, + MAX_MSG_LEN - (n + 1 + size), &sub_len); - case 4: - id = l_get_le16(pkt + 2); - n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_LIST, msg); - msg_status = msg + n; - msg[n++] = 0; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(id, msg + n); - n += 2; - id = SET_ID(SIG_VENDOR, id); - break; + if (msg[n] == MESH_STATUS_SUCCESS) + n += sub_len; - case 6: - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - n = mesh_model_opcode_set(OP_CONFIG_VEND_MODEL_SUB_LIST, msg); - msg_status = msg + n; - msg[n++] = 0; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(VENDOR_ID(id), msg + n); - n += 2; - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - break; - } - - buf_size = sizeof(uint16_t) * MAX_GRP_PER_MOD; - status = mesh_model_sub_get(node, ele_addr, id, msg + n, buf_size, - &size); - - if (status == MESH_STATUS_SUCCESS) - n += size; - - *msg_status = (uint8_t) status; - - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); - return true; + n += (size + 1); + return n; } -static bool save_config_sub(struct mesh_node *node, uint16_t ele_addr, - uint32_t id, bool vendor, - const uint8_t *addr, bool virt, - uint16_t grp, uint32_t opcode) +static bool save_cfg_sub(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, bool vendor, const uint8_t *label, + bool virt, uint16_t grp, uint32_t opcode) { + struct mesh_config *cfg = node_config_get(node); struct mesh_config_sub db_sub = { .virt = virt, - .src.addr = grp + .addr.grp = grp }; + id = (vendor) ? id : MODEL_ID(id); + if (virt) - memcpy(db_sub.src.virt_addr, addr, 16); + memcpy(db_sub.addr.label, label, 16); + + if (opcode == OP_CONFIG_MODEL_SUB_VIRT_DELETE && + opcode == OP_CONFIG_MODEL_SUB_DELETE) + return mesh_config_model_sub_del(cfg, ele_addr, id, vendor, + &db_sub); if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE || opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) - mesh_config_model_sub_del_all(node_config_get(node), ele_addr, - vendor ? id : MODEL_ID(id), - vendor); - if (opcode != OP_CONFIG_MODEL_SUB_VIRT_DELETE && - opcode != OP_CONFIG_MODEL_SUB_DELETE) - return mesh_config_model_sub_add(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_sub); - else - return mesh_config_model_sub_del(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_sub); + if (!mesh_config_model_sub_del_all(cfg, ele_addr, id, vendor)) + return false; + + return mesh_config_model_sub_add(cfg, ele_addr, id, vendor, &db_sub); } -static void config_sub_set(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size, - bool virt, uint32_t opcode) +static uint16_t cfg_sub_add_msg(struct mesh_node *node, const uint8_t *pkt, + bool vendor, uint32_t opcode) { - uint16_t grp, ele_addr; + uint16_t addr, ele_addr, n; uint32_t id; - const uint8_t *addr = NULL; - int status = MESH_STATUS_SUCCESS; - bool vendor = false; - switch (size) { - default: - l_error("Bad length: %d", size); - return; - case 4: - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) - return; + addr = l_get_le16(pkt + 2); - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); - break; - case 6: - if (virt) - return; + if (!IS_GROUP(addr)) + return 0; - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); - } else { - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - vendor = true; - } + ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 4); - break; - case 8: - if (virt) - return; + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); - vendor = true; - break; - case 20: - if (!virt) - return; + if (opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) + msg[n] = mesh_model_sub_ovrt(node, ele_addr, id, addr); + else if (opcode == OP_CONFIG_MODEL_SUB_ADD) + msg[n] = mesh_model_sub_add(node, ele_addr, id, addr); + else + msg[n] = mesh_model_sub_del(node, ele_addr, id, addr); - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 18)); - break; - case 22: - if (!virt) - return; + if (msg[n] == MESH_STATUS_SUCCESS && + !save_cfg_sub(node, ele_addr, id, vendor, NULL, false, + addr, opcode)) + msg[n] = MESH_STATUS_STORAGE_FAIL; - vendor = true; - id = SET_ID(l_get_le16(pkt + 18), l_get_le16(pkt + 20)); - break; + if (vendor) { + memcpy(msg + n + 1, pkt, 8); + n += 9; + } else { + memcpy(msg + n + 1, pkt, 6); + n += 7; } + return n; +} + +static uint16_t cfg_virt_sub_add_msg(struct mesh_node *node, const uint8_t *pkt, + bool vendor, uint32_t opcode) +{ + uint16_t addr, ele_addr, n; + uint32_t id; + const uint8_t *label; + + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); + ele_addr = l_get_le16(pkt); + label = pkt + 2; + id = CFG_SET_ID(vendor, pkt + 18); + + if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE) + msg[n] = mesh_model_virt_sub_ovrt(node, ele_addr, id, label, + &addr); + else if (opcode == OP_CONFIG_MODEL_SUB_VIRT_ADD) + msg[n] = mesh_model_virt_sub_add(node, ele_addr, id, label, + &addr); + else + msg[n] = mesh_model_virt_sub_del(node, ele_addr, id, label, + &addr); - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - addr = pkt + 2; - grp = l_get_le16(addr); - } else - grp = UNASSIGNED_ADDRESS; + if (msg[n] == MESH_STATUS_SUCCESS && + !save_cfg_sub(node, ele_addr, id, vendor, + label, true, addr, opcode)) + msg[n] = MESH_STATUS_STORAGE_FAIL; - switch (opcode) { - default: - l_debug("Bad opcode: %x", opcode); - return; + l_put_le16(ele_addr, msg + n + 1); + l_put_le16(addr, msg + n + 3); - case OP_CONFIG_MODEL_SUB_DELETE_ALL: - status = mesh_model_sub_del_all(node, ele_addr, id); + if (vendor) { + l_put_le16(VENDOR_ID(id), msg + n + 5); + l_put_le16(MODEL_ID(id), msg + n + 7); + n += 9; + } else { + l_put_le16(MODEL_ID(id), msg + n + 5); + n += 7; + } - if (status == MESH_STATUS_SUCCESS) - mesh_config_model_sub_del_all(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor); - break; + return n; +} - case OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_OVERWRITE: - status = mesh_model_sub_ovr(node, ele_addr, id, - addr, virt, &grp); +static uint16_t config_sub_del_all(struct mesh_node *node, const uint8_t *pkt, + bool vendor) +{ + uint16_t ele_addr, n, grp = UNASSIGNED_ADDRESS; + uint32_t id; - if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, id, vendor, addr, - virt, grp, opcode); - break; - case OP_CONFIG_MODEL_SUB_VIRT_ADD: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_ADD: - status = mesh_model_sub_add(node, ele_addr, id, - addr, virt, &grp); + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - if (status == MESH_STATUS_SUCCESS && - !save_config_sub(node, ele_addr, id, vendor, - addr, virt, grp, opcode)) - status = MESH_STATUS_STORAGE_FAIL; + ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); - break; - case OP_CONFIG_MODEL_SUB_VIRT_DELETE: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_DELETE: - status = mesh_model_sub_del(node, ele_addr, id, addr, virt, - &grp); + msg[n] = mesh_model_sub_del_all(node, ele_addr, id); - if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, id, vendor, addr, - virt, grp, opcode); + if (msg[n] == MESH_STATUS_SUCCESS) { + struct mesh_config *cfg = node_config_get(node); - break; + if (!mesh_config_model_sub_del_all(cfg, ele_addr, + vendor ? id : MODEL_ID(id), + vendor)) + msg[n] = MESH_STATUS_STORAGE_FAIL; + } + + l_put_le16(ele_addr, msg + n + 1); + l_put_le16(grp, msg + n + 3); + + if (vendor) { + l_put_le16(VENDOR_ID(id), msg + n + 5); + l_put_le16(MODEL_ID(id), msg + n + 7); + n += 9; + } else { + l_put_le16(MODEL_ID(id), msg + n + 5); + n += 7; } - send_sub_status(node, net_idx, src, dst, status, ele_addr, grp, id); + return n; } static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, @@ -797,28 +742,38 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_VEND_MODEL_SUB_GET: if (size != 6) return true; - - config_sub_get(node, net_idx, src, dst, pkt, size); - break; + /* Fall Through */ case OP_CONFIG_MODEL_SUB_GET: - if (size != 4) + if (size != 4 && opcode == OP_CONFIG_MODEL_SUB_GET) return true; - config_sub_get(node, net_idx, src, dst, pkt, size); + n = cfg_sub_get_msg(node, net_idx, src, dst, pkt, size); break; case OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE: case OP_CONFIG_MODEL_SUB_VIRT_DELETE: case OP_CONFIG_MODEL_SUB_VIRT_ADD: - virt = true; - /* Fall Through */ + if (size != 20 && size != 22) + return true; + + n = cfg_virt_sub_add_msg(node, pkt, size == 22, opcode); + break; + case OP_CONFIG_MODEL_SUB_OVERWRITE: case OP_CONFIG_MODEL_SUB_DELETE: case OP_CONFIG_MODEL_SUB_ADD: + if (size != 6 && size != 8) + return true; + + n = cfg_sub_add_msg(node, pkt, size == 8, opcode); + break; + case OP_CONFIG_MODEL_SUB_DELETE_ALL: - config_sub_set(node, net_idx, src, dst, pkt, size, virt, - opcode); + if (size != 4 && size != 6) + return true; + + n = config_sub_del_all(node, pkt, size == 6); break; case OP_CONFIG_RELAY_SET: diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index deb0019f9..a40f92c01 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1069,11 +1069,11 @@ static bool parse_model_subscriptions(json_object *jsubs, switch (len) { case 4: - if (sscanf(str, "%04hx", &subs[i].src.addr) != 1) + if (sscanf(str, "%04hx", &subs[i].addr.grp) != 1) goto fail; break; case 32: - if (!str2hex(str, len, subs[i].src.virt_addr, 16)) + if (!str2hex(str, len, subs[i].addr.label, 16)) goto fail; subs[i].virt = true; break; @@ -2068,10 +2068,10 @@ bool mesh_config_model_sub_add(struct mesh_config *cfg, uint16_t ele_addr, return false; if (!sub->virt) { - snprintf(buf, 5, "%4.4x", sub->src.addr); + snprintf(buf, 5, "%4.4x", sub->addr.grp); len = 4; } else { - hex2str(sub->src.virt_addr, 16, buf, 33); + hex2str(sub->addr.label, 16, buf, 33); len = 32; } @@ -2122,10 +2122,10 @@ bool mesh_config_model_sub_del(struct mesh_config *cfg, uint16_t ele_addr, return true; if (!sub->virt) { - snprintf(buf, 5, "%4.4x", sub->src.addr); + snprintf(buf, 5, "%4.4x", sub->addr.grp); len = 4; } else { - hex2str(sub->src.virt_addr, 16, buf, 33); + hex2str(sub->addr.label, 16, buf, 33); len = 32; } diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 7dfa9f20c..f15f3f376 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -24,9 +24,9 @@ struct mesh_config; struct mesh_config_sub { bool virt; union { - uint16_t addr; - uint8_t virt_addr[16]; - } src; + uint16_t grp; + uint8_t label[16]; + } addr; }; struct mesh_config_pub { diff --git a/mesh/model.c b/mesh/model.c index ef7668147..3c9b6577a 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -664,7 +664,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } - if (l_queue_length(mod->bindings) >= MAX_BINDINGS) + if (l_queue_length(mod->bindings) >= MAX_MODEL_BINDINGS) return MESH_STATUS_INSUFF_RESOURCES; if (!mesh_config_model_binding_add(node_config_get(node), addr, @@ -737,7 +737,7 @@ static int set_virt_pub(struct mesh_model *mod, const uint8_t *label, } static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod, - const uint8_t *label, uint16_t *dst) + const uint8_t *label, uint16_t *addr) { struct mesh_virtual *virt = l_queue_find(mod->virtuals, find_virt_by_label, label); @@ -745,40 +745,35 @@ static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod, if (!virt) { virt = add_virtual(label); if (!virt) - return MESH_STATUS_STORAGE_FAIL; + return MESH_STATUS_INSUFF_RESOURCES; l_queue_push_head(mod->virtuals, virt); mesh_net_dst_reg(net, virt->addr); l_debug("Added virtual sub addr %4.4x", virt->addr); } - if (dst) - *dst = virt->addr; + if (addr) + *addr = virt->addr; return MESH_STATUS_SUCCESS; } static int add_sub(struct mesh_net *net, struct mesh_model *mod, - const uint8_t *group, bool b_virt, uint16_t *dst) + uint16_t addr) { - uint16_t grp; - - if (b_virt) - return add_virt_sub(net, mod, group, dst); - - grp = l_get_le16(group); - if (dst) - *dst = grp; + if (!mod->subs) + mod->subs = l_queue_new(); - if (!l_queue_find(mod->subs, simple_match, L_UINT_TO_PTR(grp))) { + if (l_queue_find(mod->subs, simple_match, L_UINT_TO_PTR(addr))) + return MESH_STATUS_SUCCESS; - if (!mod->subs) - mod->subs = l_queue_new(); + if ((l_queue_length(mod->subs) + l_queue_length(mod->virtuals)) >= + MAX_MODEL_SUBS) + return MESH_STATUS_INSUFF_RESOURCES; - l_queue_push_tail(mod->subs, L_UINT_TO_PTR(grp)); - mesh_net_dst_reg(net, grp); - l_debug("Added group subscription %4.4x", grp); - } + l_queue_push_tail(mod->subs, L_UINT_TO_PTR(addr)); + mesh_net_dst_reg(net, addr); + l_debug("Added group subscription %4.4x", addr); return MESH_STATUS_SUCCESS; } @@ -1454,8 +1449,8 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { struct mesh_model *mod; int status, ele_idx = node_get_element_idx(node, addr); @@ -1470,7 +1465,35 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - status = add_sub(node_get_net(node), mod, group, is_virt, dst); + status = add_sub(node_get_net(node), mod, addr); + if (status != MESH_STATUS_SUCCESS) + return status; + + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); + + return MESH_STATUS_SUCCESS; +} + +int mesh_model_virt_sub_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *pub_addr) +{ + struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; + + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + + status = add_virt_sub(node_get_net(node), mod, label, pub_addr); if (status != MESH_STATUS_SUCCESS) return status; @@ -1482,12 +1505,11 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { - struct l_queue *virtuals, *subs; struct mesh_model *mod; - int status, ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1499,36 +1521,39 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - subs = mod->subs; - virtuals = mod->virtuals; - mod->subs = l_queue_new(); - mod->virtuals = l_queue_new(); + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); - if (!mod->subs || !mod->virtuals) - return MESH_STATUS_INSUFF_RESOURCES; + add_sub(node_get_net(node), mod, addr); - status = add_sub(node_get_net(node), mod, group, is_virt, dst); + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); - if (status != MESH_STATUS_SUCCESS) { - /* Adding new group failed, so revert to old lists */ - l_queue_destroy(mod->subs, NULL); - mod->subs = subs; - l_queue_destroy(mod->virtuals, unref_virt); - mod->virtuals = virtuals; - } else { - const struct l_queue_entry *entry; - struct mesh_net *net = node_get_net(node); + return MESH_STATUS_SUCCESS; +} + +int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr) +{ + struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; - entry = l_queue_get_entries(subs); + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; - for (; entry; entry = entry->next) - mesh_net_dst_unreg(net, - (uint16_t) L_PTR_TO_UINT(entry->data)); + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); - /* Destroy old lists */ - l_queue_destroy(subs, NULL); - l_queue_destroy(virtuals, unref_virt); - } + status = add_virt_sub(node_get_net(node), mod, label, addr); if (!mod->cbs) /* External models */ @@ -1537,10 +1562,9 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, return status; } -int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { - uint16_t grp; struct mesh_model *mod; int ele_idx = node_get_element_idx(node, addr); @@ -1554,26 +1578,47 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - if (is_virt) { - struct mesh_virtual *virt; + if (l_queue_remove(mod->subs, L_UINT_TO_PTR(addr))) { + mesh_net_dst_unreg(node_get_net(node), addr); - virt = l_queue_find(mod->virtuals, find_virt_by_label, group); - if (virt) { - l_queue_remove(mod->virtuals, virt); - grp = virt->addr; - unref_virt(virt); - } else { - if (!mesh_crypto_virtual_addr(group, &grp)) - return MESH_STATUS_STORAGE_FAIL; - } - } else { - grp = l_get_le16(group); + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); } - *dst = grp; + return MESH_STATUS_SUCCESS; +} - if (l_queue_remove(mod->subs, L_UINT_TO_PTR(grp))) { - mesh_net_dst_unreg(node_get_net(node), grp); +int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr) +{ + struct mesh_model *mod; + struct mesh_virtual *virt; + int ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; + + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + + virt = l_queue_remove_if(mod->virtuals, find_virt_by_label, label); + + if (virt) { + *addr = virt->addr; + unref_virt(virt); + } else { + *addr = UNASSIGNED_ADDRESS; + return MESH_STATUS_SUCCESS; + } + + if (l_queue_remove(mod->subs, L_UINT_TO_PTR(*addr))) { + mesh_net_dst_unreg(node_get_net(node), *addr); if (!mod->cbs) /* External models */ @@ -1614,9 +1659,9 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, struct mesh_config_pub *pub = db_mod->pub; uint32_t i; - if (db_mod->num_bindings > MAX_BINDINGS) { + if (db_mod->num_bindings > MAX_MODEL_BINDINGS) { l_warn("Binding list too long %u (max %u)", - db_mod->num_bindings, MAX_BINDINGS); + db_mod->num_bindings, MAX_MODEL_BINDINGS); return NULL; } @@ -1670,22 +1715,12 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, return mod; for (i = 0; i < db_mod->num_subs; i++) { - uint16_t group; - uint8_t *src; + struct mesh_config_sub *sub = &db_mod->subs[i]; - /* - * To keep calculations for virtual label coherent, - * convert to little endian. - */ - l_put_le16(db_mod->subs[i].src.addr, &group); - src = db_mod->subs[i].virt ? db_mod->subs[i].src.virt_addr : - (uint8_t *) &group; - - if (add_sub(net, mod, src, db_mod->subs[i].virt, NULL) != - MESH_STATUS_SUCCESS) { - mesh_model_free(mod); - return NULL; - } + if (!sub->virt) + add_sub(net, mod, sub->addr.grp); + else + add_virt_sub(net, mod, sub->addr.label, NULL); } return mod; diff --git a/mesh/model.h b/mesh/model.h index 0d8dddf92..3221379af 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -19,8 +19,8 @@ struct mesh_model; -#define MAX_BINDINGS 10 -#define MAX_GRP_PER_MOD 10 +#define MAX_MODEL_BINDINGS 10 +#define MAX_MODEL_SUBS 10 #define ACTION_ADD 1 #define ACTION_UPDATE 2 @@ -89,12 +89,21 @@ int mesh_model_get_bindings(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_sz, uint16_t *len); int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); + uint16_t grp); +int mesh_model_virt_sub_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); + uint16_t grp); +int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id); -int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); +int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr); +int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size); uint16_t mesh_model_cfg_blk(uint8_t *pkt); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uGaaCvYvI1/5zAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 22:39:18 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SPyeCPYvI1+5IQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 22:39:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C6E65A1977; Thu, 30 Jul 2020 22:39:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728840AbgG3UjA (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 16:39:00 -0400 Received: from mga01.intel.com ([192.55.52.88]:35025 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728774AbgG3Ui7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 16:38:59 -0400 IronPort-SDR: c5rJEF0Km5popbUGrEAKxmFX5aacffKL6JZkWFy8thjbRUz8aOACTXNFZV2sdzFei/y6WKlsJT sFydq7oYLfKA== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="169803100" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="169803100" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 13:38:58 -0700 IronPort-SDR: uyW+kIw57m+r6LEE7v60ai7gM/9UHIEczmFx55yZSVjxg+QYBwUSfNql9GJ82+pe4pDM6ANm67 kq9Lo1gsGluw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="330864964" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2020 13:38:58 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 04/10] mesh: Clean up handling of config publication messages Date: Thu, 30 Jul 2020 13:38:45 -0700 Message-Id: <20200730203851.32043-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200730203851.32043-1-inga.stotland@intel.com> References: <20200730203851.32043-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: C6E65A1977 X-Rspamd-UID: 113a10 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 70 ++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 1cd0bcdd5..871ecf878 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -44,11 +44,9 @@ static const uint8_t supported_pages[] = { static uint8_t msg[MAX_MSG_LEN]; -static void send_pub_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, uint32_t id, - uint16_t pub_addr, uint16_t idx, bool cred_flag, - uint8_t ttl, uint8_t period, uint8_t retransmit) +static uint16_t set_pub_status(uint8_t status, uint16_t ele_addr, uint32_t id, + uint16_t pub_addr, uint16_t idx, bool cred_flag, + uint8_t ttl, uint8_t period, uint8_t retransmit) { size_t n; @@ -72,41 +70,32 @@ static void send_pub_status(struct mesh_node *node, uint16_t net_idx, n += 4; } - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); + return n; } -static void config_pub_get(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size) +static uint16_t config_pub_get(struct mesh_node *node, const uint8_t *pkt, + bool vendor) { uint32_t id; uint16_t ele_addr; struct mesh_model_pub *pub; int status; - if (size == 4) { - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); - } else if (size == 6) { - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - } else - return; - ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); + pub = mesh_model_pub_get(node, ele_addr, id, &status); if (pub && status == MESH_STATUS_SUCCESS) - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, pub->addr, pub->idx, pub->credential, - pub->ttl, pub->period, pub->retransmit); + return set_pub_status(status, ele_addr, id, pub->addr, pub->idx, + pub->credential, pub->ttl, pub->period, + pub->retransmit); else - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, 0, 0, 0, 0, 0, 0); + return set_pub_status(status, ele_addr, id, 0, 0, 0, 0, 0, 0); } -static void config_pub_set(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, bool virt, bool vendor) +static uint16_t config_pub_set(struct mesh_node *node, const uint8_t *pkt, + bool virt, bool vendor) { uint32_t id; uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; @@ -125,17 +114,12 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, ttl = pkt[6]; period = pkt[7]; retransmit = pkt[8]; - id = l_get_le16(pkt + 9); - - if (!vendor) - id = SET_ID(SIG_VENDOR, id); - else - id = SET_ID(id, l_get_le16(pkt + 11)); + id = CFG_SET_ID(vendor, pkt + 9); /* Don't accept virtual seeming addresses */ test_addr = l_get_le16(pub_addr); if (!virt && IS_VIRTUAL(test_addr)) - return; + return 0; cred_flag = !!(CREDFLAG_MASK & idx); idx &= APP_IDX_MASK; @@ -144,15 +128,11 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, cred_flag, ttl, period, retransmit, virt, &ota); - l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, mod: %x, idx: %3.3x", + l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, id: %x, idx: %3.3x", status, ele_addr, ota, id, idx); - if (status != MESH_STATUS_SUCCESS) { - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, 0, 0, 0, 0, 0, 0); - - return; - } + if (status != MESH_STATUS_SUCCESS) + return set_pub_status(status, ele_addr, id, 0, 0, 0, 0, 0, 0); if (IS_UNASSIGNED(test_addr) && !virt) { ttl = period = idx = 0; @@ -180,12 +160,12 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, /* Save model publication to config file */ if (!mesh_config_model_pub_add(node_config_get(node), ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_pub)) + vendor, &db_pub)) status = MESH_STATUS_STORAGE_FAIL; } - send_pub_status(node, net_idx, src, dst, status, ele_addr, id, ota, - idx, cred_flag, ttl, period, retransmit); + return set_pub_status(status, ele_addr, id, ota, idx, cred_flag, ttl, + period, retransmit); } static uint16_t cfg_sub_get_msg(struct mesh_node *node, uint16_t net_idx, @@ -664,14 +644,14 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (!virt && (size != 11 && size != 13)) return true; - config_pub_set(node, net_idx, src, dst, pkt, virt, - size == 13 || size == 27); + n = config_pub_set(node, pkt, virt, size == 13 || size == 27); break; case OP_CONFIG_MODEL_PUB_GET: if (size != 4 && size != 6) return true; - config_pub_get(node, net_idx, src, dst, pkt, size); + + n = config_pub_get(node, pkt, size == 6); break; case OP_CONFIG_VEND_MODEL_SUB_GET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KHVVNfsvI1/5zAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 22:39:23 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uJwSNPsvI18iHAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 22:39:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 675D9A2E27; Thu, 30 Jul 2020 22:39:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728855AbgG3UjA (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 16:39:00 -0400 Received: from mga01.intel.com ([192.55.52.88]:35036 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728771AbgG3Ui7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 16:38:59 -0400 IronPort-SDR: LorYiRARARr8OmO+o2ztxayJe2QHnj3t7DEjCnzonglHQKFoT5EPl+TBhVRxQMaQZ07O1OCXE/ h/B9mAxDUV1Q== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="169803099" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="169803099" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 13:38:58 -0700 IronPort-SDR: 0nDAtzDAU6c8Bkc5TJmhhu+OulQY8kJo93NT6mXE+vyG2XmxCSZGmYExXaCfRsuzu3IM7V9wvA f5zV1La8KOeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="330864957" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2020 13:38:57 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 03/10] mesh: Clean up handling of config node identity message Date: Thu, 30 Jul 2020 13:38:44 -0700 Message-Id: <20200730203851.32043-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200730203851.32043-1-inga.stotland@intel.com> References: <20200730203851.32043-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 675D9A2E27 X-Rspamd-UID: 837713 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 6621d0935..1cd0bcdd5 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -774,11 +774,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_NODE_IDENTITY_SET: - if (size != 3 || pkt[2] > 0x01) - return true; - - n_idx = l_get_le16(pkt); - if (n_idx > 0xfff) + if (size != 3) return true; /* Currently setting node identity not supported */ @@ -786,18 +782,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall Through */ case OP_NODE_IDENTITY_GET: - if (size < 2) + if (opcode == OP_NODE_IDENTITY_GET && size != 2) return true; n_idx = l_get_le16(pkt); - if (n_idx > 0xfff) - return true; n = mesh_model_opcode_set(OP_NODE_IDENTITY_STATUS, msg); - - status = mesh_net_get_identity_mode(net, n_idx, &state); - - msg[n++] = status; + msg[n++] = mesh_net_get_identity_mode(net, n_idx, &state); l_put_le16(n_idx, msg + n); n += 2; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0AY4DwEwI1/5zAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 22:39:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id IF7TDQEwI1/0pwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 22:39:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 07E3BA1AA5; Thu, 30 Jul 2020 22:39:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730550AbgG3UjB (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 16:39:01 -0400 Received: from mga01.intel.com ([192.55.52.88]:35035 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728771AbgG3UjB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 16:39:01 -0400 IronPort-SDR: VgWeTaFlFq9ROzVuTTd8cPijaSbi44VvjvYXhe+J/Suy5+wXaZNeViL1ZJual694+frKlmpA8N 1zhQzPtxSSRQ== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="169803102" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="169803102" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 13:39:00 -0700 IronPort-SDR: IMoOCXJbrCDJ3Mg8We/Hllh5h9xdKJKvYr5LwIKKRe+SwcsNU9PX9CxeTFV0VIsLje5Jo1ves2 /Iv/mZXcp5rA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="330864974" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2020 13:38:59 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 06/10] mesh: Clean up handling of config relay messages Date: Thu, 30 Jul 2020 13:38:47 -0700 Message-Id: <20200730203851.32043-7-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200730203851.32043-1-inga.stotland@intel.com> References: <20200730203851.32043-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 07E3BA1AA5 X-Rspamd-UID: 73718b This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 67e320eda..f1237b0fe 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -390,6 +390,30 @@ static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt, return n; } +static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t count; + uint16_t interval; + uint16_t n; + + if (pkt[0] > 0x01) + return 0; + + if (opcode == OP_CONFIG_RELAY_SET) { + count = (pkt[1] & 0x7) + 1; + interval = ((pkt[1] >> 3) + 1) * 10; + node_relay_mode_set(node, !!pkt[0], count, interval); + } + + n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); + + msg[n++] = node_relay_mode_get(node, &count, &interval); + msg[n++] = (count - 1) + ((interval/10 - 1) << 3); + + return n; +} + static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; @@ -759,24 +783,14 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_RELAY_SET: - if (size != 2 || pkt[0] > 0x01) + if (size != 2) return true; - - count = (pkt[1] & 0x7) + 1; - interval = ((pkt[1] >> 3) + 1) * 10; - node_relay_mode_set(node, !!pkt[0], count, interval); /* Fall Through */ - case OP_CONFIG_RELAY_GET: if (opcode == OP_CONFIG_RELAY_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); - - msg[n++] = node_relay_mode_get(node, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Relay Config (%d)", msg[n-1]); + n = cfg_relay_msg(node, pkt, opcode); break; case OP_CONFIG_NETWORK_TRANSMIT_SET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YHRlKgYwI1/5zAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 22:39:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id KGqKKQYwI188qwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 22:39:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6464CA2DF8; Thu, 30 Jul 2020 22:39:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728771AbgG3UjC (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 16:39:02 -0400 Received: from mga01.intel.com ([192.55.52.88]:35035 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728809AbgG3Ui7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 16:38:59 -0400 IronPort-SDR: bO+4G1v8i4R/80DOHZIM8VbG9/XYhm6Dsr0jiNd1Kd8Y4Bj96RwTySYRKFBfhf7EmnnlCEYLce 89VIHi3mdo5Q== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="169803101" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="169803101" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 13:38:59 -0700 IronPort-SDR: Li0M3bedzVlOsS++Bx9i7971V5Fj6MBFtvjbazXpll/r74nER87VIxMwH9n8pQlMv06jxMjngo YtfS7c4iyeMg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="330864968" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2020 13:38:59 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 05/10] mesh: Clean up handling of config net and app key messages Date: Thu, 30 Jul 2020 13:38:46 -0700 Message-Id: <20200730203851.32043-6-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200730203851.32043-1-inga.stotland@intel.com> References: <20200730203851.32043-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6464CA2DF8 X-Rspamd-UID: d3be7f This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 147 ++++++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 72 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 871ecf878..67e320eda 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -541,6 +541,73 @@ static void node_reset(void *user_data) node_remove(node); } +static uint16_t cfg_appkey_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint16_t n_idx, a_idx, n; + struct mesh_net *net = node_get_net(node); + + n_idx = l_get_le16(pkt) & 0xfff; + a_idx = l_get_le16(pkt + 1) >> 4; + + n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); + + if (opcode == OP_APPKEY_ADD) + msg[n] = appkey_key_add(net, n_idx, a_idx, pkt + 3); + else if (opcode == OP_APPKEY_UPDATE) + msg[n] = appkey_key_update(net, n_idx, a_idx, pkt + 3); + else + msg[n] = appkey_key_delete(net, n_idx, a_idx); + + l_debug("AppKey Command %s: Net_Idx %3.3x, App_Idx %3.3x", + (msg[n] == MESH_STATUS_SUCCESS) ? "success" : "fail", + n_idx, a_idx); + + memcpy(msg + n + 1, &pkt[0], 3); + + return n + 4; +} + +static uint16_t cfg_netkey_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint16_t n_idx, n; + struct mesh_net *net = node_get_net(node); + + n_idx = l_get_le16(pkt); + n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); + + if (opcode == OP_NETKEY_ADD) + msg[n] = mesh_net_add_key(net, n_idx, pkt + 2); + else if (opcode == OP_NETKEY_UPDATE) + msg[n] = mesh_net_update_key(net, n_idx, pkt + 2); + else + msg[n] = mesh_net_del_key(net, n_idx); + + l_debug("NetKey Command %s: Net_Idx %3.3x", + (msg[n] == MESH_STATUS_SUCCESS) ? "success" : "fail", + n_idx); + + memcpy(msg + n + 1, &pkt[0], 2); + + return n + 3; +} + +static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t n_idx, sz, n; + + n_idx = l_get_le16(pkt); + + n = mesh_model_opcode_set(OP_APPKEY_LIST, msg); + l_put_le16(n_idx, msg + n + 1); + + msg[n] = appkey_list(node_get_net(node), n_idx, msg + n + 3, + MAX_MSG_LEN - (n + 3), &sz); + + return n + 3 + sz; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -579,7 +646,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint32_t opcode, tmp32; int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; - uint16_t n_idx, a_idx; + uint16_t n_idx; uint8_t state, status; uint8_t phase; bool virt = false; @@ -850,60 +917,19 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 19) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; - - if (opcode == OP_APPKEY_ADD) - b_res = appkey_key_add(net, n_idx, a_idx, pkt + 3); - else - b_res = appkey_key_update(net, n_idx, a_idx, - pkt + 3); - - l_debug("Add/Update AppKey %s: Net_Idx %3.3x, App_Idx %3.3x", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail", - n_idx, a_idx); - - - n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); - - msg[n++] = b_res; - msg[n++] = pkt[0]; - msg[n++] = pkt[1]; - msg[n++] = pkt[2]; - break; - + /* Fall Through */ case OP_APPKEY_DELETE: - if (size != 3) + if (opcode == OP_APPKEY_DELETE && size != 3) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; - b_res = appkey_key_delete(net, n_idx, a_idx); - l_debug("Delete AppKey %s Net_Idx %3.3x to App_Idx %3.3x", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail", - n_idx, a_idx); - - n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); - msg[n++] = b_res; - msg[n++] = pkt[0]; - msg[n++] = pkt[1]; - msg[n++] = pkt[2]; + n = cfg_appkey_msg(node, pkt, opcode); break; case OP_APPKEY_GET: if (size != 2) return true; - n_idx = l_get_le16(pkt); - - n = mesh_model_opcode_set(OP_APPKEY_LIST, msg); - - status = appkey_list(net, n_idx, msg + n + 3, - MAX_MSG_LEN - n - 3, &size); - - msg[n] = status; - l_put_le16(n_idx, msg + n + 1); - n += (size + 3); + n = cfg_get_appkeys_msg(node, pkt); break; case OP_NETKEY_ADD: @@ -911,35 +937,12 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 18) return true; - n_idx = l_get_le16(pkt); - - if (opcode == OP_NETKEY_ADD) - b_res = mesh_net_add_key(net, n_idx, pkt + 2); - else - b_res = mesh_net_update_key(net, n_idx, pkt + 2); - - l_debug("NetKey Add/Update %s", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail"); - - n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); - msg[n++] = b_res; - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; - break; - + /* Fall Through */ case OP_NETKEY_DELETE: - if (size != 2) + if (opcode == OP_NETKEY_DELETE && size != 2) return true; - b_res = mesh_net_del_key(net, l_get_le16(pkt)); - - l_debug("NetKey delete %s", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail"); - - n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); - msg[n++] = b_res; - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; + n = cfg_netkey_msg(node, pkt, opcode); break; case OP_NETKEY_GET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oH8FAwwwI1/5zAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 22:39:40 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ENZFAQwwI1952wAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 22:39:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CD86AA1AA5; Thu, 30 Jul 2020 22:39:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728871AbgG3UjF (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 16:39:05 -0400 Received: from mga01.intel.com ([192.55.52.88]:35035 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728809AbgG3UjD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 16:39:03 -0400 IronPort-SDR: zQ+/mWA2w5RXvyKskEgVfsEwRO8fSqhitr+Mx6QT6Zm8WhMXKc+ms+aB8+VrRXIhLRit0cX6VD zUh657P/8dng== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="169803105" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="169803105" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 13:39:02 -0700 IronPort-SDR: 3putM2FNdyXZFAn4DkyLgEetbNlRyBtznig6cNfzzCwUfgsQNdVby/iLwii+L3J7VzlbPeZYN+ b5JHIFA+sghg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="330864985" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2020 13:39:01 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 07/10] mesh: Clean up handling of config poll timeout message Date: Thu, 30 Jul 2020 13:38:48 -0700 Message-Id: <20200730203851.32043-8-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200730203851.32043-1-inga.stotland@intel.com> References: <20200730203851.32043-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: CD86AA1AA5 X-Rspamd-UID: 001c65 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 34 +++++++++++++++++++++++----------- mesh/cfgmod.h | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index f1237b0fe..bc564f0ef 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -632,6 +632,25 @@ static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt) return n + 3 + sz; } +static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t n, addr = l_get_le16(pkt); + uint32_t poll_to; + + if (!IS_UNICAST(addr)) + return 0; + + n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); + l_put_le16(addr, msg + n); + n += 2; + + poll_to = mesh_net_friend_timeout(node_get_net(node), addr); + msg[n++] = poll_to; + msg[n++] = poll_to >> 8; + msg[n++] = poll_to >> 16; + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -667,7 +686,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct mesh_net *net; const uint8_t *pkt = data; struct timeval time_now; - uint32_t opcode, tmp32; + uint32_t opcode; int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; uint16_t n_idx; @@ -1103,18 +1122,11 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, msg[n++] = hb->sub_max_hops; break; - case OP_CONFIG_POLL_TIMEOUT_LIST: - if (size != 2 || l_get_le16(pkt) == 0 || - l_get_le16(pkt) > 0x7fff) + case OP_CONFIG_POLL_TIMEOUT_GET: + if (size != 2) return true; - n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; - tmp32 = mesh_net_friend_timeout(net, l_get_le16(pkt)); - msg[n++] = tmp32; - msg[n++] = tmp32 >> 8; - msg[n++] = tmp32 >> 16; + n = cfg_poll_timeout_msg(node, pkt); break; case OP_NODE_RESET: diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 7b6a95807..6d73656a7 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -66,7 +66,7 @@ #define OP_CONFIG_MODEL_SUB_LIST 0x802A #define OP_CONFIG_VEND_MODEL_SUB_GET 0x802B #define OP_CONFIG_VEND_MODEL_SUB_LIST 0x802C -#define OP_CONFIG_POLL_TIMEOUT_LIST 0x802D +#define OP_CONFIG_POLL_TIMEOUT_GET 0x802D #define OP_CONFIG_POLL_TIMEOUT_STATUS 0x802E /* Health opcodes in health-mod.h */ #define OP_CONFIG_HEARTBEAT_PUB_GET 0x8038 -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4JylGREwI18ttwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 22:39:45 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CLnHFxEwI1+5IQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 22:39:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3B018A2F75; Thu, 30 Jul 2020 22:39:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730563AbgG3UjG (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 16:39:06 -0400 Received: from mga01.intel.com ([192.55.52.88]:35041 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730551AbgG3UjF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 16:39:05 -0400 IronPort-SDR: XRHxFgbxWRSOWsPWhYVKHp9tbjtp0hjpBxUJ9Gzowq3Hj94bM/GoZLHaRhQR8vga36SViwn8vR gHdEpR0UtrdA== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="169803108" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="169803108" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 13:39:03 -0700 IronPort-SDR: 3VnxijT3Sk5cVlSsucJPprv2PTd2EEZdPWYIwjMSt87mNfsoEPwqPeHtDyh8Jh8KcwN1whef9q OlEnYzT66eDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="330864990" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2020 13:39:03 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 08/10] mesh: Clean up handling of config net transmit messages Date: Thu, 30 Jul 2020 13:38:49 -0700 Message-Id: <20200730203851.32043-9-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200730203851.32043-1-inga.stotland@intel.com> References: <20200730203851.32043-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3B018A2F75 X-Rspamd-UID: 2d3178 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index bc564f0ef..a7369e435 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -651,6 +651,28 @@ static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) return n; } +static uint16_t cfg_net_tx_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t cnt; + uint16_t interval, n; + struct mesh_net *net = node_get_net(node); + + cnt = (pkt[0] & 0x7) + 1; + interval = ((pkt[0] >> 3) + 1) * 10; + + if (opcode == OP_CONFIG_NETWORK_TRANSMIT_SET && + mesh_config_write_net_transmit(node_config_get(node), + cnt, interval)) + mesh_net_transmit_params_set(net, cnt, interval); + + n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, msg); + + mesh_net_transmit_params_get(net, &cnt, &interval); + msg[n++] = (cnt - 1) + ((interval/10 - 1) << 3); + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -693,8 +715,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint8_t state, status; uint8_t phase; bool virt = false; - uint8_t count; - uint16_t interval; uint16_t n; if (app_idx != APP_IDX_DEV_LOCAL) @@ -815,25 +835,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_NETWORK_TRANSMIT_SET: if (size != 1) return true; - - count = (pkt[0] & 0x7) + 1; - interval = ((pkt[0] >> 3) + 1) * 10; - - if (mesh_config_write_net_transmit(node_config_get(node), count, - interval)) - mesh_net_transmit_params_set(net, count, interval); /* Fall Through */ case OP_CONFIG_NETWORK_TRANSMIT_GET: if (opcode == OP_CONFIG_NETWORK_TRANSMIT_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, - msg); - mesh_net_transmit_params_get(net, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Network Transmit Config"); + n = cfg_net_tx_msg(node, pkt, opcode); break; case OP_CONFIG_PROXY_SET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mH4QMxYwI18ttwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 22:39:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id MLBcMRYwI1++/AEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 22:39:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 88D8AA1977; Thu, 30 Jul 2020 22:39:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730566AbgG3UjH (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 16:39:07 -0400 Received: from mga01.intel.com ([192.55.52.88]:35043 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730552AbgG3UjF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 16:39:05 -0400 IronPort-SDR: ZYoBTIQVrr45weGxRAQysws92frWjjy/4dwc3NWnq47N1h3y6skDtNQ2neFYny8IA20JC9wbIQ tcTK2njatHfQ== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="169803109" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="169803109" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 13:39:04 -0700 IronPort-SDR: IG42GYL9o1wYXLviryrJKNcrYDe0A3/wiPeWaSvAqZAikcMYlIuFpXrZnwfms+yQtppH9g+9hh JAO4M8nOVrmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="330864997" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2020 13:39:04 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 09/10] mesh: Clean up handling of config KR phase messages Date: Thu, 30 Jul 2020 13:38:50 -0700 Message-Id: <20200730203851.32043-10-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200730203851.32043-1-inga.stotland@intel.com> References: <20200730203851.32043-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 88D8AA1977 X-Rspamd-UID: ba4dce This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 55 +++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index a7369e435..cacc8b6ea 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -414,6 +414,31 @@ static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt, return n; } +static uint16_t cfg_key_refresh_phase(struct mesh_node *node, + const uint8_t *pkt, int opcode) +{ + struct mesh_net *net = node_get_net(node); + uint16_t n, idx = l_get_le16(pkt); + uint8_t phase; + + n = mesh_model_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_STATUS, msg); + + if (opcode == OP_CONFIG_KEY_REFRESH_PHASE_SET) { + phase = pkt[2]; + msg[n] = mesh_net_key_refresh_phase_set(net, idx, phase); + l_debug("Set KR Phase: net=%3.3x transition=%d", idx, phase); + } else { + msg[n] = mesh_net_key_refresh_phase_get(net, idx, &phase); + l_debug("Get KR Phase: net=%3.3x phase=%d", idx, phase); + } + + l_put_le16(idx, msg + n); + msg[n + 2] = (msg[n] != MESH_STATUS_SUCCESS) ? + KEY_REFRESH_PHASE_NONE : phase; + + return n + 3; +} + static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; @@ -712,8 +737,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; uint16_t n_idx; - uint8_t state, status; - uint8_t phase; + uint8_t state; bool virt = false; uint16_t n; @@ -920,37 +944,16 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_KEY_REFRESH_PHASE_SET: - if (size != 3 || pkt[2] > 0x03) + if (size != 3 || pkt[2] > KEY_REFRESH_PHASE_THREE) return true; - b_res = mesh_net_key_refresh_phase_set(net, l_get_le16(pkt), - pkt[2]); - size = 2; /* Fall Through */ case OP_CONFIG_KEY_REFRESH_PHASE_GET: - if (size != 2) + if (size != 2 && opcode == OP_CONFIG_KEY_REFRESH_PHASE_GET) return true; - n_idx = l_get_le16(pkt); - - n = mesh_model_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_STATUS, - msg); - - /* State: 0x00-0x03 phase of key refresh */ - status = mesh_net_key_refresh_phase_get(net, n_idx, - &phase); - if (status != MESH_STATUS_SUCCESS) { - b_res = status; - phase = KEY_REFRESH_PHASE_NONE; - } - - msg[n++] = b_res; - l_put_le16(n_idx, msg + n); - n += 2; - msg[n++] = phase; - - l_debug("Get/Set Key Refresh State (%d)", msg[n-1]); + n = cfg_key_refresh_phase(node, pkt, opcode); break; case OP_APPKEY_ADD: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8MwBAB0wI1+WwAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 30 Jul 2020 22:39:57 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id ICJMOhwwI188qwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 30 Jul 2020 22:39:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F1B91A1AA5; Thu, 30 Jul 2020 22:39:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730570AbgG3UjH (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 16:39:07 -0400 Received: from mga01.intel.com ([192.55.52.88]:35035 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730553AbgG3UjG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 16:39:06 -0400 IronPort-SDR: rjg9rTYs6t+ArfDlw7CepGYzfkC4J7P69Xw+39X5Nb4wLVXOebvG5Qu1xjJrYHQmzcTV95n66J FHMarbz32vQA== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="169803110" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="169803110" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 13:39:05 -0700 IronPort-SDR: gU3GHjsUZFGhV1gXOgkufTL3KFgaSU0VVLntBtbbrfLYJC1RarOczJrUBsmk+WBGyE/tzdzlv9 tCUdb5edl/gw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="330865003" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2020 13:39:05 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 10/10] mesh: Refactor heartbeat pub/sub Date: Thu, 30 Jul 2020 13:38:51 -0700 Message-Id: <20200730203851.32043-11-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200730203851.32043-1-inga.stotland@intel.com> References: <20200730203851.32043-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: F1B91A1AA5 X-Rspamd-UID: 593f5f Move heartbeat publication/subscription timers and housekeeping to net.c since this is where the trigger events and control messages are handled. Configuration server (cfgmod-server.c) stays responsible for parsing the set pub/sub message parameters and assemblying the pub/sub status messages. Also, make sure that the correct message status is reported. --- mesh/cfgmod-server.c | 307 ++++++++++++++----------------------------- mesh/net.c | 273 ++++++++++++++++++++++++++++---------- mesh/net.h | 48 ++++--- 3 files changed, 328 insertions(+), 300 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index cacc8b6ea..a447a3524 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -439,50 +439,6 @@ static uint16_t cfg_key_refresh_phase(struct mesh_node *node, return n + 3; } -static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) -{ - struct mesh_net *net = user_data; - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - mesh_net_heartbeat_send(net); - - if (hb->pub_count != 0xffff) - hb->pub_count--; - if (hb->pub_count > 0) - l_timeout_modify(hb->pub_timer, hb->pub_period); - else { - l_timeout_remove(hb->pub_timer); - hb->pub_timer = NULL; - } -} - -static void update_hb_pub_timer(struct mesh_net *net, - struct mesh_net_heartbeat *hb) -{ - if (IS_UNASSIGNED(hb->pub_dst) || hb->pub_count == 0) { - l_timeout_remove(hb->pub_timer); - hb->pub_timer = NULL; - return; - } - - if (!hb->pub_timer) - hb->pub_timer = l_timeout_create(hb->pub_period, - hb_pub_timeout_func, net, NULL); - else - l_timeout_modify(hb->pub_timer, hb->pub_period); -} - -static void hb_sub_timeout_func(struct l_timeout *timeout, void *user_data) -{ - struct mesh_net *net = user_data; - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - l_debug("HB Subscription Ended"); - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; -} - static uint8_t uint32_to_log(uint32_t value) { uint32_t val = 1; @@ -501,85 +457,112 @@ static uint8_t uint32_to_log(uint32_t value) return ret; } -static uint32_t log_to_uint32(uint8_t log, uint8_t offset) +static uint16_t hb_subscription_get(struct mesh_node *node, int status) { - if (!log) - return 0x0000; - else if (log > 0x11) - return 0xffff; + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_sub *sub = mesh_net_get_heartbeat_sub(net); + struct timeval time_now; + uint16_t n; + + gettimeofday(&time_now, NULL); + time_now.tv_sec -= sub->start; + + if (time_now.tv_sec >= (long int) sub->period) + time_now.tv_sec = 0; else - return (1 << (log - offset)); -} + time_now.tv_sec = sub->period - time_now.tv_sec; + l_debug("Sub Period (Log %2.2x) %d sec", uint32_to_log(time_now.tv_sec), + (int) time_now.tv_sec); -static int hb_subscription_set(struct mesh_net *net, uint16_t src, - uint16_t dst, uint8_t period_log) + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); + msg[n++] = status; + l_put_le16(sub->src, msg + n); + n += 2; + l_put_le16(sub->dst, msg + n); + n += 2; + msg[n++] = uint32_to_log(time_now.tv_sec); + msg[n++] = uint32_to_log(sub->count); + msg[n++] = sub->count ? sub->min_hops : 0; + msg[n++] = sub->max_hops; + + return n; +} + +static uint16_t hb_subscription_set(struct mesh_node *node, const uint8_t *pkt) { - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - struct timeval time_now; + uint16_t src, dst; + uint8_t period_log; + struct mesh_net *net; + int status; + + src = l_get_le16(pkt); + dst = l_get_le16(pkt + 2); /* SRC must be Unicast, DST can be any legal address except Virtual */ if ((!IS_UNASSIGNED(src) && !IS_UNICAST(src)) || IS_VIRTUAL(dst)) - return -1; - - /* Check if the subscription should be disabled */ - if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst)) { - if (IS_GROUP(hb->sub_dst)) - mesh_net_dst_unreg(net, hb->sub_dst); - - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; - hb->sub_dst = UNASSIGNED_ADDRESS; - hb->sub_src = UNASSIGNED_ADDRESS; - hb->sub_count = 0; - hb->sub_period = 0; - hb->sub_min_hops = 0; - hb->sub_max_hops = 0; - return MESH_STATUS_SUCCESS; - - } else if (!period_log && src == hb->sub_src && dst == hb->sub_dst) { - /* Preserve collected data, but disable */ - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; - hb->sub_period = 0; - return MESH_STATUS_SUCCESS; - } + return 0; - if (hb->sub_dst != dst) { - if (IS_GROUP(hb->sub_dst)) - mesh_net_dst_unreg(net, hb->sub_dst); - if (IS_GROUP(dst)) - mesh_net_dst_reg(net, dst); - } + period_log = pkt[4]; - hb->sub_enabled = !!period_log; - hb->sub_src = src; - hb->sub_dst = dst; - hb->sub_count = 0; - hb->sub_period = log_to_uint32(period_log, 1); - hb->sub_min_hops = 0x00; - hb->sub_max_hops = 0x00; + if (period_log > 0x11) + return 0; - gettimeofday(&time_now, NULL); - hb->sub_start = time_now.tv_sec; + net = node_get_net(node); - if (!hb->sub_enabled) { - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - return MESH_STATUS_SUCCESS; - } + status = mesh_net_set_heartbeat_sub(net, src, dst, period_log); - hb->sub_min_hops = 0xff; + return hb_subscription_get(node, status); +} - if (!hb->sub_timer) - hb->sub_timer = l_timeout_create(hb->sub_period, - hb_sub_timeout_func, net, NULL); - else - l_timeout_modify(hb->sub_timer, hb->sub_period); +static uint16_t hb_publication_get(struct mesh_node *node, int status) +{ + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_pub *pub = mesh_net_get_heartbeat_pub(net); + uint16_t n; - return MESH_STATUS_SUCCESS; + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg); + msg[n++] = status; + l_put_le16(pub->dst, msg + n); + n += 2; + msg[n++] = uint32_to_log(pub->count); + msg[n++] = uint32_to_log(pub->period); + msg[n++] = pub->ttl; + l_put_le16(pub->features, msg + n); + n += 2; + l_put_le16(pub->net_idx, msg + n); + n += 2; + + return n; +} + +static uint16_t hb_publication_set(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t dst, features, net_idx; + uint8_t period_log, count_log, ttl; + struct mesh_net *net; + int status; + + dst = l_get_le16(pkt); + count_log = pkt[2]; + period_log = pkt[3]; + ttl = pkt[4]; + + if (count_log > 0x11 && count_log != 0xff) + return 0; + + if (period_log > 0x11 || ttl > TTL_MASK || IS_VIRTUAL(dst)) + return 0; + + features = l_get_le16(pkt + 5) & 0xf; + net_idx = l_get_le16(pkt + 7); + + net = node_get_net(node); + + status = mesh_net_set_heartbeat_pub(net, dst, features, net_idx, ttl, + count_log, period_log); + + return hb_publication_get(node, status); } static void node_reset(void *user_data) @@ -732,10 +715,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct mesh_node *node = (struct mesh_node *) user_data; struct mesh_net *net; const uint8_t *pkt = data; - struct timeval time_now; uint32_t opcode; - int b_res = MESH_STATUS_SUCCESS; - struct mesh_net_heartbeat *hb; uint16_t n_idx; uint8_t state; bool virt = false; @@ -751,7 +731,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, return false; net = node_get_net(node); - hb = mesh_net_heartbeat_get(net); + l_debug("CONFIG-SRV-opcode 0x%x size %u idx %3.3x", opcode, size, net_idx); @@ -1024,113 +1004,35 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_HEARTBEAT_PUB_SET: - l_debug("OP_CONFIG_HEARTBEAT_PUB_SET"); + l_debug("Config Heartbeat Publication Set"); if (size != 9) return true; - if (pkt[2] > 0x11 || pkt[3] > 0x10 || pkt[4] > 0x7f) - return true; - else if (IS_VIRTUAL(l_get_le16(pkt))) - b_res = MESH_STATUS_INVALID_ADDRESS; - else if (l_get_le16(pkt + 7) != mesh_net_get_primary_idx(net)) - /* Future work: check for valid subnets */ - b_res = MESH_STATUS_INVALID_NETKEY; - - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, - msg); - msg[n++] = b_res; - - memcpy(&msg[n], pkt, 9); - - /* Ignore RFU bits in features */ - l_put_le16(l_get_le16(pkt + 5) & 0xf, &msg[n + 5]); - - /* Add octet count to status */ - n += 9; - - if (b_res != MESH_STATUS_SUCCESS) - break; - - hb->pub_dst = l_get_le16(pkt); - if (hb->pub_dst == UNASSIGNED_ADDRESS || - pkt[2] == 0 || pkt[3] == 0) { - /* - * We might still have a pub_dst here in case - * we need it for State Change heartbeat - */ - hb->pub_count = 0; - hb->pub_period = 0; - } else { - hb->pub_count = (pkt[2] != 0xff) ? - log_to_uint32(pkt[2], 1) : 0xffff; - hb->pub_period = log_to_uint32(pkt[3], 1); - } - - hb->pub_ttl = pkt[4]; - hb->pub_features = l_get_le16(pkt + 5) & 0xf; - hb->pub_net_idx = l_get_le16(pkt + 7); - update_hb_pub_timer(net, hb); - + n = hb_publication_set(node, pkt); break; case OP_CONFIG_HEARTBEAT_PUB_GET: if (size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg); - msg[n++] = b_res; - l_put_le16(hb->pub_dst, msg + n); - n += 2; - msg[n++] = uint32_to_log(hb->pub_count); - msg[n++] = uint32_to_log(hb->pub_period); - msg[n++] = hb->pub_ttl; - l_put_le16(hb->pub_features, msg + n); - n += 2; - l_put_le16(hb->pub_net_idx, msg + n); - n += 2; + n = hb_publication_get(node, MESH_STATUS_SUCCESS); break; case OP_CONFIG_HEARTBEAT_SUB_SET: if (size != 5) return true; - l_debug("Set Sub Period (Log %2.2x) %d sec", - pkt[4], log_to_uint32(pkt[4], 1)); - - b_res = hb_subscription_set(net, l_get_le16(pkt), - l_get_le16(pkt + 2), - pkt[4]); - if (b_res < 0) - return true; + l_debug("Set HB Sub Period Log %2.2x", pkt[4]); - /* Fall through */ + n = hb_subscription_set(node, pkt); + break; case OP_CONFIG_HEARTBEAT_SUB_GET: - if (opcode == OP_CONFIG_HEARTBEAT_SUB_GET && size != 0) - return true; - - gettimeofday(&time_now, NULL); - time_now.tv_sec -= hb->sub_start; - if (time_now.tv_sec >= (long int) hb->sub_period) - time_now.tv_sec = 0; - else - time_now.tv_sec = hb->sub_period - time_now.tv_sec; - - l_debug("Sub Period (Log %2.2x) %d sec", - uint32_to_log(time_now.tv_sec), - (int) time_now.tv_sec); + if (size != 0) + return true; - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); - msg[n++] = b_res; - l_put_le16(hb->sub_src, msg + n); - n += 2; - l_put_le16(hb->sub_dst, msg + n); - n += 2; - msg[n++] = uint32_to_log(time_now.tv_sec); - msg[n++] = uint32_to_log(hb->sub_count); - msg[n++] = hb->sub_count ? hb->sub_min_hops : 0; - msg[n++] = hb->sub_max_hops; + n = hb_subscription_get(node, MESH_STATUS_SUCCESS); break; case OP_CONFIG_POLL_TIMEOUT_GET: @@ -1160,13 +1062,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, static void cfgmod_srv_unregister(void *user_data) { - struct mesh_node *node = user_data; - struct mesh_net *net = node_get_net(node); - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - l_timeout_remove(hb->pub_timer); - l_timeout_remove(hb->sub_timer); - hb->pub_timer = hb->sub_timer = NULL; } static const struct mesh_model_ops ops = { diff --git a/mesh/net.c b/mesh/net.c index b54c647cb..5bfaa181a 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -23,6 +23,8 @@ #define _GNU_SOURCE +#include <sys/time.h> + #include <ell/ell.h> #include "mesh/mesh-defs.h" @@ -132,7 +134,10 @@ struct mesh_net { uint8_t count; } relay; - struct mesh_net_heartbeat heartbeat; + /* Heartbeat info */ + struct mesh_net_heartbeat_sub hb_sub; + struct mesh_net_heartbeat_pub hb_pub; + uint16_t features; struct l_queue *subnets; struct l_queue *msg_cache; @@ -255,35 +260,46 @@ static bool match_friend_key_id(const void *a, const void *b) (key_id == friend->net_key_upd); } -static void idle_mesh_heartbeat_send(void *net) +static void send_hb_publication(void *data) { - mesh_net_heartbeat_send(net); + struct mesh_net *net = data; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + uint8_t msg[4]; + int n = 0; + + if (pub->dst == UNASSIGNED_ADDRESS) + return; + + msg[n++] = NET_OP_HEARTBEAT; + msg[n++] = pub->ttl; + l_put_be16(net->features, msg + n); + n += 2; + + mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), + pub->ttl, 0, 0, pub->dst, msg, n); } static void trigger_heartbeat(struct mesh_net *net, uint16_t feature, - bool in_use) + bool enable) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - - l_debug("%s: %4.4x --> %d", __func__, feature, in_use); + l_debug("HB: %4.4x --> %d", feature, enable); - if (in_use) { - if (net->heartbeat.features & feature) + if (enable) { + if (net->features & feature) return; /* no change */ - hb->features |= feature; + net->features |= feature; } else { - if (!(hb->features & feature)) + if (!(net->features & feature)) return; /* no change */ - hb->features &= ~feature; + net->features &= ~feature; } - if (!(hb->pub_features & feature)) - return; /* not interested in this feature */ - - l_idle_oneshot(idle_mesh_heartbeat_send, net, NULL); + if (!(net->hb_pub.features & feature)) + return; /* no interest in this feature */ + l_idle_oneshot(send_hb_publication, net, NULL); } static bool match_by_friend(const void *a, const void *b) @@ -616,8 +632,6 @@ struct mesh_net *mesh_net_new(struct mesh_node *node) net->destinations = l_queue_new(); net->app_keys = l_queue_new(); - memset(&net->heartbeat, 0, sizeof(net->heartbeat)); - if (!nets) nets = l_queue_new(); @@ -813,8 +827,8 @@ int mesh_net_del_key(struct mesh_net *net, uint16_t idx) appkey_delete_bound_keys(net, idx); /* Disable hearbeat publication on this subnet */ - if (idx == net->heartbeat.pub_net_idx) - net->heartbeat.pub_dst = UNASSIGNED_ADDRESS; + if (idx == net->hb_pub.net_idx) + net->hb_pub.dst = UNASSIGNED_ADDRESS; /* TODO: cancel beacon_enable on this subnet */ @@ -2017,25 +2031,23 @@ static bool ctl_received(struct mesh_net *net, uint16_t key_id, break; case NET_OP_HEARTBEAT: - if (net->heartbeat.sub_enabled && - src == net->heartbeat.sub_src) { + if (net->hb_sub.enabled && src == net->hb_sub.src) { uint8_t hops = pkt[0] - ttl + 1; print_packet("Rx-NET_OP_HEARTBEAT", pkt, len); - if (net->heartbeat.sub_count != 0xffff) - net->heartbeat.sub_count++; + if (net->hb_sub.count != 0xffff) + net->hb_sub.count++; - if (net->heartbeat.sub_min_hops > hops) - net->heartbeat.sub_min_hops = hops; + if (net->hb_sub.min_hops > hops) + net->hb_sub.min_hops = hops; - if (net->heartbeat.sub_max_hops < hops) - net->heartbeat.sub_max_hops = hops; + if (net->hb_sub.max_hops < hops) + net->hb_sub.max_hops = hops; l_debug("HB: cnt:%4.4x min:%2.2x max:%2.2x", - net->heartbeat.sub_count, - net->heartbeat.sub_min_hops, - net->heartbeat.sub_max_hops); + net->hb_sub.count, net->hb_sub.min_hops, + net->hb_sub.max_hops); } break; } @@ -3276,52 +3288,14 @@ int mesh_net_update_key(struct mesh_net *net, uint16_t idx, return MESH_STATUS_SUCCESS; } -static uint16_t get_features(struct mesh_net *net) -{ - uint16_t features = 0; - - if (net->relay.enable) - features |= FEATURE_RELAY; - - if (net->proxy_enable) - features |= FEATURE_PROXY; - - if (net->friend_enable) - features |= FEATURE_FRIEND; - - return features; -} - -struct mesh_net_heartbeat *mesh_net_heartbeat_get(struct mesh_net *net) -{ - return &net->heartbeat; -} - -void mesh_net_heartbeat_send(struct mesh_net *net) +struct mesh_net_heartbeat_sub *mesh_net_get_heartbeat_sub(struct mesh_net *net) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - uint8_t msg[4]; - int n = 0; - - if (hb->pub_dst == UNASSIGNED_ADDRESS) - return; - - msg[n++] = NET_OP_HEARTBEAT; - msg[n++] = hb->pub_ttl; - l_put_be16(hb->features, msg + n); - n += 2; - - mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), - hb->pub_ttl, 0, 0, hb->pub_dst, msg, n); + return &net->hb_sub; } -void mesh_net_heartbeat_init(struct mesh_net *net) +struct mesh_net_heartbeat_pub *mesh_net_get_heartbeat_pub(struct mesh_net *net) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - - memset(hb, 0, sizeof(struct mesh_net_heartbeat)); - hb->sub_min_hops = 0xff; - hb->features = get_features(net); + return &net->hb_pub; } void mesh_net_set_iv_index(struct mesh_net *net, uint32_t index, bool update) @@ -3559,3 +3533,156 @@ void net_msg_add_replay_cache(struct mesh_net *net, uint16_t src, uint32_t seq, /* Optimize so that most recent conversations stay earliest in cache */ l_queue_push_head(net->replay_cache, rpe); } + +static void hb_sub_timeout_func(struct l_timeout *timeout, void *user_data) +{ + struct mesh_net *net = user_data; + struct mesh_net_heartbeat_sub *sub = &net->hb_sub; + + l_debug("HB Subscription Ended"); + l_timeout_remove(sub->timer); + sub->timer = NULL; + sub->enabled = false; +} + +static uint32_t log_to_uint32(uint8_t log) +{ + if (!log) + return 0x0000; + + return (1 << (log - 1)); +} + +int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, + uint8_t period_log) +{ + struct mesh_net_heartbeat_sub *sub = &net->hb_sub; + struct timeval time_now; + + if (!net) + return MESH_STATUS_UNSPECIFIED_ERROR; + + /* Check if the subscription should be disabled */ + if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst)) { + if (IS_GROUP(sub->dst)) + mesh_net_dst_unreg(net, sub->dst); + + sub->enabled = false; + sub->dst = UNASSIGNED_ADDRESS; + sub->src = UNASSIGNED_ADDRESS; + sub->count = 0; + sub->period = 0; + sub->min_hops = 0; + sub->max_hops = 0; + + } else if (!period_log && src == sub->src && dst == sub->dst) { + /* Preserve collected data, but disable */ + sub->enabled = false; + sub->period = 0; + + } else if (sub->dst != dst) { + if (IS_GROUP(sub->dst)) + mesh_net_dst_unreg(net, sub->dst); + + if (IS_GROUP(dst)) + mesh_net_dst_reg(net, dst); + + sub->enabled = !!period_log; + sub->src = src; + sub->dst = dst; + sub->count = 0; + sub->period = log_to_uint32(period_log); + sub->min_hops = 0x00; + sub->max_hops = 0x00; + gettimeofday(&time_now, NULL); + sub->start = time_now.tv_sec; + } + + /* TODO: Save to node config */ + + if (!sub->enabled) { + l_timeout_remove(sub->timer); + sub->timer = NULL; + return MESH_STATUS_SUCCESS; + } + + sub->min_hops = 0xff; + + if (!sub->timer) + sub->timer = l_timeout_create(sub->period, hb_sub_timeout_func, + net, NULL); + else + l_timeout_modify(sub->timer, sub->period); + + return MESH_STATUS_SUCCESS; +} + +static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) +{ + struct mesh_net *net = user_data; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + + send_hb_publication(net); + + if (pub->count != 0xffff) + pub->count--; + + if (pub->count > 0) + l_timeout_modify(pub->timer, pub->period); + else { + l_timeout_remove(pub->timer); + pub->timer = NULL; + } +} + +static void update_hb_pub_timer(struct mesh_net *net, + struct mesh_net_heartbeat_pub *pub) +{ + if (IS_UNASSIGNED(pub->dst) || pub->count == 0) { + l_timeout_remove(pub->timer); + pub->timer = NULL; + return; + } + + if (!pub->timer) + pub->timer = l_timeout_create(pub->period, + hb_pub_timeout_func, net, NULL); + else + l_timeout_modify(pub->timer, pub->period); +} + +int mesh_net_set_heartbeat_pub(struct mesh_net *net, uint16_t dst, + uint16_t features, uint16_t idx, uint8_t ttl, + uint8_t count_log, uint8_t period_log) +{ + struct mesh_subnet *subnet; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + + if (!net) + return MESH_STATUS_UNSPECIFIED_ERROR; + + subnet = l_queue_find(net->subnets, match_key_index, + L_UINT_TO_PTR(idx)); + if (!subnet) + return MESH_STATUS_INVALID_NETKEY; + + pub->dst = dst; + + if (pub->dst == UNASSIGNED_ADDRESS) { + pub->count = 0; + pub->period = 0; + pub->ttl = 0; + } else { + pub->count = (count_log != 0xff) ? + log_to_uint32(count_log) : 0xffff; + pub->period = log_to_uint32(period_log); + } + + pub->ttl = ttl; + pub->features = features; + pub->net_idx = idx; + update_hb_pub_timer(net, pub); + + /* TODO: Save to node config */ + return MESH_STATUS_SUCCESS; +} diff --git a/mesh/net.h b/mesh/net.h index 7117f1a47..0e36ab068 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -131,25 +131,27 @@ struct mesh_net_prov_caps { uint16_t input_action; } __packed; -struct mesh_net_heartbeat { - struct l_timeout *pub_timer; - struct l_timeout *sub_timer; - struct timeval sub_time; - bool sub_enabled; - uint32_t pub_period; - uint32_t sub_period; - uint32_t sub_start; - uint16_t pub_dst; - uint16_t pub_count; - uint16_t pub_features; +struct mesh_net_heartbeat_sub { + struct l_timeout *timer; + uint32_t start; + uint32_t period; uint16_t features; - uint16_t pub_net_idx; - uint16_t sub_src; - uint16_t sub_dst; - uint16_t sub_count; - uint8_t pub_ttl; - uint8_t sub_min_hops; - uint8_t sub_max_hops; + uint16_t src; + uint16_t dst; + uint16_t count; + bool enabled; + uint8_t min_hops; + uint8_t max_hops; +}; + +struct mesh_net_heartbeat_pub { + struct l_timeout *timer; + uint32_t period; + uint16_t dst; + uint16_t count; + uint16_t features; + uint16_t net_idx; + uint8_t ttl; }; struct mesh_key_set { @@ -330,9 +332,13 @@ void mesh_net_send_seg(struct mesh_net *net, uint32_t key_id, uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t src, uint16_t dst, uint32_t hdr, const void *seg, uint16_t seg_len); -struct mesh_net_heartbeat *mesh_net_heartbeat_get(struct mesh_net *net); -void mesh_net_heartbeat_init(struct mesh_net *net); -void mesh_net_heartbeat_send(struct mesh_net *net); +struct mesh_net_heartbeat_sub *mesh_net_get_heartbeat_sub(struct mesh_net *net); +int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, + uint8_t period_log); +struct mesh_net_heartbeat_pub *mesh_net_get_heartbeat_pub(struct mesh_net *net); +int mesh_net_set_heartbeat_pub(struct mesh_net *net, uint16_t dst, + uint16_t features, uint16_t idx, uint8_t ttl, + uint8_t count_log, uint8_t period_log); bool mesh_net_key_list_get(struct mesh_net *net, uint8_t *buf, uint16_t *count); uint16_t mesh_net_get_primary_idx(struct mesh_net *net); uint32_t mesh_net_friend_timeout(struct mesh_net *net, uint16_t addr); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EAL8GSS4I188PwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 08:20:20 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wPATGCS4I18keQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 08:20:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E800941432; Fri, 31 Jul 2020 08:20:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731424AbgGaGTo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 02:19:44 -0400 Received: from mga06.intel.com ([134.134.136.31]:44826 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731359AbgGaGTn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 02:19:43 -0400 IronPort-SDR: mDFSXu0C0Z37OFt5RWKP4tPuT1UqmMv5b99wT3cXk5TPuizLjR/CQtudgaGqApv7TYm9EnyJgy KEybt3zCPKSQ== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="213269546" X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="213269546" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 23:19:37 -0700 IronPort-SDR: IYrhxq1O9BjhIuaiHXwLjFqUIFZifo0woJrNrLQNxhCDEnTqIkb2h6yF/4bsgfsjnEc2eSdbGC NwN/OOZXCH8w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="329163333" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jul 2020 23:19:37 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 01/10] mesh: Clean up handling of config subscription messages Date: Thu, 30 Jul 2020 23:19:27 -0700 Message-Id: <20200731061936.56952-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: E800941432 X-Rspamd-UID: 6992d9 This provides better functional grouping based on whether a group or a virtual label is used for the subscription address. Also, use a single point for sending out the composed Config Server status messages. --- mesh/cfgmod-server.c | 344 +++++++++++++++++----------------------- mesh/mesh-config-json.c | 12 +- mesh/mesh-config.h | 6 +- mesh/model.c | 211 ++++++++++++++---------- mesh/model.h | 21 ++- 5 files changed, 296 insertions(+), 298 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 7672ad3b6..cd0e8b94c 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -32,6 +32,10 @@ #include "mesh/mesh-config.h" #include "mesh/cfgmod.h" +#define CFG_SET_ID(vendor, pkt) ((vendor) ? \ + (SET_ID(l_get_le16((pkt)), l_get_le16((pkt) + 2))) : \ + (SET_ID(SIG_VENDOR, l_get_le16(pkt)))) + /* Supported composition pages, sorted high to low */ /* Only page 0 is currently supported */ static const uint8_t supported_pages[] = { @@ -185,237 +189,177 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, idx, cred_flag, ttl, period, retransmit); } -static void send_sub_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, - uint16_t addr, uint32_t id) +static uint16_t cfg_sub_get_msg(struct mesh_node *node, const uint8_t *pkt, + uint16_t size) { - int n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - - msg[n++] = status; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(addr, msg + n); - n += 2; - - if (IS_VENDOR(id)) { - l_put_le16(VENDOR_ID(id), msg + n); - l_put_le16(MODEL_ID(id), msg + n + 2); - n += 4; - } else { - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - } - - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); -} - -static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size) -{ - uint16_t ele_addr; + uint16_t ele_addr, n, sub_len; uint32_t id; - uint16_t n = 0; - int status; - uint8_t *msg_status; - uint16_t buf_size; + int opcode; + bool vendor = (size == 6); - /* Incoming message has already been size-checked */ ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); + opcode = vendor ? OP_CONFIG_VEND_MODEL_SUB_LIST : + OP_CONFIG_MODEL_SUB_LIST; + n = mesh_model_opcode_set(opcode, msg); + memcpy(msg + n + 1, pkt, size); - switch (size) { - default: - l_debug("Bad length %d", size); - return false; - - case 4: - id = l_get_le16(pkt + 2); - n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_LIST, msg); - msg_status = msg + n; - msg[n++] = 0; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(id, msg + n); - n += 2; - id = SET_ID(SIG_VENDOR, id); - break; - - case 6: - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - n = mesh_model_opcode_set(OP_CONFIG_VEND_MODEL_SUB_LIST, msg); - msg_status = msg + n; - msg[n++] = 0; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(VENDOR_ID(id), msg + n); - n += 2; - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - break; - } - - buf_size = sizeof(uint16_t) * MAX_GRP_PER_MOD; - status = mesh_model_sub_get(node, ele_addr, id, msg + n, buf_size, - &size); - - if (status == MESH_STATUS_SUCCESS) - n += size; + msg[n] = mesh_model_sub_get(node, ele_addr, id, msg + n + 1 + size, + MAX_MSG_LEN - (n + 1 + size), &sub_len); - *msg_status = (uint8_t) status; + if (msg[n] == MESH_STATUS_SUCCESS) + n += sub_len; - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); - return true; + n += (size + 1); + return n; } -static bool save_config_sub(struct mesh_node *node, uint16_t ele_addr, - uint32_t id, bool vendor, - const uint8_t *addr, bool virt, - uint16_t grp, uint32_t opcode) +static bool save_cfg_sub(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, bool vendor, const uint8_t *label, + bool virt, uint16_t grp, uint32_t opcode) { + struct mesh_config *cfg = node_config_get(node); struct mesh_config_sub db_sub = { .virt = virt, - .src.addr = grp + .addr.grp = grp }; + id = (vendor) ? id : MODEL_ID(id); + if (virt) - memcpy(db_sub.src.virt_addr, addr, 16); + memcpy(db_sub.addr.label, label, 16); + + if (opcode == OP_CONFIG_MODEL_SUB_VIRT_DELETE && + opcode == OP_CONFIG_MODEL_SUB_DELETE) + return mesh_config_model_sub_del(cfg, ele_addr, id, vendor, + &db_sub); if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE || opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) - mesh_config_model_sub_del_all(node_config_get(node), ele_addr, - vendor ? id : MODEL_ID(id), - vendor); - if (opcode != OP_CONFIG_MODEL_SUB_VIRT_DELETE && - opcode != OP_CONFIG_MODEL_SUB_DELETE) - return mesh_config_model_sub_add(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_sub); - else - return mesh_config_model_sub_del(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_sub); + if (!mesh_config_model_sub_del_all(cfg, ele_addr, id, vendor)) + return false; + + return mesh_config_model_sub_add(cfg, ele_addr, id, vendor, &db_sub); } -static void config_sub_set(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size, - bool virt, uint32_t opcode) +static uint16_t cfg_sub_add_msg(struct mesh_node *node, const uint8_t *pkt, + bool vendor, uint32_t opcode) { - uint16_t grp, ele_addr; + uint16_t addr, ele_addr, n; uint32_t id; - const uint8_t *addr = NULL; - int status = MESH_STATUS_SUCCESS; - bool vendor = false; - switch (size) { - default: - l_error("Bad length: %d", size); - return; - case 4: - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) - return; + addr = l_get_le16(pkt + 2); - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); - break; - case 6: - if (virt) - return; + if (!IS_GROUP(addr)) + return 0; - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); - } else { - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - vendor = true; - } + ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 4); - break; - case 8: - if (virt) - return; + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); - vendor = true; - break; - case 20: - if (!virt) - return; + if (opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) + msg[n] = mesh_model_sub_ovrt(node, ele_addr, id, addr); + else if (opcode == OP_CONFIG_MODEL_SUB_ADD) + msg[n] = mesh_model_sub_add(node, ele_addr, id, addr); + else + msg[n] = mesh_model_sub_del(node, ele_addr, id, addr); - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 18)); - break; - case 22: - if (!virt) - return; + if (msg[n] == MESH_STATUS_SUCCESS && + !save_cfg_sub(node, ele_addr, id, vendor, NULL, false, + addr, opcode)) + msg[n] = MESH_STATUS_STORAGE_FAIL; - vendor = true; - id = SET_ID(l_get_le16(pkt + 18), l_get_le16(pkt + 20)); - break; + if (vendor) { + memcpy(msg + n + 1, pkt, 8); + n += 9; + } else { + memcpy(msg + n + 1, pkt, 6); + n += 7; } + return n; +} + +static uint16_t cfg_virt_sub_add_msg(struct mesh_node *node, const uint8_t *pkt, + bool vendor, uint32_t opcode) +{ + uint16_t addr, ele_addr, n; + uint32_t id; + const uint8_t *label; + + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); + ele_addr = l_get_le16(pkt); + label = pkt + 2; + id = CFG_SET_ID(vendor, pkt + 18); + + if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE) + msg[n] = mesh_model_virt_sub_ovrt(node, ele_addr, id, label, + &addr); + else if (opcode == OP_CONFIG_MODEL_SUB_VIRT_ADD) + msg[n] = mesh_model_virt_sub_add(node, ele_addr, id, label, + &addr); + else + msg[n] = mesh_model_virt_sub_del(node, ele_addr, id, label, + &addr); - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - addr = pkt + 2; - grp = l_get_le16(addr); - } else - grp = UNASSIGNED_ADDRESS; + if (msg[n] == MESH_STATUS_SUCCESS && + !save_cfg_sub(node, ele_addr, id, vendor, + label, true, addr, opcode)) + msg[n] = MESH_STATUS_STORAGE_FAIL; - switch (opcode) { - default: - l_debug("Bad opcode: %x", opcode); - return; + l_put_le16(ele_addr, msg + n + 1); + l_put_le16(addr, msg + n + 3); - case OP_CONFIG_MODEL_SUB_DELETE_ALL: - status = mesh_model_sub_del_all(node, ele_addr, id); + if (vendor) { + l_put_le16(VENDOR_ID(id), msg + n + 5); + l_put_le16(MODEL_ID(id), msg + n + 7); + n += 9; + } else { + l_put_le16(MODEL_ID(id), msg + n + 5); + n += 7; + } - if (status == MESH_STATUS_SUCCESS) - mesh_config_model_sub_del_all(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor); - break; + return n; +} - case OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_OVERWRITE: - status = mesh_model_sub_ovr(node, ele_addr, id, - addr, virt, &grp); +static uint16_t config_sub_del_all(struct mesh_node *node, const uint8_t *pkt, + bool vendor) +{ + uint16_t ele_addr, n, grp = UNASSIGNED_ADDRESS; + uint32_t id; - if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, id, vendor, addr, - virt, grp, opcode); - break; - case OP_CONFIG_MODEL_SUB_VIRT_ADD: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_ADD: - status = mesh_model_sub_add(node, ele_addr, id, - addr, virt, &grp); + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - if (status == MESH_STATUS_SUCCESS && - !save_config_sub(node, ele_addr, id, vendor, - addr, virt, grp, opcode)) - status = MESH_STATUS_STORAGE_FAIL; + ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); - break; - case OP_CONFIG_MODEL_SUB_VIRT_DELETE: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_DELETE: - status = mesh_model_sub_del(node, ele_addr, id, addr, virt, - &grp); + msg[n] = mesh_model_sub_del_all(node, ele_addr, id); - if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, id, vendor, addr, - virt, grp, opcode); + if (msg[n] == MESH_STATUS_SUCCESS) { + struct mesh_config *cfg = node_config_get(node); - break; + if (!mesh_config_model_sub_del_all(cfg, ele_addr, + vendor ? id : MODEL_ID(id), + vendor)) + msg[n] = MESH_STATUS_STORAGE_FAIL; + } + + l_put_le16(ele_addr, msg + n + 1); + l_put_le16(grp, msg + n + 3); + + if (vendor) { + l_put_le16(VENDOR_ID(id), msg + n + 5); + l_put_le16(MODEL_ID(id), msg + n + 7); + n += 9; + } else { + l_put_le16(MODEL_ID(id), msg + n + 5); + n += 7; } - send_sub_status(node, net_idx, src, dst, status, ele_addr, grp, id); + return n; } static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, @@ -797,28 +741,38 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_VEND_MODEL_SUB_GET: if (size != 6) return true; - - config_sub_get(node, net_idx, src, dst, pkt, size); - break; + /* Fall Through */ case OP_CONFIG_MODEL_SUB_GET: - if (size != 4) + if (size != 4 && opcode == OP_CONFIG_MODEL_SUB_GET) return true; - config_sub_get(node, net_idx, src, dst, pkt, size); + n = cfg_sub_get_msg(node, pkt, size); break; case OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE: case OP_CONFIG_MODEL_SUB_VIRT_DELETE: case OP_CONFIG_MODEL_SUB_VIRT_ADD: - virt = true; - /* Fall Through */ + if (size != 20 && size != 22) + return true; + + n = cfg_virt_sub_add_msg(node, pkt, size == 22, opcode); + break; + case OP_CONFIG_MODEL_SUB_OVERWRITE: case OP_CONFIG_MODEL_SUB_DELETE: case OP_CONFIG_MODEL_SUB_ADD: + if (size != 6 && size != 8) + return true; + + n = cfg_sub_add_msg(node, pkt, size == 8, opcode); + break; + case OP_CONFIG_MODEL_SUB_DELETE_ALL: - config_sub_set(node, net_idx, src, dst, pkt, size, virt, - opcode); + if (size != 4 && size != 6) + return true; + + n = config_sub_del_all(node, pkt, size == 6); break; case OP_CONFIG_RELAY_SET: diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index deb0019f9..a40f92c01 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1069,11 +1069,11 @@ static bool parse_model_subscriptions(json_object *jsubs, switch (len) { case 4: - if (sscanf(str, "%04hx", &subs[i].src.addr) != 1) + if (sscanf(str, "%04hx", &subs[i].addr.grp) != 1) goto fail; break; case 32: - if (!str2hex(str, len, subs[i].src.virt_addr, 16)) + if (!str2hex(str, len, subs[i].addr.label, 16)) goto fail; subs[i].virt = true; break; @@ -2068,10 +2068,10 @@ bool mesh_config_model_sub_add(struct mesh_config *cfg, uint16_t ele_addr, return false; if (!sub->virt) { - snprintf(buf, 5, "%4.4x", sub->src.addr); + snprintf(buf, 5, "%4.4x", sub->addr.grp); len = 4; } else { - hex2str(sub->src.virt_addr, 16, buf, 33); + hex2str(sub->addr.label, 16, buf, 33); len = 32; } @@ -2122,10 +2122,10 @@ bool mesh_config_model_sub_del(struct mesh_config *cfg, uint16_t ele_addr, return true; if (!sub->virt) { - snprintf(buf, 5, "%4.4x", sub->src.addr); + snprintf(buf, 5, "%4.4x", sub->addr.grp); len = 4; } else { - hex2str(sub->src.virt_addr, 16, buf, 33); + hex2str(sub->addr.label, 16, buf, 33); len = 32; } diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 7dfa9f20c..f15f3f376 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -24,9 +24,9 @@ struct mesh_config; struct mesh_config_sub { bool virt; union { - uint16_t addr; - uint8_t virt_addr[16]; - } src; + uint16_t grp; + uint8_t label[16]; + } addr; }; struct mesh_config_pub { diff --git a/mesh/model.c b/mesh/model.c index ef7668147..3c9b6577a 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -664,7 +664,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } - if (l_queue_length(mod->bindings) >= MAX_BINDINGS) + if (l_queue_length(mod->bindings) >= MAX_MODEL_BINDINGS) return MESH_STATUS_INSUFF_RESOURCES; if (!mesh_config_model_binding_add(node_config_get(node), addr, @@ -737,7 +737,7 @@ static int set_virt_pub(struct mesh_model *mod, const uint8_t *label, } static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod, - const uint8_t *label, uint16_t *dst) + const uint8_t *label, uint16_t *addr) { struct mesh_virtual *virt = l_queue_find(mod->virtuals, find_virt_by_label, label); @@ -745,40 +745,35 @@ static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod, if (!virt) { virt = add_virtual(label); if (!virt) - return MESH_STATUS_STORAGE_FAIL; + return MESH_STATUS_INSUFF_RESOURCES; l_queue_push_head(mod->virtuals, virt); mesh_net_dst_reg(net, virt->addr); l_debug("Added virtual sub addr %4.4x", virt->addr); } - if (dst) - *dst = virt->addr; + if (addr) + *addr = virt->addr; return MESH_STATUS_SUCCESS; } static int add_sub(struct mesh_net *net, struct mesh_model *mod, - const uint8_t *group, bool b_virt, uint16_t *dst) + uint16_t addr) { - uint16_t grp; - - if (b_virt) - return add_virt_sub(net, mod, group, dst); - - grp = l_get_le16(group); - if (dst) - *dst = grp; + if (!mod->subs) + mod->subs = l_queue_new(); - if (!l_queue_find(mod->subs, simple_match, L_UINT_TO_PTR(grp))) { + if (l_queue_find(mod->subs, simple_match, L_UINT_TO_PTR(addr))) + return MESH_STATUS_SUCCESS; - if (!mod->subs) - mod->subs = l_queue_new(); + if ((l_queue_length(mod->subs) + l_queue_length(mod->virtuals)) >= + MAX_MODEL_SUBS) + return MESH_STATUS_INSUFF_RESOURCES; - l_queue_push_tail(mod->subs, L_UINT_TO_PTR(grp)); - mesh_net_dst_reg(net, grp); - l_debug("Added group subscription %4.4x", grp); - } + l_queue_push_tail(mod->subs, L_UINT_TO_PTR(addr)); + mesh_net_dst_reg(net, addr); + l_debug("Added group subscription %4.4x", addr); return MESH_STATUS_SUCCESS; } @@ -1454,8 +1449,8 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { struct mesh_model *mod; int status, ele_idx = node_get_element_idx(node, addr); @@ -1470,7 +1465,35 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - status = add_sub(node_get_net(node), mod, group, is_virt, dst); + status = add_sub(node_get_net(node), mod, addr); + if (status != MESH_STATUS_SUCCESS) + return status; + + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); + + return MESH_STATUS_SUCCESS; +} + +int mesh_model_virt_sub_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *pub_addr) +{ + struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; + + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + + status = add_virt_sub(node_get_net(node), mod, label, pub_addr); if (status != MESH_STATUS_SUCCESS) return status; @@ -1482,12 +1505,11 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { - struct l_queue *virtuals, *subs; struct mesh_model *mod; - int status, ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1499,36 +1521,39 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - subs = mod->subs; - virtuals = mod->virtuals; - mod->subs = l_queue_new(); - mod->virtuals = l_queue_new(); + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); - if (!mod->subs || !mod->virtuals) - return MESH_STATUS_INSUFF_RESOURCES; + add_sub(node_get_net(node), mod, addr); - status = add_sub(node_get_net(node), mod, group, is_virt, dst); + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); - if (status != MESH_STATUS_SUCCESS) { - /* Adding new group failed, so revert to old lists */ - l_queue_destroy(mod->subs, NULL); - mod->subs = subs; - l_queue_destroy(mod->virtuals, unref_virt); - mod->virtuals = virtuals; - } else { - const struct l_queue_entry *entry; - struct mesh_net *net = node_get_net(node); + return MESH_STATUS_SUCCESS; +} + +int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr) +{ + struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; - entry = l_queue_get_entries(subs); + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; - for (; entry; entry = entry->next) - mesh_net_dst_unreg(net, - (uint16_t) L_PTR_TO_UINT(entry->data)); + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); - /* Destroy old lists */ - l_queue_destroy(subs, NULL); - l_queue_destroy(virtuals, unref_virt); - } + status = add_virt_sub(node_get_net(node), mod, label, addr); if (!mod->cbs) /* External models */ @@ -1537,10 +1562,9 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, return status; } -int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { - uint16_t grp; struct mesh_model *mod; int ele_idx = node_get_element_idx(node, addr); @@ -1554,26 +1578,47 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - if (is_virt) { - struct mesh_virtual *virt; + if (l_queue_remove(mod->subs, L_UINT_TO_PTR(addr))) { + mesh_net_dst_unreg(node_get_net(node), addr); - virt = l_queue_find(mod->virtuals, find_virt_by_label, group); - if (virt) { - l_queue_remove(mod->virtuals, virt); - grp = virt->addr; - unref_virt(virt); - } else { - if (!mesh_crypto_virtual_addr(group, &grp)) - return MESH_STATUS_STORAGE_FAIL; - } - } else { - grp = l_get_le16(group); + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); } - *dst = grp; + return MESH_STATUS_SUCCESS; +} - if (l_queue_remove(mod->subs, L_UINT_TO_PTR(grp))) { - mesh_net_dst_unreg(node_get_net(node), grp); +int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr) +{ + struct mesh_model *mod; + struct mesh_virtual *virt; + int ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; + + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + + virt = l_queue_remove_if(mod->virtuals, find_virt_by_label, label); + + if (virt) { + *addr = virt->addr; + unref_virt(virt); + } else { + *addr = UNASSIGNED_ADDRESS; + return MESH_STATUS_SUCCESS; + } + + if (l_queue_remove(mod->subs, L_UINT_TO_PTR(*addr))) { + mesh_net_dst_unreg(node_get_net(node), *addr); if (!mod->cbs) /* External models */ @@ -1614,9 +1659,9 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, struct mesh_config_pub *pub = db_mod->pub; uint32_t i; - if (db_mod->num_bindings > MAX_BINDINGS) { + if (db_mod->num_bindings > MAX_MODEL_BINDINGS) { l_warn("Binding list too long %u (max %u)", - db_mod->num_bindings, MAX_BINDINGS); + db_mod->num_bindings, MAX_MODEL_BINDINGS); return NULL; } @@ -1670,22 +1715,12 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, return mod; for (i = 0; i < db_mod->num_subs; i++) { - uint16_t group; - uint8_t *src; + struct mesh_config_sub *sub = &db_mod->subs[i]; - /* - * To keep calculations for virtual label coherent, - * convert to little endian. - */ - l_put_le16(db_mod->subs[i].src.addr, &group); - src = db_mod->subs[i].virt ? db_mod->subs[i].src.virt_addr : - (uint8_t *) &group; - - if (add_sub(net, mod, src, db_mod->subs[i].virt, NULL) != - MESH_STATUS_SUCCESS) { - mesh_model_free(mod); - return NULL; - } + if (!sub->virt) + add_sub(net, mod, sub->addr.grp); + else + add_virt_sub(net, mod, sub->addr.label, NULL); } return mod; diff --git a/mesh/model.h b/mesh/model.h index 0d8dddf92..3221379af 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -19,8 +19,8 @@ struct mesh_model; -#define MAX_BINDINGS 10 -#define MAX_GRP_PER_MOD 10 +#define MAX_MODEL_BINDINGS 10 +#define MAX_MODEL_SUBS 10 #define ACTION_ADD 1 #define ACTION_UPDATE 2 @@ -89,12 +89,21 @@ int mesh_model_get_bindings(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_sz, uint16_t *len); int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); + uint16_t grp); +int mesh_model_virt_sub_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); + uint16_t grp); +int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id); -int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); +int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr); +int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size); uint16_t mesh_model_cfg_blk(uint8_t *pkt); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cCh2GfxtI198MwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 03:03:56 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id YGwCGPxtI1+SfgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 03:03:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EB485A11E2; Fri, 31 Jul 2020 03:03:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730935AbgGaBDs (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 21:03:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728080AbgGaBDq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 21:03:46 -0400 Received: from mail-ua1-x944.google.com (mail-ua1-x944.google.com [IPv6:2607:f8b0:4864:20::944]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F532C061575 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 18:03:46 -0700 (PDT) Received: by mail-ua1-x944.google.com with SMTP id x19so3126785uap.11 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 18:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+wYtuIahi8xNh+qop7NMQ+Yr+S+J0oeXKPSMxVb1bcQ=; b=U1ti9bzZVkEsMGU9J987jd2ZK0f6QCFMDKXM9k1cURTKlSGcpWmsd1rMe8Q6ZciIwG 5rIvIbku0CzxrRGLkUHvGNomS6Iirng6oNr4/JFCCTBicF1Vl3HCyCLI72l5/LvvJlLq TOHkrIYj0pcr7DRGzkq3Nh1GrRqwCsNPZ2PJI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+wYtuIahi8xNh+qop7NMQ+Yr+S+J0oeXKPSMxVb1bcQ=; b=WQISSYEsV06/rYTac5un7lGWnAyFtCrnjml1L17rRurrIbHucVM9qAywermA69yPj9 5+eI63iS+BNbvqvVoTqS+6f2ZvYRDARbr91qOcKmV+Wudxy6xnW+etY2+fCn3D4DNo1v F9mZp9GTWQGKh1RUGZX/cFRR1cSgSv9am9rpmLVffOT9R0KCuboC4um72zYpoThrDTd1 BsfJJxqsfdjseJvXvZhN6rwQL7uWi0J5d9AIN3+rdwQSeZ+kRy1SoZ9ab7oSJTDeFYUI TCJlA139hEUIQabhu23ThJJ68TBuwTok/zH52IZ8+B6ePQcaBQwqBHx4SQUlF2tPb0Bg M2Kg== X-Gm-Message-State: AOAM533u998IYkZavK+NpiXSqFOE7cQ+W5K1pG2VFZJaPl4nDQPGDqex 6QgkMjjQJvBYa9yb25MbEGDDTRn6ClQ= X-Google-Smtp-Source: ABdhPJzoO0IjdqbCE+WghcbqxucCMzEI6b7DEcMohE032wh0ib5aQDd+oMsfMOXvvGriISz1KPtzLA== X-Received: by 2002:ab0:6585:: with SMTP id v5mr1046266uam.73.1596157424888; Thu, 30 Jul 2020 18:03:44 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id r5sm1023993vkf.20.2020.07.30.18.03.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 18:03:44 -0700 (PDT) From: Alain Michaud <alainm@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Yu Liu <yudilu@google.com> Subject: [PATCH] Bluetooth: use the proper scan params when conn is pending Date: Fri, 31 Jul 2020 01:03:41 +0000 Message-Id: <20200731010341.1421926-1-alainm@chromium.org> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: EB485A11E2 X-Rspamd-UID: 11c923 When an LE connection is requested and an RPA update is needed via hci_connect_le_scan, the default scanning parameters are used rather than the connect parameters. This leads to significant delays in the connection establishment process when using lower duty cycle scanning parameters. The patch simply looks at the pended connection list when trying to determine which scanning parameters should be used. Before: < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8                             #378 [hci0] 1659.247156         Own address type: Public (0x00)         Filter policy: Ignore not in white list (0x01)         PHYs: 0x01         Entry 0: LE 1M           Type: Passive (0x00)           Interval: 367.500 msec (0x024c)           Window: 37.500 msec (0x003c) After: < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8                               #39 [hci0] 7.422109         Own address type: Public (0x00)         Filter policy: Ignore not in white list (0x01)         PHYs: 0x01         Entry 0: LE 1M           Type: Passive (0x00)           Interval: 60.000 msec (0x0060)           Window: 60.000 msec (0x0060) Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Yu Liu <yudilu@google.com> Signed-off-by: Alain Michaud <alainm@chromium.org> --- net/bluetooth/hci_request.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 435400a43a78..e0269192f2e5 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -953,6 +953,27 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, } } +/* Returns true if an le connection is in the scanning state */ +static inline bool hci_is_le_conn_scanning(struct hci_dev *hdev) +{ + struct hci_conn_hash *h = &hdev->conn_hash; + struct hci_conn *c; + + rcu_read_lock(); + + list_for_each_entry_rcu(c, &h->list, list) { + if (c->type == LE_LINK && c->state == BT_CONNECT && + test_bit(HCI_CONN_SCANNING, &c->flags)) { + rcu_read_unlock(); + return true; + } + } + + rcu_read_unlock(); + + return false; +} + /* Ensure to call hci_req_add_le_scan_disable() first to disable the * controller based address resolution to be able to reconfigure * resolving list. @@ -1003,6 +1024,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) if (hdev->suspended) { window = hdev->le_scan_window_suspend; interval = hdev->le_scan_int_suspend; + } else if (hci_is_le_conn_scanning(hdev)) { + window = hdev->le_scan_window_connect; + interval = hdev->le_scan_int_connect; } else { window = hdev->le_scan_window; interval = hdev->le_scan_interval; -- 2.28.0.163.g6104cc2f0b6-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UFmYNmluI198MwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 03:05:45 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wAnKNGluI1+1jgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 03:05:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 863D9A1883; Fri, 31 Jul 2020 03:05:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728588AbgGaBFk (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 21:05:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728080AbgGaBFj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 21:05:39 -0400 Received: from mail-vs1-xe43.google.com (mail-vs1-xe43.google.com [IPv6:2607:f8b0:4864:20::e43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD361C061574 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 18:05:39 -0700 (PDT) Received: by mail-vs1-xe43.google.com with SMTP id s20so14968169vsq.5 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 18:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XL5rU5YC60frM3gP4UMCvKHyUzU+TZFJvAqINKMI6/E=; b=C8l0mXCQI4PP7k7BzBzwn63GljjNdROnpiBppAXoHj8EuD5jzgQeauXCNdEq0bkOyG cQazyxuAMC0HhsLQDMhNoya2W4bAtSN3cjm00MJv55Mvmxqhmsqn0lAihFXIbybfAQk4 tw6VM7v6heHmWB6J8p8xfBfPUGGK60CUc485k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XL5rU5YC60frM3gP4UMCvKHyUzU+TZFJvAqINKMI6/E=; b=jF8dFVfLNDleaLs6zkPUtDxN+iTL25XeE0Hj9b/2FPgywaTa7GELJn2lyPzXQ49pv2 RQa7Xs+Z1OCkNLuTALbrgib/uPWWjIO3WdjKcP6W7TKA2PoSN3YRqUq3z+aDJfpObGff FpdMdVLM/65eYrNy+8SedO3M12CY+XaVtL/Fxnk8G/q/77ENn1LzEVNg4WKzRulmGCLZ qPHWixz6eQS36dLYLv3Nl75ya+ojJ12Sk6jjeORj+bM9eAEzEAPsiLX8K14e0LAmt6KM kJ06gdyBpPh+puFC7GhDm2LMP1siuSSKHlJKz/ozD6p/le8qO7X5pShM7CUR130MX6K2 xlLg== X-Gm-Message-State: AOAM531yRCtb+LSODm2behYTI8HIk4Xv7yEqtCXBvdyTr9xiGK2Ohy4U U3vrlghh5GK5A78xzRL4Zi8KyVwSujo= X-Google-Smtp-Source: ABdhPJzrwa6/9L8GG30Dt/jpgz3bqBnMkSBKMB4UmarP2YKaOViUJ7X+/zWSnq40NhBahCLfyA6tGQ== X-Received: by 2002:a67:eb92:: with SMTP id e18mr1486085vso.96.1596157538598; Thu, 30 Jul 2020 18:05:38 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id n62sm1009914vke.12.2020.07.30.18.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 18:05:37 -0700 (PDT) From: Alain Michaud <alainm@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Yu Liu <yudiliu@google.com> Subject: [PATCH v2] Bluetooth: use the proper scan params when conn is pending Date: Fri, 31 Jul 2020 01:05:34 +0000 Message-Id: <20200731010535.1422455-1-alainm@chromium.org> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 863D9A1883 X-Rspamd-UID: 1a672f When an LE connection is requested and an RPA update is needed via hci_connect_le_scan, the default scanning parameters are used rather than the connect parameters. This leads to significant delays in the connection establishment process when using lower duty cycle scanning parameters. The patch simply looks at the pended connection list when trying to determine which scanning parameters should be used. Before: < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8                             #378 [hci0] 1659.247156         Own address type: Public (0x00)         Filter policy: Ignore not in white list (0x01)         PHYs: 0x01         Entry 0: LE 1M           Type: Passive (0x00)           Interval: 367.500 msec (0x024c)           Window: 37.500 msec (0x003c) After: < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8                               #39 [hci0] 7.422109         Own address type: Public (0x00)         Filter policy: Ignore not in white list (0x01)         PHYs: 0x01         Entry 0: LE 1M           Type: Passive (0x00)           Interval: 60.000 msec (0x0060)           Window: 60.000 msec (0x0060) Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Yu Liu <yudiliu@google.com> Signed-off-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: - Fixing Yu's email tag net/bluetooth/hci_request.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 435400a43a78..e0269192f2e5 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -953,6 +953,27 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, } } +/* Returns true if an le connection is in the scanning state */ +static inline bool hci_is_le_conn_scanning(struct hci_dev *hdev) +{ + struct hci_conn_hash *h = &hdev->conn_hash; + struct hci_conn *c; + + rcu_read_lock(); + + list_for_each_entry_rcu(c, &h->list, list) { + if (c->type == LE_LINK && c->state == BT_CONNECT && + test_bit(HCI_CONN_SCANNING, &c->flags)) { + rcu_read_unlock(); + return true; + } + } + + rcu_read_unlock(); + + return false; +} + /* Ensure to call hci_req_add_le_scan_disable() first to disable the * controller based address resolution to be able to reconfigure * resolving list. @@ -1003,6 +1024,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) if (hdev->suspended) { window = hdev->le_scan_window_suspend; interval = hdev->le_scan_int_suspend; + } else if (hci_is_le_conn_scanning(hdev)) { + window = hdev->le_scan_window_connect; + interval = hdev->le_scan_int_connect; } else { window = hdev->le_scan_window; interval = hdev->le_scan_interval; -- 2.28.0.163.g6104cc2f0b6-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qJ7UFmOMI19GnwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 05:13:39 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id MKMhFWOMI1/YXQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 05:13:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 04C2FA01FB; Fri, 31 Jul 2020 05:13:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731321AbgGaDN3 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 23:13:29 -0400 Received: from mail-io1-f69.google.com ([209.85.166.69]:47893 "EHLO mail-io1-f69.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731203AbgGaDNY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 23:13:24 -0400 Received: by mail-io1-f69.google.com with SMTP id d22so20040651iom.14 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 20:13:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=/pC2jX1hCFTSa0XcmmFAvUUMdwWwZxAez1TyfC9ev/c=; b=niyBS/hnI58cPn9bjZ8m69cM6KGmdJu0fS+Pzrd0UcnQwMDmwYau5NmtoqRwySUAX3 XYff02dAbBnBZRR59M/ahQSCpGHYHL2mkG1uq79ME9qpEJL/H7Dhllr0a2pf/QHDaJDA enrqpExT1dNltRiBS0DMFi5fYJ0IoifiuOvN+XHWuk3hQ88dQo3e4Zfz/BK2TlXZlM8F NwUoI2252/uecHBu4NRJMdePCbeZFRZi1UDzUDjzaNmtrRMZCl3m3Rmw5uDYSIPRSjGd ur5usBLO4ADWiGdlAefErWQ2AEhih17nNtNixcl8xByvCW60CAtmU0yKAaXKm9avfFBk KXLw== X-Gm-Message-State: AOAM5301RJdUauciqsqWcQhF47lqkfEo1RCN1V0YwPuGez5ROXpC7G5J WcDyM+XfnpgBhB/fGWbj4pg5u2/my5ze3Abq1Wo7k9GPM7UZ X-Google-Smtp-Source: ABdhPJw/Ch8WWG2O2qDM/9Jc5exVf6rgoPHKV5c9rE7Zq499OYcDuWvWDwZhuYN+Oj75uDd9AC4/tt54t2GmMmtveNwvxWia5tHP MIME-Version: 1.0 X-Received: by 2002:a05:6602:381:: with SMTP id f1mr1631261iov.193.1596165203333; Thu, 30 Jul 2020 20:13:23 -0700 (PDT) Date: Thu, 30 Jul 2020 20:13:23 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000f298fc05abb42b70@google.com> Subject: WARNING: ODEBUG bug in cancel_delayed_work From: syzbot <syzbot+338f014a98367a08a114@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: 04C2FA01FB X-Rspamd-UID: d0819b Hello, syzbot found the following issue on: HEAD commit: 27a2145d ibmvnic: Fix IRQ mapping disposal in error path git tree: net console output: https://syzkaller.appspot.com/x/log.txt?x=14277848900000 kernel config: https://syzkaller.appspot.com/x/.config?x=ca6448d2af2ba351 dashboard link: https://syzkaller.appspot.com/bug?extid=338f014a98367a08a114 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=168aec04900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11148e5c900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+338f014a98367a08a114@syzkaller.appspotmail.com ------------[ cut here ]------------ ODEBUG: assert_init not available (active state 0) object type: timer_list hint: 0x0 WARNING: CPU: 0 PID: 6858 at lib/debugobjects.c:485 debug_print_object+0x160/0x250 lib/debugobjects.c:485 Kernel panic - not syncing: panic_on_warn set ... CPU: 0 PID: 6858 Comm: syz-executor296 Not tainted 5.8.0-rc6-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 panic+0x2e3/0x75c kernel/panic.c:231 __warn.cold+0x20/0x45 kernel/panic.c:600 report_bug+0x1bd/0x210 lib/bug.c:198 handle_bug+0x38/0x90 arch/x86/kernel/traps.c:235 exc_invalid_op+0x13/0x40 arch/x86/kernel/traps.c:255 asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:540 RIP: 0010:debug_print_object+0x160/0x250 lib/debugobjects.c:485 Code: dd a0 9f 93 88 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 bf 00 00 00 48 8b 14 dd a0 9f 93 88 48 c7 c7 00 95 93 88 e8 b2 ae a9 fd <0f> 0b 83 05 db 0b 14 07 01 48 83 c4 20 5b 5d 41 5c 41 5d c3 48 89 RSP: 0018:ffffc9000168f578 EFLAGS: 00010082 RAX: 0000000000000000 RBX: 0000000000000005 RCX: 0000000000000000 RDX: ffff888096dec4c0 RSI: ffffffff815d4ef7 RDI: fffff520002d1ea1 RBP: 0000000000000001 R08: 0000000000000001 R09: ffff8880ae620fcb R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff89bcc540 R13: ffffffff81630df0 R14: ffff888095382200 R15: 1ffff920002d1eba debug_object_assert_init lib/debugobjects.c:870 [inline] debug_object_assert_init+0x1f4/0x2e0 lib/debugobjects.c:841 debug_timer_assert_init kernel/time/timer.c:736 [inline] debug_assert_init kernel/time/timer.c:781 [inline] del_timer+0x6d/0x110 kernel/time/timer.c:1207 try_to_grab_pending kernel/workqueue.c:1249 [inline] __cancel_work kernel/workqueue.c:3221 [inline] cancel_delayed_work+0xe0/0x450 kernel/workqueue.c:3250 l2cap_clear_timer include/net/bluetooth/l2cap.h:879 [inline] l2cap_chan_del+0x541/0x1300 net/bluetooth/l2cap_core.c:661 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:824 l2cap_sock_shutdown+0x3b8/0xe90 net/bluetooth/l2cap_sock.c:1339 l2cap_sock_release+0x63/0x1d0 net/bluetooth/l2cap_sock.c:1382 __sock_release+0xcd/0x280 net/socket.c:605 sock_close+0x18/0x20 net/socket.c:1278 __fput+0x33c/0x880 fs/file_table.c:281 task_work_run+0xdd/0x190 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0xb72/0x2a40 kernel/exit.c:805 do_group_exit+0x125/0x310 kernel/exit.c:903 get_signal+0x40b/0x1ee0 kernel/signal.c:2743 do_signal+0x82/0x2520 arch/x86/kernel/signal.c:810 exit_to_usermode_loop arch/x86/entry/common.c:235 [inline] __prepare_exit_to_usermode+0x156/0x1f0 arch/x86/entry/common.c:269 do_syscall_64+0x6c/0xe0 arch/x86/entry/common.c:393 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x446d69 Code: Bad RIP value. RSP: 002b:00007ffc69898b98 EFLAGS: 00000246 ORIG_RAX: 000000000000002a RAX: fffffffffffffffc RBX: 0000000000000003 RCX: 0000000000446d69 RDX: 000000000000000e RSI: 0000000020000040 RDI: 0000000000000004 RBP: 00007ffc69898bd0 R08: 0000000000000000 R09: 00000000000000ff R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000004 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Kernel Offset: disabled Rebooting in 86400 seconds.. --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UBLTAXiMI19GnwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 05:14:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2JoKAHiMI1+AKgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 05:14:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EB8B8A11E2; Fri, 31 Jul 2020 05:13:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731282AbgGaDN3 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 30 Jul 2020 23:13:29 -0400 Received: from mail-il1-f198.google.com ([209.85.166.198]:37561 "EHLO mail-il1-f198.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731297AbgGaDNY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 30 Jul 2020 23:13:24 -0400 Received: by mail-il1-f198.google.com with SMTP id k69so2042030ilg.4 for <linux-bluetooth@vger.kernel.org>; Thu, 30 Jul 2020 20:13:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=wX4UxClPuPiSj/FUSxb7K5H0GkdpHs3QFxD4LPSNLqA=; b=rDvmR2wnRHUaRop0ZH/jLjJjo1bm5rcC5QZbNRgKj1EOTAIBmifuKLQDICqblhGvTt iKMzgf2tnxtv6707htmncpdTJ79SriYawvHBXBr0ur6ztSq/vaq9iJiIQr2wdi9ZGQU5 JPT4dXAgMaTAI6sAMvurCHrn9BpV0UMW9msOUIPyC93z6J2bnJVZmXVyHvZ+tM+hEWYK T3Vf1O8Drb2cmpA1oXXNciP69VOdz2uiWA1r7xyyMkxduY/ly8CHM9VZJKrwCZht9YGG Tb0kGl6anKGQkGJGZ3HKgau9jIVkBMG2AOjthOOUm4XEoFiqH9CshoCbAGXoPXYfz7k/ AjeA== X-Gm-Message-State: AOAM532KG8CBMP/wI8MH/EDDX407L9loSiW9qzdIg1QTb00TJlgewVyZ Z7Oy4KwgrUL+i2obsF3nb331gyJka/jOWEosChoe2O9taDoq X-Google-Smtp-Source: ABdhPJwwXeZjCISUCoDvHg+GBVSC0YtBkDu6ONKcAkrSJGzoKHuoinf8LqGYz/vtMMcNSmMI7chfpv+l8rlLTtfpCN5AQvrvvTv3 MIME-Version: 1.0 X-Received: by 2002:a92:8b11:: with SMTP id i17mr1662247ild.212.1596165203611; Thu, 30 Jul 2020 20:13:23 -0700 (PDT) Date: Thu, 30 Jul 2020 20:13:23 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000f6d80505abb42b60@google.com> Subject: WARNING in cancel_delayed_work From: syzbot <syzbot+35e70efb794757d7e175@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.44 / 15.00 / 200.00 X-Rspamd-Queue-Id: EB8B8A11E2 X-Rspamd-UID: 06bf31 Hello, syzbot found the following issue on: HEAD commit: 83bdc727 random32: remove net_rand_state from the latent e.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10479f12900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=35e70efb794757d7e175 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1160faa2900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11816098900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+35e70efb794757d7e175@syzkaller.appspotmail.com ------------[ cut here ]------------ ODEBUG: assert_init not available (active state 0) object type: timer_list hint: 0x0 WARNING: CPU: 0 PID: 6889 at lib/debugobjects.c:488 debug_print_object lib/debugobjects.c:485 [inline] WARNING: CPU: 0 PID: 6889 at lib/debugobjects.c:488 debug_object_assert_init+0x1fa/0x250 lib/debugobjects.c:870 Kernel panic - not syncing: panic_on_warn set ... CPU: 0 PID: 6889 Comm: syz-executor259 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 panic+0x264/0x7a0 kernel/panic.c:231 __warn+0x227/0x250 kernel/panic.c:600 report_bug+0x1b1/0x2e0 lib/bug.c:198 handle_bug+0x42/0x80 arch/x86/kernel/traps.c:235 exc_invalid_op+0x16/0x40 arch/x86/kernel/traps.c:255 asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:540 RIP: 0010:debug_print_object lib/debugobjects.c:485 [inline] RIP: 0010:debug_object_assert_init+0x1fa/0x250 lib/debugobjects.c:870 Code: e8 ab ec 11 fe 4c 8b 45 00 48 c7 c7 0f b7 14 89 48 c7 c6 09 b6 14 89 48 c7 c2 22 30 2c 89 31 c9 49 89 d9 31 c0 e8 16 9e a4 fd <0f> 0b ff 05 02 ca eb 05 48 83 c5 38 48 89 e8 48 c1 e8 03 42 80 3c RSP: 0018:ffffc90001477828 EFLAGS: 00010046 RAX: 8d1db38e33234900 RBX: 0000000000000000 RCX: ffff888091cfe200 RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000 RBP: ffffffff894edb20 R08: ffffffff815dd389 R09: ffffed1015d041c3 R10: ffffed1015d041c3 R11: 0000000000000000 R12: dffffc0000000000 R13: ffff8880a687e200 R14: 0000000000000002 R15: ffffffff8ba2a2a0 debug_timer_assert_init kernel/time/timer.c:737 [inline] debug_assert_init kernel/time/timer.c:782 [inline] del_timer+0x2f/0x340 kernel/time/timer.c:1208 try_to_grab_pending+0xba/0x9f0 kernel/workqueue.c:1249 __cancel_work kernel/workqueue.c:3221 [inline] cancel_delayed_work+0x37/0x2b0 kernel/workqueue.c:3250 l2cap_clear_timer include/net/bluetooth/l2cap.h:879 [inline] l2cap_chan_del+0x5bf/0x760 net/bluetooth/l2cap_core.c:661 l2cap_chan_close+0x7bf/0xae0 net/bluetooth/l2cap_core.c:824 l2cap_sock_shutdown+0x39f/0x700 net/bluetooth/l2cap_sock.c:1339 l2cap_sock_release+0x63/0x190 net/bluetooth/l2cap_sock.c:1382 __sock_release net/socket.c:605 [inline] sock_close+0xd8/0x260 net/socket.c:1278 __fput+0x2f0/0x750 fs/file_table.c:281 task_work_run+0x137/0x1c0 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0x601/0x1f80 kernel/exit.c:805 do_group_exit+0x161/0x2d0 kernel/exit.c:903 get_signal+0x139b/0x1d30 kernel/signal.c:2743 do_signal+0x33/0x610 arch/x86/kernel/signal.c:810 exit_to_usermode_loop arch/x86/entry/common.c:235 [inline] __prepare_exit_to_usermode+0xd7/0x1e0 arch/x86/entry/common.c:269 do_syscall_64+0x7f/0xe0 arch/x86/entry/common.c:393 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x446d69 Code: Bad RIP value. RSP: 002b:00007ffc9b702c28 EFLAGS: 00000246 ORIG_RAX: 000000000000002a RAX: fffffffffffffffc RBX: 0000000000000003 RCX: 0000000000446d69 RDX: 000000000000000e RSI: 0000000020000040 RDI: 0000000000000004 RBP: 00007ffc9b702c60 R08: 0000000000000000 R09: 00000000000000ff R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000004 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Kernel Offset: disabled Rebooting in 86400 seconds.. --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sOcaFge4I182UQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 08:19:51 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id KNFlFAe4I18ieQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 08:19:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 95B1D41432; Fri, 31 Jul 2020 08:19:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731414AbgGaGTk (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 02:19:40 -0400 Received: from mga06.intel.com ([134.134.136.31]:44828 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731404AbgGaGTj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 02:19:39 -0400 IronPort-SDR: fITy5npkKJaWx3eSj1c+pBSu0tBcQd6gkC3NOJeE6gJ/VReppvp7VzXdwbJ4OUe0NqP517vacC cnh5L9m6bNBw== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="213269549" X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="213269549" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 23:19:39 -0700 IronPort-SDR: ReR8ykOfQVZ/CK4YzQ1mNkXilhY2beSYcUDnkAMoBxS0yI0lRwbh8F00xrk+iRI04X/zP8FEfy zlfryhmE+Glg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="329163338" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jul 2020 23:19:38 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 02/10] mesh: Clean up handling of config model binding messages Date: Thu, 30 Jul 2020 23:19:28 -0700 Message-Id: <20200731061936.56952-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200731061936.56952-1-inga.stotland@intel.com> References: <20200731061936.56952-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 95B1D41432 X-Rspamd-UID: 721b85 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 128 +++++++++++-------------------------------- mesh/model.c | 16 +----- 2 files changed, 35 insertions(+), 109 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index cd0e8b94c..8a92c6cd7 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -112,8 +112,7 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; const uint8_t *pub_addr; uint16_t test_addr; - uint8_t ttl, period; - uint8_t retransmit; + uint8_t ttl, period, retransmit; int status; bool cred_flag; @@ -362,115 +361,52 @@ static uint16_t config_sub_del_all(struct mesh_node *node, const uint8_t *pkt, return n; } -static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t addr, - uint32_t id, uint16_t idx) -{ - size_t n = mesh_model_opcode_set(OP_MODEL_APP_STATUS, msg); - - msg[n++] = status; - l_put_le16(addr, msg + n); - n += 2; - l_put_le16(idx, msg + n); - n += 2; - - if (IS_VENDOR(id)) { - l_put_le16(VENDOR_ID(id), msg + n); - n += 2; - } - - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); -} - -static void model_app_list(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, +static uint16_t model_app_list(struct mesh_node *node, const uint8_t *pkt, uint16_t size) { - uint16_t ele_addr; + uint16_t ele_addr, n, bnd_len; uint32_t id; - uint8_t *status; - uint16_t n; - int result; + int opcode; + opcode = (size == 4) ? OP_MODEL_APP_LIST : OP_VEND_MODEL_APP_LIST; ele_addr = l_get_le16(pkt); - switch (size) { - default: - return; - case 4: - n = mesh_model_opcode_set(OP_MODEL_APP_LIST, msg); - status = msg + n; - id = l_get_le16(pkt + 2); - l_put_le16(ele_addr, msg + 1 + n); - l_put_le16((uint16_t) id, msg + 3 + n); - id = SET_ID(SIG_VENDOR, id); - n += 5; - break; - case 6: - n = mesh_model_opcode_set(OP_VEND_MODEL_APP_LIST, msg); - status = msg + n; - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); + n = mesh_model_opcode_set(opcode, msg); + memcpy(msg + n + 1, pkt, size); - l_put_le16(ele_addr, msg + 1 + n); - l_put_le16((uint16_t) VENDOR_ID(id), msg + 3 + n); - l_put_le16((uint16_t) MODEL_ID(id), msg + 5 + n); - n += 7; - break; - } + id = CFG_SET_ID(size == 6, pkt + 2); - result = mesh_model_get_bindings(node, ele_addr, id, msg + n, - MAX_MSG_LEN - n, &size); - n += size; + msg[n] = mesh_model_get_bindings(node, ele_addr, id, msg + n + 1 + size, + MAX_MSG_LEN - (n + 1 + size), &bnd_len); - if (result >= 0) { - *status = result; - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, - DEFAULT_TTL, false, msg, n); - } + if (msg[n] == MESH_STATUS_SUCCESS) + n += bnd_len; + + n += (size + 1); + return n; } -static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size, - bool unbind) +static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt, + uint16_t size, bool unbind) { - uint16_t ele_addr; + uint16_t ele_addr, idx, n; uint32_t id; - uint16_t idx; - int result; - - switch (size) { - default: - return false; - - case 6: - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); - break; - case 8: - id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); - break; - } ele_addr = l_get_le16(pkt); idx = l_get_le16(pkt + 2); + id = CFG_SET_ID(size == 8, pkt + 4); - if (idx > 0xfff) - return false; + n = mesh_model_opcode_set(OP_MODEL_APP_STATUS, msg); if (unbind) - result = mesh_model_binding_del(node, ele_addr, id, idx); + msg[n] = mesh_model_binding_del(node, ele_addr, id, idx); else - result = mesh_model_binding_add(node, ele_addr, id, idx); + msg[n] = mesh_model_binding_add(node, ele_addr, id, idx); - send_model_app_status(node, net_idx, src, dst, result, ele_addr, - id, idx); + memcpy(msg + n + 1, pkt, size); + n += (size + 1); - return true; + return n; } static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) @@ -703,8 +639,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 1 || pkt[0] > TTL_MASK || pkt[0] == 1) return true; - if (pkt[0] <= TTL_MASK) - node_default_ttl_set(node, pkt[0]); + node_default_ttl_set(node, pkt[0]); /* Fall Through */ case OP_CONFIG_DEFAULT_TTL_GET: @@ -1048,22 +983,25 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_MODEL_APP_BIND: case OP_MODEL_APP_UNBIND: - model_app_bind(node, net_idx, src, dst, pkt, size, - opcode != OP_MODEL_APP_BIND); + if (size != 6 && size != 8) + return true; + + n = model_app_bind(node, pkt, size, + opcode != OP_MODEL_APP_BIND); break; case OP_VEND_MODEL_APP_GET: if (size != 6) return true; - model_app_list(node, net_idx, src, dst, pkt, size); + n = model_app_list(node, pkt, size); break; case OP_MODEL_APP_GET: if (size != 4) return true; - model_app_list(node, net_idx, src, dst, pkt, size); + n = model_app_list(node, pkt, size); break; case OP_CONFIG_HEARTBEAT_PUB_SET: diff --git a/mesh/model.c b/mesh/model.c index 3c9b6577a..e2cadfe36 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -111,13 +111,7 @@ static bool simple_match(const void *a, const void *b) static bool has_binding(struct l_queue *bindings, uint16_t idx) { - const struct l_queue_entry *l; - - for (l = l_queue_get_entries(bindings); l; l = l->next) { - if (L_PTR_TO_UINT(l->data) == idx) - return true; - } - return false; + return l_queue_find(bindings, simple_match, L_UINT_TO_PTR(idx)) != NULL; } static bool find_virt_by_label(const void *a, const void *b) @@ -628,7 +622,6 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, uint16_t app_idx, bool unbind) { struct mesh_model *mod; - bool is_present; int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) @@ -645,12 +638,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, if (!appkey_have_key(node_get_net(node), app_idx)) return MESH_STATUS_INVALID_APPKEY; - is_present = has_binding(mod->bindings, app_idx); - - if (!is_present && unbind) - return MESH_STATUS_SUCCESS; - - if (is_present && !unbind) + if (unbind ^ has_binding(mod->bindings, app_idx)) return MESH_STATUS_SUCCESS; if (unbind) { -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oCQPMQy4I182UQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 08:19:56 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QNWSLwy4I1/k7gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 08:19:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8B0AF41874; Fri, 31 Jul 2020 08:19:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731416AbgGaGTk (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 02:19:40 -0400 Received: from mga06.intel.com ([134.134.136.31]:44828 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731413AbgGaGTk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 02:19:40 -0400 IronPort-SDR: NO6oIYmiWFNWzGy+63wdatIVKKfknqiWYc+SZWIlrTSS8YDEZsxWbDjJgKNQPdLwwy4EjpT0ze N8pcnXHJnfzA== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="213269551" X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="213269551" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 23:19:40 -0700 IronPort-SDR: O8Fx9XL4QNZkm8urtU8pyVowrxM2yeBU6/k3fxKtmMqE2DULf/BUfppjtAIcfpkdjrVVPnldSS /dn98EkVUSGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="329163341" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jul 2020 23:19:39 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 03/10] mesh: Clean up handling of config node identity message Date: Thu, 30 Jul 2020 23:19:29 -0700 Message-Id: <20200731061936.56952-3-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200731061936.56952-1-inga.stotland@intel.com> References: <20200731061936.56952-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8B0AF41874 X-Rspamd-UID: 9abac1 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 8a92c6cd7..2d47429f7 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -773,11 +773,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_NODE_IDENTITY_SET: - if (size != 3 || pkt[2] > 0x01) - return true; - - n_idx = l_get_le16(pkt); - if (n_idx > 0xfff) + if (size != 3) return true; /* Currently setting node identity not supported */ @@ -785,18 +781,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall Through */ case OP_NODE_IDENTITY_GET: - if (size < 2) + if (opcode == OP_NODE_IDENTITY_GET && size != 2) return true; n_idx = l_get_le16(pkt); - if (n_idx > 0xfff) - return true; n = mesh_model_opcode_set(OP_NODE_IDENTITY_STATUS, msg); - - status = mesh_net_get_identity_mode(net, n_idx, &state); - - msg[n++] = status; + msg[n++] = mesh_net_get_identity_mode(net, n_idx, &state); l_put_le16(n_idx, msg + n); n += 2; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iLTDHRK4I182UQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 08:20:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id oEcfHBK4I1+bXAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 08:20:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E592A41432; Fri, 31 Jul 2020 08:19:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731418AbgGaGTl (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 02:19:41 -0400 Received: from mga06.intel.com ([134.134.136.31]:44828 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731415AbgGaGTl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 02:19:41 -0400 IronPort-SDR: itYisu8WiV/xmmvwm/2Om0DPJGVZqU/rw+JuPXsZ6FhzdDJWI+NtzZlwXmcvVeum1ZcPdVCQ32 fG0/1v9Amvfw== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="213269552" X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="213269552" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 23:19:40 -0700 IronPort-SDR: eBWjUGnSU3xITWeMvglJxL28Yy0wJTJayM8LVLDl1HopvbV5gT5r+ipbkXUsFW+O2pTWTuCuU3 jQj5wbD1O2Lg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="329163344" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jul 2020 23:19:40 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 04/10] mesh: Clean up handling of config publication messages Date: Thu, 30 Jul 2020 23:19:30 -0700 Message-Id: <20200731061936.56952-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200731061936.56952-1-inga.stotland@intel.com> References: <20200731061936.56952-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: E592A41432 X-Rspamd-UID: 7eecaf This modification allows using a single point for sending out the composed status messages by the Config Server. Also, return Feature Not Supported errror code when credential flag is set, but the node does not support LPN feature --- mesh/cfgmod-server.c | 95 +++++++++++++++++--------------------------- mesh/model.c | 7 +++- 2 files changed, 41 insertions(+), 61 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 2d47429f7..9633b7240 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -44,11 +44,9 @@ static const uint8_t supported_pages[] = { static uint8_t msg[MAX_MSG_LEN]; -static void send_pub_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, uint32_t id, - uint16_t pub_addr, uint16_t idx, bool cred_flag, - uint8_t ttl, uint8_t period, uint8_t retransmit) +static uint16_t set_pub_status(uint8_t status, uint16_t ele_addr, uint32_t id, + uint16_t pub_addr, uint16_t idx, bool cred_flag, + uint8_t ttl, uint8_t period, uint8_t retransmit) { size_t n; @@ -72,46 +70,36 @@ static void send_pub_status(struct mesh_node *node, uint16_t net_idx, n += 4; } - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); + return n; } -static void config_pub_get(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size) +static uint16_t config_pub_get(struct mesh_node *node, const uint8_t *pkt, + bool vendor) { uint32_t id; uint16_t ele_addr; struct mesh_model_pub *pub; int status; - if (size == 4) { - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); - } else if (size == 6) { - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - } else - return; - ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); + pub = mesh_model_pub_get(node, ele_addr, id, &status); if (pub && status == MESH_STATUS_SUCCESS) - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, pub->addr, pub->idx, pub->credential, - pub->ttl, pub->period, pub->retransmit); + return set_pub_status(status, ele_addr, id, pub->addr, pub->idx, + pub->credential, pub->ttl, pub->period, + pub->retransmit); else - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, 0, 0, 0, 0, 0, 0); + return set_pub_status(status, ele_addr, id, 0, 0, 0, 0, 0, 0); } -static void config_pub_set(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, bool virt, bool vendor) +static uint16_t config_pub_set(struct mesh_node *node, const uint8_t *pkt, + bool virt, bool vendor) { uint32_t id; - uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; + uint16_t ele_addr, idx, pub_dst; const uint8_t *pub_addr; - uint16_t test_addr; uint8_t ttl, period, retransmit; int status; bool cred_flag; @@ -119,42 +107,31 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, ele_addr = l_get_le16(pkt); pub_addr = pkt + 2; - pkt += (virt ? 14 : 0); + pub_dst = l_get_le16(pub_addr); + + if (!virt && IS_VIRTUAL(pub_dst)) + return 0; + pkt += (virt ? 14 : 0); idx = l_get_le16(pkt + 4); + cred_flag = !!(CREDFLAG_MASK & idx); + idx &= APP_IDX_MASK; ttl = pkt[6]; period = pkt[7]; retransmit = pkt[8]; - id = l_get_le16(pkt + 9); - - if (!vendor) - id = SET_ID(SIG_VENDOR, id); - else - id = SET_ID(id, l_get_le16(pkt + 11)); - - /* Don't accept virtual seeming addresses */ - test_addr = l_get_le16(pub_addr); - if (!virt && IS_VIRTUAL(test_addr)) - return; - - cred_flag = !!(CREDFLAG_MASK & idx); - idx &= APP_IDX_MASK; + id = CFG_SET_ID(vendor, pkt + 9); status = mesh_model_pub_set(node, ele_addr, id, pub_addr, idx, cred_flag, ttl, period, retransmit, - virt, &ota); - - l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, mod: %x, idx: %3.3x", - status, ele_addr, ota, id, idx); + virt, &pub_dst); - if (status != MESH_STATUS_SUCCESS) { - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, 0, 0, 0, 0, 0, 0); + l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, id: %x, idx: %3.3x", + status, ele_addr, pub_dst, id, idx); - return; - } + if (status != MESH_STATUS_SUCCESS) + return set_pub_status(status, ele_addr, id, 0, 0, 0, 0, 0, 0); - if (IS_UNASSIGNED(test_addr) && !virt) { + if (IS_UNASSIGNED(pub_dst) && !virt) { ttl = period = idx = 0; /* Remove model publication from config file */ @@ -165,7 +142,7 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, } else { struct mesh_config_pub db_pub = { .virt = virt, - .addr = ota, + .addr = pub_dst, .idx = idx, .ttl = ttl, .credential = cred_flag, @@ -180,12 +157,12 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, /* Save model publication to config file */ if (!mesh_config_model_pub_add(node_config_get(node), ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_pub)) + vendor, &db_pub)) status = MESH_STATUS_STORAGE_FAIL; } - send_pub_status(node, net_idx, src, dst, status, ele_addr, id, ota, - idx, cred_flag, ttl, period, retransmit); + return set_pub_status(status, ele_addr, id, pub_dst, idx, cred_flag, + ttl, period, retransmit); } static uint16_t cfg_sub_get_msg(struct mesh_node *node, const uint8_t *pkt, @@ -663,14 +640,14 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (!virt && (size != 11 && size != 13)) return true; - config_pub_set(node, net_idx, src, dst, pkt, virt, - size == 13 || size == 27); + n = config_pub_set(node, pkt, virt, size == 13 || size == 27); break; case OP_CONFIG_MODEL_PUB_GET: if (size != 4 && size != 6) return true; - config_pub_get(node, net_idx, src, dst, pkt, size); + + n = config_pub_get(node, pkt, size == 6); break; case OP_CONFIG_VEND_MODEL_SUB_GET: diff --git a/mesh/model.c b/mesh/model.c index e2cadfe36..a92ab6b43 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -1072,7 +1072,7 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *pub_addr, uint16_t idx, bool cred_flag, uint8_t ttl, uint8_t period, uint8_t retransmit, - bool is_virt, uint16_t *dst) + bool is_virt, uint16_t *pub_dst) { struct mesh_model *mod; int status, ele_idx = node_get_element_idx(node, addr); @@ -1099,6 +1099,9 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } + if (cred_flag && node_lpn_mode_get(node) != MESH_MODE_ENABLED) + return MESH_STATUS_FEATURE_NO_SUPPORT; + /* Check if the old publication destination is a virtual label */ if (mod->pub && mod->pub->virt) { unref_virt(mod->pub->virt); @@ -1112,7 +1115,7 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, status = set_virt_pub(mod, pub_addr, idx, cred_flag, ttl, period, retransmit); - *dst = mod->pub->addr; + *pub_dst = mod->pub->addr; if (status != MESH_STATUS_SUCCESS) return status; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UOHoFxi4I188PwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 08:20:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id kL2RFhi4I19i9AEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 08:20:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 03F7C41873; Fri, 31 Jul 2020 08:20:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731421AbgGaGTn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 02:19:43 -0400 Received: from mga06.intel.com ([134.134.136.31]:44828 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731415AbgGaGTm (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 02:19:42 -0400 IronPort-SDR: zZsHICX3sMYFIz3pX/tjXQ/eXqy+lMEwitJ9dDJ7/nTqX7Q7lKisa7aNLdM+UY+t3rq1nExXHg rLbnzk6v79Ig== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="213269555" X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="213269555" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 23:19:42 -0700 IronPort-SDR: FyA+DWj941kBdfgUaZD8mhRgItvoqQrH1r6fuedk12NKtBv6q5FUYm2CeEvT/QGpaAcofXZ7mW E27yXP1VRjsg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="329163352" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jul 2020 23:19:41 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 06/10] mesh: Clean up handling of config relay messages Date: Thu, 30 Jul 2020 23:19:32 -0700 Message-Id: <20200731061936.56952-6-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200731061936.56952-1-inga.stotland@intel.com> References: <20200731061936.56952-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 03F7C41873 X-Rspamd-UID: 79c078 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 9d243dd8b..8d5ec7438 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -386,6 +386,30 @@ static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt, return n; } +static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t count; + uint16_t interval; + uint16_t n; + + if (pkt[0] > 0x01) + return 0; + + if (opcode == OP_CONFIG_RELAY_SET) { + count = (pkt[1] & 0x7) + 1; + interval = ((pkt[1] >> 3) + 1) * 10; + node_relay_mode_set(node, !!pkt[0], count, interval); + } + + n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); + + msg[n++] = node_relay_mode_get(node, &count, &interval); + msg[n++] = (count - 1) + ((interval/10 - 1) << 3); + + return n; +} + static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; @@ -755,24 +779,14 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_RELAY_SET: - if (size != 2 || pkt[0] > 0x01) + if (size != 2) return true; - - count = (pkt[1] & 0x7) + 1; - interval = ((pkt[1] >> 3) + 1) * 10; - node_relay_mode_set(node, !!pkt[0], count, interval); /* Fall Through */ - case OP_CONFIG_RELAY_GET: if (opcode == OP_CONFIG_RELAY_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); - - msg[n++] = node_relay_mode_get(node, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Relay Config (%d)", msg[n-1]); + n = cfg_relay_msg(node, pkt, opcode); break; case OP_CONFIG_NETWORK_TRANSMIT_SET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QAoWMR24I182UQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 08:20:13 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 8A+8Lx24I1+2fQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 08:20:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7E54A41870; Fri, 31 Jul 2020 08:20:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731422AbgGaGTn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 02:19:43 -0400 Received: from mga06.intel.com ([134.134.136.31]:44828 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731419AbgGaGTn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 02:19:43 -0400 IronPort-SDR: F4YLPskVNCLwwkenyzw4MmMJqlJe5T61E20GN4EDA697eVrCodpa4I3LDrzgQM82ub3UupFGEj V6CfQNxRoLHg== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="213269556" X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="213269556" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 23:19:42 -0700 IronPort-SDR: opczn7GJRWhXBRCdIZWiaZxVyI9oHND7I+AvHbJJ7PZRMp/8tiVNEeV39fDKO1jG5lkOwGDNGh eh0lzUNIL5MQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="329163355" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jul 2020 23:19:42 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 07/10] mesh: Clean up handling of config poll timeout message Date: Thu, 30 Jul 2020 23:19:33 -0700 Message-Id: <20200731061936.56952-7-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200731061936.56952-1-inga.stotland@intel.com> References: <20200731061936.56952-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7E54A41870 X-Rspamd-UID: 1136b0 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 34 +++++++++++++++++++++++----------- mesh/cfgmod.h | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 8d5ec7438..e489a56cd 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -628,6 +628,25 @@ static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt) return n + 3 + sz; } +static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t n, addr = l_get_le16(pkt); + uint32_t poll_to; + + if (!IS_UNICAST(addr)) + return 0; + + n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); + l_put_le16(addr, msg + n); + n += 2; + + poll_to = mesh_net_friend_timeout(node_get_net(node), addr); + msg[n++] = poll_to; + msg[n++] = poll_to >> 8; + msg[n++] = poll_to >> 16; + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -663,7 +682,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct mesh_net *net; const uint8_t *pkt = data; struct timeval time_now; - uint32_t opcode, tmp32; + uint32_t opcode; int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; uint16_t n_idx; @@ -1099,18 +1118,11 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, msg[n++] = hb->sub_max_hops; break; - case OP_CONFIG_POLL_TIMEOUT_LIST: - if (size != 2 || l_get_le16(pkt) == 0 || - l_get_le16(pkt) > 0x7fff) + case OP_CONFIG_POLL_TIMEOUT_GET: + if (size != 2) return true; - n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; - tmp32 = mesh_net_friend_timeout(net, l_get_le16(pkt)); - msg[n++] = tmp32; - msg[n++] = tmp32 >> 8; - msg[n++] = tmp32 >> 16; + n = cfg_poll_timeout_msg(node, pkt); break; case OP_NODE_RESET: diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 7b6a95807..6d73656a7 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -66,7 +66,7 @@ #define OP_CONFIG_MODEL_SUB_LIST 0x802A #define OP_CONFIG_VEND_MODEL_SUB_GET 0x802B #define OP_CONFIG_VEND_MODEL_SUB_LIST 0x802C -#define OP_CONFIG_POLL_TIMEOUT_LIST 0x802D +#define OP_CONFIG_POLL_TIMEOUT_GET 0x802D #define OP_CONFIG_POLL_TIMEOUT_STATUS 0x802E /* Health opcodes in health-mod.h */ #define OP_CONFIG_HEARTBEAT_PUB_GET 0x8038 -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EGB0NCm4I182UQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 08:20:25 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 6JLFMim4I18keQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 08:20:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 867C641760; Fri, 31 Jul 2020 08:20:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731426AbgGaGTo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 02:19:44 -0400 Received: from mga06.intel.com ([134.134.136.31]:44828 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731419AbgGaGTn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 02:19:43 -0400 IronPort-SDR: mgRUeVbwLAgqHESCEP3xiqTos1XuuWqPXLmlxYe2ZVAdushi0aZwAW0j801+mBf6S89Wb8mlwX TgNIg7qdPRRQ== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="213269557" X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="213269557" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 23:19:43 -0700 IronPort-SDR: mcYk5sxhY7yRcDTKR2w8qjRqscLTMKCeO1kGVuEnfyz6q1/sZvYRa/Sm9lgZ6iBJNu/leFqX1s mRJ80MYSCZDQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="329163360" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jul 2020 23:19:43 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 08/10] mesh: Clean up handling of config net transmit messages Date: Thu, 30 Jul 2020 23:19:34 -0700 Message-Id: <20200731061936.56952-8-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200731061936.56952-1-inga.stotland@intel.com> References: <20200731061936.56952-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 867C641760 X-Rspamd-UID: 7990c7 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index e489a56cd..b27105b40 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -647,6 +647,28 @@ static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) return n; } +static uint16_t cfg_net_tx_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t cnt; + uint16_t interval, n; + struct mesh_net *net = node_get_net(node); + + cnt = (pkt[0] & 0x7) + 1; + interval = ((pkt[0] >> 3) + 1) * 10; + + if (opcode == OP_CONFIG_NETWORK_TRANSMIT_SET && + mesh_config_write_net_transmit(node_config_get(node), + cnt, interval)) + mesh_net_transmit_params_set(net, cnt, interval); + + n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, msg); + + mesh_net_transmit_params_get(net, &cnt, &interval); + msg[n++] = (cnt - 1) + ((interval/10 - 1) << 3); + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -689,8 +711,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint8_t state, status; uint8_t phase; bool virt = false; - uint8_t count; - uint16_t interval; uint16_t n; if (app_idx != APP_IDX_DEV_LOCAL) @@ -811,25 +831,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_NETWORK_TRANSMIT_SET: if (size != 1) return true; - - count = (pkt[0] & 0x7) + 1; - interval = ((pkt[0] >> 3) + 1) * 10; - - if (mesh_config_write_net_transmit(node_config_get(node), count, - interval)) - mesh_net_transmit_params_set(net, count, interval); /* Fall Through */ case OP_CONFIG_NETWORK_TRANSMIT_GET: if (opcode == OP_CONFIG_NETWORK_TRANSMIT_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, - msg); - mesh_net_transmit_params_get(net, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Network Transmit Config"); + n = cfg_net_tx_msg(node, pkt, opcode); break; case OP_CONFIG_PROXY_SET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UGkUFDC4I188PwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 08:20:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 6Ar1EjC4I1+VUgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 08:20:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0BC8F41759; Fri, 31 Jul 2020 08:20:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731428AbgGaGTp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 02:19:45 -0400 Received: from mga06.intel.com ([134.134.136.31]:44845 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731425AbgGaGTo (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 02:19:44 -0400 IronPort-SDR: vXwx0QKo+80A4Vz9t1Qjp8Esd1g7mR7YOK7rXArMh9V7bUQXNbNYo4wTqvnker2KngC/iqp5mi IYjx0sHU6BFw== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="213269559" X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="213269559" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 23:19:44 -0700 IronPort-SDR: 5+H94sVLgFDOWrQ4wk3T9qNDKqLQ+cFGcVboUNn/B/uIm7gyo/hQxMZdR1foNyDCQwUBdtWeO6 xhdwDiGURXFg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="329163365" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jul 2020 23:19:43 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 09/10] mesh: Clean up handling of config KR phase messages Date: Thu, 30 Jul 2020 23:19:35 -0700 Message-Id: <20200731061936.56952-9-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200731061936.56952-1-inga.stotland@intel.com> References: <20200731061936.56952-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0BC8F41759 X-Rspamd-UID: 75b968 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 55 +++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index b27105b40..a694edb44 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -410,6 +410,31 @@ static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt, return n; } +static uint16_t cfg_key_refresh_phase(struct mesh_node *node, + const uint8_t *pkt, int opcode) +{ + struct mesh_net *net = node_get_net(node); + uint16_t n, idx = l_get_le16(pkt); + uint8_t phase; + + n = mesh_model_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_STATUS, msg); + + if (opcode == OP_CONFIG_KEY_REFRESH_PHASE_SET) { + phase = pkt[2]; + msg[n] = mesh_net_key_refresh_phase_set(net, idx, phase); + l_debug("Set KR Phase: net=%3.3x transition=%d", idx, phase); + } else { + msg[n] = mesh_net_key_refresh_phase_get(net, idx, &phase); + l_debug("Get KR Phase: net=%3.3x phase=%d", idx, phase); + } + + l_put_le16(idx, msg + n); + msg[n + 2] = (msg[n] != MESH_STATUS_SUCCESS) ? + KEY_REFRESH_PHASE_NONE : phase; + + return n + 3; +} + static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; @@ -708,8 +733,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; uint16_t n_idx; - uint8_t state, status; - uint8_t phase; + uint8_t state; bool virt = false; uint16_t n; @@ -916,37 +940,16 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_KEY_REFRESH_PHASE_SET: - if (size != 3 || pkt[2] > 0x03) + if (size != 3 || pkt[2] > KEY_REFRESH_PHASE_THREE) return true; - b_res = mesh_net_key_refresh_phase_set(net, l_get_le16(pkt), - pkt[2]); - size = 2; /* Fall Through */ case OP_CONFIG_KEY_REFRESH_PHASE_GET: - if (size != 2) + if (size != 2 && opcode == OP_CONFIG_KEY_REFRESH_PHASE_GET) return true; - n_idx = l_get_le16(pkt); - - n = mesh_model_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_STATUS, - msg); - - /* State: 0x00-0x03 phase of key refresh */ - status = mesh_net_key_refresh_phase_get(net, n_idx, - &phase); - if (status != MESH_STATUS_SUCCESS) { - b_res = status; - phase = KEY_REFRESH_PHASE_NONE; - } - - msg[n++] = b_res; - l_put_le16(n_idx, msg + n); - n += 2; - msg[n++] = phase; - - l_debug("Get/Set Key Refresh State (%d)", msg[n-1]); + n = cfg_key_refresh_phase(node, pkt, opcode); break; case OP_APPKEY_ADD: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8FoUADa4I182UQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 08:20:38 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id cFe9OTW4I1/ucgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 08:20:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 806414014E; Fri, 31 Jul 2020 08:20:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731429AbgGaGTq (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 02:19:46 -0400 Received: from mga06.intel.com ([134.134.136.31]:44831 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731413AbgGaGTp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 02:19:45 -0400 IronPort-SDR: yKYOsThrBd3b9OPEzP5/GqiSAI68qEIVIlvzkfxFHEwk0OBqVPzNMT2qPx1I9rgBopUpBWBLTT o1Cx+e8EBHbQ== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="213269553" X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="213269553" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 23:19:41 -0700 IronPort-SDR: LRT5zmBiSBJipnFM8a7MtRBphVKoHufW8oLBR/tq9U0BUmtC99tw0NsbPNp4Ng/hEsx4RhmMNK NO0oVyvVaWuA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="329163348" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jul 2020 23:19:40 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 05/10] mesh: Clean up handling of config net and app key messages Date: Thu, 30 Jul 2020 23:19:31 -0700 Message-Id: <20200731061936.56952-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200731061936.56952-1-inga.stotland@intel.com> References: <20200731061936.56952-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 806414014E X-Rspamd-UID: 6104ac This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 147 ++++++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 72 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 9633b7240..9d243dd8b 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -537,6 +537,73 @@ static void node_reset(void *user_data) node_remove(node); } +static uint16_t cfg_appkey_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint16_t n_idx, a_idx, n; + struct mesh_net *net = node_get_net(node); + + n_idx = l_get_le16(pkt) & 0xfff; + a_idx = l_get_le16(pkt + 1) >> 4; + + n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); + + if (opcode == OP_APPKEY_ADD) + msg[n] = appkey_key_add(net, n_idx, a_idx, pkt + 3); + else if (opcode == OP_APPKEY_UPDATE) + msg[n] = appkey_key_update(net, n_idx, a_idx, pkt + 3); + else + msg[n] = appkey_key_delete(net, n_idx, a_idx); + + l_debug("AppKey Command %s: Net_Idx %3.3x, App_Idx %3.3x", + (msg[n] == MESH_STATUS_SUCCESS) ? "success" : "fail", + n_idx, a_idx); + + memcpy(msg + n + 1, &pkt[0], 3); + + return n + 4; +} + +static uint16_t cfg_netkey_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint16_t n_idx, n; + struct mesh_net *net = node_get_net(node); + + n_idx = l_get_le16(pkt); + n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); + + if (opcode == OP_NETKEY_ADD) + msg[n] = mesh_net_add_key(net, n_idx, pkt + 2); + else if (opcode == OP_NETKEY_UPDATE) + msg[n] = mesh_net_update_key(net, n_idx, pkt + 2); + else + msg[n] = mesh_net_del_key(net, n_idx); + + l_debug("NetKey Command %s: Net_Idx %3.3x", + (msg[n] == MESH_STATUS_SUCCESS) ? "success" : "fail", + n_idx); + + memcpy(msg + n + 1, &pkt[0], 2); + + return n + 3; +} + +static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t n_idx, sz, n; + + n_idx = l_get_le16(pkt); + + n = mesh_model_opcode_set(OP_APPKEY_LIST, msg); + l_put_le16(n_idx, msg + n + 1); + + msg[n] = appkey_list(node_get_net(node), n_idx, msg + n + 3, + MAX_MSG_LEN - (n + 3), &sz); + + return n + 3 + sz; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -575,7 +642,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint32_t opcode, tmp32; int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; - uint16_t n_idx, a_idx; + uint16_t n_idx; uint8_t state, status; uint8_t phase; bool virt = false; @@ -846,60 +913,19 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 19) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; - - if (opcode == OP_APPKEY_ADD) - b_res = appkey_key_add(net, n_idx, a_idx, pkt + 3); - else - b_res = appkey_key_update(net, n_idx, a_idx, - pkt + 3); - - l_debug("Add/Update AppKey %s: Net_Idx %3.3x, App_Idx %3.3x", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail", - n_idx, a_idx); - - - n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); - - msg[n++] = b_res; - msg[n++] = pkt[0]; - msg[n++] = pkt[1]; - msg[n++] = pkt[2]; - break; - + /* Fall Through */ case OP_APPKEY_DELETE: - if (size != 3) + if (opcode == OP_APPKEY_DELETE && size != 3) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; - b_res = appkey_key_delete(net, n_idx, a_idx); - l_debug("Delete AppKey %s Net_Idx %3.3x to App_Idx %3.3x", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail", - n_idx, a_idx); - - n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); - msg[n++] = b_res; - msg[n++] = pkt[0]; - msg[n++] = pkt[1]; - msg[n++] = pkt[2]; + n = cfg_appkey_msg(node, pkt, opcode); break; case OP_APPKEY_GET: if (size != 2) return true; - n_idx = l_get_le16(pkt); - - n = mesh_model_opcode_set(OP_APPKEY_LIST, msg); - - status = appkey_list(net, n_idx, msg + n + 3, - MAX_MSG_LEN - n - 3, &size); - - msg[n] = status; - l_put_le16(n_idx, msg + n + 1); - n += (size + 3); + n = cfg_get_appkeys_msg(node, pkt); break; case OP_NETKEY_ADD: @@ -907,35 +933,12 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 18) return true; - n_idx = l_get_le16(pkt); - - if (opcode == OP_NETKEY_ADD) - b_res = mesh_net_add_key(net, n_idx, pkt + 2); - else - b_res = mesh_net_update_key(net, n_idx, pkt + 2); - - l_debug("NetKey Add/Update %s", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail"); - - n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); - msg[n++] = b_res; - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; - break; - + /* Fall Through */ case OP_NETKEY_DELETE: - if (size != 2) + if (opcode == OP_NETKEY_DELETE && size != 2) return true; - b_res = mesh_net_del_key(net, l_get_le16(pkt)); - - l_debug("NetKey delete %s", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail"); - - n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); - msg[n++] = b_res; - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; + n = cfg_netkey_msg(node, pkt, opcode); break; case OP_NETKEY_GET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4ExNHDy4I182UQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 08:20:44 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id aH3mGjy4I1+2fQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 08:20:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2B6E841117; Fri, 31 Jul 2020 08:20:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731430AbgGaGTq (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 02:19:46 -0400 Received: from mga06.intel.com ([134.134.136.31]:44845 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731419AbgGaGTq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 02:19:46 -0400 IronPort-SDR: EHzijH7e2qY81St8U3YAugu6T2fkHqRcTCJRoA978KNm9WUUnuB0PRelunNfWamFfve21tBKy+ 17I1zDjvai3Q== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="213269560" X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="213269560" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 23:19:45 -0700 IronPort-SDR: ++bHjBtB99corp186Ncx/UNlxa5FnFUaQOq+y6GtXsNGf9UwDb9Ffc1aN7ASPIaBC7iTWyizBk rTTu89d8dF9A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="329163368" Received: from wlloyd-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.79.39]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jul 2020 23:19:44 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 10/10] mesh: Refactor heartbeat pub/sub Date: Thu, 30 Jul 2020 23:19:36 -0700 Message-Id: <20200731061936.56952-10-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200731061936.56952-1-inga.stotland@intel.com> References: <20200731061936.56952-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2B6E841117 X-Rspamd-UID: 57a9ca Move heartbeat publication/subscription timers and housekeeping to net.c since this is where the trigger events and control messages are handled. Configuration server (cfgmod-server.c) stays responsible for parsing the set pub/sub message parameters and assemblying the pub/sub status messages. Also, make sure that the correct message status is reported. --- mesh/cfgmod-server.c | 307 ++++++++++++++----------------------------- mesh/net.c | 273 ++++++++++++++++++++++++++++---------- mesh/net.h | 48 ++++--- 3 files changed, 328 insertions(+), 300 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index a694edb44..8db474154 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -435,50 +435,6 @@ static uint16_t cfg_key_refresh_phase(struct mesh_node *node, return n + 3; } -static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) -{ - struct mesh_net *net = user_data; - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - mesh_net_heartbeat_send(net); - - if (hb->pub_count != 0xffff) - hb->pub_count--; - if (hb->pub_count > 0) - l_timeout_modify(hb->pub_timer, hb->pub_period); - else { - l_timeout_remove(hb->pub_timer); - hb->pub_timer = NULL; - } -} - -static void update_hb_pub_timer(struct mesh_net *net, - struct mesh_net_heartbeat *hb) -{ - if (IS_UNASSIGNED(hb->pub_dst) || hb->pub_count == 0) { - l_timeout_remove(hb->pub_timer); - hb->pub_timer = NULL; - return; - } - - if (!hb->pub_timer) - hb->pub_timer = l_timeout_create(hb->pub_period, - hb_pub_timeout_func, net, NULL); - else - l_timeout_modify(hb->pub_timer, hb->pub_period); -} - -static void hb_sub_timeout_func(struct l_timeout *timeout, void *user_data) -{ - struct mesh_net *net = user_data; - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - l_debug("HB Subscription Ended"); - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; -} - static uint8_t uint32_to_log(uint32_t value) { uint32_t val = 1; @@ -497,85 +453,112 @@ static uint8_t uint32_to_log(uint32_t value) return ret; } -static uint32_t log_to_uint32(uint8_t log, uint8_t offset) +static uint16_t hb_subscription_get(struct mesh_node *node, int status) { - if (!log) - return 0x0000; - else if (log > 0x11) - return 0xffff; + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_sub *sub = mesh_net_get_heartbeat_sub(net); + struct timeval time_now; + uint16_t n; + + gettimeofday(&time_now, NULL); + time_now.tv_sec -= sub->start; + + if (time_now.tv_sec >= (long int) sub->period) + time_now.tv_sec = 0; else - return (1 << (log - offset)); -} + time_now.tv_sec = sub->period - time_now.tv_sec; + l_debug("Sub Period (Log %2.2x) %d sec", uint32_to_log(time_now.tv_sec), + (int) time_now.tv_sec); -static int hb_subscription_set(struct mesh_net *net, uint16_t src, - uint16_t dst, uint8_t period_log) + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); + msg[n++] = status; + l_put_le16(sub->src, msg + n); + n += 2; + l_put_le16(sub->dst, msg + n); + n += 2; + msg[n++] = uint32_to_log(time_now.tv_sec); + msg[n++] = uint32_to_log(sub->count); + msg[n++] = sub->count ? sub->min_hops : 0; + msg[n++] = sub->max_hops; + + return n; +} + +static uint16_t hb_subscription_set(struct mesh_node *node, const uint8_t *pkt) { - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - struct timeval time_now; + uint16_t src, dst; + uint8_t period_log; + struct mesh_net *net; + int status; + + src = l_get_le16(pkt); + dst = l_get_le16(pkt + 2); /* SRC must be Unicast, DST can be any legal address except Virtual */ if ((!IS_UNASSIGNED(src) && !IS_UNICAST(src)) || IS_VIRTUAL(dst)) - return -1; - - /* Check if the subscription should be disabled */ - if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst)) { - if (IS_GROUP(hb->sub_dst)) - mesh_net_dst_unreg(net, hb->sub_dst); - - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; - hb->sub_dst = UNASSIGNED_ADDRESS; - hb->sub_src = UNASSIGNED_ADDRESS; - hb->sub_count = 0; - hb->sub_period = 0; - hb->sub_min_hops = 0; - hb->sub_max_hops = 0; - return MESH_STATUS_SUCCESS; - - } else if (!period_log && src == hb->sub_src && dst == hb->sub_dst) { - /* Preserve collected data, but disable */ - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; - hb->sub_period = 0; - return MESH_STATUS_SUCCESS; - } + return 0; - if (hb->sub_dst != dst) { - if (IS_GROUP(hb->sub_dst)) - mesh_net_dst_unreg(net, hb->sub_dst); - if (IS_GROUP(dst)) - mesh_net_dst_reg(net, dst); - } + period_log = pkt[4]; - hb->sub_enabled = !!period_log; - hb->sub_src = src; - hb->sub_dst = dst; - hb->sub_count = 0; - hb->sub_period = log_to_uint32(period_log, 1); - hb->sub_min_hops = 0x00; - hb->sub_max_hops = 0x00; + if (period_log > 0x11) + return 0; - gettimeofday(&time_now, NULL); - hb->sub_start = time_now.tv_sec; + net = node_get_net(node); - if (!hb->sub_enabled) { - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - return MESH_STATUS_SUCCESS; - } + status = mesh_net_set_heartbeat_sub(net, src, dst, period_log); - hb->sub_min_hops = 0xff; + return hb_subscription_get(node, status); +} - if (!hb->sub_timer) - hb->sub_timer = l_timeout_create(hb->sub_period, - hb_sub_timeout_func, net, NULL); - else - l_timeout_modify(hb->sub_timer, hb->sub_period); +static uint16_t hb_publication_get(struct mesh_node *node, int status) +{ + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_pub *pub = mesh_net_get_heartbeat_pub(net); + uint16_t n; - return MESH_STATUS_SUCCESS; + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg); + msg[n++] = status; + l_put_le16(pub->dst, msg + n); + n += 2; + msg[n++] = uint32_to_log(pub->count); + msg[n++] = uint32_to_log(pub->period); + msg[n++] = pub->ttl; + l_put_le16(pub->features, msg + n); + n += 2; + l_put_le16(pub->net_idx, msg + n); + n += 2; + + return n; +} + +static uint16_t hb_publication_set(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t dst, features, net_idx; + uint8_t period_log, count_log, ttl; + struct mesh_net *net; + int status; + + dst = l_get_le16(pkt); + count_log = pkt[2]; + period_log = pkt[3]; + ttl = pkt[4]; + + if (count_log > 0x11 && count_log != 0xff) + return 0; + + if (period_log > 0x11 || ttl > TTL_MASK || IS_VIRTUAL(dst)) + return 0; + + features = l_get_le16(pkt + 5) & 0xf; + net_idx = l_get_le16(pkt + 7); + + net = node_get_net(node); + + status = mesh_net_set_heartbeat_pub(net, dst, features, net_idx, ttl, + count_log, period_log); + + return hb_publication_get(node, status); } static void node_reset(void *user_data) @@ -728,10 +711,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct mesh_node *node = (struct mesh_node *) user_data; struct mesh_net *net; const uint8_t *pkt = data; - struct timeval time_now; uint32_t opcode; - int b_res = MESH_STATUS_SUCCESS; - struct mesh_net_heartbeat *hb; uint16_t n_idx; uint8_t state; bool virt = false; @@ -747,7 +727,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, return false; net = node_get_net(node); - hb = mesh_net_heartbeat_get(net); + l_debug("CONFIG-SRV-opcode 0x%x size %u idx %3.3x", opcode, size, net_idx); @@ -1020,113 +1000,35 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_HEARTBEAT_PUB_SET: - l_debug("OP_CONFIG_HEARTBEAT_PUB_SET"); + l_debug("Config Heartbeat Publication Set"); if (size != 9) return true; - if (pkt[2] > 0x11 || pkt[3] > 0x10 || pkt[4] > 0x7f) - return true; - else if (IS_VIRTUAL(l_get_le16(pkt))) - b_res = MESH_STATUS_INVALID_ADDRESS; - else if (l_get_le16(pkt + 7) != mesh_net_get_primary_idx(net)) - /* Future work: check for valid subnets */ - b_res = MESH_STATUS_INVALID_NETKEY; - - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, - msg); - msg[n++] = b_res; - - memcpy(&msg[n], pkt, 9); - - /* Ignore RFU bits in features */ - l_put_le16(l_get_le16(pkt + 5) & 0xf, &msg[n + 5]); - - /* Add octet count to status */ - n += 9; - - if (b_res != MESH_STATUS_SUCCESS) - break; - - hb->pub_dst = l_get_le16(pkt); - if (hb->pub_dst == UNASSIGNED_ADDRESS || - pkt[2] == 0 || pkt[3] == 0) { - /* - * We might still have a pub_dst here in case - * we need it for State Change heartbeat - */ - hb->pub_count = 0; - hb->pub_period = 0; - } else { - hb->pub_count = (pkt[2] != 0xff) ? - log_to_uint32(pkt[2], 1) : 0xffff; - hb->pub_period = log_to_uint32(pkt[3], 1); - } - - hb->pub_ttl = pkt[4]; - hb->pub_features = l_get_le16(pkt + 5) & 0xf; - hb->pub_net_idx = l_get_le16(pkt + 7); - update_hb_pub_timer(net, hb); - + n = hb_publication_set(node, pkt); break; case OP_CONFIG_HEARTBEAT_PUB_GET: if (size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg); - msg[n++] = b_res; - l_put_le16(hb->pub_dst, msg + n); - n += 2; - msg[n++] = uint32_to_log(hb->pub_count); - msg[n++] = uint32_to_log(hb->pub_period); - msg[n++] = hb->pub_ttl; - l_put_le16(hb->pub_features, msg + n); - n += 2; - l_put_le16(hb->pub_net_idx, msg + n); - n += 2; + n = hb_publication_get(node, MESH_STATUS_SUCCESS); break; case OP_CONFIG_HEARTBEAT_SUB_SET: if (size != 5) return true; - l_debug("Set Sub Period (Log %2.2x) %d sec", - pkt[4], log_to_uint32(pkt[4], 1)); - - b_res = hb_subscription_set(net, l_get_le16(pkt), - l_get_le16(pkt + 2), - pkt[4]); - if (b_res < 0) - return true; + l_debug("Set HB Sub Period Log %2.2x", pkt[4]); - /* Fall through */ + n = hb_subscription_set(node, pkt); + break; case OP_CONFIG_HEARTBEAT_SUB_GET: - if (opcode == OP_CONFIG_HEARTBEAT_SUB_GET && size != 0) - return true; - - gettimeofday(&time_now, NULL); - time_now.tv_sec -= hb->sub_start; - if (time_now.tv_sec >= (long int) hb->sub_period) - time_now.tv_sec = 0; - else - time_now.tv_sec = hb->sub_period - time_now.tv_sec; - - l_debug("Sub Period (Log %2.2x) %d sec", - uint32_to_log(time_now.tv_sec), - (int) time_now.tv_sec); + if (size != 0) + return true; - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); - msg[n++] = b_res; - l_put_le16(hb->sub_src, msg + n); - n += 2; - l_put_le16(hb->sub_dst, msg + n); - n += 2; - msg[n++] = uint32_to_log(time_now.tv_sec); - msg[n++] = uint32_to_log(hb->sub_count); - msg[n++] = hb->sub_count ? hb->sub_min_hops : 0; - msg[n++] = hb->sub_max_hops; + n = hb_subscription_get(node, MESH_STATUS_SUCCESS); break; case OP_CONFIG_POLL_TIMEOUT_GET: @@ -1156,13 +1058,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, static void cfgmod_srv_unregister(void *user_data) { - struct mesh_node *node = user_data; - struct mesh_net *net = node_get_net(node); - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - l_timeout_remove(hb->pub_timer); - l_timeout_remove(hb->sub_timer); - hb->pub_timer = hb->sub_timer = NULL; } static const struct mesh_model_ops ops = { diff --git a/mesh/net.c b/mesh/net.c index b54c647cb..5bfaa181a 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -23,6 +23,8 @@ #define _GNU_SOURCE +#include <sys/time.h> + #include <ell/ell.h> #include "mesh/mesh-defs.h" @@ -132,7 +134,10 @@ struct mesh_net { uint8_t count; } relay; - struct mesh_net_heartbeat heartbeat; + /* Heartbeat info */ + struct mesh_net_heartbeat_sub hb_sub; + struct mesh_net_heartbeat_pub hb_pub; + uint16_t features; struct l_queue *subnets; struct l_queue *msg_cache; @@ -255,35 +260,46 @@ static bool match_friend_key_id(const void *a, const void *b) (key_id == friend->net_key_upd); } -static void idle_mesh_heartbeat_send(void *net) +static void send_hb_publication(void *data) { - mesh_net_heartbeat_send(net); + struct mesh_net *net = data; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + uint8_t msg[4]; + int n = 0; + + if (pub->dst == UNASSIGNED_ADDRESS) + return; + + msg[n++] = NET_OP_HEARTBEAT; + msg[n++] = pub->ttl; + l_put_be16(net->features, msg + n); + n += 2; + + mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), + pub->ttl, 0, 0, pub->dst, msg, n); } static void trigger_heartbeat(struct mesh_net *net, uint16_t feature, - bool in_use) + bool enable) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - - l_debug("%s: %4.4x --> %d", __func__, feature, in_use); + l_debug("HB: %4.4x --> %d", feature, enable); - if (in_use) { - if (net->heartbeat.features & feature) + if (enable) { + if (net->features & feature) return; /* no change */ - hb->features |= feature; + net->features |= feature; } else { - if (!(hb->features & feature)) + if (!(net->features & feature)) return; /* no change */ - hb->features &= ~feature; + net->features &= ~feature; } - if (!(hb->pub_features & feature)) - return; /* not interested in this feature */ - - l_idle_oneshot(idle_mesh_heartbeat_send, net, NULL); + if (!(net->hb_pub.features & feature)) + return; /* no interest in this feature */ + l_idle_oneshot(send_hb_publication, net, NULL); } static bool match_by_friend(const void *a, const void *b) @@ -616,8 +632,6 @@ struct mesh_net *mesh_net_new(struct mesh_node *node) net->destinations = l_queue_new(); net->app_keys = l_queue_new(); - memset(&net->heartbeat, 0, sizeof(net->heartbeat)); - if (!nets) nets = l_queue_new(); @@ -813,8 +827,8 @@ int mesh_net_del_key(struct mesh_net *net, uint16_t idx) appkey_delete_bound_keys(net, idx); /* Disable hearbeat publication on this subnet */ - if (idx == net->heartbeat.pub_net_idx) - net->heartbeat.pub_dst = UNASSIGNED_ADDRESS; + if (idx == net->hb_pub.net_idx) + net->hb_pub.dst = UNASSIGNED_ADDRESS; /* TODO: cancel beacon_enable on this subnet */ @@ -2017,25 +2031,23 @@ static bool ctl_received(struct mesh_net *net, uint16_t key_id, break; case NET_OP_HEARTBEAT: - if (net->heartbeat.sub_enabled && - src == net->heartbeat.sub_src) { + if (net->hb_sub.enabled && src == net->hb_sub.src) { uint8_t hops = pkt[0] - ttl + 1; print_packet("Rx-NET_OP_HEARTBEAT", pkt, len); - if (net->heartbeat.sub_count != 0xffff) - net->heartbeat.sub_count++; + if (net->hb_sub.count != 0xffff) + net->hb_sub.count++; - if (net->heartbeat.sub_min_hops > hops) - net->heartbeat.sub_min_hops = hops; + if (net->hb_sub.min_hops > hops) + net->hb_sub.min_hops = hops; - if (net->heartbeat.sub_max_hops < hops) - net->heartbeat.sub_max_hops = hops; + if (net->hb_sub.max_hops < hops) + net->hb_sub.max_hops = hops; l_debug("HB: cnt:%4.4x min:%2.2x max:%2.2x", - net->heartbeat.sub_count, - net->heartbeat.sub_min_hops, - net->heartbeat.sub_max_hops); + net->hb_sub.count, net->hb_sub.min_hops, + net->hb_sub.max_hops); } break; } @@ -3276,52 +3288,14 @@ int mesh_net_update_key(struct mesh_net *net, uint16_t idx, return MESH_STATUS_SUCCESS; } -static uint16_t get_features(struct mesh_net *net) -{ - uint16_t features = 0; - - if (net->relay.enable) - features |= FEATURE_RELAY; - - if (net->proxy_enable) - features |= FEATURE_PROXY; - - if (net->friend_enable) - features |= FEATURE_FRIEND; - - return features; -} - -struct mesh_net_heartbeat *mesh_net_heartbeat_get(struct mesh_net *net) -{ - return &net->heartbeat; -} - -void mesh_net_heartbeat_send(struct mesh_net *net) +struct mesh_net_heartbeat_sub *mesh_net_get_heartbeat_sub(struct mesh_net *net) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - uint8_t msg[4]; - int n = 0; - - if (hb->pub_dst == UNASSIGNED_ADDRESS) - return; - - msg[n++] = NET_OP_HEARTBEAT; - msg[n++] = hb->pub_ttl; - l_put_be16(hb->features, msg + n); - n += 2; - - mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), - hb->pub_ttl, 0, 0, hb->pub_dst, msg, n); + return &net->hb_sub; } -void mesh_net_heartbeat_init(struct mesh_net *net) +struct mesh_net_heartbeat_pub *mesh_net_get_heartbeat_pub(struct mesh_net *net) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - - memset(hb, 0, sizeof(struct mesh_net_heartbeat)); - hb->sub_min_hops = 0xff; - hb->features = get_features(net); + return &net->hb_pub; } void mesh_net_set_iv_index(struct mesh_net *net, uint32_t index, bool update) @@ -3559,3 +3533,156 @@ void net_msg_add_replay_cache(struct mesh_net *net, uint16_t src, uint32_t seq, /* Optimize so that most recent conversations stay earliest in cache */ l_queue_push_head(net->replay_cache, rpe); } + +static void hb_sub_timeout_func(struct l_timeout *timeout, void *user_data) +{ + struct mesh_net *net = user_data; + struct mesh_net_heartbeat_sub *sub = &net->hb_sub; + + l_debug("HB Subscription Ended"); + l_timeout_remove(sub->timer); + sub->timer = NULL; + sub->enabled = false; +} + +static uint32_t log_to_uint32(uint8_t log) +{ + if (!log) + return 0x0000; + + return (1 << (log - 1)); +} + +int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, + uint8_t period_log) +{ + struct mesh_net_heartbeat_sub *sub = &net->hb_sub; + struct timeval time_now; + + if (!net) + return MESH_STATUS_UNSPECIFIED_ERROR; + + /* Check if the subscription should be disabled */ + if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst)) { + if (IS_GROUP(sub->dst)) + mesh_net_dst_unreg(net, sub->dst); + + sub->enabled = false; + sub->dst = UNASSIGNED_ADDRESS; + sub->src = UNASSIGNED_ADDRESS; + sub->count = 0; + sub->period = 0; + sub->min_hops = 0; + sub->max_hops = 0; + + } else if (!period_log && src == sub->src && dst == sub->dst) { + /* Preserve collected data, but disable */ + sub->enabled = false; + sub->period = 0; + + } else if (sub->dst != dst) { + if (IS_GROUP(sub->dst)) + mesh_net_dst_unreg(net, sub->dst); + + if (IS_GROUP(dst)) + mesh_net_dst_reg(net, dst); + + sub->enabled = !!period_log; + sub->src = src; + sub->dst = dst; + sub->count = 0; + sub->period = log_to_uint32(period_log); + sub->min_hops = 0x00; + sub->max_hops = 0x00; + gettimeofday(&time_now, NULL); + sub->start = time_now.tv_sec; + } + + /* TODO: Save to node config */ + + if (!sub->enabled) { + l_timeout_remove(sub->timer); + sub->timer = NULL; + return MESH_STATUS_SUCCESS; + } + + sub->min_hops = 0xff; + + if (!sub->timer) + sub->timer = l_timeout_create(sub->period, hb_sub_timeout_func, + net, NULL); + else + l_timeout_modify(sub->timer, sub->period); + + return MESH_STATUS_SUCCESS; +} + +static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) +{ + struct mesh_net *net = user_data; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + + send_hb_publication(net); + + if (pub->count != 0xffff) + pub->count--; + + if (pub->count > 0) + l_timeout_modify(pub->timer, pub->period); + else { + l_timeout_remove(pub->timer); + pub->timer = NULL; + } +} + +static void update_hb_pub_timer(struct mesh_net *net, + struct mesh_net_heartbeat_pub *pub) +{ + if (IS_UNASSIGNED(pub->dst) || pub->count == 0) { + l_timeout_remove(pub->timer); + pub->timer = NULL; + return; + } + + if (!pub->timer) + pub->timer = l_timeout_create(pub->period, + hb_pub_timeout_func, net, NULL); + else + l_timeout_modify(pub->timer, pub->period); +} + +int mesh_net_set_heartbeat_pub(struct mesh_net *net, uint16_t dst, + uint16_t features, uint16_t idx, uint8_t ttl, + uint8_t count_log, uint8_t period_log) +{ + struct mesh_subnet *subnet; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + + if (!net) + return MESH_STATUS_UNSPECIFIED_ERROR; + + subnet = l_queue_find(net->subnets, match_key_index, + L_UINT_TO_PTR(idx)); + if (!subnet) + return MESH_STATUS_INVALID_NETKEY; + + pub->dst = dst; + + if (pub->dst == UNASSIGNED_ADDRESS) { + pub->count = 0; + pub->period = 0; + pub->ttl = 0; + } else { + pub->count = (count_log != 0xff) ? + log_to_uint32(count_log) : 0xffff; + pub->period = log_to_uint32(period_log); + } + + pub->ttl = ttl; + pub->features = features; + pub->net_idx = idx; + update_hb_pub_timer(net, pub); + + /* TODO: Save to node config */ + return MESH_STATUS_SUCCESS; +} diff --git a/mesh/net.h b/mesh/net.h index 7117f1a47..0e36ab068 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -131,25 +131,27 @@ struct mesh_net_prov_caps { uint16_t input_action; } __packed; -struct mesh_net_heartbeat { - struct l_timeout *pub_timer; - struct l_timeout *sub_timer; - struct timeval sub_time; - bool sub_enabled; - uint32_t pub_period; - uint32_t sub_period; - uint32_t sub_start; - uint16_t pub_dst; - uint16_t pub_count; - uint16_t pub_features; +struct mesh_net_heartbeat_sub { + struct l_timeout *timer; + uint32_t start; + uint32_t period; uint16_t features; - uint16_t pub_net_idx; - uint16_t sub_src; - uint16_t sub_dst; - uint16_t sub_count; - uint8_t pub_ttl; - uint8_t sub_min_hops; - uint8_t sub_max_hops; + uint16_t src; + uint16_t dst; + uint16_t count; + bool enabled; + uint8_t min_hops; + uint8_t max_hops; +}; + +struct mesh_net_heartbeat_pub { + struct l_timeout *timer; + uint32_t period; + uint16_t dst; + uint16_t count; + uint16_t features; + uint16_t net_idx; + uint8_t ttl; }; struct mesh_key_set { @@ -330,9 +332,13 @@ void mesh_net_send_seg(struct mesh_net *net, uint32_t key_id, uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t src, uint16_t dst, uint32_t hdr, const void *seg, uint16_t seg_len); -struct mesh_net_heartbeat *mesh_net_heartbeat_get(struct mesh_net *net); -void mesh_net_heartbeat_init(struct mesh_net *net); -void mesh_net_heartbeat_send(struct mesh_net *net); +struct mesh_net_heartbeat_sub *mesh_net_get_heartbeat_sub(struct mesh_net *net); +int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, + uint8_t period_log); +struct mesh_net_heartbeat_pub *mesh_net_get_heartbeat_pub(struct mesh_net *net); +int mesh_net_set_heartbeat_pub(struct mesh_net *net, uint16_t dst, + uint16_t features, uint16_t idx, uint8_t ttl, + uint8_t count_log, uint8_t period_log); bool mesh_net_key_list_get(struct mesh_net *net, uint8_t *buf, uint16_t *count); uint16_t mesh_net_get_primary_idx(struct mesh_net *net); uint32_t mesh_net_friend_timeout(struct mesh_net *net, uint16_t addr); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YJxMNGO6I188PwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 08:29:55 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AMu7MmO6I18f7wEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 08:29:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 34C7140990; Fri, 31 Jul 2020 08:29:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731396AbgGaG3n convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 02:29:43 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:51784 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731351AbgGaG3n (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 02:29:43 -0400 Received: from marcel-macpro.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 33F24CED04; Fri, 31 Jul 2020 08:39:44 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2] Bluetooth: use the proper scan params when conn is pending From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200731010535.1422455-1-alainm@chromium.org> Date: Fri, 31 Jul 2020 08:29:41 +0200 Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Yu Liu <yudiliu@google.com> Content-Transfer-Encoding: 8BIT Message-Id: <C43B1571-6221-4D1A-A4F7-E211FE69F499@holtmann.org> References: <20200731010535.1422455-1-alainm@chromium.org> To: Alain Michaud <alainm@chromium.org> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 34C7140990 X-Rspamd-UID: e8b35f Hi Alain, > When an LE connection is requested and an RPA update is needed via > hci_connect_le_scan, the default scanning parameters are used rather > than the connect parameters. This leads to significant delays in the > connection establishment process when using lower duty cycle scanning > parameters. > > The patch simply looks at the pended connection list when trying to > determine which scanning parameters should be used. > > Before: > < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8 > #378 [hci0] 1659.247156 > Own address type: Public (0x00) > Filter policy: Ignore not in white list (0x01) > PHYs: 0x01 > Entry 0: LE 1M > Type: Passive (0x00) > Interval: 367.500 msec (0x024c) > Window: 37.500 msec (0x003c) > > After: > < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8 > #39 [hci0] 7.422109 > Own address type: Public (0x00) > Filter policy: Ignore not in white list (0x01) > PHYs: 0x01 > Entry 0: LE 1M > Type: Passive (0x00) > Interval: 60.000 msec (0x0060) > Window: 60.000 msec (0x0060) > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Reviewed-by: Yu Liu <yudiliu@google.com> > Signed-off-by: Alain Michaud <alainm@chromium.org> please swap these around, the signed-off-by from the author should come first. > > --- > > Changes in v2: > - Fixing Yu's email tag > > net/bluetooth/hci_request.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) Patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WISQLlfLI1+ktQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 09:42:15 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id sGSLLVfLI1+VlAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 09:42:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AE25DA1996; Fri, 31 Jul 2020 09:42:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731692AbgGaHmI (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 03:42:08 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:39910 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbgGaHmI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 03:42:08 -0400 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.0.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1k1Pfy-0001TP-Sl; Fri, 31 Jul 2020 17:42:00 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Fri, 31 Jul 2020 17:41:58 +1000 Date: Fri, 31 Jul 2020 17:41:58 +1000 From: Herbert Xu <herbert@gondor.apana.org.au> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org Cc: Tudor Ambarus <tudor.ambarus@microchip.com> Subject: [PATCH] Bluetooth: Remove CRYPTO_ALG_INTERNAL flag Message-ID: <20200731074158.GA20263@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: AE25DA1996 X-Rspamd-UID: 314778 The flag CRYPTO_ALG_INTERNAL is not meant to be used outside of the Crypto API. It isn't needed here anyway. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> diff --git a/net/bluetooth/selftest.c b/net/bluetooth/selftest.c index 03e3c89c3046..f71c6fa65fb3 100644 --- a/net/bluetooth/selftest.c +++ b/net/bluetooth/selftest.c @@ -205,7 +205,7 @@ static int __init test_ecdh(void) calltime = ktime_get(); - tfm = crypto_alloc_kpp("ecdh", CRYPTO_ALG_INTERNAL, 0); + tfm = crypto_alloc_kpp("ecdh", 0, 0); if (IS_ERR(tfm)) { BT_ERR("Unable to create ECDH crypto context"); err = PTR_ERR(tfm); diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index c2c5ab05fa7e..b0d7310b9d16 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -1387,7 +1387,7 @@ static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) goto zfree_smp; } - smp->tfm_ecdh = crypto_alloc_kpp("ecdh", CRYPTO_ALG_INTERNAL, 0); + smp->tfm_ecdh = crypto_alloc_kpp("ecdh", 0, 0); if (IS_ERR(smp->tfm_ecdh)) { BT_ERR("Unable to create ECDH crypto context"); goto free_shash; @@ -3282,7 +3282,7 @@ static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid) return ERR_CAST(tfm_cmac); } - tfm_ecdh = crypto_alloc_kpp("ecdh", CRYPTO_ALG_INTERNAL, 0); + tfm_ecdh = crypto_alloc_kpp("ecdh", 0, 0); if (IS_ERR(tfm_ecdh)) { BT_ERR("Unable to create ECDH crypto context"); crypto_free_shash(tfm_cmac); @@ -3847,7 +3847,7 @@ int __init bt_selftest_smp(void) return PTR_ERR(tfm_cmac); } - tfm_ecdh = crypto_alloc_kpp("ecdh", CRYPTO_ALG_INTERNAL, 0); + tfm_ecdh = crypto_alloc_kpp("ecdh", 0, 0); if (IS_ERR(tfm_ecdh)) { BT_ERR("Unable to create ECDH crypto context"); crypto_free_shash(tfm_cmac); -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MEubEerZI1+O/AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 10:44:26 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id YLSpD+rZI1+jAwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 10:44:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1B16DA158F; Fri, 31 Jul 2020 10:44:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731912AbgGaIoJ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 04:44:09 -0400 Received: from mail-il1-f197.google.com ([209.85.166.197]:54253 "EHLO mail-il1-f197.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731374AbgGaIoG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 04:44:06 -0400 Received: by mail-il1-f197.google.com with SMTP id v13so7942992ila.20 for <linux-bluetooth@vger.kernel.org>; Fri, 31 Jul 2020 01:44:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=2MiWhebPAZEwNHbE02ggeQmHTDlIjaaAtS5l21f1BPw=; b=iBXQaP86SCGC6SIP7sne1BNpGX6rpQj+YGVXRMfMyPgtO8oypRGgZBZkacYwqx+S7D o3ZRYyMwvoqWW24RlPm0Vg2P5LjjaSYc7+WRXRgkV205HG8uj59QIP8Zj1ySEpqn6xDA ZdaJ2OEfRnZJUenWX/p4SibmZZ7++44xuQB75NGbZSXZqIUPR3me0xnPdB3DnAFt6iDS I2b8ZI6i9A/9odjwBCZxbXHkD4WAHXpbO/8txkLNC/Gj6ckYluHQXhifV59kjfAeHL9U 0BNeH4WP6AgymL63R+vr79gAPKkQyJVLXf8AOVLu+AS820BrHu4mQISdCkAPzVZl46pW FNtw== X-Gm-Message-State: AOAM5308J1lqpAHrsIt5q05hDYQO2ZVDN49IoXA+TsJerr74+r74+iXR cOzylYQjP8e3BsSBrXDq2r1Qe5XuujRdXtiToIgK3tPnGT/Z X-Google-Smtp-Source: ABdhPJy4Rj2LLEiAspTEtCegum11hHhIEmst76GFNZjb8ziE/nZyOIvy4zdOy45COS+BYVrIBbRSJc0ymQWmZ3YMzOpl0u7SggRq MIME-Version: 1.0 X-Received: by 2002:a6b:7416:: with SMTP id s22mr2545374iog.160.1596185045466; Fri, 31 Jul 2020 01:44:05 -0700 (PDT) Date: Fri, 31 Jul 2020 01:44:05 -0700 In-Reply-To: <000000000000f6d80505abb42b60@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000a1816805abb8caa1@google.com> Subject: Re: WARNING in cancel_delayed_work From: syzbot <syzbot+35e70efb794757d7e175@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, johannes.berg@intel.com, johannes@sipsolutions.net, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, luciano.coelho@intel.com, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1B16DA158F X-Rspamd-UID: cd2ed3 syzbot has bisected this issue to: commit fbd05e4a6e82fd573d3aa79e284e424b8d78c149 Author: Luca Coelho <luciano.coelho@intel.com> Date: Thu Sep 15 15:15:09 2016 +0000 cfg80211: add helper to find an IE that matches a byte-array bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1790af82900000 start commit: 83bdc727 random32: remove net_rand_state from the latent e.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1050af82900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=35e70efb794757d7e175 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1160faa2900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11816098900000 Reported-by: syzbot+35e70efb794757d7e175@syzkaller.appspotmail.com Fixes: fbd05e4a6e82 ("cfg80211: add helper to find an IE that matches a byte-array") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eB1fFQMgJF/QAgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 15:43:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id MLnQEwMgJF/gHwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 15:43:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8C20740676; Fri, 31 Jul 2020 15:43:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729729AbgGaNnY (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 09:43:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbgGaNnY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 09:43:24 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5AD9C061574 for <linux-bluetooth@vger.kernel.org>; Fri, 31 Jul 2020 06:43:23 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id t6so19547721ljk.9 for <linux-bluetooth@vger.kernel.org>; Fri, 31 Jul 2020 06:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=y8PXeEt0L8JsJtZtNq1ErYk/sYqqK5LKuJSlIGvyQuM=; b=Qu7CBdOCzcT8826VDP3PCS8bE3b88CLSDRpfyq47AME0PVm+nIIt34JR/EmX5gqO9r +mf6XNlsaTAQnhXMikrc0tMAAxs7au0vFUf8XmYAa7okPHgZKZ/FnMqa7iQW0H+WQf4Q 2nQkzU+XAPwF3S/qDFfNRfgzBIiyIEFE3Eb2H2gcLBwEifdMNMyP8DcsegGZsG9lccJf +H8BiE+l7PpmJNcW5+ATaqeKCEKNYr2rf5ED8mGULBp7dDCEPRQYrMnaf6W0i8Bce7if WCJxs8hzas9hC6DFSNeC2j+kBLp3Dk3X9enkveoWyD1/DU5pgAAFDCvf6wXY/juKqI/g 5TTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=y8PXeEt0L8JsJtZtNq1ErYk/sYqqK5LKuJSlIGvyQuM=; b=ZgU+WjgsH1ggJjcgjEBKKnODdeWWryFg4cm+woiM43XIFQkZBKShwp0rprj62Lupt0 J072krJ8rZECPRPvGnGwZsGSrFxU0px27XTOW3uTVgx7iuaR2/5sdZst06Qrp4+k2StT wiqLxwMyVYNcIsQSC9YcWfiq54YTm1Pnit5GaH5rlZSRt8NYQetovskMaCBgVH4YPcQy ay/7TM063EoOhVSrPSr13r4GDg+7+B6Pxo+HNR5H2odXhic9HDNbGXmqzzhWY8Qpulor NLDTc6GNCkLMM7m5V8pGcgu9pSqr7JlIS8t9bYDAqledCt1/VepCdDfH8A9MExMyUQyf AXHw== X-Gm-Message-State: AOAM531YtCOcZ7xqhLaIySkIMNQs+OQ6aJ+Nopxrrwv2ZT6OAAMNzgrc HAi81h48aa08DEoLEaRAQRqMyeoA X-Google-Smtp-Source: ABdhPJzxXid1KIJmsdyajf+mvtdX5ZxnyeYkvVrfOeCBUIl2P6OZTKB2ooBXp20o87GfirLG2Obh0A== X-Received: by 2002:a2e:7f1a:: with SMTP id a26mr1158099ljd.123.1596203002107; Fri, 31 Jul 2020 06:43:22 -0700 (PDT) Received: from localhost (91-154-113-38.elisa-laajakaista.fi. [91.154.113.38]) by smtp.gmail.com with ESMTPSA id n205sm1939590lfd.59.2020.07.31.06.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 06:43:21 -0700 (PDT) Date: Fri, 31 Jul 2020 16:43:19 +0300 From: Johan Hedberg <johan.hedberg@gmail.com> To: Marcel Holtmann <marcel@holtmann.org> Cc: linux-bluetooth@vger.kernel.org Subject: Re: [PATCH] Bluetooth: Increment management interface revision Message-ID: <20200731134319.GA77314@jhedberg-mac01.home> Mail-Followup-To: Marcel Holtmann <marcel@holtmann.org>, linux-bluetooth@vger.kernel.org References: <20200730174011.71784-1-marcel@holtmann.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200730174011.71784-1-marcel@holtmann.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8C20740676 X-Rspamd-UID: 34ac2c Hi Marcel, On Thu, Jul 30, 2020, Marcel Holtmann wrote: > Increment the mgmt revision due to the recently added new commands. > > Signed-off-by: Marcel Holtmann <marcel@holtmann.org> > --- > net/bluetooth/mgmt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied to bluetooth-next. Thanks. Johan Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YIy7GyogJF/RAgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 15:44:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id oCJGGiogJF+NlgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 15:44:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3928A40180; Fri, 31 Jul 2020 15:44:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730448AbgGaNoE (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 09:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbgGaNoE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 09:44:04 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3EB1C061574 for <linux-bluetooth@vger.kernel.org>; Fri, 31 Jul 2020 06:44:03 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id t23so8970008ljc.3 for <linux-bluetooth@vger.kernel.org>; Fri, 31 Jul 2020 06:44:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=lo9C2xqeYkWsxppLoGKUzu0q9gC446jx7IkUkPm91X8=; b=dXakR4S/Bb/wgfWJjE1KHhI61z0LuDuKggBu7VYG0hOFo2/ebDpUuE5uj/fiVZHPda qM9UkOM+7N4oMJNTMTGXATXVFL5LW/G9G4l+ygQnwtNDURg7aTQ+1EvAT+987Y2NhxSX c69BSSHsIdu4Z3fN799/c7+orNWu1xgqNAMEiGzop0bZHzc4xbJRKK8fcEmF6JOPSOVQ 7XdvZdQqLqPc9IbxV6UpCYMlHT3lU2kbJ6qN/EVvbNiypslfeYbwKXC/bieg2RmWfBoG 4UPZ2r7SiYGSkQAvEmbutL/oc7DAHkWM9A74RU9rxHu0aXAan4rlMYSvbPealg/s3LO0 RoXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=lo9C2xqeYkWsxppLoGKUzu0q9gC446jx7IkUkPm91X8=; b=clzrnTq28AhSyUrofvnegm/tXbwZaFqZBOoqvRhXjvryWObeoU6H21JPezKrpBHIL/ O2DRQ4XhDcjdh1tnCm8cfrR5f3JkdwpgYBilIXK4SWplg6k4wbCYdSBszQpovedhnOi9 x9wXbkf0s43fzwSe2LKqAvu9LprbN0ozP+Rd9Zc+dPKJk3PIrFU8goPN49nxuF82tXV3 K1imaPIP3NmWXLSmStIKHx3zfYyhHOqbt2vgdK2K7hfR/PxSvttY2Tdxl4FEj2NY1fCn kh3cyJeFylOj1+ZWcxgnSYOf2f+r78YrzZLnU0wrdgL/5aLhpslRPeo+gdbOoLTIMvaU YaaA== X-Gm-Message-State: AOAM531KZNgVFAVp0ag+Ith4xXreDgxpcOl5L4csNtw2vzRd7DeRx4k+ oo6SK2RhJdmYJrQ3ULcUByk= X-Google-Smtp-Source: ABdhPJyZr/T9Nc7yd1lyN7Zn1ZVws7thHHCvNHgvE7Q6gu3OtIcK8IIJWcMkjehqDt4hQhk4lvneuQ== X-Received: by 2002:a2e:3503:: with SMTP id z3mr1805872ljz.336.1596203042378; Fri, 31 Jul 2020 06:44:02 -0700 (PDT) Received: from localhost (91-154-113-38.elisa-laajakaista.fi. [91.154.113.38]) by smtp.gmail.com with ESMTPSA id v14sm1676084ljk.10.2020.07.31.06.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 06:44:01 -0700 (PDT) Date: Fri, 31 Jul 2020 16:44:00 +0300 From: Johan Hedberg <johan.hedberg@gmail.com> To: Herbert Xu <herbert@gondor.apana.org.au> Cc: Marcel Holtmann <marcel@holtmann.org>, linux-bluetooth@vger.kernel.org, Tudor Ambarus <tudor.ambarus@microchip.com> Subject: Re: [PATCH] Bluetooth: Remove CRYPTO_ALG_INTERNAL flag Message-ID: <20200731134400.GB77314@jhedberg-mac01.home> Mail-Followup-To: Herbert Xu <herbert@gondor.apana.org.au>, Marcel Holtmann <marcel@holtmann.org>, linux-bluetooth@vger.kernel.org, Tudor Ambarus <tudor.ambarus@microchip.com> References: <20200731074158.GA20263@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200731074158.GA20263@gondor.apana.org.au> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.21 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3928A40180 X-Rspamd-UID: e37f68 Hi Herbert, On Fri, Jul 31, 2020, Herbert Xu wrote: > The flag CRYPTO_ALG_INTERNAL is not meant to be used outside of > the Crypto API. It isn't needed here anyway. > > Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Applied to bluetooth-next. Thanks. Johan Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +FtHGTMsJF9TPwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 16:35:31 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6FShFzMsJF+cxwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 16:35:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E474BA1580; Fri, 31 Jul 2020 16:35:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728597AbgGaOfV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 10:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728697AbgGaOfV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 10:35:21 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED6BCC061574; Fri, 31 Jul 2020 07:35:20 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id h12so4758537pgf.7; Fri, 31 Jul 2020 07:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:mime-version :content-disposition; bh=VLbajNqJUMYFLAkFWvJlnYUaYnpgXI5a4nI621gWylA=; b=FL9bLTARP7lqQu8UAECga0zexpTERH34lhWR/wh6PLeABhQBYrbJIWTfz3mHDR5eC6 srDHg/iE8J1RB9E3bC1B3bhRKyAeINdF6EHHGH4ay12F/a+q6GHC8U9FxIo/u4tLCPbo JyFjZBfHERaozFF4SLub6ByCr2FKOCXIxm0XM982CYWwuV2T3Y95Zcnox0fFbuXJfWS7 GLCCnvFIWNMX8Q7Ta8nuy9TSWH51jlh3PzCRZzmzKJnv6H6eW853yJxQNDTRLR9galol d3z4wvoRMtog/w/TS7v04yZ44GGNhLzqmrMJKTUMM4iigGVF/uhUgjkpHZqdc8I1p4yp LAJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:mime-version:content-disposition; bh=VLbajNqJUMYFLAkFWvJlnYUaYnpgXI5a4nI621gWylA=; b=E0yJldlnOBXWRMezerpx70QjwSQ7Q/r1wcL4zSb9+XnO51kiFx7tQc6BmokuZrx2F7 NQVGzkSAs72QrLnHyR2eDCx+WtpIqwOpYPBktjPrSXCxuDlWE72s6vleI/A3EAJ7uhJf NXA9dKMbNUR84Fd+xk55Xujy7/ImWbQZTESPRDYmgNUDEZXcZZPpCu04H70HA6tBt/vV Iz6LH66HYQw4TFEHKJpTXkiYvHqBqB2xOASmhvD3dbQSWwD6HtxOPAQBBwCv1DodQrVS hM3Ck+pP+dQTFdTFeVvOajkBs6v/mRajg/CwGGa3flf5TKANMM3hM3LvVa3ychJaE/AE 8z+Q== X-Gm-Message-State: AOAM53215zLXxJuzTydVsc6+k0HY57dahiBIOrnid4APCNTaPyCqoe7z SinnNxO5znvt2GK9EDigcguv74JJzvY= X-Google-Smtp-Source: ABdhPJw4+RSjYjidqyCq0HJT4pb78WhAIHTwaY4G8Qhq3JvheyLpQg6GujglaZ3auLAhp5bFI8JvDw== X-Received: by 2002:a62:fcc6:: with SMTP id e189mr3836328pfh.25.1596206119052; Fri, 31 Jul 2020 07:35:19 -0700 (PDT) Received: from localhost ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id mr21sm7863948pjb.57.2020.07.31.07.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 07:35:18 -0700 (PDT) Date: Fri, 31 Jul 2020 17:35:15 +0300 From: Johan Hedberg <johan.hedberg@gmail.com> To: davem@davemloft.net Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: pull request: bluetooth-next 2020-07-31 Message-ID: <20200731143515.GA79165@markorti-mobl.ger.corp.intel.com> Mail-Followup-To: davem@davemloft.net, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HcAYCG3uE/tztfnV" Content-Disposition: inline Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.34 / 15.00 / 200.00 X-Rspamd-Queue-Id: E474BA1580 X-Rspamd-UID: 8a4f86 --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Dave, Here's the main bluetooth-next pull request for 5.9: - Fix firmware filenames for Marvell chipsets - Several suspend-related fixes - Addedd mgmt commands for runtime configuration - Multiple fixes for Qualcomm-based controllers - Add new monitoring feature for mgmt - Fix handling of legacy cipher (E4) together with security level 4 - Add support for Realtek 8822CE controller - Fix issues with Chinese controllers using fake VID/PID values - Multiple other smaller fixes & improvements Please let me know if there are any issues pulling. Thanks. Johan --- The following changes since commit 065fcfd49763ec71ae345bb5c5a74f961031e70e: selftests: net: ip_defrag: ignore EPERM (2020-06-02 15:54:20 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.gi= t for-upstream for you to fetch changes up to 075f77324f90149bac12c8a705dae5786a1d24fb: Bluetooth: Remove CRYPTO_ALG_INTERNAL flag (2020-07-31 16:42:04 +0300) ---------------------------------------------------------------- Abhishek Pandit-Subedi (15): Bluetooth: Allow suspend even when preparation has failed Bluetooth: btmrvl_sdio: Set parent dev to hdev Bluetooth: btmrvl_sdio: Implement prevent_wake Bluetooth: btmrvl_sdio: Refactor irq wakeup Bluetooth: Add bdaddr_list_with_flags for classic whitelist Bluetooth: Replace wakeable list with flag Bluetooth: Replace wakeable in hci_conn_params Bluetooth: Add get/set device flags mgmt op Bluetooth: Add hci_dev_lock to get/set device flags Bluetooth: btusb: Reset port on cmd timeout Bluetooth: btusb: BTUSB_WAKEUP_DISABLE prevents wake Bluetooth: Don't restart scanning if paused Bluetooth: btusb: Comment on unbalanced pm reference Bluetooth: Fix suspend notifier race Revert "Bluetooth: btusb: Disable runtime suspend on Realtek devices" Alain Michaud (11): Bluetooth: Removing noisy dbg message Bluetooth: Add support for BT_PKT_STATUS CMSG data for SCO connections Bluetooth: Use only 8 bits for the HCI CMSG state flags Bluetooth: mgmt: read/set system parameter definitions Bluetooth: centralize default value initialization. Bluetooth: implement read/set default system parameters mgmt Bluetooth: use configured params for ext adv Bluetooth: Adding a configurable autoconnect timeout Bluetooth: use configured default params for active scans Bluetooth: le_simult_central_peripheral experimental feature Bluetooth: use the proper scan params when conn is pending Alexander A. Klimov (1): Replace HTTP links with HTTPS ones: BLUETOOTH SUBSYSTEM Balakrishna Godavarthi (3): Bluetooth: hci_qca: Disable SoC debug logging for WCN3991 Bluetooth: hci_qca: Increase SoC idle timeout to 200ms Bluetooth: hci_qca: Request Tx clock vote off only when Tx is pending Chethan T N (2): Bluetooth: btusb: Add support to read Intel debug feature Bluetooth: btusb: Configure Intel debug feature based on available su= pport Dan Carpenter (1): Bluetooth: hci_qca: Fix an error pointer dereference Daniel Winkler (1): Bluetooth: Add per-instance adv disable/remove Gustavo A. R. Silva (3): Bluetooth: core: Use fallthrough pseudo-keyword Bluetooth: RFCOMM: Use fallthrough pseudo-keyword Bluetooth: Use fallthrough pseudo-keyword Herbert Xu (1): Bluetooth: Remove CRYPTO_ALG_INTERNAL flag Hilda Wu (1): Bluetooth: btusb: USB alternate setting 1 for WBS Ismael Ferreras Morezuelas (1): Bluetooth: btusb: Fix and detect most of the Chinese Bluetooth contro= llers Joseph Hwang (1): Bluetooth: btusb: add Realtek 8822CE to usb_device_id table Kiran K (1): Bluetooth: btusb: Refactor of firmware download flow for Intel conrol= lers Lihong Kou (1): Bluetooth: add a mutex lock to avoid UAF in do_enale_set Luiz Augusto von Dentz (1): Bluetooth: Disconnect if E0 is used for Level 4 Manish Mandlik (2): Bluetooth: Check scan state before disabling during suspend Bluetooth: Terminate the link if pairing is cancelled Marcel Holtmann (6): Bluetooth: mgmt: Add commands for runtime configuration Bluetooth: mgmt: Use command complete on success for set system config Bluetooth: Translate additional address type correctly Bluetooth: Configure controller address resolution if available Bluetooth: Update resolving list when updating whitelist Bluetooth: Increment management interface revision Martin Blumenstingl (1): dt-bindings: net: bluetooth: realtek: Fix uart-has-rtscts example Matthias Kaehlcke (4): Bluetooth: hci_qca: Simplify determination of serial clock on/off sta= te from votes Bluetooth: hci_qca: Only remove TX clock vote after TX is completed Bluetooth: hci_qca: Skip serdev wait when no transfer is pending Bluetooth: hci_qca: Refactor error handling in qca_suspend() Max Chou (1): Bluetooth: Return NOTIFY_DONE for hci_suspend_notifier Miao-chen Chou (9): Bluetooth: Add definitions for advertisement monitor features Bluetooth: Add handler of MGMT_OP_READ_ADV_MONITOR_FEATURES Bluetooth: Add handler of MGMT_OP_ADD_ADV_PATTERNS_MONITOR Bluetooth: Add handler of MGMT_OP_REMOVE_ADV_MONITOR Bluetooth: Notify adv monitor added event Bluetooth: Notify adv monitor removed event Bluetooth: Update background scan and report device based on advertis= ement monitors Bluetooth: Fix kernel oops triggered by hci_adv_monitors_clear() Bluetooth: Use whitelist for scan policy when suspending Nicolas Boichat (2): Bluetooth: hci_h5: Set HCI_UART_RESET_ON_INIT to correct flags Bluetooth: hci_serdev: Only unregister device if it was registered Pali Roh=E1r (4): mwifiex: Fix firmware filename for sd8977 chipset mwifiex: Fix firmware filename for sd8997 chipset btmrvl: Fix firmware filename for sd8977 chipset btmrvl: Fix firmware filename for sd8997 chipset Patrick Steinhardt (1): Bluetooth: Fix update of connection state in `hci_encrypt_cfm` Peilin Ye (3): Bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result= _evt() Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_evt() Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi= _evt() Sathish Narasimman (5): Bluetooth: Translate additional address type during le_conn Bluetooth: Let controller creates RPA during le create conn Bluetooth: Enable/Disable address resolution during le create conn Bluetooth: Enable RPA Timeout Bluetooth: Enable controller RPA resolution using Experimental feature Sean Wang (2): Bluetooth: btusb: fix up firmware download sequence Bluetooth: btmtksdio: fix up firmware download sequence Venkata Lakshmi Narayana Gubba (3): Bluetooth: hci_qca: Bug fix during SSR timeout Bluetooth: hci_qca: Bug fixes for SSR Bluetooth: hci_qca: Stop collecting memdump again for command timeout= during SSR .../devicetree/bindings/net/realtek-bluetooth.yaml | 2 +- drivers/bluetooth/bcm203x.c | 2 +- drivers/bluetooth/bluecard_cs.c | 2 - drivers/bluetooth/btintel.c | 59 +++ drivers/bluetooth/btintel.h | 21 + drivers/bluetooth/btmrvl_main.c | 11 + drivers/bluetooth/btmrvl_sdio.c | 21 +- drivers/bluetooth/btmtksdio.c | 16 +- drivers/bluetooth/btqca.c | 27 + drivers/bluetooth/btqca.h | 2 + drivers/bluetooth/btusb.c | 303 +++++++---- drivers/bluetooth/hci_h5.c | 2 +- drivers/bluetooth/hci_ll.c | 2 +- drivers/bluetooth/hci_qca.c | 134 +++-- drivers/bluetooth/hci_serdev.c | 3 +- drivers/net/wireless/marvell/mwifiex/sdio.h | 4 +- include/net/bluetooth/bluetooth.h | 12 + include/net/bluetooth/hci.h | 28 +- include/net/bluetooth/hci_core.h | 107 +++- include/net/bluetooth/hci_sock.h | 4 +- include/net/bluetooth/mgmt.h | 95 ++++ include/net/bluetooth/sco.h | 2 + net/bluetooth/6lowpan.c | 5 + net/bluetooth/Kconfig | 2 +- net/bluetooth/Makefile | 2 +- net/bluetooth/af_bluetooth.c | 5 +- net/bluetooth/hci_conn.c | 51 +- net/bluetooth/hci_core.c | 212 +++++++- net/bluetooth/hci_event.c | 71 ++- net/bluetooth/hci_request.c | 286 ++++++++-- net/bluetooth/hci_request.h | 5 +- net/bluetooth/hci_sock.c | 7 +- net/bluetooth/l2cap_core.c | 25 +- net/bluetooth/l2cap_sock.c | 4 +- net/bluetooth/mgmt.c | 577 +++++++++++++++++= +++- net/bluetooth/mgmt_config.c | 283 ++++++++++ net/bluetooth/mgmt_config.h | 17 + net/bluetooth/msft.c | 7 + net/bluetooth/msft.h | 9 + net/bluetooth/rfcomm/core.c | 2 +- net/bluetooth/rfcomm/sock.c | 2 +- net/bluetooth/sco.c | 32 ++ net/bluetooth/selftest.c | 2 +- net/bluetooth/smp.c | 8 +- 44 files changed, 2149 insertions(+), 324 deletions(-) create mode 100644 net/bluetooth/mgmt_config.c create mode 100644 net/bluetooth/mgmt_config.h --HcAYCG3uE/tztfnV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQ8m6QjaLXd1XJ73Dsfyv3T9pQ3KgUCXyQsIAAKCRAfyv3T9pQ3 Kn7LAQCCcnriFiWIZNDceKtkAIfn8kQs7sYNvhgWhzIymvfVpgEAwgtQpMcKFB+A XbLs/Og9dZ35bJ/JtrD9mSwcsPb5rQQ= =B82a -----END PGP SIGNATURE----- --HcAYCG3uE/tztfnV-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cII+C81MJF8gHAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 18:54:37 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eDd5Cc1MJF8nfQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 18:54:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1801041750; Fri, 31 Jul 2020 18:54:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733127AbgGaQyX (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 12:54:23 -0400 Received: from mail-il1-f199.google.com ([209.85.166.199]:39840 "EHLO mail-il1-f199.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732970AbgGaQyW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 12:54:22 -0400 Received: by mail-il1-f199.google.com with SMTP id i66so13664604ile.6 for <linux-bluetooth@vger.kernel.org>; Fri, 31 Jul 2020 09:54:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=eBgrKQgetDK1Zn56OoxluDo5PjxwfEKYs/QHbyKlBBU=; b=A2xRfnDUafkVBreL8yhXy5bbspjAAvXqjknHzOSAsxEVqmyvcwzJtzbN1Qslv6KCLk 9fCcFc321OjAu/m+mlBZ2q+rlZlF7R7hjt4OEDKY4J5+c9UAYbRU/GbTz4mDPopI0FPC HxXrXZkO3gAIsiGMDaCcREN9Pu+v3q5WXjVN08RPFwWudiHovAw46UoHecoGozj1NXe9 eZdftOdma/a73F8EYlID7QY8FLmqkjz+cDIBL57K27Y6MJsvoHoiyEoPpaHpcKapTetO Q2Gt/mdhqkovwBbdP3WSNrBynn9v4KBpHWakhpBrJ3L+UF3/1HOBE7/pyL/b5jt7cs9F kg7w== X-Gm-Message-State: AOAM531ZIzonRl+ELhjg5K/hUTzmPcXvBMjbWzFzWXbTEYgUuCyCuedY A+9k/1YhMAiJM5iyeudjcPNZjZrXa0YaKJFKCjYfoQAuJBOP X-Google-Smtp-Source: ABdhPJzaSTz1SnrId/zd7MDfvEa0UoNTFZIqjC7NL6DP4uHj4qPo6tHc/AEzuVgOLgtWDRneKBwcdzLIwXNrIx4b6bAPYqH4N/qD MIME-Version: 1.0 X-Received: by 2002:a92:874a:: with SMTP id d10mr4688320ilm.273.1596214461567; Fri, 31 Jul 2020 09:54:21 -0700 (PDT) Date: Fri, 31 Jul 2020 09:54:21 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000f796a105abbfa33d@google.com> Subject: INFO: trying to register non-static key in skb_queue_purge From: syzbot <syzbot+99efc1c133eff186721a@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1801041750 X-Rspamd-UID: 8be68b Hello, syzbot found the following issue on: HEAD commit: 83bdc727 random32: remove net_rand_state from the latent e.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=11088204900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=99efc1c133eff186721a compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12429014900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12dbc404900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+99efc1c133eff186721a@syzkaller.appspotmail.com IPVS: ftp: loaded support on port[0] = 21 INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 0 PID: 6819 Comm: syz-executor370 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 register_lock_class+0xf06/0x1520 kernel/locking/lockdep.c:893 __lock_acquire+0x102/0x2c30 kernel/locking/lockdep.c:4259 lock_acquire+0x160/0x720 kernel/locking/lockdep.c:4959 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x9e/0xc0 kernel/locking/spinlock.c:159 skb_dequeue net/core/skbuff.c:3038 [inline] skb_queue_purge+0x2e/0x1c0 net/core/skbuff.c:3076 l2cap_conn_del+0x3de/0x650 net/bluetooth/l2cap_core.c:1890 hci_disconn_cfm include/net/bluetooth/hci_core.h:1355 [inline] hci_conn_hash_flush+0x127/0x200 net/bluetooth/hci_conn.c:1536 hci_dev_do_close+0xb7b/0x1040 net/bluetooth/hci_core.c:1761 hci_unregister_dev+0x16d/0x1590 net/bluetooth/hci_core.c:3606 vhci_release+0x73/0xc0 drivers/bluetooth/hci_vhci.c:340 __fput+0x2f0/0x750 fs/file_table.c:281 task_work_run+0x137/0x1c0 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0x601/0x1f80 kernel/exit.c:805 do_group_exit+0x161/0x2d0 kernel/exit.c:903 __do_sys_exit_group+0x13/0x20 kernel/exit.c:914 __se_sys_exit_group+0x10/0x10 kernel/exit.c:912 __x64_sys_exit_group+0x37/0x40 kernel/exit.c:912 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x444fe8 Code: Bad RIP value. RSP: 002b:00007ffe95cf39a8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 0000000000444fe8 RDX: 0000000000000001 RSI: 000000000000003c RDI: 0000000000000001 RBP: 00000000004cce10 R08: 00000000000000e7 R09: ffffffffffffffd0 R10: 00007fa6b64e3700 R11: 0000000000000246 R12: 0000000000000001 R13: 00000000006e0200 R14: 00000000011eb850 R15: 0000000000000001 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UADzEdFMJF8gHAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 18:54:41 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id mKwEEdFMJF9j1AAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 18:54:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5C5C141747; Fri, 31 Jul 2020 18:54:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732994AbgGaQyX (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 12:54:23 -0400 Received: from mail-io1-f70.google.com ([209.85.166.70]:48499 "EHLO mail-io1-f70.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732860AbgGaQyW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 12:54:22 -0400 Received: by mail-io1-f70.google.com with SMTP id r9so21433394ioa.15 for <linux-bluetooth@vger.kernel.org>; Fri, 31 Jul 2020 09:54:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=ARDRp3KNxJ0Mur5k39eF0BHl1nLpOy5JRf/QHvN6dFk=; b=I+e46udr2Qsztz6AqpRRQcdTTS2IFeMguELC2o002FWMnQeP+Fx+M1gMUci62Oyg2+ EQmwKmLrRz84D29yiJNvbjqOKiZELwS8t0AiUBfrY3GDM+N9ALB/I6UNgm5VFL6r4mll Mcy/eGFT2zNKm7+ZZ6ewKtkFj+YBHXX6/OOyh21/1M3DGRqea3o5N5zHKMFch1WZ3qh0 /DPBp2b3tksFTabeBByAuyeoFIexxrhB9oDIQJmNrZqSj56CZQrmEMEYWEpYE0ascW46 Clzli/nXilIO449UEWf5OUuQq2Ajs19J0fHDbzccSF52pjeisRDSbdGNl5A93KF7WYal bDyw== X-Gm-Message-State: AOAM53333ARAG6im3O+Vwbu0SDoHY+YCjmk3VuRTmI1h7D9lHHZ+cM1s 5Mw6oAypdBqbrGu8YCcZXOVdPJhm2dtomuOKx9NBocM9kDkH X-Google-Smtp-Source: ABdhPJxP2PbBB8deYKj2Tc4M1SS2BCEM0juaeT3FHB8Zzq3MURwrPnYltjduqem2f6JiZYRpGP2INyzeumkyJnqkAJRd8iw1hVjt MIME-Version: 1.0 X-Received: by 2002:a6b:4407:: with SMTP id r7mr4409152ioa.77.1596214461310; Fri, 31 Jul 2020 09:54:21 -0700 (PDT) Date: Fri, 31 Jul 2020 09:54:21 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000f3b11a05abbfa345@google.com> Subject: INFO: trying to register non-static key in skb_dequeue From: syzbot <syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5C5C141747 X-Rspamd-UID: ebd157 Hello, syzbot found the following issue on: HEAD commit: 83bdc727 random32: remove net_rand_state from the latent e.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=119bc404900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 dashboard link: https://syzkaller.appspot.com/bug?extid=fadfba6a911f6bf71842 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16ce9270900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1485c092900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com IPVS: ftp: loaded support on port[0] = 21 INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 1 PID: 6833 Comm: syz-executor596 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 assign_lock_key kernel/locking/lockdep.c:894 [inline] register_lock_class+0x157d/0x1630 kernel/locking/lockdep.c:1206 __lock_acquire+0xfa/0x56e0 kernel/locking/lockdep.c:4259 lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:4959 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x8c/0xc0 kernel/locking/spinlock.c:159 skb_dequeue+0x1c/0x180 net/core/skbuff.c:3038 skb_queue_purge+0x21/0x30 net/core/skbuff.c:3076 l2cap_chan_del+0x61d/0x1300 net/bluetooth/l2cap_core.c:657 l2cap_conn_del+0x46a/0x9e0 net/bluetooth/l2cap_core.c:1890 l2cap_disconn_cfm net/bluetooth/l2cap_core.c:8159 [inline] l2cap_disconn_cfm+0x85/0xa0 net/bluetooth/l2cap_core.c:8152 hci_disconn_cfm include/net/bluetooth/hci_core.h:1355 [inline] hci_conn_hash_flush+0x114/0x220 net/bluetooth/hci_conn.c:1536 hci_dev_do_close+0x5c6/0x1080 net/bluetooth/hci_core.c:1761 hci_unregister_dev+0x1a3/0xe20 net/bluetooth/hci_core.c:3606 vhci_release+0x70/0xe0 drivers/bluetooth/hci_vhci.c:340 __fput+0x33c/0x880 fs/file_table.c:281 task_work_run+0xdd/0x190 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0xb72/0x2a40 kernel/exit.c:805 do_group_exit+0x125/0x310 kernel/exit.c:903 __do_sys_exit_group kernel/exit.c:914 [inline] __se_sys_exit_group kernel/exit.c:912 [inline] __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:912 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x444fe8 Code: Bad RIP value. RSP: 002b:00007ffde50eda98 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 0000000000444fe8 RDX: 0000000000000001 RSI: 000000000000003c RDI: 0000000000000001 RBP: 00000000004cce10 R08: 00000000000000e7 R09: ffffffffffffffd0 R10: 00007f0c43ebb700 R11: 0000000000000246 R12: 0000000000000001 R13: 00000000006e0200 R14: 0000000001898850 R15: 0000000000000001 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MFWgAidPJF8gHAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 31 Jul 2020 19:04:39 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id mMn3ACdPJF+TiAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 31 Jul 2020 19:04:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0DC6EA192B; Fri, 31 Jul 2020 19:04:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733072AbgGaREY (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 13:04:24 -0400 Received: from mail-io1-f72.google.com ([209.85.166.72]:38100 "EHLO mail-io1-f72.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732973AbgGaREX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 13:04:23 -0400 Received: by mail-io1-f72.google.com with SMTP id a65so12443502iog.5 for <linux-bluetooth@vger.kernel.org>; Fri, 31 Jul 2020 10:04:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=ZdAnHGVy9LgoO3SJHEMpX6y3/EdWZ4Nira0XtxekYaE=; b=f95R7Q2yroqz1LnI+l2g/9OTjUischlDqouGY0XpVqZqwiwfzWs/KD28Z7OyJbBI4q Z9tTy/1nlQDsnRxMkS7/nZqaWQqSoxEZZeZgLSYmrm9wRIw84LnK3OU4IDe+2Ye0gQ3b 2kvEhrauPPafHRAh5xh7+2X8WibAQ3xMnzys+m5TgsZA5tqQCxz0uNTbt8j6wywXxn0A ofBFu4X4LH86d+D0TruIQ1XQgUZ/qQY7zpzN065CvVnuovsSY1KSt6Ogq2ePUwKWCNLu mnglWGb7ZF3xI6hfhtuBnoXpgroSiYM3RPsorCmT7IGsPTu6jTJbjDjtjnMmS2Y1mVHp 6xFw== X-Gm-Message-State: AOAM533HmmrMXkA2LMS7Em7DTCZ2ezPGN4SyKJ0Q65a1i3wSpzKV2gJr dqmQKkGA4scx2elX0Px07Jz+dZTjUMkhcakxjO4V4ZK1sJgU X-Google-Smtp-Source: ABdhPJxjiOxqxzdFpC1XBmA7iIoooMkgjCPCp2JMxWYhW4zWLMdOs5xQbJ5qjdoB0lxgaA8MJokuspLO3/3N/aulcDJqfFKuv+Qh MIME-Version: 1.0 X-Received: by 2002:a05:6638:13c5:: with SMTP id i5mr6006394jaj.29.1596215062006; Fri, 31 Jul 2020 10:04:22 -0700 (PDT) Date: Fri, 31 Jul 2020 10:04:21 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000c18f1a05abbfc792@google.com> Subject: KASAN: null-ptr-deref Write in amp_read_loc_assoc_final_data From: syzbot <syzbot+f4fb0eaafdb51c32a153@syzkaller.appspotmail.com> To: corbet@lwn.net, coreteam@netfilter.org, davem@davemloft.net, johan.hedberg@gmail.com, kaber@trash.net, kadlec@blackhole.kfki.hu, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux@armlinux.org.uk, marcel@holtmann.org, mchehab@kernel.org, mchehab@s-opensource.com, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, pablo@netfilter.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0DC6EA192B X-Rspamd-UID: c855ae Hello, syzbot found the following issue on: HEAD commit: 83bdc727 random32: remove net_rand_state from the latent e.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=176e5d12900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=f4fb0eaafdb51c32a153 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13d5ed24900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1381a56c900000 The issue was bisected to: commit a4585c31c5018578b4abf699ddfdff719dd1c313 Author: Mauro Carvalho Chehab <mchehab@s-opensource.com> Date: Tue Oct 18 19:44:09 2016 +0000 [media] marvell-ccic: don't break long lines bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=160d627c900000 final oops: https://syzkaller.appspot.com/x/report.txt?x=150d627c900000 console output: https://syzkaller.appspot.com/x/log.txt?x=110d627c900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+f4fb0eaafdb51c32a153@syzkaller.appspotmail.com Fixes: a4585c31c501 ("[media] marvell-ccic: don't break long lines") ================================================================== BUG: KASAN: null-ptr-deref in instrument_atomic_write include/linux/instrumented.h:71 [inline] BUG: KASAN: null-ptr-deref in set_bit include/asm-generic/bitops/instrumented-atomic.h:28 [inline] BUG: KASAN: null-ptr-deref in amp_read_loc_assoc_final_data+0x115/0x260 net/bluetooth/amp.c:304 Write of size 8 at addr 0000000000000030 by task kworker/u5:2/6842 CPU: 1 PID: 6842 Comm: kworker/u5:2 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 __kasan_report mm/kasan/report.c:517 [inline] kasan_report+0x151/0x1d0 mm/kasan/report.c:530 check_memory_region_inline mm/kasan/generic.c:183 [inline] check_memory_region+0x2b5/0x2f0 mm/kasan/generic.c:192 instrument_atomic_write include/linux/instrumented.h:71 [inline] set_bit include/asm-generic/bitops/instrumented-atomic.h:28 [inline] amp_read_loc_assoc_final_data+0x115/0x260 net/bluetooth/amp.c:304 hci_chan_selected_evt net/bluetooth/hci_event.c:4897 [inline] hci_event_packet+0x8289/0x18240 net/bluetooth/hci_event.c:6164 hci_rx_work+0x236/0x9c0 net/bluetooth/hci_core.c:4705 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 ================================================================== Kernel panic - not syncing: panic_on_warn set ... CPU: 1 PID: 6842 Comm: kworker/u5:2 Tainted: G B 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 panic+0x264/0x7a0 kernel/panic.c:231 end_report mm/kasan/report.c:104 [inline] __kasan_report mm/kasan/report.c:520 [inline] kasan_report+0x1c9/0x1d0 mm/kasan/report.c:530 check_memory_region_inline mm/kasan/generic.c:183 [inline] check_memory_region+0x2b5/0x2f0 mm/kasan/generic.c:192 instrument_atomic_write include/linux/instrumented.h:71 [inline] set_bit include/asm-generic/bitops/instrumented-atomic.h:28 [inline] amp_read_loc_assoc_final_data+0x115/0x260 net/bluetooth/amp.c:304 hci_chan_selected_evt net/bluetooth/hci_event.c:4897 [inline] hci_event_packet+0x8289/0x18240 net/bluetooth/hci_event.c:6164 hci_rx_work+0x236/0x9c0 net/bluetooth/hci_core.c:4705 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Kernel Offset: disabled Rebooting in 86400 seconds.. --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. For information about bisection process see: https://goo.gl/tpsmEJ#bisection syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MHPzHZK0JF9fgQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 01 Aug 2020 02:17:22 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id KCCRHJK0JF/aSgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 01 Aug 2020 02:17:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 806B2A1A7B; Sat, 1 Aug 2020 02:17:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727982AbgHAARH (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 31 Jul 2020 20:17:07 -0400 Received: from mail-io1-f70.google.com ([209.85.166.70]:45614 "EHLO mail-io1-f70.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726671AbgHAARH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 31 Jul 2020 20:17:07 -0400 Received: by mail-io1-f70.google.com with SMTP id p17so18962310iod.12 for <linux-bluetooth@vger.kernel.org>; Fri, 31 Jul 2020 17:17:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=EeowjFs3ag00jmXysHEViINXb8Feznj0QWnCDc8JX9k=; b=GA18wfOqacdk5rVPKqZWcp2SfpRkSuhz/ueA0TZHxs8QL61EJIuScmqZjz8GwWNWAN 26XDmlJqR+wJMsuBMiW5XiLAbV8JeiA2eOpkYAmqqtOUx1SdH4TojUAmQXjEC0/YCOVQ t0OeKt3+K4QHTpklg/V//5wERKS+iiItZGzFOZuJkzWIwpUrD5ZERGGQDm83J3MRD7zF d96FEvtn8vPx0yiqy/B507fkilpg8F5IkgjFlm72npi1Ap0Y7JFDlC1D3CwHngMdvVie aw55dacmG9AId1rk2DR6ruQFwXgkRzOoq08pDF7p7ki7bEdeW7ZtQzSVQ3W2oSfoWKxM yW8A== X-Gm-Message-State: AOAM530XKrY+xrbQtKcmqhUW5YnGJBlMySKnRzLsZ400M//LoJ3Taddw 4Asc4QG6sQZHyU58YUAs2XUxCx9qRncIJbqbIJkM6oGNy+Oy X-Google-Smtp-Source: ABdhPJyUdXAO2hc9zkb+flLDdicREQ1MO5ek2xuunUaYgAh3EJco6GeHhbiRHe9n9Y2O1M10MBJzTxGwK5OnmfSGd22hGobEilwF MIME-Version: 1.0 X-Received: by 2002:a5d:8a0c:: with SMTP id w12mr5949284iod.63.1596241026434; Fri, 31 Jul 2020 17:17:06 -0700 (PDT) Date: Fri, 31 Jul 2020 17:17:06 -0700 In-Reply-To: <000000000000f796a105abbfa33d@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000005b507905abc5d32f@google.com> Subject: Re: INFO: trying to register non-static key in skb_queue_purge From: syzbot <syzbot+99efc1c133eff186721a@syzkaller.appspotmail.com> To: andrew@lunn.ch, davem@davemloft.net, hkallweit1@gmail.com, jakub.kicinski@netronome.com, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 4 X-Rspamd-Score: 0.61 / 15.00 / 200.00 X-Rspamd-Queue-Id: 806B2A1A7B X-Rspamd-UID: c3c46f syzbot has bisected this issue to: commit 65b27995a4ab8fc51b4adc6b4dcdca20f7a595bb Author: Heiner Kallweit <hkallweit1@gmail.com> Date: Mon Aug 12 21:52:19 2019 +0000 net: phy: let phy_speed_down/up support speeds >1Gbps bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1327ef50900000 start commit: 83bdc727 random32: remove net_rand_state from the latent e.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=10a7ef50900000 console output: https://syzkaller.appspot.com/x/log.txt?x=1727ef50900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=99efc1c133eff186721a syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12429014900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12dbc404900000 Reported-by: syzbot+99efc1c133eff186721a@syzkaller.appspotmail.com Fixes: 65b27995a4ab ("net: phy: let phy_speed_down/up support speeds >1Gbps") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6IvbMmLvJF86PgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 01 Aug 2020 06:28:18 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id CAA1MWLvJF8n6QEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 01 Aug 2020 06:28:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=mnmoran.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ACB3940150; Sat, 1 Aug 2020 06:28:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725290AbgHAE2K (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 1 Aug 2020 00:28:10 -0400 Received: from hoster906.com ([192.252.156.27]:36526 "EHLO hoster906.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725280AbgHAE2K (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 1 Aug 2020 00:28:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mnmoran.org; h=from :subject:to:message-id:date:mime-version:content-type :content-transfer-encoding; s=dkim; bh=tUGC/4kqFAdss6ER3xbfTPwiA cVcsdUrk59/+z2PlcU=; b=dY5w/VzYvSnQkHZI1akXMfBuOA8lT5V1qKBp1pkrd vTe3KZKmaMyoL3EByFGrKfurm0an+Aw9b9c3o3/Q1cH6fGhHbXGIE+Gi92gkW4S0 8BYCWcktbYh7Jx/rK7misudK6Xhzq8W44RNFYTuu4phkfrpM+rlLqEmAjr+yGIz7 BQ= Received: (qmail 30737 invoked by uid 503); 1 Aug 2020 04:28:08 -0000 Received: from unknown (HELO ?192.168.254.79?) (pop-before-smtp@162.39.210.203) by hoster906.com with ESMTPA; 1 Aug 2020 04:28:08 -0000 From: "Michael N. Moran" <mike@mnmoran.org> Subject: [PATCH BlueZ 0/1] mesh: Add strings for SIG Model IDs. To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Message-ID: <bc557704-e59c-d83b-9d5a-698ef37b23a9@mnmoran.org> Date: Sat, 1 Aug 2020 00:28:03 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.16 / 15.00 / 200.00 X-Rspamd-Queue-Id: ACB3940150 X-Rspamd-UID: a6bf7c My first BlueZ patch. This patch adds a utility function returning a string describing a SIG Model ID and uses this function for in the mesh-cfgclient in the list-nodes command output and in the display of received composition data. The strings were taken directly from the Bluetooth Mesh Profile and Mesh Model specifications. Michael N. Moran (1): Add strings for SIG Model IDs. tools/mesh/cfgcli.c | 3 ++- tools/mesh/remote.c | 5 ++-- tools/mesh/util.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ tools/mesh/util.h | 1 + 4 files changed, 70 insertions(+), 3 deletions(-) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id II/kL2jvJF86PgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 01 Aug 2020 06:28:24 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gDUmLmjvJF9HLgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 01 Aug 2020 06:28:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=mnmoran.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6CC6540507; Sat, 1 Aug 2020 06:28:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725497AbgHAE2T (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 1 Aug 2020 00:28:19 -0400 Received: from hoster906.com ([192.252.156.27]:36534 "EHLO hoster906.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725280AbgHAE2S (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 1 Aug 2020 00:28:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mnmoran.org; h=from :subject:to:message-id:date:mime-version:content-type :content-transfer-encoding; s=dkim; bh=RQ6muDbhi5qlTXb9qudsQrmIW aVmnVsaDonl5X/utjo=; b=ZAPChbpMiGx6hefpQ2Qy/6JX6RPdOwkOJLs07tj32 wqvZRZSqy6DMR6zZ2dh8rEX7o6v6qgqVhVk7ISiR/MMvcwNVU1he9PPeQaGaseIc 3MWeps9DvkbsXe2kWInQQR7Zhv5VYJlElC9pb34O94ZxJf4j2z83si6yPKdoMoRv 9A= Received: (qmail 30888 invoked by uid 503); 1 Aug 2020 04:28:17 -0000 Received: from unknown (HELO ?192.168.254.79?) (pop-before-smtp@162.39.210.203) by hoster906.com with ESMTPA; 1 Aug 2020 04:28:17 -0000 From: "Michael N. Moran" <mike@mnmoran.org> Subject: [PATCH BlueZ 1/1] mesh: Add strings for SIG Model IDs. To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Message-ID: <d3547f5d-5dae-38fb-41c6-33454e8b1356@mnmoran.org> Date: Sat, 1 Aug 2020 00:28:12 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6CC6540507 X-Rspamd-UID: c56d5d This patch adds a utility function returning a string describing a SIG Model ID and uses this function for in the mesh-cfgclient in the list-nodes command output and in the display of received composition data. --- tools/mesh/cfgcli.c | 3 ++- tools/mesh/remote.c | 5 ++-- tools/mesh/util.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ tools/mesh/util.h | 1 + 4 files changed, 70 insertions(+), 3 deletions(-) diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c index e36c8dca5..f6f465c6c 100644 --- a/tools/mesh/cfgcli.c +++ b/tools/mesh/cfgcli.c @@ -263,7 +263,8 @@ static uint32_t print_mod_id(uint8_t *data, bool vendor, const char *offset) if (!vendor) { mod_id = get_le16(data); - bt_shell_printf("%sModel ID\t%4.4x\n", offset, mod_id); + bt_shell_printf("%sModel ID\t%4.4x \"%s\"\n", + offset, mod_id,sig_model_string(mod_id)); mod_id = VENDOR_ID_MASK | mod_id; } else { mod_id = get_le16(data + 2); diff --git a/tools/mesh/remote.c b/tools/mesh/remote.c index c74f0bec1..ba3e50d3f 100644 --- a/tools/mesh/remote.c +++ b/tools/mesh/remote.c @@ -30,6 +30,7 @@ #include "tools/mesh/keys.h" #include "tools/mesh/mesh-db.h" #include "tools/mesh/remote.h" +#include "tools/mesh/util.h" #define abs_diff(a, b) ((a) > (b) ? (a) - (b) : (b) - (a)) @@ -293,8 +294,8 @@ static void print_model(void *model, void *user_data) if (mod_id >= VENDOR_ID_MASK) { mod_id &= ~VENDOR_ID_MASK; - bt_shell_printf("\t\t\t" COLOR_GREEN "SIG model: %4.4x\n" - COLOR_OFF, mod_id); + bt_shell_printf("\t\t\t" COLOR_GREEN "SIG model: %4.4x \"%s\"\n" + COLOR_OFF, mod_id,sig_model_string(mod_id)); return; } diff --git a/tools/mesh/util.c b/tools/mesh/util.c index 7176cc562..4603a6261 100644 --- a/tools/mesh/util.c +++ b/tools/mesh/util.c @@ -138,3 +138,67 @@ void swap_u256_bytes(uint8_t *u256) u256[i] ^= u256[31 - i]; } } + +const char* sig_model_string(uint16_t sig_model_id) +{ + switch (sig_model_id) { + case 0x0000: return "Configuration Server"; + case 0x0001: return "Configuration Client"; + case 0x0002: return "Health Server"; + case 0x0003: return "Health Client"; + case 0x1000: return "Generic OnOff Server"; + case 0x1001: return "Generic OnOff Client"; + case 0x1002: return "Generic Level Server"; + case 0x1003: return "Generic Level Client"; + case 0x1004: return "Generic Default Transition Time Server"; + case 0x1005: return "Generic Default Transition Time Client"; + case 0x1006: return "Generic Power OnOff Server"; + case 0x1007: return "Generic Power OnOff Setup Server"; + case 0x1008: return "Generic Power OnOff Client"; + case 0x1009: return "Generic Power Level Server"; + case 0x100A: return "Generic Power Level Setup Server"; + case 0x100B: return "Generic Power Level Client"; + case 0x100C: return "Generic Battery Server"; + case 0x100D: return "Generic Battery Client"; + case 0x100E: return "Generic Location Server"; + case 0x100F: return "Generic Location Setup Server"; + case 0x1010: return "Generic Location Client"; + case 0x1011: return "Generic Admin Property Server"; + case 0x1012: return "Generic Manufacturer Property Server"; + case 0x1013: return "Generic User Property Server"; + case 0x1014: return "Generic Client Property Server"; + case 0x1015: return "Generic Property Client"; + case 0x1100: return "Sensor Server"; + case 0x1101: return "Sensor Setup Server"; + case 0x1102: return "Sensor Client"; + case 0x1200: return "Time Server"; + case 0x1201: return "Time Setup Server"; + case 0x1202: return "Time Client"; + case 0x1203: return "Scene Server"; + case 0x1204: return "Scene Setup Server"; + case 0x1205: return "Scene Client"; + case 0x1206: return "Scheduler Server"; + case 0x1207: return "Scheduler Setup Server"; + case 0x1208: return "Scheduler Client"; + case 0x1300: return "Light Lightness Server"; + case 0x1301: return "Light Lightness Setup Server"; + case 0x1302: return "Light Lightness Client"; + case 0x1303: return "Light CTL Server"; + case 0x1304: return "Light CTL Setup Server"; + case 0x1305: return "Light CTL Client"; + case 0x1306: return "Light CTL Temperature Server"; + case 0x1307: return "Light HSL Server"; + case 0x1308: return "Light HSL Setup Server"; + case 0x1309: return "Light HSL Client"; + case 0x130A: return "Light HSL Hue Server"; + case 0x130B: return "Light HSL Saturation Server"; + case 0x130C: return "Light xyL Server"; + case 0x130D: return "Light xyL Setup Server"; + case 0x130E: return "Light xyL Client"; + case 0x130F: return "Light LC Server"; + case 0x1310: return "Light LC Setup Server"; + case 0x1311: return "Light LC Client"; + + default: return "Unknown"; + } +} diff --git a/tools/mesh/util.h b/tools/mesh/util.h index cca07cf96..7e966bc69 100644 --- a/tools/mesh/util.h +++ b/tools/mesh/util.h @@ -27,3 +27,4 @@ uint16_t mesh_opcode_set(uint32_t opcode, uint8_t *buf); bool mesh_opcode_get(const uint8_t *buf, uint16_t sz, uint32_t *opcode, int *n); const char *mesh_status_str(uint8_t status); void swap_u256_bytes(uint8_t *u256); +const char* sig_model_string(uint16_t sig_model_id); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YFOMGsaNJV+RQAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 01 Aug 2020 17:44:06 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wDXEGMaNJV+B+wEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 01 Aug 2020 17:44:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=sholland.org header.b=tstKvIUf; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=BSqHk3Ag X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8A89F41759; Sat, 1 Aug 2020 17:44:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726748AbgHAPnu (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 1 Aug 2020 11:43:50 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:53529 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726432AbgHAPnt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 1 Aug 2020 11:43:49 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 9EDCD5C00F1; Sat, 1 Aug 2020 11:43:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 01 Aug 2020 11:43:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm3; bh=138EtoiNOuOs5U9pvNEstgflm8 9KYVe/SnhbzLU1en4=; b=tstKvIUfpsmzh0gGpUmBdP0HyLRht058hew7gfDAIL Jjziv9wUYZwBnjJieMiG410ZPi8X8ezjDeiUg/6FWh/YbFDyRrRIKQGoJ+V+6qEb /XEIC3eEdioqyv/3/JsL6kI2Pu2xfooCKNo/lc9JDi4JRU189J5WF+aYNh8JCOMD IJKLcuuRc1gzZq8JQE2hel5AeoyGQNClxE7ddqzHXKIVv3hLtevg8dofKt45gTE6 7x7KqZ+JCaowChFuhFg4o9yuvn7tA2e7srgjmDMZ56poTqK/qMVKWHNOOqK+iFgY 1XR2+d5VXJ+ob8Ct2gDzFcdPUBudJnDU51+ENEMQCreQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=138EtoiNOuOs5U9pv NEstgflm89KYVe/SnhbzLU1en4=; b=BSqHk3AglAwx1eCAHXsXsnVAterQ5JHci MheL7fAkktGuxj5Qrj3lYSJvNVQsqSIhbenqYAC/S9DHIz5RgoI8jGIv/IL08mUq Tk6e5YGW6/d9CohDdJU88KA4T4+bCC0VqgRq53hEi2vhkY9IOj4bc0ksjkAQSvS5 qDCP7z2tW2MWjmLQe8/Q8T/n+hB6Ub+N3tC+AE9RsmUc/cZBGbdcfG0zUVusCHMb xVKSBfi7Y1ZfKKwUaJ0f5F0tEIULdcenIALXLGlMHmouN5Sy4bFcSdozSvSOv3FP d31ZySxN60jR/WGfBEMBnigGIvdeH6L+Zx+62obfZbMiN1EIlRfOw== X-ME-Sender: <xms:tI0lX_rlZJwvCw475eDDZ3w_5CDrW4NpvadhQZGobq80AKCva-S5Hw> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrjedtgdelfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghlucfj ohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrfgrth htvghrnhepieetkefhheduudfgledtudefjeejfeegveehkeeufffhhfejkeehiefftdev tdevnecukfhppeejtddrudefhedrudegkedrudehudenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgrnhgurdho rhhg X-ME-Proxy: <xmx:tI0lX5qjAlQaNm9D6H326U26FKL3wk9P35HvW-rCeMVfnalDHbf9DQ> <xmx:tI0lX8NcdHn7hVd7kSbNHe79ltstTIF5v7ffMGioVlj71pg9gGfciQ> <xmx:tI0lXy4diiTaXcIWw01bZ4xHUwg-_TG2y_SoY-BloqJtfXP8Babpkw> <xmx:tI0lX0n8gqnUXVdy-On7mbmiycoYYWIJb7IEAUhB7nZFSHFGDdhDpw> Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id BFF1430600DC; Sat, 1 Aug 2020 11:43:47 -0400 (EDT) From: Samuel Holland <samuel@sholland.org> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Cc: Hans de Goede <hdegoede@redhat.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Samuel Holland <samuel@sholland.org>, stable@vger.kernel.org Subject: [PATCH 1/2] Bluetooth: hci_h5: Stop erroneously setting HCI_UART_REGISTERED Date: Sat, 1 Aug 2020 10:43:45 -0500 Message-Id: <20200801154346.63882-1-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 12 X-Rspamd-Score: 1.84 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8A89F41759 X-Rspamd-UID: 58bb9c This code attempts to set the HCI_UART_RESET_ON_INIT flag. However, it sets the bit in the wrong flag word: HCI_UART_RESET_ON_INIT goes in hu->hdev_flags, not hu->flags. So it is actually setting HCI_UART_REGISTERED, which is bit 1 in hu->flags. Since commit cba736465e5c ("Bluetooth: hci_serdev: Remove setting of HCI_QUIRK_RESET_ON_CLOSE."), this flag is ignored for hci_serdev users, so instead of fixing which flag is set, let's remove the flag entirely. Cc: stable@vger.kernel.org Fixes: ce945552fde4 ("Bluetooth: hci_h5: Add support for serdev enumerated devices") Signed-off-by: Samuel Holland <samuel@sholland.org> --- drivers/bluetooth/hci_h5.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index e60b2e0773db..981d96cc7695 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c @@ -793,8 +793,6 @@ static int h5_serdev_probe(struct serdev_device *serdev) if (!h5) return -ENOMEM; - set_bit(HCI_UART_RESET_ON_INIT, &h5->serdev_hu.flags); - h5->hu = &h5->serdev_hu; h5->serdev_hu.serdev = serdev; serdev_device_set_drvdata(serdev, h5); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8HxbD8qNJV+CKgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 01 Aug 2020 17:44:10 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id QBOuDcqNJV+B+wEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 01 Aug 2020 17:44:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=sholland.org header.b=eE/HQiHc; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=mfEefv+m X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8B5D440F40; Sat, 1 Aug 2020 17:44:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbgHAPny (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 1 Aug 2020 11:43:54 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:45325 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725841AbgHAPnt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 1 Aug 2020 11:43:49 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id A07B85C00F2; Sat, 1 Aug 2020 11:43:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 01 Aug 2020 11:43:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=fLE/BR/AfO59g KvBp7sezPVqGqn3x1Dpcq3I+BQXhzk=; b=eE/HQiHcfS6C4NSf1tO8GS2lYvR5H hrP+ldGh07Y9Na2k7bNzc26W4B3qFTJJTk3+7FlTFi/wzg9RVxOGdRF3ZLZWNI3R bV4dM+H1Om289XgEfl8iak/ukyHfPAbOIizEDQT5HqaulHJnt4b3DKIfKV1e7JN9 rlRjLWNIn+Bg1treek5BFfHFNEETIbKrfmmpkkVI4TH+mADUwnmxqcMLWJOjKaxz dAR5PD3ODcHeIgNYhhUd3RAKaOCt4tVtPY8o1rRvbcpfyhpj21vl2aUcN5IpHBby ksA6BaUxtrRA6u+JOQwM6TLOzmp5DC6P2oNvb0zbc8UCYr6ky4ahXAwoA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=fLE/BR/AfO59gKvBp7sezPVqGqn3x1Dpcq3I+BQXhzk=; b=mfEefv+m vSv3Xb/8LImHvLtDoKGu697+xhp8O+BBscg6LkD3bJ0zaGy6TVXO5HaAUAmPQxXm +LR2AtAvwxQD5RiIwv5ZzgD4sKvZBWe0w0FRPLmmeBHrWCIHhn9PhhJJxYZjuKBO 2WSLEIlenj2dD7F492XCpJsjfLT9nn48vVxmY8TspWgN9rGElsdz6L28XyUemvw8 2PscoXwh8qsAwxW7MzxszSJjLxRB6k/B9yqb4kM1W/+yWIe4HarmCnYjDuVv1S0o snv+w3f78SqtVlOExORtScb9aHydAvVp7CfUMmc2Rwh8svlUF5QDPEtk+3pqVlGw rxjKo+yKlvI/1Q== X-ME-Sender: <xms:tI0lX-4LxBE8hH486tCytiUjTvK6S3wdGa274cDkXvHIUuyPhaybhQ> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrjedtgdelfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghl ucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrf grthhtvghrnhepudfhjeefvdfhgfefheetgffhieeigfefhefgvddvveefgeejheejvdfg jeehueeinecukfhppeejtddrudefhedrudegkedrudehudenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgrnhgu rdhorhhg X-ME-Proxy: <xmx:tI0lX34Ej15o3lvQCJWF6OSME-HGqO5HRla88vPA-OziF47yPZV_TQ> <xmx:tI0lX9d1diDL1Q_BYHL8DfPWp91tub_stNBt48dWZvzUozh6WJSmjw> <xmx:tI0lX7LCZpkkEzbdcYJdoM8YEJg13-cygRmR33u99Ubnae5xjawyAg> <xmx:tI0lX-3H-s4LZSwR8lq5k3jcC_F2x9q2FnS2ZnaMEq2vzKG2ng2N-w> Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 20CF73060272; Sat, 1 Aug 2020 11:43:48 -0400 (EDT) From: Samuel Holland <samuel@sholland.org> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Cc: Hans de Goede <hdegoede@redhat.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Samuel Holland <samuel@sholland.org>, stable@vger.kernel.org Subject: [PATCH 2/2] Bluetooth: hci_serdev: Fix crash with HCI_UART_INIT_PENDING Date: Sat, 1 Aug 2020 10:43:46 -0500 Message-Id: <20200801154346.63882-2-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200801154346.63882-1-samuel@sholland.org> References: <20200801154346.63882-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 12 X-Rspamd-Score: 1.88 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8B5D440F40 X-Rspamd-UID: 6be710 When using HCI_UART_INIT_PENDING, hci_register_dev is not called from hci_uart_register_device. Instead, it is called by hci_uart_init_work, which is enqueued by hci_uart_init_ready (as hu->init_ready). In the case of the hci_h5 proto, hci_uart_init_ready is called only after handshaking with the hardware. If that handshake never completes, hci_register_dev is never called. When later unregistering the device, the kernel crashes: Unable to handle kernel write to read-only memory at virtual address 0000000000000008 Internal error: Oops: 96000045 [#1] PREEMPT SMP Modules linked in: hci_uart(-) btrtl bnep bluetooth 8723cs(C) [...] CPU: 3 PID: 516 Comm: rmmod Tainted: G C 5.8.0-rc7-00277-gd87641cb644c-dirty #1 Hardware name: Pine64 PinePhone Braveheart (1.1) (DT) pstate: 80400005 (Nzcv daif +PAN -UAO BTYPE=--) pc : hci_unregister_dev+0x58/0x4b0 [bluetooth] lr : hci_unregister_dev+0x54/0x4b0 [bluetooth] sp : ffffffc011b5bc60 x29: ffffffc011b5bc60 x28: ffffff8075d23800 x27: 0000000000000000 x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 x23: 0000000000000000 x22: ffffffc008d86000 x21: ffffff8079dd2000 x20: ffffff8078026000 x19: ffffffc008f4f6d0 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000004 x14: ffffff807b15c110 x13: 0000000000000000 x12: ffffff80778e6720 x11: ffffff80778e66c8 x10: ffffff807ac6ada2 x9 : ffffffc010c95864 x8 : 0000000000210d00 x7 : 0000000000000000 x6 : 0000000000000001 x5 : 0000000000000001 x4 : 0000000000000001 x3 : 0000000000000000 x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000 Call trace: hci_unregister_dev+0x58/0x4b0 [bluetooth] hci_uart_unregister_device+0x40/0x74 [hci_uart] h5_serdev_remove+0x18/0x20 [hci_uart] serdev_drv_remove+0x28/0x4c __device_release_driver+0x174/0x210 driver_detach+0xc4/0x100 bus_remove_driver+0x5c/0xb0 driver_unregister+0x34/0x60 h5_deinit+0x14/0xd10 [hci_uart] hci_uart_exit+0xc/0x30 [hci_uart] __arm64_sys_delete_module+0x1b0/0x260 el0_svc_common.constprop.0+0x60/0x100 do_el0_svc+0x20/0x30 el0_sync_handler+0x88/0x1b4 el0_sync+0x138/0x140 Code: aa1303e0 79408297 95f69770 a9400682 (f9000441) ---[ end trace b68f9044c8f92379 ]--- Fix the crash by flushing the hu->init_ready work to ensure hci_register_dev is not being called concurrently, and then only calling hci_unregister_dev if the HCI was previously registered. Cc: stable@vger.kernel.org Fixes: fdee6d8fc630 ("Bluetooth: hci_serdev: Fix HCI_UART_INIT_PENDING not working") Signed-off-by: Samuel Holland <samuel@sholland.org> --- drivers/bluetooth/hci_serdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index 599855e4c57c..3977bba485c2 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -355,7 +355,10 @@ void hci_uart_unregister_device(struct hci_uart *hu) struct hci_dev *hdev = hu->hdev; clear_bit(HCI_UART_PROTO_READY, &hu->flags); - hci_unregister_dev(hdev); + + cancel_work_sync(&hu->init_ready); + if (test_bit(HCI_UART_REGISTERED, &hu->flags)) + hci_unregister_dev(hdev); hci_free_dev(hdev); cancel_work_sync(&hu->write_work); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kOLhGVCXJV8/bwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 01 Aug 2020 18:24:48 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id OGnNGFCXJV/uLgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 01 Aug 2020 18:24:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=sholland.org header.b=hhOs7lAO; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=KP1aCXG5 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E51ADA19E1; Sat, 1 Aug 2020 18:24:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbgHAQYc (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 1 Aug 2020 12:24:32 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:44983 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725841AbgHAQYb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 1 Aug 2020 12:24:31 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 7D9CF5C00EF; Sat, 1 Aug 2020 12:24:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 01 Aug 2020 12:24:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=A R8KqUnGVjK7QTE3PI1CuQvIC++1Koq61ifqJ5NJFGw=; b=hhOs7lAOcdDJ16NvU gnuvG12GqRYeEQVrMudf56LnoOOpWN6gu57sIPiqUymz6BL8t6w/hOEf7ujX5KLU +2D7OLrys/MmgDoVY+4RyHx83MQVoIEKvPM6gwr/Oz74i0G2RvVoE3my4aiz7J+f VwO67EYJy9H/WavpqIZlr52GStXBvCdk0I+6qpOyb5mvlAnh64LeKNF8iarpURjI NxUkKYCrS+iPXzZqpvkz4nfCICrUYd2eNsvccTYFejxelDdIyFy55bHDYhOKNAM4 PU+VnVcgoK3ez96vAu547EpEZ2LGY68wRy+1JKNqD2mMrjF/wp6Is3UFQwdD8GPa bvWnQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=AR8KqUnGVjK7QTE3PI1CuQvIC++1Koq61ifqJ5NJF Gw=; b=KP1aCXG5RggBrmp3+c/mBqi1wqnuKBKIhCEVYjfcj6BCJrnz4fQI80Vgw aCrA2iQHzKNu1urp0laqPnqQL36ryNuwiG+O0N/gLBIAWCwooEJHLXspxIrwHZDA p7ISgX7emb2qZIMhfTZcSWMTOqNQxz6FsCuziUugeV8QfdyT/jvPF90kiCkSLpPR oWeIrRegSrkC0oqSdFpKiqUMe+ndnMIklE59gTLE/bP+ENL0DLXDFPfZR1QnCa1v mp5gLwFcrGcDSFLs2/5JXqavnRY8NlQTGGk4jao4UNlinrHsKa14e8RETdsLZ0ai FbST8Sc6igcEQ42lYMvHZlVePRvnQ== X-ME-Sender: <xms:PZclXzTItlu3x_0usgXA3tCWVs2TGIf9hRQ0gN47Z9Wl593srCt4ag> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrjedtgddutdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepgfevffetleehffejueekvdekvdeitdehveegfeekheeuieeiueet uefgtedtgeegnecukfhppeejtddrudefhedrudegkedrudehudenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgr nhgurdhorhhg X-ME-Proxy: <xmx:PpclX0wSmDTsB-4Vm2mHLkv3l4Vnzs56xWSWEuw0kcekKLhteBMrew> <xmx:PpclX41qoMKau78iZuzqyUY4AJ1xPNIWD0IhiJdVtu-3Wqe9hoF-4A> <xmx:PpclXzB458IDE7z96JztAZsHNYlSrNL93QoZN7aOCSZLAQSvt9WxNA> <xmx:PpclX_tuzntJvLFJ12UTLSME0EcPj4Y5Imn3zk00GoVOBuRiV9vKNQ> Received: from [192.168.50.169] (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id A28453060067; Sat, 1 Aug 2020 12:24:29 -0400 (EDT) Subject: Re: [PATCH 1/2] Bluetooth: hci_h5: Stop erroneously setting HCI_UART_REGISTERED To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Cc: Hans de Goede <hdegoede@redhat.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20200801154346.63882-1-samuel@sholland.org> From: Samuel Holland <samuel@sholland.org> Message-ID: <789a7d61-bdc0-19a2-d4e0-03b2f89bb516@sholland.org> Date: Sat, 1 Aug 2020 11:24:46 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200801154346.63882-1-samuel@sholland.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.02 / 15.00 / 200.00 X-Rspamd-Queue-Id: E51ADA19E1 X-Rspamd-UID: 18019e On 8/1/20 10:43 AM, Samuel Holland wrote: > This code attempts to set the HCI_UART_RESET_ON_INIT flag. However, > it sets the bit in the wrong flag word: HCI_UART_RESET_ON_INIT goes in > hu->hdev_flags, not hu->flags. So it is actually setting > HCI_UART_REGISTERED, which is bit 1 in hu->flags. > > Since commit cba736465e5c ("Bluetooth: hci_serdev: Remove setting of > HCI_QUIRK_RESET_ON_CLOSE."), this flag is ignored for hci_serdev users, > so instead of fixing which flag is set, let's remove the flag entirely. > > Cc: stable@vger.kernel.org > Fixes: ce945552fde4 ("Bluetooth: hci_h5: Add support for serdev enumerated devices") > Signed-off-by: Samuel Holland <samuel@sholland.org> > --- > drivers/bluetooth/hci_h5.c | 2 -- > 1 file changed, 2 deletions(-) Sorry, I didn't see the other patches that were just added to -next. I'll rebase my additional changes on top of them and resend. Regards, Samuel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SNomFpuYJV8IdgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 01 Aug 2020 18:30:19 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id sNd8FJuYJV87RgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 01 Aug 2020 18:30:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=sholland.org header.b=QpBmy8JE; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=gmwiPuLf X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D8022A1CDA; Sat, 1 Aug 2020 18:30:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbgHAQ37 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 1 Aug 2020 12:29:59 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:37301 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbgHAQ37 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 1 Aug 2020 12:29:59 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 08F835C00CD; Sat, 1 Aug 2020 12:29:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 01 Aug 2020 12:29:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=FhcIa5vl19H1Q blhkWUef9NQmw0YCfpphgojts1RzX8=; b=QpBmy8JELAjTsoUSWhhnQ8Xsdarfx j45BkSPOB3LmOa0asJz/gYTMUMp5RIRFpnsT4ckK0XkbW0KtxgNAzAlY2MQDaAD7 uKnqjuJs9BxSAAbvY68kZipHASbjPK+VBpKO3Pu/8vyaHKke9447zy1H1py4od+Y 4PdihZQL/7lj9/oAr5KL98gFrioLT5d+cfUTjR6e7Ssl6KI8C0EhPmcxz7n6Db87 0R+oCAEauWH0HZUXuwAmO7v63EyZXCTj1V1zH5WxLh3IjlaNqjGMGPFZ7mucaXUt EVqlxbFtq4+QPd9sGV1jhe48Vqgls/5khhHO2I5GoUQByr410L+DPgqLQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=FhcIa5vl19H1QblhkWUef9NQmw0YCfpphgojts1RzX8=; b=gmwiPuLf ty1/QDRZRbPvvrv/SqW6plo6h4QMXFosA6rGaWIqn8N6gdztx5cuQTZVzZLktmVA UzI8GGNGoZl1o1Y7Zt38/f2oPhDVt42ac6erQVMjl2q6dFmvyAjnhFq2h70bAuaF S4P+b+aQ3VhZOzXYqhrCFbmLwxJOn8Y79II4dCRVc7NRmdXNBvHfKmH7z+R2czZt 6vloy6fyudN8+JJyosbv5cLijoRtAjiqfo2khnRwPkJ2QQx84NGAjiMijvz5YFtk qfzAjzsSJoXp683vK/FPektO9wso9u/I07yMZXV+zQoSpcdRqYO5ng/Tlzb9IIe6 q6tdD6wXVLjJhg== X-ME-Sender: <xms:hZglX-zzVCEIuYxrRQvlXZ8ffFA6pNqOl_gOufbNw3j0_q9YLt2sBg> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrjedtgddutdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucfkphepjedtrddufeehrddugeekrdduhedunecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmhhuvghlsehshhholhhlrghn ugdrohhrgh X-ME-Proxy: <xmx:hZglX6T_11FImR_VqxvSK0Okm5jIBH_klhrlqv9zyWj_hA634qyI9Q> <xmx:hZglXwWJNcNxBH1tNwasgUlcibr1fHyeAFS4EQ73qV2G7YXn06gsNg> <xmx:hZglX0hBZSKGFCDdYP9I8oN_N2P-bAz0oNynOsuI3zc6vkGhya9IKA> <xmx:hpglXzO6UewIaOa9yafvbfqzrlXCpHXMfd0901VORoXUHbO40w85lg> Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 8C2C23060067; Sat, 1 Aug 2020 12:29:57 -0400 (EDT) From: Samuel Holland <samuel@sholland.org> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>, Hans de Goede <hdegoede@redhat.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Samuel Holland <samuel@sholland.org> Subject: [PATCH 2/2] Bluetooth: hci_ldisc/hci_serdev: Cancel init work before unregistering Date: Sat, 1 Aug 2020 11:29:56 -0500 Message-Id: <20200801162956.22610-2-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200801162956.22610-1-samuel@sholland.org> References: <20200801162956.22610-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.60 / 15.00 / 200.00 X-Rspamd-Queue-Id: D8022A1CDA X-Rspamd-UID: b923b9 If hci_uart_tty_close() or hci_uart_unregister_device() is called while hu->init_ready is scheduled, hci_register_dev() could be called after the hci_uart is torn down. Avoid this by ensuring the work is complete or canceled before checking the HCI_UART_REGISTERED flag. Fixes: 9f2aee848fe6 ("Bluetooth: Add delayed init sequence support for UART controllers") Signed-off-by: Samuel Holland <samuel@sholland.org> --- drivers/bluetooth/hci_ldisc.c | 1 + drivers/bluetooth/hci_serdev.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 85a30fb9177b..f83d67eafc9f 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -538,6 +538,7 @@ static void hci_uart_tty_close(struct tty_struct *tty) clear_bit(HCI_UART_PROTO_READY, &hu->flags); percpu_up_write(&hu->proto_lock); + cancel_work_sync(&hu->init_ready); cancel_work_sync(&hu->write_work); if (hdev) { diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index 7b233312e723..3977bba485c2 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -355,6 +355,8 @@ void hci_uart_unregister_device(struct hci_uart *hu) struct hci_dev *hdev = hu->hdev; clear_bit(HCI_UART_PROTO_READY, &hu->flags); + + cancel_work_sync(&hu->init_ready); if (test_bit(HCI_UART_REGISTERED, &hu->flags)) hci_unregister_dev(hdev); hci_free_dev(hdev); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iOkvDp+YJV/XaQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 01 Aug 2020 18:30:23 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 6PDJDJ+YJV8zRgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 01 Aug 2020 18:30:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=sholland.org header.b=RGpVdE6R; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=RaOPscq5 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 78E91A1BEA; Sat, 1 Aug 2020 18:30:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726534AbgHAQ37 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 1 Aug 2020 12:29:59 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:44369 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725841AbgHAQ37 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 1 Aug 2020 12:29:59 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id F400B5C0073; Sat, 1 Aug 2020 12:29:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 01 Aug 2020 12:29:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm3; bh=53Jxaj3NoHeE/kFuF4Ggf7Os2J Cj0STpNlmUixXXrgc=; b=RGpVdE6RgdbHMd8hiA7W9m/ow2qPINGWeYYQs9VWrt gSEjZ4HEu33hx36JMWxDB46Vt7J8T92XYF1CVoOhG3PaYIwfFUQS/y5InIabgTpF ZaMz0IMKuAChOSJWw7UfzbBqzU4DbrfAnYO7BZCPPsH3u7Sb6Zzj+efMDky/enh0 6tKqdnuYlLAmRIGWYMThepHEhC74gsJ4CpI2Xtfaiqjle5kiYKjb/ntc2QbewKei 6uf8KwQw6USi1nSnYbmrIHt1hw7zcHXiP0PGORfEGibNdYMzCttWt3eNKuZPWkdr UTCFwjeGmpTPoEJpiHFNBpzC6bjeMY28uQITgcC6O2Fg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=53Jxaj3NoHeE/kFuF 4Ggf7Os2JCj0STpNlmUixXXrgc=; b=RaOPscq5J9gKRyrU9eXsuO48kqRwOcFV4 erpZMPM0/Cb1DpJjtTYXVXgN7U27dNfAN5qCEhLofjPh8ZfRuMDuTX6LNaXUvQey L0BeoNnTNPwblCPXpCocM7WNuScNCcVIOxWTUaxEypiXf4NZr3KIhAxY7vamx+FS RhRBMYlL+SUS1+eWdxSpusAVrVjCX6KAkyUaoY12ypFbOeDJU8JR7vsAnmY88LOQ 2JYDHF3gwJ78jNxtHkFKLrR5KSag0F5t3ZobItiSJS+7eTArB1zCHzf90u0C7R1z nbE6P8fqFbXbHsFEsplOq3Mh128JsbjMi8CciyYNSVrSgtCJ4RhRQ== X-ME-Sender: <xms:hZglXxyHLUXTQYXFByO06rMs11fYPD2d7BOZUFNU8zR-1-cFU7We4w> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrjedtgddutdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgvlhcu jfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtffrrg htthgvrhhnpeeiteekhfehuddugfeltddufeejjeefgeevheekueffhffhjeekheeiffdt vedtveenucfkphepjedtrddufeehrddugeekrdduhedunecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmhhuvghlsehshhholhhlrghnugdr ohhrgh X-ME-Proxy: <xmx:hZglXxTLi3karcXXB8vvyrDtYpemTkk4X9k3DBz2KQGb9vWYNL9Cww> <xmx:hZglX7XHyd4PgqJqcrunWDDYAtZ8it5KYv0Dd-NeXVlXAbyr504fyQ> <xmx:hZglXzgSFnv50RyH19RxSbkAShXtuJK9s18pKSsS4W3B5xeestuX-g> <xmx:hZglX6OqhptTELDV0yFhlykH9_BpcZQSRub_GmYvQ6hCUIUyJOoTjw> Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 1E5D730600A3; Sat, 1 Aug 2020 12:29:57 -0400 (EDT) From: Samuel Holland <samuel@sholland.org> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>, Hans de Goede <hdegoede@redhat.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Samuel Holland <samuel@sholland.org> Subject: [PATCH 1/2] Bluetooth: hci_h5: Remove ignored flag HCI_UART_RESET_ON_INIT Date: Sat, 1 Aug 2020 11:29:55 -0500 Message-Id: <20200801162956.22610-1-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.60 / 15.00 / 200.00 X-Rspamd-Queue-Id: 78E91A1BEA X-Rspamd-UID: 61c18a Since commit cba736465e5c ("Bluetooth: hci_serdev: Remove setting of HCI_QUIRK_RESET_ON_CLOSE."), this flag is ignored for hci_serdev users, so let's remove setting it. Signed-off-by: Samuel Holland <samuel@sholland.org> --- drivers/bluetooth/hci_h5.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index e41854e0d79a..981d96cc7695 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c @@ -793,8 +793,6 @@ static int h5_serdev_probe(struct serdev_device *serdev) if (!h5) return -ENOMEM; - set_bit(HCI_UART_RESET_ON_INIT, &h5->serdev_hu.hdev_flags); - h5->hu = &h5->serdev_hu; h5->serdev_hu.serdev = serdev; serdev_device_set_drvdata(serdev, h5); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0CZcFkmZJV8IdgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 01 Aug 2020 18:33:13 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +JqZFEmZJV9NDQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 01 Aug 2020 18:33:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8BFA540134; Sat, 1 Aug 2020 18:33:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727057AbgHAQdH (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 1 Aug 2020 12:33:07 -0400 Received: from mail-io1-f69.google.com ([209.85.166.69]:48561 "EHLO mail-io1-f69.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726748AbgHAQdG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 1 Aug 2020 12:33:06 -0400 Received: by mail-io1-f69.google.com with SMTP id r9so23382100ioa.15 for <linux-bluetooth@vger.kernel.org>; Sat, 01 Aug 2020 09:33:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=SIdCK8Q+4LKw+jmzrptYCoQd/JoF3mumY50X9Ph/hTE=; b=Yp5CxSqrfh5++OZ58NE4K92opZrfKm6sWxb3Sh29nkbmZefsyHQpOvzEiTfT20mvWL Ylhe3sPibXiwVfUgvZrdkbqz8Zr1Nu+xJbQeqDb9tUBAyfKEMNhx3SQ7Ex3WQW8cUk44 AQGRxWyP3MGm2V/bGpTA3E/T+l8l1QxEkZ9RzoF6AKlIzIrq6NX/JnoydDnhBLBhtFY6 aLiQRCcXxhnDNcvQqGJy6c+TCi/wXwqHqqiXx7r3Z7E2IhDBKu80KjBogAesWguaxiqs vc529Ruw6D747421twHXyXQ71iD9yCYDGdNc8L5j2nyNXTZhIpF+cRGFKdRguHm/xs1h ++hg== X-Gm-Message-State: AOAM531ikU1A02RHKRDrBaHjOnF1W2UZte/i+cXMW3XYOgS3zRXjJnaC gApwWs2OzCRPbJGjlF3q4qIBruDp26F8JRzrAYdcorTD0LDg X-Google-Smtp-Source: ABdhPJxr/wL4FBG9BjuUQiXlSC8n5B0989oGaJ3+8JI4slsvtNxiaGVvvNeo1Fc/qvwpgTWkAaur6QYbJbGO5vawji+M3kZenXYs MIME-Version: 1.0 X-Received: by 2002:a05:6602:1343:: with SMTP id i3mr8889517iov.134.1596299585453; Sat, 01 Aug 2020 09:33:05 -0700 (PDT) Date: Sat, 01 Aug 2020 09:33:05 -0700 In-Reply-To: <000000000000f298fc05abb42b70@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000bf03f305abd37535@google.com> Subject: Re: WARNING: ODEBUG bug in cancel_delayed_work From: syzbot <syzbot+338f014a98367a08a114@syzkaller.appspotmail.com> To: bhumirks@gmail.com, coreteam@netfilter.org, davem@davemloft.net, devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, johan.hedberg@gmail.com, kaber@trash.net, kadlec@blackhole.kfki.hu, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, pablo@netfilter.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.94 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8BFA540134 X-Rspamd-UID: b4ec4f syzbot has bisected this issue to: commit 43ff7f53de2294a83dcf84b35de6ffa1ffafae9d Author: Bhumika Goyal <bhumirks@gmail.com> Date: Thu Oct 6 18:10:01 2016 +0000 Staging: vc04_services: vchiq_arm: Remove unused function remote_event_destroy bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=107c810c900000 start commit: d8b9faec Merge tag 'drm-fixes-2020-07-31' of git://anongit.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=127c810c900000 console output: https://syzkaller.appspot.com/x/log.txt?x=147c810c900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 dashboard link: https://syzkaller.appspot.com/bug?extid=338f014a98367a08a114 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1111ad5c900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16565d5c900000 Reported-by: syzbot+338f014a98367a08a114@syzkaller.appspotmail.com Fixes: 43ff7f53de22 ("Staging: vc04_services: vchiq_arm: Remove unused function remote_event_destroy") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eMyYGKe6JV8jHAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 01 Aug 2020 20:55:35 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id aFEvF6e6JV//ugEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 01 Aug 2020 20:55:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4F6514166F; Sat, 1 Aug 2020 20:55:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726808AbgHASzW (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 1 Aug 2020 14:55:22 -0400 Received: from mail-il1-f197.google.com ([209.85.166.197]:38132 "EHLO mail-il1-f197.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbgHASzV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 1 Aug 2020 14:55:21 -0400 Received: by mail-il1-f197.google.com with SMTP id t79so21844482ild.5 for <linux-bluetooth@vger.kernel.org>; Sat, 01 Aug 2020 11:55:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=qQIA2QYUDlIkIkoCeDn3ShR5eJP9B1EyOlqL+wH8+eg=; b=f7k8Sx3ottF7FZSIbpsuSp4awPqxgAX+SsYGjrrbcisCwvPQJuwX+dePbThL8yllaD UDX8254iRdteKSewil/kPYldtXGrawlyy7qdkeBl0/G8M5oG5dAJanWO+B8Oj7u+ew5f SFnZ1Th/7nIg2xiVxDWtyy+tlO/9sgH0LX/+/vD6ioDGb98v6dOn9wCjGO9Oxnx8c9/H I805pYBE2pfynNZHxEaauhI7nn0tNhulcQO5U6z1qHzEG7VWzzAqXxm8Ms4Cw9NAGXCp AaD2OXg3iOhRb1JD63c4x/RjuPYf6zkH7RNE1Jp4WRbUg02MLzhOFyos/4eW3Uj5olPq tl1A== X-Gm-Message-State: AOAM530Udqr8odB65kXaHavMeLefz7mn6BARaXFd8cBqaEI71BVLQRA0 3RZezYZjHD/WfQJA2q9NiogFx0L+7ENonpM2xJC9FlnwbX0z X-Google-Smtp-Source: ABdhPJyAnxuWi0Ar7UbGU8cFxZxOdqtZIrd/H1i1Lo4eIUgzWQ+QRZgqjc2PIeKovrr2D9XmJyB9FwIQP4/m6yOXch6deouJO2cF MIME-Version: 1.0 X-Received: by 2002:a92:ad01:: with SMTP id w1mr10198997ilh.301.1596308120160; Sat, 01 Aug 2020 11:55:20 -0700 (PDT) Date: Sat, 01 Aug 2020 11:55:20 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000007450a405abd572a8@google.com> Subject: WARNING in hci_conn_timeout From: syzbot <syzbot+2446dd3cb07277388db6@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4F6514166F X-Rspamd-UID: 1e3f97 Hello, syzbot found the following issue on: HEAD commit: 7dc6fd0f Merge branch 'i2c/for-current' of git://git.kerne.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=12a70832900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=2446dd3cb07277388db6 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13f781d4900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=116a0c14900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+2446dd3cb07277388db6@syzkaller.appspotmail.com ------------[ cut here ]------------ WARNING: CPU: 0 PID: 6953 at net/bluetooth/hci_conn.c:412 hci_conn_timeout+0x20f/0x290 net/bluetooth/hci_conn.c:412 Kernel panic - not syncing: panic_on_warn set ... CPU: 1 PID: 6953 Comm: kworker/u5:2 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_conn_timeout Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 panic+0x264/0x7a0 kernel/panic.c:231 __warn+0x227/0x250 kernel/panic.c:600 report_bug+0x1b1/0x2e0 lib/bug.c:198 handle_bug+0x42/0x80 arch/x86/kernel/traps.c:235 exc_invalid_op+0x16/0x40 arch/x86/kernel/traps.c:255 asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:540 RIP: 0010:hci_conn_timeout+0x20f/0x290 net/bluetooth/hci_conn.c:412 Code: c7 50 4d 8d 89 e8 71 d0 5f fa 48 8b 35 6a 7c 39 02 bf 40 00 00 00 4c 89 f2 5b 41 5c 41 5e 41 5f e9 46 69 f8 f9 e8 61 c1 20 fa <0f> 0b e9 5c fe ff ff 89 d9 80 e1 07 80 c1 03 38 c1 0f 8c 1a fe ff RSP: 0018:ffffc90001577cc8 EFLAGS: 00010293 RAX: ffffffff8753d0ff RBX: 00000000ffffffff RCX: ffff888092948440 RDX: 0000000000000000 RSI: 00000000ffffffff RDI: 0000000000000000 RBP: ffff8880a9b7b008 R08: ffffffff8753cf3b R09: ffffed1010da5003 R10: ffffed1010da5003 R11: 0000000000000000 R12: ffff8880a7290d00 R13: ffff8880a7290d18 R14: ffff888086d28128 R15: dffffc0000000000 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Kernel Offset: disabled Rebooting in 86400 seconds.. --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oEX7KCXzJV/YBgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 00:56:37 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IMsQJyXzJV+YMgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 00:56:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8A5E440134; Sun, 2 Aug 2020 00:56:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbgHAW4L (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 1 Aug 2020 18:56:11 -0400 Received: from mail-io1-f71.google.com ([209.85.166.71]:53629 "EHLO mail-io1-f71.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726545AbgHAW4K (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 1 Aug 2020 18:56:10 -0400 Received: by mail-io1-f71.google.com with SMTP id f22so15759584iof.20 for <linux-bluetooth@vger.kernel.org>; Sat, 01 Aug 2020 15:56:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=dOzePy5yJodn3MAztJ8MjMszFxBpzjO8+9+k54Plw7U=; b=YeFLHyWpCWNCRunyZoFFIOguyNC7DawplTpC40pHOSNglgNZAZzPk/CfE/Op4q6KgL k79EoTLYzV/2cPyMOGju6nnovj3xHo/lRXx222nVxWzeag32B4mrzwJATehVdUv8eVuN kakGXPzvjzrUaGn6sQFnojH8fhBxmy7YHyFIiFoOZ+7HQKcKNtFD/XLR1odc3oTwAc6P z52PRm+gZ+GQPRlDYBqBt8WiCJmz1avMSUsFDN4CMkE6+9/2wgb4BShHjfiq5G4MQDVd +FUWmkyds7UnWmo3k2Qyq/Dn7EznlAYLD+Bqhz+8MdJ/Cx/3NxlU4Utmy0i3Rd5wmvbF z7VQ== X-Gm-Message-State: AOAM532ksvmEZV5V8fSmOxA7FqwdapgD9RGaagPDM+DnbxNWWakk1Rw2 duNc//lOcfaAcHjhw+9aWWYubG+ApZNH9V3OivQ5fEFs/K5C X-Google-Smtp-Source: ABdhPJzoFyfIZQhNRPiFzD4/WN4vVmjC3jcEN/n2QVLjineSWA8YL2dCDfS0uwVot1kHmJxuiejHJRIs+6Vlg9DaPmCCBtbeQtI1 MIME-Version: 1.0 X-Received: by 2002:a92:79c4:: with SMTP id u187mr10446904ilc.194.1596322569603; Sat, 01 Aug 2020 15:56:09 -0700 (PDT) Date: Sat, 01 Aug 2020 15:56:09 -0700 In-Reply-To: <0000000000007450a405abd572a8@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000b54f9f05abd8cfbb@google.com> Subject: Re: WARNING in hci_conn_timeout From: syzbot <syzbot+2446dd3cb07277388db6@syzkaller.appspotmail.com> To: coreteam@netfilter.org, davem@davemloft.net, devel@driverdev.osuosl.org, forest@alittletooquiet.net, gregkh@linuxfoundation.org, johan.hedberg@gmail.com, kaber@trash.net, kadlec@blackhole.kfki.hu, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, pablo@netfilter.org, rvarsha016@gmail.com, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8A5E440134 X-Rspamd-UID: 155da4 syzbot has bisected this issue to: commit 3d30311c0e4d834c94e6a27d6242a942d6a76b85 Author: Varsha Rao <rvarsha016@gmail.com> Date: Sun Oct 9 11:13:56 2016 +0000 staging: vt6655: Removes unnecessary blank lines. bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=17023a14900000 start commit: 7dc6fd0f Merge branch 'i2c/for-current' of git://git.kerne.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=14823a14900000 console output: https://syzkaller.appspot.com/x/log.txt?x=10823a14900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=2446dd3cb07277388db6 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13f781d4900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=116a0c14900000 Reported-by: syzbot+2446dd3cb07277388db6@syzkaller.appspotmail.com Fixes: 3d30311c0e4d ("staging: vt6655: Removes unnecessary blank lines.") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SJVGHWU/Jl8PdgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 06:21:57 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id GD3fG2U/Jl+quQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 06:21:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3B93DA193B; Sun, 2 Aug 2020 06:21:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725993AbgHBEVt (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 00:21:49 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:49514 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbgHBEVt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 00:21:49 -0400 Received: from [114.252.213.24] (helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from <hui.wang@canonical.com>) id 1k25VL-0002Xt-A0; Sun, 02 Aug 2020 04:21:48 +0000 From: Hui Wang <hui.wang@canonical.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com Subject: [PATCH] Bluetooth: btusb: Add a module parameter ignore_id for debugging Date: Sun, 2 Aug 2020 12:21:38 +0800 Message-Id: <20200802042138.9149-1-hui.wang@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3B93DA193B X-Rspamd-UID: 08c7f6 There is always an on-board usb bluetooth hci on the laptops, if the bluetooth function doesn't work well like a bt headset can't work with HSP/HFP mode, we often plug an external usb BT hci to verify if that headset could work with the exteral BT hci or not, in this situation, there will be 2 hcis (hci0 and hci1) in the system, and so far, the gnome can't handle the hci1 well so we met lots of problems when debugging with hci1 under gnome. After adding this new module parameter, we could ban the on-board usb hci by putting btusb.ignore_id=idVendor,idProduct to the bootargs, then the external usb hci will be hci0 and there is only one hci in the system. We could easily debug with the external usb bluetooth hci after this change. Signed-off-by: Hui Wang <hui.wang@canonical.com> --- drivers/bluetooth/btusb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 5f022e9cf667..f6ab0cb313ed 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -32,6 +32,7 @@ static bool force_scofix; static bool enable_autosuspend = IS_ENABLED(CONFIG_BT_HCIBTUSB_AUTOSUSPEND); static bool reset = true; +static u16 ignore_id[2]; static struct usb_driver btusb_driver; @@ -3714,11 +3715,17 @@ static int btusb_probe(struct usb_interface *intf, struct gpio_desc *reset_gpio; struct btusb_data *data; struct hci_dev *hdev; + struct usb_device *dev; unsigned ifnum_base; int i, err; BT_DBG("intf %p id %p", intf, id); + dev = interface_to_usbdev(intf); + if (ignore_id[0] == le16_to_cpu(dev->descriptor.idVendor) && + ignore_id[1] == le16_to_cpu(dev->descriptor.idProduct)) + return -ENODEV; + /* interface numbers are hardcoded in the spec */ if (intf->cur_altsetting->desc.bInterfaceNumber != 0) { if (!(id->driver_info & BTUSB_IFNUM_2)) @@ -4273,6 +4280,10 @@ MODULE_PARM_DESC(enable_autosuspend, "Enable USB autosuspend by default"); module_param(reset, bool, 0644); MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); +module_param_array(ignore_id, ushort, NULL, 0644); +MODULE_PARM_DESC(ignore_id, "btusb will ignore this device if the id matches." + " e.g. ignore_id=idVendor,idProduct"); + MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION); MODULE_VERSION(VERSION); -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8GnpJa5dJl9c1QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 08:31:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id OL5iJK5dJl+6sgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 08:31:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 04C86A1E22; Sun, 2 Aug 2020 08:31:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725885AbgHBGaz (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 02:30:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:54970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725798AbgHBGay (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 02:30:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7D3412076B; Sun, 2 Aug 2020 06:30:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596349854; bh=s+L0U8SYjfQdqJYaY42N4VU+qvySTS5Xee4dhuCBX9U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I/oX3DpgcNRRhOjx0JjtQZ1e/KUK3Tfa6vijN3rhYLm2irsgdoJZmTsNJF7hlEAf6 voTF1U0eu7qD96zxUQw19Kwej9hBNJ3EKG0AK4zdxtRsITJXOh+/Y3Srbn+XVZZsaP ZOiFFxHHSDJyEUlpCJ9JS+8inrlUVBSYsfMJH/fM= Date: Sun, 2 Aug 2020 08:30:37 +0200 From: Greg KH <gregkh@linuxfoundation.org> To: syzbot <syzbot+2446dd3cb07277388db6@syzkaller.appspotmail.com> Cc: coreteam@netfilter.org, davem@davemloft.net, devel@driverdev.osuosl.org, forest@alittletooquiet.net, johan.hedberg@gmail.com, kaber@trash.net, kadlec@blackhole.kfki.hu, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, pablo@netfilter.org, rvarsha016@gmail.com, syzkaller-bugs@googlegroups.com Subject: Re: WARNING in hci_conn_timeout Message-ID: <20200802063037.GA3650705@kroah.com> References: <0000000000007450a405abd572a8@google.com> <000000000000b54f9f05abd8cfbb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000000000000b54f9f05abd8cfbb@google.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.44 / 15.00 / 200.00 X-Rspamd-Queue-Id: 04C86A1E22 X-Rspamd-UID: ac117d On Sat, Aug 01, 2020 at 03:56:09PM -0700, syzbot wrote: > syzbot has bisected this issue to: > > commit 3d30311c0e4d834c94e6a27d6242a942d6a76b85 > Author: Varsha Rao <rvarsha016@gmail.com> > Date: Sun Oct 9 11:13:56 2016 +0000 > > staging: vt6655: Removes unnecessary blank lines. I doubt this is the real issue :( Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YLQsD7BlJl+BDAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 09:05:20 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id QFhkDbBlJl9MoQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 09:05:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8D6E94061A; Sun, 2 Aug 2020 09:05:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726086AbgHBHFO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 03:05:14 -0400 Received: from mga07.intel.com ([134.134.136.100]:15371 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbgHBHFN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 03:05:13 -0400 IronPort-SDR: iO1FfOgDL9f/jrMer17cgYjzWC0EJiFtqyi8wh+F+Syjq/ZsZI56wPc4jMa+CRW0htJqCpnQjO FAqTjkA+njJg== X-IronPort-AV: E=McAfee;i="6000,8403,9700"; a="216411277" X-IronPort-AV: E=Sophos;i="5.75,425,1589266800"; d="scan'208";a="216411277" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2020 00:04:42 -0700 IronPort-SDR: QMeeBUrFb/tG5B5P9zojMg7lKxpix4SncDpnpD2O8QIp27YDZ9Zmyet6FLzy2QqtlBPUqqej2C ud3Rv8nwfugg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,425,1589266800"; d="scan'208";a="305487284" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga002.jf.intel.com with ESMTP; 02 Aug 2020 00:04:42 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 2 Aug 2020 00:04:41 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 2 Aug 2020 00:04:41 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 2 Aug 2020 00:04:41 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 2 Aug 2020 00:04:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V91+VeLM/Pp3rqFbG//fmid5lF8S6cb+wkD0XqL39oqUAwVyDGcQYY4gPE+AQJY9u4BRNbR45NxXjPOXYu59u/nN5WFaOUxcHNTFJhy7mti4KVxb4u14IGUp3utqRXfEMZIzO0D2MDJ47hyxNRqxBug73vVBKKPhQl1IGs9Z/26KGJR8Hz/adkl46MWcD8zGvNItBf2/2t1IhMnuK/3abGWGSPmPoDz5/jBl0yB6LQITbO7zCFOM8t/NprgrRUEdm+SdKXNlblDas0eCxjQZq3g8kHFmbQkpz5vd9ZBCWselg6PXlqb3ASDjFg0H6aXHLps9brR2qrKxlfZyC9o8SA== 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-SenderADCheck; bh=ww8iXmQdvJzN7Js9ch3KQMdFCOdkeGPxQofkwJqY0dE=; b=idEj6CDEcZ0Ard8z3qmIKzEki9f9XTNq520hLsmJXXVbmHfGU3FywBPfJ9NeLelu35DCyn+XAlT5bOFXHPosbypGMxZBu7WES+hQ8uBrAJ7OkGiipUIHWVxDRVcey08NaUSNNSxPz130XeVefTHNP/chM1n+03a68O3z8ZAQY+Quf8W5DkbYFkRY5c+Agw9VEGMQ5UIeDTbQYJy9vPxxfkLGpaNH7WtwajHNHvEkbyHkXPTTelE4uqKgQ8/VwN1O94mIIDyER0M4naQgBniUg4b7KJD2quYb2NzvI0VqtdDOtMy3q3HeaMBa4Nh1jqHWSOpdlImIkFF6Rw4fXgiX9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ww8iXmQdvJzN7Js9ch3KQMdFCOdkeGPxQofkwJqY0dE=; b=T2Gn4sKhUeY+5TyJb67IcUtuAwMII2fu6Jylt04uc9ju3D9Ic1QUGSi4zI01qAbDDIib4CkF8rPpc/X+J3rud8L4Pf2688GM1CpQRFSEcHTN38y0PsbQ3hJQFFWbK2POfG9YY4ydXMH6OGdscNb/sen3q2YaqCKxtSJsf3oYj6w= Received: from MW3PR11MB4556.namprd11.prod.outlook.com (2603:10b6:303:5b::21) by MWHPR11MB1950.namprd11.prod.outlook.com (2603:10b6:300:112::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.17; Sun, 2 Aug 2020 07:04:39 +0000 Received: from MW3PR11MB4556.namprd11.prod.outlook.com ([fe80::3591:c4a5:ffe2:4b82]) by MW3PR11MB4556.namprd11.prod.outlook.com ([fe80::3591:c4a5:ffe2:4b82%7]) with mapi id 15.20.3239.021; Sun, 2 Aug 2020 07:04:39 +0000 From: "Stotland, Inga" <inga.stotland@intel.com> To: "mike@mnmoran.org" <mike@mnmoran.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Subject: Re: [PATCH BlueZ 1/1] mesh: Add strings for SIG Model IDs. Thread-Topic: [PATCH BlueZ 1/1] mesh: Add strings for SIG Model IDs. Thread-Index: AQHWZ7w4yOcgtCQ2w0eDcOM+ardaGakkZuYA Date: Sun, 2 Aug 2020 07:04:39 +0000 Message-ID: <b20b3a4a31a6393a1f1c035823fa20b7a778c1b2.camel@intel.com> References: <d3547f5d-5dae-38fb-41c6-33454e8b1356@mnmoran.org> In-Reply-To: <d3547f5d-5dae-38fb-41c6-33454e8b1356@mnmoran.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.36.4 (3.36.4-1.fc32) authentication-results: mnmoran.org; dkim=none (message not signed) header.d=none;mnmoran.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fa8b47a6-dd01-4b97-5cf2-08d836b252d7 x-ms-traffictypediagnostic: MWHPR11MB1950: x-microsoft-antispam-prvs: <MWHPR11MB19501194A528A6ED69A1CB6CFB4C0@MWHPR11MB1950.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:98; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: hDawSQzwQl33dQvw3ZXE1lXcE0kJ/lRZl5z0lMB88S4MPHl+FjjFq1IIEICQuulDdzn9fCczezuEEF7iwlGJDR+rHsx9w4EB4fMRsRh6Na3lULgk6B033ppJ+ORO7HldEVlRTZ6NeAQSiLigABBHDqHcpmJlpblmYdw6uo+MUyqjiLcj1KO11idYDozRwIlCYUIjbaW+Qsfougl+xj8wCQxXFHPVukr2Jqjh7U6xon/0jqFup9p5zF5o2SgdOEDBHwRWnICf9VlKi1wkfHbQsloew+N4DLvpYT2av0UJGizKxRT2TVtDpg63Ffqz9jfwsZFQD+E0N76Ei0tT848lzg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4556.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(39860400002)(396003)(136003)(366004)(376002)(346002)(83380400001)(8936002)(71200400001)(316002)(6486002)(86362001)(8676002)(36756003)(110136005)(478600001)(2616005)(2906002)(91956017)(6512007)(5660300002)(6506007)(66476007)(66556008)(66446008)(186003)(64756008)(66946007)(76116006)(26005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: zr+D3/pJ/IXUzXfiYBuFDXlVxdXp2CP9AXRqujPlcSAl34wBpVds2VbcDCtA4o/VRGPfS3UaVM0bB+G3uwOlZ2VdsyuWTQMCHzcH7oa1ULznxCMKIHgALmcBiSyfofEemEQKis5i+CZkUYOw2SCzP0DH700RuZshJFc56N/oe7Zt6migQfpQbedxzX1xBg0cjywpObC+idM9MAh1wLrPJQ7bX4p51q0AoL7SJmpLxB2qoethSZogks+MwdPYuStHCFj+kjbK4PFXHgKuJz/Bh/Z3IRr5ytVdef76ESMeUhwMujwlJ39OeMuHefC5WEzd6iT/xlyY9npXqccc5tOacvY+U33Uu1GELSCKwPK9RF0Cb/y8MjmdeJcLYDhPXo3q7iiFGctN9PNAZKpNmw0bMbcTXdo+BjtIGu7OAd3+7HzYZ9A8Q3+IOrnFAFI9Oh5LiTrYVTAvpKzQTZTQU6G+mrSacibDiu8pjTO2HFtfJPo6hCvIlXXG5J6wSKzwtKkHAuHBbbX/LFuUVsIvZf0LKKqhVEIcSwt07zjNe76eIn1QzUsyp6wqQN0mqCv0wL5CjfJS3DO3imeVr/YfeD8w5pXfXoDH3I97nsmU/r8XkR/saJehRe6N20o9rAwl0B+3T9DYCFATxgH6VWeDYXKuUA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="utf-8" Content-ID: <FA7C6EA2AD1197409198A1C5047DA50F@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4556.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa8b47a6-dd01-4b97-5cf2-08d836b252d7 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Aug 2020 07:04:39.4441 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: XMGD8o420FuI/slLDrHKmREKcr3wiH2Md3pLvvb8/AHB33PLEfPIWNOc4q1DGv/ryN9uWshDcPPPGVIM8FcMjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1950 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8D6E94061A X-Rspamd-UID: 7342bf SGkgTWljaGFlbCwNCg0KVGhhbmtzIGZvciB0aGUgcGF0Y2guIEZldyBzdHlsZSB0d2Vha3MuDQoN CkZpcnN0LCBubyBwZXJpb2QgYXQgdGhlIGVuZCBvZiBjb21taXQgdGl0bGUuDQoNCk9uIFNhdCwg MjAyMC0wOC0wMSBhdCAwMDoyOCAtMDQwMCwgTWljaGFlbCBOLiBNb3JhbiB3cm90ZToNCj4gVGhp cyBwYXRjaCBhZGRzIGEgdXRpbGl0eSBmdW5jdGlvbiByZXR1cm5pbmcgYSBzdHJpbmcNCj4gZGVz Y3JpYmluZyBhIFNJRyBNb2RlbCBJRCBhbmQgdXNlcyB0aGlzIGZ1bmN0aW9uDQo+IGZvciBpbiB0 aGUgbWVzaC1jZmdjbGllbnQgaW4gdGhlIGxpc3Qtbm9kZXMgY29tbWFuZA0KPiBvdXRwdXQgYW5k IGluIHRoZSBkaXNwbGF5IG9mIHJlY2VpdmVkIGNvbXBvc2l0aW9uIGRhdGEuDQo+IA0KPiAtLS0N Cj4gICB0b29scy9tZXNoL2NmZ2NsaS5jIHwgIDMgKystDQo+ICAgdG9vbHMvbWVzaC9yZW1vdGUu YyB8ICA1ICsrLS0NCj4gICB0b29scy9tZXNoL3V0aWwuYyAgIHwgNjQgDQo+ICsrKysrKysrKysr KysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKw0KPiAgIHRvb2xzL21lc2gvdXRpbC5o ICAgfCAgMSArDQo+ICAgNCBmaWxlcyBjaGFuZ2VkLCA3MCBpbnNlcnRpb25zKCspLCAzIGRlbGV0 aW9ucygtKQ0KPiANCj4gZGlmZiAtLWdpdCBhL3Rvb2xzL21lc2gvY2ZnY2xpLmMgYi90b29scy9t ZXNoL2NmZ2NsaS5jDQo+IGluZGV4IGUzNmM4ZGNhNS4uZjZmNDY1YzZjIDEwMDY0NA0KPiAtLS0g YS90b29scy9tZXNoL2NmZ2NsaS5jDQo+ICsrKyBiL3Rvb2xzL21lc2gvY2ZnY2xpLmMNCj4gQEAg LTI2Myw3ICsyNjMsOCBAQCBzdGF0aWMgdWludDMyX3QgcHJpbnRfbW9kX2lkKHVpbnQ4X3QgDQo+ ICpkYXRhLCBib29sIHZlbmRvciwgY29uc3QgY2hhciAqb2Zmc2V0KQ0KPiAgICAJaWYgKCF2ZW5k b3IpIHsNCj4gICAJCW1vZF9pZCA9IGdldF9sZTE2KGRhdGEpOw0KPiAtCQlidF9zaGVsbF9wcmlu dGYoIiVzTW9kZWwgSURcdCU0LjR4XG4iLCBvZmZzZXQsIG1vZF9pZCk7DQo+ICsJCWJ0X3NoZWxs X3ByaW50ZigiJXNNb2RlbCBJRFx0JTQuNHggXCIlc1wiXG4iLA0KPiArCQkJb2Zmc2V0LCBtb2Rf aWQsc2lnX21vZGVsX3N0cmluZyhtb2RfaWQpKTsNCg0KU3BhY2UgYmVmb3JlIHNpZ19tb2RlbF9z dHJpbmcuDQpBbHNvLCBtYWtlIHN1cmUgdGhhdCB0aGUgIHdyYXBwZWQgbGluZQ0KIm9mZnNldCxt b2RfaWQsc2lnX21vZGVsX3N0cmluZyhtb2RfaWQpKSIgaXMNCnJpZ2h0IGFkanVzdGVkLCBpLmUu LCBhY2NvcmRpbmcgdG8gQmx1ZVogY29kaW5nIHN0eWxlIChhcyBvdXRsaW5lZCBpbg0KZG9jL2Nv ZGluZy1zdHlsZS50eHQpOg0KIlRoZSByZWZlcnJlZCBzdHlsZSBmb3IgbGluZSB3cmFwcGluZyBp cyB0byBpbmRlbnQgYXMgZmFyIGFzIHBvc3NpYmxlDQp0byB0aGUgcmlnaHQgd2l0aG91dCBoaXR0 aW5nIHRoZSA4MCBjb2x1bW5zIGxpbWl0LiINCg0KPiAgIAkJbW9kX2lkID0gVkVORE9SX0lEX01B U0sgfCBtb2RfaWQ7DQo+ICAgCX0gZWxzZSB7DQo+ICAgCQltb2RfaWQgPSBnZXRfbGUxNihkYXRh ICsgMik7DQo+IGRpZmYgLS1naXQgYS90b29scy9tZXNoL3JlbW90ZS5jIGIvdG9vbHMvbWVzaC9y ZW1vdGUuYw0KPiBpbmRleCBjNzRmMGJlYzEuLmJhM2U1MGQzZiAxMDA2NDQNCj4gLS0tIGEvdG9v bHMvbWVzaC9yZW1vdGUuYw0KPiArKysgYi90b29scy9tZXNoL3JlbW90ZS5jDQo+IEBAIC0zMCw2 ICszMCw3IEBADQo+ICAgI2luY2x1ZGUgInRvb2xzL21lc2gva2V5cy5oIg0KPiAgICNpbmNsdWRl ICJ0b29scy9tZXNoL21lc2gtZGIuaCINCj4gICAjaW5jbHVkZSAidG9vbHMvbWVzaC9yZW1vdGUu aCINCj4gKyNpbmNsdWRlICJ0b29scy9tZXNoL3V0aWwuaCINCg0KTGluZSBicmVhayBiZXR3ZWVu IGluY2x1ZGVzICYgZGVmaW5lcw0KDQo+ICAgICNkZWZpbmUgYWJzX2RpZmYoYSwgYikgKChhKSA+ IChiKSA/IChhKSAtIChiKSA6IChiKSAtIChhKSkNCj4gICBAQCAtMjkzLDggKzI5NCw4IEBAIHN0 YXRpYyB2b2lkIHByaW50X21vZGVsKHZvaWQgKm1vZGVsLCANCj4gdm9pZCAqdXNlcl9kYXRhKQ0K PiAgICAJaWYgKG1vZF9pZCA+PSBWRU5ET1JfSURfTUFTSykgew0KPiAgIAkJbW9kX2lkICY9IH5W RU5ET1JfSURfTUFTSzsNCj4gLQkJYnRfc2hlbGxfcHJpbnRmKCJcdFx0XHQiIENPTE9SX0dSRUVO ICJTSUcgbW9kZWw6ICU0LjR4XG4iDQo+IC0JCQkJCQkJQ09MT1JfT0ZGLCBtb2RfaWQpOw0KPiAr CQlidF9zaGVsbF9wcmludGYoIlx0XHRcdCIgQ09MT1JfR1JFRU4gIlNJRyBtb2RlbDogJTQuNHgg DQo+IFwiJXNcIlxuIg0KPiArCQkJCQkJCUNPTE9SX09GRiwgbW9kX2lkLHNpZ19tb2RlbF9zdHJp bmcobW9kX2lkKSk7DQoNClNwYWNlIGJlZm9yZSBzaWdfbW9kZWxfc3RyaW5nLg0KQWxzbywgbWFr ZSBzdXJlIHRoYXQgdGhlICB3cmFwcGVkIGxpbmUNCiJvZmZzZXQsbW9kX2lkLHNpZ19tb2RlbF9z dHJpbmcobW9kX2lkKSkiIGlzDQpyaWdodCBhZGp1c3RlZCwgaS5lLiwgYWNjb3JkaW5nIHRvIEJs dWVaIGNvZGluZyBzdHlsZSAoYXMgb3V0bGluZWQgaW4NCmRvYy9jb2Rpbmctc3R5bGUudHh0KToN CiJUaGUgcmVmZXJyZWQgc3R5bGUgZm9yIGxpbmUgd3JhcHBpbmcgaXMgdG8gaW5kZW50IGFzIGZh ciBhcyBwb3NzaWJsZQ0KdG8gdGhlIHJpZ2h0IHdpdGhvdXQgaGl0dGluZyB0aGUgODAgY29sdW1u cyBsaW1pdC4iDQoNCj4gICAJCXJldHVybjsNCj4gICAJfQ0KPiAgIGRpZmYgLS1naXQgYS90b29s cy9tZXNoL3V0aWwuYyBiL3Rvb2xzL21lc2gvdXRpbC5jDQo+IGluZGV4IDcxNzZjYzU2Mi4uNDYw M2E2MjYxIDEwMDY0NA0KPiAtLS0gYS90b29scy9tZXNoL3V0aWwuYw0KPiArKysgYi90b29scy9t ZXNoL3V0aWwuYw0KPiBAQCAtMTM4LDMgKzEzOCw2NyBAQCB2b2lkIHN3YXBfdTI1Nl9ieXRlcyh1 aW50OF90ICp1MjU2KQ0KPiAgIAkJdTI1NltpXSBePSB1MjU2WzMxIC0gaV07DQo+ICAgCX0NCj4g ICB9DQo+ICsNCj4gK2NvbnN0IGNoYXIqCXNpZ19tb2RlbF9zdHJpbmcodWludDE2X3Qgc2lnX21v ZGVsX2lkKQ0KDQoiY2hhcioJc2lnIiAtPiAiY2hhciAqc2lnIg0KDQo+ICt7DQo+ICsJc3dpdGNo IChzaWdfbW9kZWxfaWQpIHsNCj4gKwljYXNlIDB4MDAwMDogcmV0dXJuICJDb25maWd1cmF0aW9u IFNlcnZlciI7DQo+ICsJY2FzZSAweDAwMDE6IHJldHVybiAiQ29uZmlndXJhdGlvbiBDbGllbnQi Ow0KPiArCWNhc2UgMHgwMDAyOiByZXR1cm4gIkhlYWx0aCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgw MDAzOiByZXR1cm4gIkhlYWx0aCBDbGllbnQiOw0KPiArCWNhc2UgMHgxMDAwOiByZXR1cm4gIkdl bmVyaWMgT25PZmYgU2VydmVyIjsNCj4gKwljYXNlIDB4MTAwMTogcmV0dXJuICJHZW5lcmljIE9u T2ZmIENsaWVudCI7DQo+ICsJY2FzZSAweDEwMDI6IHJldHVybiAiR2VuZXJpYyBMZXZlbCBTZXJ2 ZXIiOw0KPiArCWNhc2UgMHgxMDAzOiByZXR1cm4gIkdlbmVyaWMgTGV2ZWwgQ2xpZW50IjsNCj4g KwljYXNlIDB4MTAwNDogcmV0dXJuICJHZW5lcmljIERlZmF1bHQgVHJhbnNpdGlvbiBUaW1lIFNl cnZlciI7DQo+ICsJY2FzZSAweDEwMDU6IHJldHVybiAiR2VuZXJpYyBEZWZhdWx0IFRyYW5zaXRp b24gVGltZSBDbGllbnQiOw0KPiArCWNhc2UgMHgxMDA2OiByZXR1cm4gIkdlbmVyaWMgUG93ZXIg T25PZmYgU2VydmVyIjsNCj4gKwljYXNlIDB4MTAwNzogcmV0dXJuICJHZW5lcmljIFBvd2VyIE9u T2ZmIFNldHVwIFNlcnZlciI7DQo+ICsJY2FzZSAweDEwMDg6IHJldHVybiAiR2VuZXJpYyBQb3dl ciBPbk9mZiBDbGllbnQiOw0KPiArCWNhc2UgMHgxMDA5OiByZXR1cm4gIkdlbmVyaWMgUG93ZXIg TGV2ZWwgU2VydmVyIjsNCj4gKwljYXNlIDB4MTAwQTogcmV0dXJuICJHZW5lcmljIFBvd2VyIExl dmVsIFNldHVwIFNlcnZlciI7DQo+ICsJY2FzZSAweDEwMEI6IHJldHVybiAiR2VuZXJpYyBQb3dl ciBMZXZlbCBDbGllbnQiOw0KPiArCWNhc2UgMHgxMDBDOiByZXR1cm4gIkdlbmVyaWMgQmF0dGVy eSBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMDBEOiByZXR1cm4gIkdlbmVyaWMgQmF0dGVyeSBDbGll bnQiOw0KPiArCWNhc2UgMHgxMDBFOiByZXR1cm4gIkdlbmVyaWMgTG9jYXRpb24gU2VydmVyIjsN Cj4gKwljYXNlIDB4MTAwRjogcmV0dXJuICJHZW5lcmljIExvY2F0aW9uIFNldHVwIFNlcnZlciI7 DQo+ICsJY2FzZSAweDEwMTA6IHJldHVybiAiR2VuZXJpYyBMb2NhdGlvbiBDbGllbnQiOw0KPiAr CWNhc2UgMHgxMDExOiByZXR1cm4gIkdlbmVyaWMgQWRtaW4gUHJvcGVydHkgU2VydmVyIjsNCj4g KwljYXNlIDB4MTAxMjogcmV0dXJuICJHZW5lcmljIE1hbnVmYWN0dXJlciBQcm9wZXJ0eSBTZXJ2 ZXIiOw0KPiArCWNhc2UgMHgxMDEzOiByZXR1cm4gIkdlbmVyaWMgVXNlciBQcm9wZXJ0eSBTZXJ2 ZXIiOw0KPiArCWNhc2UgMHgxMDE0OiByZXR1cm4gIkdlbmVyaWMgQ2xpZW50IFByb3BlcnR5IFNl cnZlciI7DQo+ICsJY2FzZSAweDEwMTU6IHJldHVybiAiR2VuZXJpYyBQcm9wZXJ0eSBDbGllbnQi Ow0KPiArCWNhc2UgMHgxMTAwOiByZXR1cm4gIlNlbnNvciBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgx MTAxOiByZXR1cm4gIlNlbnNvciBTZXR1cCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMTAyOiByZXR1 cm4gIlNlbnNvciBDbGllbnQiOw0KPiArCWNhc2UgMHgxMjAwOiByZXR1cm4gIlRpbWUgU2VydmVy IjsNCj4gKwljYXNlIDB4MTIwMTogcmV0dXJuICJUaW1lIFNldHVwIFNlcnZlciI7DQo+ICsJY2Fz ZSAweDEyMDI6IHJldHVybiAiVGltZSBDbGllbnQiOw0KPiArCWNhc2UgMHgxMjAzOiByZXR1cm4g IlNjZW5lIFNlcnZlciI7DQo+ICsJY2FzZSAweDEyMDQ6IHJldHVybiAiU2NlbmUgU2V0dXAgU2Vy dmVyIjsNCj4gKwljYXNlIDB4MTIwNTogcmV0dXJuICJTY2VuZSBDbGllbnQiOw0KPiArCWNhc2Ug MHgxMjA2OiByZXR1cm4gIlNjaGVkdWxlciBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMjA3OiByZXR1 cm4gIlNjaGVkdWxlciBTZXR1cCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMjA4OiByZXR1cm4gIlNj aGVkdWxlciBDbGllbnQiOw0KPiArCWNhc2UgMHgxMzAwOiByZXR1cm4gIkxpZ2h0IExpZ2h0bmVz cyBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzAxOiByZXR1cm4gIkxpZ2h0IExpZ2h0bmVzcyBTZXR1 cCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzAyOiByZXR1cm4gIkxpZ2h0IExpZ2h0bmVzcyBDbGll bnQiOw0KPiArCWNhc2UgMHgxMzAzOiByZXR1cm4gIkxpZ2h0IENUTCBTZXJ2ZXIiOw0KPiArCWNh c2UgMHgxMzA0OiByZXR1cm4gIkxpZ2h0IENUTCBTZXR1cCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgx MzA1OiByZXR1cm4gIkxpZ2h0IENUTCBDbGllbnQiOw0KPiArCWNhc2UgMHgxMzA2OiByZXR1cm4g IkxpZ2h0IENUTCBUZW1wZXJhdHVyZSBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzA3OiByZXR1cm4g IkxpZ2h0IEhTTCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzA4OiByZXR1cm4gIkxpZ2h0IEhTTCBT ZXR1cCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzA5OiByZXR1cm4gIkxpZ2h0IEhTTCBDbGllbnQi Ow0KPiArCWNhc2UgMHgxMzBBOiByZXR1cm4gIkxpZ2h0IEhTTCBIdWUgU2VydmVyIjsNCj4gKwlj YXNlIDB4MTMwQjogcmV0dXJuICJMaWdodCBIU0wgU2F0dXJhdGlvbiBTZXJ2ZXIiOw0KPiArCWNh c2UgMHgxMzBDOiByZXR1cm4gIkxpZ2h0IHh5TCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzBEOiBy ZXR1cm4gIkxpZ2h0IHh5TCBTZXR1cCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzBFOiByZXR1cm4g IkxpZ2h0IHh5TCBDbGllbnQiOw0KPiArCWNhc2UgMHgxMzBGOiByZXR1cm4gIkxpZ2h0IExDIFNl cnZlciI7DQo+ICsJY2FzZSAweDEzMTA6IHJldHVybiAiTGlnaHQgTEMgU2V0dXAgU2VydmVyIjsN Cj4gKwljYXNlIDB4MTMxMTogcmV0dXJuICJMaWdodCBMQyBDbGllbnQiOw0KPiArDQo+ICsJZGVm YXVsdDogcmV0dXJuICJVbmtub3duIjsNCj4gKwl9DQo+ICt9DQo+IGRpZmYgLS1naXQgYS90b29s cy9tZXNoL3V0aWwuaCBiL3Rvb2xzL21lc2gvdXRpbC5oDQo+IGluZGV4IGNjYTA3Y2Y5Ni4uN2U5 NjZiYzY5IDEwMDY0NA0KPiAtLS0gYS90b29scy9tZXNoL3V0aWwuaA0KPiArKysgYi90b29scy9t ZXNoL3V0aWwuaA0KPiBAQCAtMjcsMyArMjcsNCBAQCB1aW50MTZfdCBtZXNoX29wY29kZV9zZXQo dWludDMyX3Qgb3Bjb2RlLCANCj4gdWludDhfdCAqYnVmKTsNCj4gICBib29sIG1lc2hfb3Bjb2Rl X2dldChjb25zdCB1aW50OF90ICpidWYsIHVpbnQxNl90IHN6LCANCj4gdWludDMyX3QgKm9wY29k ZSwgaW50ICpuKTsNCj4gICBjb25zdCBjaGFyICptZXNoX3N0YXR1c19zdHIodWludDhfdCBzdGF0 dXMpOw0KPiAgIHZvaWQgc3dhcF91MjU2X2J5dGVzKHVpbnQ4X3QgKnUyNTYpOw0KPiArY29uc3Qg Y2hhcioJc2lnX21vZGVsX3N0cmluZyh1aW50MTZfdCBzaWdfbW9kZWxfaWQpOw0KDQoiY2hhcioJ c2lnIiAtPiAiY2hhciAqc2lnIg0KDQoNClJlZ2FyZHMsDQpJbmdhDQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mMHqM5DUJl+FZAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 16:58:24 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id KG0VMpDUJl/cIgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 16:58:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1325DA1ACA; Sun, 2 Aug 2020 16:58:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726509AbgHBO6S (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 10:58:18 -0400 Received: from mail-il1-f199.google.com ([209.85.166.199]:34829 "EHLO mail-il1-f199.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726347AbgHBO6Q (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 10:58:16 -0400 Received: by mail-il1-f199.google.com with SMTP id g6so10641283iln.2 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 07:58:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=rP8qFuAIj5PA4GqYTY6invSs7s5chTKGJL4gZOv9MdY=; b=QcUaMd5R8ddFMsdmz334GpiS3h8X6I+3ANmu61nZn0Cm/9t8Wo4/UrYR8FoyUBdkIt rFlsaE52Lprp/2LYHZOopBKgD3bbEVIztof4FR6iE4fhCUMI+Tyv6z/JwCUAdGn0VJkY KBH2wkmcfVd3geEUcDBhoIn2C32Dqhz5GqvjA54H5HbwhRa48v5iYpLZo3SqUS36Cl0L C4KQiBUvI7RbGWjZOOrn9/+l8RAzTawRoG1wxKYs8ce0leTEIASqXhLTppGqd48D81NX M4aevd58U6PBNXGzbwTwPGMhz3ZRJol3ICK+uAld/WVUS8P5WAE6LEFpFQX3r3ERt5zp z7fA== X-Gm-Message-State: AOAM53056cEitog3AhcWOWgeEiuQZ4jS3djuoCvq6HqNFCAAz1DtOBH7 PJXyjE6WY70NI6YV03oZVdUOwjsoN3L8inCvp8T4y0vHZpvH X-Google-Smtp-Source: ABdhPJx9ALeHovUaCpJtg/QHit8tfWWHnVJ9RsvBsueoJYR9kZOfzHYl19tkkKfuQ3rlXOOSq2JcbkvVksIk0rI4isSp62iyhVn9 MIME-Version: 1.0 X-Received: by 2002:a92:9116:: with SMTP id t22mr4949412ild.305.1596380295789; Sun, 02 Aug 2020 07:58:15 -0700 (PDT) Date: Sun, 02 Aug 2020 07:58:15 -0700 In-Reply-To: <0000000000008b9e0705a38afe52@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000075030605abe640e5@google.com> Subject: Re: WARNING: refcount bug in do_enable_set From: syzbot <syzbot+2e9900a1e1b3c9c96a77@syzkaller.appspotmail.com> To: davem@davemloft.net, hdanton@sina.com, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.37 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1325DA1ACA X-Rspamd-UID: 0a8084 syzbot has found a reproducer for the following issue on: HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1194935c900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=2e9900a1e1b3c9c96a77 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10b7ddca900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=126dcf6c900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+2e9900a1e1b3c9c96a77@syzkaller.appspotmail.com ------------[ cut here ]------------ refcount_t: underflow; use-after-free. WARNING: CPU: 1 PID: 2540 at lib/refcount.c:28 refcount_warn_saturate+0x15b/0x1a0 lib/refcount.c:28 Kernel panic - not syncing: panic_on_warn set ... CPU: 1 PID: 2540 Comm: kworker/1:8 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events do_enable_set Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 panic+0x264/0x7a0 kernel/panic.c:231 __warn+0x227/0x250 kernel/panic.c:600 report_bug+0x1b1/0x2e0 lib/bug.c:198 handle_bug+0x42/0x80 arch/x86/kernel/traps.c:235 exc_invalid_op+0x16/0x40 arch/x86/kernel/traps.c:255 asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:540 RIP: 0010:refcount_warn_saturate+0x15b/0x1a0 lib/refcount.c:28 Code: c7 8a af 14 89 31 c0 e8 b3 f2 a8 fd 0f 0b eb 85 e8 2a 32 d7 fd c6 05 a4 d9 eb 05 01 48 c7 c7 b6 af 14 89 31 c0 e8 95 f2 a8 fd <0f> 0b e9 64 ff ff ff e8 09 32 d7 fd c6 05 84 d9 eb 05 01 48 c7 c7 RSP: 0018:ffffc90007d27c48 EFLAGS: 00010246 RAX: adb9104953f59b00 RBX: 0000000000000003 RCX: ffff8880a02d0540 RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000 RBP: 0000000000000003 R08: ffffffff815dd389 R09: ffffed1015d262c0 R10: ffffed1015d262c0 R11: 0000000000000000 R12: dffffc0000000000 R13: ffff8880a0259118 R14: dffffc0000000000 R15: ffff8880ae9350c0 do_enable_set+0x66e/0x900 net/bluetooth/6lowpan.c:1083 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Kernel Offset: disabled Rebooting in 86400 seconds.. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wBE6MBPWJl+FZAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 17:04:51 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UIPBLhPWJl8+SgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 17:04:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E5265A0A11; Sun, 2 Aug 2020 17:04:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725951AbgHBPEr (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 11:04:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725853AbgHBPEr (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 11:04:47 -0400 X-Greylist: delayed 460 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 02 Aug 2020 08:04:46 PDT Received: from hera.iit.uni-miskolc.hu (hera.iit.uni-miskolc.hu [IPv6:2001:738:6001:500::4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8ECAC06174A for <linux-bluetooth@vger.kernel.org>; Sun, 2 Aug 2020 08:04:46 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by hera.iit.uni-miskolc.hu (Postfix) with ESMTP id 401AB127; Sun, 2 Aug 2020 16:56:55 +0200 (CEST) X-Virus-Scanned: Kamavis at iit.uni-miskolc.hu Received: from hera.iit.uni-miskolc.hu ([127.0.0.1]) by localhost (hera.iit.uni-miskolc.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V-SdNRgwAo2I; Sun, 2 Aug 2020 16:56:47 +0200 (CEST) Received: from titan.hitronhub.home (unknown [IPv6:2a02:8109:a180:908:226:9eff:fe30:2af8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: szucst@iit.uni-miskolc.hu) by hera.iit.uni-miskolc.hu (Postfix) with ESMTPSA id 77BA5126; Sun, 2 Aug 2020 16:56:47 +0200 (CEST) From: =?UTF-8?q?Tam=C3=A1s=20Sz=C5=B1cs?= <tszucs@protonmail.ch> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Tam=C3=A1s=20Sz=C5=B1cs?= <tszucs@protonmail.ch> Subject: [PATCH] Bluetooth: btmrvl: eliminate duplicates introducing btmrvl_reg_89xx Date: Sun, 2 Aug 2020 16:56:42 +0200 Message-Id: <20200802145642.9990-1-tszucs@protonmail.ch> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 10 X-Rspamd-Score: 1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: E5265A0A11 X-Rspamd-UID: 394b36 SD89xx devices use identical card register settings. Make sure a single common instance is used to describe them. Signed-off-by: Tamás Szűcs <tszucs@protonmail.ch> --- drivers/bluetooth/btmrvl_sdio.c | 54 +++------------------------------ 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c index cfb9f9db44a0..92b28ff331b4 100644 --- a/drivers/bluetooth/btmrvl_sdio.c +++ b/drivers/bluetooth/btmrvl_sdio.c @@ -215,30 +215,7 @@ static const struct btmrvl_sdio_card_reg btmrvl_reg_8897 = { .fw_dump_end = 0xea, }; -static const struct btmrvl_sdio_card_reg btmrvl_reg_8977 = { - .cfg = 0x00, - .host_int_mask = 0x08, - .host_intstatus = 0x0c, - .card_status = 0x5c, - .sq_read_base_addr_a0 = 0xf8, - .sq_read_base_addr_a1 = 0xf9, - .card_revision = 0xc8, - .card_fw_status0 = 0xe8, - .card_fw_status1 = 0xe9, - .card_rx_len = 0xea, - .card_rx_unit = 0xeb, - .io_port_0 = 0xe4, - .io_port_1 = 0xe5, - .io_port_2 = 0xe6, - .int_read_to_clear = true, - .host_int_rsr = 0x04, - .card_misc_cfg = 0xD8, - .fw_dump_ctrl = 0xf0, - .fw_dump_start = 0xf1, - .fw_dump_end = 0xf8, -}; - -static const struct btmrvl_sdio_card_reg btmrvl_reg_8987 = { +static const struct btmrvl_sdio_card_reg btmrvl_reg_89xx = { .cfg = 0x00, .host_int_mask = 0x08, .host_intstatus = 0x0c, @@ -261,29 +238,6 @@ static const struct btmrvl_sdio_card_reg btmrvl_reg_8987 = { .fw_dump_end = 0xf8, }; -static const struct btmrvl_sdio_card_reg btmrvl_reg_8997 = { - .cfg = 0x00, - .host_int_mask = 0x08, - .host_intstatus = 0x0c, - .card_status = 0x5c, - .sq_read_base_addr_a0 = 0xf8, - .sq_read_base_addr_a1 = 0xf9, - .card_revision = 0xc8, - .card_fw_status0 = 0xe8, - .card_fw_status1 = 0xe9, - .card_rx_len = 0xea, - .card_rx_unit = 0xeb, - .io_port_0 = 0xe4, - .io_port_1 = 0xe5, - .io_port_2 = 0xe6, - .int_read_to_clear = true, - .host_int_rsr = 0x04, - .card_misc_cfg = 0xD8, - .fw_dump_ctrl = 0xf0, - .fw_dump_start = 0xf1, - .fw_dump_end = 0xf8, -}; - static const struct btmrvl_sdio_device btmrvl_sdio_sd8688 = { .helper = "mrvl/sd8688_helper.bin", .firmware = "mrvl/sd8688.bin", @@ -332,7 +286,7 @@ static const struct btmrvl_sdio_device btmrvl_sdio_sd8897 = { static const struct btmrvl_sdio_device btmrvl_sdio_sd8977 = { .helper = NULL, .firmware = "mrvl/sdsd8977_combo_v2.bin", - .reg = &btmrvl_reg_8977, + .reg = &btmrvl_reg_89xx, .support_pscan_win_report = true, .sd_blksz_fw_dl = 256, .supports_fw_dump = true, @@ -341,7 +295,7 @@ static const struct btmrvl_sdio_device btmrvl_sdio_sd8977 = { static const struct btmrvl_sdio_device btmrvl_sdio_sd8987 = { .helper = NULL, .firmware = "mrvl/sd8987_uapsta.bin", - .reg = &btmrvl_reg_8987, + .reg = &btmrvl_reg_89xx, .support_pscan_win_report = true, .sd_blksz_fw_dl = 256, .supports_fw_dump = true, @@ -350,7 +304,7 @@ static const struct btmrvl_sdio_device btmrvl_sdio_sd8987 = { static const struct btmrvl_sdio_device btmrvl_sdio_sd8997 = { .helper = NULL, .firmware = "mrvl/sdsd8997_combo_v4.bin", - .reg = &btmrvl_reg_8997, + .reg = &btmrvl_reg_89xx, .support_pscan_win_report = true, .sd_blksz_fw_dl = 256, .supports_fw_dump = true, -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ILxiOZzUJl8WdgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 16:58:36 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 2JH0N5zUJl88IQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 16:58:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 04983A1C2D; Sun, 2 Aug 2020 16:58:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726748AbgHBO6X convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 10:58:23 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:54399 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725853AbgHBO6V (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 10:58:21 -0400 Received: from [192.168.1.151] (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id CC417CED2E; Sun, 2 Aug 2020 17:08:22 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Bluetooth: btusb: Add a module parameter ignore_id for debugging From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200802042138.9149-1-hui.wang@canonical.com> Date: Sun, 2 Aug 2020 16:58:19 +0200 Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Johan Hedberg <johan.hedberg@gmail.com> Content-Transfer-Encoding: 8BIT Message-Id: <432B3E10-052D-4DCB-84A4-B239D218D4E5@holtmann.org> References: <20200802042138.9149-1-hui.wang@canonical.com> To: Hui Wang <hui.wang@canonical.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: 0.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: 04983A1C2D X-Rspamd-UID: 058d83 Hi Hui, > There is always an on-board usb bluetooth hci on the laptops, if > the bluetooth function doesn't work well like a bt headset can't work > with HSP/HFP mode, we often plug an external usb BT hci to verify if > that headset could work with the exteral BT hci or not, in this > situation, there will be 2 hcis (hci0 and hci1) in the system, and > so far, the gnome can't handle the hci1 well so we met lots of > problems when debugging with hci1 under gnome. > > After adding this new module parameter, we could ban the on-board > usb hci by putting btusb.ignore_id=idVendor,idProduct to the bootargs, > then the external usb hci will be hci0 and there is only one hci > in the system. We could easily debug with the external usb bluetooth > hci after this change. > > Signed-off-by: Hui Wang <hui.wang@canonical.com> > --- > drivers/bluetooth/btusb.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) please use this instead. echo “vvvv pppp 0 08fd 0002" > /sys/bus/usb/drivers/foo/new_id Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8AHeBzb/Jl+5SQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 20:00:22 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uL1lBjb/Jl+xygEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 20:00:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 78512418AE; Sun, 2 Aug 2020 20:00:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727787AbgHBSAP convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 14:00:15 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:48680 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbgHBSAP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 14:00:15 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id D8365CED31; Sun, 2 Aug 2020 20:10:16 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: btmrvl: eliminate duplicates introducing btmrvl_reg_89xx From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200802145642.9990-1-tszucs@protonmail.ch> Date: Sun, 2 Aug 2020 20:00:13 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <5511988E-D6FA-4488-9090-68FFA4CC36FF@holtmann.org> References: <20200802145642.9990-1-tszucs@protonmail.ch> To: =?utf-8?B?VGFtw6FzIFN6xbFjcw==?= <tszucs@protonmail.ch> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 78512418AE X-Rspamd-UID: 1a9104 Hi Tamas, > SD89xx devices use identical card register settings. Make sure a single common > instance is used to describe them. > > Signed-off-by: Tamás Szűcs <tszucs@protonmail.ch> > --- > drivers/bluetooth/btmrvl_sdio.c | 54 +++------------------------------ > 1 file changed, 4 insertions(+), 50 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mKxEMMP/Jl+5SQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 20:02:43 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kJmELsP/Jl9G+AEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 20:02:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4EA0D40016; Sun, 2 Aug 2020 20:02:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727846AbgHBSCc convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 14:02:32 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:60382 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbgHBSCb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 14:02:31 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 29119CED31; Sun, 2 Aug 2020 20:12:32 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH 2/2] Bluetooth: hci_ldisc/hci_serdev: Cancel init work before unregistering From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200801162956.22610-2-samuel@sholland.org> Date: Sun, 2 Aug 2020 20:02:29 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, Gustavo Padovan <gustavo.padovan@collabora.co.uk>, Hans de Goede <hdegoede@redhat.com>, Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <33FE7F8B-3467-4BC6-B74C-CA7835A4E9CF@holtmann.org> References: <20200801162956.22610-1-samuel@sholland.org> <20200801162956.22610-2-samuel@sholland.org> To: Samuel Holland <samuel@sholland.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.89 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4EA0D40016 X-Rspamd-UID: f9e6cc Hi Samuel, > If hci_uart_tty_close() or hci_uart_unregister_device() is called while > hu->init_ready is scheduled, hci_register_dev() could be called after > the hci_uart is torn down. Avoid this by ensuring the work is complete > or canceled before checking the HCI_UART_REGISTERED flag. > > Fixes: 9f2aee848fe6 ("Bluetooth: Add delayed init sequence support for UART controllers") > Signed-off-by: Samuel Holland <samuel@sholland.org> > --- > drivers/bluetooth/hci_ldisc.c | 1 + > drivers/bluetooth/hci_serdev.c | 2 ++ > 2 files changed, 3 insertions(+) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aElBMOD/Jl+0RAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 20:03:12 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gLkKL+D/Jl/nHAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 20:03:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5F349418A6; Sun, 2 Aug 2020 20:03:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727889AbgHBSC4 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 14:02:56 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:33877 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbgHBSCz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 14:02:55 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id E6FDECED31; Sun, 2 Aug 2020 20:12:56 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH 1/2] Bluetooth: hci_h5: Remove ignored flag HCI_UART_RESET_ON_INIT From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200801162956.22610-1-samuel@sholland.org> Date: Sun, 2 Aug 2020 20:02:54 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, Gustavo Padovan <gustavo.padovan@collabora.co.uk>, Hans de Goede <hdegoede@redhat.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <9854BD61-4A65-4F4F-AAB4-138C34B13312@holtmann.org> References: <20200801162956.22610-1-samuel@sholland.org> To: Samuel Holland <samuel@sholland.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.44 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5F349418A6 X-Rspamd-UID: ae3496 Hi Samuel, > Since commit cba736465e5c ("Bluetooth: hci_serdev: Remove setting of > HCI_QUIRK_RESET_ON_CLOSE."), this flag is ignored for hci_serdev users, > so let's remove setting it. > > Signed-off-by: Samuel Holland <samuel@sholland.org> > --- > drivers/bluetooth/hci_h5.c | 2 -- > 1 file changed, 2 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2D4lBQUmJ1+ZGwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 22:45:57 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wN/8AwUmJ1/YggAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 22:45:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5C252A193B; Sun, 2 Aug 2020 22:45:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727957AbgHBUpc (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 16:45:32 -0400 Received: from mail-io1-f72.google.com ([209.85.166.72]:45996 "EHLO mail-io1-f72.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727829AbgHBUpV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 16:45:21 -0400 Received: by mail-io1-f72.google.com with SMTP id p17so22016333iod.12 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 13:45:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=VIjViLF9vTXg5y9QTImEwwOAxUFJ5T2PWR5V15NAn6c=; b=Qi7vWxG/WuOZwHB7l1FPbjxFYtEHskpH0NSdKJnKayQlgoKQK3l+96PJtuLXnJ01H5 R7SD7tJekZR9aB1VwreKVtYwGUi7L+UIM5P4bOVPjeWD1mi+yqUw783twNDUtxmE341M cWsv0t5BxFbyd2wn/IJsmMNElzH6I6OA71/EaiM3abdNG2xqDTjhb4Ou5g7pVBZfnGPW SAxG1ILlHKCUDPHMkh7Py+5DCQ7mx8GCPJFOpbgxU4RTJI+BuHq0HPG5/By7XaDxsEiT IXBb+JniOtylU7paVEXW+6tmY8qYHIrVWIgs0vq0X5VkpR1wqIkaq5uL42RO2qbxa5/+ stzA== X-Gm-Message-State: AOAM5329y/66CbcI3q90MMbnSv5lCBUQlRtrxWHMjI6WhWltzWeZ7oNM K6atdOD6K5Qz4SG4iIzelfVr0/zZi+j8U/ihbGxYS6Rg7wZg X-Google-Smtp-Source: ABdhPJwKE34lm1+CsRz/PxsW8nnNxqCCOnFZMSoCVSsP/yrqpddTlWmL55FBsziS5ULFyTw/8c62UfSpZlMcwGsLbjip5GkNpPlo MIME-Version: 1.0 X-Received: by 2002:a92:5f17:: with SMTP id t23mr12897147ilb.62.1596401120044; Sun, 02 Aug 2020 13:45:20 -0700 (PDT) Date: Sun, 02 Aug 2020 13:45:20 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000adea7f05abeb19cf@google.com> Subject: KASAN: use-after-free Read in hci_chan_del From: syzbot <syzbot+305a91e025a73e4fd6ce@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5C252A193B X-Rspamd-UID: 1c1823 Hello, syzbot found the following issue on: HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=11b8d570900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=305a91e025a73e4fd6ce compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11f7ceea900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17e5de04900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+305a91e025a73e4fd6ce@syzkaller.appspotmail.com IPVS: ftp: loaded support on port[0] = 21 ================================================================== BUG: KASAN: use-after-free in hci_chan_del+0x33/0x130 net/bluetooth/hci_conn.c:1707 Read of size 8 at addr ffff8880a9591f18 by task syz-executor081/6793 CPU: 0 PID: 6793 Comm: syz-executor081 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 print_address_description+0x66/0x5a0 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report+0x132/0x1d0 mm/kasan/report.c:530 hci_chan_del+0x33/0x130 net/bluetooth/hci_conn.c:1707 l2cap_conn_del+0x4c2/0x650 net/bluetooth/l2cap_core.c:1900 hci_disconn_cfm include/net/bluetooth/hci_core.h:1355 [inline] hci_conn_hash_flush+0x127/0x200 net/bluetooth/hci_conn.c:1536 hci_dev_do_close+0xb7b/0x1040 net/bluetooth/hci_core.c:1761 hci_unregister_dev+0x16d/0x1590 net/bluetooth/hci_core.c:3606 vhci_release+0x73/0xc0 drivers/bluetooth/hci_vhci.c:340 __fput+0x2f0/0x750 fs/file_table.c:281 task_work_run+0x137/0x1c0 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0x601/0x1f80 kernel/exit.c:805 do_group_exit+0x161/0x2d0 kernel/exit.c:903 __do_sys_exit_group+0x13/0x20 kernel/exit.c:914 __se_sys_exit_group+0x10/0x10 kernel/exit.c:912 __x64_sys_exit_group+0x37/0x40 kernel/exit.c:912 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x444fe8 Code: Bad RIP value. RSP: 002b:00007ffe96e46e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 0000000000444fe8 RDX: 0000000000000001 RSI: 000000000000003c RDI: 0000000000000001 RBP: 00000000004ccdd0 R08: 00000000000000e7 R09: ffffffffffffffd0 R10: 00007f5ee25cd700 R11: 0000000000000246 R12: 0000000000000001 R13: 00000000006e0200 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 6821: save_stack mm/kasan/common.c:48 [inline] set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494 kmem_cache_alloc_trace+0x234/0x300 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] hci_chan_create+0x9a/0x270 net/bluetooth/hci_conn.c:1692 l2cap_conn_add+0x66/0xb00 net/bluetooth/l2cap_core.c:7699 l2cap_connect_cfm+0xdb/0x12b0 net/bluetooth/l2cap_core.c:8097 hci_connect_cfm include/net/bluetooth/hci_core.h:1340 [inline] hci_remote_features_evt net/bluetooth/hci_event.c:3210 [inline] hci_event_packet+0x1164c/0x18260 net/bluetooth/hci_event.c:6061 hci_rx_work+0x236/0x9c0 net/bluetooth/hci_core.c:4705 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Freed by task 1530: save_stack mm/kasan/common.c:48 [inline] set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0x114/0x170 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x10a/0x220 mm/slab.c:3757 hci_disconn_loglink_complete_evt net/bluetooth/hci_event.c:4999 [inline] hci_event_packet+0x304e/0x18260 net/bluetooth/hci_event.c:6188 hci_rx_work+0x236/0x9c0 net/bluetooth/hci_core.c:4705 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 The buggy address belongs to the object at ffff8880a9591f00 which belongs to the cache kmalloc-128 of size 128 The buggy address is located 24 bytes inside of 128-byte region [ffff8880a9591f00, ffff8880a9591f80) The buggy address belongs to the page: page:ffffea0002a56440 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880a9591800 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea0002a5a648 ffffea00028a4a08 ffff8880aa400700 raw: ffff8880a9591800 ffff8880a9591000 000000010000000a 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880a9591e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880a9591e80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff8880a9591f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880a9591f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8880a9592000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ================================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cH5DLQgmJ1+ZGwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 22:46:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 6LBtKwgmJ1/YMAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 22:46:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 42359A1DE2; Sun, 2 Aug 2020 22:45:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727887AbgHBUpV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 16:45:21 -0400 Received: from mail-io1-f69.google.com ([209.85.166.69]:40926 "EHLO mail-io1-f69.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727098AbgHBUpU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 16:45:20 -0400 Received: by mail-io1-f69.google.com with SMTP id t22so15956461iob.7 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 13:45:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=RXzvXK6OwD5sKXbnrgicyuSzP9xmdWgB2LwI/qp4B8g=; b=LenZ+Yz1DZjHym85n1g8q5SIU6MEw724T8NDTkx9pOQZpwhooRoddHmfgimwb6vtyd gXY910dRzl3cbrA77Q9vvQx8hAirR3PDOVYsvg6YH6ht/WL0uxtGVBHRJOTS7cNT0IOv x68Knqcufu8CtINpt6eWsAau4FCG0RNvYY7qjJn8ds1z47ncxSNCocNmwNiMw3909w5z 9IZxG++ofCoHCS61FzkffONfgycHZOiCOZGH0ARhpRkakpaVs0dHb0wKTjPQmJx8IkDm t6cBwNZboXPedfHgLaLbwh9f4RlvKjU/c/565rL5Vbdic+DqiGEbh6gZD7RF8hGevmaO /f4Q== X-Gm-Message-State: AOAM533HSJXcWodX+4hWjPZWIiN5NvL3kuxvGMoC4CwrhJj88oYA80tT uJ7RTd3OA3XFpsxUoz7mOQYWpyZEY9as3gd1qXekgggROsYA X-Google-Smtp-Source: ABdhPJwS6z64gwXYyqJmUHpKD7bkhS2G9ZwGRgeCJ9WvFEQ6ciYipYww9Ipkk9UqjXGRdT07cN4NNkp+ci28BlKNfTpZcqHad183 MIME-Version: 1.0 X-Received: by 2002:a05:6638:d12:: with SMTP id q18mr16853928jaj.5.1596401119651; Sun, 02 Aug 2020 13:45:19 -0700 (PDT) Date: Sun, 02 Aug 2020 13:45:19 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000a7eb5e05abeb197d@google.com> Subject: general protection fault in hci_event_packet From: syzbot <syzbot+0bef568258653cff272f@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@armlinux.org.uk, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: 42359A1DE2 X-Rspamd-UID: 72232b Hello, syzbot found the following issue on: HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=11af8670900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=0bef568258653cff272f compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=146f0832900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=101f8e04900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] CPU: 1 PID: 6835 Comm: kworker/u5:1 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work RIP: 0010:hci_phy_link_complete_evt net/bluetooth/hci_event.c:4926 [inline] RIP: 0010:hci_event_packet+0x8386/0x18260 net/bluetooth/hci_event.c:6180 Code: c1 e8 03 49 be 00 00 00 00 00 fc ff df 42 80 3c 30 00 74 08 48 89 df e8 58 9a 5e fa 48 8b 1b 48 83 c3 10 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 3b 9a 5e fa 48 8b 1b 48 89 d8 48 RSP: 0018:ffffc900015b7ac8 EFLAGS: 00010202 RAX: 0000000000000002 RBX: 0000000000000010 RCX: dffffc0000000000 RDX: ffff8880920805c0 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffff888092ef2000 R08: ffffffff875506b4 R09: fffffbfff131a9a6 R10: fffffbfff131a9a6 R11: 0000000000000000 R12: ffff8880a6e4c010 R13: ffff8880a6e4d110 R14: dffffc0000000000 R15: ffff8880a6e4c000 FS: 0000000000000000(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020000000 CR3: 00000000a85d0000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: hci_rx_work+0x236/0x9c0 net/bluetooth/hci_core.c:4705 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Modules linked in: ---[ end trace c208f496eb8e7691 ]--- RIP: 0010:hci_phy_link_complete_evt net/bluetooth/hci_event.c:4926 [inline] RIP: 0010:hci_event_packet+0x8386/0x18260 net/bluetooth/hci_event.c:6180 Code: c1 e8 03 49 be 00 00 00 00 00 fc ff df 42 80 3c 30 00 74 08 48 89 df e8 58 9a 5e fa 48 8b 1b 48 83 c3 10 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 3b 9a 5e fa 48 8b 1b 48 89 d8 48 RSP: 0018:ffffc900015b7ac8 EFLAGS: 00010202 RAX: 0000000000000002 RBX: 0000000000000010 RCX: dffffc0000000000 RDX: ffff8880920805c0 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffff888092ef2000 R08: ffffffff875506b4 R09: fffffbfff131a9a6 R10: fffffbfff131a9a6 R11: 0000000000000000 R12: ffff8880a6e4c010 R13: ffff8880a6e4d110 R14: dffffc0000000000 R15: ffff8880a6e4c000 FS: 0000000000000000(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f095f0866c0 CR3: 0000000009479000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yKp/JgwmJ18SEgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 22:46:04 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id aH4SJQwmJ1+VnAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 22:46:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D5E86A0A11; Sun, 2 Aug 2020 22:46:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727979AbgHBUpk (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 16:45:40 -0400 Received: from mail-il1-f198.google.com ([209.85.166.198]:38488 "EHLO mail-il1-f198.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727109AbgHBUpV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 16:45:21 -0400 Received: by mail-il1-f198.google.com with SMTP id t79so23721125ild.5 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 13:45:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=1xycOSK9097oITbtkPQ2Z+DRSqX1NFWh+pkPwjLV+LY=; b=R9Pu8X4OiDJ9pNKDfIVKSLgT1SClOxovQQb0bOTJXLren5H3oT/3agmTr9yBd1mjT7 RTnHDpy1qx3ERfQ80nEabMpPA8HMLxlpRteGi08HqK2RwKhTl/k4pL8GmsU45muBRQqt rxpdHDgAAuFF4zIKNtDX1Ud7LJo9960l145Lx7gMBNjz/lh4QcTrNa4ByW6P+I26W7C9 dQB7hSUv4M25utltb+vwrYUxV1AByGda2xX7sYSThLbDyk0JO4US5jeIIII4OL8n7YIl oNxAZycHtz0uw+XnwU4+DV/GLXiOU/+iRAlBOHFPsS2NJZiR5TUgG3O5JTeg8eiBKGHa c15g== X-Gm-Message-State: AOAM530/UTO73Z6h0eM477FDtJi0f1FEJNMInyQS/4YIpYlL1J5AvS44 gc8mj0GP2FzaqotZ46FtNIAclqMny9vabTsyN3sApllEp/Am X-Google-Smtp-Source: ABdhPJwVUWGfBOw2qltlxlKtIO0DVihpZCkVO501w3BsGQbUNyEt3TmeTq4L2nxZ+whRI96eKPygp/iHbXShO3RmXqYwHRR2fGTk MIME-Version: 1.0 X-Received: by 2002:a92:ba57:: with SMTP id o84mr13395563ili.215.1596401119857; Sun, 02 Aug 2020 13:45:19 -0700 (PDT) Date: Sun, 02 Aug 2020 13:45:19 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000ab11c505abeb19f5@google.com> Subject: KASAN: use-after-free Write in __sco_sock_close From: syzbot <syzbot+077eca30d3cb7c02b273@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: D5E86A0A11 X-Rspamd-UID: ba4425 Hello, syzbot found the following issue on: HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=17082904900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=077eca30d3cb7c02b273 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12cf1904900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10d52e14900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+077eca30d3cb7c02b273@syzkaller.appspotmail.com ================================================================== BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:71 [inline] BUG: KASAN: use-after-free in atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline] BUG: KASAN: use-after-free in hci_conn_drop include/net/bluetooth/hci_core.h:1049 [inline] BUG: KASAN: use-after-free in sco_chan_del net/bluetooth/sco.c:148 [inline] BUG: KASAN: use-after-free in __sco_sock_close+0x47c/0xed0 net/bluetooth/sco.c:433 Write of size 4 at addr ffff88809191e010 by task syz-executor393/6961 CPU: 0 PID: 6961 Comm: syz-executor393 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 print_address_description+0x66/0x5a0 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report+0x132/0x1d0 mm/kasan/report.c:530 check_memory_region_inline mm/kasan/generic.c:183 [inline] check_memory_region+0x2b5/0x2f0 mm/kasan/generic.c:192 instrument_atomic_write include/linux/instrumented.h:71 [inline] atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline] hci_conn_drop include/net/bluetooth/hci_core.h:1049 [inline] sco_chan_del net/bluetooth/sco.c:148 [inline] __sco_sock_close+0x47c/0xed0 net/bluetooth/sco.c:433 sco_sock_close net/bluetooth/sco.c:447 [inline] sco_sock_release+0x63/0x4f0 net/bluetooth/sco.c:1021 __sock_release net/socket.c:605 [inline] sock_close+0xd8/0x260 net/socket.c:1278 __fput+0x2f0/0x750 fs/file_table.c:281 task_work_run+0x137/0x1c0 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0x601/0x1f80 kernel/exit.c:805 do_group_exit+0x161/0x2d0 kernel/exit.c:903 get_signal+0x139b/0x1d30 kernel/signal.c:2743 do_signal+0x33/0x610 arch/x86/kernel/signal.c:810 exit_to_usermode_loop arch/x86/entry/common.c:235 [inline] __prepare_exit_to_usermode+0xd7/0x1e0 arch/x86/entry/common.c:269 do_syscall_64+0x7f/0xe0 arch/x86/entry/common.c:393 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x446e69 Code: Bad RIP value. RSP: 002b:00007ffde45fd7f8 EFLAGS: 00000246 ORIG_RAX: 000000000000002a RAX: fffffffffffffffc RBX: 0000000000000000 RCX: 0000000000446e69 RDX: 0000000000000008 RSI: 0000000020000000 RDI: 0000000000000004 RBP: 0000000000000004 R08: 0000000000000002 R09: 00000003000000ff R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000407ac0 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 6961: save_stack mm/kasan/common.c:48 [inline] set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494 kmem_cache_alloc_trace+0x234/0x300 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] hci_conn_add+0x5d/0x1040 net/bluetooth/hci_conn.c:525 hci_connect_sco+0x29a/0xa10 net/bluetooth/hci_conn.c:1279 sco_connect net/bluetooth/sco.c:240 [inline] sco_sock_connect+0x2de/0xaa0 net/bluetooth/sco.c:576 __sys_connect_file net/socket.c:1854 [inline] __sys_connect+0x2da/0x360 net/socket.c:1871 __do_sys_connect net/socket.c:1882 [inline] __se_sys_connect net/socket.c:1879 [inline] __x64_sys_connect+0x76/0x80 net/socket.c:1879 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 6957: save_stack mm/kasan/common.c:48 [inline] set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0x114/0x170 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x10a/0x220 mm/slab.c:3757 device_release+0x70/0x1a0 drivers/base/core.c:1575 kobject_cleanup lib/kobject.c:693 [inline] kobject_release lib/kobject.c:722 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x15b/0x220 lib/kobject.c:739 hci_conn_del+0x2c2/0x550 net/bluetooth/hci_conn.c:645 hci_phy_link_complete_evt net/bluetooth/hci_event.c:4921 [inline] hci_event_packet+0x8335/0x18260 net/bluetooth/hci_event.c:6180 hci_rx_work+0x236/0x9c0 net/bluetooth/hci_core.c:4705 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 The buggy address belongs to the object at ffff88809191e000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 16 bytes inside of 4096-byte region [ffff88809191e000, ffff88809191f000) The buggy address belongs to the page: page:ffffea0002464780 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea0002464780 order:1 compound_mapcount:0 flags: 0xfffe0000010200(slab|head) raw: 00fffe0000010200 ffffea0002489f88 ffffea000249dd08 ffff8880aa402000 raw: 0000000000000000 ffff88809191e000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809191df00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88809191df80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88809191e000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88809191e080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88809191e100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QMuhERAmJ1+ZGwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 22:46:08 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wG4vEBAmJ1/DcQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 22:46:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BC3D5A010F; Sun, 2 Aug 2020 22:46:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727983AbgHBUpl (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 16:45:41 -0400 Received: from mail-io1-f71.google.com ([209.85.166.71]:37178 "EHLO mail-io1-f71.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726807AbgHBUpU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 16:45:20 -0400 Received: by mail-io1-f71.google.com with SMTP id f6so10892609ioa.4 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 13:45:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=WCj8CYMMQAWzJ6MWSBeZcNE1cIR+npprASii5Yv7VV0=; b=ue383sXVJ9ptUWrdHxbUeVJJTxa5/0U3SvqGQGeC23l7rwNrXdMU9Er1IH5SX5qPuG zpsavTq6SX+5jLwySl9Z5vupqFzuHuQD57T55Ha0q6cseW4FWau/74ZSO7yBf/1CHh6M hsGsaUdZZvRc0+LrhCFNRUrbh8+BAsphHaKyc+gKXX1uK9o0MHSBKfy+3op50gs4u0Dq y5L8JsVTjVSAmexhhh8HvaN6yGnXozrwd3SL5yU3u1S9zpEZBpRD+WOi3LIwmyhzyh52 YWzlhA00TzshVsrhxiKW1dzBV6/jV8yI87WhPHeE++kHtKigyCMDjc7yxqTNMne2m15E I+NQ== X-Gm-Message-State: AOAM532DED7ilpVhEDEcU2s/C3a5aOuVjVQW0w7AaqeygKlbJ0x/Ke2G y7ATOvXEK92e9SZs8V6F1KTMwPRLDTWnncYncHFzVwoQNKxH X-Google-Smtp-Source: ABdhPJxrDcWd2SstCuCwqW3Wn8G3wdsFFZ9beZO0KN/EJRcm6ZJcbbq9Ex6Ya2FXgRS/n7yrwTIrUDsDwpzrGLwErE+N+CulYzQO MIME-Version: 1.0 X-Received: by 2002:a05:6638:348:: with SMTP id x8mr16357883jap.62.1596401119369; Sun, 02 Aug 2020 13:45:19 -0700 (PDT) Date: Sun, 02 Aug 2020 13:45:19 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000a39e4905abeb193f@google.com> Subject: general protection fault in hci_phy_link_complete_evt From: syzbot <syzbot+18e38290a2a263b31aa0@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@armlinux.org.uk, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: BC3D5A010F X-Rspamd-UID: 29825e Hello, syzbot found the following issue on: HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=15ab47ca900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 dashboard link: https://syzkaller.appspot.com/bug?extid=18e38290a2a263b31aa0 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17f3dd0c900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1032a642900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+18e38290a2a263b31aa0@syzkaller.appspotmail.com general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] CPU: 1 PID: 6861 Comm: kworker/u5:1 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work RIP: 0010:hci_phy_link_complete_evt.isra.0+0x23e/0x790 net/bluetooth/hci_event.c:4926 Code: 48 c1 ea 03 80 3c 02 00 0f 85 3e 05 00 00 48 8b 9d 30 09 00 00 48 b8 00 00 00 00 00 fc ff df 48 8d 7b 10 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 da 04 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b RSP: 0018:ffffc90001897a38 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff871af0e3 RDX: 0000000000000002 RSI: ffffffff871af0f0 RDI: 0000000000000010 RBP: ffff88808f25e000 R08: 0000000000000001 R09: ffff8880a1cf6a88 R10: 0000000000000000 R11: 0000000000000000 R12: dffffc0000000000 R13: ffff8880877f1110 R14: ffff8880926b480b R15: 00000000000000c8 FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020000000 CR3: 00000000a7ccc000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: hci_event_packet+0x481a/0x86f5 net/bluetooth/hci_event.c:6180 hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Modules linked in: ---[ end trace 905ef6786a414f06 ]--- RIP: 0010:hci_phy_link_complete_evt.isra.0+0x23e/0x790 net/bluetooth/hci_event.c:4926 Code: 48 c1 ea 03 80 3c 02 00 0f 85 3e 05 00 00 48 8b 9d 30 09 00 00 48 b8 00 00 00 00 00 fc ff df 48 8d 7b 10 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 da 04 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b RSP: 0018:ffffc90001897a38 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff871af0e3 RDX: 0000000000000002 RSI: ffffffff871af0f0 RDI: 0000000000000010 RBP: ffff88808f25e000 R08: 0000000000000001 R09: ffff8880a1cf6a88 R10: 0000000000000000 R11: 0000000000000000 R12: dffffc0000000000 R13: ffff8880877f1110 R14: ffff8880926b480b R15: 00000000000000c8 FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fff77d3f7a7 CR3: 000000009291e000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4CljASsmJ1+ZGwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 22:46:35 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eG+ROyomJ1+IfwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 22:46:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 22C6DA1ACA; Sun, 2 Aug 2020 22:46:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728023AbgHBUqZ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 16:46:25 -0400 Received: from mail-il1-f199.google.com ([209.85.166.199]:55307 "EHLO mail-il1-f199.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727988AbgHBUqV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 16:46:21 -0400 Received: by mail-il1-f199.google.com with SMTP id i78so20940796ill.22 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 13:46:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=UR/ZO0hH6TY23jTg0tEYuIZyHB35kzhpcW94c67p/IY=; b=AGfqPpsu60oefJmnJOvjC+lrKwWzDx0oT1SKFlSw68VB2zZ2eR2NuMvxyw7S5nxGgx SPE2LEFUL0+qDa8k4o92P0xV0PFsseelb4GV5I7vTb6bpwrYxLMyg1n/i/5j4lMF0a3l aChwt3xkLdoZpbJvxG/7q2nxr2T6Bt9NLRDDAcfP93ivPvMh2huJ5GFbfJWV/OlHqdSU 2g1lUfCC/ai5wcDE2l3w9HYw7XaB0ATh5XK5EpQnL057jHxihUJe3v0jd6e5iew/ut1c IW+Ki4flbBg+11ns9e3k0VgXRlzM8EgXXgFEuQvmjPolKtJz1n26zw8utzDxwHJ/G6Eu Zn0g== X-Gm-Message-State: AOAM533PLXHufRuxdLYlhko6Cxjmxn6NQZ3dJMu4OhcN7/CjrMHdHL9C zOTnCfO/8etC+lvBl/Lq4CvxLiN06Oj136aAFF36udgj0YHA X-Google-Smtp-Source: ABdhPJz7QroLRzfyvDXIacdc4voPN0fxMrySmyqn0CFftkCfYMBM0YQGazUDxAJijzwoaYNvZzDHqwqhpHTS867zlK7eYtmTskSB MIME-Version: 1.0 X-Received: by 2002:a6b:5d0a:: with SMTP id r10mr13874575iob.186.1596401179781; Sun, 02 Aug 2020 13:46:19 -0700 (PDT) Date: Sun, 02 Aug 2020 13:46:19 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000003d6e8405abeb1da7@google.com> Subject: KASAN: use-after-free Read in hci_send_acl From: syzbot <syzbot+98228e7407314d2d4ba2@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: 22C6DA1ACA X-Rspamd-UID: 7d9a6c Hello, syzbot found the following issue on: HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=13482904900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 dashboard link: https://syzkaller.appspot.com/bug?extid=98228e7407314d2d4ba2 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=152f1904900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1482dfca900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+98228e7407314d2d4ba2@syzkaller.appspotmail.com ================================================================== BUG: KASAN: use-after-free in hci_send_acl+0xabe/0xc60 net/bluetooth/hci_core.c:3991 Read of size 8 at addr ffff8880a6ff8818 by task kworker/u5:2/6855 CPU: 1 PID: 6855 Comm: kworker/u5:2 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530 hci_send_acl+0xabe/0xc60 net/bluetooth/hci_core.c:3991 l2cap_send_cmd+0x6d5/0x8a0 net/bluetooth/l2cap_core.c:949 l2cap_send_move_chan_cfm_icid net/bluetooth/l2cap_core.c:4917 [inline] l2cap_move_fail net/bluetooth/l2cap_core.c:5401 [inline] l2cap_move_channel_rsp net/bluetooth/l2cap_core.c:5440 [inline] l2cap_bredr_sig_cmd net/bluetooth/l2cap_core.c:5719 [inline] l2cap_sig_channel net/bluetooth/l2cap_core.c:6418 [inline] l2cap_recv_frame+0x6936/0xae10 net/bluetooth/l2cap_core.c:7660 l2cap_recv_acldata+0x7f6/0x8e0 net/bluetooth/l2cap_core.c:8313 hci_acldata_packet net/bluetooth/hci_core.c:4520 [inline] hci_rx_work+0x4c7/0xb10 net/bluetooth/hci_core.c:4710 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Allocated by task 6855: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494 kmem_cache_alloc_trace+0x14f/0x2d0 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] hci_chan_create+0x9b/0x330 net/bluetooth/hci_conn.c:1692 l2cap_conn_add.part.0+0x1e/0xe10 net/bluetooth/l2cap_core.c:7699 l2cap_conn_add net/bluetooth/l2cap_core.c:8139 [inline] l2cap_connect_cfm+0x23b/0x1090 net/bluetooth/l2cap_core.c:8097 hci_connect_cfm include/net/bluetooth/hci_core.h:1340 [inline] hci_remote_features_evt net/bluetooth/hci_event.c:3210 [inline] hci_event_packet+0x3e01/0x86f5 net/bluetooth/hci_event.c:6061 hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Freed by task 6855: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x103/0x2c0 mm/slab.c:3757 hci_disconn_loglink_complete_evt net/bluetooth/hci_event.c:4999 [inline] hci_event_packet+0x319a/0x86f5 net/bluetooth/hci_event.c:6188 hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 The buggy address belongs to the object at ffff8880a6ff8800 which belongs to the cache kmalloc-128 of size 128 The buggy address is located 24 bytes inside of 128-byte region [ffff8880a6ff8800, ffff8880a6ff8880) The buggy address belongs to the page: page:ffffea00029bfe00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880a6ff8c00 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea0002934388 ffff8880aa001540 ffff8880aa000700 raw: ffff8880a6ff8c00 ffff8880a6ff8000 000000010000000c 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880a6ff8700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880a6ff8780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff8880a6ff8800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880a6ff8880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8880a6ff8900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yJttHzAmJ18SEgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 22:46:40 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WIVeHjAmJ1/DcQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 22:46:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 27DA3A1965; Sun, 2 Aug 2020 22:46:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727995AbgHBUqV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 16:46:21 -0400 Received: from mail-il1-f200.google.com ([209.85.166.200]:39572 "EHLO mail-il1-f200.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727919AbgHBUqU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 16:46:20 -0400 Received: by mail-il1-f200.google.com with SMTP id i66so17677404ile.6 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 13:46:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=gb1bfcM4gWAnNmFB6x9ih5/iUQPdrS6TKSoNqV7OW28=; b=tpH2aGnZn8xKPmm/AkCkz6sPhnh+DWZV8nv/26Bbqn8bFv4EP1F37gNw+6TQ20WQi6 srL2QiavAeVG9i1TdFJQh7J2DwZOrVti1MlezMReoQp2MsH+F7q9oQO2C/0/4jdTI5wj lDSqP8W4MjfYcnBRZ18Y1eSrYYs2D+39ZpdgGRqVPZkuKncvKyin3zILQoAFJvoIROcS 4pKqb6TlrYPfTQZ0M4nvTHy0FqJoeGY8UdTHegk+rr2YYJtYtMGALLZzGSgBwqLeCj5E 2UHDqyi0oc4Q3vJPRf9cE0za4mjyS1p2YDopvWp3JfWlrVCsw99G4hSWbQyhGTlc3BJV HY1Q== X-Gm-Message-State: AOAM531OtM3fGPUyRZo9SleFegp5/oI1QmF9qPm70ffiJ9HKIpNu42Ng ILyh6kSAY+pMTBm8VajNytP8rub55jP8VfuRjvdBaucYhOWb X-Google-Smtp-Source: ABdhPJz7mj17MBSURQBMv5KS03Lt3OtdtOLBNNjQvilwwvX1G4E5QRCMfbqyg7nZk+NKYsCvDasVLq+D+43TBGEvxDXjyrRQdLdK MIME-Version: 1.0 X-Received: by 2002:a6b:da0d:: with SMTP id x13mr13949462iob.138.1596401179576; Sun, 02 Aug 2020 13:46:19 -0700 (PDT) Date: Sun, 02 Aug 2020 13:46:19 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000003a51d705abeb1d74@google.com> Subject: KMSAN: uninit-value in process_adv_report From: syzbot <syzbot+e4244d85e5b777ac4d3d@syzkaller.appspotmail.com> To: davem@davemloft.net, glider@google.com, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@armlinux.org.uk, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.40 / 15.00 / 200.00 X-Rspamd-Queue-Id: 27DA3A1965 X-Rspamd-UID: f9d17b Hello, syzbot found the following issue on: HEAD commit: 93f54a72 instrumented.h: fix KMSAN support git tree: https://github.com/google/kmsan.git master console output: https://syzkaller.appspot.com/x/log.txt?x=13238a42900000 kernel config: https://syzkaller.appspot.com/x/.config?x=fa4f3b91169c2501 dashboard link: https://syzkaller.appspot.com/bug?extid=e4244d85e5b777ac4d3d compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) userspace arch: i386 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=108830ec900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12f9336c900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+e4244d85e5b777ac4d3d@syzkaller.appspotmail.com Bluetooth: hci0: unknown advertising packet type: 0x2b ===================================================== BUG: KMSAN: uninit-value in hci_bdaddr_is_rpa include/net/bluetooth/hci_core.h:1486 [inline] BUG: KMSAN: uninit-value in process_adv_report+0x781/0x2000 net/bluetooth/hci_event.c:5409 CPU: 0 PID: 2202 Comm: kworker/u5:0 Not tainted 5.8.0-rc5-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1df/0x240 lib/dump_stack.c:118 kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:121 __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:215 hci_bdaddr_is_rpa include/net/bluetooth/hci_core.h:1486 [inline] process_adv_report+0x781/0x2000 net/bluetooth/hci_event.c:5409 hci_le_direct_adv_report_evt net/bluetooth/hci_event.c:5837 [inline] hci_le_meta_evt net/bluetooth/hci_event.c:5902 [inline] hci_event_packet+0x1d08/0x33ee0 net/bluetooth/hci_event.c:6155 hci_rx_work+0x95f/0xce0 net/bluetooth/hci_core.c:4705 process_one_work+0x1540/0x1f30 kernel/workqueue.c:2269 worker_thread+0xed2/0x23f0 kernel/workqueue.c:2415 kthread+0x515/0x550 kernel/kthread.c:292 ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:293 Uninit was created at: kmsan_save_stack_with_flags mm/kmsan/kmsan.c:144 [inline] kmsan_internal_poison_shadow+0x66/0xd0 mm/kmsan/kmsan.c:127 kmsan_slab_alloc+0x8a/0xe0 mm/kmsan/kmsan_hooks.c:80 slab_alloc_node mm/slub.c:2839 [inline] __kmalloc_node_track_caller+0xb40/0x1200 mm/slub.c:4478 __kmalloc_reserve net/core/skbuff.c:142 [inline] __alloc_skb+0x2fd/0xac0 net/core/skbuff.c:210 alloc_skb include/linux/skbuff.h:1083 [inline] bt_skb_alloc include/net/bluetooth/bluetooth.h:377 [inline] vhci_get_user drivers/bluetooth/hci_vhci.c:165 [inline] vhci_write+0x15b/0x800 drivers/bluetooth/hci_vhci.c:285 call_write_iter include/linux/fs.h:1908 [inline] new_sync_write fs/read_write.c:503 [inline] vfs_write+0xd98/0x1480 fs/read_write.c:578 ksys_write+0x267/0x450 fs/read_write.c:631 __do_sys_write fs/read_write.c:643 [inline] __se_sys_write+0x92/0xb0 fs/read_write.c:640 __ia32_sys_write+0x4a/0x70 fs/read_write.c:640 do_syscall_32_irqs_on arch/x86/entry/common.c:430 [inline] __do_fast_syscall_32+0x2aa/0x400 arch/x86/entry/common.c:477 do_fast_syscall_32+0x6b/0xd0 arch/x86/entry/common.c:505 do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:554 entry_SYSENTER_compat_after_hwframe+0x4d/0x5c ===================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qKe2OuQxJ18VRQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 02 Aug 2020 23:36:36 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2BZBOeQxJ1+RwwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 02 Aug 2020 23:36:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B2CDDA19E1; Sun, 2 Aug 2020 23:36:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727893AbgHBVgW (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 17:36:22 -0400 Received: from mail-il1-f199.google.com ([209.85.166.199]:35265 "EHLO mail-il1-f199.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726163AbgHBVgV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 17:36:21 -0400 Received: by mail-il1-f199.google.com with SMTP id g6so11166177iln.2 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 14:36:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=jE1eXr0aFrBGEBZ/GquO7bRsGe66Rk2RCOW4RqQ0FHw=; b=bizqgwKgdKPMB9UnjLHxAOAGfcmuTz9S8lIm9+JOccZIZOZkR8WMVCNNevwCIUd0FD W5vQUVBJhH6AeHdwjaZYpZaSBLcQlfLjhQ91tnbTpQLv9OCZ+EiYFRe/7ObM56ie4nch jEGyMdKh79K1B/q3ZcFRYazAeddi951yk2vm8JkjzDflFfnCQ31gVMhA56O2Ru+biMx6 I+4yJRZGOqABVeZZq0mYTMHxCc8AKgvd33zy1nTufprgrXvZz38WwNC0xBmGC51+j+GE 4KFX2RlUCltIGpd1q0I+WdcM5JbHwJxljntyg5pGnUiO2Z4BDNlYLSXgdUK559lepQEK HUYQ== X-Gm-Message-State: AOAM531Oo/JLXNnfji5S2MQJDIta7zbMquhBo7mYuG4YiT0jHAl2phnz iYYHERBVGQqFxXMI2G8fQRVFPxPHBBUGdnQQluEqa7Iiqs5G X-Google-Smtp-Source: ABdhPJxZzGmFuPg5FmbI2K9VWsx3CzEkSHK5VQYK7Ervj4iVi+5O0dnvvtMgJPr1SY0otVqLq14WPCR2aFZrHo32bi4SmirZ3ajk MIME-Version: 1.0 X-Received: by 2002:a92:c7a1:: with SMTP id f1mr5341536ilk.162.1596404180792; Sun, 02 Aug 2020 14:36:20 -0700 (PDT) Date: Sun, 02 Aug 2020 14:36:20 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000001d48cd05abebd088@google.com> Subject: WARNING: ODEBUG bug in bt_host_release From: syzbot <syzbot+0ce8a29c6c6469b16632@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: B2CDDA19E1 X-Rspamd-UID: 630992 Hello, syzbot found the following issue on: HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=11e1da92900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=0ce8a29c6c6469b16632 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14f653ca900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+0ce8a29c6c6469b16632@syzkaller.appspotmail.com ------------[ cut here ]------------ ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x80 arch/x86/include/asm/paravirt.h:770 WARNING: CPU: 1 PID: 20314 at lib/debugobjects.c:488 debug_print_object lib/debugobjects.c:485 [inline] WARNING: CPU: 1 PID: 20314 at lib/debugobjects.c:488 __debug_check_no_obj_freed lib/debugobjects.c:967 [inline] WARNING: CPU: 1 PID: 20314 at lib/debugobjects.c:488 debug_check_no_obj_freed+0x45c/0x640 lib/debugobjects.c:998 Kernel panic - not syncing: panic_on_warn set ... CPU: 1 PID: 20314 Comm: syz-executor.5 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 panic+0x264/0x7a0 kernel/panic.c:231 __warn+0x227/0x250 kernel/panic.c:600 report_bug+0x1b1/0x2e0 lib/bug.c:198 handle_bug+0x42/0x80 arch/x86/kernel/traps.c:235 exc_invalid_op+0x16/0x40 arch/x86/kernel/traps.c:255 asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:540 RIP: 0010:debug_print_object lib/debugobjects.c:485 [inline] RIP: 0010:__debug_check_no_obj_freed lib/debugobjects.c:967 [inline] RIP: 0010:debug_check_no_obj_freed+0x45c/0x640 lib/debugobjects.c:998 Code: 74 08 4c 89 f7 e8 04 e4 11 fe 4d 8b 06 48 c7 c7 ef b7 14 89 48 c7 c6 fd 95 12 89 48 89 da 89 e9 4d 89 f9 31 c0 e8 64 95 a4 fd <0f> 0b 48 ba 00 00 00 00 00 fc ff df ff 05 86 c1 eb 05 48 8b 5c 24 RSP: 0018:ffffc90003777b90 EFLAGS: 00010046 RAX: ffd2d42dae8b6000 RBX: ffffffff8918b660 RCX: ffff888087ef6000 RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: ffffffff815dd389 R09: ffffed1015d241c3 R10: ffffed1015d241c3 R11: 0000000000000000 R12: ffff8880a131c9ec R13: ffffffff8ba5dfb8 R14: ffffffff894edb20 R15: ffffffff814c4b60 kfree+0xfc/0x220 mm/slab.c:3756 bt_host_release+0x18/0x20 net/bluetooth/hci_sysfs.c:86 device_release+0x70/0x1a0 drivers/base/core.c:1575 kobject_cleanup lib/kobject.c:693 [inline] kobject_release lib/kobject.c:722 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x15b/0x220 lib/kobject.c:739 vhci_release+0x7b/0xc0 drivers/bluetooth/hci_vhci.c:341 __fput+0x2f0/0x750 fs/file_table.c:281 task_work_run+0x137/0x1c0 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0x601/0x1f80 kernel/exit.c:805 do_group_exit+0x161/0x2d0 kernel/exit.c:903 __do_sys_exit_group+0x13/0x20 kernel/exit.c:914 __se_sys_exit_group+0x10/0x10 kernel/exit.c:912 __x64_sys_exit_group+0x37/0x40 kernel/exit.c:912 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x45cc79 Code: Bad RIP value. RSP: 002b:00007ffe023458d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000045cc79 RDX: 00000000004166d1 RSI: 0000000000ca85f0 RDI: 0000000000000043 RBP: 00000000004c2903 R08: 000000000000000b R09: 0000000000000000 R10: 000000000246f940 R11: 0000000000000246 R12: 0000000000000004 R13: 00007ffe02345a20 R14: 00000000000b206f R15: 00007ffe02345a30 Kernel Offset: disabled Rebooting in 86400 seconds.. --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eEYxHwtfJ1+mTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 02:49:15 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AOx4HQtfJ1+GSwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 02:49:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 804AFA112B; Mon, 3 Aug 2020 02:49:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726989AbgHCAtG (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 20:49:06 -0400 Received: from mail-io1-f71.google.com ([209.85.166.71]:40748 "EHLO mail-io1-f71.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727087AbgHCAtF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 20:49:05 -0400 Received: by mail-io1-f71.google.com with SMTP id t22so16249872iob.7 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 17:49:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=zjMjCpZHpZC9oX4mSp6lGsDleX+rgZUM4Hc+zQq53tE=; b=HvSx+YC+FJ6MkO7/aIP1b1m5IdfpPvf61McOYUIUj1pVsEVz7lFuIZNJJqGm7ScFap Ts19JkeyBCxVMXWWpiA2bx1w6LxQpaBrgGGcmS9k3an8JGzgqL0G5e72QMPgEyIbJn+K +/rby+M2QUD2XGJsxHOmfYgJkZlefcfn7LUIgJy2PfUu14XSQmj8kmPRIFgCe/nRFInL rhS9umkJZJip+v/X1Ic/9nFotrvZ+brJHqALQOTplZUJH0yJN/80NvHujcuYz4ubZ334 nzIP11N8NnxtNalYn/fSCP733MEg/jJss+FcQQTOIYhxGQX80rgxzoyUlW8m9tmL7M7S 02fw== X-Gm-Message-State: AOAM532vYDXdJ0Be3UsTYseBLZQQRdrBXeVPxmtFEJbtbHk4yuOOTfYm 5hINBb/h4FK9i+K59cgs+hstpJTV0LqxJypRR6ochcNOGmBJ X-Google-Smtp-Source: ABdhPJx51fMhfJaafxHzZAN2jjWSIrSl/b5CFIul4+GGQOi4s1mKok/hTo4u9c3s4cBgSHZ/wcwXjrq3H3VFwrd210mpw03EVfqe MIME-Version: 1.0 X-Received: by 2002:a05:6602:15d0:: with SMTP id f16mr168098iow.45.1596415744953; Sun, 02 Aug 2020 17:49:04 -0700 (PDT) Date: Sun, 02 Aug 2020 17:49:04 -0700 In-Reply-To: <000000000000ab11c505abeb19f5@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000064571305abee81ea@google.com> Subject: Re: KASAN: use-after-free Write in __sco_sock_close From: syzbot <syzbot+077eca30d3cb7c02b273@syzkaller.appspotmail.com> To: coreteam@netfilter.org, davem@davemloft.net, devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, johan.hedberg@gmail.com, kaber@trash.net, kadlec@blackhole.kfki.hu, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, marcel@holtmann.org, mchehab@kernel.org, mchehab@s-opensource.com, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, pablo@netfilter.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: 804AFA112B X-Rspamd-UID: dd14b4 syzbot has bisected this issue to: commit 43ea43b9d8b27b7acd443ec59319faa3cdb8a616 Author: Mauro Carvalho Chehab <mchehab@s-opensource.com> Date: Wed Oct 12 11:21:43 2016 +0000 [media] radio-bcm2048: don't ignore errors bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1036e6a4900000 start commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=1236e6a4900000 console output: https://syzkaller.appspot.com/x/log.txt?x=1436e6a4900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=077eca30d3cb7c02b273 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12cf1904900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10d52e14900000 Reported-by: syzbot+077eca30d3cb7c02b273@syzkaller.appspotmail.com Fixes: 43ea43b9d8b2 ("[media] radio-bcm2048: don't ignore errors") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KKVVCs18J1/HvgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 04:56:13 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qFILCc18J18yPgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 04:56:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 923B940676; Mon, 3 Aug 2020 04:56:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726998AbgHCC4D (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 2 Aug 2020 22:56:03 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:45734 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726963AbgHCC4D (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 2 Aug 2020 22:56:03 -0400 Received: from [114.252.213.24] (helo=[192.168.2.106]) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from <hui.wang@canonical.com>) id 1k2Qdt-0006Pd-Dl; Mon, 03 Aug 2020 02:56:01 +0000 Subject: Re: [PATCH] Bluetooth: btusb: Add a module parameter ignore_id for debugging To: Marcel Holtmann <marcel@holtmann.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Johan Hedberg <johan.hedberg@gmail.com> References: <20200802042138.9149-1-hui.wang@canonical.com> <432B3E10-052D-4DCB-84A4-B239D218D4E5@holtmann.org> From: Hui Wang <hui.wang@canonical.com> Message-ID: <8c625767-7211-2b41-7673-33e641c2924e@canonical.com> Date: Mon, 3 Aug 2020 10:55:54 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <432B3E10-052D-4DCB-84A4-B239D218D4E5@holtmann.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.86 / 15.00 / 200.00 X-Rspamd-Queue-Id: 923B940676 X-Rspamd-UID: ee0177 On 2020/8/2 下午10:58, Marcel Holtmann wrote: > Hi Hui, > >> There is always an on-board usb bluetooth hci on the laptops, if >> the bluetooth function doesn't work well like a bt headset can't work >> with HSP/HFP mode, we often plug an external usb BT hci to verify if >> that headset could work with the exteral BT hci or not, in this >> situation, there will be 2 hcis (hci0 and hci1) in the system, and >> so far, the gnome can't handle the hci1 well so we met lots of >> problems when debugging with hci1 under gnome. >> >> After adding this new module parameter, we could ban the on-board >> usb hci by putting btusb.ignore_id=idVendor,idProduct to the bootargs, >> then the external usb hci will be hci0 and there is only one hci >> in the system. We could easily debug with the external usb bluetooth >> hci after this change. >> >> Signed-off-by: Hui Wang <hui.wang@canonical.com> >> --- >> drivers/bluetooth/btusb.c | 11 +++++++++++ >> 1 file changed, 11 insertions(+) > please use this instead. > > echo “vvvv pppp 0 08fd 0002" > /sys/bus/usb/drivers/foo/new_id Thanks,  but to run the command above,  the system should boot up first.  After the system boot up, the btusb is already loaded and and the on-board hci is already driven by btusb. looks like it is too late to run that command for on-board hci. Thanks, Hui. > > Regards > > Marcel > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KJokDx+bJ19N8QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 07:05:35 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id GMN2DR+bJ1/ECgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 07:05:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 34E8AA2B7E; Mon, 3 Aug 2020 07:05:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727793AbgHCFF1 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 01:05:27 -0400 Received: from mail-il1-f200.google.com ([209.85.166.200]:53977 "EHLO mail-il1-f200.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727785AbgHCFF1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 01:05:27 -0400 Received: by mail-il1-f200.google.com with SMTP id v13so13548751ila.20 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 22:05:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=cut/OZHOZGCHhxupESbAJlID0VkFW48Y+FIVqKyDOXM=; b=VEDGrSyaed3vVGfMukZEawHpuWoE3Z/8xqgKfu8zAXc9bRNphPQ61AXDlIvFTqkXX7 NPYZyeJfv2NomVmvVChiNVxBOiqpgz8YCfywVTlPcH0wyYzTzeI1Hw1HgEpTc3oCSizr Gv4+7VgXTayw2n6Uzpi08e9FlWwYc13Qee2iU2uRkje23A7w5/XXHN82l6dT4EMukgnD nZAca72gh2vqUENcRULjwcx6HpuyJeO8OzLF3MtYcL9lqTvR5q9hpr7e6ajNCzIjG3RK vgvQIgnSamoapOFRyq7aexAILj5ameyywKEu64XoC8jbBPFYix5jWsEw3L/K63A1GghS RU2Q== X-Gm-Message-State: AOAM531MMQUmCA7qrfkwXhE2nybK7grc2tU0UzE7AGDxoB9VNR7mING8 0wEnVQuHAAroFEKXopGQaoVQyjQc7EC/jIhCRyRclLYsq6TM X-Google-Smtp-Source: ABdhPJzj+NuLSz9Bg0hONKimYPAD2PStxSb+qf4Bdn0pfCvEw28/rTFX9HIXaWA2c4Xzxf1YJosn9E179niQ4kkhXNqwAoHiskDt MIME-Version: 1.0 X-Received: by 2002:a92:aa01:: with SMTP id j1mr15351168ili.30.1596431126218; Sun, 02 Aug 2020 22:05:26 -0700 (PDT) Date: Sun, 02 Aug 2020 22:05:26 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000002fcce805abf21687@google.com> Subject: KASAN: use-after-free Write in sco_chan_del From: syzbot <syzbot+8f6017ee5c7fb9515782@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: 34E8AA2B7E X-Rspamd-UID: cb18ba Hello, syzbot found the following issue on: HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=11638a42900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 dashboard link: https://syzkaller.appspot.com/bug?extid=8f6017ee5c7fb9515782 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17fd776c900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15ac7014900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+8f6017ee5c7fb9515782@syzkaller.appspotmail.com ================================================================== BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:71 [inline] BUG: KASAN: use-after-free in atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline] BUG: KASAN: use-after-free in hci_conn_drop include/net/bluetooth/hci_core.h:1049 [inline] BUG: KASAN: use-after-free in sco_chan_del+0xe6/0x430 net/bluetooth/sco.c:148 Write of size 4 at addr ffff8880a03d8010 by task syz-executor104/6978 CPU: 1 PID: 6978 Comm: syz-executor104 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530 check_memory_region_inline mm/kasan/generic.c:186 [inline] check_memory_region+0x13d/0x180 mm/kasan/generic.c:192 instrument_atomic_write include/linux/instrumented.h:71 [inline] atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline] hci_conn_drop include/net/bluetooth/hci_core.h:1049 [inline] sco_chan_del+0xe6/0x430 net/bluetooth/sco.c:148 __sco_sock_close+0x16e/0x5b0 net/bluetooth/sco.c:433 sco_sock_close net/bluetooth/sco.c:447 [inline] sco_sock_release+0x69/0x290 net/bluetooth/sco.c:1021 __sock_release+0xcd/0x280 net/socket.c:605 sock_close+0x18/0x20 net/socket.c:1278 __fput+0x33c/0x880 fs/file_table.c:281 task_work_run+0xdd/0x190 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0xb72/0x2a40 kernel/exit.c:805 do_group_exit+0x125/0x310 kernel/exit.c:903 get_signal+0x40b/0x1ee0 kernel/signal.c:2743 do_signal+0x82/0x2520 arch/x86/kernel/signal.c:810 exit_to_usermode_loop arch/x86/entry/common.c:235 [inline] __prepare_exit_to_usermode+0x156/0x1f0 arch/x86/entry/common.c:269 do_syscall_64+0x6c/0xe0 arch/x86/entry/common.c:393 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x446e69 Code: Bad RIP value. RSP: 002b:00007fff15a45008 EFLAGS: 00000246 ORIG_RAX: 000000000000002a RAX: fffffffffffffffc RBX: 0000000000000000 RCX: 0000000000446e69 RDX: 0000000000000008 RSI: 0000000020000000 RDI: 0000000000000004 RBP: 0000000000000004 R08: 0000000000000002 R09: 00000003000100ff R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000407ac0 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 6978: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494 kmem_cache_alloc_trace+0x14f/0x2d0 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] hci_conn_add+0x53/0x1340 net/bluetooth/hci_conn.c:525 hci_connect_sco+0x350/0x860 net/bluetooth/hci_conn.c:1279 sco_connect net/bluetooth/sco.c:240 [inline] sco_sock_connect+0x308/0x980 net/bluetooth/sco.c:576 __sys_connect_file+0x155/0x1a0 net/socket.c:1854 __sys_connect+0x160/0x190 net/socket.c:1871 __do_sys_connect net/socket.c:1882 [inline] __se_sys_connect net/socket.c:1879 [inline] __x64_sys_connect+0x6f/0xb0 net/socket.c:1879 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 6972: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x103/0x2c0 mm/slab.c:3757 device_release+0x71/0x200 drivers/base/core.c:1579 kobject_cleanup lib/kobject.c:693 [inline] kobject_release lib/kobject.c:722 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x1c0/0x270 lib/kobject.c:739 put_device+0x1b/0x30 drivers/base/core.c:2799 hci_conn_del+0x27e/0x6a0 net/bluetooth/hci_conn.c:645 hci_phy_link_complete_evt.isra.0+0x508/0x790 net/bluetooth/hci_event.c:4921 hci_event_packet+0x481a/0x86f5 net/bluetooth/hci_event.c:6180 hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 The buggy address belongs to the object at ffff8880a03d8000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 16 bytes inside of 4096-byte region [ffff8880a03d8000, ffff8880a03d9000) The buggy address belongs to the page: page:ffffea000280f600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea000280f600 order:1 compound_mapcount:0 flags: 0xfffe0000010200(slab|head) raw: 00fffe0000010200 ffffea0002882888 ffffea00027ede08 ffff8880aa002000 raw: 0000000000000000 ffff8880a03d8000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880a03d7f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc ffff8880a03d7f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff8880a03d8000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880a03d8080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880a03d8100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oET+K6ayJ187nAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 08:45:58 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YIkjKqayJ18CawAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 08:45:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BF6D7A1A7B; Mon, 3 Aug 2020 08:45:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727788AbgHCGpw convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 02:45:52 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:55431 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725965AbgHCGpw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 02:45:52 -0400 Received: from marcel-macpro.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 9AFA7CED39; Mon, 3 Aug 2020 08:55:53 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Bluetooth: btusb: Add a module parameter ignore_id for debugging From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <8c625767-7211-2b41-7673-33e641c2924e@canonical.com> Date: Mon, 3 Aug 2020 08:45:50 +0200 Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Johan Hedberg <johan.hedberg@gmail.com> Content-Transfer-Encoding: 8BIT Message-Id: <636EB5CB-7A63-4C3B-A053-D59EA73FF1F2@holtmann.org> References: <20200802042138.9149-1-hui.wang@canonical.com> <432B3E10-052D-4DCB-84A4-B239D218D4E5@holtmann.org> <8c625767-7211-2b41-7673-33e641c2924e@canonical.com> To: Hui Wang <hui.wang@canonical.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: 0.12 / 15.00 / 200.00 X-Rspamd-Queue-Id: BF6D7A1A7B X-Rspamd-UID: 32bed0 Hi Hui, >>> There is always an on-board usb bluetooth hci on the laptops, if >>> the bluetooth function doesn't work well like a bt headset can't work >>> with HSP/HFP mode, we often plug an external usb BT hci to verify if >>> that headset could work with the exteral BT hci or not, in this >>> situation, there will be 2 hcis (hci0 and hci1) in the system, and >>> so far, the gnome can't handle the hci1 well so we met lots of >>> problems when debugging with hci1 under gnome. >>> >>> After adding this new module parameter, we could ban the on-board >>> usb hci by putting btusb.ignore_id=idVendor,idProduct to the bootargs, >>> then the external usb hci will be hci0 and there is only one hci >>> in the system. We could easily debug with the external usb bluetooth >>> hci after this change. >>> >>> Signed-off-by: Hui Wang <hui.wang@canonical.com> >>> --- >>> drivers/bluetooth/btusb.c | 11 +++++++++++ >>> 1 file changed, 11 insertions(+) >> please use this instead. >> >> echo “vvvv pppp 0 08fd 0002" > /sys/bus/usb/drivers/foo/new_id > > Thanks, but to run the command above, the system should boot up first. After the system boot up, the btusb is already loaded and and the on-board hci is already driven by btusb. looks like it is too late to run that command for on-board hci. then unload the module first or blacklist the module. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iHWKCT20J1/4lQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 08:52:45 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SP/iBz20J19UdgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 08:52:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9A7E2A1751; Mon, 3 Aug 2020 08:52:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726721AbgHCGwh (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 02:52:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbgHCGwg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 02:52:36 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9007C06174A for <linux-bluetooth@vger.kernel.org>; Sun, 2 Aug 2020 23:52:36 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id e22so25714828pgl.6 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 23:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=NvpgW09Qx9kcQUivEiNanw9jEQfujYcYKP6nVpJ353A=; b=XXOTl8OVI1+ObfPXab+XUFupwBKbeDdy/48x+KRGrapuXx49C5vJr5CDfL05I6bHk0 e/W1fgQi2BMTskBTfTw6xY2NsLMAb0To14p/KgVEca76B3xuzRtVYUnFyOXDcwwhRii5 wAr7CUcfxW7v4i6GbkC+HL/RYMbUY/ZRuo1GQUMh/vTO6e2AUfSEmzH5PCJFRQ23kJGR 1f4NRv5nubH1wHAV0eoLRedY/JSX9GMQi68SXYaVerKshrUsOKkB98TLG+x2LXWcvS6D ECw4v36Lfvw9Z8HF+QZ46yLZLdTW/cNBzx5HzhU5qdJDb2lp42dNMREOY1+u4KpspN52 hUXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=NvpgW09Qx9kcQUivEiNanw9jEQfujYcYKP6nVpJ353A=; b=HvtkGHeXjMim2OABrpdtp5sxmHPE7dB4VNY8N5FpYf6W2ht4cNDBYMkNVVwDtbwK1J bZHQaDLTgjx+VsivHwwvtAOVRN57eW2PKtu8X0WgrhKO62sUz3lda6fW7FeEw31oKogn UOWetuxycUl7iX94cmL2MvOZ1/rNWzVv1lbNfFQcsRwJP5yrcM54933Z3YmhzOugRQ6L 9IbzWIdaAt1Fy2DNhjP6BxIdsvgbG/3DvowneV9NhWME9F78xxSVIk664ZM/zV2XQ+UO LPz/eD50P+8g8aZWHd407+ibRswkunMrRKAqz6IPM2PA0zuxIcphtX/kTzGa5ozCMLvi UFJA== X-Gm-Message-State: AOAM530hUIMzS3VKCSRkZS6n/cMEhRtrJbCP842PoIwZGWYo6jyKkdPL H0XBaIFBdECIgcLqPk/WMuJgWx6aqzCZ9plYz5c7T//WcsTpZ+raFPWcqdLhg9cJMBLQLFbDL3z PhBxd+WulwxwhOLEYsWoYwnTg05+PU0xQRcDC6I0dI54KXs6tmJlTsSLA6bhJSd2yoWv0OhgBWK HA X-Google-Smtp-Source: ABdhPJy+4K+dCNl8KB2HvqPEDgKNvPvKLUg1+IPvOn4PFUBGMEAS6V6claMBvCva82c1+OBu+OxRAKxn+Odh X-Received: by 2002:a62:3741:: with SMTP id e62mr14062269pfa.127.1596437555981; Sun, 02 Aug 2020 23:52:35 -0700 (PDT) Date: Mon, 3 Aug 2020 14:52:23 +0800 In-Reply-To: <20200803145200.Bluez.v2.1.Ibf5508171632eebb66a6cd0ed2fa87bfac078f74@changeid> Message-Id: <20200803145200.Bluez.v2.2.I90a7cdf110044e880cf5610972e93a0f47d6c9fd@changeid> Mime-Version: 1.0 References: <20200803145200.Bluez.v2.1.Ibf5508171632eebb66a6cd0ed2fa87bfac078f74@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [Bluez PATCH v2 2/3] input/device: Implement handle for UHID_SET_REPORT From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9A7E2A1751 X-Rspamd-UID: 2950b4 From: Archie Pusaka <apusaka@chromium.org> This patch listens to UHID_SET_REPORT event and forwards this message to the hid device. Upon reply, we also send a report back to the kernel as UHID_SET_REPORT_REPLY. hidp_send_set_report no longer listen UHID_OUTPUT events, that is handled by hidp_send_output instead. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Changes in v2: -Split into three patches, now this only handles UHID_SET_REPORT profiles/input/device.c | 100 ++++++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 24 deletions(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index ac4487f63..757290080 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -258,6 +258,29 @@ static bool uhid_send_get_report_reply(struct input_device *idev, return true; } +static bool uhid_send_set_report_reply(struct input_device *idev, + uint32_t id, uint16_t err) +{ + struct uhid_event ev; + int ret; + + if (!idev->uhid_created) + return false; + + memset(&ev, 0, sizeof(ev)); + ev.type = UHID_SET_REPORT_REPLY; + ev.u.set_report_reply.id = id; + ev.u.set_report_reply.err = err; + + ret = bt_uhid_send(idev->uhid, &ev); + if (ret < 0) { + error("bt_uhid_send: %s (%d)", strerror(-ret), -ret); + return false; + } + + return true; +} + static bool uhid_send_input_report(struct input_device *idev, const uint8_t *data, size_t size) { @@ -404,6 +427,8 @@ static void hidp_recv_ctrl_handshake(struct input_device *idev, uint8_t param) pending_req_complete = true; } else if (pending_req_type == HIDP_TRANS_SET_REPORT) { DBG("SET_REPORT failed (%u)", param); + uhid_send_set_report_reply(idev, idev->report_rsp_id, + EIO); pending_req_complete = true; } else DBG("Spurious HIDP_HSHK_ERR"); @@ -446,7 +471,8 @@ static void hidp_recv_ctrl_data(struct input_device *idev, uint8_t param, DBG(""); pending_req_type = idev->report_req_pending & HIDP_HEADER_TRANS_MASK; - if (pending_req_type != HIDP_TRANS_GET_REPORT) { + if (pending_req_type != HIDP_TRANS_GET_REPORT && + pending_req_type != HIDP_TRANS_SET_REPORT) { DBG("Spurious DATA on control channel"); return; } @@ -461,8 +487,12 @@ static void hidp_recv_ctrl_data(struct input_device *idev, uint8_t param, case HIDP_DATA_RTYPE_FEATURE: case HIDP_DATA_RTYPE_INPUT: case HIDP_DATA_RTYPE_OUTPUT: - uhid_send_get_report_reply(idev, data + 1, size - 1, + if (pending_req_type == HIDP_TRANS_GET_REPORT) + uhid_send_get_report_reply(idev, data + 1, size - 1, idev->report_rsp_id, 0); + else + uhid_send_set_report_reply(idev, idev->report_rsp_id, + 0); break; case HIDP_DATA_RTYPE_OTHER: @@ -579,9 +609,13 @@ static gboolean hidp_report_req_timeout(gpointer data) switch (pending_req_type) { case HIDP_TRANS_GET_REPORT: req_type_str = "GET_REPORT"; + uhid_send_get_report_reply(idev, NULL, 0, idev->report_rsp_id, + ETIMEDOUT); break; case HIDP_TRANS_SET_REPORT: req_type_str = "SET_REPORT"; + uhid_send_set_report_reply(idev, idev->report_rsp_id, + ETIMEDOUT); break; default: /* Should never happen */ @@ -598,6 +632,17 @@ static gboolean hidp_report_req_timeout(gpointer data) return FALSE; } +static void hidp_send_output(struct uhid_event *ev, void *user_data) +{ + struct input_device *idev = user_data; + uint8_t hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUTPUT; + + DBG(""); + + hidp_send_intr_message(idev, hdr, ev->u.output.data, + ev->u.output.size); +} + static void hidp_send_set_report(struct uhid_event *ev, void *user_data) { struct input_device *idev = user_data; @@ -606,34 +651,37 @@ static void hidp_send_set_report(struct uhid_event *ev, void *user_data) DBG(""); - switch (ev->u.output.rtype) { + switch (ev->u.set_report.rtype) { case UHID_FEATURE_REPORT: - /* Send SET_REPORT on control channel */ - if (idev->report_req_pending) { - DBG("Old GET_REPORT or SET_REPORT still pending"); - return; - } - hdr = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE; - sent = hidp_send_ctrl_message(idev, hdr, ev->u.output.data, - ev->u.output.size); - if (sent) { - idev->report_req_pending = hdr; - idev->report_req_timer = - g_timeout_add_seconds(REPORT_REQ_TIMEOUT, - hidp_report_req_timeout, idev); - } + break; + case UHID_INPUT_REPORT: + hdr = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_INPUT; break; case UHID_OUTPUT_REPORT: - /* Send DATA on interrupt channel */ - hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUTPUT; - hidp_send_intr_message(idev, hdr, ev->u.output.data, - ev->u.output.size); + hdr = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_OUTPUT; break; default: - DBG("Unsupported HID report type %u", ev->u.output.rtype); + DBG("Unsupported HID report type %u", ev->u.set_report.rtype); + return; + } + + if (idev->report_req_pending) { + DBG("Old GET_REPORT or SET_REPORT still pending"); + uhid_send_set_report_reply(idev, ev->u.set_report.id, EBUSY); return; } + + sent = hidp_send_ctrl_message(idev, hdr, ev->u.set_report.data, + ev->u.set_report.size); + if (sent) { + idev->report_req_pending = hdr; + idev->report_req_timer = + g_timeout_add_seconds(REPORT_REQ_TIMEOUT, + hidp_report_req_timeout, idev); + idev->report_rsp_id = ev->u.set_report.id; + } else + uhid_send_set_report_reply(idev, ev->u.set_report.id, EIO); } static void hidp_send_get_report(struct uhid_event *ev, void *user_data) @@ -675,7 +723,9 @@ static void hidp_send_get_report(struct uhid_event *ev, void *user_data) g_timeout_add_seconds(REPORT_REQ_TIMEOUT, hidp_report_req_timeout, idev); idev->report_rsp_id = ev->u.get_report.id; - } + } else + uhid_send_get_report_reply(idev, NULL, 0, ev->u.get_report.id, + EIO); } static void epox_endian_quirk(unsigned char *data, int size) @@ -908,9 +958,11 @@ static int uhid_connadd(struct input_device *idev, struct hidp_connadd_req *req) return err; } - bt_uhid_register(idev->uhid, UHID_OUTPUT, hidp_send_set_report, idev); + bt_uhid_register(idev->uhid, UHID_OUTPUT, hidp_send_output, idev); bt_uhid_register(idev->uhid, UHID_GET_REPORT, hidp_send_get_report, idev); + bt_uhid_register(idev->uhid, UHID_SET_REPORT, hidp_send_set_report, + idev); idev->uhid_created = true; -- 2.28.0.163.g6104cc2f0b6-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IIUoHje0J1/4lQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 08:52:39 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 0LJ0HDe0J1+5BAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 08:52:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D939DA1D91; Mon, 3 Aug 2020 08:52:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726373AbgHCGwd (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 02:52:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbgHCGwd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 02:52:33 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DF81C06174A for <linux-bluetooth@vger.kernel.org>; Sun, 2 Aug 2020 23:52:33 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id b127so29752123ybh.21 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 23:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=kvGLc9MoMctHddyD48jmqsqHTMBXm6uOmxj+kdRL0nk=; b=rhAHmpe+hMPJWKIWqshL8K8rQAnWp6jnNbozbsIfUvk29jQojR+OHtK8wm4gXmlf3S aFs/ySkdSJS5Eac/O8wp3SXMb30RvKEB7N1AQS6N2+KeSrBLzofUfvN6iepL6vtkuQye I1dDEVgCo7MjpDmsZYN+Ct7cl36Nhwk05NDphorzWADmg4TPPMCYI2xNE7wond0UywK7 SdWA7b4hsMMwDsQGQ43E3Z7w+Bg1yK0fVV+DZsuLsyH9zfjxf7mxTBzY05WQJwKkU86Q C6X5BR5VQb4UOmZTrVK6d8VP6ZnkmLkRX6nAnHP5GMDyfPUaX1ENWgqKykL9fPMvkylX 3cWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=kvGLc9MoMctHddyD48jmqsqHTMBXm6uOmxj+kdRL0nk=; b=gZth7kMlBOTfRabtRnAW47WkOfZfxO5cdnCPVuSF9odDO0o6dcUvtr/r7S6NK5wHIX BRAa3upEmd2gDUbndo4edID4MmdZ8PBzoiF/v+pMZ0rA6nMuaqhrQD3RpcHxwqFw/PcG WaODKs7S1sr+18hukJLpNAvt7OjE4f4XovlDFLpO+YNZAUpFdtj/QFefW5UWqzJzn7Mc Z1kKI3MyuIk8jr4x30lR5YvGlWFFc2ZYSQIHzB7b7VIn8OyVt9xE3fMav5KjX1mkNkP4 8JxS4yIgp7ZIg9iSUeNbZHkZqLul+g00egxLZtHxIAK8KU6SHuNZNFbDF2WkzfL5M+Yf j+fQ== X-Gm-Message-State: AOAM532Z49koVIYBBSwOZRzLL7ciwS3Oyz1hRZmmP3ubrc509EJRN0mA 3UDxtJXIUGPhpeHYB/GTNuNjr9pB8PwGWwMnTByTKSLSrKqpoxH37+cTOhifZWfIbzUFlTWYqQy GteqNgR5Qe9XwctxuAf+Tu0BMB+NnBjXvmYdyBE1q3zM3JzcErRCNZIPEQn6Lw2L0Vmw28JL8QF pW X-Google-Smtp-Source: ABdhPJx90jasNTt6/kbdQFWPhXuloV9ACsUp3X1TiGC70uhv9sRL/Y3PpsOc/hk9C8Mb+sZFXABzdUrsHdx0 X-Received: by 2002:a25:d98f:: with SMTP id q137mr21530834ybg.480.1596437552064; Sun, 02 Aug 2020 23:52:32 -0700 (PDT) Date: Mon, 3 Aug 2020 14:52:22 +0800 Message-Id: <20200803145200.Bluez.v2.1.Ibf5508171632eebb66a6cd0ed2fa87bfac078f74@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [Bluez PATCH v2 1/3] input/device: Replace UHID_FEATURE with UHID_GET_REPORT From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: D939DA1D91 X-Rspamd-UID: e45bad From: Archie Pusaka <apusaka@chromium.org> According to kernel's uhid.h, UHID_FEATURE is obsolete and is replaced with UHID_GET_REPORT. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Changes in v2: -Split into three patches, now this only handles UHID_GET_REPORT profiles/input/device.c | 41 +++++++++++++++++++------------------- profiles/input/hidp_defs.h | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index ee0b2404a..ac4487f63 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -220,7 +220,7 @@ static bool hidp_send_intr_message(struct input_device *idev, uint8_t hdr, return hidp_send_message(idev->intr_io, hdr, data, size); } -static bool uhid_send_feature_answer(struct input_device *idev, +static bool uhid_send_get_report_reply(struct input_device *idev, const uint8_t *data, size_t size, uint32_t id, uint16_t err) { @@ -230,8 +230,8 @@ static bool uhid_send_feature_answer(struct input_device *idev, if (data == NULL) size = 0; - if (size > sizeof(ev.u.feature_answer.data)) - size = sizeof(ev.u.feature_answer.data); + if (size > sizeof(ev.u.get_report_reply.data)) + size = sizeof(ev.u.get_report_reply.data); if (!idev->uhid_created) { DBG("HID report (%zu bytes) dropped", size); @@ -239,13 +239,13 @@ static bool uhid_send_feature_answer(struct input_device *idev, } memset(&ev, 0, sizeof(ev)); - ev.type = UHID_FEATURE_ANSWER; - ev.u.feature_answer.id = id; - ev.u.feature_answer.err = err; - ev.u.feature_answer.size = size; + ev.type = UHID_GET_REPORT_REPLY; + ev.u.get_report_reply.id = id; + ev.u.get_report_reply.err = err; + ev.u.get_report_reply.size = size; if (size > 0) - memcpy(ev.u.feature_answer.data, data, size); + memcpy(ev.u.get_report_reply.data, data, size); ret = bt_uhid_send(idev->uhid, &ev); if (ret < 0) { @@ -399,7 +399,7 @@ static void hidp_recv_ctrl_handshake(struct input_device *idev, uint8_t param) case HIDP_HSHK_ERR_FATAL: if (pending_req_type == HIDP_TRANS_GET_REPORT) { DBG("GET_REPORT failed (%u)", param); - uhid_send_feature_answer(idev, NULL, 0, + uhid_send_get_report_reply(idev, NULL, 0, idev->report_rsp_id, EIO); pending_req_complete = true; } else if (pending_req_type == HIDP_TRANS_SET_REPORT) { @@ -460,8 +460,8 @@ static void hidp_recv_ctrl_data(struct input_device *idev, uint8_t param, switch (param) { case HIDP_DATA_RTYPE_FEATURE: case HIDP_DATA_RTYPE_INPUT: - case HIDP_DATA_RTYPE_OUPUT: - uhid_send_feature_answer(idev, data + 1, size - 1, + case HIDP_DATA_RTYPE_OUTPUT: + uhid_send_get_report_reply(idev, data + 1, size - 1, idev->report_rsp_id, 0); break; @@ -626,7 +626,7 @@ static void hidp_send_set_report(struct uhid_event *ev, void *user_data) break; case UHID_OUTPUT_REPORT: /* Send DATA on interrupt channel */ - hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT; + hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUTPUT; hidp_send_intr_message(idev, hdr, ev->u.output.data, ev->u.output.size); break; @@ -646,13 +646,13 @@ static void hidp_send_get_report(struct uhid_event *ev, void *user_data) if (idev->report_req_pending) { DBG("Old GET_REPORT or SET_REPORT still pending"); - uhid_send_feature_answer(idev, NULL, 0, ev->u.feature.id, + uhid_send_get_report_reply(idev, NULL, 0, ev->u.get_report.id, EBUSY); return; } /* Send GET_REPORT on control channel */ - switch (ev->u.feature.rtype) { + switch (ev->u.get_report.rtype) { case UHID_FEATURE_REPORT: hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_FEATURE; break; @@ -660,21 +660,21 @@ static void hidp_send_get_report(struct uhid_event *ev, void *user_data) hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_INPUT; break; case UHID_OUTPUT_REPORT: - hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_OUPUT; + hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_OUTPUT; break; default: - DBG("Unsupported HID report type %u", ev->u.feature.rtype); + DBG("Unsupported HID report type %u", ev->u.get_report.rtype); return; } - sent = hidp_send_ctrl_message(idev, hdr, &ev->u.feature.rnum, - sizeof(ev->u.feature.rnum)); + sent = hidp_send_ctrl_message(idev, hdr, &ev->u.get_report.rnum, + sizeof(ev->u.get_report.rnum)); if (sent) { idev->report_req_pending = hdr; idev->report_req_timer = g_timeout_add_seconds(REPORT_REQ_TIMEOUT, hidp_report_req_timeout, idev); - idev->report_rsp_id = ev->u.feature.id; + idev->report_rsp_id = ev->u.get_report.id; } } @@ -909,7 +909,8 @@ static int uhid_connadd(struct input_device *idev, struct hidp_connadd_req *req) } bt_uhid_register(idev->uhid, UHID_OUTPUT, hidp_send_set_report, idev); - bt_uhid_register(idev->uhid, UHID_FEATURE, hidp_send_get_report, idev); + bt_uhid_register(idev->uhid, UHID_GET_REPORT, hidp_send_get_report, + idev); idev->uhid_created = true; diff --git a/profiles/input/hidp_defs.h b/profiles/input/hidp_defs.h index 5dc479acf..bb9231dbb 100644 --- a/profiles/input/hidp_defs.h +++ b/profiles/input/hidp_defs.h @@ -63,7 +63,7 @@ #define HIDP_DATA_RSRVD_MASK 0x0c #define HIDP_DATA_RTYPE_OTHER 0x00 #define HIDP_DATA_RTYPE_INPUT 0x01 -#define HIDP_DATA_RTYPE_OUPUT 0x02 +#define HIDP_DATA_RTYPE_OUTPUT 0x02 #define HIDP_DATA_RTYPE_FEATURE 0x03 /* HIDP protocol header parameters */ -- 2.28.0.163.g6104cc2f0b6-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4B7LK0K0J187nAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 08:52:50 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wDxCKkK0J1+SggAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 08:52:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4C304A1AA5; Mon, 3 Aug 2020 08:52:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726891AbgHCGwl (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 02:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726795AbgHCGwk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 02:52:40 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8AD9C06174A for <linux-bluetooth@vger.kernel.org>; Sun, 2 Aug 2020 23:52:40 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id u206so9764257ybb.8 for <linux-bluetooth@vger.kernel.org>; Sun, 02 Aug 2020 23:52:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=YTtUuJN3BP1ZpCkvg2WNDwIo42ZiWhldxD72P5cBZAI=; b=dbjD66GWcTIozlJ0va5aBohunDnmM5ZuTqmpFr6IKinn6M8lIdg972XnUGkPr27GQw nOHtvP6hX2mlHA9Hcf2nYf/RWvA8UFdQExBq6tZ2h+lfs7Qm1SRlaSFmVHqw2FlYAf3S Q7x4ZZi8rX9PRVsdOT7xrCoTnGuy3tY5at2vK8/sfzOCw3koNqNkGNwWIRH8pCjKcPYA LjVHlV2DVMawX0ONgu/itbK0B4G/OMj0ocrA9TXyDsGigOunaPFuPUPMDGeBIe/Ewp32 ZfSpfTnruR9HCTr0sFsbyVlp0pb2B7RbF9wuxcV1CcbBdx2aCL2TcRNPbeU/rUZY2x6+ DBTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=YTtUuJN3BP1ZpCkvg2WNDwIo42ZiWhldxD72P5cBZAI=; b=Mo1guZ0wXJJaQEj0s92cUkR18NPorFp1YT2DMhhtQiRYiV9kg62r12LjUL50Jo5ifO wOYIcswm1Nw5SilP8oK9424WPZePkXQyEHX7vik07ACXjJ53/3xdabYTSKuAAk3V3Ys+ Xg5Dz7Dd5CdMLpu4eGyxnm5VRasnnEMkw//2d1nYKUSLM6JnB3osjdF445qKYSjj7BL9 AnPbc0sgT6Nmj8v2J7fQpgODpApXzlZ8CAvT0sJ1ji2FkXql5kRhXhSN/f2JBlFW1gc6 dIcx7BSbEDvgRIo2YcdQSbXzuksN1o/THyS1L2R0QwAz1jbNo4VyhFBAant1+msAY1Jd 6e4Q== X-Gm-Message-State: AOAM532qXGc2SscIllY1RJ8qOO3KfGj0VSV7M+alHmjhUoF+JSRmUasq lTOC1EbRetl2zMKZaOXUlQuupavlC2ONmR9AisvNafKDdNMBiGNP3qU04f8LSJVjrdXaanOfNMx QKIeroVlfhWoksZaU9+XEdBEbEuc81nMUJLncZvrWoYSkqBi1bxT4fyGZJZb1ijWVHSyEeCPMfB h/ X-Google-Smtp-Source: ABdhPJxkpJpasGt6QYRGcIH6kxUv8QnEdEtNtPZ4J0ep/xhlcijzUYh5hiWjnepV5mf+ZZfUn6OmmdJWBtD5 X-Received: by 2002:a25:40cb:: with SMTP id n194mr23399710yba.380.1596437559750; Sun, 02 Aug 2020 23:52:39 -0700 (PDT) Date: Mon, 3 Aug 2020 14:52:24 +0800 In-Reply-To: <20200803145200.Bluez.v2.1.Ibf5508171632eebb66a6cd0ed2fa87bfac078f74@changeid> Message-Id: <20200803145200.Bluez.v2.3.Icf343eb0ccd09fc96a897594ca12dc1a44903126@changeid> Mime-Version: 1.0 References: <20200803145200.Bluez.v2.1.Ibf5508171632eebb66a6cd0ed2fa87bfac078f74@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [Bluez PATCH v2 3/3] input/device: Send UHID_DESTROY upon disconnection From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4C304A1AA5 X-Rspamd-UID: db55e2 From: Archie Pusaka <apusaka@chromium.org> According to the uhid documentation: "If your device disconnects, you should send an UHID_DESTROY event" Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Changes in v2: -Split into three patches, now this only handles UHID_DESTROY profiles/input/device.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index 757290080..8fc04be37 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -117,6 +117,7 @@ bool input_get_classic_bonded_only(void) static void input_device_enter_reconnect_mode(struct input_device *idev); static int connection_disconnect(struct input_device *idev, uint32_t flags); +static int uhid_disconnect(struct input_device *idev); static bool input_device_bonded(struct input_device *idev) { @@ -393,6 +394,10 @@ static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data if (!idev->ctrl_io && idev->virtual_cable_unplug) virtual_cable_unplug(idev); + /* If connection abruptly ended, uhid might be not yet disconnected */ + if (idev->uhid_created) + uhid_disconnect(idev); + return FALSE; } @@ -969,6 +974,28 @@ static int uhid_connadd(struct input_device *idev, struct hidp_connadd_req *req) return err; } +static int uhid_disconnect(struct input_device *idev) +{ + int err; + struct uhid_event ev; + + if (!idev->uhid_created) + return 0; + + memset(&ev, 0, sizeof(ev)); + ev.type = UHID_DESTROY; + + err = bt_uhid_send(idev->uhid, &ev); + if (err < 0) { + error("bt_uhid_send: %s", strerror(-err)); + return err; + } + + idev->uhid_created = false; + + return err; +} + static gboolean encrypt_notify(GIOChannel *io, GIOCondition condition, gpointer data) { @@ -1127,7 +1154,7 @@ static int connection_disconnect(struct input_device *idev, uint32_t flags) idev->virtual_cable_unplug = true; if (idev->uhid) - return 0; + return uhid_disconnect(idev); else return ioctl_disconnect(idev, flags); } -- 2.28.0.163.g6104cc2f0b6-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qK5rLunDJ184xwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 09:59:37 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id SPMALenDJ1+lmAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 09:59:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 46C1A417C0; Mon, 3 Aug 2020 09:59:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725867AbgHCH7b (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 03:59:31 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:56657 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbgHCH7b (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 03:59:31 -0400 Received: from [114.252.213.24] (helo=[192.168.0.104]) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from <hui.wang@canonical.com>) id 1k2VNY-0007Hb-Ae; Mon, 03 Aug 2020 07:59:28 +0000 Subject: Re: [PATCH] Bluetooth: btusb: Add a module parameter ignore_id for debugging To: Marcel Holtmann <marcel@holtmann.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Johan Hedberg <johan.hedberg@gmail.com> References: <20200802042138.9149-1-hui.wang@canonical.com> <432B3E10-052D-4DCB-84A4-B239D218D4E5@holtmann.org> <8c625767-7211-2b41-7673-33e641c2924e@canonical.com> <636EB5CB-7A63-4C3B-A053-D59EA73FF1F2@holtmann.org> From: Hui Wang <hui.wang@canonical.com> Message-ID: <301c3ace-fa24-85af-8913-c692d2dcd071@canonical.com> Date: Mon, 3 Aug 2020 15:59:16 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <636EB5CB-7A63-4C3B-A053-D59EA73FF1F2@holtmann.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.66 / 15.00 / 200.00 X-Rspamd-Queue-Id: 46C1A417C0 X-Rspamd-UID: 61fd2b On 2020/8/3 下午2:45, Marcel Holtmann wrote: > Hi Hui, > >>>> There is always an on-board usb bluetooth hci on the laptops, if >>>> the bluetooth function doesn't work well like a bt headset can't work >>>> with HSP/HFP mode, we often plug an external usb BT hci to verify if >>>> that headset could work with the exteral BT hci or not, in this >>>> situation, there will be 2 hcis (hci0 and hci1) in the system, and >>>> so far, the gnome can't handle the hci1 well so we met lots of >>>> problems when debugging with hci1 under gnome. >>>> >>>> After adding this new module parameter, we could ban the on-board >>>> usb hci by putting btusb.ignore_id=idVendor,idProduct to the bootargs, >>>> then the external usb hci will be hci0 and there is only one hci >>>> in the system. We could easily debug with the external usb bluetooth >>>> hci after this change. >>>> >>>> Signed-off-by: Hui Wang <hui.wang@canonical.com> >>>> --- >>>> drivers/bluetooth/btusb.c | 11 +++++++++++ >>>> 1 file changed, 11 insertions(+) >>> please use this instead. >>> >>> echo “vvvv pppp 0 08fd 0002" > /sys/bus/usb/drivers/foo/new_id >> Thanks, but to run the command above, the system should boot up first. After the system boot up, the btusb is already loaded and and the on-board hci is already driven by btusb. looks like it is too late to run that command for on-board hci. > then unload the module first or blacklist the module. Sorry,  still don't understand.  After unload/blacklist the module, there will be no /sys/bus/usb/drivers/foo/new_id. Once we load the module, the on-board hci will be driven by the module immediately. Looks like setting new_id is only useful for USB dongles, for on-board usb devices,  I have no idea how to use the new_id. Thanks, Hui. > > Regards > > Marcel > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uMWrCETFJ1+2BAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 10:05:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id QJ6sBkTFJ19WPwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 10:05:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9F440A19A1; Mon, 3 Aug 2020 10:05:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725905AbgHCIFR convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 04:05:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:57024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbgHCIFR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 04:05:17 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 03 Aug 2020 08:05:12 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aragmor@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-60824-62941-UauFKn7hVx@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.52 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9F440A19A1 X-Rspamd-UID: f15712 https://bugzilla.kernel.org/show_bug.cgi?id=60824 Aragmor (aragmor@gmail.com) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aragmor@gmail.com --- Comment #118 from Aragmor (aragmor@gmail.com) --- Tested with kernel 5.8.0-050800-generic x86_64 on Ubunutu 20.04 Works for bcdDevice 88.91 Broken for bcdDevice 25.20 is this patch included in newest kernel? lsusb -v log for 88.91 Bus 001 Device 013: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 224 Wireless bDeviceSubClass 1 Radio Frequency bDeviceProtocol 1 Bluetooth bMaxPacketSize0 64 idVendor 0x0a12 Cambridge Silicon Radio, Ltd idProduct 0x0001 Bluetooth Dongle (HCI mode) bcdDevice 88.91 iManufacturer 0 iProduct 2 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x00b1 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 1 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 2 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 3 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 4 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 5 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 lsusb -v log for 25.20 Bus 001 Device 012: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 224 Wireless bDeviceSubClass 1 Radio Frequency bDeviceProtocol 1 Bluetooth bMaxPacketSize0 64 idVendor 0x0a12 Cambridge Silicon Radio, Ltd idProduct 0x0001 Bluetooth Dongle (HCI mode) bcdDevice 25.20 iManufacturer 0 iProduct 2 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x00b1 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 1 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 2 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 3 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 4 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 5 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8B1+MljIJ19SRQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 10:18:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id uINDMFjIJ18IRwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 10:18:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EC5D5418AF; Mon, 3 Aug 2020 10:18:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726080AbgHCISW convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 04:18:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:59396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbgHCISW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 04:18:22 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 03 Aug 2020 08:18:19 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: swyterzone@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-AKOs8gTlur@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: EC5D5418AF X-Rspamd-UID: 0ace5c https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #119 from Swyter (swyterzone@gmail.com) --- By the way, guys. While knowing the bcdDevice/lsusb is interesting, the important part to narrow down these dongles is knowing their HCI version, HCI Revision, LMP version, LMP Subversion and Manufacturer fields. So please include some kind of `hciconfig -a` output or the 'Read Local Version Information' packet from your `btmon -w my.log` session that should show up at the start of your capture. That's what actually allows us to add specific workarounds. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QLX8OoPKJ1+WSQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 10:27:47 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aEpzOYPKJ19h0QAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 10:27:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F1AD5A2B7E; Mon, 3 Aug 2020 10:27:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726433AbgHCI1i convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 04:27:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:33924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726394AbgHCI1i (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 04:27:38 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 03 Aug 2020 08:27:35 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aragmor@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: <bug-60824-62941-XgUwby0zOI@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: F1AD5A2B7E X-Rspamd-UID: 19c44c https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #120 from Aragmor (aragmor@gmail.com) --- Created attachment 290729 --> https://bugzilla.kernel.org/attachment.cgi?id=290729&action=edit btmon -w for working bt dongle 4.0 hciconfig -a hci0: Type: Primary Bus: USB BD Address: 00:1A:7D:DA:71:11 ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING PSCAN ISCAN RX bytes:622 acl:0 sco:0 events:38 errors:0 TX bytes:952 acl:0 sco:0 commands:38 errors:0 Features: 0xff 0xff 0x8f 0xfe 0xdb 0xff 0x5b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT Name: 'ardom' Class: 0x1c0104 Service Classes: Rendering, Capturing, Object Transfer Device Class: Computer, Desktop workstation HCI Version: 4.0 (0x6) Revision: 0x22bb LMP Version: 4.0 (0x6) Subversion: 0x22bb Manufacturer: Cambridge Silicon Radio (10) -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AJd8N7bKJ1+WSQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 10:28:38 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MIezNbbKJ18JyAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 10:28:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 253C4A1C74; Mon, 3 Aug 2020 10:28:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725945AbgHCI2b convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 04:28:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:34152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbgHCI2b (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 04:28:31 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 03 Aug 2020 08:28:28 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aragmor@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: <bug-60824-62941-sz9EvAaFDU@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: 253C4A1C74 X-Rspamd-UID: 376b37 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #121 from Aragmor (aragmor@gmail.com) --- Created attachment 290731 --> https://bugzilla.kernel.org/attachment.cgi?id=290731&action=edit btmon -w for broken bt dongle 4.0 hciconfig -a hci0: Type: Primary Bus: USB BD Address: 00:1A:7D:DA:71:10 ACL MTU: 640:4 SCO MTU: 64:8 DOWN RX bytes:501 acl:0 sco:0 events:22 errors:0 TX bytes:326 acl:0 sco:0 commands:22 errors:1 Features: 0xff 0xff 0x8f 0xfa 0x9b 0xff 0x59 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GB5wHdjKJ1+WSQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 10:29:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id KFaOG9jKJ18uHQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 10:29:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 94AFAA2BA1; Mon, 3 Aug 2020 10:29:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726119AbgHCI3F convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 04:29:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:34442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbgHCI3F (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 04:29:05 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 03 Aug 2020 08:29:02 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aragmor@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: <bug-60824-62941-dQqzRNtWc7@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: 94AFAA2BA1 X-Rspamd-UID: 572a9a https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #122 from Aragmor (aragmor@gmail.com) --- Created attachment 290733 --> https://bugzilla.kernel.org/attachment.cgi?id=290733&action=edit btmon -w for broken bt dongle 5.0 hciconfig -a hci0: Type: Primary Bus: USB BD Address: 00:1A:7D:DA:71:10 ACL MTU: 640:4 SCO MTU: 64:8 DOWN RX bytes:501 acl:0 sco:0 events:22 errors:0 TX bytes:326 acl:0 sco:0 commands:22 errors:1 Features: 0xff 0xff 0x8f 0xfa 0x9b 0xff 0x59 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sEhhGUPPJ1+2BAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 10:48:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OATPF0PPJ1+A9wAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 10:48:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 802A040134; Mon, 3 Aug 2020 10:47:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725884AbgHCIr5 convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 04:47:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:37506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbgHCIr5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 04:47:57 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 03 Aug 2020 08:47:53 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: swyterzone@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-QElPAbm7j1@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 802A040134 X-Rspamd-UID: fe49f3 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #123 from Swyter (swyterzone@gmail.com) --- Looks like the last two are fake CSR (i.e. the interesting ones), but because they don't initialize properly we can't actually see HCI/LMP/Manufacturer stuff we are interested in. Sounds like a packet capture is the only way of finding these values. So please use `btmon -w my.log` (or alternatively `hcidump -X`) to capture the Bluetooth traffic as shown in previous comments. The good thing is that they should get stuck early on, so I don't expect a lot of traffic once you plug that in. Search for 'Read Local Version Information' in this thread to see examples. So yeah, if possible, please include the bcdDevice + hciconfig -a + 'Read Local Version Information' packet in your tests. The bigger the corpus of counterfeit dongles, the more we can extrapolate and make better workarounds that work for everyone. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gGaAL9zSJ1/ghQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 11:03:24 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 0NuZLdzSJ1+EgQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 11:03:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 60E71418B7; Mon, 3 Aug 2020 11:03:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726230AbgHCJDR convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 05:03:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:41940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbgHCJDR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 05:03:17 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 03 Aug 2020 09:03:14 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aragmor@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: <bug-60824-62941-KtteTWpWVc@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: 60E71418B7 X-Rspamd-UID: 0f123c https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #124 from Aragmor (aragmor@gmail.com) --- Created attachment 290735 --> https://bugzilla.kernel.org/attachment.cgi?id=290735&action=edit 'hcidump -X' while executing 'hciconfig hci0 up' -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UIctDwjUJ1/ghQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 11:08:24 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cCmpDQjUJ19h0QAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 11:08:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 66AD6A2BA1; Mon, 3 Aug 2020 11:08:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725971AbgHCJIR convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 05:08:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:46264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbgHCJIR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 05:08:17 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 03 Aug 2020 09:08:14 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aragmor@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: <bug-60824-62941-eE1F0GcvWG@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: 66AD6A2BA1 X-Rspamd-UID: 3a04fe https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #125 from Aragmor (aragmor@gmail.com) --- Created attachment 290737 --> https://bugzilla.kernel.org/attachment.cgi?id=290737&action=edit `btmon -w` while executing `hciconfig hci0 up` for fake BT dongle 4.0 -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yAKaOxbUJ1+KogEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 11:08:38 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id kGSzORbUJ19aBQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 11:08:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3F441A1D91; Mon, 3 Aug 2020 11:08:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726080AbgHCJIc convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 05:08:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:46588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbgHCJIc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 05:08:32 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 03 Aug 2020 09:08:29 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aragmor@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: <bug-60824-62941-xbkQXT3wgl@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3F441A1D91 X-Rspamd-UID: 2fee49 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #126 from Aragmor (aragmor@gmail.com) --- Created attachment 290739 --> https://bugzilla.kernel.org/attachment.cgi?id=290739&action=edit `btmon -w` while executing `hciconfig hci0 up` for fake BT dongle 5.0 -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wMbBEZTYJ1/ghQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 11:27:48 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iFsREJTYJ18AlQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 11:27:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 22BE9A0D27; Mon, 3 Aug 2020 11:27:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726011AbgHCJ1m (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 05:27:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725945AbgHCJ1m (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 05:27:42 -0400 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4830CC06174A for <linux-bluetooth@vger.kernel.org>; Mon, 3 Aug 2020 02:27:42 -0700 (PDT) Received: by mail-ot1-x332.google.com with SMTP id e11so3229418otk.4 for <linux-bluetooth@vger.kernel.org>; Mon, 03 Aug 2020 02:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=xZua3WLGIsLHsuGx6nc6hFbCI7jWaIIkx7pcm6vifGI=; b=UWnSzNM2Z0VZpZJAPTye3jDsDPF7YuFb3z1pmwmNPBXbEvO7gN0lFIGKmuqo3KQSub DkpRRjmd7RngiQ2dbc2luJt2LiopPeGjmV2FETVgg6tu0W9NuiLrQ0KiLiv2vw42O9R6 PB05ie8rZLH2WTsfgcExRuw8BfdOZ4tzq+SjfcSlL/73sZKhjv1qAlmdocicKS0M77BM Uywo5sdoYYdtO+tRnymlY6kBe/wf+a3bVxfKM/zkwj76J1g0viWrno/NxtmPq9bujU1X 8ixlcMuw+bh4QOi8cdae68GTk6dB7LZLLaEJ9Saw5ISRf5oLxhXQlpEKAoSDj4SZXufu XW1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=xZua3WLGIsLHsuGx6nc6hFbCI7jWaIIkx7pcm6vifGI=; b=dPa7NDfgdL6yAwialviaGHWW09/6qilr2nHrhzHemi0Tiabl8JcktBcPxLnMclrBvP rbGXWVQyNB3KJIEfqlqYH9i00iS/uB8SMA2dx6d2jPzyPiJ7zbI2XNd+bUNjO5hQp9ta RgM4i0UCAYxJ7LK+Tf9MZ8YBG9SJ3mL4gdItNFe2V6dggM5iIgtZjfsEMpKSqPiXZI97 lmtT7or1HhIDX8U6KQNuN6ATmtgF+ysyWRtOXOqrCfWGnvLs19I4rqEPh3lQDCU1akth IYYK0sy0YrRtB3zHSdXFQIDSLWrboZfipzYPwyuxxndJrr1u8MyluxXTNGBkSh65R8US UGhw== X-Gm-Message-State: AOAM530H/AhXDu4n0D3EuaKBt4y1OZJWjzyOSLsA4fI7S8x+HMhc0fTw OLl5MH2qmvS8S7YFN3e4nFCNn9rGFCV5DJaOvMFXAuE= X-Google-Smtp-Source: ABdhPJwa2XIgb0WXt7OlAfF4pnzJAJlpJJsQKIkvzecKWab+Yxgs1i/xp41vpghdj5w1r42sJQPjuY6sXfyykqg7NPA= X-Received: by 2002:a05:6830:4d9:: with SMTP id s25mr13287236otd.153.1596446861239; Mon, 03 Aug 2020 02:27:41 -0700 (PDT) MIME-Version: 1.0 From: Click2 work <clicktowork2@gmail.com> Date: Mon, 3 Aug 2020 14:57:30 +0530 Message-ID: <CAPWCbyVpt6vzgrK+wZ5POtD6kORFASg5gY1A9ddnpOPBaGNk8w@mail.gmail.com> Subject: BlueZ Features To: linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: 22BE9A0D27 X-Rspamd-UID: 77d53b Hi , I am nubie to BlueZ , so please bear with me if my questions sounds dumb. I have some queries regarding the Bluez stack and I don't know where exactly I can post the questions. Can you please help me with this?.Basically my queries are listed below. 1) Does BlueZ support the latest BT 5.2/5.1/5.0 features? 2) What is the maximum BT specification BlueZ support? 3)What are the changes needed if we want to support the latest BT features? Please let me know where I can get this information?. Looking forward to hearing from you. Regards, Sri. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UIGeJggnKF8a2AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 17:02:32 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WDVxJAgnKF9fTgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 17:02:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=mnmoran.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 31ACB418AB; Mon, 3 Aug 2020 17:02:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728000AbgHCOG7 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 10:06:59 -0400 Received: from hoster906.com ([192.252.156.27]:49114 "EHLO hoster906.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726785AbgHCOG6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 10:06:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mnmoran.org; h=from :subject:to:message-id:date:mime-version:content-type :content-transfer-encoding; s=dkim; bh=yXHqsbOynObuzhrZ2pPJ22ivg 7HdNterhdvigB2i2yY=; b=m1eMr8lvvTYrhdnxIUvMMzRly9OvBMDNRCDdDwIz/ OIrnPRFrFu+QIrE+2E9Xi8F8xdwZflLHvr95pfOyPVaZdyyLAInppP9eHqejC4/d HOeuJcsWefLfyjwXPIn1PQEMn9G6GLH9GIbJQiLI/uTGdVb4vAGlqIAiaUSSJryb kg= Received: (qmail 31989 invoked by uid 503); 3 Aug 2020 14:06:57 -0000 Received: from unknown (HELO ?192.168.254.79?) (pop-before-smtp@162.39.210.203) by hoster906.com with ESMTPA; 3 Aug 2020 14:06:57 -0000 From: "Michael N. Moran" <mike@mnmoran.org> Subject: [PATCH BlueZ v2 0/1] mesh: Add strings for SIG Model IDs To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Message-ID: <ede1e2f7-e6eb-f878-6bd4-f540200da198@mnmoran.org> Date: Mon, 3 Aug 2020 10:06:51 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 31ACB418AB X-Rspamd-UID: 259a2e My first BlueZ patch. This patch adds a utility function returning a string describing a SIG Model ID and uses this function for in the mesh-cfgclient in the list-nodes command output and in the display of received composition data. The strings were taken directly from the Bluetooth Mesh Profile and Mesh Model specifications. Fixed style issues. Michael N. Moran (1): Add strings for SIG Model IDs tools/mesh/cfgcli.c | 3 ++- tools/mesh/remote.c | 5 ++-- tools/mesh/util.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ tools/mesh/util.h | 1 + 4 files changed, 70 insertions(+), 3 deletions(-) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0MPBJxUnKF9x/wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 17:02:45 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id mF0lJhUnKF9fTgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 17:02:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=mnmoran.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ED119418A6; Mon, 3 Aug 2020 17:02:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728271AbgHCOH4 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 10:07:56 -0400 Received: from hoster906.com ([192.252.156.27]:49224 "EHLO hoster906.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbgHCOHz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 10:07:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mnmoran.org; h=from :subject:to:message-id:date:mime-version:content-type :content-transfer-encoding; s=dkim; bh=L7wJiaPTNNBoh2x4608zvE36N HtHcq2BA+rXIDzW5B8=; b=QPKZ1H1NrJUWVgSQuQiOUspLEfdOsPk1KKrj7lfFj 3NwQE+y8gfbSQT8kF7BGq80t6pmOuOA0Zs/J5v1S5989uc4CQqZry9TJtXZWQHSl Yl18UIygQLaIGqRZiT9uIYIrJ4hlUKOxkRAoLcGpSOLdyNVKJNVU7cVtLDlP/iKy b4= Received: (qmail 1103 invoked by uid 503); 3 Aug 2020 14:07:54 -0000 Received: from unknown (HELO ?192.168.254.79?) (pop-before-smtp@162.39.210.203) by hoster906.com with ESMTPA; 3 Aug 2020 14:07:54 -0000 From: "Michael N. Moran" <mike@mnmoran.org> Subject: [PATCH BlueZ v2 1/1] mesh: Add strings for SIG Model IDs To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Message-ID: <84fb4cad-5402-6d6b-b72e-a03a1c5d187a@mnmoran.org> Date: Mon, 3 Aug 2020 10:07:48 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: ED119418A6 X-Rspamd-UID: ad5484 --- tools/mesh/cfgcli.c | 3 ++- tools/mesh/remote.c | 5 ++-- tools/mesh/util.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ tools/mesh/util.h | 1 + 4 files changed, 70 insertions(+), 3 deletions(-) diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c index e36c8dca5..351f40ad0 100644 --- a/tools/mesh/cfgcli.c +++ b/tools/mesh/cfgcli.c @@ -263,7 +263,8 @@ static uint32_t print_mod_id(uint8_t *data, bool vendor, const char *offset) if (!vendor) { mod_id = get_le16(data); - bt_shell_printf("%sModel ID\t%4.4x\n", offset, mod_id); + bt_shell_printf("%sModel ID\t%4.4x \"%s\"\n", + offset, mod_id, sig_model_string(mod_id)); mod_id = VENDOR_ID_MASK | mod_id; } else { mod_id = get_le16(data + 2); diff --git a/tools/mesh/remote.c b/tools/mesh/remote.c index c74f0bec1..206885c07 100644 --- a/tools/mesh/remote.c +++ b/tools/mesh/remote.c @@ -30,6 +30,7 @@ #include "tools/mesh/keys.h" #include "tools/mesh/mesh-db.h" #include "tools/mesh/remote.h" +#include "tools/mesh/util.h" #define abs_diff(a, b) ((a) > (b) ? (a) - (b) : (b) - (a)) @@ -293,8 +294,8 @@ static void print_model(void *model, void *user_data) if (mod_id >= VENDOR_ID_MASK) { mod_id &= ~VENDOR_ID_MASK; - bt_shell_printf("\t\t\t" COLOR_GREEN "SIG model: %4.4x\n" - COLOR_OFF, mod_id); + bt_shell_printf("\t\t\t" COLOR_GREEN "SIG model: %4.4x \"%s\"\n" + COLOR_OFF, mod_id, sig_model_string(mod_id)); return; } diff --git a/tools/mesh/util.c b/tools/mesh/util.c index 7176cc562..82e4c9ad2 100644 --- a/tools/mesh/util.c +++ b/tools/mesh/util.c @@ -138,3 +138,67 @@ void swap_u256_bytes(uint8_t *u256) u256[i] ^= u256[31 - i]; } } + +const char *sig_model_string(uint16_t sig_model_id) +{ + switch (sig_model_id) { + case 0x0000: return "Configuration Server"; + case 0x0001: return "Configuration Client"; + case 0x0002: return "Health Server"; + case 0x0003: return "Health Client"; + case 0x1000: return "Generic OnOff Server"; + case 0x1001: return "Generic OnOff Client"; + case 0x1002: return "Generic Level Server"; + case 0x1003: return "Generic Level Client"; + case 0x1004: return "Generic Default Transition Time Server"; + case 0x1005: return "Generic Default Transition Time Client"; + case 0x1006: return "Generic Power OnOff Server"; + case 0x1007: return "Generic Power OnOff Setup Server"; + case 0x1008: return "Generic Power OnOff Client"; + case 0x1009: return "Generic Power Level Server"; + case 0x100A: return "Generic Power Level Setup Server"; + case 0x100B: return "Generic Power Level Client"; + case 0x100C: return "Generic Battery Server"; + case 0x100D: return "Generic Battery Client"; + case 0x100E: return "Generic Location Server"; + case 0x100F: return "Generic Location Setup Server"; + case 0x1010: return "Generic Location Client"; + case 0x1011: return "Generic Admin Property Server"; + case 0x1012: return "Generic Manufacturer Property Server"; + case 0x1013: return "Generic User Property Server"; + case 0x1014: return "Generic Client Property Server"; + case 0x1015: return "Generic Property Client"; + case 0x1100: return "Sensor Server"; + case 0x1101: return "Sensor Setup Server"; + case 0x1102: return "Sensor Client"; + case 0x1200: return "Time Server"; + case 0x1201: return "Time Setup Server"; + case 0x1202: return "Time Client"; + case 0x1203: return "Scene Server"; + case 0x1204: return "Scene Setup Server"; + case 0x1205: return "Scene Client"; + case 0x1206: return "Scheduler Server"; + case 0x1207: return "Scheduler Setup Server"; + case 0x1208: return "Scheduler Client"; + case 0x1300: return "Light Lightness Server"; + case 0x1301: return "Light Lightness Setup Server"; + case 0x1302: return "Light Lightness Client"; + case 0x1303: return "Light CTL Server"; + case 0x1304: return "Light CTL Setup Server"; + case 0x1305: return "Light CTL Client"; + case 0x1306: return "Light CTL Temperature Server"; + case 0x1307: return "Light HSL Server"; + case 0x1308: return "Light HSL Setup Server"; + case 0x1309: return "Light HSL Client"; + case 0x130A: return "Light HSL Hue Server"; + case 0x130B: return "Light HSL Saturation Server"; + case 0x130C: return "Light xyL Server"; + case 0x130D: return "Light xyL Setup Server"; + case 0x130E: return "Light xyL Client"; + case 0x130F: return "Light LC Server"; + case 0x1310: return "Light LC Setup Server"; + case 0x1311: return "Light LC Client"; + + default: return "Unknown"; + } +} diff --git a/tools/mesh/util.h b/tools/mesh/util.h index cca07cf96..2b9b926b1 100644 --- a/tools/mesh/util.h +++ b/tools/mesh/util.h @@ -27,3 +27,4 @@ uint16_t mesh_opcode_set(uint32_t opcode, uint8_t *buf); bool mesh_opcode_get(const uint8_t *buf, uint16_t sz, uint32_t *opcode, int *n); const char *mesh_status_str(uint8_t status); void swap_u256_bytes(uint8_t *u256); +const char *sig_model_string(uint16_t sig_model_id); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uCtjOzYpKF8a2AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 17:11:50 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OD8IOjYpKF/hKwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 17:11:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1C6A340990; Mon, 3 Aug 2020 17:11:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbgHCOyQ convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 10:54:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:44622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbgHCOyQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 10:54:16 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 03 Aug 2020 14:54:12 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gustavoyaraujo@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: <bug-60824-62941-Q77j65SFav@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1C6A340990 X-Rspamd-UID: 2356b4 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #127 from AndreyTarkovsky (gustavoyaraujo@gmail.com) --- Created attachment 290745 --> https://bugzilla.kernel.org/attachment.cgi?id=290745&action=edit (btmon -w) while executing `hciconfig hci0 up` for fake BT dongle 4.0 Plugged the dongle and did the command as showed in the last comments. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AAF+JodEKF894wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 19:08:23 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 2HavJIdEKF8FOwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 19:08:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D1835A2C01; Mon, 3 Aug 2020 19:08:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726925AbgHCRIM (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 13:08:12 -0400 Received: from mail-il1-f198.google.com ([209.85.166.198]:45698 "EHLO mail-il1-f198.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726864AbgHCRIH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 13:08:07 -0400 Received: by mail-il1-f198.google.com with SMTP id 65so6752151ilb.12 for <linux-bluetooth@vger.kernel.org>; Mon, 03 Aug 2020 10:08:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=Uagz7c3ZVrQ4AmBTqTiRjiEhG5PZlj6ITpIEOjqwLlk=; b=LRhUZ7lmO2qJ1dGadXNMOPTOSl5Ftehx6DvyJ/T5bZjiPyl0AAipVJnt1zfXGZHylz 2ga46CZKWIcEPef6efi3G77wYM+mev41vreP/P/cDMiZ8bbAwRgCnG3HZrw10u4TaF/M miW5S6/w98FY05puMYsUf9FkX17bxIvQvo+prJ4FLi8XCcGlqBA+JiTpakpIa8HnOK3b p3pia17bayPIeWzvSbxhVopv9W41Yt7hXgJCgtlDZowU9FxrgJf38e6tk3BGnjFTTKSp UgCL+sy9TWkPn+JT2DR/8CFfItKnzIyKvhoSbYj7UbG9RVIZ6ZOgOic8hSAekXclFRpw hVRw== X-Gm-Message-State: AOAM533gIQsyMw64IRZPe5i62dGhRP3hksd0Gg7rr7gdk2eoqicM0uqR yq0tHmjv8WJcgxiyPUZHT2Wr+EmHEF2sZJSdr9aPKVBSerwe X-Google-Smtp-Source: ABdhPJwUoO2AGC6UR45bmv6qFFKyJ8ndp7XrS1e6QhsHYtzpbvYwfQUycvap8dTkeAspF89iKUlUGDNf8nhiIGlpOp1dgS5vlqxA MIME-Version: 1.0 X-Received: by 2002:a6b:bb43:: with SMTP id l64mr795486iof.191.1596474486108; Mon, 03 Aug 2020 10:08:06 -0700 (PDT) Date: Mon, 03 Aug 2020 10:08:06 -0700 In-Reply-To: <000000000000adea7f05abeb19cf@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000a335a405abfc2e1e@google.com> Subject: Re: KASAN: use-after-free Read in hci_chan_del From: syzbot <syzbot+305a91e025a73e4fd6ce@syzkaller.appspotmail.com> To: coreteam@netfilter.org, davem@davemloft.net, devel@driverdev.osuosl.org, eric@anholt.net, gregkh@linuxfoundation.org, johan.hedberg@gmail.com, kaber@trash.net, kadlec@blackhole.kfki.hu, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, pablo@netfilter.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: D1835A2C01 X-Rspamd-UID: d3ae13 syzbot has bisected this issue to: commit 166beccd47e11e4d27477e8ca1d7eda47cf3b2da Author: Eric Anholt <eric@anholt.net> Date: Mon Oct 3 18:52:06 2016 +0000 staging/vchi: Convert to current get_user_pages() arguments. bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=178321a4900000 start commit: 5a30a789 Merge tag 'x86-urgent-2020-08-02' of git://git.ke.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=144321a4900000 console output: https://syzkaller.appspot.com/x/log.txt?x=104321a4900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55 dashboard link: https://syzkaller.appspot.com/bug?extid=305a91e025a73e4fd6ce syz repro: https://syzkaller.appspot.com/x/repro.syz?x=127dd914900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=122a94ec900000 Reported-by: syzbot+305a91e025a73e4fd6ce@syzkaller.appspotmail.com Fixes: 166beccd47e1 ("staging/vchi: Convert to current get_user_pages() arguments.") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sI4bANIpKF9x/wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 17:14:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id OHSROtEpKF+y/QEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 17:14:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E844B40134; Mon, 3 Aug 2020 17:14:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727920AbgHCPFX (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 11:05:23 -0400 Received: from mail-il1-f198.google.com ([209.85.166.198]:56867 "EHLO mail-il1-f198.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727838AbgHCPFW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 11:05:22 -0400 Received: by mail-il1-f198.google.com with SMTP id w81so27594248ilk.23 for <linux-bluetooth@vger.kernel.org>; Mon, 03 Aug 2020 08:05:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=cwHAmIAnWDXaQ8U+cgz3uBI7B40rqObvLOBOdb+Z848=; b=AFqeBZBXcJDqiTupPzIzN/Mptk3GVcCDOyIleG+uW1z0D7wv1t0Q0ZkzVLy5vY8Dem 53fTYHdzPYqukgQ018q8lMEqB2KXfxFphmpXYpTGMRwQtq7EOV8QeO0cICLWegKqkgPJ U+p2+2HsPFELz1/RzQTZPeNBIsSFdMKqsXC6EpqTWPMAB/j8V40aW6SEqpeOQwrUwVqc 3Fd6ZGrbs97KbGpyZYo+aFe89zLr8MTNAGgDH0/BNyoP94XkdlMqwoohYl0Q0Bm0dwLr By6h009qgyuocmL/jHN7oULdrQxPpCvtLI/kjcGruuzoHSXmw6T1lwiYBtR24LbxpO7O +UNw== X-Gm-Message-State: AOAM530vLIpK6JUuFXXGo5osMdvwI6qliP9NUf6tS2ZirKtPp7qJzzla MQRFMK4Z0dYwHdqNOufsYZ+Q/MP+3G/J8gk5QSY38SiWSuv8 X-Google-Smtp-Source: ABdhPJynY1P/Ats+QjnU0eZn1C6aGDytmEJlnR20o3Pr43gms75ovSxM3yYUFPnfz9XxtEny6CaMM1EUKc79LPamNTb2xxmMA0Xn MIME-Version: 1.0 X-Received: by 2002:a6b:3bd4:: with SMTP id i203mr231137ioa.205.1596467121253; Mon, 03 Aug 2020 08:05:21 -0700 (PDT) Date: Mon, 03 Aug 2020 08:05:21 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000a876b805abfa77e0@google.com> Subject: KASAN: slab-out-of-bounds Read in hci_le_meta_evt From: syzbot <syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@armlinux.org.uk, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: E844B40134 X-Rspamd-UID: f1c98f Hello, syzbot found the following issue on: HEAD commit: 5a30a789 Merge tag 'x86-urgent-2020-08-02' of git://git.ke.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=11cd21cc900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 dashboard link: https://syzkaller.appspot.com/bug?extid=24ebd650e20bd263ca01 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10fd4504900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14aa36a4900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com Bluetooth: hci0: unknown advertising packet type: 0x2b ================================================================== BUG: KASAN: slab-out-of-bounds in hci_le_direct_adv_report_evt net/bluetooth/hci_event.c:5850 [inline] BUG: KASAN: slab-out-of-bounds in hci_le_meta_evt+0x380c/0x3eb0 net/bluetooth/hci_event.c:5914 Read of size 1 at addr ffff8880a727de0c by task kworker/u5:0/1535 CPU: 1 PID: 1535 Comm: kworker/u5:0 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530 hci_le_direct_adv_report_evt net/bluetooth/hci_event.c:5850 [inline] hci_le_meta_evt+0x380c/0x3eb0 net/bluetooth/hci_event.c:5914 hci_event_packet+0x245a/0x86f5 net/bluetooth/hci_event.c:6167 hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Allocated by task 6834: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494 __kmalloc_reserve net/core/skbuff.c:142 [inline] __alloc_skb+0xae/0x550 net/core/skbuff.c:210 alloc_skb include/linux/skbuff.h:1083 [inline] bt_skb_alloc include/net/bluetooth/bluetooth.h:377 [inline] vhci_get_user drivers/bluetooth/hci_vhci.c:165 [inline] vhci_write+0xbd/0x450 drivers/bluetooth/hci_vhci.c:285 call_write_iter include/linux/fs.h:1908 [inline] new_sync_write+0x422/0x650 fs/read_write.c:503 vfs_write+0x59d/0x6b0 fs/read_write.c:578 ksys_write+0x12d/0x250 fs/read_write.c:631 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 6627: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x103/0x2c0 mm/slab.c:3757 tomoyo_find_next_domain+0x81d/0x1f77 security/tomoyo/domain.c:885 tomoyo_bprm_check_security security/tomoyo/tomoyo.c:101 [inline] tomoyo_bprm_check_security+0x121/0x1a0 security/tomoyo/tomoyo.c:91 security_bprm_check+0x45/0xa0 security/security.c:840 search_binary_handler fs/exec.c:1737 [inline] exec_binprm fs/exec.c:1790 [inline] __do_execve_file+0x1577/0x2ee0 fs/exec.c:1926 do_execveat_common fs/exec.c:1980 [inline] do_execve+0x35/0x50 fs/exec.c:1997 __do_sys_execve fs/exec.c:2073 [inline] __se_sys_execve fs/exec.c:2068 [inline] __x64_sys_execve+0x7c/0xa0 fs/exec.c:2068 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff8880a727dc00 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 12 bytes to the right of 512-byte region [ffff8880a727dc00, ffff8880a727de00) The buggy address belongs to the page: page:ffffea00029c9f40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00029e3848 ffffea0002731b88 ffff8880aa000a80 raw: 0000000000000000 ffff8880a727d000 0000000100000004 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880a727dd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff8880a727dd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff8880a727de00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff8880a727de80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8880a727df00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ================================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UKZfLMlFKF/PtQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 19:13:45 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IIKcKslFKF8PwwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 19:13:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=armlinux.org.uk X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DABC5418A7; Mon, 3 Aug 2020 19:13:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728337AbgHCRMo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 13:12:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbgHCRMo (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 13:12:44 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A36C9C06174A; Mon, 3 Aug 2020 10:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=a4yiFZSXRsBVbohmfx7FDLAnp12OJjyh0v7RJM5PeaY=; b=kqFYnOVq8dafpmcb5NQmBTY+1 5hfwe97tAx/9KZ5EiuTchyF8GoIZ1wN79lbFH1lIhlZvD4jNBgKskJ+daV8eTPugKgbs5tKq122rt RIyQR+dhA8CMoNn8zWCawbDQf+uzkWT0l5NI+2svvtLhqnTrUt6QetR2MKlUsplSutiT0Raa1Pe9x rCBfBUDY1iWQdE8D+gpgT0RT6r3mAhwNdXzsy3Hp8X0Bj9T2g28TL3wZ3UAylAm7r73aYbGy1rxMf 22NtpeWKTRo9YpSh7HPMSyXce0YLOF5wPFRLnQNsLffCEdzEKCt+GtM1ZkBBYe+GocrTfilvgAgIz zapLSHZiQ==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:47878) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <linux@armlinux.org.uk>) id 1k2e0q-0001mF-To; Mon, 03 Aug 2020 18:12:36 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from <linux@shell.armlinux.org.uk>) id 1k2e0n-0003GQ-1C; Mon, 03 Aug 2020 18:12:33 +0100 Date: Mon, 3 Aug 2020 18:12:33 +0100 From: Russell King - ARM Linux admin <linux@armlinux.org.uk> To: syzbot <syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com> Cc: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: KASAN: slab-out-of-bounds Read in hci_le_meta_evt Message-ID: <20200803171232.GR1551@shell.armlinux.org.uk> References: <000000000000a876b805abfa77e0@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000000000000a876b805abfa77e0@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.16 / 15.00 / 200.00 X-Rspamd-Queue-Id: DABC5418A7 X-Rspamd-UID: 124112 Dear syzbot, Please explain why you are spamming me with all these reports - four so far. I don't understand why you think I should be doing anything with these. Thanks. On Mon, Aug 03, 2020 at 08:05:21AM -0700, syzbot wrote: > Hello, > > syzbot found the following issue on: > > HEAD commit: 5a30a789 Merge tag 'x86-urgent-2020-08-02' of git://git.ke.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=11cd21cc900000 > kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 > dashboard link: https://syzkaller.appspot.com/bug?extid=24ebd650e20bd263ca01 > compiler: gcc (GCC) 10.1.0-syz 20200507 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10fd4504900000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14aa36a4900000 > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com > > Bluetooth: hci0: unknown advertising packet type: 0x2b > ================================================================== > BUG: KASAN: slab-out-of-bounds in hci_le_direct_adv_report_evt net/bluetooth/hci_event.c:5850 [inline] > BUG: KASAN: slab-out-of-bounds in hci_le_meta_evt+0x380c/0x3eb0 net/bluetooth/hci_event.c:5914 > Read of size 1 at addr ffff8880a727de0c by task kworker/u5:0/1535 > > CPU: 1 PID: 1535 Comm: kworker/u5:0 Not tainted 5.8.0-rc7-syzkaller #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 > Workqueue: hci0 hci_rx_work > Call Trace: > __dump_stack lib/dump_stack.c:77 [inline] > dump_stack+0x18f/0x20d lib/dump_stack.c:118 > print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383 > __kasan_report mm/kasan/report.c:513 [inline] > kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530 > hci_le_direct_adv_report_evt net/bluetooth/hci_event.c:5850 [inline] > hci_le_meta_evt+0x380c/0x3eb0 net/bluetooth/hci_event.c:5914 > hci_event_packet+0x245a/0x86f5 net/bluetooth/hci_event.c:6167 > hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 > process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 > worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 > kthread+0x3b5/0x4a0 kernel/kthread.c:291 > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 > > Allocated by task 6834: > save_stack+0x1b/0x40 mm/kasan/common.c:48 > set_track mm/kasan/common.c:56 [inline] > __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494 > __kmalloc_reserve net/core/skbuff.c:142 [inline] > __alloc_skb+0xae/0x550 net/core/skbuff.c:210 > alloc_skb include/linux/skbuff.h:1083 [inline] > bt_skb_alloc include/net/bluetooth/bluetooth.h:377 [inline] > vhci_get_user drivers/bluetooth/hci_vhci.c:165 [inline] > vhci_write+0xbd/0x450 drivers/bluetooth/hci_vhci.c:285 > call_write_iter include/linux/fs.h:1908 [inline] > new_sync_write+0x422/0x650 fs/read_write.c:503 > vfs_write+0x59d/0x6b0 fs/read_write.c:578 > ksys_write+0x12d/0x250 fs/read_write.c:631 > do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > Freed by task 6627: > save_stack+0x1b/0x40 mm/kasan/common.c:48 > set_track mm/kasan/common.c:56 [inline] > kasan_set_free_info mm/kasan/common.c:316 [inline] > __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455 > __cache_free mm/slab.c:3426 [inline] > kfree+0x103/0x2c0 mm/slab.c:3757 > tomoyo_find_next_domain+0x81d/0x1f77 security/tomoyo/domain.c:885 > tomoyo_bprm_check_security security/tomoyo/tomoyo.c:101 [inline] > tomoyo_bprm_check_security+0x121/0x1a0 security/tomoyo/tomoyo.c:91 > security_bprm_check+0x45/0xa0 security/security.c:840 > search_binary_handler fs/exec.c:1737 [inline] > exec_binprm fs/exec.c:1790 [inline] > __do_execve_file+0x1577/0x2ee0 fs/exec.c:1926 > do_execveat_common fs/exec.c:1980 [inline] > do_execve+0x35/0x50 fs/exec.c:1997 > __do_sys_execve fs/exec.c:2073 [inline] > __se_sys_execve fs/exec.c:2068 [inline] > __x64_sys_execve+0x7c/0xa0 fs/exec.c:2068 > do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > The buggy address belongs to the object at ffff8880a727dc00 > which belongs to the cache kmalloc-512 of size 512 > The buggy address is located 12 bytes to the right of > 512-byte region [ffff8880a727dc00, ffff8880a727de00) > The buggy address belongs to the page: > page:ffffea00029c9f40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 > flags: 0xfffe0000000200(slab) > raw: 00fffe0000000200 ffffea00029e3848 ffffea0002731b88 ffff8880aa000a80 > raw: 0000000000000000 ffff8880a727d000 0000000100000004 0000000000000000 > page dumped because: kasan: bad access detected > > Memory state around the buggy address: > ffff8880a727dd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > ffff8880a727dd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > >ffff8880a727de00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc > ^ > ffff8880a727de80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc > ffff8880a727df00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc > ================================================================== > > > --- > This report is generated by a bot. It may contain errors. > See https://goo.gl/tpsmEJ for more information about syzbot. > syzbot engineers can be reached at syzkaller@googlegroups.com. > > syzbot will keep track of this issue. See: > https://goo.gl/tpsmEJ#status for how to communicate with syzbot. > syzbot can test patches for this issue, for details see: > https://goo.gl/tpsmEJ#testing-patches > -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CGWmCmtIKF/s+QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 19:24:59 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yAJPCWtIKF+qCgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 19:24:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8222341753; Mon, 3 Aug 2020 19:24:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728512AbgHCRVH (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 13:21:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:44854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727803AbgHCRVG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 13:21:06 -0400 Received: from gmail.com (unknown [104.132.1.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D71D220792; Mon, 3 Aug 2020 17:21:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596475265; bh=jGN7xhLfLhvidfL47wcuIKF2cDWQoBJ68JRX9J/3CaI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=2cjkusXf5uipTXfA/Efb96S/p2wf7pAsFsMItD6wYfAAJJmSLoo4cdCHrAU079Wjh y6qiyjYKGGuZdAabq3/coHxCq+UPL0UySp+aNGwuH02cS7DDuOoUrkabk/N+2y4N4U rD3yvkQGYDWnYz+xkdRbbW15H/1NHVF8dRFlM5/k= Date: Mon, 3 Aug 2020 10:21:04 -0700 From: Eric Biggers <ebiggers@kernel.org> To: Russell King - ARM Linux admin <linux@armlinux.org.uk> Cc: syzbot <syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com>, davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: KASAN: slab-out-of-bounds Read in hci_le_meta_evt Message-ID: <20200803172104.GA1644292@gmail.com> References: <000000000000a876b805abfa77e0@google.com> <20200803171232.GR1551@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200803171232.GR1551@shell.armlinux.org.uk> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -6.88 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8222341753 X-Rspamd-UID: 1e0b7a On Mon, Aug 03, 2020 at 06:12:33PM +0100, Russell King - ARM Linux admin wrote: > Dear syzbot, > > Please explain why you are spamming me with all these reports - four so > far. I don't understand why you think I should be doing anything with > these. > > Thanks. syzbot just uses get_maintainer.pl. $ ./scripts/get_maintainer.pl net/bluetooth/hci_event.c Marcel Holtmann <marcel@holtmann.org> (maintainer:BLUETOOTH SUBSYSTEM) Johan Hedberg <johan.hedberg@gmail.com> (maintainer:BLUETOOTH SUBSYSTEM) "David S. Miller" <davem@davemloft.net> (maintainer:NETWORKING [GENERAL]) Jakub Kicinski <kuba@kernel.org> (maintainer:NETWORKING [GENERAL]) Russell King <linux@armlinux.org.uk> (maintainer:SFF/SFP/SFP+ MODULE SUPPORT) linux-bluetooth@vger.kernel.org (open list:BLUETOOTH SUBSYSTEM) netdev@vger.kernel.org (open list:NETWORKING [GENERAL]) linux-kernel@vger.kernel.org (open list) Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8LZELT5KKF+BCQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 19:32:46 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YOKgKz5KKF8UrwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 19:32:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=armlinux.org.uk X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AA8D2A1CB4; Mon, 3 Aug 2020 19:32:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728269AbgHCRca (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 13:32:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726398AbgHCRca (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 13:32:30 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B508C06174A; Mon, 3 Aug 2020 10:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0ZDD1ZPqsN+tFofRrEFxYutxtUgK9Ft2cc16nR6TtKQ=; b=LCwADhUujEXFWHoJ0pW3J/I5r 8o8K5TVpuJxvaMw2CkilXdpCncofaEBbZFdRkQQbvMWpwFI8Kclj03J2WFpO5e5n3o+sL2el9iBHw WVc8l2xunrWTmC9y731AAqcvJuflejdR0JqMDiqpj+fUQBKWUruowhC3yp5b0B2sqJD6kYxrU93Cu 9p2ua/k9CcDM2UtkE01bACMbBkpkkw2Gke+OLNKcnGWkqpHavGU4xfPJd1rDqpiYiohWT8B/bMAmO 9Yq4jVHkgEIvMFdcPWfE3zrUisPn1MXHJWgEUAvAT/OlvG5pv/NSbr/r10m2hWe0DsFLzWJjvU1az ip4OY4gGg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:47888) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <linux@armlinux.org.uk>) id 1k2eK2-0001oV-JY; Mon, 03 Aug 2020 18:32:26 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from <linux@shell.armlinux.org.uk>) id 1k2eK0-0003Gp-3l; Mon, 03 Aug 2020 18:32:24 +0100 Date: Mon, 3 Aug 2020 18:32:24 +0100 From: Russell King - ARM Linux admin <linux@armlinux.org.uk> To: Eric Biggers <ebiggers@kernel.org> Cc: syzbot <syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com>, davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: KASAN: slab-out-of-bounds Read in hci_le_meta_evt Message-ID: <20200803173223.GS1551@shell.armlinux.org.uk> References: <000000000000a876b805abfa77e0@google.com> <20200803171232.GR1551@shell.armlinux.org.uk> <20200803172104.GA1644292@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200803172104.GA1644292@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.41 / 15.00 / 200.00 X-Rspamd-Queue-Id: AA8D2A1CB4 X-Rspamd-UID: 8a8218 On Mon, Aug 03, 2020 at 10:21:04AM -0700, Eric Biggers wrote: > On Mon, Aug 03, 2020 at 06:12:33PM +0100, Russell King - ARM Linux admin wrote: > > Dear syzbot, > > > > Please explain why you are spamming me with all these reports - four so > > far. I don't understand why you think I should be doing anything with > > these. > > > > Thanks. > > syzbot just uses get_maintainer.pl. > > $ ./scripts/get_maintainer.pl net/bluetooth/hci_event.c > Marcel Holtmann <marcel@holtmann.org> (maintainer:BLUETOOTH SUBSYSTEM) > Johan Hedberg <johan.hedberg@gmail.com> (maintainer:BLUETOOTH SUBSYSTEM) > "David S. Miller" <davem@davemloft.net> (maintainer:NETWORKING [GENERAL]) > Jakub Kicinski <kuba@kernel.org> (maintainer:NETWORKING [GENERAL]) > Russell King <linux@armlinux.org.uk> (maintainer:SFF/SFP/SFP+ MODULE SUPPORT) > linux-bluetooth@vger.kernel.org (open list:BLUETOOTH SUBSYSTEM) > netdev@vger.kernel.org (open list:NETWORKING [GENERAL]) > linux-kernel@vger.kernel.org (open list) Ah, and, because the file mentions "phylink" (although it makes no use of the phylink code), get_maintainer spits out my address. Great. So how do I get get_maintainer to identify patches that are making use of phylink, but avoid this bluetooth code... (that's not a question.) -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cDYOI1lQKF/G/wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 19:58:49 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2CJSIVlQKF8ieQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 19:58:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 651ECA19A1; Mon, 3 Aug 2020 19:58:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727101AbgHCR6e (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 13:58:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:54774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbgHCR6e (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 13:58:34 -0400 Received: from gmail.com (unknown [104.132.1.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C4EF122B45; Mon, 3 Aug 2020 17:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596477513; bh=8kJJz6W/mGZtko6NJf68mrmroXbObC8q8KfF+PQIH3I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=alKiqgzMUdWV9Mzs5zcN4fyg3p/X5TiiDveOG7C4wnqW94hnWw/lIA0n8psIu+jns 45wEDRMAucjA7d/YfdLyisGHnWDlS/xuO/u8HyZOK5FvNd9nD15G0EIkWEm69CMWxp eoz5HgyXVG/XjiCGV7phP6pXr3DcS2mtJWMm8FwQ= Date: Mon, 3 Aug 2020 10:58:32 -0700 From: Eric Biggers <ebiggers@kernel.org> To: Russell King - ARM Linux admin <linux@armlinux.org.uk> Cc: syzbot <syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com>, davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: KASAN: slab-out-of-bounds Read in hci_le_meta_evt Message-ID: <20200803175832.GB1644292@gmail.com> References: <000000000000a876b805abfa77e0@google.com> <20200803171232.GR1551@shell.armlinux.org.uk> <20200803172104.GA1644292@gmail.com> <20200803173223.GS1551@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200803173223.GS1551@shell.armlinux.org.uk> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -6.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: 651ECA19A1 X-Rspamd-UID: 025355 On Mon, Aug 03, 2020 at 06:32:24PM +0100, Russell King - ARM Linux admin wrote: > On Mon, Aug 03, 2020 at 10:21:04AM -0700, Eric Biggers wrote: > > On Mon, Aug 03, 2020 at 06:12:33PM +0100, Russell King - ARM Linux admin wrote: > > > Dear syzbot, > > > > > > Please explain why you are spamming me with all these reports - four so > > > far. I don't understand why you think I should be doing anything with > > > these. > > > > > > Thanks. > > > > syzbot just uses get_maintainer.pl. > > > > $ ./scripts/get_maintainer.pl net/bluetooth/hci_event.c > > Marcel Holtmann <marcel@holtmann.org> (maintainer:BLUETOOTH SUBSYSTEM) > > Johan Hedberg <johan.hedberg@gmail.com> (maintainer:BLUETOOTH SUBSYSTEM) > > "David S. Miller" <davem@davemloft.net> (maintainer:NETWORKING [GENERAL]) > > Jakub Kicinski <kuba@kernel.org> (maintainer:NETWORKING [GENERAL]) > > Russell King <linux@armlinux.org.uk> (maintainer:SFF/SFP/SFP+ MODULE SUPPORT) > > linux-bluetooth@vger.kernel.org (open list:BLUETOOTH SUBSYSTEM) > > netdev@vger.kernel.org (open list:NETWORKING [GENERAL]) > > linux-kernel@vger.kernel.org (open list) > > Ah, and, because the file mentions "phylink" (although it makes no use > of the phylink code), get_maintainer spits out my address. Great. > > So how do I get get_maintainer to identify patches that are making use > of phylink, but avoid this bluetooth code... (that's not a question.) > I think "K: " (content regex) in MAINTAINERS is best avoided. This isn't the first time that someone has volunteered to maintain all files containing $foo, then complained when they receive emails for those files as they requested... If you do really want to use it, can you use a more specific regex? E.g. a regex that matches "#include <linux/phylink.h>" or some specific function(s)? - Eric Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cFOEEhRtKF8x0AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 03 Aug 2020 22:01:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +N/kEBRtKF+iNAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 03 Aug 2020 22:01:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5DC68A0F5C; Mon, 3 Aug 2020 22:01:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728525AbgHCUBN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 16:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727091AbgHCUBN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 16:01:13 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFCCFC06174A for <linux-bluetooth@vger.kernel.org>; Mon, 3 Aug 2020 13:01:12 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id v21so21580354otj.9 for <linux-bluetooth@vger.kernel.org>; Mon, 03 Aug 2020 13:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7hlg5svWlsRE4MtXofp3Yd6rbfJDIbDN8Va86Lsz6+o=; b=R5hZ7y5QwI9miGU3E3zobKw6F63dJa1lRzSiT8OI7bF3i89YKWdRP7shKkHbpB7eaW 4qSp+g2CdBpdCUevm46VojJ0KL47abYMYvCsm713CWIlK7jc+3toxk6wDk1HKfCId4R+ 4WqJBVxT5nM9+1ppLL/Xqnf959rgYHnzHwFfP9geGoQ7Q2Lz1RCe8hDLxgOoYLBZ4OHV +srMiRiHTBgS+2baCSLh3dx21cLKMp5X57coUFO+q7LvMAySxp4i3DkLRBwO1K2G9kAf 36pqNWdkpVs5bPJwzEilu376O/iLaQO+xy64Zfv03Th+UxdRBmWfGhLkXgMi+9HhD5Eq 9Bvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7hlg5svWlsRE4MtXofp3Yd6rbfJDIbDN8Va86Lsz6+o=; b=K2wET//74FFAeU1WfliUK2Qk13jxKljBGoCR9iKm83fCdJnQf81PvKJPCc43B6R/i7 P52VAOlthHngaxw9xIYMVTnb1RzYJXqEtyX2soXqu2+NB0gIynMJ+OCYFCfwtktOAdQk B358QbGmu3HchURfUwpJg+pCGLHmMGV7BbV3ozkTzkk67nT73emjoJAfdf4nmlbZUOHu N/bycSLL7S8k4EE2PYI8czIfnQAHoWGSi9hbiKLAtL41l5lgfdLz0lFc0U3caeO84fqE yaDw5njgUs5FE+QXCbwbEhP7ycT6Satb/Ow89Nu4Y98YzhcjvnAg9g2tvGJITt6lcK1d 3k8g== X-Gm-Message-State: AOAM531en2WEbx5zSSZWhP3HdRrRGf/rGMwxSf4v22EOqkOYvt1vbG35 L0s9JT+peKgrTAebBzHDrdxwCAvLgZXvWPwvt/o= X-Google-Smtp-Source: ABdhPJzroe1s8rxne+IDicgWMu+ARSf45mE2pObgb0IE9yaZmpaXllvs4MYj8OpLOP3uwXVgx3G7iqgDnh8fSE9Clw8= X-Received: by 2002:a9d:6053:: with SMTP id v19mr14557878otj.362.1596484871899; Mon, 03 Aug 2020 13:01:11 -0700 (PDT) MIME-Version: 1.0 References: <20200803145200.Bluez.v2.1.Ibf5508171632eebb66a6cd0ed2fa87bfac078f74@changeid> In-Reply-To: <20200803145200.Bluez.v2.1.Ibf5508171632eebb66a6cd0ed2fa87bfac078f74@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 3 Aug 2020 13:01:02 -0700 Message-ID: <CABBYNZ+enHjri-aMrWcur5V+EWDRWj9b5Zmwp4v4ijDpYN7m4A@mail.gmail.com> Subject: Re: [Bluez PATCH v2 1/3] input/device: Replace UHID_FEATURE with UHID_GET_REPORT To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.60 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5DC68A0F5C X-Rspamd-UID: c339be Hi Archie, On Sun, Aug 2, 2020 at 11:52 PM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > According to kernel's uhid.h, UHID_FEATURE is obsolete and is > replaced with UHID_GET_REPORT. > > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > > Changes in v2: > -Split into three patches, now this only handles UHID_GET_REPORT > > profiles/input/device.c | 41 +++++++++++++++++++------------------- > profiles/input/hidp_defs.h | 2 +- > 2 files changed, 22 insertions(+), 21 deletions(-) > > diff --git a/profiles/input/device.c b/profiles/input/device.c > index ee0b2404a..ac4487f63 100644 > --- a/profiles/input/device.c > +++ b/profiles/input/device.c > @@ -220,7 +220,7 @@ static bool hidp_send_intr_message(struct input_device *idev, uint8_t hdr, > return hidp_send_message(idev->intr_io, hdr, data, size); > } > > -static bool uhid_send_feature_answer(struct input_device *idev, > +static bool uhid_send_get_report_reply(struct input_device *idev, > const uint8_t *data, size_t size, > uint32_t id, uint16_t err) > { > @@ -230,8 +230,8 @@ static bool uhid_send_feature_answer(struct input_device *idev, > if (data == NULL) > size = 0; > > - if (size > sizeof(ev.u.feature_answer.data)) > - size = sizeof(ev.u.feature_answer.data); > + if (size > sizeof(ev.u.get_report_reply.data)) > + size = sizeof(ev.u.get_report_reply.data); > > if (!idev->uhid_created) { > DBG("HID report (%zu bytes) dropped", size); > @@ -239,13 +239,13 @@ static bool uhid_send_feature_answer(struct input_device *idev, > } > > memset(&ev, 0, sizeof(ev)); > - ev.type = UHID_FEATURE_ANSWER; > - ev.u.feature_answer.id = id; > - ev.u.feature_answer.err = err; > - ev.u.feature_answer.size = size; > + ev.type = UHID_GET_REPORT_REPLY; > + ev.u.get_report_reply.id = id; > + ev.u.get_report_reply.err = err; > + ev.u.get_report_reply.size = size; > > if (size > 0) > - memcpy(ev.u.feature_answer.data, data, size); > + memcpy(ev.u.get_report_reply.data, data, size); > > ret = bt_uhid_send(idev->uhid, &ev); > if (ret < 0) { > @@ -399,7 +399,7 @@ static void hidp_recv_ctrl_handshake(struct input_device *idev, uint8_t param) > case HIDP_HSHK_ERR_FATAL: > if (pending_req_type == HIDP_TRANS_GET_REPORT) { > DBG("GET_REPORT failed (%u)", param); > - uhid_send_feature_answer(idev, NULL, 0, > + uhid_send_get_report_reply(idev, NULL, 0, > idev->report_rsp_id, EIO); > pending_req_complete = true; > } else if (pending_req_type == HIDP_TRANS_SET_REPORT) { > @@ -460,8 +460,8 @@ static void hidp_recv_ctrl_data(struct input_device *idev, uint8_t param, > switch (param) { > case HIDP_DATA_RTYPE_FEATURE: > case HIDP_DATA_RTYPE_INPUT: > - case HIDP_DATA_RTYPE_OUPUT: > - uhid_send_feature_answer(idev, data + 1, size - 1, > + case HIDP_DATA_RTYPE_OUTPUT: > + uhid_send_get_report_reply(idev, data + 1, size - 1, > idev->report_rsp_id, 0); > break; > > @@ -626,7 +626,7 @@ static void hidp_send_set_report(struct uhid_event *ev, void *user_data) > break; > case UHID_OUTPUT_REPORT: > /* Send DATA on interrupt channel */ > - hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT; > + hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUTPUT; > hidp_send_intr_message(idev, hdr, ev->u.output.data, > ev->u.output.size); > break; > @@ -646,13 +646,13 @@ static void hidp_send_get_report(struct uhid_event *ev, void *user_data) > > if (idev->report_req_pending) { > DBG("Old GET_REPORT or SET_REPORT still pending"); > - uhid_send_feature_answer(idev, NULL, 0, ev->u.feature.id, > + uhid_send_get_report_reply(idev, NULL, 0, ev->u.get_report.id, > EBUSY); > return; > } > > /* Send GET_REPORT on control channel */ > - switch (ev->u.feature.rtype) { > + switch (ev->u.get_report.rtype) { > case UHID_FEATURE_REPORT: > hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_FEATURE; > break; > @@ -660,21 +660,21 @@ static void hidp_send_get_report(struct uhid_event *ev, void *user_data) > hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_INPUT; > break; > case UHID_OUTPUT_REPORT: > - hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_OUPUT; > + hdr = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_OUTPUT; > break; > default: > - DBG("Unsupported HID report type %u", ev->u.feature.rtype); > + DBG("Unsupported HID report type %u", ev->u.get_report.rtype); > return; > } > > - sent = hidp_send_ctrl_message(idev, hdr, &ev->u.feature.rnum, > - sizeof(ev->u.feature.rnum)); > + sent = hidp_send_ctrl_message(idev, hdr, &ev->u.get_report.rnum, > + sizeof(ev->u.get_report.rnum)); > if (sent) { > idev->report_req_pending = hdr; > idev->report_req_timer = > g_timeout_add_seconds(REPORT_REQ_TIMEOUT, > hidp_report_req_timeout, idev); > - idev->report_rsp_id = ev->u.feature.id; > + idev->report_rsp_id = ev->u.get_report.id; > } > } > > @@ -909,7 +909,8 @@ static int uhid_connadd(struct input_device *idev, struct hidp_connadd_req *req) > } > > bt_uhid_register(idev->uhid, UHID_OUTPUT, hidp_send_set_report, idev); > - bt_uhid_register(idev->uhid, UHID_FEATURE, hidp_send_get_report, idev); > + bt_uhid_register(idev->uhid, UHID_GET_REPORT, hidp_send_get_report, > + idev); > > idev->uhid_created = true; > > diff --git a/profiles/input/hidp_defs.h b/profiles/input/hidp_defs.h > index 5dc479acf..bb9231dbb 100644 > --- a/profiles/input/hidp_defs.h > +++ b/profiles/input/hidp_defs.h > @@ -63,7 +63,7 @@ > #define HIDP_DATA_RSRVD_MASK 0x0c > #define HIDP_DATA_RTYPE_OTHER 0x00 > #define HIDP_DATA_RTYPE_INPUT 0x01 > -#define HIDP_DATA_RTYPE_OUPUT 0x02 > +#define HIDP_DATA_RTYPE_OUTPUT 0x02 > #define HIDP_DATA_RTYPE_FEATURE 0x03 > > /* HIDP protocol header parameters */ > -- > 2.28.0.163.g6104cc2f0b6-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yNCYBZ6kKF+O/gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 01:58:22 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id yN0KBJ6kKF+d/AEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 01:58:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2590340676; Tue, 4 Aug 2020 01:58:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729014AbgHCX6R (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 19:58:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726718AbgHCX6Q (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 19:58:16 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A71C5C06174A for <linux-bluetooth@vger.kernel.org>; Mon, 3 Aug 2020 16:58:16 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id y10so1308858plp.6 for <linux-bluetooth@vger.kernel.org>; Mon, 03 Aug 2020 16:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=rUZ3X/1bYQIGZFQNZhgcWGW3ZdRY5Mhti8H9iXiM9lk=; b=ZaIbQVT0OomaOH01ot9u6k2tT1PDSsMQ3CCG8mgENXzzQPHa3w9Dk1QpAcdIywdQib r99FPVxztB2ZqU4W8m9EHdEkKNOcBZpRcO84FxX8+tDrlW5CX2vd4MTu9wNBdSbHGuyb ZouE+yOVfcJqTOn50MGlshHZqZrivHABic4yqiz2O4lmtPX9hXTePVHCFDGzkTXC/sn5 Qho9/9kYOivChECaNfUDZ/h14nKuOVHbA3k+hxLP9DNJufTQWC9oROa8HuBm0J5Kd6Dx pPwCOj0H5OyJ4x6wsTVqUdtOylgdw+s1f6WtJ0QW3ccImb99ANm8dcpW2zP00lBsd/oY t/mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=rUZ3X/1bYQIGZFQNZhgcWGW3ZdRY5Mhti8H9iXiM9lk=; b=MFR1llBralqDKefbzjhzUGceVA3t7/tPgXP96WY55yUccuEEZUYmSfx3A+2YNQxLc3 l2LrKjGiFgklixrfMCgp+JR/QYC0GT1RyyWRXYSod8gOc+us0sHCe5X4PtDbUKNfeRW+ dNLMolrY7QCnxeDoxlxhoqkXjO48MYBD9LE3v7guyX05QOTEfl7sop/INKNIeYghbO9S AyOzOmn2ejkykt3aQ9u1QVkPVTWVqwQrENX0hmKGx+9gon62FVk0fibVOrukisS5uE/Q 4nc0QXpK0oZSbKfp6oCj8zWXJ79L4aS9r/betp72AA/QXogDmEnhTCfTP/1kgbChKzNc QoCg== X-Gm-Message-State: AOAM530Wzx03uzBUUju4mjCOUvy4sY5G6Km5PMlJiH/0LDdWb9ICjVQi hUaEW3ALTit7DDwcG3KHV25QqNeFd8C8sfK6HNTtsNZH9ixxE+T5o+W5YWLaKhIHz8wDy9YpTNx GqsbgrQ2WNvABCA39kiuX5k5UxecRyKX3VXM36v+HkHHkChnJUsRvHaQcmfc/Po8Av3poiFXHB7 GL X-Google-Smtp-Source: ABdhPJzBxgZDyH+WAccia3SJHZuVpF/2YhzWzTeeFfaUQRSJ1CZCItuMMzeggke8hYggT9k8zJLmK6DjM5/g X-Received: by 2002:a62:206:: with SMTP id 6mr14329299pfc.228.1596499095904; Mon, 03 Aug 2020 16:58:15 -0700 (PDT) Date: Mon, 3 Aug 2020 16:58:10 -0700 Message-Id: <20200803235811.2441774-1-yudiliu@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [RFC PATCH v1 0/1] A client needs to query whether the Bluetooth adapter support WBS, so we From: Yu Liu <yudiliu@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Yu Liu <yudiliu@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.33 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2590340676 X-Rspamd-UID: a29f5c designed this new D-Bus API to provide a generic way to query the adapter's capabilities. Initially this will only cover WBS capability, but can be easily extended to support other capabilities. Changes in v1: - Initial change Archie Pusaka (1): adapter - D-Bus API for querying the adapter's capability doc/adapter-api.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) -- 2.28.0.163.g6104cc2f0b6-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sEoaCQKlKF9oTAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 02:00:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 8PR3BwKlKF85YwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 02:00:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 084C44014E; Tue, 4 Aug 2020 01:59:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729203AbgHCX6Y (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 3 Aug 2020 19:58:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729139AbgHCX6W (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 3 Aug 2020 19:58:22 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EDB7C0617A0 for <linux-bluetooth@vger.kernel.org>; Mon, 3 Aug 2020 16:58:22 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id r1so7230805ybg.4 for <linux-bluetooth@vger.kernel.org>; Mon, 03 Aug 2020 16:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=we5XgM9D/FaMqpDjAxLlNgitGEtix5X3KZAI9OVXI+Q=; b=pY8qCSOzC6iiErMuP9CTXE3NltWwjZ7lSbcKrVBfAMy9qTdAEwdoc6K2J9PKi+uUfT lZLns8PNAfzUZ4wKDpGbTLwvULJXY8VeBzbJtuQKJmWC3mwm0lMq5gRPR0Mc2BokqL5X AenKXWKyUmT/WVayuYU/fbJXI0zU4Yg7OuUZ1LASAKe1NU9XW78T1OWNKeAR0ZS2Ricf ULSs5WtG1BsDaLX782jH+Oy14OhOvsbrWjz2UTtUmCV5SMS0AnofgeWzKbr4Lf4Acb62 5Qam0PnLzuejFH4F6HMOTCoj+I0e6ehTlp7aaVCOAbVX81oZETPHlvnb7D/46c3i6dK9 Ew4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=we5XgM9D/FaMqpDjAxLlNgitGEtix5X3KZAI9OVXI+Q=; b=HLUeck/bicbDO6+45cWmOBxazId05rfPIl32qaQqt16SUYpM5lYM8kDiwj6AqG7RXw nKqveP290Q2GM7FLK5QUD0K5LHSRmaI0AanrUKpDBlQuqWPJTNo+KSdEwkQDhIw5H/rP 7Mut57tnROCQtdS3y48GcxV7nMDlegpWI6BVjKzGJXgYrD0nBm6wZHrZAUMO/cC/NOSo Bt06pzyfog7MbsjdWFH+PA86FaeBY2refkuaq8HsdJqevhduFjNeTpNTO6n9QJOSc6jf lcttYwjfsAIVBJAjerht/eFsPm2lHkE0jNkKHksa8BEqzesF/J+6ClyQfLoRkT9qQRtU b+tg== X-Gm-Message-State: AOAM5309e0mnFSaqUIn35AY/rWX9kBaLTv9af9kFnb731jEuZFETrX2r VuArjA3lv28j3+wpPSAfOKObTxhuG/vLQ/Lm+It9GpfZ1R9eYP9csrx6VCkuizTjYD+ZQ2PWUaN aTDIf/cdHViAgxiDzpPN7N4u9kbWd/JK1Hu8f0UmjWSbpvgaY7+idASDD1tvKuOeqYRnMYctA65 2Q X-Google-Smtp-Source: ABdhPJyow2D93lYIGorxjwbD2s8L89iJWAb+APXTF4pA4mPd5J1ykxyXrVphQiS1zIk7/zc9eFNYRIqhk88e X-Received: by 2002:a25:38c5:: with SMTP id f188mr28455307yba.132.1596499101772; Mon, 03 Aug 2020 16:58:21 -0700 (PDT) Date: Mon, 3 Aug 2020 16:58:11 -0700 In-Reply-To: <20200803235811.2441774-1-yudiliu@google.com> Message-Id: <20200803165804.RFC.v1.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> Mime-Version: 1.0 References: <20200803235811.2441774-1-yudiliu@google.com> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [RFC PATCH v1 1/1] adapter - D-Bus API for querying the adapter's capability From: Yu Liu <yudiliu@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Archie Pusaka <apusaka@chromium.org>, sonnysasaka@chromium.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 084C44014E X-Rspamd-UID: 184510 From: Archie Pusaka <apusaka@chromium.org> Initially this is introduced to query whether WBS is supported by the adapter, the API is generic enough to be extended to support querying others in the future. Reviewed-by: sonnysasaka@chromium.org --- Changes in v1: - Initial change doc/adapter-api.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt index 1a7255750..250d0e9b3 100644 --- a/doc/adapter-api.txt +++ b/doc/adapter-api.txt @@ -204,6 +204,23 @@ Methods void StartDiscovery() org.bluez.Error.NotReady org.bluez.Error.Failed + dict GetSupportedCapabilities() + + This method returns a dictionary of supported + capabilities that is populated when the adapter + initiated. + + The dictionary is following the format + {capability : value}, where: + + string capability: The supported capability under + discussion. + variant value: A more detailed description of + the capability. + + Possible errors: org.bluez.Error.NotReady + org.bluez.Error.Failed + Properties string Address [readonly] The Bluetooth device address. -- 2.28.0.163.g6104cc2f0b6-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YKKCFtP3KF/6bgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 07:53:23 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2PViFdP3KF88JgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 07:53:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 952E3418AA; Tue, 4 Aug 2020 07:53:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728715AbgHDFxG (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 01:53:06 -0400 Received: from mail-io1-f71.google.com ([209.85.166.71]:56916 "EHLO mail-io1-f71.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728500AbgHDFxG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 01:53:06 -0400 Received: by mail-io1-f71.google.com with SMTP id q20so8011347iod.23 for <linux-bluetooth@vger.kernel.org>; Mon, 03 Aug 2020 22:53:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=BRdtTRPOEaQKBrhbJMVyVg8f+gg0wNhNpfaLQFbDwIc=; b=DRPGVNsLbV9cXXkPP+gHN9qzHCpW6CnrGA2+IZM3B9uOd77EvjB4zbLTs6YQwn/fo5 oNICnTqvsHB4IFwMjD0ucXYW0lqoa8aSjOHW9MFBqWjD6veZmQIzqzRwfZLNglvOzYOT ZPeuQGNIZ1DOou20xRplnFiKJbnSNmv3/WBM+ocNssciU4MeJ684NZbzU2RJgIo2VARY aZmr7uetPxqjYlOGo67NqETWWizy4Xz0qWrpidJHQpOaoLuq7Bq8Ggd18dwNt2oi82i8 LEtPL/hZBUdmNNGDzVU78FJWaUNqGUKEbkrY5lmINhg5xyBNAaQwPXLzIW5i3McHlVyz a1GA== X-Gm-Message-State: AOAM530FWvQxedzcwLED4BlZ6172iBcJnmwn2Xh4NA78Dsfnkote/p3L UjQtV14eEtqnJKZF4bvHkBelxUFRWojJypGRRr9jo18GgNhW X-Google-Smtp-Source: ABdhPJzEkoMCbnNdFUe97FE5HM517BQ0ax1yAE9KKbwZVWX1mKbnq4Vi7DM1AkTvDXzbANiqrkZroxhk4raf2RYgrw3J8jVZ61+P MIME-Version: 1.0 X-Received: by 2002:a6b:e216:: with SMTP id z22mr3305588ioc.97.1596520385235; Mon, 03 Aug 2020 22:53:05 -0700 (PDT) Date: Mon, 03 Aug 2020 22:53:05 -0700 In-Reply-To: <0000000000003d6e8405abeb1da7@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000070529b05ac06deaa@google.com> Subject: Re: KASAN: use-after-free Read in hci_send_acl From: syzbot <syzbot+98228e7407314d2d4ba2@syzkaller.appspotmail.com> To: a@unstable.cc, b.a.t.m.a.n@lists.open-mesh.org, davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, mareklindner@neomailbox.ch, michael.chan@broadcom.com, netdev@vger.kernel.org, sw@simonwunderlich.de, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.37 / 15.00 / 200.00 X-Rspamd-Queue-Id: 952E3418AA X-Rspamd-UID: 2b4fdd syzbot has bisected this issue to: commit 4ffcd582301bd020b1f9d00c55473af305ec19b5 Author: Michael Chan <michael.chan@broadcom.com> Date: Mon Sep 19 07:58:07 2016 +0000 bnxt_en: Pad TX packets below 52 bytes. bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=167b0f04900000 start commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=157b0f04900000 console output: https://syzkaller.appspot.com/x/log.txt?x=117b0f04900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 dashboard link: https://syzkaller.appspot.com/bug?extid=98228e7407314d2d4ba2 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=152f1904900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1482dfca900000 Reported-by: syzbot+98228e7407314d2d4ba2@syzkaller.appspotmail.com Fixes: 4ffcd582301b ("bnxt_en: Pad TX packets below 52 bytes.") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gLWmI7AbKV8JdgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 10:26:24 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id KDcBIrAbKV8D7gEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 10:26:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1CD2E40990; Tue, 4 Aug 2020 10:26:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727821AbgHDI0R (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 04:26:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgHDI0Q (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 04:26:16 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 796D4C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 4 Aug 2020 01:26:16 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id d190so1842202wmd.4 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 01:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZmhpbFxvmBbgjVB2bV0hQ83JX8ki51Di/oiDIdD0E/E=; b=VM3ePbN/e5INfOwzMov5hPHI8qXwyNzrfU00D99uNUq5g8N8fSiddQ+Q1YKOTDYOlM lJoVOe/sZIyO0p7ePv8H6S6zvCU83OmYknSzIARLgFTaGLekMqjDS7tCmsfjcq3GUwZ3 UX8I3ZJaE6ynQabGBF+kN2+I2swIMVp++muao/3uZQEQPiOz5vmMKS5jJS74llPNsZrh vT7Fw3OYki/MRC8cCHmGgRK23shEqlp6/WZ3jh9bG8iu93YmlgsQEVN3KOGZho1Gg1px YI9W9w6DB2k8MshzGl9Wt5CpnTUmZNUqRG/0YUT+dZ2Yo5oSpvfthlxpnxC/OwajdW0q 1pxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZmhpbFxvmBbgjVB2bV0hQ83JX8ki51Di/oiDIdD0E/E=; b=TJTwF0F3/BFY4I6vHIP3JSNI8F3hnCg/Vz5sLIRV+NmHhcKLzh9QIxvvo6B+o0IS3+ 9A2k9BD0vSbEJjPGPTUyF55ZHiT9O2wWblEQ9QUHjSBCP1WROYlsjC8WJAI41Cyf9xWl fGWNBd5ErgJNZUCUcKKrfq0DvuJ/ILqGeTh2PK0qo6a2ZEmZ5EwMk7HGss8BpDrABUF5 VmcosCM+lh22RaK64PygOx7aHiD4UyJLlBf4ECXsanShLWxN/UnZyf1nm6otv2XYTFCq E9HU5wHmP03Xh6OzoPLlGZqkXXHOyiBfZsDTMqqCLuF+Aa+SECd9OhmQ+y8ceGFkaKxQ 5MxA== X-Gm-Message-State: AOAM531UVewj+WBbqohReP4U7u8mzSrU2QyzsUrHWgb35Ug9UWS+Z6qI 26Cu1pq3vT0lid3y2STc+QkIKExzFpeayAmzf9oWMw== X-Google-Smtp-Source: ABdhPJzxN4iIqZdjFRj0uyx+TuEAxJhistbvKxXRT5tSjRUz7X7Ef5mG/jfNrNe8TvjwpNhyDCs61srirly3IKE6+3I= X-Received: by 2002:a1c:9e84:: with SMTP id h126mr2790856wme.61.1596529574769; Tue, 04 Aug 2020 01:26:14 -0700 (PDT) MIME-Version: 1.0 References: <20200708121928.bluez.v2.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> In-Reply-To: <20200708121928.bluez.v2.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> From: Archie Pusaka <apusaka@google.com> Date: Tue, 4 Aug 2020 16:26:03 +0800 Message-ID: <CAJQfnxEBjHMAO=kTqRBExgS40g7=OJbv-NOTE1V=PM=K1sdGcw@mail.gmail.com> Subject: Re: [bluez PATCH v2] avrcp: include all player settings in notif event To: Howard Chung <howardchung@google.com> Cc: BlueZ <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1CD2E40990 X-Rspamd-UID: 18388e Hi Bluez maintainers, Could you take a look at this fix? Thank you! Regards, Archie On Wed, 8 Jul 2020 at 12:19, Howard Chung <howardchung@google.com> wrote: > > According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player > application settings should be returned to the CT and let CT to > determine which settings have changed. Currently bluez only returns > the changed attribute instead. This patch also addresses a potential > issue on which the number of application settings mismatches with > the actual number returned. > > Reviewed-by: Archie Pusaka <apusaka@chromium.org> > --- > > Changes in v2: > - Fixed unused variables > > profiles/audio/avrcp.c | 71 +++++++++++++++++++----------------------- > 1 file changed, 32 insertions(+), 39 deletions(-) > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > index e2428250e..a4de7530e 100644 > --- a/profiles/audio/avrcp.c > +++ b/profiles/audio/avrcp.c > @@ -369,6 +369,7 @@ static uint32_t company_ids[] = { > }; > > static void avrcp_register_notification(struct avrcp *session, uint8_t event); > +static GList *player_list_settings(struct avrcp_player *player); > > static sdp_record_t *avrcp_ct_record(void) > { > @@ -743,6 +744,35 @@ static int play_status_to_val(const char *status) > return -EINVAL; > } > > +static uint16_t player_settings_changed(struct avrcp_player *player, > + struct avrcp_header *pdu) > +{ > + GList *settings = player_list_settings(player); > + int size = 2; > + > + for (; settings; settings = settings->next) { > + const char *key = settings->data; > + int attr; > + int val; > + > + attr = attr_to_val(key); > + if (attr < 0) > + continue; > + > + val = player_get_setting(player, attr); > + if (val < 0) > + continue; > + > + pdu->params[size++] = attr; > + pdu->params[size++] = val; > + } > + > + g_list_free(settings); > + > + pdu->params[1] = (size - 2) >> 1; > + return size; > +} > + > void avrcp_player_event(struct avrcp_player *player, uint8_t id, > const void *data) > { > @@ -751,8 +781,6 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > uint8_t code; > uint16_t size; > GSList *l; > - int attr; > - int val; > > if (player->sessions == NULL) > return; > @@ -791,19 +819,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > size = 1; > break; > case AVRCP_EVENT_SETTINGS_CHANGED: > - size = 2; > - pdu->params[1] = 1; > - > - attr = attr_to_val(data); > - if (attr < 0) > - return; > - > - val = player_get_setting(player, attr); > - if (val < 0) > - return; > - > - pdu->params[size++] = attr; > - pdu->params[size++] = val; > + size = player_settings_changed(player, pdu); > break; > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > size = 5; > @@ -1595,7 +1611,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > struct btd_device *dev = session->dev; > uint16_t len = ntohs(pdu->params_len); > uint64_t uid; > - GList *settings; > > /* > * 1 byte for EventID, 4 bytes for Playback interval but the latest > @@ -1626,29 +1641,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > len = 1; > break; > case AVRCP_EVENT_SETTINGS_CHANGED: > - len = 1; > - settings = player_list_settings(player); > - > - pdu->params[len++] = g_list_length(settings); > - for (; settings; settings = settings->next) { > - const char *key = settings->data; > - int attr; > - int val; > - > - attr = attr_to_val(key); > - if (attr < 0) > - continue; > - > - val = player_get_setting(player, attr); > - if (val < 0) > - continue; > - > - pdu->params[len++] = attr; > - pdu->params[len++] = val; > - } > - > - g_list_free(settings); > - > + len = player_settings_changed(player, pdu); > break; > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > len = 5; > -- > 2.27.0.383.g050319c2ae-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6AAyF+0sKV/y8AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 11:39:57 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id kFEsFe0sKV/KbwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 11:39:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 68F0C418A5; Tue, 4 Aug 2020 11:39:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbgHDJjo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 05:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbgHDJjn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 05:39:43 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FD79C06174A; Tue, 4 Aug 2020 02:39:43 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o13so21818997pgf.0; Tue, 04 Aug 2020 02:39:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lVM8DPgIzaCBPlmdMpwhgrG6jaxJmkvPn7CWbb/dTlA=; b=ZSzidZsFNsMMcg+cnTYShgZHrAbKJaPoiT7zCW38D6fUKoVYti7+S11nWF1L/y22/K 5O7K9aLgn3BSCNFjxZTFrEzTrHmTJHSk8gTaXqXQ1FPLgTWo8DxJUfWESFwARo9lxQ1T uDtL8eOVZcusQBHPWuCd/buOUyrenWARwMZil8qP9aqxHbE+T60lvxWB30PgrSVhno7G CsShOmJJbW+kIOifBJ7v998dwBRt5blF45VskwRTPMGoYvlvMHMSdbZ750T3Qcpx0/BU AKRhsxk14RqUJ0pPO/A05gRWr1+za0kHkGbvc1SmWvfe1N9Vy0q6lS7LzINrAZDgCtrK RUkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lVM8DPgIzaCBPlmdMpwhgrG6jaxJmkvPn7CWbb/dTlA=; b=pA/5rbRlqsrMyXYG1Rq5JJj2tPcPBYztrTnE3/VaODl0k1mJmJRy+Q0Kf/dZ5+++LK edpEbGvHWMFZ3ZNS5XiJ4fLFN0AtE/6HfOzIrMpWUc8Fhg/+qmf5AJFhs2BsjI1xQgOs S3UBEIxf03QpoutBxOgrdO6uYzZowDw5+dRkC95HtpKCaMaJtcBnnhZYmB/NvGrvqkV0 uQMACXSIs1O4QaNsGrYie8SHEpBIIoYgQjTKP468uD6Narl/6bvHwxsQIb6URQOM5nqH v5hfKwpKRMk5r4XNpqL+CMhRzIR0ZGolcyv0vNUKxGuNcQ8meQfmpMX78RIzPaLieRAB ZF8A== X-Gm-Message-State: AOAM5319tNchlbNkcdq9+0zfQePFwAiEmUnzyfTjZVmMnboyWRDeDO2R ELu0rEwZJUN+tlTz22RPam8h8vgMKXX5Iw== X-Google-Smtp-Source: ABdhPJwEx8K2nBJam5PzEaCRjHbdokQrFW8yhQuhwwD2yzjx1fHT5E4IzG/zJp8W+PCj2IQgjapvhw== X-Received: by 2002:a62:2c48:: with SMTP id s69mr19348795pfs.63.1596533982563; Tue, 04 Aug 2020 02:39:42 -0700 (PDT) Received: from localhost ([2001:e42:102:1532:160:16:113:140]) by smtp.gmail.com with ESMTPSA id f3sm3514155pfj.206.2020.08.04.02.39.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2020 02:39:41 -0700 (PDT) From: Coiby Xu <coiby.xu@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com, Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, netdev@vger.kernel.org (open list:NETWORKING [GENERAL]), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] Bluetooth: Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN Date: Tue, 4 Aug 2020 17:39:37 +0800 Message-Id: <20200804093937.772961-1-coiby.xu@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.70 / 15.00 / 200.00 X-Rspamd-Queue-Id: 68F0C418A5 X-Rspamd-UID: 894f20 When L2CAP channel is destroyed by hci_unregister_dev, it will acquire the spin lock of the (struct l2cap_chan *)->tx_q list to delete all the buffers. But sometimes when hci_unregister_dev is being called, this lock may have not bee initialized. Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN to fix this problem. Reported-by: syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=fadfba6a911f6bf71842 Signed-off-by: Coiby Xu <coiby.xu@gmail.com> --- net/bluetooth/6lowpan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index bb55d92691b0..713c618a73df 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -651,6 +651,7 @@ static struct l2cap_chan *chan_create(void) l2cap_chan_set_defaults(chan); + skb_queue_head_init(&chan->tx_q); chan->chan_type = L2CAP_CHAN_CONN_ORIENTED; chan->mode = L2CAP_MODE_LE_FLOWCTL; chan->imtu = 1280; -- 2.27.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EOSUK8AtKV9uqgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 11:43:28 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id MKX2KcAtKV9GzwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 11:43:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=kroah.com header.b=nAtgpS7L; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=efU+VnGc X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B3254A2C04; Tue, 4 Aug 2020 11:43:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726841AbgHDJnO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 05:43:14 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:56981 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbgHDJnO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 05:43:14 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 0BC6B5C0200; Tue, 4 Aug 2020 05:43:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 04 Aug 2020 05:43:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=cjBmqIM9+5mv2uiP07cYDoPaonT iqBxD1XI04vEZs68=; b=nAtgpS7LWMG6/2CgXZn0XgBEo6SGNf+0Zmx5YLC5lL0 bOPCXbcOONVwb9ClrSXuAz3AeQ7R0tfCr5bpkVCfx1du1sPga3uoFh58mpwuoq3J uH7Mss1O/rqWwulrZFXlfkemagThxzbJkm5W4klZRUQUZmlAPKSV/gIPvcWpRdMM f9mVKNsdiopykUjx/QEBrpWhdF2VlIfNoiiFaFqO/BlxwNtL8uTTtKfI20CPGIun Fys7cxmLZ4SbgHuQFDBoYYWK/tz6MW0qCJyeYOWdFNArEeKqy9hKaQua+3vJbCjr VTfkVE5CuSRqzM55v9VxVRDxboR5wfvY2ULpsfOKuKA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=cjBmqI M9+5mv2uiP07cYDoPaonTiqBxD1XI04vEZs68=; b=efU+VnGc/SEcIFLkan12oR 6ey8zxF5TlXEi9+e2D9/pdQECvxXRT04hGehE6xKVxJZRdusFuFNswe6JgqCgVO3 pN0RwNn2j1yggX3kMx1+BNiX0GKxo3qWTs6MFZD8iCxpXZbAWc3hSFyAKIWjU64N 8WPoX7HQzhevn2OuK4eNRTgQLLXXznnYeRpruwSDz8gTSSI0BJQA8P9MbIR/omWV 479PXZhxsYdjp5YYTmsVUX+6KZ1IQT9UKoYstHu8cT2alLr0XQ5Vz+IBiVgOiH9j pqygEDDcz5Qx8v3VjtSwzdUpwcwgSPs1JvCN+MnRxxGwPkIFyeDr/tSjJsSdAHLg == X-ME-Sender: <xms:sC0pX5ce8V0YCMHf-IPaCTLG7jEve0j_XrdmaEX0Gs-S_cx03oT1yA> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrjeeigddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenog fuuhhsphgvtghtffhomhgrihhnucdlgeelmdenucfjughrpeffhffvuffkfhggtggujges thdtredttddtvdenucfhrhhomhepifhrvghgucfmjfcuoehgrhgvgheskhhrohgrhhdrtg homheqnecuggftrfgrthhtvghrnhepfeefteeuhfffleehvddtleejudekiedthfejjedt tdetkefgledtvdejgfeuteefnecuffhomhgrihhnpegrphhpshhpohhtrdgtohhmnecukf hppeekfedrkeeirdekledruddtjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehgrhgvgheskhhrohgrhhdrtghomh X-ME-Proxy: <xmx:sC0pX3PMTw5qwCJgqnXtEGgRncmFEn821-QMPRsSO6leY07HjDQdLg> <xmx:sC0pXyi3DfWtNMKPBN0-4DtyG9msFx-6ZXSCNtAfIPOC3vtGnHFabA> <xmx:sC0pXy9YKHdOVX4EnfjJEN-15W-EIbc_Tmp3EvEvTvqGxcACPpid6A> <xmx:sS0pX5hXT-Q3wCBEx5lmxkto-WSQAtmnHhrPn0T6Bui5Rn67LaSLsw> Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 2741930600A3; Tue, 4 Aug 2020 05:43:12 -0400 (EDT) Date: Tue, 4 Aug 2020 11:42:53 +0200 From: Greg KH <greg@kroah.com> To: Coiby Xu <coiby.xu@gmail.com> Cc: linux-bluetooth@vger.kernel.org, Johan Hedberg <johan.hedberg@gmail.com>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, open list <linux-kernel@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org>, syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com, linux-kernel-mentees@lists.linuxfoundation.org, "David S. Miller" <davem@davemloft.net> Subject: Re: [Linux-kernel-mentees] [PATCH] Bluetooth: Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN Message-ID: <20200804094253.GA2667430@kroah.com> References: <20200804093937.772961-1-coiby.xu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200804093937.772961-1-coiby.xu@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.46 / 15.00 / 200.00 X-Rspamd-Queue-Id: B3254A2C04 X-Rspamd-UID: 3b994f On Tue, Aug 04, 2020 at 05:39:37PM +0800, Coiby Xu wrote: > When L2CAP channel is destroyed by hci_unregister_dev, it will > acquire the spin lock of the (struct l2cap_chan *)->tx_q list to > delete all the buffers. But sometimes when hci_unregister_dev is > being called, this lock may have not bee initialized. Initialize > the TX queue lock when creating struct l2cap_chan in 6LOWPAN to fix > this problem. > > Reported-by: syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com > Link: https://syzkaller.appspot.com/bug?extid=fadfba6a911f6bf71842 > Signed-off-by: Coiby Xu <coiby.xu@gmail.com> > --- > net/bluetooth/6lowpan.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c > index bb55d92691b0..713c618a73df 100644 > --- a/net/bluetooth/6lowpan.c > +++ b/net/bluetooth/6lowpan.c > @@ -651,6 +651,7 @@ static struct l2cap_chan *chan_create(void) > > l2cap_chan_set_defaults(chan); > > + skb_queue_head_init(&chan->tx_q); > chan->chan_type = L2CAP_CHAN_CONN_ORIENTED; > chan->mode = L2CAP_MODE_LE_FLOWCTL; > chan->imtu = 1280; Nice, did syzbot verify that this resolves the issue? thanks, greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4L9CLH47KV+fWQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 12:42:06 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WLD0Kn47KV8pBQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 12:42:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CA9FAA1977; Tue, 4 Aug 2020 12:41:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729620AbgHDKly (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 06:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728170AbgHDKly (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 06:41:54 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9C0EC06174A; Tue, 4 Aug 2020 03:41:53 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id u185so19967793pfu.1; Tue, 04 Aug 2020 03:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=dS+3+hYqZ66uBhMhwpE9mDgfqdGREXxXTLcJTBg38DQ=; b=gOMIs+Ulxkf/Kb2dkPeZGEn2TCWU8Lgw9SjOnGHaKWjSB8ENZ356Iq+3vmqhD/sbdQ OFQEoTVcWkrtOfczN3+xZOKCe+ic3JN0BHmTzaB/L7V38v7JFRy9/AJJ3uAPymKpGSP5 h3Ok5CKfbYEWt4mN46WHUaN6g0HyTzjs65bjQPPAN3OpYKvrKKKxBcjIN1xtfDD8+DMe ETEwyXFWsSV3J/4pa5bGRR3mcl4N93gr5bNoAa0TZQHmvDp1IevU1FY87ujtQp4vtNlW ZYYGWlhl5el9PAqgdXCvpmfP5CPt7ITxnzsY4hB36NW5H121wgn+tZIpkoOwJNosbMs4 iepA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dS+3+hYqZ66uBhMhwpE9mDgfqdGREXxXTLcJTBg38DQ=; b=MWD1PMjcyXjzeFcw+3ucQqXq4nSqQ5WT0/wF9OoF+huGktoR3F5ZfC0O3EQEbZNbqj D6LsW9bqsaAMKp2/7j8tqI2VAJ93kHnwRMldhU9D5GMt6s8GzqytHcuE6Y1z9wQFGN5p 0m4wu+/zKcRgWNRUcZZJk+ATi73X1IAOl7nj8f6t6HWEeOunZrY/dma1SF5hMxmZ0ofg kc4F41a5r/U0sx/TqBvat6Pq9lB2Am+eulnind+CxkVcw18RIbSiI2/KlAeW1kWkm/IQ KBGnp0HyWNzr/im45sQ0NkxldWvj57D05Ar7BBTK16KFgsX28Z43INt0knzqoPpmkCCZ OECw== X-Gm-Message-State: AOAM532p9xs+HS2zH50zVnWxM7fvJEJlnOfZv2ORGMmUEX4cmjyZFh0d arwpGFaL2nrQYB2At+CkT3g= X-Google-Smtp-Source: ABdhPJwVkry725oBjqKvwKBp+5Fi90O4GOYmW5vJcWNN4EmW2jkEGBAC9qAjuPvRaCJloMFFEN8n8A== X-Received: by 2002:a63:1208:: with SMTP id h8mr18942187pgl.128.1596537713384; Tue, 04 Aug 2020 03:41:53 -0700 (PDT) Received: from localhost ([2001:e42:102:1532:160:16:113:140]) by smtp.gmail.com with ESMTPSA id t63sm15210765pgt.50.2020.08.04.03.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2020 03:41:52 -0700 (PDT) From: Coiby Xu <coiby.xu@gmail.com> X-Google-Original-From: Coiby Xu <Coiby.Xu@gmail.com> Date: Tue, 4 Aug 2020 18:41:48 +0800 To: Greg KH <greg@kroah.com> Cc: linux-bluetooth@vger.kernel.org, Johan Hedberg <johan.hedberg@gmail.com>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, open list <linux-kernel@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org>, syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com, linux-kernel-mentees@lists.linuxfoundation.org, "David S. Miller" <davem@davemloft.net> Subject: Re: [Linux-kernel-mentees] [PATCH] Bluetooth: Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN Message-ID: <20200804104148.nqxcy4f44uga7wjs@Rk> References: <20200804093937.772961-1-coiby.xu@gmail.com> <20200804094253.GA2667430@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200804094253.GA2667430@kroah.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.20 / 15.00 / 200.00 X-Rspamd-Queue-Id: CA9FAA1977 X-Rspamd-UID: 43594c On Tue, Aug 04, 2020 at 11:42:53AM +0200, Greg KH wrote: >On Tue, Aug 04, 2020 at 05:39:37PM +0800, Coiby Xu wrote: >> When L2CAP channel is destroyed by hci_unregister_dev, it will >> acquire the spin lock of the (struct l2cap_chan *)->tx_q list to >> delete all the buffers. But sometimes when hci_unregister_dev is >> being called, this lock may have not bee initialized. Initialize >> the TX queue lock when creating struct l2cap_chan in 6LOWPAN to fix >> this problem. >> >> Reported-by: syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com >> Link: https://syzkaller.appspot.com/bug?extid=fadfba6a911f6bf71842 >> Signed-off-by: Coiby Xu <coiby.xu@gmail.com> >> --- >> net/bluetooth/6lowpan.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c >> index bb55d92691b0..713c618a73df 100644 >> --- a/net/bluetooth/6lowpan.c >> +++ b/net/bluetooth/6lowpan.c >> @@ -651,6 +651,7 @@ static struct l2cap_chan *chan_create(void) >> >> l2cap_chan_set_defaults(chan); >> >> + skb_queue_head_init(&chan->tx_q); >> chan->chan_type = L2CAP_CHAN_CONN_ORIENTED; >> chan->mode = L2CAP_MODE_LE_FLOWCTL; >> chan->imtu = 1280; > >Nice, did syzbot verify that this resolves the issue? > >thanks, > >greg k-h Yes. Thank you for reminding me. I'll also add an Tested-by: tag next time. -- Best regards, Coiby Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kIZyNTdcKV8aYwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 15:01:43 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oPiwMzdcKV/V3gAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 15:01:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DA60AA2BD3; Tue, 4 Aug 2020 15:01:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726210AbgHDNBa (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 09:01:30 -0400 Received: from mail-il1-f200.google.com ([209.85.166.200]:43631 "EHLO mail-il1-f200.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726954AbgHDNBH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 09:01:07 -0400 Received: by mail-il1-f200.google.com with SMTP id f131so9178393ilh.10 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 06:01:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=06+82rKMp3PGXLDD6Ap7gC365MaLMsLGY5Rl6STa3zE=; b=KGCXRJ6z2NnWqsTugSoBZEddg3by2lWWN+Kz5wRJbnRRo8mmGjU2jK5jplndO2Vh9W BlyyOdkby3QpZqdaczb5f3pfHNh5SOOcBD1uZRRyskqJmkf1O1b3RGOvojrzRcUSASND rpRJRIHe/6Ai6QSPX/nKjGSBVMy9HePVb+Geh3sQaTFCU3R8fBqTQ5c45dHPBvnBSyx2 sMEq6e/E2BoMX7bqOlPfkk3RL59K2F/zGBO41uRITcZ99FEB2Y89UMXlMmv2Xo4iXDQb ynFwW+53fjNGiAkQNEPRljb4XIIXep5nDZNadR7ktWGFOnnF0wXyi8pXSNKTc2Scpj/F cZOQ== X-Gm-Message-State: AOAM531w39pO3Y6IOapS07GTBZUDzhssAXhsVQNdvk2nnnOlr98hSq74 0zzzpnZ0HwRb655VM6wchh4CMhr81EUNEBa7BB0osIRq0vt2 X-Google-Smtp-Source: ABdhPJysIn/3rq8mJzFBZcPdgkiq5Vci73yhB6VXvAfDq6syCOUZWs4ErkDjGmgAWbCV304S/arGJe8W97c4vCtTU2PHRCJr/z6K MIME-Version: 1.0 X-Received: by 2002:a05:6e02:d51:: with SMTP id h17mr4320234ilj.155.1596546066783; Tue, 04 Aug 2020 06:01:06 -0700 (PDT) Date: Tue, 04 Aug 2020 06:01:06 -0700 In-Reply-To: <000000000000a7eb5e05abeb197d@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000002da68705ac0cd9ab@google.com> Subject: Re: general protection fault in hci_event_packet From: syzbot <syzbot+0bef568258653cff272f@syzkaller.appspotmail.com> To: a@unstable.cc, b.a.t.m.a.n@lists.open-mesh.org, davem@davemloft.net, geert@linux-m68k.org, javier@osg.samsung.com, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@armlinux.org.uk, marcel@holtmann.org, mareklindner@neomailbox.ch, netdev@vger.kernel.org, sw@simonwunderlich.de, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.46 / 15.00 / 200.00 X-Rspamd-Queue-Id: DA60AA2BD3 X-Rspamd-UID: a26438 syzbot has bisected this issue to: commit 941992d2944789641470626e9336d663236b1d28 Author: Javier Martinez Canillas <javier@osg.samsung.com> Date: Mon Sep 12 14:03:34 2016 +0000 ethernet: amd: use IS_ENABLED() instead of checking for built-in or module bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=155180c2900000 start commit: bcf87687 Linux 5.8 git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=175180c2900000 console output: https://syzkaller.appspot.com/x/log.txt?x=135180c2900000 kernel config: https://syzkaller.appspot.com/x/.config?x=4b489d75d0c8859d dashboard link: https://syzkaller.appspot.com/bug?extid=0bef568258653cff272f syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1043af04900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12ca1dea900000 Reported-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Fixes: 941992d29447 ("ethernet: amd: use IS_ENABLED() instead of checking for built-in or module") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sJFMF56CKV+F/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 17:45:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ANqrFZ6CKV+jtQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 17:45:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 169DCA1BF8; Tue, 4 Aug 2020 17:45:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728813AbgHDPp1 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 11:45:27 -0400 Received: from mail-io1-f70.google.com ([209.85.166.70]:51624 "EHLO mail-io1-f70.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728678AbgHDPpV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 11:45:21 -0400 Received: by mail-io1-f70.google.com with SMTP id l1so29338992ioh.18 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 08:45:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=teHlcAYbi+ok/LTx4VJANdq80jBucOESYR39MhGarW8=; b=hkCzFg2P8vhl1QY310hbFWBRt2+0/Ek93zQpiafw6ozIwR1OUYXGt0+aXFF8xGPx3P AWnfOQ3gsDMMAQYaHUP6KQbI+qu0/SlWJwjwt2KWJJ/SxYoGgwZTRMBFq4sRPagEHptk xar9d6vlwvFVyVmTERdKOFjF51lZLCVHWk+Yh843Il/zmwKgMiKVcFjU/JX4eam9E821 d3djmLVfp8gyDa/EVQOnvHK4h4JW7gsgi4ApjPuUJ2DWKe8c1GtKt285NRoNDH6K9gLD PF+IQIo0vw6ce2S05A6o9SgvIbBbxMC+6UShnxsq4iEbcRPY6aIf+t4GghsjOyp5SBuA 15aQ== X-Gm-Message-State: AOAM530NooAACs8INil5iScEBEaA6K7nP+R0m0Xk/Nfmul/XegLdTeOY JsHc7Ky80+x5OP/MmcTJpuX76kulDuizzcGiEQQjiDYWIMgo X-Google-Smtp-Source: ABdhPJzA7NgNLQAjeEjq1AEqh5bI5S7LSZJoBvLtJPvmA0EXPKSKEh5jxuv4jBfYNKZaoAZhgDqz5TmU+M4IzRrWIjmR9mk3Skp0 MIME-Version: 1.0 X-Received: by 2002:a92:9910:: with SMTP id p16mr5384051ili.51.1596555919572; Tue, 04 Aug 2020 08:45:19 -0700 (PDT) Date: Tue, 04 Aug 2020 08:45:19 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000734f2505ac0f2426@google.com> Subject: KASAN: use-after-free Write in hci_conn_del From: syzbot <syzbot+7b1677fecb5976b0a099@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.21 / 15.00 / 200.00 X-Rspamd-Queue-Id: 169DCA1BF8 X-Rspamd-UID: 61bc06 Hello, syzbot found the following issue on: HEAD commit: bcf87687 Linux 5.8 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=14184392900000 kernel config: https://syzkaller.appspot.com/x/.config?x=19b11af1e394136d dashboard link: https://syzkaller.appspot.com/bug?extid=7b1677fecb5976b0a099 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15e1ff04900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+7b1677fecb5976b0a099@syzkaller.appspotmail.com ================================================================== BUG: KASAN: use-after-free in hci_conn_del+0x64e/0x6a0 net/bluetooth/hci_conn.c:630 Write of size 8 at addr ffff888089f54938 by task syz-executor.1/6870 CPU: 0 PID: 6870 Comm: syz-executor.1 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530 hci_conn_del+0x64e/0x6a0 net/bluetooth/hci_conn.c:630 hci_conn_hash_flush+0x189/0x220 net/bluetooth/hci_conn.c:1537 hci_dev_do_close+0x5c6/0x1080 net/bluetooth/hci_core.c:1761 hci_unregister_dev+0x1a3/0xe20 net/bluetooth/hci_core.c:3606 vhci_release+0x70/0xe0 drivers/bluetooth/hci_vhci.c:340 __fput+0x33c/0x880 fs/file_table.c:281 task_work_run+0xdd/0x190 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0xb72/0x2a40 kernel/exit.c:805 do_group_exit+0x125/0x310 kernel/exit.c:903 __do_sys_exit_group kernel/exit.c:914 [inline] __se_sys_exit_group kernel/exit.c:912 [inline] __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:912 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x45cce9 Code: Bad RIP value. RSP: 002b:00007ffd598b2c88 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000045cce9 RDX: 0000000000416741 RSI: 0000000000ca85f0 RDI: 0000000000000043 RBP: 00000000004c2983 R08: 000000000000000b R09: 0000000000000000 R10: 0000000002936940 R11: 0000000000000246 R12: 0000000000000008 R13: 00007ffd598b2dd0 R14: 0000000000136032 R15: 00007ffd598b2de0 Allocated by task 12376: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494 __do_kmalloc mm/slab.c:3656 [inline] __kmalloc+0x17a/0x340 mm/slab.c:3665 kmalloc include/linux/slab.h:560 [inline] tomoyo_realpath_from_path+0xc3/0x620 security/tomoyo/realpath.c:254 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x272/0x380 security/tomoyo/file.c:771 tomoyo_file_open security/tomoyo/tomoyo.c:313 [inline] tomoyo_file_open+0xa3/0xd0 security/tomoyo/tomoyo.c:308 security_file_open+0x52/0x3f0 security/security.c:1574 do_dentry_open+0x3a0/0x1290 fs/open.c:815 do_open fs/namei.c:3243 [inline] path_openat+0x1bb9/0x2750 fs/namei.c:3360 do_filp_open+0x17e/0x3c0 fs/namei.c:3387 do_sys_openat2+0x16f/0x3b0 fs/open.c:1179 do_sys_open fs/open.c:1195 [inline] ksys_open include/linux/syscalls.h:1388 [inline] __do_sys_open fs/open.c:1201 [inline] __se_sys_open fs/open.c:1199 [inline] __x64_sys_open+0x119/0x1c0 fs/open.c:1199 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 12376: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x103/0x2c0 mm/slab.c:3757 tomoyo_realpath_from_path+0x191/0x620 security/tomoyo/realpath.c:291 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x272/0x380 security/tomoyo/file.c:771 tomoyo_file_open security/tomoyo/tomoyo.c:313 [inline] tomoyo_file_open+0xa3/0xd0 security/tomoyo/tomoyo.c:308 security_file_open+0x52/0x3f0 security/security.c:1574 do_dentry_open+0x3a0/0x1290 fs/open.c:815 do_open fs/namei.c:3243 [inline] path_openat+0x1bb9/0x2750 fs/namei.c:3360 do_filp_open+0x17e/0x3c0 fs/namei.c:3387 do_sys_openat2+0x16f/0x3b0 fs/open.c:1179 do_sys_open fs/open.c:1195 [inline] ksys_open include/linux/syscalls.h:1388 [inline] __do_sys_open fs/open.c:1201 [inline] __se_sys_open fs/open.c:1199 [inline] __x64_sys_open+0x119/0x1c0 fs/open.c:1199 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff888089f54000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 2360 bytes inside of 4096-byte region [ffff888089f54000, ffff888089f55000) The buggy address belongs to the page: page:ffffea000227d500 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea000227d500 order:1 compound_mapcount:0 flags: 0xfffe0000010200(slab|head) raw: 00fffe0000010200 ffffea0001e59308 ffffea00028b3908 ffff8880aa002000 raw: 0000000000000000 ffff888089f54000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888089f54800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888089f54880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888089f54900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888089f54980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888089f54a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uCI6DteCKV/NbAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 17:46:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YLyQDNeCKV9ZvwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 17:46:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1A8B940872; Tue, 4 Aug 2020 17:46:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728048AbgHDPqY (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 11:46:24 -0400 Received: from mail-il1-f198.google.com ([209.85.166.198]:46706 "EHLO mail-il1-f198.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbgHDPqV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 11:46:21 -0400 Received: by mail-il1-f198.google.com with SMTP id p89so1017094ilb.13 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 08:46:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=6DIGHsfagDAKp/ULUYoRigrhDRxL/hgZYQkhUVMz60M=; b=CM7I8hmNvZJ2OUaFyPxl0jO1rFp7uRzZCxbcvo4go3XANJLnwQGSRypRdOgDbWt02L SR+Yr2w0NgbN9onMoFYrz2wJcuiremHx5W+0JBMtM4p2G3lglTdAtV1D0wXkJyb831rK 3pWOYh0FW+virlWgFfmcBoQdYVUijXy6/y3yVVNgln+xp+8VTHBs5Y1ktSIpuiDPQUS+ mpgYcXRDT3mGraCqIH4nmQHu5y/WxMOQrtG95twipRp1xDEVcObqZ4GUAIdcqBTyoUUe bqoM2PNV8+2D2oOi96VQPJpGi2CGuxGRSazeX2yMhnpMQjbL5+Nug48xxJuYl6gFnbd2 oS5A== X-Gm-Message-State: AOAM533U83Z0UOd3RJaP7eioIUcRpLxCKg2R1j3tfoHzilZojeWSPDv5 aboTioTeeeaoRHs08pQ0bBUZbFp4OySSQ40KDH/bryVa87gk X-Google-Smtp-Source: ABdhPJwREH5djPThxSKSlsh2hZXG0gUc6T8OaJnHQpaUn8wwW0H6qM9YYvSOZhhGKa36+anYlyxP3/n0XA3MFh4u/NGsX+q9GZiB MIME-Version: 1.0 X-Received: by 2002:a92:9106:: with SMTP id t6mr5721334ild.105.1596555980358; Tue, 04 Aug 2020 08:46:20 -0700 (PDT) Date: Tue, 04 Aug 2020 08:46:20 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000012cbe905ac0f28c1@google.com> Subject: KASAN: use-after-free Read in __sco_sock_close From: syzbot <syzbot+a9b58a6aa2a3e1d37f87@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1A8B940872 X-Rspamd-UID: e9c12d Hello, syzbot found the following issue on: HEAD commit: bcf87687 Linux 5.8 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=107dbe0a900000 kernel config: https://syzkaller.appspot.com/x/.config?x=4b489d75d0c8859d dashboard link: https://syzkaller.appspot.com/bug?extid=a9b58a6aa2a3e1d37f87 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=145f6342900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+a9b58a6aa2a3e1d37f87@syzkaller.appspotmail.com ================================================================== BUG: KASAN: use-after-free in debug_spin_lock_before kernel/locking/spinlock_debug.c:83 [inline] BUG: KASAN: use-after-free in do_raw_spin_lock+0x5e1/0x800 kernel/locking/spinlock_debug.c:112 Read of size 4 at addr ffff8880a74d4e8c by task syz-executor.5/18383 CPU: 1 PID: 18383 Comm: syz-executor.5 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 print_address_description+0x66/0x5a0 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report+0x132/0x1d0 mm/kasan/report.c:530 debug_spin_lock_before kernel/locking/spinlock_debug.c:83 [inline] do_raw_spin_lock+0x5e1/0x800 kernel/locking/spinlock_debug.c:112 spin_lock include/linux/spinlock.h:353 [inline] sco_chan_del net/bluetooth/sco.c:142 [inline] __sco_sock_close+0x408/0xed0 net/bluetooth/sco.c:433 sco_sock_close net/bluetooth/sco.c:447 [inline] sco_sock_release+0x63/0x4f0 net/bluetooth/sco.c:1021 __sock_release net/socket.c:605 [inline] sock_close+0xd8/0x260 net/socket.c:1278 __fput+0x2f0/0x750 fs/file_table.c:281 task_work_run+0x137/0x1c0 kernel/task_work.c:135 get_signal+0x15ab/0x1d30 kernel/signal.c:2547 do_signal+0x33/0x610 arch/x86/kernel/signal.c:810 exit_to_usermode_loop arch/x86/entry/common.c:235 [inline] __prepare_exit_to_usermode+0xd7/0x1e0 arch/x86/entry/common.c:269 do_syscall_64+0x7f/0xe0 arch/x86/entry/common.c:393 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x45cce9 Code: 2d b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb b5 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007ff2665afc78 EFLAGS: 00000246 ORIG_RAX: 000000000000002a RAX: fffffffffffffffc RBX: 0000000000002140 RCX: 000000000045cce9 RDX: 0000000000000008 RSI: 0000000020000000 RDI: 0000000000000006 RBP: 000000000078bf40 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 000000000078bf0c R13: 00007ffdf046a56f R14: 00007ff2665b09c0 R15: 000000000078bf0c Allocated by task 18383: save_stack mm/kasan/common.c:48 [inline] set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494 kmem_cache_alloc_trace+0x234/0x300 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] sco_conn_add net/bluetooth/sco.c:112 [inline] sco_connect net/bluetooth/sco.c:247 [inline] sco_sock_connect+0x3c6/0xaa0 net/bluetooth/sco.c:576 __sys_connect_file net/socket.c:1854 [inline] __sys_connect+0x2da/0x360 net/socket.c:1871 __do_sys_connect net/socket.c:1882 [inline] __se_sys_connect net/socket.c:1879 [inline] __x64_sys_connect+0x76/0x80 net/socket.c:1879 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 8113: save_stack mm/kasan/common.c:48 [inline] set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0x114/0x170 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x10a/0x220 mm/slab.c:3757 sco_connect_cfm+0x96/0x7e0 net/bluetooth/sco.c:1136 hci_connect_cfm include/net/bluetooth/hci_core.h:1340 [inline] hci_sco_setup+0xf0/0x3e0 net/bluetooth/hci_conn.c:399 hci_conn_complete_evt net/bluetooth/hci_event.c:2641 [inline] hci_event_packet+0x1258e/0x18260 net/bluetooth/hci_event.c:6033 hci_rx_work+0x236/0x9c0 net/bluetooth/hci_core.c:4705 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 The buggy address belongs to the object at ffff8880a74d4e80 which belongs to the cache kmalloc-96 of size 96 The buggy address is located 12 bytes inside of 96-byte region [ffff8880a74d4e80, ffff8880a74d4ee0) The buggy address belongs to the page: page:ffffea00029d3500 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00023cae88 ffffea000288c588 ffff8880aa400540 raw: 0000000000000000 ffff8880a74d4000 0000000100000020 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880a74d4d80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff8880a74d4e00: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc >ffff8880a74d4e80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff8880a74d4f00: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc ffff8880a74d4f80: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc ================================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IBRDLkODKV+F/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 17:48:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QNyOLEODKV+qLQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 17:48:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=mnmoran.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A057F4178E; Tue, 4 Aug 2020 17:48:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728244AbgHDPsN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 11:48:13 -0400 Received: from hoster906.com ([192.252.156.27]:33310 "EHLO hoster906.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726276AbgHDPsM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 11:48:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mnmoran.org; h=from:to :cc:subject:date:message-id:mime-version :content-transfer-encoding; s=dkim; bh=JeWBNCglrPXMkIDFXHpQ7uegi 0IUk9cEgkTv06h0Heg=; b=B+aiKcEs5O6UCKy/8F0az4QUeFallvFYzz511zfvh SJeFlSS3lnpT0/LdSMsTlrey7/HoqCH8XLlsfhQ/Iv6uJT2Iqxdo24B7U0UUFW70 PD3ftlertvlhFFQyx6z23xalBSFGWWmUU9yFMW4HFQKsiYhZFGe3uVTBhOSuw+X8 HA= Received: (qmail 29229 invoked by uid 503); 4 Aug 2020 15:48:11 -0000 Received: from unknown (HELO knuckle.Home) (mike@mnmoran.org@162.39.210.203) by hoster906.com with ESMTPA; 4 Aug 2020 15:48:11 -0000 From: "Michael N. Moran" <mike@mnmoran.org> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, inga.stotland@intel.com, "Michael N. Moran" <mike@mnmoran.org> Subject: [PATCH v3] Checkpoint Bluetooth Mesh. Date: Tue, 4 Aug 2020 11:47:58 -0400 Message-Id: <20200804154758.1086522-1-mike@mnmoran.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: A057F4178E X-Rspamd-UID: 607fe9 --- rpi/libdirs.b | 2 ++ rpi/notes | 29 ----------------------------- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/rpi/libdirs.b b/rpi/libdirs.b index bf34b9b..f340ed9 100644 --- a/rpi/libdirs.b +++ b/rpi/libdirs.b @@ -1,2 +1,4 @@ +src/oscl/buffer +src/oscl/platform/posix/oscl/kernel/platform +src/mnm/btmesh/libdirs.b diff --git a/rpi/notes b/rpi/notes index 544184a..e69de29 100644 --- a/rpi/notes +++ b/rpi/notes @@ -1,29 +0,0 @@ -[0] HCI_COMMAND_PKT -[1-2] HCI_CMD_LE_SET_ADV_DATA -[3] length Number of significant octets in data - -struct bt_hci_cmd_le_set_adv_data { -[3] uint8_t len; -[4-?] uint8_t data[31]; -} __attribute__ ((packed)); - -HCI_COMMAND_PKT - -struct ad_struct { - uint8_t len; sizeof(ad.type)+sizeof(pb_adv_pdu)+pdu_len - uint8_t type; - uint8_t data[] -} - -struct pb_adv_pdu { pbadv* - uint32_t link_id; - uint8_t trans_num; - pdu[] - } - -////////// -HCI_CMD_LE_SET_ADV_ENABLE -struct bt_hci_cmd_le_set_adv_enable { - uint8_t enable; -} - -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8GbgMb2DKV+F/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 17:50:21 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wPB9ML2DKV9+4gEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 17:50:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=mnmoran.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6650140507; Tue, 4 Aug 2020 17:50:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728678AbgHDPuO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 11:50:14 -0400 Received: from hoster906.com ([192.252.156.27]:33422 "EHLO hoster906.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728467AbgHDPuO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 11:50:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mnmoran.org; h=subject :to:cc:references:from:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; s=dkim; bh=KUzPGjgFdmTe MjE9x68YrAgI6gQ33T8A1Sxd6wkaRT8=; b=1P6OdhnoKFljtq8bfjNJJ0WkeKtX +3Hk9BvSKSlnAYJPNegNHuMHJBl6gIyPYaNCtPkWIeNw2iH3Rjmv4naon8/UajKB jy7+0vi4dDUvEw1TJI3QhutxKxFjAITuBoGONlZlyjdPd9KXrVLIpY0Oo46dT+GI M1FDmlelwfWIJJE= Received: (qmail 32015 invoked by uid 503); 4 Aug 2020 15:50:13 -0000 Received: from unknown (HELO ?192.168.254.79?) (mike@mnmoran.org@162.39.210.203) by hoster906.com with ESMTPA; 4 Aug 2020 15:50:13 -0000 Subject: Re: [PATCH v3] Checkpoint Bluetooth Mesh. To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, inga.stotland@intel.com References: <20200804154758.1086522-1-mike@mnmoran.org> From: "Michael N. Moran" <mike@mnmoran.org> Message-ID: <355b50ed-e82f-a0df-0447-eaf0e113cec4@mnmoran.org> Date: Tue, 4 Aug 2020 11:50:12 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200804154758.1086522-1-mike@mnmoran.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6650140507 X-Rspamd-UID: 11ec0f Humble appologies. GIT send-email n00b at work. Please ignore these On 8/4/20 11:47 AM, Michael N. Moran wrote: > --- > rpi/libdirs.b | 2 ++ > rpi/notes | 29 ----------------------------- > 2 files changed, 2 insertions(+), 29 deletions(-) > > diff --git a/rpi/libdirs.b b/rpi/libdirs.b > index bf34b9b..f340ed9 100644 > --- a/rpi/libdirs.b > +++ b/rpi/libdirs.b > @@ -1,2 +1,4 @@ > +src/oscl/buffer > +src/oscl/platform/posix/oscl/kernel/platform > +src/mnm/btmesh/libdirs.b > > diff --git a/rpi/notes b/rpi/notes > index 544184a..e69de29 100644 > --- a/rpi/notes > +++ b/rpi/notes > @@ -1,29 +0,0 @@ > -[0] HCI_COMMAND_PKT > -[1-2] HCI_CMD_LE_SET_ADV_DATA > -[3] length Number of significant octets in data > - > -struct bt_hci_cmd_le_set_adv_data { > -[3] uint8_t len; > -[4-?] uint8_t data[31]; > -} __attribute__ ((packed)); > - > -HCI_COMMAND_PKT > - > -struct ad_struct { > - uint8_t len; sizeof(ad.type)+sizeof(pb_adv_pdu)+pdu_len > - uint8_t type; > - uint8_t data[] > -} > - > -struct pb_adv_pdu { pbadv* > - uint32_t link_id; > - uint8_t trans_num; > - pdu[] > - } > - > -////////// > -HCI_CMD_LE_SET_ADV_ENABLE > -struct bt_hci_cmd_le_set_adv_enable { > - uint8_t enable; > -} > - > -- Michael N. Moran (h) 770 704 9751 218 Wilshire Terrace (c) 678 521 5460 White, GA, USA 30184 http://mnmoran.org Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QHYdGM2EKV/NbAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 17:54:53 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 4K43Fs2EKV9s4QEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 17:54:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=mnmoran.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CD5A140180; Tue, 4 Aug 2020 17:54:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728945AbgHDPyp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 11:54:45 -0400 Received: from hoster906.com ([192.252.156.27]:33762 "EHLO hoster906.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbgHDPyn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 11:54:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mnmoran.org; h=from:to :cc:subject:date:message-id:mime-version :content-transfer-encoding; s=dkim; bh=boMfjA1aVaiU0+3V01vqoMuPP RtftT4YWtwV2fDu3AE=; b=g0KQlgcXMp3p2C9zFb8opvtFB2guXZiPIR3BKqply WLm0gRo0SGOR8QXnSV8TS94wR33ENqgkeA9lKyT2fP6WDgVYAbFcrH/RnodhMW8P ND8kegHjgp0nTUawY3a5xe82/ViVTaxvY8PKDJx7EZaHpWiw86mO36Zv9N1FTXO7 uo= Received: (qmail 5218 invoked by uid 503); 4 Aug 2020 15:54:29 -0000 Received: from unknown (HELO knuckle.Home) (mike@mnmoran.org@162.39.210.203) by hoster906.com with ESMTPA; 4 Aug 2020 15:54:29 -0000 From: "Michael N. Moran" <mike@mnmoran.org> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, inga.stotland@intel.com, "Michael N. Moran" <mike@mnmoran.org> Subject: [PATCH BlueZ v3] mesh: Add strings for SIG Model IDs Date: Tue, 4 Aug 2020 11:54:04 -0400 Message-Id: <20200804155404.1086789-1-mike@mnmoran.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: CD5A140180 X-Rspamd-UID: 43a43f --- tools/mesh/cfgcli.c | 3 ++- tools/mesh/remote.c | 5 ++-- tools/mesh/util.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ tools/mesh/util.h | 1 + 4 files changed, 70 insertions(+), 3 deletions(-) diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c index e36c8dca5..351f40ad0 100644 --- a/tools/mesh/cfgcli.c +++ b/tools/mesh/cfgcli.c @@ -263,7 +263,8 @@ static uint32_t print_mod_id(uint8_t *data, bool vendor, const char *offset) if (!vendor) { mod_id = get_le16(data); - bt_shell_printf("%sModel ID\t%4.4x\n", offset, mod_id); + bt_shell_printf("%sModel ID\t%4.4x \"%s\"\n", + offset, mod_id, sig_model_string(mod_id)); mod_id = VENDOR_ID_MASK | mod_id; } else { mod_id = get_le16(data + 2); diff --git a/tools/mesh/remote.c b/tools/mesh/remote.c index c74f0bec1..206885c07 100644 --- a/tools/mesh/remote.c +++ b/tools/mesh/remote.c @@ -30,6 +30,7 @@ #include "tools/mesh/keys.h" #include "tools/mesh/mesh-db.h" #include "tools/mesh/remote.h" +#include "tools/mesh/util.h" #define abs_diff(a, b) ((a) > (b) ? (a) - (b) : (b) - (a)) @@ -293,8 +294,8 @@ static void print_model(void *model, void *user_data) if (mod_id >= VENDOR_ID_MASK) { mod_id &= ~VENDOR_ID_MASK; - bt_shell_printf("\t\t\t" COLOR_GREEN "SIG model: %4.4x\n" - COLOR_OFF, mod_id); + bt_shell_printf("\t\t\t" COLOR_GREEN "SIG model: %4.4x \"%s\"\n" + COLOR_OFF, mod_id, sig_model_string(mod_id)); return; } diff --git a/tools/mesh/util.c b/tools/mesh/util.c index 7176cc562..82e4c9ad2 100644 --- a/tools/mesh/util.c +++ b/tools/mesh/util.c @@ -138,3 +138,67 @@ void swap_u256_bytes(uint8_t *u256) u256[i] ^= u256[31 - i]; } } + +const char *sig_model_string(uint16_t sig_model_id) +{ + switch (sig_model_id) { + case 0x0000: return "Configuration Server"; + case 0x0001: return "Configuration Client"; + case 0x0002: return "Health Server"; + case 0x0003: return "Health Client"; + case 0x1000: return "Generic OnOff Server"; + case 0x1001: return "Generic OnOff Client"; + case 0x1002: return "Generic Level Server"; + case 0x1003: return "Generic Level Client"; + case 0x1004: return "Generic Default Transition Time Server"; + case 0x1005: return "Generic Default Transition Time Client"; + case 0x1006: return "Generic Power OnOff Server"; + case 0x1007: return "Generic Power OnOff Setup Server"; + case 0x1008: return "Generic Power OnOff Client"; + case 0x1009: return "Generic Power Level Server"; + case 0x100A: return "Generic Power Level Setup Server"; + case 0x100B: return "Generic Power Level Client"; + case 0x100C: return "Generic Battery Server"; + case 0x100D: return "Generic Battery Client"; + case 0x100E: return "Generic Location Server"; + case 0x100F: return "Generic Location Setup Server"; + case 0x1010: return "Generic Location Client"; + case 0x1011: return "Generic Admin Property Server"; + case 0x1012: return "Generic Manufacturer Property Server"; + case 0x1013: return "Generic User Property Server"; + case 0x1014: return "Generic Client Property Server"; + case 0x1015: return "Generic Property Client"; + case 0x1100: return "Sensor Server"; + case 0x1101: return "Sensor Setup Server"; + case 0x1102: return "Sensor Client"; + case 0x1200: return "Time Server"; + case 0x1201: return "Time Setup Server"; + case 0x1202: return "Time Client"; + case 0x1203: return "Scene Server"; + case 0x1204: return "Scene Setup Server"; + case 0x1205: return "Scene Client"; + case 0x1206: return "Scheduler Server"; + case 0x1207: return "Scheduler Setup Server"; + case 0x1208: return "Scheduler Client"; + case 0x1300: return "Light Lightness Server"; + case 0x1301: return "Light Lightness Setup Server"; + case 0x1302: return "Light Lightness Client"; + case 0x1303: return "Light CTL Server"; + case 0x1304: return "Light CTL Setup Server"; + case 0x1305: return "Light CTL Client"; + case 0x1306: return "Light CTL Temperature Server"; + case 0x1307: return "Light HSL Server"; + case 0x1308: return "Light HSL Setup Server"; + case 0x1309: return "Light HSL Client"; + case 0x130A: return "Light HSL Hue Server"; + case 0x130B: return "Light HSL Saturation Server"; + case 0x130C: return "Light xyL Server"; + case 0x130D: return "Light xyL Setup Server"; + case 0x130E: return "Light xyL Client"; + case 0x130F: return "Light LC Server"; + case 0x1310: return "Light LC Setup Server"; + case 0x1311: return "Light LC Client"; + + default: return "Unknown"; + } +} diff --git a/tools/mesh/util.h b/tools/mesh/util.h index cca07cf96..2b9b926b1 100644 --- a/tools/mesh/util.h +++ b/tools/mesh/util.h @@ -27,3 +27,4 @@ uint16_t mesh_opcode_set(uint32_t opcode, uint8_t *buf); bool mesh_opcode_get(const uint8_t *buf, uint16_t sz, uint32_t *opcode, int *n); const char *mesh_status_str(uint8_t status); void swap_u256_bytes(uint8_t *u256); +const char *sig_model_string(uint16_t sig_model_id); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KOkZILyKKV/lqgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 18:20:12 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SBFWHryKKV9RaAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 18:20:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3D75A418A9; Tue, 4 Aug 2020 18:20:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729390AbgHDQUE (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 12:20:04 -0400 Received: from mga12.intel.com ([192.55.52.136]:7993 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729516AbgHDQT5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 12:19:57 -0400 IronPort-SDR: wQ4ngPwB5GQY+JhkLWhk1lxPGaBrwr74BZmfoRkXAgBVqnlvbVaCB9cXXaFpYVhvfxGnKSNojX wjMY5kPgCxuA== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="131912007" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="131912007" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 09:19:55 -0700 IronPort-SDR: WpYqCRe08bmPZ0/a6Dz/yXUjbnoN1FB7wuadPLM+5jUxjdSe34LM/RycFVtSPVQuq6WlF+eH5e sD5iPz046wOQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="275846834" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by fmsmga008.fm.intel.com with ESMTP; 04 Aug 2020 09:19:55 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 4 Aug 2020 09:19:54 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 4 Aug 2020 09:19:54 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 4 Aug 2020 09:19:54 -0700 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (104.47.38.52) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 4 Aug 2020 09:19:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HOLNeRonXzI9UQkEKtTi+GiUJjXx7Ky1H/gGkXkGd9rSvDwiACITkWFoaDVFeGBh7ZvBmKPwQek9mdPQ7SX6GjdrI+HSC3InH8Lq2Z7/DdGurlckkR6W+ss/kS2/y4PPSDgJ+p2U6ZJwUiyEt7rjQOpoXTxTMM3QYejzt+tv+7ir5Nfm94fkM1WMcDtLwVkOMYIFvBbyKS7RpR9bmpKSc5JC40vd33o1PjiNSLDlNPPpSW00hAqjG7/oqDrbHtlNxVPEv57bgeKEnjE0jaJTh8A8ezZ/cdkwBMKci/+hJ3xMr5GRx4NK+QVVe/DnpCA5Ij8nlgRNIsjc5uxncQjMGg== 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-SenderADCheck; bh=cyQUc9baQTwRuc/fnGTTMP9M4QrawMz/v8ZWOOA3mtE=; b=FfTZjuhJVIwosU/c77nnRnX7ral9J7QnHeWEG8LWauw/Dm0Qbt0GRg7YvpWs17Zyebl8kKtYJoxjxUqqvhuzmRDkdAX8tjwIBF3wVfht6Advfdp//+wKTO0tTRjf+k+o8BU2C+4GFguSUnpD0EoHAYw/8pRtqJ4YZRfOV4A6RSqC0Do30Y5zpHP6q6Hx6f2y0S0ZFDajlcd47HD0SXN9iErHFEcZneTRAwN4arCyjGY5N0kK9rR/Ku7iRJJu0b4Lj/v4tVi7z1Xp6gnjtUqasiOqMLItOX7+piKWexl5oLvITSx7SXSo3s501O8Dr21g0oYjE7QbXdkpu1GSFcol+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cyQUc9baQTwRuc/fnGTTMP9M4QrawMz/v8ZWOOA3mtE=; b=rbHIQsMnN6Grksq7ID7UyqkvMj+IUsHO/KWS2j0mkU0KvpqqrkpDPSKxz7InAUS3Y+S6mwloPVWIWAMb0UmHFLVfzy2+6JQpFCJ4M3oAwjVgaR431VtzasNk2SejXrKK1Tx368pqH9VPtoMGuMiWGyLPlwrFSRNIt9iTsCs4WS4= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4537.namprd11.prod.outlook.com (2603:10b6:303:5d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.16; Tue, 4 Aug 2020 16:19:51 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3239.022; Tue, 4 Aug 2020 16:19:51 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "mike@mnmoran.org" <mike@mnmoran.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> CC: "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ v3] mesh: Add strings for SIG Model IDs Thread-Topic: [PATCH BlueZ v3] mesh: Add strings for SIG Model IDs Thread-Index: AQHWaneRD4JU0jbrQkOP4vmnV3fyD6koITgA Date: Tue, 4 Aug 2020 16:19:51 +0000 Message-ID: <d71503cbdc789b59f152794b9d015c4b1cae8fdf.camel@intel.com> References: <20200804155404.1086789-1-mike@mnmoran.org> In-Reply-To: <20200804155404.1086789-1-mike@mnmoran.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: mnmoran.org; dkim=none (message not signed) header.d=none;mnmoran.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 38c20645-099a-4581-ab9f-08d838923758 x-ms-traffictypediagnostic: MW3PR11MB4537: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MW3PR11MB45373D8114CC48B871452548E14A0@MW3PR11MB4537.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:17; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ZOCrY7Jbl+Qv0yE6aLwYCK5IUaSSrTeyU6mdaU3txyH+CUxVHSHCB8lJf/+MAncYCaep6FQQB3zuQ3nD+y4MfHIpBnSY5k2811yN31HJrl7MPa7V11p9SlkV+pQsJod1T4+3mwhRzLJuHNYXDDpaV5P4jtp5IhAFWlpkt8/BvHEh35mJVt2DyPyeRNYjqASG/UQuzf6yrNYDrOirMeqABtHHyC9f68YWDz7s1taRbzqepjkBSUD/D9oTcerJeLsmfE5CEJYZWT9pzEwBgk8XJK4sXrJd55SQRmxao5RYUlf8iMMLkBqfoeAqf7lkQtqdF1HW10LXNzIb4xCJ8M9YKw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(366004)(376002)(39860400002)(396003)(346002)(5660300002)(2616005)(6512007)(66946007)(86362001)(66446008)(83380400001)(66476007)(76116006)(66556008)(91956017)(36756003)(64756008)(71200400001)(8676002)(6486002)(110136005)(316002)(2906002)(4326008)(478600001)(107886003)(6506007)(26005)(8936002)(186003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: jgFXaam5sB1jug/42MyOnqWiAJ+YtYnJ/3s7AJsTZ/feojk6lCgplEEr/p/CpbDLbem38cdi/luj/5Z1ukpZDC8gBfpRFs/Fzp/WKqw2oqZruHB3bDLXThKk+VFWa6bY6BP6c091HvRV0Nyik1mnRS8N/AQb0++5SSb1DF2VDOELFZmonZe6jRKSKUhq4hgkmrH+go470oksnLqPfCG2W4Fc0FQvN9pZLvBMRPlOka7CRdigto6jJ2j/k+wXMbjvGjDyEpx9Fg46YbCMizzQQynJ4rKMfWFaDEOEBawIcsi05Ey92a0/PSOY85IFT3PYyf0QAqLJr0Et9RLJQTXe2QUVERy5e2se5Bo7w2k+5XNC7IhQEJU8W6iCpHynOjdsnZqFReStJr/IL8EnvnJ42uWFZXV3hvqHjhJAP7VKXUIQgo35ma0gFGzQU3tbnqan4DnjejiMa5cBrVzpG1x/aFlnyBL9p++Wj9xpgR3jkUhXAmctpQ9+JIlet/6UyQ2+OnWm8o2w45ODbcAVWx5Wrpsy2kRyUDS66pXiugLxeoLms7sFafbkTugXEGOUoYHvUIhdzbwg7m+jNg8IZCjTvGlCeAe9G9g14Jt7/G2QdUCClJxunTHO3Cp1prObWWz+D4WMW4LIo7fyYvgi4C/Y1g== Content-Type: text/plain; charset="utf-8" Content-ID: <2B774D7A359EE24D82EBAA3ADBE875B8@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38c20645-099a-4581-ab9f-08d838923758 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Aug 2020 16:19:51.6559 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LIAWNJkH70CWAWDuQIOlD5mZUbwt4Z8xE33EJKFMoGxxRcPs3/CUOKGakXwF33k2BWFe4hqfG6KFo9duUp2m3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4537 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3D75A418A9 X-Rspamd-UID: 5bdd90 DQpBcHBsaWVkIHdpdGggZm9sbG93aW5nIHdoaXRlc3BhY2Ugc3R5bGUgZ3VpZGUgZml4ZXM6DQoN CjgwIGNoYXJhY3RvciB2aW9sYXRpb25zIGF0Og0KdG9vbHMvbWVzaC9jZmdjbGkuYzoyNjcNCnRv b2xzL21lc2gvcmVtb3RlLmM6Mjk4DQoNCmluY29ycmVjdCBUQUIgaW4gc2lnX21vZGVsX3N0cmlu ZygpIHByb3RvdHlwZQ0KdG9vbHMvbWVzaC91dGlsLmM6MTQyDQp0b29scy9tZXNoL3V0aWwuaDoz MA0KDQpPbiBUdWUsIDIwMjAtMDgtMDQgYXQgMTE6NTQgLTA0MDAsIE1pY2hhZWwgTi4gTW9yYW4g d3JvdGU6DQo+IC0tLQ0KPiAgdG9vbHMvbWVzaC9jZmdjbGkuYyB8ICAzICsrLQ0KPiAgdG9vbHMv bWVzaC9yZW1vdGUuYyB8ICA1ICsrLS0NCj4gIHRvb2xzL21lc2gvdXRpbC5jICAgfCA2NCArKysr KysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysNCj4gIHRvb2xzL21lc2gv dXRpbC5oICAgfCAgMSArDQo+ICA0IGZpbGVzIGNoYW5nZWQsIDcwIGluc2VydGlvbnMoKyksIDMg ZGVsZXRpb25zKC0pDQo+IA0KPiBkaWZmIC0tZ2l0IGEvdG9vbHMvbWVzaC9jZmdjbGkuYyBiL3Rv b2xzL21lc2gvY2ZnY2xpLmMNCj4gaW5kZXggZTM2YzhkY2E1Li4zNTFmNDBhZDAgMTAwNjQ0DQo+ IC0tLSBhL3Rvb2xzL21lc2gvY2ZnY2xpLmMNCj4gKysrIGIvdG9vbHMvbWVzaC9jZmdjbGkuYw0K PiBAQCAtMjYzLDcgKzI2Myw4IEBAIHN0YXRpYyB1aW50MzJfdCBwcmludF9tb2RfaWQodWludDhf dCAqZGF0YSwgYm9vbCB2ZW5kb3IsIGNvbnN0IGNoYXIgKm9mZnNldCkNCj4gIA0KPiAgCWlmICgh dmVuZG9yKSB7DQo+ICAJCW1vZF9pZCA9IGdldF9sZTE2KGRhdGEpOw0KPiAtCQlidF9zaGVsbF9w cmludGYoIiVzTW9kZWwgSURcdCU0LjR4XG4iLCBvZmZzZXQsIG1vZF9pZCk7DQo+ICsJCWJ0X3No ZWxsX3ByaW50ZigiJXNNb2RlbCBJRFx0JTQuNHggXCIlc1wiXG4iLA0KPiArCQkJCQkJCW9mZnNl dCwgbW9kX2lkLCBzaWdfbW9kZWxfc3RyaW5nKG1vZF9pZCkpOw0KPiAgCQltb2RfaWQgPSBWRU5E T1JfSURfTUFTSyB8IG1vZF9pZDsNCj4gIAl9IGVsc2Ugew0KPiAgCQltb2RfaWQgPSBnZXRfbGUx NihkYXRhICsgMik7DQo+IGRpZmYgLS1naXQgYS90b29scy9tZXNoL3JlbW90ZS5jIGIvdG9vbHMv bWVzaC9yZW1vdGUuYw0KPiBpbmRleCBjNzRmMGJlYzEuLjIwNjg4NWMwNyAxMDA2NDQNCj4gLS0t IGEvdG9vbHMvbWVzaC9yZW1vdGUuYw0KPiArKysgYi90b29scy9tZXNoL3JlbW90ZS5jDQo+IEBA IC0zMCw2ICszMCw3IEBADQo+ICAjaW5jbHVkZSAidG9vbHMvbWVzaC9rZXlzLmgiDQo+ICAjaW5j bHVkZSAidG9vbHMvbWVzaC9tZXNoLWRiLmgiDQo+ICAjaW5jbHVkZSAidG9vbHMvbWVzaC9yZW1v dGUuaCINCj4gKyNpbmNsdWRlICJ0b29scy9tZXNoL3V0aWwuaCINCj4gIA0KPiAgI2RlZmluZSBh YnNfZGlmZihhLCBiKSAoKGEpID4gKGIpID8gKGEpIC0gKGIpIDogKGIpIC0gKGEpKQ0KPiAgDQo+ IEBAIC0yOTMsOCArMjk0LDggQEAgc3RhdGljIHZvaWQgcHJpbnRfbW9kZWwodm9pZCAqbW9kZWws IHZvaWQgKnVzZXJfZGF0YSkNCj4gIA0KPiAgCWlmIChtb2RfaWQgPj0gVkVORE9SX0lEX01BU0sp IHsNCj4gIAkJbW9kX2lkICY9IH5WRU5ET1JfSURfTUFTSzsNCj4gLQkJYnRfc2hlbGxfcHJpbnRm KCJcdFx0XHQiIENPTE9SX0dSRUVOICJTSUcgbW9kZWw6ICU0LjR4XG4iDQo+IC0JCQkJCQkJQ09M T1JfT0ZGLCBtb2RfaWQpOw0KPiArCQlidF9zaGVsbF9wcmludGYoIlx0XHRcdCIgQ09MT1JfR1JF RU4gIlNJRyBtb2RlbDogJTQuNHggXCIlc1wiXG4iDQo+ICsJCQkJCQkJQ09MT1JfT0ZGLCBtb2Rf aWQsIHNpZ19tb2RlbF9zdHJpbmcobW9kX2lkKSk7DQo+ICAJCXJldHVybjsNCj4gIAl9DQo+ICAN Cj4gZGlmZiAtLWdpdCBhL3Rvb2xzL21lc2gvdXRpbC5jIGIvdG9vbHMvbWVzaC91dGlsLmMNCj4g aW5kZXggNzE3NmNjNTYyLi44MmU0YzlhZDIgMTAwNjQ0DQo+IC0tLSBhL3Rvb2xzL21lc2gvdXRp bC5jDQo+ICsrKyBiL3Rvb2xzL21lc2gvdXRpbC5jDQo+IEBAIC0xMzgsMyArMTM4LDY3IEBAIHZv aWQgc3dhcF91MjU2X2J5dGVzKHVpbnQ4X3QgKnUyNTYpDQo+ICAJCXUyNTZbaV0gXj0gdTI1Nlsz MSAtIGldOw0KPiAgCX0NCj4gIH0NCj4gKw0KPiArY29uc3QgY2hhcgkqc2lnX21vZGVsX3N0cmlu Zyh1aW50MTZfdCBzaWdfbW9kZWxfaWQpDQo+ICt7DQo+ICsJc3dpdGNoIChzaWdfbW9kZWxfaWQp IHsNCj4gKwljYXNlIDB4MDAwMDogcmV0dXJuICJDb25maWd1cmF0aW9uIFNlcnZlciI7DQo+ICsJ Y2FzZSAweDAwMDE6IHJldHVybiAiQ29uZmlndXJhdGlvbiBDbGllbnQiOw0KPiArCWNhc2UgMHgw MDAyOiByZXR1cm4gIkhlYWx0aCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgwMDAzOiByZXR1cm4gIkhl YWx0aCBDbGllbnQiOw0KPiArCWNhc2UgMHgxMDAwOiByZXR1cm4gIkdlbmVyaWMgT25PZmYgU2Vy dmVyIjsNCj4gKwljYXNlIDB4MTAwMTogcmV0dXJuICJHZW5lcmljIE9uT2ZmIENsaWVudCI7DQo+ ICsJY2FzZSAweDEwMDI6IHJldHVybiAiR2VuZXJpYyBMZXZlbCBTZXJ2ZXIiOw0KPiArCWNhc2Ug MHgxMDAzOiByZXR1cm4gIkdlbmVyaWMgTGV2ZWwgQ2xpZW50IjsNCj4gKwljYXNlIDB4MTAwNDog cmV0dXJuICJHZW5lcmljIERlZmF1bHQgVHJhbnNpdGlvbiBUaW1lIFNlcnZlciI7DQo+ICsJY2Fz ZSAweDEwMDU6IHJldHVybiAiR2VuZXJpYyBEZWZhdWx0IFRyYW5zaXRpb24gVGltZSBDbGllbnQi Ow0KPiArCWNhc2UgMHgxMDA2OiByZXR1cm4gIkdlbmVyaWMgUG93ZXIgT25PZmYgU2VydmVyIjsN Cj4gKwljYXNlIDB4MTAwNzogcmV0dXJuICJHZW5lcmljIFBvd2VyIE9uT2ZmIFNldHVwIFNlcnZl ciI7DQo+ICsJY2FzZSAweDEwMDg6IHJldHVybiAiR2VuZXJpYyBQb3dlciBPbk9mZiBDbGllbnQi Ow0KPiArCWNhc2UgMHgxMDA5OiByZXR1cm4gIkdlbmVyaWMgUG93ZXIgTGV2ZWwgU2VydmVyIjsN Cj4gKwljYXNlIDB4MTAwQTogcmV0dXJuICJHZW5lcmljIFBvd2VyIExldmVsIFNldHVwIFNlcnZl ciI7DQo+ICsJY2FzZSAweDEwMEI6IHJldHVybiAiR2VuZXJpYyBQb3dlciBMZXZlbCBDbGllbnQi Ow0KPiArCWNhc2UgMHgxMDBDOiByZXR1cm4gIkdlbmVyaWMgQmF0dGVyeSBTZXJ2ZXIiOw0KPiAr CWNhc2UgMHgxMDBEOiByZXR1cm4gIkdlbmVyaWMgQmF0dGVyeSBDbGllbnQiOw0KPiArCWNhc2Ug MHgxMDBFOiByZXR1cm4gIkdlbmVyaWMgTG9jYXRpb24gU2VydmVyIjsNCj4gKwljYXNlIDB4MTAw RjogcmV0dXJuICJHZW5lcmljIExvY2F0aW9uIFNldHVwIFNlcnZlciI7DQo+ICsJY2FzZSAweDEw MTA6IHJldHVybiAiR2VuZXJpYyBMb2NhdGlvbiBDbGllbnQiOw0KPiArCWNhc2UgMHgxMDExOiBy ZXR1cm4gIkdlbmVyaWMgQWRtaW4gUHJvcGVydHkgU2VydmVyIjsNCj4gKwljYXNlIDB4MTAxMjog cmV0dXJuICJHZW5lcmljIE1hbnVmYWN0dXJlciBQcm9wZXJ0eSBTZXJ2ZXIiOw0KPiArCWNhc2Ug MHgxMDEzOiByZXR1cm4gIkdlbmVyaWMgVXNlciBQcm9wZXJ0eSBTZXJ2ZXIiOw0KPiArCWNhc2Ug MHgxMDE0OiByZXR1cm4gIkdlbmVyaWMgQ2xpZW50IFByb3BlcnR5IFNlcnZlciI7DQo+ICsJY2Fz ZSAweDEwMTU6IHJldHVybiAiR2VuZXJpYyBQcm9wZXJ0eSBDbGllbnQiOw0KPiArCWNhc2UgMHgx MTAwOiByZXR1cm4gIlNlbnNvciBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMTAxOiByZXR1cm4gIlNl bnNvciBTZXR1cCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMTAyOiByZXR1cm4gIlNlbnNvciBDbGll bnQiOw0KPiArCWNhc2UgMHgxMjAwOiByZXR1cm4gIlRpbWUgU2VydmVyIjsNCj4gKwljYXNlIDB4 MTIwMTogcmV0dXJuICJUaW1lIFNldHVwIFNlcnZlciI7DQo+ICsJY2FzZSAweDEyMDI6IHJldHVy biAiVGltZSBDbGllbnQiOw0KPiArCWNhc2UgMHgxMjAzOiByZXR1cm4gIlNjZW5lIFNlcnZlciI7 DQo+ICsJY2FzZSAweDEyMDQ6IHJldHVybiAiU2NlbmUgU2V0dXAgU2VydmVyIjsNCj4gKwljYXNl IDB4MTIwNTogcmV0dXJuICJTY2VuZSBDbGllbnQiOw0KPiArCWNhc2UgMHgxMjA2OiByZXR1cm4g IlNjaGVkdWxlciBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMjA3OiByZXR1cm4gIlNjaGVkdWxlciBT ZXR1cCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMjA4OiByZXR1cm4gIlNjaGVkdWxlciBDbGllbnQi Ow0KPiArCWNhc2UgMHgxMzAwOiByZXR1cm4gIkxpZ2h0IExpZ2h0bmVzcyBTZXJ2ZXIiOw0KPiAr CWNhc2UgMHgxMzAxOiByZXR1cm4gIkxpZ2h0IExpZ2h0bmVzcyBTZXR1cCBTZXJ2ZXIiOw0KPiAr CWNhc2UgMHgxMzAyOiByZXR1cm4gIkxpZ2h0IExpZ2h0bmVzcyBDbGllbnQiOw0KPiArCWNhc2Ug MHgxMzAzOiByZXR1cm4gIkxpZ2h0IENUTCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzA0OiByZXR1 cm4gIkxpZ2h0IENUTCBTZXR1cCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzA1OiByZXR1cm4gIkxp Z2h0IENUTCBDbGllbnQiOw0KPiArCWNhc2UgMHgxMzA2OiByZXR1cm4gIkxpZ2h0IENUTCBUZW1w ZXJhdHVyZSBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzA3OiByZXR1cm4gIkxpZ2h0IEhTTCBTZXJ2 ZXIiOw0KPiArCWNhc2UgMHgxMzA4OiByZXR1cm4gIkxpZ2h0IEhTTCBTZXR1cCBTZXJ2ZXIiOw0K PiArCWNhc2UgMHgxMzA5OiByZXR1cm4gIkxpZ2h0IEhTTCBDbGllbnQiOw0KPiArCWNhc2UgMHgx MzBBOiByZXR1cm4gIkxpZ2h0IEhTTCBIdWUgU2VydmVyIjsNCj4gKwljYXNlIDB4MTMwQjogcmV0 dXJuICJMaWdodCBIU0wgU2F0dXJhdGlvbiBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzBDOiByZXR1 cm4gIkxpZ2h0IHh5TCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzBEOiByZXR1cm4gIkxpZ2h0IHh5 TCBTZXR1cCBTZXJ2ZXIiOw0KPiArCWNhc2UgMHgxMzBFOiByZXR1cm4gIkxpZ2h0IHh5TCBDbGll bnQiOw0KPiArCWNhc2UgMHgxMzBGOiByZXR1cm4gIkxpZ2h0IExDIFNlcnZlciI7DQo+ICsJY2Fz ZSAweDEzMTA6IHJldHVybiAiTGlnaHQgTEMgU2V0dXAgU2VydmVyIjsNCj4gKwljYXNlIDB4MTMx MTogcmV0dXJuICJMaWdodCBMQyBDbGllbnQiOw0KPiArDQo+ICsJZGVmYXVsdDogcmV0dXJuICJV bmtub3duIjsNCj4gKwl9DQo+ICt9DQo+IGRpZmYgLS1naXQgYS90b29scy9tZXNoL3V0aWwuaCBi L3Rvb2xzL21lc2gvdXRpbC5oDQo+IGluZGV4IGNjYTA3Y2Y5Ni4uMmI5YjkyNmIxIDEwMDY0NA0K PiAtLS0gYS90b29scy9tZXNoL3V0aWwuaA0KPiArKysgYi90b29scy9tZXNoL3V0aWwuaA0KPiBA QCAtMjcsMyArMjcsNCBAQCB1aW50MTZfdCBtZXNoX29wY29kZV9zZXQodWludDMyX3Qgb3Bjb2Rl LCB1aW50OF90ICpidWYpOw0KPiAgYm9vbCBtZXNoX29wY29kZV9nZXQoY29uc3QgdWludDhfdCAq YnVmLCB1aW50MTZfdCBzeiwgdWludDMyX3QgKm9wY29kZSwgaW50ICpuKTsNCj4gIGNvbnN0IGNo YXIgKm1lc2hfc3RhdHVzX3N0cih1aW50OF90IHN0YXR1cyk7DQo+ICB2b2lkIHN3YXBfdTI1Nl9i eXRlcyh1aW50OF90ICp1MjU2KTsNCj4gK2NvbnN0IGNoYXIJKnNpZ19tb2RlbF9zdHJpbmcodWlu dDE2X3Qgc2lnX21vZGVsX2lkKTsNCg== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cLNjAO+VKV/D0QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 19:07:59 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id uJZsOu6VKV+/fAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 19:07:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 64A10418AA; Tue, 4 Aug 2020 19:07:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729853AbgHDRHw (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 13:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729305AbgHDRHv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 13:07:51 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AD1BC06174A for <linux-bluetooth@vger.kernel.org>; Tue, 4 Aug 2020 10:07:51 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id u24so27100830oiv.7 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 10:07:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2ourZThngvCc0upPjZ1J59KAT7nWgEJLpFvhZJce+3c=; b=je2SqnLoGBRd0YmIG4qDEUl7wrvJRSzk0T+CrqOE0pfDNRAa375+3JMMea9NRpKuEX tdCApFEsZuy5POzdXRi0hGNu2EUdnPcJPdrlHAqIJcklYh7cZKndjrFq4/wodU8M7JfQ vaB3rcnvIKK+wIeXy4pmY+4TBw18STQq66R1n8o6GmtIxC7SeBT6kpeAHQ7QBUQGgN/+ /qlzIRaX7dsqpmfSNO+3Pl4BuCzkyylKx0s01ax1yB+bTYeGs7ou1/5CenTs5FynHumJ ulxC9QbJ37iYNXxQR1VBTxXQHnriCSvPpXeMLOt56mKzTgluA7+44iJ+3BK48QZQyelV jy1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2ourZThngvCc0upPjZ1J59KAT7nWgEJLpFvhZJce+3c=; b=OdhRVYCxeWeNUYgZgPMk3tDrO5hqpzMWOFhK7IV9hjbYzgPlWLLm/V3uxRAEMMgnNq nSPqFjFNHWPjjE9oACeuD6pYqDX8BHG4Plrtf72fjfYyAsIoUivN8RUu8zSmTuJpuMFG voqak39Qw/MPpqGkFQgVMKJ9uEteaArDvMsTbpwAGIqfS5Lg4f16KghL2IA3jSJ7Rh0w nrDqL5DM8xoNA9peVUZJmXMxvBf/cX9GCyD7SKm2n6oTwDIW61W6YZzMxTh93F70Aau7 u+1r8b9Uh58p3/Gka7uj30Fsg/UYaYcfopFyIp/b3lxFdwfZgI+jUlaZ7cmM5JnZzXYV yjFg== X-Gm-Message-State: AOAM5330gd3HIbi5lcZeIiPSLkuSlZ3tMEJhnIk6hVS5ckZJRwZpadu/ +CXAaexcHXvBUwTQfXmemUWnsshy0gpIHyhmfmI= X-Google-Smtp-Source: ABdhPJy7w4vlzl/MzpSNr4olIA+PAvwLSuUSWtM97kAlia0mhodBALwk+o4nYFx7HV4paxhbU5swURldJzNlBZHEvAI= X-Received: by 2002:aca:cc50:: with SMTP id c77mr4010176oig.152.1596560870088; Tue, 04 Aug 2020 10:07:50 -0700 (PDT) MIME-Version: 1.0 References: <20200708121928.bluez.v2.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> <CAJQfnxEBjHMAO=kTqRBExgS40g7=OJbv-NOTE1V=PM=K1sdGcw@mail.gmail.com> In-Reply-To: <CAJQfnxEBjHMAO=kTqRBExgS40g7=OJbv-NOTE1V=PM=K1sdGcw@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 4 Aug 2020 10:07:40 -0700 Message-ID: <CABBYNZ+dZsOGQZh6R3wGg3qPUep9tz7BzsDRH4__mbHKcL8P+g@mail.gmail.com> Subject: Re: [bluez PATCH v2] avrcp: include all player settings in notif event To: Archie Pusaka <apusaka@google.com> Cc: Howard Chung <howardchung@google.com>, BlueZ <linux-bluetooth@vger.kernel.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 64A10418AA X-Rspamd-UID: db0952 Hi Archie, On Tue, Aug 4, 2020 at 1:26 AM Archie Pusaka <apusaka@google.com> wrote: > > Hi Bluez maintainers, > > Could you take a look at this fix? > Thank you! Has there been any new version? It looks like CI has caught some problems with it or that has been resolved by V2? > Regards, > Archie > > > On Wed, 8 Jul 2020 at 12:19, Howard Chung <howardchung@google.com> wrote: > > > > According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player > > application settings should be returned to the CT and let CT to > > determine which settings have changed. Currently bluez only returns > > the changed attribute instead. This patch also addresses a potential > > issue on which the number of application settings mismatches with > > the actual number returned. > > > > Reviewed-by: Archie Pusaka <apusaka@chromium.org> > > --- > > > > Changes in v2: > > - Fixed unused variables > > > > profiles/audio/avrcp.c | 71 +++++++++++++++++++----------------------- > > 1 file changed, 32 insertions(+), 39 deletions(-) > > > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > > index e2428250e..a4de7530e 100644 > > --- a/profiles/audio/avrcp.c > > +++ b/profiles/audio/avrcp.c > > @@ -369,6 +369,7 @@ static uint32_t company_ids[] = { > > }; > > > > static void avrcp_register_notification(struct avrcp *session, uint8_t event); > > +static GList *player_list_settings(struct avrcp_player *player); > > > > static sdp_record_t *avrcp_ct_record(void) > > { > > @@ -743,6 +744,35 @@ static int play_status_to_val(const char *status) > > return -EINVAL; > > } > > > > +static uint16_t player_settings_changed(struct avrcp_player *player, > > + struct avrcp_header *pdu) > > +{ > > + GList *settings = player_list_settings(player); > > + int size = 2; > > + > > + for (; settings; settings = settings->next) { > > + const char *key = settings->data; > > + int attr; > > + int val; > > + > > + attr = attr_to_val(key); > > + if (attr < 0) > > + continue; > > + > > + val = player_get_setting(player, attr); > > + if (val < 0) > > + continue; > > + > > + pdu->params[size++] = attr; > > + pdu->params[size++] = val; > > + } > > + > > + g_list_free(settings); > > + > > + pdu->params[1] = (size - 2) >> 1; > > + return size; > > +} > > + > > void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > const void *data) > > { > > @@ -751,8 +781,6 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > uint8_t code; > > uint16_t size; > > GSList *l; > > - int attr; > > - int val; > > > > if (player->sessions == NULL) > > return; > > @@ -791,19 +819,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > size = 1; > > break; > > case AVRCP_EVENT_SETTINGS_CHANGED: > > - size = 2; > > - pdu->params[1] = 1; > > - > > - attr = attr_to_val(data); > > - if (attr < 0) > > - return; > > - > > - val = player_get_setting(player, attr); > > - if (val < 0) > > - return; > > - > > - pdu->params[size++] = attr; > > - pdu->params[size++] = val; > > + size = player_settings_changed(player, pdu); > > break; > > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > > size = 5; > > @@ -1595,7 +1611,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > > struct btd_device *dev = session->dev; > > uint16_t len = ntohs(pdu->params_len); > > uint64_t uid; > > - GList *settings; > > > > /* > > * 1 byte for EventID, 4 bytes for Playback interval but the latest > > @@ -1626,29 +1641,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > > len = 1; > > break; > > case AVRCP_EVENT_SETTINGS_CHANGED: > > - len = 1; > > - settings = player_list_settings(player); > > - > > - pdu->params[len++] = g_list_length(settings); > > - for (; settings; settings = settings->next) { > > - const char *key = settings->data; > > - int attr; > > - int val; > > - > > - attr = attr_to_val(key); > > - if (attr < 0) > > - continue; > > - > > - val = player_get_setting(player, attr); > > - if (val < 0) > > - continue; > > - > > - pdu->params[len++] = attr; > > - pdu->params[len++] = val; > > - } > > - > > - g_list_free(settings); > > - > > + len = player_settings_changed(player, pdu); > > break; > > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > > len = 5; > > -- > > 2.27.0.383.g050319c2ae-goog > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aBDoNe+WKV9hnQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 19:12:15 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +GA2NO+WKV8ABAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 19:12:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7B983418AC; Tue, 4 Aug 2020 19:12:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729388AbgHDRMG (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 13:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729472AbgHDRL6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 13:11:58 -0400 Received: from mail-ua1-x943.google.com (mail-ua1-x943.google.com [IPv6:2607:f8b0:4864:20::943]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04449C061757 for <linux-bluetooth@vger.kernel.org>; Tue, 4 Aug 2020 10:11:57 -0700 (PDT) Received: by mail-ua1-x943.google.com with SMTP id r63so13081112uar.9 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 10:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NDe2U+JQQtlm6PkmOwl5fjQfHoZ0o3DW3eDHCm6kTvQ=; b=SoyMHVPkgxHGIyVFghEqt+dz76dWygdZK5qv96mgYHIB8BQDfnDSdlwicrCousdePt 6kFYSc0n7RSJRhh/WbIBfAW1Mu0Sap9jaMdg6UlhNdK0k672HQpR0CmBGVutHlwlHgV+ jMC83l8tqgA+ALlv4CakhMvyvvf1kF8Uhx/7c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NDe2U+JQQtlm6PkmOwl5fjQfHoZ0o3DW3eDHCm6kTvQ=; b=cN6FKgv2Zzr5pePYQySg9EuMRwaWQcOnbplR+7uvaoyJ67fs0gL+VMjU/Cn1+cEnRF e91nZr7JhxNLsd7ip9VYxMBje7FlCMZgrm/Q6SB+jEisScvzzIpsIGuRof3zB/+ZGTZu CnfkGB/Wt/rkddeAdnL1k4yN71SuE2mMcwYS/B+OQZk9ol3woXEQlrKTmio2Bc67AIIh Si54WKSxoOBVyGCAHWKhzQ3pfgpyhAw9fdb5erz+Gal1MOEt7makjBgvjQsOKhHloQxC qXpeJ6+gMj0klAs1qnmzRzUG9ZEaqFes42cWuEVzZkQEx11EaKMm7TnKt4cdw447Jx/a KJ4A== X-Gm-Message-State: AOAM532xQNGqqMphWayT6hqpRsnqoSW0IZvNS7qE66hE8Ls8zhJo0SrN 5fo3Z+5GyFBsCBOBQnABJFV4vlzniTfYdgUOinPLIQ== X-Google-Smtp-Source: ABdhPJzdxejwD5qJ3tvpESkSc0h2CyPb4WDolKHYh5SfDmcf4Fg5xK3WK/bLFsJz2MfIniAOjYF53pvHQqw0ach4VHA= X-Received: by 2002:a9f:2197:: with SMTP id 23mr15629203uac.60.1596561115676; Tue, 04 Aug 2020 10:11:55 -0700 (PDT) MIME-Version: 1.0 References: <20200729014225.1842177-1-abhishekpandit@chromium.org> In-Reply-To: <20200729014225.1842177-1-abhishekpandit@chromium.org> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Tue, 4 Aug 2020 10:11:44 -0700 Message-ID: <CANFp7mV0TP-WbBWGSpduERaf9-KBXevhG7xKvjkMrqrtWWkZ5w@mail.gmail.com> Subject: Re: [PATCH 0/3] Bluetooth: Emit events for suspend/resume To: Marcel Holtmann <marcel@holtmann.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev <netdev@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7B983418AC X-Rspamd-UID: 9e46d4 Hi, Gentle reminder that this is waiting for feedback. Related userspace changes are here to see how we plan on using it: https://patchwork.kernel.org/project/bluetooth/list/?series=325777 Thanks Abhishek On Tue, Jul 28, 2020 at 6:42 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > > Hi Marcel, > > This series adds the suspend/resume events suggested in > https://patchwork.kernel.org/patch/11663455/. > > I have tested it with some userspace changes that monitors the > controller resumed event to trigger audio device reconnection and > verified that the events are correctly emitted. > > Please take a look. > Abhishek > > > Abhishek Pandit-Subedi (3): > Bluetooth: Add mgmt suspend and resume events > Bluetooth: Add suspend reason for device disconnect > Bluetooth: Emit controller suspend and resume events > > include/net/bluetooth/hci_core.h | 6 +++ > include/net/bluetooth/mgmt.h | 16 +++++++ > net/bluetooth/hci_core.c | 26 +++++++++++- > net/bluetooth/hci_event.c | 73 ++++++++++++++++++++++++++++++++ > net/bluetooth/mgmt.c | 28 ++++++++++++ > 5 files changed, 148 insertions(+), 1 deletion(-) > > -- > 2.28.0.rc0.142.g3c755180ce-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4FT3N5HCKV918AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 22:18:25 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6OpLNpHCKV/GswAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 22:18:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1AB93A1664; Tue, 4 Aug 2020 22:18:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726961AbgHDURw (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 16:17:52 -0400 Received: from mga09.intel.com ([134.134.136.24]:64991 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726720AbgHDURu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 16:17:50 -0400 IronPort-SDR: W+t0JQX3978lC1+MtHDU7eh/BPLJZYIUL6ajf9H37i+0iGj3fNhtIKwDHvbA68WECrno9tc6tr lnsXl/sh2r8w== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565397" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565397" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:49 -0700 IronPort-SDR: pC75ObEXvPigEStMJPpDfrUKNWXNwTxviKjezXifrdK19TM7mnyvMjDT+6Wd/EXSPzHX6FvuBr 6I7+MKvF+DRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783853" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:49 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v3 09/10] mesh: Clean up handling of config KR phase messages Date: Tue, 4 Aug 2020 13:17:43 -0700 Message-Id: <20200804201744.23327-9-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804201744.23327-1-inga.stotland@intel.com> References: <20200804201744.23327-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1AB93A1664 X-Rspamd-UID: b6d2ec This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 55 +++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 5b3ed3d97..5854f7a1c 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -420,6 +420,31 @@ static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt, return n; } +static uint16_t cfg_key_refresh_phase(struct mesh_node *node, + const uint8_t *pkt, int opcode) +{ + struct mesh_net *net = node_get_net(node); + uint16_t n, idx = l_get_le16(pkt); + uint8_t phase; + + n = mesh_model_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_STATUS, msg); + + if (opcode == OP_CONFIG_KEY_REFRESH_PHASE_SET) { + phase = pkt[2]; + msg[n] = mesh_net_key_refresh_phase_set(net, idx, phase); + l_debug("Set KR Phase: net=%3.3x transition=%d", idx, phase); + } else { + msg[n] = mesh_net_key_refresh_phase_get(net, idx, &phase); + l_debug("Get KR Phase: net=%3.3x phase=%d", idx, phase); + } + + l_put_le16(idx, msg + n); + msg[n + 2] = (msg[n] != MESH_STATUS_SUCCESS) ? + KEY_REFRESH_PHASE_NONE : phase; + + return n + 3; +} + static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; @@ -718,8 +743,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; uint16_t n_idx; - uint8_t state, status; - uint8_t phase; + uint8_t state; bool virt = false; uint16_t n; @@ -926,37 +950,16 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_KEY_REFRESH_PHASE_SET: - if (size != 3 || pkt[2] > 0x03) + if (size != 3 || pkt[2] > KEY_REFRESH_PHASE_THREE) return true; - b_res = mesh_net_key_refresh_phase_set(net, l_get_le16(pkt), - pkt[2]); - size = 2; /* Fall Through */ case OP_CONFIG_KEY_REFRESH_PHASE_GET: - if (size != 2) + if (size != 2 && opcode == OP_CONFIG_KEY_REFRESH_PHASE_GET) return true; - n_idx = l_get_le16(pkt); - - n = mesh_model_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_STATUS, - msg); - - /* State: 0x00-0x03 phase of key refresh */ - status = mesh_net_key_refresh_phase_get(net, n_idx, - &phase); - if (status != MESH_STATUS_SUCCESS) { - b_res = status; - phase = KEY_REFRESH_PHASE_NONE; - } - - msg[n++] = b_res; - l_put_le16(n_idx, msg + n); - n += 2; - msg[n++] = phase; - - l_debug("Get/Set Key Refresh State (%d)", msg[n-1]); + n = cfg_key_refresh_phase(node, pkt, opcode); break; case OP_APPKEY_ADD: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wA6LLZfCKV+89gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 22:18:31 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 6H8HLJfCKV/spAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 22:18:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0E95BA1D09; Tue, 4 Aug 2020 22:18:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726963AbgHDURw (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 16:17:52 -0400 Received: from mga09.intel.com ([134.134.136.24]:65000 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726861AbgHDURv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 16:17:51 -0400 IronPort-SDR: /r4LLgebyEGGxfUsbEsQ9I6fEzmitbGV765aa9CJyKfczDMmZ999Fjlp5ZbFHUB0y202KgM1JN bVWvmJXRzrrQ== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565399" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565399" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:50 -0700 IronPort-SDR: rKGEktD89CY9SMjnaWEwGk9YZLCX60jh912v8o7+jEUhWWJKigfRsyzso5WmeBg0QJ42wHqwoq 0rGfHv3xAprA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783858" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:49 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v3 10/10] mesh: Refactor heartbeat pub/sub Date: Tue, 4 Aug 2020 13:17:44 -0700 Message-Id: <20200804201744.23327-10-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804201744.23327-1-inga.stotland@intel.com> References: <20200804201744.23327-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0E95BA1D09 X-Rspamd-UID: 3357e4 Move heartbeat publication/subscription timers and housekeeping to net.c since this is where the trigger events and control messages are handled. Configuration server (cfgmod-server.c) stays responsible for parsing the set pub/sub message parameters and assemblying the pub/sub status messages. Also, make sure that the correct message status is reported. --- mesh/cfgmod-server.c | 307 ++++++++++++++----------------------------- mesh/net.c | 273 ++++++++++++++++++++++++++++---------- mesh/net.h | 48 ++++--- 3 files changed, 328 insertions(+), 300 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 5854f7a1c..40ecec16a 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -445,50 +445,6 @@ static uint16_t cfg_key_refresh_phase(struct mesh_node *node, return n + 3; } -static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) -{ - struct mesh_net *net = user_data; - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - mesh_net_heartbeat_send(net); - - if (hb->pub_count != 0xffff) - hb->pub_count--; - if (hb->pub_count > 0) - l_timeout_modify(hb->pub_timer, hb->pub_period); - else { - l_timeout_remove(hb->pub_timer); - hb->pub_timer = NULL; - } -} - -static void update_hb_pub_timer(struct mesh_net *net, - struct mesh_net_heartbeat *hb) -{ - if (IS_UNASSIGNED(hb->pub_dst) || hb->pub_count == 0) { - l_timeout_remove(hb->pub_timer); - hb->pub_timer = NULL; - return; - } - - if (!hb->pub_timer) - hb->pub_timer = l_timeout_create(hb->pub_period, - hb_pub_timeout_func, net, NULL); - else - l_timeout_modify(hb->pub_timer, hb->pub_period); -} - -static void hb_sub_timeout_func(struct l_timeout *timeout, void *user_data) -{ - struct mesh_net *net = user_data; - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - l_debug("HB Subscription Ended"); - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; -} - static uint8_t uint32_to_log(uint32_t value) { uint32_t val = 1; @@ -507,85 +463,112 @@ static uint8_t uint32_to_log(uint32_t value) return ret; } -static uint32_t log_to_uint32(uint8_t log, uint8_t offset) +static uint16_t hb_subscription_get(struct mesh_node *node, int status) { - if (!log) - return 0x0000; - else if (log > 0x11) - return 0xffff; + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_sub *sub = mesh_net_get_heartbeat_sub(net); + struct timeval time_now; + uint16_t n; + + gettimeofday(&time_now, NULL); + time_now.tv_sec -= sub->start; + + if (time_now.tv_sec >= (long int) sub->period) + time_now.tv_sec = 0; else - return (1 << (log - offset)); -} + time_now.tv_sec = sub->period - time_now.tv_sec; + l_debug("Sub Period (Log %2.2x) %d sec", uint32_to_log(time_now.tv_sec), + (int) time_now.tv_sec); -static int hb_subscription_set(struct mesh_net *net, uint16_t src, - uint16_t dst, uint8_t period_log) + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); + msg[n++] = status; + l_put_le16(sub->src, msg + n); + n += 2; + l_put_le16(sub->dst, msg + n); + n += 2; + msg[n++] = uint32_to_log(time_now.tv_sec); + msg[n++] = uint32_to_log(sub->count); + msg[n++] = sub->count ? sub->min_hops : 0; + msg[n++] = sub->max_hops; + + return n; +} + +static uint16_t hb_subscription_set(struct mesh_node *node, const uint8_t *pkt) { - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - struct timeval time_now; + uint16_t src, dst; + uint8_t period_log; + struct mesh_net *net; + int status; + + src = l_get_le16(pkt); + dst = l_get_le16(pkt + 2); /* SRC must be Unicast, DST can be any legal address except Virtual */ if ((!IS_UNASSIGNED(src) && !IS_UNICAST(src)) || IS_VIRTUAL(dst)) - return -1; - - /* Check if the subscription should be disabled */ - if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst)) { - if (IS_GROUP(hb->sub_dst)) - mesh_net_dst_unreg(net, hb->sub_dst); - - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; - hb->sub_dst = UNASSIGNED_ADDRESS; - hb->sub_src = UNASSIGNED_ADDRESS; - hb->sub_count = 0; - hb->sub_period = 0; - hb->sub_min_hops = 0; - hb->sub_max_hops = 0; - return MESH_STATUS_SUCCESS; - - } else if (!period_log && src == hb->sub_src && dst == hb->sub_dst) { - /* Preserve collected data, but disable */ - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; - hb->sub_period = 0; - return MESH_STATUS_SUCCESS; - } + return 0; - if (hb->sub_dst != dst) { - if (IS_GROUP(hb->sub_dst)) - mesh_net_dst_unreg(net, hb->sub_dst); - if (IS_GROUP(dst)) - mesh_net_dst_reg(net, dst); - } + period_log = pkt[4]; - hb->sub_enabled = !!period_log; - hb->sub_src = src; - hb->sub_dst = dst; - hb->sub_count = 0; - hb->sub_period = log_to_uint32(period_log, 1); - hb->sub_min_hops = 0x00; - hb->sub_max_hops = 0x00; + if (period_log > 0x11) + return 0; - gettimeofday(&time_now, NULL); - hb->sub_start = time_now.tv_sec; + net = node_get_net(node); - if (!hb->sub_enabled) { - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - return MESH_STATUS_SUCCESS; - } + status = mesh_net_set_heartbeat_sub(net, src, dst, period_log); - hb->sub_min_hops = 0xff; + return hb_subscription_get(node, status); +} - if (!hb->sub_timer) - hb->sub_timer = l_timeout_create(hb->sub_period, - hb_sub_timeout_func, net, NULL); - else - l_timeout_modify(hb->sub_timer, hb->sub_period); +static uint16_t hb_publication_get(struct mesh_node *node, int status) +{ + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_pub *pub = mesh_net_get_heartbeat_pub(net); + uint16_t n; - return MESH_STATUS_SUCCESS; + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg); + msg[n++] = status; + l_put_le16(pub->dst, msg + n); + n += 2; + msg[n++] = uint32_to_log(pub->count); + msg[n++] = uint32_to_log(pub->period); + msg[n++] = pub->ttl; + l_put_le16(pub->features, msg + n); + n += 2; + l_put_le16(pub->net_idx, msg + n); + n += 2; + + return n; +} + +static uint16_t hb_publication_set(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t dst, features, net_idx; + uint8_t period_log, count_log, ttl; + struct mesh_net *net; + int status; + + dst = l_get_le16(pkt); + count_log = pkt[2]; + period_log = pkt[3]; + ttl = pkt[4]; + + if (count_log > 0x11 && count_log != 0xff) + return 0; + + if (period_log > 0x11 || ttl > TTL_MASK || IS_VIRTUAL(dst)) + return 0; + + features = l_get_le16(pkt + 5) & 0xf; + net_idx = l_get_le16(pkt + 7); + + net = node_get_net(node); + + status = mesh_net_set_heartbeat_pub(net, dst, features, net_idx, ttl, + count_log, period_log); + + return hb_publication_get(node, status); } static void node_reset(void *user_data) @@ -738,10 +721,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct mesh_node *node = (struct mesh_node *) user_data; struct mesh_net *net; const uint8_t *pkt = data; - struct timeval time_now; uint32_t opcode; - int b_res = MESH_STATUS_SUCCESS; - struct mesh_net_heartbeat *hb; uint16_t n_idx; uint8_t state; bool virt = false; @@ -757,7 +737,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, return false; net = node_get_net(node); - hb = mesh_net_heartbeat_get(net); + l_debug("CONFIG-SRV-opcode 0x%x size %u idx %3.3x", opcode, size, net_idx); @@ -1030,113 +1010,35 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_HEARTBEAT_PUB_SET: - l_debug("OP_CONFIG_HEARTBEAT_PUB_SET"); + l_debug("Config Heartbeat Publication Set"); if (size != 9) return true; - if (pkt[2] > 0x11 || pkt[3] > 0x10 || pkt[4] > 0x7f) - return true; - else if (IS_VIRTUAL(l_get_le16(pkt))) - b_res = MESH_STATUS_INVALID_ADDRESS; - else if (l_get_le16(pkt + 7) != mesh_net_get_primary_idx(net)) - /* Future work: check for valid subnets */ - b_res = MESH_STATUS_INVALID_NETKEY; - - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, - msg); - msg[n++] = b_res; - - memcpy(&msg[n], pkt, 9); - - /* Ignore RFU bits in features */ - l_put_le16(l_get_le16(pkt + 5) & 0xf, &msg[n + 5]); - - /* Add octet count to status */ - n += 9; - - if (b_res != MESH_STATUS_SUCCESS) - break; - - hb->pub_dst = l_get_le16(pkt); - if (hb->pub_dst == UNASSIGNED_ADDRESS || - pkt[2] == 0 || pkt[3] == 0) { - /* - * We might still have a pub_dst here in case - * we need it for State Change heartbeat - */ - hb->pub_count = 0; - hb->pub_period = 0; - } else { - hb->pub_count = (pkt[2] != 0xff) ? - log_to_uint32(pkt[2], 1) : 0xffff; - hb->pub_period = log_to_uint32(pkt[3], 1); - } - - hb->pub_ttl = pkt[4]; - hb->pub_features = l_get_le16(pkt + 5) & 0xf; - hb->pub_net_idx = l_get_le16(pkt + 7); - update_hb_pub_timer(net, hb); - + n = hb_publication_set(node, pkt); break; case OP_CONFIG_HEARTBEAT_PUB_GET: if (size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg); - msg[n++] = b_res; - l_put_le16(hb->pub_dst, msg + n); - n += 2; - msg[n++] = uint32_to_log(hb->pub_count); - msg[n++] = uint32_to_log(hb->pub_period); - msg[n++] = hb->pub_ttl; - l_put_le16(hb->pub_features, msg + n); - n += 2; - l_put_le16(hb->pub_net_idx, msg + n); - n += 2; + n = hb_publication_get(node, MESH_STATUS_SUCCESS); break; case OP_CONFIG_HEARTBEAT_SUB_SET: if (size != 5) return true; - l_debug("Set Sub Period (Log %2.2x) %d sec", - pkt[4], log_to_uint32(pkt[4], 1)); - - b_res = hb_subscription_set(net, l_get_le16(pkt), - l_get_le16(pkt + 2), - pkt[4]); - if (b_res < 0) - return true; + l_debug("Set HB Sub Period Log %2.2x", pkt[4]); - /* Fall through */ + n = hb_subscription_set(node, pkt); + break; case OP_CONFIG_HEARTBEAT_SUB_GET: - if (opcode == OP_CONFIG_HEARTBEAT_SUB_GET && size != 0) - return true; - - gettimeofday(&time_now, NULL); - time_now.tv_sec -= hb->sub_start; - if (time_now.tv_sec >= (long int) hb->sub_period) - time_now.tv_sec = 0; - else - time_now.tv_sec = hb->sub_period - time_now.tv_sec; - - l_debug("Sub Period (Log %2.2x) %d sec", - uint32_to_log(time_now.tv_sec), - (int) time_now.tv_sec); + if (size != 0) + return true; - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); - msg[n++] = b_res; - l_put_le16(hb->sub_src, msg + n); - n += 2; - l_put_le16(hb->sub_dst, msg + n); - n += 2; - msg[n++] = uint32_to_log(time_now.tv_sec); - msg[n++] = uint32_to_log(hb->sub_count); - msg[n++] = hb->sub_count ? hb->sub_min_hops : 0; - msg[n++] = hb->sub_max_hops; + n = hb_subscription_get(node, MESH_STATUS_SUCCESS); break; case OP_CONFIG_POLL_TIMEOUT_GET: @@ -1166,13 +1068,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, static void cfgmod_srv_unregister(void *user_data) { - struct mesh_node *node = user_data; - struct mesh_net *net = node_get_net(node); - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - l_timeout_remove(hb->pub_timer); - l_timeout_remove(hb->sub_timer); - hb->pub_timer = hb->sub_timer = NULL; } static const struct mesh_model_ops ops = { diff --git a/mesh/net.c b/mesh/net.c index b54c647cb..5bfaa181a 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -23,6 +23,8 @@ #define _GNU_SOURCE +#include <sys/time.h> + #include <ell/ell.h> #include "mesh/mesh-defs.h" @@ -132,7 +134,10 @@ struct mesh_net { uint8_t count; } relay; - struct mesh_net_heartbeat heartbeat; + /* Heartbeat info */ + struct mesh_net_heartbeat_sub hb_sub; + struct mesh_net_heartbeat_pub hb_pub; + uint16_t features; struct l_queue *subnets; struct l_queue *msg_cache; @@ -255,35 +260,46 @@ static bool match_friend_key_id(const void *a, const void *b) (key_id == friend->net_key_upd); } -static void idle_mesh_heartbeat_send(void *net) +static void send_hb_publication(void *data) { - mesh_net_heartbeat_send(net); + struct mesh_net *net = data; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + uint8_t msg[4]; + int n = 0; + + if (pub->dst == UNASSIGNED_ADDRESS) + return; + + msg[n++] = NET_OP_HEARTBEAT; + msg[n++] = pub->ttl; + l_put_be16(net->features, msg + n); + n += 2; + + mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), + pub->ttl, 0, 0, pub->dst, msg, n); } static void trigger_heartbeat(struct mesh_net *net, uint16_t feature, - bool in_use) + bool enable) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - - l_debug("%s: %4.4x --> %d", __func__, feature, in_use); + l_debug("HB: %4.4x --> %d", feature, enable); - if (in_use) { - if (net->heartbeat.features & feature) + if (enable) { + if (net->features & feature) return; /* no change */ - hb->features |= feature; + net->features |= feature; } else { - if (!(hb->features & feature)) + if (!(net->features & feature)) return; /* no change */ - hb->features &= ~feature; + net->features &= ~feature; } - if (!(hb->pub_features & feature)) - return; /* not interested in this feature */ - - l_idle_oneshot(idle_mesh_heartbeat_send, net, NULL); + if (!(net->hb_pub.features & feature)) + return; /* no interest in this feature */ + l_idle_oneshot(send_hb_publication, net, NULL); } static bool match_by_friend(const void *a, const void *b) @@ -616,8 +632,6 @@ struct mesh_net *mesh_net_new(struct mesh_node *node) net->destinations = l_queue_new(); net->app_keys = l_queue_new(); - memset(&net->heartbeat, 0, sizeof(net->heartbeat)); - if (!nets) nets = l_queue_new(); @@ -813,8 +827,8 @@ int mesh_net_del_key(struct mesh_net *net, uint16_t idx) appkey_delete_bound_keys(net, idx); /* Disable hearbeat publication on this subnet */ - if (idx == net->heartbeat.pub_net_idx) - net->heartbeat.pub_dst = UNASSIGNED_ADDRESS; + if (idx == net->hb_pub.net_idx) + net->hb_pub.dst = UNASSIGNED_ADDRESS; /* TODO: cancel beacon_enable on this subnet */ @@ -2017,25 +2031,23 @@ static bool ctl_received(struct mesh_net *net, uint16_t key_id, break; case NET_OP_HEARTBEAT: - if (net->heartbeat.sub_enabled && - src == net->heartbeat.sub_src) { + if (net->hb_sub.enabled && src == net->hb_sub.src) { uint8_t hops = pkt[0] - ttl + 1; print_packet("Rx-NET_OP_HEARTBEAT", pkt, len); - if (net->heartbeat.sub_count != 0xffff) - net->heartbeat.sub_count++; + if (net->hb_sub.count != 0xffff) + net->hb_sub.count++; - if (net->heartbeat.sub_min_hops > hops) - net->heartbeat.sub_min_hops = hops; + if (net->hb_sub.min_hops > hops) + net->hb_sub.min_hops = hops; - if (net->heartbeat.sub_max_hops < hops) - net->heartbeat.sub_max_hops = hops; + if (net->hb_sub.max_hops < hops) + net->hb_sub.max_hops = hops; l_debug("HB: cnt:%4.4x min:%2.2x max:%2.2x", - net->heartbeat.sub_count, - net->heartbeat.sub_min_hops, - net->heartbeat.sub_max_hops); + net->hb_sub.count, net->hb_sub.min_hops, + net->hb_sub.max_hops); } break; } @@ -3276,52 +3288,14 @@ int mesh_net_update_key(struct mesh_net *net, uint16_t idx, return MESH_STATUS_SUCCESS; } -static uint16_t get_features(struct mesh_net *net) -{ - uint16_t features = 0; - - if (net->relay.enable) - features |= FEATURE_RELAY; - - if (net->proxy_enable) - features |= FEATURE_PROXY; - - if (net->friend_enable) - features |= FEATURE_FRIEND; - - return features; -} - -struct mesh_net_heartbeat *mesh_net_heartbeat_get(struct mesh_net *net) -{ - return &net->heartbeat; -} - -void mesh_net_heartbeat_send(struct mesh_net *net) +struct mesh_net_heartbeat_sub *mesh_net_get_heartbeat_sub(struct mesh_net *net) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - uint8_t msg[4]; - int n = 0; - - if (hb->pub_dst == UNASSIGNED_ADDRESS) - return; - - msg[n++] = NET_OP_HEARTBEAT; - msg[n++] = hb->pub_ttl; - l_put_be16(hb->features, msg + n); - n += 2; - - mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), - hb->pub_ttl, 0, 0, hb->pub_dst, msg, n); + return &net->hb_sub; } -void mesh_net_heartbeat_init(struct mesh_net *net) +struct mesh_net_heartbeat_pub *mesh_net_get_heartbeat_pub(struct mesh_net *net) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - - memset(hb, 0, sizeof(struct mesh_net_heartbeat)); - hb->sub_min_hops = 0xff; - hb->features = get_features(net); + return &net->hb_pub; } void mesh_net_set_iv_index(struct mesh_net *net, uint32_t index, bool update) @@ -3559,3 +3533,156 @@ void net_msg_add_replay_cache(struct mesh_net *net, uint16_t src, uint32_t seq, /* Optimize so that most recent conversations stay earliest in cache */ l_queue_push_head(net->replay_cache, rpe); } + +static void hb_sub_timeout_func(struct l_timeout *timeout, void *user_data) +{ + struct mesh_net *net = user_data; + struct mesh_net_heartbeat_sub *sub = &net->hb_sub; + + l_debug("HB Subscription Ended"); + l_timeout_remove(sub->timer); + sub->timer = NULL; + sub->enabled = false; +} + +static uint32_t log_to_uint32(uint8_t log) +{ + if (!log) + return 0x0000; + + return (1 << (log - 1)); +} + +int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, + uint8_t period_log) +{ + struct mesh_net_heartbeat_sub *sub = &net->hb_sub; + struct timeval time_now; + + if (!net) + return MESH_STATUS_UNSPECIFIED_ERROR; + + /* Check if the subscription should be disabled */ + if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst)) { + if (IS_GROUP(sub->dst)) + mesh_net_dst_unreg(net, sub->dst); + + sub->enabled = false; + sub->dst = UNASSIGNED_ADDRESS; + sub->src = UNASSIGNED_ADDRESS; + sub->count = 0; + sub->period = 0; + sub->min_hops = 0; + sub->max_hops = 0; + + } else if (!period_log && src == sub->src && dst == sub->dst) { + /* Preserve collected data, but disable */ + sub->enabled = false; + sub->period = 0; + + } else if (sub->dst != dst) { + if (IS_GROUP(sub->dst)) + mesh_net_dst_unreg(net, sub->dst); + + if (IS_GROUP(dst)) + mesh_net_dst_reg(net, dst); + + sub->enabled = !!period_log; + sub->src = src; + sub->dst = dst; + sub->count = 0; + sub->period = log_to_uint32(period_log); + sub->min_hops = 0x00; + sub->max_hops = 0x00; + gettimeofday(&time_now, NULL); + sub->start = time_now.tv_sec; + } + + /* TODO: Save to node config */ + + if (!sub->enabled) { + l_timeout_remove(sub->timer); + sub->timer = NULL; + return MESH_STATUS_SUCCESS; + } + + sub->min_hops = 0xff; + + if (!sub->timer) + sub->timer = l_timeout_create(sub->period, hb_sub_timeout_func, + net, NULL); + else + l_timeout_modify(sub->timer, sub->period); + + return MESH_STATUS_SUCCESS; +} + +static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) +{ + struct mesh_net *net = user_data; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + + send_hb_publication(net); + + if (pub->count != 0xffff) + pub->count--; + + if (pub->count > 0) + l_timeout_modify(pub->timer, pub->period); + else { + l_timeout_remove(pub->timer); + pub->timer = NULL; + } +} + +static void update_hb_pub_timer(struct mesh_net *net, + struct mesh_net_heartbeat_pub *pub) +{ + if (IS_UNASSIGNED(pub->dst) || pub->count == 0) { + l_timeout_remove(pub->timer); + pub->timer = NULL; + return; + } + + if (!pub->timer) + pub->timer = l_timeout_create(pub->period, + hb_pub_timeout_func, net, NULL); + else + l_timeout_modify(pub->timer, pub->period); +} + +int mesh_net_set_heartbeat_pub(struct mesh_net *net, uint16_t dst, + uint16_t features, uint16_t idx, uint8_t ttl, + uint8_t count_log, uint8_t period_log) +{ + struct mesh_subnet *subnet; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + + if (!net) + return MESH_STATUS_UNSPECIFIED_ERROR; + + subnet = l_queue_find(net->subnets, match_key_index, + L_UINT_TO_PTR(idx)); + if (!subnet) + return MESH_STATUS_INVALID_NETKEY; + + pub->dst = dst; + + if (pub->dst == UNASSIGNED_ADDRESS) { + pub->count = 0; + pub->period = 0; + pub->ttl = 0; + } else { + pub->count = (count_log != 0xff) ? + log_to_uint32(count_log) : 0xffff; + pub->period = log_to_uint32(period_log); + } + + pub->ttl = ttl; + pub->features = features; + pub->net_idx = idx; + update_hb_pub_timer(net, pub); + + /* TODO: Save to node config */ + return MESH_STATUS_SUCCESS; +} diff --git a/mesh/net.h b/mesh/net.h index 2673b895a..6d707436e 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -129,25 +129,27 @@ struct mesh_net_prov_caps { uint16_t input_action; } __packed; -struct mesh_net_heartbeat { - struct l_timeout *pub_timer; - struct l_timeout *sub_timer; - struct timeval sub_time; - bool sub_enabled; - uint32_t pub_period; - uint32_t sub_period; - uint32_t sub_start; - uint16_t pub_dst; - uint16_t pub_count; - uint16_t pub_features; +struct mesh_net_heartbeat_sub { + struct l_timeout *timer; + uint32_t start; + uint32_t period; uint16_t features; - uint16_t pub_net_idx; - uint16_t sub_src; - uint16_t sub_dst; - uint16_t sub_count; - uint8_t pub_ttl; - uint8_t sub_min_hops; - uint8_t sub_max_hops; + uint16_t src; + uint16_t dst; + uint16_t count; + bool enabled; + uint8_t min_hops; + uint8_t max_hops; +}; + +struct mesh_net_heartbeat_pub { + struct l_timeout *timer; + uint32_t period; + uint16_t dst; + uint16_t count; + uint16_t features; + uint16_t net_idx; + uint8_t ttl; }; struct mesh_key_set { @@ -328,9 +330,13 @@ void mesh_net_send_seg(struct mesh_net *net, uint32_t key_id, uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t src, uint16_t dst, uint32_t hdr, const void *seg, uint16_t seg_len); -struct mesh_net_heartbeat *mesh_net_heartbeat_get(struct mesh_net *net); -void mesh_net_heartbeat_init(struct mesh_net *net); -void mesh_net_heartbeat_send(struct mesh_net *net); +struct mesh_net_heartbeat_sub *mesh_net_get_heartbeat_sub(struct mesh_net *net); +int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, + uint8_t period_log); +struct mesh_net_heartbeat_pub *mesh_net_get_heartbeat_pub(struct mesh_net *net); +int mesh_net_set_heartbeat_pub(struct mesh_net *net, uint16_t dst, + uint16_t features, uint16_t idx, uint8_t ttl, + uint8_t count_log, uint8_t period_log); bool mesh_net_key_list_get(struct mesh_net *net, uint8_t *buf, uint16_t *count); uint16_t mesh_net_get_primary_idx(struct mesh_net *net); uint32_t mesh_net_friend_timeout(struct mesh_net *net, uint16_t addr); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SH40MgiXKV/00QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 19:12:40 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id GNyFMAiXKV8cIQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 19:12:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AD61041765; Tue, 4 Aug 2020 19:12:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729964AbgHDRMe (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 13:12:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729391AbgHDRMa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 13:12:30 -0400 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9185DC06174A for <linux-bluetooth@vger.kernel.org>; Tue, 4 Aug 2020 10:12:30 -0700 (PDT) Received: by mail-vs1-xe42.google.com with SMTP id j23so15092341vsq.7 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 10:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aldbhSzOkNRsGNiPJyEC/gglp+26OuNIUIYrm3hBhJE=; b=iX6Uye0aXNQArYfLdZEVLD/zW8NoQMEHi2sfdh9o/pwjVrCyRREZ3+tgmYgVBwQH01 VAmkPVQNbpkphKOQkbfN7v1XrkGtoZ/rB5kJYtyJaibhJwE3biZBN6x5w1xNBEd79NRz HMHeJcaQB7zR5LaEtOv3GRtFA811E+5vYp/0s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aldbhSzOkNRsGNiPJyEC/gglp+26OuNIUIYrm3hBhJE=; b=W/B74WfIlSHBO/s3g0n0l9n61KCpKVx3KqJ2p1T4r6TDo3iOVv35t/Md/C/cVm6Nly FW8TwY1qeYYzgdx0qtZBqo9UIcN9RKkr4LhPhFwUBdYGXIMn5eI3Yc0VU/6I1o3reCe1 Xg9sbMHuOxWReVW1wwq+aUqmKc9tskEZAfVrbub/vBp/vLY9sN9cRN66aMO3tSKxpMzo arnkJhLqTU0JcFp8DANVVO1H1/VvnzGdkj3oj3XjmPQ2EsYUkCxQB13FAGcvoI7zQecc CfolQlCbg75t/Z3p1gGt5HBOdHbUK6qLqF+D4PHzVx+7dJAzT/ZGhIwDdGdtIHpONXQK aWSQ== X-Gm-Message-State: AOAM531Qm91M4qkvUY6Oofh10OiJ4SX58JOvNiHxfaUCdiv/wmm2tJdk LJ105I1pAP26vTY9J6DPZCBMypsr+jRti5nBeSiSwg== X-Google-Smtp-Source: ABdhPJzexOr11cx+rybI7pAl/bxA0ZIEAMu48optiPZpp1K8AInizPGgxbP3/m/1O0WBMOGqxnCuJIYI1WI9zqhrkCM= X-Received: by 2002:a67:3111:: with SMTP id x17mr16188920vsx.196.1596561148224; Tue, 04 Aug 2020 10:12:28 -0700 (PDT) MIME-Version: 1.0 References: <20200729015540.1848987-1-abhishekpandit@chromium.org> In-Reply-To: <20200729015540.1848987-1-abhishekpandit@chromium.org> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Tue, 4 Aug 2020 10:12:16 -0700 Message-ID: <CANFp7mU3zRr2P7NBQKfNQQf7c-xb1T=cRys_=iGnoBBrVNFkZA@mail.gmail.com> Subject: Re: [RFC Bluez PATCH 0/3] adapter: Reconnect audio when resuming from suspend To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>, Marcel Holtmann <marcel@holtmann.org> Cc: ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: AD61041765 X-Rspamd-UID: acc2e5 Hi, Gentle reminder that this is waiting for feedback. Thanks Abhishek On Tue, Jul 28, 2020 at 6:55 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > > Hi Luiz and Marcel, > > This is a quality of life improvement for the behavior of audio devices > during system suspend. This depends on a kernel change that emits > suspend/resume events: > > https://patchwork.kernel.org/project/bluetooth/list/?series=325771 > > Right now, audio devices will be disconnected as part of suspend but > won't be reconnected when the system resumes without user interaction. > This is annoying to some users as it causes an interruption to their > normal work flow. > > This change reconnects audio devices that were disconnected for suspend > using the following logic: > > * In the Device Disconnected management event, if the disconnect reason > was 0x5 (Disconnected by Local Host for Suspend) and the device is an > audio sink (implements major services Audio + Rendering), then it is > queued for reconnect. > * When the Controller Resumed management event is seen, we check if > an audio device needs to be reconnected. If yes, we queue a delayed > callback to do the reconnection. The delay is 5s by default and is > meant to allow sufficient time for any Wi-Fi activity that may occur > during resume (since Bluetooth connect may adversely affect that). > > A reconnect is only attempted once after the controller resumes and the > delay between resume and reconnect is configurable via the > ReconnectAudioDelay key in the General settings. The 5s delay was chosen > arbitrarily and I think anywhere up to 10s is probably ok. A longer > delay is better to account for spurious wakeups and Wi-Fi reconnection > time (avoiding any co-ex issues) at the downside of reconnection speed. > > Here are the tests I have done with this: > - Single suspend and verified the headphones reconnect > - Suspend stress test for 25 iterations and verify both Wi-Fi and > Bluetooth audio reconnect on resume. (Ran with wake minimum time of > 10s) > - Suspend test with wake time < 5s to verify that BT reconnect isn't > attempted. Ran 5 iterations with low wake time and then let it stay > awake to confirm reconnect finally completed after 5s+ wake time. > - Suspend test with wake time between 3s - 6s. Ran with 5 iterations and > verified it wasn't connected at the end. A connection attempt was > made but not completed due to suspend. A reconnect attempt was not > made afterwards, which is by design. > > Luiz@ Marcel@: Does this sound ok (give up after an attempt)? > > I've tested this on a Pixelbook Go (AC-9260 controller) and HP > Chromebook 14a (RTL8822CE controller) with GID6B headset. I'm hoping to > test this with a few more headsets to make sure this is ok and I'm > looking for some early feedback. > > Thanks > Abhishek > > > > Abhishek Pandit-Subedi (3): > mgmt: Add controller suspend and resume events > monitor: Add btmon support for Suspend and Resume events > adapter: Reconnect audio on controller resume > > lib/mgmt.h | 14 +++++++++ > monitor/packet.c | 55 ++++++++++++++++++++++++++++++++ > src/adapter.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ > src/device.c | 27 ++++++++++++++++ > src/device.h | 2 ++ > src/main.conf | 6 ++++ > 6 files changed, 186 insertions(+) > > -- > 2.28.0.rc0.142.g3c755180ce-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SK0eI+GuKV+3bQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 20:54:25 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wBrRIeGuKV+xPwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 20:54:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5FA15A1B5E; Tue, 4 Aug 2020 20:54:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbgHDSyR (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 14:54:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726847AbgHDSyR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 14:54:17 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79E45C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 4 Aug 2020 11:54:17 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id 93so21217265otx.2 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 11:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ps2dcnol61iF2JZhyG1S/i1/3uCM6kYo4ZVmCayz3mk=; b=QtOKEYFaITmw8WtiXDBNJl1pCfhTFeeN+q3fvuo5jlOoF4mibmu6fKVmzL9OvpUo58 SjWJHIBadllhhfJj+PWuHhgDHxxCdqPhNjJnNDSHSEWWVdXh5lYdNOp0rpHxvClTtfxU EbQvhJVBNNgxNQIQzCbnu375TZ65As5a+lsjYQDLHEu2dMWdrrmaYgDv2VdCWPA6esmD mKKJ8GVRLBN617JIc327MDqZsVzYtEkor+YBgT1Z3DVoAxhtnWy3Pl1p+K+w58y0pZbo tGcV5CEEm2HtHm+gyBpEsCQGnLVStC2qzLh5tm09d7Dl4teKVy69rCk0z1KeDl0R8Bgp F5IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ps2dcnol61iF2JZhyG1S/i1/3uCM6kYo4ZVmCayz3mk=; b=oLrR1F2aR9OTHWN5K6JV28EhOG8z9y3B10spVO2+DozlVHn1kR4jfOZUv/zxtgxKlx Dkr/F0b9Sce8pzHmXaLLJXuNsqVMcF9Io+U8LxJ5Gn51fc59tBHvsWycB9vSphWpkWGu QIjIyhgo6ih5Pt4pnVJOC3l6hJYU0WXfzNH2uMUGUpFadxGhq8AMjxyDkzPzqvSnpsE7 Q39KWNbRJRp+pkv506QZF64TGBySN/cyA6Rr9o2V/WixWn1ctuPyqfT/8UBUiuh6HlIm 2gxohfe5KyCSrVd/D0UzIaxCNVwKlU8aArdezSFqn7HKhUWlWQxpjDjW3o3LTIAoCy2L 8BGA== X-Gm-Message-State: AOAM531mp7D2IHGv+hQxZS1dLNGLELRFDSia1e5QYayMDzRDMD6e1gUG 2YD2qMHm5kjDHwxbV7amFErlHbz/zYG7zYo7H/Y= X-Google-Smtp-Source: ABdhPJw5WlgvZ99C2zsQjJTLnF6S0EUXlaCnDaZg5J1G0PfJhSXm1j3l/EtuOs7FpogDlRxklZZkZbDrOe+vORiOHrM= X-Received: by 2002:a9d:39c2:: with SMTP id y60mr18787426otb.91.1596567256419; Tue, 04 Aug 2020 11:54:16 -0700 (PDT) MIME-Version: 1.0 References: <20200729015540.1848987-1-abhishekpandit@chromium.org> <5f20d725.1c69fb81.6d882.1d23@mx.google.com> In-Reply-To: <5f20d725.1c69fb81.6d882.1d23@mx.google.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 4 Aug 2020 11:54:06 -0700 Message-ID: <CABBYNZJMHCWm9-F3R1vpqcaazcieA=Dp9+fppQzmm+_-hfhzcw@mail.gmail.com> Subject: Re: [RFC Bluez PATCH 3/3] adapter: Reconnect audio on controller resume To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.78 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5FA15A1B5E X-Rspamd-UID: 465487 Hi Abhishek, On Tue, Jul 28, 2020 at 6:55 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > During system suspend, all peer devices are disconnected. On resume, HID > devices will reconnect but audio devices stay disconnected. As a quality > of life improvement, keep track of the last audio device disconnected > during suspend and try to reconnect when the controller resumes from > suspend. > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > --- > Hey Luiz, > > On our internal review, two things stood out in this commit that we > weren't able to come to a consensus on internally: > > * Is it better to use the audio device class or should we compare to the > A2DP, HFP and HSP uuids? > * Constructing the dbus message internally before calling dev_connect > looks a bit weird. I couldn't figure out how to internally trigger > this function (since it seems to require a msg to respond to on > success/failure). Any thoughts? > > > src/adapter.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ > src/device.c | 27 +++++++++++++++++ > src/device.h | 2 ++ > src/main.conf | 6 ++++ > 4 files changed, 117 insertions(+) > > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..b1073c439 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -90,6 +90,7 @@ > #define IDLE_DISCOV_TIMEOUT (5) > #define TEMP_DEV_TIMEOUT (3 * 60) > #define BONDING_TIMEOUT (2 * 60) > +#define RECONNECT_AUDIO_DELAY (5) > > #define SCAN_TYPE_BREDR (1 << BDADDR_BREDR) > #define SCAN_TYPE_LE ((1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM)) > @@ -269,6 +270,15 @@ struct btd_adapter { > struct btd_device *connect_le; /* LE device waiting to be connected */ > sdp_list_t *services; /* Services associated to adapter */ > > + /* audio device to reconnect after resuming from suspend */ > + struct reconnect_audio_info { > + bdaddr_t addr; > + uint8_t addr_type; > + bool reconnect; > + } reconnect_audio; > + guint reconnect_audio_timeout; /* timeout for reconnect on resume */ > + uint32_t reconnect_audio_delay; /* delay reconnect after resume */ > + > struct btd_gatt_database *database; > struct btd_adv_manager *adv_manager; > > @@ -6256,6 +6266,7 @@ static void load_config(struct btd_adapter *adapter) > /* Get discoverable mode */ > adapter->stored_discoverable = g_key_file_get_boolean(key_file, > "General", "Discoverable", &gerr); > + > if (gerr) { > adapter->stored_discoverable = false; > g_error_free(gerr); > @@ -6271,6 +6282,16 @@ static void load_config(struct btd_adapter *adapter) > gerr = NULL; > } > > + /* Get audio reconnect delay */ > + adapter->reconnect_audio_delay = g_key_file_get_integer( > + key_file, "General", "ReconnectAudioDelay", &gerr); > + > + if (gerr) { > + adapter->reconnect_audio_delay = RECONNECT_AUDIO_DELAY; > + g_error_free(gerr); > + gerr = NULL; > + } > + > g_key_file_free(key_file); > } > > @@ -7820,6 +7841,15 @@ static void dev_disconnected(struct btd_adapter *adapter, > if (device) { > adapter_remove_connection(adapter, device, addr->type); > disconnect_notify(device, reason); > + > + if (reason == MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND && > + device_class_is_audio(device)) { > + adapter->reconnect_audio.reconnect = true; > + adapter->reconnect_audio.addr_type = > + btd_device_get_bdaddr_type(device); > + bacpy(&adapter->reconnect_audio.addr, > + device_get_address(device)); > + } > } > > bonding_attempt_complete(adapter, &addr->bdaddr, addr->type, > @@ -8766,6 +8796,53 @@ static void connected_callback(uint16_t index, uint16_t length, > eir_data_free(&eir_data); > } > > +static gboolean reconnect_audio_timeout(gpointer user_data) > +{ > + struct btd_adapter *adapter = user_data; > + > + adapter->reconnect_audio_timeout = 0; > + > + if (adapter->reconnect_audio.reconnect) { > + struct btd_device *dev = btd_adapter_find_device( > + adapter, &adapter->reconnect_audio.addr, > + adapter->reconnect_audio.addr_type); > + > + adapter->reconnect_audio.reconnect = false; > + > + if (!dev || btd_device_is_connected(dev)) > + return FALSE; > + > + device_internal_connect(dev); > + } > + > + return FALSE; > +} > + > +static void controller_resume_callback(uint16_t index, uint16_t length, > + const void *param, void *user_data) > +{ > + const struct mgmt_ev_controller_resume *ev = param; > + struct btd_adapter *adapter = user_data; > + > + if (length < sizeof(*ev)) { > + btd_error(adapter->dev_id, "Too small device resume event"); > + return; > + } > + > + DBG("Controller resume with wake event 0x%x", ev->wake_reason); > + > + if (adapter->reconnect_audio_timeout > 0) { > + g_source_remove(adapter->reconnect_audio_timeout); > + adapter->reconnect_audio_timeout = 0; > + } > + > + if (adapter->reconnect_audio.reconnect) { > + adapter->reconnect_audio_timeout = > + g_timeout_add_seconds(adapter->reconnect_audio_delay, > + reconnect_audio_timeout, adapter); > + } > +} > + > static void device_blocked_callback(uint16_t index, uint16_t length, > const void *param, void *user_data) > { > @@ -9389,6 +9466,11 @@ static void read_info_complete(uint8_t status, uint16_t length, > user_passkey_notify_callback, > adapter, NULL); > > + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, > + adapter->dev_id, > + controller_resume_callback, > + adapter, NULL); > + > set_dev_class(adapter); > > set_name(adapter, btd_adapter_get_name(adapter)); > diff --git a/src/device.c b/src/device.c > index bb8e07e8f..8b165ffa4 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -747,6 +747,12 @@ gboolean device_is_trusted(struct btd_device *device) > return device->trusted; > } > > +bool device_class_is_audio(struct btd_device *device) > +{ > + /* Look for major service classes Audio (0x20) + Rendering (0x4) */ > + return ((device->class >> 16) & 0x24) == 0x24; > +} > + > static gboolean dev_property_get_address(const GDBusPropertyTable *property, > DBusMessageIter *iter, void *data) > { > @@ -6853,6 +6859,27 @@ struct btd_service *btd_device_get_service(struct btd_device *dev, > return NULL; > } > > +/* Internal function to connect to a device. This fakes the dbus message used to > + * call the "Connect" api on the device so that the same function can be called > + * by bluez internally. > + */ > +bool device_internal_connect(struct btd_device *dev) > +{ > + DBusMessage *msg; > + > + if (!device_is_connectable(dev)) > + return false; > + > + msg = dbus_message_new_method_call("org.bluez", > + device_get_path(dev), > + DEVICE_INTERFACE, > + "Connect"); > + /* Sending the message usually sets serial. Fake it here. */ > + dbus_message_set_serial(msg, 1); > + > + dev_connect(dbus_conn, msg, dev); > +} > + > void btd_device_init(void) > { > dbus_conn = btd_get_dbus_connection(); > diff --git a/src/device.h b/src/device.h > index 956fec1ae..82f97b5bd 100644 > --- a/src/device.h > +++ b/src/device.h > @@ -98,6 +98,7 @@ bool device_is_connectable(struct btd_device *device); > bool device_is_paired(struct btd_device *device, uint8_t bdaddr_type); > bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type); > gboolean device_is_trusted(struct btd_device *device); > +bool device_class_is_audio(struct btd_device *device); > void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type); > void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type); > void btd_device_set_temporary(struct btd_device *device, bool temporary); > @@ -186,6 +187,7 @@ int btd_device_connect_services(struct btd_device *dev, GSList *services); > uint32_t btd_device_get_current_flags(struct btd_device *dev); > void btd_device_flags_changed(struct btd_device *dev, uint32_t supported_flags, > uint32_t current_flags); > +bool device_internal_connect(struct btd_device *dev); > > void btd_device_init(void); > void btd_device_cleanup(void); > diff --git a/src/main.conf b/src/main.conf > index f41203b96..c6bb78a84 100644 > --- a/src/main.conf > +++ b/src/main.conf > @@ -82,6 +82,12 @@ > # 0 = disable timer, i.e. never keep temporary devices > #TemporaryTimeout = 30 > > +# How long to wait after controller resume before reconnecting to last used > +# audio device. > +# The value is in seconds. > +# Default: 5 > +#ReconnectAudioDelay = 5 > + > [Controller] > # The following values are used to load default adapter parameters. BlueZ loads > # the values into the kernel before the adapter is powered if the kernel > -- > 2.28.0.rc0.142.g3c755180ce-goog Usually connection policy is handled by the policy plugin since there may be platforms that want implement their own connection policies on top of bluetoothd so they can just disable the policy plugin, iirc we do have reconnection policies for unexpected disconnect which should probably be used in the event a suspend actually trigger a disconnection see: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/plugins/policy.c#n761 We might need a reason code to indicate to the policy when a disconnect happens due to suspend logic. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6HekGTibKV+8CgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 19:30:32 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kBNUFzibKV8YLwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 19:30:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5856BA1664; Tue, 4 Aug 2020 19:30:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728570AbgHDRaZ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 13:30:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbgHDRaY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 13:30:24 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB713C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 4 Aug 2020 10:30:23 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id f7so38207115wrw.1 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 10:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QcMS4tAZxi6H4xHOSqM9jReJTM3G2aGxItAR5kPpiU4=; b=ptrfQ5Abp2AwQP1Qpf69hwWx9hcPgweaP03bqx7ijqg0aT/BH/6/YKCKaBqLewwZKD nyOH9EVyg4TZLAZwMfQnX8+5+wSlJV6+Av82pi7NK4z58g1FYXPX1zSH9bWQWFFXxvRr mVqWOmw6TF+VzG07bSUvlhR9iv4kh9mg5MdkVC/+IBSyjSOITkZVm3k5+cAma180AqdX I5nGk7Pf686tX/FY6brwADCGbseARWhjkm7E5P/Gbun+9U332w9iJzNetKDv7Xa2CEv7 45OHmw7yiDxcIEE+b6cEJkEDI45nWdtvYTACykscClz694ALShGOhvtVJ2jJio3jE6D5 DBSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QcMS4tAZxi6H4xHOSqM9jReJTM3G2aGxItAR5kPpiU4=; b=gRagKw1OcRctosz/4vSRCYis6Ewc5umP11twNiyLyrQnBNJkK58zCMLUk6a7uMpcDG g548PMi8PyXLnqgyhi4AmRczmazuoSqR8ckWC3h4eJoDJVG2tCQtoNr2yzYntFr4y9lX GUnNpDVHu3olq6++fUjctiWeJEdKcxpBc0HmyaUCxTCELDlPNmYsrrjOrvT9jo/Kl1ua CRrWEZf7hBYOmplHbnD32IuZ39gpe7+Q+ScwKRM6ee8QynAr8fWatuEKc/3deGYaMLpR bAr8iQjrJmF/AYvytSYGBm9A1TEq8vf2VSBzhzCB24x3T6uNjnBNapg8zJ+65TDG+X98 qbhw== X-Gm-Message-State: AOAM530Km5sf0cpl8Ub0rH0i5Rowd20uEBsCEwe+votipfBbmwMnAxI1 i1JhrcOxgiDZZ58f6UAeQN4p6hzw+AZNUakkVoj2jg== X-Google-Smtp-Source: ABdhPJxU0OV+4f3J8HxTYU9IsJ696EFu8RXQI4z+9nJu8vs49J5o22+CIHP2+hzsaIiRh1P8EFYW9sTUPTMecMKQY7k= X-Received: by 2002:a5d:540c:: with SMTP id g12mr19890425wrv.120.1596562221818; Tue, 04 Aug 2020 10:30:21 -0700 (PDT) MIME-Version: 1.0 References: <20200708121928.bluez.v2.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> <CAJQfnxEBjHMAO=kTqRBExgS40g7=OJbv-NOTE1V=PM=K1sdGcw@mail.gmail.com> <CABBYNZ+dZsOGQZh6R3wGg3qPUep9tz7BzsDRH4__mbHKcL8P+g@mail.gmail.com> In-Reply-To: <CABBYNZ+dZsOGQZh6R3wGg3qPUep9tz7BzsDRH4__mbHKcL8P+g@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Wed, 5 Aug 2020 01:30:10 +0800 Message-ID: <CAJQfnxGvvfSHS8ZdYcBPN6Me8E4r76YkkDubnB71r_8MXsDSsQ@mail.gmail.com> Subject: Re: [bluez PATCH v2] avrcp: include all player settings in notif event To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Howard Chung <howardchung@google.com>, BlueZ <linux-bluetooth@vger.kernel.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5856BA1664 X-Rspamd-UID: e3e34f Hi Luiz, Is this the problem? https://lore.kernel.org/linux-bluetooth/5f05427c.1c69fb81.f61e.0992@mx.google.com/ If so, that has been resolved in v2. Regards, Archie On Wed, 5 Aug 2020 at 01:07, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Archie, > > On Tue, Aug 4, 2020 at 1:26 AM Archie Pusaka <apusaka@google.com> wrote: > > > > Hi Bluez maintainers, > > > > Could you take a look at this fix? > > Thank you! > > Has there been any new version? It looks like CI has caught some > problems with it or that has been resolved by V2? > > > Regards, > > Archie > > > > > > On Wed, 8 Jul 2020 at 12:19, Howard Chung <howardchung@google.com> wrote: > > > > > > According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player > > > application settings should be returned to the CT and let CT to > > > determine which settings have changed. Currently bluez only returns > > > the changed attribute instead. This patch also addresses a potential > > > issue on which the number of application settings mismatches with > > > the actual number returned. > > > > > > Reviewed-by: Archie Pusaka <apusaka@chromium.org> > > > --- > > > > > > Changes in v2: > > > - Fixed unused variables > > > > > > profiles/audio/avrcp.c | 71 +++++++++++++++++++----------------------- > > > 1 file changed, 32 insertions(+), 39 deletions(-) > > > > > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > > > index e2428250e..a4de7530e 100644 > > > --- a/profiles/audio/avrcp.c > > > +++ b/profiles/audio/avrcp.c > > > @@ -369,6 +369,7 @@ static uint32_t company_ids[] = { > > > }; > > > > > > static void avrcp_register_notification(struct avrcp *session, uint8_t event); > > > +static GList *player_list_settings(struct avrcp_player *player); > > > > > > static sdp_record_t *avrcp_ct_record(void) > > > { > > > @@ -743,6 +744,35 @@ static int play_status_to_val(const char *status) > > > return -EINVAL; > > > } > > > > > > +static uint16_t player_settings_changed(struct avrcp_player *player, > > > + struct avrcp_header *pdu) > > > +{ > > > + GList *settings = player_list_settings(player); > > > + int size = 2; > > > + > > > + for (; settings; settings = settings->next) { > > > + const char *key = settings->data; > > > + int attr; > > > + int val; > > > + > > > + attr = attr_to_val(key); > > > + if (attr < 0) > > > + continue; > > > + > > > + val = player_get_setting(player, attr); > > > + if (val < 0) > > > + continue; > > > + > > > + pdu->params[size++] = attr; > > > + pdu->params[size++] = val; > > > + } > > > + > > > + g_list_free(settings); > > > + > > > + pdu->params[1] = (size - 2) >> 1; > > > + return size; > > > +} > > > + > > > void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > const void *data) > > > { > > > @@ -751,8 +781,6 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > uint8_t code; > > > uint16_t size; > > > GSList *l; > > > - int attr; > > > - int val; > > > > > > if (player->sessions == NULL) > > > return; > > > @@ -791,19 +819,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > size = 1; > > > break; > > > case AVRCP_EVENT_SETTINGS_CHANGED: > > > - size = 2; > > > - pdu->params[1] = 1; > > > - > > > - attr = attr_to_val(data); > > > - if (attr < 0) > > > - return; > > > - > > > - val = player_get_setting(player, attr); > > > - if (val < 0) > > > - return; > > > - > > > - pdu->params[size++] = attr; > > > - pdu->params[size++] = val; > > > + size = player_settings_changed(player, pdu); > > > break; > > > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > > > size = 5; > > > @@ -1595,7 +1611,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > > > struct btd_device *dev = session->dev; > > > uint16_t len = ntohs(pdu->params_len); > > > uint64_t uid; > > > - GList *settings; > > > > > > /* > > > * 1 byte for EventID, 4 bytes for Playback interval but the latest > > > @@ -1626,29 +1641,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > > > len = 1; > > > break; > > > case AVRCP_EVENT_SETTINGS_CHANGED: > > > - len = 1; > > > - settings = player_list_settings(player); > > > - > > > - pdu->params[len++] = g_list_length(settings); > > > - for (; settings; settings = settings->next) { > > > - const char *key = settings->data; > > > - int attr; > > > - int val; > > > - > > > - attr = attr_to_val(key); > > > - if (attr < 0) > > > - continue; > > > - > > > - val = player_get_setting(player, attr); > > > - if (val < 0) > > > - continue; > > > - > > > - pdu->params[len++] = attr; > > > - pdu->params[len++] = val; > > > - } > > > - > > > - g_list_free(settings); > > > - > > > + len = player_settings_changed(player, pdu); > > > break; > > > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > > > len = 5; > > > -- > > > 2.27.0.383.g050319c2ae-goog > > > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eLKvB3PCKV918AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 22:17:55 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0Fa6BXPCKV8yMgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 22:17:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D4B53A1A49; Tue, 4 Aug 2020 22:17:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726580AbgHDURs (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 16:17:48 -0400 Received: from mga09.intel.com ([134.134.136.24]:64989 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725981AbgHDURr (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 16:17:47 -0400 IronPort-SDR: 65Qd8up8GwcOiaQJWWJeIDBMWwy9t9QNPJf3oUPi8Mlngoo7ky7VopwVn0M0s7ysb+dfAs2R9Y humhvfJqNHmA== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565369" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565369" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:46 -0700 IronPort-SDR: UfvKq+Z6u0vcQ7J4Qm/EdJsJp3283I0FX/vKgqLBHkc1z5PvaR99yTPaAhsvzrabmutLmLlkvw fKA+OaC/SuVw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783826" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:46 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v3 02/10] mesh: Clean up handling of config model binding messages Date: Tue, 4 Aug 2020 13:17:36 -0700 Message-Id: <20200804201744.23327-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804201744.23327-1-inga.stotland@intel.com> References: <20200804201744.23327-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: D4B53A1A49 X-Rspamd-UID: 83056f This modification allows using a single point for sending out the composed status messages by the Config Server. Also, remove unused definitions for binding functions in node.h --- mesh/cfgmod-server.c | 130 ++++++++++++------------------------------- mesh/model.c | 16 +----- mesh/node.h | 4 -- 3 files changed, 38 insertions(+), 112 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index cd0e8b94c..35d0325a9 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -112,8 +112,7 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; const uint8_t *pub_addr; uint16_t test_addr; - uint8_t ttl, period; - uint8_t retransmit; + uint8_t ttl, period, retransmit; int status; bool cred_flag; @@ -362,115 +361,56 @@ static uint16_t config_sub_del_all(struct mesh_node *node, const uint8_t *pkt, return n; } -static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t addr, - uint32_t id, uint16_t idx) -{ - size_t n = mesh_model_opcode_set(OP_MODEL_APP_STATUS, msg); - - msg[n++] = status; - l_put_le16(addr, msg + n); - n += 2; - l_put_le16(idx, msg + n); - n += 2; - - if (IS_VENDOR(id)) { - l_put_le16(VENDOR_ID(id), msg + n); - n += 2; - } - - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); -} - -static void model_app_list(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, +static uint16_t model_app_list(struct mesh_node *node, const uint8_t *pkt, uint16_t size) { - uint16_t ele_addr; + uint16_t ele_addr, n, bnd_len; uint32_t id; - uint8_t *status; - uint16_t n; - int result; + int opcode; + opcode = (size == 4) ? OP_MODEL_APP_LIST : OP_VEND_MODEL_APP_LIST; ele_addr = l_get_le16(pkt); - switch (size) { - default: - return; - case 4: - n = mesh_model_opcode_set(OP_MODEL_APP_LIST, msg); - status = msg + n; - id = l_get_le16(pkt + 2); - l_put_le16(ele_addr, msg + 1 + n); - l_put_le16((uint16_t) id, msg + 3 + n); - id = SET_ID(SIG_VENDOR, id); - n += 5; - break; - case 6: - n = mesh_model_opcode_set(OP_VEND_MODEL_APP_LIST, msg); - status = msg + n; - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); + n = mesh_model_opcode_set(opcode, msg); + memcpy(msg + n + 1, pkt, size); - l_put_le16(ele_addr, msg + 1 + n); - l_put_le16((uint16_t) VENDOR_ID(id), msg + 3 + n); - l_put_le16((uint16_t) MODEL_ID(id), msg + 5 + n); - n += 7; - break; - } + id = CFG_SET_ID(size == 6, pkt + 2); - result = mesh_model_get_bindings(node, ele_addr, id, msg + n, - MAX_MSG_LEN - n, &size); - n += size; + msg[n] = mesh_model_get_bindings(node, ele_addr, id, msg + n + 1 + size, + MAX_MSG_LEN - (n + 1 + size), &bnd_len); - if (result >= 0) { - *status = result; - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, - DEFAULT_TTL, false, msg, n); - } + if (msg[n] == MESH_STATUS_SUCCESS) + n += bnd_len; + + n += (size + 1); + return n; } -static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size, - bool unbind) +static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt, + uint16_t size, bool unbind) { - uint16_t ele_addr; + uint16_t ele_addr, idx, n; uint32_t id; - uint16_t idx; - int result; - switch (size) { - default: - return false; - case 6: - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); - break; - case 8: - id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); - break; - } + idx = l_get_le16(pkt + 2); + if (idx > APP_IDX_MASK) + return 0; ele_addr = l_get_le16(pkt); - idx = l_get_le16(pkt + 2); + id = CFG_SET_ID(size == 8, pkt + 4); - if (idx > 0xfff) - return false; + n = mesh_model_opcode_set(OP_MODEL_APP_STATUS, msg); if (unbind) - result = mesh_model_binding_del(node, ele_addr, id, idx); + msg[n] = mesh_model_binding_del(node, ele_addr, id, idx); else - result = mesh_model_binding_add(node, ele_addr, id, idx); + msg[n] = mesh_model_binding_add(node, ele_addr, id, idx); - send_model_app_status(node, net_idx, src, dst, result, ele_addr, - id, idx); + memcpy(msg + n + 1, pkt, size); + n += (size + 1); - return true; + return n; } static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) @@ -703,8 +643,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 1 || pkt[0] > TTL_MASK || pkt[0] == 1) return true; - if (pkt[0] <= TTL_MASK) - node_default_ttl_set(node, pkt[0]); + node_default_ttl_set(node, pkt[0]); /* Fall Through */ case OP_CONFIG_DEFAULT_TTL_GET: @@ -1048,22 +987,25 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_MODEL_APP_BIND: case OP_MODEL_APP_UNBIND: - model_app_bind(node, net_idx, src, dst, pkt, size, - opcode != OP_MODEL_APP_BIND); + if (size != 6 && size != 8) + return true; + + n = model_app_bind(node, pkt, size, + opcode != OP_MODEL_APP_BIND); break; case OP_VEND_MODEL_APP_GET: if (size != 6) return true; - model_app_list(node, net_idx, src, dst, pkt, size); + n = model_app_list(node, pkt, size); break; case OP_MODEL_APP_GET: if (size != 4) return true; - model_app_list(node, net_idx, src, dst, pkt, size); + n = model_app_list(node, pkt, size); break; case OP_CONFIG_HEARTBEAT_PUB_SET: diff --git a/mesh/model.c b/mesh/model.c index 3c9b6577a..e2cadfe36 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -111,13 +111,7 @@ static bool simple_match(const void *a, const void *b) static bool has_binding(struct l_queue *bindings, uint16_t idx) { - const struct l_queue_entry *l; - - for (l = l_queue_get_entries(bindings); l; l = l->next) { - if (L_PTR_TO_UINT(l->data) == idx) - return true; - } - return false; + return l_queue_find(bindings, simple_match, L_UINT_TO_PTR(idx)) != NULL; } static bool find_virt_by_label(const void *a, const void *b) @@ -628,7 +622,6 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, uint16_t app_idx, bool unbind) { struct mesh_model *mod; - bool is_present; int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) @@ -645,12 +638,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, if (!appkey_have_key(node_get_net(node), app_idx)) return MESH_STATUS_INVALID_APPKEY; - is_present = has_binding(mod->bindings, app_idx); - - if (!is_present && unbind) - return MESH_STATUS_SUCCESS; - - if (is_present && !unbind) + if (unbind ^ has_binding(mod->bindings, app_idx)) return MESH_STATUS_SUCCESS; if (unbind) { diff --git a/mesh/node.h b/mesh/node.h index 47c998530..7874b8692 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -49,10 +49,6 @@ const uint8_t *node_get_token(struct mesh_node *node); const uint8_t *node_get_device_key(struct mesh_node *node); void node_set_num_elements(struct mesh_node *node, uint8_t num_ele); uint8_t node_get_num_elements(struct mesh_node *node); -bool node_add_binding(struct mesh_node *node, uint8_t ele_idx, - uint32_t model_id, uint16_t app_idx); -bool node_del_binding(struct mesh_node *node, uint8_t ele_idx, - uint32_t model_id, uint16_t app_idx); uint8_t node_default_ttl_get(struct mesh_node *node); bool node_default_ttl_set(struct mesh_node *node, uint8_t ttl); bool node_set_sequence_number(struct mesh_node *node, uint32_t seq); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eD7ODHnCKV918AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 22:18:01 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AKXhCnnCKV/MdwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 22:18:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3AC4CA1965; Tue, 4 Aug 2020 22:17:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726752AbgHDURs (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 16:17:48 -0400 Received: from mga09.intel.com ([134.134.136.24]:64991 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726113AbgHDURs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 16:17:48 -0400 IronPort-SDR: JHSS/TuJOiBR4JrH3ZD7G6zeWsn2W5W0+5fbg56ilEfaaJbcmiP/umuT09TLTtCtK710rvybJa qPNwenMPxSSA== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565368" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565368" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:45 -0700 IronPort-SDR: m8XF26v8hJu+Eh4ncXmEJ1zFGHQkCJHYUPsMG2Rk7KPWJELT9/SJjiFD5oxAi0bsHY/ckyPSxa 8XyB9yXya2qw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783822" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:45 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v3 01/10] mesh: Clean up handling of config subscription messages Date: Tue, 4 Aug 2020 13:17:35 -0700 Message-Id: <20200804201744.23327-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3AC4CA1965 X-Rspamd-UID: 797675 This provides better functional grouping based on whether a group or a virtual label is used for the subscription address. Also, use a single point for sending out the composed Config Server status messages. --- mesh/cfgmod-server.c | 344 +++++++++++++++++----------------------- mesh/mesh-config-json.c | 12 +- mesh/mesh-config.h | 6 +- mesh/model.c | 211 ++++++++++++++---------- mesh/model.h | 21 ++- 5 files changed, 296 insertions(+), 298 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 7672ad3b6..cd0e8b94c 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -32,6 +32,10 @@ #include "mesh/mesh-config.h" #include "mesh/cfgmod.h" +#define CFG_SET_ID(vendor, pkt) ((vendor) ? \ + (SET_ID(l_get_le16((pkt)), l_get_le16((pkt) + 2))) : \ + (SET_ID(SIG_VENDOR, l_get_le16(pkt)))) + /* Supported composition pages, sorted high to low */ /* Only page 0 is currently supported */ static const uint8_t supported_pages[] = { @@ -185,237 +189,177 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, idx, cred_flag, ttl, period, retransmit); } -static void send_sub_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, - uint16_t addr, uint32_t id) +static uint16_t cfg_sub_get_msg(struct mesh_node *node, const uint8_t *pkt, + uint16_t size) { - int n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - - msg[n++] = status; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(addr, msg + n); - n += 2; - - if (IS_VENDOR(id)) { - l_put_le16(VENDOR_ID(id), msg + n); - l_put_le16(MODEL_ID(id), msg + n + 2); - n += 4; - } else { - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - } - - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); -} - -static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size) -{ - uint16_t ele_addr; + uint16_t ele_addr, n, sub_len; uint32_t id; - uint16_t n = 0; - int status; - uint8_t *msg_status; - uint16_t buf_size; + int opcode; + bool vendor = (size == 6); - /* Incoming message has already been size-checked */ ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); + opcode = vendor ? OP_CONFIG_VEND_MODEL_SUB_LIST : + OP_CONFIG_MODEL_SUB_LIST; + n = mesh_model_opcode_set(opcode, msg); + memcpy(msg + n + 1, pkt, size); - switch (size) { - default: - l_debug("Bad length %d", size); - return false; - - case 4: - id = l_get_le16(pkt + 2); - n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_LIST, msg); - msg_status = msg + n; - msg[n++] = 0; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(id, msg + n); - n += 2; - id = SET_ID(SIG_VENDOR, id); - break; - - case 6: - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - n = mesh_model_opcode_set(OP_CONFIG_VEND_MODEL_SUB_LIST, msg); - msg_status = msg + n; - msg[n++] = 0; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(VENDOR_ID(id), msg + n); - n += 2; - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - break; - } - - buf_size = sizeof(uint16_t) * MAX_GRP_PER_MOD; - status = mesh_model_sub_get(node, ele_addr, id, msg + n, buf_size, - &size); - - if (status == MESH_STATUS_SUCCESS) - n += size; + msg[n] = mesh_model_sub_get(node, ele_addr, id, msg + n + 1 + size, + MAX_MSG_LEN - (n + 1 + size), &sub_len); - *msg_status = (uint8_t) status; + if (msg[n] == MESH_STATUS_SUCCESS) + n += sub_len; - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); - return true; + n += (size + 1); + return n; } -static bool save_config_sub(struct mesh_node *node, uint16_t ele_addr, - uint32_t id, bool vendor, - const uint8_t *addr, bool virt, - uint16_t grp, uint32_t opcode) +static bool save_cfg_sub(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, bool vendor, const uint8_t *label, + bool virt, uint16_t grp, uint32_t opcode) { + struct mesh_config *cfg = node_config_get(node); struct mesh_config_sub db_sub = { .virt = virt, - .src.addr = grp + .addr.grp = grp }; + id = (vendor) ? id : MODEL_ID(id); + if (virt) - memcpy(db_sub.src.virt_addr, addr, 16); + memcpy(db_sub.addr.label, label, 16); + + if (opcode == OP_CONFIG_MODEL_SUB_VIRT_DELETE && + opcode == OP_CONFIG_MODEL_SUB_DELETE) + return mesh_config_model_sub_del(cfg, ele_addr, id, vendor, + &db_sub); if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE || opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) - mesh_config_model_sub_del_all(node_config_get(node), ele_addr, - vendor ? id : MODEL_ID(id), - vendor); - if (opcode != OP_CONFIG_MODEL_SUB_VIRT_DELETE && - opcode != OP_CONFIG_MODEL_SUB_DELETE) - return mesh_config_model_sub_add(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_sub); - else - return mesh_config_model_sub_del(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_sub); + if (!mesh_config_model_sub_del_all(cfg, ele_addr, id, vendor)) + return false; + + return mesh_config_model_sub_add(cfg, ele_addr, id, vendor, &db_sub); } -static void config_sub_set(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size, - bool virt, uint32_t opcode) +static uint16_t cfg_sub_add_msg(struct mesh_node *node, const uint8_t *pkt, + bool vendor, uint32_t opcode) { - uint16_t grp, ele_addr; + uint16_t addr, ele_addr, n; uint32_t id; - const uint8_t *addr = NULL; - int status = MESH_STATUS_SUCCESS; - bool vendor = false; - switch (size) { - default: - l_error("Bad length: %d", size); - return; - case 4: - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) - return; + addr = l_get_le16(pkt + 2); - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); - break; - case 6: - if (virt) - return; + if (!IS_GROUP(addr)) + return 0; - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); - } else { - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - vendor = true; - } + ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 4); - break; - case 8: - if (virt) - return; + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); - vendor = true; - break; - case 20: - if (!virt) - return; + if (opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) + msg[n] = mesh_model_sub_ovrt(node, ele_addr, id, addr); + else if (opcode == OP_CONFIG_MODEL_SUB_ADD) + msg[n] = mesh_model_sub_add(node, ele_addr, id, addr); + else + msg[n] = mesh_model_sub_del(node, ele_addr, id, addr); - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 18)); - break; - case 22: - if (!virt) - return; + if (msg[n] == MESH_STATUS_SUCCESS && + !save_cfg_sub(node, ele_addr, id, vendor, NULL, false, + addr, opcode)) + msg[n] = MESH_STATUS_STORAGE_FAIL; - vendor = true; - id = SET_ID(l_get_le16(pkt + 18), l_get_le16(pkt + 20)); - break; + if (vendor) { + memcpy(msg + n + 1, pkt, 8); + n += 9; + } else { + memcpy(msg + n + 1, pkt, 6); + n += 7; } + return n; +} + +static uint16_t cfg_virt_sub_add_msg(struct mesh_node *node, const uint8_t *pkt, + bool vendor, uint32_t opcode) +{ + uint16_t addr, ele_addr, n; + uint32_t id; + const uint8_t *label; + + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); + ele_addr = l_get_le16(pkt); + label = pkt + 2; + id = CFG_SET_ID(vendor, pkt + 18); + + if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE) + msg[n] = mesh_model_virt_sub_ovrt(node, ele_addr, id, label, + &addr); + else if (opcode == OP_CONFIG_MODEL_SUB_VIRT_ADD) + msg[n] = mesh_model_virt_sub_add(node, ele_addr, id, label, + &addr); + else + msg[n] = mesh_model_virt_sub_del(node, ele_addr, id, label, + &addr); - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - addr = pkt + 2; - grp = l_get_le16(addr); - } else - grp = UNASSIGNED_ADDRESS; + if (msg[n] == MESH_STATUS_SUCCESS && + !save_cfg_sub(node, ele_addr, id, vendor, + label, true, addr, opcode)) + msg[n] = MESH_STATUS_STORAGE_FAIL; - switch (opcode) { - default: - l_debug("Bad opcode: %x", opcode); - return; + l_put_le16(ele_addr, msg + n + 1); + l_put_le16(addr, msg + n + 3); - case OP_CONFIG_MODEL_SUB_DELETE_ALL: - status = mesh_model_sub_del_all(node, ele_addr, id); + if (vendor) { + l_put_le16(VENDOR_ID(id), msg + n + 5); + l_put_le16(MODEL_ID(id), msg + n + 7); + n += 9; + } else { + l_put_le16(MODEL_ID(id), msg + n + 5); + n += 7; + } - if (status == MESH_STATUS_SUCCESS) - mesh_config_model_sub_del_all(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor); - break; + return n; +} - case OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_OVERWRITE: - status = mesh_model_sub_ovr(node, ele_addr, id, - addr, virt, &grp); +static uint16_t config_sub_del_all(struct mesh_node *node, const uint8_t *pkt, + bool vendor) +{ + uint16_t ele_addr, n, grp = UNASSIGNED_ADDRESS; + uint32_t id; - if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, id, vendor, addr, - virt, grp, opcode); - break; - case OP_CONFIG_MODEL_SUB_VIRT_ADD: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_ADD: - status = mesh_model_sub_add(node, ele_addr, id, - addr, virt, &grp); + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - if (status == MESH_STATUS_SUCCESS && - !save_config_sub(node, ele_addr, id, vendor, - addr, virt, grp, opcode)) - status = MESH_STATUS_STORAGE_FAIL; + ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); - break; - case OP_CONFIG_MODEL_SUB_VIRT_DELETE: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_DELETE: - status = mesh_model_sub_del(node, ele_addr, id, addr, virt, - &grp); + msg[n] = mesh_model_sub_del_all(node, ele_addr, id); - if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, id, vendor, addr, - virt, grp, opcode); + if (msg[n] == MESH_STATUS_SUCCESS) { + struct mesh_config *cfg = node_config_get(node); - break; + if (!mesh_config_model_sub_del_all(cfg, ele_addr, + vendor ? id : MODEL_ID(id), + vendor)) + msg[n] = MESH_STATUS_STORAGE_FAIL; + } + + l_put_le16(ele_addr, msg + n + 1); + l_put_le16(grp, msg + n + 3); + + if (vendor) { + l_put_le16(VENDOR_ID(id), msg + n + 5); + l_put_le16(MODEL_ID(id), msg + n + 7); + n += 9; + } else { + l_put_le16(MODEL_ID(id), msg + n + 5); + n += 7; } - send_sub_status(node, net_idx, src, dst, status, ele_addr, grp, id); + return n; } static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, @@ -797,28 +741,38 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_VEND_MODEL_SUB_GET: if (size != 6) return true; - - config_sub_get(node, net_idx, src, dst, pkt, size); - break; + /* Fall Through */ case OP_CONFIG_MODEL_SUB_GET: - if (size != 4) + if (size != 4 && opcode == OP_CONFIG_MODEL_SUB_GET) return true; - config_sub_get(node, net_idx, src, dst, pkt, size); + n = cfg_sub_get_msg(node, pkt, size); break; case OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE: case OP_CONFIG_MODEL_SUB_VIRT_DELETE: case OP_CONFIG_MODEL_SUB_VIRT_ADD: - virt = true; - /* Fall Through */ + if (size != 20 && size != 22) + return true; + + n = cfg_virt_sub_add_msg(node, pkt, size == 22, opcode); + break; + case OP_CONFIG_MODEL_SUB_OVERWRITE: case OP_CONFIG_MODEL_SUB_DELETE: case OP_CONFIG_MODEL_SUB_ADD: + if (size != 6 && size != 8) + return true; + + n = cfg_sub_add_msg(node, pkt, size == 8, opcode); + break; + case OP_CONFIG_MODEL_SUB_DELETE_ALL: - config_sub_set(node, net_idx, src, dst, pkt, size, virt, - opcode); + if (size != 4 && size != 6) + return true; + + n = config_sub_del_all(node, pkt, size == 6); break; case OP_CONFIG_RELAY_SET: diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index deb0019f9..a40f92c01 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1069,11 +1069,11 @@ static bool parse_model_subscriptions(json_object *jsubs, switch (len) { case 4: - if (sscanf(str, "%04hx", &subs[i].src.addr) != 1) + if (sscanf(str, "%04hx", &subs[i].addr.grp) != 1) goto fail; break; case 32: - if (!str2hex(str, len, subs[i].src.virt_addr, 16)) + if (!str2hex(str, len, subs[i].addr.label, 16)) goto fail; subs[i].virt = true; break; @@ -2068,10 +2068,10 @@ bool mesh_config_model_sub_add(struct mesh_config *cfg, uint16_t ele_addr, return false; if (!sub->virt) { - snprintf(buf, 5, "%4.4x", sub->src.addr); + snprintf(buf, 5, "%4.4x", sub->addr.grp); len = 4; } else { - hex2str(sub->src.virt_addr, 16, buf, 33); + hex2str(sub->addr.label, 16, buf, 33); len = 32; } @@ -2122,10 +2122,10 @@ bool mesh_config_model_sub_del(struct mesh_config *cfg, uint16_t ele_addr, return true; if (!sub->virt) { - snprintf(buf, 5, "%4.4x", sub->src.addr); + snprintf(buf, 5, "%4.4x", sub->addr.grp); len = 4; } else { - hex2str(sub->src.virt_addr, 16, buf, 33); + hex2str(sub->addr.label, 16, buf, 33); len = 32; } diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 7dfa9f20c..f15f3f376 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -24,9 +24,9 @@ struct mesh_config; struct mesh_config_sub { bool virt; union { - uint16_t addr; - uint8_t virt_addr[16]; - } src; + uint16_t grp; + uint8_t label[16]; + } addr; }; struct mesh_config_pub { diff --git a/mesh/model.c b/mesh/model.c index ef7668147..3c9b6577a 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -664,7 +664,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } - if (l_queue_length(mod->bindings) >= MAX_BINDINGS) + if (l_queue_length(mod->bindings) >= MAX_MODEL_BINDINGS) return MESH_STATUS_INSUFF_RESOURCES; if (!mesh_config_model_binding_add(node_config_get(node), addr, @@ -737,7 +737,7 @@ static int set_virt_pub(struct mesh_model *mod, const uint8_t *label, } static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod, - const uint8_t *label, uint16_t *dst) + const uint8_t *label, uint16_t *addr) { struct mesh_virtual *virt = l_queue_find(mod->virtuals, find_virt_by_label, label); @@ -745,40 +745,35 @@ static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod, if (!virt) { virt = add_virtual(label); if (!virt) - return MESH_STATUS_STORAGE_FAIL; + return MESH_STATUS_INSUFF_RESOURCES; l_queue_push_head(mod->virtuals, virt); mesh_net_dst_reg(net, virt->addr); l_debug("Added virtual sub addr %4.4x", virt->addr); } - if (dst) - *dst = virt->addr; + if (addr) + *addr = virt->addr; return MESH_STATUS_SUCCESS; } static int add_sub(struct mesh_net *net, struct mesh_model *mod, - const uint8_t *group, bool b_virt, uint16_t *dst) + uint16_t addr) { - uint16_t grp; - - if (b_virt) - return add_virt_sub(net, mod, group, dst); - - grp = l_get_le16(group); - if (dst) - *dst = grp; + if (!mod->subs) + mod->subs = l_queue_new(); - if (!l_queue_find(mod->subs, simple_match, L_UINT_TO_PTR(grp))) { + if (l_queue_find(mod->subs, simple_match, L_UINT_TO_PTR(addr))) + return MESH_STATUS_SUCCESS; - if (!mod->subs) - mod->subs = l_queue_new(); + if ((l_queue_length(mod->subs) + l_queue_length(mod->virtuals)) >= + MAX_MODEL_SUBS) + return MESH_STATUS_INSUFF_RESOURCES; - l_queue_push_tail(mod->subs, L_UINT_TO_PTR(grp)); - mesh_net_dst_reg(net, grp); - l_debug("Added group subscription %4.4x", grp); - } + l_queue_push_tail(mod->subs, L_UINT_TO_PTR(addr)); + mesh_net_dst_reg(net, addr); + l_debug("Added group subscription %4.4x", addr); return MESH_STATUS_SUCCESS; } @@ -1454,8 +1449,8 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { struct mesh_model *mod; int status, ele_idx = node_get_element_idx(node, addr); @@ -1470,7 +1465,35 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - status = add_sub(node_get_net(node), mod, group, is_virt, dst); + status = add_sub(node_get_net(node), mod, addr); + if (status != MESH_STATUS_SUCCESS) + return status; + + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); + + return MESH_STATUS_SUCCESS; +} + +int mesh_model_virt_sub_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *pub_addr) +{ + struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; + + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + + status = add_virt_sub(node_get_net(node), mod, label, pub_addr); if (status != MESH_STATUS_SUCCESS) return status; @@ -1482,12 +1505,11 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { - struct l_queue *virtuals, *subs; struct mesh_model *mod; - int status, ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1499,36 +1521,39 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - subs = mod->subs; - virtuals = mod->virtuals; - mod->subs = l_queue_new(); - mod->virtuals = l_queue_new(); + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); - if (!mod->subs || !mod->virtuals) - return MESH_STATUS_INSUFF_RESOURCES; + add_sub(node_get_net(node), mod, addr); - status = add_sub(node_get_net(node), mod, group, is_virt, dst); + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); - if (status != MESH_STATUS_SUCCESS) { - /* Adding new group failed, so revert to old lists */ - l_queue_destroy(mod->subs, NULL); - mod->subs = subs; - l_queue_destroy(mod->virtuals, unref_virt); - mod->virtuals = virtuals; - } else { - const struct l_queue_entry *entry; - struct mesh_net *net = node_get_net(node); + return MESH_STATUS_SUCCESS; +} + +int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr) +{ + struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; - entry = l_queue_get_entries(subs); + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; - for (; entry; entry = entry->next) - mesh_net_dst_unreg(net, - (uint16_t) L_PTR_TO_UINT(entry->data)); + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); - /* Destroy old lists */ - l_queue_destroy(subs, NULL); - l_queue_destroy(virtuals, unref_virt); - } + status = add_virt_sub(node_get_net(node), mod, label, addr); if (!mod->cbs) /* External models */ @@ -1537,10 +1562,9 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, return status; } -int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { - uint16_t grp; struct mesh_model *mod; int ele_idx = node_get_element_idx(node, addr); @@ -1554,26 +1578,47 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - if (is_virt) { - struct mesh_virtual *virt; + if (l_queue_remove(mod->subs, L_UINT_TO_PTR(addr))) { + mesh_net_dst_unreg(node_get_net(node), addr); - virt = l_queue_find(mod->virtuals, find_virt_by_label, group); - if (virt) { - l_queue_remove(mod->virtuals, virt); - grp = virt->addr; - unref_virt(virt); - } else { - if (!mesh_crypto_virtual_addr(group, &grp)) - return MESH_STATUS_STORAGE_FAIL; - } - } else { - grp = l_get_le16(group); + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); } - *dst = grp; + return MESH_STATUS_SUCCESS; +} - if (l_queue_remove(mod->subs, L_UINT_TO_PTR(grp))) { - mesh_net_dst_unreg(node_get_net(node), grp); +int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr) +{ + struct mesh_model *mod; + struct mesh_virtual *virt; + int ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; + + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + + virt = l_queue_remove_if(mod->virtuals, find_virt_by_label, label); + + if (virt) { + *addr = virt->addr; + unref_virt(virt); + } else { + *addr = UNASSIGNED_ADDRESS; + return MESH_STATUS_SUCCESS; + } + + if (l_queue_remove(mod->subs, L_UINT_TO_PTR(*addr))) { + mesh_net_dst_unreg(node_get_net(node), *addr); if (!mod->cbs) /* External models */ @@ -1614,9 +1659,9 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, struct mesh_config_pub *pub = db_mod->pub; uint32_t i; - if (db_mod->num_bindings > MAX_BINDINGS) { + if (db_mod->num_bindings > MAX_MODEL_BINDINGS) { l_warn("Binding list too long %u (max %u)", - db_mod->num_bindings, MAX_BINDINGS); + db_mod->num_bindings, MAX_MODEL_BINDINGS); return NULL; } @@ -1670,22 +1715,12 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, return mod; for (i = 0; i < db_mod->num_subs; i++) { - uint16_t group; - uint8_t *src; + struct mesh_config_sub *sub = &db_mod->subs[i]; - /* - * To keep calculations for virtual label coherent, - * convert to little endian. - */ - l_put_le16(db_mod->subs[i].src.addr, &group); - src = db_mod->subs[i].virt ? db_mod->subs[i].src.virt_addr : - (uint8_t *) &group; - - if (add_sub(net, mod, src, db_mod->subs[i].virt, NULL) != - MESH_STATUS_SUCCESS) { - mesh_model_free(mod); - return NULL; - } + if (!sub->virt) + add_sub(net, mod, sub->addr.grp); + else + add_virt_sub(net, mod, sub->addr.label, NULL); } return mod; diff --git a/mesh/model.h b/mesh/model.h index 0d8dddf92..3221379af 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -19,8 +19,8 @@ struct mesh_model; -#define MAX_BINDINGS 10 -#define MAX_GRP_PER_MOD 10 +#define MAX_MODEL_BINDINGS 10 +#define MAX_MODEL_SUBS 10 #define ACTION_ADD 1 #define ACTION_UPDATE 2 @@ -89,12 +89,21 @@ int mesh_model_get_bindings(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_sz, uint16_t *len); int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); + uint16_t grp); +int mesh_model_virt_sub_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); + uint16_t grp); +int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id); -int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); +int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr); +int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size); uint16_t mesh_model_cfg_blk(uint8_t *pkt); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sNzwBH7CKV918AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 22:18:06 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6EtlAn7CKV/GswAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 22:18:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 51A2EA1BD0; Tue, 4 Aug 2020 22:18:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726810AbgHDURt (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 16:17:49 -0400 Received: from mga09.intel.com ([134.134.136.24]:64989 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbgHDURs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 16:17:48 -0400 IronPort-SDR: QruiDq78fjaIlbxRNxYaTwQCzBEFD1B5jhfZUsy4OBco/beYh11cRtKYxH2EtDrm2GUkHgOGXf CbVbHPohtI8A== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565377" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565377" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:46 -0700 IronPort-SDR: 1v5ZKe0Eu8t3XtIK+GMdk/vgSrNPNWRdnPc1RU3YR/lLJbXb4eVIVNMZom93iuRjqyZZ8JOz2K +pqeEpsg4mxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783831" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:46 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v3 03/10] mesh: Clean up handling of config node identity message Date: Tue, 4 Aug 2020 13:17:37 -0700 Message-Id: <20200804201744.23327-3-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804201744.23327-1-inga.stotland@intel.com> References: <20200804201744.23327-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 51A2EA1BD0 X-Rspamd-UID: bdc340 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 35d0325a9..c501b0a52 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -777,11 +777,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_NODE_IDENTITY_SET: - if (size != 3 || pkt[2] > 0x01) - return true; - - n_idx = l_get_le16(pkt); - if (n_idx > 0xfff) + if (size != 3) return true; /* Currently setting node identity not supported */ @@ -789,18 +785,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall Through */ case OP_NODE_IDENTITY_GET: - if (size < 2) + if (opcode == OP_NODE_IDENTITY_GET && size != 2) return true; n_idx = l_get_le16(pkt); - if (n_idx > 0xfff) - return true; n = mesh_model_opcode_set(OP_NODE_IDENTITY_STATUS, msg); - - status = mesh_net_get_identity_mode(net, n_idx, &state); - - msg[n++] = status; + msg[n++] = mesh_net_get_identity_mode(net, n_idx, &state); l_put_le16(n_idx, msg + n); n += 2; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WPt7CIPCKV+89gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 22:18:11 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id ACPlBoPCKV8+EAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 22:18:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2EE6BA1A49; Tue, 4 Aug 2020 22:18:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726859AbgHDURt (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 16:17:49 -0400 Received: from mga09.intel.com ([134.134.136.24]:64989 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726720AbgHDURs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 16:17:48 -0400 IronPort-SDR: Eobp0Wk3gS6c+LAvKzWJe26WNYJW8BCPNC+5RP7gC0LXSL9FhQ6eefLhM9mVVtdkP07VQjWFfK T9ZIcikeBF5A== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565390" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565390" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:48 -0700 IronPort-SDR: P5s/Xm0nn+psuihhxMk87xs/lrftw2Lb8XIjZ9csDGe1S3hNXZGEiJ0VjhDRCE36OyJ86AJRRR 5pbmOgJyOEYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783840" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:47 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v3 05/10] mesh: Clean up handling of config net and app key messages Date: Tue, 4 Aug 2020 13:17:39 -0700 Message-Id: <20200804201744.23327-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804201744.23327-1-inga.stotland@intel.com> References: <20200804201744.23327-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2EE6BA1A49 X-Rspamd-UID: 2ca93a This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 147 ++++++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 72 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 57646543d..030f9e744 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -547,6 +547,73 @@ static void node_reset(void *user_data) node_remove(node); } +static uint16_t cfg_appkey_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint16_t n_idx, a_idx, n; + struct mesh_net *net = node_get_net(node); + + n_idx = l_get_le16(pkt) & 0xfff; + a_idx = l_get_le16(pkt + 1) >> 4; + + n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); + + if (opcode == OP_APPKEY_ADD) + msg[n] = appkey_key_add(net, n_idx, a_idx, pkt + 3); + else if (opcode == OP_APPKEY_UPDATE) + msg[n] = appkey_key_update(net, n_idx, a_idx, pkt + 3); + else + msg[n] = appkey_key_delete(net, n_idx, a_idx); + + l_debug("AppKey Command %s: Net_Idx %3.3x, App_Idx %3.3x", + (msg[n] == MESH_STATUS_SUCCESS) ? "success" : "fail", + n_idx, a_idx); + + memcpy(msg + n + 1, &pkt[0], 3); + + return n + 4; +} + +static uint16_t cfg_netkey_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint16_t n_idx, n; + struct mesh_net *net = node_get_net(node); + + n_idx = l_get_le16(pkt); + n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); + + if (opcode == OP_NETKEY_ADD) + msg[n] = mesh_net_add_key(net, n_idx, pkt + 2); + else if (opcode == OP_NETKEY_UPDATE) + msg[n] = mesh_net_update_key(net, n_idx, pkt + 2); + else + msg[n] = mesh_net_del_key(net, n_idx); + + l_debug("NetKey Command %s: Net_Idx %3.3x", + (msg[n] == MESH_STATUS_SUCCESS) ? "success" : "fail", + n_idx); + + memcpy(msg + n + 1, &pkt[0], 2); + + return n + 3; +} + +static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t n_idx, sz, n; + + n_idx = l_get_le16(pkt); + + n = mesh_model_opcode_set(OP_APPKEY_LIST, msg); + l_put_le16(n_idx, msg + n + 1); + + msg[n] = appkey_list(node_get_net(node), n_idx, msg + n + 3, + MAX_MSG_LEN - (n + 3), &sz); + + return n + 3 + sz; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -585,7 +652,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint32_t opcode, tmp32; int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; - uint16_t n_idx, a_idx; + uint16_t n_idx; uint8_t state, status; uint8_t phase; bool virt = false; @@ -856,60 +923,19 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 19) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; - - if (opcode == OP_APPKEY_ADD) - b_res = appkey_key_add(net, n_idx, a_idx, pkt + 3); - else - b_res = appkey_key_update(net, n_idx, a_idx, - pkt + 3); - - l_debug("Add/Update AppKey %s: Net_Idx %3.3x, App_Idx %3.3x", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail", - n_idx, a_idx); - - - n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); - - msg[n++] = b_res; - msg[n++] = pkt[0]; - msg[n++] = pkt[1]; - msg[n++] = pkt[2]; - break; - + /* Fall Through */ case OP_APPKEY_DELETE: - if (size != 3) + if (opcode == OP_APPKEY_DELETE && size != 3) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; - b_res = appkey_key_delete(net, n_idx, a_idx); - l_debug("Delete AppKey %s Net_Idx %3.3x to App_Idx %3.3x", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail", - n_idx, a_idx); - - n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); - msg[n++] = b_res; - msg[n++] = pkt[0]; - msg[n++] = pkt[1]; - msg[n++] = pkt[2]; + n = cfg_appkey_msg(node, pkt, opcode); break; case OP_APPKEY_GET: if (size != 2) return true; - n_idx = l_get_le16(pkt); - - n = mesh_model_opcode_set(OP_APPKEY_LIST, msg); - - status = appkey_list(net, n_idx, msg + n + 3, - MAX_MSG_LEN - n - 3, &size); - - msg[n] = status; - l_put_le16(n_idx, msg + n + 1); - n += (size + 3); + n = cfg_get_appkeys_msg(node, pkt); break; case OP_NETKEY_ADD: @@ -917,35 +943,12 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 18) return true; - n_idx = l_get_le16(pkt); - - if (opcode == OP_NETKEY_ADD) - b_res = mesh_net_add_key(net, n_idx, pkt + 2); - else - b_res = mesh_net_update_key(net, n_idx, pkt + 2); - - l_debug("NetKey Add/Update %s", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail"); - - n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); - msg[n++] = b_res; - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; - break; - + /* Fall Through */ case OP_NETKEY_DELETE: - if (size != 2) + if (opcode == OP_NETKEY_DELETE && size != 2) return true; - b_res = mesh_net_del_key(net, l_get_le16(pkt)); - - l_debug("NetKey delete %s", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail"); - - n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); - msg[n++] = b_res; - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; + n = cfg_netkey_msg(node, pkt, opcode); break; case OP_NETKEY_GET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oAnpA4jCKV918AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 22:18:16 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id 6HmHAojCKV+kOwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 22:18:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 43C94A1BF8; Tue, 4 Aug 2020 22:18:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726927AbgHDURv (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 16:17:51 -0400 Received: from mga09.intel.com ([134.134.136.24]:64991 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726804AbgHDURt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 16:17:49 -0400 IronPort-SDR: Y84rKC+WdpIY3/mwNE06/XNqOyKWhx49z9zytu6uDqDCWSGukSxbWcZP01FrEbm9aiOcBm9uJJ llQshrNDe3tg== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565394" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565394" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:48 -0700 IronPort-SDR: 8zBlRNszDlZ13myN52ktE+5K2fi+7V8QI3upRMXBsBid4aF3jr3hA+25iytvZybtlovWly4qRd /LuzoUtzFq9Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783846" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:48 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v3 07/10] mesh: Clean up handling of config poll timeout message Date: Tue, 4 Aug 2020 13:17:41 -0700 Message-Id: <20200804201744.23327-7-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804201744.23327-1-inga.stotland@intel.com> References: <20200804201744.23327-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 43C94A1BF8 X-Rspamd-UID: c3e97b This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 34 +++++++++++++++++++++++----------- mesh/cfgmod.h | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 6ca1c1dd1..9b1375317 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -638,6 +638,25 @@ static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt) return n + 3 + sz; } +static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t n, addr = l_get_le16(pkt); + uint32_t poll_to; + + if (!IS_UNICAST(addr)) + return 0; + + n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); + l_put_le16(addr, msg + n); + n += 2; + + poll_to = mesh_net_friend_timeout(node_get_net(node), addr); + msg[n++] = poll_to; + msg[n++] = poll_to >> 8; + msg[n++] = poll_to >> 16; + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -673,7 +692,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct mesh_net *net; const uint8_t *pkt = data; struct timeval time_now; - uint32_t opcode, tmp32; + uint32_t opcode; int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; uint16_t n_idx; @@ -1109,18 +1128,11 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, msg[n++] = hb->sub_max_hops; break; - case OP_CONFIG_POLL_TIMEOUT_LIST: - if (size != 2 || l_get_le16(pkt) == 0 || - l_get_le16(pkt) > 0x7fff) + case OP_CONFIG_POLL_TIMEOUT_GET: + if (size != 2) return true; - n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; - tmp32 = mesh_net_friend_timeout(net, l_get_le16(pkt)); - msg[n++] = tmp32; - msg[n++] = tmp32 >> 8; - msg[n++] = tmp32 >> 16; + n = cfg_poll_timeout_msg(node, pkt); break; case OP_NODE_RESET: diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 7b6a95807..6d73656a7 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -66,7 +66,7 @@ #define OP_CONFIG_MODEL_SUB_LIST 0x802A #define OP_CONFIG_VEND_MODEL_SUB_GET 0x802B #define OP_CONFIG_VEND_MODEL_SUB_LIST 0x802C -#define OP_CONFIG_POLL_TIMEOUT_LIST 0x802D +#define OP_CONFIG_POLL_TIMEOUT_GET 0x802D #define OP_CONFIG_POLL_TIMEOUT_STATUS 0x802E /* Health opcodes in health-mod.h */ #define OP_CONFIG_HEARTBEAT_PUB_GET 0x8038 -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GB+zOIzCKV+89gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 22:18:20 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id kPopN4zCKV+kOwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 22:18:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 301B6A1965; Tue, 4 Aug 2020 22:18:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726935AbgHDURw (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 16:17:52 -0400 Received: from mga09.intel.com ([134.134.136.24]:64989 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbgHDURt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 16:17:49 -0400 IronPort-SDR: RBKp57p9NpxzVXaTp7QmSHWL4LrMyAZ+891ggqWrt5DTxPkfgfnEguibqRYoASBnbK/gxLmjC5 uq5qmzywjjSg== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565395" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565395" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:49 -0700 IronPort-SDR: O8d3fH5GhsfEP0PT2vZiN0L7SXonS2qEpD2QV5K/COWTfM2FZiKm7wZM2McnJvQKmXpxBocNKJ XnQTdlYwGMhg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783849" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:49 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v3 08/10] mesh: Clean up handling of config net transmit messages Date: Tue, 4 Aug 2020 13:17:42 -0700 Message-Id: <20200804201744.23327-8-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804201744.23327-1-inga.stotland@intel.com> References: <20200804201744.23327-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 301B6A1965 X-Rspamd-UID: 3c28b4 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 9b1375317..5b3ed3d97 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -657,6 +657,28 @@ static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) return n; } +static uint16_t cfg_net_tx_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t cnt; + uint16_t interval, n; + struct mesh_net *net = node_get_net(node); + + cnt = (pkt[0] & 0x7) + 1; + interval = ((pkt[0] >> 3) + 1) * 10; + + if (opcode == OP_CONFIG_NETWORK_TRANSMIT_SET && + mesh_config_write_net_transmit(node_config_get(node), + cnt, interval)) + mesh_net_transmit_params_set(net, cnt, interval); + + n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, msg); + + mesh_net_transmit_params_get(net, &cnt, &interval); + msg[n++] = (cnt - 1) + ((interval/10 - 1) << 3); + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -699,8 +721,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint8_t state, status; uint8_t phase; bool virt = false; - uint8_t count; - uint16_t interval; uint16_t n; if (app_idx != APP_IDX_DEV_LOCAL) @@ -821,25 +841,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_NETWORK_TRANSMIT_SET: if (size != 1) return true; - - count = (pkt[0] & 0x7) + 1; - interval = ((pkt[0] >> 3) + 1) * 10; - - if (mesh_config_write_net_transmit(node_config_get(node), count, - interval)) - mesh_net_transmit_params_set(net, count, interval); /* Fall Through */ case OP_CONFIG_NETWORK_TRANSMIT_GET: if (opcode == OP_CONFIG_NETWORK_TRANSMIT_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, - msg); - mesh_net_transmit_params_get(net, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Network Transmit Config"); + n = cfg_net_tx_msg(node, pkt, opcode); break; case OP_CONFIG_PROXY_SET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4DHeD53CKV+89gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 22:18:37 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id APz5Dp3CKV+CGAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 22:18:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0C658A1BEA; Tue, 4 Aug 2020 22:18:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726984AbgHDURz (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 16:17:55 -0400 Received: from mga09.intel.com ([134.134.136.24]:64989 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbgHDURt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 16:17:49 -0400 IronPort-SDR: 51mzmAnOZFda4tHcmnISHRtbn4fnqiWJ3JApP/hIuurV9ZK3ciEZlCHDeFi2GUVU/GVT2v+5uL YCnsJlzkihCQ== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565393" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565393" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:48 -0700 IronPort-SDR: yYxMPNnptyVkbpV4iz+vou+d7DPTps8lCIU2X+TOVGVaJqifGBOAMCTFxs1z8HtkLe0mOo72d4 7n73rOriGvIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783843" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:48 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v3 06/10] mesh: Clean up handling of config relay messages Date: Tue, 4 Aug 2020 13:17:40 -0700 Message-Id: <20200804201744.23327-6-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804201744.23327-1-inga.stotland@intel.com> References: <20200804201744.23327-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0C658A1BEA X-Rspamd-UID: cfdb90 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 030f9e744..6ca1c1dd1 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -396,6 +396,30 @@ static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt, return n; } +static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t count; + uint16_t interval; + uint16_t n; + + if (pkt[0] > 0x01) + return 0; + + if (opcode == OP_CONFIG_RELAY_SET) { + count = (pkt[1] & 0x7) + 1; + interval = ((pkt[1] >> 3) + 1) * 10; + node_relay_mode_set(node, !!pkt[0], count, interval); + } + + n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); + + msg[n++] = node_relay_mode_get(node, &count, &interval); + msg[n++] = (count - 1) + ((interval/10 - 1) << 3); + + return n; +} + static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; @@ -765,24 +789,14 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_RELAY_SET: - if (size != 2 || pkt[0] > 0x01) + if (size != 2) return true; - - count = (pkt[1] & 0x7) + 1; - interval = ((pkt[1] >> 3) + 1) * 10; - node_relay_mode_set(node, !!pkt[0], count, interval); /* Fall Through */ - case OP_CONFIG_RELAY_GET: if (opcode == OP_CONFIG_RELAY_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); - - msg[n++] = node_relay_mode_get(node, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Relay Config (%d)", msg[n-1]); + n = cfg_relay_msg(node, pkt, opcode); break; case OP_CONFIG_NETWORK_TRANSMIT_SET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2KHPGqLCKV+89gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 04 Aug 2020 22:18:42 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UKgqGaLCKV8EnAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 04 Aug 2020 22:18:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6230DA1306; Tue, 4 Aug 2020 22:18:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726987AbgHDUR4 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 16:17:56 -0400 Received: from mga09.intel.com ([134.134.136.24]:64991 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725981AbgHDURt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 16:17:49 -0400 IronPort-SDR: Fl2JyHvFPPjW9Fadun+vGO/qIP3EcnbhBRGE2Ngcj2U1aH4hBzsBbohJfHHVtEkZyvyGwL51Is 9dG33tOGpCuA== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565382" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565382" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:47 -0700 IronPort-SDR: tZGx8TUirL2GpoSvaupYMYyTVqmpsAy/TLPRT48FuwfsNQ4nVi1Gi4nXvkabWKLKqJNiTkGdvc Wx0SJMGLveQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783835" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:47 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v3 04/10] mesh: Clean up handling of config publication messages Date: Tue, 4 Aug 2020 13:17:38 -0700 Message-Id: <20200804201744.23327-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804201744.23327-1-inga.stotland@intel.com> References: <20200804201744.23327-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6230DA1306 X-Rspamd-UID: ce283c This modification allows using a single point for sending out the composed status messages by the Config Server. Also, return Feature Not Supported errror code when credential flag is set, but the node does not support LPN feature --- mesh/cfgmod-server.c | 99 ++++++++++++++++++-------------------------- mesh/model.c | 7 +++- mesh/net.h | 2 - 3 files changed, 46 insertions(+), 62 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index c501b0a52..57646543d 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -32,6 +32,8 @@ #include "mesh/mesh-config.h" #include "mesh/cfgmod.h" +#define CREDFLAG_MASK 0x1000 + #define CFG_SET_ID(vendor, pkt) ((vendor) ? \ (SET_ID(l_get_le16((pkt)), l_get_le16((pkt) + 2))) : \ (SET_ID(SIG_VENDOR, l_get_le16(pkt)))) @@ -44,11 +46,9 @@ static const uint8_t supported_pages[] = { static uint8_t msg[MAX_MSG_LEN]; -static void send_pub_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, uint32_t id, - uint16_t pub_addr, uint16_t idx, bool cred_flag, - uint8_t ttl, uint8_t period, uint8_t retransmit) +static uint16_t set_pub_status(uint8_t status, uint16_t ele_addr, uint32_t id, + uint16_t pub_addr, uint16_t idx, bool cred_flag, + uint8_t ttl, uint8_t period, uint8_t retransmit) { size_t n; @@ -72,46 +72,36 @@ static void send_pub_status(struct mesh_node *node, uint16_t net_idx, n += 4; } - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); + return n; } -static void config_pub_get(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size) +static uint16_t config_pub_get(struct mesh_node *node, const uint8_t *pkt, + bool vendor) { uint32_t id; uint16_t ele_addr; struct mesh_model_pub *pub; int status; - if (size == 4) { - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); - } else if (size == 6) { - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - } else - return; - ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); + pub = mesh_model_pub_get(node, ele_addr, id, &status); if (pub && status == MESH_STATUS_SUCCESS) - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, pub->addr, pub->idx, pub->credential, - pub->ttl, pub->period, pub->retransmit); + return set_pub_status(status, ele_addr, id, pub->addr, pub->idx, + pub->credential, pub->ttl, pub->period, + pub->retransmit); else - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, 0, 0, 0, 0, 0, 0); + return set_pub_status(status, ele_addr, id, 0, 0, 0, 0, 0, 0); } -static void config_pub_set(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, bool virt, bool vendor) +static uint16_t config_pub_set(struct mesh_node *node, const uint8_t *pkt, + bool virt, bool vendor) { uint32_t id; - uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; + uint16_t ele_addr, idx, pub_dst; const uint8_t *pub_addr; - uint16_t test_addr; uint8_t ttl, period, retransmit; int status; bool cred_flag; @@ -119,42 +109,35 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, ele_addr = l_get_le16(pkt); pub_addr = pkt + 2; - pkt += (virt ? 14 : 0); + pub_dst = l_get_le16(pub_addr); - idx = l_get_le16(pkt + 4); - ttl = pkt[6]; - period = pkt[7]; - retransmit = pkt[8]; - id = l_get_le16(pkt + 9); + if (!virt && IS_VIRTUAL(pub_dst)) + return 0; - if (!vendor) - id = SET_ID(SIG_VENDOR, id); - else - id = SET_ID(id, l_get_le16(pkt + 11)); + pkt += (virt ? 14 : 0); - /* Don't accept virtual seeming addresses */ - test_addr = l_get_le16(pub_addr); - if (!virt && IS_VIRTUAL(test_addr)) - return; + idx = l_get_le16(pkt + 4); + if (idx > CREDFLAG_MASK) + return 0; cred_flag = !!(CREDFLAG_MASK & idx); idx &= APP_IDX_MASK; + ttl = pkt[6]; + period = pkt[7]; + retransmit = pkt[8]; + id = CFG_SET_ID(vendor, pkt + 9); status = mesh_model_pub_set(node, ele_addr, id, pub_addr, idx, cred_flag, ttl, period, retransmit, - virt, &ota); - - l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, mod: %x, idx: %3.3x", - status, ele_addr, ota, id, idx); + virt, &pub_dst); - if (status != MESH_STATUS_SUCCESS) { - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, 0, 0, 0, 0, 0, 0); + l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, id: %x, idx: %3.3x", + status, ele_addr, pub_dst, id, idx); - return; - } + if (status != MESH_STATUS_SUCCESS) + return set_pub_status(status, ele_addr, id, 0, 0, 0, 0, 0, 0); - if (IS_UNASSIGNED(test_addr) && !virt) { + if (IS_UNASSIGNED(pub_dst) && !virt) { ttl = period = idx = 0; /* Remove model publication from config file */ @@ -165,7 +148,7 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, } else { struct mesh_config_pub db_pub = { .virt = virt, - .addr = ota, + .addr = pub_dst, .idx = idx, .ttl = ttl, .credential = cred_flag, @@ -180,12 +163,12 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, /* Save model publication to config file */ if (!mesh_config_model_pub_add(node_config_get(node), ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_pub)) + vendor, &db_pub)) status = MESH_STATUS_STORAGE_FAIL; } - send_pub_status(node, net_idx, src, dst, status, ele_addr, id, ota, - idx, cred_flag, ttl, period, retransmit); + return set_pub_status(status, ele_addr, id, pub_dst, idx, cred_flag, + ttl, period, retransmit); } static uint16_t cfg_sub_get_msg(struct mesh_node *node, const uint8_t *pkt, @@ -667,14 +650,14 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (!virt && (size != 11 && size != 13)) return true; - config_pub_set(node, net_idx, src, dst, pkt, virt, - size == 13 || size == 27); + n = config_pub_set(node, pkt, virt, size == 13 || size == 27); break; case OP_CONFIG_MODEL_PUB_GET: if (size != 4 && size != 6) return true; - config_pub_get(node, net_idx, src, dst, pkt, size); + + n = config_pub_get(node, pkt, size == 6); break; case OP_CONFIG_VEND_MODEL_SUB_GET: diff --git a/mesh/model.c b/mesh/model.c index e2cadfe36..a92ab6b43 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -1072,7 +1072,7 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *pub_addr, uint16_t idx, bool cred_flag, uint8_t ttl, uint8_t period, uint8_t retransmit, - bool is_virt, uint16_t *dst) + bool is_virt, uint16_t *pub_dst) { struct mesh_model *mod; int status, ele_idx = node_get_element_idx(node, addr); @@ -1099,6 +1099,9 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } + if (cred_flag && node_lpn_mode_get(node) != MESH_MODE_ENABLED) + return MESH_STATUS_FEATURE_NO_SUPPORT; + /* Check if the old publication destination is a virtual label */ if (mod->pub && mod->pub->virt) { unref_virt(mod->pub->virt); @@ -1112,7 +1115,7 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, status = set_virt_pub(mod, pub_addr, idx, cred_flag, ttl, period, retransmit); - *dst = mod->pub->addr; + *pub_dst = mod->pub->addr; if (status != MESH_STATUS_SUCCESS) return status; diff --git a/mesh/net.h b/mesh/net.h index 7117f1a47..2673b895a 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -32,8 +32,6 @@ struct mesh_node; #define CTL 0x80 -#define CREDFLAG_MASK 0x1000 - #define KEY_CACHE_SIZE 64 #define FRND_CACHE_MAX 32 -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6C+AIe/vKV9iCgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 01:31:59 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 4GWfH+/vKV9JLAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 01:31:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B3D81A1751; Wed, 5 Aug 2020 01:31:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726104AbgHDXbw convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 19:31:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:58660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbgHDXbw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 19:31:52 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 206457] Gamepad Dualshock4 CUH-ZCT2U doesn't pair or connect Date: Tue, 04 Aug 2020 23:31:50 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: blocking X-Bugzilla-Who: arael78@gmail.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-206457-62941-VVTUSo6AZ4@https.bugzilla.kernel.org/> In-Reply-To: <bug-206457-62941@https.bugzilla.kernel.org/> References: <bug-206457-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.52 / 15.00 / 200.00 X-Rspamd-Queue-Id: B3D81A1751 X-Rspamd-UID: b137fe https://bugzilla.kernel.org/show_bug.cgi?id=206457 --- Comment #5 from arael78@gmail.com --- Here is the log from running bluetoothd with options -n an -d: The dualshock device is D0_27_96_19_12_33. bluetoothd[9774]: src/adapter.c:device_found_callback() hci0 addr D0:27:96:19:12:33, rssi -51 flags 0x0000 eir_len 42 bluetoothd[9774]: src/device.c:device_create() dst D0:27:96:19:12:33 bluetoothd[9774]: src/device.c:device_new() address D0:27:96:19:12:33 bluetoothd[9774]: src/device.c:device_new() Creating device /org/bluez/hci0/dev_D0_27_96_19_12_33 bluetoothd[9774]: src/device.c:device_set_legacy() legacy 0 bluetoothd[9774]: src/device.c:device_set_rssi_with_delta() rssi -51 bluetoothd[9774]: src/device.c:device_set_class() /org/bluez/hci0/dev_D0_27_96_19_12_33 0x002508 bluetoothd[9774]: src/device.c:btd_device_set_temporary() temporary 0 bluetoothd[9774]: src/agent.c:agent_ref() 0x5579ce015af0: ref=2 bluetoothd[9774]: src/device.c:bonding_request_new() Requesting bonding for D0:27:96:19:12:33 bluetoothd[9774]: src/agent.c:agent_ref() 0x5579ce015af0: ref=3 bluetoothd[9774]: src/agent.c:agent_unref() 0x5579ce015af0: ref=2 bluetoothd[9774]: src/adapter.c:suspend_discovery() bluetoothd[9774]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr D0:27:96:19:12:33 type 0 io_cap 0x01 bluetoothd[9774]: src/adapter.c:add_whitelist_complete() D0:27:96:19:12:33 added to kernel whitelist bluetoothd[9774]: src/adapter.c:suspend_discovery_complete() status 0x00 bluetoothd[9774]: src/adapter.c:discovering_callback() hci0 type 7 discovering 0 method 1 bluetoothd[9774]: src/adapter.c:connected_callback() hci0 device D0:27:96:19:12:33 connected eir_len 26 bluetoothd[9774]: src/adapter.c:new_link_key_callback() hci0 new key for D0:27:96:19:12:33 type 4 pin_len 0 store_hint 1 bluetoothd[9774]: src/device.c:device_set_bonded() bluetoothd[9774]: src/device.c:device_bonding_complete() bonding 0x5579ce036410 status 0x00 bluetoothd[9774]: src/device.c:device_bonding_complete() Proceeding with service discovery bluetoothd[9774]: src/agent.c:agent_unref() 0x5579ce015af0: ref=1 bluetoothd[9774]: src/adapter.c:resume_discovery() bluetoothd[9774]: src/adapter.c:trigger_start_discovery() bluetoothd[9774]: src/adapter.c:cancel_passive_scanning() bluetoothd[9774]: src/adapter.c:pair_device_complete() Success (0x00) bluetoothd[9774]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr D0:27:96:19:12:33 type 0 status 0x0 bluetoothd[9774]: src/device.c:device_bonding_complete() bonding (nil) status 0x00 bluetoothd[9774]: src/adapter.c:resume_discovery() bluetoothd[9774]: src/adapter.c:trigger_start_discovery() bluetoothd[9774]: src/adapter.c:cancel_passive_scanning() bluetoothd[9774]: src/adapter.c:start_discovery_timeout() bluetoothd[9774]: src/adapter.c:start_discovery_timeout() adapter->current_discovery_filter == 1 bluetoothd[9774]: src/adapter.c:start_discovery_timeout() sending MGMT_OP_START_SERVICE_DISCOVERY 127, 7, 0 bluetoothd[9774]: src/adapter.c:start_discovery_complete() status 0x00 bluetoothd[9774]: src/adapter.c:discovering_callback() hci0 type 7 discovering 1 method 1 bluetoothd[9774]: src/adapter.c:device_found_callback() hci0 addr 02:11:8D:DA:78:CB, rssi -92 flags 0x0004 eir_len 31 bluetoothd[9774]: src/device.c:device_set_legacy() legacy 0 bluetoothd[9774]: src/device.c:device_set_rssi_with_delta() rssi -92 delta 0 bluetoothd[9774]: src/device.c:device_set_flags() flags 0 bluetoothd[9774]: src/adapter.c:device_found_callback() hci0 addr 02:11:8D:DA:78:CB, rssi -92 flags 0x0004 eir_len 31 bluetoothd[9774]: src/device.c:device_set_legacy() legacy 0 bluetoothd[9774]: src/device.c:device_set_rssi_with_delta() rssi -92 delta 0 bluetoothd[9774]: src/device.c:device_set_flags() flags 0 bluetoothd[9774]: src/adapter.c:discovering_callback() hci0 type 7 discovering 0 method 1 bluetoothd[9774]: src/adapter.c:trigger_start_discovery() bluetoothd[9774]: src/adapter.c:cancel_passive_scanning() bluetoothd[9774]: src/adapter.c:start_discovery_timeout() bluetoothd[9774]: src/adapter.c:start_discovery_timeout() adapter->current_discovery_filter == 1 bluetoothd[9774]: src/adapter.c:start_discovery_timeout() sending MGMT_OP_START_SERVICE_DISCOVERY 127, 7, 0 bluetoothd[9774]: src/adapter.c:start_discovery_complete() status 0x00 bluetoothd[9774]: src/adapter.c:discovering_callback() hci0 type 7 discovering 1 method 1 bluetoothd[9774]: src/adapter.c:device_found_callback() hci0 addr 02:11:8D:DA:78:CB, rssi -92 flags 0x0004 eir_len 31 bluetoothd[9774]: src/device.c:device_set_legacy() legacy 0 bluetoothd[9774]: src/device.c:device_set_rssi_with_delta() rssi -92 delta 0 bluetoothd[9774]: src/device.c:device_set_flags() flags 0 bluetoothd[9774]: src/adapter.c:discovering_callback() hci0 type 7 discovering 0 method 1 bluetoothd[9774]: src/adapter.c:trigger_start_discovery() bluetoothd[9774]: src/adapter.c:cancel_passive_scanning() bluetoothd[9774]: src/adapter.c:start_discovery_timeout() bluetoothd[9774]: src/adapter.c:start_discovery_timeout() adapter->current_discovery_filter == 1 bluetoothd[9774]: src/adapter.c:start_discovery_timeout() sending MGMT_OP_START_SERVICE_DISCOVERY 127, 7, 0 bluetoothd[9774]: src/adapter.c:start_discovery_complete() status 0x00 bluetoothd[9774]: src/adapter.c:discovering_callback() hci0 type 7 discovering 1 method 1 bluetoothd[9774]: src/adapter.c:device_found_callback() hci0 addr 02:11:8D:DA:78:CB, rssi -92 flags 0x0004 eir_len 31 bluetoothd[9774]: src/device.c:device_set_legacy() legacy 0 bluetoothd[9774]: src/device.c:device_set_rssi_with_delta() rssi -92 delta 0 bluetoothd[9774]: src/device.c:device_set_flags() flags 0 bluetoothd[9774]: src/adapter.c:device_found_callback() hci0 addr 02:11:8D:DA:78:CB, rssi -93 flags 0x0004 eir_len 31 bluetoothd[9774]: src/device.c:device_set_legacy() legacy 0 bluetoothd[9774]: src/device.c:device_set_rssi_with_delta() rssi -93 delta 1 bluetoothd[9774]: src/device.c:device_set_flags() flags 0 bluetoothd[9774]: src/adapter.c:device_found_callback() hci0 addr 02:11:8D:DA:78:CB, rssi -92 flags 0x0004 eir_len 31 bluetoothd[9774]: src/device.c:device_set_legacy() legacy 0 bluetoothd[9774]: src/device.c:device_set_rssi_with_delta() rssi -92 delta 1 bluetoothd[9774]: src/device.c:device_set_flags() flags 0 bluetoothd[9774]: src/adapter.c:discovering_callback() hci0 type 7 discovering 0 method 1 bluetoothd[9774]: src/adapter.c:trigger_start_discovery() bluetoothd[9774]: src/adapter.c:cancel_passive_scanning() bluetoothd[9774]: src/adapter.c:start_discovery_timeout() bluetoothd[9774]: src/adapter.c:start_discovery_timeout() adapter->current_discovery_filter == 1 bluetoothd[9774]: src/adapter.c:start_discovery_timeout() sending MGMT_OP_START_SERVICE_DISCOVERY 127, 7, 0 bluetoothd[9774]: src/adapter.c:start_discovery_complete() status 0x00 bluetoothd[9774]: src/adapter.c:discovering_callback() hci0 type 7 discovering 1 method 1 bluetoothd[9774]: src/adapter.c:device_found_callback() hci0 addr 02:11:8D:DA:78:CB, rssi -93 flags 0x0004 eir_len 31 bluetoothd[9774]: src/device.c:device_set_legacy() legacy 0 bluetoothd[9774]: src/device.c:device_set_rssi_with_delta() rssi -93 delta 1 bluetoothd[9774]: src/device.c:device_set_flags() flags 0 bluetoothd[9774]: src/adapter.c:device_found_callback() hci0 addr 02:11:8D:DA:78:CB, rssi -91 flags 0x0004 eir_len 31 bluetoothd[9774]: src/device.c:device_set_legacy() legacy 0 bluetoothd[9774]: src/device.c:device_set_rssi_with_delta() rssi -91 delta 2 bluetoothd[9774]: src/device.c:device_set_flags() flags 0 bluetoothd[9774]: D0:27:96:19:12:33: error updating services: Connection timed out (110) bluetoothd[9774]: src/device.c:device_svc_resolved() /org/bluez/hci0/dev_D0_27_96_19_12_33 err -110 bluetoothd[9774]: src/adapter.c:dev_disconnected() Device D0:27:96:19:12:33 disconnected, reason 2 bluetoothd[9774]: src/adapter.c:adapter_remove_connection() bluetoothd[9774]: plugins/policy.c:disconnect_cb() reason 2 bluetoothd[9774]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr D0:27:96:19:12:33 type 0 status 0xe bluetoothd[9774]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e bluetoothd[9774]: src/device.c:device_bonding_failed() status 14 bluetoothd[9774]: src/adapter.c:resume_discovery() bluetoothd[9774]: src/adapter.c:trigger_start_discovery() bluetoothd[9774]: src/adapter.c:cancel_passive_scanning() bluetoothd[9774]: src/adapter.c:device_found_callback() hci0 addr 02:11:8D:DA:78:CB, rssi -92 flags 0x0004 eir_len 31 bluetoothd[9774]: src/device.c:device_set_legacy() legacy 0 bluetoothd[9774]: src/device.c:device_set_rssi_with_delta() rssi -92 delta 1 bluetoothd[9774]: src/device.c:device_set_flags() flags 0 bluetoothd[9774]: src/adapter.c:device_found_callback() hci0 addr 02:11:8D:DA:78:CB, rssi -92 flags 0x0004 eir_len 31 bluetoothd[9774]: src/device.c:device_set_legacy() legacy 0 bluetoothd[9774]: src/device.c:device_set_rssi_with_delta() rssi -92 delta 0 bluetoothd[9774]: src/device.c:device_set_flags() flags 0 -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QKB8Bxf9KV+uXQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 02:28:07 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 6PjIBRf9KV90PAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 02:28:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D9EA140016; Wed, 5 Aug 2020 02:28:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726233AbgHEA2A (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 20:28:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725864AbgHEA2A (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 20:28:00 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4686DC06174A for <linux-bluetooth@vger.kernel.org>; Tue, 4 Aug 2020 17:28:00 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id 93so21862576otx.2 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 17:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zdHIiHjGwmFIPpak6RdYlYPjVjAfyOEuobIYuxfqcsQ=; b=BpZp4ecfq1Hm60U7cNnWr2+W7OrEpL15P+MUczNMPie+FQe7/jkWqMtMjCSW47X5Ce eCJSHNnfn8xm6fSF5GpJJB9gqHcSyJgrDtsX2WPB75QXmQouVaHmNwyKs8x5iL95cm9P FCG1YSDeoYVG97SMXAscgpxu2HyqgsXofB8Sh/S2zrVaHx4Yf/Kf7r7eVH+t32r58Vnw kctDOuNkFxgB4bCiJEuH5F/s2Xwh0lN3dHEibZRIzTKEaXXj3nS1fBdLV/okUPWQDbUL lQNKhBzfEbV6O/QtmBLhrzE4MMVWRa7xjBSTXoO+nfHN7URsWNMwNEJL5xgW60WPI7qX TG0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zdHIiHjGwmFIPpak6RdYlYPjVjAfyOEuobIYuxfqcsQ=; b=eFEv/latwQzHbFB6gQdBpG7J008FOnDpbwGteyid7cwsLtCGXKpIApVT3UJ8U9imhK SQy1BHIu0ap/HjP0ZGU3CLGJ6SExtF/e1USDmKP5Aj9poyqyST5LHte0jjxRn6r+Qs/b JW/BkAxwXtt/4nliSLZpp5e4PMibMZrhO2SyT/IFAjRXMAWLodxcqofLZdqMl8ESDOJl vbs0VuchsjjGmY6Nb3Y16BViiKsE2ozFHpXLCmn+RIWN4lWeDdnSVpNv9QQ0FhBLSNo0 x0ls4bpcs+VnGZQuujbwL+AH6QH1hwP8XXbjDgm8M0AyYcux9I3ByRkBHIITjPozLBKK ADcw== X-Gm-Message-State: AOAM532UxDH5CddyTGOgRvmsa6XnBXd31FJhQ3kxAr0qSd6Al8t0f+be k9h8j5rF9G7kqxbAopbWiNbOOkzOO7kWA3TKnQA= X-Google-Smtp-Source: ABdhPJxtm+guNHIsYvKGWCSR6xVl3OUoIChGWUVAcjqWf2koOcW8sS98oF+wqJyo556eAnRA7PzUH51S2kZqyy6yZWc= X-Received: by 2002:a9d:5e18:: with SMTP id d24mr579488oti.88.1596587279519; Tue, 04 Aug 2020 17:27:59 -0700 (PDT) MIME-Version: 1.0 References: <20200708121928.bluez.v2.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> <CAJQfnxEBjHMAO=kTqRBExgS40g7=OJbv-NOTE1V=PM=K1sdGcw@mail.gmail.com> <CABBYNZ+dZsOGQZh6R3wGg3qPUep9tz7BzsDRH4__mbHKcL8P+g@mail.gmail.com> <CAJQfnxGvvfSHS8ZdYcBPN6Me8E4r76YkkDubnB71r_8MXsDSsQ@mail.gmail.com> In-Reply-To: <CAJQfnxGvvfSHS8ZdYcBPN6Me8E4r76YkkDubnB71r_8MXsDSsQ@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 4 Aug 2020 17:27:49 -0700 Message-ID: <CABBYNZ+7JsBAb3s2m0PFnrcnDdSisFLyYEq6rp96fDNNw5zx8Q@mail.gmail.com> Subject: Re: [bluez PATCH v2] avrcp: include all player settings in notif event To: Archie Pusaka <apusaka@google.com> Cc: Howard Chung <howardchung@google.com>, BlueZ <linux-bluetooth@vger.kernel.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: D9EA140016 X-Rspamd-UID: bb83f6 Hi Archie, On Tue, Aug 4, 2020 at 10:30 AM Archie Pusaka <apusaka@google.com> wrote: > > Hi Luiz, > > Is this the problem? > https://lore.kernel.org/linux-bluetooth/5f05427c.1c69fb81.f61e.0992@mx.google.com/ > > If so, that has been resolved in v2. Found it, but it doesn't seem to apply on top of master: Applying: avrcp: include all player settings in notif event error: patch failed: profiles/audio/avrcp.c:1595 error: profiles/audio/avrcp.c: patch does not apply Patch failed at 0001 avrcp: include all player settings in notif event > Regards, > Archie > > On Wed, 5 Aug 2020 at 01:07, Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Archie, > > > > On Tue, Aug 4, 2020 at 1:26 AM Archie Pusaka <apusaka@google.com> wrote: > > > > > > Hi Bluez maintainers, > > > > > > Could you take a look at this fix? > > > Thank you! > > > > Has there been any new version? It looks like CI has caught some > > problems with it or that has been resolved by V2? > > > > > Regards, > > > Archie > > > > > > > > > On Wed, 8 Jul 2020 at 12:19, Howard Chung <howardchung@google.com> wrote: > > > > > > > > According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player > > > > application settings should be returned to the CT and let CT to > > > > determine which settings have changed. Currently bluez only returns > > > > the changed attribute instead. This patch also addresses a potential > > > > issue on which the number of application settings mismatches with > > > > the actual number returned. > > > > > > > > Reviewed-by: Archie Pusaka <apusaka@chromium.org> > > > > --- > > > > > > > > Changes in v2: > > > > - Fixed unused variables > > > > > > > > profiles/audio/avrcp.c | 71 +++++++++++++++++++----------------------- > > > > 1 file changed, 32 insertions(+), 39 deletions(-) > > > > > > > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > > > > index e2428250e..a4de7530e 100644 > > > > --- a/profiles/audio/avrcp.c > > > > +++ b/profiles/audio/avrcp.c > > > > @@ -369,6 +369,7 @@ static uint32_t company_ids[] = { > > > > }; > > > > > > > > static void avrcp_register_notification(struct avrcp *session, uint8_t event); > > > > +static GList *player_list_settings(struct avrcp_player *player); > > > > > > > > static sdp_record_t *avrcp_ct_record(void) > > > > { > > > > @@ -743,6 +744,35 @@ static int play_status_to_val(const char *status) > > > > return -EINVAL; > > > > } > > > > > > > > +static uint16_t player_settings_changed(struct avrcp_player *player, > > > > + struct avrcp_header *pdu) > > > > +{ > > > > + GList *settings = player_list_settings(player); > > > > + int size = 2; > > > > + > > > > + for (; settings; settings = settings->next) { > > > > + const char *key = settings->data; > > > > + int attr; > > > > + int val; > > > > + > > > > + attr = attr_to_val(key); > > > > + if (attr < 0) > > > > + continue; > > > > + > > > > + val = player_get_setting(player, attr); > > > > + if (val < 0) > > > > + continue; > > > > + > > > > + pdu->params[size++] = attr; > > > > + pdu->params[size++] = val; > > > > + } > > > > + > > > > + g_list_free(settings); > > > > + > > > > + pdu->params[1] = (size - 2) >> 1; > > > > + return size; > > > > +} > > > > + > > > > void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > > const void *data) > > > > { > > > > @@ -751,8 +781,6 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > > uint8_t code; > > > > uint16_t size; > > > > GSList *l; > > > > - int attr; > > > > - int val; > > > > > > > > if (player->sessions == NULL) > > > > return; > > > > @@ -791,19 +819,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > > size = 1; > > > > break; > > > > case AVRCP_EVENT_SETTINGS_CHANGED: > > > > - size = 2; > > > > - pdu->params[1] = 1; > > > > - > > > > - attr = attr_to_val(data); > > > > - if (attr < 0) > > > > - return; > > > > - > > > > - val = player_get_setting(player, attr); > > > > - if (val < 0) > > > > - return; > > > > - > > > > - pdu->params[size++] = attr; > > > > - pdu->params[size++] = val; > > > > + size = player_settings_changed(player, pdu); > > > > break; > > > > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > > > > size = 5; > > > > @@ -1595,7 +1611,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > > > > struct btd_device *dev = session->dev; > > > > uint16_t len = ntohs(pdu->params_len); > > > > uint64_t uid; > > > > - GList *settings; > > > > > > > > /* > > > > * 1 byte for EventID, 4 bytes for Playback interval but the latest > > > > @@ -1626,29 +1641,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > > > > len = 1; > > > > break; > > > > case AVRCP_EVENT_SETTINGS_CHANGED: > > > > - len = 1; > > > > - settings = player_list_settings(player); > > > > - > > > > - pdu->params[len++] = g_list_length(settings); > > > > - for (; settings; settings = settings->next) { > > > > - const char *key = settings->data; > > > > - int attr; > > > > - int val; > > > > - > > > > - attr = attr_to_val(key); > > > > - if (attr < 0) > > > > - continue; > > > > - > > > > - val = player_get_setting(player, attr); > > > > - if (val < 0) > > > > - continue; > > > > - > > > > - pdu->params[len++] = attr; > > > > - pdu->params[len++] = val; > > > > - } > > > > - > > > > - g_list_free(settings); > > > > - > > > > + len = player_settings_changed(player, pdu); > > > > break; > > > > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > > > > len = 5; > > > > -- > > > > 2.27.0.383.g050319c2ae-goog > > > > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QC9nH8/9KV+uXQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 02:31:11 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id oAugHc/9KV/hPgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 02:31:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 879FEA2B61; Wed, 5 Aug 2020 02:31:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725981AbgHEAbE (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 20:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbgHEAbE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 20:31:04 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3552FC06174A for <linux-bluetooth@vger.kernel.org>; Tue, 4 Aug 2020 17:31:03 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id l2so28462085wrc.7 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 17:31:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/Dpvs//O9nnxahENNC/AELRXWkyrOzB1Fassg4ndGXQ=; b=ljLtgwBJa8aW2ZqI9l/xkF56ViMQ4ahF9wmOInOb2gpFPavWNLg7cpnYXAS6a3y4/G KvcORqDwgAKbgIcVES8GLEAFYqHH7QGuXvZ0UzDAEZ7viYvIveUvLgtSyEptxcpPu6dM xA/+w+ZxHq7t9jhza9CYk1iTaauQB+WWBi0ZfP1r25tHZBjXantpDrC4W0ZmUPHxJZfH kZY9bR1zudPhHAGaS3ZlVx4wDqaVuE1fgq/pgeNba5PTXuK5DGjSr4W3TRh9nzTjCf19 SDVWbUVKHX/nlk9BO78Ysg/ayIDVzLaFdEp+FdKIGJnt3w0/FEfKHVkxD/ZqmTjoY0EM OW3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/Dpvs//O9nnxahENNC/AELRXWkyrOzB1Fassg4ndGXQ=; b=fBXNvJljDE2tjDpX7fR2Vfm/7sljE4dHAiPlEJJrXUh3j/TNXT2S7fX8i1mVKgsWQ3 27SKKsIaTUVOcMJNXG2eZ13TgYQV/ZqEuirQ2jSvy9UvPwBg26kt14rX1D6p0F2HX4KV ZcBJNSx98oVsl4hKZIfANa6mLBZipZDqtFjKfWafPS6gONWBeg0KpzJTaNFlDiYziN+3 HvM0Mdte1s1osVOV5gxu7qnb8ImW6jNPNAXXhx2vyaO2MmVkNHdwZThoYCDb+O+IK8Ew gNUtzOVr9dslfdrdb4r9ZpoMUiqbxiMGkRlykAnkrtUsbXTD73iUmynQKBGU4goYzd0K UM9Q== X-Gm-Message-State: AOAM531QG7XkfApMUufQp2cXX7FvHBLS1nklGm8l7VMdW5drNXQW8HxT 6n48OlT0v6w/Kmwlue6z+Qgt31CJIpiRMRPDN/mG+Q== X-Google-Smtp-Source: ABdhPJzlcdmJWe1kw5mUBGCmhFJBaou3JrOfQeQ2mprYBZXBvr+gWNIIMXG8HKlNllVzsp7NS67WN6fI8XJlLCRXoN8= X-Received: by 2002:a5d:6aca:: with SMTP id u10mr349255wrw.365.1596587462366; Tue, 04 Aug 2020 17:31:02 -0700 (PDT) MIME-Version: 1.0 References: <20200708121928.bluez.v2.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> <CAJQfnxEBjHMAO=kTqRBExgS40g7=OJbv-NOTE1V=PM=K1sdGcw@mail.gmail.com> <CABBYNZ+dZsOGQZh6R3wGg3qPUep9tz7BzsDRH4__mbHKcL8P+g@mail.gmail.com> <CAJQfnxGvvfSHS8ZdYcBPN6Me8E4r76YkkDubnB71r_8MXsDSsQ@mail.gmail.com> <CABBYNZ+7JsBAb3s2m0PFnrcnDdSisFLyYEq6rp96fDNNw5zx8Q@mail.gmail.com> In-Reply-To: <CABBYNZ+7JsBAb3s2m0PFnrcnDdSisFLyYEq6rp96fDNNw5zx8Q@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Wed, 5 Aug 2020 08:30:50 +0800 Message-ID: <CAJQfnxGZvrJOj-UDcxMQqZ8Qj9SVT+umHZYyswPRefLPnLDeow@mail.gmail.com> Subject: Re: [bluez PATCH v2] avrcp: include all player settings in notif event To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Howard Chung <howardchung@google.com>, BlueZ <linux-bluetooth@vger.kernel.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: 879FEA2B61 X-Rspamd-UID: 9b10d5 Got it, we will rebase to master and resubmit. Regards, Archie On Wed, 5 Aug 2020 at 08:28, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Archie, > > On Tue, Aug 4, 2020 at 10:30 AM Archie Pusaka <apusaka@google.com> wrote: > > > > Hi Luiz, > > > > Is this the problem? > > https://lore.kernel.org/linux-bluetooth/5f05427c.1c69fb81.f61e.0992@mx.google.com/ > > > > If so, that has been resolved in v2. > > Found it, but it doesn't seem to apply on top of master: > > Applying: avrcp: include all player settings in notif event > error: patch failed: profiles/audio/avrcp.c:1595 > error: profiles/audio/avrcp.c: patch does not apply > Patch failed at 0001 avrcp: include all player settings in notif event > > > Regards, > > Archie > > > > On Wed, 5 Aug 2020 at 01:07, Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > > > > > > Hi Archie, > > > > > > On Tue, Aug 4, 2020 at 1:26 AM Archie Pusaka <apusaka@google.com> wrote: > > > > > > > > Hi Bluez maintainers, > > > > > > > > Could you take a look at this fix? > > > > Thank you! > > > > > > Has there been any new version? It looks like CI has caught some > > > problems with it or that has been resolved by V2? > > > > > > > Regards, > > > > Archie > > > > > > > > > > > > On Wed, 8 Jul 2020 at 12:19, Howard Chung <howardchung@google.com> wrote: > > > > > > > > > > According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player > > > > > application settings should be returned to the CT and let CT to > > > > > determine which settings have changed. Currently bluez only returns > > > > > the changed attribute instead. This patch also addresses a potential > > > > > issue on which the number of application settings mismatches with > > > > > the actual number returned. > > > > > > > > > > Reviewed-by: Archie Pusaka <apusaka@chromium.org> > > > > > --- > > > > > > > > > > Changes in v2: > > > > > - Fixed unused variables > > > > > > > > > > profiles/audio/avrcp.c | 71 +++++++++++++++++++----------------------- > > > > > 1 file changed, 32 insertions(+), 39 deletions(-) > > > > > > > > > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > > > > > index e2428250e..a4de7530e 100644 > > > > > --- a/profiles/audio/avrcp.c > > > > > +++ b/profiles/audio/avrcp.c > > > > > @@ -369,6 +369,7 @@ static uint32_t company_ids[] = { > > > > > }; > > > > > > > > > > static void avrcp_register_notification(struct avrcp *session, uint8_t event); > > > > > +static GList *player_list_settings(struct avrcp_player *player); > > > > > > > > > > static sdp_record_t *avrcp_ct_record(void) > > > > > { > > > > > @@ -743,6 +744,35 @@ static int play_status_to_val(const char *status) > > > > > return -EINVAL; > > > > > } > > > > > > > > > > +static uint16_t player_settings_changed(struct avrcp_player *player, > > > > > + struct avrcp_header *pdu) > > > > > +{ > > > > > + GList *settings = player_list_settings(player); > > > > > + int size = 2; > > > > > + > > > > > + for (; settings; settings = settings->next) { > > > > > + const char *key = settings->data; > > > > > + int attr; > > > > > + int val; > > > > > + > > > > > + attr = attr_to_val(key); > > > > > + if (attr < 0) > > > > > + continue; > > > > > + > > > > > + val = player_get_setting(player, attr); > > > > > + if (val < 0) > > > > > + continue; > > > > > + > > > > > + pdu->params[size++] = attr; > > > > > + pdu->params[size++] = val; > > > > > + } > > > > > + > > > > > + g_list_free(settings); > > > > > + > > > > > + pdu->params[1] = (size - 2) >> 1; > > > > > + return size; > > > > > +} > > > > > + > > > > > void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > > > const void *data) > > > > > { > > > > > @@ -751,8 +781,6 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > > > uint8_t code; > > > > > uint16_t size; > > > > > GSList *l; > > > > > - int attr; > > > > > - int val; > > > > > > > > > > if (player->sessions == NULL) > > > > > return; > > > > > @@ -791,19 +819,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > > > size = 1; > > > > > break; > > > > > case AVRCP_EVENT_SETTINGS_CHANGED: > > > > > - size = 2; > > > > > - pdu->params[1] = 1; > > > > > - > > > > > - attr = attr_to_val(data); > > > > > - if (attr < 0) > > > > > - return; > > > > > - > > > > > - val = player_get_setting(player, attr); > > > > > - if (val < 0) > > > > > - return; > > > > > - > > > > > - pdu->params[size++] = attr; > > > > > - pdu->params[size++] = val; > > > > > + size = player_settings_changed(player, pdu); > > > > > break; > > > > > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > > > > > size = 5; > > > > > @@ -1595,7 +1611,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > > > > > struct btd_device *dev = session->dev; > > > > > uint16_t len = ntohs(pdu->params_len); > > > > > uint64_t uid; > > > > > - GList *settings; > > > > > > > > > > /* > > > > > * 1 byte for EventID, 4 bytes for Playback interval but the latest > > > > > @@ -1626,29 +1641,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > > > > > len = 1; > > > > > break; > > > > > case AVRCP_EVENT_SETTINGS_CHANGED: > > > > > - len = 1; > > > > > - settings = player_list_settings(player); > > > > > - > > > > > - pdu->params[len++] = g_list_length(settings); > > > > > - for (; settings; settings = settings->next) { > > > > > - const char *key = settings->data; > > > > > - int attr; > > > > > - int val; > > > > > - > > > > > - attr = attr_to_val(key); > > > > > - if (attr < 0) > > > > > - continue; > > > > > - > > > > > - val = player_get_setting(player, attr); > > > > > - if (val < 0) > > > > > - continue; > > > > > - > > > > > - pdu->params[len++] = attr; > > > > > - pdu->params[len++] = val; > > > > > - } > > > > > - > > > > > - g_list_free(settings); > > > > > - > > > > > + len = player_settings_changed(player, pdu); > > > > > break; > > > > > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > > > > > len = 5; > > > > > -- > > > > > 2.27.0.383.g050319c2ae-goog > > > > > > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yHpdLRkUKl+SqwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 04:06:17 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id gJLkKxkUKl+oQAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 04:06:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0EC504014E; Wed, 5 Aug 2020 04:06:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726846AbgHECGL (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 22:06:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725864AbgHECGL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 22:06:11 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA53FC06174A for <linux-bluetooth@vger.kernel.org>; Tue, 4 Aug 2020 19:06:10 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id z20so6482755qti.21 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 19:06:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=OVuwt5e+xgXyzQNIFWeSxNVaCjdVa8/8Q/IXl45czd0=; b=dbvpIYt/WRicOqkDi68hfUiragxidL6czwd73bk3nvyY0rOh+cWD+TFos8g9FxeyXh U1tggJt7LZgD+4Ng934Gv/rd6PAGlwADBnlALJ5pR5Yafb3BpRp/zxz6vFtvexnGvqfv uPeK48kXWczEVEkxaVeA4sU6Bs/ytiO34j2vx6Ntpq2rvP76XPWqCTYZNfRY6D6gNz7n jwdDCIeW5PwbJiyxMRP7naX0TSgYEs0GRVoXFWmymVmQt/AikjcRXBSTBxC5PohBoZNR ONWrPfczQvP3atMQF3kkbR39hDlSCpoVEnjeV1FxaNQFbMci+2rbaeK0GEcjpELCaeG9 fXNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=OVuwt5e+xgXyzQNIFWeSxNVaCjdVa8/8Q/IXl45czd0=; b=J/t9ThCoa4GCb28Ydt/LpQadKpr9LD6gDNx/frqDevYNyOp+K5YT2DyE/oW5JCsf59 YuBQWK2ibHxyDj/U/LO6aiuiarYXM1Nl4ecnS/J2uLTn/xNA6FJWWUC63PKETQvN6med C1EXseKguW10RfsSH+tgQTJwo1EJvI9A6GpiWi8TvpDLTeCLtaQgUbunuSa77DJ03f+N AhWaBuFiMOxx317e4yJISuF3Ny+tVajfNmdYV8j9otpRxqnExYgeetTjoYG42BxIOlso IOKf6iDPDt7OxIhsERW/AEN/tRHrBAORj9/Vx1SMYqBiE3RyLEgbfcjepjPJWqkjOBr2 +f6w== X-Gm-Message-State: AOAM531lWNA1Bqu37ywIDXsYkJyNJECpFNR7ezP9qcvAvvUSiMGm/xQP vPxzOqaHSzd2+5HrVynuTBkTT7Wn8wiceHoBPRPbIyu7FL3rGgmaPHB0CUdhfeDqvm/EBiB1dVM AdVekRuw334HDNgoxxJp0DGxIEW5b4QstVlsZd6NL33xUQd3qxjdlYTa/VaBMYT74XALXSmZ66Y v91ceIoY/65uI= X-Google-Smtp-Source: ABdhPJxqUNDS3jp47PGHBTNDk2sME/X0Dlti/WW9Pt4a9Oplcd3grM3DYayfzl9mAUjEJU4AicYM2meY8me25xNuGQ== X-Received: by 2002:a05:6214:4e1:: with SMTP id cl1mr1325762qvb.147.1596593169940; Tue, 04 Aug 2020 19:06:09 -0700 (PDT) Date: Wed, 5 Aug 2020 10:05:36 +0800 Message-Id: <20200805100342.bluez.v3.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [bluez PATCH v3] avrcp: include all player settings in notif event From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, Howard Chung <howardchung@google.com>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0EC504014E X-Rspamd-UID: 7224b0 According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player application settings should be returned to the CT and let CT to determine which settings have changed. Currently bluez only returns the changed attribute instead. This patch also addresses a potential issue on which the number of application settings mismatches with the actual number returned. Reviewed-by: Archie Pusaka <apusaka@chromium.org> --- Changes in v3: - Rebase to master Changes in v2: - Fixed unused variables profiles/audio/avrcp.c | 71 +++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 4e7ff75c0..5d0256c52 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -370,6 +370,7 @@ static uint32_t company_ids[] = { }; static void avrcp_register_notification(struct avrcp *session, uint8_t event); +static GList *player_list_settings(struct avrcp_player *player); static sdp_record_t *avrcp_ct_record(void) { @@ -744,6 +745,35 @@ static int play_status_to_val(const char *status) return -EINVAL; } +static uint16_t player_settings_changed(struct avrcp_player *player, + struct avrcp_header *pdu) +{ + GList *settings = player_list_settings(player); + int size = 2; + + for (; settings; settings = settings->next) { + const char *key = settings->data; + int attr; + int val; + + attr = attr_to_val(key); + if (attr < 0) + continue; + + val = player_get_setting(player, attr); + if (val < 0) + continue; + + pdu->params[size++] = attr; + pdu->params[size++] = val; + } + + g_list_free(settings); + + pdu->params[1] = (size - 2) >> 1; + return size; +} + void avrcp_player_event(struct avrcp_player *player, uint8_t id, const void *data) { @@ -752,8 +782,6 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, uint8_t code; uint16_t size; GSList *l; - int attr; - int val; if (player->sessions == NULL) return; @@ -792,19 +820,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, size = 1; break; case AVRCP_EVENT_SETTINGS_CHANGED: - size = 2; - pdu->params[1] = 1; - - attr = attr_to_val(data); - if (attr < 0) - return; - - val = player_get_setting(player, attr); - if (val < 0) - return; - - pdu->params[size++] = attr; - pdu->params[size++] = val; + size = player_settings_changed(player, pdu); break; case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: size = 5; @@ -1597,7 +1613,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, uint16_t len = ntohs(pdu->params_len); uint64_t uid; int8_t volume; - GList *settings; /* * 1 byte for EventID, 4 bytes for Playback interval but the latest @@ -1628,29 +1643,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, len = 1; break; case AVRCP_EVENT_SETTINGS_CHANGED: - len = 1; - settings = player_list_settings(player); - - pdu->params[len++] = g_list_length(settings); - for (; settings; settings = settings->next) { - const char *key = settings->data; - int attr; - int val; - - attr = attr_to_val(key); - if (attr < 0) - continue; - - val = player_get_setting(player, attr); - if (val < 0) - continue; - - pdu->params[len++] = attr; - pdu->params[len++] = val; - } - - g_list_free(settings); - + len = player_settings_changed(player, pdu); break; case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: len = 5; -- 2.28.0.163.g6104cc2f0b6-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EK+VFOQUKl+SqwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 04:09:40 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 2DuTEuQUKl+g2AEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 04:09:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E0B5240016; Wed, 5 Aug 2020 04:09:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726027AbgHECJd (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 4 Aug 2020 22:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbgHECJd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 4 Aug 2020 22:09:33 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC446C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 4 Aug 2020 19:09:32 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id g19so30808077ejc.9 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 19:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tg3HI0jbtprDiDbYdKJx1rklV2KoK5ZnOI27uFfC/oU=; b=eAkMdMJKdREEIor6+hykf+N3tpkWh7hMnQusBzuFymGAQJffCgN1UiuGCA+fNUscQz 6XE99fsV7p2itG2W84ccc7kkuKKSZKArMQOVJCxD3hMtSrd14ue7T2O3EdI4VPduLHek Q7d1CllqyMLXZ0js9G0pIN7o99ClMbjFuotLy9B5SoVIN1cZ+OoX581q0o2fvu4+uvUT 0kZCvP/00RJ89irJWL5bjL6hzqQZcoovKHZWR02B79xvNVPsSPlVolo0CRItdxmFMH8T rEAOQ5C9FY4PoI65O2JbQ0x3op2ZHj/w/MFGs/Cfd8Qwh5G9XNCYiz+PF8kEECzoaXwx uZUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tg3HI0jbtprDiDbYdKJx1rklV2KoK5ZnOI27uFfC/oU=; b=SiqlW6pD3hmbbDvaflbIkGTFwixuWbloKWoKgyVjyoZxOyuc3ztbuhGpy8cV6icS5E rF+sH5RHO7eSzSeZbmJu+ljmPPY5vpdXcG3dh++e1irAmhyWNvxo4XQnn+MXjr93SJU8 GaWGZWxpLaciCoIitXbY/CXVqsZKD+oN9tzCFbMz+nFulfseOxb9sScedj0rGSyO63cW BtJ1QlAPYExcHJRfhD2g6/3w/EXcSt8exrBRcpCdAhfd7E/dTnup+HyAg/XTxw+a3S86 rixxJb4xpAqlCmMjaYInMOWWnbX8JY007f/QPBThGSNTmpx3pLoImYhQ2RrYuZipQSuF XV5Q== X-Gm-Message-State: AOAM530sVbJRWL9HuWXX8Hme2KWJTX0MO2hZ1rIniY1wQyDhuFpCR89g 1S2gZUa/Aqf1U8FTFXGYg+BBn/MRELJ4DVkNKKDB/w== X-Google-Smtp-Source: ABdhPJyrHbkubY82sWVjRIWOVjZeNQkWkYrgngeV/MjpK5WLSGCq9a3bQitgOhT64Zf7N1epom48q9YM1vU/QBGENYc= X-Received: by 2002:a17:906:4882:: with SMTP id v2mr1017475ejq.302.1596593371358; Tue, 04 Aug 2020 19:09:31 -0700 (PDT) MIME-Version: 1.0 References: <20200708121928.bluez.v2.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> <CAJQfnxEBjHMAO=kTqRBExgS40g7=OJbv-NOTE1V=PM=K1sdGcw@mail.gmail.com> <CABBYNZ+dZsOGQZh6R3wGg3qPUep9tz7BzsDRH4__mbHKcL8P+g@mail.gmail.com> <CAJQfnxGvvfSHS8ZdYcBPN6Me8E4r76YkkDubnB71r_8MXsDSsQ@mail.gmail.com> <CABBYNZ+7JsBAb3s2m0PFnrcnDdSisFLyYEq6rp96fDNNw5zx8Q@mail.gmail.com> <CAJQfnxGZvrJOj-UDcxMQqZ8Qj9SVT+umHZYyswPRefLPnLDeow@mail.gmail.com> In-Reply-To: <CAJQfnxGZvrJOj-UDcxMQqZ8Qj9SVT+umHZYyswPRefLPnLDeow@mail.gmail.com> From: Yun-hao Chung <howardchung@google.com> Date: Wed, 5 Aug 2020 10:09:20 +0800 Message-ID: <CAPHZWUf3Vem96AmmM6BN71=SfCSvUeKfNfd4cbHy+uq=TQOCKg@mail.gmail.com> Subject: Re: [bluez PATCH v2] avrcp: include all player settings in notif event To: Archie Pusaka <apusaka@google.com> Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>, BlueZ <linux-bluetooth@vger.kernel.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: E0B5240016 X-Rspamd-UID: fc6a12 I've rebased and submitted as patch v3, please check. Thanks, Howard On Wed, Aug 5, 2020 at 8:31 AM Archie Pusaka <apusaka@google.com> wrote: > > Got it, we will rebase to master and resubmit. > > Regards, > Archie > > On Wed, 5 Aug 2020 at 08:28, Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Archie, > > > > On Tue, Aug 4, 2020 at 10:30 AM Archie Pusaka <apusaka@google.com> wrote: > > > > > > Hi Luiz, > > > > > > Is this the problem? > > > https://lore.kernel.org/linux-bluetooth/5f05427c.1c69fb81.f61e.0992@mx.google.com/ > > > > > > If so, that has been resolved in v2. > > > > Found it, but it doesn't seem to apply on top of master: > > > > Applying: avrcp: include all player settings in notif event > > error: patch failed: profiles/audio/avrcp.c:1595 > > error: profiles/audio/avrcp.c: patch does not apply > > Patch failed at 0001 avrcp: include all player settings in notif event > > > > > Regards, > > > Archie > > > > > > On Wed, 5 Aug 2020 at 01:07, Luiz Augusto von Dentz > > > <luiz.dentz@gmail.com> wrote: > > > > > > > > Hi Archie, > > > > > > > > On Tue, Aug 4, 2020 at 1:26 AM Archie Pusaka <apusaka@google.com> wrote: > > > > > > > > > > Hi Bluez maintainers, > > > > > > > > > > Could you take a look at this fix? > > > > > Thank you! > > > > > > > > Has there been any new version? It looks like CI has caught some > > > > problems with it or that has been resolved by V2? > > > > > > > > > Regards, > > > > > Archie > > > > > > > > > > > > > > > On Wed, 8 Jul 2020 at 12:19, Howard Chung <howardchung@google.com> wrote: > > > > > > > > > > > > According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player > > > > > > application settings should be returned to the CT and let CT to > > > > > > determine which settings have changed. Currently bluez only returns > > > > > > the changed attribute instead. This patch also addresses a potential > > > > > > issue on which the number of application settings mismatches with > > > > > > the actual number returned. > > > > > > > > > > > > Reviewed-by: Archie Pusaka <apusaka@chromium.org> > > > > > > --- > > > > > > > > > > > > Changes in v2: > > > > > > - Fixed unused variables > > > > > > > > > > > > profiles/audio/avrcp.c | 71 +++++++++++++++++++----------------------- > > > > > > 1 file changed, 32 insertions(+), 39 deletions(-) > > > > > > > > > > > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > > > > > > index e2428250e..a4de7530e 100644 > > > > > > --- a/profiles/audio/avrcp.c > > > > > > +++ b/profiles/audio/avrcp.c > > > > > > @@ -369,6 +369,7 @@ static uint32_t company_ids[] = { > > > > > > }; > > > > > > > > > > > > static void avrcp_register_notification(struct avrcp *session, uint8_t event); > > > > > > +static GList *player_list_settings(struct avrcp_player *player); > > > > > > > > > > > > static sdp_record_t *avrcp_ct_record(void) > > > > > > { > > > > > > @@ -743,6 +744,35 @@ static int play_status_to_val(const char *status) > > > > > > return -EINVAL; > > > > > > } > > > > > > > > > > > > +static uint16_t player_settings_changed(struct avrcp_player *player, > > > > > > + struct avrcp_header *pdu) > > > > > > +{ > > > > > > + GList *settings = player_list_settings(player); > > > > > > + int size = 2; > > > > > > + > > > > > > + for (; settings; settings = settings->next) { > > > > > > + const char *key = settings->data; > > > > > > + int attr; > > > > > > + int val; > > > > > > + > > > > > > + attr = attr_to_val(key); > > > > > > + if (attr < 0) > > > > > > + continue; > > > > > > + > > > > > > + val = player_get_setting(player, attr); > > > > > > + if (val < 0) > > > > > > + continue; > > > > > > + > > > > > > + pdu->params[size++] = attr; > > > > > > + pdu->params[size++] = val; > > > > > > + } > > > > > > + > > > > > > + g_list_free(settings); > > > > > > + > > > > > > + pdu->params[1] = (size - 2) >> 1; > > > > > > + return size; > > > > > > +} > > > > > > + > > > > > > void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > > > > const void *data) > > > > > > { > > > > > > @@ -751,8 +781,6 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > > > > uint8_t code; > > > > > > uint16_t size; > > > > > > GSList *l; > > > > > > - int attr; > > > > > > - int val; > > > > > > > > > > > > if (player->sessions == NULL) > > > > > > return; > > > > > > @@ -791,19 +819,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > > > > > > size = 1; > > > > > > break; > > > > > > case AVRCP_EVENT_SETTINGS_CHANGED: > > > > > > - size = 2; > > > > > > - pdu->params[1] = 1; > > > > > > - > > > > > > - attr = attr_to_val(data); > > > > > > - if (attr < 0) > > > > > > - return; > > > > > > - > > > > > > - val = player_get_setting(player, attr); > > > > > > - if (val < 0) > > > > > > - return; > > > > > > - > > > > > > - pdu->params[size++] = attr; > > > > > > - pdu->params[size++] = val; > > > > > > + size = player_settings_changed(player, pdu); > > > > > > break; > > > > > > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > > > > > > size = 5; > > > > > > @@ -1595,7 +1611,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > > > > > > struct btd_device *dev = session->dev; > > > > > > uint16_t len = ntohs(pdu->params_len); > > > > > > uint64_t uid; > > > > > > - GList *settings; > > > > > > > > > > > > /* > > > > > > * 1 byte for EventID, 4 bytes for Playback interval but the latest > > > > > > @@ -1626,29 +1641,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > > > > > > len = 1; > > > > > > break; > > > > > > case AVRCP_EVENT_SETTINGS_CHANGED: > > > > > > - len = 1; > > > > > > - settings = player_list_settings(player); > > > > > > - > > > > > > - pdu->params[len++] = g_list_length(settings); > > > > > > - for (; settings; settings = settings->next) { > > > > > > - const char *key = settings->data; > > > > > > - int attr; > > > > > > - int val; > > > > > > - > > > > > > - attr = attr_to_val(key); > > > > > > - if (attr < 0) > > > > > > - continue; > > > > > > - > > > > > > - val = player_get_setting(player, attr); > > > > > > - if (val < 0) > > > > > > - continue; > > > > > > - > > > > > > - pdu->params[len++] = attr; > > > > > > - pdu->params[len++] = val; > > > > > > - } > > > > > > - > > > > > > - g_list_free(settings); > > > > > > - > > > > > > + len = player_settings_changed(player, pdu); > > > > > > break; > > > > > > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > > > > > > len = 5; > > > > > > -- > > > > > > 2.27.0.383.g050319c2ae-goog > > > > > > > > > > > > > > > > > > > > > > -- > > > > Luiz Augusto von Dentz > > > > > > > > -- > > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kJWuNftOKl+yjwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 08:17:31 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CFQVNPtOKl8OxAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 08:17:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 64D0CA17D2; Wed, 5 Aug 2020 08:17:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727867AbgHEGRY (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 02:17:24 -0400 Received: from mail-il1-f198.google.com ([209.85.166.198]:49965 "EHLO mail-il1-f198.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbgHEGRX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 02:17:23 -0400 Received: by mail-il1-f198.google.com with SMTP id v12so22189784iln.16 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 23:17:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=6PDC0ZVEJqL6K1HxTwRQQLH2RS/QaggDpUtN9JPJU64=; b=G40f4zmKNmsFoqz5tLfqsR3zgPI6J2fN7lsUi7SWZPazz44/jwktg7xXJYRir5dWLh LKPIegThEQTuVKk80a8927kFLsj6oiA37dlfZ+XUF9F62xx6XweowYixYTMmfhdJAJoj csFUfZShAcx0+b0T7jmnBZ/wdde2afvwkp3dMyMGhCC3BUgbpUR8dolAvb/e7/cYiERz AD/Kz+VBebs+Ref7I0zhsMy7gUIEiE2gFbe5rq6F+gEepXpQiZH88OzHPh+ZTKBrW3qe KY7xljYcPJEq5Hvl9lSIbSXm9HXjFLKsV4xdlfvGf2xacMZBKZ9H8uDcC36kbPURd+ZQ Ea8A== X-Gm-Message-State: AOAM531AX78DYQBktQp/TfoarI7R8XJTUsq1JeTBue9wQrXVmC2qmGao tsANOq5jCM1rb7804zMu4qSX+sDsNaj7gCk90hdG74zYA6Tt X-Google-Smtp-Source: ABdhPJxAm7AKtMYNvwony85dtePeDXVrt4L3/rrzInP8PLHq8OPLMBeeKIdDJBPgT0guK5HrMi08lmHeMR7qRZ4nh/zIQlGyvqif MIME-Version: 1.0 X-Received: by 2002:a92:c52e:: with SMTP id m14mr2448392ili.205.1596608242510; Tue, 04 Aug 2020 23:17:22 -0700 (PDT) Date: Tue, 04 Aug 2020 23:17:22 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000023efa305ac1b5309@google.com> Subject: WARNING: refcount bug in l2cap_global_chan_by_psm From: syzbot <syzbot+39ad9f042519082fcec9@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.44 / 15.00 / 200.00 X-Rspamd-Queue-Id: 64D0CA17D2 X-Rspamd-UID: 33da68 Hello, syzbot found the following issue on: HEAD commit: c0842fbc random32: move the pseudo-random 32-bit definitio.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=142980c2900000 kernel config: https://syzkaller.appspot.com/x/.config?x=76cacb0fe58c4a1e dashboard link: https://syzkaller.appspot.com/bug?extid=39ad9f042519082fcec9 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1100fc58900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13a9d662900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+39ad9f042519082fcec9@syzkaller.appspotmail.com ------------[ cut here ]------------ refcount_t: addition on 0; use-after-free. WARNING: CPU: 1 PID: 6830 at lib/refcount.c:25 refcount_warn_saturate+0x13d/0x1a0 lib/refcount.c:25 Kernel panic - not syncing: panic_on_warn set ... CPU: 1 PID: 6830 Comm: kworker/u5:2 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 panic+0x264/0x7a0 kernel/panic.c:231 __warn+0x227/0x250 kernel/panic.c:600 report_bug+0x1b1/0x2e0 lib/bug.c:198 handle_bug+0x42/0x80 arch/x86/kernel/traps.c:235 exc_invalid_op+0x16/0x40 arch/x86/kernel/traps.c:255 asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:547 RIP: 0010:refcount_warn_saturate+0x13d/0x1a0 lib/refcount.c:25 Code: c7 c3 ca 14 89 31 c0 e8 41 c0 a9 fd 0f 0b eb a3 e8 f8 0a d8 fd c6 05 38 a8 ec 05 01 48 c7 c7 fa ca 14 89 31 c0 e8 23 c0 a9 fd <0f> 0b eb 85 e8 da 0a d8 fd c6 05 1b a8 ec 05 01 48 c7 c7 26 cb 14 RSP: 0018:ffffc90001607a70 EFLAGS: 00010246 RAX: 94a8124281310300 RBX: 0000000000000002 RCX: ffff888092562280 RDX: 0000000000000000 RSI: 0000000080000001 RDI: 0000000000000000 RBP: 0000000000000002 R08: ffffffff815e07c9 R09: ffffed1015d262c0 R10: ffffed1015d262c0 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8880a948e018 R15: 0000000000000001 refcount_add include/linux/refcount.h:206 [inline] refcount_inc include/linux/refcount.h:241 [inline] kref_get include/linux/kref.h:45 [inline] l2cap_chan_hold net/bluetooth/l2cap_core.c:495 [inline] l2cap_global_chan_by_psm+0x4aa/0x4e0 net/bluetooth/l2cap_core.c:1978 l2cap_conless_channel net/bluetooth/l2cap_core.c:7596 [inline] l2cap_recv_frame+0x530/0x8f10 net/bluetooth/l2cap_core.c:7666 hci_acldata_packet net/bluetooth/hci_core.c:4520 [inline] hci_rx_work+0x7d7/0x9c0 net/bluetooth/hci_core.c:4710 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Kernel Offset: disabled Rebooting in 86400 seconds.. --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0I/5LQ5PKl87swAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 08:17:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by localhost with LMTPS id EH8HLQ5PKl8VGAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 08:17:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D1E29A2C01; Wed, 5 Aug 2020 08:17:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727946AbgHEGRa (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 02:17:30 -0400 Received: from mail-io1-f69.google.com ([209.85.166.69]:42809 "EHLO mail-io1-f69.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727111AbgHEGRX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 02:17:23 -0400 Received: by mail-io1-f69.google.com with SMTP id l18so31010939ion.9 for <linux-bluetooth@vger.kernel.org>; Tue, 04 Aug 2020 23:17:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=di6vgA1QwvKcuaK4zAt5UtCoArB7tUveaatpD9fjTvM=; b=o6xJSvv2KB/Dj3e/mOTBLuxas8mgL05DVbZtH9imVIXkdSjvA9it3+3Jj/fS/YfOEF jH5j2Q7HLLX7YvU36PxY2IInQDNw5Vx2dh5ohUyG3lAe+l60bCiJcnsZLurdfrWXswN1 3Fi8PHuxQQwsuImSwZTjqtfkcJHzxALTBZ1aoLePlYKW9rCJZMrEdKk7Giv8MMdUOM+d UN1NyfDpBGQlk41GIP+g3nYZYQSoO7qpLCRfpwTDPvKIk0degB8iefCccoGjd+b1ssAz CkqdQe20AGDQbwfZ34sE7VOA+iKZ5x8uf0kDLo3Bf7CNMTWCfn9ObC9c5l08mfX5/Tft N/aQ== X-Gm-Message-State: AOAM5314tQ/XqKCbgBljH6wFOQ5lHBSHP0s2nl/ecNl9PcVYlGGTf7Sa +kVEQLnblFM7XumX4QFPQ0FLoewHtaRyR0iIL6Ec242WcpTP X-Google-Smtp-Source: ABdhPJw7CeR8FScCQjTke99M/QZIjT4CWXzYncIR8c+ldAl42UTk0q7UGzeqpI+NBgeN3NmNaEMNkenJVSxmswwfEb6X1QBIHAn5 MIME-Version: 1.0 X-Received: by 2002:a05:6638:1313:: with SMTP id r19mr2355385jad.60.1596608242876; Tue, 04 Aug 2020 23:17:22 -0700 (PDT) Date: Tue, 04 Aug 2020 23:17:22 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000029856f05ac1b5335@google.com> Subject: WARNING: locking bug in hci_dev_reset From: syzbot <syzbot+f456fc1d58a1f67c401f@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.21 / 15.00 / 200.00 X-Rspamd-Queue-Id: D1E29A2C01 X-Rspamd-UID: 74a639 Hello, syzbot found the following issue on: HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: net console output: https://syzkaller.appspot.com/x/log.txt?x=10887792900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 dashboard link: https://syzkaller.appspot.com/bug?extid=f456fc1d58a1f67c401f compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=123baf04900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+f456fc1d58a1f67c401f@syzkaller.appspotmail.com ------------[ cut here ]------------ DEBUG_LOCKS_WARN_ON(1) WARNING: CPU: 0 PID: 22435 at kernel/locking/lockdep.c:183 hlock_class kernel/locking/lockdep.c:183 [inline] WARNING: CPU: 0 PID: 22435 at kernel/locking/lockdep.c:183 hlock_class kernel/locking/lockdep.c:172 [inline] WARNING: CPU: 0 PID: 22435 at kernel/locking/lockdep.c:183 check_wait_context kernel/locking/lockdep.c:4054 [inline] WARNING: CPU: 0 PID: 22435 at kernel/locking/lockdep.c:183 __lock_acquire+0x1629/0x56e0 kernel/locking/lockdep.c:4330 Kernel panic - not syncing: panic_on_warn set ... CPU: 0 PID: 22435 Comm: syz-executor.2 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 panic+0x2e3/0x75c kernel/panic.c:231 __warn.cold+0x20/0x45 kernel/panic.c:600 report_bug+0x1bd/0x210 lib/bug.c:198 handle_bug+0x38/0x90 arch/x86/kernel/traps.c:235 exc_invalid_op+0x13/0x40 arch/x86/kernel/traps.c:255 asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:540 RIP: 0010:hlock_class kernel/locking/lockdep.c:183 [inline] RIP: 0010:hlock_class kernel/locking/lockdep.c:172 [inline] RIP: 0010:check_wait_context kernel/locking/lockdep.c:4054 [inline] RIP: 0010:__lock_acquire+0x1629/0x56e0 kernel/locking/lockdep.c:4330 Code: 08 84 d2 0f 85 bd 35 00 00 8b 35 a2 a2 55 09 85 f6 0f 85 cc fa ff ff 48 c7 c6 20 b0 4b 88 48 c7 c7 20 ab 4b 88 e8 b9 44 eb ff <0f> 0b e9 b2 fa ff ff e8 3b a0 8e 06 85 c0 0f 84 ed fa ff ff 48 c7 RSP: 0018:ffffc90002a17810 EFLAGS: 00010086 RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000000 RDX: ffff8880949044c0 RSI: ffffffff815d4ef7 RDI: fffff52000542ef4 RBP: ffff888094904db8 R08: 0000000000000000 R09: ffffffff89bb5c23 R10: 0000000000000aea R11: 0000000000000001 R12: ffff8880949044c0 R13: 00000000000006d9 R14: ffff88809487c138 R15: 0000000000040000 lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:4959 flush_workqueue+0x110/0x13e0 kernel/workqueue.c:2780 drain_workqueue+0x1a5/0x3c0 kernel/workqueue.c:2945 hci_dev_do_reset net/bluetooth/hci_core.c:1864 [inline] hci_dev_reset+0x23e/0x450 net/bluetooth/hci_core.c:1907 hci_sock_ioctl+0x510/0x800 net/bluetooth/hci_sock.c:1036 sock_do_ioctl+0xcb/0x2d0 net/socket.c:1048 sock_ioctl+0x3b8/0x730 net/socket.c:1199 vfs_ioctl fs/ioctl.c:48 [inline] ksys_ioctl+0x11a/0x180 fs/ioctl.c:753 __do_sys_ioctl fs/ioctl.c:762 [inline] __se_sys_ioctl fs/ioctl.c:760 [inline] __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x45cce9 Code: 2d b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb b5 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007fab01629c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 000000000001d300 RCX: 000000000045cce9 RDX: 0000000000000000 RSI: 00000000400448cb RDI: 0000000000000006 RBP: 000000000078c120 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 000000000078c0ec R13: 00007ffc2d1075ff R14: 00007fab0162a9c0 R15: 000000000078c0ec Kernel Offset: disabled Rebooting in 86400 seconds.. --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MEYmNkhgKl+UGQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 09:31:20 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8IeKNEhgKl8iqAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 09:31:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 23927A2CA4; Wed, 5 Aug 2020 09:31:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726775AbgHEHbN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 03:31:13 -0400 Received: from mail-il1-f197.google.com ([209.85.166.197]:52119 "EHLO mail-il1-f197.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbgHEHbJ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 03:31:09 -0400 Received: by mail-il1-f197.google.com with SMTP id c84so8703023ila.18 for <linux-bluetooth@vger.kernel.org>; Wed, 05 Aug 2020 00:31:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=UAjlV35CqUYg8Wq8iE9joWFodTfiF9zQm++Jk44fcSY=; b=fFSA0ku2bKmCryeIoxfWNuwgwxe1fZqpkCiGLEEQDJKqOxqFlLAW8K3/8C7wQKmYPk GUzusERy5DWzHIXLsjeJ2of5CekZz4wxu5qHaCjU6arlE9sZpTuMwyUitGLu8bKBd5OI 1sNp+/AubC/AOGlBGSBs8XWV55ZD3r4SLQAPbc6nOmpHQulJRQ3gNcHyER+d4bpDETWp 29rr5mewOizjIxpe44sfK6dxy+4lfboJymlPx+Cq/5tpstW9H51NW7b3iLjBhBB8IePe foc/cSO9T8Vuqx0KOjH79CLXvPoSeIcMDqCOqe2xStNGkg+XmVabZz7I5/mp5jpAefGf olhQ== X-Gm-Message-State: AOAM533E85xxJnWDDnRMDkEMWpaHMOW3PyoO1UwHhDEuc5ydoLiIREUB sbT+Q9KOJdo5R2g9Rm3kXImnc0ffPDh43lArjLoEqUr1OA5W X-Google-Smtp-Source: ABdhPJydINKXG6kk6Rt5Q7YptVJc6WU2HIGHbqBbyEup0nCj4eB/muV9ogT+bIQJk1+5SdRMqrFrePgB51/EIuvRRPKG7IPv2d9A MIME-Version: 1.0 X-Received: by 2002:a92:1b5b:: with SMTP id b88mr2679375ilb.104.1596612668103; Wed, 05 Aug 2020 00:31:08 -0700 (PDT) Date: Wed, 05 Aug 2020 00:31:08 -0700 In-Reply-To: <000000000000a39e4905abeb193f@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000ed214e05ac1c5ae8@google.com> Subject: Re: general protection fault in hci_phy_link_complete_evt From: syzbot <syzbot+18e38290a2a263b31aa0@syzkaller.appspotmail.com> To: a@unstable.cc, b.a.t.m.a.n@lists.open-mesh.org, davem@davemloft.net, johan.hedberg@gmail.com, johannes.berg@intel.com, johannes@sipsolutions.net, kuba@kernel.org, kvalo@codeaurora.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux@armlinux.org.uk, marcel@holtmann.org, mareklindner@neomailbox.ch, netdev@vger.kernel.org, sw@simonwunderlich.de, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 9 X-Rspamd-Score: 1.41 / 15.00 / 200.00 X-Rspamd-Queue-Id: 23927A2CA4 X-Rspamd-UID: d945e7 syzbot has bisected this issue to: commit b59abfbed638037f3b51eeb73266892cd2df177f Author: Johannes Berg <johannes.berg@intel.com> Date: Thu Sep 15 13:30:03 2016 +0000 mac80211_hwsim: statically initialize hwsim_radios list bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15dd5f98900000 start commit: c0842fbc random32: move the pseudo-random 32-bit definitio.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=17dd5f98900000 console output: https://syzkaller.appspot.com/x/log.txt?x=13dd5f98900000 kernel config: https://syzkaller.appspot.com/x/.config?x=cf567e8c7428377e dashboard link: https://syzkaller.appspot.com/bug?extid=18e38290a2a263b31aa0 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17e4e094900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1143e7ca900000 Reported-by: syzbot+18e38290a2a263b31aa0@syzkaller.appspotmail.com Fixes: b59abfbed638 ("mac80211_hwsim: statically initialize hwsim_radios list") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yB0FHxPdKl94SAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 18:23:47 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id iG+QHRPdKl97YAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 18:23:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 049AEA11C8; Wed, 5 Aug 2020 18:23:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726238AbgHEQXk (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 12:23:40 -0400 Received: from mail-io1-f72.google.com ([209.85.166.72]:41778 "EHLO mail-io1-f72.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726641AbgHEQWf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 12:22:35 -0400 Received: by mail-io1-f72.google.com with SMTP id e12so11755384ioc.8 for <linux-bluetooth@vger.kernel.org>; Wed, 05 Aug 2020 09:22:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=avna9i89Ds5+HlHIO0jP2gsy42y6k6d4i5A6G0eC9Zg=; b=Ij+HqAvsAedeWMgOcrcMEJXz6+sxrYz3EO0laFyJ57y+LgvwJwxXyQicp73SDbBIQk 19GMODRkoDk61lcQ8q867gygSieT6JHMf3lqfyMZWQlBQHe/VnH9Xy+XN/LUEaBhVNEp qD2A4EeK4UWYQbh9KETGnE6Mm/PY4g9g+BCQyG8E0rrizQHgoZaIFVv6jxyoN7zPGhOl /UGhsT8O70rXnmkrAiTQcd4z7XMmjS6fU5RULum3fzIEfouPtF2b8HXEwc1XckB8yYZi nDxWA0cRhzS+tOzJJ2jsyA2h46l1fy6ENT11wu8g1Cmk4Yxt//DMoKv06gfDHYNIxH4G uEdg== X-Gm-Message-State: AOAM532s9iTu2vqI6mLK4jhRkNdfz/pyXb4jgfwRfuWWIVq5V2DphEjL /kndOMrgklMYv/ViLayV50j6UEElePG8lTWZxGokyNepkzNH X-Google-Smtp-Source: ABdhPJyx4yEzfPaYCDRlqOY3SOtYmFn8sbh8/x3+5nlNm2RDYZA9WGMYMn0ZKb0xJk3/Mq74bCnR7H5fZMI1spSxNxHREkmBWCcD MIME-Version: 1.0 X-Received: by 2002:a05:6602:24c2:: with SMTP id h2mr4088770ioe.198.1596643761947; Wed, 05 Aug 2020 09:09:21 -0700 (PDT) Date: Wed, 05 Aug 2020 09:09:21 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000438c6705ac23983f@google.com> Subject: BUG: unable to handle kernel paging request in lock_sock_nested From: syzbot <syzbot+3ea58ce4ad976e46ca65@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 049AEA11C8 X-Rspamd-UID: 087212 Hello, syzbot found the following issue on: HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: net console output: https://syzkaller.appspot.com/x/log.txt?x=141a4c1a900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 dashboard link: https://syzkaller.appspot.com/bug?extid=3ea58ce4ad976e46ca65 compiler: gcc (GCC) 10.1.0-syz 20200507 Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+3ea58ce4ad976e46ca65@syzkaller.appspotmail.com BUG: unable to handle page fault for address: fffffbfff32980d2 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 21ffe5067 P4D 21ffe5067 PUD 21ffe4067 PMD 0 Oops: 0000 [#1] PREEMPT SMP KASAN CPU: 0 PID: 19427 Comm: kworker/0:15 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout RIP: 0010:bytes_is_nonzero mm/kasan/generic.c:91 [inline] RIP: 0010:memory_is_nonzero mm/kasan/generic.c:108 [inline] RIP: 0010:memory_is_poisoned_n mm/kasan/generic.c:134 [inline] RIP: 0010:memory_is_poisoned mm/kasan/generic.c:165 [inline] RIP: 0010:check_memory_region_inline mm/kasan/generic.c:183 [inline] RIP: 0010:check_memory_region+0xdb/0x180 mm/kasan/generic.c:192 Code: 80 38 00 74 f2 48 89 c2 b8 01 00 00 00 48 85 d2 75 56 5b 5d 41 5c c3 48 85 d2 74 5e 48 01 ea eb 09 48 83 c0 01 48 39 d0 74 50 <80> 38 00 74 f2 eb d4 41 bc 08 00 00 00 48 89 ea 45 29 dc 4d 8d 1c RSP: 0018:ffffc90001ed78c0 EFLAGS: 00010082 RAX: fffffbfff32980d2 RBX: fffffbfff32980d3 RCX: ffffffff8159b005 RDX: fffffbfff32980d3 RSI: 0000000000000008 RDI: ffffffff994c0690 RBP: fffffbfff32980d2 R08: 0000000000000000 R09: ffffffff994c0697 R10: fffffbfff32980d2 R11: 0000000000000000 R12: ffff88806a3fc380 R13: ffff88806a3fcd12 R14: 0000000000000000 R15: ffff88806a3fcc50 FS: 0000000000000000(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: fffffbfff32980d2 CR3: 000000009cb24000 CR4: 00000000001406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: instrument_atomic_read include/linux/instrumented.h:56 [inline] test_bit include/asm-generic/bitops/instrumented-non-atomic.h:110 [inline] __lock_acquire+0x1025/0x56e0 kernel/locking/lockdep.c:4350 lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:4959 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:175 spin_lock_bh include/linux/spinlock.h:358 [inline] lock_sock_nested+0x3b/0x110 net/core/sock.c:3049 l2cap_sock_teardown_cb+0x88/0x400 net/bluetooth/l2cap_sock.c:1520 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:824 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Modules linked in: CR2: fffffbfff32980d2 ---[ end trace 74995b61ea36495b ]--- RIP: 0010:bytes_is_nonzero mm/kasan/generic.c:91 [inline] RIP: 0010:memory_is_nonzero mm/kasan/generic.c:108 [inline] RIP: 0010:memory_is_poisoned_n mm/kasan/generic.c:134 [inline] RIP: 0010:memory_is_poisoned mm/kasan/generic.c:165 [inline] RIP: 0010:check_memory_region_inline mm/kasan/generic.c:183 [inline] RIP: 0010:check_memory_region+0xdb/0x180 mm/kasan/generic.c:192 Code: 80 38 00 74 f2 48 89 c2 b8 01 00 00 00 48 85 d2 75 56 5b 5d 41 5c c3 48 85 d2 74 5e 48 01 ea eb 09 48 83 c0 01 48 39 d0 74 50 <80> 38 00 74 f2 eb d4 41 bc 08 00 00 00 48 89 ea 45 29 dc 4d 8d 1c RSP: 0018:ffffc90001ed78c0 EFLAGS: 00010082 RAX: fffffbfff32980d2 RBX: fffffbfff32980d3 RCX: ffffffff8159b005 RDX: fffffbfff32980d3 RSI: 0000000000000008 RDI: ffffffff994c0690 RBP: fffffbfff32980d2 R08: 0000000000000000 R09: ffffffff994c0697 R10: fffffbfff32980d2 R11: 0000000000000000 R12: ffff88806a3fc380 R13: ffff88806a3fcd12 R14: 0000000000000000 R15: ffff88806a3fcc50 FS: 0000000000000000(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: fffffbfff32980d2 CR3: 000000009cb24000 CR4: 00000000001406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ALZXJCXyKl9hyAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 19:53:41 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id uDWkIiXyKl995wAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 19:53:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id ABA70A1260; Wed, 5 Aug 2020 19:53:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729045AbgHERwP (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 13:52:15 -0400 Received: from mga05.intel.com ([192.55.52.43]:42221 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728997AbgHERuy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 13:50:54 -0400 IronPort-SDR: eaZqSI89yVxW4+eQH4DzyI96qMTXiwOCS2kHuTod+K6rMeoeAs4DP12gaaUeJe4I7Mi9x7NZAO lJg+611kmwsw== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470632" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470632" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:44:58 -0700 IronPort-SDR: iofcmEzlugcWij2qhLQZ2xXtS3SKLEicyEkRbLotLLe/9abwuftYJ81YBRMy1rFCu7TMl2ANkE ZTqaH0Q0J7TA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245728" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:44:58 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v4 03/10] mesh: Clean up handling of config node identity message Date: Wed, 5 Aug 2020 10:44:49 -0700 Message-Id: <20200805174456.49342-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805174456.49342-1-inga.stotland@intel.com> References: <20200805174456.49342-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: ABA70A1260 X-Rspamd-UID: 665e36 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 35d0325a9..c501b0a52 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -777,11 +777,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_NODE_IDENTITY_SET: - if (size != 3 || pkt[2] > 0x01) - return true; - - n_idx = l_get_le16(pkt); - if (n_idx > 0xfff) + if (size != 3) return true; /* Currently setting node identity not supported */ @@ -789,18 +785,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall Through */ case OP_NODE_IDENTITY_GET: - if (size < 2) + if (opcode == OP_NODE_IDENTITY_GET && size != 2) return true; n_idx = l_get_le16(pkt); - if (n_idx > 0xfff) - return true; n = mesh_model_opcode_set(OP_NODE_IDENTITY_STATUS, msg); - - status = mesh_net_get_identity_mode(net, n_idx, &state); - - msg[n++] = status; + msg[n++] = mesh_net_get_identity_mode(net, n_idx, &state); l_put_le16(n_idx, msg + n); n += 2; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sIEeLSzyKl9hyAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 19:53:48 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ML3mKyzyKl9HgAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 19:53:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 928A2A11C8; Wed, 5 Aug 2020 19:53:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728999AbgHERxb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 13:53:31 -0400 Received: from mga05.intel.com ([192.55.52.43]:42213 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729036AbgHERuz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 13:50:55 -0400 IronPort-SDR: CL9dOmAUyumlRHlyqJ8guF3MDWmtmGZUT2KAHdf9LnWXFCF6DgUd87BU9ncrDokFWt1DlCWGoL 5qqdQ4esDYpw== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470643" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470643" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:44:59 -0700 IronPort-SDR: a81zaGdrVDutwySX5zxfF//JtmG8/9BO72B40fk34+HayY2HE6IbNwS80ojI0nVejq84nTWx1X tEHZt0ZU+Mmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245739" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:44:59 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v4 05/10] mesh: Clean up handling of config net and app key messages Date: Wed, 5 Aug 2020 10:44:51 -0700 Message-Id: <20200805174456.49342-6-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805174456.49342-1-inga.stotland@intel.com> References: <20200805174456.49342-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 928A2A11C8 X-Rspamd-UID: d26a14 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 147 ++++++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 72 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 57646543d..030f9e744 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -547,6 +547,73 @@ static void node_reset(void *user_data) node_remove(node); } +static uint16_t cfg_appkey_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint16_t n_idx, a_idx, n; + struct mesh_net *net = node_get_net(node); + + n_idx = l_get_le16(pkt) & 0xfff; + a_idx = l_get_le16(pkt + 1) >> 4; + + n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); + + if (opcode == OP_APPKEY_ADD) + msg[n] = appkey_key_add(net, n_idx, a_idx, pkt + 3); + else if (opcode == OP_APPKEY_UPDATE) + msg[n] = appkey_key_update(net, n_idx, a_idx, pkt + 3); + else + msg[n] = appkey_key_delete(net, n_idx, a_idx); + + l_debug("AppKey Command %s: Net_Idx %3.3x, App_Idx %3.3x", + (msg[n] == MESH_STATUS_SUCCESS) ? "success" : "fail", + n_idx, a_idx); + + memcpy(msg + n + 1, &pkt[0], 3); + + return n + 4; +} + +static uint16_t cfg_netkey_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint16_t n_idx, n; + struct mesh_net *net = node_get_net(node); + + n_idx = l_get_le16(pkt); + n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); + + if (opcode == OP_NETKEY_ADD) + msg[n] = mesh_net_add_key(net, n_idx, pkt + 2); + else if (opcode == OP_NETKEY_UPDATE) + msg[n] = mesh_net_update_key(net, n_idx, pkt + 2); + else + msg[n] = mesh_net_del_key(net, n_idx); + + l_debug("NetKey Command %s: Net_Idx %3.3x", + (msg[n] == MESH_STATUS_SUCCESS) ? "success" : "fail", + n_idx); + + memcpy(msg + n + 1, &pkt[0], 2); + + return n + 3; +} + +static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t n_idx, sz, n; + + n_idx = l_get_le16(pkt); + + n = mesh_model_opcode_set(OP_APPKEY_LIST, msg); + l_put_le16(n_idx, msg + n + 1); + + msg[n] = appkey_list(node_get_net(node), n_idx, msg + n + 3, + MAX_MSG_LEN - (n + 3), &sz); + + return n + 3 + sz; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -585,7 +652,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint32_t opcode, tmp32; int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; - uint16_t n_idx, a_idx; + uint16_t n_idx; uint8_t state, status; uint8_t phase; bool virt = false; @@ -856,60 +923,19 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 19) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; - - if (opcode == OP_APPKEY_ADD) - b_res = appkey_key_add(net, n_idx, a_idx, pkt + 3); - else - b_res = appkey_key_update(net, n_idx, a_idx, - pkt + 3); - - l_debug("Add/Update AppKey %s: Net_Idx %3.3x, App_Idx %3.3x", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail", - n_idx, a_idx); - - - n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); - - msg[n++] = b_res; - msg[n++] = pkt[0]; - msg[n++] = pkt[1]; - msg[n++] = pkt[2]; - break; - + /* Fall Through */ case OP_APPKEY_DELETE: - if (size != 3) + if (opcode == OP_APPKEY_DELETE && size != 3) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; - b_res = appkey_key_delete(net, n_idx, a_idx); - l_debug("Delete AppKey %s Net_Idx %3.3x to App_Idx %3.3x", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail", - n_idx, a_idx); - - n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); - msg[n++] = b_res; - msg[n++] = pkt[0]; - msg[n++] = pkt[1]; - msg[n++] = pkt[2]; + n = cfg_appkey_msg(node, pkt, opcode); break; case OP_APPKEY_GET: if (size != 2) return true; - n_idx = l_get_le16(pkt); - - n = mesh_model_opcode_set(OP_APPKEY_LIST, msg); - - status = appkey_list(net, n_idx, msg + n + 3, - MAX_MSG_LEN - n - 3, &size); - - msg[n] = status; - l_put_le16(n_idx, msg + n + 1); - n += (size + 3); + n = cfg_get_appkeys_msg(node, pkt); break; case OP_NETKEY_ADD: @@ -917,35 +943,12 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 18) return true; - n_idx = l_get_le16(pkt); - - if (opcode == OP_NETKEY_ADD) - b_res = mesh_net_add_key(net, n_idx, pkt + 2); - else - b_res = mesh_net_update_key(net, n_idx, pkt + 2); - - l_debug("NetKey Add/Update %s", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail"); - - n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); - msg[n++] = b_res; - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; - break; - + /* Fall Through */ case OP_NETKEY_DELETE: - if (size != 2) + if (opcode == OP_NETKEY_DELETE && size != 2) return true; - b_res = mesh_net_del_key(net, l_get_le16(pkt)); - - l_debug("NetKey delete %s", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail"); - - n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); - msg[n++] = b_res; - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; + n = cfg_netkey_msg(node, pkt, opcode); break; case OP_NETKEY_GET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oM5aBDXyKl9hyAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 19:53:57 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id eCH6AjXyKl/+mwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 19:53:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EDD6DA11C8; Wed, 5 Aug 2020 19:53:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728858AbgHERxd (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 13:53:33 -0400 Received: from mga05.intel.com ([192.55.52.43]:42218 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729037AbgHERuy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 13:50:54 -0400 IronPort-SDR: esvKMfuqqQ35u4alo5jJslvPD+eTgAbtJ5097ch/lNIHhxPrUwXSEEaqr9s7bbeWqkAmLZ6Nlw z9YxVvzRaqdw== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470637" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470637" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:44:59 -0700 IronPort-SDR: 6N1XZ+5AQ+p9ybhj4PqV5w43MKmz19K3TTPYTxKoSFAR5UQXG+TTOPAZiwBkwLhJE999upO5Zq 7AogoIbVSMSQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245732" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:44:59 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v4 04/10] mesh: Clean up handling of config publication messages Date: Wed, 5 Aug 2020 10:44:50 -0700 Message-Id: <20200805174456.49342-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805174456.49342-1-inga.stotland@intel.com> References: <20200805174456.49342-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: EDD6DA11C8 X-Rspamd-UID: 10f048 This modification allows using a single point for sending out the composed status messages by the Config Server. Also, return Feature Not Supported errror code when credential flag is set, but the node does not support LPN feature --- mesh/cfgmod-server.c | 99 ++++++++++++++++++-------------------------- mesh/model.c | 7 +++- mesh/net.h | 2 - 3 files changed, 46 insertions(+), 62 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index c501b0a52..57646543d 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -32,6 +32,8 @@ #include "mesh/mesh-config.h" #include "mesh/cfgmod.h" +#define CREDFLAG_MASK 0x1000 + #define CFG_SET_ID(vendor, pkt) ((vendor) ? \ (SET_ID(l_get_le16((pkt)), l_get_le16((pkt) + 2))) : \ (SET_ID(SIG_VENDOR, l_get_le16(pkt)))) @@ -44,11 +46,9 @@ static const uint8_t supported_pages[] = { static uint8_t msg[MAX_MSG_LEN]; -static void send_pub_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, uint32_t id, - uint16_t pub_addr, uint16_t idx, bool cred_flag, - uint8_t ttl, uint8_t period, uint8_t retransmit) +static uint16_t set_pub_status(uint8_t status, uint16_t ele_addr, uint32_t id, + uint16_t pub_addr, uint16_t idx, bool cred_flag, + uint8_t ttl, uint8_t period, uint8_t retransmit) { size_t n; @@ -72,46 +72,36 @@ static void send_pub_status(struct mesh_node *node, uint16_t net_idx, n += 4; } - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); + return n; } -static void config_pub_get(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size) +static uint16_t config_pub_get(struct mesh_node *node, const uint8_t *pkt, + bool vendor) { uint32_t id; uint16_t ele_addr; struct mesh_model_pub *pub; int status; - if (size == 4) { - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); - } else if (size == 6) { - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - } else - return; - ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); + pub = mesh_model_pub_get(node, ele_addr, id, &status); if (pub && status == MESH_STATUS_SUCCESS) - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, pub->addr, pub->idx, pub->credential, - pub->ttl, pub->period, pub->retransmit); + return set_pub_status(status, ele_addr, id, pub->addr, pub->idx, + pub->credential, pub->ttl, pub->period, + pub->retransmit); else - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, 0, 0, 0, 0, 0, 0); + return set_pub_status(status, ele_addr, id, 0, 0, 0, 0, 0, 0); } -static void config_pub_set(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, bool virt, bool vendor) +static uint16_t config_pub_set(struct mesh_node *node, const uint8_t *pkt, + bool virt, bool vendor) { uint32_t id; - uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; + uint16_t ele_addr, idx, pub_dst; const uint8_t *pub_addr; - uint16_t test_addr; uint8_t ttl, period, retransmit; int status; bool cred_flag; @@ -119,42 +109,35 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, ele_addr = l_get_le16(pkt); pub_addr = pkt + 2; - pkt += (virt ? 14 : 0); + pub_dst = l_get_le16(pub_addr); - idx = l_get_le16(pkt + 4); - ttl = pkt[6]; - period = pkt[7]; - retransmit = pkt[8]; - id = l_get_le16(pkt + 9); + if (!virt && IS_VIRTUAL(pub_dst)) + return 0; - if (!vendor) - id = SET_ID(SIG_VENDOR, id); - else - id = SET_ID(id, l_get_le16(pkt + 11)); + pkt += (virt ? 14 : 0); - /* Don't accept virtual seeming addresses */ - test_addr = l_get_le16(pub_addr); - if (!virt && IS_VIRTUAL(test_addr)) - return; + idx = l_get_le16(pkt + 4); + if (idx > CREDFLAG_MASK) + return 0; cred_flag = !!(CREDFLAG_MASK & idx); idx &= APP_IDX_MASK; + ttl = pkt[6]; + period = pkt[7]; + retransmit = pkt[8]; + id = CFG_SET_ID(vendor, pkt + 9); status = mesh_model_pub_set(node, ele_addr, id, pub_addr, idx, cred_flag, ttl, period, retransmit, - virt, &ota); - - l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, mod: %x, idx: %3.3x", - status, ele_addr, ota, id, idx); + virt, &pub_dst); - if (status != MESH_STATUS_SUCCESS) { - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, 0, 0, 0, 0, 0, 0); + l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, id: %x, idx: %3.3x", + status, ele_addr, pub_dst, id, idx); - return; - } + if (status != MESH_STATUS_SUCCESS) + return set_pub_status(status, ele_addr, id, 0, 0, 0, 0, 0, 0); - if (IS_UNASSIGNED(test_addr) && !virt) { + if (IS_UNASSIGNED(pub_dst) && !virt) { ttl = period = idx = 0; /* Remove model publication from config file */ @@ -165,7 +148,7 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, } else { struct mesh_config_pub db_pub = { .virt = virt, - .addr = ota, + .addr = pub_dst, .idx = idx, .ttl = ttl, .credential = cred_flag, @@ -180,12 +163,12 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, /* Save model publication to config file */ if (!mesh_config_model_pub_add(node_config_get(node), ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_pub)) + vendor, &db_pub)) status = MESH_STATUS_STORAGE_FAIL; } - send_pub_status(node, net_idx, src, dst, status, ele_addr, id, ota, - idx, cred_flag, ttl, period, retransmit); + return set_pub_status(status, ele_addr, id, pub_dst, idx, cred_flag, + ttl, period, retransmit); } static uint16_t cfg_sub_get_msg(struct mesh_node *node, const uint8_t *pkt, @@ -667,14 +650,14 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (!virt && (size != 11 && size != 13)) return true; - config_pub_set(node, net_idx, src, dst, pkt, virt, - size == 13 || size == 27); + n = config_pub_set(node, pkt, virt, size == 13 || size == 27); break; case OP_CONFIG_MODEL_PUB_GET: if (size != 4 && size != 6) return true; - config_pub_get(node, net_idx, src, dst, pkt, size); + + n = config_pub_get(node, pkt, size == 6); break; case OP_CONFIG_VEND_MODEL_SUB_GET: diff --git a/mesh/model.c b/mesh/model.c index e2cadfe36..a92ab6b43 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -1072,7 +1072,7 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *pub_addr, uint16_t idx, bool cred_flag, uint8_t ttl, uint8_t period, uint8_t retransmit, - bool is_virt, uint16_t *dst) + bool is_virt, uint16_t *pub_dst) { struct mesh_model *mod; int status, ele_idx = node_get_element_idx(node, addr); @@ -1099,6 +1099,9 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } + if (cred_flag && node_lpn_mode_get(node) != MESH_MODE_ENABLED) + return MESH_STATUS_FEATURE_NO_SUPPORT; + /* Check if the old publication destination is a virtual label */ if (mod->pub && mod->pub->virt) { unref_virt(mod->pub->virt); @@ -1112,7 +1115,7 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, status = set_virt_pub(mod, pub_addr, idx, cred_flag, ttl, period, retransmit); - *dst = mod->pub->addr; + *pub_dst = mod->pub->addr; if (status != MESH_STATUS_SUCCESS) return status; diff --git a/mesh/net.h b/mesh/net.h index 7117f1a47..2673b895a 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -32,8 +32,6 @@ struct mesh_node; #define CTL 0x80 -#define CREDFLAG_MASK 0x1000 - #define KEY_CACHE_SIZE 64 #define FRND_CACHE_MAX 32 -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wJjzA6LyKl9HFAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 19:55:46 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MNKgAqLyKl8aiQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 19:55:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D651D420BE; Wed, 5 Aug 2020 19:55:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728928AbgHERyv (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 13:54:51 -0400 Received: from mga05.intel.com ([192.55.52.43]:42213 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729031AbgHERtk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 13:49:40 -0400 IronPort-SDR: EmgZD/uYicIsrfiU/ONvOdB6tbyZMUKMzLguFT0s5xri9iI+TsvctbNsKlFl5g4IPDA5elN0wG YCop0fokZv2A== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470622" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470622" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:44:58 -0700 IronPort-SDR: upjRO79vetpmJY5R+6Wi2nBAqCdfN4GbLYP3quwp9FaBDlKMLnZxw95jCHNPtofJkatWGa5K+V ltJN/W4OBGQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245719" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:44:58 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v4 02/10] mesh: Clean up handling of config model binding messages Date: Wed, 5 Aug 2020 10:44:48 -0700 Message-Id: <20200805174456.49342-3-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805174456.49342-1-inga.stotland@intel.com> References: <20200805174456.49342-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: D651D420BE X-Rspamd-UID: df36ff This modification allows using a single point for sending out the composed status messages by the Config Server. Also, remove unused definitions for binding functions in node.h --- mesh/cfgmod-server.c | 130 ++++++++++++------------------------------- mesh/model.c | 16 +----- mesh/node.h | 4 -- 3 files changed, 38 insertions(+), 112 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index cd0e8b94c..35d0325a9 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -112,8 +112,7 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; const uint8_t *pub_addr; uint16_t test_addr; - uint8_t ttl, period; - uint8_t retransmit; + uint8_t ttl, period, retransmit; int status; bool cred_flag; @@ -362,115 +361,56 @@ static uint16_t config_sub_del_all(struct mesh_node *node, const uint8_t *pkt, return n; } -static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t addr, - uint32_t id, uint16_t idx) -{ - size_t n = mesh_model_opcode_set(OP_MODEL_APP_STATUS, msg); - - msg[n++] = status; - l_put_le16(addr, msg + n); - n += 2; - l_put_le16(idx, msg + n); - n += 2; - - if (IS_VENDOR(id)) { - l_put_le16(VENDOR_ID(id), msg + n); - n += 2; - } - - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); -} - -static void model_app_list(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, +static uint16_t model_app_list(struct mesh_node *node, const uint8_t *pkt, uint16_t size) { - uint16_t ele_addr; + uint16_t ele_addr, n, bnd_len; uint32_t id; - uint8_t *status; - uint16_t n; - int result; + int opcode; + opcode = (size == 4) ? OP_MODEL_APP_LIST : OP_VEND_MODEL_APP_LIST; ele_addr = l_get_le16(pkt); - switch (size) { - default: - return; - case 4: - n = mesh_model_opcode_set(OP_MODEL_APP_LIST, msg); - status = msg + n; - id = l_get_le16(pkt + 2); - l_put_le16(ele_addr, msg + 1 + n); - l_put_le16((uint16_t) id, msg + 3 + n); - id = SET_ID(SIG_VENDOR, id); - n += 5; - break; - case 6: - n = mesh_model_opcode_set(OP_VEND_MODEL_APP_LIST, msg); - status = msg + n; - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); + n = mesh_model_opcode_set(opcode, msg); + memcpy(msg + n + 1, pkt, size); - l_put_le16(ele_addr, msg + 1 + n); - l_put_le16((uint16_t) VENDOR_ID(id), msg + 3 + n); - l_put_le16((uint16_t) MODEL_ID(id), msg + 5 + n); - n += 7; - break; - } + id = CFG_SET_ID(size == 6, pkt + 2); - result = mesh_model_get_bindings(node, ele_addr, id, msg + n, - MAX_MSG_LEN - n, &size); - n += size; + msg[n] = mesh_model_get_bindings(node, ele_addr, id, msg + n + 1 + size, + MAX_MSG_LEN - (n + 1 + size), &bnd_len); - if (result >= 0) { - *status = result; - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, - DEFAULT_TTL, false, msg, n); - } + if (msg[n] == MESH_STATUS_SUCCESS) + n += bnd_len; + + n += (size + 1); + return n; } -static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size, - bool unbind) +static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt, + uint16_t size, bool unbind) { - uint16_t ele_addr; + uint16_t ele_addr, idx, n; uint32_t id; - uint16_t idx; - int result; - switch (size) { - default: - return false; - case 6: - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); - break; - case 8: - id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); - break; - } + idx = l_get_le16(pkt + 2); + if (idx > APP_IDX_MASK) + return 0; ele_addr = l_get_le16(pkt); - idx = l_get_le16(pkt + 2); + id = CFG_SET_ID(size == 8, pkt + 4); - if (idx > 0xfff) - return false; + n = mesh_model_opcode_set(OP_MODEL_APP_STATUS, msg); if (unbind) - result = mesh_model_binding_del(node, ele_addr, id, idx); + msg[n] = mesh_model_binding_del(node, ele_addr, id, idx); else - result = mesh_model_binding_add(node, ele_addr, id, idx); + msg[n] = mesh_model_binding_add(node, ele_addr, id, idx); - send_model_app_status(node, net_idx, src, dst, result, ele_addr, - id, idx); + memcpy(msg + n + 1, pkt, size); + n += (size + 1); - return true; + return n; } static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) @@ -703,8 +643,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 1 || pkt[0] > TTL_MASK || pkt[0] == 1) return true; - if (pkt[0] <= TTL_MASK) - node_default_ttl_set(node, pkt[0]); + node_default_ttl_set(node, pkt[0]); /* Fall Through */ case OP_CONFIG_DEFAULT_TTL_GET: @@ -1048,22 +987,25 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_MODEL_APP_BIND: case OP_MODEL_APP_UNBIND: - model_app_bind(node, net_idx, src, dst, pkt, size, - opcode != OP_MODEL_APP_BIND); + if (size != 6 && size != 8) + return true; + + n = model_app_bind(node, pkt, size, + opcode != OP_MODEL_APP_BIND); break; case OP_VEND_MODEL_APP_GET: if (size != 6) return true; - model_app_list(node, net_idx, src, dst, pkt, size); + n = model_app_list(node, pkt, size); break; case OP_MODEL_APP_GET: if (size != 4) return true; - model_app_list(node, net_idx, src, dst, pkt, size); + n = model_app_list(node, pkt, size); break; case OP_CONFIG_HEARTBEAT_PUB_SET: diff --git a/mesh/model.c b/mesh/model.c index 3c9b6577a..e2cadfe36 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -111,13 +111,7 @@ static bool simple_match(const void *a, const void *b) static bool has_binding(struct l_queue *bindings, uint16_t idx) { - const struct l_queue_entry *l; - - for (l = l_queue_get_entries(bindings); l; l = l->next) { - if (L_PTR_TO_UINT(l->data) == idx) - return true; - } - return false; + return l_queue_find(bindings, simple_match, L_UINT_TO_PTR(idx)) != NULL; } static bool find_virt_by_label(const void *a, const void *b) @@ -628,7 +622,6 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, uint16_t app_idx, bool unbind) { struct mesh_model *mod; - bool is_present; int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) @@ -645,12 +638,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, if (!appkey_have_key(node_get_net(node), app_idx)) return MESH_STATUS_INVALID_APPKEY; - is_present = has_binding(mod->bindings, app_idx); - - if (!is_present && unbind) - return MESH_STATUS_SUCCESS; - - if (is_present && !unbind) + if (unbind ^ has_binding(mod->bindings, app_idx)) return MESH_STATUS_SUCCESS; if (unbind) { diff --git a/mesh/node.h b/mesh/node.h index 47c998530..7874b8692 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -49,10 +49,6 @@ const uint8_t *node_get_token(struct mesh_node *node); const uint8_t *node_get_device_key(struct mesh_node *node); void node_set_num_elements(struct mesh_node *node, uint8_t num_ele); uint8_t node_get_num_elements(struct mesh_node *node); -bool node_add_binding(struct mesh_node *node, uint8_t ele_idx, - uint32_t model_id, uint16_t app_idx); -bool node_del_binding(struct mesh_node *node, uint8_t ele_idx, - uint32_t model_id, uint16_t app_idx); uint8_t node_default_ttl_get(struct mesh_node *node); bool node_default_ttl_set(struct mesh_node *node, uint8_t ttl); bool node_set_sequence_number(struct mesh_node *node, uint32_t seq); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QB/VG88NK19unQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 21:51:43 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id kOFzGs8NK1/AegEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 21:51:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7425EA01FB; Wed, 5 Aug 2020 21:51:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728242AbgHETvM (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 15:51:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728244AbgHETuw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 15:50:52 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02D8EC061575 for <linux-bluetooth@vger.kernel.org>; Wed, 5 Aug 2020 12:50:52 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id e6so20473090oii.4 for <linux-bluetooth@vger.kernel.org>; Wed, 05 Aug 2020 12:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+uvhSulsTo3IYqkmirIw+uCMi1pBoea9+GY2Ru9yZyY=; b=o44XPh0hnxv6lw/4AMZHgdfmf/+lWcU04OKR3IjWzINiSv5taRh+U6neT/ONZz06rJ 0DL+4vvgGOERkOYfAaokmDH70dpTm0uRANPyh+ZlOLNoIgn8/WquQ8RtmYkFB9F/1Yff EyFUGY9EcOoYaC0NJzRMzg9lxCHkOQ+P2TUCdZFXaKX08L1Uai3wZtxmjQ70pu6TP3hO dWAIGBQjnX21mfQISf9Es7yqCKGRUBv3+cyGOruzrRSTjbY3weCnKlIXeGyFHHk4q4NM heosTO6q/L8I2B6yMazu1M+rhHATol5t9N/WguRMPUM4ymSpBaIwW6YQmKDP25r2F7EA XBOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+uvhSulsTo3IYqkmirIw+uCMi1pBoea9+GY2Ru9yZyY=; b=KQCv+PrKyiRW3DTTMj8AWqh39gI3IT7QeOcCfUiqFB6xFZiwzEoi9hdfeMTRk1H6F1 99XB+vK6BvNttBxXXVmF7wFUIQ9ilgr/mRgpJFwPgPvdZZ4bN4Vb80A3NjPZ4nKyB1VV aFPABDd/5CivqRD09At2/9An39dFOoDN/4CQyHvqROVGKfNYa8UhnvWeQZ0pnYBZibY+ 2AiqGXzdGUNLRZI4QRVs4btQp5v2WtccXsbQM1kShStmdI+qdKsYlXSxenr+G08fmmB4 ZAXCD5CpIY2xShcYUVtO3lAEnDjvpeb5Ta23BwYW8taUWzVgXVB281tQyDE9hrCgnxwH UNdA== X-Gm-Message-State: AOAM531wsvuWE8Gpjs532dAGUI125wsgdn6nhtFoEI5FIURyCcnfGR9w tWKAGGtn0KPJPu7rZ0w+0KfRKrtAyH98J+2Y+H0= X-Google-Smtp-Source: ABdhPJznKOj8VOEhnUGQLG9tX/RNqeFHc58b//dIUARm2o/sHJW+kStwIyCsk09ur2uqfhHAkhcpS21orBtUUj4j2pc= X-Received: by 2002:aca:cc50:: with SMTP id c77mr3948006oig.152.1596657051339; Wed, 05 Aug 2020 12:50:51 -0700 (PDT) MIME-Version: 1.0 References: <20200805100342.bluez.v3.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> In-Reply-To: <20200805100342.bluez.v3.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 5 Aug 2020 12:50:41 -0700 Message-ID: <CABBYNZ+=ZjPe147Jr8vEVCRixjFoq9xMYWObOLYHErGF3e5DCg@mail.gmail.com> Subject: Re: [bluez PATCH v3] avrcp: include all player settings in notif event To: Howard Chung <howardchung@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7425EA01FB X-Rspamd-UID: 33fad4 Hi Howard, On Tue, Aug 4, 2020 at 7:06 PM Howard Chung <howardchung@google.com> wrote: > > According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player > application settings should be returned to the CT and let CT to > determine which settings have changed. Currently bluez only returns > the changed attribute instead. This patch also addresses a potential > issue on which the number of application settings mismatches with > the actual number returned. > > Reviewed-by: Archie Pusaka <apusaka@chromium.org> > --- > > Changes in v3: > - Rebase to master > > Changes in v2: > - Fixed unused variables > > profiles/audio/avrcp.c | 71 +++++++++++++++++++----------------------- > 1 file changed, 32 insertions(+), 39 deletions(-) > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > index 4e7ff75c0..5d0256c52 100644 > --- a/profiles/audio/avrcp.c > +++ b/profiles/audio/avrcp.c > @@ -370,6 +370,7 @@ static uint32_t company_ids[] = { > }; > > static void avrcp_register_notification(struct avrcp *session, uint8_t event); > +static GList *player_list_settings(struct avrcp_player *player); > > static sdp_record_t *avrcp_ct_record(void) > { > @@ -744,6 +745,35 @@ static int play_status_to_val(const char *status) > return -EINVAL; > } > > +static uint16_t player_settings_changed(struct avrcp_player *player, > + struct avrcp_header *pdu) > +{ > + GList *settings = player_list_settings(player); > + int size = 2; > + > + for (; settings; settings = settings->next) { > + const char *key = settings->data; > + int attr; > + int val; > + > + attr = attr_to_val(key); > + if (attr < 0) > + continue; > + > + val = player_get_setting(player, attr); > + if (val < 0) > + continue; > + > + pdu->params[size++] = attr; > + pdu->params[size++] = val; > + } > + > + g_list_free(settings); > + > + pdu->params[1] = (size - 2) >> 1; > + return size; > +} > + > void avrcp_player_event(struct avrcp_player *player, uint8_t id, > const void *data) > { > @@ -752,8 +782,6 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > uint8_t code; > uint16_t size; > GSList *l; > - int attr; > - int val; > > if (player->sessions == NULL) > return; > @@ -792,19 +820,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > size = 1; > break; > case AVRCP_EVENT_SETTINGS_CHANGED: > - size = 2; > - pdu->params[1] = 1; > - > - attr = attr_to_val(data); > - if (attr < 0) > - return; > - > - val = player_get_setting(player, attr); > - if (val < 0) > - return; > - > - pdu->params[size++] = attr; > - pdu->params[size++] = val; > + size = player_settings_changed(player, pdu); > break; > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > size = 5; > @@ -1597,7 +1613,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > uint16_t len = ntohs(pdu->params_len); > uint64_t uid; > int8_t volume; > - GList *settings; > > /* > * 1 byte for EventID, 4 bytes for Playback interval but the latest > @@ -1628,29 +1643,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > len = 1; > break; > case AVRCP_EVENT_SETTINGS_CHANGED: > - len = 1; > - settings = player_list_settings(player); > - > - pdu->params[len++] = g_list_length(settings); > - for (; settings; settings = settings->next) { > - const char *key = settings->data; > - int attr; > - int val; > - > - attr = attr_to_val(key); > - if (attr < 0) > - continue; > - > - val = player_get_setting(player, attr); > - if (val < 0) > - continue; > - > - pdu->params[len++] = attr; > - pdu->params[len++] = val; > - } > - > - g_list_free(settings); > - > + len = player_settings_changed(player, pdu); > break; > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > len = 5; > -- > 2.28.0.163.g6104cc2f0b6-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QAOvMD0QK1/IZAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 22:02:05 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id mHDRLz0QK18uGwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 22:02:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=univ-grenoble-alpes.fr X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E9971A1191; Wed, 5 Aug 2020 22:01:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729831AbgHET77 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 15:59:59 -0400 Received: from zm-mta-out-3.u-ga.fr ([152.77.200.56]:57626 "EHLO zm-mta-out-3.u-ga.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727902AbgHEQmA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 12:42:00 -0400 X-Greylist: delayed 3753 seconds by postgrey-1.27 at vger.kernel.org; Wed, 05 Aug 2020 12:41:59 EDT Received: from zm-mta-out.u-ga.fr (zm-mta-out.u-ga.fr [152.77.200.53]) by zm-mta-out-3.u-ga.fr (Postfix) with ESMTP id D656D4114A; Wed, 5 Aug 2020 16:15:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=univ-grenoble-alpes.fr; s=2020; t=1596636921; bh=Zt1T/CpzCqJIEWzrAeePDreLWGu5RL2i6Ub8umsFiPs=; h=Date:From:To:Cc:Subject:From; b=lWdtGM9HMpn8NvxxxiZit6owszSOtY5AESaxgQ5odSyyvjYypkqt5kzdAajsqVYaB eKU29nH6xULoKEtLqrEac9acgH3fz6lPrGpZ8PZVu7aSpyhcj8DlUwujN8PonGvwUt jSq+6uhD2yOXG8mFWY31cghzCRAFUaRrXzSyNBymawYhwPk1G4pFmYAwVIaKDZc2ai v6bI8CcCwHvKtkALw0+Dn38s0AgkP1PSzaKswN9V3loj8w0HpvF9lhbk9KBlQorE7h xXm5ka5cFq9Oi+4WIKC8N76WNKQ0gjqPBoM5qXY/hbc+ccDcH5fdgLUT0Bw7flcvul IzA3R/2sYCOrw== Received: from smtps.univ-grenoble-alpes.fr (smtps1.u-ga.fr [152.77.1.30]) by zm-mta-out.u-ga.fr (Postfix) with ESMTP id CF7BB80831; Wed, 5 Aug 2020 16:15:21 +0200 (CEST) Received: from ifmail.u-ga.fr (ifmail.u-ga.fr [152.77.212.13]) by smtps.univ-grenoble-alpes.fr (Postfix) with ESMTP id 61FA0187E12; Wed, 5 Aug 2020 16:15:21 +0200 (CEST) Received: by ifmail.u-ga.fr (Postfix, from userid 33) id 9DC454059F; Wed, 5 Aug 2020 16:15:21 +0200 (CEST) Received: from lfbn-lyo-1-473-99.w2-7.abo.wanadoo.fr (lfbn-lyo-1-473-99.w2-7.abo.wanadoo.fr [2.7.63.99]) by ifmail.univ-grenoble-alpes.fr (Horde Framework) with HTTP; Wed, 05 Aug 2020 14:15:21 +0000 Date: Wed, 05 Aug 2020 14:15:21 +0000 Message-ID: <20200805141521.Horde.OY2o_GjmTsW1aKqSHDZjf1V@ifmail.univ-grenoble-alpes.fr> From: demailly <Jean-Pierre.Demailly@univ-grenoble-alpes.fr> To: linux-bluetooth@vger.kernel.org Cc: tina@vson.com.cn, Jean-Pierre Demailly <jean-pierre.demailly@univ-grenoble-alpes.fr> Subject: Reading data from bluetooth LCD tablet User-Agent: Horde Application Framework 5 Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline X-Greylist: Whitelist-UGA MAILHOST (SMTP non authentifie) depuis 152.77.212.13 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: E9971A1191 X-Rspamd-UID: 1a4374 Hi, I recently bought a NewYes LCD tablet that is advertized with Android/Windows/MacOS software only, but can still act as an excellent (and cheap) graphics tablet under Linux, check https://www.banggood.com/NEWYES-10inch-Bluetooth-Archive-Synchronize-Writing-Tablet-Save-Drawing-LCD-Office-Family-Graffiti-Toy-Gift-p-1446888.html?cur_warehouse=CN I succeeded in writing a rather simple user space driver for the tablet connected with the USB cable, using libusb. The code is available as newyes_tablet_driver.tar.bz2 on https://sourceforge.net/projects/sf-xpaint/files/deskwrite/ However, the constructor does not provide any technical information about the bluetooth settings (just proprietary binary code, see http://9612.myvsoncloud.com/). The device is seen as bd-address: FF:FF:05:00:1C:02 name: VSON#WP9612#000000 [CHG] Device FF:FF:05:00:1C:02 UUIDs: 00001800-0000-1000-8000-00805f9b34fb [CHG] Device FF:FF:05:00:1C:02 UUIDs: 00001801-0000-1000-8000-00805f9b34fb [CHG] Device FF:FF:05:00:1C:02 UUIDs: 0000fff0-0000-1000-8000-00805f9b34fb Pairing in a standard way does not work, neither under Linux nor Windows, although the Android "e-Draw" app provided by the constructor (http://www.vson.com.cn/English/html/9571303320.html) seems to provide such a pairing - pairing from the Android bluetooth stack itself does not work either. Is there any reasonable way to reverse-engineer this stuff in the absence of response from VSON at this date ? I would content myself with the USB connection, but it seems that the data recorded by the tablet are available only under bluetooth - they are not obviously visible via the usb connection. Worse, the vector data input do not seem to be accessible by bluetooth via e-Draw, just png images, which is really not a very smart idea. Being locked by such proprietary policies would be really shameful ... Many thanks in advance, Jean-Pierre Demailly Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OI57NmfzKl9hyAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 19:59:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uKN5NGfzKl8PegEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 19:59:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8DC6F420D9; Wed, 5 Aug 2020 19:58:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729036AbgHERyo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 13:54:44 -0400 Received: from mga05.intel.com ([192.55.52.43]:42218 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729032AbgHERtm (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 13:49:42 -0400 IronPort-SDR: Dcy1g+Ux//oN0O1PlqjlCYkyeF/hBSMvLYg0HulbxVxcaGHzRErv904RJ2ooYb8DTNbYgJzqG6 e+Zb+VfaZ5ig== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470615" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470615" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:44:57 -0700 IronPort-SDR: q607ibXjCdFI/Nas3LPINf4H6m4irrDQ2t9Ob+iedN0rxdVQcYsHmidQk0MDgI9fL7iDpuumKu LDnpIj5yQaYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245715" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:44:57 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v4 01/10] mesh: Clean up handling of config subscription messages Date: Wed, 5 Aug 2020 10:44:47 -0700 Message-Id: <20200805174456.49342-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805174456.49342-1-inga.stotland@intel.com> References: <20200805174456.49342-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8DC6F420D9 X-Rspamd-UID: a54c3f This provides better functional grouping based on whether a group or a virtual label is used for the subscription address. Also, use a single point for sending out the composed Config Server status messages. --- mesh/cfgmod-server.c | 344 +++++++++++++++++----------------------- mesh/mesh-config-json.c | 12 +- mesh/mesh-config.h | 6 +- mesh/model.c | 211 ++++++++++++++---------- mesh/model.h | 21 ++- 5 files changed, 296 insertions(+), 298 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 7672ad3b6..cd0e8b94c 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -32,6 +32,10 @@ #include "mesh/mesh-config.h" #include "mesh/cfgmod.h" +#define CFG_SET_ID(vendor, pkt) ((vendor) ? \ + (SET_ID(l_get_le16((pkt)), l_get_le16((pkt) + 2))) : \ + (SET_ID(SIG_VENDOR, l_get_le16(pkt)))) + /* Supported composition pages, sorted high to low */ /* Only page 0 is currently supported */ static const uint8_t supported_pages[] = { @@ -185,237 +189,177 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, idx, cred_flag, ttl, period, retransmit); } -static void send_sub_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, - uint16_t addr, uint32_t id) +static uint16_t cfg_sub_get_msg(struct mesh_node *node, const uint8_t *pkt, + uint16_t size) { - int n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - - msg[n++] = status; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(addr, msg + n); - n += 2; - - if (IS_VENDOR(id)) { - l_put_le16(VENDOR_ID(id), msg + n); - l_put_le16(MODEL_ID(id), msg + n + 2); - n += 4; - } else { - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - } - - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); -} - -static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size) -{ - uint16_t ele_addr; + uint16_t ele_addr, n, sub_len; uint32_t id; - uint16_t n = 0; - int status; - uint8_t *msg_status; - uint16_t buf_size; + int opcode; + bool vendor = (size == 6); - /* Incoming message has already been size-checked */ ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); + opcode = vendor ? OP_CONFIG_VEND_MODEL_SUB_LIST : + OP_CONFIG_MODEL_SUB_LIST; + n = mesh_model_opcode_set(opcode, msg); + memcpy(msg + n + 1, pkt, size); - switch (size) { - default: - l_debug("Bad length %d", size); - return false; - - case 4: - id = l_get_le16(pkt + 2); - n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_LIST, msg); - msg_status = msg + n; - msg[n++] = 0; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(id, msg + n); - n += 2; - id = SET_ID(SIG_VENDOR, id); - break; - - case 6: - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - n = mesh_model_opcode_set(OP_CONFIG_VEND_MODEL_SUB_LIST, msg); - msg_status = msg + n; - msg[n++] = 0; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(VENDOR_ID(id), msg + n); - n += 2; - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - break; - } - - buf_size = sizeof(uint16_t) * MAX_GRP_PER_MOD; - status = mesh_model_sub_get(node, ele_addr, id, msg + n, buf_size, - &size); - - if (status == MESH_STATUS_SUCCESS) - n += size; + msg[n] = mesh_model_sub_get(node, ele_addr, id, msg + n + 1 + size, + MAX_MSG_LEN - (n + 1 + size), &sub_len); - *msg_status = (uint8_t) status; + if (msg[n] == MESH_STATUS_SUCCESS) + n += sub_len; - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); - return true; + n += (size + 1); + return n; } -static bool save_config_sub(struct mesh_node *node, uint16_t ele_addr, - uint32_t id, bool vendor, - const uint8_t *addr, bool virt, - uint16_t grp, uint32_t opcode) +static bool save_cfg_sub(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, bool vendor, const uint8_t *label, + bool virt, uint16_t grp, uint32_t opcode) { + struct mesh_config *cfg = node_config_get(node); struct mesh_config_sub db_sub = { .virt = virt, - .src.addr = grp + .addr.grp = grp }; + id = (vendor) ? id : MODEL_ID(id); + if (virt) - memcpy(db_sub.src.virt_addr, addr, 16); + memcpy(db_sub.addr.label, label, 16); + + if (opcode == OP_CONFIG_MODEL_SUB_VIRT_DELETE && + opcode == OP_CONFIG_MODEL_SUB_DELETE) + return mesh_config_model_sub_del(cfg, ele_addr, id, vendor, + &db_sub); if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE || opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) - mesh_config_model_sub_del_all(node_config_get(node), ele_addr, - vendor ? id : MODEL_ID(id), - vendor); - if (opcode != OP_CONFIG_MODEL_SUB_VIRT_DELETE && - opcode != OP_CONFIG_MODEL_SUB_DELETE) - return mesh_config_model_sub_add(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_sub); - else - return mesh_config_model_sub_del(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_sub); + if (!mesh_config_model_sub_del_all(cfg, ele_addr, id, vendor)) + return false; + + return mesh_config_model_sub_add(cfg, ele_addr, id, vendor, &db_sub); } -static void config_sub_set(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size, - bool virt, uint32_t opcode) +static uint16_t cfg_sub_add_msg(struct mesh_node *node, const uint8_t *pkt, + bool vendor, uint32_t opcode) { - uint16_t grp, ele_addr; + uint16_t addr, ele_addr, n; uint32_t id; - const uint8_t *addr = NULL; - int status = MESH_STATUS_SUCCESS; - bool vendor = false; - switch (size) { - default: - l_error("Bad length: %d", size); - return; - case 4: - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) - return; + addr = l_get_le16(pkt + 2); - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); - break; - case 6: - if (virt) - return; + if (!IS_GROUP(addr)) + return 0; - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); - } else { - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - vendor = true; - } + ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 4); - break; - case 8: - if (virt) - return; + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); - vendor = true; - break; - case 20: - if (!virt) - return; + if (opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) + msg[n] = mesh_model_sub_ovrt(node, ele_addr, id, addr); + else if (opcode == OP_CONFIG_MODEL_SUB_ADD) + msg[n] = mesh_model_sub_add(node, ele_addr, id, addr); + else + msg[n] = mesh_model_sub_del(node, ele_addr, id, addr); - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 18)); - break; - case 22: - if (!virt) - return; + if (msg[n] == MESH_STATUS_SUCCESS && + !save_cfg_sub(node, ele_addr, id, vendor, NULL, false, + addr, opcode)) + msg[n] = MESH_STATUS_STORAGE_FAIL; - vendor = true; - id = SET_ID(l_get_le16(pkt + 18), l_get_le16(pkt + 20)); - break; + if (vendor) { + memcpy(msg + n + 1, pkt, 8); + n += 9; + } else { + memcpy(msg + n + 1, pkt, 6); + n += 7; } + return n; +} + +static uint16_t cfg_virt_sub_add_msg(struct mesh_node *node, const uint8_t *pkt, + bool vendor, uint32_t opcode) +{ + uint16_t addr, ele_addr, n; + uint32_t id; + const uint8_t *label; + + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); + ele_addr = l_get_le16(pkt); + label = pkt + 2; + id = CFG_SET_ID(vendor, pkt + 18); + + if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE) + msg[n] = mesh_model_virt_sub_ovrt(node, ele_addr, id, label, + &addr); + else if (opcode == OP_CONFIG_MODEL_SUB_VIRT_ADD) + msg[n] = mesh_model_virt_sub_add(node, ele_addr, id, label, + &addr); + else + msg[n] = mesh_model_virt_sub_del(node, ele_addr, id, label, + &addr); - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - addr = pkt + 2; - grp = l_get_le16(addr); - } else - grp = UNASSIGNED_ADDRESS; + if (msg[n] == MESH_STATUS_SUCCESS && + !save_cfg_sub(node, ele_addr, id, vendor, + label, true, addr, opcode)) + msg[n] = MESH_STATUS_STORAGE_FAIL; - switch (opcode) { - default: - l_debug("Bad opcode: %x", opcode); - return; + l_put_le16(ele_addr, msg + n + 1); + l_put_le16(addr, msg + n + 3); - case OP_CONFIG_MODEL_SUB_DELETE_ALL: - status = mesh_model_sub_del_all(node, ele_addr, id); + if (vendor) { + l_put_le16(VENDOR_ID(id), msg + n + 5); + l_put_le16(MODEL_ID(id), msg + n + 7); + n += 9; + } else { + l_put_le16(MODEL_ID(id), msg + n + 5); + n += 7; + } - if (status == MESH_STATUS_SUCCESS) - mesh_config_model_sub_del_all(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor); - break; + return n; +} - case OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_OVERWRITE: - status = mesh_model_sub_ovr(node, ele_addr, id, - addr, virt, &grp); +static uint16_t config_sub_del_all(struct mesh_node *node, const uint8_t *pkt, + bool vendor) +{ + uint16_t ele_addr, n, grp = UNASSIGNED_ADDRESS; + uint32_t id; - if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, id, vendor, addr, - virt, grp, opcode); - break; - case OP_CONFIG_MODEL_SUB_VIRT_ADD: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_ADD: - status = mesh_model_sub_add(node, ele_addr, id, - addr, virt, &grp); + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - if (status == MESH_STATUS_SUCCESS && - !save_config_sub(node, ele_addr, id, vendor, - addr, virt, grp, opcode)) - status = MESH_STATUS_STORAGE_FAIL; + ele_addr = l_get_le16(pkt); + id = CFG_SET_ID(vendor, pkt + 2); - break; - case OP_CONFIG_MODEL_SUB_VIRT_DELETE: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_DELETE: - status = mesh_model_sub_del(node, ele_addr, id, addr, virt, - &grp); + msg[n] = mesh_model_sub_del_all(node, ele_addr, id); - if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, id, vendor, addr, - virt, grp, opcode); + if (msg[n] == MESH_STATUS_SUCCESS) { + struct mesh_config *cfg = node_config_get(node); - break; + if (!mesh_config_model_sub_del_all(cfg, ele_addr, + vendor ? id : MODEL_ID(id), + vendor)) + msg[n] = MESH_STATUS_STORAGE_FAIL; + } + + l_put_le16(ele_addr, msg + n + 1); + l_put_le16(grp, msg + n + 3); + + if (vendor) { + l_put_le16(VENDOR_ID(id), msg + n + 5); + l_put_le16(MODEL_ID(id), msg + n + 7); + n += 9; + } else { + l_put_le16(MODEL_ID(id), msg + n + 5); + n += 7; } - send_sub_status(node, net_idx, src, dst, status, ele_addr, grp, id); + return n; } static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, @@ -797,28 +741,38 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_VEND_MODEL_SUB_GET: if (size != 6) return true; - - config_sub_get(node, net_idx, src, dst, pkt, size); - break; + /* Fall Through */ case OP_CONFIG_MODEL_SUB_GET: - if (size != 4) + if (size != 4 && opcode == OP_CONFIG_MODEL_SUB_GET) return true; - config_sub_get(node, net_idx, src, dst, pkt, size); + n = cfg_sub_get_msg(node, pkt, size); break; case OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE: case OP_CONFIG_MODEL_SUB_VIRT_DELETE: case OP_CONFIG_MODEL_SUB_VIRT_ADD: - virt = true; - /* Fall Through */ + if (size != 20 && size != 22) + return true; + + n = cfg_virt_sub_add_msg(node, pkt, size == 22, opcode); + break; + case OP_CONFIG_MODEL_SUB_OVERWRITE: case OP_CONFIG_MODEL_SUB_DELETE: case OP_CONFIG_MODEL_SUB_ADD: + if (size != 6 && size != 8) + return true; + + n = cfg_sub_add_msg(node, pkt, size == 8, opcode); + break; + case OP_CONFIG_MODEL_SUB_DELETE_ALL: - config_sub_set(node, net_idx, src, dst, pkt, size, virt, - opcode); + if (size != 4 && size != 6) + return true; + + n = config_sub_del_all(node, pkt, size == 6); break; case OP_CONFIG_RELAY_SET: diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index deb0019f9..a40f92c01 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1069,11 +1069,11 @@ static bool parse_model_subscriptions(json_object *jsubs, switch (len) { case 4: - if (sscanf(str, "%04hx", &subs[i].src.addr) != 1) + if (sscanf(str, "%04hx", &subs[i].addr.grp) != 1) goto fail; break; case 32: - if (!str2hex(str, len, subs[i].src.virt_addr, 16)) + if (!str2hex(str, len, subs[i].addr.label, 16)) goto fail; subs[i].virt = true; break; @@ -2068,10 +2068,10 @@ bool mesh_config_model_sub_add(struct mesh_config *cfg, uint16_t ele_addr, return false; if (!sub->virt) { - snprintf(buf, 5, "%4.4x", sub->src.addr); + snprintf(buf, 5, "%4.4x", sub->addr.grp); len = 4; } else { - hex2str(sub->src.virt_addr, 16, buf, 33); + hex2str(sub->addr.label, 16, buf, 33); len = 32; } @@ -2122,10 +2122,10 @@ bool mesh_config_model_sub_del(struct mesh_config *cfg, uint16_t ele_addr, return true; if (!sub->virt) { - snprintf(buf, 5, "%4.4x", sub->src.addr); + snprintf(buf, 5, "%4.4x", sub->addr.grp); len = 4; } else { - hex2str(sub->src.virt_addr, 16, buf, 33); + hex2str(sub->addr.label, 16, buf, 33); len = 32; } diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 7dfa9f20c..f15f3f376 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -24,9 +24,9 @@ struct mesh_config; struct mesh_config_sub { bool virt; union { - uint16_t addr; - uint8_t virt_addr[16]; - } src; + uint16_t grp; + uint8_t label[16]; + } addr; }; struct mesh_config_pub { diff --git a/mesh/model.c b/mesh/model.c index ef7668147..3c9b6577a 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -664,7 +664,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } - if (l_queue_length(mod->bindings) >= MAX_BINDINGS) + if (l_queue_length(mod->bindings) >= MAX_MODEL_BINDINGS) return MESH_STATUS_INSUFF_RESOURCES; if (!mesh_config_model_binding_add(node_config_get(node), addr, @@ -737,7 +737,7 @@ static int set_virt_pub(struct mesh_model *mod, const uint8_t *label, } static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod, - const uint8_t *label, uint16_t *dst) + const uint8_t *label, uint16_t *addr) { struct mesh_virtual *virt = l_queue_find(mod->virtuals, find_virt_by_label, label); @@ -745,40 +745,35 @@ static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod, if (!virt) { virt = add_virtual(label); if (!virt) - return MESH_STATUS_STORAGE_FAIL; + return MESH_STATUS_INSUFF_RESOURCES; l_queue_push_head(mod->virtuals, virt); mesh_net_dst_reg(net, virt->addr); l_debug("Added virtual sub addr %4.4x", virt->addr); } - if (dst) - *dst = virt->addr; + if (addr) + *addr = virt->addr; return MESH_STATUS_SUCCESS; } static int add_sub(struct mesh_net *net, struct mesh_model *mod, - const uint8_t *group, bool b_virt, uint16_t *dst) + uint16_t addr) { - uint16_t grp; - - if (b_virt) - return add_virt_sub(net, mod, group, dst); - - grp = l_get_le16(group); - if (dst) - *dst = grp; + if (!mod->subs) + mod->subs = l_queue_new(); - if (!l_queue_find(mod->subs, simple_match, L_UINT_TO_PTR(grp))) { + if (l_queue_find(mod->subs, simple_match, L_UINT_TO_PTR(addr))) + return MESH_STATUS_SUCCESS; - if (!mod->subs) - mod->subs = l_queue_new(); + if ((l_queue_length(mod->subs) + l_queue_length(mod->virtuals)) >= + MAX_MODEL_SUBS) + return MESH_STATUS_INSUFF_RESOURCES; - l_queue_push_tail(mod->subs, L_UINT_TO_PTR(grp)); - mesh_net_dst_reg(net, grp); - l_debug("Added group subscription %4.4x", grp); - } + l_queue_push_tail(mod->subs, L_UINT_TO_PTR(addr)); + mesh_net_dst_reg(net, addr); + l_debug("Added group subscription %4.4x", addr); return MESH_STATUS_SUCCESS; } @@ -1454,8 +1449,8 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { struct mesh_model *mod; int status, ele_idx = node_get_element_idx(node, addr); @@ -1470,7 +1465,35 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - status = add_sub(node_get_net(node), mod, group, is_virt, dst); + status = add_sub(node_get_net(node), mod, addr); + if (status != MESH_STATUS_SUCCESS) + return status; + + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); + + return MESH_STATUS_SUCCESS; +} + +int mesh_model_virt_sub_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *pub_addr) +{ + struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; + + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + + status = add_virt_sub(node_get_net(node), mod, label, pub_addr); if (status != MESH_STATUS_SUCCESS) return status; @@ -1482,12 +1505,11 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { - struct l_queue *virtuals, *subs; struct mesh_model *mod; - int status, ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1499,36 +1521,39 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - subs = mod->subs; - virtuals = mod->virtuals; - mod->subs = l_queue_new(); - mod->virtuals = l_queue_new(); + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); - if (!mod->subs || !mod->virtuals) - return MESH_STATUS_INSUFF_RESOURCES; + add_sub(node_get_net(node), mod, addr); - status = add_sub(node_get_net(node), mod, group, is_virt, dst); + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); - if (status != MESH_STATUS_SUCCESS) { - /* Adding new group failed, so revert to old lists */ - l_queue_destroy(mod->subs, NULL); - mod->subs = subs; - l_queue_destroy(mod->virtuals, unref_virt); - mod->virtuals = virtuals; - } else { - const struct l_queue_entry *entry; - struct mesh_net *net = node_get_net(node); + return MESH_STATUS_SUCCESS; +} + +int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr) +{ + struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; - entry = l_queue_get_entries(subs); + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; - for (; entry; entry = entry->next) - mesh_net_dst_unreg(net, - (uint16_t) L_PTR_TO_UINT(entry->data)); + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); - /* Destroy old lists */ - l_queue_destroy(subs, NULL); - l_queue_destroy(virtuals, unref_virt); - } + status = add_virt_sub(node_get_net(node), mod, label, addr); if (!mod->cbs) /* External models */ @@ -1537,10 +1562,9 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, return status; } -int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { - uint16_t grp; struct mesh_model *mod; int ele_idx = node_get_element_idx(node, addr); @@ -1554,26 +1578,47 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - if (is_virt) { - struct mesh_virtual *virt; + if (l_queue_remove(mod->subs, L_UINT_TO_PTR(addr))) { + mesh_net_dst_unreg(node_get_net(node), addr); - virt = l_queue_find(mod->virtuals, find_virt_by_label, group); - if (virt) { - l_queue_remove(mod->virtuals, virt); - grp = virt->addr; - unref_virt(virt); - } else { - if (!mesh_crypto_virtual_addr(group, &grp)) - return MESH_STATUS_STORAGE_FAIL; - } - } else { - grp = l_get_le16(group); + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); } - *dst = grp; + return MESH_STATUS_SUCCESS; +} - if (l_queue_remove(mod->subs, L_UINT_TO_PTR(grp))) { - mesh_net_dst_unreg(node_get_net(node), grp); +int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr) +{ + struct mesh_model *mod; + struct mesh_virtual *virt; + int ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; + + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + + virt = l_queue_remove_if(mod->virtuals, find_virt_by_label, label); + + if (virt) { + *addr = virt->addr; + unref_virt(virt); + } else { + *addr = UNASSIGNED_ADDRESS; + return MESH_STATUS_SUCCESS; + } + + if (l_queue_remove(mod->subs, L_UINT_TO_PTR(*addr))) { + mesh_net_dst_unreg(node_get_net(node), *addr); if (!mod->cbs) /* External models */ @@ -1614,9 +1659,9 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, struct mesh_config_pub *pub = db_mod->pub; uint32_t i; - if (db_mod->num_bindings > MAX_BINDINGS) { + if (db_mod->num_bindings > MAX_MODEL_BINDINGS) { l_warn("Binding list too long %u (max %u)", - db_mod->num_bindings, MAX_BINDINGS); + db_mod->num_bindings, MAX_MODEL_BINDINGS); return NULL; } @@ -1670,22 +1715,12 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, return mod; for (i = 0; i < db_mod->num_subs; i++) { - uint16_t group; - uint8_t *src; + struct mesh_config_sub *sub = &db_mod->subs[i]; - /* - * To keep calculations for virtual label coherent, - * convert to little endian. - */ - l_put_le16(db_mod->subs[i].src.addr, &group); - src = db_mod->subs[i].virt ? db_mod->subs[i].src.virt_addr : - (uint8_t *) &group; - - if (add_sub(net, mod, src, db_mod->subs[i].virt, NULL) != - MESH_STATUS_SUCCESS) { - mesh_model_free(mod); - return NULL; - } + if (!sub->virt) + add_sub(net, mod, sub->addr.grp); + else + add_virt_sub(net, mod, sub->addr.label, NULL); } return mod; diff --git a/mesh/model.h b/mesh/model.h index 0d8dddf92..3221379af 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -19,8 +19,8 @@ struct mesh_model; -#define MAX_BINDINGS 10 -#define MAX_GRP_PER_MOD 10 +#define MAX_MODEL_BINDINGS 10 +#define MAX_MODEL_SUBS 10 #define ACTION_ADD 1 #define ACTION_UPDATE 2 @@ -89,12 +89,21 @@ int mesh_model_get_bindings(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_sz, uint16_t *len); int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); + uint16_t grp); +int mesh_model_virt_sub_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); + uint16_t grp); +int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id); -int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); +int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr); +int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size); uint16_t mesh_model_cfg_blk(uint8_t *pkt); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2FiKK/oRK1+oXgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 22:09:30 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sGsKKvoRK1/lXgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 22:09:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1D8C4A1197; Wed, 5 Aug 2020 22:09:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728189AbgHEUGt (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 16:06:49 -0400 Received: from mail-pg1-f200.google.com ([209.85.215.200]:48770 "EHLO mail-pg1-f200.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726986AbgHEQed (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 12:34:33 -0400 Received: by mail-pg1-f200.google.com with SMTP id k32so2130669pgm.15 for <linux-bluetooth@vger.kernel.org>; Wed, 05 Aug 2020 09:34:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=vD/veeEc05bcXlG0e+JSfe9O59TwwwUvH3Hr6H/SIyA=; b=TWBJCGlPk9ZLOIl7WWeZt/iFerGhW9MW1R5RXz6L3d/xiTXtmRIQfzajtKxyKxdBaZ Ejk0A4KKv0uDna1aVUsCh9LnPrbgeWCxws3lR3N3JqqBkzoCO9/iLNc+iNYvt1weJJua IQI3IvpKz5rNiukyLgb7B3vXJqAULIhzwrUG6YMXj+GmejBtGA1Oc/52DWzQUM33KV6i IJZf+5vX2WZVjNlYF3IgQWnm9rbJR1OhTsu0XLa7OR+EWWM37f7N6MaWT86tjtzzkESg K0u25eeC9QlVHri2alYsq5Jgk0QpSgxInpmPvzMOacN3C4Z/7KyiGL6/iSujc0Ih6Uhv ACOg== X-Gm-Message-State: AOAM531OjpdCXRiM2SSj5Xq1KX1NYqZHVmxiPMOdQAd9rR9sjDhaxpKP BqRVLaRknl8dLjIHKRjFMgToktVXOYx4vfy/HLHxA1zX7PJw X-Google-Smtp-Source: ABdhPJyCIyEAmTjH3mqmhkj1F6rTlvWQHvwfZk6hoXyQVk34+x2BOvU/JDLR5tpGpsL3ZeWGnfdbt0fxmuRIfqVtucp3aBL6viaF MIME-Version: 1.0 X-Received: by 2002:a92:dcc6:: with SMTP id b6mr4591063ilr.147.1596642980561; Wed, 05 Aug 2020 08:56:20 -0700 (PDT) Date: Wed, 05 Aug 2020 08:56:20 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000b087a705ac2369dd@google.com> Subject: INFO: trying to register non-static key in l2cap_chan_del From: syzbot <syzbot+abfc0f5e668d4099af73@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1D8C4A1197 X-Rspamd-UID: b6a465 Hello, syzbot found the following issue on: HEAD commit: 442489c2 Merge tag 'timers-core-2020-08-04' of git://git.k.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=15aa9494900000 kernel config: https://syzkaller.appspot.com/x/.config?x=669b4bedb6478222 dashboard link: https://syzkaller.appspot.com/bug?extid=abfc0f5e668d4099af73 compiler: gcc (GCC) 10.1.0-syz 20200507 Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+abfc0f5e668d4099af73@syzkaller.appspotmail.com INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 1 PID: 27 Comm: kworker/1:1 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 assign_lock_key kernel/locking/lockdep.c:894 [inline] register_lock_class+0x157d/0x1630 kernel/locking/lockdep.c:1206 __lock_acquire+0xf9/0x5640 kernel/locking/lockdep.c:4305 lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:5005 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:175 spin_lock_bh include/linux/spinlock.h:359 [inline] lock_sock_nested+0x3b/0x110 net/core/sock.c:3070 l2cap_sock_teardown_cb+0x88/0x400 net/bluetooth/l2cap_sock.c:1520 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:824 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor instruction fetch in kernel mode #PF: error_code(0x0010) - not-present page PGD 32376067 P4D 32376067 PUD 9356f067 PMD 0 Oops: 0010 [#1] PREEMPT SMP KASAN CPU: 1 PID: 27 Comm: kworker/1:1 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout RIP: 0010:0x0 Code: Bad RIP value. RSP: 0018:ffffc90000e17b60 EFLAGS: 00010246 RAX: dffffc0000000000 RBX: ffff88808d94c000 RCX: ffffffff8723aa4f RDX: 1ffff11005e48c8c RSI: ffffffff8723ac9c RDI: ffff88802f246000 RBP: 0000000000000005 R08: 0000000000000001 R09: ffff88802f246067 R10: 0000000000000009 R11: 0000000000000001 R12: 000000000000006f R13: ffff88802f246000 R14: 0000000000000000 R15: 0000000000000005 FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 0000000094fa9000 CR4: 00000000001426e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: l2cap_sock_teardown_cb+0x374/0x400 net/bluetooth/l2cap_sock.c:1547 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:824 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Modules linked in: CR2: 0000000000000000 ---[ end trace 661471e896caece1 ]--- RIP: 0010:0x0 Code: Bad RIP value. RSP: 0018:ffffc90000e17b60 EFLAGS: 00010246 RAX: dffffc0000000000 RBX: ffff88808d94c000 RCX: ffffffff8723aa4f RDX: 1ffff11005e48c8c RSI: ffffffff8723ac9c RDI: ffff88802f246000 RBP: 0000000000000005 R08: 0000000000000001 R09: ffff88802f246067 R10: 0000000000000009 R11: 0000000000000001 R12: 000000000000006f R13: ffff88802f246000 R14: 0000000000000000 R15: 0000000000000005 FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 0000000094fa9000 CR4: 00000000001426e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KCZ9NEcSK19QugAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 22:10:47 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 6HJxM0cSK18uGwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 22:10:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CF900A0377; Wed, 5 Aug 2020 22:10:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729818AbgHEUHX (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 16:07:23 -0400 Received: from mail-io1-f69.google.com ([209.85.166.69]:51842 "EHLO mail-io1-f69.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726898AbgHEQdI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 12:33:08 -0400 Received: by mail-io1-f69.google.com with SMTP id l1so31948675ioh.18 for <linux-bluetooth@vger.kernel.org>; Wed, 05 Aug 2020 09:33:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=xdDF8KAwPeDbsdN5hACSBVSNt3eeL93Vn3ZE06PW0ws=; b=Q2H/pe1XDzyd1GLPT2YihSl7c5opc/ZSq6u3aoZgbu+xtM0tFVFi7Enp1+cbiWoD4m rCGxCfbuPtf3jqADhueqAfVPUEiJQwcHXki17uFy3iOGIk0TsYHcRpBSXzc7tjgZnJCo j94d4wJE9q9AjwUs+D7jjMjC+d2ZZtaZsoqStpzORvkrPqEljjeljNtzfaaa90sAN3lM wYG+Relh6soUkTEHkBEKF2in3JRsSRNaep37/wmudyA6ae0ZzMAgwG/rrrekZEdRRqQi NQp1aKK1HefGct7C+H2hvbRd9H3RoPbwTwta1ZgnCr1M37y8Q50CYcr9XxN44jzhMsbx 5Dlw== X-Gm-Message-State: AOAM530IYDEB6t0X2uTqs0D0szJV8pgveCW1ZeyPNKMoDjcn7Xy1D+yD CtHiyxK8DpP2Fuo+WUlYInB3XxtE6SuISJcgcrOmd0A3PRet X-Google-Smtp-Source: ABdhPJx1bzir56joK2ABAxtH0sKqUYFQk87L5ebinbPqcd6dHIycZoH3GBn4mZAYZSuRbVEjVUHzKuZ7t4g9wSnDVEVr5CKihhk0 MIME-Version: 1.0 X-Received: by 2002:a6b:ba06:: with SMTP id k6mr4243404iof.101.1596645187111; Wed, 05 Aug 2020 09:33:07 -0700 (PDT) Date: Wed, 05 Aug 2020 09:33:07 -0700 In-Reply-To: <00000000000023efa305ac1b5309@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000035d35105ac23ed6d@google.com> Subject: Re: WARNING: refcount bug in l2cap_global_chan_by_psm From: syzbot <syzbot+39ad9f042519082fcec9@syzkaller.appspotmail.com> To: coreteam@netfilter.org, davem@davemloft.net, edubezval@gmail.com, johan.hedberg@gmail.com, kaber@trash.net, kadlec@blackhole.kfki.hu, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, marcel@holtmann.org, mchehab@kernel.org, mchehab@s-opensource.com, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, pablo@netfilter.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 10 X-Rspamd-Score: 1.63 / 15.00 / 200.00 X-Rspamd-Queue-Id: CF900A0377 X-Rspamd-UID: 96d7d3 syzbot has bisected this issue to: commit 3c1e300966d7edc380e405b3ab70b6e3c813a121 Author: Mauro Carvalho Chehab <mchehab@s-opensource.com> Date: Tue Oct 18 19:44:12 2016 +0000 [media] si4713: don't break long lines bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=108f4002900000 start commit: c0842fbc random32: move the pseudo-random 32-bit definitio.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=128f4002900000 console output: https://syzkaller.appspot.com/x/log.txt?x=148f4002900000 kernel config: https://syzkaller.appspot.com/x/.config?x=76cacb0fe58c4a1e dashboard link: https://syzkaller.appspot.com/bug?extid=39ad9f042519082fcec9 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14491b04900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1188e392900000 Reported-by: syzbot+39ad9f042519082fcec9@syzkaller.appspotmail.com Fixes: 3c1e300966d7 ("[media] si4713: don't break long lines") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gHhII4YUK1+oXgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 22:20:22 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wBCpIYYUK19OCwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 22:20:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id ACAB8A11EC; Wed, 5 Aug 2020 22:20:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729586AbgHEUOp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 16:14:45 -0400 Received: from mail-il1-f200.google.com ([209.85.166.200]:48158 "EHLO mail-il1-f200.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726764AbgHEQX0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 12:23:26 -0400 Received: by mail-il1-f200.google.com with SMTP id x4so1918959ilk.15 for <linux-bluetooth@vger.kernel.org>; Wed, 05 Aug 2020 09:22:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=gf59HPMENV3tGrAXq5hE5QTaFPtfjI08GkK5Z/pVw18=; b=MjuqQJn+f9EWfaCts4O27lNzwI97ivjbFtq2KMF1LmRu9woaI0yUXhiMrvLTYCRBug wPXX4MhYqY2Q5boegvamFBkF/HdCkSFIfp8AVV8S0a5NnRLSuO5cDLdKkcgZP8I5yU5M qSofgeGnZJma8VgEBw40atPkg7vlwPZq31nhpXhoywCOWldw6RGoKOkun4BmCv1oLyGl K7vWF40fLTgEFeNe0uICSL8JgTBqxdm4FAeOX5yTm6Wyb4w/bX30O6nW4kMvcC37V4ho MVWEYHPp00NTxo3kNF0ZCiiVaQ/xzfNGKKU2DBZTxOXHrRBI5vnn64rKZlPk14Cprriz wsjA== X-Gm-Message-State: AOAM531HIPphqtAzuI2KrjM34wLDAh3h1JeMgIjr+DON6HALqvI5OoQp 5RuMGxEnBSAwh/WbrXUPHQ/+aqQ3tqPiNnKON8EH8CZQwg4V X-Google-Smtp-Source: ABdhPJxl0BPdl6oM/s7HLtGwzvDPhEYlmelG5KgJF5rbDcL7n1B3Q6UoxJACGDSfOLK8hC/Y8LQyi/I8pkm2k0uNJ6e3zo992gYj MIME-Version: 1.0 X-Received: by 2002:a5d:9a86:: with SMTP id c6mr4183230iom.27.1596643761561; Wed, 05 Aug 2020 09:09:21 -0700 (PDT) Date: Wed, 05 Aug 2020 09:09:21 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000003da5f105ac239832@google.com> Subject: general protection fault in bt_accept_unlink From: syzbot <syzbot+a9c8613ce9eafbd86441@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: ACAB8A11EC X-Rspamd-UID: 3bb954 Hello, syzbot found the following issue on: HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: net console output: https://syzkaller.appspot.com/x/log.txt?x=1639b284900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 dashboard link: https://syzkaller.appspot.com/bug?extid=a9c8613ce9eafbd86441 compiler: gcc (GCC) 10.1.0-syz 20200507 Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+a9c8613ce9eafbd86441@syzkaller.appspotmail.com general protection fault, probably for non-canonical address 0xf777682000003777: 0000 [#1] PREEMPT SMP KASAN KASAN: maybe wild-memory-access in range [0xbbbb61000001bbb8-0xbbbb61000001bbbf] CPU: 0 PID: 9028 Comm: kworker/0:6 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout RIP: 0010:__list_del_entry_valid+0x81/0xef lib/list_debug.c:51 Code: 0f 84 df 00 00 00 48 b8 22 01 00 00 00 00 ad de 49 39 c4 0f 84 e0 00 00 00 48 b8 00 00 00 00 00 fc ff df 4c 89 e2 48 c1 ea 03 <80> 3c 02 00 75 51 49 8b 14 24 48 39 ea 0f 85 97 00 00 00 49 8d 7d RSP: 0018:ffffc900091afb18 EFLAGS: 00010a06 RAX: dffffc0000000000 RBX: ffff8880a71664b8 RCX: ffffffff8724984f RDX: 17776c2000003777 RSI: ffffffff8717d437 RDI: ffff8880a71664c0 RBP: ffff8880a71664b8 R08: 0000000000000001 R09: ffff8880a7166067 R10: 0000000000000009 R11: 00000000000ccae8 R12: bbbb61000001bbbb R13: bb60000000bbbbbb R14: 00000060000000bb R15: 0000000000000005 FS: 0000000000000000(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000ca8660 CR3: 000000009115f000 CR4: 00000000001406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: __list_del_entry include/linux/list.h:132 [inline] list_del_init include/linux/list.h:204 [inline] bt_accept_unlink+0x26/0x280 net/bluetooth/af_bluetooth.c:187 l2cap_sock_teardown_cb+0x197/0x400 net/bluetooth/l2cap_sock.c:1544 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:824 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Modules linked in: ---[ end trace 89227449b8393688 ]--- RIP: 0010:__list_del_entry_valid+0x81/0xef lib/list_debug.c:51 Code: 0f 84 df 00 00 00 48 b8 22 01 00 00 00 00 ad de 49 39 c4 0f 84 e0 00 00 00 48 b8 00 00 00 00 00 fc ff df 4c 89 e2 48 c1 ea 03 <80> 3c 02 00 75 51 49 8b 14 24 48 39 ea 0f 85 97 00 00 00 49 8d 7d RSP: 0018:ffffc900091afb18 EFLAGS: 00010a06 RAX: dffffc0000000000 RBX: ffff8880a71664b8 RCX: ffffffff8724984f RDX: 17776c2000003777 RSI: ffffffff8717d437 RDI: ffff8880a71664c0 RBP: ffff8880a71664b8 R08: 0000000000000001 R09: ffff8880a7166067 R10: 0000000000000009 R11: 00000000000ccae8 R12: bbbb61000001bbbb R13: bb60000000bbbbbb R14: 00000060000000bb R15: 0000000000000005 FS: 0000000000000000(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000ca8660 CR3: 000000009d89f000 CR4: 00000000001406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OOOWAlb2Kl9hyAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 20:11:34 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OGj1AFb2Kl/e8QAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 20:11:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2B5A6420C1; Wed, 5 Aug 2020 20:11:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729158AbgHESLT (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 14:11:19 -0400 Received: from mail-io1-f71.google.com ([209.85.166.71]:43024 "EHLO mail-io1-f71.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729165AbgHESJX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 14:09:23 -0400 Received: by mail-io1-f71.google.com with SMTP id f19so8145793iol.10 for <linux-bluetooth@vger.kernel.org>; Wed, 05 Aug 2020 11:09:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=YloGL6E01nHExHJj20pzTeVaG7arypuWNvc/TTQM6GU=; b=twXCNRo9w6147W3HskG4yBRiknV4vMSs883mZfQImTQ3mUMjrm9/DVmQiLy71GOG+K P8PjmVSt9Kv5tIOAgufUo+nmE3cLDeV/jKop5JGbtyzdoPv6WpC1nipBQPPEhMPLTSwJ kkU5jO850Bj5m9cpursVtV4SMXjCDUIm4SxDlpdyTxM+oMULLQ1zYWbpr/WIZT1q1/26 C6pVW6+jhwdImNfUH8P/PQvyfkf2HRqm5+mWuPFY8hofmc+VSCR237aLi98AMZrfJhBT jlapPXPhswKh4rScvty1U20zRUaTIAjNWUGqQUyCmLzgXMXHdaE6SoFGPvKI3+ZgxGeP eNGQ== X-Gm-Message-State: AOAM530nsWRCX0qr51NJPQusfGcnFB4NiOHOkA387GCz9PlRNQN54nAi b3wp7c08kMalWWpDC+ACoctLnpOcZwo8ZB1MMd92QumkpV1q X-Google-Smtp-Source: ABdhPJxKKv7Wr77Bbzsv5urdfzRqc3Ro2et+RbGkg6ws9iwd9GeFuikYIHMlqbLtnzqWa1N3LL1eyj/v5jRCbV2oUEfjHNWPBA2z MIME-Version: 1.0 X-Received: by 2002:a05:6638:2493:: with SMTP id x19mr5753725jat.53.1596650962939; Wed, 05 Aug 2020 11:09:22 -0700 (PDT) Date: Wed, 05 Aug 2020 11:09:22 -0700 In-Reply-To: <000000000000b087a705ac2369dd@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000079f28205ac254528@google.com> Subject: Re: INFO: trying to register non-static key in l2cap_chan_del From: syzbot <syzbot+abfc0f5e668d4099af73@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -1.20 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2B5A6420C1 X-Rspamd-UID: aa4423 syzbot has found a reproducer for the following issue on: HEAD commit: 4c900a6b farsync: switch from 'pci_' to 'dma_' API git tree: net-next console output: https://syzkaller.appspot.com/x/log.txt?x=1561801a900000 kernel config: https://syzkaller.appspot.com/x/.config?x=91a13b78c7dc258d dashboard link: https://syzkaller.appspot.com/bug?extid=abfc0f5e668d4099af73 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15bdcc3a900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+abfc0f5e668d4099af73@syzkaller.appspotmail.com INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 0 PID: 5 Comm: kworker/0:0 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 assign_lock_key kernel/locking/lockdep.c:894 [inline] register_lock_class+0x157d/0x1630 kernel/locking/lockdep.c:1206 __lock_acquire+0xfa/0x56e0 kernel/locking/lockdep.c:4259 lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:4959 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:175 spin_lock_bh include/linux/spinlock.h:358 [inline] lock_sock_nested+0x3b/0x110 net/core/sock.c:3019 l2cap_sock_teardown_cb+0x88/0x400 net/bluetooth/l2cap_sock.c:1520 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:823 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor instruction fetch in kernel mode #PF: error_code(0x0010) - not-present page PGD 0 P4D 0 Oops: 0010 [#1] PREEMPT SMP KASAN CPU: 0 PID: 5 Comm: kworker/0:0 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout RIP: 0010:0x0 Code: Bad RIP value. RSP: 0018:ffffc90000cbfb60 EFLAGS: 00010246 RAX: dffffc0000000000 RBX: ffff8880931bd000 RCX: ffffffff8728bc2f RDX: 1ffff11014549a8c RSI: ffffffff8728be7c RDI: ffff8880a2a4d000 RBP: 0000000000000005 R08: 0000000000000001 R09: ffff8880a2a4d067 R10: 0000000000000009 R11: 0000000000000001 R12: 000000000000006f R13: ffff8880a2a4d000 R14: 0000000000000000 R15: 0000000000000005 FS: 0000000000000000(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 00000000929e6000 CR4: 00000000001406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: l2cap_sock_teardown_cb+0x374/0x400 net/bluetooth/l2cap_sock.c:1547 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:823 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Modules linked in: CR2: 0000000000000000 ---[ end trace ecb0577583d92fc1 ]--- RIP: 0010:0x0 Code: Bad RIP value. RSP: 0018:ffffc90000cbfb60 EFLAGS: 00010246 RAX: dffffc0000000000 RBX: ffff8880931bd000 RCX: ffffffff8728bc2f RDX: 1ffff11014549a8c RSI: ffffffff8728be7c RDI: ffff8880a2a4d000 RBP: 0000000000000005 R08: 0000000000000001 R09: ffff8880a2a4d067 R10: 0000000000000009 R11: 0000000000000001 R12: 000000000000006f R13: ffff8880a2a4d000 R14: 0000000000000000 R15: 0000000000000005 FS: 0000000000000000(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 00000000929e6000 CR4: 00000000001406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SMH4DOL4Kl/YJwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 20:22:26 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id qF9lC+L4Kl8UEAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 20:22:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9137A420B8; Wed, 5 Aug 2020 20:22:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728367AbgHESVS (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 14:21:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729181AbgHESLW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 14:11:22 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A2CCC06138D; Wed, 5 Aug 2020 11:10:32 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id s15so16744045qvv.7; Wed, 05 Aug 2020 11:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CSOoq3zhF6z2fZ+X97MfanJIRrTuyK8BNIkdVGDMQEQ=; b=WkEWqptLDy3R6ioOulhs9LCTz33DYC1YwZpUJavPXOLVGV2Oh1GCAetOfpDiAicnfC bnnTTBfinXKPD8zwEhxTo3jAr1u6b1KivySeOrU9BiBn/I6UQAqhjBJCNsMKvG0hkImf ALAyJ0TBul74xRJlxBK0ORqfKLnd46HXDgh18AjaR8DPqu0fHH8ldssbfQi1trX6tRB7 5UW7Vc1V2K2qydneRegNu1wCNbnVqa8s8SaDMEMPNS65YHhlNkvARMGJz77FYBEcMec3 v1SU3F9ISIdfIyZiYpIFsVgMAzZcO+5s6AMfJZRSIANi/QySkiAvuVZebvBhIVj14HNN KJ6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CSOoq3zhF6z2fZ+X97MfanJIRrTuyK8BNIkdVGDMQEQ=; b=a4Plm0h/9rXTD4DSDFG67hE/2D5IY1EAldWANby4cPctLkiqPo4Ped9khm/Z1iUGuX soLEHmcfXVsL2O3zVZSsvIzjZGDrzdeJfP7kAo5cjj1UTD3u+GxwICQgQW5Ffvisjqc1 WMc/mS1lTjSmN7w3GcdzWX2R/14/TPkHIsuSZMj3OeCew7e96gBJCVGz9diRbEBL+I9r seAheRMgxGkRCxnFvXscmqKwnljpGc83bQSouqJdjkMq/xtk7nG4wPlKZ5Vx1jYpjR/y UCl/re5o8+CpdaWuAoWv4Bvs5oYxW053tWhI3oNqceyFn1dYBfAwKBLXoiaOPPnym312 OT4w== X-Gm-Message-State: AOAM530BDCfwX1T4ctGYQKfWyNjVotXgZnz12wqWqp4YweWjpH8dQfH6 ibluYCAoc+ODEW6S1UTe+Q== X-Google-Smtp-Source: ABdhPJybD0CTplQH9PaqhvAh94r4pvrJHLy/2Cb1rWWuo+HcvlxTLUJMXYleqq82a0Jy8907RV108g== X-Received: by 2002:ad4:438f:: with SMTP id s15mr5142142qvr.164.1596651031728; Wed, 05 Aug 2020 11:10:31 -0700 (PDT) Received: from localhost.localdomain (146-115-88-66.s3894.c3-0.sbo-ubr1.sbo.ma.cable.rcncustomer.com. [146.115.88.66]) by smtp.gmail.com with ESMTPSA id i7sm2571560qtb.27.2020.08.05.11.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:10:31 -0700 (PDT) From: Peilin Ye <yepeilin.cs@gmail.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Cc: Peilin Ye <yepeilin.cs@gmail.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH net] Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt() Date: Wed, 5 Aug 2020 14:09:02 -0400 Message-Id: <20200805180902.684024-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.41 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9137A420B8 X-Rspamd-UID: fa76be `num_reports` is not being properly checked. A malformed event packet with a large `num_reports` number makes hci_le_direct_adv_report_evt() read out of bounds. Fix it. Reported-and-tested-by: syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com Fixes: 2f010b55884e ("Bluetooth: Add support for handling LE Direct Advertising Report events") Link: https://syzkaller.appspot.com/bug?extid=24ebd650e20bd263ca01 Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> --- I moved the initialization of `ev` out of the loop and restructured the function a bit, since otherwise the check would look like: if (!num_reports || skb->len < num_reports * sizeof(struct hci_ev_le_direct_adv_info) + 1) return; Therefore I used the similar structure with hci_inquiry_result_evt() etc. hci_le_adv_report_evt() and hci_le_ext_adv_report_evt() also have the same issue with `num_reports`, but I'm not sure how to perform the check for them, since they use variable-length reports. Should we do something like this? (take hci_le_adv_report_evt() as example:) if (!num_reports || skb->len < num_reports * (sizeof(*ev) + HCI_MAX_AD_LENGTH + 1) + 1) return; Then how about hci_le_ext_adv_report_evt()? There is no such `HCI_MAX_AD_LENGTH` restrictions on `ev->length` for it, I assume? Would like to hear your opinion. Thank you! net/bluetooth/hci_event.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 4b7fc430793c..aec43ae488d1 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5863,21 +5863,19 @@ static void hci_le_direct_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb) { u8 num_reports = skb->data[0]; - void *ptr = &skb->data[1]; + struct hci_ev_le_direct_adv_info *ev = (void *)&skb->data[1]; - hci_dev_lock(hdev); + if (!num_reports || skb->len < num_reports * sizeof(*ev) + 1) + return; - while (num_reports--) { - struct hci_ev_le_direct_adv_info *ev = ptr; + hci_dev_lock(hdev); + for (; num_reports; num_reports--, ev++) process_adv_report(hdev, ev->evt_type, &ev->bdaddr, ev->bdaddr_type, &ev->direct_addr, ev->direct_addr_type, ev->rssi, NULL, 0, false); - ptr += sizeof(*ev); - } - hci_dev_unlock(hdev); } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0BB4C3wGK1+MewAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 21:20:28 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id cKesCXwGK1/9YQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 21:20:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 710F7420B7; Wed, 5 Aug 2020 21:20:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728146AbgHETUQ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 15:20:16 -0400 Received: from mga05.intel.com ([192.55.52.43]:42221 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728993AbgHERsu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 13:48:50 -0400 IronPort-SDR: RLh1ZHCg3Zj5wL6y2bWc1PxR9FWvMGHiPK0vfhu3QPJiwLswJhX0xOscgqWJyF9Zh/OmEaGMwj lyPDu2E7AvAw== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470677" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470677" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:45:03 -0700 IronPort-SDR: U25lcw8gnejGnT7Sl7TNPH+p+LCBftht2W67RkExKa1jwR+ha3vhvtgC9R6Ilejjq+haJISkxw Rk147iy6U4Og== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245800" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:45:02 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v4 10/10] mesh: Refactor heartbeat pub/sub Date: Wed, 5 Aug 2020 10:44:56 -0700 Message-Id: <20200805174456.49342-11-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805174456.49342-1-inga.stotland@intel.com> References: <20200805174456.49342-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 710F7420B7 X-Rspamd-UID: da7ff3 Move heartbeat publication/subscription timers and housekeeping to net.c since this is where the trigger events and control messages are handled. Configuration server (cfgmod-server.c) stays responsible for parsing the set pub/sub message parameters and assemblying the pub/sub status messages. Also, make sure that the correct message status is reported. --- mesh/cfgmod-server.c | 307 ++++++++++++++----------------------------- mesh/net.c | 273 ++++++++++++++++++++++++++++---------- mesh/net.h | 48 ++++--- 3 files changed, 328 insertions(+), 300 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 98c04dde7..25632abeb 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -457,50 +457,6 @@ done: return n + 3; } -static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) -{ - struct mesh_net *net = user_data; - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - mesh_net_heartbeat_send(net); - - if (hb->pub_count != 0xffff) - hb->pub_count--; - if (hb->pub_count > 0) - l_timeout_modify(hb->pub_timer, hb->pub_period); - else { - l_timeout_remove(hb->pub_timer); - hb->pub_timer = NULL; - } -} - -static void update_hb_pub_timer(struct mesh_net *net, - struct mesh_net_heartbeat *hb) -{ - if (IS_UNASSIGNED(hb->pub_dst) || hb->pub_count == 0) { - l_timeout_remove(hb->pub_timer); - hb->pub_timer = NULL; - return; - } - - if (!hb->pub_timer) - hb->pub_timer = l_timeout_create(hb->pub_period, - hb_pub_timeout_func, net, NULL); - else - l_timeout_modify(hb->pub_timer, hb->pub_period); -} - -static void hb_sub_timeout_func(struct l_timeout *timeout, void *user_data) -{ - struct mesh_net *net = user_data; - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - l_debug("HB Subscription Ended"); - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; -} - static uint8_t uint32_to_log(uint32_t value) { uint32_t val = 1; @@ -519,85 +475,112 @@ static uint8_t uint32_to_log(uint32_t value) return ret; } -static uint32_t log_to_uint32(uint8_t log, uint8_t offset) +static uint16_t hb_subscription_get(struct mesh_node *node, int status) { - if (!log) - return 0x0000; - else if (log > 0x11) - return 0xffff; + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_sub *sub = mesh_net_get_heartbeat_sub(net); + struct timeval time_now; + uint16_t n; + + gettimeofday(&time_now, NULL); + time_now.tv_sec -= sub->start; + + if (time_now.tv_sec >= (long int) sub->period) + time_now.tv_sec = 0; else - return (1 << (log - offset)); -} + time_now.tv_sec = sub->period - time_now.tv_sec; + + l_debug("Sub Period (Log %2.2x) %d sec", uint32_to_log(time_now.tv_sec), + (int) time_now.tv_sec); + + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); + msg[n++] = status; + l_put_le16(sub->src, msg + n); + n += 2; + l_put_le16(sub->dst, msg + n); + n += 2; + msg[n++] = uint32_to_log(time_now.tv_sec); + msg[n++] = uint32_to_log(sub->count); + msg[n++] = sub->count ? sub->min_hops : 0; + msg[n++] = sub->max_hops; + return n; +} -static int hb_subscription_set(struct mesh_net *net, uint16_t src, - uint16_t dst, uint8_t period_log) +static uint16_t hb_subscription_set(struct mesh_node *node, const uint8_t *pkt) { - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - struct timeval time_now; + uint16_t src, dst; + uint8_t period_log; + struct mesh_net *net; + int status; + + src = l_get_le16(pkt); + dst = l_get_le16(pkt + 2); /* SRC must be Unicast, DST can be any legal address except Virtual */ if ((!IS_UNASSIGNED(src) && !IS_UNICAST(src)) || IS_VIRTUAL(dst)) - return -1; - - /* Check if the subscription should be disabled */ - if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst)) { - if (IS_GROUP(hb->sub_dst)) - mesh_net_dst_unreg(net, hb->sub_dst); - - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; - hb->sub_dst = UNASSIGNED_ADDRESS; - hb->sub_src = UNASSIGNED_ADDRESS; - hb->sub_count = 0; - hb->sub_period = 0; - hb->sub_min_hops = 0; - hb->sub_max_hops = 0; - return MESH_STATUS_SUCCESS; - - } else if (!period_log && src == hb->sub_src && dst == hb->sub_dst) { - /* Preserve collected data, but disable */ - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; - hb->sub_period = 0; - return MESH_STATUS_SUCCESS; - } + return 0; - if (hb->sub_dst != dst) { - if (IS_GROUP(hb->sub_dst)) - mesh_net_dst_unreg(net, hb->sub_dst); - if (IS_GROUP(dst)) - mesh_net_dst_reg(net, dst); - } + period_log = pkt[4]; - hb->sub_enabled = !!period_log; - hb->sub_src = src; - hb->sub_dst = dst; - hb->sub_count = 0; - hb->sub_period = log_to_uint32(period_log, 1); - hb->sub_min_hops = 0x00; - hb->sub_max_hops = 0x00; + if (period_log > 0x11) + return 0; - gettimeofday(&time_now, NULL); - hb->sub_start = time_now.tv_sec; + net = node_get_net(node); - if (!hb->sub_enabled) { - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - return MESH_STATUS_SUCCESS; - } + status = mesh_net_set_heartbeat_sub(net, src, dst, period_log); - hb->sub_min_hops = 0xff; + return hb_subscription_get(node, status); +} - if (!hb->sub_timer) - hb->sub_timer = l_timeout_create(hb->sub_period, - hb_sub_timeout_func, net, NULL); - else - l_timeout_modify(hb->sub_timer, hb->sub_period); +static uint16_t hb_publication_get(struct mesh_node *node, int status) +{ + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_pub *pub = mesh_net_get_heartbeat_pub(net); + uint16_t n; - return MESH_STATUS_SUCCESS; + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg); + msg[n++] = status; + l_put_le16(pub->dst, msg + n); + n += 2; + msg[n++] = uint32_to_log(pub->count); + msg[n++] = uint32_to_log(pub->period); + msg[n++] = pub->ttl; + l_put_le16(pub->features, msg + n); + n += 2; + l_put_le16(pub->net_idx, msg + n); + n += 2; + + return n; +} + +static uint16_t hb_publication_set(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t dst, features, net_idx; + uint8_t period_log, count_log, ttl; + struct mesh_net *net; + int status; + + dst = l_get_le16(pkt); + count_log = pkt[2]; + period_log = pkt[3]; + ttl = pkt[4]; + + if (count_log > 0x11 && count_log != 0xff) + return 0; + + if (period_log > 0x11 || ttl > TTL_MASK || IS_VIRTUAL(dst)) + return 0; + + features = l_get_le16(pkt + 5) & 0xf; + net_idx = l_get_le16(pkt + 7); + + net = node_get_net(node); + + status = mesh_net_set_heartbeat_pub(net, dst, features, net_idx, ttl, + count_log, period_log); + + return hb_publication_get(node, status); } static void node_reset(void *user_data) @@ -750,10 +733,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct mesh_node *node = (struct mesh_node *) user_data; struct mesh_net *net; const uint8_t *pkt = data; - struct timeval time_now; uint32_t opcode; - int b_res = MESH_STATUS_SUCCESS; - struct mesh_net_heartbeat *hb; uint16_t n_idx; uint8_t state; bool virt = false; @@ -769,7 +749,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, return false; net = node_get_net(node); - hb = mesh_net_heartbeat_get(net); + l_debug("CONFIG-SRV-opcode 0x%x size %u idx %3.3x", opcode, size, net_idx); @@ -1043,113 +1023,35 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_HEARTBEAT_PUB_SET: - l_debug("OP_CONFIG_HEARTBEAT_PUB_SET"); + l_debug("Config Heartbeat Publication Set"); if (size != 9) return true; - if (pkt[2] > 0x11 || pkt[3] > 0x10 || pkt[4] > 0x7f) - return true; - else if (IS_VIRTUAL(l_get_le16(pkt))) - b_res = MESH_STATUS_INVALID_ADDRESS; - else if (l_get_le16(pkt + 7) != mesh_net_get_primary_idx(net)) - /* Future work: check for valid subnets */ - b_res = MESH_STATUS_INVALID_NETKEY; - - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, - msg); - msg[n++] = b_res; - - memcpy(&msg[n], pkt, 9); - - /* Ignore RFU bits in features */ - l_put_le16(l_get_le16(pkt + 5) & 0xf, &msg[n + 5]); - - /* Add octet count to status */ - n += 9; - - if (b_res != MESH_STATUS_SUCCESS) - break; - - hb->pub_dst = l_get_le16(pkt); - if (hb->pub_dst == UNASSIGNED_ADDRESS || - pkt[2] == 0 || pkt[3] == 0) { - /* - * We might still have a pub_dst here in case - * we need it for State Change heartbeat - */ - hb->pub_count = 0; - hb->pub_period = 0; - } else { - hb->pub_count = (pkt[2] != 0xff) ? - log_to_uint32(pkt[2], 1) : 0xffff; - hb->pub_period = log_to_uint32(pkt[3], 1); - } - - hb->pub_ttl = pkt[4]; - hb->pub_features = l_get_le16(pkt + 5) & 0xf; - hb->pub_net_idx = l_get_le16(pkt + 7); - update_hb_pub_timer(net, hb); - + n = hb_publication_set(node, pkt); break; case OP_CONFIG_HEARTBEAT_PUB_GET: if (size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg); - msg[n++] = b_res; - l_put_le16(hb->pub_dst, msg + n); - n += 2; - msg[n++] = uint32_to_log(hb->pub_count); - msg[n++] = uint32_to_log(hb->pub_period); - msg[n++] = hb->pub_ttl; - l_put_le16(hb->pub_features, msg + n); - n += 2; - l_put_le16(hb->pub_net_idx, msg + n); - n += 2; + n = hb_publication_get(node, MESH_STATUS_SUCCESS); break; case OP_CONFIG_HEARTBEAT_SUB_SET: if (size != 5) return true; - l_debug("Set Sub Period (Log %2.2x) %d sec", - pkt[4], log_to_uint32(pkt[4], 1)); - - b_res = hb_subscription_set(net, l_get_le16(pkt), - l_get_le16(pkt + 2), - pkt[4]); - if (b_res < 0) - return true; + l_debug("Set HB Sub Period Log %2.2x", pkt[4]); - /* Fall through */ + n = hb_subscription_set(node, pkt); + break; case OP_CONFIG_HEARTBEAT_SUB_GET: - if (opcode == OP_CONFIG_HEARTBEAT_SUB_GET && size != 0) - return true; - - gettimeofday(&time_now, NULL); - time_now.tv_sec -= hb->sub_start; - if (time_now.tv_sec >= (long int) hb->sub_period) - time_now.tv_sec = 0; - else - time_now.tv_sec = hb->sub_period - time_now.tv_sec; - - l_debug("Sub Period (Log %2.2x) %d sec", - uint32_to_log(time_now.tv_sec), - (int) time_now.tv_sec); + if (size != 0) + return true; - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); - msg[n++] = b_res; - l_put_le16(hb->sub_src, msg + n); - n += 2; - l_put_le16(hb->sub_dst, msg + n); - n += 2; - msg[n++] = uint32_to_log(time_now.tv_sec); - msg[n++] = uint32_to_log(hb->sub_count); - msg[n++] = hb->sub_count ? hb->sub_min_hops : 0; - msg[n++] = hb->sub_max_hops; + n = hb_subscription_get(node, MESH_STATUS_SUCCESS); break; case OP_CONFIG_POLL_TIMEOUT_GET: @@ -1179,13 +1081,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, static void cfgmod_srv_unregister(void *user_data) { - struct mesh_node *node = user_data; - struct mesh_net *net = node_get_net(node); - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - l_timeout_remove(hb->pub_timer); - l_timeout_remove(hb->sub_timer); - hb->pub_timer = hb->sub_timer = NULL; } static const struct mesh_model_ops ops = { diff --git a/mesh/net.c b/mesh/net.c index 9b4454fee..633727601 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -23,6 +23,8 @@ #define _GNU_SOURCE +#include <sys/time.h> + #include <ell/ell.h> #include "mesh/mesh-defs.h" @@ -132,7 +134,10 @@ struct mesh_net { uint8_t count; } relay; - struct mesh_net_heartbeat heartbeat; + /* Heartbeat info */ + struct mesh_net_heartbeat_sub hb_sub; + struct mesh_net_heartbeat_pub hb_pub; + uint16_t features; struct l_queue *subnets; struct l_queue *msg_cache; @@ -255,35 +260,46 @@ static bool match_friend_key_id(const void *a, const void *b) (key_id == friend->net_key_upd); } -static void idle_mesh_heartbeat_send(void *net) +static void send_hb_publication(void *data) { - mesh_net_heartbeat_send(net); + struct mesh_net *net = data; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + uint8_t msg[4]; + int n = 0; + + if (pub->dst == UNASSIGNED_ADDRESS) + return; + + msg[n++] = NET_OP_HEARTBEAT; + msg[n++] = pub->ttl; + l_put_be16(net->features, msg + n); + n += 2; + + mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), + pub->ttl, 0, 0, pub->dst, msg, n); } static void trigger_heartbeat(struct mesh_net *net, uint16_t feature, - bool in_use) + bool enable) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - - l_debug("%s: %4.4x --> %d", __func__, feature, in_use); + l_debug("HB: %4.4x --> %d", feature, enable); - if (in_use) { - if (net->heartbeat.features & feature) + if (enable) { + if (net->features & feature) return; /* no change */ - hb->features |= feature; + net->features |= feature; } else { - if (!(hb->features & feature)) + if (!(net->features & feature)) return; /* no change */ - hb->features &= ~feature; + net->features &= ~feature; } - if (!(hb->pub_features & feature)) - return; /* not interested in this feature */ - - l_idle_oneshot(idle_mesh_heartbeat_send, net, NULL); + if (!(net->hb_pub.features & feature)) + return; /* no interest in this feature */ + l_idle_oneshot(send_hb_publication, net, NULL); } static bool match_by_friend(const void *a, const void *b) @@ -616,8 +632,6 @@ struct mesh_net *mesh_net_new(struct mesh_node *node) net->destinations = l_queue_new(); net->app_keys = l_queue_new(); - memset(&net->heartbeat, 0, sizeof(net->heartbeat)); - if (!nets) nets = l_queue_new(); @@ -813,8 +827,8 @@ int mesh_net_del_key(struct mesh_net *net, uint16_t idx) appkey_delete_bound_keys(net, idx); /* Disable hearbeat publication on this subnet */ - if (idx == net->heartbeat.pub_net_idx) - net->heartbeat.pub_dst = UNASSIGNED_ADDRESS; + if (idx == net->hb_pub.net_idx) + net->hb_pub.dst = UNASSIGNED_ADDRESS; /* TODO: cancel beacon_enable on this subnet */ @@ -2017,25 +2031,23 @@ static bool ctl_received(struct mesh_net *net, uint16_t key_id, break; case NET_OP_HEARTBEAT: - if (net->heartbeat.sub_enabled && - src == net->heartbeat.sub_src) { + if (net->hb_sub.enabled && src == net->hb_sub.src) { uint8_t hops = pkt[0] - ttl + 1; print_packet("Rx-NET_OP_HEARTBEAT", pkt, len); - if (net->heartbeat.sub_count != 0xffff) - net->heartbeat.sub_count++; + if (net->hb_sub.count != 0xffff) + net->hb_sub.count++; - if (net->heartbeat.sub_min_hops > hops) - net->heartbeat.sub_min_hops = hops; + if (net->hb_sub.min_hops > hops) + net->hb_sub.min_hops = hops; - if (net->heartbeat.sub_max_hops < hops) - net->heartbeat.sub_max_hops = hops; + if (net->hb_sub.max_hops < hops) + net->hb_sub.max_hops = hops; l_debug("HB: cnt:%4.4x min:%2.2x max:%2.2x", - net->heartbeat.sub_count, - net->heartbeat.sub_min_hops, - net->heartbeat.sub_max_hops); + net->hb_sub.count, net->hb_sub.min_hops, + net->hb_sub.max_hops); } break; } @@ -3259,52 +3271,14 @@ int mesh_net_update_key(struct mesh_net *net, uint16_t idx, return MESH_STATUS_SUCCESS; } -static uint16_t get_features(struct mesh_net *net) -{ - uint16_t features = 0; - - if (net->relay.enable) - features |= FEATURE_RELAY; - - if (net->proxy_enable) - features |= FEATURE_PROXY; - - if (net->friend_enable) - features |= FEATURE_FRIEND; - - return features; -} - -struct mesh_net_heartbeat *mesh_net_heartbeat_get(struct mesh_net *net) -{ - return &net->heartbeat; -} - -void mesh_net_heartbeat_send(struct mesh_net *net) +struct mesh_net_heartbeat_sub *mesh_net_get_heartbeat_sub(struct mesh_net *net) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - uint8_t msg[4]; - int n = 0; - - if (hb->pub_dst == UNASSIGNED_ADDRESS) - return; - - msg[n++] = NET_OP_HEARTBEAT; - msg[n++] = hb->pub_ttl; - l_put_be16(hb->features, msg + n); - n += 2; - - mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), - hb->pub_ttl, 0, 0, hb->pub_dst, msg, n); + return &net->hb_sub; } -void mesh_net_heartbeat_init(struct mesh_net *net) +struct mesh_net_heartbeat_pub *mesh_net_get_heartbeat_pub(struct mesh_net *net) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - - memset(hb, 0, sizeof(struct mesh_net_heartbeat)); - hb->sub_min_hops = 0xff; - hb->features = get_features(net); + return &net->hb_pub; } void mesh_net_set_iv_index(struct mesh_net *net, uint32_t index, bool update) @@ -3542,3 +3516,156 @@ void net_msg_add_replay_cache(struct mesh_net *net, uint16_t src, uint32_t seq, /* Optimize so that most recent conversations stay earliest in cache */ l_queue_push_head(net->replay_cache, rpe); } + +static void hb_sub_timeout_func(struct l_timeout *timeout, void *user_data) +{ + struct mesh_net *net = user_data; + struct mesh_net_heartbeat_sub *sub = &net->hb_sub; + + l_debug("HB Subscription Ended"); + l_timeout_remove(sub->timer); + sub->timer = NULL; + sub->enabled = false; +} + +static uint32_t log_to_uint32(uint8_t log) +{ + if (!log) + return 0x0000; + + return (1 << (log - 1)); +} + +int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, + uint8_t period_log) +{ + struct mesh_net_heartbeat_sub *sub = &net->hb_sub; + struct timeval time_now; + + if (!net) + return MESH_STATUS_UNSPECIFIED_ERROR; + + /* Check if the subscription should be disabled */ + if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst)) { + if (IS_GROUP(sub->dst)) + mesh_net_dst_unreg(net, sub->dst); + + sub->enabled = false; + sub->dst = UNASSIGNED_ADDRESS; + sub->src = UNASSIGNED_ADDRESS; + sub->count = 0; + sub->period = 0; + sub->min_hops = 0; + sub->max_hops = 0; + + } else if (!period_log && src == sub->src && dst == sub->dst) { + /* Preserve collected data, but disable */ + sub->enabled = false; + sub->period = 0; + + } else if (sub->dst != dst) { + if (IS_GROUP(sub->dst)) + mesh_net_dst_unreg(net, sub->dst); + + if (IS_GROUP(dst)) + mesh_net_dst_reg(net, dst); + + sub->enabled = !!period_log; + sub->src = src; + sub->dst = dst; + sub->count = 0; + sub->period = log_to_uint32(period_log); + sub->min_hops = 0x00; + sub->max_hops = 0x00; + gettimeofday(&time_now, NULL); + sub->start = time_now.tv_sec; + } + + /* TODO: Save to node config */ + + if (!sub->enabled) { + l_timeout_remove(sub->timer); + sub->timer = NULL; + return MESH_STATUS_SUCCESS; + } + + sub->min_hops = 0xff; + + if (!sub->timer) + sub->timer = l_timeout_create(sub->period, hb_sub_timeout_func, + net, NULL); + else + l_timeout_modify(sub->timer, sub->period); + + return MESH_STATUS_SUCCESS; +} + +static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) +{ + struct mesh_net *net = user_data; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + + send_hb_publication(net); + + if (pub->count != 0xffff) + pub->count--; + + if (pub->count > 0) + l_timeout_modify(pub->timer, pub->period); + else { + l_timeout_remove(pub->timer); + pub->timer = NULL; + } +} + +static void update_hb_pub_timer(struct mesh_net *net, + struct mesh_net_heartbeat_pub *pub) +{ + if (IS_UNASSIGNED(pub->dst) || pub->count == 0) { + l_timeout_remove(pub->timer); + pub->timer = NULL; + return; + } + + if (!pub->timer) + pub->timer = l_timeout_create(pub->period, + hb_pub_timeout_func, net, NULL); + else + l_timeout_modify(pub->timer, pub->period); +} + +int mesh_net_set_heartbeat_pub(struct mesh_net *net, uint16_t dst, + uint16_t features, uint16_t idx, uint8_t ttl, + uint8_t count_log, uint8_t period_log) +{ + struct mesh_subnet *subnet; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + + if (!net) + return MESH_STATUS_UNSPECIFIED_ERROR; + + subnet = l_queue_find(net->subnets, match_key_index, + L_UINT_TO_PTR(idx)); + if (!subnet) + return MESH_STATUS_INVALID_NETKEY; + + pub->dst = dst; + + if (pub->dst == UNASSIGNED_ADDRESS) { + pub->count = 0; + pub->period = 0; + pub->ttl = 0; + } else { + pub->count = (count_log != 0xff) ? + log_to_uint32(count_log) : 0xffff; + pub->period = log_to_uint32(period_log); + } + + pub->ttl = ttl; + pub->features = features; + pub->net_idx = idx; + update_hb_pub_timer(net, pub); + + /* TODO: Save to node config */ + return MESH_STATUS_SUCCESS; +} diff --git a/mesh/net.h b/mesh/net.h index 3d374280f..91e07ef78 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -129,25 +129,27 @@ struct mesh_net_prov_caps { uint16_t input_action; } __packed; -struct mesh_net_heartbeat { - struct l_timeout *pub_timer; - struct l_timeout *sub_timer; - struct timeval sub_time; - bool sub_enabled; - uint32_t pub_period; - uint32_t sub_period; - uint32_t sub_start; - uint16_t pub_dst; - uint16_t pub_count; - uint16_t pub_features; +struct mesh_net_heartbeat_sub { + struct l_timeout *timer; + uint32_t start; + uint32_t period; uint16_t features; - uint16_t pub_net_idx; - uint16_t sub_src; - uint16_t sub_dst; - uint16_t sub_count; - uint8_t pub_ttl; - uint8_t sub_min_hops; - uint8_t sub_max_hops; + uint16_t src; + uint16_t dst; + uint16_t count; + bool enabled; + uint8_t min_hops; + uint8_t max_hops; +}; + +struct mesh_net_heartbeat_pub { + struct l_timeout *timer; + uint32_t period; + uint16_t dst; + uint16_t count; + uint16_t features; + uint16_t net_idx; + uint8_t ttl; }; struct mesh_key_set { @@ -328,9 +330,13 @@ void mesh_net_send_seg(struct mesh_net *net, uint32_t key_id, uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t src, uint16_t dst, uint32_t hdr, const void *seg, uint16_t seg_len); -struct mesh_net_heartbeat *mesh_net_heartbeat_get(struct mesh_net *net); -void mesh_net_heartbeat_init(struct mesh_net *net); -void mesh_net_heartbeat_send(struct mesh_net *net); +struct mesh_net_heartbeat_sub *mesh_net_get_heartbeat_sub(struct mesh_net *net); +int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, + uint8_t period_log); +struct mesh_net_heartbeat_pub *mesh_net_get_heartbeat_pub(struct mesh_net *net); +int mesh_net_set_heartbeat_pub(struct mesh_net *net, uint16_t dst, + uint16_t features, uint16_t idx, uint8_t ttl, + uint8_t count_log, uint8_t period_log); bool mesh_net_key_list_get(struct mesh_net *net, uint8_t *buf, uint16_t *count); uint16_t mesh_net_get_primary_idx(struct mesh_net *net); uint32_t mesh_net_friend_timeout(struct mesh_net *net, uint16_t addr); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iJezHYkGK1/IZAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 21:20:41 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 4LfTG4kGK1/wegEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 21:20:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9C026420BE; Wed, 5 Aug 2020 21:20:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728507AbgHETUQ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 15:20:16 -0400 Received: from mga05.intel.com ([192.55.52.43]:42213 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728959AbgHERsm (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 13:48:42 -0400 IronPort-SDR: M4ofSXJ3SM3mNWO9lfkMD6WQqkUlsypVWtK2eNPbIuyxP2v5Tk+GFD0SuMz0i7v+evZlQoc7vr lAYjmMvqdB+A== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470599" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470599" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:44:57 -0700 IronPort-SDR: +yHScxxKYp1319fLV3oiV2j8kplv4RaoZ7+LNK5nJe7NgB3RpWacCe87zoGaTwcl7jQBMv6vqA PKec3VjAAaAg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245692" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:44:56 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v4 00/10] Mesh Config Server clean up Date: Wed, 5 Aug 2020 10:44:46 -0700 Message-Id: <20200805174456.49342-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 18 X-Rspamd-Score: 2.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9C026420BE X-Rspamd-UID: 4813cf v4 - Further fixes in handling Key Refresh Phase Set message ******************* v3 - address Brian's comments ******************* This patch set groups functionality by config messages. Also, fixes the cases where malformed messages should be silently ignored and the situations when incorrect error status is sent in response. Inga Stotland (10): mesh: Clean up handling of config subscription messages mesh: Clean up handling of config model binding messages mesh: Clean up handling of config node identity message mesh: Clean up handling of config publication messages mesh: Clean up handling of config net and app key messages mesh: Clean up handling of config relay messages mesh: Clean up handling of config poll timeout message mesh: Clean up handling of config net transmit messages mesh: Clean up handling of config KR phase messages mesh: Refactor heartbeat pub/sub mesh/cfgmod-server.c | 1196 +++++++++++++++++---------------------- mesh/cfgmod.h | 2 +- mesh/mesh-config-json.c | 12 +- mesh/mesh-config.h | 6 +- mesh/mesh-defs.h | 3 + mesh/model.c | 234 ++++---- mesh/model.h | 21 +- mesh/net.c | 326 +++++++---- mesh/net.h | 54 +- mesh/node.h | 4 - 10 files changed, 912 insertions(+), 946 deletions(-) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wFJQLpcGK1/IZAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 21:20:55 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id eAZBLJcGK1/AegEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 21:20:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AB440420C3; Wed, 5 Aug 2020 21:20:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728586AbgHETUa (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 15:20:30 -0400 Received: from mga05.intel.com ([192.55.52.43]:42218 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729011AbgHERsd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 13:48:33 -0400 IronPort-SDR: Q5E0MYTINo4cbxVY4MCN83I4ln99/V5qPyP+lbfb5C4cIjZhsnkd1JBv0SUqPQ0DToxuIq31cB +HLEt8HcJPKw== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470672" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470672" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:45:02 -0700 IronPort-SDR: +MZaZ9ic0ukh830t1xE74snLMpFxy5pkt+TGb5EArAMw8zgeONk+hPcjaLTrMLRThC4QhdXhce liTCv5OH0y2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245790" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:45:02 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v4 09/10] mesh: Clean up handling of config KR phase messages Date: Wed, 5 Aug 2020 10:44:55 -0700 Message-Id: <20200805174456.49342-10-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805174456.49342-1-inga.stotland@intel.com> References: <20200805174456.49342-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: AB440420C3 X-Rspamd-UID: 6eb0c0 This modification allows using a single point for sending out the composed status messages by the Config Server. Also, this checks for the correct relationship between KR transition and KR phase values. Correct error codes are sent on unsuccessful requests and malformed requests are ignored. --- mesh/cfgmod-server.c | 68 +++++++++++++++++++++++++++----------------- mesh/mesh-defs.h | 3 ++ mesh/net.c | 53 ++++++++++++---------------------- mesh/net.h | 4 +-- 4 files changed, 65 insertions(+), 63 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 5b3ed3d97..98c04dde7 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -420,6 +420,43 @@ static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt, return n; } +static uint16_t cfg_key_refresh_phase(struct mesh_node *node, + const uint8_t *pkt, int opcode) +{ + struct mesh_net *net = node_get_net(node); + uint16_t n, idx = l_get_le16(pkt); + uint8_t phase; + int status; + + n = mesh_model_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_STATUS, msg); + status = mesh_net_key_refresh_phase_get(net, idx, &phase); + + if (status == MESH_STATUS_SUCCESS && + opcode == OP_CONFIG_KEY_REFRESH_PHASE_SET) { + + if (pkt[2] == KEY_REFRESH_TRANS_TWO) { + if (phase == KEY_REFRESH_PHASE_TWO) + goto done; + else if (phase != KEY_REFRESH_PHASE_ONE) + return 0; + } + + status = mesh_net_key_refresh_phase_set(net, idx, pkt[2]); + l_debug("Set KR Phase: net=%3.3x transition=%d", idx, pkt[2]); + + if (status == MESH_STATUS_SUCCESS) + mesh_net_key_refresh_phase_get(net, idx, &phase); + } + +done: + msg[n] = status; + l_put_le16(idx, msg + n); + msg[n + 2] = (status != MESH_STATUS_SUCCESS) ? + KEY_REFRESH_PHASE_NONE : phase; + + return n + 3; +} + static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; @@ -718,8 +755,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; uint16_t n_idx; - uint8_t state, status; - uint8_t phase; + uint8_t state; bool virt = false; uint16_t n; @@ -926,37 +962,17 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_KEY_REFRESH_PHASE_SET: - if (size != 3 || pkt[2] > 0x03) + if (size != 3 || (pkt[2] != KEY_REFRESH_TRANS_THREE && + pkt[2] != KEY_REFRESH_TRANS_TWO)) return true; - b_res = mesh_net_key_refresh_phase_set(net, l_get_le16(pkt), - pkt[2]); - size = 2; /* Fall Through */ case OP_CONFIG_KEY_REFRESH_PHASE_GET: - if (size != 2) + if (size != 2 && opcode == OP_CONFIG_KEY_REFRESH_PHASE_GET) return true; - n_idx = l_get_le16(pkt); - - n = mesh_model_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_STATUS, - msg); - - /* State: 0x00-0x03 phase of key refresh */ - status = mesh_net_key_refresh_phase_get(net, n_idx, - &phase); - if (status != MESH_STATUS_SUCCESS) { - b_res = status; - phase = KEY_REFRESH_PHASE_NONE; - } - - msg[n++] = b_res; - l_put_le16(n_idx, msg + n); - n += 2; - msg[n++] = phase; - - l_debug("Get/Set Key Refresh State (%d)", msg[n-1]); + n = cfg_key_refresh_phase(node, pkt, opcode); break; case OP_APPKEY_ADD: diff --git a/mesh/mesh-defs.h b/mesh/mesh-defs.h index bbde53303..6ceeb73f5 100644 --- a/mesh/mesh-defs.h +++ b/mesh/mesh-defs.h @@ -36,6 +36,9 @@ #define KEY_REFRESH_PHASE_TWO 0x02 #define KEY_REFRESH_PHASE_THREE 0x03 +#define KEY_REFRESH_TRANS_TWO 0x02 +#define KEY_REFRESH_TRANS_THREE 0x03 + #define DEFAULT_TTL 0xff #define TTL_MASK 0x7f diff --git a/mesh/net.c b/mesh/net.c index b54c647cb..9b4454fee 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -2433,6 +2433,10 @@ static int key_refresh_phase_two(struct mesh_net *net, uint16_t idx) return MESH_STATUS_INVALID_NETKEY; l_debug("Key refresh procedure phase 2: start using new net TX keys"); + + if (subnet->kr_phase == KEY_REFRESH_PHASE_TWO) + return MESH_STATUS_SUCCESS; + subnet->key_refresh = 1; subnet->net_key_tx = subnet->net_key_upd; /* @@ -2445,8 +2449,9 @@ static int key_refresh_phase_two(struct mesh_net *net, uint16_t idx) l_queue_foreach(net->friends, frnd_kr_phase2, net); - mesh_config_net_key_set_phase(node_config_get(net->node), idx, - KEY_REFRESH_PHASE_TWO); + if (!mesh_config_net_key_set_phase(node_config_get(net->node), idx, + KEY_REFRESH_PHASE_TWO)) + return MESH_STATUS_STORAGE_FAIL; return MESH_STATUS_SUCCESS; } @@ -2479,8 +2484,9 @@ static int key_refresh_finish(struct mesh_net *net, uint16_t idx) l_queue_foreach(net->friends, frnd_kr_phase3, net); - mesh_config_net_key_set_phase(node_config_get(net->node), idx, - KEY_REFRESH_PHASE_NONE); + if (!mesh_config_net_key_set_phase(node_config_get(net->node), idx, + KEY_REFRESH_PHASE_NONE)) + return MESH_STATUS_STORAGE_FAIL; return MESH_STATUS_SUCCESS; } @@ -3168,45 +3174,22 @@ void mesh_net_transport_send(struct mesh_net *net, uint32_t key_id, send_msg_pkt(net, pkt, pkt_len + 1); } -uint8_t mesh_net_key_refresh_phase_set(struct mesh_net *net, uint16_t idx, +int mesh_net_key_refresh_phase_set(struct mesh_net *net, uint16_t idx, uint8_t transition) { - struct mesh_subnet *subnet; - - if (!net) - return MESH_STATUS_UNSPECIFIED_ERROR; - - subnet = l_queue_find(net->subnets, match_key_index, - L_UINT_TO_PTR(idx)); - if (!subnet) - return MESH_STATUS_INVALID_NETKEY; - - if (transition == subnet->kr_phase) - return MESH_STATUS_SUCCESS; + switch (transition) { + case KEY_REFRESH_TRANS_TWO: + return key_refresh_phase_two(net, idx); - if ((transition != 2 && transition != 3) || - transition < subnet->kr_phase) - return MESH_STATUS_CANNOT_SET; + case KEY_REFRESH_TRANS_THREE: + return key_refresh_finish(net, idx); - switch (transition) { - case 2: - if (key_refresh_phase_two(net, idx) - != MESH_STATUS_SUCCESS) - return MESH_STATUS_CANNOT_SET; - break; - case 3: - if (key_refresh_finish(net, idx) - != MESH_STATUS_SUCCESS) - return MESH_STATUS_CANNOT_SET; - break; default: - return MESH_STATUS_CANNOT_SET; + return MESH_STATUS_UNSPECIFIED_ERROR; } - - return MESH_STATUS_SUCCESS; } -uint8_t mesh_net_key_refresh_phase_get(struct mesh_net *net, uint16_t idx, +int mesh_net_key_refresh_phase_get(struct mesh_net *net, uint16_t idx, uint8_t *phase) { struct mesh_subnet *subnet; diff --git a/mesh/net.h b/mesh/net.h index 2673b895a..3d374280f 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -320,9 +320,9 @@ void mesh_friend_sub_add(struct mesh_net *net, uint16_t lpn, uint8_t ele_cnt, const uint8_t *list); void mesh_friend_sub_del(struct mesh_net *net, uint16_t lpn, uint8_t cnt, const uint8_t *del_list); -uint8_t mesh_net_key_refresh_phase_set(struct mesh_net *net, uint16_t net_idx, +int mesh_net_key_refresh_phase_set(struct mesh_net *net, uint16_t net_idx, uint8_t transition); -uint8_t mesh_net_key_refresh_phase_get(struct mesh_net *net, uint16_t net_idx, +int mesh_net_key_refresh_phase_get(struct mesh_net *net, uint16_t net_idx, uint8_t *phase); void mesh_net_send_seg(struct mesh_net *net, uint32_t key_id, uint32_t iv_index, uint8_t ttl, uint32_t seq, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gBVhLLsGK1/IZAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 21:21:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id uL5yKrsGK19MUwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 21:21:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CF43B420D1; Wed, 5 Aug 2020 21:21:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728888AbgHETUn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 15:20:43 -0400 Received: from mga05.intel.com ([192.55.52.43]:42213 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728987AbgHERr2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 13:47:28 -0400 IronPort-SDR: CCSYNJadoEpWMG6Wxyr0at1auLtruYX53uY15jy2z5e07XzfjJjDq2LrxxZPFfhFQLPpTUO/qz vWUlAdf4R0zQ== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470653" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470653" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:45:00 -0700 IronPort-SDR: WAsY6ol6J9SOdoFWzuZuf7GiSCm9tY9IgAZRGXHmIpHOroj7tY+EFqomV7semR9+C2f8rJalrg TFWjSQD3W62Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245747" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:45:00 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v4 06/10] mesh: Clean up handling of config relay messages Date: Wed, 5 Aug 2020 10:44:52 -0700 Message-Id: <20200805174456.49342-7-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805174456.49342-1-inga.stotland@intel.com> References: <20200805174456.49342-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: CF43B420D1 X-Rspamd-UID: 5c4793 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 030f9e744..6ca1c1dd1 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -396,6 +396,30 @@ static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt, return n; } +static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t count; + uint16_t interval; + uint16_t n; + + if (pkt[0] > 0x01) + return 0; + + if (opcode == OP_CONFIG_RELAY_SET) { + count = (pkt[1] & 0x7) + 1; + interval = ((pkt[1] >> 3) + 1) * 10; + node_relay_mode_set(node, !!pkt[0], count, interval); + } + + n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); + + msg[n++] = node_relay_mode_get(node, &count, &interval); + msg[n++] = (count - 1) + ((interval/10 - 1) << 3); + + return n; +} + static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; @@ -765,24 +789,14 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_RELAY_SET: - if (size != 2 || pkt[0] > 0x01) + if (size != 2) return true; - - count = (pkt[1] & 0x7) + 1; - interval = ((pkt[1] >> 3) + 1) * 10; - node_relay_mode_set(node, !!pkt[0], count, interval); /* Fall Through */ - case OP_CONFIG_RELAY_GET: if (opcode == OP_CONFIG_RELAY_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); - - msg[n++] = node_relay_mode_get(node, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Relay Config (%d)", msg[n-1]); + n = cfg_relay_msg(node, pkt, opcode); break; case OP_CONFIG_NETWORK_TRANSMIT_SET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oEtJB8EGK1/IZAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 21:21:37 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IJ26BcEGK192wwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 21:21:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D173B420BE; Wed, 5 Aug 2020 21:21:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728868AbgHETUn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 15:20:43 -0400 Received: from mga05.intel.com ([192.55.52.43]:42221 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728989AbgHERrb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 13:47:31 -0400 IronPort-SDR: vb2gEmlZG6KKkEMFjhFQjALxpnX5K5lzEwoAumx0lBC4pAnMeXYVCPKXzuf9iu5K45u8PQKLwb LRvVPR6by+6g== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470666" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470666" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:45:01 -0700 IronPort-SDR: HXkJqGMiCRMqe4Diix6MVCo3h0L9bv7IxvbKs9UY7roFHr0VguEKsCFzEWmAk3RbBkGhbD26SK dVIN/9nlsFlQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245771" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:45:01 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v4 08/10] mesh: Clean up handling of config net transmit messages Date: Wed, 5 Aug 2020 10:44:54 -0700 Message-Id: <20200805174456.49342-9-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805174456.49342-1-inga.stotland@intel.com> References: <20200805174456.49342-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: D173B420BE X-Rspamd-UID: a26084 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 9b1375317..5b3ed3d97 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -657,6 +657,28 @@ static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) return n; } +static uint16_t cfg_net_tx_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t cnt; + uint16_t interval, n; + struct mesh_net *net = node_get_net(node); + + cnt = (pkt[0] & 0x7) + 1; + interval = ((pkt[0] >> 3) + 1) * 10; + + if (opcode == OP_CONFIG_NETWORK_TRANSMIT_SET && + mesh_config_write_net_transmit(node_config_get(node), + cnt, interval)) + mesh_net_transmit_params_set(net, cnt, interval); + + n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, msg); + + mesh_net_transmit_params_get(net, &cnt, &interval); + msg[n++] = (cnt - 1) + ((interval/10 - 1) << 3); + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -699,8 +721,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint8_t state, status; uint8_t phase; bool virt = false; - uint8_t count; - uint16_t interval; uint16_t n; if (app_idx != APP_IDX_DEV_LOCAL) @@ -821,25 +841,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_NETWORK_TRANSMIT_SET: if (size != 1) return true; - - count = (pkt[0] & 0x7) + 1; - interval = ((pkt[0] >> 3) + 1) * 10; - - if (mesh_config_write_net_transmit(node_config_get(node), count, - interval)) - mesh_net_transmit_params_set(net, count, interval); /* Fall Through */ case OP_CONFIG_NETWORK_TRANSMIT_GET: if (opcode == OP_CONFIG_NETWORK_TRANSMIT_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, - msg); - mesh_net_transmit_params_get(net, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Network Transmit Config"); + n = cfg_net_tx_msg(node, pkt, opcode); break; case OP_CONFIG_PROXY_SET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GC5JKsgGK1+MewAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 05 Aug 2020 21:21:44 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mPTlKMgGK191UgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 05 Aug 2020 21:21:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AE6B5420D9; Wed, 5 Aug 2020 21:21:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbgHETVT (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 15:21:19 -0400 Received: from mga05.intel.com ([192.55.52.43]:42218 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728988AbgHERr1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 13:47:27 -0400 IronPort-SDR: J9rjp3oVY9xGPmS7hmZjJc8/uqil547rGxBETq+KSm2PT1arymo26ZtDL/kjtHIZuV+kLhvVxb vYGGYC3rworQ== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470658" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470658" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:45:01 -0700 IronPort-SDR: SPTRrvFqEXg3XhXh3+VEu2X5rEqDgzBzydNUNM/cg7j6h0/m7S6HUlOMn64W67Sl18Pw02AkxF KIETEP5Ei3Jg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245758" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:45:00 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v4 07/10] mesh: Clean up handling of config poll timeout message Date: Wed, 5 Aug 2020 10:44:53 -0700 Message-Id: <20200805174456.49342-8-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805174456.49342-1-inga.stotland@intel.com> References: <20200805174456.49342-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: AE6B5420D9 X-Rspamd-UID: 66a552 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 34 +++++++++++++++++++++++----------- mesh/cfgmod.h | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 6ca1c1dd1..9b1375317 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -638,6 +638,25 @@ static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt) return n + 3 + sz; } +static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t n, addr = l_get_le16(pkt); + uint32_t poll_to; + + if (!IS_UNICAST(addr)) + return 0; + + n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); + l_put_le16(addr, msg + n); + n += 2; + + poll_to = mesh_net_friend_timeout(node_get_net(node), addr); + msg[n++] = poll_to; + msg[n++] = poll_to >> 8; + msg[n++] = poll_to >> 16; + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -673,7 +692,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct mesh_net *net; const uint8_t *pkt = data; struct timeval time_now; - uint32_t opcode, tmp32; + uint32_t opcode; int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; uint16_t n_idx; @@ -1109,18 +1128,11 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, msg[n++] = hb->sub_max_hops; break; - case OP_CONFIG_POLL_TIMEOUT_LIST: - if (size != 2 || l_get_le16(pkt) == 0 || - l_get_le16(pkt) > 0x7fff) + case OP_CONFIG_POLL_TIMEOUT_GET: + if (size != 2) return true; - n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; - tmp32 = mesh_net_friend_timeout(net, l_get_le16(pkt)); - msg[n++] = tmp32; - msg[n++] = tmp32 >> 8; - msg[n++] = tmp32 >> 16; + n = cfg_poll_timeout_msg(node, pkt); break; case OP_NODE_RESET: diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 7b6a95807..6d73656a7 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -66,7 +66,7 @@ #define OP_CONFIG_MODEL_SUB_LIST 0x802A #define OP_CONFIG_VEND_MODEL_SUB_GET 0x802B #define OP_CONFIG_VEND_MODEL_SUB_LIST 0x802C -#define OP_CONFIG_POLL_TIMEOUT_LIST 0x802D +#define OP_CONFIG_POLL_TIMEOUT_GET 0x802D #define OP_CONFIG_POLL_TIMEOUT_STATUS 0x802E /* Health opcodes in health-mod.h */ #define OP_CONFIG_HEARTBEAT_PUB_GET 0x8038 -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0BXlEat9K193swAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 06 Aug 2020 05:48:59 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id yM6AEKt9K18qHAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 06 Aug 2020 05:48:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E3EEA40AE5; Thu, 6 Aug 2020 05:48:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727987AbgHFDst (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 5 Aug 2020 23:48:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726026AbgHFDss (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 5 Aug 2020 23:48:48 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C1FEC061574 for <linux-bluetooth@vger.kernel.org>; Wed, 5 Aug 2020 20:48:48 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id p25so3289118qkp.2 for <linux-bluetooth@vger.kernel.org>; Wed, 05 Aug 2020 20:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7+zYpV/8KSJzoPyXral7BRHxWQemzQJ45iKZeuf/8Ic=; b=VpcB5IBtErOIL7CZYsSzoR87GxbT0tfoyOtlxj0pZNzsUxbIybITtM+InDRqXyJEMg gjPEe0aRfQ9dtKsJ4lU9DzpZPxsBBjtj/jqbG9jCkbtTIBcGi0wH0kQY9QazJB734ObQ MVAt8j7GqQkW4oAUXp6H4tsNGO5OL4SjUcS5w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7+zYpV/8KSJzoPyXral7BRHxWQemzQJ45iKZeuf/8Ic=; b=ZuSNQ2t9LnnujwZYR7IuiveVspadO75X5p0XxoiIftZMRFQAluH9H6zAiInSAIlMHe XWGPoKlvWfoKFQdTiXFd/XsUm3GA2HlZEK5+B4XKizza1B5azvxFmnmw8ZQUc7klZtZC IOaLhSU9PoDhXG7yOe3hv6GgBn8u0KVSDHp74Z7XNTjFL8fQ8rtVhXTcUx402GmcsAwb rTkBvQVNvKy8TGOm7J9udBos66NMiBCDSINetuJEaKn0ZirGh5jVTcsF9WEs7m2SplAA aOQJpn67KumOoz6Nzdr7MtVvZRCMFIp0/sDNNA+4xTA5sZgyebfcOTdmpYErMyPh4wDc P1tg== X-Gm-Message-State: AOAM531/bksPYZyaF3ed8H8ummQTGt0u0N0qxtOzMH+82Q2IQj2XIMy5 3dYCj53uCtV5OXWwf9tk+IjGpsUWu5/crsIFANG5qA== X-Google-Smtp-Source: ABdhPJyoSQKE8nHeGlAA4xLPh7nVoXluGFdF6qwbCdq0yPkGBJ443BSldmJkhXxkAgGPV76qYBf6nLoAp8xu6nuz7CM= X-Received: by 2002:a05:620a:144e:: with SMTP id i14mr6343030qkl.453.1596685727081; Wed, 05 Aug 2020 20:48:47 -0700 (PDT) MIME-Version: 1.0 References: <20200729015540.1848987-1-abhishekpandit@chromium.org> <5f20d725.1c69fb81.6d882.1d23@mx.google.com> <CABBYNZJMHCWm9-F3R1vpqcaazcieA=Dp9+fppQzmm+_-hfhzcw@mail.gmail.com> In-Reply-To: <CABBYNZJMHCWm9-F3R1vpqcaazcieA=Dp9+fppQzmm+_-hfhzcw@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Wed, 5 Aug 2020 20:48:34 -0700 Message-ID: <CANFp7mVDnNCFm+sObXMwgAmV=uFAdeam-DM7eNd1rOTKUTf+hQ@mail.gmail.com> Subject: Re: [RFC Bluez PATCH 3/3] adapter: Reconnect audio on controller resume To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: E3EEA40AE5 X-Rspamd-UID: 7c9839 Hi Luiz, On Tue, Aug 4, 2020 at 11:54 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Abhishek, > > On Tue, Jul 28, 2020 at 6:55 PM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > During system suspend, all peer devices are disconnected. On resume, HID > > devices will reconnect but audio devices stay disconnected. As a quality > > of life improvement, keep track of the last audio device disconnected > > during suspend and try to reconnect when the controller resumes from > > suspend. > > > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > --- > > Hey Luiz, > > > > On our internal review, two things stood out in this commit that we > > weren't able to come to a consensus on internally: > > > > * Is it better to use the audio device class or should we compare to the > > A2DP, HFP and HSP uuids? > > * Constructing the dbus message internally before calling dev_connect > > looks a bit weird. I couldn't figure out how to internally trigger > > this function (since it seems to require a msg to respond to on > > success/failure). Any thoughts? > > > > > > src/adapter.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ > > src/device.c | 27 +++++++++++++++++ > > src/device.h | 2 ++ > > src/main.conf | 6 ++++ > > 4 files changed, 117 insertions(+) > > > > diff --git a/src/adapter.c b/src/adapter.c > > index 5e896a9f0..b1073c439 100644 > > --- a/src/adapter.c > > +++ b/src/adapter.c > > @@ -90,6 +90,7 @@ > > #define IDLE_DISCOV_TIMEOUT (5) > > #define TEMP_DEV_TIMEOUT (3 * 60) > > #define BONDING_TIMEOUT (2 * 60) > > +#define RECONNECT_AUDIO_DELAY (5) > > > > #define SCAN_TYPE_BREDR (1 << BDADDR_BREDR) > > #define SCAN_TYPE_LE ((1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM)) > > @@ -269,6 +270,15 @@ struct btd_adapter { > > struct btd_device *connect_le; /* LE device waiting to be connected */ > > sdp_list_t *services; /* Services associated to adapter */ > > > > + /* audio device to reconnect after resuming from suspend */ > > + struct reconnect_audio_info { > > + bdaddr_t addr; > > + uint8_t addr_type; > > + bool reconnect; > > + } reconnect_audio; > > + guint reconnect_audio_timeout; /* timeout for reconnect on resume */ > > + uint32_t reconnect_audio_delay; /* delay reconnect after resume */ > > + > > struct btd_gatt_database *database; > > struct btd_adv_manager *adv_manager; > > > > @@ -6256,6 +6266,7 @@ static void load_config(struct btd_adapter *adapter) > > /* Get discoverable mode */ > > adapter->stored_discoverable = g_key_file_get_boolean(key_file, > > "General", "Discoverable", &gerr); > > + > > if (gerr) { > > adapter->stored_discoverable = false; > > g_error_free(gerr); > > @@ -6271,6 +6282,16 @@ static void load_config(struct btd_adapter *adapter) > > gerr = NULL; > > } > > > > + /* Get audio reconnect delay */ > > + adapter->reconnect_audio_delay = g_key_file_get_integer( > > + key_file, "General", "ReconnectAudioDelay", &gerr); > > + > > + if (gerr) { > > + adapter->reconnect_audio_delay = RECONNECT_AUDIO_DELAY; > > + g_error_free(gerr); > > + gerr = NULL; > > + } > > + > > g_key_file_free(key_file); > > } > > > > @@ -7820,6 +7841,15 @@ static void dev_disconnected(struct btd_adapter *adapter, > > if (device) { > > adapter_remove_connection(adapter, device, addr->type); > > disconnect_notify(device, reason); > > + > > + if (reason == MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND && > > + device_class_is_audio(device)) { > > + adapter->reconnect_audio.reconnect = true; > > + adapter->reconnect_audio.addr_type = > > + btd_device_get_bdaddr_type(device); > > + bacpy(&adapter->reconnect_audio.addr, > > + device_get_address(device)); > > + } > > } > > > > bonding_attempt_complete(adapter, &addr->bdaddr, addr->type, > > @@ -8766,6 +8796,53 @@ static void connected_callback(uint16_t index, uint16_t length, > > eir_data_free(&eir_data); > > } > > > > +static gboolean reconnect_audio_timeout(gpointer user_data) > > +{ > > + struct btd_adapter *adapter = user_data; > > + > > + adapter->reconnect_audio_timeout = 0; > > + > > + if (adapter->reconnect_audio.reconnect) { > > + struct btd_device *dev = btd_adapter_find_device( > > + adapter, &adapter->reconnect_audio.addr, > > + adapter->reconnect_audio.addr_type); > > + > > + adapter->reconnect_audio.reconnect = false; > > + > > + if (!dev || btd_device_is_connected(dev)) > > + return FALSE; > > + > > + device_internal_connect(dev); > > + } > > + > > + return FALSE; > > +} > > + > > +static void controller_resume_callback(uint16_t index, uint16_t length, > > + const void *param, void *user_data) > > +{ > > + const struct mgmt_ev_controller_resume *ev = param; > > + struct btd_adapter *adapter = user_data; > > + > > + if (length < sizeof(*ev)) { > > + btd_error(adapter->dev_id, "Too small device resume event"); > > + return; > > + } > > + > > + DBG("Controller resume with wake event 0x%x", ev->wake_reason); > > + > > + if (adapter->reconnect_audio_timeout > 0) { > > + g_source_remove(adapter->reconnect_audio_timeout); > > + adapter->reconnect_audio_timeout = 0; > > + } > > + > > + if (adapter->reconnect_audio.reconnect) { > > + adapter->reconnect_audio_timeout = > > + g_timeout_add_seconds(adapter->reconnect_audio_delay, > > + reconnect_audio_timeout, adapter); > > + } > > +} > > + > > static void device_blocked_callback(uint16_t index, uint16_t length, > > const void *param, void *user_data) > > { > > @@ -9389,6 +9466,11 @@ static void read_info_complete(uint8_t status, uint16_t length, > > user_passkey_notify_callback, > > adapter, NULL); > > > > + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, > > + adapter->dev_id, > > + controller_resume_callback, > > + adapter, NULL); > > + > > set_dev_class(adapter); > > > > set_name(adapter, btd_adapter_get_name(adapter)); > > diff --git a/src/device.c b/src/device.c > > index bb8e07e8f..8b165ffa4 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -747,6 +747,12 @@ gboolean device_is_trusted(struct btd_device *device) > > return device->trusted; > > } > > > > +bool device_class_is_audio(struct btd_device *device) > > +{ > > + /* Look for major service classes Audio (0x20) + Rendering (0x4) */ > > + return ((device->class >> 16) & 0x24) == 0x24; > > +} > > + > > static gboolean dev_property_get_address(const GDBusPropertyTable *property, > > DBusMessageIter *iter, void *data) > > { > > @@ -6853,6 +6859,27 @@ struct btd_service *btd_device_get_service(struct btd_device *dev, > > return NULL; > > } > > > > +/* Internal function to connect to a device. This fakes the dbus message used to > > + * call the "Connect" api on the device so that the same function can be called > > + * by bluez internally. > > + */ > > +bool device_internal_connect(struct btd_device *dev) > > +{ > > + DBusMessage *msg; > > + > > + if (!device_is_connectable(dev)) > > + return false; > > + > > + msg = dbus_message_new_method_call("org.bluez", > > + device_get_path(dev), > > + DEVICE_INTERFACE, > > + "Connect"); > > + /* Sending the message usually sets serial. Fake it here. */ > > + dbus_message_set_serial(msg, 1); > > + > > + dev_connect(dbus_conn, msg, dev); > > +} > > + > > void btd_device_init(void) > > { > > dbus_conn = btd_get_dbus_connection(); > > diff --git a/src/device.h b/src/device.h > > index 956fec1ae..82f97b5bd 100644 > > --- a/src/device.h > > +++ b/src/device.h > > @@ -98,6 +98,7 @@ bool device_is_connectable(struct btd_device *device); > > bool device_is_paired(struct btd_device *device, uint8_t bdaddr_type); > > bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type); > > gboolean device_is_trusted(struct btd_device *device); > > +bool device_class_is_audio(struct btd_device *device); > > void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type); > > void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type); > > void btd_device_set_temporary(struct btd_device *device, bool temporary); > > @@ -186,6 +187,7 @@ int btd_device_connect_services(struct btd_device *dev, GSList *services); > > uint32_t btd_device_get_current_flags(struct btd_device *dev); > > void btd_device_flags_changed(struct btd_device *dev, uint32_t supported_flags, > > uint32_t current_flags); > > +bool device_internal_connect(struct btd_device *dev); > > > > void btd_device_init(void); > > void btd_device_cleanup(void); > > diff --git a/src/main.conf b/src/main.conf > > index f41203b96..c6bb78a84 100644 > > --- a/src/main.conf > > +++ b/src/main.conf > > @@ -82,6 +82,12 @@ > > # 0 = disable timer, i.e. never keep temporary devices > > #TemporaryTimeout = 30 > > > > +# How long to wait after controller resume before reconnecting to last used > > +# audio device. > > +# The value is in seconds. > > +# Default: 5 > > +#ReconnectAudioDelay = 5 > > + > > [Controller] > > # The following values are used to load default adapter parameters. BlueZ loads > > # the values into the kernel before the adapter is powered if the kernel > > -- > > 2.28.0.rc0.142.g3c755180ce-goog > > Usually connection policy is handled by the policy plugin since there > may be platforms that want implement their own connection policies on > top of bluetoothd so they can just disable the policy plugin, iirc we > do have reconnection policies for unexpected disconnect which should > probably be used in the event a suspend actually trigger a > disconnection see: > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/plugins/policy.c#n761 > > We might need a reason code to indicate to the policy when a > disconnect happens due to suspend logic. I am emitting a new reason code for disconnect (local disconnect due to suspend, 0x5). If this is just passing through the reason from the mgmt event, I can continue using that. Will update this patch to use the policy plugin and send up another revision. Thanks Abhishek > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0B1/Bhk8LF8xxwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 06 Aug 2020 19:21:29 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cKHLBBk8LF9rWwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 06 Aug 2020 19:21:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2D1E9A1200; Thu, 6 Aug 2020 19:21:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730024AbgHFRVL (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 13:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729392AbgHFRVG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 13:21:06 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F660C061574 for <linux-bluetooth@vger.kernel.org>; Thu, 6 Aug 2020 10:21:06 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id 25so19993553oir.0 for <linux-bluetooth@vger.kernel.org>; Thu, 06 Aug 2020 10:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=04JNgWhAmFtVEhtAD5f70k6Irb7jisVHE/QnXDHGPxg=; b=OQaqu+gIUEE67sPgEtfIBEJAe3qwIc/rHH4LuJXPYJWkWgFFW3tVnX8hgrLEGKdnaN 32XJZt62udourTWELHaejTU/ga2yVWrbUlrxZQZPe0Cbp1RKNVFEPXFLy3qP3DezOaM7 76P4rVKFsVrv4KLIEXsyHJntwkIJQMPfvQ7AoQdtoKcpMNiGeMcO5hIHwKEzol840dnz xjcrqKImXhN4ojZQOzSB0fke4IV6Ejym4bDXFbiz6w0Tsgy9+509MXLT+x2gAnBacMJr ITEtoufER3og9pugsdZMy/tJbEqZf1XJVtikJJZVB8J5GzvL9dMHeonalOZy24VbfzNz 1YYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=04JNgWhAmFtVEhtAD5f70k6Irb7jisVHE/QnXDHGPxg=; b=PQavarGP1CM/vXKPJQoMnGocONzv9hhK8C0e1VTu+ptwWEkF+Rw1TKB/bkP0jhkitF gW5AmsJpKe7LFXQ14RoWAQs5foZ5GRQSdLO8+pEbXLVP/iw0uDkNl8mp0pyMlJzTRYP2 MSbtn38rBJz2uV47ndQeIMZcE/x10tJHYXt/IWiQFFD3LFMHECowUZABv4EwywPLcNQn s3nssv5ian/z3jg9RxH+H2TB6THkmhYWLiFWi1ZYKRG/QjVqIRwm696nLapv/WNWVJAT Zy8DIy7Mpj7h11RgYnVXa1xVkPY0ElahBcT3MWp6FU0BuuECnjeK65BzINu2Pl+bFzhr CZTw== X-Gm-Message-State: AOAM533gpHpSyqtceFsjFqUPO7hLJ8Qkjw0PNr/c0ROI24AZRDVXVmzl Y9s+yqm8wC6Iwo8oE2z8WS3ujfhUBd/VBncgzVo= X-Google-Smtp-Source: ABdhPJzAh8p1G+JnMo9mfBvlxcZAUJMMC5vkXkypr6uh+VGlKSkYAZNXMB6TlRjhfI4W6ZwSfcG0lGH+qIVK1v4/2Lg= X-Received: by 2002:aca:f504:: with SMTP id t4mr8158354oih.137.1596734464392; Thu, 06 Aug 2020 10:21:04 -0700 (PDT) MIME-Version: 1.0 References: <20200729015540.1848987-1-abhishekpandit@chromium.org> <5f20d725.1c69fb81.6d882.1d23@mx.google.com> <CABBYNZJMHCWm9-F3R1vpqcaazcieA=Dp9+fppQzmm+_-hfhzcw@mail.gmail.com> <CANFp7mVDnNCFm+sObXMwgAmV=uFAdeam-DM7eNd1rOTKUTf+hQ@mail.gmail.com> In-Reply-To: <CANFp7mVDnNCFm+sObXMwgAmV=uFAdeam-DM7eNd1rOTKUTf+hQ@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 6 Aug 2020 10:20:54 -0700 Message-ID: <CABBYNZKUMnFuJ74CSnWRqF8N08QK9mGjp33B8xVfOyPMdLritA@mail.gmail.com> Subject: Re: [RFC Bluez PATCH 3/3] adapter: Reconnect audio on controller resume To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -5.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2D1E9A1200 X-Rspamd-UID: 6679a1 Hi Abhishek, On Wed, Aug 5, 2020 at 8:48 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Hi Luiz, > > On Tue, Aug 4, 2020 at 11:54 AM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Abhishek, > > > > On Tue, Jul 28, 2020 at 6:55 PM Abhishek Pandit-Subedi > > <abhishekpandit@chromium.org> wrote: > > > > > > During system suspend, all peer devices are disconnected. On resume, HID > > > devices will reconnect but audio devices stay disconnected. As a quality > > > of life improvement, keep track of the last audio device disconnected > > > during suspend and try to reconnect when the controller resumes from > > > suspend. > > > > > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > > --- > > > Hey Luiz, > > > > > > On our internal review, two things stood out in this commit that we > > > weren't able to come to a consensus on internally: > > > > > > * Is it better to use the audio device class or should we compare to the > > > A2DP, HFP and HSP uuids? > > > * Constructing the dbus message internally before calling dev_connect > > > looks a bit weird. I couldn't figure out how to internally trigger > > > this function (since it seems to require a msg to respond to on > > > success/failure). Any thoughts? > > > > > > > > > src/adapter.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ > > > src/device.c | 27 +++++++++++++++++ > > > src/device.h | 2 ++ > > > src/main.conf | 6 ++++ > > > 4 files changed, 117 insertions(+) > > > > > > diff --git a/src/adapter.c b/src/adapter.c > > > index 5e896a9f0..b1073c439 100644 > > > --- a/src/adapter.c > > > +++ b/src/adapter.c > > > @@ -90,6 +90,7 @@ > > > #define IDLE_DISCOV_TIMEOUT (5) > > > #define TEMP_DEV_TIMEOUT (3 * 60) > > > #define BONDING_TIMEOUT (2 * 60) > > > +#define RECONNECT_AUDIO_DELAY (5) > > > > > > #define SCAN_TYPE_BREDR (1 << BDADDR_BREDR) > > > #define SCAN_TYPE_LE ((1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM)) > > > @@ -269,6 +270,15 @@ struct btd_adapter { > > > struct btd_device *connect_le; /* LE device waiting to be connected */ > > > sdp_list_t *services; /* Services associated to adapter */ > > > > > > + /* audio device to reconnect after resuming from suspend */ > > > + struct reconnect_audio_info { > > > + bdaddr_t addr; > > > + uint8_t addr_type; > > > + bool reconnect; > > > + } reconnect_audio; > > > + guint reconnect_audio_timeout; /* timeout for reconnect on resume */ > > > + uint32_t reconnect_audio_delay; /* delay reconnect after resume */ > > > + > > > struct btd_gatt_database *database; > > > struct btd_adv_manager *adv_manager; > > > > > > @@ -6256,6 +6266,7 @@ static void load_config(struct btd_adapter *adapter) > > > /* Get discoverable mode */ > > > adapter->stored_discoverable = g_key_file_get_boolean(key_file, > > > "General", "Discoverable", &gerr); > > > + > > > if (gerr) { > > > adapter->stored_discoverable = false; > > > g_error_free(gerr); > > > @@ -6271,6 +6282,16 @@ static void load_config(struct btd_adapter *adapter) > > > gerr = NULL; > > > } > > > > > > + /* Get audio reconnect delay */ > > > + adapter->reconnect_audio_delay = g_key_file_get_integer( > > > + key_file, "General", "ReconnectAudioDelay", &gerr); > > > + > > > + if (gerr) { > > > + adapter->reconnect_audio_delay = RECONNECT_AUDIO_DELAY; > > > + g_error_free(gerr); > > > + gerr = NULL; > > > + } > > > + > > > g_key_file_free(key_file); > > > } > > > > > > @@ -7820,6 +7841,15 @@ static void dev_disconnected(struct btd_adapter *adapter, > > > if (device) { > > > adapter_remove_connection(adapter, device, addr->type); > > > disconnect_notify(device, reason); > > > + > > > + if (reason == MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND && > > > + device_class_is_audio(device)) { > > > + adapter->reconnect_audio.reconnect = true; > > > + adapter->reconnect_audio.addr_type = > > > + btd_device_get_bdaddr_type(device); > > > + bacpy(&adapter->reconnect_audio.addr, > > > + device_get_address(device)); > > > + } > > > } > > > > > > bonding_attempt_complete(adapter, &addr->bdaddr, addr->type, > > > @@ -8766,6 +8796,53 @@ static void connected_callback(uint16_t index, uint16_t length, > > > eir_data_free(&eir_data); > > > } > > > > > > +static gboolean reconnect_audio_timeout(gpointer user_data) > > > +{ > > > + struct btd_adapter *adapter = user_data; > > > + > > > + adapter->reconnect_audio_timeout = 0; > > > + > > > + if (adapter->reconnect_audio.reconnect) { > > > + struct btd_device *dev = btd_adapter_find_device( > > > + adapter, &adapter->reconnect_audio.addr, > > > + adapter->reconnect_audio.addr_type); > > > + > > > + adapter->reconnect_audio.reconnect = false; > > > + > > > + if (!dev || btd_device_is_connected(dev)) > > > + return FALSE; > > > + > > > + device_internal_connect(dev); > > > + } > > > + > > > + return FALSE; > > > +} > > > + > > > +static void controller_resume_callback(uint16_t index, uint16_t length, > > > + const void *param, void *user_data) > > > +{ > > > + const struct mgmt_ev_controller_resume *ev = param; > > > + struct btd_adapter *adapter = user_data; > > > + > > > + if (length < sizeof(*ev)) { > > > + btd_error(adapter->dev_id, "Too small device resume event"); > > > + return; > > > + } > > > + > > > + DBG("Controller resume with wake event 0x%x", ev->wake_reason); > > > + > > > + if (adapter->reconnect_audio_timeout > 0) { > > > + g_source_remove(adapter->reconnect_audio_timeout); > > > + adapter->reconnect_audio_timeout = 0; > > > + } > > > + > > > + if (adapter->reconnect_audio.reconnect) { > > > + adapter->reconnect_audio_timeout = > > > + g_timeout_add_seconds(adapter->reconnect_audio_delay, > > > + reconnect_audio_timeout, adapter); > > > + } > > > +} > > > + > > > static void device_blocked_callback(uint16_t index, uint16_t length, > > > const void *param, void *user_data) > > > { > > > @@ -9389,6 +9466,11 @@ static void read_info_complete(uint8_t status, uint16_t length, > > > user_passkey_notify_callback, > > > adapter, NULL); > > > > > > + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, > > > + adapter->dev_id, > > > + controller_resume_callback, > > > + adapter, NULL); > > > + > > > set_dev_class(adapter); > > > > > > set_name(adapter, btd_adapter_get_name(adapter)); > > > diff --git a/src/device.c b/src/device.c > > > index bb8e07e8f..8b165ffa4 100644 > > > --- a/src/device.c > > > +++ b/src/device.c > > > @@ -747,6 +747,12 @@ gboolean device_is_trusted(struct btd_device *device) > > > return device->trusted; > > > } > > > > > > +bool device_class_is_audio(struct btd_device *device) > > > +{ > > > + /* Look for major service classes Audio (0x20) + Rendering (0x4) */ > > > + return ((device->class >> 16) & 0x24) == 0x24; > > > +} > > > + > > > static gboolean dev_property_get_address(const GDBusPropertyTable *property, > > > DBusMessageIter *iter, void *data) > > > { > > > @@ -6853,6 +6859,27 @@ struct btd_service *btd_device_get_service(struct btd_device *dev, > > > return NULL; > > > } > > > > > > +/* Internal function to connect to a device. This fakes the dbus message used to > > > + * call the "Connect" api on the device so that the same function can be called > > > + * by bluez internally. > > > + */ > > > +bool device_internal_connect(struct btd_device *dev) > > > +{ > > > + DBusMessage *msg; > > > + > > > + if (!device_is_connectable(dev)) > > > + return false; > > > + > > > + msg = dbus_message_new_method_call("org.bluez", > > > + device_get_path(dev), > > > + DEVICE_INTERFACE, > > > + "Connect"); > > > + /* Sending the message usually sets serial. Fake it here. */ > > > + dbus_message_set_serial(msg, 1); > > > + > > > + dev_connect(dbus_conn, msg, dev); > > > +} > > > + > > > void btd_device_init(void) > > > { > > > dbus_conn = btd_get_dbus_connection(); > > > diff --git a/src/device.h b/src/device.h > > > index 956fec1ae..82f97b5bd 100644 > > > --- a/src/device.h > > > +++ b/src/device.h > > > @@ -98,6 +98,7 @@ bool device_is_connectable(struct btd_device *device); > > > bool device_is_paired(struct btd_device *device, uint8_t bdaddr_type); > > > bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type); > > > gboolean device_is_trusted(struct btd_device *device); > > > +bool device_class_is_audio(struct btd_device *device); > > > void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type); > > > void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type); > > > void btd_device_set_temporary(struct btd_device *device, bool temporary); > > > @@ -186,6 +187,7 @@ int btd_device_connect_services(struct btd_device *dev, GSList *services); > > > uint32_t btd_device_get_current_flags(struct btd_device *dev); > > > void btd_device_flags_changed(struct btd_device *dev, uint32_t supported_flags, > > > uint32_t current_flags); > > > +bool device_internal_connect(struct btd_device *dev); > > > > > > void btd_device_init(void); > > > void btd_device_cleanup(void); > > > diff --git a/src/main.conf b/src/main.conf > > > index f41203b96..c6bb78a84 100644 > > > --- a/src/main.conf > > > +++ b/src/main.conf > > > @@ -82,6 +82,12 @@ > > > # 0 = disable timer, i.e. never keep temporary devices > > > #TemporaryTimeout = 30 > > > > > > +# How long to wait after controller resume before reconnecting to last used > > > +# audio device. > > > +# The value is in seconds. > > > +# Default: 5 > > > +#ReconnectAudioDelay = 5 > > > + > > > [Controller] > > > # The following values are used to load default adapter parameters. BlueZ loads > > > # the values into the kernel before the adapter is powered if the kernel > > > -- > > > 2.28.0.rc0.142.g3c755180ce-goog > > > > Usually connection policy is handled by the policy plugin since there > > may be platforms that want implement their own connection policies on > > top of bluetoothd so they can just disable the policy plugin, iirc we > > do have reconnection policies for unexpected disconnect which should > > probably be used in the event a suspend actually trigger a > > disconnection see: > > > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/plugins/policy.c#n761 > > > > We might need a reason code to indicate to the policy when a > > disconnect happens due to suspend logic. > > I am emitting a new reason code for disconnect (local disconnect due > to suspend, 0x5). If this is just passing through the reason from the > mgmt event, I can continue using that. Yep. > Will update this patch to use the policy plugin and send up another revision. I'd use a switch to catch all reasons that should trigger a reconnection. > Thanks > Abhishek > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iJD5FRY9LF8xxwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 06 Aug 2020 19:25:42 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YOdEFBY9LF8edgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 06 Aug 2020 19:25:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 274E4420EE; Thu, 6 Aug 2020 19:25:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729707AbgHFRYn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 13:24:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729324AbgHFREE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 13:04:04 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E0CC0A8888 for <linux-bluetooth@vger.kernel.org>; Thu, 6 Aug 2020 07:20:11 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id g6so39320131ljn.11 for <linux-bluetooth@vger.kernel.org>; Thu, 06 Aug 2020 07:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VoVb4u7m4wnWBugEVb4iq1vaqN0jNSaxwjcJWhpXkDQ=; b=Pn1hvLMJv+VVZbn9YCH1Tnv6/jjWzDfjWx37dj0hePvs9jVS+N//KjXP/hviL934Sh h7V1ZXJagTRw3tWVtuvpFS8jXZ7PrDPYsQ8N4ez66sMq0RCmybOmF4SZ3LwjSlv6HPK1 iZjSdErtDgQx5m+kPLFFIfrQNzECqoV+9FUorIpvYpmxpCXLoH/nvYgmTabTcTMoia8T Xa8LMax+H0RBKG7Mnc/a7/ykTak2FBk6+sN38IFH0Fp4+a3f9xwJcdu5u/UzLeZ3VaQu 1BvI0iq4vgrRGRR8zZZPA0ICDLeIdLTXACy3wUcbVVa1pavD1rkyVH7H5cotBKA/bK1v iBkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VoVb4u7m4wnWBugEVb4iq1vaqN0jNSaxwjcJWhpXkDQ=; b=NHXAnt+QtNMBz94iO8ZT1BVjtVp5zSIkKqzdw2CB2DzF2TsJqha0fGVDVwqR5frjDI LJfwEy4o8/COzopmrLNasiYx+I9AKEYqKFJ4aIHFPssuIph6vdz35vDYufkbpe+849a7 Pz/vYeUA1MJlH0qXagEMrk1UEGftGzDCko69Bu14qv3jEqru8mHt/7ZMHtvJIEb9jM4E Wdqm/B/4ARFrxUgx0YQbGIt/21WWaahYc+0C+xGjuhWK2rUzDhUsFdBTAPYzAW3jiFfN B1krIG7tzmAxooK5GeL0+CBXkoU9dZWxz3NFRH6CBP+F8Fyt2Ov/+mQDZctA6SaPK6B3 YX4A== X-Gm-Message-State: AOAM532En9SS+VMlbsm0mCGhVK0NHeG+4WGLDT7MSvK4Gs+OlFV+Qjsg Y2XBgRsCb4KRgKTXR97b3DQrABl5AQE= X-Google-Smtp-Source: ABdhPJxu0Q9CI4y4Hmu25Rl2ZQHS5erbTsqX7b5wHGN/QIQ4lAN0ZkzO2T9YcomCN9/KOzxbEIUrmg== X-Received: by 2002:a2e:321a:: with SMTP id y26mr3801125ljy.388.1596723608972; Thu, 06 Aug 2020 07:20:08 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id j144sm2992562lfj.54.2020.08.06.07.20.07 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 07:20:08 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= <michal.lowas-rzechonek@silvair.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] mesh: Allow deleting non-existing net key Date: Thu, 6 Aug 2020 16:21:08 +0200 Message-Id: <20200806142108.32664-1-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 274E4420EE X-Rspamd-UID: 3fee12 When deleting a non-existing key, first check that it doesn't exist (and return success), then verify it's not the last key we have. --- mesh/net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mesh/net.c b/mesh/net.c index 7cc75ce42..b044d7fe0 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -789,15 +789,15 @@ int mesh_net_del_key(struct mesh_net *net, uint16_t idx) if (!net) return MESH_STATUS_UNSPECIFIED_ERROR; - /* Cannot remove primary key */ - if (l_queue_length(net->subnets) <= 1) - return MESH_STATUS_CANNOT_REMOVE; - subnet = l_queue_find(net->subnets, match_key_index, L_UINT_TO_PTR(idx)); if (!subnet) return MESH_STATUS_SUCCESS; + /* Cannot remove primary key */ + if (l_queue_length(net->subnets) <= 1) + return MESH_STATUS_CANNOT_REMOVE; + /* Delete associated app keys */ appkey_delete_bound_keys(net, idx); -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aMccCag9LF8xxwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 06 Aug 2020 19:28:08 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id mG0MB6g9LF9dZwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 06 Aug 2020 19:28:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 51FD1420D3; Thu, 6 Aug 2020 19:28:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730283AbgHFR0E (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 13:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729684AbgHFRCZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 13:02:25 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07C25C0A8885 for <linux-bluetooth@vger.kernel.org>; Thu, 6 Aug 2020 07:12:19 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id b30so26190077lfj.12 for <linux-bluetooth@vger.kernel.org>; Thu, 06 Aug 2020 07:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=wOtQVCByMmS8zx5JVOBX8sDiqkGOFDwGVLmWAyBfyyM=; b=2N0AxslgghBHb0YltaKyY6lgeayRTAdDNJuWzYsJfNblHHseaPieELqxGyfc1E3L1U OFZB9Vo7doQwVZg+edxevNNZGp3zDAKYyhqiVgUbKH9uImmUklkCGMQsZ8UdFIveNw96 62oFVlITf/gYrgUy3LkW1hZZvV5xy0MtLcloy4xwbsHofP8g+uXUYZSb0kjlqasGLeQ7 Xf90RSf3WCBkixHxL/+ncoGfKRVSeikHZ98qqkEC/yJckQpc+GuAJ1ItBVijSiU570U/ v/OB89Ef4OPDRhoGsFBkGybbzmES3TCvZQbcBFvPf2FgzLPlHNe7zpMLxCTBnH/KZ7JI kh6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=wOtQVCByMmS8zx5JVOBX8sDiqkGOFDwGVLmWAyBfyyM=; b=CEFZfRmAOHJVblcwzr02UMsleH6cKWXkgy2tGnqYZqB5Immh+y3awgiVwfJcaJKZwm Biatdpon1MTM6U6FIGwPhS6XORowXfQzwOayzY6OC7hMoAGKxSvNXO4aNKedQS4Ac+VH qQA6NQqr8RWmaEZ83IuYLfQhHRF0ZFha1+7MpWL5CfbEyQFKWxgSPQyp8b88zyIzTfue XB/rBFzHI3wOnXAoI4nWeeG6yAbmlgFWaIZ/LiaaWV2GAM9d2R3GNgG0AHPoRSq7EPe0 PfP8LFJrpqGi2JV5zBOiu0o1nKie2us5QMDegkSjKqANBdi3v4NLbgEVIEuCG9tqE8aD X0Ww== X-Gm-Message-State: AOAM5318HaI5jar2hI4cjVE/zJ21EJq3H0EdBZk9y36FQ5WIyVwZ0u0N XsdJfgvR62M2A/lPfut4Lj+PG0iCRi0= X-Google-Smtp-Source: ABdhPJynn5ckzq8aBaLTIKM7skF7KFvpQ1jr+fTsO8HXyR12QrhnDoOF9/F3w2dQXqFi0p0FGPTwMA== X-Received: by 2002:a19:9149:: with SMTP id y9mr4153141lfj.81.1596723130890; Thu, 06 Aug 2020 07:12:10 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id h6sm2750937lfc.84.2020.08.06.07.12.09 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 07:12:10 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= <michal.lowas-rzechonek@silvair.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] mesh: Allow deleting non-existing app key Date: Thu, 6 Aug 2020 16:13:09 +0200 Message-Id: <20200806141309.26007-1-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 51FD1420D3 X-Rspamd-UID: 4b1861 Mesh Profile v1.0.1, section 4.3.2.40 Config AppKey Status (...) The Status Code shall be Success if the received request was redundant (add of an identical existing key, update of an identical updated key, or delete of a non-existent key), with no further action taken. --- mesh/appkey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh/appkey.c b/mesh/appkey.c index 45d604007..a4771bd7d 100644 --- a/mesh/appkey.c +++ b/mesh/appkey.c @@ -320,7 +320,7 @@ int appkey_key_delete(struct mesh_net *net, uint16_t net_idx, key = l_queue_find(app_keys, match_key_index, L_UINT_TO_PTR(app_idx)); if (!key) - return MESH_STATUS_INVALID_APPKEY; + return MESH_STATUS_SUCCESS; if (key->net_idx != net_idx) return MESH_STATUS_INVALID_NETKEY; -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qPA4CzpELF+UGQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 06 Aug 2020 19:56:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id QCTYCTpELF+5mgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 06 Aug 2020 19:56:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8B833A1035; Thu, 6 Aug 2020 19:56:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbgHFRzr convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 13:55:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:43516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728016AbgHFQSn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 12:18:43 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 208591] connecting to bluetooth Samsung earbuds freezes the system (kubuntu 20.04) with 5.8rc kernels. Hard reset needed. Date: Thu, 06 Aug 2020 11:53:41 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pavel@noa-labs.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-208591-62941-0yKhZHvcF4@https.bugzilla.kernel.org/> In-Reply-To: <bug-208591-62941@https.bugzilla.kernel.org/> References: <bug-208591-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8B833A1035 X-Rspamd-UID: 942a2a https://bugzilla.kernel.org/show_bug.cgi?id=208591 Pavel (pavel@noa-labs.com) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pavel@noa-labs.com --- Comment #6 from Pavel (pavel@noa-labs.com) --- Same with Huawei Maimang 5 Something broke in between 5.7.12, and 5.8-r1 -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6KZ2DqhNLF9lBgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 06 Aug 2020 20:36:24 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2BioDKhNLF+SoQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 06 Aug 2020 20:36:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6FAEA420DD; Thu, 6 Aug 2020 20:36:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728680AbgHFSf5 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 14:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729234AbgHFSfN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 14:35:13 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0670EC06179F for <linux-bluetooth@vger.kernel.org>; Thu, 6 Aug 2020 11:17:16 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id u185so25562269pfu.1 for <linux-bluetooth@vger.kernel.org>; Thu, 06 Aug 2020 11:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=v4tqhlgmt81cyWp6+Y/SY9rGMdsYRprJ694OWSXWLMo=; b=N1wD0R3AOnK+Q8wxwi6DORvnLVCVh6x4akbZdRH3ntsI8qF+pzu97Mn2I2dhvK8r5G EwaRJwU39vn+lWySty/ey+AHPTfcVgTpmDxuaD6nFZ4cNBfOXWLwEE0Cx4ZK/AIGc8+S BNAV9WWVO1W7LO0ZBgPJ5kl8HyYiyFu5y0Sa312XdbdMLkdSBj9OP0mAF+yVReKKp1Xh K7TBORSoO/JMHwSHNj1or/lkTZ5MhUXDdPmGDv7+1gjygTwnA8gI2UC6AotNjpk3vc+T GPWFVVgXsLqrdm7c0qtBxKfPw+BiysVSCtrG7lkIdvoZCEuG2GPZgWEubQsgUtnz7lyN RZkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v4tqhlgmt81cyWp6+Y/SY9rGMdsYRprJ694OWSXWLMo=; b=Zp3lAAuxKYpNod7n7x0WTJkp8xARbEQpbLCpVUg6Z0fLiWh6pmacP9hS0FB72n+NCb V1CJ+MRgztlNSPWPqY5Bx4BBhi3OlSnDNGBIwd+zY7YjxpoAfvTpjmPOoQxiRABO7UkX rrcHB6MbcSVvRQGBA3/eGgTd3u/1ObqMi8R//b+rRLg3PipFZsoR7XGBbXoTzVKhX9RN vAHBbTaC/2nhp5f6vZj9bTiqvc8d11bpBqsgd/USMldufZASfUmtVVricnJEFDtdsdDs W3D475evhP59uwUCvT2c/PYKqWc37hFIq01PsMisT70VM1xgXPBX9nJ6yyS3tWcYU5xt B9cg== X-Gm-Message-State: AOAM532xM71mQiPsZufaJlsRdNuJJ3xREeSlQEcpe34w36GKnCy6uUsv 1jdGqnge+4BEDOgG6ufuMTCHa18a X-Google-Smtp-Source: ABdhPJxhZQK4/QjC5TvcUKEuVGKnFNar2XCWpt2GDQ1UXfltcdLJMZ3F+f409ESGhSomqUs6mMtKoA== X-Received: by 2002:a62:fc08:: with SMTP id e8mr9044462pfh.208.1596737836164; Thu, 06 Aug 2020 11:17:16 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id o16sm10341078pfu.188.2020.08.06.11.17.15 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 11:17:15 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 3/4] Bluetooth: Disable High Speed by default Date: Thu, 6 Aug 2020 11:17:13 -0700 Message-Id: <20200806181714.3216076-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200806181714.3216076-1-luiz.dentz@gmail.com> References: <20200806181714.3216076-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.02 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6FAEA420DD X-Rspamd-UID: 2523e8 From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Bluetooth High Speed requires hardware support which is very uncommon nowadays since HS has not pickup interest by the industry. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> --- net/bluetooth/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index e2497d764e97..64e669acd42f 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -64,7 +64,6 @@ source "net/bluetooth/hidp/Kconfig" config BT_HS bool "Bluetooth High Speed (HS) features" depends on BT_BREDR - default y help Bluetooth High Speed includes support for off-loading Bluetooth connections via 802.11 (wifi) physical layer -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yHPTHeRNLF+UGQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 06 Aug 2020 20:37:24 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MOc/HORNLF/9mAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 06 Aug 2020 20:37:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CB740420C7; Thu, 6 Aug 2020 20:37:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729322AbgHFSgM (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 14:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728445AbgHFSfd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 14:35:33 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19EC5C06179E for <linux-bluetooth@vger.kernel.org>; Thu, 6 Aug 2020 11:17:16 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id 17so5192132pfw.9 for <linux-bluetooth@vger.kernel.org>; Thu, 06 Aug 2020 11:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=pFzx4UzRGdTUTCbe4nHo78+TYdF+MApzZHrO9nCgmQs=; b=qrj/DQ6Rh4AxUN5uxlW5tuZM0KijDFBeZ1Q8MfcQlJdCa8Xw54PWHXRZ3DX/c6tvDR cKcmsW5d5NR9ksF2RCsYn6CbTB1m3mxbNX5Pxqil4SkH0d6xACLetc8AwxVx+fhVib7I PE/Pf068KIim6hidydigZ8NApkcV6PoXTWn/0FbFn2YToxU8Ro1sHnw4EpzhwPU2YjYo v4xWOs7o28IxuF6buCTTuI0ujUWE3Bn+y9QrzO+znZPK5u0MJdvghaYHub94VS/opBPW J1SR6JeIBiToIEgi71i1D6CDUe2P/MkWGj7SfigQlRYZK97xVHm/s+ICWynns4LMPCdm XjpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=pFzx4UzRGdTUTCbe4nHo78+TYdF+MApzZHrO9nCgmQs=; b=cIDZve8eicHIeSmeVZtjKytxuHzc2+jhm2Zxo3D3Lsg8navlIPi5JEHus+1qzuUSAA BZPCrm6fxyw+RtQ6vq3I9gLVu2gkm/NPVQaNNF6plnRodcpDaavErdI28LM4n4f0O1yF Zy8Yg10tl898SN0OLFD5GRmvflWOkYOiZH2ilv4gCytQjpdsc9ztTjmYMcVuqNEO+bx2 uJn71EDTVYXC/U8A38UyZ6OAX1y7YUojo9OGMEVJaunX0d5RT7uRAlp+P8OUTYbi65nh q1r1VZJHjlZDR9KrjsKaxQ3bBY2BOJLCf59pAYtGZ51irBlKFFzDb49mfcbM8S0Xtui7 MqrA== X-Gm-Message-State: AOAM532dRguQAzKJd5SEP2YeZhqEqo+3npJWFKbDA21jfBBXPa/b3U+R gMtbwZixAj6ZxEH7uLtSfw2gVwWc X-Google-Smtp-Source: ABdhPJyaAgbLBEwLqkIwOy0PdsDJpXU79KMZU4vP+LaobVuRyYv7og6oM7Mnfiq5QlQP6b0Wq7yFoQ== X-Received: by 2002:a62:17c1:: with SMTP id 184mr9430654pfx.136.1596737834525; Thu, 06 Aug 2020 11:17:14 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id o16sm10341078pfu.188.2020.08.06.11.17.13 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 11:17:14 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 1/4] Bluetooth: A2MP: Fix not initializing all members Date: Thu, 6 Aug 2020 11:17:11 -0700 Message-Id: <20200806181714.3216076-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: CB740420C7 X-Rspamd-UID: d59103 From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This fixes various places where a stack variable is used uninitialized. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> --- net/bluetooth/a2mp.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c index 26526be579c7..da7fd7c8c2dc 100644 --- a/net/bluetooth/a2mp.c +++ b/net/bluetooth/a2mp.c @@ -226,6 +226,9 @@ static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb, struct a2mp_info_req req; found = true; + + memset(&req, 0, sizeof(req)); + req.id = cl->id; a2mp_send(mgr, A2MP_GETINFO_REQ, __next_ident(mgr), sizeof(req), &req); @@ -305,6 +308,8 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, if (!hdev || hdev->dev_type != HCI_AMP) { struct a2mp_info_rsp rsp; + memset(&rsp, 0, sizeof(rsp)); + rsp.id = req->id; rsp.status = A2MP_STATUS_INVALID_CTRL_ID; @@ -348,6 +353,8 @@ static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb, if (!ctrl) return -ENOMEM; + memset(&req, 0, sizeof(req)); + req.id = rsp->id; a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req), &req); @@ -376,6 +383,8 @@ static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb, struct a2mp_amp_assoc_rsp rsp; rsp.id = req->id; + memset(&rsp, 0, sizeof(rsp)); + if (tmp) { rsp.status = A2MP_STATUS_COLLISION_OCCURED; amp_mgr_put(tmp); @@ -464,7 +473,6 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, struct a2mp_cmd *hdr) { struct a2mp_physlink_req *req = (void *) skb->data; - struct a2mp_physlink_rsp rsp; struct hci_dev *hdev; struct hci_conn *hcon; @@ -475,6 +483,8 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, BT_DBG("local_id %d, remote_id %d", req->local_id, req->remote_id); + memset(&rsp, 0, sizeof(rsp)); + rsp.local_id = req->remote_id; rsp.remote_id = req->local_id; @@ -553,6 +563,8 @@ static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, BT_DBG("local_id %d remote_id %d", req->local_id, req->remote_id); + memset(&rsp, 0, sizeof(rsp)); + rsp.local_id = req->remote_id; rsp.remote_id = req->local_id; rsp.status = A2MP_STATUS_SUCCESS; @@ -675,6 +687,8 @@ static int a2mp_chan_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) if (err) { struct a2mp_cmd_rej rej; + memset(&rej, 0, sizeof(rej)); + rej.reason = cpu_to_le16(0); hdr = (void *) skb->data; @@ -898,6 +912,8 @@ void a2mp_send_getinfo_rsp(struct hci_dev *hdev) BT_DBG("%s mgr %p", hdev->name, mgr); + memset(&rsp, 0, sizeof(rsp)); + rsp.id = hdev->id; rsp.status = A2MP_STATUS_INVALID_CTRL_ID; @@ -995,6 +1011,8 @@ void a2mp_send_create_phy_link_rsp(struct hci_dev *hdev, u8 status) if (!mgr) return; + memset(&rsp, 0, sizeof(rsp)); + hs_hcon = hci_conn_hash_lookup_state(hdev, AMP_LINK, BT_CONNECT); if (!hs_hcon) { rsp.status = A2MP_STATUS_UNABLE_START_LINK_CREATION; @@ -1027,6 +1045,8 @@ void a2mp_discover_amp(struct l2cap_chan *chan) mgr->bredr_chan = chan; + memset(&req, 0, sizeof(req)); + req.mtu = cpu_to_le16(L2CAP_A2MP_DEFAULT_MTU); req.ext_feat = 0; a2mp_send(mgr, A2MP_DISCOVER_REQ, 1, sizeof(req), &req); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8ESGOvVNLF+UGQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 06 Aug 2020 20:37:41 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +CsMOfVNLF8tOgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 06 Aug 2020 20:37:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5BC7D420EB; Thu, 6 Aug 2020 20:37:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729316AbgHFSgL (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 14:36:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728031AbgHFSfZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 14:35:25 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F73C061757 for <linux-bluetooth@vger.kernel.org>; Thu, 6 Aug 2020 11:17:16 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id ep8so7108330pjb.3 for <linux-bluetooth@vger.kernel.org>; Thu, 06 Aug 2020 11:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=a5pUTcsTuja48kdMdKoSv+A/cIC8t1yvGUP8/DdcotE=; b=MMjlIBVWWTQQ3RIngn7E6idE5SPekvRCXvV2xLkYOgLBUFLR61s6w824aVaSrmTeK4 9F6sB/q8sdR6KZySkYJuzbBs+x9bhbRJF9LnPJlM4lyL+Rgr+t400nCUDriLPLD+mDXP gIn/wKHVIZk+7mvDuMTaViwk4zNj5LjssTmKzaOgR2ivVpntjf46rgwGV/6bc0s/xjle 9RP5oGi10oywctt8zz+uuk2Y2j39ANj6rinS6A/ney3On0DUiszg8lCaUWLrkukdmY9J KPU1MG/NRWNAIvCsrC9y2pzntAU6y6Yj1Fd7VKrPxIa5gHaoAWKv5sMPstiPvbVupD5C QQsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a5pUTcsTuja48kdMdKoSv+A/cIC8t1yvGUP8/DdcotE=; b=eRSMSv+c50xpChmb5mYR32q1kaOodLrOkBDdvcyc47ctx1eN8IxILutjV1FL0M3Em9 C53Z7Kqu90nWk4XoiW9+3m/dD/2GGwVYWOKdPGYH5/nsd7KQiRrILMeETI2fbiatpqn/ sqxmTOROpt2Aq6rKooynvjWO9ViES81TjH/4XE/0Zy/IrRnkMgpuWDjR37XsGkBIK7Hz B0+tsbko24XisPuaHrtDfpoOsQgYeRwtNLKDTfaMNaWIGWJ3i7DBTNbu8sXbm4cTcYxo NxhIlmlh5c7iVXbM5fLP3ohCFbbMjE3HrwRgfv5iqATP3Nk/qAgy6pn+yCqQblbSoS1g N7lw== X-Gm-Message-State: AOAM5332DWk1ZYJ7SEHOoREQFftLb3qYYdzVmx3Ie6K6vRjteb1V22Fa pzpsifT+lSiZM3M9Oj0F3UeVfPRq X-Google-Smtp-Source: ABdhPJwxIapyQC4EdrIjwo22RpaSdy2Q0wlWXsZydn7RF+sxTwHcXR3pvSoF37DeGFxFVt1+sfr7tA== X-Received: by 2002:a17:902:8643:: with SMTP id y3mr8974426plt.199.1596737835197; Thu, 06 Aug 2020 11:17:15 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id o16sm10341078pfu.188.2020.08.06.11.17.14 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 11:17:14 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 2/4] Bluetooth: L2CAP: Fix calling sk_filter on non-socket based channel Date: Thu, 6 Aug 2020 11:17:12 -0700 Message-Id: <20200806181714.3216076-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200806181714.3216076-1-luiz.dentz@gmail.com> References: <20200806181714.3216076-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5BC7D420EB X-Rspamd-UID: d54fad From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Only sockets will have the chan->data set to an actual sk, channels like A2MP would have its own data which would likely cause a crash when calling sk_filter, in order to fix this a new callback has been introduced so channels can implement their own filtering if necessary. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> --- include/net/bluetooth/l2cap.h | 2 ++ net/bluetooth/l2cap_core.c | 7 ++++--- net/bluetooth/l2cap_sock.c | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index bc5e9fbc3853..61800a7b6192 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -666,6 +666,8 @@ struct l2cap_ops { struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, unsigned long hdr_len, unsigned long len, int nb); + int (*filter) (struct l2cap_chan * chan, + struct sk_buff *skb); }; struct l2cap_conn { diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index a4458c07b5e5..4a6b5e40e5e4 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -7301,9 +7301,10 @@ static int l2cap_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) goto drop; } - if ((chan->mode == L2CAP_MODE_ERTM || - chan->mode == L2CAP_MODE_STREAMING) && sk_filter(chan->data, skb)) - goto drop; + if (chan->ops->filter) { + if (chan->ops->filter(chan, skb)) + goto drop; + } if (!control->sframe) { int err; diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index e1a3e66b1754..79b4c01c515b 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1663,6 +1663,19 @@ static void l2cap_sock_suspend_cb(struct l2cap_chan *chan) sk->sk_state_change(sk); } +static int l2cap_sock_filter(struct l2cap_chan *chan, struct sk_buff *skb) +{ + struct sock *sk = chan->data; + + switch (chan->mode) { + case L2CAP_MODE_ERTM: + case L2CAP_MODE_STREAMING: + return sk_filter(sk, skb); + } + + return 0; +} + static const struct l2cap_ops l2cap_chan_ops = { .name = "L2CAP Socket Interface", .new_connection = l2cap_sock_new_connection_cb, @@ -1678,6 +1691,7 @@ static const struct l2cap_ops l2cap_chan_ops = { .get_sndtimeo = l2cap_sock_get_sndtimeo_cb, .get_peer_pid = l2cap_sock_get_peer_pid_cb, .alloc_skb = l2cap_sock_alloc_skb_cb, + .filter = l2cap_sock_filter, }; static void l2cap_sock_destruct(struct sock *sk) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SNu3JOlOLF+UGQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 06 Aug 2020 20:41:45 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id mGD4IulOLF+2MAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 06 Aug 2020 20:41:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1C43E420F5; Thu, 6 Aug 2020 20:41:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729979AbgHFSkK (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 14:40:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729981AbgHFSkI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 14:40:08 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEEAFC0617A0 for <linux-bluetooth@vger.kernel.org>; Thu, 6 Aug 2020 11:17:17 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id mt12so7282848pjb.4 for <linux-bluetooth@vger.kernel.org>; Thu, 06 Aug 2020 11:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QrCSGaZo3W622aXcnbTdNOpWK+XU36Ue7MMISwHaE48=; b=OPwELL54m6rtl08l7IuN5lrL+6LgIu2mHgTOEQ4EIHVwQqa6sHGHonzyMenwmqw9vm KEGmy/EaFgX6TCFJqHHr56AAFPx3BZ8gL3Sw9i+DKLe83nBf78d4v86slQUEHxYvyHGB d98VwaS+wbrpG5ICQ3jBP314AmPrmuE0EPlolPcr8gEbDBZD6UM0hVnqS91yjVmsxpTD wV5WFmNgiw7LofDE2HGZ9KV5mrSK+J0luEwhyEWZYl9AE+1WsldZ1OnDIj93mx9R0wYc J6n9Mmy5h2uighwZB8/2npjSm+Bp/vf2epv/SS7rQ88c7GGvWudaqZptnOCLedpwu7nP jiug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QrCSGaZo3W622aXcnbTdNOpWK+XU36Ue7MMISwHaE48=; b=ka2h0T8I/Xvx8cmCmEV9YVAxHEOIWZ9VliotrM0pDmwtAiDWPEwrPEraDP4/ROYGwV HaE8nHOBYBypOrWAd/A14wlLprgC6DBuOZ7Vm0bdEhJgzpUF4n5PJg3coX5a0K9L2YhE cnDOHhT2HxGtmpWepGrnqR6xX+7Z8y1aazEvOtHuvwigOLOjicCtlaoO+nLq1iaxEdto 0L/nUHxJE6cI8hva1Og7mVXQn9mHW3Cusvg6EfOnKSAFsTAB4KZJaJ/iaXIqNyRBtcLZ 4+nmeGrs4goYRjhqSivKstPIzHO4v3E3LEbWsRJdyl/NTQQ5kDLa91pNHGsVFwU8CpbY ming== X-Gm-Message-State: AOAM532okFW73ZDbd3KmaJYYvlC2f05Xaj02mToX9WzWJLDjyKvVSh63 SnPnZSqmb85eU1ydYX/C0douDCqD X-Google-Smtp-Source: ABdhPJxAvHDYOWeibSFHSpMpOG+Juf4MXbo63ZW3bbqWWr40VCY5GaduLbm/v4E3viMH7YoF1HRYqA== X-Received: by 2002:a17:902:7605:: with SMTP id k5mr9226566pll.122.1596737837096; Thu, 06 Aug 2020 11:17:17 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id o16sm10341078pfu.188.2020.08.06.11.17.16 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 11:17:16 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH 4/4] Bluetooth: MGMT: Fix not checking if BT_HS is enabled Date: Thu, 6 Aug 2020 11:17:14 -0700 Message-Id: <20200806181714.3216076-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200806181714.3216076-1-luiz.dentz@gmail.com> References: <20200806181714.3216076-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1C43E420F5 X-Rspamd-UID: ad2f73 From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This checks if BT_HS is enabled relecting it on MGMT_SETTING_HS instead of always reporting it as supported. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> --- net/bluetooth/mgmt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5bbe71002fb9..5758ccb524ef 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -782,7 +782,8 @@ static u32 get_supported_settings(struct hci_dev *hdev) if (lmp_ssp_capable(hdev)) { settings |= MGMT_SETTING_SSP; - settings |= MGMT_SETTING_HS; + if (IS_ENABLED(CONFIG_BT_HS)) + settings |= MGMT_SETTING_HS; } if (lmp_sc_capable(hdev)) @@ -1815,6 +1816,10 @@ static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) bt_dev_dbg(hdev, "sock %p", sk); + if (!IS_ENABLED(CONFIG_BT_HS)) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, + MGMT_STATUS_NOT_SUPPORTED); + status = mgmt_bredr_support(hdev); if (status) return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, status); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cIxaDXaCLF9PXQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 00:21:42 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id APf3C3aCLF+dqQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 00:21:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BBE77420C1; Fri, 7 Aug 2020 00:21:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726212AbgHFWVd (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 18:21:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbgHFWVc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 18:21:32 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54080C061574; Thu, 6 Aug 2020 15:21:32 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id p1so111079pls.4; Thu, 06 Aug 2020 15:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=t1TN4T3jQ2jrlk3a/d7SaKfk2DJyftZUv6bXnlt6NPQ=; b=GyumodkGmYKsGSwVnzxjXGz3Hc6dDp/7EX3r4spkycDyPVNN0ciFP2qEtF0XPhrBf4 +cCI0OWrH6x101NHuYUTOaXPwuCecyhxfEvjJRna72hDnNI+bib+8AzwceW3eJdE75Gn SeIJKEi14my/hEJw+qU/KCE5RSHazXH9KHIfKLNltLm7ADcruE5/tGFOBJjd/g0Mnrl5 TD9+5yjblEpGaVz4M1LHrXLmcdWRpP5c2NV1JaW3i6df06bY03MlPUl3EghFXAFM5iLk Ox9KU5vu5QYQH83zkF+ICm8Q2r+16LLLSd84hY8z6dVmhZCgoIg7vDd5Gd8rg9nvzxvN 9EXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=t1TN4T3jQ2jrlk3a/d7SaKfk2DJyftZUv6bXnlt6NPQ=; b=e1lzyzb0IUfIRzudWXCJ1cnSbrZG3OU8EoVQ0p+kJDkZ1tnLXS6o966fc2KdC6EHeL 3SrIF0a5mXVw76vBuseFHDBVjkkqkjlSiZ4ovEVfQAjHNwieeA9kQTFnWW2rC5ZbPf9O XCVz7HUemkpVnapitCxqsMEN6h+Q28m+bBbKFOppxvOEkVHfUzGS1ldj+fNmo5m0qPl1 ED2axOJ1D3LUxfVoNB0CC1/auI0H9efPJaH6IlviqbYNd5RQTwLOmmWz2ftkLDDCIrhJ Wdyw2sb/kvUexW2wviff3HtcudiqYhWO/eNEvVHcZJMxGZcVkKXQc7LPLka0fe1Ye8m0 FC6w== X-Gm-Message-State: AOAM533QHJUjqnXMz8lHoCE9mfaVnnvTe76eDAuB5RQDhG7tKwWbhiP6 q6J7leABOdw2O3ozloO5s2k= X-Google-Smtp-Source: ABdhPJwdY4ryrXf97t2P6yPCseaEpoaitTdHlZtd60UHAYlnINemi0RFvJHHjsz9ZaSHJyy7n+NjVw== X-Received: by 2002:a17:902:45:: with SMTP id 63mr9766294pla.179.1596752491350; Thu, 06 Aug 2020 15:21:31 -0700 (PDT) Received: from [10.1.10.11] (c-73-241-150-58.hsd1.ca.comcast.net. [73.241.150.58]) by smtp.gmail.com with ESMTPSA id w82sm9912017pff.7.2020.08.06.15.21.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Aug 2020 15:21:30 -0700 (PDT) Subject: Re: [PATCH 25/26] net: pass a sockptr_t into ->setsockopt To: Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com> Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org, Stefan Schmidt <stefan@datenfreihafen.org> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-26-hch@lst.de> From: Eric Dumazet <eric.dumazet@gmail.com> Message-ID: <6357942b-0b6e-1901-7dce-e308c9fac347@gmail.com> Date: Thu, 6 Aug 2020 15:21:25 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200723060908.50081-26-hch@lst.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -3.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: BBE77420C1 X-Rspamd-UID: 8b899f On 7/22/20 11:09 PM, Christoph Hellwig wrote: > Rework the remaining setsockopt code to pass a sockptr_t instead of a > plain user pointer. This removes the last remaining set_fs(KERNEL_DS) > outside of architecture specific code. > > Signed-off-by: Christoph Hellwig <hch@lst.de> > Acked-by: Stefan Schmidt <stefan@datenfreihafen.org> [ieee802154] > --- ... > diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c > index 594e01ad670aa6..874f01cd7aec42 100644 > --- a/net/ipv6/raw.c > +++ b/net/ipv6/raw.c > @@ -972,13 +972,13 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) > } > ... > static int do_rawv6_setsockopt(struct sock *sk, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct raw6_sock *rp = raw6_sk(sk); > int val; > > - if (get_user(val, (int __user *)optval)) > + if (copy_from_sockptr(&val, optval, sizeof(val))) > return -EFAULT; > converting get_user(...) to copy_from_sockptr(...) really assumed the optlen has been validated to be >= sizeof(int) earlier. Which is not always the case, for example here. User application can fool us passing optlen=0, and a user pointer of exactly TASK_SIZE-1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +I9DNJiILF8sdgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 00:47:52 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2JRWMpiILF/txwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 00:47:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0F21D420ED; Fri, 7 Aug 2020 00:47:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726055AbgHFWrr (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 18:47:47 -0400 Received: from mga04.intel.com ([192.55.52.120]:20857 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725927AbgHFWrp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 18:47:45 -0400 IronPort-SDR: SqiMjTx2noN/IV5c0UUeSZrxpbfkhGAkAjXjD+eNpchBFkRLoTlGD/1fVBfPOYgYUUvHUs4j7o 7yM+KnXwgEww== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="150401048" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="150401048" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 15:47:42 -0700 IronPort-SDR: TQFBkSmBcVF2wvdYcwWoHWJmOgaFoofjQS006WLrkcKOTYmNq+aqG4IvJ3bXMwq90a5f4fzFS+ tm6+VML1XcgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="323589050" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by orsmga008.jf.intel.com with ESMTP; 06 Aug 2020 15:47:42 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 6 Aug 2020 15:47:42 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 6 Aug 2020 15:47:42 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.104) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 6 Aug 2020 15:47:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZLotEFGba+r8kRSNxRICcXYTZXyQDKiKhQ3GH5uNl+oVNuoUmTqRBkKolB8n25K4F8vcJQDuNHqhqHxvzODG0pwfQM4fHqkyTlNrsLBPnZeauaF81qIxP+XOr8s79p0+CYqI8rrBU9wY2ircT+ffclMTd27ck7AYkOUsp5rxXjWt8wV7fdnAtwKvdrAQfLftlDvsVO0O0PpBYbvd8BMz24Z5U9kvevWHUtyGKst670aQMqXby81io2YibEe285GIgChblMTQjg8XrN9YV8BOO7ML3IDI6vx6hbY7BDBrQINmrNdo6Yz5ptaVpTF8sCJWqoBfDkJv11aeLee6Y7hx1Q== 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-SenderADCheck; bh=N7XHCkoYhxVn3uqJ55SoGtJ0zb0z2/43XWdbFmOfjAs=; b=dzh4kWwLQ2H0MWugqe5fvOoosHK756W1YhdTapXLk7+zMTTOTobMJCtfp7mdnoWrVXruH5S7K2izSKC4fLHFsd9ilROCx2JFm/hPdbdcVFWBrdCqNv0y/BePko22t8HI8X7pM6QrGAxfofzt3o502MZ+PELInYk82JNXsd8OpeECOd86bhsZI0SUDNFJWmVeqmEKlSMHldHjb4KS65fEsqLkQZ2KoeQV6VcgOp9LXDkeCKEe6rjYYB0KcI9rVGvR8VT6NlmuZD0t32TnaOKIKHRqORXAEnsoEh0EsCZSNnlkvxt4+fun8dUtmwRoem51bpWp9jRH2k3nkwhGncCGzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N7XHCkoYhxVn3uqJ55SoGtJ0zb0z2/43XWdbFmOfjAs=; b=KBtKyELC+X9nNOMLZrSOTEm3HcB7xhkMWCtyQsO18gndqXfMhEajhnLj7bm5NJICPbBOT62Y4IhDuYpMrbWFF2LTRFh/MI0pZuDQ8uD8j7IApuU04tpKRwuNNoWEPTpe6alGN8vIDpQwJlqYoqnlcpjraThS4XBh/dbs5+ydqhw= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1262.namprd11.prod.outlook.com (2603:10b6:300:29::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Thu, 6 Aug 2020 22:47:33 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3261.016; Thu, 6 Aug 2020 22:47:33 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "michal.lowas-rzechonek@silvair.com" <michal.lowas-rzechonek@silvair.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Subject: Re: [PATCH BlueZ] mesh: Allow deleting non-existing net key Thread-Topic: [PATCH BlueZ] mesh: Allow deleting non-existing net key Thread-Index: AQHWbBaJnr+b05JfNUW1TdQDlt2mM6krrvWA Date: Thu, 6 Aug 2020 22:47:33 +0000 Message-ID: <3de6d95d9fb718a23dce907197a646a08a7af6ea.camel@intel.com> References: <20200806142108.32664-1-michal.lowas-rzechonek@silvair.com> In-Reply-To: <20200806142108.32664-1-michal.lowas-rzechonek@silvair.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: silvair.com; dkim=none (message not signed) header.d=none;silvair.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e5acb108-ae6c-4c63-5c63-08d83a5ab565 x-ms-traffictypediagnostic: MWHPR11MB1262: x-microsoft-antispam-prvs: <MWHPR11MB1262F11E788C1176B8911E30E1480@MWHPR11MB1262.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:5797; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Mt7Rkg8ZzIriRLhbmz69ATlmoRJakcOtGMQNN0L60CfgNf4xYEpvwsPM/W9DP+qbna5ZqvlGMlYtqLa2V2PHuIWNujTjGL/Ns7T1TS/dtgm4Yj7yOvVDHXsO83wN1Mswz4gljDZ7BoGKCiQy0Dtj9JfiU6OGJnnArhjPTBQ2YPtI3ia3VXHdteIxecI1lwWM+rUWpu8qGy7jyOjtnsZBLv4ejV/q8WtLcrmhDcMqZpG3OwT/duEhoxB2GPwGkxsOev4p1dM/jYuz88EapK3Flzm+SlNEfYMvPKCQM9tabYHh/WS9yzF3nhQ6/qGnXC/S x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(91956017)(2906002)(66556008)(66476007)(64756008)(66446008)(83380400001)(76116006)(66946007)(8936002)(8676002)(5660300002)(6506007)(2616005)(478600001)(4744005)(110136005)(71200400001)(6512007)(316002)(86362001)(26005)(186003)(36756003)(6486002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: hYFvxhvktSsVyOqJgTA5XP5PCmnmA5nxlQH6cC89Tt7oIpVlLFRq0b30s7L+ZeV2iE9/7We9dfetDAlttHX0uliujE4tYAD8R1T0Ve/7fOj4MJDlgubWgtdGP83BETZ1oqVBYPF2j63AKsiZqWPkWmRPWzjBcywoidiWlMRVhVAo1BnY2S/jUbAS+C6Q33M3TflIOMen5z0gZhkcp4CkbtdbedbYHAGy0aAvGNr6a0hF9+ca1p4AaGWGQ4r0Fmd9juCaax2iZq+zdA8t8toAYphE90LX4rsgwhdNY1kHjYAsnMDRzRvDcN8eWXptBeWLGKiP6mvd5Ym+xMZK6XvYR2Q2x7xvskv4TUsf/mjboZRymTypakS+vKpe+9z9SaG2q8+vqZFh9cNLAPcrfsT20FUo+ZW8L7wbTTA1dWA61RtLRINOIbgql8ieQ0pf9idVboctmEfIj/Xi9Gb7ErYuCTk0GG/VyLMGTd5bzaJHUWkDGiPdjN4Kvg91AqWcex9l+QpP7VY7aW7MJiswGMZVi4haN0ATpZx5Rnltz+7cpPaAZh0Cp0HWx0nXeLLNoj64TevwEOj3EVxX0YieXMDyUzWblryivZgB+x/zuIYiJSJURNz2hmSHriDqZbWHyTnhKDPBkE/gwZKQoLRgfVKOXw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="utf-8" Content-ID: <A067F867F1E09041862370A26A8B6758@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5acb108-ae6c-4c63-5c63-08d83a5ab565 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Aug 2020 22:47:33.6835 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: oFIfAxDdcFgJS7pnoe45fgLuX0ABq+u7Zd6a65xsY+FRA1uHH31pdm8XIvpW+yTePBK6K1GTPLEdg8ug2zVaaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1262 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0F21D420ED X-Rspamd-UID: 909bcf QXBwbGllZA0KT24gVGh1LCAyMDIwLTA4LTA2IGF0IDE2OjIxICswMjAwLCBNaWNoYcWCIExvd2Fz LVJ6ZWNob25layB3cm90ZToNCj4gV2hlbiBkZWxldGluZyBhIG5vbi1leGlzdGluZyBrZXksIGZp cnN0IGNoZWNrIHRoYXQgaXQgZG9lc24ndCBleGlzdCAoYW5kDQo+IHJldHVybiBzdWNjZXNzKSwg dGhlbiB2ZXJpZnkgaXQncyBub3QgdGhlIGxhc3Qga2V5IHdlIGhhdmUuDQo+IC0tLQ0KPiAgbWVz aC9uZXQuYyB8IDggKysrKy0tLS0NCj4gIDEgZmlsZSBjaGFuZ2VkLCA0IGluc2VydGlvbnMoKyks IDQgZGVsZXRpb25zKC0pDQo+IA0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9uZXQuYyBiL21lc2gvbmV0 LmMNCj4gaW5kZXggN2NjNzVjZTQyLi5iMDQ0ZDdmZTAgMTAwNjQ0DQo+IC0tLSBhL21lc2gvbmV0 LmMNCj4gKysrIGIvbWVzaC9uZXQuYw0KPiBAQCAtNzg5LDE1ICs3ODksMTUgQEAgaW50IG1lc2hf bmV0X2RlbF9rZXkoc3RydWN0IG1lc2hfbmV0ICpuZXQsIHVpbnQxNl90IGlkeCkNCj4gIAlpZiAo IW5ldCkNCj4gIAkJcmV0dXJuIE1FU0hfU1RBVFVTX1VOU1BFQ0lGSUVEX0VSUk9SOw0KPiAgDQo+ IC0JLyogQ2Fubm90IHJlbW92ZSBwcmltYXJ5IGtleSAqLw0KPiAtCWlmIChsX3F1ZXVlX2xlbmd0 aChuZXQtPnN1Ym5ldHMpIDw9IDEpDQo+IC0JCXJldHVybiBNRVNIX1NUQVRVU19DQU5OT1RfUkVN T1ZFOw0KPiAtDQo+ICAJc3VibmV0ID0gbF9xdWV1ZV9maW5kKG5ldC0+c3VibmV0cywgbWF0Y2hf a2V5X2luZGV4LA0KPiAgCQkJCQkJCUxfVUlOVF9UT19QVFIoaWR4KSk7DQo+ICAJaWYgKCFzdWJu ZXQpDQo+ICAJCXJldHVybiBNRVNIX1NUQVRVU19TVUNDRVNTOw0KPiAgDQo+ICsJLyogQ2Fubm90 IHJlbW92ZSBwcmltYXJ5IGtleSAqLw0KPiArCWlmIChsX3F1ZXVlX2xlbmd0aChuZXQtPnN1Ym5l dHMpIDw9IDEpDQo+ICsJCXJldHVybiBNRVNIX1NUQVRVU19DQU5OT1RfUkVNT1ZFOw0KPiArDQo+ ICAJLyogRGVsZXRlIGFzc29jaWF0ZWQgYXBwIGtleXMgKi8NCj4gIAlhcHBrZXlfZGVsZXRlX2Jv dW5kX2tleXMobmV0LCBpZHgpOw0KPiAgDQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kA9mIp2ILF8sdgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 00:47:57 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SJacIJ2ILF9r8wAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 00:47:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ECAC9420E0; Fri, 7 Aug 2020 00:47:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726093AbgHFWrs (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 18:47:48 -0400 Received: from mga03.intel.com ([134.134.136.65]:18324 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725927AbgHFWrr (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 18:47:47 -0400 IronPort-SDR: H4VCMe3tKpSslees4lf6CG7ThDk17fpFAR2Ihvo0kptv9R2P/npHn6h0hmg0bRuqvn6X3lJRMi pWQbQ7C76rNg== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="152903557" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="152903557" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 15:47:46 -0700 IronPort-SDR: G4RTzh6oOdnF9I7j85D9RrrR6HMc9QoU7TfAQ1c3czwlUPceGh8LzAs6TL5nu/M/6Q8k6NrOLq qACC4kkdginA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="437705917" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by orsmga004.jf.intel.com with ESMTP; 06 Aug 2020 15:47:46 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 6 Aug 2020 15:47:46 -0700 Received: from orsmsx113.amr.corp.intel.com (10.22.240.9) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 6 Aug 2020 15:47:46 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX113.amr.corp.intel.com (10.22.240.9) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 6 Aug 2020 15:47:46 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 6 Aug 2020 15:47:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FJFK+IE87lbYfc1FcRJgPUpdqXo0gkcZ4ZOLU4tiugINJ30yEUI7WbPrjIu/W1KL/bmwAs0zM+2H4IY+zJOgqN5c9224aGdnFc2uTSTT+Dc9ztYDG2TIgMBjYi/0cc12MFrS5LrLz4yn8kdSN63EuitFVLXtP+eyiz/tU+z5NqLv01F9CqeKqxSkqlmGSt9g2akrzaMcUHhbA93uFqf91mGu9FbO+jwJ+jCs1nSHu2RI5L0gM+tjbFDVeJVuxI2xgz5Y/yrudn/vsTOgeOBd7+n9dWFos4DOZyvbogBHRMfg87Ket+aBKUnG8ScC1K8WithAFmvG46vuL2BEFnHziw== 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-SenderADCheck; bh=M4IjB2IxVo7g0lgxx8sevx5bJFFoRTu4+ckqQK4ueGc=; b=jacJbLm4E3ACil6D/BtXYjtnkdGjsTgI/hu2SbrBYDgkEtARyzu4tBZgScIrmkvKIdyO3G1FvdESyns1GB4+Q2HCH8bD2hlCosEo+e/ES5+d+jkcZaF7/IrOnOTcgg6QCbNWhys15w8WDzwApn+J64oJONNRrCaZfM2+E69IS+LwVP3cw+ukg6GmhPMJKNKOPb/Y8u0jI9TZEDGbHoqX2ni/zprtii/7wMcNGL0L/Rrksd5/oAh61+CelqDJ7vxqjC9SGnOuBdFC2b38DVzcQBLal3DkSzmQ7MKYdkYPHcVEcY+yYef8ll512KZ90mesTfQs/XTVhs1yNcub9QNPAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M4IjB2IxVo7g0lgxx8sevx5bJFFoRTu4+ckqQK4ueGc=; b=A5KvqI/cNc+KeTbcxjej1L6kwR1ac2sOHsP8wU41GByCRsqE3a4R57DCaI77p1K35Sc1KJ1ZZuVORPCcygeQ/uIZakJrCIzOgNJ4GyA0IXVvoMCe+fZFE+8Mx8cq98A2FILKZKDddKzdLjA1eZj7703jX8UFojJLJuBVNM4cpBk= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4763.namprd11.prod.outlook.com (2603:10b6:303:2c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.17; Thu, 6 Aug 2020 22:47:45 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3261.016; Thu, 6 Aug 2020 22:47:45 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "michal.lowas-rzechonek@silvair.com" <michal.lowas-rzechonek@silvair.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Subject: Re: [PATCH BlueZ] mesh: Allow deleting non-existing app key Thread-Topic: [PATCH BlueZ] mesh: Allow deleting non-existing app key Thread-Index: AQHWbBbQz0XSvPCZMUuUqy/znTYKaKkrrwQA Date: Thu, 6 Aug 2020 22:47:45 +0000 Message-ID: <90334f4eedbc5c4f6e2da2c17ab4791d6d32dc7b.camel@intel.com> References: <20200806141309.26007-1-michal.lowas-rzechonek@silvair.com> In-Reply-To: <20200806141309.26007-1-michal.lowas-rzechonek@silvair.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: silvair.com; dkim=none (message not signed) header.d=none;silvair.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7c4bffb6-84c3-4452-3453-08d83a5abc7c x-ms-traffictypediagnostic: MW3PR11MB4763: x-microsoft-antispam-prvs: <MW3PR11MB4763D005DF714460E663FBD4E1480@MW3PR11MB4763.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:6430; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WlgznTksMJe/tFA6N9DIhVMOt5ItB0Spf8Ij66BJWrWm1gUT3jGyJoUxGDIYX9BvNuFXP37ui7WBrzUXG2m7UKOOX+J8acm5ur4EH7Ldh8Zmf9sTCuZm/IrAaPSM5k/XJ21cy4JzKO89hz/2suqVQGOvSDcTWGmZGt/12s9/3WGQFdEft/CYl1AX5uttXmSOqviRgZ1kAVm9NwNgFyfbxEfzo4PZ1+rk5gSWSmGdRnIt95aKUgslaJwPZ/ijQLVzpLbld/RdeXrO7no1CRZXn22bYJ6FgBMGS6ot6c0RhEiMAFlRDUj2XJr7LejlhQ8i5Ug8atp4vUQMydpOmSh+6Q== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(366004)(376002)(39860400002)(346002)(396003)(6486002)(71200400001)(64756008)(36756003)(478600001)(66476007)(86362001)(8676002)(26005)(2906002)(66446008)(6506007)(66556008)(4744005)(6512007)(5660300002)(91956017)(8936002)(186003)(316002)(76116006)(110136005)(83380400001)(2616005)(66946007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: ob9sI0YtnuGbVcTylTfr5R+Sbh0ROp+I5oYkUkOyNUKrWkiSSOKE/Fg3cJbDDdOPyby5I6D/2x2Ua3856WW0ThH9EXH9xNUDftmV2HEvBMG/TnPK3DttevMCqmPtqQ1sS/YOGWrz83Vn3m7GvSno8Xq9o7A5250ASZnP1iQi2XJgNHu4kzgGEUcmbpiOXqqcB5xjuWe2AETxfOMGN/BzLoTUDerDkxnKRuYVcrRkfLau+y4+YXdSHc5KBdigeDw3eU3jbwldriPCOmEE8xshNXexCYtOVUrMH65NwY6/7Y9QCuiND6H8Pd2pACGtJXv2t8Ii2IXgPyfx/l36rE8ith3OEzWXQEX0+UxfGIGqn9wMaAEWbEiozOPzb0jGwrJuuYvfJZ6GbuaobLkYAdFTN+2Lw0LHT9p0PeZCWuFu1nSeD4ApSzUkeJkMA/pLAMJGAnyQj01DVMeHcVWUj7cTiZH+iOBePbzvj/93Pnh69czYDMKFFC3GYP70xu1g9XFBL6oke9OqLUYcDRvU3rWkPolr8TQvxG3woZSREAt+eZwrCpPSlV2uxsyowmlNdDI48R0o1/erPX8lrJpauyUomMUQeNVwKt6N/MIzDBrHxerMpcB5rDnRkDkyiga40nt9ui11qXdTOReNCEf/4zRttg== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="utf-8" Content-ID: <E64624370AE031418F468E0952ADBA94@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c4bffb6-84c3-4452-3453-08d83a5abc7c X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Aug 2020 22:47:45.5663 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: aFLLgiCuQhqIRyR9ApMyihC2x9pFZ1yI/hwZ+XoWtfF1EZb9h9xg/1ZPxax22vmQj+R1upaC2+ZVSt9R0wG2ig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4763 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: ECAC9420E0 X-Rspamd-UID: 4b9ecc QXBwbGllZA0KT24gVGh1LCAyMDIwLTA4LTA2IGF0IDE2OjEzICswMjAwLCBNaWNoYcWCIExvd2Fz LVJ6ZWNob25layB3cm90ZToNCj4gTWVzaCBQcm9maWxlIHYxLjAuMSwgc2VjdGlvbiA0LjMuMi40 MCBDb25maWcgQXBwS2V5IFN0YXR1cw0KPiANCj4gKC4uLikgVGhlIFN0YXR1cyBDb2RlIHNoYWxs IGJlIFN1Y2Nlc3MgaWYgdGhlIHJlY2VpdmVkIHJlcXVlc3Qgd2FzDQo+IHJlZHVuZGFudCAoYWRk IG9mIGFuIGlkZW50aWNhbCBleGlzdGluZyBrZXksIHVwZGF0ZSBvZiBhbiBpZGVudGljYWwNCj4g dXBkYXRlZCBrZXksIG9yIGRlbGV0ZSBvZiBhIG5vbi1leGlzdGVudCBrZXkpLCB3aXRoIG5vIGZ1 cnRoZXIgYWN0aW9uDQo+IHRha2VuLg0KPiAtLS0NCj4gIG1lc2gvYXBwa2V5LmMgfCAyICstDQo+ ICAxIGZpbGUgY2hhbmdlZCwgMSBpbnNlcnRpb24oKyksIDEgZGVsZXRpb24oLSkNCj4gDQo+IGRp ZmYgLS1naXQgYS9tZXNoL2FwcGtleS5jIGIvbWVzaC9hcHBrZXkuYw0KPiBpbmRleCA0NWQ2MDQw MDcuLmE0NzcxYmQ3ZCAxMDA2NDQNCj4gLS0tIGEvbWVzaC9hcHBrZXkuYw0KPiArKysgYi9tZXNo L2FwcGtleS5jDQo+IEBAIC0zMjAsNyArMzIwLDcgQEAgaW50IGFwcGtleV9rZXlfZGVsZXRlKHN0 cnVjdCBtZXNoX25ldCAqbmV0LCB1aW50MTZfdCBuZXRfaWR4LA0KPiAgCWtleSA9IGxfcXVldWVf ZmluZChhcHBfa2V5cywgbWF0Y2hfa2V5X2luZGV4LCBMX1VJTlRfVE9fUFRSKGFwcF9pZHgpKTsN Cj4gIA0KPiAgCWlmICgha2V5KQ0KPiAtCQlyZXR1cm4gTUVTSF9TVEFUVVNfSU5WQUxJRF9BUFBL RVk7DQo+ICsJCXJldHVybiBNRVNIX1NUQVRVU19TVUNDRVNTOw0KPiAgDQo+ICAJaWYgKGtleS0+ bmV0X2lkeCAhPSBuZXRfaWR4KQ0KPiAgCQlyZXR1cm4gTUVTSF9TVEFUVVNfSU5WQUxJRF9ORVRL RVk7DQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8KJ3LGSKLF9IhAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 00:55:32 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UMiPKmSKLF8kJwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 00:55:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 094D2420DD; Fri, 7 Aug 2020 00:55:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726096AbgHFWz0 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 18:55:26 -0400 Received: from mga02.intel.com ([134.134.136.20]:48214 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbgHFWzZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 18:55:25 -0400 IronPort-SDR: Tx7noXLfpz4FAqMezlgkrm1hQ1eE9rDDCh2wVLawFBRlG3Q0yjir9c4L7SOUGK82xzATimT7iP yejRH2uhEYNA== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140823975" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140823975" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 15:55:24 -0700 IronPort-SDR: vRn9TaQZhoqfWV6yBzo5VwZT94eYaA13PcaqTTDmFELlEvQg7xQ7V3JZP0HJVvC1djQ8GzUUXM 2jvIn+pH2VlQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="493364627" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga006.fm.intel.com with ESMTP; 06 Aug 2020 15:55:24 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] mesh: Use correct TTL value to send model publication Date: Thu, 6 Aug 2020 15:55:23 -0700 Message-Id: <20200806225523.109092-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 094D2420DD X-Rspamd-UID: eb14b8 When sending model publishing data, use TTL value configured for that publication instead of the default TTL value used for regular messages. --- mesh/model.c | 4 ++-- mesh/model.h | 2 +- mesh/node.c | 11 ++++------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/mesh/model.c b/mesh/model.c index ef7668147..043ad1d70 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -1022,7 +1022,7 @@ done: } int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, - uint8_t ttl, const void *msg, uint16_t msg_len) + const void *msg, uint16_t msg_len) { struct mesh_net *net = node_get_net(node); struct mesh_model *mod; @@ -1063,7 +1063,7 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, result = msg_send(node, mod->pub->credential != 0, src, mod->pub->addr, mod->pub->idx, net_idx, - label, ttl, false, msg, msg_len); + label, mod->pub->ttl, false, msg, msg_len); return result ? MESH_ERROR_NONE : MESH_ERROR_FAILED; } diff --git a/mesh/model.h b/mesh/model.h index 0d8dddf92..e4906e330 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -103,7 +103,7 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint8_t ttl, bool segmented, const void *msg, uint16_t msg_len); int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, - uint8_t ttl, const void *msg, uint16_t msg_len); + const void *msg, uint16_t msg_len); bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, uint32_t seq, uint32_t iv_index, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t key_aid, diff --git a/mesh/node.c b/mesh/node.c index 3dca73cef..4b70587ae 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -1983,7 +1983,7 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, struct l_dbus_message_iter iter_data; uint16_t mod_id, src; struct node_element *ele; - uint8_t *data, ttl; + uint8_t *data; uint32_t len, id; int result; @@ -2010,10 +2010,8 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - ttl = mesh_net_get_default_ttl(node->net); - id = SET_ID(SIG_VENDOR, mod_id); - result = mesh_model_publish(node, id, src, ttl, data, len); + result = mesh_model_publish(node, id, src, data, len); if (result != MESH_ERROR_NONE) return dbus_error(msg, result, NULL); @@ -2030,7 +2028,7 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, struct l_dbus_message_iter iter_data; uint16_t src, mod_id, vendor_id; struct node_element *ele; - uint8_t ttl, *data = NULL; + uint8_t *data = NULL; uint32_t len; int result; @@ -2057,8 +2055,7 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - ttl = mesh_net_get_default_ttl(node->net); - result = mesh_model_publish(node, SET_ID(vendor_id, mod_id), src, ttl, + result = mesh_model_publish(node, SET_ID(vendor_id, mod_id), src, data, len); if (result != MESH_ERROR_NONE) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MFyaKaOrLF/wbQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:17:23 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id EL/HJ6OrLF/vVwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:17:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EC5A1A12D7; Fri, 7 Aug 2020 03:17:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726027AbgHGBRS (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:17:18 -0400 Received: from mga03.intel.com ([134.134.136.65]:31449 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbgHGBRR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:17:17 -0400 IronPort-SDR: 4Xl6Mxuh/9QT3TRdO+c5WNtylrHhH8AVqnr0KZeSgEfsSd9DChMEMGOCC3QyM3GDkiXwfpll4Z QM8vN25BGiTA== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="152936389" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="152936389" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:17:17 -0700 IronPort-SDR: DP1DyI2ODBaJ+3qBH9KLl0Cvg0eBTyQdicr0t2i0bxs70uFDYmOM1VDdulHeNSUIDMXIzwtGcS jD8SlysRmWDw== X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="493876844" Received: from apazhamp-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.82.188]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:17:16 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [PATCH 1/3] btp: Update connect event structure Date: Thu, 6 Aug 2020 18:17:01 -0700 Message-Id: <20200807011703.22087-1-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 8 X-Rspamd-Score: 1.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: EC5A1A12D7 X-Rspamd-UID: 7fc0d6 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch updates the connect event struct to align withe the btp spec. Opcode 0x82 - Device Connected event Controller Index: <controller id> Event parameters: Address_Type (1 octet) Address (6 octets) Connection Interval (2 octets) Connection Latency (2 octets) Supervision Timeout (2 octets) --- src/shared/btp.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/shared/btp.h b/src/shared/btp.h index f0ac3a1ee..cc71a71df 100644 --- a/src/shared/btp.h +++ b/src/shared/btp.h @@ -259,6 +259,9 @@ struct btp_device_found_ev { struct btp_gap_device_connected_ev { uint8_t address_type; bdaddr_t address; + uint16_t connection_interval; + uint16_t connection_latency; + uint16_t supervision_timeout; } __packed; #define BTP_EV_GAP_DEVICE_DISCONNECTED 0x83 -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KMLsMsWwLF9qfQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:39:17 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id CBMdMcWwLF8oWAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:39:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 378F2420F7; Fri, 7 Aug 2020 03:39:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726226AbgHGBio (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:38:44 -0400 Received: from mga18.intel.com ([134.134.136.126]:44001 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbgHGBim (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:38:42 -0400 IronPort-SDR: B6W4LUokobmJ5obUoKf+X9khfQEd4nHt/H+LDJmohabGmzgMv0t5Xdl5xFP+FS34ueQlyy0H1t Yxun+m2DSNcg== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140558047" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140558047" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:38:41 -0700 IronPort-SDR: 7DEo5aJlG/yNggW9YwePrDRfPi/596QvV/ldC363lNeMU771eW7lSz6GGFRc31NyRPhk+qEUbo U4SqfHzt1rZw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="397442090" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga001.fm.intel.com with ESMTP; 06 Aug 2020 18:38:41 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v5 07/10] mesh: Clean up handling of config poll timeout message Date: Thu, 6 Aug 2020 18:38:31 -0700 Message-Id: <20200807013834.123263-8-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200807013834.123263-1-inga.stotland@intel.com> References: <20200807013834.123263-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 378F2420F7 X-Rspamd-UID: 41b569 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 34 +++++++++++++++++++++++----------- mesh/cfgmod.h | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 8e3da79d5..f3cc18ae0 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -643,6 +643,25 @@ static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt) return n + 3 + sz; } +static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t n, addr = l_get_le16(pkt); + uint32_t poll_to; + + if (!IS_UNICAST(addr)) + return 0; + + n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); + l_put_le16(addr, msg + n); + n += 2; + + poll_to = mesh_net_friend_timeout(node_get_net(node), addr); + msg[n++] = poll_to; + msg[n++] = poll_to >> 8; + msg[n++] = poll_to >> 16; + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -678,7 +697,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct mesh_net *net; const uint8_t *pkt = data; struct timeval time_now; - uint32_t opcode, tmp32; + uint32_t opcode; int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; uint16_t n_idx; @@ -1117,18 +1136,11 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, msg[n++] = hb->sub_max_hops; break; - case OP_CONFIG_POLL_TIMEOUT_LIST: - if (size != 2 || l_get_le16(pkt) == 0 || - l_get_le16(pkt) > 0x7fff) + case OP_CONFIG_POLL_TIMEOUT_GET: + if (size != 2) return true; - n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; - tmp32 = mesh_net_friend_timeout(net, l_get_le16(pkt)); - msg[n++] = tmp32; - msg[n++] = tmp32 >> 8; - msg[n++] = tmp32 >> 16; + n = cfg_poll_timeout_msg(node, pkt); break; case OP_NODE_RESET: diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 7b6a95807..6d73656a7 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -66,7 +66,7 @@ #define OP_CONFIG_MODEL_SUB_LIST 0x802A #define OP_CONFIG_VEND_MODEL_SUB_GET 0x802B #define OP_CONFIG_VEND_MODEL_SUB_LIST 0x802C -#define OP_CONFIG_POLL_TIMEOUT_LIST 0x802D +#define OP_CONFIG_POLL_TIMEOUT_GET 0x802D #define OP_CONFIG_POLL_TIMEOUT_STATUS 0x802E /* Health opcodes in health-mod.h */ #define OP_CONFIG_HEARTBEAT_PUB_GET 0x8038 -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iNRxDqqrLF/wbQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:17:30 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sKcxDaqrLF9dTwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:17:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C691BA12D7; Fri, 7 Aug 2020 03:17:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726058AbgHGBRU (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:17:20 -0400 Received: from mga03.intel.com ([134.134.136.65]:31449 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbgHGBRU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:17:20 -0400 IronPort-SDR: qcCDsTMPKrpFVwnxa77ZmAtlJcVCHgaZVFTubQHObFUO6X77JeVrQh0hXGTaLSpfdxI6nKa3YL GvEwvc2PLGSQ== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="152936390" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="152936390" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:17:17 -0700 IronPort-SDR: gG8ehUGZkalLnfNTlR3ARitinWpGV0WwfhHmSeay2TLQH6thbHMQM9F9jDdoD+9hfcwdzmHM2B z/iT/qLwogmA== X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="493876848" Received: from apazhamp-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.82.188]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:17:16 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [PATCH 2/3] tools/btpclientctl: Add btpclient test application Date: Thu, 6 Aug 2020 18:17:02 -0700 Message-Id: <20200807011703.22087-2-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200807011703.22087-1-tedd.an@linux.intel.com> References: <20200807011703.22087-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 10 X-Rspamd-Score: 1.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: C691BA12D7 X-Rspamd-UID: 5f0cee From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds a test application for btpclient, which exercises the BTP API. --- Makefile.tools | 7 +- tools/btpclientctrl.c | 2151 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2157 insertions(+), 1 deletion(-) create mode 100644 tools/btpclientctrl.c diff --git a/Makefile.tools b/Makefile.tools index 9b9236609..6100c2bdf 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -492,11 +492,16 @@ test_scripts += test/sap_client.py test/bluezutils.py \ test/test-gatt-profile test/test-mesh test/agent.py if BTPCLIENT -noinst_PROGRAMS += tools/btpclient +noinst_PROGRAMS += tools/btpclient tools/btpclientctrl tools_btpclient_SOURCES = tools/btpclient.c src/shared/btp.c src/shared/btp.h tools_btpclient_LDADD = lib/libbluetooth-internal.la \ src/libshared-ell.la $(ell_ldadd) tools_btpclient_DEPENDENCIES = lib/libbluetooth-internal.la $(ell_dependencies) tools/btpclient.$(OBJEXT): src/libshared-ell.la ell/internal + +tools_btpclientctrl_SOURCES = tools/btpclientctrl.c client/display.c +tools_btpclientctrl_LDADD = lib/libbluetooth-internal.la \ + src/libshared-mainloop.la $(GLIB_LIBS) \ + src/libshared-glib.la -lreadline endif diff --git a/tools/btpclientctrl.c b/tools/btpclientctrl.c new file mode 100644 index 000000000..a9bbb4d01 --- /dev/null +++ b/tools/btpclientctrl.c @@ -0,0 +1,2151 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdarg.h> +#include <errno.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/param.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <poll.h> +#include <getopt.h> +#include <stdbool.h> +#include <wordexp.h> +#include <ctype.h> + +#include <glib.h> + +#include "lib/bluetooth.h" + +#include "src/shared/mainloop.h" +#include "src/shared/io.h" +#include "src/shared/util.h" +#include "src/shared/shell.h" +#include "src/shared/btp.h" + +#define DEFAULT_SOCKET_PATH "/tmp/bt-stack-tester" + +#define PROMPT_ON COLOR_BLUE "[btpclient]" COLOR_OFF "# " + +#define EVT_OPCODE_BASE 0x80 + +#define DEFAULT_INDEX 0x00 + +static char *socket_path; +static bool enable_dump; + +struct client_data { + int fd; + + /* Incoming buffer for response and event */ + uint8_t buf[512]; +}; + +struct btpclientctl { + int server_fd; + struct client_data *client_data; + bool debug_enabled; + + /* Outgoing buffer for command */ + uint8_t buf[560]; + uint16_t buf_len; +}; + +struct ad_data { + uint8_t type; + uint8_t len; + uint8_t data[25]; +}; + +struct advertise_data { + int duration; + int ad_data_len; + uint8_t ad_data[256]; + int scan_data_len; + uint8_t scan_data[256]; +}; + +struct indexstr_data { + int index; + const char *str; +}; + +struct bitfield_data { + uint32_t bit; + const char *str; +}; + +struct opcode_data { + uint8_t opcode; + int bit; + const char *str; + + void (*cmd_func)(const void *data, uint16_t size); + uint16_t cmd_size; + bool cmd_fixed; + + void (*rsp_func)(const void *data, uint16_t size); + uint16_t rsp_size; + bool rsp_fixed; + + void (*evt_func)(const void *data, uint16_t size); + uint16_t evt_size; + bool evt_fixed; +}; + +struct service_data { + uint8_t id; + int bit; + const char *str; + const struct opcode_data *opcode_table; +}; + +static struct advertise_data *advertise_data; +static struct btpclientctl *btpclientctl; +static bool client_active; +static uint8_t bt_index = DEFAULT_INDEX; + +static void hexdump_print(const char *str, void *user_data) +{ + bt_shell_printf("%s%s\n", (char *) user_data, str); +} + +static bool parse_argument_on_off(int argc, char *argv[], uint8_t *val) +{ + if (!strcasecmp(argv[1], "on") || !strcasecmp(argv[1], "yes")) + *val = 1; + else if (!strcasecmp(argv[1], "off") || !strcasecmp(argv[1], "no")) + *val = 0; + else + *val = atoi(argv[1]); + return true; +} + +static bool parse_argument_list(int argc, char *argv[], uint8_t *val, + const struct indexstr_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (strcasecmp(argv[1], table[i].str) == 0) { + *val = table[i].index; + return true; + } + } + + bt_shell_printf("Invalid arguement %s\n", argv[1]); + + return false; +} + +static bool parse_argument_bitfield_list(int argc, char *argv[], uint32_t *val, + const struct bitfield_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (strcasecmp(argv[0], table[i].str) == 0) { + *val = table[i].bit; + return true; + } + } + + bt_shell_printf("Invalid argument %s\n", argv[0]); + + return false; +} + +static bool parse_argument_addr(int argc, char *argv[], uint8_t *addr_type, + bdaddr_t *bdaddr) +{ + if (argc < 3) { + bt_shell_printf("Invalid parameter\n"); + return false; + } + + *addr_type = atoi(argv[1]); + str2ba(argv[2], bdaddr); + + return true; +} + +static char *argument_gen(const char *text, int state, + const struct indexstr_data *list) +{ + static int index, len; + const char *arg; + + if (!state) { + index = 0; + len = strlen(text); + } + + while ((arg = list[index].str)) { + index++; + + if (!strncasecmp(arg, text, len)) + return strdup(arg); + } + + return NULL; +} + +static char *argument_gen_bitfield(const char *text, int state, + const struct bitfield_data *list) +{ + static int index, len; + const char *arg; + + if (!state) { + index = 0; + len = strlen(text); + } + + while ((arg = list[index].str)) { + index++; + + if (!strncasecmp(arg, text, len)) + return strdup(arg); + } + + return NULL; +} + +static const struct service_data service_table[]; + +static const struct service_data *find_service_data(uint8_t service_id) +{ + int i; + + for (i = 0; service_table[i].str; i++) { + if (service_table[i].id == service_id) + return &service_table[i]; + } + + return NULL; +} + +static const struct opcode_data *find_opcode_data(uint8_t opcode, + const struct opcode_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (table[i].opcode == opcode) + return &table[i]; + } + + return NULL; +} + +static const char *get_indexstr(int val, const struct indexstr_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (val == table[i].index) + return table[i].str; + } + + return "Unknown"; +} + +static uint32_t print_bitfield(uint32_t val, const struct bitfield_data *table, + const char *prefix) +{ + uint32_t mask = val; + int i; + + for (i = 0; table[i].str; i++) { + if (val & (((uint32_t) 1) << table[i].bit)) { + bt_shell_printf("%s%s (0x%4.4x)\n", prefix, + table[i].str, table[i].bit); + mask &= ~(((uint32_t) 1) << table[i].bit); + } + } + + return mask; +} + +static void print_bdaddr(const bdaddr_t *address, uint8_t address_type) +{ + char addr[18]; + + ba2str(address, addr); + if (address_type == BTP_GAP_ADDR_PUBLIC) + bt_shell_printf("\t%s (public)\n", addr); + else if (address_type == BTP_GAP_ADDR_RANDOM) + bt_shell_printf("\t%s (random)\n", addr); + else + bt_shell_printf("\t%s (unknown)\n", addr); +} + +static void null_cmd(const void *data, uint16_t size) +{ + /* Empty */ +} + +static void null_rsp(const void *data, uint16_t size) +{ + /* Empty */ +} + +static void null_evt(const void *data, uint16_t size) +{ + /* Empty */ +} + +static const struct indexstr_data error_table[] = { + { 0x01, "Faile" }, + { 0x02, "Unknown Command" }, + { 0x03, "Not Ready" }, + { 0x04, "Invalid Index" }, + { } +}; + +static void print_error_rsp(const void *data, uint16_t size) +{ + uint8_t reason = ((uint8_t *)data)[0]; + + bt_shell_printf(COLOR_RED "\tReason: %s (%d)\n" COLOR_OFF, + get_indexstr(reason, error_table), reason); +} + +static const char *service_to_str(uint8_t service_id) +{ + int i; + + for (i = 0; service_table[i].str; i++) { + if (service_table[i].id == service_id) + return service_table[i].str; + } + + return "Unknown Service ID"; +} + +static const char *get_supported_service(int bit) +{ + int i; + + for (i = 0; service_table[i].str; i++) { + if (service_table[i].bit == bit) + return service_table[i].str; + } + + return NULL; +} + +static const char *get_supported_command(const struct opcode_data *table, + int bit) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (table[i].bit == bit) + return table[i].str; + } + return NULL; +} + +static void print_btp_hdr(struct btp_hdr *btp_hdr, const char *type_str, + const char *opcode_str) +{ + bt_shell_printf("%s: %s(%d) %s(0x%02x) INDEX(0x%02x)\n", type_str, + service_to_str(btp_hdr->service), btp_hdr->service, + opcode_str, btp_hdr->opcode, btp_hdr->index); +} + +static const struct opcode_data opcode_table_core[]; + +static void print_core_read_supported_commands_rsp(const void *data, + uint16_t size) +{ + uint8_t cmds; + const char *str; + int i, bit; + + cmds = ((uint8_t *)data)[0]; + + for (i = 1; i < (int)(sizeof(cmds) * 8); i++) { + bit = 0; + bit = 1 << i; + if (cmds & bit) { + str = get_supported_command(opcode_table_core, i); + if (str) + bt_shell_printf("\t%s (Bit %d)\n", str, i); + else + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); + } + } +} + +static void print_core_read_supported_services_rsp(const void *data, + uint16_t size) +{ + uint8_t services; + const char *str; + int i, bit; + + services = ((uint8_t *)data)[0]; + + for (i = 0; i < (int)(sizeof(services) * 8); i++) { + bit = 1 << i; + if (services & bit) { + str = get_supported_service(i); + if (str) + bt_shell_printf("\t%s (Bit %d)\n", str, i); + else + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); + } + } +} + +static void print_core_register_service_cmd(const void *data, uint16_t size) +{ + const struct btp_core_register_cp *cp = data; + + bt_shell_printf("\tService ID: %s(0x%02x)\n", + service_to_str(cp->service_id), cp->service_id); +} + +static void print_core_unregister_service_cmd(const void *data, uint16_t size) +{ + const struct btp_core_unregister_cp *cp = data; + + bt_shell_printf("\tService ID: %s(0x%02x)\n", + service_to_str(cp->service_id), cp->service_id); +} + +static const struct opcode_data opcode_table_core[] = { + { 0x00, 0, "Error", + null_cmd, 0, true, + print_error_rsp, 1, true }, + { 0x01, 1, "Read Supported Commands", + null_cmd, 0, true, + print_core_read_supported_commands_rsp, 1, true }, + { 0x02, 2, "Read Supported Services", + null_cmd, 0, true, + print_core_read_supported_services_rsp, 1, true }, + { 0x03, 3, "Register Service", + print_core_register_service_cmd, 1, true, + null_rsp, 0, true }, + { 0x04, 4, "Unregister Service", + print_core_unregister_service_cmd, 1, true, + null_rsp, 0, true }, + { 0x80, -1, "IUT Ready", + null_cmd, 0, true, + null_rsp, 0, true, + null_evt, 0, true }, + { } +}; + +static const struct opcode_data opcode_table_gap[]; + +static void print_gap_read_supported_commands_rsp(const void *data, + uint16_t size) +{ + uint16_t cmds; + const char *str; + int i; + + cmds = le16_to_cpu(((uint16_t *)data)[0]); + + for (i = 1; i < (int)(sizeof(cmds) * 8); i++) { + if (cmds & (1 << i)) { + str = get_supported_command(opcode_table_gap, i); + if (str) + bt_shell_printf("\t%s (Bit %d)\n", str, i); + else + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); + } + } +} + +static void print_gap_read_controller_index_list_rsp(const void *data, + uint16_t size) +{ + const struct btp_gap_read_index_rp *list = data; + int i; + + for (i = 0; i < list->num; i++) + bt_shell_printf("\tIndex: %d\n", list->indexes[i]); +} + +static const struct bitfield_data gap_setting_table[] = { + { 0, "Powered" }, + { 1, "Connectable" }, + { 2, "Fast Connectable" }, + { 3, "Discoverable" }, + { 4, "Bondable" }, + { 5, "Link Layer Security" }, + { 6, "Secure Simple Pairing" }, + { 7, "BR/EDR" }, + { 8, "High Speed" }, + { 9, "Low Energy" }, + { 10, "Advertising" }, + { 11, "Secure Connection" }, + { 12, "Debug Keys" }, + { 13, "Privacy" }, + { 14, "Controller Configuration" }, + { 15, "Static Address" }, + { } +}; + +static void print_gap_settings(uint32_t val, const struct bitfield_data *table, + const char *prefix) +{ + uint32_t mask; + + mask = print_bitfield(val, table, prefix); + if (mask) + bt_shell_printf("%sUnknown settings (0x%4.4x)\n", prefix, mask); +} + +static void print_gap_read_controller_information_rsp(const void *data, + uint16_t size) +{ + const struct btp_gap_read_info_rp *info = data; + char addr[18]; + + ba2str(&info->address, addr); + bt_shell_printf("\tAddress: %s\n", addr); + bt_shell_printf("\tSupported Settings\n"); + print_gap_settings(le32_to_cpu(info->supported_settings), + gap_setting_table, "\t\t"); + bt_shell_printf("\tCurrent Settings\n"); + print_gap_settings(le32_to_cpu(info->current_settings), + gap_setting_table, "\t\t"); + bt_shell_printf("\tClass: 0x%02x%02x%02x\n", + info->cod[2], info->cod[1], info->cod[0]); + bt_shell_printf("\tShort: %s\n", info->short_name); + bt_shell_printf("\tName: %s\n", info->name); +} + +static void print_gap_reset_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_reset_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static const struct indexstr_data on_off_table[] = { + { 0x00, "Off" }, + { 0x01, "On" }, + { } +}; + +static void print_gap_set_powered_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_powered_cp *cp = data; + + bt_shell_printf("\tSet Power: %s (%d)\n", + get_indexstr(cp->powered, on_off_table), + cp->powered); +} + +static void print_gap_set_powered_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_powered_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_set_connectable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_connectable_cp *cp = data; + + bt_shell_printf("\t Set Connectable: %s (%d)\n", + get_indexstr(cp->connectable, on_off_table), + cp->connectable); +} + +static void print_gap_set_connectable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_connectable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_set_fast_connectable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_fast_connectable_cp *cp = data; + + bt_shell_printf("\t Set Fast Connectable: %s (%d)\n", + get_indexstr(cp->fast_connectable, on_off_table), + cp->fast_connectable); +} + +static void print_gap_set_fast_connectable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_fast_connectable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static const struct indexstr_data gap_discoverable_table[] = { + { 0x00, "Off" }, + { 0x01, "On" }, + { 0x02, "Limited" }, + { } +}; + +static void print_gap_set_discoverable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_discoverable_cp *cp = data; + + bt_shell_printf("\t Set Discoverable: %s (%d)\n", + get_indexstr(cp->discoverable, gap_discoverable_table), + cp->discoverable); +} + +static void print_gap_set_discoverable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_discoverable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_set_bondable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_bondable_cp *cp = data; + + bt_shell_printf("\t Set Bondable: %s (%d)\n", + get_indexstr(cp->bondable, on_off_table), + cp->bondable); +} + +static void print_gap_set_bondable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_bondable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_adv_data(const uint8_t *data, uint8_t len, const char *prefix) +{ + struct ad_data *ad; + const uint8_t *ptr = data; + int count = len; + char str[96]; + int i, j; + + while (count > 0) { + ad = (struct ad_data *)ptr; + + bt_shell_printf("%sData:\n", prefix); + bt_shell_printf("%s\tType: 0x%02x (%d)\n", prefix, ad->type, + ad->len); + count -= 2; + + for (i = 0, j = 0; i < ad->len; i++) { + j += sprintf(str + j, "%02x ", ad->data[i]); + if ((i % 16) == 15) { + str[j] = '\0'; + bt_shell_printf("%s\t%s\n", prefix, str); + j = 0; + } + } + str[j] = '\0'; + bt_shell_printf("%s\t%s\n", prefix, str); + + count -= ad->len; + } +} + +static void print_gap_start_advertising_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_start_adv_cp *cp = data; + + if (cp->adv_data_len) { + bt_shell_printf("\tAdvertising Data:\n"); + print_adv_data(cp->data, cp->adv_data_len, "\t\t"); + } + + if (cp->scan_rsp_len) { + bt_shell_printf("\tScan Response Data:\n"); + print_adv_data(cp->data + cp->adv_data_len, cp->scan_rsp_len, + "\t\t"); + } +} + +static void print_gap_start_advertising_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_start_adv_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_stop_advertising_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_start_adv_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static const struct bitfield_data gap_discovery_flags_table[] = { + { 0, "LE" }, + { 1, "BREDE" }, + { 2, "Limited" }, + { 3, "Active" }, + { 4, "Observation" }, + { } +}; + +static void print_gap_start_discovery_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_start_discovery_cp *cp = data; + uint32_t mask; + + mask = print_bitfield(le32_to_cpu(cp->flags), + gap_discovery_flags_table, "\t\t"); + if (mask) + bt_shell_printf("\t\tUnknown flags (0x%4.4x)\n", mask); +} + +static void print_gap_connect_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_connect_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static void print_gap_disconnect_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_disconnect_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static const struct indexstr_data gap_io_capa_table[] = { + { 0x00, "DisplayOnly" }, + { 0x01, "DisplayYesNo" }, + { 0x02, "KeyboardOnly" }, + { 0x03, "NoInputOutput" }, + { 0x04, "KeyboardDisplay" }, + { } +}; + +static void print_gap_set_io_capa_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_io_capa_cp *cp = data; + + bt_shell_printf("\tIO Capa: %s (%d)\n", + get_indexstr(cp->capa, gap_io_capa_table), cp->capa); +} + +static void print_gap_pair_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_pair_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static void print_gap_unpair_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_unpair_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static void print_gap_passkey_entry_response_cmd(const void *data, + uint16_t size) +{ + const struct btp_gap_passkey_entry_rsp_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(cp->passkey)); +} + +static void print_gap_passkey_confirmation_response_cmd(const void *data, + uint16_t size) +{ + const struct btp_gap_passkey_confirm_rsp_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); + bt_shell_printf("\tMatch: %d\n", cp->match); +} + +static void print_gap_new_settings_evt(const void *data, uint16_t size) +{ + const struct btp_new_settings_ev *ev = data; + + print_gap_settings(le32_to_cpu(ev->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_eir(const uint8_t *eir, uint16_t eir_len, + const char *prefix) +{ + char str[64]; + int i, n; + + if (eir_len == 0) { + bt_shell_printf("%sEIR Data: Empty\n", prefix); + return; + } + + bt_shell_printf("%sEIR Data:\n", prefix); + for (i = 0, n = 0; i < eir_len; i++) { + n += sprintf(str + n, "%02x ", eir[i]); + if ((i % 16) == 15) { + str[n] = '\0'; + bt_shell_printf("\t%s%s\n", prefix, str); + n = 0; + } + } +} + +static const struct bitfield_data gap_device_found_flags_table[] = { + { 0, "RSSI Valid" }, + { 1, "Adv_Data Included" }, + { 2, "Scan_Rsp Included" }, + { } +}; + +static void print_gap_device_found_evt(const void *data, uint16_t size) +{ + const struct btp_device_found_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tRSSI: %d\n", ev->rssi); + bt_shell_printf("\tFlags:\n"); + print_bitfield(ev->flags, gap_device_found_flags_table, "\t\t"); + print_gap_eir(ev->eir, ev->eir_len, "\t"); +} + +static void print_gap_device_connected_evt(const void *data, uint16_t size) +{ + const struct btp_gap_device_connected_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); +} + +static void print_gap_device_disconnected_evt(const void *data, uint16_t size) +{ + const struct btp_gap_device_disconnected_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); +} + +static void print_gap_passkey_display_evt(const void *data, uint16_t size) +{ + const struct btp_gap_passkey_display_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(ev->passkey)); +} + +static void print_gap_passkey_enter_request_evt(const void *data, uint16_t size) +{ + const struct btp_gap_passkey_req_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); +} + +static void print_gap_passkey_confirm_request_evt(const void *data, + uint16_t size) +{ + const struct btp_gap_passkey_confirm_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(ev->passkey)); +} + +static void print_gap_identity_resolved_evt(const void *data, uint16_t size) +{ + const struct btp_gap_identity_resolved_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tIdentity: "); + print_bdaddr(&ev->identity_address, ev->identity_address_type); +} + + +static const struct opcode_data opcode_table_gap[] = { + { 0x00, 0, "Error", + null_cmd, 0, true, + print_error_rsp, 1, true }, + { 0x01, 1, "Read Supported Commands", + null_cmd, 0, true, + print_gap_read_supported_commands_rsp, 2, true }, + { 0x02, 2, "Read Controller Index List", + null_cmd, 0, true, + print_gap_read_controller_index_list_rsp, 2, false }, + { 0x03, 3, "Read Controller Information", + null_cmd, 0, true, + print_gap_read_controller_information_rsp, 277, true }, + { 0x04, 4, "Reset", + null_cmd, 0, true, + print_gap_reset_rsp, 4, true }, + { 0x05, 5, "Set Powered", + print_gap_set_powered_cmd, 1, true, + print_gap_set_powered_rsp, 4, true }, + { 0x06, 6, "Set Connectable", + print_gap_set_connectable_cmd, 1, true, + print_gap_set_connectable_rsp, 4, true }, + { 0x07, 7, "Set Fast Connectable", + print_gap_set_fast_connectable_cmd, 1, true, + print_gap_set_fast_connectable_rsp, 4, true }, + { 0x08, 8, "Set Discoverable", + print_gap_set_discoverable_cmd, 1, true, + print_gap_set_discoverable_rsp, 4, true }, + { 0x09, 9, "Set Bondable", + print_gap_set_bondable_cmd, 1, true, + print_gap_set_bondable_rsp, 4, true }, + { 0x0a, 10, "Starting Advertising", + print_gap_start_advertising_cmd, 2, false, + print_gap_start_advertising_rsp, 4, true }, + { 0x0b, 11, "Stop Advertising", + null_cmd, 0, true, + print_gap_stop_advertising_rsp, 4, true }, + { 0x0c, 12, "Start Discovery", + print_gap_start_discovery_cmd, 1, true, + null_rsp, 0, true }, + { 0x0d, 13, "Stop Discovery", + null_cmd, 0, true, + null_rsp, 0, true }, + { 0x0e, 14, "Connect", + print_gap_connect_cmd, 7, true, + null_rsp, 0, true }, + { 0x0f, 15, "Disconnect", + print_gap_disconnect_cmd, 7, true, + null_rsp, 0, true }, + { 0x10, 16, "Set I/O Capability", + print_gap_set_io_capa_cmd, 1, true, + null_rsp, 0, true }, + { 0x11, 17, "Pair", + print_gap_pair_cmd, 7, true, + null_rsp, 0, true }, + { 0x12, 18, "Unpair", + print_gap_unpair_cmd, 7, true, + null_rsp, 0, true }, + { 0x13, 19, "Passkey Entry Response", + print_gap_passkey_entry_response_cmd, 11, true, + null_rsp, 0, true }, + { 0x14, 20, "Passkey Confirmation Response", + print_gap_passkey_confirmation_response_cmd, 8, true, + null_rsp, 0, true }, + { 0x80, -1, "New Settings", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_new_settings_evt, 4, true }, + { 0x81, -1, "Device Found", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_device_found_evt, 11, false }, + { 0x82, -1, "Device Connected", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_device_connected_evt, 7, true }, + { 0x83, -1, "Device Disconnected", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_device_disconnected_evt, 7, true }, + { 0x84, -1, "Passkey Display", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_passkey_display_evt, 11, true }, + { 0x85, -1, "Passkey Entry Request", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_passkey_enter_request_evt, 7, true }, + { 0x86, -1, "Passkey Confirm Request", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_passkey_confirm_request_evt, 11, true }, + { 0x87, -1, "Identity Resolved", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_identity_resolved_evt, 14, true }, + { } +}; + +static const struct service_data service_table[] = { + { 0x00, 0, "Core", opcode_table_core}, + { 0x01, 1, "GAP", opcode_table_gap}, + { } +}; + +static bool write_packet(int fd, const void *data, size_t size) +{ + while (size > 0) { + ssize_t written; + + written = write(fd, data, size); + if (written < 0) { + if (errno == EAGAIN || errno == EINTR) + continue; + return false; + } + + if (enable_dump) + util_hexdump('<', data, written, hexdump_print, + "OUT: "); + + data += written; + size -= written; + } + + return true; +} + +static void btp_print_cmd(struct btp_hdr *btp_hdr, void *data) +{ + const struct service_data *table; + const struct opcode_data *opcode_data; + + table = find_service_data(btp_hdr->service); + if (!table) { + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); + return; + } + + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); + if (!opcode_data) { + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); + return; + } + + print_btp_hdr(btp_hdr, "CMD", opcode_data->str); + + if (opcode_data->cmd_fixed) { + if (btp_hdr->data_len != opcode_data->cmd_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } else { + if (btp_hdr->data_len < opcode_data->cmd_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } + + opcode_data->cmd_func(data, btp_hdr->data_len); +} + +static void btp_print_rsp(struct btp_hdr *btp_hdr, void *data) +{ + const struct service_data *table; + const struct opcode_data *opcode_data; + + table = find_service_data(btp_hdr->service); + if (!table) { + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); + return; + } + + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); + if (!opcode_data) { + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); + return; + } + + print_btp_hdr(btp_hdr, "RSP", opcode_data->str); + + if (opcode_data->rsp_fixed) { + if (btp_hdr->data_len != opcode_data->rsp_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } else { + if (btp_hdr->data_len < opcode_data->rsp_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } + + opcode_data->rsp_func(data, btp_hdr->data_len); +} + +static void btp_print_evt(struct btp_hdr *btp_hdr, void *data) +{ + const struct service_data *table; + const struct opcode_data *opcode_data; + + table = find_service_data(btp_hdr->service); + if (!table) { + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); + return; + } + + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); + if (!opcode_data) { + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); + return; + } + + print_btp_hdr(btp_hdr, "EVT", opcode_data->str); + + if (opcode_data->evt_fixed) { + if (btp_hdr->data_len != opcode_data->evt_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } else { + if (btp_hdr->data_len < opcode_data->evt_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } + + opcode_data->evt_func(data, btp_hdr->data_len); +} + +static bool send_cmd(uint8_t service_id, uint8_t opcode, uint8_t index, + uint16_t data_len, void *data) +{ + struct btp_hdr *hdr; + int client_fd; + + if (!client_active) { + bt_shell_printf("ERROR: Client is not active\n"); + return false; + } + + hdr = (struct btp_hdr *)(btpclientctl->buf); + + hdr->service = service_id; + hdr->opcode = opcode; + hdr->index = index; + hdr->data_len = cpu_to_le16(data_len); + if (data) + memcpy(hdr->data, data, data_len); + + btpclientctl->buf_len = sizeof(*hdr) + data_len; + + client_fd = btpclientctl->client_data->fd; + + btp_print_cmd(hdr, data_len ? hdr->data : NULL); + + if (!write_packet(client_fd, btpclientctl->buf, + btpclientctl->buf_len)) { + fprintf(stderr, "Failed to send command to client\n"); + mainloop_remove_fd(client_fd); + return false; + } + + return true; +} + +static void client_read_destroy(void *user_data) +{ + struct client_data *client_data = user_data; + + close(client_data->fd); + free(client_data); + + client_active = false; + + bt_shell_printf("Client is disconnected\n"); +} + +static void client_read_callback(int fd, uint32_t events, void *user_data) +{ + struct client_data *client_data = user_data; + struct btp_hdr *btp_hdr; + uint8_t *data, *ptr; + ssize_t len, pkt_len; + + if (events & (EPOLLERR | EPOLLHUP)) { + fprintf(stderr, "Error from client connection\n"); + mainloop_remove_fd(client_data->fd); + return; + } + + if (events & EPOLLRDHUP) { + fprintf(stderr, "Remote hangeup of cliient connection\n"); + mainloop_remove_fd(client_data->fd); + return; + } + + /* Read incoming packet */ + len = read(client_data->fd, client_data->buf, sizeof(client_data->buf)); + if (len < 0) { + if (errno == EAGAIN || errno == EINTR) + return; + + fprintf(stderr, "Read from client descriptor failed\n"); + mainloop_remove_fd(client_data->fd); + return; + } + + if (len < (ssize_t)sizeof(struct btp_hdr) - 1) + return; + + ptr = client_data->buf; + + while (len) { + btp_hdr = (struct btp_hdr *)ptr; + + pkt_len = sizeof(*btp_hdr) + btp_hdr->data_len; + + if (enable_dump) + util_hexdump('>', ptr, pkt_len, hexdump_print, "IN : "); + + if (btp_hdr->data_len) + data = btp_hdr->data; + else + data = NULL; + + if (btp_hdr->opcode < EVT_OPCODE_BASE) + btp_print_rsp(btp_hdr, data); + else + btp_print_evt(btp_hdr, data); + + ptr += pkt_len; + len -= pkt_len; + } +} + +static struct client_data *setup_client(int client_fd) +{ + struct client_data *client_data; + + client_data = new0(struct client_data, 1); + if (!client_data) + return NULL; + + client_data->fd = client_fd; + + mainloop_add_fd(client_data->fd, EPOLLIN | EPOLLRDHUP, + client_read_callback, client_data, client_read_destroy); + + return client_data; +} + +static void server_callback(int fd, uint32_t events, void *user_data) +{ + union { + struct sockaddr common; + struct sockaddr_un sun; + struct sockaddr_in sin; + } addr; + socklen_t len; + int client_fd; + struct client_data *client_data; + struct btpclientctl *btpclientctl = user_data; + + if (events & (EPOLLERR | EPOLLHUP)) { + mainloop_quit(); + return; + } + + memset(&addr, 0, sizeof(addr)); + len = sizeof(addr); + + if (getsockname(fd, &addr.common, &len) < 0) { + perror("Failed to get socket name"); + return; + } + + client_fd = accept(fd, &addr.common, &len); + if (client_fd < 0) { + perror("Failed to accept client socket"); + return; + } + + bt_shell_printf("Client is connected\n"); + + /* Setup Client */ + client_data = setup_client(client_fd); + if (!client_data) { + fprintf(stderr, "Failed to setup client\n"); + close(client_fd); + return; + } + + btpclientctl->client_data = client_data; + client_active = true; +} + +static int open_socket(const char *path) +{ + struct sockaddr_un addr; + size_t len; + int fd; + + len = strlen(path); + if (len > sizeof(addr.sun_path) - 1) { + fprintf(stderr, "Socket path is too long\n"); + return -1; + } + + unlink(path); + + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (fd < 0) { + perror("Failed to open Unix server socket"); + return -1; + } + + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); + + if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + perror("Failed to bind Unix server socket"); + goto error_close; + } + + if (listen(fd, 1) < 0) { + perror("Failed to listen Unix server socket"); + goto error_close; + } + + bt_shell_printf("Waiting for client connection...\n"); + + if (chmod(path, 0666) < 0) { + perror("Failed to change Unix socket file mode"); + goto error_close; + } + + return fd; + +error_close: + close(fd); + return -1; +} + +static void cmd_ad_show(int argc, char **argv) +{ + bt_shell_printf("AD: Saved Advertise/Scan data\n"); + + if (!advertise_data) { + bt_shell_printf("\tError: Not initialized\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (advertise_data->ad_data_len) { + bt_shell_printf("\tAD Data:\n"); + print_adv_data(advertise_data->ad_data, + advertise_data->ad_data_len, "\t\t"); + } + + if (advertise_data->scan_data_len) { + bt_shell_printf("\tScan Data:\n"); + print_adv_data(advertise_data->scan_data, + advertise_data->scan_data_len, "\t\t"); + } + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static bool ad_add_data(struct ad_data *ad_data, int argc, char *argv[]) +{ + char *endptr = NULL; + int i; + long val; + + /* Type */ + val = strtol(argv[0], &endptr, 0); + if (!endptr || *endptr != '\0' || val > UINT8_MAX) { + bt_shell_printf("Error: Invalid Type\n"); + return false; + } + ad_data->type = val; + + for (i = 1; i < argc; i++) { + endptr = NULL; + + val = strtol(argv[i], &endptr, 0); + if (!endptr || *endptr != '\0' || val > UINT8_MAX) { + bt_shell_printf("Error: Invalid data at %d\n", i); + return false; + } + + ad_data->data[ad_data->len] = val; + ad_data->len++; + } + + return true; +} + +static void cmd_ad_add_ad(int argc, char **argv) +{ + struct ad_data ad_data; + uint8_t *ptr; + + bt_shell_printf("AD: Save Advertise data\n"); + + if (!advertise_data) { + bt_shell_printf("\tError: Not initialized\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (argc < 2) { + bt_shell_printf("\tInvalid Parameter Number\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + memset(&ad_data, 0, sizeof(ad_data)); + + if (!ad_add_data(&ad_data, argc - 1, argv + 1)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + ptr = advertise_data->ad_data + advertise_data->ad_data_len; + memcpy(ptr, &ad_data, ad_data.len + 2); + advertise_data->ad_data_len += ad_data.len + 2; + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_ad_add_scan(int argc, char **argv) +{ + struct ad_data ad_data; + uint8_t *ptr; + + bt_shell_printf("AD: Save Scan data\n"); + + if (!advertise_data) { + bt_shell_printf("\tError: Not initialized\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (argc < 2) { + bt_shell_printf("\tInvalid Parameter Number\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!ad_add_data(&ad_data, argc - 1, argv + 1)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + ptr = advertise_data->scan_data + advertise_data->scan_data_len; + memcpy(ptr, &ad_data, ad_data.len + 2); + advertise_data->scan_data_len += ad_data.len + 2; + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_ad_duration(int argc, char **argv) +{ + uint32_t val; + + bt_shell_printf("AD: Set Advertising Duration\n"); + + if (!advertise_data) { + bt_shell_printf("\tError: Not initialized\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (argc > 2) { + bt_shell_printf("\tInvalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + /* No parameter */ + if (argc == 1) { + bt_shell_printf("\tDuration: %d\n", advertise_data->duration); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + val = (uint32_t)atoi(argv[1]); + + if (val == 0) + val = UINT32_MAX; + + advertise_data->duration = val; + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_ad_clear(int argc, char **argv) +{ + bt_shell_printf("AD: Clear Advertise/Scan data\n"); + + if (!advertise_data) { + bt_shell_printf("\tError: Not initialized\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + advertise_data->ad_data_len = 0; + advertise_data->scan_data_len = 0; + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_core_read_cmds(int argc, char **argv) +{ + bt_shell_printf("Core: Read Supported Commands\n"); + + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_READ_SUPPORTED_COMMANDS, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_core_read_services(int argc, char **argv) +{ + bt_shell_printf("Core: Read Supported Services\n"); + + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_READ_SUPPORTED_SERVICES, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_core_register_service(int argc, char **argv) +{ + uint8_t service_id; + + bt_shell_printf("Core: Register Service\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + service_id = atoi(argv[1]); + if (service_id == 0) { + bt_shell_printf("CORE service is already registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_REGISTER, + BTP_INDEX_NON_CONTROLLER, 1, &service_id)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_core_unregister_service(int argc, char **argv) +{ + uint8_t service_id; + + bt_shell_printf("Core: Unregister Service\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + service_id = atoi(argv[1]); + if (service_id == 0) { + bt_shell_printf("Cannot unregister CORE service\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_UNREGISTER, + BTP_INDEX_NON_CONTROLLER, 1, &service_id)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_set_index(int argc, char **argv) +{ + uint8_t index; + + bt_shell_printf("Set Default Controller Index\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + index = atoi(argv[1]); + if (index == bt_index) { + bt_shell_printf("Controller index is already set\n"); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + bt_index = index; + bt_shell_printf("Controller index is updated to 0x%02x\n", bt_index); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_read_cmds(int argc, char **argv) +{ + bt_shell_printf("GAP: Read Supported Commands\n"); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_SUPPORTED_COMMANDS, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_read_index(int argc, char **argv) +{ + bt_shell_printf("GAP: Read Controller Index List\n"); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_CONTROLLER_INDEX_LIST, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_read_info(int argc, char **argv) +{ + uint8_t index; + + bt_shell_printf("GAP: Read Controller Information\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + index = atoi(argv[1]); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_COTROLLER_INFO, + index, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_reset(int argc, char **argv) +{ + bt_shell_printf("GAP: Reset\n"); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_RESET, bt_index, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_on_off_gen(const char *text, int state) +{ + return argument_gen(text, state, on_off_table); +} + +static void cmd_gap_power(int argc, char **argv) +{ + struct btp_gap_set_powered_cp cp; + + bt_shell_printf("GAP: Set Power\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_on_off(argc, argv, &cp.powered)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_POWERED, bt_index, + sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_connectable(int argc, char **argv) +{ + struct btp_gap_set_connectable_cp cp; + + bt_shell_printf("GAP: Set Connectable\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_on_off(argc, argv, &cp.connectable)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_CONNECTABLE, bt_index, + sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_fast_connectable(int argc, char **argv) +{ + struct btp_gap_set_fast_connectable_cp cp; + + bt_shell_printf("GAP: Set Fast Connectable\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_on_off(argc, argv, &cp.fast_connectable)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_FAST_CONNECTABLE, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_discoverable_gen(const char *text, int state) +{ + return argument_gen(text, state, gap_discoverable_table); +} + +static void cmd_gap_discoverable(int argc, char **argv) +{ + struct btp_gap_set_discoverable_cp cp; + + bt_shell_printf("GAP: Set Discoverable\n"); + + memset(&cp, 0, sizeof(cp)); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_list(argc, argv, &cp.discoverable, + gap_discoverable_table)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_DISCOVERABLE, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_bondable(int argc, char **argv) +{ + struct btp_gap_set_bondable_cp cp; + + bt_shell_printf("GAP: Set Bondable\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_on_off(argc, argv, &cp.bondable)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_BONDABLE, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_start_adv(int argc, char **argv) +{ + struct btp_gap_start_adv_cp *cp; + int total; + + bt_shell_printf("GAP: Start Advertising\n"); + + /* Check if AD data is availabel */ + if (advertise_data->ad_data_len == 0 && + advertise_data->scan_data_len == 0) { + bt_shell_printf("ERROR: No Advertise or Scan data available\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + /* Allocate the maximum size */ + cp = (struct btp_gap_start_adv_cp *)malloc(520); + + memset(cp, 0, 520); + total = 2; + + if (advertise_data->ad_data_len) { + memcpy(cp->data, advertise_data->ad_data, + advertise_data->ad_data_len); + cp->adv_data_len = advertise_data->ad_data_len; + } else + cp->adv_data_len = 0; + + total += cp->adv_data_len; + + if (advertise_data->scan_data_len) { + memcpy(cp->data + cp->adv_data_len, advertise_data->scan_data, + advertise_data->scan_data_len); + cp->scan_rsp_len = advertise_data->scan_data_len; + } else + cp->scan_rsp_len = 0; + + total += cp->scan_rsp_len; + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_START_ADVERTISING, + bt_index, total, cp)) { + free(cp); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + free(cp); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_stop_adv(int argc, char **argv) +{ + bt_shell_printf("GAP: Stop Advertising\n"); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_STOP_ADVERTISING, + bt_index, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_start_disc_gen(const char *text, int state) +{ + return argument_gen_bitfield(text, state, gap_discovery_flags_table); +} + +static void cmd_gap_start_disc(int argc, char **argv) +{ + struct btp_gap_start_discovery_cp cp; + int i; + uint32_t f; + + bt_shell_printf("GAP: Start Discovery\n"); + + if (argc < 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + memset(&cp, 0, sizeof(cp)); + + for (i = 1; i < argc; i++) { + if (!parse_argument_bitfield_list(argc - i, &argv[i], &f, + gap_discovery_flags_table)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + cp.flags |= (1 << f); + } + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_START_DISCOVERY, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_stop_disc(int argc, char **argv) +{ + bt_shell_printf("GAP: Stop Discovery\n"); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_STOP_DISCOVERY, bt_index, + 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_connect(int argc, char **argv) +{ + struct btp_gap_connect_cp cp; + + bt_shell_printf("GAP: Connect\n"); + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_CONNECT, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_disconnect(int argc, char **argv) +{ + struct btp_gap_disconnect_cp cp; + + bt_shell_printf("GAP: Disconnect\n"); + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_DISCONNECT, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_io_capa_gen(const char *text, int state) +{ + return argument_gen(text, state, gap_io_capa_table); +} + +static void cmd_gap_set_io_capa(int argc, char **argv) +{ + struct btp_gap_set_io_capa_cp cp; + + bt_shell_printf("GAP: Get IO Capability\n"); + + memset(&cp, 0, sizeof(cp)); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_list(argc, argv, &cp.capa, gap_io_capa_table)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_IO_CAPA, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_pair(int argc, char **argv) +{ + struct btp_gap_pair_cp cp; + + bt_shell_printf("GAP: Pair\n"); + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_PAIR, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_unpair(int argc, char **argv) +{ + struct btp_gap_unpair_cp cp; + + bt_shell_printf("GAP: Unpair\n"); + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_UNPAIR, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static const struct bt_shell_menu ad_menu = { + .name = "ad", + .desc = "Manage Advertise DataSubmenu", + .entries = { + { "show", NULL, + cmd_ad_show, "Show current saved AD/Scan data" }, + { "add-ad", "<type> <data=xx xx ...>", + cmd_ad_add_ad, "Save AD data" }, + { "add-scan", "<type> <data=xx xx ...>", + cmd_ad_add_scan, "Save Scan data" }, + { "duration", "<duration>", + cmd_ad_duration, "Set duration" }, + { "clear", "<all/ad/scan/duration>", + cmd_ad_clear, "Clear saved AD/Scan/duration data" }, + { } }, +}; + +static const struct bt_shell_menu gap_menu = { + .name = "gap", + .desc = "GAP API Submenu", + .entries = { + { "read-cmds", NULL, + cmd_gap_read_cmds, "Show supported commands" }, + { "list", NULL, + cmd_gap_read_index, "Show index of controllers" }, + { "read-info", "<index>", + cmd_gap_read_info, "Read controller information" }, + { "reset", NULL, + cmd_gap_reset, "Reset controller and stack" }, + { "power", "<on/off>", + cmd_gap_power, "Set controller power", + gap_on_off_gen }, + { "connectable", "<on/off>", + cmd_gap_connectable, "Set controller connectable", + gap_on_off_gen }, + { "fast-connectable", "<on/off>", + cmd_gap_fast_connectable, "Set controller fast connectable", + gap_on_off_gen }, + { "discoverable", "<on/off/limited>", + cmd_gap_discoverable, "Set controller discoverable", + gap_discoverable_gen }, + { "bondable", "<on/off>", + cmd_gap_bondable, "Set controller bondable", + gap_on_off_gen }, + { "start-adv", NULL, + cmd_gap_start_adv, "Start Advertising" }, + { "stop-adv", NULL, + cmd_gap_stop_adv, "Stop Advertising" }, + { "start-disc", "<flags...>", + cmd_gap_start_disc, "Start discovery", + gap_start_disc_gen }, + { "stop-disc", NULL, + cmd_gap_stop_disc, "Stop discovery" }, + { "connect", "<type> <bdaddr>", + cmd_gap_connect, "Connect" }, + { "disconnect", "<type> <bdaddr>", + cmd_gap_disconnect, "Disconnect" }, + { "set-capa", "<io capability>", + cmd_gap_set_io_capa, "Set IO capability", + gap_io_capa_gen }, + { "pair", "<type> <bdaddr>", + cmd_gap_pair, "Pair" }, + { "unpair", "<type> <bdaddr>", + cmd_gap_unpair, "Unpair" }, + { } }, +}; + +static const struct bt_shell_menu main_menu = { + .name = "main", + .entries = { + { "read-cmds", NULL, + cmd_core_read_cmds, "Read supported commands" }, + { "read-services", NULL, + cmd_core_read_services, "Read supported services" }, + { "register", "<service id>", + cmd_core_register_service, "Register service" }, + { "unregister", "<service id>", + cmd_core_unregister_service, "Unregister service" }, + { "index", "<index>", + cmd_set_index, "Set controller index. Default is 0" }, + { } }, +}; + +static const struct option main_options[] = { + { "socket", required_argument, 0, 's' }, + { "dump ", required_argument, 0, 'd' }, + { 0, 0, 0, 0 } +}; + +static const char *socket_path_option; +static const char *dump_option; + +static const char **optargs[] = { + &socket_path_option, + &dump_option, +}; + +static const char *help[] = { + "Socket path to listen for BTP client\n", + "Use \"on\" to enable hex dump\n", +}; + +static const struct bt_shell_opt opt = { + .options = main_options, + .optno = sizeof(main_options) / sizeof(struct option), + .optstr = "s:d:", + .optarg = optargs, + .help = help, +}; + +int main(int argc, char *argv[]) +{ + int status; + int server_fd; + + bt_shell_init(argc, argv, &opt); + bt_shell_set_menu(&main_menu); + bt_shell_add_submenu(&ad_menu); + bt_shell_add_submenu(&gap_menu); + + if (socket_path_option) + socket_path = g_strdup(socket_path_option); + else + socket_path = g_strdup(DEFAULT_SOCKET_PATH); + + if (dump_option && !strcasecmp(dump_option, "on")) + enable_dump = true; + else + enable_dump = false; + + + btpclientctl = new0(struct btpclientctl, 1); + if (!btpclientctl) { + status = EXIT_FAILURE; + goto error_exit; + } + + advertise_data = new0(struct advertise_data, 1); + if (!advertise_data) { + status = EXIT_FAILURE; + goto error_free_client; + } + + advertise_data->ad_data_len = 0; + advertise_data->scan_data_len = 0; + + bt_shell_attach(fileno(stdin)); + + server_fd = open_socket(socket_path); + if (server_fd < 0) { + status = EXIT_FAILURE; + goto error_free_ad; + } + + btpclientctl->server_fd = server_fd; + + mainloop_add_fd(btpclientctl->server_fd, EPOLLIN, server_callback, + btpclientctl, NULL); + + bt_shell_set_prompt(PROMPT_ON); + + status = bt_shell_run(); + + close(btpclientctl->server_fd); + +error_free_ad: + free(advertise_data); +error_free_client: + free(btpclientctl); +error_exit: + g_free(socket_path); + return status; +} -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2HuUF6+rLF/wbQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:17:35 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id mMTiFa+rLF/DRwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:17:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5CCF5A020E; Fri, 7 Aug 2020 03:17:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726078AbgHGBRV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:17:21 -0400 Received: from mga03.intel.com ([134.134.136.65]:31449 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbgHGBRU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:17:20 -0400 IronPort-SDR: FQD3XSe1QiarS2NroEoqlHumxtjWzcWZfxr70b8ZpJX6srOBCfdCRF79vlarXB1E5HRCmZ7mko JiZzsSNAipdA== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="152936391" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="152936391" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:17:17 -0700 IronPort-SDR: TSyuzHD6ml2jaXtM9ekBHxOHx1FfjghLQG2i46/AyCEIkmVVCNZBkWXd/2uk9VLB/mR1bBMbIp IexxbN19++ig== X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="493876851" Received: from apazhamp-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.82.188]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:17:17 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [PATCH 3/3] btpclient: Fix gap reset not sending response Date: Thu, 6 Aug 2020 18:17:03 -0700 Message-Id: <20200807011703.22087-3-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200807011703.22087-1-tedd.an@linux.intel.com> References: <20200807011703.22087-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 8 X-Rspamd-Score: 1.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5CCF5A020E X-Rspamd-UID: 120b06 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch fixes the GAP reset command to response the default settings after resetting the stack. --- tools/btpclient.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tools/btpclient.c b/tools/btpclient.c index f9c693056..38e326670 100644 --- a/tools/btpclient.c +++ b/tools/btpclient.c @@ -521,6 +521,19 @@ static void reset_unreg_agent_reply(struct l_dbus_proxy *proxy, ag.registered = false; } +static void update_current_settings(struct btp_adapter *adapter, + uint32_t new_settings) +{ + struct btp_new_settings_ev ev; + + adapter->current_settings = new_settings; + + ev.current_settings = L_CPU_TO_LE32(adapter->current_settings); + + btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_NEW_SETTINGS, adapter->index, + sizeof(ev), &ev); +} + static void btp_gap_reset(uint8_t index, const void *param, uint16_t length, void *user_data) { @@ -528,6 +541,7 @@ static void btp_gap_reset(uint8_t index, const void *param, uint16_t length, const struct l_queue_entry *entry; uint8_t status; bool prop; + uint32_t default_settings; if (!adapter) { status = BTP_ERROR_INVALID_INDEX; @@ -570,10 +584,13 @@ static void btp_gap_reset(uint8_t index, const void *param, uint16_t length, goto failed; } - adapter->current_settings = adapter->default_settings; + default_settings = adapter->default_settings; + + update_current_settings(adapter, default_settings); /* TODO for we assume all went well */ - btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_RESET, index, 0, NULL); + btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_RESET, index, + sizeof(default_settings), &default_settings); return; failed: @@ -644,19 +661,6 @@ failed: btp_send_error(btp, BTP_GAP_SERVICE, index, status); } -static void update_current_settings(struct btp_adapter *adapter, - uint32_t new_settings) -{ - struct btp_new_settings_ev ev; - - adapter->current_settings = new_settings; - - ev.current_settings = L_CPU_TO_LE32(adapter->current_settings); - - btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_NEW_SETTINGS, adapter->index, - sizeof(ev), &ev); -} - static void btp_gap_set_connectable(uint8_t index, const void *param, uint16_t length, void *user_data) { -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YL9tMaOwLF/wbQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:38:43 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gBeiL6OwLF933wEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:38:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DBAD1420D3; Fri, 7 Aug 2020 03:38:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726038AbgHGBih (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:38:37 -0400 Received: from mga18.intel.com ([134.134.136.126]:43978 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbgHGBih (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:38:37 -0400 IronPort-SDR: QyEwnpsYG57s9w9/JOM/uMQOAfNy2T47JOsVAKJskj0iNvV/CAAHej7WoesqRjVeB8mcCMiAGA m/i/b82SpDjw== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140558035" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140558035" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:38:36 -0700 IronPort-SDR: PD8tttQWi2/Ra55aAh0VmpofO12MqFE/dKUDAD1IFfRk3S4ulJNgB0WMzhDHsuf2cTUq31n/bu P/noJS2AyUww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="397442060" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga001.fm.intel.com with ESMTP; 06 Aug 2020 18:38:36 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v5 00/10] Mesh Config Server clean up Date: Thu, 6 Aug 2020 18:38:24 -0700 Message-Id: <20200807013834.123263-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 18 X-Rspamd-Score: 2.84 / 15.00 / 200.00 X-Rspamd-Queue-Id: DBAD1420D3 X-Rspamd-UID: 8cf174 v5 - addressed more of Brian's comments. Added missing range checking ******************* v4 - Further fixes in handling Key Refresh Phase Set message ******************* v3 - address Brian's comments ******************* This patch set groups functionality by config messages. Also, fixes the cases where malformed messages should be silently ignored and the situations when incorrect error status is sent in response. Inga Stotland (10): mesh: Clean up handling of config subscription messages mesh: Clean up handling of config model binding messages mesh: Clean up handling of config node identity message mesh: Clean up handling of config publication messages mesh: Clean up handling of config net and app key messages mesh: Clean up handling of config relay messages mesh: Clean up handling of config poll timeout message mesh: Clean up handling of config net transmit messages mesh: Clean up handling of config KR phase messages mesh: Refactor heartbeat pub/sub mesh/cfgmod-server.c | 1198 +++++++++++++++++---------------------- mesh/cfgmod.h | 2 +- mesh/mesh-config-json.c | 12 +- mesh/mesh-config.h | 6 +- mesh/mesh-defs.h | 6 + mesh/model.c | 238 ++++---- mesh/model.h | 21 +- mesh/net.c | 326 +++++++---- mesh/net.h | 54 +- mesh/node.h | 4 - 10 files changed, 924 insertions(+), 943 deletions(-) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cLPYK6iwLF/wbQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:38:48 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id EOMyKqiwLF/vVwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:38:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EA35B420D3; Fri, 7 Aug 2020 03:38:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726058AbgHGBik (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:38:40 -0400 Received: from mga18.intel.com ([134.134.136.126]:43991 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbgHGBij (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:38:39 -0400 IronPort-SDR: qWtHpGPykUKRcTVKxDNNUtQYjg34kjx7QcA71yFFf/JH8vw/7tNC98ec+1UryY3mx/CprY4NUQ TV5ylr6g85jw== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140558038" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140558038" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:38:38 -0700 IronPort-SDR: ct/Py4rrlJObpfK1wWbqZsfffDNGnctWguD15vEmbH0KhEcfu+tdAbRQY0XCMenp4qmBJXnHmK 4l1hA/AK/gSQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="397442071" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga001.fm.intel.com with ESMTP; 06 Aug 2020 18:38:38 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v5 02/10] mesh: Clean up handling of config model binding messages Date: Thu, 6 Aug 2020 18:38:26 -0700 Message-Id: <20200807013834.123263-3-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200807013834.123263-1-inga.stotland@intel.com> References: <20200807013834.123263-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: EA35B420D3 X-Rspamd-UID: 53d091 This modification allows using a single point for sending out the composed status messages by the Config Server. Also, remove unused definitions for binding functions in node.h --- mesh/cfgmod-server.c | 130 ++++++++++++------------------------------- mesh/mesh-defs.h | 3 + mesh/model.c | 20 ++----- mesh/node.h | 4 -- 4 files changed, 45 insertions(+), 112 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 069c25062..992279165 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -112,8 +112,7 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; const uint8_t *pub_addr; uint16_t test_addr; - uint8_t ttl, period; - uint8_t retransmit; + uint8_t ttl, period, retransmit; int status; bool cred_flag; @@ -362,115 +361,56 @@ static uint16_t config_sub_del_all(struct mesh_node *node, const uint8_t *pkt, return n; } -static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t addr, - uint32_t id, uint16_t idx) -{ - size_t n = mesh_model_opcode_set(OP_MODEL_APP_STATUS, msg); - - msg[n++] = status; - l_put_le16(addr, msg + n); - n += 2; - l_put_le16(idx, msg + n); - n += 2; - - if (IS_VENDOR(id)) { - l_put_le16(VENDOR_ID(id), msg + n); - n += 2; - } - - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); -} - -static void model_app_list(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, +static uint16_t model_app_list(struct mesh_node *node, const uint8_t *pkt, uint16_t size) { - uint16_t ele_addr; + uint16_t ele_addr, n, bnd_len; uint32_t id; - uint8_t *status; - uint16_t n; - int result; + int opcode; + opcode = (size == 4) ? OP_MODEL_APP_LIST : OP_VEND_MODEL_APP_LIST; ele_addr = l_get_le16(pkt); - switch (size) { - default: - return; - case 4: - n = mesh_model_opcode_set(OP_MODEL_APP_LIST, msg); - status = msg + n; - id = l_get_le16(pkt + 2); - l_put_le16(ele_addr, msg + 1 + n); - l_put_le16((uint16_t) id, msg + 3 + n); - id = SET_ID(SIG_VENDOR, id); - n += 5; - break; - case 6: - n = mesh_model_opcode_set(OP_VEND_MODEL_APP_LIST, msg); - status = msg + n; - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); + n = mesh_model_opcode_set(opcode, msg); + memcpy(msg + n + 1, pkt, size); - l_put_le16(ele_addr, msg + 1 + n); - l_put_le16((uint16_t) VENDOR_ID(id), msg + 3 + n); - l_put_le16((uint16_t) MODEL_ID(id), msg + 5 + n); - n += 7; - break; - } + id = CFG_GET_ID(size == 6, pkt + 2); - result = mesh_model_get_bindings(node, ele_addr, id, msg + n, - MAX_MSG_LEN - n, &size); - n += size; + msg[n] = mesh_model_get_bindings(node, ele_addr, id, msg + n + 1 + size, + MAX_MSG_LEN - (n + 1 + size), &bnd_len); - if (result >= 0) { - *status = result; - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, - DEFAULT_TTL, false, msg, n); - } + if (msg[n] == MESH_STATUS_SUCCESS) + n += bnd_len; + + n += (size + 1); + return n; } -static bool model_app_bind(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size, - bool unbind) +static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt, + uint16_t size, bool unbind) { - uint16_t ele_addr; + uint16_t ele_addr, idx, n; uint32_t id; - uint16_t idx; - int result; - switch (size) { - default: - return false; - case 6: - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); - break; - case 8: - id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); - break; - } + idx = l_get_le16(pkt + 2); + if (idx > APP_IDX_MAX) + return 0; ele_addr = l_get_le16(pkt); - idx = l_get_le16(pkt + 2); + id = CFG_GET_ID(size == 8, pkt + 4); - if (idx > 0xfff) - return false; + n = mesh_model_opcode_set(OP_MODEL_APP_STATUS, msg); if (unbind) - result = mesh_model_binding_del(node, ele_addr, id, idx); + msg[n] = mesh_model_binding_del(node, ele_addr, id, idx); else - result = mesh_model_binding_add(node, ele_addr, id, idx); + msg[n] = mesh_model_binding_add(node, ele_addr, id, idx); - send_model_app_status(node, net_idx, src, dst, result, ele_addr, - id, idx); + memcpy(msg + n + 1, pkt, size); + n += (size + 1); - return true; + return n; } static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) @@ -703,8 +643,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 1 || pkt[0] > TTL_MASK || pkt[0] == 1) return true; - if (pkt[0] <= TTL_MASK) - node_default_ttl_set(node, pkt[0]); + node_default_ttl_set(node, pkt[0]); /* Fall Through */ case OP_CONFIG_DEFAULT_TTL_GET: @@ -1048,22 +987,25 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_MODEL_APP_BIND: case OP_MODEL_APP_UNBIND: - model_app_bind(node, net_idx, src, dst, pkt, size, - opcode != OP_MODEL_APP_BIND); + if (size != 6 && size != 8) + return true; + + n = model_app_bind(node, pkt, size, + opcode != OP_MODEL_APP_BIND); break; case OP_VEND_MODEL_APP_GET: if (size != 6) return true; - model_app_list(node, net_idx, src, dst, pkt, size); + n = model_app_list(node, pkt, size); break; case OP_MODEL_APP_GET: if (size != 4) return true; - model_app_list(node, net_idx, src, dst, pkt, size); + n = model_app_list(node, pkt, size); break; case OP_CONFIG_HEARTBEAT_PUB_SET: diff --git a/mesh/mesh-defs.h b/mesh/mesh-defs.h index bbde53303..5ade751a3 100644 --- a/mesh/mesh-defs.h +++ b/mesh/mesh-defs.h @@ -105,6 +105,9 @@ #define NET_IDX_INVALID 0xffff #define NET_NID_INVALID 0xff +#define NET_IDX_MAX 0x0fff +#define APP_IDX_MAX 0x0fff + #define APP_IDX_MASK 0x0fff #define APP_IDX_DEV_REMOTE 0x6fff #define APP_IDX_DEV_LOCAL 0x7fff diff --git a/mesh/model.c b/mesh/model.c index 3c9b6577a..90192328f 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -111,13 +111,7 @@ static bool simple_match(const void *a, const void *b) static bool has_binding(struct l_queue *bindings, uint16_t idx) { - const struct l_queue_entry *l; - - for (l = l_queue_get_entries(bindings); l; l = l->next) { - if (L_PTR_TO_UINT(l->data) == idx) - return true; - } - return false; + return l_queue_find(bindings, simple_match, L_UINT_TO_PTR(idx)) != NULL; } static bool find_virt_by_label(const void *a, const void *b) @@ -628,7 +622,6 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, uint16_t app_idx, bool unbind) { struct mesh_model *mod; - bool is_present; int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) @@ -645,12 +638,11 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, if (!appkey_have_key(node_get_net(node), app_idx)) return MESH_STATUS_INVALID_APPKEY; - is_present = has_binding(mod->bindings, app_idx); - - if (!is_present && unbind) - return MESH_STATUS_SUCCESS; - - if (is_present && !unbind) + /* + * If deleting a binding that is not present, return success. + * If adding a binding that already exists, return success. + */ + if (unbind ^ has_binding(mod->bindings, app_idx)) return MESH_STATUS_SUCCESS; if (unbind) { diff --git a/mesh/node.h b/mesh/node.h index 47c998530..7874b8692 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -49,10 +49,6 @@ const uint8_t *node_get_token(struct mesh_node *node); const uint8_t *node_get_device_key(struct mesh_node *node); void node_set_num_elements(struct mesh_node *node, uint8_t num_ele); uint8_t node_get_num_elements(struct mesh_node *node); -bool node_add_binding(struct mesh_node *node, uint8_t ele_idx, - uint32_t model_id, uint16_t app_idx); -bool node_del_binding(struct mesh_node *node, uint8_t ele_idx, - uint32_t model_id, uint16_t app_idx); uint8_t node_default_ttl_get(struct mesh_node *node); bool node_default_ttl_set(struct mesh_node *node, uint8_t ttl); bool node_set_sequence_number(struct mesh_node *node, uint32_t seq); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OA+VD66wLF9qfQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:38:54 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id kGjqDa6wLF+jywEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:38:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D40F5420E5; Fri, 7 Aug 2020 03:38:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726175AbgHGBik (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:38:40 -0400 Received: from mga18.intel.com ([134.134.136.126]:43978 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbgHGBik (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:38:40 -0400 IronPort-SDR: Tmvfj9axfnktOp+ajt6UmTZxwtbdtxoFAXeuCH5bx0CrlQQIET2HhLA9qk7I7gnug58qsZTzxU T7hhpW30WVxQ== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140558036" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140558036" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:38:37 -0700 IronPort-SDR: KdEJ5/T3oKUD1lR3qj/n+0vRYJFE5O78KpwGzuoEr/jm7867PtHjCl6bUmU/TTzkd9Y/Z7SjPc hdPQEQZ5i1fg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="397442067" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga001.fm.intel.com with ESMTP; 06 Aug 2020 18:38:37 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v5 01/10] mesh: Clean up handling of config subscription messages Date: Thu, 6 Aug 2020 18:38:25 -0700 Message-Id: <20200807013834.123263-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200807013834.123263-1-inga.stotland@intel.com> References: <20200807013834.123263-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: D40F5420E5 X-Rspamd-UID: 359b85 This provides better functional grouping based on whether a group or a virtual label is used for the subscription address. Also, use a single point for sending out the composed Config Server status messages. --- mesh/cfgmod-server.c | 344 +++++++++++++++++----------------------- mesh/mesh-config-json.c | 12 +- mesh/mesh-config.h | 6 +- mesh/model.c | 211 ++++++++++++++---------- mesh/model.h | 21 ++- 5 files changed, 296 insertions(+), 298 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 7672ad3b6..069c25062 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -32,6 +32,10 @@ #include "mesh/mesh-config.h" #include "mesh/cfgmod.h" +#define CFG_GET_ID(vendor, pkt) ((vendor) ? \ + (SET_ID(l_get_le16((pkt)), l_get_le16((pkt) + 2))) : \ + (SET_ID(SIG_VENDOR, l_get_le16(pkt)))) + /* Supported composition pages, sorted high to low */ /* Only page 0 is currently supported */ static const uint8_t supported_pages[] = { @@ -185,237 +189,177 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, idx, cred_flag, ttl, period, retransmit); } -static void send_sub_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, - uint16_t addr, uint32_t id) +static uint16_t cfg_sub_get_msg(struct mesh_node *node, const uint8_t *pkt, + uint16_t size) { - int n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - - msg[n++] = status; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(addr, msg + n); - n += 2; - - if (IS_VENDOR(id)) { - l_put_le16(VENDOR_ID(id), msg + n); - l_put_le16(MODEL_ID(id), msg + n + 2); - n += 4; - } else { - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - } - - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); -} - -static bool config_sub_get(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size) -{ - uint16_t ele_addr; + uint16_t ele_addr, n, sub_len; uint32_t id; - uint16_t n = 0; - int status; - uint8_t *msg_status; - uint16_t buf_size; + int opcode; + bool vendor = (size == 6); - /* Incoming message has already been size-checked */ ele_addr = l_get_le16(pkt); + id = CFG_GET_ID(vendor, pkt + 2); + opcode = vendor ? OP_CONFIG_VEND_MODEL_SUB_LIST : + OP_CONFIG_MODEL_SUB_LIST; + n = mesh_model_opcode_set(opcode, msg); + memcpy(msg + n + 1, pkt, size); - switch (size) { - default: - l_debug("Bad length %d", size); - return false; - - case 4: - id = l_get_le16(pkt + 2); - n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_LIST, msg); - msg_status = msg + n; - msg[n++] = 0; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(id, msg + n); - n += 2; - id = SET_ID(SIG_VENDOR, id); - break; - - case 6: - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - n = mesh_model_opcode_set(OP_CONFIG_VEND_MODEL_SUB_LIST, msg); - msg_status = msg + n; - msg[n++] = 0; - l_put_le16(ele_addr, msg + n); - n += 2; - l_put_le16(VENDOR_ID(id), msg + n); - n += 2; - l_put_le16(MODEL_ID(id), msg + n); - n += 2; - break; - } - - buf_size = sizeof(uint16_t) * MAX_GRP_PER_MOD; - status = mesh_model_sub_get(node, ele_addr, id, msg + n, buf_size, - &size); - - if (status == MESH_STATUS_SUCCESS) - n += size; + msg[n] = mesh_model_sub_get(node, ele_addr, id, msg + n + 1 + size, + MAX_MSG_LEN - (n + 1 + size), &sub_len); - *msg_status = (uint8_t) status; + if (msg[n] == MESH_STATUS_SUCCESS) + n += sub_len; - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); - return true; + n += (size + 1); + return n; } -static bool save_config_sub(struct mesh_node *node, uint16_t ele_addr, - uint32_t id, bool vendor, - const uint8_t *addr, bool virt, - uint16_t grp, uint32_t opcode) +static bool save_cfg_sub(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, bool vendor, const uint8_t *label, + bool virt, uint16_t grp, uint32_t opcode) { + struct mesh_config *cfg = node_config_get(node); struct mesh_config_sub db_sub = { .virt = virt, - .src.addr = grp + .addr.grp = grp }; + id = (vendor) ? id : MODEL_ID(id); + if (virt) - memcpy(db_sub.src.virt_addr, addr, 16); + memcpy(db_sub.addr.label, label, 16); + + if (opcode == OP_CONFIG_MODEL_SUB_VIRT_DELETE && + opcode == OP_CONFIG_MODEL_SUB_DELETE) + return mesh_config_model_sub_del(cfg, ele_addr, id, vendor, + &db_sub); if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE || opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) - mesh_config_model_sub_del_all(node_config_get(node), ele_addr, - vendor ? id : MODEL_ID(id), - vendor); - if (opcode != OP_CONFIG_MODEL_SUB_VIRT_DELETE && - opcode != OP_CONFIG_MODEL_SUB_DELETE) - return mesh_config_model_sub_add(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_sub); - else - return mesh_config_model_sub_del(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_sub); + if (!mesh_config_model_sub_del_all(cfg, ele_addr, id, vendor)) + return false; + + return mesh_config_model_sub_add(cfg, ele_addr, id, vendor, &db_sub); } -static void config_sub_set(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size, - bool virt, uint32_t opcode) +static uint16_t cfg_sub_add_msg(struct mesh_node *node, const uint8_t *pkt, + bool vendor, uint32_t opcode) { - uint16_t grp, ele_addr; + uint16_t addr, ele_addr, n; uint32_t id; - const uint8_t *addr = NULL; - int status = MESH_STATUS_SUCCESS; - bool vendor = false; - switch (size) { - default: - l_error("Bad length: %d", size); - return; - case 4: - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) - return; + addr = l_get_le16(pkt + 2); - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); - break; - case 6: - if (virt) - return; + if (!IS_GROUP(addr)) + return 0; - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 4)); - } else { - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - vendor = true; - } + ele_addr = l_get_le16(pkt); + id = CFG_GET_ID(vendor, pkt + 4); - break; - case 8: - if (virt) - return; + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - id = SET_ID(l_get_le16(pkt + 4), l_get_le16(pkt + 6)); - vendor = true; - break; - case 20: - if (!virt) - return; + if (opcode == OP_CONFIG_MODEL_SUB_OVERWRITE) + msg[n] = mesh_model_sub_ovrt(node, ele_addr, id, addr); + else if (opcode == OP_CONFIG_MODEL_SUB_ADD) + msg[n] = mesh_model_sub_add(node, ele_addr, id, addr); + else + msg[n] = mesh_model_sub_del(node, ele_addr, id, addr); - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 18)); - break; - case 22: - if (!virt) - return; + if (msg[n] == MESH_STATUS_SUCCESS && + !save_cfg_sub(node, ele_addr, id, vendor, NULL, false, + addr, opcode)) + msg[n] = MESH_STATUS_STORAGE_FAIL; - vendor = true; - id = SET_ID(l_get_le16(pkt + 18), l_get_le16(pkt + 20)); - break; + if (vendor) { + memcpy(msg + n + 1, pkt, 8); + n += 9; + } else { + memcpy(msg + n + 1, pkt, 6); + n += 7; } + return n; +} + +static uint16_t cfg_virt_sub_add_msg(struct mesh_node *node, const uint8_t *pkt, + bool vendor, uint32_t opcode) +{ + uint16_t addr, ele_addr, n; + uint32_t id; + const uint8_t *label; + + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); + ele_addr = l_get_le16(pkt); + label = pkt + 2; + id = CFG_GET_ID(vendor, pkt + 18); + + if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE) + msg[n] = mesh_model_virt_sub_ovrt(node, ele_addr, id, label, + &addr); + else if (opcode == OP_CONFIG_MODEL_SUB_VIRT_ADD) + msg[n] = mesh_model_virt_sub_add(node, ele_addr, id, label, + &addr); + else + msg[n] = mesh_model_virt_sub_del(node, ele_addr, id, label, + &addr); - if (opcode != OP_CONFIG_MODEL_SUB_DELETE_ALL) { - addr = pkt + 2; - grp = l_get_le16(addr); - } else - grp = UNASSIGNED_ADDRESS; + if (msg[n] == MESH_STATUS_SUCCESS && + !save_cfg_sub(node, ele_addr, id, vendor, + label, true, addr, opcode)) + msg[n] = MESH_STATUS_STORAGE_FAIL; - switch (opcode) { - default: - l_debug("Bad opcode: %x", opcode); - return; + l_put_le16(ele_addr, msg + n + 1); + l_put_le16(addr, msg + n + 3); - case OP_CONFIG_MODEL_SUB_DELETE_ALL: - status = mesh_model_sub_del_all(node, ele_addr, id); + if (vendor) { + l_put_le16(VENDOR_ID(id), msg + n + 5); + l_put_le16(MODEL_ID(id), msg + n + 7); + n += 9; + } else { + l_put_le16(MODEL_ID(id), msg + n + 5); + n += 7; + } - if (status == MESH_STATUS_SUCCESS) - mesh_config_model_sub_del_all(node_config_get(node), - ele_addr, vendor ? id : MODEL_ID(id), - vendor); - break; + return n; +} - case OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_OVERWRITE: - status = mesh_model_sub_ovr(node, ele_addr, id, - addr, virt, &grp); +static uint16_t config_sub_del_all(struct mesh_node *node, const uint8_t *pkt, + bool vendor) +{ + uint16_t ele_addr, n, grp = UNASSIGNED_ADDRESS; + uint32_t id; - if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, id, vendor, addr, - virt, grp, opcode); - break; - case OP_CONFIG_MODEL_SUB_VIRT_ADD: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_ADD: - status = mesh_model_sub_add(node, ele_addr, id, - addr, virt, &grp); + n = mesh_model_opcode_set(OP_CONFIG_MODEL_SUB_STATUS, msg); - if (status == MESH_STATUS_SUCCESS && - !save_config_sub(node, ele_addr, id, vendor, - addr, virt, grp, opcode)) - status = MESH_STATUS_STORAGE_FAIL; + ele_addr = l_get_le16(pkt); + id = CFG_GET_ID(vendor, pkt + 2); - break; - case OP_CONFIG_MODEL_SUB_VIRT_DELETE: - grp = UNASSIGNED_ADDRESS; - /* Fall Through */ - case OP_CONFIG_MODEL_SUB_DELETE: - status = mesh_model_sub_del(node, ele_addr, id, addr, virt, - &grp); + msg[n] = mesh_model_sub_del_all(node, ele_addr, id); - if (status == MESH_STATUS_SUCCESS) - save_config_sub(node, ele_addr, id, vendor, addr, - virt, grp, opcode); + if (msg[n] == MESH_STATUS_SUCCESS) { + struct mesh_config *cfg = node_config_get(node); - break; + if (!mesh_config_model_sub_del_all(cfg, ele_addr, + vendor ? id : MODEL_ID(id), + vendor)) + msg[n] = MESH_STATUS_STORAGE_FAIL; + } + + l_put_le16(ele_addr, msg + n + 1); + l_put_le16(grp, msg + n + 3); + + if (vendor) { + l_put_le16(VENDOR_ID(id), msg + n + 5); + l_put_le16(MODEL_ID(id), msg + n + 7); + n += 9; + } else { + l_put_le16(MODEL_ID(id), msg + n + 5); + n += 7; } - send_sub_status(node, net_idx, src, dst, status, ele_addr, grp, id); + return n; } static void send_model_app_status(struct mesh_node *node, uint16_t net_idx, @@ -797,28 +741,38 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_VEND_MODEL_SUB_GET: if (size != 6) return true; - - config_sub_get(node, net_idx, src, dst, pkt, size); - break; + /* Fall Through */ case OP_CONFIG_MODEL_SUB_GET: - if (size != 4) + if (size != 4 && opcode == OP_CONFIG_MODEL_SUB_GET) return true; - config_sub_get(node, net_idx, src, dst, pkt, size); + n = cfg_sub_get_msg(node, pkt, size); break; case OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE: case OP_CONFIG_MODEL_SUB_VIRT_DELETE: case OP_CONFIG_MODEL_SUB_VIRT_ADD: - virt = true; - /* Fall Through */ + if (size != 20 && size != 22) + return true; + + n = cfg_virt_sub_add_msg(node, pkt, size == 22, opcode); + break; + case OP_CONFIG_MODEL_SUB_OVERWRITE: case OP_CONFIG_MODEL_SUB_DELETE: case OP_CONFIG_MODEL_SUB_ADD: + if (size != 6 && size != 8) + return true; + + n = cfg_sub_add_msg(node, pkt, size == 8, opcode); + break; + case OP_CONFIG_MODEL_SUB_DELETE_ALL: - config_sub_set(node, net_idx, src, dst, pkt, size, virt, - opcode); + if (size != 4 && size != 6) + return true; + + n = config_sub_del_all(node, pkt, size == 6); break; case OP_CONFIG_RELAY_SET: diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index deb0019f9..a40f92c01 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1069,11 +1069,11 @@ static bool parse_model_subscriptions(json_object *jsubs, switch (len) { case 4: - if (sscanf(str, "%04hx", &subs[i].src.addr) != 1) + if (sscanf(str, "%04hx", &subs[i].addr.grp) != 1) goto fail; break; case 32: - if (!str2hex(str, len, subs[i].src.virt_addr, 16)) + if (!str2hex(str, len, subs[i].addr.label, 16)) goto fail; subs[i].virt = true; break; @@ -2068,10 +2068,10 @@ bool mesh_config_model_sub_add(struct mesh_config *cfg, uint16_t ele_addr, return false; if (!sub->virt) { - snprintf(buf, 5, "%4.4x", sub->src.addr); + snprintf(buf, 5, "%4.4x", sub->addr.grp); len = 4; } else { - hex2str(sub->src.virt_addr, 16, buf, 33); + hex2str(sub->addr.label, 16, buf, 33); len = 32; } @@ -2122,10 +2122,10 @@ bool mesh_config_model_sub_del(struct mesh_config *cfg, uint16_t ele_addr, return true; if (!sub->virt) { - snprintf(buf, 5, "%4.4x", sub->src.addr); + snprintf(buf, 5, "%4.4x", sub->addr.grp); len = 4; } else { - hex2str(sub->src.virt_addr, 16, buf, 33); + hex2str(sub->addr.label, 16, buf, 33); len = 32; } diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 7dfa9f20c..f15f3f376 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -24,9 +24,9 @@ struct mesh_config; struct mesh_config_sub { bool virt; union { - uint16_t addr; - uint8_t virt_addr[16]; - } src; + uint16_t grp; + uint8_t label[16]; + } addr; }; struct mesh_config_pub { diff --git a/mesh/model.c b/mesh/model.c index ef7668147..3c9b6577a 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -664,7 +664,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } - if (l_queue_length(mod->bindings) >= MAX_BINDINGS) + if (l_queue_length(mod->bindings) >= MAX_MODEL_BINDINGS) return MESH_STATUS_INSUFF_RESOURCES; if (!mesh_config_model_binding_add(node_config_get(node), addr, @@ -737,7 +737,7 @@ static int set_virt_pub(struct mesh_model *mod, const uint8_t *label, } static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod, - const uint8_t *label, uint16_t *dst) + const uint8_t *label, uint16_t *addr) { struct mesh_virtual *virt = l_queue_find(mod->virtuals, find_virt_by_label, label); @@ -745,40 +745,35 @@ static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod, if (!virt) { virt = add_virtual(label); if (!virt) - return MESH_STATUS_STORAGE_FAIL; + return MESH_STATUS_INSUFF_RESOURCES; l_queue_push_head(mod->virtuals, virt); mesh_net_dst_reg(net, virt->addr); l_debug("Added virtual sub addr %4.4x", virt->addr); } - if (dst) - *dst = virt->addr; + if (addr) + *addr = virt->addr; return MESH_STATUS_SUCCESS; } static int add_sub(struct mesh_net *net, struct mesh_model *mod, - const uint8_t *group, bool b_virt, uint16_t *dst) + uint16_t addr) { - uint16_t grp; - - if (b_virt) - return add_virt_sub(net, mod, group, dst); - - grp = l_get_le16(group); - if (dst) - *dst = grp; + if (!mod->subs) + mod->subs = l_queue_new(); - if (!l_queue_find(mod->subs, simple_match, L_UINT_TO_PTR(grp))) { + if (l_queue_find(mod->subs, simple_match, L_UINT_TO_PTR(addr))) + return MESH_STATUS_SUCCESS; - if (!mod->subs) - mod->subs = l_queue_new(); + if ((l_queue_length(mod->subs) + l_queue_length(mod->virtuals)) >= + MAX_MODEL_SUBS) + return MESH_STATUS_INSUFF_RESOURCES; - l_queue_push_tail(mod->subs, L_UINT_TO_PTR(grp)); - mesh_net_dst_reg(net, grp); - l_debug("Added group subscription %4.4x", grp); - } + l_queue_push_tail(mod->subs, L_UINT_TO_PTR(addr)); + mesh_net_dst_reg(net, addr); + l_debug("Added group subscription %4.4x", addr); return MESH_STATUS_SUCCESS; } @@ -1454,8 +1449,8 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { struct mesh_model *mod; int status, ele_idx = node_get_element_idx(node, addr); @@ -1470,7 +1465,35 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - status = add_sub(node_get_net(node), mod, group, is_virt, dst); + status = add_sub(node_get_net(node), mod, addr); + if (status != MESH_STATUS_SUCCESS) + return status; + + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); + + return MESH_STATUS_SUCCESS; +} + +int mesh_model_virt_sub_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *pub_addr) +{ + struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; + + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + + status = add_virt_sub(node_get_net(node), mod, label, pub_addr); if (status != MESH_STATUS_SUCCESS) return status; @@ -1482,12 +1505,11 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { - struct l_queue *virtuals, *subs; struct mesh_model *mod; - int status, ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1499,36 +1521,39 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - subs = mod->subs; - virtuals = mod->virtuals; - mod->subs = l_queue_new(); - mod->virtuals = l_queue_new(); + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); - if (!mod->subs || !mod->virtuals) - return MESH_STATUS_INSUFF_RESOURCES; + add_sub(node_get_net(node), mod, addr); - status = add_sub(node_get_net(node), mod, group, is_virt, dst); + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); - if (status != MESH_STATUS_SUCCESS) { - /* Adding new group failed, so revert to old lists */ - l_queue_destroy(mod->subs, NULL); - mod->subs = subs; - l_queue_destroy(mod->virtuals, unref_virt); - mod->virtuals = virtuals; - } else { - const struct l_queue_entry *entry; - struct mesh_net *net = node_get_net(node); + return MESH_STATUS_SUCCESS; +} + +int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr) +{ + struct mesh_model *mod; + int status, ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; - entry = l_queue_get_entries(subs); + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; - for (; entry; entry = entry->next) - mesh_net_dst_unreg(net, - (uint16_t) L_PTR_TO_UINT(entry->data)); + l_queue_clear(mod->subs, NULL); + l_queue_clear(mod->virtuals, unref_virt); - /* Destroy old lists */ - l_queue_destroy(subs, NULL); - l_queue_destroy(virtuals, unref_virt); - } + status = add_virt_sub(node_get_net(node), mod, label, addr); if (!mod->cbs) /* External models */ @@ -1537,10 +1562,9 @@ int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, return status; } -int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *group, bool is_virt, uint16_t *dst) +int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr) { - uint16_t grp; struct mesh_model *mod; int ele_idx = node_get_element_idx(node, addr); @@ -1554,26 +1578,47 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t addr, uint32_t id, if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) return MESH_STATUS_NOT_SUB_MOD; - if (is_virt) { - struct mesh_virtual *virt; + if (l_queue_remove(mod->subs, L_UINT_TO_PTR(addr))) { + mesh_net_dst_unreg(node_get_net(node), addr); - virt = l_queue_find(mod->virtuals, find_virt_by_label, group); - if (virt) { - l_queue_remove(mod->virtuals, virt); - grp = virt->addr; - unref_virt(virt); - } else { - if (!mesh_crypto_virtual_addr(group, &grp)) - return MESH_STATUS_STORAGE_FAIL; - } - } else { - grp = l_get_le16(group); + if (!mod->cbs) + /* External models */ + cfg_update_model_subs(node, ele_idx, mod); } - *dst = grp; + return MESH_STATUS_SUCCESS; +} - if (l_queue_remove(mod->subs, L_UINT_TO_PTR(grp))) { - mesh_net_dst_unreg(node_get_net(node), grp); +int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr) +{ + struct mesh_model *mod; + struct mesh_virtual *virt; + int ele_idx = node_get_element_idx(node, ele_addr); + + if (ele_idx < 0) + return MESH_STATUS_INVALID_ADDRESS; + + mod = get_model(node, (uint8_t) ele_idx, id); + if (!mod) + return MESH_STATUS_INVALID_MODEL; + + if (!mod->sub_enabled || (mod->cbs && !(mod->cbs->sub))) + return MESH_STATUS_NOT_SUB_MOD; + + virt = l_queue_remove_if(mod->virtuals, find_virt_by_label, label); + + if (virt) { + *addr = virt->addr; + unref_virt(virt); + } else { + *addr = UNASSIGNED_ADDRESS; + return MESH_STATUS_SUCCESS; + } + + if (l_queue_remove(mod->subs, L_UINT_TO_PTR(*addr))) { + mesh_net_dst_unreg(node_get_net(node), *addr); if (!mod->cbs) /* External models */ @@ -1614,9 +1659,9 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, struct mesh_config_pub *pub = db_mod->pub; uint32_t i; - if (db_mod->num_bindings > MAX_BINDINGS) { + if (db_mod->num_bindings > MAX_MODEL_BINDINGS) { l_warn("Binding list too long %u (max %u)", - db_mod->num_bindings, MAX_BINDINGS); + db_mod->num_bindings, MAX_MODEL_BINDINGS); return NULL; } @@ -1670,22 +1715,12 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, return mod; for (i = 0; i < db_mod->num_subs; i++) { - uint16_t group; - uint8_t *src; + struct mesh_config_sub *sub = &db_mod->subs[i]; - /* - * To keep calculations for virtual label coherent, - * convert to little endian. - */ - l_put_le16(db_mod->subs[i].src.addr, &group); - src = db_mod->subs[i].virt ? db_mod->subs[i].src.virt_addr : - (uint8_t *) &group; - - if (add_sub(net, mod, src, db_mod->subs[i].virt, NULL) != - MESH_STATUS_SUCCESS) { - mesh_model_free(mod); - return NULL; - } + if (!sub->virt) + add_sub(net, mod, sub->addr.grp); + else + add_virt_sub(net, mod, sub->addr.label, NULL); } return mod; diff --git a/mesh/model.h b/mesh/model.h index 0d8dddf92..3221379af 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -19,8 +19,8 @@ struct mesh_model; -#define MAX_BINDINGS 10 -#define MAX_GRP_PER_MOD 10 +#define MAX_MODEL_BINDINGS 10 +#define MAX_MODEL_SUBS 10 #define ACTION_ADD 1 #define ACTION_UPDATE 2 @@ -89,12 +89,21 @@ int mesh_model_get_bindings(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_sz, uint16_t *len); int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); + uint16_t grp); +int mesh_model_virt_sub_add(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); + uint16_t grp); +int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id); -int mesh_model_sub_ovr(struct mesh_node *node, uint16_t addr, uint32_t id, - const uint8_t *grp, bool b_virt, uint16_t *dst); +int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, + uint16_t addr); +int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, + uint32_t id, const uint8_t *label, + uint16_t *addr); int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size); uint16_t mesh_model_cfg_blk(uint8_t *pkt); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0HURCLOwLF9qfQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:38:59 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gMuABrOwLF9LTAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:38:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5FA01420E5; Fri, 7 Aug 2020 03:38:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726197AbgHGBil (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:38:41 -0400 Received: from mga18.intel.com ([134.134.136.126]:43978 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbgHGBik (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:38:40 -0400 IronPort-SDR: ZzcnPh6Lt501SNsJPhdJR/EhXTcvz6rPyOaqZMM8jKe//6kssTcu3mCxhYH+UHLwDFZD1jMQpE AT7HZ2rXm09A== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140558041" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140558041" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:38:40 -0700 IronPort-SDR: Krc5OgDgSfq50jRfe6RvxcaJaTEqj73WRjAlWjHkYgFY+BZkfqZz9/zQlmi0uD9MwwgNSukT1U JmDe9zPR+IkA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="397442078" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga001.fm.intel.com with ESMTP; 06 Aug 2020 18:38:39 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v5 04/10] mesh: Clean up handling of config publication messages Date: Thu, 6 Aug 2020 18:38:28 -0700 Message-Id: <20200807013834.123263-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200807013834.123263-1-inga.stotland@intel.com> References: <20200807013834.123263-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5FA01420E5 X-Rspamd-UID: 8d0f33 This modification allows using a single point for sending out the composed status messages by the Config Server. Also, return Feature Not Supported errror code when credential flag is set, but the node does not support LPN feature --- mesh/cfgmod-server.c | 99 ++++++++++++++++++-------------------------- mesh/model.c | 7 +++- mesh/net.h | 2 - 3 files changed, 46 insertions(+), 62 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 82938dc83..6ed5800c0 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -32,6 +32,8 @@ #include "mesh/mesh-config.h" #include "mesh/cfgmod.h" +#define CREDFLAG_MASK 0x1000 + #define CFG_GET_ID(vendor, pkt) ((vendor) ? \ (SET_ID(l_get_le16((pkt)), l_get_le16((pkt) + 2))) : \ (SET_ID(SIG_VENDOR, l_get_le16(pkt)))) @@ -44,11 +46,9 @@ static const uint8_t supported_pages[] = { static uint8_t msg[MAX_MSG_LEN]; -static void send_pub_status(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - uint8_t status, uint16_t ele_addr, uint32_t id, - uint16_t pub_addr, uint16_t idx, bool cred_flag, - uint8_t ttl, uint8_t period, uint8_t retransmit) +static uint16_t set_pub_status(uint8_t status, uint16_t ele_addr, uint32_t id, + uint16_t pub_addr, uint16_t idx, bool cred_flag, + uint8_t ttl, uint8_t period, uint8_t retransmit) { size_t n; @@ -72,46 +72,36 @@ static void send_pub_status(struct mesh_node *node, uint16_t net_idx, n += 4; } - mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, DEFAULT_TTL, - false, msg, n); + return n; } -static void config_pub_get(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, uint16_t size) +static uint16_t config_pub_get(struct mesh_node *node, const uint8_t *pkt, + bool vendor) { uint32_t id; uint16_t ele_addr; struct mesh_model_pub *pub; int status; - if (size == 4) { - id = SET_ID(SIG_VENDOR, l_get_le16(pkt + 2)); - } else if (size == 6) { - id = SET_ID(l_get_le16(pkt + 2), l_get_le16(pkt + 4)); - } else - return; - ele_addr = l_get_le16(pkt); + id = CFG_GET_ID(vendor, pkt + 2); + pub = mesh_model_pub_get(node, ele_addr, id, &status); if (pub && status == MESH_STATUS_SUCCESS) - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, pub->addr, pub->idx, pub->credential, - pub->ttl, pub->period, pub->retransmit); + return set_pub_status(status, ele_addr, id, pub->addr, pub->idx, + pub->credential, pub->ttl, pub->period, + pub->retransmit); else - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, 0, 0, 0, 0, 0, 0); + return set_pub_status(status, ele_addr, id, 0, 0, 0, 0, 0, 0); } -static void config_pub_set(struct mesh_node *node, uint16_t net_idx, - uint16_t src, uint16_t dst, - const uint8_t *pkt, bool virt, bool vendor) +static uint16_t config_pub_set(struct mesh_node *node, const uint8_t *pkt, + bool virt, bool vendor) { uint32_t id; - uint16_t ele_addr, idx, ota = UNASSIGNED_ADDRESS; + uint16_t ele_addr, idx, pub_dst; const uint8_t *pub_addr; - uint16_t test_addr; uint8_t ttl, period, retransmit; int status; bool cred_flag; @@ -119,42 +109,35 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, ele_addr = l_get_le16(pkt); pub_addr = pkt + 2; - pkt += (virt ? 14 : 0); + pub_dst = l_get_le16(pub_addr); - idx = l_get_le16(pkt + 4); - ttl = pkt[6]; - period = pkt[7]; - retransmit = pkt[8]; - id = l_get_le16(pkt + 9); + if (!virt && IS_VIRTUAL(pub_dst)) + return 0; - if (!vendor) - id = SET_ID(SIG_VENDOR, id); - else - id = SET_ID(id, l_get_le16(pkt + 11)); + pkt += (virt ? 14 : 0); - /* Don't accept virtual seeming addresses */ - test_addr = l_get_le16(pub_addr); - if (!virt && IS_VIRTUAL(test_addr)) - return; + idx = l_get_le16(pkt + 4); + if (idx > CREDFLAG_MASK) + return 0; cred_flag = !!(CREDFLAG_MASK & idx); idx &= APP_IDX_MASK; + ttl = pkt[6]; + period = pkt[7]; + retransmit = pkt[8]; + id = CFG_GET_ID(vendor, pkt + 9); status = mesh_model_pub_set(node, ele_addr, id, pub_addr, idx, cred_flag, ttl, period, retransmit, - virt, &ota); - - l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, mod: %x, idx: %3.3x", - status, ele_addr, ota, id, idx); + virt, &pub_dst); - if (status != MESH_STATUS_SUCCESS) { - send_pub_status(node, net_idx, src, dst, status, ele_addr, - id, 0, 0, 0, 0, 0, 0); + l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, id: %x, idx: %3.3x", + status, ele_addr, pub_dst, id, idx); - return; - } + if (status != MESH_STATUS_SUCCESS) + return set_pub_status(status, ele_addr, id, 0, 0, 0, 0, 0, 0); - if (IS_UNASSIGNED(test_addr) && !virt) { + if (IS_UNASSIGNED(pub_dst) && !virt) { ttl = period = idx = 0; /* Remove model publication from config file */ @@ -165,7 +148,7 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, } else { struct mesh_config_pub db_pub = { .virt = virt, - .addr = ota, + .addr = pub_dst, .idx = idx, .ttl = ttl, .credential = cred_flag, @@ -180,12 +163,12 @@ static void config_pub_set(struct mesh_node *node, uint16_t net_idx, /* Save model publication to config file */ if (!mesh_config_model_pub_add(node_config_get(node), ele_addr, vendor ? id : MODEL_ID(id), - vendor, &db_pub)) + vendor, &db_pub)) status = MESH_STATUS_STORAGE_FAIL; } - send_pub_status(node, net_idx, src, dst, status, ele_addr, id, ota, - idx, cred_flag, ttl, period, retransmit); + return set_pub_status(status, ele_addr, id, pub_dst, idx, cred_flag, + ttl, period, retransmit); } static uint16_t cfg_sub_get_msg(struct mesh_node *node, const uint8_t *pkt, @@ -667,14 +650,14 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (!virt && (size != 11 && size != 13)) return true; - config_pub_set(node, net_idx, src, dst, pkt, virt, - size == 13 || size == 27); + n = config_pub_set(node, pkt, virt, size == 13 || size == 27); break; case OP_CONFIG_MODEL_PUB_GET: if (size != 4 && size != 6) return true; - config_pub_get(node, net_idx, src, dst, pkt, size); + + n = config_pub_get(node, pkt, size == 6); break; case OP_CONFIG_VEND_MODEL_SUB_GET: diff --git a/mesh/model.c b/mesh/model.c index 90192328f..c6ca0db47 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -1076,7 +1076,7 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *pub_addr, uint16_t idx, bool cred_flag, uint8_t ttl, uint8_t period, uint8_t retransmit, - bool is_virt, uint16_t *dst) + bool is_virt, uint16_t *pub_dst) { struct mesh_model *mod; int status, ele_idx = node_get_element_idx(node, addr); @@ -1103,6 +1103,9 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_SUCCESS; } + if (cred_flag && node_lpn_mode_get(node) != MESH_MODE_ENABLED) + return MESH_STATUS_FEATURE_NO_SUPPORT; + /* Check if the old publication destination is a virtual label */ if (mod->pub && mod->pub->virt) { unref_virt(mod->pub->virt); @@ -1116,7 +1119,7 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, status = set_virt_pub(mod, pub_addr, idx, cred_flag, ttl, period, retransmit); - *dst = mod->pub->addr; + *pub_dst = mod->pub->addr; if (status != MESH_STATUS_SUCCESS) return status; diff --git a/mesh/net.h b/mesh/net.h index 7117f1a47..2673b895a 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -32,8 +32,6 @@ struct mesh_node; #define CTL 0x80 -#define CREDFLAG_MASK 0x1000 - #define KEY_CACHE_SIZE 64 #define FRND_CACHE_MAX 32 -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UM+cObewLF/wbQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:39:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id KLDRN7ewLF/vVwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:39:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3D45C420F2; Fri, 7 Aug 2020 03:38:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbgHGBim (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:38:42 -0400 Received: from mga18.intel.com ([134.134.136.126]:44001 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726055AbgHGBil (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:38:41 -0400 IronPort-SDR: 20VQxvOQKB9lmPCP++Kwmj2QoYb+PiuACJm2YK93i+kgWmersfuUv3C8H6CXfeRuOgW/8l23iU EhEC4VeasN7Q== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140558042" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140558042" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:38:40 -0700 IronPort-SDR: ciAcmXg7ns3jkrU8LZSFKvvTUkIWhSuEKautbb0W7K7oBtP1QKYjQ0ZlurvlPLha7T64Z1APRb 4nPcP3Hv0ogw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="397442082" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga001.fm.intel.com with ESMTP; 06 Aug 2020 18:38:40 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v5 05/10] mesh: Clean up handling of config net and app key messages Date: Thu, 6 Aug 2020 18:38:29 -0700 Message-Id: <20200807013834.123263-6-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200807013834.123263-1-inga.stotland@intel.com> References: <20200807013834.123263-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 15 X-Rspamd-Score: 2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3D45C420F2 X-Rspamd-UID: b1213e This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 155 +++++++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 72 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 6ed5800c0..2797de8ab 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -547,6 +547,81 @@ static void node_reset(void *user_data) node_remove(node); } +static uint16_t cfg_appkey_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint16_t n_idx, a_idx, n; + struct mesh_net *net = node_get_net(node); + + n_idx = l_get_le16(pkt) & 0xfff; + if (n_idx > NET_IDX_MAX) + return 0; + + a_idx = l_get_le16(pkt + 1) >> 4; + if (a_idx > APP_IDX_MAX) + return 0; + + n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); + + if (opcode == OP_APPKEY_ADD) + msg[n] = appkey_key_add(net, n_idx, a_idx, pkt + 3); + else if (opcode == OP_APPKEY_UPDATE) + msg[n] = appkey_key_update(net, n_idx, a_idx, pkt + 3); + else + msg[n] = appkey_key_delete(net, n_idx, a_idx); + + l_debug("AppKey Command %s: Net_Idx %3.3x, App_Idx %3.3x", + (msg[n] == MESH_STATUS_SUCCESS) ? "success" : "fail", + n_idx, a_idx); + + memcpy(msg + n + 1, &pkt[0], 3); + + return n + 4; +} + +static uint16_t cfg_netkey_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint16_t n_idx, n; + struct mesh_net *net = node_get_net(node); + + n_idx = l_get_le16(pkt); + if (n_idx > NET_IDX_MAX) + return 0; + + n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); + + if (opcode == OP_NETKEY_ADD) + msg[n] = mesh_net_add_key(net, n_idx, pkt + 2); + else if (opcode == OP_NETKEY_UPDATE) + msg[n] = mesh_net_update_key(net, n_idx, pkt + 2); + else + msg[n] = mesh_net_del_key(net, n_idx); + + l_debug("NetKey Command %s: Net_Idx %3.3x", + (msg[n] == MESH_STATUS_SUCCESS) ? "success" : "fail", + n_idx); + + memcpy(msg + n + 1, &pkt[0], 2); + + return n + 3; +} + +static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t n_idx, sz, n; + + n_idx = l_get_le16(pkt); + + n = mesh_model_opcode_set(OP_APPKEY_LIST, msg); + l_put_le16(n_idx, msg + n + 1); + + msg[n] = appkey_list(node_get_net(node), n_idx, msg + n + 3, + MAX_MSG_LEN - (n + 3), &sz); + + return n + 3 + sz; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -585,7 +660,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint32_t opcode, tmp32; int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; - uint16_t n_idx, a_idx; + uint16_t n_idx; uint8_t state, status; uint8_t phase; bool virt = false; @@ -858,60 +933,19 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 19) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; - - if (opcode == OP_APPKEY_ADD) - b_res = appkey_key_add(net, n_idx, a_idx, pkt + 3); - else - b_res = appkey_key_update(net, n_idx, a_idx, - pkt + 3); - - l_debug("Add/Update AppKey %s: Net_Idx %3.3x, App_Idx %3.3x", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail", - n_idx, a_idx); - - - n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); - - msg[n++] = b_res; - msg[n++] = pkt[0]; - msg[n++] = pkt[1]; - msg[n++] = pkt[2]; - break; - + /* Fall Through */ case OP_APPKEY_DELETE: - if (size != 3) + if (opcode == OP_APPKEY_DELETE && size != 3) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; - b_res = appkey_key_delete(net, n_idx, a_idx); - l_debug("Delete AppKey %s Net_Idx %3.3x to App_Idx %3.3x", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail", - n_idx, a_idx); - - n = mesh_model_opcode_set(OP_APPKEY_STATUS, msg); - msg[n++] = b_res; - msg[n++] = pkt[0]; - msg[n++] = pkt[1]; - msg[n++] = pkt[2]; + n = cfg_appkey_msg(node, pkt, opcode); break; case OP_APPKEY_GET: if (size != 2) return true; - n_idx = l_get_le16(pkt); - - n = mesh_model_opcode_set(OP_APPKEY_LIST, msg); - - status = appkey_list(net, n_idx, msg + n + 3, - MAX_MSG_LEN - n - 3, &size); - - msg[n] = status; - l_put_le16(n_idx, msg + n + 1); - n += (size + 3); + n = cfg_get_appkeys_msg(node, pkt); break; case OP_NETKEY_ADD: @@ -919,35 +953,12 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (size != 18) return true; - n_idx = l_get_le16(pkt); - - if (opcode == OP_NETKEY_ADD) - b_res = mesh_net_add_key(net, n_idx, pkt + 2); - else - b_res = mesh_net_update_key(net, n_idx, pkt + 2); - - l_debug("NetKey Add/Update %s", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail"); - - n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); - msg[n++] = b_res; - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; - break; - + /* Fall Through */ case OP_NETKEY_DELETE: - if (size != 2) + if (opcode == OP_NETKEY_DELETE && size != 2) return true; - b_res = mesh_net_del_key(net, l_get_le16(pkt)); - - l_debug("NetKey delete %s", - (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail"); - - n = mesh_model_opcode_set(OP_NETKEY_STATUS, msg); - msg[n++] = b_res; - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; + n = cfg_netkey_msg(node, pkt, opcode); break; case OP_NETKEY_GET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qMIPIbywLF/wbQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:39:08 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id cNIMH7ywLF8ZzgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:39:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 11FC8420E7; Fri, 7 Aug 2020 03:39:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726202AbgHGBim (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:38:42 -0400 Received: from mga18.intel.com ([134.134.136.126]:44001 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbgHGBil (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:38:41 -0400 IronPort-SDR: vQbbzfuBlVyfccbG1etcMX7RgamVILNBQT94snjHH+oWjAcZE3PND9bB0zfFhGhS42DjRnOT00 QTwnlUJCm5bQ== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140558044" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140558044" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:38:41 -0700 IronPort-SDR: b4jZ3c9jq2K7PYNHGYvVE4GuMLlCr2vaFzOh2sccQ2PrU3fmHQ4x8nxY9QbTOD7/q7QlPlmlc0 gsv4/rEn/Enw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="397442085" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga001.fm.intel.com with ESMTP; 06 Aug 2020 18:38:41 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v5 06/10] mesh: Clean up handling of config relay messages Date: Thu, 6 Aug 2020 18:38:30 -0700 Message-Id: <20200807013834.123263-7-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200807013834.123263-1-inga.stotland@intel.com> References: <20200807013834.123263-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 11FC8420E7 X-Rspamd-UID: d28a12 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 2797de8ab..8e3da79d5 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -396,6 +396,27 @@ static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt, return n; } +static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t count; + uint16_t interval; + uint16_t n; + + if (opcode == OP_CONFIG_RELAY_SET) { + count = (pkt[1] & 0x7) + 1; + interval = ((pkt[1] >> 3) + 1) * 10; + node_relay_mode_set(node, !!pkt[0], count, interval); + } + + n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); + + msg[n++] = node_relay_mode_get(node, &count, &interval); + msg[n++] = (count - 1) + ((interval/10 - 1) << 3); + + return n; +} + static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; @@ -775,22 +796,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_RELAY_SET: if (size != 2 || pkt[0] > 0x01) return true; - - count = (pkt[1] & 0x7) + 1; - interval = ((pkt[1] >> 3) + 1) * 10; - node_relay_mode_set(node, !!pkt[0], count, interval); /* Fall Through */ case OP_CONFIG_RELAY_GET: if (opcode == OP_CONFIG_RELAY_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); - - msg[n++] = node_relay_mode_get(node, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Relay Config (%d)", msg[n-1]); + n = cfg_relay_msg(node, pkt, opcode); break; case OP_CONFIG_NETWORK_TRANSMIT_SET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8DbwBsGwLF/wbQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:39:13 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gLIiBcGwLF933wEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:39:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A8188420D3; Fri, 7 Aug 2020 03:39:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726190AbgHGBik (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:38:40 -0400 Received: from mga18.intel.com ([134.134.136.126]:43991 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726055AbgHGBik (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:38:40 -0400 IronPort-SDR: ZhO1qK3v0M8UvGVylBiQeE+p+s/1AXu4WvB2oxZPsKKw80M8NFCb8tF5QOtJ5MBZ4Q3mgVHe1a OI+YHt6N1+gw== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140558039" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140558039" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:38:39 -0700 IronPort-SDR: qyNlTQOi2tGnFqTthXPQL+HdbKtTsaFNNi0lL0lUCAFWhz4jYO7hyJ9AzoZ7ko/fZshmhiBRDo 8eBfFb98kMlA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="397442075" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga001.fm.intel.com with ESMTP; 06 Aug 2020 18:38:39 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v5 03/10] mesh: Clean up handling of config node identity message Date: Thu, 6 Aug 2020 18:38:27 -0700 Message-Id: <20200807013834.123263-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200807013834.123263-1-inga.stotland@intel.com> References: <20200807013834.123263-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: A8188420D3 X-Rspamd-UID: 1c655f This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 992279165..82938dc83 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -777,11 +777,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_NODE_IDENTITY_SET: - if (size != 3 || pkt[2] > 0x01) - return true; - - n_idx = l_get_le16(pkt); - if (n_idx > 0xfff) + if (size != 3) return true; /* Currently setting node identity not supported */ @@ -789,18 +785,15 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, /* Fall Through */ case OP_NODE_IDENTITY_GET: - if (size < 2) + if (opcode == OP_NODE_IDENTITY_GET && size != 2) return true; n_idx = l_get_le16(pkt); - if (n_idx > 0xfff) + if (n_idx > NET_IDX_MAX) return true; n = mesh_model_opcode_set(OP_NODE_IDENTITY_STATUS, msg); - - status = mesh_net_get_identity_mode(net, n_idx, &state); - - msg[n++] = status; + msg[n++] = mesh_net_get_identity_mode(net, n_idx, &state); l_put_le16(n_idx, msg + n); n += 2; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wA6AGsqwLF/wbQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:39:22 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wAcfGcqwLF8oWAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:39:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EB8D0420E7; Fri, 7 Aug 2020 03:39:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726232AbgHGBio (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:38:44 -0400 Received: from mga18.intel.com ([134.134.136.126]:44001 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgHGBin (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:38:43 -0400 IronPort-SDR: hqPlxLHPANRWYA6VDhO5yN0zK+Lzy7zJlG39GBmfn5ourxD04qxRV9tmJ7GkywpAPRlvz5+DBO 1lPctfE4eXYA== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140558049" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140558049" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:38:42 -0700 IronPort-SDR: d0+DkxrQIk/MRWpMjC+d2blzVC8eWQV9gV8j9RaJSWH4d1DhkdUN4BQWfdAiwvzyBvLOJGGt26 gXzz5PevfvvQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="397442094" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga001.fm.intel.com with ESMTP; 06 Aug 2020 18:38:42 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v5 08/10] mesh: Clean up handling of config net transmit messages Date: Thu, 6 Aug 2020 18:38:32 -0700 Message-Id: <20200807013834.123263-9-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200807013834.123263-1-inga.stotland@intel.com> References: <20200807013834.123263-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: EB8D0420E7 X-Rspamd-UID: 3cfac2 This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index f3cc18ae0..191c5b8ef 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -662,6 +662,28 @@ static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) return n; } +static uint16_t cfg_net_tx_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t cnt; + uint16_t interval, n; + struct mesh_net *net = node_get_net(node); + + cnt = (pkt[0] & 0x7) + 1; + interval = ((pkt[0] >> 3) + 1) * 10; + + if (opcode == OP_CONFIG_NETWORK_TRANSMIT_SET && + mesh_config_write_net_transmit(node_config_get(node), + cnt, interval)) + mesh_net_transmit_params_set(net, cnt, interval); + + n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, msg); + + mesh_net_transmit_params_get(net, &cnt, &interval); + msg[n++] = (cnt - 1) + ((interval/10 - 1) << 3); + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -704,8 +726,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint8_t state, status; uint8_t phase; bool virt = false; - uint8_t count; - uint16_t interval; uint16_t n; if (app_idx != APP_IDX_DEV_LOCAL) @@ -827,25 +847,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_NETWORK_TRANSMIT_SET: if (size != 1) return true; - - count = (pkt[0] & 0x7) + 1; - interval = ((pkt[0] >> 3) + 1) * 10; - - if (mesh_config_write_net_transmit(node_config_get(node), count, - interval)) - mesh_net_transmit_params_set(net, count, interval); /* Fall Through */ case OP_CONFIG_NETWORK_TRANSMIT_GET: if (opcode == OP_CONFIG_NETWORK_TRANSMIT_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, - msg); - mesh_net_transmit_params_get(net, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Network Transmit Config"); + n = cfg_net_tx_msg(node, pkt, opcode); break; case OP_CONFIG_PROXY_SET: -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OFLgEs+wLF/wbQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:39:27 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id QIoaEc+wLF/vVwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:39:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8B32C420F2; Fri, 7 Aug 2020 03:39:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726238AbgHGBip (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:38:45 -0400 Received: from mga18.intel.com ([134.134.136.126]:44019 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbgHGBin (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:38:43 -0400 IronPort-SDR: LlFEVufB2rlM+AxlXgfEkUDZVwdDbL2n3pkRkM3131dQXSWNw5uTeDEZHuSq0oc/pI30gBpKCy 07nxbe0a6UsA== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140558050" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140558050" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:38:43 -0700 IronPort-SDR: t4uVcoSKqelWuFm0deHcGzx3AKwsL/jB1yuMIYOVfbwMq9Z10Y6SV1B1G2SojXSa+s5bq/9O0A 9OJNVY6/+k4A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="397442098" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga001.fm.intel.com with ESMTP; 06 Aug 2020 18:38:42 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v5 09/10] mesh: Clean up handling of config KR phase messages Date: Thu, 6 Aug 2020 18:38:33 -0700 Message-Id: <20200807013834.123263-10-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200807013834.123263-1-inga.stotland@intel.com> References: <20200807013834.123263-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8B32C420F2 X-Rspamd-UID: 33da4c This modification allows using a single point for sending out the composed status messages by the Config Server. Also, this checks for the correct relationship between KR transition and KR phase values. Correct error codes are sent on unsuccessful requests and malformed requests are ignored. --- mesh/cfgmod-server.c | 68 +++++++++++++++++++++++++++----------------- mesh/mesh-defs.h | 3 ++ mesh/net.c | 53 ++++++++++++---------------------- mesh/net.h | 4 +-- 4 files changed, 65 insertions(+), 63 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 191c5b8ef..ea0741969 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -417,6 +417,43 @@ static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt, return n; } +static uint16_t cfg_key_refresh_phase(struct mesh_node *node, + const uint8_t *pkt, int opcode) +{ + struct mesh_net *net = node_get_net(node); + uint16_t n, idx = l_get_le16(pkt); + uint8_t phase; + int status; + + n = mesh_model_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_STATUS, msg); + status = mesh_net_key_refresh_phase_get(net, idx, &phase); + + if (status == MESH_STATUS_SUCCESS && + opcode == OP_CONFIG_KEY_REFRESH_PHASE_SET) { + + if (pkt[2] == KEY_REFRESH_TRANS_TWO) { + if (phase == KEY_REFRESH_PHASE_TWO) + goto done; + else if (phase != KEY_REFRESH_PHASE_ONE) + return 0; + } + + status = mesh_net_key_refresh_phase_set(net, idx, pkt[2]); + l_debug("Set KR Phase: net=%3.3x transition=%d", idx, pkt[2]); + + if (status == MESH_STATUS_SUCCESS) + mesh_net_key_refresh_phase_get(net, idx, &phase); + } + +done: + msg[n] = status; + l_put_le16(idx, msg + n); + msg[n + 2] = (status != MESH_STATUS_SUCCESS) ? + KEY_REFRESH_PHASE_NONE : phase; + + return n + 3; +} + static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; @@ -723,8 +760,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; uint16_t n_idx; - uint8_t state, status; - uint8_t phase; + uint8_t state; bool virt = false; uint16_t n; @@ -934,37 +970,17 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_KEY_REFRESH_PHASE_SET: - if (size != 3 || pkt[2] > 0x03) + if (size != 3 || (pkt[2] != KEY_REFRESH_TRANS_THREE && + pkt[2] != KEY_REFRESH_TRANS_TWO)) return true; - b_res = mesh_net_key_refresh_phase_set(net, l_get_le16(pkt), - pkt[2]); - size = 2; /* Fall Through */ case OP_CONFIG_KEY_REFRESH_PHASE_GET: - if (size != 2) + if (size != 2 && opcode == OP_CONFIG_KEY_REFRESH_PHASE_GET) return true; - n_idx = l_get_le16(pkt); - - n = mesh_model_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_STATUS, - msg); - - /* State: 0x00-0x03 phase of key refresh */ - status = mesh_net_key_refresh_phase_get(net, n_idx, - &phase); - if (status != MESH_STATUS_SUCCESS) { - b_res = status; - phase = KEY_REFRESH_PHASE_NONE; - } - - msg[n++] = b_res; - l_put_le16(n_idx, msg + n); - n += 2; - msg[n++] = phase; - - l_debug("Get/Set Key Refresh State (%d)", msg[n-1]); + n = cfg_key_refresh_phase(node, pkt, opcode); break; case OP_APPKEY_ADD: diff --git a/mesh/mesh-defs.h b/mesh/mesh-defs.h index 5ade751a3..1a41e987b 100644 --- a/mesh/mesh-defs.h +++ b/mesh/mesh-defs.h @@ -36,6 +36,9 @@ #define KEY_REFRESH_PHASE_TWO 0x02 #define KEY_REFRESH_PHASE_THREE 0x03 +#define KEY_REFRESH_TRANS_TWO 0x02 +#define KEY_REFRESH_TRANS_THREE 0x03 + #define DEFAULT_TTL 0xff #define TTL_MASK 0x7f diff --git a/mesh/net.c b/mesh/net.c index b54c647cb..9b4454fee 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -2433,6 +2433,10 @@ static int key_refresh_phase_two(struct mesh_net *net, uint16_t idx) return MESH_STATUS_INVALID_NETKEY; l_debug("Key refresh procedure phase 2: start using new net TX keys"); + + if (subnet->kr_phase == KEY_REFRESH_PHASE_TWO) + return MESH_STATUS_SUCCESS; + subnet->key_refresh = 1; subnet->net_key_tx = subnet->net_key_upd; /* @@ -2445,8 +2449,9 @@ static int key_refresh_phase_two(struct mesh_net *net, uint16_t idx) l_queue_foreach(net->friends, frnd_kr_phase2, net); - mesh_config_net_key_set_phase(node_config_get(net->node), idx, - KEY_REFRESH_PHASE_TWO); + if (!mesh_config_net_key_set_phase(node_config_get(net->node), idx, + KEY_REFRESH_PHASE_TWO)) + return MESH_STATUS_STORAGE_FAIL; return MESH_STATUS_SUCCESS; } @@ -2479,8 +2484,9 @@ static int key_refresh_finish(struct mesh_net *net, uint16_t idx) l_queue_foreach(net->friends, frnd_kr_phase3, net); - mesh_config_net_key_set_phase(node_config_get(net->node), idx, - KEY_REFRESH_PHASE_NONE); + if (!mesh_config_net_key_set_phase(node_config_get(net->node), idx, + KEY_REFRESH_PHASE_NONE)) + return MESH_STATUS_STORAGE_FAIL; return MESH_STATUS_SUCCESS; } @@ -3168,45 +3174,22 @@ void mesh_net_transport_send(struct mesh_net *net, uint32_t key_id, send_msg_pkt(net, pkt, pkt_len + 1); } -uint8_t mesh_net_key_refresh_phase_set(struct mesh_net *net, uint16_t idx, +int mesh_net_key_refresh_phase_set(struct mesh_net *net, uint16_t idx, uint8_t transition) { - struct mesh_subnet *subnet; - - if (!net) - return MESH_STATUS_UNSPECIFIED_ERROR; - - subnet = l_queue_find(net->subnets, match_key_index, - L_UINT_TO_PTR(idx)); - if (!subnet) - return MESH_STATUS_INVALID_NETKEY; - - if (transition == subnet->kr_phase) - return MESH_STATUS_SUCCESS; + switch (transition) { + case KEY_REFRESH_TRANS_TWO: + return key_refresh_phase_two(net, idx); - if ((transition != 2 && transition != 3) || - transition < subnet->kr_phase) - return MESH_STATUS_CANNOT_SET; + case KEY_REFRESH_TRANS_THREE: + return key_refresh_finish(net, idx); - switch (transition) { - case 2: - if (key_refresh_phase_two(net, idx) - != MESH_STATUS_SUCCESS) - return MESH_STATUS_CANNOT_SET; - break; - case 3: - if (key_refresh_finish(net, idx) - != MESH_STATUS_SUCCESS) - return MESH_STATUS_CANNOT_SET; - break; default: - return MESH_STATUS_CANNOT_SET; + return MESH_STATUS_UNSPECIFIED_ERROR; } - - return MESH_STATUS_SUCCESS; } -uint8_t mesh_net_key_refresh_phase_get(struct mesh_net *net, uint16_t idx, +int mesh_net_key_refresh_phase_get(struct mesh_net *net, uint16_t idx, uint8_t *phase) { struct mesh_subnet *subnet; diff --git a/mesh/net.h b/mesh/net.h index 2673b895a..3d374280f 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -320,9 +320,9 @@ void mesh_friend_sub_add(struct mesh_net *net, uint16_t lpn, uint8_t ele_cnt, const uint8_t *list); void mesh_friend_sub_del(struct mesh_net *net, uint16_t lpn, uint8_t cnt, const uint8_t *del_list); -uint8_t mesh_net_key_refresh_phase_set(struct mesh_net *net, uint16_t net_idx, +int mesh_net_key_refresh_phase_set(struct mesh_net *net, uint16_t net_idx, uint8_t transition); -uint8_t mesh_net_key_refresh_phase_get(struct mesh_net *net, uint16_t net_idx, +int mesh_net_key_refresh_phase_get(struct mesh_net *net, uint16_t net_idx, uint8_t *phase); void mesh_net_send_seg(struct mesh_net *net, uint32_t key_id, uint32_t iv_index, uint8_t ttl, uint32_t seq, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aLnzK9SwLF/wbQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 03:39:32 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id INo6KtSwLF/7fwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 03:39:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 66A0F420EE; Fri, 7 Aug 2020 03:39:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726249AbgHGBiq (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 21:38:46 -0400 Received: from mga18.intel.com ([134.134.136.126]:44021 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbgHGBip (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 21:38:45 -0400 IronPort-SDR: X2P6Bp6yeU0FzY9mzxxouUWTDpCH0Oj56rHyaKiBc/63r6S+gNT0xwd4Hp5iEcRrZsGUlHqLJO DmBfrdGRjpbQ== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140558052" X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="140558052" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 18:38:44 -0700 IronPort-SDR: y4xNy3RixOODKWXn5mcrV6vRyxnmxv6ViEdrDm1gibfvmrqZimFAd+Ot794RW792Xo8/W/v/IL yTDi2AWrkIxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,443,1589266800"; d="scan'208";a="397442102" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.119.50]) by fmsmga001.fm.intel.com with ESMTP; 06 Aug 2020 18:38:43 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v5 10/10] mesh: Refactor heartbeat pub/sub Date: Thu, 6 Aug 2020 18:38:34 -0700 Message-Id: <20200807013834.123263-11-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200807013834.123263-1-inga.stotland@intel.com> References: <20200807013834.123263-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 17 X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 66A0F420EE X-Rspamd-UID: aafde9 Move heartbeat publication/subscription timers and housekeeping to net.c since this is where the trigger events and control messages are handled. Configuration server (cfgmod-server.c) stays responsible for parsing the set pub/sub message parameters and assemblying the pub/sub status messages. Also, make sure that the correct message status is reported. --- mesh/cfgmod-server.c | 307 ++++++++++++++----------------------------- mesh/net.c | 273 ++++++++++++++++++++++++++++---------- mesh/net.h | 48 ++++--- 3 files changed, 328 insertions(+), 300 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index ea0741969..ffeb0afeb 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -454,50 +454,6 @@ done: return n + 3; } -static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) -{ - struct mesh_net *net = user_data; - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - mesh_net_heartbeat_send(net); - - if (hb->pub_count != 0xffff) - hb->pub_count--; - if (hb->pub_count > 0) - l_timeout_modify(hb->pub_timer, hb->pub_period); - else { - l_timeout_remove(hb->pub_timer); - hb->pub_timer = NULL; - } -} - -static void update_hb_pub_timer(struct mesh_net *net, - struct mesh_net_heartbeat *hb) -{ - if (IS_UNASSIGNED(hb->pub_dst) || hb->pub_count == 0) { - l_timeout_remove(hb->pub_timer); - hb->pub_timer = NULL; - return; - } - - if (!hb->pub_timer) - hb->pub_timer = l_timeout_create(hb->pub_period, - hb_pub_timeout_func, net, NULL); - else - l_timeout_modify(hb->pub_timer, hb->pub_period); -} - -static void hb_sub_timeout_func(struct l_timeout *timeout, void *user_data) -{ - struct mesh_net *net = user_data; - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - l_debug("HB Subscription Ended"); - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; -} - static uint8_t uint32_to_log(uint32_t value) { uint32_t val = 1; @@ -516,85 +472,112 @@ static uint8_t uint32_to_log(uint32_t value) return ret; } -static uint32_t log_to_uint32(uint8_t log, uint8_t offset) +static uint16_t hb_subscription_get(struct mesh_node *node, int status) { - if (!log) - return 0x0000; - else if (log > 0x11) - return 0xffff; + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_sub *sub = mesh_net_get_heartbeat_sub(net); + struct timeval time_now; + uint16_t n; + + gettimeofday(&time_now, NULL); + time_now.tv_sec -= sub->start; + + if (time_now.tv_sec >= (long int) sub->period) + time_now.tv_sec = 0; else - return (1 << (log - offset)); -} + time_now.tv_sec = sub->period - time_now.tv_sec; + + l_debug("Sub Period (Log %2.2x) %d sec", uint32_to_log(time_now.tv_sec), + (int) time_now.tv_sec); + + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); + msg[n++] = status; + l_put_le16(sub->src, msg + n); + n += 2; + l_put_le16(sub->dst, msg + n); + n += 2; + msg[n++] = uint32_to_log(time_now.tv_sec); + msg[n++] = uint32_to_log(sub->count); + msg[n++] = sub->count ? sub->min_hops : 0; + msg[n++] = sub->max_hops; + return n; +} -static int hb_subscription_set(struct mesh_net *net, uint16_t src, - uint16_t dst, uint8_t period_log) +static uint16_t hb_subscription_set(struct mesh_node *node, const uint8_t *pkt) { - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - struct timeval time_now; + uint16_t src, dst; + uint8_t period_log; + struct mesh_net *net; + int status; + + src = l_get_le16(pkt); + dst = l_get_le16(pkt + 2); /* SRC must be Unicast, DST can be any legal address except Virtual */ if ((!IS_UNASSIGNED(src) && !IS_UNICAST(src)) || IS_VIRTUAL(dst)) - return -1; - - /* Check if the subscription should be disabled */ - if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst)) { - if (IS_GROUP(hb->sub_dst)) - mesh_net_dst_unreg(net, hb->sub_dst); - - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; - hb->sub_dst = UNASSIGNED_ADDRESS; - hb->sub_src = UNASSIGNED_ADDRESS; - hb->sub_count = 0; - hb->sub_period = 0; - hb->sub_min_hops = 0; - hb->sub_max_hops = 0; - return MESH_STATUS_SUCCESS; - - } else if (!period_log && src == hb->sub_src && dst == hb->sub_dst) { - /* Preserve collected data, but disable */ - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - hb->sub_enabled = false; - hb->sub_period = 0; - return MESH_STATUS_SUCCESS; - } + return 0; - if (hb->sub_dst != dst) { - if (IS_GROUP(hb->sub_dst)) - mesh_net_dst_unreg(net, hb->sub_dst); - if (IS_GROUP(dst)) - mesh_net_dst_reg(net, dst); - } + period_log = pkt[4]; - hb->sub_enabled = !!period_log; - hb->sub_src = src; - hb->sub_dst = dst; - hb->sub_count = 0; - hb->sub_period = log_to_uint32(period_log, 1); - hb->sub_min_hops = 0x00; - hb->sub_max_hops = 0x00; + if (period_log > 0x11) + return 0; - gettimeofday(&time_now, NULL); - hb->sub_start = time_now.tv_sec; + net = node_get_net(node); - if (!hb->sub_enabled) { - l_timeout_remove(hb->sub_timer); - hb->sub_timer = NULL; - return MESH_STATUS_SUCCESS; - } + status = mesh_net_set_heartbeat_sub(net, src, dst, period_log); - hb->sub_min_hops = 0xff; + return hb_subscription_get(node, status); +} - if (!hb->sub_timer) - hb->sub_timer = l_timeout_create(hb->sub_period, - hb_sub_timeout_func, net, NULL); - else - l_timeout_modify(hb->sub_timer, hb->sub_period); +static uint16_t hb_publication_get(struct mesh_node *node, int status) +{ + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_pub *pub = mesh_net_get_heartbeat_pub(net); + uint16_t n; - return MESH_STATUS_SUCCESS; + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg); + msg[n++] = status; + l_put_le16(pub->dst, msg + n); + n += 2; + msg[n++] = uint32_to_log(pub->count); + msg[n++] = uint32_to_log(pub->period); + msg[n++] = pub->ttl; + l_put_le16(pub->features, msg + n); + n += 2; + l_put_le16(pub->net_idx, msg + n); + n += 2; + + return n; +} + +static uint16_t hb_publication_set(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t dst, features, net_idx; + uint8_t period_log, count_log, ttl; + struct mesh_net *net; + int status; + + dst = l_get_le16(pkt); + count_log = pkt[2]; + period_log = pkt[3]; + ttl = pkt[4]; + + if (count_log > 0x11 && count_log != 0xff) + return 0; + + if (period_log > 0x11 || ttl > TTL_MASK || IS_VIRTUAL(dst)) + return 0; + + features = l_get_le16(pkt + 5) & 0xf; + net_idx = l_get_le16(pkt + 7); + + net = node_get_net(node); + + status = mesh_net_set_heartbeat_pub(net, dst, features, net_idx, ttl, + count_log, period_log); + + return hb_publication_get(node, status); } static void node_reset(void *user_data) @@ -755,10 +738,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct mesh_node *node = (struct mesh_node *) user_data; struct mesh_net *net; const uint8_t *pkt = data; - struct timeval time_now; uint32_t opcode; - int b_res = MESH_STATUS_SUCCESS; - struct mesh_net_heartbeat *hb; uint16_t n_idx; uint8_t state; bool virt = false; @@ -774,7 +754,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, return false; net = node_get_net(node); - hb = mesh_net_heartbeat_get(net); + l_debug("CONFIG-SRV-opcode 0x%x size %u idx %3.3x", opcode, size, net_idx); @@ -1051,113 +1031,35 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_HEARTBEAT_PUB_SET: - l_debug("OP_CONFIG_HEARTBEAT_PUB_SET"); + l_debug("Config Heartbeat Publication Set"); if (size != 9) return true; - if (pkt[2] > 0x11 || pkt[3] > 0x10 || pkt[4] > 0x7f) - return true; - else if (IS_VIRTUAL(l_get_le16(pkt))) - b_res = MESH_STATUS_INVALID_ADDRESS; - else if (l_get_le16(pkt + 7) != mesh_net_get_primary_idx(net)) - /* Future work: check for valid subnets */ - b_res = MESH_STATUS_INVALID_NETKEY; - - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, - msg); - msg[n++] = b_res; - - memcpy(&msg[n], pkt, 9); - - /* Ignore RFU bits in features */ - l_put_le16(l_get_le16(pkt + 5) & 0xf, &msg[n + 5]); - - /* Add octet count to status */ - n += 9; - - if (b_res != MESH_STATUS_SUCCESS) - break; - - hb->pub_dst = l_get_le16(pkt); - if (hb->pub_dst == UNASSIGNED_ADDRESS || - pkt[2] == 0 || pkt[3] == 0) { - /* - * We might still have a pub_dst here in case - * we need it for State Change heartbeat - */ - hb->pub_count = 0; - hb->pub_period = 0; - } else { - hb->pub_count = (pkt[2] != 0xff) ? - log_to_uint32(pkt[2], 1) : 0xffff; - hb->pub_period = log_to_uint32(pkt[3], 1); - } - - hb->pub_ttl = pkt[4]; - hb->pub_features = l_get_le16(pkt + 5) & 0xf; - hb->pub_net_idx = l_get_le16(pkt + 7); - update_hb_pub_timer(net, hb); - + n = hb_publication_set(node, pkt); break; case OP_CONFIG_HEARTBEAT_PUB_GET: if (size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg); - msg[n++] = b_res; - l_put_le16(hb->pub_dst, msg + n); - n += 2; - msg[n++] = uint32_to_log(hb->pub_count); - msg[n++] = uint32_to_log(hb->pub_period); - msg[n++] = hb->pub_ttl; - l_put_le16(hb->pub_features, msg + n); - n += 2; - l_put_le16(hb->pub_net_idx, msg + n); - n += 2; + n = hb_publication_get(node, MESH_STATUS_SUCCESS); break; case OP_CONFIG_HEARTBEAT_SUB_SET: if (size != 5) return true; - l_debug("Set Sub Period (Log %2.2x) %d sec", - pkt[4], log_to_uint32(pkt[4], 1)); - - b_res = hb_subscription_set(net, l_get_le16(pkt), - l_get_le16(pkt + 2), - pkt[4]); - if (b_res < 0) - return true; + l_debug("Set HB Sub Period Log %2.2x", pkt[4]); - /* Fall through */ + n = hb_subscription_set(node, pkt); + break; case OP_CONFIG_HEARTBEAT_SUB_GET: - if (opcode == OP_CONFIG_HEARTBEAT_SUB_GET && size != 0) - return true; - - gettimeofday(&time_now, NULL); - time_now.tv_sec -= hb->sub_start; - if (time_now.tv_sec >= (long int) hb->sub_period) - time_now.tv_sec = 0; - else - time_now.tv_sec = hb->sub_period - time_now.tv_sec; - - l_debug("Sub Period (Log %2.2x) %d sec", - uint32_to_log(time_now.tv_sec), - (int) time_now.tv_sec); + if (size != 0) + return true; - n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); - msg[n++] = b_res; - l_put_le16(hb->sub_src, msg + n); - n += 2; - l_put_le16(hb->sub_dst, msg + n); - n += 2; - msg[n++] = uint32_to_log(time_now.tv_sec); - msg[n++] = uint32_to_log(hb->sub_count); - msg[n++] = hb->sub_count ? hb->sub_min_hops : 0; - msg[n++] = hb->sub_max_hops; + n = hb_subscription_get(node, MESH_STATUS_SUCCESS); break; case OP_CONFIG_POLL_TIMEOUT_GET: @@ -1187,13 +1089,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, static void cfgmod_srv_unregister(void *user_data) { - struct mesh_node *node = user_data; - struct mesh_net *net = node_get_net(node); - struct mesh_net_heartbeat *hb = mesh_net_heartbeat_get(net); - - l_timeout_remove(hb->pub_timer); - l_timeout_remove(hb->sub_timer); - hb->pub_timer = hb->sub_timer = NULL; } static const struct mesh_model_ops ops = { diff --git a/mesh/net.c b/mesh/net.c index 9b4454fee..633727601 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -23,6 +23,8 @@ #define _GNU_SOURCE +#include <sys/time.h> + #include <ell/ell.h> #include "mesh/mesh-defs.h" @@ -132,7 +134,10 @@ struct mesh_net { uint8_t count; } relay; - struct mesh_net_heartbeat heartbeat; + /* Heartbeat info */ + struct mesh_net_heartbeat_sub hb_sub; + struct mesh_net_heartbeat_pub hb_pub; + uint16_t features; struct l_queue *subnets; struct l_queue *msg_cache; @@ -255,35 +260,46 @@ static bool match_friend_key_id(const void *a, const void *b) (key_id == friend->net_key_upd); } -static void idle_mesh_heartbeat_send(void *net) +static void send_hb_publication(void *data) { - mesh_net_heartbeat_send(net); + struct mesh_net *net = data; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + uint8_t msg[4]; + int n = 0; + + if (pub->dst == UNASSIGNED_ADDRESS) + return; + + msg[n++] = NET_OP_HEARTBEAT; + msg[n++] = pub->ttl; + l_put_be16(net->features, msg + n); + n += 2; + + mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), + pub->ttl, 0, 0, pub->dst, msg, n); } static void trigger_heartbeat(struct mesh_net *net, uint16_t feature, - bool in_use) + bool enable) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - - l_debug("%s: %4.4x --> %d", __func__, feature, in_use); + l_debug("HB: %4.4x --> %d", feature, enable); - if (in_use) { - if (net->heartbeat.features & feature) + if (enable) { + if (net->features & feature) return; /* no change */ - hb->features |= feature; + net->features |= feature; } else { - if (!(hb->features & feature)) + if (!(net->features & feature)) return; /* no change */ - hb->features &= ~feature; + net->features &= ~feature; } - if (!(hb->pub_features & feature)) - return; /* not interested in this feature */ - - l_idle_oneshot(idle_mesh_heartbeat_send, net, NULL); + if (!(net->hb_pub.features & feature)) + return; /* no interest in this feature */ + l_idle_oneshot(send_hb_publication, net, NULL); } static bool match_by_friend(const void *a, const void *b) @@ -616,8 +632,6 @@ struct mesh_net *mesh_net_new(struct mesh_node *node) net->destinations = l_queue_new(); net->app_keys = l_queue_new(); - memset(&net->heartbeat, 0, sizeof(net->heartbeat)); - if (!nets) nets = l_queue_new(); @@ -813,8 +827,8 @@ int mesh_net_del_key(struct mesh_net *net, uint16_t idx) appkey_delete_bound_keys(net, idx); /* Disable hearbeat publication on this subnet */ - if (idx == net->heartbeat.pub_net_idx) - net->heartbeat.pub_dst = UNASSIGNED_ADDRESS; + if (idx == net->hb_pub.net_idx) + net->hb_pub.dst = UNASSIGNED_ADDRESS; /* TODO: cancel beacon_enable on this subnet */ @@ -2017,25 +2031,23 @@ static bool ctl_received(struct mesh_net *net, uint16_t key_id, break; case NET_OP_HEARTBEAT: - if (net->heartbeat.sub_enabled && - src == net->heartbeat.sub_src) { + if (net->hb_sub.enabled && src == net->hb_sub.src) { uint8_t hops = pkt[0] - ttl + 1; print_packet("Rx-NET_OP_HEARTBEAT", pkt, len); - if (net->heartbeat.sub_count != 0xffff) - net->heartbeat.sub_count++; + if (net->hb_sub.count != 0xffff) + net->hb_sub.count++; - if (net->heartbeat.sub_min_hops > hops) - net->heartbeat.sub_min_hops = hops; + if (net->hb_sub.min_hops > hops) + net->hb_sub.min_hops = hops; - if (net->heartbeat.sub_max_hops < hops) - net->heartbeat.sub_max_hops = hops; + if (net->hb_sub.max_hops < hops) + net->hb_sub.max_hops = hops; l_debug("HB: cnt:%4.4x min:%2.2x max:%2.2x", - net->heartbeat.sub_count, - net->heartbeat.sub_min_hops, - net->heartbeat.sub_max_hops); + net->hb_sub.count, net->hb_sub.min_hops, + net->hb_sub.max_hops); } break; } @@ -3259,52 +3271,14 @@ int mesh_net_update_key(struct mesh_net *net, uint16_t idx, return MESH_STATUS_SUCCESS; } -static uint16_t get_features(struct mesh_net *net) -{ - uint16_t features = 0; - - if (net->relay.enable) - features |= FEATURE_RELAY; - - if (net->proxy_enable) - features |= FEATURE_PROXY; - - if (net->friend_enable) - features |= FEATURE_FRIEND; - - return features; -} - -struct mesh_net_heartbeat *mesh_net_heartbeat_get(struct mesh_net *net) -{ - return &net->heartbeat; -} - -void mesh_net_heartbeat_send(struct mesh_net *net) +struct mesh_net_heartbeat_sub *mesh_net_get_heartbeat_sub(struct mesh_net *net) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - uint8_t msg[4]; - int n = 0; - - if (hb->pub_dst == UNASSIGNED_ADDRESS) - return; - - msg[n++] = NET_OP_HEARTBEAT; - msg[n++] = hb->pub_ttl; - l_put_be16(hb->features, msg + n); - n += 2; - - mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), - hb->pub_ttl, 0, 0, hb->pub_dst, msg, n); + return &net->hb_sub; } -void mesh_net_heartbeat_init(struct mesh_net *net) +struct mesh_net_heartbeat_pub *mesh_net_get_heartbeat_pub(struct mesh_net *net) { - struct mesh_net_heartbeat *hb = &net->heartbeat; - - memset(hb, 0, sizeof(struct mesh_net_heartbeat)); - hb->sub_min_hops = 0xff; - hb->features = get_features(net); + return &net->hb_pub; } void mesh_net_set_iv_index(struct mesh_net *net, uint32_t index, bool update) @@ -3542,3 +3516,156 @@ void net_msg_add_replay_cache(struct mesh_net *net, uint16_t src, uint32_t seq, /* Optimize so that most recent conversations stay earliest in cache */ l_queue_push_head(net->replay_cache, rpe); } + +static void hb_sub_timeout_func(struct l_timeout *timeout, void *user_data) +{ + struct mesh_net *net = user_data; + struct mesh_net_heartbeat_sub *sub = &net->hb_sub; + + l_debug("HB Subscription Ended"); + l_timeout_remove(sub->timer); + sub->timer = NULL; + sub->enabled = false; +} + +static uint32_t log_to_uint32(uint8_t log) +{ + if (!log) + return 0x0000; + + return (1 << (log - 1)); +} + +int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, + uint8_t period_log) +{ + struct mesh_net_heartbeat_sub *sub = &net->hb_sub; + struct timeval time_now; + + if (!net) + return MESH_STATUS_UNSPECIFIED_ERROR; + + /* Check if the subscription should be disabled */ + if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst)) { + if (IS_GROUP(sub->dst)) + mesh_net_dst_unreg(net, sub->dst); + + sub->enabled = false; + sub->dst = UNASSIGNED_ADDRESS; + sub->src = UNASSIGNED_ADDRESS; + sub->count = 0; + sub->period = 0; + sub->min_hops = 0; + sub->max_hops = 0; + + } else if (!period_log && src == sub->src && dst == sub->dst) { + /* Preserve collected data, but disable */ + sub->enabled = false; + sub->period = 0; + + } else if (sub->dst != dst) { + if (IS_GROUP(sub->dst)) + mesh_net_dst_unreg(net, sub->dst); + + if (IS_GROUP(dst)) + mesh_net_dst_reg(net, dst); + + sub->enabled = !!period_log; + sub->src = src; + sub->dst = dst; + sub->count = 0; + sub->period = log_to_uint32(period_log); + sub->min_hops = 0x00; + sub->max_hops = 0x00; + gettimeofday(&time_now, NULL); + sub->start = time_now.tv_sec; + } + + /* TODO: Save to node config */ + + if (!sub->enabled) { + l_timeout_remove(sub->timer); + sub->timer = NULL; + return MESH_STATUS_SUCCESS; + } + + sub->min_hops = 0xff; + + if (!sub->timer) + sub->timer = l_timeout_create(sub->period, hb_sub_timeout_func, + net, NULL); + else + l_timeout_modify(sub->timer, sub->period); + + return MESH_STATUS_SUCCESS; +} + +static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) +{ + struct mesh_net *net = user_data; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + + send_hb_publication(net); + + if (pub->count != 0xffff) + pub->count--; + + if (pub->count > 0) + l_timeout_modify(pub->timer, pub->period); + else { + l_timeout_remove(pub->timer); + pub->timer = NULL; + } +} + +static void update_hb_pub_timer(struct mesh_net *net, + struct mesh_net_heartbeat_pub *pub) +{ + if (IS_UNASSIGNED(pub->dst) || pub->count == 0) { + l_timeout_remove(pub->timer); + pub->timer = NULL; + return; + } + + if (!pub->timer) + pub->timer = l_timeout_create(pub->period, + hb_pub_timeout_func, net, NULL); + else + l_timeout_modify(pub->timer, pub->period); +} + +int mesh_net_set_heartbeat_pub(struct mesh_net *net, uint16_t dst, + uint16_t features, uint16_t idx, uint8_t ttl, + uint8_t count_log, uint8_t period_log) +{ + struct mesh_subnet *subnet; + struct mesh_net_heartbeat_pub *pub = &net->hb_pub; + + if (!net) + return MESH_STATUS_UNSPECIFIED_ERROR; + + subnet = l_queue_find(net->subnets, match_key_index, + L_UINT_TO_PTR(idx)); + if (!subnet) + return MESH_STATUS_INVALID_NETKEY; + + pub->dst = dst; + + if (pub->dst == UNASSIGNED_ADDRESS) { + pub->count = 0; + pub->period = 0; + pub->ttl = 0; + } else { + pub->count = (count_log != 0xff) ? + log_to_uint32(count_log) : 0xffff; + pub->period = log_to_uint32(period_log); + } + + pub->ttl = ttl; + pub->features = features; + pub->net_idx = idx; + update_hb_pub_timer(net, pub); + + /* TODO: Save to node config */ + return MESH_STATUS_SUCCESS; +} diff --git a/mesh/net.h b/mesh/net.h index 3d374280f..91e07ef78 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -129,25 +129,27 @@ struct mesh_net_prov_caps { uint16_t input_action; } __packed; -struct mesh_net_heartbeat { - struct l_timeout *pub_timer; - struct l_timeout *sub_timer; - struct timeval sub_time; - bool sub_enabled; - uint32_t pub_period; - uint32_t sub_period; - uint32_t sub_start; - uint16_t pub_dst; - uint16_t pub_count; - uint16_t pub_features; +struct mesh_net_heartbeat_sub { + struct l_timeout *timer; + uint32_t start; + uint32_t period; uint16_t features; - uint16_t pub_net_idx; - uint16_t sub_src; - uint16_t sub_dst; - uint16_t sub_count; - uint8_t pub_ttl; - uint8_t sub_min_hops; - uint8_t sub_max_hops; + uint16_t src; + uint16_t dst; + uint16_t count; + bool enabled; + uint8_t min_hops; + uint8_t max_hops; +}; + +struct mesh_net_heartbeat_pub { + struct l_timeout *timer; + uint32_t period; + uint16_t dst; + uint16_t count; + uint16_t features; + uint16_t net_idx; + uint8_t ttl; }; struct mesh_key_set { @@ -328,9 +330,13 @@ void mesh_net_send_seg(struct mesh_net *net, uint32_t key_id, uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t src, uint16_t dst, uint32_t hdr, const void *seg, uint16_t seg_len); -struct mesh_net_heartbeat *mesh_net_heartbeat_get(struct mesh_net *net); -void mesh_net_heartbeat_init(struct mesh_net *net); -void mesh_net_heartbeat_send(struct mesh_net *net); +struct mesh_net_heartbeat_sub *mesh_net_get_heartbeat_sub(struct mesh_net *net); +int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, + uint8_t period_log); +struct mesh_net_heartbeat_pub *mesh_net_get_heartbeat_pub(struct mesh_net *net); +int mesh_net_set_heartbeat_pub(struct mesh_net *net, uint16_t dst, + uint16_t features, uint16_t idx, uint8_t ttl, + uint8_t count_log, uint8_t period_log); bool mesh_net_key_list_get(struct mesh_net *net, uint8_t *buf, uint16_t *count); uint16_t mesh_net_get_primary_idx(struct mesh_net *net); uint32_t mesh_net_friend_timeout(struct mesh_net *net, uint16_t addr); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YHUiCOu7LF+5nwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 04:26:51 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cFWiBuu7LF/DIwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 04:26:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 94E5EA1200; Fri, 7 Aug 2020 04:26:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726338AbgHGC03 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 22:26:29 -0400 Received: from mail-io1-f69.google.com ([209.85.166.69]:51546 "EHLO mail-io1-f69.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbgHGC01 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 22:26:27 -0400 Received: by mail-io1-f69.google.com with SMTP id l1so505401ioh.18 for <linux-bluetooth@vger.kernel.org>; Thu, 06 Aug 2020 19:26:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=P4HaL8fuExeVT2ON4Wu7436r4YukaeyETCtLgx2utNk=; b=oQXnr9yh3miiJBV5KOmOPj3Lx9fpdydDmCEtj6p1QeEV7wpi83ZoOmhUmEoIauxEu4 GNsrQnaSibC+eSIAe6odw0XukskvMNWMTYqFRdjFT0z0bt5vcP8gPxaTgpnhL+zOepwc les1OdtaODQUqHncjSvfrBXSrN6GHIhO39FzX/XES+O4iFGj7gTUl+n442aMP8LNssC1 PZ5rGmrs2F3bjCL5IHeUPcxAEz5Syx1WiksO8NfUr/2C6GZ2XrrfMKmLOtev+fP0gN9Y qCc4hvriWdLxVIlcl4Hc4ViVnyku1cGonyHiKcto+nVV7zIGYpyBNfRkbsTN8AKx08Pn YdUg== X-Gm-Message-State: AOAM531aelOh+1uBKYG47EmI/+6lxKgsZrzGpcDUMU/2fPLIU2QEWHj8 SZgajMOgVwSivxT81yvJvaXVMVW6KhD66ULo6XuMigYLue79 X-Google-Smtp-Source: ABdhPJxC+84P4eA4etCMj8bj2rNpwjY7+2e8369KBCiLW0ybXGFHpcCp84efsiZ87C3C9o/rgJ/W/0ZmK9AIsZ8STNyY0l/N0nb5 MIME-Version: 1.0 X-Received: by 2002:a6b:8b10:: with SMTP id n16mr2168652iod.11.1596767185982; Thu, 06 Aug 2020 19:26:25 -0700 (PDT) Date: Thu, 06 Aug 2020 19:26:25 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000e8d94d05ac40540a@google.com> Subject: WARNING: refcount bug in bt_accept_dequeue From: syzbot <syzbot+6048aa700d088954b0fc@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -2.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 94E5EA1200 X-Rspamd-UID: 10f2c1 Hello, syzbot found the following issue on: HEAD commit: 47ec5303 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1083e7ec900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e0c783f658542f35 dashboard link: https://syzkaller.appspot.com/bug?extid=6048aa700d088954b0fc compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11c227dc900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+6048aa700d088954b0fc@syzkaller.appspotmail.com ------------[ cut here ]------------ refcount_t: addition on 0; use-after-free. WARNING: CPU: 1 PID: 3805 at lib/refcount.c:25 refcount_warn_saturate+0x13d/0x1a0 lib/refcount.c:25 Kernel panic - not syncing: panic_on_warn set ... CPU: 1 PID: 3805 Comm: krfcommd Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 panic+0x264/0x7a0 kernel/panic.c:231 __warn+0x227/0x250 kernel/panic.c:600 report_bug+0x1b1/0x2e0 lib/bug.c:198 handle_bug+0x42/0x80 arch/x86/kernel/traps.c:235 exc_invalid_op+0x16/0x40 arch/x86/kernel/traps.c:255 asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:536 RIP: 0010:refcount_warn_saturate+0x13d/0x1a0 lib/refcount.c:25 Code: c7 93 1e 15 89 31 c0 e8 71 0c a9 fd 0f 0b eb a3 e8 88 66 d7 fd c6 05 97 4d ed 05 01 48 c7 c7 ca 1e 15 89 31 c0 e8 53 0c a9 fd <0f> 0b eb 85 e8 6a 66 d7 fd c6 05 7a 4d ed 05 01 48 c7 c7 f6 1e 15 RSP: 0018:ffffc90001997b80 EFLAGS: 00010246 RAX: b5077223a4630100 RBX: 0000000000000002 RCX: ffff88809902e380 RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000 RBP: 0000000000000002 R08: ffffffff815dffd9 R09: ffffed1015d262c0 R10: ffffed1015d262c0 R11: 0000000000000000 R12: ffff88808df4b4b8 R13: ffff88808df4b080 R14: 0000000000000000 R15: dffffc0000000000 refcount_add include/linux/refcount.h:205 [inline] refcount_inc include/linux/refcount.h:241 [inline] sock_hold include/net/sock.h:692 [inline] bt_accept_dequeue+0x34e/0x560 net/bluetooth/af_bluetooth.c:206 l2cap_sock_accept+0x21c/0x430 net/bluetooth/l2cap_sock.c:332 kernel_accept+0x143/0x410 net/socket.c:3569 rfcomm_accept_connection net/bluetooth/rfcomm/core.c:1931 [inline] rfcomm_process_sessions+0x1c5/0xc540 net/bluetooth/rfcomm/core.c:1990 rfcomm_run+0x3b5/0x900 net/bluetooth/rfcomm/core.c:2086 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Kernel Offset: disabled Rebooting in 86400 seconds.. --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0AgMOVPPLF/35wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 05:49:39 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 4KNYN1PPLF95kQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 05:49:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D77F54081A; Fri, 7 Aug 2020 05:49:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726166AbgHGDtb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 23:49:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbgHGDtb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 23:49:31 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1D80C061574 for <linux-bluetooth@vger.kernel.org>; Thu, 6 Aug 2020 20:49:30 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id c12so381086qtn.9 for <linux-bluetooth@vger.kernel.org>; Thu, 06 Aug 2020 20:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=NEu1QocgVLoaGMVACuICewytF2Fj42EX58ouyCXb0sU=; b=q+smDEOQePWETTuwhlfWOGGgqiRxw3AjECzNiPx36dUfQ+IYT/sNol6P2D1uQ2wkyL yk6PCyuhPn+opMDADrTeAF2DU1F2Ul94lOs8KtwYR9DtId5TgkVmR8RpqVxlipA8h/De yHHtCszZVttxHF3dLYCN3w+v3j6IsDeFu7upSepcKyk3ETiVDUxdrL3Th1Nbh6jQkilz 5XRqLQDfsqGz3RbCj4w3RUEvV/7k9Xg01rFjMZ6AVnKOis0MYirzOhXWErISqz+VtnOO mFGvoY7TyyVXIrNSoj7VZR1nDK0Bm3dkUqEwN/R4l8bizKez6vFTkxXq/uAED1XqcK9G k50w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=NEu1QocgVLoaGMVACuICewytF2Fj42EX58ouyCXb0sU=; b=dX5Y1Ybb01eFlYXcNwB4PF93lBXqYbjkCr6vDXA86vBpnMAT1kvLoQ0O5pUBVCzJTD tPhwc01ykvUovGLLCIUg70NtXNlGPUenAVoCwK+lV9U23cCyJwH5hu//c0HufNgOP5Z2 rK4AD81ZazYuJ91l3jVdri2LAOOwD8wtboPeYKIS2n/+soE5FD3HIVRdCanHGdIfmrxL xvWxdLXpMMPDl+0RIjukNhqBGXkeYi8bIiLAMrZnkhyGSeRysG4wAPQTCxjn6CV7FecV SmH5SheCmhqsIxlSHsKN81HJ+wZwaxare78wRdm74GjjotAd1X2wV+nN8vPdUMU7gQc4 /fIQ== X-Gm-Message-State: AOAM5312X5oJGXdJNw1wLniyCgszIYbM+7KvHkW+0QQ+jLsP1rTFUAwP 4q7+fb4Dk8Rb9TeAyKroMd1Xitw/EuY= X-Google-Smtp-Source: ABdhPJzkbDq1tPnWARF72l7Z2oDa29QsOv9Hpg5Lx3bFUsxjwuE3P5p9XWPECelkICIcNwrQE1abrg== X-Received: by 2002:ac8:1a14:: with SMTP id v20mr12379916qtj.269.1596772169154; Thu, 06 Aug 2020 20:49:29 -0700 (PDT) Received: from [172.17.0.2] ([52.251.91.70]) by smtp.gmail.com with ESMTPSA id v28sm7491153qtk.28.2020.08.06.20.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 20:49:28 -0700 (PDT) Message-ID: <5f2ccf48.1c69fb81.6d7c3.7937@mx.google.com> Date: Thu, 06 Aug 2020 20:49:28 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============8324179757018013729==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, inga.stotland@intel.com Subject: RE: [BlueZ,v5,10/10] mesh: Refactor heartbeat pub/sub Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200807013834.123263-11-inga.stotland@intel.com> References: <20200807013834.123263-11-inga.stotland@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 34 X-Rspamd-Score: 5.11 / 15.00 / 200.00 X-Rspamd-Queue-Id: D77F54081A X-Rspamd-UID: e4208d --===============8324179757018013729== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:UNNECESSARY_INT: Prefer 'long' over 'long int' as the int is unnecessary #88: FILE: mesh/cfgmod-server.c:485: + if (time_now.tv_sec >= (long int) sub->period) - total: 0 errors, 1 warnings, 784 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============8324179757018013729==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wHaRN1jPLF/35wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 05:49:44 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id AOv3NVjPLF/dhAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 05:49:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 11A32420DD; Fri, 7 Aug 2020 05:49:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726202AbgHGDtc (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 23:49:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbgHGDtb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 23:49:31 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43C13C061756 for <linux-bluetooth@vger.kernel.org>; Thu, 6 Aug 2020 20:49:31 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id b2so174104qvp.9 for <linux-bluetooth@vger.kernel.org>; Thu, 06 Aug 2020 20:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=szxJQP+sEk661ULD0Fm7uL5R+vWdcxCH+iUQg7SvJG4=; b=LLPOZQJrT8DXRl3OUjklo9TO960ZBqP+4M8bniNGRSbNuSDwW0tHv7gGwqN+h9SWtP kl50EsLIDGFySeoQC62TlBF9nxddebsjpwqbZIKipPJaCNCQ+j863nYnmuuB3t+sUYcc aRSgOOZmEuhP+w185Em42bwMqUoabvBG39LWWiqRK1x3XdNRd5dg3Ql7eKJK9pDm/AMz NTlRpVoeXRxRmeRFa8xDrWYvXdRKAvVGdnntyCqCGBqpD65dQOYtG2HNBivHMeIXNNQS Sp9Wm5ZSib87Z8XrgtuRL3PH0ZSqbGo5FtaIvWBnjtsy6pRUaVwJlybP0kNmSYHPthzo p2iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=szxJQP+sEk661ULD0Fm7uL5R+vWdcxCH+iUQg7SvJG4=; b=QF/Ic8xaBaJUkzwu5vpSDdCXCzh/mtcgoSEcOLiEchd5X3ooKTVxCrTpEduG+qCGLS /2JH/vNW0wG1PejCKjQGMcqbb3fVpVPo3uk5YZOo6s4iBGgVT9VRUBm+YPGmpokKDP57 x5qKGWwPESLg9ZZx8BFkAqzFp8AprYjvUUOK46mt/C6yBo3AeLAZ020DDBFkG4ttKD27 2yGEws8DtXZ2keHD2z3+2aMzBrtqoz4gMZqifiFkqabOxklmw261d2CIHAclMd9x6+0a v/GdJyXlHT/DkMFjAHukE+ZL1A86wSRk6ba0DwTWuhp5L8dCWsN/uPd+sQTAvH7RCpq0 w+Qg== X-Gm-Message-State: AOAM532/X/U7KHbb6EOTtBa/baFP3NFo3r17+4Uxd4Z7T09b6Tvxm3VF gJh28sZWvwyLmNTG9LKvhtRTwzM9f4E= X-Google-Smtp-Source: ABdhPJwpDVrZpZYN1QR08eIVGbhoHDN1CyQhGGkXUj9V82SUvm5PR4seyJKHGnhgFD++7eQr/J3hlQ== X-Received: by 2002:a0c:b791:: with SMTP id l17mr13206725qve.44.1596772167157; Thu, 06 Aug 2020 20:49:27 -0700 (PDT) Received: from [172.17.0.2] ([52.251.91.70]) by smtp.gmail.com with ESMTPSA id t12sm5706430qkt.56.2020.08.06.20.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 20:49:26 -0700 (PDT) Message-ID: <5f2ccf46.1c69fb81.4f4fe.eb7e@mx.google.com> Date: Thu, 06 Aug 2020 20:49:26 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============5005600605274241964==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, inga.stotland@intel.com Subject: RE: [BlueZ,v5,01/10] mesh: Clean up handling of config subscription messages Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200807013834.123263-2-inga.stotland@intel.com> References: <20200807013834.123263-2-inga.stotland@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 27 X-Rspamd-Score: 4.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 11A32420DD X-Rspamd-UID: 289d08 --===============5005600605274241964== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #398: FILE: mesh/cfgmod-server.c:744: + /* Fall Through */ - total: 0 errors, 1 warnings, 811 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============5005600605274241964==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MCxON13PLF9Z0wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 05:49:49 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id wNPMNV3PLF+LaAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 05:49:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 10293417C0; Fri, 7 Aug 2020 05:49:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726217AbgHGDtc (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 6 Aug 2020 23:49:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbgHGDtb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 6 Aug 2020 23:49:31 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6F52C061575 for <linux-bluetooth@vger.kernel.org>; Thu, 6 Aug 2020 20:49:30 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id d14so582609qke.13 for <linux-bluetooth@vger.kernel.org>; Thu, 06 Aug 2020 20:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=3TXlOXvMutsu5xQq+ZZJ0pZ5YdbjIi+ZhSRah2RzjiI=; b=LrlNXw+NKk1Pi5XJlQ4XNQNb7RIb8W3bRVIlVczSrEmNv3Psubz6527jDtdFnGyDv8 SdApNXNwws6t5RdKakJXVqoXvzRXaMMfpAdxMMfRU1ip3dujeHDqXzU1vC8Y4IwC7RcV Pd42XO6aQRU2qs4rIhTKedRUmj22GBikgERwdJ3bk2pzU5vROxmGN0XL9u3kkfrCxJJS ojwCWJObQmW9dZa+545sVb0M1qBHWG3ev7LHjdWy4P7usKdiL9om/hPToTjnAPQskidV 7hmD9lbEXP3zxuQszoHRB1aB6dbdlpBQQRcEDQ2yI2GtG7g395zAfcLVid/EzXBYAAmO Y+cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=3TXlOXvMutsu5xQq+ZZJ0pZ5YdbjIi+ZhSRah2RzjiI=; b=k0YoiB5GybMtzNQItxeFNMOKjtJ5IjpQoMe0O/KsEOhX2+MOGRmHAajp0wcW8EvPka /aZEGwWfdwsTbWddFOlSupjEI4/UMbSM8VdaNlLAAoHjFqE2hCZNQH5Zb2Nx8yYoOFu5 DKWDTJB4VA8BiageQ9KxKYmkf+BccTtXw52071VZ1mjKX30cPIVESzD7tU23Halap6w+ RymKBdzcVJYUBv/P2J2No6wC5rnbUOcFdKTi51rWdFCujspGkLToDHIuJjTszXCul80U hnkOQ9xjcCqOmjr9IbXxB6gT5PtxcyRBiVe5D9pKmULdPnXW3GxdikuIXoKSoUk1vooc 1zhw== X-Gm-Message-State: AOAM533LofPgnKFcnrKvohJ9hEYHhonvmCbAfelqi2acwdmrYxZ4Nz2/ Bv7XZ9XGQsU7WMRpaR0TU15Loml3Khc= X-Google-Smtp-Source: ABdhPJxrdKbgXZN5+njSpoEfBivCtaxnLovwK6tOYolvV0/DFH8hwFs4K3/OxO+BqSOoFJGCY/uMJQ== X-Received: by 2002:a37:a0d3:: with SMTP id j202mr11369300qke.365.1596772168107; Thu, 06 Aug 2020 20:49:28 -0700 (PDT) Received: from [172.17.0.2] ([52.251.91.70]) by smtp.gmail.com with ESMTPSA id h144sm5842437qke.83.2020.08.06.20.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 20:49:27 -0700 (PDT) Message-ID: <5f2ccf47.1c69fb81.8adb.f0af@mx.google.com> Date: Thu, 06 Aug 2020 20:49:27 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============1992372064314151277==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, inga.stotland@intel.com Subject: RE: [BlueZ,v5,05/10] mesh: Clean up handling of config net and app key messages Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200807013834.123263-6-inga.stotland@intel.com> References: <20200807013834.123263-6-inga.stotland@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: 31 X-Rspamd-Score: 4.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 10293417C0 X-Rspamd-UID: faa1bb --===============1992372064314151277== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #130: FILE: mesh/cfgmod-server.c:936: + /* Fall Through */ WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #189: FILE: mesh/cfgmod-server.c:956: + /* Fall Through */ - total: 0 errors, 2 warnings, 191 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============1992372064314151277==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4KdNFr79LF/hmwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 09:07:42 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id +PMcFb79LF9FRQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 09:07:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 302BB42110; Fri, 7 Aug 2020 09:07:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726459AbgHGHHS (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 7 Aug 2020 03:07:18 -0400 Received: from mail-io1-f69.google.com ([209.85.166.69]:48499 "EHLO mail-io1-f69.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgHGHHR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 7 Aug 2020 03:07:17 -0400 Received: by mail-io1-f69.google.com with SMTP id k10so955009iow.15 for <linux-bluetooth@vger.kernel.org>; Fri, 07 Aug 2020 00:07:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=qv4lE7G2xaxTSAJq3kTpN12XBqorrrJ0WTduANv5o2E=; b=tW8bGikvrU7PBdLwv8YUS9vnGbrHU+xw0c1YCXMDgu1nnA2u97fE3di7518QeFgDCt /+NmhBGy6uzM1ki4c5h0AgZtnWXiGBFeiYV0GiiE3hYENwRpw/PbcSpz56SG3UbeBNxV IDKrQuX2e7xOssXvChL+0WXSMkpSUXtd7ay5Pj8Z1UemPjqdat6dA2FlzQFCVZ4NVcfH U+djKx4BtFkcZyVoBDArJLzOpdGqs5ARuHf1iWRFM9qj3K3mnHU0FbPmPcYhOhEgYYCf Gur7crIL70eLKUoaUliyVFuqWpIMWY5VRyWA0KSVUe4kpXSv/Xe1boWmktVPZU3kKsme DStw== X-Gm-Message-State: AOAM533JihuAxdVrPUkerBDZNHfBX/8CEE+WzBwpIWWcllZkaZ3Nf2eg Oku9hM/IskWS104rfyG6xrc8d5CAOtK6BrH8o6Ht3D6OWHex X-Google-Smtp-Source: ABdhPJz+Fp2qewsy1tzCgdnTssJIOpyK1pr79B/YED4ieO7jQXedDYAOnf7J2eMFO/mmqoemvNgL3LD3hRLj31KCKx4NqGvCI7Iu MIME-Version: 1.0 X-Received: by 2002:a92:d8d2:: with SMTP id l18mr2843601ilo.94.1596784036194; Fri, 07 Aug 2020 00:07:16 -0700 (PDT) Date: Fri, 07 Aug 2020 00:07:16 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000042af6205ac444172@google.com> Subject: WARNING: locking bug in l2cap_chan_del From: syzbot <syzbot+01d7fc00b2a0419d01cc@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 302BB42110 X-Rspamd-UID: 40eb2b Hello, syzbot found the following issue on: HEAD commit: 47ec5303 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=111d93fa900000 kernel config: https://syzkaller.appspot.com/x/.config?x=7bb894f55faf8242 dashboard link: https://syzkaller.appspot.com/bug?extid=01d7fc00b2a0419d01cc compiler: gcc (GCC) 10.1.0-syz 20200507 Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+01d7fc00b2a0419d01cc@syzkaller.appspotmail.com ------------[ cut here ]------------ DEBUG_LOCKS_WARN_ON(1) WARNING: CPU: 0 PID: 12006 at kernel/locking/lockdep.c:183 hlock_class kernel/locking/lockdep.c:183 [inline] WARNING: CPU: 0 PID: 12006 at kernel/locking/lockdep.c:183 hlock_class kernel/locking/lockdep.c:172 [inline] WARNING: CPU: 0 PID: 12006 at kernel/locking/lockdep.c:183 check_wait_context kernel/locking/lockdep.c:4100 [inline] WARNING: CPU: 0 PID: 12006 at kernel/locking/lockdep.c:183 __lock_acquire+0x1674/0x5640 kernel/locking/lockdep.c:4376 Kernel panic - not syncing: panic_on_warn set ... CPU: 0 PID: 12006 Comm: kworker/0:14 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 panic+0x2e3/0x75c kernel/panic.c:231 __warn.cold+0x20/0x45 kernel/panic.c:600 report_bug+0x1bd/0x210 lib/bug.c:198 handle_bug+0x38/0x90 arch/x86/kernel/traps.c:235 exc_invalid_op+0x14/0x40 arch/x86/kernel/traps.c:255 asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:536 RIP: 0010:hlock_class kernel/locking/lockdep.c:183 [inline] RIP: 0010:hlock_class kernel/locking/lockdep.c:172 [inline] RIP: 0010:check_wait_context kernel/locking/lockdep.c:4100 [inline] RIP: 0010:__lock_acquire+0x1674/0x5640 kernel/locking/lockdep.c:4376 Code: d2 0f 85 f1 36 00 00 44 8b 15 b0 8e 57 09 45 85 d2 0f 85 1c fa ff ff 48 c7 c6 80 af 4b 88 48 c7 c7 80 aa 4b 88 e8 ce 36 eb ff <0f> 0b e9 02 fa ff ff c7 44 24 38 fe ff ff ff 41 bf 01 00 00 00 c7 RSP: 0018:ffffc900065878e0 EFLAGS: 00010086 RAX: 0000000000000000 RBX: 0000000000000004 RCX: 0000000000000000 RDX: ffff888051186380 RSI: ffffffff815d8eb7 RDI: fffff52000cb0f0e RBP: ffff888051186cf0 R08: 0000000000000000 R09: ffffffff89bcb3c3 R10: 00000000000010e6 R11: 0000000000000001 R12: 0000000000000000 R13: 000000000000126a R14: ffff888051186380 R15: 0000000000040000 lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:5005 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:175 spin_lock_bh include/linux/spinlock.h:359 [inline] lock_sock_nested+0x3b/0x110 net/core/sock.c:3040 l2cap_sock_teardown_cb+0x88/0x400 net/bluetooth/l2cap_sock.c:1520 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:823 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Kernel Offset: disabled Rebooting in 86400 seconds.. --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eL2oNdT/LF/CqgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 09:16:36 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oPDbM9T/LF+4WwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 09:16:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 598A9A11EC; Fri, 7 Aug 2020 09:16:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726550AbgHGHQZ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 7 Aug 2020 03:16:25 -0400 Received: from mail-io1-f70.google.com ([209.85.166.70]:36986 "EHLO mail-io1-f70.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726450AbgHGHQY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 7 Aug 2020 03:16:24 -0400 Received: by mail-io1-f70.google.com with SMTP id f6so997210ioa.4 for <linux-bluetooth@vger.kernel.org>; Fri, 07 Aug 2020 00:16:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=OO3Q8CrVHRBuOi/YH4CBh0Wwl12/N/j2vjuXZ553ypI=; b=ryjgWeQ1cFYkqxwaa8vJSRpkabbdzmDy8zXpLDoVxaWE9tgQ2cwEJlfT8vi7X1nie8 Mx+JUOxMVH3tD7ggQD/NTXKHmbRWy3VQcszRSwUlqQ8dk7g76g/CrnZbw6fLcsYI9ZVn kQ0BeHccVTTDa/yPzezhFI9tzjJoMD9lU0hfBrC94lkIc8ZJ++V+y5c5BCckqt2GTuJK ijHu0XM/siNqF632ukbqgo75t+qOzt0H9kDC7HNnahAu4bZq9pXozlPDpeUTq+01Uy3b rcMkDFpwt21vp0x16+ypzqcV+g1tUGJQImOPtO1/KgrSAOvqTOFW2tCPLJm28rXJsn2v Sx7w== X-Gm-Message-State: AOAM533WAr/G41N8ohRaCZsmcs0Xb0nhkMVclZmhe2PJGDWfeg4gshMa VeBwsocLPrjL9UGanEEAYMEWGSSKyzESECn/JV+fjL7gGgbm X-Google-Smtp-Source: ABdhPJwEIVuxGhXN9XBU+72Oqwehxi/aQnjzwAa7mc9utApu36Le+7G9OqhYyrqGjB5wKOnma3Rh22T/vpSIEhtceZUEhd14Nbal MIME-Version: 1.0 X-Received: by 2002:a92:9116:: with SMTP id t22mr3026831ild.305.1596784583029; Fri, 07 Aug 2020 00:16:23 -0700 (PDT) Date: Fri, 07 Aug 2020 00:16:23 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000dabdc805ac4461b5@google.com> Subject: INFO: trying to register non-static key in l2cap_chan_close From: syzbot <syzbot+3ae233f384d5b0aaa9e0@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.21 / 15.00 / 200.00 X-Rspamd-Queue-Id: 598A9A11EC X-Rspamd-UID: 13e376 Hello, syzbot found the following issue on: HEAD commit: 01830e6c Add linux-next specific files for 20200731 git tree: linux-next console output: https://syzkaller.appspot.com/x/log.txt?x=171e3dc6900000 kernel config: https://syzkaller.appspot.com/x/.config?x=2e226b2d1364112c dashboard link: https://syzkaller.appspot.com/bug?extid=3ae233f384d5b0aaa9e0 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15e18fec900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+3ae233f384d5b0aaa9e0@syzkaller.appspotmail.com INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 0 PID: 6982 Comm: kworker/0:1 Not tainted 5.8.0-rc7-next-20200731-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 assign_lock_key kernel/locking/lockdep.c:894 [inline] register_lock_class+0x157d/0x1630 kernel/locking/lockdep.c:1206 __lock_acquire+0xf9/0x5640 kernel/locking/lockdep.c:4303 lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:5003 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:175 spin_lock_bh include/linux/spinlock.h:359 [inline] lock_sock_nested+0x3b/0x110 net/core/sock.c:3048 l2cap_sock_teardown_cb+0x88/0x400 net/bluetooth/l2cap_sock.c:1520 l2cap_chan_close+0x2cc/0xb10 net/bluetooth/l2cap_core.c:832 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oDzoId//LF/hmwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 09:16:47 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 6MBZIN//LF8zOAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 09:16:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0C3AAA112B; Fri, 7 Aug 2020 09:16:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726606AbgHGHQb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 7 Aug 2020 03:16:31 -0400 Received: from mail-il1-f199.google.com ([209.85.166.199]:55405 "EHLO mail-il1-f199.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726094AbgHGHQX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 7 Aug 2020 03:16:23 -0400 Received: by mail-il1-f199.google.com with SMTP id i78so805755ill.22 for <linux-bluetooth@vger.kernel.org>; Fri, 07 Aug 2020 00:16:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=W4cVy11OCLnN/zPHpr+tWScWweV3Vb2c1Wlz/XJooDc=; b=sChHW1wpxKQLgZTsGhFZ4k8bXWY9I+rTW8c55+IUNA9vOv/DJA3N1hK9U+5XZ9cKzn sBeykbQUP8IQ1XWOAAPptTfBJvVt1VmmvLAuEdXay8zHZWdo8ddqNLXw5lb84HcjJrn4 RIUP6W0DgGtrjPF+J6N+5x/TGcZFpV1l8uqU1IfB3pADH4DZtnzgLqeRvcPu70cC8y5z rto8a1LbKNFRWLsDm47EPGb1JtNFF5K+nl0Un2CIm1cUxUiuL/E00ngTN6l2fcPTdozN tUOHfWGaAIYYwncOhbtZx2sfIuCdFj5Nh0NX/qywGwmkT010d/Fc0EyjEUHXNjAHdFeu 4VlQ== X-Gm-Message-State: AOAM531kAwRKQ2ABt1F2xGlpZB0HQzDrE48hSL1td21EQt87gkoAODfQ EY49VttpAhNcGsuLvUmxPXm5V1j6p70NUduNZlkFlO0YepfW X-Google-Smtp-Source: ABdhPJxpxMAx65WmbFFSsgv31NegkqlA8MObGTlpV+ua7JbfBjLtrdjKhGoSE+RixHS8C6A5HqQansj7ioPkTjlLoXF/+U8dRujA MIME-Version: 1.0 X-Received: by 2002:a92:d782:: with SMTP id d2mr3215408iln.8.1596784582572; Fri, 07 Aug 2020 00:16:22 -0700 (PDT) Date: Fri, 07 Aug 2020 00:16:22 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000d3c45105ac44616f@google.com> Subject: memory leak in hci_conn_add From: syzbot <syzbot+52b86f9cc3cda3b318e0@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0C3AAA112B X-Rspamd-UID: dd79df Hello, syzbot found the following issue on: HEAD commit: 47ec5303 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=11a0122c900000 kernel config: https://syzkaller.appspot.com/x/.config?x=eab224ce244e423c dashboard link: https://syzkaller.appspot.com/bug?extid=52b86f9cc3cda3b318e0 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=118774aa900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+52b86f9cc3cda3b318e0@syzkaller.appspotmail.com 2020/08/07 02:25:22 executed programs: 153 BUG: memory leak unreferenced object 0xffff88811aef9800 (size 2048): comm "syz-executor.0", pid 7170, jiffies 4295036619 (age 51.850s) hex dump (first 32 bytes): 00 40 3d 15 81 88 ff ff 22 01 00 00 00 00 ad de .@=....."....... 00 00 00 00 11 aa aa aa aa aa 00 aa aa aa aa aa ................ backtrace: [<00000000d9c20f00>] kmalloc include/linux/slab.h:555 [inline] [<00000000d9c20f00>] kzalloc include/linux/slab.h:669 [inline] [<00000000d9c20f00>] hci_conn_add+0x2e/0x4a0 net/bluetooth/hci_conn.c:525 [<0000000035c3df04>] hci_connect_acl net/bluetooth/hci_conn.c:1252 [inline] [<0000000035c3df04>] hci_connect_acl+0x154/0x170 net/bluetooth/hci_conn.c:1237 [<0000000084224e06>] l2cap_chan_connect+0x2bb/0xbb0 net/bluetooth/l2cap_core.c:7900 [<000000008efaf6d0>] bt_6lowpan_connect net/bluetooth/6lowpan.c:932 [inline] [<000000008efaf6d0>] lowpan_control_write+0x2fb/0x380 net/bluetooth/6lowpan.c:1166 [<00000000d92efe51>] full_proxy_write+0x61/0x90 fs/debugfs/file.c:234 [<000000007171039b>] vfs_write+0xfa/0x250 fs/read_write.c:576 [<000000006150b244>] ksys_write+0x72/0x120 fs/read_write.c:631 [<00000000c631a395>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 [<00000000f2b9f07c>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 BUG: memory leak unreferenced object 0xffff88811c49f200 (size 512): comm "syz-executor.0", pid 7170, jiffies 4295036619 (age 51.850s) hex dump (first 32 bytes): 00 98 ef 1a 81 88 ff ff c0 9a 3e 15 81 88 ff ff ..........>..... fd 03 00 00 00 00 00 00 00 06 00 00 00 00 00 00 ................ backtrace: [<000000003ade7b37>] kmalloc include/linux/slab.h:555 [inline] [<000000003ade7b37>] kzalloc include/linux/slab.h:669 [inline] [<000000003ade7b37>] l2cap_conn_add.part.0+0x3b/0x300 net/bluetooth/l2cap_core.c:7702 [<00000000c0f3ada8>] l2cap_conn_add net/bluetooth/l2cap_core.c:7888 [inline] [<00000000c0f3ada8>] l2cap_chan_connect+0x742/0xbb0 net/bluetooth/l2cap_core.c:7909 [<000000008efaf6d0>] bt_6lowpan_connect net/bluetooth/6lowpan.c:932 [inline] [<000000008efaf6d0>] lowpan_control_write+0x2fb/0x380 net/bluetooth/6lowpan.c:1166 [<00000000d92efe51>] full_proxy_write+0x61/0x90 fs/debugfs/file.c:234 [<000000007171039b>] vfs_write+0xfa/0x250 fs/read_write.c:576 [<000000006150b244>] ksys_write+0x72/0x120 fs/read_write.c:631 [<00000000c631a395>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 [<00000000f2b9f07c>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cFSdNAoBLV/hmwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 09:21:46 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4ANhMwoBLV+4zAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 09:21:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A95DFA11DF; Fri, 7 Aug 2020 09:21:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726486AbgHGHV0 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 7 Aug 2020 03:21:26 -0400 Received: from verein.lst.de ([213.95.11.211]:52859 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgHGHV0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 7 Aug 2020 03:21:26 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id A67A168D0F; Fri, 7 Aug 2020 09:21:20 +0200 (CEST) Date: Fri, 7 Aug 2020 09:21:20 +0200 From: Christoph Hellwig <hch@lst.de> To: Eric Dumazet <eric.dumazet@gmail.com> Cc: Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com>, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org, Stefan Schmidt <stefan@datenfreihafen.org> Subject: Re: [PATCH 25/26] net: pass a sockptr_t into ->setsockopt Message-ID: <20200807072120.GB2086@lst.de> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-26-hch@lst.de> <6357942b-0b6e-1901-7dce-e308c9fac347@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6357942b-0b6e-1901-7dce-e308c9fac347@gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.07 / 15.00 / 200.00 X-Rspamd-Queue-Id: A95DFA11DF X-Rspamd-UID: a9a694 On Thu, Aug 06, 2020 at 03:21:25PM -0700, Eric Dumazet wrote: > converting get_user(...) to copy_from_sockptr(...) really assumed the optlen > has been validated to be >= sizeof(int) earlier. > > Which is not always the case, for example here. Yes. And besides the bpfilter mess the main reason I even had to add the sockptr vs just copying optlen in the high-level socket code. Please take a look at the patch in the other thread to just revert to the "dumb" version everywhere. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eOUxJWIcLV8ziwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 11:18:26 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id mKySI2IcLV/4jwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 11:18:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 247614210E; Fri, 7 Aug 2020 11:18:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727858AbgHGJSP (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 7 Aug 2020 05:18:15 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:39637 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726511AbgHGJSI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 7 Aug 2020 05:18:08 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-126-koqkZgaFNyeZIHOyATR4EA-1; Fri, 07 Aug 2020 10:18:04 +0100 X-MC-Unique: koqkZgaFNyeZIHOyATR4EA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 7 Aug 2020 10:18:03 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Fri, 7 Aug 2020 10:18:03 +0100 From: David Laight <David.Laight@ACULAB.COM> To: 'Eric Dumazet' <eric.dumazet@gmail.com>, Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com> CC: "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "bpf@vger.kernel.org" <bpf@vger.kernel.org>, "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>, "coreteam@netfilter.org" <coreteam@netfilter.org>, "linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>, "linux-hams@vger.kernel.org" <linux-hams@vger.kernel.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "bridge@lists.linux-foundation.org" <bridge@lists.linux-foundation.org>, "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>, "dccp@vger.kernel.org" <dccp@vger.kernel.org>, "linux-decnet-user@lists.sourceforge.net" <linux-decnet-user@lists.sourceforge.net>, "linux-wpan@vger.kernel.org" <linux-wpan@vger.kernel.org>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, "mptcp@lists.01.org" <mptcp@lists.01.org>, "lvs-devel@vger.kernel.org" <lvs-devel@vger.kernel.org>, "rds-devel@oss.oracle.com" <rds-devel@oss.oracle.com>, "linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>, "tipc-discussion@lists.sourceforge.net" <tipc-discussion@lists.sourceforge.net>, "linux-x25@vger.kernel.org" <linux-x25@vger.kernel.org>, Stefan Schmidt <stefan@datenfreihafen.org> Subject: RE: [PATCH 25/26] net: pass a sockptr_t into ->setsockopt Thread-Topic: [PATCH 25/26] net: pass a sockptr_t into ->setsockopt Thread-Index: AQHWbD/ze4VO5Mh7NUG6O93LfP2Gq6ksXaow Date: Fri, 7 Aug 2020 09:18:03 +0000 Message-ID: <f21589f1262640b09ca27ed20f8e6790@AcuMS.aculab.com> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-26-hch@lst.de> <6357942b-0b6e-1901-7dce-e308c9fac347@gmail.com> In-Reply-To: <6357942b-0b6e-1901-7dce-e308c9fac347@gmail.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.87 / 15.00 / 200.00 X-Rspamd-Queue-Id: 247614210E X-Rspamd-UID: f7bc43 RnJvbTogRXJpYyBEdW1hemV0DQo+IFNlbnQ6IDA2IEF1Z3VzdCAyMDIwIDIzOjIxDQo+IA0KPiBP biA3LzIyLzIwIDExOjA5IFBNLCBDaHJpc3RvcGggSGVsbHdpZyB3cm90ZToNCj4gPiBSZXdvcmsg dGhlIHJlbWFpbmluZyBzZXRzb2Nrb3B0IGNvZGUgdG8gcGFzcyBhIHNvY2twdHJfdCBpbnN0ZWFk IG9mIGENCj4gPiBwbGFpbiB1c2VyIHBvaW50ZXIuICBUaGlzIHJlbW92ZXMgdGhlIGxhc3QgcmVt YWluaW5nIHNldF9mcyhLRVJORUxfRFMpDQo+ID4gb3V0c2lkZSBvZiBhcmNoaXRlY3R1cmUgc3Bl Y2lmaWMgY29kZS4NCj4gPg0KPiA+IFNpZ25lZC1vZmYtYnk6IENocmlzdG9waCBIZWxsd2lnIDxo Y2hAbHN0LmRlPg0KPiA+IEFja2VkLWJ5OiBTdGVmYW4gU2NobWlkdCA8c3RlZmFuQGRhdGVuZnJl aWhhZmVuLm9yZz4gW2llZWU4MDIxNTRdDQo+ID4gLS0tDQo+IA0KPiANCj4gLi4uDQo+IA0KPiA+ IGRpZmYgLS1naXQgYS9uZXQvaXB2Ni9yYXcuYyBiL25ldC9pcHY2L3Jhdy5jDQo+ID4gaW5kZXgg NTk0ZTAxYWQ2NzBhYTYuLjg3NGYwMWNkN2FlYzQyIDEwMDY0NA0KPiA+IC0tLSBhL25ldC9pcHY2 L3Jhdy5jDQo+ID4gKysrIGIvbmV0L2lwdjYvcmF3LmMNCj4gPiBAQCAtOTcyLDEzICs5NzIsMTMg QEAgc3RhdGljIGludCByYXd2Nl9zZW5kbXNnKHN0cnVjdCBzb2NrICpzaywgc3RydWN0IG1zZ2hk ciAqbXNnLCBzaXplX3QgbGVuKQ0KPiA+ICB9DQo+ID4NCj4gDQo+IC4uLg0KPiANCj4gPiAgc3Rh dGljIGludCBkb19yYXd2Nl9zZXRzb2Nrb3B0KHN0cnVjdCBzb2NrICpzaywgaW50IGxldmVsLCBp bnQgb3B0bmFtZSwNCj4gPiAtCQkJICAgIGNoYXIgX191c2VyICpvcHR2YWwsIHVuc2lnbmVkIGlu dCBvcHRsZW4pDQo+ID4gKwkJCSAgICAgICBzb2NrcHRyX3Qgb3B0dmFsLCB1bnNpZ25lZCBpbnQg b3B0bGVuKQ0KPiA+ICB7DQo+ID4gIAlzdHJ1Y3QgcmF3Nl9zb2NrICpycCA9IHJhdzZfc2soc2sp Ow0KPiA+ICAJaW50IHZhbDsNCj4gPg0KPiA+IC0JaWYgKGdldF91c2VyKHZhbCwgKGludCBfX3Vz ZXIgKilvcHR2YWwpKQ0KPiA+ICsJaWYgKGNvcHlfZnJvbV9zb2NrcHRyKCZ2YWwsIG9wdHZhbCwg c2l6ZW9mKHZhbCkpKQ0KPiA+ICAJCXJldHVybiAtRUZBVUxUOw0KPiA+DQo+IA0KPiBjb252ZXJ0 aW5nIGdldF91c2VyKC4uLikgICB0byAgY29weV9mcm9tX3NvY2twdHIoLi4uKSByZWFsbHkgYXNz dW1lZCB0aGUgb3B0bGVuDQo+IGhhcyBiZWVuIHZhbGlkYXRlZCB0byBiZSA+PSBzaXplb2YoaW50 KSBlYXJsaWVyLg0KPiANCj4gV2hpY2ggaXMgbm90IGFsd2F5cyB0aGUgY2FzZSwgZm9yIGV4YW1w bGUgaGVyZS4NCj4gDQo+IFVzZXIgYXBwbGljYXRpb24gY2FuIGZvb2wgdXMgcGFzc2luZyBvcHRs ZW49MCwgYW5kIGEgdXNlciBwb2ludGVyIG9mIGV4YWN0bHkgVEFTS19TSVpFLTENCg0KV29uJ3Qg dGhlIHVzZXIgcG9pbnRlciBmb3JjZSBjb3B5X2Zyb21fc29ja3B0cigpIHRvIGNhbGwNCmNvcHlf ZnJvbV91c2VyKCkgd2hpY2ggd2lsbCB0aGVuIGRvIGFjY2Vzc19vaygpIG9uIHRoZSBlbnRpcmUN CnJhbmdlIGFuZCBzbyByZXR1cm4gLUVGQVVMVC4NCg0KVGhlIG9ubHkgcHJvYmxlbXMgYXJpc2Ug aWYgdGhlIGtlcm5lbCBjb2RlIGFkZHMgYW4gb2Zmc2V0IHRvIHRoZQ0KdXNlciBhZGRyZXNzLg0K QW5kIHRoZSBsYXRlciBwYXRjaCBhZGRlZCBhbiBvZmZzZXQgdG8gdGhlIGNvcHkgZnVuY3Rpb25z Lg0KDQoJRGF2aWQNCg0KLQ0KUmVnaXN0ZXJlZCBBZGRyZXNzIExha2VzaWRlLCBCcmFtbGV5IFJv YWQsIE1vdW50IEZhcm0sIE1pbHRvbiBLZXluZXMsIE1LMSAxUFQsIFVLDQpSZWdpc3RyYXRpb24g Tm86IDEzOTczODYgKFdhbGVzKQ0K Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uFgYJ3hgLV8vYgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 16:08:56 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id aLZcJXhgLV+SAwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 16:08:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9F4C7A11E7; Fri, 7 Aug 2020 16:08:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726699AbgHGOIg (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 7 Aug 2020 10:08:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbgHGOAI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 7 Aug 2020 10:00:08 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AB80C061575; Fri, 7 Aug 2020 06:59:26 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id u128so1042121pfb.6; Fri, 07 Aug 2020 06:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KkgC/IfZgfpRrHJateeuAuB7TNckjX9ScGM6wvRUKgI=; b=gDMavG5S3kcl1rHlmaIoh4h3AYKDs61EYZN8cDWB74dcRQJBQd0+pzoVYEOzovxZ6h eJWijr6Xw5aNrN6uqIKECi/C3CMLum49xD4ayGZU5SCqKI5EIhok9ewLtPGgHhEd19uT /EYlh//DysbcBPh9myNWMQzxHPisMLRScDsNeoOsup5vA4gWdGhGu8be8vzbdTD8VZaS TVS6/qccykmKkXJN8moBVApR9dpm8+L+Ifu5XZwHri5sFP3sqGK5xxLy+2p6JmvH7M+9 0IBgfEunDLgdwJAg64hXWLJ3rTkUD542IaGzrBdHgqq/MtvSXsQAdXcgy5CbwBggVq2/ FgMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KkgC/IfZgfpRrHJateeuAuB7TNckjX9ScGM6wvRUKgI=; b=OsPnzlh2Y5QffI1aJDF3jvTqAqErGnS3arYXuqTSYhEhrhieykS7544+GjusuVO0ZG J0bt7bXrBW1jaG9m2r392qjWcFH/7ZdbajlXUqGMtct9SpgBeqGb25XcRy/2mc0vz1OV OXo/udPbhZiHU3sYbaCTxU2XdqqD1YDtC5VKgXrycsNLn+NjyWYh28qxEEwccm0oauJH H2GAOdu1MMJuahDM4cmzMssXGXTDRy2g5JLp1XjNg5N36S4sRXq3QVyw632AoB4Mv8mZ TPBjreU4XIjlQBGpGvqRI31H3tDmTkxn31JV3VPcub03Y5NSt0RBRvJrJRhMPTf2bQ/6 8hgA== X-Gm-Message-State: AOAM5316x3pKKHeQkf8jueZfTIkw2Zu7vqSZ19VgMzIoimen3CRO9iSg MFsyXnHEPSxgh3KIZHUM4H3Er3WTtuBjLg== X-Google-Smtp-Source: ABdhPJz4Wsqd8oawH81Y8HKewsfkWQhSxRPY2Ov5elBmaChRBM6h41G4JBnG2tm9eAT+qNWOK3v2Lw== X-Received: by 2002:aa7:8a4d:: with SMTP id n13mr14406135pfa.143.1596808765226; Fri, 07 Aug 2020 06:59:25 -0700 (PDT) Received: from localhost ([2001:e42:102:1532:160:16:113:140]) by smtp.gmail.com with ESMTPSA id u15sm11212157pju.42.2020.08.07.06.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 06:59:24 -0700 (PDT) From: Coiby Xu <coiby.xu@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, syzkaller-bugs@googlegroups.com, syzbot+305a91e025a73e4fd6ce@syzkaller.appspotmail.com, Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, netdev@vger.kernel.org (open list:NETWORKING [GENERAL]), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] Bluetooth: Delete both L2CAP connction and HCI channel when completing destroying logical link in AMP Date: Fri, 7 Aug 2020 21:59:17 +0800 Message-Id: <20200807135918.1177869-1-coiby.xu@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.70 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9F4C7A11E7 X-Rspamd-UID: efd9e0 When destroying a logical link (HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE) in AMP, L2CAP connection (struct l2cap_conn) should be deleted together with HCI channel (struct hci_chan). Otherwise HCI channel will be deleted twice when unregistering a HCI device. `static void l2cap_conn_del(struct hci_conn *hcon, int err)` could achieve this purpose. Make it a public function. Reported-and-tested-by: syzbot+305a91e025a73e4fd6ce@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=305a91e025a73e4fd6ce Signed-off-by: Coiby Xu <coiby.xu@gmail.com> --- include/net/bluetooth/l2cap.h | 1 + net/bluetooth/amp.c | 2 +- net/bluetooth/l2cap_core.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 8f1e6a7a2df8..8508a433d6ac 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -988,6 +988,7 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan); typedef void (*l2cap_chan_func_t)(struct l2cap_chan *chan, void *data); void l2cap_chan_list(struct l2cap_conn *conn, l2cap_chan_func_t func, void *data); +void l2cap_conn_del(struct hci_conn *hcon, int err); void l2cap_chan_del(struct l2cap_chan *chan, int err); void l2cap_send_conn_req(struct l2cap_chan *chan); void l2cap_move_start(struct l2cap_chan *chan); diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c index 9c711f0dfae3..cee02f009cef 100644 --- a/net/bluetooth/amp.c +++ b/net/bluetooth/amp.c @@ -584,5 +584,5 @@ void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason) { BT_DBG("hchan %p", hchan); - hci_chan_del(hchan); + l2cap_conn_del(hchan->conn, bt_to_errno(reason)); } diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index fe913a5c754a..38f60fb9b515 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1851,7 +1851,7 @@ static void l2cap_unregister_all_users(struct l2cap_conn *conn) } } -static void l2cap_conn_del(struct hci_conn *hcon, int err) +void l2cap_conn_del(struct hci_conn *hcon, int err) { struct l2cap_conn *conn = hcon->l2cap_data; struct l2cap_chan *chan, *l; -- 2.27.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ANKVC2NnLV8YfQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 16:38:27 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AHXvCWNnLV+SAwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 16:38:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 40643A1279; Fri, 7 Aug 2020 16:38:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726061AbgHGOiV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 7 Aug 2020 10:38:21 -0400 Received: from mga02.intel.com ([134.134.136.20]:2918 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbgHGOiT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 7 Aug 2020 10:38:19 -0400 IronPort-SDR: JBKB/iKG94dz3Q6iSwUEZpGz7SBsYt8uEAuSYMZSq9xks7EIXgHSc6nkHptN/BbA77HHyTWJVy /nFuHZY/T6Ig== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="140970079" X-IronPort-AV: E=Sophos;i="5.75,446,1589266800"; d="scan'208";a="140970079" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 07:38:17 -0700 IronPort-SDR: 2VCzMbhwvmdynh76gLo3uoxmRhCgL10N9hJRkGSSlHbUw1vpgxwrxV9CNPV0SoGOIynhJ8yJRm 3EH0BNao0BvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,446,1589266800"; d="scan'208";a="316555900" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga004.fm.intel.com with ESMTP; 07 Aug 2020 07:38:17 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 7 Aug 2020 07:38:16 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 7 Aug 2020 07:38:16 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.175) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 7 Aug 2020 07:38:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GCvEgCh72LtOGPlNcY30CXKp10p3WjYgKPit1X0j4LqXgIKtCaO4QWmbDy7lVBiGeTSzLnS1d4QiDIaQ+LmGgUjz+9jhnubSpgSkqDMpANkIYucamXx32fijOiNZ0vpcyLn99DnbhN9toKaefuy63AlyCz92ztlSOZdUWngmBUAJe9vxcc1ib13DAdHPatfhLbAX1GZrCxd4XqPQPOiw+p2RP2tMRxiWYL308c7jfQIRjBWFYR/af80NkKlm4stWpxXFYcAsrkPLNKDbauN00E0zN3pFRWFiPpJANJ95ckc6CSyUK/Z1Sbrwh+ddHqaJHDZo+4hcjLAkahkB9M0wuQ== 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-SenderADCheck; bh=pqvkrfHdYsfZQSezKp9/0eIQaxEIX9aNAXTsKYZSSSg=; b=fzEAuX023MBXpL5rZ71mtBWdXTtxaV8Meqz1smzNwL2urE6IQegJD2tXTGS/9U5ZpgOWdHLPAkLz2KAaWbdF0yNnviFf0JlYm0WbOa9ZD3E4Db2ck0lIkeKaIFQ6BSRaSS3tnlI/oK4fhG7/qCzA+zytI/PnzW0WtLsUOACF6y1Vx8ddUOXVY75hoHJrxSlHHUdundvuA4TRG14PCt3O6rasmGLXq+yA0pixVS3Ij4PSA/pNDwyDFGpZI/5Z/HbITOYqY4QplJJzDI1nIk3Eh4JG1BPEcp77/6B+cZu0c+9UmibqDrNp68mIphFGQk4nNO54eKpNqXPjRfHl6jFRMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pqvkrfHdYsfZQSezKp9/0eIQaxEIX9aNAXTsKYZSSSg=; b=apo5YAKKVTWVrJWDPq49fjo5/Q4W0QuuqfqjEEKJzgmIPg95ckJSunnCfzv519KuXEzNVSfTyHAbRLWz9r9gxRpcBRD1w9+I5H5HRKFYbgnhzGs2OKobVkDs4IXJVxJJAGSPX9SODP5EzdbLVXofmpLI/E9tB3iZB51n1Ua0OgQ= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1904.namprd11.prod.outlook.com (2603:10b6:300:111::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16; Fri, 7 Aug 2020 14:38:13 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3261.020; Fri, 7 Aug 2020 14:38:13 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: Use correct TTL value to send model publication Thread-Topic: [PATCH BlueZ] mesh: Use correct TTL value to send model publication Thread-Index: AQHWbESudHCYPsSHdkuCloOt6dEuzaksuDcA Date: Fri, 7 Aug 2020 14:38:13 +0000 Message-ID: <c4626c74a850df528c073e981000dbe5e9c13f1d.camel@intel.com> References: <20200806225523.109092-1-inga.stotland@intel.com> In-Reply-To: <20200806225523.109092-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.54.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b7dc60e5-0bbe-4d0f-202d-08d83adf83b5 x-ms-traffictypediagnostic: MWHPR11MB1904: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR11MB190473083F13D8CA3D788EBFE1490@MWHPR11MB1904.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:3968; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6RnIceUjBxKctpeiM7U9m5IGk8kRABSZghFt3BbLInUH+YuRJ3poDCFHL+WAZ0R3vjos5PDJRZOgG0chlwIIkiKZsR6SPpWmpAGzNpqr82iamS0PtEc9NN+qW0DP5m/X8bOMTeKP+AvfRnnxt5qstsa+EyC3VtEYgCl71JhMQvk40bNMWVjC0pW6RWI1b/uvurUe7myuRQRQiXb6RF+JC7/mrzkcfbuMRBLep20naKZeawHBrDX8bNtopMjq6jl+WaLu/u/ECgv2Ag689wc7b9jvidbnnM2RQnBQXi4bZNythmTE8HTkrvUkuE5lNG8UoZrQuoKsl0zYgVOxudngmw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(39860400002)(396003)(376002)(366004)(346002)(478600001)(71200400001)(6636002)(110136005)(8936002)(316002)(6486002)(8676002)(2906002)(186003)(26005)(66446008)(66476007)(66556008)(83380400001)(91956017)(76116006)(36756003)(6506007)(5660300002)(6512007)(2616005)(86362001)(64756008)(66946007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: OyCOzgpcAkx43rSGwE27GoUzKS90AaCvGR4DritoJLWI11reVfVNE7BZPogDwDfU898Ione0s0YNgFrqQyTeTZp3h5PZN2Rd/MKDuD/d04+GHO1vdLIRZ9DL4teN6VN3VSKBWBfzFzwadxU1D9DH9m0+yaYI0QfpAZK9cDASo7AkVeCeJY7LjUosLgq5mZwEwhJ/ozw3CbnvKJAaw8UWCBO5I5XL/7wt1PbLkX707O3hR4sTieAywVyyBP4BkBMdksl9zRGRVPsllF9uk2dlPrxy5cAappcx6kfLg4tQJf9tGKI5CFZUV7m4k49PjCZwtEApirG0v5+/fyUVBpXpXoB/OiyRE1/HerfzUgWxMWX4DCi+4dSWdgMJaqli0PF2A0gm5cYP+5GZlPEvWAlunZI1XGxu5C/Ijg/rab7Us4WtVIsA0JLBXQdGYXo7Ye+NHMShTv1xbO7yQ8K41S/g83gVh0tMM+oBK7j4vLjibY7wB9xpYcV2Fa2RtNaZhhBBH8MT7vUwGBZs5UQuaFh8mKKijfTddHKu1z5vma49FF+3fzs2J8e3EXecMqVU+v4KsidKnt8X9Nxu9Dd58w37SdZXFyiCFhMoUrJk6/wYpGk7EDJlfGSTCp8acsxJkarZXV47BsIAUA5o4rCpJXZS3Q== Content-Type: text/plain; charset="utf-8" Content-ID: <7940D0DF24EE424780D3F4F344AF1673@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7dc60e5-0bbe-4d0f-202d-08d83adf83b5 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Aug 2020 14:38:13.3932 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: QFqaAbOciOMS2/OTtcbUXaAqveLAG1JrbnWL/A5XbgvvHzc0TWDnK1iXaX2UlN/2YCBXZlutfGx6dGXdkiS1oA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1904 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 40643A1279 X-Rspamd-UID: 5d6a03 QXBwbGllZA0KT24gVGh1LCAyMDIwLTA4LTA2IGF0IDE1OjU1IC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBXaGVuIHNlbmRpbmcgbW9kZWwgcHVibGlzaGluZyBkYXRhLCB1c2UgVFRMIHZh bHVlIGNvbmZpZ3VyZWQgZm9yDQo+IHRoYXQgcHVibGljYXRpb24gaW5zdGVhZCBvZiB0aGUgZGVm YXVsdCBUVEwgdmFsdWUgdXNlZCBmb3IgcmVndWxhcg0KPiBtZXNzYWdlcy4NCj4gLS0tDQo+ICBt ZXNoL21vZGVsLmMgfCAgNCArKy0tDQo+ICBtZXNoL21vZGVsLmggfCAgMiArLQ0KPiAgbWVzaC9u b2RlLmMgIHwgMTEgKysrKy0tLS0tLS0NCj4gIDMgZmlsZXMgY2hhbmdlZCwgNyBpbnNlcnRpb25z KCspLCAxMCBkZWxldGlvbnMoLSkNCj4gDQo+IGRpZmYgLS1naXQgYS9tZXNoL21vZGVsLmMgYi9t ZXNoL21vZGVsLmMNCj4gaW5kZXggZWY3NjY4MTQ3Li4wNDNhZDFkNzAgMTAwNjQ0DQo+IC0tLSBh L21lc2gvbW9kZWwuYw0KPiArKysgYi9tZXNoL21vZGVsLmMNCj4gQEAgLTEwMjIsNyArMTAyMiw3 IEBAIGRvbmU6DQo+ICB9DQo+ICANCj4gIGludCBtZXNoX21vZGVsX3B1Ymxpc2goc3RydWN0IG1l c2hfbm9kZSAqbm9kZSwgdWludDMyX3QgaWQsIHVpbnQxNl90IHNyYywNCj4gLQkJCQl1aW50OF90 IHR0bCwgY29uc3Qgdm9pZCAqbXNnLCB1aW50MTZfdCBtc2dfbGVuKQ0KPiArCQkJCQljb25zdCB2 b2lkICptc2csIHVpbnQxNl90IG1zZ19sZW4pDQo+ICB7DQo+ICAJc3RydWN0IG1lc2hfbmV0ICpu ZXQgPSBub2RlX2dldF9uZXQobm9kZSk7DQo+ICAJc3RydWN0IG1lc2hfbW9kZWwgKm1vZDsNCj4g QEAgLTEwNjMsNyArMTA2Myw3IEBAIGludCBtZXNoX21vZGVsX3B1Ymxpc2goc3RydWN0IG1lc2hf bm9kZSAqbm9kZSwgdWludDMyX3QgaWQsIHVpbnQxNl90IHNyYywNCj4gIA0KPiAgCXJlc3VsdCA9 IG1zZ19zZW5kKG5vZGUsIG1vZC0+cHViLT5jcmVkZW50aWFsICE9IDAsIHNyYywNCj4gIAkJCQlt b2QtPnB1Yi0+YWRkciwgbW9kLT5wdWItPmlkeCwgbmV0X2lkeCwNCj4gLQkJCQlsYWJlbCwgdHRs LCBmYWxzZSwgbXNnLCBtc2dfbGVuKTsNCj4gKwkJCQlsYWJlbCwgbW9kLT5wdWItPnR0bCwgZmFs c2UsIG1zZywgbXNnX2xlbik7DQo+ICANCj4gIAlyZXR1cm4gcmVzdWx0ID8gTUVTSF9FUlJPUl9O T05FIDogTUVTSF9FUlJPUl9GQUlMRUQ7DQo+ICB9DQo+IGRpZmYgLS1naXQgYS9tZXNoL21vZGVs LmggYi9tZXNoL21vZGVsLmgNCj4gaW5kZXggMGQ4ZGRkZjkyLi5lNDkwNmUzMzAgMTAwNjQ0DQo+ IC0tLSBhL21lc2gvbW9kZWwuaA0KPiArKysgYi9tZXNoL21vZGVsLmgNCj4gQEAgLTEwMyw3ICsx MDMsNyBAQCBib29sIG1lc2hfbW9kZWxfc2VuZChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50 MTZfdCBzcmMsIHVpbnQxNl90IGRzdCwNCj4gIAkJCQkJdWludDhfdCB0dGwsIGJvb2wgc2VnbWVu dGVkLA0KPiAgCQkJCQljb25zdCB2b2lkICptc2csIHVpbnQxNl90IG1zZ19sZW4pOw0KPiAgaW50 IG1lc2hfbW9kZWxfcHVibGlzaChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MzJfdCBpZCwg dWludDE2X3Qgc3JjLA0KPiAtCQkJCXVpbnQ4X3QgdHRsLCBjb25zdCB2b2lkICptc2csIHVpbnQx Nl90IG1zZ19sZW4pOw0KPiArCQkJCQljb25zdCB2b2lkICptc2csIHVpbnQxNl90IG1zZ19sZW4p Ow0KPiAgYm9vbCBtZXNoX21vZGVsX3J4KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIGJvb2wgc3pt aWN0LCB1aW50MzJfdCBzZXEwLA0KPiAgCQkJdWludDMyX3Qgc2VxLCB1aW50MzJfdCBpdl9pbmRl eCwgdWludDE2X3QgbmV0X2lkeCwNCj4gIAkJCXVpbnQxNl90IHNyYywgdWludDE2X3QgZHN0LCB1 aW50OF90IGtleV9haWQsDQo+IGRpZmYgLS1naXQgYS9tZXNoL25vZGUuYyBiL21lc2gvbm9kZS5j DQo+IGluZGV4IDNkY2E3M2NlZi4uNGI3MDU4N2FlIDEwMDY0NA0KPiAtLS0gYS9tZXNoL25vZGUu Yw0KPiArKysgYi9tZXNoL25vZGUuYw0KPiBAQCAtMTk4Myw3ICsxOTgzLDcgQEAgc3RhdGljIHN0 cnVjdCBsX2RidXNfbWVzc2FnZSAqcHVibGlzaF9jYWxsKHN0cnVjdCBsX2RidXMgKmRidXMsDQo+ ICAJc3RydWN0IGxfZGJ1c19tZXNzYWdlX2l0ZXIgaXRlcl9kYXRhOw0KPiAgCXVpbnQxNl90IG1v ZF9pZCwgc3JjOw0KPiAgCXN0cnVjdCBub2RlX2VsZW1lbnQgKmVsZTsNCj4gLQl1aW50OF90ICpk YXRhLCB0dGw7DQo+ICsJdWludDhfdCAqZGF0YTsNCj4gIAl1aW50MzJfdCBsZW4sIGlkOw0KPiAg CWludCByZXN1bHQ7DQo+ICANCj4gQEAgLTIwMTAsMTAgKzIwMTAsOCBAQCBzdGF0aWMgc3RydWN0 IGxfZGJ1c19tZXNzYWdlICpwdWJsaXNoX2NhbGwoc3RydWN0IGxfZGJ1cyAqZGJ1cywNCj4gIAkJ cmV0dXJuIGRidXNfZXJyb3IobXNnLCBNRVNIX0VSUk9SX0lOVkFMSURfQVJHUywNCj4gIAkJCQkJ CQkiSW5jb3JyZWN0IGRhdGEiKTsNCj4gIA0KPiAtCXR0bCA9IG1lc2hfbmV0X2dldF9kZWZhdWx0 X3R0bChub2RlLT5uZXQpOw0KPiAtDQo+ICAJaWQgPSBTRVRfSUQoU0lHX1ZFTkRPUiwgbW9kX2lk KTsNCj4gLQlyZXN1bHQgPSBtZXNoX21vZGVsX3B1Ymxpc2gobm9kZSwgaWQsIHNyYywgdHRsLCBk YXRhLCBsZW4pOw0KPiArCXJlc3VsdCA9IG1lc2hfbW9kZWxfcHVibGlzaChub2RlLCBpZCwgc3Jj LCBkYXRhLCBsZW4pOw0KPiAgDQo+ICAJaWYgKHJlc3VsdCAhPSBNRVNIX0VSUk9SX05PTkUpDQo+ ICAJCXJldHVybiBkYnVzX2Vycm9yKG1zZywgcmVzdWx0LCBOVUxMKTsNCj4gQEAgLTIwMzAsNyAr MjAyOCw3IEBAIHN0YXRpYyBzdHJ1Y3QgbF9kYnVzX21lc3NhZ2UgKnZlbmRvcl9wdWJsaXNoX2Nh bGwoc3RydWN0IGxfZGJ1cyAqZGJ1cywNCj4gIAlzdHJ1Y3QgbF9kYnVzX21lc3NhZ2VfaXRlciBp dGVyX2RhdGE7DQo+ICAJdWludDE2X3Qgc3JjLCBtb2RfaWQsIHZlbmRvcl9pZDsNCj4gIAlzdHJ1 Y3Qgbm9kZV9lbGVtZW50ICplbGU7DQo+IC0JdWludDhfdCB0dGwsICpkYXRhID0gTlVMTDsNCj4g Kwl1aW50OF90ICpkYXRhID0gTlVMTDsNCj4gIAl1aW50MzJfdCBsZW47DQo+ICAJaW50IHJlc3Vs dDsNCj4gIA0KPiBAQCAtMjA1Nyw4ICsyMDU1LDcgQEAgc3RhdGljIHN0cnVjdCBsX2RidXNfbWVz c2FnZSAqdmVuZG9yX3B1Ymxpc2hfY2FsbChzdHJ1Y3QgbF9kYnVzICpkYnVzLA0KPiAgCQlyZXR1 cm4gZGJ1c19lcnJvcihtc2csIE1FU0hfRVJST1JfSU5WQUxJRF9BUkdTLA0KPiAgCQkJCQkJCSJJ bmNvcnJlY3QgZGF0YSIpOw0KPiAgDQo+IC0JdHRsID0gbWVzaF9uZXRfZ2V0X2RlZmF1bHRfdHRs KG5vZGUtPm5ldCk7DQo+IC0JcmVzdWx0ID0gbWVzaF9tb2RlbF9wdWJsaXNoKG5vZGUsIFNFVF9J RCh2ZW5kb3JfaWQsIG1vZF9pZCksIHNyYywgdHRsLA0KPiArCXJlc3VsdCA9IG1lc2hfbW9kZWxf cHVibGlzaChub2RlLCBTRVRfSUQodmVuZG9yX2lkLCBtb2RfaWQpLCBzcmMsDQo+ICAJCQkJCQkJ CWRhdGEsIGxlbik7DQo+ICANCj4gIAlpZiAocmVzdWx0ICE9IE1FU0hfRVJST1JfTk9ORSkNCg== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +AbDH62FLV98NwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 18:47:41 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id mFoXHq2FLV9TgAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 18:47:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 95B69A147C; Fri, 7 Aug 2020 18:47:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726595AbgHGQr1 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 7 Aug 2020 12:47:27 -0400 Received: from mail-io1-f71.google.com ([209.85.166.71]:41210 "EHLO mail-io1-f71.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725934AbgHGQrV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 7 Aug 2020 12:47:21 -0400 Received: by mail-io1-f71.google.com with SMTP id e12so2015178ioc.8 for <linux-bluetooth@vger.kernel.org>; Fri, 07 Aug 2020 09:47:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=0KluU1RLnMxS1ahAPUCEJr4pkzAjGYdf2Vdm5OzbWDw=; b=nMNpu+KgWupHPj8YnHPmdoBdjs+Y871By8zPI26s6q375HRQsrml854obwjTjZ1sUv ByWIxcTGmuLHXQSFGZeRUmuQsMZFC05xqIKtRmgQ3E79Fv9FQ5tffEAAPWzI7xdUOrIS TMdvJLPhk7jRQ9XRz7RIIZnvatXp/lpNilxUIYWPjzIo6yy7euHbQ1Cyy88TDzin13xn eDtVdkcgNKk4ilyyUu4+AGk3ea716PMEkR2/hX4w4ocrjyHM+z3UT6lno8TacMBBkgkw s8tX2K3Pt7EfjX3pd7uRC1UmzVZDXTCGofULdWGeYOOp9HNcUo1WtX7iPj/jV0XcqKgX QGpA== X-Gm-Message-State: AOAM532hKaaa6SFSxVgKA0scJJF45OaekiK3Vvss9a3MM1+iMSBxRcTQ 8/+WVHmFLXu9BqtV5FplhhzR9/BHrdOr4ZAYnAt+JSsg3Exs X-Google-Smtp-Source: ABdhPJy9gDQ/dkV++l/KRRJAxkJGXdXcLdeHJuNBVEFVACUkRdhcTN7YCwWftXQkzglwjGrANSNUIt/g0+1iB6jCOGo0sPn0LESo MIME-Version: 1.0 X-Received: by 2002:a92:bada:: with SMTP id t87mr5533456ill.112.1596818840712; Fri, 07 Aug 2020 09:47:20 -0700 (PDT) Date: Fri, 07 Aug 2020 09:47:20 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000c57f2d05ac4c5b8e@google.com> Subject: BUG: corrupted list in kobject_add_internal From: syzbot <syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com> To: abhishekpandit@chromium.org, davem@davemloft.net, gregkh@linuxfoundation.org, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, rafael@kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.68 / 15.00 / 200.00 X-Rspamd-Queue-Id: 95B69A147C X-Rspamd-UID: c4fb56 Hello, syzbot found the following issue on: HEAD commit: 5a30a789 Merge tag 'x86-urgent-2020-08-02' of git://git.ke.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1660c858900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 dashboard link: https://syzkaller.appspot.com/bug?extid=dd768a260f7358adbaf9 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14b73afc900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=124893a4900000 The issue was bisected to: commit 4f40afc6c76451daff7d0dcfc8a3d113ccf65bfc Author: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Wed Mar 11 15:54:01 2020 +0000 Bluetooth: Handle BR/EDR devices during suspend bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11cb1e0a900000 final oops: https://syzkaller.appspot.com/x/report.txt?x=13cb1e0a900000 console output: https://syzkaller.appspot.com/x/log.txt?x=15cb1e0a900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com Fixes: 4f40afc6c764 ("Bluetooth: Handle BR/EDR devices during suspend") debugfs: Directory '200' with parent 'hci0' already present! list_add double add: new=ffff88808e9b6418, prev=ffff88808e9b6418, next=ffff8880a973ef00. ------------[ cut here ]------------ kernel BUG at lib/list_debug.c:29! invalid opcode: 0000 [#1] PREEMPT SMP KASAN CPU: 1 PID: 6882 Comm: kworker/u5:1 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work RIP: 0010:__list_add_valid.cold+0x26/0x3c lib/list_debug.c:29 Code: 57 ff ff ff 4c 89 e1 48 c7 c7 20 92 93 88 e8 b1 f1 c1 fd 0f 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 60 93 93 88 e8 9a f1 c1 fd <0f> 0b 48 89 f1 48 c7 c7 e0 92 93 88 4c 89 e6 e8 86 f1 c1 fd 0f 0b RSP: 0018:ffffc90001777830 EFLAGS: 00010282 RAX: 0000000000000058 RBX: ffff8880a973ef00 RCX: 0000000000000000 RDX: ffff888094f1c200 RSI: ffffffff815d4ef7 RDI: fffff520002eeef8 RBP: ffff88808e9b6418 R08: 0000000000000058 R09: ffff8880ae7318e7 R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a973ef00 R13: ffff888087315270 R14: ffff88808e9b6430 R15: ffff88808e9b6418 FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffdcd6db747 CR3: 000000009ba09000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: __list_add include/linux/list.h:67 [inline] list_add_tail include/linux/list.h:100 [inline] kobj_kset_join lib/kobject.c:196 [inline] kobject_add_internal+0x18d/0x940 lib/kobject.c:246 kobject_add_varg lib/kobject.c:390 [inline] kobject_add+0x150/0x1c0 lib/kobject.c:442 device_add+0x35a/0x1be0 drivers/base/core.c:2633 hci_conn_add_sysfs+0x84/0xe0 net/bluetooth/hci_sysfs.c:53 hci_conn_complete_evt net/bluetooth/hci_event.c:2607 [inline] hci_event_packet+0xe0b/0x86f5 net/bluetooth/hci_event.c:6033 hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:291 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Modules linked in: ---[ end trace b1bcc552c32d25e9 ]--- RIP: 0010:__list_add_valid.cold+0x26/0x3c lib/list_debug.c:29 Code: 57 ff ff ff 4c 89 e1 48 c7 c7 20 92 93 88 e8 b1 f1 c1 fd 0f 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 60 93 93 88 e8 9a f1 c1 fd <0f> 0b 48 89 f1 48 c7 c7 e0 92 93 88 4c 89 e6 e8 86 f1 c1 fd 0f 0b RSP: 0018:ffffc90001777830 EFLAGS: 00010282 RAX: 0000000000000058 RBX: ffff8880a973ef00 RCX: 0000000000000000 RDX: ffff888094f1c200 RSI: ffffffff815d4ef7 RDI: fffff520002eeef8 RBP: ffff88808e9b6418 R08: 0000000000000058 R09: ffff8880ae7318e7 R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a973ef00 R13: ffff888087315270 R14: ffff88808e9b6430 R15: ffff88808e9b6418 FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffdcd6db747 CR3: 0000000009a79000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. For information about bisection process see: https://goo.gl/tpsmEJ#bisection syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ENe9KKOdLV+hhQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 20:29:55 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 6Ar6JqOdLV8PCQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 20:29:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3F5A640AE5; Fri, 7 Aug 2020 20:29:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726076AbgHGS3Z (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 7 Aug 2020 14:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725934AbgHGS3Y (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 7 Aug 2020 14:29:24 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D3A7C061756; Fri, 7 Aug 2020 11:29:23 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id ha11so1330588pjb.1; Fri, 07 Aug 2020 11:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Z120/2fGgMoMEJFP3y/UN7XiDtbeEapazuzyhr8LDZE=; b=QBJVGJ0GG4JwOGjOXDhn/ptRbCpViFRSryd/D1uD/PPByb8ofXHghQtBL4zAWGT9Xe QK/cUuMjhxG0m1Hgc9zv3PWjG85dcSZ3U99MdqgrJZlSJ7yNitbrWEKj0pKrpQ5j4U2+ mYi6rg0gFPqzK2WTohJzzlVFs9f88hQH3fpr0BAInmFjUAgk2jPvQt5YPhc+dRklJCLA 1PiMOZ7kUlZdKKqrhoSbKIrPYqUmIDmxZL7Nhpp4CbVKZHsjBzyt1SbkbQp0snfBQJX6 D0ebWljTdKFZBlaqVyAN81FA6P/pxFRTidd7EBz+FBfE/yEz78eEPIzn3SALlg9BIULK bJSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Z120/2fGgMoMEJFP3y/UN7XiDtbeEapazuzyhr8LDZE=; b=XBEw5BfjOhO7TRexKhdv3xqccXF1PsfVX1ssuCVYLzOJsNiEXk+gJCAgqn9rFwdB1g 2YIqOfMExR995vdEmm3U+cadypuRcInt+JC1mKShBlYGFMM6Q1ojgtyjf5LsD1rFarjy DiC86o0dqen+w2Hnx8zSgGOFasa+tJc9YjIiENzOsBm/8zX9gpyz/RahTCncT3IO1eKA jlTPXIH3pVHtjwV8a1hOvDAReyMYud61o5TRGFScvC9BUEJyDw1YmdhVzRy8ZAI7o1H6 8gYpYWkOtGeVvG+plRYX9PBzjltSKvq6zXNrVPF+6PDhTsx9IPAwDk1QP8Em/8p5IZ1F 22lw== X-Gm-Message-State: AOAM531B/YdZD5B+DWTBrQ6T+kMGGS75NFQ0qi3qNuaN2rKUoDL4LLDq GOhATJJRfGrQwKE/goXhZZ0= X-Google-Smtp-Source: ABdhPJwIAkNKceIOzLVjCyNTLbqqQvdxFebKOpJzF9rIr6w9P+XPfBqJiKCvAm7AAVFD3CFXOteoEw== X-Received: by 2002:a17:902:b210:: with SMTP id t16mr13276026plr.90.1596824962910; Fri, 07 Aug 2020 11:29:22 -0700 (PDT) Received: from [10.1.10.11] (c-73-241-150-58.hsd1.ca.comcast.net. [73.241.150.58]) by smtp.gmail.com with ESMTPSA id q66sm11499854pjq.17.2020.08.07.11.29.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Aug 2020 11:29:21 -0700 (PDT) Subject: Re: [PATCH 25/26] net: pass a sockptr_t into ->setsockopt To: David Laight <David.Laight@ACULAB.COM>, 'Eric Dumazet' <eric.dumazet@gmail.com>, Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com> Cc: "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "bpf@vger.kernel.org" <bpf@vger.kernel.org>, "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>, "coreteam@netfilter.org" <coreteam@netfilter.org>, "linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>, "linux-hams@vger.kernel.org" <linux-hams@vger.kernel.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "bridge@lists.linux-foundation.org" <bridge@lists.linux-foundation.org>, "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>, "dccp@vger.kernel.org" <dccp@vger.kernel.org>, "linux-decnet-user@lists.sourceforge.net" <linux-decnet-user@lists.sourceforge.net>, "linux-wpan@vger.kernel.org" <linux-wpan@vger.kernel.org>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, "mptcp@lists.01.org" <mptcp@lists.01.org>, "lvs-devel@vger.kernel.org" <lvs-devel@vger.kernel.org>, "rds-devel@oss.oracle.com" <rds-devel@oss.oracle.com>, "linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>, "tipc-discussion@lists.sourceforge.net" <tipc-discussion@lists.sourceforge.net>, "linux-x25@vger.kernel.org" <linux-x25@vger.kernel.org>, Stefan Schmidt <stefan@datenfreihafen.org> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-26-hch@lst.de> <6357942b-0b6e-1901-7dce-e308c9fac347@gmail.com> <f21589f1262640b09ca27ed20f8e6790@AcuMS.aculab.com> From: Eric Dumazet <eric.dumazet@gmail.com> Message-ID: <90f626a4-d9e5-91a5-b71d-498e3b125da1@gmail.com> Date: Fri, 7 Aug 2020 11:29:19 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <f21589f1262640b09ca27ed20f8e6790@AcuMS.aculab.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3F5A640AE5 X-Rspamd-UID: cb1c12 On 8/7/20 2:18 AM, David Laight wrote: > From: Eric Dumazet >> Sent: 06 August 2020 23:21 >> >> On 7/22/20 11:09 PM, Christoph Hellwig wrote: >>> Rework the remaining setsockopt code to pass a sockptr_t instead of a >>> plain user pointer. This removes the last remaining set_fs(KERNEL_DS) >>> outside of architecture specific code. >>> >>> Signed-off-by: Christoph Hellwig <hch@lst.de> >>> Acked-by: Stefan Schmidt <stefan@datenfreihafen.org> [ieee802154] >>> --- >> >> >> ... >> >>> diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c >>> index 594e01ad670aa6..874f01cd7aec42 100644 >>> --- a/net/ipv6/raw.c >>> +++ b/net/ipv6/raw.c >>> @@ -972,13 +972,13 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) >>> } >>> >> >> ... >> >>> static int do_rawv6_setsockopt(struct sock *sk, int level, int optname, >>> - char __user *optval, unsigned int optlen) >>> + sockptr_t optval, unsigned int optlen) >>> { >>> struct raw6_sock *rp = raw6_sk(sk); >>> int val; >>> >>> - if (get_user(val, (int __user *)optval)) >>> + if (copy_from_sockptr(&val, optval, sizeof(val))) >>> return -EFAULT; >>> >> >> converting get_user(...) to copy_from_sockptr(...) really assumed the optlen >> has been validated to be >= sizeof(int) earlier. >> >> Which is not always the case, for example here. >> >> User application can fool us passing optlen=0, and a user pointer of exactly TASK_SIZE-1 > > Won't the user pointer force copy_from_sockptr() to call > copy_from_user() which will then do access_ok() on the entire > range and so return -EFAULT. > > The only problems arise if the kernel code adds an offset to the > user address. > And the later patch added an offset to the copy functions. I dunno, I definitely got the following syzbot crash No repro found by syzbot yet, but I suspect a 32bit binary program did : setsockopt(fd, 0x29, 0x24, 0xffffffffffffffff, 0x0) BUG: KASAN: wild-memory-access in memcpy include/linux/string.h:406 [inline] BUG: KASAN: wild-memory-access in copy_from_sockptr_offset include/linux/sockptr.h:71 [inline] BUG: KASAN: wild-memory-access in copy_from_sockptr include/linux/sockptr.h:77 [inline] BUG: KASAN: wild-memory-access in do_rawv6_setsockopt net/ipv6/raw.c:1023 [inline] BUG: KASAN: wild-memory-access in rawv6_setsockopt+0x1a1/0x6f0 net/ipv6/raw.c:1084 Read of size 4 at addr 00000000ffffffff by task syz-executor.0/28251 CPU: 3 PID: 28251 Comm: syz-executor.0 Not tainted 5.8.0-syzkaller #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 __kasan_report mm/kasan/report.c:517 [inline] kasan_report.cold+0x5/0x37 mm/kasan/report.c:530 check_memory_region_inline mm/kasan/generic.c:186 [inline] check_memory_region+0x13d/0x180 mm/kasan/generic.c:192 memcpy+0x20/0x60 mm/kasan/common.c:105 memcpy include/linux/string.h:406 [inline] copy_from_sockptr_offset include/linux/sockptr.h:71 [inline] copy_from_sockptr include/linux/sockptr.h:77 [inline] do_rawv6_setsockopt net/ipv6/raw.c:1023 [inline] rawv6_setsockopt+0x1a1/0x6f0 net/ipv6/raw.c:1084 __sys_setsockopt+0x2ad/0x6d0 net/socket.c:2138 __do_sys_setsockopt net/socket.c:2149 [inline] __se_sys_setsockopt net/socket.c:2146 [inline] __ia32_sys_setsockopt+0xb9/0x150 net/socket.c:2146 do_syscall_32_irqs_on arch/x86/entry/common.c:84 [inline] __do_fast_syscall_32+0x57/0x80 arch/x86/entry/common.c:126 do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:149 entry_SYSENTER_compat_after_hwframe+0x4d/0x5c RIP: 0023:0xf7f22569 Code: c4 01 10 03 03 74 c0 01 10 05 03 74 b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 eb 0d 90 90 90 90 90 90 90 90 90 90 90 90 RSP: 002b:00000000f551c0bc EFLAGS: 00000296 ORIG_RAX: 000000000000016e RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000000029 RDX: 0000000000000024 RSI: 00000000ffffffff RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 ================================================================== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CIWnAp3GLV8zWgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 07 Aug 2020 23:24:45 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id oJs2AZ3GLV965wAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 07 Aug 2020 23:24:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C547440AE5; Fri, 7 Aug 2020 23:24:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726038AbgHGVYj (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 7 Aug 2020 17:24:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbgHGVYi (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 7 Aug 2020 17:24:38 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4BF1C061756 for <linux-bluetooth@vger.kernel.org>; Fri, 7 Aug 2020 14:24:37 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id y7so2415445qvj.11 for <linux-bluetooth@vger.kernel.org>; Fri, 07 Aug 2020 14:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=5wEq7H/aTNQaC+MLpK5FtBm7PEKzvcE/3MXY5TiR0Ys=; b=YLTXn3KDoWVX7zL61wg+vMsOZgSPtjTr51oWZbrLqqzqKyIfqXC4GFPtbCERqT1CCs VA+R71NO8RSRnNH9tH/ODzTAqhbP9PfQaUkVo1wEduD8mzCeGgiKxGvx6uey/1ORdHlz Z1IA5b/U6cxZJqSJyPnoabyei0tqTQEUlc+MNSTTefOGCd7A13ZZTavYw4EFAu1KT3sO z/OEzCawQ45+MV1OyrFgRcqOgbmpVw6euOovQ4zp7j2x1//iNIFAy8IvqGrH7oka3beI 7awR6Ix5LphIEfJni0C9dFzKDq6zGkgz3Y0aRHt7SmfxxxvCAcWFYlt81oRwuefX18ky fghw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=5wEq7H/aTNQaC+MLpK5FtBm7PEKzvcE/3MXY5TiR0Ys=; b=kLhrS+OBy7B+Gg/Ri5qzznwW/9a5Ci1p8Snb9D2oFfGKps8UUY1r6CFy36O8jxyMN/ ujDF2juTAuy4Wbxe4gWc7hS5Hn0btemVtxB0WkvQZKc6+cmp/2Oikfhbv4ZCAjxo0+K7 8p/lWYoe7vVs+/QskiYbjzoRQvfaNrkMQgnSUD0w6UONslP/TEqk/rXJy9nDxglxo5ob sJ/hs+TD6W/YqyYfOARf8GPZkei4weiLZlZQ7k3K5EPRpsJ+E/BoSS8d+eFAB9k0a14R qLXjMJaPea2xeZg9QzsUxUcqUD7PbvbQpnm3vK1n4pw0QRt6F2FhZZpkkqW4UWivZ8No AlvQ== X-Gm-Message-State: AOAM532Ye+kXcGlZy65Uqw2TJAy2nH+6HOCiyCFcJR6L5GBumhRB7r1s OKJTk8TzfD9ua74mIqXGgRrc6LF9SC9nrA== X-Google-Smtp-Source: ABdhPJzXSkwcXJXmHIWjMQ6VwywoEfsm9VoC3QzWrKQhwFovJgEMB/aFmjst1ySbYhBAPUGbD/yC7GxwT3EI5Q== X-Received: by 2002:a0c:cc94:: with SMTP id f20mr16875759qvl.159.1596835476792; Fri, 07 Aug 2020 14:24:36 -0700 (PDT) Date: Fri, 7 Aug 2020 14:24:33 -0700 Message-Id: <20200807142429.BlueZ.1.I588558f1e38231193d6e955a4008ce54712d5c89@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [BlueZ PATCH] Disable auto-connect on cancel pair From: Manish Mandlik <mmandlik@google.com> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: alainm@chromium.org, chromeos-bluetooth-upstreaming@chromium.org, sonnysasaka@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik <mmandlik@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: C547440AE5 X-Rspamd-UID: 428722 While pairing process is in progress, service discovery starts in the background. If HOG profile is detected, auto connect is enabled for that device. This causes future advertisement from that device to trigger a pairing even if the user has already cancelled the pairing. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Manish Mandlik <mmandlik@google.com> --- src/device.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/device.c b/src/device.c index 470596ee4..ab5bb123e 100644 --- a/src/device.c +++ b/src/device.c @@ -2870,6 +2870,15 @@ static void device_cancel_bonding(struct btd_device *device, uint8_t status) if (!bonding) return; + /* Auto connect may get enabled during the service discovery even + * before the pairing process completes. In such case, disable it + * when the user has cancelled the pairing process. + */ + if (device->auto_connect) { + device->disable_auto_connect = TRUE; + device_set_auto_connect(device, FALSE); + } + ba2str(&device->bdaddr, addr); DBG("Canceling bonding request for %s", addr); -- 2.28.0.236.gb10cc79966-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mHX5AvQkLl+VMgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 08 Aug 2020 06:07:16 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id +FZGAfQkLl+lEAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 08 Aug 2020 06:07:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9E49D418AF; Sat, 8 Aug 2020 06:07:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725954AbgHHEGn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 8 Aug 2020 00:06:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgHHEGm (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 8 Aug 2020 00:06:42 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E736C061756; Fri, 7 Aug 2020 21:06:42 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id p4so3635899qkf.0; Fri, 07 Aug 2020 21:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eBX2STd6CRBk1vKmSlEBQtLB8UUMASbhavMeJ1WJR0A=; b=ImMnrn3Z4k3xH3d5wjuGGYN5dCY5Wg7yTR6mWwxE/0/bqZN2eh0ux/M635crPwEWDO RUqUkjgZ166oTo3IMuMmnuMHsSMhkDzoRms1MNwfTUorcMFXA6UACHWMaal1MUaCARlN RUqIlF2x87k23WZtrRs2/GqwsDiG1blYKkLittDuyJQzNHsFAhC5NfgMSB0kFmP2VIYD 2X3iQoriLLXUSbdBDPmnR2S8YGDLWYyiyAjU6JfeQLkoIAcUMa/itMhvlGFDVDWyx3bU osogjoRLH9tdNW8lQiZdZcy9WzfK4K3DIN248WTy1sj5QRBgygAtyaU6lmCPxULnuLC6 DqYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eBX2STd6CRBk1vKmSlEBQtLB8UUMASbhavMeJ1WJR0A=; b=X8F/7+R/+iOLZpWCkoZZGiEWtCqKhrLp07JmhlwRAMhMeiKzwtceA9z1bxXNv6OUCD cY4M1/wG3Ji18qN2IyUlmTI9Qs9DaVgI5f1HlE0cdYvfddV5B66z0LLXpguJXMHGyRjR fSn6heNYswsJZ8gqsc9nv7g0OoDAKIhsCudvqdxRL8DsYG4JlxOMoO7AoRWIcIhyZv20 C83m2htx14OUIYLS2hsn37pQRocNvw+aP7/jKOIbooj2gJUGQYofZYVIX4UlZRD7J6YM R416hKME0SNhHzWGqtXZsU1vAhV1kHvkx9fMPScmuhsE4rhClvXxFXPNY3rg6yQV/ded pVHg== X-Gm-Message-State: AOAM533KCDOXIwgVQnuVm7h/kpwsqVHLrPNJ4K0R9w6UdrwadWG4Z0Jn bDE3XyX9MYIC5ZvyPztVPw== X-Google-Smtp-Source: ABdhPJyiVi2TyBkfekwvTN8eseV1M60k4LZxF4cWE/pBssVqKoNRkt5Jy/31+Zj0ox2uqwcG0951nA== X-Received: by 2002:a37:a503:: with SMTP id o3mr16204813qke.162.1596859601722; Fri, 07 Aug 2020 21:06:41 -0700 (PDT) Received: from localhost.localdomain (146-115-88-66.s3894.c3-0.sbo-ubr1.sbo.ma.cable.rcncustomer.com. [146.115.88.66]) by smtp.gmail.com with ESMTPSA id i7sm9264630qtb.27.2020.08.07.21.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 21:06:41 -0700 (PDT) From: Peilin Ye <yepeilin.cs@gmail.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Cc: Peilin Ye <yepeilin.cs@gmail.com>, Andrei Emeltchenko <andrei.emeltchenko@intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, linux-kernel-mentees@lists.linuxfoundation.org, syzkaller-bugs@googlegroups.com, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH net] Bluetooth: Fix NULL pointer dereference in amp_read_loc_assoc_final_data() Date: Sat, 8 Aug 2020 00:04:40 -0400 Message-Id: <20200808040440.255578-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9E49D418AF X-Rspamd-UID: fa0ef4 Prevent amp_read_loc_assoc_final_data() from dereferencing `mgr` as NULL. Reported-and-tested-by: syzbot+f4fb0eaafdb51c32a153@syzkaller.appspotmail.com Fixes: 9495b2ee757f ("Bluetooth: AMP: Process Chan Selected event") Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> --- net/bluetooth/amp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c index 9c711f0dfae3..be2d469d6369 100644 --- a/net/bluetooth/amp.c +++ b/net/bluetooth/amp.c @@ -297,6 +297,9 @@ void amp_read_loc_assoc_final_data(struct hci_dev *hdev, struct hci_request req; int err; + if (!mgr) + return; + cp.phy_handle = hcon->handle; cp.len_so_far = cpu_to_le16(0); cp.max_len = cpu_to_le16(hdev->amp_assoc_size); -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sGc8BrpMLl9v1gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 08 Aug 2020 08:56:58 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wAKJBLpMLl9PpAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 08 Aug 2020 08:56:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DA965A0979; Sat, 8 Aug 2020 08:56:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726199AbgHHG4U (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 8 Aug 2020 02:56:20 -0400 Received: from mail-il1-f198.google.com ([209.85.166.198]:45193 "EHLO mail-il1-f198.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725786AbgHHG4U (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 8 Aug 2020 02:56:20 -0400 Received: by mail-il1-f198.google.com with SMTP id 65so3372044ilb.12 for <linux-bluetooth@vger.kernel.org>; Fri, 07 Aug 2020 23:56:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=PU7yqFGMVKvrXPZB8XKknR7zBk1zUbYuGJQogoX3Viw=; b=UJNJtoNN6XN8dEgnESTh2k2fodXhGCyVT+v8TVgW9MHwmEDMOIr2B0qLyCrwcYOttP jk4X+oHfeQAYOngbeBOH5nURuQPWavzQ8acWAr5IGFMO+qV1GTUzE9+z0UZpje4PvQNE VDr/S+BuQQHaDq4RsnmnMt0wRqTfY5IucQFsNJd662987rqDIg5cM71+nJksXXXydtgD nV6TCQHtbfkBB/WhYffukI9TtyjK98wlKDKnhojtkbVA8MVU1p2BTy8HqBEZFb6xhx/7 xdiZNHqE5xACYCetZ8qfIo766VTfkzJafCMedQyWd+AeUeW/YO4QLcDxL8z1VuwWo07k kBaw== X-Gm-Message-State: AOAM5334CuZBqkbGCAiTNRUH32somTFg1iD2dG4Pawh8X+xbInwAk13r BW9NqGKzsG4t3CiLKyawdqFLWcfmhPGBOrR0lkgwKlrlNgEP X-Google-Smtp-Source: ABdhPJwJok0tKX3N0EHJGvBinV+En+9WTSlTMOoK1f6SpNiSfFRIgFTy9mPXiPsajTS50wvhAhBbI7r0W5Cds9T3Fm+RoOsiWPtN MIME-Version: 1.0 X-Received: by 2002:a92:5e9c:: with SMTP id f28mr8288344ilg.302.1596869778665; Fri, 07 Aug 2020 23:56:18 -0700 (PDT) Date: Fri, 07 Aug 2020 23:56:18 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000e8fb4b05ac58372e@google.com> Subject: KASAN: use-after-free Read in hci_get_auth_info From: syzbot <syzbot+13010b6a10bbd82cc79c@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: DA965A0979 X-Rspamd-UID: 5f667b Hello, syzbot found the following issue on: HEAD commit: d6efb3ac Merge tag 'tty-5.9-rc1' of git://git.kernel.org/p.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=14ad2134900000 kernel config: https://syzkaller.appspot.com/x/.config?x=61ec43e42a83feae dashboard link: https://syzkaller.appspot.com/bug?extid=13010b6a10bbd82cc79c compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12fd9bc6900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+13010b6a10bbd82cc79c@syzkaller.appspotmail.com ================================================================== BUG: KASAN: use-after-free in __mutex_waiter_is_first kernel/locking/mutex.c:200 [inline] BUG: KASAN: use-after-free in __mutex_lock_common+0x12cd/0x2fc0 kernel/locking/mutex.c:1040 Read of size 8 at addr ffff88808e668060 by task syz-executor.4/19584 CPU: 0 PID: 19584 Comm: syz-executor.4 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 print_address_description+0x66/0x5a0 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report+0x132/0x1d0 mm/kasan/report.c:530 __mutex_waiter_is_first kernel/locking/mutex.c:200 [inline] __mutex_lock_common+0x12cd/0x2fc0 kernel/locking/mutex.c:1040 __mutex_lock kernel/locking/mutex.c:1103 [inline] mutex_lock_nested+0x1a/0x20 kernel/locking/mutex.c:1118 hci_get_auth_info+0x69/0x3a0 net/bluetooth/hci_conn.c:1689 hci_sock_bound_ioctl net/bluetooth/hci_sock.c:957 [inline] hci_sock_ioctl+0x5ae/0x750 net/bluetooth/hci_sock.c:1060 sock_do_ioctl+0x7b/0x260 net/socket.c:1047 sock_ioctl+0x4aa/0x690 net/socket.c:1198 vfs_ioctl fs/ioctl.c:48 [inline] ksys_ioctl fs/ioctl.c:753 [inline] __do_sys_ioctl fs/ioctl.c:762 [inline] __se_sys_ioctl+0xf9/0x160 fs/ioctl.c:760 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x45ccd9 Code: 2d b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb b5 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007f113a564c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 000000000001d300 RCX: 000000000045ccd9 RDX: 0000000020000000 RSI: 00000000800448d7 RDI: 0000000000000005 RBP: 000000000078bf40 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 000000000078bf0c R13: 00007ffd62ea93af R14: 00007f113a5659c0 R15: 000000000078bf0c Allocated by task 6822: save_stack mm/kasan/common.c:48 [inline] set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494 kmem_cache_alloc_trace+0x234/0x300 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] hci_alloc_dev+0x4c/0x1aa0 net/bluetooth/hci_core.c:3543 __vhci_create_device drivers/bluetooth/hci_vhci.c:99 [inline] vhci_create_device+0x113/0x520 drivers/bluetooth/hci_vhci.c:148 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Freed by task 9965: save_stack mm/kasan/common.c:48 [inline] set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0x114/0x170 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x10a/0x220 mm/slab.c:3757 bt_host_release+0x18/0x20 net/bluetooth/hci_sysfs.c:86 device_release+0x70/0x1a0 drivers/base/core.c:1796 kobject_cleanup lib/kobject.c:704 [inline] kobject_release lib/kobject.c:735 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x1a0/0x2c0 lib/kobject.c:752 vhci_release+0x7b/0xc0 drivers/bluetooth/hci_vhci.c:341 __fput+0x2f0/0x750 fs/file_table.c:281 task_work_run+0x137/0x1c0 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0x5f3/0x1f20 kernel/exit.c:806 do_group_exit+0x161/0x2d0 kernel/exit.c:903 __do_sys_exit_group+0x13/0x20 kernel/exit.c:914 __ia32_sys_exit_group+0x0/0x40 kernel/exit.c:912 __x64_sys_exit_group+0x37/0x40 kernel/exit.c:912 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff88808e668000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 96 bytes inside of 8192-byte region [ffff88808e668000, ffff88808e66a000) The buggy address belongs to the page: page:ffffea0002399a00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea0002399a00 order:2 compound_mapcount:0 compound_pincount:0 flags: 0xfffe0000010200(slab|head) raw: 00fffe0000010200 ffffea000217a208 ffffea0001e6c008 ffff8880aa4021c0 raw: 0000000000000000 ffff88808e668000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88808e667f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88808e667f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88808e668000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88808e668080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88808e668100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AOd9BHl0Ll9kmwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 08 Aug 2020 11:46:33 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 6DcPA3l0Ll86aAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 08 Aug 2020 11:46:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 40BE2420D7; Sat, 8 Aug 2020 11:46:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726128AbgHHJqY (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 8 Aug 2020 05:46:24 -0400 Received: from mail-io1-f70.google.com ([209.85.166.70]:46487 "EHLO mail-io1-f70.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725980AbgHHJqW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 8 Aug 2020 05:46:22 -0400 Received: by mail-io1-f70.google.com with SMTP id n1so3478914ion.13 for <linux-bluetooth@vger.kernel.org>; Sat, 08 Aug 2020 02:46:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=Mgd7GqjjHZbKTVg1oMh8UpWpxgZW/6tvB9gNkmYnfYE=; b=qOlIUUApVAqZcWxPdyJNZtph60ACPZbwu06mL/X/nY8FOLLEeStAk8pUf3V8ZFSC0n 5d3vkoddWrxz/h3PCSuiLlV/CByyGi92klzERwJklkmn3tmZk0JfAJCOXPD1+YPxT1DT 43GuCCYwY2VTqlLnhxxAJoPww5OWIXkiSveG2wvxeGVz1vYOBhtJvpqICFBuJEZ9fb4y J16nLfUU6NjWiygeDYiDA0roYVM+A+J20XFtrcLglOB2woummYB/f5GniisZbyCiga3c Qwvw7rAj7+13Xubb//SxB3q9ufR9uYJcR0b+XMZSolmelskgoSqNCVaClIT3yp0M2Lb7 6exw== X-Gm-Message-State: AOAM5323ABCGU8pnL5tVBy4WtDOMMmPqsXJNe2y5Xc2nJ2RYUdTCOLHr 03eoda36lDf4P8tB7xBJ8ckmolSNJ0bt/ZEmRDGm0SlF01qC X-Google-Smtp-Source: ABdhPJzW8/kOTaphgcikkhZB1BACCXuyS9i2Q48y8/n1Uc0jg23uS5/J2KZB4W9dkahJKWLM4/ndHDDc3MSj9hj88H1XQl04F5BJ MIME-Version: 1.0 X-Received: by 2002:a6b:3e04:: with SMTP id l4mr8449851ioa.206.1596879981392; Sat, 08 Aug 2020 02:46:21 -0700 (PDT) Date: Sat, 08 Aug 2020 02:46:21 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000000a389a05ac5a9864@google.com> Subject: KASAN: null-ptr-deref Write in l2cap_chan_put From: syzbot <syzbot+452e9465a3b2817fa4c2@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.47 / 15.00 / 200.00 X-Rspamd-Queue-Id: 40BE2420D7 X-Rspamd-UID: aca3d0 Hello, syzbot found the following issue on: HEAD commit: 5631c5e0 Merge tag 'xfs-5.9-merge-7' of git://git.kernel.o.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=15c21934900000 kernel config: https://syzkaller.appspot.com/x/.config?x=afba7c06f91e56eb dashboard link: https://syzkaller.appspot.com/bug?extid=452e9465a3b2817fa4c2 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=131e96aa900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+452e9465a3b2817fa4c2@syzkaller.appspotmail.com ================================================================== BUG: KASAN: null-ptr-deref in instrument_atomic_write include/linux/instrumented.h:71 [inline] BUG: KASAN: null-ptr-deref in atomic_fetch_sub_release include/asm-generic/atomic-instrumented.h:220 [inline] BUG: KASAN: null-ptr-deref in refcount_sub_and_test include/linux/refcount.h:266 [inline] BUG: KASAN: null-ptr-deref in refcount_dec_and_test include/linux/refcount.h:294 [inline] BUG: KASAN: null-ptr-deref in kref_put include/linux/kref.h:64 [inline] BUG: KASAN: null-ptr-deref in l2cap_chan_put+0x28/0x230 net/bluetooth/l2cap_core.c:502 Write of size 4 at addr 0000000000000018 by task kworker/0:1/7077 CPU: 0 PID: 7077 Comm: kworker/0:1 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 __kasan_report mm/kasan/report.c:517 [inline] kasan_report.cold+0x5/0x37 mm/kasan/report.c:530 check_memory_region_inline mm/kasan/generic.c:186 [inline] check_memory_region+0x13d/0x180 mm/kasan/generic.c:192 instrument_atomic_write include/linux/instrumented.h:71 [inline] atomic_fetch_sub_release include/asm-generic/atomic-instrumented.h:220 [inline] refcount_sub_and_test include/linux/refcount.h:266 [inline] refcount_dec_and_test include/linux/refcount.h:294 [inline] kref_put include/linux/kref.h:64 [inline] l2cap_chan_put+0x28/0x230 net/bluetooth/l2cap_core.c:502 l2cap_sock_kill+0xbd/0x180 net/bluetooth/l2cap_sock.c:1217 l2cap_chan_timeout+0x1c1/0x450 net/bluetooth/l2cap_core.c:438 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 ================================================================== Kernel panic - not syncing: panic_on_warn set ... CPU: 0 PID: 7077 Comm: kworker/0:1 Tainted: G B 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 panic+0x2e3/0x75c kernel/panic.c:231 end_report+0x4d/0x53 mm/kasan/report.c:104 __kasan_report mm/kasan/report.c:520 [inline] kasan_report.cold+0xd/0x37 mm/kasan/report.c:530 check_memory_region_inline mm/kasan/generic.c:186 [inline] check_memory_region+0x13d/0x180 mm/kasan/generic.c:192 instrument_atomic_write include/linux/instrumented.h:71 [inline] atomic_fetch_sub_release include/asm-generic/atomic-instrumented.h:220 [inline] refcount_sub_and_test include/linux/refcount.h:266 [inline] refcount_dec_and_test include/linux/refcount.h:294 [inline] kref_put include/linux/kref.h:64 [inline] l2cap_chan_put+0x28/0x230 net/bluetooth/l2cap_core.c:502 l2cap_sock_kill+0xbd/0x180 net/bluetooth/l2cap_sock.c:1217 l2cap_chan_timeout+0x1c1/0x450 net/bluetooth/l2cap_core.c:438 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Kernel Offset: disabled Rebooting in 86400 seconds.. --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GOEYB7qmLl+IrQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 08 Aug 2020 15:20:58 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id qCOTBbqmLl/rQgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 08 Aug 2020 15:20:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0281FA0979; Sat, 8 Aug 2020 15:20:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726198AbgHHNUq (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 8 Aug 2020 09:20:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:52766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbgHHNUq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 8 Aug 2020 09:20:46 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 54EF420723; Sat, 8 Aug 2020 13:20:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596892845; bh=MlnkqZhAL551l/PW8HGYejBM9HWodDIFRIQwqBTxpDc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xgwdb6TZ4wDkLdouPWsYSaa+QI8f2humJf26itsFeW31+uuO/KR1XCyzH8ox4n6CN eIWZgT/LnpAsShgVV0z83TQaFDHqe0ZjQ1deZux7EmijrDoFwoF+XlArgXn+ptPh1I ZrhPnIk9QRayh57xgAnPzFoGDjvnBaRHACCuhSpc= Received: by pali.im (Postfix) id EA56E688; Sat, 8 Aug 2020 15:20:42 +0200 (CEST) Date: Sat, 8 Aug 2020 15:20:42 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Marcel Holtmann <marcel@holtmann.org> Cc: Bluez mailing list <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, David Heidelberg <david@ixit.cz> Subject: Re: [PATCH] Install avinfo utility Message-ID: <20200808132042.mma5ykynagwx3ubd@pali> References: <20200506193435.3746-1-pali@kernel.org> <CECA6D9A-0F26-40E8-BFDF-A24CD972307D@holtmann.org> <20200610093306.zt3q3s2wmwp3almw@pali> <7672C0A0-AF6A-41B2-B50F-7836B3E5CC73@holtmann.org> <20200611125304.b4mxxuv7rupamfmg@pali> <20200713090913.6duirl4yhrjcyxoh@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200713090913.6duirl4yhrjcyxoh@pali> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0281FA0979 X-Rspamd-UID: 9050e3 On Monday 13 July 2020 11:09:13 Pali Rohár wrote: > On Thursday 11 June 2020 14:53:04 Pali Rohár wrote: > > On Wednesday 10 June 2020 19:31:47 Marcel Holtmann wrote: > > > Hi Pali, > > > > > > >>> This utility is very useful for determining which A2DP codecs are supported > > > >>> by remote side. So install it to system as part of bluez package. > > > >>> --- > > > >>> Makefile.tools | 4 ++-- > > > >>> 1 file changed, 2 insertions(+), 2 deletions(-) > > > >>> > > > >>> diff --git a/Makefile.tools b/Makefile.tools > > > >>> index 9b9236609..d52721612 100644 > > > >>> --- a/Makefile.tools > > > >>> +++ b/Makefile.tools > > > >>> @@ -176,9 +176,9 @@ endif > > > >>> if TOOLS > > > >>> bin_PROGRAMS += tools/rctest tools/l2test tools/l2ping tools/bccmd \ > > > >>> tools/bluemoon tools/hex2hcd tools/mpris-proxy \ > > > >>> - tools/btattach > > > >>> + tools/btattach tools/avinfo > > > >>> > > > >>> -noinst_PROGRAMS += tools/bdaddr tools/avinfo tools/avtest \ > > > >>> +noinst_PROGRAMS += tools/bdaddr tools/avtest \ > > > >>> tools/scotest tools/amptest tools/hwdb \ > > > >>> tools/hcieventmask tools/hcisecfilter \ > > > >>> tools/btinfo tools/btconfig \ > > > >> > > > >> I had no intention to install that tool since it is too limited > > > > > > > > Sorry, but I have not seen any limitations with this tool yet. I'm using > > > > it very often. And also other people who use it have not mentioned any > > > > limitations or problems. > > > > > > > > So could you be more specific what are those limitations? > > > > > > > > Also it is the first thing which I'm saying people that should run and > > > > send me output of it if something related to A2DP does not work. > > > > > > > > And because linux distributions do not package this utility and bluez > > > > developers (for me for unknown reasons) decided to not install it, > > > > result is that people have to always compile bluez from source to run > > > > this utility if their A2DP audio does not work or "remote" debugging of > > > > A2DP is needed. > > > > > > > > So result is that who want to know why A2DP audio does not work is > > > > forced to compile & install bluez from sources and not to use from > > > > distribution package. And this probably not the expected state. > > > > > > > > In any case, nobody reported to me any limitation with one exception > > > > that it cannot decode capabilities of some custom vendor codecs. But > > > > most of them are already supported as I sent needed patches in past. > > > > > > > >> and makes too many assumption. > > > > > > > > For example which assumptions? > > > > > > that nothing else is happening right now. It backstabs the actual AVDTP and A2DP implementation. > > > > Marcel, but this is not a problem. For that one purpose which avinfo > > provides it ideal and works fine. Personally I do not see any problem > > with it. > > > > > >> In addition it has a bad name with no Bluetooth prefix. > > > > > > > > So, lets rename it. What about "btavinfo"? > > > > > > Lets extend btinfo with all sort of capabilities. Make the av portion just one of. I want to remove the multitudes of test utilities anyway. We have to many tiny utilities that are just scattered around and avinfo is just one of them. > > > > This looks like a not-so-trivial task and moreover independent of > > providing current version of avinfo to users. > > > > avinfo already exists, is already part of bluez project, it is already > > compiling during bluez build and is already used by me and lot of other > > users and works for that one purpose as expected. > > > > > > > > > >> If we think it is useful to have such a test utility, then we need to clean this up first > > > > > > > > What exactly to clean up first? > > > > > > > > Note that I have already done cleanup of this utility. > > > > > > > >> and put this into a larger btinfo work to gather appropriate information from a remote device for debug purposes. > > > > > > > > I do not see how btinfo can be used for A2DP purposes. Seems this is > > > > utility for local controller info and not for remove A2DP. > > > > > > This needs a bit thinking, but pretty much simple things like this: > > > > > > btinfo local > > > btinfo avdtp <remote_bdaddr> > > > > > > We can create a module handling system so that you can easily links existing tiny utilities into one. > > > > I'm not against this change. But this is additional work which needs to > > be done. And it would not happen today or tomorrow unless you have > > already patches which implement it. > > > > As I said avinfo is already there, implemented, it is working and is > > part of bluez source code. And is basically the first step when > > debugging issues with A2DP audio. > > > > So what is the real issue with not only compiling this avinfo tool > > during building bluez but also installing it? > > Because nobody presented any real issue for more then month and I'm not > aware of any, could be avinfo finally enabled during installation? PING, two months passed and I have not received any new reply to this patch. If there are really no problems, could it be applied? Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qGWYLGOnLl8+tAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 08 Aug 2020 15:23:47 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ODwkK2OnLl/+awEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 08 Aug 2020 15:23:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 287FC420CD; Sat, 8 Aug 2020 15:23:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726321AbgHHNXj (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 8 Aug 2020 09:23:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:53570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbgHHNXj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 8 Aug 2020 09:23:39 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A6E3320723 for <linux-bluetooth@vger.kernel.org>; Sat, 8 Aug 2020 13:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596893018; bh=Ht92/zWPb+n/nHPB7VAzZcrJ3VqkXZ4XRHUJcfGEaAI=; h=Date:From:To:Subject:References:In-Reply-To:From; b=Fn5+AH4XkLjLehSp+4wDh1sQNBpshp+jOZrXxfhEUSpZ/6tvWS5Dc8LcmxtA1CvDD eYDEdAD5lhP9BOVnLM3jIBio17uQ3T1RlxbfW4HgUAG6VcG8134MMY1324JlFpovCV lIHQkaL1mrDIAfsUgTpwsyMzeqK7pQdeY/77ASVU= Received: by pali.im (Postfix) id 05E13688; Sat, 8 Aug 2020 15:23:37 +0200 (CEST) Date: Sat, 8 Aug 2020 15:23:36 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: linux-bluetooth@vger.kernel.org Subject: Re: [PATCH] avinfo: Print more A/V capabilities Message-ID: <20200808132336.opzyojwsyj2txgbp@pali> References: <20200512165112.24006-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200512165112.24006-1-pali@kernel.org> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.50 / 15.00 / 200.00 X-Rspamd-Queue-Id: 287FC420CD X-Rspamd-UID: aef7f7 Hello! I would like to remind also this patch: On Tuesday 12 May 2020 18:51:12 Pali Rohár wrote: > --- > tools/avinfo.c | 27 ++++++++++++++++++++++++--- > 1 file changed, 24 insertions(+), 3 deletions(-) > > diff --git a/tools/avinfo.c b/tools/avinfo.c > index e45b50918..576981a5e 100644 > --- a/tools/avinfo.c > +++ b/tools/avinfo.c > @@ -65,6 +65,7 @@ > #define AVDTP_HEADER_COMPRESSION 0x05 > #define AVDTP_MULTIPLEXING 0x06 > #define AVDTP_MEDIA_CODEC 0x07 > +#define AVDTP_DELAY_REPORTING 0x08 > > /* SEP types definitions */ > #define AVDTP_SEP_TYPE_SOURCE 0x00 > @@ -696,13 +697,33 @@ static void print_caps(void *data, int size) > > switch (cap->category) { > case AVDTP_MEDIA_TRANSPORT: > + printf("\tMedia Transport: Supported\n"); > + break; > case AVDTP_REPORTING: > + printf("\tReporting: Supported\n"); > + break; > + case AVDTP_DELAY_REPORTING: > + printf("\tDelay Reporting: Supported\n"); > + break; > case AVDTP_RECOVERY: > + case AVDTP_HEADER_COMPRESSION: > case AVDTP_MULTIPLEXING: > - /* FIXME: Add proper functions */ > - break; > default: > - printf("\tUnknown category: %d\n", cap->category); > + switch (cap->category) { > + case AVDTP_RECOVERY: > + printf("\tRecovery:\n"); > + break; > + case AVDTP_HEADER_COMPRESSION: > + printf("\tHeader compression:\n"); > + break; > + case AVDTP_MULTIPLEXING: > + printf("\tMultiplexing:\n"); > + break; > + default: > + printf("\tUnknown category: %d\n", cap->category); > + break; > + } > + /* FIXME: Add proper functions */ > printf("\t\tData:"); > for (i = 0; i < cap->length; ++i) > printf(" 0x%.02x", > -- > 2.20.1 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AChqCbOnLl/WqQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 08 Aug 2020 15:25:07 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CKgbB7OnLl/WnQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 08 Aug 2020 15:25:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 02C9F420D7; Sat, 8 Aug 2020 15:25:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726202AbgHHNZB (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 8 Aug 2020 09:25:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:53884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbgHHNZB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 8 Aug 2020 09:25:01 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B20020723 for <linux-bluetooth@vger.kernel.org>; Sat, 8 Aug 2020 13:25:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596893100; bh=uTZi8XQx5B9/6I0VJvU6zhntMI3gUTe0kTqgT9XRZ60=; h=Date:From:To:Subject:References:In-Reply-To:From; b=DtBNTAslRX7cmkWtboIgecxqUUeFC75A6QSLv5RAcvM2mx8A+RyxJeBVAoYptplnJ qy4tGQDpwBJdbz0bmFl6ZGOC82mOQoU8EkLJ0Xjkc0eR8pMcqkuh1BRdVyXNIy//bV WHtAfHL1lYIsN4uMjQtXDGssHh7qttghZnzRjHBs= Received: by pali.im (Postfix) id 74BE7688; Sat, 8 Aug 2020 15:24:58 +0200 (CEST) Date: Sat, 8 Aug 2020 15:24:58 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: linux-bluetooth@vger.kernel.org Subject: Re: [PATCH] tools/hcidump: Decode FastStream, aptX Low Latency, aptX HD and LDAC Message-ID: <20200808132458.2ia4xxfjd5x4d6ds@pali> References: <20190201124353.GK32745@reaktio.net> <20190206114300.rxw3ptq7hzathzqe@pali> <20190224131907.GV32745@reaktio.net> <20190305122630.gwnaz3y7ckzqfjfq@pali> <20190410082924.exo2oihzd7w2oz3e@pali> <20190607130739.j25oqqj624anmcqr@pali> <20191014110746.n3pmoigtf3ewbmrq@pali> <20200209130532.4evozfyutikzwn4a@pali> <20200414230015.5ndqz5k5kx5vakj4@pali> <20200503111449.k6ugzpaitbv5mggs@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200503111449.k6ugzpaitbv5mggs@pali> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -7.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 02C9F420D7 X-Rspamd-UID: be958e On Sunday 03 May 2020 13:14:49 Pali Rohár wrote: > On Wednesday 15 April 2020 01:00:15 Pali Rohár wrote: > > On Sunday 09 February 2020 14:05:32 Pali Rohár wrote: > > > On Monday 14 October 2019 13:07:46 Pali Rohár wrote: > > > > On Friday 07 June 2019 15:07:39 Pali Rohár wrote: > > > > > On Wednesday 10 April 2019 10:29:24 Pali Rohár wrote: > > > > > > On Tuesday 05 March 2019 13:26:30 Pali Rohár wrote: > > > > > > > On Sunday 24 February 2019 15:19:07 Pasi Kärkkäinen wrote: > > > > > > > > On Wed, Feb 06, 2019 at 12:43:00PM +0100, Pali Rohár wrote: > > > > > > > > > On Friday 01 February 2019 14:43:53 Pasi Kärkkäinen wrote: > > > > > > > > > > Hi, > > > > > > > > > > > > > > > > > > > > On Wed, Jan 30, 2019 at 02:24:11PM +0200, Luiz Augusto von Dentz wrote: > > > > > > > > > > > Hi Pali, Pasi, > > > > > > > > > > > On Wed, Jan 30, 2019 at 2:09 PM Pali Rohár <pali.rohar@gmail.com> wrote: > > > > > > > > > > > > > > > > > > > > > > > > On Wednesday 30 January 2019 10:15:17 Pasi Kärkkäinen wrote: > > > > > > > > > > > > > On Wed, Jan 23, 2019 at 06:54:48PM +0100, Pali Rohár wrote: > > > > > > > > > > > > > > On Wednesday 23 January 2019 18:46:18 Marcel Holtmann wrote: > > > > > > > > > > > > > > > Hi Pali, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > > > tools/parser/avdtp.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++--- > > > > > > > > > > > > > > > > 1 file changed, 55 insertions(+), 3 deletions(-) > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > diff --git a/tools/parser/avdtp.c b/tools/parser/avdtp.c > > > > > > > > > > > > > > > > index 18569c895..a21410f5a 100644 > > > > > > > > > > > > > > > > --- a/tools/parser/avdtp.c > > > > > > > > > > > > > > > > +++ b/tools/parser/avdtp.c > > > > > > > > > > > > > > > > @@ -155,6 +155,12 @@ static char *vndcodec2str(uint32_t vendor, uint16_t vndcodec) > > > > > > > > > > > > > > > > { > > > > > > > > > > > > > > > > if (vendor == 0x0000004f && vndcodec == 0x0001) > > > > > > > > > > > > > > > > return "aptX"; > > > > > > > > > > > > > > > > + else if (vendor == 0x0000000a && vndcodec == 0x0001) > > > > > > > > > > > > > > > > + return "FastStream"; > > > > > > > > > > > > > > > > + else if (vendor == 0x0000000a && vndcodec == 0x0002) > > > > > > > > > > > > > > > > + return "aptX Low Latency"; > > > > > > > > > > > > > > > > + else if (vendor == 0x000000d7 && vndcodec == 0x0024) > > > > > > > > > > > > > > > > + return "aptX HD"; > > > > > > > > > > > > > > > > else if (vendor == 0x0000012d && vndcodec == 0x00aa) > > > > > > > > > > > > > > > > return "LDAC"; > > > > > > > > > > > > > > > > return "Unknown???; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > lets keep the focus on btmon support since nobody should be using hcidump anymore. > > > > > > > > > > > > > > > > > > > > > > > > > > > > In btmon I already implemented it and patches are now merged. I just > > > > > > > > > > > > > > found another place where this capability parsing is implemented and > > > > > > > > > > > > > > based on fact that users still use hcidump I quickly looked at it and > > > > > > > > > > > > > > implemented this parsing. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I agree, hcidump still comes up on many places (guides, blogs, mailinglist posts, etc), > > > > > > > > > > > > > so it makes sense to add these patches to hcidump aswell. Especially when the patch is quite small. > > > > > > > > > > > > > > > > > > > > > > > > Exactly, people still use hcidump... > > > > > > > > > > > > > > > > > > > > > > Well it is a deprecated tool which we might remove starting on BlueZ > > > > > > > > > > > 6.x which we would like to do in the very next release, if that > > > > > > > > > > > doesn't happen than perhaps Id take these patches in for a very last > > > > > > > > > > > BlueZ 5.x release. > > > > > > > > > > > > > > > > > > > > > > @Marcel: Or you have a better plan? We could do one last 5.x and then > > > > > > > > > > > start working on removing the deprecated tools/etc. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > +1 for doing one last 5.x release before deprecating and removing tools etc! > > > > > > > > > > > > > > > > > > Ok, what is the plan? If hcidump is not going to be deleted in upcoming > > > > > > > > > release, can you take this patch? > > > > > > > > > > > > > > > > > > > > > > > > > How about applying this patch now, considering it's small, and has value for anyone using hcidump. > > > > > > > > hcidump then gets removed later whenever the removal of deprecated features/tools starts. > > > > > > > > > > > > > > So... what are plans for next release? > > > > > > > > > > > > Marcel, Luiz, can you comment next steps? It is waiting there for your > > > > > > info here for more than 2 months. > > > > > > > > > > PING! > > > > > > > > Just a gentle reminder for this thread and patch. > > > > > > > > > > Ping, another reminder. > > > > Ping, could you please give us information what is the state of this > > tool and a linked patch? > > Ping again, I have not got any reply for this patch for more then year. > Patch can be still cleanly applied on top of git master branch. Hello! Have you had a time to look at this patch? Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iGqZLWCoLl/WqQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 08 Aug 2020 15:28:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CBjSK2CoLl/WnQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 08 Aug 2020 15:28:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2E407A0979; Sat, 8 Aug 2020 15:27:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726233AbgHHN1u (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 8 Aug 2020 09:27:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:54514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbgHHN1u (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 8 Aug 2020 09:27:50 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 050382072D; Sat, 8 Aug 2020 13:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596893270; bh=IKNDctw8eaqDUmhLYS20d90D4oduBKl5cJTRFCqj0Ow=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BqNsO3UyVb3g8gWXLEvvIkNHLQ0pAjsqVwHYVD6761hq1w6VYDTGzsmcz5B25aRsZ oj4AhgRxiTRqWUcs0BM94uOdOiHeVEWFnCbxzbG4pSE/1pwVFAMvmfF7toYOfYdqZq FMg5m3Bv8Lj2JQABtsj+vI4gaRE1yhaCRcPsovyo= Received: by pali.im (Postfix) id 1865B688; Sat, 8 Aug 2020 15:27:48 +0200 (CEST) Date: Sat, 8 Aug 2020 15:27:47 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Pavel Machek <pavel@ucw.cz>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, Sebastian Reichel <sre@kernel.org>, David Heidelberg <david@ixit.cz> Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Removal of HCI commands? (Was: Re: OCF_READ_LOCAL_CODECS is permitted only for root user) Message-ID: <20200808132747.4byefjg5ysddgkel@pali> References: <20191228171212.56anj4d4kvjeqhms@pali> <45BB2908-4E16-4C74-9DB4-8BAD93B42A21@holtmann.org> <20200104102436.bhqagqrfwupj6hkm@pali> <20200209132137.7pi4pgnassosh3ax@pali> <20200414225618.zgh5h4jexahfukdl@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200414225618.zgh5h4jexahfukdl@pali> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.12 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2E407A0979 X-Rspamd-UID: a51b4c On Wednesday 15 April 2020 00:56:18 Pali Rohár wrote: > On Sunday 09 February 2020 14:21:37 Pali Rohár wrote: > > On Saturday 04 January 2020 11:24:36 Pali Rohár wrote: > > > On Saturday 04 January 2020 10:44:52 Marcel Holtmann wrote: > > > > Hi Pali, > > > > > > > > > I wrote a simple script "sco_features.pl" which show all supported > > > > > codecs by local HCI bluetooth adapter. Script is available at: > > > > > > > > > > https://github.com/pali/hsphfpd-prototype/blob/prototype/sco_features.pl > > > > > > > > > > And I found out that OCF_READ_LOCAL_CODECS HCI command cannot be send by > > > > > non-root user. Kernel returns "Operation not permitted" error. > > > > > > > > > > What is reason that kernel blocks OCF_READ_LOCAL_CODECS command for > > > > > non-root users? Without it (audio) application does not know which > > > > > codecs local bluetooth adapter supports. > > > > > > > > > > E.g. OCF_READ_LOCAL_EXT_FEATURES or OCF_READ_VOICE_SETTING commands can > > > > > be send also by non-root user and kernel does not block them. > > > > > > > > actually the direct access to HCI commands is being removed. So we have no plans to add new commands into the list since that it what the kernel is suppose to handle. If we wanted to expose this, then it has to be via mgmt. > > > > > > Hi Marcel! Thank you for information. I have not know that this API is > > > "deprecated" and is going to be removed. But userspace audio > > > applications need to know what bluetooth adapter supports, so can you > > > export result of these commands to userspace? My script linked above > > > calls: OCF_READ_VOICE_SETTING, OCF_READ_LOCAL_COMMANDS, > > > OCF_READ_LOCAL_EXT_FEATURES, OCF_READ_LOCAL_CODECS > > > > Hello! Just a gently reminder for this question. How to retrieve > > information about supported codecs from userspace by non-root user? > > Because running all bluetooth audio applications by root is not really a > > solution. Plus if above API for root user is going to be removed, what > > is a replacement? > > Hello! > > I have not got any answer to my email from Marcel for months, so I'm > adding other developers to loop. Could somebody tell me that is the > replacement API if above one is going to be removed? > > I was not able to find any documentation where could be described this > API nor information about deprecation / removal. > > And are you aware of the fact that removing of API could potentially > break existing applications? > > I really need to know which API should I use, because when I use API > which is going to be removed, then my application stops working. And I > really want to avoid it. > > Also I have not got any response yet, how can I read list of supported > codecs by bluetooth adapter by ordinary non-root user? Audio application > needs to know list of supported codecs and it is really insane to run it > as root. Hello! This is just another reminder that I have not got any reply to this email. Does silence mean that audio applications are expected to work only under root account and ordinary users are not able to use audio and list supported codecs? Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ANFtKpeuLl+8zQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 08 Aug 2020 15:54:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id MB7UKJeuLl+EfQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 08 Aug 2020 15:54:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5AFA8420CB; Sat, 8 Aug 2020 15:54:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726242AbgHHNyW (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 8 Aug 2020 09:54:22 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:47990 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbgHHNyM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 8 Aug 2020 09:54:12 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-8-i9qSWaqDO72eG3L16A1dCQ-1; Sat, 08 Aug 2020 14:54:08 +0100 X-MC-Unique: i9qSWaqDO72eG3L16A1dCQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Sat, 8 Aug 2020 14:54:07 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Sat, 8 Aug 2020 14:54:07 +0100 From: David Laight <David.Laight@ACULAB.COM> To: 'Eric Dumazet' <eric.dumazet@gmail.com>, Christoph Hellwig <hch@lst.de>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Eric Dumazet <edumazet@google.com> CC: "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "bpf@vger.kernel.org" <bpf@vger.kernel.org>, "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>, "coreteam@netfilter.org" <coreteam@netfilter.org>, "linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>, "linux-hams@vger.kernel.org" <linux-hams@vger.kernel.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "bridge@lists.linux-foundation.org" <bridge@lists.linux-foundation.org>, "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>, "dccp@vger.kernel.org" <dccp@vger.kernel.org>, "linux-decnet-user@lists.sourceforge.net" <linux-decnet-user@lists.sourceforge.net>, "linux-wpan@vger.kernel.org" <linux-wpan@vger.kernel.org>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, "mptcp@lists.01.org" <mptcp@lists.01.org>, "lvs-devel@vger.kernel.org" <lvs-devel@vger.kernel.org>, "rds-devel@oss.oracle.com" <rds-devel@oss.oracle.com>, "linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>, "tipc-discussion@lists.sourceforge.net" <tipc-discussion@lists.sourceforge.net>, "linux-x25@vger.kernel.org" <linux-x25@vger.kernel.org>, Stefan Schmidt <stefan@datenfreihafen.org> Subject: RE: [PATCH 25/26] net: pass a sockptr_t into ->setsockopt Thread-Topic: [PATCH 25/26] net: pass a sockptr_t into ->setsockopt Thread-Index: AQHWbD/ze4VO5Mh7NUG6O93LfP2Gq6ksXaowgACKZoCAAVFEkA== Date: Sat, 8 Aug 2020 13:54:06 +0000 Message-ID: <ed3741fdf1774cfbbd59d06ecb6994d8@AcuMS.aculab.com> References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-26-hch@lst.de> <6357942b-0b6e-1901-7dce-e308c9fac347@gmail.com> <f21589f1262640b09ca27ed20f8e6790@AcuMS.aculab.com> <90f626a4-d9e5-91a5-b71d-498e3b125da1@gmail.com> In-Reply-To: <90f626a4-d9e5-91a5-b71d-498e3b125da1@gmail.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.87 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5AFA8420CB X-Rspamd-UID: f73569 RnJvbTogRXJpYyBEdW1hemV0DQo+IFNlbnQ6IDA3IEF1Z3VzdCAyMDIwIDE5OjI5DQo+IA0KPiBP biA4LzcvMjAgMjoxOCBBTSwgRGF2aWQgTGFpZ2h0IHdyb3RlOg0KPiA+IEZyb206IEVyaWMgRHVt YXpldA0KPiA+PiBTZW50OiAwNiBBdWd1c3QgMjAyMCAyMzoyMQ0KPiA+Pg0KPiA+PiBPbiA3LzIy LzIwIDExOjA5IFBNLCBDaHJpc3RvcGggSGVsbHdpZyB3cm90ZToNCj4gPj4+IFJld29yayB0aGUg cmVtYWluaW5nIHNldHNvY2tvcHQgY29kZSB0byBwYXNzIGEgc29ja3B0cl90IGluc3RlYWQgb2Yg YQ0KPiA+Pj4gcGxhaW4gdXNlciBwb2ludGVyLiAgVGhpcyByZW1vdmVzIHRoZSBsYXN0IHJlbWFp bmluZyBzZXRfZnMoS0VSTkVMX0RTKQ0KPiA+Pj4gb3V0c2lkZSBvZiBhcmNoaXRlY3R1cmUgc3Bl Y2lmaWMgY29kZS4NCj4gPj4+DQo+ID4+PiBTaWduZWQtb2ZmLWJ5OiBDaHJpc3RvcGggSGVsbHdp ZyA8aGNoQGxzdC5kZT4NCj4gPj4+IEFja2VkLWJ5OiBTdGVmYW4gU2NobWlkdCA8c3RlZmFuQGRh dGVuZnJlaWhhZmVuLm9yZz4gW2llZWU4MDIxNTRdDQo+ID4+PiAtLS0NCj4gPj4NCj4gPj4NCj4g Pj4gLi4uDQo+ID4+DQo+ID4+PiBkaWZmIC0tZ2l0IGEvbmV0L2lwdjYvcmF3LmMgYi9uZXQvaXB2 Ni9yYXcuYw0KPiA+Pj4gaW5kZXggNTk0ZTAxYWQ2NzBhYTYuLjg3NGYwMWNkN2FlYzQyIDEwMDY0 NA0KPiA+Pj4gLS0tIGEvbmV0L2lwdjYvcmF3LmMNCj4gPj4+ICsrKyBiL25ldC9pcHY2L3Jhdy5j DQo+ID4+PiBAQCAtOTcyLDEzICs5NzIsMTMgQEAgc3RhdGljIGludCByYXd2Nl9zZW5kbXNnKHN0 cnVjdCBzb2NrICpzaywgc3RydWN0IG1zZ2hkciAqbXNnLCBzaXplX3QgbGVuKQ0KPiA+Pj4gIH0N Cj4gPj4+DQo+ID4+DQo+ID4+IC4uLg0KPiA+Pg0KPiA+Pj4gIHN0YXRpYyBpbnQgZG9fcmF3djZf c2V0c29ja29wdChzdHJ1Y3Qgc29jayAqc2ssIGludCBsZXZlbCwgaW50IG9wdG5hbWUsDQo+ID4+ PiAtCQkJICAgIGNoYXIgX191c2VyICpvcHR2YWwsIHVuc2lnbmVkIGludCBvcHRsZW4pDQo+ID4+ PiArCQkJICAgICAgIHNvY2twdHJfdCBvcHR2YWwsIHVuc2lnbmVkIGludCBvcHRsZW4pDQo+ID4+ PiAgew0KPiA+Pj4gIAlzdHJ1Y3QgcmF3Nl9zb2NrICpycCA9IHJhdzZfc2soc2spOw0KPiA+Pj4g IAlpbnQgdmFsOw0KPiA+Pj4NCj4gPj4+IC0JaWYgKGdldF91c2VyKHZhbCwgKGludCBfX3VzZXIg KilvcHR2YWwpKQ0KPiA+Pj4gKwlpZiAoY29weV9mcm9tX3NvY2twdHIoJnZhbCwgb3B0dmFsLCBz aXplb2YodmFsKSkpDQo+ID4+PiAgCQlyZXR1cm4gLUVGQVVMVDsNCj4gPj4+DQo+ID4+DQo+ID4+ IGNvbnZlcnRpbmcgZ2V0X3VzZXIoLi4uKSAgIHRvICBjb3B5X2Zyb21fc29ja3B0ciguLi4pIHJl YWxseSBhc3N1bWVkIHRoZSBvcHRsZW4NCj4gPj4gaGFzIGJlZW4gdmFsaWRhdGVkIHRvIGJlID49 IHNpemVvZihpbnQpIGVhcmxpZXIuDQo+ID4+DQo+ID4+IFdoaWNoIGlzIG5vdCBhbHdheXMgdGhl IGNhc2UsIGZvciBleGFtcGxlIGhlcmUuDQo+ID4+DQo+ID4+IFVzZXIgYXBwbGljYXRpb24gY2Fu IGZvb2wgdXMgcGFzc2luZyBvcHRsZW49MCwgYW5kIGEgdXNlciBwb2ludGVyIG9mIGV4YWN0bHkg VEFTS19TSVpFLTENCj4gPg0KPiA+IFdvbid0IHRoZSB1c2VyIHBvaW50ZXIgZm9yY2UgY29weV9m cm9tX3NvY2twdHIoKSB0byBjYWxsDQo+ID4gY29weV9mcm9tX3VzZXIoKSB3aGljaCB3aWxsIHRo ZW4gZG8gYWNjZXNzX29rKCkgb24gdGhlIGVudGlyZQ0KPiA+IHJhbmdlIGFuZCBzbyByZXR1cm4g LUVGQVVMVC4NCj4gPg0KPiA+IFRoZSBvbmx5IHByb2JsZW1zIGFyaXNlIGlmIHRoZSBrZXJuZWwg Y29kZSBhZGRzIGFuIG9mZnNldCB0byB0aGUNCj4gPiB1c2VyIGFkZHJlc3MuDQo+ID4gQW5kIHRo ZSBsYXRlciBwYXRjaCBhZGRlZCBhbiBvZmZzZXQgdG8gdGhlIGNvcHkgZnVuY3Rpb25zLg0KPiAN Cj4gSSBkdW5ubywgSSBkZWZpbml0ZWx5IGdvdCB0aGUgZm9sbG93aW5nIHN5emJvdCBjcmFzaA0K PiANCj4gTm8gcmVwcm8gZm91bmQgYnkgc3l6Ym90IHlldCwgYnV0IEkgc3VzcGVjdCBhIDMyYml0 IGJpbmFyeSBwcm9ncmFtDQo+IGRpZCA6DQo+IA0KPiBzZXRzb2Nrb3B0KGZkLCAweDI5LCAweDI0 LCAweGZmZmZmZmZmZmZmZmZmZmYsIDB4MCkNCg0KQSBmZXcgdG9vIG1hbnkgZmZzLi4uDQoNCj4g QlVHOiBLQVNBTjogd2lsZC1tZW1vcnktYWNjZXNzIGluIG1lbWNweSBpbmNsdWRlL2xpbnV4L3N0 cmluZy5oOjQwNiBbaW5saW5lXQ0KPiBCVUc6IEtBU0FOOiB3aWxkLW1lbW9yeS1hY2Nlc3MgaW4g Y29weV9mcm9tX3NvY2twdHJfb2Zmc2V0IGluY2x1ZGUvbGludXgvc29ja3B0ci5oOjcxIFtpbmxp bmVdDQo+IEJVRzogS0FTQU46IHdpbGQtbWVtb3J5LWFjY2VzcyBpbiBjb3B5X2Zyb21fc29ja3B0 ciBpbmNsdWRlL2xpbnV4L3NvY2twdHIuaDo3NyBbaW5saW5lXQ0KPiBCVUc6IEtBU0FOOiB3aWxk LW1lbW9yeS1hY2Nlc3MgaW4gZG9fcmF3djZfc2V0c29ja29wdCBuZXQvaXB2Ni9yYXcuYzoxMDIz IFtpbmxpbmVdDQo+IEJVRzogS0FTQU46IHdpbGQtbWVtb3J5LWFjY2VzcyBpbiByYXd2Nl9zZXRz b2Nrb3B0KzB4MWExLzB4NmYwIG5ldC9pcHY2L3Jhdy5jOjEwODQNCj4gUmVhZCBvZiBzaXplIDQg YXQgYWRkciAwMDAwMDAwMGZmZmZmZmZmIGJ5IHRhc2sgc3l6LWV4ZWN1dG9yLjAvMjgyNTENCg0K WWVwLCB0aGUgY29kZSBpcyBuZWFybHksIGJ1dCBub3QgcXVpdGUgcmlnaHQuDQpUaGUgcHJvYmxl bSBpcyBhbG1vc3QgY2VydGFpbmx5IHRoYXQgYWNjZXNzX29rKHgsIDApIGFsd2F5cyByZXR1cm5z IHN1Y2Nlc3MuDQoNCkluIGFueSBjYXNlIHRoZSBjaGVjayBmb3IgYSB2YWxpZCB1c2VyIGFkZHJl c3Mgb3VnaHQgdG8gYmUgZXhhY3RseQ0KdGhlIHNhbWUgb25lIHRoYXQgbGF0ZXIgc2VsZWN0cyBi ZXR3ZWVuIGNvcHlfdG8vZnJvbV91c2VyKCkgYW5kIG1lbWNweSgpLg0KDQpUaGUgbGF0dGVyIGNv bXBhcmVzIHRoZSBhZGRyZXNzIGFnYWluc3QgJ1RBU0tfU0laRScuDQpIb3dldmVyIHRoYXQgaXNu J3QgdGhlIHJpZ2h0IHZhbHVlIGVpdGhlciAtIEkgdGhpbmsgaXQgcmVhZHMNCnRoZSB2YWx1ZSBm cm9tICdjdXJyZW50JyB0aGF0IHNldF9mcygpIHNldHMuDQpXaGF0IHRoaXMgY29kZSBuZWVkcyBp cyBhbnkgYWRkcmVzcyB0aGF0IGlzIGFib3ZlIHRoZSBoaWdoZXN0DQp1c2VyIGFkZHJlc3MgYW5k IGJlbG93IChvciBlcXVhbCB0bykgdG8gbG93ZXN0IGtlcm5lbCBvbmUuDQoNCk9uIGkzODYgKGFu ZCBwcm9iYWJseSBtb3N0IDMyYml0IGxpbnV4KSB0aGlzIGlzIDB4YzAwMDAwMDAuDQpPbiB4ODYt NjQgdGhpcyBjb3VsZCBiZSBhbnkgYWRkcmVzcyBpbiB0aGUgYWRkcmVzcyAnYmxhY2sgaG9sZScu DQpQaWNraW5nIDF1bGw8PDYzIG1heSBiZSBiZXN0Lg0KUXVpdGUgd2hhdCB0aGUgY29ycmVjdCAj ZGVmaW5lIGlzIHJlcXVpcmVzIGZ1cnRoZXIgcmVzZWFyY2guDQoNClRoZXJlIGlzIGFjdHVhbGx5 IHNjb3BlIGZvciBtYWtpbmcgaW5pdF91c2VyX3NvY2twdHIoa2Vybl9hZGRyZXNzKQ0Kc2F2ZSBh IHZhbHVlIHRoYXQgd2lsbCBjYXVzZSBjb3B5X3RvL2Zyb21fc29ja3B0cigpIGdvIGludG8NCnRo ZSB1c2VyLWNvcHkgcGF0aCB3aXRoIGFuIGFkZHJlc3MgdGhhdCBhY2Nlc3Nfb2soKSB3aWxsIHJl amVjdC4NClRoZW4gdGhlIC1FRkFVTFQgd2lsbCBnZXQgZ2VuZXJhdGVkIGluIHRoZSAnZXhwZWN0 ZWQnIHBsYWNlDQphbmQgdGhlcmUgaXMgbm8gc2NvcGUgZm9yIGZhaWxpbmcgdG8gdGVzdCBpdCdz IHJldHVybiB2YWx1ZS4NCg0KCURhdmlkDQoNCi0NClJlZ2lzdGVyZWQgQWRkcmVzcyBMYWtlc2lk ZSwgQnJhbWxleSBSb2FkLCBNb3VudCBGYXJtLCBNaWx0b24gS2V5bmVzLCBNSzEgMVBULCBVSw0K UmVnaXN0cmF0aW9uIE5vOiAxMzk3Mzg2IChXYWxlcykNCg== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kHeKJ2r9Ll+j/QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 08 Aug 2020 21:30:50 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id gOz5JWr9Ll/OAgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 08 Aug 2020 21:30:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5847940134; Sat, 8 Aug 2020 21:30:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726389AbgHHTaU (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 8 Aug 2020 15:30:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:48992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726232AbgHHTaT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 8 Aug 2020 15:30:19 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E0FEF2067D for <linux-bluetooth@vger.kernel.org>; Sat, 8 Aug 2020 19:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596915019; bh=2226bEyerzItLybHMBlj5sXan6LT38jfwU0O6wIhD/s=; h=From:To:Subject:Date:From; b=Il2yOt84oi1WlbuJrm7R64bqyQy4ObzqfSbUpG4wdOCGui1xcwsMQrGat5g8yOc7/ Nz9NOV10GCEmOqmOnVmoYsbJAQ2iU2VOktnKuAbcnyfhF2S0yeL2+Wp4g7KO9+hpAr 1ZmLPvUUtPG1UbF/5DoLqgkbGN+zcEiHyD3olYnI= Received: by pali.im (Postfix) id DEF725FD; Sat, 8 Aug 2020 21:30:16 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org> To: linux-bluetooth@vger.kernel.org Subject: [PATCH] sbcenc: Add missing error check for unsupported sample rates Date: Sat, 8 Aug 2020 21:30:14 +0200 Message-Id: <20200808193014.28951-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5847940134 X-Rspamd-UID: da43cd Signed-off-by: Pali Rohár <pali@kernel.org> --- src/sbcenc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sbcenc.c b/src/sbcenc.c index dabdff4..2a4c240 100644 --- a/src/sbcenc.c +++ b/src/sbcenc.c @@ -105,6 +105,10 @@ static void encode(char *filename, int subbands, int bitpool, int joint, case 48000: sbc.frequency = SBC_FREQ_48000; break; + default: + fprintf(stderr, "Unsupported sample rate %ukHz\n", + BE_INT(au_hdr.sample_rate)); + goto done; } srate = BE_INT(au_hdr.sample_rate); -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kHPGK3D9Ll87+QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 08 Aug 2020 21:30:56 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EDw5KnD9Ll/xcQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 08 Aug 2020 21:30:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BEF36420C1; Sat, 8 Aug 2020 21:30:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726499AbgHHTac (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 8 Aug 2020 15:30:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:49058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726442AbgHHTaa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 8 Aug 2020 15:30:30 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2E3A42067D for <linux-bluetooth@vger.kernel.org>; Sat, 8 Aug 2020 19:30:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596915030; bh=7/IP/YeW1xDEX7TOnwwN4jstuz8IGkEV5kbaaX15IfM=; h=From:To:Subject:Date:From; b=kxObHKXmDWR+ZLRbfThBEoD0QCAQ6KV1ara53Y8k+vNekS7FBeKTBcnmdvj2xCD5R JLHWCPRmA7Bg0DEcSZrhdYdPruef6wY4HO4v6XMYXGS6QWHzhvaZCXXhUOmjvCTXNR 87kX/ynP+aWioONxjOKqxeBjb81AyjN9egoljAg0= Received: by pali.im (Postfix) id 7B73A5FD; Sat, 8 Aug 2020 21:30:28 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org> To: linux-bluetooth@vger.kernel.org Subject: [PATCH] sbcenc: Remove duplicate check for num of channels Date: Sat, 8 Aug 2020 21:30:26 +0200 Message-Id: <20200808193026.29007-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: BEF36420C1 X-Rspamd-UID: 0f8af9 Signed-off-by: Pali Rohár <pali@kernel.org> --- src/sbcenc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sbcenc.c b/src/sbcenc.c index 2a4c240..6f8d794 100644 --- a/src/sbcenc.c +++ b/src/sbcenc.c @@ -142,7 +142,6 @@ static void encode(char *filename, int subbands, int bitpool, int joint, blocks == 12 ? SBC_BLK_12 : SBC_BLK_16; } else { if (BE_INT(au_hdr.sample_rate) != 16000 || - BE_INT(au_hdr.channels) != 1 || BE_INT(au_hdr.channels) != 1) { fprintf(stderr, "mSBC requires 16 bits, 16kHz, mono " "input\n"); -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2AwOJsIYL18u7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 08 Aug 2020 23:27:30 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uG1lJMIYL1/BqQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 08 Aug 2020 23:27:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0A1E1A0183; Sat, 8 Aug 2020 23:27:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726375AbgHHV1R (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 8 Aug 2020 17:27:17 -0400 Received: from mail-io1-f69.google.com ([209.85.166.69]:43465 "EHLO mail-io1-f69.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgHHV1R (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 8 Aug 2020 17:27:17 -0400 Received: by mail-io1-f69.google.com with SMTP id f19so4385122iol.10 for <linux-bluetooth@vger.kernel.org>; Sat, 08 Aug 2020 14:27:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=IADNMrokZmxOUKia7Uum9r4PEiRU6p/oiYSUbRzW15k=; b=KwDoG/YQAHYOn/2wkxMFffEVAImrlnfaTi1cS9k6rm3W1COxbwH2RDiOEv+CZ8LAk1 lXkrPjZZIho/5lx66FeJGPjBdErCTc38VqKyqw0qMbA5eDIP4sFhwulePllOQGBc3vOv NfG+N5YfPAULmmT+ph7fP3+odCm3X3GRNDcx95VubU84T36H1dV4GPR1zIJNC9m4HwNX 6Fcmzvc1zAfV+26Kk39h7W4uDmTUrHV+7/iVmkoW8pFb2PoNKbEopg5kTicbwC+r41do yRZ8Vs62T920C/xXvBUHRD8QqnjPpBLp9CcQyXcrytS6yvkTeQqJ03nRsEvODm/qjPKX goIg== X-Gm-Message-State: AOAM530SODZ1s9LazLWXEzy0noi1VymD6kCvGm9A11I9U+zgklzOZ0bd jGLwrdeykEDG7Cfcc373r/CKlsbMvJ8ZUYKJR4CsuxeOGksX X-Google-Smtp-Source: ABdhPJwi//OPGAqjzWtcAVqRFu+q32nwkVhlurk0BWqeIBfa0Ekl0+QoU8oNh+cSdWS3Pxj6iDOfUcGVs6UiB/m7Cr7fogCDrGei MIME-Version: 1.0 X-Received: by 2002:a92:c7d0:: with SMTP id g16mr10954289ilk.101.1596922035608; Sat, 08 Aug 2020 14:27:15 -0700 (PDT) Date: Sat, 08 Aug 2020 14:27:15 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000aaa4a905ac646223@google.com> Subject: KASAN: use-after-free Read in __queue_work (3) From: syzbot <syzbot+77e5e02c6c81136cdaff@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.21 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0A1E1A0183 X-Rspamd-UID: 7c3b19 Hello, syzbot found the following issue on: HEAD commit: c0842fbc random32: move the pseudo-random 32-bit definitio.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=127a8d66900000 kernel config: https://syzkaller.appspot.com/x/.config?x=cf567e8c7428377e dashboard link: https://syzkaller.appspot.com/bug?extid=77e5e02c6c81136cdaff compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=140e36a4900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+77e5e02c6c81136cdaff@syzkaller.appspotmail.com ================================================================== BUG: KASAN: use-after-free in __queue_work+0xc6c/0xf20 kernel/workqueue.c:1412 Read of size 4 at addr ffff88809f1ab9c0 by task syz-executor.3/16144 CPU: 0 PID: 16144 Comm: syz-executor.3 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530 __queue_work+0xc6c/0xf20 kernel/workqueue.c:1412 queue_work_on+0x18b/0x200 kernel/workqueue.c:1518 queue_work include/linux/workqueue.h:507 [inline] req_run+0x2c5/0x4a0 net/bluetooth/hci_request.c:90 hci_req_run_skb net/bluetooth/hci_request.c:102 [inline] __hci_req_sync+0x1dd/0x830 net/bluetooth/hci_request.c:215 hci_req_sync+0x8a/0xc0 net/bluetooth/hci_request.c:282 hci_dev_cmd+0x5b3/0x950 net/bluetooth/hci_core.c:2011 hci_sock_ioctl+0x3fa/0x800 net/bluetooth/hci_sock.c:1053 sock_do_ioctl+0xcb/0x2d0 net/socket.c:1048 sock_ioctl+0x3b8/0x730 net/socket.c:1199 vfs_ioctl fs/ioctl.c:48 [inline] ksys_ioctl+0x11a/0x180 fs/ioctl.c:753 __do_sys_ioctl fs/ioctl.c:762 [inline] __se_sys_ioctl fs/ioctl.c:760 [inline] __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x45cce9 Code: 2d b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb b5 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007f18d49bfc78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 000000000001d300 RCX: 000000000045cce9 RDX: 0000000020000000 RSI: 00000000400448de RDI: 0000000000000004 RBP: 000000000078c080 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 000000000078c04c R13: 00007ffc84a6ab1f R14: 00007f18d49c09c0 R15: 000000000078c04c Allocated by task 9187: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494 __do_kmalloc mm/slab.c:3656 [inline] __kmalloc+0x17a/0x340 mm/slab.c:3665 kmalloc include/linux/slab.h:560 [inline] kzalloc include/linux/slab.h:669 [inline] alloc_workqueue+0x166/0xe50 kernel/workqueue.c:4265 hci_register_dev+0x1b5/0x930 net/bluetooth/hci_core.c:3509 __vhci_create_device+0x2ac/0x5b0 drivers/bluetooth/hci_vhci.c:124 vhci_create_device drivers/bluetooth/hci_vhci.c:148 [inline] vhci_open_timeout+0x38/0x50 drivers/bluetooth/hci_vhci.c:305 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Freed by task 16170: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x103/0x2c0 mm/slab.c:3757 rcu_do_batch kernel/rcu/tree.c:2427 [inline] rcu_core+0x5c7/0x1190 kernel/rcu/tree.c:2655 __do_softirq+0x2de/0xa24 kernel/softirq.c:298 The buggy address belongs to the object at ffff88809f1ab800 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 448 bytes inside of 1024-byte region [ffff88809f1ab800, ffff88809f1abc00) The buggy address belongs to the page: page:ffffea00027c6ac0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00028becc8 ffffea00028ddbc8 ffff8880aa000c40 raw: 0000000000000000 ffff88809f1ab000 0000000100000002 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809f1ab880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88809f1ab900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88809f1ab980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88809f1aba00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88809f1aba80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uIk+B7mGL1/e1QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 09 Aug 2020 07:16:41 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iITeBbmGL1/h8QAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 09 Aug 2020 07:16:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 73C31A13BE; Sun, 9 Aug 2020 07:16:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726207AbgHIFPK (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 9 Aug 2020 01:15:10 -0400 Received: from mail-il1-f198.google.com ([209.85.166.198]:40889 "EHLO mail-il1-f198.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725988AbgHIFPK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 9 Aug 2020 01:15:10 -0400 Received: by mail-il1-f198.google.com with SMTP id z16so5194194ill.7 for <linux-bluetooth@vger.kernel.org>; Sat, 08 Aug 2020 22:15:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=+7GquL5yQSGcFGMZlACJ2Y2BFlEpHb0ViyNa4GHMUYI=; b=rMKqoFXSgY4F1MrcXxUWWLOI1YxA02DIucJqt6GA/qnHq0Lqy1rdIzoaFX36EM6uk1 H3QItdZ0+08Av+qyXWN3LQ4+OrRnWodNafFoWs1QrhruU7bIrDbX0oflBSQR2raDSLZE YhFGFsMEJkAAWWDrxqojK36VM8PYIm9xachapP9AVSwgSLEs1RiCmRYlvXPmbZ4B07o4 g6Zge+9zIfViO0HZDcSJG7mECiSD0iVVzR1cq4dmvQWsCPNp7hloss6zdojhnOYrR8gq Om27rNxzUQtyq+loq5anRYzoOUXV97zqnkQesAR2NBcoFLpOFhlZK1YLPFxObYvlA1TS FFKg== X-Gm-Message-State: AOAM533yueFchy2l0DgS6YPmeqHgzmEUHmS0sN3sBfOdCd506mTIOTQb JM6IOpkLG4Ti0g/vDj4MIbl46Yg7wS+x5KiCR+/eruSohhcx X-Google-Smtp-Source: ABdhPJwnoROO8orXk27MbZoY6LmPmQEmrUZnYlYAjH2J4bAGvlMJDDzVwIZ0hH60TV5qaTtB7u2wVG/qNSiGwWh/MNVTaKiDIsBk MIME-Version: 1.0 X-Received: by 2002:a92:918b:: with SMTP id e11mr12138160ill.201.1596950109419; Sat, 08 Aug 2020 22:15:09 -0700 (PDT) Date: Sat, 08 Aug 2020 22:15:09 -0700 In-Reply-To: <000000000000cde53e05ac446157@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000fefd5e05ac6aeb99@google.com> Subject: Re: WARNING: ODEBUG bug in put_device From: syzbot <syzbot+a9290936c6e87b3dc3c2@syzkaller.appspotmail.com> To: bgolaszewski@baylibre.com, davem@davemloft.net, gregkh@linuxfoundation.org, jdelvare@suse.com, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, marcel@holtmann.org, netdev@vger.kernel.org, rafael@kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 73C31A13BE X-Rspamd-UID: 56f458 syzbot has bisected this issue to: commit 6f8c8f3c31015808100ee54fc471ff5dffdf1734 Author: Bartosz Golaszewski <bgolaszewski@baylibre.com> Date: Thu Aug 8 08:01:44 2019 +0000 hwmon: pmbus: ucd9000: remove unneeded include bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1550298a900000 start commit: 47ec5303 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=1750298a900000 console output: https://syzkaller.appspot.com/x/log.txt?x=1350298a900000 kernel config: https://syzkaller.appspot.com/x/.config?x=7bb894f55faf8242 dashboard link: https://syzkaller.appspot.com/bug?extid=a9290936c6e87b3dc3c2 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11b69a52900000 Reported-by: syzbot+a9290936c6e87b3dc3c2@syzkaller.appspotmail.com Fixes: 6f8c8f3c3101 ("hwmon: pmbus: ucd9000: remove unneeded include") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eGdFOtKKL1818AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 09 Aug 2020 07:34:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id mBwmOdKKL198CwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 09 Aug 2020 07:34:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C983C420BF; Sun, 9 Aug 2020 07:34:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726097AbgHIFeD (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 9 Aug 2020 01:34:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725988AbgHIFeC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 9 Aug 2020 01:34:02 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5B5FC061756 for <linux-bluetooth@vger.kernel.org>; Sat, 8 Aug 2020 22:34:02 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id k12so4824480otr.1 for <linux-bluetooth@vger.kernel.org>; Sat, 08 Aug 2020 22:34:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=2VpcYfBJa/ronbImLa6I+wXesRjiNdZljgfdNr+5KsE=; b=RccIo4MQtUPYotw1GL+NPkug/MlbGmQr/xuIGZ61BLn6DLzHQpTKjMLqQp7pUuKQhy e+VqOhwmGB+rnJF2TZmduSWM9pszK0uPGcfGJV6a/gNJFRhIC6uOM+hcvdPf3roF+kQi zp+EQDj/fQJj4LPMkgUKy6g4ejDEm1gIV4Vgte2KHlPS/mMWPgBBG3W++t4jp3VD7ofZ ViZ/4mJMdKa2QfpWfylmmvNFDV6wGt6mkEJbXui84NgXCCXHf2ZmqqcTb84nXn3Ba2HD UcHVMlKQi31LxPwEkhRXEUWo1VsY44NeEufPv4TG6YQEdPaxnyAzKjNiVmZF+dSMkboY hi6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=2VpcYfBJa/ronbImLa6I+wXesRjiNdZljgfdNr+5KsE=; b=MLY24vzrw9ElbWUIis4aMTNSCMf0q06V7O/X5DKiguWBFJb8ICsEq14lsLzkkV9P/y 9JXpfXCR59WJipzUg/5taX5W27zbSJSMxV6sZvVfORqbeV6sRFpf7qAxYFz61Q3ZOX5d 60uMskW6M/iHu4Tkkh/sjNjHbAg7VyvK0q5Pujg64H39KrajDt+N169CC7aKir+6Kb0i X8mZVpkVfD/MSqeu/t0F3RIc4BXlYNv8lqcT/hU2HyBaf/8zV+JWKAfADFO8pyE7ceSa xyUxMc+fGb7rIT0NhcjHOIMGp/sNs54TEr3QjNghtM2S2oBAM24RMI2KuWQmhXf/xcIw 8A0g== X-Gm-Message-State: AOAM530jO//w8tPGJIhlIviXW73ZU2gPEgEgCQ0gZ+RTEzov9M+cA/u5 7uPmz6bE+CIZqOPfhvqADgxK3nbSKoSFMnsp5qJD+g== X-Google-Smtp-Source: ABdhPJx8yDPl1Lm/96FrMiRuxKpdHNophm9vVC+3/azSbq7r9ybDXdWUQpoZT1OHPfNUzE3J6bTpW8hkSV+h7C/9FK0= X-Received: by 2002:a9d:39c2:: with SMTP id y60mr18534190otb.91.1596951240503; Sat, 08 Aug 2020 22:34:00 -0700 (PDT) MIME-Version: 1.0 References: <20200506193435.3746-1-pali@kernel.org> <CECA6D9A-0F26-40E8-BFDF-A24CD972307D@holtmann.org> <20200610093306.zt3q3s2wmwp3almw@pali> <7672C0A0-AF6A-41B2-B50F-7836B3E5CC73@holtmann.org> <20200611125304.b4mxxuv7rupamfmg@pali> <20200713090913.6duirl4yhrjcyxoh@pali> <20200808132042.mma5ykynagwx3ubd@pali> In-Reply-To: <20200808132042.mma5ykynagwx3ubd@pali> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Sat, 8 Aug 2020 22:33:48 -0700 Message-ID: <CABBYNZ+Ep6njp9vfEZrFTGCiSMcsdoPnPa21H0ApJ1O3tau_MQ@mail.gmail.com> Subject: Re: [PATCH] Install avinfo utility To: =?UTF-8?Q?Pali_Roh=C3=A1r?= <pali@kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org>, David Heidelberg <david@ixit.cz> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: C983C420BF X-Rspamd-UID: 1d309d Hi Pali, On Sat, Aug 8, 2020 at 6:20 AM Pali Roh=C3=A1r <pali@kernel.org> wrote: > > On Monday 13 July 2020 11:09:13 Pali Roh=C3=A1r wrote: > > On Thursday 11 June 2020 14:53:04 Pali Roh=C3=A1r wrote: > > > On Wednesday 10 June 2020 19:31:47 Marcel Holtmann wrote: > > > > Hi Pali, > > > > > > > > >>> This utility is very useful for determining which A2DP codecs a= re supported > > > > >>> by remote side. So install it to system as part of bluez packag= e. > > > > >>> --- > > > > >>> Makefile.tools | 4 ++-- > > > > >>> 1 file changed, 2 insertions(+), 2 deletions(-) > > > > >>> > > > > >>> diff --git a/Makefile.tools b/Makefile.tools > > > > >>> index 9b9236609..d52721612 100644 > > > > >>> --- a/Makefile.tools > > > > >>> +++ b/Makefile.tools > > > > >>> @@ -176,9 +176,9 @@ endif > > > > >>> if TOOLS > > > > >>> bin_PROGRAMS +=3D tools/rctest tools/l2test tools/l2ping tools/= bccmd \ > > > > >>> tools/bluemoon tools/hex2hcd tools/mpris-= proxy \ > > > > >>> - tools/btattach > > > > >>> + tools/btattach tools/avinfo > > > > >>> > > > > >>> -noinst_PROGRAMS +=3D tools/bdaddr tools/avinfo tools/avtest \ > > > > >>> +noinst_PROGRAMS +=3D tools/bdaddr tools/avtest \ > > > > >>> tools/scotest tools/amptest tools/hwdb \ > > > > >>> tools/hcieventmask tools/hcisecfilter \ > > > > >>> tools/btinfo tools/btconfig \ > > > > >> > > > > >> I had no intention to install that tool since it is too limited > > > > > > > > > > Sorry, but I have not seen any limitations with this tool yet. I'= m using > > > > > it very often. And also other people who use it have not mentione= d any > > > > > limitations or problems. > > > > > > > > > > So could you be more specific what are those limitations? > > > > > > > > > > Also it is the first thing which I'm saying people that should ru= n and > > > > > send me output of it if something related to A2DP does not work. > > > > > > > > > > And because linux distributions do not package this utility and b= luez > > > > > developers (for me for unknown reasons) decided to not install it= , > > > > > result is that people have to always compile bluez from source to= run > > > > > this utility if their A2DP audio does not work or "remote" debugg= ing of > > > > > A2DP is needed. > > > > > > > > > > So result is that who want to know why A2DP audio does not work i= s > > > > > forced to compile & install bluez from sources and not to use fro= m > > > > > distribution package. And this probably not the expected state. > > > > > > > > > > In any case, nobody reported to me any limitation with one except= ion > > > > > that it cannot decode capabilities of some custom vendor codecs. = But > > > > > most of them are already supported as I sent needed patches in pa= st. > > > > > > > > > >> and makes too many assumption. > > > > > > > > > > For example which assumptions? > > > > > > > > that nothing else is happening right now. It backstabs the actual A= VDTP and A2DP implementation. > > > > > > Marcel, but this is not a problem. For that one purpose which avinfo > > > provides it ideal and works fine. Personally I do not see any problem > > > with it. > > > > > > > >> In addition it has a bad name with no Bluetooth prefix. > > > > > > > > > > So, lets rename it. What about "btavinfo"? > > > > > > > > Lets extend btinfo with all sort of capabilities. Make the av porti= on just one of. I want to remove the multitudes of test utilities anyway. W= e have to many tiny utilities that are just scattered around and avinfo is = just one of them. > > > > > > This looks like a not-so-trivial task and moreover independent of > > > providing current version of avinfo to users. > > > > > > avinfo already exists, is already part of bluez project, it is alread= y > > > compiling during bluez build and is already used by me and lot of oth= er > > > users and works for that one purpose as expected. > > > > > > > > > > > > >> If we think it is useful to have such a test utility, then we ne= ed to clean this up first > > > > > > > > > > What exactly to clean up first? > > > > > > > > > > Note that I have already done cleanup of this utility. > > > > > > > > > >> and put this into a larger btinfo work to gather appropriate inf= ormation from a remote device for debug purposes. > > > > > > > > > > I do not see how btinfo can be used for A2DP purposes. Seems this= is > > > > > utility for local controller info and not for remove A2DP. > > > > > > > > This needs a bit thinking, but pretty much simple things like this: > > > > > > > > btinfo local > > > > btinfo avdtp <remote_bdaddr> > > > > > > > > We can create a module handling system so that you can easily links= existing tiny utilities into one. > > > > > > I'm not against this change. But this is additional work which needs = to > > > be done. And it would not happen today or tomorrow unless you have > > > already patches which implement it. > > > > > > As I said avinfo is already there, implemented, it is working and is > > > part of bluez source code. And is basically the first step when > > > debugging issues with A2DP audio. > > > > > > So what is the real issue with not only compiling this avinfo tool > > > during building bluez but also installing it? > > > > Because nobody presented any real issue for more then month and I'm not > > aware of any, could be avinfo finally enabled during installation? > > PING, two months passed and I have not received any new reply to this pat= ch. > > If there are really no problems, could it be applied? For the record I do intend to enable listing available endpoints in bluetooth-player, which might actually get merged into bluetoothctl as a new menu, recently there have been some vulnerabilities reported against these kind of tools that are meant to only be used for testing purposes so I would only be in favor of installing them with we add some new build option i.e. --enable-testing and document that these tools are meant for testing only (and shall probably be package separately) so we avoid these pointless reports for tools that are not really meant to be used in production. --=20 Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UL/FAv+kL1/9ZwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 09 Aug 2020 09:25:51 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UNv2AP+kL197pQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 09 Aug 2020 09:25:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9C92E418AF; Sun, 9 Aug 2020 09:25:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbgHIHZj (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 9 Aug 2020 03:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725710AbgHIHZj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 9 Aug 2020 03:25:39 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F1AC061756; Sun, 9 Aug 2020 00:25:39 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id 17so3474498pfw.9; Sun, 09 Aug 2020 00:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LXRSiIIsdnywtiWIezzvW9bD/x7NcWCcTqyfL9gD3uA=; b=jTuxgSGiRxcq2P0c4zCzQVGkKUXnW72njViEDu2UqsELULaRrrvefVtmdzbqhX1w1i n+dDIuOuMuQ6fYCWbBBjY1IRqDaiIK9bbf5R4xoVzK3L+YRtayZyRMPqee9Xa3ECWum3 UhDUewKiPcz+d+z3nKGOxtRH966wCewfCtOkWXyXf7TdHvTXRGDDeUCxBdrMzx6hv8aZ jQezRA1C6bspfmHJwhj4VASRBPZCDzpIM+jGXjUxH8dsH/roWiS9sI2grqe+X7FBD+60 OD7xNcemiev6I9jy/0cgA8tU5rDsCZvY1nW243cPIZpBcNGmDzJd1kOLAPPdlimCwNLP QKAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LXRSiIIsdnywtiWIezzvW9bD/x7NcWCcTqyfL9gD3uA=; b=ICc9+khSAXoIuFU1ALI0ABjm5RuSn/+cqXlFcO5WvHNB/GHNYx+QF461q6elH5lcNV Vi0j+aO/c2A2ggNNLZn+nj4h8a3STfwvE/E1QGzHl3YtmoUArhPcvtfBhPWl8eniPlJr hhqhz2v6GHhTHWF34jIrKXmdM9q6Ad+pXoBPbSM8MHJzE4kbNizJx99fnXWtevcprrk9 nqFAp/7IlXQky8e4Y1KS4HPcJEnbw1ljR/N7WvKbQrPB7Qlf0KrUDJRSK3bOm0pS87AM 03psy05XGIfd0pUmx7VjTzfXYlARXT4N3/kGSU+/OOJ+WX9PJgkT2vUbdqgs4W9LdQB8 66dA== X-Gm-Message-State: AOAM5328rIaf661TKl8jxziEq+7iTTMl7H6gTexV9ZlDy6HpPveV2S3m JtHOTJKulCtJYEZJ/zKULe0= X-Google-Smtp-Source: ABdhPJw58c9cbbVQ4EeDel38Sb8HMMdoskAIBG4iV5s2tEWaCOtmA5+GVFN7EqxkwXKPTcEwCcQ9mg== X-Received: by 2002:a62:5284:: with SMTP id g126mr19969971pfb.139.1596957938246; Sun, 09 Aug 2020 00:25:38 -0700 (PDT) Received: from localhost.localdomain (c-24-16-167-223.hsd1.wa.comcast.net. [24.16.167.223]) by smtp.gmail.com with ESMTPSA id z4sm17935792pfb.55.2020.08.09.00.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 00:25:37 -0700 (PDT) From: YourName <argoz1701@gmail.com> To: marcel@holtmann.org Cc: johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, argoz1701 <argoz1701@gmail.com> Subject: [PATCH] drivers: bluetooth: btintel.c: fixed format issue. Date: Sun, 9 Aug 2020 00:25:32 -0700 Message-Id: <20200809072532.14919-1-argoz1701@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9C92E418AF X-Rspamd-UID: 29a3a0 From: argoz1701 <argoz1701@gmail.com> Fixed a coding style issue. Signed-off-by: Daniel West <argoz1701@gmail.com> --- drivers/bluetooth/btintel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index 5fa5be3c5598..d0512506fa05 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -29,7 +29,7 @@ int btintel_check_bdaddr(struct hci_dev *hdev) HCI_INIT_TIMEOUT); if (IS_ERR(skb)) { int err = PTR_ERR(skb); - bt_dev_err(hdev, "Reading Intel device address failed (%d)", + bt_dev_err(hdev, "Reading Intel device address failed (%d)", err); return err; } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uER8CVLkL19ytwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 09 Aug 2020 13:56:02 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UMWmB1LkL18AswAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 09 Aug 2020 13:56:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 83F42A12CF; Sun, 9 Aug 2020 13:55:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726468AbgHILzo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 9 Aug 2020 07:55:44 -0400 Received: from mga05.intel.com ([192.55.52.43]:53130 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbgHILzk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 9 Aug 2020 07:55:40 -0400 IronPort-SDR: QTJWN+5UcGXpjtWobFv4vFGO3Pth8xHR7ModPbmbaLqRdAL+NZpKb5YRKC8GSGnWrr9iK4EPs9 Hm90hz5dziBg== X-IronPort-AV: E=McAfee;i="6000,8403,9707"; a="238242409" X-IronPort-AV: E=Sophos;i="5.75,453,1589266800"; d="gz'50?scan'50,208,50";a="238242409" X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2020 04:35:18 -0700 IronPort-SDR: KzKuM2zNeGzzy2mIf3m3bSlg7SFQsLkkYOdd6c9prCyXefzUtGtpMA4k9/kIn+fHzHMaiue8/u o794b/gQBrPA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,453,1589266800"; d="gz'50?scan'50,208,50";a="277057670" Received: from lkp-server02.sh.intel.com (HELO 5ad9e2f13e37) ([10.239.97.151]) by fmsmga008.fm.intel.com with ESMTP; 09 Aug 2020 04:35:16 -0700 Received: from kbuild by 5ad9e2f13e37 with local (Exim 4.92) (envelope-from <lkp@intel.com>) id 1k4jbg-00008U-21; Sun, 09 Aug 2020 11:35:16 +0000 Date: Sun, 9 Aug 2020 19:35:07 +0800 From: kernel test robot <lkp@intel.com> To: YourName <argoz1701@gmail.com>, marcel@holtmann.org Cc: kbuild-all@lists.01.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, argoz1701 <argoz1701@gmail.com> Subject: Re: [PATCH] drivers: bluetooth: btintel.c: fixed format issue. Message-ID: <202008091929.c2nESFzv%lkp@intel.com> References: <20200809072532.14919-1-argoz1701@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1yeeQ81UyVL57Vl7" Content-Disposition: inline In-Reply-To: <20200809072532.14919-1-argoz1701@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: 83F42A12CF X-Rspamd-UID: 44a172 --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi YourName, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on bluetooth-next/master] [also build test WARNING on v5.8 next-20200807] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/YourName/drivers-bluetooth-btintel-c-fixed-format-issue/20200809-152614 base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master config: i386-randconfig-m021-20200809 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> smatch warnings: drivers/bluetooth/btintel.c:32 btintel_check_bdaddr() warn: inconsistent indenting vim +32 drivers/bluetooth/btintel.c 48f0ed1bb68589 Marcel Holtmann 2015-04-06 22 48f0ed1bb68589 Marcel Holtmann 2015-04-06 23 int btintel_check_bdaddr(struct hci_dev *hdev) 48f0ed1bb68589 Marcel Holtmann 2015-04-06 24 { 48f0ed1bb68589 Marcel Holtmann 2015-04-06 25 struct hci_rp_read_bd_addr *bda; 48f0ed1bb68589 Marcel Holtmann 2015-04-06 26 struct sk_buff *skb; 48f0ed1bb68589 Marcel Holtmann 2015-04-06 27 48f0ed1bb68589 Marcel Holtmann 2015-04-06 28 skb = __hci_cmd_sync(hdev, HCI_OP_READ_BD_ADDR, 0, NULL, 48f0ed1bb68589 Marcel Holtmann 2015-04-06 29 HCI_INIT_TIMEOUT); 48f0ed1bb68589 Marcel Holtmann 2015-04-06 30 if (IS_ERR(skb)) { 48f0ed1bb68589 Marcel Holtmann 2015-04-06 31 int err = PTR_ERR(skb); 2064ee332e4c1b Marcel Holtmann 2017-10-30 @32 bt_dev_err(hdev, "Reading Intel device address failed (%d)", 2064ee332e4c1b Marcel Holtmann 2017-10-30 33 err); 48f0ed1bb68589 Marcel Holtmann 2015-04-06 34 return err; 48f0ed1bb68589 Marcel Holtmann 2015-04-06 35 } 48f0ed1bb68589 Marcel Holtmann 2015-04-06 36 48f0ed1bb68589 Marcel Holtmann 2015-04-06 37 if (skb->len != sizeof(*bda)) { 2064ee332e4c1b Marcel Holtmann 2017-10-30 38 bt_dev_err(hdev, "Intel device address length mismatch"); 48f0ed1bb68589 Marcel Holtmann 2015-04-06 39 kfree_skb(skb); 48f0ed1bb68589 Marcel Holtmann 2015-04-06 40 return -EIO; 48f0ed1bb68589 Marcel Holtmann 2015-04-06 41 } 48f0ed1bb68589 Marcel Holtmann 2015-04-06 42 48f0ed1bb68589 Marcel Holtmann 2015-04-06 43 bda = (struct hci_rp_read_bd_addr *)skb->data; 48f0ed1bb68589 Marcel Holtmann 2015-04-06 44 48f0ed1bb68589 Marcel Holtmann 2015-04-06 45 /* For some Intel based controllers, the default Bluetooth device 48f0ed1bb68589 Marcel Holtmann 2015-04-06 46 * address 00:03:19:9E:8B:00 can be found. These controllers are 48f0ed1bb68589 Marcel Holtmann 2015-04-06 47 * fully operational, but have the danger of duplicate addresses 48f0ed1bb68589 Marcel Holtmann 2015-04-06 48 * and that in turn can cause problems with Bluetooth operation. 48f0ed1bb68589 Marcel Holtmann 2015-04-06 49 */ 48f0ed1bb68589 Marcel Holtmann 2015-04-06 50 if (!bacmp(&bda->bdaddr, BDADDR_INTEL)) { 2064ee332e4c1b Marcel Holtmann 2017-10-30 51 bt_dev_err(hdev, "Found Intel default device address (%pMR)", 2064ee332e4c1b Marcel Holtmann 2017-10-30 52 &bda->bdaddr); 48f0ed1bb68589 Marcel Holtmann 2015-04-06 53 set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks); 48f0ed1bb68589 Marcel Holtmann 2015-04-06 54 } 48f0ed1bb68589 Marcel Holtmann 2015-04-06 55 48f0ed1bb68589 Marcel Holtmann 2015-04-06 56 kfree_skb(skb); 48f0ed1bb68589 Marcel Holtmann 2015-04-06 57 48f0ed1bb68589 Marcel Holtmann 2015-04-06 58 return 0; 48f0ed1bb68589 Marcel Holtmann 2015-04-06 59 } 48f0ed1bb68589 Marcel Holtmann 2015-04-06 60 EXPORT_SYMBOL_GPL(btintel_check_bdaddr); 48f0ed1bb68589 Marcel Holtmann 2015-04-06 61 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org --1yeeQ81UyVL57Vl7 Content-Type: application/gzip Content-Disposition: attachment; filename=".config.gz" Content-Transfer-Encoding: base64 H4sICE3IL18AAy5jb25maWcAlDxNd+Smsvv8ij6TTbJIrr/Gd3Le8QIhpCYtCQ2gdrc3Oo6n J9cnHnte277J/PtXBUgChJy8LCZWVVFCUN8U/f1336/I68vTl9uX+7vbh4dvq98Pj4fj7cvh 0+rz/cPhf1a5WDVCr1jO9c9AXN0/vv71r/vzD5er9z9/+Pnkp+Pd5WpzOD4eHlb06fHz/e+v MPr+6fG777+joil42VPab5lUXDS9Zjt99e73u7uffln9kB9+u799XP3y8zmwOX3/o/3rnTeM q76k9OrbAConVle/nJyfnAyIKh/hZ+fvT8x/I5+KNOWIPvHYr4nqiar7UmgxvcRD8KbiDfNQ olFadlQLqSYolx/7ayE3EyTreJVrXrNek6xivRJST1i9lozkwLwQ8A+QKBwK6/X9qjSL/7B6 Pry8fp1WMJNiw5oeFlDVrffihuueNdueSFgCXnN9dX4GXMbZ1i2Ht2um9Or+efX49IKMxzUT lFTDsrx7lwL3pPNXxnxWr0ilPfo12bJ+w2TDqr684d70fEwGmLM0qrqpSRqzu1kaIZYQF4AY F8Cblf/9Md7M7S0CnGFiAf1ZzoeItzleJBjmrCBdpc2+eis8gNdC6YbU7OrdD49Pj4cf301s 1TVJf6Laqy1vaRLXCsV3ff2xYx1LzOaaaLruDdb/QCqFUn3NaiH3PdGa0HWSe6dYxbMEX9KB KYn2j0h4lUHAhEH+qgkfQY2agMatnl9/e/72/HL4MqlJyRomOTUK2UqReZrro9RaXKcxvPmV UY364E1P5oBSsMS9ZIo1eXooXfuij5Bc1IQ3IUzxOj0cWcstwXf3tchZOKwQkrLcGQ7elBNW tUQqhkRpvjnLurJQZgMPj59WT5+jxZuspKAbJTp4kd35XHivMfvjkxgR/ZYavCUVz4lmfUWU 7umeVoltMLZxO9vrAW34sS1rtHoT2ddgP0n+a6d0gq4Wqu9anMsgN/r+y+H4nBKd9U3fwiiR c+oLeyMQw/MqpSAG6VOvebnGnTSfJ1WoFm71Z1MYuLWSsbrVwLUJ9G2Ab0XVNZrIfVqXLVVi lsN4KmD4sBC07f6lb5//WL3AdFa3MLXnl9uX59Xt3d3T6+PL/ePv09JoTjc9DOgJNTwC+UMZ M5sZIMdpZSpHTaQMTAZQpOaH7k9popU/DoEguxXZz4aFNLsFrq3i0yThYTSiOVfoknNfI/7B aphVk7RbqbnswEfve8BNL4SHnu1AoDyxVAGFGROBcCHMUCfBCdQM1OUsBdeS0LcRvYlB6sxf h/D7xi3e2D+8Td+MsiUCdeGbNXCNRH+MKzCAKMD68kJfnZ1M8skbvYGoomARzel54CM6iL1s NEXXYAyNGRjkWd395/Dp9eFwXH0+3L68Hg/PBuy+K4ENDNs1aXSfodEDvl1Tk7bXVdYXVafW npErpehazyC1pGRWrZicoOAZaRk99hv4X6AX1cbxS6yURdjPnBgVhMs+xEw+uVAw/ya/5rle JzhKvTjSwluep/bMYWXuR2gOWIBduTEfHjPL2ZbTlMF0eFA31NrUNJgslsdlbZF8G3i4xCAl 6GakIZoEZh2iKPCcYJZSb1szumkFSCXacgj1Pf9lRQ+jYsPY5wnODHYhZ2BvKbicPLUNaNC8 cLpCG7c1vlR6O22eSQ3crEv1QkGZRzE2AKLQGiAuoh6nBqDdTWo+eRhKm+cLb4JCoN9wyj8t PO1FC0af3zCMTMyuCVmTJr3pEbWCP7wFhRBAexGA1XSen17GNGBQKWtNgGSMWDSmpardwFwq onEy3kcYqXEPo1GewlR8V2LaNTgLDjFsIOCqZLpGt+Mil5TYGTGYRTbFGtSzCh27Cb/noUJg Fz1rY+1kU3uODSTf58iqArZLsnSEEC5QkiYjEEsWXfLDig6Sd++D8BHshre2rfC/WPGyIVXh ybX5VB9ggjgfoNbWTg7GmXvCyUXfySi8IPmWw4zdaqdWEfhlREruW+gN0u5rNYf0wZ6NULMs qLyab1kgWd5G+4mPNLFGkbIBxuFgfWGaGTBpqNk4TxUV++gzNVbOQJMbB7xYnieNjtUOmFIf B9QtPT25GDyoK+G0h+Pnp+OX28e7w4r99/AIURABJ0oxDoK4dQp6Qo7RPA0S1qHf1rA4giYj 4X/4xuGF29q+bvC43oeoqsvsmwNlRah1v1YpRZNcOyyTEPD/cpPOoCuSymKRe/g2kSYjOAkJ kYKLQMNBgEVHWnHIlSSYCJFWzJAQc1IIEVO7rdZdUUCMZGITs/YEPFhgSzWrjUPEkhgvOCUu 4fVyCVHwClQtFa2j6TXOMcgpw7rVQLz7cNmfe64Jnn0vZ0tpaNBzRiHn9aYpOt12ujduRV+9 Ozx8Pj/7CYuOfplqA862V13bBtU1CBLpxoa5M1xdewGx0cQagz3ZgBflNp28+vAWnuyuTi/T BIMY/Q2fgCxgN6btivRBwDUgrHwHXCE/ct6vL3I6HwK2iWcSs/E8jD1GM4SJHZq2XQpHINzp sQQaee2RAuQEVLFvS5CZuKajmLYhnU0eId+YCBoGYdSAMsYLWEmsF6y7ZrNAZ2Q6SWbnwzMm G1tCAd+qeFbFU1adahlswgLa5AFm6UjVrztw9lU242BESg2GDqZktGyJrDN1KM9WFeDzGZHV nmKlx/d2bWnTmwrMXKWuxuTH1aMVwW1A4ca1ZtSqtbHd7fHp7vD8/HRcvXz7ahNYLw1ybG4E jM/DwFDVqfwD1bZgRHeS2UjZkytR5QU3WdEUXTINnh+EZIGVlTAI4WTgJhHFdhq2A7c4EZV4 dGBusGjaKhUYk57U01CXdvgBgyogweVzyOgrAjvVc8kDX2aDfVFzMEQQj4OWod1jMuVk9yCk EItAfFt2zK9GtUSSLQ9jzgG2mLtswNlFfGwFru2wFgXyUGkXbU1Mt+k67PiyqEyTCjkH0iG3 HpnUFx8u1S7JH1FpxPs3EFqla9KIq+uFN10uMQSlhmC95vxv0G/jU9I34IJzhXqzMI/Nvxfg H9JwKjsl0uF6zQrwzWwhZqmveYMVZ7owEYc+zxd4V2SBb8nAEZe70zewfbWwPXQv+W5xkbec 0PM+fc5ikAtrh3HxwigIbdLhEiq0c4FvWBTZ4NdYJ2crTv/2SarTZZw1SBjpU9HuQ0uCcW8L NtoWElRXh2iQ/BBA63ZH1+XlRQwW2xACUQWvu9oY1ILUvNpfXfp4Y00gU66VF0lxApYNrXkf 5NlIv613MzvvB4FYtcWEnVUsWWPFeYCjs4vh1Ycc2IhDEP8NGDDbc+B6X/rnLiMX0D/SyTkC QrxG1Qzi2NQrupom4TdrInb+qcy6ZdY0ygjG6q7CwEnqoMSZ1zyxFI2JUBSG8BCjZKyEV5ym kXiCNEMNuUGMAEAg1Lh47aJQ1777cwAsqVasJDSSUtJQjtmUHWPDCC8T+/L0eP/ydAwOAryU b1CAxmStXzyxmdFI0lZpxzQjpXgOkAojfFLj88W1K8y4/GNh6uHi2WUAsV9wI0hzegmR+SKW i7bCf1gyUtECLEUWBFj8QzqpRGaSYX0N4sGuVWn7xikoIdioRRag6ctBFw8KvY3A0ykIOJPM HO4iFRU43OWFFzFta9VWEBedBxn3AD0rky8Z0Kfp2AN0QxQFZA1XJ3/Rk7CHw80hFOGWROJO W4IRsoYcmVMVxU4FaDOwAP0jicTAHKMuo40JHA698XzWs3e8QsGqhugQD0A7NvWZmJkiZyd+ cZga4T0rBN/c6vgT0adA9igUFoxk18bJOxKhXGEsVw8znkgtgwWhsYfQeAxzfXV54QmiljK5 o2Zx5mULj6WCvDdyjzVv4wlb9ddqZ9YWxWBZBSPS5g0H79GFjSys4EHdtOAgN12WfKliFHP2 lGLc9KcnJz4jgJy9P0lr2E1/frKIAj4nyTdcnU5KsGE75sUOVBK17vPO7whq13vFIelHNZCo SKdOj7xszdSEUMhTWjiMJxUvGxh/Fg135YttrtL9LbTOTb0ARDBVRIa94MW+r3IdVE4HK/5G Hhvoo1XSQbrXIO3VrDbiaKzJadFpaP/EsH3683Bcgce4/f3w5fD4Yt5GaMtXT1+xfc3LnF3V wCsxuTLCdAQWIdSGt6aq6+1M3auKsUD0AYZyaeCpzaj7a7JhprciYDRCXdOXJyMBtgzeH7CY VUtxLvkWz3DyxbQUaLCXbL4gw8fN2eZmQradZIFjeJgzQFzcNUFpFWSk1x9tFNCbPMmEMi6I Wiq6jzUZ3GVPWGZPg6U2SgJrLMSmayPpqsE4a9e7hENav/pmIK7SaidpAhvlFSQnE4q0ZtlK tmBkDbeWyn5Jay1FLF12XhBBFMrOYmmkZNtebJmUPGep0hjSMBq0EvkokgpHDSYjGhziPmKV dVqDz/oSAE0/hF2rf4Z350tX5x8Cui18g4jGFqSJpqBJHkFyaxp8kEmzJAM588tO46ra5MiG rItons9WckT6YbPB8DaZW0QsSVlKkE9tGAQftYawFFYkhNJOQZbc5wpMbsEr/zB5rOK6NUFz 2bWlJHk857dwUS3NzpaiPIq5oMPfmoB/eEvSs9Q5nkFh70Ly6yANXIt89raslOlY3ol93qG1 w9OUayIxlqj2KSc8KjlpmWcqQnh4MOuTR9qCtOWapUP+iYTx5teldbAEWAePFj9vdTEmR/6I eUcfyBoezIMoBe2O2U7313QJS8Hm5di9NyOYbTP8XaQ20oa7Y8Y9hVlFSvZNpgrkGNF6nwTO zFceIABjAJmoqcgM7im9wOj7hAsOUuvb2vpKpLg4ikMoQfZ9VpEm8ESIxDOAa4w5g08eWu1W xfHwv6+Hx7tvq+e72webVE8hk7MzyUPS9OiRMf/0cPAa7aeJB9xNzbgU274ieb6gewFdzZpu oeAz0mgmFt8z1KeT2mRRQy3bj//GLxpTKxPEx2R/H7qZ9clenwfA6gewSKvDy93PP3rlDDBS pcBUKoiDDLSu7eNCJwWS5Fyyhc5ES0CalDVBXOqdtMnOTmD5PnZ84SAazwWzLqVT7sQQS0NB 8UGlutYVxaA+POdAyFpapUyrTcXTRd+G6ffvT05TmgQhd+Mdn5lscK+KoONwYY/s/t0/3h6/ rdiX14fbKCJ3WYgp8E28ZvShpQZHgaerwmak5hXF/fHLn7fHwyo/3v83aG9gee6bGHiMs1KH KbisjfeAZMRyHgcV1z0tXPNBYmQpRFmxkYE/0qGwuGZ6sGaBn5k9pK2rH9hfL4fH5/vfHg7T 13DsnPh8e3f4caVev359Or54Hwa57pZINTlShDDlH5MPNBD5aFvfSyPiptqQg8RzphoWxq8A IKKABGVaLg9Rk92InM7PfV7XkrRt0PuBWFyjSmDjqQkwpKiCvQMKSlrV4dmqoUq30HhkRgnh XwL/UpXqqERqHRzQmWlSfmY3K4S79TGKPhzBOqn9/2ziwLIzc219Lz+CwiYLs7futDmueLjY SWFkiOE/OLe599KH34+3q8/DpD4ZPfF7axcIBvRMwwKd3Gy9rBRPHjswNDckvIGBh6EQ0Ui/ jQWD1u3u/elZAFJrcto3PIadvb+MobolECpcRbeubo93/7l/OdxhxeGnT4ev8A3oXmYFAVt5 CRu2THEmgplvFLadxgMPEAwZ46OHTdwv8GtXt+C3MxYc9poqJ4WX7hUWJ4uFK16i1TE/M6cp Z+4aU+nBplaKCUaU5uJZFt76gvSrz/CSkTdTPPdPMeewBtjtkmgJmX2dhS5xWpq+Y4P34YpU L2jRNbavyEhN+lbPloUR+3QNyXBcQ9IfIdHDonnhZSe6xL0UBRtlIiB7TSdaSdMtA7k/lr9c W++cQLGhyLyAtEFHaFK9mduLhbavqr9ec236xSJe2OWi+nzfEPSH5haFHRHRnZ9lXKPX62e3 tVSNlTx3STDeHcgJQDuxCobNKk6uXGwS0NkWx+TG4YXGxYHr6z6DD7U92hGu5juQ5QmtzHQi IpMlgNB1sukbAVsStIfGDZMJOcGUEUtspv3c9uKYESkmifcP7ZHSLVFYw532M9D9N7CJ3tS6 7vqSYEnAJe9Yq0yi8S5IisTJndUTez3DnVTHk3EGxIkdHuREFG6cvVq6gMtFt9CQxVva21tu w2XVxGK4Kr1rSEtS4FJXIBcRctZSNRh513YVoIfbWZMZTo6NBsHKiGa2bOYDuV6DabViYJqM ZtY0ecEqEHmBIuUfqQe2rMGzLTT12NCW2By7z4DDZt24zGk2wCCxgg6+dObewA4MR2iMYjup J2Qi77CAik4EW9OlL8ejWTMYc4QUtBhOcwtaMGNHtgMTlbS34agPocyJdj8YS135N7ltihXa HFph51wGOwRheu5RC7wMzUtXbjifIUjkdMasBe0q7mnKyGtwJXq4Jiyvd75QLaLi4Xblk8NT qGmtW9ij87PhkCg07mNAAB4q5eHRIPot2vFQ1/Tes4bKfTteRSyp2P702+3z4dPqD9sR/vX4 9Pn+IWg9QCL35QmuBjsEVeGF0jlm6ll+48XByuCvDuABE2+SPc9/EzUOrCSsPd6Z8DXcXCxQ 2CM/dX44rYnVyN4BNgmMHwg6ZNcgIt1FMDnqJTxyUJKOl/6rdMPGQLlQFnFolHIJjvstGlsu q7lSYM6m21g9r80JTXJo14DsgV7t60xUaRKQ8Hqg2+DNjfQJpDFKGpzd7Ggnq4JjALygpajC UvHHsBtzuLqVqfC66wRO332frnxpVkquk7fBHKrXpydzNLbx5iF4OHM1TlKGuOtMzwB9/THm i73MhUpDU6/EFRYtqeKPtz+YMag4D0/n7bnr7fHlHjVjpb99ddc0HQOYv+Y2/HMnkcmyEhjW idRTE5ULlUJgruuDpzpiNBX/A+uPmKyHHw0wzFH9S0kOHF6QRKA5brW/VSCm+6deDgmjuLAd xjn4ofB3RjzkZp/5ezqAs+Kj/ynhS6ZEtzn1SgSN2x3VQsiBFoPGLfTTEaktlsn6+mpu/81P QuSGTXQ2HZPI6xQBmmyIo1zRoW3RBpA8R6PRGzuQcmzDFak+Y8VQ6Q9/KMGjNZ0FQ7FoopjO 62397K/D3evLLVZd8KduVqaD7MXbo4w3Ra0xQvGkqSrCJN8RKSp5Gxx4OQRYudQBKTJxcf9U C1qYkJltffjydPy2qqey97xRIdmmNNUjXQdUTZqOJO8ujl1QlsQLHgZMHP3ZV7XmlzF0gt5V KuI8D38aovQtr2PElaii8o9r4DDNG7Yn8iIalKE7CetbDmRDLhobIj8ei2I004YmGWpBEGmD 1ZEkDuewFtBH1z+wg8ZIc6/7y4vM/5WMDKIiX7htV77AiNOf+0almqmGUquJa+3PXuTy6uLk l7EFeCHW97zjHA+zv47Kfm9R1/bC5fQJwf2cTXDFnUKu1ZgG6tTSh/dQ4HGx6WTE+f4JgXij SE1t2TetEIG432RdyoHcnBcQn0817Rtl7yj6JeMBZqQ3Vbp3JR9TWh0KXp6RzocbeFhL2gSC ZG+SbKOEEZbQdCi738EYXoOX3sGXrmvi/7oUgkuGOmFa9UyjoP/hJq/Bw2zIcVpz5zp5/jDa S+Rjsjdf42tnmHMQ0n2/ZpUru4/GatkeTcLhW4RNZq/7DCUjY9Saw8ufT8c/IOT2rJkXENAN S60/uDIvfcEnsL+B9BlYzknyDmOl/M2Gx+WfLECkFn4TZuFfLscn0KEyOAo1QPRPqQNtxKku 6/HKVNCTjQhrZaK3JVtaDYK3aMJ8bcT0cO9/nAMNnFNGv6aTMsCDWbUJsstb81MKzBdMDxiR 82DTeWvv0VOiQujYaiZFF9RrOJZwMozkWT/7VZiB3f9x9iTLjeNK/oqiDxPvHXpKoixbOvQB AkkJZYKkCUqm68JwlV3djueyK2zXW/5+kAAXJJiQZuZQ3VZmYiHW3FFmXWI10hha2ko7Ulbv Ue0WpzmPbeEeZAOGZ0xLJTHClHnp/27jPZ8CjePtBFqxypskUYoJZGfsafLQjINpEW19yJHc O9D7E20r2VZaFIQRpwdHdt9ZSOneZgPGH3B3MM+Meymkku1xgUfAAiO3Xs3N6Q4U14KsyX7K sRb4kw/xMBRohNLi4A+EBo0DR8uKsFBbRofMGZwWSamvtJ3D+84AzY70p8pgSKDZNh4dLykw fDcBrtgtBQaQXkegcnROF6ha/7kbNh6B2qKMQz2UH2j4rW7itiiQlXxA7vVf1GE64FXt7p4R frfNGAE/JjvmWKwHeH4kiIH5xybYAZUh+7xTfU57Mw8Ud0lgqQwUItOyVSECiomeKuZnRobH O+I7t1vkLdjzgnpmyOZ6vJm7E7xkP9yTgpU3IB6679cfv/31n6/P97+5/ZXxSuF0MXorh8I2 vcHAmPb6APktwbQZOCUg6SZo/jF7lBvWqOxO8vQOYUwRzaMb/au+YGTppRTRNNaGQHZsW55A 6hMn5oEvAn9wXtO4isy9pI9bxJPCby3x6P0NJwK9zIDEaF6o2TPY7rYeHXtqStjIIn2NOVTw u2fCyZYNwXFJsRfuhbhDN+G2ErFrjrC/W7GTerDyovCnpsMfM5Z3dh4vjNmnlBUZtmFsWnBU KubNPICIEqbF9TxaOHqzEdbujhU6VxyUPFb0VMUJz0nWNstQuKH+SQe/spplZBxPtBo7mbHS 8cAq9wVwZyOvliQJdHOFgptHaJtn3R8mbZLeMHlN6g2cIpYrdMUIPjThjHOfh8xw+ze/Hn89 ahHgU6fCQpr/jrrl2xv/lgfwvqajdgZ8Ggg07wnKSlCbpUcbvufGXyaAqUj1ZI+1fm4T4M0U WCc3GQHdplMg36opUJ9XmB8yxRl8F9Xt3el+x2p6mAJc/z+R03biqprSyhvTODFbWgg8M958 X1wn0ypvUnL2ITiSWpA9Pr2xJGRZdk0m9RyKksttT0emDatJ0MGaAz470CfWOJshjtgM9zSF UH8np3RiqBE9HawJkcKVeFh99aWFUd2N89Pjug7+8dvP70/fX9vv9+8fv3Veys/37+9P35++ eUnBoQTPvPWsAWATExyvNADXXORx0kwRRj65mNaT3k5hBxQSbgGe40YP7bYBmiDTnDpSl4qL vpx2Ms1MyuFJbcEckMNolCldW1L56xMwEvz8Q/Y7I9UYiiAa6mBksP+wL/QiQOuPU3auOAfH G1VAInG3n1vNbzBj3yG91ZL8qG6F7uA4Hw6w3bm+qMeJVuJIqyQGcKZZCjDjo7vaOu8eJRcD IcUBGLsP1SZGTMRqPWxaLrj2JDVZ+isfIO1OFZjGLG6kPgTa3M1KuleVdyybsYqTIy6ULfXi UBCfjFA3Ve2Uh18grnoQuRe4jZwr5GkOv9sikWCKNKpJSQaFddk4DYPuXU8OqtPABNZg1YC+ HGLBXDv/9gabIsu0/RyI4zdZ++oqYbIzmE5MlJ1Scvbx+P7hxWqYrl/Xu4ROn2JYyKrQUlCh RZfCExM6xemkeg/hKkNHnlVWLDZD1llRv/3j8WNW3T88vYLbwsfrt9dnpDtlmhGkpoA5k6t/ gBoBA7ZcYsDu1t3BAPm82Cw300AXls/ix38+fXPd6VG5Iw+knTHI5hRWZaewekmfwIEZ2yp4 6ZTcRMeHdeWwy1vIEZjEroFdL8cUdjw64npgW9dUAAhUkyelVwRAreTtVLz0aMDnppi4uWns XsQl6uwe6U41IKN5E4MhRVBwFVCpebMD10SIgiOy90dGvevzzPQBazbC4/nX48fr68dfswc7 /A9+GMa27rLLoFlwVygMd43xey629UFtvSHuwTbmehojRlBuucRj3COkm5nVRVR15o2VQalY 0BomS3BgFXXndqW5jObLhviaki3mTbhcascAAeM6W1DjsqTO6w6ZHRLOqtiv6qj/IZisjtkE 0MKnIyir98trTFdfd1RjME9oaTgnXKovg6oko4/T9tqdOnTej+BbUSWZdXofj4x0BwLrYnq8 9YiXx8eH99nH6+zro+4tWOsfwFI/60TdhePj0UHAkgGWtr2JcDGpFOdjHyAL5A/0szuzTCLA 0XWxSq9F5gyw/W32LrL+WbDIywN9AXYEuzIoiG0848SmnDi+dGDj+OLxoRsiJ7dzIgsyw3dS 7ttMoC3bw8C7QB+lQftwTwZ+J4jvdBmUNPAEimKazwrLbCKlcdmtVepTrC+kpwSzt6P2gmRg SebzfCZDuVSucZiJrPBY5qTe10WR9ZxkSKGVdDxPf7ZObmJELLDqK6FDBbvUou5LCt6P7pET P5rR+E94sYoIz1RJ6R0B1Za19KrTg0QFBwPGRGpNgimDCSy4TfQybiKAMJwUGZIdMIkh4HwC JwWRDR3QoqDkGcBoPtcnLhnN3Zp2PGd/m9mkG/ahFgdsnVho2d8lM+GxxAy7NaHJ9THtl3q1 Ws2D3TAxr8GUey6p2pd84GO5mH17ffl4e32G5xkm9z/Qp7X+r02040DhMaSJtDUgJi9omJXV QFbjZtwh709/vtxCcBp0g7/qP8ZwyeEmOkVmHbNev+pePz0D+jFYzQkqe73cPzxC9jKDHocE XooZ63I/hrM4yXli8p+ajw5uNkyaeArpngk+2/7gNknP2TCfycvDz9enlw88i5rZ8uJ1XOiQ McDfLIk+1fzgNtSTobWh/fd/PX18++vsslK3nahcJ9zlPE5XMdaAWaKSSy6Y/9u4a7ccp5WF gt7Z2PX992/3bw+zr29PD3+6mXvvQO8+Vm1+toWjybIQvd4L5AdkwTWdj7ND2pR19NKJL6+i DbGZxTqabyL3W+GTwKXTd/arWCkQ+9cBICDWPgJVHOo/lm56qo6gy96kpf26acNO4UN9kuki OzoJ8UCEk2WMTR2kr3XsceB6lU/Bxk295aBJ+dE9DXT/8+kBvHDtynmYCsB92VqJ1RXFtQ9t lqptmmmjUPByTfRR0+vzLppiqsZglu7yDnR0jIN9+tYxDbPC9y892OgO6ww2DiQCt8bjxn28 7ljLEm/sHtZKiBMhJ1avpDxmEHlDr83KtjlE35unCSdbaog+fn7Vx9vb+CXpbRcK7vBePch4 7sXwDtGI1CJwxcZQ/fHzxlImns8fGhKt2bws8xWRIyUVQDES9azlNMK6+8ZBkmAmJdYRexr3 ApIJwHCxAcOA0Z1U4hgweQ/KlSqQ0MYSmKxhthrNnkPAGmWfBiJmHL07UvuG37Csh6T2kE5e y/CBJ/4AfTxkkMV9qy/8WrjBNFWyQ66a9ncrInfzW5jKhATX3AncDQ7rYFK6wlFfqfsoX1+Y 8+2kRrF0WoejzATamSWYuqsJUKm5yfuoZxyMNN26QyIUK0W78QdFUyP/TAGCEKTm2brBzXIv Bv9kJ2dHX90ghBVaGvJcWquCT54c2eVuiLmscSxTHU+9PbygkZ/3b+/ewQrFWHVlYjzIiB+N d0JksEshIIt0WhYR6LkwaTgIqkkoSd9B08OD/lNzfhCWYV81qd/uX95tepJZdv8fHBGiW9pm 13oz4SEaopLGs6ImjZ6pqweDX23l2MCEwY/rMY1bVEAp9IKEki2iNwNVlF7XhgQhaLyGaBu9 hq3RYTKjFZOfqkJ+Sp/v3zWj9dfTzymXZiYOZ+oE0OckTrjZ+4HJ1gfB8PwnKqkrA9OTeY/K C4dzqGBHbll+3ZrX1NoF/mIPG53EXmAstC8WBCyiemoUn/riCS1p+BgZq9rhQnu4vj3ZtJlD LbwJrVw51wAKD8C2JrDDZSDCM2fFofufP8GE0QGNasxQ3X+D5J7e9BZw6jS9t/lka0I0hWSU gRSwNnER5O5LM6b2eBw8mdmCgCkPVGZzTR0hxLvyatJikx2pUZo785H2UcLH5++/gwxx//Ty +DDTVQX13KYZyVerxWQvGSi8/ZIGUjA5VCG9B5DAkz92mLxRGRDtbSWsb7RIKcsFJraezqgm yfdltLyOVuSDajBhqo5Wmf+JKtOjGyhR7mHk0XTofz4MUh3XRQ15b0G56kbFdFjNDKjuFZtF tMbtm/M1gunxT6n46f0fvxcvv3OY2rBtywxMwXdL8m44vwzQGZtr0SeP/THqwN3k2JkKDFlP 2utAflBIYvZ6VNTA6bkLz4mhSjgHEXrPNOuD3fQCJBBbEL5h2a0pEyTQTNeEwExBVsZxNfsv +/9IC9Fy9sNGphAyGNRkC1ATdb4qok++kdfBH7aUyg0w5rkYxFvGbrbbAr1zqdkTcIQNpfhJ TVxfjXJ3aOB1sf2MAF3CFwTroi4RDHGt+jcK6CjSXr2OYF36qBHm58i1KTzwY1w94IcHaLHf aw/V8pMgvQ/HYhPnFAelDuZ9Z1qaHMmCV0RPw5r1+mpzOe21PlYuJh8H6WXa0tVDuqEkJo7E CEhSz4KWOoe4qNIx6Y/EOFVxFxE+AbT5Icvgh2Nj8zBt/878JDFST5k6XAWPLVvgjpeIqeOn Lw1aR6XgqBblMmoat/AX72AZTZFd4YP3SIGHBi+eaX8BasIi7TPX62m11i8a6E5UHldbJzQC fhFDNak639IHV49XzfpEm+gyc4Ddp4wPxLm4yT1nJgl8U3h8dF9XccGdQKnc4cEEt6GATXgv EHY5mKPc3dn5P21JX+Shw9uY+ELVNNN5rPJtTENbngnLilJI83BB1Wvj8qNMpqkPAeplaBtm UKMc2QkI3fCx0SYImP2tJOOJDTJl2wpF6hloZydFhNyjgZAYTFKzaueevg6w3wa4Zx0OWqNN mg5RStlpXAIbojN6J7ljajn9p/dvU8WClhdUUUFqerXMjvMIsTIsXkWrpo3LgrrL4oOUd/gC ElsJ6cbQhbBneU0+OFGLVLYcZaw0oKumWThu71xtlpG6mCNeO8l5VihwUYGl5PsK9ZtFrVbL VSvTXeksRBc6eMTCV1x5FNxJkaMqdMvty1ZklD2elbHarOcRw0GrQmXRZj6nIi4sKpq75P2k 1Bq3WlFPTfQU2/3i6mruqAU6uOnHZo7cUPaSXy5XdHxCrBaXaxrV+Vx2MfqkJXSvZ9k10wKH o+dEs5TlkrDBKppZRRYm45LkdN4aA1sVpwm1EyBtQ1vVylHEl8eS5QKFZ/AIbvkJU5okmoOW jumuX2QGrg/T6AKtvQG8Igesw9tnCYi+dnjJmsv11cpJ12rhmyVv3JygPbRpLi6RF4BFiLhu 15t9mSjKStERJcliPr9w9QLeNw9Lf3u1mLf+M1EWGnTpGLF686uDLGs3aLx+/Pf9+0y8vH+8 /fphHgx+/+v+TYtWH6Bdg9Znz1rUmj3o8+npJ/zpygA1qEdI/v//US916HXKZNMme/54fLuf peWOOTlSX//1Asr62Q+jGZz9DfJ7P7096rYj/nfkxAlefuZNo5KMuzEqC5k4blgDqJVowEd4 3dAmlZFiH5Mxio6rdP95kKP2eaalCi01vT0+33/owZos+qPmzJBOWQPchXOqkmHV8b3rGg17 k2Ucsi56Wp5+1wLi1K5ukW/cnm1ZzlrmDOQB0k8ilY97240FIUWfm4UGfnSjUz4/3r8/6uYf Z/HrN7OkjOb309PDI/z777f3D6M5+uvx+eenp5fvr7PXlxlw1kbedO5UeJij0ZxbizPeALgW slOcOUDNrRGSgkEpjcPEO3RDWwjUQC24ARmonqspfwZg1ARC9KH4Nlcr6VI6kut2k0BNvoML +iCT5FQUvKYDI8y7J2CuSKemB5gO0OxpQL8qP3399ef3p3/7EzTRtwzSUPdCLdVzLuPLC/pZ KOfjtOx3emCM0ShNXbcap+Pv003pVo63UI8p0nRbsIp0ke1Ixi+eltZH9mVEPyM6MO5fAs9e eR82ScQFOJbwy8g1kw+ITCxWzZLqFJPx1UVDesz2FLUQTRmcqFNF60qkWUJ0CJg/zI25mOWp AbB8I13l8pKqcl/Wy0s63Lon+WzeFaT4rkFe5Qt4ImC6kPXgEPu7Xi+uIhIeLch5MJhTY5mr 9dXFYkWVLWMezfXEQ5LNUxqInixPbqlq1PH2+tRho4SQkD+JKir06C8oznugyPhmnlxeTsek rqTmzafwo2DriDfUeq75+pLP5wvyYLV556y1gSvRK5Yn291kMZSFI1pXTMBBXldIrDCVkEps onaHTyFvC0lI8hJbfGNjyLc5lGk9amzen2cBLWtsvoPaQh3KtbZ1kPkEdLG6RLBR9P/hQI1c 5yZstK4YP/Bv38uog3bCpZq+kNYRWMcHeE9H1bpPJ/dnLPuk7NMBjpGmLpZBJttUkrpuCz2x NYhADji9Ayrj++qp+D1Km74YfBLod8WhKVGAL6xydY0aDEml9Aeb19sQYxJDIk9IWVsmsdey UeTRraiclWpfOLK5BpoMy/p6PwpIPTX9konKy0UaQ0tIKabxyVZ51WmGnSY1eYTdzRZDwifg ekKNw9qk6/qSVAX6SCLZkQttbzK/5QFFmhUQxV7hEY0TUPbj+uJDqB6Ru0nwYGKNBgSB0ozZ xFUjCCxd7nYbQL0NrCqK2gRV2HwjE7LUfSwTFoeNLHXbgMeRzQwrBB6zs+JvNIlQKb2TVZhh 1WLNdUVeQlmAQSpid9cBDJzDnBtUmOPa1/6lB5z83P62ISU7a9bEGP11O7vcLSebJMlssdxc zP6WamnzVv/7O+VdnIoqgcgYyv+sQ7V5oe6QDHeq7uEMhfMBPE47/y7Xl4RxeHBbFnoktrXj cZkndRe656hBx7EeT9Eij0PZQIxakcTAt+wOHpM76kNuzHMkAdc3k7EpCdgy9PdAFhBa2iiD qGMTwgCrfQzE72mpPJQRZhdIOaP7p5JgYgz9lyoCUTEVuPXQd3V9oPuu4e3RTFpVKBUKQzwm NR2X3pkYQq3mmaeNH7mSys+x0hv1P96evv4CPUPnBcucFN7IbtzHAPwviwzqCnhZARlO4fP1 qRcXVbvknjXNuoov+erqgjZPDgTrDT1CRVUntHNIfVfuaSWr0yMWs7JOkGKzA5l3hFP6MHAr 0HwC2o5JvViSHL5bKGPc3K7IwqIywQvS+RUVrRP/2cEkF/SC7pRotTr3EZJ98UL3RxR+XFLG 68Vi0YZWbAnrbkkrv7vJzCUPbXV4OK3Zkd5tbpf04ZTXgtH9rTgNh3WJ355jdRZKMJTR4jsg 6C0MmNAcnFsMB80HoZg0C2nz7XpNKgmcwjbjId5V2wt6M225hLM0kBsgb+jB4KHFVYtdkS+D ldGb0j4N7FsO3IKhDBzjB3P7EqtTiGI7nTJdEBASvxiZvAMVOoqDJNeSZokz5SVxsKC2phfO gKbHa0DTEzeij1QEqdszzT+hfvlHA1HE5HtG62+XSM25Dkc53acGYgVpXEzn93IajfGRa1NF ZiKUDqYvBVGgSObIIvrBSHXIY0j2eLo+zXaB2spdSkl0tu/JF74XyABtIW1eqk5yhHRhrb/V pjWlh8+iVgfiRkzl8fNifebgsE8lkit0f2C3iSBRYh2tXPcDF2XyDbgftiDPHwDPfbp5wLay o7OUafiRTiglmlAR/2oYMRfB1umz67M8szQkq45JhgZDHmUolYG63tHtq+u76ExDuhWWF2gV yqy5aAN5VjRuZUSAEFbdnkSnt2f6I3iFF8G1Wq9X9LFmUbpa2rhwrb6s1xchg5TXaDHZVTmP 1p8vaQuBRjbRhcbSaD2kVxfLM/vHtKoSic1oivO24ElW9PmEzlRyh8Oc4fdiHlgOacKy/Eyv clb7fepAtAyg1st1dIZLgBR2lefBpaLAYj42uzObQ/9ZFXkh6bMnx30XmqNL/m/n4nq5mROH ImuCglASXfurzC9dBrJOuj0/iligm9C8PBR7zO60YHHthbrv29BRBc+1n7mRbe73LqgTcax7 zajrbUJWfJdAYFsqzgg8ZZIreHKMnLqbrNhhL4+bjC2bhublbrIgb6jrbJK8DaFvgokY+44c wMYtEVt7w9mVvmbA95iulINzhpd+axTe5dnpr2L06dXl/OLMvqoSkLDwk+gBtcN6sdwEEuQC qi7ozVitF5dUIDLqhF4lTJETWkFuNpQOxEJO16iY1AwUdjOCu9eX+oiSSXJDdgQeN6lS/Q9x 4SqQm0TDIVKUn5PeldAHPaqQb6L5knqTG5VCm0r/3ASuEY1abM6sAaVvDOKwUpJvFro39CFQ Cr4Itanr2ywWAfEJkBfnjntVcFBVNbQSRtXm4kNDUEujhjw7vYccH0dleScTRt/+sIQSWkfI Ic1dHrjQxOFMJ+7yotRyJBIEbnnbZDs6955Ttk72hxqd1RZyphQuASk/NJcFqbRVIK1o7Wk4 pnUe8UWjf7bVXgRivgF7hIcJ/4exK2mT2+bRf8XHmUMm2qU65KCipCq5tdCiqkrdl3o6cU/i Z7zksfv7xvn3Q5CURFKgeg5eCi+4igsIgkCN+lXTsr3VT1L5tqSVlPstdg24hSF8S9mwOBFZ 0ipLwnyq3Suv4mka3tdvfqCpHnAdIQABxR+qVkWBjyUuUTo2C+GE6GgbYaxSnHSacLUio6yV Oj9aUe7WpEKABtH4cIgdxsjUOuquAMXpDD8bg9s16XhxvlRYUgDEz+f4JwHwgZ8QHUo8gCnE HXC4MVLe3jI/xntvxfHlD3CQ0DOHYAE4/+OS9gA+M3y/BKymZ3wlu1m7xewE7X5DfQAC+6on buVGj2GmoTxcG7q9gHE03siqaKat7g5JhzSdH4LOKiAEms/3DmhgtXHwA886uWOcDjVr4+iN NqyHaAwEf/7OPtVPhAg85EoVhGGLUIaBrMYB3WmjTh8d/E+PhS5z6ZBQT5edqVNTy9iQP5Kt pd3tU5tP7+Dq8PPLjx/vjt+/PX/8/fnrR+2JgTZo4dqzDiLPg9tTaxFStzZvZqjlh+5Uml97 ZHHR0Cp/KBuHvmblyscsGaogxNcLjbHlXNF7h1mgxkdIEAdvcuXjpoMQpqJKgwhfqfQS8yzw 364/GQIPX/Q1rvON1bhkdG3hkItriZW68O7wNyLvi10ZwzYx+9jDq8cKx8se4zh/be/UevKk 7KH//ter0whLuGTUbG/hp3Tf+MWkVRWENhSeKS0EvB5Lr0MGWYZbfADPJhbS5uNQTwpZfFJ8 hlnw6evry/f/fjYe76hEcA2PFDPTwW3iZbJbsqCM7/383Dv95ntBtM/z+FuaaI/RJNP7/tFy 6GvA5RWpWnkFs6ov+mdweUCUCR7KR2HeurZipvC5YJi0anQaxxn2lM9iOay1WxFK+QelNQaN D0fjfnFBPoy+5xAvDJ4Uk1k1jsBPPKTgQrkmH5IsRuDm4UF/uLfQwXOogywGaIklGkmeRH6C dizHssjf7Vg5jrFKtlkYhGi2AIWYnaaW65SG8QFN3RJMHFphOviBj6bsytvoMElYeMCtPWio d8uYVRBIX/dNUdXsPDvY2XKwsb/lN9NMawUv3YPjzaqWQUsxFejaBL6oRNiXboP72F/I2bDo WuBpxEcVqKHvJcGQnPr+hH186QnaWj7EGoOv7vPyAsEUsQerkkGEuNMWavlbSNU5KUmu1V6H agoClx6xaQVPI3FEGFt5znnHxRA0YOXK9HDkP9Dy1Vllg8l381zC4cJytO0t8aXkarzTZ44g xkNbR9aDS0Ey3WkBRa58miISaC12+yygygs1U2VFEU3prYyDQj2+svl939D4SRou4EgQtcRX UGTnHm8p8Wxod37+/lE89Kp/7d+BCGC8jh104z/ET4LFIX7e68yLApvI/zY9KkgyGbOApL7x hhPoXEaQM289UEs6qSnDLugkzI/4HLYLkWEDrJyUpY2Vm10cC8CydIeDd4qdh4lTUaNN8XID QhNerKFzytvS7LuZcu8Y38ERehMhxLK9+N6DsQ0sWNVmnnVjqA4m2ABZX8MhIqQ8+vz1/P35 j1dwRmq/uR6FoewqP7ti5h6yOx0ftRObfFLqJCoXBEG8uBlohOdOMNoHb4XziGcv3z89f966 NVJrjwiTTIyg3hLIgthDifeipAOYVpTF7K0L55P+NIyBMEN+Esdefr/mnNQ5vLvp/BUc/7Fd QWci0jTSURn9oZIOlFM+uKpJ3q5ZyyXlFjXV0bm64X4R7u0iDB34h6zbcmFBCxIBmosSlwx0 xpxRiPx9dQQuML7kDfy6Oxpf3N4sahiDDDUC0ZkayhwDpK0LpHBw+ade5W0Ocd23r79AUk4R o1o8/EXspFVWXIYMndcYOovjMkOyQEc2uE8nxWFal2tEbUzaub5n+DlYwayuaodRseJowMYQ 9y4+50FINzn0tTOHn9Qsdag5FRMfm8dyKHKHcbDiUhvM+zE/2SPPwfoWW11NyeQwr1AscJH9 VjZKvU/Zm5x8c9uDB+reOzlcMf5N6FtlCK66g+eIb7ESuCITnmLrU034oo7rReaBzBeiJz/E vRTMn5va5vSLHzRjk7BGckvGQQalQMaxdC3dFS5L/eU4ZIXcWTU295NjKnT9U++yKgFvSa4c hQdWPoM6h+2drDioOlxxEHjOoELuRmzPEYAZCKKh80zH+KlUimi3ZcJq3p2ipm0NZ46iMeOv c6rwE2++x5J0cH9xt17vaAi81+qs2L9tra6QpHa9ylF7RMHHjCOCJLHaYR8H6A1i2RU9fscg 6wWB8voKMxjl+HFTNc0lwI3LuF3RtwhJeC7n8mRbougcsWi9Q1igvMVsPlb8VPYFVglxU4qS RVgWtCzCZxR6nARVVE164+jM+u7RvCVUD8mFO7Q/ENFzTfrYEaFIckgy4Bwegv5F+GPvFY5M lzVkCCJ8z6jpfGmFLjTOSmv3k7cc9UGtPIqaGi5KsjRMfs6L07w6cDnYXq74cMKdl3HgAUaL 5srJ8L0qgrmLK4aVBjccgg4OgUEE14txGo+fqePCkE/1EzmX8FATRi+mZiD8D8UHPNUqK/hq ZntaktQN4W4oPTXinQxmPJEZqwMib/5cdVQ8fIerO3gH8gXPo7tce5ciDvg6VKcBiLx3NCrt KowMmFwOyJV3Grw7nR6R5o9h+ESDyI0oHcqmYQvO0IAufOUhtrtoLpw0j5tdaI77sTNL5o8/ XNh4Bw/Y0kP99tojIMhth64Dgs8hVHa8G40ZA4AIYYMPWgGfeTr8PoCj7WWa1f7tvz6/fvr7 88tP3hiokvDaitWLC2FHqS0QwVLL7lSaVeWZWmvASpUFWuRmJFHoJVuAkvwQR74L+IkAdQei 0BYYSiNyO5CLUkvh7iAweSa0KfQXm7udZZaiohbAod9RBlOO8pfRkH/+89v3T69/fflhdXxz 6o/1aLcDyJSgu/SC5sZ7U7OMpdxFswJO6tdPr/ayd7yenP7Xtx+vu+FhZKG1L31vWDXl5AR1 uzajwveITmyLNE42GQnqnUVZhimsFAs8M9vkdm9pYBLrzLPYakbOdpE1a7HDOkDg2SMyc+iE 2W+AEnm1D9mmb6TlMJ8iF+dcFr4zDlhgUoUmoWdnC6aJiUMQ4PC1dtw0S4wvwJv1SvgKQr86 I22tj+Mf//x4ffny7ncIeaBcff/HFz58Pv/z7uXL7y8fP758fPer4vrl29dfwOHOf5pZEj41 kMWkKFl96oRHLXMftUDW5LqzXQvFXAtZLMf8ERxKODwfWdk5rMeBrTwFnnuRLtvy6hrHqvEG v1h9ddeqPSaRAOdD2c5Ll0btXZdnYjST3NkzdEIdW3FkeAitlZ3V7RwcSqPKs/5mUJU/+Sb6 lR9wOc+vcqF5/vj896uxwJgdX/dgMHMJMDFEMDSdNf82PpNFxftjP1aXp6d7z49LdnXHHO7V rphUKuC6ezSdocmJAw6qexniStS7f/1L7hSqbdqUsMa7vMe7ywCJpkQvhGvr0aFR2crhfsa5 thufy4jsJyjbySNIyovhdtaATxPnw6GVBXakN1hc8pYuKy310uO/EIhhySkqcobmmOKGkmU4 mrWTqTv8IWAquZXCOrVIpT5fJNvnHzCAybpZbswpILlUtmnaSaBNtfhXvuAwMS4CHHPLth7I lxHO4Q1m3isODMsTVqOx8/Jl0W936R3JpFE9aK2imdF7BFHOPKN2FRqEUjiBn+gdlG3Ip3BE WQWoaVPv3jR0W07jEO4B7eWUtRPxZS1waVg5DA8ewJDQkSkjfsb3Xi8wu0bqh82eaSfdxR1Q Ri6cNXVVgaLUbv4E71cchW4NqYH69Nh9aOn99MHdBfI1/jpGNUl26/gKqnyZdP7Zt7oa3NZQ 5n8M8yLxpfqeHoWLo1L3hCMa35RJMHlmH1nLzkISJ2+riwVdPggHZd049I3ZJS0at5Npo5j/ MA5X8hKa6VEaf8xCsCB//gTeTfXtCLKAcxaqWTSDMlLmXF+6kSp2KXBTNpe1/TCQj/TofX8Q Cgm7EAWKC0e8WjPLNpDAiinZY6nPnxAn6/n12/ft8WCkvLbf/vgfGyhFjOd3ytodLOe6crz1 w4N4/AB1Z2PeQvgaCAoN3j75Vsn3/o8iIBQXCESuP/7LiODJe8qPs0y5hKbkjG4W2zotTVSn xPVKWkU/UwDEHL7o0Zo4vdVt9jR+OCFWl45Y16yQE/8fXoQByB1vU6W5KjBfdf/ditwSGoTM w8y+ZhbGO1W/bF3oY1tNWJ7DQ+Zhp4sZl29ajaGmEExMtljIuRyGx2stPApaWPPINwER33QD bR6UL0UO/TTiDrDnEvOu6zvwjYWlJ2WRD1zGRe8PFA/fMK/lMBpBcucRIhwcuDKveU9xaCfr 93AJPIj02+4obzU7XoYT8u0u3VCz0g4Gq9CxPqk8N1D54cJ3jONgOKSA+S3vl00CP1uwUTgv a+q2Hn+L/WDm6CtLkyvOImZsjTmXevhgv8iWg93e19erKMiMr+cVdjgR4BqbWGqtZIiZL89/ /80PkyLfjVwt0oHrUimqfDFrbglfktgWdLRoG/FJUItbTo2464IKFguuBlQj/OPpjhT1hulH LwMezFOwIJ6bW2FlU+tO2gRFPMi9kk0l22OWMDSWqoTL7skPUiszlrd5XAR8WPXHi43V/WST Hhkxtb6CfJ2yGFtoBLhINtYXuVdKQpp1cO5PL7ckvuL/olAwFdoZHL4XwXnyHmWl1QBARDRY 0/hWx3gq57dO/SyzmyJ7t7W/25il+kSR3WfvbBYY+qibKAHf6g7cum3yvDE/IWaV1x1zr8sW tY6gvvz8m2/m265UZt72LCs6uum/Ez9PNI4radFHYF+M3nqtcDBtshW64RCX5hVDleFBhAU8 0poEme/ZGlOr2XL5qYo3umOon/ou31RS+iZ217HID16MqYQkah2wBPF93j3dRzS4pcC3qiC5 PNDwEOGvRRSepXHinK3wFdIk9uyJD/bP1hAfKeOMWWKxCnLg20PmQo5+5Nn53s41eyjBtO5a Ggr57YdYfHlvPpDZQKUodjXwOGaTvay1fIfvz1bz6GblhQgarsVDhJYXYIC9gRM8Q0HCwN+s qX2RX+umMfzrI+1cjmy7A5Tvi34S2e0Dk6uDP20WDzklnX3VkjDMMm+TjNasZ7htjFzyh5x/ a+xeQGYro+1qnxtplnyew477zdVUc1rvIcnMWXw6DeUpH/XYlqpm5OGiPzD09f/DkXQWVPxf /veT0r5tTs6cUyqWxEMNfRNdkYIF0cEzcteQzFgOdMy/YRqElcNWL68IO+HaRKQlegvZ5+d/ W88N/fkAz48Ajtqok7xxy7+QoYVe7AIyfbhZELzkLED5sFcqsPqh0elaHomj3CB0lYsfoozE oefINfRdgKuCYXgnusNCE8zwVLE34UCaeS7Ax4Gs9CK89Kz0U33SmgNEOzSBmdE9v+IGMBId Sob6XpEou1DaaN6OdartUtzARDAy4wBX5JIDW4uUhJ4XhB94QdlqKBJFBPZN2tWQ5wweiQch IHmJI7aDzPVOboHn49LBzAKfxGF5qbNkaIAEncEwvzcQTPyYGZryxI85V21Qzgg7alYsc6MN 4uwaXRI3ZR8/BOmEx5mYayeEo23RnO7rkshM57uWn0oDKRwJsHoIDI+0MDeLS5L8W+pTc0Zq RiHjLcBzzQ4ekgLkrCDVKzIjDi34mqPoznWELzmOYRIb73hmRIYMEM/rJz9K0IjDWoUtAc9E DiFW55YGSYD7251Z+HeO/HivewXHASkZgCBOcSDVY35oQJxhWbH2GEZITkoqTbGRccovpxKs VoJDtD+RZ9PancE8jLEXon04jIcIPSbPDOKykMsutNjW/0KY7+lXEktPFIfDIUZG5q1uiKZg mJdG/ScXn4wDpSSqiz/rgkS+Bnh+5YdH7GmLiotXpKEfmTbLCxL5mGRsMGjb20pvfS/wXYBh d2FC2CwwOQ7OxKjDKJ3DT1O0SocgwuIFFmM6+cbrnhUIfQ/vsZH3iMsYX+fZryvnSAK8oRxC H0ubHDHSHhaiYREZSRP0W031vco77U7HYnjIwAcwQvc9HKjy1o/Pcn9GymsLcCo4nB6RLhdv z1uCdolwALTXI+KpD5LpOFEfy7FgCeqba8X9JMBTlk3DlzP0wnBmERuneqJvYXX8wLvhiPRc 6nOJtsKBLKhO27yqNA7TmGG1PDHXCw6Jt8QP0yyEOu7yVYycUXPwhWHkp5jLmBvhKZZaNLGf mYFRNSjw2F4vnrjglSN5pkmAUKWpTrdFzvU58UNkVtTHNtdt4zU61UNkLXTQBIvVGvmosYeU AEYaapps2g+KyJ3GvycR0ko+rQY/wKOmighELue2M4/YS7G9zuRIt6NQAabFrA0yWjtSHvA6 j4TLJvjervME/ht1joIA6S4BRMg6KYDEWaUg2Vu6QZjzzYfbOpR4qBbPYPHRHU5ASbY/bznP YW/gCJ1SivWGREK01RCV1YqEh3GEBzTbJMEGqwBiZFoI4IDs07KGBywJoSEqbYwk0YWshb/s qsA/tsQ1Y/m6NyFzvGmTEKNiuyqn4rzYgGsxuYRTEcmqaTO0tAwtLUNLy1J0bLeoi0wNxiZR ax49NHochLgbfIPHIbubPHtTRj5tQfoEgChAm9qNROrBajY6nwsqVjLyWYdpRXWONI23SxsH +NEf6TQADl6E1oyS1v3OdG5YlcUHbDpSZcRuJ1BkVGoO0r3ePZbNnVblNk+Iak6qiqL51h2j F37+poxid8gL2xDGATZvOZB5CTJz64GyOPKwJKxJMi61YEM0iL0kQUcpbD4pdnOocYSZj8wi tZijH1Eu1bbnhC1T4KWoxw6TJUYFTbkaZm9sJmEURa4lPUuy/d2ETiXfjPYqyM/nkRdh2wlH 4jBJkR3hQoqD56GVAijYleSngpY+Vt5Tw2uKZkpvLYh+O5my84h9YU7GxiYnhz+xgjhA9vZI 9XBgm2PRlnznRUZuyeXwyEMWdg4EvgNIQG2JVLtlJEpbf7tMzcgBPW9K9BjuihX8GBAn0wTP oFrTR4aGBykmFAko3Dv1s3FkchJsqtZyEQJf14gfZEXm7w/wvGBpFvw/eNLdwzrv8ww/DdZd HniY22+dYZocScNgV+YaSYqskOO5JTE6EcaW+p7rab7GsrfXCQZEKuF0dFUGOiqYtTT2kfEL DpIJvYhjEdIEDidZgr1+WDhGP/CRAq9jFoQI/ZaFaRqesMIAyvy90y1wHPwCz/UQFK5cD/hN v8Gyt7BzhoYv/SOy1Uso6Vwt4rPwjD1SM1nKM7zB2HlotIx9QmunOmd88Hzdh5OQuHJNj6QI EKFtrMGhGdtiZVsOp7IDZz7qIbyM3Xlv2W+ezby5SZqBHmvzDEL4THA0BvGvKVKFopSvfE79 lVe1pPdbzUqsFJ2xyuuBbwm54yEGlgQ8PIEfTIev6jmJO3eEUa8vAsMThrt6x4DAa42w5kLY pXysXc+TFReY+21U0vXX15fPYGT8/YvhdGlJLSxO5ScnTd5iVv+ShfXkXox8vexZNT9Ds3KZ WVSNNpURQ5yzhpE3IXVa8wKGZRQvw1rMgbm1g/leSCZKsKKXG9nd4u22HKeRi/M1wXM0O4+c d8vFv4FmFKLdtCL5KK7ZgYV2+6womwCnC9D1t/yxv2BXyQuPdOshnmzfyw6mZ4EUAT4ohf06 z40vB9uiNmas0k/z8+sff3389uc7+v3l9dOXl2//en13+sbb//WbYRIy50KHUhUC0wKph8nA l0BtfLiYur6nb2dFwS2JPqQwRn0VgWz3OtaRTJbzj9U/Lge0rK/G9dMbTjg0QCsLHadKE77r AwV4knCfRxql7XGsGh+MbWV68pKD3q6584qct6rQLOOVt6Tt6H+q6wFML7aZKNtltNuK227F 8ikJpwnJk/fvBSHn5MMFYhzLKi+l5MUVPJrzdYEDSDl5U7fwYtxsKlBT3/NNankkd340jgR1 ab24pshKk5VRiFnB5VXdYB28xNj1YzzPqh4peWNMlJeh32lGfUx5cVbeoM9nmEHJLa/g3tXi TkLPK9nRVUIJpx07DW+gi3/kR4igMrsFiGbvnSkyoM6U89w74YSI9EWt79XSmtTqbX70WZq/ 0H7ONMOVfZZGfmjXecG7693l8zXxZPsxSfJIuAxpV+BI0iCyiFzQj80OgMPmbFK9RcL0mNpd Nn5opywxaXCIMAqa5V6TjVOzNK02rIeZqLmxIecnu/dgsJaUn3nxxcnYituytkdLVx+80NWH /8fYlTVHjiPnd/8KxT547Qg7lvfxMA8oksXiFC+RLFZpXhjaVnWPwmqpV4d327/eSIAs4kiU OmI0LeWXxI1EAkhkUlEcWnakZgm+y4hjqx8tNrb//ff7t/PDKryT+9cHQWaDk9QEk20Df1C6 2G5+kgyYOiT6MO3Bf2/T98VGci0pvsoGlp49Wpa/SgqIUIF/vaAqEdwjqV+tXSOxYGMUSpIW zdUUFgbD99zXEZSPeTDESy8zqTnMqMG0aJNUBC0cAFr/syekXz+ev8CLvcX5qqbEVttU8cLI KMwOXhydQCXJEMWej+22GQwOhtib4UT0MLZCuzKRA7EBRMvux5bhgJsxpLEf2tVxNHKQU+tY EDkDe1PJqjM/31fcyQFUgfMfrEZMp55N2qS2mXUU5V30ggSYed4FdOVmUS3jGE3yjwCUnAwZ PM1kt/QyBNfyJ/FiSiDKPqpEQLqTZQAzC5NpuyLwqGSBZliB3QDuGvoicdV25GLt9kC6/cUX BtISZZvIb6GA0IuEdYfGeoBub46JEU12A+xFCiND1W3LVK4Y52DOVQ10/m7OBHLZiFS+ou1i 6Px5/1Wx+mhf3/aBgxncAciejyQVXeYbuUT6uxGgRlFb4aHFV1Sb18zc0A+x89wZXkwN1c8o PcJOalc4VoY8N7QMFeIQuIGePqWih8wMXPR38avsD+aDCvfcygSBigqY9AZBoINGLRdXsC8V VCdOUy1kVFh+Lji/plG85bBc50cmclEWo0SRto/Y+atUz672hwANPgFoX3hhcEIy7StfPLO9 kDSfgAzZ30V02ODnx2Rz8ud6mQoxP0Xi72GG6vHL68v56fzl/fXl+fHL2w0P1VAs8VyQHScw XMTw8gLl1xOSCsMfREqNPYBTBtf1T9PQJ5JtFqD8fZZMG8D/xUHsCzBXtS0fX9z4wyv0Oo1D oSLY9ZdaF6piEruUpo1CNFaygPuBj6anjSlGj21HXWdxJlMsV2A6lrYTuleCWUP7Vq7v4qfi vPBXXSszFrYRMMKmx65MoZifB/5EiPrquQCIRpD0Xlg6uNEDa4nKN93ALLDBdJTDUSwLSB3G 77Jm2LVP1zsKUsCsfecJLPsrYF8kaeyqHk5F73wmhXQ9v8jhDLmRQ9suxCvh91aebXECN+5N OZjs21Ze8DV74C6j+wPuQXRlhsNvdvZ9YV9HyMpFF9k8CoSpu0KgQEfyBaUApr4bYyJbYJlH Wpk2Npr+jFPNB17SYCwXjRZrXKaiftJilMkULU1hwq4qhV4iNd1i+IbGMKiPKwNXT7EacmT0 Zcu1FS/6MnbRt2AST+CENsHSp5IpcE942rAqhLiVh8JkCNoiMEUhqhTKLL6PFlGV6wI0JC4P 5oVlSsEgxGXmygXqom+QrBIX0xo/Z4sCD7sRV3hEgy4ZktRJBfIdvKaLcvpZvmEYOQGa+ryX UgIFSXgomuDJUBSbCpa0Nm21z4ZH1fqejWneIksU+TFaAIoEhhFctbdhjJq6CzxUMbfRuae/ vBKw7eGPzLbQbmzHKLLwHmZQZIZiHDpWmGzWlGUBYrr11Xr3ZQ7n1ga50lN12EJNESSeyPEM TQ8WUnbgYgcIElPguHhTcf3QQVtf1yhVLAqMxQp8+xeKpSqhGorrIiqbd13qjbIj4S5RpyB4 ExSWvrIQn+F2CT8052FPZ2LRTXV2AaQTfDouEn9BsNNcYAiET1f676MpSfBLfz3NntR3jenr Hela7HORqaJKyn6TXs/lVLVoyQv+fEwHuqSqdIC1KYQckHyqdeDvvKAdVzVoBBiaXFZnUvK7 4uTvUkcri144HqlLqq7s7pPyDVRNK9TG0+MhiSjiXF2ofJZ2ZHDV3jCozwANXUaqP9ADh6Jb PMEghSzypmvLQ24McQssB1KjTl/pNILYuIXcQYu3PyUn7vSkMA4j7gkEm5AFk7EUkxqdRwhR m2iOhtORuq8KeF5pbLECVcCT6bRpTlM6ig8qM3Xis7DTjN7Jh8wXOujEDRrbifPMuJrkTKZj p1S8jC74Ju1G5kq8z8os0a9iqvPD4/2y43n/+UMMczYXj1QQ2WcpgZYH7eyyyadhxCqh8ELU mwEaHGWWWDsCrk6MufZp92kSi2MsIRUJZ+/vxRwufqK0Nlk+HIs0aybJY+XcSg17d8iDu7CW HR8fzi9e+fj88a+blx+wsRSalqczeqUgUlYa28j/ROjQnxntT/FxEodJOqp+CzjAt5xVUbMI 5nWeCasLS7PKKof+qDcQDNuWpN9BzOQpob9h5vGc7VjzOCqXJsQqL4w3wRu81jRqe1LpdnuA nuK15heIT+f7tzOUhXXRn/fvzAnkmbmOfNAz6c7/+Di/vd8QLhKzU0snfpXVdCyy9KSORwon TpXLYR8jzkd2N18fn97PrzTv+zfaPHDGB7+/3/x1y4Cb7+LHfxWtx3h9IaTop+M5KYThKjbn /Y/3j1ckBDYfAlV2J1macWrflE1wQs/4OMNwpFspTx2fwzGI9MSAGmDCmMNFe3CpMG+E0c7n N0lJO0gaD6cPGfFD/6Syw/Gw6IiEtZpC457EZdr6tWjIu3wt0laZoQBLsra0zK4JG1zmQx5V h997AJb2m04tJ93cFew3rQJUv9qjREeu1T6TFBggdQT0nbqRqRWJxWN1ofHFnp8zIiQMrWCn s29p5zt6s/DDVNOg2By2jrJOrnREMjI6FVRN22NIWnGhUeRoehUpyyYxfdirH3G5NrQi3SvX 0cFvw3tV2CZkS1W7pFAzEnxBKhNnMbRK+sLpzBNIZBMVm1n48zfj2qysDvig5KjuWF8U/uu6 wKuKy36+hhpaYywqrSHGAjxCYETQg/QUAIDITCwqU+BpGTiVXm2q8NPlSLkJkNd20UMhJ90/ f3l8erp//YkYInA9ZxhIslNLCAovO3Xn1rkfD48vVHP48gIuwf7r5sfry5fz2xu4PwZHxt8f /6WYDs/ScySH1ODgdOZISeihG90LHkeiX4gL2Y7jUBswdIYHnu1rvcPojpZM1beuJx8uzMOy d13Uo/AC+674aHmllq5DtMzL0XUsUiSOu1GxA62I62nK0rGKwlDLAKhujIyL1gn7qjXPMrb7 3QzbiTKJ2syvdSvr1y7tL4zqOkwFaMA9XV5SlthXtVFMQqkEVfTAbtFYB467eu0B8KJrAgE4 Agu7VFnxSHZ9JAEwg68kvxkiGztNvaB+oPYkJQYacd9bkpvZeYyWUUCLH2gALFvS0w6RrM8M OIMOxetTmY5JqWFsfVs+OhMAwznzhSO0DEeqi2blRFf6ZDjGknMogao1HFD1hhjbk8sdMQjj D4b1vTTqkcEc2rpkSU6OH3mSK1RlRAu5nJ9No5yl7uAXiAIH+qRUmAehVltO1kQGkF291xk5 RsixG8WakCL7KLKxYbDrI0cNWSw1zqUhhMZ5/E7FzP+ev5+f328gzpHWA4c2DTzLtTVByoFZ Bkj56Gmuy9bfOMuXF8pDhRtchKLZghQLfWfXaxLSmAI3pEi7m/ePZ7oXWpJdTSMUiC/Lj29f znRFfj6/QBCx89MP4VO1fUNXnwSV74Qxsmjhxnhz5Qa6VW6L1HLE2l0pCh+699/Pr/c0tWe6 Jujh4ufR0Q5FDYcSpVrQXeHLAcvmclYnB3VoJcDIKgd037wmAxx6+GeoT4UL7Bpyc1FjBQ43 oxPoaglQxfuflRqhvHLssws99K6J1mb0g88ZrhWdwtpq0oyyJ5CVV5c1jIoW3Q/QN5MLHDry O/oLHb93vcBoU4doycIQ440ibCA2Y6y0pAZjTWK7kR+p5LEPAkc7VKiGuLLEjahAdjWtD8g8 UJ+63xniFnesdsEHPJvBthG9hgKjhRoLCDhavlEKJDjLls5yrTZxtaaqm6a2bBSq/Kop1f3u 1P3ue7Wevr8PCNFrwejGbTjAXpbk2kpO6f6GbJH0qoK02M0Bh7MhyvZav/d+ErqVtCThUpMJ 1JLS9H3Ysvj6kb5FIfvQxeZaeozDK0KUwpEVTmNSiSWTsmcF2j7dv/2JRWNeygRX4+Y2BpOx QCszmGt4gZixnM3FH/e1xS/v7SCQVivtC2GXCxjhYfKkFRhB5d3vcKjZxRqv+8fb+8v3x/87 3wwjX7ilNhG+gJh+rckSTmCDjWrkGFRlhTFS1ikzX2gw3dcyRn0mKGxxFIm2wSLIzsvsa6Dh y6ovuDxCy1YNjoW6tVWZFANlFcXGpcLkyD5nFNRGZarIdDvYlri1ELFT4lhOZMJ8yzJ+5xmx 6lTSD/3+Ghpq12UzmnheH4n6ooQSqlbJhnD6eDHYC4iM28TClw6NycELwjBDIedSGL7MzO22 TahuaGrTKOr6gH46GCt/ILFlcBUkT3rH9g3WnwJbMcQ2bgMsMHVU2Js68lS6lt1tTcW9rezU pq3ooQ9fVMYNrbknrU+IlGNibnh5eXqD4GNUUJ+fXn7cPJ//efP19eX5nX6JiFX9aJHx5K/3 P/4EM/D12mY1Us/NXgTyQeqgMScQYBtXdCnWH4sBQmk1mNViKoYNon+w3c+UbgqM2ktGxEBP 24kcTljIcJmN+fvts3ILx8V4MaZ91c+hr+W8gb7dLNDPf9PSpYWo6L5taNqmbPK7qcu2vVrQ Lbs3RZ1ACFwQb32i4yKdtkVXzTEu1Qorh1wCOAxKY1ICu15oSQ6P7kS3tACPHanQKsN3GD2H oIU0PawtoJlMGHzX7+AwH0PHSv67p6PlEocWNsvz6cQN1dJwTQS+4qHjQ8uSFpIF6YvSDjA1 bGGAmJ6wyMbRCfv+AqsqghBux1RMfsTRVfrGnLVbQyWBFOxcZJVL0hGqcZkGD6nSvD3IHcZp kz5xZiApcIMfgQUsu9sBMz4RmHLSDXw2bC/hIEnS3vwHP7lOXtrlxPo/Ibjs18dvH6/3cLUt ypw5PXhihrbxryXIb8Uf33483f+8yZ6/PT6ftSyVDNNEHoCcRv+rUfouTQRfFFwG7LOupqJx fsM5F/hqKcSE6+YwZkR6HjOTIGwBSe6mZDhduZ5fmLkBho+SFwcWv7k4XFUHubYLDLZRZZHv BhkuYtEP3EKZWMD4qe2aTfbbX/6iTCRgSEg7HLpsyrrO4E3ywooMPda7D6/f//ZIGW7S898/ vtG2/aaIAvj4yDJQxz2DTPFMZYYlTLDhexBq19Loj9OWXZly7mYDUc+1dUFmpYIv2U8p+YXC 5YcET+v6Isd4yuZIx9WYMcOzhIdm7PXenXMaNyWp91M2UuFjZOoONTgvmdpKnABIR8kdSGfx 18en803+8fhwfrhpfrw/fn98Q6YpH1uskRYPNmBubGk8MGa4oxZmdHbo26xOf6M7O41zl1Gh tcnIwNSabiQlsOl8bZdlVTtc8g08nQduiBczoc2hvzuSYvgtwsrXUzVBrILGwALMlgUMnEPH lIXfbKRFr7WctLjmWaUuaCNdqw3jY6yO+VZbATmVKjGJcfXJKyI57p5pVJ1XhymlugFqjwLo IS2VJawf1OJUOcm1+wxxmUxIB15idmmFW6BemMoxxWP4AMftCfPhBMimSXa9XEx4LcVCJSor cEtqFg1WWpba++fz05u69jFWqkrTxLKup11fYsbBAicd3dMfdLs0DZXf+lM9uL4fB0j+tMDZ tCvg2YcTxqmJYxjpJvp4oKK/RFOB1lL7giP6KYvGkpVFSqZ96vqDLb6CWDm2WXEqagiIYE9F 5WyI6A5YYrsDT2zbOyu0HC8tnIC4FlqpoiyGbE//iV0HTevCUMRRZCd45Yq6bkq6y2itMP4j wSyLV97f02IqB1qwKrPkk4WVZ1/UeVr0LTjm26dWHKaye2OhwTOSQvnKYU9T27m2FxyvZi98 QHPfpXSTHht6jFT9gbZimcYWerYuJEq5Npbr3+L9AXDu+SHap/B4oC4jy4t2pXxiLvA0I4FC s/FreD+HcseWjT+1WrmbkorT01QmKfxaH+gAM2xDlw8gWDHzl9QM4C4gJli1mj6FHzpSB8eP wsl3hx7jo/8nfVMXyTSOJ9vaWq5Xy3YsK29H+nYDEafBQ15zoBImoSsP7i9Q/OouLeiU7aog tGP8aATl1m+Ede4m2bOm+H1n+SEteGwU28sH9aaZug0d/6mLjv1l2PVBagfpJyyZuyPokBNY Avd362ShY0/iqj7LK4qIRTX83vOdbCve0eDchOAJZsW+mTz3OG7tHGVgT1TKWzp0Ors/WYY5 MbP1lhuOYXo0nHkh/J472GWGBrwUxfVAu6qgW4ohDA11FVmieDQUEwyWSHLyHI/ssRMjndUP fLLXVBLOM7RgMmY50UCH3WdVnpk9txoy8kvMbW56Mi4wdofybl5Kw+l4e8qvC/yx6KmK1pxg SsVOHGNtSYUO1ULz6dS2lu8nTihdlyhKgaRndEWaK0r3vFwviKRXrJ4cNq+PD9/Uo4YkrXt2 iiaVMdnRjoZzPTg9UVfmZZ2ipJoFYJNh0AgmZuyonNfBrnVXtOCQOm1P8Bo0z6ZN5FujO22P MnN9LNcDPmVcwLlLO9SuF5glD5yKTG0fBY6jD6sLaLiKZwdOBYz3IsLjGHGOIrYcTS8GshK4 QUJBKVq6Sj5g2xU1RBdNApc2oW2JN9IMb/pdsSGz1VdwHQ2vopGC0sVl23q2pZH7OvBpD0SB /kGb2k5v2b5af/70hgoJUp8CF7VlUNlCKTaxhKatDMC5GxhA+bZtBCZmuKpsSwWYW8tpc02f KGIC2VCTsdBE3ky+6k2WVahL2vxgaIvqpOy0KWG7UbNKiq6jyv1tVpnSySvbObhy/KKhqO8A 250i1w/xOOULD6i8joP1mMjhekLTi4AnDpMFqAoqut3bAStTl7WkRV9bLhx0ofHlh7YCErq+ 6Qhy3DQndhWtiCZ2cCa39ZDqe9vOdjBjpXmfqe2EC2IWI2RUvGpg2iU8+oFd/QReR/f9cs69 fb3/fr75+8fXr+fX2ZOsIL23mympUohLJbgP3VBdeCi2dyJJLO9yh8BuFJBi0QRS0XcPZEJ/ tkVZdlTWa0DStHc0OaIBdGOZZxu6lZKQ/q7H0wIATQsAMa21Jhs4V8yKvJ6yOi3QABVLjtLz DKhitqVKdZZOophg9znJYaPkP+akLDYSbT39FKkVOGTldxm9lCps2qH0A3c9qnftn/evD/+8 fz1jfryhOdnEx6vXVo7SKJRCm3jbwDI9r9D4p8kd3Vk4yvt8kQ4jAf+USjPlI9pKhn0XBQ9j 1mMaE4xWTxTk0AXy/KIUcFENT3IMLdDbqeLUD5Klk79QE+JEg6nliisvFlcAOfSmYFeM8ogB wvxYUsydkc3+eBaOSyYmriJEt+YUKbOIbskieSqSjk63Bl5Zil4DYbguQdrFxDmRCu2yzGq6 KTQVYuG764fi9oDJt5VJbsuZyN+nYEmSMTNMZX7TpXzGieZOnXFD33Fw6XExXTLc4YsAx5RS UMpkmmeA5ScpXyDhJepdJeXeNU9DvrjI4oqR5Le6K5kkSVbKQCFLRvr35MrnswvVEMobJr9h AYSpkzVUeBf4EwyK7+867OyFIi5fl2XCpQZiGgwwDoCxadKmsVV5NVDNHrNBAnlNlXO6Iqtd 3O1NIljtMzrpKrosm+rMXHebQOZA0Az2yWGLWaeAlBVPyUFQbKhGeBo8X5PwWDxnuT+Zly/j 5M/gGKCpTNN+Q5tWkcczjb0WzlN5bC6YNmZ7KtitUJ0PVWgrT1MWO0VMW2JL6eb+y/88PX77 8/3m32/KJF1e0Wsvk+FEkL0pnx10iOMMsNLbWnRb5gxoiB/GUfVU2823lhDNjtGH0fWtW2n7 AHSucWMduqCuaFYKxCFtHK+SaWOeO57rEE8mLy9DZSqpejeIt7n4FmcuOx16+614cAZ0vnOQ ac1QuXSnICx8F3EmtyCCz2Ex/p+xa2ly21bW+/yKqbtKFqcOH+JD55YXEEhJyPBlgpKo2bCc ZJLrurYnZU+q4n9/0ABJ4dHQZGOP+muAQOPVABrdaFJrtVpldWPpLtgN6w2fHbYhmcsIyBjw nrb1dKnKAgM5OZKe4GUhBXiGwlZji0c3dteqgvhFvaHSb1qAT6wWF/aATWPp8kR/tX5DNC9E bisZjle13M5JFGRVh2G7Ig0DNDehMI60aTw1LQt0QL8xbJevCNUT4h/ZT7ZxdRyu/7Sh2R5a 89ckLwQm+ShdH/03yK/paky0Og2R7chyrpZjYrd8n7enRo+FBT+nlnPL4bhJh6toMeKY7hPe yKWR3j+N+FIN+OStHcJUVoWRiySykm6T3KQXNSmbAxxXOfkcL0XZmSRevnemA6D35FILxdok irEoaiQq1+73YPpmoj+DT57vNmViTSejsZxNTMgIrOtMYs3GsgdI74xLZVvUn8iCKjl+N5MV 14ZI19ngzQS/OJZCmL3iiKV3IqYTJP0rfUunPTdLfAY/y1wa0FDTitBEWTPglluymB77FplF LUaQboE3t/HED7vT3iRzsGhoqN2fZBuf6vpqS3XlvyNbSAw9YSrPSu9CMJwqrSddSCgwbpq6 O22CcDqR3vpE21XxZOzxdSpkaCLn0eUmdJuth96m4L2uClS3YqZ8SRHmpr9JSa147Lmam2Ew r76Ds2SToLEQAeXs2FnCIgNjY+cUQ1LlSQcaWh5YTnmuHyQvNCuq+kzFo7cCeIkc/qchjtEt GaC7Ic9GO4kkTu0ZYqC1FNPf5ZRDgtC0EJXUmonG8SRpx6tQY5BOI+nWjMY3UR46tNQIkL3S xI7pMhW8s4e5DDHhk5aKP6GOvc08h3FvtWxB+opEVgsdZKBNk1aRq8uoUm9sYcn0nmDVa1bY nYgcmOA72sqwZmiQSoGU9Nha8SYbiBhQsAO2k7yBUjZIouLnN5I53WpJh+ntsoj1KQwerSaf ie50MgNWbygbHsZZgBFDuzwlD7exb2AAaHpHulHVwulttplJOs7xMu3rHL1ZlsoAdGTry0DD z5WkaGkZWhs8G9XvxVRrDGWVj878stD9H3ts+0MY2dtJvd+2la8bVmO6STclN8si9CIuNsex 051nuitwUzNx1qamjnQPFGrJGI/W6tuzbmCFrV7Vpf4MdCZtU4SUWHyc8SwItxYRbFbObGfX +XZcoq+RjOSRPcPNRLV+2FA/nFruDNHzGEW+3nCt91rgpWPxL2kHrh+eq/5GVFdAlfE11Q9W EtMJ1I1ad20Dtf1uQ9L22aGW4+DJSmi50v2TEPZT+S4KNrkh7M7SC8Bfp02YkBl/JYPVK+YH 0OI9kTBwJhQJ8DG6eiQPOCWMvHe/Lcmqm9tLmMo1jCLMhHJhSPfMlhaQj2xPaGmXc0eLKMDj nc/p4HosdbPr2gIlHgtMFINocq8TyYXpTHpGfCuCCqZlqfVjJ3SScrC/2BWy/SgaZViOQ2oP TKr0z93J2jkAskQhNfdsDtuy73KR5Q2Ti5hxf1aqeq7hbARmiD4JJSKLwm09buFgSQaH81d1 SdMP4BhBMns/aYWV18D+LDPII+drOHvZtB4vr0oNrlXQJC/HjtYy4CSL+HQ5Mj5UHi+uUqcq OTs08lZW8Ots6rH1C52dPf3+8vVh//X5+duvHz49P9DutHp8pC+fP7980VhnJ5FIkv9oIWHm Ku85GA73SLcChBOGiRWg+r13S7dkeyrEsuZLz7lPwV45uoLt8XKVqmBYsRjds8r30RKqeuez rB5lsU+Gu627rWApHqLRjyyNwsBuT6c8rMZvA1dchedSLwnl84x7IwXiKM+xtSC8oCucBZQu 4zwfkyGr92CTUFRXoQE1h6khNXr7aibcXQfaq3EaeMapzZiEC6OnMBROFflFMmf/YPC6qeY5 483SL2lqIqalYBuAjdM/K1sjt7ebf/YZUXeZkI5RkEXjW3KSvHK6jN8ozcJc8jwO039WGN7u 9WkRy7weHsUump45ZiyyMEE+S//EOhbg/r30wjGvJmhqNPy8zqBeHMknZs4J2Y1HlK/tyntO mjV+t1kgEyU5rbZeHnx1vOFCpWFT2U2sQyZeLZuhrRfee3xiATd8v+scO3IdegIWjbbTaYzL 1wi7viXFpayqfya/aRzEfpUs+jkeaiyOHmAdVW7d9DfndwOUoancQs8xpq1JGGdSOjPclhFw ue7KceZbFiT3Y8O+OxDPx57GaShqZKCDWeKs7i9+TKSbUMfPjKHoWda1KyY0x+k0sMo5217Q MPPu1W8sY4hnHRr+RGzEDPTloBwf3IDbzgYxljB0jjB0bDpib2AcLsvqZMUfN2HgP71aWDwO NjSWDerjTGNIkg0io8dNGjpHBguy8R9PKJYkRmNKagyJ7vJqpVc0SfXgJwuwK6IcB4aJ09al L+Fi0eNvycDjpEIdxZocqAwUdL91FA9muGpyOIe8CtpE1RtSljxJ6LEyMbmcg+sbdK+dJEeG iB0A0/eLjmS+3e/KgIxZRcdH7IxxbPECbByRzjQDvgEm4Dj0nl4vHBu8pPHGuQ5RCHjsvZun 0rHcTJVChdCN4L0LFa6M/X275FmIWvtrDNHGOWFRCKhqd5PmcYRIW9F9wp5R7r1klKcCQ50G iLyPBVE1xpTSpp36xziIUxdUanOOFHZRqD1InGTEAyUBMllKRH/eYADbyIfEGTq7KAz1MWl+ ESs/r/Ot0LUvtFiCiLhMHa3DNEfbH6As374xqUiuLdKLZwAfxQuIDmMAjZCLFuDrWQt8v2sJ rjjA5DUDd3KX8Nu5C4E6F0Y69rZEFZtHJxF4EkZ/ewO32nz3CyxGDDqI+0osssgI7MFrWYLR kzRERh7Q8XwSw/WmQffkn3jyye37gZXua0x+GMDd2b1xxdmhJuqCyINAGDMjONmNQb6iIuJf sTHCtHXO+v2s03uUZc/JEud1FAeIfABIA3Rxn6E3OsLChY5XAW6SNENzH0iMmgjqDAnS0hwe cBF0LzAQHiWeWNQGT3pPawOOzL6jnAEz8LIOZPZV5wrYl80zIFRgZCGQ0QfcOyoB7Mk2zzDg 5sv/Lujr0zrL/aZeOePQvgMz4WjEaqbDeHcxWdBJ/sbiL0FBxxCbIwYekyjKSgxRqh4qH8CS e7qQjJgQI1WWcZBjZNRd6jwJnavdBUEtuA0G7FuCnvuyzFD3iDoDNpfL4A7oGi+R7I0sMcUX 6NiglnSk/8qoEx7+DBmJQMemdUHPMb1L0X1DY0bvjwoIjx3gRd8GjknJgqD2tQYDXott5s0y u7dLB4Yc6YlPVZxbTk1XSB4fbdPOe1W96JFZgsxLEB8WW3klHdOohzTF9Cs4iE6w4dxgRlkr ECHym8+0kfHfkVTs5IjxWt08sjKSqIWakr5YD6Zw2JarWrsPPemOEvcuVaP/9OPaDEcwr9Em wPWedLEaYIX7DuDIjOKIn9NOngpeZZDK5jDgtxCCsScXFDod0eeWkPXNHl6dk/75/OvHD59k yZxTQOAnG/C/YReQ0P6EKQkSMy3fJekE5gdOLcvqkWGvrwAEf5391cyGHpn4ZRPbnhMzSqci nw4Ee7B7lOGUKKmqq52m69uCPZZX7ExV5ikNHKzPX9VFtkEUDXNoG/Djon/iRp32e1+Tih7E 78JVSVvMHFKCT6L0ZlEOZb1jfWER931tV/5QtT1rT/gNIjCIrKVTGM+3H69Wo19INbSdSTuz 8iIte6zyXGc/YwaVQcgvizRYhJ/JrrdaZLiw5kisvB7LhjMxlOxvVLRrL7pKL4mlMyKrsmnP mMWfBFuxHS/1qzWdCj86w0BhRTztDHh/qndV2ZEisrg0nsN2EwjUejrALseyrOxOZPT+A6O1 aOrSrmUtmqxHHawp9CqjYdqpZOzdgz8ZgyPbdj+Y4qlb8Hlnd9f6VA1MdjOT3gzMJLT9UD6a pI404BhB9GOtu2tEJSo9QTmQ6tqMVjZikqlogRLhfft3a9KYEfQpLcIHWXuyEP3ON/UsLBCP 2E5dkUZ6yqH+sdv14HrNk7eYPh1Zzo6G7KaWUfYq1mDGzRIfSlJbOQ3QG8WaU3Int1PTVXdm nN7jPE9OGeCZinDUcFfmXZN++Lm9wgc0NUCjOt1hYOfWmkrajpel1RXAc8qhtmn9iQ/zwwbd f4RG9w/IEyzkU2e+xpVTKGN2gG4DH1lT+yalp7JvzcovFKfiT9dCLOj21MjFlNn20/G0Q+lU VKyt51/Wcl91RmgkTMmQ2gfE0DZ1opsKI83wfFpMx4rFt8GSx+5FsHVfX15ffn355OoyMibo zpjXZfRPmAZRW8038rXZbvfCPyiX0Z56wR2sVS/DhbORbLUb1T+glb49UjaBrweh1iq3FLeG 1cLpmsT56t6gQXzjoWcHk3qqOjab+RlCE3828ske0jrSIrSHVY/w6UgLI0cze/UaxciZNE17 Aher8l2CilvvmKiZsaigAW4RlI3cZn/DEzzKY6hDWsllPKmyS9QOuM3UjIG93VBWVu4O166S qwMfYDh5OWH+l81wELOFIHisHpTR7epaVlSzItd30Q9Gt24WDV920Jdvr+D8eQnqXGCjg6bZ GASyzT7r9BE62dFctVZ6sTtQgrldWzmU0TRCBbvHUp0YOujylNjoL+WtIDa1b1sp2mkYEHQY oD8pp+4uajyKWql7XpkFW76OvHOWrTyeojA4dq78GO/CMB3dku9FzwCzPSeFWKrjTRTOgNmZ 5lJ4+9AJYdBnhCoPQ7coK1mUtsUgajVTn5M0Bf90TlaQCec7kx2IMk4uGOPrM7d6Of9AP334 9g1zSCP7OsX2O3IG6aXjZLMAl8LqN0NNl082YjX9z4Os1tD24Cvpt+c/IWTFA9izUs4efvnr 9WFXPcLkM/Hi4fOH74vV64dP314efnl++PL8/Nvzb/8ryvJs5HR8/vSnNNf8/PL1+eHjl99f lpRQUfb5A3ifdj3wywYvaK57ahU01lkPcRXtjI2BG32CKYO/yxGwEUu5aMXQkK0Aj61/7hKw 34eMnDOKhmOnorJSsuEL3dD3RhYffbdGsv/wKsT2+eHw6a/nh+rD9+evi+Bq2UVqIkT627MW jVi2PWuntqmu9rRUXGjsLa8AsUMzWZUjRD0sibPYzXRHUBiPM5esSM1rD8Lq0YMsZzXf7ekk SwN3jhFEdzSugCi8mCUrY/CBPuEbdCfOswh/4yk7vSiY6bNjzdVcnlFFrKxZGlmTbs2i1CSR 4jScLNnw8sxLS02pykM7yF28SXaXrPmwRvyfUTQmlGKS7vUsORZqw2xluB/gVXBFcB+5shJw Gjb7sEQ+KOGp3osFR2wSIIrMobRqzMQ6vzsfiNnilVO5AfxYCJVp15OhxU6+ZD3aC+l7pmvs Mm3JnYWTl4Oas/dshHgJ9vcYh93uHjOFA/gqkozWEvokZTZG1uJwgu62i5JwtJcNLvQy8Uec 6Cf5OrJJzbP8+RXOIzwClaHH7oxZ0nJ1XLZ23e7/vn/7+KvYqchZCO+73VF7m9K0ndJaaMnO pgBBP57OxiOZgRzPrdSDPzskNUJ31zVIhjOM4/nllLbx8JTXFMeBFIcSn+KHa4eG8pErvJgs 5shJZlkA4LMZMGhrN7TWg913lx4ex5cYkRd5lhvXzwvg8+IuchFKdEu1Y4qVtGjuuXZUL5+k EVR9hnSyv88NL37/mxf/hiR3FOU1a0juc28AGC+Ousa7ksTQk/6kOG91FyE3XCnKxnfE5N8e 4a9733JM2bUsq2GPP0gFnsuO43okgKSinuAoUn5sX093UmM+n/TSdY6EVFUptytCd5nHYzKg Z0ZEWktAJsdpF6OGIQCe+JGaBTkJwbFUdPHAaYuSVOD1HcYdnht9f3Sb8Mjf+/rg7CUXaffa 41qjLms+MNS1AGyYYf+oOZiB3aR0j3Sr4o02LUe5OrLrYUpvYIk8XmCGbA7letACjnMQZUEm JGQI8djJCm7iIEp0R/aKzON0kzjUS2RE/VMlgydu+mX4jZrYVNoHQbgJQ2NhkEhZhUkUxLil kOSAMKVx4CSUZExzXNB0E1mlAOLWdNi80oMQD8spGZpy2OTjHYZLj+64JdZRsk1iuywzVblZ MjuI6XlJlbCLt5sNQkycOnZJMo7OY5AVi0K3+kBGHZotaOp+JU9069GFmKduQ8maJqiLswVO dRMVSV29eJl5FYSG0YYHOe6KUGWIOgiTUF8eINaermqpTltEeeB+rRriZOsVTE3DOMtjJ9VA SZoEmMmHgiuabA2rIJUbGbPMiFitkbf22IPOn/xtEdshCpz0ZbOPwl1NnWI+DkUkRoOvmIzH 4b6Kw61d0BlQJkDWLCT32r98+vjl/38Mf5LqUH/YPczuvf76AnHwkIPnhx9vZ/g/ac74ZMuA 5ljblapG0ZIWEZ4tOpVsGM3ynbfvcThMveoXmKqJmBDwyTOGYA7JEKIVv17lf6jj0PTWukps +Prxjz8MVVY/a7QXjeUI0vLkZWCtWCWOrfHq3sDrATuCMljW8FeezyM+Sw2cdicPQujAzmy4 eso+T4N4wZdDY/M+U0ry45+vH3759Pzt4VWJ89bRmufX3z9+eoWAizLE3sOPIPXXD1//eH79 yVktV/mKHRsHd9z++WWtKxFNgd11GVwdafTjAgMTywq4LHMmkDUpmJxgd7imZGcfEGsmSqVl O4hjhG1wmfi3EWqO7iXuRlPvf2tinHPasPrE3bwnUhSzPG/VR+FJgaZnM42zHo4Ud4MoJoKN xonyaBm1tIeTK4wLgKkfsX2OhDi7eOTBupZh6qfGwvtuQEXNhCxxpB967gWEusgMhys2LrI9 69NECY864B2p2KFz2p+0Wx8JOZdSQLWSzzEn+ZWbDSVB3+5LfbguMv2xgSSW2Wgakc7UBLV0 liDLozxLOisjQd1miZ09i404WzMtcmllHEamf1xJH2P8rZ9KlGxQdXUtZepm2OcRHt9uzhEp bhIiBWMZvnfqByq9kX3XCUJF2aR5mLuI2oQYpCMV258rTlzcN/7P19dfAy2AJ7AIeGiP+HYP cF/fAKw5i/3TspsRhIePSwwObV0ERtYMe7fvrQh4RvR8QuLKM6SbDq4UTqyUXgT9FejPzqnV eqcMhXYOpZZUZLdLnkquaW83pGyfthh9zANjXCxIwcEZsqeSC0O2cbNU9OlSDLYIZjTN8HcA C8vxWudJip/gLzxCT03xQGAaR741vTkvUP+YB5hF7orzhMZZhCVlvBLjFx+rJk90v5IzE+7Y dWEaBQv2yHTBO7oHm3SsoBIK3pCiZIrRY3CDJfV/Ir+XuN6Eg2n5biLQSe4WcPc+jrCjjgXn Yk++DQj2hX1tvwB1+4Ho++G9PiQYEvMpnZ40wjeFC0tZx0F0bwD1Z8GQuwOoP+d5gIxhXogB mS+7IDB9NycDVMjbN8YRsOBvnY2JANu3GQyJOY8v9E3soaMDE5Dt/TaTA9/jD3kV4Bb3OnBr vE2iO8i80dNQt1o35oMN0lJqFopcQAyNKIyQNqxpl20tWSE+GaBxP3z5DZnxEZnFUXx/rlGl ebMrbik65SlsOl5qZD+03tzeXZdo3Trr6NzeEWpNrzFA4C2sCyVJ7Ftf8mTak5pV17f6dba5 36+jTYAtcOqsyC2UoKfYuB0ew2wguZui3uRDnuJ0/XGSTk+26HzK6zTy+BS4TaabPLjP0ncJ vTt0oC8EmNwX3/J30j5dm/d159Zqduew9P2XL/8S2/o3OhQpwMezK7n9IP4SkzoiU2pF7Vnr nMG12vfb8wz+/OXby9f7BVhuNzBRXFhF26nENVSxufMZtQlod9prlmxzEn5tKASx0l2yXyRV u5VTiW8E9Xuq23N5i9CllwLQJU47GohbsRxL0nEkqaRLXRyPQK9z0VqZVCzx78x6LknIaZwv yQ3z5mKzyXJskX7kop21SVn9luYv74K/4yy3AMtGju7JAWafjXYVe6NNPTj4j9bI6KwWBeSU Mcd4ewjTR7Tbd6SXDtg7GXxbt0aXMXl7VVCL3LeyoRPtWlQC6iJmqkvOrfBuKyNYDkgr9Apc 2SMF+i9p19bcKLKk/4ofz4nY2eEu9IgASbRAYEBqdb8ofGxNt2Jsy2vLsdPn129lVQGZRWLP iX1pt/LLKoqiLllZecEMW/wOCJBXQuzLkJfQJdCFPFUJ7cANOuMaAUglZ1C6zepbUoMYNWnB AhF2qAZCk9ZxiQ86sl5I9tI7N5HGbNOWO+fLUvUO348BqVgGNOT0fslaukIQ2S7e+jD1IBfg aqeulxEjvnfRidqLdLvDH0KT+dBlGtwnVWRWfKzUsZYSFxDulX5pjUwFBe6aVVDlKCJ3GQA5 y9yOmzZQGjVkZZsvTGKdUe8CRYU+GS2NMibX2+WP683618vp9bf9zY/309uVC+D1GevwvFWd fluwee6aNlqp3HndeC/B74vMGUmZVDb0sNIky8U2+54eNwsSeZdhEzIl5rRGjyyyJuaC/Jt8 WRN9kAtAM8GUGQ1gjYWO71NzNg1EifjnK0R8TMpRJyk0goptC19DjmEf66AY2A4+qtzHGWnH MAl3P4IdaNp05Y5jWR/AoMPDI3fM4LNS1JgPJJLxc3Lo9sCxQvYhEp0dXG5Bo0yhHXjTVcxt m0/8NWLj9R09G0h/mT1jj9Im00THdSi3kY6YPKbLNBZwI2qvhjndojq0qPIYMPHFJxZewlnF jhvws6LDA5davBt45jjsR+lhNsaU5hK/2jTu38dsQxI1IAJRc5IOayesHjr821ZaotgWVZRr eCVWnXWV8O5Y3dK0DA5cOIZuRYor5d036pskul2UUZ2Y2UE1/KV2P/42mxS8fbeG61XXZ9LP JIG4Hh90bMc0aptGkmjU2wopoNAUxJQqUkidwpChF5jmb7Nj4NPTO8syYS+CWALrgyUDGGbW eDUS9DxaVDE7prdyB+FnlsIKVnDSLHWb+OyC0AQOpxbod8A2ZQqpmOef73nSCnxiz0vaeWg7 /NuIcsGH67pgSHbjHlRkMO4d9Z+CZPihEbYvNqHFbA9iWx4vgLBXM+KJ3MLZVLjdxFF/SV6Z 8XrHrzPcaJBDhSoo8tCeOzt2bAowz3hnqDqc2c5YEMzEcHq7aj+K/nAuoej+/vR4er08na6G qiwS50pbbKe8KlSjnqF31OKkUat60vPd4+XHzfVy83D+cb7ePcKVv2jKlagKomQW2iQApKA4 4cRjPqoSP7SD/3X+7eH8erqHM/TE49uZi+N3aQK1vOyIXZgV2pzPHqY6+e7l7l6wPd+fJrsE d4EQ+ya+w2zmBWzvfP4IpUCRbRR/FNz8er7+PL2dSafMQyyTyt8efvPJOpTz0On6v5fXP2X/ /Pr36fW/brKnl9ODbFjMfgR/rqOM6vr/Zg16RF/FCBclT68/ft3IEQjjPotpj6az0Ocz/01X oC5AT2+XRzCj+nQkO43t6KhIuurPyvYOrcyE7epV2VWlDVoXieTuz/cXqEdUfrp5ezmd7n+S 6Mw8x9Ab+uSm8pCMVo/o+eH1cn7ANXakcRVSIOHNctr0uEoKIYhy+2mnGjSTpayaIwRsXpTU ZGq3zZpvTVNFvKm1Mgo7xvnmeMi3kOhx8/V7zRlWQSJhHGFB/T5Gq8J2Am9zXOYjbJEEgetR QzINQRJWz1rwXi2YZzbdFpXJ1U0mqvc/KgqpaG2sTUd0kqKW0H2e7k3wezZL98IpejCiV3Ei Zh/Xg3UUhjPu9lbjTZBYTmTmidaILebbB0XTqvGZl23Wtm2N2wiJjR2a4w8hrjWZZ3tg4S/c MIs7mUS6Z2ETAnYM7Wzm+vW47YIezvcjepttv+UxN7TavAkdixP1NcMutgN7/IUFeWYx5CoR 7DN8EaSRr9JermxJQp0NJLLiTllV5rlud82wunv783RFnqBDslaKDBUfsvwYHTKxiGRLNoN5 lubJYidNZ3CD1gUY34Oiqzny2q6NkPHIiUQTujxSw7tpOh91rUNJ/MCOmBTEq/I2X3Gmb4cw 6H2rOw3j0CyZbuQrjhQsfhwXBc6cEIGlmsxsQxjXu+hr2hVGVnXgwASVNKD6/grfOpqItTHw tuvdNoEcqDnrWnQozMdUaXQLNO6Fs6gsRu2K4rReJ5z2HJDj16xO85Tmk1XARLAU5WG4Knb8 CTFqxKjJo6otq2m8eyjXKInj7paU7cJ8rzRNxTly/CQCk4qSOFng03Uik0EUi6xE53RElKU5 bvGnILdYANWLlrN21dhuxN8UZRiyKhQJw+BI0iaG5HglUUT0cDSR17BnGKWm7nq0yCBN+XKT 5VxGnuXuS9Y2O923aKXS9DZa5CmSDVZVclTJwI5LEierkqa2OaGg8YaI9NO2sdh5rIlRni0K OOohs9wkjaooGTVXRZJpICh4hR4Hpvob4Dfd3AgASWkjLlPIBLtU3S+jGMyWs5RXpTMl/gbf bttEy3QUy2mCWyYP/xt867LdpN/EZ2NHwJC7JWsq51iR0d7lf0lUwuPJ4uJfsVg7x71pHq/z OKXbvOTDDSqGMtrIhC4fsOyNOTeI3bsaMu4dXbFLtW35GZOM2XYsqzpdZWzcsY61giyYqsph RBVNNhp8QDNX7lhlsBM7aLVjQ22qGFnjgazpt9icSH5F7fKHBrf2AVy0enqPobW6gjeoo01D 1B4XFWeXCrn2onzUynzc8CraRjI63/iVyu23gTh8EUGGB8MTJvIVShuBWSBbyDQOImy1UT16 IJhFSW2xGDmCYdtmEfacKfIDjsNiDLOs4qeeQmvWJVznqIL4YIKyTeN2PAUWh/ZrLGaX6KC2 2E1WEq/bBFxkwalZDHj0UmoiQfwqOYD7gWlOtXqZJ7r05FMq8DglEUI0XZwpW5nmyQCaeDdB 5jjJJQcijyLzkMpl2FU0oArlCTBw9+fjKqvw91wmyBKoG7jruizS/pHEEEVhokAF4VembCI0 T7tgPaiHBw5FdHIZPqR/hxIlWkfMcWKtjijWnxZf1AB5s5CR/pB706gYWFgoSd58CPAvonqM 7BfM49Uu14wBtdeS0G49JO3eKRliUcmAlqvUfLSCtJHRIJtrK6gxBbWp7/UekxsUJ2X2HGKs pUXa1iR2ayEEqGhbDksCU8M62qegP0EfI9+ARX5elptdNZA7RkiZW0V4fg3aGI4mIy57IUmd g9Aps3PE0mQ+UUoYkD8J2d4U4k0iM4tF4iROZ1iLYGBzZ+oF40YdGznhHrFVXwvjqqJD9jGv ikAsy+wgJk5RTAjSwJKvimO84hbn9Vcxb7cyhoQ+iMePl/s/b5rL++v9aWztJ2prauli47tk 1KT7lqEuxJLdUYeRCbFPIZ6PWO/awDNuOzoFN9eMfmUUEtWiRBdB/RG5WO+ouMItWRCzoI6O BalC12lEfclEP++ErEMsXRSRkau1Dvnpcj29vF7uGWPJFEJXgq8MNv9jSqiaXp7efrCWzlXR CFFKDILjSgZ2qSfyuStGZa3EdjN9BBZixJEejjmj12vK+OYfza+36+nppny+iX+eX/4JWuf7 8x/nexQbRKmXnx4vPwQZUrfi9+hUzQysyoEa+2Gy2BiV8OL1cvdwf3maKsfi6hbjUP0+JJS9 vbxmt1OVfMaqnGL/uzhMVTDCJHj7fvcomjbZdhbH3wuEq9HHOpwfz89/GXXqIjqb4j7e4bHI lejvGv7Wp0ezT6qslnXKRftIDyBTdqtO+tf1/vLcRb4bhWJUzMdIiJBfIhzvpgPq7Hu5jUb0 ZROJ7cca0XWAh0EPo8j9mc/15txtO2GTAumoZghT6PrIn2GgG2EENFC1W9/2x02s23A+cyOm lU3h+6z7ica7QEujNggg5gS8QqxKNeunjG9rMjCg3C2XOKTYQDvGC45Vqjkn6OokyaIQaKXc Njviag/4BnS9wEXJ2hMbBEjVQoKq/2IBDpWhL9M9tYH4qD2Lg1maLggrrU6QO/aJpklBrrvZ G93Nd3uTvpkntyAdcc5tZskhd3E2KU2gWueOaFx1C+LMGRFYLjPvyKKIbNYKXQAONWERFMNd F0GxGPxKxcZpESMHz94kcvE1hRhDdYLlMkUg1zqSxF4/oLDN8vFHNzGGjRb+Faq8r41v3nZF 4R5iAoNT+0c4hMAw8M2hSebGTzNVmiLyZ7LNIf6ysUnAoCJ2HRd1ZVFEM8/3RwQ6bDqiEZsq mpHsJ4IQejgOjiDMfd/urkso1STgRh5iMVB8Qggcn2bejCPTag9dVG9C12bVUgJZRD65sP// GLKoBGmgpW4jPFVm1tyuyWSc2dS4EShz3ucIrGEC/l4RoDl3WSgBx3iAM+dOVQLwZsT8ZRZY o9/HTCkJozrKc6z3JrCxQoitLTB+h0ebUvBEht9zA8d7I1gKhTPye069eoHizaf6aj7n7BCi ZO4FpNYMLhBBrCDnt9gWA8wGMn81Ec1hzVpVBkMH51vHrDLdqrznYsC0acxHolxnoYdd3NaH GV7ssm3kHA664p42aMaMJ+Zt7HgzbsRIBKdXkoR5YBJQRwnhxbYc4qAKJLjg4C78JBSa3I7H 34cDxntcg/KA3EsXceU61oESPIcMfyDN2RRiRbo9frfDkPZhUTmBMze7bxvtZiGfE1t2NcRs 7gNZofWnEN+YHxZNK/oQaR5aOe6s0I7HNGyQ1dG8xqKRwxRgO7bLTXaNWmFjW6PabCdsjOBe GgjsCUNTiTc0L6aizeZYelW00KUGIJoahJNNbVRUMbNQIYTpw0SPCrzNY8+nqX33y8C2Jufu PqvgohqSYU2x6HPRYYT/p4aJy9fL8/UmfX5AOwfs/HUq9rA8JVvRqIQ+Pr88irOVsfeEbkCM KNdF7Jme9/0Bu69A6Q9+np5kbFTl0YmrbfNICL3rIXfFsJ5KKP1eaoyV+dIAr+/qN5UlNI3q ieMmJItcdGuaWMAzszqDc8+q4pNNVw2WbPbfw/kBd+7opTkhr7topSILw/EheMwh08d2Jb+u cp89P3Tus2D4F4sj/OWZZhPTQqg6ftCAZwY8HDCGLBhs/biJRdO3Tn0PpcZpqq5c36ZBwQXy aVOhToFmsdGmCKfSnQ/6gtEzDAGYtovHyHgxMP2xtKmrmoxiXt6p2TRlb+tbAR/fQUAum+sQ ABq1Q1A8h9/PAPK4JVQCSKwXv/25AyHdmnRENQhubTzdZ+25BBA4Xm2KZ34QBubvMc88MM94 gjrzOYM9CYSk+CywzaKsdwkAM4u+n5IFsQDnWpxAINa+kJ6MY/CRjVgxrCrbIwmilTQeSWMr xBybnGNA7gnw3lsEjutS6SI6+DbveQJQyNooCpHEm2HjRCDMHboti6ZaoQOBNU2y789skzYj B2FNC2xUpdoHVQcgW+4PJknvTvDw/vT0S6v/6NaV7Iri2zHdr9KtMSlVGkmJTyP6LouqXAhD r2Ai5tKkQbKZy9fT/7yfnu9/9fbo/4Y4lknS/F7lead+VpcIK7D2vrteXn9Pzm/X1/O/3sFq n5jAdyGDyOXDRDkV5ePn3dvpt1ywnR5u8svl5eYf4rn/vPmjb9cbahd+1tIjmaIlYUaCmP+n dXflPukTskr++PV6ebu/vJzEODUlAalsssz1Dog2u/92WDAu4Ewsp4e68XxDR7SyWeblIWoc cdDAW8RAo1sHopPVDW2jq291eaQG2EW1cy3fmtCl6C1HlWPVOBKa1vJIGCt5hm22XUFAPFZy m/5QSqw43T1efyIxrqO+Xm/qu+vpprg8n6/0uy5Tz7PoIVqSuFUa1NiWjb2RNYVknWWfh0Dc RNXA96fzw/n6ixl1hePaRNGTrFv2GLeGY411YL/ueldkCYlxum4bx7HN33TYaJqhYFu3O3Y1 b7KZ0lENIqqgmGlBuk4wX1gtsmJhuUIM3qfT3dv76+npJMT+d9GBjJMWH+hQYwEzST3WxF5j oTHpMjHpzIFvwrxx8/JQNuEMj5COYkoRPX3CSro4BETPsYcZGcgZSe4fMEAERgRw0mLeFEHS HKborPTZYR/Ud8xcsrd+8FFxBfAhjsS7EFOHDVCFKT7/+HlFk4XatkU5a3ycfBHzQckHaGjs QIXDDqUc5jXakXIXEtOT0lXSzN0JpasEjRzhwxBa27MJ7zaA2AuEuHAdGzucAIGKYYLi8p7x EEjeJ0WDAOuc8aFNGg6BORIaG6vKiSoLq0wURfSIZS3Ng6k8vDS5M7dsNqE5YcGR7STFxjIh vo7Ix1lBFQJtZZ7zpYlsBwt/dVVbPl728ram4eL34pt7RmaJ6OB5vEO8htDhZVtGMsYdKl9W 4E/PLZmVaJ5MMYBTrGe27br0N77GatqN65KM6e1xt88ax2dIdA4PZGNJb+PG9Wz+8CexiTic 3XdsxVfzWVWlREL0OkCY4bs1QfB8F3XArvHt0CGSyD7e5uYXMECXtwfap0UeWKx4piBs2rTP A5tuBN/FtxNfyGb3MLoIqegzdz+eT1d1c8Ls5ZtwjuOgyt/4UmRjzef4/KJvAYtotWWJpiJp AOjFVLRySbhCNHOAO23LIoWks4b8V8Sub3g70xVfPoqX7rrmfQQzN3y9XX8R+6FHhDIDmhBL TS7SER1YF64RwZgin9StmbpJ1IUT4r69GhXvj9fzy+PpL3LkkTqoHdHIEUYtEd0/np9HA4pb A7NtnGfb/kt+fLOrbuqPddl2udTRfs08Uj6zSwxw8xs46j4/iIPy88nUj61rmQmg08lNDB6Z irHeVe2EcQDsQHlZVjwszU45rR/fQi0yPAupXMbKvHv+8f4o/v9yeTtLR3Xcsf3k/pydnBxf Llch2JwZwwXfwetd0tgkZiuoRzyiXAEC3uYVgd4yxZXHb62A2K5tMvsTTpeSnXdDbKvcPNdM vCvbD6L/rziFRFHN7S5my0R1qojSI7ye3kBYZBbRRWUFVrHC617lUCU7/DbXRkkbia2dyLOI aiRSJ/labA1kMUwqITp+Yi4h8wUSCaWaiCSRxRX0OitSVLlND3yKMrEmaZCu91XumnU0fjAR wwkglwv5qpfq7q0YKntEUAhpUOt7eMivK8cKUMHvVSTk2GBEoNV3RGPZHY2U4YDwDKEEuENC 485NeQHv6aScHo6Xv85PcF6FBeHh/KYiTDB1SwGWj/2SZwk4r2Rtetzj+b6wHTz/KxXsrpNY lxDsgqYAauqlxQtrzWHuTmRAE5DPDjioDUngIE7J0K1ILPLd3DqYkT8+6ZP/OG7E3DizQySJ CSXQJ9Wqzer09AJqSnYRAY32PKSrcFYcZS7PMi53VY5uHtAMb9OC+DQV+WFuBTarKZIQubEu xAGKKAMlhZt6rdjhqEJfUpyJJHrRwbVDn4+IwvXDUHTb8kF19kU64QOubPKHH33uA0SSbhuU FLUFOBbmcRKPqxh58wBx2eTHZWtwynRjLmXMq6YxuZqGOiUN1MEnabDHFaBM9jWRvEu+JZgw jOyIs/r25v7n+QWFl+zWgfoWTPmRT7p4m4yYt48K92WrKN4cVTbQQS0gL+dbCPs2ZeUl0+xC 2pe4jTirQbEwp60MDFeXeY5NPBWyqOOiaRf6It5ElVHN6isJZCyRNoNBEHNBv9ffbpr3f71J 2+ihc3ToVZoeFRGPRQZOtARexMVxU24jmf2VloQSOs7zsS3rGsxJ8edFMNTJf2PE1GRCNuWz 8RC2KN9z8RWABwZvVhzC4lancCU1FNlB+vbpl5yoozpERyfcFjJ/LX3bHoLOMGuPxViuzNST 9PlRVa3LbXoskiLgk78AWxmneQm3ynWSNmaPSi8LlV138jmIJ+OEF+BpBS5DBpEX1M6RZbEo OUAmikVTiY6znh8cJ0VfjJ0z66hiXaOTPBUcX5RDZy8iI51kocL1UfF6Af5847F/eoV493JT fFK3AFwU2o/Y+gkYke6HVMajx+GIRd2Ss03qMkvYbaGPZtQLJ4vtPskKtN52me1lyOBBwQXR nzdEW95yPrLl0og1nEQHHUyP0GjsBIiNz2nyunQ8+Ge/86grlK8319e7eym6oV7u1saW8/NT g6FFOYs7it49jGEj6KZr8phj1a4/ZiiaaXdgeHLLhB4RdCamQHeZMn71rlaII4XfQ7t4VbXY JqSZCHeDIcoci1XdMxvSvInHeyIT9bA2GJu4Jum4sjj11MHsF1NHEcXrQ+l8VMmizpJVyrzk sk7T76nGmdK6fRVoQ5TMVxsvqUIGDKNDjGlMp8zJEm2ZHeW4LFKeCq83euUOm2wz4ZpqxjFa 7hgqCcu5bGiHN5nMCgwzcFsm7KMFSxE17ZATcQwQJ2FEj5oqTRMKCYHh/yp7suW2kV1/xZWn e6oyM7EjO86pykOLi8QRNzdJS/ILy7EVRzXxUl7OmblffwE0m+wFreQ+zDgCwN4bDaDRQGEX 0swTfMZik1WR6QiaJHq/wz+592AmeGTaGBsApnczXSAZljbuIWHRoXPl4tPnk0B6P4VvjmeB DE9IgKPEKQaAorjpvOHPa32TVVaUXfyNwmGo/CbPCiuTPALUURy1Mrd5nYz8+AVDfFy+X1XT sjzIeaGmnFH2GHiPzmRD94oj2NNJv67Q15SyNRrx6AUqyaAgpw162jfmWQGgrCrs0zzZtCeA YEYBMB97Jx+gAoFY0GQwfREffERTNUnUST5NJZDM/LJnmICyB92CWhUqexZsgUOj67deq81c 1YpgK4riQOk5pq3y5zw+MVuIv4NB6KG+Yk7zYkv3mAYScCkv4v0ZRm08lJby0+bEGbsqUjDO f7ZV1RuGvAEyjaGlJGks9ARUKFzhC3cSfWLZlSDMwxhuey/HiUMdDuyj8KLBxJkHegKDmvYg AzlpVsosDw5CeqLGwGTXCGpa0R78ot+ItpXedz/dAprqwBYgEjXITMtUjgIlSPMxd3QVGA0G 7YWZnX1Co/Mr/vH+hOftYBp/1bCZha9A99HryjgCA7Kns9jGnYev3F0uoGAgIVcwMlXNTk4G SgbirbwRBQjr+GxiG8BDoaB0ym3dWhKJBQbBZ2FPRkNLjZ/Bhkn2o0CsdEoYlcvarEEEP7no qtaIaU4/MbsKPcynswdfTBnanQTgQLYWslTdH2tSiBADU9gWJD5zSi/Sou0vOVuswhjGOSog MkOPia6t0mZmcR8Fs0ApcX0zCEpnui0PGVHspVbBrORi62zeIUbyzXczxWjaeGx5ANH+ZxfY gF9mTVstpLCkLIVyThENrua4Y0EXNEM9EAoXpdnHETYWNYkPE25sASsyDF1V3Y5/k1XxR3wZ k9QwCQ2GYb36fHb2gWd4XZxqPqQL5wtUV1VV80cq2j+SDf6/bJ0qx6XdOrytaOBLvgGXI7Xx tU7WEoFAXQvQUWYfP3H4rMIYPk3Sfnm3f3k8Pz/9/NvxO46wa9NzkwMNld7bEKbYt9dv50Zy 3LJlTm4tyB0aHGXYeNm93T4efeMGDUN4WONAgNUQe2oyDiH0sggooIRFi6K5HQmIowgyKBzV lXRQ0TLLY5mU7hf48ERGS9otnduwqO7I2mnJxatElmYXHAN3W9T2siDAQZlOUXin8bJbADuc swuqSFSYqwRDmRkRhPCPFgf0rKfZpZCaxWizkj9JY9GYFog2KMVbM0qqJOYOcxiciD3xYwD1 cs20XKRu++h8cljgCBwylQG35y5XnbbA7zrv3JN7noQF0XlIEHW7+Wc6SKYeZGBxHzz4Go7W xA39MGExR9Mo6VnYpisKIa2jd/yMVgnny0YEhryEfmXwp3ELv7JSaisYyFEuiNw0/BbIbp7x ERWHBhTAzPoSBKhwG4kEjvNq0F/YIjB11U/rScVl1UlHCtR7Ac4Ve1kqiBK+4uSSLX2gKVr+ Kq256ESz5Fn8xlnXRVbCjndO9iK03pa18/lFuZn5oDNPLh2AwWTlQ5XGdQ1BMGIcxv3YqvGw 9DqHIDQYXkFVy2X8U2SwIHVFmsNStD33Nx5POar4eikbl3mKAKZ7Qrpfg8RvIqcTZUQvo5GA v5hQlOezE5bOpkIFItyYIMLtoz6T2RZXHtmhdpsD8Cv0Vg+4D/gujS1+d7v79uP6dffOIyyb KvenFyNreUAUQt1pRiXMA6qrBQ+G/2GMw3duKxC3wlheyE6+nM0YdCE2cMZjrNIpXo2Brg9/ PXRzpJg4xba5DAij3hZWEHVeBD7wxOhEViFWgmkjm9SpAzSrdSVX5sHO3aPkxmKFH9M0G5Ln VGbejMJrP2OdhCySTx+N4Ag2xvRztTDn9nsnB8fb0Rwi/tbeIeIfJ9pEAWd9h4h3o3KIuBAJ DokV/M/BcR4lDsmpPZEG5iyI+Rwc6s8f+QArNtEpd1XslHMSriMQmMRu5KdQ30EDxBXanwdW 0vHJ6YfgkAKSswMgDWXrtYdMV3XslqcRoenV+I92GzV45o6NRoSXsKbgXk6b+E98Dz4HOhZo 4PEs1OPjcBNXVXbe8/cFI5pP64XoQkQoQghe6tQUUZK3GedDMBGUbdLJym0/4WQl2kxwhsiR ZCuzPDf9LDRmIRIeLpNkZY8igjNoqShjBlF2WesXQ13PzND6GtN2coWJwy0EmQBMv9Scu9ju ygxXvuU0oEAgustC5NkV+X2Peb05k1/Vry9Mk4p1naOCJexu3p7RA9DLRL5KtsZBg7/gDL7A VMe9Z8+qE9lkcGCVLRJirt+AKjeUxCJb2UERcZhgMJMeIsGg+fES9KpE0uiEqcjomUU+lRYO Bss55qluyE2qlZl9y3bAuK5RtnZDbIzSM+CezEXAsk4hiSkkdAl97Sj9db3tMcNzJJTZZDJA uGScNbGSZPltQBEzzbVoT8ki+hJVtWWS16YazKKhD+3yy7s/Xr7uH/54e9k93z/e7n77vvvx tHs2xI6sEGoMEnRh6dHvcphdTInFtFFbvKZhF8aGzZviyzt8uX77+N+H9/9c31+///F4ffu0 f3j/cv1tB+Xsb9/vH153d7iW3399+vZOLe/V7vlh9+Po+/Xz7Y58gqdlri6Rd/ePz/8c7R/2 +L5x/7/X9vv5DG/lYByiFenL5sUrIMhcD3MyNt6+AdE06MRgkLAmu0A7NDrcjTEgibuPdUs3 MPak1ZnJdZpt6UaTV7AiKaJ660I3pqlOgeoLFyJFFp/BPomqS8PahRu20lf20fM/T6+PRzeP z7ujx+cjtWqMCMxEjFcgKioxBz7x4YmIWaBP2qyirF6aa9xB+J8sRbNkgT6ptJKIjzCW0NAm nYYHWyJCjV/VtU8NQMPWP5SAmqFPCoeXWDDlDnD/g64JU/dx1hCDU3fZLtUiPT45L7rcQ5Rd zgP96ulP7Peua5dwQnjkFPXaJW6ywi9hkXfAdxWb21BYGWUsf/v6Y3/z21+7f45uaAHfPV8/ ff/HW7eyEV7l8dKrJTG9YUYYERomrgEs44Z3X9Fj0cnL5OT09NgSy5U34dvrd3yTcwOa/+1R 8kBtx7dP/92/fj8SLy+PN3tCxdev115noqjwJy8qmEZGS5AGxMmHusq3bn45d1Musgbm399+ yUXmMQ3o/VIAD73U8zCn0CV43rz4zZ37Ex+lc2+go9ZfuRGzTpNobpslCZqz1vIBWTHV1dHc n+wNUx9IJGsp/C1bLvWw+vwgBpGz7fxpQtvyOGjL65fvoTErhN+4ZSEipucb6MihdXhZCN99 Nt7f7V5e/Xpl9PGEmS4CK2dJHslDYZBz5CjeMG+Id7vgeS5WycncK0vBG3/FyKg9/hBnqb8d 2LNhnC+3oCKeMTB/XosM1j35lvtjJIuY2z8INqM9TeCT0zNmNgHxkQ2YoPfjUhz7mxQ2+ekZ Bz49Zo7apfjoA4uPPifGG/955R+d7UIefz7x6Ne1qk4JFPun73YSB81p/C0GsL5lxAoAl9mw 7LwzpezmGVOUjGbMAqrWacauOIXwQuDpFSYwoUnmHx6RQF1LfcTh/LWDUH+KYmY0UvrrtWW1 FFckTrlLpsGEa4fWjD4GuG+ThHPhGbGyVs89WHjfNMlJf2pGeRtX04w5jtqEzYA+INcVTZG3 1hQ8NNgafToJBdHj/RM+W7TUhXG86erAK8a6whtg5zN/iedX/uqiWxGPEm8G9F6Q1w+3j/dH 5dv9192zjvC1t6Mfjsu6yfqoluyFre6EnFNc2c5fTogJnBMKB3zxJwVz5zAiPOCfGeZdTfC9 k6mXGJKom8LEQXmtCRJqJSDc9JFU2o5NLhq1j0NVhtx+DPUCGFLq6k0/9l+fr0FLfH58e90/ MCc6RtnhWB/BOZ5FYXnUwacfbzFbyqAKNxqJFA8YS+JqUyQ8apRljbYcImPRHLNDuD6XQUzH e6DjQySHOhCUx6beTbIwSzQepO44L1lfjGZbYAasLCKzVbutbaVdI+tung80TTe3yTanHz73 USIHi1fiOWbXq6g5x/v+S8RS5kmG4tPg6MF//4k0LfzYMCFlC7RN1YlyiSRXisHmNq5tDC31 jbSUl6Nv+HJqf/eg3rrefN/d/LV/uJvWuboVMy2F0nKx9PENXjiaN36ITzYtPnqZBoR3JEjg H7GQW7c+nloVDfsE07w1LU+sXdt+odO6T/OsxDaQb2X6ZYyeFWIFygxjmmc0pJ+Degx8WxoX /HlWJkL25DTkmCrJe5Vzg85AYoOZbIwFph9+gjBXRvW2TyW9GjSXiEmSJ2UAWyYt5RRsfFSa lTH8T8LQzk0rfFTJ2GQVMFBF0pddMU/MkMbKHmy+iR1fq0bZ+CzBQTlg8kID7tynKJkNb1Iy sx9Ege6ksDHhmC2H4CwWS4pAuYZTzQIdn9kUvsoBjWm73v7KVolQF9KXATYXJwxwh2S+5d+6 WCS8P/ZAIuRasDfgCm/PjIzOLJ3HPoGiT+Y6nPtqYWRoOoM2Nw10F2etz6hhIcdVYQ7EiDK9 RaZGIRTfjrlwdMHCM9gW5K7UCeNAeW8XhBolG/AZS216vUztQGqulIBXC4E5+s0Vgt3fZOYy dv0ApVe3bHLZgSATZzOvLGGmCZ1g7RK2IlNJA4fIgSrm0Z9eafaETt3sF1fmO30DMQfECYvJ rwoRQFQBuNFlzSDMOxm9BEHb6ZsqryxNwoTiRdZ5AAUVGijysb8UuXKLn4ZDSCm2igGZwkBT RRnwm8ukJ4IJhTwLeJn5/laB8LFDb/E4hMfm0JTUPEo31APjXphvbQmHCCiCpFpTNkFWiDgR x7Jv+7OZxRwQg571+MTCOMDXWdXmc5ssouYok9Lu2/Xbj1cMFfK6v3t7fHs5uldXJ9fPu+sj jAv8b0MsxlsokPb6Yr6FtTP5f46IBg0tCmnKYya6TiReTItFIOusVVTA8dImYp+oIInIQV4q UBk+N66HEcElJNdDtsjVMjQG7cI85vLK2n74+9ClcZkPTs6aA8luvPDVbc2v8BrTWKfygnKV T5Ciziwn1jgrrN/wI42N5VBlMT2GbVpprNsuQlfb1hby6HpUb8DLuKn8bblIWvSNrdJYMOEp 8JvePDstREvig/kOoEIrhEqJ6UDP/zYPbgLh+xIYXSv+QIOBDCpzdJLCfZisPdyj1VqYGWcJ FCd1ZZYHO8l5RqkGiZ1XIzKSIzTaV6Ra1ibo0/P+4fUvFRfofvdy5/sHkEC66l0f5AEcYYol VpUevPHyapGDGJmPN2GfghQXXZa0X2bT4CklxCvBcO3DW2bdlDjJBf98MN6WArN7h58EWhSh 1/Yg680rVL4SKYHc2CjqM/jvElOzNGqghtkIjvBoX9r/2P32ur8fdIIXIr1R8Gd/PlRdg9nA g8HmirsosUx7BlafcglvtzAoG5B4eW9VgyheC5nycuQiBu4TyawOPNJMSro+LDq0feLrRM6h QcIo0wuzL8cfTmb2LqjhIMTAEgVfvkxETDUAFUuwBALMkkiJ6HM2dR91tFEvI/EtRiHayDgV XQy1tK/K3OBFqgt1RSe8O2FpBUdOv07EinI1RrWVx/SXlwYtJDIE7m/0No93X9/u7tCFIHt4 eX1+w1DOxiIqxCKjhzvSUCAN4OjHoKbpy4e/jzkqFceIL2GIcdSgL1EZJYZD8ND5xmH1xBlX sG7MtYu/OWuJ1tC6eSOGJ8F47orcemRMWJZH/tJw2Q3Gx0ZJ7m8sfKTj3YkNjh5juQY/RZ6W bFpMCmQ7kqjiEE/nPOf5jd9W69KyyZChpsqaqrSOTxvel9XwcPqL66g00Vwlkn/EO7UMH0Uf IJFVLPB1Jy9yjLOmiNcbd0OYkFFtb+OuMARX9bv33qkp8JCGPrib1bvJxq14ADPqpI1PlXzu 9FpjKZzqT+vGeAqrcCEy6og3HRhlTYoia91xUSBY8oHl6mN03NFN3s01qSGpEJhM2M5GHbYD CDc5sC6/JxoTZqnkadXh6W7JNnAOxAMyKePgsaAKuSz8mi8LuqFGKfbAd72cs5/WC1D4F9z8 OQsX9ZnO5Hsu2OUQlJ2YHMUOzOoyWyyBMuQoaAwdPkpO82rtNiCAjCJq+0ogq/Rt3gqLi1Lx iYmZgkJnGRdUCVQLrB7XqW3idW7PmiUG0PPcBpD+qHp8enl/hKli3p7U+ba8friz3hPX0KAI Pewq/pm+hcfAJF0yqYAKSVpC1wJ4Wm1V2qK/XFezKS0tz8tfoVPIftnBILai4Rbu+gJEBBAU 4sq6ViJ7uqqCPasOD5Ry7wX54PYNhQLzxHF2Vlj8Jbx3WzU5HTKlu3OMI7xKktoxJisrNjr0 TEfs/7w87R/QyQf6c//2uvt7B//Yvd78/vvv/zICf2JcBip7QRqPq5jVEla6EX3B0EwQIcVa FVHC6IaM+USA/Q5yCzSbdG2ySbwjo4Gu2q/ohs3Ok6/XCgNstVqTc61DINeN9cJXQamFjtqv Hk3WPp8ZEMHOiLZCJafJk9DXONJ0Rzqcg9x2oybBLmjR69c+LKdOmvZprZb+P1aBLrCVmKoX uAdxZkdbJqTZD5K/YbD6rkRfBFjyyk58gOmu1OEYYE5/Kenw9vr1+gjFwhu8uvF0sSEIgyst IfhAzU1AEyWk8lp3hIlJ66WTuidRC+QgDM6eBRyOD/bDrTUC5TEp28zJyqLcDqKOlWbVZos6 ZgeCIOOOgZ5WdvXgByDSpI4rJ4KtD4w7D8LhMuAeuwIuuTDf6+mYxFZX3EEAJq30Mkka2YFJ UqFjQJTHWGz8VOMFQhlt24rblORHMK1kn8WVFFUfUNKRwNKuVKrnYexCinrJ02iDR6o3URjZ r7N2iUY7Tw5kyOJM4imIZiGXfCArSFwlB3IZOyQYSQL3L1GS0uwWEg0fqlImpCo7shkymcrc V/+UwI/oLXUJ/rQ4lQ10I/IHrQbBv4BtBoot2zivvAFgTOq4KFJvxVo7J4tBx1tG2fHHzzOy CgflxkZg3sGfCKwUfzNr6BBZJ6Mb0d/nZ9x+thmuvyQ352f9YOQi41tnaGaJkPlwgW1pBSa8 j+eLmu2MRYWRaDdxwBc1STOQ1VvMtxg+6zBaR96ZV4m0fjCcX2C3YdfwHijGXTnpgdM7j0qZ GPsPm3P+9alBwXrCjfiO/rCFu/EaXJ5DBk8hRcDsFdVM5CWnDPSy4t4PqQEg20xtuIPVFLMO ZQc3GFFXrrMSh8u1co2s1l5lph263b28ohiAgmz0+J/d8/XdzniUhnWajF4Fzgtr91Ngveng ULBkQ7uExRGvsYPx6ZMXjbyUqmWIjGaMR8ETTWVUKXGpcHnOa3AVypOh42yimrkH2+eEdLM4 j8jyJhd8uGlEKhtPyPxEFIVYJfqFoFkpoLJqVLScSqHZwF3ZIq3GmrZBt4DSi1BnUxRFpNsV ILKrMk7eNMt5A8qgHIPaG1WXA3OsLYdICccQ3iS1Ss0gV0qmIGDCIz+xH3vxG8F7EaZubf4P ajDB32aJAgA= --1yeeQ81UyVL57Vl7-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kLxwH0wXMF/+7AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 09 Aug 2020 17:33:32 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QBq1HUwXMF/YcgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 09 Aug 2020 17:33:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5FB4C420C1; Sun, 9 Aug 2020 17:33:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726241AbgHIPd0 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 9 Aug 2020 11:33:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:50264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbgHIPdY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 9 Aug 2020 11:33:24 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7FBB72068F; Sun, 9 Aug 2020 15:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596987203; bh=iOSdODAAWXGtqLlfX3lddOiL36z3fqOcdMKbzb9GFYE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mSF7JZ3NrODn76MM+8wp9ysWjXP5mhr8DiPqxZlAmCQmM9wRTcMDxtqIVGwnIux9d xQwc+4/vRx+ygs5KIC39D81m4EFM90J4h+CMeAiyMb5EEDXPW/AsYD2rPq7XLBkX9D 1cUSHm8+A5SGDIk8bivlPsVZ3XmDXUHmdkjn1blg= Received: by pali.im (Postfix) id 45DF17CE; Sun, 9 Aug 2020 17:33:21 +0200 (CEST) Date: Sun, 9 Aug 2020 17:33:21 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org>, David Heidelberg <david@ixit.cz> Subject: Re: [PATCH] Install avinfo utility Message-ID: <20200809153321.gywj4elkefrcusvz@pali> References: <20200506193435.3746-1-pali@kernel.org> <CECA6D9A-0F26-40E8-BFDF-A24CD972307D@holtmann.org> <20200610093306.zt3q3s2wmwp3almw@pali> <7672C0A0-AF6A-41B2-B50F-7836B3E5CC73@holtmann.org> <20200611125304.b4mxxuv7rupamfmg@pali> <20200713090913.6duirl4yhrjcyxoh@pali> <20200808132042.mma5ykynagwx3ubd@pali> <CABBYNZ+Ep6njp9vfEZrFTGCiSMcsdoPnPa21H0ApJ1O3tau_MQ@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <CABBYNZ+Ep6njp9vfEZrFTGCiSMcsdoPnPa21H0ApJ1O3tau_MQ@mail.gmail.com> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5FB4C420C1 X-Rspamd-UID: c62cfe On Saturday 08 August 2020 22:33:48 Luiz Augusto von Dentz wrote: > Hi Pali, > > On Sat, Aug 8, 2020 at 6:20 AM Pali Rohár <pali@kernel.org> wrote: > > > > On Monday 13 July 2020 11:09:13 Pali Rohár wrote: > > > On Thursday 11 June 2020 14:53:04 Pali Rohár wrote: > > > > On Wednesday 10 June 2020 19:31:47 Marcel Holtmann wrote: > > > > > Hi Pali, > > > > > > > > > > >>> This utility is very useful for determining which A2DP codecs are supported > > > > > >>> by remote side. So install it to system as part of bluez package. > > > > > >>> --- > > > > > >>> Makefile.tools | 4 ++-- > > > > > >>> 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > >>> > > > > > >>> diff --git a/Makefile.tools b/Makefile.tools > > > > > >>> index 9b9236609..d52721612 100644 > > > > > >>> --- a/Makefile.tools > > > > > >>> +++ b/Makefile.tools > > > > > >>> @@ -176,9 +176,9 @@ endif > > > > > >>> if TOOLS > > > > > >>> bin_PROGRAMS += tools/rctest tools/l2test tools/l2ping tools/bccmd \ > > > > > >>> tools/bluemoon tools/hex2hcd tools/mpris-proxy \ > > > > > >>> - tools/btattach > > > > > >>> + tools/btattach tools/avinfo > > > > > >>> > > > > > >>> -noinst_PROGRAMS += tools/bdaddr tools/avinfo tools/avtest \ > > > > > >>> +noinst_PROGRAMS += tools/bdaddr tools/avtest \ > > > > > >>> tools/scotest tools/amptest tools/hwdb \ > > > > > >>> tools/hcieventmask tools/hcisecfilter \ > > > > > >>> tools/btinfo tools/btconfig \ > > > > > >> > > > > > >> I had no intention to install that tool since it is too limited > > > > > > > > > > > > Sorry, but I have not seen any limitations with this tool yet. I'm using > > > > > > it very often. And also other people who use it have not mentioned any > > > > > > limitations or problems. > > > > > > > > > > > > So could you be more specific what are those limitations? > > > > > > > > > > > > Also it is the first thing which I'm saying people that should run and > > > > > > send me output of it if something related to A2DP does not work. > > > > > > > > > > > > And because linux distributions do not package this utility and bluez > > > > > > developers (for me for unknown reasons) decided to not install it, > > > > > > result is that people have to always compile bluez from source to run > > > > > > this utility if their A2DP audio does not work or "remote" debugging of > > > > > > A2DP is needed. > > > > > > > > > > > > So result is that who want to know why A2DP audio does not work is > > > > > > forced to compile & install bluez from sources and not to use from > > > > > > distribution package. And this probably not the expected state. > > > > > > > > > > > > In any case, nobody reported to me any limitation with one exception > > > > > > that it cannot decode capabilities of some custom vendor codecs. But > > > > > > most of them are already supported as I sent needed patches in past. > > > > > > > > > > > >> and makes too many assumption. > > > > > > > > > > > > For example which assumptions? > > > > > > > > > > that nothing else is happening right now. It backstabs the actual AVDTP and A2DP implementation. > > > > > > > > Marcel, but this is not a problem. For that one purpose which avinfo > > > > provides it ideal and works fine. Personally I do not see any problem > > > > with it. > > > > > > > > > >> In addition it has a bad name with no Bluetooth prefix. > > > > > > > > > > > > So, lets rename it. What about "btavinfo"? > > > > > > > > > > Lets extend btinfo with all sort of capabilities. Make the av portion just one of. I want to remove the multitudes of test utilities anyway. We have to many tiny utilities that are just scattered around and avinfo is just one of them. > > > > > > > > This looks like a not-so-trivial task and moreover independent of > > > > providing current version of avinfo to users. > > > > > > > > avinfo already exists, is already part of bluez project, it is already > > > > compiling during bluez build and is already used by me and lot of other > > > > users and works for that one purpose as expected. > > > > > > > > > > > > > > > >> If we think it is useful to have such a test utility, then we need to clean this up first > > > > > > > > > > > > What exactly to clean up first? > > > > > > > > > > > > Note that I have already done cleanup of this utility. > > > > > > > > > > > >> and put this into a larger btinfo work to gather appropriate information from a remote device for debug purposes. > > > > > > > > > > > > I do not see how btinfo can be used for A2DP purposes. Seems this is > > > > > > utility for local controller info and not for remove A2DP. > > > > > > > > > > This needs a bit thinking, but pretty much simple things like this: > > > > > > > > > > btinfo local > > > > > btinfo avdtp <remote_bdaddr> > > > > > > > > > > We can create a module handling system so that you can easily links existing tiny utilities into one. > > > > > > > > I'm not against this change. But this is additional work which needs to > > > > be done. And it would not happen today or tomorrow unless you have > > > > already patches which implement it. > > > > > > > > As I said avinfo is already there, implemented, it is working and is > > > > part of bluez source code. And is basically the first step when > > > > debugging issues with A2DP audio. > > > > > > > > So what is the real issue with not only compiling this avinfo tool > > > > during building bluez but also installing it? > > > > > > Because nobody presented any real issue for more then month and I'm not > > > aware of any, could be avinfo finally enabled during installation? > > > > PING, two months passed and I have not received any new reply to this patch. > > > > If there are really no problems, could it be applied? > > For the record I do intend to enable listing available endpoints in > bluetooth-player, which might actually get merged into bluetoothctl as > a new menu, Will it provide everything which is avinfo provides? > recently there have been some vulnerabilities reported > against these kind of tools that are meant to only be used for testing > purposes Could you be more specific what is that vulnerability, so we can fix it? It is the only issue? If yes, I'm going to fix it once I receive details about it. > so I would only be in favor of installing them with we add > some new build option i.e. --enable-testing and document that these > tools are meant for testing only (and shall probably be package > separately) so we avoid these pointless reports for tools that are not > really meant to be used in production. As I said, avinfo is required tool for debugging A2DP audio transfers in case there are problems and probably it is the only tool useful for such purpose. Lot of users are reporting that "audio does not work" and the only way to debug is, is to ask users to provide full output of avinfo. Well, it can be classified as "testing tool", but highly required in case audio does not work. So please provide information about that vulnerability and I will fix it. As being silent for two months about existing vulnerability is not really good. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AHAXABY/MF+1CgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 09 Aug 2020 20:23:18 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wDbjORU/MF94uQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 09 Aug 2020 20:23:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D6E98A020E; Sun, 9 Aug 2020 20:23:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726291AbgHISXI (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 9 Aug 2020 14:23:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726266AbgHISXH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 9 Aug 2020 14:23:07 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 850B6C061756 for <linux-bluetooth@vger.kernel.org>; Sun, 9 Aug 2020 11:23:07 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id k12so5629740otr.1 for <linux-bluetooth@vger.kernel.org>; Sun, 09 Aug 2020 11:23:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=o2lF/nlQ8cjk+f5euqbhqvYXb0X8Exdt9M4jAdEQkgA=; b=ag5QUjFLFM1W+f/jPKULcmBJs7YbpCmphgN86+yfECawJF3YcyLo+zOD70CADFXjJB DOfCF1U7Ib79cbKKo3AaUk7Bysprqr8xdFfSzx+Ud3idTzXLfe02kGhwmy8Y60IG5WWD Xaij+oJdnDmbC3rKsPtcWLctNI7WeG8lC2rkKujb3JJfdaV7mgYeQRVaVOCDv5w0U5M3 xK4ODb1gE8cEV8NMmGN38rQilc4jBXxKPP1BO9nS5nRm6WDqp6NMpkclQeGu1vH2XnV9 Yowjsck3S4FaZXXSLqvkQjjJpdPDkpsUGhuzSxqE6x2W8Sy3VLV3VjBNU8RRVS5X7zv9 EeFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=o2lF/nlQ8cjk+f5euqbhqvYXb0X8Exdt9M4jAdEQkgA=; b=Fd93BtX9H8aC48ACYcY5q+8wx81w42uiprvWohgmXpBm/bzywnjXPHm/sc0ZfGMS5v KWH21Bp15sAKup4+rWFuUPk+reI+W3riMvV2wJrlQIOlSXeRV/fUFdwV6BoOywRHs/ow yXKjYKdBfjHj+dcuA9HW9rggYPNdn73ld/FhEMVzZ6DgTVksyF98N+jn9QBqdRyEYDwX EaXQjpR0uhTJyhoql+DKiqTI5y9I8WU3MnLdVEzdJWIhEGVN7uWO9XlmAK4GsUoLxLUr qVx4p48+klV8W93rJhquiwfcAgT0jNhygbVy3GdTgeXDS9eM11VfLJJQ1w+5Bxh+lmyD DHrQ== X-Gm-Message-State: AOAM532VJQ4mdvXF2qEF3sXIEYIzp1lQngXMEky/koBM5iqT8I6kcw4N zyISS45tWsuw9YRYvlll/j8o/ebGy2nDGo21cyc= X-Google-Smtp-Source: ABdhPJwoSYTyt6oAfIWSvm6hswkUc5O03kNJ0U97PRNcIwHW5RbcPNwL/WQ8xtLA8aTu961N0NEs72icrSIP03Lsvbk= X-Received: by 2002:a9d:6053:: with SMTP id v19mr20193915otj.362.1596997386134; Sun, 09 Aug 2020 11:23:06 -0700 (PDT) MIME-Version: 1.0 References: <20200506193435.3746-1-pali@kernel.org> <CECA6D9A-0F26-40E8-BFDF-A24CD972307D@holtmann.org> <20200610093306.zt3q3s2wmwp3almw@pali> <7672C0A0-AF6A-41B2-B50F-7836B3E5CC73@holtmann.org> <20200611125304.b4mxxuv7rupamfmg@pali> <20200713090913.6duirl4yhrjcyxoh@pali> <20200808132042.mma5ykynagwx3ubd@pali> <CABBYNZ+Ep6njp9vfEZrFTGCiSMcsdoPnPa21H0ApJ1O3tau_MQ@mail.gmail.com> <20200809153321.gywj4elkefrcusvz@pali> In-Reply-To: <20200809153321.gywj4elkefrcusvz@pali> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Sun, 9 Aug 2020 11:22:53 -0700 Message-ID: <CABBYNZJwf==cfNgEzVJ0r+gA7QVFxyXp25OT13X+=qW6pH5-9A@mail.gmail.com> Subject: Re: [PATCH] Install avinfo utility To: =?UTF-8?Q?Pali_Roh=C3=A1r?= <pali@kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org>, David Heidelberg <david@ixit.cz> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: D6E98A020E X-Rspamd-UID: 221986 Hi Pali, On Sun, Aug 9, 2020 at 8:33 AM Pali Roh=C3=A1r <pali@kernel.org> wrote: > > On Saturday 08 August 2020 22:33:48 Luiz Augusto von Dentz wrote: > > Hi Pali, > > > > On Sat, Aug 8, 2020 at 6:20 AM Pali Roh=C3=A1r <pali@kernel.org> wrote: > > > > > > On Monday 13 July 2020 11:09:13 Pali Roh=C3=A1r wrote: > > > > On Thursday 11 June 2020 14:53:04 Pali Roh=C3=A1r wrote: > > > > > On Wednesday 10 June 2020 19:31:47 Marcel Holtmann wrote: > > > > > > Hi Pali, > > > > > > > > > > > > >>> This utility is very useful for determining which A2DP code= cs are supported > > > > > > >>> by remote side. So install it to system as part of bluez pa= ckage. > > > > > > >>> --- > > > > > > >>> Makefile.tools | 4 ++-- > > > > > > >>> 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > >>> > > > > > > >>> diff --git a/Makefile.tools b/Makefile.tools > > > > > > >>> index 9b9236609..d52721612 100644 > > > > > > >>> --- a/Makefile.tools > > > > > > >>> +++ b/Makefile.tools > > > > > > >>> @@ -176,9 +176,9 @@ endif > > > > > > >>> if TOOLS > > > > > > >>> bin_PROGRAMS +=3D tools/rctest tools/l2test tools/l2ping to= ols/bccmd \ > > > > > > >>> tools/bluemoon tools/hex2hcd tools/mp= ris-proxy \ > > > > > > >>> - tools/btattach > > > > > > >>> + tools/btattach tools/avinfo > > > > > > >>> > > > > > > >>> -noinst_PROGRAMS +=3D tools/bdaddr tools/avinfo tools/avtes= t \ > > > > > > >>> +noinst_PROGRAMS +=3D tools/bdaddr tools/avtest \ > > > > > > >>> tools/scotest tools/amptest tools/hwd= b \ > > > > > > >>> tools/hcieventmask tools/hcisecfilter= \ > > > > > > >>> tools/btinfo tools/btconfig \ > > > > > > >> > > > > > > >> I had no intention to install that tool since it is too limi= ted > > > > > > > > > > > > > > Sorry, but I have not seen any limitations with this tool yet= . I'm using > > > > > > > it very often. And also other people who use it have not ment= ioned any > > > > > > > limitations or problems. > > > > > > > > > > > > > > So could you be more specific what are those limitations? > > > > > > > > > > > > > > Also it is the first thing which I'm saying people that shoul= d run and > > > > > > > send me output of it if something related to A2DP does not wo= rk. > > > > > > > > > > > > > > And because linux distributions do not package this utility a= nd bluez > > > > > > > developers (for me for unknown reasons) decided to not instal= l it, > > > > > > > result is that people have to always compile bluez from sourc= e to run > > > > > > > this utility if their A2DP audio does not work or "remote" de= bugging of > > > > > > > A2DP is needed. > > > > > > > > > > > > > > So result is that who want to know why A2DP audio does not wo= rk is > > > > > > > forced to compile & install bluez from sources and not to use= from > > > > > > > distribution package. And this probably not the expected stat= e. > > > > > > > > > > > > > > In any case, nobody reported to me any limitation with one ex= ception > > > > > > > that it cannot decode capabilities of some custom vendor code= cs. But > > > > > > > most of them are already supported as I sent needed patches i= n past. > > > > > > > > > > > > > >> and makes too many assumption. > > > > > > > > > > > > > > For example which assumptions? > > > > > > > > > > > > that nothing else is happening right now. It backstabs the actu= al AVDTP and A2DP implementation. > > > > > > > > > > Marcel, but this is not a problem. For that one purpose which avi= nfo > > > > > provides it ideal and works fine. Personally I do not see any pro= blem > > > > > with it. > > > > > > > > > > > >> In addition it has a bad name with no Bluetooth prefix. > > > > > > > > > > > > > > So, lets rename it. What about "btavinfo"? > > > > > > > > > > > > Lets extend btinfo with all sort of capabilities. Make the av p= ortion just one of. I want to remove the multitudes of test utilities anywa= y. We have to many tiny utilities that are just scattered around and avinfo= is just one of them. > > > > > > > > > > This looks like a not-so-trivial task and moreover independent of > > > > > providing current version of avinfo to users. > > > > > > > > > > avinfo already exists, is already part of bluez project, it is al= ready > > > > > compiling during bluez build and is already used by me and lot of= other > > > > > users and works for that one purpose as expected. > > > > > > > > > > > > > > > > > > >> If we think it is useful to have such a test utility, then w= e need to clean this up first > > > > > > > > > > > > > > What exactly to clean up first? > > > > > > > > > > > > > > Note that I have already done cleanup of this utility. > > > > > > > > > > > > > >> and put this into a larger btinfo work to gather appropriate= information from a remote device for debug purposes. > > > > > > > > > > > > > > I do not see how btinfo can be used for A2DP purposes. Seems = this is > > > > > > > utility for local controller info and not for remove A2DP. > > > > > > > > > > > > This needs a bit thinking, but pretty much simple things like t= his: > > > > > > > > > > > > btinfo local > > > > > > btinfo avdtp <remote_bdaddr> > > > > > > > > > > > > We can create a module handling system so that you can easily l= inks existing tiny utilities into one. > > > > > > > > > > I'm not against this change. But this is additional work which ne= eds to > > > > > be done. And it would not happen today or tomorrow unless you hav= e > > > > > already patches which implement it. > > > > > > > > > > As I said avinfo is already there, implemented, it is working and= is > > > > > part of bluez source code. And is basically the first step when > > > > > debugging issues with A2DP audio. > > > > > > > > > > So what is the real issue with not only compiling this avinfo too= l > > > > > during building bluez but also installing it? > > > > > > > > Because nobody presented any real issue for more then month and I'm= not > > > > aware of any, could be avinfo finally enabled during installation? > > > > > > PING, two months passed and I have not received any new reply to this= patch. > > > > > > If there are really no problems, could it be applied? > > > > For the record I do intend to enable listing available endpoints in > > bluetooth-player, which might actually get merged into bluetoothctl as > > a new menu, > > Will it provide everything which is avinfo provides? Regarding endpoints yes, it is the endpoint information that has been exposed via D-Bus objects. > > recently there have been some vulnerabilities reported > > against these kind of tools that are meant to only be used for testing > > purposes > > Could you be more specific what is that vulnerability, so we can fix it? It is not related to avinfo, it was gatttool if you are curious about it, but most if not all our tools do tend to leak memory when they are exiting which would trigger some analyzer, etc, to have pointless reports about those leaks. > It is the only issue? If yes, I'm going to fix it once I receive > details about it. > > > so I would only be in favor of installing them with we add > > some new build option i.e. --enable-testing and document that these > > tools are meant for testing only (and shall probably be package > > separately) so we avoid these pointless reports for tools that are not > > really meant to be used in production. > > As I said, avinfo is required tool for debugging A2DP audio transfers in > case there are problems and probably it is the only tool useful for such > purpose. > > Lot of users are reporting that "audio does not work" and the only way > to debug is, is to ask users to provide full output of avinfo. Well if the issue is at the negotiation it avinfo is not the useful, btmon traces are what I usually recommend having as you can figure out what issues are 99% of the time. > Well, it can be classified as "testing tool", but highly required in > case audio does not work. It is not a qualifiable implementation that is for sure, so classifying it as a testing tool is the best we can do. > So please provide information about that vulnerability and I will fix > it. As being silent for two months about existing vulnerability is not > really good. --=20 Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SPOFAhWcMF/SKAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 03:00:05 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eJa0ABWcMF9gIwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 03:00:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5AB02A0D15; Mon, 10 Aug 2020 03:00:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726536AbgHJA7v (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 9 Aug 2020 20:59:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbgHJA7v (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 9 Aug 2020 20:59:51 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BA2AC061756; Sun, 9 Aug 2020 17:59:51 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id f9so4085449pju.4; Sun, 09 Aug 2020 17:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=q0qJO4EPZit/EH6A7WT7wLcgl0yNkUMzQdIUs1Xd0rs=; b=WcDioUBhF3OBNLdRFGPm4xL/wg35NsnX1T7B+N5mLgLGfMHPO6e+ws8jSymjP+fehv Ymmj/A6435/LrpYObcEkppCnaGGFKHSFsc5Ok7yFInm1fFiQ1pRb5OADygG4gD/UQiyU jRioeUsmQzBmnvSOQVGnA7APtjxLRx2pCwkaAoh0rKBI+KwCOGP94+uGAeBY4BZPHm8K 61uXgWQlXJ1btsyM3z4HvgYLxoXS0TwCFcZ1JQVvvSH/tfXVaDabCX6i5Iq26FN+Fl7f q+swu2/13lE3Skkfm/pY2Jf9hphdNgNueVLvi4ZCbH+cGiPdJ9qxMi00TiTCAh4bi/ZG hZHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=q0qJO4EPZit/EH6A7WT7wLcgl0yNkUMzQdIUs1Xd0rs=; b=LCZEr76RLHWB4JtMuoZrlTadoxuEVl13t0EVvp9pAtBOv93dT7GqiEtHzIN7MBcKxw 1y5chC1JNSIIewfbyZfmmu4yaRu9tK+UNSCNcaCKpW2Pc3uDJ+eIfq1gO/dxIrI0Esxf MKLG9tx5eovoQzTEVzwAPbsPfFO9hiLsGRy+2rdQRPIw9hCRbnwN4LCzn0qKmAP0v78M 1cCQrU/TMcAYi8NlCyFhWTrbY0xkP26CLdOLlsKicAhWXjwGKOgVjY0+y7HoWRuLF1H+ DL4TLiC0svddgnsiqYcjGg+5SmwvvX1hTrZ3K8YJvtmDkcJwmEolAGWh6mAzvdvTZEtv 4z2A== X-Gm-Message-State: AOAM532tJHFLrFFJqmyp1GPCDFK2KHa5xJJRQauwyW0ZU7swN2iY0Das BJ+tmKy/+JQ6BqvIzkNPqeQzZVVIU8vkhA== X-Google-Smtp-Source: ABdhPJwN4CR2mZ8LTgbsjjdYYXjpnUy33fewmZnUndv91/R9tDZ9Wg5yIe7kVXKqjfra6UNUTrSO0Q== X-Received: by 2002:a17:90b:252:: with SMTP id fz18mr24344482pjb.48.1597021190564; Sun, 09 Aug 2020 17:59:50 -0700 (PDT) Received: from localhost.localdomain (c-24-16-167-223.hsd1.wa.comcast.net. [24.16.167.223]) by smtp.gmail.com with ESMTPSA id j5sm21504055pfg.80.2020.08.09.17.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 17:59:50 -0700 (PDT) From: YourName <argoz1701@gmail.com> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mturquette@baylibre.com, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-clk@vger.kernel.org, argoz1701@gmail.com Subject: [PATCH 3/3] drivers/clk/clk-asm9260.c Date: Sun, 9 Aug 2020 17:59:41 -0700 Message-Id: <20200810005941.20581-1-argoz1701@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.31 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5AB02A0D15 X-Rspamd-UID: 018e10 From: Daniel <argoz1701@gmail.com> --- drivers/ata/acard-ahci.c | 6 +++--- drivers/bluetooth/bfusb.c | 5 ++--- drivers/clk/clk-asm9260.c | 12 ++++++------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/ata/acard-ahci.c b/drivers/ata/acard-ahci.c index 2a04e8abd397..3ffb21f3e88b 100644 --- a/drivers/ata/acard-ahci.c +++ b/drivers/ata/acard-ahci.c @@ -79,10 +79,10 @@ static struct ata_port_operations acard_ops = { #define AHCI_HFLAGS(flags) .private_data = (void *)(flags) -static const struct ata_port_info acard_ahci_port_info[] = { +static const struct ata_port_info acard_ahci_port_info[] ={ [board_acard_ahci] = - { - AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ), + + { AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ), .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 5a321b4076aa..dc6a62cb1941 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -355,15 +355,14 @@ static void bfusb_rx_complete(struct urb *urb) while (count) { hdr = buf[0] | (buf[1] << 8); - if (hdr & 0x4000) { + if (hdr & 0x4000) len = 0; count -= 2; buf += 2; - } else { + else { len = (buf[2] == 0) ? 256 : buf[2]; count -= 3; buf += 3; - } if (count < len) { bt_dev_err(data->hdev, "block extends over URB buffer ranges"); diff --git a/drivers/clk/clk-asm9260.c b/drivers/clk/clk-asm9260.c index bacebd457e6f..4e608807a00a 100644 --- a/drivers/clk/clk-asm9260.c +++ b/drivers/clk/clk-asm9260.c @@ -92,8 +92,8 @@ static const struct asm9260_div_clk asm9260_div_clks[] __initconst = { { CLKID_SYS_CPU, "cpu_div", "main_gate", HW_CPUCLKDIV }, { CLKID_SYS_AHB, "ahb_div", "cpu_div", HW_SYSAHBCLKDIV }, - /* i2s has two deviders: one for only external mclk and internal - * devider for all clks. */ + //i2s has two deviders: one for only external mclk and internal + //devider for all clks. { CLKID_SYS_I2S0M, "i2s0m_div", "i2s0_mclk", HW_I2S0MCLKDIV }, { CLKID_SYS_I2S1M, "i2s1m_div", "i2s1_mclk", HW_I2S1MCLKDIV }, { CLKID_SYS_I2S0S, "i2s0s_div", "i2s0_gate", HW_I2S0SCLKDIV }, @@ -232,10 +232,10 @@ static const struct asm9260_gate_data asm9260_ahb_gates[] __initconst = { HW_AHBCLKCTRL1, 16 }, }; -static const char __initdata *main_mux_p[] = { NULL, NULL }; -static const char __initdata *i2s0_mux_p[] = { NULL, NULL, "i2s0m_div"}; -static const char __initdata *i2s1_mux_p[] = { NULL, NULL, "i2s1m_div"}; -static const char __initdata *clkout_mux_p[] = { NULL, NULL, "rtc"}; +static const char __initconst *main_mux_p[] = { NULL, NULL }; +static const char __initconst *i2s0_mux_p[] = { NULL, NULL, "i2s0m_div"}; +static const char __initconst *i2s1_mux_p[] = { NULL, NULL, "i2s1m_div"}; +static const char __initconst *clkout_mux_p[] = { NULL, NULL, "rtc"}; static u32 three_mux_table[] = {0, 1, 3}; static struct asm9260_mux_clock asm9260_mux_clks[] __initdata = { -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8PcYNmwKMV9zUgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 10:50:52 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id eE7/NGwKMV9aawAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 10:50:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8CDF9A1579; Mon, 10 Aug 2020 10:50:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726585AbgHJIub (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 04:50:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbgHJIub (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 04:50:31 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7599C061756; Mon, 10 Aug 2020 01:50:30 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id w14so8675587ljj.4; Mon, 10 Aug 2020 01:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2vy5WK0/lZz1ewdjEJ/g1nZeGw5MBX8oCLLIJ1fU9Bo=; b=RVXduCsjsI1KO/t7jAETjHGfpJeIfBkNLlUdPZQLbIvZJXw1A7nNDa7rQ3p6FXYjhG TNaAfEriRKSt6fTkDhNBKJS4Ye72JJuXQggjStSGEVPwDw25sN8BYj2yNNZhH7R9FK8L 2OlOYujONBOc43ByZbz646sekkhZliKDQF6bdQXePc7kxBD+kCr3jlqzOkaasB+gcIs5 qll9KEywhbWs6TUmlhTxOtVBlEe5Wn4oyl7fTUmiSVO/l4GauqgmJkPhpalzxIusIn79 YzBZf+M88uBOYHw2rmonuNOdMGzTmoiUHda5qzBlNGXGXl6P9pGuTn6FX9rrlkDEoJ0k SrIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=2vy5WK0/lZz1ewdjEJ/g1nZeGw5MBX8oCLLIJ1fU9Bo=; b=eg2cpGNBTSmz/+XktP1b2Wl0PRwQAquFq/+a+pClsjs2Ym7i4QAEz4Y6AzqNAcrfpd 7V4qVKaKeHXVrfoVR6XsE8g4+iwr5FN0lVdBFileCpDw4b9/8lCaX6h0nx83Jb/Zhtfl eJV/lplEUjIwGQcF9U8w4+5jAeuSSUK+lNk3lyan+M7tgyyLMXXS6v8ur+FCEaqTceIl E2abELiGz8Jkc+EEJxSVEMFgo0Q+Zc87zEkAUFybo0DZgWAtjdoa++CISSb6G+Rm5nlh xjNVOMjA+Pd/vUI2n4EdlYvzqNCJ5uLOxHgZvSSnsRslxyjJqwgN/bLfhvo8xGj2i6L3 UiNg== X-Gm-Message-State: AOAM530M5FKF9SJYYPwXpyNJLzexCNmqxfDt6Gxr/TAtVnE929lBIOX/ I3yE7JE7qv/owQc/QdXDWPz85fVR X-Google-Smtp-Source: ABdhPJzAKqKsxBUQ6dMvRHeeew+CCTavJevMHcIrxLQGzCgyq6bCmkzedAvzc2gB+iPcDqXEXN7ggQ== X-Received: by 2002:a2e:5018:: with SMTP id e24mr34551ljb.261.1597049429209; Mon, 10 Aug 2020 01:50:29 -0700 (PDT) Received: from ?IPv6:2a00:1fa0:656:4d4d:4047:314a:a423:d91? ([2a00:1fa0:656:4d4d:4047:314a:a423:d91]) by smtp.gmail.com with ESMTPSA id o16sm8976071ljc.66.2020.08.10.01.50.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Aug 2020 01:50:28 -0700 (PDT) Subject: Re: [PATCH 3/3] drivers/clk/clk-asm9260.c To: YourName <argoz1701@gmail.com>, marcel@holtmann.org, johan.hedberg@gmail.com Cc: mturquette@baylibre.com, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-clk@vger.kernel.org References: <20200810005941.20581-1-argoz1701@gmail.com> From: Sergei Shtylyov <sergei.shtylyov@gmail.com> Organization: Brain-dead Software Message-ID: <bdab839e-1aba-5b0f-e5de-52ddebc8b9ed@gmail.com> Date: Mon, 10 Aug 2020 11:50:26 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200810005941.20581-1-argoz1701@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8CDF9A1579 X-Rspamd-UID: 71f2d5 Hello! On 10.08.2020 3:59, YourName wrote: > From: Daniel <argoz1701@gmail.com> Full name needed here. > --- > drivers/ata/acard-ahci.c | 6 +++--- > drivers/bluetooth/bfusb.c | 5 ++--- > drivers/clk/clk-asm9260.c | 12 ++++++------ > 3 files changed, 11 insertions(+), 12 deletions(-) > > diff --git a/drivers/ata/acard-ahci.c b/drivers/ata/acard-ahci.c > index 2a04e8abd397..3ffb21f3e88b 100644 > --- a/drivers/ata/acard-ahci.c > +++ b/drivers/ata/acard-ahci.c > @@ -79,10 +79,10 @@ static struct ata_port_operations acard_ops = { > > #define AHCI_HFLAGS(flags) .private_data = (void *)(flags) > > -static const struct ata_port_info acard_ahci_port_info[] = { > +static const struct ata_port_info acard_ahci_port_info[] ={ > [board_acard_ahci] = > - { > - AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ), > + > + { AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ), This does nothing except ruining the valid code formatting. > .flags = AHCI_FLAG_COMMON, > .pio_mask = ATA_PIO4, > .udma_mask = ATA_UDMA6, > diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c > index 5a321b4076aa..dc6a62cb1941 100644 > --- a/drivers/bluetooth/bfusb.c > +++ b/drivers/bluetooth/bfusb.c > @@ -355,15 +355,14 @@ static void bfusb_rx_complete(struct urb *urb) > while (count) { > hdr = buf[0] | (buf[1] << 8); > > - if (hdr & 0x4000) { > + if (hdr & 0x4000) > len = 0; > count -= 2; > buf += 2; > - } else { > + else { > len = (buf[2] == 0) ? 256 : buf[2]; > count -= 3; > buf += 3; > - } This just ruins the code. > > if (count < len) { > bt_dev_err(data->hdev, "block extends over URB buffer ranges"); > diff --git a/drivers/clk/clk-asm9260.c b/drivers/clk/clk-asm9260.c > index bacebd457e6f..4e608807a00a 100644 > --- a/drivers/clk/clk-asm9260.c > +++ b/drivers/clk/clk-asm9260.c > @@ -92,8 +92,8 @@ static const struct asm9260_div_clk asm9260_div_clks[] __initconst = { > { CLKID_SYS_CPU, "cpu_div", "main_gate", HW_CPUCLKDIV }, > { CLKID_SYS_AHB, "ahb_div", "cpu_div", HW_SYSAHBCLKDIV }, > > - /* i2s has two deviders: one for only external mclk and internal > - * devider for all clks. */ > + //i2s has two deviders: one for only external mclk and internal > + //devider for all clks. Divider. :-) This is not the preferred multi-line comment formatting anyway. > { CLKID_SYS_I2S0M, "i2s0m_div", "i2s0_mclk", HW_I2S0MCLKDIV }, > { CLKID_SYS_I2S1M, "i2s1m_div", "i2s1_mclk", HW_I2S1MCLKDIV }, > { CLKID_SYS_I2S0S, "i2s0s_div", "i2s0_gate", HW_I2S0SCLKDIV }, [...] MBR, Sergei Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MOEFEdSbMV/j/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 21:11:16 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id ePXcD9SbMV/FcwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 21:11:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F3A08A1444; Mon, 10 Aug 2020 21:11:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728711AbgHJTJ5 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 15:09:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:36842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728698AbgHJTJ4 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 15:09:56 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9B33722D07; Mon, 10 Aug 2020 19:09:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597086595; bh=TWkVTrn4wtXnPeHy9dd1qMkMpuJMdWKnycx+yE2RMEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yvl+W82k+iWq5bnQy2piXwuP2WWEp9opIzE72SrmVUHbzZXCk8OgGI9lB5uoZcFSX 3IVdwrQOk0zxNSBFYVGo1Pahx6PLIQ1si799e+i6QXjt9pyqhLFCOjyk7RKQ5CMDse olSkZzpYQHFl2reUZq20RuwE50vUc9ZChyxZH8yY= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org Subject: [PATCH AUTOSEL 5.8 41/64] Bluetooth: hci_qca: Bug fixes for SSR Date: Mon, 10 Aug 2020 15:08:36 -0400 Message-Id: <20200810190859.3793319-41-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200810190859.3793319-1-sashal@kernel.org> References: <20200810190859.3793319-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: F3A08A1444 X-Rspamd-UID: ff129b From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> [ Upstream commit 3344537f614b966f726c1ec044d1c70a8cabe178 ] 1.During SSR for command time out if BT SoC goes to inresponsive state, power cycling of BT SoC was not happening. Given the fix by sending hw error event to reset the BT SoC. 2.If SSR is triggered then ignore the transmit data requests to BT SoC until SSR is completed. Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/bluetooth/hci_qca.c | 40 +++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 81c3c38baba18..3788ec7a4ad6b 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -72,7 +72,8 @@ enum qca_flags { QCA_DROP_VENDOR_EVENT, QCA_SUSPENDING, QCA_MEMDUMP_COLLECTION, - QCA_HW_ERROR_EVENT + QCA_HW_ERROR_EVENT, + QCA_SSR_TRIGGERED }; enum qca_capabilities { @@ -862,6 +863,13 @@ static int qca_enqueue(struct hci_uart *hu, struct sk_buff *skb) BT_DBG("hu %p qca enq skb %p tx_ibs_state %d", hu, skb, qca->tx_ibs_state); + if (test_bit(QCA_SSR_TRIGGERED, &qca->flags)) { + /* As SSR is in progress, ignore the packets */ + bt_dev_dbg(hu->hdev, "SSR is in progress"); + kfree_skb(skb); + return 0; + } + /* Prepend skb with frame type */ memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1); @@ -1128,6 +1136,7 @@ static int qca_controller_memdump_event(struct hci_dev *hdev, struct hci_uart *hu = hci_get_drvdata(hdev); struct qca_data *qca = hu->priv; + set_bit(QCA_SSR_TRIGGERED, &qca->flags); skb_queue_tail(&qca->rx_memdump_q, skb); queue_work(qca->workqueue, &qca->ctrl_memdump_evt); @@ -1488,6 +1497,7 @@ static void qca_hw_error(struct hci_dev *hdev, u8 code) struct qca_memdump_data *qca_memdump = qca->qca_memdump; char *memdump_buf = NULL; + set_bit(QCA_SSR_TRIGGERED, &qca->flags); set_bit(QCA_HW_ERROR_EVENT, &qca->flags); bt_dev_info(hdev, "mem_dump_status: %d", qca->memdump_state); @@ -1532,10 +1542,30 @@ static void qca_cmd_timeout(struct hci_dev *hdev) struct hci_uart *hu = hci_get_drvdata(hdev); struct qca_data *qca = hu->priv; - if (qca->memdump_state == QCA_MEMDUMP_IDLE) + set_bit(QCA_SSR_TRIGGERED, &qca->flags); + if (qca->memdump_state == QCA_MEMDUMP_IDLE) { + set_bit(QCA_MEMDUMP_COLLECTION, &qca->flags); qca_send_crashbuffer(hu); - else - bt_dev_info(hdev, "Dump collection is in process"); + qca_wait_for_dump_collection(hdev); + } else if (qca->memdump_state == QCA_MEMDUMP_COLLECTING) { + /* Let us wait here until memory dump collected or + * memory dump timer expired. + */ + bt_dev_info(hdev, "waiting for dump to complete"); + qca_wait_for_dump_collection(hdev); + } + + mutex_lock(&qca->hci_memdump_lock); + if (qca->memdump_state != QCA_MEMDUMP_COLLECTED) { + qca->memdump_state = QCA_MEMDUMP_TIMEOUT; + if (!test_bit(QCA_HW_ERROR_EVENT, &qca->flags)) { + /* Inject hw error event to reset the device + * and driver. + */ + hci_reset_dev(hu->hdev); + } + } + mutex_unlock(&qca->hci_memdump_lock); } static int qca_wcn3990_init(struct hci_uart *hu) @@ -1646,6 +1676,8 @@ static int qca_setup(struct hci_uart *hu) if (ret) return ret; + clear_bit(QCA_SSR_TRIGGERED, &qca->flags); + if (qca_is_wcn399x(soc_type)) { set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks); -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cF+2M/KeMV/j/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 21:24:34 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +I7nMfKeMV9yZgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 21:24:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A6C18420CC; Mon, 10 Aug 2020 21:24:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730096AbgHJTOt (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 15:14:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:47298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730082AbgHJTOs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 15:14:48 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 89F9A22C9E; Mon, 10 Aug 2020 19:14:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597086887; bh=2R3z984rFOdN8uqAPoe8cJ/10YD+Q32bNKUVBayTgo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TQd/sxIDtDz2nTZ9Kzjwk8Uuvm8sXBBxmWdKtyaHwSOpvtKqXefEmJN6lxb7iH6PK qpd5BA2XFZhXYzz/J3duEnrcEEk3IgZsOYrohUf2Voj5ws7d/dstZSgFTyVWBhIG7/ IaBUrD5uMh7HN0O0h9hAHhV6rlwv/YGKdkjrB8G8= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lihong Kou <koulihong@huawei.com>, syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 02/16] Bluetooth: add a mutex lock to avoid UAF in do_enale_set Date: Mon, 10 Aug 2020 15:14:29 -0400 Message-Id: <20200810191443.3795581-2-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200810191443.3795581-1-sashal@kernel.org> References: <20200810191443.3795581-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: A6C18420CC X-Rspamd-UID: 3a0ead From: Lihong Kou <koulihong@huawei.com> [ Upstream commit f9c70bdc279b191da8d60777c627702c06e4a37d ] In the case we set or free the global value listen_chan in different threads, we can encounter the UAF problems because the method is not protected by any lock, add one to avoid this bug. BUG: KASAN: use-after-free in l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 Read of size 8 at addr ffff888096950000 by task kworker/1:102/2868 CPU: 1 PID: 2868 Comm: kworker/1:102 Not tainted 5.5.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events do_enable_set Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1fb/0x318 lib/dump_stack.c:118 print_address_description+0x74/0x5c0 mm/kasan/report.c:374 __kasan_report+0x149/0x1c0 mm/kasan/report.c:506 kasan_report+0x26/0x50 mm/kasan/common.c:641 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135 l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 do_enable_set+0x660/0x900 net/bluetooth/6lowpan.c:1074 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Allocated by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] __kasan_kmalloc+0x118/0x1c0 mm/kasan/common.c:515 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529 kmem_cache_alloc_trace+0x221/0x2f0 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] l2cap_chan_create+0x50/0x320 net/bluetooth/l2cap_core.c:446 chan_create net/bluetooth/6lowpan.c:640 [inline] bt_6lowpan_listen net/bluetooth/6lowpan.c:959 [inline] do_enable_set+0x6a4/0x900 net/bluetooth/6lowpan.c:1078 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Freed by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] kasan_set_free_info mm/kasan/common.c:337 [inline] __kasan_slab_free+0x12e/0x1e0 mm/kasan/common.c:476 kasan_slab_free+0xe/0x10 mm/kasan/common.c:485 __cache_free mm/slab.c:3426 [inline] kfree+0x10d/0x220 mm/slab.c:3757 l2cap_chan_destroy net/bluetooth/l2cap_core.c:484 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_chan_put+0x170/0x190 net/bluetooth/l2cap_core.c:498 do_enable_set+0x66c/0x900 net/bluetooth/6lowpan.c:1075 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 The buggy address belongs to the object at ffff888096950000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 0 bytes inside of 2048-byte region [ffff888096950000, ffff888096950800) The buggy address belongs to the page: page:ffffea00025a5400 refcount:1 mapcount:0 mapping:ffff8880aa400e00 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00027d1548 ffffea0002397808 ffff8880aa400e00 raw: 0000000000000000 ffff888096950000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809694ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88809694ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888096950000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888096950080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888096950100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Reported-by: syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com Signed-off-by: Lihong Kou <koulihong@huawei.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/6lowpan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 4cd6b8d811ffa..11602902884ba 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -57,6 +57,7 @@ static bool enable_6lowpan; /* We are listening incoming connections via this channel */ static struct l2cap_chan *listen_chan; +static DEFINE_MUTEX(set_lock); struct lowpan_peer { struct list_head list; @@ -1195,12 +1196,14 @@ static void do_enable_set(struct work_struct *work) enable_6lowpan = set_enable->flag; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); } listen_chan = bt_6lowpan_listen(); + mutex_unlock(&set_lock); kfree(set_enable); } @@ -1252,11 +1255,13 @@ static ssize_t lowpan_control_write(struct file *fp, if (ret == -EINVAL) return ret; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); listen_chan = NULL; } + mutex_unlock(&set_lock); if (conn) { struct lowpan_peer *peer; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WJ7IHTqgMV9JPAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 21:30:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id kPcQHDqgMV/FcwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 21:30:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1A3C4420C1; Mon, 10 Aug 2020 21:29:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729983AbgHJTRd (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 15:17:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:46434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729996AbgHJTOW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 15:14:22 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E596322BED; Mon, 10 Aug 2020 19:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597086861; bh=htSXr8sF7+JHBcxaFrOXAmW3pF9fyFXPzeVcUuhuPrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YHU5PVL7MtvN4sqXe5veRBvUOzXyb0d3snJr3EMie71lQrGitiGgDigfeX/n9z0+I 4GSME1H9Wm4/1gD+KtD6jjMZ3HRbswFRGHqlc0Q7KEpEY9y5mAkPVGci8PBRILxCtB zKAlJnqAsVixenu+UgM56M+4LGXn+R5hR87KpdDU= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lihong Kou <koulihong@huawei.com>, syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 02/17] Bluetooth: add a mutex lock to avoid UAF in do_enale_set Date: Mon, 10 Aug 2020 15:14:03 -0400 Message-Id: <20200810191418.3795394-2-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200810191418.3795394-1-sashal@kernel.org> References: <20200810191418.3795394-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1A3C4420C1 X-Rspamd-UID: 303fc7 From: Lihong Kou <koulihong@huawei.com> [ Upstream commit f9c70bdc279b191da8d60777c627702c06e4a37d ] In the case we set or free the global value listen_chan in different threads, we can encounter the UAF problems because the method is not protected by any lock, add one to avoid this bug. BUG: KASAN: use-after-free in l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 Read of size 8 at addr ffff888096950000 by task kworker/1:102/2868 CPU: 1 PID: 2868 Comm: kworker/1:102 Not tainted 5.5.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events do_enable_set Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1fb/0x318 lib/dump_stack.c:118 print_address_description+0x74/0x5c0 mm/kasan/report.c:374 __kasan_report+0x149/0x1c0 mm/kasan/report.c:506 kasan_report+0x26/0x50 mm/kasan/common.c:641 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135 l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 do_enable_set+0x660/0x900 net/bluetooth/6lowpan.c:1074 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Allocated by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] __kasan_kmalloc+0x118/0x1c0 mm/kasan/common.c:515 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529 kmem_cache_alloc_trace+0x221/0x2f0 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] l2cap_chan_create+0x50/0x320 net/bluetooth/l2cap_core.c:446 chan_create net/bluetooth/6lowpan.c:640 [inline] bt_6lowpan_listen net/bluetooth/6lowpan.c:959 [inline] do_enable_set+0x6a4/0x900 net/bluetooth/6lowpan.c:1078 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Freed by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] kasan_set_free_info mm/kasan/common.c:337 [inline] __kasan_slab_free+0x12e/0x1e0 mm/kasan/common.c:476 kasan_slab_free+0xe/0x10 mm/kasan/common.c:485 __cache_free mm/slab.c:3426 [inline] kfree+0x10d/0x220 mm/slab.c:3757 l2cap_chan_destroy net/bluetooth/l2cap_core.c:484 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_chan_put+0x170/0x190 net/bluetooth/l2cap_core.c:498 do_enable_set+0x66c/0x900 net/bluetooth/6lowpan.c:1075 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 The buggy address belongs to the object at ffff888096950000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 0 bytes inside of 2048-byte region [ffff888096950000, ffff888096950800) The buggy address belongs to the page: page:ffffea00025a5400 refcount:1 mapcount:0 mapping:ffff8880aa400e00 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00027d1548 ffffea0002397808 ffff8880aa400e00 raw: 0000000000000000 ffff888096950000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809694ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88809694ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888096950000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888096950080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888096950100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Reported-by: syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com Signed-off-by: Lihong Kou <koulihong@huawei.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/6lowpan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 21096c8822231..3bfd747aa515b 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -57,6 +57,7 @@ static bool enable_6lowpan; /* We are listening incoming connections via this channel */ static struct l2cap_chan *listen_chan; +static DEFINE_MUTEX(set_lock); struct lowpan_peer { struct list_head list; @@ -1187,12 +1188,14 @@ static void do_enable_set(struct work_struct *work) enable_6lowpan = set_enable->flag; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); } listen_chan = bt_6lowpan_listen(); + mutex_unlock(&set_lock); kfree(set_enable); } @@ -1244,11 +1247,13 @@ static ssize_t lowpan_control_write(struct file *fp, if (ret == -EINVAL) return ret; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); listen_chan = NULL; } + mutex_unlock(&set_lock); if (conn) { struct lowpan_peer *peer; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wKKACNGgMV+kSQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 21:32:33 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id ICcbB9GgMV+koQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 21:32:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C8408420C3; Mon, 10 Aug 2020 21:32:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729872AbgHJTNu (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 15:13:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:45184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729858AbgHJTNt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 15:13:49 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7EFF02224D; Mon, 10 Aug 2020 19:13:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597086828; bh=WpV52KAFDM0xr311bUeYlAhrwM/hcvWw2VepPjQWodA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G8s9sivkTJypQYTZtJlZV2Wto+vc3VLNv6YHYaAS/knBXXRP4svKazj6iGegy7y83 w5e4kNna4OXDWs5evc4XbqcjuPWhaOOkZ9chuunEmO8IgaxCEtYf4INFQss9WQIYND kjF6h7IoI1Va3uwWrn5m4dZSt7z6ATZSNIQdACfI= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lihong Kou <koulihong@huawei.com>, syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 02/22] Bluetooth: add a mutex lock to avoid UAF in do_enale_set Date: Mon, 10 Aug 2020 15:13:24 -0400 Message-Id: <20200810191345.3795166-2-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200810191345.3795166-1-sashal@kernel.org> References: <20200810191345.3795166-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: C8408420C3 X-Rspamd-UID: fafc32 From: Lihong Kou <koulihong@huawei.com> [ Upstream commit f9c70bdc279b191da8d60777c627702c06e4a37d ] In the case we set or free the global value listen_chan in different threads, we can encounter the UAF problems because the method is not protected by any lock, add one to avoid this bug. BUG: KASAN: use-after-free in l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 Read of size 8 at addr ffff888096950000 by task kworker/1:102/2868 CPU: 1 PID: 2868 Comm: kworker/1:102 Not tainted 5.5.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events do_enable_set Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1fb/0x318 lib/dump_stack.c:118 print_address_description+0x74/0x5c0 mm/kasan/report.c:374 __kasan_report+0x149/0x1c0 mm/kasan/report.c:506 kasan_report+0x26/0x50 mm/kasan/common.c:641 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135 l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 do_enable_set+0x660/0x900 net/bluetooth/6lowpan.c:1074 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Allocated by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] __kasan_kmalloc+0x118/0x1c0 mm/kasan/common.c:515 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529 kmem_cache_alloc_trace+0x221/0x2f0 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] l2cap_chan_create+0x50/0x320 net/bluetooth/l2cap_core.c:446 chan_create net/bluetooth/6lowpan.c:640 [inline] bt_6lowpan_listen net/bluetooth/6lowpan.c:959 [inline] do_enable_set+0x6a4/0x900 net/bluetooth/6lowpan.c:1078 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Freed by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] kasan_set_free_info mm/kasan/common.c:337 [inline] __kasan_slab_free+0x12e/0x1e0 mm/kasan/common.c:476 kasan_slab_free+0xe/0x10 mm/kasan/common.c:485 __cache_free mm/slab.c:3426 [inline] kfree+0x10d/0x220 mm/slab.c:3757 l2cap_chan_destroy net/bluetooth/l2cap_core.c:484 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_chan_put+0x170/0x190 net/bluetooth/l2cap_core.c:498 do_enable_set+0x66c/0x900 net/bluetooth/6lowpan.c:1075 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 The buggy address belongs to the object at ffff888096950000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 0 bytes inside of 2048-byte region [ffff888096950000, ffff888096950800) The buggy address belongs to the page: page:ffffea00025a5400 refcount:1 mapcount:0 mapping:ffff8880aa400e00 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00027d1548 ffffea0002397808 ffff8880aa400e00 raw: 0000000000000000 ffff888096950000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809694ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88809694ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888096950000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888096950080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888096950100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Reported-by: syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com Signed-off-by: Lihong Kou <koulihong@huawei.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/6lowpan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 357475cceec61..9a75f9b00b512 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -57,6 +57,7 @@ static bool enable_6lowpan; /* We are listening incoming connections via this channel */ static struct l2cap_chan *listen_chan; +static DEFINE_MUTEX(set_lock); struct lowpan_peer { struct list_head list; @@ -1082,12 +1083,14 @@ static void do_enable_set(struct work_struct *work) enable_6lowpan = set_enable->flag; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); } listen_chan = bt_6lowpan_listen(); + mutex_unlock(&set_lock); kfree(set_enable); } @@ -1139,11 +1142,13 @@ static ssize_t lowpan_control_write(struct file *fp, if (ret == -EINVAL) return ret; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); listen_chan = NULL; } + mutex_unlock(&set_lock); if (conn) { struct lowpan_peer *peer; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MHmUA+GhMV9VJwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 21:37:05 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CGXcAeGhMV89ewAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 21:37:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1940340732; Mon, 10 Aug 2020 21:37:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730019AbgHJTW3 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 15:22:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:43594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729685AbgHJTNF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 15:13:05 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 519C521775; Mon, 10 Aug 2020 19:13:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597086784; bh=WpV52KAFDM0xr311bUeYlAhrwM/hcvWw2VepPjQWodA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=08KotkF9QfASJRn0L7D1i6PEcAoiMAclukKHA3C6bHNmAVRa24SsL35qb2VuOEKk6 kJaxsdogIW1AXhDmxiYp+ZvQBMr/Z7EsGHfJj0HIo+b3Fg5qRVCpHyG9mowrqrTc0n GkT2DtzqoPAFRbXwelr1QerSU5JGwjQs9fKqyMFk= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lihong Kou <koulihong@huawei.com>, syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 03/31] Bluetooth: add a mutex lock to avoid UAF in do_enale_set Date: Mon, 10 Aug 2020 15:12:31 -0400 Message-Id: <20200810191259.3794858-3-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200810191259.3794858-1-sashal@kernel.org> References: <20200810191259.3794858-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1940340732 X-Rspamd-UID: 87d261 From: Lihong Kou <koulihong@huawei.com> [ Upstream commit f9c70bdc279b191da8d60777c627702c06e4a37d ] In the case we set or free the global value listen_chan in different threads, we can encounter the UAF problems because the method is not protected by any lock, add one to avoid this bug. BUG: KASAN: use-after-free in l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 Read of size 8 at addr ffff888096950000 by task kworker/1:102/2868 CPU: 1 PID: 2868 Comm: kworker/1:102 Not tainted 5.5.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events do_enable_set Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1fb/0x318 lib/dump_stack.c:118 print_address_description+0x74/0x5c0 mm/kasan/report.c:374 __kasan_report+0x149/0x1c0 mm/kasan/report.c:506 kasan_report+0x26/0x50 mm/kasan/common.c:641 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135 l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 do_enable_set+0x660/0x900 net/bluetooth/6lowpan.c:1074 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Allocated by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] __kasan_kmalloc+0x118/0x1c0 mm/kasan/common.c:515 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529 kmem_cache_alloc_trace+0x221/0x2f0 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] l2cap_chan_create+0x50/0x320 net/bluetooth/l2cap_core.c:446 chan_create net/bluetooth/6lowpan.c:640 [inline] bt_6lowpan_listen net/bluetooth/6lowpan.c:959 [inline] do_enable_set+0x6a4/0x900 net/bluetooth/6lowpan.c:1078 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Freed by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] kasan_set_free_info mm/kasan/common.c:337 [inline] __kasan_slab_free+0x12e/0x1e0 mm/kasan/common.c:476 kasan_slab_free+0xe/0x10 mm/kasan/common.c:485 __cache_free mm/slab.c:3426 [inline] kfree+0x10d/0x220 mm/slab.c:3757 l2cap_chan_destroy net/bluetooth/l2cap_core.c:484 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_chan_put+0x170/0x190 net/bluetooth/l2cap_core.c:498 do_enable_set+0x66c/0x900 net/bluetooth/6lowpan.c:1075 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 The buggy address belongs to the object at ffff888096950000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 0 bytes inside of 2048-byte region [ffff888096950000, ffff888096950800) The buggy address belongs to the page: page:ffffea00025a5400 refcount:1 mapcount:0 mapping:ffff8880aa400e00 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00027d1548 ffffea0002397808 ffff8880aa400e00 raw: 0000000000000000 ffff888096950000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809694ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88809694ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888096950000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888096950080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888096950100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Reported-by: syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com Signed-off-by: Lihong Kou <koulihong@huawei.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/6lowpan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 357475cceec61..9a75f9b00b512 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -57,6 +57,7 @@ static bool enable_6lowpan; /* We are listening incoming connections via this channel */ static struct l2cap_chan *listen_chan; +static DEFINE_MUTEX(set_lock); struct lowpan_peer { struct list_head list; @@ -1082,12 +1083,14 @@ static void do_enable_set(struct work_struct *work) enable_6lowpan = set_enable->flag; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); } listen_chan = bt_6lowpan_listen(); + mutex_unlock(&set_lock); kfree(set_enable); } @@ -1139,11 +1142,13 @@ static ssize_t lowpan_control_write(struct file *fp, if (ret == -EINVAL) return ret; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); listen_chan = NULL; } + mutex_unlock(&set_lock); if (conn) { struct lowpan_peer *peer; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cDHQKZCjMV/j/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 21:44:16 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QDCZKJCjMV9KjgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 21:44:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 54E4440AE5; Mon, 10 Aug 2020 21:44:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729569AbgHJTZt (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 15:25:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:40958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729357AbgHJTL7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 15:11:59 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 40FFF2078D; Mon, 10 Aug 2020 19:11:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597086718; bh=hUo21oQW7nz+fD4ACNrbY5Chug6U6GeExSjug/QP+IE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1zhb274SvmlNVFV3p5AjAu5UQXMxyraGthm7OLaIshYerVXr6gtZS68u5Sds5VmBt 1dVPsvJrb3K/h+1GJuNbJp76Y7Nm8fTXGyh7TxvNOLwgvQMWPIEPieoKukJox/8rbG IzgeiJzmMgceb8cZeTArLFdKvHhBRTizuiu6w0a0= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lihong Kou <koulihong@huawei.com>, syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 03/45] Bluetooth: add a mutex lock to avoid UAF in do_enale_set Date: Mon, 10 Aug 2020 15:11:11 -0400 Message-Id: <20200810191153.3794446-3-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200810191153.3794446-1-sashal@kernel.org> References: <20200810191153.3794446-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: 54E4440AE5 X-Rspamd-UID: 6c8dfc From: Lihong Kou <koulihong@huawei.com> [ Upstream commit f9c70bdc279b191da8d60777c627702c06e4a37d ] In the case we set or free the global value listen_chan in different threads, we can encounter the UAF problems because the method is not protected by any lock, add one to avoid this bug. BUG: KASAN: use-after-free in l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 Read of size 8 at addr ffff888096950000 by task kworker/1:102/2868 CPU: 1 PID: 2868 Comm: kworker/1:102 Not tainted 5.5.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events do_enable_set Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1fb/0x318 lib/dump_stack.c:118 print_address_description+0x74/0x5c0 mm/kasan/report.c:374 __kasan_report+0x149/0x1c0 mm/kasan/report.c:506 kasan_report+0x26/0x50 mm/kasan/common.c:641 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135 l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 do_enable_set+0x660/0x900 net/bluetooth/6lowpan.c:1074 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Allocated by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] __kasan_kmalloc+0x118/0x1c0 mm/kasan/common.c:515 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529 kmem_cache_alloc_trace+0x221/0x2f0 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] l2cap_chan_create+0x50/0x320 net/bluetooth/l2cap_core.c:446 chan_create net/bluetooth/6lowpan.c:640 [inline] bt_6lowpan_listen net/bluetooth/6lowpan.c:959 [inline] do_enable_set+0x6a4/0x900 net/bluetooth/6lowpan.c:1078 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Freed by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] kasan_set_free_info mm/kasan/common.c:337 [inline] __kasan_slab_free+0x12e/0x1e0 mm/kasan/common.c:476 kasan_slab_free+0xe/0x10 mm/kasan/common.c:485 __cache_free mm/slab.c:3426 [inline] kfree+0x10d/0x220 mm/slab.c:3757 l2cap_chan_destroy net/bluetooth/l2cap_core.c:484 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_chan_put+0x170/0x190 net/bluetooth/l2cap_core.c:498 do_enable_set+0x66c/0x900 net/bluetooth/6lowpan.c:1075 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 The buggy address belongs to the object at ffff888096950000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 0 bytes inside of 2048-byte region [ffff888096950000, ffff888096950800) The buggy address belongs to the page: page:ffffea00025a5400 refcount:1 mapcount:0 mapping:ffff8880aa400e00 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00027d1548 ffffea0002397808 ffff8880aa400e00 raw: 0000000000000000 ffff888096950000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809694ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88809694ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888096950000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888096950080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888096950100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Reported-by: syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com Signed-off-by: Lihong Kou <koulihong@huawei.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/6lowpan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 4febc82a7c761..52fb6d6d6d585 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -50,6 +50,7 @@ static bool enable_6lowpan; /* We are listening incoming connections via this channel */ static struct l2cap_chan *listen_chan; +static DEFINE_MUTEX(set_lock); struct lowpan_peer { struct list_head list; @@ -1070,12 +1071,14 @@ static void do_enable_set(struct work_struct *work) enable_6lowpan = set_enable->flag; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); } listen_chan = bt_6lowpan_listen(); + mutex_unlock(&set_lock); kfree(set_enable); } @@ -1127,11 +1130,13 @@ static ssize_t lowpan_control_write(struct file *fp, if (ret == -EINVAL) return ret; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); listen_chan = NULL; } + mutex_unlock(&set_lock); if (conn) { struct lowpan_peer *peer; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qD1ZB46kMV87bgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 21:48:30 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qDz3BY6kMV/XowAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 21:48:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6A8DE420C1; Mon, 10 Aug 2020 21:48:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729265AbgHJT2A (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 15:28:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:39638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729236AbgHJTLU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 15:11:20 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BCF2B20885; Mon, 10 Aug 2020 19:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597086679; bh=15qDq60fpjZ7HW0bZaWJ+geijTtQUm7ianQRg3nvz3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J2x1NPFUqtMDmyv+ggKk38bvT/3wnkNlk1KEJDjeZRW5CvWHl3euiPceSptJ/x+qN hmskQr28qqd2EmG3+4RnjM7VUgzJekGUaF+yQbjjaivdewkOsRLamtPjeu3t+82u2r e5IkpNVazwjsoJ8v1FNk2xCOEmBt41RTjSxjy+AY= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 37/60] Bluetooth: hci_qca: Bug fixes for SSR Date: Mon, 10 Aug 2020 15:10:05 -0400 Message-Id: <20200810191028.3793884-37-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200810191028.3793884-1-sashal@kernel.org> References: <20200810191028.3793884-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6A8DE420C1 X-Rspamd-UID: 55bb6a From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> [ Upstream commit 3344537f614b966f726c1ec044d1c70a8cabe178 ] 1.During SSR for command time out if BT SoC goes to inresponsive state, power cycling of BT SoC was not happening. Given the fix by sending hw error event to reset the BT SoC. 2.If SSR is triggered then ignore the transmit data requests to BT SoC until SSR is completed. Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/bluetooth/hci_qca.c | 40 +++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 0b1036e5e963c..14e4d2eaf8959 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -71,7 +71,8 @@ enum qca_flags { QCA_DROP_VENDOR_EVENT, QCA_SUSPENDING, QCA_MEMDUMP_COLLECTION, - QCA_HW_ERROR_EVENT + QCA_HW_ERROR_EVENT, + QCA_SSR_TRIGGERED }; @@ -854,6 +855,13 @@ static int qca_enqueue(struct hci_uart *hu, struct sk_buff *skb) BT_DBG("hu %p qca enq skb %p tx_ibs_state %d", hu, skb, qca->tx_ibs_state); + if (test_bit(QCA_SSR_TRIGGERED, &qca->flags)) { + /* As SSR is in progress, ignore the packets */ + bt_dev_dbg(hu->hdev, "SSR is in progress"); + kfree_skb(skb); + return 0; + } + /* Prepend skb with frame type */ memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1); @@ -1085,6 +1093,7 @@ static int qca_controller_memdump_event(struct hci_dev *hdev, struct hci_uart *hu = hci_get_drvdata(hdev); struct qca_data *qca = hu->priv; + set_bit(QCA_SSR_TRIGGERED, &qca->flags); skb_queue_tail(&qca->rx_memdump_q, skb); queue_work(qca->workqueue, &qca->ctrl_memdump_evt); @@ -1445,6 +1454,7 @@ static void qca_hw_error(struct hci_dev *hdev, u8 code) struct qca_memdump_data *qca_memdump = qca->qca_memdump; char *memdump_buf = NULL; + set_bit(QCA_SSR_TRIGGERED, &qca->flags); set_bit(QCA_HW_ERROR_EVENT, &qca->flags); bt_dev_info(hdev, "mem_dump_status: %d", qca->memdump_state); @@ -1489,10 +1499,30 @@ static void qca_cmd_timeout(struct hci_dev *hdev) struct hci_uart *hu = hci_get_drvdata(hdev); struct qca_data *qca = hu->priv; - if (qca->memdump_state == QCA_MEMDUMP_IDLE) + set_bit(QCA_SSR_TRIGGERED, &qca->flags); + if (qca->memdump_state == QCA_MEMDUMP_IDLE) { + set_bit(QCA_MEMDUMP_COLLECTION, &qca->flags); qca_send_crashbuffer(hu); - else - bt_dev_info(hdev, "Dump collection is in process"); + qca_wait_for_dump_collection(hdev); + } else if (qca->memdump_state == QCA_MEMDUMP_COLLECTING) { + /* Let us wait here until memory dump collected or + * memory dump timer expired. + */ + bt_dev_info(hdev, "waiting for dump to complete"); + qca_wait_for_dump_collection(hdev); + } + + mutex_lock(&qca->hci_memdump_lock); + if (qca->memdump_state != QCA_MEMDUMP_COLLECTED) { + qca->memdump_state = QCA_MEMDUMP_TIMEOUT; + if (!test_bit(QCA_HW_ERROR_EVENT, &qca->flags)) { + /* Inject hw error event to reset the device + * and driver. + */ + hci_reset_dev(hu->hdev); + } + } + mutex_unlock(&qca->hci_memdump_lock); } static int qca_wcn3990_init(struct hci_uart *hu) @@ -1603,6 +1633,8 @@ static int qca_setup(struct hci_uart *hu) if (ret) return ret; + clear_bit(QCA_SSR_TRIGGERED, &qca->flags); + if (qca_is_wcn399x(soc_type)) { set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks); -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AECyJp+lMV87bgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 21:53:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +JS3JJ+lMV/WowAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 21:53:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B39C8420C3; Mon, 10 Aug 2020 21:52:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730232AbgHJT3e (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 15:29:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:38002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729009AbgHJTKh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 15:10:37 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 175B720639; Mon, 10 Aug 2020 19:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597086636; bh=hUo21oQW7nz+fD4ACNrbY5Chug6U6GeExSjug/QP+IE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0gYgeByaiD2XHhyVmQ5ZKQJDM5hnsZRVdjzybvYx1ZBgkP1oC6EkBHcu/pNnlabtG K8MPfAbIqGykNLICV/93mDngH59V75jz2UMFYxtO1IuClenY5O1MLJ/PuVea7rFaU1 Ea+6Hft3W/zvO/gMoHw42J9WsxxNf/6aSHPebbMQ= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lihong Kou <koulihong@huawei.com>, syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 05/60] Bluetooth: add a mutex lock to avoid UAF in do_enale_set Date: Mon, 10 Aug 2020 15:09:33 -0400 Message-Id: <20200810191028.3793884-5-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200810191028.3793884-1-sashal@kernel.org> References: <20200810191028.3793884-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: B39C8420C3 X-Rspamd-UID: bcee2c From: Lihong Kou <koulihong@huawei.com> [ Upstream commit f9c70bdc279b191da8d60777c627702c06e4a37d ] In the case we set or free the global value listen_chan in different threads, we can encounter the UAF problems because the method is not protected by any lock, add one to avoid this bug. BUG: KASAN: use-after-free in l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 Read of size 8 at addr ffff888096950000 by task kworker/1:102/2868 CPU: 1 PID: 2868 Comm: kworker/1:102 Not tainted 5.5.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events do_enable_set Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1fb/0x318 lib/dump_stack.c:118 print_address_description+0x74/0x5c0 mm/kasan/report.c:374 __kasan_report+0x149/0x1c0 mm/kasan/report.c:506 kasan_report+0x26/0x50 mm/kasan/common.c:641 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135 l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 do_enable_set+0x660/0x900 net/bluetooth/6lowpan.c:1074 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Allocated by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] __kasan_kmalloc+0x118/0x1c0 mm/kasan/common.c:515 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529 kmem_cache_alloc_trace+0x221/0x2f0 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] l2cap_chan_create+0x50/0x320 net/bluetooth/l2cap_core.c:446 chan_create net/bluetooth/6lowpan.c:640 [inline] bt_6lowpan_listen net/bluetooth/6lowpan.c:959 [inline] do_enable_set+0x6a4/0x900 net/bluetooth/6lowpan.c:1078 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Freed by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] kasan_set_free_info mm/kasan/common.c:337 [inline] __kasan_slab_free+0x12e/0x1e0 mm/kasan/common.c:476 kasan_slab_free+0xe/0x10 mm/kasan/common.c:485 __cache_free mm/slab.c:3426 [inline] kfree+0x10d/0x220 mm/slab.c:3757 l2cap_chan_destroy net/bluetooth/l2cap_core.c:484 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_chan_put+0x170/0x190 net/bluetooth/l2cap_core.c:498 do_enable_set+0x66c/0x900 net/bluetooth/6lowpan.c:1075 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 The buggy address belongs to the object at ffff888096950000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 0 bytes inside of 2048-byte region [ffff888096950000, ffff888096950800) The buggy address belongs to the page: page:ffffea00025a5400 refcount:1 mapcount:0 mapping:ffff8880aa400e00 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00027d1548 ffffea0002397808 ffff8880aa400e00 raw: 0000000000000000 ffff888096950000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809694ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88809694ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888096950000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888096950080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888096950100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Reported-by: syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com Signed-off-by: Lihong Kou <koulihong@huawei.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/6lowpan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 4febc82a7c761..52fb6d6d6d585 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -50,6 +50,7 @@ static bool enable_6lowpan; /* We are listening incoming connections via this channel */ static struct l2cap_chan *listen_chan; +static DEFINE_MUTEX(set_lock); struct lowpan_peer { struct list_head list; @@ -1070,12 +1071,14 @@ static void do_enable_set(struct work_struct *work) enable_6lowpan = set_enable->flag; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); } listen_chan = bt_6lowpan_listen(); + mutex_unlock(&set_lock); kfree(set_enable); } @@ -1127,11 +1130,13 @@ static ssize_t lowpan_control_write(struct file *fp, if (ret == -EINVAL) return ret; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); listen_chan = NULL; } + mutex_unlock(&set_lock); if (conn) { struct lowpan_peer *peer; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YFxHBg2oMV/2sgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 22:03:25 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id IDHSBA2oMV9s2gAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 22:03:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BC0A440AE5; Mon, 10 Aug 2020 22:03:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728892AbgHJTeB (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 15:34:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:35232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728308AbgHJTJJ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 15:09:09 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EC46A22B4E; Mon, 10 Aug 2020 19:09:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597086546; bh=wNpQYJFvzAHC3btzCqiA6w25nsGp1ZuOBw4d9rOui6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uz3ELkLnFDpohYdYAgM+gXIvGOK28Bs5djuZ17sNWKiE/kldOpJ+FYU8htfemuShC taQjJKLf2jzBgfTRbJoJNrz/KT4cTaAwhdjAl3TbkS2BHAqgY7FwWe69OttXJ+/MIg wgHXJ+IMtRHFrTNamn+7GxckUZRLdjK7Xtf516Jw= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lihong Kou <koulihong@huawei.com>, syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.8 05/64] Bluetooth: add a mutex lock to avoid UAF in do_enale_set Date: Mon, 10 Aug 2020 15:08:00 -0400 Message-Id: <20200810190859.3793319-5-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200810190859.3793319-1-sashal@kernel.org> References: <20200810190859.3793319-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: BC0A440AE5 X-Rspamd-UID: 3b0cbf From: Lihong Kou <koulihong@huawei.com> [ Upstream commit f9c70bdc279b191da8d60777c627702c06e4a37d ] In the case we set or free the global value listen_chan in different threads, we can encounter the UAF problems because the method is not protected by any lock, add one to avoid this bug. BUG: KASAN: use-after-free in l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 Read of size 8 at addr ffff888096950000 by task kworker/1:102/2868 CPU: 1 PID: 2868 Comm: kworker/1:102 Not tainted 5.5.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events do_enable_set Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1fb/0x318 lib/dump_stack.c:118 print_address_description+0x74/0x5c0 mm/kasan/report.c:374 __kasan_report+0x149/0x1c0 mm/kasan/report.c:506 kasan_report+0x26/0x50 mm/kasan/common.c:641 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135 l2cap_chan_close+0x48/0x990 net/bluetooth/l2cap_core.c:730 do_enable_set+0x660/0x900 net/bluetooth/6lowpan.c:1074 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Allocated by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] __kasan_kmalloc+0x118/0x1c0 mm/kasan/common.c:515 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529 kmem_cache_alloc_trace+0x221/0x2f0 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] l2cap_chan_create+0x50/0x320 net/bluetooth/l2cap_core.c:446 chan_create net/bluetooth/6lowpan.c:640 [inline] bt_6lowpan_listen net/bluetooth/6lowpan.c:959 [inline] do_enable_set+0x6a4/0x900 net/bluetooth/6lowpan.c:1078 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Freed by task 2870: save_stack mm/kasan/common.c:72 [inline] set_track mm/kasan/common.c:80 [inline] kasan_set_free_info mm/kasan/common.c:337 [inline] __kasan_slab_free+0x12e/0x1e0 mm/kasan/common.c:476 kasan_slab_free+0xe/0x10 mm/kasan/common.c:485 __cache_free mm/slab.c:3426 [inline] kfree+0x10d/0x220 mm/slab.c:3757 l2cap_chan_destroy net/bluetooth/l2cap_core.c:484 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_chan_put+0x170/0x190 net/bluetooth/l2cap_core.c:498 do_enable_set+0x66c/0x900 net/bluetooth/6lowpan.c:1075 process_one_work+0x7f5/0x10f0 kernel/workqueue.c:2264 worker_thread+0xbbc/0x1630 kernel/workqueue.c:2410 kthread+0x332/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 The buggy address belongs to the object at ffff888096950000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 0 bytes inside of 2048-byte region [ffff888096950000, ffff888096950800) The buggy address belongs to the page: page:ffffea00025a5400 refcount:1 mapcount:0 mapping:ffff8880aa400e00 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00027d1548 ffffea0002397808 ffff8880aa400e00 raw: 0000000000000000 ffff888096950000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809694ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88809694ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888096950000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888096950080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888096950100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Reported-by: syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com Signed-off-by: Lihong Kou <koulihong@huawei.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/6lowpan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index bb55d92691b06..cff4944d5b663 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -50,6 +50,7 @@ static bool enable_6lowpan; /* We are listening incoming connections via this channel */ static struct l2cap_chan *listen_chan; +static DEFINE_MUTEX(set_lock); struct lowpan_peer { struct list_head list; @@ -1078,12 +1079,14 @@ static void do_enable_set(struct work_struct *work) enable_6lowpan = set_enable->flag; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); } listen_chan = bt_6lowpan_listen(); + mutex_unlock(&set_lock); kfree(set_enable); } @@ -1135,11 +1138,13 @@ static ssize_t lowpan_control_write(struct file *fp, if (ret == -EINVAL) return ret; + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); listen_chan = NULL; } + mutex_unlock(&set_lock); if (conn) { struct lowpan_peer *peer; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UO0EE5ioMV/j/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 22:05:44 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0EkMEZioMV/IjAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 22:05:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 36DC741117; Mon, 10 Aug 2020 22:05:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728322AbgHJUCE convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 16:02:04 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:47813 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727817AbgHJUCD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 16:02:03 -0400 Received: from marcel-macpro.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 20EF2CED43; Mon, 10 Aug 2020 22:12:03 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 3/3] drivers/clk/clk-asm9260.c From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <bdab839e-1aba-5b0f-e5de-52ddebc8b9ed@gmail.com> Date: Mon, 10 Aug 2020 22:01:58 +0200 Cc: YourName <argoz1701@gmail.com>, Johan Hedberg <johan.hedberg@gmail.com>, mturquette@baylibre.com, linux-ide@vger.kernel.org, kernel list <linux-kernel@vger.kernel.org>, Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, linux-clk@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <B73FCD9B-842F-440C-8BF1-16C9F415A341@holtmann.org> References: <20200810005941.20581-1-argoz1701@gmail.com> <bdab839e-1aba-5b0f-e5de-52ddebc8b9ed@gmail.com> To: Sergei Shtylyov <sergei.shtylyov@gmail.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.67 / 15.00 / 200.00 X-Rspamd-Queue-Id: 36DC741117 X-Rspamd-UID: 4e37f0 Hi, >> From: Daniel <argoz1701@gmail.com> > > Full name needed here. > >> --- >> drivers/ata/acard-ahci.c | 6 +++--- >> drivers/bluetooth/bfusb.c | 5 ++--- >> drivers/clk/clk-asm9260.c | 12 ++++++------ >> 3 files changed, 11 insertions(+), 12 deletions(-) please don’t intermix patches for different subsystems. And have a proper commit message explaining what is changed. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IM4HHhDBMV93VQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 10 Aug 2020 23:50:08 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cIPDGxDBMV9yZgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 10 Aug 2020 23:50:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 915DEA11F8; Mon, 10 Aug 2020 23:50:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726537AbgHJVuC (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 17:50:02 -0400 Received: from mga14.intel.com ([192.55.52.115]:16681 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726481AbgHJVuC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 17:50:02 -0400 IronPort-SDR: 469zZERuADeIRiRefUtKvvFuxbFNUTZTZ05VlHLJ7EPjBDiXJ6jPMmeR83qEq1w9DZuN7GRls3 FmZxKvJ5SIFA== X-IronPort-AV: E=McAfee;i="6000,8403,9709"; a="152845927" X-IronPort-AV: E=Sophos;i="5.75,458,1589266800"; d="scan'208";a="152845927" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2020 14:50:01 -0700 IronPort-SDR: W1gCXYavQf31ZW1YsMoTsejkYMyBMiKsk9jEHV5NH1KCGJzipRxG439aIUEylFx8Q6xUUvPFwS ijlLyFniHf6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,458,1589266800"; d="scan'208";a="324574770" Received: from unknown (HELO fmsmsx606.amr.corp.intel.com) ([10.18.84.216]) by orsmga008.jf.intel.com with ESMTP; 10 Aug 2020 14:50:01 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 10 Aug 2020 14:50:00 -0700 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 10 Aug 2020 14:50:00 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 10 Aug 2020 14:50:00 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.47) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 10 Aug 2020 14:50:00 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LrpcUsz46dhHvewyUXsE6MHwfswz3NuFgF51hy7R8CMwfQ2RsghYzQ2kkZLmwikw+m4x81oBfLhEFlYiMK/IzuwTQuK9D4KfCHbMgU2/Emum1+80iI0+GTKzsksJeRCfBnO6epKFF55uZvb5JW0k2XTHdgWYsumeu0Iv73xq/mmqDbJ/rzvgKpl95PDSd3orqETE3EjO9xK4fF8goAcN0Y3uMhTdUAPKpJmFP5XpYvp2v4YVUtTv7dlVcSFuAFjBpxABZljRdCrEvX2wQj/aFh1eJNU8zTTVVoh1Le2vNGaz4BjgGtpziylz3jxZxG/xPlEyBFWL+CZRo9oQmBYzHQ== 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-SenderADCheck; bh=yyHHK1omVb8oq1N4YRZebn+PAIEyDO9bX8V1PfEsSg4=; b=bDJis4TMbTry5RI0yK6cWM9S5NTalepnO7JdycbXObBF8yrPh928ndxbtotiTFho+mMnlo+KsKb3/E14GBWEkfmPqlQkagwYZPBZDJni6DWCNqBNbZ8iK48pEelkQuxfNyay4fDUJrRtBUBCFo+Lew6sb0Lr0GCjQeHT7ItDNg3MZGhT5ieSAmVTzYs+ZKF/n6sf1UG+f78E6IAqBsLr99e8mt97oFIOey+zXwat/LKg3FB74OZRXyftcb1SAqmZGY2jnSYAMm2Fz3S5P7+APO4ShkAOuHo9PBbUXxjg7qyDdXVGcIotAg71Yux2kubnR8VXllLrDkxZNdWTdvXopA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yyHHK1omVb8oq1N4YRZebn+PAIEyDO9bX8V1PfEsSg4=; b=Fgy/TCc9OPSgiATkUfcuhJshsBN3d428vz7TkVg6X8DsIVlZyu+k/ItCAaw8G9QgVv65OCNjPEHffTvx2ILlh2rkAj6NHWAiE3zDnYZTLa4UvEp1p/BoM+EVYb5vGcuuHKfZ26GV2wawOQK/7dt90YF600rQF4xW2tDx1+ozYLA= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4602.namprd11.prod.outlook.com (2603:10b6:303:52::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.15; Mon, 10 Aug 2020 21:49:59 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3261.024; Mon, 10 Aug 2020 21:49:59 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ v5 00/10] Mesh Config Server clean up Thread-Topic: [PATCH BlueZ v5 00/10] Mesh Config Server clean up Thread-Index: AQHWbFt7eIFIOH2JaUq8r1g1sTtaw6kx56oA Date: Mon, 10 Aug 2020 21:49:59 +0000 Message-ID: <dd88995a7d18444affc2c1592b8894b9a9dddb6f.camel@intel.com> References: <20200807013834.123263-1-inga.stotland@intel.com> In-Reply-To: <20200807013834.123263-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: db3ddbf7-ac90-4c76-5dcc-08d83d77542a x-ms-traffictypediagnostic: MW3PR11MB4602: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MW3PR11MB4602AFCBB5279ABBCB385F80E1440@MW3PR11MB4602.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oGHf8wRwMnHmlWgc3q+66u+OgeWdQEowNWKGpt2//L9CmcjiOaLo+XE/7jx1uXZx8zpiferEnKzGtRuQpMjpHWRf3GjdXkFVgcS/zj0KZA4Uw/VUpbDOxn1zqXFoWWEg3ikqAdqWge37fyZ0KUAbF0tJo0/+ItdQztSGWkNHgtAq4vdcCujH3ePdDXn6p3iY86sBwFpduIVHKLSVfts28qfbazpxMhu0mhNxFfMmOYF4RO9M2kuBIwOsvhRdjexEolL0BzPMtnLxMuIcrtYkSCQ2/bWzq9QUl1Coi05XOIaQTiuiXMWaHn/m7Z/DeAlwuYmB04y3L58yg3RMsSDFYQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(136003)(376002)(366004)(346002)(39860400002)(64756008)(66556008)(6506007)(66446008)(6512007)(83380400001)(478600001)(86362001)(2906002)(186003)(76116006)(36756003)(91956017)(2616005)(66476007)(26005)(66946007)(6636002)(316002)(5660300002)(110136005)(8936002)(8676002)(71200400001)(6486002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: B38BZwTx3Cdu9bEMM5ZQk2Alom69YYjCx0y/OIOhKR6xApw7XzNn1Uw1ZLeOQOVuAhDy0HritQ4ElX6rCWBx8bEkcfGqzOXt/fQxnS/JhFnrdqrzbFKtpVjmQ0EwczP4tNxWVAZvimp4SEC7tjxkaE8D13LW1OOxy7pdONM2kA9XEalOVb0tjLIY9C/WZDGUxMKGbf41IUpDD0HAHyGgKIAbkZ610/8dqR3JqT1Rc9sVvfaFYZC/2Q9J+4JTH4LWpkI2AIq+lWcgAhrzVUF0xIbHsXCnl7STRnIjBT9fN/AZgPn1DmbWaZ6FfglxiHx71MtgXZ0GaGDRFzux4aU4P6Bnshf+o34bJgpbR0DTHEiRdqohcZjTKL0NRBTMBOHlXPVA3MU3sqwj3juoryKb6RvZ1OpavYxJwzLaa3UDQ5bShu21DQyVz8fjMSQ/VA3DuGLYGqky+DtVbxuhgHIu6xOZaUujsHSH9L3yVIyluG5v7OGxb9pFGsUhKMQPqhZFnHejtHQEtLGTahMdec2EjzpPxSjy3nFIeaHbsJEsZInYbf61aypBRve1alAbUZgR1gixduADR0GsMgZ0tu5SKK6kAABFWChAHZiGVL7l3JhKsHmTiB34o3bgskTaFQ+OK/D7hr7cXgBi88aNXLvgiA== Content-Type: text/plain; charset="utf-8" Content-ID: <1CEB07D90A095F4B83C5CC6F86D8310D@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: db3ddbf7-ac90-4c76-5dcc-08d83d77542a X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Aug 2020 21:49:59.3219 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Sfu/hVL8RoENlvh0XubFD6X8eQm4HZDvrR2IIH1Viq9/RT0LfXJWyZvgDAgeqvjK7lpG4wR3Y7bKxIsofnd6Ew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4602 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: 915DEA11F8 X-Rspamd-UID: 06f0b3 UGF0Y2hzZXQgQXBwbGllZA0KDQpPbiBUaHUsIDIwMjAtMDgtMDYgYXQgMTg6MzggLTA3MDAsIElu Z2EgU3RvdGxhbmQgd3JvdGU6DQo+IHY1IC0gYWRkcmVzc2VkIG1vcmUgb2YgQnJpYW4ncyBjb21t ZW50cy4gQWRkZWQgbWlzc2luZyByYW5nZSBjaGVja2luZw0KPiANCj4gKioqKioqKioqKioqKioq KioqKg0KPiB2NCAtIEZ1cnRoZXIgZml4ZXMgaW4gaGFuZGxpbmcgS2V5IFJlZnJlc2ggUGhhc2Ug U2V0IG1lc3NhZ2UNCj4gDQo+ICoqKioqKioqKioqKioqKioqKioNCj4gIHYzIC0gYWRkcmVzcyBC cmlhbidzIGNvbW1lbnRzDQo+ICANCj4gKioqKioqKioqKioqKioqKioqKg0KPiBUaGlzIHBhdGNo IHNldCBncm91cHMgZnVuY3Rpb25hbGl0eSBieSBjb25maWcgbWVzc2FnZXMuDQo+IEFsc28sIGZp eGVzIHRoZSBjYXNlcyB3aGVyZSBtYWxmb3JtZWQgbWVzc2FnZXMgc2hvdWxkIGJlICBzaWxlbnRs eQ0KPiBpZ25vcmVkIGFuZCB0aGUgc2l0dWF0aW9ucyB3aGVuIGluY29ycmVjdCBlcnJvciBzdGF0 dXMNCj4gaXMgc2VudCBpbiByZXNwb25zZS4NCj4gDQo+IA0KPiBJbmdhIFN0b3RsYW5kICgxMCk6 DQo+ICAgbWVzaDogQ2xlYW4gdXAgaGFuZGxpbmcgb2YgY29uZmlnIHN1YnNjcmlwdGlvbiBtZXNz YWdlcw0KPiAgIG1lc2g6IENsZWFuIHVwIGhhbmRsaW5nIG9mIGNvbmZpZyBtb2RlbCBiaW5kaW5n IG1lc3NhZ2VzDQo+ICAgbWVzaDogQ2xlYW4gdXAgaGFuZGxpbmcgb2YgY29uZmlnIG5vZGUgaWRl bnRpdHkgbWVzc2FnZQ0KPiAgIG1lc2g6IENsZWFuIHVwIGhhbmRsaW5nIG9mIGNvbmZpZyBwdWJs aWNhdGlvbiBtZXNzYWdlcw0KPiAgIG1lc2g6IENsZWFuIHVwIGhhbmRsaW5nIG9mIGNvbmZpZyBu ZXQgYW5kIGFwcCBrZXkgbWVzc2FnZXMNCj4gICBtZXNoOiBDbGVhbiB1cCBoYW5kbGluZyBvZiBj b25maWcgcmVsYXkgbWVzc2FnZXMNCj4gICBtZXNoOiBDbGVhbiB1cCBoYW5kbGluZyBvZiBjb25m aWcgcG9sbCB0aW1lb3V0IG1lc3NhZ2UNCj4gICBtZXNoOiBDbGVhbiB1cCBoYW5kbGluZyBvZiBj b25maWcgbmV0IHRyYW5zbWl0IG1lc3NhZ2VzDQo+ICAgbWVzaDogQ2xlYW4gdXAgaGFuZGxpbmcg b2YgY29uZmlnIEtSIHBoYXNlIG1lc3NhZ2VzDQo+ICAgbWVzaDogUmVmYWN0b3IgaGVhcnRiZWF0 IHB1Yi9zdWINCj4gDQo+ICBtZXNoL2NmZ21vZC1zZXJ2ZXIuYyAgICB8IDExOTggKysrKysrKysr KysrKysrKystLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQo+ICBtZXNoL2NmZ21vZC5oICAgICAgICAg ICB8ICAgIDIgKy0NCj4gIG1lc2gvbWVzaC1jb25maWctanNvbi5jIHwgICAxMiArLQ0KPiAgbWVz aC9tZXNoLWNvbmZpZy5oICAgICAgfCAgICA2ICstDQo+ICBtZXNoL21lc2gtZGVmcy5oICAgICAg ICB8ICAgIDYgKw0KPiAgbWVzaC9tb2RlbC5jICAgICAgICAgICAgfCAgMjM4ICsrKystLS0tDQo+ ICBtZXNoL21vZGVsLmggICAgICAgICAgICB8ICAgMjEgKy0NCj4gIG1lc2gvbmV0LmMgICAgICAg ICAgICAgIHwgIDMyNiArKysrKysrLS0tLQ0KPiAgbWVzaC9uZXQuaCAgICAgICAgICAgICAgfCAg IDU0ICstDQo+ICBtZXNoL25vZGUuaCAgICAgICAgICAgICB8ICAgIDQgLQ0KPiAgMTAgZmlsZXMg Y2hhbmdlZCwgOTI0IGluc2VydGlvbnMoKyksIDk0MyBkZWxldGlvbnMoLSkNCj4gDQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sFneHKzLMV8O8gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 00:35:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iAhFG6zLMV/GagEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 00:35:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6852FA0FCD; Tue, 11 Aug 2020 00:35:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726775AbgHJWfP convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 18:35:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:56292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726439AbgHJWfP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 18:35:15 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Mon, 10 Aug 2020 22:35:12 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vicpt@protonmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc attachments.created Message-ID: <bug-60824-62941-rTyOB7Sb7D@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.90 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6852FA0FCD X-Rspamd-UID: 526efa https://bugzilla.kernel.org/show_bug.cgi?id=60824 vic (vicpt@protonmail.com) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vicpt@protonmail.com --- Comment #128 from vic (vicpt@protonmail.com) --- Created attachment 290829 --> https://bugzilla.kernel.org/attachment.cgi?id=290829&action=edit Relevant info (In reply to Swyter from comment #111) > Just submitted v4 for kernel review. Its behavior should be identical to v3, > it only contains a few minor technical changes and logic flow tweaks, to > appease the BlueZ gods. Nothing new. > ... > https://patchwork.kernel.org/patch/11686157/ Tried your patch on my current in use kernel 5.7.12 but unfortunately can't get my fake CSR to initiate properly. Hcidump and other relevant info in attachment. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KkT8EvsRMl93EgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 05:35:23 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id sGsjEfsRMl8QQAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 05:35:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AE61DA01FB; Tue, 11 Aug 2020 05:35:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728190AbgHKDfJ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 10 Aug 2020 23:35:09 -0400 Received: from mail-io1-f71.google.com ([209.85.166.71]:47773 "EHLO mail-io1-f71.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727912AbgHKDfI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 10 Aug 2020 23:35:08 -0400 Received: by mail-io1-f71.google.com with SMTP id 18so8738360ioo.14 for <linux-bluetooth@vger.kernel.org>; Mon, 10 Aug 2020 20:35:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=0XXF4gP00AKnsVQiDFXbJzMYIOYWHxHdd4RVsRPAbhc=; b=XdkL7YE1dZ6GHmkwM4Oxe/LzLuYeliVu/GQynz/r97vHieBb6JCVRzzaSMI3upbbf7 BM/vlyk+nVtn8BGOvcIZOBdKu8tTJw1fg+yv63RLpGnV2R8B5QWtlKRUmqQWbVBPQlYc IJOjDxBVKKCwITZHOhEnPK3jCrakkNgUMcIf6/3zIUg+U50iqTkBbKbaR+tndWFgxc79 Ch2gBIfeFe7PO51RqLK3+RigXoOHacqPhHzSCFQ5JiR56kZyD4OrtMPwwXCdsPwD4JhC 2U9yggGJkLKPKSI9uxmuYz6CJSer/u2O38M2JrSzq7L7nHH8P/fyEx7PlTXnlzg5fhgp EIjw== X-Gm-Message-State: AOAM530UnWiztDdwHXNW+gIdq/Plgv8KhPG7N8KWpCMxccBq89H+yjuY AR6Ya2PfsJG2A/5lyQHGbjdQVvFlNPydX6V84iDw4hPQnfP7 X-Google-Smtp-Source: ABdhPJxgP7ejVjnfsazNH0Tqy82Cxwho0b25shTclrrEX2JEZZQVzsMpsyfvz791kmnbkiw1QrmUlfEf4tjZSNi1+1P0jsQ/cPE1 MIME-Version: 1.0 X-Received: by 2002:a6b:5502:: with SMTP id j2mr20825119iob.204.1597116908036; Mon, 10 Aug 2020 20:35:08 -0700 (PDT) Date: Mon, 10 Aug 2020 20:35:08 -0700 In-Reply-To: <000000000000734f2505ac0f2426@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000f7ec6f05ac91c11d@google.com> Subject: Re: KASAN: use-after-free Write in hci_conn_del From: syzbot <syzbot+7b1677fecb5976b0a099@syzkaller.appspotmail.com> To: clm@fb.com, davem@davemloft.net, dsterba@suse.com, johan.hedberg@gmail.com, josef@toxicpanda.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, nborisov@suse.com, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.45 / 15.00 / 200.00 X-Rspamd-Queue-Id: AE61DA01FB X-Rspamd-UID: 8ff520 syzbot has bisected this issue to: commit 6a3c7f5c87854e948c3c234e5f5e745c7c553722 Author: Nikolay Borisov <nborisov@suse.com> Date: Thu May 28 08:05:13 2020 +0000 btrfs: don't balance btree inode pages from buffered write path bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=14f973c2900000 start commit: 5631c5e0 Merge tag 'xfs-5.9-merge-7' of git://git.kernel.o.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=16f973c2900000 console output: https://syzkaller.appspot.com/x/log.txt?x=12f973c2900000 kernel config: https://syzkaller.appspot.com/x/.config?x=afba7c06f91e56eb dashboard link: https://syzkaller.appspot.com/bug?extid=7b1677fecb5976b0a099 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=155d73fa900000 Reported-by: syzbot+7b1677fecb5976b0a099@syzkaller.appspotmail.com Fixes: 6a3c7f5c8785 ("btrfs: don't balance btree inode pages from buffered write path") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AG4nLvk/Ml9LVwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 08:51:37 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QFviLPk/Ml+wugAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 08:51:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 619B5418AF; Tue, 11 Aug 2020 08:51:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728253AbgHKGvR (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 02:51:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:34292 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727971AbgHKGvQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 02:51:16 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E2729AD43; Tue, 11 Aug 2020 06:51:35 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id D9FD0DAFD3; Tue, 11 Aug 2020 08:50:13 +0200 (CEST) Date: Tue, 11 Aug 2020 08:50:13 +0200 From: David Sterba <dsterba@suse.cz> To: syzbot <syzbot+7b1677fecb5976b0a099@syzkaller.appspotmail.com> Cc: clm@fb.com, davem@davemloft.net, dsterba@suse.com, johan.hedberg@gmail.com, josef@toxicpanda.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, nborisov@suse.com, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: KASAN: use-after-free Write in hci_conn_del Message-ID: <20200811065013.GI2026@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, syzbot <syzbot+7b1677fecb5976b0a099@syzkaller.appspotmail.com>, clm@fb.com, davem@davemloft.net, dsterba@suse.com, johan.hedberg@gmail.com, josef@toxicpanda.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, nborisov@suse.com, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com References: <000000000000734f2505ac0f2426@google.com> <000000000000f7ec6f05ac91c11d@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000000000000f7ec6f05ac91c11d@google.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: 619B5418AF X-Rspamd-UID: d69717 On Mon, Aug 10, 2020 at 08:35:08PM -0700, syzbot wrote: > syzbot has bisected this issue to: > > commit 6a3c7f5c87854e948c3c234e5f5e745c7c553722 > Author: Nikolay Borisov <nborisov@suse.com> > Date: Thu May 28 08:05:13 2020 +0000 > > btrfs: don't balance btree inode pages from buffered write path This does not make sense wrt use-after-free in HCI, which is completely unrelated subsystem. The patch removes a call to function doing some potentially heavy work, so this likely affects timing and making the bisection unreliable. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sHXsC0ufMl/ibwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 15:38:19 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UI1KCkufMl9ReAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 15:38:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F413BA281C; Tue, 11 Aug 2020 15:38:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728614AbgHKNiN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 09:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728532AbgHKNiN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 09:38:13 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D728BC06174A for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 06:38:12 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id b30so6668292lfj.12 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 06:38:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=RCyZYPQarluAYNVjuTSqO+Z2+TU6RV9vTCrq9qlBlfY=; b=qAopXdLwEQfbvL/gbWcJKBr5f0NhiW7os3EIIPFK4Vxcf6wUZkj+sUb7dpxPIpy4Ni t9rgScCn4ROyFy02sfsNT7jHleK7T6seKkWJ5xDe1l7a3NUzxQiHo8xDklu/oCSltG1K o3NljsBErJ1vvdKKqJoFY7K76a0fu8lLvK9hGdldkBzDVH21nLn2KTq/h0xkwlLffj0D ndDLZptXvZpSVlzVUn6qeU3oGWPPkeyfwoyVeizZA7oMuB/OwZ2/FofvommeI2NaqiCS QHcs9zp4ZFVlUB/GNSU2VA2mKz/VOnSxrheNfBPzdXyaHArRbQpQTQx9pJ3S6wMPL01+ qCoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=RCyZYPQarluAYNVjuTSqO+Z2+TU6RV9vTCrq9qlBlfY=; b=jqOaqTHB65xX6C/2avHcpmmlnWXrO11deH32TPiEwNZ0+epC1cUCUqmlRLMQKah09e 87GQ+C6MESKQTj5oZLDXyyUP3469wmhS1Jw19e9IqEfLR0SklYb1Z/5m6V9V2yYcAuma UkkfYjD1oq2lcD2wEQTNtAHAq9N9oCQk2qS0m05Wl3jhsBgwFqbTJMG4RJB/ryDl/uKR qXhbJn2iOIQxk2RPxT95IGIkp+BlVkTiVNcPOAx/+pGrBFF19xyP893m9PwBnaIVyGKC 6zoAmM7z2NEwAz9CsqMQ0rNEovkj5MO/G5mJF7pzWaR+sitppGgHs4kOm+/NTnQEwWAt UK3g== X-Gm-Message-State: AOAM530FbAy2JuPgtsGzyOCo9peVgoz7Ly7Mo39ApbL6hoRdOftgxNoa t5x3xvAND+RcPRA+bNch/FrmX4zcbQ0= X-Google-Smtp-Source: ABdhPJzW1sWoD5Ql3b4dzjt3MsGzqOWO65E4CECvI7zhooM0z/iqis+1OlMJdrGqO0Ae+kKyO+w57A== X-Received: by 2002:a19:fc14:: with SMTP id a20mr3310545lfi.0.1597153086267; Tue, 11 Aug 2020 06:38:06 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id w11sm11579622lff.62.2020.08.11.06.38.04 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 06:38:05 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= <michal.lowas-rzechonek@silvair.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] mesh: Fix application key binding lookup Date: Tue, 11 Aug 2020 15:39:07 +0200 Message-Id: <20200811133907.8249-1-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: F413BA281C X-Rspamd-UID: 27292a Because l_queue_find can't distinguish between entry->data equal to zero and missing entry, has_binding() fails when we bind app key with index 0, via L_UINT_TO_PTR. Bug has been introduced in commit 1a2a6debd --- mesh/model.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mesh/model.c b/mesh/model.c index 4eaad31be..7d7f1551a 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -140,7 +140,15 @@ static bool simple_match(const void *a, const void *b) static bool has_binding(struct l_queue *bindings, uint16_t idx) { - return l_queue_find(bindings, simple_match, L_UINT_TO_PTR(idx)) != NULL; + /* don't use l_queue_find, it can't distinguish between missing entry + * and entry with data equal to NULL */ + const struct l_queue_entry *entry; + + for (entry = l_queue_get_entries(bindings); entry; entry = entry->next) + if (L_PTR_TO_INT(entry->data) == idx) + return true; + + return false; } static bool find_virt_by_label(const void *a, const void *b) -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qJUOGCOiMl/ibwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 15:50:27 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MPs2FiOiMl8SQAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 15:50:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5DB69420C2; Tue, 11 Aug 2020 15:50:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728783AbgHKNuN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 09:50:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728781AbgHKNuI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 09:50:08 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB593C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 06:50:07 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id k18so9401477qtm.10 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 06:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=w+qODleQQsKHZ1WWrEjUAUHGpfYDNjuEG5I1xgDqiqw=; b=UiXzMu2ZQMNFIUP2BS80wsk1I6I4Vcbcjk7BbrsCYsZ/kdkrxO8KFydAOENZCAgTR0 zP7SbgADrXj65RGevnYq5cXm8LtdEsDeAEWJ24EH6s9408IBPvj+8ILkhSgRitY4ZORZ xzRVsRpxlO6bFgJBZnvaJugJc1AOt4leoA/n9vqms2VsxURjnU1CeFu7SuuVWlMRjP8q vhjAK9xDy66Zrstgw3rFADDOMbq6at3WRWhfpxVWHrfBR/ktVqaobJnddDwY5jasu0BU dJs+519UfMGeLNRQWc6HGAtg8KXXtsgfIeI89kV3plTbol1lSP/cvPukX+V0pE2+8uvy T6qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=w+qODleQQsKHZ1WWrEjUAUHGpfYDNjuEG5I1xgDqiqw=; b=A4t4Yftue9g9jTBg0mKGaR2ZCfZaQTi7TuKxwtHaMmpkgiN6BwSCb6H0S6tF9dgFmc 57lMvgA17rC83C4v88T7WZf2NU4Y48cwPU6k7kbOBkSpb0yKBMJJPZz5gLQx95Ogin8J 4SgGiv1xUTLafzm3FKWRg7/Jacm6wBl4UNV7OMdUmmC3n2Pju3vZhRe5+waarNvF+t56 l4ib/dglx5FYpGx8iPAXCX4mwxyw964MY+OpnVgw9+uCCvlzEaJTIQvanH89qcvMBrBh xrDlVAFgbwHGBwzdY6mhISFNXc5gLfiCMawChVFSOc2tkTHW2CLcyaQOfLydWmMkuhGU RJ6g== X-Gm-Message-State: AOAM530/yDAZ8bTgWd5c5FJ3okOp26r8JMxZ1M7jpr/DWLIIVTuFVxdD seC0mjexxPirvXwiA5lIR5hh/xNV6yU= X-Google-Smtp-Source: ABdhPJwOqp69NLU1HYy9v1whcIGKYX/g0pMlB3Wl0qD2JfNwwNgQOXJ4LEk2w1FRpC7MvWvcM8aZ/g== X-Received: by 2002:aed:3e90:: with SMTP id n16mr1140988qtf.37.1597153805984; Tue, 11 Aug 2020 06:50:05 -0700 (PDT) Received: from [172.17.0.2] ([20.36.202.113]) by smtp.gmail.com with ESMTPSA id w1sm17910057qkj.90.2020.08.11.06.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 06:50:05 -0700 (PDT) Message-ID: <5f32a20d.1c69fb81.54e64.69a4@mx.google.com> Date: Tue, 11 Aug 2020 06:50:05 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============7420580290351379786==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, michal.lowas-rzechonek@silvair.com Subject: RE: [BlueZ] mesh: Fix application key binding lookup Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200811133907.8249-1-michal.lowas-rzechonek@silvair.com> References: <20200811133907.8249-1-michal.lowas-rzechonek@silvair.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 4.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5DB69420C2 X-Rspamd-UID: 66756c --===============7420580290351379786== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit 1a2a6debd00a ("mesh: Clean up handling of config model binding messages")' #11: Bug has been introduced in commit 1a2a6debd WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line #23: FILE: mesh/model.c:115: + * and entry with data equal to NULL */ - total: 1 errors, 1 warnings, 16 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============7420580290351379786==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YOVbLB2vMl/B6AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 16:45:49 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wPyfKh2vMl/0ogAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 16:45:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 53F64420CA; Tue, 11 Aug 2020 16:45:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728817AbgHKOpm (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 10:45:42 -0400 Received: from mga17.intel.com ([192.55.52.151]:42784 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728794AbgHKOpl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 10:45:41 -0400 IronPort-SDR: /VTP3db7TndUaGyVzSNud4vTAYpLcZJCnNcEUPcnCge9a2rf0d1swNdHAp0tcfHziM4yQ8P/Es YO+Qh1Y1Oa/g== X-IronPort-AV: E=McAfee;i="6000,8403,9710"; a="133790179" X-IronPort-AV: E=Sophos;i="5.76,461,1592895600"; d="scan'208";a="133790179" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2020 07:45:40 -0700 IronPort-SDR: ZK/iLEJ15/2Gp89LmraZRB7ouSMYEKXHQSLCr9dEsvi6LOPiVZzxL6xUbfPd2PhyZO9IRfpsBZ GQUxcrPrMS7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,461,1592895600"; d="scan'208";a="276311653" Received: from orsmsx605-2.jf.intel.com (HELO ORSMSX605.amr.corp.intel.com) ([10.22.229.85]) by fmsmga007.fm.intel.com with ESMTP; 11 Aug 2020 07:45:39 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 11 Aug 2020 07:45:39 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 11 Aug 2020 07:45:39 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.103) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 11 Aug 2020 07:45:38 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gJhhmaQtWc2zJBHAEl52CK4oxqtDDYJWoIojfdcCu1LNQagFgt4w+1elwmw9FInD9WTv2ANCaBUPYNm9RBHTpceolczB8CQkOGCZ0fbEdNsWQCidTKo+gQSIE6qlNJeAf1u60dj+jPXjav9ku0J1ID/8zMfoO/bu6EDMlg5BSAcsB1aUsxe37jMVt0ivnmDf2uTXFz6c14mRa2VRI0vEW8Bpa5H5Y25SunMpHxMqVHo/323Lh9yGJRUF46QeLFICV+zbxKqvTS7dzyjUuOvk5yfrUlpPYm8dJALHdaUQ7EzkCEYS+b+uhP/IjxfJIduGVChuhSDB0C8+rlROdW0OhQ== 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-SenderADCheck; bh=Ku4Jzp8qaohDkLYr1wbrismdZI/3mj474AdX3srNSbg=; b=LCGqVwlDa+arRTR2oHhQbLaPOIE4ZltTQChH50ekxuHHte4Frarb/pemR07+wMh7C/93x6gv7WLXQ/mNUeKTxJ2MuLZMZnObkcwA6wWfJgnfKexul2VIPVRn2q/slRlG70OZ4TeFQy9r2FdeCm+ajGMPYlSCm0jSI1zUzo+UcdoHDnNEIqYQfFxMh27diNTuT9SrvFqzmTWW4ps2EANbF/aVEY9fHUMaVcPBZtTDul3xpEGKzxz1/xURZzhIyNp/sRP7KMkJyIeHrWnreaE4ZNlaQiRFxa7RM24iaAVi+2Atbdpggs3Ab6SDpvYle8muwF1rS8f43uRACQMyMIhzWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ku4Jzp8qaohDkLYr1wbrismdZI/3mj474AdX3srNSbg=; b=yBWYKBm/5iubqGfAyPPgNEG9aaywOGONeCajgtl1KoLx9yGGch9QQ59XlTjTHfWlH2E/iT7IdsiGuuKky+2eeWN1g0dZqwTp/hah2Oa20BjwdUz4rhgzyjDTYjTV9APnS30prdPAk/g6qjI0iMfv9ogHv31vczaJBUYN/sCJ5CY= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1680.namprd11.prod.outlook.com (2603:10b6:301:d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Tue, 11 Aug 2020 14:45:37 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3261.025; Tue, 11 Aug 2020 14:45:36 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "michal.lowas-rzechonek@silvair.com" <michal.lowas-rzechonek@silvair.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Subject: Re: [PATCH BlueZ] mesh: Fix application key binding lookup Thread-Topic: [PATCH BlueZ] mesh: Fix application key binding lookup Thread-Index: AQHWb+Swk4oatecJNkO/IyZuZpxm2Kky/FqA Date: Tue, 11 Aug 2020 14:45:36 +0000 Message-ID: <98f53d6f9bf01499848b4409a9bca17ad2a7d173.camel@intel.com> References: <20200811133907.8249-1-michal.lowas-rzechonek@silvair.com> In-Reply-To: <20200811133907.8249-1-michal.lowas-rzechonek@silvair.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: silvair.com; dkim=none (message not signed) header.d=none;silvair.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2e40e385-c52e-4384-2f42-08d83e0535b6 x-ms-traffictypediagnostic: MWHPR11MB1680: x-microsoft-antispam-prvs: <MWHPR11MB1680BAB488E0AF9B978236A6E1450@MWHPR11MB1680.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:2887; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: N4OaQZ+jqOVS1Vxm2qsCVtLwKAD2kBhfTfMiu30+9S6VqhXk+FLNxde6PXXK5qBxp13XnHM/2J76xfCDi9cGHeoVAYR9uIjy9DvACQHu9cwEVmhTVmmyspROZbZTFrBLWuyCkX28cj5fOKyU6mXCCaxyIBJSSu88p6sQJWd3X2Om82uAwzYO7MNaLGpbe7Ph2tL1YHIxejQfO0ist5PUoxQ/asbkwm03WUszpRi+KfDQYc4j16A8TSG26TWWu85XAdvcIII0yWEVAL1K+A51DH0P+LjtTlFPTXrJc/qjWtVJmLKASlXJTQECa2sjGlouAZ6pWftPrrZs+NfsGyty/w== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(376002)(366004)(136003)(39860400002)(396003)(66556008)(66476007)(66446008)(64756008)(66946007)(6512007)(8676002)(36756003)(71200400001)(86362001)(5660300002)(2906002)(91956017)(76116006)(8936002)(83380400001)(26005)(6506007)(316002)(6486002)(186003)(2616005)(478600001)(110136005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: jUmzG6q2L25/W4ZiQZFg9rJpG+SSSMmG1lIPXUgvcaP13T5LVoBg1MCj8EaZbbr3L2ylbMxdekxF6A4NQ+tDRgFBEVsm0jzShpQ7B9auIoif90MZx661EJNMdgQLzcHELRaFKzz8yOkzm1NgtkyBiqpLDNJGRf4pu/Za1cOapcnRc8JSavX+TkEi0+Pnz5Cl03rlJI5XNhHsJY1G1BfEkkW1Bek9aUpg6L1ujRV7JwZBiNxBQ0G4K/l+vvAVr/4vgGepN/iV8NP+rZIH0GmieAfcbwsdivBX/dCVhMzNDTEY5KxxgflaxbutsxOAM6BrTvJmk+U7P4Cvcl1XFg2IbYqeoodd0jifQiZYt5BaZR5FxvbDRkgZ8sH7UjS8htqQvymO1FwWCQFu28wG9eSA91xZwuDq/TWLMGHt5fEjvYqBR+gj6jARDGX4jMeghNlAWuaHWK/7ugD3Ouv9+HrwtowXouRsi3ccyfGAdaiQdUOzAhTaAC0XTxNnE9+IPuNSoW1qpwCicK4tjtrNAJilmuZBB4lTGCwwYZsNB5bHxK5cPraQVXuiDTI/cRFTyPmp62iMI4szwCNiWZ5XoYqw4jwBZuSa9pcY9Lwrto2FcsEj4w5UQpxQBWJZ1wBGdbcZ51PPyH9GSKxmJN3/YECEnA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="utf-8" Content-ID: <BB60050838811A43A70C00C8A1F71BE5@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e40e385-c52e-4384-2f42-08d83e0535b6 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Aug 2020 14:45:36.8073 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: /RYTZMCsD3QL+F7A8TkTvCGK9Y4gWAo+e0DdHYZ4svWI52U4V0GNoAgP6HG2riZYFmu3k3GlqW0ginXunO2NjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1680 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 53F64420CA X-Rspamd-UID: e6253b QXBwbGllZCwgVGhhbmtzLg0KDQpPbiBUdWUsIDIwMjAtMDgtMTEgYXQgMTU6MzkgKzAyMDAsIE1p Y2hhxYIgTG93YXMtUnplY2hvbmVrIHdyb3RlOg0KPiBCZWNhdXNlIGxfcXVldWVfZmluZCBjYW4n dCBkaXN0aW5ndWlzaCBiZXR3ZWVuIGVudHJ5LT5kYXRhIGVxdWFsIHRvIHplcm8NCj4gYW5kIG1p c3NpbmcgZW50cnksIGhhc19iaW5kaW5nKCkgZmFpbHMgd2hlbiB3ZSBiaW5kIGFwcCBrZXkgd2l0 aCBpbmRleA0KPiAwLCB2aWEgTF9VSU5UX1RPX1BUUi4NCj4gDQo+IEJ1ZyBoYXMgYmVlbiBpbnRy b2R1Y2VkIGluIGNvbW1pdCAxYTJhNmRlYmQNCj4gLS0tDQo+ICBtZXNoL21vZGVsLmMgfCAxMCAr KysrKysrKystDQo+ICAxIGZpbGUgY2hhbmdlZCwgOSBpbnNlcnRpb25zKCspLCAxIGRlbGV0aW9u KC0pDQo+IA0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9tb2RlbC5jIGIvbWVzaC9tb2RlbC5jDQo+IGlu ZGV4IDRlYWFkMzFiZS4uN2Q3ZjE1NTFhIDEwMDY0NA0KPiAtLS0gYS9tZXNoL21vZGVsLmMNCj4g KysrIGIvbWVzaC9tb2RlbC5jDQo+IEBAIC0xNDAsNyArMTQwLDE1IEBAIHN0YXRpYyBib29sIHNp bXBsZV9tYXRjaChjb25zdCB2b2lkICphLCBjb25zdCB2b2lkICpiKQ0KPiAgDQo+ICBzdGF0aWMg Ym9vbCBoYXNfYmluZGluZyhzdHJ1Y3QgbF9xdWV1ZSAqYmluZGluZ3MsIHVpbnQxNl90IGlkeCkN Cj4gIHsNCj4gLQlyZXR1cm4gbF9xdWV1ZV9maW5kKGJpbmRpbmdzLCBzaW1wbGVfbWF0Y2gsIExf VUlOVF9UT19QVFIoaWR4KSkgIT0gTlVMTDsNCj4gKwkvKiBkb24ndCB1c2UgbF9xdWV1ZV9maW5k LCBpdCBjYW4ndCBkaXN0aW5ndWlzaCBiZXR3ZWVuIG1pc3NpbmcgZW50cnkNCj4gKwkgKiBhbmQg ZW50cnkgd2l0aCBkYXRhIGVxdWFsIHRvIE5VTEwgKi8NCj4gKwljb25zdCBzdHJ1Y3QgbF9xdWV1 ZV9lbnRyeSAqZW50cnk7DQo+ICsNCj4gKwlmb3IgKGVudHJ5ID0gbF9xdWV1ZV9nZXRfZW50cmll cyhiaW5kaW5ncyk7IGVudHJ5OyBlbnRyeSA9IGVudHJ5LT5uZXh0KQ0KPiArCQlpZiAoTF9QVFJf VE9fSU5UKGVudHJ5LT5kYXRhKSA9PSBpZHgpDQo+ICsJCQlyZXR1cm4gdHJ1ZTsNCj4gKw0KPiAr CXJldHVybiBmYWxzZTsNCj4gIH0NCj4gIA0KPiAgc3RhdGljIGJvb2wgZmluZF92aXJ0X2J5X2xh YmVsKGNvbnN0IHZvaWQgKmEsIGNvbnN0IHZvaWQgKmIpDQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QEMoIh3IMl9KuwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 18:32:29 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id oAFmIB3IMl9VzgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 18:32:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 493FE41870; Tue, 11 Aug 2020 18:32:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729323AbgHKQbi (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 12:31:38 -0400 Received: from mga17.intel.com ([192.55.52.151]:55308 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728862AbgHKQbh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 12:31:37 -0400 IronPort-SDR: UsA247tjODg3NCIJh7xgjKivTr9MqDQ20/ipqtreUiiJlwn6gvskyPmyl7TS3bjSk4YrEPuh1p bZaGm71gcOfQ== X-IronPort-AV: E=McAfee;i="6000,8403,9710"; a="133815955" X-IronPort-AV: E=Sophos;i="5.76,301,1592895600"; d="scan'208";a="133815955" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2020 09:31:36 -0700 IronPort-SDR: E1rAa5ZhJVqw8TldjmV/5rE7uKjqNyKr3m920gcghLRXUNmd7W5u5ph5xaDSH5DZlddOcmmVLx P4UvM9Zreq/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,301,1592895600"; d="scan'208";a="294767768" Received: from rajkumar-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.82.230]) by orsmga006.jf.intel.com with ESMTP; 11 Aug 2020 09:31:35 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] mesh: Fix element index look up for config model subs Date: Tue, 11 Aug 2020 09:31:34 -0700 Message-Id: <20200811163134.8561-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 493FE41870 X-Rspamd-UID: 9de065 Use element address for looking up element index (subscription address was erroneously used to perform the lookup). --- mesh/model.c | 15 ++++++++------- mesh/model.h | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mesh/model.c b/mesh/model.c index 690be29d5..23afb93a8 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -1402,13 +1402,13 @@ done: return MESH_STATUS_SUCCESS; } -int mesh_model_sub_get(struct mesh_node *node, uint16_t addr, uint32_t id, +int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size) { int16_t n; struct mesh_model *mod; const struct l_queue_entry *entry; - int ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, ele_addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1454,7 +1454,7 @@ int mesh_model_sub_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint16_t addr) { struct mesh_model *mod; - int status, ele_idx = node_get_element_idx(node, addr); + int status, ele_idx = node_get_element_idx(node, ele_addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1510,7 +1510,7 @@ int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint16_t addr) { struct mesh_model *mod; - int ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, ele_addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1567,7 +1567,7 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint16_t addr) { struct mesh_model *mod; - int ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, ele_addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; @@ -1629,10 +1629,11 @@ int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, return MESH_STATUS_SUCCESS; } -int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id) +int mesh_model_sub_del_all(struct mesh_node *node, uint16_t ele_addr, + uint32_t id) { struct mesh_model *mod; - int ele_idx = node_get_element_idx(node, addr); + int ele_idx = node_get_element_idx(node, ele_addr); if (ele_idx < 0) return MESH_STATUS_INVALID_ADDRESS; diff --git a/mesh/model.h b/mesh/model.h index a88d25d77..147a02279 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -98,7 +98,8 @@ int mesh_model_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, int mesh_model_virt_sub_del(struct mesh_node *node, uint16_t ele_addr, uint32_t id, const uint8_t *label, uint16_t *addr); -int mesh_model_sub_del_all(struct mesh_node *node, uint16_t addr, uint32_t id); +int mesh_model_sub_del_all(struct mesh_node *node, uint16_t ele_addr, + uint32_t id); int mesh_model_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint16_t addr); int mesh_model_virt_sub_ovrt(struct mesh_node *node, uint16_t ele_addr, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gN0iKhPJMl96mgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 18:36:35 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id KHUgKRPJMl9qDAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 18:36:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 727A2420D1; Tue, 11 Aug 2020 18:36:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729248AbgHKQgH (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 12:36:07 -0400 Received: from mga07.intel.com ([134.134.136.100]:13796 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729121AbgHKQfq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 12:35:46 -0400 IronPort-SDR: pkWSbyIig5YpGEp9b7KJNb5hnKtIwXW6b6lGqGhi8NA/M39rPEB21ThiiFAlO/INdQ8+maURpx p1gcEa8zxXNA== X-IronPort-AV: E=McAfee;i="6000,8403,9710"; a="218108531" X-IronPort-AV: E=Sophos;i="5.76,301,1592895600"; d="scan'208";a="218108531" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2020 09:35:45 -0700 IronPort-SDR: khF0RyFQRNxOxUfgHHMSIP0l/+ykplDdEISSN+LKafAvwpZd9S5wADPjM+xEkfyxZNBC9WA/Qp Eh2btyq1nz2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,301,1592895600"; d="scan'208";a="276335730" Received: from orsmsx602-2.jf.intel.com (HELO ORSMSX602.amr.corp.intel.com) ([10.22.229.82]) by fmsmga007.fm.intel.com with ESMTP; 11 Aug 2020 09:35:44 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 11 Aug 2020 09:35:44 -0700 Received: from orsmsx105.amr.corp.intel.com (10.22.225.132) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 11 Aug 2020 09:35:44 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX105.amr.corp.intel.com (10.22.225.132) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 11 Aug 2020 09:35:43 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.171) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 11 Aug 2020 09:35:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fBtUGJGdAlyHVW21S/yRNtzo9PUBqTdzP5Lovo9AW/TqrfwCMJS7dth1oXYArVvG82Tagn+Nabstup4ywtVGLXb9ZjkLmgoXpt3XSoMC9jsw2/td6sHsFCcc7+ICB4dlet5pKySosuoI378LHzCcEBll7p+D70t1Ndis8RJViYauVVdOJCLisr3XwwbLjoZv3llYZFvFOji2bFjSP//kEG8ikZf1BRvcDA7PQobacz+sobewdT/qKXemerIw8r7vdW/znGxnWxGjfEDxKjcdbF5FvUftlPxEotdujelZuEbiT+79cVc5SHAB+3hYWJ5JVJPfqoIK6oEZ3X2vU6vvlg== 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-SenderADCheck; bh=TmFLbYhOATAsHB28RazPlVFEC5JoLJWO95nIh5ntNGM=; b=h5rhZPZp3pwQ9HDRKE+W4C889HE/2rUTdu7+9gVLCk7OHpsDjPqwI1FiGHVZ9rDjHS939Vu5lenY5LcC3eWZezJ5pEUq9aDFjtcmVUzWCV3MNha/SOcJrFYsNvrGen1NJWhQE078s13MFO8hUb59JxtxvkGJZVTXAPea3BTPY8QoeM8lnN+Sksi9MIAaCg4aow9z9mvu3hEAsohVmRkwZyowLdYl+P12z/H3m/EErUj1RNRXFKLMPzQ/lxFXHt4njWWSOw4ylogITBaPAmSpXy7Z4lz/zJSsrJCKSxl7qles28142f+A59Gc/4sYAVyVpDkqLWQeU2ivtr4UTVZQrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TmFLbYhOATAsHB28RazPlVFEC5JoLJWO95nIh5ntNGM=; b=YIwCcLKQDhkGPUolR8y4NR/w1rSawbdZtjvpWFVv0P9eAtve/SF5MZVN6St+QPLlfk/rEMgqHkh5zK0nrJyTha5fN77n0TIZZ9SDJv/59/89Gi81w1FaJMZz69nE11RHuM67DMLb/VAlWcBqX6QIkPTB/kFQRhjjeeUNDHFJKrk= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1311.namprd11.prod.outlook.com (2603:10b6:300:2a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Tue, 11 Aug 2020 16:35:42 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3261.025; Tue, 11 Aug 2020 16:35:42 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: Fix element index look up for config model subs Thread-Topic: [PATCH BlueZ] mesh: Fix element index look up for config model subs Thread-Index: AQHWb/zq/0NZdSIbE0WrsBFB0HqzxqkzGu4A Date: Tue, 11 Aug 2020 16:35:42 +0000 Message-ID: <e277c5f0ab4207198879e0dfa85e7f6a9daea6f4.camel@intel.com> References: <20200811163134.8561-1-inga.stotland@intel.com> In-Reply-To: <20200811163134.8561-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2050df03-e21e-4365-3e4c-08d83e14971e x-ms-traffictypediagnostic: MWHPR11MB1311: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR11MB1311485E4D92EA4660DA282EE1450@MWHPR11MB1311.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:6790; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9Uc0MQ0yZgrvW+l/EbOIA/xUQI3we7qHgaBSBqE5kPQmLyVbSLbXb4MDq3lXQV8luqyTIQg+/yC9OusziG/+aod8wlTwf0ZIreSiIC6lHhMb96AAwQaZVto+rgS2OlbJzPIHLuIm+P77Uc/zM4yl1G3ayPU1ZF0q3mDer2653q2WuUqyqPSO5hC7H9DsQLJ5+XlyQzg969yES1dCLV0glLN8/J/rHLGUIbe2q57RH8mXydfRBZQIERYw4TvJgZPKHPUmNP0c6EqEkGdpQM2Nu2rQBs/Z1eOVln70gX1qUSgjpJ8HNVGrizwSPneP3ODPGbvbT8+Hp1dlm0j76hI1Bg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(39860400002)(396003)(346002)(366004)(136003)(83380400001)(6512007)(8676002)(86362001)(5660300002)(6486002)(6636002)(8936002)(186003)(2616005)(6506007)(478600001)(110136005)(64756008)(66946007)(76116006)(91956017)(66556008)(66446008)(36756003)(2906002)(71200400001)(26005)(66476007)(316002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: VaJNTHq5LEZ/7meMcmvF3Clz8dtKmoJfceLprEk224v71akrjzynxfCUGoA91uVvKir67b7dLnpuHFywFOgileXCRk1G5Gtf0plaROtIEFvUyhUuvtmJiEA8MYufmLcbU4iq6PwsqFGd6DWaPUJ1WWRZPRbRNLJNT91zcvKtJrase8RvptsSK/1Ut5dIAMZoyc8a5w5f44dQ48o28AY+xQeGqwfUnpRTmruKYEum0NsEzR0yRYCV5pSy/kmorEjvk0Emh4oUPXbJ80Xiy3I/3aT3YECGW7jNMMWkFdvvhbd7BNUnZaH+RQn2OpuMwB2MWaFvi3lJ7ibwLvjubsPXNqe8AOhgt1J7mX+2nBltBZBmT8C94+8ZlMpJHupxEzSUWKzBC2oLK2I9zSR5i+VmQgUihtDTWJgfV58deZ2j1Wz7umAB45xphQ0nMBT4R15Ve/9zc31FrRmLVrcZgOOLC4XAgjVPjtP6RN2tU/Pa9dZLCdWHrtn1merW43k9eYPSGJ6+S0Jy+T0ZL8leip2ANaSgjUq1Nj2bIEWvxvFEngRj8LF2MM/EXahhD62UT4zcOI1PCPsE5qFPa75HfwIYhTr1fuhuRQ/imWG170pOkCZxENdHYJrvIvzLnb+7S05tCBzpkUwwM1Du8u1EsdQ/ew== Content-Type: text/plain; charset="utf-8" Content-ID: <9B836DBE76063A4687647CBF904FF646@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2050df03-e21e-4365-3e4c-08d83e14971e X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Aug 2020 16:35:42.8325 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: dFlSxWRDycbCJoqaMRR7P7jt9A2xiUsfZZt2i/+ZMJHxkzJpUxFT5vP2B3SocgsQgKJeIfJCNqJYETQSvjMoAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1311 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 727A2420D1 X-Rspamd-UID: 44294f QXBwbGllZA0KT24gVHVlLCAyMDIwLTA4LTExIGF0IDA5OjMxIC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBVc2UgZWxlbWVudCBhZGRyZXNzIGZvciBsb29raW5nIHVwIGVsZW1lbnQgaW5k ZXggKHN1YnNjcmlwdGlvbg0KPiBhZGRyZXNzIHdhcyBlcnJvbmVvdXNseSB1c2VkIHRvIHBlcmZv cm0gdGhlIGxvb2t1cCkuDQo+IC0tLQ0KPiAgbWVzaC9tb2RlbC5jIHwgMTUgKysrKysrKystLS0t LS0tDQo+ICBtZXNoL21vZGVsLmggfCAgMyArKy0NCj4gIDIgZmlsZXMgY2hhbmdlZCwgMTAgaW5z ZXJ0aW9ucygrKSwgOCBkZWxldGlvbnMoLSkNCj4gDQo+IGRpZmYgLS1naXQgYS9tZXNoL21vZGVs LmMgYi9tZXNoL21vZGVsLmMNCj4gaW5kZXggNjkwYmUyOWQ1Li4yM2FmYjkzYTggMTAwNjQ0DQo+ IC0tLSBhL21lc2gvbW9kZWwuYw0KPiArKysgYi9tZXNoL21vZGVsLmMNCj4gQEAgLTE0MDIsMTMg KzE0MDIsMTMgQEAgZG9uZToNCj4gIAlyZXR1cm4gTUVTSF9TVEFUVVNfU1VDQ0VTUzsNCj4gIH0N Cj4gIA0KPiAtaW50IG1lc2hfbW9kZWxfc3ViX2dldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1 aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCwNCj4gK2ludCBtZXNoX21vZGVsX3N1Yl9nZXQoc3Ry dWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgZWxlX2FkZHIsIHVpbnQzMl90IGlkLA0KPiAg CQkJdWludDhfdCAqYnVmLCB1aW50MTZfdCBidWZfc2l6ZSwgdWludDE2X3QgKnNpemUpDQo+ICB7 DQo+ICAJaW50MTZfdCBuOw0KPiAgCXN0cnVjdCBtZXNoX21vZGVsICptb2Q7DQo+ICAJY29uc3Qg c3RydWN0IGxfcXVldWVfZW50cnkgKmVudHJ5Ow0KPiAtCWludCBlbGVfaWR4ID0gbm9kZV9nZXRf ZWxlbWVudF9pZHgobm9kZSwgYWRkcik7DQo+ICsJaW50IGVsZV9pZHggPSBub2RlX2dldF9lbGVt ZW50X2lkeChub2RlLCBlbGVfYWRkcik7DQo+ICANCj4gIAlpZiAoZWxlX2lkeCA8IDApDQo+ICAJ CXJldHVybiBNRVNIX1NUQVRVU19JTlZBTElEX0FERFJFU1M7DQo+IEBAIC0xNDU0LDcgKzE0NTQs NyBAQCBpbnQgbWVzaF9tb2RlbF9zdWJfYWRkKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQx Nl90IGVsZV9hZGRyLCB1aW50MzJfdCBpZCwNCj4gIAkJCQkJCQkJdWludDE2X3QgYWRkcikNCj4g IHsNCj4gIAlzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kOw0KPiAtCWludCBzdGF0dXMsIGVsZV9pZHgg PSBub2RlX2dldF9lbGVtZW50X2lkeChub2RlLCBhZGRyKTsNCj4gKwlpbnQgc3RhdHVzLCBlbGVf aWR4ID0gbm9kZV9nZXRfZWxlbWVudF9pZHgobm9kZSwgZWxlX2FkZHIpOw0KPiAgDQo+ICAJaWYg KGVsZV9pZHggPCAwKQ0KPiAgCQlyZXR1cm4gTUVTSF9TVEFUVVNfSU5WQUxJRF9BRERSRVNTOw0K PiBAQCAtMTUxMCw3ICsxNTEwLDcgQEAgaW50IG1lc2hfbW9kZWxfc3ViX292cnQoc3RydWN0IG1l c2hfbm9kZSAqbm9kZSwgdWludDE2X3QgZWxlX2FkZHIsIHVpbnQzMl90IGlkLA0KPiAgCQkJCQkJ CQl1aW50MTZfdCBhZGRyKQ0KPiAgew0KPiAgCXN0cnVjdCBtZXNoX21vZGVsICptb2Q7DQo+IC0J aW50IGVsZV9pZHggPSBub2RlX2dldF9lbGVtZW50X2lkeChub2RlLCBhZGRyKTsNCj4gKwlpbnQg ZWxlX2lkeCA9IG5vZGVfZ2V0X2VsZW1lbnRfaWR4KG5vZGUsIGVsZV9hZGRyKTsNCj4gIA0KPiAg CWlmIChlbGVfaWR4IDwgMCkNCj4gIAkJcmV0dXJuIE1FU0hfU1RBVFVTX0lOVkFMSURfQUREUkVT UzsNCj4gQEAgLTE1NjcsNyArMTU2Nyw3IEBAIGludCBtZXNoX21vZGVsX3N1Yl9kZWwoc3RydWN0 IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgZWxlX2FkZHIsIHVpbnQzMl90IGlkLA0KPiAgCQkJ CQkJCQl1aW50MTZfdCBhZGRyKQ0KPiAgew0KPiAgCXN0cnVjdCBtZXNoX21vZGVsICptb2Q7DQo+ IC0JaW50IGVsZV9pZHggPSBub2RlX2dldF9lbGVtZW50X2lkeChub2RlLCBhZGRyKTsNCj4gKwlp bnQgZWxlX2lkeCA9IG5vZGVfZ2V0X2VsZW1lbnRfaWR4KG5vZGUsIGVsZV9hZGRyKTsNCj4gIA0K PiAgCWlmIChlbGVfaWR4IDwgMCkNCj4gIAkJcmV0dXJuIE1FU0hfU1RBVFVTX0lOVkFMSURfQURE UkVTUzsNCj4gQEAgLTE2MjksMTAgKzE2MjksMTEgQEAgaW50IG1lc2hfbW9kZWxfdmlydF9zdWJf ZGVsKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IGVsZV9hZGRyLA0KPiAgCXJldHVy biBNRVNIX1NUQVRVU19TVUNDRVNTOw0KPiAgfQ0KPiAgDQo+IC1pbnQgbWVzaF9tb2RlbF9zdWJf ZGVsX2FsbChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBp ZCkNCj4gK2ludCBtZXNoX21vZGVsX3N1Yl9kZWxfYWxsKHN0cnVjdCBtZXNoX25vZGUgKm5vZGUs IHVpbnQxNl90IGVsZV9hZGRyLA0KPiArCQkJCQkJCQl1aW50MzJfdCBpZCkNCj4gIHsNCj4gIAlz dHJ1Y3QgbWVzaF9tb2RlbCAqbW9kOw0KPiAtCWludCBlbGVfaWR4ID0gbm9kZV9nZXRfZWxlbWVu dF9pZHgobm9kZSwgYWRkcik7DQo+ICsJaW50IGVsZV9pZHggPSBub2RlX2dldF9lbGVtZW50X2lk eChub2RlLCBlbGVfYWRkcik7DQo+ICANCj4gIAlpZiAoZWxlX2lkeCA8IDApDQo+ICAJCXJldHVy biBNRVNIX1NUQVRVU19JTlZBTElEX0FERFJFU1M7DQo+IGRpZmYgLS1naXQgYS9tZXNoL21vZGVs LmggYi9tZXNoL21vZGVsLmgNCj4gaW5kZXggYTg4ZDI1ZDc3Li4xNDdhMDIyNzkgMTAwNjQ0DQo+ IC0tLSBhL21lc2gvbW9kZWwuaA0KPiArKysgYi9tZXNoL21vZGVsLmgNCj4gQEAgLTk4LDcgKzk4 LDggQEAgaW50IG1lc2hfbW9kZWxfc3ViX2RlbChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50 MTZfdCBlbGVfYWRkciwgdWludDMyX3QgaWQsDQo+ICBpbnQgbWVzaF9tb2RlbF92aXJ0X3N1Yl9k ZWwoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgZWxlX2FkZHIsDQo+ICAJCQkJCXVp bnQzMl90IGlkLCBjb25zdCB1aW50OF90ICpsYWJlbCwNCj4gIAkJCQkJdWludDE2X3QgKmFkZHIp Ow0KPiAtaW50IG1lc2hfbW9kZWxfc3ViX2RlbF9hbGwoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwg dWludDE2X3QgYWRkciwgdWludDMyX3QgaWQpOw0KPiAraW50IG1lc2hfbW9kZWxfc3ViX2RlbF9h bGwoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgZWxlX2FkZHIsDQo+ICsJCQkJCQkJ CXVpbnQzMl90IGlkKTsNCj4gIGludCBtZXNoX21vZGVsX3N1Yl9vdnJ0KHN0cnVjdCBtZXNoX25v ZGUgKm5vZGUsIHVpbnQxNl90IGVsZV9hZGRyLCB1aW50MzJfdCBpZCwNCj4gIAkJCQkJCQkJdWlu dDE2X3QgYWRkcik7DQo+ICBpbnQgbWVzaF9tb2RlbF92aXJ0X3N1Yl9vdnJ0KHN0cnVjdCBtZXNo X25vZGUgKm5vZGUsIHVpbnQxNl90IGVsZV9hZGRyLA0K Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mO1bGa/OMl+/jgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 19:00:31 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id WMQ5GK/OMl+5AgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 19:00:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 88FEBA12CF; Tue, 11 Aug 2020 19:00:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729314AbgHKQ7c (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 12:59:32 -0400 Received: from mail-il1-f198.google.com ([209.85.166.198]:40590 "EHLO mail-il1-f198.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729150AbgHKQ7T (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 12:59:19 -0400 Received: by mail-il1-f198.google.com with SMTP id z16so11030469ill.7 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 09:59:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=l3wlPqr6ipWe8Opm66dLPgisSNnhHiymwvjRBVgKADg=; b=YKpgaBRGCQyiDMClXUIoT3Ixtv4IXe8BoRVWix9otSxZ5nmnwwD9rlV2RrKaXG+0bd Sg8LAiJ6y/J6tyS72YU2pMoXTmQ+LoTsCU40Ft/v7vdaMspaTiVY7UHaxZz3wqjrtuEo ui+9xTkK972hx2Hu2xMJ/5Sq7Lpq2LjD4UjiHShPJOOLzTn5TsuEB+1pDaMmPHoMd4Zn tjFSSmP+ixC/42uknyVnjZwdyoydPs1VFX8uQ3c6fe8Q+P+xMeUuegwQ+ZvGcz98o7FE H1G9tRXKc98nUId5d2uiw4m39EQzLTl+nf+WKzytHUTJr5XCiV+LP4AvkAyp7ttEoO7g YVbQ== X-Gm-Message-State: AOAM532shjq0U15qMZlbp2RSs8rtPKmC3dPphPtu1528Zop3tG2DKe25 0tf5++fwksbsK1Vm68AYJwKjKUx9B6OESlY/ms05rWKBqEnX X-Google-Smtp-Source: ABdhPJxJQUhNpwViTKlqIYQHdVNHdSYbUVL2IQMxAttPZayrs+KLh/wyllEFuWMrDd47AXUX6rFXx/1jkrZkBqrw35YQnudVFt++ MIME-Version: 1.0 X-Received: by 2002:a02:c919:: with SMTP id t25mr27761316jao.38.1597165157907; Tue, 11 Aug 2020 09:59:17 -0700 (PDT) Date: Tue, 11 Aug 2020 09:59:17 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000e2852705ac9cfd73@google.com> Subject: KASAN: slab-out-of-bounds Read in lock_sock_nested From: syzbot <syzbot+9a0875bc1b2ca466b484@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 88FEBA12CF X-Rspamd-UID: 39ed83 Hello, syzbot found the following issue on: HEAD commit: bfdd5aaa Merge tag 'Smack-for-5.9' of git://github.com/csc.. git tree: net-next console output: https://syzkaller.appspot.com/x/log.txt?x=167b4d3a900000 kernel config: https://syzkaller.appspot.com/x/.config?x=7bb894f55faf8242 dashboard link: https://syzkaller.appspot.com/bug?extid=9a0875bc1b2ca466b484 compiler: gcc (GCC) 10.1.0-syz 20200507 Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+9a0875bc1b2ca466b484@syzkaller.appspotmail.com ================================================================== BUG: KASAN: slab-out-of-bounds in __lock_acquire+0x41d0/0x5640 kernel/locking/lockdep.c:4296 Read of size 8 at addr ffff8880497850a0 by task kworker/1:2/23918 CPU: 1 PID: 23918 Comm: kworker/1:2 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530 __lock_acquire+0x41d0/0x5640 kernel/locking/lockdep.c:4296 lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:5005 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:175 spin_lock_bh include/linux/spinlock.h:359 [inline] lock_sock_nested+0x3b/0x110 net/core/sock.c:3040 l2cap_sock_teardown_cb+0x88/0x400 net/bluetooth/l2cap_sock.c:1520 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:823 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Allocated by task 3899: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494 __do_kmalloc mm/slab.c:3656 [inline] __kmalloc+0x17a/0x340 mm/slab.c:3665 kmalloc include/linux/slab.h:560 [inline] tomoyo_realpath_from_path+0xc3/0x620 security/tomoyo/realpath.c:254 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x272/0x380 security/tomoyo/file.c:771 tomoyo_file_open security/tomoyo/tomoyo.c:313 [inline] tomoyo_file_open+0xa3/0xd0 security/tomoyo/tomoyo.c:308 security_file_open+0x52/0x3f0 security/security.c:1574 do_dentry_open+0x3a0/0x1290 fs/open.c:815 do_open fs/namei.c:3243 [inline] path_openat+0x1bb9/0x2750 fs/namei.c:3360 do_filp_open+0x17e/0x3c0 fs/namei.c:3387 do_sys_openat2+0x16f/0x3b0 fs/open.c:1179 do_sys_open fs/open.c:1195 [inline] ksys_open include/linux/syscalls.h:1390 [inline] __do_sys_open fs/open.c:1201 [inline] __se_sys_open fs/open.c:1199 [inline] __x64_sys_open+0x119/0x1c0 fs/open.c:1199 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 3899: save_stack+0x1b/0x40 mm/kasan/common.c:48 set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x103/0x2c0 mm/slab.c:3757 tomoyo_realpath_from_path+0x191/0x620 security/tomoyo/realpath.c:291 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x272/0x380 security/tomoyo/file.c:771 tomoyo_file_open security/tomoyo/tomoyo.c:313 [inline] tomoyo_file_open+0xa3/0xd0 security/tomoyo/tomoyo.c:308 security_file_open+0x52/0x3f0 security/security.c:1574 do_dentry_open+0x3a0/0x1290 fs/open.c:815 do_open fs/namei.c:3243 [inline] path_openat+0x1bb9/0x2750 fs/namei.c:3360 do_filp_open+0x17e/0x3c0 fs/namei.c:3387 do_sys_openat2+0x16f/0x3b0 fs/open.c:1179 do_sys_open fs/open.c:1195 [inline] ksys_open include/linux/syscalls.h:1390 [inline] __do_sys_open fs/open.c:1201 [inline] __se_sys_open fs/open.c:1199 [inline] __x64_sys_open+0x119/0x1c0 fs/open.c:1199 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff888049784000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 160 bytes to the right of 4096-byte region [ffff888049784000, ffff888049785000) The buggy address belongs to the page: page:ffffea000125e100 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea000125e100 order:1 compound_mapcount:0 flags: 0xfffe0000010200(slab|head) raw: 00fffe0000010200 ffffea0001c34088 ffffea000122f088 ffff8880aa002000 raw: 0000000000000000 ffff888049784000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888049784f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888049785000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888049785080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff888049785100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888049785180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ================================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QEduMlzQMl+/jgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 19:07:40 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id KOobMVzQMl8tFwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 19:07:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3F6D1420CC; Tue, 11 Aug 2020 19:07:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729350AbgHKRH0 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 13:07:26 -0400 Received: from mail-io1-f69.google.com ([209.85.166.69]:54374 "EHLO mail-io1-f69.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729104AbgHKRHP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 13:07:15 -0400 Received: by mail-io1-f69.google.com with SMTP id z25so10191877ioh.21 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 10:07:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=3ZPRrfgd4U28dH7RCjAGl0xrthCHCi5aVcTRVhPqTvM=; b=iLf+YFDegaDR/4WEaHMfV5OAn5AXU3BbxZyPMzg4dKtviHOOBjsNMknRrf2xNP4fLF 0eAfUgZYuDwvmWe4kRnyj/1DnomVjjziwbA9fvYX4Bwly2pE1V7CNSZan3aAavvNqhWd C8hq4hcpI0fKD5Ra5Y+eKBRAQMT7uziVrqD26NUpBDCUG7Pwf+NllqcVZFc77T5TFRuC OKfCMcKb47A7ZC/U8NQR+3hpW/ZwqaIHWnN7qP4pgKwFJlbfbda1epX2AUSAvCBbPWYe TKfjY3MYkmFltACA5J5vS1evqbHRulWUd6qoZQE9Ui92Mnp4ukY6fz0KFdAMc+iVKmlZ 455w== X-Gm-Message-State: AOAM530l4fUglKNEjE8qVZ/Dq2mcKjZ/pYlALsoeZKtPxNoO43fJIxo/ zvmSgdxR9x/1V2mIXDr37KhpEDkOLq0GMFyXjbfwuvTaGUdv X-Google-Smtp-Source: ABdhPJxK0j2N8H15/HLiv2i5ZMHye9rsVOvMWhuPkrGjHecyzW74B0tXTaV6lYOkeo5F0GQWDSisUUJz/C8OpJqjHcxr0bZjG/ZI MIME-Version: 1.0 X-Received: by 2002:a92:d8d2:: with SMTP id l18mr21745562ilo.94.1597165634421; Tue, 11 Aug 2020 10:07:14 -0700 (PDT) Date: Tue, 11 Aug 2020 10:07:14 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000004991e705ac9d1a83@google.com> Subject: inconsistent lock state in sco_conn_del From: syzbot <syzbot+65684128cd7c35bc66a1@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3F6D1420CC X-Rspamd-UID: c3d58d Hello, syzbot found the following issue on: HEAD commit: f80535b9 Add linux-next specific files for 20200810 git tree: linux-next console output: https://syzkaller.appspot.com/x/log.txt?x=152ffd8a900000 kernel config: https://syzkaller.appspot.com/x/.config?x=2055bd0d83d5ee16 dashboard link: https://syzkaller.appspot.com/bug?extid=65684128cd7c35bc66a1 compiler: gcc (GCC) 10.1.0-syz 20200507 Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+65684128cd7c35bc66a1@syzkaller.appspotmail.com ================================ WARNING: inconsistent lock state 5.8.0-next-20200810-syzkaller #0 Not tainted -------------------------------- inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage. syz-executor.5/11793 [HC0[0]:SC0[0]:HE1:SE1] takes: ffff8880554ec0a0 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.?.}-{2:2}, at: spin_lock include/linux/spinlock.h:354 [inline] ffff8880554ec0a0 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.?.}-{2:2}, at: sco_conn_del+0x128/0x270 net/bluetooth/sco.c:176 {IN-SOFTIRQ-W} state was registered at: lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:5005 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:354 [inline] sco_sock_timeout+0x24/0x140 net/bluetooth/sco.c:83 call_timer_fn+0x1ac/0x760 kernel/time/timer.c:1413 expire_timers kernel/time/timer.c:1458 [inline] __run_timers.part.0+0x67c/0xaa0 kernel/time/timer.c:1755 __run_timers kernel/time/timer.c:1736 [inline] run_timer_softirq+0xae/0x1a0 kernel/time/timer.c:1768 __do_softirq+0x2de/0xa24 kernel/softirq.c:298 asm_call_on_stack+0xf/0x20 arch/x86/entry/entry_64.S:706 __run_on_irqstack arch/x86/include/asm/irq_stack.h:22 [inline] run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:48 [inline] do_softirq_own_stack+0x9d/0xd0 arch/x86/kernel/irq_64.c:77 invoke_softirq kernel/softirq.c:393 [inline] __irq_exit_rcu kernel/softirq.c:423 [inline] irq_exit_rcu+0x1f3/0x230 kernel/softirq.c:435 sysvec_apic_timer_interrupt+0x51/0xf0 arch/x86/kernel/apic/apic.c:1090 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:581 arch_local_irq_enable arch/x86/include/asm/paravirt.h:780 [inline] __local_bh_enable_ip+0x101/0x190 kernel/softirq.c:200 spin_unlock_bh include/linux/spinlock.h:399 [inline] batadv_nc_purge_paths+0x2a5/0x3a0 net/batman-adv/network-coding.c:470 batadv_nc_worker+0x868/0xe50 net/batman-adv/network-coding.c:721 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 irq event stamp: 33895 hardirqs last enabled at (33895): [<ffffffff81b4172d>] kfree+0x1cd/0x2c0 mm/slab.c:3757 hardirqs last disabled at (33894): [<ffffffff81b415cf>] kfree+0x6f/0x2c0 mm/slab.c:3746 softirqs last enabled at (30344): [<ffffffff88000f2f>] asm_call_on_stack+0xf/0x20 arch/x86/entry/entry_64.S:706 softirqs last disabled at (30333): [<ffffffff88000f2f>] asm_call_on_stack+0xf/0x20 arch/x86/entry/entry_64.S:706 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(slock-AF_BLUETOOTH-BTPROTO_SCO); <Interrupt> lock(slock-AF_BLUETOOTH-BTPROTO_SCO); *** DEADLOCK *** 3 locks held by syz-executor.5/11793: #0: ffff88805b990f40 (&hdev->req_lock){+.+.}-{3:3}, at: hci_dev_do_close+0xf5/0x1080 net/bluetooth/hci_core.c:1720 #1: ffff88805b990078 (&hdev->lock){+.+.}-{3:3}, at: hci_dev_do_close+0x253/0x1080 net/bluetooth/hci_core.c:1757 #2: ffffffff8a9a5c28 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_disconn_cfm include/net/bluetooth/hci_core.h:1435 [inline] #2: ffffffff8a9a5c28 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_conn_hash_flush+0xc7/0x220 net/bluetooth/hci_conn.c:1557 stack backtrace: CPU: 0 PID: 11793 Comm: syz-executor.5 Not tainted 5.8.0-next-20200810-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 print_usage_bug kernel/locking/lockdep.c:4020 [inline] valid_state kernel/locking/lockdep.c:3361 [inline] mark_lock_irq kernel/locking/lockdep.c:3560 [inline] mark_lock.cold+0x7a/0x7f kernel/locking/lockdep.c:4006 mark_usage kernel/locking/lockdep.c:3923 [inline] __lock_acquire+0x8cd/0x5640 kernel/locking/lockdep.c:4380 lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:5005 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:354 [inline] sco_conn_del+0x128/0x270 net/bluetooth/sco.c:176 sco_disconn_cfm net/bluetooth/sco.c:1178 [inline] sco_disconn_cfm+0x62/0x80 net/bluetooth/sco.c:1171 hci_disconn_cfm include/net/bluetooth/hci_core.h:1438 [inline] hci_conn_hash_flush+0x114/0x220 net/bluetooth/hci_conn.c:1557 hci_dev_do_close+0x5c6/0x1080 net/bluetooth/hci_core.c:1770 hci_unregister_dev+0x1bd/0xe30 net/bluetooth/hci_core.c:3790 vhci_release+0x70/0xe0 drivers/bluetooth/hci_vhci.c:340 __fput+0x285/0x920 fs/file_table.c:281 task_work_run+0xdd/0x190 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0xb7d/0x29f0 kernel/exit.c:806 do_group_exit+0x125/0x310 kernel/exit.c:903 get_signal+0x40b/0x1ee0 kernel/signal.c:2743 arch_do_signal+0x82/0x2520 arch/x86/kernel/signal.c:811 exit_to_user_mode_loop kernel/entry/common.c:135 [inline] exit_to_user_mode_prepare+0x15d/0x1c0 kernel/entry/common.c:166 syscall_exit_to_user_mode+0x59/0x2b0 kernel/entry/common.c:241 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x45ce69 Code: Bad RIP value. RSP: 002b:00007fd132defcf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca RAX: fffffffffffffe00 RBX: 000000000118bfc8 RCX: 000000000045ce69 RDX: 0000000000000000 RSI: 0000000000000080 RDI: 000000000118bfc8 RBP: 000000000118bfc0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 000000000118bfcc R13: 00007ffd9693ba5f R14: 00007fd132df09c0 R15: 000000000118bfcc --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EBXlBAfTMl+tAgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 19:19:03 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id yE97AwfTMl9kGQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 19:19:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1F467420D5; Tue, 11 Aug 2020 19:18:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729167AbgHKRS5 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 13:18:57 -0400 Received: from mga12.intel.com ([192.55.52.136]:29208 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728990AbgHKRS4 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 13:18:56 -0400 IronPort-SDR: FTTwAgxCnOHpAmwMo30QWOxkJETx7NmEx0hUjvdGx0FJjBFntMZEY6LBUU0g9lvMJ+QfKcHTKF N5/iPvoGq7bQ== X-IronPort-AV: E=McAfee;i="6000,8403,9710"; a="133316706" X-IronPort-AV: E=Sophos;i="5.76,301,1592895600"; d="scan'208";a="133316706" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2020 10:18:56 -0700 IronPort-SDR: fWSOwbyptCKZ1TxnwTe4+YxCJ6GcdyzbB5VEqmPjOv3P/vgKyTqShCyxa8rOE6YACOcAlHvuQt e3JK3tZShC1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,301,1592895600"; d="scan'208";a="369010868" Received: from rajkumar-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.82.230]) by orsmga001.jf.intel.com with ESMTP; 11 Aug 2020 10:18:55 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] mesh: Fix logic error when saving model subscriptions Date: Tue, 11 Aug 2020 10:18:55 -0700 Message-Id: <20200811171855.13189-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1F467420D5 X-Rspamd-UID: 1d5507 This fixes opcode check condition when saving configuration for model subscriptions: use || instead of && for opcode checking --- mesh/cfgmod-server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index d31c8d99f..9da981700 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -211,7 +211,7 @@ static bool save_cfg_sub(struct mesh_node *node, uint16_t ele_addr, if (virt) memcpy(db_sub.addr.label, label, 16); - if (opcode == OP_CONFIG_MODEL_SUB_VIRT_DELETE && + if (opcode == OP_CONFIG_MODEL_SUB_VIRT_DELETE || opcode == OP_CONFIG_MODEL_SUB_DELETE) return mesh_config_model_sub_del(cfg, ele_addr, id, vendor, &db_sub); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2EuXAyffMl+6QwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 20:10:47 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MLPGACffMl8qlQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 20:10:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9359A41757; Tue, 11 Aug 2020 20:10:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726114AbgHKSKl (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 14:10:41 -0400 Received: from mga09.intel.com ([134.134.136.24]:2383 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgHKSKk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 14:10:40 -0400 IronPort-SDR: JMd2aaucZdUOAYnUHTHkGwaa2o4HIAxMfYkJq7GHLuIa78NIxW3JotnbTsV6t7pw7I7aiK6yUb 4tL2E/iGZmeA== X-IronPort-AV: E=McAfee;i="6000,8403,9710"; a="154925136" X-IronPort-AV: E=Sophos;i="5.76,301,1592895600"; d="scan'208";a="154925136" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2020 11:10:40 -0700 IronPort-SDR: AFzGw2COHN6ut8Zc0d1Qns59e79PGgvd/MIE4MBg6qgcHP5EX5uABiUi703XJrhI8IMW2sc5yl 1bwedVuNtzdg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,301,1592895600"; d="scan'208";a="469527357" Received: from unknown (HELO fmsmsx605.amr.corp.intel.com) ([10.18.84.215]) by orsmga005.jf.intel.com with ESMTP; 11 Aug 2020 11:10:40 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 11 Aug 2020 11:10:39 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 11 Aug 2020 11:10:39 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 11 Aug 2020 11:10:39 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.43) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 11 Aug 2020 11:10:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ei6FWVkrnk5/JwtWssWLW2Wz0KQ3pSX9ARQ3nyfhJk/vVUl7Sdpa6WDZG1DMNpmSgIcSKy9Up7nKrE0dFVc/UbLGle+H48dxLhJl8HzCtbWo1DGURGnDHyzLxUz0P2y8UoOkMJfN9n+VSKHtRGi5ANMUbbh/jHwXw0jCA4KW3LtqCR2xqYrPcUizx7H/ERd0nSnszEuBtQ4f4Nt1SfhPBau1ZHxNwapZSioMo9ezkK8OlZU6xoAcVnK/aiO1nJbt0Ql9VdhU3WqcXqfDKyN7LJyd8enKC4tCCj8cB8Phc4O+V2sAC5JhJe3OCxre0psaDRMa4JjUMFNx0Z5adnriww== 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-SenderADCheck; bh=yWOSM60GNsMCwKaxQaarQ7DwYvK6CQlmk/JuvtjjgVs=; b=nurV0UG87h6AGKl8XC+PMfXKi9VVkplnjH9O2DZ8Y2Uz3nmPUbmMXMHCb39KmF6rsO3e4SgZe6wqhjSpn1ZjQVlT29gznGygFqIh8ZXOxAoKXKfdTs8sCG2v4K5xw3rJOixTzXSaSvyO5HxCaRYhNEiQJuDChLefjcv9dK1aafZIkFCvN/GNvTxcl5AIdVc9EYlHM3jw4GVAzYevH7dU12aNeGN/ilabx4tOFQ59gd9yikPjB8AJnD3PPLaUe9P0s8TCLesVK5qEgVyOnYArEqFRlZAHgCJERewVR7hrPbu6w0RVt0To16MNckGgFTk/kMwiChNSwDRqf5kv3u23GQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yWOSM60GNsMCwKaxQaarQ7DwYvK6CQlmk/JuvtjjgVs=; b=gMJ3jp+Qfja2TrjWqsi8MCYH1jKOaZTiXuGlK/psTQHoNq7hwVWo6osRNHTvgd44cjdVlOtuVyNr8Ch8tR0IaStctoQYyGQ2DNejMX6aUDKrFHKlnhr/2FRZuDHyBW/jzMs86Feaio1tfMeqDXw9DlOFjMPr9Fpu+GNiXufBP5Q= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4602.namprd11.prod.outlook.com (2603:10b6:303:52::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.15; Tue, 11 Aug 2020 18:10:35 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3261.025; Tue, 11 Aug 2020 18:10:35 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: Fix logic error when saving model subscriptions Thread-Topic: [PATCH BlueZ] mesh: Fix logic error when saving model subscriptions Thread-Index: AQHWcAOBLdRAgysY7UmYq3dZkeGf4KkzNWIA Date: Tue, 11 Aug 2020 18:10:35 +0000 Message-ID: <5e58663071e4179cd71bd96c4dd81a6f9d8d73b4.camel@intel.com> References: <20200811171855.13189-1-inga.stotland@intel.com> In-Reply-To: <20200811171855.13189-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.54.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cc5a6e7d-dcce-408c-140d-08d83e21d815 x-ms-traffictypediagnostic: MW3PR11MB4602: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MW3PR11MB4602294ED8E0C9E4724C73F4E1450@MW3PR11MB4602.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:3631; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dMFcLRhP3F7Qt7y7f2nCyIpCZAOoSmBoSLAsGESDMoVBmTwJRtGSqiVGSEFzjE/uK3BpyrZ5qyq79wLWBUZJgB1YIi180IEOGoEw9FkGGLCjR3fKnHmCbUK38w0nYQJT/CCy5qjVO+SQgCnIf8YKve3JAiIloj/zOXTjXwDpqunN0x6Gd3z/d0HQPuGreSW0Wu5vaZ/VOBxBKPFV+5156uQk93kqsAcNtJ7FbRcS3rGoiPNleFgfV08M9nIDWLsjuBhiJx0ThKZzwAf4I7V131QcbvWcT5pZfPSzXqt1+2YA7lN3L45pb0E1eLjrLBXWKrZ9Yj25XVPiQupCEApizw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(366004)(39860400002)(346002)(136003)(376002)(396003)(4744005)(6512007)(71200400001)(6486002)(86362001)(6636002)(8676002)(8936002)(2906002)(316002)(36756003)(478600001)(83380400001)(66556008)(6506007)(66446008)(110136005)(186003)(26005)(66476007)(64756008)(76116006)(2616005)(66946007)(91956017)(5660300002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: KxgXP3TajfpR9E8YACZTuSh3Lff6UPmbqE3wwxEjEXovr4U0yti5hcQ1dJDbwJ7YWkOh/xNFw2Ale7ta5gFK+qspnGqLve6AhcxcIjywc7h3rvI9FXKMzXlWRSETn2GeXZJie4TbhbDWAAqZ6bxoIcvpjMMmGG8eIZ0W4F/zOwrfzaNdwdhCX3U28cGkTwGFFDGM17C51r9Xtj0z7jhEgMtCGwsBozDj3xUz20RvpiLyehBx/rh3JQMN+5KI0fF3Vuo1YPCx4VUgroRqzmqf5CLbovEoTtu134QSftUtWGoyr2I3MkFRaqhppAHBKgNlyOzfDtwXjjRE2jlmcOREBPz7vG+MdmwSAzc+KciTF5o64c2wTx7HES2QcTAIkwzdjR4qiZs1U1ru2XvLhJF8Q77FGLiWRGyJs3lCJWrPfjbLyVL1s0sTkrmhMyaWSsGv7BCoNhJwXhYhSVIasPKMtNFkAj/qmIlWBMbQ+Qy7SL9H0QfOd62/nHwojWysrpfr2mlhzMa16e4HfLHJnkcFfxL2xxgmuNGoLjnefQXwu+WADqDOn/b6jDHYGyKuQwRp8OW1B0arLZBv02aWLA+IKNSseA//RS0YT1JM/mRc4UQiKqIUhD6jMyRPz0aO+vm4M1P6a1YzvtR1+UtEnoYoKg== Content-Type: text/plain; charset="utf-8" Content-ID: <FA8BA326F8810146A9D21897D10FF03E@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc5a6e7d-dcce-408c-140d-08d83e21d815 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Aug 2020 18:10:35.2062 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: YeiOsf/dkyTlUNxvTDiWqQicmkEoxxcNzJyWxjtWbkH4DGGNfgDWQKIyWDqATm9jjC7zU6xTYjuSUN04st3k2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4602 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9359A41757 X-Rspamd-UID: d14010 QXBwbGllZA0KT24gVHVlLCAyMDIwLTA4LTExIGF0IDEwOjE4IC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBUaGlzIGZpeGVzIG9wY29kZSBjaGVjayBjb25kaXRpb24gd2hlbiBzYXZpbmcg Y29uZmlndXJhdGlvbiBmb3IgbW9kZWwNCj4gc3Vic2NyaXB0aW9uczogdXNlIHx8IGluc3RlYWQg b2YgJiYgZm9yIG9wY29kZSBjaGVja2luZw0KPiAtLS0NCj4gIG1lc2gvY2ZnbW9kLXNlcnZlci5j IHwgMiArLQ0KPiAgMSBmaWxlIGNoYW5nZWQsIDEgaW5zZXJ0aW9uKCspLCAxIGRlbGV0aW9uKC0p DQo+IA0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9jZmdtb2Qtc2VydmVyLmMgYi9tZXNoL2NmZ21vZC1z ZXJ2ZXIuYw0KPiBpbmRleCBkMzFjOGQ5OWYuLjlkYTk4MTcwMCAxMDA2NDQNCj4gLS0tIGEvbWVz aC9jZmdtb2Qtc2VydmVyLmMNCj4gKysrIGIvbWVzaC9jZmdtb2Qtc2VydmVyLmMNCj4gQEAgLTIx MSw3ICsyMTEsNyBAQCBzdGF0aWMgYm9vbCBzYXZlX2NmZ19zdWIoc3RydWN0IG1lc2hfbm9kZSAq bm9kZSwgdWludDE2X3QgZWxlX2FkZHIsDQo+ICAJaWYgKHZpcnQpDQo+ICAJCW1lbWNweShkYl9z dWIuYWRkci5sYWJlbCwgbGFiZWwsIDE2KTsNCj4gIA0KPiAtCWlmIChvcGNvZGUgPT0gT1BfQ09O RklHX01PREVMX1NVQl9WSVJUX0RFTEVURSAmJg0KPiArCWlmIChvcGNvZGUgPT0gT1BfQ09ORklH X01PREVMX1NVQl9WSVJUX0RFTEVURSB8fA0KPiAgCQkJb3Bjb2RlID09IE9QX0NPTkZJR19NT0RF TF9TVUJfREVMRVRFKQ0KPiAgCQlyZXR1cm4gbWVzaF9jb25maWdfbW9kZWxfc3ViX2RlbChjZmcs IGVsZV9hZGRyLCBpZCwgdmVuZG9yLA0KPiAgCQkJCQkJCQkmZGJfc3ViKTsNCg== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wBoYK4HgMl8GUAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 20:16:33 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id IA9NKYHgMl+dGgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 20:16:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 56DADA0A11; Tue, 11 Aug 2020 20:16:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726165AbgHKSQ0 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 14:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgHKSQ0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 14:16:26 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE5A0C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:16:25 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id o1so7215218plk.1 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=AErl5Ugw7OMWv6KhOS8L/zGN7BNkongguRT2IWZuj04=; b=lh0rUF2nk897OhG50BJ5e4HTN9HUCmTaA9yrWCgqm8lQI9j9vSuYd9iQdWFIpiGXNt FDyObqlu6oeoqI/BHpoCvC+PaFDNQbn3UULND7E3MT4sOIK6ZKAn4OyuFa4p0NOlmeG5 VR9KhKZ+FxFIGaI6GkTn/tVJ8880fwZyjyIrAs6714ajMQN3CFdkxxbMsp7ELa/uVFkW RaIG0gqi8N4m+CIWJ4+ZR12bz9kBphWNDs5bZLsrCAjVZKlzBCo54pHb+xHlOaz/qOsC l3f4AExCkoWA9O+XiKAq/OxWsgBB9Vnmfwah2srewD0I1DJoYcUcm3t9Xi48v8tvZTSM QmNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=AErl5Ugw7OMWv6KhOS8L/zGN7BNkongguRT2IWZuj04=; b=c9d1JYNZmqlc+nMMWVkxtp0A4CkrVHL0aON17enjyglCnlLo2TGElFDm9hIXwcGCWW 2Lh+6Kgw9dspsbtOl8JdF4S0OT1PsggN4WPP4HUUpZN6SaBxnDmY5h7ES/eNFy/TjwJG lRPsx/cQXSARV7alDidCdZBf1eXBP1YAyWaaLlLGZk14LTEW7DZdLac9QhWuMIfDVhDV SV8Y/CkPNJBY4cF9qKJbXmfofqUkQlLk/f5awNoHU7r0fq9ZBXhxjG7J8gJg/qibFKUu KY5Mo2ebNOwwKp4rGXvqewlnPvHfDKagNpQDCJV+wVZdcHmdKTzKz25qvA3Ol9WTLH33 sQ4A== X-Gm-Message-State: AOAM531CLH4B1ls1WyZFZFiCo1s0+lrMVEm/ke+7OHQ1WbqJyP1qDLVZ Yqe7/+VcH0QrDL2mORMFbtCv3qMB X-Google-Smtp-Source: ABdhPJwR/imoicwYWXXAMCVwjLxAumOFbkTuPwhUVi+x8l5QI61vp1PYIPCyrQng66q7Ol10ixGv9A== X-Received: by 2002:a17:90a:3ac3:: with SMTP id b61mr2231912pjc.1.1597169784516; Tue, 11 Aug 2020 11:16:24 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id b22sm27011519pfb.213.2020.08.11.11.16.23 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 11:16:23 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH SBC 1/3] sbc: Add initial code for SSE primitives Date: Tue, 11 Aug 2020 11:16:21 -0700 Message-Id: <20200811181623.3683374-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: 56DADA0A11 X-Rspamd-UID: 9257a6 From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> --- Makefile.am | 1 + sbc/sbc_primitives.c | 20 ++- sbc/sbc_primitives_sse.c | 361 +++++++++++++++++++++++++++++++++++++++ sbc/sbc_primitives_sse.h | 38 +++++ 4 files changed, 417 insertions(+), 3 deletions(-) create mode 100644 sbc/sbc_primitives_sse.c create mode 100644 sbc/sbc_primitives_sse.h diff --git a/Makefile.am b/Makefile.am index 342043d..7ff0c7d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,6 +14,7 @@ sbc_headers = sbc/sbc.h sbc_sources = sbc/sbc.c sbc/sbc_private.h sbc/sbc_math.h sbc/sbc_tables.h \ sbc/sbc_primitives.h sbc/sbc_primitives.c \ + sbc/sbc_primitives_sse.h sbc/sbc_primitives_sse.c \ sbc/sbc_primitives_mmx.h sbc/sbc_primitives_mmx.c \ sbc/sbc_primitives_iwmmxt.h sbc/sbc_primitives_iwmmxt.c \ sbc/sbc_primitives_neon.h sbc/sbc_primitives_neon.c \ diff --git a/sbc/sbc_primitives.c b/sbc/sbc_primitives.c index ff343cf..97a75be 100644 --- a/sbc/sbc_primitives.c +++ b/sbc/sbc_primitives.c @@ -33,6 +33,7 @@ #include "sbc_tables.h" #include "sbc_primitives.h" +#include "sbc_primitives_sse.h" #include "sbc_primitives_mmx.h" #include "sbc_primitives_iwmmxt.h" #include "sbc_primitives_neon.h" @@ -590,6 +591,21 @@ static int sbc_calc_scalefactors_j( return joint; } +static void sbc_init_primitives_x86(struct sbc_encoder_state *state) +{ + __builtin_cpu_init(); + +#ifdef SBC_BUILD_WITH_MMX_SUPPORT + if (__builtin_cpu_supports("mmx")) + sbc_init_primitives_mmx(state); +#endif + +#ifdef SBC_BUILD_WITH_SSE_SUPPORT + if (__builtin_cpu_supports("sse4.2")) + sbc_init_primitives_sse(state); +#endif +} + /* * Detect CPU features and setup function pointers */ @@ -614,9 +630,7 @@ void sbc_init_primitives(struct sbc_encoder_state *state) state->implementation_info = "Generic C"; /* X86/AMD64 optimizations */ -#ifdef SBC_BUILD_WITH_MMX_SUPPORT - sbc_init_primitives_mmx(state); -#endif + sbc_init_primitives_x86(state); /* ARM optimizations */ #ifdef SBC_BUILD_WITH_ARMV6_SUPPORT diff --git a/sbc/sbc_primitives_sse.c b/sbc/sbc_primitives_sse.c new file mode 100644 index 0000000..c2b729a --- /dev/null +++ b/sbc/sbc_primitives_sse.c @@ -0,0 +1,361 @@ +/* + * + * Bluetooth low-complexity, subband codec (SBC) library + * + * Copyright (C) 2020 Intel Corporation + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <stdint.h> +#include <limits.h> +#include "sbc.h" +#include "sbc_math.h" +#include "sbc_tables.h" + +#include "sbc_primitives_sse.h" + +/* + * SSE optimizations + */ + +#ifdef SBC_BUILD_WITH_SSE_SUPPORT + +static inline void sbc_analyze_four_sse(const int16_t *in, int32_t *out, + const FIXED_T *consts) +{ + static const SBC_ALIGNED int32_t round_c[2] = { + 1 << (SBC_PROTO_FIXED4_SCALE - 1), + 1 << (SBC_PROTO_FIXED4_SCALE - 1), + }; + __asm__ volatile ( + "movq (%0), %%mm0\n" + "movq 8(%0), %%mm1\n" + "pmaddwd (%1), %%mm0\n" + "pmaddwd 8(%1), %%mm1\n" + "paddd (%2), %%mm0\n" + "paddd (%2), %%mm1\n" + "\n" + "movq 16(%0), %%mm2\n" + "movq 24(%0), %%mm3\n" + "pmaddwd 16(%1), %%mm2\n" + "pmaddwd 24(%1), %%mm3\n" + "paddd %%mm2, %%mm0\n" + "paddd %%mm3, %%mm1\n" + "\n" + "movq 32(%0), %%mm2\n" + "movq 40(%0), %%mm3\n" + "pmaddwd 32(%1), %%mm2\n" + "pmaddwd 40(%1), %%mm3\n" + "paddd %%mm2, %%mm0\n" + "paddd %%mm3, %%mm1\n" + "\n" + "movq 48(%0), %%mm2\n" + "movq 56(%0), %%mm3\n" + "pmaddwd 48(%1), %%mm2\n" + "pmaddwd 56(%1), %%mm3\n" + "paddd %%mm2, %%mm0\n" + "paddd %%mm3, %%mm1\n" + "\n" + "movq 64(%0), %%mm2\n" + "movq 72(%0), %%mm3\n" + "pmaddwd 64(%1), %%mm2\n" + "pmaddwd 72(%1), %%mm3\n" + "paddd %%mm2, %%mm0\n" + "paddd %%mm3, %%mm1\n" + "\n" + "psrad %4, %%mm0\n" + "psrad %4, %%mm1\n" + "packssdw %%mm0, %%mm0\n" + "packssdw %%mm1, %%mm1\n" + "\n" + "movq %%mm0, %%mm2\n" + "pmaddwd 80(%1), %%mm0\n" + "pmaddwd 88(%1), %%mm2\n" + "\n" + "movq %%mm1, %%mm3\n" + "pmaddwd 96(%1), %%mm1\n" + "pmaddwd 104(%1), %%mm3\n" + "paddd %%mm1, %%mm0\n" + "paddd %%mm3, %%mm2\n" + "\n" + "movq %%mm0, (%3)\n" + "movq %%mm2, 8(%3)\n" + : + : "r" (in), "r" (consts), "r" (&round_c), "r" (out), + "i" (SBC_PROTO_FIXED4_SCALE) + : "cc", "memory"); +} + +static inline void sbc_analyze_eight_sse(const int16_t *in, int32_t *out, + const FIXED_T *consts) +{ + static const SBC_ALIGNED int32_t round_c[2] = { + 1 << (SBC_PROTO_FIXED8_SCALE - 1), + 1 << (SBC_PROTO_FIXED8_SCALE - 1), + }; + __asm__ volatile ( + "movq (%0), %%mm0\n" + "movq 8(%0), %%mm1\n" + "movq 16(%0), %%mm2\n" + "movq 24(%0), %%mm3\n" + "pmaddwd (%1), %%mm0\n" + "pmaddwd 8(%1), %%mm1\n" + "pmaddwd 16(%1), %%mm2\n" + "pmaddwd 24(%1), %%mm3\n" + "paddd (%2), %%mm0\n" + "paddd (%2), %%mm1\n" + "paddd (%2), %%mm2\n" + "paddd (%2), %%mm3\n" + "\n" + "movq 32(%0), %%mm4\n" + "movq 40(%0), %%mm5\n" + "movq 48(%0), %%mm6\n" + "movq 56(%0), %%mm7\n" + "pmaddwd 32(%1), %%mm4\n" + "pmaddwd 40(%1), %%mm5\n" + "pmaddwd 48(%1), %%mm6\n" + "pmaddwd 56(%1), %%mm7\n" + "paddd %%mm4, %%mm0\n" + "paddd %%mm5, %%mm1\n" + "paddd %%mm6, %%mm2\n" + "paddd %%mm7, %%mm3\n" + "\n" + "movq 64(%0), %%mm4\n" + "movq 72(%0), %%mm5\n" + "movq 80(%0), %%mm6\n" + "movq 88(%0), %%mm7\n" + "pmaddwd 64(%1), %%mm4\n" + "pmaddwd 72(%1), %%mm5\n" + "pmaddwd 80(%1), %%mm6\n" + "pmaddwd 88(%1), %%mm7\n" + "paddd %%mm4, %%mm0\n" + "paddd %%mm5, %%mm1\n" + "paddd %%mm6, %%mm2\n" + "paddd %%mm7, %%mm3\n" + "\n" + "movq 96(%0), %%mm4\n" + "movq 104(%0), %%mm5\n" + "movq 112(%0), %%mm6\n" + "movq 120(%0), %%mm7\n" + "pmaddwd 96(%1), %%mm4\n" + "pmaddwd 104(%1), %%mm5\n" + "pmaddwd 112(%1), %%mm6\n" + "pmaddwd 120(%1), %%mm7\n" + "paddd %%mm4, %%mm0\n" + "paddd %%mm5, %%mm1\n" + "paddd %%mm6, %%mm2\n" + "paddd %%mm7, %%mm3\n" + "\n" + "movq 128(%0), %%mm4\n" + "movq 136(%0), %%mm5\n" + "movq 144(%0), %%mm6\n" + "movq 152(%0), %%mm7\n" + "pmaddwd 128(%1), %%mm4\n" + "pmaddwd 136(%1), %%mm5\n" + "pmaddwd 144(%1), %%mm6\n" + "pmaddwd 152(%1), %%mm7\n" + "paddd %%mm4, %%mm0\n" + "paddd %%mm5, %%mm1\n" + "paddd %%mm6, %%mm2\n" + "paddd %%mm7, %%mm3\n" + "\n" + "psrad %4, %%mm0\n" + "psrad %4, %%mm1\n" + "psrad %4, %%mm2\n" + "psrad %4, %%mm3\n" + "\n" + "packssdw %%mm0, %%mm0\n" + "packssdw %%mm1, %%mm1\n" + "packssdw %%mm2, %%mm2\n" + "packssdw %%mm3, %%mm3\n" + "\n" + "movq %%mm0, %%mm4\n" + "movq %%mm0, %%mm5\n" + "pmaddwd 160(%1), %%mm4\n" + "pmaddwd 168(%1), %%mm5\n" + "\n" + "movq %%mm1, %%mm6\n" + "movq %%mm1, %%mm7\n" + "pmaddwd 192(%1), %%mm6\n" + "pmaddwd 200(%1), %%mm7\n" + "paddd %%mm6, %%mm4\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm2, %%mm6\n" + "movq %%mm2, %%mm7\n" + "pmaddwd 224(%1), %%mm6\n" + "pmaddwd 232(%1), %%mm7\n" + "paddd %%mm6, %%mm4\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm3, %%mm6\n" + "movq %%mm3, %%mm7\n" + "pmaddwd 256(%1), %%mm6\n" + "pmaddwd 264(%1), %%mm7\n" + "paddd %%mm6, %%mm4\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm4, (%3)\n" + "movq %%mm5, 8(%3)\n" + "\n" + "movq %%mm0, %%mm5\n" + "pmaddwd 176(%1), %%mm0\n" + "pmaddwd 184(%1), %%mm5\n" + "\n" + "movq %%mm1, %%mm7\n" + "pmaddwd 208(%1), %%mm1\n" + "pmaddwd 216(%1), %%mm7\n" + "paddd %%mm1, %%mm0\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm2, %%mm7\n" + "pmaddwd 240(%1), %%mm2\n" + "pmaddwd 248(%1), %%mm7\n" + "paddd %%mm2, %%mm0\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm3, %%mm7\n" + "pmaddwd 272(%1), %%mm3\n" + "pmaddwd 280(%1), %%mm7\n" + "paddd %%mm3, %%mm0\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm0, 16(%3)\n" + "movq %%mm5, 24(%3)\n" + : + : "r" (in), "r" (consts), "r" (&round_c), "r" (out), + "i" (SBC_PROTO_FIXED8_SCALE) + : "cc", "memory"); +} + +static inline void sbc_analyze_4b_4s_sse(struct sbc_encoder_state *state, + int16_t *x, int32_t *out, int out_stride) +{ + /* Analyze blocks */ + sbc_analyze_four_sse(x + 12, out, analysis_consts_fixed4_simd_odd); + out += out_stride; + sbc_analyze_four_sse(x + 8, out, analysis_consts_fixed4_simd_even); + out += out_stride; + sbc_analyze_four_sse(x + 4, out, analysis_consts_fixed4_simd_odd); + out += out_stride; + sbc_analyze_four_sse(x + 0, out, analysis_consts_fixed4_simd_even); + + __asm__ volatile ("emms\n"); +} + +static inline void sbc_analyze_4b_8s_sse(struct sbc_encoder_state *state, + int16_t *x, int32_t *out, int out_stride) +{ + /* Analyze blocks */ + sbc_analyze_eight_sse(x + 24, out, analysis_consts_fixed8_simd_odd); + out += out_stride; + sbc_analyze_eight_sse(x + 16, out, analysis_consts_fixed8_simd_even); + out += out_stride; + sbc_analyze_eight_sse(x + 8, out, analysis_consts_fixed8_simd_odd); + out += out_stride; + sbc_analyze_eight_sse(x + 0, out, analysis_consts_fixed8_simd_even); + + __asm__ volatile ("emms\n"); +} + +static inline void sbc_analyze_1b_8s_sse_even(struct sbc_encoder_state *state, + int16_t *x, int32_t *out, int out_stride); + +static inline void sbc_analyze_1b_8s_sse_odd(struct sbc_encoder_state *state, + int16_t *x, int32_t *out, int out_stride) +{ + sbc_analyze_eight_sse(x, out, analysis_consts_fixed8_simd_odd); + state->sbc_analyze_8s = sbc_analyze_1b_8s_sse_even; + + __asm__ volatile ("emms\n"); +} + +static inline void sbc_analyze_1b_8s_sse_even(struct sbc_encoder_state *state, + int16_t *x, int32_t *out, int out_stride) +{ + sbc_analyze_eight_sse(x, out, analysis_consts_fixed8_simd_even); + state->sbc_analyze_8s = sbc_analyze_1b_8s_sse_odd; + + __asm__ volatile ("emms\n"); +} + +static void sbc_calc_scalefactors_sse( + int32_t sb_sample_f[16][2][8], + uint32_t scale_factor[2][8], + int blocks, int channels, int subbands) +{ + static const SBC_ALIGNED int32_t consts[2] = { + 1 << SCALE_OUT_BITS, + 1 << SCALE_OUT_BITS, + }; + int ch, sb; + intptr_t blk; + for (ch = 0; ch < channels; ch++) { + for (sb = 0; sb < subbands; sb += 2) { + blk = (blocks - 1) * (((char *) &sb_sample_f[1][0][0] - + (char *) &sb_sample_f[0][0][0])); + __asm__ volatile ( + "movq (%4), %%mm0\n" + "1:\n" + "movq (%1, %0), %%mm1\n" + "pxor %%mm2, %%mm2\n" + "pcmpgtd %%mm2, %%mm1\n" + "paddd (%1, %0), %%mm1\n" + "pcmpgtd %%mm1, %%mm2\n" + "pxor %%mm2, %%mm1\n" + + "por %%mm1, %%mm0\n" + + "sub %2, %0\n" + "jns 1b\n" + + "movd %%mm0, %k0\n" + "psrlq $32, %%mm0\n" + "bsrl %k0, %k0\n" + "subl %5, %k0\n" + "movl %k0, (%3)\n" + + "movd %%mm0, %k0\n" + "bsrl %k0, %k0\n" + "subl %5, %k0\n" + "movl %k0, 4(%3)\n" + : "+r" (blk) + : "r" (&sb_sample_f[0][ch][sb]), + "i" ((char *) &sb_sample_f[1][0][0] - + (char *) &sb_sample_f[0][0][0]), + "r" (&scale_factor[ch][sb]), + "r" (&consts), + "i" (SCALE_OUT_BITS) + : "cc", "memory"); + } + } + __asm__ volatile ("emms\n"); +} + +void sbc_init_primitives_sse(struct sbc_encoder_state *state) +{ + state->sbc_analyze_4s = sbc_analyze_4b_4s_sse; + if (state->increment == 1) + state->sbc_analyze_8s = sbc_analyze_1b_8s_sse_odd; + else + state->sbc_analyze_8s = sbc_analyze_4b_8s_sse; + state->sbc_calc_scalefactors = sbc_calc_scalefactors_sse; + state->implementation_info = "SSE"; +} + +#endif diff --git a/sbc/sbc_primitives_sse.h b/sbc/sbc_primitives_sse.h new file mode 100644 index 0000000..8830cfd --- /dev/null +++ b/sbc/sbc_primitives_sse.h @@ -0,0 +1,38 @@ +/* + * + * Bluetooth low-complexity, subband codec (SBC) library + * + * Copyright (C) 2020 Intel Corporation + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __SBC_PRIMITIVES_SSE_H +#define __SBC_PRIMITIVES_SSE_H + +#include "sbc_primitives.h" + +#if defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) && \ + !defined(SBC_HIGH_PRECISION) && (SCALE_OUT_BITS == 15) + +#define SBC_BUILD_WITH_SSE_SUPPORT + +void sbc_init_primitives_sse(struct sbc_encoder_state *encoder_state); + +#endif + +#endif -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CGN1LobgMl+6QwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 20:16:38 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id OFFTLYbgMl85FQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 20:16:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D1A6CA12D7; Tue, 11 Aug 2020 20:16:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbgHKSQ2 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 14:16:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgHKSQ0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 14:16:26 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21513C061787 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:16:26 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id 74so8033131pfx.13 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UyGhDQx+Fo5M3xKnhn89uy/B9QHHoarx84rdgC8Xt+M=; b=gwS6XEWEeTvDROkJDmbr4xY4Tg27BRumNXRCORqrHqSqoDt5Q0sQr3EVf7uKeAO1P8 XcUTe7Tlbw7NO9Am9OcBDhUraqonqnm+rXhsGAvkHJJoiqjAr6W1yhlDgSFcXfZ3p36L +99t117x4HP4GNgamIs+bOfzpJOHh8/hb1/j4N3uxrDKyU4dvfxwPaVvtd8JE0j1vUmL R8nRZ3FRRbQ4ynxArrlfa0C+QSgD1bFg1qW/2unFlvVJD3JI8FQG10lgJhFgf6h8w6zZ IEHZBWo3d9boRE52D3Lk70vLXCA+7lsJ7RQfVTmIuG+r96vPTbKd/6mzk+pTii+4E/7H oJXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UyGhDQx+Fo5M3xKnhn89uy/B9QHHoarx84rdgC8Xt+M=; b=XWW7LrPmgQ0P8mqhEF4Gln6dy0D3Y0tcgmpHESyXndHwTCpFpRquQ7YRjkmsIpPVuE FFAWriZHVPyyG+Gyy0Wtq9Fav0kWBb+KL4xR/gR57nYZkD6ab1Czr1Wcj2A7CSZsuWzQ BQJsRHZvAPGLgW1XqnLECK3jQhHBupyU+M3wJaLBFFRNmVFp+c2Nyv5DcgOzb71GdblP K8gvgEdqBS1J6nCkQEZl1Cvq2lDoEuS1BNBj7HEK63vbpYWyvAL+hOvVtPomJXSBJvqe WA8AImFXYKLKNJCjoT/AdIeXHAx0fMSWSnBqdvPiema4YB1I3AYI9eVR4qkgLqyVP01f qvcQ== X-Gm-Message-State: AOAM531ShB8wEboKSq/Lge3ATitIfRBZIcHAqjpjTjLxWU0VqyyG9zO9 6l6cIP8pxeQ2oW7SC9rWGwajnC4d X-Google-Smtp-Source: ABdhPJy66salRM0DMojhugequGg5gyaD7WO4LX2t4ysUrV20lLsEegLyOGiDOlDYksQZYnNd/i+viA== X-Received: by 2002:a63:6fc3:: with SMTP id k186mr1864216pgc.109.1597169785295; Tue, 11 Aug 2020 11:16:25 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id b22sm27011519pfb.213.2020.08.11.11.16.24 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 11:16:24 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH SBC 2/3] sbc/sbc_primitives_sse: Optimize sbc_analyze_4s Date: Tue, 11 Aug 2020 11:16:22 -0700 Message-Id: <20200811181623.3683374-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200811181623.3683374-1-luiz.dentz@gmail.com> References: <20200811181623.3683374-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: D1A6CA12D7 X-Rspamd-UID: bf3bc4 From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This makes use 128 bit XMM registers whenever possible. $ time src/sbcenc_mmx -s 4 sin_4m.au > /dev/null real 0m1.073s user 0m1.039s sys 0m0.030s === After ==== $ time src/sbcenc -s 4 sin_4m.au > /dev/null real 0m1.049s user 0m1.000s sys 0m0.047s --- sbc/sbc_primitives_sse.c | 58 +++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/sbc/sbc_primitives_sse.c b/sbc/sbc_primitives_sse.c index c2b729a..6471bd5 100644 --- a/sbc/sbc_primitives_sse.c +++ b/sbc/sbc_primitives_sse.c @@ -38,48 +38,40 @@ static inline void sbc_analyze_four_sse(const int16_t *in, int32_t *out, const FIXED_T *consts) { - static const SBC_ALIGNED int32_t round_c[2] = { + static const SBC_ALIGNED int32_t round_c[4] = { + 1 << (SBC_PROTO_FIXED4_SCALE - 1), + 1 << (SBC_PROTO_FIXED4_SCALE - 1), 1 << (SBC_PROTO_FIXED4_SCALE - 1), 1 << (SBC_PROTO_FIXED4_SCALE - 1), }; __asm__ volatile ( - "movq (%0), %%mm0\n" - "movq 8(%0), %%mm1\n" - "pmaddwd (%1), %%mm0\n" - "pmaddwd 8(%1), %%mm1\n" - "paddd (%2), %%mm0\n" - "paddd (%2), %%mm1\n" + "movdqu (%0), %%xmm0\n" + "pmaddwd (%1), %%xmm0\n" + "paddd (%2), %%xmm0\n" "\n" - "movq 16(%0), %%mm2\n" - "movq 24(%0), %%mm3\n" - "pmaddwd 16(%1), %%mm2\n" - "pmaddwd 24(%1), %%mm3\n" - "paddd %%mm2, %%mm0\n" - "paddd %%mm3, %%mm1\n" + "movdqu 16(%0), %%xmm1\n" + "pmaddwd 16(%1), %%xmm1\n" + "paddd %%xmm1, %%xmm0\n" "\n" - "movq 32(%0), %%mm2\n" - "movq 40(%0), %%mm3\n" - "pmaddwd 32(%1), %%mm2\n" - "pmaddwd 40(%1), %%mm3\n" - "paddd %%mm2, %%mm0\n" - "paddd %%mm3, %%mm1\n" + "movdqu 32(%0), %%xmm1\n" + "pmaddwd 32(%1), %%xmm1\n" + "paddd %%xmm1, %%xmm0\n" "\n" - "movq 48(%0), %%mm2\n" - "movq 56(%0), %%mm3\n" - "pmaddwd 48(%1), %%mm2\n" - "pmaddwd 56(%1), %%mm3\n" - "paddd %%mm2, %%mm0\n" - "paddd %%mm3, %%mm1\n" + "movdqu 48(%0), %%xmm1\n" + "pmaddwd 48(%1), %%xmm1\n" + "paddd %%xmm1, %%xmm0\n" "\n" - "movq 64(%0), %%mm2\n" - "movq 72(%0), %%mm3\n" - "pmaddwd 64(%1), %%mm2\n" - "pmaddwd 72(%1), %%mm3\n" - "paddd %%mm2, %%mm0\n" - "paddd %%mm3, %%mm1\n" + "movdqu 64(%0), %%xmm1\n" + "pmaddwd 64(%1), %%xmm1\n" + "paddd %%xmm1, %%xmm0\n" + "\n" + "psrad %4, %%xmm0\n" + "\n" + "movdqa %%xmm0, %%xmm1\n" + "punpckhqdq %%xmm1, %%xmm1\n" + "movdq2q %%xmm0, %%mm0\n" + "movdq2q %%xmm1, %%mm1\n" "\n" - "psrad %4, %%mm0\n" - "psrad %4, %%mm1\n" "packssdw %%mm0, %%mm0\n" "packssdw %%mm1, %%mm1\n" "\n" -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iLp2AIzgMl+6QwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 20:16:44 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UBRNOovgMl95jwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 20:16:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DB358A0D15; Tue, 11 Aug 2020 20:16:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726235AbgHKSQ3 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 14:16:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgHKSQ2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 14:16:28 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 244A6C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:16:28 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id 2so2270013pjx.5 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZuY+8ttpOiBKxERHjcGAwCRhPfgHFomYRLZ89jgaUJI=; b=pGYOIwguiT71kLJwMKFDadxrolB7t7l/kGTIK2b4yFSdlxPgvkMgjf9/DiaFgmR1vT KakZFS77e/12pW8u564C9n+GHBN739eYceqxijFGEOJMtZJIYADja5N60VK3Um+oXsnD Om4fh393zfvyGHRrn0jHco6XC648XCw2GDFDCUV5YDNpPDdKvG0d/UmOu+1LInYe9d/I yJyJkin+1tmKTngljqfNlGT0xVNjSIbMcJ7Thi2p9NpuVnXSM9aD6TQ7zC7pJ0TmN4IX shHiR8yfl6rK0ecSN6zG9dhakEkpQ1ZW9roiral2lDG2UvBA7s59aOiDvywuIJ4ymK1T 7P4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZuY+8ttpOiBKxERHjcGAwCRhPfgHFomYRLZ89jgaUJI=; b=MW2LIUPodYv7IefrBjWKm5T9d+5Ob9gXRHJ4PmEnJvAO6q0CL+o6i6VyH7xX2VywHx 3zArB370RObge9pV2jOxO/KT0+gRmgMbDPOOho15vhk5oS9UhFKjzpxhk1pNeiJ2tJuf konBGUA0ENMsYl692PAXEP5mrklGBVrOwgcFjRYH76WOKnhHmQy4dhWFFtpvjWjnERwq eP6o68q1uniqteNFvfFVQCOPWlG6cxBSVR1VIRg+gr84XQTxyUOx3T2MJLtecZOq0whB RHnxcxTLyQ5lAFdZVcPZGPuvIZnfcC6okv1vu3l5BaCF5LAiuRu7OtpmKJOkH5eTWhsl 7Pvg== X-Gm-Message-State: AOAM530CHBVJo7H0/MZzIFXLX72oiE2klP4LlR4nOti2NaTLsSncG+fj oQJKlqVkbxAzL6Njz6XF3Tq8x7Ae X-Google-Smtp-Source: ABdhPJwZUTeF7RhbZyEQi55oHMef1OMcXh6lE6+MVhSd+UJJAE3rCM6nG0g9VqUusf0ybJjWj6926A== X-Received: by 2002:a17:90b:1116:: with SMTP id gi22mr2383393pjb.209.1597169786957; Tue, 11 Aug 2020 11:16:26 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id b22sm27011519pfb.213.2020.08.11.11.16.25 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 11:16:25 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH SBC 3/3] sbc/sbc_primitives_sse: Optimize sbc_analyze_8s Date: Tue, 11 Aug 2020 11:16:23 -0700 Message-Id: <20200811181623.3683374-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200811181623.3683374-1-luiz.dentz@gmail.com> References: <20200811181623.3683374-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: DB358A0D15 X-Rspamd-UID: 02dc45 From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This makes use 128 bit XMM registers whenever possible. $ time src/sbcenc_mmx -s 8 sin_64m.au > /dev/null real 0m1.064s user 0m1.012s sys 0m0.049s === After ==== $ time src/sbcenc -s 8 sin_64m.au > /dev/null real 0m1.032s user 0m0.996s sys 0m0.033s --- sbc/sbc_primitives_sse.c | 109 ++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 65 deletions(-) diff --git a/sbc/sbc_primitives_sse.c b/sbc/sbc_primitives_sse.c index 6471bd5..6f8eb49 100644 --- a/sbc/sbc_primitives_sse.c +++ b/sbc/sbc_primitives_sse.c @@ -96,80 +96,59 @@ static inline void sbc_analyze_four_sse(const int16_t *in, int32_t *out, static inline void sbc_analyze_eight_sse(const int16_t *in, int32_t *out, const FIXED_T *consts) { - static const SBC_ALIGNED int32_t round_c[2] = { + static const SBC_ALIGNED int32_t round_c[4] = { + 1 << (SBC_PROTO_FIXED8_SCALE - 1), + 1 << (SBC_PROTO_FIXED8_SCALE - 1), 1 << (SBC_PROTO_FIXED8_SCALE - 1), 1 << (SBC_PROTO_FIXED8_SCALE - 1), }; __asm__ volatile ( - "movq (%0), %%mm0\n" - "movq 8(%0), %%mm1\n" - "movq 16(%0), %%mm2\n" - "movq 24(%0), %%mm3\n" - "pmaddwd (%1), %%mm0\n" - "pmaddwd 8(%1), %%mm1\n" - "pmaddwd 16(%1), %%mm2\n" - "pmaddwd 24(%1), %%mm3\n" - "paddd (%2), %%mm0\n" - "paddd (%2), %%mm1\n" - "paddd (%2), %%mm2\n" - "paddd (%2), %%mm3\n" + "movdqu (%0), %%xmm0\n" + "movdqu 16(%0), %%xmm1\n" + "pmaddwd (%1), %%xmm0\n" + "pmaddwd 16(%1), %%xmm1\n" + "paddd (%2), %%xmm0\n" + "paddd (%2), %%xmm1\n" "\n" - "movq 32(%0), %%mm4\n" - "movq 40(%0), %%mm5\n" - "movq 48(%0), %%mm6\n" - "movq 56(%0), %%mm7\n" - "pmaddwd 32(%1), %%mm4\n" - "pmaddwd 40(%1), %%mm5\n" - "pmaddwd 48(%1), %%mm6\n" - "pmaddwd 56(%1), %%mm7\n" - "paddd %%mm4, %%mm0\n" - "paddd %%mm5, %%mm1\n" - "paddd %%mm6, %%mm2\n" - "paddd %%mm7, %%mm3\n" + "movdqu 32(%0), %%xmm2\n" + "movdqu 48(%0), %%xmm3\n" + "pmaddwd 32(%1), %%xmm2\n" + "pmaddwd 48(%1), %%xmm3\n" + "paddd %%xmm2, %%xmm0\n" + "paddd %%xmm3, %%xmm1\n" "\n" - "movq 64(%0), %%mm4\n" - "movq 72(%0), %%mm5\n" - "movq 80(%0), %%mm6\n" - "movq 88(%0), %%mm7\n" - "pmaddwd 64(%1), %%mm4\n" - "pmaddwd 72(%1), %%mm5\n" - "pmaddwd 80(%1), %%mm6\n" - "pmaddwd 88(%1), %%mm7\n" - "paddd %%mm4, %%mm0\n" - "paddd %%mm5, %%mm1\n" - "paddd %%mm6, %%mm2\n" - "paddd %%mm7, %%mm3\n" + "movdqu 64(%0), %%xmm2\n" + "movdqu 80(%0), %%xmm3\n" + "pmaddwd 64(%1), %%xmm2\n" + "pmaddwd 80(%1), %%xmm3\n" + "paddd %%xmm2, %%xmm0\n" + "paddd %%xmm3, %%xmm1\n" "\n" - "movq 96(%0), %%mm4\n" - "movq 104(%0), %%mm5\n" - "movq 112(%0), %%mm6\n" - "movq 120(%0), %%mm7\n" - "pmaddwd 96(%1), %%mm4\n" - "pmaddwd 104(%1), %%mm5\n" - "pmaddwd 112(%1), %%mm6\n" - "pmaddwd 120(%1), %%mm7\n" - "paddd %%mm4, %%mm0\n" - "paddd %%mm5, %%mm1\n" - "paddd %%mm6, %%mm2\n" - "paddd %%mm7, %%mm3\n" + "movdqu 96(%0), %%xmm2\n" + "movdqu 112(%0), %%xmm3\n" + "pmaddwd 96(%1), %%xmm2\n" + "pmaddwd 112(%1), %%xmm3\n" + "paddd %%xmm2, %%xmm0\n" + "paddd %%xmm3, %%xmm1\n" "\n" - "movq 128(%0), %%mm4\n" - "movq 136(%0), %%mm5\n" - "movq 144(%0), %%mm6\n" - "movq 152(%0), %%mm7\n" - "pmaddwd 128(%1), %%mm4\n" - "pmaddwd 136(%1), %%mm5\n" - "pmaddwd 144(%1), %%mm6\n" - "pmaddwd 152(%1), %%mm7\n" - "paddd %%mm4, %%mm0\n" - "paddd %%mm5, %%mm1\n" - "paddd %%mm6, %%mm2\n" - "paddd %%mm7, %%mm3\n" + "movdqu 128(%0), %%xmm2\n" + "movdqu 144(%0), %%xmm3\n" + "pmaddwd 128(%1), %%xmm2\n" + "pmaddwd 144(%1), %%xmm3\n" + "paddd %%xmm2, %%xmm0\n" + "paddd %%xmm3, %%xmm1\n" + "\n" + "psrad %4, %%xmm0\n" + "psrad %4, %%xmm1\n" "\n" - "psrad %4, %%mm0\n" - "psrad %4, %%mm1\n" - "psrad %4, %%mm2\n" - "psrad %4, %%mm3\n" + "movdqa %%xmm0, %%xmm2\n" + "movdqa %%xmm1, %%xmm3\n" + "punpckhqdq %%xmm2, %%xmm2\n" + "punpckhqdq %%xmm3, %%xmm3\n" + "movdq2q %%xmm0, %%mm0\n" + "movdq2q %%xmm2, %%mm1\n" + "movdq2q %%xmm1, %%mm2\n" + "movdq2q %%xmm3, %%mm3\n" "\n" "packssdw %%mm0, %%mm0\n" "packssdw %%mm1, %%mm1\n" -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8AwsEwriMl9TbQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 20:23:06 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4Fl4EQriMl9GbQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 20:23:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 46664420D3; Tue, 11 Aug 2020 20:23:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726068AbgHKSXB (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 14:23:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgHKSXA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 14:23:00 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81528C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:23:00 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id t10so9776122ejs.8 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=80MqzdbmpekdCOXsCwtPy9E0KJ1f3RCz3JzvHIOL3oY=; b=Qov1Ikofkd7DoHpiXC5igXurZ5v0Fvtjl+PLkSmwodk8fciUbwQimTCfxTm/zSRUOY WD4Q2JekSdtbDP0bZ4qoYU1kcFF6focFzeOcL2e3WLdEGHR9MKVJJKlrrTtPQqjhOw0r I+pMLZoCKCCkCOzUuxdAi1Sxch5YKtVeowhCrpJkNI+JlLqMHYZFERed+5kZdH7MA3CH EH1meiLs3l7uuMJs2pNbeuPQtDqzXNuHqW9QrPJZtBHoCjOlOfjb8WIquyqkyH6E9VJd cdvhZp6UdMemlkMwrvxKs94e7VHwjZGjetznnYtjedCYvlXodfuxWoYuevAsfndovGlq nPxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=80MqzdbmpekdCOXsCwtPy9E0KJ1f3RCz3JzvHIOL3oY=; b=rIEdXzn7uWr7ECLLTLRtmg1WSSxUeJVrnwmKMjHysHLk85DfTFSIYGqOOCg+mERxhr wH2I3WFth7iwDLtRETvf+toiOvz+fqdIz04aq9R3jtYIHahw5IGQ58dMQGMsikfeAn82 FdJo5WNmoblhDr8Ferdh9xqC5ERVDp2N5La9s/Evu3dJjvVRWuxQ2wIKSC4X2ESzJIVy t6SMICG/dpgTz7XY9lDv3JIVpoCMgvRnC4/hGMDQg0wL+P8EQlxj+ou2VflIWXBVxSas LsxKgWgMpqniU2vwPOh0ctY/0ZkTr3OKbVIhwkehpbFdUgRRTkuX2jFTTY9090zYNQnt TlWA== X-Gm-Message-State: AOAM5337xboVfOzDSfH8nO+7UR8QkAkp5Wc+2WNQNhZbW/g6B6ebXo89 OrsM9fWE0B47yk8I9LLGSVv48qwtz/CALdETwjKwbYwzNSs= X-Google-Smtp-Source: ABdhPJz7gfcfvfKo7suWvZgVOZYBNf4mG71TTgwLfhwgWewfIVZTES92hBbalSac1fPK52XAEgPevutKUKCZ5VHIbQw= X-Received: by 2002:a17:906:e093:: with SMTP id gh19mr11531736ejb.210.1597170177637; Tue, 11 Aug 2020 11:22:57 -0700 (PDT) MIME-Version: 1.0 References: <20200803235811.2441774-1-yudiliu@google.com> <20200803165804.RFC.v1.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> In-Reply-To: <20200803165804.RFC.v1.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> From: Yu Liu <yudiliu@google.com> Date: Tue, 11 Aug 2020 11:22:21 -0700 Message-ID: <CAHC-ybxKkrDzvtyj3ksyeh4zMuoCGeCOoRodLHi1ADLBYL1efQ@mail.gmail.com> Subject: Re: [RFC PATCH v1 1/1] adapter - D-Bus API for querying the adapter's capability To: linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.86 / 15.00 / 200.00 X-Rspamd-Queue-Id: 46664420D3 X-Rspamd-UID: c15106 Friendly ping for comments, thanks. On Mon, Aug 3, 2020 at 4:58 PM Yu Liu <yudiliu@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > Initially this is introduced to query whether WBS is supported by the adapter, > the API is generic enough to be extended to support querying others in > the future. > > Reviewed-by: sonnysasaka@chromium.org > > --- > > Changes in v1: > - Initial change > > doc/adapter-api.txt | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt > index 1a7255750..250d0e9b3 100644 > --- a/doc/adapter-api.txt > +++ b/doc/adapter-api.txt > @@ -204,6 +204,23 @@ Methods void StartDiscovery() > org.bluez.Error.NotReady > org.bluez.Error.Failed > > + dict GetSupportedCapabilities() > + > + This method returns a dictionary of supported > + capabilities that is populated when the adapter > + initiated. > + > + The dictionary is following the format > + {capability : value}, where: > + > + string capability: The supported capability under > + discussion. > + variant value: A more detailed description of > + the capability. > + > + Possible errors: org.bluez.Error.NotReady > + org.bluez.Error.Failed > + > Properties string Address [readonly] > > The Bluetooth device address. > -- > 2.28.0.163.g6104cc2f0b6-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0RTbFa7jMl/keAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 20:30:06 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IHarE67jMl+edAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 20:30:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 30688420C2; Tue, 11 Aug 2020 20:30:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726164AbgHKS37 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 14:29:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbgHKS37 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 14:29:59 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89953C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:29:58 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id a6so2827066oog.9 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=fdxJyK64IhcdH2atTzNBdhDwAuEzjFER0OJtA1BgZGU=; b=m5WK8boW+6IbhXIHo3CNYA+M96rVERn6X6w64V9YEdEyOnFLUas6hDWPHx28tLp3uF QmPBxju5QNM2ghp1MHppYx535jP0ZXyEJ3Qmn54Mde+eNDBf8+nQXFJ+AKxwPkvobEue JTWIMygE5WpfDxOFbUYF37UrfQmKFekWUrwbiP6eNqAGkP6NYaKtPftE9pygzsdslGfo thRrKQQ5e1d9VKKlEnlkW+GNybbyRkqIhUNjEyHuEeZJjBSOw0Tdv9q2GfNxC/+FBYci gJXzQPVEhroCUMYkp8Zr6dWemmV2slCDHgBRW3p77g9SY80/fkix9kTWb5QwltcJ3T9h iC9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=fdxJyK64IhcdH2atTzNBdhDwAuEzjFER0OJtA1BgZGU=; b=K+59l8zFPdINpMM5Odifrp66b2FOVG3MgaFUhtEJtWYxo2zwXv4Bvzr32tvVzIVTs3 IosBUTBmu01pc1KP9BcY1jfb2adbjbbgUWOg5vstlSxuYbv15w1+2eR13BIU5h4LAZ3O taquKRz5Pf1orFEsX5Yjp7LBxYgIVBdDX5etJu3k/cXDPgz1OGu5VHFwcpusXBUft196 TTqU7J9Lf+0Hyn4cNvDqoanlmPySatAKRmVgkBRy7g4CrHqgdhe5FjoYcmLemyvp5cH7 YlE2u2wQ5mcbhBxV34flGVH3fUAolOlTI7N4CSjsoM7AR2O1nYYORZLOzwIC/+lMNRzi uYVg== X-Gm-Message-State: AOAM531p0yRAz3itPEksyOyGxjSkLtByQw6oD98Sg/GNrnsYlrhthcau X/RXkvEdqOaPSvO1elxR/r/iln1A+1ytasy/lBQ= X-Google-Smtp-Source: ABdhPJyEmusZ1QL77ZM5y7NLzbqmJIdQY+gxs7gy82GQZvVYGpAoeCa+gj8D4r4+59TauPAfW4S09gfEQTmvANUe0lo= X-Received: by 2002:a4a:380b:: with SMTP id c11mr6433608ooa.17.1597170597877; Tue, 11 Aug 2020 11:29:57 -0700 (PDT) MIME-Version: 1.0 References: <20200808193026.29007-1-pali@kernel.org> In-Reply-To: <20200808193026.29007-1-pali@kernel.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 11 Aug 2020 11:29:48 -0700 Message-ID: <CABBYNZJGQ26oiOqeGyUBvOPSzTWGuJpTumuzq+MPyiLzMkj4HQ@mail.gmail.com> Subject: Re: [PATCH] sbcenc: Remove duplicate check for num of channels To: =?UTF-8?Q?Pali_Roh=C3=A1r?= <pali@kernel.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 30688420C2 X-Rspamd-UID: b05e59 Hi Pali, On Sat, Aug 8, 2020 at 12:34 PM Pali Roh=C3=A1r <pali@kernel.org> wrote: > > Signed-off-by: Pali Roh=C3=A1r <pali@kernel.org> > --- > src/sbcenc.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/src/sbcenc.c b/src/sbcenc.c > index 2a4c240..6f8d794 100644 > --- a/src/sbcenc.c > +++ b/src/sbcenc.c > @@ -142,7 +142,6 @@ static void encode(char *filename, int subbands, int = bitpool, int joint, > blocks =3D=3D 12 ? SBC_BLK_12 : S= BC_BLK_16; > } else { > if (BE_INT(au_hdr.sample_rate) !=3D 16000 || > - BE_INT(au_hdr.channels) !=3D 1 || > BE_INT(au_hdr.channels) !=3D 1) { > fprintf(stderr, "mSBC requires 16 bits, 16kHz, mo= no " > "input\n"= ); > -- > 2.20.1 Applied, thanks. --=20 Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aFcPMcrjMl+6QwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 20:30:34 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id cAzHL8rjMl+dGgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 20:30:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DD500420F8; Tue, 11 Aug 2020 20:30:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725987AbgHKSa3 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 14:30:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgHKSa2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 14:30:28 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 579C8C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:30:28 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id u63so13139778oie.5 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 11:30:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=bRl+N2lUAUG3eTPKJF5TH+I9ukhRa38Y8HEJ3262t1w=; b=gjcmiJT41mgveIIu4ovS/fBlYB3ML/Qyu6PCXKc6P7yYQK5+wxaLYyz/mag1ZqS81z TTAViQhBpqvkHZRbslXnqmJ/p4d6MDhcjiNOmVMRHg2tCza0/QCGASWQ8rpui+h4Te30 v9/05Odn/wRc1VxbNRxCBlyIMEn13L3PwWb4Cl9TjxZ2bAvgVCi9jl537Kk5jKI7ZS7Z pNedzYOuVpt3/k9irXUV+VL0wudKW6J32AkqdyuT9WdbXWj2Rz0xh0kpKrTInQwLE0zh 3bQcsLK94cbkmvzVoz6EH42wIVWagqr9QpOA8delYjBeCj4hgptLmkXqcBPMsT77sqTM px7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=bRl+N2lUAUG3eTPKJF5TH+I9ukhRa38Y8HEJ3262t1w=; b=U6LPhi2JyiC5oNXb0kPavEZhLhGXk7zUzX6iIe25ubqX41xl3TYAB4VKZazQE1FKTb F7LusTf0tWitTTdgLd4vvh4rEs851aurr4/pVk3tV6ipt1FcpTPuY/Nr/uMvvn+43fzs rp9IyBJjvxGq7DYKRZ3LpKlD7J2AydsZAuEQlysXisg8dyHbOjaZwWDvDeyEJm/ZWCbE cyrjAEALP/R28p/o/obo+vpxghLxI61wKlC2S0rYmiMg/pJJ759Ojb/qVyoRjLh009x/ lB7lJNDsfLpNimKZ3Ep3MNaJlKn00CBn+bUOxn/PZ+x+6NYBbDCLgmnKEvW33XrxfKtA yLMg== X-Gm-Message-State: AOAM532WQRGg9tezJZX7pKaR48s5zMXyL3mzWv+h5nzVI2NuLyyAH7H1 UxHfzfSAl/3vmsG2jlpCYPa1E432Wdv9hz3IxwYS0Q== X-Google-Smtp-Source: ABdhPJxvIYkebtSCWjLpCApcjIoOySUdddnoJ/R/GdfBt9yFL+2v0M/Nt76o5/pj/KJQxWVfnFtJZxy/qy0bShSGNlc= X-Received: by 2002:aca:cc50:: with SMTP id c77mr4408361oig.152.1597170626544; Tue, 11 Aug 2020 11:30:26 -0700 (PDT) MIME-Version: 1.0 References: <20200808193014.28951-1-pali@kernel.org> In-Reply-To: <20200808193014.28951-1-pali@kernel.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 11 Aug 2020 11:30:16 -0700 Message-ID: <CABBYNZJ0+frWpUWE3J+T+KfobesCnfpmskfOZRO0Lt3rFSfhRw@mail.gmail.com> Subject: Re: [PATCH] sbcenc: Add missing error check for unsupported sample rates To: =?UTF-8?Q?Pali_Roh=C3=A1r?= <pali@kernel.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: DD500420F8 X-Rspamd-UID: f666b4 Hi Pali, On Sat, Aug 8, 2020 at 12:34 PM Pali Roh=C3=A1r <pali@kernel.org> wrote: > > Signed-off-by: Pali Roh=C3=A1r <pali@kernel.org> > --- > src/sbcenc.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/src/sbcenc.c b/src/sbcenc.c > index dabdff4..2a4c240 100644 > --- a/src/sbcenc.c > +++ b/src/sbcenc.c > @@ -105,6 +105,10 @@ static void encode(char *filename, int subbands, int= bitpool, int joint, > case 48000: > sbc.frequency =3D SBC_FREQ_48000; > break; > + default: > + fprintf(stderr, "Unsupported sample rate %ukHz\n"= , > + BE_INT(au_hdr.sample_rate)); > + goto done; > } > > srate =3D BE_INT(au_hdr.sample_rate); > -- > 2.20.1 Applied, thanks. --=20 Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uB7ILjLzMl8dwgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 21:36:18 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id aOEQLTLzMl+pagEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 21:36:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id ADBB9A158F; Tue, 11 Aug 2020 21:36:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726165AbgHKTgM (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 15:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbgHKTgM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 15:36:12 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC83CC06174A for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 12:36:11 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id t6so14846937ljk.9 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 12:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=QoWUrHUI37BhHrd5gtDXSnBITu53jXT7bzCBrIIvQMQ=; b=hXSckqYYbW/UMauC+dL9LeqEubqyEHBZsujHUkFhkul0Kf08u14o7v3IeKbulVMJrX T/NgT7HCmuu4jzeNjUMDWXcD0XBjGwTDL+S/rgxz6sCI/0tVxFyha/Fn7V6dwZvMdGT/ 6Po72SUP6r7BBtfJjaAQgJ6EWHirnspR2bNJCBfMNITVrBn0u153X3YVdxgLHWubygJS EBIATcrWDGT6gw/K9frCjXLFLQYg8hVEQgVBVSkdfg4L9gG9qb1s35nJQH0mBXegowcv /K8ybutcHK8vA62qWr52qIXfHJwJydYQLGThE+HDpE3EMq15JzyQox9WWluGqk+i8VDK noKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=QoWUrHUI37BhHrd5gtDXSnBITu53jXT7bzCBrIIvQMQ=; b=l06Niz8paUaBtcTvLu/iSEjyiMYJGHh3vhlN1cd604cYkB+TfnS8cif+fQ36EvgRiS v7WuDxnPDCPlzTotDAp+QSuGOpAvXx7Ihi/dOVbZ4UQaX4fJTKfjGkA11ouiJhL/2nNr Yjw9wUnoroCVz+70zxnoRz6PAGQGrqQsLSGQlPqz9ewSzb+PFqcV39A/cK9u21vBT8T+ DoFb625J/eIRPgWBcJLf40+Gv8vFOalcuEhza/5W0x60i8YUZ9basFfHj8AG7T1SdV0u VYN6bZaHoUcUFXSh86RKpKvh2kpSIHzs9N5BLoS7d11UVDBmY04W0EhTul2KVJ2OyORQ vCZA== X-Gm-Message-State: AOAM5323iKx2qNkmkZXESpc7xe+bY6UPAMnnPg8+qws4xtLbkhTTmCY4 p/dO3fH5wR2n+ggVger8k40yHVZpbohFHA== X-Google-Smtp-Source: ABdhPJw662+CIO4HcJlF+UZRpi/g2hatb3qS5AECLoYNHiRoGjMtiBgIjq1NnOAB48Cgylua+gJuSw== X-Received: by 2002:a2e:9dd0:: with SMTP id x16mr3577475ljj.144.1597174567734; Tue, 11 Aug 2020 12:36:07 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id c17sm11820674lfr.23.2020.08.11.12.36.06 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 12:36:06 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= <michal.lowas-rzechonek@silvair.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] mesh: Fix encoding of Config Key Refresh Phase Status Date: Tue, 11 Aug 2020 21:37:09 +0200 Message-Id: <20200811193709.27341-1-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: ADBB9A158F X-Rspamd-UID: 3e7a52 Config Key Refresh Phase Status is 4 octets long (see Mesh Profile v1.0.1, section 4.3.2.60): 1 octet for status, 2 octets for net key index, 1 octet for the phase. --- mesh/cfgmod-server.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 9da981700..90ebdf046 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -447,11 +447,11 @@ static uint16_t cfg_key_refresh_phase(struct mesh_node *node, done: msg[n] = status; - l_put_le16(idx, msg + n); - msg[n + 2] = (status != MESH_STATUS_SUCCESS) ? + l_put_le16(idx, &msg[n + 1]); + msg[n + 3] = (status != MESH_STATUS_SUCCESS) ? KEY_REFRESH_PHASE_NONE : phase; - return n + 3; + return n + 4; } static uint8_t uint32_to_log(uint32_t value) -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8DATK036Ml9O9AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 11 Aug 2020 22:06:37 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id AJt8KU36Ml+nqAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 11 Aug 2020 22:06:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A9588A169E; Tue, 11 Aug 2020 22:06:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726705AbgHKUGP (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 11 Aug 2020 16:06:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726700AbgHKUGN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 11 Aug 2020 16:06:13 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B078DC06174A for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 13:06:12 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id 140so7351422lfi.5 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 13:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=UDIw5818LlvGzqFPAaCDNYzmCD84cqoJl5mgh1begB4=; b=NHodcNmiZDOWn+ObWKGqBMNxRMC90r+5TaIFqA966ywcoZVn7PbkYmFG0YtmPyNodx tVCTbK7YQ6CWUEuk+2LHwJPSHqQMZqWOPrpe+LVpslQSFQBRB/3iiR8LTlocNJ0gKbyp S5Try9e4XH3cif4jf8l8XtyEDPE0FFX7EyM8SiifKUFb+kQH/uwcM27GaTLtpURo3MbF w9usw26ONyzlMoyF9M9tnxan8kL5vEb5qONkRV2KYYJ3XPfHHExUR+zoptoJG+UlfHC/ 8sr5VK2a03CMTuXAjlRRJFjeGcMzco5fY0D3Q8tWYu+Ge8TqYk1+kaul8Xz63s3/T3u+ G/wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=UDIw5818LlvGzqFPAaCDNYzmCD84cqoJl5mgh1begB4=; b=DH92VFnaZJgsE46sxY9lB12ODOzhbZz3Xx4aB6Hh8vwP1R4yBWjhOsI6XQ6QQyl8nH vwxzMr4vQOc+sEW3qIXPTRiPvRxUdlVsmD92EcpcQLvpxf+7kYapnrnc+955bSsWegtB ffsiHdtOx6DttcO5uF2JMD1Z3rkGxOzI6O9/EdnRFJqepXQdOz7iIoI/GTLKB+33YVQt n3qy2Ow9/9J3y0wz1mBsvuYZUMawYZznirdaCtI9Q0aKYZGQcOZ8RcV7nBJ2zkTMXAeZ ToCOcgPUwgdP3dtYLqCt15a0fPbZdFso4iWQ6ubGh9qESjeSWeaZj7qUsmounFnss+Zc 83Lw== X-Gm-Message-State: AOAM533zgY7dfIkKKYMmMZdKaewhftn35aPd7iywOLJmdtYQBCh/v7hl lRxW1zck3Rmnm6HkTRCttiIgK2ehR7EAqg== X-Google-Smtp-Source: ABdhPJxYIz6/B5heg55WcK2Y9HbB70V1JSyfK9zpDj7UI/Dm2fuONjE2JmuW4tQdP09XEG5xHKAL9Q== X-Received: by 2002:a19:c206:: with SMTP id l6mr3909340lfc.152.1597176370819; Tue, 11 Aug 2020 13:06:10 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id 132sm11902805lfo.16.2020.08.11.13.06.09 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 13:06:10 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= <michal.lowas-rzechonek@silvair.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] mesh: Fix lookup of non-vendor models in node config Date: Tue, 11 Aug 2020 22:07:12 +0200 Message-Id: <20200811200712.21083-1-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: A9588A169E X-Rspamd-UID: 8fccad In commit 81a0868b082c ("mesh: Move model functionality out of node.c to model.c"), we changed the way we handle model ids, resulting in vendor mask not being stripped from model id before update_bindings() calls mesh_config_model_binding_*(). This resulted in get_element_model not finding the model. --- mesh/mesh-config-json.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index ae1099fcb..ce8dd5cde 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -170,11 +170,6 @@ static json_object *get_element_model(json_object *jnode, int ele_idx, size_t len; char buf[9]; - if (!vendor) - snprintf(buf, 5, "%4.4x", (uint16_t)mod_id); - else - snprintf(buf, 9, "%8.8x", mod_id); - if (!json_object_object_get_ex(jnode, "elements", &jelements)) return NULL; @@ -190,7 +185,7 @@ static json_object *get_element_model(json_object *jnode, int ele_idx, return NULL; if (!vendor) { - snprintf(buf, 5, "%4.4x", mod_id); + snprintf(buf, 5, "%4.4x", (uint16_t)mod_id); len = 4; } else { snprintf(buf, 9, "%8.8x", mod_id); -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cDvJHEBuM18mIgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 06:21:20 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id QF93G0BuM18FvAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 06:21:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A1824420D2; Wed, 12 Aug 2020 06:21:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726035AbgHLEVO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 00:21:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725944AbgHLEVO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 00:21:14 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC828C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 21:21:13 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id q19so785542qtp.0 for <linux-bluetooth@vger.kernel.org>; Tue, 11 Aug 2020 21:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=+D4+SojV3Y/sxfWJh2lOz+64TmUygXb7unMVRm5nVlg=; b=c64mJIYEdJS1vHCGKh56UAFMxMmAInNMzJQy6xeVJP1jnnG+ZcIgxRgocKAX5ia6cp 4yMd5nRQFOO5g89miBJz6K2FpthVzGgYiZNhqiakXmW8S4+YinzG7hlAE41vRzQ58bbm 05eKUcNvALyZbbk7bbluQbBMcIhzYmNTPPzEgSPSkqBC9NyrItphHDKq8gdONP1qWQMp T9nvx98/m5fOkMW3N5cF8iaOZAXF5gUdLEKoTwCXW/EmDdP1WBBARDsPZ/OwovhF0yxr uN2k4/eEZgmMqLDtnV89hEJJuyGWMrHs3m2D0uA/2wtpxm6YqZOMBGC2LuHxhtWK9Gky 4/AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=+D4+SojV3Y/sxfWJh2lOz+64TmUygXb7unMVRm5nVlg=; b=ofLSSXjYMRzEImFK5GdBtOJixCUbcn8v6c+DG7o2Fi09dE09NZmEkV4TSO4CwUH2K4 MDiDDOZ90f3eGy36MpC9SX7LlNyQuFUXC/d820OmIz1vo2pBFIfVOcGdYnfGvX/9IjLC TLWv9AaenM3cFR4cx4j0v7UJWweOnAVkuti3FOYo/GpmdDN25qKp47/l7RfwEYTYKaNE WLnoSLDAqYbPTbii6UW+JyrF7KSqdLV1rLA+tBpuo/A1rbN7Sk7llnbQEuJq36JgsTD7 +cj21qam+WhdT9I65VRBejvT5xs4ryZG3YFT4ern/Z2if4Z2yItZT/IvyCSVR47I6cTM i7NQ== X-Gm-Message-State: AOAM532uHSugMHXgi0AMdQxtXtk2SV+aC3IhLlGL3WAi/WQlT7ZDe3UO fBggwyFGZ0El9Yrr2HDsTuf3QbPn5il+OjtJowDoG0na6CsEa5fDL77g61YyoP1e1YpTrZMqYcA ft0E31ojxwb6wAnvLUWUGI/628Y34BMXb2GLOK+eHqtIWDYYe0IVjRlonCtyvMVZTqSY57HQCf+ qg X-Google-Smtp-Source: ABdhPJw0XULDvdLIOteN/Ki85Ly6P10QFgsxdTVoKyCUAzaA3gGP0W7kMlPaV7w9+BOnPdSZ7KrYwcrZsPXw X-Received: by 2002:ad4:462f:: with SMTP id x15mr4837625qvv.180.1597206072767; Tue, 11 Aug 2020 21:21:12 -0700 (PDT) Date: Wed, 12 Aug 2020 12:20:52 +0800 Message-Id: <20200812121946.Bluez.v1.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [Bluez PATCH v1] input: Don't browse SDP if HIDSDPDisable is set From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: A1824420D2 X-Rspamd-UID: 707e1a From: Archie Pusaka <apusaka@chromium.org> According to the HID1.1 spec, part 5.3.4.9: The HIDSDPDisable attribute is a Boolean value, which indicates whether connection to the SDP channel and Control or Interrupt channels are mutually exclusive. This feature supports Bluetooth HID devices that have minimal resources, and multiplex those resources between servicing the initialization (SDP) and runtime (Control and Interrupt) channels. However, Bluez still tries to connect SDP upon HID connection, regardless of the existence of the HIDSDPDisable attribute. This patch prevents the connection of SDP after HID has been established, if the device has HIDSDPDisable attribute. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- profiles/input/device.c | 2 ++ src/device.c | 8 +++++++- src/device.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index 6ec0a4c63..fac8c6896 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -1373,6 +1373,8 @@ static struct input_device *input_device_new(struct btd_service *service) /* Initialize device properties */ extract_hid_props(idev, rec); + device_set_skip_passive_sdp_discovery(device, idev->disable_sdp); + return idev; } diff --git a/src/device.c b/src/device.c index 2237a7670..a67787a2d 100644 --- a/src/device.c +++ b/src/device.c @@ -195,6 +195,7 @@ struct btd_device { bool le; bool pending_paired; /* "Paired" waiting for SDP */ bool svc_refreshed; + bool skip_passive_sdp_discovery; /* Manage whether this device can wake the system from suspend. * - wake_support: Requires a profile that supports wake (i.e. HID) @@ -1472,6 +1473,10 @@ static gboolean dev_property_wake_allowed_exist( return device_get_wake_support(device); } +void device_set_skip_passive_sdp_discovery(struct btd_device *dev, bool skip) +{ + dev->skip_passive_sdp_discovery = skip; +} static gboolean disconnect_all(gpointer user_data) { @@ -1805,7 +1810,8 @@ done: btd_error_failed(dev->connect, strerror(-err))); } else { /* Start passive SDP discovery to update known services */ - if (dev->bredr && !dev->svc_refreshed) + if (dev->bredr && !dev->svc_refreshed && + !dev->skip_passive_sdp_discovery) device_browse_sdp(dev, NULL); g_dbus_send_reply(dbus_conn, dev->connect, DBUS_TYPE_INVALID); } diff --git a/src/device.h b/src/device.h index cb8d884e8..5348d2652 100644 --- a/src/device.h +++ b/src/device.h @@ -145,6 +145,7 @@ void device_set_wake_override(struct btd_device *device, bool wake_override); void device_set_wake_allowed(struct btd_device *device, bool wake_allowed, guint32 id); void device_set_wake_allowed_complete(struct btd_device *device); +void device_set_skip_passive_sdp_discovery(struct btd_device *dev, bool skip); typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal, void *user_data); -- 2.28.0.236.gb10cc79966-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SFLQNXHcM1+y5wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 14:11:29 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id WCvjNHHcM19n9AAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 14:11:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B7C8B420EB; Wed, 12 Aug 2020 14:11:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbgHLMLY convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 08:11:24 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:46894 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbgHLMLY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 08:11:24 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id D023CCECDC; Wed, 12 Aug 2020 14:21:27 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [Bluez PATCH v1] input: Don't browse SDP if HIDSDPDisable is set From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200812121946.Bluez.v1.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> Date: Wed, 12 Aug 2020 14:11:22 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Transfer-Encoding: 8BIT Message-Id: <DCC53118-15F0-47E1-9539-9484D32593E9@holtmann.org> References: <20200812121946.Bluez.v1.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> To: Archie Pusaka <apusaka@google.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: B7C8B420EB X-Rspamd-UID: 97cbdb Hi Archie, > According to the HID1.1 spec, part 5.3.4.9: > The HIDSDPDisable attribute is a Boolean value, which indicates > whether connection to the SDP channel and Control or Interrupt > channels are mutually exclusive. This feature supports Bluetooth > HID devices that have minimal resources, and multiplex those > resources between servicing the initialization (SDP) and runtime > (Control and Interrupt) channels. > > However, Bluez still tries to connect SDP upon HID connection, > regardless of the existence of the HIDSDPDisable attribute. > > This patch prevents the connection of SDP after HID has been > established, if the device has HIDSDPDisable attribute. out of curiosity, is a qualification test failing or do you have devices that really enforce the Disable SDP part of the specification. A long long long time ago (we are talking 15+ years) some HID devices only allowed 2 L2CAP channels to be open at the same time. So the PSM 1 for SDP needed to be closed before opening the second HID data channel. If this is failing devices, it would be good to include the btmon trace of failure in the commit message so that we archive this. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wOhcE+XcM18FFQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 14:13:25 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4N1iEeXcM1+wHQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 14:13:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 89DDD420C4; Wed, 12 Aug 2020 14:13:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbgHLMNS convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 08:13:18 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:36496 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbgHLMNS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 08:13:18 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id CD672CECDC; Wed, 12 Aug 2020 14:23:21 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [RFC PATCH v1 1/1] adapter - D-Bus API for querying the adapter's capability From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200803165804.RFC.v1.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> Date: Wed, 12 Aug 2020 14:13:16 +0200 Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Archie Pusaka <apusaka@chromium.org>, sonnysasaka@chromium.org Content-Transfer-Encoding: 8BIT Message-Id: <7D5EF527-14F0-42C2-B39B-50B55F01BE74@holtmann.org> References: <20200803235811.2441774-1-yudiliu@google.com> <20200803165804.RFC.v1.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> To: Yu Liu <yudiliu@google.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.65 / 15.00 / 200.00 X-Rspamd-Queue-Id: 89DDD420C4 X-Rspamd-UID: 698539 Hi Yu, > Initially this is introduced to query whether WBS is supported by the adapter, > the API is generic enough to be extended to support querying others in > the future. > > Reviewed-by: sonnysasaka@chromium.org > > --- > > Changes in v1: > - Initial change > > doc/adapter-api.txt | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt > index 1a7255750..250d0e9b3 100644 > --- a/doc/adapter-api.txt > +++ b/doc/adapter-api.txt > @@ -204,6 +204,23 @@ Methods void StartDiscovery() > org.bluez.Error.NotReady > org.bluez.Error.Failed > > + dict GetSupportedCapabilities() > + > + This method returns a dictionary of supported > + capabilities that is populated when the adapter > + initiated. > + > + The dictionary is following the format > + {capability : value}, where: > + > + string capability: The supported capability under > + discussion. > + variant value: A more detailed description of > + the capability. > + > + Possible errors: org.bluez.Error.NotReady > + org.bluez.Error.Failed can’t this be just an array{string} that lists the capabilities? And if we introduce it, then lets introduce it also with the first user of it. Otherwise we end up forgetting to comment on the actual possible capabilities. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yDMmCzLlM19yQwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 14:48:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id mI6QOTHlM18CAQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 14:48:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 63967A0183; Wed, 12 Aug 2020 14:48:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727885AbgHLMso convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 08:48:44 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:59109 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726829AbgHLMso (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 08:48:44 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 50943CECDC; Wed, 12 Aug 2020 14:58:47 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH SBC 1/3] sbc: Add initial code for SSE primitives From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200811181623.3683374-1-luiz.dentz@gmail.com> Date: Wed, 12 Aug 2020 14:48:42 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <93FEE5B2-F495-40C4-9386-E44DF132C49D@holtmann.org> References: <20200811181623.3683374-1-luiz.dentz@gmail.com> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.59 / 15.00 / 200.00 X-Rspamd-Queue-Id: 63967A0183 X-Rspamd-UID: 0ddb78 Hi Luiz, > > --- > Makefile.am | 1 + > sbc/sbc_primitives.c | 20 ++- > sbc/sbc_primitives_sse.c | 361 +++++++++++++++++++++++++++++++++++++++ > sbc/sbc_primitives_sse.h | 38 +++++ > 4 files changed, 417 insertions(+), 3 deletions(-) > create mode 100644 sbc/sbc_primitives_sse.c > create mode 100644 sbc/sbc_primitives_sse.h > > diff --git a/Makefile.am b/Makefile.am > index 342043d..7ff0c7d 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -14,6 +14,7 @@ sbc_headers = sbc/sbc.h > > sbc_sources = sbc/sbc.c sbc/sbc_private.h sbc/sbc_math.h sbc/sbc_tables.h \ > sbc/sbc_primitives.h sbc/sbc_primitives.c \ > + sbc/sbc_primitives_sse.h sbc/sbc_primitives_sse.c \ > sbc/sbc_primitives_mmx.h sbc/sbc_primitives_mmx.c \ > sbc/sbc_primitives_iwmmxt.h sbc/sbc_primitives_iwmmxt.c \ > sbc/sbc_primitives_neon.h sbc/sbc_primitives_neon.c \ > diff --git a/sbc/sbc_primitives.c b/sbc/sbc_primitives.c > index ff343cf..97a75be 100644 > --- a/sbc/sbc_primitives.c > +++ b/sbc/sbc_primitives.c > @@ -33,6 +33,7 @@ > #include "sbc_tables.h" > > #include "sbc_primitives.h" > +#include "sbc_primitives_sse.h" > #include "sbc_primitives_mmx.h" > #include "sbc_primitives_iwmmxt.h" > #include "sbc_primitives_neon.h" > @@ -590,6 +591,21 @@ static int sbc_calc_scalefactors_j( > return joint; > } > > +static void sbc_init_primitives_x86(struct sbc_encoder_state *state) > +{ > + __builtin_cpu_init(); > + > +#ifdef SBC_BUILD_WITH_MMX_SUPPORT > + if (__builtin_cpu_supports("mmx")) > + sbc_init_primitives_mmx(state); > +#endif > + > +#ifdef SBC_BUILD_WITH_SSE_SUPPORT > + if (__builtin_cpu_supports("sse4.2")) > + sbc_init_primitives_sse(state); > +#endif lets keep the ifdef in the primitive functions they belong. This should be consistent across all primitives and not spread in two places. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qCkJB2gANF9YvQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 16:44:56 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wPyDBWgANF9biQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 16:44:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=mnmoran.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 98F31A017C; Wed, 12 Aug 2020 16:44:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726611AbgHLOot (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 10:44:49 -0400 Received: from hoster906.com ([192.252.156.27]:49204 "EHLO hoster906.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726434AbgHLOot (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 10:44:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mnmoran.org; h=from :subject:to:message-id:date:mime-version:content-type :content-transfer-encoding; s=dkim; bh=1BGXvAlqAjky12gnZjIc2GpJL aEX4ldCWFrER7CRVyc=; b=aa0/V+SIL1b+ug9XOhNFKxjiedeVBl2lTeV38OYT/ 7B1fmE5/1nGrklnCayOOXYHlxKeNsfDkxySIk8r28s3Bqqbw3LI+Yi/XyFNl9b2K XERS3e4R/RXyezrH3b3VBa4J5pGA7bwLhffAFphlg4zHfD46v5CDo7hhvEkQxG72 P0= Received: (qmail 3067 invoked by uid 503); 12 Aug 2020 14:44:48 -0000 Received: from unknown (HELO ?192.168.254.79?) (mike@mnmoran.org@162.39.210.203) by hoster906.com with ESMTPA; 12 Aug 2020 14:44:48 -0000 From: "Michael N. Moran" <mike@mnmoran.org> Subject: Single-Segment Segmented Mesh Messages To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Message-ID: <bc77bb7c-4ae6-aa1c-74d1-dfaceb48900b@mnmoran.org> Date: Wed, 12 Aug 2020 10:44:48 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.21 / 15.00 / 200.00 X-Rspamd-Queue-Id: 98F31A017C X-Rspamd-UID: 9f316b I've been trying to wrap my head around the mesh d-bus api as described in "doc/mesh-api.txt". In particular, I'm looking at the org.bluez.mesh.Node1 interface Send() and DevKeySend() operations. I don't see any way for a client application (Access Layer) to specify that a message that would fit into a single lower transport pdu should be sent as a single-segment message. The motivation for this is to be able to test the reassembly capability of an actual mesh node/device. For example, I would like to add an option to the test/test-mesh application to be able to send on/off messages using a single-segment message (if the destination element address is unicast). As it is, it appears that the bluetooth-meshd makes the decision on its own based on the length of the upper transport layer pdu. From the Mesh Profile v1.0 spec: > 3.5.3.1 Segmentation > > [...] If the Upper Transport PDU can fit into a single Lower Transport PDU using a Segmented Message format, then the lower transport layer can use a single segmented message to transmit this Upper Transport PDU. > > [...] A single-segment segmented message should be used when delivery of an Upper Transport PDU can be more efficiently transmitted using a segmented message than an unsegmented message. > > [...] A single-segment segmented message should be used when delivery of an Upper Transport PDU can be more efficiently transmitted using a segmented message than an unsegmented message. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mMBfJLkYNF/l2wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 18:28:41 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UBVLIrkYNF97NAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 18:28:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4ED96420BD; Wed, 12 Aug 2020 18:28:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbgHLQ2g (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 12:28:36 -0400 Received: from mga14.intel.com ([192.55.52.115]:15293 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726456AbgHLQ2f (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 12:28:35 -0400 IronPort-SDR: EcSrklZPwF+mXeKK1v/LDdI5ZClwGykj2N9MMYouWCHpm3yIBiZ6cMa63/5ZDCuA1tXlYzh2vB D3eGZ2EGwsGw== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="153215110" X-IronPort-AV: E=Sophos;i="5.76,304,1592895600"; d="scan'208";a="153215110" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 09:28:34 -0700 IronPort-SDR: ZXUeH1UUaO8ubX3JAQS9Y4UBC2gBnAn6PRCM4UlQrRzQ6CC3fEpceM59MLFARX4qGRKlP29eiw ChiYsSIBbj1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,304,1592895600"; d="scan'208";a="332846477" Received: from fmsmsx603-2.cps.intel.com (HELO fmsmsx603.amr.corp.intel.com) ([10.18.84.213]) by FMSMGA003.fm.intel.com with ESMTP; 12 Aug 2020 09:28:34 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 12 Aug 2020 09:28:33 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 12 Aug 2020 09:28:33 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.171) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 12 Aug 2020 09:28:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LsEY+3nhL5uaG9X6QzYi20ueOBIl1Vgy8RqtdGhRvJPma1mud1JFV+xRc2YouAcmmROA+cbjiIT3yQkEg0iG96v/UMNIe/2RYr9p2MMhS7UfkjYcFKySmGJRQ4Rcwdcd/to1L6r8zHsddhu5PzZXyQVD9vHjKNCqWm+TL6Kajp9I8LR/g4hlRQ8OzAtNPISvu9OqYhiNUidFtF9bX/VfkV2qYm4Me22zp6cD1wJjNH7PSUT4bbUJw3sOKXv5EKFNoK560zYK5ywlbBuh+K0K5A28UaQkWeTSTKU2rMIyzXzA1X45Q6qJBqECDlIzgC2ioCfqnmsijXRNGEvzJBsjNw== 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-SenderADCheck; bh=iwh0Uw746Nh3EJlVCPni6QimEDZlBkMZdEC9RVhMRqA=; b=nQwBVz7zo+1XkwvVXtaHPg6t0riJLwqZKwTuieevs7DlcmvJ/iyW7KGnFxGjPK9DLVU5pRG1oQgFnzt/h9RUgySTW5zbR0DgWQfJXgr10prtjCRQDa6GS2RA92LbDT0f6H8GVJzvY9H/oSa1Q/eWKECtIPLka9VpifKMfnjYpIthjRdo+/vzkXhc9miABTlHqRkfrq1v8A4HJA4iU+HV6jA/fhoebCfxP0nkSE5FS2F2XkWHhDLzopaQPmQip5SiMZ3hXMroK4cA5z/IhuCtE/CuKrbobWDF4nLuvYtgDGYh1DjvbF7ho2KoZ/4ncsH1YMFCZ/4pqe2gCzcZuhsGpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iwh0Uw746Nh3EJlVCPni6QimEDZlBkMZdEC9RVhMRqA=; b=HkTmkkKYGMBrChlNjmHy9Z6LValdEaAZZzJacw7gngyHXNvICEse7Zy4TSTH19EErC9c0wkY+myMIpexVEWUm+yIl1exunG72Odztoo6m0y5sgSjEhpucjIWOf0HjTntuDYgXTJS4pVpyiiBoI+eI/GAtacZQp0hN8Jyi+gC+/E= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1853.namprd11.prod.outlook.com (2603:10b6:300:112::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15; Wed, 12 Aug 2020 16:28:28 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3283.015; Wed, 12 Aug 2020 16:28:28 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "michal.lowas-rzechonek@silvair.com" <michal.lowas-rzechonek@silvair.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Subject: Re: [PATCH BlueZ] mesh: Fix encoding of Config Key Refresh Phase Status Thread-Topic: [PATCH BlueZ] mesh: Fix encoding of Config Key Refresh Phase Status Thread-Index: AQHWcBayG3TGPnpP10+G1M3FsfNV7qk0qwmA Date: Wed, 12 Aug 2020 16:28:28 +0000 Message-ID: <26cc25a933fc4d6df173a347e479d18e9f43a0f4.camel@intel.com> References: <20200811193709.27341-1-michal.lowas-rzechonek@silvair.com> In-Reply-To: <20200811193709.27341-1-michal.lowas-rzechonek@silvair.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: silvair.com; dkim=none (message not signed) header.d=none;silvair.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 625263bb-a7cf-4906-65cf-08d83edcbea9 x-ms-traffictypediagnostic: MWHPR11MB1853: x-microsoft-antispam-prvs: <MWHPR11MB185300AF43E6589B200242B7E1420@MWHPR11MB1853.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:5797; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ztimS/s0vMyp/CvIMZ51a4yK64KoM+SKUpO5UkAVSNub6AGkrEccMA/72S+Y84Kt4BVXEmzUfHNr/RBb5Mc6nHMG4uYTWSlEUvbFomSC1ZXcvvpjnirNErqwqYjJATy77cV3QG17Y0ClXed/5UypcCpkrBFlfZx/eJR3r7AZSvc3y1GkSE7K5lI9tcdyU5gSEKe6Lt3tETyUiWdW6JkSMQ8d5EP4ato/KKnKQjLc8/wgTwlnR1mKZXJVYX/npIUsoYe8FEs1MDaGo6wD/qFCyDTxyMzCnoFdcFwP4Tz1kvY0a3RJnH7WaRqDuuOMFX6KURJvRNbP5PAPSsVrBxTwRA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(39860400002)(396003)(366004)(376002)(346002)(6486002)(186003)(6506007)(71200400001)(2616005)(86362001)(4744005)(36756003)(5660300002)(110136005)(26005)(6512007)(66556008)(8936002)(8676002)(2906002)(76116006)(64756008)(66446008)(478600001)(91956017)(66476007)(66946007)(83380400001)(316002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 2PbE9AUWQvmZ5XUQse3cHzJxw/C2Z4Opw7w060LcLsUkRJQeJ71BjPcmp4dUqfH3zOnkXFaOcf3Yeb1tpWcx02dkIkeotYDYB1/+ZLyiKaris9NFBlMgioGqe9lFhDDVJKlyWdh2f9RuHVE6CDamBL1RtMJUdsmTCGNWsAeWlEjsSnILxukPCkJ04rbgcWzaEIardQYNR15yg6CSAotvgRpPHVWSCJsfiiVyVM8ef4yUWNr+fjN+5//SJVYzUIHYgEg/JrgsZg+6w8InV9TqnqsplipBv4lN5bKL4MBrkc7g2zGTH7sT3CMgnqWkVv9bCM7vvXp5NE7PZkKt7gYHzGJ28abUAlSw1j7/Bw3Kw686TSH4islC7C/iI1y6J1Xj0n18Pkro4OrlH3Hwt8EIsZFmvARfnP9fz6yVkitFBVOJcqVv8i1SRYUZsQW0FwitGE0V9ZqZtrxLv5rmWJl8jeIJzODHsGSYc9KNftaRwzqmjaY+AHYCBqQPn7Olx6Mw8X6B/kktrxKhAtnmJ2xwYuR+t0XfigpAK2cHdBdAMG+c7/wRsEuew9gMZlyoAz2tBxmuooNKHp7xVona4SvfKcy7+iPHc5EcTiJtkvlj7T8PaUIN9yxZMmyS7EHSEyWG4IQVgARzADolKHiuWn/Siw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="utf-8" Content-ID: <8E789FD9728CBC4594A4CBD69C62F4A7@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 625263bb-a7cf-4906-65cf-08d83edcbea9 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Aug 2020 16:28:28.3493 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: rf2hq4u5Ec9Evt4Gxd2kPCfDV4Uf8KXVgu4JEvpfpHOol9RXctlrB6Cir46k7NowXHxhHGOlXY8jJU2DtE0VOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1853 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4ED96420BD X-Rspamd-UID: edabbb QXBwbGllZA0KDQpPbiBUdWUsIDIwMjAtMDgtMTEgYXQgMjE6MzcgKzAyMDAsIE1pY2hhxYIgTG93 YXMtUnplY2hvbmVrIHdyb3RlOg0KPiBDb25maWcgS2V5IFJlZnJlc2ggUGhhc2UgU3RhdHVzIGlz IDQgb2N0ZXRzIGxvbmcgKHNlZSBNZXNoIFByb2ZpbGUNCj4gdjEuMC4xLCBzZWN0aW9uIDQuMy4y LjYwKTogMSBvY3RldCBmb3Igc3RhdHVzLCAyIG9jdGV0cyBmb3IgbmV0IGtleQ0KPiBpbmRleCwg MSBvY3RldCBmb3IgdGhlIHBoYXNlLg0KPiAtLS0NCj4gIG1lc2gvY2ZnbW9kLXNlcnZlci5jIHwg NiArKystLS0NCj4gIDEgZmlsZSBjaGFuZ2VkLCAzIGluc2VydGlvbnMoKyksIDMgZGVsZXRpb25z KC0pDQo+IA0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9jZmdtb2Qtc2VydmVyLmMgYi9tZXNoL2NmZ21v ZC1zZXJ2ZXIuYw0KPiBpbmRleCA5ZGE5ODE3MDAuLjkwZWJkZjA0NiAxMDA2NDQNCj4gLS0tIGEv bWVzaC9jZmdtb2Qtc2VydmVyLmMNCj4gKysrIGIvbWVzaC9jZmdtb2Qtc2VydmVyLmMNCj4gQEAg LTQ0NywxMSArNDQ3LDExIEBAIHN0YXRpYyB1aW50MTZfdCBjZmdfa2V5X3JlZnJlc2hfcGhhc2Uo c3RydWN0IG1lc2hfbm9kZSAqbm9kZSwNCj4gIA0KPiAgZG9uZToNCj4gIAltc2dbbl0gPSBzdGF0 dXM7DQo+IC0JbF9wdXRfbGUxNihpZHgsIG1zZyArIG4pOw0KPiAtCW1zZ1tuICsgMl0gPSAoc3Rh dHVzICE9IE1FU0hfU1RBVFVTX1NVQ0NFU1MpID8NCj4gKwlsX3B1dF9sZTE2KGlkeCwgJm1zZ1tu ICsgMV0pOw0KPiArCW1zZ1tuICsgM10gPSAoc3RhdHVzICE9IE1FU0hfU1RBVFVTX1NVQ0NFU1Mp ID8NCj4gIAkJCQkJCUtFWV9SRUZSRVNIX1BIQVNFX05PTkUgOiBwaGFzZTsNCj4gIA0KPiAtCXJl dHVybiBuICsgMzsNCj4gKwlyZXR1cm4gbiArIDQ7DQo+ICB9DQo+ICANCj4gIHN0YXRpYyB1aW50 OF90IHVpbnQzMl90b19sb2codWludDMyX3QgdmFsdWUpDQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cJ7NI/48NF/kyAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 21:03:26 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8PApIv48NF/luAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 21:03:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E1B6041870; Wed, 12 Aug 2020 21:03:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726640AbgHLTDT (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 15:03:19 -0400 Received: from mga02.intel.com ([134.134.136.20]:7248 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726512AbgHLTDT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 15:03:19 -0400 IronPort-SDR: xiFcWE0lHd+xYdGqEbn5TJPFULxUYdXZmZqV1Ng7xueaLnav29dqs6279TlyJISC/As/n/iEy4 EF2BNpXgYduQ== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="141885366" X-IronPort-AV: E=Sophos;i="5.76,305,1592895600"; d="scan'208";a="141885366" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 12:03:18 -0700 IronPort-SDR: 5zmocYRBpVxRPPJJOx4wq4wTO2vnEA+HtzanBpcTTwi9pNkLpBvHZP/QM7SFeK3P0sHG1PDE+D qz73AgfLYUwQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,305,1592895600"; d="scan'208";a="295161208" Received: from vsriva1-mobl1.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.229.126]) by orsmga006.jf.intel.com with ESMTP; 12 Aug 2020 12:03:18 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 1/2] mesh: Fix model ID prior to calling mesh config functions Date: Wed, 12 Aug 2020 12:03:16 -0700 Message-Id: <20200812190317.102140-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: E1B6041870 X-Rspamd-UID: b1ff70 Model IDs for SIG defined models need to be stripped off SIG_VENDOR value used for internal housekeeping prior to calling functions that save new model state in node configuration. Also, remove duplicate statements for model lookup in node config. --- mesh/mesh-config-json.c | 7 +------ mesh/model.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index a40f92c01..086d618b1 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -169,11 +169,6 @@ static json_object *get_element_model(json_object *jnode, int ele_idx, size_t len; char buf[9]; - if (!vendor) - snprintf(buf, 5, "%4.4x", (uint16_t)mod_id); - else - snprintf(buf, 9, "%8.8x", mod_id); - if (!json_object_object_get_ex(jnode, "elements", &jelements)) return NULL; @@ -189,7 +184,7 @@ static json_object *get_element_model(json_object *jnode, int ele_idx, return NULL; if (!vendor) { - snprintf(buf, 5, "%4.4x", mod_id); + snprintf(buf, 5, "%4.4x", (uint16_t)mod_id); len = 4; } else { snprintf(buf, 9, "%8.8x", mod_id); diff --git a/mesh/model.c b/mesh/model.c index 23afb93a8..136edb194 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -628,6 +628,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, uint16_t app_idx, bool unbind) { struct mesh_model *mod; + bool vendor; int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) @@ -651,11 +652,15 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, if (unbind ^ has_binding(mod->bindings, app_idx)) return MESH_STATUS_SUCCESS; + vendor = IS_VENDOR(id); + id = vendor ? id : MODEL_ID(id); + if (unbind) { model_unbind_idx(node, ele_idx, mod, app_idx); + if (!mesh_config_model_binding_del(node_config_get(node), - addr, IS_VENDOR(id), - id, app_idx)) + addr, vendor, id, + app_idx)) return MESH_STATUS_STORAGE_FAIL; l_debug("Unbind key %4.4x to model %8.8x", app_idx, mod->id); @@ -666,13 +671,12 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_INSUFF_RESOURCES; if (!mesh_config_model_binding_add(node_config_get(node), addr, - IS_VENDOR(id), id, app_idx)) + vendor, id, app_idx)) return MESH_STATUS_STORAGE_FAIL; model_bind_idx(node, ele_idx, mod, app_idx); return MESH_STATUS_SUCCESS; - } static struct mesh_virtual *add_virtual(const uint8_t *v) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GOy6BAQ9NF8ofgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 21:03:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4EbqAgQ9NF8+ywAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 21:03:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 07E10420BA; Wed, 12 Aug 2020 21:03:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726578AbgHLTDV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 15:03:21 -0400 Received: from mga02.intel.com ([134.134.136.20]:7248 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbgHLTDT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 15:03:19 -0400 IronPort-SDR: 4hNE40jw6QyNOteiIJKrIFCH2ZT2NeSweAdVNAyBhbUDi4MyUzrGLRyG/GEraA7y5VZDF+Sni+ uKkfhjjTYP3w== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="141885369" X-IronPort-AV: E=Sophos;i="5.76,305,1592895600"; d="scan'208";a="141885369" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 12:03:19 -0700 IronPort-SDR: vf0iPNKsKqaJT5Cu8JQZg+nFMQARb4+we36Bh5bjIp2PkPyKvIT+VcOO1AV1u6Y+IlHgYlhk7K S8LOWtFKYI4A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,305,1592895600"; d="scan'208";a="295161216" Received: from vsriva1-mobl1.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.229.126]) by orsmga006.jf.intel.com with ESMTP; 12 Aug 2020 12:03:19 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 2/2] mesh: Make mesh config model binding API consistent Date: Wed, 12 Aug 2020 12:03:17 -0700 Message-Id: <20200812190317.102140-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200812190317.102140-1-inga.stotland@intel.com> References: <20200812190317.102140-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: 07E10420BA X-Rspamd-UID: 15e5b3 This changes the order of function arguments in mesh_config_model_binding_add() and mesh_config_model_binding_del() to make them consistent with the rest of mesh_config_model... APIs --- mesh/mesh-config-json.c | 4 ++-- mesh/mesh-config.h | 4 ++-- mesh/model.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 086d618b1..a145388d6 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -837,7 +837,7 @@ bool mesh_config_app_key_del(struct mesh_config *cfg, uint16_t net_idx, } bool mesh_config_model_binding_add(struct mesh_config *cfg, uint16_t ele_addr, - bool vendor, uint32_t mod_id, + uint32_t mod_id, bool vendor, uint16_t app_idx) { json_object *jnode, *jmodel, *jstring, *jarray = NULL; @@ -882,7 +882,7 @@ bool mesh_config_model_binding_add(struct mesh_config *cfg, uint16_t ele_addr, } bool mesh_config_model_binding_del(struct mesh_config *cfg, uint16_t ele_addr, - bool vendor, uint32_t mod_id, + uint32_t mod_id, bool vendor, uint16_t app_idx) { json_object *jnode, *jmodel, *jarray; diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index f15f3f376..50a55d51e 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -152,10 +152,10 @@ bool mesh_config_comp_page_add(struct mesh_config *cfg, uint8_t page, uint8_t *data, uint16_t size); bool mesh_config_comp_page_mv(struct mesh_config *cfg, uint8_t old, uint8_t nw); bool mesh_config_model_binding_add(struct mesh_config *cfg, uint16_t ele_addr, - bool vendor, uint32_t mod_id, + uint32_t mod_id, bool vendor, uint16_t app_idx); bool mesh_config_model_binding_del(struct mesh_config *cfg, uint16_t ele_addr, - bool vendor, uint32_t mod_id, + uint32_t mod_id, bool vendor, uint16_t app_idx); bool mesh_config_model_pub_add(struct mesh_config *cfg, uint16_t ele_addr, uint32_t mod_id, bool vendor, diff --git a/mesh/model.c b/mesh/model.c index 136edb194..961391f13 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -659,7 +659,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, model_unbind_idx(node, ele_idx, mod, app_idx); if (!mesh_config_model_binding_del(node_config_get(node), - addr, vendor, id, + addr, id, vendor, app_idx)) return MESH_STATUS_STORAGE_FAIL; @@ -671,7 +671,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_INSUFF_RESOURCES; if (!mesh_config_model_binding_add(node_config_get(node), addr, - vendor, id, app_idx)) + id, vendor, app_idx)) return MESH_STATUS_STORAGE_FAIL; model_bind_idx(node, ele_idx, mod, app_idx); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OL3FF61SNF++HAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 22:35:57 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AHF4Fq1SNF+JGwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 22:35:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8ACDCA0F5C; Wed, 12 Aug 2020 22:35:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbgHLUfw (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 16:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726030AbgHLUfv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 16:35:51 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9452C061383 for <linux-bluetooth@vger.kernel.org>; Wed, 12 Aug 2020 13:35:51 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id e4so1707316pjd.0 for <linux-bluetooth@vger.kernel.org>; Wed, 12 Aug 2020 13:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding:thread-index:content-language; bh=mpEnNZQnLlJNcY8p8W8RFZ+S/9A7eLY+2ognL6bHrAo=; b=h8b3pBE28mDWlzQovnRmjvjZlISShKsRlGH507tdVMyCuWuV0MFP+7zmrU+iB7mchn qM6qfwETnK+fcUWERrECOY0RiMnpPuxIlmEzEjWfdZc6kbWUU9iDf5Aibuh9pdcaHS5n MX7vFp+QF+T8u2xiruDnANHvvp/EdJ3woIgg1Q4uonNax5lp2AZXFNJJ0utRu1vRV99K Y0UsncTLQTDeKvAeq4NqONXbbeB2N4k0xcL6scEThP/seo/vxDp48cjpAG6l3d97AE+t ncinophGdlnlEgqL1bLcrLiHzRLze+3p/eQIBPAuO8h6+K+GCnqP0Qsm6fqbYd/Rpg/E OqZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding:thread-index:content-language; bh=mpEnNZQnLlJNcY8p8W8RFZ+S/9A7eLY+2ognL6bHrAo=; b=mlGfkx2hMbOZutud6ls4fz+o/NNTS9vUrBGaq32bzfEXoIg1OCqqhGZem8q7dVUD+h DQ1ilBnMCNk8Fo/3PsuoYiBvZFwmozuZP21lIrGV3cu3P2XQGrVQ+sxfuK8oQu19Sh8F s7/asKxS+was+Qhnx9P8Yn+DX4CRXn3ldF91F1FDOv+C6VxPGMDxEkGReDKuNLKfpdES 0fF3tp1Ed5DSYBD3pOpih5GLaTWklTjQ8g9AYZqbljBoFqTAiL5fV1O+tmYWP82zxLLu RSSFDARowgV85MwwrxTk7d/6tsf/cRkLRbfIEcfpjSFVIRFZRvky0qDIOU9rH9Zev2uF QIEw== X-Gm-Message-State: AOAM532cVFx9YYaJDmpKQAPR0aF0ZgjVSDl3BXaz8AliZ7uRLkt4p+Jt L7eovsECrLexN6vRljWjXfrptSep X-Google-Smtp-Source: ABdhPJwx55sbLWEN4uMoeI3KCTj8L0RKL+t+FueemJV5DUkk0GfbGu+mLdcU5I/R0S987a3Xm1jT1w== X-Received: by 2002:a17:902:8685:: with SMTP id g5mr1015181plo.201.1597264549854; Wed, 12 Aug 2020 13:35:49 -0700 (PDT) Received: from LAPTOPV63503GP (c-76-103-226-229.hsd1.ca.comcast.net. [76.103.226.229]) by smtp.gmail.com with ESMTPSA id f27sm3316142pfk.217.2020.08.12.13.35.48 for <linux-bluetooth@vger.kernel.org> (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Aug 2020 13:35:49 -0700 (PDT) From: "Viktor Filiba" <termic.technology@gmail.com> To: <linux-bluetooth@vger.kernel.org> Subject: Bluez 5.5 stack Date: Wed, 12 Aug 2020 13:35:49 -0700 Message-ID: <022b01d670e8$2ad9aac0$808d0040$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-Index: AdZw6Ci/x+H4NcVWT+CFZzpnXA8OFg== Content-Language: en-us Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.84 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8ACDCA0F5C X-Rspamd-UID: c5878c Does the stack handle automatic acknowledgment of indicate messages? I only see StartNotify() Thank you, Viktor Filiba Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6HcPHetVNF9kFwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 22:49:47 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UE6qG+tVNF/CGgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 22:49:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 45EDAA016A; Wed, 12 Aug 2020 22:49:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbgHLUtk (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 16:49:40 -0400 Received: from mga18.intel.com ([134.134.136.126]:41644 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726282AbgHLUtk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 16:49:40 -0400 IronPort-SDR: HNuIpzlUtEa25JT9khlacIX5t3P67npAtFRizqW+eniKW/KDHcbHXWcbXx2CBJDdw80FGg+8Ln AL5OYfuM5WQg== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="141695141" X-IronPort-AV: E=Sophos;i="5.76,305,1592895600"; d="scan'208";a="141695141" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 13:49:40 -0700 IronPort-SDR: iW19ueYDiZLNg7Max9fMuQFCCJ2zYgzNvte/+Y9RE8ecToYnw7DkHMxu5qBq3Zdr9f0G5NVJCZ ajrsRpqd+BWQ== X-IronPort-AV: E=Sophos;i="5.76,305,1592895600"; d="scan'208";a="276669179" Received: from kwang8-mobl1.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.80.72]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 13:49:39 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [V2 1/3] btp: Update connect event structure Date: Wed, 12 Aug 2020 13:49:30 -0700 Message-Id: <20200812204932.25627-1-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.67 / 15.00 / 200.00 X-Rspamd-Queue-Id: 45EDAA016A X-Rspamd-UID: 14ce68 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch updates the connect event struct to align withe the btp spec. Opcode 0x82 - Device Connected event Controller Index: <controller id> Event parameters: Address_Type (1 octet) Address (6 octets) Connection Interval (2 octets) Connection Latency (2 octets) Supervision Timeout (2 octets) --- src/shared/btp.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/shared/btp.h b/src/shared/btp.h index f0ac3a1ee..cc71a71df 100644 --- a/src/shared/btp.h +++ b/src/shared/btp.h @@ -259,6 +259,9 @@ struct btp_device_found_ev { struct btp_gap_device_connected_ev { uint8_t address_type; bdaddr_t address; + uint16_t connection_interval; + uint16_t connection_latency; + uint16_t supervision_timeout; } __packed; #define BTP_EV_GAP_DEVICE_DISCONNECTED 0x83 -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KKvjB2pWNF+4UwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 22:51:54 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id KOuLBmpWNF8fKAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 22:51:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7B60D4081A; Wed, 12 Aug 2020 22:51:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726531AbgHLUvp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 16:51:45 -0400 Received: from mga18.intel.com ([134.134.136.126]:41644 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726512AbgHLUvp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 16:51:45 -0400 IronPort-SDR: uO3qlspK6siMnCVNV0VNOFshMSbd0fB6Vms2pi3n5TBnZySpcDnj1ZqV93nXcogFJVn5w2gGoc EDmOIihkINqg== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="141695144" X-IronPort-AV: E=Sophos;i="5.76,305,1592895600"; d="scan'208";a="141695144" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 13:49:40 -0700 IronPort-SDR: Xjb17TSMtDuBqd9FDywM25V162xu6ZtfAA0IWEMeuNG8FDNjNsJQ3SvIN3WTyvm6OOIjT3tvqW J++fWkzU0jfQ== X-IronPort-AV: E=Sophos;i="5.76,305,1592895600"; d="scan'208";a="276669182" Received: from kwang8-mobl1.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.80.72]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 13:49:39 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [V2 2/3] tools/btpclientctl: Add btpclient test application Date: Wed, 12 Aug 2020 13:49:31 -0700 Message-Id: <20200812204932.25627-2-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200812204932.25627-1-tedd.an@linux.intel.com> References: <20200812204932.25627-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.93 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7B60D4081A X-Rspamd-UID: df3d6c From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds a test application for btpclient, which exercises the BTP API. --- .gitignore | 1 + Makefile.tools | 7 +- tools/btpclientctl.c | 2151 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2158 insertions(+), 1 deletion(-) create mode 100644 tools/btpclientctl.c diff --git a/.gitignore b/.gitignore index eabdb273f..f4fb5db28 100644 --- a/.gitignore +++ b/.gitignore @@ -120,6 +120,7 @@ tools/btconfig tools/btmgmt tools/btsnoop tools/btpclient +tools/btpclientctl tools/btmon-logger tools/bluetooth-logger.service peripheral/btsensor diff --git a/Makefile.tools b/Makefile.tools index 9b9236609..37db68382 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -492,11 +492,16 @@ test_scripts += test/sap_client.py test/bluezutils.py \ test/test-gatt-profile test/test-mesh test/agent.py if BTPCLIENT -noinst_PROGRAMS += tools/btpclient +noinst_PROGRAMS += tools/btpclient tools/btpclientctl tools_btpclient_SOURCES = tools/btpclient.c src/shared/btp.c src/shared/btp.h tools_btpclient_LDADD = lib/libbluetooth-internal.la \ src/libshared-ell.la $(ell_ldadd) tools_btpclient_DEPENDENCIES = lib/libbluetooth-internal.la $(ell_dependencies) tools/btpclient.$(OBJEXT): src/libshared-ell.la ell/internal + +tools_btpclientctl_SOURCES = tools/btpclientctl.c client/display.c +tools_btpclientctl_LDADD = lib/libbluetooth-internal.la \ + src/libshared-mainloop.la $(GLIB_LIBS) \ + src/libshared-glib.la -lreadline endif diff --git a/tools/btpclientctl.c b/tools/btpclientctl.c new file mode 100644 index 000000000..a9bbb4d01 --- /dev/null +++ b/tools/btpclientctl.c @@ -0,0 +1,2151 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdarg.h> +#include <errno.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/param.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <poll.h> +#include <getopt.h> +#include <stdbool.h> +#include <wordexp.h> +#include <ctype.h> + +#include <glib.h> + +#include "lib/bluetooth.h" + +#include "src/shared/mainloop.h" +#include "src/shared/io.h" +#include "src/shared/util.h" +#include "src/shared/shell.h" +#include "src/shared/btp.h" + +#define DEFAULT_SOCKET_PATH "/tmp/bt-stack-tester" + +#define PROMPT_ON COLOR_BLUE "[btpclient]" COLOR_OFF "# " + +#define EVT_OPCODE_BASE 0x80 + +#define DEFAULT_INDEX 0x00 + +static char *socket_path; +static bool enable_dump; + +struct client_data { + int fd; + + /* Incoming buffer for response and event */ + uint8_t buf[512]; +}; + +struct btpclientctl { + int server_fd; + struct client_data *client_data; + bool debug_enabled; + + /* Outgoing buffer for command */ + uint8_t buf[560]; + uint16_t buf_len; +}; + +struct ad_data { + uint8_t type; + uint8_t len; + uint8_t data[25]; +}; + +struct advertise_data { + int duration; + int ad_data_len; + uint8_t ad_data[256]; + int scan_data_len; + uint8_t scan_data[256]; +}; + +struct indexstr_data { + int index; + const char *str; +}; + +struct bitfield_data { + uint32_t bit; + const char *str; +}; + +struct opcode_data { + uint8_t opcode; + int bit; + const char *str; + + void (*cmd_func)(const void *data, uint16_t size); + uint16_t cmd_size; + bool cmd_fixed; + + void (*rsp_func)(const void *data, uint16_t size); + uint16_t rsp_size; + bool rsp_fixed; + + void (*evt_func)(const void *data, uint16_t size); + uint16_t evt_size; + bool evt_fixed; +}; + +struct service_data { + uint8_t id; + int bit; + const char *str; + const struct opcode_data *opcode_table; +}; + +static struct advertise_data *advertise_data; +static struct btpclientctl *btpclientctl; +static bool client_active; +static uint8_t bt_index = DEFAULT_INDEX; + +static void hexdump_print(const char *str, void *user_data) +{ + bt_shell_printf("%s%s\n", (char *) user_data, str); +} + +static bool parse_argument_on_off(int argc, char *argv[], uint8_t *val) +{ + if (!strcasecmp(argv[1], "on") || !strcasecmp(argv[1], "yes")) + *val = 1; + else if (!strcasecmp(argv[1], "off") || !strcasecmp(argv[1], "no")) + *val = 0; + else + *val = atoi(argv[1]); + return true; +} + +static bool parse_argument_list(int argc, char *argv[], uint8_t *val, + const struct indexstr_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (strcasecmp(argv[1], table[i].str) == 0) { + *val = table[i].index; + return true; + } + } + + bt_shell_printf("Invalid arguement %s\n", argv[1]); + + return false; +} + +static bool parse_argument_bitfield_list(int argc, char *argv[], uint32_t *val, + const struct bitfield_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (strcasecmp(argv[0], table[i].str) == 0) { + *val = table[i].bit; + return true; + } + } + + bt_shell_printf("Invalid argument %s\n", argv[0]); + + return false; +} + +static bool parse_argument_addr(int argc, char *argv[], uint8_t *addr_type, + bdaddr_t *bdaddr) +{ + if (argc < 3) { + bt_shell_printf("Invalid parameter\n"); + return false; + } + + *addr_type = atoi(argv[1]); + str2ba(argv[2], bdaddr); + + return true; +} + +static char *argument_gen(const char *text, int state, + const struct indexstr_data *list) +{ + static int index, len; + const char *arg; + + if (!state) { + index = 0; + len = strlen(text); + } + + while ((arg = list[index].str)) { + index++; + + if (!strncasecmp(arg, text, len)) + return strdup(arg); + } + + return NULL; +} + +static char *argument_gen_bitfield(const char *text, int state, + const struct bitfield_data *list) +{ + static int index, len; + const char *arg; + + if (!state) { + index = 0; + len = strlen(text); + } + + while ((arg = list[index].str)) { + index++; + + if (!strncasecmp(arg, text, len)) + return strdup(arg); + } + + return NULL; +} + +static const struct service_data service_table[]; + +static const struct service_data *find_service_data(uint8_t service_id) +{ + int i; + + for (i = 0; service_table[i].str; i++) { + if (service_table[i].id == service_id) + return &service_table[i]; + } + + return NULL; +} + +static const struct opcode_data *find_opcode_data(uint8_t opcode, + const struct opcode_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (table[i].opcode == opcode) + return &table[i]; + } + + return NULL; +} + +static const char *get_indexstr(int val, const struct indexstr_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (val == table[i].index) + return table[i].str; + } + + return "Unknown"; +} + +static uint32_t print_bitfield(uint32_t val, const struct bitfield_data *table, + const char *prefix) +{ + uint32_t mask = val; + int i; + + for (i = 0; table[i].str; i++) { + if (val & (((uint32_t) 1) << table[i].bit)) { + bt_shell_printf("%s%s (0x%4.4x)\n", prefix, + table[i].str, table[i].bit); + mask &= ~(((uint32_t) 1) << table[i].bit); + } + } + + return mask; +} + +static void print_bdaddr(const bdaddr_t *address, uint8_t address_type) +{ + char addr[18]; + + ba2str(address, addr); + if (address_type == BTP_GAP_ADDR_PUBLIC) + bt_shell_printf("\t%s (public)\n", addr); + else if (address_type == BTP_GAP_ADDR_RANDOM) + bt_shell_printf("\t%s (random)\n", addr); + else + bt_shell_printf("\t%s (unknown)\n", addr); +} + +static void null_cmd(const void *data, uint16_t size) +{ + /* Empty */ +} + +static void null_rsp(const void *data, uint16_t size) +{ + /* Empty */ +} + +static void null_evt(const void *data, uint16_t size) +{ + /* Empty */ +} + +static const struct indexstr_data error_table[] = { + { 0x01, "Faile" }, + { 0x02, "Unknown Command" }, + { 0x03, "Not Ready" }, + { 0x04, "Invalid Index" }, + { } +}; + +static void print_error_rsp(const void *data, uint16_t size) +{ + uint8_t reason = ((uint8_t *)data)[0]; + + bt_shell_printf(COLOR_RED "\tReason: %s (%d)\n" COLOR_OFF, + get_indexstr(reason, error_table), reason); +} + +static const char *service_to_str(uint8_t service_id) +{ + int i; + + for (i = 0; service_table[i].str; i++) { + if (service_table[i].id == service_id) + return service_table[i].str; + } + + return "Unknown Service ID"; +} + +static const char *get_supported_service(int bit) +{ + int i; + + for (i = 0; service_table[i].str; i++) { + if (service_table[i].bit == bit) + return service_table[i].str; + } + + return NULL; +} + +static const char *get_supported_command(const struct opcode_data *table, + int bit) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (table[i].bit == bit) + return table[i].str; + } + return NULL; +} + +static void print_btp_hdr(struct btp_hdr *btp_hdr, const char *type_str, + const char *opcode_str) +{ + bt_shell_printf("%s: %s(%d) %s(0x%02x) INDEX(0x%02x)\n", type_str, + service_to_str(btp_hdr->service), btp_hdr->service, + opcode_str, btp_hdr->opcode, btp_hdr->index); +} + +static const struct opcode_data opcode_table_core[]; + +static void print_core_read_supported_commands_rsp(const void *data, + uint16_t size) +{ + uint8_t cmds; + const char *str; + int i, bit; + + cmds = ((uint8_t *)data)[0]; + + for (i = 1; i < (int)(sizeof(cmds) * 8); i++) { + bit = 0; + bit = 1 << i; + if (cmds & bit) { + str = get_supported_command(opcode_table_core, i); + if (str) + bt_shell_printf("\t%s (Bit %d)\n", str, i); + else + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); + } + } +} + +static void print_core_read_supported_services_rsp(const void *data, + uint16_t size) +{ + uint8_t services; + const char *str; + int i, bit; + + services = ((uint8_t *)data)[0]; + + for (i = 0; i < (int)(sizeof(services) * 8); i++) { + bit = 1 << i; + if (services & bit) { + str = get_supported_service(i); + if (str) + bt_shell_printf("\t%s (Bit %d)\n", str, i); + else + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); + } + } +} + +static void print_core_register_service_cmd(const void *data, uint16_t size) +{ + const struct btp_core_register_cp *cp = data; + + bt_shell_printf("\tService ID: %s(0x%02x)\n", + service_to_str(cp->service_id), cp->service_id); +} + +static void print_core_unregister_service_cmd(const void *data, uint16_t size) +{ + const struct btp_core_unregister_cp *cp = data; + + bt_shell_printf("\tService ID: %s(0x%02x)\n", + service_to_str(cp->service_id), cp->service_id); +} + +static const struct opcode_data opcode_table_core[] = { + { 0x00, 0, "Error", + null_cmd, 0, true, + print_error_rsp, 1, true }, + { 0x01, 1, "Read Supported Commands", + null_cmd, 0, true, + print_core_read_supported_commands_rsp, 1, true }, + { 0x02, 2, "Read Supported Services", + null_cmd, 0, true, + print_core_read_supported_services_rsp, 1, true }, + { 0x03, 3, "Register Service", + print_core_register_service_cmd, 1, true, + null_rsp, 0, true }, + { 0x04, 4, "Unregister Service", + print_core_unregister_service_cmd, 1, true, + null_rsp, 0, true }, + { 0x80, -1, "IUT Ready", + null_cmd, 0, true, + null_rsp, 0, true, + null_evt, 0, true }, + { } +}; + +static const struct opcode_data opcode_table_gap[]; + +static void print_gap_read_supported_commands_rsp(const void *data, + uint16_t size) +{ + uint16_t cmds; + const char *str; + int i; + + cmds = le16_to_cpu(((uint16_t *)data)[0]); + + for (i = 1; i < (int)(sizeof(cmds) * 8); i++) { + if (cmds & (1 << i)) { + str = get_supported_command(opcode_table_gap, i); + if (str) + bt_shell_printf("\t%s (Bit %d)\n", str, i); + else + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); + } + } +} + +static void print_gap_read_controller_index_list_rsp(const void *data, + uint16_t size) +{ + const struct btp_gap_read_index_rp *list = data; + int i; + + for (i = 0; i < list->num; i++) + bt_shell_printf("\tIndex: %d\n", list->indexes[i]); +} + +static const struct bitfield_data gap_setting_table[] = { + { 0, "Powered" }, + { 1, "Connectable" }, + { 2, "Fast Connectable" }, + { 3, "Discoverable" }, + { 4, "Bondable" }, + { 5, "Link Layer Security" }, + { 6, "Secure Simple Pairing" }, + { 7, "BR/EDR" }, + { 8, "High Speed" }, + { 9, "Low Energy" }, + { 10, "Advertising" }, + { 11, "Secure Connection" }, + { 12, "Debug Keys" }, + { 13, "Privacy" }, + { 14, "Controller Configuration" }, + { 15, "Static Address" }, + { } +}; + +static void print_gap_settings(uint32_t val, const struct bitfield_data *table, + const char *prefix) +{ + uint32_t mask; + + mask = print_bitfield(val, table, prefix); + if (mask) + bt_shell_printf("%sUnknown settings (0x%4.4x)\n", prefix, mask); +} + +static void print_gap_read_controller_information_rsp(const void *data, + uint16_t size) +{ + const struct btp_gap_read_info_rp *info = data; + char addr[18]; + + ba2str(&info->address, addr); + bt_shell_printf("\tAddress: %s\n", addr); + bt_shell_printf("\tSupported Settings\n"); + print_gap_settings(le32_to_cpu(info->supported_settings), + gap_setting_table, "\t\t"); + bt_shell_printf("\tCurrent Settings\n"); + print_gap_settings(le32_to_cpu(info->current_settings), + gap_setting_table, "\t\t"); + bt_shell_printf("\tClass: 0x%02x%02x%02x\n", + info->cod[2], info->cod[1], info->cod[0]); + bt_shell_printf("\tShort: %s\n", info->short_name); + bt_shell_printf("\tName: %s\n", info->name); +} + +static void print_gap_reset_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_reset_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static const struct indexstr_data on_off_table[] = { + { 0x00, "Off" }, + { 0x01, "On" }, + { } +}; + +static void print_gap_set_powered_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_powered_cp *cp = data; + + bt_shell_printf("\tSet Power: %s (%d)\n", + get_indexstr(cp->powered, on_off_table), + cp->powered); +} + +static void print_gap_set_powered_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_powered_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_set_connectable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_connectable_cp *cp = data; + + bt_shell_printf("\t Set Connectable: %s (%d)\n", + get_indexstr(cp->connectable, on_off_table), + cp->connectable); +} + +static void print_gap_set_connectable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_connectable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_set_fast_connectable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_fast_connectable_cp *cp = data; + + bt_shell_printf("\t Set Fast Connectable: %s (%d)\n", + get_indexstr(cp->fast_connectable, on_off_table), + cp->fast_connectable); +} + +static void print_gap_set_fast_connectable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_fast_connectable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static const struct indexstr_data gap_discoverable_table[] = { + { 0x00, "Off" }, + { 0x01, "On" }, + { 0x02, "Limited" }, + { } +}; + +static void print_gap_set_discoverable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_discoverable_cp *cp = data; + + bt_shell_printf("\t Set Discoverable: %s (%d)\n", + get_indexstr(cp->discoverable, gap_discoverable_table), + cp->discoverable); +} + +static void print_gap_set_discoverable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_discoverable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_set_bondable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_bondable_cp *cp = data; + + bt_shell_printf("\t Set Bondable: %s (%d)\n", + get_indexstr(cp->bondable, on_off_table), + cp->bondable); +} + +static void print_gap_set_bondable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_bondable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_adv_data(const uint8_t *data, uint8_t len, const char *prefix) +{ + struct ad_data *ad; + const uint8_t *ptr = data; + int count = len; + char str[96]; + int i, j; + + while (count > 0) { + ad = (struct ad_data *)ptr; + + bt_shell_printf("%sData:\n", prefix); + bt_shell_printf("%s\tType: 0x%02x (%d)\n", prefix, ad->type, + ad->len); + count -= 2; + + for (i = 0, j = 0; i < ad->len; i++) { + j += sprintf(str + j, "%02x ", ad->data[i]); + if ((i % 16) == 15) { + str[j] = '\0'; + bt_shell_printf("%s\t%s\n", prefix, str); + j = 0; + } + } + str[j] = '\0'; + bt_shell_printf("%s\t%s\n", prefix, str); + + count -= ad->len; + } +} + +static void print_gap_start_advertising_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_start_adv_cp *cp = data; + + if (cp->adv_data_len) { + bt_shell_printf("\tAdvertising Data:\n"); + print_adv_data(cp->data, cp->adv_data_len, "\t\t"); + } + + if (cp->scan_rsp_len) { + bt_shell_printf("\tScan Response Data:\n"); + print_adv_data(cp->data + cp->adv_data_len, cp->scan_rsp_len, + "\t\t"); + } +} + +static void print_gap_start_advertising_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_start_adv_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_stop_advertising_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_start_adv_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static const struct bitfield_data gap_discovery_flags_table[] = { + { 0, "LE" }, + { 1, "BREDE" }, + { 2, "Limited" }, + { 3, "Active" }, + { 4, "Observation" }, + { } +}; + +static void print_gap_start_discovery_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_start_discovery_cp *cp = data; + uint32_t mask; + + mask = print_bitfield(le32_to_cpu(cp->flags), + gap_discovery_flags_table, "\t\t"); + if (mask) + bt_shell_printf("\t\tUnknown flags (0x%4.4x)\n", mask); +} + +static void print_gap_connect_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_connect_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static void print_gap_disconnect_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_disconnect_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static const struct indexstr_data gap_io_capa_table[] = { + { 0x00, "DisplayOnly" }, + { 0x01, "DisplayYesNo" }, + { 0x02, "KeyboardOnly" }, + { 0x03, "NoInputOutput" }, + { 0x04, "KeyboardDisplay" }, + { } +}; + +static void print_gap_set_io_capa_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_io_capa_cp *cp = data; + + bt_shell_printf("\tIO Capa: %s (%d)\n", + get_indexstr(cp->capa, gap_io_capa_table), cp->capa); +} + +static void print_gap_pair_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_pair_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static void print_gap_unpair_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_unpair_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static void print_gap_passkey_entry_response_cmd(const void *data, + uint16_t size) +{ + const struct btp_gap_passkey_entry_rsp_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(cp->passkey)); +} + +static void print_gap_passkey_confirmation_response_cmd(const void *data, + uint16_t size) +{ + const struct btp_gap_passkey_confirm_rsp_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); + bt_shell_printf("\tMatch: %d\n", cp->match); +} + +static void print_gap_new_settings_evt(const void *data, uint16_t size) +{ + const struct btp_new_settings_ev *ev = data; + + print_gap_settings(le32_to_cpu(ev->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_eir(const uint8_t *eir, uint16_t eir_len, + const char *prefix) +{ + char str[64]; + int i, n; + + if (eir_len == 0) { + bt_shell_printf("%sEIR Data: Empty\n", prefix); + return; + } + + bt_shell_printf("%sEIR Data:\n", prefix); + for (i = 0, n = 0; i < eir_len; i++) { + n += sprintf(str + n, "%02x ", eir[i]); + if ((i % 16) == 15) { + str[n] = '\0'; + bt_shell_printf("\t%s%s\n", prefix, str); + n = 0; + } + } +} + +static const struct bitfield_data gap_device_found_flags_table[] = { + { 0, "RSSI Valid" }, + { 1, "Adv_Data Included" }, + { 2, "Scan_Rsp Included" }, + { } +}; + +static void print_gap_device_found_evt(const void *data, uint16_t size) +{ + const struct btp_device_found_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tRSSI: %d\n", ev->rssi); + bt_shell_printf("\tFlags:\n"); + print_bitfield(ev->flags, gap_device_found_flags_table, "\t\t"); + print_gap_eir(ev->eir, ev->eir_len, "\t"); +} + +static void print_gap_device_connected_evt(const void *data, uint16_t size) +{ + const struct btp_gap_device_connected_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); +} + +static void print_gap_device_disconnected_evt(const void *data, uint16_t size) +{ + const struct btp_gap_device_disconnected_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); +} + +static void print_gap_passkey_display_evt(const void *data, uint16_t size) +{ + const struct btp_gap_passkey_display_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(ev->passkey)); +} + +static void print_gap_passkey_enter_request_evt(const void *data, uint16_t size) +{ + const struct btp_gap_passkey_req_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); +} + +static void print_gap_passkey_confirm_request_evt(const void *data, + uint16_t size) +{ + const struct btp_gap_passkey_confirm_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(ev->passkey)); +} + +static void print_gap_identity_resolved_evt(const void *data, uint16_t size) +{ + const struct btp_gap_identity_resolved_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tIdentity: "); + print_bdaddr(&ev->identity_address, ev->identity_address_type); +} + + +static const struct opcode_data opcode_table_gap[] = { + { 0x00, 0, "Error", + null_cmd, 0, true, + print_error_rsp, 1, true }, + { 0x01, 1, "Read Supported Commands", + null_cmd, 0, true, + print_gap_read_supported_commands_rsp, 2, true }, + { 0x02, 2, "Read Controller Index List", + null_cmd, 0, true, + print_gap_read_controller_index_list_rsp, 2, false }, + { 0x03, 3, "Read Controller Information", + null_cmd, 0, true, + print_gap_read_controller_information_rsp, 277, true }, + { 0x04, 4, "Reset", + null_cmd, 0, true, + print_gap_reset_rsp, 4, true }, + { 0x05, 5, "Set Powered", + print_gap_set_powered_cmd, 1, true, + print_gap_set_powered_rsp, 4, true }, + { 0x06, 6, "Set Connectable", + print_gap_set_connectable_cmd, 1, true, + print_gap_set_connectable_rsp, 4, true }, + { 0x07, 7, "Set Fast Connectable", + print_gap_set_fast_connectable_cmd, 1, true, + print_gap_set_fast_connectable_rsp, 4, true }, + { 0x08, 8, "Set Discoverable", + print_gap_set_discoverable_cmd, 1, true, + print_gap_set_discoverable_rsp, 4, true }, + { 0x09, 9, "Set Bondable", + print_gap_set_bondable_cmd, 1, true, + print_gap_set_bondable_rsp, 4, true }, + { 0x0a, 10, "Starting Advertising", + print_gap_start_advertising_cmd, 2, false, + print_gap_start_advertising_rsp, 4, true }, + { 0x0b, 11, "Stop Advertising", + null_cmd, 0, true, + print_gap_stop_advertising_rsp, 4, true }, + { 0x0c, 12, "Start Discovery", + print_gap_start_discovery_cmd, 1, true, + null_rsp, 0, true }, + { 0x0d, 13, "Stop Discovery", + null_cmd, 0, true, + null_rsp, 0, true }, + { 0x0e, 14, "Connect", + print_gap_connect_cmd, 7, true, + null_rsp, 0, true }, + { 0x0f, 15, "Disconnect", + print_gap_disconnect_cmd, 7, true, + null_rsp, 0, true }, + { 0x10, 16, "Set I/O Capability", + print_gap_set_io_capa_cmd, 1, true, + null_rsp, 0, true }, + { 0x11, 17, "Pair", + print_gap_pair_cmd, 7, true, + null_rsp, 0, true }, + { 0x12, 18, "Unpair", + print_gap_unpair_cmd, 7, true, + null_rsp, 0, true }, + { 0x13, 19, "Passkey Entry Response", + print_gap_passkey_entry_response_cmd, 11, true, + null_rsp, 0, true }, + { 0x14, 20, "Passkey Confirmation Response", + print_gap_passkey_confirmation_response_cmd, 8, true, + null_rsp, 0, true }, + { 0x80, -1, "New Settings", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_new_settings_evt, 4, true }, + { 0x81, -1, "Device Found", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_device_found_evt, 11, false }, + { 0x82, -1, "Device Connected", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_device_connected_evt, 7, true }, + { 0x83, -1, "Device Disconnected", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_device_disconnected_evt, 7, true }, + { 0x84, -1, "Passkey Display", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_passkey_display_evt, 11, true }, + { 0x85, -1, "Passkey Entry Request", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_passkey_enter_request_evt, 7, true }, + { 0x86, -1, "Passkey Confirm Request", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_passkey_confirm_request_evt, 11, true }, + { 0x87, -1, "Identity Resolved", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_identity_resolved_evt, 14, true }, + { } +}; + +static const struct service_data service_table[] = { + { 0x00, 0, "Core", opcode_table_core}, + { 0x01, 1, "GAP", opcode_table_gap}, + { } +}; + +static bool write_packet(int fd, const void *data, size_t size) +{ + while (size > 0) { + ssize_t written; + + written = write(fd, data, size); + if (written < 0) { + if (errno == EAGAIN || errno == EINTR) + continue; + return false; + } + + if (enable_dump) + util_hexdump('<', data, written, hexdump_print, + "OUT: "); + + data += written; + size -= written; + } + + return true; +} + +static void btp_print_cmd(struct btp_hdr *btp_hdr, void *data) +{ + const struct service_data *table; + const struct opcode_data *opcode_data; + + table = find_service_data(btp_hdr->service); + if (!table) { + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); + return; + } + + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); + if (!opcode_data) { + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); + return; + } + + print_btp_hdr(btp_hdr, "CMD", opcode_data->str); + + if (opcode_data->cmd_fixed) { + if (btp_hdr->data_len != opcode_data->cmd_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } else { + if (btp_hdr->data_len < opcode_data->cmd_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } + + opcode_data->cmd_func(data, btp_hdr->data_len); +} + +static void btp_print_rsp(struct btp_hdr *btp_hdr, void *data) +{ + const struct service_data *table; + const struct opcode_data *opcode_data; + + table = find_service_data(btp_hdr->service); + if (!table) { + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); + return; + } + + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); + if (!opcode_data) { + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); + return; + } + + print_btp_hdr(btp_hdr, "RSP", opcode_data->str); + + if (opcode_data->rsp_fixed) { + if (btp_hdr->data_len != opcode_data->rsp_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } else { + if (btp_hdr->data_len < opcode_data->rsp_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } + + opcode_data->rsp_func(data, btp_hdr->data_len); +} + +static void btp_print_evt(struct btp_hdr *btp_hdr, void *data) +{ + const struct service_data *table; + const struct opcode_data *opcode_data; + + table = find_service_data(btp_hdr->service); + if (!table) { + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); + return; + } + + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); + if (!opcode_data) { + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); + return; + } + + print_btp_hdr(btp_hdr, "EVT", opcode_data->str); + + if (opcode_data->evt_fixed) { + if (btp_hdr->data_len != opcode_data->evt_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } else { + if (btp_hdr->data_len < opcode_data->evt_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } + + opcode_data->evt_func(data, btp_hdr->data_len); +} + +static bool send_cmd(uint8_t service_id, uint8_t opcode, uint8_t index, + uint16_t data_len, void *data) +{ + struct btp_hdr *hdr; + int client_fd; + + if (!client_active) { + bt_shell_printf("ERROR: Client is not active\n"); + return false; + } + + hdr = (struct btp_hdr *)(btpclientctl->buf); + + hdr->service = service_id; + hdr->opcode = opcode; + hdr->index = index; + hdr->data_len = cpu_to_le16(data_len); + if (data) + memcpy(hdr->data, data, data_len); + + btpclientctl->buf_len = sizeof(*hdr) + data_len; + + client_fd = btpclientctl->client_data->fd; + + btp_print_cmd(hdr, data_len ? hdr->data : NULL); + + if (!write_packet(client_fd, btpclientctl->buf, + btpclientctl->buf_len)) { + fprintf(stderr, "Failed to send command to client\n"); + mainloop_remove_fd(client_fd); + return false; + } + + return true; +} + +static void client_read_destroy(void *user_data) +{ + struct client_data *client_data = user_data; + + close(client_data->fd); + free(client_data); + + client_active = false; + + bt_shell_printf("Client is disconnected\n"); +} + +static void client_read_callback(int fd, uint32_t events, void *user_data) +{ + struct client_data *client_data = user_data; + struct btp_hdr *btp_hdr; + uint8_t *data, *ptr; + ssize_t len, pkt_len; + + if (events & (EPOLLERR | EPOLLHUP)) { + fprintf(stderr, "Error from client connection\n"); + mainloop_remove_fd(client_data->fd); + return; + } + + if (events & EPOLLRDHUP) { + fprintf(stderr, "Remote hangeup of cliient connection\n"); + mainloop_remove_fd(client_data->fd); + return; + } + + /* Read incoming packet */ + len = read(client_data->fd, client_data->buf, sizeof(client_data->buf)); + if (len < 0) { + if (errno == EAGAIN || errno == EINTR) + return; + + fprintf(stderr, "Read from client descriptor failed\n"); + mainloop_remove_fd(client_data->fd); + return; + } + + if (len < (ssize_t)sizeof(struct btp_hdr) - 1) + return; + + ptr = client_data->buf; + + while (len) { + btp_hdr = (struct btp_hdr *)ptr; + + pkt_len = sizeof(*btp_hdr) + btp_hdr->data_len; + + if (enable_dump) + util_hexdump('>', ptr, pkt_len, hexdump_print, "IN : "); + + if (btp_hdr->data_len) + data = btp_hdr->data; + else + data = NULL; + + if (btp_hdr->opcode < EVT_OPCODE_BASE) + btp_print_rsp(btp_hdr, data); + else + btp_print_evt(btp_hdr, data); + + ptr += pkt_len; + len -= pkt_len; + } +} + +static struct client_data *setup_client(int client_fd) +{ + struct client_data *client_data; + + client_data = new0(struct client_data, 1); + if (!client_data) + return NULL; + + client_data->fd = client_fd; + + mainloop_add_fd(client_data->fd, EPOLLIN | EPOLLRDHUP, + client_read_callback, client_data, client_read_destroy); + + return client_data; +} + +static void server_callback(int fd, uint32_t events, void *user_data) +{ + union { + struct sockaddr common; + struct sockaddr_un sun; + struct sockaddr_in sin; + } addr; + socklen_t len; + int client_fd; + struct client_data *client_data; + struct btpclientctl *btpclientctl = user_data; + + if (events & (EPOLLERR | EPOLLHUP)) { + mainloop_quit(); + return; + } + + memset(&addr, 0, sizeof(addr)); + len = sizeof(addr); + + if (getsockname(fd, &addr.common, &len) < 0) { + perror("Failed to get socket name"); + return; + } + + client_fd = accept(fd, &addr.common, &len); + if (client_fd < 0) { + perror("Failed to accept client socket"); + return; + } + + bt_shell_printf("Client is connected\n"); + + /* Setup Client */ + client_data = setup_client(client_fd); + if (!client_data) { + fprintf(stderr, "Failed to setup client\n"); + close(client_fd); + return; + } + + btpclientctl->client_data = client_data; + client_active = true; +} + +static int open_socket(const char *path) +{ + struct sockaddr_un addr; + size_t len; + int fd; + + len = strlen(path); + if (len > sizeof(addr.sun_path) - 1) { + fprintf(stderr, "Socket path is too long\n"); + return -1; + } + + unlink(path); + + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (fd < 0) { + perror("Failed to open Unix server socket"); + return -1; + } + + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); + + if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + perror("Failed to bind Unix server socket"); + goto error_close; + } + + if (listen(fd, 1) < 0) { + perror("Failed to listen Unix server socket"); + goto error_close; + } + + bt_shell_printf("Waiting for client connection...\n"); + + if (chmod(path, 0666) < 0) { + perror("Failed to change Unix socket file mode"); + goto error_close; + } + + return fd; + +error_close: + close(fd); + return -1; +} + +static void cmd_ad_show(int argc, char **argv) +{ + bt_shell_printf("AD: Saved Advertise/Scan data\n"); + + if (!advertise_data) { + bt_shell_printf("\tError: Not initialized\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (advertise_data->ad_data_len) { + bt_shell_printf("\tAD Data:\n"); + print_adv_data(advertise_data->ad_data, + advertise_data->ad_data_len, "\t\t"); + } + + if (advertise_data->scan_data_len) { + bt_shell_printf("\tScan Data:\n"); + print_adv_data(advertise_data->scan_data, + advertise_data->scan_data_len, "\t\t"); + } + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static bool ad_add_data(struct ad_data *ad_data, int argc, char *argv[]) +{ + char *endptr = NULL; + int i; + long val; + + /* Type */ + val = strtol(argv[0], &endptr, 0); + if (!endptr || *endptr != '\0' || val > UINT8_MAX) { + bt_shell_printf("Error: Invalid Type\n"); + return false; + } + ad_data->type = val; + + for (i = 1; i < argc; i++) { + endptr = NULL; + + val = strtol(argv[i], &endptr, 0); + if (!endptr || *endptr != '\0' || val > UINT8_MAX) { + bt_shell_printf("Error: Invalid data at %d\n", i); + return false; + } + + ad_data->data[ad_data->len] = val; + ad_data->len++; + } + + return true; +} + +static void cmd_ad_add_ad(int argc, char **argv) +{ + struct ad_data ad_data; + uint8_t *ptr; + + bt_shell_printf("AD: Save Advertise data\n"); + + if (!advertise_data) { + bt_shell_printf("\tError: Not initialized\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (argc < 2) { + bt_shell_printf("\tInvalid Parameter Number\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + memset(&ad_data, 0, sizeof(ad_data)); + + if (!ad_add_data(&ad_data, argc - 1, argv + 1)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + ptr = advertise_data->ad_data + advertise_data->ad_data_len; + memcpy(ptr, &ad_data, ad_data.len + 2); + advertise_data->ad_data_len += ad_data.len + 2; + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_ad_add_scan(int argc, char **argv) +{ + struct ad_data ad_data; + uint8_t *ptr; + + bt_shell_printf("AD: Save Scan data\n"); + + if (!advertise_data) { + bt_shell_printf("\tError: Not initialized\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (argc < 2) { + bt_shell_printf("\tInvalid Parameter Number\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!ad_add_data(&ad_data, argc - 1, argv + 1)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + ptr = advertise_data->scan_data + advertise_data->scan_data_len; + memcpy(ptr, &ad_data, ad_data.len + 2); + advertise_data->scan_data_len += ad_data.len + 2; + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_ad_duration(int argc, char **argv) +{ + uint32_t val; + + bt_shell_printf("AD: Set Advertising Duration\n"); + + if (!advertise_data) { + bt_shell_printf("\tError: Not initialized\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (argc > 2) { + bt_shell_printf("\tInvalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + /* No parameter */ + if (argc == 1) { + bt_shell_printf("\tDuration: %d\n", advertise_data->duration); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + val = (uint32_t)atoi(argv[1]); + + if (val == 0) + val = UINT32_MAX; + + advertise_data->duration = val; + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_ad_clear(int argc, char **argv) +{ + bt_shell_printf("AD: Clear Advertise/Scan data\n"); + + if (!advertise_data) { + bt_shell_printf("\tError: Not initialized\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + advertise_data->ad_data_len = 0; + advertise_data->scan_data_len = 0; + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_core_read_cmds(int argc, char **argv) +{ + bt_shell_printf("Core: Read Supported Commands\n"); + + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_READ_SUPPORTED_COMMANDS, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_core_read_services(int argc, char **argv) +{ + bt_shell_printf("Core: Read Supported Services\n"); + + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_READ_SUPPORTED_SERVICES, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_core_register_service(int argc, char **argv) +{ + uint8_t service_id; + + bt_shell_printf("Core: Register Service\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + service_id = atoi(argv[1]); + if (service_id == 0) { + bt_shell_printf("CORE service is already registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_REGISTER, + BTP_INDEX_NON_CONTROLLER, 1, &service_id)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_core_unregister_service(int argc, char **argv) +{ + uint8_t service_id; + + bt_shell_printf("Core: Unregister Service\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + service_id = atoi(argv[1]); + if (service_id == 0) { + bt_shell_printf("Cannot unregister CORE service\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_UNREGISTER, + BTP_INDEX_NON_CONTROLLER, 1, &service_id)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_set_index(int argc, char **argv) +{ + uint8_t index; + + bt_shell_printf("Set Default Controller Index\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + index = atoi(argv[1]); + if (index == bt_index) { + bt_shell_printf("Controller index is already set\n"); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + bt_index = index; + bt_shell_printf("Controller index is updated to 0x%02x\n", bt_index); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_read_cmds(int argc, char **argv) +{ + bt_shell_printf("GAP: Read Supported Commands\n"); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_SUPPORTED_COMMANDS, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_read_index(int argc, char **argv) +{ + bt_shell_printf("GAP: Read Controller Index List\n"); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_CONTROLLER_INDEX_LIST, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_read_info(int argc, char **argv) +{ + uint8_t index; + + bt_shell_printf("GAP: Read Controller Information\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + index = atoi(argv[1]); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_COTROLLER_INFO, + index, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_reset(int argc, char **argv) +{ + bt_shell_printf("GAP: Reset\n"); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_RESET, bt_index, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_on_off_gen(const char *text, int state) +{ + return argument_gen(text, state, on_off_table); +} + +static void cmd_gap_power(int argc, char **argv) +{ + struct btp_gap_set_powered_cp cp; + + bt_shell_printf("GAP: Set Power\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_on_off(argc, argv, &cp.powered)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_POWERED, bt_index, + sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_connectable(int argc, char **argv) +{ + struct btp_gap_set_connectable_cp cp; + + bt_shell_printf("GAP: Set Connectable\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_on_off(argc, argv, &cp.connectable)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_CONNECTABLE, bt_index, + sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_fast_connectable(int argc, char **argv) +{ + struct btp_gap_set_fast_connectable_cp cp; + + bt_shell_printf("GAP: Set Fast Connectable\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_on_off(argc, argv, &cp.fast_connectable)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_FAST_CONNECTABLE, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_discoverable_gen(const char *text, int state) +{ + return argument_gen(text, state, gap_discoverable_table); +} + +static void cmd_gap_discoverable(int argc, char **argv) +{ + struct btp_gap_set_discoverable_cp cp; + + bt_shell_printf("GAP: Set Discoverable\n"); + + memset(&cp, 0, sizeof(cp)); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_list(argc, argv, &cp.discoverable, + gap_discoverable_table)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_DISCOVERABLE, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_bondable(int argc, char **argv) +{ + struct btp_gap_set_bondable_cp cp; + + bt_shell_printf("GAP: Set Bondable\n"); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_on_off(argc, argv, &cp.bondable)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_BONDABLE, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_start_adv(int argc, char **argv) +{ + struct btp_gap_start_adv_cp *cp; + int total; + + bt_shell_printf("GAP: Start Advertising\n"); + + /* Check if AD data is availabel */ + if (advertise_data->ad_data_len == 0 && + advertise_data->scan_data_len == 0) { + bt_shell_printf("ERROR: No Advertise or Scan data available\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + /* Allocate the maximum size */ + cp = (struct btp_gap_start_adv_cp *)malloc(520); + + memset(cp, 0, 520); + total = 2; + + if (advertise_data->ad_data_len) { + memcpy(cp->data, advertise_data->ad_data, + advertise_data->ad_data_len); + cp->adv_data_len = advertise_data->ad_data_len; + } else + cp->adv_data_len = 0; + + total += cp->adv_data_len; + + if (advertise_data->scan_data_len) { + memcpy(cp->data + cp->adv_data_len, advertise_data->scan_data, + advertise_data->scan_data_len); + cp->scan_rsp_len = advertise_data->scan_data_len; + } else + cp->scan_rsp_len = 0; + + total += cp->scan_rsp_len; + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_START_ADVERTISING, + bt_index, total, cp)) { + free(cp); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + free(cp); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_stop_adv(int argc, char **argv) +{ + bt_shell_printf("GAP: Stop Advertising\n"); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_STOP_ADVERTISING, + bt_index, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_start_disc_gen(const char *text, int state) +{ + return argument_gen_bitfield(text, state, gap_discovery_flags_table); +} + +static void cmd_gap_start_disc(int argc, char **argv) +{ + struct btp_gap_start_discovery_cp cp; + int i; + uint32_t f; + + bt_shell_printf("GAP: Start Discovery\n"); + + if (argc < 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + memset(&cp, 0, sizeof(cp)); + + for (i = 1; i < argc; i++) { + if (!parse_argument_bitfield_list(argc - i, &argv[i], &f, + gap_discovery_flags_table)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + cp.flags |= (1 << f); + } + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_START_DISCOVERY, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_stop_disc(int argc, char **argv) +{ + bt_shell_printf("GAP: Stop Discovery\n"); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_STOP_DISCOVERY, bt_index, + 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_connect(int argc, char **argv) +{ + struct btp_gap_connect_cp cp; + + bt_shell_printf("GAP: Connect\n"); + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_CONNECT, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_disconnect(int argc, char **argv) +{ + struct btp_gap_disconnect_cp cp; + + bt_shell_printf("GAP: Disconnect\n"); + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_DISCONNECT, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_io_capa_gen(const char *text, int state) +{ + return argument_gen(text, state, gap_io_capa_table); +} + +static void cmd_gap_set_io_capa(int argc, char **argv) +{ + struct btp_gap_set_io_capa_cp cp; + + bt_shell_printf("GAP: Get IO Capability\n"); + + memset(&cp, 0, sizeof(cp)); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_list(argc, argv, &cp.capa, gap_io_capa_table)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_IO_CAPA, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_pair(int argc, char **argv) +{ + struct btp_gap_pair_cp cp; + + bt_shell_printf("GAP: Pair\n"); + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_PAIR, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_unpair(int argc, char **argv) +{ + struct btp_gap_unpair_cp cp; + + bt_shell_printf("GAP: Unpair\n"); + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_UNPAIR, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static const struct bt_shell_menu ad_menu = { + .name = "ad", + .desc = "Manage Advertise DataSubmenu", + .entries = { + { "show", NULL, + cmd_ad_show, "Show current saved AD/Scan data" }, + { "add-ad", "<type> <data=xx xx ...>", + cmd_ad_add_ad, "Save AD data" }, + { "add-scan", "<type> <data=xx xx ...>", + cmd_ad_add_scan, "Save Scan data" }, + { "duration", "<duration>", + cmd_ad_duration, "Set duration" }, + { "clear", "<all/ad/scan/duration>", + cmd_ad_clear, "Clear saved AD/Scan/duration data" }, + { } }, +}; + +static const struct bt_shell_menu gap_menu = { + .name = "gap", + .desc = "GAP API Submenu", + .entries = { + { "read-cmds", NULL, + cmd_gap_read_cmds, "Show supported commands" }, + { "list", NULL, + cmd_gap_read_index, "Show index of controllers" }, + { "read-info", "<index>", + cmd_gap_read_info, "Read controller information" }, + { "reset", NULL, + cmd_gap_reset, "Reset controller and stack" }, + { "power", "<on/off>", + cmd_gap_power, "Set controller power", + gap_on_off_gen }, + { "connectable", "<on/off>", + cmd_gap_connectable, "Set controller connectable", + gap_on_off_gen }, + { "fast-connectable", "<on/off>", + cmd_gap_fast_connectable, "Set controller fast connectable", + gap_on_off_gen }, + { "discoverable", "<on/off/limited>", + cmd_gap_discoverable, "Set controller discoverable", + gap_discoverable_gen }, + { "bondable", "<on/off>", + cmd_gap_bondable, "Set controller bondable", + gap_on_off_gen }, + { "start-adv", NULL, + cmd_gap_start_adv, "Start Advertising" }, + { "stop-adv", NULL, + cmd_gap_stop_adv, "Stop Advertising" }, + { "start-disc", "<flags...>", + cmd_gap_start_disc, "Start discovery", + gap_start_disc_gen }, + { "stop-disc", NULL, + cmd_gap_stop_disc, "Stop discovery" }, + { "connect", "<type> <bdaddr>", + cmd_gap_connect, "Connect" }, + { "disconnect", "<type> <bdaddr>", + cmd_gap_disconnect, "Disconnect" }, + { "set-capa", "<io capability>", + cmd_gap_set_io_capa, "Set IO capability", + gap_io_capa_gen }, + { "pair", "<type> <bdaddr>", + cmd_gap_pair, "Pair" }, + { "unpair", "<type> <bdaddr>", + cmd_gap_unpair, "Unpair" }, + { } }, +}; + +static const struct bt_shell_menu main_menu = { + .name = "main", + .entries = { + { "read-cmds", NULL, + cmd_core_read_cmds, "Read supported commands" }, + { "read-services", NULL, + cmd_core_read_services, "Read supported services" }, + { "register", "<service id>", + cmd_core_register_service, "Register service" }, + { "unregister", "<service id>", + cmd_core_unregister_service, "Unregister service" }, + { "index", "<index>", + cmd_set_index, "Set controller index. Default is 0" }, + { } }, +}; + +static const struct option main_options[] = { + { "socket", required_argument, 0, 's' }, + { "dump ", required_argument, 0, 'd' }, + { 0, 0, 0, 0 } +}; + +static const char *socket_path_option; +static const char *dump_option; + +static const char **optargs[] = { + &socket_path_option, + &dump_option, +}; + +static const char *help[] = { + "Socket path to listen for BTP client\n", + "Use \"on\" to enable hex dump\n", +}; + +static const struct bt_shell_opt opt = { + .options = main_options, + .optno = sizeof(main_options) / sizeof(struct option), + .optstr = "s:d:", + .optarg = optargs, + .help = help, +}; + +int main(int argc, char *argv[]) +{ + int status; + int server_fd; + + bt_shell_init(argc, argv, &opt); + bt_shell_set_menu(&main_menu); + bt_shell_add_submenu(&ad_menu); + bt_shell_add_submenu(&gap_menu); + + if (socket_path_option) + socket_path = g_strdup(socket_path_option); + else + socket_path = g_strdup(DEFAULT_SOCKET_PATH); + + if (dump_option && !strcasecmp(dump_option, "on")) + enable_dump = true; + else + enable_dump = false; + + + btpclientctl = new0(struct btpclientctl, 1); + if (!btpclientctl) { + status = EXIT_FAILURE; + goto error_exit; + } + + advertise_data = new0(struct advertise_data, 1); + if (!advertise_data) { + status = EXIT_FAILURE; + goto error_free_client; + } + + advertise_data->ad_data_len = 0; + advertise_data->scan_data_len = 0; + + bt_shell_attach(fileno(stdin)); + + server_fd = open_socket(socket_path); + if (server_fd < 0) { + status = EXIT_FAILURE; + goto error_free_ad; + } + + btpclientctl->server_fd = server_fd; + + mainloop_add_fd(btpclientctl->server_fd, EPOLLIN, server_callback, + btpclientctl, NULL); + + bt_shell_set_prompt(PROMPT_ON); + + status = bt_shell_run(); + + close(btpclientctl->server_fd); + +error_free_ad: + free(advertise_data); +error_free_client: + free(btpclientctl); +error_exit: + g_free(socket_path); + return status; +} -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qIArM25WNF+4UwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 22:51:58 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id qDoTMm5WNF+6uQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 22:51:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3D9C640813; Wed, 12 Aug 2020 22:51:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726573AbgHLUvq (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 16:51:46 -0400 Received: from mga18.intel.com ([134.134.136.126]:41644 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726528AbgHLUvq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 16:51:46 -0400 IronPort-SDR: 8Q+Y9XsAUqvFzoC4mJqmKxedXRozZLCtUYawixh041+J+57d33ptGTW5VW9ZZ1Pex4qLw8+7Lk Qrbs593Mm3Dg== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="141695146" X-IronPort-AV: E=Sophos;i="5.76,305,1592895600"; d="scan'208";a="141695146" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 13:49:40 -0700 IronPort-SDR: 3f70OIRZdGrryAUlQ+ctiXfVAnZ4MvLplQClcoh2VXac5sbcYq8pYredHR2PupNxK2UV5VxBnZ 8up6u98H81uA== X-IronPort-AV: E=Sophos;i="5.76,305,1592895600"; d="scan'208";a="276669184" Received: from kwang8-mobl1.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.80.72]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 13:49:40 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [V2 3/3] btpclient: Fix gap reset not sending response Date: Wed, 12 Aug 2020 13:49:32 -0700 Message-Id: <20200812204932.25627-3-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200812204932.25627-1-tedd.an@linux.intel.com> References: <20200812204932.25627-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.93 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3D9C640813 X-Rspamd-UID: be6e4a From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch fixes the GAP reset command to response the default settings after resetting the stack. --- tools/btpclient.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tools/btpclient.c b/tools/btpclient.c index f9c693056..38e326670 100644 --- a/tools/btpclient.c +++ b/tools/btpclient.c @@ -521,6 +521,19 @@ static void reset_unreg_agent_reply(struct l_dbus_proxy *proxy, ag.registered = false; } +static void update_current_settings(struct btp_adapter *adapter, + uint32_t new_settings) +{ + struct btp_new_settings_ev ev; + + adapter->current_settings = new_settings; + + ev.current_settings = L_CPU_TO_LE32(adapter->current_settings); + + btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_NEW_SETTINGS, adapter->index, + sizeof(ev), &ev); +} + static void btp_gap_reset(uint8_t index, const void *param, uint16_t length, void *user_data) { @@ -528,6 +541,7 @@ static void btp_gap_reset(uint8_t index, const void *param, uint16_t length, const struct l_queue_entry *entry; uint8_t status; bool prop; + uint32_t default_settings; if (!adapter) { status = BTP_ERROR_INVALID_INDEX; @@ -570,10 +584,13 @@ static void btp_gap_reset(uint8_t index, const void *param, uint16_t length, goto failed; } - adapter->current_settings = adapter->default_settings; + default_settings = adapter->default_settings; + + update_current_settings(adapter, default_settings); /* TODO for we assume all went well */ - btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_RESET, index, 0, NULL); + btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_RESET, index, + sizeof(default_settings), &default_settings); return; failed: @@ -644,19 +661,6 @@ failed: btp_send_error(btp, BTP_GAP_SERVICE, index, status); } -static void update_current_settings(struct btp_adapter *adapter, - uint32_t new_settings) -{ - struct btp_new_settings_ev ev; - - adapter->current_settings = new_settings; - - ev.current_settings = L_CPU_TO_LE32(adapter->current_settings); - - btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_NEW_SETTINGS, adapter->index, - sizeof(ev), &ev); -} - static void btp_gap_set_connectable(uint8_t index, const void *param, uint16_t length, void *user_data) { -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CCoEOCFeNF+5UwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 12 Aug 2020 23:24:49 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id IAN+NiFeNF8dqwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 12 Aug 2020 23:24:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 862E2A03FD; Wed, 12 Aug 2020 23:24:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726490AbgHLVYn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 17:24:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725934AbgHLVYn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 17:24:43 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFC62C061383 for <linux-bluetooth@vger.kernel.org>; Wed, 12 Aug 2020 14:24:42 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id b14so3465205qkn.4 for <linux-bluetooth@vger.kernel.org>; Wed, 12 Aug 2020 14:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=oSv9lNjLIcC+dSOR04T0KHy3KMdDW83IZKCS+JX1+YQ=; b=GSH3b4FsClaIQFZjp5TZkpSdI0sWWok33kV84CPaMyGVsG43bYSD+YwjeEnSr6ersQ zalSPLBtKNKBi/xYbdekj9pSCLn4WJpS4+QR5xocb6B9ypNFTklnwcO1MqHV7iOrgSFN b1AVWdWDm8ZmMViHbzHqu0dRxE+ABf86pdt4COz43y6SwhkGtKA4CNQNr8jWn19bRgqW NTWU0JDnonbrPybyPY4yV5fF2qkZAEUKbz+wEfDXNl6UlJ7ebZQpI+ARWJ6Zvds2TjRg jBJlHOGwpWw4HJ9xtwgEyZsvTlvvOCCWvSjqc6AzXoTsES5Xuo3uPt0KVerMintLzMHh 3f7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=oSv9lNjLIcC+dSOR04T0KHy3KMdDW83IZKCS+JX1+YQ=; b=FY49TmwfN7yXanrgWyspyG80s8YdP5ZxRvkqZHa4y/RfHSLTCZbUjI4hADGGfExu7K aDRg5ATToifb/nbgjuGbc940sA4QyKS8e+g1c1gPV5/THXxV48RGeKRdwEWdNBqTB22x s/w9Rh8B/7vNv/1tgjXqPQTx3/zOS3vcEQXy4TuYoqpRpmfkS4PsvBnK7bBafvjJ7HWK ZB9Qj1AqJtFChfBFkAEKimNpR+UhjFERwnG59fNLeQmISBElS3mkPK7LVrww6XPhyCYR pSzw6xg6g+mN+GB0ppF5c+CSEoQZ812t+1P7zu0Tfuy++ryfIYsVEyOycnSZVY2heRPm 3oXQ== X-Gm-Message-State: AOAM531dtVJh0IT28kvv2XIyGROh6cNYa2LjB8HqnvHJ1ybo+J2Fl0GO bLn/8WYJvJqmgJOhmSQujdeZR0RKkQs= X-Google-Smtp-Source: ABdhPJxiouZnj3zR+EALTDOvyHkBJY/9tnu4FYQGgffoNdssHUeAC3ABJIUrIrP88TYtKAdHFApGWA== X-Received: by 2002:a05:620a:13c9:: with SMTP id g9mr1921845qkl.436.1597267481847; Wed, 12 Aug 2020 14:24:41 -0700 (PDT) Received: from [172.17.0.2] ([52.247.8.108]) by smtp.gmail.com with ESMTPSA id o25sm3311884qkm.42.2020.08.12.14.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2020 14:24:41 -0700 (PDT) Message-ID: <5f345e19.1c69fb81.cce10.d6f2@mx.google.com> Date: Wed, 12 Aug 2020 14:24:41 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============7821008023768021923==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, tedd.an@linux.intel.com Subject: RE: [V2,2/3] tools/btpclientctl: Add btpclient test application Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200812204932.25627-2-tedd.an@linux.intel.com> References: <20200812204932.25627-2-tedd.an@linux.intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.84 / 15.00 / 200.00 X-Rspamd-Queue-Id: 862E2A03FD X-Rspamd-UID: 77df0e --===============7821008023768021923== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #49: FILE: tools/btpclientctl.c:1: +/* ERROR:FSF_MAILING_ADDRESS: Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. #67: FILE: tools/btpclientctl.c:19: + * along with this program; if not, write to the Free Software$ ERROR:FSF_MAILING_ADDRESS: Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. #68: FILE: tools/btpclientctl.c:20: + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA$ WARNING:TYPO_SPELLING: 'arguement' may be misspelled - perhaps 'argument'? #215: FILE: tools/btpclientctl.c:167: + bt_shell_printf("Invalid arguement %s\n", argv[1]); WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const #2124: FILE: tools/btpclientctl.c:2076: +static const char *help[] = { - total: 2 errors, 3 warnings, 2175 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============7821008023768021923==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uCUMIDeJNF+3kgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 13 Aug 2020 02:28:39 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0HkzHjeJNF9RfgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 13 Aug 2020 02:28:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5494540872; Thu, 13 Aug 2020 02:28:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726533AbgHMA2d (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 12 Aug 2020 20:28:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbgHMA2d (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 12 Aug 2020 20:28:33 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D9C8C061383 for <linux-bluetooth@vger.kernel.org>; Wed, 12 Aug 2020 17:28:33 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id x25so1908509pff.4 for <linux-bluetooth@vger.kernel.org>; Wed, 12 Aug 2020 17:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=t2jktOp3oLFCxWLPdRedZQlig2hKxvQwaPspKdm/eDI=; b=QZCYdxvWssD+hStyvbPSHpls7j9anvadJrrp94CoajB6/De6t8zv5/n2iSfqbId1lG Kd2qLuUFuYFQgPOxkVdQqH0nCcnrqiuO1XAhYw3VGCqICMKA6Id0wO4iLkmVJNXLNBEd uh5CFAjalU37XFpaDjC2V6m8go5+BgPap/Vq8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=t2jktOp3oLFCxWLPdRedZQlig2hKxvQwaPspKdm/eDI=; b=OSfMCcUsD7DoRC0TH5H98oLvhTG2qb7FWumjKCnPU3Pa3omcDulQbpasJ3+81OAaL0 rZgCcsEkuSMxtQFT8Zz3S9uRXvlfq3Mnf8EY+woXryDC6wfZQjKvAPHBteZmEyopmxV0 LScCj+3sTNeufJs9AOc62kQTTR56tRAreCkNtdzpjRwOu7puPPDsLt/70Q3OCgrG1OxF No+q6Yzy9Gx8JMnD6nsHHAMJ/Sk1rB8bLByOkmhsu/ljHCpYKRMQF1JN95kmAwdNoFN6 albjjNCE+fckm32D/m5Ki0yw+lShmm5QHImYLmU/EmzIPOBErjps3wi7pvPhlYO4Of+K VJ/w== X-Gm-Message-State: AOAM530yyhB9K2wp1/JbfleG4lDL6Rz26WTqRlgmqQadL5SxZ6CS1keY dnBYf2i6SSA4F+b2Ho29Jeg4BdAHzkQ= X-Google-Smtp-Source: ABdhPJwMevQWaXfbcSLDsUqIf/TKNnhc2aV13KJyh/H4+c213T2lKCGb/Xn2EABJMb2/f1je61znmg== X-Received: by 2002:a63:af01:: with SMTP id w1mr1546730pge.23.1597278511728; Wed, 12 Aug 2020 17:28:31 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id 2sm3945626pfv.27.2020.08.12.17.28.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Aug 2020 17:28:30 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org> Subject: [PATCH BlueZ] checkpatch: Ignore SPDX license tag Date: Wed, 12 Aug 2020 17:28:19 -0700 Message-Id: <20200813002819.359374-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.86 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5494540872 X-Rspamd-UID: 43c887 BlueZ does not use SPDX license tag on file headers. --- .checkpatch.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/.checkpatch.conf b/.checkpatch.conf index 419733832..72c3529c3 100644 --- a/.checkpatch.conf +++ b/.checkpatch.conf @@ -12,3 +12,4 @@ --ignore PREFER_PACKED --ignore COMMIT_MESSAGE --ignore SSCANF_TO_KSTRTO +--ignore SPDX_LICENSE_TAG -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aEgUO4rONF9ubgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 13 Aug 2020 07:24:26 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id qGCzOYrONF/9UgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 13 Aug 2020 07:24:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 141BAA124F; Thu, 13 Aug 2020 07:24:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726042AbgHMFYU (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 13 Aug 2020 01:24:20 -0400 Received: from mail-il1-f197.google.com ([209.85.166.197]:44588 "EHLO mail-il1-f197.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbgHMFYT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 13 Aug 2020 01:24:19 -0400 Received: by mail-il1-f197.google.com with SMTP id z15so3558341ile.11 for <linux-bluetooth@vger.kernel.org>; Wed, 12 Aug 2020 22:24:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=MIGAdD8AV/NC1BP8vlLnD+v3sHhkKr3057HeKchSrxM=; b=szJcZSot7SqYtZbRF0FQJkBhCjK7Oz4tcrGQiYdgmNBLZnmmVLQKwoZhHUOO2OOPjr Y0CjX38KQBToYiS48WYlYI+ZGIqs3tgkJc2g3onZA3sm6PV4tJNyTDt4EFt8EbecYr+/ fYIr/T7iiTjuWXd+WuakjFp2AmzQ5+zwv/dNRdlQzAjS2Hi1GIZ0LC9eYh047zP6cJX/ 2t/lmyTvQGEzTLs7c/kCXJSUuedr56yWkGCmI4wv63h9fb7uaFTHzXg3bZOVrKq1zIsc sXDWOwCUK/q1Sv26yxPSSNtWIrRn4lya2T+NMBr5tbusjnWW+BVgH63y/ycImzRDl1Yn 43pQ== X-Gm-Message-State: AOAM5320X16MKQ9OvXxGAxQygCVohLEFbhxV07Vrr1RvSgdka6jh6rWJ TXD4xk1ZPhMjvYP2TDsQ1yCrRRppOE/ZOYnAOPyQ32ozb+cU X-Google-Smtp-Source: ABdhPJxe/Y534Kujvl7uJwA40M2Jd7ICtQOtb+65Yk6LhxvJf9iNcev7hCxUSV5nArY+7yR3D+MdMzCJp8K5VbfJa70QRQfGBks0 MIME-Version: 1.0 X-Received: by 2002:a92:d9d1:: with SMTP id n17mr2940649ilq.182.1597296259060; Wed, 12 Aug 2020 22:24:19 -0700 (PDT) Date: Wed, 12 Aug 2020 22:24:19 -0700 In-Reply-To: <00000000000042af6205ac444172@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000001f5a1105acbb8483@google.com> Subject: Re: WARNING: locking bug in l2cap_chan_del From: syzbot <syzbot+01d7fc00b2a0419d01cc@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: 141BAA124F X-Rspamd-UID: 460ec4 syzbot has found a reproducer for the following issue on: HEAD commit: 06a7a37b ipv4: tunnel: fix compilation on ARCH=um git tree: net console output: https://syzkaller.appspot.com/x/log.txt?x=115caa16900000 kernel config: https://syzkaller.appspot.com/x/.config?x=7bb894f55faf8242 dashboard link: https://syzkaller.appspot.com/bug?extid=01d7fc00b2a0419d01cc compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13fb564a900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+01d7fc00b2a0419d01cc@syzkaller.appspotmail.com ------------[ cut here ]------------ DEBUG_LOCKS_WARN_ON(1) WARNING: CPU: 0 PID: 5 at kernel/locking/lockdep.c:183 hlock_class kernel/locking/lockdep.c:183 [inline] WARNING: CPU: 0 PID: 5 at kernel/locking/lockdep.c:183 hlock_class kernel/locking/lockdep.c:172 [inline] WARNING: CPU: 0 PID: 5 at kernel/locking/lockdep.c:183 check_wait_context kernel/locking/lockdep.c:4100 [inline] WARNING: CPU: 0 PID: 5 at kernel/locking/lockdep.c:183 __lock_acquire+0x1674/0x5640 kernel/locking/lockdep.c:4376 Kernel panic - not syncing: panic_on_warn set ... CPU: 0 PID: 5 Comm: kworker/0:0 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 panic+0x2e3/0x75c kernel/panic.c:231 __warn.cold+0x20/0x45 kernel/panic.c:600 report_bug+0x1bd/0x210 lib/bug.c:198 handle_bug+0x38/0x90 arch/x86/kernel/traps.c:235 exc_invalid_op+0x14/0x40 arch/x86/kernel/traps.c:255 asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:536 RIP: 0010:hlock_class kernel/locking/lockdep.c:183 [inline] RIP: 0010:hlock_class kernel/locking/lockdep.c:172 [inline] RIP: 0010:check_wait_context kernel/locking/lockdep.c:4100 [inline] RIP: 0010:__lock_acquire+0x1674/0x5640 kernel/locking/lockdep.c:4376 Code: d2 0f 85 f1 36 00 00 44 8b 15 f0 8e 57 09 45 85 d2 0f 85 1c fa ff ff 48 c7 c6 80 af 4b 88 48 c7 c7 80 aa 4b 88 e8 ce 36 eb ff <0f> 0b e9 02 fa ff ff c7 44 24 38 fe ff ff ff 41 bf 01 00 00 00 c7 RSP: 0018:ffffc90000cbf8e0 EFLAGS: 00010086 RAX: 0000000000000000 RBX: 0000000000000004 RCX: 0000000000000000 RDX: ffff8880a95a2140 RSI: ffffffff815d8eb7 RDI: fffff52000197f0e RBP: ffff8880a95a2ab0 R08: 0000000000000000 R09: ffffffff89bcb3c3 R10: 00000000000007d2 R11: 0000000000000001 R12: 0000000000000000 R13: 00000000000019a1 R14: ffff8880a95a2140 R15: 0000000000040000 lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:5005 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:175 spin_lock_bh include/linux/spinlock.h:359 [inline] lock_sock_nested+0x3b/0x110 net/core/sock.c:3040 l2cap_sock_teardown_cb+0x88/0x400 net/bluetooth/l2cap_sock.c:1520 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:823 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Kernel Offset: disabled Rebooting in 86400 seconds.. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yC5qJkvJNF8jZwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 13 Aug 2020 07:02:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id EDkZJUvJNF/SbAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 13 Aug 2020 07:02:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 39787420CD; Thu, 13 Aug 2020 07:01:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725960AbgHMFB4 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 13 Aug 2020 01:01:56 -0400 Received: from mga01.intel.com ([192.55.52.88]:34463 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbgHMFBz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 13 Aug 2020 01:01:55 -0400 IronPort-SDR: depHhk6SWEhwQJ9+QCCZXPZSwNCY+0GUaPzympX0utZpRAXl7x7CSwSd4EEwRLDNYzQEVW7+l8 yg6y220AqlUQ== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="172205220" X-IronPort-AV: E=Sophos;i="5.76,307,1592895600"; d="scan'208";a="172205220" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 22:01:55 -0700 IronPort-SDR: l5Qlt8gjeMgg64IdpM21NWlJXlb8m9q0eaKN+OF4Zf6eW3/5erXHPu7oK95h/C0tIsIvYTwA7C L59tHssq1RJw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,307,1592895600"; d="scan'208";a="399054397" Received: from bnichola-mobl1.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.230.96]) by fmsmga001.fm.intel.com with ESMTP; 12 Aug 2020 22:01:55 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] mesh: Don't add config server when loading from storage Date: Wed, 12 Aug 2020 22:01:50 -0700 Message-Id: <20200813050150.135751-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.70 / 15.00 / 200.00 X-Rspamd-Queue-Id: 39787420CD X-Rspamd-UID: f32c89 Adding a sonfig server model when loading from storage is unnecessary, since the daemon-generated stored configuration always contains config server model. This also fixes a memory leak caused by bad parameters passed to mesh_model_add() --- mesh/node.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/mesh/node.c b/mesh/node.c index 4b70587ae..1eeffeb8b 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -353,9 +353,6 @@ static bool add_elements_from_storage(struct mesh_node *node, if (!add_element_from_storage(node, entry->data)) return false; - /* Add configuration server model on the primary element */ - mesh_model_add(node, PRIMARY_ELE_IDX, CONFIG_SRV_MODEL, NULL); - return true; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iLi7OuX8NF+bagEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 13 Aug 2020 10:42:13 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +KRgOeX8NF9VKwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 13 Aug 2020 10:42:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 16763A0979; Thu, 13 Aug 2020 10:42:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726747AbgHMImE (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 13 Aug 2020 04:42:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbgHMImD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 13 Aug 2020 04:42:03 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 700BBC061384 for <linux-bluetooth@vger.kernel.org>; Thu, 13 Aug 2020 01:42:03 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id bh1so2314021plb.12 for <linux-bluetooth@vger.kernel.org>; Thu, 13 Aug 2020 01:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UbdKBrdotq83jU1QMt2IgDl1E5bjqx/qouMsGAbK12g=; b=OYR7BzflZ0O26S/A/8KyvAlO9i5MxabYg3uJa4lwLP/KO8VpoWe1AGRaLgoCvgILZ5 p9+GoT6fxqwL+icHSjdQqdh2Fskcy629eO6zofQY/xX+VYwCo5TgfzB8Fop7L3jCxNb5 +OM9N8p9615NU0FnPwJPjVhkN7i2zeP39mdaY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UbdKBrdotq83jU1QMt2IgDl1E5bjqx/qouMsGAbK12g=; b=oEDjGIjiOAGufhJ/eTDtYEhxjK+tYVZ6+ECENckTQYxIGtRAuHIRmXyNi3IBSypk0e iQBNlOp1BUEJNnsrSgh5IdJQigHKNQiPNda3S05/x4qfLQCCFibVEP69lLHDzGJYACn3 h7Xy8lhpzgDp0AB7oe4kqFAkDD3U4YN/tatUQntDycvRH5/QVFg/7DgGzgYoLeElYKUA GBvWISrnArSERPAokKuDrJWF15rkvXGidSu+EtHzwXtNHvf+L6mhQUWFMbU5/RbPI6Ev czOy/BhQZb3BlQzu7bgQ+KVmuFj80vt+YFYbtuX7y1Y/BZ2msD+4/qPf8YBJjxOzh4l0 FKjQ== X-Gm-Message-State: AOAM531q74PGnr2W5mLapae5PSfcnImylMNwSSi5Ah39ievnq9Rq4PYx b/wM1yCRjBCay/zj2eSPGs2SFWo8Fvg= X-Google-Smtp-Source: ABdhPJz6TJ9Uw4cwCnhTlFM6qfZ5wovRm/Htuj/dUG3SzboFS8rc3aZmT9tP3vIGXe59SYYi15vlSQ== X-Received: by 2002:a17:902:8a85:: with SMTP id p5mr2996916plo.193.1597308122498; Thu, 13 Aug 2020 01:42:02 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id y29sm5032035pfr.11.2020.08.13.01.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2020 01:42:01 -0700 (PDT) From: Joseph Hwang <josephsih@chromium.org> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Joseph Hwang <josephsih@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v1 0/2] To support the HFP WBS, a chip vendor may choose a particular Date: Thu, 13 Aug 2020 16:41:27 +0800 Message-Id: <20200813084129.332730-1-josephsih@chromium.org> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.48 / 15.00 / 200.00 X-Rspamd-Queue-Id: 16763A0979 X-Rspamd-UID: a96da6 USB alternate seeting of which the packet size is distinct. The patches are to expose the packet size to user space so that the user space does not need to hard code those values. We have verified this patch on Chromebooks which use - Realtek 8822CE controller with USB alt setting 1 - Intel controller with USB alt setting 6 Our user space audio server, cras, can get the correct packet length from the socket option. Joseph Hwang (2): Bluetooth: btusb: define HCI packet sizes of USB Alts Bluetooth: sco: expose WBS packet length in socket option drivers/bluetooth/btusb.c | 43 +++++++++++++++++++++++-------- include/net/bluetooth/bluetooth.h | 2 ++ include/net/bluetooth/hci_core.h | 1 + net/bluetooth/sco.c | 8 ++++++ 4 files changed, 43 insertions(+), 11 deletions(-) -- 2.28.0.236.gb10cc79966-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YB9ANu5CNl/nzQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 09:53:18 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OJObNO5CNl82+gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 09:53:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=tugraz.at X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BDA72A11FD; Fri, 14 Aug 2020 09:53:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726247AbgHNHxN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 03:53:13 -0400 Received: from mailrelay.tugraz.at ([129.27.2.202]:60399 "EHLO mailrelay.tugraz.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbgHNHxM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 03:53:12 -0400 X-Greylist: delayed 425 seconds by postgrey-1.27 at vger.kernel.org; Fri, 14 Aug 2020 03:53:11 EDT Received: from [129.27.228.116] (tug-swl-228-116.tugraz.at [129.27.228.116]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4BSb8q37dmz3x42 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 09:46:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1597391163; bh=SA8BRs4UvPAdIj12RFtIhXoPxHJyIrccxcow0rqIa9M=; h=To:From:Subject:Date; b=B3QqD0b5H7+YYEDwTvK+axVJquOfP1FNgBGtFEdDAoQtF1dmFSW5abS+3mD7aSNLH 9s8Qmbs55UCPnmMcCu7nS7oPGFlBDz3iQzJFEvmFaH2EEc3X9dXn9QUu2sE2unTB4h dxjJbI8vAVItuwTuYAVkNjd+m3h/Ym+Z6JDdLbTM= To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> From: Christian Seifert <christian.seifert@student.tugraz.at> Subject: [BlueZ] BLE Security Mode 2 Support Message-ID: <edd02903-6460-76c0-7b96-169c15d42699@student.tugraz.at> Date: Fri, 14 Aug 2020 09:46:02 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: Avast (VPS 200813-8, 13.08.2020), Outbound message X-Antivirus-Status: Clean X-TUG-Backscatter-control: 8/uCiIPrZbSKetTI+3UC4A X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.117 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.14 / 15.00 / 200.00 X-Rspamd-Queue-Id: BDA72A11FD X-Rspamd-UID: aadb1c Hello, i am trying to implement a communication channel that uses BLE Security Mode 2 Lvl 1 or 2. Both participants that need to communicate are Raspberry Pi's running Raspberry Pi OS and BlueZ as Bluetooth Stack. The data i want to send is already encrypted which makes Data Signing interesting for me. Does BlueZ Support BLE Security Mode 2 Lvl 1/2 and if yes how can i access the functionality? Furthermore in my research to find the answer for this question i always seemed to come across Security Mode 3 mentioned in combination with BlueZ. Does this simply refer to Security Mode 1 Lvl 3? In order to find an answer for this question: I searched the web rigorously / Tried to find an answer in forums / Read the Documentation / Tried to read the source code / Checked the archives As i found nearly nothing regarding this topic my last resort is to ask this E-Mail Chain and i would be extremely gratefull if someone would be able to answer my question or tip me off into the right direction. Thank you very much for your time and help in advance! Best regards, Christian Seifert PS: Please excuse my poor Translation attempts as English is not my first language. I will gladly try to rewrite any confusing or misleading parts in my message if pointed out! Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MCb4Bu9ENl+8uwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 10:01:51 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UM9dBe9ENl+DggAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 10:01:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1CB42A1996; Fri, 14 Aug 2020 10:01:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726320AbgHNIBn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 04:01:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:46728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726124AbgHNIBn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 04:01:43 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F9D42065C; Fri, 14 Aug 2020 08:01:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597392102; bh=Jg0UKpPfQWQi3+FOI35pkwnDNhqPylAnpzgmFN2q6m4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BFw6AgNFi4ABRI5micuWSD5wPZUWeyUZeuR2k/olspvXko6ID0dBS0gO5p3c2OjLs VDc/kSxCvMon33u3GyUtdsHi0JqxHr3n5fTb8zQwjIYZCSu+IT3T2Kl3JkOYvRocr1 K1btzgyGd56Uu+nH4HwKgtayf4+blI2RHEPJ2MAw= Received: by pali.im (Postfix) id D4FEEBD5; Fri, 14 Aug 2020 10:01:39 +0200 (CEST) Date: Fri, 14 Aug 2020 10:01:39 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org>, David Heidelberg <david@ixit.cz> Subject: Re: [PATCH] Install avinfo utility Message-ID: <20200814080139.23g24skan7krigdo@pali> References: <20200506193435.3746-1-pali@kernel.org> <CECA6D9A-0F26-40E8-BFDF-A24CD972307D@holtmann.org> <20200610093306.zt3q3s2wmwp3almw@pali> <7672C0A0-AF6A-41B2-B50F-7836B3E5CC73@holtmann.org> <20200611125304.b4mxxuv7rupamfmg@pali> <20200713090913.6duirl4yhrjcyxoh@pali> <20200808132042.mma5ykynagwx3ubd@pali> <CABBYNZ+Ep6njp9vfEZrFTGCiSMcsdoPnPa21H0ApJ1O3tau_MQ@mail.gmail.com> <20200809153321.gywj4elkefrcusvz@pali> <CABBYNZJwf==cfNgEzVJ0r+gA7QVFxyXp25OT13X+=qW6pH5-9A@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <CABBYNZJwf==cfNgEzVJ0r+gA7QVFxyXp25OT13X+=qW6pH5-9A@mail.gmail.com> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1CB42A1996 X-Rspamd-UID: 9c917c On Sunday 09 August 2020 11:22:53 Luiz Augusto von Dentz wrote: > Hi Pali, > > On Sun, Aug 9, 2020 at 8:33 AM Pali Rohár <pali@kernel.org> wrote: > > > > On Saturday 08 August 2020 22:33:48 Luiz Augusto von Dentz wrote: > > > Hi Pali, > > > > > > On Sat, Aug 8, 2020 at 6:20 AM Pali Rohár <pali@kernel.org> wrote: > > > > > > > > On Monday 13 July 2020 11:09:13 Pali Rohár wrote: > > > > > On Thursday 11 June 2020 14:53:04 Pali Rohár wrote: > > > > > > On Wednesday 10 June 2020 19:31:47 Marcel Holtmann wrote: > > > > > > > Hi Pali, > > > > > > > > > > > > > > >>> This utility is very useful for determining which A2DP codecs are supported > > > > > > > >>> by remote side. So install it to system as part of bluez package. > > > > > > > >>> --- > > > > > > > >>> Makefile.tools | 4 ++-- > > > > > > > >>> 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > > >>> > > > > > > > >>> diff --git a/Makefile.tools b/Makefile.tools > > > > > > > >>> index 9b9236609..d52721612 100644 > > > > > > > >>> --- a/Makefile.tools > > > > > > > >>> +++ b/Makefile.tools > > > > > > > >>> @@ -176,9 +176,9 @@ endif > > > > > > > >>> if TOOLS > > > > > > > >>> bin_PROGRAMS += tools/rctest tools/l2test tools/l2ping tools/bccmd \ > > > > > > > >>> tools/bluemoon tools/hex2hcd tools/mpris-proxy \ > > > > > > > >>> - tools/btattach > > > > > > > >>> + tools/btattach tools/avinfo > > > > > > > >>> > > > > > > > >>> -noinst_PROGRAMS += tools/bdaddr tools/avinfo tools/avtest \ > > > > > > > >>> +noinst_PROGRAMS += tools/bdaddr tools/avtest \ > > > > > > > >>> tools/scotest tools/amptest tools/hwdb \ > > > > > > > >>> tools/hcieventmask tools/hcisecfilter \ > > > > > > > >>> tools/btinfo tools/btconfig \ > > > > > > > >> > > > > > > > >> I had no intention to install that tool since it is too limited > > > > > > > > > > > > > > > > Sorry, but I have not seen any limitations with this tool yet. I'm using > > > > > > > > it very often. And also other people who use it have not mentioned any > > > > > > > > limitations or problems. > > > > > > > > > > > > > > > > So could you be more specific what are those limitations? > > > > > > > > > > > > > > > > Also it is the first thing which I'm saying people that should run and > > > > > > > > send me output of it if something related to A2DP does not work. > > > > > > > > > > > > > > > > And because linux distributions do not package this utility and bluez > > > > > > > > developers (for me for unknown reasons) decided to not install it, > > > > > > > > result is that people have to always compile bluez from source to run > > > > > > > > this utility if their A2DP audio does not work or "remote" debugging of > > > > > > > > A2DP is needed. > > > > > > > > > > > > > > > > So result is that who want to know why A2DP audio does not work is > > > > > > > > forced to compile & install bluez from sources and not to use from > > > > > > > > distribution package. And this probably not the expected state. > > > > > > > > > > > > > > > > In any case, nobody reported to me any limitation with one exception > > > > > > > > that it cannot decode capabilities of some custom vendor codecs. But > > > > > > > > most of them are already supported as I sent needed patches in past. > > > > > > > > > > > > > > > >> and makes too many assumption. > > > > > > > > > > > > > > > > For example which assumptions? > > > > > > > > > > > > > > that nothing else is happening right now. It backstabs the actual AVDTP and A2DP implementation. > > > > > > > > > > > > Marcel, but this is not a problem. For that one purpose which avinfo > > > > > > provides it ideal and works fine. Personally I do not see any problem > > > > > > with it. > > > > > > > > > > > > > >> In addition it has a bad name with no Bluetooth prefix. > > > > > > > > > > > > > > > > So, lets rename it. What about "btavinfo"? > > > > > > > > > > > > > > Lets extend btinfo with all sort of capabilities. Make the av portion just one of. I want to remove the multitudes of test utilities anyway. We have to many tiny utilities that are just scattered around and avinfo is just one of them. > > > > > > > > > > > > This looks like a not-so-trivial task and moreover independent of > > > > > > providing current version of avinfo to users. > > > > > > > > > > > > avinfo already exists, is already part of bluez project, it is already > > > > > > compiling during bluez build and is already used by me and lot of other > > > > > > users and works for that one purpose as expected. > > > > > > > > > > > > > > > > > > > > > >> If we think it is useful to have such a test utility, then we need to clean this up first > > > > > > > > > > > > > > > > What exactly to clean up first? > > > > > > > > > > > > > > > > Note that I have already done cleanup of this utility. > > > > > > > > > > > > > > > >> and put this into a larger btinfo work to gather appropriate information from a remote device for debug purposes. > > > > > > > > > > > > > > > > I do not see how btinfo can be used for A2DP purposes. Seems this is > > > > > > > > utility for local controller info and not for remove A2DP. > > > > > > > > > > > > > > This needs a bit thinking, but pretty much simple things like this: > > > > > > > > > > > > > > btinfo local > > > > > > > btinfo avdtp <remote_bdaddr> > > > > > > > > > > > > > > We can create a module handling system so that you can easily links existing tiny utilities into one. > > > > > > > > > > > > I'm not against this change. But this is additional work which needs to > > > > > > be done. And it would not happen today or tomorrow unless you have > > > > > > already patches which implement it. > > > > > > > > > > > > As I said avinfo is already there, implemented, it is working and is > > > > > > part of bluez source code. And is basically the first step when > > > > > > debugging issues with A2DP audio. > > > > > > > > > > > > So what is the real issue with not only compiling this avinfo tool > > > > > > during building bluez but also installing it? > > > > > > > > > > Because nobody presented any real issue for more then month and I'm not > > > > > aware of any, could be avinfo finally enabled during installation? > > > > > > > > PING, two months passed and I have not received any new reply to this patch. > > > > > > > > If there are really no problems, could it be applied? > > > > > > For the record I do intend to enable listing available endpoints in > > > bluetooth-player, which might actually get merged into bluetoothctl as > > > a new menu, > > > > Will it provide everything which is avinfo provides? > > Regarding endpoints yes, it is the endpoint information that has been > exposed via D-Bus objects. Ok, please let me know know it is merged and I will try it. > > > recently there have been some vulnerabilities reported > > > against these kind of tools that are meant to only be used for testing > > > purposes > > > > Could you be more specific what is that vulnerability, so we can fix it? > > It is not related to avinfo, it was gatttool if you are curious about > it, but most if not all our tools do tend to leak memory when they are > exiting which would trigger some analyzer, etc, to have pointless > reports about those leaks. Ok, but this does not look like security issue. Just false positive report of memory leak. Nothing highly critical. > > It is the only issue? If yes, I'm going to fix it once I receive > > details about it. > > > > > so I would only be in favor of installing them with we add > > > some new build option i.e. --enable-testing and document that these > > > tools are meant for testing only (and shall probably be package > > > separately) so we avoid these pointless reports for tools that are not > > > really meant to be used in production. > > > > As I said, avinfo is required tool for debugging A2DP audio transfers in > > case there are problems and probably it is the only tool useful for such > > purpose. > > > > Lot of users are reporting that "audio does not work" and the only way > > to debug is, is to ask users to provide full output of avinfo. > > Well if the issue is at the negotiation it avinfo is not the useful, > btmon traces are what I usually recommend having as you can figure out > what issues are 99% of the time. In more cases it is needed to know what codecs and which their configuration is supported. And dumping this is hard from btmon as it produce tons of output (not related to this) and in some cases it does not provide this information (e.g. when during handshake is not enumerated all codecs). So btmon is not replacement for avinfo. It is tool for diagnostic other issues, e.g. those related to handshake / negotiation. So both are required. > > Well, it can be classified as "testing tool", but highly required in > > case audio does not work. > > It is not a qualifiable implementation that is for sure, so > classifying it as a testing tool is the best we can do. Ok, I have no problem to say it is "for testing" or "for debugging". Distribution maintainers can decide where to put that package and how to install it. But important is that tool needs to be available to end users in some form. > > So please provide information about that vulnerability and I will fix > > it. As being silent for two months about existing vulnerability is not > > really good. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MIQMCGVfNl9CUQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 11:54:45 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id yEKABmVfNl+7VgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 11:54:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2D6BB420CA; Fri, 14 Aug 2020 11:54:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726786AbgHNJyi (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 05:54:38 -0400 Received: from lucky1.263xmail.com ([211.157.147.131]:36114 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726603AbgHNJyi (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 05:54:38 -0400 Received: from localhost (unknown [192.168.167.70]) by lucky1.263xmail.com (Postfix) with ESMTP id A2048B0AAE for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 17:54:34 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED: 0 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [113.57.152.160]) by smtp.263.net (postfix) whith ESMTP id P26754T139821989230336S1597398873569370_; Fri, 14 Aug 2020 17:54:34 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <a450811399363fd9bfc0679124b830ca> X-RL-SENDER: chengbo@uniontech.com X-SENDER: chengbo@uniontech.com X-LOGIN-NAME: chengbo@uniontech.com X-FST-TO: linux-bluetooth@vger.kernel.org X-SENDER-IP: 113.57.152.160 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: chengbo <515672508@qq.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] adapt:Set property mode failed,memory leak This patch will fix a memory leak,when set property mode,it will send a msg, but if failed,the data'memory do not free Date: Fri, 14 Aug 2020 17:54:33 +0800 Message-Id: <20200814095433.10654-1-515672508@qq.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2D6BB420CA X-Rspamd-UID: c0c57b --- src/adapter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..cb4cd8b75 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2918,6 +2918,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param, property_set_mode_complete, data, g_free) > 0) + g_free(data); return; g_free(data); -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WBwOD/X8NF9HqgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 13 Aug 2020 10:42:29 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id eKo5DfX8NF/dDQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 13 Aug 2020 10:42:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E5F69420BC; Thu, 13 Aug 2020 10:42:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726732AbgHMImR (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 13 Aug 2020 04:42:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726648AbgHMImQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 13 Aug 2020 04:42:16 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72086C061383 for <linux-bluetooth@vger.kernel.org>; Thu, 13 Aug 2020 01:42:16 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id ep8so2440821pjb.3 for <linux-bluetooth@vger.kernel.org>; Thu, 13 Aug 2020 01:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kLumMv32BeXkjDSmCSCfzv64I6KOcubFlQAnOBbQLHk=; b=csVCNsb/O6GNaQuqDG/6pQTHaBxFMmUH+HNd8tBVt3o1oYYoahhUoR+zPRfRsHeC53 W5RiwuVQcQYezemmi7mrz9Gt1ewdaWgPeZbVH1glbExQs7ev2LnIdr5rd6oGyJSUXTUH XE2KyPEseLoBPEgcdTPLzYLrOGBDqC5EPqOAs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kLumMv32BeXkjDSmCSCfzv64I6KOcubFlQAnOBbQLHk=; b=QXXKHQRimnuoBekglt2Wt0E5vp3bVG2gTMpvT2D9YvdIe/Q2PYbbhBX9UOd9bZQgHE o52xJIX73C+iMJGxCZ44faxQlpMTuLu8WunIIUXjvTP1oYM+S5DktVC+NKrvuj2dBNqK t9y0Bvegwt7B7qH57V41D9kJorwW1kbO/mblyLmRcw4mRB/PmgMYJomFraQnNEXl8pLO 3MsYsWqCJuNRY7XnS7oEXdhe0usAAhwUzJ8G8rQGt+/efEBCMki6h5g08QS5lll0pffO wHIWNKRMVKw/wG70O0q9YlPvB+Dyw16kXJilSG5vL8tU9OWt+jq/mHygnACtkI+N7l4W iuHQ== X-Gm-Message-State: AOAM530hKbuysNe6R9Ije9AR/C0GHIvTZa4qHxRL0omUwEZloMg9EgXc IF18RuiWeLMlV1mmccNIOYV7lmypIbU= X-Google-Smtp-Source: ABdhPJyzjTuLImgoE0a6KvLgH//MuZxi67QVY9MCW+hO3+K/A//viL/LFBbLPVK4l/SIBGJEjHMpJw== X-Received: by 2002:a17:90a:a65:: with SMTP id o92mr4072981pjo.104.1597308135142; Thu, 13 Aug 2020 01:42:15 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id y29sm5032035pfr.11.2020.08.13.01.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2020 01:42:14 -0700 (PDT) From: Joseph Hwang <josephsih@chromium.org> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Joseph Hwang <josephsih@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v1 1/2] Bluetooth: btusb: define HCI packet sizes of USB Alts Date: Thu, 13 Aug 2020 16:41:28 +0800 Message-Id: <20200813164059.v1.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog In-Reply-To: <20200813084129.332730-1-josephsih@chromium.org> References: <20200813084129.332730-1-josephsih@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: E5F69420BC X-Rspamd-UID: 57e9ba It is desirable to define the HCI packet payload sizes of USB alternate settings so that they can be exposed to user space. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Signed-off-by: Joseph Hwang <josephsih@chromium.org> --- drivers/bluetooth/btusb.c | 43 ++++++++++++++++++++++++-------- include/net/bluetooth/hci_core.h | 1 + 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 8d2608ddfd0875..df7cadf6385868 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -459,6 +459,22 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { #define BTUSB_WAKEUP_DISABLE 14 #define BTUSB_USE_ALT1_FOR_WBS 15 +/* Per core spec 5, vol 4, part B, table 2.1, + * list the hci packet payload sizes for various ALT settings. + * This is used to set the packet length for the wideband speech. + * If a controller does not probe its usb alt setting, the default + * value will be 0. Any clients at upper layers should interpret it + * as a default value and set a proper packet length accordingly. + * + * To calculate the HCI packet payload length: + * for alternate settings 1 - 5: + * hci_packet_size = suggested_max_packet_size * 3 (packets) - + * 3 (HCI header octets) + * for alternate setting 6: + * hci_packet_size = suggested_max_packet_size - 3 (HCI header octets) + */ +static const int hci_packet_size_usb_alt[] = { 0, 24, 48, 72, 96, 144, 60 }; + struct btusb_data { struct hci_dev *hdev; struct usb_device *udev; @@ -3958,6 +3974,15 @@ static int btusb_probe(struct usb_interface *intf, hdev->notify = btusb_notify; hdev->prevent_wake = btusb_prevent_wake; + if (id->driver_info & BTUSB_AMP) { + /* AMP controllers do not support SCO packets */ + data->isoc = NULL; + } else { + /* Interface orders are hardcoded in the specification */ + data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); + data->isoc_ifnum = ifnum_base + 1; + } + #ifdef CONFIG_PM err = btusb_config_oob_wake(hdev); if (err) @@ -4021,6 +4046,10 @@ static int btusb_probe(struct usb_interface *intf, hdev->set_diag = btintel_set_diag; hdev->set_bdaddr = btintel_set_bdaddr; hdev->cmd_timeout = btusb_intel_cmd_timeout; + + if (btusb_find_altsetting(data, 6)) + hdev->sco_pkt_len = hci_packet_size_usb_alt[6]; + set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); @@ -4062,15 +4091,6 @@ static int btusb_probe(struct usb_interface *intf, btusb_check_needs_reset_resume(intf); } - if (id->driver_info & BTUSB_AMP) { - /* AMP controllers do not support SCO packets */ - data->isoc = NULL; - } else { - /* Interface orders are hardcoded in the specification */ - data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); - data->isoc_ifnum = ifnum_base + 1; - } - if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) && (id->driver_info & BTUSB_REALTEK)) { hdev->setup = btrtl_setup_realtek; @@ -4082,9 +4102,10 @@ static int btusb_probe(struct usb_interface *intf, * (DEVICE_REMOTE_WAKEUP) */ set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); - if (btusb_find_altsetting(data, 1)) + if (btusb_find_altsetting(data, 1)) { set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); - else + hdev->sco_pkt_len = hci_packet_size_usb_alt[1]; + } else bt_dev_err(hdev, "Device does not support ALT setting 1"); } diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 8caac20556b499..0624496328fc09 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -417,6 +417,7 @@ struct hci_dev { unsigned int acl_pkts; unsigned int sco_pkts; unsigned int le_pkts; + unsigned int sco_pkt_len; __u16 block_len; __u16 block_mtu; -- 2.28.0.236.gb10cc79966-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UEJBGP/8NF9HqgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 13 Aug 2020 10:42:39 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QKuyFv/8NF/dDQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 13 Aug 2020 10:42:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EA8A7417C0; Thu, 13 Aug 2020 10:42:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726224AbgHMIm0 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 13 Aug 2020 04:42:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726249AbgHMImV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 13 Aug 2020 04:42:21 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C970C061384 for <linux-bluetooth@vger.kernel.org>; Thu, 13 Aug 2020 01:42:21 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id d19so2464123pgl.10 for <linux-bluetooth@vger.kernel.org>; Thu, 13 Aug 2020 01:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+S61hbBUWnnIr1pACyWESONaaBAFPVTE7r0Hpph1Gy8=; b=DjVFX12upbN/1MoEtx0DJ4hrWuRWIvGCnoULuK4GMDwGU5lTCJphBanBCrloKdbF0B xwrai9Q1rPNKyUwaTAPvPsrLrBioD4hu6g3BKexmyMxpNATBLeP4sVA56ReqhznRbpo8 vhAO9Qp6Cp4G3x3DMSmlMt8HqMrkVO2JY5fzY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+S61hbBUWnnIr1pACyWESONaaBAFPVTE7r0Hpph1Gy8=; b=HpzZ7aJgTIVvYGVD4lTbIEmDiD1BRNNUQaXoDWCRW5WJTYBjXIlsvOve2diZwNTo8r 2KEkAjWKaG0m28Q4urlBsFnrcfvnYqTJc36641vs3dymArWqwDcKFbTs8F4xjNIIz5yp QmyIIZYpkvMhgg6mGS22cfiB5Jmov3AplXfpoPS0epKzkeSSoee/WIuqV8R7hBHqENPw PKCFh9AxT+GxXRDdE85DyFdalyxg65sgA8YimHe0MKvCaeEHwQVE/peDkkzeuiCdiiEi 1mAIOn/SAn9vqIJ8ExcwtK8m0n1pMFtc7iw6hY41o+TZxT39Hh8O9pGVPzWzwTY8pkdy 9L3w== X-Gm-Message-State: AOAM531C/jb/6Qe3qWWRoHpk3OBo6fL02r/m9BEBVXSQXMY42Ffa8Udo 2uZTZROabtr53lGtN11soVEgq8gv6rQ= X-Google-Smtp-Source: ABdhPJx0RsR6ADUaGZ1eXG6LZOZfLxE+6htn34QhBtxpC7kCXbOsswRKnrgB+bAYO0kYBNQ2aBolmQ== X-Received: by 2002:a63:dc4a:: with SMTP id f10mr2646729pgj.394.1597308140322; Thu, 13 Aug 2020 01:42:20 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id y29sm5032035pfr.11.2020.08.13.01.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2020 01:42:19 -0700 (PDT) From: Joseph Hwang <josephsih@chromium.org> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Joseph Hwang <josephsih@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v1 2/2] Bluetooth: sco: expose WBS packet length in socket option Date: Thu, 13 Aug 2020 16:41:29 +0800 Message-Id: <20200813164059.v1.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog In-Reply-To: <20200813084129.332730-1-josephsih@chromium.org> References: <20200813084129.332730-1-josephsih@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: EA8A7417C0 X-Rspamd-UID: ed8b42 It is desirable to expose the wideband speech packet length via a socket option to the user space so that the user space can set the value correctly in configuring the sco connection. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Signed-off-by: Joseph Hwang <josephsih@chromium.org> --- include/net/bluetooth/bluetooth.h | 2 ++ net/bluetooth/sco.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 9125effbf4483d..922cc03143def4 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -153,6 +153,8 @@ struct bt_voice { #define BT_SCM_PKT_STATUS 0x03 +#define BT_SCO_PKT_LEN 17 + __printf(1, 2) void bt_info(const char *fmt, ...); __printf(1, 2) diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index dcf7f96ff417e6..97e4e7c7b8cf62 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -67,6 +67,7 @@ struct sco_pinfo { __u32 flags; __u16 setting; __u8 cmsg_mask; + __u32 pkt_len; struct sco_conn *conn; }; @@ -267,6 +268,8 @@ static int sco_connect(struct sock *sk) sco_sock_set_timer(sk, sk->sk_sndtimeo); } + sco_pi(sk)->pkt_len = hdev->sco_pkt_len; + done: hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -1001,6 +1004,11 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, err = -EFAULT; break; + case BT_SCO_PKT_LEN: + if (put_user(sco_pi(sk)->pkt_len, (u32 __user *)optval)) + err = -EFAULT; + break; + default: err = -ENOPROTOOPT; break; -- 2.28.0.236.gb10cc79966-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qNvGKEuVNV+LQQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 13 Aug 2020 21:32:27 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id MBAMJ0uVNV8YBwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 13 Aug 2020 21:32:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 03830A0183; Thu, 13 Aug 2020 21:32:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726384AbgHMTcV convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 13 Aug 2020 15:32:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:33574 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbgHMTcV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 13 Aug 2020 15:32:21 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Thu, 13 Aug 2020 19:32:18 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gnulux@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-KE6B11wnfG@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.62 / 15.00 / 200.00 X-Rspamd-Queue-Id: 03830A0183 X-Rspamd-UID: eb485a https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #132 from Olivier JUDITH (gnulux@gmail.com) --- Hi, Encoutering issue with a new bluetooth dongle (hci1) acquired from Gearbest site. hciconfig hci0 up Can't init device hci0: Invalid request code (56) I tried on 5.4 kernel and moved to 5.8.1-050801-generic the same behaviour. hci1: Type: Primary Bus: USB BD Address: 00:1A:7D:DA:71:10 ACL MTU: 640:4 SCO MTU: 64:8 DOWN RX bytes:501 acl:0 sco:0 events:22 errors:0 TX bytes:329 acl:0 sco:0 commands:22 errors:0 Features: 0xff 0xff 0x8f 0xfa 0x9b 0xff 0x59 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT hci0: Type: Primary Bus: USB BD Address: 4C:1D:96:6D:CB:48 ACL MTU: 1021:4 SCO MTU: 96:6 UP RUNNING RX bytes:19359 acl:0 sco:0 events:3062 errors:0 TX bytes:748521 acl:0 sco:0 commands:3061 errors:0 Features: 0xbf 0xfe 0x0f 0xfe 0xdb 0xff 0x7b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH SNIFF Link mode: SLAVE ACCEPT Name: 'VivoBook' Class: 0x1c010c Service Classes: Rendering, Capturing, Object Transfer Device Class: Computer, Laptop HCI Version: 5.1 (0xa) Revision: 0x100 LMP Version: 5.1 (0xa) Subversion: 0x100 Manufacturer: Intel Corp. (2) Any help wil be appreciated. Regards -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EDA1K0S5NV/sBgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 00:05:56 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +A1xKUS5NV/CNAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 00:05:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 13B9941117; Fri, 14 Aug 2020 00:05:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726467AbgHMWFo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 13 Aug 2020 18:05:44 -0400 Received: from mga09.intel.com ([134.134.136.24]:39661 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgHMWFn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 13 Aug 2020 18:05:43 -0400 IronPort-SDR: pZJciN7vc5UsXXdQ+8lZ0co191q34apyv+PAHiXirzLmM2tKfxRSg1Rlai2nrCJk3VpkrtX9lA 0RmpJzgqw0CA== X-IronPort-AV: E=McAfee;i="6000,8403,9712"; a="155441746" X-IronPort-AV: E=Sophos;i="5.76,309,1592895600"; d="scan'208";a="155441746" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2020 15:05:41 -0700 IronPort-SDR: 2UBCv+9rmNvVdDKgmdBUCJUGpwHJjB84evv5yohB9WQ0wNR/WkONbyPQew6FzsHe5+wxJcHw71 cS6zi6j4UVkA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,309,1592895600"; d="scan'208";a="276968489" Received: from unknown (HELO fmsmsx605.amr.corp.intel.com) ([10.18.84.215]) by fmsmga007.fm.intel.com with ESMTP; 13 Aug 2020 15:05:41 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 13 Aug 2020 15:05:40 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 13 Aug 2020 15:05:40 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.105) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Thu, 13 Aug 2020 15:05:40 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RHvh7EOkjRfi2z6M+ZBGBuRRHesqt1kky5E61JCk7LpSkJzPszWq2Z9y+lcXokjnQ6sk5kYtlw0WDXQfAmH/DB7HBlBbb+NSkauBxCF5pcBL8m5hPvM9NQ8TyO4a/btu5G9lAErsv14zuKpUaPcDsrkU1hFKUmhz5fvLX5xmtojUN4QwnS/7OS2/bKR+KLzgVKC6M88+BH6gBg11j3QcIcaZmHk2RcDxzJHI3XvfgMr/3JaO6MHDtyS+dw3X0gooVXgVDLYFdQL8ar6+lp6mYbfl/zlXi+aiydOoURAmmSLQNyiLl3zuL42twZJ/Vpv/RXphE9oBdqIMtvMrlrIgnA== 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-SenderADCheck; bh=fMca/oLyGjYBIftnTJw0oz5dtN8XJ5z3yfjjFVsz7As=; b=nu0BQnRsCpi0e+X1NNvzqeD9fu+NY4W4WSY8vR/ojprfzW5EyWRHU1yvNrfdhV7nwCwglMQ0SBkBQxa2XoPRsHfjPKcsWj1EePVX1Haeg7tQlBYYKpgKvVa0k8By8W9scZVcH9yiw7kgjn+AXHK1K6StT+JqJhzbao2Bc4vHTnnyPPxDnCLNPtp49uUsQtvxlArhQlp3D6SC/ZaLVb4cWjWISJhkgnb19WrLbbeCZORt/z2ffHVM1HX2ULyurUrBx5RrbbGBKBxi0rPTbSEgElfnQSxBdIGRVjMD2TVtwfTkHMbfRBk5qUsjME2rryR7z4xan0EDh6BEOXGViu1+5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fMca/oLyGjYBIftnTJw0oz5dtN8XJ5z3yfjjFVsz7As=; b=sMPcR3rPp/tNdQrCv+GByo2FrEhlVgkiheUT1wbpXoELalhLg+qkt3EfR9M46G8huLO8Y6zHOyJmdtVt9Q13U8BJ6k0MdOht/LxXGUMH3n47mqUxEhCBPTsc7Du60946ZjUNAGLA0df6Kg3bqpLhqN4KvN2xYu44zDuS26wHfL8= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1791.namprd11.prod.outlook.com (2603:10b6:300:10f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.18; Thu, 13 Aug 2020 22:05:39 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3283.015; Thu, 13 Aug 2020 22:05:39 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> CC: "michal.lowas-rzechonek@silvair.com" <michal.lowas-rzechonek@silvair.com> Subject: Re: [PATCH BlueZ 1/2] mesh: Fix model ID prior to calling mesh config functions Thread-Topic: [PATCH BlueZ 1/2] mesh: Fix model ID prior to calling mesh config functions Thread-Index: AQHWcNtEnuhduX/s2UOK1SdgwF0M66k2mgoA Date: Thu, 13 Aug 2020 22:05:39 +0000 Message-ID: <3e4a1b55178ae1099523669695792fd8de328ab7.camel@intel.com> References: <20200812190317.102140-1-inga.stotland@intel.com> In-Reply-To: <20200812190317.102140-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7a089729-9b21-4976-f4b9-08d83fd50383 x-ms-traffictypediagnostic: MWHPR11MB1791: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR11MB1791D5DAB9795C51E44293F7E1430@MWHPR11MB1791.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:2733; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /UwEvdRWMgo+XTvs0oXTl10Y4ixc/tSS2OcVep0jeOgbVqnXMiqJV0DAT5kIhQPEVhPpD4BXaZAHEhlZfBcDs9qUEzyBiWeYYqjtr+m/NdIHyjiFmJ9nThvtvzyGhW95m4bEsesBek8lEOyhPf5AFZ7TvLPpzI3ZjG0RA+cQln7IT1Br57KklXDMicSW+N9XRL0TsKsRZe73MGOiwIcV/JVBV+6RKRDq86ZTjOWOKI08o4OcYE3lGhUbX1QxuLeSzFHSfPIxIDpmpX+Zb34jI1PMMIeMadK6QGC+ylhbDrDwtsTOYJ8rCYTdAIVCoxJy/TvhN9eekQqBxHtwdayAiw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(366004)(346002)(136003)(396003)(39860400002)(5660300002)(66946007)(64756008)(66446008)(91956017)(186003)(26005)(71200400001)(8936002)(8676002)(6506007)(2906002)(76116006)(66476007)(66556008)(4326008)(316002)(6512007)(83380400001)(110136005)(6486002)(2616005)(6636002)(478600001)(36756003)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: XtBFgH5R8G79fR4BPqtaHoQUvTTNDVUsus4Ifoi2hyW2mCX6cdHJlFXud6A9ZTGhCVULyzn1DjEVT2wu/WLAEZS6bHznh6TnaiItwNOAcLrgomMTH997C/nzToL8WZOgLs9Ocz1koJHj8fHhmA2wW4sGThM1xxwjPJZomjcVMKquN7GSlBlRXHu17UCosz+lO5ucFVHTyPp3o0G3MLnS3b7mUwQfOHpCWGVqHueFWFYNKIv27jTkd6/iTeeyik/gvvFflqVfND/2jCBU64z2SNNbzLJOumugMCkz7Eddjnzl5PmeOONM/Ibl5PV8N+aE/uOB9M/VJ6PxVwmQQO9fYKKOnmYd2w8wcx36b3SUXraDxWMBlrZ0jKInDzSCqCBRq5bPTYqy3UaxM8c3RFzZREuyAd30hFD78xdcm7jBBwjCj2YZhVw3HT6ooLtO06gaOvjXKuyLdv3eHm2T+ZSfoVI1b52UqhKeM7qnLeFzjFQo8EXaBZP/H5PaENxy4Ito+NDbSdy08667YCBZkVOfHsyXY4OzDW0tiolEtQZxbodZP7l9eF1OmLSlGTPU7wwSEqhxA1RubBpRznIAfbaZIJ8G5BQuaVIBM6xyAUwTtZ57CKJn+DEuvzv3mWoi5tl4vqYB8AOjXJkPF4NdZrlC8A== Content-Type: text/plain; charset="utf-8" Content-ID: <F576B6E33E55824081C54E2FA513B57F@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a089729-9b21-4976-f4b9-08d83fd50383 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Aug 2020 22:05:39.0835 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: xitRmvJa9fdFa/fkZ30yaen+Gg+a93EYJL59fq4+wggLY+rK5LVlbn+74FoMuSW906o5mNhIKy46U6ZLZjhAOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1791 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.20 / 15.00 / 200.00 X-Rspamd-Queue-Id: 13B9941117 X-Rspamd-UID: 2a941c QXBwbGllZCBQYXRjaHNldA0KDQpPbiBXZWQsIDIwMjAtMDgtMTIgYXQgMTI6MDMgLTA3MDAsIElu Z2EgU3RvdGxhbmQgd3JvdGU6DQo+IE1vZGVsIElEcyBmb3IgU0lHIGRlZmluZWQgbW9kZWxzIG5l ZWQgdG8gYmUgc3RyaXBwZWQgb2ZmIFNJR19WRU5ET1INCj4gdmFsdWUgdXNlZCBmb3IgaW50ZXJu YWwgaG91c2VrZWVwaW5nIHByaW9yIHRvIGNhbGxpbmcgZnVuY3Rpb25zDQo+IHRoYXQgc2F2ZSBu ZXcgbW9kZWwgc3RhdGUgaW4gbm9kZSBjb25maWd1cmF0aW9uLg0KPiANCj4gQWxzbywgcmVtb3Zl IGR1cGxpY2F0ZSBzdGF0ZW1lbnRzIGZvciBtb2RlbCBsb29rdXAgaW4gbm9kZSBjb25maWcuDQo+ IC0tLQ0KPiAgbWVzaC9tZXNoLWNvbmZpZy1qc29uLmMgfCAgNyArLS0tLS0tDQo+ICBtZXNoL21v ZGVsLmMgICAgICAgICAgICB8IDEyICsrKysrKysrLS0tLQ0KPiAgMiBmaWxlcyBjaGFuZ2VkLCA5 IGluc2VydGlvbnMoKyksIDEwIGRlbGV0aW9ucygtKQ0KPiANCj4gZGlmZiAtLWdpdCBhL21lc2gv bWVzaC1jb25maWctanNvbi5jIGIvbWVzaC9tZXNoLWNvbmZpZy1qc29uLmMNCj4gaW5kZXggYTQw ZjkyYzAxLi4wODZkNjE4YjEgMTAwNjQ0DQo+IC0tLSBhL21lc2gvbWVzaC1jb25maWctanNvbi5j DQo+ICsrKyBiL21lc2gvbWVzaC1jb25maWctanNvbi5jDQo+IEBAIC0xNjksMTEgKzE2OSw2IEBA IHN0YXRpYyBqc29uX29iamVjdCAqZ2V0X2VsZW1lbnRfbW9kZWwoanNvbl9vYmplY3QgKmpub2Rl LCBpbnQgZWxlX2lkeCwNCj4gIAlzaXplX3QgbGVuOw0KPiAgCWNoYXIgYnVmWzldOw0KPiAgDQo+ IC0JaWYgKCF2ZW5kb3IpDQo+IC0JCXNucHJpbnRmKGJ1ZiwgNSwgIiU0LjR4IiwgKHVpbnQxNl90 KW1vZF9pZCk7DQo+IC0JZWxzZQ0KPiAtCQlzbnByaW50ZihidWYsIDksICIlOC44eCIsIG1vZF9p ZCk7DQo+IC0NCj4gIAlpZiAoIWpzb25fb2JqZWN0X29iamVjdF9nZXRfZXgoam5vZGUsICJlbGVt ZW50cyIsICZqZWxlbWVudHMpKQ0KPiAgCQlyZXR1cm4gTlVMTDsNCj4gIA0KPiBAQCAtMTg5LDcg KzE4NCw3IEBAIHN0YXRpYyBqc29uX29iamVjdCAqZ2V0X2VsZW1lbnRfbW9kZWwoanNvbl9vYmpl Y3QgKmpub2RlLCBpbnQgZWxlX2lkeCwNCj4gIAkJcmV0dXJuIE5VTEw7DQo+ICANCj4gIAlpZiAo IXZlbmRvcikgew0KPiAtCQlzbnByaW50ZihidWYsIDUsICIlNC40eCIsIG1vZF9pZCk7DQo+ICsJ CXNucHJpbnRmKGJ1ZiwgNSwgIiU0LjR4IiwgKHVpbnQxNl90KW1vZF9pZCk7DQo+ICAJCWxlbiA9 IDQ7DQo+ICAJfSBlbHNlIHsNCj4gIAkJc25wcmludGYoYnVmLCA5LCAiJTguOHgiLCBtb2RfaWQp Ow0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9tb2RlbC5jIGIvbWVzaC9tb2RlbC5jDQo+IGluZGV4IDIz YWZiOTNhOC4uMTM2ZWRiMTk0IDEwMDY0NA0KPiAtLS0gYS9tZXNoL21vZGVsLmMNCj4gKysrIGIv bWVzaC9tb2RlbC5jDQo+IEBAIC02MjgsNiArNjI4LDcgQEAgc3RhdGljIGludCB1cGRhdGVfYmlu ZGluZyhzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBhZGRyLCB1aW50MzJfdCBpZCwN Cj4gIAkJCQkJCXVpbnQxNl90IGFwcF9pZHgsIGJvb2wgdW5iaW5kKQ0KPiAgew0KPiAgCXN0cnVj dCBtZXNoX21vZGVsICptb2Q7DQo+ICsJYm9vbCB2ZW5kb3I7DQo+ICAJaW50IGVsZV9pZHggPSBu b2RlX2dldF9lbGVtZW50X2lkeChub2RlLCBhZGRyKTsNCj4gIA0KPiAgCWlmIChlbGVfaWR4IDwg MCkNCj4gQEAgLTY1MSwxMSArNjUyLDE1IEBAIHN0YXRpYyBpbnQgdXBkYXRlX2JpbmRpbmcoc3Ry dWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgYWRkciwgdWludDMyX3QgaWQsDQo+ICAJaWYg KHVuYmluZCBeIGhhc19iaW5kaW5nKG1vZC0+YmluZGluZ3MsIGFwcF9pZHgpKQ0KPiAgCQlyZXR1 cm4gTUVTSF9TVEFUVVNfU1VDQ0VTUzsNCj4gIA0KPiArCXZlbmRvciA9IElTX1ZFTkRPUihpZCk7 DQo+ICsJaWQgPSB2ZW5kb3IgPyBpZCA6IE1PREVMX0lEKGlkKTsNCj4gKw0KPiAgCWlmICh1bmJp bmQpIHsNCj4gIAkJbW9kZWxfdW5iaW5kX2lkeChub2RlLCBlbGVfaWR4LCBtb2QsIGFwcF9pZHgp Ow0KPiArDQo+ICAJCWlmICghbWVzaF9jb25maWdfbW9kZWxfYmluZGluZ19kZWwobm9kZV9jb25m aWdfZ2V0KG5vZGUpLA0KPiAtCQkJCQkJCWFkZHIsIElTX1ZFTkRPUihpZCksDQo+IC0JCQkJCQkJ aWQsIGFwcF9pZHgpKQ0KPiArCQkJCQkJCWFkZHIsIHZlbmRvciwgaWQsDQo+ICsJCQkJCQkJCWFw cF9pZHgpKQ0KPiAgCQkJcmV0dXJuIE1FU0hfU1RBVFVTX1NUT1JBR0VfRkFJTDsNCj4gIA0KPiAg CQlsX2RlYnVnKCJVbmJpbmQga2V5ICU0LjR4IHRvIG1vZGVsICU4Ljh4IiwgYXBwX2lkeCwgbW9k LT5pZCk7DQo+IEBAIC02NjYsMTMgKzY3MSwxMiBAQCBzdGF0aWMgaW50IHVwZGF0ZV9iaW5kaW5n KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IGFkZHIsIHVpbnQzMl90IGlkLA0KPiAg CQlyZXR1cm4gTUVTSF9TVEFUVVNfSU5TVUZGX1JFU09VUkNFUzsNCj4gIA0KPiAgCWlmICghbWVz aF9jb25maWdfbW9kZWxfYmluZGluZ19hZGQobm9kZV9jb25maWdfZ2V0KG5vZGUpLCBhZGRyLA0K PiAtCQkJCQkJSVNfVkVORE9SKGlkKSwgaWQsIGFwcF9pZHgpKQ0KPiArCQkJCQkJdmVuZG9yLCBp ZCwgYXBwX2lkeCkpDQo+ICAJCXJldHVybiBNRVNIX1NUQVRVU19TVE9SQUdFX0ZBSUw7DQo+ICAN Cj4gIAltb2RlbF9iaW5kX2lkeChub2RlLCBlbGVfaWR4LCBtb2QsIGFwcF9pZHgpOw0KPiAgDQo+ ICAJcmV0dXJuIE1FU0hfU1RBVFVTX1NVQ0NFU1M7DQo+IC0NCj4gIH0NCj4gIA0KPiAgc3RhdGlj IHN0cnVjdCBtZXNoX3ZpcnR1YWwgKmFkZF92aXJ0dWFsKGNvbnN0IHVpbnQ4X3QgKnYpDQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QGtoMr65NV9bDwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 00:07:58 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4OfKML65NV/sXgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 00:07:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9AE45A1191; Fri, 14 Aug 2020 00:07:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726597AbgHMWHw (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 13 Aug 2020 18:07:52 -0400 Received: from mga07.intel.com ([134.134.136.100]:24095 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbgHMWHw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 13 Aug 2020 18:07:52 -0400 IronPort-SDR: uU9TxIzrmQCHm5z3E/myun4uTwjba/MBAOncizG4dgPMjEq1+A1MmylEvmbb21nwFY7nWET87H WHXeHoWW7zVw== X-IronPort-AV: E=McAfee;i="6000,8403,9712"; a="218661152" X-IronPort-AV: E=Sophos;i="5.76,309,1592895600"; d="scan'208";a="218661152" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2020 15:07:51 -0700 IronPort-SDR: mre7UKtFWo4s4hVIrG8BCRnj1+bcCaXNn41pNeLDJDpjZeZ4cu7jo9cbXX49x0rjxIGFy8JYrA M7q1YpknI+Yg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,309,1592895600"; d="scan'208";a="276968812" Received: from orsmsx603-2.jf.intel.com (HELO ORSMSX603.amr.corp.intel.com) ([10.22.229.83]) by fmsmga007.fm.intel.com with ESMTP; 13 Aug 2020 15:07:50 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 13 Aug 2020 15:07:50 -0700 Received: from orsmsx113.amr.corp.intel.com (10.22.240.9) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 13 Aug 2020 15:07:50 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX113.amr.corp.intel.com (10.22.240.9) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 13 Aug 2020 15:07:49 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.104) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 13 Aug 2020 15:07:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dbzegjG1YrqTUOAMovTlXR5VrxhTqYyjLcSYLxzXiuM/T5jUEDLkWeYusxL9g7gePk3Mnt07U092hSkzd9d1sNUgT/yhSBMNc2yR8+rpJFtxtUh0VyafBzTwPjPo07bszVtOtfamEh9Xj9C9+bcWubglQeIvnS4wtKo4Y/USSdyFXHBesfEtKo5jIayxNHJatoLRY77XHT6dVS5c+GXZSrvlPGeX07k4+tsuLPu1Cfn5RhVvLrKY2kYRk4mg7IyitcHwj9ENuyMecWPutxih8bqSvcwJg9lTCvLzxhWmB9HtRFxCnVxBRhP+uw9AyaQudcqEvyqOeHzYPPycEniz1A== 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-SenderADCheck; bh=oJmkOe4d0t242j6IN8kAQah/n2/h/HH84ArRYJi6634=; b=OObeSqJL92vdKKUSGSe0ajYkF1JxIMq2NPHr6GZ5UB0p22/48vnsNxmtiNKCUD8/luolaynPJTvKrWSno5leN8OFGAs9ElaTnYjoxTzf2XjNx5QLwoMINf9Y5f0TigDYUq15KXsARTe8FerOsRzjewTjC5L9pMNss7EkfJRuYmpzZ7yUpSLdB3N+Rt3j6Xwny6F82xoDHf8IjPyeKyMaz2jj5cFFsVwzYbJsw27X66k/zi0AB3Llkv81qDYWshhyL7QVTlknpdffuaq9bdABiL7VT6Qe7QhMvdGhNj6Akr+j9xNXK8YrXU/GJTqfrwmx/VOm280ZFOu+c3s2n3V8EQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oJmkOe4d0t242j6IN8kAQah/n2/h/HH84ArRYJi6634=; b=fu4iLUIXgyh7iNvX8CRHzJhEoF35JjAoaq1CLrmJL4UrmPr6xk5tHKbjfuIWC2wB0AxV/3zIKHlkrhJg7byI/8Esk+CR9YAWjHIdztcU4rfNfduXY6CtAcSX/pVZYnCfyVBhZqhNf/C4EWZ775f1TD7Fp3+yt1tyAVpItm42lro= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4540.namprd11.prod.outlook.com (2603:10b6:303:56::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16; Thu, 13 Aug 2020 22:07:48 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3283.015; Thu, 13 Aug 2020 22:07:48 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: Don't add config server when loading from storage Thread-Topic: [PATCH BlueZ] mesh: Don't add config server when loading from storage Thread-Index: AQHWcS7fMTf7nS1atkC4hoybqdxjzak2mfyA Date: Thu, 13 Aug 2020 22:07:48 +0000 Message-ID: <86c5c593b4170cf3f75a9d2834a705cae79d3012.camel@intel.com> References: <20200813050150.135751-1-inga.stotland@intel.com> In-Reply-To: <20200813050150.135751-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.54.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 56e1abb0-1c4a-483e-4cad-08d83fd550b2 x-ms-traffictypediagnostic: MW3PR11MB4540: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MW3PR11MB4540AB895782ECC76D184E66E1430@MW3PR11MB4540.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0RhhPKnty+9SFRDC/Rwpxvv3jABWOoe20yQSFwmPUEnUMCaDli3Zgje/ZUgMYz0R3WL+DW6MkH9JFl0TJ4NYdJROmuo5iQ5lbnUJFiTt3Igbi8eHf7PtcqllFji1Y3ZIv5m67F8bWZAq5e5bT3wh1hBZAyhDzorxHYHWmK4GdksUw1s3pNkrhWYSLuf155QYqXWemSzzd+UGE7T3/b9cvRvMU7E0ucGTrtJ9CtBwxzMWlamEUl3hmzA8619VgDjj2X435tfCLopG2m6bGuNu6Jv0xa8uMT7kA++6RRFRaSyrOO1q4FpmK3MyyFKyDrhx7rkIgFieINvANLS1NJzOzg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(376002)(396003)(39860400002)(136003)(366004)(2616005)(5660300002)(6512007)(91956017)(2906002)(6486002)(36756003)(186003)(8936002)(6506007)(26005)(8676002)(478600001)(76116006)(64756008)(83380400001)(86362001)(66476007)(316002)(66446008)(71200400001)(4744005)(66946007)(66556008)(6636002)(110136005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: UqoyJlaxcSCNNlXi6wnoUkKTEEpD4T96nbuc25m61jIbvfa2GKvXxAEtMvWVHNWSgKwXkRdvuMzxMHvULm2DpOxAY61j6A4HYGKIxMRFigiYfwSz4YU0bn0ohVRBScJWYgAsYhqY8cHKyi0RBprCH7vnhWnW6VfM4kNE+Un4Vmyrd+aSfb0tvlsgvEK+ixGIYN0Bvt0kgwuK5QXoQYzKfhb+tA382hzZG+jDJ3xozhK4Oc/xqLiUXJnL+xhX3KcYahh6sNC62lqRpSvfrM99YGT1D1MFVYkXnqatGudLORoakkw9Nh82Q8RJrebsP8sYJxq35Na6azVgr4sgqu+1qtsQkO0hEb3pfTgyv7+bcc54rXWSSGimKyUxtMokzikzX4gQcqoPz+IrwpTTmMmTUOlXZwecLOLfIOvCUC6833uhImOb41WdWPBZhTdiXamQuzD1W/ltVrGU8/xT6Z/TD2jA7Gsi+U7pLCeKPrFkEBCopSUgLO9gZm+SBkqd90F016obAjWOCqy8pLpvrczmIbrMkcn2ahxk9xEu2dobdy3GHDt4gT3bXi1gE6ONYUfW8p3PS4y7fADBEZyYn+M1O3CsSafnh5q+WtL/wmnKdkzIGQDS4tKcdHoz7EOieoykLPNQ19Vw9FAdZlBLClSDHA== Content-Type: text/plain; charset="utf-8" Content-ID: <48816393DC249349BD5D802822C7462C@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56e1abb0-1c4a-483e-4cad-08d83fd550b2 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Aug 2020 22:07:48.5768 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 8f4hDaAMZP+bv/Njkll2fjxH+WsbnhBdJvA3tp5UxXIBNO8Kl/oT3tnKiO1tFqem6lqrkJWB+kT1a6AjJ917bA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4540 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.94 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9AE45A1191 X-Rspamd-UID: 616770 QXBwbGllZA0KT24gV2VkLCAyMDIwLTA4LTEyIGF0IDIyOjAxIC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBBZGRpbmcgYSBzb25maWcgc2VydmVyIG1vZGVsIHdoZW4gbG9hZGluZyBmcm9t IHN0b3JhZ2UgaXMgdW5uZWNlc3NhcnksDQo+IHNpbmNlIHRoZSBkYWVtb24tZ2VuZXJhdGVkIHN0 b3JlZCBjb25maWd1cmF0aW9uIGFsd2F5cyBjb250YWlucw0KPiBjb25maWcgc2VydmVyIG1vZGVs Lg0KPiBUaGlzIGFsc28gZml4ZXMgYSBtZW1vcnkgbGVhayBjYXVzZWQgYnkgYmFkIHBhcmFtZXRl cnMgcGFzc2VkIHRvDQo+IG1lc2hfbW9kZWxfYWRkKCkNCj4gLS0tDQo+ICBtZXNoL25vZGUuYyB8 IDMgLS0tDQo+ICAxIGZpbGUgY2hhbmdlZCwgMyBkZWxldGlvbnMoLSkNCj4gDQo+IGRpZmYgLS1n aXQgYS9tZXNoL25vZGUuYyBiL21lc2gvbm9kZS5jDQo+IGluZGV4IDRiNzA1ODdhZS4uMWVlZmZl YjhiIDEwMDY0NA0KPiAtLS0gYS9tZXNoL25vZGUuYw0KPiArKysgYi9tZXNoL25vZGUuYw0KPiBA QCAtMzUzLDkgKzM1Myw2IEBAIHN0YXRpYyBib29sIGFkZF9lbGVtZW50c19mcm9tX3N0b3JhZ2Uo c3RydWN0IG1lc2hfbm9kZSAqbm9kZSwNCj4gIAkJaWYgKCFhZGRfZWxlbWVudF9mcm9tX3N0b3Jh Z2Uobm9kZSwgZW50cnktPmRhdGEpKQ0KPiAgCQkJcmV0dXJuIGZhbHNlOw0KPiAgDQo+IC0JLyog QWRkIGNvbmZpZ3VyYXRpb24gc2VydmVyIG1vZGVsIG9uIHRoZSBwcmltYXJ5IGVsZW1lbnQgKi8N Cj4gLQltZXNoX21vZGVsX2FkZChub2RlLCBQUklNQVJZX0VMRV9JRFgsIENPTkZJR19TUlZfTU9E RUwsIE5VTEwpOw0KPiAtDQo+ICAJcmV0dXJuIHRydWU7DQo+ICB9DQo+ICANCg== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MLFsFoX3NV9eZgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 04:31:33 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id GBZUFIX3NV8CogAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 04:31:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 580DA41298; Fri, 14 Aug 2020 04:31:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726570AbgHNCb0 convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 13 Aug 2020 22:31:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:54372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbgHNCbZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 13 Aug 2020 22:31:25 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 207169] Bluetooth: hci0: command 0x200c tx timeout cause suspend failed Date: Fri, 14 Aug 2020 02:31:24 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: youling257@gmail.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-207169-62941-DUdeRbQ6wV@https.bugzilla.kernel.org/> In-Reply-To: <bug-207169-62941@https.bugzilla.kernel.org/> References: <bug-207169-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.62 / 15.00 / 200.00 X-Rspamd-Queue-Id: 580DA41298 X-Rspamd-UID: 904046 https://bugzilla.kernel.org/show_bug.cgi?id=207169 --- Comment #15 from youling257@gmail.com --- test linux kernel 5.9 can suspend. [ 140.585885] PM: suspend entry (s2idle) [ 140.624364] Filesystems sync: 0.038 seconds [ 142.648683] Bluetooth: hci0: Timed out waiting for suspend events [ 142.648688] Bluetooth: hci0: Suspend timeout bit: 4 [ 142.648691] Bluetooth: hci0: Suspend notifier action (3) failed: -110 [ 142.648696] Freezing user space processes ... [ 142.650906] Bluetooth: hci0: command 0x0c1a tx timeout [ 142.652280] (elapsed 0.003 seconds) done. [ 142.652290] OOM killer disabled. [ 142.652292] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done. [ 142.654571] printk: Suspending console(s) (use no_console_suspend to debug) [ 142.720243] rt5640 i2c-10EC5640:00: disabling jack detect before suspend [ 142.740141] RTW: suspend start [ 142.743909] RTW: rtw_dev_unload: driver not in IPS [ 142.759916] RTW: rtw suspend success in 20 ms [ 143.302475] serial 00:02: disabled [ 143.302513] rtc_cmos 00:00: suspend, ctrl 02 [ 153.664622] RTW: resume start [ 153.665044] RTW: == SDIO Card Info == [ 153.665050] RTW: clock: 50000000 Hz [ 153.665053] RTW: timing spec : [ 153.665055] sd high-speed [ 153.665060] RTW: sd3_bus_mode: FALSE [ 153.665063] RTW: ================ [ 153.693327] rtc_cmos 00:00: resume, ctrl 02 [ 153.722253] rt5640 i2c-10EC5640:00: re-enabling jack detect after resume [ 153.729674] rt5640 i2c-10EC5640:00: irq status 0x110 [ 154.994299] RTW: wlan0- hw port(0) mac_addr =8c:18:d9:27:71:71 [ 155.006720] RTW: rtw_resume_common:0 in 1342 ms [ 155.157170] OOM killer enabled. [ 155.157173] Restarting tasks ... done. [ 157.187320] Bluetooth: hci0: Timed out waiting for suspend events [ 157.187324] Bluetooth: hci0: Suspend timeout bit: 5 [ 157.187328] Bluetooth: hci0: Suspend notifier action (4) failed: -110 [ 157.187332] PM: suspend exit [ 157.188315] Bluetooth: hci0: command 0x0c05 tx timeout [ 159.239690] Bluetooth: hci0: command 0x200b tx timeout -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uHU5Ob4oNl8pKgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 08:01:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id wDFeN74oNl8RiwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 08:01:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DA4A5A1402; Fri, 14 Aug 2020 08:01:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726606AbgHNGBV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 02:01:21 -0400 Received: from mail-io1-f69.google.com ([209.85.166.69]:40069 "EHLO mail-io1-f69.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726006AbgHNGBU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 02:01:20 -0400 Received: by mail-io1-f69.google.com with SMTP id t22so5625831iob.7 for <linux-bluetooth@vger.kernel.org>; Thu, 13 Aug 2020 23:01:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=sCmDfjgeHQU2XqasYC2w9/9D2xVFH6ihBv/kfF+e3jw=; b=BmgFJuJRPEtipxNh7wGJERedJYU6TdHPC46CaBxM3s2J+pAN72n4jCXuYi7DdlL6Hm R4VtC+bkNwouBz/acFJlVnSkZO1vwIoQ8ah45gh49QWieK/2CabNZMTx1dmouUwLa0LB YXaoAEbclEstOt9aAJ2+1yZfVNHLKSYfi9Ydk/fK2808QYW6tnPVKd59olNsUwHAnuqU 2YFdUbM5WVOBtteKdOOWBeUqtr5GS4bHKCcBj2DMOLQUXOFCNZjQVFZ5T6oKtu5cVh4s FRI/PToT/qi5Akpr4lwbDAu47bs1dZ8a2O2fq37LXmr2UG9cFL471nLII8cpUrM+6FUV AWwQ== X-Gm-Message-State: AOAM533FuoD8426DJ11wIyLSIPvcc94r3ICnxBxUsaFSdal1y9mJcJg8 Yk4EcVQ/Tzm3dV7dP5f3hUFno8Gf5jg3NtANam3pRNgwp5xs X-Google-Smtp-Source: ABdhPJxIBN6j/ZMeKyaWqmCi1FaCp4RvYhD+TKcut9djsRe8PAAgfRTsBpUH9s8I3/LT/c0SXsjPTloEZFBbUzf4VQep43bHcnFr MIME-Version: 1.0 X-Received: by 2002:a6b:591a:: with SMTP id n26mr941583iob.122.1597384879879; Thu, 13 Aug 2020 23:01:19 -0700 (PDT) Date: Thu, 13 Aug 2020 23:01:19 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000055c63705acd02676@google.com> Subject: BUG: corrupted list in hci_chan_del From: syzbot <syzbot+21e61af4106356a893be@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.90 / 15.00 / 200.00 X-Rspamd-Queue-Id: DA4A5A1402 X-Rspamd-UID: 1d1251 Hello, syzbot found the following issue on: HEAD commit: 990f2273 Merge tag 's390-5.9-2' of git://git.kernel.org/pu.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=16311491900000 kernel config: https://syzkaller.appspot.com/x/.config?x=9c89856ae5fc8b6 dashboard link: https://syzkaller.appspot.com/bug?extid=21e61af4106356a893be compiler: gcc (GCC) 10.1.0-syz 20200507 userspace arch: i386 Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+21e61af4106356a893be@syzkaller.appspotmail.com list_del corruption. prev->next should be ffff8880a2c52c00, but was 0000000000000000 ------------[ cut here ]------------ kernel BUG at lib/list_debug.c:51! invalid opcode: 0000 [#1] PREEMPT SMP KASAN CPU: 1 PID: 11221 Comm: syz-executor.0 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:__list_del_entry_valid.cold+0xf/0x55 lib/list_debug.c:51 Code: e8 0a af bf fd 0f 0b 48 89 f1 48 c7 c7 60 fe 93 88 4c 89 e6 e8 f6 ae bf fd 0f 0b 48 89 ee 48 c7 c7 00 00 94 88 e8 e5 ae bf fd <0f> 0b 4c 89 ea 48 89 ee 48 c7 c7 40 ff 93 88 e8 d1 ae bf fd 0f 0b RSP: 0018:ffffc90008907828 EFLAGS: 00010282 RAX: 0000000000000054 RBX: 0000000000000000 RCX: 0000000000000000 RDX: ffff88805eb3a5c0 RSI: ffffffff815dbc57 RDI: fffff52001120ef7 RBP: ffff8880a2c52c00 R08: 0000000000000054 R09: ffff8880ae7318e7 R10: 0000000000000000 R11: 000000000004e618 R12: ffff88809421fe00 R13: ffffffff8920ff20 R14: fffffbfff1522378 R15: ffff888097af65d8 FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033 CR2: 00007f0f6a6c5000 CR3: 0000000009a8d000 CR4: 00000000001506e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: __list_del_entry include/linux/list.h:132 [inline] list_del_rcu include/linux/rculist.h:158 [inline] hci_chan_del+0x3f/0x190 net/bluetooth/hci_conn.c:1733 l2cap_conn_del+0x61b/0x9e0 net/bluetooth/l2cap_core.c:1900 l2cap_disconn_cfm net/bluetooth/l2cap_core.c:8160 [inline] l2cap_disconn_cfm+0x85/0xa0 net/bluetooth/l2cap_core.c:8153 hci_disconn_cfm include/net/bluetooth/hci_core.h:1438 [inline] hci_conn_hash_flush+0x114/0x220 net/bluetooth/hci_conn.c:1557 hci_dev_do_close+0x5c6/0x1080 net/bluetooth/hci_core.c:1770 hci_unregister_dev+0x1bd/0xe30 net/bluetooth/hci_core.c:3790 vhci_release+0x70/0xe0 drivers/bluetooth/hci_vhci.c:340 __fput+0x285/0x920 fs/file_table.c:281 task_work_run+0xdd/0x190 kernel/task_work.c:135 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0xb7d/0x29f0 kernel/exit.c:806 do_group_exit+0x125/0x310 kernel/exit.c:903 get_signal+0x40b/0x1ee0 kernel/signal.c:2743 arch_do_signal+0x82/0x2520 arch/x86/kernel/signal.c:811 exit_to_user_mode_loop kernel/entry/common.c:135 [inline] exit_to_user_mode_prepare+0x15d/0x1c0 kernel/entry/common.c:166 syscall_exit_to_user_mode+0x59/0x2b0 kernel/entry/common.c:241 __do_fast_syscall_32+0x63/0x80 arch/x86/entry/common.c:127 do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:149 entry_SYSENTER_compat_after_hwframe+0x4d/0x5c RIP: 0023:0xf7f33569 Code: Bad RIP value. RSP: 002b:00000000f550c12c EFLAGS: 00000292 ORIG_RAX: 00000000000000f0 RAX: fffffffffffffe00 RBX: 0000000008b9c014 RCX: 0000000000000080 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000008b9c018 RBP: 00000000f550c228 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Modules linked in: --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kAG3B90xNl8xVwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 08:40:29 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QMIvBd0xNl8OegEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 08:40:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1B05CA12D1; Fri, 14 Aug 2020 08:40:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726268AbgHNGkX (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 02:40:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbgHNGkX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 02:40:23 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90565C061757 for <linux-bluetooth@vger.kernel.org>; Thu, 13 Aug 2020 23:40:23 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id 2so3943170pjx.5 for <linux-bluetooth@vger.kernel.org>; Thu, 13 Aug 2020 23:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bw7HqmrKE4bMmC/qo7mdRecaT5OsOCHG6GMDFaNmUWA=; b=CECAaDGR7fbf7xXfzpCCnNxkBdYsdlyBrBHfF4k+vAHwcLocKFg7ZO+gPHCe5UbdC6 xIlfHB8hn4WIh7ePCZV3yJPtOxDG3j6Ycn7TRAS/G8ZKIta63O38A0Lb6AeBlSSy2Wri ZL1L/Yi0qmWWOW5vnaN4JVpSKJJ2iL1+OWcRk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bw7HqmrKE4bMmC/qo7mdRecaT5OsOCHG6GMDFaNmUWA=; b=MOnBXKdInsJOeZE+XRNAF9OpE3Jr6QE06l2BC4P8Q07QApfMY20nUaPY907G1boj8I 56Ge00FYTOiw1asSqVBAw7eD6FmmmRUlGlfCFqPGKpreDPCnEgP2WkTjrsj9m3BXv3QF JPFGlcxrZl+zHvgJBIxdZZ4fbEzZuRqyv0EIbsyvf1nx3+0iPlM73R9mA26/QrvFG85p rZYRQollCED5zqoDDz0SIo5LcN4qpg9DLluWaS3ackIQYEuemCWZF9HBOBY6BVoAtrtj PKPv9MQ6JLEstypB6DjdKgM6Swsm5VLN4cKiaQ3EYb1gdIUEGwHyjBOXfAzx+GAZEXgE GmjA== X-Gm-Message-State: AOAM531+99Eg3iLBBzlCbsvBdW29QtRgN+Rjj7SqmkoeMDSDZP33zcwX Y7WihP1FwBjD55epEoj/OrIA9lk6TPrB5g== X-Google-Smtp-Source: ABdhPJxeGyXcflDF+cbSwnZJHaLGcDtjXji9UiK19E7oNjzWZzRCxY5dK3IbhiJv9eBN6Pdf44s5aw== X-Received: by 2002:a17:90a:cc14:: with SMTP id b20mr1075583pju.1.1597387220263; Thu, 13 Aug 2020 23:40:20 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id mh14sm7464214pjb.23.2020.08.13.23.40.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Aug 2020 23:40:19 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v1] shared/ad: move MAX_ADV_DATA_LEN macro to the header Date: Thu, 13 Aug 2020 23:40:15 -0700 Message-Id: <20200813233952.BlueZ.v1.1.I716fc87b0c97e5349a04766a61ecad1f5b0fd28e@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.10 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1B05CA12D1 X-Rspamd-UID: 4d312b This moves MAX_ADV_DATA_LEN macro to src/shared/ad.h. --- Hi Maintainers, In order to avoid duplicate definition of the maximum data length of advertisement for the following series of advertisement monitor API, we'd like to reuse the one in shared/ad. Thanks, Miao src/shared/ad.c | 2 -- src/shared/ad.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/ad.c b/src/shared/ad.c index 8d276842e..6d882a9b3 100644 --- a/src/shared/ad.c +++ b/src/shared/ad.c @@ -33,8 +33,6 @@ #include "src/shared/queue.h" #include "src/shared/util.h" -#define MAX_ADV_DATA_LEN 31 - struct bt_ad { int ref_count; char *name; diff --git a/src/shared/ad.h b/src/shared/ad.h index 19aa1d035..dc92c89bc 100644 --- a/src/shared/ad.h +++ b/src/shared/ad.h @@ -27,6 +27,8 @@ #include "lib/bluetooth.h" #include "lib/uuid.h" +#define MAX_ADV_DATA_LEN 31 + #define BT_AD_FLAGS 0x01 #define BT_AD_UUID16_SOME 0x02 #define BT_AD_UUID16_ALL 0x03 -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WDfvCNhgNl8RdAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 12:00:56 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id CKgbB9hgNl+nxAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 12:00:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0FA38420DD; Fri, 14 Aug 2020 12:00:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726313AbgHNKAu (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 06:00:50 -0400 Received: from lucky1.263xmail.com ([211.157.147.135]:56922 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726012AbgHNKAu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 06:00:50 -0400 Received: from localhost (unknown [192.168.167.235]) by lucky1.263xmail.com (Postfix) with ESMTP id 599CAA1A0C for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 18:00:47 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED: 0 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [113.57.152.160]) by smtp.263.net (postfix) whith ESMTP id P18320T139785796572928S1597399247734917_; Fri, 14 Aug 2020 18:00:48 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <78f4aea74d0e4521b5d1f26efcf9465d> X-RL-SENDER: chengbo@uniontech.com X-SENDER: chengbo@uniontech.com X-LOGIN-NAME: chengbo@uniontech.com X-FST-TO: linux-bluetooth@vger.kernel.org X-SENDER-IP: 113.57.152.160 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: chengbo <515672508@qq.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] adapt:Set property mode failed,memory leak Date: Fri, 14 Aug 2020 18:00:47 +0800 Message-Id: <20200814100047.11008-1-515672508@qq.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0FA38420DD X-Rspamd-UID: afac26 This patch will fix a memory leak,when set property mode,it will send a msg, but if failed,the data'memory do not free --- ...Set-property-mode-failed-memory-leak.patch | 26 +++++++++++++++++++ src/adapter.c | 1 + 2 files changed, 27 insertions(+) create mode 100644 0001-adapt-Set-property-mode-failed-memory-leak.patch diff --git a/0001-adapt-Set-property-mode-failed-memory-leak.patch b/0001-adapt-Set-property-mode-failed-memory-leak.patch new file mode 100644 index 000000000..4994e03a6 --- /dev/null +++ b/0001-adapt-Set-property-mode-failed-memory-leak.patch @@ -0,0 +1,26 @@ +From 62d56bedbd32662b3f33af99dd464d67958e76d6 Mon Sep 17 00:00:00 2001 +From: chengbo <515672508@qq.com> +Date: Fri, 14 Aug 2020 17:09:51 +0800 +Subject: [PATCH BlueZ] adapt:Set property mode failed,memory leak This patch + will fix a memory leak,when set property mode,it will send a msg, but if + failed,the data'memory do not free + +--- + src/adapter.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/adapter.c b/src/adapter.c +index 5e896a9f0..cb4cd8b75 100644 +--- a/src/adapter.c ++++ b/src/adapter.c +@@ -2918,6 +2918,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, + + if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param, + property_set_mode_complete, data, g_free) > 0) ++ g_free(data); + return; + + g_free(data); +-- +2.20.1 + diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..cb4cd8b75 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2918,6 +2918,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param, property_set_mode_complete, data, g_free) > 0) + g_free(data); return; g_free(data); -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MFwZAO/qNl/y7wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 21:50:07 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id wBo7Ou7qNl/phwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 21:50:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D62B541175; Fri, 14 Aug 2020 21:50:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbgHNTuB (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 15:50:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726662AbgHNTuB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 15:50:01 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58B1FC061385 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 12:50:01 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id h16so8486722oti.7 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 12:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F3pZPWea4SVUhsA9E1hMWz0vj5oAgMBKq/U07Pmy2vY=; b=LsDhPO8ahOZ7WNKe7Ym4bWtLQGvbUiExDsIS1kWrZPpbDev3ce4hrtV9chbk1tIE4J r/J8ho4TThlutF4+NohZ8DXMk/UZGro87lX0EVwXXSUIQg71Kx1ZKTVUdlJORVi0iVA6 SPjtHGkHIAw017SRLGSCODs6TErTxgEXcG80nlU1HI4SCm9TD/rB36sU0SnCLlVt4Pi3 zz70Bj6oXUS+wyYSol38cdzhI0hZXo77BP+0kXYhl29+X7919oDdEi0LgO3OksZSNV9b RjishTVts9xZVMW7XmvQq2MAsG1/FDEXBVy5CIw8kSVXAkzik2i/TUVwRbEhLBTq5jQc /1kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F3pZPWea4SVUhsA9E1hMWz0vj5oAgMBKq/U07Pmy2vY=; b=qfNI4xadBDf7XbDVZNJmDucY9Ll93xmKvLWSafex7MMcKB4UY1eLSJ7BtvBnjbyxT+ Ur3RoZsQO9DV22Z3EU6JwYPWSQoq+cJszreE5aEA1eoTAFY4VVA5gSSMcnG0s6YNCCTs LXacYyTENf/yXRekiB2zDWEfAtQUFlQ9NricuAbG2nfmeEbh9VlBx3gz88HC2TP+lqXs UHPr9yo0Gt1qqDE2mieJblqYKXEBAVfafBcD3tYEPXmWXA4FgKb2Bf7h7F13Y5/sip4J w20Vvc0q/GhEJfxHjn/BwFc88VvINRULaCP9OlcVe7h0ZDkPp8XOYC9MBy3lvqly6TM1 4uQQ== X-Gm-Message-State: AOAM532Uq0dN/SgNvHaa0l0IuilX92RflbA0g8W/X682eQ0Wyeu1Vzuv fz6jvM4BlQWkU/CZ9EG+ixa8azp0Xh3FWzk72Aw= X-Google-Smtp-Source: ABdhPJxTDWUgfYrBZu3CStfX8xrinT4Q58vGDPAta0JtFOl1fflG/f9gkQ0fIzB4pHbfCCN3XO7SLVLwQq6uOkQnkRo= X-Received: by 2002:a9d:24e7:: with SMTP id z94mr3076355ota.91.1597434600725; Fri, 14 Aug 2020 12:50:00 -0700 (PDT) MIME-Version: 1.0 References: <20200813233952.BlueZ.v1.1.I716fc87b0c97e5349a04766a61ecad1f5b0fd28e@changeid> In-Reply-To: <20200813233952.BlueZ.v1.1.I716fc87b0c97e5349a04766a61ecad1f5b0fd28e@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 14 Aug 2020 12:49:50 -0700 Message-ID: <CABBYNZJeK4W2a3JLRZdXD=0bupY+V7DBGEtWiBpaycjWVKcy2g@mail.gmail.com> Subject: Re: [BlueZ PATCH v1] shared/ad: move MAX_ADV_DATA_LEN macro to the header To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: D62B541175 X-Rspamd-UID: e2b428 Hi Miao-chen, On Thu, Aug 13, 2020 at 11:43 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > This moves MAX_ADV_DATA_LEN macro to src/shared/ad.h. > --- > Hi Maintainers, > > In order to avoid duplicate definition of the maximum data length of > advertisement for the following series of advertisement monitor API, > we'd like to reuse the one in shared/ad. > > Thanks, > Miao > > src/shared/ad.c | 2 -- > src/shared/ad.h | 2 ++ > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/shared/ad.c b/src/shared/ad.c > index 8d276842e..6d882a9b3 100644 > --- a/src/shared/ad.c > +++ b/src/shared/ad.c > @@ -33,8 +33,6 @@ > #include "src/shared/queue.h" > #include "src/shared/util.h" > > -#define MAX_ADV_DATA_LEN 31 > - > struct bt_ad { > int ref_count; > char *name; > diff --git a/src/shared/ad.h b/src/shared/ad.h > index 19aa1d035..dc92c89bc 100644 > --- a/src/shared/ad.h > +++ b/src/shared/ad.h > @@ -27,6 +27,8 @@ > #include "lib/bluetooth.h" > #include "lib/uuid.h" > > +#define MAX_ADV_DATA_LEN 31 Id suggest renaming this to BT_AD_MAX_DATA_LEN or something like that so it is consistent with the prefixing we are using for bt_ad related defines. > + > #define BT_AD_FLAGS 0x01 > #define BT_AD_UUID16_SOME 0x02 > #define BT_AD_UUID16_ALL 0x03 > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IKeHKW7sNl9H8QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 21:56:30 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id uLYsKG7sNl+BkgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 21:56:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 59910420C9; Fri, 14 Aug 2020 21:56:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727093AbgHNT4R (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 15:56:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726297AbgHNT4R (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 15:56:17 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 416D3C061385; Fri, 14 Aug 2020 12:56:16 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id h22so8483275otq.11; Fri, 14 Aug 2020 12:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sD1hZF2WdFP1115pTPAq+FgT6KZuW8nyCloT6zbSfds=; b=OFSJI9uLzODA4OcY1hVAe6WHCPZQZoKwaxcAlkY3h7E+FIVyKNBc+LitG0bJce7GM9 MI8t2RVPG1bPqQYEhRkPl1B+ZisQwqamhVZY4Ugayj54oXPxzK2O+cNz9fGv6nNdkDUP KuiJInYJstOMsOVbUgEOlknsCJUzx3pYpBMpRGc6JCryU79HxqGybFK8Tm1xNlAYhgZ6 gy6LCOMb1V1bv1NyGvwCvuMzCVGXDq+xt1yH5R2lvCLiMIrImA5MFQT2ZOiBBknFfHLI JgupdGsIcdpLUlGfmyFxvVPXrb//GWhVPfCJAsUt1fX/ngEu3//rAr2eUBRUSxIraJgy x1sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sD1hZF2WdFP1115pTPAq+FgT6KZuW8nyCloT6zbSfds=; b=Tlqk1UT5RWSvffk2oZ23mchyfhuXwP2RJVYpQipoikXRBhhXLzcbjNR8mEOqHkxEKs M4C0Kw4VRDnMnM2OYWzuVF0BunJuHn992AtfMqyEKJ8Dyve+WOeo6luvDqKzCHey2KdC KxzZWJDWbXXEk/+nYVakQ46rEB4A2TzLnPiCKoVULRv8mD+W/ZIgi1krhN+mYrUiwAvU LQxrmlymmqIYEgD1T1Mvav6KabVEidPe9yCRFVlnJgpm3khJV800hmh5Z0LCFXaDBJeB HvgHz5TXb3Mvtx7PnulPkZ6juwM+8CzZE40AlMNT/4s4iOjCOULGiCLEYb4zdj3AJ1CE 5WHw== X-Gm-Message-State: AOAM532vXKp9yoauLdxlxdKBtsbdY7UDY/+LsOHiZTYyFuD70Rn72NCP bUUmVZYAiuy+N+U/yji1tVWKlrdEBCU25gRQyg8= X-Google-Smtp-Source: ABdhPJy6y8VniNbwmMIOoU7RwRwYzrIN3Z8PfE0Fq+Prr4D1B0V/OsFpi82tLiD5BIDc6eUrhcwgYOzjKVvfaC/2Ms0= X-Received: by 2002:a9d:6053:: with SMTP id v19mr2981691otj.362.1597434976086; Fri, 14 Aug 2020 12:56:16 -0700 (PDT) MIME-Version: 1.0 References: <20200813084129.332730-1-josephsih@chromium.org> <20200813164059.v1.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> In-Reply-To: <20200813164059.v1.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 14 Aug 2020 12:56:05 -0700 Message-ID: <CABBYNZJ-nBXeujF2WkMEPYPQhXAphqKCV39gr-QYFdTC3GvjXg@mail.gmail.com> Subject: Re: [PATCH v1 2/2] Bluetooth: sco: expose WBS packet length in socket option To: Joseph Hwang <josephsih@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Joseph Hwang <josephsih@google.com>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.67 / 15.00 / 200.00 X-Rspamd-Queue-Id: 59910420C9 X-Rspamd-UID: 5f48c6 Hi Joseph, On Thu, Aug 13, 2020 at 1:42 AM Joseph Hwang <josephsih@chromium.org> wrote: > > It is desirable to expose the wideband speech packet length via > a socket option to the user space so that the user space can set > the value correctly in configuring the sco connection. > > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > --- > > include/net/bluetooth/bluetooth.h | 2 ++ > net/bluetooth/sco.c | 8 ++++++++ > 2 files changed, 10 insertions(+) > > diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h > index 9125effbf4483d..922cc03143def4 100644 > --- a/include/net/bluetooth/bluetooth.h > +++ b/include/net/bluetooth/bluetooth.h > @@ -153,6 +153,8 @@ struct bt_voice { > > #define BT_SCM_PKT_STATUS 0x03 > > +#define BT_SCO_PKT_LEN 17 > + > __printf(1, 2) > void bt_info(const char *fmt, ...); > __printf(1, 2) > diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c > index dcf7f96ff417e6..97e4e7c7b8cf62 100644 > --- a/net/bluetooth/sco.c > +++ b/net/bluetooth/sco.c > @@ -67,6 +67,7 @@ struct sco_pinfo { > __u32 flags; > __u16 setting; > __u8 cmsg_mask; > + __u32 pkt_len; > struct sco_conn *conn; > }; > > @@ -267,6 +268,8 @@ static int sco_connect(struct sock *sk) > sco_sock_set_timer(sk, sk->sk_sndtimeo); > } > > + sco_pi(sk)->pkt_len = hdev->sco_pkt_len; > + > done: > hci_dev_unlock(hdev); > hci_dev_put(hdev); > @@ -1001,6 +1004,11 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, > err = -EFAULT; > break; > > + case BT_SCO_PKT_LEN: > + if (put_user(sco_pi(sk)->pkt_len, (u32 __user *)optval)) > + err = -EFAULT; > + break; Couldn't we expose this via BT_SNDMTU/BT_RCVMTU? > default: > err = -ENOPROTOOPT; > break; > -- > 2.28.0.236.gb10cc79966-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sH3kGhbvNl/y7wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 22:07:50 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iG5AGRbvNl8+yQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 22:07:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A145C420BA; Fri, 14 Aug 2020 22:07:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726905AbgHNUHg (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 16:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgHNUHg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 16:07:36 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40C61C061385; Fri, 14 Aug 2020 13:07:36 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id r21so8507748ota.10; Fri, 14 Aug 2020 13:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HiYOL/T1huNoqPIDdiz/g4I/4oQL0zNRwFDNOHIA1vU=; b=OjTMQwHr+IuhO5yT3Lfpke+Ef/oxA1iUmTzW9eQjK8CmgwTxrgjaVWSHmC+KMKN1ol ZcnzFRVza9A3CrbMDgrxvQ9U6ucW7IV1fPGg+UxCOs6SwNmu15bkNqI3HlrPzewry3A+ CVk1udcph4o4XseIkDw830SDix1aBBSerOhelOf12p0Gs1mOlkGttK6VlSyphlcWbSEV etlPaY29KybfqgmKRMOurZ8x48LOV9/gBPRpfApDHfgNSXUkrBVFdyoS3TTgGGcyNEbu RmvvUoHXw4VFvsfNwvIBX/mj2nqFFLo5ok3UlKBLH59PE8xWZzfFxV1SXP4hTmX4MM3A P67g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HiYOL/T1huNoqPIDdiz/g4I/4oQL0zNRwFDNOHIA1vU=; b=LMxa0hrUB0yeJfzCPvOW4BTRmJlFD/ebH3Gi3a7wOZgHro3roIUPIyr8Dzzdw6tpOG /SdbmPZrlo9YaMCNcxNTnqN46umk1/DsS6uE1MGL+SuA5MydBWFEKvqFo/A0Sxpbrele DJmBjs6JGXgU54+xK4nModNKM9rTFwPPwaB5fGRUzuPznqSAF0yRiIIK5ItFRwIRqnx7 AHAC6SjrqrhcplT1Xcj+o5cmweHCRCXzWHbuJJsu91fC0Q/xwk4+5spbVPo68jfZB+36 TgHTkW7lC+SjRUoG7y2bHpCw1ed99gWaeYBqAXPL4EO/FLcD5R41NI8kmvNtQTlo0UvF fddg== X-Gm-Message-State: AOAM533zyUvyCzErxdVCel0cAqqqKzmLWC1RVAgRtk82u1m8BhwC7WJp nGHw96yFD6jOhDoiQ3n82u3MmS4w1bxw9m/yZikDVGw5238H1Q== X-Google-Smtp-Source: ABdhPJxN3wN9ulvlSIWvknHDwGRLtdC5dBgL/A0mhtKTxbAQBOS0rGZzcQ2r/gikFIWbAqJ9JqLK9HsZ1Y1ZlpC8kxg= X-Received: by 2002:a9d:24e7:: with SMTP id z94mr3123897ota.91.1597435655540; Fri, 14 Aug 2020 13:07:35 -0700 (PDT) MIME-Version: 1.0 References: <20200813084129.332730-1-josephsih@chromium.org> <20200813164059.v1.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> In-Reply-To: <20200813164059.v1.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 14 Aug 2020 13:07:25 -0700 Message-ID: <CABBYNZ+GPmHuVe_TCUwCVYuOzH8m0=Nmwv48Tn-by_5PnqqwOg@mail.gmail.com> Subject: Re: [PATCH v1 1/2] Bluetooth: btusb: define HCI packet sizes of USB Alts To: Joseph Hwang <josephsih@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Joseph Hwang <josephsih@google.com>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: A145C420BA X-Rspamd-UID: afdf5c Hi Joseph, On Thu, Aug 13, 2020 at 1:42 AM Joseph Hwang <josephsih@chromium.org> wrote: > > It is desirable to define the HCI packet payload sizes of > USB alternate settings so that they can be exposed to user > space. > > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > --- > > drivers/bluetooth/btusb.c | 43 ++++++++++++++++++++++++-------- > include/net/bluetooth/hci_core.h | 1 + > 2 files changed, 33 insertions(+), 11 deletions(-) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index 8d2608ddfd0875..df7cadf6385868 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -459,6 +459,22 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { > #define BTUSB_WAKEUP_DISABLE 14 > #define BTUSB_USE_ALT1_FOR_WBS 15 > > +/* Per core spec 5, vol 4, part B, table 2.1, > + * list the hci packet payload sizes for various ALT settings. > + * This is used to set the packet length for the wideband speech. > + * If a controller does not probe its usb alt setting, the default > + * value will be 0. Any clients at upper layers should interpret it > + * as a default value and set a proper packet length accordingly. > + * > + * To calculate the HCI packet payload length: > + * for alternate settings 1 - 5: > + * hci_packet_size = suggested_max_packet_size * 3 (packets) - > + * 3 (HCI header octets) > + * for alternate setting 6: > + * hci_packet_size = suggested_max_packet_size - 3 (HCI header octets) > + */ > +static const int hci_packet_size_usb_alt[] = { 0, 24, 48, 72, 96, 144, 60 }; > + > struct btusb_data { > struct hci_dev *hdev; > struct usb_device *udev; > @@ -3958,6 +3974,15 @@ static int btusb_probe(struct usb_interface *intf, > hdev->notify = btusb_notify; > hdev->prevent_wake = btusb_prevent_wake; > > + if (id->driver_info & BTUSB_AMP) { > + /* AMP controllers do not support SCO packets */ > + data->isoc = NULL; > + } else { > + /* Interface orders are hardcoded in the specification */ > + data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); > + data->isoc_ifnum = ifnum_base + 1; > + } > + > #ifdef CONFIG_PM > err = btusb_config_oob_wake(hdev); > if (err) > @@ -4021,6 +4046,10 @@ static int btusb_probe(struct usb_interface *intf, > hdev->set_diag = btintel_set_diag; > hdev->set_bdaddr = btintel_set_bdaddr; > hdev->cmd_timeout = btusb_intel_cmd_timeout; > + > + if (btusb_find_altsetting(data, 6)) > + hdev->sco_pkt_len = hci_packet_size_usb_alt[6]; > + > set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); > set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); > set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); > @@ -4062,15 +4091,6 @@ static int btusb_probe(struct usb_interface *intf, > btusb_check_needs_reset_resume(intf); > } > > - if (id->driver_info & BTUSB_AMP) { > - /* AMP controllers do not support SCO packets */ > - data->isoc = NULL; > - } else { > - /* Interface orders are hardcoded in the specification */ > - data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); > - data->isoc_ifnum = ifnum_base + 1; > - } > - > if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) && > (id->driver_info & BTUSB_REALTEK)) { > hdev->setup = btrtl_setup_realtek; > @@ -4082,9 +4102,10 @@ static int btusb_probe(struct usb_interface *intf, > * (DEVICE_REMOTE_WAKEUP) > */ > set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); > - if (btusb_find_altsetting(data, 1)) > + if (btusb_find_altsetting(data, 1)) { > set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); > - else > + hdev->sco_pkt_len = hci_packet_size_usb_alt[1]; > + } else > bt_dev_err(hdev, "Device does not support ALT setting 1"); > } > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h > index 8caac20556b499..0624496328fc09 100644 > --- a/include/net/bluetooth/hci_core.h > +++ b/include/net/bluetooth/hci_core.h > @@ -417,6 +417,7 @@ struct hci_dev { > unsigned int acl_pkts; > unsigned int sco_pkts; > unsigned int le_pkts; > + unsigned int sco_pkt_len; Id use sco_mtu to so the following check actually does what it intended to do: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/net/bluetooth/sco.c#n283 Right now it seems we are using the buffer length as MTU but I think we should actually use the packet length if it is lower than the buffer length, actually it doesn't seems SCO packets can be fragmented so the buffer length must always be big enough to carry a full packet so I assume setting the packet length as conn->mtu will always be correct. > > __u16 block_len; > __u16 block_mtu; > -- > 2.28.0.236.gb10cc79966-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IHmtHSvwNl/+FgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 22:12:27 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gHU0HCvwNl9o4wAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 22:12:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ED284418AF; Fri, 14 Aug 2020 22:12:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727773AbgHNUMV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 16:12:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgHNUMV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 16:12:21 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A48AC061385 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 13:12:21 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id j7so9173833oij.9 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 13:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JGEIRApH5/p8VsQhcxbCoWl1EO+fqrquJVhKDliJ+14=; b=T6BxVt3vew1+fIyQb/pbzntGpUJesqiMxNhyvtCqSK33JYbAaKXfRyeOdgXWF71kGQ IOKPRWG1np+dSUKIdN+NhEXbHwEYuB8CXXchsiDN3sBvwVfiW5DePh7RFZ6mk6rysmPc PpYkEttRc2qfqr6bb8qVnGpcHzZHlCGEYtKA1Fz4i22nD/OnfLoM9jlehgyuDKAf80HW D0lrs57VKYOxI8nzikRL/EF+hg7hHncXIIiNaeiD4p/lZyT7YW5NOCdoqUUAVaYI2znw SAZNPM2CFp+zPkNRUaMQ0a/4SRUEP/sH58Ds5sYRVswCfJldvdWaVY+lb3yfHV90xtPH itPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JGEIRApH5/p8VsQhcxbCoWl1EO+fqrquJVhKDliJ+14=; b=LA2ASTrDvkQCuYM/hWzME96U6tXBz0E6gdvZ8RhF/xOR2xwSfAxgBk3Ir4nV47v15y 1mzt+Ghbf+bXzf5skXykiG6peNTO3vE9xdOJdhXoF/cYhv6V4p6KgDbIBPrs9GqTiVYC W/xnYlnCpMjS2AJP7z1ZJZXj3Jr5TwnvGev1pwfaEk/qt19d/8Fcyln/nSw7MtMkpLPw wn0VdcKV6ORQfTlvVznvmxsr5s00djx9Fsm4GeDRPIxJ3EWx/3D6qUmnGNYnsV7vrriO gFmyyAMfdHvfzkyG+98uB2bHOnXUurromaEji2dC23drORBboEWaSSgzfjofkcfwq17x X1iA== X-Gm-Message-State: AOAM533WdahyDv2dNvvydFF0tN3lHIVsJGsOF/8cEZerD/4FS4iXFKrJ ZdmKmoDOAQi2HQm/1F9HroWjbnmSa+x/bOvAwWzEcXCa X-Google-Smtp-Source: ABdhPJxYJToXsXo2RhBzxWCjVCXfkAtP9ZwDqDsVvZ0aWOcsmv+I32TgiZtzC5B/Q9tf4U2kbpLp1LNXXpc71dhZtlc= X-Received: by 2002:aca:5703:: with SMTP id l3mr2487285oib.48.1597435940117; Fri, 14 Aug 2020 13:12:20 -0700 (PDT) MIME-Version: 1.0 References: <20200812204932.25627-2-tedd.an@linux.intel.com> <5f345e19.1c69fb81.cce10.d6f2@mx.google.com> In-Reply-To: <5f345e19.1c69fb81.cce10.d6f2@mx.google.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 14 Aug 2020 13:12:10 -0700 Message-ID: <CABBYNZ+xikP5s1dBzyHGhJg4JE-Aj8faQtvjUCQJaV1RUnVvrg@mail.gmail.com> Subject: Re: [V2,2/3] tools/btpclientctl: Add btpclient test application To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Cc: Tedd Ho-Jeong An <tedd.an@linux.intel.com>, Marcel Holtmann <marcel@holtmann.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: ED284418AF X-Rspamd-UID: ce0f03 Hi Tedd, Marcel, On Wed, Aug 12, 2020 at 2:27 PM <bluez.test.bot@gmail.com> wrote: > > > This is automated email and please do not reply to this email! > > Dear submitter, > > Thank you for submitting the patches to the linux bluetooth mailing list. > While we are preparing for reviewing the patches, we found the following > issue/warning. > > Test Result: > checkpatch Failed > > Outputs: > WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 > #49: FILE: tools/btpclientctl.c:1: > +/* It might be a good idea to start using SPDX license identifiers though, @Marcel any thoughts on that? > ERROR:FSF_MAILING_ADDRESS: Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. > #67: FILE: tools/btpclientctl.c:19: > + * along with this program; if not, write to the Free Software$ > > ERROR:FSF_MAILING_ADDRESS: Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. > #68: FILE: tools/btpclientctl.c:20: > + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA$ > > WARNING:TYPO_SPELLING: 'arguement' may be misspelled - perhaps 'argument'? > #215: FILE: tools/btpclientctl.c:167: > + bt_shell_printf("Invalid arguement %s\n", argv[1]); > > WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const > #2124: FILE: tools/btpclientctl.c:2076: > +static const char *help[] = { > > - total: 2 errors, 3 warnings, 2175 lines checked > > NOTE: For some of the reported defects, checkpatch may be able to > mechanically convert to the typical style using --fix or --fix-inplace. > > Your patch has style problems, please review. > > NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO > > NOTE: If any of the errors are false positives, please report > them to the maintainer, see CHECKPATCH in MAINTAINERS. > > > > --- > Regards, > Linux Bluetooth -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2IDdI9hmNl8pjgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 12:26:32 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 2P7OIthmNl8hdAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 12:26:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 40AD0A1209; Fri, 14 Aug 2020 12:26:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726297AbgHNK0Y (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 06:26:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726012AbgHNK0Y (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 06:26:24 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73835C061383 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 03:26:24 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id b14so7876537qkn.4 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 03:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=5mWMT1GNug/0Oyb2iDfnCIU7HkUgJEDm49qTfvOMAYE=; b=TmsULxZkdxqS3p+/5VpEC801kKyEOa4biFDkNfBGz2yFGEIyROYZZYcLfsIN03wd/+ xzW0sESEletlDy0nuEoTMPJ80YoWLtkllnsbMCgToFRPINfA0WTcdoiIgZphtMv2LaUc 22aVC5Z9vDksL2zSoP0WeWvdzDV5nHisdwI72TwFQHdmgOudEWDa/bk7DYsexER+5d4K JiAMogYAyryR0W/6YuPmP9uIyRlpaGLJ+OxZYK6JY9eDIxUPzW0sEVGoPtdYxoXbTCxq SlOP8bZBJ30DI4S7UbnIM5ij+cHIso2n6wjNtgI6XqH6sYIqY6e7PlDpKuXHF/mSGwMv Szqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=5mWMT1GNug/0Oyb2iDfnCIU7HkUgJEDm49qTfvOMAYE=; b=gzmIFFVOU/qQKKmlKt/33q7FnrZjuI90dF8cTTeSSPMlQ5n7y/ii8kaQNlI2ysrgOo wiLK3rVl0tJR9BdghXteIJJJYqk67pgVlzNZuRx35Yfb6IxCEbkjgMjDW0pjkyIqYF9k qWTB8MSzBP4ExvJIALrlk0Rl3rjyuZGADYj0WNKRLyoKxMF3eb5X06geq08an7e5SpqP +OmeXLbl9FiSBIYhT2h3Lb78ROuzVQrIeEwFHhp+KsDyw+ekXPyxdCrFAparrtFLYY9U C2h0N6VQxeRoS8Js2MECmNeDA4F07kMH6WqRoMi0A0xcuPdNJk7GqxItySVX+aqSBuPu NCKw== X-Gm-Message-State: AOAM531+94/KerZPjUoOCLRoN1hLl/4CdSGA4EH20x1qwTBzi/SEJMqy HmkbNd5xRLYwfWp9I0tMfTMdQjeJHCOaKA== X-Google-Smtp-Source: ABdhPJwG2pRCon3JYyxXjnzJz484nfFX/2pDTbwl9PmbXrGmGQyZZlrixYtH/daVg9FrM0gESE5E1A== X-Received: by 2002:a05:620a:24e:: with SMTP id q14mr1345565qkn.482.1597400782923; Fri, 14 Aug 2020 03:26:22 -0700 (PDT) Received: from [172.17.0.2] ([52.254.74.102]) by smtp.gmail.com with ESMTPSA id a6sm8434144qka.5.2020.08.14.03.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 03:26:22 -0700 (PDT) Message-ID: <5f3666ce.1c69fb81.4c7cb.1ba3@mx.google.com> Date: Fri, 14 Aug 2020 03:26:22 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3876638814309108230==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, 515672508@qq.com Subject: RE: [BlueZ] adapt:Set property mode failed,memory leak This patch will fix a memory leak,when set property mode,it will send a msg, but if failed,the data'memory do not free Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200814095433.10654-1-515672508@qq.com> References: <20200814095433.10654-1-515672508@qq.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.35 / 15.00 / 200.00 X-Rspamd-Queue-Id: 40AD0A1209 X-Rspamd-UID: 0e054b --===============3876638814309108230== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 1: T1 Title exceeds max length (161>72): "adapt:Set property mode failed,memory leak This patch will fix a memory leak,when set property mode,it will send a msg, but if failed,the data'memory do not free" 3: B6 Body message is missing --- Regards, Linux Bluetooth --===============3876638814309108230==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0NPjE3FnNl8pjgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 12:29:05 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +GHzEXFnNl+nxAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 12:29:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 201E8A12D1; Fri, 14 Aug 2020 12:29:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726812AbgHNK2z (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 06:28:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726735AbgHNK2w (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 06:28:52 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 721B0C061383 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 03:28:51 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id 2so7836263qkf.10 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 03:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=/1MLXCdEu7siuiOtoRF23IoFTdUDvY1mjVcwi3A7tJU=; b=utlT8+NZB2s1duBya1iLjwGVUaSqOy1FAUr044KBpr9ZCx6JUYw3kV7WvrRgVxjiZs +mT1A01tt0AvlvTaheqCiE5xjWWsxzlNIV3MBviQPO6/oXL+hrw2PHhkhqmt31MEcKwg n0WFuTn32N42D1y3evEoQCl/t4og4M27Z2oOiJQv5EKfn/vLiHNpnUyeur1KWOY/Q2QY R0JmBFwTdsYNTMb3vE6XwNJ5NxT7baN2DdEMqM2qxynbOE11P3PviiETw1OlQeaWWW1G EtiYDsLx9sf2YnfuvWVHevmmhXpgGJXjbKefdwJjfJAVab6bZefzBAtxBIlMJ5QLYwnt EWVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=/1MLXCdEu7siuiOtoRF23IoFTdUDvY1mjVcwi3A7tJU=; b=jzzjdbZCe2YqXaFKdrBXsGGtmk+ZHmyduZE1CiQ8o7+sitZ+5B/hygs1kKFI5b/k+/ oQuxf/iNBy3f+8YZp/SR6eb1f1Gg0IMKYVjuDusmzR9b7iLw6vq02t5NsP5WKo2fVNgp ONC53B2ICrXwfgIxTqHdS+7i62wNFvt6al8LryCrHwnRyq8Fm0q0LcVmBE9tkj+ygu0B IL+rr3gjs4eDXLDhf/PC8H5KZkU7bmhxr+Cd0sUHujXEkXiGdEBW9ulBjTEQvdwlqQHb 9FpaGkxHNq7E+ti8DonzxuN1BclGb521Guc+btR9pcNKOS+aopjYfdV7QjyIjwxDiZxr LWDw== X-Gm-Message-State: AOAM533XAsKRLK/Pi4TeZ1PNpyTdktb1hp+MdIVONqnVzcB4xzL195GR 9MJk3/Qct73ZqGHuqlXgczpW5t8sbx22vA== X-Google-Smtp-Source: ABdhPJyodE9G//HQ930auQcMl4tBw/YbK5btfavwnl6EFMPM7a+NjwgDGTJQ+kjuKp6f4r/pII45Iw== X-Received: by 2002:a37:a503:: with SMTP id o3mr1312425qke.162.1597400929578; Fri, 14 Aug 2020 03:28:49 -0700 (PDT) Received: from [172.17.0.2] ([52.254.74.102]) by smtp.gmail.com with ESMTPSA id h20sm8225047qkk.79.2020.08.14.03.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 03:28:49 -0700 (PDT) Message-ID: <5f366761.1c69fb81.53a96.12c8@mx.google.com> Date: Fri, 14 Aug 2020 03:28:49 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============2568234707712340665==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, 515672508@qq.com Subject: RE: [BlueZ] adapt:Set property mode failed,memory leak This patch will fix a memory leak,when set property mode,it will send a msg, but if failed,the data'memory do not free Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200814095433.10654-1-515672508@qq.com> References: <20200814095433.10654-1-515672508@qq.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.20 / 15.00 / 200.00 X-Rspamd-Queue-Id: 201E8A12D1 X-Rspamd-UID: 4631ac --===============2568234707712340665== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnNyYy9hZGFwdGVyLmM6IEluIGZ1bmN0aW9uIOKAmHByb3BlcnR5X3Nl dF9tb2Rl4oCZOgpzcmMvYWRhcHRlci5jOjI5MTk6MjogZXJyb3I6IHRoaXMg4oCYaWbigJkgY2xh dXNlIGRvZXMgbm90IGd1YXJkLi4uIFstV2Vycm9yPW1pc2xlYWRpbmctaW5kZW50YXRpb25dCiAy OTE5IHwgIGlmIChtZ210X3NlbmQoYWRhcHRlci0+bWdtdCwgb3Bjb2RlLCBhZGFwdGVyLT5kZXZf aWQsIGxlbiwgcGFyYW0sCiAgICAgIHwgIF5+CnNyYy9hZGFwdGVyLmM6MjkyMjozOiBub3RlOiAu Li50aGlzIHN0YXRlbWVudCwgYnV0IHRoZSBsYXR0ZXIgaXMgbWlzbGVhZGluZ2x5IGluZGVudGVk IGFzIGlmIGl0IHdlcmUgZ3VhcmRlZCBieSB0aGUg4oCYaWbigJkKIDI5MjIgfCAgIHJldHVybjsK ICAgICAgfCAgIF5+fn5+fgpjYzE6IGFsbCB3YXJuaW5ncyBiZWluZyB0cmVhdGVkIGFzIGVycm9y cwptYWtlWzFdOiAqKiogW01ha2VmaWxlOjkxNjc6IHNyYy9ibHVldG9vdGhkLWFkYXB0ZXIub10g RXJyb3IgMQptYWtlOiAqKiogW01ha2VmaWxlOjQwMTA6IGFsbF0gRXJyb3IgMgoKCgotLS0KUmVn YXJkcywKTGludXggQmx1ZXRvb3RoCg== --===============2568234707712340665==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eDeXBEZsNl8a8QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 12:49:42 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 4Hv2AkZsNl9GQAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 12:49:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0035A420D0; Fri, 14 Aug 2020 12:49:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727807AbgHNKtf (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 06:49:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727064AbgHNKt2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 06:49:28 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60A0FC061384 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 03:49:23 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id v13so7746825oiv.13 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 03:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q1a9PUcYGX9ux4Mfdps7vP428ddbJQAbnf/pLAoi3NE=; b=ML1859OaZObRxKMk/2VNFzxEVwB2nJYUW59jyN7MUugdjW/tQLlKaL2VNn6cDUaYTb p7iVLIVe19Ph3bWbpBplhfZZi2H8OWHh3rHyOnykbNoSnbRxcT8fXdVmNUQlsGCrcxRy ZM+BABJtrx/EHKIqIRkguzj8t+26wsWSQjSB6qf7kJgRg9Wxi9I8OBvCwiIIw/tBxZih XFwxU+Eoqjq7WDNxq47lJNQclz90LAmUBEhX9L5F7viWrQsgZsgJlKmRGEVwxlPA5avw ky804lWqTFS1qUOPL4VKWWjYorStIS7PyfqJIr+e6PrmsD6uv4UoutfJS/KxvGxDzqPp trFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q1a9PUcYGX9ux4Mfdps7vP428ddbJQAbnf/pLAoi3NE=; b=S5rRaot9Hz0h/bo83/fulCPrbcjA3FyI3aIes9EVj6uai5RglT2ZecT6iogTaRujiy swHJM2hiwPlZLQm9mE2tN4w39Cc6LTda+PCpMNhiUEtt1l33umhqDR9RTwwMSGK6RTFf zrp4cMgWs13hgYPfXkYSrx0cSSvu7FijXmimRCnHgGbuirFixo6JEf+qFWpZ56g+jT15 Vg0WaM8uox2cFLzHsk3LLRewzEAZVP0Vaqr11S5Sx2we6bly0yI0b3zHmdUH34d/tUwk ojsE1Z1Yy8qLolj0ysgngk5pd2eKquQYox9c7s4Mnrenc3j9QYRBsE6RxPwn48/DmKLN ufWA== X-Gm-Message-State: AOAM531dwWkKfYu70ZkXJEVNiwnA1rjckSD9t0Jf+ljLMOu8uArqOVbk OINDZCsZfLCeD5unQ8nNS8pQrGzpKemCZr2D755JSMe0xCwsag== X-Google-Smtp-Source: ABdhPJxYZONl/LYYpixLR3pAvv24CKhn7JLDHImieUooe5qgUUa+13VbXPz/RQ3UZYPk20QeAC38ZULW1qBU+QV8/lE= X-Received: by 2002:aca:c38c:: with SMTP id t134mr1110680oif.15.1597402162069; Fri, 14 Aug 2020 03:49:22 -0700 (PDT) MIME-Version: 1.0 References: <edd02903-6460-76c0-7b96-169c15d42699@student.tugraz.at> In-Reply-To: <edd02903-6460-76c0-7b96-169c15d42699@student.tugraz.at> From: Emil Lenngren <emil.lenngren@gmail.com> Date: Fri, 14 Aug 2020 12:49:10 +0200 Message-ID: <CAO1O6sf5WKvFZxzRnRo2UweFSJ-0Z7OkQXyfcu6nc_BTjOGq7w@mail.gmail.com> Subject: Re: [BlueZ] BLE Security Mode 2 Support To: Christian Seifert <christian.seifert@student.tugraz.at> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.16 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0035A420D0 X-Rspamd-UID: b702c1 Hi Christian, Den fre 14 aug. 2020 kl 11:21 skrev Christian Seifert <christian.seifert@student.tugraz.at>: > > Hello, > > i am trying to implement a communication channel that uses BLE Security > Mode 2 Lvl 1 or 2. Both participants that need to communicate are > Raspberry Pi's running Raspberry Pi OS and BlueZ as Bluetooth Stack. The > data i want to send is already encrypted which makes Data Signing > interesting for me. > > Does BlueZ Support BLE Security Mode 2 Lvl 1/2 and if yes how can i > access the functionality? > > Furthermore in my research to find the answer for this question i always > seemed to come across Security Mode 3 mentioned in combination with > BlueZ. Does this simply refer to Security Mode 1 Lvl 3? > > In order to find an answer for this question: I searched the web > rigorously / Tried to find an answer in forums / Read the Documentation > / Tried to read the source code / Checked the archives > > As i found nearly nothing regarding this topic my last resort is to ask > this E-Mail Chain and i would be extremely gratefull if someone would be > able to answer my question or tip me off into the right direction. > > Thank you very much for your time and help in advance! > > Best regards, > Christian Seifert > > PS: Please excuse my poor Translation attempts as English is not my > first language. I will gladly try to rewrite any confusing or misleading > parts in my message if pointed out! I have worked with BLE for around six years and I've never heard of anyone using security mode 2. It seems like it's one of those "wouldn't-it-be-nice-to-have" when they designed this many years ago, without understanding the idea is quite bad when security mode 1 exists which is superior. There are not many benefits of using this over security mode 1. There are more cons: - Data is not being encrypted, only signed. - There's only one single kind of ATT packet that can be signed, the "Signed Write Command", which is then used by GATT "Signed Write Without Response". This means that no read/write requests, notifications/indications or service discovery can be signed. It's therefore not possible to sign anything in the direction from a GATT server to a GATT client. - The signature consists of a 8 bytes CMAC signature followed by a 32-bit message counter. You can therefore only send up to 12 bytes shorter packets for a given MTU. - The signature counter must be updated and stored on flash after every message, and must be preserved across reconnections and reboots. For embedded devices with a limit of write-erase cycles this could potentially be a huge issue. With security mode 1 this doesn't happen as the link layer packet counter is per connection and direction, and can therefore be stored in RAM. - A "MITM hacker" could potentially receive a signed message, disconnect from the sender, and a few days later connect to the intended receiver and deliver the message, without the receiver noticing it has been delayed such a long time (assuming it didn't get any packet with higher counter in the meantime). - Packets can intentionally or unintentionally be dropped, without the receiver noticing that there are missing packets (assuming the Bluetooth stack doesn't expose the counter to the "application"). - It requires a specific API for the application to use (signed writes). With security mode 1 it's the lower layer that encrypts and signes everything and your GATT application can be the same regardless if you're unencrypted or encrypted. - If you implement this in a GATT server and the GATT client doesn't support signed writes, you can't really know or ask the GATT client if it supports signed writes. Even though the CSRK might be transferred during bonding, you can't know if signed writes are actually supported (yes many bluetooth stacks are stupidly made like this). The only benefit as I see it is that it requires 2.5 less round trips than setting up AES-CCM as in security mode 1. Generally the support in different Bluetooth stacks doesn't seem to be that good. For example Nordic Semiconductor's soft device doesn't support security mode 2. It seems the dbus gatt api supports signed writes, by reading the documentation and code. Simply set "type" to "command" when executing a WriteValue. Signed authenticated writes will be used if the characteristic supports it and the link is unencrypted, otherwise normal Write Without Responses will be used. For the GATT server, set the characteristic flags to include "authenticated-signed-writes". I'm not sure how to make the bonding and connection setup to actually use security mode 2 instead of mode 1 though. Security mode 3 doesn't exist for BLE. It exists for Bluetooth classic though, so maybe that's what they're referring to. /Emil Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AJCNIx7fNl8jxQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 20:59:42 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id SPJXIh7fNl+Y1AEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 20:59:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1D2F9A28DD; Fri, 14 Aug 2020 20:59:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727773AbgHNS7g (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 14:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbgHNS7g (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 14:59:36 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAF4AC061385 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 11:59:35 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id x24so8398984otp.3 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 11:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=f9NmrfjmloOjIBZHPMZM+Y6w3bDNQCvO94f8urAGQjQ=; b=uXnhT0ecVqTx4Xo/qctxxvCCVaxdpI1vvezlZ9ZDnlUqFZy5fkr1vWrVM06WGL1Iz0 EDXUTEe7jkeUthaYw5uhDZdQd2gwwhdr4BLz30VF5SHdOZDN9knAP9NkH322/RNATqBM gjI7tTwZM0ZiN1OyNDOx9bPq4I7V+m//+vIy73Ak5Pn6uk9Zr3VYZESE5mCfbku96tT1 DKpomGSbSCKVVlO60JfBqtZKapGbbM49opT7qY1h6lk87oK5pveCI34qRxZjaoUiD9TX oRhPQsL7SZ/pPuldAdBmneVepXI873Wy+ssuq1bRv3eAAe4R9Rd5S7Q0nKmnElFSvoki I90g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=f9NmrfjmloOjIBZHPMZM+Y6w3bDNQCvO94f8urAGQjQ=; b=IRpzOAN5EAGHjJ1ITs8tpfnnkPY25A4BXHCPqglvjPbckp54SadwZPqXapfQbFC+vt UesdFobMKtGqnPgn0NW93tkJK+1OmbgOMyKc+Cc3iLUFnlf+qgdUcpJNL2botflIEOct 6plDw2ClYQGVQ+x5tXqU7vmvk+VBaR2cC5jcwT6Lj2CckSCK2vU6LG8BNr9yK4lsdexU JUdXrG3rFsCbDJNnZc7dVi3gyWVtRFXFsML4opEaOBjGFmMOB1MJ3Ej9RVyUCyksoe3q kOVkk1gfx19lacwJfSoETEysvHb5Lzyfpr7XFXFduJHT7v2YmBm/dhgvuxfIXzNxrUX8 DxWw== X-Gm-Message-State: AOAM531neVGwOj8N2yWSYOq2A6qXT+p7ubMUWIAuOeHQp+tAtfLE9kGu OLzPl/+Dqlj+Qa2tYhsFYn8ddiZlRK3HBK2djQ8= X-Google-Smtp-Source: ABdhPJxuaxXn66br6UualO06iWGRChAzWOopn0ZjnMHf+rtJSiFLvDidoIMrx4qNYcCuqsbxkBlhvDm/eWtd+HQTCFk= X-Received: by 2002:a9d:24e7:: with SMTP id z94mr2915575ota.91.1597431575159; Fri, 14 Aug 2020 11:59:35 -0700 (PDT) MIME-Version: 1.0 References: <20200812121946.Bluez.v1.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> In-Reply-To: <20200812121946.Bluez.v1.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 14 Aug 2020 11:59:25 -0700 Message-ID: <CABBYNZKUDn-gWfkZzH4kO5c6kRNMomH9-o8XHJ_Lv+7ujrMNrw@mail.gmail.com> Subject: Re: [Bluez PATCH v1] input: Don't browse SDP if HIDSDPDisable is set To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.66 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1D2F9A28DD X-Rspamd-UID: fadd3a Hi Archie, On Tue, Aug 11, 2020 at 9:21 PM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > According to the HID1.1 spec, part 5.3.4.9: > The HIDSDPDisable attribute is a Boolean value, which indicates > whether connection to the SDP channel and Control or Interrupt > channels are mutually exclusive. This feature supports Bluetooth > HID devices that have minimal resources, and multiplex those > resources between servicing the initialization (SDP) and runtime > (Control and Interrupt) channels. > > However, Bluez still tries to connect SDP upon HID connection, > regardless of the existence of the HIDSDPDisable attribute. > > This patch prevents the connection of SDP after HID has been > established, if the device has HIDSDPDisable attribute. > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > --- > > profiles/input/device.c | 2 ++ > src/device.c | 8 +++++++- > src/device.h | 1 + > 3 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/profiles/input/device.c b/profiles/input/device.c > index 6ec0a4c63..fac8c6896 100644 > --- a/profiles/input/device.c > +++ b/profiles/input/device.c > @@ -1373,6 +1373,8 @@ static struct input_device *input_device_new(struct btd_service *service) > /* Initialize device properties */ > extract_hid_props(idev, rec); > > + device_set_skip_passive_sdp_discovery(device, idev->disable_sdp); Shouldn't you actually be checking for the presence of HIDSDPDisable, I suppose the first time when you pair with it the SDP must be active in order for us to be able to probe the drivers, then once we get the SDP records stored we should inhibit the refresh of the records. > return idev; > } > > diff --git a/src/device.c b/src/device.c > index 2237a7670..a67787a2d 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -195,6 +195,7 @@ struct btd_device { > bool le; > bool pending_paired; /* "Paired" waiting for SDP */ > bool svc_refreshed; > + bool skip_passive_sdp_discovery; > > /* Manage whether this device can wake the system from suspend. > * - wake_support: Requires a profile that supports wake (i.e. HID) > @@ -1472,6 +1473,10 @@ static gboolean dev_property_wake_allowed_exist( > return device_get_wake_support(device); > } > > +void device_set_skip_passive_sdp_discovery(struct btd_device *dev, bool skip) > +{ > + dev->skip_passive_sdp_discovery = skip; > +} > > static gboolean disconnect_all(gpointer user_data) > { > @@ -1805,7 +1810,8 @@ done: > btd_error_failed(dev->connect, strerror(-err))); > } else { > /* Start passive SDP discovery to update known services */ > - if (dev->bredr && !dev->svc_refreshed) > + if (dev->bredr && !dev->svc_refreshed && > + !dev->skip_passive_sdp_discovery) > device_browse_sdp(dev, NULL); > g_dbus_send_reply(dbus_conn, dev->connect, DBUS_TYPE_INVALID); > } > diff --git a/src/device.h b/src/device.h > index cb8d884e8..5348d2652 100644 > --- a/src/device.h > +++ b/src/device.h > @@ -145,6 +145,7 @@ void device_set_wake_override(struct btd_device *device, bool wake_override); > void device_set_wake_allowed(struct btd_device *device, bool wake_allowed, > guint32 id); > void device_set_wake_allowed_complete(struct btd_device *device); > +void device_set_skip_passive_sdp_discovery(struct btd_device *dev, bool skip); > > typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal, > void *user_data); > -- > 2.28.0.236.gb10cc79966-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WFdyFTTgNl8kogEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 21:04:20 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id uP0wFDTgNl+JyAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 21:04:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 29E66420B7; Fri, 14 Aug 2020 21:04:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726897AbgHNTEP (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 15:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726593AbgHNTEO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 15:04:14 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23718C061385 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 12:04:14 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id i92so5967847pje.0 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 12:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Sym/AmXhI2hFDD6PNhYTvYIW04BDHmyuqhnUhFDB198=; b=In8sZKHdSEbhLPcwRUfe7iXD7g6GuOB752EKkJMSV9iP16ltG3sgfA9O+Yaof7JYU0 yIsj305aKFhCEDRAxvT62nvMk3XlW7dr13kW4pGUOmCWjUs1JoeEDpbefG5xA4XNpmlF 97ez5sKMlF9hA/7UR2rKBmR+zGpcmRmkXBiz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Sym/AmXhI2hFDD6PNhYTvYIW04BDHmyuqhnUhFDB198=; b=Bzj9Yp6s7EzhKR2tahTb9MOv7++18UlcQQxj8TaT4PO+opwhmGvyfhqxTND6at3g7y t5TvNYVgQ5xhojqZXy/kzRXTytBE0oLceXDUk0slEwYsTAOnTPP/lv2L5TRFuSut+WEL vfrLYi7ZrhQXB6aCdwNWnGXtMmwzNeOgJYbftIcQb9xRCzE+AFnD63XZv9XlDtI23o4c XZ1fWvvYoo69cevjWNJHWse8eXHt0T1QWuS43pIdoWzZ+Hh4zsT0TZDn7UIY+tGkk/yj ay/d8Gqprm4BjJXPE7ZjyRJwSkiafnoxg7reS2XjZpVgNHelPUdFjFwktufRHDtBkxxU mioQ== X-Gm-Message-State: AOAM531LRqF2EQojYkBC/i3lHFwOqWBmpc7uqQYpJDTnKu6RXUdPYlO8 /gXgtbes47GOSvHoOuPjQ4tG9FJa4RKggw== X-Google-Smtp-Source: ABdhPJwMK/6lUhSpFQ4BPd/LzqydFyN1Vx3qtTOaHsE0hZwfzmqu7dffcBqXlPfC/RZcHSUr/Azigw== X-Received: by 2002:a17:90a:216a:: with SMTP id a97mr3353255pje.144.1597431853192; Fri, 14 Aug 2020 12:04:13 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id z2sm10125840pfq.46.2020.08.14.12.04.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Aug 2020 12:04:12 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org> Subject: [PATCH] Bluetooth: Fix auto-creation of hci_conn at Conn Complete event Date: Fri, 14 Aug 2020 12:04:06 -0700 Message-Id: <20200814190406.361415-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 29E66420B7 X-Rspamd-UID: bca121 Currently the code auto-creates hci_conn only if the remote address has been discovered before. This may not be the case. For example, the remote device may trigger connection after reboot at already-paired state so there is no inquiry result found, but it is still correct to create the hci_conn when Connection Complete event is received. A better guard is to check against bredr allowlist. Devices in the allowlist have been given permission to auto-connect. Fixes: 4f40afc6c764 ("Bluetooth: Handle BR/EDR devices during suspend") Signed-off-by: Sonny Sasaka <sonnysasaka@chromium.org> --- net/bluetooth/hci_event.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 33d8458fdd4a..6b83da1790ee 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2566,7 +2566,6 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_ev_conn_complete *ev = (void *) skb->data; - struct inquiry_entry *ie; struct hci_conn *conn; BT_DBG("%s", hdev->name); @@ -2575,13 +2574,19 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); if (!conn) { - /* Connection may not exist if auto-connected. Check the inquiry - * cache to see if we've already discovered this bdaddr before. - * If found and link is an ACL type, create a connection class + /* Connection may not exist if auto-connected. Check the bredr + * allowlist to see if this device is allowed to auto connect. + * If link is an ACL type, create a connection class * automatically. + * + * Auto-connect will only occur if the event filter is + * programmed with a given address. Right now, event filter is + * only used during suspend. */ - ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); - if (ie && ev->link_type == ACL_LINK) { + if (ev->link_type == ACL_LINK && + hci_bdaddr_list_lookup_with_flags(&hdev->whitelist, + &ev->bdaddr, + BDADDR_BREDR)) { conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, HCI_ROLE_SLAVE); if (!conn) { -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OJsxAGLhNl/20wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 21:09:22 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id kERfOmHhNl+JyAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 21:09:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4F047420B7; Fri, 14 Aug 2020 21:09:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727920AbgHNTJQ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 15:09:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbgHNTJP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 15:09:15 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DC54C061385 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 12:09:15 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id u20so5016648pfn.0 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 12:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dPKm4oa2dN1Vf5/ovK5Iqwbq1EaqjYUe9CdiX1HO9dI=; b=cxr1uYhkmPFKReP0IqFfPTtHZbZEpvhzHU+z/er4B/I/bSmzdLha1Td+kiyGooZC6q EkJX55wRwyRMIvyOC+DgGtgVqZ70BDD69OvHTGX2npQlkn+T0BGUZD1cPoUd++31gN/q l/IDLVXuDEQsg9VN4PxqQ/56fCpN+AWGBBQ+w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dPKm4oa2dN1Vf5/ovK5Iqwbq1EaqjYUe9CdiX1HO9dI=; b=H9dWHgJ6KUGo+F5gyEFYcn7ed3lN7AJjTsUZMLhiewCleu2vHpLhqoTQTlHuCLZgF0 TYplXwIvy2+HAU4W0hI2JrT8gntJOXY0k9PWdNV3VU587gBfb1uQQqi/eO/D4urmn67U sKdIQERzXUKpy0+k65YDct8Wh8gJxXUKxkv4ii+pq7ZjrKQsfFTKTZL6wVWYyTOxqaJj abp2D7jP7dup9yxia1gcIrYzs7QcyKMIIQHCCR35HvZdWanOpm2/XgRH8TFu7mFo2DPe sZ6uh4RAerMn7oJYPVbE9ee6/ubzrbe8B7cSGaMD1n1uhwrAmSgkJKSDoiRVYTMZVlnD Ib8w== X-Gm-Message-State: AOAM530UM6mhEig4EPfPGf66AGxsHoJcf9FPjPgwt0HOFV4SxvRjPblS y4R65wlAkYaR8PsqNxYxSmgzJIw4eSJIDA== X-Google-Smtp-Source: ABdhPJwAx4bCFH/vqzup+Sj+BRBqFZHnwKEeyz5teB1/b5fUS7SSusWqHlqAsbCp3d38f6r1HleOfw== X-Received: by 2002:a62:ea01:: with SMTP id t1mr2789546pfh.125.1597432154796; Fri, 14 Aug 2020 12:09:14 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id f17sm10223112pfq.67.2020.08.14.12.09.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Aug 2020 12:09:14 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [PATCH v2] Bluetooth: Fix auto-creation of hci_conn at Conn Complete event Date: Fri, 14 Aug 2020 12:09:09 -0700 Message-Id: <20200814190909.361764-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4F047420B7 X-Rspamd-UID: 053dae Currently the code auto-creates hci_conn only if the remote address has been discovered before. This may not be the case. For example, the remote device may trigger connection after reboot at already-paired state so there is no inquiry result found, but it is still correct to create the hci_conn when Connection Complete event is received. A better guard is to check against bredr allowlist. Devices in the allowlist have been given permission to auto-connect. Fixes: 4f40afc6c764 ("Bluetooth: Handle BR/EDR devices during suspend") Signed-off-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- net/bluetooth/hci_event.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 33d8458fdd4a..6b83da1790ee 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2566,7 +2566,6 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_ev_conn_complete *ev = (void *) skb->data; - struct inquiry_entry *ie; struct hci_conn *conn; BT_DBG("%s", hdev->name); @@ -2575,13 +2574,19 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); if (!conn) { - /* Connection may not exist if auto-connected. Check the inquiry - * cache to see if we've already discovered this bdaddr before. - * If found and link is an ACL type, create a connection class + /* Connection may not exist if auto-connected. Check the bredr + * allowlist to see if this device is allowed to auto connect. + * If link is an ACL type, create a connection class * automatically. + * + * Auto-connect will only occur if the event filter is + * programmed with a given address. Right now, event filter is + * only used during suspend. */ - ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); - if (ie && ev->link_type == ACL_LINK) { + if (ev->link_type == ACL_LINK && + hci_bdaddr_list_lookup_with_flags(&hdev->whitelist, + &ev->bdaddr, + BDADDR_BREDR)) { conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, HCI_ROLE_SLAVE); if (!conn) { -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MKA1MWziNl9q2AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 21:13:48 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +Od8L2ziNl+JyAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 21:13:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AD910418AF; Fri, 14 Aug 2020 21:13:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727957AbgHNTNn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 15:13:43 -0400 Received: from mga07.intel.com ([134.134.136.100]:2112 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726652AbgHNTNn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 15:13:43 -0400 IronPort-SDR: z3XemW9hYiGKrHgEB5aSKGWEXKQ2gudejEbXDi+1beMHBsYrQVXvgo9gTA7e8+Em0LjZy53KvL rcO4Ddq+lDhw== X-IronPort-AV: E=McAfee;i="6000,8403,9713"; a="218806298" X-IronPort-AV: E=Sophos;i="5.76,313,1592895600"; d="scan'208";a="218806298" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2020 12:13:42 -0700 IronPort-SDR: Z+GmXw5H+Vnec/Y3umde71aF80CRFaJ7rSCcuRL56QkhSVeebWE0P9y8lqDKfPKECIE89YZOO/ ZtyOcrKrlFyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,313,1592895600"; d="scan'208";a="327983431" Received: from bgi1-mobl2.amr.corp.intel.com ([10.255.85.168]) by fmsmga002.fm.intel.com with ESMTP; 14 Aug 2020 12:13:42 -0700 From: Brian Gix <brian.gix@intel.com> To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@gmail.com, Brian Gix <brian.gix@intel.com> Subject: [PATCH BlueZ] mesh: fix double-free of outbound tx data Date: Fri, 14 Aug 2020 12:13:39 -0700 Message-Id: <20200814191339.955528-1-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: AD910418AF X-Rspamd-UID: 0a0153 Due to the asyncronous multi-step process to send a packet on an HCI socket, an outbound packet could be superceded before send procedure is completed. This change ensures that at any stage in the process, that the pointer to the packet has been fully disposed. --- mesh/mesh-io-generic.c | 52 +++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c index 4b26b1181..67b13a1b9 100644 --- a/mesh/mesh-io-generic.c +++ b/mesh/mesh-io-generic.c @@ -329,6 +329,30 @@ static void scan_disable_rsp(const void *buf, uint8_t size, set_recv_scan_enable, pvt, NULL); } +static bool simple_match(const void *a, const void *b) +{ + return a == b; +} + +static bool find_by_ad_type(const void *a, const void *b) +{ + const struct tx_pkt *tx = a; + uint8_t ad_type = L_PTR_TO_UINT(b); + + return !ad_type || ad_type == tx->pkt[0]; +} + +static bool find_by_pattern(const void *a, const void *b) +{ + const struct tx_pkt *tx = a; + const struct tx_pattern *pattern = b; + + if (tx->len < pattern->len) + return false; + + return (!memcmp(tx->pkt, pattern->data, pattern->len)); +} + static bool find_active(const void *a, const void *b) { const struct pvt_rx_reg *rx_reg = a; @@ -533,8 +557,10 @@ static void set_send_adv_data(const void *buf, uint8_t size, &cmd, sizeof(cmd), set_send_adv_enable, pvt, NULL); done: - if (tx->delete) + if (tx->delete) { + l_queue_remove_if(pvt->tx_pkts, simple_match, tx); l_free(tx); + } pvt->tx = NULL; } @@ -569,8 +595,11 @@ static void send_pkt(struct mesh_io_private *pvt, struct tx_pkt *tx, { struct bt_hci_cmd_le_set_adv_enable cmd; - if (pvt->tx && pvt->tx->delete) + /* Delete superseded packet in favor of new packet */ + if (pvt->tx && pvt->tx != tx && pvt->tx->delete) { + l_queue_remove_if(pvt->tx_pkts, simple_match, pvt->tx); l_free(pvt->tx); + } pvt->tx = tx; pvt->interval = interval; @@ -733,25 +762,6 @@ static bool send_tx(struct mesh_io *io, struct mesh_io_send_info *info, return true; } -static bool find_by_ad_type(const void *a, const void *b) -{ - const struct tx_pkt *tx = a; - uint8_t ad_type = L_PTR_TO_UINT(b); - - return !ad_type || ad_type == tx->pkt[0]; -} - -static bool find_by_pattern(const void *a, const void *b) -{ - const struct tx_pkt *tx = a; - const struct tx_pattern *pattern = b; - - if (tx->len < pattern->len) - return false; - - return (!memcmp(tx->pkt, pattern->data, pattern->len)); -} - static bool tx_cancel(struct mesh_io *io, const uint8_t *data, uint8_t len) { struct mesh_io_private *pvt = io->pvt; -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gP/EFTrkNl+R3QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 21:21:30 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 0EckFDrkNl92aAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 21:21:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 058B1420C4; Fri, 14 Aug 2020 21:21:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728137AbgHNTVO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 15:21:14 -0400 Received: from mga17.intel.com ([192.55.52.151]:13702 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbgHNTVK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 15:21:10 -0400 IronPort-SDR: bvM9jGbroV69AGdDVl+sjhZ8IyeaF50V+8qRiu2MgwFbH1J8lU02Q5Nn6KUn8obJZMNuiolE/5 YBvGCR125z8w== X-IronPort-AV: E=McAfee;i="6000,8403,9713"; a="134542258" X-IronPort-AV: E=Sophos;i="5.76,313,1592895600"; d="scan'208";a="134542258" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2020 12:21:04 -0700 IronPort-SDR: TPlx6sB/KvdPA18U7Xl6nhrnAKKgCvvNjlmbOgNr6WdSvJHPB1fdsgJIyjmC4OVvuciWJBnOVl 4m8F12IXifkg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,313,1592895600"; d="scan'208";a="309468116" Received: from orsmsx601-2.jf.intel.com (HELO ORSMSX601.amr.corp.intel.com) ([10.22.229.81]) by orsmga002.jf.intel.com with ESMTP; 14 Aug 2020 12:21:04 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 14 Aug 2020 12:21:04 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 14 Aug 2020 12:21:04 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.170) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 14 Aug 2020 12:20:59 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZH2v0PKRf+420OpPA0uDz5I+tTtsqttEQDlGWW+WMX7qK1PoZo5ICIr4g2bZSOqWcavxRcF2eMHJi/Sy5d/SFyM9zu8jA97AtQkK6YF0htEvrdmsq3Xv8Su4VQjnKgjwV6jHNaoH+vDc9snfgAhkoHUcDH79LZCaGmB65nZpoSJWUio0FPMOPozttXG0O1kC6gc1TAAmTPti5xfLUjt2cJaLtcPoFTT2VVioToX8Op08mkbDfkH69z27PRhX+yAEE0FdnlWTsmYzOutuCgUOLGMIdlFBy7U89TvMI56TIFO++Y2IzDgZlbYryLYs8GoeZgikis6j7JFcPIfV+sgdCw== 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-SenderADCheck; bh=MrMR+e2YXAHVOAwZBoSK6aDhWcjxWTLkKfMR6eA4xoY=; b=L1yBnOznW8a0djXaGIqhB2SdZ8Gw1YDYwBIiWzigvZ6wzDjF3fLvI2Sk1Xu+DVJd014kWY2EcUTqCir+tc+uACURIrMg4kj7CSExNbnlVjL2+QpOiFKFjL6ye82IglrtTaXCjVuka9PaI+mSOuWfsiM7P5mv4yYDIit2Pvbe9tUtQhXlenDhvcq8Ttp4/QTEC8np6hcNKAGRSk8+fNN6pblMKectz9pylefd+t9AJrgsnhRwh6W0uFwOj9QRRS253/A61E8DQizwdWg3Q/8YP470eXIUXlqMs6e2srlWRsYNKNKfoSDRh9QlhGg9sC9xRTdxhky2QX0QieAnxWyJjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MrMR+e2YXAHVOAwZBoSK6aDhWcjxWTLkKfMR6eA4xoY=; b=f8asNupISmmk8xCLBdijvcV7Gss5ex24opb4WRiw6VpC+4x3dcXjpmmoIC++rLaurqurWbhzB9/XkYGFm8mqg3Mv5xZE26u11uPpExQhrcSCsfzdLDJOyQI53851m7mfr1yWAnbtLjdiIyHtTTymAYQHsx1DqzTJcNv8tdw47Bk= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1487.namprd11.prod.outlook.com (2603:10b6:301:b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15; Fri, 14 Aug 2020 19:20:57 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3283.015; Fri, 14 Aug 2020 19:20:57 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> CC: "brian.gix@gmail.com" <brian.gix@gmail.com>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: fix double-free of outbound tx data Thread-Topic: [PATCH BlueZ] mesh: fix double-free of outbound tx data Thread-Index: AQHWcm8LUWsrR6ccTU6US6EW6xm9jKk3+zMA Date: Fri, 14 Aug 2020 19:20:57 +0000 Message-ID: <251b18820d7fe8960efae2df2ba185d7e9e59622.camel@intel.com> References: <20200814191339.955528-1-brian.gix@intel.com> In-Reply-To: <20200814191339.955528-1-brian.gix@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1ffa0cd1-099b-4475-afcc-08d840872bc4 x-ms-traffictypediagnostic: MWHPR11MB1487: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR11MB14876301FBC10D779193BC42E1400@MWHPR11MB1487.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Xr6Qm1eUvS+igLnX0f0EabCPp8A7lDdXqwqG5XS0easd+L9R7T147fPhS/m238DF7vcx57h+Kw67cMcto9w/0tBE0kZopp2UbUYQDD+FYEjm0p+1Fpfvs238/oWfRzKQnY9RTaMWoIx+8/TbCdlkjQyudPoKkBPAM4xCWDSYmUACIa3u359JoT7FeF1wrF4iHr9vdha1PI5n6TZobHc3bLJYzN+RM/yKcxIi68TXqGYUs3i4U3ghR9nwotWWGtiav9JG1Fpd6Z7STqP1owr81smLp19i9EhBL2ap4E/XzBXisZAn9P7RtSdgkJFxbWDGuc1S/sQWxjarMVddPniCzg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(346002)(136003)(366004)(39860400002)(6506007)(76116006)(107886003)(478600001)(66476007)(6916009)(83380400001)(86362001)(66446008)(64756008)(316002)(6486002)(66556008)(66946007)(8676002)(91956017)(8936002)(6512007)(36756003)(186003)(4326008)(5660300002)(2616005)(54906003)(71200400001)(2906002)(26005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: pKEEF6iTfrNxlqfaFoiOGI7CTvU0UJyAJp3ZPpyxn3k8iycNsrcdDgxphTXvqe8TB1KlNXOxvjMBWwLU6d5l/Hw4qF9albBqXhjeYY4uFLVztjRt9O1QsB7tm4JCNBu+XzK0mq5689Ia3PLDK8ipQ8f4i9JHGlTE5eLvxCaUKovqaJMwxqs3jEC1jjkP8a1wmRoA57p74EIOHEQixU/zR9gP+Cu79xWZO9Nd8DWJnR8SkGt1aIXEqB7RtnZCrG4I2vFeH28BUMAS7ISeG5aJivW6GIRKCxa89ed54Mg0T9GYlaJyG0C3jrp2hX0cvGWnsz+4hKrsTDY9ybnRR4ooJQAiZfnRLoy0nr3z1W9G6jKNz8Tf5FCezhQsPSVcIebSz/yCS+6JpweoQXd7O0uun8WYt0QWB/+e4YZOtEEKj6dBkVyz1cB1SREBA16Rhc5Rxf/O0wi4a5Vau/WplITlyt8e/G2at/V3ObTrv9SJwO7Frbi8HaksCW2/CtBiMLUwyteZ2pD7V93wrxODa4B4xci6dIfC6rG1ctFgxmnTwNCB0q6lSzBHi6do0VUXMbbkLdFDOPFR2mqZPsi8475p5VHt1fx8Ai3PYrbYXe10HRLZ4LlfWVq58KKnfaOeKWuBBlk7LFynYQbBsDe9rYoWKg== Content-Type: text/plain; charset="utf-8" Content-ID: <07B75A2BC77D4D42AC1B26E1F8CEA964@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ffa0cd1-099b-4475-afcc-08d840872bc4 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Aug 2020 19:20:57.0763 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: QW266y6qa4orBTPNSc4FQoVBNiQ033ymXuMpaBRlMeNmPiZPfJNdlBs/K9fLfPGRjcTNqlCu2lYWyFX/tarzOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1487 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.94 / 15.00 / 200.00 X-Rspamd-Queue-Id: 058B1420C4 X-Rspamd-UID: f28df7 QXBwbGllZA0KT24gRnJpLCAyMDIwLTA4LTE0IGF0IDEyOjEzIC0wNzAwLCBCcmlhbiBHaXggd3Jv dGU6DQo+IER1ZSB0byB0aGUgYXN5bmNyb25vdXMgbXVsdGktc3RlcCBwcm9jZXNzIHRvIHNlbmQg YSBwYWNrZXQgb24gYW4gSENJDQo+IHNvY2tldCwgYW4gb3V0Ym91bmQgcGFja2V0IGNvdWxkIGJl IHN1cGVyY2VkZWQgYmVmb3JlIHNlbmQgcHJvY2VkdXJlDQo+IGlzIGNvbXBsZXRlZC4gIFRoaXMg Y2hhbmdlIGVuc3VyZXMgdGhhdCBhdCBhbnkgc3RhZ2UgaW4gdGhlIHByb2Nlc3MsDQo+IHRoYXQg dGhlIHBvaW50ZXIgdG8gdGhlIHBhY2tldCBoYXMgYmVlbiBmdWxseSBkaXNwb3NlZC4NCj4gLS0t DQo+ICBtZXNoL21lc2gtaW8tZ2VuZXJpYy5jIHwgNTIgKysrKysrKysrKysrKysrKysrKysrKysr Ky0tLS0tLS0tLS0tLS0tLS0tDQo+ICAxIGZpbGUgY2hhbmdlZCwgMzEgaW5zZXJ0aW9ucygrKSwg MjEgZGVsZXRpb25zKC0pDQo+IA0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9tZXNoLWlvLWdlbmVyaWMu YyBiL21lc2gvbWVzaC1pby1nZW5lcmljLmMNCj4gaW5kZXggNGIyNmIxMTgxLi42N2IxM2ExYjkg MTAwNjQ0DQo+IC0tLSBhL21lc2gvbWVzaC1pby1nZW5lcmljLmMNCj4gKysrIGIvbWVzaC9tZXNo LWlvLWdlbmVyaWMuYw0KPiBAQCAtMzI5LDYgKzMyOSwzMCBAQCBzdGF0aWMgdm9pZCBzY2FuX2Rp c2FibGVfcnNwKGNvbnN0IHZvaWQgKmJ1ZiwgdWludDhfdCBzaXplLA0KPiAgCQkJc2V0X3JlY3Zf c2Nhbl9lbmFibGUsIHB2dCwgTlVMTCk7DQo+ICB9DQo+ICANCj4gK3N0YXRpYyBib29sIHNpbXBs ZV9tYXRjaChjb25zdCB2b2lkICphLCBjb25zdCB2b2lkICpiKQ0KPiArew0KPiArCXJldHVybiBh ID09IGI7DQo+ICt9DQo+ICsNCj4gK3N0YXRpYyBib29sIGZpbmRfYnlfYWRfdHlwZShjb25zdCB2 b2lkICphLCBjb25zdCB2b2lkICpiKQ0KPiArew0KPiArCWNvbnN0IHN0cnVjdCB0eF9wa3QgKnR4 ID0gYTsNCj4gKwl1aW50OF90IGFkX3R5cGUgPSBMX1BUUl9UT19VSU5UKGIpOw0KPiArDQo+ICsJ cmV0dXJuICFhZF90eXBlIHx8IGFkX3R5cGUgPT0gdHgtPnBrdFswXTsNCj4gK30NCj4gKw0KPiAr c3RhdGljIGJvb2wgZmluZF9ieV9wYXR0ZXJuKGNvbnN0IHZvaWQgKmEsIGNvbnN0IHZvaWQgKmIp DQo+ICt7DQo+ICsJY29uc3Qgc3RydWN0IHR4X3BrdCAqdHggPSBhOw0KPiArCWNvbnN0IHN0cnVj dCB0eF9wYXR0ZXJuICpwYXR0ZXJuID0gYjsNCj4gKw0KPiArCWlmICh0eC0+bGVuIDwgcGF0dGVy bi0+bGVuKQ0KPiArCQlyZXR1cm4gZmFsc2U7DQo+ICsNCj4gKwlyZXR1cm4gKCFtZW1jbXAodHgt PnBrdCwgcGF0dGVybi0+ZGF0YSwgcGF0dGVybi0+bGVuKSk7DQo+ICt9DQo+ICsNCj4gIHN0YXRp YyBib29sIGZpbmRfYWN0aXZlKGNvbnN0IHZvaWQgKmEsIGNvbnN0IHZvaWQgKmIpDQo+ICB7DQo+ ICAJY29uc3Qgc3RydWN0IHB2dF9yeF9yZWcgKnJ4X3JlZyA9IGE7DQo+IEBAIC01MzMsOCArNTU3 LDEwIEBAIHN0YXRpYyB2b2lkIHNldF9zZW5kX2Fkdl9kYXRhKGNvbnN0IHZvaWQgKmJ1ZiwgdWlu dDhfdCBzaXplLA0KPiAgCQkJCQkmY21kLCBzaXplb2YoY21kKSwNCj4gIAkJCQkJc2V0X3NlbmRf YWR2X2VuYWJsZSwgcHZ0LCBOVUxMKTsNCj4gIGRvbmU6DQo+IC0JaWYgKHR4LT5kZWxldGUpDQo+ ICsJaWYgKHR4LT5kZWxldGUpIHsNCj4gKwkJbF9xdWV1ZV9yZW1vdmVfaWYocHZ0LT50eF9wa3Rz LCBzaW1wbGVfbWF0Y2gsIHR4KTsNCj4gIAkJbF9mcmVlKHR4KTsNCj4gKwl9DQo+ICANCj4gIAlw dnQtPnR4ID0gTlVMTDsNCj4gIH0NCj4gQEAgLTU2OSw4ICs1OTUsMTEgQEAgc3RhdGljIHZvaWQg c2VuZF9wa3Qoc3RydWN0IG1lc2hfaW9fcHJpdmF0ZSAqcHZ0LCBzdHJ1Y3QgdHhfcGt0ICp0eCwN Cj4gIHsNCj4gIAlzdHJ1Y3QgYnRfaGNpX2NtZF9sZV9zZXRfYWR2X2VuYWJsZSBjbWQ7DQo+ICAN Cj4gLQlpZiAocHZ0LT50eCAmJiBwdnQtPnR4LT5kZWxldGUpDQo+ICsJLyogRGVsZXRlIHN1cGVy c2VkZWQgcGFja2V0IGluIGZhdm9yIG9mIG5ldyBwYWNrZXQgKi8NCj4gKwlpZiAocHZ0LT50eCAm JiBwdnQtPnR4ICE9IHR4ICYmIHB2dC0+dHgtPmRlbGV0ZSkgew0KPiArCQlsX3F1ZXVlX3JlbW92 ZV9pZihwdnQtPnR4X3BrdHMsIHNpbXBsZV9tYXRjaCwgcHZ0LT50eCk7DQo+ICAJCWxfZnJlZShw dnQtPnR4KTsNCj4gKwl9DQo+ICANCj4gIAlwdnQtPnR4ID0gdHg7DQo+ICAJcHZ0LT5pbnRlcnZh bCA9IGludGVydmFsOw0KPiBAQCAtNzMzLDI1ICs3NjIsNiBAQCBzdGF0aWMgYm9vbCBzZW5kX3R4 KHN0cnVjdCBtZXNoX2lvICppbywgc3RydWN0IG1lc2hfaW9fc2VuZF9pbmZvICppbmZvLA0KPiAg CXJldHVybiB0cnVlOw0KPiAgfQ0KPiAgDQo+IC1zdGF0aWMgYm9vbCBmaW5kX2J5X2FkX3R5cGUo Y29uc3Qgdm9pZCAqYSwgY29uc3Qgdm9pZCAqYikNCj4gLXsNCj4gLQljb25zdCBzdHJ1Y3QgdHhf cGt0ICp0eCA9IGE7DQo+IC0JdWludDhfdCBhZF90eXBlID0gTF9QVFJfVE9fVUlOVChiKTsNCj4g LQ0KPiAtCXJldHVybiAhYWRfdHlwZSB8fCBhZF90eXBlID09IHR4LT5wa3RbMF07DQo+IC19DQo+ IC0NCj4gLXN0YXRpYyBib29sIGZpbmRfYnlfcGF0dGVybihjb25zdCB2b2lkICphLCBjb25zdCB2 b2lkICpiKQ0KPiAtew0KPiAtCWNvbnN0IHN0cnVjdCB0eF9wa3QgKnR4ID0gYTsNCj4gLQljb25z dCBzdHJ1Y3QgdHhfcGF0dGVybiAqcGF0dGVybiA9IGI7DQo+IC0NCj4gLQlpZiAodHgtPmxlbiA8 IHBhdHRlcm4tPmxlbikNCj4gLQkJcmV0dXJuIGZhbHNlOw0KPiAtDQo+IC0JcmV0dXJuICghbWVt Y21wKHR4LT5wa3QsIHBhdHRlcm4tPmRhdGEsIHBhdHRlcm4tPmxlbikpOw0KPiAtfQ0KPiAtDQo+ ICBzdGF0aWMgYm9vbCB0eF9jYW5jZWwoc3RydWN0IG1lc2hfaW8gKmlvLCBjb25zdCB1aW50OF90 ICpkYXRhLCB1aW50OF90IGxlbikNCj4gIHsNCj4gIAlzdHJ1Y3QgbWVzaF9pb19wcml2YXRlICpw dnQgPSBpby0+cHZ0Ow0K Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WPwFLajqNl9H8QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 21:48:56 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2Gg0K6jqNl8PiwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 21:48:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 32914A23E7; Fri, 14 Aug 2020 21:48:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728506AbgHNTsk (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 15:48:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbgHNTsj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 15:48:39 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 277B3C061385 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 12:48:39 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id b22so9108200oic.8 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 12:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AkiSS7C196rcK+zBhAjxtXjYul49ai89IRKHkJgPUbU=; b=F995vKQTNEPsu5A0/o+7LcXSTRllakdBH0deijtTxfBBDjg15XJkAmHaolcqJ+L26F uZZyGTOVgcXkSiiI2kYAKsBBso7zzBEnXfZz9EBPP3SpMqnJbIRbNKKM/pL48Hvth5MV AZpDW+U7aewo5DAbgdJzY0NxtS5gVIKLwJa2cGTgp0hQySKzCNIfAbcvn7O49IPSRMrg 4Kp043ACUpY8iXHsWnyaBUur+oZVSI9yOdxt6g2J9D22USOBNtWn+TUDaCzXaGCclNY8 hNtXpmDJ+w1hWDelpHkWJDny4+xW8jYHYzIhHYXm1mCqvIpgcwXw8Fnkhi6IWHWj2nHA H49g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AkiSS7C196rcK+zBhAjxtXjYul49ai89IRKHkJgPUbU=; b=V19HQEmO/qJ970wqF29dYQ1qswuirc1CtH4rZQ+ryNEQvgws/eFih73JhfC4lvRiZy fv+wHszn5ArsAT/VhXALQS15xGw5ZLjDDkQ1MhVT3NgZ0UcMJi2CnVJ8uT3yvqW7fVgf d4LVUqYFk1/diiZTIeZ4qXXkH+suNAGxJdLHF2+KSl9oDjuGmAyKbZ2tmCiSNTurcfMM xqz/+q7FfcOIyiv78AMfjlm4DQsOmDIhXWy57RsCNGvFFiOYElrRHKQ8q+YFDa6KwUn/ 5A6fNUfZciPv1LRMcyrzxLEYh9e+LppVnQd6VEkLUIIcI34G7JxUDLefgHyzzrRIfMFj EvrA== X-Gm-Message-State: AOAM532T/VphO4vLBHhiXelwwz8Cg3T7bBR1jvp3Jd+EFPJ3/HnBJrkq dDGnlCmUqLRYsjbUki65pGjpmZRYsUQSBYbrY7Z9Yk7D X-Google-Smtp-Source: ABdhPJyz+Qfgy+rw3xgS7YcdmNxLU2je2gXTPgABj0c0dv0PaSc8PnnJhKTw5HbFqKkExHEJIE3Dhc5vRhvevAxKumU= X-Received: by 2002:aca:f504:: with SMTP id t4mr2624914oih.137.1597434517246; Fri, 14 Aug 2020 12:48:37 -0700 (PDT) MIME-Version: 1.0 References: <20200814100047.11008-1-515672508@qq.com> In-Reply-To: <20200814100047.11008-1-515672508@qq.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 14 Aug 2020 12:48:27 -0700 Message-ID: <CABBYNZKeMkbqnn1qswaLVcLxuAmc6OFPjVUidTiYSpAGvna=Rw@mail.gmail.com> Subject: Re: [PATCH BlueZ] adapt:Set property mode failed,memory leak To: chengbo <515672508@qq.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.08 / 15.00 / 200.00 X-Rspamd-Queue-Id: 32914A23E7 X-Rspamd-UID: cbe8a0 Hi, On Fri, Aug 14, 2020 at 4:40 AM chengbo <515672508@qq.com> wrote: > > This patch will fix a memory leak,when set property mode,it will send a msg, > but if failed,the data'memory do not free Give a look to HACKING documentation on how to properly format patches as it looks like you are appending the first version on this one as well. > --- > ...Set-property-mode-failed-memory-leak.patch | 26 +++++++++++++++++++ > src/adapter.c | 1 + > 2 files changed, 27 insertions(+) > create mode 100644 0001-adapt-Set-property-mode-failed-memory-leak.patch > > diff --git a/0001-adapt-Set-property-mode-failed-memory-leak.patch b/0001-adapt-Set-property-mode-failed-memory-leak.patch > new file mode 100644 > index 000000000..4994e03a6 > --- /dev/null > +++ b/0001-adapt-Set-property-mode-failed-memory-leak.patch > @@ -0,0 +1,26 @@ > +From 62d56bedbd32662b3f33af99dd464d67958e76d6 Mon Sep 17 00:00:00 2001 > +From: chengbo <515672508@qq.com> > +Date: Fri, 14 Aug 2020 17:09:51 +0800 > +Subject: [PATCH BlueZ] adapt:Set property mode failed,memory leak This patch > + will fix a memory leak,when set property mode,it will send a msg, but if > + failed,the data'memory do not free > + > +--- > + src/adapter.c | 1 + > + 1 file changed, 1 insertion(+) > + > +diff --git a/src/adapter.c b/src/adapter.c > +index 5e896a9f0..cb4cd8b75 100644 > +--- a/src/adapter.c > ++++ b/src/adapter.c > +@@ -2918,6 +2918,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, > + > + if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param, > + property_set_mode_complete, data, g_free) > 0) > ++ g_free(data); > + return; > + > + g_free(data); > +-- > +2.20.1 > + > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..cb4cd8b75 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -2918,6 +2918,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, > > if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param, > property_set_mode_complete, data, g_free) > 0) > + g_free(data); > return; > > g_free(data); > -- > 2.20.1 > > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oO0cCmHzNl9bLAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 22:26:09 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id qI2ZCGHzNl9o4wAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 22:26:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 98275A29F6; Fri, 14 Aug 2020 22:25:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbgHNUZ6 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 16:25:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726229AbgHNUZ5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 16:25:57 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9252BC061385 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 13:25:57 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id n128so5371923oif.0 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 13:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=T7bIHvBM1AvJQZjJyTsDsUREIH6V/JIP5HxyTUwKQEA=; b=vOpJw14RFvCZWGI3+vCrsaZmhVi9roa8bgZBgERyozvek+++OG14XCjBsPqcEW6ZMJ F7h261jS5k8CJHgbmFzrfU4rGT2Q70Y6Ud/nv8MBgQgWPl1WEnEnNJS5b3YXdqWZhgzW xw7OlJxBR/0Gl4ipfbNzbfd3Crj+4r9eYRXHQUCi85j8ZseHyUgAVbtB7cTDmnlvwOas JApFvGb5iQE1jQ83jhggooB+1aIxSgpHu2CsYpvt0ZCjIkZ+MFtsC0giEGJS++XF5G1Z S8iSt7Qxf3eN3+RL290K7jqQSFREJxu0r++PT6Ig3u7v4jG8bjWioyKL9oqBvH3iIkob RPiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=T7bIHvBM1AvJQZjJyTsDsUREIH6V/JIP5HxyTUwKQEA=; b=cM3x+M7xf3etYFkOulO3tNiXFRbQDGsl4jWu1rqT+8vJGd97hiJm+WxihoUDTpGtkG Avoj/M9C/G2YIe4e/6sf5pHbwh/Jsjk+t+Blpjv1glOQ6+7mP79qpLzpn9Mb+iOAYZeI 9V32t6kuGob1WHSNtb2Mk0R4El5C0/CMq1pRHKe1X7Q/y5vBleUJzvcv5iynhgJWpqR0 BXulYUX39B5d3sO1h7siTX++mUF4VSh3fm4rAvTmG7H4L/Z49gBE8OMKl+uAaENFxav1 INRF/Ok4fQLXEoPgPwaShIKlwPB1N+VOsl+kHYwnaahmVAY9KBp7hJj8naKEbpfbACQF ko3w== X-Gm-Message-State: AOAM530VoiTTO90VQFDgofdgmaa1XY1GGz5swrocmuKI2fK3fKw+cQqf KP2P0QnRDlLYzRLYKhTmCxEqlJryspRAAFS/hFU= X-Google-Smtp-Source: ABdhPJxqaWPfbf4cj1EZgm0grRDzSVOzJOiLjDaXg01y+nqsV/CC4NiOfmYYCCYoEdULaq5MLnI8Big3UqX4HoisE9w= X-Received: by 2002:aca:f504:: with SMTP id t4mr2713118oih.137.1597436755833; Fri, 14 Aug 2020 13:25:55 -0700 (PDT) MIME-Version: 1.0 References: <20200812204932.25627-1-tedd.an@linux.intel.com> <20200812204932.25627-2-tedd.an@linux.intel.com> In-Reply-To: <20200812204932.25627-2-tedd.an@linux.intel.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 14 Aug 2020 13:25:45 -0700 Message-ID: <CABBYNZKRyUCVeshB4F1XLkDJBhf9CtCwek+5znBvw8AW33av4A@mail.gmail.com> Subject: Re: [V2 2/3] tools/btpclientctl: Add btpclient test application To: Tedd Ho-Jeong An <tedd.an@linux.intel.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Tedd Ho-Jeong An <tedd.an@intel.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: 98275A29F6 X-Rspamd-UID: bacdd7 Hi Tedd, On Wed, Aug 12, 2020 at 1:53 PM <tedd.an@linux.intel.com> wrote: > > From: Tedd Ho-Jeong An <tedd.an@intel.com> > > This patch adds a test application for btpclient, which exercises the > BTP API. > --- > .gitignore | 1 + > Makefile.tools | 7 +- > tools/btpclientctl.c | 2151 ++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 2158 insertions(+), 1 deletion(-) > create mode 100644 tools/btpclientctl.c > > diff --git a/.gitignore b/.gitignore > index eabdb273f..f4fb5db28 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -120,6 +120,7 @@ tools/btconfig > tools/btmgmt > tools/btsnoop > tools/btpclient > +tools/btpclientctl > tools/btmon-logger > tools/bluetooth-logger.service > peripheral/btsensor > diff --git a/Makefile.tools b/Makefile.tools > index 9b9236609..37db68382 100644 > --- a/Makefile.tools > +++ b/Makefile.tools > @@ -492,11 +492,16 @@ test_scripts += test/sap_client.py test/bluezutils.py \ > test/test-gatt-profile test/test-mesh test/agent.py > > if BTPCLIENT > -noinst_PROGRAMS += tools/btpclient > +noinst_PROGRAMS += tools/btpclient tools/btpclientctl > > tools_btpclient_SOURCES = tools/btpclient.c src/shared/btp.c src/shared/btp.h > tools_btpclient_LDADD = lib/libbluetooth-internal.la \ > src/libshared-ell.la $(ell_ldadd) > tools_btpclient_DEPENDENCIES = lib/libbluetooth-internal.la $(ell_dependencies) > tools/btpclient.$(OBJEXT): src/libshared-ell.la ell/internal > + > +tools_btpclientctl_SOURCES = tools/btpclientctl.c client/display.c > +tools_btpclientctl_LDADD = lib/libbluetooth-internal.la \ > + src/libshared-mainloop.la $(GLIB_LIBS) \ > + src/libshared-glib.la -lreadline > endif > diff --git a/tools/btpclientctl.c b/tools/btpclientctl.c > new file mode 100644 > index 000000000..a9bbb4d01 > --- /dev/null > +++ b/tools/btpclientctl.c > @@ -0,0 +1,2151 @@ > +/* > + * > + * BlueZ - Bluetooth protocol stack for Linux > + * > + * Copyright (C) 2012 Intel Corporation. All rights reserved. > + * > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > + * > + */ > + > +#ifdef HAVE_CONFIG_H > +#include <config.h> > +#endif > + > +#define _GNU_SOURCE > +#include <stdio.h> > +#include <stdarg.h> > +#include <errno.h> > +#include <unistd.h> > +#include <stdlib.h> > +#include <string.h> > +#include <sys/types.h> > +#include <sys/param.h> > +#include <sys/socket.h> > +#include <sys/un.h> > +#include <sys/stat.h> > +#include <fcntl.h> > +#include <poll.h> > +#include <getopt.h> > +#include <stdbool.h> > +#include <wordexp.h> > +#include <ctype.h> > + > +#include <glib.h> > + > +#include "lib/bluetooth.h" > + > +#include "src/shared/mainloop.h" > +#include "src/shared/io.h" > +#include "src/shared/util.h" > +#include "src/shared/shell.h" > +#include "src/shared/btp.h" > + > +#define DEFAULT_SOCKET_PATH "/tmp/bt-stack-tester" > + > +#define PROMPT_ON COLOR_BLUE "[btpclient]" COLOR_OFF "# " > + > +#define EVT_OPCODE_BASE 0x80 > + > +#define DEFAULT_INDEX 0x00 > + > +static char *socket_path; > +static bool enable_dump; > + > +struct client_data { > + int fd; > + > + /* Incoming buffer for response and event */ > + uint8_t buf[512]; > +}; > + > +struct btpclientctl { > + int server_fd; > + struct client_data *client_data; > + bool debug_enabled; > + > + /* Outgoing buffer for command */ > + uint8_t buf[560]; > + uint16_t buf_len; > +}; > + > +struct ad_data { > + uint8_t type; > + uint8_t len; > + uint8_t data[25]; > +}; > + > +struct advertise_data { > + int duration; > + int ad_data_len; > + uint8_t ad_data[256]; > + int scan_data_len; > + uint8_t scan_data[256]; > +}; > + > +struct indexstr_data { > + int index; > + const char *str; > +}; > + > +struct bitfield_data { > + uint32_t bit; > + const char *str; > +}; > + > +struct opcode_data { > + uint8_t opcode; > + int bit; > + const char *str; > + > + void (*cmd_func)(const void *data, uint16_t size); > + uint16_t cmd_size; > + bool cmd_fixed; > + > + void (*rsp_func)(const void *data, uint16_t size); > + uint16_t rsp_size; > + bool rsp_fixed; > + > + void (*evt_func)(const void *data, uint16_t size); > + uint16_t evt_size; > + bool evt_fixed; > +}; > + > +struct service_data { > + uint8_t id; > + int bit; > + const char *str; > + const struct opcode_data *opcode_table; > +}; > + > +static struct advertise_data *advertise_data; > +static struct btpclientctl *btpclientctl; > +static bool client_active; > +static uint8_t bt_index = DEFAULT_INDEX; > + > +static void hexdump_print(const char *str, void *user_data) > +{ > + bt_shell_printf("%s%s\n", (char *) user_data, str); > +} > + > +static bool parse_argument_on_off(int argc, char *argv[], uint8_t *val) > +{ > + if (!strcasecmp(argv[1], "on") || !strcasecmp(argv[1], "yes")) > + *val = 1; > + else if (!strcasecmp(argv[1], "off") || !strcasecmp(argv[1], "no")) > + *val = 0; > + else > + *val = atoi(argv[1]); > + return true; > +} > + > +static bool parse_argument_list(int argc, char *argv[], uint8_t *val, > + const struct indexstr_data *table) > +{ > + int i; > + > + for (i = 0; table[i].str; i++) { > + if (strcasecmp(argv[1], table[i].str) == 0) { > + *val = table[i].index; > + return true; > + } > + } > + > + bt_shell_printf("Invalid arguement %s\n", argv[1]); > + > + return false; > +} > + > +static bool parse_argument_bitfield_list(int argc, char *argv[], uint32_t *val, > + const struct bitfield_data *table) > +{ > + int i; > + > + for (i = 0; table[i].str; i++) { > + if (strcasecmp(argv[0], table[i].str) == 0) { > + *val = table[i].bit; > + return true; > + } > + } > + > + bt_shell_printf("Invalid argument %s\n", argv[0]); > + > + return false; > +} > + > +static bool parse_argument_addr(int argc, char *argv[], uint8_t *addr_type, > + bdaddr_t *bdaddr) > +{ > + if (argc < 3) { > + bt_shell_printf("Invalid parameter\n"); > + return false; > + } > + > + *addr_type = atoi(argv[1]); > + str2ba(argv[2], bdaddr); > + > + return true; > +} > + > +static char *argument_gen(const char *text, int state, > + const struct indexstr_data *list) > +{ > + static int index, len; > + const char *arg; > + > + if (!state) { > + index = 0; > + len = strlen(text); > + } > + > + while ((arg = list[index].str)) { > + index++; > + > + if (!strncasecmp(arg, text, len)) > + return strdup(arg); > + } > + > + return NULL; > +} > + > +static char *argument_gen_bitfield(const char *text, int state, > + const struct bitfield_data *list) > +{ > + static int index, len; > + const char *arg; > + > + if (!state) { > + index = 0; > + len = strlen(text); > + } > + > + while ((arg = list[index].str)) { > + index++; > + > + if (!strncasecmp(arg, text, len)) > + return strdup(arg); > + } > + > + return NULL; > +} > + > +static const struct service_data service_table[]; > + > +static const struct service_data *find_service_data(uint8_t service_id) > +{ > + int i; > + > + for (i = 0; service_table[i].str; i++) { > + if (service_table[i].id == service_id) > + return &service_table[i]; > + } > + > + return NULL; > +} > + > +static const struct opcode_data *find_opcode_data(uint8_t opcode, > + const struct opcode_data *table) > +{ > + int i; > + > + for (i = 0; table[i].str; i++) { > + if (table[i].opcode == opcode) > + return &table[i]; > + } > + > + return NULL; > +} > + > +static const char *get_indexstr(int val, const struct indexstr_data *table) > +{ > + int i; > + > + for (i = 0; table[i].str; i++) { > + if (val == table[i].index) > + return table[i].str; > + } > + > + return "Unknown"; > +} > + > +static uint32_t print_bitfield(uint32_t val, const struct bitfield_data *table, > + const char *prefix) > +{ > + uint32_t mask = val; > + int i; > + > + for (i = 0; table[i].str; i++) { > + if (val & (((uint32_t) 1) << table[i].bit)) { > + bt_shell_printf("%s%s (0x%4.4x)\n", prefix, > + table[i].str, table[i].bit); > + mask &= ~(((uint32_t) 1) << table[i].bit); > + } > + } > + > + return mask; > +} > + > +static void print_bdaddr(const bdaddr_t *address, uint8_t address_type) > +{ > + char addr[18]; > + > + ba2str(address, addr); > + if (address_type == BTP_GAP_ADDR_PUBLIC) > + bt_shell_printf("\t%s (public)\n", addr); > + else if (address_type == BTP_GAP_ADDR_RANDOM) > + bt_shell_printf("\t%s (random)\n", addr); > + else > + bt_shell_printf("\t%s (unknown)\n", addr); > +} > + > +static void null_cmd(const void *data, uint16_t size) > +{ > + /* Empty */ > +} > + > +static void null_rsp(const void *data, uint16_t size) > +{ > + /* Empty */ > +} > + > +static void null_evt(const void *data, uint16_t size) > +{ > + /* Empty */ > +} > + > +static const struct indexstr_data error_table[] = { > + { 0x01, "Faile" }, > + { 0x02, "Unknown Command" }, > + { 0x03, "Not Ready" }, > + { 0x04, "Invalid Index" }, > + { } > +}; > + > +static void print_error_rsp(const void *data, uint16_t size) > +{ > + uint8_t reason = ((uint8_t *)data)[0]; > + > + bt_shell_printf(COLOR_RED "\tReason: %s (%d)\n" COLOR_OFF, > + get_indexstr(reason, error_table), reason); > +} > + > +static const char *service_to_str(uint8_t service_id) > +{ > + int i; > + > + for (i = 0; service_table[i].str; i++) { > + if (service_table[i].id == service_id) > + return service_table[i].str; > + } > + > + return "Unknown Service ID"; > +} > + > +static const char *get_supported_service(int bit) > +{ > + int i; > + > + for (i = 0; service_table[i].str; i++) { > + if (service_table[i].bit == bit) > + return service_table[i].str; > + } > + > + return NULL; > +} > + > +static const char *get_supported_command(const struct opcode_data *table, > + int bit) > +{ > + int i; > + > + for (i = 0; table[i].str; i++) { > + if (table[i].bit == bit) > + return table[i].str; > + } > + return NULL; > +} > + > +static void print_btp_hdr(struct btp_hdr *btp_hdr, const char *type_str, > + const char *opcode_str) > +{ > + bt_shell_printf("%s: %s(%d) %s(0x%02x) INDEX(0x%02x)\n", type_str, > + service_to_str(btp_hdr->service), btp_hdr->service, > + opcode_str, btp_hdr->opcode, btp_hdr->index); > +} > + > +static const struct opcode_data opcode_table_core[]; > + > +static void print_core_read_supported_commands_rsp(const void *data, > + uint16_t size) > +{ > + uint8_t cmds; > + const char *str; > + int i, bit; > + > + cmds = ((uint8_t *)data)[0]; > + > + for (i = 1; i < (int)(sizeof(cmds) * 8); i++) { > + bit = 0; > + bit = 1 << i; > + if (cmds & bit) { > + str = get_supported_command(opcode_table_core, i); > + if (str) > + bt_shell_printf("\t%s (Bit %d)\n", str, i); > + else > + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); > + } > + } > +} > + > +static void print_core_read_supported_services_rsp(const void *data, > + uint16_t size) > +{ > + uint8_t services; > + const char *str; > + int i, bit; > + > + services = ((uint8_t *)data)[0]; > + > + for (i = 0; i < (int)(sizeof(services) * 8); i++) { > + bit = 1 << i; > + if (services & bit) { > + str = get_supported_service(i); > + if (str) > + bt_shell_printf("\t%s (Bit %d)\n", str, i); > + else > + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); > + } > + } > +} > + > +static void print_core_register_service_cmd(const void *data, uint16_t size) > +{ > + const struct btp_core_register_cp *cp = data; > + > + bt_shell_printf("\tService ID: %s(0x%02x)\n", > + service_to_str(cp->service_id), cp->service_id); > +} > + > +static void print_core_unregister_service_cmd(const void *data, uint16_t size) > +{ > + const struct btp_core_unregister_cp *cp = data; > + > + bt_shell_printf("\tService ID: %s(0x%02x)\n", > + service_to_str(cp->service_id), cp->service_id); > +} > + > +static const struct opcode_data opcode_table_core[] = { > + { 0x00, 0, "Error", > + null_cmd, 0, true, > + print_error_rsp, 1, true }, > + { 0x01, 1, "Read Supported Commands", > + null_cmd, 0, true, > + print_core_read_supported_commands_rsp, 1, true }, > + { 0x02, 2, "Read Supported Services", > + null_cmd, 0, true, > + print_core_read_supported_services_rsp, 1, true }, > + { 0x03, 3, "Register Service", > + print_core_register_service_cmd, 1, true, > + null_rsp, 0, true }, > + { 0x04, 4, "Unregister Service", > + print_core_unregister_service_cmd, 1, true, > + null_rsp, 0, true }, > + { 0x80, -1, "IUT Ready", > + null_cmd, 0, true, > + null_rsp, 0, true, > + null_evt, 0, true }, > + { } > +}; > + > +static const struct opcode_data opcode_table_gap[]; > + > +static void print_gap_read_supported_commands_rsp(const void *data, > + uint16_t size) > +{ > + uint16_t cmds; > + const char *str; > + int i; > + > + cmds = le16_to_cpu(((uint16_t *)data)[0]); > + > + for (i = 1; i < (int)(sizeof(cmds) * 8); i++) { > + if (cmds & (1 << i)) { > + str = get_supported_command(opcode_table_gap, i); > + if (str) > + bt_shell_printf("\t%s (Bit %d)\n", str, i); > + else > + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); > + } > + } > +} > + > +static void print_gap_read_controller_index_list_rsp(const void *data, > + uint16_t size) > +{ > + const struct btp_gap_read_index_rp *list = data; > + int i; > + > + for (i = 0; i < list->num; i++) > + bt_shell_printf("\tIndex: %d\n", list->indexes[i]); > +} > + > +static const struct bitfield_data gap_setting_table[] = { > + { 0, "Powered" }, > + { 1, "Connectable" }, > + { 2, "Fast Connectable" }, > + { 3, "Discoverable" }, > + { 4, "Bondable" }, > + { 5, "Link Layer Security" }, > + { 6, "Secure Simple Pairing" }, > + { 7, "BR/EDR" }, > + { 8, "High Speed" }, > + { 9, "Low Energy" }, > + { 10, "Advertising" }, > + { 11, "Secure Connection" }, > + { 12, "Debug Keys" }, > + { 13, "Privacy" }, > + { 14, "Controller Configuration" }, > + { 15, "Static Address" }, > + { } > +}; > + > +static void print_gap_settings(uint32_t val, const struct bitfield_data *table, > + const char *prefix) > +{ > + uint32_t mask; > + > + mask = print_bitfield(val, table, prefix); > + if (mask) > + bt_shell_printf("%sUnknown settings (0x%4.4x)\n", prefix, mask); > +} > + > +static void print_gap_read_controller_information_rsp(const void *data, > + uint16_t size) > +{ > + const struct btp_gap_read_info_rp *info = data; > + char addr[18]; > + > + ba2str(&info->address, addr); > + bt_shell_printf("\tAddress: %s\n", addr); > + bt_shell_printf("\tSupported Settings\n"); > + print_gap_settings(le32_to_cpu(info->supported_settings), > + gap_setting_table, "\t\t"); > + bt_shell_printf("\tCurrent Settings\n"); > + print_gap_settings(le32_to_cpu(info->current_settings), > + gap_setting_table, "\t\t"); > + bt_shell_printf("\tClass: 0x%02x%02x%02x\n", > + info->cod[2], info->cod[1], info->cod[0]); > + bt_shell_printf("\tShort: %s\n", info->short_name); > + bt_shell_printf("\tName: %s\n", info->name); > +} > + > +static void print_gap_reset_rsp(const void *data, uint16_t size) > +{ > + const struct btp_gap_reset_rp *rp = data; > + > + print_gap_settings(le32_to_cpu(rp->current_settings), > + gap_setting_table, "\t"); > +} > + > +static const struct indexstr_data on_off_table[] = { > + { 0x00, "Off" }, > + { 0x01, "On" }, > + { } > +}; > + > +static void print_gap_set_powered_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_set_powered_cp *cp = data; > + > + bt_shell_printf("\tSet Power: %s (%d)\n", > + get_indexstr(cp->powered, on_off_table), > + cp->powered); > +} > + > +static void print_gap_set_powered_rsp(const void *data, uint16_t size) > +{ > + const struct btp_gap_set_powered_rp *rp = data; > + > + print_gap_settings(le32_to_cpu(rp->current_settings), > + gap_setting_table, "\t"); > +} > + > +static void print_gap_set_connectable_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_set_connectable_cp *cp = data; > + > + bt_shell_printf("\t Set Connectable: %s (%d)\n", > + get_indexstr(cp->connectable, on_off_table), > + cp->connectable); > +} > + > +static void print_gap_set_connectable_rsp(const void *data, uint16_t size) > +{ > + const struct btp_gap_set_connectable_rp *rp = data; > + > + print_gap_settings(le32_to_cpu(rp->current_settings), > + gap_setting_table, "\t"); > +} > + > +static void print_gap_set_fast_connectable_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_set_fast_connectable_cp *cp = data; > + > + bt_shell_printf("\t Set Fast Connectable: %s (%d)\n", > + get_indexstr(cp->fast_connectable, on_off_table), > + cp->fast_connectable); > +} > + > +static void print_gap_set_fast_connectable_rsp(const void *data, uint16_t size) > +{ > + const struct btp_gap_set_fast_connectable_rp *rp = data; > + > + print_gap_settings(le32_to_cpu(rp->current_settings), > + gap_setting_table, "\t"); > +} > + > +static const struct indexstr_data gap_discoverable_table[] = { > + { 0x00, "Off" }, > + { 0x01, "On" }, > + { 0x02, "Limited" }, > + { } > +}; > + > +static void print_gap_set_discoverable_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_set_discoverable_cp *cp = data; > + > + bt_shell_printf("\t Set Discoverable: %s (%d)\n", > + get_indexstr(cp->discoverable, gap_discoverable_table), > + cp->discoverable); > +} > + > +static void print_gap_set_discoverable_rsp(const void *data, uint16_t size) > +{ > + const struct btp_gap_set_discoverable_rp *rp = data; > + > + print_gap_settings(le32_to_cpu(rp->current_settings), > + gap_setting_table, "\t"); > +} > + > +static void print_gap_set_bondable_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_set_bondable_cp *cp = data; > + > + bt_shell_printf("\t Set Bondable: %s (%d)\n", > + get_indexstr(cp->bondable, on_off_table), > + cp->bondable); > +} > + > +static void print_gap_set_bondable_rsp(const void *data, uint16_t size) > +{ > + const struct btp_gap_set_bondable_rp *rp = data; > + > + print_gap_settings(le32_to_cpu(rp->current_settings), > + gap_setting_table, "\t"); > +} > + > +static void print_adv_data(const uint8_t *data, uint8_t len, const char *prefix) > +{ > + struct ad_data *ad; > + const uint8_t *ptr = data; > + int count = len; > + char str[96]; > + int i, j; > + > + while (count > 0) { > + ad = (struct ad_data *)ptr; It might be a good idea to make bt_ad able to load for memory and then use bt_ad_foreach_data to print them out, I actually had something like that before (e.g bt_ad_new_with_data(void *, size_t)) but I guess Ive never finished it/pushed it upstream but it should be relatively simple to have something like that done again so we don't have the logic of parsing Adv Data duplicated again. > + bt_shell_printf("%sData:\n", prefix); > + bt_shell_printf("%s\tType: 0x%02x (%d)\n", prefix, ad->type, > + ad->len); > + count -= 2; > + > + for (i = 0, j = 0; i < ad->len; i++) { > + j += sprintf(str + j, "%02x ", ad->data[i]); > + if ((i % 16) == 15) { > + str[j] = '\0'; > + bt_shell_printf("%s\t%s\n", prefix, str); > + j = 0; > + } > + } > + str[j] = '\0'; > + bt_shell_printf("%s\t%s\n", prefix, str); > + > + count -= ad->len; > + } > +} > + > +static void print_gap_start_advertising_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_start_adv_cp *cp = data; > + > + if (cp->adv_data_len) { > + bt_shell_printf("\tAdvertising Data:\n"); > + print_adv_data(cp->data, cp->adv_data_len, "\t\t"); > + } > + > + if (cp->scan_rsp_len) { > + bt_shell_printf("\tScan Response Data:\n"); > + print_adv_data(cp->data + cp->adv_data_len, cp->scan_rsp_len, > + "\t\t"); > + } > +} > + > +static void print_gap_start_advertising_rsp(const void *data, uint16_t size) > +{ > + const struct btp_gap_start_adv_rp *rp = data; > + > + print_gap_settings(le32_to_cpu(rp->current_settings), > + gap_setting_table, "\t"); > +} > + > +static void print_gap_stop_advertising_rsp(const void *data, uint16_t size) > +{ > + const struct btp_gap_start_adv_rp *rp = data; > + > + print_gap_settings(le32_to_cpu(rp->current_settings), > + gap_setting_table, "\t"); > +} > + > +static const struct bitfield_data gap_discovery_flags_table[] = { > + { 0, "LE" }, > + { 1, "BREDE" }, > + { 2, "Limited" }, > + { 3, "Active" }, > + { 4, "Observation" }, > + { } > +}; > + > +static void print_gap_start_discovery_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_start_discovery_cp *cp = data; > + uint32_t mask; > + > + mask = print_bitfield(le32_to_cpu(cp->flags), > + gap_discovery_flags_table, "\t\t"); > + if (mask) > + bt_shell_printf("\t\tUnknown flags (0x%4.4x)\n", mask); > +} > + > +static void print_gap_connect_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_connect_cp *cp = data; > + > + print_bdaddr(&cp->address, cp->address_type); > +} > + > +static void print_gap_disconnect_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_disconnect_cp *cp = data; > + > + print_bdaddr(&cp->address, cp->address_type); > +} > + > +static const struct indexstr_data gap_io_capa_table[] = { > + { 0x00, "DisplayOnly" }, > + { 0x01, "DisplayYesNo" }, > + { 0x02, "KeyboardOnly" }, > + { 0x03, "NoInputOutput" }, > + { 0x04, "KeyboardDisplay" }, > + { } > +}; > + > +static void print_gap_set_io_capa_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_set_io_capa_cp *cp = data; > + > + bt_shell_printf("\tIO Capa: %s (%d)\n", > + get_indexstr(cp->capa, gap_io_capa_table), cp->capa); > +} > + > +static void print_gap_pair_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_pair_cp *cp = data; > + > + print_bdaddr(&cp->address, cp->address_type); > +} > + > +static void print_gap_unpair_cmd(const void *data, uint16_t size) > +{ > + const struct btp_gap_unpair_cp *cp = data; > + > + print_bdaddr(&cp->address, cp->address_type); > +} > + > +static void print_gap_passkey_entry_response_cmd(const void *data, > + uint16_t size) > +{ > + const struct btp_gap_passkey_entry_rsp_cp *cp = data; > + > + print_bdaddr(&cp->address, cp->address_type); > + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(cp->passkey)); > +} > + > +static void print_gap_passkey_confirmation_response_cmd(const void *data, > + uint16_t size) > +{ > + const struct btp_gap_passkey_confirm_rsp_cp *cp = data; > + > + print_bdaddr(&cp->address, cp->address_type); > + bt_shell_printf("\tMatch: %d\n", cp->match); > +} > + > +static void print_gap_new_settings_evt(const void *data, uint16_t size) > +{ > + const struct btp_new_settings_ev *ev = data; > + > + print_gap_settings(le32_to_cpu(ev->current_settings), > + gap_setting_table, "\t"); > +} > + > +static void print_gap_eir(const uint8_t *eir, uint16_t eir_len, > + const char *prefix) > +{ > + char str[64]; > + int i, n; > + > + if (eir_len == 0) { > + bt_shell_printf("%sEIR Data: Empty\n", prefix); > + return; > + } > + > + bt_shell_printf("%sEIR Data:\n", prefix); > + for (i = 0, n = 0; i < eir_len; i++) { > + n += sprintf(str + n, "%02x ", eir[i]); > + if ((i % 16) == 15) { > + str[n] = '\0'; > + bt_shell_printf("\t%s%s\n", prefix, str); > + n = 0; > + } > + } > +} > + > +static const struct bitfield_data gap_device_found_flags_table[] = { > + { 0, "RSSI Valid" }, > + { 1, "Adv_Data Included" }, > + { 2, "Scan_Rsp Included" }, > + { } > +}; > + > +static void print_gap_device_found_evt(const void *data, uint16_t size) > +{ > + const struct btp_device_found_ev *ev = data; > + > + print_bdaddr(&ev->address, ev->address_type); > + bt_shell_printf("\tRSSI: %d\n", ev->rssi); > + bt_shell_printf("\tFlags:\n"); > + print_bitfield(ev->flags, gap_device_found_flags_table, "\t\t"); > + print_gap_eir(ev->eir, ev->eir_len, "\t"); > +} > + > +static void print_gap_device_connected_evt(const void *data, uint16_t size) > +{ > + const struct btp_gap_device_connected_ev *ev = data; > + > + print_bdaddr(&ev->address, ev->address_type); > +} > + > +static void print_gap_device_disconnected_evt(const void *data, uint16_t size) > +{ > + const struct btp_gap_device_disconnected_ev *ev = data; > + > + print_bdaddr(&ev->address, ev->address_type); > +} > + > +static void print_gap_passkey_display_evt(const void *data, uint16_t size) > +{ > + const struct btp_gap_passkey_display_ev *ev = data; > + > + print_bdaddr(&ev->address, ev->address_type); > + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(ev->passkey)); > +} > + > +static void print_gap_passkey_enter_request_evt(const void *data, uint16_t size) > +{ > + const struct btp_gap_passkey_req_ev *ev = data; > + > + print_bdaddr(&ev->address, ev->address_type); > +} > + > +static void print_gap_passkey_confirm_request_evt(const void *data, > + uint16_t size) > +{ > + const struct btp_gap_passkey_confirm_ev *ev = data; > + > + print_bdaddr(&ev->address, ev->address_type); > + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(ev->passkey)); > +} > + > +static void print_gap_identity_resolved_evt(const void *data, uint16_t size) > +{ > + const struct btp_gap_identity_resolved_ev *ev = data; > + > + print_bdaddr(&ev->address, ev->address_type); > + bt_shell_printf("\tIdentity: "); > + print_bdaddr(&ev->identity_address, ev->identity_address_type); > +} > + > + > +static const struct opcode_data opcode_table_gap[] = { > + { 0x00, 0, "Error", > + null_cmd, 0, true, > + print_error_rsp, 1, true }, > + { 0x01, 1, "Read Supported Commands", > + null_cmd, 0, true, > + print_gap_read_supported_commands_rsp, 2, true }, > + { 0x02, 2, "Read Controller Index List", > + null_cmd, 0, true, > + print_gap_read_controller_index_list_rsp, 2, false }, > + { 0x03, 3, "Read Controller Information", > + null_cmd, 0, true, > + print_gap_read_controller_information_rsp, 277, true }, > + { 0x04, 4, "Reset", > + null_cmd, 0, true, > + print_gap_reset_rsp, 4, true }, > + { 0x05, 5, "Set Powered", > + print_gap_set_powered_cmd, 1, true, > + print_gap_set_powered_rsp, 4, true }, > + { 0x06, 6, "Set Connectable", > + print_gap_set_connectable_cmd, 1, true, > + print_gap_set_connectable_rsp, 4, true }, > + { 0x07, 7, "Set Fast Connectable", > + print_gap_set_fast_connectable_cmd, 1, true, > + print_gap_set_fast_connectable_rsp, 4, true }, > + { 0x08, 8, "Set Discoverable", > + print_gap_set_discoverable_cmd, 1, true, > + print_gap_set_discoverable_rsp, 4, true }, > + { 0x09, 9, "Set Bondable", > + print_gap_set_bondable_cmd, 1, true, > + print_gap_set_bondable_rsp, 4, true }, > + { 0x0a, 10, "Starting Advertising", > + print_gap_start_advertising_cmd, 2, false, > + print_gap_start_advertising_rsp, 4, true }, > + { 0x0b, 11, "Stop Advertising", > + null_cmd, 0, true, > + print_gap_stop_advertising_rsp, 4, true }, > + { 0x0c, 12, "Start Discovery", > + print_gap_start_discovery_cmd, 1, true, > + null_rsp, 0, true }, > + { 0x0d, 13, "Stop Discovery", > + null_cmd, 0, true, > + null_rsp, 0, true }, > + { 0x0e, 14, "Connect", > + print_gap_connect_cmd, 7, true, > + null_rsp, 0, true }, > + { 0x0f, 15, "Disconnect", > + print_gap_disconnect_cmd, 7, true, > + null_rsp, 0, true }, > + { 0x10, 16, "Set I/O Capability", > + print_gap_set_io_capa_cmd, 1, true, > + null_rsp, 0, true }, > + { 0x11, 17, "Pair", > + print_gap_pair_cmd, 7, true, > + null_rsp, 0, true }, > + { 0x12, 18, "Unpair", > + print_gap_unpair_cmd, 7, true, > + null_rsp, 0, true }, > + { 0x13, 19, "Passkey Entry Response", > + print_gap_passkey_entry_response_cmd, 11, true, > + null_rsp, 0, true }, > + { 0x14, 20, "Passkey Confirmation Response", > + print_gap_passkey_confirmation_response_cmd, 8, true, > + null_rsp, 0, true }, > + { 0x80, -1, "New Settings", > + null_cmd, 0, true, > + null_rsp, 0, true, > + print_gap_new_settings_evt, 4, true }, > + { 0x81, -1, "Device Found", > + null_cmd, 0, true, > + null_rsp, 0, true, > + print_gap_device_found_evt, 11, false }, > + { 0x82, -1, "Device Connected", > + null_cmd, 0, true, > + null_rsp, 0, true, > + print_gap_device_connected_evt, 7, true }, > + { 0x83, -1, "Device Disconnected", > + null_cmd, 0, true, > + null_rsp, 0, true, > + print_gap_device_disconnected_evt, 7, true }, > + { 0x84, -1, "Passkey Display", > + null_cmd, 0, true, > + null_rsp, 0, true, > + print_gap_passkey_display_evt, 11, true }, > + { 0x85, -1, "Passkey Entry Request", > + null_cmd, 0, true, > + null_rsp, 0, true, > + print_gap_passkey_enter_request_evt, 7, true }, > + { 0x86, -1, "Passkey Confirm Request", > + null_cmd, 0, true, > + null_rsp, 0, true, > + print_gap_passkey_confirm_request_evt, 11, true }, > + { 0x87, -1, "Identity Resolved", > + null_cmd, 0, true, > + null_rsp, 0, true, > + print_gap_identity_resolved_evt, 14, true }, > + { } > +}; > + > +static const struct service_data service_table[] = { > + { 0x00, 0, "Core", opcode_table_core}, > + { 0x01, 1, "GAP", opcode_table_gap}, > + { } > +}; > + > +static bool write_packet(int fd, const void *data, size_t size) > +{ > + while (size > 0) { > + ssize_t written; > + > + written = write(fd, data, size); > + if (written < 0) { > + if (errno == EAGAIN || errno == EINTR) > + continue; > + return false; > + } > + > + if (enable_dump) > + util_hexdump('<', data, written, hexdump_print, > + "OUT: "); > + > + data += written; > + size -= written; > + } > + > + return true; > +} > + > +static void btp_print_cmd(struct btp_hdr *btp_hdr, void *data) > +{ > + const struct service_data *table; > + const struct opcode_data *opcode_data; > + > + table = find_service_data(btp_hdr->service); > + if (!table) { > + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); > + return; > + } > + > + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); > + if (!opcode_data) { > + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); > + return; > + } > + > + print_btp_hdr(btp_hdr, "CMD", opcode_data->str); > + > + if (opcode_data->cmd_fixed) { > + if (btp_hdr->data_len != opcode_data->cmd_size) { > + bt_shell_printf("Invalid Parameter length %d\n", > + btp_hdr->data_len); > + return; > + } > + } else { > + if (btp_hdr->data_len < opcode_data->cmd_size) { > + bt_shell_printf("Invalid Parameter length %d\n", > + btp_hdr->data_len); > + return; > + } > + } > + > + opcode_data->cmd_func(data, btp_hdr->data_len); > +} > + > +static void btp_print_rsp(struct btp_hdr *btp_hdr, void *data) > +{ > + const struct service_data *table; > + const struct opcode_data *opcode_data; > + > + table = find_service_data(btp_hdr->service); > + if (!table) { > + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); > + return; > + } > + > + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); > + if (!opcode_data) { > + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); > + return; > + } > + > + print_btp_hdr(btp_hdr, "RSP", opcode_data->str); > + > + if (opcode_data->rsp_fixed) { > + if (btp_hdr->data_len != opcode_data->rsp_size) { > + bt_shell_printf("Invalid Parameter length %d\n", > + btp_hdr->data_len); > + return; > + } > + } else { > + if (btp_hdr->data_len < opcode_data->rsp_size) { > + bt_shell_printf("Invalid Parameter length %d\n", > + btp_hdr->data_len); > + return; > + } > + } > + > + opcode_data->rsp_func(data, btp_hdr->data_len); > +} > + > +static void btp_print_evt(struct btp_hdr *btp_hdr, void *data) > +{ > + const struct service_data *table; > + const struct opcode_data *opcode_data; > + > + table = find_service_data(btp_hdr->service); > + if (!table) { > + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); > + return; > + } > + > + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); > + if (!opcode_data) { > + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); > + return; > + } > + > + print_btp_hdr(btp_hdr, "EVT", opcode_data->str); > + > + if (opcode_data->evt_fixed) { > + if (btp_hdr->data_len != opcode_data->evt_size) { > + bt_shell_printf("Invalid Parameter length %d\n", > + btp_hdr->data_len); > + return; > + } > + } else { > + if (btp_hdr->data_len < opcode_data->evt_size) { > + bt_shell_printf("Invalid Parameter length %d\n", > + btp_hdr->data_len); > + return; > + } > + } > + > + opcode_data->evt_func(data, btp_hdr->data_len); > +} > + > +static bool send_cmd(uint8_t service_id, uint8_t opcode, uint8_t index, > + uint16_t data_len, void *data) > +{ > + struct btp_hdr *hdr; > + int client_fd; > + > + if (!client_active) { > + bt_shell_printf("ERROR: Client is not active\n"); > + return false; > + } > + > + hdr = (struct btp_hdr *)(btpclientctl->buf); > + > + hdr->service = service_id; > + hdr->opcode = opcode; > + hdr->index = index; > + hdr->data_len = cpu_to_le16(data_len); > + if (data) > + memcpy(hdr->data, data, data_len); > + > + btpclientctl->buf_len = sizeof(*hdr) + data_len; > + > + client_fd = btpclientctl->client_data->fd; > + > + btp_print_cmd(hdr, data_len ? hdr->data : NULL); > + > + if (!write_packet(client_fd, btpclientctl->buf, > + btpclientctl->buf_len)) { > + fprintf(stderr, "Failed to send command to client\n"); > + mainloop_remove_fd(client_fd); > + return false; > + } > + > + return true; > +} > + > +static void client_read_destroy(void *user_data) > +{ > + struct client_data *client_data = user_data; > + > + close(client_data->fd); > + free(client_data); > + > + client_active = false; > + > + bt_shell_printf("Client is disconnected\n"); > +} > + > +static void client_read_callback(int fd, uint32_t events, void *user_data) > +{ > + struct client_data *client_data = user_data; > + struct btp_hdr *btp_hdr; > + uint8_t *data, *ptr; > + ssize_t len, pkt_len; > + > + if (events & (EPOLLERR | EPOLLHUP)) { > + fprintf(stderr, "Error from client connection\n"); > + mainloop_remove_fd(client_data->fd); > + return; > + } > + > + if (events & EPOLLRDHUP) { > + fprintf(stderr, "Remote hangeup of cliient connection\n"); > + mainloop_remove_fd(client_data->fd); > + return; > + } > + > + /* Read incoming packet */ > + len = read(client_data->fd, client_data->buf, sizeof(client_data->buf)); > + if (len < 0) { > + if (errno == EAGAIN || errno == EINTR) > + return; > + > + fprintf(stderr, "Read from client descriptor failed\n"); > + mainloop_remove_fd(client_data->fd); > + return; > + } > + > + if (len < (ssize_t)sizeof(struct btp_hdr) - 1) > + return; > + > + ptr = client_data->buf; > + > + while (len) { > + btp_hdr = (struct btp_hdr *)ptr; > + > + pkt_len = sizeof(*btp_hdr) + btp_hdr->data_len; > + > + if (enable_dump) > + util_hexdump('>', ptr, pkt_len, hexdump_print, "IN : "); > + > + if (btp_hdr->data_len) > + data = btp_hdr->data; > + else > + data = NULL; > + > + if (btp_hdr->opcode < EVT_OPCODE_BASE) > + btp_print_rsp(btp_hdr, data); > + else > + btp_print_evt(btp_hdr, data); > + > + ptr += pkt_len; > + len -= pkt_len; > + } > +} > + > +static struct client_data *setup_client(int client_fd) > +{ > + struct client_data *client_data; > + > + client_data = new0(struct client_data, 1); > + if (!client_data) > + return NULL; > + > + client_data->fd = client_fd; > + > + mainloop_add_fd(client_data->fd, EPOLLIN | EPOLLRDHUP, > + client_read_callback, client_data, client_read_destroy); > + > + return client_data; > +} > + > +static void server_callback(int fd, uint32_t events, void *user_data) > +{ > + union { > + struct sockaddr common; > + struct sockaddr_un sun; > + struct sockaddr_in sin; > + } addr; > + socklen_t len; > + int client_fd; > + struct client_data *client_data; > + struct btpclientctl *btpclientctl = user_data; > + > + if (events & (EPOLLERR | EPOLLHUP)) { > + mainloop_quit(); > + return; > + } > + > + memset(&addr, 0, sizeof(addr)); > + len = sizeof(addr); > + > + if (getsockname(fd, &addr.common, &len) < 0) { > + perror("Failed to get socket name"); > + return; > + } > + > + client_fd = accept(fd, &addr.common, &len); > + if (client_fd < 0) { > + perror("Failed to accept client socket"); > + return; > + } > + > + bt_shell_printf("Client is connected\n"); > + > + /* Setup Client */ > + client_data = setup_client(client_fd); > + if (!client_data) { > + fprintf(stderr, "Failed to setup client\n"); > + close(client_fd); > + return; > + } > + > + btpclientctl->client_data = client_data; > + client_active = true; > +} > + > +static int open_socket(const char *path) > +{ > + struct sockaddr_un addr; > + size_t len; > + int fd; > + > + len = strlen(path); > + if (len > sizeof(addr.sun_path) - 1) { > + fprintf(stderr, "Socket path is too long\n"); > + return -1; > + } > + > + unlink(path); > + > + fd = socket(AF_UNIX, SOCK_STREAM, 0); > + if (fd < 0) { > + perror("Failed to open Unix server socket"); > + return -1; > + } > + > + memset(&addr, 0, sizeof(addr)); > + addr.sun_family = AF_UNIX; > + strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); > + > + if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { > + perror("Failed to bind Unix server socket"); > + goto error_close; > + } > + > + if (listen(fd, 1) < 0) { > + perror("Failed to listen Unix server socket"); > + goto error_close; > + } > + > + bt_shell_printf("Waiting for client connection...\n"); > + > + if (chmod(path, 0666) < 0) { > + perror("Failed to change Unix socket file mode"); > + goto error_close; > + } > + > + return fd; > + > +error_close: > + close(fd); > + return -1; > +} > + > +static void cmd_ad_show(int argc, char **argv) > +{ > + bt_shell_printf("AD: Saved Advertise/Scan data\n"); > + > + if (!advertise_data) { > + bt_shell_printf("\tError: Not initialized\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (advertise_data->ad_data_len) { > + bt_shell_printf("\tAD Data:\n"); > + print_adv_data(advertise_data->ad_data, > + advertise_data->ad_data_len, "\t\t"); > + } > + > + if (advertise_data->scan_data_len) { > + bt_shell_printf("\tScan Data:\n"); > + print_adv_data(advertise_data->scan_data, > + advertise_data->scan_data_len, "\t\t"); > + } > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static bool ad_add_data(struct ad_data *ad_data, int argc, char *argv[]) > +{ > + char *endptr = NULL; > + int i; > + long val; > + > + /* Type */ > + val = strtol(argv[0], &endptr, 0); > + if (!endptr || *endptr != '\0' || val > UINT8_MAX) { > + bt_shell_printf("Error: Invalid Type\n"); > + return false; > + } > + ad_data->type = val; > + > + for (i = 1; i < argc; i++) { > + endptr = NULL; > + > + val = strtol(argv[i], &endptr, 0); > + if (!endptr || *endptr != '\0' || val > UINT8_MAX) { > + bt_shell_printf("Error: Invalid data at %d\n", i); > + return false; > + } > + > + ad_data->data[ad_data->len] = val; > + ad_data->len++; > + } > + > + return true; > +} > + > +static void cmd_ad_add_ad(int argc, char **argv) > +{ > + struct ad_data ad_data; > + uint8_t *ptr; > + > + bt_shell_printf("AD: Save Advertise data\n"); > + > + if (!advertise_data) { > + bt_shell_printf("\tError: Not initialized\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (argc < 2) { > + bt_shell_printf("\tInvalid Parameter Number\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + memset(&ad_data, 0, sizeof(ad_data)); > + > + if (!ad_add_data(&ad_data, argc - 1, argv + 1)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + ptr = advertise_data->ad_data + advertise_data->ad_data_len; > + memcpy(ptr, &ad_data, ad_data.len + 2); > + advertise_data->ad_data_len += ad_data.len + 2; > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_ad_add_scan(int argc, char **argv) > +{ > + struct ad_data ad_data; > + uint8_t *ptr; > + > + bt_shell_printf("AD: Save Scan data\n"); > + > + if (!advertise_data) { > + bt_shell_printf("\tError: Not initialized\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (argc < 2) { > + bt_shell_printf("\tInvalid Parameter Number\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (!ad_add_data(&ad_data, argc - 1, argv + 1)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + ptr = advertise_data->scan_data + advertise_data->scan_data_len; > + memcpy(ptr, &ad_data, ad_data.len + 2); > + advertise_data->scan_data_len += ad_data.len + 2; > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_ad_duration(int argc, char **argv) > +{ > + uint32_t val; > + > + bt_shell_printf("AD: Set Advertising Duration\n"); > + > + if (!advertise_data) { > + bt_shell_printf("\tError: Not initialized\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (argc > 2) { > + bt_shell_printf("\tInvalid parameter\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + /* No parameter */ > + if (argc == 1) { > + bt_shell_printf("\tDuration: %d\n", advertise_data->duration); > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > + } > + > + val = (uint32_t)atoi(argv[1]); > + > + if (val == 0) > + val = UINT32_MAX; > + > + advertise_data->duration = val; > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_ad_clear(int argc, char **argv) > +{ > + bt_shell_printf("AD: Clear Advertise/Scan data\n"); > + > + if (!advertise_data) { > + bt_shell_printf("\tError: Not initialized\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + advertise_data->ad_data_len = 0; > + advertise_data->scan_data_len = 0; > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_core_read_cmds(int argc, char **argv) > +{ > + bt_shell_printf("Core: Read Supported Commands\n"); > + > + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_READ_SUPPORTED_COMMANDS, > + BTP_INDEX_NON_CONTROLLER, 0, NULL)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_core_read_services(int argc, char **argv) > +{ > + bt_shell_printf("Core: Read Supported Services\n"); > + > + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_READ_SUPPORTED_SERVICES, > + BTP_INDEX_NON_CONTROLLER, 0, NULL)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_core_register_service(int argc, char **argv) > +{ > + uint8_t service_id; > + > + bt_shell_printf("Core: Register Service\n"); > + > + if (argc != 2) { > + bt_shell_printf("Invalid parameter\n"); > + > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + service_id = atoi(argv[1]); > + if (service_id == 0) { > + bt_shell_printf("CORE service is already registered\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_REGISTER, > + BTP_INDEX_NON_CONTROLLER, 1, &service_id)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_core_unregister_service(int argc, char **argv) > +{ > + uint8_t service_id; > + > + bt_shell_printf("Core: Unregister Service\n"); > + > + if (argc != 2) { > + bt_shell_printf("Invalid parameter\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + service_id = atoi(argv[1]); > + if (service_id == 0) { > + bt_shell_printf("Cannot unregister CORE service\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_UNREGISTER, > + BTP_INDEX_NON_CONTROLLER, 1, &service_id)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_set_index(int argc, char **argv) > +{ > + uint8_t index; > + > + bt_shell_printf("Set Default Controller Index\n"); > + > + if (argc != 2) { > + bt_shell_printf("Invalid parameter\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + index = atoi(argv[1]); > + if (index == bt_index) { > + bt_shell_printf("Controller index is already set\n"); > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > + } > + > + bt_index = index; > + bt_shell_printf("Controller index is updated to 0x%02x\n", bt_index); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_read_cmds(int argc, char **argv) > +{ > + bt_shell_printf("GAP: Read Supported Commands\n"); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_SUPPORTED_COMMANDS, > + BTP_INDEX_NON_CONTROLLER, 0, NULL)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_read_index(int argc, char **argv) > +{ > + bt_shell_printf("GAP: Read Controller Index List\n"); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_CONTROLLER_INDEX_LIST, > + BTP_INDEX_NON_CONTROLLER, 0, NULL)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_read_info(int argc, char **argv) > +{ > + uint8_t index; > + > + bt_shell_printf("GAP: Read Controller Information\n"); > + > + if (argc != 2) { > + bt_shell_printf("Invalid parameter\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + index = atoi(argv[1]); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_COTROLLER_INFO, > + index, 0, NULL)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_reset(int argc, char **argv) > +{ > + bt_shell_printf("GAP: Reset\n"); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_RESET, bt_index, 0, NULL)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static char *gap_on_off_gen(const char *text, int state) > +{ > + return argument_gen(text, state, on_off_table); > +} > + > +static void cmd_gap_power(int argc, char **argv) > +{ > + struct btp_gap_set_powered_cp cp; > + > + bt_shell_printf("GAP: Set Power\n"); > + > + if (argc != 2) { > + bt_shell_printf("Invalid parameter\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (!parse_argument_on_off(argc, argv, &cp.powered)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_POWERED, bt_index, > + sizeof(cp), &cp)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_connectable(int argc, char **argv) > +{ > + struct btp_gap_set_connectable_cp cp; > + > + bt_shell_printf("GAP: Set Connectable\n"); > + > + if (argc != 2) { > + bt_shell_printf("Invalid parameter\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (!parse_argument_on_off(argc, argv, &cp.connectable)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_CONNECTABLE, bt_index, > + sizeof(cp), &cp)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_fast_connectable(int argc, char **argv) > +{ > + struct btp_gap_set_fast_connectable_cp cp; > + > + bt_shell_printf("GAP: Set Fast Connectable\n"); > + > + if (argc != 2) { > + bt_shell_printf("Invalid parameter\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (!parse_argument_on_off(argc, argv, &cp.fast_connectable)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_FAST_CONNECTABLE, > + bt_index, sizeof(cp), &cp)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static char *gap_discoverable_gen(const char *text, int state) > +{ > + return argument_gen(text, state, gap_discoverable_table); > +} > + > +static void cmd_gap_discoverable(int argc, char **argv) > +{ > + struct btp_gap_set_discoverable_cp cp; > + > + bt_shell_printf("GAP: Set Discoverable\n"); > + > + memset(&cp, 0, sizeof(cp)); > + > + if (argc != 2) { > + bt_shell_printf("Invalid parameter\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (!parse_argument_list(argc, argv, &cp.discoverable, > + gap_discoverable_table)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_DISCOVERABLE, > + bt_index, sizeof(cp), &cp)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_bondable(int argc, char **argv) > +{ > + struct btp_gap_set_bondable_cp cp; > + > + bt_shell_printf("GAP: Set Bondable\n"); > + > + if (argc != 2) { > + bt_shell_printf("Invalid parameter\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (!parse_argument_on_off(argc, argv, &cp.bondable)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_BONDABLE, > + bt_index, sizeof(cp), &cp)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_start_adv(int argc, char **argv) > +{ > + struct btp_gap_start_adv_cp *cp; > + int total; > + > + bt_shell_printf("GAP: Start Advertising\n"); > + > + /* Check if AD data is availabel */ > + if (advertise_data->ad_data_len == 0 && > + advertise_data->scan_data_len == 0) { > + bt_shell_printf("ERROR: No Advertise or Scan data available\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + /* Allocate the maximum size */ > + cp = (struct btp_gap_start_adv_cp *)malloc(520); > + > + memset(cp, 0, 520); > + total = 2; > + > + if (advertise_data->ad_data_len) { > + memcpy(cp->data, advertise_data->ad_data, > + advertise_data->ad_data_len); > + cp->adv_data_len = advertise_data->ad_data_len; > + } else > + cp->adv_data_len = 0; > + > + total += cp->adv_data_len; > + > + if (advertise_data->scan_data_len) { > + memcpy(cp->data + cp->adv_data_len, advertise_data->scan_data, > + advertise_data->scan_data_len); > + cp->scan_rsp_len = advertise_data->scan_data_len; > + } else > + cp->scan_rsp_len = 0; > + > + total += cp->scan_rsp_len; > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_START_ADVERTISING, > + bt_index, total, cp)) { > + free(cp); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + free(cp); > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_stop_adv(int argc, char **argv) > +{ > + bt_shell_printf("GAP: Stop Advertising\n"); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_STOP_ADVERTISING, > + bt_index, 0, NULL)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static char *gap_start_disc_gen(const char *text, int state) > +{ > + return argument_gen_bitfield(text, state, gap_discovery_flags_table); > +} > + > +static void cmd_gap_start_disc(int argc, char **argv) > +{ > + struct btp_gap_start_discovery_cp cp; > + int i; > + uint32_t f; > + > + bt_shell_printf("GAP: Start Discovery\n"); > + > + if (argc < 2) { > + bt_shell_printf("Invalid parameter\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + memset(&cp, 0, sizeof(cp)); > + > + for (i = 1; i < argc; i++) { > + if (!parse_argument_bitfield_list(argc - i, &argv[i], &f, > + gap_discovery_flags_table)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + cp.flags |= (1 << f); > + } > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_START_DISCOVERY, > + bt_index, sizeof(cp), &cp)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_stop_disc(int argc, char **argv) > +{ > + bt_shell_printf("GAP: Stop Discovery\n"); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_STOP_DISCOVERY, bt_index, > + 0, NULL)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_connect(int argc, char **argv) > +{ > + struct btp_gap_connect_cp cp; > + > + bt_shell_printf("GAP: Connect\n"); > + > + memset(&cp, 0, sizeof(cp)); > + > + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_CONNECT, > + bt_index, sizeof(cp), &cp)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_disconnect(int argc, char **argv) > +{ > + struct btp_gap_disconnect_cp cp; > + > + bt_shell_printf("GAP: Disconnect\n"); > + > + memset(&cp, 0, sizeof(cp)); > + > + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_DISCONNECT, > + bt_index, sizeof(cp), &cp)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static char *gap_io_capa_gen(const char *text, int state) > +{ > + return argument_gen(text, state, gap_io_capa_table); > +} > + > +static void cmd_gap_set_io_capa(int argc, char **argv) > +{ > + struct btp_gap_set_io_capa_cp cp; > + > + bt_shell_printf("GAP: Get IO Capability\n"); > + > + memset(&cp, 0, sizeof(cp)); > + > + if (argc != 2) { > + bt_shell_printf("Invalid parameter\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + if (!parse_argument_list(argc, argv, &cp.capa, gap_io_capa_table)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_IO_CAPA, > + bt_index, sizeof(cp), &cp)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_pair(int argc, char **argv) > +{ > + struct btp_gap_pair_cp cp; > + > + bt_shell_printf("GAP: Pair\n"); > + > + memset(&cp, 0, sizeof(cp)); > + > + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_PAIR, > + bt_index, sizeof(cp), &cp)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void cmd_gap_unpair(int argc, char **argv) > +{ > + struct btp_gap_unpair_cp cp; > + > + bt_shell_printf("GAP: Unpair\n"); > + > + memset(&cp, 0, sizeof(cp)); > + > + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_UNPAIR, > + bt_index, sizeof(cp), &cp)) > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static const struct bt_shell_menu ad_menu = { > + .name = "ad", > + .desc = "Manage Advertise DataSubmenu", > + .entries = { > + { "show", NULL, > + cmd_ad_show, "Show current saved AD/Scan data" }, > + { "add-ad", "<type> <data=xx xx ...>", > + cmd_ad_add_ad, "Save AD data" }, > + { "add-scan", "<type> <data=xx xx ...>", > + cmd_ad_add_scan, "Save Scan data" }, > + { "duration", "<duration>", > + cmd_ad_duration, "Set duration" }, > + { "clear", "<all/ad/scan/duration>", > + cmd_ad_clear, "Clear saved AD/Scan/duration data" }, > + { } }, > +}; > + > +static const struct bt_shell_menu gap_menu = { > + .name = "gap", > + .desc = "GAP API Submenu", > + .entries = { > + { "read-cmds", NULL, > + cmd_gap_read_cmds, "Show supported commands" }, > + { "list", NULL, > + cmd_gap_read_index, "Show index of controllers" }, > + { "read-info", "<index>", > + cmd_gap_read_info, "Read controller information" }, > + { "reset", NULL, > + cmd_gap_reset, "Reset controller and stack" }, > + { "power", "<on/off>", > + cmd_gap_power, "Set controller power", > + gap_on_off_gen }, > + { "connectable", "<on/off>", > + cmd_gap_connectable, "Set controller connectable", > + gap_on_off_gen }, > + { "fast-connectable", "<on/off>", > + cmd_gap_fast_connectable, "Set controller fast connectable", > + gap_on_off_gen }, > + { "discoverable", "<on/off/limited>", > + cmd_gap_discoverable, "Set controller discoverable", > + gap_discoverable_gen }, > + { "bondable", "<on/off>", > + cmd_gap_bondable, "Set controller bondable", > + gap_on_off_gen }, > + { "start-adv", NULL, > + cmd_gap_start_adv, "Start Advertising" }, > + { "stop-adv", NULL, > + cmd_gap_stop_adv, "Stop Advertising" }, > + { "start-disc", "<flags...>", > + cmd_gap_start_disc, "Start discovery", > + gap_start_disc_gen }, > + { "stop-disc", NULL, > + cmd_gap_stop_disc, "Stop discovery" }, > + { "connect", "<type> <bdaddr>", > + cmd_gap_connect, "Connect" }, > + { "disconnect", "<type> <bdaddr>", > + cmd_gap_disconnect, "Disconnect" }, > + { "set-capa", "<io capability>", > + cmd_gap_set_io_capa, "Set IO capability", > + gap_io_capa_gen }, > + { "pair", "<type> <bdaddr>", > + cmd_gap_pair, "Pair" }, > + { "unpair", "<type> <bdaddr>", > + cmd_gap_unpair, "Unpair" }, > + { } }, > +}; > + > +static const struct bt_shell_menu main_menu = { > + .name = "main", > + .entries = { > + { "read-cmds", NULL, > + cmd_core_read_cmds, "Read supported commands" }, > + { "read-services", NULL, > + cmd_core_read_services, "Read supported services" }, > + { "register", "<service id>", > + cmd_core_register_service, "Register service" }, > + { "unregister", "<service id>", > + cmd_core_unregister_service, "Unregister service" }, > + { "index", "<index>", > + cmd_set_index, "Set controller index. Default is 0" }, > + { } }, > +}; > + > +static const struct option main_options[] = { > + { "socket", required_argument, 0, 's' }, > + { "dump ", required_argument, 0, 'd' }, > + { 0, 0, 0, 0 } > +}; > + > +static const char *socket_path_option; > +static const char *dump_option; > + > +static const char **optargs[] = { > + &socket_path_option, > + &dump_option, > +}; > + > +static const char *help[] = { > + "Socket path to listen for BTP client\n", > + "Use \"on\" to enable hex dump\n", > +}; > + > +static const struct bt_shell_opt opt = { > + .options = main_options, > + .optno = sizeof(main_options) / sizeof(struct option), > + .optstr = "s:d:", > + .optarg = optargs, > + .help = help, > +}; > + > +int main(int argc, char *argv[]) > +{ > + int status; > + int server_fd; > + > + bt_shell_init(argc, argv, &opt); > + bt_shell_set_menu(&main_menu); > + bt_shell_add_submenu(&ad_menu); > + bt_shell_add_submenu(&gap_menu); > + > + if (socket_path_option) > + socket_path = g_strdup(socket_path_option); > + else > + socket_path = g_strdup(DEFAULT_SOCKET_PATH); > + > + if (dump_option && !strcasecmp(dump_option, "on")) > + enable_dump = true; > + else > + enable_dump = false; > + > + > + btpclientctl = new0(struct btpclientctl, 1); > + if (!btpclientctl) { > + status = EXIT_FAILURE; > + goto error_exit; > + } > + > + advertise_data = new0(struct advertise_data, 1); > + if (!advertise_data) { > + status = EXIT_FAILURE; > + goto error_free_client; > + } > + > + advertise_data->ad_data_len = 0; > + advertise_data->scan_data_len = 0; > + > + bt_shell_attach(fileno(stdin)); > + > + server_fd = open_socket(socket_path); > + if (server_fd < 0) { > + status = EXIT_FAILURE; > + goto error_free_ad; > + } > + > + btpclientctl->server_fd = server_fd; > + > + mainloop_add_fd(btpclientctl->server_fd, EPOLLIN, server_callback, > + btpclientctl, NULL); > + > + bt_shell_set_prompt(PROMPT_ON); > + > + status = bt_shell_run(); > + > + close(btpclientctl->server_fd); > + > +error_free_ad: > + free(advertise_data); > +error_free_client: > + free(btpclientctl); > +error_exit: > + g_free(socket_path); > + return status; > +} > -- > 2.25.4 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OEO6OBf9OF8KxwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 16 Aug 2020 11:32:07 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gOYRNxf9OF/TdwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 16 Aug 2020 11:32:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5FE94420CB; Sun, 16 Aug 2020 11:32:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726847AbgHPJcC convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 16 Aug 2020 05:32:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:47682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726721AbgHPJcB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 16 Aug 2020 05:32:01 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 208915] Regression: issues and hang during PAN network connection Date: Sun, 16 Aug 2020 09:32:01 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alxchk@gmail.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: <bug-208915-62941-RGWpSzxGmS@https.bugzilla.kernel.org/> In-Reply-To: <bug-208915-62941@https.bugzilla.kernel.org/> References: <bug-208915-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.14 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5FE94420CB X-Rspamd-UID: e46aee https://bugzilla.kernel.org/show_bug.cgi?id=208915 --- Comment #1 from Oleksii Shevchuk (alxchk@gmail.com) --- Created attachment 290923 --> https://bugzilla.kernel.org/attachment.cgi?id=290923&action=edit Perf top -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qJTWD5IYOV+5XAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 16 Aug 2020 13:29:22 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +OI0DpIYOV+yxQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 16 Aug 2020 13:29:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8B90DA010F; Sun, 16 Aug 2020 13:29:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729033AbgHPL3N convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 16 Aug 2020 07:29:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:57304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728975AbgHPL2e (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 16 Aug 2020 07:28:34 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 208915] Regression: issues and hang during PAN network connection Date: Sun, 16 Aug 2020 11:28:26 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pavel@noa-labs.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-208915-62941-fHHHP1Osiu@https.bugzilla.kernel.org/> In-Reply-To: <bug-208915-62941@https.bugzilla.kernel.org/> References: <bug-208915-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.93 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8B90DA010F X-Rspamd-UID: 010147 https://bugzilla.kernel.org/show_bug.cgi?id=208915 Pavel (pavel@noa-labs.com) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pavel@noa-labs.com --- Comment #2 from Pavel (pavel@noa-labs.com) --- Same for me. Intel AX200, Huawei Maimang 5 -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eIlZE6b6Nl86TwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 14 Aug 2020 22:57:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id qApkEab6Nl8QnwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 14 Aug 2020 22:57:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 51650420B7; Fri, 14 Aug 2020 22:57:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726754AbgHNU5F (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 16:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726623AbgHNU5E (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 16:57:04 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74069C061385 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 13:57:04 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id r21so8609062ota.10 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 13:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5OTgAFgKEoxzSV29z4pMnxFk0J4VZgiMtd7nFNa4KdY=; b=GbWjM8o7D8CSRP4Vml3v/oCPfSfdOOJeQyzvnn/8jKkzkVn703MCxflUG6uCpTGRTl fI+wtEsCFjfnxHWWDTa24RZzNAXUZ4fC3fljQCfXjUahZzSefhdqtOPhsSrHEOCbw+tS LilN4/UMa5G1ubftgPFypu5DB1l6U24GP9fWCK2SVqJkF3OO/Ol4hdwzo9bV+BDiO3jt MZLwJyD44qgqZmiiEMLH7dL7LxfS20RjULVl0aV1bvuuUw1whaidvxxdyvL5K1pHd7LZ GJDgcImt8rdRua4i2Kmd9mhwCYxPyyorM/e/GK3R8uNBbWFiZ58z7iRapsAQJiuqpOgm mE4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5OTgAFgKEoxzSV29z4pMnxFk0J4VZgiMtd7nFNa4KdY=; b=kxiqfNEPy4Z9R8dY6I/QlHbe0SNl91I1uSS+ae8NxqoSqvyG+jTl2K2irZ8rh/uOzF FCS0ygK86Q4LZKMnBZ+5qlCu+80CaolORp8VfaUsobUjEMmOUFVlqwIqFjB9gqqvACHa ZHd9B1vDpZrKaXoLI5g7lKzRYZTff9H7/PKAIKmR/YDPChfSyxr/y2Zj8csN0Ryc/C62 DwY758HT3U64ARz6u5CHgoFkCHWqjfL45sLy96ugBa1DDSMpnsqJxzzsAMqyvshgVKzD R9ak4kHCgxJUgWAMHDACmYMnHwM3g8ElFtc6+Y8cX++AsENISmaRSfrmCeaJh3yJHc3l 5xGQ== X-Gm-Message-State: AOAM531V9NSjsQcgd6u15QDJu8RJtfCEVHjUmlg10beUiAvkDh2987Zb c4wdD45Z9RsK1BdCeWV7VhuPeRY+fWdOTnXkAHxoTubxNQI= X-Google-Smtp-Source: ABdhPJysemBbRsxg1OJi9T1j8NWw3ToQqNXPdzZcm+ECMcdcbCFo6mUDKLeb9OFCPcNw4uFN1dLk32gnAYvbwt+ZTEM= X-Received: by 2002:a9d:429:: with SMTP id 38mr3079328otc.88.1597438623827; Fri, 14 Aug 2020 13:57:03 -0700 (PDT) MIME-Version: 1.0 References: <20200811181623.3683374-1-luiz.dentz@gmail.com> <93FEE5B2-F495-40C4-9386-E44DF132C49D@holtmann.org> In-Reply-To: <93FEE5B2-F495-40C4-9386-E44DF132C49D@holtmann.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 14 Aug 2020 13:56:53 -0700 Message-ID: <CABBYNZK0mJCRpkAgKrWQ+TQJbrPDkzEX+AkTum62sUQR0Tw6mg@mail.gmail.com> Subject: Re: [PATCH SBC 1/3] sbc: Add initial code for SSE primitives To: Marcel Holtmann <marcel@holtmann.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.21 / 15.00 / 200.00 X-Rspamd-Queue-Id: 51650420B7 X-Rspamd-UID: 2a8a4e Hi Marcel, On Wed, Aug 12, 2020 at 5:48 AM Marcel Holtmann <marcel@holtmann.org> wrote: > > Hi Luiz, > > > > > --- > > Makefile.am | 1 + > > sbc/sbc_primitives.c | 20 ++- > > sbc/sbc_primitives_sse.c | 361 +++++++++++++++++++++++++++++++++++++++ > > sbc/sbc_primitives_sse.h | 38 +++++ > > 4 files changed, 417 insertions(+), 3 deletions(-) > > create mode 100644 sbc/sbc_primitives_sse.c > > create mode 100644 sbc/sbc_primitives_sse.h > > > > diff --git a/Makefile.am b/Makefile.am > > index 342043d..7ff0c7d 100644 > > --- a/Makefile.am > > +++ b/Makefile.am > > @@ -14,6 +14,7 @@ sbc_headers = sbc/sbc.h > > > > sbc_sources = sbc/sbc.c sbc/sbc_private.h sbc/sbc_math.h sbc/sbc_tables.h \ > > sbc/sbc_primitives.h sbc/sbc_primitives.c \ > > + sbc/sbc_primitives_sse.h sbc/sbc_primitives_sse.c \ > > sbc/sbc_primitives_mmx.h sbc/sbc_primitives_mmx.c \ > > sbc/sbc_primitives_iwmmxt.h sbc/sbc_primitives_iwmmxt.c \ > > sbc/sbc_primitives_neon.h sbc/sbc_primitives_neon.c \ > > diff --git a/sbc/sbc_primitives.c b/sbc/sbc_primitives.c > > index ff343cf..97a75be 100644 > > --- a/sbc/sbc_primitives.c > > +++ b/sbc/sbc_primitives.c > > @@ -33,6 +33,7 @@ > > #include "sbc_tables.h" > > > > #include "sbc_primitives.h" > > +#include "sbc_primitives_sse.h" > > #include "sbc_primitives_mmx.h" > > #include "sbc_primitives_iwmmxt.h" > > #include "sbc_primitives_neon.h" > > @@ -590,6 +591,21 @@ static int sbc_calc_scalefactors_j( > > return joint; > > } > > > > +static void sbc_init_primitives_x86(struct sbc_encoder_state *state) > > +{ > > + __builtin_cpu_init(); > > + > > +#ifdef SBC_BUILD_WITH_MMX_SUPPORT > > + if (__builtin_cpu_supports("mmx")) > > + sbc_init_primitives_mmx(state); > > +#endif > > + > > +#ifdef SBC_BUILD_WITH_SSE_SUPPORT > > + if (__builtin_cpu_supports("sse4.2")) > > + sbc_init_primitives_sse(state); > > +#endif > > lets keep the ifdef in the primitive functions they belong. This should be consistent across all primitives and not spread in two places. I guess you mean moving #ifdef SBC_BUILD_WITH_SSE_SUPPORT into sbc_primitives_sse.c, same for mmx, right? I will fix that, although I was thinking on not even compiling those files when the config option is not enabled which would result in undefined symbols, I can however have alternative versions when its options are not enabled which basically does nothing. > Regards > > Marcel > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AJfFFvgON1/roAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 15 Aug 2020 00:23:52 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sKjsFPgON19GWwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 15 Aug 2020 00:23:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 474F1A0C36; Sat, 15 Aug 2020 00:23:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbgHNWXo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 18:23:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726229AbgHNWXo (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 18:23:44 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF24BC061385 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 15:23:43 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id ha11so5019870pjb.1 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 15:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5jRl27RMtgZLeq7b/WHxRkukWBIOKeVCPevK+sNiPhQ=; b=k73o73VNd0qn9M+iiKly87GFMMXb6KyBorDW4eREbb7tWN2jSXYRFziRAoYgSezuUF FLz13Od/1weIFdHYZAkH4EE6DZ2zj7DIZfLAK/em3ojP/RtKqLTLGoQKKszjB6dJ4pV9 mte4YoB6Bc6FECyWkOAdnIkWLrrXIYtyO/yYs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5jRl27RMtgZLeq7b/WHxRkukWBIOKeVCPevK+sNiPhQ=; b=kfH5VwKIJ6JMDsEB4dqff15jwwl71xg4WX0Dv7kML/inR6KBKQxofINRGXkDrUHcjq yaL/PRk6ld9Mz7b0DzZLJxMxHNnnx1uTMrjINiL4OapCoLgVtxFIz5aZ/k7iK/ZVeL8A WxaaXMmzE5v27TkuWAQTdbPnJzvZvHbtO6q3oB5IkgIucwIVailXOvMR7hH9P0HOGUAj rrtGQIXhSRWv+d6inTkRzoAcfz3TbWhF3mRinSKtyNErNEAsDD3/3qdHd/i+LlyAvZCk uk0uRFWvYzYzDbrWBJ1D0bFEGaOrCBfBgGOhh6xTNLA6Bgq3JaJUp2NgCL9ux4An6wwQ fwtA== X-Gm-Message-State: AOAM531ccmB7MfjXv2qruratjqmmr6f5Y93VkqW7uHe/nrSzm8S+PCV/ 593nJUH+lsm9ksTL9elKfgAoCg== X-Google-Smtp-Source: ABdhPJw4VToGF1Qswjip3GwGa5R4xOuQDDzZR0q80w8U/1h/s8l757szCrDYF3vT/E21VzKADGZyYA== X-Received: by 2002:a17:902:82c2:: with SMTP id u2mr3422745plz.239.1597443823248; Fri, 14 Aug 2020 15:23:43 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id a17sm9302460pgi.26.2020.08.14.15.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 15:23:42 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Daniel Winkler <danielwinkler@google.com>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH] bluetooth: Set ext scan response only when it exists Date: Fri, 14 Aug 2020 15:23:36 -0700 Message-Id: <20200814152323.1.Ib022565452fde0c02fbcf619950ef868715dd243@changeid> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 474F1A0C36 X-Rspamd-UID: d38963 Only set extended scan response only when it exists. Otherwise, clear the scan response data. Per the core spec v5.2, Vol 4, Part E, 7.8.55 If the advertising set is non-scannable and the Host uses this command other than to discard existing data, the Controller shall return the error code Invalid HCI Command Parameters (0x12). On WCN3991, the controller correctly responds with Invalid Parameters when this is sent. That error causes __hci_req_hci_power_on to fail with -EINVAL and LE devices can't connect because background scanning isn't configured. Here is an hci trace of where this issue occurs during power on: < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25 Handle: 0x00 Properties: 0x0010 Use legacy advertising PDUs: ADV_NONCONN_IND Min advertising interval: 181.250 msec (0x0122) Max advertising interval: 181.250 msec (0x0122) Channel map: 37, 38, 39 (0x07) Own address type: Random (0x01) Peer address type: Public (0x00) Peer address: 00:00:00:00:00:00 (OUI 00-00-00) Filter policy: Allow Scan Request from Any, Allow Connect... TX power: 127 dbm (0x7f) Primary PHY: LE 1M (0x01) Secondary max skip: 0x00 Secondary PHY: LE 1M (0x01) SID: 0x00 Scan request notifications: Disabled (0x00) > HCI Event: Command Complete (0x0e) plen 5 LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 1 Status: Success (0x00) TX power (selected): 9 dbm (0x09) < HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7 Advertising handle: 0x00 Advertising random address: 08:FD:55:ED:22:28 (OUI 08-FD-55) > HCI Event: Command Complete (0x0e) plen 4 LE Set Advertising Set Random Address (0x08|0x0035) ncmd Status: Success (0x00) < HCI Command: LE Set Extended Scan Response Data (0x08|0x0038) plen 35 Handle: 0x00 Operation: Complete scan response data (0x03) Fragment preference: Minimize fragmentation (0x01) Data length: 0x0d Name (short): Chromebook > HCI Event: Command Complete (0x0e) plen 4 LE Set Extended Scan Response Data (0x08|0x0038) ncmd 1 Status: Invalid HCI Command Parameters (0x12) Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Daniel Winkler <danielwinkler@google.com> --- net/bluetooth/hci_request.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index e0269192f2e536..e17bc8a1c66ddd 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1533,11 +1533,14 @@ void __hci_req_update_scan_rsp_data(struct hci_request *req, u8 instance) memset(&cp, 0, sizeof(cp)); - if (instance) + /* Extended scan response data doesn't allow a response to be + * set if the instance isn't scannable. + */ + if (get_adv_instance_scan_rsp_len(hdev, instance)) len = create_instance_scan_rsp_data(hdev, instance, cp.data); else - len = create_default_scan_rsp_data(hdev, cp.data); + len = 0; if (hdev->scan_rsp_data_len == len && !memcmp(cp.data, hdev->scan_rsp_data, len)) -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gLPnNBkXN1/tvAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 15 Aug 2020 00:58:33 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2Aw9MxkXN18D5gEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 15 Aug 2020 00:58:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 97517420DA; Sat, 15 Aug 2020 00:58:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728028AbgHNW6Y (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 18:58:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbgHNW6X (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 18:58:23 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D70F9C061385 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 15:58:23 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id t13so7255943pjd.0 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 15:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=DYBPrA8sCUr9nfv4S2QQxK9888V5PiTctZCZCYiPjog=; b=U3orD6F3Izflh9/TcLR+xnPcE9gpu7GMgVOivUGX+0/T5eFnMUJKcnArweJMGsr4Jj 6smMB4lntcFs9sOUQz+VS6OMvC1BCbuhs4Ij5wZbOGapJdLT/aoR82X7/aLvYhihZpSO ePNcpjlUjWohdtOiJJK6uUorDbW1Np96+l4EI2R3EEDVDcTuaHnkYrjcjIgLEgYPsvgN nlYi6fgL1O5MlFHJfXvUCoKuUCepl01y/Fvll63tDj0sXVXNlGqD2aeHSrMuy3ShtKLf H3VjKaiY1Nkw+1lJNGgZe63DfOTx/u+UPOoP5P+DO+xBMLqNPqXhLMdwdE5CbC/EYqjR C7UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=DYBPrA8sCUr9nfv4S2QQxK9888V5PiTctZCZCYiPjog=; b=MqzZ1OKNQySwKh+YfjlEZAxgo5wZTJsK7ssESY40e3eIO7Hp+Zy+0B4N8LaXIAKVVP lUtzuSRTOCTq/XZ2vxBnEQS03vZ9PQS3dCKnLb0EsPWb+jSZYksj5t9jG/wt8SvbTKIP Avo1BFLf6r0DGpv+/ZTXnFaMJzACa19Dex+j+0asiI8Y2ZY8xAaEkOn7arxMkFhxjtzS qrpYVzqLOLelMj95O+UgTmju44/lJ0wzLTma50j824dkQpFbeny3bYZMIlLK4xQdVwKF LKuB3XeryL7VEvvxEOG16hxH3SDVQTG7muDuml5MbIUzF4bUSw5MP2wRKFl7ihs3MgFx Mw2g== X-Gm-Message-State: AOAM530Ot15v6Zcg0AOZLkQhiK1W5C7WHbppGQwbBgUdrj7StWpoTo58 rfVWM+a6ofupZdvyIzY3u65fMDue5sQ9M89JeAb5 X-Google-Smtp-Source: ABdhPJxFsdCZ5eF33zzvwv3OCG+LLDirDPoWvVLn13gIWyzT2e7aV1WFubmPaksOqaUCEOe4eP2iXyTEbTrr3slgB7YJ X-Received: by 2002:a17:90b:193:: with SMTP id t19mr4018900pjs.162.1597445902591; Fri, 14 Aug 2020 15:58:22 -0700 (PDT) Date: Fri, 14 Aug 2020 15:58:18 -0700 Message-Id: <20200814155807.Bluez.1.Ia90c97ad9ec0b51b7aaae1216864e8379c1470d5@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [Bluez PATCH] advertising: Fix dbus response for over-advertising From: Daniel Winkler <danielwinkler@google.com> To: simon.mikuda@streamunlimited.com, linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: 97517420DA X-Rspamd-UID: f44e21 client_free would always send a dbus method_return to fix the case where a request to Unregister occurred before the MGMT call returned. However, in the code path where too many advertisements are registered, this method_return prevents the failure from being sent properly. This patch makes sure the reference to the register_advertisement DBusMessage is not stored in the client structure until the end of register_advertisement. This ensures that we only respond once, either in register_advertisement or in client_free, not both. It also changes the dbus response in the fast unregister_advertisement case from a method_return to a btd_error_failed, since the registration was never allowed to complete, and thus was not successful. The patch was tested in the following ways: To verify it did not break the segfault fix in caff2b48ca54bbc57b5da3f63317767489aa5b48, I repro'd the failure by quickly unregistering after registering, and verified that the segfault is still fixed with this change. Ran through our automated tests that register too many advertisements and verify that the registration fails with the intended "Maximum Advertisements Reached" error response. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- src/advertising.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/advertising.c b/src/advertising.c index 076d591b6..e5f25948d 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -119,9 +119,13 @@ static void client_free(void *data) } if (client->reg) { - g_dbus_send_message(btd_get_dbus_connection(), - dbus_message_new_method_return(client->reg)); + DBusMessage *reply; + + reply = btd_error_failed(client->reg, + "Failed to complete registration"); + g_dbus_send_message(btd_get_dbus_connection(), reply); dbus_message_unref(client->reg); + client->reg = NULL; } if (client->add_adv_id) @@ -1152,8 +1156,6 @@ static struct btd_adv_client *client_create(struct btd_adv_manager *manager, g_dbus_client_set_proxy_handlers(client->client, client_proxy_added, NULL, NULL, client); - client->reg = dbus_message_ref(msg); - client->data = bt_ad_new(); if (!client->data) goto fail; @@ -1216,6 +1218,8 @@ static DBusMessage *register_advertisement(DBusConnection *conn, DBG("Registered advertisement at path %s", match.path); + client->reg = dbus_message_ref(msg); + queue_push_tail(manager->clients, client); return NULL; -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MJlrApYeN18d9QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 15 Aug 2020 01:30:30 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AOu+AJYeN1/OjgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 15 Aug 2020 01:30:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B1402420C3; Sat, 15 Aug 2020 01:30:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727930AbgHNXaS (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 19:30:18 -0400 Received: from mail-io1-f72.google.com ([209.85.166.72]:46873 "EHLO mail-io1-f72.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgHNXaR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 19:30:17 -0400 Received: by mail-io1-f72.google.com with SMTP id n1so7061964ion.13 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 16:30:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=SA9X8J8qG/6k9RqPtMDue8VLhzxw1Kg1UAqeNkKdQ3s=; b=jJYb/Q0D7Q+eDfg27xMJLIBRVf3AvdwBVTqG+0NQEoXkZVDJBxOOif8llZ1ihC41Xa ZOOU9+38+LZp41x4w1ATdo2GDb7nxu8g5D3/qGm4BVNcXEz8Xs/pBs34NyUx957Au98k oHYogJNs0IrOu2jZmt1lqJ/L5GtKD1Eyog+RYqAbbQsnVFU3EBGaL7vUatkCh89YcUs/ sZ2Xre8wznJ+15KrFn9JyHPikTfXpbROqVvujq+1LyN7OugSA9XPwNl5HHifVjdQxd27 7r5I5WO7QU0rRBj4jopTo1V6lzeOE0dToaI1JF9HRZ5rqnw1mqFJ6vGEo0rI/BUbUjM2 Z79g== X-Gm-Message-State: AOAM532Lv41MY9hHrSVDIWHZ1QgP88O5rxviI0wN9KmhYu3s5SOtq0EQ hW4pGcg6weIZBtC8feClWMp8dEbXub+1v+DE0Iyex8Gr7XOi X-Google-Smtp-Source: ABdhPJz9eIGB6Ws8UTY+Q8ajVoXMDaX5s1VQsNBPUQJEiSzcKKaE0ZdxmHaR4hN3v/pddtH2CEq7UIzi+idpeuj2wETkzX+vzNXh MIME-Version: 1.0 X-Received: by 2002:a02:3f0d:: with SMTP id d13mr4625141jaa.99.1597447816184; Fri, 14 Aug 2020 16:30:16 -0700 (PDT) Date: Fri, 14 Aug 2020 16:30:16 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000a18a8305acdecd3e@google.com> Subject: BUG: corrupted list in bt_accept_unlink From: syzbot <syzbot+7f4d3ecf4d3480301722@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: B1402420C3 X-Rspamd-UID: 9e13f7 Hello, syzbot found the following issue on: HEAD commit: a1d21081 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=11c77891900000 kernel config: https://syzkaller.appspot.com/x/.config?x=9c89856ae5fc8b6 dashboard link: https://syzkaller.appspot.com/bug?extid=7f4d3ecf4d3480301722 compiler: gcc (GCC) 10.1.0-syz 20200507 userspace arch: i386 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1180847a900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+7f4d3ecf4d3480301722@syzkaller.appspotmail.com list_del corruption. prev->next should be ffff8880913ab4b8, but was ffff8880890c54b8 ------------[ cut here ]------------ kernel BUG at lib/list_debug.c:51! invalid opcode: 0000 [#1] PREEMPT SMP KASAN CPU: 1 PID: 17 Comm: kworker/1:0 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout RIP: 0010:__list_del_entry_valid.cold+0xf/0x55 lib/list_debug.c:51 Code: e8 5a ab bf fd 0f 0b 48 89 f1 48 c7 c7 40 ff 93 88 4c 89 e6 e8 46 ab bf fd 0f 0b 48 89 ee 48 c7 c7 e0 00 94 88 e8 35 ab bf fd <0f> 0b 4c 89 ea 48 89 ee 48 c7 c7 20 00 94 88 e8 21 ab bf fd 0f 0b RSP: 0018:ffffc90000d8fb18 EFLAGS: 00010282 RAX: 0000000000000054 RBX: ffff8880913ab4b8 RCX: 0000000000000000 RDX: ffff8880a968a480 RSI: ffffffff815dbc57 RDI: fffff520001b1f55 RBP: ffff8880913ab4b8 R08: 0000000000000054 R09: ffff8880ae7318e7 R10: 0000000000000000 R11: 00000000000c3a18 R12: ffff8880890c54b8 R13: ffff88809914f4b8 R14: ffff88809914f000 R15: 0000000000000008 FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000081570f0 CR3: 00000000a6dc2000 CR4: 00000000001506e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: __list_del_entry include/linux/list.h:132 [inline] list_del_init include/linux/list.h:204 [inline] bt_accept_unlink+0x26/0x280 net/bluetooth/af_bluetooth.c:187 l2cap_sock_teardown_cb+0x197/0x400 net/bluetooth/l2cap_sock.c:1544 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:823 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Modules linked in: ---[ end trace ea2f8b77c156d63d ]--- RIP: 0010:__list_del_entry_valid.cold+0xf/0x55 lib/list_debug.c:51 Code: e8 5a ab bf fd 0f 0b 48 89 f1 48 c7 c7 40 ff 93 88 4c 89 e6 e8 46 ab bf fd 0f 0b 48 89 ee 48 c7 c7 e0 00 94 88 e8 35 ab bf fd <0f> 0b 4c 89 ea 48 89 ee 48 c7 c7 20 00 94 88 e8 21 ab bf fd 0f 0b RSP: 0018:ffffc90000d8fb18 EFLAGS: 00010282 RAX: 0000000000000054 RBX: ffff8880913ab4b8 RCX: 0000000000000000 RDX: ffff8880a968a480 RSI: ffffffff815dbc57 RDI: fffff520001b1f55 RBP: ffff8880913ab4b8 R08: 0000000000000054 R09: ffff8880ae7318e7 R10: 0000000000000000 R11: 00000000000c3a18 R12: ffff8880890c54b8 R13: ffff88809914f4b8 R14: ffff88809914f000 R15: 0000000000000008 FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000080f0b38 CR3: 0000000009a8d000 CR4: 00000000001506e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2A+DCE0pN18QVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 15 Aug 2020 02:16:13 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id qOEUB00pN181OAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 15 Aug 2020 02:16:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6B639418AF; Sat, 15 Aug 2020 02:16:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727822AbgHOAQH convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 14 Aug 2020 20:16:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:51550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbgHOAQG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 14 Aug 2020 20:16:06 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Sat, 15 Aug 2020 00:16:04 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vicpt@protonmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-9pWmSyLogr@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6B639418AF X-Rspamd-UID: a55fd2 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #134 from vic (vicpt@protonmail.com) --- (In reply to Swyter from comment #111) > Just submitted v4 for kernel review. Its behavior should be identical to v3, > it only contains a few minor technical changes and logic flow tweaks, to > appease the BlueZ gods. Nothing new. > ... > https://patchwork.kernel.org/patch/11686157/ Just to correct my last comment #128. The patch indeed work. First time I tried I didn't pay attention to the patch, I just applied the patch. Then I built only the module (btusb) for my in use kernel version. For obvious reasons it didn't work. Today with more time I realized the stupidity I did, then I built the entire kernel. Now after load the btusb module with the options "reset=1 enable_autosuspend=0" the dongle initiates and apparently works correctly. I'm sorry for the misinformation on my last comment. Thank you Swyter for your time on fixing this. Hope to see the patch in mainline kernel soon. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6FdWGcRYOF8/yAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 15 Aug 2020 23:51:00 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id OA2PF8RYOF++eAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 15 Aug 2020 23:51:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 408E540813; Sat, 15 Aug 2020 23:50:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728435AbgHOVux (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 15 Aug 2020 17:50:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728340AbgHOVus (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 15 Aug 2020 17:50:48 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9942C061344 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 17:40:47 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id 2so5161025pjx.5 for <linux-bluetooth@vger.kernel.org>; Fri, 14 Aug 2020 17:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5Gtg0Mu/abosx7cbMyjvqm3BgSpDd0rRtzMxQNPezKE=; b=b3PfH/wypQHJ685ofVrtZdKKOqKYgm0iqPC0Pbe4odmP9dGa349PVYdCmd7nTWR8vR xqutgbAOShitN9KXbUGkfnX2RmB6HDHK3bQHFNQ1X0f0k/murDm8wXR6ZTPUhXSoYUE6 dXn2GyTtSWrIHdlaeg/XasUr0caLPhjuk9rBo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5Gtg0Mu/abosx7cbMyjvqm3BgSpDd0rRtzMxQNPezKE=; b=IYj9YSRy/hD1ktgno5zQxfedPjYiVmlXuL4SAF/b2cNsh4VdqB4hR8O4RLBFVPTQR1 1hZV9j7P1kxCpM3lZUiEc0FH2BanHv1dJrtcMtdnt84MY5RwkPghuvzYLX0oSRcB+6YK KXLmPXoFba+gXlhXo78QhJ2LPuWIl6Z5/rHEMR+XhWN8c1ZlTN6181ZfS3A5nRjKsmt6 WfgNp8LW+TcTRTYEOoXGHw13uSHBRvQclPKcDyd5jGCh+Q2C+Gz4G2BjCE5hpMsuEJ6s tDnWlC45xs244RfyuaeR7IJRivORXhlvTgGMTF5uO6T+vEJbJZAlcQJTWi6+R2xGNVZm ATJw== X-Gm-Message-State: AOAM530nLUMVIREjkeewALS6IPU9s9C57m3hrxsAz5T2NWllvABBO7BH nm+8+LGb56UJ1coSNbZd7mLQ/Q== X-Google-Smtp-Source: ABdhPJyMZNGYoN3/sqk/JU4g3eewEpC+vFQpWtnhH5IY3352HMEya4rrUrGdYRs60YVUu1WzYjs8Pw== X-Received: by 2002:a17:902:c282:: with SMTP id i2mr3747922pld.205.1597452047421; Fri, 14 Aug 2020 17:40:47 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 196sm10762214pfc.178.2020.08.14.17.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 17:40:45 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Balakrishna Godavarthi <bgodavar@codeaurora.org>, Manish Mandlik <mmandlik@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH] Bluetooth: Only mark socket zapped after unlocking Date: Fri, 14 Aug 2020 17:40:32 -0700 Message-Id: <20200814173929.1.Ic1b9d93cf2d393e3efda4c2977639c095d276311@changeid> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.78 / 15.00 / 200.00 X-Rspamd-Queue-Id: 408E540813 X-Rspamd-UID: 62769c Since l2cap_sock_teardown_cb doesn't acquire the channel lock before setting the socket as zapped, it could potentially race with l2cap_sock_release which frees the socket. Thus, wait until the cleanup is complete before marking the socket as zapped. This race was reproduced on a JBL GO speaker after the remote device rejected L2CAP connection due to resource unavailability. Here is a dmesg log with debug logs from a repro of this bug: [ 3465.424086] Bluetooth: hci_core.c:hci_acldata_packet() hci0 len 16 handle 0x0003 flags 0x0002 [ 3465.424090] Bluetooth: hci_conn.c:hci_conn_enter_active_mode() hcon 00000000cfedd07d mode 0 [ 3465.424094] Bluetooth: l2cap_core.c:l2cap_recv_acldata() conn 000000007eae8952 len 16 flags 0x2 [ 3465.424098] Bluetooth: l2cap_core.c:l2cap_recv_frame() len 12, cid 0x0001 [ 3465.424102] Bluetooth: l2cap_core.c:l2cap_raw_recv() conn 000000007eae8952 [ 3465.424175] Bluetooth: l2cap_core.c:l2cap_sig_channel() code 0x03 len 8 id 0x0c [ 3465.424180] Bluetooth: l2cap_core.c:l2cap_connect_create_rsp() dcid 0x0045 scid 0x0000 result 0x02 status 0x00 [ 3465.424189] Bluetooth: l2cap_core.c:l2cap_chan_put() chan 000000006acf9bff orig refcnt 4 [ 3465.424196] Bluetooth: l2cap_core.c:l2cap_chan_del() chan 000000006acf9bff, conn 000000007eae8952, err 111, state BT_CONNECT [ 3465.424203] Bluetooth: l2cap_sock.c:l2cap_sock_teardown_cb() chan 000000006acf9bff state BT_CONNECT [ 3465.424221] Bluetooth: l2cap_core.c:l2cap_chan_put() chan 000000006acf9bff orig refcnt 3 [ 3465.424226] Bluetooth: hci_core.h:hci_conn_drop() hcon 00000000cfedd07d orig refcnt 6 [ 3465.424234] BUG: spinlock bad magic on CPU#2, kworker/u17:0/159 [ 3465.425626] Bluetooth: hci_sock.c:hci_sock_sendmsg() sock 000000002bb0cb64 sk 00000000a7964053 [ 3465.430330] lock: 0xffffff804410aac0, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0 [ 3465.430332] Causing a watchdog bite! Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reported-by: Balakrishna Godavarthi <bgodavar@codeaurora.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- We had some more data available (outside of dmesg and oops) that led us to suspect a race between l2cap_sock_teardown_cb and l2cap_sock_release. I've left this out of the commit message since it's not an oops or dmesg logs. Crash stack from CPU4: -- -24 |spin_bug( | [X19] lock = 0xFFFFFF810BDB1EC0, | [X20] msg = 0xFFFFFFD143FD7960) -25 |debug_spin_lock_before(inline) | [X19] lock = 0xFFFFFF810BDB1EC0 -25 |do_raw_spin_lock( | [X19] lock = 0xFFFFFF810BDB1EC0) -26 |raw_spin_lock_irqsave( | [X19] lock = 0xFFFFFF810BDB1EC0) -27 |skb_peek(inline) -27 |__skb_dequeue(inline) -27 |skb_dequeue( | [X20] list = 0xFFFFFF810BDB1EA8) | [locdesc] flags = 12297829382473034410 -28 |skb_queue_purge( | [X19] list = 0xFFFFFF810BDB1EA8 -> ( | [D:0xFFFFFF810BDB1EA8] next = 0x0, | [D:0xFFFFFF810BDB1EB0] prev = 0x0, | [D:0xFFFFFF810BDB1EB8] qlen = 0, | [D:0xFFFFFF810BDB1EC0] lock = ([D:0xFFFFFF810BDB1EC0] rlock = ([D:0xFFFFFF810BDB1EC0] raw_lock | [X0] skb = ??? -29 |l2cap_seq_list_free(inline) | [locdesc] seq_list = 0xFFFFFF810BDB1ED8 -> ( | [D:0xFFFFFF810BDB1ED8] head = 0, | [D:0xFFFFFF810BDB1EDA] tail = 0, | [D:0xFFFFFF810BDB1EDC] mask = 0, | [D:0xFFFFFF810BDB1EE0] list = 0x0) -29 |l2cap_chan_del( | [X19] chan = 0xFFFFFF810BDB1C00, | ?) -30 |l2cap_chan_unlock(inline) -30 |l2cap_connect_create_rsp(inline) | [X20] conn = 0xFFFFFF81231F2600 | [locdesc] err = 0 | [X27] chan = 0xFFFFFF810BDB1C00 -30 |l2cap_bredr_sig_cmd(inline) | [X20] conn = 0xFFFFFF81231F2600 | [locdesc] err = 0 -30 |l2cap_sig_channel(inline) | [X20] conn = 0xFFFFFF81231F2600 | [X19] skb = 0xFFFFFF813DE4C040 | [X28] data = 0xFFFFFF8131582014 | [locdesc] cmd_len = 43690 -30 |l2cap_recv_frame( | [X20] conn = 0xFFFFFF81231F2600, | [X19] skb = 0xFFFFFF813DE4C040) | [locdesc] psm = 43690 -31 |l2cap_recv_acldata( | ?, | [X19] skb = 0xFFFFFF813DE4C040, | ?) | [X21] len = 16 -32 |hci_rx_work( | ?) | [X21] hdev = 0xFFFFFF8133A02000 -33 |__read_once_size(inline) | [locdesc] size = 4 -33 |atomic_read(inline) | [locdesc] __u = ([locdesc] __val = -1431655766, [locdesc] __c = (170)) -33 |static_key_count(inline) -33 |static_key_false(inline) -33 |trace_workqueue_execute_end(inline) | [X22] work = 0xFFFFFF8133A02838 -33 |process_one_work( | [X19] worker = 0xFFFFFF8133FE4500, | [X22] work = 0xFFFFFF8133A02838) | [locdesc] work_color = -1431655766 -34 |__read_once_size(inline) | [locdesc] size = 8 -34 |list_empty(inline) | [locdesc] __u = ([locdesc] __val = 0xAAAAAAAAAAAAAAAA, [locdesc] __c = (170)) -34 |worker_thread( | [X19] __worker = 0xFFFFFF8133FE4500) | [X19] worker = 0xFFFFFF8133FE4500 -35 |kthread( | [X20] _create = 0xFFFFFF8133FB3A00) | [X20] create = 0xFFFFFF8133FB3A00 | [X0] ret = ??? -36 |ret_from_fork(asm) net/bluetooth/l2cap_sock.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index e1a3e66b175402..e7cfe28140c39b 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1521,8 +1521,6 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err) parent = bt_sk(sk)->parent; - sock_set_flag(sk, SOCK_ZAPPED); - switch (chan->state) { case BT_OPEN: case BT_BOUND: @@ -1549,8 +1547,11 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err) break; } - release_sock(sk); + + /* Only zap after cleanup to avoid use after free race */ + sock_set_flag(sk, SOCK_ZAPPED); + } static void l2cap_sock_state_change_cb(struct l2cap_chan *chan, int state, -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ILXxEJBbOF/j1gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 16 Aug 2020 00:02:56 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id SF3ND5BbOF8XVAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 16 Aug 2020 00:02:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BD58B420C5; Sun, 16 Aug 2020 00:02:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728911AbgHOVvo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 15 Aug 2020 17:51:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728863AbgHOVvh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 15 Aug 2020 17:51:37 -0400 Received: from mail-io1-xd48.google.com (mail-io1-xd48.google.com [IPv6:2607:f8b0:4864:20::d48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D42EFC0002FE for <linux-bluetooth@vger.kernel.org>; Sat, 15 Aug 2020 10:19:25 -0700 (PDT) Received: by mail-io1-xd48.google.com with SMTP id c1so7774948ioh.16 for <linux-bluetooth@vger.kernel.org>; Sat, 15 Aug 2020 10:19:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=t8QMO3n4KROmSRkoKVG2lLOeJzzDaqBTfQOpgHU7bgA=; b=h6p+KzJ+2Iykq3yWaxNpmZcWKqiyZS7m9iMB+d647jnH3IJvyxqf6ur7KwYyxsyaoz AfKcnc5Suy4EK5W5ze9QAPyCojnNz8QQ8LaKV/T47o11dgz6JLMO7xilVClB29Gdyxi8 kmxuPvLs7XyMW90NVM+YbYZoR/19gsufw1361j8iqloVcfZpNajsjqsGihzj7PciSJS0 S6xwx0I2Ic/3GsGRiHzxIALSLbsYIxeh9HJrasTMVW9uOJddCzFjFvemckA/Epb8xSnY uILRnXTGlVsy4idmT/H+KhD4XlafnSQoNCf1EZVnqr7GLgkpUt2Zpskok1gVszG76H0R o4yA== X-Gm-Message-State: AOAM531s07p5cHYYHHtQ5KvbrhyjotR7JiBOCyEEzGMeFQ+maCdlmzll BVqfGIAYFankRbfvZz9WnXzYcGeFZY3pBMgrzVPp2Vw9ZVOs X-Google-Smtp-Source: ABdhPJwuiQ330unLGWYjqFD92eeYv7ieCWrxq3Aup/qHbAfQlSVCCMJLJOr7JsR076+ho+SlBCbpNUu4pGvr8oOWH/UxiyB1o8EX MIME-Version: 1.0 X-Received: by 2002:a02:866d:: with SMTP id e100mr7502553jai.83.1597511964807; Sat, 15 Aug 2020 10:19:24 -0700 (PDT) Date: Sat, 15 Aug 2020 10:19:24 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000002fe0e605acedbdfc@google.com> Subject: KMSAN: uninit-value in hci_chan_lookup_handle From: syzbot <syzbot+4c14a8f574461e1c3659@syzkaller.appspotmail.com> To: davem@davemloft.net, glider@google.com, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: BD58B420C5 X-Rspamd-UID: fa93be Hello, syzbot found the following issue on: HEAD commit: ce8056d1 wip: changed copy_from_user where instrumented git tree: https://github.com/google/kmsan.git master console output: https://syzkaller.appspot.com/x/log.txt?x=16c0e1e2900000 kernel config: https://syzkaller.appspot.com/x/.config?x=3afe005fb99591f dashboard link: https://syzkaller.appspot.com/bug?extid=4c14a8f574461e1c3659 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16fd6aa6900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=105910ce900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+4c14a8f574461e1c3659@syzkaller.appspotmail.com ===================================================== BUG: KMSAN: uninit-value in __hci_chan_lookup_handle net/bluetooth/hci_conn.c:1741 [inline] BUG: KMSAN: uninit-value in hci_chan_lookup_handle+0x1e3/0x310 net/bluetooth/hci_conn.c:1757 CPU: 0 PID: 8496 Comm: kworker/u5:2 Not tainted 5.8.0-rc5-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci0 hci_rx_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x21c/0x280 lib/dump_stack.c:118 kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:121 __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:215 __hci_chan_lookup_handle net/bluetooth/hci_conn.c:1741 [inline] hci_chan_lookup_handle+0x1e3/0x310 net/bluetooth/hci_conn.c:1757 hci_disconn_loglink_complete_evt net/bluetooth/hci_event.c:4992 [inline] hci_event_packet+0x14e10/0x39d30 net/bluetooth/hci_event.c:6176 hci_rx_work+0x6df/0xd30 net/bluetooth/hci_core.c:4705 process_one_work+0x1688/0x2140 kernel/workqueue.c:2269 worker_thread+0x10bc/0x2730 kernel/workqueue.c:2415 kthread+0x551/0x590 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Uninit was created at: kmsan_save_stack_with_flags mm/kmsan/kmsan.c:144 [inline] kmsan_internal_poison_shadow+0x66/0xd0 mm/kmsan/kmsan.c:127 kmsan_slab_alloc+0x8a/0xe0 mm/kmsan/kmsan_hooks.c:80 slab_alloc_node mm/slub.c:2839 [inline] __kmalloc_node_track_caller+0xeab/0x12e0 mm/slub.c:4478 __kmalloc_reserve net/core/skbuff.c:142 [inline] __alloc_skb+0x35f/0xb30 net/core/skbuff.c:210 alloc_skb include/linux/skbuff.h:1083 [inline] bt_skb_alloc include/net/bluetooth/bluetooth.h:377 [inline] vhci_get_user drivers/bluetooth/hci_vhci.c:165 [inline] vhci_write+0x18a/0x890 drivers/bluetooth/hci_vhci.c:285 call_write_iter include/linux/fs.h:1908 [inline] new_sync_write fs/read_write.c:503 [inline] vfs_write+0xf9a/0x17c0 fs/read_write.c:578 ksys_write+0x275/0x500 fs/read_write.c:631 __do_sys_write fs/read_write.c:643 [inline] __se_sys_write+0x92/0xb0 fs/read_write.c:640 __x64_sys_write+0x4a/0x70 fs/read_write.c:640 do_syscall_64+0xad/0x160 arch/x86/entry/common.c:386 entry_SYSCALL_64_after_hwframe+0x44/0xa9 ===================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sMFoEd9bOF/j1gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 16 Aug 2020 00:04:15 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ACSaD99bOF9d7wEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 16 Aug 2020 00:04:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 17D32420C8; Sun, 16 Aug 2020 00:04:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728116AbgHOWAK (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 15 Aug 2020 18:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728853AbgHOVvh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 15 Aug 2020 17:51:37 -0400 Received: from mail-il1-x148.google.com (mail-il1-x148.google.com [IPv6:2607:f8b0:4864:20::148]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE1FAC0F26CD for <linux-bluetooth@vger.kernel.org>; Sat, 15 Aug 2020 10:19:25 -0700 (PDT) Received: by mail-il1-x148.google.com with SMTP id e12so8795392ile.14 for <linux-bluetooth@vger.kernel.org>; Sat, 15 Aug 2020 10:19:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=GpKlYOLTQ3NZOHf3k+bXCS8gLg7b2ROCnIxYzCs9K7Y=; b=hZZ5rjeuraBiLyXJEtf7NMqp6FrZnQM0Mq1EJ78ra384MysBAd4CkhnaI8m7CbWmEq R+gnsoQ60x516mRPVAusXDfoxp7otW+D8Vpvf/bS5IyMKVutJHR18rZTcLAc0UUTaU+O 7Qb2u85LxUN2oBLQhIkEiYPwYGMXLgGhJhchxYwSC5DIs2p70q6UZBx17v2koWRxcQBc g2XNEwEzyE8oGfOYYBUPIA6cgHxc9ZcllU202ZrUNhGXDlCgZERctYBSvqlfvNZ0fFsN QMx1sbnxHlj9ua00tMvSHB72Imljofq+a6VRV0iWF7Gpz2EdEKNgxnezg/yNZoA5mcoR Ee7w== X-Gm-Message-State: AOAM532H12PHFn8zdGAX1W1r08s77MW+TcjfIhF/rbJ7gDMtcUlCdblk boveot9JhzY9l5q3lHeFeOft9+duqPzFe4MUke84ZWdb4yhJ X-Google-Smtp-Source: ABdhPJzgWk0fNRRV9SxWB4STKsUr+rNsP+8+REIA7cb/c2NKeIHdOl1bkAZJR4qeWpTJhROEEuaRmDE7QKSDCrP/+Du82uxCBax8 MIME-Version: 1.0 X-Received: by 2002:a05:6e02:792:: with SMTP id q18mr7200462ils.104.1597511965051; Sat, 15 Aug 2020 10:19:25 -0700 (PDT) Date: Sat, 15 Aug 2020 10:19:25 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000033913705acedbd6b@google.com> Subject: memory leak in read_adv_mon_features From: syzbot <syzbot+f7f6e564f4202d8601c6@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 17D32420C8 X-Rspamd-UID: 8079c6 Hello, syzbot found the following issue on: HEAD commit: 7fca4dee Merge tag 'powerpc-5.9-2' of git://git.kernel.org.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=15ea92a1900000 kernel config: https://syzkaller.appspot.com/x/.config?x=e320bbff976a5cdc dashboard link: https://syzkaller.appspot.com/bug?extid=f7f6e564f4202d8601c6 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1286db9a900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1143ddf6900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+f7f6e564f4202d8601c6@syzkaller.appspotmail.com BUG: memory leak unreferenced object 0xffff88812b18e6e0 (size 32): comm "syz-executor286", pid 6490, jiffies 4294993450 (age 13.120s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 20 00 10 00 00 00 00 00 ........ ....... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000f286b99c>] kmalloc include/linux/slab.h:559 [inline] [<00000000f286b99c>] read_adv_mon_features+0xa1/0x150 net/bluetooth/mgmt.c:4180 [<00000000f0f16504>] hci_mgmt_cmd net/bluetooth/hci_sock.c:1603 [inline] [<00000000f0f16504>] hci_sock_sendmsg+0xb01/0xc60 net/bluetooth/hci_sock.c:1738 [<000000001560da71>] sock_sendmsg_nosec net/socket.c:651 [inline] [<000000001560da71>] sock_sendmsg+0x4c/0x60 net/socket.c:671 [<000000007d7be9f6>] sock_write_iter+0xc5/0x140 net/socket.c:998 [<00000000e3633d41>] call_write_iter include/linux/fs.h:1882 [inline] [<00000000e3633d41>] new_sync_write+0x173/0x210 fs/read_write.c:503 [<0000000021a87df2>] vfs_write+0x21d/0x280 fs/read_write.c:578 [<0000000003f07ff6>] ksys_write+0xd8/0x120 fs/read_write.c:631 [<0000000003a7df09>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 [<000000005ecd28f6>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 BUG: memory leak unreferenced object 0xffff88812b18e660 (size 32): comm "syz-executor286", pid 6495, jiffies 4294993998 (age 7.640s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 20 00 10 00 00 00 00 00 ........ ....... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000f286b99c>] kmalloc include/linux/slab.h:559 [inline] [<00000000f286b99c>] read_adv_mon_features+0xa1/0x150 net/bluetooth/mgmt.c:4180 [<00000000f0f16504>] hci_mgmt_cmd net/bluetooth/hci_sock.c:1603 [inline] [<00000000f0f16504>] hci_sock_sendmsg+0xb01/0xc60 net/bluetooth/hci_sock.c:1738 [<000000001560da71>] sock_sendmsg_nosec net/socket.c:651 [inline] [<000000001560da71>] sock_sendmsg+0x4c/0x60 net/socket.c:671 [<000000007d7be9f6>] sock_write_iter+0xc5/0x140 net/socket.c:998 [<00000000e3633d41>] call_write_iter include/linux/fs.h:1882 [inline] [<00000000e3633d41>] new_sync_write+0x173/0x210 fs/read_write.c:503 [<0000000021a87df2>] vfs_write+0x21d/0x280 fs/read_write.c:578 [<0000000003f07ff6>] ksys_write+0xd8/0x120 fs/read_write.c:631 [<0000000003a7df09>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 [<000000005ecd28f6>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EABhJdrqOF9hXQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 16 Aug 2020 10:14:18 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SKKII9rqOF9rbwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 16 Aug 2020 10:14:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D7288A190F; Sun, 16 Aug 2020 10:14:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728746AbgHPIOI (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 16 Aug 2020 04:14:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725986AbgHPIOE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 16 Aug 2020 04:14:04 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38535C061756; Sun, 16 Aug 2020 01:14:04 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id v4so14241149ljd.0; Sun, 16 Aug 2020 01:14:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=bcZntAIR5yiduRedyBOkEhWnIQVjSv+jGHpqWFNJEk0=; b=eP3TePlBVUJ/eODfTYNXP1IVxLPaYTu0UrtLqRgS8qLbXhHx3HJWwqJgERuewkWblC x5foXZyrSCswF9iPp8ppApJh0xTLD0Z6fxa2CQCyP1OtWQyvo6mj8k9mYGyXo0m/FmTx 9+XGClEILI5Uk0MbOH5CJYaAlvAmx5HTqpM1nFAoKuDiTW2Ip9s4S57F1F7hNIr6D47g RMD3KOnklV+PrKloWLJMeHKIVtppeqMIQVUOovwChl91vVw9uUKBbl8f6sUjrWlI8hTa 3/dfYOXZWiiP//nzPI3h9hTSsN13EqBaY8BBic/bgajoEoTvmkYP1uLQ7ChdzFrLSsMR k9iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=bcZntAIR5yiduRedyBOkEhWnIQVjSv+jGHpqWFNJEk0=; b=MeCI4d0Y5Gg1mU+qrsc7JgQll/RFRwRqlNoh+YkRTh5S3n82bfjrM4mIxc4vzOkYPV 0RS6hXvsS/JVfDSPniXBdhbkdtmFk+V+FKgR6+GnYBP7SRh0AvH8snhb8ky1BUWd5nla rf/wgU5c/iCmsZHI0ChnpVJsgEjVKCv9bQ5scLw0j+1HDI3kPMEtweh0SK7x0mmv+JKe zMA986kYMHiot1K7U5QuU1B1/8uSKWwcZkssLla8E8huDK9JHN8fI3xL+Kalno6ndT0D Iq5gtYqL+gjMhuMkRygb+QAQVuYBAZYItmlGEgwQaVJoe/HSnRASaD0CB1Lud5+0b9q6 RmEw== X-Gm-Message-State: AOAM5315oFwe94XBfIghK8U5fbeG4DqDchFKPgkZDmeeKV06X8aJ4xh1 B3jSitE9ppxsJll/y/D6+uvsYYf9u90UXtJ4GDULZZbriyEK6tFA X-Google-Smtp-Source: ABdhPJz0V5KIQgcAA7RY/i1gNrKWEWz1r1xkvKxD8xBu2aHhkP3VuMF30qAZarvxvQ6hGhvvALz+hfYM24/3t3fzLaw= X-Received: by 2002:a05:651c:2cb:: with SMTP id f11mr4594604ljo.431.1597565640647; Sun, 16 Aug 2020 01:14:00 -0700 (PDT) MIME-Version: 1.0 From: Fox Chen <foxhlchen@gmail.com> Date: Sun, 16 Aug 2020 16:13:49 +0800 Message-ID: <CAC2o3D+g9BHpMNJCj3z5QWt3_+k+sUGaGSww+s-udyPP9tEkUg@mail.gmail.com> Subject: HCI_EV_PHY_LINK_COMPLETE in net/bluetooth/hci_event.c To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg KH <gregkh@linuxfoundation.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: D7288A190F X-Rspamd-UID: 165edd Dear all, I have a question about static void hci_phy_link_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) -- HCI_EV_PHY_LINK_COMPLETE event packet handler in hci_even.c:4940 if (ev->status) { hci_conn_del(hcon); <-------------- hci_dev_unlock(hdev); return; } Is it correct to del hcon here?? Because later on, when we close the socket fd, socket_close will call sco_chan_del which will eventually call hci_conn_drop. With hcon already deleted by this handler, it will crash. This bug is reported by syzbot in https://syzkaller.appspot.com/bug?id=57e98513afbe427bbd65ac295130bcf5bc860dd8 I'm trying to fix that, but I don't know the design nature of HCI_EV_PHY_LINK_COMPLETE. Will this scenario happen in real life?? Can I remove hci_conn_del(hcon) here (I tested it, which fixes this bug) ?? Thanks, Fox Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sPEMH2vwOV8esAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 04:50:19 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8LRRHWvwOV+GvQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 04:50:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7D52941298; Mon, 17 Aug 2020 04:50:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726898AbgHQCuF (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 16 Aug 2020 22:50:05 -0400 Received: from lucky1.263xmail.com ([211.157.147.133]:39990 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbgHQCuD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 16 Aug 2020 22:50:03 -0400 X-Greylist: delayed 442 seconds by postgrey-1.27 at vger.kernel.org; Sun, 16 Aug 2020 22:50:02 EDT Received: from localhost (unknown [192.168.167.235]) by lucky1.263xmail.com (Postfix) with ESMTP id DCD08C5EB9 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 10:42:34 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED: 0 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [113.57.152.160]) by smtp.263.net (postfix) whith ESMTP id P18320T139785900570368S1597632154375135_; Mon, 17 Aug 2020 10:42:35 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <607354c5bf9259ae2c0df726aa5bea82> X-RL-SENDER: chengbo@uniontech.com X-SENDER: chengbo@uniontech.com X-LOGIN-NAME: chengbo@uniontech.com X-FST-TO: linux-bluetooth@vger.kernel.org X-SENDER-IP: 113.57.152.160 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: chengbo <515672508@qq.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/1] scr:Set property mode failed,memory leak Date: Mon, 17 Aug 2020 10:42:34 +0800 Message-Id: <20200817024234.13758-1-515672508@qq.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.70 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7D52941298 X-Rspamd-UID: 224460 This patch will fix a memory leak,when set property mode, it will creat a request,if failed,the data's memory do not free --- src/adapter.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..3d07921a7 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2917,9 +2917,10 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, data->id = id; if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param, - property_set_mode_complete, data, g_free) > 0) + property_set_mode_complete, data, g_free) > 0) { + g_free(data); return; - + } g_free(data); failed: -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yMz4A5swOl/e1QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 09:24:11 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UMy6AJswOl9YOgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 09:24:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AF4E3A15ED; Mon, 17 Aug 2020 09:24:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726194AbgHQHXz (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 03:23:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725765AbgHQHXy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 03:23:54 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 060FFC061388 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 00:23:53 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id t14so13020697wmi.3 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 00:23:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vOGqHtr5VUN/O/Q25+wJOUQ13DGoVd1SRCXNWEYZZuk=; b=XfiQf3kzucTaickG4QyikCvE9Y/1BUDVhlENgRIuTLOxP77k7+BKJxRjJ+YLsU4gOJ 44XWkbhhBVsKGNx/Tf7SDuj84HPYYH6yu+KqIt1jBD9PErUQG4KJAsgkMITfBv8AFq+6 T0Y8ck1TmpZpH9xXYJVuD0DCSOYyRIF9T30w45YWvc4G2Fvp+OsO3h+8N1VTj4sUeAAI IZznBPhoyoiFREEUgkHygEZim+EBdWq7nFyERLh1cMcY28hcf+loXYWko9BpFG/AxMlu FVjOCYhGxxZp+Wvv3KYIHpO6oLtuyI8V4mZettK17N4FL/qgNPKuo0LypXd7AD569oKb 11CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vOGqHtr5VUN/O/Q25+wJOUQ13DGoVd1SRCXNWEYZZuk=; b=Co48oc1/zykuPro786BAZwmO60FGfjnm6awpwo95yFoOSMf6cXSkv7Qq8Jf7O5QYOK kY2Y43Hn3g9q9a1cueEkkJDVExTKIwZMjjwv7l23B0Xg0cQeayeBdqL2TFAEFc3Kvef8 Rak0Ftrsjs88pSI7DGqadkwavafhltrg59fzvWqD8AJp1fA98vn63nId4jfLQ9JMgmg6 EDR3FftnDWKyx3We5/OmAj++KV+O+vIVlGAUwvdr2HAoVDBG775th+SodRaN1+UNNzop TNvgZQ6QCBQXylgsAeEFsc/qmdY8BLmUhRtHwXla+AFA3nMByWR7tk35PTuQG9kgottJ 6JMg== X-Gm-Message-State: AOAM530SKB9/7iYpvH9ThlBQ3/yZCzJXoJkvfHTt5efewpeuyilK/k5B U9dnc14r8vvgRGSqy4QkKt76tYgbG7SVfF/ZfJGEGw== X-Google-Smtp-Source: ABdhPJxlA48gou57NxM+JSjZXfdSs+iThswkreEWh79QRz1tJ6kAGVTu7KO+OmT/CoTfonuJJh/Wh10qXqPdX7og4Gc= X-Received: by 2002:a7b:c401:: with SMTP id k1mr12970484wmi.18.1597649032287; Mon, 17 Aug 2020 00:23:52 -0700 (PDT) MIME-Version: 1.0 References: <20200812121946.Bluez.v1.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> <CABBYNZKUDn-gWfkZzH4kO5c6kRNMomH9-o8XHJ_Lv+7ujrMNrw@mail.gmail.com> In-Reply-To: <CABBYNZKUDn-gWfkZzH4kO5c6kRNMomH9-o8XHJ_Lv+7ujrMNrw@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Mon, 17 Aug 2020 15:23:41 +0800 Message-ID: <CAJQfnxFcEqWrGqWCPSL-F4PZRyvwYRSRUcthEOW1Gn4q0bZO1g@mail.gmail.com> Subject: Re: [Bluez PATCH v1] input: Don't browse SDP if HIDSDPDisable is set To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.39 / 15.00 / 200.00 X-Rspamd-Queue-Id: AF4E3A15ED X-Rspamd-UID: 2da303 Hi Luiz, On Sat, 15 Aug 2020 at 02:59, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Archie, > > On Tue, Aug 11, 2020 at 9:21 PM Archie Pusaka <apusaka@google.com> wrote: > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > According to the HID1.1 spec, part 5.3.4.9: > > The HIDSDPDisable attribute is a Boolean value, which indicates > > whether connection to the SDP channel and Control or Interrupt > > channels are mutually exclusive. This feature supports Bluetooth > > HID devices that have minimal resources, and multiplex those > > resources between servicing the initialization (SDP) and runtime > > (Control and Interrupt) channels. > > > > However, Bluez still tries to connect SDP upon HID connection, > > regardless of the existence of the HIDSDPDisable attribute. > > > > This patch prevents the connection of SDP after HID has been > > established, if the device has HIDSDPDisable attribute. > > > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > --- > > > > profiles/input/device.c | 2 ++ > > src/device.c | 8 +++++++- > > src/device.h | 1 + > > 3 files changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/profiles/input/device.c b/profiles/input/device.c > > index 6ec0a4c63..fac8c6896 100644 > > --- a/profiles/input/device.c > > +++ b/profiles/input/device.c > > @@ -1373,6 +1373,8 @@ static struct input_device *input_device_new(struct btd_service *service) > > /* Initialize device properties */ > > extract_hid_props(idev, rec); > > > > + device_set_skip_passive_sdp_discovery(device, idev->disable_sdp); > > Shouldn't you actually be checking for the presence of HIDSDPDisable, Yes, the variable idev->disable_sdp stores the presence of HIDSDPDisable attribute. > I suppose the first time when you pair with it the SDP must be active > in order for us to be able to probe the drivers, then once we get the > SDP records stored we should inhibit the refresh of the records. Correct, the first time we pair the device, SDP is still active as usual. The additional check is only applied when refreshing the SDP records. > > > return idev; > > } > > > > diff --git a/src/device.c b/src/device.c > > index 2237a7670..a67787a2d 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -195,6 +195,7 @@ struct btd_device { > > bool le; > > bool pending_paired; /* "Paired" waiting for SDP */ > > bool svc_refreshed; > > + bool skip_passive_sdp_discovery; > > > > /* Manage whether this device can wake the system from suspend. > > * - wake_support: Requires a profile that supports wake (i.e. HID) > > @@ -1472,6 +1473,10 @@ static gboolean dev_property_wake_allowed_exist( > > return device_get_wake_support(device); > > } > > > > +void device_set_skip_passive_sdp_discovery(struct btd_device *dev, bool skip) > > +{ > > + dev->skip_passive_sdp_discovery = skip; > > +} > > > > static gboolean disconnect_all(gpointer user_data) > > { > > @@ -1805,7 +1810,8 @@ done: > > btd_error_failed(dev->connect, strerror(-err))); > > } else { > > /* Start passive SDP discovery to update known services */ > > - if (dev->bredr && !dev->svc_refreshed) > > + if (dev->bredr && !dev->svc_refreshed && > > + !dev->skip_passive_sdp_discovery) > > device_browse_sdp(dev, NULL); > > g_dbus_send_reply(dbus_conn, dev->connect, DBUS_TYPE_INVALID); > > } > > diff --git a/src/device.h b/src/device.h > > index cb8d884e8..5348d2652 100644 > > --- a/src/device.h > > +++ b/src/device.h > > @@ -145,6 +145,7 @@ void device_set_wake_override(struct btd_device *device, bool wake_override); > > void device_set_wake_allowed(struct btd_device *device, bool wake_allowed, > > guint32 id); > > void device_set_wake_allowed_complete(struct btd_device *device); > > +void device_set_skip_passive_sdp_discovery(struct btd_device *dev, bool skip); > > > > typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal, > > void *user_data); > > -- > > 2.28.0.236.gb10cc79966-goog > > > > > -- > Luiz Augusto von Dentz Thanks, Archie Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QIWIJfqCOl+bEwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 15:15:38 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2FoNJPqCOl+LMgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 15:15:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B2A1340134; Mon, 17 Aug 2020 15:15:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728575AbgHQNPa convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 09:15:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:41394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728767AbgHQNMW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 09:12:22 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 198919] Xbox (One) Wireless Controller won't connect Date: Mon, 17 Aug 2020 13:12:21 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: high X-Bugzilla-Who: paananen.olli@tuta.io X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-198919-62941-ON7JMgpS0Q@https.bugzilla.kernel.org/> In-Reply-To: <bug-198919-62941@https.bugzilla.kernel.org/> References: <bug-198919-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.70 / 15.00 / 200.00 X-Rspamd-Queue-Id: B2A1340134 X-Rspamd-UID: 5f4f00 https://bugzilla.kernel.org/show_bug.cgi?id=198919 paananen.olli@tuta.io changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |paananen.olli@tuta.io --- Comment #4 from paananen.olli@tuta.io --- Same issue in Arch linux kernel 5.8.1. Worked fine before with xpadneo or xpad driver if disabled bluetooth ertm. Works properly with lts kernel (5.4.58) so regression happened somewhere between 5.4 and 5.8. Systemctl status bluetooth spams this: Refusing input device connect: No such file or directory (2) Refusing connection from *controller mac*: unknown device -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QJchDGakOl/qwwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 17:38:14 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id YL3WCmakOl8mZAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 17:38:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 26D20A1315; Mon, 17 Aug 2020 17:38:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730290AbgHQPbn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 11:31:43 -0400 Received: from mail-il1-f199.google.com ([209.85.166.199]:44029 "EHLO mail-il1-f199.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730283AbgHQPb1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 11:31:27 -0400 Received: by mail-il1-f199.google.com with SMTP id 2so12208142ill.10 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 08:31:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=W7K7lW55Dn94R20eYYTCzBxa9B+ssGzLwKDqHmECJpA=; b=jbqR/U4ptOyxFAQAQNkC43gn3M67fgoRNhhjjjRj7r5JubgrJ85ObMDknj8HXy9Pj+ VCWni942n/Lg8ZMoW8w8cQIcKulHhlMfhRQ7zqGWGOWG53QtdokxhW79z+aL603wNAkI IR6c+wl1sb35RLogG3gaf8/EbcWKwI1ZLBnCuaPhsdwo+GhWM/lyQFVxlndup5nUMzk9 J6LTnVusJG4Ho7AqIjyTNELYbiW8FJEWLwz/c4JQawwZsovH0+kMB2/9o1I4Qbx2f5og ftda1VVt4ZEkqsrn//gRB14JL/zxiPwS+ebIW8Ps1P4uT+nGqiSMUkfXOUJ1J1i3OLyH xVSA== X-Gm-Message-State: AOAM532BRlxJxoScAcV7D7d9Uri6A0yGD9iPKo3qphpsxX/ChDZhbwY9 /FECTEZoWaDi2UVcDLdb5VZX/GQGMxphlQ6QgHP+7Hj1qYE2 X-Google-Smtp-Source: ABdhPJwYKxGHy0MLF+yiMDC0FLZLpIMQg10/YFZtRi/BhjGZeROGoSHU7CDMfq2pXT/HGoE9GTN7fsDoqqAxcyEImusSusSEAMtS MIME-Version: 1.0 X-Received: by 2002:a05:6602:29c3:: with SMTP id z3mr12649177ioq.126.1597678286698; Mon, 17 Aug 2020 08:31:26 -0700 (PDT) Date: Mon, 17 Aug 2020 08:31:26 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000be7fb805ad147615@google.com> Subject: inconsistent lock state in sco_sock_timeout From: syzbot <syzbot+2f6d7c28bb4bf7e82060@syzkaller.appspotmail.com> To: a@unstable.cc, andrew@lunn.ch, b.a.t.m.a.n@lists.open-mesh.org, davem@davemloft.net, hkallweit1@gmail.com, jakub.kicinski@netronome.com, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, mareklindner@neomailbox.ch, netdev@vger.kernel.org, sw@simonwunderlich.de, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 26D20A1315 X-Rspamd-UID: a63c34 Hello, syzbot found the following issue on: HEAD commit: 2cc3c4b3 Merge tag 'io_uring-5.9-2020-08-15' of git://git... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10cf6aa6900000 kernel config: https://syzkaller.appspot.com/x/.config?x=19f02fc5c511a391 dashboard link: https://syzkaller.appspot.com/bug?extid=2f6d7c28bb4bf7e82060 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13071491900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11ec5be2900000 The issue was bisected to: commit 331c56ac73846fa267c04ee6aa9a00bb5fed9440 Author: Heiner Kallweit <hkallweit1@gmail.com> Date: Mon Aug 12 21:51:27 2019 +0000 net: phy: add phy_speed_down_core and phy_resolve_min_speed bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1623bea6900000 final oops: https://syzkaller.appspot.com/x/report.txt?x=1523bea6900000 console output: https://syzkaller.appspot.com/x/log.txt?x=1123bea6900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+2f6d7c28bb4bf7e82060@syzkaller.appspotmail.com Fixes: 331c56ac7384 ("net: phy: add phy_speed_down_core and phy_resolve_min_speed") ================================ WARNING: inconsistent lock state 5.8.0-syzkaller #0 Not tainted -------------------------------- inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage. swapper/1/0 [HC0[0]:SC1[1]:HE1:SE0] takes: ffff888088b810a0 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.?.}-{2:2}, at: spin_lock include/linux/spinlock.h:354 [inline] ffff888088b810a0 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.?.}-{2:2}, at: sco_sock_timeout+0x2b/0x280 net/bluetooth/sco.c:83 {SOFTIRQ-ON-W} state was registered at: lock_acquire+0x160/0x730 kernel/locking/lockdep.c:5005 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:354 [inline] sco_conn_del+0x100/0x710 net/bluetooth/sco.c:176 hci_disconn_cfm include/net/bluetooth/hci_core.h:1438 [inline] hci_conn_hash_flush+0x127/0x200 net/bluetooth/hci_conn.c:1557 hci_dev_do_close+0xb7b/0x1040 net/bluetooth/hci_core.c:1770 hci_unregister_dev+0x185/0x1590 net/bluetooth/hci_core.c:3790 vhci_release+0x73/0xc0 drivers/bluetooth/hci_vhci.c:340 __fput+0x34f/0x7b0 fs/file_table.c:281 task_work_run+0x137/0x1c0 kernel/task_work.c:141 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0x5f3/0x1f20 kernel/exit.c:806 do_group_exit+0x161/0x2d0 kernel/exit.c:903 get_signal+0x13bb/0x1d50 kernel/signal.c:2757 arch_do_signal+0x33/0x610 arch/x86/kernel/signal.c:811 exit_to_user_mode_loop kernel/entry/common.c:135 [inline] exit_to_user_mode_prepare+0x8d/0x1b0 kernel/entry/common.c:166 syscall_exit_to_user_mode+0x5e/0x1a0 kernel/entry/common.c:241 entry_SYSCALL_64_after_hwframe+0x44/0xa9 irq event stamp: 1760434 hardirqs last enabled at (1760434): [<ffffffff882bbc5f>] __raw_spin_unlock_irq include/linux/spinlock_api_smp.h:168 [inline] hardirqs last enabled at (1760434): [<ffffffff882bbc5f>] _raw_spin_unlock_irq+0x1f/0x80 kernel/locking/spinlock.c:199 hardirqs last disabled at (1760433): [<ffffffff882bbab1>] __raw_spin_lock_irq include/linux/spinlock_api_smp.h:126 [inline] hardirqs last disabled at (1760433): [<ffffffff882bbab1>] _raw_spin_lock_irq+0x41/0x80 kernel/locking/spinlock.c:167 softirqs last enabled at (1760422): [<ffffffff88292264>] sysvec_apic_timer_interrupt+0x14/0xf0 arch/x86/kernel/apic/apic.c:1091 softirqs last disabled at (1760423): [<ffffffff88400f2f>] asm_call_on_stack+0xf/0x20 arch/x86/entry/entry_64.S:706 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(slock-AF_BLUETOOTH-BTPROTO_SCO); <Interrupt> lock(slock-AF_BLUETOOTH-BTPROTO_SCO); *** DEADLOCK *** 1 lock held by swapper/1/0: #0: ffffc90000da8dc0 ((&sk->sk_timer)){+.-.}-{0:0}, at: lockdep_copy_map include/linux/lockdep.h:45 [inline] #0: ffffc90000da8dc0 ((&sk->sk_timer)){+.-.}-{0:0}, at: call_timer_fn+0x57/0x160 kernel/time/timer.c:1403 stack backtrace: CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: <IRQ> __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 print_usage_bug+0x1117/0x11d0 kernel/locking/lockdep.c:3350 mark_lock_irq arch/x86/include/asm/paravirt.h:661 [inline] mark_lock+0x10e2/0x1b00 kernel/locking/lockdep.c:4006 mark_usage kernel/locking/lockdep.c:3905 [inline] __lock_acquire+0xa99/0x2ab0 kernel/locking/lockdep.c:4380 lock_acquire+0x160/0x730 kernel/locking/lockdep.c:5005 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:354 [inline] sco_sock_timeout+0x2b/0x280 net/bluetooth/sco.c:83 call_timer_fn+0x91/0x160 kernel/time/timer.c:1413 expire_timers kernel/time/timer.c:1458 [inline] __run_timers+0x65e/0x830 kernel/time/timer.c:1755 run_timer_softirq+0x46/0x80 kernel/time/timer.c:1768 __do_softirq+0x236/0x66c kernel/softirq.c:298 asm_call_on_stack+0xf/0x20 arch/x86/entry/entry_64.S:706 </IRQ> __run_on_irqstack arch/x86/include/asm/irq_stack.h:22 [inline] run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:48 [inline] do_softirq_own_stack+0x91/0xe0 arch/x86/kernel/irq_64.c:77 invoke_softirq kernel/softirq.c:393 [inline] __irq_exit_rcu+0x1e1/0x1f0 kernel/softirq.c:423 irq_exit_rcu+0x5/0x10 kernel/softirq.c:435 sysvec_apic_timer_interrupt+0xd5/0xf0 arch/x86/kernel/apic/apic.c:1091 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:581 RIP: 0010:tick_nohz_idle_exit+0x2f2/0x3a0 kernel/time/tick-sched.c:1213 Code: 30 00 74 0c 48 c7 c7 08 15 4d 89 e8 f8 0b 4c 00 48 83 3d 48 52 e4 07 00 0f 84 a6 00 00 00 e8 95 37 0c 00 fb 66 0f 1f 44 00 00 <48> 83 c4 20 5b 41 5c 41 5d 41 5e 41 5f 5d c3 e8 7a 37 0c 00 0f 0b RSP: 0018:ffffc90000d3fe68 EFLAGS: 00000293 RAX: ffffffff8168c2cb RBX: ffff8880ae927f80 RCX: ffff8880a9a3e340 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff8168c29a RBP: 000000b26607d004 R08: ffffffff817abce0 R09: ffffed1015d26c6c R10: ffffed1015d26c6c R11: 0000000000000000 R12: 0000000000000000 R13: ffff8880ae927f54 R14: dffffc0000000000 R15: 1ffff11015d24fea do_idle+0x5fe/0x650 kernel/sched/idle.c:289 cpu_startup_entry+0x15/0x20 kernel/sched/idle.c:372 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. For information about bisection process see: https://goo.gl/tpsmEJ#bisection syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MN2bBgDOOl/QJQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 20:35:44 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id GEylBQDOOl/X2gEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 20:35:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 14BD240813; Mon, 17 Aug 2020 20:35:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389392AbgHQR2S (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 13:28:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730731AbgHQRLS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 13:11:18 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80FA2C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 10:11:18 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id h16so13992944oti.7 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 10:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hWeNEkNfq1meNCt3Isl8R2a96rkFpIvROSVf2r++u2A=; b=DjCAvyXBrXoVKz4YVQc7EDwas/ts6H55sPx9ZggebnplYs2N1tiY10AoS6GtOWRX6+ POMXgrOLVnnI8fmA5UYWze2KPq/zwFZkHGMBsx70p5BUbMtpFkhFmNFc27SPwoUJlSiy 1Fo2pabsGey1lvsJmMTrmcrqrKJVCzp14qEcIxfhnUuPOMmX2NqBJUnBRHu6pNA0SkRC 2u3bBsF+QhSnbXyAUXyhAy8s1bmd3ZklRxfeRxLbqn3Ltj8r0ffLiYUZOfyZvLRtY7de 7vkAL11ZiBcTROgUVaGvRzNg7CiEm8mPUB1EluSX2k7f+66Ba3g+aKh/b4UED2kZcDk4 KmIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hWeNEkNfq1meNCt3Isl8R2a96rkFpIvROSVf2r++u2A=; b=L8uzZDVRcUFrCAyxGbACQlGU4vEysB/DmFB7CjDPfV8wdQx3xFBV8xIWvxVBNU81Uo jEf5uxf3oXZGJ2FiAaSVMX+WN5/GL9YCtLGI1RrQ7J895J/m6X3h9ngGHecxr8IhxajH j1fYn+3gap2HgX/QcsZ11bwTfyN/RxgIycnqYKUFIxWzF2p8EtAsRlKC7WOzId3QXN6g SaRZ3kVD9EYY6DIlDrPhOfJl2pCur3S07kxISi+GIdGI2kXfucxPW8JTfcAJ7WaBxC+Y w92Eel14xcsau4ICmxUFzRjiRHyEKEX5e2s+sX8/OQiOlo1WDVufIqVqzOHDZrnG2cqc gmWw== X-Gm-Message-State: AOAM530LrRmEEsh52jyEHIYGkthxh8QqDrEXva7nhC/5XyRfNImPKEuN U9TCiSXzeXfJCmBhtj1gzVdZdlZq2UzgTbZ3+V8= X-Google-Smtp-Source: ABdhPJwwO5CkMRHDYb83BDrGy/TN6kFLnvXgqE1Zz4fYFPRm6BsOI0B45nI7sTsjjj6PG0lY5/q6ypziMDEeiMhxMf4= X-Received: by 2002:a9d:6053:: with SMTP id v19mr11500633otj.362.1597684277869; Mon, 17 Aug 2020 10:11:17 -0700 (PDT) MIME-Version: 1.0 References: <20200807142429.BlueZ.1.I588558f1e38231193d6e955a4008ce54712d5c89@changeid> In-Reply-To: <20200807142429.BlueZ.1.I588558f1e38231193d6e955a4008ce54712d5c89@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 17 Aug 2020 10:11:07 -0700 Message-ID: <CABBYNZL4s151e-a+X0fEA73RM54aA--m+on7as4dLrJX0xevQQ@mail.gmail.com> Subject: Re: [BlueZ PATCH] Disable auto-connect on cancel pair To: Manish Mandlik <mmandlik@google.com> Cc: Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.07 / 15.00 / 200.00 X-Rspamd-Queue-Id: 14BD240813 X-Rspamd-UID: 84aa00 Hi Manish, On Fri, Aug 7, 2020 at 2:24 PM Manish Mandlik <mmandlik@google.com> wrote: > > While pairing process is in progress, service discovery starts in the > background. If HOG profile is detected, auto connect is enabled for > that device. This causes future advertisement from that device to > trigger a pairing even if the user has already cancelled the pairing. So it looks like something is not right if the user cancel the pairing process I would expect the device to be removed if this happens when setting up a new device or at least call Disconnect method which would disable auto_connect if the device is not trusted. > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > Signed-off-by: Manish Mandlik <mmandlik@google.com> > --- > > src/device.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/src/device.c b/src/device.c > index 470596ee4..ab5bb123e 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -2870,6 +2870,15 @@ static void device_cancel_bonding(struct btd_device *device, uint8_t status) > if (!bonding) > return; > > + /* Auto connect may get enabled during the service discovery even > + * before the pairing process completes. In such case, disable it > + * when the user has cancelled the pairing process. > + */ > + if (device->auto_connect) { > + device->disable_auto_connect = TRUE; > + device_set_auto_connect(device, FALSE); > + } BlueZ has the trusted property so upper layer can actually flag if the device is trusted regardless if it is paired on not, so this seems out of place or we should at least check if if the device has been marked as trusted. > ba2str(&device->bdaddr, addr); > DBG("Canceling bonding request for %s", addr); > > -- > 2.28.0.236.gb10cc79966-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sCU7CFTOOl/QJQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 20:37:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yGsRBlTOOl8NVQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 20:37:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 119AE420D0; Mon, 17 Aug 2020 20:37:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389597AbgHQRbM (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 13:31:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389263AbgHQQ6R (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 12:58:17 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 206F6C061343 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 09:58:16 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id b22so15374104oic.8 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 09:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RiMNDic3Fr3dtj4r7uAD1eVHZ+S58Ejt8jAJ9yNaxDg=; b=ZJIyIqzoxc9pxvvi0PmXXi5rrfOWTFXka83ZwMCcVreRNeG5IQowoVKgyE8uDj2qSS jJY65Cu2VMCNcZX5HaY/3msj0wbFPTLUfVydWc9wjqwxmty0szcyDKWcYMUgjfwlli9V NRaren7WN2zX7j3mxPcBLfoprZ2eqh/q868FfCzPAlDvV9so4XJiQ3R2q9BUKSTnBYXo oTECBPBzWS9ZYbiujc8owOyEzKpQpAxYsMm85IocPvxcqXH9JqXSv+gMcsJMeZRrDTlg 0ekenHqmzjjOtzDQVTlQcoHbax5xRKN/RrFY3uM30bhsBY4A6q7+mzCFvNd4xsPn07F4 Ylcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RiMNDic3Fr3dtj4r7uAD1eVHZ+S58Ejt8jAJ9yNaxDg=; b=jcrlkeZ9zaBk21zcDX4olS3W1TlEFUUSGkfTqC8VQPoXZ8vKbV/uxd09FdtrYHcdHb AeFIujK+2uue/nYdo/lBfpfVW8EDWLZGlZx5OuOfQl0bhK8swnyNe112EzoBre/n0i85 uhocVtrdwVIDubWRxvlbNM5ZfOndw8eIS4KL8axLt4toveRCNPuTK6dALJt66glVC0Mn zfFNwzaFSxgM0fDyN6BxP7KUUjBvoBuPDzXrbc9kNZxhdO4H04/6EBD4ERJLXV0bk+e3 dhifdRgRd3mKiU0HYey7joWf48+txYsk3O+tGb2u0ZP1q7h8U/G+u32JkRlQqXKtWIWo 3+/A== X-Gm-Message-State: AOAM531d9U5PcShaCXtUWn2jjHTCprts1lpE5tbxxCNQkfIXhoOm6ioj 0kJO1mZrov2sfnysBGIZ+W24LQFhvaJC8cj2P6A= X-Google-Smtp-Source: ABdhPJyxRPgIgwZ3dfvBxFzTGe5KFA+ENncz5TUUK4kFTxuYbR4cRtMQoDRnqFMe0bE7vUEV1AFBJ+79+2/byGzZb/M= X-Received: by 2002:aca:cc50:: with SMTP id c77mr9582912oig.152.1597683495306; Mon, 17 Aug 2020 09:58:15 -0700 (PDT) MIME-Version: 1.0 References: <20200812121946.Bluez.v1.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> <CABBYNZKUDn-gWfkZzH4kO5c6kRNMomH9-o8XHJ_Lv+7ujrMNrw@mail.gmail.com> <CAJQfnxFcEqWrGqWCPSL-F4PZRyvwYRSRUcthEOW1Gn4q0bZO1g@mail.gmail.com> In-Reply-To: <CAJQfnxFcEqWrGqWCPSL-F4PZRyvwYRSRUcthEOW1Gn4q0bZO1g@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 17 Aug 2020 09:58:03 -0700 Message-ID: <CABBYNZJu2FQWPFUcJtvb93gp7gbD9_gOk_p2FxNaaBam0tW2VQ@mail.gmail.com> Subject: Re: [Bluez PATCH v1] input: Don't browse SDP if HIDSDPDisable is set To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.13 / 15.00 / 200.00 X-Rspamd-Queue-Id: 119AE420D0 X-Rspamd-UID: a9b1d7 Hi Archie, On Mon, Aug 17, 2020 at 12:23 AM Archie Pusaka <apusaka@google.com> wrote: > > Hi Luiz, > > > On Sat, 15 Aug 2020 at 02:59, Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Archie, > > > > On Tue, Aug 11, 2020 at 9:21 PM Archie Pusaka <apusaka@google.com> wrote: > > > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > > > According to the HID1.1 spec, part 5.3.4.9: > > > The HIDSDPDisable attribute is a Boolean value, which indicates > > > whether connection to the SDP channel and Control or Interrupt > > > channels are mutually exclusive. This feature supports Bluetooth > > > HID devices that have minimal resources, and multiplex those > > > resources between servicing the initialization (SDP) and runtime > > > (Control and Interrupt) channels. > > > > > > However, Bluez still tries to connect SDP upon HID connection, > > > regardless of the existence of the HIDSDPDisable attribute. > > > > > > This patch prevents the connection of SDP after HID has been > > > established, if the device has HIDSDPDisable attribute. > > > > > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > > --- > > > > > > profiles/input/device.c | 2 ++ > > > src/device.c | 8 +++++++- > > > src/device.h | 1 + > > > 3 files changed, 10 insertions(+), 1 deletion(-) > > > > > > diff --git a/profiles/input/device.c b/profiles/input/device.c > > > index 6ec0a4c63..fac8c6896 100644 > > > --- a/profiles/input/device.c > > > +++ b/profiles/input/device.c > > > @@ -1373,6 +1373,8 @@ static struct input_device *input_device_new(struct btd_service *service) > > > /* Initialize device properties */ > > > extract_hid_props(idev, rec); > > > > > > + device_set_skip_passive_sdp_discovery(device, idev->disable_sdp); > > > > Shouldn't you actually be checking for the presence of HIDSDPDisable, > > Yes, the variable idev->disable_sdp stores the presence of > HIDSDPDisable attribute. I didn't realize it was already being stored, now it makes sense. > > I suppose the first time when you pair with it the SDP must be active > > in order for us to be able to probe the drivers, then once we get the > > SDP records stored we should inhibit the refresh of the records. > > Correct, the first time we pair the device, SDP is still active as > usual. The additional check is only applied when refreshing the SDP > records. > > > > > > return idev; > > > } > > > > > > diff --git a/src/device.c b/src/device.c > > > index 2237a7670..a67787a2d 100644 > > > --- a/src/device.c > > > +++ b/src/device.c > > > @@ -195,6 +195,7 @@ struct btd_device { > > > bool le; > > > bool pending_paired; /* "Paired" waiting for SDP */ > > > bool svc_refreshed; > > > + bool skip_passive_sdp_discovery; Let's have it as refresh_discovery and I'd add support for setting it globally on main.conf so we can initialize it with main_opts.refresh_discovery so we are consistent with the terminology we have been using. > > > > > > /* Manage whether this device can wake the system from suspend. > > > * - wake_support: Requires a profile that supports wake (i.e. HID) > > > @@ -1472,6 +1473,10 @@ static gboolean dev_property_wake_allowed_exist( > > > return device_get_wake_support(device); > > > } > > > > > > +void device_set_skip_passive_sdp_discovery(struct btd_device *dev, bool skip) > > > +{ > > > + dev->skip_passive_sdp_discovery = skip; > > > +} > > > > > > static gboolean disconnect_all(gpointer user_data) > > > { > > > @@ -1805,7 +1810,8 @@ done: > > > btd_error_failed(dev->connect, strerror(-err))); > > > } else { > > > /* Start passive SDP discovery to update known services */ > > > - if (dev->bredr && !dev->svc_refreshed) > > > + if (dev->bredr && !dev->svc_refreshed && > > > + !dev->skip_passive_sdp_discovery) > > > device_browse_sdp(dev, NULL); Then here just check for dev->refresh_discovery. > > > g_dbus_send_reply(dbus_conn, dev->connect, DBUS_TYPE_INVALID); > > > } > > > diff --git a/src/device.h b/src/device.h > > > index cb8d884e8..5348d2652 100644 > > > --- a/src/device.h > > > +++ b/src/device.h > > > @@ -145,6 +145,7 @@ void device_set_wake_override(struct btd_device *device, bool wake_override); > > > void device_set_wake_allowed(struct btd_device *device, bool wake_allowed, > > > guint32 id); > > > void device_set_wake_allowed_complete(struct btd_device *device); > > > +void device_set_skip_passive_sdp_discovery(struct btd_device *dev, bool skip); And here we name it device_set_refresh_discovery so plugins can actually set if the device should have refresh_discovery enabled/disabled. > > > > > > typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal, > > > void *user_data); > > > -- > > > 2.28.0.236.gb10cc79966-goog > > > > > > > > > -- > > Luiz Augusto von Dentz > > Thanks, > Archie -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SKF1AJH+Ol81XgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 00:02:57 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id KJxvOpD+Ol+xbAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 00:02:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1ABA0420E2; Tue, 18 Aug 2020 00:02:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728312AbgHQV0D (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 17:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727019AbgHQV0C (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 17:26:02 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49A71C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 14:26:02 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id q7so12998674qtd.1 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 14:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=UuJE2iFxGr+pK6Ja4BJ1thQ9MqtdEznWrskfkznhejE=; b=PNDNHba492pImbDK8n3vNAOHennFHh43XZDD22jWKsr0o4q9nfOD1qXBmfmziGbI/l +SuAE98GFR4CL6aoVLp/rCv3zDY94i36+wO8D8c8wOquq4lOydG6esVry6mMtwJy6DJq uJgEzcVeKfScoSpTqRByYxAR6/37QI0v/90L4OtP7MtwjSChpqAB/gplsmZQkjMMM7qf osG2hSGI5i1Pgz+3bEmNUQBTumj8Nl7wx0tx8hCaPVmLSP7hLzw6SG9RlMVe7BAdwgzV L/Xn/SoH+5UIiaPvDClLAuMkDW8fvW5sQtAjsSUDMA31INh2wfwwGRfWJFRmxYzZ4dxU RPKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=UuJE2iFxGr+pK6Ja4BJ1thQ9MqtdEznWrskfkznhejE=; b=gl1fdyUJVJ6/9nNFeXsaXAUshxG0PMCC9ecrw0Dw03mBLujrcaK2FQJeAsbF2lWHvh 6mG8xYsA93+fdnRTxNr/CvccfoKvQveF3X+fxVXPP/ttV2iLdetAONQEVu+78JlajgcU 2hJbXQfCEuDOPfZcRRNDU5Lcfva+j0n6JHYE1JhKCCMKF0zfI1e4NYxffRyxk6uQ3Giu MJ47f0u76Lvd5wktmLLRSMRzUsqiA4gbxYbpf+/AIYGtbz0Mq6zxhga9NKb9UjnxZb9A I6fmZqvLVfw0dkZ7lKRcbv433lr+4lUdbbH2v3VQtsTESyewCuVLQPoxOWR8LWRXvyux B/8w== X-Gm-Message-State: AOAM531XukcobqlwGMXCPBLFmqGUOFUYM/Pp0xqkVBJDjmyWKSPRwX2v w8ceqH+FpW5U3zwlmCcO0Fn3XK56gvehgSP2r1YXp/alaeYAO72jhGja+PPHHk+nOSs4u4CcuwA 1+2tpB46oEmTdSTJAwLqbzn+n+vwB9Fq13GMswFAsQHnnuXJJ6I0+7/IvrzCuEXRYRso0oCTese wB X-Google-Smtp-Source: ABdhPJzzyTfAyRTReEtDGwLWv+RW4ISuz4YtMgTA1DqFUi/nRnmjVdpNhrvG4lb961gJF0qRqvp8q4axPmoF X-Received: by 2002:a05:6214:3e8:: with SMTP id cf8mr16285641qvb.74.1597699560661; Mon, 17 Aug 2020 14:26:00 -0700 (PDT) Date: Mon, 17 Aug 2020 14:25:54 -0700 In-Reply-To: <20200817212554.3844965-1-yudiliu@google.com> Message-Id: <20200817142545.RFC.v2.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> Mime-Version: 1.0 References: <20200817212554.3844965-1-yudiliu@google.com> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [RFC PATCH v2 1/1] adapter - D-Bus API for querying the adapter's capabilities From: Yu Liu <yudiliu@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Archie Pusaka <apusaka@chromium.org>, sonnysasaka@chromium.org, Yu Liu <yudiliu@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.55 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1ABA0420E2 X-Rspamd-UID: 870cc0 From: Archie Pusaka <apusaka@chromium.org> Initially this is introduced to query whether WBS is supported by the adapter, the API is generic enough to be extended to support querying others in the future. Reviewed-by: sonnysasaka@chromium.org Signed-off-by: Yu Liu <yudiliu@google.com> --- Changes in v2: - Return an array of strings instead of a dict Changes in v1: - Initial change doc/adapter-api.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt index 1a7255750..8fbcadb54 100644 --- a/doc/adapter-api.txt +++ b/doc/adapter-api.txt @@ -204,6 +204,18 @@ Methods void StartDiscovery() org.bluez.Error.NotReady org.bluez.Error.Failed + array{string} GetCapabilities() + + This method returns a list of supported + capabilities that is populated when the adapter + initiated. + + Possible values: + "wbs" - Wide band speech + + Possible errors: org.bluez.Error.NotReady + org.bluez.Error.Failed + Properties string Address [readonly] The Bluetooth device address. -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MAj9Bp7+Ol81XgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 00:03:10 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 4MlaBZ7+Ol/1ogAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 00:03:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EE3D8420D1; Tue, 18 Aug 2020 00:03:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728307AbgHQV2u (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 17:28:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726634AbgHQV2t (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 17:28:49 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F8FCC061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 14:28:48 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id cq28so13572391edb.10 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 14:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=bBCMQeGY4Yt1dNxEDMZhgLQrrMQkGXldrNWfS6LMfEI=; b=KdbZs+H53rII9I5yLj6Q2r22pr4S+R+pjy8gN4X9GI+3O0YcCSAROczL+a5sE1zioG 021VvT5EPdrc76z4Q5OX4K054JywINWd8qoBGWrigZ8pAJXKgG3Te0Zje06FbfmCwmJF vcuPKtv5tAYKvOBxaTu8isc9KsW/dQsvHPT9viYaEp3eHbk19vdluvqSnosaAV/NiEYB NCUwrgljyTiomLNztyE8K+cHZPPGSlABlGu/D6MdFWClPYc5xEsu0G7YnJRv9ya1FMnx 0fOq27OWP//x8mm69fV8tNAOxorV4AXX1LBXX67GfzxUIRxA2JKa2KKqK249nSeWJB+D /sHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=bBCMQeGY4Yt1dNxEDMZhgLQrrMQkGXldrNWfS6LMfEI=; b=TC9KcFnF+7klp/Tqmq/4CKpg+ceZg2napwjXqvP32vO9V6PsK3UICBmK+kzo5fnTx/ DXDNO6S0rh7aNOZLzybVx6+tBhtkgpCsgG6Qgswogu+3Fw4ve1M/iYAnncxNU9m1zwmW ZIIa/dSJh0SAFFULgzQEg7h5U8vzAZyIXR8hH7X2OErt+JAZ0NbxtRUETaN1vQ+Aiy01 5B/55HiWU4AsQiDGid2Vy8zG1r0kIQsmtCiOXoBkqu5lQ5W+z/ZAz+WUkosllVzRkWRW +YDGOZk85QnWX7ZmOjxh+YnyDvj2/bT0v/AErMWAFlL4AySs5W1HxSeWHksWRER8142i Ydnw== X-Gm-Message-State: AOAM532RQputhBYLhsiu6yBpECHcZXH1IEIbN/+OrfCjTxcs+6xKPbVh ebV/a9p5giju7ri3ip1gTw9VSaiq4e2JakjUysMLsJpaRFDK0A== X-Google-Smtp-Source: ABdhPJxUCRKz+bCfFDCMDvf3n5ZZbEeyIGgUUa/WOPPLmnwpuOJNi1ahBrCJpczUoJtODHY5iCYJWgYf3hvAWLhyjrc= X-Received: by 2002:a50:f311:: with SMTP id p17mr17507537edm.37.1597699727322; Mon, 17 Aug 2020 14:28:47 -0700 (PDT) MIME-Version: 1.0 References: <20200803235811.2441774-1-yudiliu@google.com> <20200803165804.RFC.v1.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> <7D5EF527-14F0-42C2-B39B-50B55F01BE74@holtmann.org> In-Reply-To: <7D5EF527-14F0-42C2-B39B-50B55F01BE74@holtmann.org> From: Yu Liu <yudiliu@google.com> Date: Mon, 17 Aug 2020 14:28:11 -0700 Message-ID: <CAHC-ybzq91aAHWtQUt_4PN9OF0yzXsW_7dWR37go6Q5+Cjre=A@mail.gmail.com> Subject: Re: [RFC PATCH v1 1/1] adapter - D-Bus API for querying the adapter's capability To: Marcel Holtmann <marcel@holtmann.org> Cc: linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: EE3D8420D1 X-Rspamd-UID: 64f306 Hi Marcel, Thanks for the suggestion, after talking to the original author we dropped the original idea and added the new API as suggested. Thanks. On Wed, Aug 12, 2020 at 5:13 AM Marcel Holtmann <marcel@holtmann.org> wrote= : > > Hi Yu, > > > Initially this is introduced to query whether WBS is supported by the a= dapter, > > the API is generic enough to be extended to support querying others in > > the future. > > > > Reviewed-by: sonnysasaka@chromium.org > > > > --- > > > > Changes in v1: > > - Initial change > > > > doc/adapter-api.txt | 17 +++++++++++++++++ > > 1 file changed, 17 insertions(+) > > > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt > > index 1a7255750..250d0e9b3 100644 > > --- a/doc/adapter-api.txt > > +++ b/doc/adapter-api.txt > > @@ -204,6 +204,23 @@ Methods void StartDiscovery() > > org.bluez.Error.NotReady > > org.bluez.Error.Failed > > > > + dict GetSupportedCapabilities() > > + > > + This method returns a dictionary of supported > > + capabilities that is populated when the adapter > > + initiated. > > + > > + The dictionary is following the format > > + {capability : value}, where: > > + > > + string capability: The supported capability = under > > + discussion. > > + variant value: A more detailed descripti= on of > > + the capability. > > + > > + Possible errors: org.bluez.Error.NotReady > > + org.bluez.Error.Failed > > can=E2=80=99t this be just an array{string} that lists the capabilities? > > And if we introduce it, then lets introduce it also with the first user o= f it. Otherwise we end up forgetting to comment on the actual possible capa= bilities. > > Regards > > Marcel > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gCg/BGTOOl/QJQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 20:37:24 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id SCXRAmTOOl//3gEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 20:37:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 099D9420C9; Mon, 17 Aug 2020 20:37:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388902AbgHQRcy (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 13:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388922AbgHQRcl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 13:32:41 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46638C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 10:32:41 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id p137so3566832oop.4 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 10:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1Au+CnITgKpC/NCaHV/yv88z60E1XlmNrYn2umiIwfw=; b=SYGPQtytDrBzuRFBSmJvq9BPH5gLbOh07+JmX9QyyiCiwKkdlb3GnXSK8EG1L6ePHX WJBNkEhLPQfSs8YcsICwRxbHAsN/P7YlpvkdnSryhH2jTOIMn5VJAN/M6fpXMCMYN5UH 8enI0Opi/DtDy2mEpob+Rh7ieiikyF23Y0kTx1lRRIR4JtITrtrN9+TVQHg266sEIG/C V/ogmJnnu4muJw/qeabAKTTd1oNQtbe3Lfe0WnjtYOvyqksI/DK7Cf47GyGPV6DzD2x8 NuDlJyvDzOwY6QZwb4CPnzIRPXxJmqA9P43AaFq5jis8eShEFpq1jCZbIiHlg0XSk1MJ ZKFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1Au+CnITgKpC/NCaHV/yv88z60E1XlmNrYn2umiIwfw=; b=Ilujk0BQp9gY/vRWUme1/pHZ4c78zmB2Tel1tdoZKRUADO7T7EaZiGApUBDgXI4YBM FSdW++Sb4d39iSGTLqZu13FZiOcS9U78UjcUS0z7RGIv0PBUiQ/+eaZrKEa3R4APNnQ8 RitFfFEZR20acZ5qatNkQcffXJ4A4QCGtiQpxaZUP3vDvHHQliujDVw/PErYr3Sp+WE7 P9IEmtv8rNtn1D0THZVL9+pmTtnriofWYqakDiRIzp10okjqeqK1jLJvRVZLfPIRrdFA LE8fnz3d5DO3ZsxYwoXWWbexgb6fFEQDyOM8TEOsCDkhrvAPUsdwH4lT2gAwbutBM5FF abNw== X-Gm-Message-State: AOAM531BkCE7JWBlV+oIW/ApCWZ8VFtZfRlPwLjTRbtRFRp0eU6h/6sP BfU68AVO2AVWAMVvMDaqSkLiy9Xhz4/4Rv6ZeEM= X-Google-Smtp-Source: ABdhPJzrkM9uCCcUaHtJhpKh1QfQhMW3YW/U3IHJnEECrIJjhc0DKrGrAtkB0IPYmxPk6qfSYu/mtmSSXac0RQpcZf4= X-Received: by 2002:a4a:e88c:: with SMTP id g12mr11738106ooe.49.1597685559392; Mon, 17 Aug 2020 10:32:39 -0700 (PDT) MIME-Version: 1.0 References: <20200817024234.13758-1-515672508@qq.com> In-Reply-To: <20200817024234.13758-1-515672508@qq.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 17 Aug 2020 10:32:29 -0700 Message-ID: <CABBYNZ+-zF9qLrYdBSWjdWd3qfOJOk-VzNVfTG5eSLYPZ76ahw@mail.gmail.com> Subject: Re: [PATCH BlueZ 1/1] scr:Set property mode failed,memory leak To: chengbo <515672508@qq.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.08 / 15.00 / 200.00 X-Rspamd-Queue-Id: 099D9420C9 X-Rspamd-UID: f60565 Hi Chengbo, On Sun, Aug 16, 2020 at 7:57 PM chengbo <515672508@qq.com> wrote: > > This patch will fix a memory leak,when set property mode, > it will creat a request,if failed,the data's memory do not free > --- > src/adapter.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..3d07921a7 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -2917,9 +2917,10 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, > data->id = id; > > if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param, > - property_set_mode_complete, data, g_free) > 0) > + property_set_mode_complete, data, g_free) > 0) { > + g_free(data); > return; > - > + } This is actually the other way around, if it fails then 0 is returned and g_free is called, so this would cause a double free as g_free would be called on destroy. > g_free(data); > > failed: > -- > 2.20.1 > > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KL8UIv0PO19+ngAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 01:17:17 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id eLEuIP0PO186bwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 01:17:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9A611A01FB; Tue, 18 Aug 2020 01:17:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726596AbgHQXRL (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 19:17:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbgHQXRI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 19:17:08 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBD60C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 16:17:07 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id v6so14769281ota.13 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 16:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sBN+7DVSoGmRYZdaF0Xc2Fr0jnFu0vtmzUtOMztMCvY=; b=JMyMxx3SP14VqB41O7Upjcma9ejQjvya7OeyvIPEczgYi1SS7ObRGpgxXtbD/7hh6U 3SDbCejRF2mPXNkjvn17ogxEKjzGp9o2/eUTZLRjS+QCXdewe7ytHq8+Fr85epKrA8NV jmw5JDcrrIyzVHnoRcIVHePaACGd5RbXtm2larBXbzs1lCpH96bOmz62YSCRLgDBRvkT hp4/1QAHQBN7Re9imjXDv2NzigrnIzq2WQyZ78IDArW3nej0StaJCEq6Lj0MdMZh1MQR 62+JmSNI1Egyfhv9FHd9Im2x9KkPyYg06OKHNlbpyOYTK/eUl8eHl+Z3aXtXkxeV3Viq aWpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sBN+7DVSoGmRYZdaF0Xc2Fr0jnFu0vtmzUtOMztMCvY=; b=iYacYCoTqLA5r9acikzoGEgwyaDHLk60XmeKAmeKF98oc42I8gvvr1F2q3jtz/MWSk wyzQCckI7aNCiSxcVY41tmloz0+Ptmx6zfd2IJ7nXimlBacOxw9d7OWpiRr17s9uBZly 2vY6cz38H3E62wDP8VXWskF4c1KUkyw9m9Br93dvSD6PreoFsXI++K0N2fM3RXyiXb7H m4Je0O2V6Lul4igqJc7MCjzUY3FllLG3LWxeQqV5eNwYvAU2OqI8B3H9Rrl4IWSb8PcB adcKnL3ymfSqyzuZoWotyzUfPyA18IIpJVD8numRR1SnVC6SorVD+kgQlLdz1DIDiaCy QB3A== X-Gm-Message-State: AOAM531Q4ju6qNuR1BVMtl7XaRCyl9SdTBBmetx/bEMmUwA+DGwShnfz rbSFyTWM0iE+8uSDwVGOD4DBi6rY8CGigMaK37p+XCAM X-Google-Smtp-Source: ABdhPJxuMnoYx4/tmAqcX1dOUrvBo2AOFjcKcnIr/RBAbf+LSjNAnf0CRuW3EGnV0m/19C/Hj5xcctpV5+ujKS0NfPY= X-Received: by 2002:a9d:6053:: with SMTP id v19mr12568844otj.362.1597706224803; Mon, 17 Aug 2020 16:17:04 -0700 (PDT) MIME-Version: 1.0 References: <20200817212554.3844965-1-yudiliu@google.com> <20200817142545.RFC.v2.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> In-Reply-To: <20200817142545.RFC.v2.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 17 Aug 2020 16:16:54 -0700 Message-ID: <CABBYNZLRqhB6d5Hm7_RqvUqCJo11D4+pgYLCeWj0j=8dZk0Bcg@mail.gmail.com> Subject: Re: [RFC PATCH v2 1/1] adapter - D-Bus API for querying the adapter's capabilities To: Yu Liu <yudiliu@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9A611A01FB X-Rspamd-UID: 3e8735 Hi Marcel, On Mon, Aug 17, 2020 at 4:07 PM Yu Liu <yudiliu@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > Initially this is introduced to query whether WBS is supported by the adapter, > the API is generic enough to be extended to support querying others in > the future. > > Reviewed-by: sonnysasaka@chromium.org > > Signed-off-by: Yu Liu <yudiliu@google.com> > --- > > Changes in v2: > - Return an array of strings instead of a dict > > Changes in v1: > - Initial change > > doc/adapter-api.txt | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt > index 1a7255750..8fbcadb54 100644 > --- a/doc/adapter-api.txt > +++ b/doc/adapter-api.txt > @@ -204,6 +204,18 @@ Methods void StartDiscovery() > org.bluez.Error.NotReady > org.bluez.Error.Failed > > + array{string} GetCapabilities() > + > + This method returns a list of supported > + capabilities that is populated when the adapter > + initiated. > + > + Possible values: > + "wbs" - Wide band speech Btw, should we stick to use wbs terminology here, or we should actually use the HCI feature/command, because wbs has actually to be implemented by the HFP afaik this is only indicating that the controller is able to notify packets drops, etc, with use of erroneous command. Perhaps we should actually use the term PLC (Packet Loss Concealment) instead since that seems to be the real capability here, afaik WBS does not actually require PLC. > + > + Possible errors: org.bluez.Error.NotReady > + org.bluez.Error.Failed > + > Properties string Address [readonly] > > The Bluetooth device address. > -- > 2.28.0.220.ged08abb693-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wEv3Aa8RO187swAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 01:24:31 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OLJCAK8RO1+EiQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 01:24:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 068B4A015E; Tue, 18 Aug 2020 01:24:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726273AbgHQXYZ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 19:24:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726165AbgHQXYY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 19:24:24 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7389C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 16:24:24 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id u63so16341979oie.5 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 16:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YFzSXlNrmd43O0W2NTqrdb9Md3q7gFf2ih/2c/pBQSQ=; b=iJNMagXQPpf8hs7lTRX1o+GAj2t/B69PGNfeQQRA+J22OSRAfuqmOQdOLQ6wCTvdYa RByU487BY+8UeADkn+3kyRBNtYxxzvO8oeo7T82nMnZ6FPOU9+9zCFDmSn+cJ/HXEwih qC2oMcTJkrswg2Pw8HH3GiHiTj0lb6E+qiu6rCYasRRKK8MOEFSViCJ+zX+xdgdf9tFo tfeHn3xu4mfVwoGiYX6P9EmuAr+SJAWfk2EDj1DjNqMA1gbvBY/KhccpBSTZPgElSken tDNeoNMPpcigiVGc8Rt2lzmsRnoKiKL8rh1vKDuxi36YSz57zeC3Yynxzzp/7Px1i4jd +I8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YFzSXlNrmd43O0W2NTqrdb9Md3q7gFf2ih/2c/pBQSQ=; b=ibJWm6IbRVz9fiN5/51Fe1Px58fKtcbnQSKj0/kL/K9fFJD6OLXcL3D8bl9L7vI9Mh UfnVRSaVPpGVGoMkyB1gaJnrgvG6pZmV1mGuWPB6U2aK6tbsNhdOZKWOyeLXdqBy+meS Jz/CiSuI1ZaAREZUETD1XYkNMwgJhXzDT2ylA84+1YZekN3uvjosJClFKR4J6/gOllId CZ6HaQTAAQ+v9kz4RC2jt55HsAn8wg21w0L+QgDlzt5lnp2cAFmf3vyOKurdglu8qmhV Fae9o0n1UlE0quM90mVo/tEnUf++56/hCfj5kaEc/Y1tMgr/cRCnhpD1gz5L54SIpD3C 8S7Q== X-Gm-Message-State: AOAM533dE1YNXH5632uYCs1989gtDQpxHOuhrasGJ5Aq2lq5OfNJL4M6 2t9Ktfg5hs0PdIl/wzKtngltqIX8ukx10m9inzs= X-Google-Smtp-Source: ABdhPJyGPpFXuqlXVN796VNfEeHLmWK7nMwA+GAzfczbPwg12QiiGEMmrdeYLbsKViaKe8MNIAjJBoKrUN2PGYtmBQU= X-Received: by 2002:aca:5703:: with SMTP id l3mr10517426oib.48.1597706663964; Mon, 17 Aug 2020 16:24:23 -0700 (PDT) MIME-Version: 1.0 References: <20200817135606.Bluez.v2.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> In-Reply-To: <20200817135606.Bluez.v2.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 17 Aug 2020 16:24:13 -0700 Message-ID: <CABBYNZLfmuLHvvMUwz_-Lg=q5aFYt6S3UEV-SA--ESmRMX4DVQ@mail.gmail.com> Subject: Re: [Bluez PATCH v2] adapter- Device needs to be in the temporary state after pairing failure To: Yu Liu <yudiliu@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: 068B4A015E X-Rspamd-UID: f45057 Hi Yu Liu, On Mon, Aug 17, 2020 at 4:04 PM Yu Liu <yudiliu@google.com> wrote: > > This caused the device hanging around as a discovered device forever > even if it is turned off or not in present. > > Reviewed-by: sonnysasaka@chromium.org > > Signed-off-by: Yu Liu <yudiliu@google.com> > --- > > Changes in v2: > - Fix title length and format issue > > Changes in v1: > - Initial change > > src/device.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/src/device.c b/src/device.c > index bb8e07e8f..93e71850c 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -6008,6 +6008,12 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, > > if (status) { > device_cancel_authentication(device, TRUE); > + > + // Put the device back to the temporary state so that it will be > + // treated as a newly discovered device. Use C style comments /* */ above. > + if (!device_is_paired(device, bdaddr_type)) > + btd_device_set_temporary(device, true); Hmm, are we perhaps removing the temporary flag too early? Or this is a result of calling Connect which clears the temporary flag? Then perhaps we should at least if the upper layer has marked the device as trusted as it should indicate the device object should be kept even if not paired. > device_bonding_failed(device, status); > return; > } > -- > 2.28.0.220.ged08abb693-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aGVoBkcUO1/d6wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 01:35:35 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id SFu8BEcUO18pEgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 01:35:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D65EF40732; Tue, 18 Aug 2020 01:35:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726382AbgHQXf3 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 19:35:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbgHQXf0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 19:35:26 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 120BEC061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 16:35:25 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id bs17so13784391edb.1 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 16:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dlqDKlV9jk1FHSuh4MPTcik7VEPdRAvdq288sP9/ibE=; b=QLqHppGVp1eQojtphbbWnTL+NThZ2dTAOnw8dw+kLbnpLGSQhbXbu1S9k0T42YIUYm x2hMFwL5FTnuiDuVu9aW/BRG/PDe+YEk1UaQtCQRsbbh01n8kfM5JXsek9UNceDPmEWQ w0Wu8RtVjn56eUD5fCxTIDgFd44USnDwsR29iWlJ7/zAzcOibxlzk76xOzDX8SCe2meX TZPPk7T7VyUPgmLgMf6WSdr4kcv1uPPuGrdZzSsPegXFqtSxI5GL0Wkjycp9EQKepmyO 6GsTLELkUpalyjfAV9TRK2VDQAH/eQSQnvRzsIgBWBj5Q3Qwso6bHLVjNLUHoU0MjGzI KNvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dlqDKlV9jk1FHSuh4MPTcik7VEPdRAvdq288sP9/ibE=; b=a/c8W+ywDdGwTz+6fTSlqCzWr+99F4Yo/uWwOqQG8fZgyASfrD1NRKCG1ILvE7XU77 XGtJgWUIFX+LDPJD3apxh++VYN2JBNfI63ULfU/CEeQtY7oXK0qOjy2o11235ICmE4cx 0VmVF3dS5zrWOSG4BdUJZMlPUYBmRFTXnYnzmmKnO8UY6+KRA9mCv+7bTzOR7IVfObIK 857ECAGg745L7wH1isTZf7fTq5nVFf2hbRu7Df7XAz7XniblzhcVjt8HzRYazg2wigK1 PC2msDwO+nSHmr5nnSBXlLBJspS4Np5dJ/sOyzeq6O72wWBQv5WEwEen1u0220zxklJC KiXQ== X-Gm-Message-State: AOAM531l3O8u2cqEX2k/45nwC3jevZvqKlhWNYo6tCLZCrlKCDyO+wi0 jfs/OK7USFnH6fluC66PCVpWrzKBaZWLyxaJpHhfFg== X-Google-Smtp-Source: ABdhPJwwzR52dwG2cjBebBxbWrvOkLGkq6YWfROFyioEv8L87Dr2d6AkQSyWh9QA1SY+iQqjDA79hfi/DK7hPEEUH6U= X-Received: by 2002:a50:af83:: with SMTP id h3mr17386293edd.139.1597707323481; Mon, 17 Aug 2020 16:35:23 -0700 (PDT) MIME-Version: 1.0 References: <20200817135606.Bluez.v2.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> <CABBYNZLfmuLHvvMUwz_-Lg=q5aFYt6S3UEV-SA--ESmRMX4DVQ@mail.gmail.com> In-Reply-To: <CABBYNZLfmuLHvvMUwz_-Lg=q5aFYt6S3UEV-SA--ESmRMX4DVQ@mail.gmail.com> From: Yu Liu <yudiliu@google.com> Date: Mon, 17 Aug 2020 16:34:47 -0700 Message-ID: <CAHC-ybx8QNsTy=_5OfMoVMRersd-YFscQAi+nvL=2rqhgWMeRA@mail.gmail.com> Subject: Re: [Bluez PATCH v2] adapter- Device needs to be in the temporary state after pairing failure To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.08 / 15.00 / 200.00 X-Rspamd-Queue-Id: D65EF40732 X-Rspamd-UID: 538638 that could be a reason and a potential fix, we remove the temp flag in dev_connect and pair_device very early on, but i suspect changing that would potentially have bigger impact and needs more due diligence and testing. On Mon, Aug 17, 2020 at 4:24 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Yu Liu, > > On Mon, Aug 17, 2020 at 4:04 PM Yu Liu <yudiliu@google.com> wrote: > > > > This caused the device hanging around as a discovered device forever > > even if it is turned off or not in present. > > > > Reviewed-by: sonnysasaka@chromium.org > > > > Signed-off-by: Yu Liu <yudiliu@google.com> > > --- > > > > Changes in v2: > > - Fix title length and format issue > > > > Changes in v1: > > - Initial change > > > > src/device.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/src/device.c b/src/device.c > > index bb8e07e8f..93e71850c 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -6008,6 +6008,12 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, > > > > if (status) { > > device_cancel_authentication(device, TRUE); > > + > > + // Put the device back to the temporary state so that it will be > > + // treated as a newly discovered device. > > Use C style comments /* */ above. > > > + if (!device_is_paired(device, bdaddr_type)) > > + btd_device_set_temporary(device, true); > > Hmm, are we perhaps removing the temporary flag too early? Or this is > a result of calling Connect which clears the temporary flag? Then > perhaps we should at least if the upper layer has marked the device as > trusted as it should indicate the device object should be kept even if > not paired. > > > device_bonding_failed(device, status); > > return; > > } > > -- > > 2.28.0.220.ged08abb693-goog > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SO5TB9YtO1/cjQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 03:24:38 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4JJ4BdYtO1/x0QAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 03:24:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DD6BF40813; Tue, 18 Aug 2020 03:24:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726302AbgHRBYb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 21:24:31 -0400 Received: from lucky1.263xmail.com ([211.157.147.132]:51744 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726290AbgHRBYb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 21:24:31 -0400 Received: from localhost (unknown [192.168.167.235]) by lucky1.263xmail.com (Postfix) with ESMTP id 08AA3ECE2D; Tue, 18 Aug 2020 09:24:25 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED: 0 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [113.57.152.160]) by smtp.263.net (postfix) whith ESMTP id P18320T139785528137472S1597713864401396_; Tue, 18 Aug 2020 09:24:25 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <4c6b7526f22a2d9df226d40b6c81469e> X-RL-SENDER: chengbo@uniontech.com X-SENDER: chengbo@uniontech.com X-LOGIN-NAME: chengbo@uniontech.com X-FST-TO: luiz.dentz@gmail.com X-SENDER-IP: 113.57.152.160 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: chengbo <515672508@qq.com> To: luiz.dentz@gmail.com Cc: 515672508@qq.com, linux-bluetooth@vger.kernel.org Subject: [PATCH] scr:Set property mode failed,memory leak Date: Tue, 18 Aug 2020 09:24:24 +0800 Message-Id: <20200818012424.8174-1-515672508@qq.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <CABBYNZ+-zF9qLrYdBSWjdWd3qfOJOk-VzNVfTG5eSLYPZ76ahw@mail.gmail.com> References: <CABBYNZ+-zF9qLrYdBSWjdWd3qfOJOk-VzNVfTG5eSLYPZ76ahw@mail.gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.71 / 15.00 / 200.00 X-Rspamd-Queue-Id: DD6BF40813 X-Rspamd-UID: 225be9 This patch will fix a memory leak,when set property mode, it will creat a request,if failed,the data's memory do not free --- src/adapter.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..3d07921a7 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2917,9 +2917,10 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, data->id = id; if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param, - property_set_mode_complete, data, g_free) > 0) + property_set_mode_complete, data, g_free) > 0) { + g_free(data); return; - + } In the original code,if mgmt_send fails then 0 is returned,then this function return directly,do not free data. Therefore, you need to free data before executing return. g_free(data); failed: -- 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UFFMNQZdO1+gOwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 06:45:58 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id IO3mMwZdO1/4nQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 06:45:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9A516A0C36; Tue, 18 Aug 2020 06:45:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgHREpx (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 00:45:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbgHREpw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 00:45:52 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 417E5C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 21:45:52 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id a65so15258824otc.8 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 21:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6XOupO0daY6AS+cMid2so2wy3R4YCt4ZXxoUOUqL0Rg=; b=UtGUn4tpC5n/0BRR6Xa0SGwlIKYlLg7AuAhAQ6g1e7DadDJm4TGof+VwRdpfK7P8Mj 1Y9JX5eioKHvSXldFwhM4FOKDY73VSaytM2MtBn5w+dYbDT1OrrmCoeOtsONTrPlOIjp GGbgvg0H9Y0tDAgHG1R0AFey5BRKZ7DhE+bO0SbggLMz5u1VEqXzcyOy+4hk39GCmtVk lvhEmro0G4JvCIpGJ+RDmpxwe3lMSc07tmK9jV9PafOGBy6k3boS821OkunN/U6GrM80 b1eweDqbfJ9KDZWH0XFmupUnHrSlcXPmEKZGRHpzmjEib37HRfAgw+1pcS2XHO2ECY70 Zgog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6XOupO0daY6AS+cMid2so2wy3R4YCt4ZXxoUOUqL0Rg=; b=s0IRw/ZWepEhr11KjHOpw16GEyAu9OZRw+5iUAezkEgbruKdCLzrqbKyRd1SaaDQnD pYFUaBZwuqGFBpR+9NmysVAIn9ZYMIa9N088NcKbQkAtXlACq5EdkNMfLWSCRQz9MeDA ImG5Jii5EEHn7m/Px97Cg8bdsbFdr/Ib4VfvtQfN5J3f2H0NozHeB6/3ooW/6LfUGdNv vC9DWTuf4AUmbIHTrBxpg5PTxO3pwZq2OCJ4wU67CulgvCkxEmLkSBp9g24+uNfkEmx4 8e97+mdN4VFFObPBYnB68h3RrSf7tJFDeG99eFoxB+3cm9rgOIE1AupztKx2Q5KUdD18 pTTw== X-Gm-Message-State: AOAM530v5NEdZutVBUq/L1QkcI5WGTmDPktulFkmo0BO9KEWb476rzyp uWQhGU8mY371a4Zx+iReHHybnArEd1xKHJd7id4= X-Google-Smtp-Source: ABdhPJw1yAsZTd1wDGFGYey7m3Ljfdq6gOyuuxIE/pdPCMoTFUpS4QCpNNNtu7/25UhGMgAzkd9VhD+zN1UMroO+MEQ= X-Received: by 2002:a9d:429:: with SMTP id 38mr12986376otc.88.1597725951605; Mon, 17 Aug 2020 21:45:51 -0700 (PDT) MIME-Version: 1.0 References: <CABBYNZ+-zF9qLrYdBSWjdWd3qfOJOk-VzNVfTG5eSLYPZ76ahw@mail.gmail.com> <20200818012424.8174-1-515672508@qq.com> In-Reply-To: <20200818012424.8174-1-515672508@qq.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 17 Aug 2020 21:45:41 -0700 Message-ID: <CABBYNZ+oX0XzfoqwcO45Die+5PeQofU=ZBeab+fiFm89Wj7Lxg@mail.gmail.com> Subject: Re: [PATCH] scr:Set property mode failed,memory leak To: chengbo <515672508@qq.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.07 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9A516A0C36 X-Rspamd-UID: 66e27a Hi Chengbo, On Mon, Aug 17, 2020 at 6:24 PM chengbo <515672508@qq.com> wrote: > > This patch will fix a memory leak,when set property mode, > it will creat a request,if failed,the data's memory do not free > --- > src/adapter.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..3d07921a7 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -2917,9 +2917,10 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, > data->id = id; > > if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param, > - property_set_mode_complete, data, g_free) > 0) > + property_set_mode_complete, data, g_free) > 0) { > + g_free(data); > return; > - > + } > > In the original code,if mgmt_send fails then 0 is returned,then this function return directly,do not free data. > Therefore, you need to free data before executing return. Nope, if (0 > 0) will evaluate to false so it will continue and the code below will be executed, the if branch is testing for success case not the opposite and that is why there is no goto failed either. > > g_free(data); > > failed: > -- > 2.20.1 > > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OLSaFN9mO18ZZwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 07:27:59 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 0H2kEt9mO19O8QEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 07:27:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B5E0941175; Tue, 18 Aug 2020 07:27:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726365AbgHRF1x (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 01:27:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbgHRF1w (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 01:27:52 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4DEEC061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 22:27:51 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id f9so8717062pju.4 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 22:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=U44b4+c2+olFule7W68+p6jyhTFBkegeEtIt/0fejrE=; b=mmM4NjcD6RHrPZGuYTJr2o99PBBBOKjtWHWkkD7FGVUswc5QcQ3Yt6hypJP8wfDp98 A4sH02Dj6DoMhwVcUQxJoUI+vjsL0/PZck6QjUUHU6OkuusJ7pyrA0P5FIt7+YVNx775 QQ3Yi9TbGrZlkmrCEu/S4lv9kg8ggfLOjSiZY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=U44b4+c2+olFule7W68+p6jyhTFBkegeEtIt/0fejrE=; b=CCeK7dJPoPtBUP+OzVtMmil5Yc9ikxFA5JUKqxTIN8OLvVFqjeUMJucoIWcgtI0B/H IBH6Q+l4V4wO26CiW5NxNq/qZGHNvSUukfA+PnnRLsx1d4pncFrB2ppW6tFGPT9O7AB4 YY2DBL5GuxWxhjFRjaimlibodXSmroxSzzmUqrXTRYlroDaNFyRrCewzcK3VPj+OXzWm OJvI+J1NXDx3BPj1CgEK10feNV09t4IY6lik0Dn7RnJomqIB43kL2UO1p7jrpz+hnuiE tWVXOVSjRqn40FXnm/sFfLNXZ4FTxGqDsxeZnzhs1o3j0xrz02568ViZ47uFrrUo3BWy NEuw== X-Gm-Message-State: AOAM530ghmPe/E5WruweO8S2VMnwoLeaPIMykoIXQFEYXJYZ+JRx84YJ 52gUK2XEghX7hAVmdKv5B73oOMC7+lP+Cw== X-Google-Smtp-Source: ABdhPJzuVXmCgZamMqBYryZvfkRlnfyBU79cArFfJWJ6ojMbFUwB0C+jNuCC8J8oK0TenuvZlezqTg== X-Received: by 2002:a17:90a:fa92:: with SMTP id cu18mr14850105pjb.215.1597728470867; Mon, 17 Aug 2020 22:27:50 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id n12sm23459315pfj.99.2020.08.17.22.27.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Aug 2020 22:27:50 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v2] shared/ad: move MAX_ADV_DATA_LEN macro to the header Date: Mon, 17 Aug 2020 22:27:46 -0700 Message-Id: <20200817222717.BlueZ.v2.1.I716fc87b0c97e5349a04766a61ecad1f5b0fd28e@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.36 / 15.00 / 200.00 X-Rspamd-Queue-Id: B5E0941175 X-Rspamd-UID: 5e9f2c This moves MAX_ADV_DATA_LEN macro to src/shared/ad.h and rename it to BT_AD_MAX_DATA_LEN. --- Hi Maintainers, In order to avoid duplicate definition of the maximum data length of advertisement for the following series of advertisement monitor API, we'd like to reuse the one in shared/ad. Thanks, Miao Changes in v2: - Rename the macro to BT_AD_MAX_DATA_LEN. src/shared/ad.c | 2 -- src/shared/ad.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/ad.c b/src/shared/ad.c index 8d276842e..6d882a9b3 100644 --- a/src/shared/ad.c +++ b/src/shared/ad.c @@ -33,8 +33,6 @@ #include "src/shared/queue.h" #include "src/shared/util.h" -#define MAX_ADV_DATA_LEN 31 - struct bt_ad { int ref_count; char *name; diff --git a/src/shared/ad.h b/src/shared/ad.h index 19aa1d035..17e3b631b 100644 --- a/src/shared/ad.h +++ b/src/shared/ad.h @@ -27,6 +27,8 @@ #include "lib/bluetooth.h" #include "lib/uuid.h" +#define BT_AD_MAX_DATA_LEN 31 + #define BT_AD_FLAGS 0x01 #define BT_AD_UUID16_SOME 0x02 #define BT_AD_UUID16_ALL 0x03 -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0MTPNj7POl/QJQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 20:41:02 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UGozNT7POl/GJAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 20:41:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EDF7B420B9; Mon, 17 Aug 2020 20:40:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731270AbgHQRfR (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 13:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730006AbgHQRfK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 13:35:10 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47936C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 10:35:09 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id k12so14091992otr.1 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 10:35:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7F2WR7ZiKtgV6Hbdw4w6WH+wyjdFEO/gsngLlaXW4JY=; b=XRM/vWqpqTA4CCDPEqZlyxy7z/PUa113phRqL8bExZI7c32oenN0l/kRzs6Hn74QV/ Mze98FZsPg6js7Lmq2BLCLmuuG9kFk7jmoYRNQGKon3ZfPt85pxIR4D2uQ32SBDhRiWH kxFYzcw9Q+LZRwbI1sUnLO4wUoIHkv5cJrBUY31DB4FyCPK8GAFBQE/6fDAFy8bRE38J 2rN4+yljrR11nzSKmLT3frdOLKqQuoTCQv/Pbce66Z+dbrCIKG477dcwn8lH4106OEK5 wdyNeSU+XADxKdsxOc/5F4xfxMmig8dvCSnn1ytV2rX6uHIQPwLSN1SHTAf2StIcZCHI 9ZkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7F2WR7ZiKtgV6Hbdw4w6WH+wyjdFEO/gsngLlaXW4JY=; b=cJoVIeZYaY44OOxJRmqjSKy4xmd6zBjuoijlkCvXls3KhI7+hSDDo0tY9KuJ825hDF Jppp6s9DQ5NjREIppup3SkyxrOBpcGUq5TGCnFKpPbyFFGp8bK806m0upRMySlgWb0UN 58SJ2PbueF9syOR/DQVWFTM5MrTL79CjXYm8uIU44pIGVhvUrdxCEVdcEGQWivoFF1rx Zg+buJBfvM9+j7DU9b4j+lIQALQjtDHV5RuMK05MWP5ElCfc6QFi5jWIKrLrboE13qvl 7YxUPAfoZ590Da01S/X/TVMrcI9fukGnTdUuhzCXYse8ES3/DTUAgMc1Jw/buBkgxAm9 Rh2A== X-Gm-Message-State: AOAM53104TNpSRjZiWuYQp/9OnG5vxwwu0AUf1MTCt3VZRxfQ4ocYuzp TP+Lk0ieQ7aZ0SmJPww/RPBre/XHn/92RgwjkFFUYnW1 X-Google-Smtp-Source: ABdhPJyH87GTs0wMxjHNRuNL4f+DnLdAfUPCtnPvlHj5Yy7TdESEPz3r4kScO8M/8MNS+MtMwMYkLgb+4lx6IwTn+tc= X-Received: by 2002:a9d:6053:: with SMTP id v19mr11582739otj.362.1597685708584; Mon, 17 Aug 2020 10:35:08 -0700 (PDT) MIME-Version: 1.0 References: <20200814155807.Bluez.1.Ia90c97ad9ec0b51b7aaae1216864e8379c1470d5@changeid> In-Reply-To: <20200814155807.Bluez.1.Ia90c97ad9ec0b51b7aaae1216864e8379c1470d5@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 17 Aug 2020 10:34:58 -0700 Message-ID: <CABBYNZKrRGb7FkCVOix8jmNwr94BQNXrS8U+a8VRBNxHoQ2ArA@mail.gmail.com> Subject: Re: [Bluez PATCH] advertising: Fix dbus response for over-advertising To: Daniel Winkler <danielwinkler@google.com> Cc: Simon Mikuda <simon.mikuda@streamunlimited.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: EDF7B420B9 X-Rspamd-UID: 3a1dac Hi Daniel, On Fri, Aug 14, 2020 at 4:09 PM Daniel Winkler <danielwinkler@google.com> wrote: > > client_free would always send a dbus method_return to fix the case where > a request to Unregister occurred before the MGMT call returned. However, > in the code path where too many advertisements are registered, this > method_return prevents the failure from being sent properly. This patch > makes sure the reference to the register_advertisement DBusMessage is > not stored in the client structure until the end of > register_advertisement. This ensures that we only respond once, either > in register_advertisement or in client_free, not both. > > It also changes the dbus response in the fast unregister_advertisement > case from a method_return to a btd_error_failed, since the registration > was never allowed to complete, and thus was not successful. > > The patch was tested in the following ways: > > To verify it did not break the segfault fix in > caff2b48ca54bbc57b5da3f63317767489aa5b48, I repro'd the failure by > quickly unregistering after registering, and verified that the segfault > is still fixed with this change. > > Ran through our automated tests that register too many advertisements > and verify that the registration fails with the intended "Maximum > Advertisements Reached" error response. > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > --- > > src/advertising.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/src/advertising.c b/src/advertising.c > index 076d591b6..e5f25948d 100644 > --- a/src/advertising.c > +++ b/src/advertising.c > @@ -119,9 +119,13 @@ static void client_free(void *data) > } > > if (client->reg) { > - g_dbus_send_message(btd_get_dbus_connection(), > - dbus_message_new_method_return(client->reg)); > + DBusMessage *reply; > + > + reply = btd_error_failed(client->reg, > + "Failed to complete registration"); > + g_dbus_send_message(btd_get_dbus_connection(), reply); > dbus_message_unref(client->reg); > + client->reg = NULL; > } > > if (client->add_adv_id) > @@ -1152,8 +1156,6 @@ static struct btd_adv_client *client_create(struct btd_adv_manager *manager, > g_dbus_client_set_proxy_handlers(client->client, client_proxy_added, > NULL, NULL, client); > > - client->reg = dbus_message_ref(msg); > - > client->data = bt_ad_new(); > if (!client->data) > goto fail; > @@ -1216,6 +1218,8 @@ static DBusMessage *register_advertisement(DBusConnection *conn, > > DBG("Registered advertisement at path %s", match.path); > > + client->reg = dbus_message_ref(msg); > + > queue_push_tail(manager->clients, client); > > return NULL; > -- > 2.28.0.220.ged08abb693-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CDY5Gib9Ol9TZgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 23:56:54 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UPagGCb9Ol8pEgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 23:56:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5956F40732; Mon, 17 Aug 2020 23:56:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726596AbgHQUmC (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 16:42:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726361AbgHQUmB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 16:42:01 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10A7FC061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 13:42:01 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id l13so19821035ybf.5 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 13:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=UNmPgd9kNtZoo9wgw4gsRYDyNuPIjwok9mt363/DTg4=; b=NtAgfKUIXsJ8BR+6PY8e+bttLBBpQL476nDd1QiQpMCDbP+YtSZ3+eLUOnYhSeqOrK KfFa/AI9tex97TLNnfJgbtKZK2ytqPHA0C+a6s6TYz6p5Sv/JqHKeWRDmqD2tK63aEv0 AKC8SEQwsQv80pfaiRAynQhSNO3WY+d8Jq6WSdU0On5W06mCM6g3EjiUr7nhGIGHsuY8 lCC1TA5ZdUVoWlBHS/mAN1Qd2gYl/Y/f8av7jSOAs9rYUNJNaLgOQKJMPqABwz7jzVs0 HUg+SttY8VcC6Ks9zGJPDxKeOWldaPI3VqltP4OzGfseeOhEZ++nNn7f2zdNpOhypJe2 0emA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=UNmPgd9kNtZoo9wgw4gsRYDyNuPIjwok9mt363/DTg4=; b=BEkiJkCKv6/MeOA1wTgPSjztZfE1rWFQ41blpykOeuW/xhhc8aq6CLIZ29jKGS4Xpz +FuXDYY5/OGpw/QGaLOE+MxmK7io+6sMlgBNpFkBB6K0GQ+Qjq7Swwm7F7/LB9KdysHg deBwEaRQp8DZjSrQcP2XcvphCHMkJggcxrg+z6Kz1ANPLmUCDfEb2ZE5yM9dqz4y/D94 LIpPc31ADG6dAqJp5oApk0LHNVDzM+MiJFs+ASAkJRGQYcJGvlR/GJy9dQh3JIReNGAZ UPTyvz2PAOws1GCmDrBSIQI1oeJDonvq4S3I8rWBSzPmqmMX/XpmuMSUqf63OHZ8fRhK vQxQ== X-Gm-Message-State: AOAM532t1YdHytEQvpC69jM+HErB5R2KouZdhQHPbd7Ak7jhsXTyb51m +WbtAE1l2HTamaeGmHLic1gf8CJ6JUWEBEBVEPgYWj9tUQRbjjWDE3mL0DE23A3yPHMpgc9A/m1 tx/uobiTp34fT6XyNME3GMsQSLcBpD+0lj2jr7ulwoXKRQO6Y4ntGgW5xVD5eHLEso6OM2SnqTZ r7 X-Google-Smtp-Source: ABdhPJyc81SBqB4rCPKkD2kKicASI6t/lTWvv4PMPtBCBk+6CPPgYlhRwxK5rv7kmmg25jeoccEtHzgNyraH X-Received: by 2002:a25:53c6:: with SMTP id h189mr23476248ybb.469.1597696920076; Mon, 17 Aug 2020 13:42:00 -0700 (PDT) Date: Mon, 17 Aug 2020 13:41:53 -0700 Message-Id: <20200817134133.Bluez.v1.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [Bluez PATCH v1] adapter- Device needs to be in the temporary state after pairing failure. From: Yu Liu <yudiliu@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Yu Liu <yudiliu@google.com>, sonnysasaka@chromium.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5956F40732 X-Rspamd-UID: f1e96d This caused the device hanging around as a discovered device forever even if it is turned off or not in present. Reviewed-by: sonnysasaka@chromium.org --- Changes in v1: - Initial change src/device.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/device.c b/src/device.c index bb8e07e8f..93e71850c 100644 --- a/src/device.c +++ b/src/device.c @@ -6008,6 +6008,12 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, if (status) { device_cancel_authentication(device, TRUE); + + // Put the device back to the temporary state so that it will be + // treated as a newly discovered device. + if (!device_is_paired(device, bdaddr_type)) + btd_device_set_temporary(device, true); + device_bonding_failed(device, status); return; } -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iM1ELmL9Ol81XgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 23:57:54 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id OCkwLWL9Ol8jmgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 23:57:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ED95B418AF; Mon, 17 Aug 2020 23:57:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726944AbgHQUu6 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 16:50:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726165AbgHQUu5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 16:50:57 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACCCDC061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 13:50:56 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id b14so16303307qkn.4 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 13:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=vLX1btiv+rxQBwdgZfx93NNh+vu/2OGlrmuq4CHtKIY=; b=chb7SWs/uEj1ggnGkc6qFw921EX87XdZSdulEemXAzo6Vf2/bh2iVGP0jp+gSCn+yE AYKkA0uOErhz3Es3uhXGklrukrje5UD2j2Qgi51ffrzdu983L5+8zuV1BL05p7tfDGRU 3rmuixoJpx/NMUoOVSlRKQRtf3395jy2XG7ZaJUs34f5B2y5YWkCVBpkmVAmDI0/2eL8 FPSl6mUo/SeClM3UG8YsTBdrtVJ9vzWH/tFLDAfmfDfSWrHimqRdXpGsnf0ee61ru4A3 6N5LS3t/HKoIq5sZ3T3nwPnXbYUYyD+nkME710CkP+dHXXv6BWrtZqWQlM8sud6TqfDE 9H9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=vLX1btiv+rxQBwdgZfx93NNh+vu/2OGlrmuq4CHtKIY=; b=ejQHtNUiNZ+qFuGKxbsAuQDl8fIRPY8yIup/PidvNp+d+PqUOeVRGGJUteZxNtYa2A kCRyyPS441StuOEMxOM03tuD+14QwVqe7pZsFdcMmcxHB3qhGo8t2UFAegpnlbtFFTUd 1nK2s6SEg788B0D2oMYs11qaK4xOaSgP3/FPjASpPupaH6W1SKXE86IkQG3CFyBESj+i 0FLTo9zogsd98oLWZgeX+J+LePAsvYMN4vYvR56DwurNCr8dCQ3+LubfJzrhWIn6Ae3q 2CLq8p82T/27I2gP3Svr8N7TUBmZ7W3Snju6s1dEN/+iXEPWPLIAm9rSRDrGpsnnwMVU pt6Q== X-Gm-Message-State: AOAM530aIlvhQMDN9AapqKxgvxwuuGQ9p+30taGOsbyvgKkum9F2tW7H yLqMnlAR7jBSU3ab/P2a8nyfX4H0eeLuLQ== X-Google-Smtp-Source: ABdhPJzzR+OimUti16ML2QZulWg6n90/8OQaq4JaOmu72osXS4AztdrgljjEWOk08Q1Fnnc27uULPg== X-Received: by 2002:a05:620a:24e:: with SMTP id q14mr14545163qkn.482.1597697455281; Mon, 17 Aug 2020 13:50:55 -0700 (PDT) Received: from [172.17.0.2] ([52.242.93.78]) by smtp.gmail.com with ESMTPSA id 65sm19443678qkf.33.2020.08.17.13.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2020 13:50:54 -0700 (PDT) Message-ID: <5f3aedae.1c69fb81.96718.fbe9@mx.google.com> Date: Mon, 17 Aug 2020 13:50:54 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============5073655635248183269==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, yudiliu@google.com Subject: RE: [Bluez,v1] adapter- Device needs to be in the temporary state after pairing failure. Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200817134133.Bluez.v1.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> References: <20200817134133.Bluez.v1.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: ED95B418AF X-Rspamd-UID: 917b69 --===============5073655635248183269== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 1: T1 Title exceeds max length (73>72): "adapter- Device needs to be in the temporary state after pairing failure." 1: T3 Title has trailing punctuation (.): "adapter- Device needs to be in the temporary state after pairing failure." --- Regards, Linux Bluetooth --===============5073655635248183269==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gDx2HWj9Ol8ZYwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 23:58:00 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id eFLEG2j9Ol/BngAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 23:58:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E01CC420CA; Mon, 17 Aug 2020 23:57:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726949AbgHQUwq (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 16:52:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726948AbgHQUwn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 16:52:43 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDCA1C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 13:52:41 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id j7so16008569oij.9 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 13:52:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=i1TlfCFtQ6IMhqvDIaQBuJ7PSjmH9A7KNtubVPP5Vy8=; b=nsYs6t8lfteW1b9b7M32XQ2plfYDvWY96zi5FRPslaJhGhNxdxvAH3uDs75t6wvKIz No3YsR/DteReY/XO6/OlrG3N3zP6irjw5zKJwNpQ4FcKlOC6S8jkPP1zsWzbGqdbYSV4 gmyUfj0LCeCjLzRDZUx7j0Q47KcXxrS6DEr+SZN6A9wOmZsGp2WMecbVaEIQINvFC9rG aR6jGPSo+duDYkc4e6gsdQ6p32cL/vPYHF+BB+rKL+DkmOYJtFHA7FcjMVR0toubmuRS hDDALkZT442A/381AlagfGjUmWYkOwpFuRK6MsQpWEzaMagQsHUd+THoOIMqs2ZdLweI 4fzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=i1TlfCFtQ6IMhqvDIaQBuJ7PSjmH9A7KNtubVPP5Vy8=; b=fT1htq/C+8CZxbfKfIy2tiPB50TksrfouaOh5JFZ6GRWYrCj7LXIyfpS415fNxjHJ8 pfHMQuY5rUf35LU7S204HzwY2Nq1qRGPOdgkqfqqPb1Z0T0qKG61qK5B3oLn0rQr7GfP m5m4xZXNXb50eoBi9kDbSqB5FZHiq73Ox9+CgGicAs9GICTVxd8eonEdydglp+JQ4Nss KDcRw4cELarGOovleTLWCUIeONsONuhxWnTZ/YJjbl0nGgr2ttOVTQqA6J6A2NvcPsOb yhj8RQoE7nvY6HZM3SmEedLsot5jLC6fhlFk9zDAZiWyzSjgU9koT+awcV9D8SnlGd6m Wesg== X-Gm-Message-State: AOAM5331F0duW850toepe1Lg5qg3U9dFiSSg4OE/tZXZYblksVUtDX13 DNWppwZXj97K6b8wTNSlfWXGrYYhuojBjDqk9Tg= X-Google-Smtp-Source: ABdhPJx/DP+ppyBgWh1MVUhgCmYVsaMyRid2zeBz5wS6ZdpHd0vsYyXVc+Z6ZKYNf8twtzVgHfuE18K9vUX5WKDi+VU= X-Received: by 2002:aca:f504:: with SMTP id t4mr11006198oih.137.1597697560997; Mon, 17 Aug 2020 13:52:40 -0700 (PDT) MIME-Version: 1.0 References: <20200807142429.BlueZ.1.I588558f1e38231193d6e955a4008ce54712d5c89@changeid> <CABBYNZL4s151e-a+X0fEA73RM54aA--m+on7as4dLrJX0xevQQ@mail.gmail.com> <CAGPPCLDFUgPU+XqNPxUBgH9kKUSEb+DvFO0PhAKTUZUToXCi4Q@mail.gmail.com> In-Reply-To: <CAGPPCLDFUgPU+XqNPxUBgH9kKUSEb+DvFO0PhAKTUZUToXCi4Q@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 17 Aug 2020 13:52:30 -0700 Message-ID: <CABBYNZK_dvQPetyJ=fi_2u3bLzLe9bayBD4PZ7yL0KskN_2nhA@mail.gmail.com> Subject: Re: [BlueZ PATCH] Disable auto-connect on cancel pair To: Manish Mandlik <mmandlik@google.com> Cc: Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.12 / 15.00 / 200.00 X-Rspamd-Queue-Id: E01CC420CA X-Rspamd-UID: 1b596d Hi Manish, On Mon, Aug 17, 2020 at 12:37 PM Manish Mandlik <mmandlik@google.com> wrote: > > Hi Luiz, > > On Mon, Aug 17, 2020 at 10:11 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: >> >> Hi Manish, >> >> On Fri, Aug 7, 2020 at 2:24 PM Manish Mandlik <mmandlik@google.com> wrote: >> > >> > While pairing process is in progress, service discovery starts in the >> > background. If HOG profile is detected, auto connect is enabled for >> > that device. This causes future advertisement from that device to >> > trigger a pairing even if the user has already cancelled the pairing. >> >> So it looks like something is not right if the user cancel the pairing >> process I would expect the device to be removed if this happens when >> setting up a new device or at least call Disconnect method which would >> disable auto_connect if the device is not trusted. > > > Earlier there was another patch related to pairing cancel issue: https://patchwork.kernel.org/patch/11608271/ > This patch terminates the link when the user cancels the pairing process. Once the link is terminated, the device is removed by disconnected_callback()->dev_disconnected()->btd_adapter_remove_device(). > > However, the device remove code-path doesn't check for or disable autoconnect. In the current bluez code, autoconnect is disabled only if the disconnect is initiated by the user (in dev_disconnect()). > > So, instead of disabling autoconnect while cancel pair, do you think we should disable it during device remove (in device_remove())? I'm not following you on this part, is there something preventing the device to be removed? If the devices end up being removed so does its autoconnect state, if that is not happening then that is the culprit here and should be fixed. > Or should we disable it in the cancel pair code-path, but with a check if the device is trusted or not as per your suggestion: > > if (device->auto_connect && !device->trusted) { > device->disable_auto_connect = TRUE; > device_set_auto_connect(device, FALSE); > } > > Please advise. > > Thank you. > >> >> > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> >> > >> > Signed-off-by: Manish Mandlik <mmandlik@google.com> >> > --- >> > >> > src/device.c | 9 +++++++++ >> > 1 file changed, 9 insertions(+) >> > >> > diff --git a/src/device.c b/src/device.c >> > index 470596ee4..ab5bb123e 100644 >> > --- a/src/device.c >> > +++ b/src/device.c >> > @@ -2870,6 +2870,15 @@ static void device_cancel_bonding(struct btd_device *device, uint8_t status) >> > if (!bonding) >> > return; >> > >> > + /* Auto connect may get enabled during the service discovery even >> > + * before the pairing process completes. In such case, disable it >> > + * when the user has cancelled the pairing process. >> > + */ >> > + if (device->auto_connect) { >> > + device->disable_auto_connect = TRUE; >> > + device_set_auto_connect(device, FALSE); >> > + } >> >> BlueZ has the trusted property so upper layer can actually flag if the >> device is trusted regardless if it is paired on not, so this seems out >> of place or we should at least check if if the device has been marked >> as trusted. >> > ba2str(&device->bdaddr, addr); >> > DBG("Canceling bonding request for %s", addr); >> > >> > -- >> > 2.28.0.236.gb10cc79966-goog >> > >> >> >> -- >> Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2Ff0CIv9Ol81XgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 17 Aug 2020 23:58:35 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cKp5B4v9Ol/6wwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 17 Aug 2020 23:58:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 46966418AF; Mon, 17 Aug 2020 23:58:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726983AbgHQU43 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 16:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbgHQU42 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 16:56:28 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22469C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 13:56:28 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id v11so19666400ybm.22 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 13:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=xAuvgih+72j9IUIm7iDAaTRlM7+svjQwxUff+8aUj68=; b=TNurjeIAgdwM1HlUV/65hI/+Ydcs0nHzExOPJdZ9NkaFFkq6jQaJgeoMQMNf3jXjod p1ihIIXKAre3BNmA4+hoRwzkmri2+zsiM/2px4AYw2YTKQxpa2TQJtHntfkIOzJCBto0 gaiZNNeD24fCr2z5DYVCaUMRdwwJKBeGmFc6S/SvAdINxQq5s4xSPDgh7G3AhAISAIl3 z1F6hbrv/UBmM+L02X5q/z7tojQ/5x+srPNe81kjblXMiXFHSV+UguzGLPOPT5F1cbUL O47ract8E0WckuOZ2uSuIHjtt8cPb3AV7nQcB36vglDw/29yNP/zsut3zaS8ZsNnykiK UuLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=xAuvgih+72j9IUIm7iDAaTRlM7+svjQwxUff+8aUj68=; b=Z9OyrGrSgeHfIeRnof7cgf4r+jZ5f3mmibnYrXRQbeUxjHC6Zp6oVfGYrPMCdwvsIp wBfUUfMNjOaf3hXQ5d2fcn61uCrDC3gSYsv8UqoN823VsqTrd4Px2QcXpoO8dkUapXQB QWMf24P8Pg8ZeWcbQ/CNtbpmKt7YGWd0PaxohCgopESe2zYjlfDam8ECqZaAqT6I0nd0 G0Hxkc3WlXhNgcB9w16HYrCRi9RiNtZsztCXB7GuJyUgbvz6y94LoHo8vfHD/2pzygVE Br1ieg3iF0RKB78J/M5dk4KLyQzdERpSPOLkGbqWqc75QVKVxZA4zuq9TMmLZl4dApgo OyIQ== X-Gm-Message-State: AOAM532YOiewqtorFw9qwUcllRj77R0HOod0wGdajhk6NZpmrEAdnTm/ C/9aTI3/3YoKHmoYJz0M+GWgCxFfcMR4OlarXS0gE65/3IhY3Kn5UnNQtYOq2/krIeZE9FtB9KK smhgLzEjRb6TqYhcg5LDGFWsZGId9kYUPizdP/WhuLn5PkIst2AhhUSz2r0kVH5rDzz+5OFtI5g dk X-Google-Smtp-Source: ABdhPJwqfJPUvnaS/gxS/kqq4BI4zelaOUHhis7TLfeiuYkElIaUgVfKPyzghzSE6h4dxZwnZ7YXyMsH/2z2 X-Received: by 2002:a25:40d8:: with SMTP id n207mr24159973yba.69.1597697787315; Mon, 17 Aug 2020 13:56:27 -0700 (PDT) Date: Mon, 17 Aug 2020 13:56:23 -0700 Message-Id: <20200817135606.Bluez.v2.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [Bluez PATCH v2] adapter- Device needs to be in the temporary state after pairing failure From: Yu Liu <yudiliu@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Yu Liu <yudiliu@google.com>, sonnysasaka@chromium.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: 46966418AF X-Rspamd-UID: 1e7d57 This caused the device hanging around as a discovered device forever even if it is turned off or not in present. Reviewed-by: sonnysasaka@chromium.org Signed-off-by: Yu Liu <yudiliu@google.com> --- Changes in v2: - Fix title length and format issue Changes in v1: - Initial change src/device.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/device.c b/src/device.c index bb8e07e8f..93e71850c 100644 --- a/src/device.c +++ b/src/device.c @@ -6008,6 +6008,12 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, if (status) { device_cancel_authentication(device, TRUE); + + // Put the device back to the temporary state so that it will be + // treated as a newly discovered device. + if (!device_is_paired(device, bdaddr_type)) + btd_device_set_temporary(device, true); + device_bonding_failed(device, status); return; } -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2GfTFG3+Ol81XgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 00:02:21 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id uDoYE23+Ol/IlwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 00:02:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 86E0441298; Tue, 18 Aug 2020 00:02:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728110AbgHQVVy (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 17:21:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727019AbgHQVVw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 17:21:52 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B0B5C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 14:21:52 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id b18so10844857pge.8 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 14:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=H+P2hBP+bTbEiqpMOjw9YdTEsWCnSEAX3HMUPcelPTI=; b=K0yJoQVvDltX6RzpiNK2gFuIayDflFySItq5E7bwJXcMwo1fmF4NvVIahfO1u67PPB 7KTNPSNdPHULdCiUWGNUliMW/eHpkfzLc+HHXx0ECbMZ8W1gae+Ave56Guq1JLVWtyRy StccwtlYRg7+DEcdab00BRETzmFrHiQKiD8S0uLDlX4Mvw+r4QhPG62rZcSG4n+gg0b2 Gr0LdL5tCQDxLpDe2o7gyGdbE6twPJhbhsMe0QeiwQVYA5jPvXmlGoVb8EIHRnqaTXD2 td/mlkNitW6xPA6laK2L5ulEa/eq3XRR5NiBWOkPZSKMVHG6ChI/f/tL/lEC8AzUX9SH UXUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=H+P2hBP+bTbEiqpMOjw9YdTEsWCnSEAX3HMUPcelPTI=; b=Vih+MAD/xuEtpbF20qqpcrndS0mg5JDUzY2k1/+iSSZ10MLH69LAc7SGQom8dkwzKk VsSA/eJ8EVNnA2B0bPjM8zDmwsU0ZGDIQXpqIDCEfS9OZ+r2EArG+lu2U+PglzbkDK9H kozdXDvs2lvUH0tckZdiJWA9juNe9g8wx3nd0QjZTVPGxFnKt1xAQjYMsDdHj7g7VOxF 0w5lVJg0ldl+Puh7ygCBNrLEM+q9GofCFHiVI46cAwLFuuHGrFzKMfwVrzDt5eH3fBel ufWfeVgFdALpRwZqueg7iP7gwDNcn16hDUM3P+vh4v0XT4FW3609XilOTvbvWaFh/xeS Vtxw== X-Gm-Message-State: AOAM531MgNvG691yNpy55e/g9n3bvitTCgVXfu9z1RBclPfpArcj8t/5 CEvrgxcN8idH79nM5bnuJx27BYaqz+kgXSeNXTOGBwkaYNE1VkMMHWgoaZvJOvVbarqmJrYcwtg kYT9McZfwIEzbJ4HrF32Wdjc2t8ndhA83gPVAaPkj5cynx8FRFZUEcQSvdQNUK3ko8ptRYlsfpo pq X-Google-Smtp-Source: ABdhPJzQSMaEncZL/vTAChPbeosYJ8UpBIPKpI8MYSRMc06spjAm2UbqlsPKrNJjQm5T+o37nnaNb4I5RmJz X-Received: by 2002:a17:902:c3c9:: with SMTP id j9mr13180422plj.62.1597699311986; Mon, 17 Aug 2020 14:21:51 -0700 (PDT) Date: Mon, 17 Aug 2020 14:21:47 -0700 Message-Id: <20200817212148.3839311-1-yudiliu@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [RFC PATCH v2 0/1] A client needs to query whether the Bluetooth adapter support WBS, so we From: Yu Liu <yudiliu@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Yu Liu <yudiliu@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: 86E0441298 X-Rspamd-UID: 9fc0f6 designed this new D-Bus API to provide a generic way to query the adapter's capabilities. Initially this will only cover WBS capability, but can be easily extended to support other capabilities. Changes in v2: - Return an array of strings instead of a dict Changes in v1: - Initial change Archie Pusaka (1): adapter - D-Bus API for querying the adapter's capabilities doc/adapter-api.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CGuYIXL+Ol81XgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 00:02:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id CHCyIHL+Ol8kpAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 00:02:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 753AF420C4; Tue, 18 Aug 2020 00:02:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728143AbgHQVV7 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 17:21:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727019AbgHQVV6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 17:21:58 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49A02C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 14:21:58 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id p138so19835260yba.12 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 14:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=HAjGBhrOHTQnEFg1YCoKCKzFr3JrN5+1ofDPMY2xqK4=; b=Rpu0OJSyGJxFS9UuwUtd0mU9gFyAmXO12edBrAUxGaBXAtDdejm4NCx9TRQyTszDjk D53GPQC7Wg6UkSP0zFxHFVbB1SGN3N5o+T1tpxagbRSy+Z3pzVuceLhRCG9bK2mws8u6 Ob+kQqm+n5vr9HgrLxoEale2LhmZvWpCJYU6AYfhgl9DsaTchS9Gk0Um1Dm78ta11Xo7 86jFu+JL8RBhE4/oEgvEUCCD1PpiwJXID2UyWC+PknrQMEAwjlmLfx6jWzV84U1V2i6C p735ZrMODb42p/iTJ3xqnh/3c6C681ewexsn93FbnpWCU+PsejbMv6DIHAQhoGi3jpA4 jKnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=HAjGBhrOHTQnEFg1YCoKCKzFr3JrN5+1ofDPMY2xqK4=; b=cxegf+L55e85DdOO5tjbZRu5Qg3OWhCzYMc6Xoo1bb120lLuOdIrC8L18usGQCSlJS mRoSJGlXRc6gbmulT+ORyp44f+GdjLxoM9enp5Wl3mg0DFc5wQbQu9IMzqe9dbOFeyXu cdtuNn6nv7tBJ4itKbDfjb2+9hx9g6OK+mQX/UMv0HiSpCPzzAOcJe066HGxOTliE3Ls 3gp6TeN5t3iiHZj98rtzdqDmb5U7DelvPc9jgpbdv09PemRQr9ApGjF4vAF/TnZHc0eM Vu8fFNImR3meG4bNNJ2CoTdcK3G4PjM37rnyvSizfMH7JH6kfeYsHiSmiMrj+8RVa9Xz 4DvQ== X-Gm-Message-State: AOAM530XwNNNhu0J9WQ1jJoxcBKpfCi8K2tzfPpcC5fea7dQ0LhxterX 6C3yLKIddyP+QxbJcvMb45b8HA3elVolC2BCTNNpFd6k8v/dPLIk78deOSUuuDtlhs3NXa3s3R6 H7zay42/GsjsJ2Lk/sbv//T+No4dn26sVYM+p09x21Eya0///M4QCpPTduZ0h1emtsERL9WYOsO ye X-Google-Smtp-Source: ABdhPJyljiHFDW7gVNnYT0WajY171oBNUGXZDCZKHV4qVg4w5JqJ0Lk2FbU8yLAsf6lwqgIrY0se2Vccxslz X-Received: by 2002:a5b:3d2:: with SMTP id t18mr23479124ybp.176.1597699317061; Mon, 17 Aug 2020 14:21:57 -0700 (PDT) Date: Mon, 17 Aug 2020 14:21:48 -0700 In-Reply-To: <20200817212148.3839311-1-yudiliu@google.com> Message-Id: <20200817142137.RFC.v2.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> Mime-Version: 1.0 References: <20200817212148.3839311-1-yudiliu@google.com> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [RFC PATCH v2 1/1] adapter - D-Bus API for querying the adapter's capabilities From: Yu Liu <yudiliu@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Archie Pusaka <apusaka@chromium.org>, sonnysasaka@chromium.org, Yu Liu <yudiliu@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 753AF420C4 X-Rspamd-UID: 963fd5 From: Archie Pusaka <apusaka@chromium.org> Initially this is introduced to query whether WBS is supported by the adapter, the API is generic enough to be extended to support querying others in the future. Reviewed-by: sonnysasaka@chromium.org Signed-off-by: Yu Liu <yudiliu@google.com> --- Changes in v2: - Return an array of strings instead of a dict Changes in v1: - Initial change doc/adapter-api.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt index 1a7255750..250d0e9b3 100644 --- a/doc/adapter-api.txt +++ b/doc/adapter-api.txt @@ -204,6 +204,23 @@ Methods void StartDiscovery() org.bluez.Error.NotReady org.bluez.Error.Failed + dict GetSupportedCapabilities() + + This method returns a dictionary of supported + capabilities that is populated when the adapter + initiated. + + The dictionary is following the format + {capability : value}, where: + + string capability: The supported capability under + discussion. + variant value: A more detailed description of + the capability. + + Possible errors: org.bluez.Error.NotReady + org.bluez.Error.Failed + Properties string Address [readonly] The Bluetooth device address. -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EINxN4v+Ol8SawAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 00:02:51 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id IKtoNYv+Ol/1ogAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 00:02:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0664E40732; Tue, 18 Aug 2020 00:02:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728306AbgHQV0A (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 17 Aug 2020 17:26:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727019AbgHQVZ6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 17 Aug 2020 17:25:58 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 853F3C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 14:25:58 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id n19so7881522ybf.0 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 14:25:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=2ry2JVOxgxZyCxpqHUw3SBA49AdxBx6Obg5uwKLjEJA=; b=V0SxV781es6GMQLoJnWzfE9hR1SwZOVRuDAbom4EbWScAnjDOERImeyJUMc0us6k+F iY0v+yVVNJgTkgvUH7qq9SGUeOsQZvLDrz2wYFN1++kXWh95UA84K8POWcevRY9JdJUE NvX/znS2ClqrVzEtSoD/IvU6ZTfUVOa/SH/b8Qk/nBS0yjFzvt7IHELSVeRj4ow9KmnD efI6wbwUXGT747OwJSt/7No7xBWAHViGhkY9tU50sAy7dujKpoBgRU9thBvS5jbwhNQN NVMCxkoGqadRSaFeXMCfpUh9yhBGue+VKUUGAGg4MCP4zF9DEPC8d26kvAOy0OqEerAM QJmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=2ry2JVOxgxZyCxpqHUw3SBA49AdxBx6Obg5uwKLjEJA=; b=UYkq16B/Rv87pncjyPHZWnUjirdKjTSt7I1ltnVgPmY6HEx4BtyaohQyJm/RYdspfA 01AW2d6gTFpZpUJEyHNJEPlacjcrvqy410Pw0GFr0JGhFDU5Q/D5i++1W4OS2BJpr2XX z0U/3HFtOHi4SyjGQzjP7MytVB3eolB+cEoEJzSk2FGfXvKfM1y4rnXVc2nL9OabGkIX mgjBW9vVSTcb4cVn0zTUBBuS7l3jq6aRg/E1Bu3gi6MTD4s6Z+WGfFA7HwaIZZBFefT3 jTp4sfWGc/43DWB2mOLa5Avaz4loSDQE5+AWvcGkOKjxCG4LNFB6k7cwC99e+iBqJswQ CHXA== X-Gm-Message-State: AOAM5311DBGS3FrD3Hh6b+GAxgXaYYyxkErpQTZ8MR2n7xeqsk2i+Q8S btMUG7ZIvzmtF3uT/MTa2S0lJvdHKIxEmLnmQJz0BtS/p8tjstecdDtCMBfA7p2VmcO3EWD3yhS 9vT8PANbDh34caaV3tqntVeuoeLU1lqw/qoag5kcqjNlAIppe5cxgFp6LeyzotANhJmNa19bPv/ i5 X-Google-Smtp-Source: ABdhPJxCif0p8c1He++UfAUR//plXBTqdbAExLua3wh9TYCPnA5fxeCjg3St4xR4AKo/ILhsmIU655pjQznf X-Received: by 2002:a05:6902:6a8:: with SMTP id j8mr22738269ybt.417.1597699557713; Mon, 17 Aug 2020 14:25:57 -0700 (PDT) Date: Mon, 17 Aug 2020 14:25:53 -0700 Message-Id: <20200817212554.3844965-1-yudiliu@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [RFC PATCH v2 0/1] A client needs to query whether the Bluetooth adapter support WBS, so we From: Yu Liu <yudiliu@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Yu Liu <yudiliu@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.10 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0664E40732 X-Rspamd-UID: ef297d designed this new D-Bus API to provide a generic way to query the adapter's capabilities. Initially this will only cover WBS capability, but can be easily extended to support other capabilities. Changes in v2: - Return an array of strings instead of a dict Changes in v1: - Initial change Archie Pusaka (1): adapter - D-Bus API for querying the adapter's capabilities doc/adapter-api.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KGJjDQJrO18ZZwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 07:45:38 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id CMZ7CwJrO19R8QEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 07:45:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A5425A2895; Tue, 18 Aug 2020 07:45:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726398AbgHRFpa (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 01:45:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbgHRFp3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 01:45:29 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 491E8C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 22:45:29 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id d26so21030410yba.20 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 22:45:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=m9GCLS7/q73b2QMns45ZyBx9tX/LulwEUzquYmCfnIo=; b=VP4Pyda8cbhWNREa0MAVRbWMcxHtXzm0LeaChboPGHtSqXpVknm+O0rh6FFQFYXDi9 BwIzT+RAfgvRbelRlrkJK2CTdVNDJeVs2u0eJPHCjsb9Mvnb+wnkStFk8qaevN2s/WaR tKBx0eELzba8DaVQqhdIPEI8tSQuZrzuJeGuRfejAFprjqPBxbt7+7VUQwp5BVBx4ndd JBZNXJR8zWxMtiGepD+nUUERYYe3s7XgvIY65/X8PxAq3QIw/QjijRUmq5LA4xILUzZz APGT3Tjk0K5h6mR44PPWwjsrJRN13mhu2yPed56aO5vRmcIwV8Gcwywb9ahV2MLVsL6+ AdPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=m9GCLS7/q73b2QMns45ZyBx9tX/LulwEUzquYmCfnIo=; b=edKipcZSIFK4HBNaNEM6LwY+oV5hYKBsPNrKdb1/BXZ6VyDv93vvGoiDzlfV2b44SL TPs8mw69asdPYGYz7t58KEGeB7yjhhMJSvvEg/kC0xswZmaGNuZoWy88ECJ8Ag5Q2vB7 eQZcKF5bgQA2xrKD/wCBIjpcsKRD71QLikb1vSpDKnCKKgJg1f16I0lnJEvSSppOi0N4 CnE8dGioSyJUHJUHoq6f50/cIcGmGp9SylHPmsFKzQMkSkbG0w5s+lWTf62puNdogQ6T 7fhbr9W2X58NWCLuK9tETw1FVST4Otrb1+HRCsiM/uV+B9RUAlvQJCssIhqmYvakhALD urDA== X-Gm-Message-State: AOAM530J7kMwgQ25yMducMeUljtUeLNLC6GPuu05Wr3Z5xBUrKgWX0Bp n7WJv49l3klNsoUQ+JTlfD22TCZBzpuXVf5eKAVzj+4A4XAivE9m/wNLLhXDpEn1uCzpGdKUOfY GzV8QKJH6fD8lhPjV0Oh+LuV9EPW/r1uxFEmJTFQp+YiGUWxUmIBAirW30X4gzvThsWgjxrtqgG TN X-Google-Smtp-Source: ABdhPJy+aJVF/cVFuD1eUiqKJ76uB0dHiyTS3TCu3OGZNe7gMxQRL3Wd7hhd4/roNeDLLTF0j988x7yVI64+ X-Received: by 2002:a5b:78e:: with SMTP id b14mr24933536ybq.408.1597729528421; Mon, 17 Aug 2020 22:45:28 -0700 (PDT) Date: Tue, 18 Aug 2020 13:45:23 +0800 Message-Id: <20200818134455.Bluez.v2.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [Bluez PATCH v2] device: Don't browse SDP if HIDSDPDisable is set From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: A5425A2895 X-Rspamd-UID: bac45b From: Archie Pusaka <apusaka@chromium.org> According to the HID1.1 spec, part 5.3.4.9: The HIDSDPDisable attribute is a Boolean value, which indicates whether connection to the SDP channel and Control or Interrupt channels are mutually exclusive. This feature supports Bluetooth HID devices that have minimal resources, and multiplex those resources between servicing the initialization (SDP) and runtime (Control and Interrupt) channels. However, Bluez still tries to connect SDP upon HID connection, regardless of the existence of the HIDSDPDisable attribute. This patch prevents the connection of SDP after HID has been established, if the device has HIDSDPDisable attribute. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- Changes in v2: * Renaming passive_sdp_discovery to refresh_discovery profiles/input/device.c | 3 +++ src/device.c | 11 +++++++++-- src/device.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index 6ec0a4c63..5e47b88f2 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -1373,6 +1373,9 @@ static struct input_device *input_device_new(struct btd_service *service) /* Initialize device properties */ extract_hid_props(idev, rec); + if (idev->disable_sdp) + device_set_refresh_discovery(device, false); + return idev; } diff --git a/src/device.c b/src/device.c index 2237a7670..52dfea18f 100644 --- a/src/device.c +++ b/src/device.c @@ -195,6 +195,7 @@ struct btd_device { bool le; bool pending_paired; /* "Paired" waiting for SDP */ bool svc_refreshed; + bool refresh_discovery; /* Manage whether this device can wake the system from suspend. * - wake_support: Requires a profile that supports wake (i.e. HID) @@ -1472,7 +1473,6 @@ static gboolean dev_property_wake_allowed_exist( return device_get_wake_support(device); } - static gboolean disconnect_all(gpointer user_data) { struct btd_device *device = user_data; @@ -1805,7 +1805,7 @@ done: btd_error_failed(dev->connect, strerror(-err))); } else { /* Start passive SDP discovery to update known services */ - if (dev->bredr && !dev->svc_refreshed) + if (dev->bredr && !dev->svc_refreshed && dev->refresh_discovery) device_browse_sdp(dev, NULL); g_dbus_send_reply(dbus_conn, dev->connect, DBUS_TYPE_INVALID); } @@ -2572,6 +2572,11 @@ done: browse_request_free(req); } +void device_set_refresh_discovery(struct btd_device *dev, bool refresh) +{ + dev->refresh_discovery = refresh; +} + static void device_set_svc_refreshed(struct btd_device *device, bool value) { if (device->svc_refreshed == value) @@ -4071,6 +4076,8 @@ static struct btd_device *device_new(struct btd_adapter *adapter, device->db_id = gatt_db_register(device->db, gatt_service_added, gatt_service_removed, device, NULL); + device->refresh_discovery = true; + return btd_device_ref(device); } diff --git a/src/device.h b/src/device.h index cb8d884e8..5ba2d7fe0 100644 --- a/src/device.h +++ b/src/device.h @@ -145,6 +145,7 @@ void device_set_wake_override(struct btd_device *device, bool wake_override); void device_set_wake_allowed(struct btd_device *device, bool wake_allowed, guint32 id); void device_set_wake_allowed_complete(struct btd_device *device); +void device_set_refresh_discovery(struct btd_device *dev, bool refresh); typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal, void *user_data); -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wAC3LUxsO18ZZwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 07:51:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id cPpeLExsO1/IaQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 07:51:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8A116420F0; Tue, 18 Aug 2020 07:51:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726381AbgHRFvC (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 01:51:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbgHRFu6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 01:50:58 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DD68C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 22:50:57 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id b2so8994351qvp.9 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 22:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=s/ew5157WXW/O2ljhcPBm7BPYHN8LWGFuoDx/C2Hqwk=; b=WVD2vjMBc9zoPmGPdyjP6ks+cQ1vijCKWhMsvmsqhALgsuybIWusb5TBaSr4Gv0yfh Hn/Z0RWyJWU4V2crvDePIwSaQC8Vkt3CwtzvC10DdBfCHxvjKx+zGGLXTEjQV5RBRm+Y KoOjeKb/OaOa0NULjIT9SheLsQhbVt/cfYFTqq8xDPJ/gqxjMvcTP+JvH+STHhvVQQX7 2PJg3zBaRKThBQF9THrSgf69iGuzKnepd4/6veonPDnfmZ+SoykM8ShfnR28tZiPM0tD BCGNa/n7nBX6lwU84W7Fb6XJaMLhP3uFJdShh6bmyM5Ae+f/ASItWBfy/nAQr5KZ+PHa i+Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=s/ew5157WXW/O2ljhcPBm7BPYHN8LWGFuoDx/C2Hqwk=; b=tfKwvqY3sAtvDljC1LH1rxaPmxiQOye6FWGl1qbwV4KZH1S/nHNflcbyCWlb2jYb6/ iCk9unh5prN/54QWU2uswIA2mWUZvOUFc0Z27qBtKoI/W3OQQFBAugqa4gDDzOUlPtSd aSwCj9wxfPa5k4lFSW7Fzye04cdYnKy3L2t2MqDpHw3QZIxYlmgLw0t3Gpc8O9NNUonc yl828XUGGtsLX5qVoBEl+3OHoz7CNlBv7AJEvnyJuwF1TR9O0TSyysiLG2JUvF2XmAZ4 pGZNWNQalbsi6wxjeM5viUALT9dDkeLaZBcThKP4mnsoX4ctME1uTGbrgpCnOZa6iV4v jkYg== X-Gm-Message-State: AOAM532yGXMfQ7LdGTHdHAg0/HaHXOzqG6E3CkHD2UTbxLNiDklAXU6f wvaZA9zIOoyrXCEPiUOMbpUXfv0CJNRE9w== X-Google-Smtp-Source: ABdhPJwZYmC3aLLlLnpE1uWQUmfWP20wRc90uUiD3q/kpeNLYiB7/AHdb4dZFeaRwIhxGVihFs5I4A== X-Received: by 2002:a0c:f6cb:: with SMTP id d11mr17977608qvo.84.1597729856777; Mon, 17 Aug 2020 22:50:56 -0700 (PDT) Received: from [172.17.0.2] ([40.123.37.4]) by smtp.gmail.com with ESMTPSA id y7sm22448111qta.36.2020.08.17.22.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2020 22:50:56 -0700 (PDT) Message-ID: <5f3b6c40.1c69fb81.6b14.bd16@mx.google.com> Date: Mon, 17 Aug 2020 22:50:56 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3896547742367780485==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v2] shared/ad: move MAX_ADV_DATA_LEN macro to the header Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200817222717.BlueZ.v2.1.I716fc87b0c97e5349a04766a61ecad1f5b0fd28e@changeid> References: <20200817222717.BlueZ.v2.1.I716fc87b0c97e5349a04766a61ecad1f5b0fd28e@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.78 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8A116420F0 X-Rspamd-UID: 0c166e --===============3896547742367780485== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCnNyYy9zaGFyZWQvYWQuYzogSW4gZnVuY3Rpb24g4oCYbmFtZV9sZW5ndGjigJk6CnNyYy9z aGFyZWQvYWQuYzoyNTg6MTI6IGVycm9yOiDigJhNQVhfQURWX0RBVEFfTEVO4oCZIHVuZGVjbGFy ZWQgKGZpcnN0IHVzZSBpbiB0aGlzIGZ1bmN0aW9uKQogIDI1OCB8ICBpZiAobGVuID4gTUFYX0FE Vl9EQVRBX0xFTiAtICpwb3MpCiAgICAgIHwgICAgICAgICAgICBefn5+fn5+fn5+fn5+fn5+CnNy Yy9zaGFyZWQvYWQuYzoyNTg6MTI6IG5vdGU6IGVhY2ggdW5kZWNsYXJlZCBpZGVudGlmaWVyIGlz IHJlcG9ydGVkIG9ubHkgb25jZSBmb3IgZWFjaCBmdW5jdGlvbiBpdCBhcHBlYXJzIGluCnNyYy9z aGFyZWQvYWQuYzogSW4gZnVuY3Rpb24g4oCYc2VyaWFsaXplX25hbWXigJk6CnNyYy9zaGFyZWQv YWQuYzo0Mjc6MTI6IGVycm9yOiDigJhNQVhfQURWX0RBVEFfTEVO4oCZIHVuZGVjbGFyZWQgKGZp cnN0IHVzZSBpbiB0aGlzIGZ1bmN0aW9uKQogIDQyNyB8ICBpZiAobGVuID4gTUFYX0FEVl9EQVRB X0xFTiAtICgqcG9zICsgMikpIHsKICAgICAgfCAgICAgICAgICAgIF5+fn5+fn5+fn5+fn5+fn4K c3JjL3NoYXJlZC9hZC5jOiBJbiBmdW5jdGlvbiDigJhidF9hZF9nZW5lcmF0ZeKAmToKc3JjL3No YXJlZC9hZC5jOjQ3OToxNjogZXJyb3I6IOKAmE1BWF9BRFZfREFUQV9MRU7igJkgdW5kZWNsYXJl ZCAoZmlyc3QgdXNlIGluIHRoaXMgZnVuY3Rpb24pCiAgNDc5IHwgIGlmICgqbGVuZ3RoID4gTUFY X0FEVl9EQVRBX0xFTikKICAgICAgfCAgICAgICAgICAgICAgICBefn5+fn5+fn5+fn5+fn5+CnNy Yy9zaGFyZWQvYWQuYzogSW4gZnVuY3Rpb24g4oCYYnRfYWRfYWRkX21hbnVmYWN0dXJlcl9kYXRh 4oCZOgpzcmMvc2hhcmVkL2FkLmM6NTg3OjEzOiBlcnJvcjog4oCYTUFYX0FEVl9EQVRBX0xFTuKA mSB1bmRlY2xhcmVkIChmaXJzdCB1c2UgaW4gdGhpcyBmdW5jdGlvbikKICA1ODcgfCAgaWYgKGxl biA+IChNQVhfQURWX0RBVEFfTEVOIC0gMiAtIHNpemVvZih1aW50MTZfdCkpKQogICAgICB8ICAg ICAgICAgICAgIF5+fn5+fn5+fn5+fn5+fn4Kc3JjL3NoYXJlZC9hZC5jOiBJbiBmdW5jdGlvbiDi gJhidF9hZF9hZGRfc2VydmljZV9kYXRh4oCZOgpzcmMvc2hhcmVkL2FkLmM6NzI0OjEzOiBlcnJv cjog4oCYTUFYX0FEVl9EQVRBX0xFTuKAmSB1bmRlY2xhcmVkIChmaXJzdCB1c2UgaW4gdGhpcyBm dW5jdGlvbikKICA3MjQgfCAgaWYgKGxlbiA+IChNQVhfQURWX0RBVEFfTEVOIC0gMiAtIChzaXpl X3QpYnRfdXVpZF9sZW4odXVpZCkpKQogICAgICB8ICAgICAgICAgICAgIF5+fn5+fn5+fn5+fn5+ fn4Kc3JjL3NoYXJlZC9hZC5jOiBJbiBmdW5jdGlvbiDigJhidF9hZF9hZGRfZGF0YeKAmToKc3Jj L3NoYXJlZC9hZC5jOjk0MzoxMzogZXJyb3I6IOKAmE1BWF9BRFZfREFUQV9MRU7igJkgdW5kZWNs YXJlZCAoZmlyc3QgdXNlIGluIHRoaXMgZnVuY3Rpb24pCiAgOTQzIHwgIGlmIChsZW4gPiAoTUFY X0FEVl9EQVRBX0xFTiAtIDIpKQogICAgICB8ICAgICAgICAgICAgIF5+fn5+fn5+fn5+fn5+fn4K bWFrZVsxXTogKioqIFtNYWtlZmlsZTo2ODA3OiBzcmMvc2hhcmVkL2FkLmxvXSBFcnJvciAxCm1h a2U6ICoqKiBbTWFrZWZpbGU6NDAxMDogYWxsXSBFcnJvciAyCgoKCi0tLQpSZWdhcmRzLApMaW51 eCBCbHVldG9vdGgK --===============3896547742367780485==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OOJbORZzO18PkQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 08:20:06 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id CO97NxZzO1/r2gEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 08:20:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3A743A289D; Tue, 18 Aug 2020 08:19:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726381AbgHRGT5 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 02:19:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbgHRGT4 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 02:19:56 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52735C061389 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 23:19:56 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id s14so2763372plp.4 for <linux-bluetooth@vger.kernel.org>; Mon, 17 Aug 2020 23:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=v8dabrhlWu3e/wsWUIqU4VU/Ni4HgcY/lR6u+xEeuiY=; b=JyxqM0AVdgHdtKH/dROXrfVgQ3zh+dHolL34HblszStQRndNwBScQ7beZ9Pl9WQ28e Rddyv+TQ9QqnwfirBZrZFm7oF9AFJ0YTFjs6HOYapPROdbo+ZWf4DajrIcHpot9/xaG4 RpqQrqts+IAcaDds+k1ShRJ0JwgHTQ2P7LlJA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=v8dabrhlWu3e/wsWUIqU4VU/Ni4HgcY/lR6u+xEeuiY=; b=anEGcfkN4pD+rND8HizJDQA/WnggW2kY76fqN92v/fSNn+tqxb67u7zhrJSPD2bP9Y K+Ac6Isg6pU1KPyaKkEuGM+EUdExtiqpaTV1qV34Vni7IcSlniQkJS957SSrwmz5pA+T ZkKkVQ1FtGRBx0rTlNI5TXkpt+b8wtdufGwffQ7ZchEjcYtlWukhoeprw/823VaKhlDK lc06yjMRmfDrkJ7YgFQOxUuprpa696h01PJOuFyGJKrawT4QZDHJwhNBg+HdILVRVBMG WEIaeNNdGmRRlfNiCxSdr2CkhVGOK2VVLIv4HI6ZCZDCItcmVvHrLAY032NU57tDHJee QuUw== X-Gm-Message-State: AOAM531o5wFK2PyesHCUiBRB5S8kAkdJrFQd1vMp3/tQg//JeebDirQP mdg9jZlhfw4cHEJu8sEfhIBEA40YQa/Gzg== X-Google-Smtp-Source: ABdhPJxw9hc6D8N0fvmwnmf9pSY3tL0pC7U/t2JoJ4tTO1XIbQPZaBXNs+GZexwcI10QgAzAJjG7pw== X-Received: by 2002:a17:902:d34c:: with SMTP id l12mr14638810plk.36.1597731595087; Mon, 17 Aug 2020 23:19:55 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id b20sm22745580pfp.140.2020.08.17.23.19.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Aug 2020 23:19:54 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v3] shared/ad: move MAX_ADV_DATA_LEN macro to the header Date: Mon, 17 Aug 2020 23:19:39 -0700 Message-Id: <20200817231822.BlueZ.v3.1.I716fc87b0c97e5349a04766a61ecad1f5b0fd28e@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.10 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3A743A289D X-Rspamd-UID: 017b25 This moves MAX_ADV_DATA_LEN macro to src/shared/ad.h and rename it to BT_AD_MAX_DATA_LEN. --- Hi Maintainers, In order to avoid duplicate definition of the maximum data length of advertisement for the following series of advertisement monitor API, we'd like to reuse the one in shared/ad. Thanks, Miao Changes in v3: - Fix occurrences of MAX_ADV_DATA_LEN. Changes in v2: - Rename the macro to BT_AD_MAX_DATA_LEN. src/shared/ad.c | 18 ++++++++---------- src/shared/ad.h | 2 ++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/shared/ad.c b/src/shared/ad.c index 8d276842e..14a2709b1 100644 --- a/src/shared/ad.c +++ b/src/shared/ad.c @@ -33,8 +33,6 @@ #include "src/shared/queue.h" #include "src/shared/util.h" -#define MAX_ADV_DATA_LEN 31 - struct bt_ad { int ref_count; char *name; @@ -257,8 +255,8 @@ static size_t name_length(const char *name, size_t *pos) len = 2 + strlen(name); - if (len > MAX_ADV_DATA_LEN - *pos) - len = MAX_ADV_DATA_LEN - *pos; + if (len > BT_AD_MAX_DATA_LEN - *pos) + len = BT_AD_MAX_DATA_LEN - *pos; return len; } @@ -426,9 +424,9 @@ static void serialize_name(const char *name, uint8_t *buf, uint8_t *pos) return; len = strlen(name); - if (len > MAX_ADV_DATA_LEN - (*pos + 2)) { + if (len > BT_AD_MAX_DATA_LEN - (*pos + 2)) { type = BT_AD_NAME_SHORT; - len = MAX_ADV_DATA_LEN - (*pos + 2); + len = BT_AD_MAX_DATA_LEN - (*pos + 2); } buf[(*pos)++] = len + 1; @@ -478,7 +476,7 @@ uint8_t *bt_ad_generate(struct bt_ad *ad, size_t *length) *length = calculate_length(ad); - if (*length > MAX_ADV_DATA_LEN) + if (*length > BT_AD_MAX_DATA_LEN) return NULL; adv_data = malloc0(*length); @@ -586,7 +584,7 @@ bool bt_ad_add_manufacturer_data(struct bt_ad *ad, uint16_t manufacturer_id, if (!ad) return false; - if (len > (MAX_ADV_DATA_LEN - 2 - sizeof(uint16_t))) + if (len > (BT_AD_MAX_DATA_LEN - 2 - sizeof(uint16_t))) return false; new_data = queue_find(ad->manufacturer_data, manufacturer_id_data_match, @@ -723,7 +721,7 @@ bool bt_ad_add_service_data(struct bt_ad *ad, const bt_uuid_t *uuid, void *data, if (!ad) return false; - if (len > (MAX_ADV_DATA_LEN - 2 - (size_t)bt_uuid_len(uuid))) + if (len > (BT_AD_MAX_DATA_LEN - 2 - (size_t)bt_uuid_len(uuid))) return false; new_data = queue_find(ad->service_data, service_uuid_match, uuid); @@ -942,7 +940,7 @@ bool bt_ad_add_data(struct bt_ad *ad, uint8_t type, void *data, size_t len) if (!ad) return false; - if (len > (MAX_ADV_DATA_LEN - 2)) + if (len > (BT_AD_MAX_DATA_LEN - 2)) return false; for (i = 0; i < sizeof(type_blacklist); i++) { diff --git a/src/shared/ad.h b/src/shared/ad.h index 19aa1d035..17e3b631b 100644 --- a/src/shared/ad.h +++ b/src/shared/ad.h @@ -27,6 +27,8 @@ #include "lib/bluetooth.h" #include "lib/uuid.h" +#define BT_AD_MAX_DATA_LEN 31 + #define BT_AD_FLAGS 0x01 #define BT_AD_UUID16_SOME 0x02 #define BT_AD_UUID16_ALL 0x03 -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qDqAC4OEO1/yGQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 09:34:27 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oPBaCoOEO18CvwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 09:34:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BE330420F0; Tue, 18 Aug 2020 09:34:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726391AbgHRHeV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 03:34:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbgHRHeU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 03:34:20 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34CA2C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 00:34:20 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id p138so21234366yba.12 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 00:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=KIJEag4RZzVjmVoGtDCYwvseq7Z4nG+l3ZU9rmybLkU=; b=aliNNij2eBXGZ5ozLtoii1xdwX5P4Cd7886XBsEDfY7wLrySG6SHUIMQB7JBJGXysw iFv2j/SAGHHSihY3K0931u7OA293EycVnTkaw2VETgMFsdkjYz/qUBV6qZs7aErL0QTH hbNIAupqJ89VGV9V4PKzFz9SiKihAqq5x+vwFCCVvMy/Vk1EfZbPAjEDDdlfSkZGhk3T B0d+sUe3S4sfoRgXKqwcl5fucq5yzQXPRFIY5uf51gE3Oeznfp9KfZDsA6kD9q6ymB8M W3UREEBkbILHDhn/8Lkg/LcWPmjqdalmQoklRjxAMDYz/TWDVEDFjQBmAWaL3L0JRMzh ZPWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=KIJEag4RZzVjmVoGtDCYwvseq7Z4nG+l3ZU9rmybLkU=; b=a8fKJE1UOfoCT4rj9mOWSX1eCS9lPk9YB/28ikfB9QVZM1fJhqk+F2ueYY39EZ2FmT 0aonTPlOIuZpNOFPL0FGKHgBWP22Yn7KPs9r7374Yt0YU9WkayMAhnUm9EggoEFiqY02 xX6lgoORpf37XgOXJPBWsaERt3H6E+gRXc7pVee+qSLeOX/knpE39lnIEvv6TZa0x7Jc 27tE4eQ4IjIfEljzgCgcb54jrsFdDEIQSMJeiQvuFpkXtWm1VpfqhlH39qxN6J79wlas JDQHlO8dnZWV7EkHOGWLnU9TfgkGTw317bqUlVWIqhN7U4gvyGWLlRKvWwSMX7/yygzd YhlQ== X-Gm-Message-State: AOAM530jCJ5BmJW91jAFR2NE7M/QtokNIFmN0MVIcqGBb3xkbr2x2y3S rdTIoTa3neHC8GrSwahDuUCMFbHK9Wae6LLz3SbupA/e65z0XxwOuuHvSYXYuiw1KUak3goQG8K ewriGWEjB5sdp4RwHgwyVdzeW83dQAJ4yhhF8YU5fjz8HGnjsI7xgNWGcBLMB+e/0NMH2DwOQ5X s9 X-Google-Smtp-Source: ABdhPJwbd2I7K7zI/PGqVVy/wyeCZ2Zp0OtK26fc5n3PEaT2t3GVLPSn0T2UB0Y5PFNJ779lW1g4wUR3Wzx4 X-Received: by 2002:a25:680e:: with SMTP id d14mr25153577ybc.15.1597736059010; Tue, 18 Aug 2020 00:34:19 -0700 (PDT) Date: Tue, 18 Aug 2020 15:34:09 +0800 Message-Id: <20200818153257.Bluez.v3.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [Bluez PATCH v3 1/2] device: Don't browse SDP if HIDSDPDisable is set From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: BE330420F0 X-Rspamd-UID: 74eeee From: Archie Pusaka <apusaka@chromium.org> According to the HID1.1 spec, part 5.3.4.9: The HIDSDPDisable attribute is a Boolean value, which indicates whether connection to the SDP channel and Control or Interrupt channels are mutually exclusive. This feature supports Bluetooth HID devices that have minimal resources, and multiplex those resources between servicing the initialization (SDP) and runtime (Control and Interrupt) channels. However, Bluez still tries to connect SDP upon HID connection, regardless of the existence of the HIDSDPDisable attribute. This patch prevents the connection of SDP after HID has been established, if the device has HIDSDPDisable attribute. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- Changes in v3: None Changes in v2: * Renaming passive_sdp_discovery to refresh_discovery profiles/input/device.c | 3 +++ src/device.c | 11 +++++++++-- src/device.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index 6ec0a4c63..5e47b88f2 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -1373,6 +1373,9 @@ static struct input_device *input_device_new(struct btd_service *service) /* Initialize device properties */ extract_hid_props(idev, rec); + if (idev->disable_sdp) + device_set_refresh_discovery(device, false); + return idev; } diff --git a/src/device.c b/src/device.c index 2237a7670..52dfea18f 100644 --- a/src/device.c +++ b/src/device.c @@ -195,6 +195,7 @@ struct btd_device { bool le; bool pending_paired; /* "Paired" waiting for SDP */ bool svc_refreshed; + bool refresh_discovery; /* Manage whether this device can wake the system from suspend. * - wake_support: Requires a profile that supports wake (i.e. HID) @@ -1472,7 +1473,6 @@ static gboolean dev_property_wake_allowed_exist( return device_get_wake_support(device); } - static gboolean disconnect_all(gpointer user_data) { struct btd_device *device = user_data; @@ -1805,7 +1805,7 @@ done: btd_error_failed(dev->connect, strerror(-err))); } else { /* Start passive SDP discovery to update known services */ - if (dev->bredr && !dev->svc_refreshed) + if (dev->bredr && !dev->svc_refreshed && dev->refresh_discovery) device_browse_sdp(dev, NULL); g_dbus_send_reply(dbus_conn, dev->connect, DBUS_TYPE_INVALID); } @@ -2572,6 +2572,11 @@ done: browse_request_free(req); } +void device_set_refresh_discovery(struct btd_device *dev, bool refresh) +{ + dev->refresh_discovery = refresh; +} + static void device_set_svc_refreshed(struct btd_device *device, bool value) { if (device->svc_refreshed == value) @@ -4071,6 +4076,8 @@ static struct btd_device *device_new(struct btd_adapter *adapter, device->db_id = gatt_db_register(device->db, gatt_service_added, gatt_service_removed, device, NULL); + device->refresh_discovery = true; + return btd_device_ref(device); } diff --git a/src/device.h b/src/device.h index cb8d884e8..5ba2d7fe0 100644 --- a/src/device.h +++ b/src/device.h @@ -145,6 +145,7 @@ void device_set_wake_override(struct btd_device *device, bool wake_override); void device_set_wake_allowed(struct btd_device *device, bool wake_allowed, guint32 id); void device_set_wake_allowed_complete(struct btd_device *device); +void device_set_refresh_discovery(struct btd_device *dev, bool refresh); typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal, void *user_data); -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uBWeFomEO18n8AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 09:34:33 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6KXkFImEO1+i4gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 09:34:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D850D420CC; Tue, 18 Aug 2020 09:34:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726598AbgHRHe0 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 03:34:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726424AbgHRHeZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 03:34:25 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01486C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 00:34:25 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id w11so21189954ybi.23 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 00:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=8eTraBlLlZCXBncwAvZWxQxxNtGKOGN+XtQwQFx1HXU=; b=oLXTjLg9JsSbeSESfrYdN+sWTj4eYdQBTbi0VDv9oe97jmF+izvH84C+t9zSXZ8RgY mp4STyZ1D9wvXZuJiDhpUdmzC7ZWdaslsH+MtuNx0j3J39NUNbJ/wiNL3ztpw1KSf1Lo luREMngUkloNOjk3pbMnQ5Rkxv47+BhUfcNtNpNlksUv5/cE/PpLBMjv2VB4MM/rh5Ss EV8FmlZUYqbDcjFEugVRiGAcpashJP1XVkMZ9VSX6F34r6Ck2NlQ0rUF9ni1YdRpg7rl hOWSZJOJkA97lu7Li1ynSWrsoTI0JF5yfsWeMo5fxVtQxWCcleDTSVs1Lpr86pPtVs5J tNiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8eTraBlLlZCXBncwAvZWxQxxNtGKOGN+XtQwQFx1HXU=; b=K3wtRp0XWvtVHhrOo8H0r4tgegbyHa8emMNs9UEa72c6T3vDDh5yFETIWnzwhy32UD Spb71J7hWboAPtNf17CMhuYv0qR2No6mfcLpDrAj/7oJTi31kqzsXw/mybBjJirYB9n3 w8jnK40C+L9OOM01Ml2JpoUlqX1adZ/ugDjgMQNWGrxZ9gCdPSb1FsV7MlNYjMJsGjs7 VJA8gybPnyDzczNpeg1V+wDtQzyiwKIQ/i9IlcULDgW2I8Z4xnjQAdVtRmPHp2w2blRn EndTcoVw/YvYPeZ8Eh2Vh2MtpYYWywCLXjAK2p39OE5BQsRV4GMWE6iZ4CyzoEXwFEIW 2/TQ== X-Gm-Message-State: AOAM533R5SEVlRwU0jIWfiHU08xk9sFnbhryxKtK3jrmSjduYWBDxZ2q /VldGDgeCwzkGzofcmXj8gHRPHOOipsthQrpgokDpplpkKsCMhfipdnb8Wq7EKMGnRsIAM4QddH /dwiMnh7BqFD2MOMJ6ROk9fHt/ZnrAipB0HKU00G29xU2Rb6+A1c5/imSvKmeN/YEc+gzhqyByu Dx X-Google-Smtp-Source: ABdhPJwBQ3GuJfx/yUbGcoSKdYE8lQg651boXcPHkh1lnS3K7Usfz9FttXBdXqViV2452GkFUxZ5kF4ryBC7 X-Received: by 2002:a25:7453:: with SMTP id p80mr24878522ybc.441.1597736064054; Tue, 18 Aug 2020 00:34:24 -0700 (PDT) Date: Tue, 18 Aug 2020 15:34:10 +0800 In-Reply-To: <20200818153257.Bluez.v3.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> Message-Id: <20200818153257.Bluez.v3.2.Ic94b32e61bb62c601e5c56e2eb32a4896c4bbf1c@changeid> Mime-Version: 1.0 References: <20200818153257.Bluez.v3.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [Bluez PATCH v3 2/2] main: add configurable refresh_discovery parameter From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: D850D420CC X-Rspamd-UID: cd648a From: Archie Pusaka <apusaka@chromium.org> This is to configure the default behavior of issuing SDP query to update the services upon profile connection. --- Changes in v3: * Add main_opts.refresh_discovery Changes in v2: None src/device.c | 2 +- src/hcid.h | 1 + src/main.c | 8 ++++++++ src/main.conf | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index 52dfea18f..a91eda027 100644 --- a/src/device.c +++ b/src/device.c @@ -4076,7 +4076,7 @@ static struct btd_device *device_new(struct btd_adapter *adapter, device->db_id = gatt_db_register(device->db, gatt_service_added, gatt_service_removed, device, NULL); - device->refresh_discovery = true; + device->refresh_discovery = main_opts.refresh_discovery; return btd_device_ref(device); } diff --git a/src/hcid.h b/src/hcid.h index 5f249ebf9..3624ba6ea 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -100,6 +100,7 @@ struct main_opts { gboolean name_resolv; gboolean debug_keys; gboolean fast_conn; + gboolean refresh_discovery; uint16_t did_source; uint16_t did_vendor; diff --git a/src/main.c b/src/main.c index ec7a9fbd7..b205575f6 100644 --- a/src/main.c +++ b/src/main.c @@ -627,6 +627,13 @@ static void parse_config(GKeyFile *config) else main_opts.fast_conn = boolean; + boolean = g_key_file_get_boolean(config, "General", + "RefreshDiscovery", &err); + if (err) + g_clear_error(&err); + else + main_opts.refresh_discovery = boolean; + str = g_key_file_get_string(config, "GATT", "Cache", &err); if (err) { DBG("%s", err->message); @@ -688,6 +695,7 @@ static void init_defaults(void) main_opts.reverse_discovery = TRUE; main_opts.name_resolv = TRUE; main_opts.debug_keys = FALSE; + main_opts.refresh_discovery = TRUE; main_opts.default_params.num_entries = 0; main_opts.default_params.br_page_scan_type = 0xFFFF; diff --git a/src/main.conf b/src/main.conf index f41203b96..42f7e41c5 100644 --- a/src/main.conf +++ b/src/main.conf @@ -82,6 +82,10 @@ # 0 = disable timer, i.e. never keep temporary devices #TemporaryTimeout = 30 +# Enables the device to issue an SDP request to update known services when +# profile is connected. Defaults to true. +#RefreshDiscovery = true + [Controller] # The following values are used to load default adapter parameters. BlueZ loads # the values into the kernel before the adapter is powered if the kernel -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kLtVJ9SJO191LAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 09:57:08 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id uGO0JdSJO1/YcwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 09:57:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4D4CCA24CC; Tue, 18 Aug 2020 09:57:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726422AbgHRH4z (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 03:56:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgHRH4y (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 03:56:54 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 244BCC061389; Tue, 18 Aug 2020 00:56:54 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id y206so9548664pfb.10; Tue, 18 Aug 2020 00:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=0a8ZXLhEGMn1gXIxhyv1oqNmrc1yvciM66y5dEH31qA=; b=OnMPWYm8lscfbPQyj1djbb0PioZoTGd5x4JH/p04tOQzntO2w3QdMDxT4Vh3tE6Kpp JEfePTroeo3muKV9QU6EQicNZyKS1IUHCaxsGZAe6s8+MGYiA+oAiwz9p5ucVc5j8A/z +3JgFIXMFVippgcpe7Ab4SDXt3aYmlLU+u8nx7Tj+g/zovWtHaOEOv2YXc9//frymD1+ p7wAkJFfgHwjxsUzpHXxKKCDlPtBwf46S8k/8QxlMToSmWkj7plbCYY6hbGxptfuKAhv W8oZ/FBjzR/kmFc8lnUnnrfx2KykJWhD4fhHA9k7P0/9WEubGAoG2ln+MWK2q+39qh9A AM5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=0a8ZXLhEGMn1gXIxhyv1oqNmrc1yvciM66y5dEH31qA=; b=sHsvUjuY63MmHIX7X/Azg0PS78IiR2xjrBD9QZWaSaPs2aiuanzGhaT0ET4T3v22IT KGanZHJg/gmpXolC8mS9Sb5bexrqv4rmMz4rRVe2w+HoyCYC9/SnGqiiBZcQBix4zMqq 0FclGWM7BrlPxsgoxOt1KU5659vrFM5nJTJrHGwmO/7T/jQQpyj5Qrl3SHwex+11W/kc /KAAXfsoYaf6T8stoFWU0/NRn7zOi5kgMvPFJ9VeEM8Ok1YAxogG8eaHBDzdX3ox4Ts1 1j5Ak2p08Rq2UaFZlbp5eFX1WSSO8k+7MMuc5lu4GKTxOMdc8/8wucA5tKyHkKpmKjmL KnSw== X-Gm-Message-State: AOAM533EtORE7fQds3hELoSniNnfyMjPPy9QzCZdolVjoHbOCFh2SsQ1 Xfr1OSGFFP7mK39ASW2+Xic8kviWlMg= X-Google-Smtp-Source: ABdhPJwCldrcVcuZK3TXMeMsmX3YZ82dces6WA6CSG6z3pNHH/qbchCc3BqaDK6HrNnLWrmYWImFHg== X-Received: by 2002:aa7:99cc:: with SMTP id v12mr14322545pfi.255.1597737412978; Tue, 18 Aug 2020 00:56:52 -0700 (PDT) Received: from oppo (69-172-89-151.static.imsbiz.com. [69.172.89.151]) by smtp.gmail.com with ESMTPSA id r28sm23400867pfg.158.2020.08.18.00.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 00:56:51 -0700 (PDT) Date: Tue, 18 Aug 2020 15:56:48 +0800 From: Qingyu Li <ieatmuttonchuan@gmail.com> To: marcel@holtmann.org, johan.hedberg@gmail.com, davem@davemloft.net, kuba@kernel.org Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net/bluetooth/hci_sock.c: add CAP_NET_RAW check. Message-ID: <20200818075648.GA29124@oppo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.09 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4D4CCA24CC X-Rspamd-UID: 1d516d When creating a raw PF_BLUETOOTH socket, CAP_NET_RAW needs to be checked first. Signed-off-by: Qingyu Li <ieatmuttonchuan@gmail.com> --- net/bluetooth/hci_sock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 251b9128f530..c0919e209f05 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -2034,6 +2034,9 @@ static int hci_sock_create(struct net *net, struct socket *sock, int protocol, if (sock->type != SOCK_RAW) return -ESOCKTNOSUPPORT; + if (!capable(CAP_NET_RAW)) + return -EPERM; + sock->ops = &hci_sock_ops; sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto, kern); -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wBEjHzyMO1+NSwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 10:07:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2BDqHTyMO1+P4QAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 10:07:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1F599A1419; Tue, 18 Aug 2020 10:07:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726592AbgHRIHJ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 04:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbgHRIHI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 04:07:08 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ACD7C061389; Tue, 18 Aug 2020 01:07:08 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id mw10so8894821pjb.2; Tue, 18 Aug 2020 01:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=StFFVCyyrqOkn7U9cLGxAfuLpee/KXFwmS5u87kiIm4=; b=iwISd+CWW2R7LQdicuTPCO4Djz+Ep8Wv035bwy+fTHpfPjAldOMn8249OlRIpvpyYZ Es6G5h55Cgvnd5ZDOOavmtGyfZnD+VnPHVberGV9wsB8LFiNcn/CCEBvZihm+MMiKOkX PfmRfyf3M4cNxWUJyD3RrKMTFpQ9FaIhU9R7OODxee8pa6G5EZAUreV2v6KCC+qgm3YY EwdmAZMuo5VKfz2Sx/rmwABbnrjqwN4nR+MNGziHsy5iJIAd2Z5/XGrc3rrnE8wUfqnA T0KRi/2W5GALncOgHIcHIwci8ERvgLydaFzAcNzFeG+BFq5lTQ8OdIDdcWIjCrGtuT44 HCTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=StFFVCyyrqOkn7U9cLGxAfuLpee/KXFwmS5u87kiIm4=; b=TDb+jx0pDP3p5VDPnrONNz2imG8tIlQu0KppL6VzcxKq3qfNvE5YIvIyLvRDCmbnQW ZhFzPDACYXZIXKng5Q/MZp53afYSTpM7E31vHBahiIRbr0nSGXlAQxBsPtDzAB34AYSR 2Gu8yegmzfNmzpYUHpdfjWsAFMVnsBxDKW+gGReQNYQy1EKm09L5IRGLzEV6sNglMnB2 lPCfzkoKcBTg29QVCNsYChcAjFv9I9rM+2P/wdUPX9MJlnfCwv9vUaV7XCGqaVcKB035 kNZznGNRQEw+dhiRmIZswxIWNkFWy2oLwxdeH4cntzXtVXi2Fbui6mTKh+tczxB+S70q J2MA== X-Gm-Message-State: AOAM531MESycJtOOg0ZZuLb+tsWGWzFgycuG9sfk747GeICoIXZwkHWk Y4K28LBU3DkhJjE4w6FOLjoOD1F9F1E= X-Google-Smtp-Source: ABdhPJz8H1EB4gkEEbz+CgswsYmcAgHxH1hWTh2rxtMgeriPdI0/FERnAKJJOo4zzNahWr410ikthA== X-Received: by 2002:a17:90a:8d85:: with SMTP id d5mr14752437pjo.45.1597738027502; Tue, 18 Aug 2020 01:07:07 -0700 (PDT) Received: from oppo (69-172-89-151.static.imsbiz.com. [69.172.89.151]) by smtp.gmail.com with ESMTPSA id kb2sm20369902pjb.34.2020.08.18.01.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 01:07:06 -0700 (PDT) Date: Tue, 18 Aug 2020 16:07:03 +0800 From: Qingyu Li <ieatmuttonchuan@gmail.com> To: marcel@holtmann.org, johan.hedberg@gmail.com, davem@davemloft.net, kuba@kernel.org Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net/bluetooth/bnep/sock.c: add CAP_NET_RAW check. Message-ID: <20200818080703.GA31526@oppo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.09 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1F599A1419 X-Rspamd-UID: de323f When creating a raw PF_BLUETOOTH socket, CAP_NET_RAW needs to be checked first. Signed-off-by: Qingyu Li <ieatmuttonchuan@gmail.com> --- net/bluetooth/bnep/sock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c index d515571b2afb..e06787a3b5ce 100644 --- a/net/bluetooth/bnep/sock.c +++ b/net/bluetooth/bnep/sock.c @@ -204,6 +204,9 @@ static int bnep_sock_create(struct net *net, struct socket *sock, int protocol, if (sock->type != SOCK_RAW) return -ESOCKTNOSUPPORT; + if (!capable(CAP_NET_RAW)) + return -EPERM; + sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto, kern); if (!sk) return -ENOMEM; -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SOSmMbuPO1+cZgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 10:22:19 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eKtMMLuPO19eKwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 10:22:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7BD4AA2792; Tue, 18 Aug 2020 10:22:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726451AbgHRIVJ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 04:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgHRIVI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 04:21:08 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06FEAC061389; Tue, 18 Aug 2020 01:21:08 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id y6so8882586plt.3; Tue, 18 Aug 2020 01:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=R6UfMfJwqHE+FvqFjrSG5hHKZrDmBk/7qX6MpbTswn4=; b=P+O+y6fHin2i63yQXnz5g3IAJ2NyZIMZ1e9cDB3VdSIrWcUAfL5/9ydchAsgXekI/6 nNHfNWZovhWixT/cctY0wawTSq7P3mL8gyCOCJtcvt2Rn9Pskgy6Gt6fR517kpfHPXKM FL8uePTrKBJYJZTFqeGjrRUnMWqMScl/eK3kBuVT9xBeRohWi+4O7ALoUGKDUgH9oV91 InGy8RhGQJjYhDKiUXaC9K4itTlqZm0OKqvXKocL0qwuc0YiBdIksHA4KX4dQELsPvvZ JplSArwK3psUnHIdO0iKEMCzwvBsr7NthpCB1DYxdISthYp7QD+NTVdCQFD9Up3+AfbC vtZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=R6UfMfJwqHE+FvqFjrSG5hHKZrDmBk/7qX6MpbTswn4=; b=X3xVog0QJIqXEhQfrdGlY+2xbFb6j6d3cEWR11KfEY7u4vfypmgJm4Q9LrjSh8Z/L/ kXGa+EtVEQtBSkoXY32rXv0p27zGJDbDKoOpDnlr53QihBtuC7/+TgC8q6G4tQIYvHXg xYmVyTCE/TfNkGvBgDctw6qYLwgpyihdYixfzpG70hpulUSwgGeWQ4ry61embmdcqY+e Qq+bpGKE8SUMuNt9cQV5b6R6fCjPv7p4bZFCehyYy5U9Y33Nf0nSeMrqJvaNpLHg/Crm 8xjZGQYK6muG8SMQ5kDT/9CU8jxWL09wl1ahg/htk4nTKaothq1yV1J7Oot/9jID/UdN PfqA== X-Gm-Message-State: AOAM533LEMlvPIA3b4C8wCZkxdE/OnJUh4GDBB1CmmfdYhEUo/57D3gu UbBFeyriIRaJJho91CqPWIj2PRAAvxY= X-Google-Smtp-Source: ABdhPJw29b/0fFyJtX5wxY8KVFb2zCD7jrzyjFsJtlVcZkoELYesRJIsd5ew9C3u9p0L9p2Qspv+UQ== X-Received: by 2002:a17:90b:4a4e:: with SMTP id lb14mr15864480pjb.228.1597738867036; Tue, 18 Aug 2020 01:21:07 -0700 (PDT) Received: from oppo (69-172-89-151.static.imsbiz.com. [69.172.89.151]) by smtp.gmail.com with ESMTPSA id u65sm23398632pfb.102.2020.08.18.01.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 01:21:06 -0700 (PDT) Date: Tue, 18 Aug 2020 16:21:03 +0800 From: Qingyu Li <ieatmuttonchuan@gmail.com> To: marcel@holtmann.org, johan.hedberg@gmail.com, davem@davemloft.net, kuba@kernel.org Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net/bluetooth/hidp/sock.c: add CAP_NET_RAW check. Message-ID: <20200818082103.GA2692@oppo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.09 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7BD4AA2792 X-Rspamd-UID: 4a8a33 When creating a raw PF_BLUETOOTH socket, CAP_NET_RAW needs to be checked first. Signed-off-by: Qingyu Li <ieatmuttonchuan@gmail.com> --- net/bluetooth/hidp/sock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index 595fb3c9d6c3..3dd9c8e0419a 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c @@ -255,6 +255,9 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol, if (sock->type != SOCK_RAW) return -ESOCKTNOSUPPORT; + if (!capable(CAP_NET_RAW)) + return -EPERM; + sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto, kern); if (!sk) return -ENOMEM; -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GCoaK3WOO19bYwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 10:16:53 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YDh1KXWOO1/bSAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 10:16:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 49116420E4; Tue, 18 Aug 2020 10:16:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726420AbgHRIQA (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 04:16:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726341AbgHRIP7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 04:15:59 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33AB6C061389; Tue, 18 Aug 2020 01:15:59 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id o5so9421042pgb.2; Tue, 18 Aug 2020 01:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=efKFji4wZbV4ryr84E81ykO6FthaFggVytOSX8yMq3Y=; b=j+erm+9yXM4DR4o7ac1+SNFpUbtVt7I+meQmJ9mwt1rWnlVx3+DV0yFmieYZ9XpIUz fj9fyWBBf0gLW3MQKfglYyXP62+cvv12b+wuDmpcOqZDvXab83Hf+/cMrnmlNSaItrO1 CpIw1hvTMf+QACLdXFmi7Y/BI3Ohgo17bIrAkONlOeYksHZ7jjNNYJWzRMdTENdsGqjO PpG0yz734CNm3MvjDxWeG7hNf44ABwTgVnkf+CTRyIEWBaGklzmuAupD5C2idxmBfCPy DruKenMqsbuJLjKLMpFo3J095x95IG9MMeoeCDmExu/OyAJUWoYwgZ7D5/+c7hkNDF3H ITJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=efKFji4wZbV4ryr84E81ykO6FthaFggVytOSX8yMq3Y=; b=r3IE5poXfBQCalz4YvMP01y5oHZm8c0246lXhlrX3snH+CCU48qVN4q73cD9l9yQ/y g26X6MpcnLK1tlofc1o+IADaqZKhzFELX2mErQD7wD/zOhrxGDsEMcPSzWDFPoo83r9+ 5hGYnIbIW6nd3Nbv+XQOWPEZThND5R9JM/jEINMaDIQ3vFW/T6utcjScSnacZqkoFsTs nFCLWQF2KXYp/8SptEG8fgHAU0FhW2dlJBrgd7bUAiD0LczKsfXwjjMmLPW7DEcS8LEx 5MshqqfQuhUC/XjbwfsXNtZ7ahqRrFbvp111EDOT4kibk2n9rR8TYDx5UxEuekjA/lRM w4dQ== X-Gm-Message-State: AOAM530Nsy8QmhAjXPUJnaybATvY8te2LhR0ShKpB1wV0ZFtGy4NX4Z0 ZLXpw3YkSj85m9fNfnt5pcLx+TvPT+M= X-Google-Smtp-Source: ABdhPJyHJGPp/aTkTMW7Ie/M2t3v4BMfISMnMoQO4IWHF2fIZIMsBP0/H7MRTu+ep8AUqS87MVWcQA== X-Received: by 2002:a62:9254:: with SMTP id o81mr14137225pfd.73.1597738558202; Tue, 18 Aug 2020 01:15:58 -0700 (PDT) Received: from oppo (69-172-89-151.static.imsbiz.com. [69.172.89.151]) by smtp.gmail.com with ESMTPSA id d13sm23367913pfq.118.2020.08.18.01.15.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 01:15:57 -0700 (PDT) Date: Tue, 18 Aug 2020 16:15:55 +0800 From: Qingyu Li <ieatmuttonchuan@gmail.com> To: marcel@holtmann.org, johan.hedberg@gmail.com, davem@davemloft.net, kuba@kernel.org, isdn@linux-pingi.de Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net/bluetooth/cmtp/sock.c: add CAP_NET_RAW check. Message-ID: <20200818081555.GA1349@oppo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.09 / 15.00 / 200.00 X-Rspamd-Queue-Id: 49116420E4 X-Rspamd-UID: 5ec96c When creating a raw PF_BLUETOOTH socket, CAP_NET_RAW needs to be checked first. Signed-off-by: Qingyu Li <ieatmuttonchuan@gmail.com> --- net/bluetooth/cmtp/sock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c index 96d49d9fae96..476ccc9bee7c 100644 --- a/net/bluetooth/cmtp/sock.c +++ b/net/bluetooth/cmtp/sock.c @@ -207,6 +207,9 @@ static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol, if (sock->type != SOCK_RAW) return -ESOCKTNOSUPPORT; + if (!capable(CAP_NET_RAW)) + return -EPERM; + sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto, kern); if (!sk) return -ENOMEM; -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cFVOFIeSO19FagEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 10:34:15 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iJ13EoeSO19KpAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 10:34:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6BFD0420F1; Tue, 18 Aug 2020 10:34:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726391AbgHRIeD (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 04:34:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgHRIeC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 04:34:02 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBC6EC061389; Tue, 18 Aug 2020 01:34:01 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id l60so9093507pjb.3; Tue, 18 Aug 2020 01:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=szP+8DM2fo2Wg0FXKp5oArkPY3dRWu1AVOY6u2GDxKg=; b=kXXy4d11xMBXcJj+fsuZKlC40XsOYUs9qFdqzuKei+P99PVGYB4cy5YvPiCQ9SE5gc nwowHtPWMwFGXmPyaIHawdQfK5b06JAnIyDjOBe3YW++Q1BV0EX6kfoY8km/11uZY8hV YprH1emQ2HNL0jUmKDhfxqGEcu+tHvd3Vtkby05p+VNjxGkQZQBEPYl+7IXbofAl6BG3 hhOroOHfCMUIFb1yeteG3XTgjOWMSn+dJWzkVa23ynA8tSGk1jcOWqU1t6F/2rg4cH0O Xw3eM1EmBGSLh20rgcywQjdmExvL2tkXvXtQYrrhFcy/p1TGSvWno4qJpYUyybKlEz3c pc1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=szP+8DM2fo2Wg0FXKp5oArkPY3dRWu1AVOY6u2GDxKg=; b=GEUMHkv9et6kytyATo1Bjk5Dq3sclEtC9cwA8XFEEgoWrai68JVpkjmtMOSxliZ256 HnyzfqLr6ImkQNkFS0EVN3ZqC3HgbpLZda4OKq5/wpc58oIl6qKyU7GY+uSBHJY3dUPZ FRtwQP/WOI5baBNrBUB20/zbrD7MJ9yL6PkJA54lnkEiCZQCE5jVK61pJf9SfauKXgya REeSCba++qEpCnBmS6l82T4AHLd6vrR/gHGs7l/GVDCmfp6OmxCokmtGH+VsZyn1lvlu +WXfCX9Oy0PqKr1h83i+CkC+DDMeDL15bWIIJ8nxrqoouMBGmPIAa4eyVRpyEZKuSLgU XEFg== X-Gm-Message-State: AOAM532HqF4zYRm2aWzo6aDlXBuO6F+5uZ4NwkUzzlkQ0OmEUvcKTDp1 gwvheujqq17jGDVP0CIPzpxjKODRq1A= X-Google-Smtp-Source: ABdhPJx/UC+X2o5gXzjptm7LMgpeuMJeCeHbSRiXInZVSqmm1lN4kB/ZsnKF8m/DRi8+r0YbjnrTpw== X-Received: by 2002:a17:902:bd90:: with SMTP id q16mr14299265pls.196.1597739641056; Tue, 18 Aug 2020 01:34:01 -0700 (PDT) Received: from oppo (69-172-89-151.static.imsbiz.com. [69.172.89.151]) by smtp.gmail.com with ESMTPSA id l78sm23898616pfd.130.2020.08.18.01.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 01:34:00 -0700 (PDT) Date: Tue, 18 Aug 2020 16:33:57 +0800 From: Qingyu Li <ieatmuttonchuan@gmail.com> To: marcel@holtmann.org, johan.hedberg@gmail.com, davem@davemloft.net, kuba@kernel.org, matthieu.baerts@tessares.net, stefan@datenfreihafen.org, arnd@arndb.de, gustavoars@kernel.org, bigeasy@linutronix.de Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net/bluetooth/rfcomm/sock.c: add CAP_NET_RAW check. Message-ID: <20200818083357.GA5442@oppo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.09 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6BFD0420F1 X-Rspamd-UID: ca80a3 When creating a raw PF_BLUETOOTH socket, CAP_NET_RAW needs to be checked first. Signed-off-by: Qingyu Li <ieatmuttonchuan@gmail.com> --- net/bluetooth/rfcomm/sock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index ae6f80730561..d67d49e5aa00 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -321,6 +321,9 @@ static int rfcomm_sock_create(struct net *net, struct socket *sock, if (sock->type != SOCK_STREAM && sock->type != SOCK_RAW) return -ESOCKTNOSUPPORT; + if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW)) + return -EPERM; + sock->ops = &rfcomm_sock_ops; sk = rfcomm_sock_alloc(net, sock, protocol, GFP_ATOMIC, kern); -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QNi5HiMHPF8XrgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 18:51:47 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EKCmHCMHPF8R6AAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 18:51:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=dptechnics.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 265D5420D9; Tue, 18 Aug 2020 18:51:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726974AbgHRQve (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 12:51:34 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17124 "EHLO sender4-op-o11.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726715AbgHRQvc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 12:51:32 -0400 X-Greylist: delayed 905 seconds by postgrey-1.27 at vger.kernel.org; Tue, 18 Aug 2020 12:51:32 EDT ARC-Seal: i=1; a=rsa-sha256; t=1597768587; cv=none; d=zohomail.com; s=zohoarc; b=N0GrxEhOEDYs/e1/1yq7Crb2xLfUfNEFauIXrRH4OujoFxhGCYvTcjP0pQqmS2yUpAJf6qoDnNIlYwF3zSS9HSoK3uxQh7Hu4UG0jJo/52L1CeweAvDl3gJYB5o7EoaF4HeS7UpXjlEpgufd/kg9dMJshFKDMD8+jRs7IpxRKvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597768587; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=MT2STI3D/C0IsbHcGVmVjss1gyVSWlFxJWLW8Trr2tk=; b=ly1OCPZHpJiV2owQhxFIJd0SmHYnZygJUASqKCtTOuSLdLlCTW3EGWi5jtcJm71kMweDQUCE0WNVO8pdFVSWeH6WZQF0aoHwjHogF1yIuXRXMrOPElYsX4P9FeAvBeJwp/Dha1b2A9ahiwoya6IhKrfrClR3SKLbDWYMabL80Bc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=dptechnics.com; spf=pass smtp.mailfrom=daan@dptechnics.com; dmarc=pass header.from=<daan@dptechnics.com> header.from=<daan@dptechnics.com> DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1597768587; s=zoho; d=dptechnics.com; i=daan@dptechnics.com; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=MT2STI3D/C0IsbHcGVmVjss1gyVSWlFxJWLW8Trr2tk=; b=AihgrU43knZAUw9Qiwwa6Y8I0DN8V9co7TN4uZK74HAqqpVaEFLpbk1SNy/c931g 6tukEMOoWPQlBSk1iwmbHGrm7ScVFadJ81fMeBPTXyg5DOTb01X3fWQFnImKwARwVxN 42LXrGK/13HQ04YskiNJRtK8/GxudRrQhRAExnbg= Received: from daan-devbox.dptechnics.local (178-116-74-88.access.telenet.be [178.116.74.88]) by mx.zohomail.com with SMTPS id 1597768585055945.5832986315066; Tue, 18 Aug 2020 09:36:25 -0700 (PDT) From: Daan Pape <daan@dptechnics.com> To: linux-bluetooth@vger.kernel.org Cc: Daan Pape <daan@dptechnics.com> Message-ID: <20200818163611.57656-2-daan@dptechnics.com> Subject: [PATCH BlueZ 1/1] Fixed issue in bluetooth-meshd which causes HCI error 0x12 when LE scanning is enabled because no random address was set. This is fixed by using the default HCI own device address option. Date: Tue, 18 Aug 2020 18:36:11 +0200 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200818163611.57656-1-daan@dptechnics.com> References: <20200818163611.57656-1-daan@dptechnics.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.14 / 15.00 / 200.00 X-Rspamd-Queue-Id: 265D5420D9 X-Rspamd-UID: df4f7b --- mesh/mesh-io-generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c index 67b13a1b9..65fd1c7b9 100644 --- a/mesh/mesh-io-generic.c +++ b/mesh/mesh-io-generic.c @@ -321,7 +321,7 @@ static void scan_disable_rsp(const void *buf, uint8_t s= ize, =09cmd.type =3D pvt->active ? 0x01 : 0x00;=09/* Passive/Active scanning */ =09cmd.interval =3D L_CPU_TO_LE16(0x0010);=09/* 10 ms */ =09cmd.window =3D L_CPU_TO_LE16(0x0010);=09/* 10 ms */ -=09cmd.own_addr_type =3D 0x01;=09=09/* ADDR_TYPE_RANDOM */ +=09cmd.own_addr_type =3D 0x00; =09=09/* Public Device Address */ =09cmd.filter_policy =3D 0x00;=09=09/* Accept all */ =20 =09bt_hci_send(pvt->hci, BT_HCI_CMD_LE_SET_SCAN_PARAMETERS, @@ -579,7 +579,7 @@ static void set_send_adv_params(const void *buf, uint8_= t size, =09cmd.min_interval =3D L_CPU_TO_LE16(hci_interval); =09cmd.max_interval =3D L_CPU_TO_LE16(hci_interval); =09cmd.type =3D 0x03; /* ADV_NONCONN_IND */ -=09cmd.own_addr_type =3D 0x01; /* ADDR_TYPE_RANDOM */ +=09cmd.own_addr_type =3D 0x00; /* Public Device Address */ =09cmd.direct_addr_type =3D 0x00; =09memset(cmd.direct_addr, 0, 6); =09cmd.channel_map =3D 0x07; --=20 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ELOyFikHPF8XrgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 18:51:53 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YEmIFCkHPF8G6QEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 18:51:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=dptechnics.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6BC27420EC; Tue, 18 Aug 2020 18:51:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727049AbgHRQvf (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 12:51:35 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17155 "EHLO sender4-op-o11.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726840AbgHRQvc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 12:51:32 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1597768585; cv=none; d=zohomail.com; s=zohoarc; b=CON19CHeR1Xgocqgddwew1x9zb8XNEnAnl9AxuWX5rPucmdYiQczRYVTu16WYDXR2BhZK9GoDpEtbsPYWYj0t5YINYxt3AjNjF4JbjqsqYmuVjcHUuNvuvqND+BZyKY88Pw6OsiCLG5A3YOGSXrq1P0uNfB3gBl3aYrcdEqfTl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597768585; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=hxsuXnoF+ernwmZV6yS/o5gUrMIRlNZG3bcfp4HIIhQ=; b=M/wWy+c7pLDY02KvkYwh6PlXIx1Zii6NwXf46XPSfY+H1BR0EnBhCGvmqaXmas/8VO6bQPTJM+y1fQu7GYTwwKvAYTSdobv/whcMbAnZBxehscmWG6/BviBbCdh90hvtFR5MhA77jC3nyzHlwOsZ6dXlNNqeOA+bRwJva5uqens= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=dptechnics.com; spf=pass smtp.mailfrom=daan@dptechnics.com; dmarc=pass header.from=<daan@dptechnics.com> header.from=<daan@dptechnics.com> DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1597768585; s=zoho; d=dptechnics.com; i=daan@dptechnics.com; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=hxsuXnoF+ernwmZV6yS/o5gUrMIRlNZG3bcfp4HIIhQ=; b=ZAzOzV+9bK4tA4+mH28ZVTDclkfeNHDKUy1RAmocW3QwOmdhzPdpbtmFErekbs2a Wz1CchP36EIHGssp6IFPaDircdsvMhPyIQOXmB19o98u1ia+Gv+DJnpPB4tUqtlpWH5 DyKihsR32KrbkoN8PuDrz6JdkCBnbfN8WnLsFBJE= Received: from daan-devbox.dptechnics.local (178-116-74-88.access.telenet.be [178.116.74.88]) by mx.zohomail.com with SMTPS id 1597768581616726.7700689087546; Tue, 18 Aug 2020 09:36:21 -0700 (PDT) From: Daan Pape <daan@dptechnics.com> To: linux-bluetooth@vger.kernel.org Cc: Daan Pape <daan@dptechnics.com> Message-ID: <20200818163611.57656-1-daan@dptechnics.com> Subject: [PATCH BlueZ 0/1] Fixed issue in bluetooth-meshd which causes HCI Date: Tue, 18 Aug 2020 18:36:10 +0200 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.13 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6BC27420EC X-Rspamd-UID: bc12e8 I had compiled bluez for OpenWRT and was running the bluetooth-meshd daemon with a Fanstel BT680T module which implement the Bluetooth 5.0 core specification. The daemon did not properly start and failed with error: LE Scan enable failed (0x12) This error is described on page 2496 of the Bluetooth Core Specification Version 5.2 and is caused by the fact that no random address was initialized. The issue is resolved by falling back to using the default HCI advertisement settings which use the public device address in it's advertisements. This is the first time that I contribute to Bluez so please forgive me if I made any styling mistake in the patch format. I also did not include my details in the 'AUTHORS' file just yet as I first wanted to wait for your reaction. In case the patch is accepted my name can be added to the 'AUTHORS' file as: Daan Pape <daan@dptechnics.com> Please do not hesitate to ask any further questions if neccesary. Kind regards, Daan Pape Daan Pape (1): Fixed issue in bluetooth-meshd which causes HCI error 0x12 when LE scanning is enabled because no random address was set. This is fixed by using the default HCI own device address option. mesh/mesh-io-generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --=20 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uHi0GkodPF9pVAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 20:26:18 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id EFkyGUodPF9SSAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 20:26:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4ABCB41175; Tue, 18 Aug 2020 20:26:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726653AbgHRS0H (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 14:26:07 -0400 Received: from mga01.intel.com ([192.55.52.88]:24086 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726652AbgHRS0G (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 14:26:06 -0400 IronPort-SDR: dHpTq1qXN7/4wYILMELe3w7gwqEQMGwU/P0Xnykja7gFHXhd+S6x8Y3LPQpFz7SiR3W7s7ZWwN gSzggFfq5eeA== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="173032866" X-IronPort-AV: E=Sophos;i="5.76,328,1592895600"; d="scan'208";a="173032866" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 11:26:07 -0700 IronPort-SDR: oC63Dy7qujs42aK44MwCv4Dhj/DyNLMFkIj7OrB6Wo3dyWwXxaBa53jFFRkn+6oI33G8ssXBWI i+KMeWZnBm/w== X-IronPort-AV: E=Sophos;i="5.76,328,1592895600"; d="scan'208";a="441318282" Received: from jbrandeb-mobl3.amr.corp.intel.com (HELO localhost) ([10.212.158.55]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 11:26:06 -0700 Date: Tue, 18 Aug 2020 11:26:05 -0700 From: Jesse Brandeburg <jesse.brandeburg@intel.com> To: Qingyu Li <ieatmuttonchuan@gmail.com> Cc: <marcel@holtmann.org>, <johan.hedberg@gmail.com>, <davem@davemloft.net>, <kuba@kernel.org>, <linux-bluetooth@vger.kernel.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: Re: [PATCH] net/bluetooth/hci_sock.c: add CAP_NET_RAW check. Message-ID: <20200818112605.0000735f@intel.com> In-Reply-To: <20200818075648.GA29124@oppo> References: <20200818075648.GA29124@oppo> X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.89 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4ABCB41175 X-Rspamd-UID: c812ef On Tue, 18 Aug 2020 15:56:48 +0800 Qingyu Li <ieatmuttonchuan@gmail.com> wrote: > When creating a raw PF_BLUETOOTH socket, > CAP_NET_RAW needs to be checked first. > Thanks for the patch! Your subject doesn't need to end in a period. In your commit message, I can guess why you'd want this patch, but your commit message should include more info about why the kernel wants this patch included. Especially since this is a user visible change and likely a fix of a bug. Please review: https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html specifically: https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html#q-any-other-tips-to-help-ensure-my-net-net-next-patch-gets-ok-d This looks like a fix, please add a Fixes tag. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wLf7JwUePF+LSwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 20:29:25 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CEnZJQUePF/XhwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 20:29:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 875F8420BB; Tue, 18 Aug 2020 20:29:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726632AbgHRS3O (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 14:29:14 -0400 Received: from mga17.intel.com ([192.55.52.151]:12408 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbgHRS3N (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 14:29:13 -0400 IronPort-SDR: qEe9DGZi8c/iGxwS/bYtUm0HUqoAUuUMsBhpoZsgKbY/VEHkIN+fuUmM28j1uj8cfGmMw9blRp LR7h1THtWr2A== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="135049959" X-IronPort-AV: E=Sophos;i="5.76,328,1592895600"; d="scan'208";a="135049959" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 11:29:11 -0700 IronPort-SDR: tepklzs+fGxGB0rc/EqS7skQCMwXcY2hCWRtlxTCE6bDbEmgmi7qjeoXRbiomB3wN91POAXzCt Ysyurc8zLwJg== X-IronPort-AV: E=Sophos;i="5.76,328,1592895600"; d="scan'208";a="441319270" Received: from jbrandeb-mobl3.amr.corp.intel.com (HELO localhost) ([10.212.158.55]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 11:29:11 -0700 Date: Tue, 18 Aug 2020 11:29:10 -0700 From: Jesse Brandeburg <jesse.brandeburg@intel.com> To: Qingyu Li <ieatmuttonchuan@gmail.com> Cc: <marcel@holtmann.org>, <johan.hedberg@gmail.com>, <davem@davemloft.net>, <kuba@kernel.org>, <linux-bluetooth@vger.kernel.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: Re: [PATCH] net/bluetooth/bnep/sock.c: add CAP_NET_RAW check. Message-ID: <20200818112910.000014ea@intel.com> In-Reply-To: <20200818080703.GA31526@oppo> References: <20200818080703.GA31526@oppo> X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.59 / 15.00 / 200.00 X-Rspamd-Queue-Id: 875F8420BB X-Rspamd-UID: baf537 On Tue, 18 Aug 2020 16:07:03 +0800 Qingyu Li <ieatmuttonchuan@gmail.com> wrote: > When creating a raw PF_BLUETOOTH socket, > CAP_NET_RAW needs to be checked first. > These changes should be part of a series (patch 0,1,2 at least), and all my replies on your other patch apply to this one as well. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MHWfJGwePF92KwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 20:31:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 6JONI2wePF9S7wAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 20:31:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6DF8941175; Tue, 18 Aug 2020 20:31:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726652AbgHRSaz (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 14:30:55 -0400 Received: from mga07.intel.com ([134.134.136.100]:32379 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbgHRSay (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 14:30:54 -0400 IronPort-SDR: 0Uw3B1NnzfhgUa/sG1ZaojbETyzVJiggeGOpkFbVnE8TdT4wkbQW18AyqUOBkULd4O3AMzGTfK tUphSzRB+HqQ== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="219288186" X-IronPort-AV: E=Sophos;i="5.76,328,1592895600"; d="scan'208";a="219288186" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 11:30:54 -0700 IronPort-SDR: oj0ejtypoatnOF/6Jfpv4z3pZWgSMXINAyyeEt2NDboMQ3FCTxbQQTboobVnvDt29S+V+xr7AT 75jZaHEVqThw== X-IronPort-AV: E=Sophos;i="5.76,328,1592895600"; d="scan'208";a="441320016" Received: from jbrandeb-mobl3.amr.corp.intel.com (HELO localhost) ([10.212.158.55]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 11:30:54 -0700 Date: Tue, 18 Aug 2020 11:30:52 -0700 From: Jesse Brandeburg <jesse.brandeburg@intel.com> To: Qingyu Li <ieatmuttonchuan@gmail.com> Cc: <marcel@holtmann.org>, <johan.hedberg@gmail.com>, <davem@davemloft.net>, <kuba@kernel.org>, <isdn@linux-pingi.de>, <linux-bluetooth@vger.kernel.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: Re: [PATCH] net/bluetooth/cmtp/sock.c: add CAP_NET_RAW check. Message-ID: <20200818113052.000032ce@intel.com> In-Reply-To: <20200818081555.GA1349@oppo> References: <20200818081555.GA1349@oppo> X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.98 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6DF8941175 X-Rspamd-UID: dff170 On Tue, 18 Aug 2020 16:15:55 +0800 Qingyu Li <ieatmuttonchuan@gmail.com> wrote: > When creating a raw PF_BLUETOOTH socket, > CAP_NET_RAW needs to be checked first. Please see my previous replies. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wBNXOd0ePF/3ZAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 18 Aug 2020 20:33:01 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kGUnON0ePF8FhAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 18 Aug 2020 20:33:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C6D6DA122C; Tue, 18 Aug 2020 20:32:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbgHRSct (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 14:32:49 -0400 Received: from mga06.intel.com ([134.134.136.31]:35411 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbgHRScs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 14:32:48 -0400 IronPort-SDR: FkBHR5Io9EdyMCvjM321zkpuxcE1xlJ4/4aPKF9tzmbl/UZGqcE0NOPAe57c8MMcxHvSdcj+XF VQJdOkLCQjiQ== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="216509878" X-IronPort-AV: E=Sophos;i="5.76,328,1592895600"; d="scan'208";a="216509878" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 11:32:47 -0700 IronPort-SDR: mcHZD9yR72fMHBZ7Uh1ZiNrimzgYvVEjMT7VF2zjPlfvSsSbWsVOSW7HQ+ZPVWdJ2FXQQSN6Sw VlKUKtxOmEuQ== X-IronPort-AV: E=Sophos;i="5.76,328,1592895600"; d="scan'208";a="441320825" Received: from jbrandeb-mobl3.amr.corp.intel.com (HELO localhost) ([10.212.158.55]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 11:32:47 -0700 Date: Tue, 18 Aug 2020 11:32:46 -0700 From: Jesse Brandeburg <jesse.brandeburg@intel.com> To: Qingyu Li <ieatmuttonchuan@gmail.com> Cc: <marcel@holtmann.org>, <johan.hedberg@gmail.com>, <davem@davemloft.net>, <kuba@kernel.org>, <linux-bluetooth@vger.kernel.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: Re: [PATCH] net/bluetooth/hidp/sock.c: add CAP_NET_RAW check. Message-ID: <20200818113246.00001f5a@intel.com> In-Reply-To: <20200818082103.GA2692@oppo> References: <20200818082103.GA2692@oppo> X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: C6D6DA122C X-Rspamd-UID: 24759e On Tue, 18 Aug 2020 16:21:03 +0800 Qingyu Li <ieatmuttonchuan@gmail.com> wrote: > When creating a raw PF_BLUETOOTH socket, > CAP_NET_RAW needs to be checked first. > > Signed-off-by: Qingyu Li <ieatmuttonchuan@gmail.com> Please see my replies to your previous patches. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QEPuAZpUPF/qfAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:22:18 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +OY0AJpUPF90YgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:22:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EDCCA40813; Wed, 19 Aug 2020 00:22:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726810AbgHRWWM (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:22:12 -0400 Received: from mga11.intel.com ([192.55.52.93]:11540 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgHRWWK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:22:10 -0400 IronPort-SDR: 1MvmYClBNo3BUix5PZO0yBa8VRgvbNKJO9qLrrMVRtoAbc13WjNCMLW5Ho4prmiESQzJ+TA8Q3 Z55nvmUPMDDg== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="152634881" X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="152634881" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 15:22:09 -0700 IronPort-SDR: Jdcjc6bvwcySXLaDcnnQPXaLA53jNVFaXNsf95PByCDEI0SNE9AEV8/ysrfUl97LdQ2tCH9G3U a2zIal+yhD+g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="336764503" Received: from ypeng18-mobl.ger.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.230.245]) by orsmga007.jf.intel.com with ESMTP; 18 Aug 2020 15:22:09 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 1/2] mesh: Always set net modes based on node feature settings Date: Tue, 18 Aug 2020 15:22:07 -0700 Message-Id: <20200818222208.50938-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.70 / 15.00 / 200.00 X-Rspamd-Queue-Id: EDCCA40813 X-Rspamd-UID: 89f7ed The network settings such as relay, beacon, proxy and friend are always set based on local node feature settings. This change makes the net modes intialization unconditional, to include the "No Support" setting on node level which should result in the disabled mode in net.c --- mesh/node.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/mesh/node.c b/mesh/node.c index 1eeffeb8b..ebc111a62 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -399,24 +399,16 @@ static bool init_storage_dir(struct mesh_node *node) static void update_net_settings(struct mesh_node *node) { - uint8_t mode; + struct mesh_net *net = node->net; - mode = node->proxy; - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_proxy_mode(node->net, mode == MESH_MODE_ENABLED); + mesh_net_set_proxy_mode(net, node->proxy == MESH_MODE_ENABLED); - mode = node->friend; - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_friend_mode(node->net, mode == MESH_MODE_ENABLED); + mesh_net_set_friend_mode(net, node->friend == MESH_MODE_ENABLED); - mode = node->relay.mode; - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_relay_mode(node->net, mode == MESH_MODE_ENABLED, + mesh_net_set_relay_mode(net, node->relay.mode == MESH_MODE_ENABLED, node->relay.cnt, node->relay.interval); - mode = node->beacon; - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_beacon_mode(node->net, mode == MESH_MODE_ENABLED); + mesh_net_set_beacon_mode(net, node->beacon == MESH_MODE_ENABLED); } static bool init_from_storage(struct mesh_config_node *db_node, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QFiCCJ9UPF/qfAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:22:23 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8FcpB59UPF+CAQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:22:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 24EFD420B7; Wed, 19 Aug 2020 00:22:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726826AbgHRWWM (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:22:12 -0400 Received: from mga11.intel.com ([192.55.52.93]:11540 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbgHRWWL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:22:11 -0400 IronPort-SDR: aMZj5JUY3UsC/2JfIlu8ibibpx9T+ayS7VtzfdlNiu7zXs7k6arY0bbvP6ey0XzeXUzTc7O8SS SS1QH/IAqt1g== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="152634886" X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="152634886" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 15:22:10 -0700 IronPort-SDR: AiLF9XTtW+fawC+lhHeGYU2SJTHh3Ocy8weAUQD4AO9JTxWgmfCJBLul3D9uZRB2DcYn6yTEaD 9Bv9UQC3a8sA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="336764509" Received: from ypeng18-mobl.ger.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.230.245]) by orsmga007.jf.intel.com with ESMTP; 18 Aug 2020 15:22:10 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 2/2] mesh: Check for enabled modes when dst is fixed address Date: Tue, 18 Aug 2020 15:22:08 -0700 Message-Id: <20200818222208.50938-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818222208.50938-1-inga.stotland@intel.com> References: <20200818222208.50938-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.70 / 15.00 / 200.00 X-Rspamd-Queue-Id: 24EFD420B7 X-Rspamd-UID: 9137dd This moves the check for incoming messages addressed to fixed addresses, e.g. RELAY, PROXY, FRIEND. If the corresponding feature is not enabled, the message is not processed. --- mesh/model.c | 21 --------------------- mesh/net.c | 9 +++++++++ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/mesh/model.c b/mesh/model.c index 961391f13..b44e2f669 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -937,27 +937,6 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, if (!num_ele || IS_UNASSIGNED(addr)) goto done; - /* - * In case of fixed group addresses check if the - * corresponding mode is enabled. - */ - if (dst == PROXIES_ADDRESS && - (node_proxy_mode_get(node) != MESH_MODE_ENABLED)) - goto done; - - if (dst == FRIENDS_ADDRESS && - (node_friend_mode_get(node) != MESH_MODE_ENABLED)) - goto done; - - if (dst == RELAYS_ADDRESS) { - uint8_t cnt; - uint16_t interval; - - if (node_relay_mode_get(node, &cnt, &interval) != - MESH_MODE_ENABLED) - goto done; - } - is_subscription = !(IS_UNICAST(dst)); for (i = 0; i < num_ele; i++) { diff --git a/mesh/net.c b/mesh/net.c index 26440b02d..115a76944 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -1658,6 +1658,15 @@ static bool msg_rxed(struct mesh_net *net, bool frnd, uint32_t iv_index, } not_for_friend: + if (dst == FRIENDS_ADDRESS && !net->friend_enable) + return false; + + if (dst == RELAYS_ADDRESS && !net->relay.enable) + return false; + + if (dst == PROXIES_ADDRESS && !net->proxy_enable) + return false; + return mesh_model_rx(net->node, szmic, seqAuth, seq, iv_index, net_idx, src, dst, key_aid, data, size); } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GET4KPFVPF/qfAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:28:01 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id aDH+JvFVPF+/LQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:28:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E0AEAA010F; Wed, 19 Aug 2020 00:27:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726963AbgHRW1u (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbgHRW1t (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:27:49 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9857DC061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:27:49 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id ha11so186792pjb.1 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KsHmEUXwiQyn5utGyEsVoXWZuKrts5eX54vDNQPsdd4=; b=T+Dhckw0Jxs03Z5Rn4qkNswc8C6ERDbn/tx5rkXCcizj2XnLuufLIvrg4vSfHN6bz+ zcAAfsLjhWYRULYmBlMeRzHmAlwy3R3hULRb74r0XPqh05bUAekEgPXm7RaK7MzFdUrB 26Ak5OlIX8znjbodxiqfztN2NlghAus6EqKYI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KsHmEUXwiQyn5utGyEsVoXWZuKrts5eX54vDNQPsdd4=; b=L3S6NjT/+fs39h+4N3npt8WjcU4Bei1lZd4EpHOdbOK7D78BPQywoMgXqI1gPZ3JQm XXbQlyBZUhGWH/r6dSHn8L2KuWJHecZDfKZMNzBhAzTxU9iQsfKz337hu1gLF8XTes/n 1mt66eLUlAS5+efDKn3EPZBYw8cWIkF1ysObXL8HH8GHSWnJZeB0T1laI/ki/4e0+eHr SWvNMdZ/Dp4FQwIAATnz2uFzc6EbVsAa1aWc2AWTFZLaC6TziGMH+ZfxXTO35zYfHw+a xUuKmmgXotLb7P+rEgaGNaEr3CPay5TM9AT+jwfRnBpCpxmg9zGifL9muYxr537p2bud mEpQ== X-Gm-Message-State: AOAM531K4LLksX2fYEOj8icmWuBFTdYcGW0Y4gHSH0DCj2TGJvIkk0jp wHM+0Oq1HgXlxVmwUqxGyVPHVoc66uKS+Q== X-Google-Smtp-Source: ABdhPJwZZwCua3mViDmCIKqsJa1pIqXVd5lv66RM0icnNYHOdIBO+Xq7GuEiB77XwrXLheq7ANkGfw== X-Received: by 2002:a17:902:16a:: with SMTP id 97mr16976203plb.207.1597789667672; Tue, 18 Aug 2020 15:27:47 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id mp3sm14137286pjb.0.2020.08.18.15.27.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2020 15:27:46 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v1 1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Date: Tue, 18 Aug 2020 15:26:35 -0700 Message-Id: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: E0AEAA010F X-Rspamd-UID: 555576 This introduces the org.bluez.AdvertisementMonitorManager1 without implementing handlers of methods and properties. The following test was performed. - Upon adapter registration, the info line of creating an ADV monitor manager gets printed, and system bus emits the interface events of org.bluez.AdvertisementMonitorManager1. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Makefile.am | 3 +- src/adapter.c | 14 +++++ src/adapter.h | 3 + src/adv_monitor.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++ src/adv_monitor.h | 32 ++++++++++ 5 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 src/adv_monitor.c create mode 100644 src/adv_monitor.h diff --git a/Makefile.am b/Makefile.am index 7719c06f8..b14ee950e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -293,7 +293,8 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ src/gatt-client.h src/gatt-client.c \ src/device.h src/device.c \ src/dbus-common.c src/dbus-common.h \ - src/eir.h src/eir.c + src/eir.h src/eir.c \ + src/adv_monitor.h src/adv_monitor.c src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ gdbus/libgdbus-internal.la \ src/libshared-glib.la \ diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..41e9de286 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -77,6 +77,7 @@ #include "attrib-server.h" #include "gatt-database.h" #include "advertising.h" +#include "adv_monitor.h" #include "eir.h" #define ADAPTER_INTERFACE "org.bluez.Adapter1" @@ -272,6 +273,8 @@ struct btd_adapter { struct btd_gatt_database *database; struct btd_adv_manager *adv_manager; + struct btd_adv_monitor_manager *adv_monitor_manager; + gboolean initialized; GSList *pin_callbacks; @@ -6346,6 +6349,9 @@ static void adapter_remove(struct btd_adapter *adapter) btd_adv_manager_destroy(adapter->adv_manager); adapter->adv_manager = NULL; + btd_adv_monitor_manager_destroy(adapter->adv_monitor_manager); + adapter->adv_monitor_manager = NULL; + g_slist_free(adapter->pin_callbacks); adapter->pin_callbacks = NULL; @@ -8623,6 +8629,14 @@ static int adapter_register(struct btd_adapter *adapter) adapter->adv_manager = btd_adv_manager_new(adapter, adapter->mgmt); + adapter->adv_monitor_manager = btd_adv_monitor_manager_create( + adapter, adapter->mgmt); + if (!adapter->adv_monitor_manager) { + btd_error(adapter->dev_id, + "Failed to create Adv Monitor Manager for adapter"); + return -EINVAL; + } + db = btd_gatt_database_get_db(adapter->database); adapter->db_id = gatt_db_register(db, services_modified, services_modified, diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..5cb467141 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -26,6 +26,9 @@ #include <dbus/dbus.h> #include <glib.h> +#include "lib/bluetooth.h" +#include "lib/sdp.h" + #define MAX_NAME_LENGTH 248 /* Invalid SSP passkey value used to indicate negative replies */ diff --git a/src/adv_monitor.c b/src/adv_monitor.c new file mode 100644 index 000000000..7044d3cca --- /dev/null +++ b/src/adv_monitor.c @@ -0,0 +1,149 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdint.h> + +#include <glib.h> +#include <dbus/dbus.h> +#include <gdbus/gdbus.h> + +#include "adapter.h" +#include "dbus-common.h" +#include "log.h" +#include "src/shared/mgmt.h" + +#include "adv_monitor.h" + +#define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" + +struct btd_adv_monitor_manager { + struct btd_adapter *adapter; + struct mgmt *mgmt; + uint16_t adapter_id; + char *path; +}; + +static const GDBusMethodTable adv_monitor_methods[] = { + { GDBUS_METHOD("RegisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { GDBUS_ASYNC_METHOD("UnregisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { } +}; + +static const GDBusPropertyTable adv_monitor_properties[] = { + {"SupportedMonitorTypes", "as", NULL, NULL, NULL}, + {"SupportedFeatures", "as", NULL, NULL, NULL}, + { } +}; + +/* Allocates a manager object */ +static struct btd_adv_monitor_manager *manager_new( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + if (!adapter || !mgmt) + return NULL; + + manager = g_new0(struct btd_adv_monitor_manager, 1); + if (!manager) + return NULL; + + manager->adapter = adapter; + manager->mgmt = mgmt_ref(mgmt); + manager->adapter_id = btd_adapter_get_index(adapter); + manager->path = g_strdup(adapter_get_path(manager->adapter)); + + return manager; +} + +/* Frees a manager object */ +static void manager_free(struct btd_adv_monitor_manager *manager) +{ + manager->adapter = NULL; + mgmt_unref(manager->mgmt); + manager->mgmt = NULL; + g_free(manager->path); + manager->path = NULL; + + g_free(manager); +} + +/* Destroys a manager object and unregisters its D-Bus interface */ +static void manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + g_dbus_unregister_interface(btd_get_dbus_connection(), + manager->path, + ADV_MONITOR_MGR_INTERFACE); + + manager_free(manager); +} + +/* Creates a manager and registers its D-Bus interface */ +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + manager = manager_new(adapter, mgmt); + if (!manager) + return NULL; + + if (g_dbus_register_interface(btd_get_dbus_connection(), manager->path, + ADV_MONITOR_MGR_INTERFACE, + adv_monitor_methods, NULL, + adv_monitor_properties, manager, NULL) + == FALSE) { + btd_error(manager->adapter_id, + "Failed to register " + ADV_MONITOR_MGR_INTERFACE); + manager_free(manager); + return NULL; + } + + btd_info(manager->adapter_id, + "Adv Monitor Manager created for adapter %s", + adapter_get_path(manager->adapter)); + + return manager; +} + +/* Destroys a manager and unregisters its D-Bus interface */ +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + btd_info(manager->adapter_id, "Destroy Adv Monitor Manager"); + + manager_destroy(manager); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h new file mode 100644 index 000000000..69ea348f8 --- /dev/null +++ b/src/adv_monitor.h @@ -0,0 +1,32 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifndef __ADV_MONITOR_H +#define __ADV_MONITOR_H + +struct mgmt; +struct btd_adapter; +struct btd_adv_monitor_manager; + +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt); +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); + +#endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uPClLtZbPF8DmgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:53:10 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id yFSfKtZbPF+/LQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:53:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9ABC9420D1; Wed, 19 Aug 2020 00:53:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727013AbgHRWxF (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:53:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbgHRWxE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:53:04 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE43BC061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:53:03 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id x12so16477574qtp.1 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=w0Pl0CMcn8lEqI4RTOD0WCr2ZYgpItdGmyjIIKw3hds=; b=dQNYBu1z0oBEJIzACOLNOP0DMlz1QIuQ3PjBGJeMlIxIdCzMezB5K7PK97M9yJtlK/ RHS15O3zNhreTfCcKbZt/VwiyC6j/N14cBJZWLHexg9soUZC6BzTt16sx2ciMIAeVdgW B7eDHlNg8RSNUTDmNkZlHpIa77uG8P+sKDylDxqp49C0RGrVGSd9xhepwLYi+JUOnUnX tDDUNk2l1GyF9SIX3WJOjDoERUgR1MIXcguoS9SSH7mZc3a6CznXtJ6yLvc1TwiGWaii thbeztC0ZpVaigQVXCqeGstEZJRv+ayA3ASbKrFGimuFWI2vovO7TzakjmGa23sWY5vm Y0MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=w0Pl0CMcn8lEqI4RTOD0WCr2ZYgpItdGmyjIIKw3hds=; b=G/nZPZMOWbnxs0ZyYRp6eE77qR3zxSQwOIZPu0vmOxoJWSL0QgoFWU2vLBREV5tHPr u6zCOqKz21ol0sxVZIbLQ6gy4bqcNLtzg9xQWibb0rU9VK6JsM2WAK+kSTAksKvKie9h kmCon9xMtkE84fX76i6wGcJybo+e1FPEeNPQCbyGmUGssLHl6J4Csw9BfzSq2n9t0YaU +Kxh+jRu4OGt0cHXcuu7hcDeyq5jEoEEp1z+M5iGJZPmd+V/sJ5txHZU8KQRkCI4n1TF 4yXxXsWp2MCEsyQ5zsn6llSXOv5bTR/B9wOq9ISNiKAFTXsbD4mKGozzWorIW56HcDzF p0FA== X-Gm-Message-State: AOAM531iMbD7huohiRsa1qhB0dZbq7idugtTfaxDzw4bmr21BIMf5J6e Hn+5bZn0ko8WE23jxt885OPB2qfQTeKpaA== X-Google-Smtp-Source: ABdhPJzhXtyYVHEftwdFYqAUNQWf20+Y4FGGDZGh2IdEHCrKjizhi2v2+Mjrk+JQjyUkxhZ209JqhA== X-Received: by 2002:ac8:7650:: with SMTP id i16mr19827711qtr.215.1597791182794; Tue, 18 Aug 2020 15:53:02 -0700 (PDT) Received: from [172.17.0.2] ([52.251.53.181]) by smtp.gmail.com with ESMTPSA id 3sm22960673qkm.117.2020.08.18.15.53.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 15:53:02 -0700 (PDT) Message-ID: <5f3c5bce.1c69fb81.89999.eda0@mx.google.com> Date: Tue, 18 Aug 2020 15:53:02 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============0553159514088848311==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v1,1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ****** X-Rspamd-Score: 8.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9ABC9420D1 X-Rspamd-UID: 5c77c1 --===============0553159514088848311== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnNyYy9hZHZfbW9uaXRvci5jOjk4OjE2OiBlcnJvcjog4oCYQlRfQURf TUFYX0RBVEFfTEVO4oCZIHVuZGVjbGFyZWQgaGVyZSAobm90IGluIGEgZnVuY3Rpb24pCiAgIDk4 IHwgIHVpbnQ4X3QgdmFsdWVbQlRfQURfTUFYX0RBVEFfTEVOXTsKICAgICAgfCAgICAgICAgICAg ICAgICBefn5+fn5+fn5+fn5+fn5+fn4Kc3JjL2Fkdl9tb25pdG9yLmM6IEluIGZ1bmN0aW9uIOKA mG1vbml0b3JfbWF0Y2jigJk6CnNyYy9hZHZfbW9uaXRvci5jOjI4NDozNTogZXJyb3I6IHBhc3Np bmcgYXJndW1lbnQgMSBvZiDigJhnX2RidXNfcHJveHlfZ2V0X3BhdGjigJkgZGlzY2FyZHMg4oCY Y29uc3TigJkgcXVhbGlmaWVyIGZyb20gcG9pbnRlciB0YXJnZXQgdHlwZSBbLVdlcnJvcj1kaXNj YXJkZWQtcXVhbGlmaWVyc10KICAyODQgfCAgaWYgKHN0cmNtcChnX2RidXNfcHJveHlfZ2V0X3Bh dGgocHJveHkpLCBtb25pdG9yLT5wYXRoKSAhPSAwKQogICAgICB8ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICBefn5+fgpJbiBmaWxlIGluY2x1ZGVkIGZyb20gc3JjL2Fkdl9tb25p dG9yLmM6MzE6Ci4vZ2RidXMvZ2RidXMuaDozMzY6MTM6IG5vdGU6IGV4cGVjdGVkIOKAmEdEQnVz UHJveHkgKuKAmSB7YWthIOKAmHN0cnVjdCBHREJ1c1Byb3h5ICrigJl9IGJ1dCBhcmd1bWVudCBp cyBvZiB0eXBlIOKAmGNvbnN0IEdEQnVzUHJveHkgKuKAmSB7YWthIOKAmGNvbnN0IHN0cnVjdCBH REJ1c1Byb3h5ICrigJl9CiAgMzM2IHwgY29uc3QgY2hhciAqZ19kYnVzX3Byb3h5X2dldF9wYXRo KEdEQnVzUHJveHkgKnByb3h5KTsKICAgICAgfCAgICAgICAgICAgICBefn5+fn5+fn5+fn5+fn5+ fn5+fn4Kc3JjL2Fkdl9tb25pdG9yLmM6IEluIGZ1bmN0aW9uIOKAmHBhcnNlX3BhdHRlcm5z4oCZ OgpzcmMvYWR2X21vbml0b3IuYzo0OTM6MzY6IGVycm9yOiBzdWdnZXN0IHBhcmVudGhlc2VzIGFy b3VuZCDigJgmJuKAmSB3aXRoaW4g4oCYfHzigJkgWy1XZXJyb3I9cGFyZW50aGVzZXNdCiAgNDkz IHwgICBpZiAoYWRfdHlwZSA+IEJUX0FEXzNEX0lORk9fREFUQSAmJgpzcmMvYWR2X21vbml0b3Iu Yzo0MzM6MTE6IGVycm9yOiB1bnVzZWQgdmFyaWFibGUg4oCYbnVtX3BhdHRlcm5z4oCZIFstV2Vy cm9yPXVudXNlZC12YXJpYWJsZV0KICA0MzMgfCAgdWludDE2X3QgbnVtX3BhdHRlcm5zID0gMDsK ICAgICAgfCAgICAgICAgICAgXn5+fn5+fn5+fn5+CnNyYy9hZHZfbW9uaXRvci5jOiBJbiBmdW5j dGlvbiDigJhnZXRfc3VwcG9ydGVkX21vbml0b3JfdHlwZXPigJk6CnNyYy9hZHZfbW9uaXRvci5j Ojc2MTozNDogZXJyb3I6IHVudXNlZCB2YXJpYWJsZSDigJhtYW5hZ2Vy4oCZIFstV2Vycm9yPXVu dXNlZC12YXJpYWJsZV0KICA3NjEgfCAgc3RydWN0IGJ0ZF9hZHZfbW9uaXRvcl9tYW5hZ2VyICpt YW5hZ2VyID0gZGF0YTsKICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBe fn5+fn5+CmNjMTogYWxsIHdhcm5pbmdzIGJlaW5nIHRyZWF0ZWQgYXMgZXJyb3JzCm1ha2VbMV06 ICoqKiBbTWFrZWZpbGU6OTI3Mjogc3JjL2JsdWV0b290aGQtYWR2X21vbml0b3Iub10gRXJyb3Ig MQptYWtlOiAqKiogW01ha2VmaWxlOjQwMTQ6IGFsbF0gRXJyb3IgMgoKCgotLS0KUmVnYXJkcywK TGludXggQmx1ZXRvb3RoCg== --===============0553159514088848311==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gAJFC9xbPF8lhwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:53:16 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aMGaCdxbPF/UcQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:53:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A6F7D420C2; Wed, 19 Aug 2020 00:53:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727021AbgHRWxF convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:53:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:60046 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726992AbgHRWxF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:53:05 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Tue, 18 Aug 2020 22:53:02 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: swyterzone@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-7Fy24nzPBK@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: A6F7D420C2 X-Rspamd-UID: b93e30 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #137 from Swyter (swyterzone@gmail.com) --- Hi! There's actually a script that should help with this, at least as reference: https://gist.github.com/nevack/6b36b82d715dc025163d9e9124840a07 It's for newer kernels, though. So while the btusb.c part should more or less apply cleanly (because the existing/original CSR workaround stuff has been there for a while) the ERR_DATA_REPORTING stuff (on hci_core.c) is new and will need to be stripped out when back-porting the patch. Who knows, maybe it's a good idea to ask someone from Canonical to add it to Ubuntu, once it's been more battle-tested. Hopefully (as it officially gets into stable kernels) distros downstream will pick this up, even on super old Linux versions. Hope that helps. :) -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qGtpCgxWPF/qfAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:28:28 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +KSMCAxWPF+PPAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:28:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A4563A1035; Wed, 19 Aug 2020 00:28:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726863AbgHRW2V (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:28:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgHRW2T (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:28:19 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0EE9C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:28:19 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id mt12so185013pjb.4 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:28:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vKJ+f/QmyMYNU6dao3M/rrJbJatyE8JsrAuSYL+1TOQ=; b=Sx1sJ4D/Jj+OxwB14Esl7d7y4DFtoFs/Dqdf9infowX8dkY6nEsM+egVf5HAH2vw2v aV46lwbw5fJQIdF+U9g1LWjCIT9eY/m5+TjTnwXX5ZaX8EeDjGaXqXAbVrZtnx+AvmDM usHMbCC/r7oQX5PZiB+TkrHoL2ofLksjtw3GI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vKJ+f/QmyMYNU6dao3M/rrJbJatyE8JsrAuSYL+1TOQ=; b=DLHp0iPXgIORaEN2cH8aOGY+yxYQYEb8Ba8X9N8bSILQJ7Fd0p2/yaWQGpBMRsROet syY/pNrDxUsCgbg4+HRIuEL46VUWJDYBCtUXRGGVT5FzlxjOFKKPy3C6jWw0c07bCfAO HTAj4dMwQoufVQ2mfI+U7J2z74aP8Kdo6HpAJyd0GyCfXikdKM+F2kBJMDUpQ+rtxq4n 3qBeh3qO0Ol7+y+O08tj10YVBmiHAVhPVdifKo7vGywrxyr8xLUzvSyrzeP/bjSoLFEZ jUfH5jvVjxHueKKw/5Vtge1C1Jsf3p8ppr1Csx302RmGDpKqxo6Q0bB9nARU73iFVtGT 3QPw== X-Gm-Message-State: AOAM531KThShjQDxW/bvWS6bWQ+lISjw8BCVjX1/hJWsmra/7NV+MBv/ PU2Mi+lFOyuSh0YtMQkjUH7EHR4rz414mQ== X-Google-Smtp-Source: ABdhPJzkH+85uFFfO7XW7FzfEsmR/amlr1Dbh1aDkPzdkKTJ61ghfRYbiuHqdGExKzQ+P82lxYGKsA== X-Received: by 2002:a17:90b:2388:: with SMTP id mr8mr1780184pjb.64.1597789698910; Tue, 18 Aug 2020 15:28:18 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id mp3sm14137286pjb.0.2020.08.18.15.28.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2020 15:28:18 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v1 2/7] adv_monitor: Implement Get functions of ADV monitor manager properties Date: Tue, 18 Aug 2020 15:26:37 -0700 Message-Id: <20200818152612.BlueZ.v1.2.I9960e45d36be3edb5f17de025e7eb8257d3cddef@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.84 / 15.00 / 200.00 X-Rspamd-Queue-Id: A4563A1035 X-Rspamd-UID: 95be3a This implements the Get functions of SupportedMonitorTypes and SupportedFeatures. The following test was performed. - Issue dbus-send to read SupportedMonitorTypes and SupportedFeatures. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- src/adv_monitor.c | 130 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 125 insertions(+), 5 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 7044d3cca..4d02237e8 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -28,10 +28,14 @@ #include <dbus/dbus.h> #include <gdbus/gdbus.h> +#include "lib/bluetooth.h" +#include "lib/mgmt.h" + #include "adapter.h" #include "dbus-common.h" #include "log.h" #include "src/shared/mgmt.h" +#include "src/shared/util.h" #include "adv_monitor.h" @@ -42,6 +46,12 @@ struct btd_adv_monitor_manager { struct mgmt *mgmt; uint16_t adapter_id; char *path; + + uint32_t supported_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ + uint32_t enabled_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ + uint16_t max_num_monitors; + uint8_t max_num_patterns; + }; static const GDBusMethodTable adv_monitor_methods[] = { @@ -54,9 +64,78 @@ static const GDBusMethodTable adv_monitor_methods[] = { { } }; +enum monitor_type { + MONITOR_TYPE_OR_PATTERNS, +}; + +const struct adv_monitor_type { + enum monitor_type type; + const char *name; +} supported_types[] = { + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, + { }, +}; + +/* Gets SupportedMonitorTypes property */ +static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, + DBusMessageIter *iter, + void *data) +{ + DBusMessageIter entry; + const struct adv_monitor_type *t; + struct btd_adv_monitor_manager *manager = data; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, + &entry); + + for (t = supported_types; t->name; t++) { + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, + &t->name); + } + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + +const struct adv_monitor_feature { + uint32_t mask; + const char *name; +} supported_features[] = { + { MGMT_ADV_MONITOR_FEATURE_MASK_OR_PATTERNS, "controller-patterns" }, + { } +}; + +/* Gets SupportedFeatures property */ +static gboolean get_supported_features(const GDBusPropertyTable *property, + DBusMessageIter *iter, + void *data) +{ + DBusMessageIter entry; + const struct adv_monitor_feature *f; + struct btd_adv_monitor_manager *manager = data; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, + &entry); + + for (f = supported_features; f->name; f++) { + if (manager->supported_features & f->mask) { + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, + &f->name); + } + } + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + static const GDBusPropertyTable adv_monitor_properties[] = { - {"SupportedMonitorTypes", "as", NULL, NULL, NULL}, - {"SupportedFeatures", "as", NULL, NULL, NULL}, + {"SupportedMonitorTypes", "as", get_supported_monitor_types, NULL, + NULL}, + {"SupportedFeatures", "as", get_supported_features, NULL, NULL}, { } }; @@ -107,6 +186,42 @@ static void manager_destroy(struct btd_adv_monitor_manager *manager) manager_free(manager); } +/* Initiates manager's members based on the return of + * MGMT_OP_READ_ADV_MONITOR_FEATURES + */ +static void read_adv_monitor_features_cb(uint8_t status, uint16_t length, + const void *param, + void *user_data) +{ + const struct mgmt_rp_read_adv_monitor_features *rp = param; + struct btd_adv_monitor_manager *manager = user_data; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(manager->adapter_id, "Failed to Read Adv Monitor " + "Features with status 0x%02x", status); + return; + } + + if (length < sizeof(*rp)) { + btd_error(manager->adapter_id, + "Wrong size of Read Adv Monitor Features " + "response"); + return; + } + + manager->supported_features = le32_to_cpu(rp->supported_features); + manager->enabled_features = le32_to_cpu(rp->enabled_features); + manager->max_num_monitors = le16_to_cpu(rp->max_num_handles); + manager->max_num_patterns = rp->max_num_patterns; + + btd_info(manager->adapter_id, "Adv Monitor Manager created with " + "supported features:0x%08x, enabled features:0x%08x, " + "max number of supported monitors:%d, " + "max number of supported patterns:%d", + manager->supported_features, manager->enabled_features, + manager->max_num_monitors, manager->max_num_patterns); +} + /* Creates a manager and registers its D-Bus interface */ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct btd_adapter *adapter, @@ -130,9 +245,14 @@ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( return NULL; } - btd_info(manager->adapter_id, - "Adv Monitor Manager created for adapter %s", - adapter_get_path(manager->adapter)); + if (!mgmt_send(manager->mgmt, MGMT_OP_READ_ADV_MONITOR_FEATURES, + manager->adapter_id, 0, NULL, + read_adv_monitor_features_cb, manager, NULL)) { + btd_error(manager->adapter_id, + "Failed to send Read Adv Monitor Features"); + manager_destroy(manager); + return NULL; + } return manager; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gLXVMClWPF/qfAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:28:57 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UHBWLylWPF8JOQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:28:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7A188A112B; Wed, 19 Aug 2020 00:28:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726953AbgHRW2v (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726904AbgHRW2q (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:28:46 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 799F9C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:28:46 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id m8so10669719pfh.3 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qgBeGmDbDsXKMizmuz8IVmUgWVZ/TZRiqFyy/OXxz8s=; b=M2wOo2Q1mHEjVvDao3EM++9NBpBWmrrZUIMjULjk+35MUpnSKr14BDNguoviJvQYSy 5uEWwJGsLLs0HayNA5kAF5rL+/XCMlkpHbH777ZLE/JVSRhIo/XgVgoFRqAdiTxFD6Sd yhwyim8Ch0ToWrDbGzPf7Cw8V5V/UgK5jY8wM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qgBeGmDbDsXKMizmuz8IVmUgWVZ/TZRiqFyy/OXxz8s=; b=GKIcIeyW/eRn5QXjyf+gtf0TBTEFBZrLETHNSovuClFzNc7Ie7NthvxIMrz+nLtKje /0yhh27+r9PlRCo+OOooQQW73hZcCg6CSzMUqfZeNG03OTc3ECbTtN16bmycH4gPzVoU se/5GM7ZVE+zorP3n7qm5HPsIeefcTM+lw4WycSYnV/cCBYOavG1S4HJkeHwCpOb111L aUHLnUZppYuYdohmN49JL728DRyyomXNrbRcjEf5mNOdzzlqCdg80cOwbO8atEw19e5N 9abQvm5ESXqcM+piWGVVvHop3IbOUl43VgyVzzUc5/ZQDtZsCKAvmwRmmVsdKONAj2YA DMRw== X-Gm-Message-State: AOAM533Dcqt6ZzGas0IEle8spJ7tG1fWUkaweM7DyH/NV04gpBK8FIOS HzcUQgB3l9hYmhJBgsrWmrHIcJJ9wxvq2w== X-Google-Smtp-Source: ABdhPJyXIihR3jry8GPU/Zkk/ryEnuWI+RtmMjoc6tOzdYztyvKKOytYOnbyK7g2TILNNr08PbrhDg== X-Received: by 2002:aa7:8a4d:: with SMTP id n13mr17726102pfa.143.1597789725595; Tue, 18 Aug 2020 15:28:45 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id mp3sm14137286pjb.0.2020.08.18.15.28.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2020 15:28:44 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v1 3/7] adv_monitor: Implement RegisterMonitor() Date: Tue, 18 Aug 2020 15:26:39 -0700 Message-Id: <20200818152612.BlueZ.v1.3.I19ff9cdbd40fe453db0e81aec8bf94dd9490dce3@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.58 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7A188A112B X-Rspamd-UID: dafcbe This implements the RegisterMonitor() method handler of ADV monitor manager interface. The following tests were performed. - Issue a RegisterMonitor() call with a valid path and expect a success as return. - Issue a RegisterMonitor() call with an invalid path and expect org.bluez.Error.InvalidArguments as return. - Issue two Registermonitor() calls with the same path and expect org.bluez.Error.AlreadyExists. - Verify the values of the registered paths with logging. - Verify D-Bus disconnection callback was triggered when the client detach from D-Bus. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- src/adv_monitor.c | 167 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 4d02237e8..3d27ad18b 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -22,7 +22,9 @@ #endif #define _GNU_SOURCE +#include <errno.h> #include <stdint.h> +#include <string.h> #include <glib.h> #include <dbus/dbus.h> @@ -34,7 +36,9 @@ #include "adapter.h" #include "dbus-common.h" #include "log.h" +#include "src/error.h" #include "src/shared/mgmt.h" +#include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" @@ -52,12 +56,170 @@ struct btd_adv_monitor_manager { uint16_t max_num_monitors; uint8_t max_num_patterns; + struct queue *apps; /* apps who registered for Adv monitoring */ }; +struct adv_monitor_app { + struct btd_adv_monitor_manager *manager; + char *owner; + char *path; + + DBusMessage *reg; + GDBusClient *client; +}; + +struct app_match_data { + const char *owner; + const char *path; +}; + +/* Replies to an app's D-Bus message and unref it */ +static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) +{ + if (!app || !app->reg || !reply) + return; + + g_dbus_send_message(btd_get_dbus_connection(), reply); + dbus_message_unref(app->reg); + app->reg = NULL; +} + +/* Destroys an app object along with related D-Bus handlers */ +static void app_destroy(void *data) +{ + struct adv_monitor_app *app = data; + + if (!app) + return; + + DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); + + if (app->reg) { + app_reply_msg(app, btd_error_failed(app->reg, + "Adv Monitor app destroyed")); + } + + if (app->client) { + g_dbus_client_set_disconnect_watch(app->client, NULL, NULL); + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, + NULL); + g_dbus_client_set_ready_watch(app->client, NULL, NULL); + g_dbus_client_unref(app->client); + app->client = NULL; + } + + g_free(app->owner); + app->owner = NULL; + g_free(app->path); + app->path = NULL; + + g_free(app); +} + +/* Handles a D-Bus disconnection event of an app */ +static void app_disconnect_cb(DBusConnection *conn, void *user_data) +{ + struct adv_monitor_app *app = user_data; + + btd_info(app->manager->adapter_id, "Adv Monitor app %s disconnected " + "from D-Bus", app->owner); + if (app && queue_remove(app->manager->apps, app)) + app_destroy(app); +} + +/* Creates an app object, initiates it and sets D-Bus event handlers */ +static struct adv_monitor_app *app_create(DBusConnection *conn, + const char *sender, const char *path, + struct btd_adv_monitor_manager *manager) +{ + struct adv_monitor_app *app; + + if (!path || !sender || !manager) + return NULL; + + app = g_new0(struct adv_monitor_app, 1); + if (!app) + return NULL; + + app->owner = g_strdup(sender); + app->path = g_strdup(path); + app->manager = manager; + app->reg = NULL; + + app->client = g_dbus_client_new(conn, sender, path); + if (!app->client) { + app_destroy(app); + return NULL; + } + + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); + g_dbus_client_set_ready_watch(app->client, NULL, NULL); + + return app; +} + +/* Matches an app based on its owner and path */ +static bool app_match(const void *a, const void *b) +{ + const struct adv_monitor_app *app = a; + const struct app_match_data *match = b; + + if (match->owner && strcmp(app->owner, match->owner)) + return false; + + if (match->path && strcmp(app->path, match->path)) + return false; + + return true; +} + +/* Handles a RegisterMonitor D-Bus call */ +static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, + void *user_data) +{ + DBusMessageIter args; + struct app_match_data match; + struct adv_monitor_app *app; + struct btd_adv_monitor_manager *manager = user_data; + + if (!dbus_message_iter_init(msg, &args)) + return btd_error_invalid_args(msg); + + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) + return btd_error_invalid_args(msg); + + dbus_message_iter_get_basic(&args, &match.path); + + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) + return btd_error_invalid_args(msg); + + match.owner = dbus_message_get_sender(msg); + + if (queue_find(manager->apps, app_match, &match)) + return btd_error_already_exists(msg); + + app = app_create(conn, match.owner, match.path, manager); + if (!app) { + btd_error(manager->adapter_id, + "Failed to reserve %s for Adv Monitor app %s", + match.path, match.owner); + return btd_error_failed(msg, + "Failed to create Adv Monitor app"); + } + + queue_push_tail(manager->apps, app); + + btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", + match.path, match.owner); + + return dbus_message_new_method_return(msg); +} + static const GDBusMethodTable adv_monitor_methods[] = { { GDBUS_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), - NULL, NULL) }, + NULL, register_monitor) }, { GDBUS_ASYNC_METHOD("UnregisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, NULL) }, @@ -157,6 +319,7 @@ static struct btd_adv_monitor_manager *manager_new( manager->mgmt = mgmt_ref(mgmt); manager->adapter_id = btd_adapter_get_index(adapter); manager->path = g_strdup(adapter_get_path(manager->adapter)); + manager->apps = queue_new(); return manager; } @@ -170,6 +333,8 @@ static void manager_free(struct btd_adv_monitor_manager *manager) g_free(manager->path); manager->path = NULL; + queue_destroy(manager->apps, app_destroy); + g_free(manager); } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EB+iATpWPF/qfAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:29:14 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id OOSNADpWPF+DkwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:29:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 86269A11EC; Wed, 19 Aug 2020 00:29:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726863AbgHRW3G (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:29:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgHRW3F (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:29:05 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31521C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:29:05 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id mw10so185944pjb.2 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9kYl3apIlbG/g27MOuyrarzuC+I9/z+Glt//16VTKr8=; b=MDyr+hTKeHX+9bEbrFKqHv14MGjhH8fCV6ff+VCyP7KRYFehLvnlCcrSxQ5lWSUaEX hOBxlSUwQsx9glNzrysXWaOqjwxMTJv6UYml4Q0LZaehFcQx7SzxzmpkfDPNaKhFUi8C HB9L9Rs+yMU4AA7xFY5r5mL0KPFyO6FubWE3c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9kYl3apIlbG/g27MOuyrarzuC+I9/z+Glt//16VTKr8=; b=rYkmiCFXKyUvz1Vo2m4vzkEm0Yx89UouQm60ZbDDquH8JwO+ZU4R5HNeG00RnSZLSN ngnOOZm5NhUZpW943KV6idirC3TNhuGsick/tI9lijm8+1r4u0AJLt04vgA09fPqczV+ hlh/dn9O2c/fGjaQpWXdnyFh908P3zURQEdLQnxPsfIyOmOJo2HE8tpvBjnORcx0Bxy6 z+h6D/pyaJdIWvnhlEZ4TP22BYpQvZgaawE24zf4tdHA3PgJtSS1xDHJq+UD51nRyg0z XPMwMMQpohFzN/kdyw1smfTg8hUp6GaxbGqWcDpaCZejcHq9SehGi6Ly/Pqy4K/JuUdT muQQ== X-Gm-Message-State: AOAM530AoZ04qIUf166aEXV3GlM93UBTA8URtf89Vd3Q9+0GcOWJFKtq noUYfGyW3PeHfb1+A3I7HA5cNcpxmkOhxA== X-Google-Smtp-Source: ABdhPJxfO/DzC94MBjdQi5OaizMKSZfBmvdk2rjDc/in+NWXkACuuiVmURd7wCY4E/KQvwKn4cWI5w== X-Received: by 2002:a17:902:d907:: with SMTP id c7mr17367789plz.132.1597789744345; Tue, 18 Aug 2020 15:29:04 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id mp3sm14137286pjb.0.2020.08.18.15.29.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2020 15:29:03 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v1 4/7] adv_monitor: Implement UnregisterMonitor() Date: Tue, 18 Aug 2020 15:26:41 -0700 Message-Id: <20200818152612.BlueZ.v1.4.I335e42ab9a238261c2492c308ce77c959f631483@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.85 / 15.00 / 200.00 X-Rspamd-Queue-Id: 86269A11EC X-Rspamd-UID: d50a5a This implements the UnregisterMonitor() method handler of ADV monitor manager interface. The following tests were performed. - Issue a UnregisterMonitor() call with a nonexistent path and expect org.bluez.Error.DoesNotExist as the return. - Issue a UnregisterMonitor() call with a invalid path and expect org.bluez.Error.InvalidArguments as the return. - Issue RegisterMonitor() with a path, issue UnregisterMonitor() and expect a successful method call return. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- src/adv_monitor.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 3d27ad18b..a9e2e4421 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -216,13 +216,48 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, return dbus_message_new_method_return(msg); } +/* Handles UnregisterMonitor D-Bus call */ +static DBusMessage *unregister_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + DBusMessageIter args; + struct app_match_data match; + struct adv_monitor_app *app; + struct btd_adv_monitor_manager *manager = user_data; + + if (!dbus_message_iter_init(msg, &args)) + return btd_error_invalid_args(msg); + + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) + return btd_error_invalid_args(msg); + + dbus_message_iter_get_basic(&args, &match.path); + + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) + return btd_error_invalid_args(msg); + + match.owner = dbus_message_get_sender(msg); + + app = queue_find(manager->apps, app_match, &match); + if (!app) + return btd_error_does_not_exist(msg); + + queue_remove(manager->apps, app); + app_destroy(app); + + btd_info(manager->adapter_id, "Path %s removed along with Adv Monitor " + "app %s", match.path, match.owner); + + return dbus_message_new_method_return(msg); +} + static const GDBusMethodTable adv_monitor_methods[] = { { GDBUS_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, register_monitor) }, { GDBUS_ASYNC_METHOD("UnregisterMonitor", GDBUS_ARGS({ "application", "o" }), - NULL, NULL) }, + NULL, unregister_monitor) }, { } }; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yB4tAE1WPF8lhwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:29:33 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WEz+OUxWPF+CAQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:29:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D9662A11EC; Wed, 19 Aug 2020 00:29:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbgHRW31 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:29:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgHRW30 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:29:26 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7DF4C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:29:26 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id t11so9882448plr.5 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yuBC8ZYcilKT59d9GC2Zo6Yq4NAlJg5iM805qukCu2s=; b=ELIDr4kP+wC9QUKYuBrn4Uv9W0qWVVTjpIAbhWFRCxbM1Rzw1l3zgcB+jJ1Yg9c+op f6lQ5tRevzAfySjEBosnwkepZcekz8FhkxKHwg8NXoEQSPz3y5vfrq7mfWJ1ptjUvi28 gbhCQYEgePQXR+DCG1vBEBMoQP/rLZgIEX2Rk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yuBC8ZYcilKT59d9GC2Zo6Yq4NAlJg5iM805qukCu2s=; b=aYh3NOPLolkEnYmQKc1ZisSae0idSuug+RXAyIXhFe5iLADi32zE9xoQU/8A5sC5db tEpFngZOdScpZkffYGeG4dFdGSh4JlVoFz7Hb5g1dZSanO5lxkPAXC99jX/q94tCI1n1 3xk1Un6FcDtNh8/ux1Zh1kinnkCBVtVolWE4SNjKhtl0kiMk7q0f+q3IFayUtf0v+L+n zXxh0Sj+Gqgd/UF1YO6sOE++HApYqF7oRtTIIPHAb0W8OXBhCGjdmNko9/gQwJavnAYG jO60iD9kRWDVY+gxREPV9getmsdGg6Ip7YrXTO+0p3Wwc4Z5bzK1KsTx0DEGxmXVsaik Mk1g== X-Gm-Message-State: AOAM530k6K/Oy23WjO0avW88sMKx07IQhW0kr+2dVMQMWO/K5+20N7ld UBvSGSLSzESirXRbl8wi4QQh0mfccGxbEQ== X-Google-Smtp-Source: ABdhPJy0JTvg8ebWc+NNgtHD6tFUL7FJCCV+DjlzbKHgJBvw40rWOGYsX3K1uZslyeBpYhaS7ek1Zw== X-Received: by 2002:a17:902:43:: with SMTP id 61mr17599611pla.16.1597789764912; Tue, 18 Aug 2020 15:29:24 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id mp3sm14137286pjb.0.2020.08.18.15.29.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2020 15:29:23 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v1 5/7] adv_monitor: Handle D-Bus client ready events Date: Tue, 18 Aug 2020 15:26:43 -0700 Message-Id: <20200818152612.BlueZ.v1.5.Id5b1ced1530cb21559bc1dcf29d8764b0c7df825@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.35 / 15.00 / 200.00 X-Rspamd-Queue-Id: D9662A11EC X-Rspamd-UID: d96ec1 This adds a handler of client ready events. The handler replies to the RegisterMonitor() method call. The following tests were performed. - Call RegisterMonitor() and expect to receive a return. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- src/adv_monitor.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index a9e2e4421..b5ea5ee99 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -127,9 +127,22 @@ static void app_disconnect_cb(DBusConnection *conn, void *user_data) app_destroy(app); } +/* Handles the ready signal of Adv Monitor app */ +static void app_ready_cb(GDBusClient *client, void *user_data) +{ + struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + + btd_info(adapter_id, "Path %s reserved for Adv Monitor app %s", + app->path, app->owner); + + app_reply_msg(app, dbus_message_new_method_return(app->reg)); +} + /* Creates an app object, initiates it and sets D-Bus event handlers */ static struct adv_monitor_app *app_create(DBusConnection *conn, - const char *sender, const char *path, + DBusMessage *msg, const char *sender, + const char *path, struct btd_adv_monitor_manager *manager) { struct adv_monitor_app *app; @@ -154,7 +167,9 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); - g_dbus_client_set_ready_watch(app->client, NULL, NULL); + g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); + + app->reg = dbus_message_ref(msg); return app; } @@ -199,7 +214,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, if (queue_find(manager->apps, app_match, &match)) return btd_error_already_exists(msg); - app = app_create(conn, match.owner, match.path, manager); + app = app_create(conn, msg, match.owner, match.path, manager); if (!app) { btd_error(manager->adapter_id, "Failed to reserve %s for Adv Monitor app %s", @@ -210,10 +225,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, queue_push_tail(manager->apps, app); - btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", - match.path, match.owner); - - return dbus_message_new_method_return(msg); + return NULL; } /* Handles UnregisterMonitor D-Bus call */ @@ -252,7 +264,7 @@ static DBusMessage *unregister_monitor(DBusConnection *conn, } static const GDBusMethodTable adv_monitor_methods[] = { - { GDBUS_METHOD("RegisterMonitor", + { GDBUS_ASYNC_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, register_monitor) }, { GDBUS_ASYNC_METHOD("UnregisterMonitor", -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IN88LWVWPF/qfAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:29:57 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id oHXhK2VWPF+DkwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:29:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 06E20A1035; Wed, 19 Aug 2020 00:29:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726953AbgHRW3v (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:29:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgHRW3v (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:29:51 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA125C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:29:50 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id v16so278736plo.1 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YT0YyTUY4S26P5kQiqn3Ul4KARkxUh8IUNOUtiUr9Us=; b=nJt0hpSbwgTyd3FHCAWy/ueQC0EV/RG0DBiG9AHhtYVwvbEbkN62dV5WM6vahO6n0Q 1F52CgaY3B+Sc7CfyH/uzOg+LNhekio925wQHK9hpjqy2JXFzY01CK6o8Stjd4X9OnQT aCs4ZY3IOwDl2+ldD61V63IVCI+/RD+/UZlPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YT0YyTUY4S26P5kQiqn3Ul4KARkxUh8IUNOUtiUr9Us=; b=fe5i/blEDQLTIvmYqBjg1S9lbB7Yp7FelhoZWJbItLiOW9tmM+Of6wegrID4Y6MIEm PS5cupk/NnyigZlJrWEvYg52pUfoKPJk7ajMcUXD7BN5JgxDzj7mU/d5FihsMcV3U588 BPivmCppI35sepVFA6BS9LNhwx4TfL5F7deBCImr+g1V2z0uJKPgZX+lWPNcPycVoqal l2i8gFCuc+k6K2ec811Sa/HhrCX94ue9hYGQ2NrWKi9qbzVnndit+/G9tvCzeFYvghdQ nZBH1s3gnmh5eyIAC/7BZgKnwS2D6abAx2oQ2vGPe0xPp0K4+HHK+jvLtbtvJYcfUsLS /nBg== X-Gm-Message-State: AOAM5330fvwSoDmyRCU7QHA7A4nRH0iLVrvLgbDazaFupVh2J92kOSbI 9rCoeIHhXq7IfGIew5ICR48BGKto0JQkDQ== X-Google-Smtp-Source: ABdhPJyxhgu+gTIUE7ra1Fqyg/umHyBYbD521G3Fj2EAqEYrMT34HWAfH0rQGfFibujr5qjx4dt0HQ== X-Received: by 2002:a17:90a:ce97:: with SMTP id g23mr1719735pju.216.1597789788347; Tue, 18 Aug 2020 15:29:48 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id mp3sm14137286pjb.0.2020.08.18.15.29.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2020 15:29:47 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v1 6/7] adv_monitor: Handle D-Bus proxy event of an ADV monitor Date: Tue, 18 Aug 2020 15:26:45 -0700 Message-Id: <20200818152612.BlueZ.v1.6.I47744c7eef31f44cf393dea2b3e437d7b41cef79@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.09 / 15.00 / 200.00 X-Rspamd-Queue-Id: 06E20A1035 X-Rspamd-UID: 2feb1e This adds two handlers, one for adding and one for removing, of D-Bus proxy events. The handler of property changes is set to NULL as intended, since for simplicity no further changes on monitor's properties would affect the ongoing monitoring. The following test steps were performed with bluetoothctl. - After registering the root path, expose two monitors and verify that the proxy added event are received. - Have two monitors added, unexpose the monitors, and verify that the proxy removed events are received for those two monitors. - Have two monitors added, unregister the monitors and verify that the proxy removed events are received for those two monitors. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- src/adv_monitor.c | 492 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 479 insertions(+), 13 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index b5ea5ee99..23fbc2b45 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -37,14 +37,23 @@ #include "dbus-common.h" #include "log.h" #include "src/error.h" +#include "src/shared/ad.h" #include "src/shared/mgmt.h" #include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" +#define ADV_MONITOR_UNSET_RSSI 127 /* dBm */ +#define ADV_MONITOR_MAX_RSSI 20 /* dBm */ +#define ADV_MONITOR_MIN_RSSI -127 /* dBm */ +#define ADV_MONITOR_UNSET_TIMER 0 /* second */ +#define ADV_MONITOR_MIN_TIMER 1 /* second */ +#define ADV_MONITOR_MAX_TIMER 300 /* second */ + struct btd_adv_monitor_manager { struct btd_adapter *adapter; struct mgmt *mgmt; @@ -66,6 +75,43 @@ struct adv_monitor_app { DBusMessage *reg; GDBusClient *client; + + struct queue *monitors; +}; + +enum monitor_type { + MONITOR_TYPE_NONE, + MONITOR_TYPE_OR_PATTERNS, +}; + +enum monitor_state { + MONITOR_STATE_NEW, /* New but not yet init'ed with actual values */ + MONITOR_STATE_FAILED, /* Failed to be init'ed */ + MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ + MONITOR_STATE_HONORED, /* Accepted by kernel */ +}; + +struct pattern { + uint8_t ad_type; + uint8_t offset; + uint8_t length; + uint8_t value[BT_AD_MAX_DATA_LEN]; +}; + +struct adv_monitor { + struct adv_monitor_app *app; + GDBusProxy *proxy; + char *path; + + enum monitor_state state; /* MONITOR_STATE_* */ + + int8_t high_rssi; /* high RSSI threshold */ + uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ + int8_t low_rssi; /* low RSSI threshold */ + uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ + + enum monitor_type type; /* MONITOR_TYPE_* */ + struct queue *patterns; }; struct app_match_data { @@ -73,6 +119,14 @@ struct app_match_data { const char *path; }; +const struct adv_monitor_type { + enum monitor_type type; + const char *name; +} supported_types[] = { + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, + { }, +}; + /* Replies to an app's D-Bus message and unref it */ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) { @@ -84,6 +138,52 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) app->reg = NULL; } +/* Frees a pattern */ +static void pattern_free(void *data) +{ + struct pattern *pattern = data; + + if (!pattern) + return; + + g_free(pattern); +} + +/* Frees a monitor object */ +static void monitor_free(void *data) +{ + struct adv_monitor *monitor = data; + + if (!monitor) + return; + + monitor->app = NULL; + g_dbus_proxy_unref(monitor->proxy); + monitor->proxy = NULL; + g_free(monitor->path); + monitor->path = NULL; + + queue_destroy(monitor->patterns, pattern_free); + monitor->patterns = NULL; + + g_free(monitor); +} + +/* Calls Release() method of the remote Adv Monitor */ +static void monitor_release(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + + if (!monitor) + return; + + DBG("Calling Release() on Adv Monitor of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "Release", NULL, NULL, NULL, + NULL); +} + /* Destroys an app object along with related D-Bus handlers */ static void app_destroy(void *data) { @@ -94,6 +194,9 @@ static void app_destroy(void *data) DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); + queue_foreach(app->monitors, monitor_release, NULL); + queue_destroy(app->monitors, monitor_free); + if (app->reg) { app_reply_msg(app, btd_error_failed(app->reg, "Adv Monitor app destroyed")); @@ -139,6 +242,372 @@ static void app_ready_cb(GDBusClient *client, void *user_data) app_reply_msg(app, dbus_message_new_method_return(app->reg)); } +/* Allocates an Adv Monitor */ +static struct adv_monitor *monitor_new(struct adv_monitor_app *app, + GDBusProxy *proxy) +{ + struct adv_monitor *monitor; + + if (!app || !proxy) + return NULL; + + monitor = g_new0(struct adv_monitor, 1); + if (!monitor) + return NULL; + + monitor->app = app; + monitor->proxy = g_dbus_proxy_ref(proxy); + monitor->path = g_strdup(g_dbus_proxy_get_path(proxy)); + + monitor->state = MONITOR_STATE_NEW; + + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + + monitor->type = MONITOR_TYPE_NONE; + monitor->patterns = NULL; + + return monitor; +} + +/* Matches a monitor based on its D-Bus path */ +static bool monitor_match(const void *a, const void *b) +{ + const GDBusProxy *proxy = b; + const struct adv_monitor *monitor = a; + + if (!proxy || !monitor) + return false; + + if (strcmp(g_dbus_proxy_get_path(proxy), monitor->path) != 0) + return false; + + return true; +} + +/* Retrieves Type from the remote Adv Monitor object, verifies the value and + * update the local Adv Monitor + */ +static bool parse_monitor_type(struct adv_monitor *monitor, const char *path) +{ + DBusMessageIter iter; + const struct adv_monitor_type *t; + const char *type_str; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (!g_dbus_proxy_get_property(monitor->proxy, "Type", &iter)) { + btd_error(adapter_id, "Failed to retrieve property Type from " + "the Adv Monitor at path %s", path); + return false; + } + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + goto failed; + + dbus_message_iter_get_basic(&iter, &type_str); + + for (t = supported_types; t->name; t++) { + if (strcmp(t->name, type_str) == 0) { + monitor->type = t->type; + return true; + } + } + +failed: + btd_error(adapter_id, "Invalid argument of property Type of the Adv " + "Monitor at path %s", path); + + return false; +} + +/* Retrieves RSSIThresholdsAndTimers from the remote Adv Monitor object, + * verifies the values and update the local Adv Monitor + */ +static bool parse_rssi_and_timeout(struct adv_monitor *monitor, + const char *path) +{ + DBusMessageIter prop_struct, iter; + int16_t h_rssi, l_rssi; + uint16_t h_rssi_timer, l_rssi_timer; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + /* Property RSSIThresholdsAndTimers is optional */ + if (!g_dbus_proxy_get_property(monitor->proxy, + "RSSIThresholdsAndTimers", + &prop_struct)) { + DBG("Adv Monitor at path %s provides no RSSI thresholds and " + "timeouts", path); + return true; + } + + if (dbus_message_iter_get_arg_type(&prop_struct) != DBUS_TYPE_STRUCT) + goto failed; + + dbus_message_iter_recurse(&prop_struct, &iter); + + /* Extract HighRSSIThreshold */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) + goto failed; + dbus_message_iter_get_basic(&iter, &h_rssi); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract HighRSSIThresholdTimer */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) + goto failed; + dbus_message_iter_get_basic(&iter, &h_rssi_timer); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract LowRSSIThreshold */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) + goto failed; + dbus_message_iter_get_basic(&iter, &l_rssi); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract LowRSSIThresholdTimer */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) + goto failed; + dbus_message_iter_get_basic(&iter, &l_rssi_timer); + + /* Verify the values of RSSIs and their timers. For simplicity, we + * enforce the all-or-none rule to these fields. In other words, either + * all are set to the unset values or all are set within valid ranges. + */ + if (h_rssi == ADV_MONITOR_UNSET_RSSI && + l_rssi == ADV_MONITOR_UNSET_RSSI && + h_rssi_timer == ADV_MONITOR_UNSET_TIMER && + l_rssi_timer == ADV_MONITOR_UNSET_TIMER) { + goto done; + } + + if (h_rssi < ADV_MONITOR_MIN_RSSI || h_rssi > ADV_MONITOR_MAX_RSSI || + l_rssi < ADV_MONITOR_MIN_RSSI || + l_rssi > ADV_MONITOR_MAX_RSSI || h_rssi <= l_rssi) { + goto failed; + } + + if (h_rssi_timer < ADV_MONITOR_MIN_TIMER || + h_rssi_timer > ADV_MONITOR_MAX_TIMER || + l_rssi_timer < ADV_MONITOR_MIN_TIMER || + l_rssi_timer > ADV_MONITOR_MAX_TIMER) { + goto failed; + } + + monitor->high_rssi = h_rssi; + monitor->low_rssi = l_rssi; + monitor->high_rssi_timeout = h_rssi_timer; + monitor->low_rssi_timeout = l_rssi_timer; + +done: + DBG("Adv Monitor at %s initiated with high RSSI threshold %d, high " + "RSSI threshold timeout %d, low RSSI threshold %d, low RSSI " + "threshold timeout %d", path, monitor->high_rssi, + monitor->high_rssi_timeout, monitor->low_rssi, + monitor->low_rssi_timeout); + + return true; + +failed: + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + + btd_error(adapter_id, "Invalid argument of property " + "RSSIThresholdsAndTimers of the Adv Monitor at path %s", + path); + + return false; +} + +/* Retrieves Patterns from the remote Adv Monitor object, verifies the values + * and update the local Adv Monitor + */ +static bool parse_patterns(struct adv_monitor *monitor, const char *path) +{ + DBusMessageIter array, array_iter; + uint16_t num_patterns = 0; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (!g_dbus_proxy_get_property(monitor->proxy, "Patterns", &array)) { + btd_error(adapter_id, "Failed to retrieve property Patterns " + "from the Adv Monitor at path %s", path); + return false; + } + + monitor->patterns = queue_new(); + + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY || + dbus_message_iter_get_element_type(&array) != + DBUS_TYPE_STRUCT) { + goto failed; + } + + dbus_message_iter_recurse(&array, &array_iter); + + while (dbus_message_iter_get_arg_type(&array_iter) == + DBUS_TYPE_STRUCT) { + int value_len; + uint8_t *value; + uint8_t offset, ad_type; + struct pattern *pattern; + DBusMessageIter struct_iter, value_iter; + + dbus_message_iter_recurse(&array_iter, &struct_iter); + + // Extract start position + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_BYTE) { + goto failed; + } + dbus_message_iter_get_basic(&struct_iter, &offset); + if (!dbus_message_iter_next(&struct_iter)) + goto failed; + + // Extract AD data type + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_BYTE) { + goto failed; + } + dbus_message_iter_get_basic(&struct_iter, &ad_type); + if (!dbus_message_iter_next(&struct_iter)) + goto failed; + + // Extract value of a pattern + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_ARRAY) { + goto failed; + } + dbus_message_iter_recurse(&struct_iter, &value_iter); + dbus_message_iter_get_fixed_array(&value_iter, &value, + &value_len); + + // Verify the values + if (offset > BT_AD_MAX_DATA_LEN - 1) + goto failed; + + if (ad_type > BT_AD_3D_INFO_DATA && + ad_type != BT_AD_MANUFACTURER_DATA + || ad_type < BT_AD_FLAGS) { + goto failed; + } + + if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) + goto failed; + + pattern = g_new0(struct pattern, 1); + if (!pattern) + goto failed; + + pattern->ad_type = ad_type; + pattern->offset = offset; + pattern->length = value_len; + g_memmove(pattern->value, value, pattern->length); + + queue_push_tail(monitor->patterns, pattern); + + dbus_message_iter_next(&array_iter); + } + + /* There must be at least one pattern. */ + if (queue_isempty(monitor->patterns)) + goto failed; + + return true; + +failed: + queue_destroy(monitor->patterns, pattern_free); + monitor->patterns = NULL; + + btd_error(adapter_id, "Invalid argument of property Patterns of the " + "Adv Monitor at path %s", path); + + return false; +} + +/* Processes the content of the remote Adv Monitor */ +static bool monitor_process(struct adv_monitor *monitor, + struct adv_monitor_app *app) +{ + const char *path = g_dbus_proxy_get_path(monitor->proxy); + + monitor->state = MONITOR_STATE_FAILED; + + if (!parse_monitor_type(monitor, path)) + goto done; + + if (!parse_rssi_and_timeout(monitor, path)) + goto done; + + if (monitor->type == MONITOR_TYPE_OR_PATTERNS && + parse_patterns(monitor, path)) { + monitor->state = MONITOR_STATE_INITED; + } + +done: + return monitor->state != MONITOR_STATE_FAILED; +} + +/* Handles an Adv Monitor D-Bus proxy added event */ +static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) +{ + struct adv_monitor *monitor; + struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + const char *path = g_dbus_proxy_get_path(proxy); + const char *iface = g_dbus_proxy_get_interface(proxy); + + if (strcmp(iface, ADV_MONITOR_INTERFACE) != 0 || + !g_str_has_prefix(path, app->path)) { + return; + } + + if (queue_find(app->monitors, monitor_match, proxy)) { + btd_error(adapter_id, "Adv Monitor proxy already exists with " + "path %s", path); + return; + } + + monitor = monitor_new(app, proxy); + if (!monitor) { + btd_error(adapter_id, "Failed to allocate an Adv Monitor for " + "the object at %s", path); + return; + } + + if (!monitor_process(monitor, app)) { + monitor_release(monitor, NULL); + monitor_free(monitor); + DBG("Adv Monitor at path %s released due to invalid content", + path); + return; + } + + queue_push_tail(app->monitors, monitor); + + DBG("Adv Monitor allocated for the object at path %s", path); +} + +/* Handles the removal of an Adv Monitor D-Bus proxy */ +static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) +{ + struct adv_monitor *monitor; + struct adv_monitor_app *app = user_data; + + monitor = queue_remove_if(app->monitors, monitor_match, proxy); + if (monitor) { + DBG("Adv Monitor removed for the object at path %s", + monitor->path); + + /* The object was gone, so we don't need to call Release() */ + monitor_free(monitor); + } +} + /* Creates an app object, initiates it and sets D-Bus event handlers */ static struct adv_monitor_app *app_create(DBusConnection *conn, DBusMessage *msg, const char *sender, @@ -165,8 +634,17 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, return NULL; } + app->monitors = queue_new(); + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); - g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); + + /* Note that any property changes on a monitor object would not affect + * the content of the corresponding monitor. + */ + g_dbus_client_set_proxy_handlers(app->client, monitor_proxy_added_cb, + monitor_proxy_removed_cb, NULL, + app); + g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); app->reg = dbus_message_ref(msg); @@ -273,18 +751,6 @@ static const GDBusMethodTable adv_monitor_methods[] = { { } }; -enum monitor_type { - MONITOR_TYPE_OR_PATTERNS, -}; - -const struct adv_monitor_type { - enum monitor_type type; - const char *name; -} supported_types[] = { - { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, - { }, -}; - /* Gets SupportedMonitorTypes property */ static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, DBusMessageIter *iter, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gNzNEdFWPF8lhwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:31:45 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 6MISENFWPF+nBwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:31:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A9939420C6; Wed, 19 Aug 2020 00:31:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726982AbgHRWbj (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726766AbgHRWbg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:31:36 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C18C3C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:31:36 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d188so10666012pfd.2 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zlvqf0NUFaWEm48IkgWk2VefD7B2sDw4UkatyR8sS4M=; b=Og4WU3idPrNBah+5oHG6lq3gGErO6ayxnp8JMMw5yJouuau6A6b8eYM1qJt/Cljg4z qwDMW1Lx9mq6pZDx/Z6zbFJrxWYTkEci6KEE24x+0K7aA4aASeQfdKs8x0GAIlBQJg8n dqXcyZphfgWnESFkCn2TnXPyOfDxFer6l3N4E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zlvqf0NUFaWEm48IkgWk2VefD7B2sDw4UkatyR8sS4M=; b=Ujy6SbqkaaObLyFzyIsV+8n0ThGtzvWSIpADHZcidXakKYFvl4BYQ3EOf/84pqDXub BP4r+3AWXS2kidOYswmZS7wT2NsTdtz4ap7IIykswhAyvPeIX9aSNuEAIxSegrArcm4s F4Zmun2DstKFatzUGZYBpJtOcKna+ZrNMJ1sFv91KtQO92dyCHVUTwpIKSy8I9JafpSG BMfgnDdmnQoK07H71cKrXVv5MpRmkJ0s7J+vPueTuUR/XRdVBiXocjZnVMkqn+tB1CRN efFJoixQzD6Lzcj3jusFBPtvURePcHCYWAgaiXYYW+GfBj8Dzi1/GJ7vQ8qjOWRNl9tv oa9Q== X-Gm-Message-State: AOAM5334PN0fZvnKaIrZPLZTHmFDi53C18REiozGlnWVmGEA64H4depW R9Lp46gKzmRCMQOPKhLU9lJTR6p6m2G6iw== X-Google-Smtp-Source: ABdhPJza4ZBSSzG1cmahVgzR81br3ediWZBIno7IgUWM9sSJsZ9iOBawNuJ6xQ7pzQ8T4RrMvI/B9Q== X-Received: by 2002:a65:6a55:: with SMTP id o21mr2016373pgu.64.1597789895904; Tue, 18 Aug 2020 15:31:35 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id mp3sm14137286pjb.0.2020.08.18.15.31.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2020 15:31:35 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v1 7/7] doc/advertisement-monitor-api: Update Advertisement Monitor API description Date: Tue, 18 Aug 2020 15:26:47 -0700 Message-Id: <20200818152612.BlueZ.v1.7.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: A9939420C6 X-Rspamd-UID: 42ca1a This modifies the following description to Advertisement Monitor API. - Add org.bluez.Error.Failed to RegisterMonitor() method. - Add more description about the usage of RegisterMonitor() and UnregisterMonitor() methods. - Add description about the ranges for the fields in property RSSIThresholdsAndTimers. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- doc/advertisement-monitor-api.txt | 34 +++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index 74adbfae9..e09b6fd25 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -49,7 +49,7 @@ Properties string Type [read-only] org.bluez.AdvertisementMonitorManager1 for the available options. - (Int16, Uint16, Int16, Uint16) RSSIThreshholdsAndTimers [read-only, optional] + (Int16, Uint16, Int16, Uint16) RSSIThresholdsAndTimers [read-only, optional] This contains HighRSSIThreshold, HighRSSIThresholdTimer, LowRSSIThreshold, LowRSSIThresholdTimer in order. The @@ -66,7 +66,11 @@ Properties string Type [read-only] RSSIs of the received advertisement(s) during LowRSSIThresholdTimer do not reach LowRSSIThreshold. - array{(uint8, uint8, string)} Patterns [read-only, optional] + The valid range of a RSSI is -127 to +20 dBm while 127 + dBm indicates unset. The valid range of a timer is 1 to + 300 seconds while 0 indicates unset. + + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] If Type is set to 0x01, this must exist and has at least one entry in the array. @@ -80,8 +84,9 @@ Properties string Type [read-only] See https://www.bluetooth.com/specifications/ assigned-numbers/generic-access-profile/ for the possible allowed value. - string content_of_pattern - This is the value of the pattern. + array{byte} content_of_pattern + This is the value of the pattern. The maximum + length of the bytes is 31. Advertisement Monitor Manager hierarchy ======================================= @@ -91,20 +96,31 @@ Object path /org/bluez/{hci0,hci1,...} Methods void RegisterMonitor(object application) - This registers a hierarchy of advertisement monitors. + This registers the root path of a hierarchy of + advertisement monitors. The application object path together with the D-Bus system bus connection ID define the identification of the application registering advertisement monitors. + Once a root path is registered by a client via this + method, the client can freely expose/unexpose + advertisement monitors without re-registering the root + path again. After use, the client should call + UnregisterMonitor() method to invalidate the + advertisement monitors. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.AlreadyExists + org.bluez.Error.Failed void UnregisterMonitor(object application) - This unregisters advertisement monitors that have been - previously registered. The object path parameter must - match the same value that has been used on - registration. + This unregisters a hierarchy of advertisement monitors + that has been previously registered. The object path + parameter must match the same value that has been used + on registration. Upon unregistration, the advertisement + monitor(s) should expect to receive Release() method as + the signal that the advertisement monitor(s) has been + deactivated. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.DoesNotExist -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kEp3IStbPF8DmgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:50:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id iED0HytbPF/wiAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:50:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F307F420D1; Wed, 19 Aug 2020 00:50:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726868AbgHRWuO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:50:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgHRWuK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:50:10 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B9CAC061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:50:10 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id 62so19927823qkj.7 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=sOhqtxXJj4yMvbecvs4HPsnjgHd4D3czM1kjOjNEj/0=; b=OrlmtQbsvfz7Qc7MFrwmFfQpNAUXUdFdl6DsWrCJ7PQpkf2DTV8oQ1S8EWdDs/pTY9 moPQRXb2uQC6YK+gfsdIJqEN1+BxqgxgPcYzZEU5odB2b0z63pP0+D/tq6okZX9PNYOh 0cxM4eBVNQWgVCe/nsrKnvgrKaDmvtMz5qyawJjUiclkDMD/RHH0AVa9FkARlsgviqAv iqx5PiGKxAuMZKNV4CmosbgZuInN0AiVUo138vkyaQGdXkS8sGPGEvzMehdByz9Ll1nG xbU8FuR1c5PKGM9FooWzMuPY2FsAw2qW9oOoccHiMed1DgV5kugGdbN82VEoqEw1+JeD xnug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=sOhqtxXJj4yMvbecvs4HPsnjgHd4D3czM1kjOjNEj/0=; b=FtXIiYod9jTW2t/tyw4XbcqaNEj18GoXGzN9yVFyxIWe2qjU/uSVJMJcGLGz39nTu8 4Cz/5kOil0lNPKJC06XFe4o5ewXiJ9iEf00zEk3rldwnyVWN8wmQrMA6IzAgqmgU2jGo OoishHXmrupA60nMP16ClQ2J7Yckg8HqCUP588Pu/WHtK65fus7AYQc/fiLmnoKqtgXX PBG4kHYv1uK1YNLzm2INGLGhivO27D3k+pW24QKuJ0X28qToQQeiCgYd867UmpOjNmm3 4+enADYhARFIH8xxMOFbZVi1j91IGeOo0cvpEwLmcJqvxS1vqEJvGw69U6XBrZ47QIeR 0iZQ== X-Gm-Message-State: AOAM531kHJ4iTUxl3BeoaH84r/2Y2ChqL9g4Il2td2wlCgifvhuVFvZz ERlGb4A4ZblVUGWju/Gq9jz/g1W2sGGgrg== X-Google-Smtp-Source: ABdhPJz3ZouduxAFvVeSzYDP9sIYiapD+iHa1CGxoNuhgSVj1MnwwGVWcdUtnl/i0AlbCBhDxwkeCQ== X-Received: by 2002:a37:a5c1:: with SMTP id o184mr18951545qke.323.1597791008204; Tue, 18 Aug 2020 15:50:08 -0700 (PDT) Received: from [172.17.0.2] ([40.70.46.103]) by smtp.gmail.com with ESMTPSA id q34sm26308706qtk.32.2020.08.18.15.50.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 15:50:07 -0700 (PDT) Message-ID: <5f3c5b1f.1c69fb81.49120.b764@mx.google.com> Date: Tue, 18 Aug 2020 15:50:07 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3994007261342680672==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, inga.stotland@intel.com Subject: RE: [BlueZ,1/2] mesh: Always set net modes based on node feature settings Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200818222208.50938-1-inga.stotland@intel.com> References: <20200818222208.50938-1-inga.stotland@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.98 / 15.00 / 200.00 X-Rspamd-Queue-Id: F307F420D1 X-Rspamd-UID: a04b6b --===============3994007261342680672== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:TYPO_SPELLING: 'intialization' may be misspelled - perhaps 'initialization'? #8: the net modes intialization unconditional, to include the "No Support" - total: 0 errors, 1 warnings, 29 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============3994007261342680672==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GLB7JTFbPF8DmgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:50:25 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id sNnyIzFbPF+DkwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:50:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 24BF340732; Wed, 19 Aug 2020 00:50:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726980AbgHRWuU (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:50:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgHRWuR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:50:17 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30181C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:50:17 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id n129so19936186qkd.6 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=CCPDV1hJpdSA2bIXqQHtDY/VDLkLLkoksM0uXPUalj0=; b=EvJJhgsHDyUf88k01+FA5SwYZdEeEC1hcCH39pThxFXEmlGtDIsFCiA0MbMO1YFYjX bVW3eAx8XN829uVY1QgE8PBQNax0Z3B8h3bX2NZHVwae0x9oj13Ze+RdyD9obMeQAs8i SpGzjMlTJwm+GVCcWXRGaf9d2/OSVPccayB5PpbWdcr1YjmrURUt/iZ7NMuZ9zvd9Q0F 1NS9gHClxqeIUdWNDfCi4Wo0nJrErr8Cd/17wz7ZB6NJZ50l3i1gZM0S2NB6SUECeM7h tlbjix5txka05YshYv2t6z7iam0Gn+kFtc5IMDb2pcEw/gDa03ikqp9bE8YYvTRRCH0G pcww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=CCPDV1hJpdSA2bIXqQHtDY/VDLkLLkoksM0uXPUalj0=; b=FOtnro7x4JtmG1nPEaP2iVdlYXZ9UEc/9RRUR3ZNpe7BOcJRZLP1KhC+hHkZYQiWGX 1ipo091o51m3W1bvwpQrVQBxqhrhHAZls6HDKr9+lYyYyEJE8+dCOoDc/ccEErNi+8eX 4wcOezvnokOn0mLzylXR8Nl/YoFbul1gVv7QfH2zEgV2mL2ygxJ9sIqiT0VhOXo+fxAy OPNcQTHuzmsii9ppHWAbVJoNJ2u/NZzzTpqWkqklgCrLV+gH8r0TBBF5ETBD5gpuvDEj ervsRH6efAP2URLVDjMx0eqW9fLJAxneh5umPnV2oFfVHQIpYSXdNLsaCqxJPI9vPJ9s YtNA== X-Gm-Message-State: AOAM533iXkKDpXk9gJsrNwY80tY9qVXTqbm8+ycUZXjnqPcdamKmbP1K GB8d+7iQNtI1w7E+tJlttfDFhYRXrCbcxQ== X-Google-Smtp-Source: ABdhPJz4+eDJABiuW3P2lYzPj1do/7jPFSCLU9z6IF6vfuUVLvHMgTidBg+EzJxdIwzNG/5hXfZPNA== X-Received: by 2002:a05:620a:a0b:: with SMTP id i11mr20015760qka.65.1597791015023; Tue, 18 Aug 2020 15:50:15 -0700 (PDT) Received: from [172.17.0.2] ([52.251.53.181]) by smtp.gmail.com with ESMTPSA id 7sm22677106qky.89.2020.08.18.15.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 15:50:14 -0700 (PDT) Message-ID: <5f3c5b26.1c69fb81.c0d25.dd5f@mx.google.com> Date: Tue, 18 Aug 2020 15:50:14 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3861455486647989601==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v1,1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ****** X-Rspamd-Score: 7.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: 24BF340732 X-Rspamd-UID: 17c04c --===============3861455486647989601== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #99: FILE: src/adv_monitor.c:1: +/* WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #254: FILE: src/adv_monitor.h:1: +/* - total: 0 errors, 2 warnings, 237 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============3861455486647989601==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YC/rIDlbPF8DmgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 00:50:33 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id EE0QHzlbPF9KRgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 00:50:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 194F440180; Wed, 19 Aug 2020 00:50:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727000AbgHRWu2 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 18:50:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbgHRWu2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 18:50:28 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E96B5C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:50:26 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id i20so5717927qkk.8 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 15:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=QNciXq1K04EUWNgTRLRsyw4jITsDyOiX1UyGmAA6u0w=; b=RtjwGElDX+E9fD+wN6kTQ/bSkcBZrP/jHbiULSwArQpmEdBBodnXaeKCQT4CNfU/an F2bB+5yr4mBmTSqese7laQyRQzrGsn05hb1rW6BR/SFyMXtmgV0bERYGfFq4koJI9okX DRLrOqPA3QmvCcWupbFYTnIfBD2n03sbeRJXlGRUJJUVQchzc0/UUBcW6oPVaofZB46s O4R4IhnR2ffGvi0ycehOq27ZLesAyr2SERadPI6/BbbG2SM4aBLwxpUsDD7M8WfJHTT+ w54ABFR8YPrZm72yjtKPAsskXuu4UTF3Q67bgTWPR90EcItsVqoljFfObApA8f38bBFN 6t2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=QNciXq1K04EUWNgTRLRsyw4jITsDyOiX1UyGmAA6u0w=; b=NoObDhR0KFz63GwUe45mR+Io6iOkDGj0pnrf0YhQOSt9pNcaPPLSsUAgok7RHzXLA6 f5Yer+Q2153JG1g6P0ztxtK/cB6BrRTeOcAC5f8rqbxuawp2s5DGmealzqLJLU2Yz3s/ QvOQJB3GddrnsaHtUmumAEtq7wd8GFdpop3hXg1Zp3gXNwrXECT+I313+QOYIKySm26x cX/TJ+FyBHXoqsAVuyNAlbBpTepVN3RYwE/GsH1pmpkv5WuE6vancmSqexAp/loxbERK s+0H8H2gPm2if+zXO+xFXppzBCUPUvsL3VHxClZA2ETgJdxsMMgFGzPint6tbbE6VJgE G7XA== X-Gm-Message-State: AOAM530rJ0V0k8l8WF3MUbJuR7F/0fjHGTnlFs4QzdF79/ExPG4T7H+A s/90G5AS8eVMymt7jq6//e/KE0nAzJnDvQ== X-Google-Smtp-Source: ABdhPJzlgpbW/7/L1rvJwg3D9JnvNzTrLnzPbXVuQkHRle5KKrTmzQVULiFkQXfy0ncQ+t3mbPlBpw== X-Received: by 2002:a37:9c58:: with SMTP id f85mr18284567qke.345.1597791025308; Tue, 18 Aug 2020 15:50:25 -0700 (PDT) Received: from [172.17.0.2] ([52.251.53.181]) by smtp.gmail.com with ESMTPSA id i7sm25191657qtb.27.2020.08.18.15.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 15:50:24 -0700 (PDT) Message-ID: <5f3c5b30.1c69fb81.6bc90.79ea@mx.google.com> Date: Tue, 18 Aug 2020 15:50:24 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============2803597289067355322==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v1,7/7] doc/advertisement-monitor-api: Update Advertisement Monitor API description Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200818152612.BlueZ.v1.7.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> References: <20200818152612.BlueZ.v1.7.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ****** X-Rspamd-Score: 7.70 / 15.00 / 200.00 X-Rspamd-Queue-Id: 194F440180 X-Rspamd-UID: 1a42d4 --===============2803597289067355322== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 1: T1 Title exceeds max length (75>72): "doc/advertisement-monitor-api: Update Advertisement Monitor API description" --- Regards, Linux Bluetooth --===============2803597289067355322==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0MhMKSdkPF+I6AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 01:28:39 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YB3EJydkPF/VeAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 01:28:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DAE67555F2; Wed, 19 Aug 2020 01:28:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726751AbgHRX2b (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 19:28:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726703AbgHRX23 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 19:28:29 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30648C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:28:29 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id m34so10457536pgl.11 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aejUMU5zSaqd7+wMdIKicjWFXZOWAZwkVCeBUjAPWDo=; b=WlylnxkI57Y1zTA6NXRygvE9ERDqhBsF2EY1i+DnVp6hopJ6eaEgBLEGqUxBbHuUVj 6PwdNpEJeekqjYyMxQZMrnptbVvKO/v7YQdhRe9Qdl6dSA/Aj6Rki2J0naWhuK7x3ey0 Vieu5cpDuS93RHmGP+T8JC0AxeUruh/FkBcu0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aejUMU5zSaqd7+wMdIKicjWFXZOWAZwkVCeBUjAPWDo=; b=HydFy3tn48PjeqTyQ5YdpYxBoPLi2iruaxIsPCXdjKWvwu/Tho16+PAwDB2cBjY/oI 0QGihD7rX2mZoFgEZq2rJRYT9nSE2dbNPnbdD1aYNyVhQOa2mYfZpkS5jTikjwmnC/ih teP7PMvin0RMpWpBolqrLZJDrFSxhpU55zMPASxgpGKwe/37Q1extVo8UtkVEwPPGKgF MStcQcy0z6rEYjpIZSuoGJ7tA+8VcUSj/lhE7rO3I4ROH25ZTdrMfhujqkpV6+W2O/oh W8BGM3Pa7m4TwlNqOo4/y9WE6CnfoOvYNT+ttZbMBFhzF+DtNThzOICKLdiNtcu8+2Uz BSfg== X-Gm-Message-State: AOAM533aQh43vvD7hIxDtmQtFv5m8zsf09Ph4w1gA5yGz6OUur6o5fsz m1u23JPJvAfCu0YUGGFpnbG29w== X-Google-Smtp-Source: ABdhPJyNH1vmStdwacwVR7XwfepJJGMq4Osrp+xllXoBHnt3Zv3+vrQl4a8ytgwrxBlK/osjffzvkg== X-Received: by 2002:a62:838a:: with SMTP id h132mr16810693pfe.72.1597793308492; Tue, 18 Aug 2020 16:28:28 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 30sm904747pjz.24.2020.08.18.16.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 16:28:27 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v2 0/3] adapter: Reconnect audio when resuming from suspend Date: Tue, 18 Aug 2020 16:28:19 -0700 Message-Id: <20200818232822.1645054-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.07 / 15.00 / 200.00 X-Rspamd-Queue-Id: DAE67555F2 X-Rspamd-UID: 23ff50 Hi Luiz and Marcel, This is a quality of life improvement for the behavior of audio devices during system suspend. This depends on a kernel change that emits suspend/resume events: https://patchwork.kernel.org/project/bluetooth/list/?series=325771 Right now, audio devices will be disconnected as part of suspend but won't be reconnected when the system resumes without user interaction. This is annoying to some users as it causes an interruption to their normal work flow. This change reconnects audio devices that were disconnected for suspend using the following logic: * Register a callback for controller resume in the policy plugin. * In the device disconnect callback, mark any devices with the A2DP service uuid for reconnect on resume after a delay. * In the controller resume callback, queue any policy items that are marked to reconnect on resume for connection with the ReconnectAudioDelay value (default = 5s for Wi-Fi coexistence). A reconnect is only attempted once after the controller resumes and the delay between resume and reconnect is configurable via the ReconnectAudioDelay key in the Policy settings. The 5s delay was chosen arbitrarily and I think anywhere up to 10s is probably ok. A longer delay is better to account for spurious wakeups and Wi-Fi reconnection time (avoiding any co-ex issues) at the downside of reconnection speed. Here are the tests I have done with this: - Single suspend and verified the headphones reconnect - Suspend stress test for 25 iterations and verify both Wi-Fi and Bluetooth audio reconnect on resume. (Ran with wake minimum time of 10s) - Suspend test with wake time < 5s to verify that BT reconnect isn't attempted. Ran 5 iterations with low wake time and then let it stay awake to confirm reconnect finally completed after 5s+ wake time. - Suspend test with wake time between 3s - 6s. Ran with 5 iterations and verified it wasn't connected at the end. A connection attempt was made but not completed due to suspend. A reconnect attempt was not made afterwards, which is by design. Luiz@ Marcel@: Does this sound ok (give up after an attempt)? I've tested this on a Pixelbook Go (AC-9260 controller) and HP Chromebook 14a (RTL8822CE controller) with GID6B headset. I've also tested this with the Pixel Buds 2. These earbuds actually reconnect automatically to the Chromebook (even without this policy change) and I verified that the new changes don't break the reconnection mechanism. Thanks Abhishek Changes in v2: - Refactored to use policy instead of connecting directly in adapter Abhishek Pandit-Subedi (3): mgmt: Add controller suspend and resume events monitor: Add btmon support for Suspend and Resume events policy: Reconnect audio on controller resume lib/mgmt.h | 14 +++++++++++ monitor/packet.c | 55 +++++++++++++++++++++++++++++++++++++++++ plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ src/adapter.h | 6 +++++ src/main.c | 1 + src/main.conf | 9 +++++++ 7 files changed, 190 insertions(+), 4 deletions(-) -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uAVOCACTPF+X3QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 04:48:32 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wDlfBgCTPF8B8gAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 04:48:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BCA69A0AA1; Wed, 19 Aug 2020 04:48:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727793AbgHSCsZ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 22:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727794AbgHSCsP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 22:48:15 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98814C061343 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 19:48:15 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id c4so17905552otf.12 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 19:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lXeL2NqENRyGepDGalfKTgrjgpPAYVjCiCWgtC+osv8=; b=a4omXrGFt2mE73+iut1A5IhTEFfx6pamQME9IhWd57cwGlHU0WCx/xyCsDMW9oCRx/ r5Je+Jnqvv1oGb7qtzaDv7HdK8PFQzuo5T1zxSjyPR57HwOTgkaLE65klwpLM+bA3M/d 6UjCbZvUpey/j0kaj3lyZFqRoIQMTdTLmSwIY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lXeL2NqENRyGepDGalfKTgrjgpPAYVjCiCWgtC+osv8=; b=Px4TgheeMlejljseH29ryd+AWv23nD4F5IM9s4461KJtP8Im79IUL4Few+LWDKg9T0 UNGUO/AMDJqTqzDiLCnrnhgEz5Q71gmIaT6G+rcfOskVHvs/0KHcJLnpVga6jYbZuoLt 3WYGiB9xQanazfLHEQqFMH3RT8IrGa1TTPt1CMrvPIjXch9p+0tdPiAlv5X5YTgsJz7v 7maMxN2h73inf6KYpjKDE8xBXk8UHIyzVFLzAk6ATEXqVubGTUFbXhJ5NLXnBuPEzctK gjdjUIQPdnX4v/UrbA96jEFzBlfFYuGW5yYXcWF1iSykGFBX+Z5E6TA+EHQ0cDegjcnQ fshA== X-Gm-Message-State: AOAM530C9KWq0zENXgGzMGD6RsCiEjbFZy5z47/+/jYyYPIo17Dz0iZp wseBfFboQXoh2EXa/eOqAe7fOnIow8+5BcqVF+KAA4ufzHA410jl X-Google-Smtp-Source: ABdhPJx7w/5ngmosBOb0nMnQpaaLLJ1ixcBwEM2m0noWsqACqIeFsrPmFWmcpoi9Um2KGR21e//49yJBL9TQ+yUx080= X-Received: by 2002:a9d:6f85:: with SMTP id h5mr17108737otq.81.1597805294630; Tue, 18 Aug 2020 19:48:14 -0700 (PDT) MIME-Version: 1.0 References: <20200813084129.332730-1-josephsih@chromium.org> In-Reply-To: <20200813084129.332730-1-josephsih@chromium.org> From: Shyh-In Hwang <josephsih@chromium.org> Date: Wed, 19 Aug 2020 10:48:03 +0800 Message-ID: <CAC9bf3SZKuCan1uDLZ55e0kHychy=6BHb1Cn4O0e5yJwBe1Wzg@mail.gmail.com> Subject: Re: [PATCH v1 0/2] To support the HFP WBS, a chip vendor may choose a particular To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: Joseph Hwang <josephsih@google.com>, chromeos-bluetooth-upstreaming@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.40 / 15.00 / 200.00 X-Rspamd-Queue-Id: BCA69A0AA1 X-Rspamd-UID: 963951 Dear maintainers: These two patches are to expose the WBS sco packet length to the user space. Since different vendors may choose different USB alternate settings which result in different packet lengths, we need the kernel to expose the lengths to the user space to handle the packets properly. Thanks! Joseph On Thu, Aug 13, 2020 at 4:42 PM Joseph Hwang <josephsih@chromium.org> wrote: > > USB alternate seeting of which the packet size is distinct. > The patches are to expose the packet size to user space so that > the user space does not need to hard code those values. > > We have verified this patch on Chromebooks which use > - Realtek 8822CE controller with USB alt setting 1 > - Intel controller with USB alt setting 6 > Our user space audio server, cras, can get the correct > packet length from the socket option. > > > Joseph Hwang (2): > Bluetooth: btusb: define HCI packet sizes of USB Alts > Bluetooth: sco: expose WBS packet length in socket option > > drivers/bluetooth/btusb.c | 43 +++++++++++++++++++++++-------- > include/net/bluetooth/bluetooth.h | 2 ++ > include/net/bluetooth/hci_core.h | 1 + > net/bluetooth/sco.c | 8 ++++++ > 4 files changed, 43 insertions(+), 11 deletions(-) > > -- > 2.28.0.236.gb10cc79966-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2JMNGMeYPF+y7AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 05:13:11 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id cHM9FseYPF+wEgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 05:13:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D2A65A020E; Wed, 19 Aug 2020 05:13:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726879AbgHSDM7 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 23:12:59 -0400 Received: from mga06.intel.com ([134.134.136.31]:17186 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726751AbgHSDM6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 23:12:58 -0400 IronPort-SDR: KYeUWiPjLtqXyJPTHpXTtpHGGOieCGGCUSg944goWW9fNldmDmI5OOfpWV8sJyAA6e93XFkCiz Ln91oM9TexUg== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="216564635" X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="216564635" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 20:12:57 -0700 IronPort-SDR: EL9dASr36AJvHM5zL57VzNE04q65oz6C7nVqq8xpnCM0MHu1DK9ARrtxrH+H+GuvJiZEloMzd2 qOAGsTIYtXfA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="292970639" Received: from orsmsx602-2.jf.intel.com (HELO ORSMSX602.amr.corp.intel.com) ([10.22.229.82]) by orsmga003.jf.intel.com with ESMTP; 18 Aug 2020 20:12:57 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 18 Aug 2020 20:12:56 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 18 Aug 2020 20:12:56 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 18 Aug 2020 20:12:56 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.102) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 18 Aug 2020 20:12:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rap4+kT2m8VyelJ9+ThuX2TBg+KVH6JIisVxPigc4KhMS0czme+rGsmt7bnfNMHMWr/q/YJAS7Y1Oc3pIry4NQWf0I23+6Qf5SkvgzNkdOsUPYkgwtPQSsFbCwCx2EvDlXV9y6ilzSddR/28X/tNxr7Jzli9nBFyRxyWYqV0Lp74xNFRCwMjxG2VulDf2QMLAwOf9biziIvNWvy6SDGKiE317rNqBXyvlP5uiuTCMPr+lt3L6PLwZngszbwPMKwpPauVJb/BTJMWFp5DLJtz4SW1Kos5gGjQHXaGbGvokmzFG1tXi/xXIx2HKS6OCFsVmoSDC9b70iamEqy8r19rlA== 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-SenderADCheck; bh=PWGo23ebG+CsALybDC/46kfUIULfeFSh1h5D6TZbU3c=; b=aakCzr4UX5dnP36e7g1pHfQ5wPW0JC4bBrQBFewkVmDs1eWxBzuGVOQRoCr3hFAsjtpcJ5a7911TIu6ofpZAORYmN+eREpqFHQR7axuyNx4FvPL75RaYm4TCShOrebr+BSr1/tfgwaXnDQCaJ98aTfMy3FHBrMTcolGfp6OqazRr5I7KikbDxRDNsugUpLCkyJJkDYJ3Y6LkEpxwK0b/WzQg01JsBMN/UhfaXoKo0YasaqhCDo2JWau2VgFdQ933jOAwLyE1ZKZMpS5999BaYaUofLhWvpCWQ99pxi6266xR0yi6LXFbrvSQBy0imEOuNhS+/Gz5S7BXKdlcXf+SiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PWGo23ebG+CsALybDC/46kfUIULfeFSh1h5D6TZbU3c=; b=wH3eTDVsKMhb0iarHYNFdX0KnpJYq3Xa+MSVQ+tAiKQzk+U3qnNzEWhHDDG4PGJ8xplRHRi6X7Et9M4lsPFxhMwaoWtUGwGDB3oAu76SCf6iUJEkg7D1J3DB94GGufMxGRR1ex6SqpbK2WrDtT/uew+nAyktIOUMjgJpZ+hP+6g= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB2032.namprd11.prod.outlook.com (2603:10b6:300:2b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15; Wed, 19 Aug 2020 03:12:54 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3305.024; Wed, 19 Aug 2020 03:12:54 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "daan@dptechnics.com" <daan@dptechnics.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Subject: Re: [PATCH BlueZ 1/1] Fixed issue in bluetooth-meshd which causes HCI error 0x12 when LE scanning is enabled because no random address was set. This is fixed by using the default HCI own device address option. Thread-Topic: [PATCH BlueZ 1/1] Fixed issue in bluetooth-meshd which causes HCI error 0x12 when LE scanning is enabled because no random address was set. This is fixed by using the default HCI own device address option. Thread-Index: AQHWdX/jPZsUrHlCZ0G9hl3GnNaX2Kk+wjyA Date: Wed, 19 Aug 2020 03:12:54 +0000 Message-ID: <0231dfc480da9571cc609f06f5d1155c9d2a0bb0.camel@intel.com> References: <20200818163611.57656-1-daan@dptechnics.com> <20200818163611.57656-2-daan@dptechnics.com> In-Reply-To: <20200818163611.57656-2-daan@dptechnics.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: dptechnics.com; dkim=none (message not signed) header.d=none;dptechnics.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.54.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c213b197-7b56-473d-7abb-08d843edc420 x-ms-traffictypediagnostic: MWHPR11MB2032: x-microsoft-antispam-prvs: <MWHPR11MB20320805A83EB00D561DA11FE15D0@MWHPR11MB2032.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ogBbWHYe/IDKYKB5svPvFeZbTh2+qKTv31pzebSwKRxvHKPeD/jwEzFtRYKGt4qZv30xO0+B9gIHgzWay3hKqtCtIzvE2r55MlinBsT9OQvoMy1wpUkgBzW7vINCGcXVfp435nD2uVqTW6n+04ivtgXAe5cMyJx5gVtXmBa0XiNOOhQYmNBdLw93jn8gayYp39pcC3FZ07DKI33veFjEySfVtb2EG2poA3O9Om8rX9o4HZkstoJZe6J3wCJYmtY7kllGzJ+S9MFwUj6eKKkqEzac3QD209fWgdPB6yc/PNjnOY9hB8FV814A+OlvCISiA6Zbasx26peS2zKW3Fikvw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(396003)(136003)(346002)(39860400002)(2616005)(8936002)(478600001)(86362001)(36756003)(2906002)(66446008)(66946007)(8676002)(66556008)(66476007)(6486002)(71200400001)(76116006)(64756008)(110136005)(26005)(6512007)(6506007)(5660300002)(316002)(91956017)(83380400001)(186003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: URd6+3C1KIGzPooNzrNoir95RpeDLT+z5z6dIVfjTbAKG2iiQI50O/mpdB2uWgOsIPSq2EP+gLm4j0lDeX6mqlucV+POffkW0rQGiuQfuW9Lgz95LUJRQIQZPfhfLH9sSqTZjBwKdJochbKkA+uEgy9CPA4RL3vQ1suDLOuL699drIFD9Vxybz+pWB8J+o0NyJc839TpzTJE8PWbaOkHmTxeCTq2Mux1W5bfD/rIGIyGjMtC/YNgS177hPAZHcVCj3+spk+QZ1xEk+brJACCbTD1PZG1kNWck8VAjOdE9CvxmbIP09U7YhynmHA9/10FSdie6ALF4dU2Hw7012586E8Ayec/vZZ7Q+AfSTwd4196Jwg4YPIGcAc1eAFwtRB6OGdl2FKpJbxxf5tYeToKei3rAnaR2IeLmvG35NsfqVA0nV3w29gG8qfWVP7SXq8W1KpyCrAkRj05DlmH7jXL8czMf22fR2kb1PU80PBR6Qf03B3I1hutzw9ww1uyX9xFii3FWpvjeEErGw55KmS9MRxSb/iZ5UVJeLFzu/csHC/NU3PgnVgsBcnPJvGqpju/vuSCzN7CJs1Rh0ODfji+cVIFS1i6Ch/LTj/ckfRfkApQq4+YSPK8sSNXFYrMqmU5JyBxUmoewl4POAv+Tf3fEg== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="utf-8" Content-ID: <C5F86B10FA27F143A305CB0C1485D1C6@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c213b197-7b56-473d-7abb-08d843edc420 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2020 03:12:54.8344 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Soxb3dz6k4rQysGZnJX33E7CMmX0tOuanbsh9w3EqiNuLLsIvbrCm7rAyM2rpbuzzDXng/yp0VKT8RBpJbJc7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB2032 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.34 / 15.00 / 200.00 X-Rspamd-Queue-Id: D2A65A020E X-Rspamd-UID: 794476 SGkgRGFhbiwNCg0KT24gVHVlLCAyMDIwLTA4LTE4IGF0IDE4OjM2ICswMjAwLCBEYWFuIFBhcGUg d3JvdGU6DQo+IC0tLQ0KPiAgbWVzaC9tZXNoLWlvLWdlbmVyaWMuYyB8IDQgKystLQ0KPiAgMSBm aWxlIGNoYW5nZWQsIDIgaW5zZXJ0aW9ucygrKSwgMiBkZWxldGlvbnMoLSkNCj4gDQo+IGRpZmYg LS1naXQgYS9tZXNoL21lc2gtaW8tZ2VuZXJpYy5jIGIvbWVzaC9tZXNoLWlvLWdlbmVyaWMuYw0K PiBpbmRleCA2N2IxM2ExYjkuLjY1ZmQxYzdiOSAxMDA2NDQNCj4gLS0tIGEvbWVzaC9tZXNoLWlv LWdlbmVyaWMuYw0KPiArKysgYi9tZXNoL21lc2gtaW8tZ2VuZXJpYy5jDQo+IEBAIC0zMjEsNyAr MzIxLDcgQEAgc3RhdGljIHZvaWQgc2Nhbl9kaXNhYmxlX3JzcChjb25zdCB2b2lkICpidWYsIHVp bnQ4X3Qgc2l6ZSwNCj4gIAljbWQudHlwZSA9IHB2dC0+YWN0aXZlID8gMHgwMSA6IDB4MDA7CS8q IFBhc3NpdmUvQWN0aXZlIHNjYW5uaW5nICovDQo+ICAJY21kLmludGVydmFsID0gTF9DUFVfVE9f TEUxNigweDAwMTApOwkvKiAxMCBtcyAqLw0KPiAgCWNtZC53aW5kb3cgPSBMX0NQVV9UT19MRTE2 KDB4MDAxMCk7CS8qIDEwIG1zICovDQo+IC0JY21kLm93bl9hZGRyX3R5cGUgPSAweDAxOwkJLyog QUREUl9UWVBFX1JBTkRPTSAqLw0KPiArCWNtZC5vd25fYWRkcl90eXBlID0gMHgwMDsgCQkvKiBQ dWJsaWMgRGV2aWNlIEFkZHJlc3MgKi8NCj4gIAljbWQuZmlsdGVyX3BvbGljeSA9IDB4MDA7CQkv KiBBY2NlcHQgYWxsICovDQo+ICANCg0KT3VyIHBvbGljeSBpcyB0byAqYWx3YXlzKiB1c2UgcmFu ZG9tIGFkZHJlc3NpbmcgZm9yIG91dGJvdW5kIG1lc2ggYWRkcmVzc2luZy4gIFNvIGlmIHRoaXMg aXMgdGhlIHJvb3QgY2F1c2Ugb2YNCnRoZSB3YXJuaW5nLCB3ZSB3aWxsIHdhbnQgdG8gZml4IGl0 IGluIHN1Y2ggYSB3YXkgdGhhdCByYW5kb20gYWRkcmVzc2luZyB3b3Jrcy4gIFRoaXMgc2hvdWxk IG9ubHkgYmUgYW4gaXNzdWUNCndoZW4gc3RhcnRpbmcgdXAsIHNvIHBlcmhhcHMgd2UganVzdCBu ZWVkIHRvIGFkZCBhIHJhbmRvbSBhZGRyZXNzIHNldCBpbnRvIHRoZSBzdGFydHVwIGNvbW1hbmQg Y2hhaW4uIA0KDQo+ICAJYnRfaGNpX3NlbmQocHZ0LT5oY2ksIEJUX0hDSV9DTURfTEVfU0VUX1ND QU5fUEFSQU1FVEVSUywNCj4gQEAgLTU3OSw3ICs1NzksNyBAQCBzdGF0aWMgdm9pZCBzZXRfc2Vu ZF9hZHZfcGFyYW1zKGNvbnN0IHZvaWQgKmJ1ZiwgdWludDhfdCBzaXplLA0KPiAgCWNtZC5taW5f aW50ZXJ2YWwgPSBMX0NQVV9UT19MRTE2KGhjaV9pbnRlcnZhbCk7DQo+ICAJY21kLm1heF9pbnRl cnZhbCA9IExfQ1BVX1RPX0xFMTYoaGNpX2ludGVydmFsKTsNCj4gIAljbWQudHlwZSA9IDB4MDM7 IC8qIEFEVl9OT05DT05OX0lORCAqLw0KPiAtCWNtZC5vd25fYWRkcl90eXBlID0gMHgwMTsgLyog QUREUl9UWVBFX1JBTkRPTSAqLw0KPiArCWNtZC5vd25fYWRkcl90eXBlID0gMHgwMDsgLyogUHVi bGljIERldmljZSBBZGRyZXNzICovDQo+ICAJY21kLmRpcmVjdF9hZGRyX3R5cGUgPSAweDAwOw0K PiAgCW1lbXNldChjbWQuZGlyZWN0X2FkZHIsIDAsIDYpOw0KPiAgCWNtZC5jaGFubmVsX21hcCA9 IDB4MDc7DQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ONUaHqGmPF+rHwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 06:12:17 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iNOvHKGmPF9DCAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 06:12:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 47193420C6; Wed, 19 Aug 2020 06:12:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725306AbgHSEML (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 00:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725280AbgHSEMH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 00:12:07 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0D76C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 21:12:06 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id a75so19804434ybg.15 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 21:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=AHZJoQheG4gkfi0dWS05sVsMgthHocN8pmTUWABp5co=; b=alXFtLawKWPZrZT1RnNOCtgWpKxEJZ3EElkArGiFPAsXjmNy7euTowqTBk6FcGnbTA Ml22ifn3GU3o3EqoNCmhS9ZvvQxT5khOLWoc82nuaHWxDWo/Vt1z1eEn/Bw09EMrHIqt dVtoIPk7x8/7JFlL3m7vuitsNCr/8rh9QX/8Ly5kEYOLCjtumV5jT5AFhLon8yr2Zpml 7C3oLhb3fZpxBGA5c8FxHrCBaKBQjLSCEw3N5LdNAVLoOgf9cjFscmDrb2qrkH3SgWSy OyguxULEi4oZ+YGwkOjuuU7yNIExujqy0zd+2iePWS349JqkEKmOtaLU0qC5g4ilFdr2 Ya9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=AHZJoQheG4gkfi0dWS05sVsMgthHocN8pmTUWABp5co=; b=mXTlWJLkKTPKt3eLBQDgDTNmxXT13aa+dFsQbEDI4CmqaIBJEc76Xer5ldkf9/Lfb9 lYAS1MB+Ff6BOlaHfrWcI3XiklIf+LVPX0+HkEoj3xcCscHxWuhf0Teq1Xq4nnjHoiiZ CYLX6OwXGixtQesnjjlUYt5kUmAwQzK2hzxJni9xcH5CzMq9o8UJOJXp0AG+l1OVmnX1 wlA5A9tay9iScAnAI4QZ4UF9/HM8e+BfPVbwdlNX1pr/w+oMTxoOBZRoshrgdR/lGiIG tYHTLyYunOGJBDpXw+gdjoE1441e+p9hsuhJ0sN6rr6ChEMBAeyW1+y9yiavH5x2V6an TwCg== X-Gm-Message-State: AOAM531wijNwdVKsZNrHMpDuUaYq8RvL+3Uq+/PXjPrszYM/r79OBOOO oZ4c3quz2KFuoNRQHAT2KQGI9v8oOy5kBk0UvXLSp1gOT4LVb07yrow4nc+5+VvIxyVmafa+Vfp 1eZ/8f8IxsSsFcnBLeEYS8+C1Ov5aIWejo5vwdd+tR3ePR+PC5Rwc7Z0sLnmVLenX8j8tHhQo7a 2SKfgq+1BlXJg= X-Google-Smtp-Source: ABdhPJwSBZjDNOQ62+VrNuhvAhlY5u6+R/jjpXhl42gM514U4HoWQtsT2R0Tmk1tqqd/YSNBIxirS0hoOycUD2FtUw== X-Received: by 2002:a25:6808:: with SMTP id d8mr31859217ybc.265.1597810325945; Tue, 18 Aug 2020 21:12:05 -0700 (PDT) Date: Wed, 19 Aug 2020 12:11:02 +0800 Message-Id: <20200819121048.BlueZ.v1.1.I3a57ea1eb3e3f5b87abc44ea478fc83817627ffc@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [BlueZ PATCH v1 1/4] client: Implement basic interface of ADV monitor in bluetoothctl From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, mcchou@chromium.org, mmandlik@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: 47193420C6 X-Rspamd-UID: d667f6 This patch implements some basic functions for ADV monitor in bluetoothctl [bluetooth]# show ... Advertisement Monitor Features: SupportedMonitorTypes: or_patterns Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Makefile.tools | 2 + client/advertisement_monitor.c | 161 +++++++++++++++++++++++++++++++++ client/advertisement_monitor.h | 23 +++++ client/main.c | 28 ++++++ 4 files changed, 214 insertions(+) create mode 100644 client/advertisement_monitor.c create mode 100644 client/advertisement_monitor.h diff --git a/Makefile.tools b/Makefile.tools index 9b9236609..88d9684a7 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -7,6 +7,8 @@ client_bluetoothctl_SOURCES = client/main.c \ client/agent.h client/agent.c \ client/advertising.h \ client/advertising.c \ + client/advertisement_monitor.h \ + client/advertisement_monitor.c \ client/gatt.h client/gatt.c client_bluetoothctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \ $(GLIB_LIBS) $(DBUS_LIBS) -lreadline diff --git a/client/advertisement_monitor.c b/client/advertisement_monitor.c new file mode 100644 index 000000000..bd2309537 --- /dev/null +++ b/client/advertisement_monitor.c @@ -0,0 +1,161 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdbool.h> +#include <string.h> + +#include "gdbus/gdbus.h" +#include "src/shared/util.h" +#include "src/shared/shell.h" +#include "advertisement_monitor.h" + +#define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" + +struct adv_monitor_manager { + GSList *supported_types; + GSList *supported_features; + GDBusProxy *proxy; + gboolean app_registered; +} manager = { NULL, NULL, NULL, FALSE }; + +static void set_supported_list(GSList **list, DBusMessageIter *iter) +{ + char *str; + DBusMessageIter subiter; + + dbus_message_iter_recurse(iter, &subiter); + while (dbus_message_iter_get_arg_type(&subiter) == + DBUS_TYPE_STRING) { + dbus_message_iter_get_basic(&subiter, &str); + *list = g_slist_append(*list, str); + dbus_message_iter_next(&subiter); + } +} + +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy) +{ + DBusMessageIter iter; + + if (manager.proxy != NULL || manager.supported_types != NULL || + manager.supported_features != NULL) { + bt_shell_printf("advertisement monitor manager already " + "added\n"); + return; + } + + manager.proxy = proxy; + + if (g_dbus_proxy_get_property(proxy, "SupportedMonitorTypes", &iter)) + set_supported_list(&(manager.supported_types), &iter); + + if (g_dbus_proxy_get_property(proxy, "SupportedFeatures", &iter)) + set_supported_list(&(manager.supported_features), &iter); + +} + +void adv_monitor_remove_manager(DBusConnection *conn) +{ + if (manager.supported_types != NULL) + g_slist_free(g_steal_pointer(&(manager.supported_types))); + if (manager.supported_features != NULL) + g_slist_free(g_steal_pointer(&(manager.supported_features))); + manager.proxy = NULL; + manager.app_registered = FALSE; +} + +static void register_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = ADV_MONITOR_APP_PATH; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +static void register_reply(DBusMessage *message, void *user_data) +{ + DBusConnection *conn = user_data; + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == FALSE) { + bt_shell_printf("AdvertisementMonitor path registered\n"); + } else { + bt_shell_printf("Failed to register path: %s\n", error.name); + dbus_error_free(&error); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } +} + +static void unregister_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = ADV_MONITOR_APP_PATH; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +static void unregister_reply(DBusMessage *message, void *user_data) +{ + DBusConnection *conn = user_data; + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == FALSE) { + bt_shell_printf("AdvertisementMonitor path unregistered\n"); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + bt_shell_printf("Failed to unregister Advertisement Monitor:" + " %s\n", error.name); + dbus_error_free(&error); + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + +void adv_monitor_register_app(DBusConnection *conn) +{ + if (manager.supported_types == NULL || manager.app_registered == TRUE || + g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", + register_setup, register_reply, + NULL, NULL) == FALSE) { + bt_shell_printf("Failed to register Advertisement Monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + manager.app_registered = TRUE; +} + +void adv_monitor_unregister_app(DBusConnection *conn) +{ + if (manager.app_registered == FALSE || + g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", + unregister_setup, unregister_reply, + NULL, NULL) == FALSE) { + bt_shell_printf("Failed to unregister Advertisement Monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + manager.app_registered = FALSE; +} diff --git a/client/advertisement_monitor.h b/client/advertisement_monitor.h new file mode 100644 index 000000000..77b0b62c6 --- /dev/null +++ b/client/advertisement_monitor.h @@ -0,0 +1,23 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); +void adv_monitor_remove_manager(DBusConnection *conn); +void adv_monitor_register_app(DBusConnection *conn); +void adv_monitor_unregister_app(DBusConnection *conn); diff --git a/client/main.c b/client/main.c index 9abada69f..7ddd13aa0 100644 --- a/client/main.c +++ b/client/main.c @@ -41,6 +41,7 @@ #include "agent.h" #include "gatt.h" #include "advertising.h" +#include "advertisement_monitor.h" /* String display constants */ #define COLORED_NEW COLOR_GREEN "NEW" COLOR_OFF @@ -58,6 +59,7 @@ static char *auto_register_agent = NULL; struct adapter { GDBusProxy *proxy; GDBusProxy *ad_proxy; + GDBusProxy *adv_monitor_proxy; GList *devices; }; @@ -528,6 +530,19 @@ static void ad_manager_added(GDBusProxy *proxy) adapter->ad_proxy = proxy; } +static void admon_manager_added(GDBusProxy *proxy) +{ + struct adapter *adapter; + + adapter = find_ctrl(ctrl_list, g_dbus_proxy_get_path(proxy)); + if (!adapter) + adapter = adapter_new(proxy); + + adapter->adv_monitor_proxy = proxy; + adv_monitor_add_manager(dbus_conn, proxy); + adv_monitor_register_app(dbus_conn); +} + static void proxy_added(GDBusProxy *proxy, void *user_data) { const char *interface; @@ -560,6 +575,9 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) ad_manager_added(proxy); } else if (!strcmp(interface, "org.bluez.Battery1")) { battery_added(proxy); + } else if (!strcmp(interface, + "org.bluez.AdvertisementMonitorManager1")) { + admon_manager_added(proxy); } } @@ -653,6 +671,9 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) ad_unregister(dbus_conn, NULL); } else if (!strcmp(interface, "org.bluez.Battery1")) { battery_removed(proxy); + } else if (!strcmp(interface, + "org.bluez.AdvertisementMonitorManager1")) { + adv_monitor_remove_manager(dbus_conn); } } @@ -935,6 +956,13 @@ static void cmd_show(int argc, char *argv[]) print_property(adapter->ad_proxy, "SupportedSecondaryChannels"); } + if (adapter->adv_monitor_proxy) { + bt_shell_printf("Advertisement Monitor Features:\n"); + print_property(adapter->adv_monitor_proxy, + "SupportedMonitorTypes"); + print_property(adapter->adv_monitor_proxy, "SupportedFeatures"); + } + return bt_shell_noninteractive_quit(EXIT_SUCCESS); } -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cBjpKaqmPF+rHwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 06:12:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MLUpKKqmPF8rNAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 06:12:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 73FC4420C6; Wed, 19 Aug 2020 06:12:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725601AbgHSEMV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 00:12:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725280AbgHSEMU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 00:12:20 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7F02C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 21:12:19 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id a75so19804897ybg.15 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 21:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=5S6/jfiMYy3835LYfWcy17MtiwNYRMUM+ig/mShYLAg=; b=GnsKx0Bn6nbI+MtoXbTYGaKT3E2MNTjxoDVlEs8Wq9Cyapk8+K6srjkI66ESJEQeGa lmvQwcR5s5PICkaO/dWKH0FJoPgnUYHNVnM+vr7Vb32sKKkN9wC765010sx3VODCACwC TF7/X/dSoCtlZRPMSuJv8BxN2+mCVhgSm8i0ZwwrTis9m+j7P0khBFAKF8bfxVk9DZcI 6/HuvsyVK01fnTgqr6cpqW2jhRxckODRwQVSdf0X8GnuZRAvUM+XO6ifN+QEeaQ8socK 7gjPwqzJf14/tdV5GWHz0sJWLdmSChzqiq8dPozyaauOtNIVzriLH2Oh73iyq5H3oBYO BrgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=5S6/jfiMYy3835LYfWcy17MtiwNYRMUM+ig/mShYLAg=; b=iwSA+zNJPBflghVM+Pd9OJ42O8zh1ZTqmdf7qKxN7/DKAr/5J5pHBzrJLjEtAx+36c Lp9d53+GsfreFMQZw/9KrKj2LKt1/cCASlA5qQ2ZVR0o4R7N/zkaXAvfP5szd19e4xIJ 9OOmh3acpuvW2RUFBfio3camw1x8knz40c03lD7jeddtjad2CIDuxnUcOp+Ddwbj2xVO d7XnxMv3ovsoL+P2LELA29B/w7wm/VXXRGELBItAeC1VKBX6vosx1Rc4jiGewWZMNyq9 1l22Gv7aWcC+kowJx2rorlSeNiv6h3osHgJuZkOiIc0x/gpc/R9mp4HQeXzOylghQGO5 fjtw== X-Gm-Message-State: AOAM530JywyrgpMbVkbimMwS2uNpP/rofcZVTC9SO5QnKJalhJ3hsvYv tHZUhUO0S/C/oRtnnw2gH0oTzsbNduFBCbNyLMgWGSsWebWypi0EzK5lDEHQd2Z+ImJtBEOPe5W eGytNPAuJI+WombvELochQ5MzZE1TehsbCmscxsT4zmR+Ewaimb2WgL2xKYnODgjp8TN3bs0CjW uVesU/Ob9F4ME= X-Google-Smtp-Source: ABdhPJwklEsXoWq+qBgeA+3VNxyKYft2BlyFe/UFcPuwOTEMP8R9Hp4/AjcUd+rYWUOK+qhPl6nLNId4V+a3/HA4vA== X-Received: by 2002:a25:2314:: with SMTP id j20mr31103344ybj.508.1597810339098; Tue, 18 Aug 2020 21:12:19 -0700 (PDT) Date: Wed, 19 Aug 2020 12:11:03 +0800 In-Reply-To: <20200819121048.BlueZ.v1.1.I3a57ea1eb3e3f5b87abc44ea478fc83817627ffc@changeid> Message-Id: <20200819121048.BlueZ.v1.2.I045d6f668c141c6b834ba6b31fc81618c0a7b8e8@changeid> Mime-Version: 1.0 References: <20200819121048.BlueZ.v1.1.I3a57ea1eb3e3f5b87abc44ea478fc83817627ffc@changeid> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [BlueZ PATCH v1 2/4] client: Implement more interfaces of ADV monitor in bluetoothctl From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, mcchou@chromium.org, mmandlik@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.38 / 15.00 / 200.00 X-Rspamd-Queue-Id: 73FC4420C6 X-Rspamd-UID: 2f183a This patch creates a submenu in bluetoothctl and implements several commands. new commands: [bluetooth]# menu advmon [bluetooth]# add-pattern-monitor or_patterns -10,10,-30,5 1,2,ab0011 Advertisement Monitor 0 added [bluetooth]# get-pattern-monitor all Advertisement Monitor 0 path: /org/bluez/adv_monitor_app/0 type: or_patterns rssi: high threshold: -10 high threshold timer: 10 low threshold: -30 low threshold timer: 5 pattern 1: start position: 1 AD data type: 2 content: ab0011 [bluetooth]# get-supported-info Supported Features: Supported Moniter Types: or_patterns [bluetooth]# remove-pattern-monitor 0 Monitor 0 deleted Signed-off-by: Howard Chung <howardchung@google.com> --- client/advertisement_monitor.c | 328 ++++++++++++++++++++++++++++++++- client/advertisement_monitor.h | 4 + client/main.c | 70 +++++++ 3 files changed, 399 insertions(+), 3 deletions(-) diff --git a/client/advertisement_monitor.c b/client/advertisement_monitor.c index bd2309537..ec8f23711 100644 --- a/client/advertisement_monitor.c +++ b/client/advertisement_monitor.c @@ -29,6 +29,7 @@ #include <string.h> #include "gdbus/gdbus.h" +#include "src/shared/ad.h" #include "src/shared/util.h" #include "src/shared/shell.h" #include "advertisement_monitor.h" @@ -36,6 +37,27 @@ #define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" +struct rssi_setting { + int16_t high_threshold; + uint16_t high_timer; + int16_t low_threshold; + uint16_t low_timer; +}; + +struct pattern { + uint8_t start_pos; + uint8_t ad_data_type; + uint8_t content_len; + uint8_t content[BT_AD_MAX_DATA_LEN]; +}; + +struct adv_monitor { + uint8_t idx; + char *type; + struct rssi_setting *rssi; + GSList *patterns; +}; + struct adv_monitor_manager { GSList *supported_types; GSList *supported_features; @@ -43,6 +65,9 @@ struct adv_monitor_manager { gboolean app_registered; } manager = { NULL, NULL, NULL, FALSE }; +static uint8_t adv_mon_idx; +static GSList *adv_mons; + static void set_supported_list(GSList **list, DBusMessageIter *iter) { char *str; @@ -138,7 +163,10 @@ static void unregister_reply(DBusMessage *message, void *user_data) void adv_monitor_register_app(DBusConnection *conn) { - if (manager.supported_types == NULL || manager.app_registered == TRUE || + if (manager.app_registered == TRUE) { + bt_shell_printf("Advertisement Monitor already registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } else if (manager.supported_types == NULL || g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", register_setup, register_reply, NULL, NULL) == FALSE) { @@ -150,8 +178,10 @@ void adv_monitor_register_app(DBusConnection *conn) void adv_monitor_unregister_app(DBusConnection *conn) { - if (manager.app_registered == FALSE || - g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", + if (manager.app_registered == FALSE) { + bt_shell_printf("Advertisement Monitor not registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } else if (g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", unregister_setup, unregister_reply, NULL, NULL) == FALSE) { bt_shell_printf("Failed to unregister Advertisement Monitor\n"); @@ -159,3 +189,295 @@ void adv_monitor_unregister_app(DBusConnection *conn) } manager.app_registered = FALSE; } + +static void free_pattern(void *user_data) +{ + struct pattern *p = user_data; + + g_free(p); +} + +static void free_adv_monitor(void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + g_free(adv_monitor->type); + g_free(adv_monitor->rssi); + g_slist_free_full(adv_monitor->patterns, free_pattern); + g_free(adv_monitor); +} + +static uint8_t str2bytearray(char *str, uint8_t *arr) +{ + int idx, len = strlen(str), arr_len = 0; + + if (len%2 != 0) + return 0; + + for (idx = 0; idx < len; idx += 2) { + if (sscanf(str+idx, "%2hhx", &arr[arr_len++]) < 1) + return 0; + } + return arr_len; +} + +static struct rssi_setting *parse_rssi(char *rssi_str) +{ + struct rssi_setting *rssi; + int16_t high_threshold, low_threshold; + uint16_t high_timer, low_timer; + + if (sscanf(rssi_str, "%hd,%hu,%hd,%hu", &high_threshold, &high_timer, + &low_threshold, &low_timer) < 4) + return NULL; + + rssi = g_malloc0(sizeof(struct rssi_setting)); + + if (!rssi) { + bt_shell_printf("Failed to allocate rssi_setting"); + bt_shell_noninteractive_quit(EXIT_FAILURE); + return NULL; + } + + rssi->high_threshold = high_threshold; + rssi->high_timer = high_timer; + rssi->low_threshold = low_threshold; + rssi->low_timer = low_timer; + + return rssi; +} + +static struct pattern *parse_pattern(char *pattern) +{ + uint8_t start_pos, ad_data_type; + char content_str[BT_AD_MAX_DATA_LEN]; + struct pattern *pat; + + if (sscanf(pattern, "%hhu,%hhu,%s", &start_pos, &ad_data_type, + content_str) < 3) + return NULL; + + pat = g_malloc0(sizeof(struct pattern)); + + if (!pat) { + bt_shell_printf("Failed to allocate pattern"); + bt_shell_noninteractive_quit(EXIT_FAILURE); + return NULL; + } + + pat->start_pos = start_pos; + pat->ad_data_type = ad_data_type; + pat->content_len = str2bytearray(content_str, pat->content); + if (pat->content_len == 0) { + free_pattern(pat); + return NULL; + } + + return pat; +} + +static GSList *parse_patterns(char *pattern_list[], int num) +{ + GSList *patterns = NULL; + int cnt; + + if (num == 0) { + bt_shell_printf("No pattern provided\n"); + return NULL; + } + + for (cnt = 0; cnt < num; cnt++) { + struct pattern *pattern; + + pattern = parse_pattern(pattern_list[cnt]); + if (pattern == NULL) { + g_slist_free_full(patterns, free_pattern); + return NULL; + } + patterns = g_slist_append(patterns, pattern); + } + + return patterns; +} + +static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) +{ + const struct adv_monitor *adv_monitor = a; + uint8_t idx = *(uint8_t *)b; + + return adv_monitor->idx != idx; +} + +static struct adv_monitor *find_adv_monitor_with_idx(uint8_t monitor_idx) +{ + GSList *list; + + list = g_slist_find_custom(adv_mons, &monitor_idx, + cmp_adv_monitor_with_idx); + + if (list) + return (struct adv_monitor *)list->data; + return NULL; +} + +static void print_bytearray(char *prefix, uint8_t *arr, uint8_t len) +{ + int idx; + + bt_shell_printf("%s", prefix); + for (idx = 0; idx < len; idx++) + bt_shell_printf("%02hhx", arr[idx]); + bt_shell_printf("\n"); +} + +static void print_adv_monitor(struct adv_monitor *adv_monitor) +{ + GSList *l; + + bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); + bt_shell_printf("\ttype: %s\n", adv_monitor->type); + if (adv_monitor->rssi) { + bt_shell_printf("\trssi:\n"); + bt_shell_printf("\t\thigh threshold: %hd\n", + adv_monitor->rssi->high_threshold); + bt_shell_printf("\t\thigh threshold timer: %hu\n", + adv_monitor->rssi->high_timer); + bt_shell_printf("\t\tlow threshold: %hd\n", + adv_monitor->rssi->low_threshold); + bt_shell_printf("\t\tlow threshold timer: %hu\n", + adv_monitor->rssi->low_timer); + } + + if (adv_monitor->patterns) { + int idx = 1; + + for (l = adv_monitor->patterns; l; l = g_slist_next(l), idx++) { + struct pattern *pattern = l->data; + + bt_shell_printf("\tpattern %d:\n", idx); + bt_shell_printf("\t\tstart position: %hhu\n", + pattern->start_pos); + bt_shell_printf("\t\tAD data type: %hhu\n", + pattern->ad_data_type); + print_bytearray("\t\tcontent: ", pattern->content, + pattern->content_len); + } + } +} + +void adv_monitor_add_monitor(DBusConnection *conn, int argc, char *argv[]) +{ + struct adv_monitor *adv_monitor; + struct rssi_setting *rssi; + GSList *patterns = NULL; + char *type; + + if (g_slist_length(adv_mons) >= UINT8_MAX) { + bt_shell_printf("Number of advertisement monitor exceeds " + "the limit"); + return; + } + + while (find_adv_monitor_with_idx(adv_mon_idx)) + adv_mon_idx += 1; + + type = argv[1]; + + if (strcmp(argv[2], "-") == 0) + rssi = NULL; + else { + rssi = parse_rssi(argv[2]); + if (rssi == NULL) { + bt_shell_printf("RSSIThresholdAndTimers malformed\n"); + return; + } + } + + patterns = parse_patterns(argv+3, argc-3); + if (patterns == NULL) { + bt_shell_printf("pattern-list malformed\n"); + return; + } + + adv_monitor = g_malloc0(sizeof(struct adv_monitor)); + + if (!adv_monitor) { + bt_shell_printf("Failed to allocate adv_monitor"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + adv_monitor->idx = adv_mon_idx; + adv_monitor->type = g_strdup(type); + adv_monitor->rssi = rssi; + adv_monitor->patterns = patterns; + + adv_mons = g_slist_append(adv_mons, adv_monitor); + bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); +} + +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx) +{ + struct adv_monitor *adv_monitor; + GSList *l; + + if (monitor_idx < 0) { + for (l = adv_mons; l; l = g_slist_next(l)) { + adv_monitor = l->data; + print_adv_monitor(adv_monitor); + } + return; + } + + adv_monitor = find_adv_monitor_with_idx(monitor_idx); + + if (adv_monitor == NULL) { + bt_shell_printf("Can't find monitor with index %d\n", + monitor_idx); + return; + } + + print_adv_monitor(adv_monitor); +} + +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) +{ + struct adv_monitor *adv_monitor; + + if (monitor_idx < 0) { + g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); + return; + } + + adv_monitor = find_adv_monitor_with_idx(monitor_idx); + if (adv_monitor == NULL) { + bt_shell_printf("Can't find monitor with index %d\n", + monitor_idx); + return; + } + + adv_mons = g_slist_remove(adv_mons, adv_monitor); + free_adv_monitor(adv_monitor); + bt_shell_printf("Monitor %d deleted\n", monitor_idx); +} + +static void print_supported_list(GSList *list) +{ + GSList *iter; + + for (iter = list; iter; iter = g_slist_next(iter)) { + char *data = iter->data; + + printf(" %s", data); + } +} + +void adv_monitor_get_supported_info(void) +{ + bt_shell_printf("Supported Features:"); + print_supported_list(manager.supported_features); + bt_shell_printf("\n"); + + bt_shell_printf("Supported Moniter Types:"); + print_supported_list(manager.supported_types); + bt_shell_printf("\n"); +} diff --git a/client/advertisement_monitor.h b/client/advertisement_monitor.h index 77b0b62c6..f2a0caf77 100644 --- a/client/advertisement_monitor.h +++ b/client/advertisement_monitor.h @@ -21,3 +21,7 @@ void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); void adv_monitor_remove_manager(DBusConnection *conn); void adv_monitor_register_app(DBusConnection *conn); void adv_monitor_unregister_app(DBusConnection *conn); +void adv_monitor_add_monitor(DBusConnection *conn, int argc, char *argv[]); +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx); +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx); +void adv_monitor_get_supported_info(void); diff --git a/client/main.c b/client/main.c index 7ddd13aa0..2b63ee62a 100644 --- a/client/main.c +++ b/client/main.c @@ -2686,6 +2686,53 @@ static void cmd_ad_clear(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_FAILURE); } +static void print_add_monitor_usage(void) +{ + bt_shell_usage(); + bt_shell_printf("RSSIThresholdAndTimers format:\n" + "\t<high-rssi>,<high-timeout>,<low-rssi>,<low-timeout>\n" + "\tor single '-' for not using RSSI as filter\n"); + bt_shell_printf("pattern format:\n" + "\t<start_position>,<ad_data_type>,<content_of_pattern>\n"); + bt_shell_printf("e.g.\n" + "\tadd-pattern-monitor or_patterns -10,10,-20,20 1,2,01ab55\n"); +} + +static void cmd_adv_monitor_add_monitor(int argc, char *argv[]) +{ + if (argc < 3) + print_add_monitor_usage(); + else + adv_monitor_add_monitor(dbus_conn, argc, argv); +} + +static void cmd_adv_monitor_print_monitor(int argc, char *argv[]) +{ + int monitor_idx; + + if (strcmp(argv[1], "all") == 0) + monitor_idx = -1; + else + monitor_idx = atoi(argv[1]); + adv_monitor_print_monitor(dbus_conn, monitor_idx); +} + +static void cmd_adv_monitor_remove_monitor(int argc, char *argv[]) +{ + int monitor_idx; + + if (strcmp(argv[1], "all") == 0) + monitor_idx = -1; + else + monitor_idx = atoi(argv[1]); + adv_monitor_remove_monitor(dbus_conn, monitor_idx); +} + +static void cmd_adv_monitor_get_supported_info(int argc, char *argv[]) +{ + adv_monitor_get_supported_info(); +} + static const struct bt_shell_menu advertise_menu = { .name = "advertise", .desc = "Advertise Options Submenu", @@ -2722,6 +2769,28 @@ static const struct bt_shell_menu advertise_menu = { { } }, }; +static const struct bt_shell_menu advertise_monitor_menu = { + .name = "advmon", + .desc = "Advertisement Monitor Options Submenu", + .entries = { + { "add-pattern-monitor", "<type-of-monitor/help> " + "[RSSIThresholdAndTimers] " + "[patterns=pattern1 pattern2 ...]", + cmd_adv_monitor_add_monitor, + "Add pattern monitor" }, + { "get-pattern-monitor", "<monitor-id/all>", + cmd_adv_monitor_print_monitor, + "Get advertisement monitor" }, + { "remove-pattern-monitor", "<monitor-id/all>", + cmd_adv_monitor_remove_monitor, + "Remove advertisement monitor" }, + { "get-supported-info", NULL, + cmd_adv_monitor_get_supported_info, + "Get advertisement manager supported " + "features and supported monitor types" }, + { } }, +}; + static const struct bt_shell_menu scan_menu = { .name = "scan", .desc = "Scan Options Submenu", @@ -2897,6 +2966,7 @@ int main(int argc, char *argv[]) bt_shell_init(argc, argv, &opt); bt_shell_set_menu(&main_menu); bt_shell_add_submenu(&advertise_menu); + bt_shell_add_submenu(&advertise_monitor_menu); bt_shell_add_submenu(&scan_menu); bt_shell_add_submenu(&gatt_menu); bt_shell_set_prompt(PROMPT_OFF); -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kMoOKLSmPF8NGwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 06:12:36 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id sIObJrSmPF93qQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 06:12:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6E093A0AA1; Wed, 19 Aug 2020 06:12:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725788AbgHSEMa (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 00:12:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725803AbgHSEM2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 00:12:28 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C2FEC061343 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 21:12:28 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id t11so14262507pfq.21 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 21:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=KDMAZBNBq+Q66R2m1YuL2nFJAbD1yqbyI9MMCt4su+g=; b=JQZI77mWDWM37eOZ3zFvzpCFX+2Iw2mWJF5wHXiHpDcwyiTiXrVGo014SZ+3rl3LKv qm/PAxkbFu2VcqPsVBbTqHkdSqB80WOQ6I2r8yqW/Cqc+L/a0yk0nBk1b3d3aE+zsWs1 1ObBl8AVf2amQwHwohT2X72+70P3sugB7lafxtFdh+XUyavyNaRE9K/+Oyl34bjmy5zw 2yq7eUx1miAahD791zfR/bJHwtUiDwH2b0jkHTGV2LayT9NjenXDBWXqn177kmytk5Cm XPxoueAT98iNcPwRaDjN9V0nfQ7eCiEwkn0K69lOtVvpojBVDTtWhdMnuo954W5AllSb h9ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=KDMAZBNBq+Q66R2m1YuL2nFJAbD1yqbyI9MMCt4su+g=; b=haK/6GHV4MREd/8+rj9goOe9+WsE+3GG5mgultR2JhaxjYzhEu78zIkG7sexO3xxQx jO+6FOZY7E7ocggU8uRz6zjdYSWZUfkZsn15aV35/JQAHYoWSfWsLKzuOhduoTapFOiG L77Drep/UkX8QDaSvzelayoEBNGwVgQmqi6IVeKWA2nToHQW9KoeFlv9rQjJUSQTF0TK tU9tkLF4RuWnqXaidnPdtQBoRTkH+m6Qy1A1l8jyLVWFYyoiPvBCaNuY9bRu0A336C6J O1Nzfhvo3a7ryDA2ToZPhndVlgp/A49gL2/V2CyJc6oHxctgQ7eNl6lADt5YLWTpr36b fTJQ== X-Gm-Message-State: AOAM531KrjjNl7aXE9uOnqxDLyKIgQkru9A8+T/KLSsMKub5j454YVPx ILOpRjVUMSvpv1br3tZ28Ouf0dCxwY/Mh6puHHBMGvfcodD7qU4o+wcvFObLbgU4uKJjG9OAQut 90HSkdXPDY7N9diSYvBNA4cijn0mcO+aXX8MrU6IQTBM0zRb20RLeoH89TvDJxqxqSqG47b0lo8 Mjo67+Zor43hM= X-Google-Smtp-Source: ABdhPJymvd3pwUrerSqA+hpGEjWZTpKw/cQxbIU/abX2D3oPGRelPiv7w+dQTSsjOIoafJAhHQgAyd7SADzkXnvzBw== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:90a:bd82:: with SMTP id z2mr477740pjr.1.1597810347418; Tue, 18 Aug 2020 21:12:27 -0700 (PDT) Date: Wed, 19 Aug 2020 12:11:04 +0800 In-Reply-To: <20200819121048.BlueZ.v1.1.I3a57ea1eb3e3f5b87abc44ea478fc83817627ffc@changeid> Message-Id: <20200819121048.BlueZ.v1.3.I3037dbcd77b86f96f7f55350ad7ce5224208c20d@changeid> Mime-Version: 1.0 References: <20200819121048.BlueZ.v1.1.I3a57ea1eb3e3f5b87abc44ea478fc83817627ffc@changeid> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [BlueZ PATCH v1 3/4] client: Expose ADV monitor objects From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, mcchou@chromium.org, mmandlik@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.62 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6E093A0AA1 X-Rspamd-UID: ab8ff9 This adds logic to expose user-defined advertisement monitor to dbus and also implements methods for exposed objects. Signed-off-by: Howard Chung <howardchung@google.com> --- client/advertisement_monitor.c | 187 ++++++++++++++++++++++++++++++++- 1 file changed, 183 insertions(+), 4 deletions(-) diff --git a/client/advertisement_monitor.c b/client/advertisement_monitor.c index ec8f23711..7ec5243e7 100644 --- a/client/advertisement_monitor.c +++ b/client/advertisement_monitor.c @@ -53,12 +53,13 @@ struct pattern { struct adv_monitor { uint8_t idx; + char *path; char *type; struct rssi_setting *rssi; GSList *patterns; }; -struct adv_monitor_manager { +static struct adv_monitor_manager { GSList *supported_types; GSList *supported_features; GDBusProxy *proxy; @@ -68,6 +69,163 @@ struct adv_monitor_manager { static uint8_t adv_mon_idx; static GSList *adv_mons; +static void remove_adv_monitor(void *data, void *user_data); + +static DBusMessage *release_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + bt_shell_printf("Advertisement monitor %d released\n", + adv_monitor->idx); + remove_adv_monitor(adv_monitor, conn); + + return dbus_message_new_method_return(msg); +} + +static DBusMessage *activate_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + bt_shell_printf("Advertisement monitor %d activated\n", + adv_monitor->idx); + return dbus_message_new_method_return(msg); +} + +static DBusMessage *device_found_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + const char *device; + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device, + DBUS_TYPE_INVALID); + bt_shell_printf("Advertisement monitor %d found device %s\n", + adv_monitor->idx, device); + return dbus_message_new_method_return(msg); +} + +static DBusMessage *device_lost_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + const char *device; + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device, + DBUS_TYPE_INVALID); + bt_shell_printf("Advertisement monitor %d lost device %s\n", + adv_monitor->idx, device); + return dbus_message_new_method_return(msg); +} + +static const GDBusMethodTable adv_monitor_methods[] = { + { GDBUS_ASYNC_METHOD("Release", NULL, NULL, release_adv_monitor) }, + { GDBUS_ASYNC_METHOD("Activate", NULL, NULL, activate_adv_monitor) }, + { GDBUS_ASYNC_METHOD("DeviceFound", GDBUS_ARGS({ "device", "o" }), + NULL, device_found_adv_monitor) }, + { GDBUS_ASYNC_METHOD("DeviceLost", GDBUS_ARGS({ "device", "o" }), + NULL, device_lost_adv_monitor) }, + { } +}; + + +static gboolean get_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, + &adv_monitor->type); + return TRUE; +} + +static gboolean get_rssi(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + struct rssi_setting *rssi = adv_monitor->rssi; + DBusMessageIter data_iter; + + dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, + NULL, &data_iter); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_INT16, + &rssi->high_threshold); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_UINT16, + &rssi->high_timer); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_INT16, + &rssi->low_threshold); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_UINT16, + &rssi->low_timer); + dbus_message_iter_close_container(iter, &data_iter); + return TRUE; +} + +static gboolean rssi_exists(const GDBusPropertyTable *property, void *data) +{ + struct adv_monitor *adv_monitor = data; + + return adv_monitor->rssi != NULL; +} + +static void append_pattern_content_to_dbus(DBusMessageIter *iter, + struct pattern *pattern) +{ + DBusMessageIter data_iter; + int idx; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE_AS_STRING, &data_iter); + for (idx = 0; idx < pattern->content_len; idx++) + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->content[idx]); + dbus_message_iter_close_container(iter, &data_iter); +} + +static void append_pattern_to_dbus(void *data, void *user_data) +{ + struct pattern *pattern = data; + DBusMessageIter *array_iter = user_data; + DBusMessageIter data_iter; + + dbus_message_iter_open_container(array_iter, DBUS_TYPE_STRUCT, + NULL, &data_iter); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->start_pos); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->ad_data_type); + append_pattern_content_to_dbus(&data_iter, pattern); + dbus_message_iter_close_container(array_iter, &data_iter); +} + +static gboolean get_patterns(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + DBusMessageIter array_iter; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "(yyay)", + &array_iter); + g_slist_foreach(adv_monitor->patterns, append_pattern_to_dbus, + &array_iter); + dbus_message_iter_close_container(iter, &array_iter); + return TRUE; +} + +static gboolean pattern_exists(const GDBusPropertyTable *property, void *data) +{ + struct adv_monitor *adv_monitor = data; + + return adv_monitor->patterns != NULL; +} + +static const GDBusPropertyTable adv_monitor_props[] = { + { "Type", "s", get_type }, + { "RSSIThresholdsAndTimers", "(nqnq)", get_rssi, NULL, rssi_exists }, + { "Patterns", "a(yyay)", get_patterns, NULL, pattern_exists }, + { } +}; + static void set_supported_list(GSList **list, DBusMessageIter *iter) { char *str; @@ -201,6 +359,7 @@ static void free_adv_monitor(void *user_data) { struct adv_monitor *adv_monitor = user_data; + g_free(adv_monitor->path); g_free(adv_monitor->type); g_free(adv_monitor->rssi); g_slist_free_full(adv_monitor->patterns, free_pattern); @@ -300,6 +459,16 @@ static GSList *parse_patterns(char *pattern_list[], int num) return patterns; } +static void remove_adv_monitor(void *data, void *user_data) +{ + struct adv_monitor *adv_monitor = data; + DBusConnection *conn = user_data; + + adv_mons = g_slist_remove(adv_mons, adv_monitor); + g_dbus_unregister_interface(conn, adv_monitor->path, + ADV_MONITOR_INTERFACE); +} + static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) { const struct adv_monitor *adv_monitor = a; @@ -335,6 +504,7 @@ static void print_adv_monitor(struct adv_monitor *adv_monitor) GSList *l; bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); + bt_shell_printf("\tpath: %s\n", adv_monitor->path); bt_shell_printf("\ttype: %s\n", adv_monitor->type); if (adv_monitor->rssi) { bt_shell_printf("\trssi:\n"); @@ -410,6 +580,16 @@ void adv_monitor_add_monitor(DBusConnection *conn, int argc, char *argv[]) adv_monitor->type = g_strdup(type); adv_monitor->rssi = rssi; adv_monitor->patterns = patterns; + adv_monitor->path = g_strdup_printf("%s/%hhu", ADV_MONITOR_APP_PATH, + adv_mon_idx); + if (g_dbus_register_interface(conn, adv_monitor->path, + ADV_MONITOR_INTERFACE, + adv_monitor_methods, NULL, + adv_monitor_props, adv_monitor, + free_adv_monitor) == FALSE) { + bt_shell_printf("Failed to register advertisement monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } adv_mons = g_slist_append(adv_mons, adv_monitor); bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); @@ -444,7 +624,7 @@ void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) struct adv_monitor *adv_monitor; if (monitor_idx < 0) { - g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); + g_slist_foreach(adv_mons, remove_adv_monitor, conn); return; } @@ -455,8 +635,7 @@ void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) return; } - adv_mons = g_slist_remove(adv_mons, adv_monitor); - free_adv_monitor(adv_monitor); + remove_adv_monitor(adv_monitor, conn); bt_shell_printf("Monitor %d deleted\n", monitor_idx); } -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AN3FG72mPF+PGQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 06:12:45 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qAHxGb2mPF81WwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 06:12:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 82F25A03FD; Wed, 19 Aug 2020 06:12:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725931AbgHSEMk (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 00:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725883AbgHSEMj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 00:12:39 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD34DC061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 21:12:38 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id e196so24609320ybh.6 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 21:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=NAYmT5pippiwPtvep7OJSxG8Hwp8J5cDMvPe3QXl29I=; b=j5YgV5NBvP12iEfssdXHIWsPKz5HBBAQuYd6YstWZuGyJupdVuyLPK3SWHrzIKukL+ Oy2HMwUGM6ZKqbAltItRNRnNxn/GCosk9qyQDw9Hm8MALCg8V+TcTnVDbLFa7zXvqA4w HM35Kjh2o536ECsBh9zBUt7p6pVntJPII0uEchu5bvVhG8T89rnFGnAGsRKQMIywcDJ+ d/tVF33ZCGQYWNv2QvKwK63ZFZxVoYnZfo2DfhvZnH1pS3PAR8LuGOicUG1nis/Qib0z YqTrqjzrs11yHtcoSG0R/rGhCeo3NzJxnaVGvfnQG4pah7EJAY+EiDtv2vrlvqaLYfUe Ckww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=NAYmT5pippiwPtvep7OJSxG8Hwp8J5cDMvPe3QXl29I=; b=QSYDYqMHOvx8IYWvqptNoyezdeO9marpIukCwSA9SL+fdd4Awekt3I15rANc8WccMw DXJzzrRrB4O7BP26hm7XOvn4totpJUybNynTfP3GDNYkc4SewPohOwhPqcvoxeCikN6s k5uuejbEo4mld3TwFoQcIcQT+9ZbUMkkqjXGtZuZsOn9zEB0is/ilE47ivcEMLm7XvPi lyI+AFCOTC6tE1b2cUh28oqXUX1Je+Aqrc7l1eOkev22vHyZ6rJ62tyDEgnsfNKiUeyV mw/91YAjbtO8RqIAFVDo0Axm2DuJ5cBOWr/lzvZUpN+0mcejBplWsnGOQ7/ZhzuM9Won PzUQ== X-Gm-Message-State: AOAM530MUrVrz70rWchIH/qT1sYaOE3tZdGJO73Pu+GrFYx7DiRY27h0 GOVCgz6Bzk7I5bj+JiMxY1znjwg3EW/FNRZm4BvUjPnxsdI2c7aHtky5Z5iXeBkouA1+G7hM403 Huh3X7GrkR1hsHgPWzUtEyCi0taDH2ElbAubsv2ofxF5ZoME5l99UEqt31J74w1NaHeMpcjjhw5 k9K08s3SmN4tQ= X-Google-Smtp-Source: ABdhPJypSxy6Q+jDMoQkNt9PubSGX41e+45UZkBZgTsAhrKxur52gnS5xTyNt+js7mMypX5sTHnt8oR8MbWfo1NDFQ== X-Received: by 2002:a25:df02:: with SMTP id w2mr28905861ybg.189.1597810357890; Tue, 18 Aug 2020 21:12:37 -0700 (PDT) Date: Wed, 19 Aug 2020 12:11:05 +0800 In-Reply-To: <20200819121048.BlueZ.v1.1.I3a57ea1eb3e3f5b87abc44ea478fc83817627ffc@changeid> Message-Id: <20200819121048.BlueZ.v1.4.I0ebba5ae17d45060148f91000e6c622bcd0b30da@changeid> Mime-Version: 1.0 References: <20200819121048.BlueZ.v1.1.I3a57ea1eb3e3f5b87abc44ea478fc83817627ffc@changeid> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [BlueZ PATCH v1 4/4] core: Add AdvertisementMonitor to bluetooth.conf From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, mcchou@chromium.org, mmandlik@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.38 / 15.00 / 200.00 X-Rspamd-Queue-Id: 82F25A03FD X-Rspamd-UID: 5f2d55 AdvertisementMonitor must be included in bluetooth.conf in order to be able to call Release Signed-off-by: Howard Chung <howardchung@google.com> --- src/bluetooth.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bluetooth.conf b/src/bluetooth.conf index 8a1e25801..b6c614908 100644 --- a/src/bluetooth.conf +++ b/src/bluetooth.conf @@ -10,6 +10,7 @@ <policy user="root"> <allow own="org.bluez"/> <allow send_destination="org.bluez"/> + <allow send_interface="org.bluez.AdvertisementMonitor1"/> <allow send_interface="org.bluez.Agent1"/> <allow send_interface="org.bluez.MediaEndpoint1"/> <allow send_interface="org.bluez.MediaPlayer1"/> -- 2.28.0.220.ged08abb693-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4JH2MixkPF+I6AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 01:28:44 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id kEt/MSxkPF/VeAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 01:28:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C5564553AF; Wed, 19 Aug 2020 01:28:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbgHRX2d (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 19:28:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726718AbgHRX2a (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 19:28:30 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62BE7C061342 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:28:30 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id k13so9917436plk.13 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XHUv3FRBN80hsAun3UWyOrIBRTs3yhxSRL5yxQg39V0=; b=PR0i5tUm4m6vaF7bl7oP3JlGmW3KVCZhOcp3TW49LecBgfPzPRpD/L+rMPmN4aHIyy GjIWsvfiT4pO1yKlLrD3uxtth3ZHIsKjrMOeyD3f9zy30iLWl3+89WYZ/3yly2pXVK3M hQFXaOcJQBOXNrctjtOCaKv+mPLdW1Kwq2wBo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XHUv3FRBN80hsAun3UWyOrIBRTs3yhxSRL5yxQg39V0=; b=Qw0V4pcC8r2+UOAXBsHCYRejhjfzpOPTDgrratZo+lw4AP1Vjy9TNuYUlL3NOyqT++ IzeUG3kyVKAQUHCPzbj6IFcU/hEGwOBsZYIXUs7nfu+riheAG7+2pmCd820ekx8yo03I V6m4ZZYV/L+R/Ka4eLye+muY3DiAEBZVU0GGjXvyelqnxzHQcin+cetFt6rrT4VCbtyh naeFMJbYO/MeEBxRCUKlgA4nKDjJrr2hW6suV9xQhjpIQzai09tZmNr2q1rbzxHdVd44 ROG+Hj2ZQTHDCKJeHnTUOvPWpFztHhwaccYQeuvDFcIqo+WIMdj3IDqJMt0oYx9/cEl5 v7RA== X-Gm-Message-State: AOAM531b+or0hSKN/ayV6N5ioYMcYeD81h7o0EWM+//2VZL5e4kSL5re cnq4+HpKxtwA072xUIOlOhCs0A== X-Google-Smtp-Source: ABdhPJxp/5FV4L2Y0CvUQVJQLq4JQoC3tZuYfhsfOTC5//EQp5SjlkqmGenIZR/Yu9OMYuE45vdTqg== X-Received: by 2002:a17:90b:1b43:: with SMTP id nv3mr1814429pjb.22.1597793309551; Tue, 18 Aug 2020 16:28:29 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 30sm904747pjz.24.2020.08.18.16.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 16:28:28 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Subject: [Bluez PATCH v2 1/3] mgmt: Add controller suspend and resume events Date: Tue, 18 Aug 2020 16:28:20 -0700 Message-Id: <20200818162807.Bluez.v2.1.I14a96397d181666c124e1c413b834428faf3db7a@changeid> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog In-Reply-To: <20200818232822.1645054-1-abhishekpandit@chromium.org> References: <20200818232822.1645054-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: C5564553AF X-Rspamd-UID: d0ad4b Add the controller suspend and resume events. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Changes in v2: None lib/mgmt.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index a800bcab4..46d894ae9 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -772,6 +772,7 @@ struct mgmt_ev_device_connected { #define MGMT_DEV_DISCONN_TIMEOUT 0x01 #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 #define MGMT_DEV_DISCONN_REMOTE 0x03 +#define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND 0x05 #define MGMT_EV_DEVICE_DISCONNECTED 0x000C struct mgmt_ev_device_disconnected { @@ -959,6 +960,17 @@ struct mgmt_ev_adv_monitor_removed { uint16_t monitor_handle; } __packed; +#define MGMT_EV_CONTROLLER_SUSPEND 0x002d +struct mgmt_ev_controller_suspend { + uint8_t suspend_state; +} __packed; + +#define MGMT_EV_CONTROLLER_RESUME 0x002e +struct mgmt_ev_controller_resume { + struct mgmt_addr_info addr; + uint8_t wake_reason; +} __packed; + static const char *mgmt_op[] = { "<0x0000>", "Read Version", @@ -1088,6 +1100,8 @@ static const char *mgmt_ev[] = { "Device Flags Changed", "Advertisement Monitor Added", /* 0x002b */ "Advertisement Monitor Removed", + "Controller Suspend", + "Controller Resume", }; static const char *mgmt_status[] = { -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WOCaDjJkPF/WxAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 01:28:50 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0EzlDDJkPF/VeAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 01:28:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 23A0442109; Wed, 19 Aug 2020 01:28:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727022AbgHRX2e (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 19:28:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726745AbgHRX2b (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 19:28:31 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63012C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:28:31 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id mt12so242136pjb.4 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7X+uls88rccAT4N2V4ZR70a3gZiJwbItKIK4d+bIKUQ=; b=GIu9x6bcnut8SKqOskUyIQwIVz1Evdzq/+W0XlMxz8JDgRyipB2SlhZrb0pn7xDfMw kv11IAwUSEl875nIPXhxIUOBp4ghjxJNPWgeLTDdBp8v3T96Y8w7Xw3i4J13E2m7+tbz onGEoAuxQOr/ltOlG/5BfqcoX+F3feNEoH4wI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7X+uls88rccAT4N2V4ZR70a3gZiJwbItKIK4d+bIKUQ=; b=TJIsbAlhPF/8dp+rN1RCSRlrQh13lKIfqYyvY0oGLRqz7YIAvMW/N40O4CMBBUKAIZ 1OlT1pbSosTQhUm6ulAxP4HJ+XmY47KRSKP8Q2dIb3joeNanKr+h6lC6kbZJa6S2If9w eo05waRfNWUe/D9QzEdngdb8vTUOwKr/rHUUoy26PyCDc2QKOkxtBRT7nj09EHL24P+9 N5KDMMDcrLy0KpB3IItaOwt1TPzLb7d+fJJl0OtF20/Ujw/6eAYlXW3p8CzfYlU8LX/4 WOrbXDtzj1GmncEQS77UeQo7xcV2OzsoCeFrOUs35/WfqOfCSJisrEWcGXGBIeTYSAen PfNw== X-Gm-Message-State: AOAM532jQ6kBGzMlTVDMVTsJIO6PrQADiMlqnr3aHhDDimrCzMCd6yLA sYj5iBXqi5Vg+O7E9E0hw0ZgFw== X-Google-Smtp-Source: ABdhPJyiVHMyc5dM1ZclPxVPfbZpltYkdPGrXlxCnwiAMJ5blhdMzN+e6FBXQTNc/RfrgCzYrnQ9BA== X-Received: by 2002:a17:90a:154e:: with SMTP id y14mr1863601pja.178.1597793310761; Tue, 18 Aug 2020 16:28:30 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 30sm904747pjz.24.2020.08.18.16.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 16:28:30 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [Bluez PATCH v2 2/3] monitor: Add btmon support for Suspend and Resume events Date: Tue, 18 Aug 2020 16:28:21 -0700 Message-Id: <20200818162807.Bluez.v2.2.Id78b98210807c1326ee2c187af73a325fc97f1e1@changeid> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog In-Reply-To: <20200818232822.1645054-1-abhishekpandit@chromium.org> References: <20200818232822.1645054-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: 23A0442109 X-Rspamd-UID: 141c33 Add support to pretty print Suspend and Resume mgmt events in btmon. Example: @ MGMT Event: Controller Suspended (0x002d) plen 1 Suspend state: Page scanning and/or passive scanning (2) @ MGMT Event: Controller Resumed (0x002e) plen 8 Wake reason: Remote wake due to peer device connection (2) LE Address: CD:F3:CD:13:C5:9A (OUI CD-F3-CD) Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Changes in v2: None monitor/packet.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 431a39b66..451630e04 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -13555,6 +13555,9 @@ static void mgmt_device_disconnected_evt(const void *data, uint16_t size) case 0x04: str = "Connection terminated due to authentication failure"; break; + case 0x05: + str = "Connection terminated by local host for suspend"; + break; default: str = "Reserved"; break; @@ -13782,6 +13785,54 @@ static void mgmt_device_flags_changed_evt(const void *data, uint16_t size) mgmt_print_added_device_flags("Current Flags", current_flags); } +static void mgmt_controller_suspend_evt(const void *data, uint16_t size) +{ + uint8_t state = get_u8(data); + char *str; + + switch (state) { + case 0x0: + str = "Controller running (failed to suspend)"; + break; + case 0x1: + str = "Disconnected and not scanning"; + break; + case 0x2: + str = "Page scanning and/or passive scanning"; + break; + default: + str = "Unknown suspend state"; + break; + } + + print_field("Suspend state: %s (%d)", str, state); +} + +static void mgmt_controller_resume_evt(const void *data, uint16_t size) +{ + uint8_t addr_type = get_u8(data + 6); + uint8_t wake_reason = get_u8(data + 7); + char *str; + + switch (wake_reason) { + case 0x0: + str = "Resume from non-Bluetooth wake source"; + break; + case 0x1: + str = "Wake due to unexpected event"; + break; + case 0x2: + str = "Remote wake due to peer device connection"; + break; + default: + str = "Unknown wake reason"; + break; + } + + print_field("Wake reason: %s (%d)", str, wake_reason); + mgmt_print_address(data, addr_type); +} + static const struct mgmt_data mgmt_event_table[] = { { 0x0001, "Command Complete", mgmt_command_complete_evt, 3, false }, @@ -13863,6 +13914,10 @@ static const struct mgmt_data mgmt_event_table[] = { mgmt_exp_feature_changed_evt, 20, true }, { 0x002a, "Device Flags Changed", mgmt_device_flags_changed_evt, 15, true }, + { 0x002d, "Controller Suspended", + mgmt_controller_suspend_evt, 1, true }, + { 0x002e, "Controller Resumed", + mgmt_controller_resume_evt, 8, true }, { } }; -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eF5QLjdkPF/WxAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 01:28:55 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8Pv6LDdkPF/VeAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 01:28:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 58F3F553C0; Wed, 19 Aug 2020 01:28:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727042AbgHRX2f (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 19:28:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726703AbgHRX2c (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 19:28:32 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DE7DC061343 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:28:32 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id mw10so241886pjb.2 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k57/y/SsN2qwSG5z4+5MymWQ2jeBayi2s6+jtaZ++Vw=; b=mrGQe2t7KeMs4Z1NzHb2h5/IguHsfUxjuYsNK6bku6s816GKgQ2ojnWfSvVmpm6deq zTLM8tfGCp/1Je4uvAlrDcEwZiJahtHyeehneHcpnJ5t8Q+meHxGw2es+HzxhUGLCi0B Z4mcTtgaLN6yMpHVNw7i/9vXF81okVLOSF/V8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k57/y/SsN2qwSG5z4+5MymWQ2jeBayi2s6+jtaZ++Vw=; b=LFuudMnfC9Yxvd9sScrdwRUgidX8/swqlEdla7x0hZxbYTqqa4IjZwCqgwraTp+oke iRtpNTRJtJSsoBraW2zMUsMS2y5zoz3jslLd0cm9dUrcCX5xbTPq08Izx81PIxrDOzxZ YcqrbJ0XBsuBYSottiCzLNQsET3nRuRYho2uR+L04LOWOtTbp7M5S7X2u9EvSV9dFI6I ErgT7pQYP7wkcZwuyBJ24PmATl6EEdDxveGKq2L2Gk6X7q42Ye05Xug4ISXeKXe9HZ/o GnMryP0JAddLwyYs4damYPcT3HVx8ZZzpuy/xuQoKy4XaUN/jYI9aihSyinc4NblevcR W1AA== X-Gm-Message-State: AOAM533welZQyhBYbeQqmvRXJwCATROu/WcmHxCHlNLJ9PyF5OXE5Fpi bFVNgaXVeH8owgCtUgmbZtEIEA== X-Google-Smtp-Source: ABdhPJwk56f+fzm7Lq8Z3SUusSK/WxVHP03g/fi1GF8jyAXVUC4ASuIy/zFLdoc9RYkfy3xIZkSABA== X-Received: by 2002:a17:90b:803:: with SMTP id bk3mr1804778pjb.57.1597793311771; Tue, 18 Aug 2020 16:28:31 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 30sm904747pjz.24.2020.08.18.16.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 16:28:31 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v2 3/3] policy: Reconnect audio on controller resume Date: Tue, 18 Aug 2020 16:28:22 -0700 Message-Id: <20200818162807.Bluez.v2.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog In-Reply-To: <20200818232822.1645054-1-abhishekpandit@chromium.org> References: <20200818232822.1645054-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: 58F3F553C0 X-Rspamd-UID: 3fde9e During system suspend, all peer devices are disconnected. On resume, HID devices will reconnect but audio devices stay disconnected. As a quality of life improvement, mark audio devices that were disconnected due to suspend and attempt to reconnect them when the controller resumes (after a delay for better co-existence with Wi-Fi). Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Changes in v2: - Refactored to use policy instead of connecting directly in adapter plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ src/adapter.h | 6 +++++ src/main.c | 1 + src/main.conf | 9 +++++++ 5 files changed, 121 insertions(+), 4 deletions(-) diff --git a/plugins/policy.c b/plugins/policy.c index de51e58b9..b07a997b9 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -75,6 +75,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; static int *reconnect_intervals = NULL; static size_t reconnect_intervals_len = 0; +static const int default_reconnect_delay = 5; +static int resume_reconnect_delay = 5; + static GSList *reconnects = NULL; static unsigned int service_id = 0; @@ -93,6 +96,8 @@ struct policy_data { uint8_t ct_retries; guint tg_timer; uint8_t tg_retries; + + bool reconnect_on_resume; }; static struct reconnect_data *reconnect_find(struct btd_device *dev) @@ -214,6 +219,7 @@ static gboolean policy_connect_sink(gpointer user_data) data->sink_timer = 0; data->sink_retries++; + data->reconnect_on_resume = false; service = btd_device_get_service(data->dev, A2DP_SINK_UUID); if (service != NULL) @@ -222,16 +228,20 @@ static gboolean policy_connect_sink(gpointer user_data) return FALSE; } -static void policy_set_sink_timer(struct policy_data *data) +static void policy_set_sink_timer_internal(struct policy_data *data, int timeout) { if (data->sink_timer > 0) g_source_remove(data->sink_timer); - data->sink_timer = g_timeout_add_seconds(SINK_RETRY_TIMEOUT, - policy_connect_sink, + data->sink_timer = g_timeout_add_seconds(timeout, policy_connect_sink, data); } +static void policy_set_sink_timer(struct policy_data *data) +{ + policy_set_sink_timer_internal(data, SINK_RETRY_TIMEOUT); +} + static void sink_cb(struct btd_service *service, btd_service_state_t old_state, btd_service_state_t new_state) { @@ -743,10 +753,30 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) static void disconnect_cb(struct btd_device *dev, uint8_t reason) { struct reconnect_data *reconnect; + struct btd_service *service; + struct policy_data *data; + bool do_reconnect = false; DBG("reason %u", reason); - if (reason != MGMT_DEV_DISCONN_TIMEOUT) + switch(reason) { + case MGMT_DEV_DISCONN_LOCAL_HOST: + case MGMT_DEV_DISCONN_REMOTE: + do_reconnect = true; + break; + /* Disconnect due to suspend will queue reconnect on resume for a2dp */ + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: + service = btd_device_get_service(dev, A2DP_SINK_UUID); + if (service && (data = policy_get_data(dev))) { + data->reconnect_on_resume = true; + } + break; + /* All other cases do not result in reconnect */ + default: + break; + } + + if (!do_reconnect) return; reconnect = reconnect_find(dev); @@ -761,6 +791,23 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) reconnect_set_timer(reconnect); } +static void controller_resume_cb(uint8_t wake_reason, const bdaddr_t *addr, + const uint8_t addr_type) +{ + struct btd_device *dev; + GSList *l; + + /* Check if any devices needed to be reconnected on resume */ + for (l = devices; l; l = g_slist_next(l)) { + struct policy_data *data = l->data; + + if (data->reconnect_on_resume) { + policy_set_sink_timer_internal(data, + resume_reconnect_delay); + } + } +} + static void conn_fail_cb(struct btd_device *dev, uint8_t status) { struct reconnect_data *reconnect; @@ -854,9 +901,17 @@ static int policy_init(void) auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", NULL); + resume_reconnect_delay = g_key_file_get_integer( + conf, "Policy", "ReconnectAudioDelay", &gerr); + + if (gerr) { + g_clear_error(&gerr); + resume_reconnect_delay = default_reconnect_delay; + } done: if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { btd_add_disconnect_cb(disconnect_cb); + btd_add_controller_resume_cb(controller_resume_cb); btd_add_conn_fail_cb(conn_fail_cb); } @@ -869,6 +924,7 @@ done: static void policy_exit(void) { btd_remove_disconnect_cb(disconnect_cb); + btd_remove_controller_resume_cb(controller_resume_cb); btd_remove_conn_fail_cb(conn_fail_cb); if (reconnect_uuids) diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..7526feb9e 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -139,6 +139,7 @@ static GSList *adapter_drivers = NULL; static GSList *disconnect_list = NULL; static GSList *conn_fail_list = NULL; +static GSList *controller_resume_list = NULL; struct link_key_info { bdaddr_t bdaddr; @@ -8766,6 +8767,45 @@ static void connected_callback(uint16_t index, uint16_t length, eir_data_free(&eir_data); } +static void controller_resume_notify(const uint8_t wake_reason, + const bdaddr_t *addr, + const uint8_t addr_type) +{ + GSList *l; + + for (l = controller_resume_list; l; l = g_slist_next(l)) { + btd_controller_resume_cb resume_cb = l->data; + resume_cb(wake_reason, addr, addr_type); + } +} + +static void controller_resume_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_ev_controller_resume *ev = param; + struct btd_adapter *adapter = user_data; + + if (length < sizeof(*ev)) { + btd_error(adapter->dev_id, "Too small device resume event"); + return; + } + + DBG("Controller resume with wake event 0x%x", ev->wake_reason); + + controller_resume_notify(ev->wake_reason, &ev->addr.bdaddr, + ev->addr.type); +} + +void btd_add_controller_resume_cb(btd_controller_resume_cb func) +{ + controller_resume_list = g_slist_append(controller_resume_list, func); +} + +void btd_remove_controller_resume_cb(btd_controller_resume_cb func) +{ + controller_resume_list = g_slist_remove(controller_resume_list, func); +} + static void device_blocked_callback(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9389,6 +9429,11 @@ static void read_info_complete(uint8_t status, uint16_t length, user_passkey_notify_callback, adapter, NULL); + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, + adapter->dev_id, + controller_resume_callback, + adapter, NULL); + set_dev_class(adapter); set_name(adapter, btd_adapter_get_name(adapter)); diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..5527e4205 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -67,6 +67,12 @@ typedef void (*btd_conn_fail_cb) (struct btd_device *device, uint8_t status); void btd_add_conn_fail_cb(btd_conn_fail_cb func); void btd_remove_conn_fail_cb(btd_conn_fail_cb func); +typedef void (*btd_controller_resume_cb)(const uint8_t wake_reason, + const bdaddr_t *addr, + const uint8_t addr_type); +void btd_add_controller_resume_cb(btd_controller_resume_cb func); +void btd_remove_controller_resume_cb(btd_controller_resume_cb func); + struct btd_adapter *adapter_find(const bdaddr_t *sba); struct btd_adapter *adapter_find_by_id(int id); void adapter_foreach(adapter_cb func, gpointer user_data); diff --git a/src/main.c b/src/main.c index 2c083de67..a1c3e7e9f 100644 --- a/src/main.c +++ b/src/main.c @@ -131,6 +131,7 @@ static const char *policy_options[] = { "ReconnectAttempts", "ReconnectIntervals", "AutoEnable", + "ReconnectAudioDelay", NULL }; diff --git a/src/main.conf b/src/main.conf index f41203b96..8d74a2aec 100644 --- a/src/main.conf +++ b/src/main.conf @@ -198,3 +198,12 @@ # This includes adapters present on start as well as adapters that are plugged # in later on. Defaults to 'false'. #AutoEnable=false + +# Audio devices that were disconnected due to suspend will be reconnected on +# resume. ReconnectAudioDelay determines the delay between when the controller +# resumes from suspend and a connection attempt is made. A longer delay can be +# better for co-existence with Wi-Fi. +# The value is in seconds. +# Default: 5 +#ReconnectAudioDelay = 5 + -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AC4VF5llPF+M/QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 01:34:49 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iPFXFZllPF8zFgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 01:34:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D32D454472; Wed, 19 Aug 2020 01:34:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727078AbgHRXea (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 19:34:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726632AbgHRXea (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 19:34:30 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8ACFC061342 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:34:29 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id a1so11043202vsp.4 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cB70dETR/NyGQeHCHTARFj9L+SQvd7OlAWQERQoCVII=; b=VH/aoSyZVjORXv3NGcpvObwwphjJTPh8Teb99rTAe6HRr/0164LWsOX0ahj5q7dRDH 5XIXK3BbjyjgmjpUwj+nAZSn4w6cRWSM6sGsH3NJe0BMbCbtUqKkHOyOIsqpouIwIB9O 4HAUlPnDMdu4VX491vMC+FOMEBW2rpYRT6IV0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cB70dETR/NyGQeHCHTARFj9L+SQvd7OlAWQERQoCVII=; b=nqWKrnCSAnmem4Z4zprGMyAxYcNkjPjzj5olVIMmSYStX2ldDFwnrXm+bKBlAO65p2 mLDxJ0k+O8NBIwOQ/qi+0MLCJ9BZ0ymJQ6BhIVys9eRaWaX8VcZcxoy2tf75mWGw7oe8 m0Ry08nbFOHY6ZBtGDgESHo8ABKCfDHL84/ahKCtHdhY+tHpvrq2Rwq9YBxrSgm2hb/3 xJ/ZFqzBt7FOj6du4GG8phkBICUro1Zw/gYAHvrxMVdSJdrkwu4Uvhai/ThGoTSRfalW qi+zgopxQ1bi7DHAJWVDtcky7/BM6aS//DBfJPFgVmYoGY9mPkWDVMGZRtZMZXvtVMMV t4Ag== X-Gm-Message-State: AOAM532b9/becparWHgDrlz+L3MPztwZAq+xcgaF1rBId0dBnvWEzvXh gXPq0hAR8yCROVnRdvakHayR5OBhU1hoJjfdQTFfRg== X-Google-Smtp-Source: ABdhPJzHyqzCkUdY55haN8OFBGZb0CYfaDh2JhndlSCGSs7EgCkjOFsKH6Ao88fQ+4pSMDiQMP+cyYhtv/6vgWxYkag= X-Received: by 2002:a05:6102:311a:: with SMTP id e26mr13531599vsh.86.1597793668644; Tue, 18 Aug 2020 16:34:28 -0700 (PDT) MIME-Version: 1.0 References: <20200729014225.1842177-1-abhishekpandit@chromium.org> <CANFp7mV0TP-WbBWGSpduERaf9-KBXevhG7xKvjkMrqrtWWkZ5w@mail.gmail.com> In-Reply-To: <CANFp7mV0TP-WbBWGSpduERaf9-KBXevhG7xKvjkMrqrtWWkZ5w@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Tue, 18 Aug 2020 16:34:17 -0700 Message-ID: <CANFp7mW3jXf1Djp=j3nYRzzoJAptJ8Z2JJCP+N6pMHGWXx=9cg@mail.gmail.com> Subject: Re: [PATCH 0/3] Bluetooth: Emit events for suspend/resume To: Marcel Holtmann <marcel@holtmann.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev <netdev@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: D32D454472 X-Rspamd-UID: 2e674b Hi Marcel, Please review this patch. A newer series for how the controller resume event will be used is available at https://patchwork.kernel.org/project/bluetooth/list/?series=334811 Besides usage in bluez, these events will also make debugging and testing suspend/resume for Bluez easier (i.e. finding spurious wakes due to BT in suspend stress tests, asserting that wakeup from peers occurred as expected in tests) Abhishek On Tue, Aug 4, 2020 at 10:11 AM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Hi, > > Gentle reminder that this is waiting for feedback. Related userspace > changes are here to see how we plan on using it: > https://patchwork.kernel.org/project/bluetooth/list/?series=325777 > > Thanks > Abhishek > > On Tue, Jul 28, 2020 at 6:42 PM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > > > Hi Marcel, > > > > This series adds the suspend/resume events suggested in > > https://patchwork.kernel.org/patch/11663455/. > > > > I have tested it with some userspace changes that monitors the > > controller resumed event to trigger audio device reconnection and > > verified that the events are correctly emitted. > > > > Please take a look. > > Abhishek > > > > > > Abhishek Pandit-Subedi (3): > > Bluetooth: Add mgmt suspend and resume events > > Bluetooth: Add suspend reason for device disconnect > > Bluetooth: Emit controller suspend and resume events > > > > include/net/bluetooth/hci_core.h | 6 +++ > > include/net/bluetooth/mgmt.h | 16 +++++++ > > net/bluetooth/hci_core.c | 26 +++++++++++- > > net/bluetooth/hci_event.c | 73 ++++++++++++++++++++++++++++++++ > > net/bluetooth/mgmt.c | 28 ++++++++++++ > > 5 files changed, 148 insertions(+), 1 deletion(-) > > > > -- > > 2.28.0.rc0.142.g3c755180ce-goog > > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IJyBEpVpPF8HEwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 01:51:49 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id cGjLEJVpPF9KRgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 01:51:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 27259A1484; Wed, 19 Aug 2020 01:51:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727122AbgHRXvo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 19:51:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726847AbgHRXvl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 19:51:41 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A81CC061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:51:41 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id j16so4526526ooc.7 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oDxCTY7BfBW9Pv/dYaiQwuSp8dNOVAO05Nfr5H416ME=; b=R33zsjkDwjbxIyT9Qh0CZvO2RfEhuzPt0E6254aDha7sScFIsooC8LSibHXKqESwAW k4Ce+abpv7C3FwlwjaWrn3fmraECFSiCuYRTppscIc5T7pSBg7s0POIvt/Nlypv7idl5 Q01c5rCpkI8mIIynikv73A1dZTsj/PCBhExxIiuLNvHuU1ZKY2glM7NvEzT6lqF84f+4 OhHcu0CCdyjCQN6qpOqn50pmr6HuHuEby0rks7/whsrjATAfDmR//NkUlNVLD+K0ydLF /G4OUq+TQf648ZL83YNbjky/0HpCG75WlGPOR4lQV4tIsQ749YXl0FO7KqfqMN1bx9I3 oNbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oDxCTY7BfBW9Pv/dYaiQwuSp8dNOVAO05Nfr5H416ME=; b=nvFADRhUviwYHOjCdnmxn60Tac7/0UGx0+UB/8GdXZ37Z58Lg1WErtSPixR7N5XLWR e8xD6BzoI/VyBmDfXSzEeUB4At/SfI6gsrKKmAUYSvTbfCdmCZiX0FGh2jC2ws1Na/G9 +j86qHxznQmBH8FCsr2imTurRmsa//tbynuhHLZD4zKDEtH0EP+/iBjqEp5WXJ2/yxri 8170ubO0Jku8sHAKWat8YTQGaaPTxozR/LrO7D4t1afT9Mc2imZayE/D7C4/Z7TRrOxZ H85tZpgadyo+u6frkbdP/MiV6fFFMgX2UTDBP699m6LSdLOvA2Ps6Ybevo4YXbT/PNoC 3Wwg== X-Gm-Message-State: AOAM533ou2IwAea+WXWwvdiM4Vdboo79a4hXaj1XwskOWAQQKBVtib1K 4DRljCTOmVtXHfxCT92PJNl4dL8ddO77PDQTFG0= X-Google-Smtp-Source: ABdhPJxNmKShFCpTA77Cg1JH7HLwjPKVLM5vgGNdqZqjTSkxoH8DaOo7MuRw7ccTwCLiR4+iFVCG6nBU5wVL0P6wGss= X-Received: by 2002:a4a:380b:: with SMTP id c11mr16684695ooa.17.1597794700230; Tue, 18 Aug 2020 16:51:40 -0700 (PDT) MIME-Version: 1.0 References: <20200818153257.Bluez.v3.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> In-Reply-To: <20200818153257.Bluez.v3.1.I254123a1c85e8cb22739cbbb1ffa2f56ac41faa8@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 18 Aug 2020 16:51:29 -0700 Message-ID: <CABBYNZJeEB82pDBT4v83T=pnMFyEHxdpoAJ_t-JPSnDTjtGLow@mail.gmail.com> Subject: Re: [Bluez PATCH v3 1/2] device: Don't browse SDP if HIDSDPDisable is set To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.66 / 15.00 / 200.00 X-Rspamd-Queue-Id: 27259A1484 X-Rspamd-UID: 0bf266 Hi Archie, On Tue, Aug 18, 2020 at 12:34 AM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > According to the HID1.1 spec, part 5.3.4.9: > The HIDSDPDisable attribute is a Boolean value, which indicates > whether connection to the SDP channel and Control or Interrupt > channels are mutually exclusive. This feature supports Bluetooth > HID devices that have minimal resources, and multiplex those > resources between servicing the initialization (SDP) and runtime > (Control and Interrupt) channels. > > However, Bluez still tries to connect SDP upon HID connection, > regardless of the existence of the HIDSDPDisable attribute. > > This patch prevents the connection of SDP after HID has been > established, if the device has HIDSDPDisable attribute. > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > --- > > Changes in v3: None > Changes in v2: > * Renaming passive_sdp_discovery to refresh_discovery > > profiles/input/device.c | 3 +++ > src/device.c | 11 +++++++++-- > src/device.h | 1 + > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/profiles/input/device.c b/profiles/input/device.c > index 6ec0a4c63..5e47b88f2 100644 > --- a/profiles/input/device.c > +++ b/profiles/input/device.c > @@ -1373,6 +1373,9 @@ static struct input_device *input_device_new(struct btd_service *service) > /* Initialize device properties */ > extract_hid_props(idev, rec); > > + if (idev->disable_sdp) > + device_set_refresh_discovery(device, false); > + > return idev; > } > > diff --git a/src/device.c b/src/device.c > index 2237a7670..52dfea18f 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -195,6 +195,7 @@ struct btd_device { > bool le; > bool pending_paired; /* "Paired" waiting for SDP */ > bool svc_refreshed; > + bool refresh_discovery; > > /* Manage whether this device can wake the system from suspend. > * - wake_support: Requires a profile that supports wake (i.e. HID) > @@ -1472,7 +1473,6 @@ static gboolean dev_property_wake_allowed_exist( > return device_get_wake_support(device); > } > > - > static gboolean disconnect_all(gpointer user_data) > { > struct btd_device *device = user_data; > @@ -1805,7 +1805,7 @@ done: > btd_error_failed(dev->connect, strerror(-err))); > } else { > /* Start passive SDP discovery to update known services */ > - if (dev->bredr && !dev->svc_refreshed) > + if (dev->bredr && !dev->svc_refreshed && dev->refresh_discovery) > device_browse_sdp(dev, NULL); > g_dbus_send_reply(dbus_conn, dev->connect, DBUS_TYPE_INVALID); > } > @@ -2572,6 +2572,11 @@ done: > browse_request_free(req); > } > > +void device_set_refresh_discovery(struct btd_device *dev, bool refresh) > +{ > + dev->refresh_discovery = refresh; > +} > + > static void device_set_svc_refreshed(struct btd_device *device, bool value) > { > if (device->svc_refreshed == value) > @@ -4071,6 +4076,8 @@ static struct btd_device *device_new(struct btd_adapter *adapter, > device->db_id = gatt_db_register(device->db, gatt_service_added, > gatt_service_removed, device, NULL); > > + device->refresh_discovery = true; > + > return btd_device_ref(device); > } > > diff --git a/src/device.h b/src/device.h > index cb8d884e8..5ba2d7fe0 100644 > --- a/src/device.h > +++ b/src/device.h > @@ -145,6 +145,7 @@ void device_set_wake_override(struct btd_device *device, bool wake_override); > void device_set_wake_allowed(struct btd_device *device, bool wake_allowed, > guint32 id); > void device_set_wake_allowed_complete(struct btd_device *device); > +void device_set_refresh_discovery(struct btd_device *dev, bool refresh); > > typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal, > void *user_data); > -- > 2.28.0.220.ged08abb693-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cIC7EsJpPF8HEwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 01:52:34 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id CDDzEMJpPF9KRgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 01:52:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 544F4A1486; Wed, 19 Aug 2020 01:52:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726972AbgHRXw2 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 19:52:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726847AbgHRXw1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 19:52:27 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88AFFC061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:52:27 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id o21so19475250oie.12 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 16:52:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=g7ZFIgm4SrssRH25wt0REgaY4NV3G1qYm3x1OTRlzQw=; b=f1wiDErKi98kZp0IRCVCqe4xLdQ9GcAPFaI3gqTXefAmdBWCRrxvCegthDc5Nwtv1j C5Iap963G0j9vN0lZGtwxkC63ftP3CGaEUfeYEfH6/dluX6NUYBxS2UXBA12jGnR7vai vDXjqB2ptNMnOXoa3xn5z7Gu5heKxldbbjWbDwfyZZQEKZEcQUjXCAPzB2rlhK5bZuuQ JgI0h0tVbVEnOsCLXttpH2m0HqIv884efIuzJ81M9VKNsdI0ieYYJ9O1uUO8PlRR4JyS b34553udP6cookDx/3GEpr0NkMctRNKGoybLiGFZ0bncRHVdCnwP3A9cY9WrE20dW07d yDZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=g7ZFIgm4SrssRH25wt0REgaY4NV3G1qYm3x1OTRlzQw=; b=jJ1jIAPM9iMzpS7iTsGekq5JEynh27LqmoIDgJnNuGtDwbuc5JBGKfv404+kfWdCuJ nHO3CPmSrWpmxV+S6m+vrkmyTlwVuIXl6azV+IpXkKFudyqN+hn3+4U94upwgdlWlZL+ pdBu44NB+iZ/gEsjVpf1EjeR2Vo0mFO5OfvvUo1MNElNTfX8MGPrUWBA8RWRipZ6zw/2 q+7RzrOoHtO+2wX1kemCZzdTbJq087FnsparKAywlk2BAj1KkfpoG/apfGy/U48JDv1e H6uNb7QtBpOvoYzpzng21i0Qk1soxQTj9oEE3NIjbPZojzoL8eycG4on4qFtA5q6BAV0 nskQ== X-Gm-Message-State: AOAM532Fqd0vcDE0FCzWYiuHZv4c1rNUjqomUKBPw0vrSc+XBzulPNQH 5+MhR9U5/VxD9zNA0Up+zgTcXZFQaSE0hCP/azI= X-Google-Smtp-Source: ABdhPJyX7YD6vmZMsJTwcT958nTvyuF54Nw92ktQLdnE2jjqyIDljGbSHBHLv4mcmGmEr6nFBvfITlfz1vTLCKAw6HQ= X-Received: by 2002:aca:cc50:: with SMTP id c77mr1637547oig.152.1597794746808; Tue, 18 Aug 2020 16:52:26 -0700 (PDT) MIME-Version: 1.0 References: <20200817231822.BlueZ.v3.1.I716fc87b0c97e5349a04766a61ecad1f5b0fd28e@changeid> In-Reply-To: <20200817231822.BlueZ.v3.1.I716fc87b0c97e5349a04766a61ecad1f5b0fd28e@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 18 Aug 2020 16:52:16 -0700 Message-ID: <CABBYNZ+JLGtby19K0skYJj1r70tF=XwqdwhMP07tS89Wh76A4w@mail.gmail.com> Subject: Re: [BlueZ PATCH v3] shared/ad: move MAX_ADV_DATA_LEN macro to the header To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: 544F4A1486 X-Rspamd-UID: 94c73a Hi Miao-chen, On Mon, Aug 17, 2020 at 11:23 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > This moves MAX_ADV_DATA_LEN macro to src/shared/ad.h and rename it to > BT_AD_MAX_DATA_LEN. > --- > Hi Maintainers, > > In order to avoid duplicate definition of the maximum data length of > advertisement for the following series of advertisement monitor API, > we'd like to reuse the one in shared/ad. > > Thanks, > Miao > > Changes in v3: > - Fix occurrences of MAX_ADV_DATA_LEN. > > Changes in v2: > - Rename the macro to BT_AD_MAX_DATA_LEN. > > src/shared/ad.c | 18 ++++++++---------- > src/shared/ad.h | 2 ++ > 2 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/src/shared/ad.c b/src/shared/ad.c > index 8d276842e..14a2709b1 100644 > --- a/src/shared/ad.c > +++ b/src/shared/ad.c > @@ -33,8 +33,6 @@ > #include "src/shared/queue.h" > #include "src/shared/util.h" > > -#define MAX_ADV_DATA_LEN 31 > - > struct bt_ad { > int ref_count; > char *name; > @@ -257,8 +255,8 @@ static size_t name_length(const char *name, size_t *pos) > > len = 2 + strlen(name); > > - if (len > MAX_ADV_DATA_LEN - *pos) > - len = MAX_ADV_DATA_LEN - *pos; > + if (len > BT_AD_MAX_DATA_LEN - *pos) > + len = BT_AD_MAX_DATA_LEN - *pos; > > return len; > } > @@ -426,9 +424,9 @@ static void serialize_name(const char *name, uint8_t *buf, uint8_t *pos) > return; > > len = strlen(name); > - if (len > MAX_ADV_DATA_LEN - (*pos + 2)) { > + if (len > BT_AD_MAX_DATA_LEN - (*pos + 2)) { > type = BT_AD_NAME_SHORT; > - len = MAX_ADV_DATA_LEN - (*pos + 2); > + len = BT_AD_MAX_DATA_LEN - (*pos + 2); > } > > buf[(*pos)++] = len + 1; > @@ -478,7 +476,7 @@ uint8_t *bt_ad_generate(struct bt_ad *ad, size_t *length) > > *length = calculate_length(ad); > > - if (*length > MAX_ADV_DATA_LEN) > + if (*length > BT_AD_MAX_DATA_LEN) > return NULL; > > adv_data = malloc0(*length); > @@ -586,7 +584,7 @@ bool bt_ad_add_manufacturer_data(struct bt_ad *ad, uint16_t manufacturer_id, > if (!ad) > return false; > > - if (len > (MAX_ADV_DATA_LEN - 2 - sizeof(uint16_t))) > + if (len > (BT_AD_MAX_DATA_LEN - 2 - sizeof(uint16_t))) > return false; > > new_data = queue_find(ad->manufacturer_data, manufacturer_id_data_match, > @@ -723,7 +721,7 @@ bool bt_ad_add_service_data(struct bt_ad *ad, const bt_uuid_t *uuid, void *data, > if (!ad) > return false; > > - if (len > (MAX_ADV_DATA_LEN - 2 - (size_t)bt_uuid_len(uuid))) > + if (len > (BT_AD_MAX_DATA_LEN - 2 - (size_t)bt_uuid_len(uuid))) > return false; > > new_data = queue_find(ad->service_data, service_uuid_match, uuid); > @@ -942,7 +940,7 @@ bool bt_ad_add_data(struct bt_ad *ad, uint8_t type, void *data, size_t len) > if (!ad) > return false; > > - if (len > (MAX_ADV_DATA_LEN - 2)) > + if (len > (BT_AD_MAX_DATA_LEN - 2)) > return false; > > for (i = 0; i < sizeof(type_blacklist); i++) { > diff --git a/src/shared/ad.h b/src/shared/ad.h > index 19aa1d035..17e3b631b 100644 > --- a/src/shared/ad.h > +++ b/src/shared/ad.h > @@ -27,6 +27,8 @@ > #include "lib/bluetooth.h" > #include "lib/uuid.h" > > +#define BT_AD_MAX_DATA_LEN 31 > + > #define BT_AD_FLAGS 0x01 > #define BT_AD_UUID16_SOME 0x02 > #define BT_AD_UUID16_ALL 0x03 > -- > 2.26.2 Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8AImNw5sPF+ETQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 02:02:22 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 6NWTNQ5sPF+qRgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 02:02:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7F1C5A020E; Wed, 19 Aug 2020 02:02:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727082AbgHSACQ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 20:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726676AbgHSACP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 20:02:15 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2364FC061342 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 17:02:14 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id i10so4961076pgk.1 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 17:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=yQ4LWb684mNHZcH5T+SHWEtZWJfEIJln+Io+MEEnEtM=; b=WBTJdZValcXOX61h8fx+y7EXUCnH8IOQfgo/Yl05CnDlYSpGOu2iTlixktq1wdqxjF h+LHNafSUclY9dgjd1iJF4UZGNjOhNC+dyZy3yUqNWFSRTZh153Xi5GpYyCAgWUuK77s G1FKdvqpbGNwExuJVxjnHzYGDaShX/rSlTPwIO0M3syjLJFINwqECEq3P7JYEWtciyJN MSo07VzE+fCA2nptWv07k0FCfArF8tjxWBKI9vwZCQCvemDhRdxuT6LgU08lMeFimezE vfeJ3KmambguXRfSrZuQt5KQ01nq5eZaJAW8tsUzQh6BrjnRbKqiluSFkfrzVbhOKqC0 89LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=yQ4LWb684mNHZcH5T+SHWEtZWJfEIJln+Io+MEEnEtM=; b=a36mcCzwtg4t+Xy89mEFYkNdTfeIlCb9/GyA1NTS0UV7Ldz1MfoThpV/UiEylPpWFK SrMfVMiZqfJ3SmG5VurjnAqDU8lOsPJmsg9A4mjCfmv0vKIrjOjItjUQoY8/VTUksNPf hk+BLZMvbBe13Bh1EWGC7XwJrjn7sZqFwD4Cnk0FtJu7OJXD9u41ptO2v20r4CtzQ9cN LX5afDNQgec/+qQoWskhqYtWRiqYunojF6aHZ/Xxh48Pz3HUpJdrUGf7H8+5AOJpaKUU g7DHDp4t4Jm+OygPZ9So2z/KsDnfH5fhwTPRSr8Zh1OAetDAoK6Oa1ACjE7iMAOig/vO xT7w== X-Gm-Message-State: AOAM530G+zPYgMkoAOx0FSuNfu6689JSku1p1A+WVgVL4UpOdnTy4CjB Bkwi7aQSabpmNRm0gpH1446d7JDvjoo= X-Google-Smtp-Source: ABdhPJygWvso55P70N3AzCgnUJ/1MBN4I7ixIVtnqxal/78ACpbLYMRBTq3IOoN5US3PSF2Ssh+3HA== X-Received: by 2002:a65:4502:: with SMTP id n2mr13862284pgq.132.1597795332966; Tue, 18 Aug 2020 17:02:12 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id d80sm25957673pfd.22.2020.08.18.17.02.12 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 17:02:12 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 1/3] sbc: Add initial code for SSE primitives Date: Tue, 18 Aug 2020 17:02:10 -0700 Message-Id: <20200819000212.211485-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.47 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7F1C5A020E X-Rspamd-UID: 6ddbfb From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> --- Makefile.am | 1 + sbc/sbc_primitives.c | 18 +- sbc/sbc_primitives_mmx.c | 49 +----- sbc/sbc_primitives_sse.c | 365 +++++++++++++++++++++++++++++++++++++++ sbc/sbc_primitives_sse.h | 38 ++++ 5 files changed, 428 insertions(+), 43 deletions(-) create mode 100644 sbc/sbc_primitives_sse.c create mode 100644 sbc/sbc_primitives_sse.h diff --git a/Makefile.am b/Makefile.am index 342043d..7ff0c7d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,6 +14,7 @@ sbc_headers = sbc/sbc.h sbc_sources = sbc/sbc.c sbc/sbc_private.h sbc/sbc_math.h sbc/sbc_tables.h \ sbc/sbc_primitives.h sbc/sbc_primitives.c \ + sbc/sbc_primitives_sse.h sbc/sbc_primitives_sse.c \ sbc/sbc_primitives_mmx.h sbc/sbc_primitives_mmx.c \ sbc/sbc_primitives_iwmmxt.h sbc/sbc_primitives_iwmmxt.c \ sbc/sbc_primitives_neon.h sbc/sbc_primitives_neon.c \ diff --git a/sbc/sbc_primitives.c b/sbc/sbc_primitives.c index ff343cf..c9d1045 100644 --- a/sbc/sbc_primitives.c +++ b/sbc/sbc_primitives.c @@ -33,6 +33,7 @@ #include "sbc_tables.h" #include "sbc_primitives.h" +#include "sbc_primitives_sse.h" #include "sbc_primitives_mmx.h" #include "sbc_primitives_iwmmxt.h" #include "sbc_primitives_neon.h" @@ -590,6 +591,19 @@ static int sbc_calc_scalefactors_j( return joint; } +static void sbc_init_primitives_x86(struct sbc_encoder_state *state) +{ + __builtin_cpu_init(); + + if (__builtin_cpu_supports("mmx")) + sbc_init_primitives_mmx(state); + +#ifdef SBC_BUILD_WITH_SSE_SUPPORT + if (__builtin_cpu_supports("sse4.2")) + sbc_init_primitives_sse(state); +#endif +} + /* * Detect CPU features and setup function pointers */ @@ -614,9 +628,7 @@ void sbc_init_primitives(struct sbc_encoder_state *state) state->implementation_info = "Generic C"; /* X86/AMD64 optimizations */ -#ifdef SBC_BUILD_WITH_MMX_SUPPORT - sbc_init_primitives_mmx(state); -#endif + sbc_init_primitives_x86(state); /* ARM optimizations */ #ifdef SBC_BUILD_WITH_ARMV6_SUPPORT diff --git a/sbc/sbc_primitives_mmx.c b/sbc/sbc_primitives_mmx.c index e2c3e56..6984ce5 100644 --- a/sbc/sbc_primitives_mmx.c +++ b/sbc/sbc_primitives_mmx.c @@ -350,50 +350,19 @@ static void sbc_calc_scalefactors_mmx( __asm__ volatile ("emms\n"); } -static int check_mmx_support(void) +void sbc_init_primitives_mmx(struct sbc_encoder_state *state) { -#ifdef __amd64__ - return 1; /* We assume that all 64-bit processors have MMX support */ -#else - int cpuid_feature_information; - __asm__ volatile ( - /* According to Intel manual, CPUID instruction is supported - * if the value of ID bit (bit 21) in EFLAGS can be modified */ - "pushf\n" - "movl (%%esp), %0\n" - "xorl $0x200000, (%%esp)\n" /* try to modify ID bit */ - "popf\n" - "pushf\n" - "xorl (%%esp), %0\n" /* check if ID bit changed */ - "jz 1f\n" - "push %%eax\n" - "push %%ebx\n" - "push %%ecx\n" - "mov $1, %%eax\n" - "cpuid\n" - "pop %%ecx\n" - "pop %%ebx\n" - "pop %%eax\n" - "1:\n" - "popf\n" - : "=d" (cpuid_feature_information) - : - : "cc"); - return cpuid_feature_information & (1 << 23); -#endif + state->sbc_analyze_4s = sbc_analyze_4b_4s_mmx; + if (state->increment == 1) + state->sbc_analyze_8s = sbc_analyze_1b_8s_mmx_odd; + else + state->sbc_analyze_8s = sbc_analyze_4b_8s_mmx; + state->sbc_calc_scalefactors = sbc_calc_scalefactors_mmx; + state->implementation_info = "MMX"; } +#else void sbc_init_primitives_mmx(struct sbc_encoder_state *state) { - if (check_mmx_support()) { - state->sbc_analyze_4s = sbc_analyze_4b_4s_mmx; - if (state->increment == 1) - state->sbc_analyze_8s = sbc_analyze_1b_8s_mmx_odd; - else - state->sbc_analyze_8s = sbc_analyze_4b_8s_mmx; - state->sbc_calc_scalefactors = sbc_calc_scalefactors_mmx; - state->implementation_info = "MMX"; - } } - #endif diff --git a/sbc/sbc_primitives_sse.c b/sbc/sbc_primitives_sse.c new file mode 100644 index 0000000..42cdb03 --- /dev/null +++ b/sbc/sbc_primitives_sse.c @@ -0,0 +1,365 @@ +/* + * + * Bluetooth low-complexity, subband codec (SBC) library + * + * Copyright (C) 2020 Intel Corporation + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <stdint.h> +#include <limits.h> +#include "sbc.h" +#include "sbc_math.h" +#include "sbc_tables.h" + +#include "sbc_primitives_sse.h" + +/* + * SSE optimizations + */ + +#ifdef SBC_BUILD_WITH_SSE_SUPPORT + +static inline void sbc_analyze_four_sse(const int16_t *in, int32_t *out, + const FIXED_T *consts) +{ + static const SBC_ALIGNED int32_t round_c[2] = { + 1 << (SBC_PROTO_FIXED4_SCALE - 1), + 1 << (SBC_PROTO_FIXED4_SCALE - 1), + }; + __asm__ volatile ( + "movq (%0), %%mm0\n" + "movq 8(%0), %%mm1\n" + "pmaddwd (%1), %%mm0\n" + "pmaddwd 8(%1), %%mm1\n" + "paddd (%2), %%mm0\n" + "paddd (%2), %%mm1\n" + "\n" + "movq 16(%0), %%mm2\n" + "movq 24(%0), %%mm3\n" + "pmaddwd 16(%1), %%mm2\n" + "pmaddwd 24(%1), %%mm3\n" + "paddd %%mm2, %%mm0\n" + "paddd %%mm3, %%mm1\n" + "\n" + "movq 32(%0), %%mm2\n" + "movq 40(%0), %%mm3\n" + "pmaddwd 32(%1), %%mm2\n" + "pmaddwd 40(%1), %%mm3\n" + "paddd %%mm2, %%mm0\n" + "paddd %%mm3, %%mm1\n" + "\n" + "movq 48(%0), %%mm2\n" + "movq 56(%0), %%mm3\n" + "pmaddwd 48(%1), %%mm2\n" + "pmaddwd 56(%1), %%mm3\n" + "paddd %%mm2, %%mm0\n" + "paddd %%mm3, %%mm1\n" + "\n" + "movq 64(%0), %%mm2\n" + "movq 72(%0), %%mm3\n" + "pmaddwd 64(%1), %%mm2\n" + "pmaddwd 72(%1), %%mm3\n" + "paddd %%mm2, %%mm0\n" + "paddd %%mm3, %%mm1\n" + "\n" + "psrad %4, %%mm0\n" + "psrad %4, %%mm1\n" + "packssdw %%mm0, %%mm0\n" + "packssdw %%mm1, %%mm1\n" + "\n" + "movq %%mm0, %%mm2\n" + "pmaddwd 80(%1), %%mm0\n" + "pmaddwd 88(%1), %%mm2\n" + "\n" + "movq %%mm1, %%mm3\n" + "pmaddwd 96(%1), %%mm1\n" + "pmaddwd 104(%1), %%mm3\n" + "paddd %%mm1, %%mm0\n" + "paddd %%mm3, %%mm2\n" + "\n" + "movq %%mm0, (%3)\n" + "movq %%mm2, 8(%3)\n" + : + : "r" (in), "r" (consts), "r" (&round_c), "r" (out), + "i" (SBC_PROTO_FIXED4_SCALE) + : "cc", "memory"); +} + +static inline void sbc_analyze_eight_sse(const int16_t *in, int32_t *out, + const FIXED_T *consts) +{ + static const SBC_ALIGNED int32_t round_c[2] = { + 1 << (SBC_PROTO_FIXED8_SCALE - 1), + 1 << (SBC_PROTO_FIXED8_SCALE - 1), + }; + __asm__ volatile ( + "movq (%0), %%mm0\n" + "movq 8(%0), %%mm1\n" + "movq 16(%0), %%mm2\n" + "movq 24(%0), %%mm3\n" + "pmaddwd (%1), %%mm0\n" + "pmaddwd 8(%1), %%mm1\n" + "pmaddwd 16(%1), %%mm2\n" + "pmaddwd 24(%1), %%mm3\n" + "paddd (%2), %%mm0\n" + "paddd (%2), %%mm1\n" + "paddd (%2), %%mm2\n" + "paddd (%2), %%mm3\n" + "\n" + "movq 32(%0), %%mm4\n" + "movq 40(%0), %%mm5\n" + "movq 48(%0), %%mm6\n" + "movq 56(%0), %%mm7\n" + "pmaddwd 32(%1), %%mm4\n" + "pmaddwd 40(%1), %%mm5\n" + "pmaddwd 48(%1), %%mm6\n" + "pmaddwd 56(%1), %%mm7\n" + "paddd %%mm4, %%mm0\n" + "paddd %%mm5, %%mm1\n" + "paddd %%mm6, %%mm2\n" + "paddd %%mm7, %%mm3\n" + "\n" + "movq 64(%0), %%mm4\n" + "movq 72(%0), %%mm5\n" + "movq 80(%0), %%mm6\n" + "movq 88(%0), %%mm7\n" + "pmaddwd 64(%1), %%mm4\n" + "pmaddwd 72(%1), %%mm5\n" + "pmaddwd 80(%1), %%mm6\n" + "pmaddwd 88(%1), %%mm7\n" + "paddd %%mm4, %%mm0\n" + "paddd %%mm5, %%mm1\n" + "paddd %%mm6, %%mm2\n" + "paddd %%mm7, %%mm3\n" + "\n" + "movq 96(%0), %%mm4\n" + "movq 104(%0), %%mm5\n" + "movq 112(%0), %%mm6\n" + "movq 120(%0), %%mm7\n" + "pmaddwd 96(%1), %%mm4\n" + "pmaddwd 104(%1), %%mm5\n" + "pmaddwd 112(%1), %%mm6\n" + "pmaddwd 120(%1), %%mm7\n" + "paddd %%mm4, %%mm0\n" + "paddd %%mm5, %%mm1\n" + "paddd %%mm6, %%mm2\n" + "paddd %%mm7, %%mm3\n" + "\n" + "movq 128(%0), %%mm4\n" + "movq 136(%0), %%mm5\n" + "movq 144(%0), %%mm6\n" + "movq 152(%0), %%mm7\n" + "pmaddwd 128(%1), %%mm4\n" + "pmaddwd 136(%1), %%mm5\n" + "pmaddwd 144(%1), %%mm6\n" + "pmaddwd 152(%1), %%mm7\n" + "paddd %%mm4, %%mm0\n" + "paddd %%mm5, %%mm1\n" + "paddd %%mm6, %%mm2\n" + "paddd %%mm7, %%mm3\n" + "\n" + "psrad %4, %%mm0\n" + "psrad %4, %%mm1\n" + "psrad %4, %%mm2\n" + "psrad %4, %%mm3\n" + "\n" + "packssdw %%mm0, %%mm0\n" + "packssdw %%mm1, %%mm1\n" + "packssdw %%mm2, %%mm2\n" + "packssdw %%mm3, %%mm3\n" + "\n" + "movq %%mm0, %%mm4\n" + "movq %%mm0, %%mm5\n" + "pmaddwd 160(%1), %%mm4\n" + "pmaddwd 168(%1), %%mm5\n" + "\n" + "movq %%mm1, %%mm6\n" + "movq %%mm1, %%mm7\n" + "pmaddwd 192(%1), %%mm6\n" + "pmaddwd 200(%1), %%mm7\n" + "paddd %%mm6, %%mm4\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm2, %%mm6\n" + "movq %%mm2, %%mm7\n" + "pmaddwd 224(%1), %%mm6\n" + "pmaddwd 232(%1), %%mm7\n" + "paddd %%mm6, %%mm4\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm3, %%mm6\n" + "movq %%mm3, %%mm7\n" + "pmaddwd 256(%1), %%mm6\n" + "pmaddwd 264(%1), %%mm7\n" + "paddd %%mm6, %%mm4\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm4, (%3)\n" + "movq %%mm5, 8(%3)\n" + "\n" + "movq %%mm0, %%mm5\n" + "pmaddwd 176(%1), %%mm0\n" + "pmaddwd 184(%1), %%mm5\n" + "\n" + "movq %%mm1, %%mm7\n" + "pmaddwd 208(%1), %%mm1\n" + "pmaddwd 216(%1), %%mm7\n" + "paddd %%mm1, %%mm0\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm2, %%mm7\n" + "pmaddwd 240(%1), %%mm2\n" + "pmaddwd 248(%1), %%mm7\n" + "paddd %%mm2, %%mm0\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm3, %%mm7\n" + "pmaddwd 272(%1), %%mm3\n" + "pmaddwd 280(%1), %%mm7\n" + "paddd %%mm3, %%mm0\n" + "paddd %%mm7, %%mm5\n" + "\n" + "movq %%mm0, 16(%3)\n" + "movq %%mm5, 24(%3)\n" + : + : "r" (in), "r" (consts), "r" (&round_c), "r" (out), + "i" (SBC_PROTO_FIXED8_SCALE) + : "cc", "memory"); +} + +static inline void sbc_analyze_4b_4s_sse(struct sbc_encoder_state *state, + int16_t *x, int32_t *out, int out_stride) +{ + /* Analyze blocks */ + sbc_analyze_four_sse(x + 12, out, analysis_consts_fixed4_simd_odd); + out += out_stride; + sbc_analyze_four_sse(x + 8, out, analysis_consts_fixed4_simd_even); + out += out_stride; + sbc_analyze_four_sse(x + 4, out, analysis_consts_fixed4_simd_odd); + out += out_stride; + sbc_analyze_four_sse(x + 0, out, analysis_consts_fixed4_simd_even); + + __asm__ volatile ("emms\n"); +} + +static inline void sbc_analyze_4b_8s_sse(struct sbc_encoder_state *state, + int16_t *x, int32_t *out, int out_stride) +{ + /* Analyze blocks */ + sbc_analyze_eight_sse(x + 24, out, analysis_consts_fixed8_simd_odd); + out += out_stride; + sbc_analyze_eight_sse(x + 16, out, analysis_consts_fixed8_simd_even); + out += out_stride; + sbc_analyze_eight_sse(x + 8, out, analysis_consts_fixed8_simd_odd); + out += out_stride; + sbc_analyze_eight_sse(x + 0, out, analysis_consts_fixed8_simd_even); + + __asm__ volatile ("emms\n"); +} + +static inline void sbc_analyze_1b_8s_sse_even(struct sbc_encoder_state *state, + int16_t *x, int32_t *out, int out_stride); + +static inline void sbc_analyze_1b_8s_sse_odd(struct sbc_encoder_state *state, + int16_t *x, int32_t *out, int out_stride) +{ + sbc_analyze_eight_sse(x, out, analysis_consts_fixed8_simd_odd); + state->sbc_analyze_8s = sbc_analyze_1b_8s_sse_even; + + __asm__ volatile ("emms\n"); +} + +static inline void sbc_analyze_1b_8s_sse_even(struct sbc_encoder_state *state, + int16_t *x, int32_t *out, int out_stride) +{ + sbc_analyze_eight_sse(x, out, analysis_consts_fixed8_simd_even); + state->sbc_analyze_8s = sbc_analyze_1b_8s_sse_odd; + + __asm__ volatile ("emms\n"); +} + +static void sbc_calc_scalefactors_sse( + int32_t sb_sample_f[16][2][8], + uint32_t scale_factor[2][8], + int blocks, int channels, int subbands) +{ + static const SBC_ALIGNED int32_t consts[2] = { + 1 << SCALE_OUT_BITS, + 1 << SCALE_OUT_BITS, + }; + int ch, sb; + intptr_t blk; + for (ch = 0; ch < channels; ch++) { + for (sb = 0; sb < subbands; sb += 2) { + blk = (blocks - 1) * (((char *) &sb_sample_f[1][0][0] - + (char *) &sb_sample_f[0][0][0])); + __asm__ volatile ( + "movq (%4), %%mm0\n" + "1:\n" + "movq (%1, %0), %%mm1\n" + "pxor %%mm2, %%mm2\n" + "pcmpgtd %%mm2, %%mm1\n" + "paddd (%1, %0), %%mm1\n" + "pcmpgtd %%mm1, %%mm2\n" + "pxor %%mm2, %%mm1\n" + + "por %%mm1, %%mm0\n" + + "sub %2, %0\n" + "jns 1b\n" + + "movd %%mm0, %k0\n" + "psrlq $32, %%mm0\n" + "bsrl %k0, %k0\n" + "subl %5, %k0\n" + "movl %k0, (%3)\n" + + "movd %%mm0, %k0\n" + "bsrl %k0, %k0\n" + "subl %5, %k0\n" + "movl %k0, 4(%3)\n" + : "+r" (blk) + : "r" (&sb_sample_f[0][ch][sb]), + "i" ((char *) &sb_sample_f[1][0][0] - + (char *) &sb_sample_f[0][0][0]), + "r" (&scale_factor[ch][sb]), + "r" (&consts), + "i" (SCALE_OUT_BITS) + : "cc", "memory"); + } + } + __asm__ volatile ("emms\n"); +} + +void sbc_init_primitives_sse(struct sbc_encoder_state *state) +{ + state->sbc_analyze_4s = sbc_analyze_4b_4s_sse; + if (state->increment == 1) + state->sbc_analyze_8s = sbc_analyze_1b_8s_sse_odd; + else + state->sbc_analyze_8s = sbc_analyze_4b_8s_sse; + state->sbc_calc_scalefactors = sbc_calc_scalefactors_sse; + state->implementation_info = "SSE"; +} + +#else +void sbc_init_primitives_sse(struct sbc_encoder_state *state) +{ +} +#endif diff --git a/sbc/sbc_primitives_sse.h b/sbc/sbc_primitives_sse.h new file mode 100644 index 0000000..8830cfd --- /dev/null +++ b/sbc/sbc_primitives_sse.h @@ -0,0 +1,38 @@ +/* + * + * Bluetooth low-complexity, subband codec (SBC) library + * + * Copyright (C) 2020 Intel Corporation + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __SBC_PRIMITIVES_SSE_H +#define __SBC_PRIMITIVES_SSE_H + +#include "sbc_primitives.h" + +#if defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) && \ + !defined(SBC_HIGH_PRECISION) && (SCALE_OUT_BITS == 15) + +#define SBC_BUILD_WITH_SSE_SUPPORT + +void sbc_init_primitives_sse(struct sbc_encoder_state *encoder_state); + +#endif + +#endif -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GEEzABRsPF+ETQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 02:02:28 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MG+ZOhNsPF9KRgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 02:02:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 098FBA0118; Wed, 19 Aug 2020 02:02:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727776AbgHSACQ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 20:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727012AbgHSACP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 20:02:15 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AFB9C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 17:02:14 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id x25so10765598pff.4 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 17:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=uSA0Ybo7FyRxzr9ClbGhKtFYud7d1Je4lZohhQzo/UQ=; b=rgWMc0GFFP67vj1Er+uBtgmm8BCRFksV5lkiVAqUZFa0jYwCT3u02NWmnXey/rjiS4 mAD1ALPXcraVBpDRtuXEalMRBgcBz212xosKO1M2JX/siZ6dfY+uHwEUIWwYsdZzlyIg ZYyJyLM1dDkiBVPJEn5DV2ky14NPKs1jrHdfqU+4m7s9ZVqAZhLraUN9WYWto5Pa1YmK UQTU5tyijc6R2Xe4dwxmCuDcgExfUkyN2Qt3sZCDMBB5VaX7DpPxnqMgo+Yj2X1c/eu2 10lOmEkmAZkGvG99aMDPEqKfjSUV35VE/PWAlkQ38Qk0Kt0HvaIu5yj7AhYyoTPzeQQB 6ypQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uSA0Ybo7FyRxzr9ClbGhKtFYud7d1Je4lZohhQzo/UQ=; b=m1F/0h3IFSrky/YUyjpcl+hjliLcXPuitmGW9yb0jWEjCF3mZcsGPBEoTmnaIs/m04 MUeC4P9hhBi1amT19NwibNbHmf6fhs6P/0OocZr6VcyHhabrqc9kqpclXzga9rXqmRfl i+xPuya10+nFEEg1K6O0snAKBE7zWkGlY0JZv84KsXRASM4AK8TfN7dkJSJEHUuXmQ2y UAv9UU/hvUueacmWkpsj9vWD02tAkkyJWG6gvRAsGby6Oi9HWFZ+qMXsYPLE2LimasZv Z4CFte4lLbX/rXscfegyS8TwGcy2b4ypw30hTr+O4qtR+bl1CdA8QJHtAho7+dSDnTRF VcqQ== X-Gm-Message-State: AOAM533xpSx3XOvS1S/f3Zaqq8dEPxNBE99sPbwxOqyU97+TrnpY52Th /Dz1XkLYS3Ou9PdAklR3kwui3kiUABg= X-Google-Smtp-Source: ABdhPJyRwLIfLZqQFQe8RGLC/Vlrqb1fALSCzl9JYxTO/F5zL/YK2OqPuK1RoxWBpxp3ad1p8g7pyw== X-Received: by 2002:a62:1dc3:: with SMTP id d186mr17270021pfd.93.1597795333812; Tue, 18 Aug 2020 17:02:13 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id d80sm25957673pfd.22.2020.08.18.17.02.13 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 17:02:13 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 2/3] sbc/sbc_primitives_sse: Optimize sbc_analyze_4s Date: Tue, 18 Aug 2020 17:02:11 -0700 Message-Id: <20200819000212.211485-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200819000212.211485-1-luiz.dentz@gmail.com> References: <20200819000212.211485-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.65 / 15.00 / 200.00 X-Rspamd-Queue-Id: 098FBA0118 X-Rspamd-UID: 5b97aa From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This makes use 128 bit XMM registers whenever possible. $ time src/sbcenc_mmx -s 4 sin_4m.au > /dev/null real 0m1.073s user 0m1.039s sys 0m0.030s === After ==== $ time src/sbcenc -s 4 sin_4m.au > /dev/null real 0m1.049s user 0m1.000s sys 0m0.047s --- sbc/sbc_primitives_sse.c | 58 +++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/sbc/sbc_primitives_sse.c b/sbc/sbc_primitives_sse.c index 42cdb03..2a903e1 100644 --- a/sbc/sbc_primitives_sse.c +++ b/sbc/sbc_primitives_sse.c @@ -38,48 +38,40 @@ static inline void sbc_analyze_four_sse(const int16_t *in, int32_t *out, const FIXED_T *consts) { - static const SBC_ALIGNED int32_t round_c[2] = { + static const SBC_ALIGNED int32_t round_c[4] = { + 1 << (SBC_PROTO_FIXED4_SCALE - 1), + 1 << (SBC_PROTO_FIXED4_SCALE - 1), 1 << (SBC_PROTO_FIXED4_SCALE - 1), 1 << (SBC_PROTO_FIXED4_SCALE - 1), }; __asm__ volatile ( - "movq (%0), %%mm0\n" - "movq 8(%0), %%mm1\n" - "pmaddwd (%1), %%mm0\n" - "pmaddwd 8(%1), %%mm1\n" - "paddd (%2), %%mm0\n" - "paddd (%2), %%mm1\n" + "movdqu (%0), %%xmm0\n" + "pmaddwd (%1), %%xmm0\n" + "paddd (%2), %%xmm0\n" "\n" - "movq 16(%0), %%mm2\n" - "movq 24(%0), %%mm3\n" - "pmaddwd 16(%1), %%mm2\n" - "pmaddwd 24(%1), %%mm3\n" - "paddd %%mm2, %%mm0\n" - "paddd %%mm3, %%mm1\n" + "movdqu 16(%0), %%xmm1\n" + "pmaddwd 16(%1), %%xmm1\n" + "paddd %%xmm1, %%xmm0\n" "\n" - "movq 32(%0), %%mm2\n" - "movq 40(%0), %%mm3\n" - "pmaddwd 32(%1), %%mm2\n" - "pmaddwd 40(%1), %%mm3\n" - "paddd %%mm2, %%mm0\n" - "paddd %%mm3, %%mm1\n" + "movdqu 32(%0), %%xmm1\n" + "pmaddwd 32(%1), %%xmm1\n" + "paddd %%xmm1, %%xmm0\n" "\n" - "movq 48(%0), %%mm2\n" - "movq 56(%0), %%mm3\n" - "pmaddwd 48(%1), %%mm2\n" - "pmaddwd 56(%1), %%mm3\n" - "paddd %%mm2, %%mm0\n" - "paddd %%mm3, %%mm1\n" + "movdqu 48(%0), %%xmm1\n" + "pmaddwd 48(%1), %%xmm1\n" + "paddd %%xmm1, %%xmm0\n" "\n" - "movq 64(%0), %%mm2\n" - "movq 72(%0), %%mm3\n" - "pmaddwd 64(%1), %%mm2\n" - "pmaddwd 72(%1), %%mm3\n" - "paddd %%mm2, %%mm0\n" - "paddd %%mm3, %%mm1\n" + "movdqu 64(%0), %%xmm1\n" + "pmaddwd 64(%1), %%xmm1\n" + "paddd %%xmm1, %%xmm0\n" + "\n" + "psrad %4, %%xmm0\n" + "\n" + "movdqa %%xmm0, %%xmm1\n" + "punpckhqdq %%xmm1, %%xmm1\n" + "movdq2q %%xmm0, %%mm0\n" + "movdq2q %%xmm1, %%mm1\n" "\n" - "psrad %4, %%mm0\n" - "psrad %4, %%mm1\n" "packssdw %%mm0, %%mm0\n" "packssdw %%mm1, %%mm1\n" "\n" -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GBCjBxlsPF+mTAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 02:02:33 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id +IpJBhlsPF+h8QEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 02:02:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 22F7AA020E; Wed, 19 Aug 2020 02:02:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727780AbgHSACS (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 18 Aug 2020 20:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727012AbgHSACR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 18 Aug 2020 20:02:17 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2DD5C061389 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 17:02:16 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id x6so10488986pgx.12 for <linux-bluetooth@vger.kernel.org>; Tue, 18 Aug 2020 17:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=z0dKBvUf9vGWL9gen29+YT/xiceR0mKKGHWkGGIRMKc=; b=aBV6XUGvXUFLEk0bOeNbgB+C6V9BCQjb1wytJmtfiOZlzs93puXKjR8BK5a2LeWJ0v Z/qu8EzSmqu2HBqozRlGMR0sj10W0YeFTYe+QLfIrAsJZ2uE3rEkSnFE7HQA7uhKkve8 7TbloMMyemuFbNti8UXx1CRIEvLBZF9LQXsgCtdiqKBCVbfR/7UWKNnyb0JefwsZWqbQ a197DbMBJwRdGI8ex3nqolddUGz+rBO6c3irliqfNklOrkqcXORExpCit+KGTRheslnB gfy655KHOv63BX7zOxp5rvYVKNKtl64MmDbetpx2FOsa3mLnUBIIVLi+x1/7frgOE576 0FgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z0dKBvUf9vGWL9gen29+YT/xiceR0mKKGHWkGGIRMKc=; b=XSwKXbl5zV/K7G7Flp4QyL3TKa7KiY+Ocg9VLGBLWwa+h+PynwjZ8zmCvr/poAUvld fY3zQ+mM0Z8zgOdfK183jIiR758pQiiUeMPhNOrILUncmepga5MQ1tuJ0Sagajvnluix s4rBo+On/WWP3lOh4oPiXz6PctxzpGvzY7B+O/7V4VYrp0wUl0q9uK3/lgX/06SYglR5 gU69r+cLg5Qe0q8SesxlFf+UJjVxPr4QbQ0K2/yTR/Uw22eBbzmdZXcQqWwR3yYurB4L pAJF0XQpAfC6sglLjK063lzMeAXZK/mzvJ0T0mHi91xfROFXRMXKn2zSMfqdXPQm3Z5k ZRRA== X-Gm-Message-State: AOAM531ALCrLso5ifcaG1nmSKAOPXTi9TQCdIJ3CGD5d/btQQAr4hPYi 7W2xVqSxQNbgZxk1JKOfB7J6zvWu/lA= X-Google-Smtp-Source: ABdhPJwFna7JKUeYZqTtXCi9ZNN3Tm//jGDR6lnX5jzqZGPuFwbs1JBwBVa/GMX6sdod8VjiGpu/BA== X-Received: by 2002:a05:6a00:78e:: with SMTP id g14mr16805555pfu.171.1597795334713; Tue, 18 Aug 2020 17:02:14 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id d80sm25957673pfd.22.2020.08.18.17.02.13 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 17:02:14 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 3/3] sbc/sbc_primitives_sse: Optimize sbc_analyze_8s Date: Tue, 18 Aug 2020 17:02:12 -0700 Message-Id: <20200819000212.211485-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200819000212.211485-1-luiz.dentz@gmail.com> References: <20200819000212.211485-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.60 / 15.00 / 200.00 X-Rspamd-Queue-Id: 22F7AA020E X-Rspamd-UID: 0ed53b From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This makes use 128 bit XMM registers whenever possible. $ time src/sbcenc_mmx -s 8 sin_64m.au > /dev/null real 0m1.064s user 0m1.012s sys 0m0.049s === After ==== $ time src/sbcenc -s 8 sin_64m.au > /dev/null real 0m1.032s user 0m0.996s sys 0m0.033s --- sbc/sbc_primitives_sse.c | 109 ++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 65 deletions(-) diff --git a/sbc/sbc_primitives_sse.c b/sbc/sbc_primitives_sse.c index 2a903e1..9bff6cf 100644 --- a/sbc/sbc_primitives_sse.c +++ b/sbc/sbc_primitives_sse.c @@ -96,80 +96,59 @@ static inline void sbc_analyze_four_sse(const int16_t *in, int32_t *out, static inline void sbc_analyze_eight_sse(const int16_t *in, int32_t *out, const FIXED_T *consts) { - static const SBC_ALIGNED int32_t round_c[2] = { + static const SBC_ALIGNED int32_t round_c[4] = { + 1 << (SBC_PROTO_FIXED8_SCALE - 1), + 1 << (SBC_PROTO_FIXED8_SCALE - 1), 1 << (SBC_PROTO_FIXED8_SCALE - 1), 1 << (SBC_PROTO_FIXED8_SCALE - 1), }; __asm__ volatile ( - "movq (%0), %%mm0\n" - "movq 8(%0), %%mm1\n" - "movq 16(%0), %%mm2\n" - "movq 24(%0), %%mm3\n" - "pmaddwd (%1), %%mm0\n" - "pmaddwd 8(%1), %%mm1\n" - "pmaddwd 16(%1), %%mm2\n" - "pmaddwd 24(%1), %%mm3\n" - "paddd (%2), %%mm0\n" - "paddd (%2), %%mm1\n" - "paddd (%2), %%mm2\n" - "paddd (%2), %%mm3\n" + "movdqu (%0), %%xmm0\n" + "movdqu 16(%0), %%xmm1\n" + "pmaddwd (%1), %%xmm0\n" + "pmaddwd 16(%1), %%xmm1\n" + "paddd (%2), %%xmm0\n" + "paddd (%2), %%xmm1\n" "\n" - "movq 32(%0), %%mm4\n" - "movq 40(%0), %%mm5\n" - "movq 48(%0), %%mm6\n" - "movq 56(%0), %%mm7\n" - "pmaddwd 32(%1), %%mm4\n" - "pmaddwd 40(%1), %%mm5\n" - "pmaddwd 48(%1), %%mm6\n" - "pmaddwd 56(%1), %%mm7\n" - "paddd %%mm4, %%mm0\n" - "paddd %%mm5, %%mm1\n" - "paddd %%mm6, %%mm2\n" - "paddd %%mm7, %%mm3\n" + "movdqu 32(%0), %%xmm2\n" + "movdqu 48(%0), %%xmm3\n" + "pmaddwd 32(%1), %%xmm2\n" + "pmaddwd 48(%1), %%xmm3\n" + "paddd %%xmm2, %%xmm0\n" + "paddd %%xmm3, %%xmm1\n" "\n" - "movq 64(%0), %%mm4\n" - "movq 72(%0), %%mm5\n" - "movq 80(%0), %%mm6\n" - "movq 88(%0), %%mm7\n" - "pmaddwd 64(%1), %%mm4\n" - "pmaddwd 72(%1), %%mm5\n" - "pmaddwd 80(%1), %%mm6\n" - "pmaddwd 88(%1), %%mm7\n" - "paddd %%mm4, %%mm0\n" - "paddd %%mm5, %%mm1\n" - "paddd %%mm6, %%mm2\n" - "paddd %%mm7, %%mm3\n" + "movdqu 64(%0), %%xmm2\n" + "movdqu 80(%0), %%xmm3\n" + "pmaddwd 64(%1), %%xmm2\n" + "pmaddwd 80(%1), %%xmm3\n" + "paddd %%xmm2, %%xmm0\n" + "paddd %%xmm3, %%xmm1\n" "\n" - "movq 96(%0), %%mm4\n" - "movq 104(%0), %%mm5\n" - "movq 112(%0), %%mm6\n" - "movq 120(%0), %%mm7\n" - "pmaddwd 96(%1), %%mm4\n" - "pmaddwd 104(%1), %%mm5\n" - "pmaddwd 112(%1), %%mm6\n" - "pmaddwd 120(%1), %%mm7\n" - "paddd %%mm4, %%mm0\n" - "paddd %%mm5, %%mm1\n" - "paddd %%mm6, %%mm2\n" - "paddd %%mm7, %%mm3\n" + "movdqu 96(%0), %%xmm2\n" + "movdqu 112(%0), %%xmm3\n" + "pmaddwd 96(%1), %%xmm2\n" + "pmaddwd 112(%1), %%xmm3\n" + "paddd %%xmm2, %%xmm0\n" + "paddd %%xmm3, %%xmm1\n" "\n" - "movq 128(%0), %%mm4\n" - "movq 136(%0), %%mm5\n" - "movq 144(%0), %%mm6\n" - "movq 152(%0), %%mm7\n" - "pmaddwd 128(%1), %%mm4\n" - "pmaddwd 136(%1), %%mm5\n" - "pmaddwd 144(%1), %%mm6\n" - "pmaddwd 152(%1), %%mm7\n" - "paddd %%mm4, %%mm0\n" - "paddd %%mm5, %%mm1\n" - "paddd %%mm6, %%mm2\n" - "paddd %%mm7, %%mm3\n" + "movdqu 128(%0), %%xmm2\n" + "movdqu 144(%0), %%xmm3\n" + "pmaddwd 128(%1), %%xmm2\n" + "pmaddwd 144(%1), %%xmm3\n" + "paddd %%xmm2, %%xmm0\n" + "paddd %%xmm3, %%xmm1\n" + "\n" + "psrad %4, %%xmm0\n" + "psrad %4, %%xmm1\n" "\n" - "psrad %4, %%mm0\n" - "psrad %4, %%mm1\n" - "psrad %4, %%mm2\n" - "psrad %4, %%mm3\n" + "movdqa %%xmm0, %%xmm2\n" + "movdqa %%xmm1, %%xmm3\n" + "punpckhqdq %%xmm2, %%xmm2\n" + "punpckhqdq %%xmm3, %%xmm3\n" + "movdq2q %%xmm0, %%mm0\n" + "movdq2q %%xmm2, %%mm1\n" + "movdq2q %%xmm1, %%mm2\n" + "movdq2q %%xmm3, %%mm3\n" "\n" "packssdw %%mm0, %%mm0\n" "packssdw %%mm1, %%mm1\n" -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WGTAGbDVPF9PPwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 09:33:04 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id MJs6GLDVPF/dMgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 09:33:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=oulu.fi X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 66BECA1230; Wed, 19 Aug 2020 09:32:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727017AbgHSH3X (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 03:29:23 -0400 Received: from mail-eopbgr130133.outbound.protection.outlook.com ([40.107.13.133]:51424 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727872AbgHSH3T (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 03:29:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KKCuxRjzuVASuHWREhH/TvwGjO9Xjf8Asx9SkZaL0uonqbNG31MMEwR8J1pQxQ82lDWOQd+UDeeUc2LEMeYH2+RRkaFKDbgRfux7kUMdqMW8/SqBBEKf/QccM+ylVh7nyKUvLafCh2Pte1g3eCF8pxFTmcycGjmIbGf1X3m4RX1xdxFrecpVfI1y9ypR04Cslx0OuPrAAGswJa+z4MPZCAwzmZ0gL0XOYtexlaDxRruaaIGIZfTKo1w+/q32fyyV2iEU6zfpIisgaRCnY7tpM5IY8gDjhg2IaR4wf7xvTkwD0VrlZdmNN+E1MPOaQdr7bg+BouEukZIUlTSVbPA31w== 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-SenderADCheck; bh=WTuHZu4ghcuEmjpo2HwGhzPbVqtMAFvCR16xDlsKyrk=; b=fmPwHY1JJm34mYgZBa/sHcQBct/edS1QZ8X3mjICSAGi+WPdXfTKzSMxfk/IrWt0PIryqt/juWCew8q1u5TLgGsMyG5qUabQ0xuSeLNuva8DT60f4du1OJfeU/YCt3MBayHkUgwFh5E3fOqjoutP4axGfxfj7s1q2W9C1iDBOAe/7S627wxOphb8iNEYCY9tBhD78wktxSdv9dWjiZ/cB4NLEtj4iVSEIduzYa28QT0rtk0A+Q26Wi1/euMA04CsWANg6FObyOqWIYp9fg2EG5B4EDq3+10mPbk9mtYOrFCf7YVC1qD2CZQplSwvf5GHRoEjZp7Ndh7L3kyh1eRVOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oulu.fi; dmarc=pass action=none header.from=oulu.fi; dkim=pass header.d=oulu.fi; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oulu.fi; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WTuHZu4ghcuEmjpo2HwGhzPbVqtMAFvCR16xDlsKyrk=; b=NvhBmfhT+D+pfFb5wbeh3OPxflM9yXriUbUXlxnrWpBbEKkgZSPwq+c9nOqiDpxsrYXtHDamL0lIehQt3ho3ibBuk1C1LOfY6wwZqiccJkufV5Pu95ys5p/UWdmvrlnYT5F31VUAfRShpzhEINOcH4HLG7uVupfXFvovV0ClOkQ= Received: from HE1PR05MB3338.eurprd05.prod.outlook.com (2603:10a6:7:2e::29) by HE1PR0502MB3754.eurprd05.prod.outlook.com (2603:10a6:7:8a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.24; Wed, 19 Aug 2020 07:29:15 +0000 Received: from HE1PR05MB3338.eurprd05.prod.outlook.com ([fe80::686b:c547:31bc:fdf4]) by HE1PR05MB3338.eurprd05.prod.outlook.com ([fe80::686b:c547:31bc:fdf4%6]) with mapi id 15.20.3305.024; Wed, 19 Aug 2020 07:29:15 +0000 From: =?iso-8859-1?Q?Jari_J=E4=E4skel=E4?= <Jari.Jaaskela@oulu.fi> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Subject: LE Secure Connections: Disconnection after pairing Thread-Topic: LE Secure Connections: Disconnection after pairing Thread-Index: AQHWdfmu1mjwZR5E3ketvt6EmmVpvA== Date: Wed, 19 Aug 2020 07:29:15 +0000 Message-ID: <HE1PR05MB3338001B735642B334087FCBFC5D0@HE1PR05MB3338.eurprd05.prod.outlook.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oulu.fi; x-originating-ip: [37.136.11.152] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0bfd1059-768e-4546-84b3-08d8441193b5 x-ms-traffictypediagnostic: HE1PR0502MB3754: x-microsoft-antispam-prvs: <HE1PR0502MB375428EBF0DCE7607EF2556AFC5D0@HE1PR0502MB3754.eurprd05.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:1388; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: N1DrwgiGjD/zdfU05/AEUnc41gV6Q1fU2n301BdBiEEo9NJLtaKd/GEdwpMD+kkIncrzXbIosKEP4Fb6x2eGfxXFv+QC8yXFAgY8bkh7xpq4Tr3/o/fHhdlwrrndvSBJwyXdWfUX8GirH3DAB7ANhbmNwWezdbz/Nw0cI9TS10zrsQ8WWEARDve1IgFzham+SdHL2QlnmYtSqogBVYj8RA3aeW0g8YBXTYWtmyYeeeGX84p0vBvCHZQCbXqXi0U5R224LqAP59tLcAWYs526oHd1VU9RHd/0bzuvG20piTFA94+OJWiFFX+KYx/lKJF0uH1GLn3kujC5E7MWvH6aON7lmokaYQu3G9cC2xV+OoH9Aza/MoRf8pNaWvXoNAn18PBY/lrxLmiMY1uDhxsA1w== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR05MB3338.eurprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(39850400004)(136003)(376002)(346002)(8676002)(6506007)(66556008)(66446008)(64756008)(8936002)(26005)(5660300002)(7696005)(4744005)(55016002)(66476007)(478600001)(9686003)(966005)(2906002)(316002)(786003)(186003)(71200400001)(86362001)(33656002)(76116006)(66946007)(6916009)(83380400001)(52536014);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: XKIHxxu/fIJEqg4RcVQqhtebmsoyOwDpPJuYHvy4Rhibe7cmnkcWv8B2IU9Fo6zbVKFLQ5hm0/2Cm0SPYCs9/JLErBnrPFnHnRLrLWYBwms8qDniQ1doUGJZzjQcZUqd83P/JryB9AN5CPjPGulyjWOQqzHwqGn9z3RDLCSxYiTYIUaR3BLsSQOAYiQ1Jy5+37tOslgEBWGT6lN8/vY175aPL7R+TLv1lVFigLSo3WVSX/ZXrlweN2+YNVuDNIu0LWv0pRwJAtS6ptbYB3WYkCASOmLpgyZlUj91ADblIA3MWKfmy5vLEYFysv4DSvBsB34QtJwN4CH34RNbYvR/Ixb+8MPs+yDdfMs6UX3P+a4aYfn5J7gQSEijYh1NtQxd0sIhWwhcvxyBjhE1dyVTMSj9uB4TTBtSOj5sDm1ZjPzWWreK3jS1iDLCogS7dMMwLPFqTmi7SN539i2KMpfw4juJ7eT9Jc/4YdUMg2SMn7gQKIoNzSR4XKE8tt5psAej9gm46kT46rKAnqCgqfPpK5Cf5+8Ok26Qa/qfZtkdJk28xrxZ6bhsb0IyFIAN7VI16UlkwWlPCGZWQqEwmfY1Wwlkq1F80+fZfj2By0yWK7tF3rRq8Ynp+Zv7f5+Ie4i1BzC77FGcgJFB2aSoyBo6tQ== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: oulu.fi X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: HE1PR05MB3338.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0bfd1059-768e-4546-84b3-08d8441193b5 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2020 07:29:15.4815 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9f9ce49a-5101-4aa3-8c75-0d5935ad6525 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: nXKvGcF68zzSKjBIE84DxjWqYKuCIAQtzf6evf6TktAGH6MvonZB+0unYK1ToCSVLcR4f23HA7oWV3Q/ZNU8g8p+4kyTWe3zNcvMUgnszgw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0502MB3754 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.58 / 15.00 / 200.00 X-Rspamd-Queue-Id: 66BECA1230 X-Rspamd-UID: 02478c Hey,=0A= =0A= I encountered this issue in July, and I reported it as a bug here:=A0https:= //bugzilla.kernel.org/show_bug.cgi?id=3D208637.=0A= See the bug report for logs.=A0=0A= =0A= Here's the description:=0A= =0A= I have been trying to establish secure connection to a gatt service. Pairin= g completes successfully (using out-of-band data), and the client can read = characteristic that has encrypt-authenticated security level, but the conne= ction is lost soon after pairing (as seen in the btmon log). This seems to = happen because the controller responds with reason Connection Timeout (0x08= ).=0A= =0A= Hardware: Raspberry Pi 4 Model B (Bluetooth chip: Cypress CYW43455).=0A= Tested on: 4.19.118-v7l+, 5.4.42-v7l.=0A= Tested BlueZ: 5.53, 5.54, master (commit 6ea1b038eedeca31c3796ac921e25509d4= 8d70ec)=0A= =0A= Best regards,=0A= Jari J=E4=E4skel=E4=0A= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QP6UMb7iPF8tngAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 10:28:46 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8G8pML7iPF9JGwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 10:28:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=dptechnics.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DFEF4A013F; Wed, 19 Aug 2020 10:28:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726466AbgHSI2l (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 04:28:41 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17150 "EHLO sender4-op-o11.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725275AbgHSI2k (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 04:28:40 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1597825718; cv=none; d=zohomail.com; s=zohoarc; b=fW+jHXIGe0SBHygLKqWSni2m7kq8jQYaMF03r5Dl+EPll++VF/9u/QkGzdBS5WXpjxBdG67p+tJMoiDmk+m4alOSM26AK0YWJk1NzNyciprM/o6SfKjQCt8jwh3BpG5XfexKxkogaBe96ba98dzfNddpEf4RUnFnQOb2b7wYbkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597825718; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=KRkOzLc/Uwuw5dAitluju1NDAe8XJoRqijty0SThLCc=; b=c44UAskkfBnU3vc5Mb54F3Tp7f/AAgCGw80YAYMLg4kY3nJ7yduhG/Umo2UlaV0xo4mCdLxL8XzWuMnu6I9Ck97VLMStgyrEDqyqUDV+mSedeP0eocO6QTxaaSxOIEedwD95st28JKwf+0B1m9bL1VGZhRCG8wV80MrrfMm1E/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=dptechnics.com; spf=pass smtp.mailfrom=daan@dptechnics.com; dmarc=pass header.from=<daan@dptechnics.com> header.from=<daan@dptechnics.com> DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1597825718; s=zoho; d=dptechnics.com; i=daan@dptechnics.com; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=KRkOzLc/Uwuw5dAitluju1NDAe8XJoRqijty0SThLCc=; b=WAuSuyVCidN+GmjgN7yfciZcmyFmKQKbVFhdpDY37lnMkh84wApiyunmhODupX3x v4pzaEo6frSgEOzdLszTayQqMPpLQDIjLDRT7KQMzBEErw5EJX6bdfposBNh8nMw88f Yg/9Xf6Xx2SJFLe9yyEfE59LcIZD1hqJDBsOtf2g= Received: from daan-devbox.dptechnics.local (178-116-74-88.access.telenet.be [178.116.74.88]) by mx.zohomail.com with SMTPS id 1597825714430753.4998273038578; Wed, 19 Aug 2020 01:28:34 -0700 (PDT) From: Daan Pape <daan@dptechnics.com> To: linux-bluetooth@vger.kernel.org Cc: Daan Pape <daan@dptechnics.com> Message-ID: <20200819082822.64903-1-daan@dptechnics.com> Subject: [PATCH BlueZ 0/1] Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans Date: Wed, 19 Aug 2020 10:28:21 +0200 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.55 / 15.00 / 200.00 X-Rspamd-Queue-Id: DFEF4A013F X-Rspamd-UID: efb6cd I had compiled bluez for OpenWRT and was running the bluetooth-meshd daemon with a Fanstel BT680T module which implement the Bluetooth 5.0 core specification. The daemon did not properly start and failed with error: LE Scan enable failed (0x12) This error is described on page 2496 of the Bluetooth Core Specification Version 5.2 and is caused by the fact that no random address was initialized. After the valuable input of Brian Gix on my first patch, I have now prepared this patch. I have now added a random address intialization after the HCI was reset in the configure_hci function. The HCI layer is now correctly initialized and no 0x12 errors are thrown. This is the first time that I contribute to Bluez so please forgive me if I made any styling mistake in the patch format. I also did not include my details in the 'AUTHORS' file just yet as I first wanted to wait for your reaction. In case the patch is accepted my name can be added to the 'AUTHORS' file as: Daan Pape <daan@dptechnics.com> Please do not hesitate to ask any further questions if neccesary. Kind regards, Daan Pape Daan Pape (1): Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans mesh/mesh-io-generic.c | 9 +++++++++ 1 file changed, 9 insertions(+) --=20 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sO4hJsPiPF8tngAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 10:28:51 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 2DLkJMPiPF+FhgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 10:28:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=dptechnics.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B9D8DA124F; Wed, 19 Aug 2020 10:28:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726752AbgHSI2o (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 04:28:44 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17155 "EHLO sender4-op-o11.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725275AbgHSI2n (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 04:28:43 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1597825721; cv=none; d=zohomail.com; s=zohoarc; b=JQOd6sEjLn8ovrXXo4MGubrEV/d6ZJ4JQyFUC5q6U79j7f67R2+W4dihcN1XGitKfUYzz/WVt9ZvjAhL9/y+ZsAjDp5fOKYDusbbyHYPGVv/4k/bes63fEmjwOUl4EqMGhYFaLuUq7chmFG/q4IIHqR+uUFcbiJxAv89bAJWjg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597825721; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=d9boOkysEGDCONb3wvtEktaiZH+gsA7O/zLknqluH/s=; b=R5TC4TVy7c2jiS1bJgg1DMvY3nRbtKfY/koi+n9knU+ZYbRxHAPv0KUM/PXtCyboIYDdMTcOVuuFwk8BPF6IA+fWrReEfCDMnpDEcW9xkzMo7m74emDe2Vfxaw9ZY0l53fgqeXYa+jlh1kSuygTsRYNp4gfsIcHkb9MrT9j3AXE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=dptechnics.com; spf=pass smtp.mailfrom=daan@dptechnics.com; dmarc=pass header.from=<daan@dptechnics.com> header.from=<daan@dptechnics.com> DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1597825721; s=zoho; d=dptechnics.com; i=daan@dptechnics.com; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=d9boOkysEGDCONb3wvtEktaiZH+gsA7O/zLknqluH/s=; b=FoUF9Ag83GWiLjTfMUvGy1HoZREFwU40b75shq6oj5Fh7pDXcUGH4lNVHxtLjr1S OZD8hmxWki9xAO9vRpp/l/Q3oDUtbgycoSnEhTQJZiiRuVYlmooMDl7pUSqyGJW1XX8 x3GuSC30R9uhxL7YNPVG/ADWB1pvsuA27Vb87PAg= Received: from daan-devbox.dptechnics.local (178-116-74-88.access.telenet.be [178.116.74.88]) by mx.zohomail.com with SMTPS id 1597825718141948.4507996388694; Wed, 19 Aug 2020 01:28:38 -0700 (PDT) From: Daan Pape <daan@dptechnics.com> To: linux-bluetooth@vger.kernel.org Cc: Daan Pape <daan@dptechnics.com> Message-ID: <20200819082822.64903-2-daan@dptechnics.com> Subject: [PATCH BlueZ 1/1] Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans Date: Wed, 19 Aug 2020 10:28:22 +0200 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200819082822.64903-1-daan@dptechnics.com> References: <20200819082822.64903-1-daan@dptechnics.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.14 / 15.00 / 200.00 X-Rspamd-Queue-Id: B9D8DA124F X-Rspamd-UID: 78af56 --- mesh/mesh-io-generic.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c index 67b13a1b9..67304d201 100644 --- a/mesh/mesh-io-generic.c +++ b/mesh/mesh-io-generic.c @@ -209,6 +209,7 @@ static void configure_hci(struct mesh_io_private *io) =09struct bt_hci_cmd_le_set_scan_parameters cmd; =09struct bt_hci_cmd_set_event_mask cmd_sem; =09struct bt_hci_cmd_le_set_event_mask cmd_slem; +=09struct bt_hci_cmd_le_set_random_address cmd_raddr; =20 =09/* Set scan parameters */ =09cmd.type =3D 0x00; /* Passive Scanning. No scanning PDUs shall be sent = */ @@ -261,6 +262,10 @@ static void configure_hci(struct mesh_io_private *io) =09cmd_slem.mask[6] =3D 0x00; =09cmd_slem.mask[7] =3D 0x00; =20 +=09/* Set LE random address */ +=09l_getrandom(cmd_raddr.addr, 6); +=09cmd_raddr.addr[5] |=3D 0xc0; + =09/* TODO: Move to suitable place. Set suitable masks */ =09/* Reset Command */ =09bt_hci_send(io->hci, BT_HCI_CMD_RESET, NULL, 0, hci_generic_callback, @@ -282,6 +287,10 @@ static void configure_hci(struct mesh_io_private *io) =09bt_hci_send(io->hci, BT_HCI_CMD_LE_SET_EVENT_MASK, &cmd_slem, =09=09=09sizeof(cmd_slem), hci_generic_callback, NULL, NULL); =20 +=09/* Set LE random address */ +=09bt_hci_send(io->hci, BT_HCI_CMD_LE_SET_RANDOM_ADDRESS, &cmd_raddr, +=09=09=09sizeof(cmd_raddr), hci_generic_callback, NULL, NULL); + =09/* Scan Params */ =09bt_hci_send(io->hci, BT_HCI_CMD_LE_SET_SCAN_PARAMETERS, &cmd, =09=09=09=09sizeof(cmd), hci_generic_callback, NULL, NULL); --=20 2.20.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WJ+zHfLnPF8NxAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 10:50:58 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WFpiIvLnPF9KzQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 10:50:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 67C5AA11FD; Wed, 19 Aug 2020 10:50:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726710AbgHSIuw (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 04:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbgHSIuv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 04:50:51 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28C30C061757 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 01:50:51 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id 77so20901235qkm.5 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 01:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=JWWNGW4uLcUJgLR3Lzv+8SY+g1N/Ade7CE0qw+59PWI=; b=T8Ooe40aksqBVpv24YXu4h91x1Cn8XV6jg2YkPBlsIx2syIEfMsqEBXlY0rHw7qTpQ gyr1n8y5vKcu8f3irFx2mXhLXIjDhVekPDBlzpfnzd/lfKwGVnKjRi0KumAoUxTmJBjM ADFEo3PF2ab9aLhcb2eiU9I+zq6fTAE2mvkGnwODrQee6nvwnZ9pSCjUHxcxf0QwlTZl SBc2hoejoKlbvrMtMgR9gNkWHhfjtcY43sdW1T0imm0ZotaMLryBCwBbaa3UrW/3LfFS kXzfnGudM5qYrkJt2VrUDsXRRuA7hbjng0B1B5klAcJnq2J0Dh7vKROd6lIL7t9h29jq uSlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=JWWNGW4uLcUJgLR3Lzv+8SY+g1N/Ade7CE0qw+59PWI=; b=oVeZQtcFBpivVpFRYhNKzVlWqEEWXQVvQ/YiAwANsWwh0D6KZ3Z7ofLkko7WDKvoZy 6Ht/r6Y8lmirD3veOaGcxgruW0xRsohsguHgK57qyfEQo8U5l9yvdeQQHyW6pzWyFTd2 2rECTFu+n2M5HxS9y9ZNEX51Pllfure+e/YWz+j+2T95YylSKVDW5Pyr5kXlhxpE+WKE t9Cl4c2NuGTfnwOwMik0j61ItlqOsOPTEKZhgGd+7D3CrLTQEz3tcc6rCVwGvVQIyscB gh6JePaNh2dD0y/RceMl9LkfON8oe7ApnEHIYqRMn7bDN7UbNKAn2zQpielDXNYpuIP/ AoLA== X-Gm-Message-State: AOAM5326IwHW8y5xh+sbMFrruxKvHNiv8ltCNxMS5zItu8OKBHJxRc2t XQZ8r4dtYzzyqPALZYBZt4pwYzAkMql/+g== X-Google-Smtp-Source: ABdhPJyPMM5M0W0c1bJUO3dlpUrmWjopO6V32pzm4c0DKN8EevMbE3oV8ueb/SCwMgIOFK5tITU/lA== X-Received: by 2002:a37:bdc4:: with SMTP id n187mr21291218qkf.192.1597827049761; Wed, 19 Aug 2020 01:50:49 -0700 (PDT) Received: from [172.17.0.2] ([52.251.90.7]) by smtp.gmail.com with ESMTPSA id g136sm23635668qke.82.2020.08.19.01.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 01:50:49 -0700 (PDT) Message-ID: <5f3ce7e9.1c69fb81.7987f.0d7e@mx.google.com> Date: Wed, 19 Aug 2020 01:50:49 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============4289954485751905989==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, daan@dptechnics.com Subject: RE: [BlueZ,1/1] Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200819082822.64903-2-daan@dptechnics.com> References: <20200819082822.64903-2-daan@dptechnics.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 67C5AA11FD X-Rspamd-UID: 921205 --===============4289954485751905989== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 1: T1 Title exceeds max length (102>72): "Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans" 3: B6 Body message is missing --- Regards, Linux Bluetooth --===============4289954485751905989==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uHYrI+8oPV9YwwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 15:28:15 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id EEGDIe8oPV+zwAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 15:28:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=omicronenergy.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 56DA2A11F2; Wed, 19 Aug 2020 15:28:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728119AbgHSN2I (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 09:28:08 -0400 Received: from ns.omicron.at ([212.183.10.25]:45256 "EHLO ns.omicron.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727992AbgHSN2H (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 09:28:07 -0400 X-Greylist: delayed 326 seconds by postgrey-1.27 at vger.kernel.org; Wed, 19 Aug 2020 09:28:06 EDT Received: from MGW02-ATKLA.omicron.at ([172.25.62.35]) by ns.omicron.at (8.15.2/8.15.2) with ESMTPS id 07JDMd7Y020945 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 15:22:39 +0200 DKIM-Filter: OpenDKIM Filter v2.11.0 ns.omicron.at 07JDMd7Y020945 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omicronenergy.com; s=default; t=1597843359; bh=ccYcGYY6Mbw1HaaTbPxfuOr7peGZ50PxigpPLEqCJwc=; h=From:To:CC:Subject:Date:From; b=lpI5xi0+LOI7APFxlu1G4JXWK6oKSB9CNe8OdpUIR0mC7RoPrVuw0WIv/7AzVnhON wHISDxCsvOARycfjLUspEnHrZUVnV8Y9FTR/Q8Qc1NniGHGmLSiLAjUKRA7gd+G3Nl kbHTM8MgPWq+17j/I6j3PJgxYRfpRkW8o06fzaqE= Received: from MGW02-ATKLA.omicron.at (localhost [127.0.0.1]) by MGW02-ATKLA.omicron.at (Postfix) with ESMTP id 4FAB0A0064 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 15:22:38 +0200 (CEST) Received: from MGW01-ATKLA.omicron.at (unknown [172.25.62.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by MGW02-ATKLA.omicron.at (Postfix) with ESMTPS id 4D846A0062 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 15:22:38 +0200 (CEST) Received: from EXC04-ATKLA.omicron.at ([172.22.100.189]) by MGW01-ATKLA.omicron.at with ESMTP id 07JDMdeZ021520-07JDMdeb021520 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=CAFAIL); Wed, 19 Aug 2020 15:22:39 +0200 Received: from marmar13.omicron.at (172.22.32.104) by EXC04-ATKLA.omicron.at (172.22.100.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 19 Aug 2020 15:22:38 +0200 From: Mark Marshall <mark.marshall@omicronenergy.com> To: <linux-bluetooth@vger.kernel.org> CC: Mark Marshall <markmarshall14@gmail.com> Subject: [PATCH BlueZ 0/2] Fix a couple of endian issues Date: Wed, 19 Aug 2020 15:22:29 +0200 Message-ID: <20200819132231.22673-1-mark.marshall@omicronenergy.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.22.32.104] X-ClientProxiedBy: EXC04-ATKLA.omicron.at (172.22.100.189) To EXC04-ATKLA.omicron.at (172.22.100.189) X-FE-Policy-ID: 1:1:1:SYSTEM Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.84 / 15.00 / 200.00 X-Rspamd-Queue-Id: 56DA2A11F2 X-Rspamd-UID: 3ebdbb From: Mark Marshall <markmarshall14@gmail.com> I'm running BlueZ on a big-endian platform, and have found a couple of small endian issues with the tools code. Mark Marshall (2): btiotest: Correct setting of addr_type for big-endian platforms l2test: Correct the endian handling tools/btiotest.c | 7 ++++--- tools/l2test.c | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aK/TAPgoPV/PkAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 15:28:24 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id qPjAAvgoPV/XtAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 15:28:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=omicronenergy.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8D6DEA11F9; Wed, 19 Aug 2020 15:28:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727975AbgHSN2K (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 09:28:10 -0400 Received: from ns.omicron.at ([212.183.10.25]:45256 "EHLO ns.omicron.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728115AbgHSN2J (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 09:28:09 -0400 X-Greylist: delayed 326 seconds by postgrey-1.27 at vger.kernel.org; Wed, 19 Aug 2020 09:28:06 EDT Received: from MGW02-ATKLA.omicron.at ([172.25.62.35]) by ns.omicron.at (8.15.2/8.15.2) with ESMTPS id 07JDMiVg020963 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 15:22:44 +0200 DKIM-Filter: OpenDKIM Filter v2.11.0 ns.omicron.at 07JDMiVg020963 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omicronenergy.com; s=default; t=1597843364; bh=SL+ccKKYMqjN6lbW3mI+FOY5RPCosCqUgpc/bMPHIDc=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=ZXrC8VADEjdrUB5jYD2f8aBWhFM7dAOx7U1oStFr/RIqY7nuZakmBbzvPSBRPvEvg ud08Trfyfah9NdPEd4xlGttnaVL4JQPzmhc4rbOUafiavUAnHAQvR+jCcYn70iXEkg NaE16Udz5W8Eu+q1ri8YvvuM45kMQljHyyEdviIk= Received: from MGW02-ATKLA.omicron.at (localhost [127.0.0.1]) by MGW02-ATKLA.omicron.at (Postfix) with ESMTP id B5FC2A0054 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 15:22:43 +0200 (CEST) Received: from MGW01-ATKLA.omicron.at (unknown [172.25.62.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by MGW02-ATKLA.omicron.at (Postfix) with ESMTPS id B40CEA0053 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 15:22:43 +0200 (CEST) Received: from EXC04-ATKLA.omicron.at ([172.22.100.189]) by MGW01-ATKLA.omicron.at with ESMTP id 07JDMiY2021525-07JDMiY4021525 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=CAFAIL) for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 15:22:44 +0200 Received: from marmar13.omicron.at (172.22.32.104) by EXC04-ATKLA.omicron.at (172.22.100.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 19 Aug 2020 15:22:40 +0200 From: Mark Marshall <mark.marshall@omicronenergy.com> To: <linux-bluetooth@vger.kernel.org> CC: Mark Marshall <mark.marshall@omicronenergy.com> Subject: [PATCH BlueZ 1/2] btiotest: Correct setting of addr_type for big-endian platforms Date: Wed, 19 Aug 2020 15:22:30 +0200 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819132231.22673-1-mark.marshall@omicronenergy.com> References: <20200819132231.22673-1-mark.marshall@omicronenergy.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.22.32.104] X-ClientProxiedBy: EXC04-ATKLA.omicron.at (172.22.100.189) To EXC04-ATKLA.omicron.at (172.22.100.189) Message-ID: <418845b9-28e1-4356-9ce2-b422720bf948@EXC04-ATKLA.omicron.at> X-FE-Policy-ID: 1:1:1:SYSTEM Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.39 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8D6DEA11F9 X-Rspamd-UID: 7d5d97 The glibc option parser expects the option values pointed to by G_OPTION_ARG_INT to be an int, so a guint8 is wrong in all cases, but on a big-endian platform you can't even change the addr_type. (On little endian, it would appear to work). --- tools/btiotest.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/btiotest.c b/tools/btiotest.c index 6c778e3c5..d56bb4fda 100644 --- a/tools/btiotest.c +++ b/tools/btiotest.c @@ -556,7 +556,7 @@ static int opt_sec = 0; static gboolean opt_master = FALSE; static int opt_priority = 0; static int opt_cid = 0; -static guint8 opt_addr_type = 0; +static int opt_addr_type = 0; static GMainLoop *main_loop; @@ -616,8 +616,9 @@ int main(int argc, char *argv[]) g_option_context_free(context); printf("accept=%d reject=%d discon=%d defer=%d sec=%d update_sec=%d" - " prio=%d voice=0x%04x\n", opt_accept, opt_reject, opt_disconn, - opt_defer, opt_sec, opt_update_sec, opt_priority, opt_voice); + " prio=%d voice=0x%04x addr_type=%u\n", opt_accept, opt_reject, opt_disconn, + opt_defer, opt_sec, opt_update_sec, opt_priority, opt_voice, + opt_addr_type); if (opt_psm || opt_cid) { if (argc > 1) -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oND+Nf0oPV/PkAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 15:28:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id eAH9M/0oPV9CJgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 15:28:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=omicronenergy.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 23DA2A13CD; Wed, 19 Aug 2020 15:28:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728145AbgHSN2O (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 09:28:14 -0400 Received: from ns.omicron.at ([212.183.10.25]:45256 "EHLO ns.omicron.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727992AbgHSN2N (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 09:28:13 -0400 X-Greylist: delayed 326 seconds by postgrey-1.27 at vger.kernel.org; Wed, 19 Aug 2020 09:28:06 EDT Received: from MGW02-ATKLA.omicron.at ([172.25.62.35]) by ns.omicron.at (8.15.2/8.15.2) with ESMTPS id 07JDMiP3020967 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 15:22:45 +0200 DKIM-Filter: OpenDKIM Filter v2.11.0 ns.omicron.at 07JDMiP3020967 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omicronenergy.com; s=default; t=1597843365; bh=1c0JuGsAJgb85k4gKftWDbw/FxvuY81Tku6bJzjflCo=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=M8QpGIYaM44x0QlQD13301tw1Q2Svo2alyoZOUH7zAHkwJxvKk50JV6wNhDu5cK23 ptd8SJFsMko9aBvxR/mV+whgyKrOVxY42tnwdHi/i7Du9G0/oA4JzyTG1nuZMLKQsU Lx8YLfgU9lw9RKRhq/tcy8QpaDNDsonYplKoaocw= Received: from MGW02-ATKLA.omicron.at (localhost [127.0.0.1]) by MGW02-ATKLA.omicron.at (Postfix) with ESMTP id C3A5BA0062 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 15:22:43 +0200 (CEST) Received: from MGW01-ATKLA.omicron.at (unknown [172.25.62.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by MGW02-ATKLA.omicron.at (Postfix) with ESMTPS id C1BF0A0053 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 15:22:43 +0200 (CEST) Received: from EXC04-ATKLA.omicron.at ([172.22.100.189]) by MGW01-ATKLA.omicron.at with ESMTP id 07JDMiY2021525-07JDMiY5021525 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=CAFAIL) for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 15:22:44 +0200 Received: from marmar13.omicron.at (172.22.32.104) by EXC04-ATKLA.omicron.at (172.22.100.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 19 Aug 2020 15:22:41 +0200 From: Mark Marshall <mark.marshall@omicronenergy.com> To: <linux-bluetooth@vger.kernel.org> CC: Mark Marshall <mark.marshall@omicronenergy.com> Subject: [PATCH BlueZ 2/2] l2test: Correct the endian handling Date: Wed, 19 Aug 2020 15:22:31 +0200 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819132231.22673-1-mark.marshall@omicronenergy.com> References: <20200819132231.22673-1-mark.marshall@omicronenergy.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.22.32.104] X-ClientProxiedBy: EXC04-ATKLA.omicron.at (172.22.100.189) To EXC04-ATKLA.omicron.at (172.22.100.189) Message-ID: <411f2f20-c199-44ef-a974-8c2230e07e51@EXC04-ATKLA.omicron.at> X-FE-Policy-ID: 1:1:1:SYSTEM Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.41 / 15.00 / 200.00 X-Rspamd-Queue-Id: 23DA2A13CD X-Rspamd-UID: 70389a The code that deals with endian issues was not always correct, use bt_get_leN in all cases. --- tools/l2test.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/l2test.c b/tools/l2test.c index 0d846ed93..a62eacb4e 100644 --- a/tools/l2test.c +++ b/tools/l2test.c @@ -1155,8 +1155,8 @@ static void info_request(char *svr) switch (btohs(rsp->result)) { case 0x0000: - memcpy(&mtu, rsp->data, sizeof(mtu)); - printf("Connectionless MTU size is %d\n", btohs(mtu)); + mtu = bt_get_le16(rsp->data); + printf("Connectionless MTU size is %d\n", mtu); break; case 0x0001: printf("Connectionless MTU is not supported\n"); @@ -1182,8 +1182,8 @@ static void info_request(char *svr) switch (btohs(rsp->result)) { case 0x0000: - memcpy(&mask, rsp->data, sizeof(mask)); - printf("Extended feature mask is 0x%04x\n", btohl(mask)); + mask = bt_get_le32(rsp->data); + printf("Extended feature mask is 0x%04x\n", mask); if (mask & L2CAP_FEAT_FLOWCTL) printf(" Flow control mode\n"); if (mask & L2CAP_FEAT_RETRANS) @@ -1210,7 +1210,7 @@ static void info_request(char *svr) break; } - if (!(mask & 0x80)) + if (!(mask & L2CAP_FEAT_FIXED_CHAN)) goto failed; memset(buf, 0, sizeof(buf)); @@ -1232,8 +1232,8 @@ static void info_request(char *svr) switch (btohs(rsp->result)) { case 0x0000: - memcpy(&channels, rsp->data, sizeof(channels)); - printf("Fixed channels list is 0x%04x\n", btohl(channels)); + channels = bt_get_le32(rsp->data); + printf("Fixed channels list is 0x%04x\n", channels); break; case 0x0001: printf("Fixed channels list is not supported\n"); -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eKtmApAyPV/C5AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 16:09:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id uNfYAJAyPV90SgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 16:09:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A0084A1444; Wed, 19 Aug 2020 16:09:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728562AbgHSNum (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 09:50:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728686AbgHSNu2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 09:50:28 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F988C061757 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 06:50:27 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id dd12so11276678qvb.0 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 06:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=5Kq+eO5N+yscRltuzqc1xrjMAGWlhYWTm3daje9xGJk=; b=Vc5Q4d1IUR6s9zJjNj85e++d8iVFv13+P42Bqk7ogPL9OwR5G5TXpPll71t2mC75xj U632lbv/ZpFDtWiMm18wb2wn533dN/uQ3PcC19ZoLduitBiG8HqNLzSI4NtTYz5JKkYQ W8F2S/Z2VEiY3SUqiF3t7H+zv3EJty34zlNw3MJoZ/nXNXy+Nkvlj1NN30/7tn0uMNTj BTPtbHLi5XUTPIr5XSZ1h+5i25+O82q0Ct0dh3kPF9QDtNK8ct1XfvohG2CnHqmlhRIX rlis52MQAatXJv3GNIPOLLRb3d5ZsOVYhqtU9FAnYHGPrhUzdKcsDhGW7cUCLIX9yu4V aw+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=5Kq+eO5N+yscRltuzqc1xrjMAGWlhYWTm3daje9xGJk=; b=gzEFtd4BtnStAPyPjUwpejPwM5Hqz82/4qydzUID2GES9of7nuemNzDRsDGtDTxMsn nwlPyvpi7J/BkE3cxTclBp/V8w/TfysakTLFMyKB3l0EsvsX3p1eUMbE1b3O3dTiC8ue nVpPJfYhxKqzZjnlkNX85G6A6y97c15J7o3aKIOu3LSu6tQcaun5FicvZJ0WmztQOH+P 4mLawoXhgN2wMvefKNryd4a3PGuirrxtjmKsaxvEGQvZgdDcfI7UEyxAMf6FgBkp2FGm 2im3BTYt2U8A4MhjIVLkuYL4+/2GijYGbDZRJFx9IvLasM/NwmnwnsBO35p4a+0beVz0 ALXQ== X-Gm-Message-State: AOAM530boI0qLA6HV8Ajthja1M8MLHEmlC+SVqyDwhEbxsCxmXFaosbP ge6iVgPO52Fp0wkrvTDRTJ0jwJocyH4fTw== X-Google-Smtp-Source: ABdhPJyAHRb3PU4Xt5Z/2OsCo+zG+PHNDNsA2hMwFBXM58ddDJCH2oer337Lqd6eT34fjhfgqTgckQ== X-Received: by 2002:a05:6214:290:: with SMTP id l16mr24139170qvv.187.1597845026600; Wed, 19 Aug 2020 06:50:26 -0700 (PDT) Received: from [172.17.0.2] ([20.186.111.146]) by smtp.gmail.com with ESMTPSA id u39sm29590481qtc.54.2020.08.19.06.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 06:50:26 -0700 (PDT) Message-ID: <5f3d2e22.1c69fb81.c1d36.72a4@mx.google.com> Date: Wed, 19 Aug 2020 06:50:26 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============5463537467180307820==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mark.marshall@omicronenergy.com Subject: RE: [BlueZ,1/2] btiotest: Correct setting of addr_type for big-endian platforms Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <418845b9-28e1-4356-9ce2-b422720bf948@EXC04-ATKLA.omicron.at> References: <418845b9-28e1-4356-9ce2-b422720bf948@EXC04-ATKLA.omicron.at> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ******** X-Rspamd-Score: 11.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: A0084A1444 X-Rspamd-UID: ceb897 --===============5463537467180307820== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: ERROR:INITIALISED_STATIC: do not initialise statics to 0 #21: FILE: tools/btiotest.c:559: +static int opt_addr_type = 0; WARNING:LONG_LINE: line over 80 characters #31: FILE: tools/btiotest.c:619: + " prio=%d voice=0x%04x addr_type=%u\n", opt_accept, opt_reject, opt_disconn, - total: 1 errors, 1 warnings, 19 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============5463537467180307820==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2CXSFqU5PV8oNQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 16:39:33 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id yHkIFaU5PV8NVgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 16:39:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 08A5442121; Wed, 19 Aug 2020 16:39:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728548AbgHSOhV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 10:37:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:33532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727827AbgHSOhT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 10:37:19 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AACFE20738; Wed, 19 Aug 2020 14:37:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597847838; bh=9XcrtgpDa8lRtRYF9tZCoWHfFG44dFLLY6OtC69LqnQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OowIhNuEd45rf/oFvYaOaETAGF+uvia8dB0Otcx6KfXxpYoM5JxASnYfjSb2YQfgj 5Ze4YoRi6VKMI3ZznYjQmc6sLIEd+20Ek70ZpcUQ4IMFkQTGStuQ3EPqkY3420WEdC 38xm9QiDDEVR790ymYcElxSonP2HDMCEbqyHXw6k= Received: by pali.im (Postfix) id D79AD582; Wed, 19 Aug 2020 16:37:16 +0200 (CEST) Date: Wed, 19 Aug 2020 16:37:16 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Joseph Hwang <josephsih@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Joseph Hwang <josephsih@google.com>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Subject: Re: [PATCH v1 2/2] Bluetooth: sco: expose WBS packet length in socket option Message-ID: <20200819143716.iimo4l3uul7lrpjn@pali> References: <20200813084129.332730-1-josephsih@chromium.org> <20200813164059.v1.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> <CABBYNZJ-nBXeujF2WkMEPYPQhXAphqKCV39gr-QYFdTC3GvjXg@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <CABBYNZJ-nBXeujF2WkMEPYPQhXAphqKCV39gr-QYFdTC3GvjXg@mail.gmail.com> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.93 / 15.00 / 200.00 X-Rspamd-Queue-Id: 08A5442121 X-Rspamd-UID: f13dfe On Friday 14 August 2020 12:56:05 Luiz Augusto von Dentz wrote: > Hi Joseph, > > On Thu, Aug 13, 2020 at 1:42 AM Joseph Hwang <josephsih@chromium.org> wrote: > > > > It is desirable to expose the wideband speech packet length via > > a socket option to the user space so that the user space can set > > the value correctly in configuring the sco connection. > > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > > --- > > > > include/net/bluetooth/bluetooth.h | 2 ++ > > net/bluetooth/sco.c | 8 ++++++++ > > 2 files changed, 10 insertions(+) > > > > diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h > > index 9125effbf4483d..922cc03143def4 100644 > > --- a/include/net/bluetooth/bluetooth.h > > +++ b/include/net/bluetooth/bluetooth.h > > @@ -153,6 +153,8 @@ struct bt_voice { > > > > #define BT_SCM_PKT_STATUS 0x03 > > > > +#define BT_SCO_PKT_LEN 17 > > + > > __printf(1, 2) > > void bt_info(const char *fmt, ...); > > __printf(1, 2) > > diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c > > index dcf7f96ff417e6..97e4e7c7b8cf62 100644 > > --- a/net/bluetooth/sco.c > > +++ b/net/bluetooth/sco.c > > @@ -67,6 +67,7 @@ struct sco_pinfo { > > __u32 flags; > > __u16 setting; > > __u8 cmsg_mask; > > + __u32 pkt_len; > > struct sco_conn *conn; > > }; > > > > @@ -267,6 +268,8 @@ static int sco_connect(struct sock *sk) > > sco_sock_set_timer(sk, sk->sk_sndtimeo); > > } > > > > + sco_pi(sk)->pkt_len = hdev->sco_pkt_len; > > + > > done: > > hci_dev_unlock(hdev); > > hci_dev_put(hdev); > > @@ -1001,6 +1004,11 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, > > err = -EFAULT; > > break; > > > > + case BT_SCO_PKT_LEN: > > + if (put_user(sco_pi(sk)->pkt_len, (u32 __user *)optval)) > > + err = -EFAULT; > > + break; > > Couldn't we expose this via BT_SNDMTU/BT_RCVMTU? Hello! There is already SCO_OPTIONS sock option, uses struct sco_options and contains 'mtu' member. I think that instead of adding new sock option, existing SCO_OPTIONS option should be used. > > default: > > err = -ENOPROTOOPT; > > break; > > -- > > 2.28.0.236.gb10cc79966-goog > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AP7tCb45PV9YwwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 16:39:58 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8AqeB745PV8K3QAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 16:39:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B588642120; Wed, 19 Aug 2020 16:39:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728660AbgHSOiZ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 10:38:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:34578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727854AbgHSOiY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 10:38:24 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C7E052078D; Wed, 19 Aug 2020 14:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597847903; bh=8xz/VjRVV4BpGcOZYP02Lbcq6ZGKUYnAY0ghh4zsOlA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eENPuUx2UY0IrjTdTM+/L7V8UqEKWGH2WGYUTFjbzG/Ea4EG5FsYa0nRgUxtjYZ8w c45HBvCYS1DyuV0dlQm2+fLYexE8iLDTpRICGxjhqvoMmnPofCqtiASu85cilezjaM ywPixZjl7BrbKBWJudG8d/5zKpGhtJULKOGyvyQA= Received: by pali.im (Postfix) id 197E4582; Wed, 19 Aug 2020 16:38:21 +0200 (CEST) Date: Wed, 19 Aug 2020 16:38:21 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Joseph Hwang <josephsih@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Joseph Hwang <josephsih@google.com>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Subject: Re: [PATCH v1 1/2] Bluetooth: btusb: define HCI packet sizes of USB Alts Message-ID: <20200819143821.qptlcrshcamlk4x3@pali> References: <20200813084129.332730-1-josephsih@chromium.org> <20200813164059.v1.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> <CABBYNZ+GPmHuVe_TCUwCVYuOzH8m0=Nmwv48Tn-by_5PnqqwOg@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <CABBYNZ+GPmHuVe_TCUwCVYuOzH8m0=Nmwv48Tn-by_5PnqqwOg@mail.gmail.com> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: B588642120 X-Rspamd-UID: 771743 On Friday 14 August 2020 13:07:25 Luiz Augusto von Dentz wrote: > Hi Joseph, > > On Thu, Aug 13, 2020 at 1:42 AM Joseph Hwang <josephsih@chromium.org> wrote: > > > > It is desirable to define the HCI packet payload sizes of > > USB alternate settings so that they can be exposed to user > > space. > > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > > --- > > > > drivers/bluetooth/btusb.c | 43 ++++++++++++++++++++++++-------- > > include/net/bluetooth/hci_core.h | 1 + > > 2 files changed, 33 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > > index 8d2608ddfd0875..df7cadf6385868 100644 > > --- a/drivers/bluetooth/btusb.c > > +++ b/drivers/bluetooth/btusb.c > > @@ -459,6 +459,22 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { > > #define BTUSB_WAKEUP_DISABLE 14 > > #define BTUSB_USE_ALT1_FOR_WBS 15 > > > > +/* Per core spec 5, vol 4, part B, table 2.1, > > + * list the hci packet payload sizes for various ALT settings. > > + * This is used to set the packet length for the wideband speech. > > + * If a controller does not probe its usb alt setting, the default > > + * value will be 0. Any clients at upper layers should interpret it > > + * as a default value and set a proper packet length accordingly. > > + * > > + * To calculate the HCI packet payload length: > > + * for alternate settings 1 - 5: > > + * hci_packet_size = suggested_max_packet_size * 3 (packets) - > > + * 3 (HCI header octets) > > + * for alternate setting 6: > > + * hci_packet_size = suggested_max_packet_size - 3 (HCI header octets) > > + */ > > +static const int hci_packet_size_usb_alt[] = { 0, 24, 48, 72, 96, 144, 60 }; > > + > > struct btusb_data { > > struct hci_dev *hdev; > > struct usb_device *udev; > > @@ -3958,6 +3974,15 @@ static int btusb_probe(struct usb_interface *intf, > > hdev->notify = btusb_notify; > > hdev->prevent_wake = btusb_prevent_wake; > > > > + if (id->driver_info & BTUSB_AMP) { > > + /* AMP controllers do not support SCO packets */ > > + data->isoc = NULL; > > + } else { > > + /* Interface orders are hardcoded in the specification */ > > + data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); > > + data->isoc_ifnum = ifnum_base + 1; > > + } > > + > > #ifdef CONFIG_PM > > err = btusb_config_oob_wake(hdev); > > if (err) > > @@ -4021,6 +4046,10 @@ static int btusb_probe(struct usb_interface *intf, > > hdev->set_diag = btintel_set_diag; > > hdev->set_bdaddr = btintel_set_bdaddr; > > hdev->cmd_timeout = btusb_intel_cmd_timeout; > > + > > + if (btusb_find_altsetting(data, 6)) > > + hdev->sco_pkt_len = hci_packet_size_usb_alt[6]; > > + > > set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); > > set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); > > set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); > > @@ -4062,15 +4091,6 @@ static int btusb_probe(struct usb_interface *intf, > > btusb_check_needs_reset_resume(intf); > > } > > > > - if (id->driver_info & BTUSB_AMP) { > > - /* AMP controllers do not support SCO packets */ > > - data->isoc = NULL; > > - } else { > > - /* Interface orders are hardcoded in the specification */ > > - data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); > > - data->isoc_ifnum = ifnum_base + 1; > > - } > > - > > if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) && > > (id->driver_info & BTUSB_REALTEK)) { > > hdev->setup = btrtl_setup_realtek; > > @@ -4082,9 +4102,10 @@ static int btusb_probe(struct usb_interface *intf, > > * (DEVICE_REMOTE_WAKEUP) > > */ > > set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); > > - if (btusb_find_altsetting(data, 1)) > > + if (btusb_find_altsetting(data, 1)) { > > set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); > > - else > > + hdev->sco_pkt_len = hci_packet_size_usb_alt[1]; > > + } else > > bt_dev_err(hdev, "Device does not support ALT setting 1"); > > } > > > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h > > index 8caac20556b499..0624496328fc09 100644 > > --- a/include/net/bluetooth/hci_core.h > > +++ b/include/net/bluetooth/hci_core.h > > @@ -417,6 +417,7 @@ struct hci_dev { > > unsigned int acl_pkts; > > unsigned int sco_pkts; > > unsigned int le_pkts; > > + unsigned int sco_pkt_len; > > Id use sco_mtu to so the following check actually does what it intended to do: > > https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/net/bluetooth/sco.c#n283 > > Right now it seems we are using the buffer length as MTU but I think > we should actually use the packet length if it is lower than the > buffer length, actually it doesn't seems SCO packets can be fragmented > so the buffer length must always be big enough to carry a full packet > so I assume setting the packet length as conn->mtu will always be > correct. I agree. We should use sco mtu for this purpose. > > > > __u16 block_len; > > __u16 block_mtu; > > -- > > 2.28.0.236.gb10cc79966-goog > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OP2JO8VAPV8oNQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 17:09:57 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 4AM3OsVAPV8lBAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 17:09:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=omicronenergy.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C5CF3A158F; Wed, 19 Aug 2020 17:09:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726897AbgHSPJw (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 11:09:52 -0400 Received: from ns.omicron.at ([212.183.10.25]:36752 "EHLO ns.omicron.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726792AbgHSPJu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 11:09:50 -0400 Received: from MGW02-ATKLA.omicron.at ([172.25.62.35]) by ns.omicron.at (8.15.2/8.15.2) with ESMTPS id 07JF9me1006602 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:48 +0200 DKIM-Filter: OpenDKIM Filter v2.11.0 ns.omicron.at 07JF9me1006602 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omicronenergy.com; s=default; t=1597849788; bh=iwYDqaF8wLGR9iRaH+BfDezv0AUJ8LlIY9TDOWahSMo=; h=From:To:CC:Subject:Date:From; b=b8uFkOQUAqLbBVKgtpeB0madR6IMa4tX2hlsAqEuyrXuIm/iaHhntARIP8BIEMxoe KDqschd3uxLK4C9eA120yX6YSmWE8uhhXC8eR9580ElXeWst5RLHxEswd2hmz+88ik fBLCFqDcJXTB90uusJ6MsPqjE2F6+R9rBNcQ2juI= Received: from MGW02-ATKLA.omicron.at (localhost [127.0.0.1]) by MGW02-ATKLA.omicron.at (Postfix) with ESMTP id 1874AA0054 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:47 +0200 (CEST) Received: from MGW01-ATKLA.omicron.at (unknown [172.25.62.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by MGW02-ATKLA.omicron.at (Postfix) with ESMTPS id 1660DA0053 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:47 +0200 (CEST) Received: from EXC04-ATKLA.omicron.at ([172.22.100.189]) by MGW01-ATKLA.omicron.at with ESMTP id 07JF9l7E027212-07JF9l7G027212 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=CAFAIL) for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:47 +0200 Received: from marmar13.omicron.at (172.22.32.104) by EXC04-ATKLA.omicron.at (172.22.100.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 19 Aug 2020 17:09:41 +0200 From: Mark Marshall <mark.marshall@omicronenergy.com> To: <linux-bluetooth@vger.kernel.org> CC: Mark Marshall <mark.marshall@omicronenergy.com> Subject: [PATCH BlueZ 0/2] Add support for LE profiles (LE-L2CAP) Date: Wed, 19 Aug 2020 17:09:29 +0200 X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.22.32.104] X-ClientProxiedBy: EXC04-ATKLA.omicron.at (172.22.100.189) To EXC04-ATKLA.omicron.at (172.22.100.189) Message-ID: <60274e5a-d210-425d-bba5-946119fd4f87@EXC04-ATKLA.omicron.at> X-FE-Policy-ID: 1:1:1:SYSTEM Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.89 / 15.00 / 200.00 X-Rspamd-Queue-Id: C5CF3A158F X-Rspamd-UID: cda50c I wanted to create a custom profile that used LE-L2CAP, and I found that there were a couple features missing that I needed. 1) It is not possible to set the Address Type in the profile. 2) It is not possible to discover the "Auto Chosen" PSM value. The first patch allows the address type to be specified in the DBus API. The second patch allows information about the profile to be read back. This is needed because, on both Andorid and iOS, when using LE-L2CAP, the application must inform the OS about which PSM to use. It is possible for the server to advertise this value with GATT, but the applciation has to read it from somewhere. Mark Marshall (2): src/profile.c: Allow the "Address Type" to be set src/profile.c: Add a GetProfileInfo method doc/profile-api.txt | 23 +++++++++ src/profile.c | 113 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 135 insertions(+), 1 deletion(-) -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UM3GOctAPV8oNQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 17:10:03 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uNwZOMtAPV8d/wAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 17:10:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=omicronenergy.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EDF87A1260; Wed, 19 Aug 2020 17:09:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727932AbgHSPJ6 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 11:09:58 -0400 Received: from ns.omicron.at ([212.183.10.25]:36798 "EHLO ns.omicron.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726792AbgHSPJz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 11:09:55 -0400 Received: from MGW02-ATKLA.omicron.at ([172.25.62.35]) by ns.omicron.at (8.15.2/8.15.2) with ESMTPS id 07JF9rv0006632 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:53 +0200 DKIM-Filter: OpenDKIM Filter v2.11.0 ns.omicron.at 07JF9rv0006632 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omicronenergy.com; s=default; t=1597849793; bh=xrgN5naBVJKHLCenPyKM1RaJmTZZdhJXPiis7fWj4YY=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=gAY3xwu4uagUfGcAczMP9SNDQzzOmBFIT/YBuyqtbRaAPG1FwbDH+YiQnQCkZRKM8 fePY/pV23rK8EuWidLlq83zrNbiJY6/45plxjd3VLeGkcQZN90FqVV6jPmdBn4vmVV 9z4SCy53ReHh/pUc6+hzJAMRa2N//z8CNurRYIDg= Received: from MGW02-ATKLA.omicron.at (localhost [127.0.0.1]) by MGW02-ATKLA.omicron.at (Postfix) with ESMTP id 1B4E1A0054 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:52 +0200 (CEST) Received: from MGW01-ATKLA.omicron.at (unknown [172.25.62.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by MGW02-ATKLA.omicron.at (Postfix) with ESMTPS id 1949FA0053 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:52 +0200 (CEST) Received: from EXC04-ATKLA.omicron.at ([172.22.100.189]) by MGW01-ATKLA.omicron.at with ESMTP id 07JF9qjn027219-07JF9qjp027219 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=CAFAIL) for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:53 +0200 Received: from marmar13.omicron.at (172.22.32.104) by EXC04-ATKLA.omicron.at (172.22.100.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 19 Aug 2020 17:09:44 +0200 From: Mark Marshall <mark.marshall@omicronenergy.com> To: <linux-bluetooth@vger.kernel.org> CC: Mark Marshall <mark.marshall@omicronenergy.com> Subject: [PATCH BlueZ 1/2] src/profile.c: Allow the "Address Type" to be set Date: Wed, 19 Aug 2020 17:09:30 +0200 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819150931.3005-1-mark.marshall@omicronenergy.com> References: <20200819150931.3005-1-mark.marshall@omicronenergy.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.22.32.104] X-ClientProxiedBy: EXC04-ATKLA.omicron.at (172.22.100.189) To EXC04-ATKLA.omicron.at (172.22.100.189) Message-ID: <98fed7ef-1975-48ca-9ea3-1482d938a806@EXC04-ATKLA.omicron.at> X-FE-Policy-ID: 1:1:1:SYSTEM Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.40 / 15.00 / 200.00 X-Rspamd-Queue-Id: EDF87A1260 X-Rspamd-UID: 0d4112 This allows us to have profiles that use LE L2CAP connections. --- doc/profile-api.txt | 10 ++++++++++ src/profile.c | 18 +++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/doc/profile-api.txt b/doc/profile-api.txt index 183c6c11a..8c7d0a06d 100644 --- a/doc/profile-api.txt +++ b/doc/profile-api.txt @@ -112,6 +112,16 @@ Object path /org/bluez Profile features (for SDP record) + uint16 AddressType + + Allows the Address Type to be + selected, can be either + BDADDR_BREDR, BDADDR_LE_PUBLIC + or BDADDR_LE_RANDOM. If an LE + address is selected and the + device is not found, the other + sort of LE address is tried. + Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.AlreadyExists diff --git a/src/profile.c b/src/profile.c index 6961a107b..10850f305 100644 --- a/src/profile.c +++ b/src/profile.c @@ -677,6 +677,7 @@ struct ext_profile { guint id; BtIOMode mode; + uint8_t addr_type; BtIOSecLevel sec_level; bool authorize; @@ -1173,9 +1174,16 @@ static struct ext_io *create_conn(struct ext_io *server, GIOChannel *io, struct btd_service *service; struct ext_io *conn; GIOCondition cond; + uint8_t addr_type; char addr[18]; - device = btd_adapter_find_device(server->adapter, dst, BDADDR_BREDR); + addr_type = server->ext->addr_type; + device = btd_adapter_find_device(server->adapter, dst, addr_type); + if (device == NULL && addr_type != BDADDR_BREDR) { + addr_type ^= (BDADDR_LE_PUBLIC | BDADDR_LE_RANDOM); + device = btd_adapter_find_device(server->adapter, dst, + addr_type); + } if (device == NULL) { ba2str(dst, addr); error("%s device %s not found", server->ext->name, addr); @@ -1350,6 +1358,7 @@ static uint32_t ext_start_servers(struct ext_profile *ext, io = bt_io_listen(connect, confirm, l2cap, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, btd_adapter_get_address(adapter), + BT_IO_OPT_SOURCE_TYPE, ext->addr_type, BT_IO_OPT_MODE, ext->mode, BT_IO_OPT_PSM, psm, BT_IO_OPT_SEC_LEVEL, ext->sec_level, @@ -1567,6 +1576,8 @@ static int connect_io(struct ext_io *conn, const bdaddr_t *src, io = bt_io_connect(ext_connect, conn, NULL, &gerr, BT_IO_OPT_SOURCE_BDADDR, src, BT_IO_OPT_DEST_BDADDR, dst, + BT_IO_OPT_SOURCE_TYPE, ext->addr_type, + BT_IO_OPT_DEST_TYPE, ext->addr_type, BT_IO_OPT_SEC_LEVEL, ext->sec_level, BT_IO_OPT_PSM, conn->psm, BT_IO_OPT_INVALID); @@ -2285,6 +2296,11 @@ static int parse_ext_opt(struct ext_profile *ext, const char *key, dbus_message_iter_get_basic(value, &str); free(ext->service); ext->service = bt_name2string(str); + } else if (strcasecmp(key, "AddressType") == 0) { + if (type != DBUS_TYPE_UINT16) + return -EINVAL; + dbus_message_iter_get_basic(value, &u16); + ext->addr_type = u16; } return 0; -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uHn4INJAPV8oNQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 17:10:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id KDGRH9JAPV8mBAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 17:10:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=omicronenergy.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2288AA16D3; Wed, 19 Aug 2020 17:10:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727087AbgHSPJ7 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 11:09:59 -0400 Received: from ns.omicron.at ([212.183.10.25]:36800 "EHLO ns.omicron.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726929AbgHSPJ4 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 11:09:56 -0400 Received: from MGW02-ATKLA.omicron.at ([172.25.62.35]) by ns.omicron.at (8.15.2/8.15.2) with ESMTPS id 07JF9rja006636 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:53 +0200 DKIM-Filter: OpenDKIM Filter v2.11.0 ns.omicron.at 07JF9rja006636 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omicronenergy.com; s=default; t=1597849793; bh=Kmfb1ak+O3JR1DK8ZEFZVPytQ63/ubyHrserK1hM8qw=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=kHWR7b2TIebTLFjSjFTxEiFu6XfX+mkoTq5Qo11zE5o9XG1UxofeW5q5zeiN7hHn3 qa2/PFusFJuJhr+wQaVyVfXBKdJj86iqC36iTtNyXC9KoPW00j6mVN6lOr/j1cIG9d I/t5jQCft2hufQFjJ6yUjwAmPmsg7VcvlW4zUJso= Received: from MGW02-ATKLA.omicron.at (localhost [127.0.0.1]) by MGW02-ATKLA.omicron.at (Postfix) with ESMTP id 29114A0062 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:52 +0200 (CEST) Received: from MGW01-ATKLA.omicron.at (unknown [172.25.62.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by MGW02-ATKLA.omicron.at (Postfix) with ESMTPS id 26DE2A0053 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:52 +0200 (CEST) Received: from EXC04-ATKLA.omicron.at ([172.22.100.189]) by MGW01-ATKLA.omicron.at with ESMTP id 07JF9qjn027219-07JF9qjq027219 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=CAFAIL) for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 17:09:53 +0200 Received: from marmar13.omicron.at (172.22.32.104) by EXC04-ATKLA.omicron.at (172.22.100.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 19 Aug 2020 17:09:47 +0200 From: Mark Marshall <mark.marshall@omicronenergy.com> To: <linux-bluetooth@vger.kernel.org> CC: Mark Marshall <mark.marshall@omicronenergy.com> Subject: [PATCH BlueZ 2/2] src/profile.c: Add a GetProfileInfo method Date: Wed, 19 Aug 2020 17:09:31 +0200 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819150931.3005-1-mark.marshall@omicronenergy.com> References: <20200819150931.3005-1-mark.marshall@omicronenergy.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.22.32.104] X-ClientProxiedBy: EXC04-ATKLA.omicron.at (172.22.100.189) To EXC04-ATKLA.omicron.at (172.22.100.189) Message-ID: <2303f692-bb7c-4851-86fa-befde45b4b32@EXC04-ATKLA.omicron.at> X-FE-Policy-ID: 1:1:1:SYSTEM Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.40 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2288AA16D3 X-Rspamd-UID: e13bab Add a GetProfileInfo method to org.bluez.ProfileManager1 --- doc/profile-api.txt | 13 +++++++ src/profile.c | 93 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/doc/profile-api.txt b/doc/profile-api.txt index 8c7d0a06d..d13703ab4 100644 --- a/doc/profile-api.txt +++ b/doc/profile-api.txt @@ -133,6 +133,19 @@ Object path /org/bluez Possible errors: org.bluez.Error.DoesNotExist + options GetProfileInfo(object profile, object adapter) + + This returns a dictionary of options for the + profile. Values returned are: UUID, Name, + Path, Service, Mode and AddressType. The + adapter parameter is optional - if it is + non-empty, then two additional values might be + returned, if the profile is active on the + specified adapter: PSM and Channel. + + Possible errors: org.bluez.Error.InvalidArguments + org.bluez.Error.DoesNotExist + Profile hierarchy ================= diff --git a/src/profile.c b/src/profile.c index 10850f305..e287a66d7 100644 --- a/src/profile.c +++ b/src/profile.c @@ -2509,6 +2509,96 @@ static DBusMessage *unregister_profile(DBusConnection *conn, return dbus_message_new_method_return(msg); } +static DBusMessage *get_profile_info(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + DBusMessage *reply; + DBusMessageIter iter, dict; + const char *path, *adapter, *sender; + struct ext_profile *ext; + uint16_t u16; + GSList *l, *next; + + sender = dbus_message_get_sender(msg); + + DBG("sender %s", sender); + + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, + DBUS_TYPE_OBJECT_PATH, &adapter, + DBUS_TYPE_INVALID)) { + return btd_error_invalid_args(msg); + } + + if (adapter && !*adapter) + adapter = NULL; + + ext = find_ext_profile(sender, path); + if (!ext) + return btd_error_does_not_exist(msg); + + reply = dbus_message_new_method_return(msg); + + dbus_message_iter_init_append(reply, &iter); + + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, + "{sv}", &dict); + + g_dbus_dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, + &ext->uuid); + if (ext->name) { + g_dbus_dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, + &ext->name); + } + if (ext->path) { + g_dbus_dict_append_entry(&dict, "Path", DBUS_TYPE_STRING, + &ext->path); + } + if (ext->service) { + g_dbus_dict_append_entry(&dict, "Service", DBUS_TYPE_STRING, + &ext->service); + } + + u16 = ext->mode; + g_dbus_dict_append_entry(&dict, "Mode", DBUS_TYPE_UINT16, + &u16); + + u16 = ext->addr_type; + g_dbus_dict_append_entry(&dict, "AddressType", DBUS_TYPE_UINT16, + &u16); + + if (adapter) { + for (l = ext->servers; l != NULL; l = next) { + struct ext_io *server = l->data; + const char *ctype; + + DBG("server:%p %d %d psm:%d chan:%d", + server, server->resolving, server->connected, + server->psm, server->chan); + + next = g_slist_next(l); + + if (strcmp(adapter, adapter_get_path(server->adapter))) + continue; + + if (server->proto == BTPROTO_L2CAP) { + ctype = "PSM"; + u16 = server->psm; + } else if (server->proto == BTPROTO_RFCOMM) { + ctype = "Channel"; + u16 = server->chan; + } else { + continue; + } + g_dbus_dict_append_entry( + &dict, ctype, DBUS_TYPE_UINT16, &u16); + } + } + + dbus_message_iter_close_container(&iter, &dict); + + return reply; +} + static const GDBusMethodTable methods[] = { { GDBUS_METHOD("RegisterProfile", GDBUS_ARGS({ "profile", "o"}, { "UUID", "s" }, @@ -2516,6 +2606,9 @@ static const GDBusMethodTable methods[] = { NULL, register_profile) }, { GDBUS_METHOD("UnregisterProfile", GDBUS_ARGS({ "profile", "o" }), NULL, unregister_profile) }, + { GDBUS_METHOD("GetProfileInfo", + GDBUS_ARGS({ "profile", "o" }, { "adapter", "o" }), + GDBUS_ARGS({ "options", "a{sv}" }), get_profile_info) }, { } }; -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8C1ZFT1tPV9kEgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 20:19:41 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CK+3Ez1tPV8GmwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 20:19:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 70D4DA1666; Wed, 19 Aug 2020 20:19:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726578AbgHSSTQ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 14:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725997AbgHSSTO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 14:19:14 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DF09C061757 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 11:19:14 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id u24so20707983oic.7 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 11:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=m0yXXFotQWroHLaVKba/7dhmvFCGNHuFoGGgLqaXvDA=; b=JQDJHmbp5ZXBQhpzSe7Q88DuMFh0mAh3S2t0cvF+7IXcPBibqH5IZLbLonyuV7RMuH UqlBUQjIrXKnGlmjxHH4/rkAntqpJ/W3QvXFdzjcXz8YiKl7f4wyGUG5q9iRopp8xfpQ qirWenKn/6RqJrGDJS2OIVrK+3HGVaS+u5/W2/lsAbtRfiz7RGQjyrAxvbhNUhtp0Gqe S244ojAn5EHaUh+7etuw0XSyTFadcXY6JTaUAg+TWZ2Jyg61vXOpy8esvAbuoKYjtDAi o/6nNsVBUxntciXD8ZOPqqzExd7sA8MWsp5IQYA/yPAQrYNjpjDZbqmcWm0QxJ0PIT/N JOdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=m0yXXFotQWroHLaVKba/7dhmvFCGNHuFoGGgLqaXvDA=; b=CXcpJNOqLO2GKYANhD16hugW7rk5vjP/98HuKg2V8ovXVNoYVauf2EpkCYfg0xoSio vbf2qvlwo16y4XeaKjHkwtek1P+l2TwZnAYa9dmCuyFC78KQfGtG6NGskvcCz/LorORg QvBc9vQSRsglk3tRpTyPeMFFd88OsdDIYc26lSUknP1gl+JDf31MqxzxcQ+OKC4G2iGy 81T0WLodieC5F9Pirg0xGp8LvNsydfeldYxNMdX6/agw//iGGPSFPEQ4JTAMn/bFtf5L MTjXCxVilqhDE4BnQ4iqB+x4LImzt9aiTBVZhYtOEa19ur9MRIh6/ULYaZkpDnTUWrXf MnnQ== X-Gm-Message-State: AOAM530GhBdFvN0q/ZAw/BfwXHDkTGcs+zn4q2vTbz8NDNw3kT5tMhNF uE7fpjP/LqGTZwO8fobWIre6e7MyzvRUOfZhSpcQon0/ X-Google-Smtp-Source: ABdhPJxMfae1EFRxtxSX00n6JKXpJMdp1Bst+fRKB3P9Q3jVNqtUC/hjjnmOxfmfA9p4tbM/m2rIHkkcq9ZCbuLNnbw= X-Received: by 2002:aca:cc50:: with SMTP id c77mr3837149oig.152.1597861152607; Wed, 19 Aug 2020 11:19:12 -0700 (PDT) MIME-Version: 1.0 References: <HE1PR05MB3338001B735642B334087FCBFC5D0@HE1PR05MB3338.eurprd05.prod.outlook.com> In-Reply-To: <HE1PR05MB3338001B735642B334087FCBFC5D0@HE1PR05MB3338.eurprd05.prod.outlook.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 19 Aug 2020 11:19:02 -0700 Message-ID: <CABBYNZJ3SG9pNYBNyusDagmwRG4PsEY189k2d31DmC=j9bTDDg@mail.gmail.com> Subject: Re: LE Secure Connections: Disconnection after pairing To: =?UTF-8?B?SmFyaSBKw6TDpHNrZWzDpA==?= <Jari.Jaaskela@oulu.fi> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.94 / 15.00 / 200.00 X-Rspamd-Queue-Id: 70D4DA1666 X-Rspamd-UID: 7b6db9 Hi Jari, On Wed, Aug 19, 2020 at 12:33 AM Jari J=C3=A4=C3=A4skel=C3=A4 <Jari.Jaaskel= a@oulu.fi> wrote: > > Hey, > > I encountered this issue in July, and I reported it as a bug here: https:= //bugzilla.kernel.org/show_bug.cgi?id=3D208637. > See the bug report for logs. > > Here's the description: > > I have been trying to establish secure connection to a gatt service. Pair= ing completes successfully (using out-of-band data), and the client can rea= d characteristic that has encrypt-authenticated security level, but the con= nection is lost soon after pairing (as seen in the btmon log). This seems t= o happen because the controller responds with reason Connection Timeout (0x= 08). That is normally a link layer problem like link supervision timeout which is part of the controller not the host stack, check if you can reproduce this using another controller. > Hardware: Raspberry Pi 4 Model B (Bluetooth chip: Cypress CYW43455). > Tested on: 4.19.118-v7l+, 5.4.42-v7l. > Tested BlueZ: 5.53, 5.54, master (commit 6ea1b038eedeca31c3796ac921e25509= d48d70ec) > > Best regards, > Jari J=C3=A4=C3=A4skel=C3=A4 --=20 Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sFv6OqhtPV+ncwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 20:21:28 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IDYlOahtPV87kwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 20:21:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AA96D4212C; Wed, 19 Aug 2020 20:21:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726810AbgHSSVN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 14:21:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726735AbgHSSVM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 14:21:12 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13A84C061757; Wed, 19 Aug 2020 11:21:12 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id x24so19831435otp.3; Wed, 19 Aug 2020 11:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=zBMYHGoLqcQIDa75kPEyh/KB+iBrkpptU65EqjbhG7Y=; b=o2l1Nfy+8w9JtCsVwTjWxIgVHG2aUehxoeLFi30efLZOoVWoTEEBaUi5FOCfLKi04y b9mZolDBq8uWo4mIHYQnk61/OsVfF0WQUTy1P5jBSM/ArtN0BnwtUTTMMuDym8emq0E3 QvRYmTZu1FR1MR378xPRy2DVifzGjzDaCCcZpIleQBJabDFrDcpaGKvYA+zpOW4y9vm0 0xoXH4sDB65Re0fDGtrWucPfe7xdPAVtdJ1d50Jze9/V/alujo9zmKnslM/4bmD/FtpJ GZpCnEHAqQIOPt7fLL1TmMrnAQqEhkgghq7JGTZ02MsEd8dU2v195s4TAiunFEIy/2ow RhgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=zBMYHGoLqcQIDa75kPEyh/KB+iBrkpptU65EqjbhG7Y=; b=mOwwuyJwUQJ6S1gCczB6LpUQxkerbdzv07Ny/x/jy5qAaewxvOzI0ZLD6lRFVtek43 pHCbtYC2b+7CZvuzZoQmyOVueHr0hXa3Gh/uWAc7tCcXQufN8Q/IHc89d/tT5Yd2eT70 axK40Oe6m/1MUYvUNeZOkL6wxFcTc239atuGGwrIBQ7WvWgBLrPLhPdRsbG9sdUBM61R v48Pb2myq89weRKNHrCD5rIPVGtq3o6dJmRJW6ERBhJxg3O7jS6s+uX+kO9FkJpeN0JN Z30tsiVEgUSVdC5uBMVYUdMYoOukjM5UMxamMOJRmtPEQ1VL1s/RtMTwbmnMeVZTU+X3 8Ntw== X-Gm-Message-State: AOAM532VDnceF/HLiggW9K5/T3UIAqFhOx5Ro0UfyTMV9Foj7KcaV5aw XdT2i5unt1wELI1z0bMeFz9uH6f0IDebtBztnwM= X-Google-Smtp-Source: ABdhPJyyFtBGtBDQDC0+qpIvbBVOSiO9PH5RJce1zRO3VRRQKtT74SqDuprv6s1YgJttg07Y2wYBSfyUOU1rwvHn3r0= X-Received: by 2002:a9d:429:: with SMTP id 38mr18272918otc.88.1597861271397; Wed, 19 Aug 2020 11:21:11 -0700 (PDT) MIME-Version: 1.0 References: <20200813084129.332730-1-josephsih@chromium.org> <20200813164059.v1.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> <CABBYNZJ-nBXeujF2WkMEPYPQhXAphqKCV39gr-QYFdTC3GvjXg@mail.gmail.com> <20200819143716.iimo4l3uul7lrpjn@pali> In-Reply-To: <20200819143716.iimo4l3uul7lrpjn@pali> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 19 Aug 2020 11:21:00 -0700 Message-ID: <CABBYNZJVDk6LWqyY7h8=KwpA4Oub+aCb3WEWnxk_AGWPvgmatg@mail.gmail.com> Subject: Re: [PATCH v1 2/2] Bluetooth: sco: expose WBS packet length in socket option To: =?UTF-8?Q?Pali_Roh=C3=A1r?= <pali@kernel.org> Cc: Joseph Hwang <josephsih@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Joseph Hwang <josephsih@google.com>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: AA96D4212C X-Rspamd-UID: 36b54e Hi Pali, On Wed, Aug 19, 2020 at 7:37 AM Pali Roh=C3=A1r <pali@kernel.org> wrote: > > On Friday 14 August 2020 12:56:05 Luiz Augusto von Dentz wrote: > > Hi Joseph, > > > > On Thu, Aug 13, 2020 at 1:42 AM Joseph Hwang <josephsih@chromium.org> w= rote: > > > > > > It is desirable to expose the wideband speech packet length via > > > a socket option to the user space so that the user space can set > > > the value correctly in configuring the sco connection. > > > > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > > > --- > > > > > > include/net/bluetooth/bluetooth.h | 2 ++ > > > net/bluetooth/sco.c | 8 ++++++++ > > > 2 files changed, 10 insertions(+) > > > > > > diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetoot= h/bluetooth.h > > > index 9125effbf4483d..922cc03143def4 100644 > > > --- a/include/net/bluetooth/bluetooth.h > > > +++ b/include/net/bluetooth/bluetooth.h > > > @@ -153,6 +153,8 @@ struct bt_voice { > > > > > > #define BT_SCM_PKT_STATUS 0x03 > > > > > > +#define BT_SCO_PKT_LEN 17 > > > + > > > __printf(1, 2) > > > void bt_info(const char *fmt, ...); > > > __printf(1, 2) > > > diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c > > > index dcf7f96ff417e6..97e4e7c7b8cf62 100644 > > > --- a/net/bluetooth/sco.c > > > +++ b/net/bluetooth/sco.c > > > @@ -67,6 +67,7 @@ struct sco_pinfo { > > > __u32 flags; > > > __u16 setting; > > > __u8 cmsg_mask; > > > + __u32 pkt_len; > > > struct sco_conn *conn; > > > }; > > > > > > @@ -267,6 +268,8 @@ static int sco_connect(struct sock *sk) > > > sco_sock_set_timer(sk, sk->sk_sndtimeo); > > > } > > > > > > + sco_pi(sk)->pkt_len =3D hdev->sco_pkt_len; > > > + > > > done: > > > hci_dev_unlock(hdev); > > > hci_dev_put(hdev); > > > @@ -1001,6 +1004,11 @@ static int sco_sock_getsockopt(struct socket *= sock, int level, int optname, > > > err =3D -EFAULT; > > > break; > > > > > > + case BT_SCO_PKT_LEN: > > > + if (put_user(sco_pi(sk)->pkt_len, (u32 __user *)optva= l)) > > > + err =3D -EFAULT; > > > + break; > > > > Couldn't we expose this via BT_SNDMTU/BT_RCVMTU? > > Hello! > > There is already SCO_OPTIONS sock option, uses struct sco_options and > contains 'mtu' member. > > I think that instead of adding new sock option, existing SCO_OPTIONS > option should be used. We are moving away from type specific options to so options like BT_SNDMTU/BT_RCVMTU should be supported in all socket types. > > > > default: > > > err =3D -ENOPROTOOPT; > > > break; > > > -- > > > 2.28.0.236.gb10cc79966-goog > > > > > > > > > -- > > Luiz Augusto von Dentz --=20 Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WF0kDR1uPV/MEwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 20:23:25 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +PpCCx1uPV96LwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 20:23:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B78DE4216A; Wed, 19 Aug 2020 20:23:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbgHSSXL (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 14:23:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:47076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726646AbgHSSXJ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 14:23:09 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB6BE20758; Wed, 19 Aug 2020 18:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597861388; bh=qy/ZEjEhG1i+wvQPbJtGZ9T5kPpw8NHao4bG1dxNlns=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JPzbGLOI8lD/e6rSmRoXD3w+zE23xhVb8yRK2e9oKUHzr8OR98pJFBbBmA0Nj2Aiy cZW+xhiPKr9jpgAH2uRYwykye0AJi+f8RkpVzVNL9NOGgf4Ek+/Bm25GGJqmXmDI2j r3FExyclO1T94xuXOTBfHDN8iugHJ72WxtziqkXg= Received: by pali.im (Postfix) id 9552E582; Wed, 19 Aug 2020 20:23:06 +0200 (CEST) Date: Wed, 19 Aug 2020 20:23:06 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Joseph Hwang <josephsih@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Joseph Hwang <josephsih@google.com>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Subject: Re: [PATCH v1 2/2] Bluetooth: sco: expose WBS packet length in socket option Message-ID: <20200819182306.wvyht6ocyqpo75tp@pali> References: <20200813084129.332730-1-josephsih@chromium.org> <20200813164059.v1.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> <CABBYNZJ-nBXeujF2WkMEPYPQhXAphqKCV39gr-QYFdTC3GvjXg@mail.gmail.com> <20200819143716.iimo4l3uul7lrpjn@pali> <CABBYNZJVDk6LWqyY7h8=KwpA4Oub+aCb3WEWnxk_AGWPvgmatg@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <CABBYNZJVDk6LWqyY7h8=KwpA4Oub+aCb3WEWnxk_AGWPvgmatg@mail.gmail.com> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: B78DE4216A X-Rspamd-UID: 24d202 On Wednesday 19 August 2020 11:21:00 Luiz Augusto von Dentz wrote: > Hi Pali, > > On Wed, Aug 19, 2020 at 7:37 AM Pali Rohár <pali@kernel.org> wrote: > > > > On Friday 14 August 2020 12:56:05 Luiz Augusto von Dentz wrote: > > > Hi Joseph, > > > > > > On Thu, Aug 13, 2020 at 1:42 AM Joseph Hwang <josephsih@chromium.org> wrote: > > > > > > > > It is desirable to expose the wideband speech packet length via > > > > a socket option to the user space so that the user space can set > > > > the value correctly in configuring the sco connection. > > > > > > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > > > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > > > > --- > > > > > > > > include/net/bluetooth/bluetooth.h | 2 ++ > > > > net/bluetooth/sco.c | 8 ++++++++ > > > > 2 files changed, 10 insertions(+) > > > > > > > > diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h > > > > index 9125effbf4483d..922cc03143def4 100644 > > > > --- a/include/net/bluetooth/bluetooth.h > > > > +++ b/include/net/bluetooth/bluetooth.h > > > > @@ -153,6 +153,8 @@ struct bt_voice { > > > > > > > > #define BT_SCM_PKT_STATUS 0x03 > > > > > > > > +#define BT_SCO_PKT_LEN 17 > > > > + > > > > __printf(1, 2) > > > > void bt_info(const char *fmt, ...); > > > > __printf(1, 2) > > > > diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c > > > > index dcf7f96ff417e6..97e4e7c7b8cf62 100644 > > > > --- a/net/bluetooth/sco.c > > > > +++ b/net/bluetooth/sco.c > > > > @@ -67,6 +67,7 @@ struct sco_pinfo { > > > > __u32 flags; > > > > __u16 setting; > > > > __u8 cmsg_mask; > > > > + __u32 pkt_len; > > > > struct sco_conn *conn; > > > > }; > > > > > > > > @@ -267,6 +268,8 @@ static int sco_connect(struct sock *sk) > > > > sco_sock_set_timer(sk, sk->sk_sndtimeo); > > > > } > > > > > > > > + sco_pi(sk)->pkt_len = hdev->sco_pkt_len; > > > > + > > > > done: > > > > hci_dev_unlock(hdev); > > > > hci_dev_put(hdev); > > > > @@ -1001,6 +1004,11 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, > > > > err = -EFAULT; > > > > break; > > > > > > > > + case BT_SCO_PKT_LEN: > > > > + if (put_user(sco_pi(sk)->pkt_len, (u32 __user *)optval)) > > > > + err = -EFAULT; > > > > + break; > > > > > > Couldn't we expose this via BT_SNDMTU/BT_RCVMTU? > > > > Hello! > > > > There is already SCO_OPTIONS sock option, uses struct sco_options and > > contains 'mtu' member. > > > > I think that instead of adding new sock option, existing SCO_OPTIONS > > option should be used. > > We are moving away from type specific options to so options like > BT_SNDMTU/BT_RCVMTU should be supported in all socket types. Yes, this make sense. But I guess that SCO_OPTIONS should be provided for backward compatibility as it is already used by lot of userspace applications. So for me it looks like that BT_SNDMTU/BT_RCVMTU should return same value as SCO_OPTIONS. > > > > > > default: > > > > err = -ENOPROTOOPT; > > > > break; > > > > -- > > > > 2.28.0.236.gb10cc79966-goog > > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AKrLEbluPV+ncwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 20:26:01 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id kPBuELluPV8o3wEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 20:26:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0511CA157A; Wed, 19 Aug 2020 20:25:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726715AbgHSSZr (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 14:25:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgHSSZp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 14:25:45 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77F70C061757; Wed, 19 Aug 2020 11:25:45 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id x24so19842704otp.3; Wed, 19 Aug 2020 11:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Uj2G5qDhsm+bapptHCJ7Bq0u40iHl5V2rOPjbm76rTA=; b=hE17SsbRqQpRbkfOlDKQ7cHbfmXUCJ0VwlKiGbZoC2ttuB63xjWR6C00YVa12lip+H 5Asa0XO6gTnbfwrYxuWZ3ol5YiA0QBQdkUPdpJ5TwkCl00rK0Sio3v6UDQCfl3a3OZRC nkVBzNoGfS+3q7RZy4Qep59FvFffEAvV1aMebFGXjGCN9CDSDpVmhHi3gE0WprXGlXir 9JMn9lLil/9r56iq7V1W7A/CLbZkGasag9MGOaS7kt0J4tv0m5RzyRMpUXKPa3uYenzy 7aHsknBx/m6nOLZBPz4cYKibvDOhl5BUwdrud2oKoxuv88+ERZIeymKB/LtV/hUoguCY Qitw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Uj2G5qDhsm+bapptHCJ7Bq0u40iHl5V2rOPjbm76rTA=; b=N/Uoss4WLC/vRYkwLdIJTZy8FdlWVEUsS1pOXCt45bhTEl0CQ2neJ7pFXsiSSIU9ry KUJRLBCjZLhiJ8nDYF6n7OY+SR09jUqCvFJuvjAZLugZQJ2KTtZhZXam6pLvA0hWD1hf hjdbalHrwEi+fhcTi0g6gXRpPJR1+N7Aihqo8F+lGkyR9g1+u7fdKhGyLpN8u3+v3+AJ fQayyHsetHgSPuwRqgzgEFpK7naGy6KUsAm1e7Zkqy0BNu2FplEMWyFQvC/2obKnZUh7 1bxcXhEbXhj93vnr4H77TcPRZCQqSy7CM8Ds4IchsmDas6wSOJ4T4oMMN6NK3HdMeCTp Yj3w== X-Gm-Message-State: AOAM531GTGzzKhOzYS416T1AMdheOC1PWVdmCs4DGGKgY0iV9D6yxPGM aPR0bRp6/7bM1WVgzFATRoEuEVU2X4OjSah1lOs= X-Google-Smtp-Source: ABdhPJwJR8sF/ZcOD7xlXzSk86ZIVJ765re8VslROHCqbVK/phzo2qOwJwntqdZES6IBnWgK5FawZmDnJIMv7glO6L8= X-Received: by 2002:a9d:24e7:: with SMTP id z94mr19379061ota.91.1597861544816; Wed, 19 Aug 2020 11:25:44 -0700 (PDT) MIME-Version: 1.0 References: <20200813084129.332730-1-josephsih@chromium.org> <20200813164059.v1.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> <CABBYNZJ-nBXeujF2WkMEPYPQhXAphqKCV39gr-QYFdTC3GvjXg@mail.gmail.com> <20200819143716.iimo4l3uul7lrpjn@pali> <CABBYNZJVDk6LWqyY7h8=KwpA4Oub+aCb3WEWnxk_AGWPvgmatg@mail.gmail.com> <20200819182306.wvyht6ocyqpo75tp@pali> In-Reply-To: <20200819182306.wvyht6ocyqpo75tp@pali> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 19 Aug 2020 11:25:34 -0700 Message-ID: <CABBYNZ+F=-YsZoL4B9=XQvHSs9wU=0W3iqbYn4s65JMAJAmAKw@mail.gmail.com> Subject: Re: [PATCH v1 2/2] Bluetooth: sco: expose WBS packet length in socket option To: =?UTF-8?Q?Pali_Roh=C3=A1r?= <pali@kernel.org> Cc: Joseph Hwang <josephsih@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Joseph Hwang <josephsih@google.com>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0511CA157A X-Rspamd-UID: b4dc32 On Wed, Aug 19, 2020 at 11:23 AM Pali Roh=C3=A1r <pali@kernel.org> wrote: > > On Wednesday 19 August 2020 11:21:00 Luiz Augusto von Dentz wrote: > > Hi Pali, > > > > On Wed, Aug 19, 2020 at 7:37 AM Pali Roh=C3=A1r <pali@kernel.org> wrote= : > > > > > > On Friday 14 August 2020 12:56:05 Luiz Augusto von Dentz wrote: > > > > Hi Joseph, > > > > > > > > On Thu, Aug 13, 2020 at 1:42 AM Joseph Hwang <josephsih@chromium.or= g> wrote: > > > > > > > > > > It is desirable to expose the wideband speech packet length via > > > > > a socket option to the user space so that the user space can set > > > > > the value correctly in configuring the sco connection. > > > > > > > > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > > > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > > > > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > > > > > --- > > > > > > > > > > include/net/bluetooth/bluetooth.h | 2 ++ > > > > > net/bluetooth/sco.c | 8 ++++++++ > > > > > 2 files changed, 10 insertions(+) > > > > > > > > > > diff --git a/include/net/bluetooth/bluetooth.h b/include/net/blue= tooth/bluetooth.h > > > > > index 9125effbf4483d..922cc03143def4 100644 > > > > > --- a/include/net/bluetooth/bluetooth.h > > > > > +++ b/include/net/bluetooth/bluetooth.h > > > > > @@ -153,6 +153,8 @@ struct bt_voice { > > > > > > > > > > #define BT_SCM_PKT_STATUS 0x03 > > > > > > > > > > +#define BT_SCO_PKT_LEN 17 > > > > > + > > > > > __printf(1, 2) > > > > > void bt_info(const char *fmt, ...); > > > > > __printf(1, 2) > > > > > diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c > > > > > index dcf7f96ff417e6..97e4e7c7b8cf62 100644 > > > > > --- a/net/bluetooth/sco.c > > > > > +++ b/net/bluetooth/sco.c > > > > > @@ -67,6 +67,7 @@ struct sco_pinfo { > > > > > __u32 flags; > > > > > __u16 setting; > > > > > __u8 cmsg_mask; > > > > > + __u32 pkt_len; > > > > > struct sco_conn *conn; > > > > > }; > > > > > > > > > > @@ -267,6 +268,8 @@ static int sco_connect(struct sock *sk) > > > > > sco_sock_set_timer(sk, sk->sk_sndtimeo); > > > > > } > > > > > > > > > > + sco_pi(sk)->pkt_len =3D hdev->sco_pkt_len; > > > > > + > > > > > done: > > > > > hci_dev_unlock(hdev); > > > > > hci_dev_put(hdev); > > > > > @@ -1001,6 +1004,11 @@ static int sco_sock_getsockopt(struct sock= et *sock, int level, int optname, > > > > > err =3D -EFAULT; > > > > > break; > > > > > > > > > > + case BT_SCO_PKT_LEN: > > > > > + if (put_user(sco_pi(sk)->pkt_len, (u32 __user *)o= ptval)) > > > > > + err =3D -EFAULT; > > > > > + break; > > > > > > > > Couldn't we expose this via BT_SNDMTU/BT_RCVMTU? > > > > > > Hello! > > > > > > There is already SCO_OPTIONS sock option, uses struct sco_options and > > > contains 'mtu' member. > > > > > > I think that instead of adding new sock option, existing SCO_OPTIONS > > > option should be used. > > > > We are moving away from type specific options to so options like > > BT_SNDMTU/BT_RCVMTU should be supported in all socket types. > > Yes, this make sense. > > But I guess that SCO_OPTIONS should be provided for backward > compatibility as it is already used by lot of userspace applications. > > So for me it looks like that BT_SNDMTU/BT_RCVMTU should return same > value as SCO_OPTIONS. Yep, luckily we can do this here because SCO MTU is symmetric. > > > > > > > > default: > > > > > err =3D -ENOPROTOOPT; > > > > > break; > > > > > -- > > > > > 2.28.0.236.gb10cc79966-goog > > > > > > > > > > > > > > > > > -- > > > > Luiz Augusto von Dentz > > > > > > > > -- > > Luiz Augusto von Dentz --=20 Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yMQEHmdxPV+ncwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 20:37:27 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 0KM4HGdxPV8fMQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 20:37:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2D98F42121; Wed, 19 Aug 2020 20:37:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726585AbgHSShV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 14:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725997AbgHSShU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 14:37:20 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE9B2C061757 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 11:37:19 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id q9so19846144oth.5 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 11:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0HeIGZ0DyzgCbL5apsf54ipOledAWW5U3rl6Iv7K7EU=; b=BB8nlnElYvnEtLlxUYqV8iuHSgs85Gg/45Dp9ymnCnHyCPW4ivRcJH3mZxdNCKhAeM 4MDNg/t4xEB1XobP3suSRBqHaERKtqck84yTFrrTrxGUUu5DD2CHqqAcqx7FEHyQbQpo ozm3l4V7coBSnhyNj9PiRXY6gbzbGFXmx9yV9/u8KnWELyYJw2KBQRa8Pd6X8Jzgu5N6 S35XjLkuvMKnRe7n5goMWpAI016ZQZkKhF/T0pDANZR9GI1zwGM17qpGEqyE2RUsdKgw OH0A5nM4nMIhcGbIXwQQSTAjpzUcSLvO5LwH1b3An2o6Nu6yL9/LX10A9fAfAkDBmEjc iNPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0HeIGZ0DyzgCbL5apsf54ipOledAWW5U3rl6Iv7K7EU=; b=VPHCXyLsCCLBvHCsZrNSwnGSJtaF1WdH0Wis+YDRStxYMJQZE9o9cb+mVWVAEcxsoh +5QczhAaCVUO+aBy5vAmRTZqDE9EUbYH3vO0M2iJNCEzGpsctaJJeKL9U0uOajwTH/o7 E2SOgbC+mWmZQqEwJ/QSusCCLOebRkjHH/WT40b6W68BYSC1FE06daNxoHTfUJDtqjvL aC9FWmNJMtuTD/Z1CCJ7dvnSePYCeI/69r3SZYtOmmZ08z4Za7EWbql/nr+J2+9h72Nc xfbfi1xjXBkTWhUBSqRB3jCCHQaBEQfg44XodNveUs0AYoIELiVvQoZAUzSKZKUBMXmt 5e2A== X-Gm-Message-State: AOAM531NKeQ1PhRRwWgrjTixb3af41kdUSNHxdHw1cDs0jFESJ3I2+jj QJwFTz6v2ZupCdx01FfGKG7p68F/jS1N/HLkuUrU4ZQtmIY= X-Google-Smtp-Source: ABdhPJxC8UBCMYG47EEADSQckWecSzJaykg83rAruk57WKUCtMUiwmXxN8tQNglInTal0V8YVvZKIwG7D9JKz6GGqEs= X-Received: by 2002:a9d:429:: with SMTP id 38mr18318780otc.88.1597862239111; Wed, 19 Aug 2020 11:37:19 -0700 (PDT) MIME-Version: 1.0 References: <20200819150931.3005-1-mark.marshall@omicronenergy.com> <2303f692-bb7c-4851-86fa-befde45b4b32@EXC04-ATKLA.omicron.at> In-Reply-To: <2303f692-bb7c-4851-86fa-befde45b4b32@EXC04-ATKLA.omicron.at> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 19 Aug 2020 11:37:08 -0700 Message-ID: <CABBYNZ+OK4EY9KGHn7oasz4GRfBDJdWNcpOhr1GNGc3D+QtZ-g@mail.gmail.com> Subject: Re: [PATCH BlueZ 2/2] src/profile.c: Add a GetProfileInfo method To: Mark Marshall <mark.marshall@omicronenergy.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2D98F42121 X-Rspamd-UID: 530b65 Hi Mark, On Wed, Aug 19, 2020 at 8:13 AM Mark Marshall <mark.marshall@omicronenergy.com> wrote: > > Add a GetProfileInfo method to org.bluez.ProfileManager1 > --- > doc/profile-api.txt | 13 +++++++ > src/profile.c | 93 +++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 106 insertions(+) > > diff --git a/doc/profile-api.txt b/doc/profile-api.txt > index 8c7d0a06d..d13703ab4 100644 > --- a/doc/profile-api.txt > +++ b/doc/profile-api.txt > @@ -133,6 +133,19 @@ Object path /org/bluez > > Possible errors: org.bluez.Error.DoesNotExist > > + options GetProfileInfo(object profile, object adapter) > + > + This returns a dictionary of options for the > + profile. Values returned are: UUID, Name, > + Path, Service, Mode and AddressType. The > + adapter parameter is optional - if it is > + non-empty, then two additional values might be > + returned, if the profile is active on the > + specified adapter: PSM and Channel. > + > + Possible errors: org.bluez.Error.InvalidArguments > + org.bluez.Error.DoesNotExist > + If this is really required I would be willing to merge something like this: https://github.com/Vudentz/BlueZ/commit/9e196f8830511a4102e990d82d06c2e0487b3ad9 It exposes service objects so you can control exactly what gets connect, though now given a second look at this seem to return details that the client can query directly on the socket itself like the Channel, PSM, Mode, etc, also not sure what is the point on retrieving things like UUID, Name, Path if the application is already in control of these when registering. > Profile hierarchy > ================= > diff --git a/src/profile.c b/src/profile.c > index 10850f305..e287a66d7 100644 > --- a/src/profile.c > +++ b/src/profile.c > @@ -2509,6 +2509,96 @@ static DBusMessage *unregister_profile(DBusConnection *conn, > return dbus_message_new_method_return(msg); > } > > +static DBusMessage *get_profile_info(DBusConnection *conn, > + DBusMessage *msg, void *user_data) > +{ > + DBusMessage *reply; > + DBusMessageIter iter, dict; > + const char *path, *adapter, *sender; > + struct ext_profile *ext; > + uint16_t u16; > + GSList *l, *next; > + > + sender = dbus_message_get_sender(msg); > + > + DBG("sender %s", sender); > + > + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, > + DBUS_TYPE_OBJECT_PATH, &adapter, > + DBUS_TYPE_INVALID)) { > + return btd_error_invalid_args(msg); > + } > + > + if (adapter && !*adapter) > + adapter = NULL; > + > + ext = find_ext_profile(sender, path); > + if (!ext) > + return btd_error_does_not_exist(msg); > + > + reply = dbus_message_new_method_return(msg); > + > + dbus_message_iter_init_append(reply, &iter); > + > + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, > + "{sv}", &dict); > + > + g_dbus_dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, > + &ext->uuid); > + if (ext->name) { > + g_dbus_dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, > + &ext->name); > + } > + if (ext->path) { > + g_dbus_dict_append_entry(&dict, "Path", DBUS_TYPE_STRING, > + &ext->path); > + } > + if (ext->service) { > + g_dbus_dict_append_entry(&dict, "Service", DBUS_TYPE_STRING, > + &ext->service); > + } > + > + u16 = ext->mode; > + g_dbus_dict_append_entry(&dict, "Mode", DBUS_TYPE_UINT16, > + &u16); > + > + u16 = ext->addr_type; > + g_dbus_dict_append_entry(&dict, "AddressType", DBUS_TYPE_UINT16, > + &u16); > + > + if (adapter) { > + for (l = ext->servers; l != NULL; l = next) { > + struct ext_io *server = l->data; > + const char *ctype; > + > + DBG("server:%p %d %d psm:%d chan:%d", > + server, server->resolving, server->connected, > + server->psm, server->chan); > + > + next = g_slist_next(l); > + > + if (strcmp(adapter, adapter_get_path(server->adapter))) > + continue; > + > + if (server->proto == BTPROTO_L2CAP) { > + ctype = "PSM"; > + u16 = server->psm; > + } else if (server->proto == BTPROTO_RFCOMM) { > + ctype = "Channel"; > + u16 = server->chan; > + } else { > + continue; > + } > + g_dbus_dict_append_entry( > + &dict, ctype, DBUS_TYPE_UINT16, &u16); > + } > + } > + > + dbus_message_iter_close_container(&iter, &dict); > + > + return reply; > +} > + > static const GDBusMethodTable methods[] = { > { GDBUS_METHOD("RegisterProfile", > GDBUS_ARGS({ "profile", "o"}, { "UUID", "s" }, > @@ -2516,6 +2606,9 @@ static const GDBusMethodTable methods[] = { > NULL, register_profile) }, > { GDBUS_METHOD("UnregisterProfile", GDBUS_ARGS({ "profile", "o" }), > NULL, unregister_profile) }, > + { GDBUS_METHOD("GetProfileInfo", > + GDBUS_ARGS({ "profile", "o" }, { "adapter", "o" }), > + GDBUS_ARGS({ "options", "a{sv}" }), get_profile_info) }, > { } > }; > > -- > 2.17.1 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KCYmBDVzPV8ymgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 20:45:09 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oCouAjVzPV8ewAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 20:45:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6148CA141E; Wed, 19 Aug 2020 20:45:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726603AbgHSSpC convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 14:45:02 -0400 Received: from s01.spamexperts.axc.nl ([185.182.56.9]:60145 "EHLO s01.spamexperts.axc.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbgHSSpB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 14:45:01 -0400 X-Greylist: delayed 6292 seconds by postgrey-1.27 at vger.kernel.org; Wed, 19 Aug 2020 14:44:59 EDT Received: from vserver85.axc.nl ([185.182.56.185]) by s01.spamexperts.axc.nl with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from <dave@daveborghuis.nl>) id 1k8RRT-0006rp-HE for linux-bluetooth@vger.kernel.org; Wed, 19 Aug 2020 19:00:06 +0200 Received: from mail.axc.nl ([185.182.56.42]) by vserver85.axc.nl with esmtp (Exim 4.94) (envelope-from <dave@daveborghuis.nl>) id 1k8RRS-00AA0T-1E for linux-bluetooth@vger.kernel.org; Wed, 19 Aug 2020 19:00:02 +0200 To: linux-bluetooth@vger.kernel.org From: Dave Borghuis <dave@daveborghuis.nl> Autocrypt: addr=dave@daveborghuis.nl; prefer-encrypt=mutual; keydata= mQINBFI9hacBEADBe9EcShlbkN2x/o3x/5S1u+m6kCJC+kNmzMHecJWzbwxsGLfUzApqImPF WGjy7yGVDp9Rl80Sz2gSijZjFkN17PSILsiHM3LvwfyBS/IMLPG0E+dB9ejrATuXrEdeXl8q QG6ZBE2ZaBgEMLhu7lAIS/E50jSij1yzSSlzcjd1m0d3kGaseiHWO0PM8sggwclI9XYOGxJK vmWAz9ayhMZNhdvkfAxsdh3hQYC7RkaBH9kjh9l5qt5t1xRcABkX3pa9ct4rzwlEswOCjURe rhaj6IHwroTNaRW1djxml4vTgyM8b7NmNmfRvwMaImUgQweb9k0wRfPEgSWthNml7aNPCRqj rF3sLiBl5xxJsm8Y9ROdiyeTyl+3iAdtQ91hAWfgK2ZFQvHNPPlelfRupXgupY6h9UJzdEkn A1F8Yx3xyizkKLbsbDt/uB9XYiIH594WbCHt6S0k8bWuTdqlYiLhKe32ij53tZy+J92tqMti HWhM3qv9CR6qLop9rIk3G6ZUDahb1NrYPT8ahh+gcjif+LFhFooLZiNxqAzguuAgrExU/NIi WuG+2So2pO04y0DcMQ1+BT+fs6tqQXdvVU23QwDY+cS+WNqh4nPg7ZYm63vPb2rlirJ/Mhq3 Xjk74WqTmKzUnWLlu5OQDp91t8Lf86hNCb/FV66dnSGyoG8xEwARAQABtCREYXZlIEJvcmdo dWlzIDxkYXZlQGRhdmVib3JnaHVpcy5ubD6JAjsEEwECACUCGy8GCwkIBwMCBhUIAgkKCwQW AgMBAh4BAheABQJSvzddAhkBAAoJEIa6Ru419rKq+9kQAIHcW/vakREY0/OLx4tTMO2WPwX+ e1pare/zdJwejcS6LksxFZ/8dwj0kk/s1ME3Zztg2vDkpQjQISFrtuNmOYekY6geRUjKgr3U BdPq+sYoge4kBIlAQnDMaVY48QtnLXZQBsXBhfRIQNj+TWuUVbHYwyLGGw9pRaJHsDJBc1cd qvCUyCOyXb0tWZCfv83jMMv/9gEJngkPC0JuIWPl0rfJ9QPTlArJw9vbMTYaUmm9vskjP1I/ qZSR7kpLrTtCcPtvWDtm2v+akrZnV9aKUY4XFkutZErJmSkk2Hp9Sz/hhAzzgfYlI3tg1Ljt EmMI5XDViPAoqLljtUKr0aIbqW2wOb8zgpx2MrO0JKqpNgEQfvGAVyXsH0PTOcshS5ri/8oC b84eHMwPqKuK9YD0990UQKNw7hN2yyqqYb22wty0PWYglfpJKUQdYMbQi3KCxGzn7Nu/E/Pk 1QTbCOVokei8wTZLGmg6L5RFF6xHLZ56mtmXSY+Oy5r8PGICdVE/nnJXN3Mg0jGliTovDz97 Wng4/Zq50chtx9fA3P00IoYuoDwvAJza3ggntTlXGN9pwGVZET+k6LkJaJ0bpHj/t+8LCcpF HJa2/wsz8cYAGlNvKpl5jjwtNLndJApG35GFB9CT2EFjNFEtOKlDCgiv9lgZOB1Gl6NfGOAI UeuO/I47uQINBFI9hacBEAD1U4TDKLPSjYGd2Ot/FkU/24VwDQ2zTCUtR4hzUTjj4zjwCL5I GCEek0LcQToDONF2t0h6pm7HKb9NOicXYsiekUY3mYkH5C/VSCxoqdYi4lhexOZH34RO+5Ln jqtF0TpdFXTFpVQ3O3eHhAYmGMt7BjEaesOAzIR9D2+bhvgIyh/APebCS4gVfQpthCjTYDvd ol8igOnMg9O/gY932gSSe7BL+BVJCMIokUu4dOe+k1EhIrC4h7gZYFpKaanE8rmg1hLni0cy kSh1joJVv/czkklzmyMGeUZrkTkxu/d3J/IgafrndW/kQ/XSJ4N5ghEegjjWlN821i+1NXRa NGxxNxo6CA+Rl12+78uGQcwL68wmyFlrrXmgr9DW70XDIEFkiAfUhkQPAq5VT6HDDjh6djco e3FbbYncJn41e4y4E/BLIC+rGimOXlbHJAIh1QFdSyoNiZD0IUr1BK+nIUTCRPAkF8GKrGN/ UthF345iFhDsKV4Oe3y5cZcOloyWbTzVnHfnD+iH65a75G34zdiUVV2g8RihiYvdC78EgkKM UIzCsvFPJHy6SGETX1d5o4lf7D71DlSr2OsaqGAnPtIMbjQPaXBhT5zenEGeoLOMs2lF/SAr fz7+5gcYiIkyR46AFlmb/COkDS4AaVZzvDBmOn0R5/hwMdD+Fw+TWoP5GQARAQABiQQ+BBgB AgAJBQJSPYWnAhsuAikJEIa6Ru419rKqwV0gBBkBAgAGBQJSPYWnAAoJEMK3KLEisodrljYP /23fop22dU9WxUksPxTQYIlsOIWSjw5RLqontCN4JeZYkDVPiDVe+PB3ZMNOhgMyY9XSy1Vm QyoM27Td+XisJ5nKcYlCZxDkxi+xyE+rz2SfpW76Qw54di3EeAEx/Qb/Al94BJ1poR6HU+fN saMZtpvY1VM/9m3N71JPLf5E50jABPARuvsRGA5eDAhxrbm+yIM5msqZgEYyxY0fLrt4qV1S wDUAMDhbOlX3U7CrnlTD4VaHZYwkv2eSZ/JcINgMaEbhKMZeYYM91/7PyS+QXHfjNngxKyTN 6yFXDOjsTycRRqWO7nnnHYNrzZZ3xSRXsUiHyWIORl6mYzKIcptb3MvRqw1h0+wz86ujCr8p sP0MRAq/iIEGdciPTqUHQKJgOO5FLCcV4oxlP/wESFXFbXlgzv40SvhZPDjPeLauLssKGVbk i/5CduYuKCb6Wwc2htKJXPMNE/H4W+Bdwz1hXiwVzyUlmv6PV78ArSLvKRB5h5Ogo1vsnar2 6JcBcxwJ//7fd2N3hMUf/tfotCPzjs6nsJINI8LZxJHLNWOs+zztwD1iEN3BiSUSsyHvluIj agg9blWzvpcRvj9KW4X7gwZwyAzfkGMjXIbl9p+97s+Gs9wNI/+Bxc5mrWIc3hY/O53sPlaB tWW6fXK/uXj59gGq+ZE8+dYARKVD4YI+4o0KlIsP/3MLFL4Axn3OEsCh21p1++P5ejpGqHPh x+ioPXqqxahWJVPKmLjhgmHmuh5cQFYePvC8Ou5AUL+4ooU3SVwOKaeWfyU0Gy6/00ZOVWD6 IEiQnKntzXdAmR8uFH+2s5UlYIM3S374Ly3vitM/arrkeRlzW9XDnslfkvjdsi++OgZGZUJY sp6QQfGWTlwzZ4DShSQmJdX7mGE3fe2GZ6VhVCHPhhqAEHpxbw9kAvN/G2iRYmRDD3ux1IHZ E1u8ScC5wYh0RIoDp+Nq3sux2XmwHfvLvK5rhIg3jszHTQRRzieOqmvriAESxuq92y+oFhfb jEIPtCvBOD4txGYPLad1bQVEH/aMIhYWdpJQ701TqMRHEtbO0c9o64S/Y2j7xomBbIyZr0/R HGkWSaS1UL2q0v3xeo46WROGSXcX8p8NXEkgVqC5hV3v6gIj9kfjxg7KiUCZAeH3qqaBTGnc aLeZzcCUG39JtZPoWGTbXHBuR6vay6FZienaalSMBOQXfqJJvePMlFpqKoeRCPCJ4ZnSZXaJ awgMeKHMUnsHtCR5DNQmH/p+/20/2a7k2YAim6P25sMay8nVNcwwvAu5ktONmRB3JAeugnTr lb/vdLbu/mv1PTwgvzxK3x45dv0uAtlP++y4TKwxfRXwopt5/rFL2/x6OzAMCGU1Pj1+emQW 0G/D Subject: Cant see Android Covid Exposure notification beacon (no problem with iPhone beacons) Message-ID: <b39b3395-ad80-bf76-caea-490666cea671@daveborghuis.nl> Date: Wed, 19 Aug 2020 19:00:01 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US PrimaryMX: Accepted email from trusted host. Hint: This skips spam scanning so make sure other host is not vulnerable X-Relay-Host: 185.182.56.42 SpamTally: Final spam score: 0 X-AuthUser: X-Originating-IP: 185.182.56.185 X-SpamExperts-Domain: vserver85.axc.nl X-SpamExperts-Username: 185.182.56.185 Authentication-Results: spamexperts.axc.nl; auth=pass smtp.auth=185.182.56.185@vserver85.axc.nl X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.11) X-Recommended-Action: accept X-Filter-ID: Mvzo4OR0dZXEDF/gcnlw0Uc1Z+hCSaILZIw3vLzlsGSpSDasLI4SayDByyq9LIhVYtIe3Q6Ueykn Pvf+cPo2l0TNWdUk1Ol2OGx3IfrIJKywOmJyM1qr8uRnWBrbSAGDkyaV/HSuvhtrCrYZnJyJprfA vZjgXTjXZ7MYLJNQ9qfEV6mG7REFdc/y+N+WUcRUrHrxZWvesWDvIZD81C02avq2Gb7u1BCYlN7N u1YChzu5cEt3QSU508Q6A7wRhsaYdmq9xo0GjtWFBExS79GWRamHZ7x6u9Brd8pYitTyb+Iigr59 rlmv/GHWoLSyMb15AwCaU+JKXuJDa3LaePMOFRkhzVJFWn887ct0NFXnFWKxnGmiI3p9NEdyvIai 1RA3JU4jwn/j8E2/0SgHcP07MMV+dz7akF52ekPgsD93vyq/ACCTOiwBg1W4fRYdQHYhH+5TduRS 72K5pleHE5QR33QmZupE66h/n5scs0KBvjbXs2KsRjKrCowEavDwQuKow/uHSYVMpt/Uo2J0FRFF QZMcLrnY3nGbRXqkywVTWWifU642KNtk4n/u8nyV2xsjehIqUczFWeS6sE8e1b5/Uj/i4hYVfUxI FxiN15g3w5z9HjheqKGe/Xw9Eqs27yPa56U4tSVR+PkAWM7EDktWGqU9EyOgYBbfvk3hETr+b0IH mFDqewO9xyOqCYO8P1aHuylOWoVldtjaf1T8hyYAn+byoVLxqGq1sXT6ejmEoSQMhGfTGKeYohdq JlHBQlshXt8dlQXuSXw6QX3vO2l6zs7fXl7o5hhgRuEQkQsBWeNYzdyzoRUEpYNmzltPrdLiRSrv GBrIgRh1MRcQAKU4P1FfEoXm0/FPF8PR0w363lk0mtdFubkFnXxurL3w551wUWKOQLOVGdmQ+BhN hOPwXKBe7/mqdKAYqg1HpF7XcTyzMeoUaX8fmEyqwIC0fLJSuG6xVdphrUpYQO+Raqyt3AWevvg3 5E1ZQVrEeUBpJbnjGc6oaCkj/CHHhRGXKIbimLNXS3W8YK6tYVOVBH2QeU+HBvHh6GQL5BmhodkO jeg= X-Report-Abuse-To: spam@s01.spamexperts.axc.nl Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.14 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6148CA141E X-Rspamd-UID: 7a6e32 Hi all, I don't know if this is the right place to ask, if not feel free to forward the mail or point me in the right direction. If I look with btmon i see no Covid exposure notification beacons from android phones, i see these beacons from a iphone. When I check with a ESP32 with a monitor I see both beacons (from iPhone and Android). I using Raspberry Pi 4 with  with all software updated. I updated bluez to last release (from 5.50 -> 5.54) with same results. Used software versions : Installed image : Raspberry Pi OS (32-bit) with desktop Release date : 2020-05-27 Bleuz version 5.50 and last release 5.54 (build from source) If needed I can recompile from source a new version. I tried to find source of a more up-to-date developer version then 5.54 but could not find this. So is there something I can do to enable to see Android Covid exposure notification ? Do I something wrong or is there a bug in the bluez stack? Background : I am making a 'CoronaCounter' app in python, I want to count the Covid exposure notification that I see. In python i use beacontools. I noticed I don't see any android beacons. More about this projcect you can find on https://github.com/zeno4ever/CoronaTeller Regards, Dave Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2L78KohzPV+ncwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 20:46:32 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iCJAKYhzPV87kwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 20:46:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 93290A15F1; Wed, 19 Aug 2020 20:46:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726603AbgHSSqZ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 14:46:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbgHSSqX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 14:46:23 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF20BC061757 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 11:46:23 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id e6so21923523oii.4 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 11:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Rza0knQ+4qFyNiTQ/EJ8ffuPpXoUjwzb3Do+frC985s=; b=d4RlF/R6xsf6XqJtDBQ9FNf0F2VFYYmAuFKA9PNNGb1Wq6P2TXRX+QRKetsdbNGuiF xxOjREYYMAPQXVzfKWE0ZyNHhBh3nRO3mGlf9cb8gBefXXtaLOXB9Wy5O6ug6BtEJwpp HfovPOJrWExJs2q1d6ci+sa2cbZTm3Y4n8nDPQWxdo61sLxwbBotoxNhrKJY1S+mD7Qo XSCEuJCjbO2mOIIB8x3GbUJs8icBLTJvrr3yC9HyJABduiJ2x7TOzh7SlokDPkYyz3aw YX5x92/yEPpjSdbL8qMKkI99fIU5XB7r/bI7qfomM34cgbucF0+4JRb3k5Ia+RGVU1lv xtRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Rza0knQ+4qFyNiTQ/EJ8ffuPpXoUjwzb3Do+frC985s=; b=MQ3FySScGdxns+6CIOHabJnODLU/80CwYwtroIIcwOqve55YeuTQhzUDws4EqIo6rR RVQvfCA2ewZ6PYVK7n8ILpLfZDrh80kbHIy++lqJqGX5xI3BhJopAD2qWHDyN4SScNmF OLi3O9Aoqz+lTlYLNJQ68WxU4R7vx1M1RkPgDcCrEKcRJYj5ocm+fE0udbOXYd2buXmO haBdoGm/M4aY7ofGrxi6h1MOwIMzqzK/ccsMumTz24r1ZplhRWit7O3/5IzWIBBDKmve HwVOap32NMujkIThLap1XDNJ0HpNgoeQcgBJGcJh3/IUXCneQ85lRx9CFOuhcDzzokMv fNGQ== X-Gm-Message-State: AOAM5333ozTItVtP+FE32IFA8e3DShZsHMXtwH+z23M1wR3Jo0rkrQ1g 0KB7Dzof+vR2i5PMzOgQdkkeQM1jkhNKglTyg2T4GXrRj4o= X-Google-Smtp-Source: ABdhPJxXDR9bGSMsrW19/YSJoFTto5iF5ZH1aM9nZhnkyP1SowI8liR3Odpk6v9N/BLX14zr2EenLM+0NtKC1fEySIo= X-Received: by 2002:aca:f504:: with SMTP id t4mr4229734oih.137.1597862781982; Wed, 19 Aug 2020 11:46:21 -0700 (PDT) MIME-Version: 1.0 References: <20200819150931.3005-1-mark.marshall@omicronenergy.com> <98fed7ef-1975-48ca-9ea3-1482d938a806@EXC04-ATKLA.omicron.at> In-Reply-To: <98fed7ef-1975-48ca-9ea3-1482d938a806@EXC04-ATKLA.omicron.at> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 19 Aug 2020 11:46:11 -0700 Message-ID: <CABBYNZLyv_B4CtnqtHXdKnyEKx0Xo8Ta=Y--sOEu+yokaV_U=A@mail.gmail.com> Subject: Re: [PATCH BlueZ 1/2] src/profile.c: Allow the "Address Type" to be set To: Mark Marshall <mark.marshall@omicronenergy.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.16 / 15.00 / 200.00 X-Rspamd-Queue-Id: 93290A15F1 X-Rspamd-UID: dd10aa Hi Mark, On Wed, Aug 19, 2020 at 8:13 AM Mark Marshall <mark.marshall@omicronenergy.com> wrote: > > This allows us to have profiles that use LE L2CAP connections. > --- > doc/profile-api.txt | 10 ++++++++++ > src/profile.c | 18 +++++++++++++++++- > 2 files changed, 27 insertions(+), 1 deletion(-) > > diff --git a/doc/profile-api.txt b/doc/profile-api.txt > index 183c6c11a..8c7d0a06d 100644 > --- a/doc/profile-api.txt > +++ b/doc/profile-api.txt > @@ -112,6 +112,16 @@ Object path /org/bluez > > Profile features (for SDP record) > > + uint16 AddressType > + > + Allows the Address Type to be > + selected, can be either > + BDADDR_BREDR, BDADDR_LE_PUBLIC > + or BDADDR_LE_RANDOM. If an LE > + address is selected and the > + device is not found, the other > + sort of LE address is tried. This sounds like a good idea but aren't we missing the GATT service that actually exposes the PSM for the client to connect to? We should probably make RegisterApplication accept Profile1 interfaces in such cases so one can register both at the same time. Also note that this should be consistent with Device.AddressType which uses a string to not a uint16. > + > Possible errors: org.bluez.Error.InvalidArguments > org.bluez.Error.AlreadyExists > > diff --git a/src/profile.c b/src/profile.c > index 6961a107b..10850f305 100644 > --- a/src/profile.c > +++ b/src/profile.c > @@ -677,6 +677,7 @@ struct ext_profile { > guint id; > > BtIOMode mode; > + uint8_t addr_type; > BtIOSecLevel sec_level; > bool authorize; > > @@ -1173,9 +1174,16 @@ static struct ext_io *create_conn(struct ext_io *server, GIOChannel *io, > struct btd_service *service; > struct ext_io *conn; > GIOCondition cond; > + uint8_t addr_type; > char addr[18]; > > - device = btd_adapter_find_device(server->adapter, dst, BDADDR_BREDR); > + addr_type = server->ext->addr_type; > + device = btd_adapter_find_device(server->adapter, dst, addr_type); > + if (device == NULL && addr_type != BDADDR_BREDR) { > + addr_type ^= (BDADDR_LE_PUBLIC | BDADDR_LE_RANDOM); > + device = btd_adapter_find_device(server->adapter, dst, > + addr_type); > + } > if (device == NULL) { > ba2str(dst, addr); > error("%s device %s not found", server->ext->name, addr); > @@ -1350,6 +1358,7 @@ static uint32_t ext_start_servers(struct ext_profile *ext, > io = bt_io_listen(connect, confirm, l2cap, NULL, &err, > BT_IO_OPT_SOURCE_BDADDR, > btd_adapter_get_address(adapter), > + BT_IO_OPT_SOURCE_TYPE, ext->addr_type, > BT_IO_OPT_MODE, ext->mode, > BT_IO_OPT_PSM, psm, > BT_IO_OPT_SEC_LEVEL, ext->sec_level, > @@ -1567,6 +1576,8 @@ static int connect_io(struct ext_io *conn, const bdaddr_t *src, > io = bt_io_connect(ext_connect, conn, NULL, &gerr, > BT_IO_OPT_SOURCE_BDADDR, src, > BT_IO_OPT_DEST_BDADDR, dst, > + BT_IO_OPT_SOURCE_TYPE, ext->addr_type, > + BT_IO_OPT_DEST_TYPE, ext->addr_type, > BT_IO_OPT_SEC_LEVEL, ext->sec_level, > BT_IO_OPT_PSM, conn->psm, > BT_IO_OPT_INVALID); > @@ -2285,6 +2296,11 @@ static int parse_ext_opt(struct ext_profile *ext, const char *key, > dbus_message_iter_get_basic(value, &str); > free(ext->service); > ext->service = bt_name2string(str); > + } else if (strcasecmp(key, "AddressType") == 0) { > + if (type != DBUS_TYPE_UINT16) > + return -EINVAL; > + dbus_message_iter_get_basic(value, &u16); > + ext->addr_type = u16; > } > > return 0; > -- > 2.17.1 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qKquHIOCPV/Y1QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 21:50:27 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id IBf5GoOCPV9xZAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 21:50:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2A9D9A1484; Wed, 19 Aug 2020 21:50:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726585AbgHSTuV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 15:50:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725275AbgHSTuV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 15:50:21 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DD36C061757 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 12:50:21 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id z22so22113009oid.1 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 12:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RwSEAG7n6KPttdgMR92zRf9Po02yJGr0+n784gk5TSk=; b=MpfuU1gI5FQEjmnLuKHWGcDgfblxOs+TlshI3Vbyu5Jp8SIVazIVHTQxQG1UkNXQ1Z 3gEQRv6HMtcfLjuLg2bsQ3rM5E23pZxmfyydHP8qoNbfGd3XIAqeHBYErjEDKYzsjktC GYkcZdZCqEl5zKfauk1jj9uS6nqQsgnMk/+QDAkeOpup+HBClcJ5niG/ayvTcpruzHNW wU+6nxfFaMOh6sNvAO0OLMp3oSPhQcj3mg7qlWzc5mUNbV6OgYxRpJd6dNU4JK53Tf4m jktcgHvVxeWx4DjKCnej2rJsk67+RYOSBOKN8awjHynTJGVLBpiC5wA+VWuj/SPJm3VO yfgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RwSEAG7n6KPttdgMR92zRf9Po02yJGr0+n784gk5TSk=; b=uN+rkYli9mrfX2T4ic/C3A5WKV35f7SKEPj82Wa8veJDMAQALoOr8HmaOxWCmFSS4N tndtF81r+lfcpgQIvC5CjcPbF9ocN5AMAdoiPLcqlNTOeUe+Rpphl3cFYp6VcEDcleCY Iud2YnhwtRZokXMkyWPmkemZkGClpR/t+536+QmyQnp/9do2u9ndGvUNWQWidpQrP+wA o1vK9rcrU2sbYTsTE/ei9AbF3qfT5X+VnMqbuSc46g0nHqazW+saJM1el8XXezi9U/wa GwX6EcSDkYkorYi8uUOEKXR95aTRoGk0NYrB/QoRdv0qLsfBzMNlPpZ7Y5ytXXsJdTqn i0Qg== X-Gm-Message-State: AOAM532myLkxEEY4sEeLK2BviW1sYKKiIwiIezlIH8DMi2Zug4/LBEsM zZT2OpJtvsyNfju+TeDxvkBDKAOU6isfU9BIV2mGKz8q X-Google-Smtp-Source: ABdhPJw0U6sr2cfBbNUTlKd+ilMq1hhnNm8IRlsGULujRbNLxVCzR1L9RzRWwMbJVzzovXn7cV5h1uyeh9dbUcNrgn8= X-Received: by 2002:aca:f504:: with SMTP id t4mr4418735oih.137.1597866619391; Wed, 19 Aug 2020 12:50:19 -0700 (PDT) MIME-Version: 1.0 References: <b39b3395-ad80-bf76-caea-490666cea671@daveborghuis.nl> In-Reply-To: <b39b3395-ad80-bf76-caea-490666cea671@daveborghuis.nl> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 19 Aug 2020 12:50:08 -0700 Message-ID: <CABBYNZJysyOYZPWVd1Cpq7C055G2Pwdu+x_9WaFfZUzDb-4_YQ@mail.gmail.com> Subject: Re: Cant see Android Covid Exposure notification beacon (no problem with iPhone beacons) To: Dave Borghuis <dave@daveborghuis.nl> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2A9D9A1484 X-Rspamd-UID: 84b5e2 Hi Dave, On Wed, Aug 19, 2020 at 11:47 AM Dave Borghuis <dave@daveborghuis.nl> wrote: > > Hi all, > > I don't know if this is the right place to ask, if not feel free to > forward the mail or point me in the right direction. > > If I look with btmon i see no Covid exposure notification beacons from > android phones, i see these beacons from a iphone. When I check with a > ESP32 with a monitor I see both beacons (from iPhone and Android). > > I using Raspberry Pi 4 with with all software updated. I updated bluez > to last release (from 5.50 -> 5.54) with same results. > > Used software versions : > > Installed image : Raspberry Pi OS (32-bit) with desktop Release date : > 2020-05-27 > > Bleuz version 5.50 and last release 5.54 (build from source) > > If needed I can recompile from source a new version. I tried to find > source of a more up-to-date developer version then 5.54 but could not > find this. > > So is there something I can do to enable to see Android Covid exposure > notification ? Do I something wrong or is there a bug in the bluez stack? You probably will need to set some filtering since the advertisement may not be 'visible', you can try with: bluetoothctl> scan.transport le bluetoothctl> scan on If that causes way too many notifications try setting some other filters like UUID/pattern if there is such information about it. > Background : I am making a 'CoronaCounter' app in python, I want to > count the Covid exposure notification that I see. In python i use > beacontools. I noticed I don't see any android beacons. More about this > projcect you can find on https://github.com/zeno4ever/CoronaTeller Is there any specification available for such beacons? > Regards, > > Dave > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SLdvMUiRPV9QNQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 22:53:28 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gNWsL0iRPV8fMQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 22:53:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 86B3E420E0; Wed, 19 Aug 2020 22:53:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbgHSUxV convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 16:53:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:52968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726617AbgHSUxS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 16:53:18 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 208965] New: not working bluetooth mouse low energy rtl8822ce Date: Wed, 19 Aug 2020 20:53:14 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: high X-Bugzilla-Who: fakecop@yandex.ru X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version cf_kernel_version rep_platform op_sys cf_tree bug_status bug_severity priority component assigned_to reporter cf_regression attachments.created Message-ID: <bug-208965-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 86B3E420E0 X-Rspamd-UID: 0e340c https://bugzilla.kernel.org/show_bug.cgi?id=208965 Bug ID: 208965 Summary: not working bluetooth mouse low energy rtl8822ce Product: Drivers Version: 2.5 Kernel Version: 5.8.1-arch1-1 Hardware: x86-64 OS: Linux Tree: Mainline Status: NEW Severity: high Priority: P1 Component: Bluetooth Assignee: linux-bluetooth@vger.kernel.org Reporter: fakecop@yandex.ru Regression: No Created attachment 292031 --> https://bugzilla.kernel.org/attachment.cgi?id=292031&action=edit journalctl I'm use huawei matebook 13 amd (2020), this is notebook use combo module wifi+bluetooth: Realtek 8822CE. I am trying to connect huawei mouse and i get error (in attachments) Systemctl log: ● bluetooth.service - Bluetooth service Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2020-08-04 16:36:29 MSK; 1min 4s ago Docs: man:bluetoothd(8) Main PID: 2110 (bluetoothd) Status: "Running" Tasks: 1 (limit: 17907) Memory: 1.7M CGroup: /system.slice/bluetooth.service └─2110 /usr/lib/bluetooth/bluetoothd -d авг 04 16:37:14 Anton bluetoothd[2110]: src/agent.c:agent_unref() 0x55720e940a70: ref=1 авг 04 16:37:14 Anton bluetoothd[2110]: src/adapter.c:resume_discovery() авг 04 16:37:14 Anton bluetoothd[2110]: src/adapter.c:pair_device_complete() Failed (0x03) авг 04 16:37:14 Anton bluetoothd[2110]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr FE:FD:2D:11:26:FD type 2 status 0x3 авг 04 16:37:14 Anton bluetoothd[2110]: src/device.c:device_bonding_complete() bonding (nil) status 0x03 авг 04 16:37:14 Anton bluetoothd[2110]: src/device.c:device_bonding_failed() status 3 авг 04 16:37:14 Anton bluetoothd[2110]: src/adapter.c:resume_discovery() авг 04 16:37:16 Anton bluetoothd[2110]: src/agent.c:agent_disconnect() Agent :1.118 disconnected авг 04 16:37:16 Anton bluetoothd[2110]: src/agent.c:agent_destroy() agent :1.118 авг 04 16:37:16 Anton bluetoothd[2110]: src/agent.c:agent_unref() 0x55720e940a70: ref=0 bluetoothctl: Agent registered [bluetooth]# select 1C:BF:C0:1A:8E:3C [bluetooth]# power on Changing power on succeeded [bluetooth]# scan on Discovery started [CHG] Controller 1C:BF:C0:1A:8E:3C Discovering: yes [NEW] Device FE:FD:2D:11:26:FD HUAWEI Mouse [bluetooth]# agent on Agent is already registered [bluetooth]# scan off Discovery stopped [CHG] Controller 1C:BF:C0:1A:8E:3C Discovering: no [CHG] Device FE:FD:2D:11:26:FD RSSI is nil [bluetooth]# pair FE:FD:2D:11:26:FD Attempting to pair with FE:FD:2D:11:26:FD [CHG] Device FE:FD:2D:11:26:FD Connected: yes [CHG] Device FE:FD:2D:11:26:FD Connected: no Failed to pair: org.bluez.Error.AuthenticationCanceled [bluetooth]# connect FE:FD:2D:11:26:FD Attempting to connect to FE:FD:2D:11:26:FD [CHG] Device FE:FD:2D:11:26:FD Connected: yes [CHG] Device FE:FD:2D:11:26:FD Connected: no Failed to connect: org.bluez.Error.Failed [bluetooth]# btmon log: Bluetooth monitor ver 5.54 = Note: Linux version 5.7.12-arch1-1 (x86_64) 0.859592 = Note: Bluetooth subsystem version 2.22 0.859597 = New Index: 1C:BF:C0:1A:8E:3C (Primary,USB,hci0) [hci0] 0.859598 = Open Index: 1C:BF:C0:1A:8E:3C [hci0] 0.859599 = Index Info: 1C:BF:C0:1A:8E:3C (Realtek Semiconductor Corporation) [hci0] 0.859601 @ MGMT Open: bluetoothd (privileged) version 1.16 {0x0001} 0.859602 @ MGMT Open: btmon (privileged) version 1.16 {0x0002} 0.859625 @ MGMT Command: Start Discovery (0x0023) plen 1 {0x0001} [hci0] 5.188846 Address type: 0x07 BR/EDR LE Public LE Random < HCI Command: LE Set Random Address (0x08|0x0005) plen 6 #1 [hci0] 5.188925 Address: 3E:88:2E:4E:58:6D (Non-Resolvable) > HCI Event: Command Complete (0x0e) plen 4 > #2 [hci0] 5.302358 LE Set Random Address (0x08|0x0005) ncmd 2 Status: Success (0x00) < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8 #3 [hci0] 5.302395 Own address type: Random (0x01) Filter policy: Accept all advertisement (0x00) PHYs: 0x01 Entry 0: LE 1M Type: Active (0x01) Interval: 11.250 msec (0x0012) Window: 11.250 msec (0x0012) > HCI Event: Command Complete (0x0e) plen 4 > #4 [hci0] 5.307380 LE Set Extended Scan Parameters (0x08|0x0041) ncmd 2 Status: Success (0x00) < HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6 #5 [hci0] 5.307438 Extended scan: Enabled (0x01) Filter duplicates: Enabled (0x01) Duration: 0 msec (0x0000) Period: 0.00 sec (0x0000) > HCI Event: Command Complete (0x0e) plen 4 > #6 [hci0] 5.310369 LE Set Extended Scan Enable (0x08|0x0042) ncmd 2 Status: Success (0x00) @ MGMT Event: Command Complete (0x0001) plen 4 {0x0001} [hci0] 5.310427 Start Discovery (0x0023) plen 1 Status: Success (0x00) Address type: 0x07 BR/EDR LE Public LE Random @ MGMT Event: Discovering (0x0013) plen 2 {0x0002} [hci0] 5.310439 Address type: 0x07 BR/EDR LE Public LE Random Discovery: Enabled (0x01) @ MGMT Event: Discovering (0x0013) plen 2 {0x0001} [hci0] 5.310439 Address type: 0x07 BR/EDR LE Public LE Random Discovery: Enabled (0x01) > HCI Event: LE Meta Event (0x3e) plen 54 > #7 [hci0] 6.257392 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x0010 Props: 0x0010 Use legacy advertising PDUs Data status: Complete Legacy PDU Type: ADV_NONCONN_IND (0x0010) Address type: Public (0x00) Address: 00:C3:F4:13:15:07 (Samsung Electronics Co.,Ltd) Primary PHY: LE 1M Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -72 dBm (0xb8) Periodic advertising invteral: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (OUI 00-00-00) Data length: 0x1c 1b ff 75 00 42 04 01 80 60 00 c3 f4 13 15 07 02 ..u.B...`....... c3 f4 13 15 06 01 00 00 00 00 00 00 ............ @ MGMT Event: Device Found (0x0012) plen 42 {0x0002} [hci0] 6.257457 LE Address: 00:C3:F4:13:15:07 (Samsung Electronics Co.,Ltd) RSSI: -72 dBm (0xb8) Flags: 0x00000004 Not Connectable Data length: 28 Company: Samsung Electronics Co. Ltd. (117) Data: 420401806000c3f413150702c3f413150601000000000000 @ MGMT Event: Device Found (0x0012) plen 42 {0x0001} [hci0] 6.257457 LE Address: 00:C3:F4:13:15:07 (Samsung Electronics Co.,Ltd) RSSI: -72 dBm (0xb8) Flags: 0x00000004 Not Connectable Data length: 28 Company: Samsung Electronics Co. Ltd. (117) Data: 420401806000c3f413150702c3f413150601000000000000 > HCI Event: LE Meta Event (0x3e) plen 52 > #8 [hci0] 9.000403 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x0013 Props: 0x0013 Connectable Scannable Use legacy advertising PDUs Data status: Complete Legacy PDU Type: ADV_IND (0x0013) Address type: Random (0x01) Address: FE:FD:2D:11:26:FD (Static) Primary PHY: LE 1M Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -24 dBm (0xe8) Periodic advertising invteral: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (OUI 00-00-00) Data length: 0x1a 0e 09 48 55 41 57 45 49 20 20 4d 6f 75 73 65 03 ..HUAWEI Mouse. 19 c2 03 02 01 05 03 03 12 18 .......... > HCI Event: LE Meta Event (0x3e) plen 52 > #9 [hci0] 9.147398 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x0013 Props: 0x0013 Connectable Scannable Use legacy advertising PDUs Data status: Complete Legacy PDU Type: ADV_IND (0x0013) Address type: Random (0x01) Address: FE:FD:2D:11:26:FD (Static) Primary PHY: LE 1M Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -16 dBm (0xf0) Periodic advertising invteral: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (OUI 00-00-00) Data length: 0x1a 0e 09 48 55 41 57 45 49 20 20 4d 6f 75 73 65 03 ..HUAWEI Mouse. 19 c2 03 02 01 05 03 03 12 18 .......... > HCI Event: LE Meta Event (0x3e) plen 52 > #10 [hci0] 9.357399 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x0013 Props: 0x0013 Connectable Scannable Use legacy advertising PDUs Data status: Complete Legacy PDU Type: ADV_IND (0x0013) Address type: Random (0x01) Address: FE:FD:2D:11:26:FD (Static) Primary PHY: LE 1M Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -14 dBm (0xf2) Periodic advertising invteral: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (OUI 00-00-00) Data length: 0x1a 0e 09 48 55 41 57 45 49 20 20 4d 6f 75 73 65 03 ..HUAWEI Mouse. 19 c2 03 02 01 05 03 03 12 18 .......... > HCI Event: LE Meta Event (0x3e) plen 52 > #11 [hci0] 9.567397 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x0013 Props: 0x0013 Connectable Scannable Use legacy advertising PDUs Data status: Complete Legacy PDU Type: ADV_IND (0x0013) Address type: Random (0x01) Address: FE:FD:2D:11:26:FD (Static) Primary PHY: LE 1M Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -16 dBm (0xf0) Periodic advertising invteral: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (OUI 00-00-00) Data length: 0x1a 0e 09 48 55 41 57 45 49 20 20 4d 6f 75 73 65 03 ..HUAWEI Mouse. 19 c2 03 02 01 05 03 03 12 18 .......... > HCI Event: LE Meta Event (0x3e) plen 52 > #12 [hci0] 9.777398 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x0013 Props: 0x0013 Connectable Scannable Use legacy advertising PDUs Data status: Complete Legacy PDU Type: ADV_IND (0x0013) Address type: Random (0x01) Address: FE:FD:2D:11:26:FD (Static) Primary PHY: LE 1M Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -10 dBm (0xf6) Periodic advertising invteral: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (OUI 00-00-00) Data length: 0x1a 0e 09 48 55 41 57 45 49 20 20 4d 6f 75 73 65 03 ..HUAWEI Mouse. 19 c2 03 02 01 05 03 03 12 18 .......... > HCI Event: LE Meta Event (0x3e) plen 52 > #13 [hci0] 9.987376 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x0013 Props: 0x0013 Connectable Scannable Use legacy advertising PDUs Data status: Complete Legacy PDU Type: ADV_IND (0x0013) Address type: Random (0x01) Address: FE:FD:2D:11:26:FD (Static) Primary PHY: LE 1M Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -8 dBm (0xf8) Periodic advertising invteral: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (OUI 00-00-00) Data length: 0x1a 0e 09 48 55 41 57 45 49 20 20 4d 6f 75 73 65 03 ..HUAWEI Mouse. 19 c2 03 02 01 05 03 03 12 18 .......... > HCI Event: LE Meta Event (0x3e) plen 52 > #14 [hci0] 10.197401 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x0013 Props: 0x0013 Connectable Scannable Use legacy advertising PDUs Data status: Complete Legacy PDU Type: ADV_IND (0x0013) Address type: Random (0x01) Address: FE:FD:2D:11:26:FD (Static) Primary PHY: LE 1M Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -14 dBm (0xf2) Periodic advertising invteral: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (OUI 00-00-00) Data length: 0x1a 0e 09 48 55 41 57 45 49 20 20 4d 6f 75 73 65 03 ..HUAWEI Mouse. 19 c2 03 02 01 05 03 03 12 18 .......... > HCI Event: LE Meta Event (0x3e) plen 52 > #15 [hci0] 10.407402 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x0013 Props: 0x0013 Connectable Scannable Use legacy advertising PDUs Data status: Complete Legacy PDU Type: ADV_IND (0x0013) Address type: Random (0x01) Address: FE:FD:2D:11:26:FD (Static) Primary PHY: LE 1M Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -12 dBm (0xf4) Periodic advertising invteral: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (OUI 00-00-00) Data length: 0x1a 0e 09 48 55 41 57 45 49 20 20 4d 6f 75 73 65 03 ..HUAWEI Mouse. 19 c2 03 02 01 05 03 03 12 18 .......... < HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6 #16 [hci0] 10.525798 Extended scan: Disabled (0x00) Filter duplicates: Disabled (0x00) Duration: 0 msec (0x0000) Period: 0.00 sec (0x0000) > HCI Event: Command Complete (0x0e) plen 4 > #17 [hci0] 10.527420 LE Set Extended Scan Enable (0x08|0x0042) ncmd 2 Status: Success (0x00) @ MGMT Event: Device Found (0x0012) plen 40 {0x0002} [hci0] 10.527479 LE Address: FE:FD:2D:11:26:FD (Static) RSSI: -12 dBm (0xf4) Flags: 0x00000000 Data length: 26 Name (complete): HUAWEI Mouse Appearance: Mouse (0x03c2) Flags: 0x05 LE Limited Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (complete): 1 entry Human Interface Device (0x1812) @ MGMT Event: Device Found (0x0012) plen 40 {0x0001} [hci0] 10.527479 LE Address: FE:FD:2D:11:26:FD (Static) RSSI: -12 dBm (0xf4) Flags: 0x00000000 Data length: 26 Name (complete): HUAWEI Mouse Appearance: Mouse (0x03c2) Flags: 0x05 LE Limited Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (complete): 1 entry Human Interface Device (0x1812) < HCI Command: Inquiry (0x01|0x0001) plen 5 #18 [hci0] 10.527581 Access code: 0x9e8b33 (General Inquiry) Length: 5.12s (0x04) Num responses: 0 > HCI Event: Command Status (0x0f) plen 4 > #19 [hci0] 10.530407 Inquiry (0x01|0x0001) ncmd 2 Status: Success (0x00) > HCI Event: Inquiry Complete (0x01) plen 1 > #20 [hci0] 15.713404 Status: Success (0x00) @ MGMT Event: Discovering (0x0013) plen 2 {0x0002} [hci0] 15.713434 Address type: 0x07 BR/EDR LE Public LE Random Discovery: Disabled (0x00) @ MGMT Event: Discovering (0x0013) plen 2 {0x0001} [hci0] 15.713434 Address type: 0x07 BR/EDR LE Public LE Random Discovery: Disabled (0x00) @ MGMT Command: Pair Device (0x0019) plen 8 {0x0001} [hci0] 15.737736 LE Address: FE:FD:2D:11:26:FD (Static) Capability: DisplayYesNo (0x01) < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8 #21 [hci0] 15.737806 Own address type: Public (0x00) Filter policy: Ignore not in white list (0x01) PHYs: 0x01 Entry 0: LE 1M Type: Passive (0x00) Interval: 60.000 msec (0x0060) Window: 30.000 msec (0x0030) > HCI Event: Command Complete (0x0e) plen 4 > #22 [hci0] 15.739428 LE Set Extended Scan Parameters (0x08|0x0041) ncmd 2 Status: Success (0x00) < HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6 #23 [hci0] 15.739490 Extended scan: Enabled (0x01) Filter duplicates: Enabled (0x01) Duration: 0 msec (0x0000) Period: 0.00 sec (0x0000) > HCI Event: Command Complete (0x0e) plen 4 > #24 [hci0] 15.742444 LE Set Extended Scan Enable (0x08|0x0042) ncmd 2 Status: Success (0x00) > HCI Event: LE Meta Event (0x3e) plen 52 > #25 [hci0] 15.847438 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x0013 Props: 0x0013 Connectable Scannable Use legacy advertising PDUs Data status: Complete Legacy PDU Type: ADV_IND (0x0013) Address type: Random (0x01) Address: FE:FD:2D:11:26:FD (Static) Primary PHY: LE 1M Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -40 dBm (0xd8) Periodic advertising invteral: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (OUI 00-00-00) Data length: 0x1a 0e 09 48 55 41 57 45 49 20 20 4d 6f 75 73 65 03 ..HUAWEI Mouse. 19 c2 03 02 01 05 03 03 12 18 .......... < HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6 #26 [hci0] 15.847520 Extended scan: Disabled (0x00) Filter duplicates: Disabled (0x00) Duration: 0 msec (0x0000) Period: 0.00 sec (0x0000) > HCI Event: Command Complete (0x0e) plen 4 > #27 [hci0] 15.849412 LE Set Extended Scan Enable (0x08|0x0042) ncmd 2 Status: Success (0x00) < HCI Command: LE Extended Create Connection (0x08|0x0043) plen 26 #28 [hci0] 15.849470 Filter policy: White list is not used (0x00) Own address type: Public (0x00) Peer address type: Random (0x01) Peer address: FE:FD:2D:11:26:FD (Static) Initiating PHYs: 0x01 Entry 0: LE 1M Scan interval: 60.000 msec (0x0060) Scan window: 60.000 msec (0x0060) Min connection interval: 30.00 msec (0x0018) Max connection interval: 50.00 msec (0x0028) Connection latency: 0 (0x0000) Supervision timeout: 420 msec (0x002a) Min connection length: 0.000 msec (0x0000) Max connection length: 0.000 msec (0x0000) > HCI Event: Command Status (0x0f) plen 4 > #29 [hci0] 15.852531 LE Extended Create Connection (0x08|0x0043) ncmd 2 Status: Success (0x00) > HCI Event: LE Meta Event (0x3e) plen 31 > #30 [hci0] 16.036426 LE Enhanced Connection Complete (0x0a) Status: Success (0x00) Handle: 16 Role: Master (0x00) Peer address type: Random (0x01) Peer address: FE:FD:2D:11:26:FD (Static) Local resolvable private address: 00:00:00:00:00:00 (Non-Resolvable) Peer resolvable private address: 00:00:00:00:00:00 (Non-Resolvable) Connection interval: 45.00 msec (0x0024) Connection latency: 0 (0x0000) Supervision timeout: 420 msec (0x002a) Master clock accuracy: 0x00 @ MGMT Event: Device Connected (0x000b) plen 39 {0x0002} [hci0] 16.036500 LE Address: FE:FD:2D:11:26:FD (Static) Flags: 0x00000000 Data length: 26 Name (complete): HUAWEI Mouse Appearance: Mouse (0x03c2) Flags: 0x05 LE Limited Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (complete): 1 entry Human Interface Device (0x1812) @ MGMT Event: Device Connected (0x000b) plen 39 {0x0001} [hci0] 16.036500 LE Address: FE:FD:2D:11:26:FD (Static) Flags: 0x00000000 Data length: 26 Name (complete): HUAWEI Mouse Appearance: Mouse (0x03c2) Flags: 0x05 LE Limited Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (complete): 1 entry Human Interface Device (0x1812) < HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2 #31 [hci0] 16.036597 Handle: 16 > HCI Event: Command Status (0x0f) plen 4 > #32 [hci0] 16.038415 LE Read Remote Used Features (0x08|0x0016) ncmd 2 Status: Success (0x00) > HCI Event: LE Meta Event (0x3e) plen 4 > #33 [hci0] 16.059417 LE Channel Selection Algorithm (0x14) Handle: 16 Algorithm: #1 (0x00) > HCI Event: Disconnect Complete (0x05) plen 4 > #34 [hci0] 16.284578 Status: Success (0x00) Handle: 16 Reason: Connection Failed to be Established (0x3e) @ MGMT Event: Device Disconnected (0x000c) plen 8 {0x0002} [hci0] 16.284608 LE Address: FE:FD:2D:11:26:FD (Static) Reason: Unspecified (0x00) @ MGMT Event: Device Disconnected (0x000c) plen 8 {0x0001} [hci0] 16.284608 LE Address: FE:FD:2D:11:26:FD (Static) Reason: Unspecified (0x00) @ MGMT Event: Command Complete (0x0001) plen 10 {0x0001} [hci0] 16.284627 Pair Device (0x0019) plen 7 Status: Failed (0x03) LE Address: FE:FD:2D:11:26:FD (Static) @ MGMT Command: Start Discovery (0x0023) plen 1 {0x0001} [hci0] 18.178861 Address type: 0x07 BR/EDR LE Public LE Random < HCI Command: LE Set Random Address (0x08|0x0005) plen 6 #35 [hci0] 18.178943 Address: 19:76:BC:0F:FA:10 (Non-Resolvable) > HCI Event: Command Complete (0x0e) plen 4 > #36 [hci0] 18.180482 LE Set Random Address (0x08|0x0005) ncmd 2 Status: Success (0x00) < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8 #37 [hci0] 18.180539 Own address type: Random (0x01) Filter policy: Accept all advertisement (0x00) PHYs: 0x01 Entry 0: LE 1M Type: Active (0x01) Interval: 11.250 msec (0x0012) Window: 11.250 msec (0x0012) > HCI Event: Command Complete (0x0e) plen 4 > #38 [hci0] 18.183465 LE Set Extended Scan Parameters (0x08|0x0041) ncmd 2 Status: Success (0x00) < HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6 #39 [hci0] 18.183520 Extended scan: Enabled (0x01) Filter duplicates: Enabled (0x01) Duration: 0 msec (0x0000) Period: 0.00 sec (0x0000) > HCI Event: Command Complete (0x0e) plen 4 > #40 [hci0] 18.186452 LE Set Extended Scan Enable (0x08|0x0042) ncmd 2 Status: Success (0x00) @ MGMT Event: Command Complete (0x0001) plen 4 {0x0001} [hci0] 18.186538 Start Discovery (0x0023) plen 1 Status: Success (0x00) Address type: 0x07 BR/EDR LE Public LE Random @ MGMT Event: Discovering (0x0013) plen 2 {0x0002} [hci0] 18.186547 Address type: 0x07 BR/EDR LE Public LE Random Discovery: Enabled (0x01) @ MGMT Event: Discovering (0x0013) plen 2 {0x0001} [hci0] 18.186547 Address type: 0x07 BR/EDR LE Public LE Random Discovery: Enabled (0x01) @ MGMT Command: Stop Discovery (0x0024) plen 1 {0x0001} [hci0] 19.465795 Address type: 0x07 BR/EDR LE Public LE Random < HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6 #41 [hci0] 19.465838 Extended scan: Disabled (0x00) Filter duplicates: Disabled (0x00) Duration: 0 msec (0x0000) Period: 0.00 sec (0x0000) > HCI Event: Command Complete (0x0e) plen 4 > #42 [hci0] 19.467439 LE Set Extended Scan Enable (0x08|0x0042) ncmd 2 Status: Success (0x00) @ MGMT Event: Command Complete (0x0001) plen 4 {0x0001} [hci0] 19.467508 Stop Discovery (0x0024) plen 1 Status: Success (0x00) Address type: 0x07 BR/EDR LE Public LE Random @ MGMT Event: Discovering (0x0013) plen 2 {0x0002} [hci0] 19.467526 Address type: 0x07 BR/EDR LE Public LE Random Discovery: Disabled (0x00) @ MGMT Event: Discovering (0x0013) plen 2 {0x0001} [hci0] 19.467526 Address type: 0x07 BR/EDR LE Public LE Random Discovery: Disabled (0x00) @ MGMT Command: Stop Discovery (0x0024) plen 1 {0x0001} [hci0] 19.467699 Address type: 0x07 BR/EDR LE Public LE Random @ MGMT Event: Command Complete (0x0001) plen 4 {0x0001} [hci0] 19.467709 Stop Discovery (0x0024) plen 1 Status: Rejected (0x0b) Address type: 0x07 BR/EDR LE Public LE Random @ MGMT Command: Pair Device (0x0019) plen 8 {0x0001} [hci0] 19.467757 LE Address: FE:FD:2D:11:26:FD (Static) Capability: DisplayYesNo (0x01) < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8 #43 [hci0] 19.467802 Own address type: Public (0x00) Filter policy: Ignore not in white list (0x01) PHYs: 0x01 Entry 0: LE 1M Type: Passive (0x00) Interval: 60.000 msec (0x0060) Window: 30.000 msec (0x0030) > HCI Event: Command Complete (0x0e) plen 4 > #44 [hci0] 19.470445 LE Set Extended Scan Parameters (0x08|0x0041) ncmd 2 Status: Success (0x00) < HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6 #45 [hci0] 19.470513 Extended scan: Enabled (0x01) Filter duplicates: Enabled (0x01) Duration: 0 msec (0x0000) Period: 0.00 sec (0x0000) > HCI Event: Command Complete (0x0e) plen 4 > #46 [hci0] 19.473434 LE Set Extended Scan Enable (0x08|0x0042) ncmd 2 Status: Success (0x00) > HCI Event: LE Meta Event (0x3e) plen 52 > #47 [hci0] 19.587457 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x0013 Props: 0x0013 Connectable Scannable Use legacy advertising PDUs Data status: Complete Legacy PDU Type: ADV_IND (0x0013) Address type: Random (0x01) Address: FE:FD:2D:11:26:FD (Static) Primary PHY: LE 1M Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -44 dBm (0xd4) Periodic advertising invteral: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (OUI 00-00-00) Data length: 0x1a 0e 09 48 55 41 57 45 49 20 20 4d 6f 75 73 65 03 ..HUAWEI Mouse. 19 c2 03 02 01 05 03 03 12 18 .......... < HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6 #48 [hci0] 19.587536 Extended scan: Disabled (0x00) Filter duplicates: Disabled (0x00) Duration: 0 msec (0x0000) Period: 0.00 sec (0x0000) > HCI Event: Command Complete (0x0e) plen 4 > #49 [hci0] 19.589453 LE Set Extended Scan Enable (0x08|0x0042) ncmd 2 Status: Success (0x00) < HCI Command: LE Extended Create Connection (0x08|0x0043) plen 26 #50 [hci0] 19.589492 Filter policy: White list is not used (0x00) Own address type: Public (0x00) Peer address type: Random (0x01) Peer address: FE:FD:2D:11:26:FD (Static) Initiating PHYs: 0x01 Entry 0: LE 1M Scan interval: 60.000 msec (0x0060) Scan window: 60.000 msec (0x0060) Min connection interval: 30.00 msec (0x0018) Max connection interval: 50.00 msec (0x0028) Connection latency: 0 (0x0000) Supervision timeout: 420 msec (0x002a) Min connection length: 0.000 msec (0x0000) Max connection length: 0.000 msec (0x0000) > HCI Event: Command Status (0x0f) plen 4 > #51 [hci0] 19.592524 LE Extended Create Connection (0x08|0x0043) ncmd 2 Status: Success (0x00) > HCI Event: LE Meta Event (0x3e) plen 31 > #52 [hci0] 19.798455 LE Enhanced Connection Complete (0x0a) Status: Success (0x00) Handle: 16 Role: Master (0x00) Peer address type: Random (0x01) Peer address: FE:FD:2D:11:26:FD (Static) Local resolvable private address: 00:00:00:00:00:00 (Non-Resolvable) Peer resolvable private address: 00:00:00:00:00:00 (Non-Resolvable) Connection interval: 45.00 msec (0x0024) Connection latency: 0 (0x0000) Supervision timeout: 420 msec (0x002a) Master clock accuracy: 0x00 @ MGMT Event: Device Connected (0x000b) plen 39 {0x0002} [hci0] 19.798500 LE Address: FE:FD:2D:11:26:FD (Static) Flags: 0x00000000 Data length: 26 Name (complete): HUAWEI Mouse Appearance: Mouse (0x03c2) Flags: 0x05 LE Limited Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (complete): 1 entry Human Interface Device (0x1812) @ MGMT Event: Device Connected (0x000b) plen 39 {0x0001} [hci0] 19.798500 LE Address: FE:FD:2D:11:26:FD (Static) Flags: 0x00000000 Data length: 26 Name (complete): HUAWEI Mouse Appearance: Mouse (0x03c2) Flags: 0x05 LE Limited Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (complete): 1 entry Human Interface Device (0x1812) < HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2 #53 [hci0] 19.798601 Handle: 16 > HCI Event: Command Status (0x0f) plen 4 > #54 [hci0] 19.800437 LE Read Remote Used Features (0x08|0x0016) ncmd 2 Status: Success (0x00) > HCI Event: LE Meta Event (0x3e) plen 4 > #55 [hci0] 19.826470 LE Channel Selection Algorithm (0x14) Handle: 16 Algorithm: #1 (0x00) > HCI Event: Disconnect Complete (0x05) plen 4 > #56 [hci0] 20.051518 Status: Success (0x00) Handle: 16 Reason: Connection Failed to be Established (0x3e) @ MGMT Event: Device Disconnected (0x000c) plen 8 {0x0002} [hci0] 20.051576 LE Address: FE:FD:2D:11:26:FD (Static) Reason: Unspecified (0x00) @ MGMT Event: Device Disconnected (0x000c) plen 8 {0x0001} [hci0] 20.051576 LE Address: FE:FD:2D:11:26:FD (Static) Reason: Unspecified (0x00) @ MGMT Event: Command Complete (0x0001) plen 10 {0x0001} [hci0] 20.051594 Pair Device (0x0019) plen 7 Status: Failed (0x03) LE Address: FE:FD:2D:11:26:FD (Static) P.S.: Please help and fix it! Mouse used bluetooth 4.0 low energy -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4BvoByiePV+PgAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 19 Aug 2020 23:48:24 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id kLhgBiiePV/rVwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 19 Aug 2020 23:48:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ED8A042121; Wed, 19 Aug 2020 23:48:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbgHSVsF (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 19 Aug 2020 17:48:05 -0400 Received: from mga18.intel.com ([134.134.136.126]:17684 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgHSVsF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 19 Aug 2020 17:48:05 -0400 IronPort-SDR: Yr3GIvBu0vxLDTBkCfzlkjEBGmK/VB5tWfs306NrcmN9eSv8egQkifc1owEYALA/MtjLY/Bnf0 0H9GV3tA44OQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="142834216" X-IronPort-AV: E=Sophos;i="5.76,332,1592895600"; d="scan'208";a="142834216" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2020 14:48:04 -0700 IronPort-SDR: gkIEOAl4gQv6ZJ5AuBXrudZDx7Cjt8NL5YXekRdcuOIh6uRg+K/aBw/+FtshatbtHSTBEx20bJ mZTom9o58ZBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,332,1592895600"; d="scan'208";a="297357612" Received: from aupasani-mobl1.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.81.12]) by orsmga006.jf.intel.com with ESMTP; 19 Aug 2020 14:48:03 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] mesh: Send correct NetKey index in DevKeyMessageReceived Date: Wed, 19 Aug 2020 14:48:02 -0700 Message-Id: <20200819214802.83756-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.97 / 15.00 / 200.00 X-Rspamd-Queue-Id: ED8A042121 X-Rspamd-UID: 74e848 The value of net_index in DevKeyMessageReceived() method must be set to the value of a subnet index on which a device key encoded message has been received. Was hard coded to 0. Fixed. --- mesh/model.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mesh/model.c b/mesh/model.c index b44e2f669..9529dfb2e 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -965,7 +965,8 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, else if (decrypt_idx == APP_IDX_DEV_REMOTE || decrypt_idx == APP_IDX_DEV_LOCAL) send_dev_key_msg_rcvd(node, i, src, decrypt_idx, - 0, forward.size, forward.data); + net_idx, forward.size, + forward.data); } /* -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wjO/MfMNPl87pAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 07:45:23 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wKroLvMNPl/nMgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 07:45:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 59F20A1DCD; Thu, 20 Aug 2020 07:41:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725798AbgHTFlf (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 01:41:35 -0400 Received: from mga18.intel.com ([134.134.136.126]:54471 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725778AbgHTFle (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 01:41:34 -0400 IronPort-SDR: BcBap1Y8AAW5GYsGBsSppBXotrV2Q6HtzXGB6f9IR58b5rd9PMof5czq5HjyM0FjSSUiI/D+rb hNVMw+doVFkQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="142875131" X-IronPort-AV: E=Sophos;i="5.76,332,1592895600"; d="scan'208";a="142875131" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2020 22:41:33 -0700 IronPort-SDR: Kj75FP9OtUJyLNyXNWxKsohEVNLLe66dh0wAcME8u0FsCSGVrVZgMvXH6XxDLdm02aInTFUN3T /ZP0AyhGCjoQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,332,1592895600"; d="scan'208";a="320740667" Received: from aupasani-mobl1.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.81.12]) by fmsmga004.fm.intel.com with ESMTP; 19 Aug 2020 22:41:33 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] mesh: Use correct retransmit parameters for publications Date: Wed, 19 Aug 2020 22:41:32 -0700 Message-Id: <20200820054132.110483-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: 59F20A1DCD X-Rspamd-UID: 9c8838 This adds previously missing retransmit count and interval values specific to model publications. The values are configured by Config CLient and may be different to each model. --- mesh/cfgmod-server.c | 26 +++++++++++------- mesh/mesh-config-json.c | 36 ++++++++++++------------- mesh/mesh-config.h | 4 +-- mesh/model.c | 59 +++++++++++++++++++++++------------------ mesh/model.h | 9 ++++--- mesh/net.c | 42 ++++++++++++++++++----------- mesh/net.h | 6 ++--- 7 files changed, 104 insertions(+), 78 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 90ebdf046..239ea889d 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -48,7 +48,7 @@ static uint8_t msg[MAX_MSG_LEN]; static uint16_t set_pub_status(uint8_t status, uint16_t ele_addr, uint32_t id, uint16_t pub_addr, uint16_t idx, bool cred_flag, - uint8_t ttl, uint8_t period, uint8_t retransmit) + uint8_t ttl, uint8_t period, uint8_t rtx) { size_t n; @@ -61,7 +61,7 @@ static uint16_t set_pub_status(uint8_t status, uint16_t ele_addr, uint32_t id, n += 6; msg[n++] = ttl; msg[n++] = period; - msg[n++] = retransmit; + msg[n++] = rtx; if (!IS_VENDOR(id)) { l_put_le16(MODEL_ID(id), msg + n); @@ -80,6 +80,7 @@ static uint16_t config_pub_get(struct mesh_node *node, const uint8_t *pkt, { uint32_t id; uint16_t ele_addr; + uint8_t rtx; struct mesh_model_pub *pub; int status; @@ -88,10 +89,12 @@ static uint16_t config_pub_get(struct mesh_node *node, const uint8_t *pkt, pub = mesh_model_pub_get(node, ele_addr, id, &status); + rtx = pub->rtx.cnt + (((pub->rtx.interval / 50) - 1) << 3); + if (pub && status == MESH_STATUS_SUCCESS) return set_pub_status(status, ele_addr, id, pub->addr, pub->idx, pub->credential, pub->ttl, pub->period, - pub->retransmit); + rtx); else return set_pub_status(status, ele_addr, id, 0, 0, 0, 0, 0, 0); } @@ -102,7 +105,7 @@ static uint16_t config_pub_set(struct mesh_node *node, const uint8_t *pkt, uint32_t id; uint16_t ele_addr, idx, pub_dst; const uint8_t *pub_addr; - uint8_t ttl, period, retransmit; + uint8_t ttl, period, rtx, cnt, interval; int status; bool cred_flag; @@ -124,12 +127,15 @@ static uint16_t config_pub_set(struct mesh_node *node, const uint8_t *pkt, idx &= APP_IDX_MASK; ttl = pkt[6]; period = pkt[7]; - retransmit = pkt[8]; + rtx = pkt[8]; id = CFG_GET_ID(vendor, pkt + 9); + cnt = rtx & 0x7; + interval = ((rtx >> 3) + 1) * 50; + status = mesh_model_pub_set(node, ele_addr, id, pub_addr, idx, - cred_flag, ttl, period, retransmit, - virt, &pub_dst); + cred_flag, ttl, period, cnt, + interval, virt, &pub_dst); l_debug("pub_set: status %d, ea %4.4x, ota: %4.4x, id: %x, idx: %3.3x", status, ele_addr, pub_dst, id, idx); @@ -153,8 +159,8 @@ static uint16_t config_pub_set(struct mesh_node *node, const uint8_t *pkt, .ttl = ttl, .credential = cred_flag, .period = period, - .count = retransmit & 0x7, - .interval = ((retransmit >> 3) + 1) * 50 + .cnt = cnt, + .interval = interval }; if (virt) @@ -168,7 +174,7 @@ static uint16_t config_pub_set(struct mesh_node *node, const uint8_t *pkt, } return set_pub_status(status, ele_addr, id, pub_dst, idx, cred_flag, - ttl, period, retransmit); + ttl, period, rtx); } static uint16_t cfg_sub_get_msg(struct mesh_node *node, const uint8_t *pkt, diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index a145388d6..63b6c3988 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1021,7 +1021,7 @@ static struct mesh_config_pub *parse_model_publication(json_object *jpub) if (!get_int(jvalue, "count", &value)) goto fail; - pub->count = (uint8_t) value; + pub->cnt = (uint8_t) value; if (!get_int(jvalue, "interval", &value)) goto fail; @@ -1339,20 +1339,20 @@ static bool parse_composition(json_object *jcomp, struct mesh_config_node *node) static bool read_net_transmit(json_object *jobj, struct mesh_config_node *node) { - json_object *jretransmit, *jvalue; + json_object *jrtx, *jvalue; uint16_t interval; uint8_t cnt; - if (!json_object_object_get_ex(jobj, "retransmit", &jretransmit)) + if (!json_object_object_get_ex(jobj, "retransmit", &jrtx)) return true; - if (!json_object_object_get_ex(jretransmit, "count", &jvalue)) + if (!json_object_object_get_ex(jrtx, "count", &jvalue)) return false; /* TODO: add range checking */ cnt = (uint8_t) json_object_get_int(jvalue); - if (!json_object_object_get_ex(jretransmit, "interval", &jvalue)) + if (!json_object_object_get_ex(jrtx, "interval", &jvalue)) return false; interval = (uint16_t) json_object_get_int(jvalue); @@ -1566,30 +1566,30 @@ bool mesh_config_write_relay_mode(struct mesh_config *cfg, uint8_t mode, bool mesh_config_write_net_transmit(struct mesh_config *cfg, uint8_t cnt, uint16_t interval) { - json_object *jnode, *jretransmit; + json_object *jnode, *jrtx; if (!cfg) return false; jnode = cfg->jnode; - jretransmit = json_object_new_object(); - if (!jretransmit) + jrtx = json_object_new_object(); + if (!jrtx) return false; - if (!write_int(jretransmit, "count", cnt)) + if (!write_int(jrtx, "count", cnt)) goto fail; - if (!write_int(jretransmit, "interval", interval)) + if (!write_int(jrtx, "interval", interval)) goto fail; json_object_object_del(jnode, "retransmit"); - json_object_object_add(jnode, "retransmit", jretransmit); + json_object_object_add(jnode, "retransmit", jrtx); return save_config(cfg->jnode, cfg->node_dir_path); fail: - json_object_put(jretransmit); + json_object_put(jrtx); return false; } @@ -1841,7 +1841,7 @@ bool mesh_config_model_pub_add(struct mesh_config *cfg, uint16_t ele_addr, uint32_t mod_id, bool vendor, struct mesh_config_pub *pub) { - json_object *jnode, *jmodel, *jpub, *jretransmit; + json_object *jnode, *jmodel, *jpub, *jrtx; bool res; int ele_idx; @@ -1885,17 +1885,17 @@ bool mesh_config_model_pub_add(struct mesh_config *cfg, uint16_t ele_addr, pub->credential ? 1 : 0)) goto fail; - jretransmit = json_object_new_object(); - if (!jretransmit) + jrtx = json_object_new_object(); + if (!jrtx) goto fail; - if (!write_int(jretransmit, "count", pub->count)) + if (!write_int(jrtx, "count", pub->cnt)) goto fail; - if (!write_int(jretransmit, "interval", pub->interval)) + if (!write_int(jrtx, "interval", pub->interval)) goto fail; - json_object_object_add(jpub, "retransmit", jretransmit); + json_object_object_add(jpub, "retransmit", jrtx); json_object_object_add(jmodel, "publish", jpub); return save_config(jnode, cfg->node_dir_path); diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 50a55d51e..738cff9dd 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -34,10 +34,10 @@ struct mesh_config_pub { uint32_t period; uint16_t addr; uint16_t idx; + uint16_t interval; uint8_t ttl; uint8_t credential; - uint8_t count; - uint8_t interval; + uint8_t cnt; uint8_t virt_addr[16]; }; diff --git a/mesh/model.c b/mesh/model.c index 961391f13..eb5142503 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -508,10 +508,11 @@ static int virt_packet_decrypt(struct mesh_net *net, const uint8_t *data, return -1; } -static bool msg_send(struct mesh_node *node, bool credential, uint16_t src, - uint32_t dst, uint16_t app_idx, uint16_t net_idx, - uint8_t *label, uint8_t ttl, bool segmented, - const void *msg, uint16_t msg_len) +static bool msg_send(struct mesh_node *node, bool cred, uint16_t src, + uint16_t dst, uint16_t app_idx, uint16_t net_idx, + uint8_t *label, uint8_t ttl, uint8_t cnt, + uint16_t interval, bool segmented, const void *msg, + uint16_t msg_len) { uint8_t dev_key[16]; uint32_t iv_index, seq_num; @@ -562,9 +563,9 @@ static bool msg_send(struct mesh_node *node, bool credential, uint16_t src, goto done; } - ret = mesh_net_app_send(net, credential, src, dst, key_aid, net_idx, - ttl, seq_num, iv_index, segmented, - szmic, out, out_len); + ret = mesh_net_app_send(net, cred, src, dst, key_aid, net_idx, ttl, + cnt, interval, seq_num, iv_index, + segmented, szmic, out, out_len); done: l_free(out); return ret; @@ -705,7 +706,7 @@ static struct mesh_virtual *add_virtual(const uint8_t *v) static int set_pub(struct mesh_model *mod, uint16_t pub_addr, uint16_t idx, bool cred_flag, uint8_t ttl, - uint8_t period, uint8_t retransmit) + uint8_t period, uint8_t cnt, uint16_t interval) { if (!mod->pub) mod->pub = l_new(struct mesh_model_pub, 1); @@ -715,14 +716,15 @@ static int set_pub(struct mesh_model *mod, uint16_t pub_addr, mod->pub->idx = idx; mod->pub->ttl = ttl; mod->pub->period = period; - mod->pub->retransmit = retransmit; + mod->pub->rtx.cnt = cnt; + mod->pub->rtx.interval = interval; return MESH_STATUS_SUCCESS; } static int set_virt_pub(struct mesh_model *mod, const uint8_t *label, uint16_t idx, bool cred_flag, uint8_t ttl, - uint8_t period, uint8_t retransmit) + uint8_t period, uint8_t cnt, uint16_t interval) { struct mesh_virtual *virt = NULL; @@ -734,8 +736,8 @@ static int set_virt_pub(struct mesh_model *mod, const uint8_t *label, mod->pub = l_new(struct mesh_model_pub, 1); mod->pub->virt = virt; - return set_pub(mod, virt->addr, idx, cred_flag, ttl, period, - retransmit); + return set_pub(mod, virt->addr, idx, cred_flag, ttl, period, cnt, + interval); } static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod, @@ -1058,9 +1060,10 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, net_idx = appkey_net_idx(net, mod->pub->idx); - result = msg_send(node, mod->pub->credential != 0, src, - mod->pub->addr, mod->pub->idx, net_idx, - label, mod->pub->ttl, false, msg, msg_len); + result = msg_send(node, mod->pub->credential != 0, src, mod->pub->addr, + mod->pub->idx, net_idx, label, mod->pub->ttl, + mod->pub->rtx.cnt, mod->pub->rtx.interval, + false, msg, msg_len); return result ? MESH_ERROR_NONE : MESH_ERROR_FAILED; } @@ -1070,6 +1073,10 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint8_t ttl, bool segmented, const void *msg, uint16_t msg_len) { + struct mesh_net *net = node_get_net(node); + uint8_t cnt; + uint16_t interval; + /* If SRC is 0, use the Primary Element */ if (src == 0) src = node_get_primary(node); @@ -1079,14 +1086,16 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, if (IS_UNASSIGNED(dst)) return false; - return msg_send(node, false, src, dst, app_idx, net_idx, - NULL, ttl, segmented, msg, msg_len); + mesh_net_transmit_params_get(net, &cnt, &interval); + + return msg_send(node, false, src, dst, app_idx, net_idx, NULL, ttl, cnt, + interval, segmented, msg, msg_len); } int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, const uint8_t *pub_addr, uint16_t idx, bool cred_flag, - uint8_t ttl, uint8_t period, uint8_t retransmit, - bool is_virt, uint16_t *pub_dst) + uint8_t ttl, uint8_t period, uint8_t cnt, + uint16_t interval, bool is_virt, uint16_t *pub_dst) { struct mesh_model *mod; int status, ele_idx = node_get_element_idx(node, addr); @@ -1124,10 +1133,10 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id, if (!is_virt) { status = set_pub(mod, l_get_le16(pub_addr), idx, cred_flag, - ttl, period, retransmit); + ttl, period, cnt, interval); } else status = set_virt_pub(mod, pub_addr, idx, cred_flag, ttl, - period, retransmit); + period, cnt, interval); *pub_dst = mod->pub->addr; @@ -1703,15 +1712,13 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx, /* Add publication if enabled and present */ if (mod->pub_enabled && pub) { - uint8_t retransmit = pub->count + - ((pub->interval / 50 - 1) << 3); if (pub->virt) set_virt_pub(mod, pub->virt_addr, pub->idx, - pub->credential, pub->ttl, - pub->period, retransmit); + pub->credential, pub->ttl, pub->period, + pub->cnt, pub->interval); else if (!IS_UNASSIGNED(pub->addr)) set_pub(mod, pub->addr, pub->idx, pub->credential, - pub->ttl, pub->period, retransmit); + pub->ttl, pub->period, pub->cnt, pub->interval); } mod->sub_enabled = db_mod->sub_enabled; diff --git a/mesh/model.h b/mesh/model.h index 147a02279..a1afedd19 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -40,10 +40,13 @@ struct mesh_model_pub { struct mesh_virtual *virt; uint16_t addr; uint16_t idx; + struct { + uint16_t interval; + uint8_t cnt; + } rtx; uint8_t ttl; uint8_t credential; uint8_t period; - uint8_t retransmit; }; typedef void (*mesh_model_unregister)(void *user_data); @@ -78,8 +81,8 @@ struct mesh_model_pub *mesh_model_pub_get(struct mesh_node *node, uint32_t id, int *status); int mesh_model_pub_set(struct mesh_node *node, uint16_t ele_addr, uint32_t id, const uint8_t *addr, uint16_t idx, bool cred_flag, - uint8_t ttl, uint8_t period, uint8_t retransmit, - bool is_virt, uint16_t *dst); + uint8_t ttl, uint8_t period, uint8_t rtx_cnt, + uint16_t rtx_interval, bool is_virt, uint16_t *dst); int mesh_model_binding_add(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint16_t idx); diff --git a/mesh/net.c b/mesh/net.c index 26440b02d..93307e70c 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -212,6 +212,8 @@ struct net_queue_data { struct oneshot_tx { struct mesh_net *net; + uint16_t interval; + uint8_t cnt; uint8_t size; uint8_t packet[30]; }; @@ -1399,7 +1401,8 @@ static void friend_ack_rxed(struct mesh_net *net, uint32_t iv_index, l_queue_foreach(net->friends, enqueue_friend_pkt, &frnd_ack); } -static bool send_seg(struct mesh_net *net, struct mesh_sar *msg, uint8_t seg); +static bool send_seg(struct mesh_net *net, uint8_t cnt, uint16_t interval, + struct mesh_sar *msg, uint8_t seg); static void send_frnd_ack(struct mesh_net *net, uint16_t src, uint16_t dst, uint32_t hdr, uint32_t flags) @@ -1593,7 +1596,7 @@ static void ack_received(struct mesh_net *net, bool timeout, l_debug("Resend Seg %d net:%p dst:%x app_idx:%3.3x", i, net, outgoing->remote, outgoing->app_idx); - send_seg(net, outgoing, i); + send_seg(net, net->tx_cnt, net->tx_interval, outgoing, i); } l_timeout_remove(outgoing->seg_timeout); @@ -2143,8 +2146,8 @@ static void send_msg_pkt_oneshot(void *user_data) tx->packet[0] = MESH_AD_TYPE_NETWORK; info.type = MESH_IO_TIMING_TYPE_GENERAL; - info.u.gen.interval = net->tx_interval; - info.u.gen.cnt = net->tx_cnt; + info.u.gen.interval = tx->interval; + info.u.gen.cnt = tx->cnt; info.u.gen.min_delay = DEFAULT_MIN_DELAY; /* No extra randomization when sending regular mesh messages */ info.u.gen.max_delay = DEFAULT_MIN_DELAY; @@ -2153,11 +2156,14 @@ static void send_msg_pkt_oneshot(void *user_data) l_free(tx); } -static void send_msg_pkt(struct mesh_net *net, uint8_t *packet, uint8_t size) +static void send_msg_pkt(struct mesh_net *net, uint8_t cnt, uint16_t interval, + uint8_t *packet, uint8_t size) { struct oneshot_tx *tx = l_new(struct oneshot_tx, 1); tx->net = net; + tx->interval = interval; + tx->cnt = cnt; tx->size = size; memcpy(tx->packet, packet, size); @@ -2872,7 +2878,8 @@ bool mesh_net_dst_unreg(struct mesh_net *net, uint16_t dst) return true; } -static bool send_seg(struct mesh_net *net, struct mesh_sar *msg, uint8_t segO) +static bool send_seg(struct mesh_net *net, uint8_t cnt, uint16_t interval, + struct mesh_sar *msg, uint8_t segO) { struct mesh_subnet *subnet; uint8_t seg_len; @@ -2927,7 +2934,7 @@ static bool send_seg(struct mesh_net *net, struct mesh_sar *msg, uint8_t segO) return false; } - send_msg_pkt(net, packet, packet_len + 1); + send_msg_pkt(net, cnt, interval, packet, packet_len + 1); msg->last_seg = segO; @@ -2967,7 +2974,8 @@ void mesh_net_send_seg(struct mesh_net *net, uint32_t net_key_id, return; } - send_msg_pkt(net, packet, packet_len + 1); + send_msg_pkt(net, net->tx_cnt, net->tx_interval, packet, + packet_len + 1); l_debug("TX: Friend Seg-%d %04x -> %04x : len %u) : TTL %d : SEQ %06x", segO, src, dst, packet_len, ttl, seq); @@ -2977,9 +2985,9 @@ void mesh_net_send_seg(struct mesh_net *net, uint32_t net_key_id, bool mesh_net_app_send(struct mesh_net *net, bool frnd_cred, uint16_t src, uint16_t dst, uint8_t key_aid, uint16_t net_idx, - uint8_t ttl, uint32_t seq, uint32_t iv_index, - bool segmented, bool szmic, - const void *msg, uint16_t msg_len) + uint8_t ttl, uint8_t cnt, uint16_t interval, + uint32_t seq, uint32_t iv_index, bool segmented, + bool szmic, const void *msg, uint16_t msg_len) { struct mesh_sar *payload = NULL; uint8_t seg, seg_max; @@ -3054,11 +3062,12 @@ bool mesh_net_app_send(struct mesh_net *net, bool frnd_cred, uint16_t src, for (i = 0; i < 4; i++) { for (seg = 0; seg <= seg_max && result; seg++) - result = send_seg(net, payload, seg); + result = send_seg(net, cnt, interval, payload, + seg); } } else { for (seg = 0; seg <= seg_max && result; seg++) - result = send_seg(net, payload, seg); + result = send_seg(net, cnt, interval, payload, seg); } /* Reliable: Cache; Unreliable: Flush*/ @@ -3108,7 +3117,7 @@ void mesh_net_ack_send(struct mesh_net *net, uint32_t key_id, uint32_t iv_index, return; } - send_msg_pkt(net, pkt, pkt_len + 1); + send_msg_pkt(net, net->tx_cnt, net->tx_interval, pkt, pkt_len + 1); l_debug("TX: Friend ACK %04x -> %04x : len %u : TTL %d : SEQ %06x", src, dst, pkt_len, ttl, seq); @@ -3182,8 +3191,9 @@ void mesh_net_transport_send(struct mesh_net *net, uint32_t key_id, return; } - if (dst != 0) - send_msg_pkt(net, pkt, pkt_len + 1); + if (!(IS_UNASSIGNED(dst))) + send_msg_pkt(net, net->tx_cnt, net->tx_interval, pkt, + pkt_len + 1); } int mesh_net_key_refresh_phase_set(struct mesh_net *net, uint16_t idx, diff --git a/mesh/net.h b/mesh/net.h index 91e07ef78..253185e42 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -300,9 +300,9 @@ void mesh_net_transport_send(struct mesh_net *net, uint32_t key_id, bool mesh_net_app_send(struct mesh_net *net, bool frnd_cred, uint16_t src, uint16_t dst, uint8_t key_id, uint16_t net_idx, - uint8_t ttl, uint32_t seq, uint32_t iv_index, - bool segmented, bool szmic, const void *msg, - uint16_t msg_len); + uint8_t ttl, uint8_t cnt, uint16_t interval, + uint32_t seq, uint32_t iv_index, bool segmented, + bool szmic, const void *msg, uint16_t msg_len); void mesh_net_ack_send(struct mesh_net *net, uint32_t key_id, uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t src, uint16_t dst, bool rly, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oEwPIvQNPl+HkwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 07:45:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2F+2IPQNPl8O5AEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 07:45:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 984F1A5C19; Thu, 20 Aug 2020 07:43:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726215AbgHTFnx convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 01:43:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:48348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbgHTFnx (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 01:43:53 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Thu, 20 Aug 2020 05:43:50 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yuyuyak@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-8GTe0OsLLk@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.62 / 15.00 / 200.00 X-Rspamd-Queue-Id: 984F1A5C19 X-Rspamd-UID: 261b29 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #138 from Mike Johnson (yuyuyak@gmail.com) --- Just compiled the 5.8.2 vanilla kernel in Gentoo, yep, v4 is there, no more patches! -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qKTeKVgTPl+HkwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 08:08:24 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id WH3QJ1gTPl870wEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 08:08:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EEC4D4213C; Thu, 20 Aug 2020 08:08:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727811AbgHTGHa (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 02:07:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727106AbgHTGH1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 02:07:27 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFB2BC061757; Wed, 19 Aug 2020 23:07:26 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id k13so435189plk.13; Wed, 19 Aug 2020 23:07:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TEwV+gAKUnRj1mZL3fDfuQy8JyNw5xNO138gnCj19os=; b=rtRjDmt5UUfqpo78XbWEZ0IEW77Ap958XcFh9IZO8Hib9H8QEMwK7C51gmFTGrZfCM CZHHmTNMZGdFyOsts960HDKghxtIW9DtASK5kkSFqmo6fCQq/w9uqgthLq9JtGhJ5wYL /vOu79veUaG9At6gwBacYEywMAZFFN5FT4ssaCys8bp2kfpuOkJ8ulLy1HLY3ythM9Nq SKqAvKtK6TxUqGdXKHyCk5PSx/jPiby4IO8AQDusBcqJvdb61eeeBT5X4Ds/LXIWtFL7 LuvYF5/yGBnQtzSrJsD7k3FT2z7u0YPd8WxI5cpOpYmdcZEEt+MoquiOY/sCNvEi0Dyi 4vzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TEwV+gAKUnRj1mZL3fDfuQy8JyNw5xNO138gnCj19os=; b=RJb8qS5RsTJkDIeRPHLeKljAocsSBusYo86/tqPVihTXj4j6PTGLTQfmlhLwG9+2f5 5x8aCFZb7DTw+qnzvMK3TI6ujJcB0wETvCmWUd/0y5xiFoSt+27R9mcBlGs8OsqSVp5U ba79JpMkq4H6OXksCvqA++Ooi3AMAMtDN3znVSimzP3x3Zuup0504Kne2DLdQBsRbJ3U puWcRLgnzEIv8037yhULPTtFQ04ldSLg47vszfOa5FXAdsz2QhutXKplUMQIaCvcAK0S LFEabS+7MR2R2lQV3SRDsY1ErW1FFVqXCRpZ2DXBj1upPfLqDIeqYD9JD2rcJHC0oq5p PXJA== X-Gm-Message-State: AOAM533z3LNKNOui/ghXuSArlWtN2k5B/j0socSvbdADMxRoiuu4/gWh 1pTrzS44nh+QiCAW7hVuY9o= X-Google-Smtp-Source: ABdhPJysPg7llFDXEbdNkggy0Zx6PGaskljQ8fbdAgXP/6VPUKIjhm441S5NYlkXYmxsHbjfymoimw== X-Received: by 2002:a17:902:b589:: with SMTP id a9mr1395800pls.98.1597903646343; Wed, 19 Aug 2020 23:07:26 -0700 (PDT) Received: from localhost ([2001:e42:102:1532:160:16:113:140]) by smtp.gmail.com with ESMTPSA id g1sm1250773pfr.97.2020.08.19.23.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 23:07:25 -0700 (PDT) From: Coiby Xu <coiby.xu@gmail.com> X-Google-Original-From: Coiby Xu <Coiby.Xu@gmail.com> Date: Thu, 20 Aug 2020 14:07:13 +0800 To: syzbot <syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com> Cc: abhishekpandit@chromium.org, davem@davemloft.net, gregkh@linuxfoundation.org, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, rafael@kernel.org, syzkaller-bugs@googlegroups.com, linux-kernel-mentees@lists.linuxfoundation.org Subject: Re: BUG: corrupted list in kobject_add_internal Message-ID: <20200820060713.smilfw3otuunnepe@Rk> References: <000000000000c57f2d05ac4c5b8e@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <000000000000c57f2d05ac4c5b8e@google.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: EEC4D4213C X-Rspamd-UID: 9357c4 On Fri, Aug 07, 2020 at 09:47:20AM -0700, syzbot wrote: >Hello, > >syzbot found the following issue on: > >HEAD commit: 5a30a789 Merge tag 'x86-urgent-2020-08-02' of git://git.ke.. >git tree: upstream >console output: https://syzkaller.appspot.com/x/log.txt?x=1660c858900000 >kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 >dashboard link: https://syzkaller.appspot.com/bug?extid=dd768a260f7358adbaf9 >compiler: gcc (GCC) 10.1.0-syz 20200507 >syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14b73afc900000 >C reproducer: https://syzkaller.appspot.com/x/repro.c?x=124893a4900000 > >The issue was bisected to: > >commit 4f40afc6c76451daff7d0dcfc8a3d113ccf65bfc >Author: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> >Date: Wed Mar 11 15:54:01 2020 +0000 > > Bluetooth: Handle BR/EDR devices during suspend > >bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11cb1e0a900000 >final oops: https://syzkaller.appspot.com/x/report.txt?x=13cb1e0a900000 >console output: https://syzkaller.appspot.com/x/log.txt?x=15cb1e0a900000 > >IMPORTANT: if you fix the issue, please add the following tag to the commit: >Reported-by: syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com >Fixes: 4f40afc6c764 ("Bluetooth: Handle BR/EDR devices during suspend") > >debugfs: Directory '200' with parent 'hci0' already present! >list_add double add: new=ffff88808e9b6418, prev=ffff88808e9b6418, next=ffff8880a973ef00. >------------[ cut here ]------------ >kernel BUG at lib/list_debug.c:29! >invalid opcode: 0000 [#1] PREEMPT SMP KASAN >CPU: 1 PID: 6882 Comm: kworker/u5:1 Not tainted 5.8.0-rc7-syzkaller #0 >Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 >Workqueue: hci0 hci_rx_work >RIP: 0010:__list_add_valid.cold+0x26/0x3c lib/list_debug.c:29 >Code: 57 ff ff ff 4c 89 e1 48 c7 c7 20 92 93 88 e8 b1 f1 c1 fd 0f 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 60 93 93 88 e8 9a f1 c1 fd <0f> 0b 48 89 f1 48 c7 c7 e0 92 93 88 4c 89 e6 e8 86 f1 c1 fd 0f 0b >RSP: 0018:ffffc90001777830 EFLAGS: 00010282 >RAX: 0000000000000058 RBX: ffff8880a973ef00 RCX: 0000000000000000 >RDX: ffff888094f1c200 RSI: ffffffff815d4ef7 RDI: fffff520002eeef8 >RBP: ffff88808e9b6418 R08: 0000000000000058 R09: ffff8880ae7318e7 >R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a973ef00 >R13: ffff888087315270 R14: ffff88808e9b6430 R15: ffff88808e9b6418 >FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 >CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 >CR2: 00007ffdcd6db747 CR3: 000000009ba09000 CR4: 00000000001406e0 >DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 >DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 >Call Trace: > __list_add include/linux/list.h:67 [inline] > list_add_tail include/linux/list.h:100 [inline] > kobj_kset_join lib/kobject.c:196 [inline] > kobject_add_internal+0x18d/0x940 lib/kobject.c:246 > kobject_add_varg lib/kobject.c:390 [inline] > kobject_add+0x150/0x1c0 lib/kobject.c:442 > device_add+0x35a/0x1be0 drivers/base/core.c:2633 > hci_conn_add_sysfs+0x84/0xe0 net/bluetooth/hci_sysfs.c:53 > hci_conn_complete_evt net/bluetooth/hci_event.c:2607 [inline] > hci_event_packet+0xe0b/0x86f5 net/bluetooth/hci_event.c:6033 > hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 > process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 > worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 > kthread+0x3b5/0x4a0 kernel/kthread.c:291 > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 >Modules linked in: >---[ end trace b1bcc552c32d25e9 ]--- >RIP: 0010:__list_add_valid.cold+0x26/0x3c lib/list_debug.c:29 >Code: 57 ff ff ff 4c 89 e1 48 c7 c7 20 92 93 88 e8 b1 f1 c1 fd 0f 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 60 93 93 88 e8 9a f1 c1 fd <0f> 0b 48 89 f1 48 c7 c7 e0 92 93 88 4c 89 e6 e8 86 f1 c1 fd 0f 0b >RSP: 0018:ffffc90001777830 EFLAGS: 00010282 >RAX: 0000000000000058 RBX: ffff8880a973ef00 RCX: 0000000000000000 >RDX: ffff888094f1c200 RSI: ffffffff815d4ef7 RDI: fffff520002eeef8 >RBP: ffff88808e9b6418 R08: 0000000000000058 R09: ffff8880ae7318e7 >R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a973ef00 >R13: ffff888087315270 R14: ffff88808e9b6430 R15: ffff88808e9b6418 >FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 >CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 >CR2: 00007ffdcd6db747 CR3: 0000000009a79000 CR4: 00000000001406e0 >DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 >DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > > >--- >This report is generated by a bot. It may contain errors. >See https://goo.gl/tpsmEJ for more information about syzbot. >syzbot engineers can be reached at syzkaller@googlegroups.com. > >syzbot will keep track of this issue. See: >https://goo.gl/tpsmEJ#status for how to communicate with syzbot. >For information about bisection process see: https://goo.gl/tpsmEJ#bisection >syzbot can test patches for this issue, for details see: >https://goo.gl/tpsmEJ#testing-patches > >-- >You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group. >To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com. >To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/000000000000c57f2d05ac4c5b8e%40google.com. This problem occurs because the HCI_EV_CONN_COMPLETE event packet is sent twice for the same HCI connection, struct hci_ev_conn_complete complete; memset(&complete, 0, sizeof(complete)); complete.status = 0; complete.handle = HCI_HANDLE_1; memset(&complete.bdaddr, 0xaa, 6); *(uint8_t*)&complete.bdaddr.b[5] = 0x10; complete.link_type = ACL_LINK; complete.encr_mode = 0; hci_send_event_packet(vhci_fd, HCI_EV_CONN_COMPLETE, &complete, sizeof(complete)); which leads to kobject_add being called twice. Thus duplicate (struct hci_conn *conn)->dev.kobj.entry is inserted into (struct hci_conn *conn)->dev.kobj.kset->list. But if it's the HCI connection creator's responsibility to not send the HCI_EV_CONN_COMPLETE event packet twice, then it's not a valid bug. Or should we make the kernel more robust by defending against this case? -- Best regards, Coiby Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8Cv0F7AUPl//vgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 08:14:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WHmQFrAUPl+YRQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 08:14:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8C3E0420E6; Thu, 20 Aug 2020 08:14:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725820AbgHTGOB (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 02:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgHTGOB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 02:14:01 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91BEDC061757 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 23:14:00 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id y11so477221qvl.4 for <linux-bluetooth@vger.kernel.org>; Wed, 19 Aug 2020 23:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jfZ8AEDo5b6yM2W8sFrMWFRKou8veGh90s+SGjERmgE=; b=Pg0Vt16UN94wMHwX8Jg15yh0TnJwz1aiilNhssiuaeTm0HKGqIGsaYga/FvxwXWYV+ 8QhbzNpU5JawQJp6GPpBksX3QCgXdnfiSu3RsPgTPeK+OIyedumsfAZ7n8J10ZbcVITz 0fCka7CdNIGbKT9ccOCr/QyhLNH2no0Z2WGRgq6KD4H12y+8/k7gXzacrN+S//8eGX6I fBcsrhgtA9b7/lfo1XwLXfS4e2kIsVtIZfm54JTL7pHTmakJAWHvclNGelzXqd03orKN Xnx/Qpru1ozi49919sz5XYbSRT2VeTiHQuW+CB86FFkt95k0c3Ha145MbV8DpLHNgkIu 86DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jfZ8AEDo5b6yM2W8sFrMWFRKou8veGh90s+SGjERmgE=; b=Lw1YikJvbr5ppSqyl5TYwWzAJB+Z4jPAaVlyjcm0ulvILD+6tpNjQWJaGfmfXk0bax nwotDhW8zNMyN0k/WzIeqr27ekDljBphqNFllOPLNDyhFL5g89RdAG3eWsJGw6gQRPnO N11A8e+LZ61RvDvF/jMH9ZmdMpTZccvE9N+9bCUcJ+z3nC1CUxlqhsEeeFlU6LkzEafv oGnUSjqHm08AyF0PbvaeG4lctBzYDn2/83UYLzmfWqRnIIAJJjUITUc8I/tQH6iUoIn7 Ifw60UcxcODZVNS4uY0iidgg3FarFkH05ziapFJMnxpukE+wo+NhX4E7rHo1R8mw5MiK HR+w== X-Gm-Message-State: AOAM531I/a6mxa8gQr3mm9S8rwifrWNlmyB51p653TKAhuoVxU53jHaV NimJVRsPsfy89OD2hwp4xL9y+o/NHpGPMQz1smHjKQ== X-Google-Smtp-Source: ABdhPJyQv4MwYbNOvB6guMd+CnDeGOCpwWpHMxEZy35VcLiAqzoitjW5LQgbN7vgNzxeLiQLr2WNkPgz37YJ+e+H17g= X-Received: by 2002:a0c:8d4a:: with SMTP id s10mr1745746qvb.34.1597904039193; Wed, 19 Aug 2020 23:13:59 -0700 (PDT) MIME-Version: 1.0 References: <000000000000c57f2d05ac4c5b8e@google.com> <20200820060713.smilfw3otuunnepe@Rk> In-Reply-To: <20200820060713.smilfw3otuunnepe@Rk> From: Dmitry Vyukov <dvyukov@google.com> Date: Thu, 20 Aug 2020 08:13:47 +0200 Message-ID: <CACT4Y+ZcU11Y0OrxsdKcwqAmJ2BmnP9pCYB1gtiBgciM0+H=cA@mail.gmail.com> Subject: Re: BUG: corrupted list in kobject_add_internal To: Coiby Xu <coiby.xu@gmail.com> Cc: syzbot <syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com>, abhishekpandit@chromium.org, David Miller <davem@davemloft.net>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Johan Hedberg <johan.hedberg@gmail.com>, Jakub Kicinski <kuba@kernel.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, netdev <netdev@vger.kernel.org>, Rafael Wysocki <rafael@kernel.org>, syzkaller-bugs <syzkaller-bugs@googlegroups.com>, linux-kernel-mentees@lists.linuxfoundation.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.02 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8C3E0420E6 X-Rspamd-UID: 5b2bb9 On Thu, Aug 20, 2020 at 8:07 AM Coiby Xu <coiby.xu@gmail.com> wrote: > > On Fri, Aug 07, 2020 at 09:47:20AM -0700, syzbot wrote: > >Hello, > > > >syzbot found the following issue on: > > > >HEAD commit: 5a30a789 Merge tag 'x86-urgent-2020-08-02' of git://git.ke.. > >git tree: upstream > >console output: https://syzkaller.appspot.com/x/log.txt?x=1660c858900000 > >kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 > >dashboard link: https://syzkaller.appspot.com/bug?extid=dd768a260f7358adbaf9 > >compiler: gcc (GCC) 10.1.0-syz 20200507 > >syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14b73afc900000 > >C reproducer: https://syzkaller.appspot.com/x/repro.c?x=124893a4900000 > > > >The issue was bisected to: > > > >commit 4f40afc6c76451daff7d0dcfc8a3d113ccf65bfc > >Author: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > >Date: Wed Mar 11 15:54:01 2020 +0000 > > > > Bluetooth: Handle BR/EDR devices during suspend > > > >bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11cb1e0a900000 > >final oops: https://syzkaller.appspot.com/x/report.txt?x=13cb1e0a900000 > >console output: https://syzkaller.appspot.com/x/log.txt?x=15cb1e0a900000 > > > >IMPORTANT: if you fix the issue, please add the following tag to the commit: > >Reported-by: syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com > >Fixes: 4f40afc6c764 ("Bluetooth: Handle BR/EDR devices during suspend") > > > >debugfs: Directory '200' with parent 'hci0' already present! > >list_add double add: new=ffff88808e9b6418, prev=ffff88808e9b6418, next=ffff8880a973ef00. > >------------[ cut here ]------------ > >kernel BUG at lib/list_debug.c:29! > >invalid opcode: 0000 [#1] PREEMPT SMP KASAN > >CPU: 1 PID: 6882 Comm: kworker/u5:1 Not tainted 5.8.0-rc7-syzkaller #0 > >Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 > >Workqueue: hci0 hci_rx_work > >RIP: 0010:__list_add_valid.cold+0x26/0x3c lib/list_debug.c:29 > >Code: 57 ff ff ff 4c 89 e1 48 c7 c7 20 92 93 88 e8 b1 f1 c1 fd 0f 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 60 93 93 88 e8 9a f1 c1 fd <0f> 0b 48 89 f1 48 c7 c7 e0 92 93 88 4c 89 e6 e8 86 f1 c1 fd 0f 0b > >RSP: 0018:ffffc90001777830 EFLAGS: 00010282 > >RAX: 0000000000000058 RBX: ffff8880a973ef00 RCX: 0000000000000000 > >RDX: ffff888094f1c200 RSI: ffffffff815d4ef7 RDI: fffff520002eeef8 > >RBP: ffff88808e9b6418 R08: 0000000000000058 R09: ffff8880ae7318e7 > >R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a973ef00 > >R13: ffff888087315270 R14: ffff88808e9b6430 R15: ffff88808e9b6418 > >FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 > >CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > >CR2: 00007ffdcd6db747 CR3: 000000009ba09000 CR4: 00000000001406e0 > >DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > >DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > >Call Trace: > > __list_add include/linux/list.h:67 [inline] > > list_add_tail include/linux/list.h:100 [inline] > > kobj_kset_join lib/kobject.c:196 [inline] > > kobject_add_internal+0x18d/0x940 lib/kobject.c:246 > > kobject_add_varg lib/kobject.c:390 [inline] > > kobject_add+0x150/0x1c0 lib/kobject.c:442 > > device_add+0x35a/0x1be0 drivers/base/core.c:2633 > > hci_conn_add_sysfs+0x84/0xe0 net/bluetooth/hci_sysfs.c:53 > > hci_conn_complete_evt net/bluetooth/hci_event.c:2607 [inline] > > hci_event_packet+0xe0b/0x86f5 net/bluetooth/hci_event.c:6033 > > hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 > > process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 > > worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 > > kthread+0x3b5/0x4a0 kernel/kthread.c:291 > > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 > >Modules linked in: > >---[ end trace b1bcc552c32d25e9 ]--- > >RIP: 0010:__list_add_valid.cold+0x26/0x3c lib/list_debug.c:29 > >Code: 57 ff ff ff 4c 89 e1 48 c7 c7 20 92 93 88 e8 b1 f1 c1 fd 0f 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 60 93 93 88 e8 9a f1 c1 fd <0f> 0b 48 89 f1 48 c7 c7 e0 92 93 88 4c 89 e6 e8 86 f1 c1 fd 0f 0b > >RSP: 0018:ffffc90001777830 EFLAGS: 00010282 > >RAX: 0000000000000058 RBX: ffff8880a973ef00 RCX: 0000000000000000 > >RDX: ffff888094f1c200 RSI: ffffffff815d4ef7 RDI: fffff520002eeef8 > >RBP: ffff88808e9b6418 R08: 0000000000000058 R09: ffff8880ae7318e7 > >R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a973ef00 > >R13: ffff888087315270 R14: ffff88808e9b6430 R15: ffff88808e9b6418 > >FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 > >CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > >CR2: 00007ffdcd6db747 CR3: 0000000009a79000 CR4: 00000000001406e0 > >DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > >DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > > > > > >--- > >This report is generated by a bot. It may contain errors. > >See https://goo.gl/tpsmEJ for more information about syzbot. > >syzbot engineers can be reached at syzkaller@googlegroups.com. > > > >syzbot will keep track of this issue. See: > >https://goo.gl/tpsmEJ#status for how to communicate with syzbot. > >For information about bisection process see: https://goo.gl/tpsmEJ#bisection > >syzbot can test patches for this issue, for details see: > >https://goo.gl/tpsmEJ#testing-patches > > > >-- > >You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group. > >To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com. > >To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/000000000000c57f2d05ac4c5b8e%40google.com. > > This problem occurs because the HCI_EV_CONN_COMPLETE event packet is sent > twice for the same HCI connection, > > struct hci_ev_conn_complete complete; > memset(&complete, 0, sizeof(complete)); > complete.status = 0; > complete.handle = HCI_HANDLE_1; > memset(&complete.bdaddr, 0xaa, 6); > *(uint8_t*)&complete.bdaddr.b[5] = 0x10; > complete.link_type = ACL_LINK; > complete.encr_mode = 0; > hci_send_event_packet(vhci_fd, HCI_EV_CONN_COMPLETE, &complete, > sizeof(complete)); > > which leads to kobject_add being called twice. Thus duplicate > (struct hci_conn *conn)->dev.kobj.entry is inserted into > (struct hci_conn *conn)->dev.kobj.kset->list. > > But if it's the HCI connection creator's responsibility to > not send the HCI_EV_CONN_COMPLETE event packet twice, then it's not a > valid bug. Or should we make the kernel more robust by defending against > this case? Hi Coiby, Whoever is sending HCI_EV_CONN_COMPLETE, this should not corrupt kernel memory. Even if it's firmware, it's not necessary trusted, see: https://www.blackhat.com/us-20/briefings/schedule/index.html#finding-new-bluetooth-low-energy-exploits-via-reverse-engineering-multiple-vendors-firmwares-19655 and: https://www.armis.com/bleedingbit/ So if an attacker takes over firmware, they can then corrupt kernel memory. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6JLYGsRaPl+argEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 13:13:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wEmRGcRaPl+ahwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 13:13:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=omicronenergy.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6353540676; Thu, 20 Aug 2020 13:13:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729922AbgHTKhl (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 06:37:41 -0400 Received: from ns.omicron.at ([212.183.10.25]:36502 "EHLO ns.omicron.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729445AbgHTKSR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 06:18:17 -0400 X-Greylist: delayed 472 seconds by postgrey-1.27 at vger.kernel.org; Thu, 20 Aug 2020 06:18:16 EDT Received: from MGW02-ATKLA.omicron.at ([172.25.62.35]) by ns.omicron.at (8.15.2/8.15.2) with ESMTPS id 07KAACRU007799 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 12:10:13 +0200 DKIM-Filter: OpenDKIM Filter v2.11.0 ns.omicron.at 07KAACRU007799 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omicronenergy.com; s=default; t=1597918213; bh=tHGzBdpZIrFsEwZDPMin6z/+uonkVMtBxKwEtWOjXkA=; h=Subject:From:To:CC:Date:In-Reply-To:References:From; b=g09GrDyiBS92zyF/HnCIQPYM4yuD7mZXKALGlqdNKKIl91ejo3g0TM/k6gxtYo/nG AtB3yBEY1hWvfHatINAaZQayjVV24orCbPnqwIHR1dppYnbaILev1LXhwgFHzjZc+j zsASQSgfFmcK1H5fcs1B1uirG2LovgmhbjSTvtxw= Received: from MGW02-ATKLA.omicron.at (localhost [127.0.0.1]) by MGW02-ATKLA.omicron.at (Postfix) with ESMTP id A0659A006D for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 12:10:11 +0200 (CEST) Received: from MGW01-ATKLA.omicron.at (unknown [172.25.62.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by MGW02-ATKLA.omicron.at (Postfix) with ESMTPS id 9E2FFA0062 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 12:10:11 +0200 (CEST) Received: from EXC04-ATKLA.omicron.at ([172.22.100.189]) by MGW01-ATKLA.omicron.at with ESMTP id 07KAAC8d030797-07KAAC8f030797 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=CAFAIL); Thu, 20 Aug 2020 12:10:12 +0200 Received: from marmar13.omicron.at (172.22.32.104) by EXC04-ATKLA.omicron.at (172.22.100.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 20 Aug 2020 12:10:11 +0200 Message-ID: <3e98e7dae29ec7be6d67fca6af99f2e0f747375e.camel@omicronenergy.com> Subject: Re: [PATCH BlueZ 2/2] src/profile.c: Add a GetProfileInfo method From: Mark Marshall <mark.marshall@omicronenergy.com> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> CC: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Date: Thu, 20 Aug 2020 12:10:02 +0200 In-Reply-To: <CABBYNZ+OK4EY9KGHn7oasz4GRfBDJdWNcpOhr1GNGc3D+QtZ-g@mail.gmail.com> References: <20200819150931.3005-1-mark.marshall@omicronenergy.com> <2303f692-bb7c-4851-86fa-befde45b4b32@EXC04-ATKLA.omicron.at> <CABBYNZ+OK4EY9KGHn7oasz4GRfBDJdWNcpOhr1GNGc3D+QtZ-g@mail.gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-IP: [172.22.32.104] X-ClientProxiedBy: EXC03-ATKLA.omicron.at (172.22.100.188) To EXC04-ATKLA.omicron.at (172.22.100.189) X-FE-Policy-ID: 1:1:1:SYSTEM Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.28 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6353540676 X-Rspamd-UID: 0a9b1a On Wed, 2020-08-19 at 11:37 -0700, Luiz Augusto von Dentz wrote: > Hi Mark, > > On Wed, Aug 19, 2020 at 8:13 AM Mark Marshall > <mark.marshall@omicronenergy.com> wrote: > > > > Add a GetProfileInfo method to org.bluez.ProfileManager1 > > --- > > doc/profile-api.txt | 13 +++++++ > > src/profile.c | 93 +++++++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 106 insertions(+) > > > > diff --git a/doc/profile-api.txt b/doc/profile-api.txt > > index 8c7d0a06d..d13703ab4 100644 > > --- a/doc/profile-api.txt > > +++ b/doc/profile-api.txt > > @@ -133,6 +133,19 @@ Object path /org/bluez > > > > Possible errors: org.bluez.Error.DoesNotExist > > > > + options GetProfileInfo(object profile, object adapter) > > + > > + This returns a dictionary of options for the > > + profile. Values returned are: UUID, Name, > > + Path, Service, Mode and AddressType. The > > + adapter parameter is optional - if it is > > + non-empty, then two additional values might be > > + returned, if the profile is active on the > > + specified adapter: PSM and Channel. > > + > > + Possible errors: org.bluez.Error.InvalidArguments > > + org.bluez.Error.DoesNotExist > > + > > If this is really required I would be willing to merge something like this: > > https://github.com/Vudentz/BlueZ/commit/9e196f8830511a4102e990d82d06c2e0487b3ad9 > > It exposes service objects so you can control exactly what gets > connect, though now given a second look at this seem to return details > that the client can query directly on the socket itself like the > Channel, PSM, Mode, etc, also not sure what is the point on retrieving > things like UUID, Name, Path if the application is already in control > of these when registering. > I only returned a full dictionary of items here as I was trying to match RegisterProfile, I don't actually need all of this info. (I also thought that the more verbose structure was more useful, but it is wasteful). The information that I really need is the PSM (or Channel) number. This information is needed on the server side, and the socket used is not exposed to anything outside of bluetoothd, as far as I can tell. (This is the socket returned from bt_io_listen, in profile.c). I have my profile auto-select a free PSM, which I thought was the preferred method. In the BR/EDR case, this number gets passed to the peer (I assume through SDP), but in the LE case, where I want to use LE-L2CAP, there is no defined mechanism to transfer the PSM. My plan was to expose it as a GATT attribute, but this mechanism is not standardised, so I didn't think BlueZ would want to be involved? Would a simpler interface that just returned the PSM or Channel number be better? Is there another way to find out the PSM of a listening socket, on the server, before a connection is made? (From my reading of the above patch, the service object is created as a link between a "profile" and a "device". In my case, I think there is no service object yet, as I have no device connection?) > > Profile hierarchy > > ================= > > diff --git a/src/profile.c b/src/profile.c > > index 10850f305..e287a66d7 100644 > > --- a/src/profile.c > > +++ b/src/profile.c > > @@ -2509,6 +2509,96 @@ static DBusMessage *unregister_profile(DBusConnection *conn, > > return dbus_message_new_method_return(msg); > > } > > > > +static DBusMessage *get_profile_info(DBusConnection *conn, > > + DBusMessage *msg, void *user_data) > > +{ > > + DBusMessage *reply; > > + DBusMessageIter iter, dict; > > + const char *path, *adapter, *sender; > > + struct ext_profile *ext; > > + uint16_t u16; > > + GSList *l, *next; > > + > > + sender = dbus_message_get_sender(msg); > > + > > + DBG("sender %s", sender); > > + > > + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, > > + DBUS_TYPE_OBJECT_PATH, &adapter, > > + DBUS_TYPE_INVALID)) { > > + return btd_error_invalid_args(msg); > > + } > > + > > + if (adapter && !*adapter) > > + adapter = NULL; > > + > > + ext = find_ext_profile(sender, path); > > + if (!ext) > > + return btd_error_does_not_exist(msg); > > + > > + reply = dbus_message_new_method_return(msg); > > + > > + dbus_message_iter_init_append(reply, &iter); > > + > > + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, > > + "{sv}", &dict); > > + > > + g_dbus_dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, > > + &ext->uuid); > > + if (ext->name) { > > + g_dbus_dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, > > + &ext->name); > > + } > > + if (ext->path) { > > + g_dbus_dict_append_entry(&dict, "Path", DBUS_TYPE_STRING, > > + &ext->path); > > + } > > + if (ext->service) { > > + g_dbus_dict_append_entry(&dict, "Service", DBUS_TYPE_STRING, > > + &ext->service); > > + } > > + > > + u16 = ext->mode; > > + g_dbus_dict_append_entry(&dict, "Mode", DBUS_TYPE_UINT16, > > + &u16); > > + > > + u16 = ext->addr_type; > > + g_dbus_dict_append_entry(&dict, "AddressType", DBUS_TYPE_UINT16, > > + &u16); > > + > > + if (adapter) { > > + for (l = ext->servers; l != NULL; l = next) { > > + struct ext_io *server = l->data; > > + const char *ctype; > > + > > + DBG("server:%p %d %d psm:%d chan:%d", > > + server, server->resolving, server->connected, > > + server->psm, server->chan); > > + > > + next = g_slist_next(l); > > + > > + if (strcmp(adapter, adapter_get_path(server->adapter))) > > + continue; > > + > > + if (server->proto == BTPROTO_L2CAP) { > > + ctype = "PSM"; > > + u16 = server->psm; > > + } else if (server->proto == BTPROTO_RFCOMM) { > > + ctype = "Channel"; > > + u16 = server->chan; > > + } else { > > + continue; > > + } > > + g_dbus_dict_append_entry( > > + &dict, ctype, DBUS_TYPE_UINT16, &u16); > > + } > > + } > > + > > + dbus_message_iter_close_container(&iter, &dict); > > + > > + return reply; > > +} > > + > > static const GDBusMethodTable methods[] = { > > { GDBUS_METHOD("RegisterProfile", > > GDBUS_ARGS({ "profile", "o"}, { "UUID", "s" }, > > @@ -2516,6 +2606,9 @@ static const GDBusMethodTable methods[] = { > > NULL, register_profile) }, > > { GDBUS_METHOD("UnregisterProfile", GDBUS_ARGS({ "profile", "o" }), > > NULL, unregister_profile) }, > > + { GDBUS_METHOD("GetProfileInfo", > > + GDBUS_ARGS({ "profile", "o" }, { "adapter", "o" }), > > + GDBUS_ARGS({ "options", "a{sv}" }), get_profile_info) }, > > { } > > }; > > > > -- > > 2.17.1 > > > > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +AOdGyhnPl+o7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 14:06:00 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8CvuGChnPl/pfAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 14:06:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D233142124; Thu, 20 Aug 2020 14:05:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729880AbgHTLjQ convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 07:39:16 -0400 Received: from s01.spamexperts.axc.nl ([185.182.56.9]:44457 "EHLO s01.spamexperts.axc.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729248AbgHTLis (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 07:38:48 -0400 Received: from vserver85.axc.nl ([185.182.56.185]) by s01.spamexperts.axc.nl with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from <dave@daveborghuis.nl>) id 1k8iu0-000184-Ov; Thu, 20 Aug 2020 13:38:44 +0200 Received: from mail.axc.nl ([185.182.56.42]) by vserver85.axc.nl with esmtp (Exim 4.94) (envelope-from <dave@daveborghuis.nl>) id 1k8itz-00Dzqn-4h; Thu, 20 Aug 2020 13:38:39 +0200 Subject: Re: Cant see Android Covid Exposure notification beacon (no problem with iPhone beacons) To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> References: <b39b3395-ad80-bf76-caea-490666cea671@daveborghuis.nl> <CABBYNZJysyOYZPWVd1Cpq7C055G2Pwdu+x_9WaFfZUzDb-4_YQ@mail.gmail.com> From: Dave Borghuis <dave@daveborghuis.nl> Autocrypt: addr=dave@daveborghuis.nl; prefer-encrypt=mutual; keydata= mQINBFI9hacBEADBe9EcShlbkN2x/o3x/5S1u+m6kCJC+kNmzMHecJWzbwxsGLfUzApqImPF WGjy7yGVDp9Rl80Sz2gSijZjFkN17PSILsiHM3LvwfyBS/IMLPG0E+dB9ejrATuXrEdeXl8q QG6ZBE2ZaBgEMLhu7lAIS/E50jSij1yzSSlzcjd1m0d3kGaseiHWO0PM8sggwclI9XYOGxJK vmWAz9ayhMZNhdvkfAxsdh3hQYC7RkaBH9kjh9l5qt5t1xRcABkX3pa9ct4rzwlEswOCjURe rhaj6IHwroTNaRW1djxml4vTgyM8b7NmNmfRvwMaImUgQweb9k0wRfPEgSWthNml7aNPCRqj rF3sLiBl5xxJsm8Y9ROdiyeTyl+3iAdtQ91hAWfgK2ZFQvHNPPlelfRupXgupY6h9UJzdEkn A1F8Yx3xyizkKLbsbDt/uB9XYiIH594WbCHt6S0k8bWuTdqlYiLhKe32ij53tZy+J92tqMti HWhM3qv9CR6qLop9rIk3G6ZUDahb1NrYPT8ahh+gcjif+LFhFooLZiNxqAzguuAgrExU/NIi WuG+2So2pO04y0DcMQ1+BT+fs6tqQXdvVU23QwDY+cS+WNqh4nPg7ZYm63vPb2rlirJ/Mhq3 Xjk74WqTmKzUnWLlu5OQDp91t8Lf86hNCb/FV66dnSGyoG8xEwARAQABtCREYXZlIEJvcmdo dWlzIDxkYXZlQGRhdmVib3JnaHVpcy5ubD6JAjsEEwECACUCGy8GCwkIBwMCBhUIAgkKCwQW AgMBAh4BAheABQJSvzddAhkBAAoJEIa6Ru419rKq+9kQAIHcW/vakREY0/OLx4tTMO2WPwX+ e1pare/zdJwejcS6LksxFZ/8dwj0kk/s1ME3Zztg2vDkpQjQISFrtuNmOYekY6geRUjKgr3U BdPq+sYoge4kBIlAQnDMaVY48QtnLXZQBsXBhfRIQNj+TWuUVbHYwyLGGw9pRaJHsDJBc1cd qvCUyCOyXb0tWZCfv83jMMv/9gEJngkPC0JuIWPl0rfJ9QPTlArJw9vbMTYaUmm9vskjP1I/ qZSR7kpLrTtCcPtvWDtm2v+akrZnV9aKUY4XFkutZErJmSkk2Hp9Sz/hhAzzgfYlI3tg1Ljt EmMI5XDViPAoqLljtUKr0aIbqW2wOb8zgpx2MrO0JKqpNgEQfvGAVyXsH0PTOcshS5ri/8oC b84eHMwPqKuK9YD0990UQKNw7hN2yyqqYb22wty0PWYglfpJKUQdYMbQi3KCxGzn7Nu/E/Pk 1QTbCOVokei8wTZLGmg6L5RFF6xHLZ56mtmXSY+Oy5r8PGICdVE/nnJXN3Mg0jGliTovDz97 Wng4/Zq50chtx9fA3P00IoYuoDwvAJza3ggntTlXGN9pwGVZET+k6LkJaJ0bpHj/t+8LCcpF HJa2/wsz8cYAGlNvKpl5jjwtNLndJApG35GFB9CT2EFjNFEtOKlDCgiv9lgZOB1Gl6NfGOAI UeuO/I47uQINBFI9hacBEAD1U4TDKLPSjYGd2Ot/FkU/24VwDQ2zTCUtR4hzUTjj4zjwCL5I GCEek0LcQToDONF2t0h6pm7HKb9NOicXYsiekUY3mYkH5C/VSCxoqdYi4lhexOZH34RO+5Ln jqtF0TpdFXTFpVQ3O3eHhAYmGMt7BjEaesOAzIR9D2+bhvgIyh/APebCS4gVfQpthCjTYDvd ol8igOnMg9O/gY932gSSe7BL+BVJCMIokUu4dOe+k1EhIrC4h7gZYFpKaanE8rmg1hLni0cy kSh1joJVv/czkklzmyMGeUZrkTkxu/d3J/IgafrndW/kQ/XSJ4N5ghEegjjWlN821i+1NXRa NGxxNxo6CA+Rl12+78uGQcwL68wmyFlrrXmgr9DW70XDIEFkiAfUhkQPAq5VT6HDDjh6djco e3FbbYncJn41e4y4E/BLIC+rGimOXlbHJAIh1QFdSyoNiZD0IUr1BK+nIUTCRPAkF8GKrGN/ UthF345iFhDsKV4Oe3y5cZcOloyWbTzVnHfnD+iH65a75G34zdiUVV2g8RihiYvdC78EgkKM UIzCsvFPJHy6SGETX1d5o4lf7D71DlSr2OsaqGAnPtIMbjQPaXBhT5zenEGeoLOMs2lF/SAr fz7+5gcYiIkyR46AFlmb/COkDS4AaVZzvDBmOn0R5/hwMdD+Fw+TWoP5GQARAQABiQQ+BBgB AgAJBQJSPYWnAhsuAikJEIa6Ru419rKqwV0gBBkBAgAGBQJSPYWnAAoJEMK3KLEisodrljYP /23fop22dU9WxUksPxTQYIlsOIWSjw5RLqontCN4JeZYkDVPiDVe+PB3ZMNOhgMyY9XSy1Vm QyoM27Td+XisJ5nKcYlCZxDkxi+xyE+rz2SfpW76Qw54di3EeAEx/Qb/Al94BJ1poR6HU+fN saMZtpvY1VM/9m3N71JPLf5E50jABPARuvsRGA5eDAhxrbm+yIM5msqZgEYyxY0fLrt4qV1S wDUAMDhbOlX3U7CrnlTD4VaHZYwkv2eSZ/JcINgMaEbhKMZeYYM91/7PyS+QXHfjNngxKyTN 6yFXDOjsTycRRqWO7nnnHYNrzZZ3xSRXsUiHyWIORl6mYzKIcptb3MvRqw1h0+wz86ujCr8p sP0MRAq/iIEGdciPTqUHQKJgOO5FLCcV4oxlP/wESFXFbXlgzv40SvhZPDjPeLauLssKGVbk i/5CduYuKCb6Wwc2htKJXPMNE/H4W+Bdwz1hXiwVzyUlmv6PV78ArSLvKRB5h5Ogo1vsnar2 6JcBcxwJ//7fd2N3hMUf/tfotCPzjs6nsJINI8LZxJHLNWOs+zztwD1iEN3BiSUSsyHvluIj agg9blWzvpcRvj9KW4X7gwZwyAzfkGMjXIbl9p+97s+Gs9wNI/+Bxc5mrWIc3hY/O53sPlaB tWW6fXK/uXj59gGq+ZE8+dYARKVD4YI+4o0KlIsP/3MLFL4Axn3OEsCh21p1++P5ejpGqHPh x+ioPXqqxahWJVPKmLjhgmHmuh5cQFYePvC8Ou5AUL+4ooU3SVwOKaeWfyU0Gy6/00ZOVWD6 IEiQnKntzXdAmR8uFH+2s5UlYIM3S374Ly3vitM/arrkeRlzW9XDnslfkvjdsi++OgZGZUJY sp6QQfGWTlwzZ4DShSQmJdX7mGE3fe2GZ6VhVCHPhhqAEHpxbw9kAvN/G2iRYmRDD3ux1IHZ E1u8ScC5wYh0RIoDp+Nq3sux2XmwHfvLvK5rhIg3jszHTQRRzieOqmvriAESxuq92y+oFhfb jEIPtCvBOD4txGYPLad1bQVEH/aMIhYWdpJQ701TqMRHEtbO0c9o64S/Y2j7xomBbIyZr0/R HGkWSaS1UL2q0v3xeo46WROGSXcX8p8NXEkgVqC5hV3v6gIj9kfjxg7KiUCZAeH3qqaBTGnc aLeZzcCUG39JtZPoWGTbXHBuR6vay6FZienaalSMBOQXfqJJvePMlFpqKoeRCPCJ4ZnSZXaJ awgMeKHMUnsHtCR5DNQmH/p+/20/2a7k2YAim6P25sMay8nVNcwwvAu5ktONmRB3JAeugnTr lb/vdLbu/mv1PTwgvzxK3x45dv0uAtlP++y4TKwxfRXwopt5/rFL2/x6OzAMCGU1Pj1+emQW 0G/D Message-ID: <db7877d0-0a9e-f855-bd18-89ce353e9499@daveborghuis.nl> Date: Thu, 20 Aug 2020 13:38:38 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <CABBYNZJysyOYZPWVd1Cpq7C055G2Pwdu+x_9WaFfZUzDb-4_YQ@mail.gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: nl PrimaryMX: Accepted email from trusted host. Hint: This skips spam scanning so make sure other host is not vulnerable X-Relay-Host: 185.182.56.42 SpamTally: Final spam score: -63 X-AuthUser: X-Originating-IP: 185.182.56.185 X-SpamExperts-Domain: vserver85.axc.nl X-SpamExperts-Username: 185.182.56.185 Authentication-Results: spamexperts.axc.nl; auth=pass smtp.auth=185.182.56.185@vserver85.axc.nl X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.16) X-Recommended-Action: accept X-Filter-ID: Mvzo4OR0dZXEDF/gcnlw0Uc1Z+hCSaILZIw3vLzlsGSpSDasLI4SayDByyq9LIhVy72u9v+dq/hO wcZEck9qmkTNWdUk1Ol2OGx3IfrIJKyP9eGNFz9TW9u+Jt8z2T3KbXsLA0HlioK7txFnPQvbtbLk 8R5mlgIwJEelNeTC3y0tOnqq+qab2kdwzh4p3GS5O5cjn8T7dzW71VxAlAoGW3D8zY6MLb0C+wr8 sSGhK4Naa40DxZPJuLUk3zkVKd8p4CuEXwMMCcu55/Z5CMTXnK0Y7LCaYwq5D2n+PKAHF2SHOoHk jMut1ww/VHX1ly+ajz2jsX3korpGxdnK+ek4CMztdQUSqk/AeLi65+4s/LrywTM2yEHEhvC9Izsy /NENTMQ3Kg3hL2oXz5A5E5R/dS4GkJ5hfB+qWugfDEytZYqsHHT1RBQQLep6oz6Esv5JPZ42IfQH uktp5FTyHYGk267On8qMjxGbEIr+mFEcSBgsZIsLqaY1UeS+5B0bzsw6rMNJRrRpQSU11Ur/Gkm4 amRc11xjO4+/snCCXc1RuVYFnr74N+RNWUFaxHlAaSW5eQX2hj4u3ZszoJwAxH6lxrR1IoyVcpAX xfUeXJw8PSKZyxi/aFboTUAaA09dklP/aIfVaCHpEB6cFH6WJxE4Zn+QHsYhW4W1sTO58EglJ5WC dveE7Y243Xbui/edkaGx5r2tx94jvSB0QQoIKsEAe1d/+NO4YR0A5YIZlsSkH5eOlWoOfH3PRLfk +7v5u57EGlTMCNh/GVYg/nv+z8zJJOeURvP7468+f+EGtWkSZL30hAicGM9TsPk6o5pKicqhH6gt CBe9JhEFklSFD9M9pPvNWU8BvYorU4xuHEB26rPImfuctUHJ3IWIjmuymvwK3R1W5CR9pPgnkojE nIFUcf8Fys7PofM8bqcKCam/1/U3ClTXlSfQV8rvfnHgqk4U9IQInBjPU7D5OqOaSonKoUnIqv6a nXFjYar+fT2UxK+2mhKsoikQ3v+3MBjtrLsOJk4KMrD/VUxugdxDLVa2jg40M5gm6TR9mEGRUtCa fc6PptSRQ17SSMcjhqOgGhuvxypUhWZ7DV/QthUn4wTjFg== X-Report-Abuse-To: spam@s01.spamexperts.axc.nl Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.20 / 15.00 / 200.00 X-Rspamd-Queue-Id: D233142124 X-Rspamd-UID: 0968c9 Hi Luiz, >> So is there something I can do to enable to see Android Covid exposure >> notification ? Do I something wrong or is there a bug in the bluez stack? > You probably will need to set some filtering since the advertisement > may not be 'visible', you can try with: > > bluetoothctl> scan.transport le > bluetoothctl> scan on I scan now with the filters : > scan.transport le > scan.uuids 0xfd6f This gives the expected result. So the bluetoothstack itself seems to work ok. Thanks for the tips. Good, now I know I have look at the python layers. I think something in the beacontools is going wrong, I will check there of find a alternative. already have a plan B, using a external ESP32 that show all the beacons. > Is there any specification available for such beacons? Sure there is, see : https://covid19-static.cdn-apple.com/applications/covid19/current/static/contact-tracing/pdf/ExposureNotification-BluetoothSpecificationv1.2.pdf Regards, Dave Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YE2qKrJqPl/xpQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 14:21:06 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SPzYKLJqPl9AtwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 14:21:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=omicronenergy.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A81A340676; Thu, 20 Aug 2020 14:21:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728060AbgHTLxh (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 07:53:37 -0400 Received: from ns.omicron.at ([212.183.10.25]:55590 "EHLO ns.omicron.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728886AbgHTLuz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 07:50:55 -0400 Received: from MGW02-ATKLA.omicron.at ([172.25.62.35]) by ns.omicron.at (8.15.2/8.15.2) with ESMTPS id 07KBoreh024837 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 13:50:53 +0200 DKIM-Filter: OpenDKIM Filter v2.11.0 ns.omicron.at 07KBoreh024837 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omicronenergy.com; s=default; t=1597924253; bh=8LwV4S/Ipp95OyTQw0O8bT2y9pn5XiWmHjkkmSbWO7M=; h=Subject:From:To:CC:Date:In-Reply-To:References:From; b=aEqc3gBdz7na16oqA/jVFagBleAf2dQA+kBHnvVMvgv990yWf630StEJVVFZG07E0 CPAJTZLCVDaLW8XoAktXg3lUcvdTn8N49nNKwrk8C+8ExZEtkbof40xOP5dm52JdJk oqXynIyb/uPnnn7+kxKG9t5Z6mYOQKVr54g9+u6U= Received: from MGW02-ATKLA.omicron.at (localhost [127.0.0.1]) by MGW02-ATKLA.omicron.at (Postfix) with ESMTP id 44450A0053 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 13:50:52 +0200 (CEST) Received: from MGW01-ATKLA.omicron.at (unknown [172.25.62.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by MGW02-ATKLA.omicron.at (Postfix) with ESMTPS id 418DCA0072 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 13:50:52 +0200 (CEST) Received: from EXC04-ATKLA.omicron.at ([172.22.100.189]) by MGW01-ATKLA.omicron.at with ESMTP id 07KBorLO003488-07KBorLQ003488 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=CAFAIL); Thu, 20 Aug 2020 13:50:53 +0200 Received: from marmar13.omicron.at (172.22.32.104) by EXC04-ATKLA.omicron.at (172.22.100.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 20 Aug 2020 13:50:52 +0200 Message-ID: <fdb46a6be1ea6ae018d733126108aa8b84c1a08b.camel@omicronenergy.com> Subject: Re: [PATCH BlueZ 1/2] src/profile.c: Allow the "Address Type" to be set From: Mark Marshall <mark.marshall@omicronenergy.com> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> CC: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Date: Thu, 20 Aug 2020 13:50:51 +0200 In-Reply-To: <CABBYNZLyv_B4CtnqtHXdKnyEKx0Xo8Ta=Y--sOEu+yokaV_U=A@mail.gmail.com> References: <20200819150931.3005-1-mark.marshall@omicronenergy.com> <98fed7ef-1975-48ca-9ea3-1482d938a806@EXC04-ATKLA.omicron.at> <CABBYNZLyv_B4CtnqtHXdKnyEKx0Xo8Ta=Y--sOEu+yokaV_U=A@mail.gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-IP: [172.22.32.104] X-ClientProxiedBy: EXC04-ATKLA.omicron.at (172.22.100.189) To EXC04-ATKLA.omicron.at (172.22.100.189) X-FE-Policy-ID: 1:1:1:SYSTEM Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.16 / 15.00 / 200.00 X-Rspamd-Queue-Id: A81A340676 X-Rspamd-UID: ffc92a Hi On Wed, 2020-08-19 at 11:46 -0700, Luiz Augusto von Dentz wrote: > Hi Mark, > > On Wed, Aug 19, 2020 at 8:13 AM Mark Marshall > <mark.marshall@omicronenergy.com> wrote: > > > > This allows us to have profiles that use LE L2CAP connections. > > --- > > doc/profile-api.txt | 10 ++++++++++ > > src/profile.c | 18 +++++++++++++++++- > > 2 files changed, 27 insertions(+), 1 deletion(-) > > > > diff --git a/doc/profile-api.txt b/doc/profile-api.txt > > index 183c6c11a..8c7d0a06d 100644 > > --- a/doc/profile-api.txt > > +++ b/doc/profile-api.txt > > @@ -112,6 +112,16 @@ Object path /org/bluez > > > > Profile features (for SDP record) > > > > + uint16 AddressType > > + > > + Allows the Address Type to be > > + selected, can be either > > + BDADDR_BREDR, BDADDR_LE_PUBLIC > > + or BDADDR_LE_RANDOM. If an LE > > + address is selected and the > > + device is not found, the other > > + sort of LE address is tried. > > This sounds like a good idea but aren't we missing the GATT service > that actually exposes the PSM for the client to connect to? We should > probably make RegisterApplication accept Profile1 interfaces in such > cases so one can register both at the same time. Also note that this > should be consistent with Device.AddressType which uses a string to > not a uint16. I didn't want to plumb this into the GATT stuff as it is not specified how it would work. I thought we would have to make up attribute UUIDs, and I thought this was better left to user space? I can use a string, yes, but I don't care about the difference between public and private, just that it's LE, not br/edr. I would treat "public" as LE/public, "private" as LE/private and "value not present" as BR/EDR? Or should I make up a string for BR ("bredr"?) > > > + > > Possible errors: org.bluez.Error.InvalidArguments > > org.bluez.Error.AlreadyExists > > > > diff --git a/src/profile.c b/src/profile.c > > index 6961a107b..10850f305 100644 > > --- a/src/profile.c > > +++ b/src/profile.c > > @@ -677,6 +677,7 @@ struct ext_profile { > > guint id; > > > > BtIOMode mode; > > + uint8_t addr_type; > > BtIOSecLevel sec_level; > > bool authorize; > > > > @@ -1173,9 +1174,16 @@ static struct ext_io *create_conn(struct ext_io *server, GIOChannel *io, > > struct btd_service *service; > > struct ext_io *conn; > > GIOCondition cond; > > + uint8_t addr_type; > > char addr[18]; > > > > - device = btd_adapter_find_device(server->adapter, dst, BDADDR_BREDR); > > + addr_type = server->ext->addr_type; > > + device = btd_adapter_find_device(server->adapter, dst, addr_type); > > + if (device == NULL && addr_type != BDADDR_BREDR) { > > + addr_type ^= (BDADDR_LE_PUBLIC | BDADDR_LE_RANDOM); > > + device = btd_adapter_find_device(server->adapter, dst, > > + addr_type); > > + } > > if (device == NULL) { > > ba2str(dst, addr); > > error("%s device %s not found", server->ext->name, addr); > > @@ -1350,6 +1358,7 @@ static uint32_t ext_start_servers(struct ext_profile *ext, > > io = bt_io_listen(connect, confirm, l2cap, NULL, &err, > > BT_IO_OPT_SOURCE_BDADDR, > > btd_adapter_get_address(adapter), > > + BT_IO_OPT_SOURCE_TYPE, ext->addr_type, > > BT_IO_OPT_MODE, ext->mode, > > BT_IO_OPT_PSM, psm, > > BT_IO_OPT_SEC_LEVEL, ext->sec_level, > > @@ -1567,6 +1576,8 @@ static int connect_io(struct ext_io *conn, const bdaddr_t *src, > > io = bt_io_connect(ext_connect, conn, NULL, &gerr, > > BT_IO_OPT_SOURCE_BDADDR, src, > > BT_IO_OPT_DEST_BDADDR, dst, > > + BT_IO_OPT_SOURCE_TYPE, ext->addr_type, > > + BT_IO_OPT_DEST_TYPE, ext->addr_type, > > BT_IO_OPT_SEC_LEVEL, ext->sec_level, > > BT_IO_OPT_PSM, conn->psm, > > BT_IO_OPT_INVALID); > > @@ -2285,6 +2296,11 @@ static int parse_ext_opt(struct ext_profile *ext, const char *key, > > dbus_message_iter_get_basic(value, &str); > > free(ext->service); > > ext->service = bt_name2string(str); > > + } else if (strcasecmp(key, "AddressType") == 0) { > > + if (type != DBUS_TYPE_UINT16) > > + return -EINVAL; > > + dbus_message_iter_get_basic(value, &u16); > > + ext->addr_type = u16; > > } > > > > return 0; > > -- > > 2.17.1 > > > > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0KQKNdJ+Pl+2gAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 15:46:58 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EOvLM9J+Pl8pnwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 15:46:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E5EF6420F3; Thu, 20 Aug 2020 15:46:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729115AbgHTNGa convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 09:06:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:39942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729391AbgHTNG0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 09:06:26 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 208975] New: The bluetooth module prevents suspend: Bluetooth: hci0: command 0x2042 tx timeout Date: Thu, 20 Aug 2020 13:06:25 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aros@gmx.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version cf_kernel_version rep_platform op_sys cf_tree bug_status bug_severity priority component assigned_to reporter cf_regression Message-ID: <bug-208975-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.02 / 15.00 / 200.00 X-Rspamd-Queue-Id: E5EF6420F3 X-Rspamd-UID: fa9052 https://bugzilla.kernel.org/show_bug.cgi?id=208975 Bug ID: 208975 Summary: The bluetooth module prevents suspend: Bluetooth: hci0: command 0x2042 tx timeout Product: Drivers Version: 2.5 Kernel Version: 5.7.10 Hardware: x86-64 OS: Linux Tree: Mainline Status: NEW Severity: normal Priority: P1 Component: Bluetooth Assignee: linux-bluetooth@vger.kernel.org Reporter: aros@gmx.com Regression: No If I try to suspend more than once, consecutive attempts will fail with this message: hci0: command 0x2042 tx timeout I use this command to fix the issue: rmmod bluetooth btintel btbcm btusb dmesg| grep -i bluet [ 3.003944] Bluetooth: Core ver 2.22 [ 3.003954] Bluetooth: HCI device and connection manager initialized [ 3.003956] Bluetooth: HCI socket layer initialized [ 3.003957] Bluetooth: L2CAP socket layer initialized [ 3.003959] Bluetooth: SCO socket layer initialized [ 3.011301] Bluetooth: hci0: Firmware revision 0.1 build 226 week 31 2019 [ 4.418932] Bluetooth: BNEP (Ethernet Emulation) ver 1.3 [ 4.418936] Bluetooth: BNEP socket layer initialized [ 286.035890] Bluetooth: RFCOMM TTY layer initialized [ 286.035895] Bluetooth: RFCOMM socket layer initialized [ 286.035935] Bluetooth: RFCOMM ver 1.11 [107783.693418] Bluetooth: hci0: command 0x2042 tx timeout [107786.253444] Bluetooth: hci0: command 0x2042 tx timeout [107809.533799] Bluetooth: hci0: urb 000000006e2d6390 failed to resubmit (2) The Bluetooth device is: Bus 003 Device 002: ID 8087:0025 Intel Corp. Wireless-AC 9260 Bluetooth Adapter Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 224 Wireless bDeviceSubClass 1 Radio Frequency bDeviceProtocol 1 Bluetooth bMaxPacketSize0 64 idVendor 0x8087 Intel Corp. idProduct 0x0025 Wireless-AC 9260 Bluetooth Adapter bcdDevice 0.02 iManufacturer 0 iProduct 0 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x00c8 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 1 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 2 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 3 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 4 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 5 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 6 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x003f 1x 63 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x003f 1x 63 bytes bInterval 1 Device Status: 0x0001 Self Powered -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qG5fFuV+Pl/RDwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 15:47:17 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id qBKkFOV+Pl+xRQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 15:47:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C9805420ED; Thu, 20 Aug 2020 15:47:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729788AbgHTNHS convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 09:07:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:41152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728877AbgHTNHR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 09:07:17 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 207629] BISECTED Bluetooth: hci0: command 0x2042 tx timeout - suspend fails - Dell XPS 9300, Dell XPS 7390, Dell Inspiron 7386, Intel NUC7JYB Date: Thu, 20 Aug 2020 13:07:16 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aros@gmx.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc blocked Message-ID: <bug-207629-62941-PJJaXaU1d8@https.bugzilla.kernel.org/> In-Reply-To: <bug-207629-62941@https.bugzilla.kernel.org/> References: <bug-207629-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.87 / 15.00 / 200.00 X-Rspamd-Queue-Id: C9805420ED X-Rspamd-UID: 016290 https://bugzilla.kernel.org/show_bug.cgi?id=207629 Artem S. Tashkinov (aros@gmx.com) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aros@gmx.com Blocks|178231 |208975 Referenced Bugs: https://bugzilla.kernel.org/show_bug.cgi?id=178231 [Bug 178231] Meta-bug: Linux suspend-to-mem and freeze performance optimization https://bugzilla.kernel.org/show_bug.cgi?id=208975 [Bug 208975] The bluetooth module prevents suspend: Bluetooth: hci0: command 0x2042 tx timeout -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OCnBAOt+Pl/RDwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 15:47:23 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id IDCdOup+Pl9ekgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 15:47:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 78B4B42110; Thu, 20 Aug 2020 15:47:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729791AbgHTNHT convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 09:07:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:41194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728918AbgHTNHR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 09:07:17 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 208975] The bluetooth module prevents suspend: Bluetooth: hci0: command 0x2042 tx timeout Date: Thu, 20 Aug 2020 13:07:16 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aros@gmx.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: dependson Message-ID: <bug-208975-62941-ec9ZQ7tEBB@https.bugzilla.kernel.org/> In-Reply-To: <bug-208975-62941@https.bugzilla.kernel.org/> References: <bug-208975-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.02 / 15.00 / 200.00 X-Rspamd-Queue-Id: 78B4B42110 X-Rspamd-UID: 76e4e8 https://bugzilla.kernel.org/show_bug.cgi?id=208975 Artem S. Tashkinov (aros@gmx.com) changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |207629 Referenced Bugs: https://bugzilla.kernel.org/show_bug.cgi?id=207629 [Bug 207629] BISECTED Bluetooth: hci0: command 0x2042 tx timeout - suspend fails - Dell XPS 9300, Dell XPS 7390, Dell Inspiron 7386, Intel NUC7JYB -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6EqFFVeJPl+DAQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 16:31:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UBPPE1eJPl/SPQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 16:31:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CD383420C7; Thu, 20 Aug 2020 16:31:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728688AbgHTNjC convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 09:39:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:48674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730426AbgHTNiz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 09:38:55 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 207629] BISECTED Bluetooth: hci0: command 0x2042 tx timeout - suspend fails - Dell XPS 9300, Dell XPS 7390, Dell Inspiron 7386, Intel NUC7JYB Date: Thu, 20 Aug 2020 13:38:54 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aros@gmx.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-207629-62941-kGVugyV1tK@https.bugzilla.kernel.org/> In-Reply-To: <bug-207629-62941@https.bugzilla.kernel.org/> References: <bug-207629-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.87 / 15.00 / 200.00 X-Rspamd-Queue-Id: CD383420C7 X-Rspamd-UID: 15835f https://bugzilla.kernel.org/show_bug.cgi?id=207629 --- Comment #27 from Artem S. Tashkinov (aros@gmx.com) --- (In reply to Abhishek Pandit-Subedi from comment #25) > Todd, can you confirm you picked up both > https://patchwork.kernel.org/patch/11582831/ and > https://patchwork.kernel.org/patch/11586221/? > > Also, what kind of failure are you seeing? Is it failing to enter suspend > completely? Is it waking spuriously? Is it not entering S0ix? (sent up a fix > for this recently) > > It would be helpful to have logs for a failure case. Could you collect some > logs with dynamic debug for BT (see comment #11) and collect a btmon trace > (btmon -w /tmp/btsnoop) when reproducing this issue? Why haven't these patches been merged with stable? Linux 5.7.15 has neither of them. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OBffOv2NPl84ZgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 16:51:41 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id aHkDOf2NPl8F+gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 16:51:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 61135420D3; Thu, 20 Aug 2020 16:51:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726950AbgHTO2E (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 10:28:04 -0400 Received: from mga14.intel.com ([192.55.52.115]:13235 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726896AbgHTO17 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 10:27:59 -0400 IronPort-SDR: HxBVpRsm+Sy2sUCPsI93t5AwCC1/Hn7nzVrgEtrO1EzpbHfqQ0RQMlGDr40HDMbxS3lLgh6YPf XBzi3MLqZ81w== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="154572196" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="154572196" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:27:57 -0700 IronPort-SDR: hUbAF9faVDT9PR7HfwV1sCKB0Kpda6yPybyxdfFSSRDbdKoyhP+ePuUhsQWT+pX6moGt6+Uoy5 16U+hH85RMxA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="320894461" Received: from orsmsx605-2.jf.intel.com (HELO ORSMSX605.amr.corp.intel.com) ([10.22.229.85]) by fmsmga004.fm.intel.com with ESMTP; 20 Aug 2020 07:27:57 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 20 Aug 2020 07:27:56 -0700 Received: from orsmsx604.amr.corp.intel.com (10.22.229.17) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 20 Aug 2020 07:27:56 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by orsmsx604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 20 Aug 2020 07:27:56 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.108) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 20 Aug 2020 07:27:54 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KX3r5wBuz/H18zE0M5KLb15i0ZV/BLsKRKJhzYdb+LOf4+TmHRhEzj3W5dySHkYaF+oiGaUGc6+u/Gj6nFQf+E7gGawZrfaxQklRfIG3jrzSV0UWb/Xu+78qYrn5+fcdVXSpxOQSc0t4b8YR3PsrDBifGx+zKOe5pzV6lg4MukwWG/M3+ACGHi1EoV63aQjoX9HcS1EZodwQ5Qf25gbm79/rmFBqVOZq4vH+KrXNBcH+zYulfuccCImYyd7bl6xE9wN52Iy7Y8jLuQeRBJOU6gVbY7pcuEgvgp1qVGDkdf06hTDLUCUqjkyRwKMr1f8IuR9DE6cuPgq7DsPzsk5Sew== 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-SenderADCheck; bh=dQTjL1sx4wgAVdBN4rTtRsCgHLKYak50494NwMkw758=; b=ZwJgDPW+5DNpL75uiOjUc+UGdoj+BWJragH/ptYepjnl2RFRe4naEsr7V5tA5Kp8ccUhyeBbRc3bkSTm3/0IeWeIuNAYN2EeTcVxRC4mkPFSsLiHVSHbk5WkruibCpd0bXrHMh+urvjv8xrBJxk01KHToK9CNypasOPVdYCNdFdnbhwcR4E1xKz+cjNDclYvJOch1M96rJ6AY+p3q0ZeoXRG8CT6ZLYIfU9M2F+7lGBCB/O52GvcG6JkGQ/WsizDbT9+JXiHYe7WtZUp+OXIti0m0dSFleQj6SvykBN7pL0ZWo4FVxq6+rsG4CYxkqBJeVw+RPH0GlHa0TR7NvMlEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dQTjL1sx4wgAVdBN4rTtRsCgHLKYak50494NwMkw758=; b=mjGfDGBQasLjxUHTVMeB3FNHNKbzS59mfsIgYFsEtIq34jXZL16y+tCxzz3ncVkA3by74+2j6YyDDSLSbzat9zBN8aq3NQnYd/m6VmxZTdq05cGDnHfSEjc5uZidUoNDAk4y6eG3f3jOv//Yav9XvT5HWuSA5yjdSdAoAu3Xc38= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4554.namprd11.prod.outlook.com (2603:10b6:303:5d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Thu, 20 Aug 2020 14:27:53 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3305.024; Thu, 20 Aug 2020 14:27:53 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ 1/2] mesh: Always set net modes based on node feature settings Thread-Topic: [PATCH BlueZ 1/2] mesh: Always set net modes based on node feature settings Thread-Index: AQHWda4MLl0z9SlriUmes56mlHGlLKlBENAA Date: Thu, 20 Aug 2020 14:27:53 +0000 Message-ID: <748067b43861ae8fe3c17d4d0108d214bf431c8d.camel@intel.com> References: <20200818222208.50938-1-inga.stotland@intel.com> In-Reply-To: <20200818222208.50938-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.54.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0798940c-d5fe-48ad-b6c1-08d845153958 x-ms-traffictypediagnostic: MW3PR11MB4554: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MW3PR11MB455475FE1A32E504278E325AE15A0@MW3PR11MB4554.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: F5vcs6TpRocsjmVFn8Zakl4JWSzKiU3Rtsx+ePUMfjTLJuuBVVOcEqgopeW3o4r0sMas/Y+okGk4fYNnL8UTOc1lUV0Z2oJ+wtlaW3G613020a6+YURce0UXgh/JrrwlXN/Yq7T5OVxKhzVw3SQCosfQOWef40pcqqTqnBGNI/kGDlNodCTOMuQmcBVmAGAE2lSHvRxEN5L0xTVLlUKAsRLJi5lx7tlJWgZHM6EI8Uv0JkpiBEw5wmoPKwEcjN2X8E19XQgJI9vTbLn2KU5T2xPFUEMyTLQrSwMx+rjUod15OsMQq2M9PTS3LMoCooFF1aFK9JWl7dQNwM68k9bvJw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(346002)(396003)(136003)(366004)(39860400002)(8676002)(83380400001)(6636002)(26005)(6506007)(6486002)(71200400001)(8936002)(36756003)(86362001)(91956017)(76116006)(66946007)(66446008)(64756008)(66556008)(66476007)(186003)(2616005)(2906002)(478600001)(6512007)(5660300002)(110136005)(316002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: pBEYolaGyJhPIFFPvTqBrOgHcUUOOgcRNCds4TcyRwj6w6JLjzi8l931Psr85vIrnn1ZwrjpC6Bw5pWdh4RyIbZVbuChZcDwr7i+EreE/W0evW4dLkueu5y4nqDmSj6+2VsoEH6Er5kpWdLGyWmrob2krUbflAkk0JZ0XOwLkJkphoHaUcUciIDtSgv/IlzHh5nexDfwmLOl5msajDwehoPZZJNN5OoRM+FX7wfbGVxQtzgOM6Ywm4eM9z/HvnRw4RxZyjJcodD3xhZF+3t7TmlS39hfj6d0/CqJYLOsFN3TeHp+sd8AdGtBL4KCa2kTXRJ14lxSPqV0qV45aYvgGqFuLSxdjYLJBEouTjAhLsOzF9SoBw0LGRyezavzvUojt7Hqb75wFLcPXImFxlM8FNL7qxgj83XAJ2Z2ix1fRY9SGWOcSIIr9vezJDuFRt1hsUYoOPBiPyU4TBtudzZeMNiLVaIefpOPTL8rTMI9svlglXySkjBqIIz1gk1ZA6RbAfgMvqD0G1bAyIkDSji0pxO7+xlncQM19ZMg3b02e7ILZt9Mo2wHRW2uzwWB/UK+Myx5q4Fk+MrKd17Jqoj5WkJiZFenImeAdy89cd8uqRLshV5JI6xa7Wo9waCK6iuX8YX7Q5qmJ+wFuY9oAJVvtw== Content-Type: text/plain; charset="utf-8" Content-ID: <5419F3EB3CBF474F89BD8CB5CCC628CD@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0798940c-d5fe-48ad-b6c1-08d845153958 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Aug 2020 14:27:53.1212 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 9IggI9wyGtpeAkyskfZAZHNweAWzfvig1+jANcXeCJXBaP8FQJpC6xOmkwomhZdJ16Qq3gahRjjnyLCURHX/qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4554 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 61135420D3 X-Rspamd-UID: fd37ce QXBwbGllZCBwYXRjaHNldCB3aXRoIHNwZWxsaW5nIGNvcnJlY3Rpb24NCg0KT24gVHVlLCAyMDIw LTA4LTE4IGF0IDE1OjIyIC0wNzAwLCBJbmdhIFN0b3RsYW5kIHdyb3RlOg0KPiBUaGUgbmV0d29y ayBzZXR0aW5ncyBzdWNoIGFzIHJlbGF5LCBiZWFjb24sIHByb3h5IGFuZCBmcmllbmQgYXJlDQo+ IGFsd2F5cyBzZXQgYmFzZWQgb24gbG9jYWwgbm9kZSBmZWF0dXJlIHNldHRpbmdzLiBUaGlzIGNo YW5nZSBtYWtlcw0KPiB0aGUgbmV0IG1vZGVzIGludGlhbGl6YXRpb24gdW5jb25kaXRpb25hbCwg dG8gaW5jbHVkZSB0aGUgIk5vIFN1cHBvcnQiDQo+IHNldHRpbmcgb24gbm9kZSBsZXZlbCB3aGlj aCBzaG91bGQgcmVzdWx0IGluIHRoZSBkaXNhYmxlZCBtb2RlIGluIG5ldC5jDQo+IC0tLQ0KPiAg bWVzaC9ub2RlLmMgfCAxOCArKysrKy0tLS0tLS0tLS0tLS0NCj4gIDEgZmlsZSBjaGFuZ2VkLCA1 IGluc2VydGlvbnMoKyksIDEzIGRlbGV0aW9ucygtKQ0KPiANCj4gZGlmZiAtLWdpdCBhL21lc2gv bm9kZS5jIGIvbWVzaC9ub2RlLmMNCj4gaW5kZXggMWVlZmZlYjhiLi5lYmMxMTFhNjIgMTAwNjQ0 DQo+IC0tLSBhL21lc2gvbm9kZS5jDQo+ICsrKyBiL21lc2gvbm9kZS5jDQo+IEBAIC0zOTksMjQg KzM5OSwxNiBAQCBzdGF0aWMgYm9vbCBpbml0X3N0b3JhZ2VfZGlyKHN0cnVjdCBtZXNoX25vZGUg Km5vZGUpDQo+ICANCj4gIHN0YXRpYyB2b2lkIHVwZGF0ZV9uZXRfc2V0dGluZ3Moc3RydWN0IG1l c2hfbm9kZSAqbm9kZSkNCj4gIHsNCj4gLQl1aW50OF90IG1vZGU7DQo+ICsJc3RydWN0IG1lc2hf bmV0ICpuZXQgPSBub2RlLT5uZXQ7DQo+ICANCj4gLQltb2RlID0gbm9kZS0+cHJveHk7DQo+IC0J aWYgKG1vZGUgPT0gTUVTSF9NT0RFX0VOQUJMRUQgfHwgbW9kZSA9PSBNRVNIX01PREVfRElTQUJM RUQpDQo+IC0JCW1lc2hfbmV0X3NldF9wcm94eV9tb2RlKG5vZGUtPm5ldCwgbW9kZSA9PSBNRVNI X01PREVfRU5BQkxFRCk7DQo+ICsJbWVzaF9uZXRfc2V0X3Byb3h5X21vZGUobmV0LCBub2RlLT5w cm94eSA9PSBNRVNIX01PREVfRU5BQkxFRCk7DQo+ICANCj4gLQltb2RlID0gbm9kZS0+ZnJpZW5k Ow0KPiAtCWlmIChtb2RlID09IE1FU0hfTU9ERV9FTkFCTEVEIHx8IG1vZGUgPT0gTUVTSF9NT0RF X0RJU0FCTEVEKQ0KPiAtCQltZXNoX25ldF9zZXRfZnJpZW5kX21vZGUobm9kZS0+bmV0LCBtb2Rl ID09IE1FU0hfTU9ERV9FTkFCTEVEKTsNCj4gKwltZXNoX25ldF9zZXRfZnJpZW5kX21vZGUobmV0 LCBub2RlLT5mcmllbmQgPT0gTUVTSF9NT0RFX0VOQUJMRUQpOw0KPiAgDQo+IC0JbW9kZSA9IG5v ZGUtPnJlbGF5Lm1vZGU7DQo+IC0JaWYgKG1vZGUgPT0gTUVTSF9NT0RFX0VOQUJMRUQgfHwgbW9k ZSA9PSBNRVNIX01PREVfRElTQUJMRUQpDQo+IC0JCW1lc2hfbmV0X3NldF9yZWxheV9tb2RlKG5v ZGUtPm5ldCwgbW9kZSA9PSBNRVNIX01PREVfRU5BQkxFRCwNCj4gKwltZXNoX25ldF9zZXRfcmVs YXlfbW9kZShuZXQsIG5vZGUtPnJlbGF5Lm1vZGUgPT0gTUVTSF9NT0RFX0VOQUJMRUQsDQo+ICAJ CQkJCW5vZGUtPnJlbGF5LmNudCwgbm9kZS0+cmVsYXkuaW50ZXJ2YWwpOw0KPiAgDQo+IC0JbW9k ZSA9IG5vZGUtPmJlYWNvbjsNCj4gLQlpZiAobW9kZSA9PSBNRVNIX01PREVfRU5BQkxFRCB8fCBt b2RlID09IE1FU0hfTU9ERV9ESVNBQkxFRCkNCj4gLQkJbWVzaF9uZXRfc2V0X2JlYWNvbl9tb2Rl KG5vZGUtPm5ldCwgbW9kZSA9PSBNRVNIX01PREVfRU5BQkxFRCk7DQo+ICsJbWVzaF9uZXRfc2V0 X2JlYWNvbl9tb2RlKG5ldCwgbm9kZS0+YmVhY29uID09IE1FU0hfTU9ERV9FTkFCTEVEKTsNCj4g IH0NCj4gIA0KPiAgc3RhdGljIGJvb2wgaW5pdF9mcm9tX3N0b3JhZ2Uoc3RydWN0IG1lc2hfY29u ZmlnX25vZGUgKmRiX25vZGUsDQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cKSFGhKOPl+DAQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 16:52:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id +NJIGRKOPl++5QEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 16:52:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 82CEF42107; Thu, 20 Aug 2020 16:51:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728058AbgHTO31 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 10:29:27 -0400 Received: from mga18.intel.com ([134.134.136.126]:38139 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726896AbgHTO3Y (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 10:29:24 -0400 IronPort-SDR: iY85XEP/d8SlYoSqyyWtvgRmJNAjCnr9HFDY5SKK54V6VDq7KMv2sFn0dwH7Pf42hYpUjsRa72 jf9dbMOEkKXg== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="142939559" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="142939559" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:29:21 -0700 IronPort-SDR: NKXgLCZRzrq+ON+/sJMV5lQ+2+6VsrJXUxKac86OGrC1Y3c6URw0RD+vIG4VJIfNDko9E8tzDO MuaTisixAoeA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="335020457" Received: from fmsmsx603-2.cps.intel.com (HELO fmsmsx603.amr.corp.intel.com) ([10.18.84.213]) by FMSMGA003.fm.intel.com with ESMTP; 20 Aug 2020 07:29:21 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 20 Aug 2020 07:29:20 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 20 Aug 2020 07:29:20 -0700 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (104.47.38.59) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 20 Aug 2020 07:29:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X1w+QKve8fIOnhJUhxiaMguZeulVNkSnz4K+uFIgjy1ZaWuH11q8zgVeSmfqZfPGk06YbmCPI2A2FHGq4UxmdWJlHe0Kz6+taozkop3qXKVvsHsbEKany2ETO+owJd7A49yedZ2Mu74JIequMl772P/Zx52Q2wZ0k1aeHHCGSg1Y2hh7ry5Cqx2U+GM0i1z1aFuVtsH+EPxHIsXXjhu+/zeRuVmFlPE1axomdgQ2cIi+NIA0xl1GQwGmnqXnIrf/XvBKVAJS9cYIxwlyXlREHK4ngV9IMDjl9+KEDVgNsUTaU06AQfmH3tn60cL0OrR5yzWwUGR6lgkuCnn1+keZrw== 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-SenderADCheck; bh=/QcuiS3Yvtdjl/w+bt+8JVF/h05tWp3FSA1BldGHkm0=; b=S1cbw476tTZE2BjvNsuSK6AXhPQzxgFXfJVQo2YgPrO3s1PS9DQ9heeT+cSBmo0PMwzqO50kmrYomk0oNpsDB7u+3f2rjiymK6eaacrIHNVGlNpknSw0t0HhzmOeBNhKXo5pPnmiOXJ6HoM4SWG0hzoonwKyVaVBkBZp6CIla8B6cINXV0rRCH/d+Ci6ofUOmC4Byao+sVK/8EQEe50K3hAwoIecj9CZj1WjxNFfAxvL5gxQWLnG+QtteokNTToEJmiSqAs9nmAKpbPPhiSqmZS66wScHs8q0jmBX3LsRpq7UHGpZDgiVf5M2rHr3e0kt1gnBNd+GVCFCjWy8l6tuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/QcuiS3Yvtdjl/w+bt+8JVF/h05tWp3FSA1BldGHkm0=; b=FbQHYxJE2+DEZiZJ/p37t/gUXTq3WjD1cTG61HHq1MIDdhbfn06cgWJDUpDqbIGKteFiZr4TiRZLBgqxuo6+ap+SVB5wV+nWR5L5Eab3qs1K13/Ex0jX52Qgm1/mGjKyqz9SoysXBgIOhUmXbcJuOKtPgzK/Jqa7Knx/bzjg3ko= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1376.namprd11.prod.outlook.com (2603:10b6:300:1d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.25; Thu, 20 Aug 2020 14:29:19 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3305.024; Thu, 20 Aug 2020 14:29:19 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: Send correct NetKey index in DevKeyMessageReceived Thread-Topic: [PATCH BlueZ] mesh: Send correct NetKey index in DevKeyMessageReceived Thread-Index: AQHWdnJt0OW6VjSYpUyye6w14UAuwalBD6yA Date: Thu, 20 Aug 2020 14:29:18 +0000 Message-ID: <01cbff2b3bc7d6c7b97e75fa93e6444480fbf262.camel@intel.com> References: <20200819214802.83756-1-inga.stotland@intel.com> In-Reply-To: <20200819214802.83756-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.54.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c6d96215-13c9-482b-52b8-08d845156c89 x-ms-traffictypediagnostic: MWHPR11MB1376: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR11MB137661852780682C96D844C2E15A0@MWHPR11MB1376.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: s6HlGvxKlZkjdy+WYcO5hrmbfJxo/SeznKNEYvXRN5iZOWVSf219Dh2+wavsXxmDqRZTDFIvMbIpNMulFUu3gXcR1YsXhaS7KADDJswfaLGJkw3WgL4HMLFFb8GEg0ip86L9OF+DzyOODpN3nTWoQtZfvYch46aihphUmuzCOReEv+dZBIrPI9tcqr9wm7ecBzcofJVrg/kxYpBH0lngGxLy/oSBFc8RONYKzXCxcZNZcIMAKg2YKcOlvSgfbaPVyVYa3o4OUgK7+Nl4rrusXS7kAiI3xMlOjM47s6X1S0VFkaguZlH5G0Ric3LtfUKmD/dBWG5tlaesUtP5KZGHMw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(366004)(39860400002)(346002)(376002)(26005)(5660300002)(186003)(8676002)(66476007)(66946007)(6486002)(4744005)(66446008)(8936002)(64756008)(478600001)(2616005)(66556008)(6636002)(76116006)(91956017)(316002)(6512007)(110136005)(6506007)(83380400001)(2906002)(71200400001)(36756003)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: OIYWy8TDDSNltbp2HrdolLAUMs+jxpWlmQmJK7J5qg8UxpfvO/BDNOK++vBbAw+wM5sXa9H3vHWVzCftGx6nvZhmOJkZpGHyosttl89mLFRCoM/dAYOCK1dPQkYheTlmz8AxnVOHpmt5zPsTwAvzZaDAB+0axDG3ZVcDMawFeDBR4do5h9VxJj58c1zfTv7V+/IMbeVG28UOMS0LtN6uGESC1NQ1xDVdrlBwvb/472N4BMceVTWhC9LHe++7K2etOR0qGLaQ3fnSg6TogyQytFjEyZzAVQzsjZqKrl7IYF8bojFoZUTIvvsPausXW6APTIoueaYG/RlGbuijQL1OQ+NHKN3Cyq9D/y26c2hc4WTHklwqsHAFPp93GmXNLutQ6xCEC+bJY3GCKkXE0sAt4Yzauzk7nhxT2xOJZSn0QZnwd3RnPDmTuVwTs21/weGYLL4bFfFzeNpWJlq3mluvQVnVc1oDdFf2iSHTgiD4Aj61nOkcBtD8XmjdM2Llu3moYoekzrEdqdefPKKPU6pZEsufeHf5dBWjw0PKtmWjXnMAaY2VgwYgaOLiBrNXV7CfHY8PXyKEWXvnEDqYp0mXuPWfoM2SrYB8tKkyvOHlyB8uTjLQ4QsqeJbymrevo/9TyVcL3V2O/KBIFfzUuRu9SQ== Content-Type: text/plain; charset="utf-8" Content-ID: <4BCDF94F0545CE478A203F7B2417EE03@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c6d96215-13c9-482b-52b8-08d845156c89 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Aug 2020 14:29:19.0045 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Zb0ZN+i260vB9WrRYH4hObqMSrghnoPSTA33rFuQsAc0bJYW3b39r/8FAiDYfITWTzIja5KpGEqLCS3y6UW+xQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1376 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 82CEF42107 X-Rspamd-UID: 70aad2 QXBwbGllZA0KT24gV2VkLCAyMDIwLTA4LTE5IGF0IDE0OjQ4IC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBUaGUgdmFsdWUgb2YgbmV0X2luZGV4IGluIERldktleU1lc3NhZ2VSZWNlaXZl ZCgpIG1ldGhvZCBtdXN0IGJlIHNldA0KPiB0byB0aGUgdmFsdWUgb2YgYSBzdWJuZXQgaW5kZXgg b24gd2hpY2ggYSBkZXZpY2Uga2V5IGVuY29kZWQgbWVzc2FnZQ0KPiBoYXMgYmVlbiByZWNlaXZl ZC4gV2FzIGhhcmQgY29kZWQgdG8gMC4gRml4ZWQuDQo+IC0tLQ0KPiAgbWVzaC9tb2RlbC5jIHwg MyArKy0NCj4gIDEgZmlsZSBjaGFuZ2VkLCAyIGluc2VydGlvbnMoKyksIDEgZGVsZXRpb24oLSkN Cj4gDQo+IGRpZmYgLS1naXQgYS9tZXNoL21vZGVsLmMgYi9tZXNoL21vZGVsLmMNCj4gaW5kZXgg YjQ0ZTJmNjY5Li45NTI5ZGZiMmUgMTAwNjQ0DQo+IC0tLSBhL21lc2gvbW9kZWwuYw0KPiArKysg Yi9tZXNoL21vZGVsLmMNCj4gQEAgLTk2NSw3ICs5NjUsOCBAQCBib29sIG1lc2hfbW9kZWxfcngo c3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgYm9vbCBzem1pY3QsIHVpbnQzMl90IHNlcTAsDQo+ICAJ CQllbHNlIGlmIChkZWNyeXB0X2lkeCA9PSBBUFBfSURYX0RFVl9SRU1PVEUgfHwNCj4gIAkJCQkg ZGVjcnlwdF9pZHggPT0gQVBQX0lEWF9ERVZfTE9DQUwpDQo+ICAJCQkJc2VuZF9kZXZfa2V5X21z Z19yY3ZkKG5vZGUsIGksIHNyYywgZGVjcnlwdF9pZHgsDQo+IC0JCQkJCQkwLCBmb3J3YXJkLnNp emUsIGZvcndhcmQuZGF0YSk7DQo+ICsJCQkJCQkJbmV0X2lkeCwgZm9yd2FyZC5zaXplLA0KPiAr CQkJCQkJCQlmb3J3YXJkLmRhdGEpOw0KPiAgCQl9DQo+ICANCj4gIAkJLyoNCg== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eA39CfSlPl+y/wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 18:33:56 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id uKZICPSlPl+wTQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 18:33:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 494AF4210A; Thu, 20 Aug 2020 18:33:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729909AbgHTQde (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 12:33:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729847AbgHTQd3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 12:33:29 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 670D6C061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 09:33:28 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id r21so1932101ota.10 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 09:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7Z2uA+NbB98XON2iyeIwtQSTejS9ojV/YxUR8dWX9Gw=; b=j1IkZwnW1ug6o35MoxYfFcPSTfqHEZr41bAiw9KBiIiGuMTAkRdkNG9ZL+ZTSyy60e Bgsvy+saYaN2l9+C/xOg6zQb16i/IgiVaRm3v43akAKQ028hSbatFdILMOJJi84CForw kEK2JbTwJRVVERz7wh2trLw4fAaTSl+0CzQfrMupID6KHjhS3ITs/9b/rc12T5D5H6IK cgeKxQB3fR6w9SmZSEnjPkyKnXzTnfs18NSsKXEYO8yaooKkq8LnBDTcuxVzkpq1Mnun lIHNc03o8bYnlVDOMFk40MW8YuQyhBV4awbKHxwTMExz50ZWG86prHtOSCZaTFZQmyn1 5zgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7Z2uA+NbB98XON2iyeIwtQSTejS9ojV/YxUR8dWX9Gw=; b=BGjolX1fYtmqMuCWMJXJRV9KsXrF5plfsSClLsKa+6eMRi0ANowS8Agn8qGM2EC3ZK pvq5bTnzj/aGXeWtjYbXsP3AdR+89BEXxn2FqfTBXdigxLO/EnD676Rs2d7cyGN9H9bP /K321cBZN6zJ89HaYpENdhc61v9JR1HnUAQ4dyyyfGX1BqwfclBc2gnkULpWKp0D9UUy NMY9wX6PBOGnUrDOJEJr/SsIMBGcUe8SMxrETHrniKqb4133ZFEVCsuHZCZpz42nYF+3 g6yWF3s+aAFYpdTGWpycqnNHcIv9QOPMYITnVyKNNwQI2TI8vF6/uxxekKAU/tgcqNgW 1/Bw== X-Gm-Message-State: AOAM533T00Ws5qfCR7d1tzU+/DL+snNaqfM4AANUwxPz1yURh/TNaC4T BmCETXZrC5r6czzzaGBgXCard+64hcIWBDK081g= X-Google-Smtp-Source: ABdhPJyxyEx78zi9NM0JZZ7LpUcYVqjT/dMTC4UGRtF2QC0/QqJEin9mhJp4X3ufloWHGsVUHAaqmogkuIeGVFXQSHY= X-Received: by 2002:a9d:24e7:: with SMTP id z94mr2735194ota.91.1597941207054; Thu, 20 Aug 2020 09:33:27 -0700 (PDT) MIME-Version: 1.0 References: <20200819150931.3005-1-mark.marshall@omicronenergy.com> <2303f692-bb7c-4851-86fa-befde45b4b32@EXC04-ATKLA.omicron.at> <CABBYNZ+OK4EY9KGHn7oasz4GRfBDJdWNcpOhr1GNGc3D+QtZ-g@mail.gmail.com> <3e98e7dae29ec7be6d67fca6af99f2e0f747375e.camel@omicronenergy.com> In-Reply-To: <3e98e7dae29ec7be6d67fca6af99f2e0f747375e.camel@omicronenergy.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 20 Aug 2020 09:33:16 -0700 Message-ID: <CABBYNZ+U+Edyb42oKWgsqVKHCZZDzXR4HRRrK0Rb2vEL_A3aiA@mail.gmail.com> Subject: Re: [PATCH BlueZ 2/2] src/profile.c: Add a GetProfileInfo method To: Mark Marshall <mark.marshall@omicronenergy.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.38 / 15.00 / 200.00 X-Rspamd-Queue-Id: 494AF4210A X-Rspamd-UID: 44d323 Hi Mark, On Thu, Aug 20, 2020 at 3:10 AM Mark Marshall <mark.marshall@omicronenergy.com> wrote: > > On Wed, 2020-08-19 at 11:37 -0700, Luiz Augusto von Dentz wrote: > > Hi Mark, > > > > On Wed, Aug 19, 2020 at 8:13 AM Mark Marshall > > <mark.marshall@omicronenergy.com> wrote: > > > > > > Add a GetProfileInfo method to org.bluez.ProfileManager1 > > > --- > > > doc/profile-api.txt | 13 +++++++ > > > src/profile.c | 93 +++++++++++++++++++++++++++++++++++++++++++++ > > > 2 files changed, 106 insertions(+) > > > > > > diff --git a/doc/profile-api.txt b/doc/profile-api.txt > > > index 8c7d0a06d..d13703ab4 100644 > > > --- a/doc/profile-api.txt > > > +++ b/doc/profile-api.txt > > > @@ -133,6 +133,19 @@ Object path /org/bluez > > > > > > Possible errors: org.bluez.Error.DoesNotExist > > > > > > + options GetProfileInfo(object profile, object adapter) > > > + > > > + This returns a dictionary of options for the > > > + profile. Values returned are: UUID, Name, > > > + Path, Service, Mode and AddressType. The > > > + adapter parameter is optional - if it is > > > + non-empty, then two additional values might be > > > + returned, if the profile is active on the > > > + specified adapter: PSM and Channel. > > > + > > > + Possible errors: org.bluez.Error.InvalidArguments > > > + org.bluez.Error.DoesNotExist > > > + > > > > If this is really required I would be willing to merge something like this: > > > > https://github.com/Vudentz/BlueZ/commit/9e196f8830511a4102e990d82d06c2e0487b3ad9 > > > > It exposes service objects so you can control exactly what gets > > connect, though now given a second look at this seem to return details > > that the client can query directly on the socket itself like the > > Channel, PSM, Mode, etc, also not sure what is the point on retrieving > > things like UUID, Name, Path if the application is already in control > > of these when registering. > > > > I only returned a full dictionary of items here as I was trying to > match RegisterProfile, I don't actually need all of this info. (I > also thought that the more verbose structure was more useful, but > it is wasteful). > > The information that I really need is the PSM (or Channel) number. > This information is needed on the server side, and the socket used > is not exposed to anything outside of bluetoothd, as far as I can > tell. (This is the socket returned from bt_io_listen, in profile.c). The file descriptor passed on NewConnection is the same socket the daemon uses so you can query things like PSM, etc, using getsockopt just like the daemon does, or do you need it before a connection is made? In which case it might be preferable to write the PSM back to the Property.Set method, that said perhaps it is better to have a PSM set instead of leaving that to be auto allocated since you may not want to change if you need to expose over GATT. > I have my profile auto-select a free PSM, which I thought was the > preferred method. In the BR/EDR case, this number gets passed to the > peer (I assume through SDP), but in the LE case, where I want to use > LE-L2CAP, there is no defined mechanism to transfer the PSM. My plan > was to expose it as a GATT attribute, but this mechanism is not > standardised, so I didn't think BlueZ would want to be involved? BlueZ don't need to get involved directly but you can have vendor specific GATT service that expose the PSM so the remote side can learn about it and connect. > Would a simpler interface that just returned the PSM or Channel number > be better? Is there another way to find out the PSM of a listening > socket, on the server, before a connection is made? For auto allocation I would make actually make the properties writable, though it seems we don't have any properties on Profile1 so we would need to create then in order to reflect the options that can be passed over on RegisterProfile. > (From my reading of the above patch, the service object is created > as a link between a "profile" and a "device". In my case, I think > there is no service object yet, as I have no device connection?) > > > > Profile hierarchy > > > ================= > > > diff --git a/src/profile.c b/src/profile.c > > > index 10850f305..e287a66d7 100644 > > > --- a/src/profile.c > > > +++ b/src/profile.c > > > @@ -2509,6 +2509,96 @@ static DBusMessage *unregister_profile(DBusConnection *conn, > > > return dbus_message_new_method_return(msg); > > > } > > > > > > +static DBusMessage *get_profile_info(DBusConnection *conn, > > > + DBusMessage *msg, void *user_data) > > > +{ > > > + DBusMessage *reply; > > > + DBusMessageIter iter, dict; > > > + const char *path, *adapter, *sender; > > > + struct ext_profile *ext; > > > + uint16_t u16; > > > + GSList *l, *next; > > > + > > > + sender = dbus_message_get_sender(msg); > > > + > > > + DBG("sender %s", sender); > > > + > > > + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, > > > + DBUS_TYPE_OBJECT_PATH, &adapter, > > > + DBUS_TYPE_INVALID)) { > > > + return btd_error_invalid_args(msg); > > > + } > > > + > > > + if (adapter && !*adapter) > > > + adapter = NULL; > > > + > > > + ext = find_ext_profile(sender, path); > > > + if (!ext) > > > + return btd_error_does_not_exist(msg); > > > + > > > + reply = dbus_message_new_method_return(msg); > > > + > > > + dbus_message_iter_init_append(reply, &iter); > > > + > > > + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, > > > + "{sv}", &dict); > > > + > > > + g_dbus_dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, > > > + &ext->uuid); > > > + if (ext->name) { > > > + g_dbus_dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, > > > + &ext->name); > > > + } > > > + if (ext->path) { > > > + g_dbus_dict_append_entry(&dict, "Path", DBUS_TYPE_STRING, > > > + &ext->path); > > > + } > > > + if (ext->service) { > > > + g_dbus_dict_append_entry(&dict, "Service", DBUS_TYPE_STRING, > > > + &ext->service); > > > + } > > > + > > > + u16 = ext->mode; > > > + g_dbus_dict_append_entry(&dict, "Mode", DBUS_TYPE_UINT16, > > > + &u16); > > > + > > > + u16 = ext->addr_type; > > > + g_dbus_dict_append_entry(&dict, "AddressType", DBUS_TYPE_UINT16, > > > + &u16); > > > + > > > + if (adapter) { > > > + for (l = ext->servers; l != NULL; l = next) { > > > + struct ext_io *server = l->data; > > > + const char *ctype; > > > + > > > + DBG("server:%p %d %d psm:%d chan:%d", > > > + server, server->resolving, server->connected, > > > + server->psm, server->chan); > > > + > > > + next = g_slist_next(l); > > > + > > > + if (strcmp(adapter, adapter_get_path(server->adapter))) > > > + continue; > > > + > > > + if (server->proto == BTPROTO_L2CAP) { > > > + ctype = "PSM"; > > > + u16 = server->psm; > > > + } else if (server->proto == BTPROTO_RFCOMM) { > > > + ctype = "Channel"; > > > + u16 = server->chan; > > > + } else { > > > + continue; > > > + } > > > + g_dbus_dict_append_entry( > > > + &dict, ctype, DBUS_TYPE_UINT16, &u16); > > > + } > > > + } > > > + > > > + dbus_message_iter_close_container(&iter, &dict); > > > + > > > + return reply; > > > +} > > > + > > > static const GDBusMethodTable methods[] = { > > > { GDBUS_METHOD("RegisterProfile", > > > GDBUS_ARGS({ "profile", "o"}, { "UUID", "s" }, > > > @@ -2516,6 +2606,9 @@ static const GDBusMethodTable methods[] = { > > > NULL, register_profile) }, > > > { GDBUS_METHOD("UnregisterProfile", GDBUS_ARGS({ "profile", "o" }), > > > NULL, unregister_profile) }, > > > + { GDBUS_METHOD("GetProfileInfo", > > > + GDBUS_ARGS({ "profile", "o" }, { "adapter", "o" }), > > > + GDBUS_ARGS({ "options", "a{sv}" }), get_profile_info) }, > > > { } > > > }; > > > > > > -- > > > 2.17.1 > > > > > > > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2EIiNg2sPl+9hwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 18:59:57 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +OofNA2sPl/ovQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 18:59:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BFD9E420C5; Thu, 20 Aug 2020 18:59:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728324AbgHTQ5Y (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 12:57:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727972AbgHTQ5T (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 12:57:19 -0400 Received: from mail-ua1-x936.google.com (mail-ua1-x936.google.com [IPv6:2607:f8b0:4864:20::936]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59F55C061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 09:57:19 -0700 (PDT) Received: by mail-ua1-x936.google.com with SMTP id s29so780630uae.1 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 09:57:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:from:date:message-id:subject:to:cc; bh=QYuR2e8AkRz6vIxG3CqwQqEQ7G/qCpkD6SKe9AUP/Rg=; b=E0rxJ6YBO2Ep5q2WB3Hki5mUK6bXNhjLmh23hVYGsYhh2eh8h0SeCbLhpeSf5x0RHY wIuMss2ECTZkkbiNAz0YjV+gjbISwMjfFGqj2EHARF0FfujtYjWBmE/0QkNzEPRHzQdx poND40MbXd8K2NAHuAG2L6zhdOlsg5EHSXots= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=QYuR2e8AkRz6vIxG3CqwQqEQ7G/qCpkD6SKe9AUP/Rg=; b=Zu2EsEvU3rMGHhxzJuCK1EfmYZn+srcZb5T/RLgwuOOeFeTrReCcjVFSuLE15okLWy dpLE6I+3VEZB1BM1dH7rxVvxUWMpPjpVWL+SMX8Cipu6ZPuHrYmMJgH+slRmOGEhWKN3 8ymi5ffH8B6S1YK1MY3x5iRxh9uOC70Uip0uprkG4uHIRJlVpskVrUvM//42zshy6hDZ G1JBNS0Rt3fqf56XifK08tipfZrEsMlSDQGWSJbIv1XUrsTNEP5PJ2m1EhCTOwtwbq+S r7otytG7RULKQuFDpjP/tjNHunjMYdvyxangq57arOGKO+Fh6c1TK50i5ePPfLViYjPA 6Xqg== X-Gm-Message-State: AOAM533gaeCJbiJYkoUzAvVeqj/2PYDzAWM56FyrVsgPo1Y//CDGUYGR cSdAuky0HUFZJrIOYro0HUZ4YwbIKg4Vr5UrpwdmZw== X-Google-Smtp-Source: ABdhPJxuiPNsNRab4REiueDhEETHzegNMG3ZBMS8VZdE2G7/syTOMsdkXHxsD8c9BBsm0AK9nSGmqyLkyVnC3fw0VU8= X-Received: by 2002:ab0:624d:: with SMTP id p13mr2316482uao.136.1597942636770; Thu, 20 Aug 2020 09:57:16 -0700 (PDT) MIME-Version: 1.0 From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Thu, 20 Aug 2020 09:57:06 -0700 Message-ID: <CANFp7mV=Uf37Hk0RgNY3dUpr46DZOSTtKzcp7ptWF8YCKEzuCQ@mail.gmail.com> Subject: Request to queue patch for 5.7 and 5.8 stable To: netdev <netdev@vger.kernel.org> Cc: aros@gmx.com, Manish Mandlik <mmandlik@google.com>, Bluez mailing list <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.65 / 15.00 / 200.00 X-Rspamd-Queue-Id: BFD9E420C5 X-Rspamd-UID: f80208 Hi netdev@, Please include upstream commit 6fb00d4e94bc28c39fa077b03e6531956de87802 for release to stable branches 5.7 and 5.8. This fixes a suspend/resume issue on Bluetooth controllers and has been extensively tested on Chromebooks. It's also needed to fix the bug reported at https://bugzilla.kernel.org/show_bug.cgi?id=207629 I assume this is the right way to request a stable patch following the faq at https://www.kernel.org/doc/Documentation/networking/netdev-FAQ.txt. If this is incorrect, please let me know the correct procedure. I think this patch was missed in normal stable backporting because it is missing a Fixes: tag. We will be more vigilant about the inclusion of this tag during code review going forward. Thanks Abhishek Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YARaKD2sPl+F4AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 19:00:45 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id SM7CJj2sPl/NVwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 19:00:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EC6DF420F7; Thu, 20 Aug 2020 19:00:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728060AbgHTQ7d convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 12:59:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:47692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726749AbgHTQ73 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 12:59:29 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 207629] BISECTED Bluetooth: hci0: command 0x2042 tx timeout - suspend fails - Dell XPS 9300, Dell XPS 7390, Dell Inspiron 7386, Intel NUC7JYB Date: Thu, 20 Aug 2020 16:59:29 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: abhishekpandit@chromium.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-207629-62941-uTtK7AFwuK@https.bugzilla.kernel.org/> In-Reply-To: <bug-207629-62941@https.bugzilla.kernel.org/> References: <bug-207629-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.59 / 15.00 / 200.00 X-Rspamd-Queue-Id: EC6DF420F7 X-Rspamd-UID: 7de91d https://bugzilla.kernel.org/show_bug.cgi?id=207629 --- Comment #28 from Abhishek Pandit-Subedi (abhishekpandit@chromium.org) --- Hi Artem, 5.7.16 got one of the fixes but not the other. I've sent a follow-up email to netdev@ to add the missing one and cc-ed you. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oNRTBT2xPl/KwQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 20 Aug 2020 19:22:05 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id qPxmAz2xPl+jvAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 20 Aug 2020 19:22:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EBB5F420E7; Thu, 20 Aug 2020 19:21:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730529AbgHTRVV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 20 Aug 2020 13:21:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730473AbgHTRVR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 20 Aug 2020 13:21:17 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0827C061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 10:21:13 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id g19so3415352ejc.9 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 10:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jdufANzauToKqmwmMwTfQjvv8/deNb/umE9oNAjsLvc=; b=KJW6cIiAm80v3j3MztQgrglJPct/M/E9qEUZZaiTyphKmd/gWcPrH6ngEfCdKX8OYa tbwkRGUMUB9NfXdGS3XVY7lJu3Zi897CZQn1ij1TrzMCGQ0DkfMSlP9jsJIaFIBFFIi6 6zlWKTyV9zGaOZa9KCXefSzKSCUw2MmUvZZSdTumfCNiWSO7XuaD8AgwZEeRCSXUc5Tc xEvx2Rvvxim3xlLM68T90uvt70Wjhqk/S2u7FPM+vUZwvQU6xdfsyJ6L0E3I4sRVGiLA GuQh9QrLe0xkpVioxDd8X45C5xYi2FLSH3kGKAEGU7OFOf9UqNN2FOWmAhrjUleKfv6B RBBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jdufANzauToKqmwmMwTfQjvv8/deNb/umE9oNAjsLvc=; b=M/2TGqNZnfBNNhZbWF0Fql9yHntjOgZHe5DLXkg8gFYSxw0FuYWNGGi+IcsifF4f7J 9QrM8VPJBAHHPfoC6iEXdGTLM4kAJRjOK9788Kz3CgEVqOY3ERI5VHQTHc/Nlk4FezfZ cE6z0qGA4+h8yXyi8SYiX9jZxsHnUQMyZzFE12ULAAtm6xPIUnVrhprSLzXm5V9os2na QVoEu2UhXWa6bl2fM41P9VhGqllurFEZWYjYnt/Gdq9G0zlF3quM+N4xf6kTuJXw5Epl nQHSVTH7FRKPYdPX2fZKwVlnHI7XdOS0WlujAiL2lzZ+TDDK1Sgg8m0MfKLGHVk4OJgl +QFw== X-Gm-Message-State: AOAM530UUKL/NXUAeUgTK9vk8JRGsWk5yp4AZgX/ot+ROHBqlwMHqGi5 S4F5wY0aHHjp21zsCX5VaqCLEXoQpU2Ex9aKjDp9fA== X-Google-Smtp-Source: ABdhPJy02Do52250u7VdnW1pqpfL7a/DbB1GUOL3tNTB7Y8cZ36NSbUMGiTNNDDYPl6t5ZaGQhHLjVNM8FrqkLhNr4E= X-Received: by 2002:a17:906:c2c8:: with SMTP id ch8mr4146656ejb.161.1597944072198; Thu, 20 Aug 2020 10:21:12 -0700 (PDT) MIME-Version: 1.0 References: <20200817212554.3844965-1-yudiliu@google.com> <20200817142545.RFC.v2.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> <CABBYNZLRqhB6d5Hm7_RqvUqCJo11D4+pgYLCeWj0j=8dZk0Bcg@mail.gmail.com> In-Reply-To: <CABBYNZLRqhB6d5Hm7_RqvUqCJo11D4+pgYLCeWj0j=8dZk0Bcg@mail.gmail.com> From: Yu Liu <yudiliu@google.com> Date: Thu, 20 Aug 2020 10:20:36 -0700 Message-ID: <CAHC-ybxshy5zmkAku6suicvjO0Ngofp0+gRyYLX_RXr9YhU94Q@mail.gmail.com> Subject: Re: [RFC PATCH v2 1/1] adapter - D-Bus API for querying the adapter's capabilities To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: EBB5F420E7 X-Rspamd-UID: ddefd6 Friendly ping for comments from Marcel. Thanks. On Mon, Aug 17, 2020 at 4:17 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Marcel, > > On Mon, Aug 17, 2020 at 4:07 PM Yu Liu <yudiliu@google.com> wrote: > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > Initially this is introduced to query whether WBS is supported by the adapter, > > the API is generic enough to be extended to support querying others in > > the future. > > > > Reviewed-by: sonnysasaka@chromium.org > > > > Signed-off-by: Yu Liu <yudiliu@google.com> > > --- > > > > Changes in v2: > > - Return an array of strings instead of a dict > > > > Changes in v1: > > - Initial change > > > > doc/adapter-api.txt | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt > > index 1a7255750..8fbcadb54 100644 > > --- a/doc/adapter-api.txt > > +++ b/doc/adapter-api.txt > > @@ -204,6 +204,18 @@ Methods void StartDiscovery() > > org.bluez.Error.NotReady > > org.bluez.Error.Failed > > > > + array{string} GetCapabilities() > > + > > + This method returns a list of supported > > + capabilities that is populated when the adapter > > + initiated. > > + > > + Possible values: > > + "wbs" - Wide band speech > > Btw, should we stick to use wbs terminology here, or we should > actually use the HCI feature/command, because wbs has actually to be > implemented by the HFP afaik this is only indicating that the > controller is able to notify packets drops, etc, with use of erroneous > command. Perhaps we should actually use the term PLC (Packet Loss > Concealment) instead since that seems to be the real capability here, > afaik WBS does not actually require PLC. > > > + > > + Possible errors: org.bluez.Error.NotReady > > + org.bluez.Error.Failed > > + > > Properties string Address [readonly] > > > > The Bluetooth device address. > > -- > > 2.28.0.220.ged08abb693-goog > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cJAkCChPP1+U2gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 06:35:52 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 6NjxBihPP193bgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 06:35:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1DCB1A0098; Fri, 21 Aug 2020 06:35:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725935AbgHUEfn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 00:35:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbgHUEfl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 00:35:41 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68DC1C061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 21:35:41 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id s14so329656plp.4 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 21:35:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sOJTXZQPaj2OGZIiejwIYG5vJGEX+qQf5BT+/1KgjFE=; b=UJm0CjaSFkOzg56uLjvFWNjhM7HporMyv++nrHK4lgfNo0QbBf84sHlOpJ0GK83Xg/ LV6orMEN7nZTjDEDeCCWm5cHZPBXZaQvl6tUnEvW9hx3cbxojyYsdgj5mDJI06PyuIjc 100YNueQmhKFvIvkEHYuy8s/51M3xa03dYgSo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sOJTXZQPaj2OGZIiejwIYG5vJGEX+qQf5BT+/1KgjFE=; b=TuYajAgHqYNkDS4swwj3RytomgmbrAxyg1iNwKMDy4O+XGMvJdVL3hNZCBiOEPv8Hy 4W9B0DwsNJ/vJaL8YVhbPBJhDCic4MpbLlV/pLvWcHIF7p0s3pE1/Uh1OFetuPP9BV0a S2DpnwP6evTVkB1VqHO92NUvFHMaOkGRZlnmzZRoXyAfjM7kT6r85Oi74Tr5gYImxJHJ wBA7rkRELA1D7KTgXGWraXSvLLnRJe3JaH+MK0qiJW4Rundcz9fPKxfYv6TAQuKmvXvO IxC/XhA/AP4XYvIR9F1OBxPlcLD0TEO53xx6A9esAh9uYJh1366CadIcRMSafb/74m4g 6xgA== X-Gm-Message-State: AOAM531KeQpAqMJW7q8pomvOVMONcIRmBleKPeaaMeiAm51yHYiqQTIV wZm/ClgF2QPAOksSMyHLgjWMK4kK2NIzCg== X-Google-Smtp-Source: ABdhPJwfdPdAWpACOEJvAVLC2qyMf5vgqDyJQmWjDqERgTZ/9J9w6jl2bI1akPhhqpQZdAvIEHOJPQ== X-Received: by 2002:a17:90b:4c03:: with SMTP id na3mr1047405pjb.29.1597984540086; Thu, 20 Aug 2020 21:35:40 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id d13sm557480pjz.3.2020.08.20.21.35.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 21:35:39 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Archie Pusaka <apusaka@chromium.org> Subject: [PATCH BlueZ] input/device: Unregister all UHID event listeners at UHID_DESTROY Date: Thu, 20 Aug 2020 21:35:36 -0700 Message-Id: <20200821043536.15332-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1DCB1A0098 X-Rspamd-UID: 78478d When destroying UHID, we should also unregister all event listeners so that they don't get double registered at reconnection. It fixes a bug where battery report is not available to kernel after reconnection and also prevents memory leak. Tested with Logitech M535 mouse: * Connect mouse to the device running BlueZ * cat /sys/class/power_supply/hid-{addr}-battery/capacity # works * Disconnect mouse * Reconnect mouse * cat /sys/class/power_supply/hid-{addr}-battery/capacity # still works Reviewed-by: Archie Pusaka <apusaka@chromium.org> --- profiles/input/device.c | 2 ++ src/shared/uhid.c | 9 +++++++++ src/shared/uhid.h | 1 + 3 files changed, 12 insertions(+) diff --git a/profiles/input/device.c b/profiles/input/device.c index 8fc04be37..f6823b7b6 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -982,6 +982,8 @@ static int uhid_disconnect(struct input_device *idev) if (!idev->uhid_created) return 0; + bt_uhid_unregister_all(idev->uhid); + memset(&ev, 0, sizeof(ev)); ev.type = UHID_DESTROY; diff --git a/src/shared/uhid.c b/src/shared/uhid.c index 685f90243..71a4e04ba 100644 --- a/src/shared/uhid.c +++ b/src/shared/uhid.c @@ -219,6 +219,15 @@ bool bt_uhid_unregister(struct bt_uhid *uhid, unsigned int id) return true; } +bool bt_uhid_unregister_all(struct bt_uhid *uhid) +{ + if (!uhid) + return false; + + queue_remove_all(uhid->notify_list, NULL, NULL, free); + return true; +} + int bt_uhid_send(struct bt_uhid *uhid, const struct uhid_event *ev) { ssize_t len; diff --git a/src/shared/uhid.h b/src/shared/uhid.h index 459a24900..dbdca852d 100644 --- a/src/shared/uhid.h +++ b/src/shared/uhid.h @@ -40,5 +40,6 @@ typedef void (*bt_uhid_callback_t)(struct uhid_event *ev, void *user_data); unsigned int bt_uhid_register(struct bt_uhid *uhid, uint32_t event, bt_uhid_callback_t func, void *user_data); bool bt_uhid_unregister(struct bt_uhid *uhid, unsigned int id); +bool bt_uhid_unregister_all(struct bt_uhid *uhid); int bt_uhid_send(struct bt_uhid *uhid, const struct uhid_event *ev); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aArNEFFgP1+gRQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 07:49:05 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id aAA6DVFgP18fGQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 07:49:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4027DA1403; Fri, 21 Aug 2020 07:49:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726062AbgHUFtA (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 01:49:00 -0400 Received: from mga18.intel.com ([134.134.136.126]:50493 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbgHUFs7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 01:48:59 -0400 IronPort-SDR: 91QqtAPYnpRBUcNOh8znkfKxR6R8MMBs7BiJYtG2UgwrMxzuohsXczKf0QNyCwmUl53/L881Le 0J/q6LnIheBQ== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="143101665" X-IronPort-AV: E=Sophos;i="5.76,335,1592895600"; d="scan'208";a="143101665" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 22:48:57 -0700 IronPort-SDR: 7dBW4DEL9L/mDCU1/sgLup0lVPcE6otDVhkmqqa7o3FaLrhgBk547W7QD5dFuEL+cDnVWoJYEc Ut/AI7p1yIeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,335,1592895600"; d="scan'208";a="278829511" Received: from ssuhag-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.84.187]) by fmsmga007.fm.intel.com with ESMTP; 20 Aug 2020 22:48:57 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] mesh: Use valid net key index when handling Send call Date: Thu, 20 Aug 2020 22:48:56 -0700 Message-Id: <20200821054856.41857-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4027DA1403 X-Rspamd-UID: 46d9ab Retrieve value of bound Net Key index based on the value of passed AppKey index. Check if the key is present and fail early in case of error. Also, pass the correct NetKey index to model layer in mesh_model_send(), instead of hard coded 0. --- mesh/model.c | 2 -- mesh/node.c | 13 +++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/mesh/model.c b/mesh/model.c index eb5142503..7e1c4ab92 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -547,8 +547,6 @@ static bool msg_send(struct mesh_node *node, bool cred, uint16_t src, l_debug("no app key for (%x)", app_idx); return false; } - - net_idx = appkey_net_idx(node_get_net(node), app_idx); } out = l_malloc(out_len); diff --git a/mesh/node.c b/mesh/node.c index 1eeffeb8b..ed3d959c5 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -1761,7 +1761,7 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, const char *sender, *ele_path; struct l_dbus_message_iter iter_data; struct node_element *ele; - uint16_t dst, app_idx, src; + uint16_t dst, app_idx, net_idx, src; uint8_t *data; uint32_t len; @@ -1790,10 +1790,15 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, if (app_idx & ~APP_IDX_MASK) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, - "Invalid key_index"); + "Invalid key index"); + + net_idx = appkey_net_idx(node_get_net(node), app_idx); + if (net_idx == NET_IDX_INVALID) + return dbus_error(msg, MESH_ERROR_INVALID_ARGS, + "Key not found"); - if (!mesh_model_send(node, src, dst, app_idx, 0, DEFAULT_TTL, false, - data, len)) + if (!mesh_model_send(node, src, dst, app_idx, net_idx, DEFAULT_TTL, + false, data, len)) return dbus_error(msg, MESH_ERROR_FAILED, NULL); return l_dbus_message_new_method_return(msg); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uLf1A8BzP19SuAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 09:12:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id sC4fAsBzP19JKwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 09:12:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 32338A1202; Fri, 21 Aug 2020 09:11:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727986AbgHUHLu (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 03:11:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727907AbgHUHLm (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 03:11:42 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18BECC061385 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:11:42 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id u21so462182ejz.0 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:11:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=A7002B1FAcwCDVUObHOePcfzoOQKLPQFGoLw3Ly97fo=; b=fHKpNm6xgaGrPl6weHyKvuMKGy9JwVcEZGlSWRpHR9A6n4MGV2s9AAlqvd9IZLhoV1 fDw6JFHxULSKM1JZat2vhGZFTHoZg42JhIJqcBSP7gHD+AjCTYsc5E2UHHuP69TmUqyX qikAfLEkChBNt83fsOpz4NduWrhsRI9n4F1i8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=A7002B1FAcwCDVUObHOePcfzoOQKLPQFGoLw3Ly97fo=; b=ZSFf/Cf7sPUgak8OuEZeyoNLEO/gQJQYHr4xWN7NoIvN5t2yXIYUcR0aNy2DtmkrX+ OdRd+6kgQzvvtPc/yfIarluDDTEkd34rOmIhX7mOcz7pfBWu2XWw63IHOGlPQ1PYOp2w RZOpzVmpfe2EzcYKkuUiBQDRhqMnxfANxN0KGJpsNuOhs5R8sfJ7iEF5EQsXEdWMIaj2 L880AD7Yyw4BvWxIBJB79EKmL9ohGPL3Q3g2UIqW20sj+Y6Pz1nu0mr9kw6E2RoNh+/s OdDcL7a/+lSNtY1D8xmZxNirFbUQaP8c3tuW/4uOpea9N8PcGItm/zMt8fN3EW1BY6Ho MXzg== X-Gm-Message-State: AOAM530ghwzOiqyMmKLq1S2SxSnD7YviTrQUxkLn/PedDV1VHhjXjBkf 1KQS4LgdZL7PYEf869pH/RkGinK19Uc9sw== X-Google-Smtp-Source: ABdhPJxKB/WMSNZpwOIx/Ia6h0hpMZcf0KtfKbwLmjdSdccoaDuuvQFXfkJrpjNKB/xG/i3jV7LDbg== X-Received: by 2002:a17:906:59b:: with SMTP id 27mr1697745ejn.56.1597993900488; Fri, 21 Aug 2020 00:11:40 -0700 (PDT) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com. [209.85.128.52]) by smtp.gmail.com with ESMTPSA id d7sm750480ejk.99.2020.08.21.00.11.40 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Aug 2020 00:11:40 -0700 (PDT) Received: by mail-wm1-f52.google.com with SMTP id k20so800946wmi.5 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:11:40 -0700 (PDT) X-Received: by 2002:a05:600c:2050:: with SMTP id p16mr2444179wmg.154.1597993898999; Fri, 21 Aug 2020 00:11:38 -0700 (PDT) MIME-Version: 1.0 References: <20200821062526.16689-1-sonnysasaka@chromium.org> In-Reply-To: <20200821062526.16689-1-sonnysasaka@chromium.org> From: Sonny Sasaka <sonnysasaka@chromium.org> Date: Fri, 21 Aug 2020 00:11:28 -0700 X-Gmail-Original-Message-ID: <CAO271m=eB=HRUXReW8BUWooU5mfz=yQfwq0Dp1KZyWbqc9KPCg@mail.gmail.com> Message-ID: <CAO271m=eB=HRUXReW8BUWooU5mfz=yQfwq0Dp1KZyWbqc9KPCg@mail.gmail.com> Subject: Re: [PATCH BlueZ] device: unset disconnecting flag when connection is removed To: BlueZ <linux-bluetooth@vger.kernel.org> Cc: Joseph Hwang <josephsih@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 32338A1202 X-Rspamd-UID: 1e90a1 Dear Maintainers, Please ignore this patch as it is broken. Apologize for the mistake. On Thu, Aug 20, 2020 at 11:25 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > From: Joseph Hwang <josephsih@chromium.org> > > A disconnecting flag has been used to avoid race condition > between the service browsing thread and the disconnecting > thread. We need to unset the flag when connection is removed. > > --- > src/device.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/src/device.c b/src/device.c > index 7b7808405..5ab591dd4 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -3041,6 +3041,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > "Paired"); > } > > + if (device) > + set_client_diconnecting(device->client, false); > + > if (device->bredr_state.connected || device->le_state.connected) > return; > > -- > 2.26.2 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wAlCIWV2P1+z1AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 09:23:17 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EG80H2V2P1/ZOwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 09:23:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 06E95A1274; Fri, 21 Aug 2020 09:23:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728369AbgHUHWD (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 03:22:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727955AbgHUHWB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 03:22:01 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D670FC061385 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:21:59 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id o5so602208pgb.2 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cPRYxgB2XxX7Z1aiBzTSI/wL9Ebvg2gjReZiaambCFo=; b=jYElMMjXdG1bg9pmnmr1kINJzz5f4CH+FPxvNf9UX2zqLwkhT3cuaFuPu3ggVeS8NV PctT9lbrnRfAMQXYDY22gsdCYJ9+NnM550iPXKGw5T0U+EgBdV+kUmmEsUTYS2DEZQ7x LIiqMSE5Skpt9IktZ+RLq+zE/wU2V7r8sOp70= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cPRYxgB2XxX7Z1aiBzTSI/wL9Ebvg2gjReZiaambCFo=; b=H+1hx4Dy3v4UXyr2X/GeEHQKO53ESGSMlRYjNv6MWXZpZkcw9iRVVG7PBbdMjQHlS3 MiCLmlhz3yaua3+7f/4+YkiLBYGhToFB4q0o4jxxWhw4aO7fZpIAepTNyeTsyOlCkKI7 u06aJFLIjVsCPUBhyJCOWhz0X3bYi5gY8V1jmBUTDE7Pd+ZcaAKcSSHRZ1Q70YLmC1Qm BT1vys3Sxs4pdUyAIIpUQI0RMQaf0cMHjf3Tt7n5r9mH68JOgdehj1urJwKxK9r75pE4 TUdwWLH7R6VL/xe1YO+WtqW/eMSfbYfjFrBJ3YpzMbZvzTk15/hM756BTfXm4yne1Hd5 ctlA== X-Gm-Message-State: AOAM530Kq1SI43EaP8WheM+F28edaj6XsJ2bVEhnrwVnpQLa8Jl33GO5 Kd6AQAB7HL9SZoZ0F7lFuXXPsDWhfBhXGg== X-Google-Smtp-Source: ABdhPJyhI0Q+WhRibjLdrsdfzsSfVkR8i/RRC8A7VoUnkhthbnIh3rF1irjC8iEcvWysQtBTJGsTaw== X-Received: by 2002:a63:3fcf:: with SMTP id m198mr1291656pga.400.1597994518826; Fri, 21 Aug 2020 00:21:58 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id d127sm1371218pfc.175.2020.08.21.00.21.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2020 00:21:58 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org> Subject: [PATCH BlueZ] shared/mgmt: Provide timeout in mgmt_send() Date: Fri, 21 Aug 2020 00:21:55 -0700 Message-Id: <20200821072155.18834-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 06E95A1274 X-Rspamd-UID: 3b2bcb This patch adds mgmt_send_with_timeout() to help callers who want to use mgmt_send with timeout handling. Ideally, all mgmt_send() caller should use timeout, but in this patch only UNPAIR_DEVICE mgmt command is known to have no-reply problem in the kernel. This prevents bluetoothd from getting stuck in a state of waiting for kernel MGMT reply forever. We still need to fix the kernel side for the missing reply. --- src/adapter.c | 8 +++--- src/shared/mgmt.c | 62 ++++++++++++++++++++++++++++++++++++++++++++--- src/shared/mgmt.h | 6 +++++ 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..787d1bbb6 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -114,6 +114,8 @@ static const struct mgmt_blocked_key_info blocked_keys[] = { 0x22, 0x8e, 0x07, 0x56, 0xb4, 0xe8, 0x5f, 0x01}}, }; +#define DEFAULT_MGMT_TIMEOUT 2 /* Timeout for MGMT commands (secs) */ + static DBusConnection *dbus_conn = NULL; static bool kernel_conn_control = false; @@ -7217,9 +7219,9 @@ int btd_adapter_remove_bonding(struct btd_adapter *adapter, cp.addr.type = bdaddr_type; cp.disconnect = 1; - if (mgmt_send(adapter->mgmt, MGMT_OP_UNPAIR_DEVICE, - adapter->dev_id, sizeof(cp), &cp, - NULL, NULL, NULL) > 0) + if (mgmt_send_with_timeout(adapter->mgmt, MGMT_OP_UNPAIR_DEVICE, + adapter->dev_id, sizeof(cp), &cp, NULL, + NULL, NULL, DEFAULT_MGMT_TIMEOUT) > 0) return 0; return -EIO; diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c index 277e361a6..7e70aba43 100644 --- a/src/shared/mgmt.c +++ b/src/shared/mgmt.c @@ -38,6 +38,7 @@ #include "src/shared/queue.h" #include "src/shared/util.h" #include "src/shared/mgmt.h" +#include "src/shared/timeout.h" struct mgmt { int ref_count; @@ -60,6 +61,11 @@ struct mgmt { void *debug_data; }; +struct mgmt_pending_request { + unsigned int request_id; + struct mgmt *mgmt; +}; + struct mgmt_request { unsigned int id; uint16_t opcode; @@ -69,6 +75,8 @@ struct mgmt_request { mgmt_request_func_t callback; mgmt_destroy_func_t destroy; void *user_data; + /* Timeout for the request if > zero, otherwise timer is not used. */ + int timeout_seconds; }; struct mgmt_notify { @@ -157,6 +165,8 @@ static void write_watch_destroy(void *user_data) mgmt->writer_active = false; } +bool mgmt_pending_timeout(void *user_data); + static bool send_request(struct mgmt *mgmt, struct mgmt_request *request) { struct iovec iov; @@ -184,6 +194,14 @@ static bool send_request(struct mgmt *mgmt, struct mgmt_request *request) mgmt->debug_data); queue_push_tail(mgmt->pending_list, request); + if (request->timeout_seconds > 0) { + struct mgmt_pending_request *pending_request = + malloc(sizeof(struct mgmt_pending_request)); + pending_request->request_id = request->id; + pending_request->mgmt = mgmt; + timeout_add(request->timeout_seconds * 1000, + mgmt_pending_timeout, pending_request, NULL); + } return true; } @@ -267,6 +285,29 @@ static void request_complete(struct mgmt *mgmt, uint8_t status, wakeup_writer(mgmt); } +bool mgmt_pending_timeout(void *user_data) +{ + struct mgmt_pending_request *pending_request = user_data; + struct mgmt *mgmt = pending_request->mgmt; + const struct mgmt_request *request = + queue_find(mgmt->pending_list, + match_request_id, + UINT_TO_PTR( + pending_request->request_id)); + + free(pending_request); + + if (!request) + return false; + + /* Pretend that kernel has replied with TIMEOUT status. */ + request_complete(mgmt, MGMT_STATUS_TIMEOUT, request->opcode, + request->index, /* length */ 0, + /* param */ NULL); + + return false; +} + struct event_index { uint16_t event; uint16_t index; @@ -571,10 +612,12 @@ static struct mgmt_request *create_request(uint16_t opcode, uint16_t index, return request; } -unsigned int mgmt_send(struct mgmt *mgmt, uint16_t opcode, uint16_t index, - uint16_t length, const void *param, - mgmt_request_func_t callback, - void *user_data, mgmt_destroy_func_t destroy) +unsigned int mgmt_send_with_timeout( + struct mgmt *mgmt, uint16_t opcode, uint16_t index, + uint16_t length, const void *param, + mgmt_request_func_t callback, + void *user_data, mgmt_destroy_func_t destroy, + int timeout_seconds) { struct mgmt_request *request; @@ -590,6 +633,7 @@ unsigned int mgmt_send(struct mgmt *mgmt, uint16_t opcode, uint16_t index, mgmt->next_request_id = 1; request->id = mgmt->next_request_id++; + request->timeout_seconds = timeout_seconds; if (!queue_push_tail(mgmt->request_queue, request)) { free(request->buf); @@ -602,6 +646,16 @@ unsigned int mgmt_send(struct mgmt *mgmt, uint16_t opcode, uint16_t index, return request->id; } +unsigned int mgmt_send(struct mgmt *mgmt, uint16_t opcode, uint16_t index, + uint16_t length, const void *param, + mgmt_request_func_t callback, + void *user_data, mgmt_destroy_func_t destroy) +{ + return mgmt_send_with_timeout( + mgmt, opcode, index, length, param, callback, user_data, + destroy, /* timeout_seconds */ 0); +} + unsigned int mgmt_send_nowait(struct mgmt *mgmt, uint16_t opcode, uint16_t index, uint16_t length, const void *param, mgmt_request_func_t callback, diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h index 7caeb3844..9aea64010 100644 --- a/src/shared/mgmt.h +++ b/src/shared/mgmt.h @@ -46,6 +46,12 @@ bool mgmt_set_close_on_unref(struct mgmt *mgmt, bool do_close); typedef void (*mgmt_request_func_t)(uint8_t status, uint16_t length, const void *param, void *user_data); +unsigned int mgmt_send_with_timeout( + struct mgmt *mgmt, uint16_t opcode, uint16_t index, + uint16_t length, const void *param, + mgmt_request_func_t callback, + void *user_data, mgmt_destroy_func_t destroy, + int timeout_seconds); unsigned int mgmt_send(struct mgmt *mgmt, uint16_t opcode, uint16_t index, uint16_t length, const void *param, mgmt_request_func_t callback, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WMh1AONmP1/2EQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 08:17:07 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gNbeOOJmP1/u+QAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 08:17:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 52483420EE; Fri, 21 Aug 2020 08:17:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725908AbgHUGQ7 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 02:16:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbgHUGQ6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 02:16:58 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A246DC061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:16:58 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id mw10so380166pjb.2 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:16:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DDwu5BrtHT0GUTjSCVzrISlqfRedLF7fjEJej4jrdw0=; b=J67vyKvQKaqoVBADWghS2x0hYbNL+miW3jRTs4563mo9NevCpvLYzrWuxL5zAPYPz0 XEgSH2G6rC6QGzYRLHgNQ0LFkkdx7mSUr5t52REDy/0VWWiRig3ow+9JZldOm6EA0whJ ydr5go4g14bLkCR/gJJ352iomAksNNDmw1UJg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DDwu5BrtHT0GUTjSCVzrISlqfRedLF7fjEJej4jrdw0=; b=CKlzqAVcbs6sT62/gE+Lnvs4TQYZu/apuPZ7JpeAwkWQg525LCZTK+dlhSPpllrqcM cAV8p/sj49U0N6f9wk/1dxOScF0brvvyfhgy7SnHhGZZd1/vHFJO0JsIDCtYHTzNDTZ2 kTK8+sQUhjhGLZodKxxtLkypYArMgdydWWNg5S0/ASM+qcCEOhLsElR45INgDQ4IaO8B Us+v2PiUuPq0+sJ0pq5IY5Xjm67yNMkvGx1aytZD6BC9s7mnrZlTtIH7nEDB32RaAVRs nhACksbUt1l1CM4s4bNr41Vw+xnB7mNY8epwJtCZsDaVGwt+zPkwBJiw1wK/TIghK6wL V5Kw== X-Gm-Message-State: AOAM5334JS1gE/GNwXbMil7UxYQKcQNKu+y7QK9laE1NMks88dBkZOrg DDHl/PR0tm5OMQnzQf+u2fnXD7v5RvTzmg== X-Google-Smtp-Source: ABdhPJz42FHgF+9Bli7lNnvQN69Wi60wbJ37qV2Pw9Xd++UNMA6KL+xYDuYauHUvRkev3trHCXTgIw== X-Received: by 2002:a17:902:fe0d:: with SMTP id g13mr1140105plj.287.1597990616558; Thu, 20 Aug 2020 23:16:56 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id h1sm927356pgs.77.2020.08.20.23.16.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 23:16:55 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Joseph Hwang <josephsih@chromium.org> Subject: [PATCH BlueZ 1/2] gatt: StartNotify is not allowed when device is disconnecting Date: Thu, 20 Aug 2020 23:16:42 -0700 Message-Id: <20200821061643.16278-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 52483420EE X-Rspamd-UID: 216b8e From: Joseph Hwang <josephsih@chromium.org> This patch fixed a bluetoothd crash in register_notify_cb(). The crash is incurred by an exception that under some situation, a characteristic may be freed when register_notify_cb() is invoked. When a device is disconnecting, the device interface would hold valid for a while until the disconnection procedure between the client and the server is completed. If another process happens to request to start notification of a characteristic on the disconnecting device, it may incur a problem. In this case, the client would still send the StartNotify request since the characteristic object is still valid. However, the characteristic may be freed soon and become invalid when the corresponding callback function is invoked later. This leads to the bluetoothd crash due to the segmentation fault. To handle the exception, if another process requests to start notification when the device is disconnecting, it should reject the request. Tested on Chrome OS that this patch fixes bluetoothd crash in register_notify_cb(). --- src/gatt-client.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gatt-client.c b/src/gatt-client.c index 20c3fbec2..c706307c7 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -1545,6 +1545,12 @@ static DBusMessage *characteristic_start_notify(DBusConnection *conn, const char *sender = dbus_message_get_sender(msg); struct async_dbus_op *op; struct notify_client *client; + struct btd_device *device = chrc->service->client->device; + + if (device_is_disconnecting(device)) { + error("Device is disconnecting. StartNotify is not allowed."); + return btd_error_not_connected(msg); + } if (chrc->notify_io) return btd_error_not_permitted(msg, "Notify acquired"); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oC5XAqB3P19Q3QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 09:28:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oDa1AKB3P1+tVgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 09:28:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ED0D6417C0; Fri, 21 Aug 2020 09:28:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727854AbgHUH20 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 03:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727784AbgHUH2Z (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 03:28:25 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D956CC061385 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:28:25 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id a79so649883pfa.8 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=f3sU0357hYiDl5l/vHKQ4nLAzIRHctOnyhKqk4fMM/Q=; b=TYaU/oTLt1fs416s8kkfo9n0n6L1TdbJmfyDGQmTDNtDL7XH49zN0s7hkjU07FDC0B R0M3hAi5RpMvGga1vSYErUVUtNXxm/pBMBwxxyPs2SKlvnNsq3kar0cgu2IjmgcxrmQh xP6Uqx2RRf223OdUvMcqtiKfa/UOyJ1abMtQM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=f3sU0357hYiDl5l/vHKQ4nLAzIRHctOnyhKqk4fMM/Q=; b=BDqBSHhYURdetT1Kdptxy7nyZsEn/pdT6WdnrEQYSipqzrg2nau6+Ee7phigpuPief xomS632OsE8xmHRtaq+qjYNY52+h3f/cWeS4AVj2O4ktfwnAzRci5jMcEv9gqi6Ok4xi 2pPagO3CKjeRGsRPujnqwPUDYV22VTfd0GjoMFavR6WO2zrmW4rElFSPX1A87UH1os3M ncVNeKGhXNgCfkUBjBbYztMepZTBTbWIDaxqNvwUBfBpsvnX9sv/a8ZCMGpfNQ2BlmG+ mmsUa7fIL1O46O1f77zvAq3hBXmKdfuSqV93alid5sPwbcw3Q7j4TIHKxyv3ZUckGM7j DI5g== X-Gm-Message-State: AOAM532Qofm3m86NZWFrKEBmlkTiTD7wClhkHiKdJw1U9iyesaX9+NNB MkEhQBDtx0X0T2ueum0ZTX3nk46UC773mg== X-Google-Smtp-Source: ABdhPJzqy+/iP4ViJxqQ8/TjUyQY+yF0/st8pMQObEoU7lfZDsERwyx7u8bFzUd13gpO7SZmlo4YEA== X-Received: by 2002:a63:441c:: with SMTP id r28mr1390657pga.84.1597994905039; Fri, 21 Aug 2020 00:28:25 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id b15sm1107738pgk.14.2020.08.21.00.28.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2020 00:28:24 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Miao-chen Chou <mcchou@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Subject: [PATCH BlueZ] client: Add cancel-pairing command Date: Fri, 21 Aug 2020 00:28:12 -0700 Message-Id: <20200821072812.19131-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: ED0D6417C0 X-Rspamd-UID: ad3483 From: Miao-chen Chou <mcchou@chromium.org> This adds cancel-pairing command which can be used to cancel the ongoing pairing. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- client/main.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/client/main.c b/client/main.c index 9abada69f..da877b546 100644 --- a/client/main.c +++ b/client/main.c @@ -1742,6 +1742,39 @@ static void cmd_pair(int argc, char *argv[]) bt_shell_printf("Attempting to pair with %s\n", proxy_address(proxy)); } +static void cancel_pairing_reply(DBusMessage *message, void *user_data) +{ + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == TRUE) { + bt_shell_printf("Failed to cancel pairing: %s\n", error.name); + dbus_error_free(&error); + return; + } + + bt_shell_printf("Cancel pairing successful\n"); +} + +static void cmd_cancel_pairing(int argc, char *argv[]) +{ + GDBusProxy *proxy; + + proxy = find_device(argc, argv); + if (!proxy) + return; + + if (g_dbus_proxy_method_call(proxy, "CancelPairing", NULL, + cancel_pairing_reply, NULL, NULL) == FALSE) { + bt_shell_printf("Failed to cancel pairing\n"); + return; + } + + bt_shell_printf("Attempting to cancel pairing with %s\n", + proxy_address(proxy)); +} + static void cmd_trust(int argc, char *argv[]) { GDBusProxy *proxy; @@ -2816,6 +2849,8 @@ static const struct bt_shell_menu main_menu = { dev_generator }, { "pair", "[dev]", cmd_pair, "Pair with device", dev_generator }, + { "cancel-pairing", "[dev]", cmd_cancel_pairing, + "Cancel pairing with device", dev_generator }, { "trust", "[dev]", cmd_trust, "Trust device", dev_generator }, { "untrust", "[dev]", cmd_untrust, "Untrust device", -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GDgxC7d5P19SuAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 09:37:27 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MGnGCbd5P1+LewEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 09:37:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 256B3A1306; Fri, 21 Aug 2020 09:37:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728023AbgHUHhV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 03:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727846AbgHUHhU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 03:37:20 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97F6CC061385 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:37:19 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id r4so520229pls.2 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8vbCiEt2lQZ7BLZaVTo8wOjdJdYQD5oyGSM9VtQ9BgU=; b=UOLsSM9x2C7zqgGj0vnr8q9Zgj8Fd2daTUYnhBevvuYOZPJNfQhfsy4IY9S23igZNR JWQYDQvuLpO6+57WflKpqtLQYphLAP/HXwzCIHzZkYNn8ljDxuxV9DAMxief/ZUyoQ6x aOzz4WRc32O5Qzd+NlwZoCW44Q2I8TxmNwGqA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8vbCiEt2lQZ7BLZaVTo8wOjdJdYQD5oyGSM9VtQ9BgU=; b=OQ2VLau2GVTMjwfsKwPshsMidyFVFdEmRssDJ/M99DEABOLJJubGLB1sqQm8NcaNee ++DQsKIz+22YvJFwcsa+aoTM5HARKcve5oghr3Jvn7Z0Ixzxhj84lqIQ0LWkLga6hd8W EjPzdklvSllYte5F/TTPAkYO7EkK+nywNWiZcp8xGZvzYDvuENG+nASHh9ThX+WlD+H5 hGYlq9N0cIjsEDcP6y8pH0hSIUJN/aQ5yUw8CaBeq78GjjHAAPj6gNHDRK3jwqP8wYBa D6KhxGr4e+5JGxKGCRUHy2Er1gv5R9oa4pwS0bqqnmOzBOTxn+5QuGdRmz48XMAEMn7a 3CYA== X-Gm-Message-State: AOAM530KxWNywcqKbk8QKLCAh/u2aXqCBXGp4dlJxLUPOeGhMrgiFNl0 jstkUWL024CVQoICHwymLH4iW1uZ7e6KIQ== X-Google-Smtp-Source: ABdhPJycApEimhqrhyRS+RwBMb3+2V28lXmK+9nJ5yW9yEpJLUXKKcRYzQr6RPlJxAtceydWGNHuXA== X-Received: by 2002:a17:90a:b787:: with SMTP id m7mr1372078pjr.169.1597995438373; Fri, 21 Aug 2020 00:37:18 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id k125sm1247807pga.48.2020.08.21.00.37.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2020 00:37:17 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [PATCH BlueZ] adapter: Fix crash in discovery_disconnect Date: Fri, 21 Aug 2020 00:37:14 -0700 Message-Id: <20200821073714.19626-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 256B3A1306 X-Rspamd-UID: 0ea575 discovery_disconnect crashed because the adapter pointer has been freed before. This patch makes sure that discovery list is cleaned up before adapter pointer is freed. Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- src/adapter.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..c0b02bf3f 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -5316,12 +5316,25 @@ static void free_service_auth(gpointer data, gpointer user_data) g_free(auth); } +static void remove_discovery_list(struct btd_adapter *adapter) +{ + g_slist_free_full(adapter->set_filter_list, discovery_free); + adapter->set_filter_list = NULL; + + g_slist_free_full(adapter->discovery_list, discovery_free); + adapter->discovery_list = NULL; +} + static void adapter_free(gpointer user_data) { struct btd_adapter *adapter = user_data; DBG("%p", adapter); + // Make sure the adapter's discovery list is cleaned up before freeing + // the adapter. + remove_discovery_list(adapter); + if (adapter->pairable_timeout_id > 0) { g_source_remove(adapter->pairable_timeout_id); adapter->pairable_timeout_id = 0; @@ -6846,11 +6859,7 @@ static void adapter_stop(struct btd_adapter *adapter) cancel_passive_scanning(adapter); - g_slist_free_full(adapter->set_filter_list, discovery_free); - adapter->set_filter_list = NULL; - - g_slist_free_full(adapter->discovery_list, discovery_free); - adapter->discovery_list = NULL; + remove_discovery_list(adapter); discovery_cleanup(adapter, 0); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6JC1EpR7P19l8AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 09:45:24 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id YPcAEZR7P1/hjQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 09:45:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 34812A1267; Fri, 21 Aug 2020 09:45:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727006AbgHUHpR (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 03:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbgHUHpQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 03:45:16 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2837C061385 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:45:15 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id h12so617725pgm.7 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ahNzFwqsXNzsJ6fzog/DY5DWWrZLWO8A13L3oZbfyg8=; b=X7y9Y/AN/biKpTBgZSJBaxsFJAYgnfRDFH6DvAqxyp/vs9MS8VM0tATkIeoz0ntKYY k5JI4rp5GaOWQ2Xg38/I5nYfCNCrUV05+xV8pRPDAH3Nj2MMG4JgSRnXMi1KpFXsS0lm 95EYdzLICPpRv5dYmJWT0+2MzythZHCw35KfE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ahNzFwqsXNzsJ6fzog/DY5DWWrZLWO8A13L3oZbfyg8=; b=ENI4Y4f2ygUpQWftCSO0+R8naX4zwz7APPc/TZ8eFFDZlXR9qu9VA6WyJM8J3LeuDv p2JIakOtmxbxZHmLaKkY9kMM/W1YkzBaeChY6k9b+S1RyA81VdXDCUXhQrT7IdAan4sb G8b7B4zZCc0g/vZAC03JGdGh5A7RmwYfjX4VXqgLpN4iMOVqRSqh9+E0mvFAsL8ZUU+x 9WXIMi6g8wUOZcub7shWzs6Dfs5tx+8J/HIiQGe5kKQuK/kGxjO3QHNKnQ9dZXP5M8IU H8xmDJ4/qewAEDmNt0IYq6j8Pw7Ta/T39cjQcgU9ds4YIDv2/1oMYn7tFs8ASTk4Opo4 K5Uw== X-Gm-Message-State: AOAM531j7LuZ56lSIy2zjF1+7gMnHyIHcx11m5Hc9BAyZjD9ATTqxsXR qPbMBLe40xZEQRhGUGOCgfjruZ7FiAL03A== X-Google-Smtp-Source: ABdhPJwZgs15uFYMeynHzgtBUTSG141REStkT1pHWE8rSqsPE0hItxdojYPOboeSEpuMtMxib37d3Q== X-Received: by 2002:a63:3710:: with SMTP id e16mr1454661pga.140.1597995915145; Fri, 21 Aug 2020 00:45:15 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id w14sm1628078pfj.220.2020.08.21.00.45.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2020 00:45:14 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [PATCH BlueZ] device: Fix race condition between device connection and disconnection Date: Fri, 21 Aug 2020 00:45:12 -0700 Message-Id: <20200821074512.19985-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 34812A1267 X-Rspamd-UID: b6e5bc When Connect() is called and waiting for return, dev_disconnected may be called due to MGMT_EV_DEVICE_DISCONNECTED event from kernel. In that case reply to client that the connection failed otherwise the dbus method will timeout because bluetoothd never replies. Tested with simulation of a lot of Connect() to bluetooth devices and check that error is returned from bluetoothd rather than dbus timeout when this race condition happens. Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- src/device.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/device.c b/src/device.c index 7b7808405..55e7b4042 100644 --- a/src/device.c +++ b/src/device.c @@ -3006,6 +3006,7 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type) void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) { struct bearer_state *state = get_state(device, bdaddr_type); + DBusMessage *reply; if (!state->connected) return; @@ -3020,6 +3021,17 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) device->disconn_timer = 0; } + // This could be executed while the client is waiting for Connect() but + // att_connect_cb has not been invoked. + // In that case reply the client that the connection failed. + if (device->connect) { + DBG("connection removed while Connect() is waiting reply"); + reply = btd_error_failed(device->connect, "Disconnected early"); + g_dbus_send_message(dbus_conn, reply); + dbus_message_unref(device->connect); + device->connect = NULL; + } + while (device->disconnects) { DBusMessage *msg = device->disconnects->data; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EKsTDgZ+P19v/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 09:55:50 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6DZrDAZ+P1/pbQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 09:55:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2A27A420E1; Fri, 21 Aug 2020 09:55:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728236AbgHUHzY (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 03:55:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728087AbgHUHzS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 03:55:18 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E2A0C061385 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:55:18 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id d22so683894pfn.5 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=z4BsBm4/JaybyWDiNEa/bs5RXulRrirwodkdVtO+qdI=; b=Svj3xn8vjjkw4I9/qdmVCZhG9PJ6VPW5bsS6q5zU/LDg1/Z0gbc3KUWZAuIzNly1S0 2aae/orbI5V6AYL2aw4N8gKOi6P6z4AvHYf6Q+Z4vQcOdkVpyYbA+SSbgJYBRN3AZIC+ 1apboJ9kUPbB2LXBNxTvr5xvWZcQdwMWK6EJg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=z4BsBm4/JaybyWDiNEa/bs5RXulRrirwodkdVtO+qdI=; b=uj2dtfqKyBDugkq42es2LQWCMEu3nYyGFTdoYyFDKd+uxpRuDGDCe2cztlFRvK2xdd hkUEGaQtjPJ95EYzPZueH2+i9SDQph5BObfZlINfuCeTO21zzGTx+XlnBnXgDyPP3y0p SSzSC80FFY79ZkVTXPS1BkDnN2A7ENEMdM5/umLabY+/g/Xaw/o9vp0gJh2dXWRxpyOC uihQsr3kHZ1pywRfC8G1Slh0XAHNJ8rfn7c66VK6UGwvU+06EHgkjqqEyBRQmdIlR3rF 41OpCpoSdqc+9DBkZJusPhW2KAeN8udj4xN2skQDOoDudAlz6UPW0OoVTO2Pm6qISLYb AWFQ== X-Gm-Message-State: AOAM5320/ATjtuRHe5g8vNp5iRJzFtaVbFGyMpgLfcvhH8pHp4+28NYf pRrIFJYS2Ai62QyGtzFfCdOtMgeMefyXBg== X-Google-Smtp-Source: ABdhPJxrit4zHO6bnmydW0jd4DmXQCkSicuyLWkypCaL5v4gc72JRbDRHD2YelE3hFZHIhLIq2yGyA== X-Received: by 2002:a05:6a00:90:: with SMTP id c16mr1543782pfj.200.1597996517807; Fri, 21 Aug 2020 00:55:17 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id f6sm1622827pfa.23.2020.08.21.00.55.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2020 00:55:17 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Miao-chen Chou <mcchou@chromium.org>, Yoni Shavit <yshavit@chromium.org>, Alain Michaud <alainm@chromium.org> Subject: [PATCH BlueZ] sixaxis: Fix a crash caused by the return of udev_device_get_property_value Date: Fri, 21 Aug 2020 00:55:14 -0700 Message-Id: <20200821075514.20406-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2A27A420E1 X-Rspamd-UID: 982a9e From: Miao-chen Chou <mcchou@chromium.org> This adds a NULL check before calling sscanf(). Reviewed-by: Yoni Shavit <yshavit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- plugins/sixaxis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c index 939fed759..996f85dd6 100644 --- a/plugins/sixaxis.c +++ b/plugins/sixaxis.c @@ -411,7 +411,7 @@ get_pairing_type_for_device(struct udev_device *udevice, uint16_t *bus, hid_id = udev_device_get_property_value(hid_parent, "HID_ID"); - if (sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3) + if (!hid_id || sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3) return NULL; cp = get_pairing(vid, pid); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AH6pCtSFP19CVwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 10:29:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id KCYICdSFP1/tCgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 10:29:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 45254420E3; Fri, 21 Aug 2020 10:29:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727817AbgHUI3C (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 04:29:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726243AbgHUI24 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 04:28:56 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C02B1C061385 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 01:28:54 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id g26so733844qka.3 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 01:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=7MQPpOTbX5csooEfwnHVSCw7zchY6zqWZMxc9Cy4IOw=; b=dwi6yygMLaNPrW5W0IcxWHdIDsGw7p3hdbaD7SpxcGo/dKwUvn18Cmu/uQEgDxboTT 5LRNmRAyUv7fEoL1Rkak6Q1gga4eQtK+SqKURKokRgUkG88YmNdRETSs7O1KzMjiqB3e FLKvv6aQGyEN1Xbp1HYGD3fuTekreWtxI08jfEimlgysuvmFJl+w4UUohhhs7F23wf2E Rcu/dTFeq28/0AGEoyZe4JprH345RxNXyZkLXnDxR6vxm6C/bbQAWhQIPrShR4JcT0lH EqS+Qao78RGP/5kJoNmW86b5a6qyUHXgeUZoRBRqsrin6oPA5qAAwYAOp5GvntVIQ85A SrRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=7MQPpOTbX5csooEfwnHVSCw7zchY6zqWZMxc9Cy4IOw=; b=exAF7P8yh1Zvpx4L6RXcAdNCURUMxoMcIgGRyCIWimLdPeqWzTji/lnq6cMyA1zWJD MTASixR4nHDyOU8v5Xjmzx3xGZYw9Df/HPpnk0epiYxvD3VQmg67DUmwgPYgb3nC3xtb 6sXhet1gCyqTLloSuxqmzJ8QlNv4rTA/wRItW7wcF0M1WZEdLMgrqrFUN+tbxZ2j5LQn uj8PxElapO/fbIAFsxnkj7REzbuI/o1cBu6Eg8+a9lIFvEfBuuXLa1wNhund0moXFUHe TvRbkKF1aGaYhkL6Yw/oORdGDYQ9tm2jfjbxZP3snnvHxI8wxs+/tvYspUPNb3+F0XP2 GMzQ== X-Gm-Message-State: AOAM531N3CaKykeAsuPsfsAnJvesyYUMDaSOZ9Amfeco3d8mTQrmb9O5 A/aPsNBx9spYFxaqnpuaJ71YBCwQoXcuXA== X-Google-Smtp-Source: ABdhPJzMET23NDbBd3/WGF8u3jEmLF+5WLH06XvcCMTYAaeerCg95/19/j4D6OHk3Gucj4itpWzW8A== X-Received: by 2002:a05:620a:38a:: with SMTP id q10mr1783838qkm.382.1597998532276; Fri, 21 Aug 2020 01:28:52 -0700 (PDT) Received: from [172.17.0.2] ([104.209.173.203]) by smtp.gmail.com with ESMTPSA id s124sm1103916qke.102.2020.08.21.01.28.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 01:28:51 -0700 (PDT) Message-ID: <5f3f85c3.1c69fb81.b01a1.3a86@mx.google.com> Date: Fri, 21 Aug 2020 01:28:51 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3923685707088330364==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, sonnysasaka@chromium.org Subject: RE: [BlueZ] sixaxis: Fix a crash caused by the return of udev_device_get_property_value Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200821075514.20406-1-sonnysasaka@chromium.org> References: <20200821075514.20406-1-sonnysasaka@chromium.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: 45254420E3 X-Rspamd-UID: 7a930c --===============3923685707088330364== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 1: T1 Title exceeds max length (75>72): "sixaxis: Fix a crash caused by the return of udev_device_get_property_value" --- Regards, Linux Bluetooth --===============3923685707088330364==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uHn/CuhmP19jbAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 08:17:12 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id uJ2CCehmP1/O0wAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 08:17:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 223A5420DB; Fri, 21 Aug 2020 08:17:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726332AbgHUGRB (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 02:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbgHUGRA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 02:17:00 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27A5DC061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:17:00 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id j13so376121pjd.4 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:17:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=51rft0zd8lDE1RWSK7jDf9MZdT3wh7FXXkl7Ry3F10c=; b=CX0npRCU0PzecA4Px8UGqAWigN7MjREnLUFvogq/WcKTMyiSlyl9lr6y2H+thLXBMG wph736DPh8WGMxApMAfr6O5BSycP2LvkohTsL0as4yaxHjsRXSywatD8KOvcuTJg2TEj xNAL9b2JP2Kg7tAMngUimS11N2OR8tFlHsbX4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=51rft0zd8lDE1RWSK7jDf9MZdT3wh7FXXkl7Ry3F10c=; b=RcWQbV4vG56MieykIrXT3CFccts2SYCTdjrT7a1LqzuxL5QgzSrVVZG8u43jaegBSM gtPalSQgJBoEXHC53lNFapTwWKU3z6uGNoH+QCfRsKX5BOV1bqkbISA+6pI8UrcZf49v VjGs/5/tNfQPY1xVjMv1mUu+9a3KYj85Aq7YyR0c2lz1A0GK5XCD2AkYxFFFGtKbQcOg wv7B9AzNyEWVVqSkOKUM9qIKMB7x0SYTEe6vzRGf/28Y8EatVTHz2zipN3bC1txa1m8L ON+IdwDkrWjAIYQoiXLxKNpI6JjupXsuT/P0t4bhhUcZtJ905b7vMi9OlQi+7jy6732a WXCg== X-Gm-Message-State: AOAM532JPEYruXjiHXXdxleoHogxCAtphD7QgNCI4S8ZOghhFwBzipXg Sho8PRhlgjTED8kQLSwxzjn5uwFtaViw3g== X-Google-Smtp-Source: ABdhPJwLOE3yFWfFPUGWgU8bWD3qlm2BVz3nriWt7I4JaOe7U1pwhJXt0YxCRKB6u3nJlCdVpuRQSg== X-Received: by 2002:a17:902:7616:: with SMTP id k22mr1220002pll.25.1597990619465; Thu, 20 Aug 2020 23:16:59 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id h1sm927356pgs.77.2020.08.20.23.16.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 23:16:58 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Joseph Hwang <josephsih@chromium.org> Subject: [PATCH BlueZ 2/2] doc/gatt-api: Add new error for StartNotify Date: Thu, 20 Aug 2020 23:16:43 -0700 Message-Id: <20200821061643.16278-2-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200821061643.16278-1-sonnysasaka@chromium.org> References: <20200821061643.16278-1-sonnysasaka@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 223A5420DB X-Rspamd-UID: 2a9fb0 From: Joseph Hwang <josephsih@chromium.org> When a device is disconnecting, StartNotify is not allowed. This adds a new error type to the doc. --- doc/gatt-api.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/gatt-api.txt b/doc/gatt-api.txt index 98fe7487c..04789c6d3 100644 --- a/doc/gatt-api.txt +++ b/doc/gatt-api.txt @@ -186,6 +186,7 @@ Methods array{byte} ReadValue(dict options) Possible Errors: org.bluez.Error.Failed org.bluez.Error.NotPermitted org.bluez.Error.InProgress + org.bluez.Error.NotConnected org.bluez.Error.NotSupported void StopNotify() -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +I3GOuBoP19WZgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 08:25:36 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 0CJbOeBoP1+YxQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 08:25:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 606F4420DF; Fri, 21 Aug 2020 08:25:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726002AbgHUGZb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 02:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbgHUGZa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 02:25:30 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B68ADC061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:25:30 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id mt12so383068pjb.4 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bA5MyBizmygKQda+oeo0TYdwB/AeAf0aaD0m7ntaAyk=; b=S9PH1WtEk0y3bdfhwaFG9/XSVmRM+19aPN4lZL6FRZdu8VbFq5a8QIZqBkGDFMsnEQ NFMKJwaNq9scn0TxUm4kXtDUCQPugARpoTZSk3AhTRoupyvzz6rUvIw2xCIc6dgSSbdB L+HULMdm1ovdFHT22J5nLoojPyFHcfTJWSn2Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bA5MyBizmygKQda+oeo0TYdwB/AeAf0aaD0m7ntaAyk=; b=aHqDqmYxcjunYMcnNkfwi/tWZ91PWBT17SQeEWi0+rX7H4xT/l9DFyuvzy6ZZcfl5I vNcoqUIm/pucgugcNuV9eANCA+ZQSRsz7ArBKoWiIYvyNM5j8bky7jNOhn3ZBcS1SSAX Hfu5+VfkIJBVGx4A4LAsUPJXMGLiEGqmQwn43qPjxwVu37QCTAxvG9wOQE/OMKaDLUaL N2iRj2aute/w5H95yAqqoddjywzdmlxXg51xVAUx3m+S1U9pTzc81lQNdcAiSb4kMQUV livQB6S3QOoO37qnQErfRGw0Rp/mMwHLhPN6OxJYE+mIXOSkoeT/reqHTjOS8DWM4Ouh Es0g== X-Gm-Message-State: AOAM532Afz8CenBBaOVzAflTSSI9WSaSJDiIei4zdkv/j45epZuX6vrt hf5U8zvTwciuXPHXlybfbraflGRBLtUpeQ== X-Google-Smtp-Source: ABdhPJx9w8QmpvzKORFE8qRe83Rgn2YnXKiVeaUGG4jUrNwCmno6uNTcnILf7sey75jWdDEtvGS5OQ== X-Received: by 2002:a17:902:c111:: with SMTP id 17mr1341653pli.46.1597991129811; Thu, 20 Aug 2020 23:25:29 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id c207sm1078895pfc.64.2020.08.20.23.25.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 23:25:29 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Joseph Hwang <josephsih@chromium.org> Subject: [PATCH BlueZ] device: unset disconnecting flag when connection is removed Date: Thu, 20 Aug 2020 23:25:26 -0700 Message-Id: <20200821062526.16689-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 606F4420DF X-Rspamd-UID: 53eb12 From: Joseph Hwang <josephsih@chromium.org> A disconnecting flag has been used to avoid race condition between the service browsing thread and the disconnecting thread. We need to unset the flag when connection is removed. --- src/device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/device.c b/src/device.c index 7b7808405..5ab591dd4 100644 --- a/src/device.c +++ b/src/device.c @@ -3041,6 +3041,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) "Paired"); } + if (device) + set_client_diconnecting(device->client, false); + if (device->bredr_state.connected || device->le_state.connected) return; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oCV3MaVqP1/wjwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 08:33:09 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id UP5iMKVqP1+I4gAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 08:33:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CDE06417C0; Fri, 21 Aug 2020 08:33:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726806AbgHUGdE (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 02:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbgHUGdD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 02:33:03 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8E0BC061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:33:03 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id e4so399693pjd.0 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:33:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ewx2UKfu+NjCOZFtWd55EizWMyt5AaNSgj2mGWFAxI4=; b=P5W329dNu5cbLJG4u9IExeMAIgAscJGO/FXry9yEWLECslzaTUn9x72zmPKKDMCw+/ nsdI12vx5RGlRHZmGov5sPfUv+DPJChX2IJf8u5A8E2BCl0shR5tBJ+eiKkNWmbTUWHF yvnOwi9Zxh0zN377UD61QRXyw//EjFZKzCK2g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ewx2UKfu+NjCOZFtWd55EizWMyt5AaNSgj2mGWFAxI4=; b=gPzdEftoI75ukfWwJmXsWzycPRrz9j6THLVF9Xq7CQtdAdjLQ3c6yNU7jgjVZLavnQ u0TAxT1tavq2OkvVSlZMrcM8GXRM+EG128SsLXVp55JK3anVH7RiaqWX8q6stTLGrJBt kh+vQ5OnMC8ABrfdFSOlNNJ8qJ4T1z2vez1GOz/YqTmYfCA/I+e+CCS5cU1HBFU6F46S pu4nKWDlja5hrEJ0Zi7yLGMwr3gxrAM18+nNphIYPGayHz24zGYxCmYt3hrpgu2atFEb GJg2j/CmdQQ/s0thpQnYuXT20ZfcN0MdvHoaN9KS5mCs85FnN1ZfLz2ayR3etaidvYtt IhgA== X-Gm-Message-State: AOAM530Ubew8U32fAS9vkYh5+9mUx7ZED6C2F+1yvvpk8XCBmUrwmYLd AykaFkOxPJaKmGTQ/Ty+cNzhGQQs8R6fOw== X-Google-Smtp-Source: ABdhPJzsQbqTT7D0tmj2jzWfQGs/CxibK1qc4xSLLiSfNBVy/rFD7q0n+kFVXFDsEzJhx27Cdg6eEg== X-Received: by 2002:a17:90b:110a:: with SMTP id gi10mr1256133pjb.206.1597991582967; Thu, 20 Aug 2020 23:33:02 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id t14sm1010315pgb.51.2020.08.20.23.33.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 23:33:02 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Miao-chen Chou <mcchou@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Subject: [PATCH BlueZ] adapter: Log the power state change of adapter to info level Date: Thu, 20 Aug 2020 23:32:59 -0700 Message-Id: <20200821063259.17020-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: CDE06417C0 X-Rspamd-UID: 606f23 From: Miao-chen Chou <mcchou@chromium.org> This changes the log level of messages in adapter_start() and adapter_stop() in order to have better visibility on the power state of adapter in bluetoothd log. Tested that on Chrome OS this has helped debug many issues more easily. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- src/adapter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..9ffe8e7e4 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -5258,7 +5258,7 @@ static void adapter_start(struct btd_adapter *adapter) g_dbus_emit_property_changed(dbus_conn, adapter->path, ADAPTER_INTERFACE, "Powered"); - DBG("adapter %s has been enabled", adapter->path); + info("adapter %s has been enabled", adapter->path); trigger_passive_scanning(adapter); } @@ -6884,7 +6884,7 @@ static void adapter_stop(struct btd_adapter *adapter) g_dbus_emit_property_changed(dbus_conn, adapter->path, ADAPTER_INTERFACE, "Powered"); - DBG("adapter %s has been disabled", adapter->path); + info("adapter %s has been disabled", adapter->path); } int btd_register_adapter_driver(struct btd_adapter_driver *driver) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OJwhFAFsP19WZgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 08:38:57 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id SOVREgFsP1/u+QAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 08:38:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0B746420E2; Fri, 21 Aug 2020 08:38:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727824AbgHUGiv (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 02:38:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726057AbgHUGit (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 02:38:49 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB089C061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:38:48 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o13so556868pgf.0 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NCAHQDySYVytSsRNqhn2N9L1L4hHyPd2rGsJSHa6Rf4=; b=giPa4T6ByZXUBXOlrSZmX+/K1NLQe+yALhKjc5JGrrE56YeTc8rfYzEO3IIqGoC9lH bKNtdCmkC5ti8Cv48BBp1nbzYBNdonm771S9dwy8uhu1moeovIRmqNXsZ2FUQsUAojLm HMvyVCICVnGBAyQovcPtMZ4xQTQxoiyrjcR9o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NCAHQDySYVytSsRNqhn2N9L1L4hHyPd2rGsJSHa6Rf4=; b=SMZg6yHBYN+xhNtyLt0b/MhaGQ7iTQCTK++7tXU3TaQEUEhyW2O6KHHw4JQjm0nHhH /SvsScXgt5w7boFkNdTlS43qwwE3mrwSeF6bKALwoO40dSZDGyzcoWCw1R0LGLCRj5Bf 4se6UGPZgVbMBcEw8AqMOHTJ0+5p1UrXFF4e6JGN0+2DKYZjU1UEWyq8Igj3+7tmBoBt SzIxeHvlpG6l05tIIVzSFmGuDdhzY52i1MmcZZi1jAHuUeS+QcjoxtTW+5xJCjJ2OGCO gGWPqwLlE/GElKrNFSfJNnTc3dA0MTSfeRTwDcqRRFXKQhSi4bz5mGo7h3965WoaRATB J3VQ== X-Gm-Message-State: AOAM533u6UWVtI2TFSY7OHpKRJY7L+VnuBYlH2KPkR7duDHzYyoZoVXp 8eseWg1tE7OrBnhwXMFncI8cZVYR2PnkRA== X-Google-Smtp-Source: ABdhPJzIx+0tnownHaG/a0n+eEOk2FJJwQ+sX8hIRLVS6FTyppAWNrWi/xya3nrQN6PH2ts6B2pEvQ== X-Received: by 2002:a63:705b:: with SMTP id a27mr1172355pgn.405.1597991927713; Thu, 20 Aug 2020 23:38:47 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id q82sm1350106pfc.139.2020.08.20.23.38.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 23:38:47 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org> Subject: [PATCH BlueZ] device: Cleanup att of a device object before assigning a new one. Date: Thu, 20 Aug 2020 23:38:44 -0700 Message-Id: <20200821063844.17349-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.11 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0B746420E2 X-Rspamd-UID: 3c8e55 For some unknown reason, sometimes the controller replies "Command Disallowed" to a Disconnect command. When this happens, bluez kernel strangely reports 2 MGMT_EV_DEVICE_CONNECTED events to bluetoothd. Unfortunately bluetoothd doesn't handle this case so this situation will lead to bluetoothd crashing due to UAF at later time. This patch protects this situation by always cleaning up the att of a device object before assigning a new one. This way the old att will not at later time fire disconnect event which would operate on the already freed device pointer. Tested by repeatedly connecting/disconnecting to a device until the situation happens and checking that bluetoothd doesn't crash. --- src/device.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/device.c b/src/device.c index 7b7808405..e696ba1c6 100644 --- a/src/device.c +++ b/src/device.c @@ -5304,6 +5304,12 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io) return false; } + // This may be reached when the device already has att attached to it. + // In this case cleanup the att first before assigning the new one, + // otherwise the old att may fire a disconnect event at later time + // and will invoke operations on the already freed device pointer. + if (dev->attrib || dev->att) + attio_cleanup(dev); dev->attrib = attrib; dev->att = g_attrib_get_att(attrib); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2HrXOYhuP19LfQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 08:49:44 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 8EFUOIhuP1/T7wAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 08:49:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E6830420DA; Fri, 21 Aug 2020 08:49:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726725AbgHUGtj (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 02:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbgHUGth (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 02:49:37 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35418C061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:49:37 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id g15so457338plj.6 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=x1Z7OatO1HXKzF7erLD+BREMH+p3vSOkNDjwzWS3Zi4=; b=mAcVoR3dXKs5BKQ3DIP/4wlIaJxEk6P4hXh2lrTNBUC0pONq4DRt+Mkv1SW3zCQidi Wmjl2gbpW0LmQfKRHNBfc2fqKuqJ5IVHiqHwo4ZiHoUaysim6yYIbOUXH+BvMuPllejC eCcSbax8MZfDjEsg+2MnwTeY4GhT7jaBIhEio= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=x1Z7OatO1HXKzF7erLD+BREMH+p3vSOkNDjwzWS3Zi4=; b=mcW55GWnse1eNHO6TzvZc19wpfFo+KkLpH3YHUbYzDcK4CiG7eOj+w5N/ZnciyXu3j FAiXbUX8wstPs6GYfmUqwNkLx5ov0HCrRAsg2RugjZOnIMfB3kuu3HsceGd1b9UTrxk1 eDRe3d4rDCUW8x19xPgjL9SHJPSD4NY5INX5l9oTQq+ogtLZ5A/dRntLLNVTaP1BRX0d e5QGR7/8bgo2H/nlr5vsHny+4XijTjeHSxWQn4/616iOb/RXCq2T8WO+18BqQF3TGo6b Qglxy7+mVbaIazSAUAaXBWUMUdYhed92LiEt55PtnpGmhEds+bvl8R8xJ88eTcCLRNWC JaMw== X-Gm-Message-State: AOAM531b0Fob4hrjYeAdJSeMSIDP2g0xW3/8AkF9R6JmBeSQiXvGkm8z gwIfVENOfOFXxVh4pz25j59S8tBl/yMUOg== X-Google-Smtp-Source: ABdhPJyvw6BBTYHc/87WO4SbQ03BXFR5HBNF1YPc2Uj5u+TfY2uKKXV0l3vwVUsos9sN/NyPa8RwpA== X-Received: by 2002:a17:90a:6903:: with SMTP id r3mr1346304pjj.65.1597992576481; Thu, 20 Aug 2020 23:49:36 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id a24sm1238435pfg.113.2020.08.20.23.49.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 23:49:36 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Joseph Hwang <josephsih@chromium.org> Subject: [PATCH BlueZ] adapter: remove eir_data.flags in device_update_last_seen() Date: Thu, 20 Aug 2020 23:49:27 -0700 Message-Id: <20200821064927.17578-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.47 / 15.00 / 200.00 X-Rspamd-Queue-Id: E6830420DA X-Rspamd-UID: 6ddf29 From: Joseph Hwang <josephsih@chromium.org> Bluez has difficulty in pairing with Apple Airpods. This issue is caused by the incorrect selection of BD address type due to two factors: (1) The LE advertising reports emitted by Airpods do not carry eir data flags. (2) If the eir data flags is missing, the found device would not be considered as coming with bredr address for some historical obsolete reason. This patch fixes (2) above. Tested on Chrome OS by pairing with Airpods. Without this patch, the pairing success rate is about 20%. With this patch, the pairing success rate becomes almost 100%. --- src/adapter.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..36bbed2dd 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6628,14 +6628,8 @@ static void update_found_devices(struct btd_adapter *adapter, device_update_last_seen(dev, bdaddr_type); - /* - * FIXME: We need to check for non-zero flags first because - * older kernels send separate adv_ind and scan_rsp. Newer - * kernels send them merged, so once we know which mgmt version - * supports this we can make the non-zero check conditional. - */ - if (bdaddr_type != BDADDR_BREDR && eir_data.flags && - !(eir_data.flags & EIR_BREDR_UNSUP)) { + if (bdaddr_type != BDADDR_BREDR && + !(eir_data.flags & EIR_BREDR_UNSUP)) { device_set_bredr_support(dev); /* Update last seen for BR/EDR in case its flag is set */ device_update_last_seen(dev, BDADDR_BREDR); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kN2eDM1uP19WZgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 08:50:53 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ALdbC81uP19eQQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 08:50:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CC39D420BB; Fri, 21 Aug 2020 08:50:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726504AbgHUGur (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 02:50:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbgHUGup (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 02:50:45 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7826C061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:50:45 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id 6so595696qtt.0 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=aBYYnNgxSeuYf5HXI+jNWeDLYiLmhNA1RcN5JBWgvzg=; b=vbMtUaLMoECZshRjMApuPDXwOmFy91lFqLqAg3UIC1WbXP5R1hxjoAjcKzYJ3EIYcY Dglg2la7eTS1JzV7AE7ZmC61Fs3PH7GdLpgtbH3bzDu9Q0gnlLpPYLT3FjlnJ6kkaGwp edUKTiMElGeA7Uiil3s2Lyfjv62mnlNhg08m0Z9SM9CYCUhy75/3fjw/wLbyYJfHHbAf LYXhtXxGzJ7cLJJ7Z7UJ3qeSzo9Y9dgXTZ3vM0ryTi1AwFDb8X+MViZaaynk/kj68J1X dbA6xSMjZabjBRJPZIo1wy+3m5q+T/Ft8PRYVran1V8cvtGiOXkilNwC7k9FzS+dzzil fJBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=aBYYnNgxSeuYf5HXI+jNWeDLYiLmhNA1RcN5JBWgvzg=; b=H2HewCXrj0i7DFFVmQhsR5hGLka+QNDDOi4p5OW4Q+aUp9bGKTjfv5bOzC0mZVcMhZ M05SzZ3UPrRug8WR0CJprwmIsAkxketp/KyiMiyYULIAhJH8puYT+IoONckWjvrqnZ3W UAf4gBhXSk8LlCzw96t+RPGOLGSLcbVS0JWe+HCj0DTcrgR0q63MERxH2SQ+94IgKOGC byKD+NYEpsUOH7OCaIadO0tFJ7gjetIwSTODCqIGKgPCWpouhcLm/XNDBOeHqecrofMR 8ZmMz3GCJwR7RB/V123ygjO6D+ZSRRlibWZVRIbLafpnUb4GnwjBBNKAtX+ZaPL/Rk3r h4DA== X-Gm-Message-State: AOAM530lymhkXwO6vZEJMbsJMcf6/tWoIjBoXAAZ/dPU05i3aRvWOmSJ ishhELy+5txE7CeuQGknOj4rOICPd9vOiw== X-Google-Smtp-Source: ABdhPJz02+SsGBkw04NtbxdveVofFzEWixWNVu7C98ESgNaybyNITyOo5HCuLey2udxkF6bj1dqWSg== X-Received: by 2002:ac8:3042:: with SMTP id g2mr1500433qte.224.1597992644524; Thu, 20 Aug 2020 23:50:44 -0700 (PDT) Received: from [172.17.0.2] ([40.79.69.72]) by smtp.gmail.com with ESMTPSA id d20sm972818qkk.84.2020.08.20.23.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 23:50:43 -0700 (PDT) Message-ID: <5f3f6ec3.1c69fb81.ad2b4.353c@mx.google.com> Date: Thu, 20 Aug 2020 23:50:43 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============5349863263851167541==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, sonnysasaka@chromium.org Subject: RE: [BlueZ] device: Cleanup att of a device object before assigning a new one. Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200821063844.17349-1-sonnysasaka@chromium.org> References: <20200821063844.17349-1-sonnysasaka@chromium.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 4.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: CC39D420BB X-Rspamd-UID: a0b534 --===============5349863263851167541== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 1: T3 Title has trailing punctuation (.): "device: Cleanup att of a device object before assigning a new one." --- Regards, Linux Bluetooth --===============5349863263851167541==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0LiYAU1vP19LfQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 08:53:01 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id WKZmO0xvP1/uCgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 08:53:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 085C8420E4; Fri, 21 Aug 2020 08:52:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727006AbgHUGwz (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 02:52:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbgHUGwy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 02:52:54 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93E13C061385 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:52:53 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id h21so560343qtp.11 for <linux-bluetooth@vger.kernel.org>; Thu, 20 Aug 2020 23:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=Eh11ksgpyEUh9I9gj2kAy7DQsu0NDTxJUJw+7RFkxhU=; b=DsTI7C/G9CVOHLUZD/KLdLtNks8bkHEG6AxDoE+eSddgHDbLGV7upgYuQUQkfO0jiE 15xBEUsxc2Cw5eHT9vq0ZW3HBtEH3jJZU6M5DYUW16nP1C1sSWPJTcRluOly2EFltHSg wmkDWt1VZkqJUxvgFGCH2zQpPCvyOJb+CRJYpEuoncXUGbSUSJ9914MBZL3KCeQKfvAk mOMang4vvuRYWKrmkvpngghFJoWf5ozT2mSU4zSTI/0xyotgDiE2VJLNZXLslWlbJccv exbk/csRd5mGRAcMwjbDhnMV2mZR7vMQZBcoQQHJjgTjuFq3OIokpSg0C+fT4ZL7x+yv bnig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=Eh11ksgpyEUh9I9gj2kAy7DQsu0NDTxJUJw+7RFkxhU=; b=dBeK44za3Ih6RE7NVBtTkHCQ97yD7SEB9uFwl8hbBJIMxC/2cl1aayykYZ2Qk+Trh3 qp8xQ9OVD/2Od/hHwdxKQAc9u9U6AgA49Mwh/S/gLKzZV/hEDivLEeRpFKvocqOPLWIL uYNWj9KTyTadeyonlqawUkbjUP3LoCDzVyUumG5zxqnTPXkmmmmwCyJozKLKpabE8ZF9 6y9WTFiLD5f//veZfV5+V1bZDjfnXNjacaIBWfhH31F+7Y6WWTrgmAzLL+9LQu5s5L9E vZiEUdEEx8BxR6hkdPnGjTnb/ck8Qjcmv9gv7FHVI9/4drhcs7sBlMMawxcx5jZOXVJV 5VsQ== X-Gm-Message-State: AOAM531ju+bu3EHFcbDk8JznsvgvWbfalrURJi2MQ1J4imgd+4FKufye guLiU2LbZm4Zt7y2UUU+NDX2s0wonurbQg== X-Google-Smtp-Source: ABdhPJy693QDsfIHCkeoqlYekN+9J98Try2w8Qt4Aw+ExoXYdoSeIwrKALFsE4yOAOALtM0K446ujg== X-Received: by 2002:ac8:4cc2:: with SMTP id l2mr1508928qtv.130.1597992772079; Thu, 20 Aug 2020 23:52:52 -0700 (PDT) Received: from [172.17.0.2] ([52.242.89.186]) by smtp.gmail.com with ESMTPSA id w20sm957759qki.108.2020.08.20.23.52.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 23:52:51 -0700 (PDT) Message-ID: <5f3f6f43.1c69fb81.378e2.3465@mx.google.com> Date: Thu, 20 Aug 2020 23:52:51 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============8702165759979088036==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, sonnysasaka@chromium.org Subject: RE: [BlueZ] device: unset disconnecting flag when connection is removed Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200821062526.16689-1-sonnysasaka@chromium.org> References: <20200821062526.16689-1-sonnysasaka@chromium.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ****** X-Rspamd-Score: 8.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: 085C8420E4 X-Rspamd-UID: 1178cd --===============8702165759979088036== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnNyYy9kZXZpY2UuYzogSW4gZnVuY3Rpb24g4oCYZGV2aWNlX3JlbW92 ZV9jb25uZWN0aW9u4oCZOgpzcmMvZGV2aWNlLmM6MzA0NTozOiBlcnJvcjogaW1wbGljaXQgZGVj bGFyYXRpb24gb2YgZnVuY3Rpb24g4oCYc2V0X2NsaWVudF9kaWNvbm5lY3RpbmfigJkgWy1XZXJy b3I9aW1wbGljaXQtZnVuY3Rpb24tZGVjbGFyYXRpb25dCiAzMDQ1IHwgICBzZXRfY2xpZW50X2Rp Y29ubmVjdGluZyhkZXZpY2UtPmNsaWVudCwgZmFsc2UpOwogICAgICB8ICAgXn5+fn5+fn5+fn5+ fn5+fn5+fn5+fn4KY2MxOiBhbGwgd2FybmluZ3MgYmVpbmcgdHJlYXRlZCBhcyBlcnJvcnMKbWFr ZVsxXTogKioqIFtNYWtlZmlsZTo5MjIzOiBzcmMvYmx1ZXRvb3RoZC1kZXZpY2Uub10gRXJyb3Ig MQptYWtlOiAqKiogW01ha2VmaWxlOjQwMTA6IGFsbF0gRXJyb3IgMgoKCgotLS0KUmVnYXJkcywK TGludXggQmx1ZXRvb3RoCg== --===============8702165759979088036==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4NVWLwdyP18JuAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 09:04:39 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0F+ELQdyP18B3QAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 09:04:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2C9914210A; Fri, 21 Aug 2020 09:04:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727779AbgHUHEd (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 03:04:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbgHUHEc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 03:04:32 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BABB9C061385 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:04:32 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id t11so477543plr.5 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 00:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1bpqRclnj9iSVxDziurF6sjEMgtIADpu9kvp6djvcNs=; b=g9SPW7IajK/DVedYtIzXGVTuSCGYJVS5BkgGSK6UXWTT7MBuZLH+fetsFvfIGk9ik4 KJKms+NaXPxtf9J7Y/DSMggTp4Zr8mw8lHKFVPAfLxArcF4D9+mxMtAOpN5iY1ft8k+6 Ao9Lvo7fL958xjftiVTvpvj1G50Ej48ynPnvQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1bpqRclnj9iSVxDziurF6sjEMgtIADpu9kvp6djvcNs=; b=XZhH0Hsa+l5SQ+BURh3We5BRzci3xdyYwgapzis8C5HLd5zGWGdRht32fyd4YUliMZ EVsBQI25HvPSjG5p8f0IiflpE2kNzdDgfPYfHOc+HLfl5nF86PtHyEqWjjVcXawirT85 CtGAJ5dzdY0IpmK0h3r36HqxM8WuUXYV+hEuYwe5LxYuT05VvGqOAsr2auQfEzqjX7nG xBWuUnnKWRNbU2+rseXIWI8DIUl6/589Sw6XG4RWrXnrgnr4l5rpJG7Vb68yiyVfKn0S 0Ei56FwXJeBP1PgbyXNuw67NTZa69dDgEpVLgOapabXPHGLZkLGK704pHzYxiG+FJ49H Rasw== X-Gm-Message-State: AOAM531UFlqRxFM6rJp7Fzs4AO1WGlBuCWJC2eF+f8IhgCHTOL5jrtEA fp63EGlPA5Pe5EtPiQijVJC0QvTPTeKluQ== X-Google-Smtp-Source: ABdhPJzJxZxlIcUcRsGSCpPd5QkpMjDucmxPD7A73v9wd/cFgQTIBEzof6H2z+F/8Lo38i06qi5Pkw== X-Received: by 2002:a17:902:30d:: with SMTP id 13mr1297142pld.300.1597993471653; Fri, 21 Aug 2020 00:04:31 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id s23sm989753pjr.7.2020.08.21.00.04.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2020 00:04:30 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Joseph Hwang <josephsih@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Subject: [PATCH BlueZ] gap: Enable the external flag Date: Fri, 21 Aug 2020 00:04:09 -0700 Message-Id: <20200821070409.18037-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.33 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2C9914210A X-Rspamd-UID: 1af4de From: Joseph Hwang <josephsih@chromium.org> This patch enables the external flag for gap so that the gap service can be exported over D-Bus. Tested on Chrome OS that this fixes https://crbug.com/722987 so that GAP API can be propagated to Android apps. Test Method 1: - Connect to a peripheral. - Use dbus methods to query the org.bluez.GattService1 interface in managed objects. - Confirm that the gap 0x1800 profile was exported like: GattService1 path: /org/bluez/hci0/dev_xx/service0001 service_props: dbus.String(u'UUID'): dbus.String(u'00001800-0000-1000-8000-00805f9b34fb' Test Method 2: - Install BleManager APK attached in C#0 of https://crbug.com/722987 to ARC++ in a chromebook. - Launch the application. - Connect to a Dash robot. Confirm that there are 3 services instead of 2. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- profiles/gap/gas.c | 1 + 1 file changed, 1 insertion(+) diff --git a/profiles/gap/gas.c b/profiles/gap/gas.c index dffa31314..abe5341c0 100644 --- a/profiles/gap/gas.c +++ b/profiles/gap/gas.c @@ -310,6 +310,7 @@ static int gap_disconnect(struct btd_service *service) static struct btd_profile gap_profile = { .name = "gap-profile", .remote_uuid = GAP_UUID, + .external = true, .device_probe = gap_probe, .device_remove = gap_remove, .accept = gap_accept, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CHsxD8j+P1/fxAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 19:05:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id kNGaDcj+P19IhwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 19:05:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1F872A1AE3; Fri, 21 Aug 2020 19:05:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728634AbgHUREp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 13:04:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728737AbgHUREk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 13:04:40 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 333EDC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:04:40 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id a65so2100783otc.8 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zmXkuSmjIU/TZiJV8eCBj0UoFt7Tb7XFXvE7rizzqWY=; b=pvvcnj6Cm2cmkWY/dVUNjTcKU59HJ6hn+5dIq+LMoGCvq2AOcLPS/rlprvWLJL9G63 NaIyPxyyJrx/O3uZVT48J39yzvthB835+Iake0HZWwqPl2LKiMhS/hIQfYWCy2ckvyle Ylf/SXLRt2ZfaogXQM/8ppFLrurmY74CHHGFD2wwE60z5SqIVxCcnJEeKaam6XLQusoB Ika3yxbBC5BT/TxolaOOk23b36czt401C7Vxea6CuJ4pHkrFDeprze4N1+BVzj8rFo9i LjsvC9IpCPNcJGToUICLJU4wiugIxgbl2xLVgMjwlhVI2jUrgFACaaQ0it8DilJrEsXw +J2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zmXkuSmjIU/TZiJV8eCBj0UoFt7Tb7XFXvE7rizzqWY=; b=RvN9/ESx/BUoHEiSppOqgYgrFj8MgRzoAERWnejc4AXde0FPhbhVUHNRIwDC/i9aM4 5MAK8h2Zzv9SQLzO0+1TlJiUNXEdjPRtpeT/ghzlP1+QQkGnwnrvc1glqC6O+ngmARco 8idLo2+k80mP2wC/AgjAkhWyA1P/T6fd3zuZXhVX8qsXETc0Y5DdPl5tU1srysskICIF /zLMbzu2THKzfbk8rNXMGiXJMtcrpkzwXakdrMz1ttgnsAHA1hECfAKz5vtJcpGqUto4 wB2NmESBvXinISTY9gT6SIZcJXDeaNYxJmhoDSQFvtrd/uUCg6YAKr4KzxgkBPCZtn9S M90g== X-Gm-Message-State: AOAM530rioZuyC9o582jv2aMaBkoTTJ3faFoW+/S5n35++Cpak9XBWBY 9/XDWmwarM+JpUbkhikIum3e3WOkNq/cIH4HLNn5AiAE X-Google-Smtp-Source: ABdhPJwCJjf92Y5XiPyAlFTxXjFlF01X/XO+/OFG/UGAXOXwZ01NU787+F7qXpKwmg3g3JNXIAIoy0tpgT03LJUbT8o= X-Received: by 2002:a9d:429:: with SMTP id 38mr2568495otc.88.1598029479041; Fri, 21 Aug 2020 10:04:39 -0700 (PDT) MIME-Version: 1.0 References: <20200821063844.17349-1-sonnysasaka@chromium.org> In-Reply-To: <20200821063844.17349-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 21 Aug 2020 10:04:28 -0700 Message-ID: <CABBYNZ+XpOa1btcjGqQiosn_oSOBki1-wF4B9jny=Gxzswz6-A@mail.gmail.com> Subject: Re: [PATCH BlueZ] device: Cleanup att of a device object before assigning a new one. To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1F872A1AE3 X-Rspamd-UID: 8ed518 Hi Sonny, On Thu, Aug 20, 2020 at 11:40 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > For some unknown reason, sometimes the controller replies "Command > Disallowed" to a Disconnect command. When this happens, bluez kernel > strangely reports 2 MGMT_EV_DEVICE_CONNECTED events to bluetoothd. > Unfortunately bluetoothd doesn't handle this case so this situation will > lead to bluetoothd crashing due to UAF at later time. > > This patch protects this situation by always cleaning up the att of a > device object before assigning a new one. This way the old att will not > at later time fire disconnect event which would operate on the already > freed device pointer. > > Tested by repeatedly connecting/disconnecting to a device until the > situation happens and checking that bluetoothd doesn't crash. > > --- > src/device.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/src/device.c b/src/device.c > index 7b7808405..e696ba1c6 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -5304,6 +5304,12 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io) > return false; > } > > + // This may be reached when the device already has att attached to it. > + // In this case cleanup the att first before assigning the new one, > + // otherwise the old att may fire a disconnect event at later time > + // and will invoke operations on the already freed device pointer. > + if (dev->attrib || dev->att) > + attio_cleanup(dev); It might be better just returning instead of cleaning up just to recreate the instance below or is there a problem reusing the existing instance? btw we need to investigate why the kernel is reporting connected 2 times in a row since that is probably a bug there. > dev->attrib = attrib; > dev->att = g_attrib_get_att(attrib); > > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aL35HPMLQF9/DQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 20:01:23 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id cE1PG/MLQF+YZAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 20:01:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 653D742110; Fri, 21 Aug 2020 20:01:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726767AbgHUSBQ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 14:01:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbgHUSBO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 14:01:14 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05501C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 11:01:10 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id a79so1440141pfa.8 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 11:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8Khob2YLsczWPVhqP71ZFU0FcOyus14dQulSnyUMpZU=; b=VTfsXh9HapOpKLuD0Fxxt0Smw0lYAGLy/xMmbg8TfhtCJzz8z88UpIe4vH5cW2+vQD pGwsKqx524N13PhnmOcsWm0lc45E5EuLfk5QfL5uiBB3MltjB2rmf2j8Um+6IIyIESDg ZD9y4ed7YytQUDap+nyHGPTCdQOS/mY2EJWvg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8Khob2YLsczWPVhqP71ZFU0FcOyus14dQulSnyUMpZU=; b=UdSixIk9EwZZGakvdqZLRy1kTTQrEGTNodUjVSVvvgmscYC/o/tHvw3Suy/sXHKFDV +SmksC87U+XlqpB/Zg+tOq9wzo5Ui2tdCFTPLQ2cPR2z85J2+cf4469t0RWyWsaWMZPQ VG2Ys+Xv1q1zcPuLYxLitRTB8nWMzhiZzeQYVU3zLY0FfyizTVHf69H/pstQVPbnvlHQ 5MfhAweoighPWkv3hRp4SKdTIt7gIpxdqgL12V9EpnoammKqjONlvBP70VbZUNafe2pv NiaZKDYZMuxTKCDPA4ld5zqy1PGWQSkQcU2IqEtn/5uUPLeDcbhnKHriGnOJ+YwqZtib RVIw== X-Gm-Message-State: AOAM5322/6deaJfTr7IPKk2jOjvABuMqfm5lNf7pcISAXASxjGtKd54m fEn/BuxaA+ntoyQwxPgnPGrvPFyD7K8meg== X-Google-Smtp-Source: ABdhPJw/NWcZGUtStCjgBqmTjX8KpgNNBg0ZOXuk71ln/JsvjY6m4AW7NstPVQYmdlObSWmDRn3Kfw== X-Received: by 2002:aa7:9467:: with SMTP id t7mr3322402pfq.64.1598032869268; Fri, 21 Aug 2020 11:01:09 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id s22sm3075558pfh.16.2020.08.21.11.01.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2020 11:01:08 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [PATCH BlueZ v2] device: Fix race condition between device connection and disconnection Date: Fri, 21 Aug 2020 11:01:06 -0700 Message-Id: <20200821180106.21048-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.48 / 15.00 / 200.00 X-Rspamd-Queue-Id: 653D742110 X-Rspamd-UID: 3bf52a When Connect() is called and waiting for return, dev_disconnected may be called due to MGMT_EV_DEVICE_DISCONNECTED event from kernel. In that case reply to client that the connection failed otherwise the dbus method will timeout because bluetoothd never replies. Tested with simulation of a lot of Connect() to bluetooth devices and check that error is returned from bluetoothd rather than dbus timeout when this race condition happens. Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- src/device.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/device.c b/src/device.c index 7b7808405..f59b6c1d0 100644 --- a/src/device.c +++ b/src/device.c @@ -3006,6 +3006,7 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type) void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) { struct bearer_state *state = get_state(device, bdaddr_type); + DBusMessage *reply; if (!state->connected) return; @@ -3020,6 +3021,18 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) device->disconn_timer = 0; } + /* This could be executed while the client is waiting for Connect() but + * att_connect_cb has not been invoked. + * In that case reply the client that the connection failed. + */ + if (device->connect) { + DBG("connection removed while Connect() is waiting reply"); + reply = btd_error_failed(device->connect, "Disconnected early"); + g_dbus_send_message(dbus_conn, reply); + dbus_message_unref(device->connect); + device->connect = NULL; + } + while (device->disconnects) { DBusMessage *msg = device->disconnects->data; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CEoSGQwMQF9S5QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 20:01:48 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eDa9FgwMQF9xYQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 20:01:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 46687421A9; Fri, 21 Aug 2020 20:01:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725948AbgHUSBm (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 14:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725885AbgHUSBl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 14:01:41 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1859AC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 11:01:41 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id m22so3290421eje.10 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 11:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X/uS7c1SrPQDGlp7+Q5FcnPtIsy/vqTZPU3IA+XfqTQ=; b=FPE/daSR//SiJRbTbi/1QePf3Z/YcKWIj4S6yCuox9RMjxBEmeAaNJUh8xaDs9gX8Q sTumnPmgkqVkB1lHEmwIlCSLCSafjnXMV4C/neVbq6IMSQdjVrui7hHsaeXCpF5u2R4b W8CBKUFrDkHQBrUD5ubptomBxQuauwAj8npxo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=X/uS7c1SrPQDGlp7+Q5FcnPtIsy/vqTZPU3IA+XfqTQ=; b=ldrRhiQQrHeNOEt5fwbnoAkh0/vOQKRgLk6zSNvcbtDxNjOBuTlYuPuj/QKImoibbT V+4d7CiwK0VOdTK24u4ADml4DY8jdzh0abmz97sw3zrMqsD5UlXvdTdgGOX8ANt+fH5C JXVgu9KjaDcIaYTzN+IIc7R/9EauBnXm2O7ETeTPUR1oauw8GZQKb8VW3wbViuWmGTi+ yzoEf5nUAOMo8RS95WdbmlHniS5JKzjh0ClFFJ2owaQS2FXj2ME21RHv1s251JvcvFFi o6csg+m5dOZy2X1bO269VIyPQb8Wu2XeTyKn9ks5bw69toLKDPab/nNGkkRU6oGKNFDl M5yg== X-Gm-Message-State: AOAM5337jLAyurMKnb/9wamcnImd64WwnlitlzPCbXml4uJKNKsHsHo+ W7u7OsCcDrjKCls9ZwpBfXjmWmU4ngr0tA== X-Google-Smtp-Source: ABdhPJzQ96rFm5l/JqOACd2Ei5iLfBEfaG+0vgU7aK706Y9wGVqDc3kQnIGWO2WHSyY4bCcovO15GQ== X-Received: by 2002:a17:906:2356:: with SMTP id m22mr4046322eja.124.1598032899246; Fri, 21 Aug 2020 11:01:39 -0700 (PDT) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com. [209.85.221.45]) by smtp.gmail.com with ESMTPSA id m13sm1502181eds.10.2020.08.21.11.01.38 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Aug 2020 11:01:38 -0700 (PDT) Received: by mail-wr1-f45.google.com with SMTP id a5so2740426wrm.6 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 11:01:38 -0700 (PDT) X-Received: by 2002:a5d:42c5:: with SMTP id t5mr3789680wrr.370.1598032898165; Fri, 21 Aug 2020 11:01:38 -0700 (PDT) MIME-Version: 1.0 References: <20200821074512.19985-1-sonnysasaka@chromium.org> <CABBYNZJp2cCqRFa2zrdLnva0UgxvG2eBhYyKr52Rx54sU=znSA@mail.gmail.com> In-Reply-To: <CABBYNZJp2cCqRFa2zrdLnva0UgxvG2eBhYyKr52Rx54sU=znSA@mail.gmail.com> From: Sonny Sasaka <sonnysasaka@chromium.org> Date: Fri, 21 Aug 2020 11:01:25 -0700 X-Gmail-Original-Message-ID: <CAO271m=ZwWs4oKH1xBRD9BwxOdiA05bLgzsA-++gTzQwEv05jA@mail.gmail.com> Message-ID: <CAO271m=ZwWs4oKH1xBRD9BwxOdiA05bLgzsA-++gTzQwEv05jA@mail.gmail.com> Subject: Re: [PATCH BlueZ] device: Fix race condition between device connection and disconnection To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 46687421A9 X-Rspamd-UID: f976ae Hi Luiz, Thanks for the feedback. I have sent a v2 fixing the comment style. On Fri, Aug 21, 2020 at 10:36 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Sonny, > > On Fri, Aug 21, 2020 at 12:47 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > > > When Connect() is called and waiting for return, dev_disconnected may be > > called due to MGMT_EV_DEVICE_DISCONNECTED event from kernel. In that > > case reply to client that the connection failed otherwise the dbus > > method will timeout because bluetoothd never replies. > > > > Tested with simulation of a lot of Connect() to bluetooth devices and > > check that error is returned from bluetoothd rather than dbus timeout > > when this race condition happens. > > > > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > > > > --- > > src/device.c | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/src/device.c b/src/device.c > > index 7b7808405..55e7b4042 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -3006,6 +3006,7 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type) > > void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > > { > > struct bearer_state *state = get_state(device, bdaddr_type); > > + DBusMessage *reply; > > > > if (!state->connected) > > return; > > @@ -3020,6 +3021,17 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > > device->disconn_timer = 0; > > } > > > > + // This could be executed while the client is waiting for Connect() but > > + // att_connect_cb has not been invoked. > > + // In that case reply the client that the connection failed. > > Please use C style comment /* */ > > > + if (device->connect) { > > + DBG("connection removed while Connect() is waiting reply"); > > + reply = btd_error_failed(device->connect, "Disconnected early"); > > + g_dbus_send_message(dbus_conn, reply); > > + dbus_message_unref(device->connect); > > + device->connect = NULL; > > + } > > + > > while (device->disconnects) { > > DBusMessage *msg = device->disconnects->data; > > > > -- > > 2.26.2 > > > > Otherwise it looks good. > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aOKKKj0EQF8vzgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 19:28:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wOYCKT0EQF/uwQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 19:28:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 97043A1AE0; Fri, 21 Aug 2020 19:28:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728223AbgHURWe (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 13:22:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728912AbgHURWa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 13:22:30 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F16AC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:22:29 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id x1so503254oox.6 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BnMS2o5L8BK4kKFKX33LOfETEbgs7A+ySsqSj/uBlAA=; b=pDaGmxfOCfEpdi8+54n5D2wf2kxnFfd9eNxwc9BDw4Iuir0mC0n5Z1AS39VmW9+Gs1 IEDvYAtXQbR56X03pr4boDSaVL4AYUN5PA/WAMWE9pTO08rs6qgoJF+1cMxCEKopSICh IIK6w3XyFerWbmA79An4cGYHhuWWuqHwPevG6iEVKk4wVmrTeU8bA3IXwkr2iAdrgoVI KyiHeLCuc7mbAkD4RRL8Zq+0uYJsrVC1vbouZY5LTg4OqyGs8fiO8wsI/yEd3oNXIxcE AtJ6L3NW87ECMhrDLBSdPRUUVB9HvBiRjcTS+xaB44yLeg+khw1MRTWgWabOJEeFwdAQ duLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BnMS2o5L8BK4kKFKX33LOfETEbgs7A+ySsqSj/uBlAA=; b=D6rtBu/LJSif/hyntoTIQRSvto8DGNi+Ivy/7rwiILUE+j7LDIX7klMHZ6+hqR6Gb1 7IqPVhLBeEWvbtSM79d0IxXPWgPyzfpJiu4DZRY3p45kI1qLuDenYYTUaekXAPFo42vh cWklKnaFjnpyhLQp2rfNfcBexJn275a1TBUCn/9L1YL4wcU/heZFPwD07mhTplyG8EI6 YfUdgh8ktFTNkvh3CFrEXk7ezIGqrBz6gwpHro6ZvWFJGKTt+9ikHBaFn8UNvi1+gG2Q 8gp3JTmkuVIJmBROzikVz53es43BnOOeFjRk5En71pw9o8V/168dhi3+RxP17JC99WDk AnkQ== X-Gm-Message-State: AOAM5306wqd0qpmMuY0Cjo8pDGHNLb8Fko2m9nyOCstzuTXrCv5KX63z 2/MKgYy+bRIQAvi1WjLUrMdxWLgZWtxL0fM/CFI= X-Google-Smtp-Source: ABdhPJwLQEy7nXQr6HRV+e1iqWbdoUMrdq2D0BeCN+XcCfNkpUQgxcfUkZFbZlCJQVgFrRr4mkQtJbBAc3FfUUZ09xU= X-Received: by 2002:a4a:e88c:: with SMTP id g12mr2847650ooe.49.1598030548520; Fri, 21 Aug 2020 10:22:28 -0700 (PDT) MIME-Version: 1.0 References: <20200821064927.17578-1-sonnysasaka@chromium.org> In-Reply-To: <20200821064927.17578-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 21 Aug 2020 10:22:18 -0700 Message-ID: <CABBYNZKW19qDviuBM-6MdnWnvR2+JO+nZOEpSFo7tVJo80v20w@mail.gmail.com> Subject: Re: [PATCH BlueZ] adapter: remove eir_data.flags in device_update_last_seen() To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Joseph Hwang <josephsih@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 97043A1AE0 X-Rspamd-UID: f2128c Hi Sonny, On Thu, Aug 20, 2020 at 11:52 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > From: Joseph Hwang <josephsih@chromium.org> > > Bluez has difficulty in pairing with Apple Airpods. This issue is > caused by the incorrect selection of BD address type due to two factors: > > (1) The LE advertising reports emitted by Airpods do not carry eir > data flags. > (2) If the eir data flags is missing, the found device would not be > considered as coming with bredr address for some historical > obsolete reason. > > This patch fixes (2) above. > > Tested on Chrome OS by pairing with Airpods. > Without this patch, the pairing success rate is about 20%. > With this patch, the pairing success rate becomes almost 100%. > > --- > src/adapter.c | 10 ++-------- > 1 file changed, 2 insertions(+), 8 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..36bbed2dd 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -6628,14 +6628,8 @@ static void update_found_devices(struct btd_adapter *adapter, > > device_update_last_seen(dev, bdaddr_type); > > - /* > - * FIXME: We need to check for non-zero flags first because > - * older kernels send separate adv_ind and scan_rsp. Newer > - * kernels send them merged, so once we know which mgmt version > - * supports this we can make the non-zero check conditional. > - */ > - if (bdaddr_type != BDADDR_BREDR && eir_data.flags && > - !(eir_data.flags & EIR_BREDR_UNSUP)) { > + if (bdaddr_type != BDADDR_BREDR && > + !(eir_data.flags & EIR_BREDR_UNSUP)) { > device_set_bredr_support(dev); > /* Update last seen for BR/EDR in case its flag is set */ > device_update_last_seen(dev, BDADDR_BREDR); > -- > 2.26.2 While I'm fine with this change we might need to bump the kernel version in order to remove the FIXME, also afaik beacons/broadcaster/non-connectable advertisement will never have any flags set so we need to make sure that doesn't end up updating the last seen for BREDR, though if that is how the Airpods are advertising then we will need to rethink how we handle the last seen logic to select which bearer should be connected first. If the Airpods are also responding to inquiry then we can probably check if BR/EDR has been marked as supported when the device uses a broadcast advertisement and not just mark it right away. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SKMBNlATQF8vzgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 20:32:48 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id IDmBNFATQF8TgwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 20:32:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C54E8A010F; Fri, 21 Aug 2020 20:32:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725804AbgHUScm (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 14:32:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbgHUScl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 14:32:41 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F798C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 11:32:41 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id j13so1176831pjd.4 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 11:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=c4fJEJrOfNYX+h8qqGsLJy1ms3/GXFmWCekSgzQoR7w=; b=oToy7o0EiYf15FrNFGitmk6Mhd74HVw1h8gYsaccxRF2dDBd3w2wvgu6fzevyurXSS SRG9Mz3uXluala7EciP9FnlMBGs/uEarwqtGkzF7cZm6zp9K0npcu2xTZMkewlXzBsAD Bpw6Zo0Qw3s7ffdalDtPi9i0xUzUVMTFuRugI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=c4fJEJrOfNYX+h8qqGsLJy1ms3/GXFmWCekSgzQoR7w=; b=EyYs4MExV4anD8aA4ubzsdUZw1f6O2DySlSVzd1i6EZNoXK19KsucJMf5kkKMaKuCb mCuhvdUNgiicM+FJkr027EZ8XzpH5yCkCca+JadmdPiGvNGhI88efcEGocVQ18CzdM51 ip1Op2e8lUMo1tZUO4P8aC+NjmT4POyCqW5iUjRpKvtWI55suPsPVlOn4QY9g6jior9a MjEfGdAH4rLtMjP2C6pjy/PRhm0sB1Ch4N2lsLK+uEweD5bhfLJiPHZfOeey1fxTDo7e NwJgKZ9JEk4YrdXL3GeSe4CHsyinCmKUBC1iXErCAbPRJq7SybUKglHqpzp/l03+CqET njew== X-Gm-Message-State: AOAM530WrchtPkNEi1s35Go8mbXQs2zyshfznSOppWxCkY83YXc2zqnY O5EsZUDOvFYN30P81iSbKXsLBd1LwYB+XQ== X-Google-Smtp-Source: ABdhPJxUFG3aGCGXY7Eddoy2oBtCflcTmDrpTmAYmr7hw5i+UelIhEqT64BDARiCtiGTwNWicskrVw== X-Received: by 2002:a17:902:c404:: with SMTP id k4mr3409459plk.234.1598034760309; Fri, 21 Aug 2020 11:32:40 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id j8sm3344145pfh.90.2020.08.21.11.32.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2020 11:32:39 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Shyh-In Hwang <josephsih@chromium.org> Subject: [PATCH BlueZ] device: Disconnect att before creating a new one Date: Fri, 21 Aug 2020 11:32:36 -0700 Message-Id: <20200821183236.21963-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.08 / 15.00 / 200.00 X-Rspamd-Queue-Id: C54E8A010F X-Rspamd-UID: 067e4c When device_attach_att is invoked, it may be that the old att is still connected (the disconnection hasn't been detected). This patch calls the disconnection callback before creating the new att since the disconnection callback will never be invoked after the new att is created. The disconnection callback also cleans up the att of the device object before assigning a new one. This way the old att will not at later time fire disconnect event which would operate on the already freed device pointer. When there is a HCI LE Disconnection Complete event followed by HCI LE Connection Complete event and they are very close together, this sequence could happen because the kernel doesn't guarantee that the closing of the l2cap socket (due to LE Disconnection Complete event) always happens earlier than the creation of the new l2cap socket (due to LE Connection Complete event). Tested by repeatedly connecting/disconnecting to a device until the situation happens and checking that bluetoothd doesn't crash. Reviewed-by: Shyh-In Hwang <josephsih@chromium.org> --- src/device.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/device.c b/src/device.c index 7b7808405..bed8f38b5 100644 --- a/src/device.c +++ b/src/device.c @@ -5304,6 +5304,15 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io) return false; } + /* This may be reached when the device already has att attached to it. + * In this case disconnect the att first before assigning the new one, + * otherwise the old att may fire a disconnect event at later time + * and will invoke operations on the already freed device pointer. + * The error code (ECONNRESET) is chosen arbitrarily since the + * disconnection event (with an error code) is not yet detected. + */ + if (dev->attrib || dev->att) + att_disconnected_cb(ECONNRESET, dev); dev->attrib = attrib; dev->att = g_attrib_get_att(attrib); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oKCiHMUTQF/jJwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 20:34:45 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CFlCG8UTQF+OYAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 20:34:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 53748A03FD; Fri, 21 Aug 2020 20:34:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725883AbgHUSeg (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 14:34:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbgHUSeg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 14:34:36 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 987ACC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 11:34:35 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id w14so1755812eds.0 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 11:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fr4MQvR1m+Ep3gAECVru7t5+/T/t18aHUrMbvW+Fi+Q=; b=MJV1VMO0bbg6z8FuF9ucxo2muc6KnyEDVNNJti0he6uZFnNPJVI69x6iN7Ins24z2Q bKHtGLOz+AYKjihD1NIcibZueaSwkIYbQVvtA9DgqbOjt4SnhYYuT20QjgTLmC3fDwnp rFHxVqnoldYL7jVGQDUf988pfHktwX3gL3YUM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fr4MQvR1m+Ep3gAECVru7t5+/T/t18aHUrMbvW+Fi+Q=; b=eL6LEYN1CjCAfeHa583CRE5btoKr4CCdqj9nAjaYPR4aPYhw+jiL0/LFUO+Wc8qfcm HEGE93jMIOXGv1ZaajpctfVCMR1juA8MfaCXNguOj4Yg0MJv1PJ2VzNd9XzZw61EpKnE 7WU87HdGBR2S8JikirDXqA+zbIBPMtwSYVDK97YirTilRF2UIBE3/z9JSZgMWvsHBqqL CK6dBve6j3aY5ITes4sBK/tJNWi+25YfhM3L3/KLKnXfM5E4xLoWG7+zGm4MPwXMTKcu greWGa7cZEZuJE0tm7h9ky84RvD8mAU88b6mXEhargSY2SNXo+uDqvHB11I0OlWxcSR3 M8Mw== X-Gm-Message-State: AOAM533+0IaLNNa4G1mqteqDkGn28TuFisS3bxxi+buOxAq57eCboIqA ccjrSIyHsOlCSPZjdyuN/csCxsF/pVb/nQ== X-Google-Smtp-Source: ABdhPJy0jPXP4xwX0oVJEkW7cyFlEOlxOHVCcGYE99IKIh4jo/JOeLGN0dvsGKtEB9FPPiuLhTpk3g== X-Received: by 2002:aa7:c70b:: with SMTP id i11mr4102876edq.272.1598034873870; Fri, 21 Aug 2020 11:34:33 -0700 (PDT) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com. [209.85.221.41]) by smtp.gmail.com with ESMTPSA id sb9sm1755758ejb.90.2020.08.21.11.34.33 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Aug 2020 11:34:33 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id w13so2495940wrk.5 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 11:34:33 -0700 (PDT) X-Received: by 2002:a5d:42c5:: with SMTP id t5mr3897237wrr.370.1598034872695; Fri, 21 Aug 2020 11:34:32 -0700 (PDT) MIME-Version: 1.0 References: <20200821063844.17349-1-sonnysasaka@chromium.org> <CABBYNZ+XpOa1btcjGqQiosn_oSOBki1-wF4B9jny=Gxzswz6-A@mail.gmail.com> In-Reply-To: <CABBYNZ+XpOa1btcjGqQiosn_oSOBki1-wF4B9jny=Gxzswz6-A@mail.gmail.com> From: Sonny Sasaka <sonnysasaka@chromium.org> Date: Fri, 21 Aug 2020 11:34:20 -0700 X-Gmail-Original-Message-ID: <CAO271mmHSZkzR7FnzQUkxuEQQLciC6tcxyaDGufFuge9EVwuYA@mail.gmail.com> Message-ID: <CAO271mmHSZkzR7FnzQUkxuEQQLciC6tcxyaDGufFuge9EVwuYA@mail.gmail.com> Subject: Re: [PATCH BlueZ] device: Cleanup att of a device object before assigning a new one. To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: 53748A03FD X-Rspamd-UID: 2ea91d Hi Luiz, I sent an incomplete patch. I realized that there was a follow up to this patch and I have sent the revision titled "device: Disconnect att before creating a new one". It contains the explanation why the kernel reports connected 2 times as well. Please ignore this patch and review the other patch instead. Thanks. On Fri, Aug 21, 2020 at 10:04 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Sonny, > > On Thu, Aug 20, 2020 at 11:40 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > > > For some unknown reason, sometimes the controller replies "Command > > Disallowed" to a Disconnect command. When this happens, bluez kernel > > strangely reports 2 MGMT_EV_DEVICE_CONNECTED events to bluetoothd. > > Unfortunately bluetoothd doesn't handle this case so this situation will > > lead to bluetoothd crashing due to UAF at later time. > > > > This patch protects this situation by always cleaning up the att of a > > device object before assigning a new one. This way the old att will not > > at later time fire disconnect event which would operate on the already > > freed device pointer. > > > > Tested by repeatedly connecting/disconnecting to a device until the > > situation happens and checking that bluetoothd doesn't crash. > > > > --- > > src/device.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/src/device.c b/src/device.c > > index 7b7808405..e696ba1c6 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -5304,6 +5304,12 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io) > > return false; > > } > > > > + // This may be reached when the device already has att attached to it. > > + // In this case cleanup the att first before assigning the new one, > > + // otherwise the old att may fire a disconnect event at later time > > + // and will invoke operations on the already freed device pointer. > > + if (dev->attrib || dev->att) > > + attio_cleanup(dev); > > It might be better just returning instead of cleaning up just to > recreate the instance below or is there a problem reusing the existing > instance? btw we need to investigate why the kernel is reporting > connected 2 times in a row since that is probably a bug there. > > > dev->attrib = attrib; > > dev->att = g_attrib_get_att(attrib); > > > > -- > > 2.26.2 > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cMWrMusqQF8HpwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 22:13:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SIPRMOsqQF9NPgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 22:13:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D7211420CF; Fri, 21 Aug 2020 22:13:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726440AbgHUUN0 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 16:13:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbgHUUNZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 16:13:25 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8227C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 13:13:24 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id h3so2557629oie.11 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 13:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ogv+gg947UfyAv5wPlmV3C3th73fMj0b7A7pBgIWYUM=; b=CTKor8JSv3h1IhuFFEXMH/vWzFCqAwTSi/oNCqSYmSlhL1LwphH7kMRMO4xf0khd8K R+HgyXm7/JHNu325KSbozapGTKS0QdUlBgYlsqQ6QR2xcCHQkcm0Qi7tQSeVRHT6UKPo rVgCffs3eM+uMAtNfJ+385ofFA7yZlaaulbUyWpeOCYep3yOhl3YLH0wqjJEVLcepCfC 4Y2dWyLx4k+/WbxXIFRAcIoZoIcMBrlw5l7GCXGBWxeesdlhe2SB5ewRDCLHdgYP7MN8 HqbNjVwFBnVsXgISwl9wjNUntRH+Pysr28DasM1LNxa/nJFQqaGcMMPFlc46NZeMcfT1 J+8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ogv+gg947UfyAv5wPlmV3C3th73fMj0b7A7pBgIWYUM=; b=KDKUtuTUBdrnZ7w7PoKlcBO8NsYr1E075QXafIivnFRJc42yqDlQhM8/hExwEbocSR cZIQv2xxix6iGxPyeRFksogs2rfc9nU8SPJ0XoY//Oq1mkeJjdVZcVenuUJzDiUMVe8+ aLqvbuZpnpcLrsXe5AD0MiFV6j0eai0hXfY4k+5XwXkgp1OBBPuihlGfRGH9l3j0EK09 NabO2iLB1rMg9CXpRgNq9a1aIPthccnE69iZfc9UmdaQdArSP8I05BSIYCmBR0UDf8lL AbWNyJKd0Zv6Ed1k1ke4s15aqBRng9Q/pc/8AJzSHuDEA/eyIkVi6yZ/L9gjDajeKiXQ U+uQ== X-Gm-Message-State: AOAM530rBHmYoF1s4doeM5rjXZq7izJkogXJ7ZiUnWF6Ge/tkI/sYTpz UXCfxdAtn3uOkyx1qlhjx4LQujs+03Ca2sAvBG0= X-Google-Smtp-Source: ABdhPJzyuEH20Rcho1zUY2OLbOVBLNUPOmI6SVN5evRXUHV62rrSlmc81qzbBp1Ci4i0yj/18yNNFX4XyiD3w2YhY5k= X-Received: by 2002:aca:5703:: with SMTP id l3mr2727815oib.48.1598040803481; Fri, 21 Aug 2020 13:13:23 -0700 (PDT) MIME-Version: 1.0 References: <20200821183236.21963-1-sonnysasaka@chromium.org> In-Reply-To: <20200821183236.21963-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 21 Aug 2020 13:13:12 -0700 Message-ID: <CABBYNZK5kO+fNXQGdaieQqqTY9bBHRUDQWitqA+-134W7TY1oQ@mail.gmail.com> Subject: Re: [PATCH BlueZ] device: Disconnect att before creating a new one To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Shyh-In Hwang <josephsih@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: D7211420CF X-Rspamd-UID: 4c2a3f Hi Sonny, On Fri, Aug 21, 2020 at 11:36 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > When device_attach_att is invoked, it may be that the old att is still > connected (the disconnection hasn't been detected). > > This patch calls the disconnection callback before creating the new att > since the disconnection callback will never be invoked after the new att > is created. The disconnection callback also cleans up the att of the > device object before assigning a new one. This way the old att will not > at later time fire disconnect event which would operate on the already > freed device pointer. > > When there is a HCI LE Disconnection Complete event followed by HCI LE > Connection Complete event and they are very close together, this > sequence could happen because the kernel doesn't guarantee that the > closing of the l2cap socket (due to LE Disconnection Complete event) > always happens earlier than the creation of the new l2cap socket (due to > LE Connection Complete event). This actually sounds like a bug in the kernel, either it should cleanup the existing sockets or not disconnect them at all if there is a new connection in place, otherwise it quite possible that there will be many more races like this. Have you tried doing something similar with BR/EDR, we actually depend on the socket being disconnected to notify all the profiles so then can cleanup properly. > Tested by repeatedly connecting/disconnecting to a device until the > situation happens and checking that bluetoothd doesn't crash. > > Reviewed-by: Shyh-In Hwang <josephsih@chromium.org> > > --- > src/device.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/src/device.c b/src/device.c > index 7b7808405..bed8f38b5 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -5304,6 +5304,15 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io) > return false; > } > > + /* This may be reached when the device already has att attached to it. > + * In this case disconnect the att first before assigning the new one, > + * otherwise the old att may fire a disconnect event at later time > + * and will invoke operations on the already freed device pointer. > + * The error code (ECONNRESET) is chosen arbitrarily since the > + * disconnection event (with an error code) is not yet detected. > + */ > + if (dev->attrib || dev->att) > + att_disconnected_cb(ECONNRESET, dev); Another way to resolve this is to cleanup earlier at device_remove_connection since we know at that point ATT will be disconnected. > dev->attrib = attrib; > dev->att = g_attrib_get_att(attrib); > > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0I1aEAwsQF8HpwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 22:18:20 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id yGgaDwwsQF/ptQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 22:18:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2B88242112; Fri, 21 Aug 2020 22:18:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726728AbgHUUSI (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 16:18:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbgHUUSH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 16:18:07 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65E66C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 13:18:07 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id l204so2594131oib.3 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 13:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=d6+9BOhrR5CBMlphNNJg78sYIPRCwjEjB32dZ4UOiP8=; b=sKP31evNtzPaZ5YQ7YoXYtGf+tqmE9Y8cYqFQEJgVhJj2crmM8mYDMZ5cmK53BMaz6 I2JphjG3ymla+TsHSGOq6YYjJdicJ+EH2dlotPFg0qidBKEt2NrpE5IKx2Na/dxoBx0E cqejfOYkzFljIDQO4ZjSmewT66fbDV94gh327LWBYW2TZxFlD8Wupjm6JZr2h7O6XEXr +QH3vAJyo9LpTqs6iKoYEVBcSlZSaoJLsVzXKNBe3yRaebzC5bTdn1Te3oJjx0iFwHut mWrdiJuYBRXrbOOx6crBi+8sotHYdxfuS7Mrm+rYsjoE/PMmsMRwArd5865NcNJSDDen C21Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=d6+9BOhrR5CBMlphNNJg78sYIPRCwjEjB32dZ4UOiP8=; b=od1xT0A4eOWj7vBfRG6q+vNEpwAzufbxKg1TQ23WIfw+HY1QfZ17EW9JVHkgaMsaI7 H4RNPCJ892qtLIt0uuBMxnkzgJ8h7DxwSumhj9nCLen9oWjnG5M/DTdVhfjSuO/Aoh0x +k64IcWzLUTbqxNgsDNXQle6HvUyHKwuUCIweyt+2rlEzwnPZ0Rgsk/dcrc6v+QPV4Kr oAkMPxSG51RD+WmqnkLkxbwJxZ2Y5rYLFaRkPF656FyJ7a0/KSslmghv9y/EFcRxdABx 14mHHR9eJ9BQW7Oma69bil8lF08NbK0jbwVbDiUP8GFakOPX7T0z1VE6pStJiLKYq2yT Si9A== X-Gm-Message-State: AOAM533uEqM8eUey0crJS77xkC4Cg/qn11C7r/G/3EfDHEAncN0Yawjq krxh+hbWSybxGcUu5CNq2NehaprDAcKwM5h+q4q6tBZd X-Google-Smtp-Source: ABdhPJxFXkA5hU/UTBAJZYDTTlUfJ7tyLK0PYuiMWApkiDzs3j77K3ZUOIvJ3UcFqp20xm9E/I/2cC+uwLKvo+3Ox9U= X-Received: by 2002:aca:cc50:: with SMTP id c77mr2767021oig.152.1598041086759; Fri, 21 Aug 2020 13:18:06 -0700 (PDT) MIME-Version: 1.0 References: <20200821175838.20761-1-sonnysasaka@chromium.org> In-Reply-To: <20200821175838.20761-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 21 Aug 2020 13:17:56 -0700 Message-ID: <CABBYNZJvBmCnNWAoLaCuv25iuda-2146U_VDYn8BQpVABSDaMA@mail.gmail.com> Subject: Re: [PATCH BlueZ v2] adapter: Fix crash in discovery_disconnect To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2B88242112 X-Rspamd-UID: 566de2 Hi Sonny, On Fri, Aug 21, 2020 at 11:00 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > discovery_disconnect crashed because the adapter pointer has been freed > before. This patch makes sure that discovery list is cleaned up before > adapter pointer is freed. > > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > > --- > src/adapter.c | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..1435e2bd7 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -5316,12 +5316,26 @@ static void free_service_auth(gpointer data, gpointer user_data) > g_free(auth); > } > > +static void remove_discovery_list(struct btd_adapter *adapter) > +{ > + g_slist_free_full(adapter->set_filter_list, discovery_free); > + adapter->set_filter_list = NULL; > + > + g_slist_free_full(adapter->discovery_list, discovery_free); > + adapter->discovery_list = NULL; > +} > + > static void adapter_free(gpointer user_data) > { > struct btd_adapter *adapter = user_data; > > DBG("%p", adapter); > > + /* Make sure the adapter's discovery list is cleaned up before freeing > + * the adapter. > + */ > + remove_discovery_list(adapter); > + > if (adapter->pairable_timeout_id > 0) { > g_source_remove(adapter->pairable_timeout_id); > adapter->pairable_timeout_id = 0; > @@ -6846,11 +6860,7 @@ static void adapter_stop(struct btd_adapter *adapter) > > cancel_passive_scanning(adapter); > > - g_slist_free_full(adapter->set_filter_list, discovery_free); > - adapter->set_filter_list = NULL; > - > - g_slist_free_full(adapter->discovery_list, discovery_free); > - adapter->discovery_list = NULL; > + remove_discovery_list(adapter); > > discovery_cleanup(adapter, 0); > > -- > 2.26.2 Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OO/4GzYsQF/YswEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 22:19:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id CCwLGzYsQF9B4QEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 22:19:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6D7A042112; Fri, 21 Aug 2020 22:18:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726670AbgHUUS4 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 16:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726483AbgHUUSx (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 16:18:53 -0400 Received: from mail-oo1-xc44.google.com (mail-oo1-xc44.google.com [IPv6:2607:f8b0:4864:20::c44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AEEAC061574 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 13:18:52 -0700 (PDT) Received: by mail-oo1-xc44.google.com with SMTP id z10so612155ooi.10 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 13:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oXHXAm4q+TYGHtxOfWBF8ZTfK3HEauWUVopzxyclBjk=; b=ofKZdUWGys1UqhInXDEbybNl9qmjJ3EiTpl72sf9StQEA6gTwvEVJdkXUtZ62OVZ5i yYEfVTrhm6p5/z6EiRIWlJYbxnUylF4/NkfMuECEdOgXcv4VhtZHWIIq+gENmnlX3wV4 Q+0PZOCD6kBCJmFubuwz0+Njkh5QT4ixDKE4H4IQSm8eQowQHvFTW1CUoJeCk36RCyDR 9w9rzfc+6uKC+dDUyiq7RJrESjbdGp3lq2hBJT49xVdeMJEqCvYvioc3PUP5Jn1LoY47 lkpmcOwvnwtLzeTUSujA5iJDcfTcNIIlpMaz7ElHmVz/yGrxyH73h6nFlTs0U71S++r9 AHeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oXHXAm4q+TYGHtxOfWBF8ZTfK3HEauWUVopzxyclBjk=; b=IzDD2jBXRu0BlPq346BB+MEvAf1OQI2RPSXfNt4OzQFPXSc13SiO20FNbyCjYAWsqp uoQJ9Bfdc4NViEmLVOheH8RBEsYXmmb7fJ1s0mQj6PsKiIWI/Ep5Ftes5lB4E62Nj5fH KbJVW4GgiEd3kGIQ+tcqj97hQy5nKw5wZkazZwNnI+psKKtvg+NNSo/A+LaVVihmAQdR 0HmZNd9GkTUZfESTwJTxNgyUaC3BNCIQ4B12GPgIqFLY52cU/e/YmfD5nBKcRnVK8NiF b7JxotMOnqRLeeOJXNo4AI7JIJfoOEyv52d/AdDURQfw76EVPG76HsRajkcMnxRg0JEL U5cA== X-Gm-Message-State: AOAM533s9INyE8CcX8AD7egPwTEfqErR1qYgFoThMThddhlpMwLdNdBQ tCeAK3HxO82z+lOzvonkW4ap/eLrHA2/6X7CMwo= X-Google-Smtp-Source: ABdhPJwTTef4jR876xO5l46J+RUb/Dx3LQwB2H8njjQImcOYvX2HY7XJSn8Xnh8+GX/lt7nlLK/u22zv7AipcgpD+eA= X-Received: by 2002:a4a:380b:: with SMTP id c11mr3392275ooa.17.1598041130670; Fri, 21 Aug 2020 13:18:50 -0700 (PDT) MIME-Version: 1.0 References: <20200821180106.21048-1-sonnysasaka@chromium.org> In-Reply-To: <20200821180106.21048-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 21 Aug 2020 13:18:40 -0700 Message-ID: <CABBYNZLukR4BiogyFSDden0KMVrMaSSTfWO-Eg6h5GGd_kiW+g@mail.gmail.com> Subject: Re: [PATCH BlueZ v2] device: Fix race condition between device connection and disconnection To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6D7A042112 X-Rspamd-UID: 3bfb9c Hi Sonny, On Fri, Aug 21, 2020 at 11:04 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > When Connect() is called and waiting for return, dev_disconnected may be > called due to MGMT_EV_DEVICE_DISCONNECTED event from kernel. In that > case reply to client that the connection failed otherwise the dbus > method will timeout because bluetoothd never replies. > > Tested with simulation of a lot of Connect() to bluetooth devices and > check that error is returned from bluetoothd rather than dbus timeout > when this race condition happens. > > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > > --- > src/device.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/src/device.c b/src/device.c > index 7b7808405..f59b6c1d0 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -3006,6 +3006,7 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type) > void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > { > struct bearer_state *state = get_state(device, bdaddr_type); > + DBusMessage *reply; > > if (!state->connected) > return; > @@ -3020,6 +3021,18 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > device->disconn_timer = 0; > } > > + /* This could be executed while the client is waiting for Connect() but > + * att_connect_cb has not been invoked. > + * In that case reply the client that the connection failed. > + */ > + if (device->connect) { > + DBG("connection removed while Connect() is waiting reply"); > + reply = btd_error_failed(device->connect, "Disconnected early"); > + g_dbus_send_message(dbus_conn, reply); > + dbus_message_unref(device->connect); > + device->connect = NULL; > + } > + > while (device->disconnects) { > DBusMessage *msg = device->disconnects->data; > > -- > 2.26.2 > Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QAxxBuEpQV+TlwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 22 Aug 2020 16:21:21 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id mESNBOEpQV9NYAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 22 Aug 2020 16:21:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4B9FA420D4; Sat, 22 Aug 2020 16:21:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728080AbgHVOVN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 22 Aug 2020 10:21:13 -0400 Received: from mga14.intel.com ([192.55.52.115]:61901 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727899AbgHVOVH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 22 Aug 2020 10:21:07 -0400 IronPort-SDR: ZTcje9Uh/zv6M/uhkptd++BjlOc60N2uSnO87OfBmYf63sC5VtKOk5g30Xn6+lpX+hAMqE1Wvl 8CiWnhJ90Jhg== X-IronPort-AV: E=McAfee;i="6000,8403,9720"; a="154977984" X-IronPort-AV: E=Sophos;i="5.76,341,1592895600"; d="scan'208";a="154977984" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2020 07:21:06 -0700 IronPort-SDR: a77ZLTayAin71VYwXsXwIUiUHlT1uj7TFhG3zGywWYT6mB4sOAWlDw0rskyHZ5gha8yHbFbj2v gUl7x8cDKyhA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,341,1592895600"; d="scan'208";a="372182659" Received: from orsmsx602-2.jf.intel.com (HELO ORSMSX602.amr.corp.intel.com) ([10.22.229.82]) by orsmga001.jf.intel.com with ESMTP; 22 Aug 2020 07:21:06 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sat, 22 Aug 2020 07:21:05 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sat, 22 Aug 2020 07:21:05 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Sat, 22 Aug 2020 07:21:05 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.108) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 22 Aug 2020 07:21:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MAw5qTHmbYgz2bX9643PuvN1+qDY2cx3Pvep8F01omQqtl4mL6pKStGb8vvLCQFyqHlDuvksjY6OkOMMf6+LBN9448Ps73TROxSzo3sxvtK2B8XBTB9lh4/dZUOV3A58ml+TjgGkemflc069Ch0IWaNOBGR4npVEdqKbnhJ0dHIw8gYDhzUlEeXCKyAXJ3aD7Qzk+AK62Sht708OgYFyzALgiZr+ar6L+zn7G5KKtPmclrQk6A1CNRXcyEJ6o/9ohXx0N0MY918+s7AZ34Pct2ESjPfY5iYWJsAetciRARpm0row7JjSYlxvIgEqlJQzWINwwfNT++ij0GwgZHirpg== 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-SenderADCheck; bh=3b+DIDrKr39zHBM8gk+sRn8leTyCuh1pVIVhyqQU+WU=; b=IG3f3XpL2FAEfUvSTZ8UiH5krfNJIjUy8BhAuRZ+k9RkMm5Qg0LYItpmg6I8LqSMlo7k7Kw1dEL+cDBxhTr0MRC6Dl/sVeCoKtghd9lISPOAAfbPm9/XIb/82hD7nC/OZ27wbakcMbUcY98dnOPHzLIHAMQlfR8A3j1VBMjTX3nSXRB2BKnZuzMK4JoL5DNg2+AQGg2s5gFd9Nvcpv/7KQMjoIMQl3ec1DpBnHRJ5XuY/BY+jfsN+6uucC9053td8lU09NuNRFakLOLyUB5D9h85Mbobm4VHlu5qwiodcvCAzqutMcu4D2qe6giq87NycAOyJE/BcfrNAL33Dao2iA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3b+DIDrKr39zHBM8gk+sRn8leTyCuh1pVIVhyqQU+WU=; b=NwLEQCwWX5/EkpW/L2s18mGFvfhNifQ4C6OEzRRYo/dapzpCFuDanCEkDBMDExMuGv+YcHGIU93N/O7szyZg/4YhVOqXTC0SEyLm4YZkL47WvgQ3urOXte8o8CjlqJ2/SQqVe81UhnNeMtNK3LY/UTS/iYsHPxR7jMliJUrd71E= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4682.namprd11.prod.outlook.com (2603:10b6:303:2e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Sat, 22 Aug 2020 14:21:04 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3305.026; Sat, 22 Aug 2020 14:21:04 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: Use valid net key index when handling Send call Thread-Topic: [PATCH BlueZ] mesh: Use valid net key index when handling Send call Thread-Index: AQHWd37J2YpmPaFZ7keIPhkCoQiFVqlEL+6A Date: Sat, 22 Aug 2020 14:21:03 +0000 Message-ID: <f1a03abbda88c79e75779762a88fee04503e258b.camel@intel.com> References: <20200821054856.41857-1-inga.stotland@intel.com> In-Reply-To: <20200821054856.41857-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [134.134.137.73] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7b43ddf1-9e85-4524-41d7-08d846a69a4f x-ms-traffictypediagnostic: MW3PR11MB4682: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MW3PR11MB468244A04AEDD6F138840ECDE1580@MW3PR11MB4682.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 4Wx4repY++WCB2gLIy7DDnmSHLNQOjMuYR5U/AG+lvGlwlQpfj8vk6cuIC9vpzAUaqZAoya4wpYsSDw4A7xz3OyfalTUHNs5RKwVnievbf1lo0/YrCxJZs9LS37HWkz4uldciKNCbuquJpnVdAwtpv8oW1gQFUEZ2gxvZvtF5bHRfdYaJ7aCatjV2ylb4yizVP3KWoGEZeHheVeb5AO63T/RufGE1/jTxG1SxflM322KdxA1zINLx/g0ylhBLalN8ybu5jeyHMqxM9ZSu6ghM37Hk//xnjNMEIFsaxL+dVF6lGrr/6mYthj5xj7t9mLDtge9VJ+HTExmMRGNIsY0yw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(396003)(39860400002)(346002)(136003)(66476007)(76116006)(64756008)(71200400001)(8936002)(66446008)(66556008)(6506007)(26005)(83380400001)(5660300002)(316002)(186003)(8676002)(36756003)(6486002)(478600001)(66946007)(86362001)(6512007)(2906002)(6636002)(2616005)(110136005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: IwoO1wzEJEz6r5kRYNp+nPNjTOtm4NIsRoB76e7KZfHkFVPQR1gDDbZW8lGlP+KhmJJn/n5mlStgDf5q8/V8vKbb6s+pGnoGW/O8ocCxIXhlj3/Qfte5DYxEGxvfk6GFefcM8FeqYukDHfAxBl2lzxk2DbKlLUJD5YSs7GnDlSY+Q/UmG1NkeeBjJG6xgH5jYSJKtrk0Ejv63fO6TysBBc0Lblc1RIN7887yI7Hoj0d/AwIpIKtALcDtbU8pZTj5eJDhFqZVAAI9I5T5zC70wQElGwrNepRZoRezzRjJSl7ENyTaP9j8wKmgWkrKAU3ZYyTlFJGN32E5Shc0rGwi4xv+FiJNBiUfKl3mDoaFQg4L/rqH/L0Y+N71Sk1i1i5XLl1sIacyYoVSMeP4lMA48NOeVrneWTFd2+/7BdwKMgPIUxi+Bjbmr4zl3T4VD8daihTiutAmcWr3kEDoCtA1JElHUkTPfxWTNNWAHA/HyKHRii5Tj36J9KBsNH6MoAAS5+sEahk6NyXarHlAjFx1I86WCDMay2UzgoX9n8x1RxFCFyG7yyilzg3FN7yB0MEm6vJrqgMIoCvnl1dDEFCulp5uetKDJD4V6HSdAchOwxRvuVfQKprhSJ4g41PiNrcOCRfxFDwF1ZDKC9/k1ldISg== Content-Type: text/plain; charset="utf-8" Content-ID: <EEE59306BA73EC4E9C6449835AC4BB6D@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b43ddf1-9e85-4524-41d7-08d846a69a4f X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Aug 2020 14:21:03.8514 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: jxaYo2lm4EBAJDVg2iAAgbMylV2t/puQCDMmm/p/0tpQ603Qcl8Xu34af8WpX1+o+qmI8R2nOPRJ/F4hHOUCJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4682 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4B9FA420D4 X-Rspamd-UID: a0e60b QXBwbGllZA0KT24gVGh1LCAyMDIwLTA4LTIwIGF0IDIyOjQ4IC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBSZXRyaWV2ZSB2YWx1ZSBvZiBib3VuZCBOZXQgS2V5IGluZGV4IGJhc2VkIG9u IHRoZSB2YWx1ZSBvZg0KPiBwYXNzZWQgQXBwS2V5IGluZGV4LiBDaGVjayBpZiB0aGUga2V5IGlz IHByZXNlbnQgYW5kIGZhaWwgZWFybHkNCj4gaW4gY2FzZSBvZiBlcnJvci4gQWxzbywgcGFzcyB0 aGUgY29ycmVjdCBOZXRLZXkgaW5kZXggdG8gbW9kZWwNCj4gbGF5ZXIgaW4gbWVzaF9tb2RlbF9z ZW5kKCksIGluc3RlYWQgb2YgaGFyZCBjb2RlZCAwLg0KPiAtLS0NCj4gIG1lc2gvbW9kZWwuYyB8 ICAyIC0tDQo+ICBtZXNoL25vZGUuYyAgfCAxMyArKysrKysrKystLS0tDQo+ICAyIGZpbGVzIGNo YW5nZWQsIDkgaW5zZXJ0aW9ucygrKSwgNiBkZWxldGlvbnMoLSkNCj4gDQo+IGRpZmYgLS1naXQg YS9tZXNoL21vZGVsLmMgYi9tZXNoL21vZGVsLmMNCj4gaW5kZXggZWI1MTQyNTAzLi43ZTFjNGFi OTIgMTAwNjQ0DQo+IC0tLSBhL21lc2gvbW9kZWwuYw0KPiArKysgYi9tZXNoL21vZGVsLmMNCj4g QEAgLTU0Nyw4ICs1NDcsNiBAQCBzdGF0aWMgYm9vbCBtc2dfc2VuZChzdHJ1Y3QgbWVzaF9ub2Rl ICpub2RlLCBib29sIGNyZWQsIHVpbnQxNl90IHNyYywNCj4gIAkJCWxfZGVidWcoIm5vIGFwcCBr ZXkgZm9yICgleCkiLCBhcHBfaWR4KTsNCj4gIAkJCXJldHVybiBmYWxzZTsNCj4gIAkJfQ0KPiAt DQo+IC0JCW5ldF9pZHggPSBhcHBrZXlfbmV0X2lkeChub2RlX2dldF9uZXQobm9kZSksIGFwcF9p ZHgpOw0KPiAgCX0NCj4gIA0KPiAgCW91dCA9IGxfbWFsbG9jKG91dF9sZW4pOw0KPiBkaWZmIC0t Z2l0IGEvbWVzaC9ub2RlLmMgYi9tZXNoL25vZGUuYw0KPiBpbmRleCAxZWVmZmViOGIuLmVkM2Q5 NTljNSAxMDA2NDQNCj4gLS0tIGEvbWVzaC9ub2RlLmMNCj4gKysrIGIvbWVzaC9ub2RlLmMNCj4g QEAgLTE3NjEsNyArMTc2MSw3IEBAIHN0YXRpYyBzdHJ1Y3QgbF9kYnVzX21lc3NhZ2UgKnNlbmRf Y2FsbChzdHJ1Y3QgbF9kYnVzICpkYnVzLA0KPiAgCWNvbnN0IGNoYXIgKnNlbmRlciwgKmVsZV9w YXRoOw0KPiAgCXN0cnVjdCBsX2RidXNfbWVzc2FnZV9pdGVyIGl0ZXJfZGF0YTsNCj4gIAlzdHJ1 Y3Qgbm9kZV9lbGVtZW50ICplbGU7DQo+IC0JdWludDE2X3QgZHN0LCBhcHBfaWR4LCBzcmM7DQo+ ICsJdWludDE2X3QgZHN0LCBhcHBfaWR4LCBuZXRfaWR4LCBzcmM7DQo+ICAJdWludDhfdCAqZGF0 YTsNCj4gIAl1aW50MzJfdCBsZW47DQo+ICANCj4gQEAgLTE3OTAsMTAgKzE3OTAsMTUgQEAgc3Rh dGljIHN0cnVjdCBsX2RidXNfbWVzc2FnZSAqc2VuZF9jYWxsKHN0cnVjdCBsX2RidXMgKmRidXMs DQo+ICANCj4gIAlpZiAoYXBwX2lkeCAmIH5BUFBfSURYX01BU0spDQo+ICAJCXJldHVybiBkYnVz X2Vycm9yKG1zZywgTUVTSF9FUlJPUl9JTlZBTElEX0FSR1MsDQo+IC0JCQkJCQkiSW52YWxpZCBr ZXlfaW5kZXgiKTsNCj4gKwkJCQkJCSJJbnZhbGlkIGtleSBpbmRleCIpOw0KPiArDQo+ICsJbmV0 X2lkeCA9IGFwcGtleV9uZXRfaWR4KG5vZGVfZ2V0X25ldChub2RlKSwgYXBwX2lkeCk7DQo+ICsJ aWYgKG5ldF9pZHggPT0gTkVUX0lEWF9JTlZBTElEKQ0KPiArCQlyZXR1cm4gZGJ1c19lcnJvciht c2csIE1FU0hfRVJST1JfSU5WQUxJRF9BUkdTLA0KPiArCQkJCQkJCSJLZXkgbm90IGZvdW5kIik7 DQo+ICANCj4gLQlpZiAoIW1lc2hfbW9kZWxfc2VuZChub2RlLCBzcmMsIGRzdCwgYXBwX2lkeCwg MCwgREVGQVVMVF9UVEwsIGZhbHNlLA0KPiAtCQkJCQkJCQlkYXRhLCBsZW4pKQ0KPiArCWlmICgh bWVzaF9tb2RlbF9zZW5kKG5vZGUsIHNyYywgZHN0LCBhcHBfaWR4LCBuZXRfaWR4LCBERUZBVUxU X1RUTCwNCj4gKwkJCQkJCQlmYWxzZSwgZGF0YSwgbGVuKSkNCj4gIAkJcmV0dXJuIGRidXNfZXJy b3IobXNnLCBNRVNIX0VSUk9SX0ZBSUxFRCwgTlVMTCk7DQo+ICANCj4gIAlyZXR1cm4gbF9kYnVz X21lc3NhZ2VfbmV3X21ldGhvZF9yZXR1cm4obXNnKTsNCg== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yLd0JF8rQV+TlwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 22 Aug 2020 16:27:43 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cFX0Il8rQV8ukwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 22 Aug 2020 16:27:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5C76A420BB; Sat, 22 Aug 2020 16:27:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728127AbgHVO1h (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 22 Aug 2020 10:27:37 -0400 Received: from mga09.intel.com ([134.134.136.24]:45620 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728019AbgHVO1f (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 22 Aug 2020 10:27:35 -0400 IronPort-SDR: lQGlaTlU4awUo6tdxGzW3v0lejl2YXacvT4zwqa96IeqUgq3yHyXPjqLfuKQG10fURMsAUGjli MffhHohOBbEw== X-IronPort-AV: E=McAfee;i="6000,8403,9720"; a="156772478" X-IronPort-AV: E=Sophos;i="5.76,341,1592895600"; d="scan'208";a="156772478" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2020 07:27:34 -0700 IronPort-SDR: 5RuZCZ3Ra/pEAdPX9RvsjPag82ornAzRv0BsiBv2rJFFTgXMUPwkphTvPKM8MTIGtQP8FLOMWR o6OoGYLiT1yw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,341,1592895600"; d="scan'208";a="442648192" Received: from fmsmsx602-2.cps.intel.com (HELO fmsmsx602.amr.corp.intel.com) ([10.18.84.212]) by orsmga004.jf.intel.com with ESMTP; 22 Aug 2020 07:27:34 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sat, 22 Aug 2020 07:27:33 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Sat, 22 Aug 2020 07:27:33 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.171) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 22 Aug 2020 07:27:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NXsM5xrlB8U5fFbrxtzXBWhIy913769bjaQl+7x9T2MoBBlSAVGuBa9USBPUh0MLwxym36XQ4CoIywXWbbaE8v01z2cLa4NAX0kgpP6/E8iZM+hI3y8CBqyRuuJPh30xuuAAw4bcHYM1aXGs3by82+zZVxW3yaGEKiELewmAdZ4AAAxdAXY7XtSX6HCEWXmbvpYEl8DDFjEQMc5SOfu/DGEeXHEy6i5j6HvBdFrd9FhsiMc22fNdx21VAuczl7bapS3yQkI6hldyfVMm6knnlbcNQ6ARXB9pc9oYby3eRo8wIDa++At3PgbKdp36BMRAHGBSvJ1f7T6v7TxqNKFg3w== 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-SenderADCheck; bh=8PRzdK51I/ZzG/2yTsjcdoKwIt7bWPCfsToa5DfpvSE=; b=LxI4uHeGtU8lbeI9Fe3LZ4d6qhPa/Gb2ndJGqo7UVcSfidlOaoqaVUNz4G2WrZ7UEmiYUxxFnYZLc6gHwFgL9EZvy7RwEzaTL4T8yPpGtt0FjfXR/hC0ETjumcTeXCtCzhyUexUGFUlX7x72c6j2I5MCytqBA3QB73ty9dYiaBZeoPQF55v99j/a8qrDZgTGugtENEsRbgRD80Jm4mwWw6Y8M0jKGti0sNfgpO31wexkMQUM1poGjUg/TI7ed9SjA/iBBuPpynIH3f6xE7XWoZ8nzprU72NSQfhGi1XLYC7xYqlHTtUqsIsLCxZgcsM8hkZH6GkAYjsn13KVO6uzJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8PRzdK51I/ZzG/2yTsjcdoKwIt7bWPCfsToa5DfpvSE=; b=muXZajqiK4+jJ80l/CB3Cj4R8gQT42ZL4olYN+Ax71I/pAYeH8KPifL/5eFX5SfGI24bMSSViflmErcSvZYX+X73CQlMYwzttupn2CGVNyUda/XyPphPtDX5CNCgHRh86f5xi7yI0qShV0InsK+gI8GtPQRJPRp9xiNF/Goq8kM= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4682.namprd11.prod.outlook.com (2603:10b6:303:2e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Sat, 22 Aug 2020 14:27:32 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3305.026; Sat, 22 Aug 2020 14:27:32 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "daan@dptechnics.com" <daan@dptechnics.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Subject: Re: [PATCH BlueZ 1/1] Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans Thread-Topic: [PATCH BlueZ 1/1] Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans Thread-Index: AQHWdgLUZ2KEwp3CbU2pCdVSfGggMalENLeA Date: Sat, 22 Aug 2020 14:27:32 +0000 Message-ID: <d9b02252be21635e6e572ae9d43e8c3539524f9c.camel@intel.com> References: <20200819082822.64903-1-daan@dptechnics.com> <20200819082822.64903-2-daan@dptechnics.com> In-Reply-To: <20200819082822.64903-2-daan@dptechnics.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: dptechnics.com; dkim=none (message not signed) header.d=none;dptechnics.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [134.134.137.73] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e60aecef-40f5-4ee7-6317-08d846a781c8 x-ms-traffictypediagnostic: MW3PR11MB4682: x-microsoft-antispam-prvs: <MW3PR11MB46829EF647690BBA04BEBBE4E1580@MW3PR11MB4682.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:3513; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: p80KLYlmfyeiXNfXwgE0JlNiQKnQXqRHjbbdbPcq0Xh5fpyk18fcRu52C1g3CkSw3a7EVeFLiMMSUE3BPXsQUFlHUUebu7W3iqJm6tjcqwNuZOeT4lUqZ5CLuuu4PWZEkmK+S9LzkDItjrFB6tpxmQ6xKsn/bK/UcHB7hzMlgQvCBlSfFu1OuklSUgJg2FWioDJv+3/TaGfcNOiBJNEIC8IlAIpGm2cubr8OH1J2aYmhmxql7rADgl96d59enLvmwIHhea+UQvixFFp3J3Ygoaob3yA7lHQvWESeok2e9rkBMgUXz0MjSLFyXWK26aPVhhYu+mtWduNYE4mcQ4KGYA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(396003)(39860400002)(346002)(136003)(66476007)(76116006)(64756008)(71200400001)(8936002)(66446008)(66556008)(6506007)(26005)(5660300002)(316002)(186003)(8676002)(36756003)(6486002)(478600001)(66946007)(86362001)(6512007)(2906002)(2616005)(110136005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 45G5OXAYUPfvcjlFKiWMUVRgYG5Y3GYWym5TgBErwz/em3PE80uwncocrmCwMKsi8hazGqXMVkWS4oGwIJ71Z2z55UrFFN7ImmfeU+LAGkpxpyBeNHhm+9gmYBymLxFfF2gtdt3iDlIaTXYFHy3Bt4La9IMJH5dlCsTqIbkPDx5F1Ur+uDHv1LHbzImjTWL12noQM1Iti6BlFQ3ouHczZEWdaDIqT4+7PVL96j4idrFhIE3dhiMIYXMn/kV7xKOHXJStGqCYPn4/+PmWifMIt7EHKu7GSv5G+lzpnvvxJW3W9iOKfeVIjBZiIUOXV6rd6ignb9wP7KwiuZ31Z/wVVVx/lT7An19hRF1dPplxCFTungoQ+tDV7noOPmSkA/mkeXp3/HE6LdGKXx1oFbp74eXkYr0uuOjUlgB/vwzZSSCJVGCXdIIJJbpvCUrKWNn7VTp5WVTbwGP/PYl6zo5yUWKyOaOgp6RHCGM5d6l3LyHP91ARvxeFdX/xa+zQrqjP2nVElc0D+OZGVsg/OzrW/2IPQgpY/zfcmTZRH6Iwnu0fru5WTtqrnWr48zu1fgLglJdKbWr/TIWZZfdwHXjdGUvjRK/9sQ5qinBvOmajA67MZ1KjRspHcd8cZ6JA/cP1VtnUIXZABAEPPHig21bndQ== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="utf-8" Content-ID: <FD31C39C8ACFE841B917D87B49235E4E@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e60aecef-40f5-4ee7-6317-08d846a781c8 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Aug 2020 14:27:32.2865 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: kCSgW0u+pFwQpQc4923HmCQauWHZLF5XIzlCvKTH7WXgVSNl/iYhyybo/zIlAXHqF7vkp2qM74kVOV6Gyjpgcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4682 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5C76A420BB X-Rspamd-UID: 665269 QXBwbGllZCB3aXRoIGNvcnJlY3Rpb25zIHRvIEdJVCBwb2xpY3kgZXJyb3JzDQpPbiBXZWQsIDIw MjAtMDgtMTkgYXQgMTA6MjggKzAyMDAsIERhYW4gUGFwZSB3cm90ZToNCj4gLS0tDQo+ICBtZXNo L21lc2gtaW8tZ2VuZXJpYy5jIHwgOSArKysrKysrKysNCj4gIDEgZmlsZSBjaGFuZ2VkLCA5IGlu c2VydGlvbnMoKykNCj4gDQo+IGRpZmYgLS1naXQgYS9tZXNoL21lc2gtaW8tZ2VuZXJpYy5jIGIv bWVzaC9tZXNoLWlvLWdlbmVyaWMuYw0KPiBpbmRleCA2N2IxM2ExYjkuLjY3MzA0ZDIwMSAxMDA2 NDQNCj4gLS0tIGEvbWVzaC9tZXNoLWlvLWdlbmVyaWMuYw0KPiArKysgYi9tZXNoL21lc2gtaW8t Z2VuZXJpYy5jDQo+IEBAIC0yMDksNiArMjA5LDcgQEAgc3RhdGljIHZvaWQgY29uZmlndXJlX2hj aShzdHJ1Y3QgbWVzaF9pb19wcml2YXRlICppbykNCj4gIAlzdHJ1Y3QgYnRfaGNpX2NtZF9sZV9z ZXRfc2Nhbl9wYXJhbWV0ZXJzIGNtZDsNCj4gIAlzdHJ1Y3QgYnRfaGNpX2NtZF9zZXRfZXZlbnRf bWFzayBjbWRfc2VtOw0KPiAgCXN0cnVjdCBidF9oY2lfY21kX2xlX3NldF9ldmVudF9tYXNrIGNt ZF9zbGVtOw0KPiArCXN0cnVjdCBidF9oY2lfY21kX2xlX3NldF9yYW5kb21fYWRkcmVzcyBjbWRf cmFkZHI7DQo+ICANCj4gIAkvKiBTZXQgc2NhbiBwYXJhbWV0ZXJzICovDQo+ICAJY21kLnR5cGUg PSAweDAwOyAvKiBQYXNzaXZlIFNjYW5uaW5nLiBObyBzY2FubmluZyBQRFVzIHNoYWxsIGJlIHNl bnQgKi8NCj4gQEAgLTI2MSw2ICsyNjIsMTAgQEAgc3RhdGljIHZvaWQgY29uZmlndXJlX2hjaShz dHJ1Y3QgbWVzaF9pb19wcml2YXRlICppbykNCj4gIAljbWRfc2xlbS5tYXNrWzZdID0gMHgwMDsN Cj4gIAljbWRfc2xlbS5tYXNrWzddID0gMHgwMDsNCj4gIA0KPiArCS8qIFNldCBMRSByYW5kb20g YWRkcmVzcyAqLw0KPiArCWxfZ2V0cmFuZG9tKGNtZF9yYWRkci5hZGRyLCA2KTsNCj4gKwljbWRf cmFkZHIuYWRkcls1XSB8PSAweGMwOw0KPiArDQo+ICAJLyogVE9ETzogTW92ZSB0byBzdWl0YWJs ZSBwbGFjZS4gU2V0IHN1aXRhYmxlIG1hc2tzICovDQo+ICAJLyogUmVzZXQgQ29tbWFuZCAqLw0K PiAgCWJ0X2hjaV9zZW5kKGlvLT5oY2ksIEJUX0hDSV9DTURfUkVTRVQsIE5VTEwsIDAsIGhjaV9n ZW5lcmljX2NhbGxiYWNrLA0KPiBAQCAtMjgyLDYgKzI4NywxMCBAQCBzdGF0aWMgdm9pZCBjb25m aWd1cmVfaGNpKHN0cnVjdCBtZXNoX2lvX3ByaXZhdGUgKmlvKQ0KPiAgCWJ0X2hjaV9zZW5kKGlv LT5oY2ksIEJUX0hDSV9DTURfTEVfU0VUX0VWRU5UX01BU0ssICZjbWRfc2xlbSwNCj4gIAkJCXNp emVvZihjbWRfc2xlbSksIGhjaV9nZW5lcmljX2NhbGxiYWNrLCBOVUxMLCBOVUxMKTsNCj4gIA0K PiArCS8qIFNldCBMRSByYW5kb20gYWRkcmVzcyAqLw0KPiArCWJ0X2hjaV9zZW5kKGlvLT5oY2ks IEJUX0hDSV9DTURfTEVfU0VUX1JBTkRPTV9BRERSRVNTLCAmY21kX3JhZGRyLA0KPiArCQkJc2l6 ZW9mKGNtZF9yYWRkciksIGhjaV9nZW5lcmljX2NhbGxiYWNrLCBOVUxMLCBOVUxMKTsNCj4gKw0K PiAgCS8qIFNjYW4gUGFyYW1zICovDQo+ICAJYnRfaGNpX3NlbmQoaW8tPmhjaSwgQlRfSENJX0NN RF9MRV9TRVRfU0NBTl9QQVJBTUVURVJTLCAmY21kLA0KPiAgCQkJCXNpemVvZihjbWQpLCBoY2lf Z2VuZXJpY19jYWxsYmFjaywgTlVMTCwgTlVMTCk7DQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cGMVKxQsQV8IxwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 22 Aug 2020 16:30:44 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aGSlKRQsQV+bnwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 22 Aug 2020 16:30:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 24ACF420D7; Sat, 22 Aug 2020 16:30:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728127AbgHVOai (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 22 Aug 2020 10:30:38 -0400 Received: from mga02.intel.com ([134.134.136.20]:32392 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727899AbgHVOaf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 22 Aug 2020 10:30:35 -0400 IronPort-SDR: ufC6MvcxdJHVGLzYqQjkWG+tCCykHq9RGOlkkMvGnRk5M9PCzP4wOg1gT7YxAgv9MMr0JwQKmS 3xIOPPVnVP4w== X-IronPort-AV: E=McAfee;i="6000,8403,9720"; a="143495230" X-IronPort-AV: E=Sophos;i="5.76,341,1592895600"; d="scan'208";a="143495230" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2020 07:21:32 -0700 IronPort-SDR: YTkgU0etl9U5p5sl0jMVHDdXOw1rerA8isOAWRXThE/yc4t0680yJpgsWjhnfzq7aI+j2Q+hiJ t34vsvBVIf2A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,341,1592895600"; d="scan'208";a="280498641" Received: from fmsmsx602-2.cps.intel.com (HELO fmsmsx602.amr.corp.intel.com) ([10.18.84.212]) by fmsmga008.fm.intel.com with ESMTP; 22 Aug 2020 07:21:31 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sat, 22 Aug 2020 07:21:31 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Sat, 22 Aug 2020 07:21:31 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 22 Aug 2020 07:21:31 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.108) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Sat, 22 Aug 2020 07:21:31 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XoQqtmgPFQ0XqAs1eFkHfCZiTH4WInQe/JVcN38ytJO57Ng1bSllG8H+Me6tmQ49H8QFQfZzPrZ57QpGCWJpvawzeb2WqFhJbRbg6BnRqGxjU/XM5NBpZqpHEAItN/rcIfCCa/xDRbGtINhvMEwTx7n3wkUMuHDHSSyd7dq07m/3SGRUzKW7QrZeiL4K0iX8jwdYKcaShQa4YobVe4pxVkRWI5eptx9j06UGLcleGn3yx50Vpfq1N0SoXSKKMG6gYPX/l7SlES2IC6iUkpntGL87yIBwgMSYywT8KJW6VIgAHBNsr1KOEDIBqyQxc9WD0hqSjYBnP0r9shnrWR86cQ== 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-SenderADCheck; bh=IpBoXtLiqlrkp+F5/KlmRMbg/1lL9uTtKFak/z+FNCI=; b=VO23zLWbVe6sy8xa6dwWRAT1A6mRk6qc8iu9gIIp1rkyez3zUhPQ30H9+k6kwNuVth5wg6AEdeqflA2drUWaAqFQ1hpl1jA7LduD+8nbs150isnFNLpZ6DCQacGPnjspe1NM5PIXUxCnQgjzIjoxVF4DY06btDJG22bDLYwNgWiEY8bGmITg09gJvQZ9E0o8gICrL80lWpI+Ib0FiPHf4DXeupgGGB/1l0YLouYGdkV5TeBakIK1Ku/EX8c/z9AEYfJyS/w8A5N5QnOME2srkdIREoCdhyMIBb6XyuxfW2Dp8aB591Qmo/1RJEy9CodmY3DJtly/zoZBOiIskX/6Pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IpBoXtLiqlrkp+F5/KlmRMbg/1lL9uTtKFak/z+FNCI=; b=Mi+wI0NEG+k2R4rgnbrorBm34Nz6Ap93HQr634znZlQ7zYetxejedGI6h6dDjEnzVfXOQBxUyLMO/FOmdP9/FdtPjsg1UfwTmANSigG8LNWgLMpNNe8iwBcxKfUcf6buZuTnu3NkLmTwTq04OO2YiSreu2emYbXyY0JJLWp9FAU= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4682.namprd11.prod.outlook.com (2603:10b6:303:2e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Sat, 22 Aug 2020 14:21:29 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3305.026; Sat, 22 Aug 2020 14:21:29 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: Use correct retransmit parameters for publications Thread-Topic: [PATCH BlueZ] mesh: Use correct retransmit parameters for publications Thread-Index: AQHWdrSURgbfRhjX/0m3bY3PKd7kuqlEMaMA Date: Sat, 22 Aug 2020 14:21:29 +0000 Message-ID: <f0d4a10e5916a79e294868813cc9c522df43889a.camel@intel.com> References: <20200820054132.110483-1-inga.stotland@intel.com> In-Reply-To: <20200820054132.110483-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [134.134.137.73] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6097af81-d948-4ed7-7c6c-08d846a6a9bb x-ms-traffictypediagnostic: MW3PR11MB4682: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MW3PR11MB468276128751D243C413DCA0E1580@MW3PR11MB4682.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:1332; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: AUVEOQzhUd26zLaP78Zdw3h6XQ+RULQvF0EhVNU2m3IG4ZWDOb2Thq1gLCKcHz6YrsrMBJMovfYltnqI9UBKF99Tmu2oQwUktYPyGIYeYPCX8tgJDz7V3DiKX+Q4jPHXePaOVvTrQ9imHxvnCeWPbMHmKmpX7IkU1+kmAebg1d3nNwHtP9zbodF1eOvePV8E9Uzgni3JXCR3dZwx0PaBgiNsoeyxn5bDMvKFFWlrkLz2Pd9FUbU6m+ZkItis9HTZV/cxgRxSFp4m4Y+GXXLx15gkMYMk2/yQoomprIWoG/L0xETfnrBAQhOl5B0RxTBhUeSDfBiiR0RoA8xndPE6hg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(396003)(39860400002)(346002)(136003)(66476007)(76116006)(64756008)(71200400001)(8936002)(66446008)(66556008)(6506007)(26005)(83380400001)(5660300002)(316002)(186003)(8676002)(36756003)(6486002)(30864003)(478600001)(66946007)(86362001)(6512007)(2906002)(6636002)(2616005)(110136005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: YwlG76bJcrVNDyWYBkpQeh3NCMyL1Vq6c1TzA75P5qwXGnsOpyNxJmS1cdIEldsUBn9ATDE/CVzEJbhXribO4bKt1u56GInVQ0RFL8+kArv18RTCl7E9pidQi3ESX/VWJsS25j1elqKqqlYH7jgDXgMkNQySzW4X2b/QiUJJyO1XivHrsqNWX634lqEWWk3K7i8OCApAWH3Zvzby9iYvHSl1dylNUG0iFHLYtMoEh/e59r7NFfCe0t5F/Z7+BdR4nKMsPgmKMHAZ2ByzHxDZhXS4FMKais6ksAj/vYcfhmxbsNkOHIxtz45b395++oTcSxJVKfaTu306DgEtvXyJtSv2ZbL75aqEsbOsrdWGXMEtvE71MaPr8HH9S6WVmCUWetUvMG0A22eCw/bCOS8r4WC5BpBnKYe2hCGrmSO2rXzJRWcok6ZFu3eh3TA/32Mmh6NbM91nUrlEe0ysHciTMYW035H7JHMYaKoWcG3EQxEJHpT7f1k3TzMdikRBjxsERG1QllSnWtJUBJEDHelK1ySWmfeSu8ZtuH7Xc7NrXG8rJiOQtzaBAgjMTWURpj0Le9gdWWUZVIqmPNhN0TgnPQNWICmU6LSY5s7s3JcjfMhZUFhUMpaNETUQKWnb3l+kL9BmGd5BkiAoE4f4GwnxnA== Content-Type: text/plain; charset="utf-8" Content-ID: <DD747EDC96A45447A83FDA039A99E86C@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6097af81-d948-4ed7-7c6c-08d846a6a9bb X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Aug 2020 14:21:29.8260 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: nnUdmZXv43JHuF6EPShgHUzI3/D+ABpI3YvrRJ+sDFFy2Z/qWTE9ibXh3Nzo2M6DdiqqErJGTyZtqXBQcgfozg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4682 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: 24ACF420D7 X-Rspamd-UID: 27f14a QXBwbGllZA0KT24gV2VkLCAyMDIwLTA4LTE5IGF0IDIyOjQxIC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBUaGlzIGFkZHMgcHJldmlvdXNseSBtaXNzaW5nIHJldHJhbnNtaXQgY291bnQg YW5kIGludGVydmFsIHZhbHVlcw0KPiBzcGVjaWZpYyB0byBtb2RlbCBwdWJsaWNhdGlvbnMuIFRo ZSB2YWx1ZXMgYXJlIGNvbmZpZ3VyZWQgYnkgQ29uZmlnIENMaWVudA0KPiBhbmQgbWF5IGJlIGRp ZmZlcmVudCB0byBlYWNoIG1vZGVsLg0KPiAtLS0NCj4gIG1lc2gvY2ZnbW9kLXNlcnZlci5jICAg IHwgMjYgKysrKysrKysrKystLS0tLS0tDQo+ICBtZXNoL21lc2gtY29uZmlnLWpzb24uYyB8IDM2 ICsrKysrKysrKysrKy0tLS0tLS0tLS0tLS0NCj4gIG1lc2gvbWVzaC1jb25maWcuaCAgICAgIHwg IDQgKy0tDQo+ICBtZXNoL21vZGVsLmMgICAgICAgICAgICB8IDU5ICsrKysrKysrKysrKysrKysr KysrKysrLS0tLS0tLS0tLS0tLS0tLS0tDQo+ICBtZXNoL21vZGVsLmggICAgICAgICAgICB8ICA5 ICsrKystLS0NCj4gIG1lc2gvbmV0LmMgICAgICAgICAgICAgIHwgNDIgKysrKysrKysrKysrKysr KysrLS0tLS0tLS0tLS0NCj4gIG1lc2gvbmV0LmggICAgICAgICAgICAgIHwgIDYgKystLS0NCj4g IDcgZmlsZXMgY2hhbmdlZCwgMTA0IGluc2VydGlvbnMoKyksIDc4IGRlbGV0aW9ucygtKQ0KPiAN Cj4gZGlmZiAtLWdpdCBhL21lc2gvY2ZnbW9kLXNlcnZlci5jIGIvbWVzaC9jZmdtb2Qtc2VydmVy LmMNCj4gaW5kZXggOTBlYmRmMDQ2Li4yMzllYTg4OWQgMTAwNjQ0DQo+IC0tLSBhL21lc2gvY2Zn bW9kLXNlcnZlci5jDQo+ICsrKyBiL21lc2gvY2ZnbW9kLXNlcnZlci5jDQo+IEBAIC00OCw3ICs0 OCw3IEBAIHN0YXRpYyB1aW50OF90IG1zZ1tNQVhfTVNHX0xFTl07DQo+ICANCj4gIHN0YXRpYyB1 aW50MTZfdCBzZXRfcHViX3N0YXR1cyh1aW50OF90IHN0YXR1cywgdWludDE2X3QgZWxlX2FkZHIs IHVpbnQzMl90IGlkLA0KPiAgCQkJCXVpbnQxNl90IHB1Yl9hZGRyLCB1aW50MTZfdCBpZHgsIGJv b2wgY3JlZF9mbGFnLA0KPiAtCQkJCXVpbnQ4X3QgdHRsLCB1aW50OF90IHBlcmlvZCwgdWludDhf dCByZXRyYW5zbWl0KQ0KPiArCQkJCXVpbnQ4X3QgdHRsLCB1aW50OF90IHBlcmlvZCwgdWludDhf dCBydHgpDQo+ICB7DQo+ICAJc2l6ZV90IG47DQo+ICANCj4gQEAgLTYxLDcgKzYxLDcgQEAgc3Rh dGljIHVpbnQxNl90IHNldF9wdWJfc3RhdHVzKHVpbnQ4X3Qgc3RhdHVzLCB1aW50MTZfdCBlbGVf YWRkciwgdWludDMyX3QgaWQsDQo+ICAJbiArPSA2Ow0KPiAgCW1zZ1tuKytdID0gdHRsOw0KPiAg CW1zZ1tuKytdID0gcGVyaW9kOw0KPiAtCW1zZ1tuKytdID0gcmV0cmFuc21pdDsNCj4gKwltc2db bisrXSA9IHJ0eDsNCj4gIA0KPiAgCWlmICghSVNfVkVORE9SKGlkKSkgew0KPiAgCQlsX3B1dF9s ZTE2KE1PREVMX0lEKGlkKSwgbXNnICsgbik7DQo+IEBAIC04MCw2ICs4MCw3IEBAIHN0YXRpYyB1 aW50MTZfdCBjb25maWdfcHViX2dldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCBjb25zdCB1aW50 OF90ICpwa3QsDQo+ICB7DQo+ICAJdWludDMyX3QgaWQ7DQo+ICAJdWludDE2X3QgZWxlX2FkZHI7 DQo+ICsJdWludDhfdCBydHg7DQo+ICAJc3RydWN0IG1lc2hfbW9kZWxfcHViICpwdWI7DQo+ICAJ aW50IHN0YXR1czsNCj4gIA0KPiBAQCAtODgsMTAgKzg5LDEyIEBAIHN0YXRpYyB1aW50MTZfdCBj b25maWdfcHViX2dldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCBjb25zdCB1aW50OF90ICpwa3Qs DQo+ICANCj4gIAlwdWIgPSBtZXNoX21vZGVsX3B1Yl9nZXQobm9kZSwgZWxlX2FkZHIsIGlkLCAm c3RhdHVzKTsNCj4gIA0KPiArCXJ0eCA9IHB1Yi0+cnR4LmNudCArICgoKHB1Yi0+cnR4LmludGVy dmFsIC8gNTApIC0gMSkgPDwgMyk7DQo+ICsNCj4gIAlpZiAocHViICYmIHN0YXR1cyA9PSBNRVNI X1NUQVRVU19TVUNDRVNTKQ0KPiAgCQlyZXR1cm4gc2V0X3B1Yl9zdGF0dXMoc3RhdHVzLCBlbGVf YWRkciwgaWQsIHB1Yi0+YWRkciwgcHViLT5pZHgsDQo+ICAJCQkJCXB1Yi0+Y3JlZGVudGlhbCwg cHViLT50dGwsIHB1Yi0+cGVyaW9kLA0KPiAtCQkJCQlwdWItPnJldHJhbnNtaXQpOw0KPiArCQkJ CQlydHgpOw0KPiAgCWVsc2UNCj4gIAkJcmV0dXJuIHNldF9wdWJfc3RhdHVzKHN0YXR1cywgZWxl X2FkZHIsIGlkLCAwLCAwLCAwLCAwLCAwLCAwKTsNCj4gIH0NCj4gQEAgLTEwMiw3ICsxMDUsNyBA QCBzdGF0aWMgdWludDE2X3QgY29uZmlnX3B1Yl9zZXQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwg Y29uc3QgdWludDhfdCAqcGt0LA0KPiAgCXVpbnQzMl90IGlkOw0KPiAgCXVpbnQxNl90IGVsZV9h ZGRyLCBpZHgsIHB1Yl9kc3Q7DQo+ICAJY29uc3QgdWludDhfdCAqcHViX2FkZHI7DQo+IC0JdWlu dDhfdCB0dGwsIHBlcmlvZCwgcmV0cmFuc21pdDsNCj4gKwl1aW50OF90IHR0bCwgcGVyaW9kLCBy dHgsIGNudCwgaW50ZXJ2YWw7DQo+ICAJaW50IHN0YXR1czsNCj4gIAlib29sIGNyZWRfZmxhZzsN Cj4gIA0KPiBAQCAtMTI0LDEyICsxMjcsMTUgQEAgc3RhdGljIHVpbnQxNl90IGNvbmZpZ19wdWJf c2V0KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIGNvbnN0IHVpbnQ4X3QgKnBrdCwNCj4gIAlpZHgg Jj0gQVBQX0lEWF9NQVNLOw0KPiAgCXR0bCA9IHBrdFs2XTsNCj4gIAlwZXJpb2QgPSBwa3RbN107 DQo+IC0JcmV0cmFuc21pdCA9IHBrdFs4XTsNCj4gKwlydHggPSBwa3RbOF07DQo+ICAJaWQgPSBD RkdfR0VUX0lEKHZlbmRvciwgcGt0ICsgOSk7DQo+ICANCj4gKwljbnQgPSBydHggJiAweDc7DQo+ ICsJaW50ZXJ2YWwgPSAoKHJ0eCA+PiAzKSArIDEpICogNTA7DQo+ICsNCj4gIAlzdGF0dXMgPSBt ZXNoX21vZGVsX3B1Yl9zZXQobm9kZSwgZWxlX2FkZHIsIGlkLCBwdWJfYWRkciwgaWR4LA0KPiAt CQkJCQljcmVkX2ZsYWcsIHR0bCwgcGVyaW9kLCByZXRyYW5zbWl0LA0KPiAtCQkJCQl2aXJ0LCAm cHViX2RzdCk7DQo+ICsJCQkJCWNyZWRfZmxhZywgdHRsLCBwZXJpb2QsIGNudCwNCj4gKwkJCQkJ aW50ZXJ2YWwsIHZpcnQsICZwdWJfZHN0KTsNCj4gIA0KPiAgCWxfZGVidWcoInB1Yl9zZXQ6IHN0 YXR1cyAlZCwgZWEgJTQuNHgsIG90YTogJTQuNHgsIGlkOiAleCwgaWR4OiAlMy4zeCIsDQo+ICAJ CQkJCXN0YXR1cywgZWxlX2FkZHIsIHB1Yl9kc3QsIGlkLCBpZHgpOw0KPiBAQCAtMTUzLDggKzE1 OSw4IEBAIHN0YXRpYyB1aW50MTZfdCBjb25maWdfcHViX3NldChzdHJ1Y3QgbWVzaF9ub2RlICpu b2RlLCBjb25zdCB1aW50OF90ICpwa3QsDQo+ICAJCQkudHRsID0gdHRsLA0KPiAgCQkJLmNyZWRl bnRpYWwgPSBjcmVkX2ZsYWcsDQo+ICAJCQkucGVyaW9kID0gcGVyaW9kLA0KPiAtCQkJLmNvdW50 ID0gcmV0cmFuc21pdCAmIDB4NywNCj4gLQkJCS5pbnRlcnZhbCA9ICgocmV0cmFuc21pdCA+PiAz KSArIDEpICogNTANCj4gKwkJCS5jbnQgPSBjbnQsDQo+ICsJCQkuaW50ZXJ2YWwgPSBpbnRlcnZh bA0KPiAgCQl9Ow0KPiAgDQo+ICAJCWlmICh2aXJ0KQ0KPiBAQCAtMTY4LDcgKzE3NCw3IEBAIHN0 YXRpYyB1aW50MTZfdCBjb25maWdfcHViX3NldChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCBjb25z dCB1aW50OF90ICpwa3QsDQo+ICAJfQ0KPiAgDQo+ICAJcmV0dXJuIHNldF9wdWJfc3RhdHVzKHN0 YXR1cywgZWxlX2FkZHIsIGlkLCBwdWJfZHN0LCBpZHgsIGNyZWRfZmxhZywNCj4gLQkJCQkJCXR0 bCwgcGVyaW9kLCByZXRyYW5zbWl0KTsNCj4gKwkJCQkJCXR0bCwgcGVyaW9kLCBydHgpOw0KPiAg fQ0KPiAgDQo+ICBzdGF0aWMgdWludDE2X3QgY2ZnX3N1Yl9nZXRfbXNnKHN0cnVjdCBtZXNoX25v ZGUgKm5vZGUsIGNvbnN0IHVpbnQ4X3QgKnBrdCwNCj4gZGlmZiAtLWdpdCBhL21lc2gvbWVzaC1j b25maWctanNvbi5jIGIvbWVzaC9tZXNoLWNvbmZpZy1qc29uLmMNCj4gaW5kZXggYTE0NTM4OGQ2 Li42M2I2YzM5ODggMTAwNjQ0DQo+IC0tLSBhL21lc2gvbWVzaC1jb25maWctanNvbi5jDQo+ICsr KyBiL21lc2gvbWVzaC1jb25maWctanNvbi5jDQo+IEBAIC0xMDIxLDcgKzEwMjEsNyBAQCBzdGF0 aWMgc3RydWN0IG1lc2hfY29uZmlnX3B1YiAqcGFyc2VfbW9kZWxfcHVibGljYXRpb24oanNvbl9v YmplY3QgKmpwdWIpDQo+ICANCj4gIAlpZiAoIWdldF9pbnQoanZhbHVlLCAiY291bnQiLCAmdmFs dWUpKQ0KPiAgCQlnb3RvIGZhaWw7DQo+IC0JcHViLT5jb3VudCA9ICh1aW50OF90KSB2YWx1ZTsN Cj4gKwlwdWItPmNudCA9ICh1aW50OF90KSB2YWx1ZTsNCj4gIA0KPiAgCWlmICghZ2V0X2ludChq dmFsdWUsICJpbnRlcnZhbCIsICZ2YWx1ZSkpDQo+ICAJCWdvdG8gZmFpbDsNCj4gQEAgLTEzMzks MjAgKzEzMzksMjAgQEAgc3RhdGljIGJvb2wgcGFyc2VfY29tcG9zaXRpb24oanNvbl9vYmplY3Qg Kmpjb21wLCBzdHJ1Y3QgbWVzaF9jb25maWdfbm9kZSAqbm9kZSkNCj4gIA0KPiAgc3RhdGljIGJv b2wgcmVhZF9uZXRfdHJhbnNtaXQoanNvbl9vYmplY3QgKmpvYmosIHN0cnVjdCBtZXNoX2NvbmZp Z19ub2RlICpub2RlKQ0KPiAgew0KPiAtCWpzb25fb2JqZWN0ICpqcmV0cmFuc21pdCwgKmp2YWx1 ZTsNCj4gKwlqc29uX29iamVjdCAqanJ0eCwgKmp2YWx1ZTsNCj4gIAl1aW50MTZfdCBpbnRlcnZh bDsNCj4gIAl1aW50OF90IGNudDsNCj4gIA0KPiAtCWlmICghanNvbl9vYmplY3Rfb2JqZWN0X2dl dF9leChqb2JqLCAicmV0cmFuc21pdCIsICZqcmV0cmFuc21pdCkpDQo+ICsJaWYgKCFqc29uX29i amVjdF9vYmplY3RfZ2V0X2V4KGpvYmosICJyZXRyYW5zbWl0IiwgJmpydHgpKQ0KPiAgCQlyZXR1 cm4gdHJ1ZTsNCj4gIA0KPiAtCWlmICghanNvbl9vYmplY3Rfb2JqZWN0X2dldF9leChqcmV0cmFu c21pdCwgImNvdW50IiwgJmp2YWx1ZSkpDQo+ICsJaWYgKCFqc29uX29iamVjdF9vYmplY3RfZ2V0 X2V4KGpydHgsICJjb3VudCIsICZqdmFsdWUpKQ0KPiAgCQlyZXR1cm4gZmFsc2U7DQo+ICANCj4g IAkvKiBUT0RPOiBhZGQgcmFuZ2UgY2hlY2tpbmcgKi8NCj4gIAljbnQgPSAodWludDhfdCkganNv bl9vYmplY3RfZ2V0X2ludChqdmFsdWUpOw0KPiAgDQo+IC0JaWYgKCFqc29uX29iamVjdF9vYmpl Y3RfZ2V0X2V4KGpyZXRyYW5zbWl0LCAiaW50ZXJ2YWwiLCAmanZhbHVlKSkNCj4gKwlpZiAoIWpz b25fb2JqZWN0X29iamVjdF9nZXRfZXgoanJ0eCwgImludGVydmFsIiwgJmp2YWx1ZSkpDQo+ICAJ CXJldHVybiBmYWxzZTsNCj4gIA0KPiAgCWludGVydmFsID0gKHVpbnQxNl90KSBqc29uX29iamVj dF9nZXRfaW50KGp2YWx1ZSk7DQo+IEBAIC0xNTY2LDMwICsxNTY2LDMwIEBAIGJvb2wgbWVzaF9j b25maWdfd3JpdGVfcmVsYXlfbW9kZShzdHJ1Y3QgbWVzaF9jb25maWcgKmNmZywgdWludDhfdCBt b2RlLA0KPiAgYm9vbCBtZXNoX2NvbmZpZ193cml0ZV9uZXRfdHJhbnNtaXQoc3RydWN0IG1lc2hf Y29uZmlnICpjZmcsIHVpbnQ4X3QgY250LA0KPiAgCQkJCQkJCXVpbnQxNl90IGludGVydmFsKQ0K PiAgew0KPiAtCWpzb25fb2JqZWN0ICpqbm9kZSwgKmpyZXRyYW5zbWl0Ow0KPiArCWpzb25fb2Jq ZWN0ICpqbm9kZSwgKmpydHg7DQo+ICANCj4gIAlpZiAoIWNmZykNCj4gIAkJcmV0dXJuIGZhbHNl Ow0KPiAgDQo+ICAJam5vZGUgPSBjZmctPmpub2RlOw0KPiAgDQo+IC0JanJldHJhbnNtaXQgPSBq c29uX29iamVjdF9uZXdfb2JqZWN0KCk7DQo+IC0JaWYgKCFqcmV0cmFuc21pdCkNCj4gKwlqcnR4 ID0ganNvbl9vYmplY3RfbmV3X29iamVjdCgpOw0KPiArCWlmICghanJ0eCkNCj4gIAkJcmV0dXJu IGZhbHNlOw0KPiAgDQo+IC0JaWYgKCF3cml0ZV9pbnQoanJldHJhbnNtaXQsICJjb3VudCIsIGNu dCkpDQo+ICsJaWYgKCF3cml0ZV9pbnQoanJ0eCwgImNvdW50IiwgY250KSkNCj4gIAkJZ290byBm YWlsOw0KPiAgDQo+IC0JaWYgKCF3cml0ZV9pbnQoanJldHJhbnNtaXQsICJpbnRlcnZhbCIsIGlu dGVydmFsKSkNCj4gKwlpZiAoIXdyaXRlX2ludChqcnR4LCAiaW50ZXJ2YWwiLCBpbnRlcnZhbCkp DQo+ICAJCWdvdG8gZmFpbDsNCj4gIA0KPiAgCWpzb25fb2JqZWN0X29iamVjdF9kZWwoam5vZGUs ICJyZXRyYW5zbWl0Iik7DQo+IC0JanNvbl9vYmplY3Rfb2JqZWN0X2FkZChqbm9kZSwgInJldHJh bnNtaXQiLCBqcmV0cmFuc21pdCk7DQo+ICsJanNvbl9vYmplY3Rfb2JqZWN0X2FkZChqbm9kZSwg InJldHJhbnNtaXQiLCBqcnR4KTsNCj4gIA0KPiAgCXJldHVybiBzYXZlX2NvbmZpZyhjZmctPmpu b2RlLCBjZmctPm5vZGVfZGlyX3BhdGgpOw0KPiAgDQo+ICBmYWlsOg0KPiAtCWpzb25fb2JqZWN0 X3B1dChqcmV0cmFuc21pdCk7DQo+ICsJanNvbl9vYmplY3RfcHV0KGpydHgpOw0KPiAgCXJldHVy biBmYWxzZTsNCj4gIA0KPiAgfQ0KPiBAQCAtMTg0MSw3ICsxODQxLDcgQEAgYm9vbCBtZXNoX2Nv bmZpZ19tb2RlbF9wdWJfYWRkKHN0cnVjdCBtZXNoX2NvbmZpZyAqY2ZnLCB1aW50MTZfdCBlbGVf YWRkciwNCj4gIAkJCQkJdWludDMyX3QgbW9kX2lkLCBib29sIHZlbmRvciwNCj4gIAkJCQkJc3Ry dWN0IG1lc2hfY29uZmlnX3B1YiAqcHViKQ0KPiAgew0KPiAtCWpzb25fb2JqZWN0ICpqbm9kZSwg Kmptb2RlbCwgKmpwdWIsICpqcmV0cmFuc21pdDsNCj4gKwlqc29uX29iamVjdCAqam5vZGUsICpq bW9kZWwsICpqcHViLCAqanJ0eDsNCj4gIAlib29sIHJlczsNCj4gIAlpbnQgZWxlX2lkeDsNCj4g IA0KPiBAQCAtMTg4NSwxNyArMTg4NSwxNyBAQCBib29sIG1lc2hfY29uZmlnX21vZGVsX3B1Yl9h ZGQoc3RydWN0IG1lc2hfY29uZmlnICpjZmcsIHVpbnQxNl90IGVsZV9hZGRyLA0KPiAgCQkJCQkJ cHViLT5jcmVkZW50aWFsID8gMSA6IDApKQ0KPiAgCQlnb3RvIGZhaWw7DQo+ICANCj4gLQlqcmV0 cmFuc21pdCA9IGpzb25fb2JqZWN0X25ld19vYmplY3QoKTsNCj4gLQlpZiAoIWpyZXRyYW5zbWl0 KQ0KPiArCWpydHggPSBqc29uX29iamVjdF9uZXdfb2JqZWN0KCk7DQo+ICsJaWYgKCFqcnR4KQ0K PiAgCQlnb3RvIGZhaWw7DQo+ICANCj4gLQlpZiAoIXdyaXRlX2ludChqcmV0cmFuc21pdCwgImNv dW50IiwgcHViLT5jb3VudCkpDQo+ICsJaWYgKCF3cml0ZV9pbnQoanJ0eCwgImNvdW50IiwgcHVi LT5jbnQpKQ0KPiAgCQlnb3RvIGZhaWw7DQo+ICANCj4gLQlpZiAoIXdyaXRlX2ludChqcmV0cmFu c21pdCwgImludGVydmFsIiwgcHViLT5pbnRlcnZhbCkpDQo+ICsJaWYgKCF3cml0ZV9pbnQoanJ0 eCwgImludGVydmFsIiwgcHViLT5pbnRlcnZhbCkpDQo+ICAJCWdvdG8gZmFpbDsNCj4gIA0KPiAt CWpzb25fb2JqZWN0X29iamVjdF9hZGQoanB1YiwgInJldHJhbnNtaXQiLCBqcmV0cmFuc21pdCk7 DQo+ICsJanNvbl9vYmplY3Rfb2JqZWN0X2FkZChqcHViLCAicmV0cmFuc21pdCIsIGpydHgpOw0K PiAgCWpzb25fb2JqZWN0X29iamVjdF9hZGQoam1vZGVsLCAicHVibGlzaCIsIGpwdWIpOw0KPiAg DQo+ICAJcmV0dXJuIHNhdmVfY29uZmlnKGpub2RlLCBjZmctPm5vZGVfZGlyX3BhdGgpOw0KPiBk aWZmIC0tZ2l0IGEvbWVzaC9tZXNoLWNvbmZpZy5oIGIvbWVzaC9tZXNoLWNvbmZpZy5oDQo+IGlu ZGV4IDUwYTU1ZDUxZS4uNzM4Y2ZmOWRkIDEwMDY0NA0KPiAtLS0gYS9tZXNoL21lc2gtY29uZmln LmgNCj4gKysrIGIvbWVzaC9tZXNoLWNvbmZpZy5oDQo+IEBAIC0zNCwxMCArMzQsMTAgQEAgc3Ry dWN0IG1lc2hfY29uZmlnX3B1YiB7DQo+ICAJdWludDMyX3QgcGVyaW9kOw0KPiAgCXVpbnQxNl90 IGFkZHI7DQo+ICAJdWludDE2X3QgaWR4Ow0KPiArCXVpbnQxNl90IGludGVydmFsOw0KPiAgCXVp bnQ4X3QgdHRsOw0KPiAgCXVpbnQ4X3QgY3JlZGVudGlhbDsNCj4gLQl1aW50OF90IGNvdW50Ow0K PiAtCXVpbnQ4X3QgaW50ZXJ2YWw7DQo+ICsJdWludDhfdCBjbnQ7DQo+ICAJdWludDhfdCB2aXJ0 X2FkZHJbMTZdOw0KPiAgfTsNCj4gIA0KPiBkaWZmIC0tZ2l0IGEvbWVzaC9tb2RlbC5jIGIvbWVz aC9tb2RlbC5jDQo+IGluZGV4IDk2MTM5MWYxMy4uZWI1MTQyNTAzIDEwMDY0NA0KPiAtLS0gYS9t ZXNoL21vZGVsLmMNCj4gKysrIGIvbWVzaC9tb2RlbC5jDQo+IEBAIC01MDgsMTAgKzUwOCwxMSBA QCBzdGF0aWMgaW50IHZpcnRfcGFja2V0X2RlY3J5cHQoc3RydWN0IG1lc2hfbmV0ICpuZXQsIGNv bnN0IHVpbnQ4X3QgKmRhdGEsDQo+ICAJcmV0dXJuIC0xOw0KPiAgfQ0KPiAgDQo+IC1zdGF0aWMg Ym9vbCBtc2dfc2VuZChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCBib29sIGNyZWRlbnRpYWwsIHVp bnQxNl90IHNyYywNCj4gLQkJdWludDMyX3QgZHN0LCB1aW50MTZfdCBhcHBfaWR4LCB1aW50MTZf dCBuZXRfaWR4LA0KPiAtCQl1aW50OF90ICpsYWJlbCwgdWludDhfdCB0dGwsIGJvb2wgc2VnbWVu dGVkLA0KPiAtCQljb25zdCB2b2lkICptc2csIHVpbnQxNl90IG1zZ19sZW4pDQo+ICtzdGF0aWMg Ym9vbCBtc2dfc2VuZChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCBib29sIGNyZWQsIHVpbnQxNl90 IHNyYywNCj4gKwkJCXVpbnQxNl90IGRzdCwgdWludDE2X3QgYXBwX2lkeCwgdWludDE2X3QgbmV0 X2lkeCwNCj4gKwkJCXVpbnQ4X3QgKmxhYmVsLCB1aW50OF90IHR0bCwgdWludDhfdCBjbnQsDQo+ ICsJCQl1aW50MTZfdCBpbnRlcnZhbCwgYm9vbCBzZWdtZW50ZWQsIGNvbnN0IHZvaWQgKm1zZywN Cj4gKwkJCXVpbnQxNl90IG1zZ19sZW4pDQo+ICB7DQo+ICAJdWludDhfdCBkZXZfa2V5WzE2XTsN Cj4gIAl1aW50MzJfdCBpdl9pbmRleCwgc2VxX251bTsNCj4gQEAgLTU2Miw5ICs1NjMsOSBAQCBz dGF0aWMgYm9vbCBtc2dfc2VuZChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCBib29sIGNyZWRlbnRp YWwsIHVpbnQxNl90IHNyYywNCj4gIAkJZ290byBkb25lOw0KPiAgCX0NCj4gIA0KPiAtCXJldCA9 ICBtZXNoX25ldF9hcHBfc2VuZChuZXQsIGNyZWRlbnRpYWwsIHNyYywgZHN0LCBrZXlfYWlkLCBu ZXRfaWR4LA0KPiAtCQkJCQl0dGwsIHNlcV9udW0sIGl2X2luZGV4LCBzZWdtZW50ZWQsDQo+IC0J CQkJCXN6bWljLCBvdXQsIG91dF9sZW4pOw0KPiArCXJldCA9ICBtZXNoX25ldF9hcHBfc2VuZChu ZXQsIGNyZWQsIHNyYywgZHN0LCBrZXlfYWlkLCBuZXRfaWR4LCB0dGwsDQo+ICsJCQkJCWNudCwg aW50ZXJ2YWwsIHNlcV9udW0sIGl2X2luZGV4LA0KPiArCQkJCQlzZWdtZW50ZWQsIHN6bWljLCBv dXQsIG91dF9sZW4pOw0KPiAgZG9uZToNCj4gIAlsX2ZyZWUob3V0KTsNCj4gIAlyZXR1cm4gcmV0 Ow0KPiBAQCAtNzA1LDcgKzcwNiw3IEBAIHN0YXRpYyBzdHJ1Y3QgbWVzaF92aXJ0dWFsICphZGRf dmlydHVhbChjb25zdCB1aW50OF90ICp2KQ0KPiAgDQo+ICBzdGF0aWMgaW50IHNldF9wdWIoc3Ry dWN0IG1lc2hfbW9kZWwgKm1vZCwgdWludDE2X3QgcHViX2FkZHIsDQo+ICAJCQl1aW50MTZfdCBp ZHgsIGJvb2wgY3JlZF9mbGFnLCB1aW50OF90IHR0bCwNCj4gLQkJCXVpbnQ4X3QgcGVyaW9kLCB1 aW50OF90IHJldHJhbnNtaXQpDQo+ICsJCQl1aW50OF90IHBlcmlvZCwgdWludDhfdCBjbnQsIHVp bnQxNl90IGludGVydmFsKQ0KPiAgew0KPiAgCWlmICghbW9kLT5wdWIpDQo+ICAJCW1vZC0+cHVi ID0gbF9uZXcoc3RydWN0IG1lc2hfbW9kZWxfcHViLCAxKTsNCj4gQEAgLTcxNSwxNCArNzE2LDE1 IEBAIHN0YXRpYyBpbnQgc2V0X3B1YihzdHJ1Y3QgbWVzaF9tb2RlbCAqbW9kLCB1aW50MTZfdCBw dWJfYWRkciwNCj4gIAltb2QtPnB1Yi0+aWR4ID0gaWR4Ow0KPiAgCW1vZC0+cHViLT50dGwgPSB0 dGw7DQo+ICAJbW9kLT5wdWItPnBlcmlvZCA9IHBlcmlvZDsNCj4gLQltb2QtPnB1Yi0+cmV0cmFu c21pdCA9IHJldHJhbnNtaXQ7DQo+ICsJbW9kLT5wdWItPnJ0eC5jbnQgPSBjbnQ7DQo+ICsJbW9k LT5wdWItPnJ0eC5pbnRlcnZhbCA9IGludGVydmFsOw0KPiAgDQo+ICAJcmV0dXJuIE1FU0hfU1RB VFVTX1NVQ0NFU1M7DQo+ICB9DQo+ICANCj4gIHN0YXRpYyBpbnQgc2V0X3ZpcnRfcHViKHN0cnVj dCBtZXNoX21vZGVsICptb2QsIGNvbnN0IHVpbnQ4X3QgKmxhYmVsLA0KPiAgCQkJdWludDE2X3Qg aWR4LCBib29sIGNyZWRfZmxhZywgdWludDhfdCB0dGwsDQo+IC0JCQl1aW50OF90IHBlcmlvZCwg dWludDhfdCByZXRyYW5zbWl0KQ0KPiArCQkJdWludDhfdCBwZXJpb2QsIHVpbnQ4X3QgY250LCB1 aW50MTZfdCBpbnRlcnZhbCkNCj4gIHsNCj4gIAlzdHJ1Y3QgbWVzaF92aXJ0dWFsICp2aXJ0ID0g TlVMTDsNCj4gIA0KPiBAQCAtNzM0LDggKzczNiw4IEBAIHN0YXRpYyBpbnQgc2V0X3ZpcnRfcHVi KHN0cnVjdCBtZXNoX21vZGVsICptb2QsIGNvbnN0IHVpbnQ4X3QgKmxhYmVsLA0KPiAgCQltb2Qt PnB1YiA9IGxfbmV3KHN0cnVjdCBtZXNoX21vZGVsX3B1YiwgMSk7DQo+ICANCj4gIAltb2QtPnB1 Yi0+dmlydCA9IHZpcnQ7DQo+IC0JcmV0dXJuIHNldF9wdWIobW9kLCB2aXJ0LT5hZGRyLCBpZHgs IGNyZWRfZmxhZywgdHRsLCBwZXJpb2QsDQo+IC0JCQkJCQkJCXJldHJhbnNtaXQpOw0KPiArCXJl dHVybiBzZXRfcHViKG1vZCwgdmlydC0+YWRkciwgaWR4LCBjcmVkX2ZsYWcsIHR0bCwgcGVyaW9k LCBjbnQsDQo+ICsJCQkJCQkJCWludGVydmFsKTsNCj4gIH0NCj4gIA0KPiAgc3RhdGljIGludCBh ZGRfdmlydF9zdWIoc3RydWN0IG1lc2hfbmV0ICpuZXQsIHN0cnVjdCBtZXNoX21vZGVsICptb2Qs DQo+IEBAIC0xMDU4LDkgKzEwNjAsMTAgQEAgaW50IG1lc2hfbW9kZWxfcHVibGlzaChzdHJ1Y3Qg bWVzaF9ub2RlICpub2RlLCB1aW50MzJfdCBpZCwgdWludDE2X3Qgc3JjLA0KPiAgDQo+ICAJbmV0 X2lkeCA9IGFwcGtleV9uZXRfaWR4KG5ldCwgbW9kLT5wdWItPmlkeCk7DQo+ICANCj4gLQlyZXN1 bHQgPSBtc2dfc2VuZChub2RlLCBtb2QtPnB1Yi0+Y3JlZGVudGlhbCAhPSAwLCBzcmMsDQo+IC0J CQkJbW9kLT5wdWItPmFkZHIsIG1vZC0+cHViLT5pZHgsIG5ldF9pZHgsDQo+IC0JCQkJbGFiZWws IG1vZC0+cHViLT50dGwsIGZhbHNlLCBtc2csIG1zZ19sZW4pOw0KPiArCXJlc3VsdCA9IG1zZ19z ZW5kKG5vZGUsIG1vZC0+cHViLT5jcmVkZW50aWFsICE9IDAsIHNyYywgbW9kLT5wdWItPmFkZHIs DQo+ICsJCQkJbW9kLT5wdWItPmlkeCwgbmV0X2lkeCwgbGFiZWwsIG1vZC0+cHViLT50dGwsDQo+ ICsJCQkJbW9kLT5wdWItPnJ0eC5jbnQsIG1vZC0+cHViLT5ydHguaW50ZXJ2YWwsDQo+ICsJCQkJ ZmFsc2UsIG1zZywgbXNnX2xlbik7DQo+ICANCj4gIAlyZXR1cm4gcmVzdWx0ID8gTUVTSF9FUlJP Ul9OT05FIDogTUVTSF9FUlJPUl9GQUlMRUQ7DQo+ICB9DQo+IEBAIC0xMDcwLDYgKzEwNzMsMTAg QEAgYm9vbCBtZXNoX21vZGVsX3NlbmQoc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3Qg c3JjLCB1aW50MTZfdCBkc3QsDQo+ICAJCQkJCXVpbnQ4X3QgdHRsLCBib29sIHNlZ21lbnRlZCwN Cj4gIAkJCQkJY29uc3Qgdm9pZCAqbXNnLCB1aW50MTZfdCBtc2dfbGVuKQ0KPiAgew0KPiArCXN0 cnVjdCBtZXNoX25ldCAqbmV0ID0gbm9kZV9nZXRfbmV0KG5vZGUpOw0KPiArCXVpbnQ4X3QgY250 Ow0KPiArCXVpbnQxNl90IGludGVydmFsOw0KPiArDQo+ICAJLyogSWYgU1JDIGlzIDAsIHVzZSB0 aGUgUHJpbWFyeSBFbGVtZW50ICovDQo+ICAJaWYgKHNyYyA9PSAwKQ0KPiAgCQlzcmMgPSBub2Rl X2dldF9wcmltYXJ5KG5vZGUpOw0KPiBAQCAtMTA3OSwxNCArMTA4NiwxNiBAQCBib29sIG1lc2hf bW9kZWxfc2VuZChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBzcmMsIHVpbnQxNl90 IGRzdCwNCj4gIAlpZiAoSVNfVU5BU1NJR05FRChkc3QpKQ0KPiAgCQlyZXR1cm4gZmFsc2U7DQo+ ICANCj4gLQlyZXR1cm4gbXNnX3NlbmQobm9kZSwgZmFsc2UsIHNyYywgZHN0LCBhcHBfaWR4LCBu ZXRfaWR4LA0KPiAtCQkJCQlOVUxMLCB0dGwsIHNlZ21lbnRlZCwgbXNnLCBtc2dfbGVuKTsNCj4g KwltZXNoX25ldF90cmFuc21pdF9wYXJhbXNfZ2V0KG5ldCwgJmNudCwgJmludGVydmFsKTsNCj4g Kw0KPiArCXJldHVybiBtc2dfc2VuZChub2RlLCBmYWxzZSwgc3JjLCBkc3QsIGFwcF9pZHgsIG5l dF9pZHgsIE5VTEwsIHR0bCwgY250LA0KPiArCQkJCQlpbnRlcnZhbCwgc2VnbWVudGVkLCBtc2cs IG1zZ19sZW4pOw0KPiAgfQ0KPiAgDQo+ICBpbnQgbWVzaF9tb2RlbF9wdWJfc2V0KHN0cnVjdCBt ZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90IGFkZHIsIHVpbnQzMl90IGlkLA0KPiAgCQkJY29uc3Qg dWludDhfdCAqcHViX2FkZHIsIHVpbnQxNl90IGlkeCwgYm9vbCBjcmVkX2ZsYWcsDQo+IC0JCQl1 aW50OF90IHR0bCwgdWludDhfdCBwZXJpb2QsIHVpbnQ4X3QgcmV0cmFuc21pdCwNCj4gLQkJCWJv b2wgaXNfdmlydCwgdWludDE2X3QgKnB1Yl9kc3QpDQo+ICsJCQl1aW50OF90IHR0bCwgdWludDhf dCBwZXJpb2QsIHVpbnQ4X3QgY250LA0KPiArCQkJdWludDE2X3QgaW50ZXJ2YWwsIGJvb2wgaXNf dmlydCwgdWludDE2X3QgKnB1Yl9kc3QpDQo+ICB7DQo+ICAJc3RydWN0IG1lc2hfbW9kZWwgKm1v ZDsNCj4gIAlpbnQgc3RhdHVzLCBlbGVfaWR4ID0gbm9kZV9nZXRfZWxlbWVudF9pZHgobm9kZSwg YWRkcik7DQo+IEBAIC0xMTI0LDEwICsxMTMzLDEwIEBAIGludCBtZXNoX21vZGVsX3B1Yl9zZXQo c3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDE2X3QgYWRkciwgdWludDMyX3QgaWQsDQo+ICAN Cj4gIAlpZiAoIWlzX3ZpcnQpIHsNCj4gIAkJc3RhdHVzID0gc2V0X3B1Yihtb2QsIGxfZ2V0X2xl MTYocHViX2FkZHIpLCBpZHgsIGNyZWRfZmxhZywNCj4gLQkJCQkJCXR0bCwgcGVyaW9kLCByZXRy YW5zbWl0KTsNCj4gKwkJCQkJCXR0bCwgcGVyaW9kLCBjbnQsIGludGVydmFsKTsNCj4gIAl9IGVs c2UNCj4gIAkJc3RhdHVzID0gc2V0X3ZpcnRfcHViKG1vZCwgcHViX2FkZHIsIGlkeCwgY3JlZF9m bGFnLCB0dGwsDQo+IC0JCQkJCQlwZXJpb2QsIHJldHJhbnNtaXQpOw0KPiArCQkJCQkJCXBlcmlv ZCwgY250LCBpbnRlcnZhbCk7DQo+ICANCj4gIAkqcHViX2RzdCA9IG1vZC0+cHViLT5hZGRyOw0K PiAgDQo+IEBAIC0xNzAzLDE1ICsxNzEyLDEzIEBAIHN0YXRpYyBzdHJ1Y3QgbWVzaF9tb2RlbCAq bW9kZWxfc2V0dXAoc3RydWN0IG1lc2hfbmV0ICpuZXQsIHVpbnQ4X3QgZWxlX2lkeCwNCj4gIA0K PiAgCS8qIEFkZCBwdWJsaWNhdGlvbiBpZiBlbmFibGVkIGFuZCBwcmVzZW50ICovDQo+ICAJaWYg KG1vZC0+cHViX2VuYWJsZWQgJiYgcHViKSB7DQo+IC0JCXVpbnQ4X3QgcmV0cmFuc21pdCA9IHB1 Yi0+Y291bnQgKw0KPiAtCQkJCQkoKHB1Yi0+aW50ZXJ2YWwgLyA1MCAtIDEpIDw8IDMpOw0KPiAg CQlpZiAocHViLT52aXJ0KQ0KPiAgCQkJc2V0X3ZpcnRfcHViKG1vZCwgcHViLT52aXJ0X2FkZHIs IHB1Yi0+aWR4LA0KPiAtCQkJCQkJcHViLT5jcmVkZW50aWFsLCBwdWItPnR0bCwNCj4gLQkJCQkJ CXB1Yi0+cGVyaW9kLCByZXRyYW5zbWl0KTsNCj4gKwkJCQkJcHViLT5jcmVkZW50aWFsLCBwdWIt PnR0bCwgcHViLT5wZXJpb2QsDQo+ICsJCQkJCXB1Yi0+Y250LCBwdWItPmludGVydmFsKTsNCj4g IAkJZWxzZSBpZiAoIUlTX1VOQVNTSUdORUQocHViLT5hZGRyKSkNCj4gIAkJCXNldF9wdWIobW9k LCBwdWItPmFkZHIsIHB1Yi0+aWR4LCBwdWItPmNyZWRlbnRpYWwsDQo+IC0JCQkJcHViLT50dGws IHB1Yi0+cGVyaW9kLCByZXRyYW5zbWl0KTsNCj4gKwkJCQlwdWItPnR0bCwgcHViLT5wZXJpb2Qs IHB1Yi0+Y250LCBwdWItPmludGVydmFsKTsNCj4gIAl9DQo+ICANCj4gIAltb2QtPnN1Yl9lbmFi bGVkID0gZGJfbW9kLT5zdWJfZW5hYmxlZDsNCj4gZGlmZiAtLWdpdCBhL21lc2gvbW9kZWwuaCBi L21lc2gvbW9kZWwuaA0KPiBpbmRleCAxNDdhMDIyNzkuLmExYWZlZGQxOSAxMDA2NDQNCj4gLS0t IGEvbWVzaC9tb2RlbC5oDQo+ICsrKyBiL21lc2gvbW9kZWwuaA0KPiBAQCAtNDAsMTAgKzQwLDEz IEBAIHN0cnVjdCBtZXNoX21vZGVsX3B1YiB7DQo+ICAJc3RydWN0IG1lc2hfdmlydHVhbCAqdmly dDsNCj4gIAl1aW50MTZfdCBhZGRyOw0KPiAgCXVpbnQxNl90IGlkeDsNCj4gKwlzdHJ1Y3Qgew0K PiArCQl1aW50MTZfdCBpbnRlcnZhbDsNCj4gKwkJdWludDhfdCBjbnQ7DQo+ICsJfSBydHg7DQo+ ICAJdWludDhfdCB0dGw7DQo+ICAJdWludDhfdCBjcmVkZW50aWFsOw0KPiAgCXVpbnQ4X3QgcGVy aW9kOw0KPiAtCXVpbnQ4X3QgcmV0cmFuc21pdDsNCj4gIH07DQo+ICANCj4gIHR5cGVkZWYgdm9p ZCAoKm1lc2hfbW9kZWxfdW5yZWdpc3Rlcikodm9pZCAqdXNlcl9kYXRhKTsNCj4gQEAgLTc4LDgg KzgxLDggQEAgc3RydWN0IG1lc2hfbW9kZWxfcHViICptZXNoX21vZGVsX3B1Yl9nZXQoc3RydWN0 IG1lc2hfbm9kZSAqbm9kZSwNCj4gIAkJCQkJCXVpbnQzMl90IGlkLCBpbnQgKnN0YXR1cyk7DQo+ ICBpbnQgbWVzaF9tb2RlbF9wdWJfc2V0KHN0cnVjdCBtZXNoX25vZGUgKm5vZGUsIHVpbnQxNl90 IGVsZV9hZGRyLCB1aW50MzJfdCBpZCwNCj4gIAkJCWNvbnN0IHVpbnQ4X3QgKmFkZHIsIHVpbnQx Nl90IGlkeCwgYm9vbCBjcmVkX2ZsYWcsDQo+IC0JCQl1aW50OF90IHR0bCwgdWludDhfdCBwZXJp b2QsIHVpbnQ4X3QgcmV0cmFuc21pdCwNCj4gLQkJCWJvb2wgaXNfdmlydCwgdWludDE2X3QgKmRz dCk7DQo+ICsJCQl1aW50OF90IHR0bCwgdWludDhfdCBwZXJpb2QsIHVpbnQ4X3QgcnR4X2NudCwN Cj4gKwkJCXVpbnQxNl90IHJ0eF9pbnRlcnZhbCwgYm9vbCBpc192aXJ0LCB1aW50MTZfdCAqZHN0 KTsNCj4gIA0KPiAgaW50IG1lc2hfbW9kZWxfYmluZGluZ19hZGQoc3RydWN0IG1lc2hfbm9kZSAq bm9kZSwgdWludDE2X3QgZWxlX2FkZHIsDQo+ICAJCQkJCQl1aW50MzJfdCBpZCwgdWludDE2X3Qg aWR4KTsNCj4gZGlmZiAtLWdpdCBhL21lc2gvbmV0LmMgYi9tZXNoL25ldC5jDQo+IGluZGV4IDI2 NDQwYjAyZC4uOTMzMDdlNzBjIDEwMDY0NA0KPiAtLS0gYS9tZXNoL25ldC5jDQo+ICsrKyBiL21l c2gvbmV0LmMNCj4gQEAgLTIxMiw2ICsyMTIsOCBAQCBzdHJ1Y3QgbmV0X3F1ZXVlX2RhdGEgew0K PiAgDQo+ICBzdHJ1Y3Qgb25lc2hvdF90eCB7DQo+ICAJc3RydWN0IG1lc2hfbmV0ICpuZXQ7DQo+ ICsJdWludDE2X3QgaW50ZXJ2YWw7DQo+ICsJdWludDhfdCBjbnQ7DQo+ICAJdWludDhfdCBzaXpl Ow0KPiAgCXVpbnQ4X3QgcGFja2V0WzMwXTsNCj4gIH07DQo+IEBAIC0xMzk5LDcgKzE0MDEsOCBA QCBzdGF0aWMgdm9pZCBmcmllbmRfYWNrX3J4ZWQoc3RydWN0IG1lc2hfbmV0ICpuZXQsIHVpbnQz Ml90IGl2X2luZGV4LA0KPiAgCWxfcXVldWVfZm9yZWFjaChuZXQtPmZyaWVuZHMsIGVucXVldWVf ZnJpZW5kX3BrdCwgJmZybmRfYWNrKTsNCj4gIH0NCj4gIA0KPiAtc3RhdGljIGJvb2wgc2VuZF9z ZWcoc3RydWN0IG1lc2hfbmV0ICpuZXQsIHN0cnVjdCBtZXNoX3NhciAqbXNnLCB1aW50OF90IHNl Zyk7DQo+ICtzdGF0aWMgYm9vbCBzZW5kX3NlZyhzdHJ1Y3QgbWVzaF9uZXQgKm5ldCwgdWludDhf dCBjbnQsIHVpbnQxNl90IGludGVydmFsLA0KPiArCQkJCQlzdHJ1Y3QgbWVzaF9zYXIgKm1zZywg dWludDhfdCBzZWcpOw0KPiAgDQo+ICBzdGF0aWMgdm9pZCBzZW5kX2ZybmRfYWNrKHN0cnVjdCBt ZXNoX25ldCAqbmV0LCB1aW50MTZfdCBzcmMsIHVpbnQxNl90IGRzdCwNCj4gIAkJCQkJCXVpbnQz Ml90IGhkciwgdWludDMyX3QgZmxhZ3MpDQo+IEBAIC0xNTkzLDcgKzE1OTYsNyBAQCBzdGF0aWMg dm9pZCBhY2tfcmVjZWl2ZWQoc3RydWN0IG1lc2hfbmV0ICpuZXQsIGJvb2wgdGltZW91dCwNCj4g IAkJbF9kZWJ1ZygiUmVzZW5kIFNlZyAlZCBuZXQ6JXAgZHN0OiV4IGFwcF9pZHg6JTMuM3giLA0K PiAgCQkJCWksIG5ldCwgb3V0Z29pbmctPnJlbW90ZSwgb3V0Z29pbmctPmFwcF9pZHgpOw0KPiAg DQo+IC0JCXNlbmRfc2VnKG5ldCwgb3V0Z29pbmcsIGkpOw0KPiArCQlzZW5kX3NlZyhuZXQsIG5l dC0+dHhfY250LCBuZXQtPnR4X2ludGVydmFsLCBvdXRnb2luZywgaSk7DQo+ICAJfQ0KPiAgDQo+ ICAJbF90aW1lb3V0X3JlbW92ZShvdXRnb2luZy0+c2VnX3RpbWVvdXQpOw0KPiBAQCAtMjE0Myw4 ICsyMTQ2LDggQEAgc3RhdGljIHZvaWQgc2VuZF9tc2dfcGt0X29uZXNob3Qodm9pZCAqdXNlcl9k YXRhKQ0KPiAgDQo+ICAJdHgtPnBhY2tldFswXSA9IE1FU0hfQURfVFlQRV9ORVRXT1JLOw0KPiAg CWluZm8udHlwZSA9IE1FU0hfSU9fVElNSU5HX1RZUEVfR0VORVJBTDsNCj4gLQlpbmZvLnUuZ2Vu LmludGVydmFsID0gbmV0LT50eF9pbnRlcnZhbDsNCj4gLQlpbmZvLnUuZ2VuLmNudCA9IG5ldC0+ dHhfY250Ow0KPiArCWluZm8udS5nZW4uaW50ZXJ2YWwgPSB0eC0+aW50ZXJ2YWw7DQo+ICsJaW5m by51Lmdlbi5jbnQgPSB0eC0+Y250Ow0KPiAgCWluZm8udS5nZW4ubWluX2RlbGF5ID0gREVGQVVM VF9NSU5fREVMQVk7DQo+ICAJLyogTm8gZXh0cmEgcmFuZG9taXphdGlvbiB3aGVuIHNlbmRpbmcg cmVndWxhciBtZXNoIG1lc3NhZ2VzICovDQo+ICAJaW5mby51Lmdlbi5tYXhfZGVsYXkgPSBERUZB VUxUX01JTl9ERUxBWTsNCj4gQEAgLTIxNTMsMTEgKzIxNTYsMTQgQEAgc3RhdGljIHZvaWQgc2Vu ZF9tc2dfcGt0X29uZXNob3Qodm9pZCAqdXNlcl9kYXRhKQ0KPiAgCWxfZnJlZSh0eCk7DQo+ICB9 DQo+ICANCj4gLXN0YXRpYyB2b2lkIHNlbmRfbXNnX3BrdChzdHJ1Y3QgbWVzaF9uZXQgKm5ldCwg dWludDhfdCAqcGFja2V0LCB1aW50OF90IHNpemUpDQo+ICtzdGF0aWMgdm9pZCBzZW5kX21zZ19w a3Qoc3RydWN0IG1lc2hfbmV0ICpuZXQsIHVpbnQ4X3QgY250LCB1aW50MTZfdCBpbnRlcnZhbCwN Cj4gKwkJCQkJCXVpbnQ4X3QgKnBhY2tldCwgdWludDhfdCBzaXplKQ0KPiAgew0KPiAgCXN0cnVj dCBvbmVzaG90X3R4ICp0eCA9IGxfbmV3KHN0cnVjdCBvbmVzaG90X3R4LCAxKTsNCj4gIA0KPiAg CXR4LT5uZXQgPSBuZXQ7DQo+ICsJdHgtPmludGVydmFsID0gaW50ZXJ2YWw7DQo+ICsJdHgtPmNu dCA9IGNudDsNCj4gIAl0eC0+c2l6ZSA9IHNpemU7DQo+ICAJbWVtY3B5KHR4LT5wYWNrZXQsIHBh Y2tldCwgc2l6ZSk7DQo+ICANCj4gQEAgLTI4NzIsNyArMjg3OCw4IEBAIGJvb2wgbWVzaF9uZXRf ZHN0X3VucmVnKHN0cnVjdCBtZXNoX25ldCAqbmV0LCB1aW50MTZfdCBkc3QpDQo+ICAJcmV0dXJu IHRydWU7DQo+ICB9DQo+ICANCj4gLXN0YXRpYyBib29sIHNlbmRfc2VnKHN0cnVjdCBtZXNoX25l dCAqbmV0LCBzdHJ1Y3QgbWVzaF9zYXIgKm1zZywgdWludDhfdCBzZWdPKQ0KPiArc3RhdGljIGJv b2wgc2VuZF9zZWcoc3RydWN0IG1lc2hfbmV0ICpuZXQsIHVpbnQ4X3QgY250LCB1aW50MTZfdCBp bnRlcnZhbCwNCj4gKwkJCQkJc3RydWN0IG1lc2hfc2FyICptc2csIHVpbnQ4X3Qgc2VnTykNCj4g IHsNCj4gIAlzdHJ1Y3QgbWVzaF9zdWJuZXQgKnN1Ym5ldDsNCj4gIAl1aW50OF90IHNlZ19sZW47 DQo+IEBAIC0yOTI3LDcgKzI5MzQsNyBAQCBzdGF0aWMgYm9vbCBzZW5kX3NlZyhzdHJ1Y3QgbWVz aF9uZXQgKm5ldCwgc3RydWN0IG1lc2hfc2FyICptc2csIHVpbnQ4X3Qgc2VnTykNCj4gIAkJcmV0 dXJuIGZhbHNlOw0KPiAgCX0NCj4gIA0KPiAtCXNlbmRfbXNnX3BrdChuZXQsIHBhY2tldCwgcGFj a2V0X2xlbiArIDEpOw0KPiArCXNlbmRfbXNnX3BrdChuZXQsIGNudCwgaW50ZXJ2YWwsIHBhY2tl dCwgcGFja2V0X2xlbiArIDEpOw0KPiAgDQo+ICAJbXNnLT5sYXN0X3NlZyA9IHNlZ087DQo+ICAN Cj4gQEAgLTI5NjcsNyArMjk3NCw4IEBAIHZvaWQgbWVzaF9uZXRfc2VuZF9zZWcoc3RydWN0IG1l c2hfbmV0ICpuZXQsIHVpbnQzMl90IG5ldF9rZXlfaWQsDQo+ICAJCXJldHVybjsNCj4gIAl9DQo+ ICANCj4gLQlzZW5kX21zZ19wa3QobmV0LCBwYWNrZXQsIHBhY2tldF9sZW4gKyAxKTsNCj4gKwlz ZW5kX21zZ19wa3QobmV0LCBuZXQtPnR4X2NudCwgbmV0LT50eF9pbnRlcnZhbCwgcGFja2V0LA0K PiArCQkJCQkJCQlwYWNrZXRfbGVuICsgMSk7DQo+ICANCj4gIAlsX2RlYnVnKCJUWDogRnJpZW5k IFNlZy0lZCAlMDR4IC0+ICUwNHggOiBsZW4gJXUpIDogVFRMICVkIDogU0VRICUwNngiLA0KPiAg CQkJCQlzZWdPLCBzcmMsIGRzdCwgcGFja2V0X2xlbiwgdHRsLCBzZXEpOw0KPiBAQCAtMjk3Nyw5 ICsyOTg1LDkgQEAgdm9pZCBtZXNoX25ldF9zZW5kX3NlZyhzdHJ1Y3QgbWVzaF9uZXQgKm5ldCwg dWludDMyX3QgbmV0X2tleV9pZCwNCj4gIA0KPiAgYm9vbCBtZXNoX25ldF9hcHBfc2VuZChzdHJ1 Y3QgbWVzaF9uZXQgKm5ldCwgYm9vbCBmcm5kX2NyZWQsIHVpbnQxNl90IHNyYywNCj4gIAkJCQl1 aW50MTZfdCBkc3QsIHVpbnQ4X3Qga2V5X2FpZCwgdWludDE2X3QgbmV0X2lkeCwNCj4gLQkJCQl1 aW50OF90IHR0bCwgdWludDMyX3Qgc2VxLCB1aW50MzJfdCBpdl9pbmRleCwNCj4gLQkJCQlib29s IHNlZ21lbnRlZCwgYm9vbCBzem1pYywNCj4gLQkJCQljb25zdCB2b2lkICptc2csIHVpbnQxNl90 IG1zZ19sZW4pDQo+ICsJCQkJdWludDhfdCB0dGwsIHVpbnQ4X3QgY250LCB1aW50MTZfdCBpbnRl cnZhbCwNCj4gKwkJCQl1aW50MzJfdCBzZXEsIHVpbnQzMl90IGl2X2luZGV4LCBib29sIHNlZ21l bnRlZCwNCj4gKwkJCQlib29sIHN6bWljLCBjb25zdCB2b2lkICptc2csIHVpbnQxNl90IG1zZ19s ZW4pDQo+ICB7DQo+ICAJc3RydWN0IG1lc2hfc2FyICpwYXlsb2FkID0gTlVMTDsNCj4gIAl1aW50 OF90IHNlZywgc2VnX21heDsNCj4gQEAgLTMwNTQsMTEgKzMwNjIsMTIgQEAgYm9vbCBtZXNoX25l dF9hcHBfc2VuZChzdHJ1Y3QgbWVzaF9uZXQgKm5ldCwgYm9vbCBmcm5kX2NyZWQsIHVpbnQxNl90 IHNyYywNCj4gIA0KPiAgCQlmb3IgKGkgPSAwOyBpIDwgNDsgaSsrKSB7DQo+ICAJCQlmb3IgKHNl ZyA9IDA7IHNlZyA8PSBzZWdfbWF4ICYmIHJlc3VsdDsgc2VnKyspDQo+IC0JCQkJcmVzdWx0ID0g c2VuZF9zZWcobmV0LCBwYXlsb2FkLCBzZWcpOw0KPiArCQkJCXJlc3VsdCA9IHNlbmRfc2VnKG5l dCwgY250LCBpbnRlcnZhbCwgcGF5bG9hZCwNCj4gKwkJCQkJCQkJCXNlZyk7DQo+ICAJCX0NCj4g IAl9IGVsc2Ugew0KPiAgCQlmb3IgKHNlZyA9IDA7IHNlZyA8PSBzZWdfbWF4ICYmIHJlc3VsdDsg c2VnKyspDQo+IC0JCQlyZXN1bHQgPSBzZW5kX3NlZyhuZXQsIHBheWxvYWQsIHNlZyk7DQo+ICsJ CQlyZXN1bHQgPSBzZW5kX3NlZyhuZXQsIGNudCwgaW50ZXJ2YWwsIHBheWxvYWQsIHNlZyk7DQo+ ICAJfQ0KPiAgDQo+ICAJLyogUmVsaWFibGU6IENhY2hlOyBVbnJlbGlhYmxlOiBGbHVzaCovDQo+ IEBAIC0zMTA4LDcgKzMxMTcsNyBAQCB2b2lkIG1lc2hfbmV0X2Fja19zZW5kKHN0cnVjdCBtZXNo X25ldCAqbmV0LCB1aW50MzJfdCBrZXlfaWQsIHVpbnQzMl90IGl2X2luZGV4LA0KPiAgCQlyZXR1 cm47DQo+ICAJfQ0KPiAgDQo+IC0Jc2VuZF9tc2dfcGt0KG5ldCwgcGt0LCBwa3RfbGVuICsgMSk7 DQo+ICsJc2VuZF9tc2dfcGt0KG5ldCwgbmV0LT50eF9jbnQsIG5ldC0+dHhfaW50ZXJ2YWwsIHBr dCwgcGt0X2xlbiArIDEpOw0KPiAgDQo+ICAJbF9kZWJ1ZygiVFg6IEZyaWVuZCBBQ0sgJTA0eCAt PiAlMDR4IDogbGVuICV1IDogVFRMICVkIDogU0VRICUwNngiLA0KPiAgCQkJCQlzcmMsIGRzdCwg cGt0X2xlbiwgdHRsLCBzZXEpOw0KPiBAQCAtMzE4Miw4ICszMTkxLDkgQEAgdm9pZCBtZXNoX25l dF90cmFuc3BvcnRfc2VuZChzdHJ1Y3QgbWVzaF9uZXQgKm5ldCwgdWludDMyX3Qga2V5X2lkLA0K PiAgCQlyZXR1cm47DQo+ICAJfQ0KPiAgDQo+IC0JaWYgKGRzdCAhPSAwKQ0KPiAtCQlzZW5kX21z Z19wa3QobmV0LCBwa3QsIHBrdF9sZW4gKyAxKTsNCj4gKwlpZiAoIShJU19VTkFTU0lHTkVEKGRz dCkpKQ0KPiArCQlzZW5kX21zZ19wa3QobmV0LCBuZXQtPnR4X2NudCwgbmV0LT50eF9pbnRlcnZh bCwgcGt0LA0KPiArCQkJCQkJCQlwa3RfbGVuICsgMSk7DQo+ICB9DQo+ICANCj4gIGludCBtZXNo X25ldF9rZXlfcmVmcmVzaF9waGFzZV9zZXQoc3RydWN0IG1lc2hfbmV0ICpuZXQsIHVpbnQxNl90 IGlkeCwNCj4gZGlmZiAtLWdpdCBhL21lc2gvbmV0LmggYi9tZXNoL25ldC5oDQo+IGluZGV4IDkx ZTA3ZWY3OC4uMjUzMTg1ZTQyIDEwMDY0NA0KPiAtLS0gYS9tZXNoL25ldC5oDQo+ICsrKyBiL21l c2gvbmV0LmgNCj4gQEAgLTMwMCw5ICszMDAsOSBAQCB2b2lkIG1lc2hfbmV0X3RyYW5zcG9ydF9z ZW5kKHN0cnVjdCBtZXNoX25ldCAqbmV0LCB1aW50MzJfdCBrZXlfaWQsDQo+ICANCj4gIGJvb2wg bWVzaF9uZXRfYXBwX3NlbmQoc3RydWN0IG1lc2hfbmV0ICpuZXQsIGJvb2wgZnJuZF9jcmVkLCB1 aW50MTZfdCBzcmMsDQo+ICAJCQkJdWludDE2X3QgZHN0LCB1aW50OF90IGtleV9pZCwgdWludDE2 X3QgbmV0X2lkeCwNCj4gLQkJCQl1aW50OF90IHR0bCwgdWludDMyX3Qgc2VxLCB1aW50MzJfdCBp dl9pbmRleCwNCj4gLQkJCQlib29sIHNlZ21lbnRlZCwgYm9vbCBzem1pYywgY29uc3Qgdm9pZCAq bXNnLA0KPiAtCQkJCXVpbnQxNl90IG1zZ19sZW4pOw0KPiArCQkJCXVpbnQ4X3QgdHRsLCB1aW50 OF90IGNudCwgdWludDE2X3QgaW50ZXJ2YWwsDQo+ICsJCQkJdWludDMyX3Qgc2VxLCB1aW50MzJf dCBpdl9pbmRleCwgYm9vbCBzZWdtZW50ZWQsDQo+ICsJCQkJYm9vbCBzem1pYywgY29uc3Qgdm9p ZCAqbXNnLCB1aW50MTZfdCBtc2dfbGVuKTsNCj4gIHZvaWQgbWVzaF9uZXRfYWNrX3NlbmQoc3Ry dWN0IG1lc2hfbmV0ICpuZXQsIHVpbnQzMl90IGtleV9pZCwNCj4gIAkJCQl1aW50MzJfdCBpdl9p bmRleCwgdWludDhfdCB0dGwsIHVpbnQzMl90IHNlcSwNCj4gIAkJCQl1aW50MTZfdCBzcmMsIHVp bnQxNl90IGRzdCwgYm9vbCBybHksDQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QD8kBywHQF8vzgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 19:41:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id yENxBSwHQF9joAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 19:41:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 761A6A1279; Fri, 21 Aug 2020 19:40:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726846AbgHURdS (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 13:33:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbgHURdQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 13:33:16 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C81F9C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:33:15 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id e6so2179118oii.4 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:33:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wQS2uBDhUd3sZz5wY/MnOMF8c1/iiCazEEEhF1oWRBg=; b=VtLle+O+/1zggmOAlP7NhC2a7boxj7Ode0jyk+SXNCH6hMoDPR7dtiS+qsYgXvm6zO 2w1NgfPi1//FzObN0LsHqcLdgwy0zi/2nqahU7iSCK+31Oa3ca/a5cj/lcm2f2U+Lxqn H7g8m250LwRjYbjQJbwhuwg+dKOzHPoq9dzHpH6zvEpNUK6mPSN/KaI+UVEd8wYZB13w w+DLzmDjMYKpY0i4cyx7qofBbDPkbEsKieBXoVNgH1QuGUjja9wKGc1ajCGzqKN3wXm3 rL/a/HaL9//h/aRo+gGZ1BJxNbH5R8eqHxJyMa8G3qeHhVSKK2YXVB0+ZB92FXkc/LQ2 mzdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wQS2uBDhUd3sZz5wY/MnOMF8c1/iiCazEEEhF1oWRBg=; b=gmT1fy3WeP9eEmVA9kSWDBIvfUmRJjDPaMKobskdp2GTQ/tGIpzZaoYIShERqOR+X/ uxB/cUTqsaFVAKb7qUPm2PhEiMun2tPCJ6JgQJyQXgtoq8jq7L5ELvU/vIYAwExCXH8x sKJj4HzkuLlOIHD5IK4VbaT1Pkh5IcInocNGbs1OyTAsc55fB7G7K6QgFX/FdXQvO+YO 86wX+RAoie8XuLIj3+hKPZQAGMLwSkMLWWzR2iGMbyL5JUkLFomnd6WoXDuHuW9i6jfp 5zVaRgv/mmiqcFlemo150mbnyKHxwq9ul2UiuwuCdiwsuYvc/bp2etoduKAzdoOBI8FC WL9A== X-Gm-Message-State: AOAM532IeEI8JesKiq0iapHv1TYt1yOmobe1/xHTxvak/pIBF5FDHUqh 5fNLC33DeOKJ2sXtKk9cdnKZCECU3Y1qQebq1ZM= X-Google-Smtp-Source: ABdhPJwsVb9fYyVBBGOrOSi0tyNQ9vSwd3IifA15JiZhptruVm87sIxHvip2vQoZD3tk9jFMPI8eX45aSUBDRWiKdKo= X-Received: by 2002:aca:cc50:: with SMTP id c77mr2353779oig.152.1598031195003; Fri, 21 Aug 2020 10:33:15 -0700 (PDT) MIME-Version: 1.0 References: <20200821070409.18037-1-sonnysasaka@chromium.org> In-Reply-To: <20200821070409.18037-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 21 Aug 2020 10:33:04 -0700 Message-ID: <CABBYNZ+XKyqK6gpxhZ_J43Uto+cSMGJAcgPKNtCLoi+whrAh6A@mail.gmail.com> Subject: Re: [PATCH BlueZ] gap: Enable the external flag To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Joseph Hwang <josephsih@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.67 / 15.00 / 200.00 X-Rspamd-Queue-Id: 761A6A1279 X-Rspamd-UID: d568a8 Hi Sonny, On Fri, Aug 21, 2020 at 12:08 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > From: Joseph Hwang <josephsih@chromium.org> > > This patch enables the external flag for gap so that the gap service can > be exported over D-Bus. > > Tested on Chrome OS that this fixes https://crbug.com/722987 so that GAP > API can be propagated to Android apps. > > Test Method 1: > - Connect to a peripheral. > - Use dbus methods to query the org.bluez.GattService1 > interface in managed objects. > - Confirm that the gap 0x1800 profile was exported like: > GattService1 path: /org/bluez/hci0/dev_xx/service0001 > service_props: dbus.String(u'UUID'): > dbus.String(u'00001800-0000-1000-8000-00805f9b34fb' > > Test Method 2: > - Install BleManager APK attached in C#0 of https://crbug.com/722987 > to ARC++ in a chromebook. > - Launch the application. > - Connect to a Dash robot. Confirm that there are 3 services > instead of 2. > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > --- > profiles/gap/gas.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/profiles/gap/gas.c b/profiles/gap/gas.c > index dffa31314..abe5341c0 100644 > --- a/profiles/gap/gas.c > +++ b/profiles/gap/gas.c > @@ -310,6 +310,7 @@ static int gap_disconnect(struct btd_service *service) > static struct btd_profile gap_profile = { > .name = "gap-profile", > .remote_uuid = GAP_UUID, > + .external = true, > .device_probe = gap_probe, > .device_remove = gap_remove, > .accept = gap_accept, > -- > 2.26.2 I guess you will end up exporting every single service at the end, so perhaps we should just have an entry to main.conf (ExportClaimedServices) where the system can define if services claimed by plugins are allowed to be accessed over D-Bus, and we should probably add a comment that when doing so it may cause conflicts between the daemon and applications (especially GAP/GATT service can be very sensitive). -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UCbhDE4HQF9S5QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 19:41:34 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QD02C04HQF/uwQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 19:41:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3723AA1A52; Fri, 21 Aug 2020 19:41:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728023AbgHURgg (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 13:36:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725820AbgHURge (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 13:36:34 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53C72C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:36:34 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id r6so506741oon.13 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:36:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6dfREwcPDaFqu0NxJIiuzEAM2Q82qJx7DHgfCuuYP78=; b=vC4TYeMFO2ageMrazWQEfEs2z5+LjGRd3G6lKGSxGhsetPSRNiXc/RgTfVpp6/ntyr Dqm9dKU65Wu7JNQQBilu2TEBKo2e9G4g1TbhV05erLnV2PeSeoTxr8F8C7z3d7nOL/y9 ij50xKiIOkdIau0FXlPvR7/lFtuSq+uDQmpT/XOJdPhIFtOxPakfYd49/vayTtVp/7Nq TCq+kB3NSt0OxMbLVTx1PMx50jh6zvTR6PCXQYXXDVMvTQCSXh5R+OG+yqPCjjEKDWA1 qMyyvd8HDJxQZXw20cmGbfZH5zEHcRH7G2zh4eh+b3C4vXw25hNtEbHvqAPMxeEgx9j9 cscw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6dfREwcPDaFqu0NxJIiuzEAM2Q82qJx7DHgfCuuYP78=; b=nIcD03P8PBcz7y4eC6BRsnObllTDLNMxUrBLbaUcmIre7aCvWmQctfBh67QatpuncZ hOpPn973FHCU13GkvykGnZJ6rROQ+OzJ/S1prNMz4MP2J6TCH8oy5ZnyW4DRquB3+hPH 4XQVndo2/joptLMzDizw4EwO+lbUbCvvN/FnIrpWCZ40QvZF13PdRxSrcWh8lXU5Y4IK sZ9RDC+QaXJHja1av3NApq47BV+PSWDJKcmX2ioXwoMvF12IQQOjk6d7fOUtnNSFMQLf UbuCc6iQVa3FHUUby3Ba8a2BEYtNG4RhdYXLzk0WByItuuwv9rSdRSrA78QjuXuwqWLW dMCg== X-Gm-Message-State: AOAM530O2FH4E7A16J038sORjcghr8Qlc8tmg3t27G7k0krclXVmBrQ8 iGylZUWTlz0hgWX/fkeQcQ7ttmGD4S6EqKt9SRE= X-Google-Smtp-Source: ABdhPJzY78KkyaeEuzb2fWcW7H51lI4SS5VazAr0XBdUqIuxBdtyrPcg0V/QIQprsG1x74XzIpd/HDHt8wzH57wNS6s= X-Received: by 2002:a4a:380b:: with SMTP id c11mr2902526ooa.17.1598031393680; Fri, 21 Aug 2020 10:36:33 -0700 (PDT) MIME-Version: 1.0 References: <20200821074512.19985-1-sonnysasaka@chromium.org> In-Reply-To: <20200821074512.19985-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 21 Aug 2020 10:36:23 -0700 Message-ID: <CABBYNZJp2cCqRFa2zrdLnva0UgxvG2eBhYyKr52Rx54sU=znSA@mail.gmail.com> Subject: Re: [PATCH BlueZ] device: Fix race condition between device connection and disconnection To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3723AA1A52 X-Rspamd-UID: 5489dd Hi Sonny, On Fri, Aug 21, 2020 at 12:47 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > When Connect() is called and waiting for return, dev_disconnected may be > called due to MGMT_EV_DEVICE_DISCONNECTED event from kernel. In that > case reply to client that the connection failed otherwise the dbus > method will timeout because bluetoothd never replies. > > Tested with simulation of a lot of Connect() to bluetooth devices and > check that error is returned from bluetoothd rather than dbus timeout > when this race condition happens. > > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > > --- > src/device.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/src/device.c b/src/device.c > index 7b7808405..55e7b4042 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -3006,6 +3006,7 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type) > void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > { > struct bearer_state *state = get_state(device, bdaddr_type); > + DBusMessage *reply; > > if (!state->connected) > return; > @@ -3020,6 +3021,17 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > device->disconn_timer = 0; > } > > + // This could be executed while the client is waiting for Connect() but > + // att_connect_cb has not been invoked. > + // In that case reply the client that the connection failed. Please use C style comment /* */ > + if (device->connect) { > + DBG("connection removed while Connect() is waiting reply"); > + reply = btd_error_failed(device->connect, "Disconnected early"); > + g_dbus_send_message(dbus_conn, reply); > + dbus_message_unref(device->connect); > + device->connect = NULL; > + } > + > while (device->disconnects) { > DBusMessage *msg = device->disconnects->data; > > -- > 2.26.2 > Otherwise it looks good. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WEGGNV8HQF8vzgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 19:41:51 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id eFkYNF8HQF+EZAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 19:41:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E0CA0A158F; Fri, 21 Aug 2020 19:41:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726373AbgHURih (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 13:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725820AbgHURid (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 13:38:33 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D482C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:38:33 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id x24so2201312otp.3 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YJmswrb/1hl1zCBlFoKUJMBSjl/y77PLsJckIS2x4MU=; b=lAY3R/2R1JkSdonBYRdHszJGrQJwmY96kCd/JOejJkUKFnwFHxo+MvpcM2+KiL6D/h gXOmIjOsACBGEOqbYUCpexfJPn8CYxqvpyCZ/rGS1hqDeoMlTsNLjroZBTO71TmWhFzI PEOEf6qMeMGNFJYO260Ktu5wilQ3Gua0PLvr3GiKxbP6bHV5YjqU0MFPCB3cWhnzewY7 mbVLkt6w3+A6o1imNtRBJ1yhQnv/l8QUqOfIDLbBaQQwZDtJGDfF8yOBAFkMcsQBvErz jp/CrxRjd/BBB7zVfzLCgI8iH30f8dXw2daUI5l2nEdnaxFZo9T6TI/dtRfO6luYaCpF 6i5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YJmswrb/1hl1zCBlFoKUJMBSjl/y77PLsJckIS2x4MU=; b=som+qkkQaGddiikTxoxsRKlqSwA1yoFdncgEVm4G6bfjhnpGG/rtSBK5+UO2q1AX1w eJr0eb/FPsEiABqsVHRXpDg4UocM08cVoqPNSsYcagfPGYleWqCh+XlxuKrwvEsPyPXW hjkYATZzZ0IV+baEbI8SfWeyjFKIupDEzYl29PnVri1X0wpTd3w9Cug/3gLAH3sPlq7r lpVM9u7M3pDOC+UaEUqF6H8qOttB3cTD82OLv+fxrjm76SvQgL7UEALhzK/3cl6jzztk neA1rstlvneg5qbra7uLOupyqTyBH0qDsE84dNm77amWWiRAr1Zm3xaSkA/9pcmxXIvn SCug== X-Gm-Message-State: AOAM531iiZiBwwj9fJT3rjsBbS8ugR4HO6fPohexSiRsaTiawTLRLl/I fbhhtHk95NPea9nbbsp7Joiz8T0Cxt6RHc/wta7EmlM+ X-Google-Smtp-Source: ABdhPJzhBud82cP1NfvwrwpAXnFji/UBgjJkzKY9o7W8wzj2O+cKzFK+a+bww0jvA17sCyMfELLiRnjEjQShyHlr9z4= X-Received: by 2002:a9d:429:: with SMTP id 38mr2660925otc.88.1598031512441; Fri, 21 Aug 2020 10:38:32 -0700 (PDT) MIME-Version: 1.0 References: <20200821073714.19626-1-sonnysasaka@chromium.org> In-Reply-To: <20200821073714.19626-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 21 Aug 2020 10:38:22 -0700 Message-ID: <CABBYNZJN0V5iPkJgbh3Xc8cF4Qdp0azcoPM7bjsto4VeVjrzFA@mail.gmail.com> Subject: Re: [PATCH BlueZ] adapter: Fix crash in discovery_disconnect To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: E0CA0A158F X-Rspamd-UID: 5af590 Hi Sonny, On Fri, Aug 21, 2020 at 12:42 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > discovery_disconnect crashed because the adapter pointer has been freed > before. This patch makes sure that discovery list is cleaned up before > adapter pointer is freed. > > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > > --- > src/adapter.c | 19 ++++++++++++++----- > 1 file changed, 14 insertions(+), 5 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..c0b02bf3f 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -5316,12 +5316,25 @@ static void free_service_auth(gpointer data, gpointer user_data) > g_free(auth); > } > > +static void remove_discovery_list(struct btd_adapter *adapter) > +{ > + g_slist_free_full(adapter->set_filter_list, discovery_free); > + adapter->set_filter_list = NULL; > + > + g_slist_free_full(adapter->discovery_list, discovery_free); > + adapter->discovery_list = NULL; > +} > + > static void adapter_free(gpointer user_data) > { > struct btd_adapter *adapter = user_data; > > DBG("%p", adapter); > > + // Make sure the adapter's discovery list is cleaned up before freeing > + // the adapter. Please use C style comments. > + remove_discovery_list(adapter); > + > if (adapter->pairable_timeout_id > 0) { > g_source_remove(adapter->pairable_timeout_id); > adapter->pairable_timeout_id = 0; > @@ -6846,11 +6859,7 @@ static void adapter_stop(struct btd_adapter *adapter) > > cancel_passive_scanning(adapter); > > - g_slist_free_full(adapter->set_filter_list, discovery_free); > - adapter->set_filter_list = NULL; > - > - g_slist_free_full(adapter->discovery_list, discovery_free); > - adapter->discovery_list = NULL; > + remove_discovery_list(adapter); > > discovery_cleanup(adapter, 0); > > -- > 2.26.2 Otherwise it looks good. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eOnYEGQIQF8vzgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 19:46:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8M76DmQIQF9qdgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 19:46:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 30162A1402; Fri, 21 Aug 2020 19:46:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726795AbgHURqG (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 13:46:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbgHURqF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 13:46:05 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8FF4C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:46:04 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id z10so516170ooi.10 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PEjL0dyRIMnvU+TEOondv6UZTt27vQTUxacVcxcjF5s=; b=EozGs8tjRWtICLn7RZ4+/hlE0wSJfoz8bzwrDJq3rc0UooK2p7XqPhQ+nCShO3WqOo d6U515KExmvgyjaILb9nuPtcu2GoPdsA1Qf853jfwnAFVg95k3FARzvGOPeRUnSJDDGX cbN8zNFCL0chYoJRdcIgbhxA32xDN19VsScIG9EFFPZXsZPhZ3F9akW7uI1LoCAvwhU5 1KHRFCIdvKZ4TswLMryXUvwn8xGpkGnkq15ckac8OhFqTT39ayecuVn+tuvBJKAgY4Pc Tjy+DFxi0B6uQ7+YVOX6brFYUeEtyqX8jo3zhq6Hia/ZYlTioH0y5gNoec1VPnXcupFU D09w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PEjL0dyRIMnvU+TEOondv6UZTt27vQTUxacVcxcjF5s=; b=Jhso988qH+tr9fWjJAGdbu93cthIv+bJ2/hNv4a5ie1d3XCOKeBzRMgAUn006JxLhJ 1QduhXI+AyzbkdFMIxCsFgFgTejQ1TGKqgjm8Ja1IS8QmQsL1aLSXkt2yHsF57qccJae xdy6wzpZva+s8WGZkx1NwPhWuqPfs4txm0OB4bOFDd77FIk4TtTNy3GX8x9n+HF3DhPu CXAiCzxIAqI68ge39J7x0Z7bG7UZLHfA3LpORpLLsrjMhnAW/vv/iLPGBhfnsJWktI5o PiBdAhDBrGiiAHVd8kwIeriLOybsawOsraFdPKnq1sRTfdwHgVvnMLopvbr9LQ3Tpcn2 BmTA== X-Gm-Message-State: AOAM531i9UXHStb3RrggMAZljT897dglJOTvkHSmKy+JUvZGCkYNjTGe AwO00IkIhEynyeSEQAuNfZXCFABNNNE2dZ6OrhE= X-Google-Smtp-Source: ABdhPJzUDng1n91jMDurRsvEbdLBfBCz8px3PaGx2/dFcwQ9O/q9TKll9w0bh7qV52DjUH+ELQvIAoXXaGNo5BiD/fM= X-Received: by 2002:a4a:924b:: with SMTP id g11mr2992050ooh.9.1598031963473; Fri, 21 Aug 2020 10:46:03 -0700 (PDT) MIME-Version: 1.0 References: <20200821072155.18834-1-sonnysasaka@chromium.org> In-Reply-To: <20200821072155.18834-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 21 Aug 2020 10:45:53 -0700 Message-ID: <CABBYNZ+OA96+WKNUNKuNHZB199zyUczBhGjLpyN4bYEAj3npkg@mail.gmail.com> Subject: Re: [PATCH BlueZ] shared/mgmt: Provide timeout in mgmt_send() To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 30162A1402 X-Rspamd-UID: 427ed4 Hi Sonny, On Fri, Aug 21, 2020 at 12:26 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > This patch adds mgmt_send_with_timeout() to help callers who want to use > mgmt_send with timeout handling. Ideally, all mgmt_send() caller should > use timeout, but in this patch only UNPAIR_DEVICE mgmt command is known > to have no-reply problem in the kernel. > > This prevents bluetoothd from getting stuck in a state of waiting for > kernel MGMT reply forever. We still need to fix the kernel side for the > missing reply. > > --- > src/adapter.c | 8 +++--- > src/shared/mgmt.c | 62 ++++++++++++++++++++++++++++++++++++++++++++--- > src/shared/mgmt.h | 6 +++++ > 3 files changed, 69 insertions(+), 7 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..787d1bbb6 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -114,6 +114,8 @@ static const struct mgmt_blocked_key_info blocked_keys[] = { > 0x22, 0x8e, 0x07, 0x56, 0xb4, 0xe8, 0x5f, 0x01}}, > }; > > +#define DEFAULT_MGMT_TIMEOUT 2 /* Timeout for MGMT commands (secs) */ > + > static DBusConnection *dbus_conn = NULL; > > static bool kernel_conn_control = false; > @@ -7217,9 +7219,9 @@ int btd_adapter_remove_bonding(struct btd_adapter *adapter, > cp.addr.type = bdaddr_type; > cp.disconnect = 1; > > - if (mgmt_send(adapter->mgmt, MGMT_OP_UNPAIR_DEVICE, > - adapter->dev_id, sizeof(cp), &cp, > - NULL, NULL, NULL) > 0) > + if (mgmt_send_with_timeout(adapter->mgmt, MGMT_OP_UNPAIR_DEVICE, > + adapter->dev_id, sizeof(cp), &cp, NULL, > + NULL, NULL, DEFAULT_MGMT_TIMEOUT) > 0) > return 0; > > return -EIO; > diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c > index 277e361a6..7e70aba43 100644 > --- a/src/shared/mgmt.c > +++ b/src/shared/mgmt.c > @@ -38,6 +38,7 @@ > #include "src/shared/queue.h" > #include "src/shared/util.h" > #include "src/shared/mgmt.h" > +#include "src/shared/timeout.h" > > struct mgmt { > int ref_count; > @@ -60,6 +61,11 @@ struct mgmt { > void *debug_data; > }; > > +struct mgmt_pending_request { > + unsigned int request_id; > + struct mgmt *mgmt; > +}; > + > struct mgmt_request { > unsigned int id; > uint16_t opcode; > @@ -69,6 +75,8 @@ struct mgmt_request { > mgmt_request_func_t callback; > mgmt_destroy_func_t destroy; > void *user_data; > + /* Timeout for the request if > zero, otherwise timer is not used. */ > + int timeout_seconds; > }; > > struct mgmt_notify { > @@ -157,6 +165,8 @@ static void write_watch_destroy(void *user_data) > mgmt->writer_active = false; > } > > +bool mgmt_pending_timeout(void *user_data); > + > static bool send_request(struct mgmt *mgmt, struct mgmt_request *request) > { > struct iovec iov; > @@ -184,6 +194,14 @@ static bool send_request(struct mgmt *mgmt, struct mgmt_request *request) > mgmt->debug_data); > > queue_push_tail(mgmt->pending_list, request); > + if (request->timeout_seconds > 0) { > + struct mgmt_pending_request *pending_request = > + malloc(sizeof(struct mgmt_pending_request)); Use new0 instead of malloc. > + pending_request->request_id = request->id; > + pending_request->mgmt = mgmt; > + timeout_add(request->timeout_seconds * 1000, > + mgmt_pending_timeout, pending_request, NULL); You might need to attach the pending request to the request itself so if it is cancel/complete you will need to free the pointer. > + } > > return true; > } > @@ -267,6 +285,29 @@ static void request_complete(struct mgmt *mgmt, uint8_t status, > wakeup_writer(mgmt); > } > > +bool mgmt_pending_timeout(void *user_data) > +{ > + struct mgmt_pending_request *pending_request = user_data; > + struct mgmt *mgmt = pending_request->mgmt; > + const struct mgmt_request *request = > + queue_find(mgmt->pending_list, > + match_request_id, > + UINT_TO_PTR( > + pending_request->request_id)); Make the request aware of the timeout so it can cancel it when it is cancelled/complete it just cancel the timeout. > + free(pending_request); > + > + if (!request) > + return false; > + > + /* Pretend that kernel has replied with TIMEOUT status. */ > + request_complete(mgmt, MGMT_STATUS_TIMEOUT, request->opcode, > + request->index, /* length */ 0, > + /* param */ NULL); > + > + return false; > +} > + > struct event_index { > uint16_t event; > uint16_t index; > @@ -571,10 +612,12 @@ static struct mgmt_request *create_request(uint16_t opcode, uint16_t index, > return request; > } > > -unsigned int mgmt_send(struct mgmt *mgmt, uint16_t opcode, uint16_t index, > - uint16_t length, const void *param, > - mgmt_request_func_t callback, > - void *user_data, mgmt_destroy_func_t destroy) > +unsigned int mgmt_send_with_timeout( > + struct mgmt *mgmt, uint16_t opcode, uint16_t index, > + uint16_t length, const void *param, > + mgmt_request_func_t callback, > + void *user_data, mgmt_destroy_func_t destroy, > + int timeout_seconds) > { > struct mgmt_request *request; > > @@ -590,6 +633,7 @@ unsigned int mgmt_send(struct mgmt *mgmt, uint16_t opcode, uint16_t index, > mgmt->next_request_id = 1; > > request->id = mgmt->next_request_id++; > + request->timeout_seconds = timeout_seconds; > > if (!queue_push_tail(mgmt->request_queue, request)) { > free(request->buf); > @@ -602,6 +646,16 @@ unsigned int mgmt_send(struct mgmt *mgmt, uint16_t opcode, uint16_t index, > return request->id; > } > > +unsigned int mgmt_send(struct mgmt *mgmt, uint16_t opcode, uint16_t index, > + uint16_t length, const void *param, > + mgmt_request_func_t callback, > + void *user_data, mgmt_destroy_func_t destroy) > +{ > + return mgmt_send_with_timeout( > + mgmt, opcode, index, length, param, callback, user_data, > + destroy, /* timeout_seconds */ 0); > +} > + > unsigned int mgmt_send_nowait(struct mgmt *mgmt, uint16_t opcode, uint16_t index, > uint16_t length, const void *param, > mgmt_request_func_t callback, > diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h > index 7caeb3844..9aea64010 100644 > --- a/src/shared/mgmt.h > +++ b/src/shared/mgmt.h > @@ -46,6 +46,12 @@ bool mgmt_set_close_on_unref(struct mgmt *mgmt, bool do_close); > typedef void (*mgmt_request_func_t)(uint8_t status, uint16_t length, > const void *param, void *user_data); > > +unsigned int mgmt_send_with_timeout( > + struct mgmt *mgmt, uint16_t opcode, uint16_t index, > + uint16_t length, const void *param, > + mgmt_request_func_t callback, > + void *user_data, mgmt_destroy_func_t destroy, > + int timeout_seconds); > unsigned int mgmt_send(struct mgmt *mgmt, uint16_t opcode, uint16_t index, > uint16_t length, const void *param, > mgmt_request_func_t callback, > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gNdeNVQKQF8vzgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 19:54:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CF5DM1QKQF8mjQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 19:54:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2D705A1717; Fri, 21 Aug 2020 19:54:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726875AbgHURyT (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 13:54:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgHURyR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 13:54:17 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50EB0C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:54:16 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id z22so2238382oid.1 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Krq1uDnHC4wEySxJ4sNYyv48cR1jwx55LtsrcUTUdZE=; b=jlRB7yns4tl56g3y15Z89EioITiIjX8A6+EY/NtIF3+L9Bx+XClcTJf0irl1mYYf/1 J/t3XUdVwpPo8hDQmic4JSLJmacFy5JMg5uWIrvgi981v8dW+JgVESgFsw45rIeZ5rLE JSGkJrkV5xn4lhSUGGtKW/hMNU7OJys+vvTtBU7ONW5hm4g3gyQzTpsYu18gdkVjV+7C gtpubHDvsqxdLarpqWnnLXV+ehrEeociZgiAubL1Z3hTTX4/v6hInsB4OPraxxpUPJO4 7k9TfcHWc89in6ioEjHgtjbI4S7Xh4NbFOJxVNPCsE9zhCaPh/m7ZwzmEvcP0+iyiqBP 9aYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Krq1uDnHC4wEySxJ4sNYyv48cR1jwx55LtsrcUTUdZE=; b=j4K4uQVw7rtBH+SDi4aRGXSwrd/TFVGaeLZCltTebuJ20uEIr6oWYXTfayPGstj3lE AgKCZetGU93Dd7+2SUMFWZbO/HEopFmoHhugzHGV+oXrhPTPwJk9qcABF0IVNdpZxzCm 28F0L6UzGI1cZGCIopOEXfkJNXlN9RFCfVqauXibifiGHM1o/papFT39Wh3B3Da0InHO nEYC0xlnlHlOFegRLutcsO3ez/2oliZJzJXg2amVA2UTwx5yh/1p68qzjmbIMfhiQkyN eBENkI/kSzoRA5e+FtPw4kwjLnuQNIWqiqGZPk1z/PpRGw3DrMe0c9wdU8e2opUHEUzN NzUg== X-Gm-Message-State: AOAM53357cvYBHrup3SVghn7i8mpwYLh4KLzlF/PHzNiwK7M/IDzTCuh HtUsItp7AB6C4zQ9vCdyN0xpTd8nUM8njvLffXopkPYE X-Google-Smtp-Source: ABdhPJzxtKeBfSCBxXcS3GhRmheSZxmQpsX6YWQgFK0cpRjnzX/KqWGDE/07JuFQg4AsTDaIxm9EBsZv1D3vdUP60hE= X-Received: by 2002:aca:cc50:: with SMTP id c77mr2398823oig.152.1598032455928; Fri, 21 Aug 2020 10:54:15 -0700 (PDT) MIME-Version: 1.0 References: <20200821043536.15332-1-sonnysasaka@chromium.org> In-Reply-To: <20200821043536.15332-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 21 Aug 2020 10:54:05 -0700 Message-ID: <CABBYNZK7n6dYz_70wrcSG0066HRW=BJwS5tqn2ZB5qGW3qJmYA@mail.gmail.com> Subject: Re: [PATCH BlueZ] input/device: Unregister all UHID event listeners at UHID_DESTROY To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2D705A1717 X-Rspamd-UID: 767f8e Hi Sonny, On Thu, Aug 20, 2020 at 9:38 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > When destroying UHID, we should also unregister all event listeners so > that they don't get double registered at reconnection. It fixes a bug > where battery report is not available to kernel after reconnection and > also prevents memory leak. > > Tested with Logitech M535 mouse: > * Connect mouse to the device running BlueZ > * cat /sys/class/power_supply/hid-{addr}-battery/capacity # works > * Disconnect mouse > * Reconnect mouse > * cat /sys/class/power_supply/hid-{addr}-battery/capacity # still works > > Reviewed-by: Archie Pusaka <apusaka@chromium.org> > > --- > profiles/input/device.c | 2 ++ > src/shared/uhid.c | 9 +++++++++ > src/shared/uhid.h | 1 + > 3 files changed, 12 insertions(+) > > diff --git a/profiles/input/device.c b/profiles/input/device.c > index 8fc04be37..f6823b7b6 100644 > --- a/profiles/input/device.c > +++ b/profiles/input/device.c > @@ -982,6 +982,8 @@ static int uhid_disconnect(struct input_device *idev) > if (!idev->uhid_created) > return 0; > > + bt_uhid_unregister_all(idev->uhid); > + > memset(&ev, 0, sizeof(ev)); > ev.type = UHID_DESTROY; > > diff --git a/src/shared/uhid.c b/src/shared/uhid.c > index 685f90243..71a4e04ba 100644 > --- a/src/shared/uhid.c > +++ b/src/shared/uhid.c > @@ -219,6 +219,15 @@ bool bt_uhid_unregister(struct bt_uhid *uhid, unsigned int id) > return true; > } > > +bool bt_uhid_unregister_all(struct bt_uhid *uhid) > +{ > + if (!uhid) > + return false; > + > + queue_remove_all(uhid->notify_list, NULL, NULL, free); > + return true; > +} > + > int bt_uhid_send(struct bt_uhid *uhid, const struct uhid_event *ev) > { > ssize_t len; > diff --git a/src/shared/uhid.h b/src/shared/uhid.h > index 459a24900..dbdca852d 100644 > --- a/src/shared/uhid.h > +++ b/src/shared/uhid.h > @@ -40,5 +40,6 @@ typedef void (*bt_uhid_callback_t)(struct uhid_event *ev, void *user_data); > unsigned int bt_uhid_register(struct bt_uhid *uhid, uint32_t event, > bt_uhid_callback_t func, void *user_data); > bool bt_uhid_unregister(struct bt_uhid *uhid, unsigned int id); > +bool bt_uhid_unregister_all(struct bt_uhid *uhid); > > int bt_uhid_send(struct bt_uhid *uhid, const struct uhid_event *ev); > -- > 2.26.2 Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EGQzHGMKQF9S5QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 19:54:43 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id kLNLG2MKQF+daQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 19:54:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 83961A11FF; Fri, 21 Aug 2020 19:54:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727061AbgHURyi (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 13:54:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgHURyh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 13:54:37 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6BB8C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:54:36 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id l84so2212922oig.10 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xNQFwJoi1mS8yo9UsU4ab+XF9HC8xWBiEbryZG9ORqs=; b=iRSUkdbklz8z2Py0ri2l9eZzqU3NNI7cYqntpEHUSiQiZJryrD09mDi+fCdzy6koz+ 81w+ZXnVk4TtVOMNEWv4SwsvmcFgDpQw34y64oHSDBSJM0rXXqeABEDVMEFnaPDJd0wL unJYmBIAWYIhhJiQr+lgrNXT20faMrefeOMBAjdEPw2N1iUEL8PL11pvG5UEb4Okbg3H r7pgkNXq9XLGXZK/rQTv/t4GOtqSUtmzP5vmTOfLy8jMM8i6atVOzAaGp52UT6BZMjA0 wbZ4K1Rr+RUsFUVT+1oifdYAgRwiIb9MGDcctRseUEDA47hn+sN0hs+NXGCJcn1nSxWU 2tBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xNQFwJoi1mS8yo9UsU4ab+XF9HC8xWBiEbryZG9ORqs=; b=eDakLXHVo/hg4vnSRg+/0hhE73VuRwFGoGvz7MX4WDfgV1mhgtoS5QE5i46uEY6CyI h+H3dTfBG71tKaolA1+9rUpCq7S8HPF2JYPrGNp1w1l+pkI6i4sWTkAOTzgKFvmyB1dj 3UFdqnjdkgbmWdiRGHgzD9TynW/dzW8rPH/PdbCh+lVKYNm+GKcHP7wlBvBCIrlL+sGO z5ELkQY7fQsopKtLdu3DAFfZCnjVKgMtWR6MEON4NdA1wsSEIeiUl64JI2pmiMeQ5lVw vFSTo68kjQtvRCaj5AU+LepLXjTmeETdnRjDaRtbC9gRrt2lfjiHzdeUCtMuzgJekQh3 48wQ== X-Gm-Message-State: AOAM530e9xsthOY0SuICjtkkPe/A8iWOVOesVisMCfWzothozDzk5jlq PUiHMWWpcvDHjrOdSaD30RV1ic8tbWruEsSmGRczeSRx X-Google-Smtp-Source: ABdhPJx9GGnYGUiOE4L862SAo9fM3aFS5Q+qLQF2HNYN6kxGFwkOPI2HHctjeGy0wCJdj/4EvFcuy8J7h71Dz9Y+7V4= X-Received: by 2002:aca:5703:: with SMTP id l3mr2378460oib.48.1598032476208; Fri, 21 Aug 2020 10:54:36 -0700 (PDT) MIME-Version: 1.0 References: <20200821072812.19131-1-sonnysasaka@chromium.org> In-Reply-To: <20200821072812.19131-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 21 Aug 2020 10:54:25 -0700 Message-ID: <CABBYNZLqJS6XW-XZ+094sx0zm7sGyTHqqvdbpAA3wHRsjZwNwQ@mail.gmail.com> Subject: Re: [PATCH BlueZ] client: Add cancel-pairing command To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 83961A11FF X-Rspamd-UID: 7affa3 Hi Sonny, On Fri, Aug 21, 2020 at 12:30 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > From: Miao-chen Chou <mcchou@chromium.org> > > This adds cancel-pairing command which can be used to cancel the ongoing > pairing. > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > --- > client/main.c | 35 +++++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) > > diff --git a/client/main.c b/client/main.c > index 9abada69f..da877b546 100644 > --- a/client/main.c > +++ b/client/main.c > @@ -1742,6 +1742,39 @@ static void cmd_pair(int argc, char *argv[]) > bt_shell_printf("Attempting to pair with %s\n", proxy_address(proxy)); > } > > +static void cancel_pairing_reply(DBusMessage *message, void *user_data) > +{ > + DBusError error; > + > + dbus_error_init(&error); > + > + if (dbus_set_error_from_message(&error, message) == TRUE) { > + bt_shell_printf("Failed to cancel pairing: %s\n", error.name); > + dbus_error_free(&error); > + return; > + } > + > + bt_shell_printf("Cancel pairing successful\n"); > +} > + > +static void cmd_cancel_pairing(int argc, char *argv[]) > +{ > + GDBusProxy *proxy; > + > + proxy = find_device(argc, argv); > + if (!proxy) > + return; > + > + if (g_dbus_proxy_method_call(proxy, "CancelPairing", NULL, > + cancel_pairing_reply, NULL, NULL) == FALSE) { > + bt_shell_printf("Failed to cancel pairing\n"); > + return; > + } > + > + bt_shell_printf("Attempting to cancel pairing with %s\n", > + proxy_address(proxy)); > +} > + > static void cmd_trust(int argc, char *argv[]) > { > GDBusProxy *proxy; > @@ -2816,6 +2849,8 @@ static const struct bt_shell_menu main_menu = { > dev_generator }, > { "pair", "[dev]", cmd_pair, "Pair with device", > dev_generator }, > + { "cancel-pairing", "[dev]", cmd_cancel_pairing, > + "Cancel pairing with device", dev_generator }, > { "trust", "[dev]", cmd_trust, "Trust device", > dev_generator }, > { "untrust", "[dev]", cmd_untrust, "Untrust device", > -- > 2.26.2 Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OIDSGl0LQF8vzgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 19:58:53 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wM3+GF0LQF9xYQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 19:58:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 775F5A12E3; Fri, 21 Aug 2020 19:58:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726876AbgHUR6r (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 13:58:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgHUR6n (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 13:58:43 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 426CAC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:58:43 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id z23so1217640plo.8 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FhSmR3bJAg3EPJpaAiOPxsM469jNIsw/321Korr/Tag=; b=WSKSlXumZMO7+jroTZzj2Xm5gQaivVbz/CdkOZXzGnnv+rQ6ZF9m9cRRR++coorOAy /CmstNZHn1g22XQsKILPLT4DeKInWLmSUKVHM39yebI3U1p3g1/q2zFY5dwRFjxlUjMd i8cxetNEzfMwjYjkcFwXuwzRvu19fv8HBmUiI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FhSmR3bJAg3EPJpaAiOPxsM469jNIsw/321Korr/Tag=; b=cK673ZHOFjteWCAPbd2pzj9IDEKv+fwaAXAUVaI87AirurnKTk5bxGYCGI4IsI4/JG wbgxaN+VMoLcC7WRuaDWP7H1UC0ZSvnDHu42qbm5aDmHTklhece62K63Wew0kafTCIx5 WemE7ANoBLTj/0vyYHkPIQjzewp5vH2wBMofS19u0zMVUiJDU3EMWZBCxHmwJAqXQJUD 4oQjopMpdMp5DFFyDWY0/r7CD0upBfotohHQUd8TV7X5lX9qOs/0v2M1AyWWR7PH830B 01GNPIJWHji1ePTuJQzTyYmSv1huFbJZb0QHkMQ1z7QM/CKRX08mfvp3uNuhjl8CII3x 2oZQ== X-Gm-Message-State: AOAM5317uSrfsvs1AVvmhskGMlrEggYnGtNhPGwlci7WIOG07IbJpuw2 yo8SOnHcIxL6cXOcbDSk5n+FP41woN+soA== X-Google-Smtp-Source: ABdhPJxj2h2w5UjfztL55HoAHaFtdy+yZa37P9GZItCHGJsyyMsWYl7KaajUI+jJwL6fdAiN6YmStA== X-Received: by 2002:a17:902:7088:: with SMTP id z8mr3044450plk.315.1598032722544; Fri, 21 Aug 2020 10:58:42 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id i72sm2807732pgc.70.2020.08.21.10.58.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2020 10:58:41 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [PATCH BlueZ v2] adapter: Fix crash in discovery_disconnect Date: Fri, 21 Aug 2020 10:58:38 -0700 Message-Id: <20200821175838.20761-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 775F5A12E3 X-Rspamd-UID: ec4f2e discovery_disconnect crashed because the adapter pointer has been freed before. This patch makes sure that discovery list is cleaned up before adapter pointer is freed. Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- src/adapter.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..1435e2bd7 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -5316,12 +5316,26 @@ static void free_service_auth(gpointer data, gpointer user_data) g_free(auth); } +static void remove_discovery_list(struct btd_adapter *adapter) +{ + g_slist_free_full(adapter->set_filter_list, discovery_free); + adapter->set_filter_list = NULL; + + g_slist_free_full(adapter->discovery_list, discovery_free); + adapter->discovery_list = NULL; +} + static void adapter_free(gpointer user_data) { struct btd_adapter *adapter = user_data; DBG("%p", adapter); + /* Make sure the adapter's discovery list is cleaned up before freeing + * the adapter. + */ + remove_discovery_list(adapter); + if (adapter->pairable_timeout_id > 0) { g_source_remove(adapter->pairable_timeout_id); adapter->pairable_timeout_id = 0; @@ -6846,11 +6860,7 @@ static void adapter_stop(struct btd_adapter *adapter) cancel_passive_scanning(adapter); - g_slist_free_full(adapter->set_filter_list, discovery_free); - adapter->set_filter_list = NULL; - - g_slist_free_full(adapter->discovery_list, discovery_free); - adapter->discovery_list = NULL; + remove_discovery_list(adapter); discovery_cleanup(adapter, 0); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GASeHZALQF9S5QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 21 Aug 2020 19:59:44 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id APIAHJALQF8mjQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 21 Aug 2020 19:59:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 79F37420E3; Fri, 21 Aug 2020 19:59:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726795AbgHUR7j (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 21 Aug 2020 13:59:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726716AbgHUR7h (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 21 Aug 2020 13:59:37 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B93CC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:59:37 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id ba10so2166468edb.3 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ihrURKlCPLS27xOORytx5XcBleBdUwAl2x0TGY8PiF4=; b=Dj/anq63kq997RdOBOsbWjPwMUK0etdBnZvIKd35K2Teu0e1f0Jh8y7GsMe3RY68gH ej9Xkww8NGbgsdUes7etngA02NqgAkdeqVLeRjVjUECBVYjogsqMxoq6lz+1IVIy/42e JqEc3o+kZNUm2yWgW3wMtsN7Oz1WCI8jgF9xM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ihrURKlCPLS27xOORytx5XcBleBdUwAl2x0TGY8PiF4=; b=qoanl3yCEjM/nx7tuk1OVNHjqaVJ3fwAYVe0MRGTvXau5675QpbqjN1PD5cV9SfL0R 70+NtmBoQ8u584HaRHPvGdcF29GFXqMjYaXXlaP+o1BHy+1TR8WI+kwiUqeB4m1BEvXy VDw3ciRbrjxfEkjlrnWylXR2OP7HwWIssviEx42NtvIy16sXM+aaHXyaUoHvitil3t6G 35MiujfeG35DcUd0mgBk46F1myei4G4yoaNkfWnVEH+B7mB8NzYbus511Q6qYY7W9Ujx ChEVn4DM1gm3N5Q2V9kewCXVHJF7zRs9fMaOHipfmC49UifE0G1ngJv9commRq+eUSNt oMPw== X-Gm-Message-State: AOAM532RUJubIhwFGP4TpxvAA9dZxHGCV1k99CGJ00VfhIypgmW+YZye 0dNwMUncOw5Gj77TmZPk4SG614yiOjMUNA== X-Google-Smtp-Source: ABdhPJz2+eYsgJPf1rHTQN8Q4/IX49lZxDxmQ4WtXFTgySvYfvW4DUqDozCHStCL+q9hFDlr0uSRqA== X-Received: by 2002:aa7:d45a:: with SMTP id q26mr3889984edr.95.1598032775609; Fri, 21 Aug 2020 10:59:35 -0700 (PDT) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com. [209.85.128.52]) by smtp.gmail.com with ESMTPSA id b7sm1665773ejp.65.2020.08.21.10.59.34 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Aug 2020 10:59:35 -0700 (PDT) Received: by mail-wm1-f52.google.com with SMTP id x5so2716383wmi.2 for <linux-bluetooth@vger.kernel.org>; Fri, 21 Aug 2020 10:59:34 -0700 (PDT) X-Received: by 2002:a7b:c5c1:: with SMTP id n1mr4092377wmk.125.1598032774448; Fri, 21 Aug 2020 10:59:34 -0700 (PDT) MIME-Version: 1.0 References: <20200821073714.19626-1-sonnysasaka@chromium.org> <CABBYNZJN0V5iPkJgbh3Xc8cF4Qdp0azcoPM7bjsto4VeVjrzFA@mail.gmail.com> In-Reply-To: <CABBYNZJN0V5iPkJgbh3Xc8cF4Qdp0azcoPM7bjsto4VeVjrzFA@mail.gmail.com> From: Sonny Sasaka <sonnysasaka@chromium.org> Date: Fri, 21 Aug 2020 10:59:22 -0700 X-Gmail-Original-Message-ID: <CAO271m=T7z2BpjPiurcrvyzaed1bG36tQTZTZz4g-VMq7NMW=Q@mail.gmail.com> Message-ID: <CAO271m=T7z2BpjPiurcrvyzaed1bG36tQTZTZz4g-VMq7NMW=Q@mail.gmail.com> Subject: Re: [PATCH BlueZ] adapter: Fix crash in discovery_disconnect To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 79F37420E3 X-Rspamd-UID: 88fb40 Hi Luiz, Thanks for the feedback, I have sent a v2 of this patch. On Fri, Aug 21, 2020 at 10:38 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Sonny, > > On Fri, Aug 21, 2020 at 12:42 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > > > discovery_disconnect crashed because the adapter pointer has been freed > > before. This patch makes sure that discovery list is cleaned up before > > adapter pointer is freed. > > > > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > > > > --- > > src/adapter.c | 19 ++++++++++++++----- > > 1 file changed, 14 insertions(+), 5 deletions(-) > > > > diff --git a/src/adapter.c b/src/adapter.c > > index 5e896a9f0..c0b02bf3f 100644 > > --- a/src/adapter.c > > +++ b/src/adapter.c > > @@ -5316,12 +5316,25 @@ static void free_service_auth(gpointer data, gpointer user_data) > > g_free(auth); > > } > > > > +static void remove_discovery_list(struct btd_adapter *adapter) > > +{ > > + g_slist_free_full(adapter->set_filter_list, discovery_free); > > + adapter->set_filter_list = NULL; > > + > > + g_slist_free_full(adapter->discovery_list, discovery_free); > > + adapter->discovery_list = NULL; > > +} > > + > > static void adapter_free(gpointer user_data) > > { > > struct btd_adapter *adapter = user_data; > > > > DBG("%p", adapter); > > > > + // Make sure the adapter's discovery list is cleaned up before freeing > > + // the adapter. > > Please use C style comments. > > > + remove_discovery_list(adapter); > > + > > if (adapter->pairable_timeout_id > 0) { > > g_source_remove(adapter->pairable_timeout_id); > > adapter->pairable_timeout_id = 0; > > @@ -6846,11 +6859,7 @@ static void adapter_stop(struct btd_adapter *adapter) > > > > cancel_passive_scanning(adapter); > > > > - g_slist_free_full(adapter->set_filter_list, discovery_free); > > - adapter->set_filter_list = NULL; > > - > > - g_slist_free_full(adapter->discovery_list, discovery_free); > > - adapter->discovery_list = NULL; > > + remove_discovery_list(adapter); > > > > discovery_cleanup(adapter, 0); > > > > -- > > 2.26.2 > > Otherwise it looks good. > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uAF3JD8uQV8HzwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 22 Aug 2020 16:39:59 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2F8nIz8uQV8S/QAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 22 Aug 2020 16:39:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D1062420BA; Sat, 22 Aug 2020 16:39:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728115AbgHVOju convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 22 Aug 2020 10:39:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:49330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727948AbgHVOjs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 22 Aug 2020 10:39:48 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Sat, 22 Aug 2020 14:39:45 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mmdesai20@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-dVCjsbIk5V@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.63 / 15.00 / 200.00 X-Rspamd-Queue-Id: D1062420BA X-Rspamd-UID: 3edc15 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #140 from MMD (mmdesai20@gmail.com) --- (In reply to Swyter from comment #137) > Hi! There's actually a script that should help with this, at least as > reference: > https://gist.github.com/nevack/6b36b82d715dc025163d9e9124840a07 > > It's for newer kernels, though. So while the btusb.c part should more or > less apply cleanly (because the existing/original CSR workaround stuff has > been there for a while) the ERR_DATA_REPORTING stuff (on hci_core.c) is new > and will need to be stripped out when back-porting the patch. > > Who knows, maybe it's a good idea to ask someone from Canonical to add it to > Ubuntu, once it's been more battle-tested. Hopefully (as it officially gets > into stable kernels) distros downstream will pick this up, even on super old > Linux versions. > > Hope that helps. :) Hi tried this script, but it gives below error cp: cannot stat '/usr/lib/modules/5.8.2-050802-generic/build/.config': No such file or director I checked there is no such directory and file. I have Ubuntu 20.04 LTS with Kernel 5.4.0-42-generic. Then updated kernel to hoping that 5.8.2-050802-generic hoping by Bluetooth device will work with this .(As you mentioned this script is accepted in 5.7 and 5.8 version of kernel) With new kernel 5.8.2-050802-generic, it detects logitech M337 mouse , but not able to configure. Then I tried above script and got error cp: cannot stat '/usr/lib/modules/5.8.2-050802-generic/build/.config': No such file or director -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mIR7IRhFQV/JNQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 22 Aug 2020 18:17:28 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oB75HxhFQV/5/wEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 22 Aug 2020 18:17:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F100142111; Sat, 22 Aug 2020 18:17:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728381AbgHVQRF (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 22 Aug 2020 12:17:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbgHVQRC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 22 Aug 2020 12:17:02 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCA33C061573; Sat, 22 Aug 2020 09:17:01 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id g6so231944pjl.0; Sat, 22 Aug 2020 09:17:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=J3cCf84pRGt6l3COYzuciKUqvDHPbTbbZOlMmG44vxw=; b=kOmWKml47Sn32ECrtxuwuhU5xK8Y0A0GsqmzZEAafEu5EwWyuP9vMQTW90pA//a/lJ RpBycZZW2nmD033Bh34kHeuIwf53WZ+fICSxu4u9mWMeLZtKB3XRWksAWwQoVrLqdJuL MBSqvgF4/oHdZ7pnjTaJha3qBbv8YUwpqV+YSR+Mj25gRxCeIRFC4H2fZYT2DQQqYjmv lQDxFunAiHiwxvywwojK9W1i0JMK2rsXm3AlJ6Ee6I5pBjSRi31+38UnOCi30GeC4AVZ t0CnyAfTzFZyr9SeOCxo1IsqpH0aKSJtD29yKS5x7h4Izi/atUwBJQ/GhnfmPG0QP6w8 RmLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J3cCf84pRGt6l3COYzuciKUqvDHPbTbbZOlMmG44vxw=; b=Nl2HbgE7O4NV5Yt2EhE/uDB/lpYNeaG/RucrL1I9okhBEiBXKrIl9rdzARh9bLNMGv Zx1eJmWCk02vLNFyhx/rUOZeE9WOB69fL4ZneojEohfAKXRSMrbrajeGlJB1UdXiw59G /lg2iEqvwcKz4Wpg0xbaoNHvVVsm9i2bL32R2GLKL6uTkpVVMjqdrIrkV/Q9G1MjJYmX CYTwRmgcTdgNTppdu2bBvdWD21bVN6h6SIvRE6JP75WVEsvBuBuB8DuFCbbBDbb9I6Nw ud57u2ZcaST/VaEcFIXjRe2Df0mQ/NQ69A/C0ONfYndfzBbCdNvhaDO3ZN7djaIUFYpK jclQ== X-Gm-Message-State: AOAM5303b3gUO+bofJtwJ223C8Q1ghCY3QbJpsE2Uf57EIJFIxgrEMnE gCcz48bUZl6dlVlYc8XZc7fDJgbKkSpHJMl//Nw= X-Google-Smtp-Source: ABdhPJx0RgyDVZQWPrb6x6zJPwDKqXLGzxbxW5FGgwrrubkiuhc4r1yprGmf0a6Yu5+CdWiXcSazig== X-Received: by 2002:a17:902:b486:: with SMTP id y6mr6703488plr.100.1598113020841; Sat, 22 Aug 2020 09:17:00 -0700 (PDT) Received: from localhost ([2001:e42:102:1532:160:16:113:140]) by smtp.gmail.com with ESMTPSA id r7sm6114638pfl.186.2020.08.22.09.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2020 09:17:00 -0700 (PDT) From: Coiby Xu <coiby.xu@gmail.com> X-Google-Original-From: Coiby Xu <Coiby.Xu@gmail.com> Date: Sun, 23 Aug 2020 00:16:46 +0800 To: Dmitry Vyukov <dvyukov@google.com> Cc: syzbot <syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com>, abhishekpandit@chromium.org, David Miller <davem@davemloft.net>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Johan Hedberg <johan.hedberg@gmail.com>, Jakub Kicinski <kuba@kernel.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, netdev <netdev@vger.kernel.org>, Rafael Wysocki <rafael@kernel.org>, syzkaller-bugs <syzkaller-bugs@googlegroups.com>, linux-kernel-mentees@lists.linuxfoundation.org Subject: Re: BUG: corrupted list in kobject_add_internal Message-ID: <20200822161646.xwtpms3fgdmfa7vk@Rk> References: <000000000000c57f2d05ac4c5b8e@google.com> <20200820060713.smilfw3otuunnepe@Rk> <CACT4Y+ZcU11Y0OrxsdKcwqAmJ2BmnP9pCYB1gtiBgciM0+H=cA@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <CACT4Y+ZcU11Y0OrxsdKcwqAmJ2BmnP9pCYB1gtiBgciM0+H=cA@mail.gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: F100142111 X-Rspamd-UID: 50159e On Thu, Aug 20, 2020 at 08:13:47AM +0200, Dmitry Vyukov wrote: >On Thu, Aug 20, 2020 at 8:07 AM Coiby Xu <coiby.xu@gmail.com> wrote: >> >> On Fri, Aug 07, 2020 at 09:47:20AM -0700, syzbot wrote: >> >Hello, >> > >> >syzbot found the following issue on: >> > >> >HEAD commit: 5a30a789 Merge tag 'x86-urgent-2020-08-02' of git://git.ke.. >> >git tree: upstream >> >console output: https://syzkaller.appspot.com/x/log.txt?x=1660c858900000 >> >kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 >> >dashboard link: https://syzkaller.appspot.com/bug?extid=dd768a260f7358adbaf9 >> >compiler: gcc (GCC) 10.1.0-syz 20200507 >> >syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14b73afc900000 >> >C reproducer: https://syzkaller.appspot.com/x/repro.c?x=124893a4900000 >> > >> >The issue was bisected to: >> > >> >commit 4f40afc6c76451daff7d0dcfc8a3d113ccf65bfc >> >Author: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> >> >Date: Wed Mar 11 15:54:01 2020 +0000 >> > >> > Bluetooth: Handle BR/EDR devices during suspend >> > >> >bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11cb1e0a900000 >> >final oops: https://syzkaller.appspot.com/x/report.txt?x=13cb1e0a900000 >> >console output: https://syzkaller.appspot.com/x/log.txt?x=15cb1e0a900000 >> > >> >IMPORTANT: if you fix the issue, please add the following tag to the commit: >> >Reported-by: syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com >> >Fixes: 4f40afc6c764 ("Bluetooth: Handle BR/EDR devices during suspend") >> > >> >debugfs: Directory '200' with parent 'hci0' already present! >> >list_add double add: new=ffff88808e9b6418, prev=ffff88808e9b6418, next=ffff8880a973ef00. >> >------------[ cut here ]------------ >> >kernel BUG at lib/list_debug.c:29! >> >invalid opcode: 0000 [#1] PREEMPT SMP KASAN >> >CPU: 1 PID: 6882 Comm: kworker/u5:1 Not tainted 5.8.0-rc7-syzkaller #0 >> >Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 >> >Workqueue: hci0 hci_rx_work >> >RIP: 0010:__list_add_valid.cold+0x26/0x3c lib/list_debug.c:29 >> >Code: 57 ff ff ff 4c 89 e1 48 c7 c7 20 92 93 88 e8 b1 f1 c1 fd 0f 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 60 93 93 88 e8 9a f1 c1 fd <0f> 0b 48 89 f1 48 c7 c7 e0 92 93 88 4c 89 e6 e8 86 f1 c1 fd 0f 0b >> >RSP: 0018:ffffc90001777830 EFLAGS: 00010282 >> >RAX: 0000000000000058 RBX: ffff8880a973ef00 RCX: 0000000000000000 >> >RDX: ffff888094f1c200 RSI: ffffffff815d4ef7 RDI: fffff520002eeef8 >> >RBP: ffff88808e9b6418 R08: 0000000000000058 R09: ffff8880ae7318e7 >> >R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a973ef00 >> >R13: ffff888087315270 R14: ffff88808e9b6430 R15: ffff88808e9b6418 >> >FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 >> >CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 >> >CR2: 00007ffdcd6db747 CR3: 000000009ba09000 CR4: 00000000001406e0 >> >DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 >> >DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 >> >Call Trace: >> > __list_add include/linux/list.h:67 [inline] >> > list_add_tail include/linux/list.h:100 [inline] >> > kobj_kset_join lib/kobject.c:196 [inline] >> > kobject_add_internal+0x18d/0x940 lib/kobject.c:246 >> > kobject_add_varg lib/kobject.c:390 [inline] >> > kobject_add+0x150/0x1c0 lib/kobject.c:442 >> > device_add+0x35a/0x1be0 drivers/base/core.c:2633 >> > hci_conn_add_sysfs+0x84/0xe0 net/bluetooth/hci_sysfs.c:53 >> > hci_conn_complete_evt net/bluetooth/hci_event.c:2607 [inline] >> > hci_event_packet+0xe0b/0x86f5 net/bluetooth/hci_event.c:6033 >> > hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 >> > process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 >> > worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 >> > kthread+0x3b5/0x4a0 kernel/kthread.c:291 >> > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 >> >Modules linked in: >> >---[ end trace b1bcc552c32d25e9 ]--- >> >RIP: 0010:__list_add_valid.cold+0x26/0x3c lib/list_debug.c:29 >> >Code: 57 ff ff ff 4c 89 e1 48 c7 c7 20 92 93 88 e8 b1 f1 c1 fd 0f 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 60 93 93 88 e8 9a f1 c1 fd <0f> 0b 48 89 f1 48 c7 c7 e0 92 93 88 4c 89 e6 e8 86 f1 c1 fd 0f 0b >> >RSP: 0018:ffffc90001777830 EFLAGS: 00010282 >> >RAX: 0000000000000058 RBX: ffff8880a973ef00 RCX: 0000000000000000 >> >RDX: ffff888094f1c200 RSI: ffffffff815d4ef7 RDI: fffff520002eeef8 >> >RBP: ffff88808e9b6418 R08: 0000000000000058 R09: ffff8880ae7318e7 >> >R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a973ef00 >> >R13: ffff888087315270 R14: ffff88808e9b6430 R15: ffff88808e9b6418 >> >FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 >> >CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 >> >CR2: 00007ffdcd6db747 CR3: 0000000009a79000 CR4: 00000000001406e0 >> >DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 >> >DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 >> > >> > >> >--- >> >This report is generated by a bot. It may contain errors. >> >See https://goo.gl/tpsmEJ for more information about syzbot. >> >syzbot engineers can be reached at syzkaller@googlegroups.com. >> > >> >syzbot will keep track of this issue. See: >> >https://goo.gl/tpsmEJ#status for how to communicate with syzbot. >> >For information about bisection process see: https://goo.gl/tpsmEJ#bisection >> >syzbot can test patches for this issue, for details see: >> >https://goo.gl/tpsmEJ#testing-patches >> > >> >-- >> >You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group. >> >To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com. >> >To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/000000000000c57f2d05ac4c5b8e%40google.com. >> >> This problem occurs because the HCI_EV_CONN_COMPLETE event packet is sent >> twice for the same HCI connection, >> >> struct hci_ev_conn_complete complete; >> memset(&complete, 0, sizeof(complete)); >> complete.status = 0; >> complete.handle = HCI_HANDLE_1; >> memset(&complete.bdaddr, 0xaa, 6); >> *(uint8_t*)&complete.bdaddr.b[5] = 0x10; >> complete.link_type = ACL_LINK; >> complete.encr_mode = 0; >> hci_send_event_packet(vhci_fd, HCI_EV_CONN_COMPLETE, &complete, >> sizeof(complete)); >> >> which leads to kobject_add being called twice. Thus duplicate >> (struct hci_conn *conn)->dev.kobj.entry is inserted into >> (struct hci_conn *conn)->dev.kobj.kset->list. >> >> But if it's the HCI connection creator's responsibility to >> not send the HCI_EV_CONN_COMPLETE event packet twice, then it's not a >> valid bug. Or should we make the kernel more robust by defending against >> this case? > >Hi Coiby, Hi Dmitry, > >Whoever is sending HCI_EV_CONN_COMPLETE, this should not corrupt >kernel memory. Even if it's firmware, it's not necessary trusted, see: >https://www.blackhat.com/us-20/briefings/schedule/index.html#finding-new-bluetooth-low-energy-exploits-via-reverse-engineering-multiple-vendors-firmwares-19655 >and: >https://www.armis.com/bleedingbit/ >So if an attacker takes over firmware, they can then corrupt kernel memory. Thank you for sharing the links. Although I haven't found out how exactly this "list_add double add" corruption would be exploited by an attacker in the two resources or on the Internet (the closest one I can find is CVE-2019-2215 which exploits list_del with CONFIG_DEBUG_LIST disabled), this should be an interesting bug and I'll learn more about Bluetooth to fix it. -- Best regards, Coiby Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uP2KBca/QV/P5QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 23 Aug 2020 03:00:54 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id oJYQBMa/QV87AgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 23 Aug 2020 03:00:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 76825420CF; Sun, 23 Aug 2020 03:00:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726075AbgHWBAi (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 22 Aug 2020 21:00:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbgHWBAi (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 22 Aug 2020 21:00:38 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04921C061573; Sat, 22 Aug 2020 18:00:38 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id g33so2797171pgb.4; Sat, 22 Aug 2020 18:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5+TanUjx4aTdxJYsMsMUFdiokbTUr43+JM8xsRSY+0I=; b=rx6aRGdcfWR0o7pmQXw8pzwtdAHGaRLCgCMimwem4zB0IThITtZDpAl4mr7GQM5ABv l1Xav6doj4OTLnwA4WdMcHEbD88JHGA94UnRMXKLOFYYtKEK9V+IYzcoAfzLlFLkkIZY c+M50sOOGpNS3D89y06E83Ur0YIMmT1+h/ZfNYjOT8pBg/wWehqtd6D4jkUFAEmJZYKB XbAqvmLPMWCwlgh0+4ZmlL2fdeGndIKC6Z3FxKiJGeU60XbTnI596i7sUNUHzyJMpqz1 E4oshkUJ9vHj2h+CgJqIGlXgpPaoG7gDkPCmf+Y4RJZ8CyPClaU/OCI306cSS4xNrpIK 1l7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5+TanUjx4aTdxJYsMsMUFdiokbTUr43+JM8xsRSY+0I=; b=KpjA+l49Q3eKA/KS6wGZJW9MgonSDMkDMXUQkgZKQ0YvyoJQNnj56nsB+8eP3fbWFp sr6QspQVcQKxv2M8TxUJZppyH7qjThA+/xbdfRUIA9USiy7+9dGXE8e30SS5UXXGVYE/ gxYYn4iRuplnZnmWQ84Rh640XpJMySTi6T7qbod7423j0Ow6kiBn3Jp6NpsvVoUXL0b8 w4umKO9w83DzosHLCjDh7PQxOsqNJZm3EiKqbO1a/hq4XYLjgz3HAGpzgBRFTIX4bh4+ D2TyB2rSR2Z+yd+phTrTZotbnVf5tklTcAo85Hf20/HWEozZrUwxTtcKkhudHZpzk1+0 KSHw== X-Gm-Message-State: AOAM530AelOY28gXqNfaCwiC51puINcyUJBplQa5fjAyHqFSZrDe674W hJh3s3iJokAxDxwlsFJV9w9O10uTEj5d/hA4rMc= X-Google-Smtp-Source: ABdhPJz1cfAq4nmjDpSF4+magItyeRjS9uG2hW1AoMBR1/nYYEIytOx/aCMpULiCkbyufqWuEEBc5A== X-Received: by 2002:a65:60ce:: with SMTP id r14mr6742305pgv.85.1598144436460; Sat, 22 Aug 2020 18:00:36 -0700 (PDT) Received: from localhost ([2001:e42:102:1532:160:16:113:140]) by smtp.gmail.com with ESMTPSA id x15sm6875701pfr.208.2020.08.22.18.00.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2020 18:00:35 -0700 (PDT) From: Coiby Xu <coiby.xu@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, gregkh@linuxfoundation.org, syzkaller-bugs@googlegroups.com, syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com, Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, netdev@vger.kernel.org (open list:NETWORKING [GENERAL]), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] Bluetooth: fix "list_add double add" in hci_conn_complete_evt Date: Sun, 23 Aug 2020 09:00:22 +0800 Message-Id: <20200823010022.938532-1-coiby.xu@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <000000000000c57f2d05ac4c5b8e@google.com> References: <000000000000c57f2d05ac4c5b8e@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.90 / 15.00 / 200.00 X-Rspamd-Queue-Id: 76825420CF X-Rspamd-UID: 03e6da When two HCI_EV_CONN_COMPLETE event packets with status=0 of the same HCI connection are received, device_add would be called twice which leads to kobject_add being called twice. Thus duplicate (struct hci_conn *conn)->dev.kobj.entry would be inserted into (struct hci_conn *conn)->dev.kobj.kset->list. This issue can be fixed by checking (struct hci_conn *conn)->debugfs. If it's not NULL, it means the HCI connection has been completed and we won't duplicate the work as for processing the first HCI_EV_CONN_COMPLETE event. Reported-and-tested-by: syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=dd768a260f7358adbaf9 Signed-off-by: Coiby Xu <coiby.xu@gmail.com> --- net/bluetooth/hci_event.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 4b7fc430793c..1233739ce760 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2605,6 +2605,11 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) } if (!ev->status) { + if (conn->debugfs) { + bt_dev_err(hdev, "The connection has been completed"); + goto unlock; + } + conn->handle = __le16_to_cpu(ev->handle); if (conn->type == ACL_LINK) { -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mKpuMKwTQl+nHwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 23 Aug 2020 08:58:52 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CE63LqwTQl8ZyQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 23 Aug 2020 08:58:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5C7CD420B9; Sun, 23 Aug 2020 08:58:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727925AbgHWG6r convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 23 Aug 2020 02:58:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:47496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbgHWG6q (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 23 Aug 2020 02:58:46 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Sun, 23 Aug 2020 06:58:43 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mmdesai20@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-iBD1YAZddQ@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.89 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5C7CD420B9 X-Rspamd-UID: c633b9 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #141 from MMD (mmdesai20@gmail.com) --- (In reply to MMD from comment #140) > (In reply to Swyter from comment #137) > > Hi! There's actually a script that should help with this, at least as > > reference: > > https://gist.github.com/nevack/6b36b82d715dc025163d9e9124840a07 > > > > It's for newer kernels, though. So while the btusb.c part should more or > > less apply cleanly (because the existing/original CSR workaround stuff has > > been there for a while) the ERR_DATA_REPORTING stuff (on hci_core.c) is new > > and will need to be stripped out when back-porting the patch. > > > > Who knows, maybe it's a good idea to ask someone from Canonical to add it > to > > Ubuntu, once it's been more battle-tested. Hopefully (as it officially gets > > into stable kernels) distros downstream will pick this up, even on super > old > > Linux versions. > > > > Hope that helps. :) > > Hi tried this script, but it gives below error > cp: cannot stat '/usr/lib/modules/5.8.2-050802-generic/build/.config': No > such file or director > > I checked there is no such directory and file. > > I have Ubuntu 20.04 LTS with Kernel 5.4.0-42-generic. Then updated kernel to > hoping that 5.8.2-050802-generic hoping by Bluetooth device will work with > this .(As you mentioned this script is accepted in 5.7 and 5.8 version of > kernel) > With new kernel 5.8.2-050802-generic, it detects logitech M337 mouse , but > not able to configure. Then I tried above script and got error > cp: cannot stat '/usr/lib/modules/5.8.2-050802-generic/build/.config': No > such file or director I tried some command as suggested by you on https://gist.github.com/nevack/6b36b82d715dc025163d9e9124840a07 Here is the output of its lsusb -vvd 0a12:0001... gives bcdDevice 25.20 dmesg |grep 'CSR clone detected' [ 75.420911] Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds... [ 4880.814947] Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds... [22664.573526] Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds... [23268.855461] Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds... btmon -w my.log Bluetooth monitor ver 5.54 = Note: Linux version 5.8.2-050802-generic (x86_64) 0.574027 = Note: Bluetooth subsystem version 2.22 0.574029 = New Index: 00:1A:7D:DA:71:10 (Primary,USB,hci0) [hci0] 0.574030 @ MGMT Open: bluetoothd (privileged) version 1.17 {0x0001} 0.574031 @ MGMT Open: btmon (privileged) version 1.17 hcidump -X HCI sniffer - Bluetooth packet analyzer ver 5.53 device: hci0 snap_len: 1500 filter: 0xffffffffffffffff -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +NASKX4eQl8pNAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 23 Aug 2020 09:45:02 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 2G3dJ34eQl9IKQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 23 Aug 2020 09:45:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CFFD1A1580; Sun, 23 Aug 2020 09:44:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726429AbgHWHoc (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 23 Aug 2020 03:44:32 -0400 Received: from mail.zju.edu.cn ([61.164.42.155]:21746 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726231AbgHWHoc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 23 Aug 2020 03:44:32 -0400 Received: from localhost.localdomain (unknown [210.32.144.184]) by mail-app2 (Coremail) with SMTP id by_KCgDnz55VHkJfniscAg--.14603S4; Sun, 23 Aug 2020 15:44:25 +0800 (CST) From: Dinghao Liu <dinghao.liu@zju.edu.cn> To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Bluetooth: btusb: Fix memleak in btusb_mtk_submit_wmt_recv_urb Date: Sun, 23 Aug 2020 15:44:21 +0800 Message-Id: <20200823074421.20769-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: by_KCgDnz55VHkJfniscAg--.14603S4 X-Coremail-Antispam: 1UD129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUYs7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_GF4l 42xK82IYc2Ij64vIr41l42xK82IY6x8ErcxFaVAv8VW8uw4UJr1UMxC20s026xCaFVCjc4 AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE 17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMI IF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Wr1j6rW3 Jr1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcS sGvfC2KfnxnUUI43ZEXa7VUbhiSPUUUUU== X-CM-SenderInfo: qrrzjiaqtzq6lmxovvfxof0/1tbiAgoSBlZdtPnBhAA7sk Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: CFFD1A1580 X-Rspamd-UID: 52f098 When kmalloc() on buf fails, urb should be freed just like when kmalloc() on dr fails. Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> --- drivers/bluetooth/btusb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 8d2608ddfd08..f88968bcdd6a 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2896,6 +2896,7 @@ static int btusb_mtk_submit_wmt_recv_urb(struct hci_dev *hdev) buf = kmalloc(size, GFP_KERNEL); if (!buf) { kfree(dr); + usb_free_urb(urb); return -ENOMEM; } -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kHvEOfA5Q1+VkAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 05:54:24 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0I7SN/A5Q19tpAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 05:54:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B6C9AA01FB; Mon, 24 Aug 2020 05:54:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728022AbgHXDyS (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 23 Aug 2020 23:54:18 -0400 Received: from mga07.intel.com ([134.134.136.100]:64620 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727912AbgHXDyS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 23 Aug 2020 23:54:18 -0400 IronPort-SDR: /7pBq2we/vMlkaBRYaw1KfRkYQeC7OHLUX/QgcgJ1j0U7wdbllPG7F7nZZ3plZ1hEVhN9dyI4c cVzpCPl1mAtA== X-IronPort-AV: E=McAfee;i="6000,8403,9722"; a="220106399" X-IronPort-AV: E=Sophos;i="5.76,347,1592895600"; d="scan'208";a="220106399" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2020 20:54:17 -0700 IronPort-SDR: MDvRtTIEoZHxEv7KLDj4NPwV1ZZCvbhnjmgapV58RKb4wKfvDmnxK5nsVrH/dH0HiuJt9HlArb qN3nv/+Q4WbA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,347,1592895600"; d="scan'208";a="322017090" Received: from jlpajela-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.252.134.16]) by fmsmga004.fm.intel.com with ESMTP; 23 Aug 2020 20:54:17 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 1/4] doc/mesh-api: Add "options" dictionary to Send/Publish Date: Sun, 23 Aug 2020 20:54:12 -0700 Message-Id: <20200824035415.13420-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200824035415.13420-1-inga.stotland@intel.com> References: <20200824035415.13420-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: B6C9AA01FB X-Rspamd-UID: 6541cf This modifies Send, DevKeySend, Publish & VendorPublish methods on mesh.Node interface to include additional argument "options". This new argument is a dictionary that currently has only one new key word defined: "ForceSegmented" - to force small payloads to be sent as one-segment messages Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification. --- doc/mesh-api.txt | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt index 495f95b0b..f836142a7 100644 --- a/doc/mesh-api.txt +++ b/doc/mesh-api.txt @@ -229,7 +229,7 @@ Object path /org/bluez/mesh/node<uuid> Methods: void Send(object element_path, uint16 destination, uint16 key_index, - array{byte} data) + dict options, array{byte} data) This method is used to send a message originated by a local model. @@ -248,6 +248,14 @@ Methods: this element. Otherwise, org.bluez.mesh.Error.NotAuthorized will be returned. + The options parameter is a dictionary with the following keys + defined: + + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". + The data parameter is an outgoing message to be encypted by the bluetooth-meshd daemon and sent on. @@ -257,7 +265,7 @@ Methods: org.bluez.mesh.Error.NotFound void DevKeySend(object element_path, uint16 destination, boolean remote, - uint16 net_index, array{byte} data) + uint16 net_index, dict options, array{byte} data) This method is used to send a message originated by a local model encoded with the device key of the remote node. @@ -279,6 +287,14 @@ Methods: The net_index parameter is the subnet index of the network on which the message is to be sent. + The options parameter is a dictionary with the following keys + defined: + + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". + The data parameter is an outgoing message to be encypted by the meshd daemon and sent on. @@ -344,7 +360,8 @@ Methods: org.bluez.mesh.Error.InvalidArguments org.bluez.mesh.Error.NotFound - void Publish(object element_path, uint16 model, array{byte} data) + void Publish(object element_path, uint16 model, dict options, + array{byte} data) This method is used to send a publication originated by a local model. If the model does not exist, or it has no publication @@ -358,6 +375,17 @@ Methods: The model parameter contains a model ID, as defined by the Bluetooth SIG. + The options parameter is a dictionary with the following keys + defined: + + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". + + The data parameter is an outgoing message to be encypted by the + meshd daemon and sent on. + Since only one Publish record may exist per element-model, the destination and key_index are obtained from the Publication record cached by the daemon. @@ -367,7 +395,7 @@ Methods: org.bluez.mesh.Error.InvalidArguments void VendorPublish(object element_path, uint16 vendor, uint16 model_id, - array{byte} data) + dict options, array{byte} data) This method is used to send a publication originated by a local vendor model. If the model does not exist, or it has no @@ -383,6 +411,17 @@ Methods: The model_id parameter is a 16-bit vendor-assigned Model Identifier. + The options parameter is a dictionary with the following keys + defined: + + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". + + The data parameter is an outgoing message to be encypted by the + meshd daemon and sent on. + Since only one Publish record may exist per element-model, the destination and key_index are obtained from the Publication record cached by the daemon. -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CMlgBfo5Q1+qjQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 05:54:34 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id EKiUA/o5Q1+n9wEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 05:54:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A2B84A01FB; Mon, 24 Aug 2020 05:54:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728070AbgHXDyT (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 23 Aug 2020 23:54:19 -0400 Received: from mga07.intel.com ([134.134.136.100]:64622 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728051AbgHXDyT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 23 Aug 2020 23:54:19 -0400 IronPort-SDR: UuRAfZvCdXJpz/6l/IAbAQoLDRDiZKBc/IIFT2pWmU6K2eC2cTH4oBhcR0IGtpon5bwN6XSknf ZvXt6Yws6UEg== X-IronPort-AV: E=McAfee;i="6000,8403,9722"; a="220106401" X-IronPort-AV: E=Sophos;i="5.76,347,1592895600"; d="scan'208";a="220106401" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2020 20:54:18 -0700 IronPort-SDR: 8NgeNABJoNFHhGcMG+Aa6pMKKL1WbzOeCZc4cM4h+2AbGusKIEifsyh0XLK0L8OqAHbxDOsjhJ CE4roO0Llw6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,347,1592895600"; d="scan'208";a="322017099" Received: from jlpajela-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.252.134.16]) by fmsmga004.fm.intel.com with ESMTP; 23 Aug 2020 20:54:18 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 3/4] tools/mesh-cfglient: Add "options" to Send/DevKeySend Date: Sun, 23 Aug 2020 20:54:14 -0700 Message-Id: <20200824035415.13420-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200824035415.13420-1-inga.stotland@intel.com> References: <20200824035415.13420-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: A2B84A01FB X-Rspamd-UID: 28bb24 This adds a new dictionary paramenter (empty by default) when invoking Send() and DevKeySend() methods. --- tools/mesh-cfgclient.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 59f079213..3987e3179 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -274,6 +274,14 @@ static void send_msg_setup(struct l_dbus_message *msg, void *user_data) l_dbus_message_builder_append_basic(builder, 'b', &req->rmt); l_dbus_message_builder_append_basic(builder, 'q', &req->idx); + + /* Options */ + l_dbus_message_builder_enter_array(builder, "{sv}"); + l_dbus_message_builder_enter_dict(builder, "sv"); + l_dbus_message_builder_leave_dict(builder); + l_dbus_message_builder_leave_array(builder); + + /* Data */ append_byte_array(builder, req->data, req->len); l_dbus_message_builder_finalize(builder); l_dbus_message_builder_destroy(builder); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8AObIPU5Q1+qjQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 05:54:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id iN62HvU5Q19tpAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 05:54:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 13E3AA1197; Mon, 24 Aug 2020 05:54:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728058AbgHXDyT (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 23 Aug 2020 23:54:19 -0400 Received: from mga07.intel.com ([134.134.136.100]:64620 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727986AbgHXDyS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 23 Aug 2020 23:54:18 -0400 IronPort-SDR: hIPanseINlgVPxm8fwq3LbPy7vyD+3Tmog33PEJXHEvLt4txy0dSzO12sQz+w8gET9Se+Yp6/j 4r9HJuhAKioA== X-IronPort-AV: E=McAfee;i="6000,8403,9722"; a="220106398" X-IronPort-AV: E=Sophos;i="5.76,347,1592895600"; d="scan'208";a="220106398" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2020 20:54:16 -0700 IronPort-SDR: Sww/gu6kXdHsYlo903CDDiFJTzU/Q7q5XjcOyTHCTiHlhsWAwGR2VgXckpZrz8VfpDwSymH76k widMGTf4cMzA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,347,1592895600"; d="scan'208";a="322017085" Received: from jlpajela-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.252.134.16]) by fmsmga004.fm.intel.com with ESMTP; 23 Aug 2020 20:54:16 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 0/4] Mesh send/publish API change Date: Sun, 23 Aug 2020 20:54:11 -0700 Message-Id: <20200824035415.13420-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.41 / 15.00 / 200.00 X-Rspamd-Queue-Id: 13E3AA1197 X-Rspamd-UID: e3cadc This patch set modifies Send, DevKeySend, Publish & VendorPublish methods on bleuz.mesh.Node interface to include additional argument "options". This new argument is a dictionary that currently has only one new key word defined: "ForceSegmented" - to force small payloads to be sent as one-segment messages Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification. Inga Stotland (4): doc/mesh-api: Add "options" dictionary to Send/Publish mesh: Handle "options" dictionary in Send/Publish methods tools/mesh-cfglient: Add "options" to Send/DevKeySend test/test-mesh: Add "options" to Send/Publish doc/mesh-api.txt | 47 ++++++++++++++++++-- mesh/cfgmod-server.c | 2 +- mesh/model.c | 6 +-- mesh/model.h | 9 ++-- mesh/node.c | 99 +++++++++++++++++++++++++++++------------- test/test-mesh | 10 ++++- tools/mesh-cfgclient.c | 8 ++++ 7 files changed, 136 insertions(+), 45 deletions(-) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UEzrLP45Q1+qjQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 05:54:38 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id EPf/Kv45Q18sywEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 05:54:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 30227A11B1; Mon, 24 Aug 2020 05:54:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728093AbgHXDyU (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 23 Aug 2020 23:54:20 -0400 Received: from mga07.intel.com ([134.134.136.100]:64622 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728083AbgHXDyT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 23 Aug 2020 23:54:19 -0400 IronPort-SDR: Y9fTsTkdclU8y1P9pKIap9+Dqx7vi1dup1ZI21ncB1GdOvFeo6CfaLmzLb1ZATs0nyql8M1yho FG8caJFcCfRw== X-IronPort-AV: E=McAfee;i="6000,8403,9722"; a="220106403" X-IronPort-AV: E=Sophos;i="5.76,347,1592895600"; d="scan'208";a="220106403" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2020 20:54:19 -0700 IronPort-SDR: uBAWpxkAW+8fNMdxbjOnomFUqqhUiKzvTQt8pd1QP2mbTEzgf0bzckcOHudCpcRYpwhluGVjsy oU2X3zySH07Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,347,1592895600"; d="scan'208";a="322017102" Received: from jlpajela-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.252.134.16]) by fmsmga004.fm.intel.com with ESMTP; 23 Aug 2020 20:54:19 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 4/4] test/test-mesh: Add "options" to Send/Publish Date: Sun, 23 Aug 2020 20:54:15 -0700 Message-Id: <20200824035415.13420-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200824035415.13420-1-inga.stotland@intel.com> References: <20200824035415.13420-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 30227A11B1 X-Rspamd-UID: 3cf075 This adds a new dictionary paramenter (empty by default) when invoking Send() or Publish() methods. --- test/test-mesh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test-mesh b/test/test-mesh index 5da0278d6..918ec8799 100755 --- a/test/test-mesh +++ b/test/test-mesh @@ -183,6 +183,8 @@ current_menu = None user_input = 0 input_error = False +#send_opts = {'ForcedSegmented' : dbus.Boolean(False)} +send_opts = dbus.Dictionary(signature='sv') def raise_error(str_value): global input_error @@ -538,14 +540,18 @@ class Model(): self.pub_period = period def send_publication(self, data): + global send_opts + print('Send publication ', end='') print(data) - node.Publish(self.path, self.model_id, data, + node.Publish(self.path, self.model_id, send_opts, data, reply_handler=generic_reply_cb, error_handler=generic_error_cb) def send_message(self, dest, key, data): - node.Send(self.path, dest, key, data, + global send_opts + + node.Send(self.path, dest, key, send_opts, data, reply_handler=generic_reply_cb, error_handler=generic_error_cb) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aKUULgM6Q1+VkAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 05:54:43 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 0IXXLAM6Q18lNwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 05:54:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D3E8DA0035; Mon, 24 Aug 2020 05:54:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728097AbgHXDyV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 23 Aug 2020 23:54:21 -0400 Received: from mga07.intel.com ([134.134.136.100]:64620 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727912AbgHXDyT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 23 Aug 2020 23:54:19 -0400 IronPort-SDR: 1Rz1tuAxjoOXC8w2SaiVgloNcArpDNEPTquI7qZPltBqSzEpb+ACCD7BXAkGEccgNfruikyIdA qHAV81X1iKrw== X-IronPort-AV: E=McAfee;i="6000,8403,9722"; a="220106400" X-IronPort-AV: E=Sophos;i="5.76,347,1592895600"; d="scan'208";a="220106400" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2020 20:54:18 -0700 IronPort-SDR: wFhIElAgv5k63IvF+mlHDR/w0D5ATAtnYKTtZ3xvFTphzbQPIhulAiz09Gbc+R8WUW3ci6UIax rzxhgcnqR3vA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,347,1592895600"; d="scan'208";a="322017095" Received: from jlpajela-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.252.134.16]) by fmsmga004.fm.intel.com with ESMTP; 23 Aug 2020 20:54:17 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 2/4] mesh: Handle "options" dictionary in Send/Publish methods Date: Sun, 23 Aug 2020 20:54:13 -0700 Message-Id: <20200824035415.13420-3-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200824035415.13420-1-inga.stotland@intel.com> References: <20200824035415.13420-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: D3E8DA0035 X-Rspamd-UID: 27d149 This adds processing of "options" dictionary argument in Send, DevKeySend, Publish & VendorPublish methods on mesh.Node interface. Only "ForceSegmented" keyword is defined to require sending small payloads as one-segment messages. --- mesh/cfgmod-server.c | 2 +- mesh/model.c | 6 +-- mesh/model.h | 9 ++-- mesh/node.c | 99 +++++++++++++++++++++++++++++++------------- 4 files changed, 77 insertions(+), 39 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 239ea889d..2e5da863a 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -1088,7 +1088,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (n) mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, - DEFAULT_TTL, false, msg, n); + DEFAULT_TTL, false, n, msg); return true; } diff --git a/mesh/model.c b/mesh/model.c index bb5d30083..7bbc9cca7 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -999,7 +999,7 @@ done: } int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, - const void *msg, uint16_t msg_len) + bool segmented, uint16_t msg_len, const void *msg) { struct mesh_net *net = node_get_net(node); struct mesh_model *mod; @@ -1041,7 +1041,7 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, result = msg_send(node, mod->pub->credential != 0, src, mod->pub->addr, mod->pub->idx, net_idx, label, mod->pub->ttl, mod->pub->rtx.cnt, mod->pub->rtx.interval, - false, msg, msg_len); + segmented, msg, msg_len); return result ? MESH_ERROR_NONE : MESH_ERROR_FAILED; } @@ -1049,7 +1049,7 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, uint8_t ttl, bool segmented, - const void *msg, uint16_t msg_len) + uint16_t msg_len, const void *msg) { struct mesh_net *net = node_get_net(node); uint8_t cnt; diff --git a/mesh/model.h b/mesh/model.h index a1afedd19..fe0648d04 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -112,19 +112,16 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size); uint16_t mesh_model_cfg_blk(uint8_t *pkt); bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, - uint16_t app_idx, uint16_t net_idx, - uint8_t ttl, bool segmented, - const void *msg, uint16_t msg_len); + uint16_t app_idx, uint16_t net_idx, uint8_t ttl, + bool segmented, uint16_t len, const void *data); int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, - const void *msg, uint16_t msg_len); + bool segmented, uint16_t len, const void *data); bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, uint32_t seq, uint32_t iv_index, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t key_aid, const uint8_t *data, uint16_t size); -void mesh_model_app_key_generate_new(struct mesh_node *node, uint16_t net_idx); void mesh_model_app_key_delete(struct mesh_node *node, uint16_t ele_idx, struct l_queue *models, uint16_t app_idx); -struct l_queue *mesh_model_get_appkeys(struct mesh_node *node); uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf); bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, uint32_t *opcode, uint16_t *n); diff --git a/mesh/node.c b/mesh/node.c index a6e9cee65..a06c290f9 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -134,6 +134,10 @@ struct managed_obj_request { }; }; +struct send_options { + bool segmented; +}; + static struct l_queue *nodes; static bool match_device_uuid(const void *a, const void *b) @@ -1745,13 +1749,33 @@ void node_build_attach_reply(struct mesh_node *node, l_dbus_message_builder_destroy(builder); } +static bool parse_send_options(struct l_dbus_message_iter *itr, + struct send_options *opts) +{ + const char *key; + struct l_dbus_message_iter var; + + opts->segmented = false; + + while (l_dbus_message_iter_next_entry(itr, &key, &var)) { + if (!strcmp(key, "ForceSegmented")) { + if (!l_dbus_message_iter_get_variant(&var, "b", + &opts->segmented)) + return false; + } + } + + return true; +} + static struct l_dbus_message *send_call(struct l_dbus *dbus, struct l_dbus_message *msg, void *user_data) { struct mesh_node *node = user_data; const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; + struct l_dbus_message_iter dict, iter_data; + struct send_options opts; struct node_element *ele; uint16_t dst, app_idx, net_idx, src; uint8_t *data; @@ -1764,8 +1788,8 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &dst, - &app_idx, &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqqa{sv}ay", &ele_path, &dst, + &app_idx, &dict, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); ele = l_queue_find(node->elements, match_element_path, ele_path); @@ -1773,6 +1797,9 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_NOT_FOUND, "Element not found"); + if (!parse_send_options(&dict, &opts)) + return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); + src = node_get_primary(node) + ele->idx; if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || @@ -1790,7 +1817,7 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, "Key not found"); if (!mesh_model_send(node, src, dst, app_idx, net_idx, DEFAULT_TTL, - false, data, len)) + opts.segmented, len, data)) return dbus_error(msg, MESH_ERROR_FAILED, NULL); return l_dbus_message_new_method_return(msg); @@ -1802,7 +1829,8 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, { struct mesh_node *node = user_data; const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; + struct l_dbus_message_iter iter_data, dict; + struct send_options opts; struct node_element *ele; uint16_t dst, app_idx, net_idx, src; bool remote; @@ -1816,8 +1844,8 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqbqay", &ele_path, &dst, - &remote, &net_idx, &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqbqa{sv}ay", &ele_path, &dst, + &remote, &net_idx, &dict, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); /* Loopbacks to local servers must use *remote* addressing */ @@ -1829,6 +1857,9 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_NOT_FOUND, "Element not found"); + if (!parse_send_options(&dict, &opts)) + return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); + src = node_get_primary(node) + ele->idx; if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || @@ -1838,7 +1869,7 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, app_idx = remote ? APP_IDX_DEV_REMOTE : APP_IDX_DEV_LOCAL; if (!mesh_model_send(node, src, dst, app_idx, net_idx, DEFAULT_TTL, - false, data, len)) + opts.segmented, len, data)) return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); return l_dbus_message_new_method_return(msg); @@ -1896,7 +1927,7 @@ static struct l_dbus_message *add_netkey_call(struct l_dbus *dbus, l_put_le16(sub_idx, &data[2]); if (!mesh_model_send(node, src, dst, APP_IDX_DEV_REMOTE, net_idx, - DEFAULT_TTL, false, data, 20)) + DEFAULT_TTL, false, 20, data)) return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); return l_dbus_message_new_method_return(msg); @@ -1962,7 +1993,7 @@ static struct l_dbus_message *add_appkey_call(struct l_dbus *dbus, data[3] = app_idx >> 4; if (!mesh_model_send(node, src, dst, APP_IDX_DEV_REMOTE, net_idx, - DEFAULT_TTL, false, data, 20)) + DEFAULT_TTL, false, 20, data)) return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); return l_dbus_message_new_method_return(msg); @@ -1974,8 +2005,9 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, { struct mesh_node *node = user_data; const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; + struct l_dbus_message_iter iter_data, dict; uint16_t mod_id, src; + struct send_options opts; struct node_element *ele; uint8_t *data; uint32_t len, id; @@ -1988,8 +2020,8 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqay", &ele_path, &mod_id, - &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqa{sv}ay", &ele_path, &mod_id, + &dict, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); ele = l_queue_find(node->elements, match_element_path, ele_path); @@ -1997,6 +2029,9 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_NOT_FOUND, "Element not found"); + if (!parse_send_options(&dict, &opts)) + return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); + src = node_get_primary(node) + ele->idx; if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || @@ -2005,7 +2040,7 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, "Incorrect data"); id = SET_ID(SIG_VENDOR, mod_id); - result = mesh_model_publish(node, id, src, data, len); + result = mesh_model_publish(node, id, src, opts.segmented, len, data); if (result != MESH_ERROR_NONE) return dbus_error(msg, result, NULL); @@ -2019,8 +2054,9 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, { struct mesh_node *node = user_data; const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; + struct l_dbus_message_iter iter_data, dict; uint16_t src, mod_id, vendor_id; + struct send_options opts; struct node_element *ele; uint8_t *data = NULL; uint32_t len; @@ -2033,8 +2069,8 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &vendor_id, - &mod_id, &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqqa{sv}ay", &ele_path, + &vendor_id, &mod_id, &dict, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); ele = l_queue_find(node->elements, match_element_path, ele_path); @@ -2042,6 +2078,9 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_NOT_FOUND, "Element not found"); + if (!parse_send_options(&dict, &opts)) + return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); + src = node_get_primary(node) + ele->idx; if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || @@ -2050,7 +2089,7 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, "Incorrect data"); result = mesh_model_publish(node, SET_ID(vendor_id, mod_id), src, - data, len); + opts.segmented, len, data); if (result != MESH_ERROR_NONE) return dbus_error(msg, result, NULL); @@ -2192,27 +2231,29 @@ static bool addresses_getter(struct l_dbus *dbus, struct l_dbus_message *msg, static void setup_node_interface(struct l_dbus_interface *iface) { - l_dbus_interface_method(iface, "Send", 0, send_call, "", "oqqay", + l_dbus_interface_method(iface, "Send", 0, send_call, "", "oqqa{sv}ay", "element_path", "destination", - "key_index", "data"); - l_dbus_interface_method(iface, "DevKeySend", 0, dev_key_send_call, - "", "oqbqay", "element_path", + "key_index", "options", "data"); + l_dbus_interface_method(iface, "DevKeySend", 0, dev_key_send_call, "", + "oqbqa{sv}ay", "element_path", "destination", "remote", - "net_index", "data"); + "net_index", "options", "data"); l_dbus_interface_method(iface, "AddNetKey", 0, add_netkey_call, "", "oqqqb", "element_path", "destination", "subnet_index", "net_index", "update"); l_dbus_interface_method(iface, "AddAppKey", 0, add_appkey_call, "", "oqqqb", "element_path", "destination", "app_index", "net_index", "update"); - l_dbus_interface_method(iface, "Publish", 0, publish_call, "", "oqay", - "element_path", "model_id", "data"); + l_dbus_interface_method(iface, "Publish", 0, publish_call, "", + "oqa{sv}ay", "element_path", "model_id", + "options", "data"); l_dbus_interface_method(iface, "VendorPublish", 0, vendor_publish_call, - "", "oqqay", "element_path", - "vendor", "model_id", "data"); + "", "oqqa{sv}ay", "element_path", + "vendor", "model_id", "options", + "data"); - l_dbus_interface_property(iface, "Features", 0, "a{sv}", features_getter, - NULL); + l_dbus_interface_property(iface, "Features", 0, "a{sv}", + features_getter, NULL); l_dbus_interface_property(iface, "Beacon", 0, "b", beacon_getter, NULL); l_dbus_interface_property(iface, "IvUpdate", 0, "b", ivupdate_getter, NULL); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OMhULdVBQ1+MrAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 06:28:05 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OCUNLNVBQ199UwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 06:28:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B63B0420C2; Mon, 24 Aug 2020 06:28:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726971AbgHXE15 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 00:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726765AbgHXE15 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 00:27:57 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAC53C061573 for <linux-bluetooth@vger.kernel.org>; Sun, 23 Aug 2020 21:27:56 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id m7so6330803qki.12 for <linux-bluetooth@vger.kernel.org>; Sun, 23 Aug 2020 21:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=TgYhbpDn3D0QSoFG2P+Jzpa0v4YA7FN0UjYK2FNiWsQ=; b=qSnacnz1I1cf4KLLZQMOyGCoh6NtlMhwUwWi3/HcTlMNbDkBJ9OsRJp/6VNI57Rfze uU1U+STFuozTanmdTeB1Ovb9L9qC24rbj/WOiHDM/IKEPyTp3lJl4Zx4YrPNpwqWMTL7 y4lx36+mHxKGwOl7tNbUFNVXwfU46lN9QoUkjhAYaUFVAWyJ5jk8J68cdPygn2ryUqyc zJlqzQHhS887a78x4ggezCCGPtzyeAPKXJI/spdOGMW5OkW+TC4zd7V8OCMfPNaTyELB iQxiqN0faGviplVQi9nlhBipwzC5QKMSQz+XYIhpl/tpP/NnD1tB9OA1uFuzhrbBuHrz 4doA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=TgYhbpDn3D0QSoFG2P+Jzpa0v4YA7FN0UjYK2FNiWsQ=; b=DlgeWqKdWO4kENSFZQ1UfKU9e/UZ208DVMK8UgUqxp8zhLE89x7N7rxPorT/R5Yduy 2UDg5y/pz1566JbPVM99gE6BX37OHDaQTpzjKdt+9tjpmIOqAbhMtDDmnqN4FdVCUofv ahofuDs2vSSq+FIS6nNK/NtTAjxbLD376RQTHoNN71KdTig336vkbcvWGMlQZ0YmqT7B y9/N8l1EmP6bi/lBTYQ/De8ndLhWMmJnSjkvTkcRt2XLr53raE9QGYnZvCzyKHm0f6h4 LRgls6zFISAzlRgr2sCTouotzBxxjBCYKU6DnGsxI5AeNjyaUnW6J7gV3hF3DeW4lTKM +OyA== X-Gm-Message-State: AOAM532ObOhyRcPkr547LoSJ4rwgHBEM3g9AvlsEz7awu8Kn4apglAm2 26+lBgUltUBYLpLNxudlGHkqh/AOGSw2MQ== X-Google-Smtp-Source: ABdhPJzKnNroZADnOg/ujqXYqfTIWxdUuRbG7X9U9AZ+tPN9lMe3dFMI+ddJUaS/6nGmyt55Ri8i8Q== X-Received: by 2002:a05:620a:652:: with SMTP id a18mr3206729qka.165.1598243275619; Sun, 23 Aug 2020 21:27:55 -0700 (PDT) Received: from [172.17.0.2] ([20.186.104.30]) by smtp.gmail.com with ESMTPSA id n33sm10246879qtd.43.2020.08.23.21.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 21:27:55 -0700 (PDT) Message-ID: <5f4341cb.1c69fb81.9bb8a.9693@mx.google.com> Date: Sun, 23 Aug 2020 21:27:55 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3150478193455029858==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, inga.stotland@intel.com Subject: RE: [BlueZ,1/4] doc/mesh-api: Add "options" dictionary to Send/Publish Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200824035415.13420-2-inga.stotland@intel.com> References: <20200824035415.13420-2-inga.stotland@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.87 / 15.00 / 200.00 X-Rspamd-Queue-Id: B63B0420C2 X-Rspamd-UID: 689fc8 --===============3150478193455029858== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 8: B3 Line contains hard tab characters (\t): " one-segment messages" --- Regards, Linux Bluetooth --===============3150478193455029858==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0JOnA42PQ19xmwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 11:59:41 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sNhWAo2PQ1+jsgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 11:59:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=omicronenergy.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 339C4A1BD0; Mon, 24 Aug 2020 11:59:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730206AbgHXIxg (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 04:53:36 -0400 Received: from ns.omicron.at ([212.183.10.25]:44154 "EHLO ns.omicron.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730192AbgHXIxd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 04:53:33 -0400 Received: from MGW02-ATKLA.omicron.at ([172.25.62.35]) by ns.omicron.at (8.15.2/8.15.2) with ESMTPS id 07O8rSsN004667 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 10:53:29 +0200 DKIM-Filter: OpenDKIM Filter v2.11.0 ns.omicron.at 07O8rSsN004667 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omicronenergy.com; s=default; t=1598259209; bh=ZJT3fiqNv7I2DTe+Bchc6djTPvtBSe9dbITUr8DTt5M=; h=Subject:From:To:CC:Date:In-Reply-To:References:From; b=a1n57/lwZpPSWlc7Ixfv6IBAoF8dCTAlm6bRXf8Jv6AgJRvqqHRwYdPMI+8ej25eE d3waAKaAvJlcgp2Wxl0Xia2OELcYiA3mh5IQCUGQQ7SLnhOW/fmldDlSly6VWULN1A RmER2X0/9NoVYF9eXFS2CDw6h2/w2hj+NVF+/+tk= Received: from MGW02-ATKLA.omicron.at (localhost [127.0.0.1]) by MGW02-ATKLA.omicron.at (Postfix) with ESMTP id 4F638A0068 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 10:53:28 +0200 (CEST) Received: from MGW01-ATKLA.omicron.at (unknown [172.25.62.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by MGW02-ATKLA.omicron.at (Postfix) with ESMTPS id 4B438A0062 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 10:53:28 +0200 (CEST) Received: from EXC04-ATKLA.omicron.at ([172.22.100.189]) by MGW01-ATKLA.omicron.at with ESMTP id 07O8rSue006416-07O8rSug006416 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=CAFAIL); Mon, 24 Aug 2020 10:53:28 +0200 Received: from marmar13.omicron.at (172.22.32.104) by EXC04-ATKLA.omicron.at (172.22.100.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 24 Aug 2020 10:53:26 +0200 Message-ID: <6293792d2a4971529ff6f6e3327a2497ad7870c3.camel@omicronenergy.com> Subject: Re: [PATCH BlueZ 2/2] src/profile.c: Add a GetProfileInfo method From: Mark Marshall <mark.marshall@omicronenergy.com> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> CC: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Date: Mon, 24 Aug 2020 10:53:26 +0200 In-Reply-To: <CABBYNZ+U+Edyb42oKWgsqVKHCZZDzXR4HRRrK0Rb2vEL_A3aiA@mail.gmail.com> References: <20200819150931.3005-1-mark.marshall@omicronenergy.com> <2303f692-bb7c-4851-86fa-befde45b4b32@EXC04-ATKLA.omicron.at> <CABBYNZ+OK4EY9KGHn7oasz4GRfBDJdWNcpOhr1GNGc3D+QtZ-g@mail.gmail.com> <3e98e7dae29ec7be6d67fca6af99f2e0f747375e.camel@omicronenergy.com> <CABBYNZ+U+Edyb42oKWgsqVKHCZZDzXR4HRRrK0Rb2vEL_A3aiA@mail.gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-IP: [172.22.32.104] X-ClientProxiedBy: EXC04-ATKLA.omicron.at (172.22.100.189) To EXC04-ATKLA.omicron.at (172.22.100.189) X-FE-Policy-ID: 1:1:1:SYSTEM Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.38 / 15.00 / 200.00 X-Rspamd-Queue-Id: 339C4A1BD0 X-Rspamd-UID: b6e4bf On Thu, 2020-08-20 at 09:33 -0700, Luiz Augusto von Dentz wrote: > Hi Mark, > > On Thu, Aug 20, 2020 at 3:10 AM Mark Marshall > <mark.marshall@omicronenergy.com> wrote: > > > > On Wed, 2020-08-19 at 11:37 -0700, Luiz Augusto von Dentz wrote: > > > Hi Mark, > > > > > > On Wed, Aug 19, 2020 at 8:13 AM Mark Marshall > > > <mark.marshall@omicronenergy.com> wrote: > > > > > > > > Add a GetProfileInfo method to org.bluez.ProfileManager1 > > > > --- > > > > doc/profile-api.txt | 13 +++++++ > > > > src/profile.c | 93 +++++++++++++++++++++++++++++++++++++++++++++ > > > > 2 files changed, 106 insertions(+) > > > > > > > > diff --git a/doc/profile-api.txt b/doc/profile-api.txt > > > > index 8c7d0a06d..d13703ab4 100644 > > > > --- a/doc/profile-api.txt > > > > +++ b/doc/profile-api.txt > > > > @@ -133,6 +133,19 @@ Object path /org/bluez > > > > > > > > Possible errors: org.bluez.Error.DoesNotExist > > > > > > > > + options GetProfileInfo(object profile, object adapter) > > > > + > > > > + This returns a dictionary of options for the > > > > + profile. Values returned are: UUID, Name, > > > > + Path, Service, Mode and AddressType. The > > > > + adapter parameter is optional - if it is > > > > + non-empty, then two additional values might be > > > > + returned, if the profile is active on the > > > > + specified adapter: PSM and Channel. > > > > + > > > > + Possible errors: org.bluez.Error.InvalidArguments > > > > + org.bluez.Error.DoesNotExist > > > > + > > > > > > If this is really required I would be willing to merge something like this: > > > > > > https://github.com/Vudentz/BlueZ/commit/9e196f8830511a4102e990d82d06c2e0487b3ad9 > > > > > > It exposes service objects so you can control exactly what gets > > > connect, though now given a second look at this seem to return details > > > that the client can query directly on the socket itself like the > > > Channel, PSM, Mode, etc, also not sure what is the point on retrieving > > > things like UUID, Name, Path if the application is already in control > > > of these when registering. > > > > > > > I only returned a full dictionary of items here as I was trying to > > match RegisterProfile, I don't actually need all of this info. (I > > also thought that the more verbose structure was more useful, but > > it is wasteful). > > > > The information that I really need is the PSM (or Channel) number. > > This information is needed on the server side, and the socket used > > is not exposed to anything outside of bluetoothd, as far as I can > > tell. (This is the socket returned from bt_io_listen, in profile.c). > > The file descriptor passed on NewConnection is the same socket the > daemon uses so you can query things like PSM, etc, using getsockopt > just like the daemon does, or do you need it before a connection is > made? In which case it might be preferable to write the PSM back to > the Property.Set method, that said perhaps it is better to have a PSM > set instead of leaving that to be auto allocated since you may not > want to change if you need to expose over GATT. The problem is that NewConnection is too late. This only gets called after the remote side has connected. The reason that I don't think it can be a property, is that the PSM is technically a "per adapter" number, it's possible (I think) for BlueZ to auto-allocate a different PSM for each adapter. If I do choose a fixed PSM, are there chances of a collision? Would such a collision matter? I have "complete" control over all software on the server, but the client devices are not mine. What is the best advice about picking a fixed PSM? > > > I have my profile auto-select a free PSM, which I thought was the > > preferred method. In the BR/EDR case, this number gets passed to the > > peer (I assume through SDP), but in the LE case, where I want to use > > LE-L2CAP, there is no defined mechanism to transfer the PSM. My plan > > was to expose it as a GATT attribute, but this mechanism is not > > standardised, so I didn't think BlueZ would want to be involved? > > BlueZ don't need to get involved directly but you can have vendor > specific GATT service that expose the PSM so the remote side can learn > about it and connect. > > > Would a simpler interface that just returned the PSM or Channel number > > be better? Is there another way to find out the PSM of a listening > > socket, on the server, before a connection is made? > > For auto allocation I would make actually make the properties > writable, though it seems we don't have any properties on Profile1 so > we would need to create then in order to reflect the options that can > be passed over on RegisterProfile. > > > (From my reading of the above patch, the service object is created > > as a link between a "profile" and a "device". In my case, I think > > there is no service object yet, as I have no device connection?) > > > > > > > > > Profile hierarchy > > > > ================= > > > > diff --git a/src/profile.c b/src/profile.c > > > > index 10850f305..e287a66d7 100644 > > > > --- a/src/profile.c > > > > +++ b/src/profile.c > > > > @@ -2509,6 +2509,96 @@ static DBusMessage *unregister_profile(DBusConnection *conn, > > > > return dbus_message_new_method_return(msg); > > > > } > > > > > > > > +static DBusMessage *get_profile_info(DBusConnection *conn, > > > > + DBusMessage *msg, void *user_data) > > > > +{ > > > > + DBusMessage *reply; > > > > + DBusMessageIter iter, dict; > > > > + const char *path, *adapter, *sender; > > > > + struct ext_profile *ext; > > > > + uint16_t u16; > > > > + GSList *l, *next; > > > > + > > > > + sender = dbus_message_get_sender(msg); > > > > + > > > > + DBG("sender %s", sender); > > > > + > > > > + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, > > > > + DBUS_TYPE_OBJECT_PATH, &adapter, > > > > + DBUS_TYPE_INVALID)) { > > > > + return btd_error_invalid_args(msg); > > > > + } > > > > + > > > > + if (adapter && !*adapter) > > > > + adapter = NULL; > > > > + > > > > + ext = find_ext_profile(sender, path); > > > > + if (!ext) > > > > + return btd_error_does_not_exist(msg); > > > > + > > > > + reply = dbus_message_new_method_return(msg); > > > > + > > > > + dbus_message_iter_init_append(reply, &iter); > > > > + > > > > + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, > > > > + "{sv}", &dict); > > > > + > > > > + g_dbus_dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, > > > > + &ext->uuid); > > > > + if (ext->name) { > > > > + g_dbus_dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, > > > > + &ext->name); > > > > + } > > > > + if (ext->path) { > > > > + g_dbus_dict_append_entry(&dict, "Path", DBUS_TYPE_STRING, > > > > + &ext->path); > > > > + } > > > > + if (ext->service) { > > > > + g_dbus_dict_append_entry(&dict, "Service", DBUS_TYPE_STRING, > > > > + &ext->service); > > > > + } > > > > + > > > > + u16 = ext->mode; > > > > + g_dbus_dict_append_entry(&dict, "Mode", DBUS_TYPE_UINT16, > > > > + &u16); > > > > + > > > > + u16 = ext->addr_type; > > > > + g_dbus_dict_append_entry(&dict, "AddressType", DBUS_TYPE_UINT16, > > > > + &u16); > > > > + > > > > + if (adapter) { > > > > + for (l = ext->servers; l != NULL; l = next) { > > > > + struct ext_io *server = l->data; > > > > + const char *ctype; > > > > + > > > > + DBG("server:%p %d %d psm:%d chan:%d", > > > > + server, server->resolving, server->connected, > > > > + server->psm, server->chan); > > > > + > > > > + next = g_slist_next(l); > > > > + > > > > + if (strcmp(adapter, adapter_get_path(server->adapter))) > > > > + continue; > > > > + > > > > + if (server->proto == BTPROTO_L2CAP) { > > > > + ctype = "PSM"; > > > > + u16 = server->psm; > > > > + } else if (server->proto == BTPROTO_RFCOMM) { > > > > + ctype = "Channel"; > > > > + u16 = server->chan; > > > > + } else { > > > > + continue; > > > > + } > > > > + g_dbus_dict_append_entry( > > > > + &dict, ctype, DBUS_TYPE_UINT16, &u16); > > > > + } > > > > + } > > > > + > > > > + dbus_message_iter_close_container(&iter, &dict); > > > > + > > > > + return reply; > > > > +} > > > > + > > > > static const GDBusMethodTable methods[] = { > > > > { GDBUS_METHOD("RegisterProfile", > > > > GDBUS_ARGS({ "profile", "o"}, { "UUID", "s" }, > > > > @@ -2516,6 +2606,9 @@ static const GDBusMethodTable methods[] = { > > > > NULL, register_profile) }, > > > > { GDBUS_METHOD("UnregisterProfile", GDBUS_ARGS({ "profile", "o" }), > > > > NULL, unregister_profile) }, > > > > + { GDBUS_METHOD("GetProfileInfo", > > > > + GDBUS_ARGS({ "profile", "o" }, { "adapter", "o" }), > > > > + GDBUS_ARGS({ "options", "a{sv}" }), get_profile_info) }, > > > > { } > > > > }; > > > > > > > > -- > > > > 2.17.1 > > > > > > > > > > > > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oFfVGfjWQ1+hrwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 17:04:24 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id +KQsGPjWQ197AQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 17:04:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5175E4210C; Mon, 24 Aug 2020 17:04:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725921AbgHXPEP (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 11:04:15 -0400 Received: from mga01.intel.com ([192.55.52.88]:50708 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgHXPEM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 11:04:12 -0400 IronPort-SDR: zh6zJ0Z5U2tHlQVa2TPoc7Cf4dH9FQ8LfNNX+1qvHR0GQGJNSfHLJPZKaRYaEqZ2kSzUdDX6N/ cO5ET6zrD/VA== X-IronPort-AV: E=McAfee;i="6000,8403,9722"; a="173956284" X-IronPort-AV: E=Sophos;i="5.76,349,1592895600"; d="scan'208";a="173956284" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 08:04:07 -0700 IronPort-SDR: moR5Yp5G/6o3VTmRDM3ez0UtugBjrHycSTu9lteaTIzN++GtXwgOO+ZJSyEDu0vkS9bAQ3EaMG 9wYti9OlmJ7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,349,1592895600"; d="scan'208";a="336199094" Received: from fmsmsx603-2.cps.intel.com (HELO fmsmsx603.amr.corp.intel.com) ([10.18.84.213]) by FMSMGA003.fm.intel.com with ESMTP; 24 Aug 2020 08:04:07 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 24 Aug 2020 08:04:06 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 24 Aug 2020 08:04:06 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.101) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 24 Aug 2020 08:04:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DPfYB/3QN0KjthoLxHPAJP4Ynl5K/QK+iEf+Y/THk/CTfaWwR/GrDr20G39Umqt4jvjog+32ZOrFibKUUkqYIb58KhbuZA991ReWmRho8RTb4ctQuDIZDXVS9I/r4noOu8xZ8q9yPOqveUJEVapWmBYWOBmeCDWN//MSvOe9WJvuz/8OhQ9LXjIS7GILbViyfP3hSlghhhY5mPN3h7gf7sxIwozSLRJtsRt5vub2Z336O1aKkjshT1x8lMkgAmsP3D0tGosXR/4yvCMd3F04inWss1zFsFMXxUpkFAiCzeT4/p6+pfADlOq+xF9ufroKBnFOQN/kLSZwn2jwQdrgLA== 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-SenderADCheck; bh=aEanj//a9v3pn8naZLf8Gqfmes1X3zWnQLYl8CndmWA=; b=MTvyoee7ot1B2EMAXCQ2+epoPb5oEFLKMqQiz+ao+1zl8TedtMoogRc0jY7nRidQpKN5PXO3+YbCSY+os7tq+TN5wIaAeyR/fnE2H9cBatbqL5e7OuMSTUOV5UfPpEt8yiLlsz/51KwgjXhI3BQyj3k2pIYZJ9XZR4lemwcEJsXvfxG5VKvxEyz6zhOQncoZqIGI63rjT1jKEupqXZoWH9r2dIpWqxI2a457Nm3fdmfLvFTkeCy3KXqvu4Klm8L0/ztAu4KHAu+yfl0Sk1zjVRSYYB1/cBAvyAmAlGiYX/rXbs6fSiW54YzCtMo7dDnHhYvtgFAemIEcBMoz9K1uCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aEanj//a9v3pn8naZLf8Gqfmes1X3zWnQLYl8CndmWA=; b=R99cbgnkThZcCDHrl8lKsnSUaFaXlWrWP/AEN4mNltSe1QtEXvLUIHQfIMuxFlpOorKpca6XESW0n0XLd8XO0wlgNmqKlETFa3EgEHLIkMl7Lj0W68FiipQoicZEZ5uMp7GFYOZLg+cXDnbsUn5sFywbTbd1Tk/H9IoL4MJxnco= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1438.namprd11.prod.outlook.com (2603:10b6:301:8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.25; Mon, 24 Aug 2020 15:04:05 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3305.026; Mon, 24 Aug 2020 15:04:05 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> CC: "michal.lowas-rzechonek@silvair.com" <michal.lowas-rzechonek@silvair.com> Subject: Re: [PATCH BlueZ 1/4] doc/mesh-api: Add "options" dictionary to Send/Publish Thread-Topic: [PATCH BlueZ 1/4] doc/mesh-api: Add "options" dictionary to Send/Publish Thread-Index: AQHWecpArCBCyLTwGkGlFXRwZUIh1qlHXAgA Date: Mon, 24 Aug 2020 15:04:05 +0000 Message-ID: <d4d15630945c28e040a68002d91cebed692b2832.camel@intel.com> References: <20200824035415.13420-1-inga.stotland@intel.com> <20200824035415.13420-2-inga.stotland@intel.com> In-Reply-To: <20200824035415.13420-2-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.54.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 631ddbed-6b95-44d8-c443-08d8483ef1cd x-ms-traffictypediagnostic: MWHPR11MB1438: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR11MB1438E9551B3A24E00DC13185E1560@MWHPR11MB1438.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: yZKdFrJFFFxgmH32fbilFldykqHaj2hRm1vZ7Hz0SYqxvEphxGOcXU2ufr6WaUPlOU6ZBEQpjuvZ5moLl1bPh++P0GKiSWwWgbYgDMJbIHUFxEXcHyQMR73T1xaoxGR0eiuccRcjLY09GGGTq25wNSMJ8b0uzeJm4nU8CnG4Z+Fn73z5xFX7AcC7CW+8mG5Df8kt/APrx5p5iBqVRwHT/zzt5AQEe8OpENMpO6/ErAYMjUoEX63drSjj9WEjCcqhf0Cfod5rIYtl1nfLEkQmL8RxbhqHr+z6PU9Fox3wuF+uSslb9zcxwTSWMhirqzdYalBQQ7sy2zaeiAZXfkHtyA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(136003)(366004)(39860400002)(376002)(2616005)(6506007)(71200400001)(83380400001)(6486002)(6636002)(8936002)(5660300002)(36756003)(86362001)(4326008)(6512007)(8676002)(110136005)(64756008)(91956017)(2906002)(66556008)(66946007)(316002)(26005)(66446008)(478600001)(76116006)(66476007)(186003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: HZTvbjB2A8U2Kz/A614ahNNF24nfhNtSrdFV/6+uv5Re9gN6/fUfsJVpJzL4gmiL+cyDeuwv9KGXpP9lIyOgMIRXsS4f5kdBEjklZW4s6N877ixHteGNwyopHHQhGCVgNZo7lfALOEGHYnExo0v1zdENC9cKjdu0lV43AEBcIiZnEgdkNgtBXqOSSlpoALqWjfFyXa2wpsLhRVSr/8Nvsw018TC2L4hX0+Nh5Zk/DoZ5rXq+qPuzWAeda4Cnz/fr3iNt/eC/i7HS9iShvd0XD5eD2rGOXxhPx1k/0sOmBbLIB3Mxm3V9ZbBK3xanvuYRh8VjACJ+eGEL6nm+6SxpyvsqEtu6YJlILlVBFUttiwMUfMEDSJi3i5p/LoEVkTjK/p1A8jJVm7dXCpHwNRKA3nxWzDK587+yHWncU4ZxSMRYEHBOc37xizJmirnv7hGkGFmOz1VpsgF6woeWYxp3VBG03+OS9e+mUsx2lqCIiQvzLBo2AW7j0nnftw7M06RpgHiOXeNksNf5UdNE13KnpVYOsWAZcE3hOCNGhmPVGPq+irCNL+bpAh8wszzMSrCUwLNFl98KiGVoW9mrxn0Hm4cwE9PTCypAW12wOK75gQP4gwwqJiXAHSDRrgMQQPc1wV3CypyygwFNiXbElGJjZQ== Content-Type: text/plain; charset="utf-8" Content-ID: <802282A8C02B454ABBDB5D514CEE81DE@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 631ddbed-6b95-44d8-c443-08d8483ef1cd X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Aug 2020 15:04:05.4244 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: hW+VZe6dJ/r4OStTW0hzrRPx4ar93QQCX3e6YpvfOVLQniq6NYAObVXRSA8Tk+fj8B42FotbTrVpNFzPF46ISA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1438 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.20 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5175E4210C X-Rspamd-UID: 898ece T24gU3VuLCAyMDIwLTA4LTIzIGF0IDIwOjU0IC0wNzAwLCBJbmdhIFN0b3RsYW5kIHdyb3RlOg0K PiBUaGlzIG1vZGlmaWVzIFNlbmQsIERldktleVNlbmQsIFB1Ymxpc2ggJiBWZW5kb3JQdWJsaXNo IG1ldGhvZHMNCj4gb24gbWVzaC5Ob2RlIGludGVyZmFjZSB0byBpbmNsdWRlIGFkZGl0aW9uYWwg YXJndW1lbnQgIm9wdGlvbnMiLg0KPiBUaGlzIG5ldyBhcmd1bWVudCBpcyBhIGRpY3Rpb25hcnkg dGhhdCBjdXJyZW50bHkgaGFzIG9ubHkgb25lDQo+IG5ldyBrZXkgd29yZCBkZWZpbmVkOg0KPiAg ICAgIkZvcmNlU2VnbWVudGVkIiAtIHRvIGZvcmNlIHNtYWxsIHBheWxvYWRzIHRvIGJlIHNlbnQg YXMNCj4gICAgIAkJICAgICAgb25lLXNlZ21lbnQgbWVzc2FnZXMNCj4gDQo+IE90aGVyIGtleSB3 b3JkcyBtYXkgYmUgZGVmaW5lZCBpbiBmdXR1cmUgdG8gYWNjb21tb2RhdGUgZXZvbHZpbmcNCj4g cmVxdWlyZW1lbnRzIG9mIE1lc2ggUHJvZmlsZSBzcGVjaWZpY2F0aW9uLg0KPiAtLS0NCj4gIGRv Yy9tZXNoLWFwaS50eHQgfCA0NyArKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrLS0tLQ0KPiAgMSBmaWxlIGNoYW5nZWQsIDQzIGluc2VydGlvbnMoKyksIDQgZGVsZXRp b25zKC0pDQo+IA0KPiBkaWZmIC0tZ2l0IGEvZG9jL21lc2gtYXBpLnR4dCBiL2RvYy9tZXNoLWFw aS50eHQNCj4gaW5kZXggNDk1Zjk1YjBiLi5mODM2MTQyYTcgMTAwNjQ0DQo+IC0tLSBhL2RvYy9t ZXNoLWFwaS50eHQNCj4gKysrIGIvZG9jL21lc2gtYXBpLnR4dA0KPiBAQCAtMjI5LDcgKzIyOSw3 IEBAIE9iamVjdCBwYXRoCS9vcmcvYmx1ZXovbWVzaC9ub2RlPHV1aWQ+DQo+ICANCj4gIA0KPiAt CXZvaWQgUHVibGlzaChvYmplY3QgZWxlbWVudF9wYXRoLCB1aW50MTYgbW9kZWwsIGFycmF5e2J5 dGV9IGRhdGEpDQo+ICsJdm9pZCBQdWJsaXNoKG9iamVjdCBlbGVtZW50X3BhdGgsIHVpbnQxNiBt b2RlbCwgZGljdCBvcHRpb25zLA0KPiArCQkJCQkJCWFycmF5e2J5dGV9IGRhdGEpDQo+ICANCj4g IAkJVGhpcyBtZXRob2QgaXMgdXNlZCB0byBzZW5kIGEgcHVibGljYXRpb24gb3JpZ2luYXRlZCBi eSBhIGxvY2FsDQo+ICAJCW1vZGVsLiBJZiB0aGUgbW9kZWwgZG9lcyBub3QgZXhpc3QsIG9yIGl0 IGhhcyBubyBwdWJsaWNhdGlvbg0KPiBAQCAtMzU4LDYgKzM3NSwxNyBAQCBNZXRob2RzOg0KPiAg CQlUaGUgbW9kZWwgcGFyYW1ldGVyIGNvbnRhaW5zIGEgbW9kZWwgSUQsIGFzIGRlZmluZWQgYnkg dGhlDQo+ICAJCUJsdWV0b290aCBTSUcuDQo+ICANCj4gKwkJVGhlIG9wdGlvbnMgcGFyYW1ldGVy IGlzIGEgZGljdGlvbmFyeSB3aXRoIHRoZSBmb2xsb3dpbmcga2V5cw0KPiArCQlkZWZpbmVkOg0K PiArDQo+ICsJCQlib29sIEZvcmNlU2VnbWVudGVkDQo+ICsJCQkJU3BlY2lmaWVzIHdoZXRoZXIg dG8gZm9yY2Ugc2VuZGluZyBvZiBhIHNob3J0DQo+ICsJCQkJbWVzc2FnZSBhcyBvbmUtc2VnbWVu dCBwYXlsb2FkLiBJZiBub3QgcHJlc2VudCwNCj4gKwkJCQl0aGUgZGVmYXVsdCBzZXR0aW5nIGlz ICJmYWxzZSIuDQo+ICsNCj4gKwkJVGhlIGRhdGEgcGFyYW1ldGVyIGlzIGFuIG91dGdvaW5nIG1l c3NhZ2UgdG8gYmUgZW5jeXB0ZWQgYnkgdGhlDQo+ICsJCW1lc2hkIGRhZW1vbiBhbmQgc2VudCBv bi4NCj4gKw0KPiAgCQlTaW5jZSBvbmx5IG9uZSBQdWJsaXNoIHJlY29yZCBtYXkgZXhpc3QgcGVy IGVsZW1lbnQtbW9kZWwsIHRoZQ0KPiAgCQlkZXN0aW5hdGlvbiBhbmQga2V5X2luZGV4IGFyZSBv YnRhaW5lZCBmcm9tIHRoZSBQdWJsaWNhdGlvbg0KPiAgCQlyZWNvcmQgY2FjaGVkIGJ5IHRoZSBk YWVtb24uDQo+IEBAIC0zNjcsNyArMzk1LDcgQEAgTWV0aG9kczoNCj4gIAkJCW9yZy5ibHVlei5t ZXNoLkVycm9yLkludmFsaWRBcmd1bWVudHMNCj4gIA0KPiAgCXZvaWQgVmVuZG9yUHVibGlzaChv YmplY3QgZWxlbWVudF9wYXRoLCB1aW50MTYgdmVuZG9yLCB1aW50MTYgbW9kZWxfaWQsDQo+IC0J CQkJCQkJYXJyYXl7Ynl0ZX0gZGF0YSkNCj4gKwkJCQkJCWRpY3Qgb3B0aW9ucywgYXJyYXl7Ynl0 ZX0gZGF0YSkNCg0KSSB3b25kZXIgaWYgd2Ugc2hvdWxkIHRha2UgdGhpcyBvcHBvcnR1bml0eSB0 byBlbGltaW5hdGUgdGhpcyBNZXRob2QgaW4gZmF2b3Igb2YgYWRkaW5nIGEgVmVuZG9yIGtleSB0 byB0aGUgbmV3DQpkaWN0aW9uYXJ5IGluIFB1Ymxpc2goKS4gIElmIHRoZSBrZXkgaXMgbWlzc2lu ZywgdGhlbiBmcm9tIHRoZSBkaWN0aW9uYXJ5IGluIFB1Ymxpc2goKSwgdGhlbiBpdCBpcyBhIFNp Zw0KZGVmaW5lZCBtb2RlbCwgYW5kIGlmIHByZXNlbnQsIHRoZW4gaXQgb3BlcmF0aW5nIGxpa2Ug dGhlIGN1cnJlbnQgUHVibGlzaFZlbmRvcigpLiAgVGhpcyB3b3VsZCBzaW1wbGlmeSB0aGUNCmNv ZGUgaW4gdGhlIGRhZW1vbiwgYW5kIG1ha2UgYSBzbWFsbGVyIGNvZGUgZm9vdHByaW50Lg0KDQo+ ICANCj4gIAkJVGhpcyBtZXRob2QgaXMgdXNlZCB0byBzZW5kIGEgcHVibGljYXRpb24gb3JpZ2lu YXRlZCBieSBhIGxvY2FsDQo+ICAJCXZlbmRvciBtb2RlbC4gSWYgdGhlIG1vZGVsIGRvZXMgbm90 IGV4aXN0LCBvciBpdCBoYXMgbm8NCj4gQEAgLTM4Myw2ICs0MTEsMTcgQEAgTWV0aG9kczoNCj4g IAkJVGhlIG1vZGVsX2lkIHBhcmFtZXRlciBpcyBhIDE2LWJpdCB2ZW5kb3ItYXNzaWduZWQgTW9k ZWwNCj4gIAkJSWRlbnRpZmllci4NCj4gIA0KPiArCQlUaGUgb3B0aW9ucyBwYXJhbWV0ZXIgaXMg YSBkaWN0aW9uYXJ5IHdpdGggdGhlIGZvbGxvd2luZyBrZXlzDQo+ICsJCWRlZmluZWQ6DQo+ICsN Cj4gKwkJCWJvb2wgRm9yY2VTZWdtZW50ZWQNCj4gKwkJCQlTcGVjaWZpZXMgd2hldGhlciB0byBm b3JjZSBzZW5kaW5nIG9mIGEgc2hvcnQNCj4gKwkJCQltZXNzYWdlIGFzIG9uZS1zZWdtZW50IHBh eWxvYWQuIElmIG5vdCBwcmVzZW50LA0KPiArCQkJCXRoZSBkZWZhdWx0IHNldHRpbmcgaXMgImZh bHNlIi4NCj4gKw0KPiArDQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WM98ELLgQ18nFAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 17:45:54 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id sK4PD7LgQ18xmwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 17:45:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6DAC8420DB; Mon, 24 Aug 2020 17:45:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727030AbgHXPpp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 11:45:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727992AbgHXPpB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 11:45:01 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94E95C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 08:45:01 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id p137so2002133oop.4 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 08:45:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=x0lKH1v1UT/weTPnocPDsO2ijkZqswvRGjCcgrrt8fM=; b=GzziYW7xfQM3wX2zjbXL8qQPPXUk1mZHgXAe19xyc3JcfsQCU6dWVwl82pOeMwB92k a/mcJHmCHN1hU63mG1lE4y5P2pkBrte0705xX1ds6li1foYu83FuRP4d6xbtpS1wi9UV NB4fz1pWxmaKKMTRHaLHcKckI05W7z0Lsf/XckkLr9Cc9BI1VDxQAth4t8WP1W2uZTOk EMwXXm4Ang4/dZwT8r2b9FhaHurIf4SqiBoCDH8695ArxNsA9M/+zx51z7oTUWZvWKAX /S40yFPF6BT+vynHMIXzJ0og4bukgbnFDTpQK6QNOAZWXHuyTzbysXB0iFpFDMzpe89z GXVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=x0lKH1v1UT/weTPnocPDsO2ijkZqswvRGjCcgrrt8fM=; b=nWpLtF8TXb17sJuaXnaa4iwdQ3mgsMWp3EVm83NfMBPBgc0FVORLiypOIqj6EG4bI8 Uvf5isSxK2Aj1M0KvVbLqUjYxmLy/BmTb9c8Onj5GY1c8UauVn7vpTvJn+OHUe0T921K tMPfcheTe0jy7qgv5OG9Xa/k9t4Sh5KIfIWaVqZk0VBo2YR6GQAKvQUscdP8+wejinfa GZ+V0/jnfddu7D6NHHoBmSlAiHBy78dEdZYgXBFShUgCsJYku98B0Mg8RQoQAEriLlNw 6+nDqZu8K1/sWdAHTa9KFyjE4WGsUMo8BZ7JFM9gGsNwY0du91BvMO4uzMQILqRmgRjL ltpQ== X-Gm-Message-State: AOAM533oaBIKCZTU/x6CmgCgHTgh/dEyA0dA+T99AAsmMqFb87Qrd3Kg FBS8vcYw+BF3QHBoeCFjrKkLZLZdZwv1lFdsdcE= X-Google-Smtp-Source: ABdhPJzE/7ahCW1nGlt+rtwSMBeCkDTSQS+V4WHRWBc6AT7bXJ4/gK/QjIwgkw+qE/QdvC+1z3I4mw5o3pxqtEYESHE= X-Received: by 2002:a4a:e88c:: with SMTP id g12mr4072053ooe.49.1598283900856; Mon, 24 Aug 2020 08:45:00 -0700 (PDT) MIME-Version: 1.0 References: <20200819150931.3005-1-mark.marshall@omicronenergy.com> <2303f692-bb7c-4851-86fa-befde45b4b32@EXC04-ATKLA.omicron.at> <CABBYNZ+OK4EY9KGHn7oasz4GRfBDJdWNcpOhr1GNGc3D+QtZ-g@mail.gmail.com> <3e98e7dae29ec7be6d67fca6af99f2e0f747375e.camel@omicronenergy.com> <CABBYNZ+U+Edyb42oKWgsqVKHCZZDzXR4HRRrK0Rb2vEL_A3aiA@mail.gmail.com> <6293792d2a4971529ff6f6e3327a2497ad7870c3.camel@omicronenergy.com> In-Reply-To: <6293792d2a4971529ff6f6e3327a2497ad7870c3.camel@omicronenergy.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 24 Aug 2020 08:44:50 -0700 Message-ID: <CABBYNZ+AduzcKtA1zshT+YpAXT_8fdymA6rgMFRfWvU=vpj-iw@mail.gmail.com> Subject: Re: [PATCH BlueZ 2/2] src/profile.c: Add a GetProfileInfo method To: Mark Marshall <mark.marshall@omicronenergy.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.38 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6DAC8420DB X-Rspamd-UID: a1c29c Hi Mark, On Mon, Aug 24, 2020 at 1:53 AM Mark Marshall <mark.marshall@omicronenergy.com> wrote: > > On Thu, 2020-08-20 at 09:33 -0700, Luiz Augusto von Dentz wrote: > > Hi Mark, > > > > On Thu, Aug 20, 2020 at 3:10 AM Mark Marshall > > <mark.marshall@omicronenergy.com> wrote: > > > > > > On Wed, 2020-08-19 at 11:37 -0700, Luiz Augusto von Dentz wrote: > > > > Hi Mark, > > > > > > > > On Wed, Aug 19, 2020 at 8:13 AM Mark Marshall > > > > <mark.marshall@omicronenergy.com> wrote: > > > > > > > > > > Add a GetProfileInfo method to org.bluez.ProfileManager1 > > > > > --- > > > > > doc/profile-api.txt | 13 +++++++ > > > > > src/profile.c | 93 +++++++++++++++++++++++++++++++++++++++++++++ > > > > > 2 files changed, 106 insertions(+) > > > > > > > > > > diff --git a/doc/profile-api.txt b/doc/profile-api.txt > > > > > index 8c7d0a06d..d13703ab4 100644 > > > > > --- a/doc/profile-api.txt > > > > > +++ b/doc/profile-api.txt > > > > > @@ -133,6 +133,19 @@ Object path /org/bluez > > > > > > > > > > Possible errors: org.bluez.Error.DoesNotExist > > > > > > > > > > + options GetProfileInfo(object profile, object adapter) > > > > > + > > > > > + This returns a dictionary of options for the > > > > > + profile. Values returned are: UUID, Name, > > > > > + Path, Service, Mode and AddressType. The > > > > > + adapter parameter is optional - if it is > > > > > + non-empty, then two additional values might be > > > > > + returned, if the profile is active on the > > > > > + specified adapter: PSM and Channel. > > > > > + > > > > > + Possible errors: org.bluez.Error.InvalidArguments > > > > > + org.bluez.Error.DoesNotExist > > > > > + > > > > > > > > If this is really required I would be willing to merge something like this: > > > > > > > > https://github.com/Vudentz/BlueZ/commit/9e196f8830511a4102e990d82d06c2e0487b3ad9 > > > > > > > > It exposes service objects so you can control exactly what gets > > > > connect, though now given a second look at this seem to return details > > > > that the client can query directly on the socket itself like the > > > > Channel, PSM, Mode, etc, also not sure what is the point on retrieving > > > > things like UUID, Name, Path if the application is already in control > > > > of these when registering. > > > > > > > > > > I only returned a full dictionary of items here as I was trying to > > > match RegisterProfile, I don't actually need all of this info. (I > > > also thought that the more verbose structure was more useful, but > > > it is wasteful). > > > > > > The information that I really need is the PSM (or Channel) number. > > > This information is needed on the server side, and the socket used > > > is not exposed to anything outside of bluetoothd, as far as I can > > > tell. (This is the socket returned from bt_io_listen, in profile.c). > > > > The file descriptor passed on NewConnection is the same socket the > > daemon uses so you can query things like PSM, etc, using getsockopt > > just like the daemon does, or do you need it before a connection is > > made? In which case it might be preferable to write the PSM back to > > the Property.Set method, that said perhaps it is better to have a PSM > > set instead of leaving that to be auto allocated since you may not > > want to change if you need to expose over GATT. > > The problem is that NewConnection is too late. This only gets called > after the remote side has connected. The reason that I don't think it > can be a property, is that the PSM is technically a "per adapter" > number, it's possible (I think) for BlueZ to auto-allocate a > different PSM for each adapter. Right, though I think we would allocate the same PSM and bind to BDADDR_ANY. > If I do choose a fixed PSM, are there chances of a collision? > Would such a collision matter? I have "complete" control over all > software on the server, but the client devices are not mine. > What is the best advice about picking a fixed PSM? If you have full control then assigning a fixed PSM is probably the best thing you can do here as you can guarantee no one else will be attempting to register a service for the same PSM. > > > > > I have my profile auto-select a free PSM, which I thought was the > > > preferred method. In the BR/EDR case, this number gets passed to the > > > peer (I assume through SDP), but in the LE case, where I want to use > > > LE-L2CAP, there is no defined mechanism to transfer the PSM. My plan > > > was to expose it as a GATT attribute, but this mechanism is not > > > standardised, so I didn't think BlueZ would want to be involved? > > > > BlueZ don't need to get involved directly but you can have vendor > > specific GATT service that expose the PSM so the remote side can learn > > about it and connect. > > > > > Would a simpler interface that just returned the PSM or Channel number > > > be better? Is there another way to find out the PSM of a listening > > > socket, on the server, before a connection is made? > > > > For auto allocation I would make actually make the properties > > writable, though it seems we don't have any properties on Profile1 so > > we would need to create then in order to reflect the options that can > > be passed over on RegisterProfile. > > > > > (From my reading of the above patch, the service object is created > > > as a link between a "profile" and a "device". In my case, I think > > > there is no service object yet, as I have no device connection?) > > > > > > > > > > > > > > Profile hierarchy > > > > > ================= > > > > > diff --git a/src/profile.c b/src/profile.c > > > > > index 10850f305..e287a66d7 100644 > > > > > --- a/src/profile.c > > > > > +++ b/src/profile.c > > > > > @@ -2509,6 +2509,96 @@ static DBusMessage *unregister_profile(DBusConnection *conn, > > > > > return dbus_message_new_method_return(msg); > > > > > } > > > > > > > > > > +static DBusMessage *get_profile_info(DBusConnection *conn, > > > > > + DBusMessage *msg, void *user_data) > > > > > +{ > > > > > + DBusMessage *reply; > > > > > + DBusMessageIter iter, dict; > > > > > + const char *path, *adapter, *sender; > > > > > + struct ext_profile *ext; > > > > > + uint16_t u16; > > > > > + GSList *l, *next; > > > > > + > > > > > + sender = dbus_message_get_sender(msg); > > > > > + > > > > > + DBG("sender %s", sender); > > > > > + > > > > > + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, > > > > > + DBUS_TYPE_OBJECT_PATH, &adapter, > > > > > + DBUS_TYPE_INVALID)) { > > > > > + return btd_error_invalid_args(msg); > > > > > + } > > > > > + > > > > > + if (adapter && !*adapter) > > > > > + adapter = NULL; > > > > > + > > > > > + ext = find_ext_profile(sender, path); > > > > > + if (!ext) > > > > > + return btd_error_does_not_exist(msg); > > > > > + > > > > > + reply = dbus_message_new_method_return(msg); > > > > > + > > > > > + dbus_message_iter_init_append(reply, &iter); > > > > > + > > > > > + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, > > > > > + "{sv}", &dict); > > > > > + > > > > > + g_dbus_dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, > > > > > + &ext->uuid); > > > > > + if (ext->name) { > > > > > + g_dbus_dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, > > > > > + &ext->name); > > > > > + } > > > > > + if (ext->path) { > > > > > + g_dbus_dict_append_entry(&dict, "Path", DBUS_TYPE_STRING, > > > > > + &ext->path); > > > > > + } > > > > > + if (ext->service) { > > > > > + g_dbus_dict_append_entry(&dict, "Service", DBUS_TYPE_STRING, > > > > > + &ext->service); > > > > > + } > > > > > + > > > > > + u16 = ext->mode; > > > > > + g_dbus_dict_append_entry(&dict, "Mode", DBUS_TYPE_UINT16, > > > > > + &u16); > > > > > + > > > > > + u16 = ext->addr_type; > > > > > + g_dbus_dict_append_entry(&dict, "AddressType", DBUS_TYPE_UINT16, > > > > > + &u16); > > > > > + > > > > > + if (adapter) { > > > > > + for (l = ext->servers; l != NULL; l = next) { > > > > > + struct ext_io *server = l->data; > > > > > + const char *ctype; > > > > > + > > > > > + DBG("server:%p %d %d psm:%d chan:%d", > > > > > + server, server->resolving, server->connected, > > > > > + server->psm, server->chan); > > > > > + > > > > > + next = g_slist_next(l); > > > > > + > > > > > + if (strcmp(adapter, adapter_get_path(server->adapter))) > > > > > + continue; > > > > > + > > > > > + if (server->proto == BTPROTO_L2CAP) { > > > > > + ctype = "PSM"; > > > > > + u16 = server->psm; > > > > > + } else if (server->proto == BTPROTO_RFCOMM) { > > > > > + ctype = "Channel"; > > > > > + u16 = server->chan; > > > > > + } else { > > > > > + continue; > > > > > + } > > > > > + g_dbus_dict_append_entry( > > > > > + &dict, ctype, DBUS_TYPE_UINT16, &u16); > > > > > + } > > > > > + } > > > > > + > > > > > + dbus_message_iter_close_container(&iter, &dict); > > > > > + > > > > > + return reply; > > > > > +} > > > > > + > > > > > static const GDBusMethodTable methods[] = { > > > > > { GDBUS_METHOD("RegisterProfile", > > > > > GDBUS_ARGS({ "profile", "o"}, { "UUID", "s" }, > > > > > @@ -2516,6 +2606,9 @@ static const GDBusMethodTable methods[] = { > > > > > NULL, register_profile) }, > > > > > { GDBUS_METHOD("UnregisterProfile", GDBUS_ARGS({ "profile", "o" }), > > > > > NULL, unregister_profile) }, > > > > > + { GDBUS_METHOD("GetProfileInfo", > > > > > + GDBUS_ARGS({ "profile", "o" }, { "adapter", "o" }), > > > > > + GDBUS_ARGS({ "options", "a{sv}" }), get_profile_info) }, > > > > > { } > > > > > }; > > > > > > > > > > -- > > > > > 2.17.1 > > > > > > > > > > > > > > > > > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QGA5DacERF/shgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 20:19:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EG+sC6cERF+BBQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 20:19:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 31FE1421A1; Mon, 24 Aug 2020 20:19:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726843AbgHXSTN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 14:19:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726578AbgHXSTM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 14:19:12 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E43C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 11:19:12 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id r15so855654pjo.9 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 11:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=IlbZ03OMg7rq/jJuN15OSJJEi++pYgR8JozgzBiRFaU=; b=WrSdcuNXbZ28VXfCpLiMtMHdX+jyEmVFfmq96+1Ts7ofy+OzgjloC6vveIlQmdAWi2 7h+aNSIJaBo0r0055dlyjAC34OFMzsVbsgT9QP6o0jczvce8ej40Vwmht3MTuYMXYgBN /YWj/UbVm4vyd6XK88VWnNnAyIKj7nOA+rFBSAXqsma0t0odt2nW+rX7yseAMW13DD4E J+nb1qj6g+XCUSFNduUkhjUuQ59S50rgto6BcHek80ohpU+r62Dj2g1zq6UYlWeXg53w zkUk7jqrePj0sVsu+vpxgN1pQCVT58pUyR3XmWExj2Pwm7ElXiyvrjp1xgOUCXGCOdvB A+zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=IlbZ03OMg7rq/jJuN15OSJJEi++pYgR8JozgzBiRFaU=; b=TR5skZ+25G8JGEci/2mCdmrYoQdXV42sVk6JKsTNAKa8C0wZqN0Der1Ozb/2hrt2UQ tN6yDG0aUcnW5NFtn8ywbSZzkpTzJ8G6KRHzyFxsbzv80RSijgNQbEo12QkCLhOKXjjC LnDmUYOiVZmgjvRjD8Pe2JNUtmihbWqdhvY9ZSbFzgJXu941muwrxfLUqNXVxT1AlzuB 9zr8uG53D3QZoweA6gRc9ONCpO0KgmrBBUUvV80Z2iVt4Yqh9K+kSyc9k8wClCR2kjAP 8xDgIlleK83PmgjVtv5sEyX9PFjiej4iSUkoTw3rXEuY95RJD6jIxFXgQisHAMyviqP+ Ul1Q== X-Gm-Message-State: AOAM531D5CLcU4tyBYEA044CaJzh4hlZVSwFo0avn8TIBUlnfOJggjhD NBFL2bgCoXb9mftPXqfQwt7RAYX375mfXuJUFpMA208JTU6y0S8HnSjj+c8dNcafA+0hBLwWhQG PK9P2hhYvNhCEnWuuMn4ECeixB4cdNDDvp8OnTu9vT1RWErKwfdM7nP4JWWDS0syfWHVoy6qJav qV X-Google-Smtp-Source: ABdhPJwzt7jP/y1XCQwJyKIlmLCio3StIzWMStUYBSuLKi5/ZiD0XyKXlVZRUL9EVUtYEFeMGjgL+cRdESGd X-Received: from yudiliu.mtv.corp.google.com ([2620:15c:202:201:8edc:d4ff:fe53:2823]) (user=yudiliu job=sendgmr) by 2002:a63:7f50:: with SMTP id p16mr4128137pgn.451.1598293150619; Mon, 24 Aug 2020 11:19:10 -0700 (PDT) Date: Mon, 24 Aug 2020 11:19:03 -0700 Message-Id: <20200824111837.Bluez.v3.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [Bluez PATCH v3] adapter - Device needs to be in the temporary state after pairing failure From: Yu Liu <yudiliu@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Yu Liu <yudiliu@google.com>, sonnysasaka@chromium.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.48 / 15.00 / 200.00 X-Rspamd-Queue-Id: 31FE1421A1 X-Rspamd-UID: 27dafa This caused the device hanging around as a discovered device forever even if it is turned off or not in present. Reviewed-by: sonnysasaka@chromium.org --- Changes in v3: - Fix comment format - Don't set temporary for trusted device Changes in v2: - Fix title length and format issue Changes in v1: - Initial change src/device.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/device.c b/src/device.c index bb8e07e8f..103b5df27 100644 --- a/src/device.c +++ b/src/device.c @@ -6008,6 +6008,14 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, if (status) { device_cancel_authentication(device, TRUE); + + /* Put the device back to the temporary state so that it will be + * treated as a newly discovered device. + */ + if (!device_is_paired(device, bdaddr_type) && + !device_is_trusted(device)) + btd_device_set_temporary(device, true); + device_bonding_failed(device, status); return; } -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iBu9A9UGRF/rhgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 20:28:37 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id EH+SAdUGRF8PXwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 20:28:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1FC8EA2429; Mon, 24 Aug 2020 20:28:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgHXS23 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 14:28:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbgHXS2U (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 14:28:20 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83285C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 11:28:19 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id p36so3566000qtd.12 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 11:28:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=ainMyn8m3YK8zwPvZsPC0ZPkL95Kkd6EhZksjdEt2Ek=; b=ZECzesz7NKdiGN4Xr7cs8Gk/t8WFnwwjfBnYFMY1MkMN/+YBQGgxkxky0CQxJfXgQl N99PrBudeB9mHjeNohAIhltV/n66PKrm5vO1Q7x/DDs5iLdlRyMF+ZCktvT4bA/52eWI IQMp3ND3gPGPRpjTkJD2inbyjbwmnAHHRTbyISVI8EyZQg4zU0XhodBq1Ab6BCWKFkXr XuPVV51qTV2+U094bAumhFB/kJURgeLal6BoAFhFdSz0YHnE/ppBSGwCza8eR7X0AWsv DhTo/Ipx+/ZAq0DT0z9plWhwKQG4PfhcUn07eQlE3ZYq9xLxDrCJmHuXL1RXmNQUyQGc hd3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=ainMyn8m3YK8zwPvZsPC0ZPkL95Kkd6EhZksjdEt2Ek=; b=Dc/qSn6bZp6Qk8qWLa7DgBhzeU+X5IvXoJFFD3GA3QfZ7MkeMkI5GcL2ISvFsU1o+4 ObLAm+B2wSbcdQAciWYbpCRZdI1JEkIxq9pegOUFhw0p5wZoEFPxajuEX2ssEcn951ry GwOTMR0NcY9w7bZPs6LREMBFOVLLgRcyEol3iSdvCXbwN7HxmHutFHpy+gm2OHz5rFOa J2J5a+IZ23Qsa+3zSkJFOswXxcfSq76PNAoeit3jmv9Ngrt8pjIAIIJUpfABiZKBu4lx 9sKMmkifOXxShXYZyp0ItbNt7erwXA1Y6VsCnpvsKhhfeKQeuNlWklQ45N7Av3BlyQhN orMw== X-Gm-Message-State: AOAM530jv5NCFjujFBQBDy6Vz0sVjlzmRgxkptWHWDsxZRp7aD+aKHJ1 1Q++dE3CI+28ubMmETPpgKW4KGzY4OLItA== X-Google-Smtp-Source: ABdhPJx1HLwI517iqo4BDdj6J6ff8bl9gQZIuJcG95ponWOBlYESBpGFIa/sFZO5ohlnp/wFG3byMw== X-Received: by 2002:ac8:4d5c:: with SMTP id x28mr6307605qtv.35.1598293698662; Mon, 24 Aug 2020 11:28:18 -0700 (PDT) Received: from [172.17.0.2] ([104.46.193.199]) by smtp.gmail.com with ESMTPSA id q126sm9453421qkb.75.2020.08.24.11.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2020 11:28:17 -0700 (PDT) Message-ID: <5f4406c1.1c69fb81.f8450.9888@mx.google.com> Date: Mon, 24 Aug 2020 11:28:17 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============8288428430018806918==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, yudiliu@google.com Subject: RE: [Bluez,v3] adapter - Device needs to be in the temporary state after pairing failure Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200824111837.Bluez.v3.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> References: <20200824111837.Bluez.v3.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.09 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1FC8EA2429 X-Rspamd-UID: 04e774 --===============8288428430018806918== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 1: T1 Title exceeds max length (73>72): "adapter - Device needs to be in the temporary state after pairing failure" --- Regards, Linux Bluetooth --===============8288428430018806918==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yDuhGf4FRF/3VQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 20:25:02 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id cP0mFv4FRF+fKwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 20:25:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6FC014218B; Mon, 24 Aug 2020 20:24:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726630AbgHXSY5 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 14:24:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbgHXSYz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 14:24:55 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70FB3C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 11:24:54 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id d26so3051618ejr.1 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 11:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F1XFwEzoiD+SioB0C34JWH1YNNT6L1PvGIichsFvB7Q=; b=GISbxeCQ8sn95jeTrha8+Hwmr5DQAquFgSUijv7NmkaRKVQkWlvsSdEq4coGS386bI qk9umOqcH2bFwmBeiqb1UkqFwrQ5AcmfUp0ASytqy1XpH7nNrHVIrNielTLTO2g/O7M0 aKMkE+KKDHe2upF2G0YFSSXnuiO6Y1HkKH0QVzYPNv8jvwmI6Nl8aXWylDnAl02ptuIA 5SPUBL9r4vKXQfA2g3AjTKbaatwgSYvvDgZYtk1btTyBzrtzdvIMCh3QEu4EqVSC+EVI A5wVJ4P32P943aU3HvbUuZ0Rpc26le8wEntyKWC3h/iZQGgynfYDGIFQhL/rZW25wuSG amKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F1XFwEzoiD+SioB0C34JWH1YNNT6L1PvGIichsFvB7Q=; b=YnSLEVcq2bePKH2vm/izF317nKlAiTNBJ1TlTzexb7Fxxbh8t0Mv8dZxHun0xGSTlP jFL6m0BJzQ3z2FIPYwQOCybpYtOfabuHjh+pdkgnc3i5/QL5M4s6lKBvOs8P+CBkHxko bsM13VNvCIOc8HB87YPVEymP8ZdfN/uyyoTc4AMINKZoVO7AhEJGKY9pz4KZB251Jtwu JJnInAuJtmYxgOp+K0bDsDjmnSQ6+IjbJXdpeiNwIXXWRzINGS7GpuQY96miyiv8nID8 /Iza0bO5DElTdrqS4WVeGEGOH3IPRPt/xCzhY7RuliORPLodtLK7SEmDJDwHEecIms8i oQgQ== X-Gm-Message-State: AOAM530sV/8Sx4gmBCzAGKvcZg8aMXodMx51insXYMwKYGi8UOt9aMBZ ce1yj0EGgdnU+mIBg5kO7Zzy+e9fiHcTbp0/P12XMA== X-Google-Smtp-Source: ABdhPJzfMAPoXZAqTfAxZpVn1xvBPwMIoan2ZR2WZu61EswhaSnBGwlheRPpNvH+Cnq+TIQg9mgI/zoVmPA0vuMyQPg= X-Received: by 2002:a17:906:560d:: with SMTP id f13mr6613583ejq.102.1598293492732; Mon, 24 Aug 2020 11:24:52 -0700 (PDT) MIME-Version: 1.0 References: <20200817135606.Bluez.v2.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> <CABBYNZLfmuLHvvMUwz_-Lg=q5aFYt6S3UEV-SA--ESmRMX4DVQ@mail.gmail.com> In-Reply-To: <CABBYNZLfmuLHvvMUwz_-Lg=q5aFYt6S3UEV-SA--ESmRMX4DVQ@mail.gmail.com> From: Yu Liu <yudiliu@google.com> Date: Mon, 24 Aug 2020 11:24:16 -0700 Message-ID: <CAHC-yby56jfNS7Lys0sDMpjV00z7tjWcXnJ46J=W=Ax+yY8OmA@mail.gmail.com> Subject: Re: [Bluez PATCH v2] adapter- Device needs to be in the temporary state after pairing failure To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.44 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6FC014218B X-Rspamd-UID: ae3d62 Hi Luiz, I just sent another patch to address your comments. The issue this cl is trying to address is that when we pair a device by calling pair_device, it removes the temporary flag very early on, then it the pairing failed due to reasons such as failed to connect the temp flag won't be removed and the device will be hanging around forever. Please review again. Thanks. On Mon, Aug 17, 2020 at 4:24 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Yu Liu, > > On Mon, Aug 17, 2020 at 4:04 PM Yu Liu <yudiliu@google.com> wrote: > > > > This caused the device hanging around as a discovered device forever > > even if it is turned off or not in present. > > > > Reviewed-by: sonnysasaka@chromium.org > > > > Signed-off-by: Yu Liu <yudiliu@google.com> > > --- > > > > Changes in v2: > > - Fix title length and format issue > > > > Changes in v1: > > - Initial change > > > > src/device.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/src/device.c b/src/device.c > > index bb8e07e8f..93e71850c 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -6008,6 +6008,12 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, > > > > if (status) { > > device_cancel_authentication(device, TRUE); > > + > > + // Put the device back to the temporary state so that it will be > > + // treated as a newly discovered device. > > Use C style comments /* */ above. > > > + if (!device_is_paired(device, bdaddr_type)) > > + btd_device_set_temporary(device, true); > > Hmm, are we perhaps removing the temporary flag too early? Or this is > a result of calling Connect which clears the temporary flag? Then > perhaps we should at least if the upper layer has marked the device as > trusted as it should indicate the device object should be kept even if > not paired. > > > device_bonding_failed(device, status); > > return; > > } > > -- > > 2.28.0.220.ged08abb693-goog > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CP4HAZUKRF8/WwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 20:44:37 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id uBh7O5QKRF9G9gAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 20:44:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 20125A19E0; Mon, 24 Aug 2020 20:44:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726306AbgHXSob (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 14:44:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725963AbgHXSoa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 14:44:30 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C6CDC061573 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 11:44:30 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id l13so11628175ybf.5 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 11:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=AI14pQdq0aOMmQdlYGuL+wyNmjvIoSpo1r6eDtgq0BY=; b=BrAKc9wgQPIsqtq9ABfffhz3A+WZVNCl822n3zT7onw9ng6GvqGqQtsQg1J7RAXUHr 8CL6ulmrGuBinD7KJMLkEZdd7STjWEqGZlXaicQVlxYIJ+wBgKsDSujTpAjgnQBbeS1A Je3jroYIkdKczCa6H+71gbOe4pxGh5WXw+v0eVxU8MctTBCjVnl6lInt6SHKWsjHwMT7 AZFDHahRZihqcr4Pbbvb3MqvM7Chn8jQdAzZQXfiNuUHCk0Z1FST5vQuB3HZeRPFcwwM BrKGhaqCPjC+ntGwkez6Xqqd8kndBhBobq7yI8090GJK0AebDB4loZJUxPH823FII7ea qBmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=AI14pQdq0aOMmQdlYGuL+wyNmjvIoSpo1r6eDtgq0BY=; b=tbhWbmw5Q2sxEdLP/F/1kvizjH6BqvGUnFO+o79+s0F1oGddh8xVp9CXYxpEyWKxjC tZ56NUc/JWpewVqZnCIlQ4zpTjZNtzOgRsMX7xu1I7pzknQ//ocgVadY8iIlpJxoAZ2e z//XC7Th34bZArF/IeqJHIY88zGxk9gwpgUde9DF3/o2mm051Nu9Kmz6ZOZO7uWP2VZE dBKiBrdJSh9hFS+Dv+cTbOmPryc2YrufbDGI8/h/A3Vb+1LDitx5AElLfdIFCk/HhSbe FjWtzerw23rRUvWu28DlHy/8bQ5Xi4DnjyHkgo88t4xtXOhrpAGHAgVvpTxlz10DpnPK cdXg== X-Gm-Message-State: AOAM532V1jkmvFdkdKBW2tQOLkpbJVpop1xlp79GqiqDuItiu10KbbZO XWMgg+Ot9vHi/z7zKX+T5WU14wPv0Dn1ZGSYTmRE2uzkQInvLehnltEtNGVr9nmOn+kOQTiDebl pyPuEC4dQE8/V4gEk7HTmjLf/3KnL7sI/1XtyjwW/gSUhJqcuXK2FSVIl8g//jwoMdFP8sqdtT2 Il X-Google-Smtp-Source: ABdhPJy7KphBM67MMKRo7GK7QhJ2irSNrnrlKewxS6tgzActn9+nf2BgfvMRF4T3gZKIG59yBWbaImiDzW0g X-Received: from yudiliu.mtv.corp.google.com ([2620:15c:202:201:8edc:d4ff:fe53:2823]) (user=yudiliu job=sendgmr) by 2002:a25:bc52:: with SMTP id d18mr9531309ybk.144.1598294669778; Mon, 24 Aug 2020 11:44:29 -0700 (PDT) Date: Mon, 24 Aug 2020 11:44:26 -0700 Message-Id: <20200824114408.Bluez.v3.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [Bluez PATCH v3] adapter - Device needs to be in the temporary state after pairing failed From: Yu Liu <yudiliu@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Yu Liu <yudiliu@google.com>, sonnysasaka@chromium.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.47 / 15.00 / 200.00 X-Rspamd-Queue-Id: 20125A19E0 X-Rspamd-UID: 3ca124 This caused the device hanging around as a discovered device forever even if it is turned off or not in present. Reviewed-by: sonnysasaka@chromium.org --- Changes in v3: - Fix comment format - Don't set temporary for trusted device Changes in v2: - Fix title length and format issue Changes in v1: - Initial change src/device.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/device.c b/src/device.c index bb8e07e8f..103b5df27 100644 --- a/src/device.c +++ b/src/device.c @@ -6008,6 +6008,14 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, if (status) { device_cancel_authentication(device, TRUE); + + /* Put the device back to the temporary state so that it will be + * treated as a newly discovered device. + */ + if (!device_is_paired(device, bdaddr_type) && + !device_is_trusted(device)) + btd_device_set_temporary(device, true); + device_bonding_failed(device, status); return; } -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MEGRDJgeRF9qnAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 24 Aug 2020 22:10:00 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id iHQWC5geRF/4eQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 24 Aug 2020 22:10:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D34014212E; Mon, 24 Aug 2020 22:09:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726519AbgHXUJy (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 16:09:54 -0400 Received: from mga17.intel.com ([192.55.52.151]:59571 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbgHXUJy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 16:09:54 -0400 IronPort-SDR: JBZtKgQJK8KRoRxqoiAfbhNMiRwUy2SRlrRHa7MI3g3V6VJkXZwJpSSADhWw3my+AqpZWy6NPR Ne+fgG21KHPw== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="136046020" X-IronPort-AV: E=Sophos;i="5.76,349,1592895600"; d="scan'208";a="136046020" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 13:09:53 -0700 IronPort-SDR: wbty+Va7ePbZTVMjxryGzdw4jeuSNoxdjxo3m5o9C1TZSzSx5HW5dqcV6R5MTj64NbPmecHp3p zg9FsVsNAfzg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,349,1592895600"; d="scan'208";a="294727631" Received: from apaharia-mobl.gar.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.231.108]) by orsmga003.jf.intel.com with ESMTP; 24 Aug 2020 13:09:53 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] mesh: Store key indices as integers in node config Date: Mon, 24 Aug 2020 13:09:52 -0700 Message-Id: <20200824200952.20818-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: D34014212E X-Rspamd-UID: c97e8d Store NetKey and AppKey indices as integers instead of hex strings. This removes unnecessary sting manipulationswhile not affecting configuration file readability. --- mesh/mesh-config-json.c | 102 +++++++++++++++------------------------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 63b6c3988..30c90170d 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -249,21 +249,31 @@ static void jarray_string_del(json_object *jarray, char *str, size_t len) } } +static bool get_key_index(json_object *jobj, const char *keyword, + uint16_t *index) +{ + int idx; + + if (!get_int(jobj, keyword, &idx)) + return false; + + if (!CHECK_KEY_IDX_RANGE(idx)) + return false; + + *index = (uint16_t) idx; + return true; +} + static json_object *get_key_object(json_object *jarray, uint16_t idx) { int i, sz = json_object_array_length(jarray); for (i = 0; i < sz; ++i) { - json_object *jentry, *jvalue; - const char *str; + json_object *jentry; uint16_t jidx; jentry = json_object_array_get_idx(jarray, i); - if (!json_object_object_get_ex(jentry, "index", &jvalue)) - return NULL; - - str = json_object_get_string(jvalue); - if (sscanf(str, "%04hx", &jidx) != 1) + if (!get_key_index(jentry, "index", &jidx)) return NULL; if (jidx == idx) @@ -273,28 +283,6 @@ static json_object *get_key_object(json_object *jarray, uint16_t idx) return NULL; } -static bool get_key_index(json_object *jobj, const char *keyword, - uint16_t *index) -{ - uint16_t idx; - json_object *jvalue; - const char *str; - - if (!json_object_object_get_ex(jobj, keyword, &jvalue)) - return false; - - str = json_object_get_string(jvalue); - - if (sscanf(str, "%04hx", &idx) != 1) - return false; - - if (!CHECK_KEY_IDX_RANGE(idx)) - return false; - - *index = (uint16_t) idx; - return true; -} - static void jarray_key_del(json_object *jarray, int16_t idx) { int i, sz = json_object_array_length(jarray); @@ -594,11 +582,23 @@ fail: return false; } +static bool write_int(json_object *jobj, const char *desc, int val) +{ + json_object *jvalue; + + jvalue = json_object_new_int(val); + if (!jvalue) + return false; + + json_object_object_del(jobj, desc); + json_object_object_add(jobj, desc, jvalue); + return true; +} + bool mesh_config_net_key_add(struct mesh_config *cfg, uint16_t idx, const uint8_t key[16]) { - json_object *jnode, *jarray = NULL, *jentry = NULL, *jstring; - char buf[5]; + json_object *jnode, *jarray = NULL, *jentry = NULL; if (!cfg) return false; @@ -618,13 +618,9 @@ bool mesh_config_net_key_add(struct mesh_config *cfg, uint16_t idx, if (!jentry) return false; - snprintf(buf, 5, "%4.4x", idx); - jstring = json_object_new_string(buf); - if (!jstring) + if (!write_int(jentry, "index", idx)) goto fail; - json_object_object_add(jentry, "index", jstring); - if (!add_key_value(jentry, "key", key)) goto fail; @@ -724,8 +720,7 @@ bool mesh_config_write_token(struct mesh_config *cfg, uint8_t *token) bool mesh_config_app_key_add(struct mesh_config *cfg, uint16_t net_idx, uint16_t app_idx, const uint8_t key[16]) { - json_object *jnode, *jarray = NULL, *jentry = NULL, *jstring = NULL; - char buf[5]; + json_object *jnode, *jarray = NULL, *jentry = NULL; if (!cfg) return false; @@ -744,20 +739,12 @@ bool mesh_config_app_key_add(struct mesh_config *cfg, uint16_t net_idx, if (!jentry) return false; - snprintf(buf, 5, "%4.4x", app_idx); - jstring = json_object_new_string(buf); - if (!jstring) + if (!write_int(jentry, "index", app_idx)) goto fail; - json_object_object_add(jentry, "index", jstring); - - snprintf(buf, 5, "%4.4x", net_idx); - jstring = json_object_new_string(buf); - if (!jstring) + if (!write_int(jentry, "boundNetKey", net_idx)) goto fail; - json_object_object_add(jentry, "boundNetKey", jstring); - if (!add_key_value(jentry, "key", key)) goto fail; @@ -995,6 +982,7 @@ static struct mesh_config_pub *parse_model_publication(json_object *jpub) case 32: if (!str2hex(str, len, pub->virt_addr, 16)) goto fail; + pub->virt = true; break; default: @@ -1468,19 +1456,6 @@ static bool write_uint32_hex(json_object *jobj, const char *desc, uint32_t val) return true; } -static bool write_int(json_object *jobj, const char *desc, int val) -{ - json_object *jvalue; - - jvalue = json_object_new_int(val); - if (!jvalue) - return false; - - json_object_object_del(jobj, desc); - json_object_object_add(jobj, desc, jvalue); - return true; -} - static const char *mode_to_string(int mode) { switch (mode) { @@ -1872,7 +1847,7 @@ bool mesh_config_model_pub_add(struct mesh_config *cfg, uint16_t ele_addr, if (!res) goto fail; - if (!write_uint16_hex(jpub, "index", pub->idx)) + if (!write_int(jpub, "index", pub->idx)) goto fail; if (!write_int(jpub, "ttl", pub->ttl)) @@ -1881,8 +1856,7 @@ bool mesh_config_model_pub_add(struct mesh_config *cfg, uint16_t ele_addr, if (!write_int(jpub, "period", pub->period)) goto fail; - if (!write_int(jpub, "credentials", - pub->credential ? 1 : 0)) + if (!write_int(jpub, "credentials", pub->credential ? 1 : 0)) goto fail; jrtx = json_object_new_object(); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qCwcI1xhRF9/EQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 25 Aug 2020 02:54:52 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CHeWIVxhRF9/rwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 25 Aug 2020 02:54:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5102042166; Tue, 25 Aug 2020 02:54:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728371AbgHYAym (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 20:54:42 -0400 Received: from mga02.intel.com ([134.134.136.20]:44191 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728352AbgHYAyk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 20:54:40 -0400 IronPort-SDR: kdCLiXOH0NePraQIvD2KGxE8WS3IkNSrUV8Htw0FKCM6pti+JmYYuwOQ9QE35zai2Eyw72K9UV SFAzqX7Jxavw== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="143797442" X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="143797442" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 17:54:40 -0700 IronPort-SDR: E4rEponhjLdmNFMt3a6mFfNhCoVcA+rTj0dGUtHrv/TQnK8QV5ujoGsnSTVEtgXBmuDJsr1fn3 VjdgS4qhYBRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="474141834" Received: from apaharia-mobl.gar.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.231.108]) by orsmga005.jf.intel.com with ESMTP; 24 Aug 2020 17:54:39 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 1/4] doc/mesh-api: Add "options" dictionary to Send/Publish Date: Mon, 24 Aug 2020 17:54:32 -0700 Message-Id: <20200825005435.26566-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200825005435.26566-1-inga.stotland@intel.com> References: <20200825005435.26566-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5102042166 X-Rspamd-UID: 61cab8 This modifies Send, DevKeySend and Publish methods on mesh.Node interface to include additional argument "options". This new argument is a dictionary that currently has only one new key word defined for Send() and DevKeySend(): "ForceSegmented" - to force small payloads to be sent as one-segment messages In case of Publish(), and additional keyword is defined "Vendor" - 16-bit Company ID as defined by the Bluetooth SIG Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification. Also, the addition of "options" dictionary to Publish allows to eliminate VendorPublish() method (taken care by "Vendor" keyword). --- doc/mesh-api.txt | 57 ++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt index 495f95b0b..cae80d694 100644 --- a/doc/mesh-api.txt +++ b/doc/mesh-api.txt @@ -229,7 +229,7 @@ Object path /org/bluez/mesh/node<uuid> Methods: void Send(object element_path, uint16 destination, uint16 key_index, - array{byte} data) + dict options, array{byte} data) This method is used to send a message originated by a local model. @@ -248,6 +248,14 @@ Methods: this element. Otherwise, org.bluez.mesh.Error.NotAuthorized will be returned. + The options parameter is a dictionary with the following keys + defined: + + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". + The data parameter is an outgoing message to be encypted by the bluetooth-meshd daemon and sent on. @@ -257,7 +265,7 @@ Methods: org.bluez.mesh.Error.NotFound void DevKeySend(object element_path, uint16 destination, boolean remote, - uint16 net_index, array{byte} data) + uint16 net_index, dict options, array{byte} data) This method is used to send a message originated by a local model encoded with the device key of the remote node. @@ -279,6 +287,14 @@ Methods: The net_index parameter is the subnet index of the network on which the message is to be sent. + The options parameter is a dictionary with the following keys + defined: + + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". + The data parameter is an outgoing message to be encypted by the meshd daemon and sent on. @@ -344,7 +360,8 @@ Methods: org.bluez.mesh.Error.InvalidArguments org.bluez.mesh.Error.NotFound - void Publish(object element_path, uint16 model, array{byte} data) + void Publish(object element_path, uint16 model, dict options, + array{byte} data) This method is used to send a publication originated by a local model. If the model does not exist, or it has no publication @@ -358,30 +375,21 @@ Methods: The model parameter contains a model ID, as defined by the Bluetooth SIG. - Since only one Publish record may exist per element-model, the - destination and key_index are obtained from the Publication - record cached by the daemon. - - Possible errors: - org.bluez.mesh.Error.DoesNotExist - org.bluez.mesh.Error.InvalidArguments - - void VendorPublish(object element_path, uint16 vendor, uint16 model_id, - array{byte} data) - - This method is used to send a publication originated by a local - vendor model. If the model does not exist, or it has no - publication record, the method returns - org.bluez.mesh.Error.DoesNotExist error. + The options parameter is a dictionary with the following keys + defined: - The element_path parameter is the object path of an element from - a collection of the application elements (see Mesh Application - Hierarchy section). + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". + uint16 Vendor - The vendor parameter is a 16-bit Bluetooth-assigned Company ID. + uint16 Vendor + A 16-bit Company ID as defined by the + Bluetooth SIG - The model_id parameter is a 16-bit vendor-assigned Model - Identifier. + The data parameter is an outgoing message to be encypted by the + meshd daemon and sent on. Since only one Publish record may exist per element-model, the destination and key_index are obtained from the Publication @@ -391,6 +399,7 @@ Methods: org.bluez.mesh.Error.DoesNotExist org.bluez.mesh.Error.InvalidArguments + Properties: dict Features [read-only] -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kOzNI2FhRF8g+QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 25 Aug 2020 02:54:57 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eOcZImFhRF9/rwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 25 Aug 2020 02:54:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B62444215B; Tue, 25 Aug 2020 02:54:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728375AbgHYAyp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 20:54:45 -0400 Received: from mga02.intel.com ([134.134.136.20]:44188 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726189AbgHYAyk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 20:54:40 -0400 IronPort-SDR: 8i91yPBQPauaZPMd0NCgsATOme5mhGU++07OIugMn27oiv+i26RgHvanE4+0bNhS/MGXa0Bqb+ 3BLb+5vfHojw== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="143797438" X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="143797438" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 17:54:38 -0700 IronPort-SDR: Upinc3hlHcKC9N/G5UQ3dvvVsTgIAxyP1YM92V75+VXVrzCXCbz6b9qM5qrYp/qEx5zx1NHxqA 01PHZqO+4W6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="474141831" Received: from apaharia-mobl.gar.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.231.108]) by orsmga005.jf.intel.com with ESMTP; 24 Aug 2020 17:54:37 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 0/4] Mesh send/publish API change Date: Mon, 24 Aug 2020 17:54:31 -0700 Message-Id: <20200825005435.26566-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: B62444215B X-Rspamd-UID: 8d2fb4 This patch set modifies Send, DevKeySend and Publish methods on bluez.mesh.Node interface to include additional argument "options". This new argument is a dictionary that currently has only one new key word defined for Send() and DevKeySend(): "ForceSegmented" - to force small payloads to be sent as one-segment messages Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification. ********* v2 ************ In case of Publish(), and additional keyword is defined "Vendor" - 16-bit Company ID as defined by the Bluetooth SIG This allows to eliminate VendorPublish() method. Inga Stotland (4): doc/mesh-api: Add "options" dictionary to Send/Publish mesh: Handle "options" dictionary in Send/Publish methods tools/mesh-cfglient: Add "options" to Send/DevKeySend test/test-mesh: Add "options" to Send/Publish doc/mesh-api.txt | 57 ++++++++++------- mesh/cfgmod-server.c | 2 +- mesh/model.c | 6 +- mesh/model.h | 9 +-- mesh/node.c | 140 ++++++++++++++++++++--------------------- test/test-mesh | 11 +++- tools/mesh-cfgclient.c | 8 +++ 7 files changed, 125 insertions(+), 108 deletions(-) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gCvsMGZhRF9/EQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 25 Aug 2020 02:55:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +I/qLWZhRF8NsgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 25 Aug 2020 02:55:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B3AEC421AF; Tue, 25 Aug 2020 02:54:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728377AbgHYAyp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 20:54:45 -0400 Received: from mga02.intel.com ([134.134.136.20]:44191 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728356AbgHYAym (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 20:54:42 -0400 IronPort-SDR: XqRs41LnA66uagpDiMY2qktO4y77E1VaYSk1z3nc9i3T08AEC43FY1PYDc8JeZ3L79BCTqwfFq zoOJTHmuq2rA== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="143797446" X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="143797446" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 17:54:42 -0700 IronPort-SDR: 7KEChBvVbPBBQL2710uR2k218z1pNA82ds5jFQgiTJx0tjDv/h7roQXXqJUVqgZFOS3eIH313r 0F4bEwWW1Hjg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="474141846" Received: from apaharia-mobl.gar.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.231.108]) by orsmga005.jf.intel.com with ESMTP; 24 Aug 2020 17:54:42 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 3/4] tools/mesh-cfglient: Add "options" to Send/DevKeySend Date: Mon, 24 Aug 2020 17:54:34 -0700 Message-Id: <20200825005435.26566-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200825005435.26566-1-inga.stotland@intel.com> References: <20200825005435.26566-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: B3AEC421AF X-Rspamd-UID: 14c95d This adds a new dictionary paramenter (empty by default) when invoking Send() and DevKeySend() methods. --- tools/mesh-cfgclient.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 59f079213..3987e3179 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -274,6 +274,14 @@ static void send_msg_setup(struct l_dbus_message *msg, void *user_data) l_dbus_message_builder_append_basic(builder, 'b', &req->rmt); l_dbus_message_builder_append_basic(builder, 'q', &req->idx); + + /* Options */ + l_dbus_message_builder_enter_array(builder, "{sv}"); + l_dbus_message_builder_enter_dict(builder, "sv"); + l_dbus_message_builder_leave_dict(builder); + l_dbus_message_builder_leave_array(builder); + + /* Data */ append_byte_array(builder, req->data, req->len); l_dbus_message_builder_finalize(builder); l_dbus_message_builder_destroy(builder); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OCXjMmthRF8g+QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 25 Aug 2020 02:55:07 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id KJYpMWthRF/wcAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 25 Aug 2020 02:55:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E4E0D420FB; Tue, 25 Aug 2020 02:55:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728378AbgHYAyp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 20:54:45 -0400 Received: from mga02.intel.com ([134.134.136.20]:44195 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728373AbgHYAyn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 20:54:43 -0400 IronPort-SDR: tHl5xcxHckPbEoJKAqGT991MYJC2doLiu0CCHLoZJHXCgNCR8yrvkvFEepF8Fk3fa1Opf8lOFI 7vTBMtoudLsA== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="143797447" X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="143797447" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 17:54:42 -0700 IronPort-SDR: H1tmZAIrESaOoqzHutOja3NmImT0oOy4u5tNmKGf8URnv2tUa5loqM4A0YtoViTgwvEggQUIsG 16iS5SuQYCIA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="474141849" Received: from apaharia-mobl.gar.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.231.108]) by orsmga005.jf.intel.com with ESMTP; 24 Aug 2020 17:54:42 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 4/4] test/test-mesh: Add "options" to Send/Publish Date: Mon, 24 Aug 2020 17:54:35 -0700 Message-Id: <20200825005435.26566-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200825005435.26566-1-inga.stotland@intel.com> References: <20200825005435.26566-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.60 / 15.00 / 200.00 X-Rspamd-Queue-Id: E4E0D420FB X-Rspamd-UID: 69fdfa This adds a new dictionary paramenter (empty by default) when invoking Send() or Publish() methods. --- test/test-mesh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/test-mesh b/test/test-mesh index 5da0278d6..1e1b8724d 100755 --- a/test/test-mesh +++ b/test/test-mesh @@ -184,6 +184,9 @@ current_menu = None user_input = 0 input_error = False +send_opts = dbus.Dictionary(signature='sv') +send_opts = {'ForceSegmented' : dbus.Boolean(True)} + def raise_error(str_value): global input_error @@ -538,14 +541,18 @@ class Model(): self.pub_period = period def send_publication(self, data): + pub_opts = dbus.Dictionary(signature='sv') + print('Send publication ', end='') print(data) - node.Publish(self.path, self.model_id, data, + node.Publish(self.path, self.model_id, pub_opts, data, reply_handler=generic_reply_cb, error_handler=generic_error_cb) def send_message(self, dest, key, data): - node.Send(self.path, dest, key, data, + global send_opts + + node.Send(self.path, dest, key, send_opts, data, reply_handler=generic_reply_cb, error_handler=generic_error_cb) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0ISCFHFhRF8g+QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 25 Aug 2020 02:55:13 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 4Kx5EnFhRF9+rgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 25 Aug 2020 02:55:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EC63F4215C; Tue, 25 Aug 2020 02:55:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728376AbgHYAyp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 20:54:45 -0400 Received: from mga02.intel.com ([134.134.136.20]:44188 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728087AbgHYAym (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 20:54:42 -0400 IronPort-SDR: ugpRWDpai+blQTfmU9YQTJ9xvMWDr6SxmwitU3eVneNYTQwcPY91sWx5bqE0nYHSK1m6g2GcWb kr1IctR1Z5iQ== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="143797444" X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="143797444" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 17:54:40 -0700 IronPort-SDR: vLqqbyaRbD2h9n97944/N6PKBkub5e5ifTpFzg/sWDm/ahx9x0BA7/IYfeyXIl7/x8B1qPZDES ulX6PJqqFBDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="474141838" Received: from apaharia-mobl.gar.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.231.108]) by orsmga005.jf.intel.com with ESMTP; 24 Aug 2020 17:54:40 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2 2/4] mesh: Handle "options" dictionary in Send/Publish methods Date: Mon, 24 Aug 2020 17:54:33 -0700 Message-Id: <20200825005435.26566-3-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200825005435.26566-1-inga.stotland@intel.com> References: <20200825005435.26566-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: EC63F4215C X-Rspamd-UID: 1585bb This adds processing of "options" dictionary argument in Send, DevKeySend & Publish methods on mesh.Node interface. This new argument is a dictionary that currently has only one new key word defined for Send() and DevKeySend(): "ForceSegmented" - to force small payloads to be sent as one-segment messages In case of Publish(), and additional keyword is defined "Vendor" - 16-bit Company ID as defined by the Bluetooth SIG Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification. Also, the addition of "options" dictionary to Publish allows to eliminate VendorPublish() method (taken care by "Vendor" keyword). --- mesh/cfgmod-server.c | 2 +- mesh/model.c | 6 +- mesh/model.h | 9 +-- mesh/node.c | 140 +++++++++++++++++++++---------------------- 4 files changed, 75 insertions(+), 82 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 239ea889d..2e5da863a 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -1088,7 +1088,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (n) mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, - DEFAULT_TTL, false, msg, n); + DEFAULT_TTL, false, n, msg); return true; } diff --git a/mesh/model.c b/mesh/model.c index bb5d30083..7bbc9cca7 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -999,7 +999,7 @@ done: } int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, - const void *msg, uint16_t msg_len) + bool segmented, uint16_t msg_len, const void *msg) { struct mesh_net *net = node_get_net(node); struct mesh_model *mod; @@ -1041,7 +1041,7 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, result = msg_send(node, mod->pub->credential != 0, src, mod->pub->addr, mod->pub->idx, net_idx, label, mod->pub->ttl, mod->pub->rtx.cnt, mod->pub->rtx.interval, - false, msg, msg_len); + segmented, msg, msg_len); return result ? MESH_ERROR_NONE : MESH_ERROR_FAILED; } @@ -1049,7 +1049,7 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, uint8_t ttl, bool segmented, - const void *msg, uint16_t msg_len) + uint16_t msg_len, const void *msg) { struct mesh_net *net = node_get_net(node); uint8_t cnt; diff --git a/mesh/model.h b/mesh/model.h index a1afedd19..fe0648d04 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -112,19 +112,16 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size); uint16_t mesh_model_cfg_blk(uint8_t *pkt); bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, - uint16_t app_idx, uint16_t net_idx, - uint8_t ttl, bool segmented, - const void *msg, uint16_t msg_len); + uint16_t app_idx, uint16_t net_idx, uint8_t ttl, + bool segmented, uint16_t len, const void *data); int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, - const void *msg, uint16_t msg_len); + bool segmented, uint16_t len, const void *data); bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, uint32_t seq, uint32_t iv_index, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t key_aid, const uint8_t *data, uint16_t size); -void mesh_model_app_key_generate_new(struct mesh_node *node, uint16_t net_idx); void mesh_model_app_key_delete(struct mesh_node *node, uint16_t ele_idx, struct l_queue *models, uint16_t app_idx); -struct l_queue *mesh_model_get_appkeys(struct mesh_node *node); uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf); bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, uint32_t *opcode, uint16_t *n); diff --git a/mesh/node.c b/mesh/node.c index a6e9cee65..c564bdb91 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -134,6 +134,11 @@ struct managed_obj_request { }; }; +struct send_options { + bool segmented; + uint16_t vendor_id; +}; + static struct l_queue *nodes; static bool match_device_uuid(const void *a, const void *b) @@ -1745,13 +1750,40 @@ void node_build_attach_reply(struct mesh_node *node, l_dbus_message_builder_destroy(builder); } +static bool parse_send_options(struct l_dbus_message_iter *itr, + struct send_options *opts) +{ + const char *key; + struct l_dbus_message_iter var; + + opts->segmented = false; + opts->vendor_id = SIG_VENDOR; + + while (l_dbus_message_iter_next_entry(itr, &key, &var)) { + if (!strcmp(key, "ForceSegmented")) { + if (!l_dbus_message_iter_get_variant(&var, "b", + &opts->segmented)) + return false; + } + + if (!strcmp(key, "Vendor")) { + if (!l_dbus_message_iter_get_variant(&var, "q", + &opts->vendor_id)) + return false; + } + } + + return true; +} + static struct l_dbus_message *send_call(struct l_dbus *dbus, struct l_dbus_message *msg, void *user_data) { struct mesh_node *node = user_data; const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; + struct l_dbus_message_iter dict, iter_data; + struct send_options opts; struct node_element *ele; uint16_t dst, app_idx, net_idx, src; uint8_t *data; @@ -1764,8 +1796,8 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &dst, - &app_idx, &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqqa{sv}ay", &ele_path, &dst, + &app_idx, &dict, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); ele = l_queue_find(node->elements, match_element_path, ele_path); @@ -1773,6 +1805,9 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_NOT_FOUND, "Element not found"); + if (!parse_send_options(&dict, &opts)) + return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); + src = node_get_primary(node) + ele->idx; if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || @@ -1790,7 +1825,7 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, "Key not found"); if (!mesh_model_send(node, src, dst, app_idx, net_idx, DEFAULT_TTL, - false, data, len)) + opts.segmented, len, data)) return dbus_error(msg, MESH_ERROR_FAILED, NULL); return l_dbus_message_new_method_return(msg); @@ -1802,7 +1837,8 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, { struct mesh_node *node = user_data; const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; + struct l_dbus_message_iter iter_data, dict; + struct send_options opts; struct node_element *ele; uint16_t dst, app_idx, net_idx, src; bool remote; @@ -1816,8 +1852,8 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqbqay", &ele_path, &dst, - &remote, &net_idx, &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqbqa{sv}ay", &ele_path, &dst, + &remote, &net_idx, &dict, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); /* Loopbacks to local servers must use *remote* addressing */ @@ -1829,6 +1865,9 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_NOT_FOUND, "Element not found"); + if (!parse_send_options(&dict, &opts)) + return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); + src = node_get_primary(node) + ele->idx; if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || @@ -1838,7 +1877,7 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, app_idx = remote ? APP_IDX_DEV_REMOTE : APP_IDX_DEV_LOCAL; if (!mesh_model_send(node, src, dst, app_idx, net_idx, DEFAULT_TTL, - false, data, len)) + opts.segmented, len, data)) return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); return l_dbus_message_new_method_return(msg); @@ -1896,7 +1935,7 @@ static struct l_dbus_message *add_netkey_call(struct l_dbus *dbus, l_put_le16(sub_idx, &data[2]); if (!mesh_model_send(node, src, dst, APP_IDX_DEV_REMOTE, net_idx, - DEFAULT_TTL, false, data, 20)) + DEFAULT_TTL, false, 20, data)) return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); return l_dbus_message_new_method_return(msg); @@ -1962,7 +2001,7 @@ static struct l_dbus_message *add_appkey_call(struct l_dbus *dbus, data[3] = app_idx >> 4; if (!mesh_model_send(node, src, dst, APP_IDX_DEV_REMOTE, net_idx, - DEFAULT_TTL, false, data, 20)) + DEFAULT_TTL, false, 20, data)) return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); return l_dbus_message_new_method_return(msg); @@ -1974,8 +2013,9 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, { struct mesh_node *node = user_data; const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; + struct l_dbus_message_iter iter_data, dict; uint16_t mod_id, src; + struct send_options opts; struct node_element *ele; uint8_t *data; uint32_t len, id; @@ -1988,8 +2028,8 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqay", &ele_path, &mod_id, - &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqa{sv}ay", &ele_path, &mod_id, + &dict, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); ele = l_queue_find(node->elements, match_element_path, ele_path); @@ -1997,51 +2037,9 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_NOT_FOUND, "Element not found"); - src = node_get_primary(node) + ele->idx; - - if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || - !len || len > MAX_MSG_LEN) - return dbus_error(msg, MESH_ERROR_INVALID_ARGS, - "Incorrect data"); - - id = SET_ID(SIG_VENDOR, mod_id); - result = mesh_model_publish(node, id, src, data, len); - - if (result != MESH_ERROR_NONE) - return dbus_error(msg, result, NULL); - - return l_dbus_message_new_method_return(msg); -} - -static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, - struct l_dbus_message *msg, - void *user_data) -{ - struct mesh_node *node = user_data; - const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; - uint16_t src, mod_id, vendor_id; - struct node_element *ele; - uint8_t *data = NULL; - uint32_t len; - int result; - - l_debug("Publish"); - - sender = l_dbus_message_get_sender(msg); - - if (strcmp(sender, node->owner)) - return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - - if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &vendor_id, - &mod_id, &iter_data)) + if (!parse_send_options(&dict, &opts)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); - ele = l_queue_find(node->elements, match_element_path, ele_path); - if (!ele) - return dbus_error(msg, MESH_ERROR_NOT_FOUND, - "Element not found"); - src = node_get_primary(node) + ele->idx; if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || @@ -2049,13 +2047,14 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - result = mesh_model_publish(node, SET_ID(vendor_id, mod_id), src, - data, len); + id = SET_ID(opts.vendor_id, mod_id); + + result = mesh_model_publish(node, id, src, opts.segmented, len, data); if (result != MESH_ERROR_NONE) return dbus_error(msg, result, NULL); - return l_dbus_message_new_method_return(msg); + return l_dbus_message_new_method_return(msg); } static bool features_getter(struct l_dbus *dbus, struct l_dbus_message *msg, @@ -2192,27 +2191,24 @@ static bool addresses_getter(struct l_dbus *dbus, struct l_dbus_message *msg, static void setup_node_interface(struct l_dbus_interface *iface) { - l_dbus_interface_method(iface, "Send", 0, send_call, "", "oqqay", + l_dbus_interface_method(iface, "Send", 0, send_call, "", "oqqa{sv}ay", "element_path", "destination", - "key_index", "data"); - l_dbus_interface_method(iface, "DevKeySend", 0, dev_key_send_call, - "", "oqbqay", "element_path", + "key_index", "options", "data"); + l_dbus_interface_method(iface, "DevKeySend", 0, dev_key_send_call, "", + "oqbqa{sv}ay", "element_path", "destination", "remote", - "net_index", "data"); + "net_index", "options", "data"); l_dbus_interface_method(iface, "AddNetKey", 0, add_netkey_call, "", "oqqqb", "element_path", "destination", "subnet_index", "net_index", "update"); l_dbus_interface_method(iface, "AddAppKey", 0, add_appkey_call, "", "oqqqb", "element_path", "destination", "app_index", "net_index", "update"); - l_dbus_interface_method(iface, "Publish", 0, publish_call, "", "oqay", - "element_path", "model_id", "data"); - l_dbus_interface_method(iface, "VendorPublish", 0, vendor_publish_call, - "", "oqqay", "element_path", - "vendor", "model_id", "data"); - - l_dbus_interface_property(iface, "Features", 0, "a{sv}", features_getter, - NULL); + l_dbus_interface_method(iface, "Publish", 0, publish_call, "", + "oqa{sv}ay", "element_path", "model_id", + "options", "data"); + l_dbus_interface_property(iface, "Features", 0, "a{sv}", + features_getter, NULL); l_dbus_interface_property(iface, "Beacon", 0, "b", beacon_getter, NULL); l_dbus_interface_property(iface, "IvUpdate", 0, "b", ivupdate_getter, NULL); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qDE2Ij5pRF+zjgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 25 Aug 2020 03:28:30 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id ECR5ID5pRF8WQQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 25 Aug 2020 03:28:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AF715421AF; Tue, 25 Aug 2020 03:28:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725926AbgHYB2Y (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 24 Aug 2020 21:28:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725648AbgHYB2V (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 24 Aug 2020 21:28:21 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E366C061795 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 18:28:21 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id p4so9604793qkf.0 for <linux-bluetooth@vger.kernel.org>; Mon, 24 Aug 2020 18:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=DAuNBpBgH3PMFZ1XPPlSiM7ZIOFoLNImY+P7f/YdMSU=; b=aPUkWddcb3QT2PdKxUVq7lODNuTjc5vGDurV+QTinJxggzK0OIzmRdHr5+Sn5JhIWQ GSWE2bp8JTHHE4WFg4mSV5dyx8c6DsrDgKjnIV63uRAM4nli2IDfyt2F1wyHZ8FJc2NS +Dvx4AqlGVAAKgGF71kRF6xKOWAas3rWM+emy7L+HGSe9OVvI+kfgSdiGjqRWclaxbyc JgJKInViNff59eKoC+QMgeK2yCtsrUvVg4atgn1tmIfsZea+ODYQLH2kzZDw/ErfblD6 iDCgQJPefGmjQ8ycXtAtgmSDNcwFexfeAIYyV2xbqrQ7U2JMBm7HN1EhRdGZLoeWRy8e j0Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=DAuNBpBgH3PMFZ1XPPlSiM7ZIOFoLNImY+P7f/YdMSU=; b=EG98GKUt4wKRI3UYELiwnyEkqAwrKN3WrkjXHWSAL8ClOoAEIygCN8kn1Fw3wBYm27 L4s6P2bHy+RX7aKRmnT3tODITD11Ak4i69SF1XEYKTA5JGcPIeLz1Nw+xinuwdUgECZM f/0CASZ60aLKIjm3+00jmEJfwZA7QclY/UvI9Mo0O38xGvg2E6ADGfvLajQXTbUrYRA/ mlbRoWjvRBEyVNM6mQFHXy2tPhhHINAFrYT9Rn+fAWBm742Icri02Hlm2FUawBibN6zB ndGjDJRiecQlE2j5nv/RkzfHmEuPGJAfGWQ/5/vRLYziBUgHiAEzWf4XVqid+uBjAVh/ tnFQ== X-Gm-Message-State: AOAM532U1wGmfPnsQHrmNm6fkv3eBehWVf5um24ShgOYlhDtnNUSoaPr NrBxY/mOYANBmtRlRjSZCophRgAh8OfxNQ== X-Google-Smtp-Source: ABdhPJzq8eVEZYJdANzd6YEVxqUxJax/CG63rIsSE8lE812Bjyl2c3d+5Ir6o0kNUt0pMPmUuXEqlA== X-Received: by 2002:a37:b184:: with SMTP id a126mr6738244qkf.23.1598318899857; Mon, 24 Aug 2020 18:28:19 -0700 (PDT) Received: from [172.17.0.2] ([52.242.91.111]) by smtp.gmail.com with ESMTPSA id m30sm13072329qtm.46.2020.08.24.18.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2020 18:28:19 -0700 (PDT) Message-ID: <5f446933.1c69fb81.e66c0.9644@mx.google.com> Date: Mon, 24 Aug 2020 18:28:19 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============0106636418685870792==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, inga.stotland@intel.com Subject: RE: [BlueZ,v2,1/4] doc/mesh-api: Add "options" dictionary to Send/Publish Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200825005435.26566-2-inga.stotland@intel.com> References: <20200825005435.26566-2-inga.stotland@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.96 / 15.00 / 200.00 X-Rspamd-Queue-Id: AF715421AF X-Rspamd-UID: 663ca4 --===============0106636418685870792== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 8: B3 Line contains hard tab characters (\t): " one-segment messages" --- Regards, Linux Bluetooth --===============0106636418685870792==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sABhG6crRV/VYgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 25 Aug 2020 17:17:59 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YD88GqcrRV9SVQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 25 Aug 2020 17:17:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 15CB7A1230; Tue, 25 Aug 2020 17:17:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726697AbgHYPRm convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 25 Aug 2020 11:17:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:46282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726627AbgHYPRV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 25 Aug 2020 11:17:21 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Tue, 25 Aug 2020 15:17:09 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mmdesai20@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-Itfr71Ib20@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.63 / 15.00 / 200.00 X-Rspamd-Queue-Id: 15CB7A1230 X-Rspamd-UID: 0d488c https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #142 from MMD (mmdesai20@gmail.com) --- (In reply to Swyter from comment #137) > Hi! There's actually a script that should help with this, at least as > reference: > https://gist.github.com/nevack/6b36b82d715dc025163d9e9124840a07 > > It's for newer kernels, though. So while the btusb.c part should more or > less apply cleanly (because the existing/original CSR workaround stuff has > been there for a while) the ERR_DATA_REPORTING stuff (on hci_core.c) is new > and will need to be stripped out when back-porting the patch. > > Who knows, maybe it's a good idea to ask someone from Canonical to add it to > Ubuntu, once it's been more battle-tested. Hopefully (as it officially gets > into stable kernels) distros downstream will pick this up, even on super old > Linux versions. > > Hope that helps. :) Yes...finally it is working... I installed kernel 5.8.3 and ran script at.. And it is working... Thank you very much.... -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SC1MEXufRV91mgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 01:32:11 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id mM+cD3ufRV+8EwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 01:32:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1B506420EC; Wed, 26 Aug 2020 01:32:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726672AbgHYXcD (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 25 Aug 2020 19:32:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726551AbgHYXcC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 25 Aug 2020 19:32:02 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F448C061574 for <linux-bluetooth@vger.kernel.org>; Tue, 25 Aug 2020 16:32:01 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id g127so340352ybf.11 for <linux-bluetooth@vger.kernel.org>; Tue, 25 Aug 2020 16:32:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=mTR23obn3++N19RG/EtHRUQ3yC7sF+wMDpRoTOlZX0k=; b=ILiabPYE0me1HApwqMZ2+3BMmFww6n1ALOpdSBbDFbzKlr8HpfRhnjA+ISbcuuCAQR 9T01Gt5pqwAn+LaofE7+YcT/A8YfaoOaSm1n03/ZcmKrAq4bY8iQ3M5U1xY70qywVrOD /cvdd25kfRWSFfgRbHhF4e+h85P2hLdeSwto5EXMHXa8Fqk3Hkwai09/435nJcz7/Wxz 9oO+z1NaMwqw3BEs1OEnxEY05fEMo4zXU6l/2iQLtpIr1W0KYbfx7WWk8sLHtkoJF6mx Lyn4XwjPSRbR2cL2swtxooPGCKUbsCemeyS7KjzH8jazjYlc/M/euZDEP39GlCSuEHAu Si3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=mTR23obn3++N19RG/EtHRUQ3yC7sF+wMDpRoTOlZX0k=; b=WwSaCLJPcjM820toviOKndfByEuKUAvtYzGAJKB2RSoedCyQlMwzlnP1xJGLkAStIh 3f5jGNXzaMkOhDLRMg1e9omBCVjT+3/nw8j03RVTaE2kvT2aR2ho1Qbt2GAyLjZIyqM8 sI/hHDETiZvmbRfOcPLp2YfPViahT1xV7fQUqDmtnMe3nIzO7ifld/Mt4VNsVzZJwuk5 2hLd9nbabLOG5Y1H7kXwpiHId8ZbN52GOnm6eneCq//lXkOBfDqvWnEqXa/ArV3gRhUv NVvi+G8SJwG0RdMMZfChd0A90UrLxrr3Uv4nc66VLpITUBnsGjN0EYBa0oBm2te+wo8e Wn5g== X-Gm-Message-State: AOAM530qSg5pl/cStSqbBpf2JGKPYK8RNe4qEKQ37MbSsdDznxuOCOry 9pcPV5nj3drN1cWG+IbIcV1cFyBd4AzN54dXxm5nsU0OD1iqkD89nWs5mWRDwzPyREBzZvjGu5e tUkrsMlg/lMFryduMeIirPIxYJy4SDFBWAizwLPqx/DldOLf/f4mM0+3kZ2bA3PWVgJYejaIZF1 SxW8mluGGrHw2826TE X-Google-Smtp-Source: ABdhPJwwLjoeH289Grt/z9y7LeTjH6etNBMtETY13Iy6KtTX8eH2Poc0k3x27Uzj1hmt6b9xngXhpGRYYx+hu4S5cLCO X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:c68b:: with SMTP id k133mr18907196ybf.491.1598398320460; Tue, 25 Aug 2020 16:32:00 -0700 (PDT) Date: Tue, 25 Aug 2020 16:31:49 -0700 Message-Id: <20200825233151.1580920-1-danielwinkler@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [PATCH 0/2] Bluetooth: Report extended adv capabilities to userspace From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Marcel Holtmann <marcel@holtmann.org>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1B506420EC X-Rspamd-UID: 260f8f Hi Maintainers, This series improves the kernel/controller support that is reported to userspace for the following extended advertising features: 1. If extended advertising is available, the number of hardware slots is used and reported, rather than the fixed default of 5. If no hardware support is available, default is used as before for software rotation. 2. New flags indicating general hardware offloading and ability to set tx power level. These are kept as two separate flags because in the future vendor commands may allow tx power to be set without hardware offloading support. Daniel Winkler (2): bluetooth: Report num supported adv instances for hw offloading bluetooth: Add MGMT capability flags for tx power and ext advertising include/net/bluetooth/mgmt.h | 2 ++ net/bluetooth/hci_core.c | 2 +- net/bluetooth/mgmt.c | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KC2YF4WfRV91mgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 01:32:21 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id oLzxFYWfRV+LCwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 01:32:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 15870420EE; Wed, 26 Aug 2020 01:32:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726752AbgHYXcI (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 25 Aug 2020 19:32:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbgHYXcG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 25 Aug 2020 19:32:06 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EDD6C061756 for <linux-bluetooth@vger.kernel.org>; Tue, 25 Aug 2020 16:32:06 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id x6so343457ybp.10 for <linux-bluetooth@vger.kernel.org>; Tue, 25 Aug 2020 16:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=kaUkInMqAgQ2Lzd+PreohlLW19JNhR91SpBMUzQm9p0=; b=PAfzZk/j+abf2vwqzxAFT3gplmX2gT7/B1H66vAmV6b/W/XwPJgtb8FtPyZDKENpe8 tcViB/VjdULapoXGX1+NZ10q95Z0GApG28ULg75ofb7vBDHgsoJhMdvc85pLcfMtZV3L NbQgmUdXZ769CN8kuqLK6y3plvqnQpVXo8L7aY+pISgsrRsqa49ETbVSXd3YHuYj3/O5 D8VnYchfeiM0YGhbU/MdVsCVzZ63RvbBxgB3ez4T3MdzdkvHpNCFSY4brrYZ+kLf0xFq nTxRTQVpWpKkgEg7h+fvY7ADfBsXvcDBMd268eE1GeY7hCANlw9uRxLwYupX58/Sc4Fp wbBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=kaUkInMqAgQ2Lzd+PreohlLW19JNhR91SpBMUzQm9p0=; b=BF6z9lGn1/EGdpSKlvoyX2Gq3jdUf4Tsp+A/S/RoMH20i05ockAniNbNso66jPMyrp RrdJaO87hQxc5DB1Ps7dFcai+Uq9xGjBMGNBNtjaIR7zyOyslcDl41/viFsAXLrc2cVf 3vQsjWtaCqtJr0RKTSmUvehnCw5U1XMcFzp5Xt6m2zPQmIMtpS3cj9/UaUKhy2fDd3YE hGJOHpERNgaIVlf4nXXjBlVyBAqtr2lteJ0x36+lA25EBbx9JiVCDEDlEJPfBCglFuK7 dNUWU6JXPVHtEFUAraq/IGBoQui623EAlb99kl3HfjBnLhGKObcTHzoBCSnCo6yY7p16 7gLg== X-Gm-Message-State: AOAM530+NK4eKQj8/Fc0HQ2lFe3XhrXoqkV9Xlab+H4uZemU4WLROo2I 2D+yfZ1yl3/Pvc2UKXTQyL7avo8xgU5S5VLMbvjDcdVnC7HUA7rR8ULEOWjnsr6lm5Vd8vtfjQt SQtiX2THaZDTCwNU6pbcPd55/tGNdqUZlzmNcwdVyjuOrgx6EnFwaHPqKY21vf7MwNERgxLUuF1 +zZrdMhl0VT9HvFpkM X-Google-Smtp-Source: ABdhPJxknta/s/oAGl30UwT+/4w1jNnjt42KUayAVjKNAjWvqKRJyEtmfW6BXOaX6IuAsQ4X260dPO/cE6HnQxsUjGv9 X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a5b:70d:: with SMTP id g13mr17995321ybq.160.1598398325448; Tue, 25 Aug 2020 16:32:05 -0700 (PDT) Date: Tue, 25 Aug 2020 16:31:50 -0700 In-Reply-To: <20200825233151.1580920-1-danielwinkler@google.com> Message-Id: <20200825163120.1.I1f7e93bc6bad468fdc24fad319de8c32621a49a7@changeid> Mime-Version: 1.0 References: <20200825233151.1580920-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [PATCH 1/2] bluetooth: Report num supported adv instances for hw offloading From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Marcel Holtmann <marcel@holtmann.org>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.99 / 15.00 / 200.00 X-Rspamd-Queue-Id: 15870420EE X-Rspamd-UID: 712dcc Here we make sure we properly report the number of supported advertising slots when we are using hardware offloading. If no hardware offloading is available, we default this value to HCI_MAX_ADV_INSTANCES for use in software rotation as before. This change has been tested on kukui (no ext adv) and hatch (ext adv) chromebooks by verifying "SupportedInstances" shows 5 (the default) and 6 (slots supported by controller), respectively. Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- net/bluetooth/hci_core.c | 2 +- net/bluetooth/mgmt.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 68bfe57b66250f..500ab478769508 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2963,7 +2963,7 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, sizeof(adv_instance->scan_rsp_data)); } else { if (hdev->adv_instance_cnt >= hdev->le_num_of_adv_sets || - instance < 1 || instance > HCI_MAX_ADV_INSTANCES) + instance < 1 || instance > hdev->le_num_of_adv_sets) return -EOVERFLOW; adv_instance = kzalloc(sizeof(*adv_instance), GFP_KERNEL); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5bbe71002fb950..8041c9cebd5cf6 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -7250,7 +7250,7 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev, rp->supported_flags = cpu_to_le32(supported_flags); rp->max_adv_data_len = HCI_MAX_AD_LENGTH; rp->max_scan_rsp_len = HCI_MAX_AD_LENGTH; - rp->max_instances = HCI_MAX_ADV_INSTANCES; + rp->max_instances = hdev->le_num_of_adv_sets; rp->num_instances = hdev->adv_instance_cnt; instance = rp->instance; @@ -7446,7 +7446,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, MGMT_STATUS_NOT_SUPPORTED); - if (cp->instance < 1 || cp->instance > HCI_MAX_ADV_INSTANCES) + if (cp->instance < 1 || cp->instance > hdev->le_num_of_adv_sets) return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, MGMT_STATUS_INVALID_PARAMS); @@ -7699,7 +7699,7 @@ static int get_adv_size_info(struct sock *sk, struct hci_dev *hdev, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO, MGMT_STATUS_REJECTED); - if (cp->instance < 1 || cp->instance > HCI_MAX_ADV_INSTANCES) + if (cp->instance < 1 || cp->instance > hdev->le_num_of_adv_sets) return mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO, MGMT_STATUS_INVALID_PARAMS); -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4B3EBpmfRV8kUgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 01:32:41 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id qDsSBZmfRV/iewEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 01:32:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D43EA420E1; Wed, 26 Aug 2020 01:32:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726820AbgHYXcQ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 25 Aug 2020 19:32:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726790AbgHYXcL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 25 Aug 2020 19:32:11 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6831C061756 for <linux-bluetooth@vger.kernel.org>; Tue, 25 Aug 2020 16:32:09 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id w17so345907ybl.9 for <linux-bluetooth@vger.kernel.org>; Tue, 25 Aug 2020 16:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=NtMj2bcsf5T/oy70A+QWn2i5VysKtCM7HUSW6c9Q/F8=; b=OF4V+BTAnjuhDpqLAN3ENPlRr166XM4CkXsvkYoyGn409D3rDgpiebFFLDw3Nb3Sxj BL4V0wcGv2ATKHvLcee8AHM0nUKWjzsZbBj+ieulmIkxuwpuoBtqwNegR45YD34zu7aC 9tFk5w88uXhMfV7TRO1pi9MuE3bMy003AifqjPEfhTk39BZVIfI18OtrDorwPG5KYpvb ERmyQ5x4uP/FIWisIJEHWGLlwJXhCKFP3ObP0its4rrZwGSatjaXpqixLyPksut9mBC4 O2gjlb6++NyKz2/y/kiuddgVOJbTFe3KPqKaqrWlAGxd+akzqOmCD/b/jeSp4HiPh8cH MgJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=NtMj2bcsf5T/oy70A+QWn2i5VysKtCM7HUSW6c9Q/F8=; b=Dk/U42gdAOGO/NmR/gqQpiXsBWW5D2vr3RCJ4/Dc4aif3tP2rcX0V8RQz9Lj3twMEB +FsoisIBGJL0HQxRp8bxfmWCnURMatf9NRAo4qrgfRkuWoSmEzSrNPiLMdMCikG4+qGS aV/FUzsjXgHZaQOZiTDs4OaSRydB0FxOFyF+VmOp0LNifW5amItlFeB/RIPBiK0swBST WTvghvnagDZC44ixmyczNthmTuSRG4UH29MWs7SFxCuZarIQ3XLfrXzbQaQCFVfCzzJd mrFvwRgmQ11HI0bu74UyzKE2Gaz8uPVF/3sLu8N+cXWXXakzGaSVsoyU/LunDxbi9itJ vweg== X-Gm-Message-State: AOAM530KMRFLsFHsp4yfZCqUZbA4OOZAm11gCOl5jLQ8buYVutaKbsoJ BgPnpECXLmttERz13E5As09VbqaEc+sxeKq6PgN0ah6AIXrDIBOPtGRq3ix7NLIKztrVQtmQP+z FrNo5DBimu2wvRbL/AakKR4t6XpLHycXgZ0uLxxUk18kIjizEZA7kSTrvPoWCXAEIGdJIFMifJt 55ASjEJKpqtt0WZtPS X-Google-Smtp-Source: ABdhPJyYcNHSnzxlABPklRA+Q1XOh563ginyu6oORioyUTcYQOT0k/q9zvtSpJqy2O7Bu2rS8xH9F5r60KnWDXBAYgzF X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:428a:: with SMTP id p132mr17184715yba.453.1598398329019; Tue, 25 Aug 2020 16:32:09 -0700 (PDT) Date: Tue, 25 Aug 2020 16:31:51 -0700 In-Reply-To: <20200825233151.1580920-1-danielwinkler@google.com> Message-Id: <20200825163120.2.I569943db89c40c4007ef7290d145c9f3d023932f@changeid> Mime-Version: 1.0 References: <20200825233151.1580920-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [PATCH 2/2] bluetooth: Add MGMT capability flags for tx power and ext advertising From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Marcel Holtmann <marcel@holtmann.org>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.98 / 15.00 / 200.00 X-Rspamd-Queue-Id: D43EA420E1 X-Rspamd-UID: 9a7ca7 For new advertising features, it will be important for userspace to know the capabilities of the controller and kernel. If the controller and kernel support extended advertising, we include flags indicating hardware offloading support and support for setting tx power of adv instances. In the future, vendor-specific commands may allow the setting of tx power in advertising instances, but for now this feature is only marked available if extended advertising is supported. This change is manually verified in userspace by ensuring the advertising manager's supported_flags field is updated with new flags on hatch chromebook (ext advertising supported). Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- include/net/bluetooth/mgmt.h | 2 ++ net/bluetooth/mgmt.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index beae5c3980f03b..9ad505b9e694e4 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -572,6 +572,8 @@ struct mgmt_rp_add_advertising { #define MGMT_ADV_FLAG_SEC_1M BIT(7) #define MGMT_ADV_FLAG_SEC_2M BIT(8) #define MGMT_ADV_FLAG_SEC_CODED BIT(9) +#define MGMT_ADV_FLAG_CAN_SET_TX_POWER BIT(10) +#define MGMT_ADV_FLAG_HW_OFFLOAD BIT(11) #define MGMT_ADV_FLAG_SEC_MASK (MGMT_ADV_FLAG_SEC_1M | MGMT_ADV_FLAG_SEC_2M | \ MGMT_ADV_FLAG_SEC_CODED) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 8041c9cebd5cf6..c5d128f331c6dc 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -7202,6 +7202,8 @@ static u32 get_supported_adv_flags(struct hci_dev *hdev) if (ext_adv_capable(hdev)) { flags |= MGMT_ADV_FLAG_SEC_1M; + flags |= MGMT_ADV_FLAG_HW_OFFLOAD; + flags |= MGMT_ADV_FLAG_CAN_SET_TX_POWER; if (hdev->le_features[1] & HCI_LE_PHY_2M) flags |= MGMT_ADV_FLAG_SEC_2M; -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +NP3IoUDRl9MuQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 08:39:01 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8BJUIYUDRl8sJwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 08:39:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 71133420BF; Wed, 26 Aug 2020 08:38:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727783AbgHZGhy (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 02:37:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727869AbgHZGht (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 02:37:49 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7A0AC061574 for <linux-bluetooth@vger.kernel.org>; Tue, 25 Aug 2020 23:37:48 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id 31so529638pgy.13 for <linux-bluetooth@vger.kernel.org>; Tue, 25 Aug 2020 23:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3zzoAm6sUSyHag4twlxTUJvc8Ko0bHT2KVfZ37UKyfE=; b=YYsjJEJvJh7OGn/tXYsRbZtl7MPAw/IERKcq3mG2Om5PezaBePnLcyFMLg8BD3PTy/ PcCKIWiw+CkPQ4Xy2pCCaZamo7PP4lztcGGXKy49kJE6ec1XstHskar28SlkEmT1z8SU CJoa/NwR7TOk2+DlPe5dJY/qt9G0/AbIgcjqA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3zzoAm6sUSyHag4twlxTUJvc8Ko0bHT2KVfZ37UKyfE=; b=LhcpHrnmGvr4oj8OJIxi11GD9k7/9IpmEI2woOikhkOoHwrorxlltRONrPKBwQsw5H Fnk1Ze/KRFok/25l1ExlFjp3vncgcWYZ6fLa6pfkqHNoyI+Ym355YBC0e9JrU7KzdHPm gRYlRFwks789tLV2xX/PA9hjx3Zgv/DawXuZQEXjppFCfzQZa+cn+q1+ZwETrUwdS0S5 7ku/Duh64WpfCze8+7v2OSujyGliJhwnpAK8wY/o8/uE+aTwjBR305Y4B2oCtuO0s9TS Ez/gtzRXFwdi71enYniWAq9ERSXE2/6BOsLmq7pYO4bLni0xmVPy5Ek967cTyj0JcEZt lv/Q== X-Gm-Message-State: AOAM532EMIovKfEbj/ZkTXg+nJ3AMHbnBD8kxmq51DYDOU1nc/vXwd4n 3W1fOsvZ87nkvUf3z4wDo6D+wXMoh2IEQg== X-Google-Smtp-Source: ABdhPJwAOj3T3sb5HI/2wq6rPObsyEI1fWGlSNQsHCzen/gxESKuOeILNadWdCJz6d/7NKb5SC734w== X-Received: by 2002:a62:6497:: with SMTP id y145mr10819614pfb.97.1598423868094; Tue, 25 Aug 2020 23:37:48 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id c3sm1500852pfd.137.2020.08.25.23.37.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Aug 2020 23:37:47 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Jie Jiang <jiejiang@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Subject: [PATCH BlueZ] gatt: Accept empty array in parse_includes() Date: Tue, 25 Aug 2020 23:37:42 -0700 Message-Id: <20200826063742.76007-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 71133420BF X-Rspamd-UID: 8189fd From: Jie Jiang <jiejiang@chromium.org> Currently parse_includes() will return false if the "Includes" property is an empty array. Empty array in the "Includes" property should be treated as valid. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- src/gatt-database.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gatt-database.c b/src/gatt-database.c index 07d567078..e7e4a36a6 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -2008,6 +2008,7 @@ static bool parse_includes(GDBusProxy *proxy, struct external_service *service) DBusMessageIter iter; DBusMessageIter array; char *obj; + int type; /* Includes property is optional */ if (!g_dbus_proxy_get_property(proxy, "Includes", &iter)) @@ -2018,9 +2019,9 @@ static bool parse_includes(GDBusProxy *proxy, struct external_service *service) dbus_message_iter_recurse(&iter, &array); - do { - if (dbus_message_iter_get_arg_type(&array) != - DBUS_TYPE_OBJECT_PATH) + while ((type = dbus_message_iter_get_arg_type(&array)) + != DBUS_TYPE_INVALID) { + if (type != DBUS_TYPE_OBJECT_PATH) return false; dbus_message_iter_get_basic(&array, &obj); @@ -2028,11 +2029,12 @@ static bool parse_includes(GDBusProxy *proxy, struct external_service *service) if (!queue_push_tail(service->includes, obj)) { error("Failed to add Includes path in queue\n"); return false; - } incr_attr_count(service, 1); - } while (dbus_message_iter_next(&array)); + + dbus_message_iter_next(&array); + } return true; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OJ29NW8xRl/UmAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 11:54:55 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QP4FNG8xRl+NyQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 11:54:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 08236A242D; Wed, 26 Aug 2020 11:54:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728067AbgHZJyn (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 05:54:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727942AbgHZJym (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 05:54:42 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74B2BC061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 02:54:42 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id i10so794933pgk.1 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 02:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MFJyxn0sYlOZ7uMd8lMntiT/9xQLuQk8yZ+XjHsuGEI=; b=DGZ/T6L9zlP50gGxSUQguqktO/Pi8kGcUE8UCT3vylg465RFHflFsrNtC324K61672 /bX/XL3i6MU81QDNKea8cYq3GI5PR0wITcatvGcENK8Uq8XA+pxLaW7KWbok6pMVHPmZ 12kqWoDbHbsUOWcG7VjBZd/R34qpmR2h1preJO9iJhdlve5IkA9fklFPPe0zrHSYejKb 1X/0ix+YAjzLDxEMIgaC7uhhF/hEdeNj3AnTkci6GxoCcRrHAHJJQxykyVyjEEdg07Bl 4MLqTWRkwxkoe131oQoWpYKDdYfR1w2R+pq/iUjOrQeZptN4IMUSUSLkXQq36Uj3Ldef dEqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MFJyxn0sYlOZ7uMd8lMntiT/9xQLuQk8yZ+XjHsuGEI=; b=kQAXMTu8OyJoPAIeADeLg0PGiWA+BUifCZpN7MtIe5jxzvF5HzoHXHCquhId8EIjnW 2jNWH5e8pWyT4PlbK9Y7Y7WvqkeLzbe+tky+3MDpDKjO5dNAVVGzU1CRdaAOgvooWHqL rM6h3FWMUgJ7u5WO6vwBzrwkNdTMq+2IeMH0HOUlKinj251nW4ysZD0qrGOLmiDI7Cuw 8O97aaCFwquHJSE+xQSoXrWsvHvltzSnLNo9NmMMmSmSO6HMBZx/lvNQmpp1fr/6xMfx Cxy9GRZSYWInTo8/RTHeMo2OPetVr/luIpgsKHICEgK36EXdMEgR58txFYQ+s5AjsagC BvVw== X-Gm-Message-State: AOAM531W1C4H8MU5eSZWfq7bsXv8cOgoa9l87uY3lMpgBr5R8R4mVwsQ 2jy/ayfTuBrEo2VXSEkKv4xBKALdmlzLwCSa X-Google-Smtp-Source: ABdhPJyBmG5k3Y9KZ0ZCu9sR5v2zFqJ1V+FJYJu9ssiRemeAMsFGIh6jJYcMFawgJ6rZP/u6fTYxIQ== X-Received: by 2002:a63:6346:: with SMTP id x67mr10035840pgb.121.1598435681601; Wed, 26 Aug 2020 02:54:41 -0700 (PDT) Received: from localhost.localdomain ([122.171.201.76]) by smtp.gmail.com with ESMTPSA id a10sm2376687pfk.26.2020.08.26.02.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 02:54:41 -0700 (PDT) From: Kiran K <kiraank@gmail.com> X-Google-Original-From: Kiran K <kiran.k@intel.com> To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, Kiran K <kiran.k@intel.com>, Chethan T N <chethan.tumkur.narayan@intel.com> Subject: [PATCH] Bluetooth: btusb: Update boot parameter specific to SKU Date: Wed, 26 Aug 2020 15:24:32 +0530 Message-Id: <20200826095432.18825-1-kiran.k@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 08236A242D X-Rspamd-UID: af9a05 boot parameter gets updated during firmware download process. Use the updated boot parameter while doing soft reset of controller. This patch fixes updating of boot parameter. Reviewed-by: Chethan T N <chethan.tumkur.narayan@intel.com> Signed-off-by: Kiran K <kiran.k@intel.com> --- drivers/bluetooth/btusb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 8d2608ddfd08..414575eccbad 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2338,10 +2338,10 @@ static bool btusb_setup_intel_new_get_fw_name(struct intel_version *ver, static int btusb_intel_download_firmware(struct hci_dev *hdev, struct intel_version *ver, - struct intel_boot_params *params) + struct intel_boot_params *params, + u32 *boot_param) { const struct firmware *fw; - u32 boot_param; char fwname[64]; int err; struct btusb_data *data = hci_get_drvdata(hdev); @@ -2479,7 +2479,7 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev, set_bit(BTUSB_DOWNLOADING, &data->flags); /* Start firmware downloading and get boot parameter */ - err = btintel_download_firmware(hdev, fw, &boot_param); + err = btintel_download_firmware(hdev, fw, boot_param); if (err < 0) { /* When FW download fails, send Intel Reset to retry * FW download. @@ -2561,7 +2561,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) return err; } - err = btusb_intel_download_firmware(hdev, &ver, ¶ms); + err = btusb_intel_download_firmware(hdev, &ver, ¶ms, &boot_param); if (err) return err; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QB56BMuTRl/GhAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 18:54:35 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id MEbhAsuTRl9BeAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 18:54:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DA35FA10B1; Wed, 26 Aug 2020 18:54:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbgHZQy2 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 12:54:28 -0400 Received: from mga12.intel.com ([192.55.52.136]:2013 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbgHZQy0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 12:54:26 -0400 IronPort-SDR: MamyRcwKctf+6eGInT8XavSvgBumzLzh43bDyTJMJp8uTvYBDMU4s0mk2ljUj7JN9EYrAtLxo9 qTElNDGJuo5g== X-IronPort-AV: E=McAfee;i="6000,8403,9725"; a="135883619" X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="135883619" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2020 09:54:26 -0700 IronPort-SDR: 9yfVrKycYdK9RkCf7/FLZ+guBuR617iQNn2z2AuiYlFCuAHn/fxvXtTsQMvuGEL5oQ5hc1mYv8 Xc0b+QMATojg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="331851951" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.63.130]) by fmsmga002.fm.intel.com with ESMTP; 26 Aug 2020 09:54:25 -0700 From: Brian Gix <brian.gix@intel.com> To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ v3 0/4] Mesh send/publish API change Date: Wed, 26 Aug 2020 09:54:16 -0700 Message-Id: <20200826165420.563822-1-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.31 / 15.00 / 200.00 X-Rspamd-Queue-Id: DA35FA10B1 X-Rspamd-UID: 9c7984 This patch set modifies Send, DevKeySend and Publish methods on bluez.mesh.Node interface to include additional argument "options". This new argument is a dictionary that currently has only one new key word defined for Send() and DevKeySend(): "ForceSegmented" - to force small payloads to be sent as one-segment messages Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification. ********* v2 ************ In case of Publish(), and additional keyword is defined "Vendor" - 16-bit Company ID as defined by the Bluetooth SIG This allows us to eliminate VendorPublish() method. ********* v3 ************ Added Vendor specific clarity to the Publish() method description in mesh-api.txt, since VendorPublish() is removed. Inga Stotland (4): doc/mesh-api: Add "options" dictionary to Send/Publish mesh: Handle "options" dictionary in Send/Publish methods tools/mesh-cfglient: Add "options" to Send/DevKeySend test/test-mesh: Add "options" to Send/Publish doc/mesh-api.txt | 60 ++++++++++-------- mesh/cfgmod-server.c | 2 +- mesh/model.c | 6 +- mesh/model.h | 9 +-- mesh/node.c | 140 ++++++++++++++++++++--------------------- test/test-mesh | 11 +++- tools/mesh-cfgclient.c | 8 +++ 7 files changed, 127 insertions(+), 109 deletions(-) -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kKv/GdCTRl98mgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 18:54:40 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 2CTbGNCTRl/LIwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 18:54:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3310CA0035; Wed, 26 Aug 2020 18:54:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727080AbgHZQya (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 12:54:30 -0400 Received: from mga12.intel.com ([192.55.52.136]:2014 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726820AbgHZQy2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 12:54:28 -0400 IronPort-SDR: 6CaOaXtqjJdSMaJMlYngwKmJjUqOMT4etWSbGNDTYVHfZUhBAO4UI0CJuAGyTKL6zGn9EnCBEy 0NTARjcDXubQ== X-IronPort-AV: E=McAfee;i="6000,8403,9725"; a="135883621" X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="135883621" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2020 09:54:27 -0700 IronPort-SDR: GPCgg/VKCQ7IhpLXVmAO8naewY9qqgoOaMoyXMe1tfjyDPSDveaM09R/GMin1Cj7I/clDLoQtS 91tn8gXktV+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="331851966" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.63.130]) by fmsmga002.fm.intel.com with ESMTP; 26 Aug 2020 09:54:26 -0700 From: Brian Gix <brian.gix@intel.com> To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ v3 2/4] mesh: Handle "options" dictionary in Send/Publish methods Date: Wed, 26 Aug 2020 09:54:18 -0700 Message-Id: <20200826165420.563822-3-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200826165420.563822-1-brian.gix@intel.com> References: <20200826165420.563822-1-brian.gix@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3310CA0035 X-Rspamd-UID: 385f2c From: Inga Stotland <inga.stotland@intel.com> This adds processing of "options" dictionary argument in Send, DevKeySend & Publish methods on mesh.Node interface. This new argument is a dictionary that currently has only one new key word defined for Send() and DevKeySend(): "ForceSegmented" - to force small payloads to be sent as one-segment messages In case of Publish(), and additional keyword is defined "Vendor" - 16-bit Company ID as defined by the Bluetooth SIG Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification. Also, the addition of "options" dictionary to Publish allows to eliminate VendorPublish() method (taken care by "Vendor" keyword). --- mesh/cfgmod-server.c | 2 +- mesh/model.c | 6 +- mesh/model.h | 9 +-- mesh/node.c | 140 +++++++++++++++++++++---------------------- 4 files changed, 75 insertions(+), 82 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 239ea889d..2e5da863a 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -1088,7 +1088,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, if (n) mesh_model_send(node, dst, src, APP_IDX_DEV_LOCAL, net_idx, - DEFAULT_TTL, false, msg, n); + DEFAULT_TTL, false, n, msg); return true; } diff --git a/mesh/model.c b/mesh/model.c index bb5d30083..7bbc9cca7 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -999,7 +999,7 @@ done: } int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, - const void *msg, uint16_t msg_len) + bool segmented, uint16_t msg_len, const void *msg) { struct mesh_net *net = node_get_net(node); struct mesh_model *mod; @@ -1041,7 +1041,7 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, result = msg_send(node, mod->pub->credential != 0, src, mod->pub->addr, mod->pub->idx, net_idx, label, mod->pub->ttl, mod->pub->rtx.cnt, mod->pub->rtx.interval, - false, msg, msg_len); + segmented, msg, msg_len); return result ? MESH_ERROR_NONE : MESH_ERROR_FAILED; } @@ -1049,7 +1049,7 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, uint8_t ttl, bool segmented, - const void *msg, uint16_t msg_len) + uint16_t msg_len, const void *msg) { struct mesh_net *net = node_get_net(node); uint8_t cnt; diff --git a/mesh/model.h b/mesh/model.h index a1afedd19..fe0648d04 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -112,19 +112,16 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size); uint16_t mesh_model_cfg_blk(uint8_t *pkt); bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, - uint16_t app_idx, uint16_t net_idx, - uint8_t ttl, bool segmented, - const void *msg, uint16_t msg_len); + uint16_t app_idx, uint16_t net_idx, uint8_t ttl, + bool segmented, uint16_t len, const void *data); int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, - const void *msg, uint16_t msg_len); + bool segmented, uint16_t len, const void *data); bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, uint32_t seq, uint32_t iv_index, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t key_aid, const uint8_t *data, uint16_t size); -void mesh_model_app_key_generate_new(struct mesh_node *node, uint16_t net_idx); void mesh_model_app_key_delete(struct mesh_node *node, uint16_t ele_idx, struct l_queue *models, uint16_t app_idx); -struct l_queue *mesh_model_get_appkeys(struct mesh_node *node); uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf); bool mesh_model_opcode_get(const uint8_t *buf, uint16_t size, uint32_t *opcode, uint16_t *n); diff --git a/mesh/node.c b/mesh/node.c index a6e9cee65..c564bdb91 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -134,6 +134,11 @@ struct managed_obj_request { }; }; +struct send_options { + bool segmented; + uint16_t vendor_id; +}; + static struct l_queue *nodes; static bool match_device_uuid(const void *a, const void *b) @@ -1745,13 +1750,40 @@ void node_build_attach_reply(struct mesh_node *node, l_dbus_message_builder_destroy(builder); } +static bool parse_send_options(struct l_dbus_message_iter *itr, + struct send_options *opts) +{ + const char *key; + struct l_dbus_message_iter var; + + opts->segmented = false; + opts->vendor_id = SIG_VENDOR; + + while (l_dbus_message_iter_next_entry(itr, &key, &var)) { + if (!strcmp(key, "ForceSegmented")) { + if (!l_dbus_message_iter_get_variant(&var, "b", + &opts->segmented)) + return false; + } + + if (!strcmp(key, "Vendor")) { + if (!l_dbus_message_iter_get_variant(&var, "q", + &opts->vendor_id)) + return false; + } + } + + return true; +} + static struct l_dbus_message *send_call(struct l_dbus *dbus, struct l_dbus_message *msg, void *user_data) { struct mesh_node *node = user_data; const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; + struct l_dbus_message_iter dict, iter_data; + struct send_options opts; struct node_element *ele; uint16_t dst, app_idx, net_idx, src; uint8_t *data; @@ -1764,8 +1796,8 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &dst, - &app_idx, &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqqa{sv}ay", &ele_path, &dst, + &app_idx, &dict, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); ele = l_queue_find(node->elements, match_element_path, ele_path); @@ -1773,6 +1805,9 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_NOT_FOUND, "Element not found"); + if (!parse_send_options(&dict, &opts)) + return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); + src = node_get_primary(node) + ele->idx; if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || @@ -1790,7 +1825,7 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, "Key not found"); if (!mesh_model_send(node, src, dst, app_idx, net_idx, DEFAULT_TTL, - false, data, len)) + opts.segmented, len, data)) return dbus_error(msg, MESH_ERROR_FAILED, NULL); return l_dbus_message_new_method_return(msg); @@ -1802,7 +1837,8 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, { struct mesh_node *node = user_data; const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; + struct l_dbus_message_iter iter_data, dict; + struct send_options opts; struct node_element *ele; uint16_t dst, app_idx, net_idx, src; bool remote; @@ -1816,8 +1852,8 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqbqay", &ele_path, &dst, - &remote, &net_idx, &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqbqa{sv}ay", &ele_path, &dst, + &remote, &net_idx, &dict, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); /* Loopbacks to local servers must use *remote* addressing */ @@ -1829,6 +1865,9 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_NOT_FOUND, "Element not found"); + if (!parse_send_options(&dict, &opts)) + return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); + src = node_get_primary(node) + ele->idx; if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || @@ -1838,7 +1877,7 @@ static struct l_dbus_message *dev_key_send_call(struct l_dbus *dbus, app_idx = remote ? APP_IDX_DEV_REMOTE : APP_IDX_DEV_LOCAL; if (!mesh_model_send(node, src, dst, app_idx, net_idx, DEFAULT_TTL, - false, data, len)) + opts.segmented, len, data)) return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); return l_dbus_message_new_method_return(msg); @@ -1896,7 +1935,7 @@ static struct l_dbus_message *add_netkey_call(struct l_dbus *dbus, l_put_le16(sub_idx, &data[2]); if (!mesh_model_send(node, src, dst, APP_IDX_DEV_REMOTE, net_idx, - DEFAULT_TTL, false, data, 20)) + DEFAULT_TTL, false, 20, data)) return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); return l_dbus_message_new_method_return(msg); @@ -1962,7 +2001,7 @@ static struct l_dbus_message *add_appkey_call(struct l_dbus *dbus, data[3] = app_idx >> 4; if (!mesh_model_send(node, src, dst, APP_IDX_DEV_REMOTE, net_idx, - DEFAULT_TTL, false, data, 20)) + DEFAULT_TTL, false, 20, data)) return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); return l_dbus_message_new_method_return(msg); @@ -1974,8 +2013,9 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, { struct mesh_node *node = user_data; const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; + struct l_dbus_message_iter iter_data, dict; uint16_t mod_id, src; + struct send_options opts; struct node_element *ele; uint8_t *data; uint32_t len, id; @@ -1988,8 +2028,8 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, if (strcmp(sender, node->owner)) return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - if (!l_dbus_message_get_arguments(msg, "oqay", &ele_path, &mod_id, - &iter_data)) + if (!l_dbus_message_get_arguments(msg, "oqa{sv}ay", &ele_path, &mod_id, + &dict, &iter_data)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); ele = l_queue_find(node->elements, match_element_path, ele_path); @@ -1997,51 +2037,9 @@ static struct l_dbus_message *publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_NOT_FOUND, "Element not found"); - src = node_get_primary(node) + ele->idx; - - if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || - !len || len > MAX_MSG_LEN) - return dbus_error(msg, MESH_ERROR_INVALID_ARGS, - "Incorrect data"); - - id = SET_ID(SIG_VENDOR, mod_id); - result = mesh_model_publish(node, id, src, data, len); - - if (result != MESH_ERROR_NONE) - return dbus_error(msg, result, NULL); - - return l_dbus_message_new_method_return(msg); -} - -static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, - struct l_dbus_message *msg, - void *user_data) -{ - struct mesh_node *node = user_data; - const char *sender, *ele_path; - struct l_dbus_message_iter iter_data; - uint16_t src, mod_id, vendor_id; - struct node_element *ele; - uint8_t *data = NULL; - uint32_t len; - int result; - - l_debug("Publish"); - - sender = l_dbus_message_get_sender(msg); - - if (strcmp(sender, node->owner)) - return dbus_error(msg, MESH_ERROR_NOT_AUTHORIZED, NULL); - - if (!l_dbus_message_get_arguments(msg, "oqqay", &ele_path, &vendor_id, - &mod_id, &iter_data)) + if (!parse_send_options(&dict, &opts)) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); - ele = l_queue_find(node->elements, match_element_path, ele_path); - if (!ele) - return dbus_error(msg, MESH_ERROR_NOT_FOUND, - "Element not found"); - src = node_get_primary(node) + ele->idx; if (!l_dbus_message_iter_get_fixed_array(&iter_data, &data, &len) || @@ -2049,13 +2047,14 @@ static struct l_dbus_message *vendor_publish_call(struct l_dbus *dbus, return dbus_error(msg, MESH_ERROR_INVALID_ARGS, "Incorrect data"); - result = mesh_model_publish(node, SET_ID(vendor_id, mod_id), src, - data, len); + id = SET_ID(opts.vendor_id, mod_id); + + result = mesh_model_publish(node, id, src, opts.segmented, len, data); if (result != MESH_ERROR_NONE) return dbus_error(msg, result, NULL); - return l_dbus_message_new_method_return(msg); + return l_dbus_message_new_method_return(msg); } static bool features_getter(struct l_dbus *dbus, struct l_dbus_message *msg, @@ -2192,27 +2191,24 @@ static bool addresses_getter(struct l_dbus *dbus, struct l_dbus_message *msg, static void setup_node_interface(struct l_dbus_interface *iface) { - l_dbus_interface_method(iface, "Send", 0, send_call, "", "oqqay", + l_dbus_interface_method(iface, "Send", 0, send_call, "", "oqqa{sv}ay", "element_path", "destination", - "key_index", "data"); - l_dbus_interface_method(iface, "DevKeySend", 0, dev_key_send_call, - "", "oqbqay", "element_path", + "key_index", "options", "data"); + l_dbus_interface_method(iface, "DevKeySend", 0, dev_key_send_call, "", + "oqbqa{sv}ay", "element_path", "destination", "remote", - "net_index", "data"); + "net_index", "options", "data"); l_dbus_interface_method(iface, "AddNetKey", 0, add_netkey_call, "", "oqqqb", "element_path", "destination", "subnet_index", "net_index", "update"); l_dbus_interface_method(iface, "AddAppKey", 0, add_appkey_call, "", "oqqqb", "element_path", "destination", "app_index", "net_index", "update"); - l_dbus_interface_method(iface, "Publish", 0, publish_call, "", "oqay", - "element_path", "model_id", "data"); - l_dbus_interface_method(iface, "VendorPublish", 0, vendor_publish_call, - "", "oqqay", "element_path", - "vendor", "model_id", "data"); - - l_dbus_interface_property(iface, "Features", 0, "a{sv}", features_getter, - NULL); + l_dbus_interface_method(iface, "Publish", 0, publish_call, "", + "oqa{sv}ay", "element_path", "model_id", + "options", "data"); + l_dbus_interface_property(iface, "Features", 0, "a{sv}", + features_getter, NULL); l_dbus_interface_property(iface, "Beacon", 0, "b", beacon_getter, NULL); l_dbus_interface_property(iface, "IvUpdate", 0, "b", ivupdate_getter, NULL); -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6HFdJdWTRl/GhAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 18:54:45 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id yJpqI9WTRl+WaAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 18:54:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8DC79A1419; Wed, 26 Aug 2020 18:54:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727784AbgHZQya (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 12:54:30 -0400 Received: from mga12.intel.com ([192.55.52.136]:2013 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbgHZQy2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 12:54:28 -0400 IronPort-SDR: WOqB0djzFbAMI4L+6+RW7vQuJ3oczcIfiO1RwsHqDGjDPNvriA199pWDloFbqfiH3h5X77Sqf1 +ZUvSK2h3nOQ== X-IronPort-AV: E=McAfee;i="6000,8403,9725"; a="135883620" X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="135883620" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2020 09:54:26 -0700 IronPort-SDR: 1NrtchoYKWVy1BodSFizdexLSq/KkxeGhSBjF00u1l4+t4OmEDJ+UZLqsB4e+c69Nk7rJ8OYhW 6HKZ3XT+SpRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="331851961" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.63.130]) by fmsmga002.fm.intel.com with ESMTP; 26 Aug 2020 09:54:26 -0700 From: Brian Gix <brian.gix@intel.com> To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ v3 1/4] doc/mesh-api: Add "options" dictionary to Send/Publish Date: Wed, 26 Aug 2020 09:54:17 -0700 Message-Id: <20200826165420.563822-2-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200826165420.563822-1-brian.gix@intel.com> References: <20200826165420.563822-1-brian.gix@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8DC79A1419 X-Rspamd-UID: 3f5563 From: Inga Stotland <inga.stotland@intel.com> This modifies Send, DevKeySend and Publish methods on mesh.Node interface to include additional argument "options". This new argument is a dictionary that currently has only one new key word defined for Send() and DevKeySend(): "ForceSegmented" - to force small payloads to be sent as one-segment messages In case of Publish(), and additional keyword is defined "Vendor" - 16-bit Company ID as defined by the Bluetooth SIG Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification. Also, the addition of "options" dictionary to Publish allows to eliminate VendorPublish() method (taken care by "Vendor" keyword). --- doc/mesh-api.txt | 60 ++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt index 495f95b0b..254ccbd7f 100644 --- a/doc/mesh-api.txt +++ b/doc/mesh-api.txt @@ -229,7 +229,7 @@ Object path /org/bluez/mesh/node<uuid> Methods: void Send(object element_path, uint16 destination, uint16 key_index, - array{byte} data) + dict options, array{byte} data) This method is used to send a message originated by a local model. @@ -248,6 +248,14 @@ Methods: this element. Otherwise, org.bluez.mesh.Error.NotAuthorized will be returned. + The options parameter is a dictionary with the following keys + defined: + + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". + The data parameter is an outgoing message to be encypted by the bluetooth-meshd daemon and sent on. @@ -257,7 +265,7 @@ Methods: org.bluez.mesh.Error.NotFound void DevKeySend(object element_path, uint16 destination, boolean remote, - uint16 net_index, array{byte} data) + uint16 net_index, dict options, array{byte} data) This method is used to send a message originated by a local model encoded with the device key of the remote node. @@ -279,6 +287,14 @@ Methods: The net_index parameter is the subnet index of the network on which the message is to be sent. + The options parameter is a dictionary with the following keys + defined: + + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". + The data parameter is an outgoing message to be encypted by the meshd daemon and sent on. @@ -344,7 +360,8 @@ Methods: org.bluez.mesh.Error.InvalidArguments org.bluez.mesh.Error.NotFound - void Publish(object element_path, uint16 model, array{byte} data) + void Publish(object element_path, uint16 model, dict options, + array{byte} data) This method is used to send a publication originated by a local model. If the model does not exist, or it has no publication @@ -356,32 +373,24 @@ Methods: Hierarchy section). The model parameter contains a model ID, as defined by the - Bluetooth SIG. - - Since only one Publish record may exist per element-model, the - destination and key_index are obtained from the Publication - record cached by the daemon. + Bluetooth SIG. If the options dictionary contains a "Vendor" + key, then this ID is defined by the specified vendor. - Possible errors: - org.bluez.mesh.Error.DoesNotExist - org.bluez.mesh.Error.InvalidArguments - - void VendorPublish(object element_path, uint16 vendor, uint16 model_id, - array{byte} data) - - This method is used to send a publication originated by a local - vendor model. If the model does not exist, or it has no - publication record, the method returns - org.bluez.mesh.Error.DoesNotExist error. + The options parameter is a dictionary with the following keys + defined: - The element_path parameter is the object path of an element from - a collection of the application elements (see Mesh Application - Hierarchy section). + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". - The vendor parameter is a 16-bit Bluetooth-assigned Company ID. + uint16 Vendor + A 16-bit Company ID as defined by the + Bluetooth SIG. This key should only exist when + publishing on a Vendor defined model. - The model_id parameter is a 16-bit vendor-assigned Model - Identifier. + The data parameter is an outgoing message to be encypted by the + meshd daemon and sent on. Since only one Publish record may exist per element-model, the destination and key_index are obtained from the Publication @@ -391,6 +400,7 @@ Methods: org.bluez.mesh.Error.DoesNotExist org.bluez.mesh.Error.InvalidArguments + Properties: dict Features [read-only] -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EGptJ9qTRl98mgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 18:54:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CNNFJdqTRl/4ygAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 18:54:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B5F08A1419; Wed, 26 Aug 2020 18:54:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728019AbgHZQyb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 12:54:31 -0400 Received: from mga12.intel.com ([192.55.52.136]:2014 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726971AbgHZQy3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 12:54:29 -0400 IronPort-SDR: pAg5h1zIqlAJVn5V2l8ClCMpKAIp8rgrpC2pRdo0fJdvNqMYK+BtFQi6rYFdltBLdEepvhv9av 3fRSsVPmXXdg== X-IronPort-AV: E=McAfee;i="6000,8403,9725"; a="135883623" X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="135883623" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2020 09:54:27 -0700 IronPort-SDR: AU+5rklClgwUa1JUQIrb9iOmVgZTWNzS5Og575e5vcHtbZb2DGjveA5CZeyXoc8eXoOXRek8OT Iu2bq7Z92tEQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="331851977" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.63.130]) by fmsmga002.fm.intel.com with ESMTP; 26 Aug 2020 09:54:27 -0700 From: Brian Gix <brian.gix@intel.com> To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ v3 4/4] test/test-mesh: Add "options" to Send/Publish Date: Wed, 26 Aug 2020 09:54:20 -0700 Message-Id: <20200826165420.563822-5-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200826165420.563822-1-brian.gix@intel.com> References: <20200826165420.563822-1-brian.gix@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.62 / 15.00 / 200.00 X-Rspamd-Queue-Id: B5F08A1419 X-Rspamd-UID: 5655d9 From: Inga Stotland <inga.stotland@intel.com> This adds a new dictionary paramenter (empty by default) when invoking Send() or Publish() methods. --- test/test-mesh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/test-mesh b/test/test-mesh index 5da0278d6..1e1b8724d 100755 --- a/test/test-mesh +++ b/test/test-mesh @@ -184,6 +184,9 @@ current_menu = None user_input = 0 input_error = False +send_opts = dbus.Dictionary(signature='sv') +send_opts = {'ForceSegmented' : dbus.Boolean(True)} + def raise_error(str_value): global input_error @@ -538,14 +541,18 @@ class Model(): self.pub_period = period def send_publication(self, data): + pub_opts = dbus.Dictionary(signature='sv') + print('Send publication ', end='') print(data) - node.Publish(self.path, self.model_id, data, + node.Publish(self.path, self.model_id, pub_opts, data, reply_handler=generic_reply_cb, error_handler=generic_error_cb) def send_message(self, dest, key, data): - node.Send(self.path, dest, key, data, + global send_opts + + node.Send(self.path, dest, key, send_opts, data, reply_handler=generic_reply_cb, error_handler=generic_error_cb) -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aOEiKt+TRl98mgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 18:54:55 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iD5rKN+TRl9U0QAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 18:54:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C459BA12E3; Wed, 26 Aug 2020 18:54:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728058AbgHZQyb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 12:54:31 -0400 Received: from mga12.intel.com ([192.55.52.136]:2013 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbgHZQy3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 12:54:29 -0400 IronPort-SDR: P1UUjfiM24j7JajYvaEIlsTcvzcrAZ2EN1pXChSDxgI9C99HKfN/YyS2hgO8w9WtMs3iw2f0LB 60WSkeqgvd4w== X-IronPort-AV: E=McAfee;i="6000,8403,9725"; a="135883622" X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="135883622" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2020 09:54:27 -0700 IronPort-SDR: C5C65wsWoyGZrGzPEP4yTggIAUM1Mfe8WK6Tvq49A3Ozks4SLBXXb8ltQyqpWohctuop58quPN Kro1tFRzrgYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="331851974" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.63.130]) by fmsmga002.fm.intel.com with ESMTP; 26 Aug 2020 09:54:26 -0700 From: Brian Gix <brian.gix@intel.com> To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ v3 3/4] tools/mesh-cfglient: Add "options" to Send/DevKeySend Date: Wed, 26 Aug 2020 09:54:19 -0700 Message-Id: <20200826165420.563822-4-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200826165420.563822-1-brian.gix@intel.com> References: <20200826165420.563822-1-brian.gix@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: C459BA12E3 X-Rspamd-UID: aad252 From: Inga Stotland <inga.stotland@intel.com> This adds a new dictionary paramenter (empty by default) when invoking Send() and DevKeySend() methods. --- tools/mesh-cfgclient.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 59f079213..3987e3179 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -274,6 +274,14 @@ static void send_msg_setup(struct l_dbus_message *msg, void *user_data) l_dbus_message_builder_append_basic(builder, 'b', &req->rmt); l_dbus_message_builder_append_basic(builder, 'q', &req->idx); + + /* Options */ + l_dbus_message_builder_enter_array(builder, "{sv}"); + l_dbus_message_builder_enter_dict(builder, "sv"); + l_dbus_message_builder_leave_dict(builder); + l_dbus_message_builder_leave_array(builder); + + /* Data */ append_byte_array(builder, req->data, req->len); l_dbus_message_builder_finalize(builder); l_dbus_message_builder_destroy(builder); -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +OlkLKiURl/GhAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 18:58:16 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id UDBVKqiURl+mYgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 18:58:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C2008420F4; Wed, 26 Aug 2020 18:58:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726971AbgHZQ6L (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 12:58:11 -0400 Received: from mga18.intel.com ([134.134.136.126]:24211 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726820AbgHZQ6J (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 12:58:09 -0400 IronPort-SDR: U7j5Qqn5MgUGBizO80DCVUHoVykRf6V7Ffq8N+Z85ZDID6FhRl27DPreskGhUHsN5iA79y+2e5 YW/01AfvDyoQ== X-IronPort-AV: E=McAfee;i="6000,8403,9725"; a="144006086" X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="144006086" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2020 09:58:08 -0700 IronPort-SDR: K+j4SrnBQ1su5J78NU3zSnzOT/IsREflmoCq7538243vvJJXE92mplWyGI3oVu1j1l6i7/URLX le1UKOA/+wZg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="329292551" Received: from fmsmsx605-2.cps.intel.com (HELO fmsmsx605.amr.corp.intel.com) ([10.18.84.215]) by orsmga008.jf.intel.com with ESMTP; 26 Aug 2020 09:58:08 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 26 Aug 2020 09:58:08 -0700 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 26 Aug 2020 09:58:08 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 26 Aug 2020 09:58:07 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.170) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 26 Aug 2020 09:58:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VDxShjlPYojZ70NOfZZnLOmHraUA/SaEn/eD29ey64ijqHYXKozzwd4cTgS1dlHQhbBK/duvHDpxrBppP4zYcAJzpZfFcpfC+9LfTTNaXnwAInNm4Y27+r/MQuCDaCRqNCx6u5XvmMGNn8wWwkkSHNnTQHmLIKGam7H5H4eEsRwfF/8Xaufu2KPQEmcLKMJtRQ5ESW8TY/kYmltw9N2ApZzmMsSdI8CzdlbYaNLNPd7Dk7GDbp6O6i5qCBeTiuoSTBJolK6OkRq66lnlQOeslKeK2SaP6bQjfO9Dtbzc9RHQgf+6NZ9OmpZB4iZ4kUvtI+04h6OcVv/7SyYdIlERJA== 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-SenderADCheck; bh=MbR7T0WBY2V4VcScOPVuQ8iXElABMQis552iZ9IXk4E=; b=kUYMBaay3BWFM2FDoJI2a6WdZzRv8CidmzHMsx27B+vgsM71uXCGEaSvsAPoDVJXOh96ZjkoTHzAlCXLuZ8xLFH2rtzzZ/Qz8LdJgu6Xpo0Yp1u3lBRHp3GsVb062By6ej91rS5di6pwzQnX5F8hR4ONBn/zB7BYnXnruTCnH0gLCj+58eiqQOv8yQQqdIjWLyC/Ug8Gwcx+hfWqvT9KWqmzOtprQNla0F41ZgH9+/JQvwxKzozI32Bkp7UOud0vGvAb9UQMPHLVSeEPW4TfR2uyRNzX5JEZdEOEafc/wLIv3uiwZl1rlFfNBVXr+O7Gct+ZRHQ1CH7Yvpzxtx2/nA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MbR7T0WBY2V4VcScOPVuQ8iXElABMQis552iZ9IXk4E=; b=tqr/M3Cf4SxuQnnaev6dzfT3glhQAusGnKGpkjf7DTD5q27NGWD79P6tqY/tyX3gd+2cM7I1Sc6kK2fwFeOo/b9IPygAC1E6e1JjsT0sQtXEaZ29xznqKUcbmdnfekN5f+U1q1VxAiUG5wVJRCtKkb7xYS/sjfxIStNQS++t2JE= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR1101MB2192.namprd11.prod.outlook.com (2603:10b6:301:59::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Wed, 26 Aug 2020 16:58:06 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3326.019; Wed, 26 Aug 2020 16:58:06 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> CC: "mike@mnmoran.org" <mike@mnmoran.org>, "michal.lowas-rzechonek@silvair.com" <michal.lowas-rzechonek@silvair.com>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ v3 0/4] Mesh send/publish API change Thread-Topic: [PATCH BlueZ v3 0/4] Mesh send/publish API change Thread-Index: AQHWe8mUWQRcoFWSdEi2UPln3ahZpalKnI6A Date: Wed, 26 Aug 2020 16:58:06 +0000 Message-ID: <4b29d4d233edd02266e905b13651859ec0dce918.camel@intel.com> References: <20200826165420.563822-1-brian.gix@intel.com> In-Reply-To: <20200826165420.563822-1-brian.gix@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.54.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e2b28ebb-4d8b-43f2-d9ed-08d849e13458 x-ms-traffictypediagnostic: MWHPR1101MB2192: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR1101MB2192DA28A722396497C3AB68E1540@MWHPR1101MB2192.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: onaXrtICe/GOV5q7qmltscYM1pqCRNmWgQkjPdbtRMuedP1Zj2WnJ1VXLudWZosvYsEMqxHKQFjFMb/rhIL8JX3gTfTksgmxbM6jK8yIuxZMNLF8WW8nk20Veq0rUd7AsFc7GxgoeXLgDzwUdzghO62Nt/fuH6dD6O2nEpb3YD3qrDtoT7MV9MApS6dKqCW5mOoDAsSqNKkUbRZuETmlGZonG4z/bJn17ws/bhmA3hAv8LLEHJIDsTSUJBNXrj3quXLUiw5srCAaitDsChvw3+QVN6UMlSQG7pCIRKIWR3OhJftk1FNdaLqsC3SgP4oK+IfdgUDczlfLHn9lkFdkTw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(376002)(366004)(136003)(39860400002)(396003)(66946007)(186003)(36756003)(91956017)(2906002)(5660300002)(76116006)(6506007)(8676002)(4326008)(6486002)(83380400001)(8936002)(64756008)(6512007)(66446008)(66556008)(66476007)(71200400001)(316002)(26005)(86362001)(54906003)(2616005)(107886003)(478600001)(6916009);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: MLon2IDrfunR4sLwbwM2VVnHL286mE5lyDaac+QQx9SHUfrkXF6fENdVvyBWw7u+fpx9HeDGhG7qoa5ZF797AE7XajjuDbWfBfLNuJHfXDWfk0GZBkMefx+TNqWT0GICqJd1cMOFJJgviUPI6gcTVj9OPoGPOfZVcqJZHfhz/vZ7vg+ygb7OaJdDNJLXDfiRhU9DubvrGwI3txOKx/mLX9nBqKlEdAruOqD4OODYMB+sf44YJrwRAjRQRueDVcmFq6w/nklT+l0L2q5/MvLKyGj/EahPyuXxAt1DAHS0sPBjCfGDgxGrME5+Nh+SKS/jD/E7nDmaVEhqSaKyK67600h8qIYCbyYOVJIlnfU1h/FPnRqbWJVOKwknmZFxcSV3XvCiBWhmmuWM66rrnsrMoIr4HqO/2M+Gks8uPOmMW5heq7j5DZXKoOa7LMpiRSwtSAACHv5FzyP04SPBldZy/g8Hf76l1pcUT1MXe804De+7SfzhO8niYkuW7ZeDV19hkBsNEPDSVonhve4XM4pCtMUY7VPD7ei89I42Ccb7C3IclXcwHKtGXP5sDgnaWGtlgwmgvq+pMbbbaACBqpuwqGzuUoFGk/O+EXVM0SYinO1Ri9ropZyFxGuiXFwc8RHLeEQ/s2W2Xgie715S+zCmMA== Content-Type: text/plain; charset="utf-8" Content-ID: <A68D441B98B0224EAD6871CB55EC472E@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e2b28ebb-4d8b-43f2-d9ed-08d849e13458 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Aug 2020 16:58:06.6477 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Ydtt9tR7aa6fX5g+tN/ZxRISFyDCNa/bLMojoQOjtNE5siVaa7wCQWCH6HgvPZsqzzTw397HS4UEEWHNuymNnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2192 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.88 / 15.00 / 200.00 X-Rspamd-Queue-Id: C2008420F4 X-Rspamd-UID: a2f3cc UGF0Y2hzZXQgQXBwbGllZA0KT24gV2VkLCAyMDIwLTA4LTI2IGF0IDA5OjU0IC0wNzAwLCBCcmlh biBHaXggd3JvdGU6DQo+IFRoaXMgcGF0Y2ggc2V0IG1vZGlmaWVzIFNlbmQsIERldktleVNlbmQg YW5kIFB1Ymxpc2ggbWV0aG9kcw0KPiBvbiBibHVlei5tZXNoLk5vZGUgaW50ZXJmYWNlIHRvIGlu Y2x1ZGUgYWRkaXRpb25hbCBhcmd1bWVudCAib3B0aW9ucyIuDQo+IA0KPiBUaGlzIG5ldyBhcmd1 bWVudCBpcyBhIGRpY3Rpb25hcnkgdGhhdCBjdXJyZW50bHkgaGFzIG9ubHkgb25lDQo+IG5ldyBr ZXkgd29yZCBkZWZpbmVkIGZvciBTZW5kKCkgYW5kIERldktleVNlbmQoKToNCj4gICAgICJGb3Jj ZVNlZ21lbnRlZCIgLSB0byBmb3JjZSBzbWFsbCBwYXlsb2FkcyB0byBiZSBzZW50IGFzDQo+ICAg ICAgICAgICAgICAgICAgICAgICBvbmUtc2VnbWVudCBtZXNzYWdlcw0KPiANCj4gT3RoZXIga2V5 IHdvcmRzIG1heSBiZSBkZWZpbmVkIGluIGZ1dHVyZSB0byBhY2NvbW1vZGF0ZSBldm9sdmluZw0K PiByZXF1aXJlbWVudHMgb2YgTWVzaCBQcm9maWxlIHNwZWNpZmljYXRpb24uDQo+IA0KPiAqKioq KioqKiogdjIgKioqKioqKioqKioqDQo+IEluIGNhc2Ugb2YgUHVibGlzaCgpLCBhbmQgYWRkaXRp b25hbCBrZXl3b3JkIGlzIGRlZmluZWQNCj4gICAgICJWZW5kb3IiIC0gIDE2LWJpdCBDb21wYW55 IElEIGFzIGRlZmluZWQgYnkgdGhlIEJsdWV0b290aCBTSUcNCj4gDQo+IFRoaXMgYWxsb3dzIHVz IHRvIGVsaW1pbmF0ZSBWZW5kb3JQdWJsaXNoKCkgbWV0aG9kLg0KPiANCj4gKioqKioqKioqIHYz ICoqKioqKioqKioqKg0KPiBBZGRlZCBWZW5kb3Igc3BlY2lmaWMgY2xhcml0eSB0byB0aGUgUHVi bGlzaCgpIG1ldGhvZCBkZXNjcmlwdGlvbiBpbg0KPiBtZXNoLWFwaS50eHQsIHNpbmNlIFZlbmRv clB1Ymxpc2goKSBpcyByZW1vdmVkLg0KPiANCj4gDQo+IEluZ2EgU3RvdGxhbmQgKDQpOg0KPiAg IGRvYy9tZXNoLWFwaTogQWRkICJvcHRpb25zIiBkaWN0aW9uYXJ5IHRvIFNlbmQvUHVibGlzaA0K PiAgIG1lc2g6IEhhbmRsZSAib3B0aW9ucyIgZGljdGlvbmFyeSBpbiBTZW5kL1B1Ymxpc2ggbWV0 aG9kcw0KPiAgIHRvb2xzL21lc2gtY2ZnbGllbnQ6IEFkZCAib3B0aW9ucyIgdG8gU2VuZC9EZXZL ZXlTZW5kDQo+ICAgdGVzdC90ZXN0LW1lc2g6IEFkZCAib3B0aW9ucyIgdG8gU2VuZC9QdWJsaXNo DQo+IA0KPiAgZG9jL21lc2gtYXBpLnR4dCAgICAgICB8ICA2MCArKysrKysrKysrLS0tLS0tLS0N Cj4gIG1lc2gvY2ZnbW9kLXNlcnZlci5jICAgfCAgIDIgKy0NCj4gIG1lc2gvbW9kZWwuYyAgICAg ICAgICAgfCAgIDYgKy0NCj4gIG1lc2gvbW9kZWwuaCAgICAgICAgICAgfCAgIDkgKy0tDQo+ICBt ZXNoL25vZGUuYyAgICAgICAgICAgIHwgMTQwICsrKysrKysrKysrKysrKysrKysrLS0tLS0tLS0t LS0tLS0tLS0tLS0tDQo+ICB0ZXN0L3Rlc3QtbWVzaCAgICAgICAgIHwgIDExICsrKy0NCj4gIHRv b2xzL21lc2gtY2ZnY2xpZW50LmMgfCAgIDggKysrDQo+ICA3IGZpbGVzIGNoYW5nZWQsIDEyNyBp bnNlcnRpb25zKCspLCAxMDkgZGVsZXRpb25zKC0pDQo+IA0K Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MJPjA/+WRl8ETgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 19:08:15 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ACtVAv+WRl98gwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 19:08:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9634DA21F5; Wed, 26 Aug 2020 19:08:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbgHZRIH convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 13:08:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:36738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726783AbgHZRIF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 13:08:05 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Wed, 26 Aug 2020 17:08:02 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: b.razmjoo@protonmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-60824-62941-n5QjlI6S9N@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.03 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9634DA21F5 X-Rspamd-UID: 32da50 https://bugzilla.kernel.org/show_bug.cgi?id=60824 Babak (b.razmjoo@protonmail.com) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |b.razmjoo@protonmail.com --- Comment #146 from Babak (b.razmjoo@protonmail.com) --- Hi everyone, I have bought a dongle just like Andres's in https://bugzilla.kernel.org/show_bug.cgi?id=60824#c81 and my system has problems activating it. This is my system: Linux localhost.localdomain 5.7.9-200.fc32.x86_64 #1 SMP Fri Jul 17 16:23:37 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux These are result of running commands recommended here: $ hciconfig -a hci0: Type: Primary Bus: USB BD Address: 00:1A:7D:DA:71:10 ACL MTU: 640:2 SCO MTU: 64:8 DOWN RX bytes:538 acl:0 sco:0 events:25 errors:0 TX bytes:338 acl:0 sco:0 commands:25 errors:0 Features: 0xff 0xff 0x8f 0xfa 0xdb 0xff 0x5b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT Local Version Information from btmon output: < HCI Command: Read Local Version Information (0x04|0x0001) plen 0 #5 [hci0] 3.570144 > HCI Event: Command Complete (0x0e) plen 12 > #6 [hci0] 3.572090 Read Local Version Information (0x04|0x0001) ncmd 1 Status: Success (0x00) HCI version: Bluetooth 4.0 (0x06) - Revision 12576 (0x3120) LMP version: Bluetooth 4.0 (0x06) - Subversion 8891 (0x22bb) Manufacturer: Cambridge Silicon Radio (10) hcidump -X resulted in this : https://bugzilla.kernel.org/attachment.cgi?id=292177 btmon -w : https://bugzilla.kernel.org/attachment.cgi?id=292179 lsusb : https://bugzilla.kernel.org/attachment.cgi?id=292181 thanks for the great work -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kE+7GU+bRl/0uwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 19:26:39 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QGURF0+bRl+dmwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 19:26:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 808EDA24FC; Wed, 26 Aug 2020 19:26:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726971AbgHZR0e (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 13:26:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbgHZR0c (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 13:26:32 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EFE6C061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 10:26:32 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id o64so2669887qkb.10 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 10:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=R6Td+eEsQ4sKJ7qKWIutZh8XijaZ4gH+hXQd/s0GbWs=; b=OrLmiZ74Fyim8TquXRIIBHBl3qXIxOqFboo3CmWQY+WuIpMqjitN0/D8j2gdGF/LyG u8xqqD9jkPRPMLkIzAbM4s79N0Fo/Xgds11UKC1gb7MBgPd1mMT4Zg6B/7Fzh+bC0B7n V+v0Ee1nqBhJfMZ00Mwwh0LBu3w/VHKAyYn+6tylRhaLPHf7j+uWsgxG1rBANqFLefoK EV0U7pr+BCjTa5gPqvLL1fbimpThmqb9VGAVmvFimPcm3DXVxoaGH1kfFP/DXnhUsh7O juLqsB4Dod0pkAbDtYZT+i1GGkAjetihSmcZJF9idMMzZVOHeyAFCdU9GfuX1ahUSDvl rolw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=R6Td+eEsQ4sKJ7qKWIutZh8XijaZ4gH+hXQd/s0GbWs=; b=QrNyQQpeoWVzEJOTdhOHTeR4JBO6yVmA1ZhCNAJbtwKhWfnLWlSFoGV5mvgAwI3Q+T GfzsAr/yr+hbCbcY/mgCYLVv6AevLrUvWK/2mtEhZB3hK0/nEbuouU9ZsQs6Wm3UVZfq i5zjtl5vNNVuE3kRMUzeZ1pM3H+srglTb0yTbNg4/afuDayBeffk+kZnDTwnA5Kel8d6 pJmYMOKThp42JjvhaHXdz43wOp0DKAhrJlQvKEbIa36+waDDBeTrDIrvLM9MXwlyV0AI ApRkXRgH0lMxNkXzywNs4sINE5jMPNDKWJOctbyK33NvXSfgZAaj3b5++mOie19UksMk pWYg== X-Gm-Message-State: AOAM5334laJzHw37MiqEwaoIT3jMgLaLS1LJGNxE03/nkqGumijK+Q1P 03aZqEC2UAX96IJmbVDD+dd8tJBNnKKVqw== X-Google-Smtp-Source: ABdhPJyXnvo3ikWoiW/ycXQxEaHjiGpxFlQuH0bmLzSNVncMtQglASEahyi980BqL5zrTHwk0lwMOQ== X-Received: by 2002:a37:680e:: with SMTP id d14mr6100066qkc.234.1598462790527; Wed, 26 Aug 2020 10:26:30 -0700 (PDT) Received: from [172.17.0.2] ([20.36.161.243]) by smtp.gmail.com with ESMTPSA id v202sm2169710qka.5.2020.08.26.10.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 10:26:30 -0700 (PDT) Message-ID: <5f469b46.1c69fb81.4207.bfcf@mx.google.com> Date: Wed, 26 Aug 2020 10:26:30 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3014515499409848566==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, brian.gix@intel.com Subject: RE: [BlueZ,v3,1/4] doc/mesh-api: Add "options" dictionary to Send/Publish Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200826165420.563822-2-brian.gix@intel.com> References: <20200826165420.563822-2-brian.gix@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.87 / 15.00 / 200.00 X-Rspamd-Queue-Id: 808EDA24FC X-Rspamd-UID: 62a579 --===============3014515499409848566== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 8: B3 Line contains hard tab characters (\t): " one-segment messages" --- Regards, Linux Bluetooth --===============3014515499409848566==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2P6kKQGfRl8MwgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 19:42:25 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8IbtJwGfRl9S4QAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 19:42:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2D85D42116; Wed, 26 Aug 2020 19:42:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726845AbgHZRmI (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 13:42:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbgHZRlz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 13:41:55 -0400 Received: from mail-vk1-xa41.google.com (mail-vk1-xa41.google.com [IPv6:2607:f8b0:4864:20::a41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFA75C061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 10:41:40 -0700 (PDT) Received: by mail-vk1-xa41.google.com with SMTP id i20so625658vkk.2 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 10:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kjbPm9wZL1OZBXAXLIVEJy8Z8Xq+x7W89UufjmoD5cc=; b=AQOOyeeK8alwcxLeR/dLIDVKm7ZvvWLhUZAgkI8CA5VOpkBPXXOS9Fsuz4zQbOFvYo z8iFhU3JVfpW7OQDa3WE50aJrCQljZFXBwFfFrYTrnZHMibaZvrqb/+KIb5reKV0cxoP Rwg9db3dn4WgX2IpyWun8dcp1ICKQDcXEkK/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kjbPm9wZL1OZBXAXLIVEJy8Z8Xq+x7W89UufjmoD5cc=; b=IK93YmqsLLWux5Xf9SpODGZesPTT1YyQOlCKtngFfifSq6U7eqipoTrT0EBbVWkczh DNfjf1tUH0xzpPzfT80yN8ikj0ZHvRyY21ZwNwkL36WGfuXORssSDbK4Flmi0I1WaBOl iEucBSPiyIQ5DG2xw9bPd4KCQe6U9ysSzCFxr9Gfxvmzx5hX3pMsrgFYB2V5BV2dqoe5 flW/eg7gPJOb/z+Z7GjiUM310HaM19Mp/0L4igPFkMmLxBwHS9DlT/6ICFnyTC1cqJgG oz4CJMXNLMWnAZPF9hrDNOH/NpIlNnpxOOxDlJcps30AoRPkgw38nnWPWC4BxVMK+2Pt YNRQ== X-Gm-Message-State: AOAM532JcmuPSqajTZ6n0NmUzscKVj16zJ7HWCv/svli9NlHvxExmubx 5wRbt8pauXrXew5dxPVtrg4xTHw9DlyyLf/sh6kHhQ== X-Google-Smtp-Source: ABdhPJykxK1jAgdMEMNI+OUnJP6yopETkGlrnY6VbCrN+la3ABTQXvoCOl+hmbNNfgNkMgZUQomhrrdt4p1YSMbGApc= X-Received: by 2002:a1f:7c45:: with SMTP id x66mr10122587vkc.53.1598463699769; Wed, 26 Aug 2020 10:41:39 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> In-Reply-To: <20200818232822.1645054-1-abhishekpandit@chromium.org> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Wed, 26 Aug 2020 10:41:28 -0700 Message-ID: <CANFp7mWqT1mO0OcJAt4AycTgFLz22p7zyRGjR1Hvj4bJmHHsTw@mail.gmail.com> Subject: Re: [Bluez PATCH v2 0/3] adapter: Reconnect audio when resuming from suspend To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>, Marcel Holtmann <marcel@holtmann.org> Cc: ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.06 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2D85D42116 X-Rspamd-UID: b117e8 Hi Luiz, Could you PTAL at this v2 patch series. I refactored the audio reconnect to use the policy plugin instead of doing the reconnect as part of the adapter logic, as requested. Thanks Abhishek On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > > Hi Luiz and Marcel, > > This is a quality of life improvement for the behavior of audio devices > during system suspend. This depends on a kernel change that emits > suspend/resume events: > > https://patchwork.kernel.org/project/bluetooth/list/?series=325771 > > Right now, audio devices will be disconnected as part of suspend but > won't be reconnected when the system resumes without user interaction. > This is annoying to some users as it causes an interruption to their > normal work flow. > > This change reconnects audio devices that were disconnected for suspend > using the following logic: > > * Register a callback for controller resume in the policy plugin. > * In the device disconnect callback, mark any devices with the A2DP > service uuid for reconnect on resume after a delay. > * In the controller resume callback, queue any policy items that are > marked to reconnect on resume for connection with the > ReconnectAudioDelay value (default = 5s for Wi-Fi coexistence). > > A reconnect is only attempted once after the controller resumes and the > delay between resume and reconnect is configurable via the > ReconnectAudioDelay key in the Policy settings. The 5s delay was chosen > arbitrarily and I think anywhere up to 10s is probably ok. A longer > delay is better to account for spurious wakeups and Wi-Fi reconnection > time (avoiding any co-ex issues) at the downside of reconnection speed. > > Here are the tests I have done with this: > - Single suspend and verified the headphones reconnect > - Suspend stress test for 25 iterations and verify both Wi-Fi and > Bluetooth audio reconnect on resume. (Ran with wake minimum time of > 10s) > - Suspend test with wake time < 5s to verify that BT reconnect isn't > attempted. Ran 5 iterations with low wake time and then let it stay > awake to confirm reconnect finally completed after 5s+ wake time. > - Suspend test with wake time between 3s - 6s. Ran with 5 iterations and > verified it wasn't connected at the end. A connection attempt was > made but not completed due to suspend. A reconnect attempt was not > made afterwards, which is by design. > > Luiz@ Marcel@: Does this sound ok (give up after an attempt)? > > I've tested this on a Pixelbook Go (AC-9260 controller) and HP > Chromebook 14a (RTL8822CE controller) with GID6B headset. > > I've also tested this with the Pixel Buds 2. These earbuds actually > reconnect automatically to the Chromebook (even without this policy > change) and I verified that the new changes don't break the reconnection > mechanism. > > Thanks > Abhishek > > > Changes in v2: > - Refactored to use policy instead of connecting directly in adapter > > Abhishek Pandit-Subedi (3): > mgmt: Add controller suspend and resume events > monitor: Add btmon support for Suspend and Resume events > policy: Reconnect audio on controller resume > > lib/mgmt.h | 14 +++++++++++ > monitor/packet.c | 55 +++++++++++++++++++++++++++++++++++++++++ > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > src/adapter.h | 6 +++++ > src/main.c | 1 + > src/main.conf | 9 +++++++ > 7 files changed, 190 insertions(+), 4 deletions(-) > > -- > 2.28.0.297.g1956fa8f8d-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YE1cNxTCRl+VXwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 22:12:04 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id KKy0NRTCRl/wGgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 22:12:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DDC3C420CC; Wed, 26 Aug 2020 22:12:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbgHZUL7 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 16:11:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbgHZUL6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 16:11:58 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AF1CC061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:11:58 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id p138so4294840yba.12 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:11:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=5f/lN0/70bYXYJZSh5TJQuXrKMG7Gi5D2DcObKSQfRQ=; b=qzvr/acgzGXq4XXO3xIy8JzkmTbtIVpkmg18jniacjglkZOwEowJB5WHQx0h572jJL xAvBM+343LMsPZ+WhBt+xd6zDgDeGTfl1VRnW3cgLpf+AA1wzUT32CD4R9RBUu1ENK/i AOrVzpVehNQuy5jIAriVFMid/bzMsDEbBpVm4vbM3Ynneswhmip1CUk388WJVkkzLaSc VUpT2zlNjPOlg39b6SrhirHEilmZQpKIaW1GVfUDpKYqSKn2LIu28dlgZJI0OvDb/pT9 K4qXwZmMJpSPmEmDA6Zl5GqT2LC4KZXfwrhkAhbqdozjftElEbrg0yRhH75SRk95J0r5 i/8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=5f/lN0/70bYXYJZSh5TJQuXrKMG7Gi5D2DcObKSQfRQ=; b=nZz1lw+64nPAyyDqTaILzUNAXG1IkftrW/cHICyzRGB4SbZ6wo5ryHFuC3BhbxqoOM W1xpu7wVOvO6VNFyapzaI4M3efCYmawtQ3tXi1w1/TvLfc//podxLsbgIIQ214IG6kn/ eRlkOiTBpISwqUljzccUQUBDAshmtvFquQ/vlEtQyLJlQzefmMLRjawqGGd1HuOR3bZH Dj24cbv1ksqqasGzHTCpIInuk9cZ8jnLeMhkXMXV6QrMQasZRSr6bM+dYr/PxTQ963Wi cgHKjUUY5bOqp4Hu8PKvcaOFDFivzMlRYzU0bH01jfD0vjpZ1v2D6IuWa5t5Mbfjxme8 lIlA== X-Gm-Message-State: AOAM532hjew0i0iwayolBWVKwSq5v9aUy0132euRYS0tnqpgOmnJXf55 pGCjWGbZKXo+P+jPDotnpINzbpZhy6vqUUOiZRPmS6D5cTTd9JWY7KNteXWGe6FLRoqjTT2beqN gJPk1Y/NJAsVGOMrYABl8PFlOIJupBkNEhbqCjbnsIMANumKEUji5XOd5AFikk/WL5Mnoto2seo MCSqd7XTaI4ctrTcwG X-Google-Smtp-Source: ABdhPJwGuuu1mPYxTn77xWiXmzXF5OjbPRy6ojJ21ttBG0W7k9W/boOjKj5LE9e74xoDBcAD7nG5cH5pEgg1JJtlBl7I X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:6d86:: with SMTP id i128mr10244044ybc.61.1598472716974; Wed, 26 Aug 2020 13:11:56 -0700 (PDT) Date: Wed, 26 Aug 2020 13:11:44 -0700 Message-Id: <20200826201147.1908411-1-danielwinkler@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [Bluez PATCH v1 0/3] Expose extended adv feature support via bluez API From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 4.41 / 15.00 / 200.00 X-Rspamd-Queue-Id: DDC3C420CC X-Rspamd-UID: 3835bc Hi Maintainers, This change adds a SupportedFeatures member to the LEAdvertisingManager interface, which allows us to expose support for hardware offloading and setting TX power on advertisements. Best, Daniel Daniel Winkler (3): PRE_UPSTREAM: advertising: Add SupportedFeatures to LEAdvertisingManager1 PRE_UPSTREAM: advertising: Add adv SupportedFeatures to bluetoothctl PRE_UPSTREAM: advertising: Add adv SupportedFeatures to doc client/main.c | 1 + doc/advertising-api.txt | 18 +++++++++++++ lib/mgmt.h | 2 ++ src/advertising.c | 56 +++++++++++++++++++++++++++++++++++++++-- 4 files changed, 75 insertions(+), 2 deletions(-) -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id hN+9MLThRl+1/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 00:27:00 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id SCiELrThRl9+QAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 00:27:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6479BA1676; Thu, 27 Aug 2020 00:26:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726929AbgHZW0z (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 18:26:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbgHZW0r (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 18:26:47 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74942C061757 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 15:26:46 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id q93so1654053pjq.0 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 15:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=PkRfetQcp2SyPXpao4+ZMmtYtLe8fTRZhlCz7rJNi6U=; b=Z8h3jmnpWF7n+FdysrKDsbSu7wBGc3eoFbM9dho9msL4PB9dDMXlpeV0H31eSQU1b5 r3Aa61QUvEgghcmBcRl7X0J61lByqkSl+w6XEBC6D9t5MhDazODWG9IPN4xaXe/bqFz8 qBNNeC18oZI1SgMDRENNkDP44pLgtiWwwXtr4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=PkRfetQcp2SyPXpao4+ZMmtYtLe8fTRZhlCz7rJNi6U=; b=nJJ/iTevoB1xKly+s6VsR/LmNOtIt/vyFYbVWmWSz36036saZLCbscvv2eP6A8cAl3 59fDUhHQ4okEGyYBshgP1oQONP//v02kjyaltd7T0TpHX6/dqSiy+wvgxChWdKXfAxhg NEHowJe3xay9K7nJ3vYL+1gP6sE2PFC28v5+rid12syS7gAORuPzPn394WKJfqWbl9d8 hcM5hdsaiDVwckunB2ITUlXlG9E5Mw2RGNmrIv2bgDIWbW6GNCrNAcUSgGv0DElH2cXq TtsD/FiA6VtLRUO3YApFl82Nfy3nJ7VuFjdZfHZttd3DU6RxTbgsNRpj+qXu+oiO6AxN 02Zg== X-Gm-Message-State: AOAM533dDcR6uk4dpXLUQ+mRF33rYkC64KDHNbcXO5l7cH8HMdzqIrRE LKRYLfWzFD2MUoITXhQZKX/d+Q== X-Google-Smtp-Source: ABdhPJwtq/aSnkaRCd+AVsIZIusn3TQlRtKEGYCH0S1le5PKTs+SyjZKUXXLlrqQjBHKw/Nd6anXZg== X-Received: by 2002:a17:90b:3ce:: with SMTP id go14mr2017340pjb.162.1598480805822; Wed, 26 Aug 2020 15:26:45 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id x19sm204076pfq.43.2020.08.26.15.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 15:26:45 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH] Bluetooth: Clear suspend tasks on unregister Date: Wed, 26 Aug 2020 15:26:39 -0700 Message-Id: <20200826152623.1.I24fb6cc377d03d64d74f83cec748afd12ee33e37@changeid> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6479BA1676 X-Rspamd-UID: e1a310 While unregistering, make sure to clear the suspend tasks before cancelling the work. If the unregister is called during resume from suspend, this will unnecessarily add 2s to the resume time otherwise. Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- This was discovered with RT8822CE using the btusb driver. This chipset will reset on resume during system suspend and was unnecessarily adding 2s to every resume. Since we're unregistering anyway, there's no harm in just clearing the pending events. net/bluetooth/hci_core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 68bfe57b66250f..ed4cb3479433c0 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3442,6 +3442,16 @@ void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, } } +static void hci_suspend_clear_tasks(struct hci_dev *hdev) +{ + int i; + + for (i = 0; i < __SUSPEND_NUM_TASKS; ++i) + clear_bit(i, hdev->suspend_tasks); + + wake_up(&hdev->suspend_wait_q); +} + static int hci_suspend_wait_event(struct hci_dev *hdev) { #define WAKE_COND \ @@ -3785,6 +3795,7 @@ void hci_unregister_dev(struct hci_dev *hdev) cancel_work_sync(&hdev->power_on); unregister_pm_notifier(&hdev->suspend_notifier); + hci_suspend_clear_tasks(hdev); cancel_work_sync(&hdev->suspend_prepare); hci_dev_do_close(hdev); -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SJINMYvmRl9qEAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 00:47:39 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id cC5uL4vmRl+KzgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 00:47:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CC660A1487; Thu, 27 Aug 2020 00:47:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726128AbgHZWrd (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 18:47:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725980AbgHZWr3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 18:47:29 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CE89C061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 15:47:29 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id kx11so1572763pjb.5 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 15:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BTV2RlnMnYfEfU+n6J7LxKvHGWuogRfWUjxo9oBtDWg=; b=hunhi80imRT79pQZiQ6L3lKxUljVv11uqwzOckeYlSW2xC/1XGMNrtCJoldSMClPz6 LLho8FdrvVzbnWU6iQtwlGYc5JfAhX03Cz8UiUfxOW/JAs04Gjx6L1onY5EalO1ukw5S lRgunltwr0SCkQ5/7jkBVzavGV8Nkhvy6GTGE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BTV2RlnMnYfEfU+n6J7LxKvHGWuogRfWUjxo9oBtDWg=; b=r24eNZIbruMbq43dplZ2QWp2R5iZRinsdyaes0VV0ODkHD6irAuv96ApiSrYalVA2o EOk7Yqyz9UkxQGieMe+T4Z2LfSBE991KmiRDh0+pWYT8K3MOf7usFyfeh3hj4wnpMGCw xNLi0ZpEYi7A4DlAG87aCtUTv2Ml6mKoIo8bREtXKDLJIB2YmjCHIJmzOXmMw12WsFSJ 8jj7IDmCEWtUL8YUe9cZ5P6M7D7k8TCMGPNoxhjRPZTlLvAC+Oom+Sfbk6Jl/S4OCWUi v0y5s2RTw4QUWRZKqI9gEFclIU33IeK7vqeP4Ca7TxG+yJ+IY9QRb7Znt8oJggbSRfXA s9Jg== X-Gm-Message-State: AOAM530ZsQDDfKJ5TfjtNyoJ894RafhtOCuJ/sAAvq58qEjG9Sr/nsku LULOxvb8UH5FyQzyoBzrx1hdtA== X-Google-Smtp-Source: ABdhPJzp3CSsjDcKg/29/X87IL09PfgN+zVZmYuop0NFK3+uXle3rQu5a8WZU1dDdQPrIdlRbbCi9g== X-Received: by 2002:a17:90a:8817:: with SMTP id s23mr8065795pjn.158.1598482048667; Wed, 26 Aug 2020 15:47:28 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id s10sm123093pjl.37.2020.08.26.15.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 15:47:28 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [PATCH] Bluetooth: Clear suspend tasks on unregister Date: Wed, 26 Aug 2020 15:47:22 -0700 Message-Id: <20200826154719.1.I24fb6cc377d03d64d74f83cec748afd12ee33e37@changeid> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: CC660A1487 X-Rspamd-UID: 30fe3c While unregistering, make sure to clear the suspend tasks before cancelling the work. If the unregister is called during resume from suspend, this will unnecessarily add 2s to the resume time otherwise. Fixes: 4e8c36c3b0d73d (Bluetooth: Fix suspend notifier race) Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- This was discovered with RT8822CE using the btusb driver. This chipset will reset on resume during system suspend and was unnecessarily adding 2s to every resume. Since we're unregistering anyway, there's no harm in just clearing the pending events. net/bluetooth/hci_core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 68bfe57b66250f..ed4cb3479433c0 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3442,6 +3442,16 @@ void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, } } +static void hci_suspend_clear_tasks(struct hci_dev *hdev) +{ + int i; + + for (i = 0; i < __SUSPEND_NUM_TASKS; ++i) + clear_bit(i, hdev->suspend_tasks); + + wake_up(&hdev->suspend_wait_q); +} + static int hci_suspend_wait_event(struct hci_dev *hdev) { #define WAKE_COND \ @@ -3785,6 +3795,7 @@ void hci_unregister_dev(struct hci_dev *hdev) cancel_work_sync(&hdev->power_on); unregister_pm_notifier(&hdev->suspend_notifier); + hci_suspend_clear_tasks(hdev); cancel_work_sync(&hdev->suspend_prepare); hci_dev_do_close(hdev); -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YEt2EMXmRl/wDAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 00:48:37 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id yJXUDsXmRl80swAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 00:48:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 52BC3420C9; Thu, 27 Aug 2020 00:48:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726838AbgHZWsW (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 18:48:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726804AbgHZWsT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 18:48:19 -0400 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7DD7C061756 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 15:48:19 -0700 (PDT) Received: by mail-vs1-xe42.google.com with SMTP id a1so1843805vsp.4 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 15:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=i1qY92/PwTT0Gk/j2QImlQ1lTtyrii53vnwrnB6jcwg=; b=Kr78kDPV8rShI6VR1rKATyA8p91nltiq2JBgff3egxahVAx6vOdWahUWS7PaMDogy/ U11DctEM0UVzdLpxGP31NOt+20skpFztsz7sBCX9vRNcPO+pIcgjNKmGR5S6Y4xHdRnI jpW1+OvpxWraR3wlY+RVYtZkR4YJCAeaW/7Ok= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=i1qY92/PwTT0Gk/j2QImlQ1lTtyrii53vnwrnB6jcwg=; b=XmBcrjBRx795RuMU9KxVgluOqS2y/aMJIZC93WocOdbwQguY2uU94WvlPXO8kAAiaW AStwBjaOWtx77vBLMk1gHCrJokBk064yvCnTARau/9vNkQy1yoNlLu36P1/C1E5d0Tt3 J5N4OTL67rwAs5bl7CWLAER1+G9k1BHR3C5ur/8ZHfwU/1dgaYPeocxLmQqy5ViurjkD KiHdEr9abdFypBEs3iTMLu+26zgdfyF+bbErdY4Mllg6osjcImK1lne9v7hLR8aZqKV3 DFOsELGURb8VQ/0XWURW6GYOQPBbtfstSB80csaievYfpFcJQpmwfCxEnRa65YOF6Oww hcnQ== X-Gm-Message-State: AOAM532wVlnu1ed+dCHIVuwgLU6yAgjB3hydwIaXWH1DgiwBPHwJ1rkj /BymTWW5Bpzmq+K/q5Yun3cBoeiaaIpkYcXJ5UudNg== X-Google-Smtp-Source: ABdhPJxdEd1ugfMHWrcNXgWBRatmklOZ31zN9s8sOVMobrAoeawvvRQ8HIDcXT6WLyulfcLzFc+J1AjPuMxMw3XLbS0= X-Received: by 2002:a05:6102:2042:: with SMTP id q2mr7894641vsr.209.1598482099029; Wed, 26 Aug 2020 15:48:19 -0700 (PDT) MIME-Version: 1.0 References: <20200826152623.1.I24fb6cc377d03d64d74f83cec748afd12ee33e37@changeid> In-Reply-To: <20200826152623.1.I24fb6cc377d03d64d74f83cec748afd12ee33e37@changeid> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Wed, 26 Aug 2020 15:48:05 -0700 Message-ID: <CANFp7mVR5mWpTNOCzVqma5dL26nWLFCYRL9xBpE72ywpj8yo1Q@mail.gmail.com> Subject: Re: [PATCH] Bluetooth: Clear suspend tasks on unregister To: Marcel Holtmann <marcel@holtmann.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org> Cc: ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev <netdev@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 52BC3420C9 X-Rspamd-UID: d257d5 Please disregard this earlier email without the Fixes tag. On Wed, Aug 26, 2020 at 3:26 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > While unregistering, make sure to clear the suspend tasks before > cancelling the work. If the unregister is called during resume from > suspend, this will unnecessarily add 2s to the resume time otherwise. > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > This was discovered with RT8822CE using the btusb driver. This chipset > will reset on resume during system suspend and was unnecessarily adding > 2s to every resume. Since we're unregistering anyway, there's no harm in > just clearing the pending events. > > net/bluetooth/hci_core.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index 68bfe57b66250f..ed4cb3479433c0 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -3442,6 +3442,16 @@ void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, > } > } > > +static void hci_suspend_clear_tasks(struct hci_dev *hdev) > +{ > + int i; > + > + for (i = 0; i < __SUSPEND_NUM_TASKS; ++i) > + clear_bit(i, hdev->suspend_tasks); > + > + wake_up(&hdev->suspend_wait_q); > +} > + > static int hci_suspend_wait_event(struct hci_dev *hdev) > { > #define WAKE_COND \ > @@ -3785,6 +3795,7 @@ void hci_unregister_dev(struct hci_dev *hdev) > cancel_work_sync(&hdev->power_on); > > unregister_pm_notifier(&hdev->suspend_notifier); > + hci_suspend_clear_tasks(hdev); > cancel_work_sync(&hdev->suspend_prepare); > > hci_dev_do_close(hdev); > -- > 2.28.0.297.g1956fa8f8d-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SEAWFtpQR18aEAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 08:21:14 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id sGWPFNpQR18OkwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 08:21:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 81950A1487; Thu, 27 Aug 2020 08:21:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727115AbgH0GVG (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 27 Aug 2020 02:21:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbgH0GVD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 27 Aug 2020 02:21:03 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E300C06125E for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 23:21:03 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id t7so3553646otp.0 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 23:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+yCzYVDGjFXRToO2nHPXDmKIWs/zZ6jwx+WQx1MXFe8=; b=K2v+dMMkJVR13irqneSrBJyQFysfJa007wpdRNBmRw3vkV6tuGYnSB3nkGB8SFFUty l+BqdailEtGSu9TdIbeiwLYAJ7r6McHtJ5ft7OAJJQQ/BodaMOEr1KPbaN1nDcnZTONs wqYCdJqsnu0lXnwsRQ9JJjo/wUqjXmsCs7D2ATghTvatusmwUI95AAOR2ZntNVMOFUUW rXdjJYgqXqijTAxwQ5wcQN9YHK9or9JIpSrzQB6KCFz8Hzj61E77Szm34NY2BamFGae6 6PM75qnjd8EMBRxaQ3G/9u9AMtjb0FayJ+Cm7SOCA6ryyDLV9VXA7UsifRMJfZvDstFo al+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+yCzYVDGjFXRToO2nHPXDmKIWs/zZ6jwx+WQx1MXFe8=; b=fbO8y8BhPe/Z/bcgMBExV8lnQ01mKmDFZq75Ml2xQvn6qvq/EkGSmRfT20doAkDoHg +7m+6cnFd4ZUpWjzVTHDnENmYMwXO9nzMUrZjh+4JPP7Yj4pykbeKJKTYbkUP6rtlGlK N6sri6z2vYh2rW2GjMOVEeBucM2Cget8KNN29sPcM4TXrWJXumCV26AUujwfqu1/5CLe J8dzHV7wTZAM17W6KvrHYA3uYUn0AvAgjMoxqep1FUbtCUrVdNkDE2pGHJdiahf+utMQ jvPh7CNU4GbgX8Wkm8PaDCQNd31IrzHbGDg+oLnQ8/PaazINUDKTktfmxr/JLOjL8GhA Lx3A== X-Gm-Message-State: AOAM5311y/BLO2wXDgI3+IfsWoGmh8jYV9VhR9vbniTqnzA0RXUCF+Fq QJFRe7J3RNADd/pr3YBtFx4BupR7v3eGhsYuNiOCeHTW X-Google-Smtp-Source: ABdhPJyNvFweq8RStXojvIqAClTpHCRj2xSHsGhS+uEehVrIhX7yKFJytq2SodgIeUZ/K1pXIUOtfbHX29+eNH/noP8= X-Received: by 2002:a9d:429:: with SMTP id 38mr11536777otc.88.1598509260420; Wed, 26 Aug 2020 23:21:00 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> <CANFp7mWqT1mO0OcJAt4AycTgFLz22p7zyRGjR1Hvj4bJmHHsTw@mail.gmail.com> In-Reply-To: <CANFp7mWqT1mO0OcJAt4AycTgFLz22p7zyRGjR1Hvj4bJmHHsTw@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 26 Aug 2020 23:20:49 -0700 Message-ID: <CABBYNZLmfWWBYZjHDkHmMpzYC02zFpWMV_xAiD1pK3cc09JwSA@mail.gmail.com> Subject: Re: [Bluez PATCH v2 0/3] adapter: Reconnect audio when resuming from suspend To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 81950A1487 X-Rspamd-UID: 75b94c Hi Abhishek, On Wed, Aug 26, 2020 at 10:41 AM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Hi Luiz, > > Could you PTAL at this v2 patch series. I refactored the audio > reconnect to use the policy plugin instead of doing the reconnect as > part of the adapter logic, as requested. > > Thanks > Abhishek > > On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > > > Hi Luiz and Marcel, > > > > This is a quality of life improvement for the behavior of audio devices > > during system suspend. This depends on a kernel change that emits > > suspend/resume events: > > > > https://patchwork.kernel.org/project/bluetooth/list/?series=325771 So we could not just use the disconnect reason like I suggested? > > Right now, audio devices will be disconnected as part of suspend but > > won't be reconnected when the system resumes without user interaction. > > This is annoying to some users as it causes an interruption to their > > normal work flow. > > > > This change reconnects audio devices that were disconnected for suspend > > using the following logic: > > > > * Register a callback for controller resume in the policy plugin. > > * In the device disconnect callback, mark any devices with the A2DP > > service uuid for reconnect on resume after a delay. > > * In the controller resume callback, queue any policy items that are > > marked to reconnect on resume for connection with the > > ReconnectAudioDelay value (default = 5s for Wi-Fi coexistence). Something like ResumeDelay would probably be better. > > A reconnect is only attempted once after the controller resumes and the > > delay between resume and reconnect is configurable via the > > ReconnectAudioDelay key in the Policy settings. The 5s delay was chosen > > arbitrarily and I think anywhere up to 10s is probably ok. A longer > > delay is better to account for spurious wakeups and Wi-Fi reconnection > > time (avoiding any co-ex issues) at the downside of reconnection speed. I would keep the same logic as out of range so the platforms can customize the number of attempts. > > Here are the tests I have done with this: > > - Single suspend and verified the headphones reconnect > > - Suspend stress test for 25 iterations and verify both Wi-Fi and > > Bluetooth audio reconnect on resume. (Ran with wake minimum time of > > 10s) > > - Suspend test with wake time < 5s to verify that BT reconnect isn't > > attempted. Ran 5 iterations with low wake time and then let it stay > > awake to confirm reconnect finally completed after 5s+ wake time. > > - Suspend test with wake time between 3s - 6s. Ran with 5 iterations and > > verified it wasn't connected at the end. A connection attempt was > > made but not completed due to suspend. A reconnect attempt was not > > made afterwards, which is by design. > > > > Luiz@ Marcel@: Does this sound ok (give up after an attempt)? > > > > I've tested this on a Pixelbook Go (AC-9260 controller) and HP > > Chromebook 14a (RTL8822CE controller) with GID6B headset. > > > > I've also tested this with the Pixel Buds 2. These earbuds actually > > reconnect automatically to the Chromebook (even without this policy > > change) and I verified that the new changes don't break the reconnection > > mechanism. > > > > Thanks > > Abhishek > > > > > > Changes in v2: > > - Refactored to use policy instead of connecting directly in adapter > > > > Abhishek Pandit-Subedi (3): > > mgmt: Add controller suspend and resume events > > monitor: Add btmon support for Suspend and Resume events > > policy: Reconnect audio on controller resume > > > > lib/mgmt.h | 14 +++++++++++ > > monitor/packet.c | 55 +++++++++++++++++++++++++++++++++++++++++ > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > > src/adapter.h | 6 +++++ > > src/main.c | 1 + > > src/main.conf | 9 +++++++ > > 7 files changed, 190 insertions(+), 4 deletions(-) > > > > -- > > 2.28.0.297.g1956fa8f8d-goog > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MNTsGJ1TR18aEAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 08:33:01 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CMEfF51TR1/wcgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 08:33:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F3202A1200; Thu, 27 Aug 2020 08:32:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726291AbgH0Gcz (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 27 Aug 2020 02:32:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726123AbgH0Gcy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 27 Aug 2020 02:32:54 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBB35C061261 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 23:32:54 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id t7so3572037otp.0 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 23:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hYbvTE+IvybYcQAg7PjeWF64QYN7nvX4MCeoT/eY1hA=; b=JtwTb5wx2s6wyUBhi8PexuWcDDG7EhfxsQEcB0Xr2bSnwyQPAfqFS4MeouD2Nr+3Ok azuPWv+pbX8xiygEtOJW9lVpg6aujKC5YOG65uga/hVfnmuEJW2XcGezofXnfH0+JMc7 NAc4rz10lSpZ+vTB26M6ivj1Wf9jA3u7LlmTQVLiTb+IZnapaHfewqyGwDWSuMW1IYWe PJAU3q/JMZmb3k5S6g1U2Zn0l2K+mAeyLmdQg7Q4p7pWFhTd8HaAoHaDLoImfi5Qp/mc JGnc8FvGJrDux+jrP5uFRpqu39he8ToWFVT6biL5gvQ3xcuJUa3quLyLACfbNVDO+cJ2 ezMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hYbvTE+IvybYcQAg7PjeWF64QYN7nvX4MCeoT/eY1hA=; b=dP7DNf5Fg2VjzRYQkxrVWR/iatr7SVR7Xlxb50v1mXQg7su54p8kH0LotKp/cWQ8HQ GAF9ERJFkiU6j9I/kXVlJ0S+/EmTHSQzJ5+SdypN1jtDmu7N5t/RQmM1hXkdoVQ3S2GD o2pStIawbwnQw8dYV3/1RJaEzx7y9C55lhvQElam6ENj6I6tUwVvQhG1r2uN2WlkOtcD yuvJF+8SH6/Sw2awPBsk0ZksUGTNG7kKqYifs0bm7xz2kIvqfEsJPC3vF96tHR9kR1t6 tFZoM6NqH05tkJ5JYorrzgwtsTcgkq6F1bmH8GHdpXjwXg3q/Ft9D4xzgGFtW8ZrHUKs naAQ== X-Gm-Message-State: AOAM5301Usj5WtKijsTMFXxvaBwlHQnxj0BJGbhcis/0SPAkOwINGGVa rHEAQl/fy+K14gsylOraqnCs9fpnUua667AF3nI= X-Google-Smtp-Source: ABdhPJwNMMWjv41Lhk8+q6rxAbY3ecog37GmW/e/WEk3waERYpDEk12j30mg73H7WFfyyK4Q1wMRWd0LFj9jSNOKu5g= X-Received: by 2002:a9d:6053:: with SMTP id v19mr11789058otj.362.1598509974017; Wed, 26 Aug 2020 23:32:54 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> <20200818162807.Bluez.v2.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> In-Reply-To: <20200818162807.Bluez.v2.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 26 Aug 2020 23:32:43 -0700 Message-ID: <CABBYNZLb_ETfO1VyAf+1rXpRT_XroQLq7u=uK6PGcrOKR7PHxA@mail.gmail.com> Subject: Re: [Bluez PATCH v2 3/3] policy: Reconnect audio on controller resume To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: F3202A1200 X-Rspamd-UID: 457777 Hi Abhishek, On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > During system suspend, all peer devices are disconnected. On resume, HID > devices will reconnect but audio devices stay disconnected. As a quality > of life improvement, mark audio devices that were disconnected due to > suspend and attempt to reconnect them when the controller resumes (after > a delay for better co-existence with Wi-Fi). > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > > Changes in v2: > - Refactored to use policy instead of connecting directly in adapter > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > src/adapter.h | 6 +++++ > src/main.c | 1 + > src/main.conf | 9 +++++++ > 5 files changed, 121 insertions(+), 4 deletions(-) > > diff --git a/plugins/policy.c b/plugins/policy.c > index de51e58b9..b07a997b9 100644 > --- a/plugins/policy.c > +++ b/plugins/policy.c > @@ -75,6 +75,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; > static int *reconnect_intervals = NULL; > static size_t reconnect_intervals_len = 0; > > +static const int default_reconnect_delay = 5; > +static int resume_reconnect_delay = 5; > + > static GSList *reconnects = NULL; > > static unsigned int service_id = 0; > @@ -93,6 +96,8 @@ struct policy_data { > uint8_t ct_retries; > guint tg_timer; > uint8_t tg_retries; > + > + bool reconnect_on_resume; > }; > > static struct reconnect_data *reconnect_find(struct btd_device *dev) > @@ -214,6 +219,7 @@ static gboolean policy_connect_sink(gpointer user_data) > > data->sink_timer = 0; > data->sink_retries++; > + data->reconnect_on_resume = false; > > service = btd_device_get_service(data->dev, A2DP_SINK_UUID); > if (service != NULL) > @@ -222,16 +228,20 @@ static gboolean policy_connect_sink(gpointer user_data) > return FALSE; > } > > -static void policy_set_sink_timer(struct policy_data *data) > +static void policy_set_sink_timer_internal(struct policy_data *data, int timeout) > { > if (data->sink_timer > 0) > g_source_remove(data->sink_timer); > > - data->sink_timer = g_timeout_add_seconds(SINK_RETRY_TIMEOUT, > - policy_connect_sink, > + data->sink_timer = g_timeout_add_seconds(timeout, policy_connect_sink, > data); > } > > +static void policy_set_sink_timer(struct policy_data *data) > +{ > + policy_set_sink_timer_internal(data, SINK_RETRY_TIMEOUT); > +} > + > static void sink_cb(struct btd_service *service, btd_service_state_t old_state, > btd_service_state_t new_state) > { > @@ -743,10 +753,30 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) > static void disconnect_cb(struct btd_device *dev, uint8_t reason) > { > struct reconnect_data *reconnect; > + struct btd_service *service; > + struct policy_data *data; > + bool do_reconnect = false; > > DBG("reason %u", reason); > > - if (reason != MGMT_DEV_DISCONN_TIMEOUT) > + switch(reason) { > + case MGMT_DEV_DISCONN_LOCAL_HOST: > + case MGMT_DEV_DISCONN_REMOTE: > + do_reconnect = true; > + break; > + /* Disconnect due to suspend will queue reconnect on resume for a2dp */ > + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: > + service = btd_device_get_service(dev, A2DP_SINK_UUID); > + if (service && (data = policy_get_data(dev))) { > + data->reconnect_on_resume = true; > + } Can't we just program the timer directly here? Or would that wakeup the system, I would imagine all timers are disabled while suspended which means when the system resumes so does the timers which would then trigger the reconnection logic. > + break; > + /* All other cases do not result in reconnect */ > + default: > + break; > + } > + > + if (!do_reconnect) > return; > > reconnect = reconnect_find(dev); > @@ -761,6 +791,23 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) > reconnect_set_timer(reconnect); > } > > +static void controller_resume_cb(uint8_t wake_reason, const bdaddr_t *addr, > + const uint8_t addr_type) > +{ > + struct btd_device *dev; > + GSList *l; > + > + /* Check if any devices needed to be reconnected on resume */ > + for (l = devices; l; l = g_slist_next(l)) { > + struct policy_data *data = l->data; > + > + if (data->reconnect_on_resume) { > + policy_set_sink_timer_internal(data, > + resume_reconnect_delay); > + } > + } > +} > + > static void conn_fail_cb(struct btd_device *dev, uint8_t status) > { > struct reconnect_data *reconnect; > @@ -854,9 +901,17 @@ static int policy_init(void) > auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", > NULL); > > + resume_reconnect_delay = g_key_file_get_integer( > + conf, "Policy", "ReconnectAudioDelay", &gerr); > + > + if (gerr) { > + g_clear_error(&gerr); > + resume_reconnect_delay = default_reconnect_delay; > + } > done: > if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { > btd_add_disconnect_cb(disconnect_cb); > + btd_add_controller_resume_cb(controller_resume_cb); > btd_add_conn_fail_cb(conn_fail_cb); > } > > @@ -869,6 +924,7 @@ done: > static void policy_exit(void) > { > btd_remove_disconnect_cb(disconnect_cb); > + btd_remove_controller_resume_cb(controller_resume_cb); > btd_remove_conn_fail_cb(conn_fail_cb); > > if (reconnect_uuids) > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..7526feb9e 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -139,6 +139,7 @@ static GSList *adapter_drivers = NULL; > > static GSList *disconnect_list = NULL; > static GSList *conn_fail_list = NULL; > +static GSList *controller_resume_list = NULL; > > struct link_key_info { > bdaddr_t bdaddr; > @@ -8766,6 +8767,45 @@ static void connected_callback(uint16_t index, uint16_t length, > eir_data_free(&eir_data); > } > > +static void controller_resume_notify(const uint8_t wake_reason, > + const bdaddr_t *addr, > + const uint8_t addr_type) > +{ > + GSList *l; > + > + for (l = controller_resume_list; l; l = g_slist_next(l)) { > + btd_controller_resume_cb resume_cb = l->data; > + resume_cb(wake_reason, addr, addr_type); > + } > +} > + > +static void controller_resume_callback(uint16_t index, uint16_t length, > + const void *param, void *user_data) > +{ > + const struct mgmt_ev_controller_resume *ev = param; > + struct btd_adapter *adapter = user_data; > + > + if (length < sizeof(*ev)) { > + btd_error(adapter->dev_id, "Too small device resume event"); > + return; > + } > + > + DBG("Controller resume with wake event 0x%x", ev->wake_reason); > + > + controller_resume_notify(ev->wake_reason, &ev->addr.bdaddr, > + ev->addr.type); > +} > + > +void btd_add_controller_resume_cb(btd_controller_resume_cb func) > +{ > + controller_resume_list = g_slist_append(controller_resume_list, func); > +} > + > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func) > +{ > + controller_resume_list = g_slist_remove(controller_resume_list, func); > +} > + > static void device_blocked_callback(uint16_t index, uint16_t length, > const void *param, void *user_data) > { > @@ -9389,6 +9429,11 @@ static void read_info_complete(uint8_t status, uint16_t length, > user_passkey_notify_callback, > adapter, NULL); > > + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, > + adapter->dev_id, > + controller_resume_callback, > + adapter, NULL); > + > set_dev_class(adapter); > > set_name(adapter, btd_adapter_get_name(adapter)); > diff --git a/src/adapter.h b/src/adapter.h > index f8ac20261..5527e4205 100644 > --- a/src/adapter.h > +++ b/src/adapter.h > @@ -67,6 +67,12 @@ typedef void (*btd_conn_fail_cb) (struct btd_device *device, uint8_t status); > void btd_add_conn_fail_cb(btd_conn_fail_cb func); > void btd_remove_conn_fail_cb(btd_conn_fail_cb func); > > +typedef void (*btd_controller_resume_cb)(const uint8_t wake_reason, > + const bdaddr_t *addr, > + const uint8_t addr_type); > +void btd_add_controller_resume_cb(btd_controller_resume_cb func); > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func); If we can program the timer just before we suspend this is not really necessary, but if you still thing that would be a good idea to notify Id put it in btd_adapter_driver with a callback for suspend and resume, that way we don't have to maintain multiple lists for each of the callbacks. > struct btd_adapter *adapter_find(const bdaddr_t *sba); > struct btd_adapter *adapter_find_by_id(int id); > void adapter_foreach(adapter_cb func, gpointer user_data); > diff --git a/src/main.c b/src/main.c > index 2c083de67..a1c3e7e9f 100644 > --- a/src/main.c > +++ b/src/main.c > @@ -131,6 +131,7 @@ static const char *policy_options[] = { > "ReconnectAttempts", > "ReconnectIntervals", > "AutoEnable", > + "ReconnectAudioDelay", > NULL > }; > > diff --git a/src/main.conf b/src/main.conf > index f41203b96..8d74a2aec 100644 > --- a/src/main.conf > +++ b/src/main.conf > @@ -198,3 +198,12 @@ > # This includes adapters present on start as well as adapters that are plugged > # in later on. Defaults to 'false'. > #AutoEnable=false > + > +# Audio devices that were disconnected due to suspend will be reconnected on > +# resume. ReconnectAudioDelay determines the delay between when the controller > +# resumes from suspend and a connection attempt is made. A longer delay can be > +# better for co-existence with Wi-Fi. > +# The value is in seconds. > +# Default: 5 > +#ReconnectAudioDelay = 5 > + > -- > 2.28.0.297.g1956fa8f8d-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qCqlKBrCRl+VXwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 22:12:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id sHgFJxrCRl88tQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 22:12:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A3336420D2; Wed, 26 Aug 2020 22:12:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726820AbgHZUMD (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 16:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbgHZUMD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 16:12:03 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD751C061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:12:02 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 83so4357538ybf.2 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=x5I31Cx/lCkc6J4SrBA8xYUW95BrqBSHcoi2qMQlDjE=; b=X5TlRlIa/cQZmDjbzYzSWOG3R7OJuKmzdHHBIRHKPM6cDkoxD4j6Fhj+ETUnPd0qpO gPCriLCFZFd9cQjFW11DygRpa0nP56om7X5X/Kn6X7ceLMDBavk6D7E4y5gqATene9WX TlwdZYaRqxeVw/CjFUq7XNU9tjtZkqByYh1TlGZA3vRDsyy/mx2dBVdGUbcv7h/5mNyb 5tpVUSquIstollCIcB///kmFxjysjUhBxndZDQ+r/JuTg0l650w7Fiv0zSXSnKK8LtZM B4436xqGhamonzagg8TSwMxfitIJ1Nza+3xS+/I1BlCnh0zZcFtU6ZiYwIXgZ2Z548wT SWRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=x5I31Cx/lCkc6J4SrBA8xYUW95BrqBSHcoi2qMQlDjE=; b=j1beBHTbWLfB9wnUt7X0iy2V7vxUYc26NkR+8fDq6FRgxEbHrBE1OsVKVP1atk1bG0 LBbc6YifNWzOaSPiUSh8VuayoaBRGNGYNQrgkz+PCgKBpxLyyTT2Hn/c8FIiukmWq1N9 pm3TE3rUBnpfuCKsT3i7QmGdqWBcyH98sSlm68IR01sYFL70VCgc/wF48Hfn2rWqSX0n 6ovIDehNoSW5pN5o1p09sCLS5oDN8WySMW0tUe+p+YVsnsRKtaI+ckLyFM5a1ggRgoAW DBwX/9aEobjVuFztH6gV1jllD3rY2HIGSZ+qMe4EcwfH1OT8/hofIv0ABI2rbt2y3ZKV DFVA== X-Gm-Message-State: AOAM533iDU3ezvaM4loIES0rjFOK9ca/IguLXd7V8vDZsRn4yuYKQB5V iiO/2akYWwF97w1MALvFBNGDHts5GRLRzptU8oy9JBKqwnTbSJHKv/MIhAAOiznsOjSVZbEP+h3 Shrm8fFlC0wzBb0a3neKSO/KK7PJ//k7nulZ5BbV1Iop0NsOtwzlTNs2D9eq31HW0NFskmVCH4x AxxLdM5KN0iSpcMZjC X-Google-Smtp-Source: ABdhPJwqPVROgyrD7pYkUsV1/xGbrktwuk/s14Ma2EcuOQZoEw8sy3gErs3HQmoi1wKgSOxsu4yCsxcTWb9NA+YV3R4t X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:c791:: with SMTP id w139mr23204942ybe.345.1598472721893; Wed, 26 Aug 2020 13:12:01 -0700 (PDT) Date: Wed, 26 Aug 2020 13:11:45 -0700 In-Reply-To: <20200826201147.1908411-1-danielwinkler@google.com> Message-Id: <20200826131103.Bluez.v1.1.Idf2f9f409a4df20b466ba723dd9b729275a5afbf@changeid> Mime-Version: 1.0 References: <20200826201147.1908411-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [Bluez PATCH v1 1/3] PRE_UPSTREAM: advertising: Add SupportedFeatures to LEAdvertisingManager1 From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: A3336420D2 X-Rspamd-UID: 31ba83 The new SupportedFeatures member tells advertising clients whether the platform has hardware support for advertising or capability to set tx power of advertisements. Additionally, fix small typo in "secondary_exists" function name. Change is tested on hatch and kukui chromebooks by using dbus-send to verify that SupportedFeatures are populated when extended advertising is available only. Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- lib/mgmt.h | 2 ++ src/advertising.c | 56 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index a800bcab4..38182e576 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -516,6 +516,8 @@ struct mgmt_rp_add_advertising { #define MGMT_ADV_FLAG_SEC_1M (1 << 7) #define MGMT_ADV_FLAG_SEC_2M (1 << 8) #define MGMT_ADV_FLAG_SEC_CODED (1 << 9) +#define MGMT_ADV_FLAG_CAN_SET_TX_POWER (1 << 10) +#define MGMT_ADV_FLAG_HW_OFFLOAD (1 << 11) #define MGMT_OP_REMOVE_ADVERTISING 0x003F struct mgmt_cp_remove_advertising { diff --git a/src/advertising.c b/src/advertising.c index e5f25948d..9853baa4e 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -1321,7 +1321,8 @@ static void append_secondary(struct btd_adv_manager *manager, } } -static gboolean secondary_exits(const GDBusPropertyTable *property, void *data) +static gboolean secondary_exists(const GDBusPropertyTable *property, + void *data) { struct btd_adv_manager *manager = data; @@ -1345,12 +1346,63 @@ static gboolean get_supported_secondary(const GDBusPropertyTable *property, return TRUE; } +static struct adv_feature { + int flag; + const char *name; +} features[] = { + { MGMT_ADV_FLAG_CAN_SET_TX_POWER, "CanSetTxPower" }, + { MGMT_ADV_FLAG_HW_OFFLOAD, "HardwareOffload" }, + { }, +}; + +static gboolean display_features(const GDBusPropertyTable *property, + void *data) +{ + struct btd_adv_manager *manager = data; + + /* Currently, all displayed features are supported if hardware + * offloading is available, so this is used to determine if we + * should display the feature list + */ + return manager->supported_flags & (MGMT_ADV_FLAG_HW_OFFLOAD); +} + +static void append_features(struct btd_adv_manager *manager, + DBusMessageIter *iter) +{ + struct adv_feature *feat; + + for (feat = features; feat->name; feat++) { + if (manager->supported_flags & feat->flag) + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, + &feat->name); + } +} + +static gboolean get_supported_features(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct btd_adv_manager *manager = data; + DBusMessageIter entry; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &entry); + + append_features(manager, &entry); + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + static const GDBusPropertyTable properties[] = { { "ActiveInstances", "y", get_active_instances, NULL, NULL }, { "SupportedInstances", "y", get_instances, NULL, NULL }, { "SupportedIncludes", "as", get_supported_includes, NULL, NULL }, { "SupportedSecondaryChannels", "as", get_supported_secondary, NULL, - secondary_exits }, + secondary_exists }, + { "SupportedFeatures", "as", get_supported_features, NULL, + display_features }, { } }; -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yAbFESDCRl+VXwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 22:12:16 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 6N43ECDCRl8y+wEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 22:12:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C4709420F2; Wed, 26 Aug 2020 22:12:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726878AbgHZUMI (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 16:12:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbgHZUMH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 16:12:07 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C00FAC061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:12:06 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id c78so1856934ybf.6 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=8A7xpmrr7m1zruibMkh52mGk5SyAjYE9eZwX3Vft4m0=; b=EQBd6Tyeq7nGzis1g4BsMpKpHXXQw3Ij5YGb0+zOrsUJZbNvZqf+fmpvC1tel3RvVY giCVv8HqtKW25dmKQ4d/Z7zUkpZDKkskipBkxgYC6Gki4cdDoFC4aXCNbenq3k8DvPJz K4fchJ3PPhX9Esy5nzAGQJUMJ+jmyc0Mb6zC4dFGkuTnfyP3iZB0ErtSzaJ/8vdIwRau CmdAELb5o3mTzamCrhFKE+9BocLnEqrto4R1tyiTuMhQpAO9Mwq5BgSe4pG0cD4fe2z6 KELMkedpI/hYK9iq4FQ4B7qDPYT8WeAc8RauwGa8ggAPaqq3F7NCvfCDZ30BoWhXpC5o BLQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8A7xpmrr7m1zruibMkh52mGk5SyAjYE9eZwX3Vft4m0=; b=Uw9pmN0b0tqSZhmrG0yiWxGOrFoHKGPzJMVSVNlC1u3a8LkDrbF7DwlHhieLA9s6Qo u2wkQd6EpsJ536FtOcjpQuit4anKdWIZpVzfYscA9A917oSbjRsldVcXcVs8fhfETP44 vRRpuwiwoTgCg3ACdw9WG2SGiQJI5BVjQZGHp4FhlG3t9FCWds6YUqlP0vCu3NdInErO dKFfL/b/gHPZxj+ZBkn51sGgSlpfz0CJcmy2uuGDMrsA0gkr+Ge0La2YfM644nh03ON4 8quUqVsZkSRmzAtSnsbDtPbn/uNbyv9oY5Gs4whkfg91jZqtyvXyhee+ZrW/H1jpWah2 euLg== X-Gm-Message-State: AOAM531MynfkoQF1ws0CTYPKu0HwaNanY1qidbaXfgB/xaOSHEAsnftj WI24+j4nfbp7QNNaNg62TOudxjPdOaHK270S7hcl1Qq2dSzIEZgTd+XFriXwik9x5M++0uC0EWz qzmX/6Z7Z10+K5KxPqmC6/Rq3V8h4DKcRtptGQ9cg8T04R3WSeTjqSSw1D+in09XTMlV2dBZqMx smXhBAgQT6PtoLgvvT X-Google-Smtp-Source: ABdhPJwP2sZGJ6OUBXde7GCsc1AQC5fSnaGsJhsGKYRenY4yZG+hm89XcG89mWb/91HD8DOV/hI5Rw4ixSm8IbH2vdpt X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:2451:: with SMTP id k78mr24201813ybk.335.1598472725915; Wed, 26 Aug 2020 13:12:05 -0700 (PDT) Date: Wed, 26 Aug 2020 13:11:46 -0700 In-Reply-To: <20200826201147.1908411-1-danielwinkler@google.com> Message-Id: <20200826131103.Bluez.v1.2.I33cf8432f94675b635ab429b3125f54048c5b66a@changeid> Mime-Version: 1.0 References: <20200826201147.1908411-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [Bluez PATCH v1 2/3] PRE_UPSTREAM: advertising: Add adv SupportedFeatures to bluetoothctl From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.44 / 15.00 / 200.00 X-Rspamd-Queue-Id: C4709420F2 X-Rspamd-UID: 11f497 This change adds SupportedFeatures to be shown in "show" option of bluetoothctl. It was tested with and without kernel support for features to verify that they are shown or not shown correctly. Change was tested by verifying SupportedFeatures were populated correctly in bluetoothctl on hatch and kukui chromebooks Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- client/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/main.c b/client/main.c index da877b546..6368cd516 100644 --- a/client/main.c +++ b/client/main.c @@ -933,6 +933,7 @@ static void cmd_show(int argc, char *argv[]) print_property(adapter->ad_proxy, "SupportedInstances"); print_property(adapter->ad_proxy, "SupportedIncludes"); print_property(adapter->ad_proxy, "SupportedSecondaryChannels"); + print_property(adapter->ad_proxy, "SupportedFeatures"); } return bt_shell_noninteractive_quit(EXIT_SUCCESS); -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uMfZIyXCRl8AZQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 22:12:21 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id KBzBIiXCRl9CXwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 22:12:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A5BAB420EE; Wed, 26 Aug 2020 22:12:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726894AbgHZUMO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 16:12:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbgHZUMM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 16:12:12 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2F9FC061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:12:11 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 83so4358035ybf.2 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=PiO+YY0khA5TeZgvkhFxD4wUEHIs5J/uidiQhfjjKHI=; b=pizbHmMfeqvihtd8t1cNQqBIsYyUogMxW5O4L9a0DPNDgBbmnhX1t7DHuW52vzhYwj ui6K14R4iYx5yaGn6Kr2xS8DkcsfU8lFKZ9SKmDxST93VzUbAoFoUNr+B8/echB7u/gz 1A2CJdEApG9s+IFCRHbF0mRmDJVjR9JCdkjuESIt7BXSbAgoIhy5H3dh32quM8+z4dbB RBMBEQzgItGatFsOvFFNurhodMH1lYQhE68y70MaBfc/PHStVuilq28LEenoPAh9Nemo q+ibzdhEEFwghlLPLac8IfQuIbLvYjVFAC0MfZS8tXnLl9NwbHFPS7qjj3BNEsFHtJn6 sbxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=PiO+YY0khA5TeZgvkhFxD4wUEHIs5J/uidiQhfjjKHI=; b=dIVcIA7pVe6h9M+MFvjrsmCcj+m2NKPEj3HAFH/aj9g3XADXUnytEikZrXUqO+CIY2 i65enVc72dRBUFpIdknsMYQFL7A8DHBl4JtYVsshyf3mZRuz0a+5FnIT4JV88lHvC+Hi oCUTOslpZ1wpOdFXLjBhl/1ZDiZCDZdcr/WzAAriZkZzqI7LfiG06Z+BqAEn49HBkrlm KeCbsDHLliSk2X/ddwafaGM7VvvnkyEhzYpw7wfuDiYhGONGR1J6md0MvU3wsHNpHa53 /16liFE4RbFsV9WXSKODY5m6ac/2cTsh3tPIXpgmoJOS2BWWeVmFAUBbHPnrFe6idEPi GvRw== X-Gm-Message-State: AOAM531CaTaeCQqdY5lGKh8xFRepydbRF4yMvBG8wL4hpWxnM9PHxf6r cC9IxyyR/HpZG2AHdhpf5MTiPx7rEO0Bz5qJJNz3Tjg1Yq8DfWWbu5t3OFx1SoObWRZ0gtsjYB6 Htl0NmgeiQo5Cv51QS63bEa93RYFtSeA6ol6s/f5G6x4giDdvHdiJbFzatBBn2VRMmcPAcYWd75 ManLqQmGpElQ+6e6YU X-Google-Smtp-Source: ABdhPJxBz0J3MpDNnC5E4A00S5fyZqViiRAu4wDtvy8dGetI66sZGNqLAWXrO/eDIEHHTMw8ANSC3BgAzpqC1SldgQ6S X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:e791:: with SMTP id e139mr25054480ybh.67.1598472730984; Wed, 26 Aug 2020 13:12:10 -0700 (PDT) Date: Wed, 26 Aug 2020 13:11:47 -0700 In-Reply-To: <20200826201147.1908411-1-danielwinkler@google.com> Message-Id: <20200826131103.Bluez.v1.3.Ieb6522963e3f54b0d63dd88ed3ce24a8942ed73e@changeid> Mime-Version: 1.0 References: <20200826201147.1908411-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [Bluez PATCH v1 3/3] PRE_UPSTREAM: advertising: Add adv SupportedFeatures to doc From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.91 / 15.00 / 200.00 X-Rspamd-Queue-Id: A5BAB420EE X-Rspamd-UID: 695e4f Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- doc/advertising-api.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt index b0565eab2..0c07f349e 100644 --- a/doc/advertising-api.txt +++ b/doc/advertising-api.txt @@ -209,3 +209,21 @@ Properties byte ActiveInstances Possible values: "1M" "2M" "Coded" + + array{string} SupportedFeatures [readonly, optional] + + List of supported platform features. If no features + are available on the platform, the SupportedFeatures + endpoint will not be populated. + + Possible values: "CanSetTxPower" + + Indicates whether platform can + specify tx power on each + advertising instance. + + "HardwareOffload" + + Indicates whether multiple + advertising will be offloaded + to the controller. -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eLn4DFXDRl+VXwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 22:17:25 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uFQaC1XDRl8yhQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 22:17:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 58D17A24BF; Wed, 26 Aug 2020 22:17:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726740AbgHZURV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 16:17:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbgHZURU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 16:17:20 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A878C061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:17:20 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id l67so4318907ybb.7 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:17:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=5f/lN0/70bYXYJZSh5TJQuXrKMG7Gi5D2DcObKSQfRQ=; b=uRpF2yvlvVv9aEyURzj8IXIHpHZrVxIKfyuUpz79LL4JhK/iVVoI4cUEuMGvOt50oc 2Zn49M4jL8/pvHXUPYRnhI/U/mQmS8/TUCz8ukWxM0V8Mt1Zz0X7M+0H8IgesbdWXxqg aFPJrWTmQXzpaUCTFvvFlUonAruXjI5TGwO2AFm08jjejXpPB5j6VmkiGDmzGvK18Bih rr1qPJNeXYjc4zUA8KdRUN0/Nj192Yd5K3Fa2NgQuqirIPHiIkbb9VvF7dnbcszKg7L3 AruYtnjBLgdLb6Oh0BA37ccwRZGatBv3L/tyCt5RXjXSfn7ZG8+pkEW7s5RKyHRiv/bG ekbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=5f/lN0/70bYXYJZSh5TJQuXrKMG7Gi5D2DcObKSQfRQ=; b=gOsYWjATFZW51TbRgkp9rcI7lONgBz0g23/Fakzb3cPRBqUHuJcJRO7nTCEq6vBv+m tCPCNtolMCQT7S01oG65bJcmkzwSGqZ0VZ4je0vTDSZHlANlTEjU7/DUFoQjdGDZC3U9 gv7wCjEXYM7TZh85WOsT86DIIL2YaZebb0vTw5/EwOB2xoOZSqU980iJGRRc3aujJI5j DmFVR0wV/DWi/UrBIvROce9axWtmdrHeuD8fnZWAsZq2/Y26sSnkAfkFfbZgxyYftUIW W+exjeq2Vj5F589Eu0M84RPDkBxon4HcFgCsIUvbwmpeQyy+UwD5S1PoRgoJwmBgMmTj Tuow== X-Gm-Message-State: AOAM533+15noeEu0Zidi0z7qRr384kpR9bgj15ubY+tyeuPpeO4KfXiU YXqWNYIBHpKsMtsl27YjRoVVssOBU6khx3dWkCR+chO+MENzIGMSL/WyzZGdFANBrY8wmSC5gZr Pm1HvKcqzfpS8v/tyTthgKusdbNJGaCCe7xENq/9XuB7XWz8WHRTI/Soo/B90UKcnIpG2O9efaI 2wZJJuMj9wYX3AJlbW X-Google-Smtp-Source: ABdhPJz1IStXfh0rJivPlGVe4gbKEtd1FOsFD0lbVX04afPvS3TILMls5lXlGck/PYTHV3kXRlNgdJ4MY8kV0EMtzxC9 X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:3556:: with SMTP id c83mr23823765yba.412.1598473039702; Wed, 26 Aug 2020 13:17:19 -0700 (PDT) Date: Wed, 26 Aug 2020 13:17:11 -0700 Message-Id: <20200826201715.1911816-1-danielwinkler@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [Bluez PATCH v1 0/3] Expose extended adv feature support via bluez API From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 4.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: 58D17A24BF X-Rspamd-UID: 2da7aa Hi Maintainers, This change adds a SupportedFeatures member to the LEAdvertisingManager interface, which allows us to expose support for hardware offloading and setting TX power on advertisements. Best, Daniel Daniel Winkler (3): PRE_UPSTREAM: advertising: Add SupportedFeatures to LEAdvertisingManager1 PRE_UPSTREAM: advertising: Add adv SupportedFeatures to bluetoothctl PRE_UPSTREAM: advertising: Add adv SupportedFeatures to doc client/main.c | 1 + doc/advertising-api.txt | 18 +++++++++++++ lib/mgmt.h | 2 ++ src/advertising.c | 56 +++++++++++++++++++++++++++++++++++++++-- 4 files changed, 75 insertions(+), 2 deletions(-) -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sHg1H1zDRl+VXwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 22:17:32 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wFfKHVzDRl+SIwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 22:17:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C6914A015F; Wed, 26 Aug 2020 22:17:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgHZUR1 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 16:17:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbgHZURZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 16:17:25 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73A1FC061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:17:25 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id l67so4319214ybb.7 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=x5I31Cx/lCkc6J4SrBA8xYUW95BrqBSHcoi2qMQlDjE=; b=kOwGJoJBl0E1Z7mvvPzizgkigTQAhMdEY9gNuEBwiXhYb2U3fTx6Zdax9uISRnqZpW V/+TPYWoXwyG+QHR6cb7NekVD0O2angGGyrrz1rLNhXN9Ykf1IcboxxBuXj9i5YelPqt rKLlspy2/yOd47/ysP6yd0fzf8ms45tFcgdVKukhkaD/LBxqWlE+lmmV6QS4mxYyP9w4 HdtOoDWRbr5CI2ROwVC+W6Q3dh6MgazSO/2BSRcE+oXeENVGoEDig2KgHCs5z9mQIGU3 3pclPjCg45VUi4+6OLUJQt/PBHw9NvsnlthdoLUYwRMcsuNufCW0MEtBNK3KpimB98Pb lnKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=x5I31Cx/lCkc6J4SrBA8xYUW95BrqBSHcoi2qMQlDjE=; b=phhSZeQP0nKNJP9bLox1ZlUsYgfub05yHcGzyjEg9SNVgQ7c7L9i5aswovabBa3U1x VdDTSu+WxlbOIAhyaPOf/YBgLE6fy4RlyvVZHNvnHrGHQiuK6FcGpUK++RlWw7GGTXPP /msemgQnGb1lZdfdhYHocZ/I8at6J9QNycNDZuyeaeBVNiBfjALpgHYLkNb0+krGmU1s dQ3YTjIMRs9MrnnsLmI4fXwdgrBosCFtI62Nva7K/b8+pA2qs4iCitLcZFNKNub/DSrj tiXuBa8NR958p/JbFNMT9MEocAPS8NX50xKpDCYZfGety1Fy1mZ0DZ2o60IFPWDCnFYN i/1w== X-Gm-Message-State: AOAM531UI+W7WMNxYgeNtl5NB+LUPja3M/pKnoWP9BxPv15V27VRXt78 +PQ8s22UdZOwKqq+udukDz5P0CQUS91A+mrW/VkUTgjcH4vhSun//+zjErp46NlvsXfEh1vlNfE ha5Zc8cZKxHNM+HZ+WX9zcTvDuMFMAKfiPhPjuR/tIJI/YjHKMMe9Thuy5TfTvtuAv1T3dcEzpY IwgNserAbmOvU6UKs7 X-Google-Smtp-Source: ABdhPJyzWubI/t49HfmzVS/EHd+wEmNGrZHrvm1Eq7yUext2ROZJwxBxb4JLb4d56l04MKLJgSlXdCxHxDWDIFWoNNMg X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:cfcc:: with SMTP id f195mr24607098ybg.490.1598473044641; Wed, 26 Aug 2020 13:17:24 -0700 (PDT) Date: Wed, 26 Aug 2020 13:17:12 -0700 In-Reply-To: <20200826201715.1911816-1-danielwinkler@google.com> Message-Id: <20200826131610.Bluez.v1.1.Idf2f9f409a4df20b466ba723dd9b729275a5afbf@changeid> Mime-Version: 1.0 References: <20200826201715.1911816-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [Bluez PATCH v1 1/3] advertising: Add SupportedFeatures to LEAdvertisingManager1 From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: C6914A015F X-Rspamd-UID: d61d2f The new SupportedFeatures member tells advertising clients whether the platform has hardware support for advertising or capability to set tx power of advertisements. Additionally, fix small typo in "secondary_exists" function name. Change is tested on hatch and kukui chromebooks by using dbus-send to verify that SupportedFeatures are populated when extended advertising is available only. Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- lib/mgmt.h | 2 ++ src/advertising.c | 56 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index a800bcab4..38182e576 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -516,6 +516,8 @@ struct mgmt_rp_add_advertising { #define MGMT_ADV_FLAG_SEC_1M (1 << 7) #define MGMT_ADV_FLAG_SEC_2M (1 << 8) #define MGMT_ADV_FLAG_SEC_CODED (1 << 9) +#define MGMT_ADV_FLAG_CAN_SET_TX_POWER (1 << 10) +#define MGMT_ADV_FLAG_HW_OFFLOAD (1 << 11) #define MGMT_OP_REMOVE_ADVERTISING 0x003F struct mgmt_cp_remove_advertising { diff --git a/src/advertising.c b/src/advertising.c index e5f25948d..9853baa4e 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -1321,7 +1321,8 @@ static void append_secondary(struct btd_adv_manager *manager, } } -static gboolean secondary_exits(const GDBusPropertyTable *property, void *data) +static gboolean secondary_exists(const GDBusPropertyTable *property, + void *data) { struct btd_adv_manager *manager = data; @@ -1345,12 +1346,63 @@ static gboolean get_supported_secondary(const GDBusPropertyTable *property, return TRUE; } +static struct adv_feature { + int flag; + const char *name; +} features[] = { + { MGMT_ADV_FLAG_CAN_SET_TX_POWER, "CanSetTxPower" }, + { MGMT_ADV_FLAG_HW_OFFLOAD, "HardwareOffload" }, + { }, +}; + +static gboolean display_features(const GDBusPropertyTable *property, + void *data) +{ + struct btd_adv_manager *manager = data; + + /* Currently, all displayed features are supported if hardware + * offloading is available, so this is used to determine if we + * should display the feature list + */ + return manager->supported_flags & (MGMT_ADV_FLAG_HW_OFFLOAD); +} + +static void append_features(struct btd_adv_manager *manager, + DBusMessageIter *iter) +{ + struct adv_feature *feat; + + for (feat = features; feat->name; feat++) { + if (manager->supported_flags & feat->flag) + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, + &feat->name); + } +} + +static gboolean get_supported_features(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct btd_adv_manager *manager = data; + DBusMessageIter entry; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &entry); + + append_features(manager, &entry); + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + static const GDBusPropertyTable properties[] = { { "ActiveInstances", "y", get_active_instances, NULL, NULL }, { "SupportedInstances", "y", get_instances, NULL, NULL }, { "SupportedIncludes", "as", get_supported_includes, NULL, NULL }, { "SupportedSecondaryChannels", "as", get_supported_secondary, NULL, - secondary_exits }, + secondary_exists }, + { "SupportedFeatures", "as", get_supported_features, NULL, + display_features }, { } }; -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eGntF2PDRl/wcgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 22:17:39 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id OImqFmPDRl+g0gEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 22:17:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AB082A23D5; Wed, 26 Aug 2020 22:17:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726836AbgHZURc (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 16:17:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbgHZUR3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 16:17:29 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1320C061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:17:28 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id q15so2088424pfu.20 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=8A7xpmrr7m1zruibMkh52mGk5SyAjYE9eZwX3Vft4m0=; b=o+G+dhR1lqYgg39p8K3R5QaTMpv/JQmfFTL/gz67THL2lGfr1NPZ/mE4hG/KTzCyjA hxWtngR7G5cRomyyxV89sqEtaQBW2KAdWyzql/feEWtVccFVfQlh7I5fWlMHKs1+jZwZ w/Fsn/FgRIAVkDNFews/GAadPa9zo9prrGslRJu0kowpZVTUzZ9FucRAJKrifR9h9tG6 QmSBTiDVPCrpuRRcppCKPmqyflV4XvIGppL78hyd2W06dHhnVVJwWSg0WWIqG86Uo0OQ 8UWMcW7au7mpEAhjs/NIz89Rw3xp+7SY3YX2DlF2uoMQEYT0tGXk1Ng/VkLXoRxk98s8 3BIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8A7xpmrr7m1zruibMkh52mGk5SyAjYE9eZwX3Vft4m0=; b=H6RkaAshGbrmBkcOSX93IEn+VWfsvSiR0wH8VLhldReLlll5Y1A/mgMBOhsnBnN9Fp n8IS3oJheJDU8oDKaInvzyJ+s24Qg5WIQYmPkF/7GIM2ea0BihI3aM+3QRdiouSN54Q+ nFoo9ZbkMyZEqr75M3St8PnrEBnCabw9s/2E8r0k93i/suqn3uA8Q+wHxZHLVbC/oHXQ N7awYvP7hyybmGbkdulYBE3vk9CmRUWWimYl98P39s3XeIm4UcljH2bBYPolFpTS9hoW WsPFWUqSEm9z0UcIZeT8fZYGu24npvFPdlw4AJww0PNFxQHC8QevCesUsM+IshqYtNHd 6K3A== X-Gm-Message-State: AOAM531wdATIiAiBi5miQNP/iH2y4IUY6zBKpVZBqwpigjTVNC7716gR 2iRf1afif7og7WlVxT0ufZ10htorepgfkid4JDX/VWgZ+pyJvqbxsBJaRfGM01T1H8uK/v89IoG iT6z5usilO31pjqGP4n9MkYIZAPJEdr465MMrDahVnjsLE7OV6y0sPUjiuwuw77oCe0yiJhxfZh mJXIdh4izAYncenAfE X-Google-Smtp-Source: ABdhPJz8nNSZI6BVW+zkvDlh3BDmJbMRmDSBx1axTwqMTRb+K8SCDYGQlw/05B/blD4RTMrMcwRjapk0dVDC2rkWbAWe X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a17:90a:f290:: with SMTP id fs16mr7472481pjb.35.1598473048230; Wed, 26 Aug 2020 13:17:28 -0700 (PDT) Date: Wed, 26 Aug 2020 13:17:13 -0700 In-Reply-To: <20200826201715.1911816-1-danielwinkler@google.com> Message-Id: <20200826131610.Bluez.v1.2.I33cf8432f94675b635ab429b3125f54048c5b66a@changeid> Mime-Version: 1.0 References: <20200826201715.1911816-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [Bluez PATCH v1 2/3] advertising: Add adv SupportedFeatures to bluetoothctl From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: AB082A23D5 X-Rspamd-UID: 640c61 This change adds SupportedFeatures to be shown in "show" option of bluetoothctl. It was tested with and without kernel support for features to verify that they are shown or not shown correctly. Change was tested by verifying SupportedFeatures were populated correctly in bluetoothctl on hatch and kukui chromebooks Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- client/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/main.c b/client/main.c index da877b546..6368cd516 100644 --- a/client/main.c +++ b/client/main.c @@ -933,6 +933,7 @@ static void cmd_show(int argc, char *argv[]) print_property(adapter->ad_proxy, "SupportedInstances"); print_property(adapter->ad_proxy, "SupportedIncludes"); print_property(adapter->ad_proxy, "SupportedSecondaryChannels"); + print_property(adapter->ad_proxy, "SupportedFeatures"); } return bt_shell_noninteractive_quit(EXIT_SUCCESS); -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QMF5EWjDRl+VXwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 22:17:44 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id OD+ND2jDRl9WvAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 22:17:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C053AA1676; Wed, 26 Aug 2020 22:17:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726838AbgHZURe (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 16:17:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbgHZURc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 16:17:32 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03030C061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:17:32 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id y9so4321574ybp.8 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=PiO+YY0khA5TeZgvkhFxD4wUEHIs5J/uidiQhfjjKHI=; b=reDgmPuMQ+/NY3WaTesgR4ekhIsCpfMhaqBC7u9shCaG39NcHh/PJ+v30oAAXnrLqf EY1oWYTVFzrg1aCIJrUkonr6yVUm2yyV0QSFa+Pl5u9jOKS/17rTwttlmBIyo+bvP+4Z HZctOS1VSPohKpnptG1bHTYLo8BUEeJNJR9MAMvEQ9PZyHdq5QD5N9jzVbQjJ+vii5CE BQiaK38wuRVLdBv1KvjZqO40Ck5agfM6v2teYJphFE2l/fYIzN2H/s7hpfxxBfb5eq4B iiV8g612yRV2iHDb6PzNq4Bc0YiwZWe5YM/sGFxYULxgUPxxPEub3scDZ8GFJi2b4II/ 7diw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=PiO+YY0khA5TeZgvkhFxD4wUEHIs5J/uidiQhfjjKHI=; b=iL/swBjzT2Fn2Z1+T/h37hw6ldPChQORu+YnmC8vf00MIZFZcxEKzXNo2viuhZexiu iXC2wu8ayAsLvl4q9CydF6D+kg09LXWMSCvuokOdy49EDodLaEMVntQFnkCm0MVPEfNg 2ONgDCqRLi+jhhx57WmugvxIHnGf3ZYFnBe/kHCUqM6YWN75YrppqVLbTbgPv4rVnvPA 8oG6y1m7vHeXaKUSommMpEMK5U9e6TvjYmkHreM7pPj+B7OKgjYSysbr3eAafjrEkhYJ 25rOXa4ow3MSAY/nkND5L5na0iF0Me9HDVqxEgEcYQVze9/tG84WtNX5s8ZplOrR3kNG XSug== X-Gm-Message-State: AOAM532B7bzHnzu5aKQMGz+LOp5+U7E+dfl5W4mLU2OIJKmwIVGwrMJP 7vunmzp2syRPiSbuTIvEe1TBA0XHxdiL2Hf/qDrojuWJDm2CKLlVJaIeyPAn7DgCrjm4lz4afE4 h1R1BxI5VQfhERBf97aFxGFWI9+Tw5Jgj/bI0/XOOS55INzBXasborsrg7sH7JgvyqlpNCEmTEI ZDvZUs63mwfwkNmsNa X-Google-Smtp-Source: ABdhPJxQn2zN2psowCQc40L2uP+d8b3nXR2+p9YtTcRG/X94z2yQ8+jWr1B2tm/znx1G6e8dg1sb3gWI2VkKCLyoQjr6 X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:c088:: with SMTP id c130mr4441613ybf.356.1598473051199; Wed, 26 Aug 2020 13:17:31 -0700 (PDT) Date: Wed, 26 Aug 2020 13:17:14 -0700 In-Reply-To: <20200826201715.1911816-1-danielwinkler@google.com> Message-Id: <20200826131610.Bluez.v1.3.Ieb6522963e3f54b0d63dd88ed3ce24a8942ed73e@changeid> Mime-Version: 1.0 References: <20200826201715.1911816-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [Bluez PATCH v1 3/3] advertising: Add adv SupportedFeatures to doc From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.71 / 15.00 / 200.00 X-Rspamd-Queue-Id: C053AA1676 X-Rspamd-UID: 241dbc Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- doc/advertising-api.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt index b0565eab2..0c07f349e 100644 --- a/doc/advertising-api.txt +++ b/doc/advertising-api.txt @@ -209,3 +209,21 @@ Properties byte ActiveInstances Possible values: "1M" "2M" "Coded" + + array{string} SupportedFeatures [readonly, optional] + + List of supported platform features. If no features + are available on the platform, the SupportedFeatures + endpoint will not be populated. + + Possible values: "CanSetTxPower" + + Indicates whether platform can + specify tx power on each + advertising instance. + + "HardwareOffload" + + Indicates whether multiple + advertising will be offloaded + to the controller. -- 2.28.0.297.g1956fa8f8d-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qCK4LBvERl/wcgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 22:20:43 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id GIK4KhvERl8y+wEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 22:20:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id ADAECA17C3; Wed, 26 Aug 2020 22:20:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726836AbgHZUUg (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 16:20:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726820AbgHZUUf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 16:20:35 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78F1EC061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:20:34 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id f24so2893265edw.10 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9FyQMjwrR+qRwgsTKniSyNPE9tsU8qToAWdwd9jIpxg=; b=YE0+JXZ5I6p6VvmcTEaMyNIjoxXKBn76HlWhC0VHuRKEO2r4wJwLb+dD0yV7zkLQOR pyGV1q5xxrS62T0DV+TbIHzGfQyjcGpvE9wBljO8JW+uPchwBAM62shW0JrCjx0arZX8 dOCQSypaoSJHZWOHN8aXnc29UvrTTWl79SmVzvUx3SKjAldDmcMYdrBVAYZAu+Csl8So u2zrNabp6bHcg2liyjT0c/+2mLazSiHAh7vES69jx/jaGT8T+VBo/+YQ0zECHV23WLuP e+0fII1iKUJU6y+v0UUfm4jyfJY+jW0vW7QR3lYjOBy9vAQofAUY5nyd5tR+8hA+ixuu kJmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9FyQMjwrR+qRwgsTKniSyNPE9tsU8qToAWdwd9jIpxg=; b=OzpV/n11Cl8varc1UnAD+d7NPbVacHtXeWi2F2AJRwC30I7nWc3Txt4TLobqe0zxKx m+bnlVKeJSipW/DsksBeHlkBw/khKf7gdA1MIdLyDWZpQO4X0FxSVwqkvBE32+a4EdrN VkBMjQFMfZ10n12lCn6bHxDyO+a2VT63mHT5C9jcZ+E+Yyq4FEVUq3mKU2kIvEA7Bx/X Y0vwooj8PuZbftYkpw0dr9VYURBpTpC3kO9XxMzVzp6L3gsTNgw/FTicLOZVd2RwW17M 4AAmnf4vn/e8QXgPE8O0GBo/nx5Ib/jompXNNijrNJJAS/fz0oeJoZzT1t97lpp1Tb3R yXOg== X-Gm-Message-State: AOAM532Uc+m4vYx+hhMxiMOUg1qJCxKSRsQNPePP1bbGEkhCaWbBWBc0 TQdq5pNQlidMvM2JYwpSd1+qFEiZdTwpStKofZfWDe9uwn3BLw== X-Google-Smtp-Source: ABdhPJzziPcDQuz4TQjblMZD1JAXNMLMZpjQmJsS9Rx6AMjaqVgCdPZNzGN0u40sjDCVeQWUx6Dv6ENIvf73m5OaCmk= X-Received: by 2002:aa7:df84:: with SMTP id b4mr16204047edy.75.1598473232696; Wed, 26 Aug 2020 13:20:32 -0700 (PDT) MIME-Version: 1.0 References: <20200826201715.1911816-1-danielwinkler@google.com> In-Reply-To: <20200826201715.1911816-1-danielwinkler@google.com> From: Daniel Winkler <danielwinkler@google.com> Date: Wed, 26 Aug 2020 13:20:21 -0700 Message-ID: <CAP2xMbsk8FO2KM-aBGG7gZoAsmJnmTk_7h+35JOb3bo0SZFKuQ@mail.gmail.com> Subject: Re: [Bluez PATCH v1 0/3] Expose extended adv feature support via bluez API To: BlueZ <linux-bluetooth@vger.kernel.org> Cc: chromeos-bluetooth-upstreaming <chromeos-bluetooth-upstreaming@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.85 / 15.00 / 200.00 X-Rspamd-Queue-Id: ADAECA17C3 X-Rspamd-UID: 04a008 Hi Maintainers, I accidentally sent a patchset with PRE-UPSTREAM commit tags on the commit headings. I have sent another version without, so please ignore the former. Thanks for your understanding. Best regards, Daniel On Wed, Aug 26, 2020 at 1:17 PM Daniel Winkler <danielwinkler@google.com> wrote: > > Hi Maintainers, > > This change adds a SupportedFeatures member to the LEAdvertisingManager > interface, which allows us to expose support for hardware offloading and > setting TX power on advertisements. > > Best, > Daniel > > > Daniel Winkler (3): > PRE_UPSTREAM: advertising: Add SupportedFeatures to > LEAdvertisingManager1 > PRE_UPSTREAM: advertising: Add adv SupportedFeatures to bluetoothctl > PRE_UPSTREAM: advertising: Add adv SupportedFeatures to doc > > client/main.c | 1 + > doc/advertising-api.txt | 18 +++++++++++++ > lib/mgmt.h | 2 ++ > src/advertising.c | 56 +++++++++++++++++++++++++++++++++++++++-- > 4 files changed, 75 insertions(+), 2 deletions(-) > > -- > 2.28.0.297.g1956fa8f8d-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8IQNAAzGRl8GeAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 26 Aug 2020 22:29:00 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SEl7OQvGRl8y+wEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 26 Aug 2020 22:28:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1397B41753; Wed, 26 Aug 2020 22:28:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbgHZU2x (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 26 Aug 2020 16:28:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbgHZU2w (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 26 Aug 2020 16:28:52 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19AD8C061574 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:28:51 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id n129so3551161qkd.6 for <linux-bluetooth@vger.kernel.org>; Wed, 26 Aug 2020 13:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=CQhIl4nHHwVJWKs3yK9yKLoxI0mRlCyp2xDolKEbfKw=; b=rh2W6g/rLvSLnlVOlj+1HfRFaE8CdrvTTQ4PbBM/punKjH+fTrGlkPeg+fhmC5Xyj1 v5AFwWmw//5v5acHXamTy1w1Oyu/Jf21Ess57OMcyQfixWFqBsvgEKdeaqK3D7UKN4Du xYHXjDYK2zazCblwRH/hsMt4YXkSNd/2hEzsErnCW5X9WYiIaW7Qcvl2eXT3hyTbXbCz FkUnkpOQi7z56pYb+lCh66hCwkaujjxNWhVr5mJVyjuPLgroKIL8DqZP/9w2SJEH4egG tmG+drXhWGvj34ugYsFmz3Ydo4ktW0oKaYPVP9Jv/ThGl71HemtIUaPx7npR3zu26jKN mjow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=CQhIl4nHHwVJWKs3yK9yKLoxI0mRlCyp2xDolKEbfKw=; b=QFvwBEeNpacBNuJF5fA3+1iRft2bR2+kNTGfRWg7nHCympjl2zFrmsZT3nkVckZ2NK fukyYVdBAsblZRszr5NqV1ZPbFoX1tmbyjFfW2NoeOxZYL3MoG1Ez2tsB79Ip6RkjuSJ hxG00R3uDSQryWdGCidOEUQzAqAMV6uu2kEsXTgEp8aUiwrKzukrif1pLjW9X1JLEXKt ehwNjLPehtWrj5vcAU+TfBFwHnGHbMI+BfznIniDL1Rz5wSaLvi9I2XFMgIjqqL//63B n8y7fN0FfMtZDWqG3Hc6vJNzDAEHcGlXmHqLLuptTq+7z+ZWbmk3Mzj9lqx4UYX54qqP SAlA== X-Gm-Message-State: AOAM533q8JUlutT+hz1DCyNL99ym91TMmBEGvbILW0zxtrzAqHkqpqbi t+Y1IyDVza/kjpEKy6eF7uUO4p8QcdQ= X-Google-Smtp-Source: ABdhPJwa33zamg473GBXrHBYYGMJ1YY/Aaxljr+qTzvN4ukUuPVHWas80qZOkSsMNA13+tsqB4LLgg== X-Received: by 2002:a05:620a:1525:: with SMTP id n5mr15552829qkk.126.1598473730804; Wed, 26 Aug 2020 13:28:50 -0700 (PDT) Received: from [172.17.0.2] ([52.254.1.170]) by smtp.gmail.com with ESMTPSA id i18sm49404qtv.39.2020.08.26.13.28.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 13:28:50 -0700 (PDT) Message-ID: <5f46c602.1c69fb81.7ac52.04e2@mx.google.com> Date: Wed, 26 Aug 2020 13:28:50 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============5321790126634835349==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, danielwinkler@google.com Subject: RE: [Bluez,v1,1/3] PRE_UPSTREAM: advertising: Add SupportedFeatures to LEAdvertisingManager1 Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200826131103.Bluez.v1.1.Idf2f9f409a4df20b466ba723dd9b729275a5afbf@changeid> References: <20200826131103.Bluez.v1.1.Idf2f9f409a4df20b466ba723dd9b729275a5afbf@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1397B41753 X-Rspamd-UID: 6a1ba2 --===============5321790126634835349== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 1: T1 Title exceeds max length (73>72): "PRE_UPSTREAM: advertising: Add SupportedFeatures to LEAdvertisingManager1" --- Regards, Linux Bluetooth --===============5321790126634835349==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oG2+OMnOR19GjgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 17:18:33 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6LU5N8nOR1/G6wAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 17:18:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=edef.eu header.b=Kyfc+NSA; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=snMo+noG X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B106042118; Thu, 27 Aug 2020 17:18:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728397AbgH0PRa (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 27 Aug 2020 11:17:30 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:36983 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728662AbgH0LgZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 27 Aug 2020 07:36:25 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 359865C02A7; Thu, 27 Aug 2020 07:28:07 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 27 Aug 2020 07:28:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=edef.eu; h=from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=PVXMaRT6s2xDNwONmZIZUhlBy1 bqQ2JglZRPiGhzxk8=; b=Kyfc+NSAbbS14HQfQt68QDI/yH3ZtIFafXK+nDYWJ/ uC79vCJ2l0q6NAqkwABGTZyQ6K6fKBfK5L6D1tRP4LVezg9ZX91SHoh5D33+IhZ7 P8X7RaEBiJb2usf7E7IFEjMyBJ/GhC/anwox+ZA8CqIECLt/jkW2jupfxxKK396x JBlYMyqRk955J8UtAGnSkvBN7wufR76AhrtRWexaU5CTwZH9OeP/z/S0X3/Q/ARr iSrFevxsXR4V28gaU+2AUA10r7sMsb6ztZxPgrHxUE1eZX9rswHDIGcu7HnbJplQ b85VRvJhBtPYR4ojVKDmfUXnlFTYhDSZDuN2ulo1saTw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=PVXMaRT6s2xDNwONm ZIZUhlBy1bqQ2JglZRPiGhzxk8=; b=snMo+noGKVMj9zRqhzfPUKj9RHX5+hIVO Ij5hLRy2XliAjy6ziceb5p7yxtDFl60ZIUVGtQZXgRLuKOuZMfFb9zhqrXOlDQJZ N/fx0OGcKTK466q3l92IatNvxjzj6q/TTI/oYi83rTh3+9ys70Wajj8ksGMhPBEP /nvpbmoYyHS58C3rYb9gI5lTn5u839hju+HBfkuhvf/eOon/b1YXPJMyVKjUf9Ra 4egfHLJhVtFVhhFDMRc2QgbbZYqUgUgulYLjeYg/8TtoL7EbyNgutZ8e3Aqwnf47 TPoBZ60SkyxAUvdGf/j+AVHKHmNpqMONCtgYuCIhLfgHVdhuDARIw== X-ME-Sender: <xms:x5hHX0Rkytg3HRSlunxT956KksOp1QdFMiracz2CDdi1uki3smieHw> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddvgedgfeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomhepvgguvghfuceovgguvghfsegvuggvfhdrvghuqeenucggtffrrght thgvrhhnpeffteetheefleejveelffefheeiuddtgffhfeejlefhvefhueejuddvgeejfe ehudenucfkphepudelhedrvddtuddrvddtiedrudejfeenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegvuggvfhesvgguvghfrdgvuh X-ME-Proxy: <xmx:x5hHXxzl59Jjayv4BrDfcMiJHNUgEpnvwozZtitoMVzTLgIDgZJvcg> <xmx:x5hHXx0NxJkgvxjf0zdKEsNBg_FmEFgVrMjCC4j5wPiZ5kbfKIQEFA> <xmx:x5hHX4AP4R3jVOn29yEMT9I3aYfIrF2DlFQ-paEyN0s2K84UpZ2O_A> <xmx:x5hHX4uTgeweMubJdmK3pc9taN5cuI3NSYAJiKKCHwjpWdGBRQwjLg> Received: from localhost (uhura.edef.eu [195.201.206.173]) by mail.messagingengine.com (Postfix) with ESMTPA id C133D30600B4; Thu, 27 Aug 2020 07:28:06 -0400 (EDT) From: edef <edef@edef.eu> To: linux-bluetooth@vger.kernel.org Cc: edef <edef@edef.eu> Subject: [PATCH BlueZ] profiles/network: Log connection event after setting device name Date: Thu, 27 Aug 2020 11:27:59 +0000 Message-Id: <20200827112759.6914-1-edef@edef.eu> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.32 / 15.00 / 200.00 X-Rspamd-Queue-Id: B106042118 X-Rspamd-UID: 32b793 Without reordering these two statements, the logs look like this: bnep%d connected bnep0 disconnected --- profiles/network/connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles/network/connection.c b/profiles/network/connection.c index 97b87d02e..170841de6 100644 --- a/profiles/network/connection.c +++ b/profiles/network/connection.c @@ -216,9 +216,9 @@ static void bnep_conn_cb(char *iface, int err, void *data) goto failed; } + memcpy(nc->dev, iface, sizeof(nc->dev)); info("%s connected", nc->dev); - memcpy(nc->dev, iface, sizeof(nc->dev)); btd_service_connecting_complete(nc->service, 0); if (nc->connect) -- 2.27.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wE5qDlbzR18WBAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 19:54:30 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id MCMZDFbzR19gpAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 19:54:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E1F88A1202; Thu, 27 Aug 2020 19:54:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726321AbgH0RyX (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 27 Aug 2020 13:54:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726236AbgH0RyW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 27 Aug 2020 13:54:22 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2DB2C061264 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 10:54:21 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id 2so5351654ois.8 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 10:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fNCaMAIWNhN8jVlQ/Qo02eEyqA9Pcys7aVb+GnI1f+g=; b=lTkJhOEB1ePvUaPkQ7dOxsfO88SK408ZuMv+HKWutFbagiT1R8z5BQnjJasUdV+qHJ j1cF/iJFJvBmWgCLtiCMXzVZ7KmMjNP6czv+/N+IlxXGtfnBdvPPU3VivrwInEqbn9Mv O/t97RC5gwsJzqfTxZWDlzB0rtsbxoawhAvvsHL3Ni7dkc+L5bOyEU4jJNezEXGnhQn9 kcUs/S6ucLX9lRNyR2WYvnNdcBCyas4sXVxd48myouMNHyBJD+2yVhykvfUcBIVR8Srn bjIU5Do/glut/OLBC3/Ae5ZUw605AxxWvttbDEGeR8ZWg2b31z7rETTOXFyqGEMxa1Fn jJvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fNCaMAIWNhN8jVlQ/Qo02eEyqA9Pcys7aVb+GnI1f+g=; b=B6rjzQHXKeFbXrnydOuCUPXP4wGe0SIabOa2Y2z2csjo2w+eDCMrruPyrdNKgYGF7R 6jfswh0+NCgUif1cUYQ1Fqftqde87vTnD0LOIrnUErgycifYUB65z6RbpD5NUQTUi+2f cAiNno01NV8zrFu4y3QO7xLHg5NSswd736q8DhS0Y5HWNTf5RP9fwaB3QRmX1PCNKBVd HXx8/Iaw8XTYhuTPrCnafaHwSYgpTgFxdumyjB9FfNgyRw28h9hb2/UWSLxHlSqqHkNz PGZr/Z55dS4NOj5MIrLeTrlaHH3HrK8BqHweenjlqg168ZuGz+hFecPrNxImPJZEHMcC oH/w== X-Gm-Message-State: AOAM530Nn1lGJ1qsz05YS8Cyu2QXwsh9giBciZ2zKLuJ9hqmF2+0jX/G GgFyVXsR7yy8W1AC6PB5K3OTEXOGDuFM+CEyhYIB6h8m X-Google-Smtp-Source: ABdhPJxm1xBHGK6oxfhMizCWMo0DKVce2q54uthG2vQXpWpZoYpq64Xmatui9z1DulKlB1B2AxD5GX8r9rXBK22fc28= X-Received: by 2002:aca:a9c9:: with SMTP id s192mr31369oie.152.1598550861227; Thu, 27 Aug 2020 10:54:21 -0700 (PDT) MIME-Version: 1.0 References: <20200824111837.Bluez.v3.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> In-Reply-To: <20200824111837.Bluez.v3.1.I21d21871d85db48b07ba847742c7cb933024307c@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 27 Aug 2020 10:54:10 -0700 Message-ID: <CABBYNZ+BrKk_-bgLb1HZGi2Xpiqm+xSgXZfK_w987wfd3oBTMg@mail.gmail.com> Subject: Re: [Bluez PATCH v3] adapter - Device needs to be in the temporary state after pairing failure To: Yu Liu <yudiliu@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.20 / 15.00 / 200.00 X-Rspamd-Queue-Id: E1F88A1202 X-Rspamd-UID: 31ef42 Hi Yu Liu, On Mon, Aug 24, 2020 at 11:30 AM Yu Liu <yudiliu@google.com> wrote: > > This caused the device hanging around as a discovered device forever > even if it is turned off or not in present. > > Reviewed-by: sonnysasaka@chromium.org > --- > > Changes in v3: > - Fix comment format > - Don't set temporary for trusted device > > Changes in v2: > - Fix title length and format issue > > Changes in v1: > - Initial change > > src/device.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/src/device.c b/src/device.c > index bb8e07e8f..103b5df27 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -6008,6 +6008,14 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, > > if (status) { > device_cancel_authentication(device, TRUE); > + > + /* Put the device back to the temporary state so that it will be > + * treated as a newly discovered device. > + */ > + if (!device_is_paired(device, bdaddr_type) && > + !device_is_trusted(device)) > + btd_device_set_temporary(device, true); > + > device_bonding_failed(device, status); > return; > } > -- > 2.28.0.297.g1956fa8f8d-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IHUUBnnzR18WBAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 19:55:05 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 8LgWBHnzR19OQQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 19:55:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 28629A1443; Thu, 27 Aug 2020 19:55:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727046AbgH0Ryy (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 27 Aug 2020 13:54:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727008AbgH0Ryv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 27 Aug 2020 13:54:51 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 260BEC061264 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 10:54:51 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id n23so5109768otq.11 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 10:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FxWSHY4tkPz7kEIppnRnRKwJg/ftBtShNG0VfcOcllg=; b=ROO70edLc3yR8M4k/6F4f7W67wSQ493oDcm8IK5ZVfLv//zwHrYYm4oGp85zwEW2Gb eqLymJ++shHHrd3DFWCiUTSefTaDYPtZkkBVtb0p2n0gJWEZ1VyPec1qbUWF/Eh0jH1/ cLTh3wufLPAifohZABvLSwfeqneqrCY1BWdYULvE58wIbdmjCXRR3HNjEMKHLRmgAksg 4cBW+Kic/KNEA3rJG+A6LMoDbpwKaRYI5HH0KH8lLV/xNNN8VdXbcyC0znTEC4mIDnw7 Sf1WMRrgcLN/X/zleThohYArLx4AZO/rSLdLfakC4/979qZyRETjwODDqsDjKAhDCNDA sDkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FxWSHY4tkPz7kEIppnRnRKwJg/ftBtShNG0VfcOcllg=; b=DCoRDSZHlHQ+VVOWbsxBk6g1LmYPeaAOmk3ZvexG2POojCc5xkt/Oxxr3Scf1l4HzB +eFwuceMJfjT7jKZMGTlfBEYNEut8kt85VLj2K3wUwh7jaAJVRNhpw9IHh+Qz4XHbIKR ecQMxOugQ32VWcgkwRx8vxkN6onLW7g/WTQc8noyDk6gmb8lf2n5aCZQZ9m4Ow0nVPDW F+p+j62+bRcYbgHBn+jE0LyStxiMISnGyVX9HKYFgLgI0Yewo7IXZpy2hQhPzqvsSnXu otKbGKr4hf6EhGZPBTsAPQTJMuMLZH4hqNWQn1vroB7KatXbMiQL9rzPBm9xa0447lZh bPag== X-Gm-Message-State: AOAM532SoSNpHLFY+X7ClXR19Z+04WcEDjP0r4Imr9cMd6gqQhnL+pIY 5PPdiOIpdCqKBOECvlfcXkmpGhDw/YNWd9S3UEm1yuMb X-Google-Smtp-Source: ABdhPJz29ZWvS/3nQqb4tWNOcZtjJwAdCUZj/cSBtc9JTb9//jrN/7vKdxhu5IQyviG9G98CSYmmuUkVavYoREwqQO4= X-Received: by 2002:a9d:6053:: with SMTP id v19mr13543766otj.362.1598550890523; Thu, 27 Aug 2020 10:54:50 -0700 (PDT) MIME-Version: 1.0 References: <20200826063742.76007-1-sonnysasaka@chromium.org> In-Reply-To: <20200826063742.76007-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 27 Aug 2020 10:54:39 -0700 Message-ID: <CABBYNZ+EPTW1OHcZj_JYRrpbKy0zMbLQ9gc2yRCntxfEJDwXdw@mail.gmail.com> Subject: Re: [PATCH BlueZ] gatt: Accept empty array in parse_includes() To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Jie Jiang <jiejiang@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 28629A1443 X-Rspamd-UID: 7a2cf2 Hi Sonny, On Tue, Aug 25, 2020 at 11:43 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > From: Jie Jiang <jiejiang@chromium.org> > > Currently parse_includes() will return false if the "Includes" property > is an empty array. Empty array in the "Includes" property should be > treated as valid. > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > --- > src/gatt-database.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/src/gatt-database.c b/src/gatt-database.c > index 07d567078..e7e4a36a6 100644 > --- a/src/gatt-database.c > +++ b/src/gatt-database.c > @@ -2008,6 +2008,7 @@ static bool parse_includes(GDBusProxy *proxy, struct external_service *service) > DBusMessageIter iter; > DBusMessageIter array; > char *obj; > + int type; > > /* Includes property is optional */ > if (!g_dbus_proxy_get_property(proxy, "Includes", &iter)) > @@ -2018,9 +2019,9 @@ static bool parse_includes(GDBusProxy *proxy, struct external_service *service) > > dbus_message_iter_recurse(&iter, &array); > > - do { > - if (dbus_message_iter_get_arg_type(&array) != > - DBUS_TYPE_OBJECT_PATH) > + while ((type = dbus_message_iter_get_arg_type(&array)) > + != DBUS_TYPE_INVALID) { > + if (type != DBUS_TYPE_OBJECT_PATH) > return false; > > dbus_message_iter_get_basic(&array, &obj); > @@ -2028,11 +2029,12 @@ static bool parse_includes(GDBusProxy *proxy, struct external_service *service) > if (!queue_push_tail(service->includes, obj)) { > error("Failed to add Includes path in queue\n"); > return false; > - > } > > incr_attr_count(service, 1); > - } while (dbus_message_iter_next(&array)); > + > + dbus_message_iter_next(&array); > + } > > return true; > } > -- > 2.26.2 Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GAbBJY/zR18e2AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 19:55:27 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +O4rJI/zR19OQQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 19:55:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 07BF4A15ED; Thu, 27 Aug 2020 19:55:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726995AbgH0RzW (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 27 Aug 2020 13:55:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbgH0RzW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 27 Aug 2020 13:55:22 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89620C061264 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 10:55:21 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id j18so5364129oig.5 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 10:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=j6hmv2VFrPeKS/IkOSA+hkC5KX7drhT9XYW0bLgpA3U=; b=BQ8oPgF/o6AAMz7GIPagL6Lwu5cj0QWvvkwsXuyR8GaqfulfFjL+ZPxw7VBPlk7lm+ sh7wnwUEh9N89rKlW/GkmClqryvDoGBRjQaPkb4Yzp4FXnydH5V2UWndYPlX9qhbUDOf G0M6QS2bIbO7IhrrMgtpduU8wB//sdPhfXvkSWnHQK7CQXi0mfYqeuk9XHn9YfX+YKov sqkFPMXem0vnnYXqgx0ZnrI177ms/IH2WfMn9YhWw8deQPO0WAwBo0YPipgXmQNQ6m+j mhBTyA+4jgcGaOHVCGmoMKPUkA/y/t9F4hOfA2B2YpvKZ3Ne2cCRej0FMVTxP1yiGiCR UWwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=j6hmv2VFrPeKS/IkOSA+hkC5KX7drhT9XYW0bLgpA3U=; b=oKIEZJa2ABccdquoZoBca9YL5oHgtvh5cDPM9JTBkXgQ8N97RNEN8aL7rXRycDVz55 bb+CQeSMJ0pbxFEsj0Hb29nm5yLfWx7Jsqk8AY6Ga4RrpaMJWjzV0TG/TsK7RxzUuIwA iMMqlfUsOuGbkO8zROr0xWSe+/qz1vhMqfdmtdLiA4ygqMrFD9o7fZDpoCThCUQJ4SLU k+EGHyxeGM+0CBHhroO9+jdJ0ON9mxVY/KgDpPVJ5PnS65ZoAReHnCrABxZBNnUSOSyH RzIW8K6nAShYmG7/buF9ZsW0hHycLxSX9Qa0HFUtE3fwSoIfADiYcvpc42plc8oo2h3r 7RHw== X-Gm-Message-State: AOAM530bwqGU/IZNY2kAQ+a/C8pfyeBQdP7BAFtDyo2RtrgcJsc/jVFZ SnBwCH1rB9FvgJQOfybbRNwK2vRhvCgF6hjB6HMvKt5A X-Google-Smtp-Source: ABdhPJzgU9bnHtYx7CfPUQRm3iU7mLLt59US/YRzVw2ThY1+EiyeYDXRAPpZxX72eduvIjASz/wGFIT8Nz1QZQWXIyQ= X-Received: by 2002:a54:478f:: with SMTP id o15mr17474oic.137.1598550920962; Thu, 27 Aug 2020 10:55:20 -0700 (PDT) MIME-Version: 1.0 References: <20200827112759.6914-1-edef@edef.eu> In-Reply-To: <20200827112759.6914-1-edef@edef.eu> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 27 Aug 2020 10:55:10 -0700 Message-ID: <CABBYNZJ8QzWF88BoxK3CbxhNiyWONfzZx5ChyD_ZB8BRXp1m-g@mail.gmail.com> Subject: Re: [PATCH BlueZ] profiles/network: Log connection event after setting device name To: edef <edef@edef.eu> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.20 / 15.00 / 200.00 X-Rspamd-Queue-Id: 07BF4A15ED X-Rspamd-UID: 064a41 Hi Edef, On Thu, Aug 27, 2020 at 8:21 AM edef <edef@edef.eu> wrote: > > Without reordering these two statements, the logs look like this: > > bnep%d connected > bnep0 disconnected > --- > profiles/network/connection.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/profiles/network/connection.c b/profiles/network/connection.c > index 97b87d02e..170841de6 100644 > --- a/profiles/network/connection.c > +++ b/profiles/network/connection.c > @@ -216,9 +216,9 @@ static void bnep_conn_cb(char *iface, int err, void *data) > goto failed; > } > > + memcpy(nc->dev, iface, sizeof(nc->dev)); > info("%s connected", nc->dev); > > - memcpy(nc->dev, iface, sizeof(nc->dev)); > btd_service_connecting_complete(nc->service, 0); > > if (nc->connect) > -- > 2.27.0 Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EAqEEWkYSF9G5gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 22:32:41 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id EKocEGkYSF89RgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 22:32:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 371D1A1DE2; Thu, 27 Aug 2020 22:32:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726266AbgH0Ucf (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 27 Aug 2020 16:32:35 -0400 Received: from fgw23-4.mail.saunalahti.fi ([62.142.5.110]:36680 "EHLO fgw23-4.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726147AbgH0Ucf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 27 Aug 2020 16:32:35 -0400 X-Greylist: delayed 963 seconds by postgrey-1.27 at vger.kernel.org; Thu, 27 Aug 2020 16:32:35 EDT Received: from ydin.reaktio.net (reaktio.net [85.76.255.15]) by fgw23.mail.saunalahti.fi (Halon) with ESMTP id 30dabc35-e8a2-11ea-8ccc-005056bdfda7; Thu, 27 Aug 2020 23:16:29 +0300 (EEST) Received: by ydin.reaktio.net (Postfix, from userid 1001) id EFFC036C0F6; Thu, 27 Aug 2020 23:16:28 +0300 (EEST) Date: Thu, 27 Aug 2020 23:16:28 +0300 From: Pasi =?iso-8859-1?Q?K=E4rkk=E4inen?= <pasik@iki.fi> To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann <marcel@holtmann.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Subject: Bluez 5.55 release? Message-ID: <20200827201628.GA3296@reaktio.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.89 / 15.00 / 200.00 X-Rspamd-Queue-Id: 371D1A1DE2 X-Rspamd-UID: edef95 Hello all, It has been a while since the previous release, so how about new bluez 5.55 release? Is there a plan for next release, certain features/patches that need to be finished before cutting a release? Thanks a lot, -- Pasi Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EJ2pJuIgSF8rtAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 23:08:50 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id WMMAJeIgSF8i2QEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 23:08:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B71B3A13DC; Thu, 27 Aug 2020 23:08:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726266AbgH0VIo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 27 Aug 2020 17:08:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbgH0VIn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 27 Aug 2020 17:08:43 -0400 Received: from mail-vk1-xa42.google.com (mail-vk1-xa42.google.com [IPv6:2607:f8b0:4864:20::a42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A05B9C061264 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 14:08:43 -0700 (PDT) Received: by mail-vk1-xa42.google.com with SMTP id i20so1588453vkk.2 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 14:08:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GAonxVXwemSpfwsUjEPqFBgj9h8pDq7GxQ1LeKwzzmY=; b=I23q2YPDxS8sLhSIFOGgi/rdfxOHGqTx+cfgtqzZHnNlc8V9j13LvPc1mqINXPGslL iQ2qdj8MowGx+k6mILDqXnvLIWvUF6ut3iyD1hHSYeLK+Xgcrhz8kbkOo4FSQxW/Whlr VjdEjSAbIrRbtcBfuVUQ4JHxNr90SBT2T6Xf4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GAonxVXwemSpfwsUjEPqFBgj9h8pDq7GxQ1LeKwzzmY=; b=PRVyRUdn5xBBBEM5PGpHq/qOdFnQ8XFrgkKpQ9WUwFxt/byLHwckmHwkYiyfnZZcVh 5iyKzAwOuHMdxIL3iAEA1XLDVvwhWFlRCZd5H0nCQ8jHasRCKBwEIkmcAjL87Yq4ANHX 5WAdwm/lgzpcPWrtWIH//Ac1vQHsueqZSfaW8JtRm0lEOOA5zNxav5w7vWZ7kmFt0Kvc JjuJ2i27MQCxXZxCLKEScA7oV+N2ANgqntofP906sm7wsq9yRDEdqwqCiZuWhkhFQfcM 4eBnSPKYwcu5tRzr7yaQH92rmtPfT7nmcpY/8dE63D418GCN1q2IVNb5TJBb2P8gI2/l oO9A== X-Gm-Message-State: AOAM531EuRlyX9ttemwbSoduSrRWPmJtDIFUkpLCJtLQQtxLKhnHRpAh /6JF+2DN/tXPW+COxp+GDNe2Ho9UWjCdvPFiVyj9Pw== X-Google-Smtp-Source: ABdhPJzNZRrVJ7oHvJzKGXn2ywkzyd4d3RtzOGRPgt2LvrvbU0o+klR5h1S+JIanyd+g3Tzsef1ll5JB7QKMBb9kLbE= X-Received: by 2002:a1f:acc5:: with SMTP id v188mr3538928vke.45.1598562522635; Thu, 27 Aug 2020 14:08:42 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> <20200818162807.Bluez.v2.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> <CABBYNZLb_ETfO1VyAf+1rXpRT_XroQLq7u=uK6PGcrOKR7PHxA@mail.gmail.com> In-Reply-To: <CABBYNZLb_ETfO1VyAf+1rXpRT_XroQLq7u=uK6PGcrOKR7PHxA@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Thu, 27 Aug 2020 14:08:28 -0700 Message-ID: <CANFp7mV03KvqpOH=LBU=0tBDhgK5K2YJ6rxYvkDKmyer4n_gLw@mail.gmail.com> Subject: Re: [Bluez PATCH v2 3/3] policy: Reconnect audio on controller resume To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: B71B3A13DC X-Rspamd-UID: 40bf7f Hi Luiz, On Wed, Aug 26, 2020 at 11:32 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Abhishek, > > On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > During system suspend, all peer devices are disconnected. On resume, HID > > devices will reconnect but audio devices stay disconnected. As a quality > > of life improvement, mark audio devices that were disconnected due to > > suspend and attempt to reconnect them when the controller resumes (after > > a delay for better co-existence with Wi-Fi). > > > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > --- > > > > Changes in v2: > > - Refactored to use policy instead of connecting directly in adapter > > > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > > src/adapter.h | 6 +++++ > > src/main.c | 1 + > > src/main.conf | 9 +++++++ > > 5 files changed, 121 insertions(+), 4 deletions(-) > > > > diff --git a/plugins/policy.c b/plugins/policy.c > > index de51e58b9..b07a997b9 100644 > > --- a/plugins/policy.c > > +++ b/plugins/policy.c > > @@ -75,6 +75,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; > > static int *reconnect_intervals = NULL; > > static size_t reconnect_intervals_len = 0; > > > > +static const int default_reconnect_delay = 5; > > +static int resume_reconnect_delay = 5; > > + > > static GSList *reconnects = NULL; > > > > static unsigned int service_id = 0; > > @@ -93,6 +96,8 @@ struct policy_data { > > uint8_t ct_retries; > > guint tg_timer; > > uint8_t tg_retries; > > + > > + bool reconnect_on_resume; > > }; > > > > static struct reconnect_data *reconnect_find(struct btd_device *dev) > > @@ -214,6 +219,7 @@ static gboolean policy_connect_sink(gpointer user_data) > > > > data->sink_timer = 0; > > data->sink_retries++; > > + data->reconnect_on_resume = false; > > > > service = btd_device_get_service(data->dev, A2DP_SINK_UUID); > > if (service != NULL) > > @@ -222,16 +228,20 @@ static gboolean policy_connect_sink(gpointer user_data) > > return FALSE; > > } > > > > -static void policy_set_sink_timer(struct policy_data *data) > > +static void policy_set_sink_timer_internal(struct policy_data *data, int timeout) > > { > > if (data->sink_timer > 0) > > g_source_remove(data->sink_timer); > > > > - data->sink_timer = g_timeout_add_seconds(SINK_RETRY_TIMEOUT, > > - policy_connect_sink, > > + data->sink_timer = g_timeout_add_seconds(timeout, policy_connect_sink, > > data); > > } > > > > +static void policy_set_sink_timer(struct policy_data *data) > > +{ > > + policy_set_sink_timer_internal(data, SINK_RETRY_TIMEOUT); > > +} > > + > > static void sink_cb(struct btd_service *service, btd_service_state_t old_state, > > btd_service_state_t new_state) > > { > > @@ -743,10 +753,30 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) > > static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > { > > struct reconnect_data *reconnect; > > + struct btd_service *service; > > + struct policy_data *data; > > + bool do_reconnect = false; > > > > DBG("reason %u", reason); > > > > - if (reason != MGMT_DEV_DISCONN_TIMEOUT) > > + switch(reason) { > > + case MGMT_DEV_DISCONN_LOCAL_HOST: > > + case MGMT_DEV_DISCONN_REMOTE: > > + do_reconnect = true; > > + break; > > + /* Disconnect due to suspend will queue reconnect on resume for a2dp */ > > + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: > > + service = btd_device_get_service(dev, A2DP_SINK_UUID); > > + if (service && (data = policy_get_data(dev))) { > > + data->reconnect_on_resume = true; > > + } > > Can't we just program the timer directly here? Or would that wakeup > the system, I would imagine all timers are disabled while suspended > which means when the system resumes so does the timers which would > then trigger the reconnection logic. This approach works if every resume is user initiated and keeps the device awake long enough to reconnect to the audio device. On ChromeOS, this isn't always the case. We have a feature called Dark Resume that occurs when the system wakes to handle an event that doesn't require user intervention and suspends again without ever turning on the screen. See: https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/docs/dark_resume.md. A primary user for this is a periodic wake-up that checks battery percentage and shuts down the system if it's too low. One of the tests I ran specifically for this is a suspend stress test with a wake time between 2-4s (i.e. suspend_stress_test -c 10 --wake_min 2 --wake_max 3) which emulates dark resumes. If we set the timer when disconnecting, the device would attempt a connection on one of the wakeups and fail (since we suspended without completing the connection). > > > + break; > > + /* All other cases do not result in reconnect */ > > + default: > > + break; > > + } > > + > > + if (!do_reconnect) > > return; > > > > reconnect = reconnect_find(dev); > > @@ -761,6 +791,23 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > reconnect_set_timer(reconnect); > > } > > > > +static void controller_resume_cb(uint8_t wake_reason, const bdaddr_t *addr, > > + const uint8_t addr_type) > > +{ > > + struct btd_device *dev; > > + GSList *l; > > + > > + /* Check if any devices needed to be reconnected on resume */ > > + for (l = devices; l; l = g_slist_next(l)) { > > + struct policy_data *data = l->data; > > + > > + if (data->reconnect_on_resume) { > > + policy_set_sink_timer_internal(data, > > + resume_reconnect_delay); > > + } > > + } > > +} > > + > > static void conn_fail_cb(struct btd_device *dev, uint8_t status) > > { > > struct reconnect_data *reconnect; > > @@ -854,9 +901,17 @@ static int policy_init(void) > > auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", > > NULL); > > > > + resume_reconnect_delay = g_key_file_get_integer( > > + conf, "Policy", "ReconnectAudioDelay", &gerr); > > + > > + if (gerr) { > > + g_clear_error(&gerr); > > + resume_reconnect_delay = default_reconnect_delay; > > + } > > done: > > if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { > > btd_add_disconnect_cb(disconnect_cb); > > + btd_add_controller_resume_cb(controller_resume_cb); > > btd_add_conn_fail_cb(conn_fail_cb); > > } > > > > @@ -869,6 +924,7 @@ done: > > static void policy_exit(void) > > { > > btd_remove_disconnect_cb(disconnect_cb); > > + btd_remove_controller_resume_cb(controller_resume_cb); > > btd_remove_conn_fail_cb(conn_fail_cb); > > > > if (reconnect_uuids) > > diff --git a/src/adapter.c b/src/adapter.c > > index 5e896a9f0..7526feb9e 100644 > > --- a/src/adapter.c > > +++ b/src/adapter.c > > @@ -139,6 +139,7 @@ static GSList *adapter_drivers = NULL; > > > > static GSList *disconnect_list = NULL; > > static GSList *conn_fail_list = NULL; > > +static GSList *controller_resume_list = NULL; > > > > struct link_key_info { > > bdaddr_t bdaddr; > > @@ -8766,6 +8767,45 @@ static void connected_callback(uint16_t index, uint16_t length, > > eir_data_free(&eir_data); > > } > > > > +static void controller_resume_notify(const uint8_t wake_reason, > > + const bdaddr_t *addr, > > + const uint8_t addr_type) > > +{ > > + GSList *l; > > + > > + for (l = controller_resume_list; l; l = g_slist_next(l)) { > > + btd_controller_resume_cb resume_cb = l->data; > > + resume_cb(wake_reason, addr, addr_type); > > + } > > +} > > + > > +static void controller_resume_callback(uint16_t index, uint16_t length, > > + const void *param, void *user_data) > > +{ > > + const struct mgmt_ev_controller_resume *ev = param; > > + struct btd_adapter *adapter = user_data; > > + > > + if (length < sizeof(*ev)) { > > + btd_error(adapter->dev_id, "Too small device resume event"); > > + return; > > + } > > + > > + DBG("Controller resume with wake event 0x%x", ev->wake_reason); > > + > > + controller_resume_notify(ev->wake_reason, &ev->addr.bdaddr, > > + ev->addr.type); > > +} > > + > > +void btd_add_controller_resume_cb(btd_controller_resume_cb func) > > +{ > > + controller_resume_list = g_slist_append(controller_resume_list, func); > > +} > > + > > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func) > > +{ > > + controller_resume_list = g_slist_remove(controller_resume_list, func); > > +} > > + > > static void device_blocked_callback(uint16_t index, uint16_t length, > > const void *param, void *user_data) > > { > > @@ -9389,6 +9429,11 @@ static void read_info_complete(uint8_t status, uint16_t length, > > user_passkey_notify_callback, > > adapter, NULL); > > > > + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, > > + adapter->dev_id, > > + controller_resume_callback, > > + adapter, NULL); > > + > > set_dev_class(adapter); > > > > set_name(adapter, btd_adapter_get_name(adapter)); > > diff --git a/src/adapter.h b/src/adapter.h > > index f8ac20261..5527e4205 100644 > > --- a/src/adapter.h > > +++ b/src/adapter.h > > @@ -67,6 +67,12 @@ typedef void (*btd_conn_fail_cb) (struct btd_device *device, uint8_t status); > > void btd_add_conn_fail_cb(btd_conn_fail_cb func); > > void btd_remove_conn_fail_cb(btd_conn_fail_cb func); > > > > +typedef void (*btd_controller_resume_cb)(const uint8_t wake_reason, > > + const bdaddr_t *addr, > > + const uint8_t addr_type); > > +void btd_add_controller_resume_cb(btd_controller_resume_cb func); > > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func); > > If we can program the timer just before we suspend this is not really > necessary, but if you still thing that would be a good idea to notify > Id put it in btd_adapter_driver with a callback for suspend and > resume, that way we don't have to maintain multiple lists for each of > the callbacks. The adapter driver seems like a reasonable place to put this so let me port that over. > > > struct btd_adapter *adapter_find(const bdaddr_t *sba); > > struct btd_adapter *adapter_find_by_id(int id); > > void adapter_foreach(adapter_cb func, gpointer user_data); > > diff --git a/src/main.c b/src/main.c > > index 2c083de67..a1c3e7e9f 100644 > > --- a/src/main.c > > +++ b/src/main.c > > @@ -131,6 +131,7 @@ static const char *policy_options[] = { > > "ReconnectAttempts", > > "ReconnectIntervals", > > "AutoEnable", > > + "ReconnectAudioDelay", > > NULL > > }; > > > > diff --git a/src/main.conf b/src/main.conf > > index f41203b96..8d74a2aec 100644 > > --- a/src/main.conf > > +++ b/src/main.conf > > @@ -198,3 +198,12 @@ > > # This includes adapters present on start as well as adapters that are plugged > > # in later on. Defaults to 'false'. > > #AutoEnable=false > > + > > +# Audio devices that were disconnected due to suspend will be reconnected on > > +# resume. ReconnectAudioDelay determines the delay between when the controller > > +# resumes from suspend and a connection attempt is made. A longer delay can be > > +# better for co-existence with Wi-Fi. > > +# The value is in seconds. > > +# Default: 5 > > +#ReconnectAudioDelay = 5 > > + > > -- > > 2.28.0.297.g1956fa8f8d-goog > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yDidOQAiSF8rtAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 23:13:36 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yOugNwAiSF+q1AEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 23:13:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3974D420DE; Thu, 27 Aug 2020 23:13:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726234AbgH0VN3 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 27 Aug 2020 17:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726073AbgH0VN3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 27 Aug 2020 17:13:29 -0400 Received: from mail-vk1-xa41.google.com (mail-vk1-xa41.google.com [IPv6:2607:f8b0:4864:20::a41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E944C061264 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 14:13:28 -0700 (PDT) Received: by mail-vk1-xa41.google.com with SMTP id x142so1590921vke.0 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 14:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OJMIcRuoc4PEJP8Cu7uCzH3gpj+jS0eHFU0v1DVRwQU=; b=D6TOPJy/EOu2QFp/Hm7uIT3bhvHnCvdwriKZVdbKlFWF/xPYy1guHq5+S5Jig+T+gl VIuveAL9m4LJHHnAcSd1zTzOWJIuleY+LGKEE3LM7JmqkrHTrvkpQQ0XdApE7NeBgnOF +eyBMtxcOXXZLHPeL5AHwfRsatfhEBy0CE+bY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OJMIcRuoc4PEJP8Cu7uCzH3gpj+jS0eHFU0v1DVRwQU=; b=UPotu5xxz5/HtKAKIc8oQNVNopvbGYquYa9W1Dd3auMsAen+LhCp2sL0k4IuHyZPb6 mbM3XgYSvLHjjmv+kbwsTElbnuUs95OONtCNPtRtIdNEh3zKPGJL4ebyH2kLHDgn0MWV 8yYm5QFQrWzxhxL+eixpheWQgXBVrPP6FQkXRxGB0kXyNSLI4WEWtRWQJdj8OVFS7QtK iNnCtPKnjL/b8vzIJ/3rAVPzgka9wAD5Vf842MEqJc3BCLitHOYWZsRQ7ohJUfcUKxan GL1NblpFlQPbvuHe3WmVbE1uLa7/cP54UYASEuRgnkhnmyPzmJAQEJvbn2ZHx05SzcTo OgZg== X-Gm-Message-State: AOAM532TIZC27CN3rbytyHmcrlJHsehC5oCNrGPqIlVQEhu21wE60vk8 U06rqHG+qXcl1WMYCLb/CHvR0TJmDO8Sdoe+CXOTgg== X-Google-Smtp-Source: ABdhPJyUNcuR0/Os0y26GBIYBrO68UQTfqjN/iP78rZAqcOIVdUKzKv7fdolRmfeYPz+I2I3mZLlJ/KahcYSewRtDa4= X-Received: by 2002:a1f:9bc6:: with SMTP id d189mr14379177vke.54.1598562807235; Thu, 27 Aug 2020 14:13:27 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> <CANFp7mWqT1mO0OcJAt4AycTgFLz22p7zyRGjR1Hvj4bJmHHsTw@mail.gmail.com> <CABBYNZLmfWWBYZjHDkHmMpzYC02zFpWMV_xAiD1pK3cc09JwSA@mail.gmail.com> In-Reply-To: <CABBYNZLmfWWBYZjHDkHmMpzYC02zFpWMV_xAiD1pK3cc09JwSA@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Thu, 27 Aug 2020 14:13:13 -0700 Message-ID: <CANFp7mWf1xDg6+nLMyrjaMaqF0=GyhauwN43ny5QMT0MWYd+tA@mail.gmail.com> Subject: Re: [Bluez PATCH v2 0/3] adapter: Reconnect audio when resuming from suspend To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3974D420DE X-Rspamd-UID: 9f4b92 Hi Luiz, On Wed, Aug 26, 2020 at 11:21 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Abhishek, > > On Wed, Aug 26, 2020 at 10:41 AM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > Hi Luiz, > > > > Could you PTAL at this v2 patch series. I refactored the audio > > reconnect to use the policy plugin instead of doing the reconnect as > > part of the adapter logic, as requested. > > > > Thanks > > Abhishek > > > > On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi > > <abhishekpandit@chromium.org> wrote: > > > > > > > > > Hi Luiz and Marcel, > > > > > > This is a quality of life improvement for the behavior of audio devices > > > during system suspend. This depends on a kernel change that emits > > > suspend/resume events: > > > > > > https://patchwork.kernel.org/project/bluetooth/list/?series=325771 > > So we could not just use the disconnect reason like I suggested? I am using the disconnect reason to mark the device for reconnection and only queueing it for reconnect on resume. As mentioned in the patch, this is to account for resumes that are not user driven and will suspend almost immediately again (i.e. periodic wake up to check battery level and see if we need to shut down). > > > > Right now, audio devices will be disconnected as part of suspend but > > > won't be reconnected when the system resumes without user interaction. > > > This is annoying to some users as it causes an interruption to their > > > normal work flow. > > > > > > This change reconnects audio devices that were disconnected for suspend > > > using the following logic: > > > > > > * Register a callback for controller resume in the policy plugin. > > > * In the device disconnect callback, mark any devices with the A2DP > > > service uuid for reconnect on resume after a delay. > > > * In the controller resume callback, queue any policy items that are > > > marked to reconnect on resume for connection with the > > > ReconnectAudioDelay value (default = 5s for Wi-Fi coexistence). > > Something like ResumeDelay would probably be better. Sure, I will rename this. > > > > A reconnect is only attempted once after the controller resumes and the > > > delay between resume and reconnect is configurable via the > > > ReconnectAudioDelay key in the Policy settings. The 5s delay was chosen > > > arbitrarily and I think anywhere up to 10s is probably ok. A longer > > > delay is better to account for spurious wakeups and Wi-Fi reconnection > > > time (avoiding any co-ex issues) at the downside of reconnection speed. > > I would keep the same logic as out of range so the platforms can > customize the number of attempts. So the first reconnect attempt after resume should be separately configurable (i.e. 5s) but subsequent reconnect attempts would use the reconnect-intervals values? That sounds good to me. > > > > Here are the tests I have done with this: > > > - Single suspend and verified the headphones reconnect > > > - Suspend stress test for 25 iterations and verify both Wi-Fi and > > > Bluetooth audio reconnect on resume. (Ran with wake minimum time of > > > 10s) > > > - Suspend test with wake time < 5s to verify that BT reconnect isn't > > > attempted. Ran 5 iterations with low wake time and then let it stay > > > awake to confirm reconnect finally completed after 5s+ wake time. > > > - Suspend test with wake time between 3s - 6s. Ran with 5 iterations and > > > verified it wasn't connected at the end. A connection attempt was > > > made but not completed due to suspend. A reconnect attempt was not > > > made afterwards, which is by design. > > > > > > Luiz@ Marcel@: Does this sound ok (give up after an attempt)? > > > > > > I've tested this on a Pixelbook Go (AC-9260 controller) and HP > > > Chromebook 14a (RTL8822CE controller) with GID6B headset. > > > > > > I've also tested this with the Pixel Buds 2. These earbuds actually > > > reconnect automatically to the Chromebook (even without this policy > > > change) and I verified that the new changes don't break the reconnection > > > mechanism. > > > > > > Thanks > > > Abhishek > > > > > > > > > Changes in v2: > > > - Refactored to use policy instead of connecting directly in adapter > > > > > > Abhishek Pandit-Subedi (3): > > > mgmt: Add controller suspend and resume events > > > monitor: Add btmon support for Suspend and Resume events > > > policy: Reconnect audio on controller resume > > > > > > lib/mgmt.h | 14 +++++++++++ > > > monitor/packet.c | 55 +++++++++++++++++++++++++++++++++++++++++ > > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > > > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > > > src/adapter.h | 6 +++++ > > > src/main.c | 1 + > > > src/main.conf | 9 +++++++ > > > 7 files changed, 190 insertions(+), 4 deletions(-) > > > > > > -- > > > 2.28.0.297.g1956fa8f8d-goog > > > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0NsvFUYjSF8viAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 27 Aug 2020 23:19:02 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id qLOkE0YjSF9hewEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 27 Aug 2020 23:19:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 736FDA1BDC; Thu, 27 Aug 2020 23:18:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727066AbgH0VSz (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 27 Aug 2020 17:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbgH0VSz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 27 Aug 2020 17:18:55 -0400 Received: from mail-ua1-x941.google.com (mail-ua1-x941.google.com [IPv6:2607:f8b0:4864:20::941]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AC67C061264 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 14:18:55 -0700 (PDT) Received: by mail-ua1-x941.google.com with SMTP id e41so636882uad.6 for <linux-bluetooth@vger.kernel.org>; Thu, 27 Aug 2020 14:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Uvsehs1Z/ivRBh8UrxKEUL/EppasaXDq8JRk0ShquEs=; b=nxhZqvRi9rS+XXDTsYK8/1wLC3y5qdutJk9rZwFQly9hEn0j/UyD5gp9E5I9fvTbTF J5bKjOQeV9xkde+99qA0Ss+cGv5NjKXAXOy5uVKMSw3XmxVr+LozoUiPRHPDDn+BMiCZ BR/i/vPXuxG9BuCc9urMHqEyz177ezk0lMyYM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Uvsehs1Z/ivRBh8UrxKEUL/EppasaXDq8JRk0ShquEs=; b=m03J6rqLqswSLsdtvHe9n/RongcrGC/fz81UuuqK5qKTRg41Ah1YbpE8nM+kEpkiFB IGhyUhNkkCh0fsIvuXFDp7z6ew3nR0qlZc0HIktET176ipEESAm6ahW4S0pwIyTUgf2R +dbdOzs90FNHBz6RUghCuNvhmlhWlkizQgGOR9PkB4NJs+Wmxgc7SH2GjCZbGkIlYFWZ T8/0MoALQTkNlmWC7WeF96+RsXxROIBhwrFZrw1yzAlsnO8l6NO5ERw4u7ONTEX3e3oL nLFRZlOWA/YC7yValEiHBb7Crj8Yp+0UiPNE1WVDKhbnGGNKJSE1xUchdkX0zz5kmd/4 tGgQ== X-Gm-Message-State: AOAM531ktDjL6gafbWL64zMFdaKzEfFKmGxdXnXEJOKZYrtraObS5nF9 mesqvUzRYDQF07vrBIGIUa9u6DS4EQS/Z2Jtt0dwNw== X-Google-Smtp-Source: ABdhPJz8MhKw9Io1d5e5ahxolqWwSDMpzr7TlQWTxz9xH4//Ha+tYCN6QHpTkfXY3xC5lUvIZBTL/NPQG2Yhv1+ufCI= X-Received: by 2002:ab0:5905:: with SMTP id n5mr1506144uad.90.1598563134246; Thu, 27 Aug 2020 14:18:54 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> <CANFp7mWqT1mO0OcJAt4AycTgFLz22p7zyRGjR1Hvj4bJmHHsTw@mail.gmail.com> <CABBYNZLmfWWBYZjHDkHmMpzYC02zFpWMV_xAiD1pK3cc09JwSA@mail.gmail.com> <CANFp7mWf1xDg6+nLMyrjaMaqF0=GyhauwN43ny5QMT0MWYd+tA@mail.gmail.com> In-Reply-To: <CANFp7mWf1xDg6+nLMyrjaMaqF0=GyhauwN43ny5QMT0MWYd+tA@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Thu, 27 Aug 2020 14:18:40 -0700 Message-ID: <CANFp7mVGCk7bYiNfGmOvNWzr=S51ME5fe20FE+JoGR9Rkk41gA@mail.gmail.com> Subject: Re: [Bluez PATCH v2 0/3] adapter: Reconnect audio when resuming from suspend To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 736FDA1BDC X-Rspamd-UID: e21dd5 On Thu, Aug 27, 2020 at 2:13 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Hi Luiz, > > On Wed, Aug 26, 2020 at 11:21 PM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Abhishek, > > > > On Wed, Aug 26, 2020 at 10:41 AM Abhishek Pandit-Subedi > > <abhishekpandit@chromium.org> wrote: > > > > > > Hi Luiz, > > > > > > Could you PTAL at this v2 patch series. I refactored the audio > > > reconnect to use the policy plugin instead of doing the reconnect as > > > part of the adapter logic, as requested. > > > > > > Thanks > > > Abhishek > > > > > > On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi > > > <abhishekpandit@chromium.org> wrote: > > > > > > > > > > > > Hi Luiz and Marcel, > > > > > > > > This is a quality of life improvement for the behavior of audio devices > > > > during system suspend. This depends on a kernel change that emits > > > > suspend/resume events: > > > > > > > > https://patchwork.kernel.org/project/bluetooth/list/?series=325771 > > > > So we could not just use the disconnect reason like I suggested? > > I am using the disconnect reason to mark the device for reconnection > and only queueing it for reconnect on resume. As mentioned in the > patch, this is to account for resumes that are not user driven and > will suspend almost immediately again (i.e. periodic wake up to check > battery level and see if we need to shut down). Correction: As mentioned in my response to patch 3 in this series: https://lore.kernel.org/linux-bluetooth/CANFp7mV03KvqpOH=LBU=0tBDhgK5K2YJ6rxYvkDKmyer4n_gLw@mail.gmail.com/ > > > > > > > Right now, audio devices will be disconnected as part of suspend but > > > > won't be reconnected when the system resumes without user interaction. > > > > This is annoying to some users as it causes an interruption to their > > > > normal work flow. > > > > > > > > This change reconnects audio devices that were disconnected for suspend > > > > using the following logic: > > > > > > > > * Register a callback for controller resume in the policy plugin. > > > > * In the device disconnect callback, mark any devices with the A2DP > > > > service uuid for reconnect on resume after a delay. > > > > * In the controller resume callback, queue any policy items that are > > > > marked to reconnect on resume for connection with the > > > > ReconnectAudioDelay value (default = 5s for Wi-Fi coexistence). > > > > Something like ResumeDelay would probably be better. > > Sure, I will rename this. > > > > > > > A reconnect is only attempted once after the controller resumes and the > > > > delay between resume and reconnect is configurable via the > > > > ReconnectAudioDelay key in the Policy settings. The 5s delay was chosen > > > > arbitrarily and I think anywhere up to 10s is probably ok. A longer > > > > delay is better to account for spurious wakeups and Wi-Fi reconnection > > > > time (avoiding any co-ex issues) at the downside of reconnection speed. > > > > I would keep the same logic as out of range so the platforms can > > customize the number of attempts. > > So the first reconnect attempt after resume should be separately > configurable (i.e. 5s) but subsequent reconnect attempts would use the > reconnect-intervals values? That sounds good to me. > > > > > > > Here are the tests I have done with this: > > > > - Single suspend and verified the headphones reconnect > > > > - Suspend stress test for 25 iterations and verify both Wi-Fi and > > > > Bluetooth audio reconnect on resume. (Ran with wake minimum time of > > > > 10s) > > > > - Suspend test with wake time < 5s to verify that BT reconnect isn't > > > > attempted. Ran 5 iterations with low wake time and then let it stay > > > > awake to confirm reconnect finally completed after 5s+ wake time. > > > > - Suspend test with wake time between 3s - 6s. Ran with 5 iterations and > > > > verified it wasn't connected at the end. A connection attempt was > > > > made but not completed due to suspend. A reconnect attempt was not > > > > made afterwards, which is by design. > > > > > > > > Luiz@ Marcel@: Does this sound ok (give up after an attempt)? > > > > > > > > I've tested this on a Pixelbook Go (AC-9260 controller) and HP > > > > Chromebook 14a (RTL8822CE controller) with GID6B headset. > > > > > > > > I've also tested this with the Pixel Buds 2. These earbuds actually > > > > reconnect automatically to the Chromebook (even without this policy > > > > change) and I verified that the new changes don't break the reconnection > > > > mechanism. > > > > > > > > Thanks > > > > Abhishek > > > > > > > > > > > > Changes in v2: > > > > - Refactored to use policy instead of connecting directly in adapter > > > > > > > > Abhishek Pandit-Subedi (3): > > > > mgmt: Add controller suspend and resume events > > > > monitor: Add btmon support for Suspend and Resume events > > > > policy: Reconnect audio on controller resume > > > > > > > > lib/mgmt.h | 14 +++++++++++ > > > > monitor/packet.c | 55 +++++++++++++++++++++++++++++++++++++++++ > > > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > > > > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > > > > src/adapter.h | 6 +++++ > > > > src/main.c | 1 + > > > > src/main.conf | 9 +++++++ > > > > 7 files changed, 190 insertions(+), 4 deletions(-) > > > > > > > > -- > > > > 2.28.0.297.g1956fa8f8d-goog > > > > > > > > > > > > -- > > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yKOEFBo2SV+lwwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 28 Aug 2020 18:51:38 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WCNXFBo2SV90lwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 28 Aug 2020 18:51:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A507DA1487; Fri, 28 Aug 2020 18:51:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726904AbgH1QvR (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 12:51:17 -0400 Received: from mga06.intel.com ([134.134.136.31]:5793 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726236AbgH1QvQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 12:51:16 -0400 IronPort-SDR: LGcqQNHy1GxIUTUk178SEKH6kuglA1/p4S86WG31PhiaGosVDC+1Kd9kPTEu7L1WYxykIwN8mc 3zuLOheNqQXQ== X-IronPort-AV: E=McAfee;i="6000,8403,9727"; a="218252304" X-IronPort-AV: E=Sophos;i="5.76,364,1592895600"; d="scan'208";a="218252304" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 09:51:14 -0700 IronPort-SDR: eLGzCObr76Et6RleFcDfNb34JW9+tIQpDMHPeCLMrTtEcibiz7yES4DZEfFuAdS5wfU5Vc0+bK jl+tvUvnk/kQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,364,1592895600"; d="scan'208";a="403802453" Received: from rbuaba-mobl2.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.83.122]) by fmsmga001.fm.intel.com with ESMTP; 28 Aug 2020 09:51:13 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ v2] mesh: Store key indices as integers in node config Date: Fri, 28 Aug 2020 09:51:12 -0700 Message-Id: <20200828165112.4937-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: A507DA1487 X-Rspamd-UID: 45bbcd Store NetKey and AppKey indices as integers instead of hex strings. This removes unnecessary string manipulations while not affecting the configuration file readability. --- mesh/mesh-config-json.c | 102 +++++++++++++++------------------------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 63b6c3988..30c90170d 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -249,21 +249,31 @@ static void jarray_string_del(json_object *jarray, char *str, size_t len) } } +static bool get_key_index(json_object *jobj, const char *keyword, + uint16_t *index) +{ + int idx; + + if (!get_int(jobj, keyword, &idx)) + return false; + + if (!CHECK_KEY_IDX_RANGE(idx)) + return false; + + *index = (uint16_t) idx; + return true; +} + static json_object *get_key_object(json_object *jarray, uint16_t idx) { int i, sz = json_object_array_length(jarray); for (i = 0; i < sz; ++i) { - json_object *jentry, *jvalue; - const char *str; + json_object *jentry; uint16_t jidx; jentry = json_object_array_get_idx(jarray, i); - if (!json_object_object_get_ex(jentry, "index", &jvalue)) - return NULL; - - str = json_object_get_string(jvalue); - if (sscanf(str, "%04hx", &jidx) != 1) + if (!get_key_index(jentry, "index", &jidx)) return NULL; if (jidx == idx) @@ -273,28 +283,6 @@ static json_object *get_key_object(json_object *jarray, uint16_t idx) return NULL; } -static bool get_key_index(json_object *jobj, const char *keyword, - uint16_t *index) -{ - uint16_t idx; - json_object *jvalue; - const char *str; - - if (!json_object_object_get_ex(jobj, keyword, &jvalue)) - return false; - - str = json_object_get_string(jvalue); - - if (sscanf(str, "%04hx", &idx) != 1) - return false; - - if (!CHECK_KEY_IDX_RANGE(idx)) - return false; - - *index = (uint16_t) idx; - return true; -} - static void jarray_key_del(json_object *jarray, int16_t idx) { int i, sz = json_object_array_length(jarray); @@ -594,11 +582,23 @@ fail: return false; } +static bool write_int(json_object *jobj, const char *desc, int val) +{ + json_object *jvalue; + + jvalue = json_object_new_int(val); + if (!jvalue) + return false; + + json_object_object_del(jobj, desc); + json_object_object_add(jobj, desc, jvalue); + return true; +} + bool mesh_config_net_key_add(struct mesh_config *cfg, uint16_t idx, const uint8_t key[16]) { - json_object *jnode, *jarray = NULL, *jentry = NULL, *jstring; - char buf[5]; + json_object *jnode, *jarray = NULL, *jentry = NULL; if (!cfg) return false; @@ -618,13 +618,9 @@ bool mesh_config_net_key_add(struct mesh_config *cfg, uint16_t idx, if (!jentry) return false; - snprintf(buf, 5, "%4.4x", idx); - jstring = json_object_new_string(buf); - if (!jstring) + if (!write_int(jentry, "index", idx)) goto fail; - json_object_object_add(jentry, "index", jstring); - if (!add_key_value(jentry, "key", key)) goto fail; @@ -724,8 +720,7 @@ bool mesh_config_write_token(struct mesh_config *cfg, uint8_t *token) bool mesh_config_app_key_add(struct mesh_config *cfg, uint16_t net_idx, uint16_t app_idx, const uint8_t key[16]) { - json_object *jnode, *jarray = NULL, *jentry = NULL, *jstring = NULL; - char buf[5]; + json_object *jnode, *jarray = NULL, *jentry = NULL; if (!cfg) return false; @@ -744,20 +739,12 @@ bool mesh_config_app_key_add(struct mesh_config *cfg, uint16_t net_idx, if (!jentry) return false; - snprintf(buf, 5, "%4.4x", app_idx); - jstring = json_object_new_string(buf); - if (!jstring) + if (!write_int(jentry, "index", app_idx)) goto fail; - json_object_object_add(jentry, "index", jstring); - - snprintf(buf, 5, "%4.4x", net_idx); - jstring = json_object_new_string(buf); - if (!jstring) + if (!write_int(jentry, "boundNetKey", net_idx)) goto fail; - json_object_object_add(jentry, "boundNetKey", jstring); - if (!add_key_value(jentry, "key", key)) goto fail; @@ -995,6 +982,7 @@ static struct mesh_config_pub *parse_model_publication(json_object *jpub) case 32: if (!str2hex(str, len, pub->virt_addr, 16)) goto fail; + pub->virt = true; break; default: @@ -1468,19 +1456,6 @@ static bool write_uint32_hex(json_object *jobj, const char *desc, uint32_t val) return true; } -static bool write_int(json_object *jobj, const char *desc, int val) -{ - json_object *jvalue; - - jvalue = json_object_new_int(val); - if (!jvalue) - return false; - - json_object_object_del(jobj, desc); - json_object_object_add(jobj, desc, jvalue); - return true; -} - static const char *mode_to_string(int mode) { switch (mode) { @@ -1872,7 +1847,7 @@ bool mesh_config_model_pub_add(struct mesh_config *cfg, uint16_t ele_addr, if (!res) goto fail; - if (!write_uint16_hex(jpub, "index", pub->idx)) + if (!write_int(jpub, "index", pub->idx)) goto fail; if (!write_int(jpub, "ttl", pub->ttl)) @@ -1881,8 +1856,7 @@ bool mesh_config_model_pub_add(struct mesh_config *cfg, uint16_t ele_addr, if (!write_int(jpub, "period", pub->period)) goto fail; - if (!write_int(jpub, "credentials", - pub->credential ? 1 : 0)) + if (!write_int(jpub, "credentials", pub->credential ? 1 : 0)) goto fail; jrtx = json_object_new_object(); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yG0tJFhjSV9dGwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 28 Aug 2020 22:04:40 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id sHmLIlhjSV/iuQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 28 Aug 2020 22:04:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8FEACA1676; Fri, 28 Aug 2020 22:04:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726821AbgH1UEd (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 16:04:33 -0400 Received: from mga17.intel.com ([192.55.52.151]:35423 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726460AbgH1UE3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 16:04:29 -0400 IronPort-SDR: vzfp+r6dZ7oHVoeLKFMrc7Uf9M0Vc4eV8APpZQ2RMeh0Ru5ThPQFC8VTz/yV/tFqGPNQBtf+h9 om2wiA7g49rQ== X-IronPort-AV: E=McAfee;i="6000,8403,9727"; a="136799285" X-IronPort-AV: E=Sophos;i="5.76,364,1592895600"; d="scan'208";a="136799285" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 13:04:29 -0700 IronPort-SDR: vM/oqMEDzpPg24FWZfdvt3FTecPhIhN385LJV8l9F0IJpbJW0evTq/Luxd3EKcv3QLi4z6XQ5N ZjtQDd1fQHwQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,364,1592895600"; d="scan'208";a="300345422" Received: from rbuaba-mobl2.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.83.122]) by orsmga006.jf.intel.com with ESMTP; 28 Aug 2020 13:04:29 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 1/2] mesh: Initialize RPL when creating or loading a node Date: Fri, 28 Aug 2020 13:04:26 -0700 Message-Id: <20200828200427.18753-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200828200427.18753-1-inga.stotland@intel.com> References: <20200828200427.18753-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8FEACA1676 X-Rspamd-UID: 0aa225 When either a new node is created or an existing node is loaded from storage, initialize RPL storage directory. Additionally, when an existing node configguration is read from storage, load saved RPL entries into the corresponding RPL lists. --- mesh/net.c | 14 +++++++------- mesh/net.h | 1 + mesh/node.c | 11 +++++++---- mesh/rpl.c | 29 ++++++++++++++++++++--------- mesh/rpl.h | 3 ++- 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/mesh/net.c b/mesh/net.c index 15d8f1c4b..83647d6ad 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -633,6 +633,7 @@ struct mesh_net *mesh_net_new(struct mesh_node *node) net->frnd_msgs = l_queue_new(); net->destinations = l_queue_new(); net->app_keys = l_queue_new(); + net->replay_cache = l_queue_new(); if (!nets) nets = l_queue_new(); @@ -2596,7 +2597,7 @@ static void update_iv_ivu_state(struct mesh_net *net, uint32_t iv_index, mesh_config_write_iv_index(cfg, iv_index, ivu); /* Cleanup Replay Protection List NVM */ - rpl_init(net->node, iv_index); + rpl_update(net->node, iv_index); } node_property_changed(net->node, "IVIndex"); @@ -3480,12 +3481,6 @@ bool net_msg_check_replay_cache(struct mesh_net *net, uint16_t src, if (!net || !net->node) return true; - if (!net->replay_cache) { - net->replay_cache = l_queue_new(); - rpl_init(net->node, net->iv_index); - rpl_get_list(net->node, net->replay_cache); - } - rpe = l_queue_find(net->replay_cache, match_replay_cache, L_UINT_TO_PTR(src)); @@ -3688,3 +3683,8 @@ int mesh_net_set_heartbeat_pub(struct mesh_net *net, uint16_t dst, /* TODO: Save to node config */ return MESH_STATUS_SUCCESS; } + +bool mesh_net_load_rpl(struct mesh_net *net) +{ + return rpl_get_list(net->node, net->replay_cache); +} diff --git a/mesh/net.h b/mesh/net.h index 253185e42..725054ce6 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -358,3 +358,4 @@ bool net_msg_check_replay_cache(struct mesh_net *net, uint16_t src, uint16_t crpl, uint32_t seq, uint32_t iv_index); void net_msg_add_replay_cache(struct mesh_net *net, uint16_t src, uint32_t seq, uint32_t iv_index); +bool mesh_net_load_rpl(struct mesh_net *net); diff --git a/mesh/node.c b/mesh/node.c index c564bdb91..f7ac5ff67 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -44,6 +44,7 @@ #include "mesh/dbus.h" #include "mesh/agent.h" #include "mesh/manager.h" +#include "mesh/rpl.h" #include "mesh/node.h" #define MESH_NODE_PATH_PREFIX "/node" @@ -399,7 +400,8 @@ static bool init_storage_dir(struct mesh_node *node) node->storage_dir = l_strdup(dir_name); - return true; + /* Initialize directory for storing RPL info */ + return rpl_init(node->storage_dir); } static void update_net_settings(struct mesh_node *node) @@ -470,6 +472,10 @@ static bool init_from_storage(struct mesh_config_node *db_node, mesh_net_set_iv_index(node->net, db_node->iv_index, db_node->iv_update); + /* Initialize directory for storing keyring and RPL info */ + if (!init_storage_dir(node) || !mesh_net_load_rpl(node->net)) + goto fail; + if (db_node->net_transmit) mesh_net_transmit_params_set(node->net, db_node->net_transmit->count, @@ -497,9 +503,6 @@ static bool init_from_storage(struct mesh_config_node *db_node, node->cfg = cfg; - /* Initialize directory for storing keyring info */ - init_storage_dir(node); - return true; fail: node_remove(node); diff --git a/mesh/rpl.c b/mesh/rpl.c index 5a667468e..792c52ad6 100644 --- a/mesh/rpl.c +++ b/mesh/rpl.c @@ -51,7 +51,7 @@ bool rpl_put_entry(struct mesh_node *node, uint16_t src, uint32_t iv_index, DIR *dir; int fd; - if (!node || !IS_UNICAST(src)) + if (!IS_UNICAST(src)) return false; node_path = node_get_storage_dir(node); @@ -100,7 +100,7 @@ void rpl_del_entry(struct mesh_node *node, uint16_t src) struct dirent *entry; DIR *dir; - if (!node || !IS_UNICAST(src)) + if (!IS_UNICAST(src)) return; node_path = node_get_storage_dir(node); @@ -205,12 +205,12 @@ bool rpl_get_list(struct mesh_node *node, struct l_queue *rpl_list) size_t len; DIR *dir; - if (!node || !rpl_list) + if (!rpl_list) return false; node_path = node_get_storage_dir(node); - len = strlen(node_path) + strlen(rpl_dir) + 14; + len = strlen(node_path) + strlen(rpl_dir) + 15; if (len > PATH_MAX) return false; @@ -241,7 +241,7 @@ bool rpl_get_list(struct mesh_node *node, struct l_queue *rpl_list) return true; } -void rpl_init(struct mesh_node *node, uint32_t cur) +void rpl_update(struct mesh_node *node, uint32_t cur) { uint32_t old = cur - 1; const char *node_path; @@ -249,12 +249,11 @@ void rpl_init(struct mesh_node *node, uint32_t cur) char path[PATH_MAX]; DIR *dir; - if (!node) - return; - node_path = node_get_storage_dir(node); + if (!node_path) + return; - if (strlen(node_path) + strlen(rpl_dir) + 10 >= PATH_MAX) + if (strlen(node_path) + strlen(rpl_dir) + 15 >= PATH_MAX) return; /* Make sure path exists */ @@ -287,3 +286,15 @@ void rpl_init(struct mesh_node *node, uint32_t cur) closedir(dir); } + +bool rpl_init(const char *node_path) +{ + char path[PATH_MAX]; + + if (strlen(node_path) + strlen(rpl_dir) + 15 >= PATH_MAX) + return false; + + snprintf(path, PATH_MAX, "%s%s", node_path, rpl_dir); + mkdir(path, 0755); + return true; +} diff --git a/mesh/rpl.h b/mesh/rpl.h index 17d2e3f05..2bbbdc9b9 100644 --- a/mesh/rpl.h +++ b/mesh/rpl.h @@ -27,4 +27,5 @@ bool rpl_put_entry(struct mesh_node *node, uint16_t src, uint32_t iv_index, uint32_t seq); void rpl_del_entry(struct mesh_node *node, uint16_t src); bool rpl_get_list(struct mesh_node *node, struct l_queue *rpl_list); -void rpl_init(struct mesh_node *node, uint32_t iv_index); +void rpl_update(struct mesh_node *node, uint32_t iv_index); +bool rpl_init(const char *node_path); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GASXMzs6SV9gYQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 28 Aug 2020 19:09:15 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id aIutMTs6SV9wHgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 28 Aug 2020 19:09:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C07F4420C1; Fri, 28 Aug 2020 19:09:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726924AbgH1RJH (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 13:09:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726654AbgH1RJF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 13:09:05 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 990E4C061264 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 10:09:04 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id y30so456454ooj.3 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 10:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ngwOPa5tS9fvjpsv61IrJk6WmCp1qkyr0/2nperfoCk=; b=JMx3L35EfL893619YKnUMOhKJ/qO/b6W2Bz39BKti9mFnmmX63oV3DUVkBVFLj4vTf n5Lgrz12aaptRztIaJ0bIIjgFzdFYcO4rnBcxf6o6Jdgl3Wg36KJy0W5Q3ekb2p8k7CS bxUi3/RxieaE4mjJdePs37rQowwlP+7aFjgLphrzVyBgGkwQueRL0Cf4hg2PNvgARmD2 TTixcS5tNDCsI4Txk3gMZXH4KE8gvC5R7rDEr6qVM4wUBsYi6ag1mlHwB9PxLDFg/pt3 73TQjJgtDLoCZF9Nbc6rXp1pU+cf1XEuYnHiKerhVHJ7KvABoA9PeZ1Ah8eFGZhLzP+l cGwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ngwOPa5tS9fvjpsv61IrJk6WmCp1qkyr0/2nperfoCk=; b=e+QBhD4vGaCjUYDHkiYazF52kKCkfGyBEATR/HHOXgbBR6tgXAu4lS020mpwnjsxre +GzIhncUeblpeWwx5t2z7yISW19mT9jNyhBw2/B4ahMGMMIZaIWqI1nLN62pGdmdswzG SyaL1t9qJkN4EdPG5n7zy1Dr6bcuBwh9306QbNBZr2UIThn+SVoUeZakmh6n2+1C44YT HFyGFGehkN8P0Om7r+/w8Oqgd4HzNwmjGZ46u5ZRYm1XxvAWr7j2uvs0d6f9Vlr5Dint c7kIkIWpuKmukonOykAkv1AWGXhTCBIjSqnNoEzSvfhmB5eSxCxH0Qs/r2LB6BhtGCPZ R4JA== X-Gm-Message-State: AOAM530SRnxHGWF6Xfro0pT69E0PnYCaf6p2N6cJAelj4/C8RRNODzDt 1MINAEUyfdljf+jdKw5/Kf/4MKa9DLKuwv1smaWM41FK X-Google-Smtp-Source: ABdhPJxD6cIcfLtDh11H2c22VoTGz30OHFsE1/FA25sok0wraN5ZKhr3qOw1mxnrQQ+Dr9sP9HUHAIuLmTmNILNBiIs= X-Received: by 2002:a4a:924b:: with SMTP id g11mr2152798ooh.9.1598634543666; Fri, 28 Aug 2020 10:09:03 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> <20200818162807.Bluez.v2.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> <CABBYNZLb_ETfO1VyAf+1rXpRT_XroQLq7u=uK6PGcrOKR7PHxA@mail.gmail.com> <CANFp7mV03KvqpOH=LBU=0tBDhgK5K2YJ6rxYvkDKmyer4n_gLw@mail.gmail.com> In-Reply-To: <CANFp7mV03KvqpOH=LBU=0tBDhgK5K2YJ6rxYvkDKmyer4n_gLw@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 28 Aug 2020 10:08:53 -0700 Message-ID: <CABBYNZ+SYSgzR_wX5Cn+5zUjep6HazCdJvAgZ0EE0uLkB_PEGg@mail.gmail.com> Subject: Re: [Bluez PATCH v2 3/3] policy: Reconnect audio on controller resume To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: C07F4420C1 X-Rspamd-UID: d963c8 Hi Abhishek, On Thu, Aug 27, 2020 at 2:08 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Hi Luiz, > > On Wed, Aug 26, 2020 at 11:32 PM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Abhishek, > > > > On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi > > <abhishekpandit@chromium.org> wrote: > > > > > > During system suspend, all peer devices are disconnected. On resume, HID > > > devices will reconnect but audio devices stay disconnected. As a quality > > > of life improvement, mark audio devices that were disconnected due to > > > suspend and attempt to reconnect them when the controller resumes (after > > > a delay for better co-existence with Wi-Fi). > > > > > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > > --- > > > > > > Changes in v2: > > > - Refactored to use policy instead of connecting directly in adapter > > > > > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > > > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > > > src/adapter.h | 6 +++++ > > > src/main.c | 1 + > > > src/main.conf | 9 +++++++ > > > 5 files changed, 121 insertions(+), 4 deletions(-) > > > > > > diff --git a/plugins/policy.c b/plugins/policy.c > > > index de51e58b9..b07a997b9 100644 > > > --- a/plugins/policy.c > > > +++ b/plugins/policy.c > > > @@ -75,6 +75,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; > > > static int *reconnect_intervals = NULL; > > > static size_t reconnect_intervals_len = 0; > > > > > > +static const int default_reconnect_delay = 5; > > > +static int resume_reconnect_delay = 5; > > > + > > > static GSList *reconnects = NULL; > > > > > > static unsigned int service_id = 0; > > > @@ -93,6 +96,8 @@ struct policy_data { > > > uint8_t ct_retries; > > > guint tg_timer; > > > uint8_t tg_retries; > > > + > > > + bool reconnect_on_resume; > > > }; > > > > > > static struct reconnect_data *reconnect_find(struct btd_device *dev) > > > @@ -214,6 +219,7 @@ static gboolean policy_connect_sink(gpointer user_data) > > > > > > data->sink_timer = 0; > > > data->sink_retries++; > > > + data->reconnect_on_resume = false; > > > > > > service = btd_device_get_service(data->dev, A2DP_SINK_UUID); > > > if (service != NULL) > > > @@ -222,16 +228,20 @@ static gboolean policy_connect_sink(gpointer user_data) > > > return FALSE; > > > } > > > > > > -static void policy_set_sink_timer(struct policy_data *data) > > > +static void policy_set_sink_timer_internal(struct policy_data *data, int timeout) > > > { > > > if (data->sink_timer > 0) > > > g_source_remove(data->sink_timer); > > > > > > - data->sink_timer = g_timeout_add_seconds(SINK_RETRY_TIMEOUT, > > > - policy_connect_sink, > > > + data->sink_timer = g_timeout_add_seconds(timeout, policy_connect_sink, > > > data); > > > } > > > > > > +static void policy_set_sink_timer(struct policy_data *data) > > > +{ > > > + policy_set_sink_timer_internal(data, SINK_RETRY_TIMEOUT); > > > +} > > > + > > > static void sink_cb(struct btd_service *service, btd_service_state_t old_state, > > > btd_service_state_t new_state) > > > { > > > @@ -743,10 +753,30 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) > > > static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > > { > > > struct reconnect_data *reconnect; > > > + struct btd_service *service; > > > + struct policy_data *data; > > > + bool do_reconnect = false; > > > > > > DBG("reason %u", reason); > > > > > > - if (reason != MGMT_DEV_DISCONN_TIMEOUT) > > > + switch(reason) { > > > + case MGMT_DEV_DISCONN_LOCAL_HOST: > > > + case MGMT_DEV_DISCONN_REMOTE: > > > + do_reconnect = true; > > > + break; > > > + /* Disconnect due to suspend will queue reconnect on resume for a2dp */ > > > + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: > > > + service = btd_device_get_service(dev, A2DP_SINK_UUID); > > > + if (service && (data = policy_get_data(dev))) { > > > + data->reconnect_on_resume = true; > > > + } > > > > Can't we just program the timer directly here? Or would that wakeup > > the system, I would imagine all timers are disabled while suspended > > which means when the system resumes so does the timers which would > > then trigger the reconnection logic. > > This approach works if every resume is user initiated and keeps the > device awake long enough to reconnect to the audio device. On > ChromeOS, this isn't always the case. We have a feature called Dark > Resume that occurs when the system wakes to handle an event that > doesn't require user intervention and suspends again without ever > turning on the screen. See: > https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/docs/dark_resume.md. > A primary user for this is a periodic wake-up that checks battery > percentage and shuts down the system if it's too low. Ok I didn't know such a feature exists in ChromeOS, but doesn't Dark Resumes should be handled by the kernel instead of each userspace component? I suppose there quite a few timers that may have side effects if dark resumes actually resume them. > One of the tests I ran specifically for this is a suspend stress test > with a wake time between 2-4s (i.e. suspend_stress_test -c 10 > --wake_min 2 --wake_max 3) which emulates dark resumes. If we set the > timer when disconnecting, the device would attempt a connection on one > of the wakeups and fail (since we suspended without completing the > connection). We could perhaps check if the kernel is capable of emitting suspend/resume events and if not just program the timer, or alternatively add another config option to indicate when the system supports such concept of Dark Resumes. > > > > > + break; > > > + /* All other cases do not result in reconnect */ > > > + default: > > > + break; > > > + } > > > + > > > + if (!do_reconnect) > > > return; > > > > > > reconnect = reconnect_find(dev); > > > @@ -761,6 +791,23 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > > reconnect_set_timer(reconnect); > > > } > > > > > > +static void controller_resume_cb(uint8_t wake_reason, const bdaddr_t *addr, > > > + const uint8_t addr_type) > > > +{ > > > + struct btd_device *dev; > > > + GSList *l; > > > + > > > + /* Check if any devices needed to be reconnected on resume */ > > > + for (l = devices; l; l = g_slist_next(l)) { > > > + struct policy_data *data = l->data; > > > + > > > + if (data->reconnect_on_resume) { > > > + policy_set_sink_timer_internal(data, > > > + resume_reconnect_delay); > > > + } > > > + } > > > +} > > > + > > > static void conn_fail_cb(struct btd_device *dev, uint8_t status) > > > { > > > struct reconnect_data *reconnect; > > > @@ -854,9 +901,17 @@ static int policy_init(void) > > > auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", > > > NULL); > > > > > > + resume_reconnect_delay = g_key_file_get_integer( > > > + conf, "Policy", "ReconnectAudioDelay", &gerr); > > > + > > > + if (gerr) { > > > + g_clear_error(&gerr); > > > + resume_reconnect_delay = default_reconnect_delay; > > > + } > > > done: > > > if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { > > > btd_add_disconnect_cb(disconnect_cb); > > > + btd_add_controller_resume_cb(controller_resume_cb); > > > btd_add_conn_fail_cb(conn_fail_cb); > > > } > > > > > > @@ -869,6 +924,7 @@ done: > > > static void policy_exit(void) > > > { > > > btd_remove_disconnect_cb(disconnect_cb); > > > + btd_remove_controller_resume_cb(controller_resume_cb); > > > btd_remove_conn_fail_cb(conn_fail_cb); > > > > > > if (reconnect_uuids) > > > diff --git a/src/adapter.c b/src/adapter.c > > > index 5e896a9f0..7526feb9e 100644 > > > --- a/src/adapter.c > > > +++ b/src/adapter.c > > > @@ -139,6 +139,7 @@ static GSList *adapter_drivers = NULL; > > > > > > static GSList *disconnect_list = NULL; > > > static GSList *conn_fail_list = NULL; > > > +static GSList *controller_resume_list = NULL; > > > > > > struct link_key_info { > > > bdaddr_t bdaddr; > > > @@ -8766,6 +8767,45 @@ static void connected_callback(uint16_t index, uint16_t length, > > > eir_data_free(&eir_data); > > > } > > > > > > +static void controller_resume_notify(const uint8_t wake_reason, > > > + const bdaddr_t *addr, > > > + const uint8_t addr_type) > > > +{ > > > + GSList *l; > > > + > > > + for (l = controller_resume_list; l; l = g_slist_next(l)) { > > > + btd_controller_resume_cb resume_cb = l->data; > > > + resume_cb(wake_reason, addr, addr_type); > > > + } > > > +} > > > + > > > +static void controller_resume_callback(uint16_t index, uint16_t length, > > > + const void *param, void *user_data) > > > +{ > > > + const struct mgmt_ev_controller_resume *ev = param; > > > + struct btd_adapter *adapter = user_data; > > > + > > > + if (length < sizeof(*ev)) { > > > + btd_error(adapter->dev_id, "Too small device resume event"); > > > + return; > > > + } > > > + > > > + DBG("Controller resume with wake event 0x%x", ev->wake_reason); > > > + > > > + controller_resume_notify(ev->wake_reason, &ev->addr.bdaddr, > > > + ev->addr.type); > > > +} > > > + > > > +void btd_add_controller_resume_cb(btd_controller_resume_cb func) > > > +{ > > > + controller_resume_list = g_slist_append(controller_resume_list, func); > > > +} > > > + > > > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func) > > > +{ > > > + controller_resume_list = g_slist_remove(controller_resume_list, func); > > > +} > > > + > > > static void device_blocked_callback(uint16_t index, uint16_t length, > > > const void *param, void *user_data) > > > { > > > @@ -9389,6 +9429,11 @@ static void read_info_complete(uint8_t status, uint16_t length, > > > user_passkey_notify_callback, > > > adapter, NULL); > > > > > > + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, > > > + adapter->dev_id, > > > + controller_resume_callback, > > > + adapter, NULL); > > > + > > > set_dev_class(adapter); > > > > > > set_name(adapter, btd_adapter_get_name(adapter)); > > > diff --git a/src/adapter.h b/src/adapter.h > > > index f8ac20261..5527e4205 100644 > > > --- a/src/adapter.h > > > +++ b/src/adapter.h > > > @@ -67,6 +67,12 @@ typedef void (*btd_conn_fail_cb) (struct btd_device *device, uint8_t status); > > > void btd_add_conn_fail_cb(btd_conn_fail_cb func); > > > void btd_remove_conn_fail_cb(btd_conn_fail_cb func); > > > > > > +typedef void (*btd_controller_resume_cb)(const uint8_t wake_reason, > > > + const bdaddr_t *addr, > > > + const uint8_t addr_type); > > > +void btd_add_controller_resume_cb(btd_controller_resume_cb func); > > > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func); > > > > If we can program the timer just before we suspend this is not really > > necessary, but if you still thing that would be a good idea to notify > > Id put it in btd_adapter_driver with a callback for suspend and > > resume, that way we don't have to maintain multiple lists for each of > > the callbacks. > > The adapter driver seems like a reasonable place to put this so let me > port that over. > > > > > > struct btd_adapter *adapter_find(const bdaddr_t *sba); > > > struct btd_adapter *adapter_find_by_id(int id); > > > void adapter_foreach(adapter_cb func, gpointer user_data); > > > diff --git a/src/main.c b/src/main.c > > > index 2c083de67..a1c3e7e9f 100644 > > > --- a/src/main.c > > > +++ b/src/main.c > > > @@ -131,6 +131,7 @@ static const char *policy_options[] = { > > > "ReconnectAttempts", > > > "ReconnectIntervals", > > > "AutoEnable", > > > + "ReconnectAudioDelay", > > > NULL > > > }; > > > > > > diff --git a/src/main.conf b/src/main.conf > > > index f41203b96..8d74a2aec 100644 > > > --- a/src/main.conf > > > +++ b/src/main.conf > > > @@ -198,3 +198,12 @@ > > > # This includes adapters present on start as well as adapters that are plugged > > > # in later on. Defaults to 'false'. > > > #AutoEnable=false > > > + > > > +# Audio devices that were disconnected due to suspend will be reconnected on > > > +# resume. ReconnectAudioDelay determines the delay between when the controller > > > +# resumes from suspend and a connection attempt is made. A longer delay can be > > > +# better for co-existence with Wi-Fi. > > > +# The value is in seconds. > > > +# Default: 5 > > > +#ReconnectAudioDelay = 5 > > > + > > > -- > > > 2.28.0.297.g1956fa8f8d-goog > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oMPPF1s9SV+tkgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 28 Aug 2020 19:22:35 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mFLpF1s9SV9BpgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 28 Aug 2020 19:22:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 522AD42107; Fri, 28 Aug 2020 19:22:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727981AbgH1RWS (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 13:22:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727889AbgH1RWM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 13:22:12 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1AF1C061264 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 10:22:11 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id n23so1506312otq.11 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 10:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zMY0HHfl5UqqUfSqFkN1PL8lgIeYCFEm7vbvGLLk/2c=; b=RSieb9YfQ4z9cNMlhtdQ9EVfSAyNHMi69xIqebohJDDcgzChkuUTR5w+8pwvCYt825 Nsky0rbn2rLrFioo8jfKTZSA/gxA/MAaQcCkR3tiKIeIqE1ua4D/td6dfN1EPi5m0pTG xiSuS7mhrMUKn6DYk+FzDB88+hoFaUVCeiVfJbMx11UoCzYXA8s3bts27WSVLP+4Y2OK KrI5qU/pHaTWKBENunnpQHt7WmjssJ2yzPXCz1raqsPPosZvj7pchPAEk1Z0D7MDogXq vE99qacVjH7LSiX23U6Mz9KHySdfggH0xPNYPlzYUvs9VfvevFnacdSq8jM6JgiC6Pya KVVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zMY0HHfl5UqqUfSqFkN1PL8lgIeYCFEm7vbvGLLk/2c=; b=PaKV3t5rn+jIyjYIWmqoqpQ/NzAXHidtGfwxJKT3GxTKLbJiqnFkH6t9KN0RBsPbQ4 PQusywP7ALYqfMqabYbTN/WL2ieI/CuGNCAFqtW/Ez8MvIAnm0taTOc3Om3DT2nzbq1x 63MeqeiSp19xmJr4CFJQR2oqXJCShffSoHYV3sIbO2rsHd2yfdNwB8f4htgi+BejWPjq Xx0K+d9pBTnZl0+BgSYYWrY7XvO+zhiyVA2aCcNX//e35gg7449ASEe87HyO70sX0E/4 jYh8jXdl3L34h3vH1/CBDQG2nnugD2b3PL7BwpXs7obNFTXvPF68c6MpSCXB6Vz2zMZA uQ7Q== X-Gm-Message-State: AOAM533PgfBZhxy/IsGjx33OWU/n8NqLd8ah5/BTc/QmJcNRraMsZR/b jOs9UxEA+dev+w2vXnVpD0gtn9aW6tP135spats= X-Google-Smtp-Source: ABdhPJySAaRekgOVCDa0z5tOKBl5h0apKOQbkQ6oZF5XIwzLGkQkb4qJ1/KegcsIIgPj02ftKTOG//ehLx8I0N62eCY= X-Received: by 2002:a9d:6053:: with SMTP id v19mr1898413otj.362.1598635330926; Fri, 28 Aug 2020 10:22:10 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> <CANFp7mWqT1mO0OcJAt4AycTgFLz22p7zyRGjR1Hvj4bJmHHsTw@mail.gmail.com> <CABBYNZLmfWWBYZjHDkHmMpzYC02zFpWMV_xAiD1pK3cc09JwSA@mail.gmail.com> <CANFp7mWf1xDg6+nLMyrjaMaqF0=GyhauwN43ny5QMT0MWYd+tA@mail.gmail.com> In-Reply-To: <CANFp7mWf1xDg6+nLMyrjaMaqF0=GyhauwN43ny5QMT0MWYd+tA@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 28 Aug 2020 10:22:01 -0700 Message-ID: <CABBYNZ+YMfvcVnB7afXyFa_bz2oNaivgsmyhS=yOGrKuh4JG9A@mail.gmail.com> Subject: Re: [Bluez PATCH v2 0/3] adapter: Reconnect audio when resuming from suspend To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: 522AD42107 X-Rspamd-UID: 5d1fab Hi Abhishek, On Thu, Aug 27, 2020 at 2:13 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Hi Luiz, > > On Wed, Aug 26, 2020 at 11:21 PM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Abhishek, > > > > On Wed, Aug 26, 2020 at 10:41 AM Abhishek Pandit-Subedi > > <abhishekpandit@chromium.org> wrote: > > > > > > Hi Luiz, > > > > > > Could you PTAL at this v2 patch series. I refactored the audio > > > reconnect to use the policy plugin instead of doing the reconnect as > > > part of the adapter logic, as requested. > > > > > > Thanks > > > Abhishek > > > > > > On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi > > > <abhishekpandit@chromium.org> wrote: > > > > > > > > > > > > Hi Luiz and Marcel, > > > > > > > > This is a quality of life improvement for the behavior of audio devices > > > > during system suspend. This depends on a kernel change that emits > > > > suspend/resume events: > > > > > > > > https://patchwork.kernel.org/project/bluetooth/list/?series=325771 > > > > So we could not just use the disconnect reason like I suggested? > > I am using the disconnect reason to mark the device for reconnection > and only queueing it for reconnect on resume. As mentioned in the > patch, this is to account for resumes that are not user driven and > will suspend almost immediately again (i.e. periodic wake up to check > battery level and see if we need to shut down). > > > > > > > Right now, audio devices will be disconnected as part of suspend but > > > > won't be reconnected when the system resumes without user interaction. > > > > This is annoying to some users as it causes an interruption to their > > > > normal work flow. > > > > > > > > This change reconnects audio devices that were disconnected for suspend > > > > using the following logic: > > > > > > > > * Register a callback for controller resume in the policy plugin. > > > > * In the device disconnect callback, mark any devices with the A2DP > > > > service uuid for reconnect on resume after a delay. > > > > * In the controller resume callback, queue any policy items that are > > > > marked to reconnect on resume for connection with the > > > > ReconnectAudioDelay value (default = 5s for Wi-Fi coexistence). > > > > Something like ResumeDelay would probably be better. > > Sure, I will rename this. > > > > > > > A reconnect is only attempted once after the controller resumes and the > > > > delay between resume and reconnect is configurable via the > > > > ReconnectAudioDelay key in the Policy settings. The 5s delay was chosen > > > > arbitrarily and I think anywhere up to 10s is probably ok. A longer > > > > delay is better to account for spurious wakeups and Wi-Fi reconnection > > > > time (avoiding any co-ex issues) at the downside of reconnection speed. > > > > I would keep the same logic as out of range so the platforms can > > customize the number of attempts. > > So the first reconnect attempt after resume should be separately > configurable (i.e. 5s) but subsequent reconnect attempts would use the > reconnect-intervals values? That sounds good to me. Right, though 5 seconds seems awfully long compared to the normal first attempt, so perhaps we could default it to just 1-2 seconds. > > > > > > Here are the tests I have done with this: > > > > - Single suspend and verified the headphones reconnect > > > > - Suspend stress test for 25 iterations and verify both Wi-Fi and > > > > Bluetooth audio reconnect on resume. (Ran with wake minimum time of > > > > 10s) > > > > - Suspend test with wake time < 5s to verify that BT reconnect isn't > > > > attempted. Ran 5 iterations with low wake time and then let it stay > > > > awake to confirm reconnect finally completed after 5s+ wake time. > > > > - Suspend test with wake time between 3s - 6s. Ran with 5 iterations and > > > > verified it wasn't connected at the end. A connection attempt was > > > > made but not completed due to suspend. A reconnect attempt was not > > > > made afterwards, which is by design. > > > > > > > > Luiz@ Marcel@: Does this sound ok (give up after an attempt)? > > > > > > > > I've tested this on a Pixelbook Go (AC-9260 controller) and HP > > > > Chromebook 14a (RTL8822CE controller) with GID6B headset. > > > > > > > > I've also tested this with the Pixel Buds 2. These earbuds actually > > > > reconnect automatically to the Chromebook (even without this policy > > > > change) and I verified that the new changes don't break the reconnection > > > > mechanism. > > > > > > > > Thanks > > > > Abhishek > > > > > > > > > > > > Changes in v2: > > > > - Refactored to use policy instead of connecting directly in adapter > > > > > > > > Abhishek Pandit-Subedi (3): > > > > mgmt: Add controller suspend and resume events > > > > monitor: Add btmon support for Suspend and Resume events > > > > policy: Reconnect audio on controller resume > > > > > > > > lib/mgmt.h | 14 +++++++++++ > > > > monitor/packet.c | 55 +++++++++++++++++++++++++++++++++++++++++ > > > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > > > > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > > > > src/adapter.h | 6 +++++ > > > > src/main.c | 1 + > > > > src/main.conf | 9 +++++++ > > > > 7 files changed, 190 insertions(+), 4 deletions(-) > > > > > > > > -- > > > > 2.28.0.297.g1956fa8f8d-goog > > > > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0AFeL2w/SV+tkgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 28 Aug 2020 19:31:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CCYjLGw/SV8ffgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 28 Aug 2020 19:31:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 960AEA12CF; Fri, 28 Aug 2020 19:31:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726654AbgH1RbR (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 13:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726266AbgH1RbQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 13:31:16 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 802C1C061264 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 10:31:16 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id b16so30283vsl.6 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 10:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GeoKDoIqa5OlKReIGRoc+Y0aswwLhaW3iLDeA4ePJt8=; b=PJoAxDQ5ok0jZs93536/BZhe6DtPAuHMrissQioIRmF+mhgSFOcF+CeW59+QT9E5Vc 9/bm3bC7YQl9GyyrC8twHY+xekx313HxB+B0i5LXlxt2YiK4Bpu2cmzwCInNEGu5AwHf /eST1ccaC9RBgzJpx2kaCcJdf54ELxMMoXoJM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GeoKDoIqa5OlKReIGRoc+Y0aswwLhaW3iLDeA4ePJt8=; b=te5SJjfiAII5NnbEurDfUi/4u6o3/h9cq5HDyIt3Vfz8cNI8dNUm2v7IzjaUg+Dcfo 9n9VXeNuKbxXyjWbFF7SiNu8syI2r7yujT5kAC5L2XGUDIp84y0UKH3I+IPG/85KrZT7 dPWVuwpN9n/YnIYCmgji4GFrEKawRqI+2fJcZEu8a9ZqZsLjHdSGnSeG8NcWLBh1qvXq R9H2AaAcE6TlXzauFAF9C8ubajXJKqGs53b/zPlflGGmalNzIz+1YxtZmR3CbanA3yem 3dB2/5iyXIp3vGQCkupmBOw9miUoO/vvqtQ0hoCmgoECQyTEkp0CxmNskEXm7VS4Fi2C LKng== X-Gm-Message-State: AOAM5304kG8d2A/uFP/ViUXnCG6LiZTUucsitGF7TSDFprrKQ+jm57G5 uH7c6ZqeQLZmbZrOsuieLON7lOasOOsBm9oH998tbQ== X-Google-Smtp-Source: ABdhPJzgbRD2tjEVkdEK3Mmkju6rRhDS06Im9r6idsLLyJqN+ZjS49ye301J/dQrTxnOwBa86sV7o4GrWEaw7HH7R2k= X-Received: by 2002:a67:c393:: with SMTP id s19mr1819443vsj.49.1598635875516; Fri, 28 Aug 2020 10:31:15 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> <20200818162807.Bluez.v2.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> <CABBYNZLb_ETfO1VyAf+1rXpRT_XroQLq7u=uK6PGcrOKR7PHxA@mail.gmail.com> <CANFp7mV03KvqpOH=LBU=0tBDhgK5K2YJ6rxYvkDKmyer4n_gLw@mail.gmail.com> <CABBYNZ+SYSgzR_wX5Cn+5zUjep6HazCdJvAgZ0EE0uLkB_PEGg@mail.gmail.com> In-Reply-To: <CABBYNZ+SYSgzR_wX5Cn+5zUjep6HazCdJvAgZ0EE0uLkB_PEGg@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Fri, 28 Aug 2020 10:31:03 -0700 Message-ID: <CANFp7mU-gunJi5pAMY0zqE-BFGB6XDE=nPpxjU0Lqf7RBKDDpw@mail.gmail.com> Subject: Re: [Bluez PATCH v2 3/3] policy: Reconnect audio on controller resume To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 960AEA12CF X-Rspamd-UID: c3ee28 Hi Luiz, On Fri, Aug 28, 2020 at 10:09 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Abhishek, > > On Thu, Aug 27, 2020 at 2:08 PM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > Hi Luiz, > > > > On Wed, Aug 26, 2020 at 11:32 PM Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > > > > > > Hi Abhishek, > > > > > > On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi > > > <abhishekpandit@chromium.org> wrote: > > > > > > > > During system suspend, all peer devices are disconnected. On resume, HID > > > > devices will reconnect but audio devices stay disconnected. As a quality > > > > of life improvement, mark audio devices that were disconnected due to > > > > suspend and attempt to reconnect them when the controller resumes (after > > > > a delay for better co-existence with Wi-Fi). > > > > > > > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > > > --- > > > > > > > > Changes in v2: > > > > - Refactored to use policy instead of connecting directly in adapter > > > > > > > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > > > > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > > > > src/adapter.h | 6 +++++ > > > > src/main.c | 1 + > > > > src/main.conf | 9 +++++++ > > > > 5 files changed, 121 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/plugins/policy.c b/plugins/policy.c > > > > index de51e58b9..b07a997b9 100644 > > > > --- a/plugins/policy.c > > > > +++ b/plugins/policy.c > > > > @@ -75,6 +75,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; > > > > static int *reconnect_intervals = NULL; > > > > static size_t reconnect_intervals_len = 0; > > > > > > > > +static const int default_reconnect_delay = 5; > > > > +static int resume_reconnect_delay = 5; > > > > + > > > > static GSList *reconnects = NULL; > > > > > > > > static unsigned int service_id = 0; > > > > @@ -93,6 +96,8 @@ struct policy_data { > > > > uint8_t ct_retries; > > > > guint tg_timer; > > > > uint8_t tg_retries; > > > > + > > > > + bool reconnect_on_resume; > > > > }; > > > > > > > > static struct reconnect_data *reconnect_find(struct btd_device *dev) > > > > @@ -214,6 +219,7 @@ static gboolean policy_connect_sink(gpointer user_data) > > > > > > > > data->sink_timer = 0; > > > > data->sink_retries++; > > > > + data->reconnect_on_resume = false; > > > > > > > > service = btd_device_get_service(data->dev, A2DP_SINK_UUID); > > > > if (service != NULL) > > > > @@ -222,16 +228,20 @@ static gboolean policy_connect_sink(gpointer user_data) > > > > return FALSE; > > > > } > > > > > > > > -static void policy_set_sink_timer(struct policy_data *data) > > > > +static void policy_set_sink_timer_internal(struct policy_data *data, int timeout) > > > > { > > > > if (data->sink_timer > 0) > > > > g_source_remove(data->sink_timer); > > > > > > > > - data->sink_timer = g_timeout_add_seconds(SINK_RETRY_TIMEOUT, > > > > - policy_connect_sink, > > > > + data->sink_timer = g_timeout_add_seconds(timeout, policy_connect_sink, > > > > data); > > > > } > > > > > > > > +static void policy_set_sink_timer(struct policy_data *data) > > > > +{ > > > > + policy_set_sink_timer_internal(data, SINK_RETRY_TIMEOUT); > > > > +} > > > > + > > > > static void sink_cb(struct btd_service *service, btd_service_state_t old_state, > > > > btd_service_state_t new_state) > > > > { > > > > @@ -743,10 +753,30 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) > > > > static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > > > { > > > > struct reconnect_data *reconnect; > > > > + struct btd_service *service; > > > > + struct policy_data *data; > > > > + bool do_reconnect = false; > > > > > > > > DBG("reason %u", reason); > > > > > > > > - if (reason != MGMT_DEV_DISCONN_TIMEOUT) > > > > + switch(reason) { > > > > + case MGMT_DEV_DISCONN_LOCAL_HOST: > > > > + case MGMT_DEV_DISCONN_REMOTE: > > > > + do_reconnect = true; > > > > + break; > > > > + /* Disconnect due to suspend will queue reconnect on resume for a2dp */ > > > > + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: > > > > + service = btd_device_get_service(dev, A2DP_SINK_UUID); > > > > + if (service && (data = policy_get_data(dev))) { > > > > + data->reconnect_on_resume = true; > > > > + } > > > > > > Can't we just program the timer directly here? Or would that wakeup > > > the system, I would imagine all timers are disabled while suspended > > > which means when the system resumes so does the timers which would > > > then trigger the reconnection logic. > > > > This approach works if every resume is user initiated and keeps the > > device awake long enough to reconnect to the audio device. On > > ChromeOS, this isn't always the case. We have a feature called Dark > > Resume that occurs when the system wakes to handle an event that > > doesn't require user intervention and suspends again without ever > > turning on the screen. See: > > https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/docs/dark_resume.md. > > A primary user for this is a periodic wake-up that checks battery > > percentage and shuts down the system if it's too low. > > Ok I didn't know such a feature exists in ChromeOS, but doesn't Dark > Resumes should be handled by the kernel instead of each userspace > component? I suppose there quite a few timers that may have side > effects if dark resumes actually resume them. > I'm not aware of the history around it but I found another page with more context of use cases (like actually letting a user space application run as would happen on a smartphone): https://www.chromium.org/chromium-os/chromiumos-design-docs/lucid-sleep > > One of the tests I ran specifically for this is a suspend stress test > > with a wake time between 2-4s (i.e. suspend_stress_test -c 10 > > --wake_min 2 --wake_max 3) which emulates dark resumes. If we set the > > timer when disconnecting, the device would attempt a connection on one > > of the wakeups and fail (since we suspended without completing the > > connection). > > We could perhaps check if the kernel is capable of emitting > suspend/resume events and if not just program the timer, or > alternatively add another config option to indicate when the system > supports such concept of Dark Resumes. > How does the following sound: * On disconnect, I always queue the reconnect but with the resume delay set instead of the interval[0] value. I also set the resume_reconnect flag * On every resume event (or dark resume event), I reset the timer and add resume_delay seconds if resume_reconnect is set * The first time the reconnect_timeout runs, I clear the resume_reconnect flag The delay will only be reapplied if the kernel is capable of emitting suspend/resume events and/or dark resume events. > > > > > > > + break; > > > > + /* All other cases do not result in reconnect */ > > > > + default: > > > > + break; > > > > + } > > > > + > > > > + if (!do_reconnect) > > > > return; > > > > > > > > reconnect = reconnect_find(dev); > > > > @@ -761,6 +791,23 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > > > reconnect_set_timer(reconnect); > > > > } > > > > > > > > +static void controller_resume_cb(uint8_t wake_reason, const bdaddr_t *addr, > > > > + const uint8_t addr_type) > > > > +{ > > > > + struct btd_device *dev; > > > > + GSList *l; > > > > + > > > > + /* Check if any devices needed to be reconnected on resume */ > > > > + for (l = devices; l; l = g_slist_next(l)) { > > > > + struct policy_data *data = l->data; > > > > + > > > > + if (data->reconnect_on_resume) { > > > > + policy_set_sink_timer_internal(data, > > > > + resume_reconnect_delay); > > > > + } > > > > + } > > > > +} > > > > + > > > > static void conn_fail_cb(struct btd_device *dev, uint8_t status) > > > > { > > > > struct reconnect_data *reconnect; > > > > @@ -854,9 +901,17 @@ static int policy_init(void) > > > > auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", > > > > NULL); > > > > > > > > + resume_reconnect_delay = g_key_file_get_integer( > > > > + conf, "Policy", "ReconnectAudioDelay", &gerr); > > > > + > > > > + if (gerr) { > > > > + g_clear_error(&gerr); > > > > + resume_reconnect_delay = default_reconnect_delay; > > > > + } > > > > done: > > > > if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { > > > > btd_add_disconnect_cb(disconnect_cb); > > > > + btd_add_controller_resume_cb(controller_resume_cb); > > > > btd_add_conn_fail_cb(conn_fail_cb); > > > > } > > > > > > > > @@ -869,6 +924,7 @@ done: > > > > static void policy_exit(void) > > > > { > > > > btd_remove_disconnect_cb(disconnect_cb); > > > > + btd_remove_controller_resume_cb(controller_resume_cb); > > > > btd_remove_conn_fail_cb(conn_fail_cb); > > > > > > > > if (reconnect_uuids) > > > > diff --git a/src/adapter.c b/src/adapter.c > > > > index 5e896a9f0..7526feb9e 100644 > > > > --- a/src/adapter.c > > > > +++ b/src/adapter.c > > > > @@ -139,6 +139,7 @@ static GSList *adapter_drivers = NULL; > > > > > > > > static GSList *disconnect_list = NULL; > > > > static GSList *conn_fail_list = NULL; > > > > +static GSList *controller_resume_list = NULL; > > > > > > > > struct link_key_info { > > > > bdaddr_t bdaddr; > > > > @@ -8766,6 +8767,45 @@ static void connected_callback(uint16_t index, uint16_t length, > > > > eir_data_free(&eir_data); > > > > } > > > > > > > > +static void controller_resume_notify(const uint8_t wake_reason, > > > > + const bdaddr_t *addr, > > > > + const uint8_t addr_type) > > > > +{ > > > > + GSList *l; > > > > + > > > > + for (l = controller_resume_list; l; l = g_slist_next(l)) { > > > > + btd_controller_resume_cb resume_cb = l->data; > > > > + resume_cb(wake_reason, addr, addr_type); > > > > + } > > > > +} > > > > + > > > > +static void controller_resume_callback(uint16_t index, uint16_t length, > > > > + const void *param, void *user_data) > > > > +{ > > > > + const struct mgmt_ev_controller_resume *ev = param; > > > > + struct btd_adapter *adapter = user_data; > > > > + > > > > + if (length < sizeof(*ev)) { > > > > + btd_error(adapter->dev_id, "Too small device resume event"); > > > > + return; > > > > + } > > > > + > > > > + DBG("Controller resume with wake event 0x%x", ev->wake_reason); > > > > + > > > > + controller_resume_notify(ev->wake_reason, &ev->addr.bdaddr, > > > > + ev->addr.type); > > > > +} > > > > + > > > > +void btd_add_controller_resume_cb(btd_controller_resume_cb func) > > > > +{ > > > > + controller_resume_list = g_slist_append(controller_resume_list, func); > > > > +} > > > > + > > > > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func) > > > > +{ > > > > + controller_resume_list = g_slist_remove(controller_resume_list, func); > > > > +} > > > > + > > > > static void device_blocked_callback(uint16_t index, uint16_t length, > > > > const void *param, void *user_data) > > > > { > > > > @@ -9389,6 +9429,11 @@ static void read_info_complete(uint8_t status, uint16_t length, > > > > user_passkey_notify_callback, > > > > adapter, NULL); > > > > > > > > + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, > > > > + adapter->dev_id, > > > > + controller_resume_callback, > > > > + adapter, NULL); > > > > + > > > > set_dev_class(adapter); > > > > > > > > set_name(adapter, btd_adapter_get_name(adapter)); > > > > diff --git a/src/adapter.h b/src/adapter.h > > > > index f8ac20261..5527e4205 100644 > > > > --- a/src/adapter.h > > > > +++ b/src/adapter.h > > > > @@ -67,6 +67,12 @@ typedef void (*btd_conn_fail_cb) (struct btd_device *device, uint8_t status); > > > > void btd_add_conn_fail_cb(btd_conn_fail_cb func); > > > > void btd_remove_conn_fail_cb(btd_conn_fail_cb func); > > > > > > > > +typedef void (*btd_controller_resume_cb)(const uint8_t wake_reason, > > > > + const bdaddr_t *addr, > > > > + const uint8_t addr_type); > > > > +void btd_add_controller_resume_cb(btd_controller_resume_cb func); > > > > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func); > > > > > > If we can program the timer just before we suspend this is not really > > > necessary, but if you still thing that would be a good idea to notify > > > Id put it in btd_adapter_driver with a callback for suspend and > > > resume, that way we don't have to maintain multiple lists for each of > > > the callbacks. > > > > The adapter driver seems like a reasonable place to put this so let me > > port that over. > > > > > > > > > struct btd_adapter *adapter_find(const bdaddr_t *sba); > > > > struct btd_adapter *adapter_find_by_id(int id); > > > > void adapter_foreach(adapter_cb func, gpointer user_data); > > > > diff --git a/src/main.c b/src/main.c > > > > index 2c083de67..a1c3e7e9f 100644 > > > > --- a/src/main.c > > > > +++ b/src/main.c > > > > @@ -131,6 +131,7 @@ static const char *policy_options[] = { > > > > "ReconnectAttempts", > > > > "ReconnectIntervals", > > > > "AutoEnable", > > > > + "ReconnectAudioDelay", > > > > NULL > > > > }; > > > > > > > > diff --git a/src/main.conf b/src/main.conf > > > > index f41203b96..8d74a2aec 100644 > > > > --- a/src/main.conf > > > > +++ b/src/main.conf > > > > @@ -198,3 +198,12 @@ > > > > # This includes adapters present on start as well as adapters that are plugged > > > > # in later on. Defaults to 'false'. > > > > #AutoEnable=false > > > > + > > > > +# Audio devices that were disconnected due to suspend will be reconnected on > > > > +# resume. ReconnectAudioDelay determines the delay between when the controller > > > > +# resumes from suspend and a connection attempt is made. A longer delay can be > > > > +# better for co-existence with Wi-Fi. > > > > +# The value is in seconds. > > > > +# Default: 5 > > > > +#ReconnectAudioDelay = 5 > > > > + > > > > -- > > > > 2.28.0.297.g1956fa8f8d-goog > > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Thanks, Abhishek Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0H3HIY1ASV+KJwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 28 Aug 2020 19:36:13 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eMxoII1ASV8wQwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 28 Aug 2020 19:36:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4FAB7417C0; Fri, 28 Aug 2020 19:36:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726500AbgH1RgG (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 13:36:06 -0400 Received: from mga11.intel.com ([192.55.52.93]:64854 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbgH1RgE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 13:36:04 -0400 IronPort-SDR: EPHBRsj+gjasJ+bm+kYB4yswRrS0ikBnleV0yChgFQTEF08gUTtxphasAa9nRNJAGDlyrK/Baf e5aPtLt1qtig== X-IronPort-AV: E=McAfee;i="6000,8403,9727"; a="154254105" X-IronPort-AV: E=Sophos;i="5.76,364,1592895600"; d="scan'208";a="154254105" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 10:35:13 -0700 IronPort-SDR: q4a7eScRhstM2sgsSvhsL8KCcnnM3dCGyia1HREiQOQHudacGDaRO7QIu2yG6BDF0LkwFUDVEu oz5uSdR/6/Aw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,364,1592895600"; d="scan'208";a="324094034" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga004.fm.intel.com with ESMTP; 28 Aug 2020 10:35:13 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 28 Aug 2020 10:34:48 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 28 Aug 2020 10:34:48 -0700 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (104.47.45.55) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 28 Aug 2020 10:34:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iNBZDgjEljqvyeNPA6wOxHuTbnb4AtQyttl+4XtRIc3V5aUtGyhaVuUYA9itoQQXXQtj9A09y8od04niLiTysMd9jdkZgjInDOIwXvSekZyN0kbjTkzmCLgwHeyB/dbqz9JIbIb3dfjRV+jZyc2AMdYnuInMlkxL311AdOmNJdLG8NMHib3iZlnfZ6qUAUehDDk5qb12AeofrXN4KCUaC3OspIlYPBCr+fgvausDaZ0plHKIkaFZmfkx8ITu7FRYBYNZwXiHB98GD4mzn+94RcOSpzR3ssS+yDvrXp17m3VY5ouC34JecNBKiaWvdBxrq5N/Xvy93xfiL0xsyUPrpg== 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-SenderADCheck; bh=vMr1GxgMjRpsPToq3JjaJECrbwcuy8yBRCL/IRAedMk=; b=QPvMaw++2I7a32a30QprUD2Qgq3N9DZa2+tjOdF8ADdirSg8KDV1D8hVFNu/9rIMwLhKUCKCTctclAps2mzwoPx2NCwl6r/KX+KYyEKCOqIMRV7cyCvRXChFm+tVeJ5/TvTgakv2+tgBxe19jbDlrYdlMGNwZL9nBkw7Pp24pAzuLaazCvtXAzMIePGOTMVGT+7l1cO/7hLd2q5m9DaTgqfhHwnrmPTfppxMRVGAZ8cdaFZJSS3eC4qMNgZd8CwnvgA/gAvAHK0HIt0xuHTbFHdgLGe/+NGsf2f7XFhBrCXpT9e41cgULOnv2fb0RbONpxm2hFYEyuxTi0C2KjvP8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vMr1GxgMjRpsPToq3JjaJECrbwcuy8yBRCL/IRAedMk=; b=puEWcxxR3wMkcuInFCLtZA1XkXBPSvQhTfk+k4+CkTYjthOF8oZ+kUSE1J/6Qfr7DPq7znsx5YKOylisHrIcDVy6TsyYi8xg7DQ5XKAUsEGcXjnsnz5soJ/J7tI801KxtYrgA0M4MWhgkR2kmx6sBSJueW2VtrRbkPgFBpZvu+I= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1952.namprd11.prod.outlook.com (2603:10b6:300:111::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23; Fri, 28 Aug 2020 17:34:47 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3326.021; Fri, 28 Aug 2020 17:34:47 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ v2] mesh: Store key indices as integers in node config Thread-Topic: [PATCH BlueZ v2] mesh: Store key indices as integers in node config Thread-Index: AQHWfVt6m8N4Q+6Zx0Cs9huLKSxS86lNyFQA Date: Fri, 28 Aug 2020 17:34:47 +0000 Message-ID: <dd5100bf840a4b0536143ece14c220d4a0f08962.camel@intel.com> References: <20200828165112.4937-1-inga.stotland@intel.com> In-Reply-To: <20200828165112.4937-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.54.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ab83732b-45e4-4673-2af3-08d84b78a8cf x-ms-traffictypediagnostic: MWHPR11MB1952: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR11MB195258A89A0C3E42B075F986E1520@MWHPR11MB1952.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:6430; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: vRXFHh/b4+My16j3hZZLDN/ryNKBaFvfAO8T/diui1ygS6fXggxpzBOjkmFFk/LL5G6XkfjWf/NUWdrAsUcxfQXS4cwMJZ1Icb3IltH6PC3SLwrccnVj+ttU2Ci5Dz/fVU+NMKRuabDLz5qW23YLc2e5uz49CagcYDSJO1wJHFmUPCpm5MOKz/jRerCIkn1SD4C0peD2r/U3Pqt9FV3hSujn1eATJJo8jbfv8LQFWcaQWKcikk6od/+Qq7d9R0xDJLbmq1SP7yMhytCb5/gUbgJQOJ6Nk+6kT/UZwZFtTDvkHrptlaCzs6qe8RTRHjbgWlVqzdgBTkxOOnM6FHIv3g== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(71200400001)(6512007)(66556008)(66476007)(64756008)(36756003)(6636002)(498600001)(66446008)(83380400001)(6486002)(2616005)(110136005)(6506007)(86362001)(8936002)(2906002)(8676002)(186003)(66946007)(76116006)(91956017)(26005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 8cvditHpN5rs2FMEzn9de+rWXywB1sVDo83vk8fBuSty5ssVXdhdDF/yUQKgH/hTzgbBfMVklwYTja9sqFfexFq8ejfQg9viMw2ecWtd9asEGD+dUd//yzwvwTxFaF99xdBLLZL/NrE7E/1dutZU37cgebYqTnG9yNnsSaVykuP5FXZPdsaX5MjEpriQPENtZsQ2xeF8X778TKQij6QUbjIpQCoUqhMtU6CZNBpEjmLy8LQ1cZ9xrCEXN4cfllK4mrNCtVAzvpnx6JNlD+y3JCoQGMp4OUj3YJ6bgRjHNLwPH05M02Rasekd4yqdoB4WATKH3kbVmo0R8E1fKrPN6GAzCy/o/prcURbIDWJwa3DII/O578FzLb7+Icbfxg/Ay0ZfjgASXSySnIXYDZnvKwS/Okdsv1C9iWEsqN2leQffY7M3I9rUilVN/Cv4wMvvxk7K9b4Mw1tK7X7TBhiup2hLxjqj8LX8g8KHt3GfePx48+bQ6TkzwWSrs3A+d2sCH1AKJJT4+sCPr8ndCCWE3FBhTYnhvB+q9DZa4vh04wrsfCTV/1fO2Acxf2mJxArebxRsx9xIxC0ILkB7sBEhUKviyS6/uzAXw3pNgTERxyI9JvFxu4BsHJ38zeeOXv6KZ2MsMKbZ3wTQSw5sziGuYw== Content-Type: text/plain; charset="utf-8" Content-ID: <A1F9934AFBFA1341ABF1D1351157D2F7@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab83732b-45e4-4673-2af3-08d84b78a8cf X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Aug 2020 17:34:47.1510 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mz9o84cPop3n0n733q4AU3Iq0eU2mX6/ESSuIs+OKFGXHQtqm4hc+dqF0anMWGRG6Ly6djYoyOWNZxwGlWZH7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1952 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4FAB7417C0 X-Rspamd-UID: 2f12b5 QXBwbGllZA0KDQpPbiBGcmksIDIwMjAtMDgtMjggYXQgMDk6NTEgLTA3MDAsIEluZ2EgU3RvdGxh bmQgd3JvdGU6DQo+IFN0b3JlIE5ldEtleSBhbmQgQXBwS2V5IGluZGljZXMgYXMgaW50ZWdlcnMg aW5zdGVhZCBvZiBoZXggc3RyaW5ncy4NCj4gVGhpcyByZW1vdmVzIHVubmVjZXNzYXJ5IHN0cmlu ZyBtYW5pcHVsYXRpb25zIHdoaWxlIG5vdCBhZmZlY3RpbmcNCj4gdGhlIGNvbmZpZ3VyYXRpb24g ZmlsZSByZWFkYWJpbGl0eS4NCj4gLS0tDQo+ICBtZXNoL21lc2gtY29uZmlnLWpzb24uYyB8IDEw MiArKysrKysrKysrKysrKystLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQo+ICAxIGZpbGUgY2hh bmdlZCwgMzggaW5zZXJ0aW9ucygrKSwgNjQgZGVsZXRpb25zKC0pDQo+IA0KPiBkaWZmIC0tZ2l0 IGEvbWVzaC9tZXNoLWNvbmZpZy1qc29uLmMgYi9tZXNoL21lc2gtY29uZmlnLWpzb24uYw0KPiBp bmRleCA2M2I2YzM5ODguLjMwYzkwMTcwZCAxMDA2NDQNCj4gLS0tIGEvbWVzaC9tZXNoLWNvbmZp Zy1qc29uLmMNCj4gKysrIGIvbWVzaC9tZXNoLWNvbmZpZy1qc29uLmMNCj4gQEAgLTI0OSwyMSAr MjQ5LDMxIEBAIHN0YXRpYyB2b2lkIGphcnJheV9zdHJpbmdfZGVsKGpzb25fb2JqZWN0ICpqYXJy YXksIGNoYXIgKnN0ciwgc2l6ZV90IGxlbikNCj4gIAl9DQo+ICB9DQo+ICANCj4gK3N0YXRpYyBi b29sIGdldF9rZXlfaW5kZXgoanNvbl9vYmplY3QgKmpvYmosIGNvbnN0IGNoYXIgKmtleXdvcmQs DQo+ICsJCQkJCQkJCXVpbnQxNl90ICppbmRleCkNCj4gK3sNCj4gKwlpbnQgaWR4Ow0KPiArDQo+ ICsJaWYgKCFnZXRfaW50KGpvYmosIGtleXdvcmQsICZpZHgpKQ0KPiArCQlyZXR1cm4gZmFsc2U7 DQo+ICsNCj4gKwlpZiAoIUNIRUNLX0tFWV9JRFhfUkFOR0UoaWR4KSkNCj4gKwkJcmV0dXJuIGZh bHNlOw0KPiArDQo+ICsJKmluZGV4ID0gKHVpbnQxNl90KSBpZHg7DQo+ICsJcmV0dXJuIHRydWU7 DQo+ICt9DQo+ICsNCj4gIHN0YXRpYyBqc29uX29iamVjdCAqZ2V0X2tleV9vYmplY3QoanNvbl9v YmplY3QgKmphcnJheSwgdWludDE2X3QgaWR4KQ0KPiAgew0KPiAgCWludCBpLCBzeiA9IGpzb25f b2JqZWN0X2FycmF5X2xlbmd0aChqYXJyYXkpOw0KPiAgDQo+ICAJZm9yIChpID0gMDsgaSA8IHN6 OyArK2kpIHsNCj4gLQkJanNvbl9vYmplY3QgKmplbnRyeSwgKmp2YWx1ZTsNCj4gLQkJY29uc3Qg Y2hhciAqc3RyOw0KPiArCQlqc29uX29iamVjdCAqamVudHJ5Ow0KPiAgCQl1aW50MTZfdCBqaWR4 Ow0KPiAgDQo+ICAJCWplbnRyeSA9IGpzb25fb2JqZWN0X2FycmF5X2dldF9pZHgoamFycmF5LCBp KTsNCj4gLQkJaWYgKCFqc29uX29iamVjdF9vYmplY3RfZ2V0X2V4KGplbnRyeSwgImluZGV4Iiwg Jmp2YWx1ZSkpDQo+IC0JCQlyZXR1cm4gTlVMTDsNCj4gLQ0KPiAtCQlzdHIgPSBqc29uX29iamVj dF9nZXRfc3RyaW5nKGp2YWx1ZSk7DQo+IC0JCWlmIChzc2NhbmYoc3RyLCAiJTA0aHgiLCAmamlk eCkgIT0gMSkNCj4gKwkJaWYgKCFnZXRfa2V5X2luZGV4KGplbnRyeSwgImluZGV4IiwgJmppZHgp KQ0KPiAgCQkJcmV0dXJuIE5VTEw7DQo+ICANCj4gIAkJaWYgKGppZHggPT0gaWR4KQ0KPiBAQCAt MjczLDI4ICsyODMsNiBAQCBzdGF0aWMganNvbl9vYmplY3QgKmdldF9rZXlfb2JqZWN0KGpzb25f b2JqZWN0ICpqYXJyYXksIHVpbnQxNl90IGlkeCkNCj4gIAlyZXR1cm4gTlVMTDsNCj4gIH0NCj4g IA0KPiAtc3RhdGljIGJvb2wgZ2V0X2tleV9pbmRleChqc29uX29iamVjdCAqam9iaiwgY29uc3Qg Y2hhciAqa2V5d29yZCwNCj4gLQkJCQkJCQkJdWludDE2X3QgKmluZGV4KQ0KPiAtew0KPiAtCXVp bnQxNl90IGlkeDsNCj4gLQlqc29uX29iamVjdCAqanZhbHVlOw0KPiAtCWNvbnN0IGNoYXIgKnN0 cjsNCj4gLQ0KPiAtCWlmICghanNvbl9vYmplY3Rfb2JqZWN0X2dldF9leChqb2JqLCBrZXl3b3Jk LCAmanZhbHVlKSkNCj4gLQkJcmV0dXJuIGZhbHNlOw0KPiAtDQo+IC0Jc3RyID0ganNvbl9vYmpl Y3RfZ2V0X3N0cmluZyhqdmFsdWUpOw0KPiAtDQo+IC0JaWYgKHNzY2FuZihzdHIsICIlMDRoeCIs ICZpZHgpICE9IDEpDQo+IC0JCXJldHVybiBmYWxzZTsNCj4gLQ0KPiAtCWlmICghQ0hFQ0tfS0VZ X0lEWF9SQU5HRShpZHgpKQ0KPiAtCQlyZXR1cm4gZmFsc2U7DQo+IC0NCj4gLQkqaW5kZXggPSAo dWludDE2X3QpIGlkeDsNCj4gLQlyZXR1cm4gdHJ1ZTsNCj4gLX0NCj4gLQ0KPiAgc3RhdGljIHZv aWQgamFycmF5X2tleV9kZWwoanNvbl9vYmplY3QgKmphcnJheSwgaW50MTZfdCBpZHgpDQo+ICB7 DQo+ICAJaW50IGksIHN6ID0ganNvbl9vYmplY3RfYXJyYXlfbGVuZ3RoKGphcnJheSk7DQo+IEBA IC01OTQsMTEgKzU4MiwyMyBAQCBmYWlsOg0KPiAgCXJldHVybiBmYWxzZTsNCj4gIH0NCj4gIA0K PiArc3RhdGljIGJvb2wgd3JpdGVfaW50KGpzb25fb2JqZWN0ICpqb2JqLCBjb25zdCBjaGFyICpk ZXNjLCBpbnQgdmFsKQ0KPiArew0KPiArCWpzb25fb2JqZWN0ICpqdmFsdWU7DQo+ICsNCj4gKwlq dmFsdWUgPSBqc29uX29iamVjdF9uZXdfaW50KHZhbCk7DQo+ICsJaWYgKCFqdmFsdWUpDQo+ICsJ CXJldHVybiBmYWxzZTsNCj4gKw0KPiArCWpzb25fb2JqZWN0X29iamVjdF9kZWwoam9iaiwgZGVz Yyk7DQo+ICsJanNvbl9vYmplY3Rfb2JqZWN0X2FkZChqb2JqLCBkZXNjLCBqdmFsdWUpOw0KPiAr CXJldHVybiB0cnVlOw0KPiArfQ0KPiArDQo+ICBib29sIG1lc2hfY29uZmlnX25ldF9rZXlfYWRk KHN0cnVjdCBtZXNoX2NvbmZpZyAqY2ZnLCB1aW50MTZfdCBpZHgsDQo+ICAJCQkJCQkJY29uc3Qg dWludDhfdCBrZXlbMTZdKQ0KPiAgew0KPiAtCWpzb25fb2JqZWN0ICpqbm9kZSwgKmphcnJheSA9 IE5VTEwsICpqZW50cnkgPSBOVUxMLCAqanN0cmluZzsNCj4gLQljaGFyIGJ1Zls1XTsNCj4gKwlq c29uX29iamVjdCAqam5vZGUsICpqYXJyYXkgPSBOVUxMLCAqamVudHJ5ID0gTlVMTDsNCj4gIA0K PiAgCWlmICghY2ZnKQ0KPiAgCQlyZXR1cm4gZmFsc2U7DQo+IEBAIC02MTgsMTMgKzYxOCw5IEBA IGJvb2wgbWVzaF9jb25maWdfbmV0X2tleV9hZGQoc3RydWN0IG1lc2hfY29uZmlnICpjZmcsIHVp bnQxNl90IGlkeCwNCj4gIAlpZiAoIWplbnRyeSkNCj4gIAkJcmV0dXJuIGZhbHNlOw0KPiAgDQo+ IC0Jc25wcmludGYoYnVmLCA1LCAiJTQuNHgiLCBpZHgpOw0KPiAtCWpzdHJpbmcgPSBqc29uX29i amVjdF9uZXdfc3RyaW5nKGJ1Zik7DQo+IC0JaWYgKCFqc3RyaW5nKQ0KPiArCWlmICghd3JpdGVf aW50KGplbnRyeSwgImluZGV4IiwgaWR4KSkNCj4gIAkJZ290byBmYWlsOw0KPiAgDQo+IC0JanNv bl9vYmplY3Rfb2JqZWN0X2FkZChqZW50cnksICJpbmRleCIsIGpzdHJpbmcpOw0KPiAtDQo+ICAJ aWYgKCFhZGRfa2V5X3ZhbHVlKGplbnRyeSwgImtleSIsIGtleSkpDQo+ICAJCWdvdG8gZmFpbDsN Cj4gIA0KPiBAQCAtNzI0LDggKzcyMCw3IEBAIGJvb2wgbWVzaF9jb25maWdfd3JpdGVfdG9rZW4o c3RydWN0IG1lc2hfY29uZmlnICpjZmcsIHVpbnQ4X3QgKnRva2VuKQ0KPiAgYm9vbCBtZXNoX2Nv bmZpZ19hcHBfa2V5X2FkZChzdHJ1Y3QgbWVzaF9jb25maWcgKmNmZywgdWludDE2X3QgbmV0X2lk eCwNCj4gIAkJCQkJdWludDE2X3QgYXBwX2lkeCwgY29uc3QgdWludDhfdCBrZXlbMTZdKQ0KPiAg ew0KPiAtCWpzb25fb2JqZWN0ICpqbm9kZSwgKmphcnJheSA9IE5VTEwsICpqZW50cnkgPSBOVUxM LCAqanN0cmluZyA9IE5VTEw7DQo+IC0JY2hhciBidWZbNV07DQo+ICsJanNvbl9vYmplY3QgKmpu b2RlLCAqamFycmF5ID0gTlVMTCwgKmplbnRyeSA9IE5VTEw7DQo+ICANCj4gIAlpZiAoIWNmZykN Cj4gIAkJcmV0dXJuIGZhbHNlOw0KPiBAQCAtNzQ0LDIwICs3MzksMTIgQEAgYm9vbCBtZXNoX2Nv bmZpZ19hcHBfa2V5X2FkZChzdHJ1Y3QgbWVzaF9jb25maWcgKmNmZywgdWludDE2X3QgbmV0X2lk eCwNCj4gIAlpZiAoIWplbnRyeSkNCj4gIAkJcmV0dXJuIGZhbHNlOw0KPiAgDQo+IC0Jc25wcmlu dGYoYnVmLCA1LCAiJTQuNHgiLCBhcHBfaWR4KTsNCj4gLQlqc3RyaW5nID0ganNvbl9vYmplY3Rf bmV3X3N0cmluZyhidWYpOw0KPiAtCWlmICghanN0cmluZykNCj4gKwlpZiAoIXdyaXRlX2ludChq ZW50cnksICJpbmRleCIsIGFwcF9pZHgpKQ0KPiAgCQlnb3RvIGZhaWw7DQo+ICANCj4gLQlqc29u X29iamVjdF9vYmplY3RfYWRkKGplbnRyeSwgImluZGV4IiwganN0cmluZyk7DQo+IC0NCj4gLQlz bnByaW50ZihidWYsIDUsICIlNC40eCIsIG5ldF9pZHgpOw0KPiAtCWpzdHJpbmcgPSBqc29uX29i amVjdF9uZXdfc3RyaW5nKGJ1Zik7DQo+IC0JaWYgKCFqc3RyaW5nKQ0KPiArCWlmICghd3JpdGVf aW50KGplbnRyeSwgImJvdW5kTmV0S2V5IiwgbmV0X2lkeCkpDQo+ICAJCWdvdG8gZmFpbDsNCj4g IA0KPiAtCWpzb25fb2JqZWN0X29iamVjdF9hZGQoamVudHJ5LCAiYm91bmROZXRLZXkiLCBqc3Ry aW5nKTsNCj4gLQ0KPiAgCWlmICghYWRkX2tleV92YWx1ZShqZW50cnksICJrZXkiLCBrZXkpKQ0K PiAgCQlnb3RvIGZhaWw7DQo+ICANCj4gQEAgLTk5NSw2ICs5ODIsNyBAQCBzdGF0aWMgc3RydWN0 IG1lc2hfY29uZmlnX3B1YiAqcGFyc2VfbW9kZWxfcHVibGljYXRpb24oanNvbl9vYmplY3QgKmpw dWIpDQo+ICAJY2FzZSAzMjoNCj4gIAkJaWYgKCFzdHIyaGV4KHN0ciwgbGVuLCBwdWItPnZpcnRf YWRkciwgMTYpKQ0KPiAgCQkJZ290byBmYWlsOw0KPiArDQo+ICAJCXB1Yi0+dmlydCA9IHRydWU7 DQo+ICAJCWJyZWFrOw0KPiAgCWRlZmF1bHQ6DQo+IEBAIC0xNDY4LDE5ICsxNDU2LDYgQEAgc3Rh dGljIGJvb2wgd3JpdGVfdWludDMyX2hleChqc29uX29iamVjdCAqam9iaiwgY29uc3QgY2hhciAq ZGVzYywgdWludDMyX3QgdmFsKQ0KPiAgCXJldHVybiB0cnVlOw0KPiAgfQ0KPiAgDQo+IC1zdGF0 aWMgYm9vbCB3cml0ZV9pbnQoanNvbl9vYmplY3QgKmpvYmosIGNvbnN0IGNoYXIgKmRlc2MsIGlu dCB2YWwpDQo+IC17DQo+IC0JanNvbl9vYmplY3QgKmp2YWx1ZTsNCj4gLQ0KPiAtCWp2YWx1ZSA9 IGpzb25fb2JqZWN0X25ld19pbnQodmFsKTsNCj4gLQlpZiAoIWp2YWx1ZSkNCj4gLQkJcmV0dXJu IGZhbHNlOw0KPiAtDQo+IC0JanNvbl9vYmplY3Rfb2JqZWN0X2RlbChqb2JqLCBkZXNjKTsNCj4g LQlqc29uX29iamVjdF9vYmplY3RfYWRkKGpvYmosIGRlc2MsIGp2YWx1ZSk7DQo+IC0JcmV0dXJu IHRydWU7DQo+IC19DQo+IC0NCj4gIHN0YXRpYyBjb25zdCBjaGFyICptb2RlX3RvX3N0cmluZyhp bnQgbW9kZSkNCj4gIHsNCj4gIAlzd2l0Y2ggKG1vZGUpIHsNCj4gQEAgLTE4NzIsNyArMTg0Nyw3 IEBAIGJvb2wgbWVzaF9jb25maWdfbW9kZWxfcHViX2FkZChzdHJ1Y3QgbWVzaF9jb25maWcgKmNm ZywgdWludDE2X3QgZWxlX2FkZHIsDQo+ICAJaWYgKCFyZXMpDQo+ICAJCWdvdG8gZmFpbDsNCj4g IA0KPiAtCWlmICghd3JpdGVfdWludDE2X2hleChqcHViLCAiaW5kZXgiLCBwdWItPmlkeCkpDQo+ ICsJaWYgKCF3cml0ZV9pbnQoanB1YiwgImluZGV4IiwgcHViLT5pZHgpKQ0KPiAgCQlnb3RvIGZh aWw7DQo+ICANCj4gIAlpZiAoIXdyaXRlX2ludChqcHViLCAidHRsIiwgcHViLT50dGwpKQ0KPiBA QCAtMTg4MSw4ICsxODU2LDcgQEAgYm9vbCBtZXNoX2NvbmZpZ19tb2RlbF9wdWJfYWRkKHN0cnVj dCBtZXNoX2NvbmZpZyAqY2ZnLCB1aW50MTZfdCBlbGVfYWRkciwNCj4gIAlpZiAoIXdyaXRlX2lu dChqcHViLCAicGVyaW9kIiwgcHViLT5wZXJpb2QpKQ0KPiAgCQlnb3RvIGZhaWw7DQo+ICANCj4g LQlpZiAoIXdyaXRlX2ludChqcHViLCAiY3JlZGVudGlhbHMiLA0KPiAtCQkJCQkJcHViLT5jcmVk ZW50aWFsID8gMSA6IDApKQ0KPiArCWlmICghd3JpdGVfaW50KGpwdWIsICJjcmVkZW50aWFscyIs IHB1Yi0+Y3JlZGVudGlhbCA/IDEgOiAwKSkNCj4gIAkJZ290byBmYWlsOw0KPiAgDQo+ICAJanJ0 eCA9IGpzb25fb2JqZWN0X25ld19vYmplY3QoKTsNCg== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uOZ4GkRBSV+KJwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 28 Aug 2020 19:39:16 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id gLp5GURBSV9xUAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 28 Aug 2020 19:39:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A3FBC420D5; Fri, 28 Aug 2020 19:39:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726654AbgH1RjJ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 13:39:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725979AbgH1RjG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 13:39:06 -0400 Received: from mail-ua1-x944.google.com (mail-ua1-x944.google.com [IPv6:2607:f8b0:4864:20::944]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCC69C061264 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 10:39:04 -0700 (PDT) Received: by mail-ua1-x944.google.com with SMTP id g20so626063uap.8 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 10:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=83mTnWWXG7WFYcr10rntPntqh05P5b7hERwEwyd9wf0=; b=j0lA5bHKaxKxedVcnpAcn/LIBj5wcXISGJkaa64a22wQPulTAUSSDXJ/TJRHoxHtnK 0056gKSbW//A9LcHq/EM0T7JKbfuicc0UHEioR5+VlkO1sFqYv2PAcE9i9L1+oteZTqm vV9q7zHg0K0RMspfSUCh1iuFu5HJn3/b1rKls= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=83mTnWWXG7WFYcr10rntPntqh05P5b7hERwEwyd9wf0=; b=G5BoKtOZdZzsMfXZe/dn10DjSMhIv7zM7tcdKf2/5c39ij5ZRu0c88/gtxBvvYnlm6 +e/J6pRtTzbjXtEocQofSDQzxkrs4EzBO2xWhRqPi7KfNfr2dX6OiGCv7b4KppqMGyD6 b8We3aQxsyXS4pQ+7s+g5qOFWlxt9oSFQgKDhQOZMcgVVHUjeiCBDRIBzcFzFiDjovyD bSdm2Zx8e27oGlSrn54MZBg3+7n6KwNuCQMvamK//S9eeyRyxuqKVfcR9calWAze6mlR J/VoF6W+VXuN3EKFDgiPKcLRUL9vLoLyao5NVJM9B+fI05/tLDZFnd71QISvfmWpE1Qi zhhw== X-Gm-Message-State: AOAM530st1bj/wBktBAh5Q+qSMDrKhUmIr4WN90hn2ivWcH7bXG7cTQs c1t5a+nTQfgVU1ar/+VgYBzvQKVp70GF4tbnXwI4+w== X-Google-Smtp-Source: ABdhPJxxrHooY3ZRSKmhwC8sKq9K/ICwN6X5V3eAnh3ZhOaaZOwPgWeWuaKF9Xh0SnnNMA/L+n53LdqEaB+kkHjNiEo= X-Received: by 2002:ab0:5905:: with SMTP id n5mr1983421uad.90.1598636343793; Fri, 28 Aug 2020 10:39:03 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> <CANFp7mWqT1mO0OcJAt4AycTgFLz22p7zyRGjR1Hvj4bJmHHsTw@mail.gmail.com> <CABBYNZLmfWWBYZjHDkHmMpzYC02zFpWMV_xAiD1pK3cc09JwSA@mail.gmail.com> <CANFp7mWf1xDg6+nLMyrjaMaqF0=GyhauwN43ny5QMT0MWYd+tA@mail.gmail.com> <CABBYNZ+YMfvcVnB7afXyFa_bz2oNaivgsmyhS=yOGrKuh4JG9A@mail.gmail.com> In-Reply-To: <CABBYNZ+YMfvcVnB7afXyFa_bz2oNaivgsmyhS=yOGrKuh4JG9A@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Fri, 28 Aug 2020 10:38:51 -0700 Message-ID: <CANFp7mVWAWkDgYJT61xGKAgYzycbjyaePngFho9dcfqkxRcuPg@mail.gmail.com> Subject: Re: [Bluez PATCH v2 0/3] adapter: Reconnect audio when resuming from suspend To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Bluez mailing list <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: A3FBC420D5 X-Rspamd-UID: 99919d Hey Luiz, On Fri, Aug 28, 2020 at 10:22 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Abhishek, > > On Thu, Aug 27, 2020 at 2:13 PM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > Hi Luiz, > > > > On Wed, Aug 26, 2020 at 11:21 PM Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > > > > > > Hi Abhishek, > > > > > > On Wed, Aug 26, 2020 at 10:41 AM Abhishek Pandit-Subedi > > > <abhishekpandit@chromium.org> wrote: > > > > > > > > Hi Luiz, > > > > > > > > Could you PTAL at this v2 patch series. I refactored the audio > > > > reconnect to use the policy plugin instead of doing the reconnect as > > > > part of the adapter logic, as requested. > > > > > > > > Thanks > > > > Abhishek > > > > > > > > On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi > > > > <abhishekpandit@chromium.org> wrote: > > > > > > > > > > > > > > > Hi Luiz and Marcel, > > > > > > > > > > This is a quality of life improvement for the behavior of audio devices > > > > > during system suspend. This depends on a kernel change that emits > > > > > suspend/resume events: > > > > > > > > > > https://patchwork.kernel.org/project/bluetooth/list/?series=325771 > > > > > > So we could not just use the disconnect reason like I suggested? > > > > I am using the disconnect reason to mark the device for reconnection > > and only queueing it for reconnect on resume. As mentioned in the > > patch, this is to account for resumes that are not user driven and > > will suspend almost immediately again (i.e. periodic wake up to check > > battery level and see if we need to shut down). > > > > > > > > > > Right now, audio devices will be disconnected as part of suspend but > > > > > won't be reconnected when the system resumes without user interaction. > > > > > This is annoying to some users as it causes an interruption to their > > > > > normal work flow. > > > > > > > > > > This change reconnects audio devices that were disconnected for suspend > > > > > using the following logic: > > > > > > > > > > * Register a callback for controller resume in the policy plugin. > > > > > * In the device disconnect callback, mark any devices with the A2DP > > > > > service uuid for reconnect on resume after a delay. > > > > > * In the controller resume callback, queue any policy items that are > > > > > marked to reconnect on resume for connection with the > > > > > ReconnectAudioDelay value (default = 5s for Wi-Fi coexistence). > > > > > > Something like ResumeDelay would probably be better. > > > > Sure, I will rename this. > > > > > > > > > > A reconnect is only attempted once after the controller resumes and the > > > > > delay between resume and reconnect is configurable via the > > > > > ReconnectAudioDelay key in the Policy settings. The 5s delay was chosen > > > > > arbitrarily and I think anywhere up to 10s is probably ok. A longer > > > > > delay is better to account for spurious wakeups and Wi-Fi reconnection > > > > > time (avoiding any co-ex issues) at the downside of reconnection speed. > > > > > > I would keep the same logic as out of range so the platforms can > > > customize the number of attempts. > > > > So the first reconnect attempt after resume should be separately > > configurable (i.e. 5s) but subsequent reconnect attempts would use the > > reconnect-intervals values? That sounds good to me. > > Right, though 5 seconds seems awfully long compared to the normal > first attempt, so perhaps we could default it to just 1-2 seconds. > I will change the default to 2s and make sure we test this on some older chipsets to check for interference with Wi-Fi. > > > > > > > > Here are the tests I have done with this: > > > > > - Single suspend and verified the headphones reconnect > > > > > - Suspend stress test for 25 iterations and verify both Wi-Fi and > > > > > Bluetooth audio reconnect on resume. (Ran with wake minimum time of > > > > > 10s) > > > > > - Suspend test with wake time < 5s to verify that BT reconnect isn't > > > > > attempted. Ran 5 iterations with low wake time and then let it stay > > > > > awake to confirm reconnect finally completed after 5s+ wake time. > > > > > - Suspend test with wake time between 3s - 6s. Ran with 5 iterations and > > > > > verified it wasn't connected at the end. A connection attempt was > > > > > made but not completed due to suspend. A reconnect attempt was not > > > > > made afterwards, which is by design. > > > > > > > > > > Luiz@ Marcel@: Does this sound ok (give up after an attempt)? > > > > > > > > > > I've tested this on a Pixelbook Go (AC-9260 controller) and HP > > > > > Chromebook 14a (RTL8822CE controller) with GID6B headset. > > > > > > > > > > I've also tested this with the Pixel Buds 2. These earbuds actually > > > > > reconnect automatically to the Chromebook (even without this policy > > > > > change) and I verified that the new changes don't break the reconnection > > > > > mechanism. > > > > > > > > > > Thanks > > > > > Abhishek > > > > > > > > > > > > > > > Changes in v2: > > > > > - Refactored to use policy instead of connecting directly in adapter > > > > > > > > > > Abhishek Pandit-Subedi (3): > > > > > mgmt: Add controller suspend and resume events > > > > > monitor: Add btmon support for Suspend and Resume events > > > > > policy: Reconnect audio on controller resume > > > > > > > > > > lib/mgmt.h | 14 +++++++++++ > > > > > monitor/packet.c | 55 +++++++++++++++++++++++++++++++++++++++++ > > > > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > > > > > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > > > > > src/adapter.h | 6 +++++ > > > > > src/main.c | 1 + > > > > > src/main.conf | 9 +++++++ > > > > > 7 files changed, 190 insertions(+), 4 deletions(-) > > > > > > > > > > -- > > > > > 2.28.0.297.g1956fa8f8d-goog > > > > > > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Thanks Abhishek Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6Jc/IlJFSV+KJwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 28 Aug 2020 19:56:34 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OPvSIVJFSV/Z1QEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 28 Aug 2020 19:56:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0DE84A112B; Fri, 28 Aug 2020 19:56:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727969AbgH1R4W (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 13:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726677AbgH1R4V (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 13:56:21 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2689C061264 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 10:56:20 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id n23so1596145otq.11 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 10:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=98Dw+kNTUpfY8xqkmQIkoZ3Vt1R+Nz7p3iSUI0oX40Q=; b=u/9pAo88LddfZji/ypCVpF4QPKGlJbLhypbkTEKgf+v+oCCi36aqje3Esu7weHIC19 NdoC7fzdlCeOtv831AP5obhWgtE113JIqR/bN0748eHFyB0jTDJ6uf8VSSQpoTnJTgOk Va3y7HV7E2Mgp6VCeP0Zv2gXR3KNFi2ch4dzUu+Z6Hs6uw6HgTJv1a2D63qAv8CyZSJi tCuYMm3l3h6Kx7kRUzirnL7+cC9mA4sDtflS04X1iEzi/SotFeufqGuH/uI/AJtJ7YP6 JvdpjQlqDQIGQvX2QcywE1OoCoB1CFSFIqr+dMV4L4NODY8O0w31neTb0rRxEBgP4Rjf kw/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=98Dw+kNTUpfY8xqkmQIkoZ3Vt1R+Nz7p3iSUI0oX40Q=; b=LuLiVY8n7uLXPnSvfy8MCifOAQ/vEgIBUnCupoJIIMy8mXF2XfiXi/DMrR4bYnyZs4 FQGRtKrsVo5cWz2CcZ9FLtz5qvtOIhGeHpXvfKnMAKYY+TRooRSYaD0iaJkvRLoGIyfR gTp2p3Lv7/Td7SK9a1B6ramwadTjcnaH1zwnRK3eJNkBg2sFfAfUaVJl0v26BWM9ljAi H9izCtW77ZDHf2xPaib/jziyn50CaAMziWUo98D4dsnqmL0s8RYcW6RIZv6SZyGz0KM/ jIkGDE7VYDZ/ghYEo2zDp5vlFTP1KKUS2mcJod5GD3ZdrTqRLvY75nvkrfvVOg3QmWIF TXgg== X-Gm-Message-State: AOAM5336VfhxMiHqkxJvE6CxNq+DgYcGk7/TWg8IYyo6MzdrjuM+j+4Z euJA3Pz9o330UMGLgpTMpQrDQcAwD8xK0/7jDMJfFjVi X-Google-Smtp-Source: ABdhPJwJUERDOxMuNrRiNWPBaReFaD9U3/ducgk1rZF0lQihABTcSwRNbDID2sPQ6mNkTap8MqpDcDgzB+U08mGbsAg= X-Received: by 2002:a9d:7e7:: with SMTP id 94mr2027147oto.91.1598637378712; Fri, 28 Aug 2020 10:56:18 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> <20200818162807.Bluez.v2.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> <CABBYNZLb_ETfO1VyAf+1rXpRT_XroQLq7u=uK6PGcrOKR7PHxA@mail.gmail.com> <CANFp7mV03KvqpOH=LBU=0tBDhgK5K2YJ6rxYvkDKmyer4n_gLw@mail.gmail.com> <CABBYNZ+SYSgzR_wX5Cn+5zUjep6HazCdJvAgZ0EE0uLkB_PEGg@mail.gmail.com> <CANFp7mU-gunJi5pAMY0zqE-BFGB6XDE=nPpxjU0Lqf7RBKDDpw@mail.gmail.com> In-Reply-To: <CANFp7mU-gunJi5pAMY0zqE-BFGB6XDE=nPpxjU0Lqf7RBKDDpw@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 28 Aug 2020 10:56:08 -0700 Message-ID: <CABBYNZ+VR7xG=TuK8VBg+6mg8C2hB=x9EWXhxV1CJYmNNhA4ng@mail.gmail.com> Subject: Re: [Bluez PATCH v2 3/3] policy: Reconnect audio on controller resume To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0DE84A112B X-Rspamd-UID: 7843eb Hi Abhishek, On Fri, Aug 28, 2020 at 10:31 AM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Hi Luiz, > > On Fri, Aug 28, 2020 at 10:09 AM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Abhishek, > > > > On Thu, Aug 27, 2020 at 2:08 PM Abhishek Pandit-Subedi > > <abhishekpandit@chromium.org> wrote: > > > > > > Hi Luiz, > > > > > > On Wed, Aug 26, 2020 at 11:32 PM Luiz Augusto von Dentz > > > <luiz.dentz@gmail.com> wrote: > > > > > > > > Hi Abhishek, > > > > > > > > On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi > > > > <abhishekpandit@chromium.org> wrote: > > > > > > > > > > During system suspend, all peer devices are disconnected. On resume, HID > > > > > devices will reconnect but audio devices stay disconnected. As a quality > > > > > of life improvement, mark audio devices that were disconnected due to > > > > > suspend and attempt to reconnect them when the controller resumes (after > > > > > a delay for better co-existence with Wi-Fi). > > > > > > > > > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > > > > --- > > > > > > > > > > Changes in v2: > > > > > - Refactored to use policy instead of connecting directly in adapter > > > > > > > > > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > > > > > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > > > > > src/adapter.h | 6 +++++ > > > > > src/main.c | 1 + > > > > > src/main.conf | 9 +++++++ > > > > > 5 files changed, 121 insertions(+), 4 deletions(-) > > > > > > > > > > diff --git a/plugins/policy.c b/plugins/policy.c > > > > > index de51e58b9..b07a997b9 100644 > > > > > --- a/plugins/policy.c > > > > > +++ b/plugins/policy.c > > > > > @@ -75,6 +75,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; > > > > > static int *reconnect_intervals = NULL; > > > > > static size_t reconnect_intervals_len = 0; > > > > > > > > > > +static const int default_reconnect_delay = 5; > > > > > +static int resume_reconnect_delay = 5; > > > > > + > > > > > static GSList *reconnects = NULL; > > > > > > > > > > static unsigned int service_id = 0; > > > > > @@ -93,6 +96,8 @@ struct policy_data { > > > > > uint8_t ct_retries; > > > > > guint tg_timer; > > > > > uint8_t tg_retries; > > > > > + > > > > > + bool reconnect_on_resume; > > > > > }; > > > > > > > > > > static struct reconnect_data *reconnect_find(struct btd_device *dev) > > > > > @@ -214,6 +219,7 @@ static gboolean policy_connect_sink(gpointer user_data) > > > > > > > > > > data->sink_timer = 0; > > > > > data->sink_retries++; > > > > > + data->reconnect_on_resume = false; > > > > > > > > > > service = btd_device_get_service(data->dev, A2DP_SINK_UUID); > > > > > if (service != NULL) > > > > > @@ -222,16 +228,20 @@ static gboolean policy_connect_sink(gpointer user_data) > > > > > return FALSE; > > > > > } > > > > > > > > > > -static void policy_set_sink_timer(struct policy_data *data) > > > > > +static void policy_set_sink_timer_internal(struct policy_data *data, int timeout) > > > > > { > > > > > if (data->sink_timer > 0) > > > > > g_source_remove(data->sink_timer); > > > > > > > > > > - data->sink_timer = g_timeout_add_seconds(SINK_RETRY_TIMEOUT, > > > > > - policy_connect_sink, > > > > > + data->sink_timer = g_timeout_add_seconds(timeout, policy_connect_sink, > > > > > data); > > > > > } > > > > > > > > > > +static void policy_set_sink_timer(struct policy_data *data) > > > > > +{ > > > > > + policy_set_sink_timer_internal(data, SINK_RETRY_TIMEOUT); > > > > > +} > > > > > + > > > > > static void sink_cb(struct btd_service *service, btd_service_state_t old_state, > > > > > btd_service_state_t new_state) > > > > > { > > > > > @@ -743,10 +753,30 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) > > > > > static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > > > > { > > > > > struct reconnect_data *reconnect; > > > > > + struct btd_service *service; > > > > > + struct policy_data *data; > > > > > + bool do_reconnect = false; > > > > > > > > > > DBG("reason %u", reason); > > > > > > > > > > - if (reason != MGMT_DEV_DISCONN_TIMEOUT) > > > > > + switch(reason) { > > > > > + case MGMT_DEV_DISCONN_LOCAL_HOST: > > > > > + case MGMT_DEV_DISCONN_REMOTE: > > > > > + do_reconnect = true; > > > > > + break; > > > > > + /* Disconnect due to suspend will queue reconnect on resume for a2dp */ > > > > > + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: > > > > > + service = btd_device_get_service(dev, A2DP_SINK_UUID); > > > > > + if (service && (data = policy_get_data(dev))) { > > > > > + data->reconnect_on_resume = true; > > > > > + } > > > > > > > > Can't we just program the timer directly here? Or would that wakeup > > > > the system, I would imagine all timers are disabled while suspended > > > > which means when the system resumes so does the timers which would > > > > then trigger the reconnection logic. > > > > > > This approach works if every resume is user initiated and keeps the > > > device awake long enough to reconnect to the audio device. On > > > ChromeOS, this isn't always the case. We have a feature called Dark > > > Resume that occurs when the system wakes to handle an event that > > > doesn't require user intervention and suspends again without ever > > > turning on the screen. See: > > > https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/docs/dark_resume.md. > > > A primary user for this is a periodic wake-up that checks battery > > > percentage and shuts down the system if it's too low. > > > > Ok I didn't know such a feature exists in ChromeOS, but doesn't Dark > > Resumes should be handled by the kernel instead of each userspace > > component? I suppose there quite a few timers that may have side > > effects if dark resumes actually resume them. > > > > I'm not aware of the history around it but I found another page with > more context of use cases (like actually letting a user space > application run as would happen on a smartphone): > https://www.chromium.org/chromium-os/chromiumos-design-docs/lucid-sleep > > > > One of the tests I ran specifically for this is a suspend stress test > > > with a wake time between 2-4s (i.e. suspend_stress_test -c 10 > > > --wake_min 2 --wake_max 3) which emulates dark resumes. If we set the > > > timer when disconnecting, the device would attempt a connection on one > > > of the wakeups and fail (since we suspended without completing the > > > connection). > > > > We could perhaps check if the kernel is capable of emitting > > suspend/resume events and if not just program the timer, or > > alternatively add another config option to indicate when the system > > supports such concept of Dark Resumes. > > > > How does the following sound: > > * On disconnect, I always queue the reconnect but with the resume > delay set instead of the interval[0] value. I also set the > resume_reconnect flag > * On every resume event (or dark resume event), I reset the timer and > add resume_delay seconds if resume_reconnect is set > * The first time the reconnect_timeout runs, I clear the resume_reconnect flag > > The delay will only be reapplied if the kernel is capable of emitting > suspend/resume events and/or dark resume events. That should work as well, does full resumes need to reset the timer though? Or we don't have any means to identify the resume type? Well either way I guess the difference would be quite small since the timeout is the same just when it is programmed (on suspend vs on resume). > > > > > > > > > + break; > > > > > + /* All other cases do not result in reconnect */ > > > > > + default: > > > > > + break; > > > > > + } > > > > > + > > > > > + if (!do_reconnect) > > > > > return; > > > > > > > > > > reconnect = reconnect_find(dev); > > > > > @@ -761,6 +791,23 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > > > > reconnect_set_timer(reconnect); > > > > > } > > > > > > > > > > +static void controller_resume_cb(uint8_t wake_reason, const bdaddr_t *addr, > > > > > + const uint8_t addr_type) > > > > > +{ > > > > > + struct btd_device *dev; > > > > > + GSList *l; > > > > > + > > > > > + /* Check if any devices needed to be reconnected on resume */ > > > > > + for (l = devices; l; l = g_slist_next(l)) { > > > > > + struct policy_data *data = l->data; > > > > > + > > > > > + if (data->reconnect_on_resume) { > > > > > + policy_set_sink_timer_internal(data, > > > > > + resume_reconnect_delay); > > > > > + } > > > > > + } > > > > > +} > > > > > + > > > > > static void conn_fail_cb(struct btd_device *dev, uint8_t status) > > > > > { > > > > > struct reconnect_data *reconnect; > > > > > @@ -854,9 +901,17 @@ static int policy_init(void) > > > > > auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", > > > > > NULL); > > > > > > > > > > + resume_reconnect_delay = g_key_file_get_integer( > > > > > + conf, "Policy", "ReconnectAudioDelay", &gerr); > > > > > + > > > > > + if (gerr) { > > > > > + g_clear_error(&gerr); > > > > > + resume_reconnect_delay = default_reconnect_delay; > > > > > + } > > > > > done: > > > > > if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { > > > > > btd_add_disconnect_cb(disconnect_cb); > > > > > + btd_add_controller_resume_cb(controller_resume_cb); > > > > > btd_add_conn_fail_cb(conn_fail_cb); > > > > > } > > > > > > > > > > @@ -869,6 +924,7 @@ done: > > > > > static void policy_exit(void) > > > > > { > > > > > btd_remove_disconnect_cb(disconnect_cb); > > > > > + btd_remove_controller_resume_cb(controller_resume_cb); > > > > > btd_remove_conn_fail_cb(conn_fail_cb); > > > > > > > > > > if (reconnect_uuids) > > > > > diff --git a/src/adapter.c b/src/adapter.c > > > > > index 5e896a9f0..7526feb9e 100644 > > > > > --- a/src/adapter.c > > > > > +++ b/src/adapter.c > > > > > @@ -139,6 +139,7 @@ static GSList *adapter_drivers = NULL; > > > > > > > > > > static GSList *disconnect_list = NULL; > > > > > static GSList *conn_fail_list = NULL; > > > > > +static GSList *controller_resume_list = NULL; > > > > > > > > > > struct link_key_info { > > > > > bdaddr_t bdaddr; > > > > > @@ -8766,6 +8767,45 @@ static void connected_callback(uint16_t index, uint16_t length, > > > > > eir_data_free(&eir_data); > > > > > } > > > > > > > > > > +static void controller_resume_notify(const uint8_t wake_reason, > > > > > + const bdaddr_t *addr, > > > > > + const uint8_t addr_type) > > > > > +{ > > > > > + GSList *l; > > > > > + > > > > > + for (l = controller_resume_list; l; l = g_slist_next(l)) { > > > > > + btd_controller_resume_cb resume_cb = l->data; > > > > > + resume_cb(wake_reason, addr, addr_type); > > > > > + } > > > > > +} > > > > > + > > > > > +static void controller_resume_callback(uint16_t index, uint16_t length, > > > > > + const void *param, void *user_data) > > > > > +{ > > > > > + const struct mgmt_ev_controller_resume *ev = param; > > > > > + struct btd_adapter *adapter = user_data; > > > > > + > > > > > + if (length < sizeof(*ev)) { > > > > > + btd_error(adapter->dev_id, "Too small device resume event"); > > > > > + return; > > > > > + } > > > > > + > > > > > + DBG("Controller resume with wake event 0x%x", ev->wake_reason); > > > > > + > > > > > + controller_resume_notify(ev->wake_reason, &ev->addr.bdaddr, > > > > > + ev->addr.type); > > > > > +} > > > > > + > > > > > +void btd_add_controller_resume_cb(btd_controller_resume_cb func) > > > > > +{ > > > > > + controller_resume_list = g_slist_append(controller_resume_list, func); > > > > > +} > > > > > + > > > > > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func) > > > > > +{ > > > > > + controller_resume_list = g_slist_remove(controller_resume_list, func); > > > > > +} > > > > > + > > > > > static void device_blocked_callback(uint16_t index, uint16_t length, > > > > > const void *param, void *user_data) > > > > > { > > > > > @@ -9389,6 +9429,11 @@ static void read_info_complete(uint8_t status, uint16_t length, > > > > > user_passkey_notify_callback, > > > > > adapter, NULL); > > > > > > > > > > + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, > > > > > + adapter->dev_id, > > > > > + controller_resume_callback, > > > > > + adapter, NULL); > > > > > + > > > > > set_dev_class(adapter); > > > > > > > > > > set_name(adapter, btd_adapter_get_name(adapter)); > > > > > diff --git a/src/adapter.h b/src/adapter.h > > > > > index f8ac20261..5527e4205 100644 > > > > > --- a/src/adapter.h > > > > > +++ b/src/adapter.h > > > > > @@ -67,6 +67,12 @@ typedef void (*btd_conn_fail_cb) (struct btd_device *device, uint8_t status); > > > > > void btd_add_conn_fail_cb(btd_conn_fail_cb func); > > > > > void btd_remove_conn_fail_cb(btd_conn_fail_cb func); > > > > > > > > > > +typedef void (*btd_controller_resume_cb)(const uint8_t wake_reason, > > > > > + const bdaddr_t *addr, > > > > > + const uint8_t addr_type); > > > > > +void btd_add_controller_resume_cb(btd_controller_resume_cb func); > > > > > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func); > > > > > > > > If we can program the timer just before we suspend this is not really > > > > necessary, but if you still thing that would be a good idea to notify > > > > Id put it in btd_adapter_driver with a callback for suspend and > > > > resume, that way we don't have to maintain multiple lists for each of > > > > the callbacks. > > > > > > The adapter driver seems like a reasonable place to put this so let me > > > port that over. > > > > > > > > > > > > struct btd_adapter *adapter_find(const bdaddr_t *sba); > > > > > struct btd_adapter *adapter_find_by_id(int id); > > > > > void adapter_foreach(adapter_cb func, gpointer user_data); > > > > > diff --git a/src/main.c b/src/main.c > > > > > index 2c083de67..a1c3e7e9f 100644 > > > > > --- a/src/main.c > > > > > +++ b/src/main.c > > > > > @@ -131,6 +131,7 @@ static const char *policy_options[] = { > > > > > "ReconnectAttempts", > > > > > "ReconnectIntervals", > > > > > "AutoEnable", > > > > > + "ReconnectAudioDelay", > > > > > NULL > > > > > }; > > > > > > > > > > diff --git a/src/main.conf b/src/main.conf > > > > > index f41203b96..8d74a2aec 100644 > > > > > --- a/src/main.conf > > > > > +++ b/src/main.conf > > > > > @@ -198,3 +198,12 @@ > > > > > # This includes adapters present on start as well as adapters that are plugged > > > > > # in later on. Defaults to 'false'. > > > > > #AutoEnable=false > > > > > + > > > > > +# Audio devices that were disconnected due to suspend will be reconnected on > > > > > +# resume. ReconnectAudioDelay determines the delay between when the controller > > > > > +# resumes from suspend and a connection attempt is made. A longer delay can be > > > > > +# better for co-existence with Wi-Fi. > > > > > +# The value is in seconds. > > > > > +# Default: 5 > > > > > +#ReconnectAudioDelay = 5 > > > > > + > > > > > -- > > > > > 2.28.0.297.g1956fa8f8d-goog > > > > > > > > > > > > > > > > > -- > > > > Luiz Augusto von Dentz > > > > > > > > -- > > Luiz Augusto von Dentz > > Thanks, > Abhishek -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cCWjHFNjSV9+xwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 28 Aug 2020 22:04:35 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UDtLGlNjSV8MqgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 28 Aug 2020 22:04:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D34C3A1267; Fri, 28 Aug 2020 22:04:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726791AbgH1UE3 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 16:04:29 -0400 Received: from mga17.intel.com ([192.55.52.151]:35423 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbgH1UE3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 16:04:29 -0400 IronPort-SDR: o96spnWxakMunJnb6NAYjU0igzs9zEGMiJLSssenC/NcRDQee6V88VVr7siE8p5ZSopxbg+PZI Cwyq/clsCmwA== X-IronPort-AV: E=McAfee;i="6000,8403,9727"; a="136799282" X-IronPort-AV: E=Sophos;i="5.76,364,1592895600"; d="scan'208";a="136799282" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 13:04:28 -0700 IronPort-SDR: wvD/nc5q60eRlDX2d5eHPM31A58M6cuLGTqW4leTrEU+jXeZhVtF+bGtD4fywy8eGY/B3B7XiW nkGJulcGT37A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,364,1592895600"; d="scan'208";a="300345419" Received: from rbuaba-mobl2.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.83.122]) by orsmga006.jf.intel.com with ESMTP; 28 Aug 2020 13:04:28 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 0/2] Mesh replay protection clean up Date: Fri, 28 Aug 2020 13:04:25 -0700 Message-Id: <20200828200427.18753-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 4.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: D34C3A1267 X-Rspamd-UID: 6b9fe5 This patch set moves RPL initialization to the node init sequence instead of checking for every incoming message whether RPL has been initialized. Also, use consistent size check for RPL directory/file paths. Inga Stotland (2): mesh: Initialize RPL when creating or loading a node mesh: Move RPL check from model to net layer mesh/model.c | 18 ++--- mesh/model.h | 6 +- mesh/net.c | 198 +++++++++++++++++++++++++++------------------------ mesh/net.h | 5 +- mesh/node.c | 11 +-- mesh/rpl.c | 29 +++++--- mesh/rpl.h | 3 +- 7 files changed, 143 insertions(+), 127 deletions(-) -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6By9BmBjSV9dGwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 28 Aug 2020 22:04:48 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4FdnBmBjSV/jKgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 28 Aug 2020 22:04:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 43B6DA1C02; Fri, 28 Aug 2020 22:04:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726800AbgH1UEm (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 16:04:42 -0400 Received: from mga17.intel.com ([192.55.52.151]:35423 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbgH1UEk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 16:04:40 -0400 IronPort-SDR: MXRM1HxNzt2jlapkcnWQXX7ODTRbDQcTT4jqmrcFNBGTbJkkx+kQMr7ySgoB4zW+EWzNhg34rM pqAHoEXy49Sw== X-IronPort-AV: E=McAfee;i="6000,8403,9727"; a="136799288" X-IronPort-AV: E=Sophos;i="5.76,364,1592895600"; d="scan'208";a="136799288" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 13:04:30 -0700 IronPort-SDR: eYyBL7er4G4WYJlpixS1TOWwRHpDhdzSWif4O0aVCmYTAZ5c1cbP3RgpSY3RWMHn+pVlu7Dv3Q i0reR4MjUexA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,364,1592895600"; d="scan'208";a="300345429" Received: from rbuaba-mobl2.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.83.122]) by orsmga006.jf.intel.com with ESMTP; 28 Aug 2020 13:04:30 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ 2/2] mesh: Move RPL check from model to net layer Date: Fri, 28 Aug 2020 13:04:27 -0700 Message-Id: <20200828200427.18753-3-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200828200427.18753-1-inga.stotland@intel.com> References: <20200828200427.18753-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 43B6DA1C02 X-Rspamd-UID: f8c6ae Check whether an incoming message has an RPL entry prior to handing it over to model layer for processing. If present in RPL or the RPL queue is full, ignore the incoming message. If the incoming message is processed successfully, add the message as a new RPL entry. --- mesh/model.c | 18 ++--- mesh/model.h | 6 +- mesh/net.c | 184 +++++++++++++++++++++++++++------------------------ mesh/net.h | 4 -- 4 files changed, 106 insertions(+), 106 deletions(-) diff --git a/mesh/model.c b/mesh/model.c index 7bbc9cca7..ed2a75215 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -862,9 +862,9 @@ static void send_msg_rcvd(struct mesh_node *node, uint8_t ele_idx, } bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, - uint32_t seq, uint32_t iv_index, - uint16_t net_idx, uint16_t src, uint16_t dst, - uint8_t key_aid, const uint8_t *data, uint16_t size) + uint32_t iv_index, uint16_t net_idx, uint16_t src, + uint16_t dst, uint8_t key_aid, const uint8_t *data, + uint16_t size) { uint8_t *clear_text; struct mod_forward forward = { @@ -877,7 +877,7 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, struct mesh_net *net = node_get_net(node); uint8_t num_ele; int decrypt_idx, i, ele_idx; - uint16_t addr, crpl; + uint16_t addr; struct mesh_virtual *decrypt_virt = NULL; bool result = false; bool is_subscription; @@ -892,12 +892,6 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, /* Unicast and not addressed to us */ return false; - /* Don't process if already in RPL */ - crpl = node_get_crpl(node); - - if (net_msg_check_replay_cache(net, src, crpl, seq, iv_index)) - return false; - clear_text = l_malloc(size); forward.data = clear_text; @@ -988,10 +982,6 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, break; } - /* If message has been handled by us, add to RPL */ - if (result) - net_msg_add_replay_cache(net, src, seq, iv_index); - done: l_free(clear_text); diff --git a/mesh/model.h b/mesh/model.h index fe0648d04..2eec761a0 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -117,9 +117,9 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, bool segmented, uint16_t len, const void *data); bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, - uint32_t seq, uint32_t iv_index, uint16_t net_idx, - uint16_t src, uint16_t dst, uint8_t key_aid, - const uint8_t *data, uint16_t size); + uint32_t iv_index, uint16_t net_idx, uint16_t src, + uint16_t dst, uint8_t key_aid, const uint8_t *data, + uint16_t size); void mesh_model_app_key_delete(struct mesh_node *node, uint16_t ele_idx, struct l_queue *models, uint16_t app_idx); uint16_t mesh_model_opcode_set(uint32_t opcode, uint8_t *buf); diff --git a/mesh/net.c b/mesh/net.c index 83647d6ad..6c7311732 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -1621,6 +1621,91 @@ static void outseg_to(struct l_timeout *seg_timeout, void *user_data) sar->seqZero, sar->last_nak); } +static bool match_replay_cache(const void *a, const void *b) +{ + const struct mesh_rpl *rpe = a; + uint16_t src = L_PTR_TO_UINT(b); + + return src == rpe->src; +} + +static bool clean_old_iv_index(void *a, void *b) +{ + struct mesh_rpl *rpe = a; + uint32_t iv_index = L_PTR_TO_UINT(b); + + if (iv_index < 2) + return false; + + if (rpe->iv_index < iv_index - 1) { + l_free(rpe); + return true; + } + + return false; +} + +static bool msg_check_replay_cache(struct mesh_net *net, uint16_t src, + uint16_t crpl, uint32_t seq, uint32_t iv_index) +{ + struct mesh_rpl *rpe; + + /* If anything missing reject this message by returning true */ + if (!net || !net->node) + return true; + + rpe = l_queue_find(net->replay_cache, match_replay_cache, + L_UINT_TO_PTR(src)); + + if (rpe) { + if (iv_index > rpe->iv_index) + return false; + + /* Return true if (iv_index | seq) too low */ + if (iv_index < rpe->iv_index || seq <= rpe->seq) { + l_debug("Ignoring replayed packet"); + return true; + } + } else if (l_queue_length(net->replay_cache) >= crpl) { + /* SRC not in Replay Cache... see if there is space for it */ + + int ret = l_queue_foreach_remove(net->replay_cache, + clean_old_iv_index, L_UINT_TO_PTR(iv_index)); + + /* Return true if no space could be freed */ + if (!ret) { + l_debug("Replay cache full"); + return true; + } + } + + return false; +} + +static void msg_add_replay_cache(struct mesh_net *net, uint16_t src, + uint32_t seq, uint32_t iv_index) +{ + struct mesh_rpl *rpe; + + if (!net || !net->replay_cache) + return; + + rpe = l_queue_remove_if(net->replay_cache, match_replay_cache, + L_UINT_TO_PTR(src)); + + if (!rpe) { + rpe = l_new(struct mesh_rpl, 1); + rpe->src = src; + } + + rpe->seq = seq; + rpe->iv_index = iv_index; + rpl_put_entry(net->node, src, iv_index, seq); + + /* Optimize so that most recent conversations stay earliest in cache */ + l_queue_push_head(net->replay_cache, rpe); +} + static bool msg_rxed(struct mesh_net *net, bool frnd, uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t net_idx, @@ -1630,6 +1715,7 @@ static bool msg_rxed(struct mesh_net *net, bool frnd, uint32_t iv_index, const uint8_t *data, uint16_t size) { uint32_t seqAuth = seq_auth(seq, seqZero); + uint16_t crpl; /* Sanity check seqAuth */ if (seqAuth > seq) @@ -1671,8 +1757,19 @@ not_for_friend: if (dst == PROXIES_ADDRESS && !net->proxy_enable) return false; - return mesh_model_rx(net->node, szmic, seqAuth, seq, iv_index, net_idx, - src, dst, key_aid, data, size); + /* Don't process if already in RPL */ + crpl = node_get_crpl(net->node); + + if (msg_check_replay_cache(net, src, crpl, seq, iv_index)) + return false; + + if (!mesh_model_rx(net->node, szmic, seqAuth, iv_index, net_idx, src, + dst, key_aid, data, size)) + return false; + + /* If message has been handled by us, add to RPL */ + msg_add_replay_cache(net, src, seq, iv_index); + return true; } static uint16_t key_id_to_net_idx(struct mesh_net *net, uint32_t key_id) @@ -3448,89 +3545,6 @@ uint32_t mesh_net_get_instant(struct mesh_net *net) return net->instant; } -static bool match_replay_cache(const void *a, const void *b) -{ - const struct mesh_rpl *rpe = a; - uint16_t src = L_PTR_TO_UINT(b); - - return src == rpe->src; -} - -static bool clean_old_iv_index(void *a, void *b) -{ - struct mesh_rpl *rpe = a; - uint32_t iv_index = L_PTR_TO_UINT(b); - - if (iv_index < 2) - return false; - - if (rpe->iv_index < iv_index - 1) { - l_free(rpe); - return true; - } - - return false; -} - -bool net_msg_check_replay_cache(struct mesh_net *net, uint16_t src, - uint16_t crpl, uint32_t seq, uint32_t iv_index) -{ - struct mesh_rpl *rpe; - - /* If anything missing reject this message by returning true */ - if (!net || !net->node) - return true; - - rpe = l_queue_find(net->replay_cache, match_replay_cache, - L_UINT_TO_PTR(src)); - - if (rpe) { - if (iv_index > rpe->iv_index) - return false; - - /* Return true if (iv_index | seq) too low */ - if (iv_index < rpe->iv_index || seq <= rpe->seq) { - l_debug("Ignoring replayed packet"); - return true; - } - } else if (l_queue_length(net->replay_cache) >= crpl) { - /* SRC not in Replay Cache... see if there is space for it */ - - int ret = l_queue_foreach_remove(net->replay_cache, - clean_old_iv_index, L_UINT_TO_PTR(iv_index)); - - /* Return true if no space could be freed */ - if (!ret) - return true; - } - - return false; -} - -void net_msg_add_replay_cache(struct mesh_net *net, uint16_t src, uint32_t seq, - uint32_t iv_index) -{ - struct mesh_rpl *rpe; - - if (!net || !net->replay_cache) - return; - - rpe = l_queue_remove_if(net->replay_cache, match_replay_cache, - L_UINT_TO_PTR(src)); - - if (!rpe) { - rpe = l_new(struct mesh_rpl, 1); - rpe->src = src; - } - - rpe->seq = seq; - rpe->iv_index = iv_index; - rpl_put_entry(net->node, src, iv_index, seq); - - /* Optimize so that most recent conversations stay earliest in cache */ - l_queue_push_head(net->replay_cache, rpe); -} - static void hb_sub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; diff --git a/mesh/net.h b/mesh/net.h index 725054ce6..7bec6d0fc 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -354,8 +354,4 @@ void mesh_net_set_prov(struct mesh_net *net, struct mesh_prov *prov); uint32_t mesh_net_get_instant(struct mesh_net *net); struct l_queue *mesh_net_get_friends(struct mesh_net *net); struct l_queue *mesh_net_get_negotiations(struct mesh_net *net); -bool net_msg_check_replay_cache(struct mesh_net *net, uint16_t src, - uint16_t crpl, uint32_t seq, uint32_t iv_index); -void net_msg_add_replay_cache(struct mesh_net *net, uint16_t src, uint32_t seq, - uint32_t iv_index); bool mesh_net_load_rpl(struct mesh_net *net); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SBGeEjmpSV/UuAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 29 Aug 2020 03:02:49 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id aP3jEDmpSV9VxwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 29 Aug 2020 03:02:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0011740134; Sat, 29 Aug 2020 03:02:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726396AbgH2BCb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 21:02:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbgH2BCW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 21:02:22 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3713C061233 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 18:02:21 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id y6so438183plt.3 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 18:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EgVLhgo2q6+uzn37hzuq4exT5rVSGJyUMMk1KlmWH+Y=; b=FTd0+jLmC0VFf0yOezHQ5xCRyo+I07pit0tXKVs9dpf+q5R7LA2uw9zjGO4Azu2lFn A0y1v8tEOacOM+VIOGOrp9VgDAv52Ahf0/nUlBXqzVC+EqobnkdDZ7xjwYR8CmfSMv+K jp3jStLhulHGjipZcoItuOw6N4jPU5rNaVfZk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EgVLhgo2q6+uzn37hzuq4exT5rVSGJyUMMk1KlmWH+Y=; b=NW0etC0vYHg46aONnsnQvO4tAy+x1Sf+EURjOYRjBV/jYFkwsrzad/eLPkbXyszgSE D/hn/OH3jplfQp7YiZ+VElbGPng+DsbQPGvfP236ztooZ/eRvA48jOeDINaiMExxjHS+ bPBrGUzU0yhC2Gu2EsgxXjPvf2+zhGGJNQ5VX2YtyIkF+UhkspUuIA+ZrBmi1htmPq2d oKfUNZ/LSPmlq8O+92IORdA5di0SWzsJqr182ISGNSSlhRSlVQcHHE8rikP8V6YtZbPM z1V9rlcke80xEAszG2u8BAi+LGnYZ1wDefYCZaDppFBaEfksUruMGej8YUwm6Puhxyg4 ZbEQ== X-Gm-Message-State: AOAM53094tdEOlRopRF4z1Ue0pGh2vSIvHc5zCvYSeH1E938sKeSUwZX ZL3ZXeDbFECFy7VG7PTuSWvKSg== X-Google-Smtp-Source: ABdhPJxDHy/Oo0u0LpMqbIu2d36kNLMlYuPkhCKHxJtgyMOETBhMW9Fi+tsZp6A7lXgzkS+dQNApSg== X-Received: by 2002:a17:90a:9483:: with SMTP id s3mr1329325pjo.98.1598662940733; Fri, 28 Aug 2020 18:02:20 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 78sm630360pfv.200.2020.08.28.18.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 18:02:20 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v3 3/3] policy: Reconnect audio on controller resume Date: Fri, 28 Aug 2020 18:02:10 -0700 Message-Id: <20200828180157.Bluez.v3.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog In-Reply-To: <20200829010210.871471-1-abhishekpandit@chromium.org> References: <20200829010210.871471-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.50 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0011740134 X-Rspamd-UID: d9b71a During system suspend, all peer devices are disconnected. On resume, HID devices will reconnect but audio devices stay disconnected. As a quality of life improvement, mark audio devices that were disconnected due to suspend and attempt to reconnect them when the controller resumes (after a delay for better co-existence with Wi-Fi). --- Changes in v3: - Refactored resume notification to use btd_adapter_driver - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 - Added A2DP_SINK_UUID to default reconnect list Changes in v2: - Refactored to use policy instead of connecting directly in adapter plugins/policy.c | 80 +++++++++++++++++++++++++++++++++++++++--------- src/adapter.c | 36 ++++++++++++++++++++++ src/adapter.h | 2 ++ src/main.c | 1 + src/main.conf | 11 ++++++- 5 files changed, 115 insertions(+), 15 deletions(-) diff --git a/plugins/policy.c b/plugins/policy.c index de51e58b9..5ab65b991 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -62,10 +62,12 @@ struct reconnect_data { guint timer; bool active; unsigned int attempt; + bool on_resume; }; static const char *default_reconnect[] = { - HSP_AG_UUID, HFP_AG_UUID, A2DP_SOURCE_UUID, NULL }; + HSP_AG_UUID, HFP_AG_UUID, A2DP_SOURCE_UUID, + A2DP_SINK_UUID, NULL }; static char **reconnect_uuids = NULL; static const size_t default_attempts = 7; @@ -75,6 +77,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; static int *reconnect_intervals = NULL; static size_t reconnect_intervals_len = 0; +static const int default_resume_delay = 2; +static int resume_delay; + static GSList *reconnects = NULL; static unsigned int service_id = 0; @@ -711,6 +716,9 @@ static gboolean reconnect_timeout(gpointer data) /* Mark the GSource as invalid */ reconnect->timer = 0; + /* Mark any reconnect on resume as handled */ + reconnect->on_resume = false; + err = btd_device_connect_services(reconnect->dev, reconnect->services); if (err < 0) { error("Reconnecting services failed: %s (%d)", @@ -724,14 +732,17 @@ static gboolean reconnect_timeout(gpointer data) return FALSE; } -static void reconnect_set_timer(struct reconnect_data *reconnect) +static void reconnect_set_timer(struct reconnect_data *reconnect, int timeout) { - static int timeout = 0; + static int interval_timeout = 0; reconnect->active = true; if (reconnect->attempt < reconnect_intervals_len) - timeout = reconnect_intervals[reconnect->attempt]; + interval_timeout = reconnect_intervals[reconnect->attempt]; + + if (timeout < 0) + timeout = interval_timeout; DBG("attempt %u/%zu %d seconds", reconnect->attempt + 1, reconnect_attempts, timeout); @@ -743,10 +754,14 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) static void disconnect_cb(struct btd_device *dev, uint8_t reason) { struct reconnect_data *reconnect; + struct btd_service *service; + struct policy_data *data; DBG("reason %u", reason); - if (reason != MGMT_DEV_DISCONN_TIMEOUT) + /* Only attempt reconnect for the following reasons */ + if (reason != MGMT_DEV_DISCONN_TIMEOUT && + reason != MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND) return; reconnect = reconnect_find(dev); @@ -755,10 +770,40 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) reconnect_reset(reconnect); - DBG("Device %s identified for auto-reconnection", - device_get_path(dev)); + DBG("Device %s identified for auto-reconnection", device_get_path(dev)); - reconnect_set_timer(reconnect); + switch(reason) + { + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: + if (btd_device_get_service(dev, A2DP_SINK_UUID)) { + reconnect->on_resume = true; + DBG("%s configured to reconnect on resume", + device_get_path(dev)); + } + break; + case MGMT_DEV_DISCONN_TIMEOUT: + reconnect_set_timer(reconnect, -1); + break; + default: + DBG("Developer error. Reason = %d", reason); + break; + } +} + +static void policy_adapter_resume(struct btd_adapter *adapter, + uint8_t wake_reason, const bdaddr_t *addr, + const uint8_t addr_type) +{ + GSList *l; + + /* Check if any devices needed to be reconnected on resume */ + for (l = reconnects; l; l = g_slist_next(l)) { + struct reconnect_data *reconnect = l->data; + + if (reconnect->on_resume) { + reconnect_set_timer(reconnect, resume_delay); + } + } } static void conn_fail_cb(struct btd_device *dev, uint8_t status) @@ -786,14 +831,15 @@ static void conn_fail_cb(struct btd_device *dev, uint8_t status) return; } - reconnect_set_timer(reconnect); + reconnect_set_timer(reconnect, -1); } static int policy_adapter_probe(struct btd_adapter *adapter) { DBG(""); - btd_adapter_restore_powered(adapter); + if (auto_enable) + btd_adapter_restore_powered(adapter); return 0; } @@ -801,6 +847,7 @@ static int policy_adapter_probe(struct btd_adapter *adapter) static struct btd_adapter_driver policy_driver = { .name = "policy", .probe = policy_adapter_probe, + .resume = policy_adapter_resume, }; static int policy_init(void) @@ -854,14 +901,20 @@ static int policy_init(void) auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", NULL); + resume_delay = g_key_file_get_integer( + conf, "Policy", "ResumeDelay", &gerr); + + if (gerr) { + g_clear_error(&gerr); + resume_delay = default_resume_delay; + } done: if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { btd_add_disconnect_cb(disconnect_cb); btd_add_conn_fail_cb(conn_fail_cb); } - if (auto_enable) - btd_register_adapter_driver(&policy_driver); + btd_register_adapter_driver(&policy_driver); return 0; } @@ -882,8 +935,7 @@ static void policy_exit(void) btd_service_remove_state_cb(service_id); - if (auto_enable) - btd_unregister_adapter_driver(&policy_driver); + btd_unregister_adapter_driver(&policy_driver); } BLUETOOTH_PLUGIN_DEFINE(policy, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, diff --git a/src/adapter.c b/src/adapter.c index 1435e2bd7..bf355bfa7 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -8776,6 +8776,37 @@ static void connected_callback(uint16_t index, uint16_t length, eir_data_free(&eir_data); } +static void controller_resume_notify(struct btd_adapter *adapter, + const uint8_t wake_reason, + const bdaddr_t *addr, + const uint8_t addr_type) +{ + GSList *l; + + for (l = adapter->drivers; l; l = g_slist_next(l)) { + struct btd_adapter_driver *driver = l->data; + if (driver->resume) + driver->resume(adapter, wake_reason, addr, addr_type); + } +} + +static void controller_resume_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_ev_controller_resume *ev = param; + struct btd_adapter *adapter = user_data; + + if (length < sizeof(*ev)) { + btd_error(adapter->dev_id, "Too small device resume event"); + return; + } + + info("Controller resume with wake event 0x%x", ev->wake_reason); + + controller_resume_notify(adapter, ev->wake_reason, &ev->addr.bdaddr, + ev->addr.type); +} + static void device_blocked_callback(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9399,6 +9430,11 @@ static void read_info_complete(uint8_t status, uint16_t length, user_passkey_notify_callback, adapter, NULL); + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, + adapter->dev_id, + controller_resume_callback, + adapter, NULL); + set_dev_class(adapter); set_name(adapter, btd_adapter_get_name(adapter)); diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..b81ef6a04 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -113,6 +113,8 @@ struct btd_adapter_driver { const char *name; int (*probe) (struct btd_adapter *adapter); void (*remove) (struct btd_adapter *adapter); + void (*resume)(struct btd_adapter *adapter, uint8_t wake_reason, + const bdaddr_t *addr, const uint8_t addr_type); }; typedef void (*service_auth_cb) (DBusError *derr, void *user_data); diff --git a/src/main.c b/src/main.c index b37c32948..038f867b5 100644 --- a/src/main.c +++ b/src/main.c @@ -131,6 +131,7 @@ static const char *policy_options[] = { "ReconnectAttempts", "ReconnectIntervals", "AutoEnable", + "ResumeDelay", NULL }; diff --git a/src/main.conf b/src/main.conf index 42f7e41c5..9f882e65a 100644 --- a/src/main.conf +++ b/src/main.conf @@ -186,7 +186,7 @@ # timeout). The policy plugin should contain a sane set of values by # default, but this list can be overridden here. By setting the list to # empty the reconnection feature gets disabled. -#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb +#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb,0000110b-0000-1000-8000-00805f9b34fb # ReconnectAttempts define the number of attempts to reconnect after a link # lost. Setting the value to 0 disables reconnecting feature. @@ -202,3 +202,12 @@ # This includes adapters present on start as well as adapters that are plugged # in later on. Defaults to 'false'. #AutoEnable=false + +# Audio devices that were disconnected due to suspend will be reconnected on +# resume. ResumeDelay determines the delay between when the controller +# resumes from suspend and a connection attempt is made. A longer delay is +# better for better co-existence with Wi-Fi. +# The value is in seconds. +# Default: 2 +#ResumeDelay = 2 + -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sAXhCQ9NSl/XiQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 29 Aug 2020 14:41:51 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id cG/rBw9NSl/q7gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 29 Aug 2020 14:41:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 88AD2417C0; Sat, 29 Aug 2020 14:41:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727923AbgH2Mlb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 29 Aug 2020 08:41:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726876AbgH2MlY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 29 Aug 2020 08:41:24 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BB74C061236; Sat, 29 Aug 2020 05:41:24 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id v16so921565plo.1; Sat, 29 Aug 2020 05:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=inoIGbEpmdL0eBcL/eTYO9DUL34BzxMhEi+RCO4Fy4w=; b=imNiGgPSNVHTgkyR65Ye2n6UFzxVcj5PC00bxL6M6q+QkbrDpme8p5sIT/vyPhC0Rq 0dxinnsMKJVrNE1SjLHFTOoDLbD1QJAJZgdZ3q7qrbzNPv7wsToS3KpU7tXAgXsx6d1E oGa7IGk95kJJO22t/7UEbQd4W/4bxQnhJ7C4gFsmzsBXs12xF+b81gdBj12E5pj/pevH LESYfR8XTlIGXcMgStlwbMpa9g4bRSFoRk6K96cbLnXn/LPyt0WVKA3l57KQszLvmq8g 8oqjDCEIMWiNb/uix5TTs2dt3S9LwISoMi/yF4JWed9HPyN3HW3zdWEttVexG7zGeSiM 4gVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=inoIGbEpmdL0eBcL/eTYO9DUL34BzxMhEi+RCO4Fy4w=; b=eBsBXJc3FnOGspXnb1aNGlbTjXf2C+LFqlfDNNg4YjTwdsIaIx+yo6lk/d3PHVWGDt tJcrE2YppeCkdzP6L1ksVrW6y+v1t1pmqu8YQgHfgLCMkutns9u6ebvPI+MT6brd6e4q kGV7s+IBEl5/xuT7VxRfs1hh/IXF1rRhD5edMQIOtiYr7NKKScdqWMbeiW44gmfj8gCv VA6F8cxQ19KcM+t99hzjh5vBNPmbuIX5UAJ/6IUTBQDuf3yFst2emSe/DRzkysqjPNff 7o9J6dClx3/7PWSHCvq0pmDOFD+JYgbRnxcgfaDU4vTFuA+mFv4O5OBjJumsBUQaWbbb MIvA== X-Gm-Message-State: AOAM533lZQVyqgV18/JJRC7yx89E8p4Ik3Hz2tvV9oKDS9msQwtBp56R 7G6D+7b5mY4dOG6rd8riqTA= X-Google-Smtp-Source: ABdhPJz+NLb7HIW5P9DPG54Uwcs3btCpwTqxKPO7aqvpyIgUfuoteTuwfpl4q5WoZwqSBATciOhjNw== X-Received: by 2002:a17:902:123:: with SMTP id 32mr2619323plb.143.1598704883743; Sat, 29 Aug 2020 05:41:23 -0700 (PDT) Received: from localhost.localdomain ([45.118.165.148]) by smtp.googlemail.com with ESMTPSA id t25sm2496901pfe.76.2020.08.29.05.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Aug 2020 05:41:22 -0700 (PDT) From: Anmol Karn <anmol.karan123@gmail.com> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, anmol.karan123@gmail.com, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Subject: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer deref in hci_phy_link_complete_evt Date: Sat, 29 Aug 2020 18:11:12 +0530 Message-Id: <20200829124112.227133-1-anmol.karan123@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 88AD2417C0 X-Rspamd-UID: fcd12f Fix null pointer deref in hci_phy_link_complete_evt, there was no checking there for the hcon->amp_mgr->l2cap_conn->hconn, and also in hci_cmd_work, for hdev->sent_cmd. To fix this issue Add pointer checking in hci_cmd_work and hci_phy_link_complete_evt. [Linux-next-20200827] Reported-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=0d93140da5a82305a66a136af99b088b75177b99 Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> --- net/bluetooth/hci_core.c | 4 ++++ net/bluetooth/hci_event.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 68bfe57b6625..533048d2a624 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -4922,6 +4922,10 @@ static void hci_cmd_work(struct work_struct *work) kfree_skb(hdev->sent_cmd); + if(hdev->sent_cmd) { + hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); + } + hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); if (hdev->sent_cmd) { if (hci_req_status_pend(hdev)) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 4b7fc430793c..c621c8a20ea4 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4941,6 +4941,10 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, hci_dev_unlock(hdev); return; } + if(!(hcon->amp_mgr->l2cap_conn->hcon)) { + hci_dev_unlock(hdev); + return; + } bredr_hcon = hcon->amp_mgr->l2cap_conn->hcon; -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4BwCFQeJSl/phQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 29 Aug 2020 18:57:43 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id qF+yEweJSl9QowEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 29 Aug 2020 18:57:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 54417420D4; Sat, 29 Aug 2020 18:57:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728478AbgH2Q50 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 29 Aug 2020 12:57:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728403AbgH2Q5X (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 29 Aug 2020 12:57:23 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F9D1C061236; Sat, 29 Aug 2020 09:57:23 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id z18so979728pjr.2; Sat, 29 Aug 2020 09:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JNi5HVcJ7yBT6DVF4xqHEm9pH1OJge9gkwZUJEYG2kc=; b=MNYxsNt6X9itvJUV8tku0XRaO2RkCQBN/mLZewjUf+5xA4M+6/yPPdjtQMeC03rKJ9 /vBExQZIZEJ/8mNV+ATN2E3odhetvXRn7l9QyHP8+42rI56Lfe/pZyP7hzOJcp7nviGZ eV2wAYm2MIa0odEJKZOwYx5+dWqyhYy7c7gfzZvpF+6sArgdZWX43/5Td5xSSdadBQAI UqLS7vU+WQBQB33Y+fG73wRdTYAzCwZC6P+Cw3zj6uciFZgLsWtKw3pLiKGDy0tPj18t HZYa8ri3GqKOo9xgNfDTnVzZPj5A3ouYyVOBecWIQ3cHMy6md3gCkWSEW7fZ2M+731WJ st0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JNi5HVcJ7yBT6DVF4xqHEm9pH1OJge9gkwZUJEYG2kc=; b=sl77v/v24McA3OEHQ6zgmMf5MX129/FsSNPVqKA4Gr52DpC3LfjDW8pod+uTiJOnqz SQG3qFm7xQle4AblQBmpChp3udSmJqQ6EIZjOkEJFKS9t3JfKwsgjQK+E/NRovbpHlaY 8uHly7JKBWdvFNOd2zQUhpUhVuou58XJ/njk2wmmqvHBzW8aSqgtUXS41a94SsSuN+ZG 5uI3VX/H3fMD2Gg3rkI1UesxgVP1+BpCXgSGNLCst2NG7X0In5pz0I4sD/rs3GRxbksg yyid59ryZfsMfn4xpciAIrIVvOViT8X9djF1rPNlUtnIDbX5SXrdw5xzkIGDmc56lxkG iibQ== X-Gm-Message-State: AOAM533FNGIS35fsr/iBp4dEGdc+bGS7WD8HcelcGOC/ZI2UgxlBYDx/ GpwkADH+Kjrr/mBrD18y8Lw= X-Google-Smtp-Source: ABdhPJyJ2xh7VLE9WxChS1XpbZ+c5kNddCKSHHWbjfZPxZl64QPAKow+8XMyVaErBkNl9etlMM2aog== X-Received: by 2002:a17:90b:238d:: with SMTP id mr13mr3474738pjb.132.1598720242628; Sat, 29 Aug 2020 09:57:22 -0700 (PDT) Received: from localhost.localdomain ([45.118.165.144]) by smtp.googlemail.com with ESMTPSA id a200sm3217970pfd.182.2020.08.29.09.57.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Aug 2020 09:57:21 -0700 (PDT) From: Anmol Karn <anmol.karan123@gmail.com> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, anmol.karan123@gmail.com, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Subject: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer deref in hci_phy_link_complete_evt Date: Sat, 29 Aug 2020 22:27:12 +0530 Message-Id: <20200829165712.229437-1-anmol.karan123@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200829124112.227133-1-anmol.karan123@gmail.com> References: <20200829124112.227133-1-anmol.karan123@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.69 / 15.00 / 200.00 X-Rspamd-Queue-Id: 54417420D4 X-Rspamd-UID: 3bb09a Fix null pointer deref in hci_phy_link_complete_evt, there was no checking there for the hcon->amp_mgr->l2cap_conn->hconn, and also in hci_cmd_work, for hdev->sent_cmd. To fix this issue Add pointer checking in hci_cmd_work and hci_phy_link_complete_evt. [Linux-next-20200827] This patch corrected some mistakes from previous patch. Reported-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=0d93140da5a82305a66a136af99b088b75177b99 Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> --- net/bluetooth/hci_core.c | 5 ++++- net/bluetooth/hci_event.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 68bfe57b6625..996efd654e7a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -4922,7 +4922,10 @@ static void hci_cmd_work(struct work_struct *work) kfree_skb(hdev->sent_cmd); - hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); + if (hdev->sent_cmd) { + hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); + } + if (hdev->sent_cmd) { if (hci_req_status_pend(hdev)) hci_dev_set_flag(hdev, HCI_CMD_PENDING); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 4b7fc430793c..1e7d9bee9111 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4941,6 +4941,10 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, hci_dev_unlock(hdev); return; } + if (!(hcon->amp_mgr->l2cap_conn->hcon)) { + hci_dev_unlock(hdev); + return; + } bredr_hcon = hcon->amp_mgr->l2cap_conn->hcon; -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4CxlCx6WSV9jIAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 29 Aug 2020 01:41:18 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id GEq3CR6WSV+uggEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 29 Aug 2020 01:41:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1F5E5420D2; Sat, 29 Aug 2020 01:41:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727017AbgH1XlK (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 19:41:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726952AbgH1Xk6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 19:40:58 -0400 Received: from mail-vk1-xa44.google.com (mail-vk1-xa44.google.com [IPv6:2607:f8b0:4864:20::a44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04F3EC061264 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 16:40:55 -0700 (PDT) Received: by mail-vk1-xa44.google.com with SMTP id t189so139979vka.10 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 16:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vSFqqZzFHpOXfCEjE5viiIdfWRjyWcOEdI0Td9ZuKwQ=; b=PK4+P8O3W2zzhIfo0k2Sd9N5breoWq1nEgGjyNoA84GQ1iG+elwXMDAV74liYSgMYV OybkuPby0WKiKWgJlEoKUzbEjY/g8+6OAoHd1xD7NhSAOGGJtKDQmMgKOm3yUxvCA344 9pH/n7TreGHLiulKIESdzNyyMQ3pPqLGIH0Kw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vSFqqZzFHpOXfCEjE5viiIdfWRjyWcOEdI0Td9ZuKwQ=; b=rYFKIvtnPkhPdO+tRHh1BQ/6RQXE5LgPWQGrszsl8AR79WVDJCSk128dRhJ9FUD93N j9wE0olDw/i04YoxpcCujoc5P0zjS8eJv0IpmmUS1K0PB7qTR/+1Ml/8sAs3NiHbZOYZ 1Ep1k0SM/x21KfNG/iNZYBRa4a17yZTa4eizGvbSCdo94p4i31dbpdNWBRk8QnyfxNvN vI5fHHHqqmOPiXOSOS5+tCmXKbrhSDgnOTM6H9YqxoPCS+rKzt/1cYCraPy/sfAZDOMT HB48Lsh5UxqEgudRi/38fyNx7m2cLTNd2/Sozi1beGYi35KFdJla3pfi63ACIBPmWWoc Pv0g== X-Gm-Message-State: AOAM532kcEh0lFnr+Ve05M5u7ud3JJPlXdJZC0csUszVzRiI1Hkvw+cM QhwTfzQAiMGOEfXNmKE3NnPmvdCn8Ln42yU+fmeKWw== X-Google-Smtp-Source: ABdhPJyZ5WgGd4gisJyWOAMdjeu57iWFhbrd+MciGP7IYrIX/UoTNtpcxSmPpm4vuah/6aUOtSXSEKVfG1O1J49LbVw= X-Received: by 2002:ac5:c925:: with SMTP id u5mr891382vkl.68.1598658054149; Fri, 28 Aug 2020 16:40:54 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> <20200818162807.Bluez.v2.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> <CABBYNZLb_ETfO1VyAf+1rXpRT_XroQLq7u=uK6PGcrOKR7PHxA@mail.gmail.com> <CANFp7mV03KvqpOH=LBU=0tBDhgK5K2YJ6rxYvkDKmyer4n_gLw@mail.gmail.com> <CABBYNZ+SYSgzR_wX5Cn+5zUjep6HazCdJvAgZ0EE0uLkB_PEGg@mail.gmail.com> <CANFp7mU-gunJi5pAMY0zqE-BFGB6XDE=nPpxjU0Lqf7RBKDDpw@mail.gmail.com> <CABBYNZ+VR7xG=TuK8VBg+6mg8C2hB=x9EWXhxV1CJYmNNhA4ng@mail.gmail.com> In-Reply-To: <CABBYNZ+VR7xG=TuK8VBg+6mg8C2hB=x9EWXhxV1CJYmNNhA4ng@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Fri, 28 Aug 2020 16:40:42 -0700 Message-ID: <CANFp7mXDuuxuazrVHQ=9ELSf3k94za9HepbEWJaacPKJMHNvvg@mail.gmail.com> Subject: Re: [Bluez PATCH v2 3/3] policy: Reconnect audio on controller resume To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1F5E5420D2 X-Rspamd-UID: a0f984 Hi Luiz, On Fri, Aug 28, 2020 at 10:56 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Abhishek, > > On Fri, Aug 28, 2020 at 10:31 AM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > Hi Luiz, > > > > On Fri, Aug 28, 2020 at 10:09 AM Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > > > > > > Hi Abhishek, > > > > > > On Thu, Aug 27, 2020 at 2:08 PM Abhishek Pandit-Subedi > > > <abhishekpandit@chromium.org> wrote: > > > > > > > > Hi Luiz, > > > > > > > > On Wed, Aug 26, 2020 at 11:32 PM Luiz Augusto von Dentz > > > > <luiz.dentz@gmail.com> wrote: > > > > > > > > > > Hi Abhishek, > > > > > > > > > > On Tue, Aug 18, 2020 at 4:28 PM Abhishek Pandit-Subedi > > > > > <abhishekpandit@chromium.org> wrote: > > > > > > > > > > > > During system suspend, all peer devices are disconnected. On resume, HID > > > > > > devices will reconnect but audio devices stay disconnected. As a quality > > > > > > of life improvement, mark audio devices that were disconnected due to > > > > > > suspend and attempt to reconnect them when the controller resumes (after > > > > > > a delay for better co-existence with Wi-Fi). > > > > > > > > > > > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > > > > > --- > > > > > > > > > > > > Changes in v2: > > > > > > - Refactored to use policy instead of connecting directly in adapter > > > > > > > > > > > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > > > > > > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > > > > > > src/adapter.h | 6 +++++ > > > > > > src/main.c | 1 + > > > > > > src/main.conf | 9 +++++++ > > > > > > 5 files changed, 121 insertions(+), 4 deletions(-) > > > > > > > > > > > > diff --git a/plugins/policy.c b/plugins/policy.c > > > > > > index de51e58b9..b07a997b9 100644 > > > > > > --- a/plugins/policy.c > > > > > > +++ b/plugins/policy.c > > > > > > @@ -75,6 +75,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; > > > > > > static int *reconnect_intervals = NULL; > > > > > > static size_t reconnect_intervals_len = 0; > > > > > > > > > > > > +static const int default_reconnect_delay = 5; > > > > > > +static int resume_reconnect_delay = 5; > > > > > > + > > > > > > static GSList *reconnects = NULL; > > > > > > > > > > > > static unsigned int service_id = 0; > > > > > > @@ -93,6 +96,8 @@ struct policy_data { > > > > > > uint8_t ct_retries; > > > > > > guint tg_timer; > > > > > > uint8_t tg_retries; > > > > > > + > > > > > > + bool reconnect_on_resume; > > > > > > }; > > > > > > > > > > > > static struct reconnect_data *reconnect_find(struct btd_device *dev) > > > > > > @@ -214,6 +219,7 @@ static gboolean policy_connect_sink(gpointer user_data) > > > > > > > > > > > > data->sink_timer = 0; > > > > > > data->sink_retries++; > > > > > > + data->reconnect_on_resume = false; > > > > > > > > > > > > service = btd_device_get_service(data->dev, A2DP_SINK_UUID); > > > > > > if (service != NULL) > > > > > > @@ -222,16 +228,20 @@ static gboolean policy_connect_sink(gpointer user_data) > > > > > > return FALSE; > > > > > > } > > > > > > > > > > > > -static void policy_set_sink_timer(struct policy_data *data) > > > > > > +static void policy_set_sink_timer_internal(struct policy_data *data, int timeout) > > > > > > { > > > > > > if (data->sink_timer > 0) > > > > > > g_source_remove(data->sink_timer); > > > > > > > > > > > > - data->sink_timer = g_timeout_add_seconds(SINK_RETRY_TIMEOUT, > > > > > > - policy_connect_sink, > > > > > > + data->sink_timer = g_timeout_add_seconds(timeout, policy_connect_sink, > > > > > > data); > > > > > > } > > > > > > > > > > > > +static void policy_set_sink_timer(struct policy_data *data) > > > > > > +{ > > > > > > + policy_set_sink_timer_internal(data, SINK_RETRY_TIMEOUT); > > > > > > +} > > > > > > + > > > > > > static void sink_cb(struct btd_service *service, btd_service_state_t old_state, > > > > > > btd_service_state_t new_state) > > > > > > { > > > > > > @@ -743,10 +753,30 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) > > > > > > static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > > > > > { > > > > > > struct reconnect_data *reconnect; > > > > > > + struct btd_service *service; > > > > > > + struct policy_data *data; > > > > > > + bool do_reconnect = false; > > > > > > > > > > > > DBG("reason %u", reason); > > > > > > > > > > > > - if (reason != MGMT_DEV_DISCONN_TIMEOUT) > > > > > > + switch(reason) { > > > > > > + case MGMT_DEV_DISCONN_LOCAL_HOST: > > > > > > + case MGMT_DEV_DISCONN_REMOTE: > > > > > > + do_reconnect = true; > > > > > > + break; > > > > > > + /* Disconnect due to suspend will queue reconnect on resume for a2dp */ > > > > > > + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: > > > > > > + service = btd_device_get_service(dev, A2DP_SINK_UUID); > > > > > > + if (service && (data = policy_get_data(dev))) { > > > > > > + data->reconnect_on_resume = true; > > > > > > + } > > > > > > > > > > Can't we just program the timer directly here? Or would that wakeup > > > > > the system, I would imagine all timers are disabled while suspended > > > > > which means when the system resumes so does the timers which would > > > > > then trigger the reconnection logic. > > > > > > > > This approach works if every resume is user initiated and keeps the > > > > device awake long enough to reconnect to the audio device. On > > > > ChromeOS, this isn't always the case. We have a feature called Dark > > > > Resume that occurs when the system wakes to handle an event that > > > > doesn't require user intervention and suspends again without ever > > > > turning on the screen. See: > > > > https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/docs/dark_resume.md. > > > > A primary user for this is a periodic wake-up that checks battery > > > > percentage and shuts down the system if it's too low. > > > > > > Ok I didn't know such a feature exists in ChromeOS, but doesn't Dark > > > Resumes should be handled by the kernel instead of each userspace > > > component? I suppose there quite a few timers that may have side > > > effects if dark resumes actually resume them. > > > > > > > I'm not aware of the history around it but I found another page with > > more context of use cases (like actually letting a user space > > application run as would happen on a smartphone): > > https://www.chromium.org/chromium-os/chromiumos-design-docs/lucid-sleep > > > > > > One of the tests I ran specifically for this is a suspend stress test > > > > with a wake time between 2-4s (i.e. suspend_stress_test -c 10 > > > > --wake_min 2 --wake_max 3) which emulates dark resumes. If we set the > > > > timer when disconnecting, the device would attempt a connection on one > > > > of the wakeups and fail (since we suspended without completing the > > > > connection). > > > > > > We could perhaps check if the kernel is capable of emitting > > > suspend/resume events and if not just program the timer, or > > > alternatively add another config option to indicate when the system > > > supports such concept of Dark Resumes. > > > > > > > How does the following sound: > > > > * On disconnect, I always queue the reconnect but with the resume > > delay set instead of the interval[0] value. I also set the > > resume_reconnect flag > > * On every resume event (or dark resume event), I reset the timer and > > add resume_delay seconds if resume_reconnect is set > > * The first time the reconnect_timeout runs, I clear the resume_reconnect flag > > > > The delay will only be reapplied if the kernel is capable of emitting > > suspend/resume events and/or dark resume events. > > That should work as well, does full resumes need to reset the timer > though? Or we don't have any means to identify the resume type? Well > either way I guess the difference would be quite small since the > timeout is the same just when it is programmed (on suspend vs on > resume). The timer exists to avoid trying to connect at the same time wi-fi may be trying to associate. By the way, I had a chance to test all this today and setting the reconnect timer on disconnect causes the connection to sometimes occur before the resume event has a chance to run. Depending on the exact timing, this will likely break the desired dark resume behavior. I tried `suspend_stress_test --wake_min=1 --wake_max=1 -c 5` and had the headset reconnect on the 3rd suspend (instead of only at the end) when using a ResumeDelay of 2. So I propose the following behavior instead: * On disconnect, queue a reconnect if reason != SUSPEND. If reason == SUSPEND, set reconnect->on_resume = true * If we support dark resume events (i.e. chromium), set the timer if resume reason == full resume and reconnect->on_resume = true (this will probably be a CHROMIUM patch that we carry in our repositories) * If we support kernel events (and not dark resume), set the timer if reconnect->on_resume = true (this will be the upstream version) I will update the resume delay to 2 and test further with some older Chromebooks. If this reduces the chance of success of BT reconnecting, we can come back and update this later. > > > > > > > > > > > > + break; > > > > > > + /* All other cases do not result in reconnect */ > > > > > > + default: > > > > > > + break; > > > > > > + } > > > > > > + > > > > > > + if (!do_reconnect) > > > > > > return; > > > > > > > > > > > > reconnect = reconnect_find(dev); > > > > > > @@ -761,6 +791,23 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > > > > > reconnect_set_timer(reconnect); > > > > > > } > > > > > > > > > > > > +static void controller_resume_cb(uint8_t wake_reason, const bdaddr_t *addr, > > > > > > + const uint8_t addr_type) > > > > > > +{ > > > > > > + struct btd_device *dev; > > > > > > + GSList *l; > > > > > > + > > > > > > + /* Check if any devices needed to be reconnected on resume */ > > > > > > + for (l = devices; l; l = g_slist_next(l)) { > > > > > > + struct policy_data *data = l->data; > > > > > > + > > > > > > + if (data->reconnect_on_resume) { > > > > > > + policy_set_sink_timer_internal(data, > > > > > > + resume_reconnect_delay); > > > > > > + } > > > > > > + } > > > > > > +} > > > > > > + > > > > > > static void conn_fail_cb(struct btd_device *dev, uint8_t status) > > > > > > { > > > > > > struct reconnect_data *reconnect; > > > > > > @@ -854,9 +901,17 @@ static int policy_init(void) > > > > > > auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", > > > > > > NULL); > > > > > > > > > > > > + resume_reconnect_delay = g_key_file_get_integer( > > > > > > + conf, "Policy", "ReconnectAudioDelay", &gerr); > > > > > > + > > > > > > + if (gerr) { > > > > > > + g_clear_error(&gerr); > > > > > > + resume_reconnect_delay = default_reconnect_delay; > > > > > > + } > > > > > > done: > > > > > > if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { > > > > > > btd_add_disconnect_cb(disconnect_cb); > > > > > > + btd_add_controller_resume_cb(controller_resume_cb); > > > > > > btd_add_conn_fail_cb(conn_fail_cb); > > > > > > } > > > > > > > > > > > > @@ -869,6 +924,7 @@ done: > > > > > > static void policy_exit(void) > > > > > > { > > > > > > btd_remove_disconnect_cb(disconnect_cb); > > > > > > + btd_remove_controller_resume_cb(controller_resume_cb); > > > > > > btd_remove_conn_fail_cb(conn_fail_cb); > > > > > > > > > > > > if (reconnect_uuids) > > > > > > diff --git a/src/adapter.c b/src/adapter.c > > > > > > index 5e896a9f0..7526feb9e 100644 > > > > > > --- a/src/adapter.c > > > > > > +++ b/src/adapter.c > > > > > > @@ -139,6 +139,7 @@ static GSList *adapter_drivers = NULL; > > > > > > > > > > > > static GSList *disconnect_list = NULL; > > > > > > static GSList *conn_fail_list = NULL; > > > > > > +static GSList *controller_resume_list = NULL; > > > > > > > > > > > > struct link_key_info { > > > > > > bdaddr_t bdaddr; > > > > > > @@ -8766,6 +8767,45 @@ static void connected_callback(uint16_t index, uint16_t length, > > > > > > eir_data_free(&eir_data); > > > > > > } > > > > > > > > > > > > +static void controller_resume_notify(const uint8_t wake_reason, > > > > > > + const bdaddr_t *addr, > > > > > > + const uint8_t addr_type) > > > > > > +{ > > > > > > + GSList *l; > > > > > > + > > > > > > + for (l = controller_resume_list; l; l = g_slist_next(l)) { > > > > > > + btd_controller_resume_cb resume_cb = l->data; > > > > > > + resume_cb(wake_reason, addr, addr_type); > > > > > > + } > > > > > > +} > > > > > > + > > > > > > +static void controller_resume_callback(uint16_t index, uint16_t length, > > > > > > + const void *param, void *user_data) > > > > > > +{ > > > > > > + const struct mgmt_ev_controller_resume *ev = param; > > > > > > + struct btd_adapter *adapter = user_data; > > > > > > + > > > > > > + if (length < sizeof(*ev)) { > > > > > > + btd_error(adapter->dev_id, "Too small device resume event"); > > > > > > + return; > > > > > > + } > > > > > > + > > > > > > + DBG("Controller resume with wake event 0x%x", ev->wake_reason); > > > > > > + > > > > > > + controller_resume_notify(ev->wake_reason, &ev->addr.bdaddr, > > > > > > + ev->addr.type); > > > > > > +} > > > > > > + > > > > > > +void btd_add_controller_resume_cb(btd_controller_resume_cb func) > > > > > > +{ > > > > > > + controller_resume_list = g_slist_append(controller_resume_list, func); > > > > > > +} > > > > > > + > > > > > > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func) > > > > > > +{ > > > > > > + controller_resume_list = g_slist_remove(controller_resume_list, func); > > > > > > +} > > > > > > + > > > > > > static void device_blocked_callback(uint16_t index, uint16_t length, > > > > > > const void *param, void *user_data) > > > > > > { > > > > > > @@ -9389,6 +9429,11 @@ static void read_info_complete(uint8_t status, uint16_t length, > > > > > > user_passkey_notify_callback, > > > > > > adapter, NULL); > > > > > > > > > > > > + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, > > > > > > + adapter->dev_id, > > > > > > + controller_resume_callback, > > > > > > + adapter, NULL); > > > > > > + > > > > > > set_dev_class(adapter); > > > > > > > > > > > > set_name(adapter, btd_adapter_get_name(adapter)); > > > > > > diff --git a/src/adapter.h b/src/adapter.h > > > > > > index f8ac20261..5527e4205 100644 > > > > > > --- a/src/adapter.h > > > > > > +++ b/src/adapter.h > > > > > > @@ -67,6 +67,12 @@ typedef void (*btd_conn_fail_cb) (struct btd_device *device, uint8_t status); > > > > > > void btd_add_conn_fail_cb(btd_conn_fail_cb func); > > > > > > void btd_remove_conn_fail_cb(btd_conn_fail_cb func); > > > > > > > > > > > > +typedef void (*btd_controller_resume_cb)(const uint8_t wake_reason, > > > > > > + const bdaddr_t *addr, > > > > > > + const uint8_t addr_type); > > > > > > +void btd_add_controller_resume_cb(btd_controller_resume_cb func); > > > > > > +void btd_remove_controller_resume_cb(btd_controller_resume_cb func); > > > > > > > > > > If we can program the timer just before we suspend this is not really > > > > > necessary, but if you still thing that would be a good idea to notify > > > > > Id put it in btd_adapter_driver with a callback for suspend and > > > > > resume, that way we don't have to maintain multiple lists for each of > > > > > the callbacks. > > > > > > > > The adapter driver seems like a reasonable place to put this so let me > > > > port that over. > > > > > > > > > > > > > > > struct btd_adapter *adapter_find(const bdaddr_t *sba); > > > > > > struct btd_adapter *adapter_find_by_id(int id); > > > > > > void adapter_foreach(adapter_cb func, gpointer user_data); > > > > > > diff --git a/src/main.c b/src/main.c > > > > > > index 2c083de67..a1c3e7e9f 100644 > > > > > > --- a/src/main.c > > > > > > +++ b/src/main.c > > > > > > @@ -131,6 +131,7 @@ static const char *policy_options[] = { > > > > > > "ReconnectAttempts", > > > > > > "ReconnectIntervals", > > > > > > "AutoEnable", > > > > > > + "ReconnectAudioDelay", > > > > > > NULL > > > > > > }; > > > > > > > > > > > > diff --git a/src/main.conf b/src/main.conf > > > > > > index f41203b96..8d74a2aec 100644 > > > > > > --- a/src/main.conf > > > > > > +++ b/src/main.conf > > > > > > @@ -198,3 +198,12 @@ > > > > > > # This includes adapters present on start as well as adapters that are plugged > > > > > > # in later on. Defaults to 'false'. > > > > > > #AutoEnable=false > > > > > > + > > > > > > +# Audio devices that were disconnected due to suspend will be reconnected on > > > > > > +# resume. ReconnectAudioDelay determines the delay between when the controller > > > > > > +# resumes from suspend and a connection attempt is made. A longer delay can be > > > > > > +# better for co-existence with Wi-Fi. > > > > > > +# The value is in seconds. > > > > > > +# Default: 5 > > > > > > +#ReconnectAudioDelay = 5 > > > > > > + > > > > > > -- > > > > > > 2.28.0.297.g1956fa8f8d-goog > > > > > > > > > > > > > > > > > > > > > -- > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > Thanks, > > Abhishek > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GGHxF+l8SV/9YgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 28 Aug 2020 23:53:45 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UDZPFul8SV/iuQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 28 Aug 2020 23:53:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ED76E420C1; Fri, 28 Aug 2020 23:53:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726550AbgH1Vxj (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 17:53:39 -0400 Received: from mga04.intel.com ([192.55.52.120]:57158 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbgH1Vxh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 17:53:37 -0400 IronPort-SDR: SeW0l5No/PWpiaz5HctxNFN3j7cRlfA3HmIIRkUr7swyT00bRGMCTlOuDlZFTSlXRvu42c3Nby h/JUwl/iNBmg== X-IronPort-AV: E=McAfee;i="6000,8403,9727"; a="154164468" X-IronPort-AV: E=Sophos;i="5.76,365,1592895600"; d="scan'208";a="154164468" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 14:53:36 -0700 IronPort-SDR: jvXL6snMzOuyo9UEEKZmsNJyH1ByuIjfX3ODqcSB6EP5N7mEwsdaKT3fvAj14Rcdnl4todIMTA xUL3sW9pqOGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,365,1592895600"; d="scan'208";a="296270523" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga003.jf.intel.com with ESMTP; 28 Aug 2020 14:53:36 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 28 Aug 2020 14:53:32 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 28 Aug 2020 14:53:32 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.170) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Fri, 28 Aug 2020 14:53:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ur22O2QnRfAIZy5g8e0gJ8wXn5cj/8U58XY9GdAIusKI9FRkR8n9AQUFcQT4rxfJj7lPNXaKBBwuW2A0w+ysxlwSW+Ks4xUw8wc7cM5ZhzWXDpqcSJKKckKt6+5xH1RxDe1LHfFo0F6XIGUGg9FfEjAb2wPfMmOSocQE39xY/wFKgVUvPtaWYRLiMh11Lzuniu1phryGN8I2YLMUFezqigCvmvOKLLdLbTOqJkkn8/GG8QjKKfUxxgGa3kUBndsIhqizHOi9RXGC4uDAa7rwZ65+f4lpTGk0KGcuo9p8BR0nc3lksDDcU/GyPrSrF/4Dm37mN5nu2uIZB4rQv6FL8w== 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-SenderADCheck; bh=aPYxisI9gkL85lO6vq6nbLTibgG740HRSirc3NJZiBw=; b=Ko551163lG5im65yDjP+cKlI6+7NunDoo4qpjrVK4UNGGT1DcIZD2ALpv7j9NZr0XBzvEsAK12uLhsVFu84764ZhPdUYkQmZKFcWHScwExXsK9WaFC+JVy8u69X5hlnu0Pepe55gC61iRxq/K7BW9vP4vrkYO/Lrc9+3QtkJd1fnDcRn5uYMC9XyuZMR4QM5iJ1j3Kt84xt/8SYKWrndGwtVZLGR4dI7fWcOsjY5ojM0qdbcCP4HhlyUVucqmTH77lWcHlNQBI89uvWiks5eonllNCzPl1Hkssz1BE/HkSySQkUp/x3FpkFaN/oSLs21+3ZntQMNDA5FTb3I+L6KIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aPYxisI9gkL85lO6vq6nbLTibgG740HRSirc3NJZiBw=; b=FY/Dn/I/b/9b+iM5Ng7JDnrXI5cBuArTTWVCvzx0GSh9TtQyJ3bAn3pu9IPhbdgrCcytBSh5b68rjVpDnkRoBmbSy3iWc+F7xW4XUXhgO+LTah/f3N6luAyhbwxgeFmLWh1Vt0ZJ/3E2d8hpA+RPBCKOf0Y4Gq30RTc0i0pgMFs= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB0080.namprd11.prod.outlook.com (2603:10b6:301:68::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.24; Fri, 28 Aug 2020 21:53:29 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3326.021; Fri, 28 Aug 2020 21:53:29 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ 0/2] Mesh replay protection clean up Thread-Topic: [PATCH BlueZ 0/2] Mesh replay protection clean up Thread-Index: AQHWfXZyNR3qUURG4Ua5e0Xzxgi9P6lOEGUA Date: Fri, 28 Aug 2020 21:53:29 +0000 Message-ID: <e9869cfd5eb4ebb48e9716987a2407bca33903b7.camel@intel.com> References: <20200828200427.18753-1-inga.stotland@intel.com> In-Reply-To: <20200828200427.18753-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.54.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1e2c9134-0d49-4bc9-2e65-08d84b9ccc7f x-ms-traffictypediagnostic: MWHPR11MB0080: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR11MB008047635BD6B18111CF1E23E1520@MWHPR11MB0080.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:6790; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: JPOGQUgYYVXZafwmf9ZVnGVfpRuFrhH4wKbk5pKWVahHoWVC0PsavAGqLJxj+a9p7YoWAZQqCv8xme6FH7O2fFY+MZwEyh+ACpP0X1bN8kQk3InS0GjrLvvJbfmMZBC78OLb/5+E9EheriUmWRD+bryLre8COjAX4pTARLZb/JtBi3xeJ2LSJYIEzK3aHPL/R3Qj61SS03l6l5K18bgoLSsplMMfAlCi11MImegtDiMMLHgYPMW7EgXFSezhV0JE+4jCSFtmdrhDHFbCI67BqYLDNXno88oZqfGcK5wdBrOfHF3yiUxDngGh/MrnCdZTY+z/VgwXVt9tPSdpkLdkeA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(396003)(39860400002)(366004)(346002)(86362001)(8676002)(8936002)(316002)(83380400001)(478600001)(110136005)(6486002)(36756003)(66476007)(5660300002)(6636002)(66556008)(71200400001)(4744005)(76116006)(6506007)(26005)(186003)(91956017)(66946007)(6512007)(2906002)(66446008)(64756008)(2616005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 3Dh4R7UhxzUWj11peEc3WN/3514PiKjoGyC9pJJNZ+k76N8xElHOez1agjjNlnTir39WfWiaj77yAqX+GrxpFEcQy83WoLgadIeIN7GS+hq0hcZ/xYXmdiCIwbLvlGxKDezmyeH04SObWabSK81MEFkkASfF3H0uE278+WHyX0FaUh2L8V7sFXzgfAiAs6cladUVp1/0MfKTnOJlxXRyRKi7cwP3Orq1hQ2Y3/EzICKIZwxInmLUfoROYNs78XD5YaNNYJsiEErtTQXyN9QfhPfbIp9XdMSvezhV7VUc/la9qXTDzKresZvjWC2xCF/tvoblQ5EtS/HcnMQZmzijtPHF27Fu0+A4KkRABVme5xghvAmbUOLPm3tkXuxhgARO6/LYf8HMKlQMCxLcgMvIIQkEIBHe/rVd5vs3Nz/dIM+RCaY3iWUAc5pB4KSdoHt7Ffl2hxfEJ0ILEOYFXiSN7K8GJBG4E8lWKF0boFCJapK+SMoZoqLVAlPhFhCnP507CmSEdEnSMsCKgHGKwk2v47nDwPSAYAwYv6KsSThdNoUIaSy4hOHSo3DWeG0HjZFm5xpwE/mw8Anw8LmemUDYA1uuiULMBhKJT312499wTFew2vMihqfKxG3KK6zjOSG2FAQ0lJbxOshjTN75I+jC9w== Content-Type: text/plain; charset="utf-8" Content-ID: <29B3B246E628B94FA0369EB7E3B1A2CC@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e2c9134-0d49-4bc9-2e65-08d84b9ccc7f X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Aug 2020 21:53:29.0395 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: oyh0duNgxqc2dcRB6M0xpHbD5T8XsYNF+8xPjUhFmTKpJOCGiPWvXzqLYn8JSIeaNDNQhMo89COD0RRBouHDvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB0080 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.33 / 15.00 / 200.00 X-Rspamd-Queue-Id: ED76E420C1 X-Rspamd-UID: 7379f1 QXBwbGllZA0KT24gRnJpLCAyMDIwLTA4LTI4IGF0IDEzOjA0IC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBUaGlzIHBhdGNoIHNldCBtb3ZlcyBSUEwgaW5pdGlhbGl6YXRpb24gdG8gdGhl IG5vZGUgaW5pdCBzZXF1ZW5jZQ0KPiBpbnN0ZWFkIG9mIGNoZWNraW5nIGZvciBldmVyeSBpbmNv bWluZyBtZXNzYWdlIHdoZXRoZXIgUlBMIGhhcw0KPiBiZWVuIGluaXRpYWxpemVkLg0KPiANCj4g QWxzbywgdXNlIGNvbnNpc3RlbnQgc2l6ZSBjaGVjayBmb3IgUlBMIGRpcmVjdG9yeS9maWxlIHBh dGhzLg0KPiANCj4gDQo+IEluZ2EgU3RvdGxhbmQgKDIpOg0KPiAgIG1lc2g6IEluaXRpYWxpemUg UlBMIHdoZW4gY3JlYXRpbmcgb3IgbG9hZGluZyBhIG5vZGUNCj4gICBtZXNoOiBNb3ZlIFJQTCBj aGVjayBmcm9tIG1vZGVsIHRvIG5ldCBsYXllcg0KPiANCj4gIG1lc2gvbW9kZWwuYyB8ICAxOCAr Ky0tLQ0KPiAgbWVzaC9tb2RlbC5oIHwgICA2ICstDQo+ICBtZXNoL25ldC5jICAgfCAxOTggKysr KysrKysrKysrKysrKysrKysrKysrKysrLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQo+ICBtZXNo L25ldC5oICAgfCAgIDUgKy0NCj4gIG1lc2gvbm9kZS5jICB8ICAxMSArLS0NCj4gIG1lc2gvcnBs LmMgICB8ICAyOSArKysrKy0tLQ0KPiAgbWVzaC9ycGwuaCAgIHwgICAzICstDQo+ICA3IGZpbGVz IGNoYW5nZWQsIDE0MyBpbnNlcnRpb25zKCspLCAxMjcgZGVsZXRpb25zKC0pDQo+IA0K Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KGyuHHGcSV/ohgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 29 Aug 2020 02:08:17 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id wCqlGnGcSV8i0gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 29 Aug 2020 02:08:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 36723420E0; Sat, 29 Aug 2020 02:08:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbgH2AIL (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 20:08:11 -0400 Received: from mga12.intel.com ([192.55.52.136]:10238 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbgH2AIK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 20:08:10 -0400 IronPort-SDR: 9CuBcQL9z2hhli6pJJT4RLGYcHTdUMAsJPj5ICfZ6w4+6LqibHu8d3yUyZVJOciKZuKmfjO+ew n56Gjcz9uurg== X-IronPort-AV: E=McAfee;i="6000,8403,9727"; a="136305338" X-IronPort-AV: E=Sophos;i="5.76,365,1592895600"; d="scan'208";a="136305338" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 17:08:10 -0700 IronPort-SDR: nEwx05z0RX4CKRRMdNkSuFsRYZn45EVFAVGkWDmSerc2rh9RfXiVGxKQdhyjzBPNBjafAHjkbF dDZqWnHGsqtQ== X-IronPort-AV: E=Sophos;i="5.76,365,1592895600"; d="scan'208";a="324213872" Received: from asmit14x-mobl1.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.83.187]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 17:08:09 -0700 From: tedd.an@intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [V3 1/3] btp: Update connect event structure Date: Fri, 28 Aug 2020 17:08:01 -0700 Message-Id: <20200829000803.20286-1-tedd.an@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 36723420E0 X-Rspamd-UID: fcfaae From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch updates the connect event struct to align withe the btp spec. Opcode 0x82 - Device Connected event Controller Index: <controller id> Event parameters: Address_Type (1 octet) Address (6 octets) Connection Interval (2 octets) Connection Latency (2 octets) Supervision Timeout (2 octets) --- src/shared/btp.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/shared/btp.h b/src/shared/btp.h index f0ac3a1ee..cc71a71df 100644 --- a/src/shared/btp.h +++ b/src/shared/btp.h @@ -259,6 +259,9 @@ struct btp_device_found_ev { struct btp_gap_device_connected_ev { uint8_t address_type; bdaddr_t address; + uint16_t connection_interval; + uint16_t connection_latency; + uint16_t supervision_timeout; } __packed; #define BTP_EV_GAP_DEVICE_DISCONNECTED 0x83 -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kLsHNHicSV+aSQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 29 Aug 2020 02:08:24 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gIl9MnicSV+/3wAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 29 Aug 2020 02:08:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 92423420DD; Sat, 29 Aug 2020 02:08:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726821AbgH2AIN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 20:08:13 -0400 Received: from mga12.intel.com ([192.55.52.136]:10238 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726775AbgH2AIL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 20:08:11 -0400 IronPort-SDR: jdn1x6s5jF4+jw77bjI5I2re3673hHc6CXqfsRfgwU5fyKA9Kcnb/pl7UfkrfgKtE2ydscQYN2 5rkzcKIZvcwQ== X-IronPort-AV: E=McAfee;i="6000,8403,9727"; a="136305339" X-IronPort-AV: E=Sophos;i="5.76,365,1592895600"; d="scan'208";a="136305339" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 17:08:10 -0700 IronPort-SDR: zxtIEoEcenhuLToqGgHugmlc0TYS4RG/hMy2C/zPhd2zvoR6QYgDmENfoz0xW4VkRAkOwsrETV jpejN8mwz0MQ== X-IronPort-AV: E=Sophos;i="5.76,365,1592895600"; d="scan'208";a="324213877" Received: from asmit14x-mobl1.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.83.187]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 17:08:10 -0700 From: tedd.an@intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [V3 2/3] tools/btpclientctl: Add btpclient test application Date: Fri, 28 Aug 2020 17:08:02 -0700 Message-Id: <20200829000803.20286-2-tedd.an@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200829000803.20286-1-tedd.an@intel.com> References: <20200829000803.20286-1-tedd.an@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 92423420DD X-Rspamd-UID: dbfba1 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds a test application for btpclient, which exercises the BTP API. --- .gitignore | 1 + Makefile.tools | 6 +- tools/btpclientctl.c | 2372 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2378 insertions(+), 1 deletion(-) create mode 100644 tools/btpclientctl.c diff --git a/.gitignore b/.gitignore index eabdb273f..f4fb5db28 100644 --- a/.gitignore +++ b/.gitignore @@ -120,6 +120,7 @@ tools/btconfig tools/btmgmt tools/btsnoop tools/btpclient +tools/btpclientctl tools/btmon-logger tools/bluetooth-logger.service peripheral/btsensor diff --git a/Makefile.tools b/Makefile.tools index 9b9236609..07dfbf4e8 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -492,11 +492,15 @@ test_scripts += test/sap_client.py test/bluezutils.py \ test/test-gatt-profile test/test-mesh test/agent.py if BTPCLIENT -noinst_PROGRAMS += tools/btpclient +noinst_PROGRAMS += tools/btpclient tools/btpclientctl tools_btpclient_SOURCES = tools/btpclient.c src/shared/btp.c src/shared/btp.h tools_btpclient_LDADD = lib/libbluetooth-internal.la \ src/libshared-ell.la $(ell_ldadd) tools_btpclient_DEPENDENCIES = lib/libbluetooth-internal.la $(ell_dependencies) tools/btpclient.$(OBJEXT): src/libshared-ell.la ell/internal + +tools_btpclientctl_SOURCES = tools/btpclientctl.c client/display.c +tools_btpclientctl_LDADD = src/libshared-mainloop.la src/libshared-glib.la \ + lib/libbluetooth-internal.la -lreadline endif diff --git a/tools/btpclientctl.c b/tools/btpclientctl.c new file mode 100644 index 000000000..5be10f23c --- /dev/null +++ b/tools/btpclientctl.c @@ -0,0 +1,2372 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdio.h> +#include <errno.h> +#include <unistd.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <poll.h> + +#include "lib/bluetooth.h" + +#include "src/shared/ad.h" +#include "src/shared/btp.h" +#include "src/shared/io.h" +#include "src/shared/mainloop.h" +#include "src/shared/queue.h" +#include "src/shared/shell.h" +#include "src/shared/util.h" + +#define DEFAULT_SOCKET_PATH "/tmp/bt-stack-tester" + +#define PROMPT_ON COLOR_BLUE "[btpclient]" COLOR_OFF "# " + +#define EVT_OPCODE_BASE 0x80 + +#define DEFAULT_INDEX 0x00 + +struct ad_data { + uint8_t data[25]; + uint8_t len; +}; + +struct name_func_entry { + const char *name; + void (*func)(void); +}; + +struct indexstr_data { + int index; + const char *str; +}; + +struct bitfield_data { + uint32_t bit; + const char *str; +}; + +struct opcode_data { + uint8_t opcode; + int bit; + const char *str; + + void (*cmd_func)(const void *data, uint16_t size); + uint16_t cmd_size; + bool cmd_fixed; + + void (*rsp_func)(const void *data, uint16_t size); + uint16_t rsp_size; + bool rsp_fixed; + + void (*evt_func)(const void *data, uint16_t size); + uint16_t evt_size; + bool evt_fixed; +}; + +struct service_data { + uint8_t id; + int bit; + const char *str; + const struct opcode_data *opcode_table; +}; + +struct advertise_data { + struct bt_ad *ad; + struct bt_ad *scan; +}; + +struct client_data { + int fd; + + /* Incoming buffer for response and event */ + uint8_t buf[512]; +}; + +struct btpclientctl { + int server_fd; + char *socket_path; + + bool debug_enabled; + bool enable_dump; + + bool client_active; + struct client_data *client_data; + + /* Outgoing buffer for command */ + uint8_t buf[560]; + uint16_t buf_len; +}; + +static struct advertise_data *advertise_data; +static struct btpclientctl *btpclientctl; +static uint8_t bt_index = DEFAULT_INDEX; + +static void hexdump_print(const char *str, void *user_data) +{ + bt_shell_printf("%s%s\n", (char *) user_data, str); +} + +static bool parse_argument_on_off(int argc, char *argv[], uint8_t *val) +{ + if (!strcasecmp(argv[1], "on") || !strcasecmp(argv[1], "yes")) + *val = 1; + else if (!strcasecmp(argv[1], "off") || !strcasecmp(argv[1], "no")) + *val = 0; + else + *val = atoi(argv[1]); + return true; +} + +static bool parse_argument_list(int argc, char *argv[], uint8_t *val, + const struct indexstr_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (strcasecmp(argv[1], table[i].str) == 0) { + *val = table[i].index; + return true; + } + } + + bt_shell_printf("Invalid arguement %s\n", argv[1]); + + return false; +} + +static bool parse_argument_bitfield_list(int argc, char *argv[], uint32_t *val, + const struct bitfield_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (strcasecmp(argv[0], table[i].str) == 0) { + *val = table[i].bit; + return true; + } + } + + bt_shell_printf("Invalid argument %s\n", argv[0]); + + return false; +} + +static bool parse_argument_addr(int argc, char *argv[], uint8_t *addr_type, + bdaddr_t *bdaddr) +{ + if (argc < 3) { + bt_shell_printf("Invalid parameter\n"); + return false; + } + + *addr_type = atoi(argv[1]); + str2ba(argv[2], bdaddr); + + return true; +} + +static char *argument_gen(const char *text, int state, + const struct indexstr_data *list) +{ + static int index, len; + const char *arg; + + if (!state) { + index = 0; + len = strlen(text); + } + + while ((arg = list[index].str)) { + index++; + + if (!strncasecmp(arg, text, len)) + return strdup(arg); + } + + return NULL; +} + +static char *argument_gen_bitfield(const char *text, int state, + const struct bitfield_data *list) +{ + static int index, len; + const char *arg; + + if (!state) { + index = 0; + len = strlen(text); + } + + while ((arg = list[index].str)) { + index++; + + if (!strncasecmp(arg, text, len)) + return strdup(arg); + } + + return NULL; +} + +static char *argument_gen_name_func_entry(const char *text, int state, + const struct name_func_entry *list) +{ + static int index, len; + const char *arg; + + if (!state) { + index = 0; + len = strlen(text); + } + + while ((arg = list[index].name)) { + index++; + + if (!strncasecmp(arg, text, len)) + return strdup(arg); + } + + return NULL; +} + +static const struct service_data service_table[]; + +static const struct service_data *find_service_data(uint8_t service_id) +{ + int i; + + for (i = 0; service_table[i].str; i++) { + if (service_table[i].id == service_id) + return &service_table[i]; + } + + return NULL; +} + +static const struct opcode_data *find_opcode_data(uint8_t opcode, + const struct opcode_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (table[i].opcode == opcode) + return &table[i]; + } + + return NULL; +} + +static const char *get_indexstr(int val, const struct indexstr_data *table) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (val == table[i].index) + return table[i].str; + } + + return "Unknown"; +} + +static uint32_t print_bitfield(uint32_t val, const struct bitfield_data *table, + const char *prefix) +{ + uint32_t mask = val; + int i; + + for (i = 0; table[i].str; i++) { + if (val & (((uint32_t) 1) << table[i].bit)) { + bt_shell_printf("%s%s (0x%4.4x)\n", prefix, + table[i].str, table[i].bit); + mask &= ~(((uint32_t) 1) << table[i].bit); + } + } + + return mask; +} + +static void print_bdaddr(const bdaddr_t *address, uint8_t address_type) +{ + char addr[18]; + + ba2str(address, addr); + if (address_type == BTP_GAP_ADDR_PUBLIC) + bt_shell_printf("\t%s (public)\n", addr); + else if (address_type == BTP_GAP_ADDR_RANDOM) + bt_shell_printf("\t%s (random)\n", addr); + else + bt_shell_printf("\t%s (unknown)\n", addr); +} + +static void null_cmd(const void *data, uint16_t size) +{ + /* Empty */ +} + +static void null_rsp(const void *data, uint16_t size) +{ + /* Empty */ +} + +static void null_evt(const void *data, uint16_t size) +{ + /* Empty */ +} + +static const struct indexstr_data error_table[] = { + { 0x01, "Faile" }, + { 0x02, "Unknown Command" }, + { 0x03, "Not Ready" }, + { 0x04, "Invalid Index" }, + { } +}; + +static void print_error_rsp(const void *data, uint16_t size) +{ + uint8_t reason = ((uint8_t *)data)[0]; + + bt_shell_printf(COLOR_RED "\tReason: %s (%d)\n" COLOR_OFF, + get_indexstr(reason, error_table), reason); +} + +static const char *service_to_str(uint8_t service_id) +{ + int i; + + for (i = 0; service_table[i].str; i++) { + if (service_table[i].id == service_id) + return service_table[i].str; + } + + return "Unknown Service ID"; +} + +static const char *get_supported_service(int bit) +{ + int i; + + for (i = 0; service_table[i].str; i++) { + if (service_table[i].bit == bit) + return service_table[i].str; + } + + return NULL; +} + +static const char *get_supported_command(const struct opcode_data *table, + int bit) +{ + int i; + + for (i = 0; table[i].str; i++) { + if (table[i].bit == bit) + return table[i].str; + } + return NULL; +} + +static void print_btp_hdr(struct btp_hdr *btp_hdr, const char *type_str, + const char *opcode_str) +{ + bt_shell_printf("%s: %s(%d) %s(0x%02x) INDEX(0x%02x)\n", type_str, + service_to_str(btp_hdr->service), btp_hdr->service, + opcode_str, btp_hdr->opcode, btp_hdr->index); +} + +static const struct opcode_data opcode_table_core[]; + +static void print_core_read_supported_commands_rsp(const void *data, + uint16_t size) +{ + uint8_t cmds; + const char *str; + int i, bit; + + cmds = ((uint8_t *)data)[0]; + + for (i = 1; i < (int)(sizeof(cmds) * 8); i++) { + bit = 0; + bit = 1 << i; + if (cmds & bit) { + str = get_supported_command(opcode_table_core, i); + if (str) + bt_shell_printf("\t%s (Bit %d)\n", str, i); + else + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); + } + } +} + +static void print_core_read_supported_services_rsp(const void *data, + uint16_t size) +{ + uint8_t services; + const char *str; + int i, bit; + + services = ((uint8_t *)data)[0]; + + for (i = 0; i < (int)(sizeof(services) * 8); i++) { + bit = 1 << i; + if (services & bit) { + str = get_supported_service(i); + if (str) + bt_shell_printf("\t%s (Bit %d)\n", str, i); + else + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); + } + } +} + +static void print_core_register_service_cmd(const void *data, uint16_t size) +{ + const struct btp_core_register_cp *cp = data; + + bt_shell_printf("\tService ID: %s(0x%02x)\n", + service_to_str(cp->service_id), cp->service_id); +} + +static void print_core_unregister_service_cmd(const void *data, uint16_t size) +{ + const struct btp_core_unregister_cp *cp = data; + + bt_shell_printf("\tService ID: %s(0x%02x)\n", + service_to_str(cp->service_id), cp->service_id); +} + +static const struct opcode_data opcode_table_core[] = { + { 0x00, 0, "Error", + null_cmd, 0, true, + print_error_rsp, 1, true }, + { 0x01, 1, "Read Supported Commands", + null_cmd, 0, true, + print_core_read_supported_commands_rsp, 1, true }, + { 0x02, 2, "Read Supported Services", + null_cmd, 0, true, + print_core_read_supported_services_rsp, 1, true }, + { 0x03, 3, "Register Service", + print_core_register_service_cmd, 1, true, + null_rsp, 0, true }, + { 0x04, 4, "Unregister Service", + print_core_unregister_service_cmd, 1, true, + null_rsp, 0, true }, + { 0x80, -1, "IUT Ready", + null_cmd, 0, true, + null_rsp, 0, true, + null_evt, 0, true }, + { } +}; + +static const struct opcode_data opcode_table_gap[]; + +static void print_gap_read_supported_commands_rsp(const void *data, + uint16_t size) +{ + uint16_t cmds; + const char *str; + int i; + + cmds = le16_to_cpu(((uint16_t *)data)[0]); + + for (i = 1; i < (int)(sizeof(cmds) * 8); i++) { + if (cmds & (1 << i)) { + str = get_supported_command(opcode_table_gap, i); + if (str) + bt_shell_printf("\t%s (Bit %d)\n", str, i); + else + bt_shell_printf("\tUNKNOWN (Bit %d)\n", i); + } + } +} + +static void print_gap_read_controller_index_list_rsp(const void *data, + uint16_t size) +{ + const struct btp_gap_read_index_rp *list = data; + int i; + + for (i = 0; i < list->num; i++) + bt_shell_printf("\tIndex: %d\n", list->indexes[i]); +} + +static const struct bitfield_data gap_setting_table[] = { + { 0, "Powered" }, + { 1, "Connectable" }, + { 2, "Fast Connectable" }, + { 3, "Discoverable" }, + { 4, "Bondable" }, + { 5, "Link Layer Security" }, + { 6, "Secure Simple Pairing" }, + { 7, "BR/EDR" }, + { 8, "High Speed" }, + { 9, "Low Energy" }, + { 10, "Advertising" }, + { 11, "Secure Connection" }, + { 12, "Debug Keys" }, + { 13, "Privacy" }, + { 14, "Controller Configuration" }, + { 15, "Static Address" }, + { } +}; + +static void print_gap_settings(uint32_t val, const struct bitfield_data *table, + const char *prefix) +{ + uint32_t mask; + + mask = print_bitfield(val, table, prefix); + if (mask) + bt_shell_printf("%sUnknown settings (0x%4.4x)\n", prefix, mask); +} + +static void print_gap_read_controller_information_rsp(const void *data, + uint16_t size) +{ + const struct btp_gap_read_info_rp *info = data; + char addr[18]; + + ba2str(&info->address, addr); + bt_shell_printf("\tAddress: %s\n", addr); + bt_shell_printf("\tSupported Settings\n"); + print_gap_settings(le32_to_cpu(info->supported_settings), + gap_setting_table, "\t\t"); + bt_shell_printf("\tCurrent Settings\n"); + print_gap_settings(le32_to_cpu(info->current_settings), + gap_setting_table, "\t\t"); + bt_shell_printf("\tClass: 0x%02x%02x%02x\n", + info->cod[2], info->cod[1], info->cod[0]); + bt_shell_printf("\tShort: %s\n", info->short_name); + bt_shell_printf("\tName: %s\n", info->name); +} + +static void print_gap_reset_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_reset_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static const struct indexstr_data on_off_table[] = { + { 0x00, "Off" }, + { 0x01, "On" }, + { } +}; + +static void print_gap_set_powered_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_powered_cp *cp = data; + + bt_shell_printf("\tSet Power: %s (%d)\n", + get_indexstr(cp->powered, on_off_table), + cp->powered); +} + +static void print_gap_set_powered_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_powered_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_set_connectable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_connectable_cp *cp = data; + + bt_shell_printf("\t Set Connectable: %s (%d)\n", + get_indexstr(cp->connectable, on_off_table), + cp->connectable); +} + +static void print_gap_set_connectable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_connectable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_set_fast_connectable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_fast_connectable_cp *cp = data; + + bt_shell_printf("\t Set Fast Connectable: %s (%d)\n", + get_indexstr(cp->fast_connectable, on_off_table), + cp->fast_connectable); +} + +static void print_gap_set_fast_connectable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_fast_connectable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static const struct indexstr_data gap_discoverable_table[] = { + { 0x00, "Off" }, + { 0x01, "On" }, + { 0x02, "Limited" }, + { } +}; + +static void print_gap_set_discoverable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_discoverable_cp *cp = data; + + bt_shell_printf("\t Set Discoverable: %s (%d)\n", + get_indexstr(cp->discoverable, gap_discoverable_table), + cp->discoverable); +} + +static void print_gap_set_discoverable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_discoverable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_set_bondable_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_bondable_cp *cp = data; + + bt_shell_printf("\t Set Bondable: %s (%d)\n", + get_indexstr(cp->bondable, on_off_table), + cp->bondable); +} + +static void print_gap_set_bondable_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_set_bondable_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +const struct indexstr_data ad_type_table[] = { + { 0x01, "BT_AD_FLAGS" }, + { 0x02, "BT_AD_UUID16_SOME" }, + { 0x03, "BT_AD_UUID16_ALL" }, + { 0x04, "BT_AD_UUID32_SOME" }, + { 0x05, "BT_AD_UUID32_ALL" }, + { 0x06, "BT_AD_UUID128_SOME" }, + { 0x07, "BT_AD_UUID128_ALL" }, + { 0x08, "BT_AD_NAME_SHORT" }, + { 0x09, "BT_AD_NAME_COMPLETE" }, + { 0x0a, "BT_AD_TX_POWER" }, + { 0x0d, "BT_AD_CLASS_OF_DEV" }, + { 0x0e, "BT_AD_SSP_HASH" }, + { 0x0f, "BT_AD_SSP_RANDOMIZER" }, + { 0x10, "BT_AD_DEVICE_ID" }, + { 0x10, "BT_AD_SMP_TK" }, + { 0x11, "BT_AD_SMP_OOB_FLAGS" }, + { 0x12, "BT_AD_SLAVE_CONN_INTERVAL" }, + { 0x14, "BT_AD_SOLICIT16" }, + { 0x15, "BT_AD_SOLICIT128" }, + { 0x16, "BT_AD_SERVICE_DATA16" }, + { 0x17, "BT_AD_PUBLIC_ADDRESS" }, + { 0x18, "BT_AD_RANDOM_ADDRESS" }, + { 0x19, "BT_AD_GAP_APPEARANCE" }, + { 0x1a, "BT_AD_ADVERTISING_INTERVAL" }, + { 0x1b, "BT_AD_LE_DEVICE_ADDRESS" }, + { 0x1c, "BT_AD_LE_ROLE" }, + { 0x1d, "BT_AD_SSP_HASH_P256" }, + { 0x1e, "BT_AD_SSP_RANDOMIZER_P256" }, + { 0x1f, "BT_AD_SOLICIT32" }, + { 0x20, "BT_AD_SERVICE_DATA32" }, + { 0x21, "BT_AD_SERVICE_DATA128" }, + { 0x22, "BT_AD_LE_SC_CONFIRM_VALUE" }, + { 0x23, "BT_AD_LE_SC_RANDOM_VALUE" }, + { 0x24, "BT_AD_URI" }, + { 0x25, "BT_AD_INDOOR_POSITIONING" }, + { 0x26, "BT_AD_TRANSPORT_DISCOVERY" }, + { 0x27, "BT_AD_LE_SUPPORTED_FEATURES" }, + { 0x28, "BT_AD_CHANNEL_MAP_UPDATE_IND" }, + { 0x29, "BT_AD_MESH_PROV" }, + { 0x2a, "BT_AD_MESH_DATA" }, + { 0x2b, "BT_AD_MESH_BEACON" }, + { 0x3d, "BT_AD_3D_INFO_DATA" }, + { 0xff, "BT_AD_MANUFACTURER_DATA" } +}; + +struct ad_struct { + uint8_t length; + uint8_t type; + uint8_t data[0]; +}; + +static void print_ad_data(const uint8_t *data, size_t data_len) +{ + struct ad_struct *ad_struct; + size_t count = 0; + + if (!data || !data_len) { + bt_shell_printf("\tEmpty\n"); + return; + } + + while (count < data_len) { + ad_struct = (struct ad_struct *)(data + count); + + bt_shell_printf("Type: %s(0x%02x)\n", + get_indexstr(ad_struct->type, ad_type_table), + ad_struct->type); + bt_shell_hexdump(ad_struct->data, ad_struct->length - 1); + + count += ad_struct->length + 1; + } +} + +static void print_gap_start_advertising_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_start_adv_cp *cp = data; + + if (cp->adv_data_len) { + bt_shell_printf("\tAdvertising Data:\n"); + print_ad_data(cp->data, cp->adv_data_len); + } + + if (cp->scan_rsp_len) { + bt_shell_printf("\tScan Response Data:\n"); + print_ad_data(cp->data + cp->adv_data_len, cp->scan_rsp_len); + } +} + +static void print_gap_start_advertising_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_start_adv_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_stop_advertising_rsp(const void *data, uint16_t size) +{ + const struct btp_gap_start_adv_rp *rp = data; + + print_gap_settings(le32_to_cpu(rp->current_settings), + gap_setting_table, "\t"); +} + +static const struct bitfield_data gap_discovery_flags_table[] = { + { 0, "LE" }, + { 1, "BREDE" }, + { 2, "Limited" }, + { 3, "Active" }, + { 4, "Observation" }, + { } +}; + +static void print_gap_start_discovery_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_start_discovery_cp *cp = data; + uint32_t mask; + + mask = print_bitfield(le32_to_cpu(cp->flags), + gap_discovery_flags_table, "\t\t"); + if (mask) + bt_shell_printf("\t\tUnknown flags (0x%4.4x)\n", mask); +} + +static void print_gap_connect_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_connect_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static void print_gap_disconnect_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_disconnect_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static const struct indexstr_data gap_io_capa_table[] = { + { 0x00, "DisplayOnly" }, + { 0x01, "DisplayYesNo" }, + { 0x02, "KeyboardOnly" }, + { 0x03, "NoInputOutput" }, + { 0x04, "KeyboardDisplay" }, + { } +}; + +static void print_gap_set_io_capa_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_set_io_capa_cp *cp = data; + + bt_shell_printf("\tIO Capa: %s (%d)\n", + get_indexstr(cp->capa, gap_io_capa_table), cp->capa); +} + +static void print_gap_pair_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_pair_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static void print_gap_unpair_cmd(const void *data, uint16_t size) +{ + const struct btp_gap_unpair_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); +} + +static void print_gap_passkey_entry_response_cmd(const void *data, + uint16_t size) +{ + const struct btp_gap_passkey_entry_rsp_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(cp->passkey)); +} + +static void print_gap_passkey_confirmation_response_cmd(const void *data, + uint16_t size) +{ + const struct btp_gap_passkey_confirm_rsp_cp *cp = data; + + print_bdaddr(&cp->address, cp->address_type); + bt_shell_printf("\tMatch: %d\n", cp->match); +} + +static void print_gap_new_settings_evt(const void *data, uint16_t size) +{ + const struct btp_new_settings_ev *ev = data; + + print_gap_settings(le32_to_cpu(ev->current_settings), + gap_setting_table, "\t"); +} + +static void print_gap_eir(const uint8_t *eir, uint16_t eir_len, + const char *prefix) +{ + char str[64]; + int i, n; + + if (eir_len == 0) { + bt_shell_printf("%sEIR Data: Empty\n", prefix); + return; + } + + bt_shell_printf("%sEIR Data:\n", prefix); + for (i = 0, n = 0; i < eir_len; i++) { + n += sprintf(str + n, "%02x ", eir[i]); + if ((i % 16) == 15) { + str[n] = '\0'; + bt_shell_printf("\t%s%s\n", prefix, str); + n = 0; + } + } +} + +static const struct bitfield_data gap_device_found_flags_table[] = { + { 0, "RSSI Valid" }, + { 1, "Adv_Data Included" }, + { 2, "Scan_Rsp Included" }, + { } +}; + +static void print_gap_device_found_evt(const void *data, uint16_t size) +{ + const struct btp_device_found_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tRSSI: %d\n", ev->rssi); + bt_shell_printf("\tFlags:\n"); + print_bitfield(ev->flags, gap_device_found_flags_table, "\t\t"); + print_gap_eir(ev->eir, ev->eir_len, "\t"); +} + +static void print_gap_device_connected_evt(const void *data, uint16_t size) +{ + const struct btp_gap_device_connected_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); +} + +static void print_gap_device_disconnected_evt(const void *data, uint16_t size) +{ + const struct btp_gap_device_disconnected_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); +} + +static void print_gap_passkey_display_evt(const void *data, uint16_t size) +{ + const struct btp_gap_passkey_display_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(ev->passkey)); +} + +static void print_gap_passkey_enter_request_evt(const void *data, uint16_t size) +{ + const struct btp_gap_passkey_req_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); +} + +static void print_gap_passkey_confirm_request_evt(const void *data, + uint16_t size) +{ + const struct btp_gap_passkey_confirm_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tPasskey: %d\n", le32_to_cpu(ev->passkey)); +} + +static void print_gap_identity_resolved_evt(const void *data, uint16_t size) +{ + const struct btp_gap_identity_resolved_ev *ev = data; + + print_bdaddr(&ev->address, ev->address_type); + bt_shell_printf("\tIdentity: "); + print_bdaddr(&ev->identity_address, ev->identity_address_type); +} + + +static const struct opcode_data opcode_table_gap[] = { + { 0x00, 0, "Error", + null_cmd, 0, true, + print_error_rsp, 1, true }, + { 0x01, 1, "Read Supported Commands", + null_cmd, 0, true, + print_gap_read_supported_commands_rsp, 2, true }, + { 0x02, 2, "Read Controller Index List", + null_cmd, 0, true, + print_gap_read_controller_index_list_rsp, 2, false }, + { 0x03, 3, "Read Controller Information", + null_cmd, 0, true, + print_gap_read_controller_information_rsp, 277, true }, + { 0x04, 4, "Reset", + null_cmd, 0, true, + print_gap_reset_rsp, 4, true }, + { 0x05, 5, "Set Powered", + print_gap_set_powered_cmd, 1, true, + print_gap_set_powered_rsp, 4, true }, + { 0x06, 6, "Set Connectable", + print_gap_set_connectable_cmd, 1, true, + print_gap_set_connectable_rsp, 4, true }, + { 0x07, 7, "Set Fast Connectable", + print_gap_set_fast_connectable_cmd, 1, true, + print_gap_set_fast_connectable_rsp, 4, true }, + { 0x08, 8, "Set Discoverable", + print_gap_set_discoverable_cmd, 1, true, + print_gap_set_discoverable_rsp, 4, true }, + { 0x09, 9, "Set Bondable", + print_gap_set_bondable_cmd, 1, true, + print_gap_set_bondable_rsp, 4, true }, + { 0x0a, 10, "Starting Advertising", + print_gap_start_advertising_cmd, 2, false, + print_gap_start_advertising_rsp, 4, true }, + { 0x0b, 11, "Stop Advertising", + null_cmd, 0, true, + print_gap_stop_advertising_rsp, 4, true }, + { 0x0c, 12, "Start Discovery", + print_gap_start_discovery_cmd, 1, true, + null_rsp, 0, true }, + { 0x0d, 13, "Stop Discovery", + null_cmd, 0, true, + null_rsp, 0, true }, + { 0x0e, 14, "Connect", + print_gap_connect_cmd, 7, true, + null_rsp, 0, true }, + { 0x0f, 15, "Disconnect", + print_gap_disconnect_cmd, 7, true, + null_rsp, 0, true }, + { 0x10, 16, "Set I/O Capability", + print_gap_set_io_capa_cmd, 1, true, + null_rsp, 0, true }, + { 0x11, 17, "Pair", + print_gap_pair_cmd, 7, true, + null_rsp, 0, true }, + { 0x12, 18, "Unpair", + print_gap_unpair_cmd, 7, true, + null_rsp, 0, true }, + { 0x13, 19, "Passkey Entry Response", + print_gap_passkey_entry_response_cmd, 11, true, + null_rsp, 0, true }, + { 0x14, 20, "Passkey Confirmation Response", + print_gap_passkey_confirmation_response_cmd, 8, true, + null_rsp, 0, true }, + { 0x80, -1, "New Settings", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_new_settings_evt, 4, true }, + { 0x81, -1, "Device Found", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_device_found_evt, 11, false }, + { 0x82, -1, "Device Connected", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_device_connected_evt, 7, true }, + { 0x83, -1, "Device Disconnected", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_device_disconnected_evt, 7, true }, + { 0x84, -1, "Passkey Display", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_passkey_display_evt, 11, true }, + { 0x85, -1, "Passkey Entry Request", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_passkey_enter_request_evt, 7, true }, + { 0x86, -1, "Passkey Confirm Request", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_passkey_confirm_request_evt, 11, true }, + { 0x87, -1, "Identity Resolved", + null_cmd, 0, true, + null_rsp, 0, true, + print_gap_identity_resolved_evt, 14, true }, + { } +}; + +static const struct service_data service_table[] = { + { 0x00, 0, "Core", opcode_table_core}, + { 0x01, 1, "GAP", opcode_table_gap}, + { } +}; + +static bool write_packet(int fd, const void *data, size_t size) +{ + while (size > 0) { + ssize_t written; + + written = write(fd, data, size); + if (written < 0) { + if (errno == EAGAIN || errno == EINTR) + continue; + return false; + } + + if (btpclientctl->enable_dump) + util_hexdump('<', data, written, hexdump_print, + "OUT: "); + + data += written; + size -= written; + } + + return true; +} + +static void btp_print_cmd(struct btp_hdr *btp_hdr, void *data) +{ + const struct service_data *table; + const struct opcode_data *opcode_data; + + table = find_service_data(btp_hdr->service); + if (!table) { + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); + return; + } + + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); + if (!opcode_data) { + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); + return; + } + + print_btp_hdr(btp_hdr, "CMD", opcode_data->str); + + if (opcode_data->cmd_fixed) { + if (btp_hdr->data_len != opcode_data->cmd_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } else { + if (btp_hdr->data_len < opcode_data->cmd_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } + + opcode_data->cmd_func(data, btp_hdr->data_len); +} + +static void btp_print_rsp(struct btp_hdr *btp_hdr, void *data) +{ + const struct service_data *table; + const struct opcode_data *opcode_data; + + table = find_service_data(btp_hdr->service); + if (!table) { + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); + return; + } + + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); + if (!opcode_data) { + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); + return; + } + + print_btp_hdr(btp_hdr, "RSP", opcode_data->str); + + if (opcode_data->rsp_fixed) { + if (btp_hdr->data_len != opcode_data->rsp_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } else { + if (btp_hdr->data_len < opcode_data->rsp_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } + + opcode_data->rsp_func(data, btp_hdr->data_len); +} + +static void btp_print_evt(struct btp_hdr *btp_hdr, void *data) +{ + const struct service_data *table; + const struct opcode_data *opcode_data; + + table = find_service_data(btp_hdr->service); + if (!table) { + bt_shell_printf("Unknown Service: 0x%02x\n", btp_hdr->service); + return; + } + + opcode_data = find_opcode_data(btp_hdr->opcode, table->opcode_table); + if (!opcode_data) { + bt_shell_printf("Unknown Opcode: 0x%02x\n", btp_hdr->opcode); + return; + } + + print_btp_hdr(btp_hdr, "EVT", opcode_data->str); + + if (opcode_data->evt_fixed) { + if (btp_hdr->data_len != opcode_data->evt_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } else { + if (btp_hdr->data_len < opcode_data->evt_size) { + bt_shell_printf("Invalid Parameter length %d\n", + btp_hdr->data_len); + return; + } + } + + opcode_data->evt_func(data, btp_hdr->data_len); +} + +static bool send_cmd(uint8_t service_id, uint8_t opcode, uint8_t index, + uint16_t data_len, void *data) +{ + struct btp_hdr *hdr; + int client_fd; + + if (!btpclientctl->client_active) { + bt_shell_printf("ERROR: Client is not active\n"); + return false; + } + + hdr = (struct btp_hdr *)(btpclientctl->buf); + + hdr->service = service_id; + hdr->opcode = opcode; + hdr->index = index; + hdr->data_len = cpu_to_le16(data_len); + if (data) + memcpy(hdr->data, data, data_len); + + btpclientctl->buf_len = sizeof(*hdr) + data_len; + + client_fd = btpclientctl->client_data->fd; + + btp_print_cmd(hdr, data_len ? hdr->data : NULL); + + if (!write_packet(client_fd, btpclientctl->buf, + btpclientctl->buf_len)) { + fprintf(stderr, "Failed to send command to client\n"); + mainloop_remove_fd(client_fd); + return false; + } + + return true; +} + +static void client_read_destroy(void *user_data) +{ + struct client_data *client_data = user_data; + + close(client_data->fd); + free(client_data); + + btpclientctl->client_active = false; + + bt_shell_printf("Client is disconnected\n"); +} + +static void client_read_callback(int fd, uint32_t events, void *user_data) +{ + struct client_data *client_data = user_data; + struct btp_hdr *btp_hdr; + uint8_t *data, *ptr; + ssize_t len, pkt_len; + + if (events & (EPOLLERR | EPOLLHUP)) { + fprintf(stderr, "Error from client connection\n"); + mainloop_remove_fd(client_data->fd); + return; + } + + if (events & EPOLLRDHUP) { + fprintf(stderr, "Remote hangeup of cliient connection\n"); + mainloop_remove_fd(client_data->fd); + return; + } + + /* Read incoming packet */ + len = read(client_data->fd, client_data->buf, sizeof(client_data->buf)); + if (len < 0) { + if (errno == EAGAIN || errno == EINTR) + return; + + fprintf(stderr, "Read from client descriptor failed\n"); + mainloop_remove_fd(client_data->fd); + return; + } + + if (len < (ssize_t)sizeof(struct btp_hdr) - 1) + return; + + ptr = client_data->buf; + + while (len) { + btp_hdr = (struct btp_hdr *)ptr; + + pkt_len = sizeof(*btp_hdr) + btp_hdr->data_len; + + if (btpclientctl->enable_dump) + util_hexdump('>', ptr, pkt_len, hexdump_print, "IN : "); + + if (btp_hdr->data_len) + data = btp_hdr->data; + else + data = NULL; + + if (btp_hdr->opcode < EVT_OPCODE_BASE) + btp_print_rsp(btp_hdr, data); + else + btp_print_evt(btp_hdr, data); + + ptr += pkt_len; + len -= pkt_len; + } +} + +static struct client_data *setup_client(int client_fd) +{ + struct client_data *client_data; + + client_data = new0(struct client_data, 1); + if (!client_data) + return NULL; + + client_data->fd = client_fd; + + mainloop_add_fd(client_data->fd, EPOLLIN | EPOLLRDHUP, + client_read_callback, client_data, client_read_destroy); + + return client_data; +} + +static void server_callback(int fd, uint32_t events, void *user_data) +{ + union { + struct sockaddr common; + struct sockaddr_un sun; + struct sockaddr_in sin; + } addr; + socklen_t len; + int client_fd; + struct client_data *client_data; + struct btpclientctl *btpclientctl = user_data; + + if (events & (EPOLLERR | EPOLLHUP)) { + mainloop_quit(); + return; + } + + memset(&addr, 0, sizeof(addr)); + len = sizeof(addr); + + if (getsockname(fd, &addr.common, &len) < 0) { + perror("Failed to get socket name"); + return; + } + + client_fd = accept(fd, &addr.common, &len); + if (client_fd < 0) { + perror("Failed to accept client socket"); + return; + } + + bt_shell_printf("Client is connected\n"); + + /* Setup Client */ + client_data = setup_client(client_fd); + if (!client_data) { + fprintf(stderr, "Failed to setup client\n"); + close(client_fd); + return; + } + + btpclientctl->client_data = client_data; + btpclientctl->client_active = true; +} + +static int open_socket(const char *path) +{ + struct sockaddr_un addr; + size_t len; + int fd; + + len = strlen(path); + if (len > sizeof(addr.sun_path) - 1) { + fprintf(stderr, "Socket path is too long\n"); + return -1; + } + + unlink(path); + + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (fd < 0) { + perror("Failed to open Unix server socket"); + return -1; + } + + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); + + if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + perror("Failed to bind Unix server socket"); + goto error_close; + } + + if (listen(fd, 1) < 0) { + perror("Failed to listen Unix server socket"); + goto error_close; + } + + bt_shell_printf("Waiting for client connection...\n"); + + if (chmod(path, 0666) < 0) { + perror("Failed to change Unix socket file mode"); + goto error_close; + } + + return fd; + +error_close: + close(fd); + return -1; +} + +static void cmd_core_read_cmds(int argc, char **argv) +{ + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_READ_SUPPORTED_COMMANDS, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_core_read_services(int argc, char **argv) +{ + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_READ_SUPPORTED_SERVICES, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_core_register_service(int argc, char **argv) +{ + uint8_t service_id; + + service_id = atoi(argv[1]); + if (service_id == 0) { + bt_shell_printf("CORE service is already registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_REGISTER, + BTP_INDEX_NON_CONTROLLER, 1, &service_id)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_core_unregister_service(int argc, char **argv) +{ + uint8_t service_id; + + service_id = atoi(argv[1]); + if (service_id == 0) { + bt_shell_printf("Cannot unregister CORE service\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!send_cmd(BTP_CORE_SERVICE, BTP_OP_CORE_UNREGISTER, + BTP_INDEX_NON_CONTROLLER, 1, &service_id)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_set_index(int argc, char **argv) +{ + uint8_t index; + + bt_shell_printf("Set Default Controller Index\n"); + + index = atoi(argv[1]); + if (index == bt_index) { + bt_shell_printf("Controller index is already set\n"); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + bt_index = index; + bt_shell_printf("Controller index is updated to 0x%02x\n", bt_index); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_read_cmds(int argc, char **argv) +{ + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_SUPPORTED_COMMANDS, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_read_index(int argc, char **argv) +{ + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_CONTROLLER_INDEX_LIST, + BTP_INDEX_NON_CONTROLLER, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_read_info(int argc, char **argv) +{ + uint8_t index; + + index = atoi(argv[1]); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_READ_COTROLLER_INFO, + index, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_reset(int argc, char **argv) +{ + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_RESET, bt_index, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_on_off_gen(const char *text, int state) +{ + return argument_gen(text, state, on_off_table); +} + +static void cmd_gap_power(int argc, char **argv) +{ + struct btp_gap_set_powered_cp cp; + + if (!parse_argument_on_off(argc, argv, &cp.powered)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_POWERED, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_connectable(int argc, char **argv) +{ + struct btp_gap_set_connectable_cp cp; + + if (!parse_argument_on_off(argc, argv, &cp.connectable)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_CONNECTABLE, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_fast_connectable(int argc, char **argv) +{ + struct btp_gap_set_fast_connectable_cp cp; + + if (!parse_argument_on_off(argc, argv, &cp.fast_connectable)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_FAST_CONNECTABLE, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_discoverable_gen(const char *text, int state) +{ + return argument_gen(text, state, gap_discoverable_table); +} + +static void cmd_gap_discoverable(int argc, char **argv) +{ + struct btp_gap_set_discoverable_cp cp; + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_list(argc, argv, &cp.discoverable, + gap_discoverable_table)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_DISCOVERABLE, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_bondable(int argc, char **argv) +{ + struct btp_gap_set_bondable_cp cp; + + if (!parse_argument_on_off(argc, argv, &cp.bondable)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_BONDABLE, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +/* + * This function converts the advertise data in the format of BT Spec to the + * format of BTP Spec. + */ +static void ad_convert_data(uint8_t *data, size_t len) +{ + struct ad_struct *ad_struct; + size_t count = 0; + uint8_t new_len; + + if (!data || !len) + return; + + while (count < len) { + ad_struct = (struct ad_struct *)(data + count); + + /* Swap AD_Type and AD_Len and update AD_Len */ + new_len = ad_struct->length - 1; + ad_struct->length = ad_struct->type; + ad_struct->type = new_len; + + count += new_len + 2; + } +} + +static void cmd_gap_start_adv(int argc, char **argv) +{ + struct btp_gap_start_adv_cp *cp; + uint8_t *ad_data, *scan_data; + size_t ad_len, scan_len; + size_t total; + int status = EXIT_SUCCESS; + + /* Generate advertise data */ + ad_data = bt_ad_generate(advertise_data->ad, &ad_len); + scan_data = bt_ad_generate(advertise_data->scan, &scan_len); + + if (!ad_data && !scan_data) { + bt_shell_printf("No Advertise or Scan data available\n"); + status = EXIT_FAILURE; + goto exit_error_free_data; + } + + total = ad_len + scan_len + 2; + + cp = (struct btp_gap_start_adv_cp *)malloc(total); + if (!cp) { + bt_shell_printf("Failed to allocated buffer\n"); + status = EXIT_FAILURE; + goto exit_error_free_data; + } + memset(cp, 0, total); + + /* + * Convert Advertise Data in the format specified in BTP Spec. + * BTP uses { AD_Type, AD_Len, AD_Data } struct instead of the format + * defined in the BT spec and BlueZ, { AD_Len, AD_Type, AD_Data }. + * + * In order to comply it, AD_Type and AD_Len need to be swapped and + * AD_Len needs be updated to exclude the length of AD_Type. + */ + ad_convert_data(ad_data, ad_len); + ad_convert_data(scan_data, scan_len); + + /* Copy Advertise data */ + cp->adv_data_len = ad_len; + memcpy(cp->data, ad_data, ad_len); + + /* Copy Scan Response data */ + cp->scan_rsp_len = scan_len; + memcpy(cp->data + ad_len, scan_data, scan_len); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_START_ADVERTISING, + bt_index, total, cp)) { + status = EXIT_FAILURE; + goto exit_error_free_cp; + } + +exit_error_free_cp: + free(cp); +exit_error_free_data: + free(ad_data); + free(scan_data); + + return bt_shell_noninteractive_quit(status); +} + +static void cmd_gap_stop_adv(int argc, char **argv) +{ + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_STOP_ADVERTISING, + bt_index, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_start_disc_gen(const char *text, int state) +{ + return argument_gen_bitfield(text, state, gap_discovery_flags_table); +} + +static void cmd_gap_start_disc(int argc, char **argv) +{ + struct btp_gap_start_discovery_cp cp; + int i; + uint32_t f; + + memset(&cp, 0, sizeof(cp)); + + for (i = 1; i < argc; i++) { + if (!parse_argument_bitfield_list(argc - i, &argv[i], &f, + gap_discovery_flags_table)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + cp.flags |= (1 << f); + } + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_START_DISCOVERY, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_stop_disc(int argc, char **argv) +{ + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_STOP_DISCOVERY, + bt_index, 0, NULL)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_connect(int argc, char **argv) +{ + struct btp_gap_connect_cp cp; + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_CONNECT, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_disconnect(int argc, char **argv) +{ + struct btp_gap_disconnect_cp cp; + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_DISCONNECT, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *gap_io_capa_gen(const char *text, int state) +{ + return argument_gen(text, state, gap_io_capa_table); +} + +static void cmd_gap_set_io_capa(int argc, char **argv) +{ + struct btp_gap_set_io_capa_cp cp; + + memset(&cp, 0, sizeof(cp)); + + if (argc != 2) { + bt_shell_printf("Invalid parameter\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!parse_argument_list(argc, argv, &cp.capa, gap_io_capa_table)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_SET_IO_CAPA, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_pair(int argc, char **argv) +{ + struct btp_gap_pair_cp cp; + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_PAIR, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_gap_unpair(int argc, char **argv) +{ + struct btp_gap_unpair_cp cp; + + memset(&cp, 0, sizeof(cp)); + + if (!parse_argument_addr(argc, argv, &cp.address_type, &cp.address)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!send_cmd(BTP_GAP_SERVICE, BTP_OP_GAP_UNPAIR, + bt_index, sizeof(cp), &cp)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static bool ad_add_data(struct ad_data *data, int argc, char *argv[]) +{ + char *endptr = NULL; + int i; + long value; + + memset(data, 0, sizeof(*data)); + + for (i = 0; i < argc; i++) { + endptr = NULL; + + value = strtol(argv[i], &endptr, 0); + if (!endptr || *endptr != '\0' || value > UINT8_MAX) { + bt_shell_printf("Invalid data index at %d\n", i); + return false; + } + + data->data[data->len] = value; + data->len++; + } + + return true; +} + +static void cmd_ad_show(int argc, char **argv) +{ + uint8_t *data; + size_t data_len; + + bt_shell_printf("Advertise Data:\n"); + data = bt_ad_generate(advertise_data->ad, &data_len); + print_ad_data(data, data_len); + + bt_shell_printf("Scan Response Data:\n"); + data = bt_ad_generate(advertise_data->scan, &data_len); + print_ad_data(data, data_len); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_ad_name(int argc, char **argv) +{ + if (argc < 2) { + cmd_ad_show(argc, argv); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + if (!bt_ad_add_name(advertise_data->ad, argv[1])) { + bt_shell_printf("Failed to add local name\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + cmd_ad_show(argc, argv); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_ad_appearance(int argc, char **argv) +{ + long value; + char *endptr = NULL; + + if (argc < 2) { + cmd_ad_show(argc, argv); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + value = strtol(argv[1], &endptr, 0); + if (!endptr || *endptr != '\0' || value > UINT16_MAX) { + bt_shell_printf("Invalid argument: %s\n", argv[1]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!bt_ad_add_appearance(advertise_data->ad, value)) { + bt_shell_printf("Failed to add appearance\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + cmd_ad_show(argc, argv); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_ad_uuids(int argc, char **argv) +{ + int i; + + if (argc < 2) { + cmd_ad_show(argc, argv); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + for (i = 1; i < argc; i++) { + bt_uuid_t uuid; + + if (bt_string_to_uuid(&uuid, argv[i]) < 0) { + bt_shell_printf("Invalid argument: %s\n", argv[i]); + goto fail; + } + + if (!bt_ad_add_service_uuid(advertise_data->ad, &uuid)) { + bt_shell_printf("Failed to add service uuid\n"); + goto fail; + } + } + + cmd_ad_show(argc, argv); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +fail: + bt_ad_clear_service_uuid(advertise_data->ad); + + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + +static void cmd_ad_manufacturer(int argc, char **argv) +{ + long value; + char *endptr = NULL; + struct ad_data data; + + if (argc < 2) { + cmd_ad_show(argc, argv); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + value = strtol(argv[1], &endptr, 0); + if (!endptr || *endptr != '\0' || value > UINT16_MAX) { + bt_shell_printf("Invalid manufacture id: %s\n", argv[1]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!ad_add_data(&data, argc-2, argv + 2)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!bt_ad_add_manufacturer_data(advertise_data->ad, value, + data.data, data.len)) { + bt_shell_printf("Failed to add manufacturer data\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + cmd_ad_show(argc, argv); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_ad_solicit(int argc, char **argv) +{ + int i; + + if (argc < 2) { + cmd_ad_show(argc, argv); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + for (i = 1; i < argc; i++) { + bt_uuid_t uuid; + + if (bt_string_to_uuid(&uuid, argv[i]) < 0) { + bt_shell_printf("Invalid argument: %s\n", argv[i]); + goto fail; + } + + if (!bt_ad_add_solicit_uuid(advertise_data->ad, &uuid)) { + bt_shell_printf("Failed to add service uuid\n"); + goto fail; + } + } + + cmd_ad_show(argc, argv); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +fail: + bt_ad_clear_solicit_uuid(advertise_data->ad); + + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + +static void cmd_ad_service_data(int argc, char **argv) +{ + bt_uuid_t uuid; + struct ad_data data; + + if (argc < 2) { + cmd_ad_show(argc, argv); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + if (bt_string_to_uuid(&uuid, argv[1]) < 0) { + bt_shell_printf("Invalid argument: %s\n", argv[1]); + goto fail; + } + + if (!ad_add_data(&data, argc-2, argv + 2)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!bt_ad_add_service_data(advertise_data->ad, &uuid, + data.data, data.len)) { + bt_shell_printf("Failed to add service data\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + cmd_ad_show(argc, argv); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +fail: + bt_ad_clear_service_data(advertise_data->ad); + + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + +static void cmd_ad_data(int argc, char **argv) +{ + long value; + char *endptr = NULL; + struct ad_data data; + + if (argc < 2) { + cmd_ad_show(argc, argv); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + value = strtol(argv[1], &endptr, 0); + if (!endptr || *endptr != '\0' || value > UINT8_MAX) { + bt_shell_printf("Invalid data type: %s\n", argv[1]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!ad_add_data(&data, argc-2, argv + 2)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + if (!bt_ad_add_data(advertise_data->ad, value, data.data, data.len)) { + bt_shell_printf("Failed to add data\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + cmd_ad_show(argc, argv); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_scan_rsp_name(int argc, char **argv) +{ + if (argc < 2) { + cmd_ad_show(argc, argv); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + if (!bt_ad_add_name(advertise_data->scan, argv[1])) { + bt_shell_printf("Failed to add local name\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + cmd_ad_show(argc, argv); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void ad_clear_name(void) +{ + bt_ad_clear_name(advertise_data->ad); +} + +static void ad_clear_appearance(void) +{ + bt_ad_clear_appearance(advertise_data->ad); +} + +static void ad_clear_uuids(void) +{ + bt_ad_clear_service_uuid(advertise_data->ad); +} + +static void ad_clear_manufacturer(void) +{ + bt_ad_clear_manufacturer_data(advertise_data->ad); +} + +static void ad_clear_solicit(void) +{ + bt_ad_clear_solicit_uuid(advertise_data->ad); +} + +static void ad_clear_service(void) +{ + bt_ad_clear_service_data(advertise_data->ad); +} + +static void ad_clear_data(void) +{ + bt_ad_clear_data(advertise_data->ad); +} + +static void ad_clear_scan_rsp(void) +{ + bt_ad_clear_name(advertise_data->scan); +} + +static void ad_clear_all(void) +{ + ad_clear_name(); + ad_clear_appearance(); + ad_clear_uuids(); + ad_clear_manufacturer(); + ad_clear_solicit(); + ad_clear_service(); + ad_clear_data(); + ad_clear_scan_rsp(); +} + +static const struct name_func_entry ad_clear_entry_table[] = { + { "name", ad_clear_name }, + { "appearance", ad_clear_appearance }, + { "uuids", ad_clear_uuids }, + { "manufacturer", ad_clear_manufacturer }, + { "solicit", ad_clear_solicit }, + { "service", ad_clear_service }, + { "data", ad_clear_data }, + { "scan-rsp", ad_clear_scan_rsp }, + { "all", ad_clear_all }, + { } +}; + +static void cmd_ad_clear(int argc, char **argv) +{ + const struct name_func_entry *entry; + + if (argc < 2) { + ad_clear_all(); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + for (entry = ad_clear_entry_table; entry && entry->name; entry++) { + if (!strcmp(entry->name, argv[1])) { + entry->func(); + goto done; + } + } + + bt_shell_printf("Invalid argument: %s\n", argv[1]); + + return bt_shell_noninteractive_quit(EXIT_FAILURE); +done: + cmd_ad_show(argc, argv); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static char *ad_clear_gen(const char *text, int state) +{ + return argument_gen_name_func_entry(text, state, ad_clear_entry_table); +} + +static const struct bt_shell_menu ad_menu = { + .name = "ad", + .desc = "Advertise Options Submenu", + .entries = { + { "show", NULL, + cmd_ad_show, "Show current saved advertise data" }, + { "name", "[name]", + cmd_ad_name, "Set/Get the local name" }, + { "appearance", "[value]", + cmd_ad_appearance, "Set/Get the appearance" }, + { "uuids", "[uuid ...]", + cmd_ad_uuids, "Set/Get advertise service uuids" }, + { "manufacturer", "[id] [data=xx xx ...]", + cmd_ad_manufacturer, "Set/Get manufacturer data" }, + { "solicit", "[uuid ...]", + cmd_ad_solicit, "Set/Get solicit uuids" }, + { "service", "[uuid] [data=xx xx ...]", + cmd_ad_service_data, "Set/Get service data" }, + { "data", "[type] [data=xx xx ...]", + cmd_ad_data, "Set/Get advertise data" }, + { "scan-rsp", "[name]", + cmd_scan_rsp_name, "Set/Get scan rsp data with name" }, + { "clear", "[all/name/appearance/uuids/...]", + cmd_ad_clear, "Clear advertise configuration", + ad_clear_gen }, + { } }, +}; + +static const struct bt_shell_menu gap_menu = { + .name = "gap", + .desc = "GAP API Submenu", + .entries = { + { "read-cmds", NULL, + cmd_gap_read_cmds, "Show supported commands" }, + { "list", NULL, + cmd_gap_read_index, "Show index of controllers" }, + { "read-info", "<index>", + cmd_gap_read_info, "Read controller information" }, + { "reset", NULL, + cmd_gap_reset, "Reset controller and stack" }, + { "power", "<on/off>", + cmd_gap_power, "Set controller power", + gap_on_off_gen }, + { "connectable", "<on/off>", + cmd_gap_connectable, "Set controller connectable", + gap_on_off_gen }, + { "fast-connectable", "<on/off>", + cmd_gap_fast_connectable, "Set controller fast connectable", + gap_on_off_gen }, + { "discoverable", "<on/off/limited>", + cmd_gap_discoverable, "Set controller discoverable", + gap_discoverable_gen }, + { "bondable", "<on/off>", + cmd_gap_bondable, "Set controller bondable", + gap_on_off_gen }, + { "start-adv", NULL, + cmd_gap_start_adv, "Start Advertising" }, + { "stop-adv", NULL, + cmd_gap_stop_adv, "Stop Advertising" }, + { "start-disc", "<flag ...>", + cmd_gap_start_disc, "Start discovery", + gap_start_disc_gen }, + { "stop-disc", NULL, + cmd_gap_stop_disc, "Stop discovery" }, + { "connect", "<type> <bdaddr>", + cmd_gap_connect, "Connect" }, + { "disconnect", "<type> <bdaddr>", + cmd_gap_disconnect, "Disconnect" }, + { "set-capa", "<io capability>", + cmd_gap_set_io_capa, "Set IO capability", + gap_io_capa_gen }, + { "pair", "<type> <bdaddr>", + cmd_gap_pair, "Pair" }, + { "unpair", "<type> <bdaddr>", + cmd_gap_unpair, "Unpair" }, + { } }, +}; + +static const struct bt_shell_menu main_menu = { + .name = "main", + .entries = { + { "read-cmds", NULL, + cmd_core_read_cmds, "Read supported commands" }, + { "read-services", NULL, + cmd_core_read_services, "Read supported services" }, + { "register", "<service_id>", + cmd_core_register_service, "Register service" }, + { "unregister", "<service_id>", + cmd_core_unregister_service, "Unregister service" }, + { "index", "<index>", + cmd_set_index, "Set controller index. Default is 0" }, + { } }, +}; + +static const struct option main_options[] = { + { "socket", required_argument, 0, 's' }, + { "dump ", required_argument, 0, 'd' }, + { 0, 0, 0, 0 } +}; + +static const char *socket_path_option; +static const char *dump_option; + +static const char **optargs[] = { + &socket_path_option, + &dump_option, +}; + +static const char *help[] = { + "Socket path to listen for BTP client\n", + "Use \"on\" to enable hex dump\n" +}; + +static const struct bt_shell_opt opt = { + .options = main_options, + .optno = sizeof(main_options) / sizeof(struct option), + .optstr = "s:d:", + .optarg = optargs, + .help = help, +}; + +int main(int argc, char *argv[]) +{ + int status; + int server_fd; + + bt_shell_init(argc, argv, &opt); + bt_shell_set_menu(&main_menu); + bt_shell_add_submenu(&ad_menu); + bt_shell_add_submenu(&gap_menu); + + btpclientctl = new0(struct btpclientctl, 1); + if (!btpclientctl) { + bt_shell_printf("Failed to allocate btpclientctl\n"); + status = EXIT_FAILURE; + goto error_exit; + } + + if (socket_path_option) + btpclientctl->socket_path = strdup(socket_path_option); + else + btpclientctl->socket_path = strdup(DEFAULT_SOCKET_PATH); + + if (dump_option && !strcasecmp(dump_option, "on")) + btpclientctl->enable_dump = true; + else + btpclientctl->enable_dump = false; + + advertise_data = new0(struct advertise_data, 1); + if (!advertise_data) { + status = EXIT_FAILURE; + goto error_free_clientctl; + } + + advertise_data->ad = bt_ad_new(); + if (!advertise_data->ad) { + status = EXIT_FAILURE; + goto error_free_advertise_data; + } + + advertise_data->scan = bt_ad_new(); + if (!advertise_data->scan) { + status = EXIT_FAILURE; + goto error_free_ad; + } + + bt_shell_attach(fileno(stdin)); + + server_fd = open_socket(btpclientctl->socket_path); + if (server_fd < 0) { + status = EXIT_FAILURE; + goto error_free_scan; + } + + btpclientctl->server_fd = server_fd; + + mainloop_add_fd(btpclientctl->server_fd, EPOLLIN, server_callback, + btpclientctl, NULL); + + bt_shell_set_prompt(PROMPT_ON); + + status = bt_shell_run(); + + close(btpclientctl->server_fd); +error_free_scan: + bt_ad_unref(advertise_data->scan); +error_free_ad: + bt_ad_unref(advertise_data->ad); +error_free_advertise_data: + free(advertise_data); +error_free_clientctl: + free(btpclientctl->socket_path); + free(btpclientctl); +error_exit: + return status; +} -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +MFwOX2cSV/ohgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 29 Aug 2020 02:08:29 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8AkKOH2cSV/dmwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 29 Aug 2020 02:08:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 134E8420DC; Sat, 29 Aug 2020 02:08:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726838AbgH2AIN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 20:08:13 -0400 Received: from mga12.intel.com ([192.55.52.136]:10238 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbgH2AIN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 20:08:13 -0400 IronPort-SDR: +3AiurOMES0StYhdXY92G4lc45OSGPiyFlOK7ZOPVjDIbTdSlyP4IccTrjoAdhC/57STOHu9GO y3VfdCLkLZzQ== X-IronPort-AV: E=McAfee;i="6000,8403,9727"; a="136305340" X-IronPort-AV: E=Sophos;i="5.76,365,1592895600"; d="scan'208";a="136305340" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 17:08:10 -0700 IronPort-SDR: u3ZMtn9vWPBh2CQBL+QGtO5w2pQBE3pydhi65ie1KoeleRTLAatETACP2uI1N6ZJv4EBvCwMr6 6tZ79QYECgvg== X-IronPort-AV: E=Sophos;i="5.76,365,1592895600"; d="scan'208";a="324213880" Received: from asmit14x-mobl1.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.83.187]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 17:08:10 -0700 From: tedd.an@intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [V3 3/3] btpclient: Fix gap reset not sending response Date: Fri, 28 Aug 2020 17:08:03 -0700 Message-Id: <20200829000803.20286-3-tedd.an@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200829000803.20286-1-tedd.an@intel.com> References: <20200829000803.20286-1-tedd.an@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 134E8420DC X-Rspamd-UID: 9663d5 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch fixes the GAP reset command to response the default settings after resetting the stack. --- tools/btpclient.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tools/btpclient.c b/tools/btpclient.c index f9c693056..38e326670 100644 --- a/tools/btpclient.c +++ b/tools/btpclient.c @@ -521,6 +521,19 @@ static void reset_unreg_agent_reply(struct l_dbus_proxy *proxy, ag.registered = false; } +static void update_current_settings(struct btp_adapter *adapter, + uint32_t new_settings) +{ + struct btp_new_settings_ev ev; + + adapter->current_settings = new_settings; + + ev.current_settings = L_CPU_TO_LE32(adapter->current_settings); + + btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_NEW_SETTINGS, adapter->index, + sizeof(ev), &ev); +} + static void btp_gap_reset(uint8_t index, const void *param, uint16_t length, void *user_data) { @@ -528,6 +541,7 @@ static void btp_gap_reset(uint8_t index, const void *param, uint16_t length, const struct l_queue_entry *entry; uint8_t status; bool prop; + uint32_t default_settings; if (!adapter) { status = BTP_ERROR_INVALID_INDEX; @@ -570,10 +584,13 @@ static void btp_gap_reset(uint8_t index, const void *param, uint16_t length, goto failed; } - adapter->current_settings = adapter->default_settings; + default_settings = adapter->default_settings; + + update_current_settings(adapter, default_settings); /* TODO for we assume all went well */ - btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_RESET, index, 0, NULL); + btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_RESET, index, + sizeof(default_settings), &default_settings); return; failed: @@ -644,19 +661,6 @@ failed: btp_send_error(btp, BTP_GAP_SERVICE, index, status); } -static void update_current_settings(struct btp_adapter *adapter, - uint32_t new_settings) -{ - struct btp_new_settings_ev ev; - - adapter->current_settings = new_settings; - - ev.current_settings = L_CPU_TO_LE32(adapter->current_settings); - - btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_NEW_SETTINGS, adapter->index, - sizeof(ev), &ev); -} - static void btp_gap_set_connectable(uint8_t index, const void *param, uint16_t length, void *user_data) { -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gKilJy2iSV9QoAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 29 Aug 2020 02:32:45 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id mI0dJi2iSV9jZgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 29 Aug 2020 02:32:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8B85AA1751; Sat, 29 Aug 2020 02:32:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726881AbgH2Aci (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 20:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726775AbgH2Ace (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 20:32:34 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C7D3C061264 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 17:32:34 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id k18so910742qtm.10 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 17:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=uuWrZLWtxSYZkUAFWX/NXCbA/WuZosou4t8w9PL8goA=; b=tQAFJl3OM64q/BMHstnMGbD3XkE7fRmXbvJ68Jd1Y5uE7vQoGoIF6c08cuMtiuipVY R1J9ZhFZYmEXdRP+4iA5iEY/Lc0Ayd3eApJvR0++h/GPQ1b1NWNBjZI7xeaGAJqQRk0q +ZCvvL2jJA5luj5yqkoBVw4BMbwam1SICUQEWqMneTNom3EeKaDuaDNcHoDiy4BN6QTt +WJo3hQ7SkhwlqYNvNBS4AeIH9IvAQnW9YFradRgeBRci99IwQ/7GvYKd9tOCk01uyrG pFAgDkgBMG6pNQJ4kQjNkEnNZZCEytDEX1KVM2THiyR+nvEZSukyCMIzmv6Qxf0O8l1V OW7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=uuWrZLWtxSYZkUAFWX/NXCbA/WuZosou4t8w9PL8goA=; b=Y6zdiFONdyfplyWm+V091+BqzNo/2bY9/ZdKxC+pzSOS2upAjWqy3Udd0ry/2G3cRM G7kafmKhAcZw58euAo5auo5h6n9pEnkdtEMgygyRBFKpuQHJuX5Ud8vsCMnraepCMH6x +5cm//u4bKuzd1eDqzA3SYYCzbeOEdvtRSknaTSHSM8/ql7QBmiiinmzbIYjnq0oy0Y9 rwTHIq/zHE8OkhnSQLsOoO4zHO84CeITzsrvWW2I49gmW40mDbbXKNC+w9nVLa3+k141 i4Mr/66WnWhwf+rP9MfocZIBAX29StMf5ALwyMlsyOB43p0GNf31iJVxp8jmJqJrHEF4 KHWg== X-Gm-Message-State: AOAM531y0yJJ+/m2exjAYv1QZnPAtVVOC/wf/CBa4meve8AflyD54PZi jUobPihoAy3RgA2tYdYt56CGtJlUbIf7dQ== X-Google-Smtp-Source: ABdhPJxk5v5VWzUKpx2QZ2Flz9cPXnxZ9urV4CTvOZPhfMmmCGDsBiswsQEZRMl6lS0mWKiFyEWc4w== X-Received: by 2002:ac8:c0e:: with SMTP id k14mr4171818qti.364.1598661152242; Fri, 28 Aug 2020 17:32:32 -0700 (PDT) Received: from [172.17.0.2] ([20.36.205.85]) by smtp.gmail.com with ESMTPSA id v13sm753810qti.64.2020.08.28.17.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 17:32:31 -0700 (PDT) Message-ID: <5f49a21f.1c69fb81.5e874.40a8@mx.google.com> Date: Fri, 28 Aug 2020 17:32:31 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3323347324394065462==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, tedd.an@intel.com Subject: RE: [V3,2/3] tools/btpclientctl: Add btpclient test application Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200829000803.20286-2-tedd.an@intel.com> References: <20200829000803.20286-2-tedd.an@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.72 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8B85AA1751 X-Rspamd-UID: 52b968 --===============3323347324394065462== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #48: FILE: tools/btpclientctl.c:1: +/* ERROR:FSF_MAILING_ADDRESS: Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. #66: FILE: tools/btpclientctl.c:19: + * along with this program; if not, write to the Free Software$ ERROR:FSF_MAILING_ADDRESS: Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. #67: FILE: tools/btpclientctl.c:20: + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA$ WARNING:TYPO_SPELLING: 'arguement' may be misspelled - perhaps 'argument'? #207: FILE: tools/btpclientctl.c:160: + bt_shell_printf("Invalid arguement %s\n", argv[1]); WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const #2332: FILE: tools/btpclientctl.c:2285: +static const char *help[] = { - total: 2 errors, 3 warnings, 2395 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============3323347324394065462==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qHZ1ICipSV/UuAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 29 Aug 2020 03:02:32 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EK/WHiipSV8F+gAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 29 Aug 2020 03:02:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7B7F740732; Sat, 29 Aug 2020 03:02:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726446AbgH2BCZ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 21:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbgH2BCT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 21:02:19 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91DF0C061264 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 18:02:19 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id ls14so326398pjb.3 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 18:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3xXRDB2sGPzoGqKOB+6TwO7ShGY5615JtErKHfxz8fk=; b=J//h6N7GjrFtY2260Hs1jViiPMfa9CkX6rEyGHVXoAzr2/ByhHU4ruyy1eUbKUQVnZ pvV5LRMRoC4f9xx4Yw+M4g7zgVgtBPpqpbp80xgkHsUt37xeGn5xaiFcUzSOfqBoGn4F yiEZk6JnQJ5R2rn4J9yOUMV8M78plctwY+Er4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3xXRDB2sGPzoGqKOB+6TwO7ShGY5615JtErKHfxz8fk=; b=StYjNdr4/2g84FdX4crv7bnzHgkYLs2u89SCnIh7rPkqmjxXvnGAF3RntMDr9TL85t rSegutqpJFDJ6F0DIF18ZuxMWsAF886PQqpxLVqAKCiwk/SLTfItPtdAc2cPor/n9otP eBIpYHfJwKwj/+bXYFmN1fVQxM8YSZQBsUrNTqQ5uyruXruem+3KIe9NKvbMg8EM+YIH 8jlloGG/pjNd2OfaDFNByJXP0Cmej324b6jE66lGTy81GstcntiUHhBcVG4ZGnKvpPYM JHea4k6lVqsFKc0MCWhClnbRG3C0djLCiSkO9akbP2A9o93GvisGccAANMYFDu293Mzv XRWg== X-Gm-Message-State: AOAM530nv+7rMkJah9A87ZbCfAC0dAaWrndzc2IKLC9Ih3cFNbgeT1Ti bjmH22/8m4r2aBbkKsqdzmx9z8aelXL3sA== X-Google-Smtp-Source: ABdhPJwNSjzZME0Uxua5lrWAjcNhkGmnvFct4vFvYBJV+jN0jDBnr6vTVdlN6ZSeGmiRa9BYkyexJg== X-Received: by 2002:a17:902:d88c:: with SMTP id b12mr594759plz.96.1598662938763; Fri, 28 Aug 2020 18:02:18 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 78sm630360pfv.200.2020.08.28.18.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 18:02:18 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Subject: [Bluez PATCH v3 1/3] mgmt: Add controller suspend and resume events Date: Fri, 28 Aug 2020 18:02:08 -0700 Message-Id: <20200828180157.Bluez.v3.1.I14a96397d181666c124e1c413b834428faf3db7a@changeid> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog In-Reply-To: <20200829010210.871471-1-abhishekpandit@chromium.org> References: <20200829010210.871471-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.47 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7B7F740732 X-Rspamd-UID: 894979 Add the controller suspend and resume events. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- Changes in v3: None Changes in v2: None lib/mgmt.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index a800bcab4..46d894ae9 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -772,6 +772,7 @@ struct mgmt_ev_device_connected { #define MGMT_DEV_DISCONN_TIMEOUT 0x01 #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 #define MGMT_DEV_DISCONN_REMOTE 0x03 +#define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND 0x05 #define MGMT_EV_DEVICE_DISCONNECTED 0x000C struct mgmt_ev_device_disconnected { @@ -959,6 +960,17 @@ struct mgmt_ev_adv_monitor_removed { uint16_t monitor_handle; } __packed; +#define MGMT_EV_CONTROLLER_SUSPEND 0x002d +struct mgmt_ev_controller_suspend { + uint8_t suspend_state; +} __packed; + +#define MGMT_EV_CONTROLLER_RESUME 0x002e +struct mgmt_ev_controller_resume { + struct mgmt_addr_info addr; + uint8_t wake_reason; +} __packed; + static const char *mgmt_op[] = { "<0x0000>", "Read Version", @@ -1088,6 +1100,8 @@ static const char *mgmt_ev[] = { "Device Flags Changed", "Advertisement Monitor Added", /* 0x002b */ "Advertisement Monitor Removed", + "Controller Suspend", + "Controller Resume", }; static const char *mgmt_status[] = { -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qOdUES6pSV/UuAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 29 Aug 2020 03:02:38 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mETIDy6pSV8F+gAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 29 Aug 2020 03:02:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A044C420C1; Sat, 29 Aug 2020 03:02:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726452AbgH2BC0 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 21:02:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbgH2BCT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 21:02:19 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AE28C06121B for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 18:02:19 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id c15so436250plq.4 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 18:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WzMgBr6hhvcDtrhfuNfDzhOG8Bse/af+dPFv5Ba8Gf8=; b=Vl4Id8eUvBWQPvZxBRw3tOc30eVeXWsHO8ttewO4X+HcoSKG9IzlHLa/fZwUychnRI KNQcdaDkblXk7BdXi1ufKelVB0L1hXPn72U35pYeDelIlCZ2elLeevOJtzfW4EHSA63d Nxd/20OEFE8zn30iw9Rq2FPoptMbsjXrwLO84= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WzMgBr6hhvcDtrhfuNfDzhOG8Bse/af+dPFv5Ba8Gf8=; b=DguL6BMAFAoAN7Vz4q16X4y2GxkUXATAneOOuxBdGJv4Rh78n3DbhweHT4CQNASiY9 2zAlEiaFDGENCtAi987V47r5fF1De4G8kYHZ3XRmrmejDICapu6pH4gfJLpnDMq94nKH 3jDiJV/Mkr5uFRkz4nGL5NXwz9XMKi2lsTVUwIfKYiaIRX4FwOSKl7lI5PFhAPvUsf5H yUeCQcvp8899kbCdlWtwmy51sQKV/0aBFvbOZqiyp1ZgcqpiMPkeNZgSP4H+Lk67zlnX 8Lz1D1KmgcXch58e4ZzjHXIGxW1IyAU91vyEuq6/WrqmTqOFrNFwv3lxj+KoPTL4hWHA Lm1A== X-Gm-Message-State: AOAM533QNOoggyl+VXCz6hhrXXv/vaUEHCB1LZo1KtSf5NP5WafophXk MpK7H9MJDXKqn67fUhjlZTl3QA== X-Google-Smtp-Source: ABdhPJxZMqSLax2XaL6lF0cIkKzf8NWqAFCsuGtvT40baW+lGqSwnWdPCzuZWTu72/IwZAP2te5Djg== X-Received: by 2002:a17:90b:194d:: with SMTP id nk13mr1353192pjb.92.1598662937746; Fri, 28 Aug 2020 18:02:17 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 78sm630360pfv.200.2020.08.28.18.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 18:02:16 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v3 0/3] adapter: Reconnect audio when resuming from suspend Date: Fri, 28 Aug 2020 18:02:07 -0700 Message-Id: <20200829010210.871471-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 4.97 / 15.00 / 200.00 X-Rspamd-Queue-Id: A044C420C1 X-Rspamd-UID: cd0c85 Hi Luiz and Marcel, This is a quality of life improvement for the behavior of audio devices during system suspend. This depends on a kernel change that emits suspend/resume events: https://patchwork.kernel.org/project/bluetooth/list/?series=325771 Right now, audio devices will be disconnected as part of suspend but won't be reconnected when the system resumes without user interaction. This is annoying to some users as it causes an interruption to their normal work flow. This change reconnects audio devices that were disconnected for suspend using the following logic: * In the device disconnect callback, mark any devices with the A2DP service uuid for reconnect. The reconnect will not be queued until resume. * In the controller resume callback, queue any policy items that are marked to reconnect on resume for connection with the ResumeDelay value (default = 2s). A reconnect is queued after the controller resumes and the delay between resume and reconnect is configurable via the ResumeDelay key in the Policy settings. The 2s delay was chosen arbitrarily and I think anywhere up to 10s is probably ok. A longer delay is better to account for spurious wakeups and Wi-Fi reconnection time (avoiding any co-ex issues) at the downside of reconnection speed. Here are the tests I have done with this: - Single suspend and verified the headphones reconnect - Suspend stress test for 25 iterations and verify both Wi-Fi and Bluetooth audio reconnect on resume. (Ran with wake minimum time of 10s) - Suspend test with wake time = 1s to verify that BT reconnect isn't attempted. Ran 5 iterations with low wake time and then let it stay awake to confirm reconnect finally completed on last resume. - Suspend test with wake time between 1s - 4s. Ran with 5 iterations and verified it connected several times in the middle and finally at the end. I've tested this on a Pixelbook Go (AC-9260 controller) and HP Chromebook 14a (RTL8822CE controller) with GID6B headset. I've also tested this with the Pixel Buds 2. These earbuds actually reconnect automatically to the Chromebook (even without this policy change) and I verified that the new changes don't break the reconnection mechanism. Thanks Abhishek Changes in v3: - Refactored resume notification to use btd_adapter_driver - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 - Added A2DP_SINK_UUID to default reconnect list Changes in v2: - Refactored to use policy instead of connecting directly in adapter Abhishek Pandit-Subedi (3): mgmt: Add controller suspend and resume events monitor: Add btmon support for Suspend and Resume events policy: Reconnect audio on controller resume lib/mgmt.h | 14 +++++++++ monitor/packet.c | 55 +++++++++++++++++++++++++++++++++ plugins/policy.c | 80 +++++++++++++++++++++++++++++++++++++++--------- src/adapter.c | 36 ++++++++++++++++++++++ src/adapter.h | 2 ++ src/main.c | 1 + src/main.conf | 11 ++++++- 7 files changed, 184 insertions(+), 15 deletions(-) -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wK5wNDOpSV/UuAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 29 Aug 2020 03:02:43 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id COmaMjOpSV/jpwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 29 Aug 2020 03:02:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B7BE7420C4; Sat, 29 Aug 2020 03:02:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726395AbgH2BCa (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 28 Aug 2020 21:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726418AbgH2BCW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 28 Aug 2020 21:02:22 -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 C4EE0C061232 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 18:02:21 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id p15so431301pli.6 for <linux-bluetooth@vger.kernel.org>; Fri, 28 Aug 2020 18:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qCwx0WjM+Tg/OUIJ0l+mpEQceJ2qn7yAxNpmvP8bdS0=; b=h8nYGDaFfEGx5g99mTM6U/CtMtRrpaRC0JKHy1KTPJ5AZCnQcb9uvAB8aIHfyWbbLX ws2b/ATWLNCPLq9/6zQaZHCBlBNI0Y+v1QlPI/ZtZPMFEqBrh5aFCPpRt8s7LCrvI9QH PCX0Gp2Ycg6FRjliqdKkBYAA5rlL3t4ZwLDXQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qCwx0WjM+Tg/OUIJ0l+mpEQceJ2qn7yAxNpmvP8bdS0=; b=rMSYsEZjCwHzXMDJBZ+oFQzOyER6zd8bsxJZttrMI3HAYYvWerdGnoPmjanCEj9XQy 5VfC0fagHxmcQtlazRunR4DmEaoiUFPTAHPuwuH/LVi4YhVph8No/lCJiiOcPqtCmyis Pg1TJnLtBl8nLZjy+A6dv9qDKfjU4RKt5FZp2yTSD7GORG21PVhGWlsAsscPITdfzmLQ 8ZIqKZ6wcTIVhf7fW1CROk7/zUeyZ7lCjEnseGEJL3KpVAI7xjFmpnPx4+K1Z2f3DZBn TfBsi5epihpbU9ri4QvjEBVMyVW0MJrerom8AZkiyhW/S+y8DTe9OjL9la3BUaEAtxpd pV6A== X-Gm-Message-State: AOAM530AlD+ijEE1QiPxXTMJTskMlw2gENF9KaivPriu31d/T9Ux9iVG XBTTlVmRE8LAnSMkbIaL4Sx0GQ== X-Google-Smtp-Source: ABdhPJxp31rxPdZ7f51B3qg3IoieSzyWo5PQRAG9BHSnCS2oHPHFS3gKXjcsP7gro8npPLhJoyHvvg== X-Received: by 2002:a17:90a:b00e:: with SMTP id x14mr1232309pjq.203.1598662939741; Fri, 28 Aug 2020 18:02:19 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 78sm630360pfv.200.2020.08.28.18.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 18:02:19 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [Bluez PATCH v3 2/3] monitor: Add btmon support for Suspend and Resume events Date: Fri, 28 Aug 2020 18:02:09 -0700 Message-Id: <20200828180157.Bluez.v3.2.Id78b98210807c1326ee2c187af73a325fc97f1e1@changeid> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog In-Reply-To: <20200829010210.871471-1-abhishekpandit@chromium.org> References: <20200829010210.871471-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.47 / 15.00 / 200.00 X-Rspamd-Queue-Id: B7BE7420C4 X-Rspamd-UID: 3885a1 Add support to pretty print Suspend and Resume mgmt events in btmon. Example: @ MGMT Event: Controller Suspended (0x002d) plen 1 Suspend state: Page scanning and/or passive scanning (2) @ MGMT Event: Controller Resumed (0x002e) plen 8 Wake reason: Remote wake due to peer device connection (2) LE Address: CD:F3:CD:13:C5:9A (OUI CD-F3-CD) Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Changes in v3: None Changes in v2: None monitor/packet.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 431a39b66..451630e04 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -13555,6 +13555,9 @@ static void mgmt_device_disconnected_evt(const void *data, uint16_t size) case 0x04: str = "Connection terminated due to authentication failure"; break; + case 0x05: + str = "Connection terminated by local host for suspend"; + break; default: str = "Reserved"; break; @@ -13782,6 +13785,54 @@ static void mgmt_device_flags_changed_evt(const void *data, uint16_t size) mgmt_print_added_device_flags("Current Flags", current_flags); } +static void mgmt_controller_suspend_evt(const void *data, uint16_t size) +{ + uint8_t state = get_u8(data); + char *str; + + switch (state) { + case 0x0: + str = "Controller running (failed to suspend)"; + break; + case 0x1: + str = "Disconnected and not scanning"; + break; + case 0x2: + str = "Page scanning and/or passive scanning"; + break; + default: + str = "Unknown suspend state"; + break; + } + + print_field("Suspend state: %s (%d)", str, state); +} + +static void mgmt_controller_resume_evt(const void *data, uint16_t size) +{ + uint8_t addr_type = get_u8(data + 6); + uint8_t wake_reason = get_u8(data + 7); + char *str; + + switch (wake_reason) { + case 0x0: + str = "Resume from non-Bluetooth wake source"; + break; + case 0x1: + str = "Wake due to unexpected event"; + break; + case 0x2: + str = "Remote wake due to peer device connection"; + break; + default: + str = "Unknown wake reason"; + break; + } + + print_field("Wake reason: %s (%d)", str, wake_reason); + mgmt_print_address(data, addr_type); +} + static const struct mgmt_data mgmt_event_table[] = { { 0x0001, "Command Complete", mgmt_command_complete_evt, 3, false }, @@ -13863,6 +13914,10 @@ static const struct mgmt_data mgmt_event_table[] = { mgmt_exp_feature_changed_evt, 20, true }, { 0x002a, "Device Flags Changed", mgmt_device_flags_changed_evt, 15, true }, + { 0x002d, "Controller Suspended", + mgmt_controller_suspend_evt, 1, true }, + { 0x002e, "Controller Resumed", + mgmt_controller_resume_evt, 8, true }, { } }; -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oJyuKDRRS1+v8gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 30 Aug 2020 09:11:48 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id wHM2JzRRS18OOQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 30 Aug 2020 09:11:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A1867420C9; Sun, 30 Aug 2020 09:11:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726657AbgH3HLf (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 30 Aug 2020 03:11:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbgH3HL0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 30 Aug 2020 03:11:26 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB07BC061573 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 00:11:25 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id w5so2904373wrp.8 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 00:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/ehZDFISSLHPOT/cvMww/3eQrFijdzTCQp0NJi7pzv0=; b=Zf1Dz954a6HkbYPcqQOnZ1aq8bpxtHGD2j1lYEKVMWd6G6YgQgtMD7scbqh49ewxIn ZFDN2wA2mqSNT51mAH2+3/j0K3LQFyF/LTJb/g99D3kwoYwobufVy+iUd9TlplIRlxal 9HR6Lx0GOEgXtMN1Kg1eNvY4Yo6hPr/EcPio30lA+nDwPuWqdMaCW3LJRW+rjbIdEo5G IitdRYZfyBo/gR/EgzoLoH04dNIbYfwJZehVqoJ5pP2PPwODkAGylums33xRhz7tyijh 92YRkWzpJUUW19f9aOX8ZtlaBlfWYODEkVNooD4NeduE4h9UzzkX1oOVFW+xfAYR4Es2 +HSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/ehZDFISSLHPOT/cvMww/3eQrFijdzTCQp0NJi7pzv0=; b=H32KVgREna4JdTMNZue/tyZQ139e0Ajg5iRAUAoN87EQWYXUXm8F3jMMA9BPLXSPRU StWbyf0asfXL99/w3O8wrkZlg8ZPcF3ZpgRBTsVFFnKkLh++QSoBhrnyGrueYwtot4iV JELK7TMv7+q22P2IYOUBc++fryzYuVlArtrk9d4T8bqd48z1tFCaUD/STD+Qu/YyuMbO DAFXS0MXCZa7ZXdTSBtCX6+y9jZ+FD9wQhNZ1T0roINET/S3SKRMVLkDBMmcVjcpryqk kXRfTTjgBZGlNNH+GRD9iCcJSr0WWRo77VujzoInIgKP7OF5fWm3GVhJd1Snd4LUB3KE Z7kw== X-Gm-Message-State: AOAM530rAQApK+W9nuKTw+xdfuKNEUQ9pLA4NgxHgegBXaMn9UlPb65E chXStp1yJpC88e0OXmt2lSR9868daEk= X-Google-Smtp-Source: ABdhPJzUT+MKgSR9ysGC0LecFZo1aT7NXO+YZEcYZ20Ga0IRDpvG6eELIPkUehm0g3WTuigqgWvtAw== X-Received: by 2002:adf:e58b:: with SMTP id l11mr4270631wrm.210.1598771481256; Sun, 30 Aug 2020 00:11:21 -0700 (PDT) Received: from thinkabit1.lan (21.81.7.51.dyn.plus.net. [51.7.81.21]) by smtp.gmail.com with ESMTPSA id h185sm5197859wme.25.2020.08.30.00.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 00:11:20 -0700 (PDT) From: Barry Byford <31baz66@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Barry Byford <31baz66@gmail.com> Subject: [PATCH BlueZ 0/1] Fix small typo in bluetoothctl Date: Sun, 30 Aug 2020 08:11:07 +0100 Message-Id: <20200830071108.19777-1-31baz66@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.55 / 15.00 / 200.00 X-Rspamd-Queue-Id: A1867420C9 X-Rspamd-UID: 667271 Changing apperance to be appearance Barry Byford (1): Fix typo in bluetoothctl client/advertising.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wKxVAUBRS1+v8gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 30 Aug 2020 09:12:00 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id cKYSOz9RS18BPwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 30 Aug 2020 09:11:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2F865420C3; Sun, 30 Aug 2020 09:11:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726960AbgH3HLl (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 30 Aug 2020 03:11:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726629AbgH3HLf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 30 Aug 2020 03:11:35 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3237CC061573 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 00:11:34 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id a17so2060132wrn.6 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 00:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iCdC5l7MREtg/ugmoGf85Z2/cwwaQHZeoBGEOMxfvgc=; b=Tr+rVnkg4t7qOxr7VdTQIopxqLZyAasAg3WSVd30+jEG5nHBq2wj/KGYaaIzUXgdeA JgTs7s3eyax/jGBSXkkcVNsdHPv5OJD6P6vrYU3Y4DkIjxgm6BhTwwNLtOF4ZSjOrEG4 P1DDs2qB7U+9x63+LW6/ZYQPRhe+SswUvJpYLjrmFOYNouUV1s2D8UT+irTw2iBVwXU1 FHgkQxcaf/fTJR5gZsZpezet6J142IVZGOLrxBy46+55jZL/K1ZSYLcpoOijHIxGEacR paNHEKszsJ9WD7WE3Tmyhl5JwKarWCkE8J12jUSMROoCfamo/QfQKKPyA0RmOi7pMVnJ jmMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iCdC5l7MREtg/ugmoGf85Z2/cwwaQHZeoBGEOMxfvgc=; b=oDjAdwbmbTydlT2vbmV4EP9Ho/DNRczwvtL7a5ES/acHS3jp8YN/AHsTcgRQRdARgS HdtEReAljMTIKPfwE3ciisgWbg0FHJnYx9YpE4+pgXnHjR41h8laO/2Zt/EZteEOCkTn uz/P5lmzop0Kp+3t7uCED62nwHS9VojZoMbWE6iWa11rw8qp6UuS8bmIJ4Tsd2M46crI BJ8TdoLwu8tlzuHtrxSAT0j+uAxzRYbCjIMVaV+tL125tW40Meld/zq3beSB1MuBsvRQ +9l9MUneMFvEy/geCFI6BdOtDGtZxOn2ITmWYG4cJW8UkcWgLGuL9kqZ0ImvyyGf6gql sSqA== X-Gm-Message-State: AOAM5315N6S2Iwni7D1Ud6y3VhBy5pHkcEchVL/tZaUIbC6uu1n6oOcQ x8os0CJtxHJ5sOwwUP08DCyrG77JMiA= X-Google-Smtp-Source: ABdhPJzkZCrC/TulrKpkoBpTnlokBgyq2VvG0wu643WMfA1aQirRg9AHhBwhumeBZG/SfWbUekgWZQ== X-Received: by 2002:adf:e504:: with SMTP id j4mr6468060wrm.205.1598771490976; Sun, 30 Aug 2020 00:11:30 -0700 (PDT) Received: from thinkabit1.lan (21.81.7.51.dyn.plus.net. [51.7.81.21]) by smtp.gmail.com with ESMTPSA id h185sm5197859wme.25.2020.08.30.00.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 00:11:30 -0700 (PDT) From: Barry Byford <31baz66@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Barry Byford <31baz66@gmail.com> Subject: [PATCH BlueZ 1/1] Fix typo in bluetoothctl Date: Sun, 30 Aug 2020 08:11:08 +0100 Message-Id: <20200830071108.19777-2-31baz66@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200830071108.19777-1-31baz66@gmail.com> References: <20200830071108.19777-1-31baz66@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.76 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2F865420C3 X-Rspamd-UID: 5b39e1 --- client/advertising.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/advertising.c b/client/advertising.c index 94eb616b2..1aa28e749 100644 --- a/client/advertising.c +++ b/client/advertising.c @@ -185,7 +185,7 @@ static void print_ad(void) bt_appear_to_str(ad.local_appearance), ad.local_appearance); else - bt_shell_printf("Apperance: %s\n", + bt_shell_printf("Appearance: %s\n", ad.appearance ? "on" : "off"); bt_shell_printf("Discoverable: %s\n", ad.discoverable ? "on": "off"); @@ -886,7 +886,7 @@ void ad_advertise_local_appearance(DBusConnection *conn, long int *value) bt_appear_to_str(ad.local_appearance), ad.local_appearance); else - bt_shell_printf("Apperance: %s\n", + bt_shell_printf("Appearance: %s\n", ad.appearance ? "on" : "off"); return bt_shell_noninteractive_quit(EXIT_SUCCESS); -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YMHYLeBuS1+BgwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 30 Aug 2020 11:18:24 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id QDqpLOBuS18ocAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 30 Aug 2020 11:18:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 725A8420BF; Sun, 30 Aug 2020 11:18:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726493AbgH3JSN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 30 Aug 2020 05:18:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:34726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbgH3JSK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 30 Aug 2020 05:18:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0ACFF20714; Sun, 30 Aug 2020 09:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598779090; bh=4gJ7NN/H4ONVbNKPoKOQktRZKpaRJ+juo2KX4MEgL04=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GzNpPawjHdJDC5Aqr+olvKQsVN5Tp+oHeiTDbaEpznDzXM7VF6OPu0I/vgyaBiXW8 IN/2wyT5EjS8UULRfqAVr518SJa/C5X07H756FOZQCsgxizKmRgdcm9gvJ/VxMa3Ts bE9UbT/OOZSFaI+CE3vYXRKRab9ClY4tS3figrtE= Date: Sun, 30 Aug 2020 11:18:08 +0200 From: Greg KH <gregkh@linuxfoundation.org> To: Anmol Karn <anmol.karan123@gmail.com> Cc: marcel@holtmann.org, johan.hedberg@gmail.com, netdev@vger.kernel.org, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, davem@davemloft.net Subject: Re: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer deref in hci_phy_link_complete_evt Message-ID: <20200830091808.GA122343@kroah.com> References: <20200829124112.227133-1-anmol.karan123@gmail.com> <20200829165712.229437-1-anmol.karan123@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200829165712.229437-1-anmol.karan123@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.14 / 15.00 / 200.00 X-Rspamd-Queue-Id: 725A8420BF X-Rspamd-UID: 5a437f On Sat, Aug 29, 2020 at 10:27:12PM +0530, Anmol Karn wrote: > Fix null pointer deref in hci_phy_link_complete_evt, there was no > checking there for the hcon->amp_mgr->l2cap_conn->hconn, and also > in hci_cmd_work, for hdev->sent_cmd. > > To fix this issue Add pointer checking in hci_cmd_work and > hci_phy_link_complete_evt. > [Linux-next-20200827] > > This patch corrected some mistakes from previous patch. So this is a v2? That should go below the --- line, right? And you should have a v2 in the subject line like the documentation asks? Can you redo this please? thanks, greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +IiLAiNvS1/opAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 30 Aug 2020 11:19:31 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gPHxACNvS1+ZtAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 30 Aug 2020 11:19:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E47A3420EB; Sun, 30 Aug 2020 11:19:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728736AbgH3JTU (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 30 Aug 2020 05:19:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:35048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbgH3JTT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 30 Aug 2020 05:19:19 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0BA7B20714; Sun, 30 Aug 2020 09:19:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598779159; bh=e2CkEznyGpjK37GjiF87TzHNHnfIBnUNctJ8uWQKXXM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nNoW5uMGuk930nrYwDxvhKucdfXCTUqfYPHcv2boWxibjqj7fY06U4WqDh4Inpe75 0NtVbdlzcP11m1XKOZDEBvQaTgWmOcAZI2nxjrqJwNihwqwWO97aCTKaYMbYKn4p1W jbraUucjy7oBpHOFj6fcfR8ZaUJUczz15FOWjuVc= Date: Sun, 30 Aug 2020 11:19:17 +0200 From: Greg KH <gregkh@linuxfoundation.org> To: Anmol Karn <anmol.karan123@gmail.com> Cc: marcel@holtmann.org, johan.hedberg@gmail.com, netdev@vger.kernel.org, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, davem@davemloft.net Subject: Re: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer deref in hci_phy_link_complete_evt Message-ID: <20200830091917.GB122343@kroah.com> References: <20200829124112.227133-1-anmol.karan123@gmail.com> <20200829165712.229437-1-anmol.karan123@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200829165712.229437-1-anmol.karan123@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.09 / 15.00 / 200.00 X-Rspamd-Queue-Id: E47A3420EB X-Rspamd-UID: 1a1aa6 On Sat, Aug 29, 2020 at 10:27:12PM +0530, Anmol Karn wrote: > Fix null pointer deref in hci_phy_link_complete_evt, there was no > checking there for the hcon->amp_mgr->l2cap_conn->hconn, and also > in hci_cmd_work, for hdev->sent_cmd. > > To fix this issue Add pointer checking in hci_cmd_work and > hci_phy_link_complete_evt. > [Linux-next-20200827] > > This patch corrected some mistakes from previous patch. > > Reported-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com > Link: https://syzkaller.appspot.com/bug?id=0d93140da5a82305a66a136af99b088b75177b99 > Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> > --- > net/bluetooth/hci_core.c | 5 ++++- > net/bluetooth/hci_event.c | 4 ++++ > 2 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index 68bfe57b6625..996efd654e7a 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -4922,7 +4922,10 @@ static void hci_cmd_work(struct work_struct *work) > > kfree_skb(hdev->sent_cmd); > > - hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); > + if (hdev->sent_cmd) { > + hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); > + } How can sent_cmd be NULL here? Are you sure something previous to this shouldn't be fixed instead? > + > if (hdev->sent_cmd) { > if (hci_req_status_pend(hdev)) > hci_dev_set_flag(hdev, HCI_CMD_PENDING); > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 4b7fc430793c..1e7d9bee9111 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -4941,6 +4941,10 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > hci_dev_unlock(hdev); > return; > } > + if (!(hcon->amp_mgr->l2cap_conn->hcon)) { > + hci_dev_unlock(hdev); > + return; > + } How can this be triggered? thanks, greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IGh+DcmUS19sSwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 30 Aug 2020 14:00:09 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id QDOFDMmUS1/M4AAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 30 Aug 2020 14:00:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6EA5DA1E24; Sun, 30 Aug 2020 14:00:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726430AbgH3L74 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 30 Aug 2020 07:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbgH3L7y (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 30 Aug 2020 07:59:54 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8507BC061573 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 04:59:54 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id i13so1661509pjv.0 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 04:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=zqFNKSuFAmeQvdRzqWYjl+KPxRmwQ0ADbz/kuXgPe7o=; b=m24aCiC4946C7cIh19AoGt0JPJM3gXIO3huwpkzE9Igc+6l2d1XgHNBGkin6AiiaWW xHDf/7tBIShgou0kSBJSDzcm6mef9h6hLavpPmgmu5EK3t/gUfPsbHeiwxFVGxwZLxS8 whs85+qqSDhiPsSFF7iTqxJr97682WyWrsAZ02YTyXcjVv7w7TrjTyBFedKJ/hqZ44LD iq9vD/lLOcoHvi2pbSx9hVBtebppeHWzyP4ul/qF4U9R7oPKv3av2Yig8H/4v1tI3ozM RXjo15bc1HtwnaFh1fGt6fmeTxUvZeqVXsas2p+xaSOnHSszjD0Uxv837xbEY+IWTAz2 sEqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=zqFNKSuFAmeQvdRzqWYjl+KPxRmwQ0ADbz/kuXgPe7o=; b=mK4IIVrphcH4sNlpBhoCdGKtfeJfgyEoIHrDogKTNoHB3u1UH4DtIpB07kCQIuGE6/ 8CNOJJ+l5cUOuS4H8xyRPRvf5TIIsRIOJZNIwDkiCBGAYOaABJNbnL1hEKUmrtIISWTD 6Hx4mpcHBfKstfae4crcPyT2BpH5PFWLwrskYOggRHVYkJQdXjJqeHfBYqUd/Gc5C3Zz KluIokSH5vTXGiWJ9rpwWeXr2o0QVjJRUwM5vsFzvkXU7EXG3cXu39edAMUnRfRK5YbW NihHdHIueLNSgK2Y6UtP48sOG0tZ1v1y9Fq7R1rvYlhd4oafxd9H35OSP13zg7joB2Se F1dQ== X-Gm-Message-State: AOAM532iH8bUIotHqjqV75cw5h8QyzX3QbmH5Thus3XL/Rph59WLRcGi Ocu1KkEZR5P2HDwK1n2RKiM1sQtKUIRfUbe2 X-Google-Smtp-Source: ABdhPJw4e4jRTE21odtj5BNqGsk51pV/ZO9MCzVABWtgbOtUrEF049pKCZoArVTYh4Hn6lf4XebT9A== X-Received: by 2002:a17:90b:4b89:: with SMTP id lr9mr6756783pjb.190.1598788793750; Sun, 30 Aug 2020 04:59:53 -0700 (PDT) Received: from ubuntu (210-65-47-79.HINET-IP.hinet.net. [210.65.47.79]) by smtp.gmail.com with ESMTPSA id q5sm5028986pfu.16.2020.08.30.04.59.52 for <linux-bluetooth@vger.kernel.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Aug 2020 04:59:52 -0700 (PDT) Date: Sun, 30 Aug 2020 04:59:48 -0700 From: zefang han <hanzefang@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] hcidump: fix a crash in le_meta_ev_dump() Message-ID: <20200830115948.GA9519@ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.50 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6EA5DA1E24 X-Rspamd-UID: 4ba2df --- tools/parser/hci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/parser/hci.c b/tools/parser/hci.c index 41f6fe087..e969d198c 100644 --- a/tools/parser/hci.c +++ b/tools/parser/hci.c @@ -3668,7 +3668,12 @@ static inline void le_meta_ev_dump(int level, struct frame *frm) frm->len -= EVT_LE_META_EVENT_SIZE; p_indent(level, frm); - printf("%s\n", ev_le_meta_str[subevent]); + + if(subevent > LE_EV_NUM){ + printf("Unknown\n"); + }else{ + printf("%s\n", ev_le_meta_str[subevent]); + } switch (mevt->subevent) { case EVT_LE_CONN_COMPLETE: -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +A94DJqaS1+MpAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 30 Aug 2020 14:24:58 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AGeYCpqaS1++QQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 30 Aug 2020 14:24:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8D6B541175; Sun, 30 Aug 2020 14:24:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728691AbgH3MYs (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 30 Aug 2020 08:24:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgH3MYm (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 30 Aug 2020 08:24:42 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 424A3C061573 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 05:24:42 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id v54so1468823qtj.7 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 05:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=ADvudt0kqBdP2QDr8zOYxTPLcM459u30M4JST48Vm4k=; b=JD67iDc6xUCGPbZ63dWKijaTJQ2cB5w/OlfMxvlcVHSm59YIblqMx7mrfk0lWhGePW Tf224cji/OoAiUQ/B5tiHY1FXWcq7fT5WoyKQUv8Xvx+K2LRj+SrNjXNBvuwCrslqcOB 7F3jm3mrx8khsQrZpt3hvRO34QkHi/7CHtlaeDNGIAydamUqn3T3gn1U0WGnZs4gvHaE f1aZ3clt666EwQ8iMi8A7BYjZ+RrOx6WedPMvSeGcWsqySPyLSWB2MFeb7jEoF8yCpfL HEj2Dhv9iEniVnXj+1597hBWcOkaRXRfiOejD8eW2cyebsPhkUy2Ih0bQ5TGiv/Z5lGd lQcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=ADvudt0kqBdP2QDr8zOYxTPLcM459u30M4JST48Vm4k=; b=LL2YH+2R6DE9zcC2ntto1VPeS/OMXVHoxFv7zIJ5qsa4HaVHX+5HyvMdqWbueY6OX2 IxoGZ+yDLKPesxBYqvjgM2rXvgQ0VHE+4VFISeFLb5OLUh5yp2KkxlG2P0+JNeEwLUva QswxkZ5nKH8OYeYsi/acJm4Jszm5kDYY4f+dCcXK4erqchfqnsdGNAbSYMQWl1C41mNZ hf0VaPxnPIwWmWWTar+g01mYvSoWz26zTwUvszZPLbHh0ithbeiK1mp2QalPVce4NiXu taxoCHJ9Zwrv4LXDo352b82AeQx3umLeIqf+YKig8uk1+sOldfvWxNCftF/mWKXaeBUm 4x4g== X-Gm-Message-State: AOAM532/Nr2qDXFiS3iglv7SasZ8hcwbWPCRehCSy1MzKkby0B3kDeWX F7UjwEIEBupXDj0Rv7fiARWj0yy85wdjJA== X-Google-Smtp-Source: ABdhPJxXL55o/50TUUHB0Ex18bLU9j9DGEZ5ESe0woZfQaRXLHxmrf3ApELvFYrBoP9LEsln67MiXw== X-Received: by 2002:aed:3081:: with SMTP id 1mr8632166qtf.356.1598790278671; Sun, 30 Aug 2020 05:24:38 -0700 (PDT) Received: from [172.17.0.2] ([52.147.165.209]) by smtp.gmail.com with ESMTPSA id z14sm5842506qtn.92.2020.08.30.05.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 05:24:37 -0700 (PDT) Message-ID: <5f4b9a85.1c69fb81.e4d93.2484@mx.google.com> Date: Sun, 30 Aug 2020 05:24:37 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============8536862862408111687==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, hanzefang@gmail.com Subject: RE: [BlueZ] hcidump: fix a crash in le_meta_ev_dump() Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200830115948.GA9519@ubuntu> References: <20200830115948.GA9519@ubuntu> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8D6B541175 X-Rspamd-UID: 168985 --===============8536862862408111687== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: ERROR:SPACING: space required before the open brace '{' #17: FILE: tools/parser/hci.c:3672: + if(subevent > LE_EV_NUM){ ERROR:SPACING: space required before the open parenthesis '(' #17: FILE: tools/parser/hci.c:3672: + if(subevent > LE_EV_NUM){ ERROR:SPACING: space required before the open brace '{' #19: FILE: tools/parser/hci.c:3674: + }else{ ERROR:SPACING: space required after that close brace '}' #19: FILE: tools/parser/hci.c:3674: + }else{ - total: 4 errors, 0 warnings, 13 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============8536862862408111687==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CAjDJ5+aS1+MpAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 30 Aug 2020 14:25:03 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sM1lJp+aS18qqQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 30 Aug 2020 14:25:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4C91D417C0; Sun, 30 Aug 2020 14:24:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728823AbgH3MYu (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 30 Aug 2020 08:24:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728609AbgH3MYn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 30 Aug 2020 08:24:43 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48C32C061575 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 05:24:43 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id di5so1360216qvb.13 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 05:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=LLH7Mj3wAP9wZ/6kJgEd+cqv5coSB18fRNoZkFjthho=; b=a5v8ttYPL8pxPcFauREW2qtBuHWiv36lO/eTuJDxv0sGAluK5LZbhBoYzCVF2Ao9BM oScxqMVb2iFQCCaUVN4lQYozgyP11TvuuGyTk8Q7M431L/+xwNj3zAaZv1REOEfMriyn 04vcAXEU6n8ZPVdXtITXWrD21Qbqn8KXs8qtkzGCKrSA6Vh408ijWqpOW2cIHE+qSSe/ E4ph1HnkpLFkKz+I9M2yRyOnYRpVSON/lFEg7R2EHH2Cza3ld0W7Kw5+1TlxtK6GruIh qEw368LYjuqzldhok2WVEreSyADh3LhKHKGgtK3sctr1oSgRmciAFIUtjOphIrdF2Wqs ufXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=LLH7Mj3wAP9wZ/6kJgEd+cqv5coSB18fRNoZkFjthho=; b=MwqmkeCy/IrjX9K2j7/+6pRpO7GL0DhJ7I231WNdageuqlzvW0aDRPG6sEvVWlLFox Hmx5H6u1uENhEhFJwKdX7L08KvE349ElyLE4c1tup2glN7WUtITJw4LMxE3to/helcMA mQ2RER7VuxQRTkPGyP7XVrteMVqcrxRn9VEASmKU5ncpY/J+lq8HdFQ+8jF6qlFA8cf4 3gbJ+7l+/KBR4GrT/sAcaIobgTiriZw1BmSFAkd3p+uWLkPHQ9egeAMGQ1HURxfvTF7R 60xNUTcMHnO87/Ej3w4Plk5U7IOVDqZLUU/lc0/QLnfcJlnS+H8OdPl4mGqkldW+yP7i oOew== X-Gm-Message-State: AOAM533cFaofSewyXNpJVPWbLIlq86i4XZJBWthb+2f0PlxGFJ8EOe8R UBRlPubMKzZuGcS5Bf4nV0WEJKKeR8ftDA== X-Google-Smtp-Source: ABdhPJyu6NSxzW3F70zwcLaEhsF1x9uqDi9fy1lHxlv3lLsQlJvqLNGOM1R5YNZWWzgyG+DGJbG4jw== X-Received: by 2002:a0c:a024:: with SMTP id b33mr1536748qva.0.1598790281245; Sun, 30 Aug 2020 05:24:41 -0700 (PDT) Received: from [172.17.0.2] ([52.147.165.209]) by smtp.gmail.com with ESMTPSA id k72sm3193084qke.121.2020.08.30.05.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 05:24:40 -0700 (PDT) Message-ID: <5f4b9a88.1c69fb81.8664e.a201@mx.google.com> Date: Sun, 30 Aug 2020 05:24:40 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3041058955183442164==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, hanzefang@gmail.com Subject: RE: [BlueZ] hcidump: fix a crash in le_meta_ev_dump() Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200830115948.GA9519@ubuntu> References: <20200830115948.GA9519@ubuntu> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.07 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4C91D417C0 X-Rspamd-UID: dcf9b8 --===============3041058955183442164== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 3: B6 Body message is missing --- Regards, Linux Bluetooth --===============3041058955183442164==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QNHWCAybS19IqwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 30 Aug 2020 14:26:52 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id MJ5hBwybS1/w+AAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 30 Aug 2020 14:26:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A7FF6A12CF; Sun, 30 Aug 2020 14:26:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728837AbgH3M0g (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 30 Aug 2020 08:26:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728831AbgH3M0e (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 30 Aug 2020 08:26:34 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3F27C061573; Sun, 30 Aug 2020 05:26:33 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id x18so516404pll.6; Sun, 30 Aug 2020 05:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ejqO87rorFkVXw0/ByXTM9CvLRvpm4qV9tVsBbkXl5I=; b=Qn/++4J3Z/bAbP0hfH0Wek8D4QXU9x5lXBOPjjGgyy3p6+DhkFdVlK0Qvg4sbZbHyi CspnA895diI0L0XAsK24N+J8fESh1feelF5xwmNNhoiSTCepBgdldjloZbw4/vZe2zDP MFGkygHfhqtWNHZh8kpm+fFqiz6gT1qfCwekkFSoTCejD0LBLfreK8URHXDxS9BRd0WL 9IGdmslXLCm0sIlbc6e9rhoSWtKYoR17FJ7W7FwGuRs1i7vfZoggNq+0lXyEQ8Z2FnOP cn26BnOtUttf/mNbMH2hNrvEXPEJ7hsA82rYu1pSJEvQ93ItrDGAR4UXt4O4uI5vEPnw Jt8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ejqO87rorFkVXw0/ByXTM9CvLRvpm4qV9tVsBbkXl5I=; b=FWs+QFB9pM+nZa4mQ7tSTToenNuVNBmjhnI+hu5JXsOK1rsa8Se9RfdU/SHMx44uGu oy9qwlkBbOn7CZurJzlnuA0K1CmGR4Ut6mJ5DqzkO0baRGihrg7OXjot85hMtJvc8Tpt MNGdg7WJsfML9RzLoqUxGPUf7S6eQMtv4EiPvxpSoM3tmxZRC9afCJC6rFvpdeR5VJ+B K4zjcMeJ2eERo/+XbU8iwGBTPfS9BLutrpMhXxkXr/gpL8MX1zTdVFbnJVTKgQ8lVOrc Tjy2Wk4ozADuk2NVn+VYwbxQzeWsamOG+eeStZ9Uy6xHuZnsY4Jl9ShW39L4cnGPg5p+ JR3Q== X-Gm-Message-State: AOAM533FdLyVa2aD9I6SVm7VunlDI5NM42XIiWaXoZI6H1Dr/G/cQabK paKTzjwSon55twUtr5PR1Yw= X-Google-Smtp-Source: ABdhPJzZtb1Nfg209xbdteCKN2XIoYQJIeLuvoBWNxezlKGZpJEy+OsTzIZvgQ8YxxVX/yrRKcwePw== X-Received: by 2002:a17:902:8347:: with SMTP id z7mr5506118pln.20.1598790391028; Sun, 30 Aug 2020 05:26:31 -0700 (PDT) Received: from Thinkpad ([45.118.165.143]) by smtp.gmail.com with ESMTPSA id lj3sm4290067pjb.26.2020.08.30.05.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 05:26:30 -0700 (PDT) Date: Sun, 30 Aug 2020 17:56:23 +0530 From: Anmol Karn <anmol.karan123@gmail.com> To: Greg KH <gregkh@linuxfoundation.org> Cc: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, anmol.karan123@gmail.com Subject: Re: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer deref in hci_phy_link_complete_evt Message-ID: <20200830122623.GA235919@Thinkpad> References: <20200829124112.227133-1-anmol.karan123@gmail.com> <20200829165712.229437-1-anmol.karan123@gmail.com> <20200830091917.GB122343@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200830091917.GB122343@kroah.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: A7FF6A12CF X-Rspamd-UID: 6393de On Sun, Aug 30, 2020 at 11:19:17AM +0200, Greg KH wrote: > On Sat, Aug 29, 2020 at 10:27:12PM +0530, Anmol Karn wrote: > > Fix null pointer deref in hci_phy_link_complete_evt, there was no > > checking there for the hcon->amp_mgr->l2cap_conn->hconn, and also > > in hci_cmd_work, for hdev->sent_cmd. > > > > To fix this issue Add pointer checking in hci_cmd_work and > > hci_phy_link_complete_evt. > > [Linux-next-20200827] > > > > This patch corrected some mistakes from previous patch. > > > > Reported-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com > > Link: https://syzkaller.appspot.com/bug?id=0d93140da5a82305a66a136af99b088b75177b99 > > Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> > > --- > > net/bluetooth/hci_core.c | 5 ++++- > > net/bluetooth/hci_event.c | 4 ++++ > > 2 files changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > > index 68bfe57b6625..996efd654e7a 100644 > > --- a/net/bluetooth/hci_core.c > > +++ b/net/bluetooth/hci_core.c > > @@ -4922,7 +4922,10 @@ static void hci_cmd_work(struct work_struct *work) > > > > kfree_skb(hdev->sent_cmd); > > > > - hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); > > + if (hdev->sent_cmd) { > > + hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); > > + } > > How can sent_cmd be NULL here? Are you sure something previous to this > shouldn't be fixed instead? Sir, sent_cmd was freed before this condition check, thats why i checked it, i think i should check it before the free of hdev->sent_cmd like, if (hdev->sent_cmd) kfree_skb(hdev->sent_cmd); what's your opininon on this. > > > > + > > if (hdev->sent_cmd) { > > if (hci_req_status_pend(hdev)) > > hci_dev_set_flag(hdev, HCI_CMD_PENDING); > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > index 4b7fc430793c..1e7d9bee9111 100644 > > --- a/net/bluetooth/hci_event.c > > +++ b/net/bluetooth/hci_event.c > > @@ -4941,6 +4941,10 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > > hci_dev_unlock(hdev); > > return; > > } > > + if (!(hcon->amp_mgr->l2cap_conn->hcon)) { > > + hci_dev_unlock(hdev); > > + return; > > + } > > How can this be triggered? syzbot showed that this line is accessed irrespective of the null value it contains, so added a pointer check for that. please give some opinions on this, if (!bredr_hcon) { hci_dev_unlock(hdev); return; } Thanks, Anmol Karn Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ANOvGLKkS1/c3gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 30 Aug 2020 15:08:02 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iDQsF7KkS19exQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 30 Aug 2020 15:08:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2B8A4418AF; Sun, 30 Aug 2020 15:07:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728765AbgH3NHy (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 30 Aug 2020 09:07:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728761AbgH3NHx (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 30 Aug 2020 09:07:53 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17769C061573 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 06:07:52 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id bh1so1748230plb.12 for <linux-bluetooth@vger.kernel.org>; Sun, 30 Aug 2020 06:07:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=WswOPChdhsXl9yL0PAanxx8W8jatho3LL/ArFA4MIY8=; b=IKyZ2eyTWjmDv8SIGocLuuLcvSfnE8GHJ6Xlz9H/IIUuOeEYTy8TH29C3qjxS8eHY5 hN+ShtNUPjPsIN0wk2saJvDeRs0NLP7s0F0G8j4Y7AqXPAFvh72sIz0ta2MSgAUTTw32 LpsgJnlt10vRU+QM5OMciTrMtH99OW9nl8Vc4Hdesd8AtMtug1nWja/JlaoFAr+HF8EV 240OADuwwF/t5hfl3YM1kv+yhe2QLsCXyB3gToFf+HRQtirSPB2P0UkXWScL5R4OVoVv KMlWd8nzGhM7uRWt92GEW7qK2zFKPnAHKGJVzGb4iEK7QX0qysPevGbOW/rPy/vVd/2k nlVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=WswOPChdhsXl9yL0PAanxx8W8jatho3LL/ArFA4MIY8=; b=Z1WcqD4ksGRzxocv5p4PsP9nqOEeR0sfOCfggkWFcsFH1MJNzoKgFF9xmaXMEyRHHE e6hlzrueuz9tWOcrJ4tu8U9rzE+C/8lZblI025dzjzWJlxHwlq8pQYNuIjhEMBnKL2Hj 2Doy+1aH7LLNUsVqHLoa2Bk5z2d3lrbRoML0/0HqHBDE//6/zihPs/9Xync95Vca02UD xOwMWyr5c7+uVrIyxxh0hSTKrtVW3l58DExaUHRSXh8eeY00m72Sj2sQFaSMRDphqAqA 6hn7AKW0rVyAh8KhSJiZSexYNAlDnlgV/6+wCJVCXfZE7V5gVrYVTvmm8FHGHT9utMR8 ObdA== X-Gm-Message-State: AOAM5335xtpM7qJ3VrcV8IWO2aCsf3UIZST825ZxukwFIDt7OYPnEak/ 0IKsciAZ9NQrCrIgLNV+eLdngjIYv2GgJ7Yx X-Google-Smtp-Source: ABdhPJz38Ybn4jxAcCpy6pg5HQk8fPTPUJ+ETe1SYbwkSDCOO7/zeO2xRxzF2ZCKLDy4x6CupATldg== X-Received: by 2002:a17:902:6ac9:: with SMTP id i9mr5631145plt.128.1598792872020; Sun, 30 Aug 2020 06:07:52 -0700 (PDT) Received: from ubuntu ([59.64.129.39]) by smtp.gmail.com with ESMTPSA id u22sm4418437pgi.85.2020.08.30.06.07.49 for <linux-bluetooth@vger.kernel.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Aug 2020 06:07:51 -0700 (PDT) Date: Sun, 30 Aug 2020 06:07:44 -0700 From: zefang han <hanzefang@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] tools/hcidump: fix a out-of-bounds read in le_meta_ev_dump() Message-ID: <20200830130744.GA10568@ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2B8A4418AF X-Rspamd-UID: ba798e Check whether the subevent code of le meta event is bigger than the size of ev_le_meta_str. --- tools/parser/hci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/parser/hci.c b/tools/parser/hci.c index 41f6fe087..acd41be83 100644 --- a/tools/parser/hci.c +++ b/tools/parser/hci.c @@ -3668,7 +3668,12 @@ static inline void le_meta_ev_dump(int level, struct frame *frm) frm->len -= EVT_LE_META_EVENT_SIZE; p_indent(level, frm); - printf("%s\n", ev_le_meta_str[subevent]); + + if (subevent > LE_EV_NUM) { + printf("Unknown\n"); + } else { + printf("%s\n", ev_le_meta_str[subevent]); + } switch (mevt->subevent) { case EVT_LE_CONN_COMPLETE: -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AGi4Fi3iS1+bOQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 30 Aug 2020 19:30:21 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ONcmFS3iS1/+hQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 30 Aug 2020 19:30:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A2526420D3; Sun, 30 Aug 2020 19:30:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726179AbgH3RaD (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 30 Aug 2020 13:30:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:41060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725934AbgH3RaD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 30 Aug 2020 13:30:03 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B598020714; Sun, 30 Aug 2020 17:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598808602; bh=BopSRUDvmAHu4C4ZgQT5LSsunJM/+eyFrpOMQmKj4+I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=a/zT74G2muYeReBEmL01IvpBsAYzbg5InWmKENnYGXCe/CJs+n+lN7YGS5w2Ku2LU W43mtTTjg1YBcBEAMCLFOTpRHcgS2bhXQ/tMU4azm211lZA0UXM36AIMRTSlJOAWNP R5fHsy4/+y4oBWFiAvdI4SDnogWOvna90R4xEJTs= Date: Sun, 30 Aug 2020 19:30:10 +0200 From: Greg KH <gregkh@linuxfoundation.org> To: Anmol Karn <anmol.karan123@gmail.com> Cc: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net Subject: Re: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer deref in hci_phy_link_complete_evt Message-ID: <20200830173010.GA1872728@kroah.com> References: <20200829124112.227133-1-anmol.karan123@gmail.com> <20200829165712.229437-1-anmol.karan123@gmail.com> <20200830091917.GB122343@kroah.com> <20200830122623.GA235919@Thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200830122623.GA235919@Thinkpad> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.09 / 15.00 / 200.00 X-Rspamd-Queue-Id: A2526420D3 X-Rspamd-UID: 24d9d1 On Sun, Aug 30, 2020 at 05:56:23PM +0530, Anmol Karn wrote: > On Sun, Aug 30, 2020 at 11:19:17AM +0200, Greg KH wrote: > > On Sat, Aug 29, 2020 at 10:27:12PM +0530, Anmol Karn wrote: > > > Fix null pointer deref in hci_phy_link_complete_evt, there was no > > > checking there for the hcon->amp_mgr->l2cap_conn->hconn, and also > > > in hci_cmd_work, for hdev->sent_cmd. > > > > > > To fix this issue Add pointer checking in hci_cmd_work and > > > hci_phy_link_complete_evt. > > > [Linux-next-20200827] > > > > > > This patch corrected some mistakes from previous patch. > > > > > > Reported-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com > > > Link: https://syzkaller.appspot.com/bug?id=0d93140da5a82305a66a136af99b088b75177b99 > > > Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> > > > --- > > > net/bluetooth/hci_core.c | 5 ++++- > > > net/bluetooth/hci_event.c | 4 ++++ > > > 2 files changed, 8 insertions(+), 1 deletion(-) > > > > > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > > > index 68bfe57b6625..996efd654e7a 100644 > > > --- a/net/bluetooth/hci_core.c > > > +++ b/net/bluetooth/hci_core.c > > > @@ -4922,7 +4922,10 @@ static void hci_cmd_work(struct work_struct *work) > > > > > > kfree_skb(hdev->sent_cmd); > > > > > > - hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); > > > + if (hdev->sent_cmd) { > > > + hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); > > > + } > > > > How can sent_cmd be NULL here? Are you sure something previous to this > > shouldn't be fixed instead? > > Sir, sent_cmd was freed before this condition check, thats why i checked it, But it can not be NULL at that point in time, as nothing set it to NULL, correct? > i think i should check it before the free of hdev->sent_cmd like, > > if (hdev->sent_cmd) > kfree_skb(hdev->sent_cmd); No, that's not needed. What is the problem with these lines that you are trying to solve? > > > + > > > if (hdev->sent_cmd) { > > > if (hci_req_status_pend(hdev)) > > > hci_dev_set_flag(hdev, HCI_CMD_PENDING); > > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > > index 4b7fc430793c..1e7d9bee9111 100644 > > > --- a/net/bluetooth/hci_event.c > > > +++ b/net/bluetooth/hci_event.c > > > @@ -4941,6 +4941,10 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > > > hci_dev_unlock(hdev); > > > return; > > > } > > > + if (!(hcon->amp_mgr->l2cap_conn->hcon)) { > > > + hci_dev_unlock(hdev); > > > + return; > > > + } > > > > How can this be triggered? > > syzbot showed that this line is accessed irrespective of the null value it contains, so added a > pointer check for that. But does hcon->amp_mgr->l2cap_conn->hcon become NULL here? thanks, greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6J1pBnAPTF+/FgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 30 Aug 2020 22:43:28 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SNi8BHAPTF8k0wEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 30 Aug 2020 22:43:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2BE93420DD; Sun, 30 Aug 2020 22:43:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726282AbgH3Umz (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 30 Aug 2020 16:42:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgH3Umy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 30 Aug 2020 16:42:54 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E824C061573; Sun, 30 Aug 2020 13:42:53 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id l191so3159496pgd.5; Sun, 30 Aug 2020 13:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Lzp6goA2AviezS1ObcAhoJPkamd8oGFknl/lz9o3BHg=; b=D8ZMSq6ZCaMQH+SvK/2jSp60cp+cGxD66jR5JXrzKIa1yYxBpEhK37W6I+ozBoxP1W 9NDE+WAgHHKNFLsc9BF69aVNY9azAERIZDstCOGuOwdO9gf4fPRZjO8bkrEoT2BKJ8je sJ1encrhctGQO1EYssfCY9vexv4WaxL10S6uEOIKDONNp6jjZF5muUcf9+FjbZkKA48H Xm82lzy4Iw5TyOA5t9yFVufuEPh8KutGPNWWcxgzWAKVvscsmlQ0IF1LoUtYE+6ByPNg KYN0s7qvNFV1YmK5jAlJs8YQEwHyn8z5HsSl5gTe7YSIt0suc1Gx/CYuGAAip+ia5Rj8 ZvUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Lzp6goA2AviezS1ObcAhoJPkamd8oGFknl/lz9o3BHg=; b=gIvSjtmAgqOiYZ5Lz07QE6ZQtEVgYtpKPKhMLEVQoHZUPHKyEvPnLTRQtJKC/E/gwU 93zxggRNItcD85tpKFBz2Ory2TOlfdSbEp6IvK6loPQlZTuvd7lBtfhg7dgz0ZuTolYr cuPa2glqdDpyo49QwBxpB7hjtLQrPX7pUhfROr95NSnaYvqrFLvMttxMgQnMThhBmybj +Pv02sU04IcugXyONR6mj7BhGkScFyTcXUqy7AFxCtG3nw4hxgEsxt/gOR9qDMHf7B+m UgKw1cFmtJHWJ+kK02RC7szzxWVvXWYelnNTIQT58Kq5H4XYM6pOjBuCCOVbCqKRRxZ+ n5aQ== X-Gm-Message-State: AOAM532hvEej1zu5CgfpYWdLOESuNs6ueF+ICR2FbFuJ+hCTeRXHoQa1 vsC4ejtrHT+CoBXXADsgAuE= X-Google-Smtp-Source: ABdhPJyWMomAVH6mrzGOHjhZQK6/BZ+CqwFOL6wR/LO7P0FYwX5dhks+kGq89NwZyRgyGLJ7LDyRJQ== X-Received: by 2002:a63:6d4c:: with SMTP id i73mr6187609pgc.63.1598820172837; Sun, 30 Aug 2020 13:42:52 -0700 (PDT) Received: from Thinkpad ([45.118.165.143]) by smtp.gmail.com with ESMTPSA id 13sm5701842pfp.3.2020.08.30.13.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 13:42:51 -0700 (PDT) Date: Mon, 31 Aug 2020 02:12:45 +0530 From: Anmol Karn <anmol.karan123@gmail.com> To: Greg KH <gregkh@linuxfoundation.org> Cc: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net Subject: Re: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer deref in hci_phy_link_complete_evt Message-ID: <20200830204245.GA249337@Thinkpad> References: <20200829124112.227133-1-anmol.karan123@gmail.com> <20200829165712.229437-1-anmol.karan123@gmail.com> <20200830091917.GB122343@kroah.com> <20200830122623.GA235919@Thinkpad> <20200830173010.GA1872728@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200830173010.GA1872728@kroah.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2BE93420DD X-Rspamd-UID: 59be78 On Sun, Aug 30, 2020 at 07:30:10PM +0200, Greg KH wrote: > On Sun, Aug 30, 2020 at 05:56:23PM +0530, Anmol Karn wrote: > > On Sun, Aug 30, 2020 at 11:19:17AM +0200, Greg KH wrote: > > > On Sat, Aug 29, 2020 at 10:27:12PM +0530, Anmol Karn wrote: > > > > Fix null pointer deref in hci_phy_link_complete_evt, there was no > > > > checking there for the hcon->amp_mgr->l2cap_conn->hconn, and also > > > > in hci_cmd_work, for hdev->sent_cmd. > > > > > > > > To fix this issue Add pointer checking in hci_cmd_work and > > > > hci_phy_link_complete_evt. > > > > [Linux-next-20200827] > > > > > > > > This patch corrected some mistakes from previous patch. > > > > > > > > Reported-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com > > > > Link: https://syzkaller.appspot.com/bug?id=0d93140da5a82305a66a136af99b088b75177b99 > > > > Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> > > > > --- > > > > net/bluetooth/hci_core.c | 5 ++++- > > > > net/bluetooth/hci_event.c | 4 ++++ > > > > 2 files changed, 8 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > > > > index 68bfe57b6625..996efd654e7a 100644 > > > > --- a/net/bluetooth/hci_core.c > > > > +++ b/net/bluetooth/hci_core.c > > > > @@ -4922,7 +4922,10 @@ static void hci_cmd_work(struct work_struct *work) > > > > > > > > kfree_skb(hdev->sent_cmd); > > > > > > > > - hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); > > > > + if (hdev->sent_cmd) { > > > > + hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); > > > > + } > > > > > > How can sent_cmd be NULL here? Are you sure something previous to this > > > shouldn't be fixed instead? > > > > Sir, sent_cmd was freed before this condition check, thats why i checked it, > > But it can not be NULL at that point in time, as nothing set it to NULL, > correct? > > > i think i should check it before the free of hdev->sent_cmd like, > > > > if (hdev->sent_cmd) > > kfree_skb(hdev->sent_cmd); > > No, that's not needed. > > What is the problem with these lines that you are trying to solve? > > > > > + > > > > if (hdev->sent_cmd) { > > > > if (hci_req_status_pend(hdev)) > > > > hci_dev_set_flag(hdev, HCI_CMD_PENDING); > > > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > > > index 4b7fc430793c..1e7d9bee9111 100644 > > > > --- a/net/bluetooth/hci_event.c > > > > +++ b/net/bluetooth/hci_event.c > > > > @@ -4941,6 +4941,10 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > > > > hci_dev_unlock(hdev); > > > > return; > > > > } > > > > + if (!(hcon->amp_mgr->l2cap_conn->hcon)) { > > > > + hci_dev_unlock(hdev); > > > > + return; > > > > + } > > > > > > How can this be triggered? > > > > syzbot showed that this line is accessed irrespective of the null value it contains, so added a > > pointer check for that. > > But does hcon->amp_mgr->l2cap_conn->hcon become NULL here? Sir, according to the report obtained by running decode_stacktrace on logs there is something getting null at this line, after verifying the buggy address i thought it would be better to check this whole line. will dig more deeper into this and will make appropriate changes in the next version, thanks for review. Anmol Karn Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yE22FbCoTF+Q9gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 09:37:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id KKHwE7CoTF+61QEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 09:37:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F37B4A11F9; Mon, 31 Aug 2020 09:37:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725949AbgHaHhN (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 03:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbgHaHhK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 03:37:10 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48936C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 00:37:10 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id b1so5387895qto.17 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 00:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=s9VJKEkalBronQIXpvXWZsG3O7AMhGMwRvW0lxf7xHg=; b=YY77rNik+jivlMpK6E3iCn6fd8mm3J7ul6FMvXFpkbVixMWy1GfcYRC2BT79HX7Gj1 IUTxVtAh8cXSa8Bn5JDflR5Z5QE3bcpNv7abPIo1j/qplGmpO2KqYaeQ4D8zLAggIhzY TIPqEMfvHUUs543pCuOJUvAeXCq1MK95YhwXfxNsiMjoZ2tYkYAwVbclYPbobUDrc/ks KcEDljEv3S56uzC5ZDJlgfhUZvhV48qtlrdPbplyJBB+0mOussZRbJaWhsihwmlp3qV2 pBwTbKaOwa2CeShsB3URMxNoB0Kni2uuEnGH6Llda9Ks2Sdsz8V2gRj8DfT9RY+EB36N XCkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=s9VJKEkalBronQIXpvXWZsG3O7AMhGMwRvW0lxf7xHg=; b=PWt3OgCil01jKIrYrH+0wfnHH213qspkzsuC3R5Shynl84pyPzLCdpq2g/Saig1B5j Ssh4UiDhG6HIcLbXnJgUzO7LvdaYmgQYye92O7qX2sOymWqZF33JkiFsYgZvOrw5uW4Q Sl/Pa30brsgPxbsACekyXds+VDPdlGwrt+9k11zltPMHjQpSkzSHLQk27rXcr0NSJyzS Wuw0D7x7s0IQAPdVhNrwqlHoFZ4rKEXVktsrDgtet8tU34t3aylTq5vo++3Lb4AbABqP 5zCCRafFxm2IarBVwX//QagQsy0TClnXSJLzG9Bw5rMUO+rpUcFOG6KJY/VpJ9G5WOIO ENqA== X-Gm-Message-State: AOAM5339s390nIO9csW1/MbTem8YgAIu172XrvAtYYoBIJcY0Kx8qJpP SMHChbUJqGPa9De79aEt0YV4mOIpSxe2toIHSWNGriu/Gpbt4scLL5HtUnqU5CqrK0+kQaefRs8 r/YWUNMsi4bmHVddzXDLjsc6MwC7XrXzdFOcn/pEW6QY/AEikUYd/Au8zsPabdp39KspKxB3+az lN X-Google-Smtp-Source: ABdhPJxVCkppEp4J0xA4mmgo0kNNNBAXnIlwOPzPn1OraYghgFX0AIWRLYc+DiGPXnt70yjTHr9k2mo6ntok X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a0c:f2c4:: with SMTP id c4mr3830159qvm.118.1598859428244; Mon, 31 Aug 2020 00:37:08 -0700 (PDT) Date: Mon, 31 Aug 2020 15:36:32 +0800 Message-Id: <20200831153544.Bluez.v1.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v1 1/2] doc/media-api: Add Press method for MediaPlayer1 From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.03 / 15.00 / 200.00 X-Rspamd-Queue-Id: F37B4A11F9 X-Rspamd-UID: 04ce3b From: Archie Pusaka <apusaka@chromium.org> This allows us to send any passthrough command. Reviewed-by: Michael Sun <michaelfsun@google.com> --- doc/media-api.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/media-api.txt b/doc/media-api.txt index dabc69936..fe7222eef 100644 --- a/doc/media-api.txt +++ b/doc/media-api.txt @@ -199,6 +199,14 @@ Methods void Play() Possible Errors: org.bluez.Error.NotSupported org.bluez.Error.Failed + void Press(byte avc_key) + + Press a specific key to send as passthrough command. + + Possible Errors: org.bluez.Error.InvalidArguments + org.bluez.Error.NotSupported + org.bluez.Error.Failed + Properties string Equalizer [readwrite] Possible values: "off" or "on" -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aIbFAF0hTV+mHQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 18:12:13 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 2HTSOlwhTV8OugAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 18:12:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=dptechnics.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4FA1CA1AE0; Mon, 31 Aug 2020 18:12:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728494AbgHaQLi (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 12:11:38 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17166 "EHLO sender4-op-o11.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728454AbgHaQLg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 12:11:36 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1598890293; cv=none; d=zohomail.com; s=zohoarc; b=O5DzV0rHwHMSbxw19SwOqV/F2ihuZ6Lq5dBgzMGe8XnMO0gsV60f634PCvWPtE82fodWfw9skLt7w+EQG2y3nyi+/ZmbiOtCoYwKm2A/Fiwp1v4fZPPwIHvw8oUnH2QdDMoeeXez2m9N7mRcv4vWlz1I5i9sYUeEHeawImO+xZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598890293; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=U7zU+T4UJWebKnXuLS0gsJ3b4OHTI28SbTdILGqbn8s=; b=ewjx1AdUEsPa/21pr6HFo6u7xRTtspiea3In2Ny2OubQvjmh1ssbturyDuylLriR6FTS35m+KfM+soLFWg2mScIHOZ20hOg4lkfSyGx/YxXiaibrLk0R9/L4uGfXJEY0x4v8OJAMSB2avFpfzT28HKU383oDo/Pp0K7NJ4qsx7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=dptechnics.com; spf=pass smtp.mailfrom=daan@dptechnics.com; dmarc=pass header.from=<daan@dptechnics.com> header.from=<daan@dptechnics.com> DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1598890293; s=zoho; d=dptechnics.com; i=daan@dptechnics.com; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=U7zU+T4UJWebKnXuLS0gsJ3b4OHTI28SbTdILGqbn8s=; b=O+1iS6ZMgdZ+Ea0q6THZjAPrMT2IvDfFgQy2qn2+U1gzyLoHGIlEpaEwJJwQS1z9 rAHnqRQ2EHSKFkAHYhUT5n8TREaApDnUKx4zXk236FjkKurs73y7eAVegIDMO6LA1sn ZpyNJmNAdculwAOfxnqYH16ykAl5zbwkH2UJ9vGc= Received: from daan-devbox.dptechnics.local (178-116-74-88.access.telenet.be [178.116.74.88]) by mx.zohomail.com with SMTPS id 1598890288445151.68956055259991; Mon, 31 Aug 2020 09:11:28 -0700 (PDT) From: Daan Pape <daan@dptechnics.com> To: linux-bluetooth@vger.kernel.org Cc: Daan Pape <daan@dptechnics.com> Message-ID: <20200831161116.15975-1-daan@dptechnics.com> Subject: [PATCH BlueZ 0/1] Mesh HCI interface init scan interval fixed Date: Mon, 31 Aug 2020 18:11:15 +0200 X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.34 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4FA1CA1AE0 X-Rspamd-UID: 26ce9d The HCI initialization function of bluetooth-meshd was not converting to the correct byte order when initializing the LE Scan Parameters. This is now fixed. Daan Pape (1): Mesh HCI interface init scan interval fixed AUTHORS | 1 + mesh/mesh-io-generic.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) --=20 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EByZDbqoTF9V8gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 09:37:30 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id MJ7GC7qoTF8haAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 09:37:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1ECAEA1C02; Mon, 31 Aug 2020 09:37:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726618AbgHaHhV (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 03:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725954AbgHaHhT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 03:37:19 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48055C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 00:37:19 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id r1so8544261ybg.4 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 00:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=eAXlDAAz5TFmeza+8DaCP4za8yezvOdPfYr8LC/+Kmw=; b=hAylWT8i1IGKX+hEyZI7h86gg8wiK9hGw71IsOt0+YkYjstQ1Sf+cDEV0mC8CdB8mW RKDhXHbQsILpanxY+qIo+u86MyI/NJn+Boa4Ig1rV0MA4mftdT4VLkwUIuWYdjKW0ta9 vAaHyQlQVy+YLgMeP3UZ0ODICGJ9RjIloK3vlR0v1XmMu1NXAxRkzDwFUWLtWtAY0BZJ CEwT1O+nKOBQn1dKiTPy3Z6o7+dabtMyKbDPs4XQW9p3uXWZos0F2t1AAEzoTKt0YGl4 +O9WNzBjuPOOvTfZNhEAv/qpP4M7B0s+LIfUYkcfjaSZDBczLgx5Z/qlDIssllr7jXRK tkhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=eAXlDAAz5TFmeza+8DaCP4za8yezvOdPfYr8LC/+Kmw=; b=aevI4xcOBjMwwhHY5EZ38mAqC8ZjxNa+gnPfYJ0/B23fPuUPsOUCG7Ti0QLOEOuU4R 5WZBIeRhNz+WWp2N01IkLvC6Xe5SbtD5SA96Oh9OgQXVb8TOWcQ5gc6cY+kRw7WLF0kS JrnTJgSwRDXKdtPqqma8CYpEisB3BbUvsOEvdLZXU5JN0AjYCPz3fhajWRawml95I85m AGfj5iaeDgPNIndsmx+wEwWSaPN5dP7EZ5VSTn854sn/G6HzHeKBn7SKdps3te0UX/mS ofVQDK59pAszGvHiET8hbPby6IoJHMP5NTKFH1ux7/el0AqM/+etEdx3T1j7MH2SkACf iTQA== X-Gm-Message-State: AOAM5303F+AEgkPKr/cn70PlJRIPFigbEmWIx4xISaSHvl4zlYqbHPNF kxskHwSxQCEl897PQm2/p0ih9bltH+J9z02rM6M/la5rWRDlPEzNW+TVBeO//KIYhRJiKXIdFc2 Qmrvvc6gOQjgnVAsBWzvnGwyrPFewJC+n8GGR8eDtMoyu4tH8eKVilDrcfTNRBopiSUzM9flHwn Th X-Google-Smtp-Source: ABdhPJy44ZKx+DKs66rlS6hLJ1rCg6GgZzOEkcdeLWTmk3p65pMOuW/wQOPYPABnk4C3FNmvbxj3g0NyysDS X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a25:8290:: with SMTP id r16mr562048ybk.122.1598859436245; Mon, 31 Aug 2020 00:37:16 -0700 (PDT) Date: Mon, 31 Aug 2020 15:36:33 +0800 In-Reply-To: <20200831153544.Bluez.v1.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> Message-Id: <20200831153544.Bluez.v1.2.Ia9ec99e1edde324e55c91828218268bc1b614136@changeid> Mime-Version: 1.0 References: <20200831153544.Bluez.v1.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v1 2/2] avrcp: Implement Press method for MediaPlayer1 From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.94 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1ECAEA1C02 X-Rspamd-UID: 4cce1d From: Archie Pusaka <apusaka@chromium.org> This allows us to send any passthrough command. Reviewed-by: Michael Sun <michaelfsun@google.com> --- profiles/audio/avrcp.c | 9 +++++++++ profiles/audio/player.c | 24 ++++++++++++++++++++++++ profiles/audio/player.h | 30 ++++++++++++++++-------------- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 5d0256c52..b6f4ef90d 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -3043,6 +3043,14 @@ static int ct_rewind(struct media_player *mp, void *user_data) return ct_press(player, AVC_REWIND); } +static int ct_press_key(struct media_player *mp, uint8_t avc_key, + void *user_data) +{ + struct avrcp_player *player = user_data; + + return ct_press(player, avc_key); +} + static int ct_list_items(struct media_player *mp, const char *name, uint32_t start, uint32_t end, void *user_data) { @@ -3388,6 +3396,7 @@ static const struct media_player_callback ct_cbs = { .previous = ct_previous, .fast_forward = ct_fast_forward, .rewind = ct_rewind, + .press = ct_press_key, .list_items = ct_list_items, .change_folder = ct_change_folder, .search = ct_search, diff --git a/profiles/audio/player.c b/profiles/audio/player.c index 09ee979e4..4a16f65b3 100644 --- a/profiles/audio/player.c +++ b/profiles/audio/player.c @@ -570,6 +570,28 @@ static DBusMessage *media_player_rewind(DBusConnection *conn, DBusMessage *msg, return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); } +static DBusMessage *media_player_press(DBusConnection *conn, DBusMessage *msg, + void *data) +{ + struct media_player *mp = data; + struct player_callback *cb = mp->cb; + int err; + uint8_t avc_key; + + if (cb->cbs->press == NULL) + return btd_error_not_supported(msg); + + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_BYTE, &avc_key, + DBUS_TYPE_INVALID)) + return btd_error_invalid_args(msg); + + err = cb->cbs->press(mp, avc_key, cb->user_data); + if (err < 0) + return btd_error_failed(msg, strerror(-err)); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + static void parse_folder_list(gpointer data, gpointer user_data) { struct media_item *item = data; @@ -704,6 +726,8 @@ static const GDBusMethodTable media_player_methods[] = { { GDBUS_METHOD("Previous", NULL, NULL, media_player_previous) }, { GDBUS_METHOD("FastForward", NULL, NULL, media_player_fast_forward) }, { GDBUS_METHOD("Rewind", NULL, NULL, media_player_rewind) }, + { GDBUS_METHOD("Press", GDBUS_ARGS({"avc_key", "y"}), NULL, + media_player_press) }, { } }; diff --git a/profiles/audio/player.h b/profiles/audio/player.h index 536394ca6..bd24c16ec 100644 --- a/profiles/audio/player.h +++ b/profiles/audio/player.h @@ -45,26 +45,28 @@ struct media_player; struct media_item; struct media_player_callback { - bool (*set_setting) (struct media_player *mp, const char *key, + bool (*set_setting)(struct media_player *mp, const char *key, const char *value, void *user_data); - int (*play) (struct media_player *mp, void *user_data); - int (*pause) (struct media_player *mp, void *user_data); - int (*stop) (struct media_player *mp, void *user_data); - int (*next) (struct media_player *mp, void *user_data); - int (*previous) (struct media_player *mp, void *user_data); - int (*fast_forward) (struct media_player *mp, void *user_data); - int (*rewind) (struct media_player *mp, void *user_data); - int (*list_items) (struct media_player *mp, const char *name, + int (*play)(struct media_player *mp, void *user_data); + int (*pause)(struct media_player *mp, void *user_data); + int (*stop)(struct media_player *mp, void *user_data); + int (*next)(struct media_player *mp, void *user_data); + int (*previous)(struct media_player *mp, void *user_data); + int (*fast_forward)(struct media_player *mp, void *user_data); + int (*rewind)(struct media_player *mp, void *user_data); + int (*press)(struct media_player *mp, uint8_t avc_key, + void *user_data); + int (*list_items)(struct media_player *mp, const char *name, uint32_t start, uint32_t end, void *user_data); - int (*change_folder) (struct media_player *mp, const char *path, + int (*change_folder)(struct media_player *mp, const char *path, uint64_t uid, void *user_data); - int (*search) (struct media_player *mp, const char *string, + int (*search)(struct media_player *mp, const char *string, void *user_data); - int (*play_item) (struct media_player *mp, const char *name, + int (*play_item)(struct media_player *mp, const char *name, uint64_t uid, void *user_data); - int (*add_to_nowplaying) (struct media_player *mp, const char *name, + int (*add_to_nowplaying)(struct media_player *mp, const char *name, uint64_t uid, void *user_data); - int (*total_items) (struct media_player *mp, const char *name, + int (*total_items)(struct media_player *mp, const char *name, void *user_data); }; -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UOq/KJKqTF/KIwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 09:45:22 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id sHGYJ5KqTF9wvQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 09:45:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D2B72A03FD; Mon, 31 Aug 2020 09:45:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725848AbgHaHpO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 03:45:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbgHaHpN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 03:45:13 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 412F3C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 00:45:13 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id g127so8425020ybf.11 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 00:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=8jQ86AYXJT4P7OxYuESa4anzbwdw7z7p9lbkOmXOBgw=; b=MSsojPncwWM2riolVB2ghhaUHF7oMREgxcKYBAeiGU4hj9aUxKyY9xNatNbT/oaZtv /aRNM4g4Dn1ocPnZKAgp7PG4GLs58VlO0ZGXBr+KD9kOhmPlaJznvbOLOP1yELcoPwEe WRWu9CphDVAX1XNS0u9I1QA4YOJIQYPd1csqt90wOCUsi+6vEETw0WTihEXA56RUj7zP f12CP6kYiQNqzpFSmfOpiW9wO/jYIcANv7trzZB/QbhKUTG1Q5WNzVn/29tHf7ZrF05l Gz7wdYg/Ao9dIB10+zXCBhNSe3IVGMLylun6iCZs64bI4JPoJFt10WNVBVk2Pi2E0YM/ Rd4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=8jQ86AYXJT4P7OxYuESa4anzbwdw7z7p9lbkOmXOBgw=; b=oaxdPhY/CuHr98VSY55Whr/QcnkTJAeJD7Q7xSGz/0fkQQgyASAkBJ3sePDUWJjvyD 6SSlhxtvi9tpQQoZCXaPP6TfWb8qIyQh9GDiJqPgq28QqAK5J1htK5sudFq2FLG/l+zz xhDukDucbvos4s4FfvPgw8DhSz2rQ5zytKIEWVFxA4XJKGrEyB9ewViSnc1p3M68wbJ+ rgEpc/0kDq9LV3rPVzjaqBrKaFwrUA3MEy5C/hnGEqkgciO51RmrxKfdIsL+YAGMTlvz ydnRcLouPPPwhvV4bfGFcoPJyR4Zz84xYhE5STXU/Pz3XFUzdhZ7YI3aTTuCPzEk8sjy JevQ== X-Gm-Message-State: AOAM532FBDeAt29CT4fVJfx2s29pQ+y+QteqeV3cGrHJNycLPZ+Yqbzy JIq1YJjG1hZoqQEpeZTGbteeQkfr9jX5cnpfCLPsCNbQjZyiaLYGfOzr05MZmb2Onn/hYy7U3M4 XL85OAo3OXOqq6Vh78KYyJcf2F+l8a0tUrs4pip1oguVRIVkKbtfhrbjDbcRQLwwtcFrky5H2cR Pf X-Google-Smtp-Source: ABdhPJyrovg27oEejz0lJquVQVUKznegi41tqVrcl9tX1JUKBaF6IfkqzaqKMbqldkvnNAiYbwFHO4DMlgQs X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a25:7a42:: with SMTP id v63mr581587ybc.4.1598859912365; Mon, 31 Aug 2020 00:45:12 -0700 (PDT) Date: Mon, 31 Aug 2020 15:44:52 +0800 Message-Id: <20200831154443.Bluez.v1.1.Ieeae14ab680eda03474551fdb7a0a020f950e9c1@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v1] media: Don't set initial volume if it's invalid From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com>, Yu Liu <yudiliu@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.13 / 15.00 / 200.00 X-Rspamd-Queue-Id: D2B72A03FD X-Rspamd-UID: e7c067 From: Archie Pusaka <apusaka@chromium.org> When initializing media transport, we try to initialize the volume of the player. However, the assigned initial volume could be invalid due to the session has not been initialized, or when we assume the role of audio sink. In this case, we should not assign the initial volume. Reviewed-by: Michael Sun <michaelfsun@google.com> Reviewed-by: Yu Liu <yudiliu@google.com> --- profiles/audio/media.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 02bf82a49..acb4a8ee9 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -494,7 +494,8 @@ static gboolean set_configuration(struct media_endpoint *endpoint, return FALSE; init_volume = media_player_get_device_volume(device); - media_transport_update_volume(transport, init_volume); + if (init_volume >= 0) + media_transport_update_volume(transport, init_volume); msg = dbus_message_new_method_call(endpoint->sender, endpoint->path, MEDIA_ENDPOINT_INTERFACE, -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SG9ZDQexTF+IVwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 10:12:55 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id EGg/DAexTF9gvAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 10:12:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EF79FA1717; Mon, 31 Aug 2020 10:12:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728047AbgHaIMs (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 04:12:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgHaIMo (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 04:12:44 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAA30C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 01:12:44 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id a14so8412722ybm.13 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 01:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=jttsDn9iolcivEGMZxCfWYyrBybAzZ7cJMXs3BjjCw0=; b=TddfAqZS24wLeYRdxoRHzTL1sz3nmpQz2cQ7Sq0arJ8iX6lnHAyt6mNlusW43yhtKd CtQQCWtxHFGlzliCDMSBTMGX1gmnGH+NTwXH0bbZd9/vUoTy2t0xDj3KNsi4yK/CQ8ad I+aY7W2M12QjRbbrzDwyxqQ5qSan2PmKYvH+HOMdpfNbyVJJfoqMrJAhlAanER2c+fl3 o/52JUy6mpy1jaVvGgf4Z5Kt1ip4SUtBsitApKFv5xwzPF5ZRvH4v8leidRx44Bm6b3Z R97l/4x0NxCW/IhuybO9WL/LCrzuR2m39vspEgNaFaYDhTHNNQDmLIl27nbGhxATgcOM cANg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=jttsDn9iolcivEGMZxCfWYyrBybAzZ7cJMXs3BjjCw0=; b=ai7eUGVz0jJ/XRFUYWSg2ybyGE3GDslKVXLL1/HwHSUfquv0l6LXuqduxD2JL79NjC Lf1z9s+AiqvpYEYQ79800Q89qUUC80Hs9vzjC2gHKNV+Cr4Sx6wFe9IhE9WZOSzUrdrv +DlrF75Nr2fjIG7DKhKuWfe2PH/vfOpGXnISJ19CJzT1fqr3RgaHTdQ76Fs19nbPZl/E G/bRiFUmrabuha+ldx7FsWClVA7YMImrILE/2rwOr2fMAMl1eBpeCcaqcPXtrtfSqYu6 IBIPCt5CRY7y0hkO8jI7PGTPo6ZVnlDXiG3OwUFkKgxqpq23stNSq4GOw8zaUlsu74j3 zp+g== X-Gm-Message-State: AOAM531o81kjkta6dSrjTVv4C4/NwIef/38WDw9f6Y52aZV/xKnhfESR dDrXrdAvBJxUGHsz5O0lFG5IoFth5K7YCnACc1VZEHZFHd6HxHkBgDlhfR1HN5YoGKi7oOBXFlM I11vk76l414m/94G5PXrSxX4UC0nWOZUvMYf1DcR+4hSUyM9aBYS7sMXm9p0m/t6U0m7OaE5t47 uv X-Google-Smtp-Source: ABdhPJzxqXE7NTI0SgpDqGuHsvQmWH5j9T7SQYU0P7OBzwXjMadPshFHGrrnD/s+R2rYq1RSgYS6qvMa+TvE X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a25:af05:: with SMTP id a5mr611200ybh.411.1598861561527; Mon, 31 Aug 2020 01:12:41 -0700 (PDT) Date: Mon, 31 Aug 2020 16:12:28 +0800 Message-Id: <20200831161140.Bluez.v1.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v1] device: don't wait for timeout if RemoveDevice is called From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.94 / 15.00 / 200.00 X-Rspamd-Queue-Id: EF79FA1717 X-Rspamd-UID: 4b4b45 From: Archie Pusaka <apusaka@chromium.org> RemoveDevice on adapter interface used to remove a device, even when the device is connected. However, since the introduction of the new 30 seconds timeout when setting a device as temporary, RemoveDevice doesn't immediately remove a connected device, but only disconnects it and waits for the timer to expire before effectively removes it. This patch removes the device as soon as it gets disconnected, provided the disconnection is triggered by a call to RemoveDevice. The regular timeout still applies for other cases. Tested manually by calling RemoveDevice on a connected device, and with ChromeOS autotest setup. Reviewed-by: Daniel Winkler <danielwinkler@google.com> --- src/adapter.c | 2 -- src/adapter.h | 2 ++ src/device.c | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 5e896a9f0..d6c65ff69 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -79,8 +79,6 @@ #include "advertising.h" #include "eir.h" -#define ADAPTER_INTERFACE "org.bluez.Adapter1" - #define MODE_OFF 0x00 #define MODE_CONNECTABLE 0x01 #define MODE_DISCOVERABLE 0x02 diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..f835c984f 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -26,6 +26,8 @@ #include <dbus/dbus.h> #include <glib.h> +#define ADAPTER_INTERFACE "org.bluez.Adapter1" + #define MAX_NAME_LENGTH 248 /* Invalid SSP passkey value used to indicate negative replies */ diff --git a/src/device.c b/src/device.c index bb8e07e8f..cee0ddfd2 100644 --- a/src/device.c +++ b/src/device.c @@ -3001,6 +3001,7 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type) void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) { struct bearer_state *state = get_state(device, bdaddr_type); + bool remove_device = false; if (!state->connected) return; @@ -3018,6 +3019,10 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) while (device->disconnects) { DBusMessage *msg = device->disconnects->data; + if (dbus_message_is_method_call(msg, ADAPTER_INTERFACE, + "RemoveDevice")) + remove_device = true; + g_dbus_send_reply(dbus_conn, msg, DBUS_TYPE_INVALID); device->disconnects = g_slist_remove(device->disconnects, msg); dbus_message_unref(msg); @@ -3043,6 +3048,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) g_dbus_emit_property_changed(dbus_conn, device->path, DEVICE_INTERFACE, "Connected"); + + if (remove_device) + btd_adapter_remove_device(device->adapter, device); } guint device_add_disconnect_watch(struct btd_device *device, @@ -4457,6 +4465,9 @@ void device_remove(struct btd_device *device, gboolean remove_stored) disconnect_all(device); } + if (device->temporary_timer > 0) + g_source_remove(device->temporary_timer); + if (device->store_id > 0) { g_source_remove(device->store_id); device->store_id = 0; -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KOcUExAeTV9OXgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 17:58:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qHp7ERAeTV97PAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 17:58:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3FFB640015; Mon, 31 Aug 2020 17:58:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728255AbgHaPt7 convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 11:49:59 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:46162 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728251AbgHaPt6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 11:49:58 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 8FED0CECCD; Mon, 31 Aug 2020 18:00:04 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: Clear suspend tasks on unregister From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200826154719.1.I24fb6cc377d03d64d74f83cec748afd12ee33e37@changeid> Date: Mon, 31 Aug 2020 17:49:54 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev <netdev@vger.kernel.org>, kernel list <linux-kernel@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org>, Miao-chen Chou <mcchou@chromium.org> Content-Transfer-Encoding: 8BIT Message-Id: <A69701BE-FBB3-4053-8187-618C0BD4B380@holtmann.org> References: <20200826154719.1.I24fb6cc377d03d64d74f83cec748afd12ee33e37@changeid> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.07 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3FFB640015 X-Rspamd-UID: 17c6b8 Hi Abhishek, > While unregistering, make sure to clear the suspend tasks before > cancelling the work. If the unregister is called during resume from > suspend, this will unnecessarily add 2s to the resume time otherwise. > > Fixes: 4e8c36c3b0d73d (Bluetooth: Fix suspend notifier race) > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > This was discovered with RT8822CE using the btusb driver. This chipset > will reset on resume during system suspend and was unnecessarily adding > 2s to every resume. Since we're unregistering anyway, there's no harm in > just clearing the pending events. > > net/bluetooth/hci_core.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index 68bfe57b66250f..ed4cb3479433c0 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -3442,6 +3442,16 @@ void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, > } > } > > +static void hci_suspend_clear_tasks(struct hci_dev *hdev) > +{ > + int i; > + > + for (i = 0; i < __SUSPEND_NUM_TASKS; ++i) > + clear_bit(i, hdev->suspend_tasks); I prefer i++ instead of ++i. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MIyIAS8eTV/XDgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 17:58:39 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id CNoTAC8eTV9OCwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 17:58:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7641440134; Mon, 31 Aug 2020 17:58:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727786AbgHaPvz convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 11:51:55 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:45686 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726714AbgHaPvy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 11:51:54 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id B9316CECCD; Mon, 31 Aug 2020 18:02:00 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [Bluez PATCH v1 3/3] advertising: Add adv SupportedFeatures to doc From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200826131610.Bluez.v1.3.Ieb6522963e3f54b0d63dd88ed3ce24a8942ed73e@changeid> Date: Mon, 31 Aug 2020 17:51:50 +0200 Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Miao-chen Chou <mcchou@chromium.org> Content-Transfer-Encoding: 8BIT Message-Id: <96B41EB6-D184-492E-84E7-1E3C4E8F6327@holtmann.org> References: <20200826201715.1911816-1-danielwinkler@google.com> <20200826131610.Bluez.v1.3.Ieb6522963e3f54b0d63dd88ed3ce24a8942ed73e@changeid> To: Daniel Winkler <danielwinkler@google.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.53 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7641440134 X-Rspamd-UID: 7e356c Hi Daniel, > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > --- > > doc/advertising-api.txt | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt > index b0565eab2..0c07f349e 100644 > --- a/doc/advertising-api.txt > +++ b/doc/advertising-api.txt > @@ -209,3 +209,21 @@ Properties byte ActiveInstances > Possible values: "1M" > "2M" > "Coded" > + > + array{string} SupportedFeatures [readonly, optional] > + > + List of supported platform features. If no features > + are available on the platform, the SupportedFeatures > + endpoint will not be populated. why not just an empty SupportedFeatures? So you can tell that at least the daemon has support for it, but the hardware does not. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8JH7E1QeTV+sIAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 17:59:16 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wHB2ElQeTV/IJQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 17:59:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BCB0941175; Mon, 31 Aug 2020 17:59:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727931AbgHaP7C (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 11:59:02 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:55544 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726946AbgHaP7B (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 11:59:01 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 12AE3CECCD; Mon, 31 Aug 2020 18:09:09 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: btusb: Update boot parameter specific to SKU From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200826095432.18825-1-kiran.k@intel.com> Date: Mon, 31 Aug 2020 17:58:58 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, "Srivatsa, Ravishankar" <ravishankar.srivatsa@intel.com>, Kiran K <kiran.k@intel.com>, Chethan T N <chethan.tumkur.narayan@intel.com> Content-Transfer-Encoding: 7bit Message-Id: <67D8B90A-27CF-46EB-9C3D-9947F6B1A8B8@holtmann.org> References: <20200826095432.18825-1-kiran.k@intel.com> To: Kiran K <kiraank@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.98 / 15.00 / 200.00 X-Rspamd-Queue-Id: BCB0941175 X-Rspamd-UID: 62ba22 Hi Kiran, > boot parameter gets updated during firmware download process. Use the > updated boot parameter while doing soft reset of controller. This patch > fixes updating of boot parameter. > > Reviewed-by: Chethan T N <chethan.tumkur.narayan@intel.com> > Signed-off-by: Kiran K <kiran.k@intel.com> > --- > drivers/bluetooth/btusb.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CAdiEZEfTV+sIAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 18:04:33 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UAb+D5EfTV/bNQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 18:04:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 459CE42110; Mon, 31 Aug 2020 18:04:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728312AbgHaQEQ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 12:04:16 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:48809 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727955AbgHaQEP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 12:04:15 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 32811CECCD; Mon, 31 Aug 2020 18:14:23 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: btusb: Fix memleak in btusb_mtk_submit_wmt_recv_urb From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200823074421.20769-1-dinghao.liu@zju.edu.cn> Date: Mon, 31 Aug 2020 18:04:13 +0200 Cc: kjlu@umn.edu, Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <0A2A956F-C10C-401E-9D87-416FE8A8E597@holtmann.org> References: <20200823074421.20769-1-dinghao.liu@zju.edu.cn> To: Dinghao Liu <dinghao.liu@zju.edu.cn> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: 459CE42110 X-Rspamd-UID: 73eded Hi Dinghao, > When kmalloc() on buf fails, urb should be freed just like > when kmalloc() on dr fails. > > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> > --- > drivers/bluetooth/btusb.c | 1 + > 1 file changed, 1 insertion(+) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CIwZFhQgTV+sIAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 18:06:44 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ANF0FBQgTV+E9gAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 18:06:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 398B5A1405; Mon, 31 Aug 2020 18:06:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728228AbgHaQGV convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 12:06:21 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:48615 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727019AbgHaQGU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 12:06:20 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id BF220CECCE; Mon, 31 Aug 2020 18:16:27 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: fix "list_add double add" in hci_conn_complete_evt From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200823010022.938532-1-coiby.xu@gmail.com> Date: Mon, 31 Aug 2020 18:06:18 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, linux-kernel-mentees@lists.linuxfoundation.org, Greg KH <gregkh@linuxfoundation.org>, syzkaller-bugs@googlegroups.com, syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com, Johan Hedberg <johan.hedberg@gmail.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org>, open list <linux-kernel@vger.kernel.org> Content-Transfer-Encoding: 8BIT Message-Id: <C0A907BA-9C0D-4124-A2AF-3748055DB062@holtmann.org> References: <000000000000c57f2d05ac4c5b8e@google.com> <20200823010022.938532-1-coiby.xu@gmail.com> To: Coiby Xu <coiby.xu@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.93 / 15.00 / 200.00 X-Rspamd-Queue-Id: 398B5A1405 X-Rspamd-UID: 8356f9 Hi Coiby, > When two HCI_EV_CONN_COMPLETE event packets with status=0 of the same > HCI connection are received, device_add would be called twice which > leads to kobject_add being called twice. Thus duplicate > (struct hci_conn *conn)->dev.kobj.entry would be inserted into > (struct hci_conn *conn)->dev.kobj.kset->list. > > This issue can be fixed by checking (struct hci_conn *conn)->debugfs. > If it's not NULL, it means the HCI connection has been completed and we > won't duplicate the work as for processing the first > HCI_EV_CONN_COMPLETE event. do you have a btmon trace for this happening? > Reported-and-tested-by: syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com > Link: https://syzkaller.appspot.com/bug?extid=dd768a260f7358adbaf9 > Signed-off-by: Coiby Xu <coiby.xu@gmail.com> > --- > net/bluetooth/hci_event.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 4b7fc430793c..1233739ce760 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -2605,6 +2605,11 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) > } > > if (!ev->status) { > + if (conn->debugfs) { > + bt_dev_err(hdev, "The connection has been completed"); > + goto unlock; > + } > + And instead of doing papering over a hole, I would rather detect that the HCI event is not valid since we already received one for this connection. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yDF4LlYhTV/XDgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 18:12:06 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0JWBLFYhTV8FsgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 18:12:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=dptechnics.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BB0E7A2686; Mon, 31 Aug 2020 18:11:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728544AbgHaQLl (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 12:11:41 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17170 "EHLO sender4-op-o11.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728461AbgHaQLj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 12:11:39 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1598890296; cv=none; d=zohomail.com; s=zohoarc; b=MWVWWnCvucgCabNqJKhKA9tHKAcbciG4m3ed9Gkq1Cqp1+g3+65BDTdkjtFxiDYZ+jkAi9mlexiqx2Pp3DyraELcVtO9Ey6O0Oz+4HshzMLkHKa8OZ2saDAEk1ITrvfnGfUe/u9lhJP8PBUelv5zcW7vQuVmt1haWMBHNQGLoCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598890296; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=i5ITdA55/iVGU4KTx2BMYFv/ttFKT7Cqa+Gi2cSOLb0=; b=UXOhM9RDA2yQsMruZWL+c48Q1LLP/gHM3nDc/1WR3YVLcbk+kOZIyuqvZ6/CvYZ+7m0mvTtqDi/EWsA4pcaV9TcpV/xR+UvhRsKfkYOZ/5SgAKSOC55G1xV1gwn8Ebrs43G7dCFu+OW3P0BAynKh7y1vxVo9jj/AlAJ1kWTNVo0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=dptechnics.com; spf=pass smtp.mailfrom=daan@dptechnics.com; dmarc=pass header.from=<daan@dptechnics.com> header.from=<daan@dptechnics.com> DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1598890296; s=zoho; d=dptechnics.com; i=daan@dptechnics.com; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=i5ITdA55/iVGU4KTx2BMYFv/ttFKT7Cqa+Gi2cSOLb0=; b=Y3AUOO6lj4IM3z0nn1Z+OTh3i40DFZxZN4chC13Lb0fifM2HrM0eLOj8hOsCNHVW TDqNW2ydxSyQ2g1jhcfpv88kPLys+qQf1L6hT5hhT6p0dd8rK7YEcogXIfa5GKpaFo3 ++inUWrMdUq5FforKNrPSsrcTaSygksT5ASsvTXA= Received: from daan-devbox.dptechnics.local (178-116-74-88.access.telenet.be [178.116.74.88]) by mx.zohomail.com with SMTPS id 1598890292793348.33179098134076; Mon, 31 Aug 2020 09:11:32 -0700 (PDT) From: Daan Pape <daan@dptechnics.com> To: linux-bluetooth@vger.kernel.org Cc: Daan Pape <daan@dptechnics.com> Message-ID: <20200831161116.15975-2-daan@dptechnics.com> Subject: [PATCH BlueZ 1/1] Mesh HCI interface init scan interval fixed Date: Mon, 31 Aug 2020 18:11:16 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200831161116.15975-1-daan@dptechnics.com> References: <20200831161116.15975-1-daan@dptechnics.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: BB0E7A2686 X-Rspamd-UID: 2cdb88 --- AUTHORS | 1 + mesh/mesh-io-generic.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 291d9b049..fd5d20cb2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -107,3 +107,4 @@ Micha=C5=82 Lowas-Rzechonek <michal.lowas-rzechonek@sil= vair.com> Jakub Witowski <jakub.witowski@silvair.com> Rafa=C5=82 Gajda <rafal.gajda@silvair.com> Szymon Czapracki <szymon.czapracki@codecoup.pl> +Daan Pape <daan@dptechnics.com> diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c index 67304d201..e65d87aab 100644 --- a/mesh/mesh-io-generic.c +++ b/mesh/mesh-io-generic.c @@ -213,8 +213,8 @@ static void configure_hci(struct mesh_io_private *io) =20 =09/* Set scan parameters */ =09cmd.type =3D 0x00; /* Passive Scanning. No scanning PDUs shall be sent = */ -=09cmd.interval =3D 0x0030; /* Scan Interval =3D N * 0.625ms */ -=09cmd.window =3D 0x0030; /* Scan Window =3D N * 0.625ms */ +=09cmd.interval =3D L_CPU_TO_LE16(0x0010); /* Scan Interval =3D N * 0.625m= s */ +=09cmd.window =3D L_CPU_TO_LE16(0x0010); /* Scan Window =3D N * 0.625ms */ =09cmd.own_addr_type =3D 0x00; /* Public Device Address */ =09/* Accept all advertising packets except directed advertising packets =09 * not addressed to this device (default). --=20 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0FI9E9QjTV/XDgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 18:22:44 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iFWJEdQjTV/RQwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 18:22:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 574C04210F; Mon, 31 Aug 2020 18:22:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728674AbgHaQWj (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 12:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727991AbgHaQWi (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 12:22:38 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D062C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 09:22:37 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id v69so5455682qkb.7 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 09:22:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=i5Ogqg2VyQTNNv++3yisqgKyfKOopi3chCdAdD44Hzk=; b=LOJbznAoM3Fed20IrO6FkRQz27mRoH6hsOAp0+8mTKJMICznfBfziZZKP55RMl9IjM D4ySrjTQvJTu2rpz3mNSeRPwDzpxjmAmJ4Q++MSXY1POqXHeEJ0z3g+8NaPxf4i5ClPd R2UpOYlOljCD4DT2CrdPNUzU1jZsp9Wk5pHrz4b//us4CD7dzgbzK1Tbm01H75m1Nb4e 7jPskDxv2g6kDoO7JLSLicvfdlkOFJn+9qDcBy4E0hJi5Bp2RDJ+9rd2Mp6uq9Hp6DA5 ivgYnHjAZSB166OD9gpBiWUVcp7EahuMfJJN158jEDW2fIO2H44LZPzsMPKTIe1JMWR/ vnRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=i5Ogqg2VyQTNNv++3yisqgKyfKOopi3chCdAdD44Hzk=; b=tJ6DUsursW68lZgyBCLuLLawMLoDzfuYpe1SBMrVL7wo90VjkvapqNzNXkH/H3/Thp k1TBMzyJAdUy1emXBBHaQfDrXg6EKa1RxHJv1Tl7NjLvsJk+l1Iw1sLtiLYBncyioDak k+jBlhIxzk647F61iPfnpYb98Pbjj8eHfz8oEu5M46oqP/vlnai+ewYdVToPBlUByzfY bsjBQSC3krn8MXxkbbFJwI0SewbyPtgpC6czyZgwwbRG4p24wVGji7gjfPPCjEFqSGml PQJsGah1sHKjnbD72AGIkcP3yN1jE2rYsAwF8MryRkyJ0p8iWmfURubAPs/q+7L9eqvI Erfg== X-Gm-Message-State: AOAM531QGTJAPPMEmxk9zGMxNzteg25JGksz1Je+jZBHc2htEeBCE0/N j4ETtxfTZtr7TqdcM5jSXYn/LRWEK07/Rg== X-Google-Smtp-Source: ABdhPJy8fO5GYyr3x29TBggmDcbrBqUPA5eCD86Hg4rnWgHUxzwFog8FX/nLxTmHUWIZVCputEuFMQ== X-Received: by 2002:ae9:e8c2:: with SMTP id a185mr2133165qkg.435.1598890955127; Mon, 31 Aug 2020 09:22:35 -0700 (PDT) Received: from [172.17.0.2] ([20.41.23.82]) by smtp.gmail.com with ESMTPSA id s184sm9612029qkf.50.2020.08.31.09.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 09:22:34 -0700 (PDT) Message-ID: <5f4d23ca.1c69fb81.2cc03.2119@mx.google.com> Date: Mon, 31 Aug 2020 09:22:34 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============0515897717102264515==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, daan@dptechnics.com Subject: RE: [BlueZ,1/1] Mesh HCI interface init scan interval fixed Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200831161116.15975-2-daan@dptechnics.com> References: <20200831161116.15975-2-daan@dptechnics.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: 574C04210F X-Rspamd-UID: 175cbf --===============0515897717102264515== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 3: B6 Body message is missing --- Regards, Linux Bluetooth --===============0515897717102264515==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4HK4F6IqTV9g3AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 18:51:46 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id oF5aFaIqTV8FsgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 18:51:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EB61740134; Mon, 31 Aug 2020 18:51:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728329AbgHaQvi (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 12:51:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbgHaQvh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 12:51:37 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E740BC061575 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 09:51:36 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id p37so918131pgl.3 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 09:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e0vvOvvHJGYF7a0Genu2fCkpngsUdQSUu8uEc44Bpec=; b=UzOsZYDpZRtoa3zdZGrzH2kjQLR4VT+DZn2shy2vnsl06x55wm8y65FeOgjXRxV55e HxkvO7V6BZW0+16tOURbnBnIHu/WjsjRe9An0i0j5mw2bIKBCkKXWhXmb0BSwWQ3b5/h WQ0S+FTtmqLPVmcYWDS4petTsGSqZhWjRFA0I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e0vvOvvHJGYF7a0Genu2fCkpngsUdQSUu8uEc44Bpec=; b=UB2cRtNwLWEnTscutqUVS8SNT3g2ubkIH25zj+hPTLZmGOF8TtM6ZMrjq85Dw4fJ0V 36Ot+0d57KIr8DUxEf62e/Ex7eUmKGLDxj5Bm5xeeMxKGaLXjC5ryYdN8VuIdeZwb1ff q5uAkg8KfXgViC23oDqW0TmvKR/6h1iZOYH88XT82pazXn0Qc4vwno+qjxg4Z17fpu91 T+/ruVEh29AYdy/wPGQiI/+5sz5aFH+LRiYGXyxmlh36P83e/4u66le+wcyIPYniJP3O s5wrex7VSPQmTBnVFLUvMlMmA7XkOEZjfuWzJXJbk6U67zjtgNiYryYV2ZckABMMIK11 gSUA== X-Gm-Message-State: AOAM533U/pmOVxWlDChtxwz4NY4UD6LjvoHcimakG1jb+nzRrlf+urgY qCCJKisjGRudzTx2pqEp1Omm8w== X-Google-Smtp-Source: ABdhPJx+lLDch40/FsX48QUf1KjmhYjA47S013g5ttuztFBm4bL4RjoNUNMuail4dby1mDZKmeW8+g== X-Received: by 2002:a63:5160:: with SMTP id r32mr2003729pgl.112.1598892696285; Mon, 31 Aug 2020 09:51:36 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id k5sm8189082pgk.78.2020.08.31.09.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 09:51:35 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [PATCH v2] Bluetooth: Clear suspend tasks on unregister Date: Mon, 31 Aug 2020 09:51:27 -0700 Message-Id: <20200831095119.v2.1.I24fb6cc377d03d64d74f83cec748afd12ee33e37@changeid> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: EB61740134 X-Rspamd-UID: f315ed While unregistering, make sure to clear the suspend tasks before cancelling the work. If the unregister is called during resume from suspend, this will unnecessarily add 2s to the resume time otherwise. Fixes: 4e8c36c3b0d73d (Bluetooth: Fix suspend notifier race) Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- This was discovered with RT8822CE using the btusb driver. This chipset will reset on resume during system suspend and was unnecessarily adding 2s to every resume. Since we're unregistering anyway, there's no harm in just clearing the pending events. Changes in v2: - ++i to i++ net/bluetooth/hci_core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 68bfe57b66250f..efc0fe2b47dac2 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3442,6 +3442,16 @@ void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, } } +static void hci_suspend_clear_tasks(struct hci_dev *hdev) +{ + int i; + + for (i = 0; i < __SUSPEND_NUM_TASKS; i++) + clear_bit(i, hdev->suspend_tasks); + + wake_up(&hdev->suspend_wait_q); +} + static int hci_suspend_wait_event(struct hci_dev *hdev) { #define WAKE_COND \ @@ -3785,6 +3795,7 @@ void hci_unregister_dev(struct hci_dev *hdev) cancel_work_sync(&hdev->power_on); unregister_pm_notifier(&hdev->suspend_notifier); + hci_suspend_clear_tasks(hdev); cancel_work_sync(&hdev->suspend_prepare); hci_dev_do_close(hdev); -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mOnpOdIqTV/gmgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 18:52:34 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uGO/ONIqTV+E9gAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 18:52:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 05463A1411; Mon, 31 Aug 2020 18:52:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728798AbgHaQwM (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 12:52:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728796AbgHaQwI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 12:52:08 -0400 Received: from mail-vs1-xe44.google.com (mail-vs1-xe44.google.com [IPv6:2607:f8b0:4864:20::e44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32113C061755 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 09:52:08 -0700 (PDT) Received: by mail-vs1-xe44.google.com with SMTP id e14so3574257vsa.9 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 09:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v2wssN0DfVl0Q5ulsK8rehD0qys9A1UTSyxawRAlJec=; b=PKX3NGBdootImldgizkUZ9JNq2aRTpLy+LDPXgaGjN67aJZcX5pKbxjF6UCyW/HP/1 1xIphJEPk/1dlpzCnvwdr8psoRTZ4SQXSMEmtmvUrQlJjlhEMVNcqa79KrQe88WEXmBS Tu8vgti347fq8k6r++gj5T7TkTnDDswBF6FeM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=v2wssN0DfVl0Q5ulsK8rehD0qys9A1UTSyxawRAlJec=; b=HlZq5u4jS48QwCwGskxHE71/vn6LKZ6/m7htwyWpirlFHddRBev+MJcP9G4xZj98v4 BD2c00Ph62Iemx0x/hKo8FZf7zfXlHzkjJqjJAlkGOWABOEf4xls7q+zgnPW3HHof+4B a+xt/OZBa0C/ngSkwn6CxjshgAgKpa8W5Xk6gc/qMjG10Jrdu2cHgENZihuhqJO9TlzR l8xwzCvGg02S7S4AKcXESjCvfzXymph6kGvGT98o4hx8T9sp/szMtX6tPeShxnP6qgD+ 0/jvBPG0mvRZCdXqMBcD6ub+CkeUDUf69DzWe7fsrgAXojiPYk5vR166ZxqhtYwu2kUh CFdA== X-Gm-Message-State: AOAM533AIwlkdy4wQ/nYsEvnMikuo2jC/uZWCdGmPN44MbWomscZ1Kzp q6kDhPVg0meRqPTLyATDYvYExnRwHaqAbwSMc8JOxA== X-Google-Smtp-Source: ABdhPJzRl4IzM+/5e+TD8Pd7j+A6SmKTwYoGY5YNvdrKb+tJbT1J0kMH3uJc5Yi9i1lQvDnOm0uTXj7cCiaXUmoq3bo= X-Received: by 2002:a05:6102:1045:: with SMTP id h5mr2083568vsq.42.1598892727414; Mon, 31 Aug 2020 09:52:07 -0700 (PDT) MIME-Version: 1.0 References: <20200826154719.1.I24fb6cc377d03d64d74f83cec748afd12ee33e37@changeid> <A69701BE-FBB3-4053-8187-618C0BD4B380@holtmann.org> In-Reply-To: <A69701BE-FBB3-4053-8187-618C0BD4B380@holtmann.org> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Mon, 31 Aug 2020 09:51:56 -0700 Message-ID: <CANFp7mXY7--Mziduq69gUj5cgCiZCZ-47JOpBNL6H0bLpN2bbQ@mail.gmail.com> Subject: Re: [PATCH] Bluetooth: Clear suspend tasks on unregister To: Marcel Holtmann <marcel@holtmann.org> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev <netdev@vger.kernel.org>, kernel list <linux-kernel@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.78 / 15.00 / 200.00 X-Rspamd-Queue-Id: 05463A1411 X-Rspamd-UID: 7b632c v2 sent with fix. On Mon, Aug 31, 2020 at 8:49 AM Marcel Holtmann <marcel@holtmann.org> wrote: > > Hi Abhishek, > > > While unregistering, make sure to clear the suspend tasks before > > cancelling the work. If the unregister is called during resume from > > suspend, this will unnecessarily add 2s to the resume time otherwise. > > > > Fixes: 4e8c36c3b0d73d (Bluetooth: Fix suspend notifier race) > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > --- > > This was discovered with RT8822CE using the btusb driver. This chipset > > will reset on resume during system suspend and was unnecessarily adding > > 2s to every resume. Since we're unregistering anyway, there's no harm in > > just clearing the pending events. > > > > net/bluetooth/hci_core.c | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > > index 68bfe57b66250f..ed4cb3479433c0 100644 > > --- a/net/bluetooth/hci_core.c > > +++ b/net/bluetooth/hci_core.c > > @@ -3442,6 +3442,16 @@ void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, > > } > > } > > > > +static void hci_suspend_clear_tasks(struct hci_dev *hdev) > > +{ > > + int i; > > + > > + for (i = 0; i < __SUSPEND_NUM_TASKS; ++i) > > + clear_bit(i, hdev->suspend_tasks); > > I prefer i++ instead of ++i. > > Regards > > Marcel > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uNgnGg4sTV/gmgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 18:57:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id oJQ5GQ4sTV+brgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 18:57:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E1CE3A1687; Mon, 31 Aug 2020 18:57:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728383AbgHaQ5m (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 12:57:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727929AbgHaQ5k (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 12:57:40 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 509CBC061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 09:57:40 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id u126so219288oif.13 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 09:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wCvkvd1UYmEI0NU5tyMK6CLs+MKQ+O6ZyATWPxd+MyA=; b=JLTnFjVMgRK40l5XPk+Ek5aPtTtB7SPZD2G4yGf46xwB3xuBSwLoYvbPy69wFuf90Y BlkFM3wVV7kUjn4fxk47oF+usix36AfZqsnXzyb197ZE37BdXg0jx6QiO1smWSFzKR/u McJ10UkAQyXgZ8z8SfAg/A2OKJJY/7Q3gQS8nO9HugCPU6WUUjt/Gu4qGJAr0T2XfDXh EQDA7aOySkeNwqeh4wF9FFEI2m/Hp+TtltoYTJ6pDfXcyIgL+L6US3HmdGkTtKX4+L8b QAb02+Ql6yyUrnxgGretHV7Vn1v21hhyfbW/TmnUxEh7gdk84Q3ly3CdWBvW5D9v4lp4 BeQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wCvkvd1UYmEI0NU5tyMK6CLs+MKQ+O6ZyATWPxd+MyA=; b=pMxxW3CzZ02VXdIO86k6VcP0ZRi8a6dzfZsUmi/dOg9IBe6QyfCyCP+kCAc4ml18xT nqdvwFPWNKQLlJdopa6JWkrQakg9ZsWBZeI6rn+3o9fTlk/ZmXl3LDpwDwl5BjuXiJF/ PsF51ZpjpttiJM3ekQKTT6Wv6H315k8bSA0Irsfvfdgg7oEbx1iZB33WAbelwpMBavIR 0EFeZAJS2ag2cX5CQnCslHIxfjgfhlBfpP289TQLExxdH9Nr2TAkjt4X+LVgqu5RDDfC Od3jCD5cMrPYu8W59HwNTCrcsNLKURRx4vrUZwYxazC01khL2iNPIAf4Ts/6IJ2sk0cz 0VzA== X-Gm-Message-State: AOAM532IeqQSU31fsYqIQDaaHGsxe1S7cXAtiuOcpv3kWs7/WOBWp7Vu K0rxZLCyemw41Qv7Q16j+OBor/Ah/tuEYSTEcIw= X-Google-Smtp-Source: ABdhPJyMN6TpsG0lVpAOFpJhJI3JosJU/j5IXNI2Ee3LaXo944LTgDShxtI9SvPEK8Cc193DkJkxTxg7lugJmcRev3Q= X-Received: by 2002:aca:a9c9:: with SMTP id s192mr178702oie.152.1598893059439; Mon, 31 Aug 2020 09:57:39 -0700 (PDT) MIME-Version: 1.0 References: <20200829010210.871471-1-abhishekpandit@chromium.org> <20200828180157.Bluez.v3.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> In-Reply-To: <20200828180157.Bluez.v3.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 31 Aug 2020 09:57:29 -0700 Message-ID: <CABBYNZJDfjSWFDStLLb+Oe46Zhuqjem=xxZoEkeDNXgyKQj6KA@mail.gmail.com> Subject: Re: [Bluez PATCH v3 3/3] policy: Reconnect audio on controller resume To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: E1CE3A1687 X-Rspamd-UID: 0d2a5a Hi Abhishek, On Fri, Aug 28, 2020 at 6:02 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > During system suspend, all peer devices are disconnected. On resume, HID > devices will reconnect but audio devices stay disconnected. As a quality > of life improvement, mark audio devices that were disconnected due to > suspend and attempt to reconnect them when the controller resumes (after > a delay for better co-existence with Wi-Fi). > > --- > > Changes in v3: > - Refactored resume notification to use btd_adapter_driver > - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 > - Added A2DP_SINK_UUID to default reconnect list > > Changes in v2: > - Refactored to use policy instead of connecting directly in adapter > > plugins/policy.c | 80 +++++++++++++++++++++++++++++++++++++++--------- > src/adapter.c | 36 ++++++++++++++++++++++ > src/adapter.h | 2 ++ > src/main.c | 1 + > src/main.conf | 11 ++++++- > 5 files changed, 115 insertions(+), 15 deletions(-) > > diff --git a/plugins/policy.c b/plugins/policy.c > index de51e58b9..5ab65b991 100644 > --- a/plugins/policy.c > +++ b/plugins/policy.c > @@ -62,10 +62,12 @@ struct reconnect_data { > guint timer; > bool active; > unsigned int attempt; > + bool on_resume; > }; > > static const char *default_reconnect[] = { > - HSP_AG_UUID, HFP_AG_UUID, A2DP_SOURCE_UUID, NULL }; > + HSP_AG_UUID, HFP_AG_UUID, A2DP_SOURCE_UUID, > + A2DP_SINK_UUID, NULL }; Lets have this change in a separate patch. > static char **reconnect_uuids = NULL; > > static const size_t default_attempts = 7; > @@ -75,6 +77,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; > static int *reconnect_intervals = NULL; > static size_t reconnect_intervals_len = 0; > > +static const int default_resume_delay = 2; > +static int resume_delay; > + > static GSList *reconnects = NULL; > > static unsigned int service_id = 0; > @@ -711,6 +716,9 @@ static gboolean reconnect_timeout(gpointer data) > /* Mark the GSource as invalid */ > reconnect->timer = 0; > > + /* Mark any reconnect on resume as handled */ > + reconnect->on_resume = false; > + > err = btd_device_connect_services(reconnect->dev, reconnect->services); > if (err < 0) { > error("Reconnecting services failed: %s (%d)", > @@ -724,14 +732,17 @@ static gboolean reconnect_timeout(gpointer data) > return FALSE; > } > > -static void reconnect_set_timer(struct reconnect_data *reconnect) > +static void reconnect_set_timer(struct reconnect_data *reconnect, int timeout) > { > - static int timeout = 0; > + static int interval_timeout = 0; > > reconnect->active = true; > > if (reconnect->attempt < reconnect_intervals_len) > - timeout = reconnect_intervals[reconnect->attempt]; > + interval_timeout = reconnect_intervals[reconnect->attempt]; > + > + if (timeout < 0) > + timeout = interval_timeout; > > DBG("attempt %u/%zu %d seconds", reconnect->attempt + 1, > reconnect_attempts, timeout); > @@ -743,10 +754,14 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) > static void disconnect_cb(struct btd_device *dev, uint8_t reason) > { > struct reconnect_data *reconnect; > + struct btd_service *service; > + struct policy_data *data; > > DBG("reason %u", reason); > > - if (reason != MGMT_DEV_DISCONN_TIMEOUT) > + /* Only attempt reconnect for the following reasons */ > + if (reason != MGMT_DEV_DISCONN_TIMEOUT && > + reason != MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND) We might want to rework this to have the reason just checked once. > return; > > reconnect = reconnect_find(dev); > @@ -755,10 +770,40 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > reconnect_reset(reconnect); > > - DBG("Device %s identified for auto-reconnection", > - device_get_path(dev)); > + DBG("Device %s identified for auto-reconnection", device_get_path(dev)); > > - reconnect_set_timer(reconnect); > + switch(reason) > + { > + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: > + if (btd_device_get_service(dev, A2DP_SINK_UUID)) { > + reconnect->on_resume = true; > + DBG("%s configured to reconnect on resume", > + device_get_path(dev)); I thought your idea was to set the timer here and then reset it on_resume so it would work even when the kernel does not indicate the resume with an event. > + } > + break; > + case MGMT_DEV_DISCONN_TIMEOUT: > + reconnect_set_timer(reconnect, -1); > + break; > + default: > + DBG("Developer error. Reason = %d", reason); > + break; > + } > +} > + > +static void policy_adapter_resume(struct btd_adapter *adapter, > + uint8_t wake_reason, const bdaddr_t *addr, > + const uint8_t addr_type) > +{ > + GSList *l; > + > + /* Check if any devices needed to be reconnected on resume */ > + for (l = reconnects; l; l = g_slist_next(l)) { > + struct reconnect_data *reconnect = l->data; We should be checking if the reconnect matches the adapter otherwise this could potentially call reconnect_set_timer multiple times for the same device if there are multiple adapters on the system. > + if (reconnect->on_resume) { > + reconnect_set_timer(reconnect, resume_delay); > + } > + } > } > > static void conn_fail_cb(struct btd_device *dev, uint8_t status) > @@ -786,14 +831,15 @@ static void conn_fail_cb(struct btd_device *dev, uint8_t status) > return; > } > > - reconnect_set_timer(reconnect); > + reconnect_set_timer(reconnect, -1); > } > > static int policy_adapter_probe(struct btd_adapter *adapter) > { > DBG(""); > > - btd_adapter_restore_powered(adapter); > + if (auto_enable) > + btd_adapter_restore_powered(adapter); > > return 0; > } > @@ -801,6 +847,7 @@ static int policy_adapter_probe(struct btd_adapter *adapter) > static struct btd_adapter_driver policy_driver = { > .name = "policy", > .probe = policy_adapter_probe, > + .resume = policy_adapter_resume, > }; > > static int policy_init(void) > @@ -854,14 +901,20 @@ static int policy_init(void) > auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", > NULL); > > + resume_delay = g_key_file_get_integer( > + conf, "Policy", "ResumeDelay", &gerr); > + > + if (gerr) { > + g_clear_error(&gerr); > + resume_delay = default_resume_delay; > + } > done: > if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { > btd_add_disconnect_cb(disconnect_cb); > btd_add_conn_fail_cb(conn_fail_cb); > } > > - if (auto_enable) > - btd_register_adapter_driver(&policy_driver); > + btd_register_adapter_driver(&policy_driver); > > return 0; > } > @@ -882,8 +935,7 @@ static void policy_exit(void) > > btd_service_remove_state_cb(service_id); > > - if (auto_enable) > - btd_unregister_adapter_driver(&policy_driver); > + btd_unregister_adapter_driver(&policy_driver); > } > > BLUETOOTH_PLUGIN_DEFINE(policy, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, > diff --git a/src/adapter.c b/src/adapter.c > index 1435e2bd7..bf355bfa7 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -8776,6 +8776,37 @@ static void connected_callback(uint16_t index, uint16_t length, > eir_data_free(&eir_data); > } > > +static void controller_resume_notify(struct btd_adapter *adapter, > + const uint8_t wake_reason, > + const bdaddr_t *addr, > + const uint8_t addr_type) > +{ > + GSList *l; > + > + for (l = adapter->drivers; l; l = g_slist_next(l)) { > + struct btd_adapter_driver *driver = l->data; > + if (driver->resume) > + driver->resume(adapter, wake_reason, addr, addr_type); This should be in a separate patch, also not sure what is the reason to pass the address and addr_type on the resume callback? If the callback requires that it can query it internally. > + } > +} > + > +static void controller_resume_callback(uint16_t index, uint16_t length, > + const void *param, void *user_data) > +{ > + const struct mgmt_ev_controller_resume *ev = param; > + struct btd_adapter *adapter = user_data; > + > + if (length < sizeof(*ev)) { > + btd_error(adapter->dev_id, "Too small device resume event"); > + return; > + } > + > + info("Controller resume with wake event 0x%x", ev->wake_reason); > + > + controller_resume_notify(adapter, ev->wake_reason, &ev->addr.bdaddr, > + ev->addr.type); > +} > + > static void device_blocked_callback(uint16_t index, uint16_t length, > const void *param, void *user_data) > { > @@ -9399,6 +9430,11 @@ static void read_info_complete(uint8_t status, uint16_t length, > user_passkey_notify_callback, > adapter, NULL); > > + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, > + adapter->dev_id, > + controller_resume_callback, > + adapter, NULL); > + > set_dev_class(adapter); > > set_name(adapter, btd_adapter_get_name(adapter)); > diff --git a/src/adapter.h b/src/adapter.h > index f8ac20261..b81ef6a04 100644 > --- a/src/adapter.h > +++ b/src/adapter.h > @@ -113,6 +113,8 @@ struct btd_adapter_driver { > const char *name; > int (*probe) (struct btd_adapter *adapter); > void (*remove) (struct btd_adapter *adapter); > + void (*resume)(struct btd_adapter *adapter, uint8_t wake_reason, > + const bdaddr_t *addr, const uint8_t addr_type); > }; > > typedef void (*service_auth_cb) (DBusError *derr, void *user_data); > diff --git a/src/main.c b/src/main.c > index b37c32948..038f867b5 100644 > --- a/src/main.c > +++ b/src/main.c > @@ -131,6 +131,7 @@ static const char *policy_options[] = { > "ReconnectAttempts", > "ReconnectIntervals", > "AutoEnable", > + "ResumeDelay", > NULL > }; > > diff --git a/src/main.conf b/src/main.conf > index 42f7e41c5..9f882e65a 100644 > --- a/src/main.conf > +++ b/src/main.conf > @@ -186,7 +186,7 @@ > # timeout). The policy plugin should contain a sane set of values by > # default, but this list can be overridden here. By setting the list to > # empty the reconnection feature gets disabled. > -#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb > +#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb,0000110b-0000-1000-8000-00805f9b34fb > > # ReconnectAttempts define the number of attempts to reconnect after a link > # lost. Setting the value to 0 disables reconnecting feature. > @@ -202,3 +202,12 @@ > # This includes adapters present on start as well as adapters that are plugged > # in later on. Defaults to 'false'. > #AutoEnable=false > + > +# Audio devices that were disconnected due to suspend will be reconnected on > +# resume. ResumeDelay determines the delay between when the controller > +# resumes from suspend and a connection attempt is made. A longer delay is > +# better for better co-existence with Wi-Fi. > +# The value is in seconds. > +# Default: 2 > +#ResumeDelay = 2 > + > -- > 2.28.0.402.g5ffc5be6b7-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +M3lOoEwTV/gmgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 19:16:49 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 8LolOYEwTV8ZdQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 19:16:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 64FEFA21F5; Mon, 31 Aug 2020 19:16:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728270AbgHaRQl (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 13:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726791AbgHaRQl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 13:16:41 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F36FDC061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 10:16:40 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id z22so1613692oid.1 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 10:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WXz+RjXMfOPYNS9vVem6858n/gkouE3nAc/3H+2U+Tk=; b=GQ/9wXpjc0tG0WXMbdmJbK2/qGlNtu2uP3Cm/QQHFUFgReBiC5V/uUooSfTF13vbCS axsHJvXEFNjwpcyWMGPdHs3FX9/04vGTf0yZBxnylEI+IbgLVb2U8dXS/LK+2pehuVO3 LxJePSYXFxmEdjR0NTMBR4hJ2HGwcKveQ5ESPJFxzpbAurGyIJBT9Z9Q241xBi1I/4ft YzCkPm5ynrTWmzLVf7knYY3ZFW9MI4mdSbJvDhhV0T5SimEWei8k2kzuKrT/Oi+UOgeF cdEQOOYy8T15f6pTH5Zh8GkrDsD9ggS4D/oEAxHV8HSei3VwsEO9r4GiGNSjZMrgBCtH pbRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WXz+RjXMfOPYNS9vVem6858n/gkouE3nAc/3H+2U+Tk=; b=Fj3/8r4lhR6jBDdNLwya26x3wFDK3wLDe1IHa+4a4bbw1K9l/b011d8z1i8vEojwzA ntk6SDeKyEKDkeQD86q9WBov+NzDkUe2AT39Dibz7UiSe7BGCdbDd0TyUituxZoWSYMH Xjmi02a9um8sGsFn3HFycmzEp8777XGMIuSwrqu0n07mJwp+POv9PA6QEnx/UHhYepMD XDQdeMi2w/2SjTvMsJGGhRcz9wI+VfAVI1gmxPW6xNmFBbwjA471cusDVB0b890GUsRM fzTMwfyyRLe0pGMX9ZfzeZjRGShvX52rshmAxwNjbBMqMz5ex/T/R7CudauqidQpUBjh MC8A== X-Gm-Message-State: AOAM532bNP1bv7cje3IJ7MxD7vAEY7IPVilZKqhgjPsQFILnPl5/MkmU DXzXkCoJglzwxHLMColXvtdIA4FKWuE2g3HkPA1RXUnK X-Google-Smtp-Source: ABdhPJzXNd+r8tQo83V7t7ymY1VwlOZcbmGI0BCGOUOmkLOhNYS4cISq6SNHtqlnSQZuoMZDxuYLipnlSpuxagvqT70= X-Received: by 2002:aca:a9c9:: with SMTP id s192mr220457oie.152.1598894199341; Mon, 31 Aug 2020 10:16:39 -0700 (PDT) MIME-Version: 1.0 References: <20200831153544.Bluez.v1.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> In-Reply-To: <20200831153544.Bluez.v1.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 31 Aug 2020 10:16:29 -0700 Message-ID: <CABBYNZ+Q84vmEDgfNuoYXAAMi6T3segO_hSkG5Oufc5F_w9Qeg@mail.gmail.com> Subject: Re: [Bluez PATCH v1 1/2] doc/media-api: Add Press method for MediaPlayer1 To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: 64FEFA21F5 X-Rspamd-UID: e583bd Hi Archie, On Mon, Aug 31, 2020 at 12:37 AM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > This allows us to send any passthrough command. > > Reviewed-by: Michael Sun <michaelfsun@google.com> > --- > > doc/media-api.txt | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/doc/media-api.txt b/doc/media-api.txt > index dabc69936..fe7222eef 100644 > --- a/doc/media-api.txt > +++ b/doc/media-api.txt > @@ -199,6 +199,14 @@ Methods void Play() > Possible Errors: org.bluez.Error.NotSupported > org.bluez.Error.Failed > > + void Press(byte avc_key) > + > + Press a specific key to send as passthrough command. > + > + Possible Errors: org.bluez.Error.InvalidArguments > + org.bluez.Error.NotSupported > + org.bluez.Error.Failed > + > Properties string Equalizer [readwrite] > > Possible values: "off" or "on" > -- > 2.28.0.402.g5ffc5be6b7-goog For now I would prefer to use dedicated method per key or are there many keys you would like to use from the upper layer? -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gNdID1oxTV/gmgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 19:20:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OJvdDVoxTV+KAQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 19:20:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9BC6E420F4; Mon, 31 Aug 2020 19:20:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728869AbgHaRUR (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 13:20:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726791AbgHaRUQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 13:20:16 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBA5DC061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 10:20:15 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id h17so5981413otl.9 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 10:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1IzJEopicGDPL2oMYcs87CbSRYx5MMY1Eccm67ldgkw=; b=uJwz38bAn/fZ1ojGptuEUEA9s7LYOxamKwJWKwX9ocW5IhZwkDZxq3nfAFM+iZH4ve ntWvzBmttmTEGt91PxxNZifpc9aPE+mqrMwGeebl/P3wMHIDOPQT/GZbluRYquOmAfjJ 2cqvWomTVzSkO16o8WowVf+0O02MpNWDK94vzObNRjj2n8qPTA4jVhFduZFOcOHqqu7j 0ycUEXipRMXVjNkir2o8vWMnhMfGLJeGApttlcj3RS1TzMeMJi1xDxp5LKJ9x0Cp1VtI Fvdu7XbjoQXy1s0ZRYqhWGyriIQoOh2xHdX9QypLRe55HlnUcbxPeYWBNpy28CyRIkNT LUBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1IzJEopicGDPL2oMYcs87CbSRYx5MMY1Eccm67ldgkw=; b=n01SegU1c+1foxS6salIJFYy2NfSYTkIAIHAk5SKbe/SXvho473B1GJ/J1Nhdq9gkV /wsY1XkKBSazL+tcukas1MEDtCWgFdAm224YJbi3yFSY7Q/ev/rgJxXS0MfuTixOqrSd oUmTsCIAnNAanNc/7/Kwpov7kZSRC6zv+3sp5iSxpWjwxjkf+AuyzqtB2drXMpY81Ep4 d+AoGhbbW++9RFQzvjJ8JRARyIqx+m6D5/oh0KZM5y5ZVoG8K/YSTGbNX/4NpCTk1/cI qVN1WsSVIuk6akdBtkQPYBJx/yzujgNsOsSdarsIruo5emdg51cY2mjbXTHBCI+YqzQV gvmA== X-Gm-Message-State: AOAM533djgl+8SvKjEctDMHwPkEuf8Uy816dvhXR3FSkZ0UdkzvU4c+o xRT4tIUe9uPZWUwC8XrSDZUjA234GOMr4/mtMFA= X-Google-Smtp-Source: ABdhPJwDKbNnYCHrbNVp864QnkJthxhtmCXUcSv4wkI4T6VnPFM49YnjCdn6VTNnLOtDiXgmZgeMZ7wyn4wnxoMhhTE= X-Received: by 2002:a9d:6053:: with SMTP id v19mr1540513otj.362.1598894415317; Mon, 31 Aug 2020 10:20:15 -0700 (PDT) MIME-Version: 1.0 References: <20200831154443.Bluez.v1.1.Ieeae14ab680eda03474551fdb7a0a020f950e9c1@changeid> In-Reply-To: <20200831154443.Bluez.v1.1.Ieeae14ab680eda03474551fdb7a0a020f950e9c1@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 31 Aug 2020 10:20:05 -0700 Message-ID: <CABBYNZJhkBJY7+Y73tdpV_ca5dmoiYhutq5iONAMbCjD+EL+zQ@mail.gmail.com> Subject: Re: [Bluez PATCH v1] media: Don't set initial volume if it's invalid To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com>, Yu Liu <yudiliu@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.22 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9BC6E420F4 X-Rspamd-UID: 6be96b Hi Archie, On Mon, Aug 31, 2020 at 12:45 AM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > When initializing media transport, we try to initialize the volume > of the player. However, the assigned initial volume could be invalid > due to the session has not been initialized, or when we assume the > role of audio sink. In this case, we should not assign the initial > volume. Not really following the explanation here, if the session has not been initialized yet shouldn't the volume be actually invalid? Or is the problem that we don't call media_transport_update_volume later when it is initialized? > Reviewed-by: Michael Sun <michaelfsun@google.com> > Reviewed-by: Yu Liu <yudiliu@google.com> > --- > > profiles/audio/media.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/profiles/audio/media.c b/profiles/audio/media.c > index 02bf82a49..acb4a8ee9 100644 > --- a/profiles/audio/media.c > +++ b/profiles/audio/media.c > @@ -494,7 +494,8 @@ static gboolean set_configuration(struct media_endpoint *endpoint, > return FALSE; > > init_volume = media_player_get_device_volume(device); > - media_transport_update_volume(transport, init_volume); > + if (init_volume >= 0) > + media_transport_update_volume(transport, init_volume); You can probably move the check to be done internally inside update_volume. > msg = dbus_message_new_method_call(endpoint->sender, endpoint->path, > MEDIA_ENDPOINT_INTERFACE, > -- > 2.28.0.402.g5ffc5be6b7-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uIzDEPs0TV8rSgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 19:35:55 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SOvlDvs0TV9m+QEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 19:35:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A471D420DA; Mon, 31 Aug 2020 19:35:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726686AbgHaRfq (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 13:35:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbgHaRfp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 13:35:45 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83CBDC061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 10:35:45 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id n23so6013646otq.11 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 10:35:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Z5VXzSpw3QdED1GgJDUjwLnGvGiM8SjQjH0TUfY3Ysc=; b=YlxgEndmh6kJiMlHMARt7f57E5pCD7FKzwAUcgEVAAgKWE2hXYXcPu+KK8mLJUQJH6 9ouA/yf5vbhJoP8Km+c8pZB1g/a11gvlHRiab4VW7ZwpD3lF3ktb0w41g1YBw/kTmtjm yUjD5F1DK+5If+pxcyqvB8gO5wVCP5Xaqwa6NvEGw5JT52JQpDdjxLWjz4VYwrsQSIQm Ab/nqFdQ4puQLQS2WnYOwKebp2b1JZa1TMC359Z5ZFD5iA3Fv//1pZ9QssT9yj3kjqjO C7pD6N8FKlK0/pUST6RQIZ3WKvcacMufRoOQ0h6uyxSxvIq8jU9AdP4DYZwFDvGi+JVz L+NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Z5VXzSpw3QdED1GgJDUjwLnGvGiM8SjQjH0TUfY3Ysc=; b=hJAP/K3h48pghN3M8QOyRko0w8Wa20dA4mqe9KG8YoPO7RRarUKCUf4EySX+IjYYod U3ZVW955IP3Cp/6cNMHgKB/nPtbLcFEg0WIqSIbjhY7GTqsEU7iOq0iD9sezVw5zgvme TgMT4ejuDtk9cbLONFQBevA6Vt1PUKWMw92DrkTC5Z5tN2+5Zm6GQ8WA+YXoqStN2z0Q x13o+UnzXS7Jn4eY9nZBwWOroOPa8PcoB8T5nP8ckCYvY/D5pNpmpt3g/DG719+n9AyB ZK/t6h7qapW4r2DGLgDVvTYKeHeT6CK/8x2a3KHzWA4ECrrfI0y2xmCvrwOdiJqqQxYJ C17A== X-Gm-Message-State: AOAM530JK14HST5ckPdBPz25HetXXw0n6NnHRXmmnIctbYZtzoykmfSS fKMJlaS6qU8U09F9FasLsQMenzmM4AlneL0eo1A= X-Google-Smtp-Source: ABdhPJzLO15tBkAivoQ6Z/upf1o7yj6nWEkEfAtB87tMBE701lCbJOQ8q7qlYtbuoVLieiEPTk5fqvHuWda3imEbKr8= X-Received: by 2002:a9d:6053:: with SMTP id v19mr1576552otj.362.1598895344667; Mon, 31 Aug 2020 10:35:44 -0700 (PDT) MIME-Version: 1.0 References: <20200831161140.Bluez.v1.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> In-Reply-To: <20200831161140.Bluez.v1.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 31 Aug 2020 10:35:34 -0700 Message-ID: <CABBYNZLTY_cFcttmMdiBH7PNU1xT2bw-eKnOQkHDak3+Y8WrXQ@mail.gmail.com> Subject: Re: [Bluez PATCH v1] device: don't wait for timeout if RemoveDevice is called To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.74 / 15.00 / 200.00 X-Rspamd-Queue-Id: A471D420DA X-Rspamd-UID: 3a5821 Hi Archie, On Mon, Aug 31, 2020 at 1:12 AM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > RemoveDevice on adapter interface used to remove a device, even when > the device is connected. However, since the introduction of the new > 30 seconds timeout when setting a device as temporary, RemoveDevice > doesn't immediately remove a connected device, but only disconnects > it and waits for the timer to expire before effectively removes it. > > This patch removes the device as soon as it gets disconnected, > provided the disconnection is triggered by a call to RemoveDevice. > The regular timeout still applies for other cases. > > Tested manually by calling RemoveDevice on a connected device, > and with ChromeOS autotest setup. > > Reviewed-by: Daniel Winkler <danielwinkler@google.com> > --- > > src/adapter.c | 2 -- > src/adapter.h | 2 ++ > src/device.c | 11 +++++++++++ > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..d6c65ff69 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -79,8 +79,6 @@ > #include "advertising.h" > #include "eir.h" > > -#define ADAPTER_INTERFACE "org.bluez.Adapter1" > - > #define MODE_OFF 0x00 > #define MODE_CONNECTABLE 0x01 > #define MODE_DISCOVERABLE 0x02 > diff --git a/src/adapter.h b/src/adapter.h > index f8ac20261..f835c984f 100644 > --- a/src/adapter.h > +++ b/src/adapter.h > @@ -26,6 +26,8 @@ > #include <dbus/dbus.h> > #include <glib.h> > > +#define ADAPTER_INTERFACE "org.bluez.Adapter1" > + > #define MAX_NAME_LENGTH 248 > > /* Invalid SSP passkey value used to indicate negative replies */ > diff --git a/src/device.c b/src/device.c > index bb8e07e8f..cee0ddfd2 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -3001,6 +3001,7 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type) > void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > { > struct bearer_state *state = get_state(device, bdaddr_type); > + bool remove_device = false; > > if (!state->connected) > return; > @@ -3018,6 +3019,10 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > while (device->disconnects) { > DBusMessage *msg = device->disconnects->data; > > + if (dbus_message_is_method_call(msg, ADAPTER_INTERFACE, > + "RemoveDevice")) > + remove_device = true; > + > g_dbus_send_reply(dbus_conn, msg, DBUS_TYPE_INVALID); > device->disconnects = g_slist_remove(device->disconnects, msg); > dbus_message_unref(msg); > @@ -3043,6 +3048,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > > g_dbus_emit_property_changed(dbus_conn, device->path, > DEVICE_INTERFACE, "Connected"); > + > + if (remove_device) > + btd_adapter_remove_device(device->adapter, device); > } > > guint device_add_disconnect_watch(struct btd_device *device, > @@ -4457,6 +4465,9 @@ void device_remove(struct btd_device *device, gboolean remove_stored) > disconnect_all(device); > } > > + if (device->temporary_timer > 0) > + g_source_remove(device->temporary_timer); > + > if (device->store_id > 0) { > g_source_remove(device->store_id); > device->store_id = 0; > -- > 2.28.0.402.g5ffc5be6b7-goog Does not apply: Applying: device: don't wait for timeout if RemoveDevice is called error: patch failed: src/device.c:3001 error: src/device.c: patch does not apply -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2Al+CU81TV9JuwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 19:37:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kHfNB081TV/RQwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 19:37:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A9B10420FC; Mon, 31 Aug 2020 19:37:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727944AbgHaRhA (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 13:37:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727963AbgHaRg7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 13:36:59 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EBD2C061575 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 10:36:58 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id u126so332113oif.13 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 10:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Zbf92dZlH3/7ED8fn+BCMplp9D+b1oAEmWrpMrO/yy4=; b=rIRSSgnywAFi6jSB/48FKd4VjhckhDEvnr86SRPG9A2yxljJsYZd4u+D9hYge/4kTk Y5t1JNb5LakG9isGUST4qMEoNO6xrWcX7WpszgPJ5wyD8o6SujFKLmu6EhUOhDPXcvc8 pNCXUqrR94rF9un9jf645m6tgpRGh7saEnxbkUL3O8dxpxnuxIPdsVmI4fryb/iW6I9a dNVrhB3gjR+6SF6I88jFQt7CftBdKAK2IGdrjk3G8xV5plUTpsUauXhjFVQiR1rXx1bl bJdCZtZGxRhWTScjZTGckIhzZ9tWGsO94xYLmeaTFq6O4mRYAj4zNHTA9iaqjZrTO4d6 kPbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Zbf92dZlH3/7ED8fn+BCMplp9D+b1oAEmWrpMrO/yy4=; b=NS9SoSO+uMjJB2hU4gxZIqNaDIQ0SeeQrgxBf8oHceaKjTmF9FgO3uhO9+1sC4Ulpm 0Wykg0dfLxHjyZPmRd+BmgPbrSTViH5sTOVlAqZwj+7N6T4wmNmYF/uaHoQFyGPrRAVF 2RKPbL6ogQXEM0QHKy0MY01bliUsWVjJG3YyXFdYgivyrqrsPgved1SIWmNFnmspvfxg xCjTJVEMjJ54/2HKVFu846jYTiRFy/C2SeDrq0c+cG7uT/nATJ04xLtW2BWGWvaoODoY M6U8U2U9ddkSewo8Spv3L1WUDA4DzJfobfwKD5c2ktbZPVRkFU37WWBeJGGY2QXeIBL8 MVig== X-Gm-Message-State: AOAM531+QCAaAy1UshJAkCvZJNrnuuW4CWzhJW6dHlDrq6EIl72kJ4Ib UuJ1dQY1ypEv62kudfy9RlQ1dYWExXPRy3DQMGs= X-Google-Smtp-Source: ABdhPJwKIe3rTpxJjotpg2TcjkqdFlTpTurdtWAcTCBEaWNfO6Yb0JR9s0CloHwBYUuDnoaAvrmV2SxSs2Yq//ixKFg= X-Received: by 2002:a05:6808:913:: with SMTP id w19mr270455oih.48.1598895417630; Mon, 31 Aug 2020 10:36:57 -0700 (PDT) MIME-Version: 1.0 References: <20200829010210.871471-1-abhishekpandit@chromium.org> <20200828180157.Bluez.v3.1.I14a96397d181666c124e1c413b834428faf3db7a@changeid> In-Reply-To: <20200828180157.Bluez.v3.1.I14a96397d181666c124e1c413b834428faf3db7a@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 31 Aug 2020 10:36:47 -0700 Message-ID: <CABBYNZJTr13-XK9KuXOD+UzB6_oSwefvpJ9ptPRf0dygdAhKHw@mail.gmail.com> Subject: Re: [Bluez PATCH v3 1/3] mgmt: Add controller suspend and resume events To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: A9B10420FC X-Rspamd-UID: cbc714 Hi Abhishek, On Fri, Aug 28, 2020 at 6:02 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Add the controller suspend and resume events. > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > --- > > Changes in v3: None > Changes in v2: None > > lib/mgmt.h | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/lib/mgmt.h b/lib/mgmt.h > index a800bcab4..46d894ae9 100644 > --- a/lib/mgmt.h > +++ b/lib/mgmt.h > @@ -772,6 +772,7 @@ struct mgmt_ev_device_connected { > #define MGMT_DEV_DISCONN_TIMEOUT 0x01 > #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 > #define MGMT_DEV_DISCONN_REMOTE 0x03 > +#define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND 0x05 > > #define MGMT_EV_DEVICE_DISCONNECTED 0x000C > struct mgmt_ev_device_disconnected { > @@ -959,6 +960,17 @@ struct mgmt_ev_adv_monitor_removed { > uint16_t monitor_handle; > } __packed; > > +#define MGMT_EV_CONTROLLER_SUSPEND 0x002d > +struct mgmt_ev_controller_suspend { > + uint8_t suspend_state; > +} __packed; > + > +#define MGMT_EV_CONTROLLER_RESUME 0x002e > +struct mgmt_ev_controller_resume { > + struct mgmt_addr_info addr; > + uint8_t wake_reason; > +} __packed; > + > static const char *mgmt_op[] = { > "<0x0000>", > "Read Version", > @@ -1088,6 +1100,8 @@ static const char *mgmt_ev[] = { > "Device Flags Changed", > "Advertisement Monitor Added", /* 0x002b */ > "Advertisement Monitor Removed", > + "Controller Suspend", > + "Controller Resume", > }; > > static const char *mgmt_status[] = { > -- > 2.28.0.402.g5ffc5be6b7-goog Patches 1 and 2 of this series were applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iMijBlY1TV/gmgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 19:37:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 4NkEBVY1TV+qsgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 19:37:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 00A97420D3; Mon, 31 Aug 2020 19:37:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726126AbgHaRhU (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 13:37:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgHaRhU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 13:37:20 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0499BC061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 10:37:20 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id 37so4350856oto.4 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 10:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TTKDttS2RbtsxmH+4uHL9y8lptlzr1gB9Bq1UlGjY/w=; b=rBZJjiyM+AR3+FHH34Rktu+zmv/bWAKFBJ7lej0+kq83mDo+IERrKjxhDkLeuWrR1d jJ2VekXmdYd7RE6Lrycx4CE+cZHjcFrYjeikyp1bmtCW4HCicU3cMLf2gTW3BRQUSVfJ EmqRZ1jmPA6tmBHfcPI3Y9nwdzsW4ZxDd4Piav14wJXXgF+iuwNJic2iaho0BDW3oJUd FnR1RSwHGH8LmQ3GgDr+eWsIpiMeDV7WCUJ6DUvVLscvS03R+b1UMvlm8v0jIgT0ywZt wVkLJju8h/qHHm5nVPOcv3F+5gonzn94J3tjavZEV8y1Ko5MNDmShHMH8vDEo/VRYI91 SnmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TTKDttS2RbtsxmH+4uHL9y8lptlzr1gB9Bq1UlGjY/w=; b=byFDqEjq2VEqvobBkpuF7/pEaDWVPcQEd/DzJJIASssn4+zhAZcPwtbNJcQ8Oellli b5B0K4ClkPvj8Q3ed4TKHsWdL0+1605OVcffpb2Bs4A8wERJs/zjLJQPe4N82mgL3Y0T Vji+HDffhvg/mjDjIKx/7yVgufnY04M17MZuFl1rngK6zNbQbr2wLFvW1vFZG/c86yMo 6Mwh88CYjC+w6MfaOXzGzMfMV6vyZ0QJE2Pw4si+7NzYRo/GP+Q3MT/Nz1ADr50Jvvvx 01l4JQz8aV6AhxiiHFR4VcnuRpPurgPfhzJ1Oy7sn5DuFhz9cSPNeqipFRfMAsyRIj/o leIg== X-Gm-Message-State: AOAM531UHVq7aTgOHEGLYNuNnri5+6Tj3ocCCs9gjIHM2GF5gDIIxc9i oKXWj7KimcLmzilGMXGfClSxsjbdGdwE6rxSHEY= X-Google-Smtp-Source: ABdhPJzbidhOFjgqFEEbjcCQISFMJC1RVUni524gfIhWxK9EadA4ZR+F8LAlgumfssVXb+SUHuf7riGkyYBlBeC0P7s= X-Received: by 2002:a9d:429:: with SMTP id 38mr1551355otc.88.1598895439389; Mon, 31 Aug 2020 10:37:19 -0700 (PDT) MIME-Version: 1.0 References: <20200830071108.19777-1-31baz66@gmail.com> <20200830071108.19777-2-31baz66@gmail.com> In-Reply-To: <20200830071108.19777-2-31baz66@gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 31 Aug 2020 10:37:09 -0700 Message-ID: <CABBYNZK9aB4B092T7EeFoziczf_ffKt3eUcAwSDEknkBhqHTHQ@mail.gmail.com> Subject: Re: [PATCH BlueZ 1/1] Fix typo in bluetoothctl To: Barry Byford <31baz66@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: 00A97420D3 X-Rspamd-UID: 1f1af9 Hi Barry, On Sun, Aug 30, 2020 at 12:17 AM Barry Byford <31baz66@gmail.com> wrote: > > --- > client/advertising.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/client/advertising.c b/client/advertising.c > index 94eb616b2..1aa28e749 100644 > --- a/client/advertising.c > +++ b/client/advertising.c > @@ -185,7 +185,7 @@ static void print_ad(void) > bt_appear_to_str(ad.local_appearance), > ad.local_appearance); > else > - bt_shell_printf("Apperance: %s\n", > + bt_shell_printf("Appearance: %s\n", > ad.appearance ? "on" : "off"); > > bt_shell_printf("Discoverable: %s\n", ad.discoverable ? "on": "off"); > @@ -886,7 +886,7 @@ void ad_advertise_local_appearance(DBusConnection *conn, long int *value) > bt_appear_to_str(ad.local_appearance), > ad.local_appearance); > else > - bt_shell_printf("Apperance: %s\n", > + bt_shell_printf("Appearance: %s\n", > ad.appearance ? "on" : "off"); > > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > -- > 2.25.1 Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GMEoIc1ATV/HtgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 20:26:21 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WA9CH81ATV+EGgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 20:26:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9D357A1657; Mon, 31 Aug 2020 20:26:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729232AbgHaS0M (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 14:26:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbgHaS0M (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 14:26:12 -0400 Received: from mail-vk1-xa44.google.com (mail-vk1-xa44.google.com [IPv6:2607:f8b0:4864:20::a44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5F79C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 11:26:11 -0700 (PDT) Received: by mail-vk1-xa44.google.com with SMTP id b4so1524042vkh.9 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 11:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TDT2Lemxs8UtoGfuluoG/9z0fCzxbWQMG0mBhTD3cLU=; b=CVV5YhQKfQJwLe0bXNnxem0KAuGuyV4PwOaYsXiKwVs4+8SwQm9vLE/HgTc6Ux0dBp 0TSJ1mKCa7eQZzXcqh834a7Tbm6yySTmKM7RFuDpvdSwOuwJN2FH9sovieq8BhdZJ47Q vZ66zkgja/utIXdE9WXtnqe8aNsrPPNhk36mY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TDT2Lemxs8UtoGfuluoG/9z0fCzxbWQMG0mBhTD3cLU=; b=ritS3IrumJ6Qq97aAS9yFjphlS1wZhmLuRlU/+1Ljvgz7eL5/BkWMzZohxVU8nDyy3 T7ft+rlUYBiBSfLA5uqjMRwTD7eO/airSz1LTl1YmZLX01+VHRNg9oVb057Opt6h09k2 2VNT44AuCszUmy3HcLaxsY5gSWrzRQ81K0rlxEhbqS5X+yO8ccaR4VUlOEICFVEe06g3 0vByJcjF+BoifjSKAiUtOQkXrNxidDdhC+o0aBNRwQR1Mait8d/+HQ2XLfyzgIhnXk5I hcdv4Ql6qvdluEQYsBqe/WEY2mYJxe1Cb+v+PPZGC2Hw03DnpZWVXlkqemm2t8RmdduM EEMA== X-Gm-Message-State: AOAM533OSm9MEDhxccEZV4gmTnxxvTUuPfYMisZZCZg+ArBHKgJFKSTJ 0/FvOahOHS/yc3cL3tgISwjh+Bf2YcxeWruV8d72Tw== X-Google-Smtp-Source: ABdhPJweMFSxCeHrXn9dBxRlUlXbvP2CTAf2tUKYq+UbT9w3aZajOyQMYaIvPhCYGjKES0x+REZ6Ft4Pl1XkgIUVU4Y= X-Received: by 2002:a1f:9bc6:: with SMTP id d189mr2236167vke.54.1598898370894; Mon, 31 Aug 2020 11:26:10 -0700 (PDT) MIME-Version: 1.0 References: <20200829010210.871471-1-abhishekpandit@chromium.org> <20200828180157.Bluez.v3.3.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> <CABBYNZJDfjSWFDStLLb+Oe46Zhuqjem=xxZoEkeDNXgyKQj6KA@mail.gmail.com> In-Reply-To: <CABBYNZJDfjSWFDStLLb+Oe46Zhuqjem=xxZoEkeDNXgyKQj6KA@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Mon, 31 Aug 2020 11:25:59 -0700 Message-ID: <CANFp7mWM6+y4Z50+xYGRYr8JANpbqsGiy8i9Sg4EmfgFD_mYpQ@mail.gmail.com> Subject: Re: [Bluez PATCH v3 3/3] policy: Reconnect audio on controller resume To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.98 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9D357A1657 X-Rspamd-UID: e62437 Hi Luiz, On Mon, Aug 31, 2020 at 9:57 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Abhishek, > > On Fri, Aug 28, 2020 at 6:02 PM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > During system suspend, all peer devices are disconnected. On resume, HID > > devices will reconnect but audio devices stay disconnected. As a quality > > of life improvement, mark audio devices that were disconnected due to > > suspend and attempt to reconnect them when the controller resumes (after > > a delay for better co-existence with Wi-Fi). > > > > --- > > > > Changes in v3: > > - Refactored resume notification to use btd_adapter_driver > > - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 > > - Added A2DP_SINK_UUID to default reconnect list > > > > Changes in v2: > > - Refactored to use policy instead of connecting directly in adapter > > > > plugins/policy.c | 80 +++++++++++++++++++++++++++++++++++++++--------- > > src/adapter.c | 36 ++++++++++++++++++++++ > > src/adapter.h | 2 ++ > > src/main.c | 1 + > > src/main.conf | 11 ++++++- > > 5 files changed, 115 insertions(+), 15 deletions(-) > > > > diff --git a/plugins/policy.c b/plugins/policy.c > > index de51e58b9..5ab65b991 100644 > > --- a/plugins/policy.c > > +++ b/plugins/policy.c > > @@ -62,10 +62,12 @@ struct reconnect_data { > > guint timer; > > bool active; > > unsigned int attempt; > > + bool on_resume; > > }; > > > > static const char *default_reconnect[] = { > > - HSP_AG_UUID, HFP_AG_UUID, A2DP_SOURCE_UUID, NULL }; > > + HSP_AG_UUID, HFP_AG_UUID, A2DP_SOURCE_UUID, > > + A2DP_SINK_UUID, NULL }; > > Lets have this change in a separate patch. Ack. Will split into its own patch. > > > static char **reconnect_uuids = NULL; > > > > static const size_t default_attempts = 7; > > @@ -75,6 +77,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; > > static int *reconnect_intervals = NULL; > > static size_t reconnect_intervals_len = 0; > > > > +static const int default_resume_delay = 2; > > +static int resume_delay; > > + > > static GSList *reconnects = NULL; > > > > static unsigned int service_id = 0; > > @@ -711,6 +716,9 @@ static gboolean reconnect_timeout(gpointer data) > > /* Mark the GSource as invalid */ > > reconnect->timer = 0; > > > > + /* Mark any reconnect on resume as handled */ > > + reconnect->on_resume = false; > > + > > err = btd_device_connect_services(reconnect->dev, reconnect->services); > > if (err < 0) { > > error("Reconnecting services failed: %s (%d)", > > @@ -724,14 +732,17 @@ static gboolean reconnect_timeout(gpointer data) > > return FALSE; > > } > > > > -static void reconnect_set_timer(struct reconnect_data *reconnect) > > +static void reconnect_set_timer(struct reconnect_data *reconnect, int timeout) > > { > > - static int timeout = 0; > > + static int interval_timeout = 0; > > > > reconnect->active = true; > > > > if (reconnect->attempt < reconnect_intervals_len) > > - timeout = reconnect_intervals[reconnect->attempt]; > > + interval_timeout = reconnect_intervals[reconnect->attempt]; > > + > > + if (timeout < 0) > > + timeout = interval_timeout; > > > > DBG("attempt %u/%zu %d seconds", reconnect->attempt + 1, > > reconnect_attempts, timeout); > > @@ -743,10 +754,14 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) > > static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > { > > struct reconnect_data *reconnect; > > + struct btd_service *service; > > + struct policy_data *data; > > > > DBG("reason %u", reason); > > > > - if (reason != MGMT_DEV_DISCONN_TIMEOUT) > > + /* Only attempt reconnect for the following reasons */ > > + if (reason != MGMT_DEV_DISCONN_TIMEOUT && > > + reason != MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND) > > We might want to rework this to have the reason just checked once. With a single check, it was either a lot less clear (break vs return in switch) or had duplication. This was the clearer option. i.e. switch(reason) { case MGMT_DEV_DISCONN_TIMEOUT: break; case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: if (btd_device_get_service(dev, A2DP_SINK_UUID)) break; else return; default: return; } /* Do the rest of the reconnect */ > > > return; > > > > reconnect = reconnect_find(dev); > > @@ -755,10 +770,40 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) > > > > reconnect_reset(reconnect); > > > > - DBG("Device %s identified for auto-reconnection", > > - device_get_path(dev)); > > + DBG("Device %s identified for auto-reconnection", device_get_path(dev)); > > > > - reconnect_set_timer(reconnect); > > + switch(reason) > > + { > > + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: > > + if (btd_device_get_service(dev, A2DP_SINK_UUID)) { > > + reconnect->on_resume = true; > > + DBG("%s configured to reconnect on resume", > > + device_get_path(dev)); > > I thought your idea was to set the timer here and then reset it > on_resume so it would work even when the kernel does not indicate the > resume with an event. I sent an email on the last thread about this. With a reconnect time of 2s (and wake time = 1s, suspend time = 10s), if we stage the timer on disconnect, it seems to run immediately on resume without waiting to be delayed. This breaks the ability of the resume notifier and dark resume notifier to delay or stop the reconnection. This disconnect callback can run before the system suspends (since userspace isn't frozen when the kernel suspend notifier runs). Depending on where the disconnect_cb runs, this results in incorrect behavior of reconnection on resume (i.e. no delays). To support the case where the kernel doesn't emit a kernel event, I think it might be better for me to check whether the kernel supports these events in the btd_adapter_driver probe function and queue on disconnect if it doesn't. Expect this in the next version. > > > + } > > + break; > > + case MGMT_DEV_DISCONN_TIMEOUT: > > + reconnect_set_timer(reconnect, -1); > > + break; > > + default: > > + DBG("Developer error. Reason = %d", reason); > > + break; > > + } > > +} > > + > > +static void policy_adapter_resume(struct btd_adapter *adapter, > > + uint8_t wake_reason, const bdaddr_t *addr, > > + const uint8_t addr_type) > > +{ > > + GSList *l; > > + > > + /* Check if any devices needed to be reconnected on resume */ > > + for (l = reconnects; l; l = g_slist_next(l)) { > > + struct reconnect_data *reconnect = l->data; > > We should be checking if the reconnect matches the adapter otherwise > this could potentially call reconnect_set_timer multiple times for the > same device if there are multiple adapters on the system. Ack -- will do for the next version. > > > + if (reconnect->on_resume) { > > + reconnect_set_timer(reconnect, resume_delay); > > + } > > + } > > } > > > > static void conn_fail_cb(struct btd_device *dev, uint8_t status) > > @@ -786,14 +831,15 @@ static void conn_fail_cb(struct btd_device *dev, uint8_t status) > > return; > > } > > > > - reconnect_set_timer(reconnect); > > + reconnect_set_timer(reconnect, -1); > > } > > > > static int policy_adapter_probe(struct btd_adapter *adapter) > > { > > DBG(""); > > > > - btd_adapter_restore_powered(adapter); > > + if (auto_enable) > > + btd_adapter_restore_powered(adapter); > > > > return 0; > > } > > @@ -801,6 +847,7 @@ static int policy_adapter_probe(struct btd_adapter *adapter) > > static struct btd_adapter_driver policy_driver = { > > .name = "policy", > > .probe = policy_adapter_probe, > > + .resume = policy_adapter_resume, > > }; > > > > static int policy_init(void) > > @@ -854,14 +901,20 @@ static int policy_init(void) > > auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", > > NULL); > > > > + resume_delay = g_key_file_get_integer( > > + conf, "Policy", "ResumeDelay", &gerr); > > + > > + if (gerr) { > > + g_clear_error(&gerr); > > + resume_delay = default_resume_delay; > > + } > > done: > > if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { > > btd_add_disconnect_cb(disconnect_cb); > > btd_add_conn_fail_cb(conn_fail_cb); > > } > > > > - if (auto_enable) > > - btd_register_adapter_driver(&policy_driver); > > + btd_register_adapter_driver(&policy_driver); > > > > return 0; > > } > > @@ -882,8 +935,7 @@ static void policy_exit(void) > > > > btd_service_remove_state_cb(service_id); > > > > - if (auto_enable) > > - btd_unregister_adapter_driver(&policy_driver); > > + btd_unregister_adapter_driver(&policy_driver); > > } > > > > BLUETOOTH_PLUGIN_DEFINE(policy, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, > > diff --git a/src/adapter.c b/src/adapter.c > > index 1435e2bd7..bf355bfa7 100644 > > --- a/src/adapter.c > > +++ b/src/adapter.c > > @@ -8776,6 +8776,37 @@ static void connected_callback(uint16_t index, uint16_t length, > > eir_data_free(&eir_data); > > } > > > > +static void controller_resume_notify(struct btd_adapter *adapter, > > + const uint8_t wake_reason, > > + const bdaddr_t *addr, > > + const uint8_t addr_type) > > +{ > > + GSList *l; > > + > > + for (l = adapter->drivers; l; l = g_slist_next(l)) { > > + struct btd_adapter_driver *driver = l->data; > > + if (driver->resume) > > + driver->resume(adapter, wake_reason, addr, addr_type); > > This should be in a separate patch, also not sure what is the reason > to pass the address and addr_type on the resume callback? If the > callback requires that it can query it internally. > Ack. Will move resume notification changes into its own patch and remove the unneeded params. > > + } > > +} > > + > > +static void controller_resume_callback(uint16_t index, uint16_t length, > > + const void *param, void *user_data) > > +{ > > + const struct mgmt_ev_controller_resume *ev = param; > > + struct btd_adapter *adapter = user_data; > > + > > + if (length < sizeof(*ev)) { > > + btd_error(adapter->dev_id, "Too small device resume event"); > > + return; > > + } > > + > > + info("Controller resume with wake event 0x%x", ev->wake_reason); > > + > > + controller_resume_notify(adapter, ev->wake_reason, &ev->addr.bdaddr, > > + ev->addr.type); > > +} > > + > > static void device_blocked_callback(uint16_t index, uint16_t length, > > const void *param, void *user_data) > > { > > @@ -9399,6 +9430,11 @@ static void read_info_complete(uint8_t status, uint16_t length, > > user_passkey_notify_callback, > > adapter, NULL); > > > > + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, > > + adapter->dev_id, > > + controller_resume_callback, > > + adapter, NULL); > > + > > set_dev_class(adapter); > > > > set_name(adapter, btd_adapter_get_name(adapter)); > > diff --git a/src/adapter.h b/src/adapter.h > > index f8ac20261..b81ef6a04 100644 > > --- a/src/adapter.h > > +++ b/src/adapter.h > > @@ -113,6 +113,8 @@ struct btd_adapter_driver { > > const char *name; > > int (*probe) (struct btd_adapter *adapter); > > void (*remove) (struct btd_adapter *adapter); > > + void (*resume)(struct btd_adapter *adapter, uint8_t wake_reason, > > + const bdaddr_t *addr, const uint8_t addr_type); > > }; > > > > typedef void (*service_auth_cb) (DBusError *derr, void *user_data); > > diff --git a/src/main.c b/src/main.c > > index b37c32948..038f867b5 100644 > > --- a/src/main.c > > +++ b/src/main.c > > @@ -131,6 +131,7 @@ static const char *policy_options[] = { > > "ReconnectAttempts", > > "ReconnectIntervals", > > "AutoEnable", > > + "ResumeDelay", > > NULL > > }; > > > > diff --git a/src/main.conf b/src/main.conf > > index 42f7e41c5..9f882e65a 100644 > > --- a/src/main.conf > > +++ b/src/main.conf > > @@ -186,7 +186,7 @@ > > # timeout). The policy plugin should contain a sane set of values by > > # default, but this list can be overridden here. By setting the list to > > # empty the reconnection feature gets disabled. > > -#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb > > +#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb,0000110b-0000-1000-8000-00805f9b34fb > > > > # ReconnectAttempts define the number of attempts to reconnect after a link > > # lost. Setting the value to 0 disables reconnecting feature. > > @@ -202,3 +202,12 @@ > > # This includes adapters present on start as well as adapters that are plugged > > # in later on. Defaults to 'false'. > > #AutoEnable=false > > + > > +# Audio devices that were disconnected due to suspend will be reconnected on > > +# resume. ResumeDelay determines the delay between when the controller > > +# resumes from suspend and a connection attempt is made. A longer delay is > > +# better for better co-existence with Wi-Fi. > > +# The value is in seconds. > > +# Default: 2 > > +#ResumeDelay = 2 > > + > > -- > > 2.28.0.402.g5ffc5be6b7-goog > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sMAXIklBTV+JXQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 20:28:25 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UHXEIElBTV/o1AEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 20:28:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BC94EA10E2; Mon, 31 Aug 2020 20:28:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728257AbgHaS2R (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 14:28:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbgHaS2Q (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 14:28:16 -0400 Received: from mail-vk1-xa44.google.com (mail-vk1-xa44.google.com [IPv6:2607:f8b0:4864:20::a44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F588C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 11:28:16 -0700 (PDT) Received: by mail-vk1-xa44.google.com with SMTP id e5so407213vkm.2 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 11:28:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h63Rj0Px9YhpYpjPVZddoHDJIC9AXL8x7ZQiNvu7YH4=; b=SyTl/NwAvI6Z6KVO9hDikmuv6SASItxkTxMNDTqAvF6VBnY5jPJ7rvJ3Mx9AaFDQKj UeBTwv1rI8/u4EKJVwI+UrBUKSXaGclHnuyf0hWiZQjYUnjJJiVfm4SxHYiPEHHS6Qpf ma5FSM5rtT0JqGw8j7E8WyYjtkkmjwm3KjUAc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h63Rj0Px9YhpYpjPVZddoHDJIC9AXL8x7ZQiNvu7YH4=; b=W/UUfowP8bViEud16iNYrs+9iL28JKURBmBPKUHUkk8sr6TUcFlYDW9fgdPkwpcFZn Zlh99rALZEf5qZlqfbLkE26tms/dzPB4BzRbLeNtYW9qVVmHbyG94YGPXGeTTms67jRu 0nJygxOmE+4vXZpxsivyEplExW7qDfYZV3RTZRT+yzYjvZpjY4NKqPC/kQoYWeLFf6Rc DCj8563x/isclSB/kZd7Z+BVPGgUVUcFSAtMEmgslXdYj38CKVY2dVBCaqCLYCExP69K cJgZ2tYWT9CcKSNtrP/ZaKBcnQXkL/iXSGa4K1WC0edjXqMUmPipqv71G6j63ZkczS/Y DDdA== X-Gm-Message-State: AOAM531L2ZGhbLgv1k5Tl33mf28FuVAM2eiL3Ep+0AeTDwZp9WAQp50D EuIxUJ5aJYqjVKUxi2ILxaNa+5xzQ+CRtdKzwu4lpg== X-Google-Smtp-Source: ABdhPJyfjthdMqZttVFDFbLfsFXicNSK2NGTUsEOZqxm6gO0DhK1vqFTB0FebvMj9pF1nA9N7tx+bw53xFrQeCtRF3Q= X-Received: by 2002:ac5:c925:: with SMTP id u5mr2185373vkl.68.1598898495413; Mon, 31 Aug 2020 11:28:15 -0700 (PDT) MIME-Version: 1.0 References: <20200829010210.871471-1-abhishekpandit@chromium.org> <20200828180157.Bluez.v3.1.I14a96397d181666c124e1c413b834428faf3db7a@changeid> <CABBYNZJTr13-XK9KuXOD+UzB6_oSwefvpJ9ptPRf0dygdAhKHw@mail.gmail.com> In-Reply-To: <CABBYNZJTr13-XK9KuXOD+UzB6_oSwefvpJ9ptPRf0dygdAhKHw@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Mon, 31 Aug 2020 11:28:05 -0700 Message-ID: <CANFp7mVq_7no-KJ0SFZ1Yqz0ZZbabgUUChXv+PsyJ00rGicDSQ@mail.gmail.com> Subject: Re: [Bluez PATCH v3 1/3] mgmt: Add controller suspend and resume events To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.02 / 15.00 / 200.00 X-Rspamd-Queue-Id: BC94EA10E2 X-Rspamd-UID: 0c7c37 Hi Luiz, Could you also merge https://patchwork.kernel.org/patch/11663455/ that adds this to docs/mgmt-api.txt? Thanks Abhishek On Mon, Aug 31, 2020 at 10:36 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Abhishek, > > On Fri, Aug 28, 2020 at 6:02 PM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > Add the controller suspend and resume events. > > > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > --- > > > > Changes in v3: None > > Changes in v2: None > > > > lib/mgmt.h | 14 ++++++++++++++ > > 1 file changed, 14 insertions(+) > > > > diff --git a/lib/mgmt.h b/lib/mgmt.h > > index a800bcab4..46d894ae9 100644 > > --- a/lib/mgmt.h > > +++ b/lib/mgmt.h > > @@ -772,6 +772,7 @@ struct mgmt_ev_device_connected { > > #define MGMT_DEV_DISCONN_TIMEOUT 0x01 > > #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 > > #define MGMT_DEV_DISCONN_REMOTE 0x03 > > +#define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND 0x05 > > > > #define MGMT_EV_DEVICE_DISCONNECTED 0x000C > > struct mgmt_ev_device_disconnected { > > @@ -959,6 +960,17 @@ struct mgmt_ev_adv_monitor_removed { > > uint16_t monitor_handle; > > } __packed; > > > > +#define MGMT_EV_CONTROLLER_SUSPEND 0x002d > > +struct mgmt_ev_controller_suspend { > > + uint8_t suspend_state; > > +} __packed; > > + > > +#define MGMT_EV_CONTROLLER_RESUME 0x002e > > +struct mgmt_ev_controller_resume { > > + struct mgmt_addr_info addr; > > + uint8_t wake_reason; > > +} __packed; > > + > > static const char *mgmt_op[] = { > > "<0x0000>", > > "Read Version", > > @@ -1088,6 +1100,8 @@ static const char *mgmt_ev[] = { > > "Device Flags Changed", > > "Advertisement Monitor Added", /* 0x002b */ > > "Advertisement Monitor Removed", > > + "Controller Suspend", > > + "Controller Resume", > > }; > > > > static const char *mgmt_status[] = { > > -- > > 2.28.0.402.g5ffc5be6b7-goog > > Patches 1 and 2 of this series were applied, thanks. > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uDPPDddeTV+bjQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 22:34:31 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8HuCDNdeTV8VrAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 22:34:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3CE36A1996; Mon, 31 Aug 2020 22:34:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728586AbgHaUeW (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 16:34:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728402AbgHaUeW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 16:34:22 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CAD3C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 13:34:22 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id y30so1791582ooj.3 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 13:34:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=afPtGRN+FnzfS3mVOZ0v/4LJTXGWDmVqMyAKYPVaFzk=; b=AWGrL2Rtst2W8ovrexQABrUbFf46ka14qb0a6uVZnrWx7FfjyGoPjYu4u/JTi3g42N zjiHYRd8lhN5hcrAku/DyvK35lM2+YBvDyRpl9fsjOx4knpA8Gqq3v/uH/UoVTqAj8XN 7IuYkeJKub2yPXDk0eLqv6lRs+iiRq8ZEi8JCoJEZa1o0mnHoov0gMbnhXWUW1yG9B/U kzaFXzOyxYitq5LMz0H65JUbOh/W8+LQN/HmDztHZpLZKKU2WuRBeVseEiLCHulLVraY r+gYLhRHQPcuOp1AR14yy3sVazt6e5pAmhhqgeQ7e93xZHLm/qhfAgxfbXLEGYtr3LCl Yvqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=afPtGRN+FnzfS3mVOZ0v/4LJTXGWDmVqMyAKYPVaFzk=; b=CxWBdczcCPgC6QoJIdZUVe1oI2q5Az54gen/pOYdKckj6XjeXVOt9u8PvNfZYrhoD8 FZusuB569dr3lfyLxgV+9p9OK4F1RaaAMo+MHvbAQeJDLXW1XzMcttm7NVM4AuRWKgqP ZyV3wdQyFCOQcRD1Vg7/vuriWeKyZCIWbj/McARJ1+HG4VGtgySGMK6JKkGAk8Zivlrj vcRIjvWZykIw1EbEHic4QWU6XE2EBpf8LJBRQc8fQxj7U8gfBo3Pwgkaa4dwU5IPAluO ZfB4mNKSqm3n/D6rSaDAqsbkjRQSZG7XZFVrq5vj5szoGYg3qDssR/00OFBeX9MZq6bn XAQQ== X-Gm-Message-State: AOAM531lof/Aal2g92O97wR7ZloutsAkuR2ob/J1XqSLv+5i8AIJ5JXp 0JkVtXkv2slEY/BBvKc1X7z4hqx2bsTQW7Qbrh1qMKka X-Google-Smtp-Source: ABdhPJwWrZqw52gSNjWIhpt3vTPk6VFhOsvAwZBaskUdyElVBI2X4MxhuZWEaaZ0fraUB5O64icp0C435tz+y5ar1/k= X-Received: by 2002:a4a:924b:: with SMTP id g11mr1976063ooh.9.1598906061330; Mon, 31 Aug 2020 13:34:21 -0700 (PDT) MIME-Version: 1.0 References: <20200829010210.871471-1-abhishekpandit@chromium.org> <20200828180157.Bluez.v3.1.I14a96397d181666c124e1c413b834428faf3db7a@changeid> <CABBYNZJTr13-XK9KuXOD+UzB6_oSwefvpJ9ptPRf0dygdAhKHw@mail.gmail.com> <CANFp7mVq_7no-KJ0SFZ1Yqz0ZZbabgUUChXv+PsyJ00rGicDSQ@mail.gmail.com> In-Reply-To: <CANFp7mVq_7no-KJ0SFZ1Yqz0ZZbabgUUChXv+PsyJ00rGicDSQ@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 31 Aug 2020 13:34:11 -0700 Message-ID: <CABBYNZLorj6c3KJtAO+fvwQzS=wsh21D+Xov=duyY3JixbuvOA@mail.gmail.com> Subject: Re: [Bluez PATCH v3 1/3] mgmt: Add controller suspend and resume events To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.26 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3CE36A1996 X-Rspamd-UID: 0e9618 Hi Abhishek, On Mon, Aug 31, 2020 at 11:28 AM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Hi Luiz, > > Could you also merge https://patchwork.kernel.org/patch/11663455/ that > adds this to docs/mgmt-api.txt? Looks like Marcel had reviewed but decided to hold on until the kernel parts are applied, have that been resolved? > Thanks > Abhishek > > On Mon, Aug 31, 2020 at 10:36 AM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Abhishek, > > > > On Fri, Aug 28, 2020 at 6:02 PM Abhishek Pandit-Subedi > > <abhishekpandit@chromium.org> wrote: > > > > > > Add the controller suspend and resume events. > > > > > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > > --- > > > > > > Changes in v3: None > > > Changes in v2: None > > > > > > lib/mgmt.h | 14 ++++++++++++++ > > > 1 file changed, 14 insertions(+) > > > > > > diff --git a/lib/mgmt.h b/lib/mgmt.h > > > index a800bcab4..46d894ae9 100644 > > > --- a/lib/mgmt.h > > > +++ b/lib/mgmt.h > > > @@ -772,6 +772,7 @@ struct mgmt_ev_device_connected { > > > #define MGMT_DEV_DISCONN_TIMEOUT 0x01 > > > #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 > > > #define MGMT_DEV_DISCONN_REMOTE 0x03 > > > +#define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND 0x05 > > > > > > #define MGMT_EV_DEVICE_DISCONNECTED 0x000C > > > struct mgmt_ev_device_disconnected { > > > @@ -959,6 +960,17 @@ struct mgmt_ev_adv_monitor_removed { > > > uint16_t monitor_handle; > > > } __packed; > > > > > > +#define MGMT_EV_CONTROLLER_SUSPEND 0x002d > > > +struct mgmt_ev_controller_suspend { > > > + uint8_t suspend_state; > > > +} __packed; > > > + > > > +#define MGMT_EV_CONTROLLER_RESUME 0x002e > > > +struct mgmt_ev_controller_resume { > > > + struct mgmt_addr_info addr; > > > + uint8_t wake_reason; > > > +} __packed; > > > + > > > static const char *mgmt_op[] = { > > > "<0x0000>", > > > "Read Version", > > > @@ -1088,6 +1100,8 @@ static const char *mgmt_ev[] = { > > > "Device Flags Changed", > > > "Advertisement Monitor Added", /* 0x002b */ > > > "Advertisement Monitor Removed", > > > + "Controller Suspend", > > > + "Controller Resume", > > > }; > > > > > > static const char *mgmt_status[] = { > > > -- > > > 2.28.0.402.g5ffc5be6b7-goog > > > > Patches 1 and 2 of this series were applied, thanks. > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uPLbHkFkTV+bjQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 22:57:37 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id OF4fHUFkTV/jMgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 22:57:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B06DEA10E2; Mon, 31 Aug 2020 22:57:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730141AbgHaU43 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 16:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729506AbgHaU41 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 16:56:27 -0400 Received: from mail-vs1-xe43.google.com (mail-vs1-xe43.google.com [IPv6:2607:f8b0:4864:20::e43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7E24C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 13:56:27 -0700 (PDT) Received: by mail-vs1-xe43.google.com with SMTP id j185so1425619vsc.3 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 13:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Jf+by2cMfVGYoXiaZmCY+bTjqc266EFHVYXp0RH8ESc=; b=M1R6AqMdsetkO+AX4MhlxLKGGKiS5BUUn3OPkOAr3SakpmTnh/jk0srXqbl8RZyZ+x lECNuMmsXgPwNbbudAi8k5HFqT4XjcGMwUvhtc2hXk4cZw8MdCppQQLLxvmnwmCqajPP mWV5uo2OeyVfwHgR8QJtJgbXb3r3u9mz79wBU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Jf+by2cMfVGYoXiaZmCY+bTjqc266EFHVYXp0RH8ESc=; b=ETx/Mn4CNqlLSrpjaG8i6NZsKgZ8gDMWTFxWycTqY/+QfU1IC3NqqSYTZXs/PQPr54 wI7cVqnGV3cyMLzMBo+O8Wbg5ABRhDkQ3MMTNP+gU7H4OXmMCezarWvjCOBRYDs2LG/v QuqZsoB3T7BV9qSkT6CnVvoy2HnDA5CrjrUSYGq2q/02xh59ZzGCmJbXAn2jmWiqX/Yz jvFrAnS5gwgNUBB+qGKx5Y2zHPBNCO/F+3ONMjzbYe/k/AQYLbMEvpR27htDRqWDJjFF nh6EGgngpCqqfyX/Hm3Psa6rEAcksazQWnfsr5J9lYQKVZQX4fEM8EVqzl6H6ojtBGNw eIHQ== X-Gm-Message-State: AOAM53066aSvskkv2jv/9fgCVe19PWDjLOd9i5woj9mERDGOze9Nr2OO wTNdOtQ3p42ZLFQN6AI1KLzJVLvSEy7CvwwIWjmmtw== X-Google-Smtp-Source: ABdhPJyU14oXwVBhctneBOUwM29iuxJsij2t0ITXHo0JJcvyYxRW6OVl+b2FyPviOv3ZZjTd1k/fj+YWHlm01XS+VEU= X-Received: by 2002:a05:6102:5e:: with SMTP id k30mr3185433vsp.170.1598907386496; Mon, 31 Aug 2020 13:56:26 -0700 (PDT) MIME-Version: 1.0 References: <20200829010210.871471-1-abhishekpandit@chromium.org> <20200828180157.Bluez.v3.1.I14a96397d181666c124e1c413b834428faf3db7a@changeid> <CABBYNZJTr13-XK9KuXOD+UzB6_oSwefvpJ9ptPRf0dygdAhKHw@mail.gmail.com> <CANFp7mVq_7no-KJ0SFZ1Yqz0ZZbabgUUChXv+PsyJ00rGicDSQ@mail.gmail.com> <CABBYNZLorj6c3KJtAO+fvwQzS=wsh21D+Xov=duyY3JixbuvOA@mail.gmail.com> In-Reply-To: <CABBYNZLorj6c3KJtAO+fvwQzS=wsh21D+Xov=duyY3JixbuvOA@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Mon, 31 Aug 2020 13:56:14 -0700 Message-ID: <CANFp7mVPnfCDLrexawK8dx7comz=_f7LKjrQn-j75i=t_RkzOw@mail.gmail.com> Subject: Re: [Bluez PATCH v3 1/3] mgmt: Add controller suspend and resume events To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.27 / 15.00 / 200.00 X-Rspamd-Queue-Id: B06DEA10E2 X-Rspamd-UID: f8372a They have not. The changes are still pending review at https://patchwork.kernel.org/project/bluetooth/list/?series=325771. If you'd like to wait for Marcel, let's revert these two patches and land the whole series as one. Thanks Abhishek On Mon, Aug 31, 2020 at 1:34 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Abhishek, > > On Mon, Aug 31, 2020 at 11:28 AM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > Hi Luiz, > > > > Could you also merge https://patchwork.kernel.org/patch/11663455/ that > > adds this to docs/mgmt-api.txt? > > Looks like Marcel had reviewed but decided to hold on until the kernel > parts are applied, have that been resolved? > > > Thanks > > Abhishek > > > > On Mon, Aug 31, 2020 at 10:36 AM Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > > > > > > Hi Abhishek, > > > > > > On Fri, Aug 28, 2020 at 6:02 PM Abhishek Pandit-Subedi > > > <abhishekpandit@chromium.org> wrote: > > > > > > > > Add the controller suspend and resume events. > > > > > > > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > > > --- > > > > > > > > Changes in v3: None > > > > Changes in v2: None > > > > > > > > lib/mgmt.h | 14 ++++++++++++++ > > > > 1 file changed, 14 insertions(+) > > > > > > > > diff --git a/lib/mgmt.h b/lib/mgmt.h > > > > index a800bcab4..46d894ae9 100644 > > > > --- a/lib/mgmt.h > > > > +++ b/lib/mgmt.h > > > > @@ -772,6 +772,7 @@ struct mgmt_ev_device_connected { > > > > #define MGMT_DEV_DISCONN_TIMEOUT 0x01 > > > > #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 > > > > #define MGMT_DEV_DISCONN_REMOTE 0x03 > > > > +#define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND 0x05 > > > > > > > > #define MGMT_EV_DEVICE_DISCONNECTED 0x000C > > > > struct mgmt_ev_device_disconnected { > > > > @@ -959,6 +960,17 @@ struct mgmt_ev_adv_monitor_removed { > > > > uint16_t monitor_handle; > > > > } __packed; > > > > > > > > +#define MGMT_EV_CONTROLLER_SUSPEND 0x002d > > > > +struct mgmt_ev_controller_suspend { > > > > + uint8_t suspend_state; > > > > +} __packed; > > > > + > > > > +#define MGMT_EV_CONTROLLER_RESUME 0x002e > > > > +struct mgmt_ev_controller_resume { > > > > + struct mgmt_addr_info addr; > > > > + uint8_t wake_reason; > > > > +} __packed; > > > > + > > > > static const char *mgmt_op[] = { > > > > "<0x0000>", > > > > "Read Version", > > > > @@ -1088,6 +1100,8 @@ static const char *mgmt_ev[] = { > > > > "Device Flags Changed", > > > > "Advertisement Monitor Added", /* 0x002b */ > > > > "Advertisement Monitor Removed", > > > > + "Controller Suspend", > > > > + "Controller Resume", > > > > }; > > > > > > > > static const char *mgmt_status[] = { > > > > -- > > > > 2.28.0.402.g5ffc5be6b7-goog > > > > > > Patches 1 and 2 of this series were applied, thanks. > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +CA8GVpvTV+jJQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 31 Aug 2020 23:44:58 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id gJhhF1pvTV8wBgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 31 Aug 2020 23:44:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D8A22420C8; Mon, 31 Aug 2020 23:44:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730342AbgHaVou (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 17:44:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbgHaVot (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 17:44:49 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36139C061573 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 14:44:49 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id c10so6880170edk.6 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 14:44:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kP7bcfk6+/3Yopc1eHI5vQIWajE9xbJMncMajv2F6lE=; b=pBeUb92uX4HJyuGbdNLPfSKC/8278cJCl/zEEeMABU/YDHDsIMbiseU7b/Q1bUPmU3 4Q0v7j1N3pQXM1b0TPoYL5pwn++q+OyKe9eJVoPA114Pagq7tR9qRPb5MHieSVJNf5Zt n4GUiqlY+4Nd+ag4uSKSqGyVo84EWMRXKuEJw27k1mwUSARJZvc7kRhr24BrILkgZipJ dRNcsC5YxM0y0zrHKuKIRAAOVh1H86SoywkdT7gckZy+T0zmmMwqoG0phG0oKdEZgnua fPe6trAvFJOMulOwgG4/+N31uWIc3ZhVv01ezMCo0rU55KgfKBx/wnMLIOhKJJyXtgs0 ALxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kP7bcfk6+/3Yopc1eHI5vQIWajE9xbJMncMajv2F6lE=; b=nIlsrTxbZMwRepO1Gv9wl977KA8/E8dPM346g3K0dOG+m/caT7RDQwR7w2ZFJV+Iww IzaQBrfKqbAUJvDSeGfLMx8WpecouNGbMfpSGpN3bGeF5bbedm/eARQvk4Ism8E2l2St uGUnO4pePR9fPY0ZIrLM/8kFpIJrlWd369wfIfqgqTukl99kQgDCTaHh9bc3k6dZ80Uz 8C6/Jnu6hULNIdUXJf7xvuRYgkucfHQFS3kUBeKbuDZkuj/lqoZji46L2U/zgUAa5KK6 4k2WnvOt6luc4cKMDRL2OnCWnS55zmadBxqjKSnsh/M2pnZc1matvNrTKTULCIrfcgtK A3qw== X-Gm-Message-State: AOAM530O/DmCD5Y21bd0/x0xfdLJKQGDtlGmTckmf6ZET6d8iLsRYO1H Oq6zRidBmyC9feRMxf6WgLlTH1XTLhNJyE8YTT/X6A== X-Google-Smtp-Source: ABdhPJxFBpU3g3yHnPBLVGd3qkkrW7OXzVNHhMwGCPvrtayFNXkdt1G/PyIzKjMXKbB3J3aS1/FwZfjWJi7InoNO29E= X-Received: by 2002:a05:6402:6d6:: with SMTP id n22mr2912538edy.79.1598910287550; Mon, 31 Aug 2020 14:44:47 -0700 (PDT) MIME-Version: 1.0 References: <20200817212554.3844965-1-yudiliu@google.com> <20200817142545.RFC.v2.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> <CABBYNZLRqhB6d5Hm7_RqvUqCJo11D4+pgYLCeWj0j=8dZk0Bcg@mail.gmail.com> <CAHC-ybxshy5zmkAku6suicvjO0Ngofp0+gRyYLX_RXr9YhU94Q@mail.gmail.com> In-Reply-To: <CAHC-ybxshy5zmkAku6suicvjO0Ngofp0+gRyYLX_RXr9YhU94Q@mail.gmail.com> From: Yu Liu <yudiliu@google.com> Date: Mon, 31 Aug 2020 14:44:11 -0700 Message-ID: <CAHC-ybxFY_3HWrvnwF5DS-i-YJtYpUuR9K3-MSWJWo=C-CKQHA@mail.gmail.com> Subject: Re: [RFC PATCH v2 1/1] adapter - D-Bus API for querying the adapter's capabilities To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>, Alain Michaud <alainmichaud@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.92 / 15.00 / 200.00 X-Rspamd-Queue-Id: D8A22420C8 X-Rspamd-UID: 3e4053 +Alain Michaud Hi Marcel, Can you please comment on the cl as well as Luiz's suggestion? Thanks. On Thu, Aug 20, 2020 at 10:20 AM Yu Liu <yudiliu@google.com> wrote: > > Friendly ping for comments from Marcel. Thanks. > > > On Mon, Aug 17, 2020 at 4:17 PM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Marcel, > > > > On Mon, Aug 17, 2020 at 4:07 PM Yu Liu <yudiliu@google.com> wrote: > > > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > > > Initially this is introduced to query whether WBS is supported by the adapter, > > > the API is generic enough to be extended to support querying others in > > > the future. > > > > > > Reviewed-by: sonnysasaka@chromium.org > > > > > > Signed-off-by: Yu Liu <yudiliu@google.com> > > > --- > > > > > > Changes in v2: > > > - Return an array of strings instead of a dict > > > > > > Changes in v1: > > > - Initial change > > > > > > doc/adapter-api.txt | 12 ++++++++++++ > > > 1 file changed, 12 insertions(+) > > > > > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt > > > index 1a7255750..8fbcadb54 100644 > > > --- a/doc/adapter-api.txt > > > +++ b/doc/adapter-api.txt > > > @@ -204,6 +204,18 @@ Methods void StartDiscovery() > > > org.bluez.Error.NotReady > > > org.bluez.Error.Failed > > > > > > + array{string} GetCapabilities() > > > + > > > + This method returns a list of supported > > > + capabilities that is populated when the adapter > > > + initiated. > > > + > > > + Possible values: > > > + "wbs" - Wide band speech > > > > Btw, should we stick to use wbs terminology here, or we should > > actually use the HCI feature/command, because wbs has actually to be > > implemented by the HFP afaik this is only indicating that the > > controller is able to notify packets drops, etc, with use of erroneous > > command. Perhaps we should actually use the term PLC (Packet Loss > > Concealment) instead since that seems to be the real capability here, > > afaik WBS does not actually require PLC. > > > > > + > > > + Possible errors: org.bluez.Error.NotReady > > > + org.bluez.Error.Failed > > > + > > > Properties string Address [readonly] > > > > > > The Bluetooth device address. > > > -- > > > 2.28.0.220.ged08abb693-goog > > > > > > > > > -- > > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4FhFHQS+TV9C5AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 05:20:36 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id iBCXGwS+TV86zgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 05:20:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C1743420C8; Tue, 1 Sep 2020 05:20:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbgIADT4 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 23:19:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgIADTy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 23:19:54 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAE32C061366 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 20:19:53 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id c18so7861577wrm.9 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 20:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hW/k5b9/UGfTLPykwG66a89mG1GM25fvIAacARRYbQA=; b=e7E9L10SJs5IBDAZauvK6MQqSkpt3e/LYFm43uCeyFCp+3fz7mHQOxNxB7nLRJ1az0 7kWra/Z+/3KeUDaZV6V2XsMrnlrAuzDOREOMpfa04rt7EXHl25JzJNHYTce/86uNLuEm JRdZjrnukkzsarZCXC/JgbIq0l5S1sxCQQ+Q13c8+rWoFyQqK4MwD3E1BxzcF56f0Mk+ k1gjuCdtjope4C9GF+cfj1RxsuSbh/zBi/3KU9O2iPly8SOQuEKKzI7cbvYXpTovJj2u fEXddUtcb6oaWt4efwDcCMWHaqAeJ5R6hBrQCZcXDSYZ4XHOvm4h7VpopBILf+zch5BM cR6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hW/k5b9/UGfTLPykwG66a89mG1GM25fvIAacARRYbQA=; b=olJ159smOLV71AQAYB9VIAQEjciegvtFGhRIPgSlyYP9GepjupwNlVEFwu6+xL4J2S xED5xx2LMJkS0Ok+bVUtPIlvLt4pXwCGHJSkPdqs/hSRLJDov+fJJ102XeaZ6RGTst1l WHXDyHK44+jv5YXwyYVV1X/rxgglgQ2+25ckoiWaowXLuk/WAJosTGCed82LKdx0MkbL WSGvlK8ldu92nIbEtlS+cMhCGhtdcPGnUTjZhKSg2oib9nyyY8lw2ITepOKA2EUuLfk0 iFdkoJXkSSMjRtDhWvvchIHtzp0gax08fc9kyBdYjwm41f/a9ukeBA3HGuaqKYWHj9vY Bndg== X-Gm-Message-State: AOAM531ekReeuMVIuNS+QWr9cPGtUC75I6oWJxZ7tWNabZx4XvwQtBpn lH5Pqep8GinihyICcZw/0ARdx9tgi4gFl5stxj9oDg== X-Google-Smtp-Source: ABdhPJwiHkO4ftDBidx4SD3qYBXYINBJPu7nwrUNXd5vNl5bFOD0LEYL7Voe6+utfzz1un+WC0rXhARPz6AwHV9YlnU= X-Received: by 2002:adf:dcc3:: with SMTP id x3mr4203661wrm.120.1598930392369; Mon, 31 Aug 2020 20:19:52 -0700 (PDT) MIME-Version: 1.0 References: <20200831153544.Bluez.v1.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> <CABBYNZ+Q84vmEDgfNuoYXAAMi6T3segO_hSkG5Oufc5F_w9Qeg@mail.gmail.com> In-Reply-To: <CABBYNZ+Q84vmEDgfNuoYXAAMi6T3segO_hSkG5Oufc5F_w9Qeg@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Tue, 1 Sep 2020 11:19:41 +0800 Message-ID: <CAJQfnxHyzFAG6zJfsuneLX_rW8yNkd2ZpKotHu3DV6vZABT-qw@mail.gmail.com> Subject: Re: [Bluez PATCH v1 1/2] doc/media-api: Add Press method for MediaPlayer1 To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: 0.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: C1743420C8 X-Rspamd-UID: 9ceab3 Hi Luiz, The reason we introduced this method is because we need to send some of AVRCP category 2 passthroughs in order to be able to qualify the AVRCP absolute volume control as an audio source, despite we don't actually plan to send any passthrough in the practice. Therefore, which passthrough we send is actually not important (to us), as long as we can do that to satisfy the requirement. However, I see that there are over 50 passthroughs across category 1 - 4, and thought that it would be cumbersome to have a different method for each key if one day we decided to support them all, hence the generic method. May I have some questions? (1) Why do you prefer a dedicated method per key? (2) Let's say I need to add a dedicated method for a single category 2 passthrough key, do you have a key in mind or I can just pick by myself? Thanks, Archie On Tue, 1 Sep 2020 at 01:16, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Archie, > > On Mon, Aug 31, 2020 at 12:37 AM Archie Pusaka <apusaka@google.com> wrote: > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > This allows us to send any passthrough command. > > > > Reviewed-by: Michael Sun <michaelfsun@google.com> > > --- > > > > doc/media-api.txt | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/doc/media-api.txt b/doc/media-api.txt > > index dabc69936..fe7222eef 100644 > > --- a/doc/media-api.txt > > +++ b/doc/media-api.txt > > @@ -199,6 +199,14 @@ Methods void Play() > > Possible Errors: org.bluez.Error.NotSupported > > org.bluez.Error.Failed > > > > + void Press(byte avc_key) > > + > > + Press a specific key to send as passthrough command. > > + > > + Possible Errors: org.bluez.Error.InvalidArguments > > + org.bluez.Error.NotSupported > > + org.bluez.Error.Failed > > + > > Properties string Equalizer [readwrite] > > > > Possible values: "off" or "on" > > -- > > 2.28.0.402.g5ffc5be6b7-goog > > For now I would prefer to use dedicated method per key or are there > many keys you would like to use from the upper layer? > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KJC0GlS/TV+QEgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 05:26:12 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id OJyGGFS/TV/DSAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 05:26:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9ECD0420C8; Tue, 1 Sep 2020 05:25:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726266AbgIADZw (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 23:25:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgIADZw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 23:25:52 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8439C0612FE for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 20:25:51 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id c19so10037wmd.1 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 20:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eqMmEzrpBcmZfuBtVzyCkIHZdVQ8yR7aZA+nyrHR4cM=; b=U9Z1a551O7jPPiOnFI+xkedmsYEgVNED/esAs+wjzN0f7BxDLp0lXalNTx8PHsxbkY aW//NxJz2fIRSMfxQU+jXQ67NJVQt481AgnH905ka/Y3vxbU02GmGaL7HQemcW+19fP4 yxZOvUxyEaGIINwATsSuZahErCE/Wb8IOxQXRN2BFH1/yaTMv/d2xxXONmRuHzhzBbcV k68tQplaxYvOkDgHfgp11uOTfSQqWn/nakOZlwfa2dXnuBJg1HRYbO2G4fUomqKkiiz5 KHvhqTI2vUQdCrnzjAWX8JmJ9x3kT7Nw6w/LgtI5uRQIlRZxL8YfL8HSrpyjFmsrbNdf rKpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eqMmEzrpBcmZfuBtVzyCkIHZdVQ8yR7aZA+nyrHR4cM=; b=MiWWPCYsoHhRGr92ZrQluaD6lQVH5b+rmeTGQIjYMvnKvWgo76PJHW9P1aVYDj+ruG YJjf8UCijIueQAGcD+E5DF99s4fxcl2AmgSWgyMgfYvnBzh8p+2IW+BKUaO7+PY2t64z X9HtmrvcetCWDl5qqTmq3Q0CE2B1vXQqgYV3CLMNlPyeIWsdsE9owjQeEHlqu72q1Gg+ ocQjtA0b9/NREHT+5BYqYG8EyT9b+mUJtcFfFUuold6ECgETeTmT83dL3u2XSxMcEpAJ P/2C97VMgI80KqU9wO7fTdQ/jlgvvZNDHfArDasx2Sg1jc/o6ycMQnTap5d4PPZba3Dq yyKQ== X-Gm-Message-State: AOAM531MT8SgypDbvTor+t3xY6aK8P01YQW2PqpQt2F7amSCbSaw8Q1n 5l54x/pF0WS4CoW/nMwxLLLQoWB8nDv5L39MQc5S+A== X-Google-Smtp-Source: ABdhPJy+KCVQSeODD3mfPKqJJoa3a/L58rsFLlf4xa6jzpHowdr4+I7w5KlLxp4I7QoSwdkLzpMI+LZTaqgcY5TRpeo= X-Received: by 2002:a7b:c401:: with SMTP id k1mr28190wmi.18.1598930747750; Mon, 31 Aug 2020 20:25:47 -0700 (PDT) MIME-Version: 1.0 References: <20200831154443.Bluez.v1.1.Ieeae14ab680eda03474551fdb7a0a020f950e9c1@changeid> <CABBYNZJhkBJY7+Y73tdpV_ca5dmoiYhutq5iONAMbCjD+EL+zQ@mail.gmail.com> In-Reply-To: <CABBYNZJhkBJY7+Y73tdpV_ca5dmoiYhutq5iONAMbCjD+EL+zQ@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Tue, 1 Sep 2020 11:25:36 +0800 Message-ID: <CAJQfnxHriLk_G0Mk-23uPankc1peCrHVFyORFasbm-UfV5gunQ@mail.gmail.com> Subject: Re: [Bluez PATCH v1] media: Don't set initial volume if it's invalid To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com>, Yu Liu <yudiliu@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: 0.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9ECD0420C8 X-Rspamd-UID: fbe659 Hi Luiz, On Tue, 1 Sep 2020 at 01:20, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Archie, > > On Mon, Aug 31, 2020 at 12:45 AM Archie Pusaka <apusaka@google.com> wrote: > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > When initializing media transport, we try to initialize the volume > > of the player. However, the assigned initial volume could be invalid > > due to the session has not been initialized, or when we assume the > > role of audio sink. In this case, we should not assign the initial > > volume. > > Not really following the explanation here, if the session has not been > initialized yet shouldn't the volume be actually invalid? Or is the > problem that we don't call media_transport_update_volume later when it > is initialized? Yes, the volume should be invalid by that time. However, the default value is invalid anyway so there is no need to reassign an invalid volume again. We still call media_transport_update_volume when the session is initialized later. > > > Reviewed-by: Michael Sun <michaelfsun@google.com> > > Reviewed-by: Yu Liu <yudiliu@google.com> > > --- > > > > profiles/audio/media.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/profiles/audio/media.c b/profiles/audio/media.c > > index 02bf82a49..acb4a8ee9 100644 > > --- a/profiles/audio/media.c > > +++ b/profiles/audio/media.c > > @@ -494,7 +494,8 @@ static gboolean set_configuration(struct media_endpoint *endpoint, > > return FALSE; > > > > init_volume = media_player_get_device_volume(device); > > - media_transport_update_volume(transport, init_volume); > > + if (init_volume >= 0) > > + media_transport_update_volume(transport, init_volume); > > You can probably move the check to be done internally inside update_volume. Correct, I will do so. > > > msg = dbus_message_new_method_call(endpoint->sender, endpoint->path, > > MEDIA_ENDPOINT_INTERFACE, > > -- > > 2.28.0.402.g5ffc5be6b7-goog > > > > > -- > Luiz Augusto von Dentz Thanks, Archie Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KIfVNNW/TV+QEgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 05:28:21 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4KccM9W/TV8sOQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 05:28:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2783542121; Tue, 1 Sep 2020 05:28:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726326AbgIAD1n (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 23:27:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgIAD1n (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 23:27:43 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B41C0C0612FE for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 20:27:42 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id z4so5108073wrr.4 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 20:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZvfKyEsORwjIi8Yl5iGwTWA+U3ccsHL5F+yZy/hSxPw=; b=RrcDNVssnho0vBsBCKwwxwcJBfhzSwYsyywgx8lNjBbSsKSlsDvdU+g256ZAt2kWAp JmlX9IlKjyve0AxaSLOOuQYSx1hVJPpy2n+93dPZmtUF3zgbo6oKjYSwP5RRNtLcddM4 rVh58ydGaFziufBNcRuxDqLpIJhF0AecqeISBQ6S/tv6s9AFoETuPSl2LnUND+3C3/CG AWY5OckL2jHXWliFtv7zQaxwAb39FHy0cAJpVLEisaiiIZlVnePbYxKFh7YXkZeIJeFs A5bWFUPD99nJSJkSIp//Y/akFCqvOWBObSB1YmqaIkb1hGoHfCma4rRJNTcsjqcVAO19 Khow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZvfKyEsORwjIi8Yl5iGwTWA+U3ccsHL5F+yZy/hSxPw=; b=Mj/j8NrtieeuexeV/FDhParju+3TBLSKicNpWs8IgWOUZIAH035K4fDR8k4mULEcMe R4/AgAKRSNOqXJk3u8G4a1lExVM62Zv6BomRHrgUcTTscl1FIIgSYHg6cfy0GnY7h646 WOFWzxpaOQ+gZcjdU8T7+rNjKQ1CN6uYE0sOjRbnG4tAg8SM4Bfg67EetSuTwcmnIN8x n7DDeCyl1URFYS05Xit+IY1bFbiV0nzcy4f5wCSuituW1t0iE6baATPGc0b7h1Dtyt/K treawiy1i/tEw21J/2KEIT2/LS+wyUugH6DwCTlw43HEnfimz7kHDgkHX1Hztdg7XEbx 417w== X-Gm-Message-State: AOAM532JWFAlliOcQKfuWhIGInzp2FL8rs1Vin/7nmw/cHM6q3biHM+D wbxQtHZR/bRMzHQQGqebhe7KXGB5yXP7+RAtarlYfg== X-Google-Smtp-Source: ABdhPJx7hptAE0c5dIBJ1XR8jdj5DYtW53Fr1l80ug398v5yGkFZPqGpI/RhlREkD321OQT9BTo2BQcdT3fpV7CChuk= X-Received: by 2002:adf:fa0c:: with SMTP id m12mr4175001wrr.406.1598930861037; Mon, 31 Aug 2020 20:27:41 -0700 (PDT) MIME-Version: 1.0 References: <20200831161140.Bluez.v1.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> <CABBYNZLTY_cFcttmMdiBH7PNU1xT2bw-eKnOQkHDak3+Y8WrXQ@mail.gmail.com> In-Reply-To: <CABBYNZLTY_cFcttmMdiBH7PNU1xT2bw-eKnOQkHDak3+Y8WrXQ@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Tue, 1 Sep 2020 11:27:30 +0800 Message-ID: <CAJQfnxH2hcAtLOCd4MywT+ydzTchGX7S+7Vb+b3vgmDvEQ6GHA@mail.gmail.com> Subject: Re: [Bluez PATCH v1] device: don't wait for timeout if RemoveDevice is called To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: 0.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2783542121 X-Rspamd-UID: 2a4dc2 Hi Luiz, On Tue, 1 Sep 2020 at 01:35, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Archie, > > On Mon, Aug 31, 2020 at 1:12 AM Archie Pusaka <apusaka@google.com> wrote: > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > RemoveDevice on adapter interface used to remove a device, even when > > the device is connected. However, since the introduction of the new > > 30 seconds timeout when setting a device as temporary, RemoveDevice > > doesn't immediately remove a connected device, but only disconnects > > it and waits for the timer to expire before effectively removes it. > > > > This patch removes the device as soon as it gets disconnected, > > provided the disconnection is triggered by a call to RemoveDevice. > > The regular timeout still applies for other cases. > > > > Tested manually by calling RemoveDevice on a connected device, > > and with ChromeOS autotest setup. > > > > Reviewed-by: Daniel Winkler <danielwinkler@google.com> > > --- > > > > src/adapter.c | 2 -- > > src/adapter.h | 2 ++ > > src/device.c | 11 +++++++++++ > > 3 files changed, 13 insertions(+), 2 deletions(-) > > > > diff --git a/src/adapter.c b/src/adapter.c > > index 5e896a9f0..d6c65ff69 100644 > > --- a/src/adapter.c > > +++ b/src/adapter.c > > @@ -79,8 +79,6 @@ > > #include "advertising.h" > > #include "eir.h" > > > > -#define ADAPTER_INTERFACE "org.bluez.Adapter1" > > - > > #define MODE_OFF 0x00 > > #define MODE_CONNECTABLE 0x01 > > #define MODE_DISCOVERABLE 0x02 > > diff --git a/src/adapter.h b/src/adapter.h > > index f8ac20261..f835c984f 100644 > > --- a/src/adapter.h > > +++ b/src/adapter.h > > @@ -26,6 +26,8 @@ > > #include <dbus/dbus.h> > > #include <glib.h> > > > > +#define ADAPTER_INTERFACE "org.bluez.Adapter1" > > + > > #define MAX_NAME_LENGTH 248 > > > > /* Invalid SSP passkey value used to indicate negative replies */ > > diff --git a/src/device.c b/src/device.c > > index bb8e07e8f..cee0ddfd2 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -3001,6 +3001,7 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type) > > void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > > { > > struct bearer_state *state = get_state(device, bdaddr_type); > > + bool remove_device = false; > > > > if (!state->connected) > > return; > > @@ -3018,6 +3019,10 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > > while (device->disconnects) { > > DBusMessage *msg = device->disconnects->data; > > > > + if (dbus_message_is_method_call(msg, ADAPTER_INTERFACE, > > + "RemoveDevice")) > > + remove_device = true; > > + > > g_dbus_send_reply(dbus_conn, msg, DBUS_TYPE_INVALID); > > device->disconnects = g_slist_remove(device->disconnects, msg); > > dbus_message_unref(msg); > > @@ -3043,6 +3048,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > > > > g_dbus_emit_property_changed(dbus_conn, device->path, > > DEVICE_INTERFACE, "Connected"); > > + > > + if (remove_device) > > + btd_adapter_remove_device(device->adapter, device); > > } > > > > guint device_add_disconnect_watch(struct btd_device *device, > > @@ -4457,6 +4465,9 @@ void device_remove(struct btd_device *device, gboolean remove_stored) > > disconnect_all(device); > > } > > > > + if (device->temporary_timer > 0) > > + g_source_remove(device->temporary_timer); > > + > > if (device->store_id > 0) { > > g_source_remove(device->store_id); > > device->store_id = 0; > > -- > > 2.28.0.402.g5ffc5be6b7-goog > > Does not apply: > > Applying: device: don't wait for timeout if RemoveDevice is called > error: patch failed: src/device.c:3001 > error: src/device.c: patch does not apply Oops, let me rebase and resubmit. > > > > -- > Luiz Augusto von Dentz Thanks, Archie Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0C6uFiDCTV9C5AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 05:38:08 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AG7DFCDCTV8H0wEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 05:38:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 67951420CF; Tue, 1 Sep 2020 05:37:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726255AbgIADhy (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Mon, 31 Aug 2020 23:37:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgIADhy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 31 Aug 2020 23:37:54 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C1D5C0612FE for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 20:37:54 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id e1so11647764ybk.14 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 20:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=LNBYe2bPyaTncbo6rNP7apjWhIf3bf+Cen1nymRRMqE=; b=S34esk/XXEqYkNMO5Z8LKXgKO+IfTlyQbdTO18FGw38ofniNtAH/uDm/HDMPzOQreh /fDUjeTWeQcx+y4UQf7Ap51cm0fOqG47FjMhj+eykdHNMMzP+u1WM2cmosEFcNNLC79B f+lEglZ8H4/WFK1np6AYLITIeaMQ60ZUx+WzsLe7/8XqygDJpKOreBX57Pq2jb/1olL6 CysBrI8Lb5274TGrFrk8otq8Ibrd9k74EKM28pPJtkhVtPC5hykdB5w1hj1Zl5/hhNOh IE9LMBTlm5TRZHvCO1djigo46c0/iQy1jINUEeQed2URJl9N29P1u+ItMJG4TSnFJU80 f/Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=LNBYe2bPyaTncbo6rNP7apjWhIf3bf+Cen1nymRRMqE=; b=DAn7xw26OaGR4/i05ipQmfqNEAc0e5yY4fYGzllOq5mTbwO5HxuapET4eyO/QuoDjj 27exc4L9w251h7xRJS2lMkmAbPK6T+eCjrfkAEUpogd7Op4dKYXs02h0k+mz5MKr6Qf7 eJkxFsJrElcE2i0y+6xJBcCP4/KYr3GmcxkoGkeyuNpTZrs+ypgTz9ozxDiB2tRsBB8i +/VakrQxJKlGYf+fwd1h8h2FDWYbGJUjpxxIkfktClMpIgpSuh6lrj7j2zbRJtpCNy8I Ehr9BOGW+1XUSynfQWdqt4xUHN+oVtLHXKKl40Fx7qggVpXYt0xl40kO77EPQGFUz6op pBHg== X-Gm-Message-State: AOAM532iicwj77s4MZqyzBdH3Bv4bTSgV3MM3vNk8EnT2DWK7xAmaus9 Y5Zyf17731t0nbIsBurfoSOe8zw2ZeRQZrkTeiFZROfvxC8SXZzw2JHEio2if9oee6Vb1RhdWto U3ZswPHHxkC+40HJRXdZiWjwZg/RRONym7sAvu7UYO2hwWaQ3ygnGZ87RB1zJxh95cowdj/XI/Q y4 X-Google-Smtp-Source: ABdhPJxG/BTV1qfGQR/fDv0zawJgXU71zmZqzm9s2P3vzwO195rqeP0d3PsrDB+ZS97wu+/59mlxibpLdC7u X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a05:6902:1026:: with SMTP id x6mr7708269ybt.349.1598931473141; Mon, 31 Aug 2020 20:37:53 -0700 (PDT) Date: Tue, 1 Sep 2020 11:37:46 +0800 Message-Id: <20200901113736.Bluez.v2.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v2] device: don't wait for timeout if RemoveDevice is called From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: 0.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 67951420CF X-Rspamd-UID: 6ddbfc From: Archie Pusaka <apusaka@chromium.org> RemoveDevice on adapter interface used to remove a device, even when the device is connected. However, since the introduction of the new 30 seconds timeout when setting a device as temporary, RemoveDevice doesn't immediately remove a connected device, but only disconnects it and waits for the timer to expire before effectively removes it. This patch removes the device as soon as it gets disconnected, provided the disconnection is triggered by a call to RemoveDevice. The regular timeout still applies for other cases. Tested manually by calling RemoveDevice on a connected device, and with ChromeOS autotest setup. Reviewed-by: Daniel Winkler <danielwinkler@google.com> Signed-off-by: Archie Pusaka <apusaka@chromium.org> --- Changes in v2: * Rebasing to HEAD src/adapter.c | 2 -- src/adapter.h | 2 ++ src/device.c | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 1435e2bd7..ffd05aa0b 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -79,8 +79,6 @@ #include "advertising.h" #include "eir.h" -#define ADAPTER_INTERFACE "org.bluez.Adapter1" - #define MODE_OFF 0x00 #define MODE_CONNECTABLE 0x01 #define MODE_DISCOVERABLE 0x02 diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..f835c984f 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -26,6 +26,8 @@ #include <dbus/dbus.h> #include <glib.h> +#define ADAPTER_INTERFACE "org.bluez.Adapter1" + #define MAX_NAME_LENGTH 248 /* Invalid SSP passkey value used to indicate negative replies */ diff --git a/src/device.c b/src/device.c index df440ce09..f20270017 100644 --- a/src/device.c +++ b/src/device.c @@ -3007,6 +3007,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) { struct bearer_state *state = get_state(device, bdaddr_type); DBusMessage *reply; + bool remove_device = false; if (!state->connected) return; @@ -3036,6 +3037,10 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) while (device->disconnects) { DBusMessage *msg = device->disconnects->data; + if (dbus_message_is_method_call(msg, ADAPTER_INTERFACE, + "RemoveDevice")) + remove_device = true; + g_dbus_send_reply(dbus_conn, msg, DBUS_TYPE_INVALID); device->disconnects = g_slist_remove(device->disconnects, msg); dbus_message_unref(msg); @@ -3061,6 +3066,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) g_dbus_emit_property_changed(dbus_conn, device->path, DEVICE_INTERFACE, "Connected"); + + if (remove_device) + btd_adapter_remove_device(device->adapter, device); } guint device_add_disconnect_watch(struct btd_device *device, @@ -4477,6 +4485,9 @@ void device_remove(struct btd_device *device, gboolean remove_stored) disconnect_all(device); } + if (device->temporary_timer > 0) + g_source_remove(device->temporary_timer); + if (device->store_id > 0) { g_source_remove(device->store_id); device->store_id = 0; -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8OSdDx7aTV+waQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 07:20:30 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id oMOODR7aTV9mkgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 07:20:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7270E42121; Tue, 1 Sep 2020 07:20:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725993AbgIAFUQ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 01:20:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725930AbgIAFUP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 01:20:15 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70E1FC061290 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 22:20:13 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id e23so121092otk.7 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 22:20:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KRFwGBLakySRCLBsud3HZmRY9ihXCzODxn9dGXiuihA=; b=up/SpoL5psQ1eMDz4BwrF7HNBqUJKRmuT6ZgPPKNsVIJVha+QfIpE3DTNIuc+LWcIe XUXeLrc/afL2CdJP5SRRSM0pwdI20Uld8ZbVuy7wHlPg2aoPOIhn6krvXAcv2PczUJPQ qRAx1uQ5xWQGGpJa4KIIi9LUHmMBmwlKLXj2ViII1nGgbTUoO+Uz03VY2+1zwpTtvY0f Gk00FYYtOE8NkkxfyLclAx58kpSZX0OIXimmSHFeZm1QUGYcoqKviJfVrctna2lbtoVa EZbEyFoAZOoal746r4GZOBAgHXhy8pPPrg1CwsgOx4fChT1iuNnq07CqAV00QG5ii/uH /JtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KRFwGBLakySRCLBsud3HZmRY9ihXCzODxn9dGXiuihA=; b=IA+jvhfcgi+Kz5zvnz/Q8AvNEyYHWwsKzYl9WgDo1p3kaVizm9NKYDeekbnyI3pxiW 6craHAYeNgWBhxYk50woozzZOEd2VXbiq+g6gmpcSVe60i4dNT7S1t5tPMw9XhNhpPuI kf+9tID8bVh2Hy4Vlw1TOVxAfpjomy5PEEpFx8DMZCxVbIxHyNEMWIWjfNrp4oT/pdGi uAzBYXGXqDdf9OgpWl+WoYGlIoddtb159vC9ElAWN2KSmsdLcevprGz5wVHsPScH3e8o cHyumpB4c2yFA6vDWcIQU7PrZcLvrMTAIyJmQR7Sh9GUmL0yyMrSD7VLB82i2VEVww2j kTFQ== X-Gm-Message-State: AOAM530/MyBr1aG0E8C+p/zw266zWw0IGLDFjnpwP0ccD5zYTQz7W1zK Ak1giE5jlWRqkW1KIl94R0iQ2A0MceLzki+iec4= X-Google-Smtp-Source: ABdhPJysurRlWe9JH95EiXQVHEmQZJrS3SbjnGV09l1/IsVFHXDGJExrVCRlC8SWRZry2dbTORxhFwhX7y7OhOVh/Zc= X-Received: by 2002:a9d:429:: with SMTP id 38mr194835otc.88.1598937612625; Mon, 31 Aug 2020 22:20:12 -0700 (PDT) MIME-Version: 1.0 References: <20200831153544.Bluez.v1.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> <CABBYNZ+Q84vmEDgfNuoYXAAMi6T3segO_hSkG5Oufc5F_w9Qeg@mail.gmail.com> <CAJQfnxHyzFAG6zJfsuneLX_rW8yNkd2ZpKotHu3DV6vZABT-qw@mail.gmail.com> In-Reply-To: <CAJQfnxHyzFAG6zJfsuneLX_rW8yNkd2ZpKotHu3DV6vZABT-qw@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 31 Aug 2020 22:20:02 -0700 Message-ID: <CABBYNZJ4Y-U1nvyBvFwUXf+c0uT-42pBbrNtBG_G4RhLXGYspw@mail.gmail.com> Subject: Re: [Bluez PATCH v1 1/2] doc/media-api: Add Press method for MediaPlayer1 To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: 0.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7270E42121 X-Rspamd-UID: 8a3153 Hi Archie, On Mon, Aug 31, 2020 at 8:19 PM Archie Pusaka <apusaka@google.com> wrote: > > Hi Luiz, > > The reason we introduced this method is because we need to send some > of AVRCP category 2 passthroughs in order to be able to qualify the > AVRCP absolute volume control as an audio source, despite we don't > actually plan to send any passthrough in the practice. I wonder what those are, are they volume up/down? > Therefore, which passthrough we send is actually not important (to > us), as long as we can do that to satisfy the requirement. > However, I see that there are over 50 passthroughs across category 1 - > 4, and thought that it would be cumbersome to have a different method > for each key if one day we decided to support them all, hence the > generic method. Yep, but there are button presses so things gets a little more complicated if we need to emulate press/hold/release semantics. > May I have some questions? > (1) Why do you prefer a dedicated method per key? > (2) Let's say I need to add a dedicated method for a single category 2 > passthrough key, do you have a key in mind or I can just pick by > myself? > > Thanks, > Archie > > > On Tue, 1 Sep 2020 at 01:16, Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Archie, > > > > On Mon, Aug 31, 2020 at 12:37 AM Archie Pusaka <apusaka@google.com> wrote: > > > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > > > This allows us to send any passthrough command. > > > > > > Reviewed-by: Michael Sun <michaelfsun@google.com> > > > --- > > > > > > doc/media-api.txt | 8 ++++++++ > > > 1 file changed, 8 insertions(+) > > > > > > diff --git a/doc/media-api.txt b/doc/media-api.txt > > > index dabc69936..fe7222eef 100644 > > > --- a/doc/media-api.txt > > > +++ b/doc/media-api.txt > > > @@ -199,6 +199,14 @@ Methods void Play() > > > Possible Errors: org.bluez.Error.NotSupported > > > org.bluez.Error.Failed > > > > > > + void Press(byte avc_key) > > > + > > > + Press a specific key to send as passthrough command. > > > + > > > + Possible Errors: org.bluez.Error.InvalidArguments > > > + org.bluez.Error.NotSupported > > > + org.bluez.Error.Failed > > > + > > > Properties string Equalizer [readwrite] > > > > > > Possible values: "off" or "on" > > > -- > > > 2.28.0.402.g5ffc5be6b7-goog > > > > For now I would prefer to use dedicated method per key or are there > > many keys you would like to use from the upper layer? > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mFujGFrHTV+xZgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 06:00:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id oL8pF1rHTV/dAgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 06:00:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 85EAC4215F; Tue, 1 Sep 2020 06:00:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725989AbgIAEAM (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 00:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725930AbgIAEAL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 00:00:11 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F28DC0612FE for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 21:00:11 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id y4so2004987pff.13 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 21:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=z0eYPoeOBrp5E0yT01/cy3y5DSF+S81jtW2iN+6CTSE=; b=k8rnRio/W/28dqBVEpQ5A/DeAtFOaJ2sLOBxo9LUuUbY68mdS76p9inJNKlgBVJn9Q e6FhfzmghguaoFMP15Y7hM+tbBWAWyatNwXl6Zv47uqh1EBtANvs7F0PwGnY6ZaLGbXO thaihSUf+LYmV4NLcZxbgIKWKBrZk3az3Zzp2RC7W1cWQFXh92M7m2rQ0FWKdC5SLrwr rY++b9su4h0OWImc8+8K/lLbcRGQYoMItA/GXLYN/FWbbhp2EB6F3I41CogE/AhHkpnt koTyv8NbXWchHRspFnMqF7MkiDDtwKgEFzIaYY6fQHyLy3PEE3LDXn5XFP738RI5IgoX P/Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=z0eYPoeOBrp5E0yT01/cy3y5DSF+S81jtW2iN+6CTSE=; b=iDbyZgHcNj9aKUFd2S8XJsAlQJHuGhJpmsBz0Jqf1Pku29sUB9PZEaR5sg/3+50onw O324OWZ/+pGZRmtzjwTYXJpEs/A0x2NuhzVrZo7u6GrgLuO+NTNfLPByMNf+2zuZndVq i3kYBTYTO7bbvT3sMHlHY11hOZYQS5WceLzL9QCanQpSFCXubV47aWG7llbMO9GvHzky ELOS504X2PQFWp8ZqzzMwpP6L/sfV9nysQrARqgdyxtep6QGmck7MseC1E4beMqE0w6t Zc+er9x1Za4CbE23OyLCL6kIHp/czQlJn4KhOV+3FyDY67acNemN0vAeulIT+BgVdpxE 7ycA== X-Gm-Message-State: AOAM531jf4wHMQ4NHM7W0L0W1cHDuE/310NFcWYGipMSt+qE6sITR5C9 rMkMh7GpaHjk5yjWBhmLn2lQPyymjl/lRYlTYHXsG4ODOPcUlB+SeMr0im9gj5e7GW8iHgpFkLi YfgoiMYqd6v6V37tCRoGqnRaHE05xzU0Sl1WHYEe+BmWKl9KsOir/+jxzM21z3F1/x71dA7oE44 uT X-Google-Smtp-Source: ABdhPJwt56jPjdKVqqBgwAmOYq1rYPl6j39lJHkWzI2GtYTbATd6pc0ueiwNXq5A5HnOCOw4JyzVH2yDpm4f X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a17:902:8488:b029:d0:4c09:c0 with SMTP id c8-20020a1709028488b02900d04c0900c0mr100062plo.2.1598932810915; Mon, 31 Aug 2020 21:00:10 -0700 (PDT) Date: Tue, 1 Sep 2020 12:00:00 +0800 Message-Id: <20200901115913.Bluez.v2.1.Ieeae14ab680eda03474551fdb7a0a020f950e9c1@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v2] audio/transport: Don't set volume if it's invalid From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: 0.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 85EAC4215F X-Rspamd-UID: 89a7b5 From: Archie Pusaka <apusaka@chromium.org> Adding a check inside media_transport_update_volume to prevent the volume being updated with an invalid value. --- Changes in v2: * Move the check from media.c:set_configuration profiles/audio/transport.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index a2c4f7dfb..dd1c553a2 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -941,6 +941,9 @@ void media_transport_update_volume(struct media_transport *transport, { struct a2dp_transport *a2dp = transport->data; + if (volume < 0) + return; + /* Check if volume really changed */ if (a2dp->volume == volume) return; -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2N+hGTzdTV+K2AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 07:33:48 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id qMxtGDzdTV8ltgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 07:33:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 26B2DA238F; Tue, 1 Sep 2020 07:33:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726130AbgIAFdg (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 01:33:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbgIAFde (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 01:33:34 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2EFEC061290 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 22:33:32 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id o5so4193467wrn.13 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 22:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OMSYJRKXJ9UZBEBmYlNcCrdjo4Oyld9VegMp+OutfRo=; b=O9nkLnJ/gKybOEyH2OCtKD//i4X4q1TQtxp8fYyNYU/UoMGo/0DJkhAyYNuBAokYA8 iLeFBXreBn4Bs3xsKAEViX8n6qPFU/1noOFABd+BXwdRMISaTiL+q+9Z2byZJrdda0/K 5rADqfxLbDchJZ25N/3jIFZvlQQHUEElOjYPRIB73q8ZhKhIpAosZrgQ7gOtJ9gSOPjh 5kAPYbd9V5FDQ0y1K02pBb2leeY72UWepiuijWVOHA/ettLZ2Kyfd9DOm+GG4yRBmbtU N0K9pSRYeN2vstDnqY5o9j1v7rmyjSsAsM3r2wZqGKmKfPc9wqH4pTYDWSmJpLbNtzSO tCjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OMSYJRKXJ9UZBEBmYlNcCrdjo4Oyld9VegMp+OutfRo=; b=FNpFmc91pZ6BJ5vzMOJkO4IxKfPK78TskeP/AYqkao0i9JLvz1bgB+jeTIG3at4Lwo kvhNEC7ioPfIIO/egPGLnw2WvLSQW8pg+SbbUNidkQ8WESVtz678TfCJ5wOs685bWFXD l+oIHedWcYC4bXEQkT1SJxEDZTtrY1bcMq77vbUtKQofRXUkkBtvoS8mJH6P8X4poZE2 jqUNoYUAiUxKOvDEwgj566SYR9lncZPLyZ1TAHCBNYO9dHquobvK3BSkImjDejN2ZRAk eWofDC3+OVKK3/p5wP6+UTubeaHaRzowFEBZD6/17H+b+yTZb9T/IjRiKTT5eDf7uQkP VEGQ== X-Gm-Message-State: AOAM532tWpLiv1Ys/tt4wQDMkHjCTdCfqsPCkXBp22S0LnmEpesIwWZy P7zSoUpd4ti8I188NWV1uWAo0kBuu3dKe3SjJztUVw== X-Google-Smtp-Source: ABdhPJyJCsIWhtCFHfQsD8IbGIEuiKctTELgpEuGwMGzbZFrNsZbuqH6dlJdqjKzzdchJyfaJjBX2VnuwJkzPRh5MJw= X-Received: by 2002:adf:fa0c:: with SMTP id m12mr4560635wrr.406.1598938411019; Mon, 31 Aug 2020 22:33:31 -0700 (PDT) MIME-Version: 1.0 References: <20200831153544.Bluez.v1.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> <CABBYNZ+Q84vmEDgfNuoYXAAMi6T3segO_hSkG5Oufc5F_w9Qeg@mail.gmail.com> <CAJQfnxHyzFAG6zJfsuneLX_rW8yNkd2ZpKotHu3DV6vZABT-qw@mail.gmail.com> <CABBYNZJ4Y-U1nvyBvFwUXf+c0uT-42pBbrNtBG_G4RhLXGYspw@mail.gmail.com> In-Reply-To: <CABBYNZJ4Y-U1nvyBvFwUXf+c0uT-42pBbrNtBG_G4RhLXGYspw@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Tue, 1 Sep 2020 13:33:19 +0800 Message-ID: <CAJQfnxEauZcut7yr85X7gTRzr7qo3BrBzXG+wHe=74c5c3sCig@mail.gmail.com> Subject: Re: [Bluez PATCH v1 1/2] doc/media-api: Add Press method for MediaPlayer1 To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: 0.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: 26B2DA238F X-Rspamd-UID: be8257 Hi Luiz, On Tue, 1 Sep 2020 at 13:20, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Archie, > > On Mon, Aug 31, 2020 at 8:19 PM Archie Pusaka <apusaka@google.com> wrote: > > > > Hi Luiz, > > > > The reason we introduced this method is because we need to send some > > of AVRCP category 2 passthroughs in order to be able to qualify the > > AVRCP absolute volume control as an audio source, despite we don't > > actually plan to send any passthrough in the practice. > > I wonder what those are, are they volume up/down? Yes, volume up/down and mute are the ones that are unique to category 2, but there are also some other buttons which are included in category 2 as well but not unique to it, for example button 0 - 9, help, and power. > > > Therefore, which passthrough we send is actually not important (to > > us), as long as we can do that to satisfy the requirement. > > However, I see that there are over 50 passthroughs across category 1 - > > 4, and thought that it would be cumbersome to have a different method > > for each key if one day we decided to support them all, hence the > > generic method. > > Yep, but there are button presses so things gets a little more > complicated if we need to emulate press/hold/release semantics. For now, I don't think having a separate method for each key will make it easier if we need to emulate hold and release semantics. Could we have 3 methods as follows, all have avc_key as a param: (a) press. This means BlueZ will auto-release it within a short amount of time (b) hold. Bluez wouldn't release it unless it received (c). (c) release. Bluez will release the previously held button. What do you think? > > > May I have some questions? > > (1) Why do you prefer a dedicated method per key? > > (2) Let's say I need to add a dedicated method for a single category 2 > > passthrough key, do you have a key in mind or I can just pick by > > myself? > > > > Thanks, > > Archie > > > > > > On Tue, 1 Sep 2020 at 01:16, Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > > > > > > Hi Archie, > > > > > > On Mon, Aug 31, 2020 at 12:37 AM Archie Pusaka <apusaka@google.com> wrote: > > > > > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > > > > > This allows us to send any passthrough command. > > > > > > > > Reviewed-by: Michael Sun <michaelfsun@google.com> > > > > --- > > > > > > > > doc/media-api.txt | 8 ++++++++ > > > > 1 file changed, 8 insertions(+) > > > > > > > > diff --git a/doc/media-api.txt b/doc/media-api.txt > > > > index dabc69936..fe7222eef 100644 > > > > --- a/doc/media-api.txt > > > > +++ b/doc/media-api.txt > > > > @@ -199,6 +199,14 @@ Methods void Play() > > > > Possible Errors: org.bluez.Error.NotSupported > > > > org.bluez.Error.Failed > > > > > > > > + void Press(byte avc_key) > > > > + > > > > + Press a specific key to send as passthrough command. > > > > + > > > > + Possible Errors: org.bluez.Error.InvalidArguments > > > > + org.bluez.Error.NotSupported > > > > + org.bluez.Error.Failed > > > > + > > > > Properties string Equalizer [readwrite] > > > > > > > > Possible values: "off" or "on" > > > > -- > > > > 2.28.0.402.g5ffc5be6b7-goog > > > > > > For now I would prefer to use dedicated method per key or are there > > > many keys you would like to use from the upper layer? > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Thanks, Archie Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4OY0DlDfTV+K2AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 07:42:40 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id IAEnDVDfTV84JAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 07:42:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E0D2EA226B; Tue, 1 Sep 2020 07:42:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726064AbgIAFm2 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 01:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725930AbgIAFm0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 01:42:26 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60C3DC0612A3 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 22:42:26 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id 109so164885otv.3 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 22:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=toz6DlAhhEzITefjqP2fJc0hANXyinkwDVinSBQ0LU0=; b=sWOLS2OvG7Vd7GfI/cLGuJsGZwHxzTPLNuJdtRuJx0TSy0sHyDQZmTejFip0ioCMgo CHT3rlCZOeK/eLUv5YQUAdVADlFyKiHBkGhXiNopeZL6tI0UySdJtkyV1xuJPoK7WCdj O4VytazIr+jsuSFtAfq41UsfIE162ilzbDyhkOJQCeI1CFfrNfFPIBY6dSg2IIqoG14A onOB4ejVY2P2i7zQpKFBBf9U8FM/66woRquVhRCRbU2iwinn4cKoJZCqgUO84QOwiCRa SoB3E1z2HiOIBVWjrD31DLyxJR0rOLXdaERucHzTg2Zl3NkhTahsqqT7pSU+2Z/GBntJ Z5yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=toz6DlAhhEzITefjqP2fJc0hANXyinkwDVinSBQ0LU0=; b=jESi9ITutEyAlW+SjZw3yU0V+Cln6XszlGOLn3h3WMGkmWHBWmR6npY+bYLpO9mxQP LAF0YRRbMxL02/oEuJ8KlqN+i+YqCQoUlTt/k3JX3Z+NP9ZEk+dLQbv0rJpNuRRIiRjP Oq1/xRo2PUVdSAl1xBxirdoAEmi3ELH2VBlCFkYgedGyw5JbltVDMiu3RIWnnom72j8g ICXp1ddYjixKYzi6GMkMlt3ZGJ814DdA0SahpruGgWUIoCyQuN1K6o/C8KO0lejuajSH 4XQdW2CKTfjAJYSTzav8F3rbnpMHQpp4dS9jlzQR2ZFHtLsjZFZBIYa5PhsBkmYwyfGV k2YQ== X-Gm-Message-State: AOAM532iIbK27NJ2XWZwagbwmcUVu3pglMYWpSooZNByf6LUAKz0EmlZ PTBDMBJ+kjKIodfhV5I/u2EGqU+gPEz53cfhq0NmHOHh X-Google-Smtp-Source: ABdhPJy63B/T2QI+EakCQqxZiWhnS4dX1/B6Gjxe/fE8bv/8BQ8nI3Jvxfw1klc6XjELYVgQtK4sWj104KktGbCR8NU= X-Received: by 2002:a9d:429:: with SMTP id 38mr235452otc.88.1598938945514; Mon, 31 Aug 2020 22:42:25 -0700 (PDT) MIME-Version: 1.0 References: <20200831153544.Bluez.v1.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> <CABBYNZ+Q84vmEDgfNuoYXAAMi6T3segO_hSkG5Oufc5F_w9Qeg@mail.gmail.com> <CAJQfnxHyzFAG6zJfsuneLX_rW8yNkd2ZpKotHu3DV6vZABT-qw@mail.gmail.com> <CABBYNZJ4Y-U1nvyBvFwUXf+c0uT-42pBbrNtBG_G4RhLXGYspw@mail.gmail.com> <CAJQfnxEauZcut7yr85X7gTRzr7qo3BrBzXG+wHe=74c5c3sCig@mail.gmail.com> In-Reply-To: <CAJQfnxEauZcut7yr85X7gTRzr7qo3BrBzXG+wHe=74c5c3sCig@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 31 Aug 2020 22:42:15 -0700 Message-ID: <CABBYNZL=NfVk3zo9C8g-Urbztx2LKWG28=4qWNbBW+KhJJh=Jw@mail.gmail.com> Subject: Re: [Bluez PATCH v1 1/2] doc/media-api: Add Press method for MediaPlayer1 To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: 0.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: E0D2EA226B X-Rspamd-UID: fdc039 Hi Archie, On Mon, Aug 31, 2020 at 10:33 PM Archie Pusaka <apusaka@google.com> wrote: > > Hi Luiz, > > On Tue, 1 Sep 2020 at 13:20, Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Archie, > > > > On Mon, Aug 31, 2020 at 8:19 PM Archie Pusaka <apusaka@google.com> wrote: > > > > > > Hi Luiz, > > > > > > The reason we introduced this method is because we need to send some > > > of AVRCP category 2 passthroughs in order to be able to qualify the > > > AVRCP absolute volume control as an audio source, despite we don't > > > actually plan to send any passthrough in the practice. > > > > I wonder what those are, are they volume up/down? > Yes, volume up/down and mute are the ones that are unique to category > 2, but there are also some other buttons which are included in > category 2 as well but not unique to it, for example button 0 - 9, > help, and power. Weird, there are dedicated commands for setting absolut volume, not sure why one would use volume up/down to qualify? Or is that testing any button that belongs to category 2? Anyway it would be nice to know what test that is and what is the expected behavior the test case expects from us. > > > > > > Therefore, which passthrough we send is actually not important (to > > > us), as long as we can do that to satisfy the requirement. > > > However, I see that there are over 50 passthroughs across category 1 - > > > 4, and thought that it would be cumbersome to have a different method > > > for each key if one day we decided to support them all, hence the > > > generic method. > > > > Yep, but there are button presses so things gets a little more > > complicated if we need to emulate press/hold/release semantics. > For now, I don't think having a separate method for each key will make > it easier if we need to emulate hold and release semantics. > > Could we have 3 methods as follows, all have avc_key as a param: > (a) press. This means BlueZ will auto-release it within a short amount of time > (b) hold. Bluez wouldn't release it unless it received (c). > (c) release. Bluez will release the previously held button. > What do you think? I'm fine with that, we might have to start the status of each request though, also the holding should not last longer than 2 seconds if I recall correctly. > > > > > May I have some questions? > > > (1) Why do you prefer a dedicated method per key? > > > (2) Let's say I need to add a dedicated method for a single category 2 > > > passthrough key, do you have a key in mind or I can just pick by > > > myself? > > > > > > Thanks, > > > Archie > > > > > > > > > On Tue, 1 Sep 2020 at 01:16, Luiz Augusto von Dentz > > > <luiz.dentz@gmail.com> wrote: > > > > > > > > Hi Archie, > > > > > > > > On Mon, Aug 31, 2020 at 12:37 AM Archie Pusaka <apusaka@google.com> wrote: > > > > > > > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > > > > > > > This allows us to send any passthrough command. > > > > > > > > > > Reviewed-by: Michael Sun <michaelfsun@google.com> > > > > > --- > > > > > > > > > > doc/media-api.txt | 8 ++++++++ > > > > > 1 file changed, 8 insertions(+) > > > > > > > > > > diff --git a/doc/media-api.txt b/doc/media-api.txt > > > > > index dabc69936..fe7222eef 100644 > > > > > --- a/doc/media-api.txt > > > > > +++ b/doc/media-api.txt > > > > > @@ -199,6 +199,14 @@ Methods void Play() > > > > > Possible Errors: org.bluez.Error.NotSupported > > > > > org.bluez.Error.Failed > > > > > > > > > > + void Press(byte avc_key) > > > > > + > > > > > + Press a specific key to send as passthrough command. > > > > > + > > > > > + Possible Errors: org.bluez.Error.InvalidArguments > > > > > + org.bluez.Error.NotSupported > > > > > + org.bluez.Error.Failed > > > > > + > > > > > Properties string Equalizer [readwrite] > > > > > > > > > > Possible values: "off" or "on" > > > > > -- > > > > > 2.28.0.402.g5ffc5be6b7-goog > > > > > > > > For now I would prefer to use dedicated method per key or are there > > > > many keys you would like to use from the upper layer? > > > > > > > > > > > > -- > > > > Luiz Augusto von Dentz > > > > > > > > -- > > Luiz Augusto von Dentz > > Thanks, > Archie -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oC0GE5PqTV8ixAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 08:30:43 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WMGoEJPqTV8FVQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 08:30:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C5F78A0979; Tue, 1 Sep 2020 08:30:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726105AbgIAGab (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 02:30:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbgIAGaa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 02:30:30 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B69BC0612AC for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 23:30:30 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id w13so147155wrk.5 for <linux-bluetooth@vger.kernel.org>; Mon, 31 Aug 2020 23:30:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8KJa7N0SPprWWdeB0qM0vnAJ/YjYjm3MX1q2sMQWlFc=; b=cRbuGe3iuJsEK97eRI7QEMrlRxkqxyrjq6Gt0GjU51yzd1QhXZAUMLB2cAHBydM33E PAk4uUNirHUW29fy+HmrVpMX5zPeHep0vT6LrJufTgWYNi8qH1Aj68B/+MWyU+ai0GMh kp46R2GrRiiKh7im++sW6rMWWObQVo5jd2hPK6+AcXB8sdaZQEFPQxXlnCvODd3dXoff PMbj0HAxW6zOJrpqxF93KqevZDhlmpUjP57Ypbi0Mp4hlDzHzaxhGyYy4pmg0ImX7C+w pBs7vHSkY9Hf3ToTRfjKhsUucXhgm3Ml6GP20jFS0aO2hDbFWPm1Z/330VGVvxOqszx9 LLDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8KJa7N0SPprWWdeB0qM0vnAJ/YjYjm3MX1q2sMQWlFc=; b=lvIYbIi29KDIH3ERm6PnGBzhpWdfIH7hlhYEj/IFd09vvpMfzWCXj2WKF1zxRqVScQ PQDlJQaSQjHSy1ElshsOyItu3r2cNINmQp441+NmTf7Atec/5oQhYvNik1MYYN/1hfss 4mwC0E3zhg7AuliogI7HMm5bUwpDcS7VQUyfVagIfL9WqmkHRtHf3k9YcYORAUHnVzAE a3+ElbK9wW+d+We4FSTmYbttb7xBliaeDpHifseu6WIpaAaiLDcTn22Tf2fwX2WzzZbX 8tmB2aeP3ao3BpHkNmE5q4ls/iSHQ1nKveE1CFBAsWGKcM0lKQdGeb9oFEBnIe2XPX3N d7mg== X-Gm-Message-State: AOAM533J7jADM/hhw71lr/s9bCIBEChM/7KrO6KwXIBYOKymNEbdb30n SBDD3Rz8Mmkxv5/mbdrgcpSoCXLAoTqC8kuzkcyqFcmjwkk= X-Google-Smtp-Source: ABdhPJyQZvwz4WuMjEEeVEjjHsFGtNCqCty5CPPFQnUer2Q2ogSbxvk5fYo0PxPwVcDzO2RKT2fdbgzHO2WoSE78xDQ= X-Received: by 2002:adf:dcc3:: with SMTP id x3mr134986wrm.120.1598941828405; Mon, 31 Aug 2020 23:30:28 -0700 (PDT) MIME-Version: 1.0 References: <20200831153544.Bluez.v1.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> <CABBYNZ+Q84vmEDgfNuoYXAAMi6T3segO_hSkG5Oufc5F_w9Qeg@mail.gmail.com> <CAJQfnxHyzFAG6zJfsuneLX_rW8yNkd2ZpKotHu3DV6vZABT-qw@mail.gmail.com> <CABBYNZJ4Y-U1nvyBvFwUXf+c0uT-42pBbrNtBG_G4RhLXGYspw@mail.gmail.com> <CAJQfnxEauZcut7yr85X7gTRzr7qo3BrBzXG+wHe=74c5c3sCig@mail.gmail.com> <CABBYNZL=NfVk3zo9C8g-Urbztx2LKWG28=4qWNbBW+KhJJh=Jw@mail.gmail.com> In-Reply-To: <CABBYNZL=NfVk3zo9C8g-Urbztx2LKWG28=4qWNbBW+KhJJh=Jw@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Tue, 1 Sep 2020 14:30:17 +0800 Message-ID: <CAJQfnxGGmRSWZgvx8VLrTO9KV5hysLjgXMK1ONKCTQKYrQ1uLA@mail.gmail.com> Subject: Re: [Bluez PATCH v1 1/2] doc/media-api: Add Press method for MediaPlayer1 To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: 0.00 / 15.00 / 200.00 X-Rspamd-Queue-Id: C5F78A0979 X-Rspamd-UID: 8c5277 On Tue, 1 Sep 2020 at 13:42, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Archie, > > On Mon, Aug 31, 2020 at 10:33 PM Archie Pusaka <apusaka@google.com> wrote: > > > > Hi Luiz, > > > > On Tue, 1 Sep 2020 at 13:20, Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > > > > > > Hi Archie, > > > > > > On Mon, Aug 31, 2020 at 8:19 PM Archie Pusaka <apusaka@google.com> wrote: > > > > > > > > Hi Luiz, > > > > > > > > The reason we introduced this method is because we need to send some > > > > of AVRCP category 2 passthroughs in order to be able to qualify the > > > > AVRCP absolute volume control as an audio source, despite we don't > > > > actually plan to send any passthrough in the practice. > > > > > > I wonder what those are, are they volume up/down? > > Yes, volume up/down and mute are the ones that are unique to category > > 2, but there are also some other buttons which are included in > > category 2 as well but not unique to it, for example button 0 - 9, > > help, and power. > > Weird, there are dedicated commands for setting absolut volume, not > sure why one would use volume up/down to qualify? Or is that testing > any button that belongs to category 2? Anyway it would be nice to know > what test that is and what is the expected behavior the test case > expects from us. Weird, yes. Sending absolute volume command capability is declared in the AVRCP ICS 2/50, but it can only be selected if 2/8 is also selected, which is sending passthrough command for category 2. Therefore, we also need to be able to send a category 2 passthrough. The test itself is AVRCP/CT/PTT/BV-02-I. This is the test to see whether we can send a category 2 passthrough, not the one to see whether we can send the absolute volume command. The test asks us to send every category 2 passthrough we declared in the ICS file (table 4). There should be at least one passthrough declared. > > > > > > > > > > Therefore, which passthrough we send is actually not important (to > > > > us), as long as we can do that to satisfy the requirement. > > > > However, I see that there are over 50 passthroughs across category 1 - > > > > 4, and thought that it would be cumbersome to have a different method > > > > for each key if one day we decided to support them all, hence the > > > > generic method. > > > > > > Yep, but there are button presses so things gets a little more > > > complicated if we need to emulate press/hold/release semantics. > > For now, I don't think having a separate method for each key will make > > it easier if we need to emulate hold and release semantics. > > > > Could we have 3 methods as follows, all have avc_key as a param: > > (a) press. This means BlueZ will auto-release it within a short amount of time > > (b) hold. Bluez wouldn't release it unless it received (c). > > (c) release. Bluez will release the previously held button. > > What do you think? > > I'm fine with that, we might have to start the status of each request > though, also the holding should not last longer than 2 seconds if I > recall correctly. Then I shall try to have this implemented. Btw I only took a quick glance, but I did not find the 2 seconds limitation in the spec. > > > > > > > > May I have some questions? > > > > (1) Why do you prefer a dedicated method per key? > > > > (2) Let's say I need to add a dedicated method for a single category 2 > > > > passthrough key, do you have a key in mind or I can just pick by > > > > myself? > > > > > > > > Thanks, > > > > Archie > > > > > > > > > > > > On Tue, 1 Sep 2020 at 01:16, Luiz Augusto von Dentz > > > > <luiz.dentz@gmail.com> wrote: > > > > > > > > > > Hi Archie, > > > > > > > > > > On Mon, Aug 31, 2020 at 12:37 AM Archie Pusaka <apusaka@google.com> wrote: > > > > > > > > > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > > > > > > > > > This allows us to send any passthrough command. > > > > > > > > > > > > Reviewed-by: Michael Sun <michaelfsun@google.com> > > > > > > --- > > > > > > > > > > > > doc/media-api.txt | 8 ++++++++ > > > > > > 1 file changed, 8 insertions(+) > > > > > > > > > > > > diff --git a/doc/media-api.txt b/doc/media-api.txt > > > > > > index dabc69936..fe7222eef 100644 > > > > > > --- a/doc/media-api.txt > > > > > > +++ b/doc/media-api.txt > > > > > > @@ -199,6 +199,14 @@ Methods void Play() > > > > > > Possible Errors: org.bluez.Error.NotSupported > > > > > > org.bluez.Error.Failed > > > > > > > > > > > > + void Press(byte avc_key) > > > > > > + > > > > > > + Press a specific key to send as passthrough command. > > > > > > + > > > > > > + Possible Errors: org.bluez.Error.InvalidArguments > > > > > > + org.bluez.Error.NotSupported > > > > > > + org.bluez.Error.Failed > > > > > > + > > > > > > Properties string Equalizer [readwrite] > > > > > > > > > > > > Possible values: "off" or "on" > > > > > > -- > > > > > > 2.28.0.402.g5ffc5be6b7-goog > > > > > > > > > > For now I would prefer to use dedicated method per key or are there > > > > > many keys you would like to use from the upper layer? > > > > > > > > > > > > > > > -- > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > Thanks, > > Archie > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8PL/IekvTl/m5gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 13:26:33 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 0HX+H+kvTl+dDQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 13:26:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F0C1CA1BD0; Tue, 1 Sep 2020 13:26:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726929AbgIALZ2 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 07:25:28 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:35854 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbgIALZY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 07:25:24 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id AEE5ECECDF; Tue, 1 Sep 2020 13:31:27 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v2] Bluetooth: Clear suspend tasks on unregister From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200831095119.v2.1.I24fb6cc377d03d64d74f83cec748afd12ee33e37@changeid> Date: Tue, 1 Sep 2020 13:24:34 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, chromeos-bluetooth-upstreaming@chromium.org, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>, Miao-chen Chou <mcchou@chromium.org> Content-Transfer-Encoding: 7bit Message-Id: <86419845-3365-4925-8CD4-9D3F35BE5ED7@holtmann.org> References: <20200831095119.v2.1.I24fb6cc377d03d64d74f83cec748afd12ee33e37@changeid> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: F0C1CA1BD0 X-Rspamd-UID: f9f8ec Hi Abhishek, > While unregistering, make sure to clear the suspend tasks before > cancelling the work. If the unregister is called during resume from > suspend, this will unnecessarily add 2s to the resume time otherwise. > > Fixes: 4e8c36c3b0d73d (Bluetooth: Fix suspend notifier race) > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > This was discovered with RT8822CE using the btusb driver. This chipset > will reset on resume during system suspend and was unnecessarily adding > 2s to every resume. Since we're unregistering anyway, there's no harm in > just clearing the pending events. > > Changes in v2: > - ++i to i++ > > net/bluetooth/hci_core.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uFhfMOxWTl/X9QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 16:13:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2OlFL+xWTl8sJwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 16:13:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=dptechnics.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5EF26A12D7; Tue, 1 Sep 2020 16:12:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727992AbgIANCh (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 09:02:37 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17101 "EHLO sender4-op-o11.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727964AbgIALzA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 07:55:00 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1598961275; cv=none; d=zohomail.com; s=zohoarc; b=NHOprI/StTQi0D0aNa96kDcalZLnX2cKYp74nndDLQRG74Y5S1MM42VPRRg2XHiJPJgIqWY12w/B9ciLMIqB1iOadomEAugOEjNnLvvhVCl3Qlxeu/fikbRSF5mVVPIdvj0I46AF2t8pJqNgtSwEL3yM1yRW/efxZnRScXlkzLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598961275; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=lRDbOVyWTCk7HLMsMU0bFp+2XW5GTAjfDlZ82+nrDas=; b=Oa5fjTkgq/kwoda5VenSRo1Pd+6q6asw1SFDxJS4DwiTbvDcYeii12sgrnqFwRuZQhv/KMeX+z+0P1i/pp/YkOo78bBkLAwMPsN6jy6tpbROQJKIkMieuzWDxjwtGv9hki7KzDlgMjm6oZ5EbQstBoMxyaeizW9u1Zxw7wyn6Lo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=dptechnics.com; spf=pass smtp.mailfrom=daan@dptechnics.com; dmarc=pass header.from=<daan@dptechnics.com> header.from=<daan@dptechnics.com> DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1598961275; s=zoho; d=dptechnics.com; i=daan@dptechnics.com; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=lRDbOVyWTCk7HLMsMU0bFp+2XW5GTAjfDlZ82+nrDas=; b=dMZh9U0JsGGFVquVdkoMw+CFpn6bDrHXIrDy+l3iQjFTswYqxdZHpZi/HTUSCwl/ i4rwHzUpWDCw7KzZgvyCJWcd2M+DAj06EBQY0JRum5MGt/YBZzCnlTA6FQkFBHLp1bz +KQxhqNHXm0XigJ5fQSRTgMnXJootErWM06actDQ= Received: from daan-devbox.dptechnics.local (178-116-74-88.access.telenet.be [178.116.74.88]) by mx.zohomail.com with SMTPS id 1598961273662400.6309226412743; Tue, 1 Sep 2020 04:54:33 -0700 (PDT) From: Daan Pape <daan@dptechnics.com> To: linux-bluetooth@vger.kernel.org Cc: Daan Pape <daan@dptechnics.com> Message-ID: <20200901115418.82056-2-daan@dptechnics.com> Subject: [PATCH BlueZ 1/1] Mesh: make SIG model header file locations more consistent Date: Tue, 1 Sep 2020 13:54:18 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200901115418.82056-1-daan@dptechnics.com> References: <20200901115418.82056-1-daan@dptechnics.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.67 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5EF26A12D7 X-Rspamd-UID: abd62c --- tools/mesh-gatt/onoff-model.c | 2 +- tools/mesh-gatt/onoff-model.h | 33 --------------------------------- tools/meshctl.c | 2 +- 3 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 tools/mesh-gatt/onoff-model.h diff --git a/tools/mesh-gatt/onoff-model.c b/tools/mesh-gatt/onoff-model.c index be519c969..140dddb79 100644 --- a/tools/mesh-gatt/onoff-model.c +++ b/tools/mesh-gatt/onoff-model.c @@ -47,7 +47,7 @@ #include "tools/mesh-gatt/node.h" #include "tools/mesh-gatt/prov-db.h" #include "tools/mesh-gatt/util.h" -#include "tools/mesh-gatt/onoff-model.h" +#include "tools/mesh/generic-onoff-model.h" =20 static uint8_t trans_id; static uint16_t onoff_app_idx =3D APP_IDX_INVALID; diff --git a/tools/mesh-gatt/onoff-model.h b/tools/mesh-gatt/onoff-model.h deleted file mode 100644 index 31599056d..000000000 --- a/tools/mesh-gatt/onoff-model.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2017 Intel Corporation. All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 = USA - * - */ - -#define GENERIC_ONOFF_SERVER_MODEL_ID=090x1000 -#define GENERIC_ONOFF_CLIENT_MODEL_ID=090x1001 - -#define OP_GENERIC_ONOFF_GET=09=09=090x8201 -#define OP_GENERIC_ONOFF_SET=09=09=090x8202 -#define OP_GENERIC_ONOFF_SET_UNACK=09=090x8203 -#define OP_GENERIC_ONOFF_STATUS=09=09=090x8204 - -void onoff_set_node(const char *args); -bool onoff_client_init(uint8_t ele); diff --git a/tools/meshctl.c b/tools/meshctl.c index 57998fded..e8eafff01 100644 --- a/tools/meshctl.c +++ b/tools/meshctl.c @@ -50,6 +50,7 @@ =20 #include "mesh/agent.h" #include "mesh/config-model.h" +#include "mesh/generic-onoff-model.h" =20 #include "mesh-gatt/mesh-net.h" #include "mesh-gatt/gatt.h" @@ -60,7 +61,6 @@ #include "mesh-gatt/prov.h" #include "mesh-gatt/util.h" #include "mesh-gatt/prov-db.h" -#include "mesh-gatt/onoff-model.h" =20 /* String display constants */ #define COLORED_NEW=09COLOR_GREEN "NEW" COLOR_OFF --=20 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QEgpOlpXTl8ahAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 16:14:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id gASEOFpXTl9TSQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 16:14:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=dptechnics.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EE5F4A2609; Tue, 1 Sep 2020 16:14:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727964AbgIAONE (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 10:13:04 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17180 "EHLO sender4-op-o11.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727918AbgIALyn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 07:54:43 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1598961272; cv=none; d=zohomail.com; s=zohoarc; b=RfGUUsV0XdxEEMFtB9w2PjQgYRCY2Zifxyv+TF4Mkc237LI0/jbnNSlhLJsZfDc4EuVT8P7KTBEXWMvM91C7LiQjM9CvLfH7FxLOT2LJmJ7bUD3nd3pDNStssrmiszLLwRdbZ1dtuTWa7n3+hyPsQaNrNC3ESCCElvEnZQZQci8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598961272; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=8GE8GX8wfUYkwmZsVMBYy3QaTa9zX1/ZjiY09VRuPTw=; b=L3mxkcMC+XmtqaPigb9z52KqKG8WRsN4+fIyTqXAnOiO62HnHJXRgVikAOqC4d+4SukUHKEkpYXiXKxGsbOMl2BxHJiKB7CLZzWQlqrLaLoarxxB+TIwW2y594Dh+iNFpPZipH8NzuIFbxZpDfjiwieA3u73HCT2EPxuZJLri/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=dptechnics.com; spf=pass smtp.mailfrom=daan@dptechnics.com; dmarc=pass header.from=<daan@dptechnics.com> header.from=<daan@dptechnics.com> DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1598961272; s=zoho; d=dptechnics.com; i=daan@dptechnics.com; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=8GE8GX8wfUYkwmZsVMBYy3QaTa9zX1/ZjiY09VRuPTw=; b=RKdqKQqFCcPkvxnmNNgExoyQ+ZWvJhoOEUCe4ijEW7BYG8HaZTsGJCCxwiaVB6X0 EKycf1LK8U7OhOoQ9DjBubLlfGEiaRJ/Omd5jiXBlqmn8ItR6tMEylwA8HvhDH/z4/k SKyRg1sG/Nz3h2cEpAEAx+WwJmw8nvAzeXGWdics= Received: from daan-devbox.dptechnics.local (178-116-74-88.access.telenet.be [178.116.74.88]) by mx.zohomail.com with SMTPS id 1598961269677786.0220243936628; Tue, 1 Sep 2020 04:54:29 -0700 (PDT) From: Daan Pape <daan@dptechnics.com> To: linux-bluetooth@vger.kernel.org Cc: Daan Pape <daan@dptechnics.com> Message-ID: <20200901115418.82056-1-daan@dptechnics.com> Subject: [PATCH BlueZ 0/1] Mesh: make SIG model header file locations more consistent Date: Tue, 1 Sep 2020 13:54:17 +0200 X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: EE5F4A2609 X-Rspamd-UID: ee07ad The configuration model header was now in the tools/mesh directory while th= e Generic OnOff header was in the tools/mesh-gatt directory. In preparation o= f=20 implementing the Generic OnOff client model in the mesh-cfgclient tool and= =20 to make the structure more consistent I renamed and moved the header file o= f the Generic OnOff model to the tools/mesh directory. Daan Pape (1): Mesh: make SIG model header file locations more consistent tools/mesh-gatt/onoff-model.c | 2 +- tools/mesh-gatt/onoff-model.h | 33 --------------------------------- tools/meshctl.c | 2 +- 3 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 tools/mesh-gatt/onoff-model.h --=20 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GBeHCAJaTl/tfAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 16:26:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id cCJsBgJaTl9hSAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 16:26:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 01F124211D; Tue, 1 Sep 2020 16:26:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728301AbgIAOZ4 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 10:25:56 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:49591 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728060AbgIAOZJ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 10:25:09 -0400 Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 01 Sep 2020 07:24:59 -0700 Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 01 Sep 2020 07:24:57 -0700 Received: from gubbaven-linux.qualcomm.com ([10.206.64.32]) by ironmsg02-blr.qualcomm.com with ESMTP; 01 Sep 2020 19:54:32 +0530 Received: by gubbaven-linux.qualcomm.com (Postfix, from userid 2365015) id E3F8E217CB; Tue, 1 Sep 2020 19:54:30 +0530 (IST) From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org, Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Subject: [PATCH v1 1/2] Bluetooth: hci_serdev: Close UART port if NON_PERSISTENT_SETUP is set Date: Tue, 1 Sep 2020 19:54:26 +0530 Message-Id: <1598970267-7170-2-git-send-email-gubbaven@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598970267-7170-1-git-send-email-gubbaven@codeaurora.org> References: <1598970267-7170-1-git-send-email-gubbaven@codeaurora.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.81 / 15.00 / 200.00 X-Rspamd-Queue-Id: 01F124211D X-Rspamd-UID: 46ad5a When HCI_QUIRK_NON_PERSISTENT_SETUP is set by drivers, it indicates that BT SoC will be completely powered OFF during BT OFF. On next BT ON firmware must be downloaded again. Holding UART port open during BT OFF is draining the battery. Now during BT OFF, UART port is closed if qurik HCI_QUIRK_NON_PERSISTENT_SETUP is set by clearing HCI_UART_PROTO_READY proto flag. On next BT ON, UART port is opened if HCI_UART_PROTO_READY proto flag is cleared. Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> --- drivers/bluetooth/hci_serdev.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index 3977bba..ef96ad0 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -113,8 +113,22 @@ static int hci_uart_flush(struct hci_dev *hdev) /* Initialize device */ static int hci_uart_open(struct hci_dev *hdev) { + struct hci_uart *hu = hci_get_drvdata(hdev); + int err; + BT_DBG("%s %p", hdev->name, hdev); + /* When Quirk HCI_QUIRK_NON_PERSISTENT_SETUP is set by + * driver, BT SoC is completely turned OFF during + * BT OFF. Upon next BT ON UART port should be opened. + */ + if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) { + err = serdev_device_open(hu->serdev); + if (err) + return err; + set_bit(HCI_UART_PROTO_READY, &hu->flags); + } + /* Undo clearing this from hci_uart_close() */ hdev->flush = hci_uart_flush; @@ -124,11 +138,25 @@ static int hci_uart_open(struct hci_dev *hdev) /* Close device */ static int hci_uart_close(struct hci_dev *hdev) { + struct hci_uart *hu = hci_get_drvdata(hdev); + BT_DBG("hdev %p", hdev); + if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) + return 0; + hci_uart_flush(hdev); hdev->flush = NULL; + /* When QUIRK HCI_QUIRK_NON_PERSISTENT_SETUP is set by driver, + * BT SOC is completely powered OFF during BT OFF, holding port + * open may drain the battery. + */ + if (test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) { + clear_bit(HCI_UART_PROTO_READY, &hu->flags); + serdev_device_close(hu->serdev); + } + return 0; } @@ -354,8 +382,6 @@ void hci_uart_unregister_device(struct hci_uart *hu) { struct hci_dev *hdev = hu->hdev; - clear_bit(HCI_UART_PROTO_READY, &hu->flags); - cancel_work_sync(&hu->init_ready); if (test_bit(HCI_UART_REGISTERED, &hu->flags)) hci_unregister_dev(hdev); @@ -364,6 +390,10 @@ void hci_uart_unregister_device(struct hci_uart *hu) cancel_work_sync(&hu->write_work); hu->proto->close(hu); - serdev_device_close(hu->serdev); + + if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) { + clear_bit(HCI_UART_PROTO_READY, &hu->flags); + serdev_device_close(hu->serdev); + } } EXPORT_SYMBOL_GPL(hci_uart_unregister_device); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wDOJFDBaTl8+pgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 16:26:56 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id SANHEzBaTl8sJwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 16:26:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 61FA941175; Tue, 1 Sep 2020 16:26:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728060AbgIAO0q (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 10:26:46 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:53509 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728381AbgIAOZJ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 10:25:09 -0400 Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 01 Sep 2020 07:24:57 -0700 Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 01 Sep 2020 07:24:55 -0700 Received: from gubbaven-linux.qualcomm.com ([10.206.64.32]) by ironmsg02-blr.qualcomm.com with ESMTP; 01 Sep 2020 19:54:32 +0530 Received: by gubbaven-linux.qualcomm.com (Postfix, from userid 2365015) id A078321B32; Tue, 1 Sep 2020 19:54:30 +0530 (IST) From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org, Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Subject: [PATCH v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set Date: Tue, 1 Sep 2020 19:54:25 +0530 Message-Id: <1598970267-7170-1-git-send-email-gubbaven@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.79 / 15.00 / 200.00 X-Rspamd-Queue-Id: 61FA941175 X-Rspamd-UID: 298dbe When HCI_QUIRK_NON_PERSISTENT_SETUP is set by drivers, it indicates that BT SoC will be completely powered OFF during BT OFF. On next BT ON firmware must be downloaded again. Holding UART port open during BT OFF is draining the battery. Now during BT OFF, UART port is closed if qurik HCI_QUIRK_NON_PERSISTENT_SETUP is set by clearing HCI_UART_PROTO_READY proto flag. On next BT ON, UART port is opened if HCI_UART_PROTO_READY proto flag is cleared. Venkata Lakshmi Narayana Gubba (2): Bluetooth: hci_serdev: Close UART port if NON_PERSISTENT_SETUP is set Bluetooth: hci_qca: Remove duplicate power off in proto close drivers/bluetooth/hci_qca.c | 5 ++--- drivers/bluetooth/hci_serdev.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +PvGMCBbTl8+pgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 16:30:56 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YDHqLiBbTl/1LgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 16:30:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3E4B6420C8; Tue, 1 Sep 2020 16:30:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728424AbgIAOat (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 10:30:49 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:57345 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728387AbgIAOZJ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 10:25:09 -0400 Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 01 Sep 2020 07:25:01 -0700 Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 01 Sep 2020 07:24:59 -0700 Received: from gubbaven-linux.qualcomm.com ([10.206.64.32]) by ironmsg02-blr.qualcomm.com with ESMTP; 01 Sep 2020 19:54:32 +0530 Received: by gubbaven-linux.qualcomm.com (Postfix, from userid 2365015) id 1364421B34; Tue, 1 Sep 2020 19:54:30 +0530 (IST) From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org, Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Subject: [PATCH v1 2/2] Bluetooth: hci_qca: Remove duplicate power off in proto close Date: Tue, 1 Sep 2020 19:54:27 +0530 Message-Id: <1598970267-7170-3-git-send-email-gubbaven@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598970267-7170-1-git-send-email-gubbaven@codeaurora.org> References: <1598970267-7170-1-git-send-email-gubbaven@codeaurora.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3E4B6420C8 X-Rspamd-UID: 949dbf During serdev unregister, hdev->shutdown is called before proto close. Removing duplicates power OFF call. Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> --- drivers/bluetooth/hci_qca.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 20e1ded..f0d9ee3 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -693,8 +693,6 @@ static int qca_close(struct hci_uart *hu) destroy_workqueue(qca->workqueue); qca->hu = NULL; - qca_power_shutdown(hu); - kfree_skb(qca->rx_skb); hu->priv = NULL; @@ -2032,8 +2030,9 @@ static int qca_serdev_probe(struct serdev_device *serdev) static void qca_serdev_remove(struct serdev_device *serdev) { struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev); + struct qca_power *power = qcadev->bt_power; - if (qca_is_wcn399x(qcadev->btsoc_type)) + if (qca_is_wcn399x(qcadev->btsoc_type) && power->vregs_on) qca_power_shutdown(&qcadev->serdev_hu); else if (qcadev->susclk) clk_disable_unprepare(qcadev->susclk); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +F5sMlJbTl/X9QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 16:31:46 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id +EfkMFJbTl+18wAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 16:31:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1B24E4215E; Tue, 1 Sep 2020 16:31:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728386AbgIAObR (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 10:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728412AbgIAOap (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 10:30:45 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EB79C061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 07:30:43 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id n133so908613qkn.11 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 07:30:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=zhSxzJ6LF79ywCvIZM4CCFow54C4LxbwybdeH+ffbuY=; b=Afr+ZR7Xr3I0ENjZ9INeMJtofyk7AivtXlmK+1Xg5P7MlpUAz6pgt8LzoJlns44t3o OUmoFxUh/F61+1nRn4qVZYDqXypzkJWse5h6Ql9rNh8GtJKRRFrI0Y7CxFrL6syNyHys BfCvySTtBIpAxsBWf2Y382wyb5bLFLta7q3r7TOjrUrYVcZaG7PCUJBi/78keUgL4iQY x7o9YyrUrraS1B/4x75aXOO8yPDJd7YicXDyI9UHdV1fJ46KllqiI2ShsF+oROWqSnVN eYWYt+4LEqMJtiDUDQTdwytpDQRTTD66nrpmenVjtwyoH46oJWzKNW+xq5RAaaFTlbTl WvUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=zhSxzJ6LF79ywCvIZM4CCFow54C4LxbwybdeH+ffbuY=; b=BVcYqoeQBrtCWQgL0QeXXLqb0+9VTAJ44w5Nllgiz05KKjPyTSKFwvOdF3sG/6vCfs cD0752L55ds9aulav4OnJnUTEW7XKq5If6P62JFENbQdqHJrM3jJmqlc1MDeqrTr9hM1 /qNbyp9LBwe0MaoMKenCHBHR9ZaZ9oNuOOGQQkjpvJfUde73z8jm6KrZTsdENCeKgmzX 9QjiljC3ELBfoBrU+BFyNSrzZWHggsMO7OxHkvCQF8JQj6gJIRxg+0FnVegd/g+GbawS uUbE3YQSXel+fduGOMJvVpBkK93sAWksG0NbuWU/BKqeRVpJBB/TfB/oYH2k4N2BCV09 YQAQ== X-Gm-Message-State: AOAM533AjBKFYCSpnls7ihwwXtGjlXm9Ql3Go9yHxuf5d/zVrQ1jCooz YgOQuaf8eeuqAFmZbwn7DiC8B9ohH1hfKA== X-Google-Smtp-Source: ABdhPJxwQ0A3hNC1qrjRDcR2hb6YTu6fo7tqyKCYatzmLgAwbmeB7K66C9cacvp1Vpmn3G4GaqGPYQ== X-Received: by 2002:a37:c09:: with SMTP id 9mr2182239qkm.471.1598970640811; Tue, 01 Sep 2020 07:30:40 -0700 (PDT) Received: from [172.17.0.2] ([52.232.245.24]) by smtp.gmail.com with ESMTPSA id d49sm470816qtc.55.2020.09.01.07.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 07:30:40 -0700 (PDT) Message-ID: <5f4e5b10.1c69fb81.e7d6.2030@mx.google.com> Date: Tue, 01 Sep 2020 07:30:40 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============4368723395144955242==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, daan@dptechnics.com Subject: RE: [BlueZ,1/1] Mesh: make SIG model header file locations more consistent Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200901115418.82056-2-daan@dptechnics.com> References: <20200901115418.82056-2-daan@dptechnics.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.21 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1B24E4215E X-Rspamd-UID: f47c46 --===============4368723395144955242== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 3: B6 Body message is missing --- Regards, Linux Bluetooth --===============4368723395144955242==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +KmIDG5bTl/X9QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 16:32:14 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id IJ9yCm5bTl+S4QEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 16:32:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1D9AA420EE; Tue, 1 Sep 2020 16:32:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728264AbgIAObm (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 10:31:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728444AbgIAObc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 10:31:32 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 028A1C061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 07:31:29 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id w186so1120556qkd.1 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 07:31:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=AQEebDuiApyMST9ZTulg4RdpITa592ypiLLzUObzPTg=; b=VfRFkaeyT5sJXBeIDV9kpajIq1yOHiBS0Ib5x4ncZtZAXizVJ8fmJYDqQkxyy28kVN sNgnEV4OlCtS5oR+dHiIJ4uZ7tpQ7c/mxvEsjjs1ADpUNINqTb1tKCx8aPyn05qok2M+ aCRmQrqnEmpXZ4Xfa/f5EvA31d3kkb/9TfZIOGhq0FNccbE7Ac+MwH9U+3adbAYLCEHz 3Loi6Mb2bJzWMGP44LjbKvRuSKzmeobI2Aua8cYboVrkVQXT2bQ9VYdWlc0njqmx2FXm faSiTE8ZKN3HlE96XjxXPHwgiO5sQZTrA7d1sGXXBbTzWllfPpZAvawskZLlA3gJA2iS YOTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=AQEebDuiApyMST9ZTulg4RdpITa592ypiLLzUObzPTg=; b=OWVtpu4bST8GnZqdb39MarjjvOhiq1ipDDwVatIfYdKDXMxt3kmOiJ0cU8wROaI/Iu 8pAQeRS2d71WheK2rQxtM6EIxsnRrbPDti4ra7104mlW0+Jf8wyS7Ou6cPNnwSFmAMHH otyxTSYtZWvm1XeKgQp3frbANGsXhgyA+UieBuol2+wqBixznToW4IYjt+tZ1j2of3WH oRs/NDRfkKd9kQuHe49Z3KU04u7RNkZWE0J/GtUjFmpWoBas7R9vzAc2gDtwfqbonmGm 98Z23f+sP4SHOOwlR3vUM0fUj6Lp+NNvWb/kY3VwHr6XWUWVG6o8Ti3CNL1TG2eKG41N C4VA== X-Gm-Message-State: AOAM5320mjHx642GjA4a3FXmNTd+Vqz+aZEg1UmwJwd+pXW22ZCzA8by CEua8+GCTrUtO+aomwddNNeqA/K+lh02/A== X-Google-Smtp-Source: ABdhPJxgCRQ7zOv7th4wrJoAJ3geJjGf3h1AFCrrQj7zO7kZY96ISplqGtfeQMLTpSYgVxa6Q09nzw== X-Received: by 2002:a37:9d4e:: with SMTP id g75mr2274521qke.186.1598970684956; Tue, 01 Sep 2020 07:31:24 -0700 (PDT) Received: from [172.17.0.2] ([52.232.245.24]) by smtp.gmail.com with ESMTPSA id b34sm1663341qtc.73.2020.09.01.07.31.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 07:31:24 -0700 (PDT) Message-ID: <5f4e5b3c.1c69fb81.a7ffb.4f12@mx.google.com> Date: Tue, 01 Sep 2020 07:31:24 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============7611905431545700016==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, daan@dptechnics.com Subject: RE: Mesh: make SIG model header file locations more consistent Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200901115418.82056-2-daan@dptechnics.com> References: <20200901115418.82056-2-daan@dptechnics.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.68 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1D9AA420EE X-Rspamd-UID: d91cfe --===============7611905431545700016== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkbuild Failed Outputs: ar: `u' modifier ignored since `D' is the default (see `U') ar: `u' modifier ignored since `D' is the default (see `U') ar: `u' modifier ignored since `D' is the default (see `U') ar: `u' modifier ignored since `D' is the default (see `U') tools/meshctl.c:53:10: fatal error: mesh/generic-onoff-model.h: No such file or directory 53 | #include "mesh/generic-onoff-model.h" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. make[1]: *** [Makefile:6791: tools/meshctl.o] Error 1 make: *** [Makefile:4010: all] Error 2 --- Regards, Linux Bluetooth --===============7611905431545700016==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kJXaBGRhTl9X1gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 16:57:40 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UKZbA2RhTl9mKQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 16:57:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 24768A2429; Tue, 1 Sep 2020 16:57:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728596AbgIAO5O (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 10:57:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728352AbgIAO5I (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 10:57:08 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D7F9C061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 07:57:08 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id q9so1478813wmj.2 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 07:57:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hLDJ+UQsBYKOwVzT7ELuuVL1CsF0kEh5OP6WOxpuSVA=; b=GGWUMXRFzgpBPc/6U2OE2ANTVTMt8sqLniAaYvyzhv6ifIN5v71HwZ7Oc0WSbVB5jz LYyyiytAQz5bAxf9eoYM01pzjanOX7ErZOL/U8rG2S/H++r5cBXF4X93KUuDkqti7Moy yOaqe8En+YtdjpkKIFK2XgVE3jgzyMgNR1YnZD27Yt0sA6cNunaDPg5xogVWQ9FAbpqK KUi1/CQwIgcpvTGdvmwSWITmqCdCJcPDziWi3M6jHKBB4DNoqYoVrfYzR0OduIFpluPp ie6mVbuD0YxKraJ/E0D1giHhOhylyogH0+opE/CO2OcAsNiI5PXX8IGE3vKodCeIVA/U Haaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hLDJ+UQsBYKOwVzT7ELuuVL1CsF0kEh5OP6WOxpuSVA=; b=BdNMDxuWsGkAKmK3dVIW47DGDcZl8FoBLUuhXEY12jI2ML15WVX74QJZEgStEFwf86 fK1Ddq6Re0oKBrNTA4DLb7O5Sng8V/YkOa83bUAtQKLkjGf+anVSVLg2CN97fRnMm2Ys tMXJ+YfB+34qo+c4XRY6SCwAwfpb89mc2/mOAy4nc3b8Br4ZsfKKFpbaxt2J12QXMubA bI/SzOcfgiFJ6+8HcRqxNnCNBaWFUFMFs8AFEKiewK9a3AuGv0JY4FwY6XAxs3lk2bQr fpmi0GsNoxHoeM6MAGaV7HmODvQEupDL6mGlWfXmqoC3rz9CagkEUIGS9MvekzGbu/cm URWA== X-Gm-Message-State: AOAM530j48ex+gL0Ou13bXDt+qwSUVUUspHtYPPxONHPwJ8pQ1gakmPp 4iRWLZD72IS9A5KCSRhgSdWICH9dJgHL7HnzTsE8pa4pzJCRMw== X-Google-Smtp-Source: ABdhPJwn8D4wdvBtqGayrcTDAeg7RwvlXYOgqSHIAscRzsDXXAeSjU2fymqsCJaw3qHJtYILA4OGTln6MEsDEnSgkdY= X-Received: by 2002:a1c:c20a:: with SMTP id s10mr2183737wmf.55.1598972226635; Tue, 01 Sep 2020 07:57:06 -0700 (PDT) MIME-Version: 1.0 References: <20200831153544.Bluez.v1.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> <CABBYNZ+Q84vmEDgfNuoYXAAMi6T3segO_hSkG5Oufc5F_w9Qeg@mail.gmail.com> <CAJQfnxHyzFAG6zJfsuneLX_rW8yNkd2ZpKotHu3DV6vZABT-qw@mail.gmail.com> <CABBYNZJ4Y-U1nvyBvFwUXf+c0uT-42pBbrNtBG_G4RhLXGYspw@mail.gmail.com> <CAJQfnxEauZcut7yr85X7gTRzr7qo3BrBzXG+wHe=74c5c3sCig@mail.gmail.com> <CABBYNZL=NfVk3zo9C8g-Urbztx2LKWG28=4qWNbBW+KhJJh=Jw@mail.gmail.com> <CAJQfnxGGmRSWZgvx8VLrTO9KV5hysLjgXMK1ONKCTQKYrQ1uLA@mail.gmail.com> In-Reply-To: <CAJQfnxGGmRSWZgvx8VLrTO9KV5hysLjgXMK1ONKCTQKYrQ1uLA@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Tue, 1 Sep 2020 22:56:55 +0800 Message-ID: <CAJQfnxE+p_VYwOMOQxCE=MG=_eV5FoxJVFE54wmQ10iJNbAErQ@mail.gmail.com> Subject: Re: [Bluez PATCH v1 1/2] doc/media-api: Add Press method for MediaPlayer1 To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.72 / 15.00 / 200.00 X-Rspamd-Queue-Id: 24768A2429 X-Rspamd-UID: 714e81 Hi Luiz, On Tue, 1 Sep 2020 at 14:30, Archie Pusaka <apusaka@google.com> wrote: > > On Tue, 1 Sep 2020 at 13:42, Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Archie, > > > > On Mon, Aug 31, 2020 at 10:33 PM Archie Pusaka <apusaka@google.com> wrote: > > > > > > Hi Luiz, > > > > > > On Tue, 1 Sep 2020 at 13:20, Luiz Augusto von Dentz > > > <luiz.dentz@gmail.com> wrote: > > > > > > > > Hi Archie, > > > > > > > > On Mon, Aug 31, 2020 at 8:19 PM Archie Pusaka <apusaka@google.com> wrote: > > > > > > > > > > Hi Luiz, > > > > > > > > > > The reason we introduced this method is because we need to send some > > > > > of AVRCP category 2 passthroughs in order to be able to qualify the > > > > > AVRCP absolute volume control as an audio source, despite we don't > > > > > actually plan to send any passthrough in the practice. > > > > > > > > I wonder what those are, are they volume up/down? > > > Yes, volume up/down and mute are the ones that are unique to category > > > 2, but there are also some other buttons which are included in > > > category 2 as well but not unique to it, for example button 0 - 9, > > > help, and power. > > > > Weird, there are dedicated commands for setting absolut volume, not > > sure why one would use volume up/down to qualify? Or is that testing > > any button that belongs to category 2? Anyway it would be nice to know > > what test that is and what is the expected behavior the test case > > expects from us. > > Weird, yes. Sending absolute volume command capability is declared in > the AVRCP ICS 2/50, but it can only be selected if 2/8 is also > selected, which is sending passthrough command for category 2. > Therefore, we also need to be able to send a category 2 passthrough. > > The test itself is AVRCP/CT/PTT/BV-02-I. This is the test to see > whether we can send a category 2 passthrough, not the one to see > whether we can send the absolute volume command. The test asks us to > send every category 2 passthrough we declared in the ICS file (table > 4). There should be at least one passthrough declared. > > > > > > > > > > > > > > > Therefore, which passthrough we send is actually not important (to > > > > > us), as long as we can do that to satisfy the requirement. > > > > > However, I see that there are over 50 passthroughs across category 1 - > > > > > 4, and thought that it would be cumbersome to have a different method > > > > > for each key if one day we decided to support them all, hence the > > > > > generic method. > > > > > > > > Yep, but there are button presses so things gets a little more > > > > complicated if we need to emulate press/hold/release semantics. > > > For now, I don't think having a separate method for each key will make > > > it easier if we need to emulate hold and release semantics. > > > > > > Could we have 3 methods as follows, all have avc_key as a param: > > > (a) press. This means BlueZ will auto-release it within a short amount of time > > > (b) hold. Bluez wouldn't release it unless it received (c). > > > (c) release. Bluez will release the previously held button. > > > What do you think? > > > > I'm fine with that, we might have to start the status of each request > > though, also the holding should not last longer than 2 seconds if I > > recall correctly. > > Then I shall try to have this implemented. > Btw I only took a quick glance, but I did not find the 2 seconds > limitation in the spec. I found it in the AV/C Panel Subunit specification from 1394 trade association. It says we want to support "hold", then we need to frequently resend the key with "pressed" state, because if 2 seconds passed without the TG receiving it, then the TG will assume a "release" state is sent (but is lost). Also, the specification doesn't support multiple simultaneous button presses, because we are supposed to send "release" before sending a new "pressed" key, so I think we don't need to track the status for each request. > > > > > > > > > > > > May I have some questions? > > > > > (1) Why do you prefer a dedicated method per key? > > > > > (2) Let's say I need to add a dedicated method for a single category 2 > > > > > passthrough key, do you have a key in mind or I can just pick by > > > > > myself? > > > > > > > > > > Thanks, > > > > > Archie > > > > > > > > > > > > > > > On Tue, 1 Sep 2020 at 01:16, Luiz Augusto von Dentz > > > > > <luiz.dentz@gmail.com> wrote: > > > > > > > > > > > > Hi Archie, > > > > > > > > > > > > On Mon, Aug 31, 2020 at 12:37 AM Archie Pusaka <apusaka@google.com> wrote: > > > > > > > > > > > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > > > > > > > > > > > This allows us to send any passthrough command. > > > > > > > > > > > > > > Reviewed-by: Michael Sun <michaelfsun@google.com> > > > > > > > --- > > > > > > > > > > > > > > doc/media-api.txt | 8 ++++++++ > > > > > > > 1 file changed, 8 insertions(+) > > > > > > > > > > > > > > diff --git a/doc/media-api.txt b/doc/media-api.txt > > > > > > > index dabc69936..fe7222eef 100644 > > > > > > > --- a/doc/media-api.txt > > > > > > > +++ b/doc/media-api.txt > > > > > > > @@ -199,6 +199,14 @@ Methods void Play() > > > > > > > Possible Errors: org.bluez.Error.NotSupported > > > > > > > org.bluez.Error.Failed > > > > > > > > > > > > > > + void Press(byte avc_key) > > > > > > > + > > > > > > > + Press a specific key to send as passthrough command. > > > > > > > + > > > > > > > + Possible Errors: org.bluez.Error.InvalidArguments > > > > > > > + org.bluez.Error.NotSupported > > > > > > > + org.bluez.Error.Failed > > > > > > > + > > > > > > > Properties string Equalizer [readwrite] > > > > > > > > > > > > > > Possible values: "off" or "on" > > > > > > > -- > > > > > > > 2.28.0.402.g5ffc5be6b7-goog > > > > > > > > > > > > For now I would prefer to use dedicated method per key or are there > > > > > > many keys you would like to use from the upper layer? > > > > > > > > > > > > > > > > > > -- > > > > > > Luiz Augusto von Dentz > > > > > > > > > > > > > > > > -- > > > > Luiz Augusto von Dentz > > > > > > Thanks, > > > Archie > > > > > > > > -- > > Luiz Augusto von Dentz Thanks, Archie Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2NIEN9eUTl+jVgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 20:37:11 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id IGvGNdeUTl94ugAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 20:37:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D5B09420DD; Tue, 1 Sep 2020 20:37:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729688AbgIARrc (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 13:47:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgIARra (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 13:47:30 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0637C061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 10:47:29 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id j21so1893299oii.10 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 10:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OBa4zSsC7mmvdX3MM5YBiZhyDeDh3CNd56AtQwupmoA=; b=X0vyufV04Cvvr6FFJ3aETHrb/NoC3lWzm1Eb9kMd8Kun4dZ93mAoxtOWxEoyUVq3Fz XdiLrRGbKoOrKxAJuJNkuKDOEreMNdUgJUf4WdfbwtAbSSOWx7/JKLalBTEnZOQULgoV y9M0siiBImjaRldkPAnjUXYt19u6e2gxkOZPmYDidWflMgvHeJmAqcjl13i8a8MzKB6d 86T/xoFEC33sekkFmTfvvBwEdp+vzx6oMPq7dhM6cK2dvSPrylWgPRW+/W/9pGOdMZk9 v88Tpv/GKKqYZQAHOdk2G2XkIvENbMTsaGlwS1R/XX/BmldfwC5DHK2+88oKk9VAOyz6 bFGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OBa4zSsC7mmvdX3MM5YBiZhyDeDh3CNd56AtQwupmoA=; b=mZK5nl/nhr9Jcvt8TlrQXn8UR0Fh/Y0lePu7EoOaNfcVYnEuoigcAkh5jxHrf3APpR z2Fda/OHgMpEJ+ssqe1MxHTJ0mt2pNYnBeq5dSDysS4ZAmCwI01MFnWxsvNwPN4ZGl28 0s/5/rFE0JCEOfVlrcwtfdT0kQJzObHqEM2NxMQlsbjhQTRaqV96VAUCjQlrf5s8sd6n ac8k+l9Bg/Z/aF3fDSnYK/J2OoW96hkI1j/rAHKU2XgKPd4/XNHFZiq/m/G6E8jS/sK0 Lp9Smwrba5FZpOSG3QueddHg8L+SilM9XtwvcjvW2zm1jVc8eScn7fiIdOvmFT8FlAfg Gf7Q== X-Gm-Message-State: AOAM531G9XkolFLzhHbbPGfF/ytG8nyK/RR/+aSbUDmTSsDBgnCbnA0q 3LpKhqtAe/cB4yf3dojRwAQMUC2nMvuvtKwFbao= X-Google-Smtp-Source: ABdhPJxXL/aJxj8HMruY2b8PhLvLnMf36eDoYI8E6GbEXHXzNDRvIzrYa7A9by477MXaEe30UYAvL8n27xGMjXq/I+s= X-Received: by 2002:a05:6808:913:: with SMTP id w19mr1759257oih.48.1598982449016; Tue, 01 Sep 2020 10:47:29 -0700 (PDT) MIME-Version: 1.0 References: <20200817212554.3844965-1-yudiliu@google.com> <20200817142545.RFC.v2.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> <CABBYNZLRqhB6d5Hm7_RqvUqCJo11D4+pgYLCeWj0j=8dZk0Bcg@mail.gmail.com> <CAHC-ybxshy5zmkAku6suicvjO0Ngofp0+gRyYLX_RXr9YhU94Q@mail.gmail.com> <CAHC-ybxFY_3HWrvnwF5DS-i-YJtYpUuR9K3-MSWJWo=C-CKQHA@mail.gmail.com> <CALWDO_Wsyx3s3SwBejAFdc6SFX=V29DnvPKmo48hd-yy9SqHSg@mail.gmail.com> In-Reply-To: <CALWDO_Wsyx3s3SwBejAFdc6SFX=V29DnvPKmo48hd-yy9SqHSg@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 1 Sep 2020 10:47:19 -0700 Message-ID: <CABBYNZJxjYUvui7e-S4TGx21W2U9QvmXhyKNOaWg3RLR4jWg2A@mail.gmail.com> Subject: Re: [RFC PATCH v2 1/1] adapter - D-Bus API for querying the adapter's capabilities To: Alain Michaud <alainmichaud@google.com> Cc: Yu Liu <yudiliu@google.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.73 / 15.00 / 200.00 X-Rspamd-Queue-Id: D5B09420DD X-Rspamd-UID: 4a4809 Hi Alain, On Tue, Sep 1, 2020 at 8:43 AM Alain Michaud <alainmichaud@google.com> wrote: > > Hi Marcel/Luiz, > > I'd be particularly interested in seeing your opinion on whether this could be better described as some form of SCO socket property... even if this is indeed an adapter property. Yep, but wasn't that supposed to be what BT_PKT_STATUS is for? I mean one can just attempt to read it with getsockopt and in case of returns an error it means the controller does not support it, that said it doesn't look like we do check the adapter features when using BT_PKT_STATUS, should that be checking if HCI_WIDEBAND_SPEECH_ENABLED is set? Also it doesn't seem we have updated userspace to support BT_PKT_STATUS, we should probably have something to test it via isotest and perhaps create a iso-tester.c to validate all the options. > Thanks, > Alain > > On Mon, Aug 31, 2020 at 5:44 PM Yu Liu <yudiliu@google.com> wrote: >> >> +Alain Michaud >> >> Hi Marcel, >> >> Can you please comment on the cl as well as Luiz's suggestion? Thanks. >> >> On Thu, Aug 20, 2020 at 10:20 AM Yu Liu <yudiliu@google.com> wrote: >> > >> > Friendly ping for comments from Marcel. Thanks. >> > >> > >> > On Mon, Aug 17, 2020 at 4:17 PM Luiz Augusto von Dentz >> > <luiz.dentz@gmail.com> wrote: >> > > >> > > Hi Marcel, >> > > >> > > On Mon, Aug 17, 2020 at 4:07 PM Yu Liu <yudiliu@google.com> wrote: >> > > > >> > > > From: Archie Pusaka <apusaka@chromium.org> >> > > > >> > > > Initially this is introduced to query whether WBS is supported by the adapter, >> > > > the API is generic enough to be extended to support querying others in >> > > > the future. >> > > > >> > > > Reviewed-by: sonnysasaka@chromium.org >> > > > >> > > > Signed-off-by: Yu Liu <yudiliu@google.com> >> > > > --- >> > > > >> > > > Changes in v2: >> > > > - Return an array of strings instead of a dict >> > > > >> > > > Changes in v1: >> > > > - Initial change >> > > > >> > > > doc/adapter-api.txt | 12 ++++++++++++ >> > > > 1 file changed, 12 insertions(+) >> > > > >> > > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt >> > > > index 1a7255750..8fbcadb54 100644 >> > > > --- a/doc/adapter-api.txt >> > > > +++ b/doc/adapter-api.txt >> > > > @@ -204,6 +204,18 @@ Methods void StartDiscovery() >> > > > org.bluez.Error.NotReady >> > > > org.bluez.Error.Failed >> > > > >> > > > + array{string} GetCapabilities() >> > > > + >> > > > + This method returns a list of supported >> > > > + capabilities that is populated when the adapter >> > > > + initiated. >> > > > + >> > > > + Possible values: >> > > > + "wbs" - Wide band speech >> > > >> > > Btw, should we stick to use wbs terminology here, or we should >> > > actually use the HCI feature/command, because wbs has actually to be >> > > implemented by the HFP afaik this is only indicating that the >> > > controller is able to notify packets drops, etc, with use of erroneous >> > > command. Perhaps we should actually use the term PLC (Packet Loss >> > > Concealment) instead since that seems to be the real capability here, >> > > afaik WBS does not actually require PLC. >> > > >> > > > + >> > > > + Possible errors: org.bluez.Error.NotReady >> > > > + org.bluez.Error.Failed >> > > > + >> > > > Properties string Address [readonly] >> > > > >> > > > The Bluetooth device address. >> > > > -- >> > > > 2.28.0.220.ged08abb693-goog >> > > > >> > > >> > > >> > > -- >> > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8JNTKESaTl/pVgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 21:00:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id OOSjJkSaTl/S3wAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 21:00:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AB6F6A11B1; Tue, 1 Sep 2020 21:00:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726490AbgIATAO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 15:00:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726107AbgIATAN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 15:00:13 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2263EC061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 12:00:12 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id c2so2839301ljj.12 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 12:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e2a2eHRC4UrZkaHxq8PViyMXpd2KFeO0w59OoKcQ6wM=; b=LuEvfc/iMsq897RADN1GPbouFhFD7vrAxT0yLxElC+bFkwVNmfGih3ZMNkLo4x1nF3 IiM2w2a+O13nF49FYYoCpnEeVpexkkn+Tglpcx2yT8CKPhZaXVzRtHRG3l++gK9MOXZn 6qykvDaSXwmT0PNUi10YyTc0rpDn/9Fnpbc+ZpD8OHyCGwBfosaaE1PxGZeqkKPLggoj Vc6OFW6TkJ4GG1ahADAGG0A1tdIAmtkqRLW7DR9f2ihMuEklKGGabnEOUTLzJThK22Fp 7VQe1Lg3Gkg8vpqjfUprw9NMaG8IQz/5e/JtwGcOpG7oY3QA3PnWUQnxced9+EvCx5Br wcGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e2a2eHRC4UrZkaHxq8PViyMXpd2KFeO0w59OoKcQ6wM=; b=N3q0OF8W2mycgaVChanUHcv/hV2OQy21cjJl/BclMiq8NMZBHnQf5kQpH31LMg8T/D DHv0/WF8KDeBT/iOR2zphbaElcck8uxlBg2F6poqE2q2edEKSzLUe228e7fbIiQYnLK9 BRa2cW8RInifpFzm1jiOyiqWTaJlJknK38Zll6p/xMqjiYn/O10/xZ9oISOye3SNdHoZ fjT0I93HS/+qJ6UwW5/rhI66W9KXYJBZbr8jMzB3CoIysNwAH4wCRWDiVgGkM0owi1WO /4Jxos3KuClwvBaPUnuPvQUNAPqVJCrmmtRSL4xKuwUgQwVWivjuRcpqyP+IXsaxZeVB VLbg== X-Gm-Message-State: AOAM5328ssmS8mScM4Npp8GuurLED3jeo81BDPitCp6OokwtRJeg0Ti7 ZXL7pg+wCX21IJG72dBv1GLJOzLk8IMAXF9fog0TgQ== X-Google-Smtp-Source: ABdhPJzlwrRTy9qT7aVCVvmafg/jgkrM7gZEw8kt6wcBjg4u+OC3q+0oMB5RrkbxoIob/FcIqzmLycVH6VwqDoupyVQ= X-Received: by 2002:a2e:b4c6:: with SMTP id r6mr1285598ljm.274.1598986810973; Tue, 01 Sep 2020 12:00:10 -0700 (PDT) MIME-Version: 1.0 References: <20200817212554.3844965-1-yudiliu@google.com> <20200817142545.RFC.v2.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> <CABBYNZLRqhB6d5Hm7_RqvUqCJo11D4+pgYLCeWj0j=8dZk0Bcg@mail.gmail.com> <CAHC-ybxshy5zmkAku6suicvjO0Ngofp0+gRyYLX_RXr9YhU94Q@mail.gmail.com> <CAHC-ybxFY_3HWrvnwF5DS-i-YJtYpUuR9K3-MSWJWo=C-CKQHA@mail.gmail.com> <CALWDO_Wsyx3s3SwBejAFdc6SFX=V29DnvPKmo48hd-yy9SqHSg@mail.gmail.com> <CABBYNZJxjYUvui7e-S4TGx21W2U9QvmXhyKNOaWg3RLR4jWg2A@mail.gmail.com> In-Reply-To: <CABBYNZJxjYUvui7e-S4TGx21W2U9QvmXhyKNOaWg3RLR4jWg2A@mail.gmail.com> From: Alain Michaud <alainmichaud@google.com> Date: Tue, 1 Sep 2020 14:59:59 -0400 Message-ID: <CALWDO_XV+Hn-U+SgAe_tCcpST0NAo+UjRCBbdS8dzBQZuUCXEg@mail.gmail.com> Subject: Re: [RFC PATCH v2 1/1] adapter - D-Bus API for querying the adapter's capabilities To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Yu Liu <yudiliu@google.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.49 / 15.00 / 200.00 X-Rspamd-Queue-Id: AB6F6A11B1 X-Rspamd-UID: bc9af6 Hi Luiz, On Tue, Sep 1, 2020 at 1:47 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Alain, > > On Tue, Sep 1, 2020 at 8:43 AM Alain Michaud <alainmichaud@google.com> wrote: > > > > Hi Marcel/Luiz, > > > > I'd be particularly interested in seeing your opinion on whether this could be better described as some form of SCO socket property... even if this is indeed an adapter property. > > Yep, but wasn't that supposed to be what BT_PKT_STATUS is for? I mean > one can just attempt to read it with getsockopt and in case of returns > an error it means the controller does not support it, that said it > doesn't look like we do check the adapter features when using > BT_PKT_STATUS, should that be checking if HCI_WIDEBAND_SPEECH_ENABLED > is set? The problem here is that this will be after the connection is created and a packet is exchanged. In this context, we'd like to know if the controller supports it ahead of creating a sco connection so we can choose to use the headset at all. For example, there are devices and circumstances where using the device's built-in mic and A2DP will yield a better experience for the user so the platform may choose that as a default for the user rather than degrading down to narrow-band. > > Also it doesn't seem we have updated userspace to support > BT_PKT_STATUS, we should probably have something to test it via > isotest and perhaps create a iso-tester.c to validate all the options. > > > Thanks, > > Alain > > > > On Mon, Aug 31, 2020 at 5:44 PM Yu Liu <yudiliu@google.com> wrote: > >> > >> +Alain Michaud > >> > >> Hi Marcel, > >> > >> Can you please comment on the cl as well as Luiz's suggestion? Thanks. > >> > >> On Thu, Aug 20, 2020 at 10:20 AM Yu Liu <yudiliu@google.com> wrote: > >> > > >> > Friendly ping for comments from Marcel. Thanks. > >> > > >> > > >> > On Mon, Aug 17, 2020 at 4:17 PM Luiz Augusto von Dentz > >> > <luiz.dentz@gmail.com> wrote: > >> > > > >> > > Hi Marcel, > >> > > > >> > > On Mon, Aug 17, 2020 at 4:07 PM Yu Liu <yudiliu@google.com> wrote: > >> > > > > >> > > > From: Archie Pusaka <apusaka@chromium.org> > >> > > > > >> > > > Initially this is introduced to query whether WBS is supported by the adapter, > >> > > > the API is generic enough to be extended to support querying others in > >> > > > the future. > >> > > > > >> > > > Reviewed-by: sonnysasaka@chromium.org > >> > > > > >> > > > Signed-off-by: Yu Liu <yudiliu@google.com> > >> > > > --- > >> > > > > >> > > > Changes in v2: > >> > > > - Return an array of strings instead of a dict > >> > > > > >> > > > Changes in v1: > >> > > > - Initial change > >> > > > > >> > > > doc/adapter-api.txt | 12 ++++++++++++ > >> > > > 1 file changed, 12 insertions(+) > >> > > > > >> > > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt > >> > > > index 1a7255750..8fbcadb54 100644 > >> > > > --- a/doc/adapter-api.txt > >> > > > +++ b/doc/adapter-api.txt > >> > > > @@ -204,6 +204,18 @@ Methods void StartDiscovery() > >> > > > org.bluez.Error.NotReady > >> > > > org.bluez.Error.Failed > >> > > > > >> > > > + array{string} GetCapabilities() > >> > > > + > >> > > > + This method returns a list of supported > >> > > > + capabilities that is populated when the adapter > >> > > > + initiated. > >> > > > + > >> > > > + Possible values: > >> > > > + "wbs" - Wide band speech > >> > > > >> > > Btw, should we stick to use wbs terminology here, or we should > >> > > actually use the HCI feature/command, because wbs has actually to be > >> > > implemented by the HFP afaik this is only indicating that the > >> > > controller is able to notify packets drops, etc, with use of erroneous > >> > > command. Perhaps we should actually use the term PLC (Packet Loss > >> > > Concealment) instead since that seems to be the real capability here, > >> > > afaik WBS does not actually require PLC. > >> > > > >> > > > + > >> > > > + Possible errors: org.bluez.Error.NotReady > >> > > > + org.bluez.Error.Failed > >> > > > + > >> > > > Properties string Address [readonly] > >> > > > > >> > > > The Bluetooth device address. > >> > > > -- > >> > > > 2.28.0.220.ged08abb693-goog > >> > > > > >> > > > >> > > > >> > > -- > >> > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IG0sHnijTl8ysQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 21:39:36 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id AF5sHHijTl+tFAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 21:39:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 04527420D4; Tue, 1 Sep 2020 21:39:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728407AbgIATja convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 15:39:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:44560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728329AbgIATja (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 15:39:30 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Tue, 01 Sep 2020 19:39:28 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ao@thurston.ru X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-60824-62941-bXxu1mfu6U@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: 04527420D4 X-Rspamd-UID: 438308 https://bugzilla.kernel.org/show_bug.cgi?id=60824 Pavel Volkov (ao@thurston.ru) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ao@thurston.ru --- Comment #147 from Pavel Volkov (ao@thurston.ru) --- My dongle worked fine with kernel 5.7, broken with 5.8.0 (problems connecting with headphones) and seems to be fixed again in 5.8.5. Same device as comment 118. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ILqqNIKxTl/R9AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 22:39:30 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id sIulMoKxTl/8rAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 22:39:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2A5BE417C0; Tue, 1 Sep 2020 22:39:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726853AbgIAUjY (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 16:39:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726091AbgIAUjW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 16:39:22 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75866C061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 13:39:22 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id c18so2944402wrm.9 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 13:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:references:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=5W1bCq0H++5vHkhWo54hQn5+PNnP+ARcLtctPXcOeRE=; b=TLbgRLt/6zdkTXVEL3nt2vJj5g+MzD3g1f6LIwIBDk+n+9uDYWf+gRXXF8VkvSUmfv rZdVLEaUjJ4ei7PH9XJgz0XVZRmApHBClSwczIphpSSB5eB9CLeEW1vuAZmVkiHMEx0R UdzykY1Nyn3iFmsSfvj4XYKjHANDpXaab7WKkNLx1SJJyhNInZ2ah4TXRUCBKsIOthCr FegWznJM51wtCAjxaCZ+GhQ0aw/auKwEGsnvc0ki1vV8zMg+Z+xxpCXlbGE10KBe5uEW fSvWNNmBxsET6IlA+gkFXahYjVj0HSJqjFuLuhn+Gsvg9T8q690NvsstCkaJyGM0f7Iq 0yNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:autocrypt:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5W1bCq0H++5vHkhWo54hQn5+PNnP+ARcLtctPXcOeRE=; b=PwzLcDRmz7nPZ0VP+cl8HJAy2I+utbkYcq9+RTeGNSc47Q9WBa7tSJW0ji4EQmfDxT Xkgcyl1heuAyZBYbIfyt7R9H0dtWBC3mViy2KryMfk7ambzmfhjQpznMnNu8O8+GWJZV m+DXmcrNJw5Sfj1Kxpvg6S0BleMhAV3pO5wSA4BzpjI2W8rbyVW0J902O5risBI9uhxc 46tOROP0jA8UJ/8ZPMCyYM8NFQUDf0JICcOjipPlhUGwm7VcI2fQ4QAUmhej1hyDKg5b Y2V4SDwY8N3wfpsUK/ufLz3AGiTgXQ4NEIlaENT4WdybtdACyMJmkfQLKI0Aicg6qR/4 u2CQ== X-Gm-Message-State: AOAM532mEowaXywVZ3aLDfSywN6Et5s2jhfRAqUx+nhAYRB5Z7x5HFIL IF2Dca2Vj5OQBbwJb+jD0oGXvvhOQSI= X-Google-Smtp-Source: ABdhPJxwNgN5OrNFJAVVGsBqMSGlO0iIoP0B8HbGSy9aFZw+lPGKQaZlbuJBdWSFhMdv4EimrG0GYQ== X-Received: by 2002:a5d:4388:: with SMTP id i8mr2441403wrq.365.1598992760624; Tue, 01 Sep 2020 13:39:20 -0700 (PDT) Received: from ?IPv6:2a02:908:1982:45e0:80a3:8327:7b91:9429? ([2a02:908:1982:45e0:80a3:8327:7b91:9429]) by smtp.googlemail.com with ESMTPSA id l21sm3048712wmj.25.2020.09.01.13.39.19 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Sep 2020 13:39:19 -0700 (PDT) Subject: Re: Bluetooth connection disconnects every few minutes From: Julian Sikorski <belegdol@gmail.com> To: linux-bluetooth@vger.kernel.org References: <67077b05-dc49-3a97-c83f-4090f1cc7cea@gmail.com> <phdhvi$sdh$1@blaine.gmane.org> <8e41e2ae-bef4-d479-9706-49fd214081a6@chini.tk> <phdpkn$q3q$1@blaine.gmane.org> <pht30d$27m$1@blaine.gmane.org> <53d57478-4b61-65a4-7f09-b7e473cc613a@chini.tk> <305017ee-6420-3c44-7842-14776c37207d@gmail.com> <12fa0585-c993-0685-ac76-27d96d539ca2@gmail.com> <9a633975-704c-1a00-3f9f-b93a499947c2@gmail.com> <8bf4641f-4d3e-faf4-f53a-c571b97d9be4@gmail.com> Autocrypt: addr=belegdol@gmail.com; prefer-encrypt=mutual; keydata= mQENBE40CmIBCACj+gI1pIMD0VGrZD4ugde8f3usLc0OE0OnPDXjqelxsC3B/x9BFoQrzfnP qJEtcB6F4V5MuEYutnteeuFsIkLHx6UIe9vr1Ze01XtN7Emsya/AKXaEcXYzUUjVmWn1NjJF ZlX0ML3mIQPERBDEY/aXAj7cVDGvkFVeKWIWE5KRqQWV2rYo0nizZTRYGB0z6KpMninG4hqF KvvpzhDS5ZnxijEYs0YAx0QllI4LjLTH3xLuYMnSbHzFRBh9zUsMttMnZdCudLZC6ZllkjtM ov/kIO35P5ygFJ9xlLyxMFkhXsARDWe3qwJCEHfJgtcblQD/LHuY200fTmrbwTK9Q4uNABEB AAG0JEp1bGlhbiBTaWtvcnNraSA8YmVsZWdkb2xAZ21haWwuY29tPokBOAQTAQIAIgUCTjQK YgIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQLdUZIcIlWSuFYwf+J5lKOXWz+FJW Vn4b8Q237R/SOlZVwVfT9u/EjxGkploecihuzRadwXDMu030zdgo0m4lwEubOD5eMvzpBSYu Dc3fDPT/T5/O7avybt2w83hptPuwU4O0EmNrkgr6pHql1nxEvBpeB8KkJnexJww95Kl1YmBX c1kdRrAShNxiVQDpPnskGtnfK2eTqyuyhECApIVLxMIX5IsqGCpslRUR6e90iHd591iJgRT+ Ji74QjkCQzJJVcKbX5T7HzbUd6mmkZjNbtog3g6WEPkI4Qdw+ZeDlSViN/SKPS2ptMMzxCOT neVuw3c6qM/VUo6AUTPSl+1c1rO2X7ZY5/Z9dCMP9rkBDQRONApiAQgAmurakWU/VVEKiPcM o5IsActeWERRTxgUXmliSp02YtBLYwOBQ6WUmJyhywOR8s3Wh93cHEPgEPI/n+cfytNxvpol liSXp3PZGJAmBSIq13d1lDYJBzDzNjUz6dj9YMV56zcsWbYF25grXbPY4acy/5RQXHWjQ4R9 dtGCMd48dhMH6O0DvsiriRxJQrcXz0mgLSi79KVns4VgIuUuPCwPyF1zNUBs/srbgTuL+On0 GjbK40GnJq/Zw2LhEGeicp0npoc4jshgVTtUXRQrGo04plJNpNg9Tl1UIbsHrjA1qz9yo8GR 4MLgXzcyfM6h+wz6qC8eI7jx4VEZxMhXtalvywARAQABiQEfBBgBAgAJBQJONApiAhsMAAoJ EC3VGSHCJVkrpl0IAJJd8qETlL0XzNZsguk8LwXi0c++iTTbotw/zn1f7CgGsZErm58KqNhR UltAZvK+lOclNPbZRsGzoEdg4TIvSymWVLN6jyblhcqH4G9mxmf6QOLvYR5I02UQiIbKvTvv mFA8bgr2vXPFc8rBmFXrwyC3DOjfrnz23kGattsFWbRA2OBq7bp/05JVoMb4QRA2TIbbvsyQ g0MMs9VldhdVfZcFqU2qKwQs8fBr8BD+OfPeiYndJV4GnfYhK692viMjv/+dgOvYcEgtlFaJ TLeiWvwUUxJ7ai45p+gCHXUYPGwrH4Dm2HAw61vUDkbT5pVOeGlFsvtOVEajnQX+MOV93l4= Message-ID: <2bd00ced-f685-9048-5a10-a20028595086@gmail.com> Date: Tue, 1 Sep 2020 22:39:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <8bf4641f-4d3e-faf4-f53a-c571b97d9be4@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2A5BE417C0 X-Rspamd-UID: af309d W dniu 01.09.2020 o 22:10, Julian Sikorski pisze: > W dniu 12.08.2018 o 17:49, Julian Sikorski pisze: >> W dniu 01.08.2018 o 19:46, Julian Sikorski pisze: >>> W dniu 09.07.2018 o 18:51, Julian Sikorski pisze: >>>> W dniu 08.07.2018 o 19:46, Georg Chini pisze: >>>>> On 08.07.2018 15:21, Julian Sikorski wrote: >>>>>> W dniu 02.07.2018 o 20:09, Julian Sikorski pisze: >>>>>>> W dniu 02.07.2018 o 18:04, Georg Chini pisze: >>>>>>>> On 02.07.2018 17:58, Julian Sikorski wrote: >>>>>>>>> W dniu 29.06.2018 o 21:47, Julian Sikorski pisze: >>>>>>>>>> Hi list, >>>>>>>>>> >>>>>>>>>> I have noticed that the bluetooth connection between my laptop (Intel >>>>>>>>>> 7260) and my headphones (Sennheiser Momentum Wirelless) is very >>>>>>>>>> unreliable. While under Windows 10 devices stay connected for >>>>>>>>>> hours on >>>>>>>>>> end, under Fedora 28 the connection is lost every few minutes at >>>>>>>>>> most. >>>>>>>>>> Often the connection will be reestablished only to be lost again. >>>>>>>>>> bluetoothd shows messages like: >>>>>>>>>> >>>>> >>>>>>>>>> I am not sure where to look further. Does it look like an issue with >>>>>>>>>> pulseaudio, or a deeper problem with linux bluetooth stack? Thanks >>>>>>>>>> for >>>>>>>>>> your input in advance! >>>>>>>>>> >>>>>>>>>> Best regards, >>>>>>>>>> Julian >>>>>>>>> This is what is logged by pulseaudio at the time the connection is >>>>>>>>> lost: >>>>>>>>> >>>>>>>>> ( 118.064|  34.694) I: [bluetooth] module-bluez5-device.c: FD error: >>>>>>>>> POLLERR POLLHUP >>>>>>>>> ( 118.064|   0.000) I: [bluetooth] bluez5-util.c: Transport >>>>>>>>> /org/bluez/hci0/dev_00_1B_66_81_8D_76/fd27 auto-released by BlueZ or >>>>>>>>> already released >>>>>>>>> ( 118.064|   0.000) I: [pulseaudio] backend-native.c: Lost RFCOMM >>>>>>>>> connection. >>>>>>>>> >>>>>>>>> >>>>>>>>  From what you are writing, it looks to me as if the issue is in the >>>>>>>> USB >>>>>>>> stack and the BT dongle keeps disconnecting/connecting. Have you >>>>>>>> tried another dongle? >>>>>>> Hi, >>>>>>> >>>>>>> I unfortunately do not own any other dongles. I tried getting some >>>>>>> useful info with btmon but the log seems flooded with way too many >>>>>>> messages to make anything out. >>>>>>> >>>>>> Hi Georg, >>>>>> >>>>>> it looks like the problem is more related to how the dongle interacts >>>>>> with this specific headphone model. I have recently bought another one >>>>>> for running (AfterShokz Trekz Air) and it works perfectly, connecting >>>>>> automatically, staying connected and even switching profiles >>>>>> automatically without issues so far. >>>>>> The hci0: last event is not cmd complete (0x0f) message seems harmless >>>>>> as it spams the dmesg output regardless of the device connected (and >>>>>> also when no device is connected at all. >>>>>> It appears that whatever is happening it makes the dongle reconnect: >>>>>> >>>>>> [nie lip  8 15:14:12 2018] usb 2-1.4: USB disconnect, device number 6 >>>>>> [nie lip  8 15:14:12 2018] usb 2-1.4: new full-speed USB device number 7 >>>>>> using ehci-pci >>>>>> [nie lip  8 15:14:12 2018] usb 2-1.4: New USB device found, >>>>>> idVendor=8087, idProduct=07dc, bcdDevice= 0.01 >>>>>> [nie lip  8 15:14:12 2018] usb 2-1.4: New USB device strings: Mfr=0, >>>>>> Product=0, SerialNumber=0 >>>>>> [nie lip  8 15:14:12 2018] Bluetooth: hci0: read Intel version: >>>>>> 3707100180012d0d2a >>>>>> [nie lip  8 15:14:12 2018] Bluetooth: hci0: Intel device is already >>>>>> patched. patch num: 2a >>>>>> >>>>>> Where would you recommend to look for reasons for this behaviour? btmon? >>>>>> Thank you for the pointers! >>>>>> >>>>>> Best regards, >>>>>> Julian >>>>>> >>>>>> >>>>> Hi Julian, >>>>> >>>>> sorry, I have no further ideas. Maybe Luiz can help you to investigate. >>>>> To me it looks like the headphone is sending something that makes the >>>>> dongle reset. >>>>> >>>>> Regards >>>>>             Georg >>>> >>>> Hi Georg, >>>> >>>> no worries - hopefully Luiz will find some time to look into this. >>>> In the meantime I have been getting acquainted with btmon. I have >>>> managed to pinpoint the exact moment during which sound stops coming >>>> through the headphones and starts coming through the laptop speakers. In >>>> the below testcase, it happens at 18:42:58: >>>> >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>> #1825 [hci0] 18:42:58.908586 >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>> #1826 [hci0] 18:42:58.928877 >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>>> {0x0002} [hci0] 18:43:00.653578 >>>> Class: 0x000000 >>>> Major class: Miscellaneous >>>> Minor class: 0x00 >>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>>> {0x0001} [hci0] 18:43:00.653578 >>>> Class: 0x000000 >>>> Major class: Miscellaneous >>>> Minor class: 0x00 >>>> @ MGMT Event: New Settings (0x0006) plen 4 >>>> {0x0002} [hci0] 18:43:00.653609 >>>> Current settings: 0x00000ada >>>> Connectable >>>> Discoverable >>>> Bondable >>>> Secure Simple Pairing >>>> BR/EDR >>>> Low Energy >>>> Secure Connections >>>> @ MGMT Event: New Settings (0x0006) plen 4 >>>> {0x0001} [hci0] 18:43:00.653609 >>>> Current settings: 0x00000ada >>>> Connectable >>>> Discoverable >>>> Bondable >>>> Secure Simple Pairing >>>> BR/EDR >>>> Low Energy >>>> Secure Connections >>>> = bluetoothd: Unable to get io data for Headset Voice gateway: >>>> getpeername: Transport endpoint is not connected.. 18:43:00.654133 >>>> = Close Index: 7C:5C:F8:B2:DF:08 >>>> [hci0] 18:43:00.678348 >>>> @ MGMT Event: Index Removed (0x0005) plen 0 >>>> {0x0002} [hci0] 18:43:00.678372 >>>> @ MGMT Event: Index Removed (0x0005) plen 0 >>>> {0x0001} [hci0] 18:43:00.678372 >>>> = Delete Index: 7C:5C:F8:B2:DF:08 >>>> [hci0] 18:43:00.678377 >>>> = bluetoothd: Endpoint unregistered: sender=:1.1492 >>>> path=/MediaEndpoint/A2DPSource >>>> 18:43:00.678966 >>>> = bluetoothd: Endpoint unregistered: sender=:1.1492 >>>> path=/MediaEndpoint/A2DPSink >>>> 18:43:00.678984 >>>> >>>> I am copying linux-bluetooth, maybe someone there will have an idea as >>>> well. Thank you for all your help in advance! >>>> >>>> Best regards, >>>> Julian >>> >>> Hi all, >>> >>> I tried to get more information using hcidump, but it does not appear >>> very interesting. I am attaching it here just in case. The last entry >>> appearing - command complete (read encryption key size) - appears upon >>> successful connection, not when the connection is dropped. How else >>> could I try to figure out what is being sent at the time of >>> disconnection? Thank you! >>> >>> Best regards, >>> Julian >> >> Hi list, >> >> I just realised I never attached the full btmon dump. Here it goes, the >> connection drops at 17:32:04: >> >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >> #1340 [hci0] 17:32:04.774611 >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>> HCI Event: Number of Completed Packets (0x13) plen 5 >> #1341 [hci0] 17:32:04.783175 >> Num handles: 1 >> Handle: 256 >> Count: 1 >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >> #1342 [hci0] 17:32:04.794981 >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>> HCI Event: Number of Completed Packets (0x13) plen 5 >> #1343 [hci0] 17:32:04.803054 >> Num handles: 1 >> Handle: 256 >> Count: 1 >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >> #1344 [hci0] 17:32:04.815326 >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>> HCI Event: Number of Completed Packets (0x13) plen 5 >> #1345 [hci0] 17:32:04.823198 >> Num handles: 1 >> Handle: 256 >> Count: 1 >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >> #1346 [hci0] 17:32:04.835578 >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >> #1347 [hci0] 17:32:04.856093 >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >> #1348 [hci0] 17:32:04.876186 >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >> #1349 [hci0] 17:32:04.896454 >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >> #1350 [hci0] 17:32:04.916869 >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >> {0x0002} [hci0] 17:32:06.637019 >> Class: 0x000000 >> Major class: Miscellaneous >> Minor class: 0x00 >> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >> {0x0001} [hci0] 17:32:06.637019 >> Class: 0x000000 >> Major class: Miscellaneous >> Minor class: 0x00 >> @ MGMT Event: New Settings (0x0006) plen 4 >> {0x0002} [hci0] 17:32:06.637034 >> Current settings: 0x00000ada >> Connectable >> Discoverable >> Bondable >> Secure Simple Pairing >> BR/EDR >> Low Energy >> Secure Connections >> @ MGMT Event: New Settings (0x0006) plen 4 >> {0x0001} [hci0] 17:32:06.637034 >> Current settings: 0x00000ada >> Connectable >> Discoverable >> Bondable >> Secure Simple Pairing >> BR/EDR >> Low Energy >> Secure Connections >> = Close Index: 7C:5C:F8:B2:DF:08 >> [hci0] 17:32:06.654087 >> @ MGMT Event: Index Removed (0x0005) plen 0 >> {0x0002} [hci0] 17:32:06.654114 >> @ MGMT Event: Index Removed (0x0005) plen 0 >> {0x0001} [hci0] 17:32:06.654114 >> = Delete Index: 7C:5C:F8:B2:DF:08 >> [hci0] 17:32:06.654120 >> = bluetoothd: Unable to get io data for Headset Voice gateway: >> getpeername: Transport endpoint is not connected.. 17:32:06.654352 >> = bluetoothd: Endpoint unregistered: sender=:1.750 >> path=/MediaEndpoint/A2DPSource >> 17:32:06.654796 >> = bluetoothd: Endpoint unregistered: sender=:1.750 >> path=/MediaEndpoint/A2DPSink >> 17:32:06.654836 >> >> I tried sending the btmon capture as attachment but it appears to be too >> large for the list, so I uploaded it here instead: >> >> https://belegdol.fedorapeople.org/btmon-aug.log >> >> Best regards, >> Julian >> > > Hi all, > > I have tried the headset again with kernel-5.8.4, bluez-5.54 and > pulseaudio-13.99.1. The situation has unfortunately not improved in the > last two years. > I am attaching the btmon capture of two connection attempts: > - the first connects and then almost immediately disconnects > - the second never succeeds > Does the capture provide any information as to why the connection is > failing? If I can provide any more data, please let me know. Thanks! > > Best regards, > Julian > If I am not mistaken, the disconnect happens right after #636 Best regards, Julian Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IJEUIcuqTl/KngAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 22:10:51 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id aJrYH8uqTl9EZgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 22:10:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 97047A1657; Tue, 1 Sep 2020 22:10:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728149AbgIAUKp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 16:10:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726669AbgIAUKm (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 16:10:42 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAE31C061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 13:10:39 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id t10so2050245wrv.1 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 13:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:references:from:to:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=NYzyMb4rPm82sJ8hGvbDWKjmvRFv2Bb/9x0WE3GTIuc=; b=uQYwc2o18BV5dKnvP7zNbIkXalbNXRsW2NRdE4vkqMzxqZnXX8d7yNNBNLrcMEBOEp YgTsNHWwu85/titHdyjUbx7WUBsXsjAsQUt9P42csxBRH+MDcVSdHDGmcSJ4OG0Bo+xp WrohX1sNLnvwsEsDNCwMhSjRIcHpjEC91Uf3tu2WZWxhNMHuVsD2kynRerqvWgkHY+Qo b8GI4G+/ZZhVa9QBoZYZ9WXmCjPWH6u10x1JzJvU7dtSI/Ni0U9K4B4iT7xAAULJICzN NbWcSmINak169fAliT2mxi/LXOTkCA/XTkPGe+LboKJ6lMAnU7t5mZWRzpb4HQqXzZ2s 98aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:references:from:to:autocrypt:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=NYzyMb4rPm82sJ8hGvbDWKjmvRFv2Bb/9x0WE3GTIuc=; b=uLmYu37ajVYSmme23XgxAsrGCfPJKxrjVQ0l8B1RpxTvtgaz/yrr+5P1mw3EYJBi9E c2RX092rPJd15hRcH24uCgSHIRQpIdmN0OmavFMTvx4dwC0hYW8p+nen80DbONjwixI8 9xCF7+R4rIhQEGwUfONirfnM2OVfI5n6iqUxaJdDICrfaosybo1EkdTP8noY7DQrMm63 gUHXn8JbCJvgQLtbcb5jX0umxA8/ecfHJgob9IR1DqpsgSPLUP1BUnV5xhBO/1ZvzH2M kqEvqOg06vl3A1zWltnLGAtAFIZCF8JBp8OFaGKQ0wVnmXTbUDfs12it2JuZOMWhsOLL zQOA== X-Gm-Message-State: AOAM533Tf3SNs3+3f0Ej3YAemqdFrPMPnaJj8VrRcx/ovHWOGyKOnVQP y/HbCfFHbv3T5E+NXJFxiqyd+x0NCDw= X-Google-Smtp-Source: ABdhPJxiyWeV87flX1ToFKNDDcg6Lopne8VOcfAD47K/I0os51iWqi/qNvEBhXle3hunWfupxGskSA== X-Received: by 2002:adf:dd0b:: with SMTP id a11mr3508315wrm.422.1598991037902; Tue, 01 Sep 2020 13:10:37 -0700 (PDT) Received: from ?IPv6:2a02:908:1982:45e0:80a3:8327:7b91:9429? ([2a02:908:1982:45e0:80a3:8327:7b91:9429]) by smtp.googlemail.com with ESMTPSA id p14sm4292496wrg.96.2020.09.01.13.10.35 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Sep 2020 13:10:36 -0700 (PDT) Subject: Re: Bluetooth connection disconnects every few minutes References: <67077b05-dc49-3a97-c83f-4090f1cc7cea@gmail.com> <phdhvi$sdh$1@blaine.gmane.org> <8e41e2ae-bef4-d479-9706-49fd214081a6@chini.tk> <phdpkn$q3q$1@blaine.gmane.org> <pht30d$27m$1@blaine.gmane.org> <53d57478-4b61-65a4-7f09-b7e473cc613a@chini.tk> <305017ee-6420-3c44-7842-14776c37207d@gmail.com> <12fa0585-c993-0685-ac76-27d96d539ca2@gmail.com> <9a633975-704c-1a00-3f9f-b93a499947c2@gmail.com> From: Julian Sikorski <belegdol@gmail.com> To: linux-bluetooth@vger.kernel.org Autocrypt: addr=belegdol@gmail.com; prefer-encrypt=mutual; keydata= mQENBE40CmIBCACj+gI1pIMD0VGrZD4ugde8f3usLc0OE0OnPDXjqelxsC3B/x9BFoQrzfnP qJEtcB6F4V5MuEYutnteeuFsIkLHx6UIe9vr1Ze01XtN7Emsya/AKXaEcXYzUUjVmWn1NjJF ZlX0ML3mIQPERBDEY/aXAj7cVDGvkFVeKWIWE5KRqQWV2rYo0nizZTRYGB0z6KpMninG4hqF KvvpzhDS5ZnxijEYs0YAx0QllI4LjLTH3xLuYMnSbHzFRBh9zUsMttMnZdCudLZC6ZllkjtM ov/kIO35P5ygFJ9xlLyxMFkhXsARDWe3qwJCEHfJgtcblQD/LHuY200fTmrbwTK9Q4uNABEB AAG0JEp1bGlhbiBTaWtvcnNraSA8YmVsZWdkb2xAZ21haWwuY29tPokBOAQTAQIAIgUCTjQK YgIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQLdUZIcIlWSuFYwf+J5lKOXWz+FJW Vn4b8Q237R/SOlZVwVfT9u/EjxGkploecihuzRadwXDMu030zdgo0m4lwEubOD5eMvzpBSYu Dc3fDPT/T5/O7avybt2w83hptPuwU4O0EmNrkgr6pHql1nxEvBpeB8KkJnexJww95Kl1YmBX c1kdRrAShNxiVQDpPnskGtnfK2eTqyuyhECApIVLxMIX5IsqGCpslRUR6e90iHd591iJgRT+ Ji74QjkCQzJJVcKbX5T7HzbUd6mmkZjNbtog3g6WEPkI4Qdw+ZeDlSViN/SKPS2ptMMzxCOT neVuw3c6qM/VUo6AUTPSl+1c1rO2X7ZY5/Z9dCMP9rkBDQRONApiAQgAmurakWU/VVEKiPcM o5IsActeWERRTxgUXmliSp02YtBLYwOBQ6WUmJyhywOR8s3Wh93cHEPgEPI/n+cfytNxvpol liSXp3PZGJAmBSIq13d1lDYJBzDzNjUz6dj9YMV56zcsWbYF25grXbPY4acy/5RQXHWjQ4R9 dtGCMd48dhMH6O0DvsiriRxJQrcXz0mgLSi79KVns4VgIuUuPCwPyF1zNUBs/srbgTuL+On0 GjbK40GnJq/Zw2LhEGeicp0npoc4jshgVTtUXRQrGo04plJNpNg9Tl1UIbsHrjA1qz9yo8GR 4MLgXzcyfM6h+wz6qC8eI7jx4VEZxMhXtalvywARAQABiQEfBBgBAgAJBQJONApiAhsMAAoJ EC3VGSHCJVkrpl0IAJJd8qETlL0XzNZsguk8LwXi0c++iTTbotw/zn1f7CgGsZErm58KqNhR UltAZvK+lOclNPbZRsGzoEdg4TIvSymWVLN6jyblhcqH4G9mxmf6QOLvYR5I02UQiIbKvTvv mFA8bgr2vXPFc8rBmFXrwyC3DOjfrnz23kGattsFWbRA2OBq7bp/05JVoMb4QRA2TIbbvsyQ g0MMs9VldhdVfZcFqU2qKwQs8fBr8BD+OfPeiYndJV4GnfYhK692viMjv/+dgOvYcEgtlFaJ TLeiWvwUUxJ7ai45p+gCHXUYPGwrH4Dm2HAw61vUDkbT5pVOeGlFsvtOVEajnQX+MOV93l4= Message-ID: <8bf4641f-4d3e-faf4-f53a-c571b97d9be4@gmail.com> Date: Tue, 1 Sep 2020 22:10:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <9a633975-704c-1a00-3f9f-b93a499947c2@gmail.com> Content-Type: multipart/mixed; boundary="------------1E532EBB45443DF8DB21149B" Content-Language: en-US Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.24 / 15.00 / 200.00 X-Rspamd-Queue-Id: 97047A1657 X-Rspamd-UID: c1b258 This is a multi-part message in MIME format. --------------1E532EBB45443DF8DB21149B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit W dniu 12.08.2018 o 17:49, Julian Sikorski pisze: > W dniu 01.08.2018 o 19:46, Julian Sikorski pisze: >> W dniu 09.07.2018 o 18:51, Julian Sikorski pisze: >>> W dniu 08.07.2018 o 19:46, Georg Chini pisze: >>>> On 08.07.2018 15:21, Julian Sikorski wrote: >>>>> W dniu 02.07.2018 o 20:09, Julian Sikorski pisze: >>>>>> W dniu 02.07.2018 o 18:04, Georg Chini pisze: >>>>>>> On 02.07.2018 17:58, Julian Sikorski wrote: >>>>>>>> W dniu 29.06.2018 o 21:47, Julian Sikorski pisze: >>>>>>>>> Hi list, >>>>>>>>> >>>>>>>>> I have noticed that the bluetooth connection between my laptop (Intel >>>>>>>>> 7260) and my headphones (Sennheiser Momentum Wirelless) is very >>>>>>>>> unreliable. While under Windows 10 devices stay connected for >>>>>>>>> hours on >>>>>>>>> end, under Fedora 28 the connection is lost every few minutes at >>>>>>>>> most. >>>>>>>>> Often the connection will be reestablished only to be lost again. >>>>>>>>> bluetoothd shows messages like: >>>>>>>>> >>>> >>>>>>>>> I am not sure where to look further. Does it look like an issue with >>>>>>>>> pulseaudio, or a deeper problem with linux bluetooth stack? Thanks >>>>>>>>> for >>>>>>>>> your input in advance! >>>>>>>>> >>>>>>>>> Best regards, >>>>>>>>> Julian >>>>>>>> This is what is logged by pulseaudio at the time the connection is >>>>>>>> lost: >>>>>>>> >>>>>>>> ( 118.064|  34.694) I: [bluetooth] module-bluez5-device.c: FD error: >>>>>>>> POLLERR POLLHUP >>>>>>>> ( 118.064|   0.000) I: [bluetooth] bluez5-util.c: Transport >>>>>>>> /org/bluez/hci0/dev_00_1B_66_81_8D_76/fd27 auto-released by BlueZ or >>>>>>>> already released >>>>>>>> ( 118.064|   0.000) I: [pulseaudio] backend-native.c: Lost RFCOMM >>>>>>>> connection. >>>>>>>> >>>>>>>> >>>>>>>  From what you are writing, it looks to me as if the issue is in the >>>>>>> USB >>>>>>> stack and the BT dongle keeps disconnecting/connecting. Have you >>>>>>> tried another dongle? >>>>>> Hi, >>>>>> >>>>>> I unfortunately do not own any other dongles. I tried getting some >>>>>> useful info with btmon but the log seems flooded with way too many >>>>>> messages to make anything out. >>>>>> >>>>> Hi Georg, >>>>> >>>>> it looks like the problem is more related to how the dongle interacts >>>>> with this specific headphone model. I have recently bought another one >>>>> for running (AfterShokz Trekz Air) and it works perfectly, connecting >>>>> automatically, staying connected and even switching profiles >>>>> automatically without issues so far. >>>>> The hci0: last event is not cmd complete (0x0f) message seems harmless >>>>> as it spams the dmesg output regardless of the device connected (and >>>>> also when no device is connected at all. >>>>> It appears that whatever is happening it makes the dongle reconnect: >>>>> >>>>> [nie lip  8 15:14:12 2018] usb 2-1.4: USB disconnect, device number 6 >>>>> [nie lip  8 15:14:12 2018] usb 2-1.4: new full-speed USB device number 7 >>>>> using ehci-pci >>>>> [nie lip  8 15:14:12 2018] usb 2-1.4: New USB device found, >>>>> idVendor=8087, idProduct=07dc, bcdDevice= 0.01 >>>>> [nie lip  8 15:14:12 2018] usb 2-1.4: New USB device strings: Mfr=0, >>>>> Product=0, SerialNumber=0 >>>>> [nie lip  8 15:14:12 2018] Bluetooth: hci0: read Intel version: >>>>> 3707100180012d0d2a >>>>> [nie lip  8 15:14:12 2018] Bluetooth: hci0: Intel device is already >>>>> patched. patch num: 2a >>>>> >>>>> Where would you recommend to look for reasons for this behaviour? btmon? >>>>> Thank you for the pointers! >>>>> >>>>> Best regards, >>>>> Julian >>>>> >>>>> >>>> Hi Julian, >>>> >>>> sorry, I have no further ideas. Maybe Luiz can help you to investigate. >>>> To me it looks like the headphone is sending something that makes the >>>> dongle reset. >>>> >>>> Regards >>>>             Georg >>> >>> Hi Georg, >>> >>> no worries - hopefully Luiz will find some time to look into this. >>> In the meantime I have been getting acquainted with btmon. I have >>> managed to pinpoint the exact moment during which sound stops coming >>> through the headphones and starts coming through the laptop speakers. In >>> the below testcase, it happens at 18:42:58: >>> >>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>> #1825 [hci0] 18:42:58.908586 >>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>> #1826 [hci0] 18:42:58.928877 >>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>> {0x0002} [hci0] 18:43:00.653578 >>> Class: 0x000000 >>> Major class: Miscellaneous >>> Minor class: 0x00 >>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>> {0x0001} [hci0] 18:43:00.653578 >>> Class: 0x000000 >>> Major class: Miscellaneous >>> Minor class: 0x00 >>> @ MGMT Event: New Settings (0x0006) plen 4 >>> {0x0002} [hci0] 18:43:00.653609 >>> Current settings: 0x00000ada >>> Connectable >>> Discoverable >>> Bondable >>> Secure Simple Pairing >>> BR/EDR >>> Low Energy >>> Secure Connections >>> @ MGMT Event: New Settings (0x0006) plen 4 >>> {0x0001} [hci0] 18:43:00.653609 >>> Current settings: 0x00000ada >>> Connectable >>> Discoverable >>> Bondable >>> Secure Simple Pairing >>> BR/EDR >>> Low Energy >>> Secure Connections >>> = bluetoothd: Unable to get io data for Headset Voice gateway: >>> getpeername: Transport endpoint is not connected.. 18:43:00.654133 >>> = Close Index: 7C:5C:F8:B2:DF:08 >>> [hci0] 18:43:00.678348 >>> @ MGMT Event: Index Removed (0x0005) plen 0 >>> {0x0002} [hci0] 18:43:00.678372 >>> @ MGMT Event: Index Removed (0x0005) plen 0 >>> {0x0001} [hci0] 18:43:00.678372 >>> = Delete Index: 7C:5C:F8:B2:DF:08 >>> [hci0] 18:43:00.678377 >>> = bluetoothd: Endpoint unregistered: sender=:1.1492 >>> path=/MediaEndpoint/A2DPSource >>> 18:43:00.678966 >>> = bluetoothd: Endpoint unregistered: sender=:1.1492 >>> path=/MediaEndpoint/A2DPSink >>> 18:43:00.678984 >>> >>> I am copying linux-bluetooth, maybe someone there will have an idea as >>> well. Thank you for all your help in advance! >>> >>> Best regards, >>> Julian >> >> Hi all, >> >> I tried to get more information using hcidump, but it does not appear >> very interesting. I am attaching it here just in case. The last entry >> appearing - command complete (read encryption key size) - appears upon >> successful connection, not when the connection is dropped. How else >> could I try to figure out what is being sent at the time of >> disconnection? Thank you! >> >> Best regards, >> Julian > > Hi list, > > I just realised I never attached the full btmon dump. Here it goes, the > connection drops at 17:32:04: > > < ACL Data TX: Handle 256 flags 0x02 dlen 850 > #1340 [hci0] 17:32:04.774611 > Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >> HCI Event: Number of Completed Packets (0x13) plen 5 > #1341 [hci0] 17:32:04.783175 > Num handles: 1 > Handle: 256 > Count: 1 > < ACL Data TX: Handle 256 flags 0x02 dlen 850 > #1342 [hci0] 17:32:04.794981 > Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >> HCI Event: Number of Completed Packets (0x13) plen 5 > #1343 [hci0] 17:32:04.803054 > Num handles: 1 > Handle: 256 > Count: 1 > < ACL Data TX: Handle 256 flags 0x02 dlen 850 > #1344 [hci0] 17:32:04.815326 > Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >> HCI Event: Number of Completed Packets (0x13) plen 5 > #1345 [hci0] 17:32:04.823198 > Num handles: 1 > Handle: 256 > Count: 1 > < ACL Data TX: Handle 256 flags 0x02 dlen 850 > #1346 [hci0] 17:32:04.835578 > Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > < ACL Data TX: Handle 256 flags 0x02 dlen 850 > #1347 [hci0] 17:32:04.856093 > Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > < ACL Data TX: Handle 256 flags 0x02 dlen 850 > #1348 [hci0] 17:32:04.876186 > Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > < ACL Data TX: Handle 256 flags 0x02 dlen 850 > #1349 [hci0] 17:32:04.896454 > Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > < ACL Data TX: Handle 256 flags 0x02 dlen 850 > #1350 [hci0] 17:32:04.916869 > Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > @ MGMT Event: Class Of Device Changed (0x0007) plen 3 > {0x0002} [hci0] 17:32:06.637019 > Class: 0x000000 > Major class: Miscellaneous > Minor class: 0x00 > @ MGMT Event: Class Of Device Changed (0x0007) plen 3 > {0x0001} [hci0] 17:32:06.637019 > Class: 0x000000 > Major class: Miscellaneous > Minor class: 0x00 > @ MGMT Event: New Settings (0x0006) plen 4 > {0x0002} [hci0] 17:32:06.637034 > Current settings: 0x00000ada > Connectable > Discoverable > Bondable > Secure Simple Pairing > BR/EDR > Low Energy > Secure Connections > @ MGMT Event: New Settings (0x0006) plen 4 > {0x0001} [hci0] 17:32:06.637034 > Current settings: 0x00000ada > Connectable > Discoverable > Bondable > Secure Simple Pairing > BR/EDR > Low Energy > Secure Connections > = Close Index: 7C:5C:F8:B2:DF:08 > [hci0] 17:32:06.654087 > @ MGMT Event: Index Removed (0x0005) plen 0 > {0x0002} [hci0] 17:32:06.654114 > @ MGMT Event: Index Removed (0x0005) plen 0 > {0x0001} [hci0] 17:32:06.654114 > = Delete Index: 7C:5C:F8:B2:DF:08 > [hci0] 17:32:06.654120 > = bluetoothd: Unable to get io data for Headset Voice gateway: > getpeername: Transport endpoint is not connected.. 17:32:06.654352 > = bluetoothd: Endpoint unregistered: sender=:1.750 > path=/MediaEndpoint/A2DPSource > 17:32:06.654796 > = bluetoothd: Endpoint unregistered: sender=:1.750 > path=/MediaEndpoint/A2DPSink > 17:32:06.654836 > > I tried sending the btmon capture as attachment but it appears to be too > large for the list, so I uploaded it here instead: > > https://belegdol.fedorapeople.org/btmon-aug.log > > Best regards, > Julian > Hi all, I have tried the headset again with kernel-5.8.4, bluez-5.54 and pulseaudio-13.99.1. The situation has unfortunately not improved in the last two years. I am attaching the btmon capture of two connection attempts: - the first connects and then almost immediately disconnects - the second never succeeds Does the capture provide any information as to why the connection is failing? If I can provide any more data, please let me know. Thanks! Best regards, Julian --------------1E532EBB45443DF8DB21149B Content-Type: application/zip; name="btmon-m2aebt.zip" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="btmon-m2aebt.zip" UEsDBBQACAAIAFuvIVEAAAAAAAAAAIHKAQAQACAAYnRtb24tbTJhZWJ0LmxvZ1VUDQAH/qdO XwKoTl/+p05fdXgLAAEEAAAAAAQAAAAA7L0LeFNV1j+8zsntJL0kaVN6AcpO71wbrlZETcvF iqggiOh4aREUlEtaKKSocFppKZeWoqLooFNQmFYF0fESHC8pigrDSIrAJFUwRdGgImmtyIxo /mufk5MEepp5v+d5/9/zffO+5Vmcc/Zee+21f3vttdfe55LZS5csWrzYBvjHAGja8DiUUiAA sTQRTq2/8Ptfvz04Zf6iCjtZNrd8yfzFi8joYQXDRg0dYbEMu+/ekSOG2QvG3DNmFMkTjwNp MTOly4QcKlpQMXfp4sVL55ElFbOXVC5ZOndhSOSIYSNGUNZ0SlgwPqLgV6gasMAYqY5gmL10 4eJFcMmfIUgglQoMWZUrcOPfvHvnWy5lBy7MV3UmeE1JF5HuF1lZ+p8iSGw4v/qYQmicOkiK cNarrfFKVsyVKfjqj6qL9EIfpIiCbyyLj2Mw9wqNgeGZoXE0QxWkCAlvvWe8yDK9VP5ucbyS MQo1xAUpoui7LzRc1CEwHChR/iB5Ea3DUESDIOK3IEWIaC1uuPgvoYu7r1R6LS/v9toJ4fXA bbDqak7GeQcfKGtlnZY9xQCfIDFGnpjXfhNgUlmS4Irl+9u9q5wOr11ZTCUu0h8OHES6p01d tcmh3sb4RVmxLH96D+dd1br/BeR7tOOguQpMZu9Kr70fXjsHpdnuKCte7l2lqiPCNbfsOu1z wPrBfRcLORymbfylw8H2+XV5Hp5vMbR+3PqRd1UWnh9eApaUCd2ZjypqM4YIOsyr0lYVV9nK Y6E685PPvXb44PoHrft++/48N0vvXTkDeTo+vtiPe/1iPypDHrIDbDTIDoxByLoFyFr3e+22 oMgnu0ifasNLp8Qm/6ik4mm+eK3MUH9ncuuBgC2FbYLPbSlzsNyeFGAW9d9Xtbg/W2WPUK0Y aR5tTp9aG1hmMl/8pssV5bymLHB/F7/4d115g09M+UQ5dU27Y9QKkl5k+E1h7TsVy1n7wgkR pNb9S4Ny6fmCiDranN6VD0dcf55elDiFQloOluK756V5V2133hnK1xGpPfKQuY5Eg6wtFiHz MRSyWUGRJXisMii9GXZIAaKuLUna7jyEaSVJW5Zsax1bthXPa+MIU+hZR2LZ43ruVa+9EdOa Em/2PH/8gK3rJ8ZNLaSStSbWYfoqzgCr8Tg+Zl7Zut/2+tqUGwMb8Nr4W8AzmLNCE55Xkw+4 9+IXB1rKeG+dvjrwrmZj4AlMf0DnBWenYuMWCvnuW+LyO6tb3Xgep80GbjmbazW8EBgWX8Lq bF7765jutXMOVWWSy7wnxu+1D3A1NQ1wWV2xAyYoWso4TGlqvtblRL5njsMJjd+fIQ+Ze1sI svogRUDmmdxwcd0XLEK22qro0pNjUNMsGHiKt098E8T4C5LBD3UvY9q+to42q+F6xSuBlTuA 9678ENNium92DUupVog2clANnpeS4fxTcC4wrPkdzF+PTXfgcW5y3HmuhvfmaM/9cMYG+0R+ Ezs5B2yGtBSLeN3NyDfBuyjUhNNBimiCt7Xh4ikC8Bh8cR2m3Y20GMmlBMhAJ5iJpEGBo9G3 /gHp6ySAcWkA9yEl9gU42R/4CVj8zWyAj5FOIq3IAZiRC/Ahkh8pG53eKKTJg3GsDAEYiPQt 0gs47w3HKWjKaIAfkQZfAXB8LMBPSLOvQjlIzyB1It12LYClEKGYCVA6C/ORFiJ9+AdsB9Iz d6JV3QXwEdK5u8SGTEIqKgEIrIJePLfvmmgDwreQut2Z6Lm7LyBAJQphjoUhmDILyXBbcFLD v3F4Pg+JzALuIyXtX6+dUtC1xnTeAvzkuBIGPFzFA7bJZcXFYrl/6oD/o2vrMRN1ma4s3rwr b++3McADiCX3aFWaxQGzSxULfIlLTFvKsm540fzit5iWguXGxjUNesZzv2sEHjvjgWc86DVW bXOK3AaTxwB8LPJ9yukDGbGLf4U1p9kDRuD19n9yR6q8K0W+ZvYuE/CsW+Fn3NpdbawzRx4y f59okPlvpW5XgMyAVQ6YhVCsYtzeVbwb8FrJC64JTFcB/1j18U6e+pLEgOf51vW24VbgR58g a0ZVArESpo4ta3JQ3i0FwLuQjzed5X5iuOV9k+PP/xnTBqp501Eh3eyCum2tlPeWicCfinnl V6g/yd38K+8dRd33JOAL8OgnVvjN0Ua21bYR5kbg8389YBObPlNhJeCeimmZD/0DA7Osh6wK Fv0rwK03AX9T3Ll/jnGTepGXT34F057lngM1+hComxSz+BfG88epwFuLe7OyX06GILs9SBGQ XchuuDjTR21p6nPM03FGw7905y6McO9EkVmeIv8v3N1VP8VNa5xA3eo04MfRIxwoe1oNXKcT PFQOOm3esXfkzuDso77ZzCqDhimjzq8fRevBiznU6Gm40n3uvV0naXrRufeKTDQF+9WiQaPU 4ZEFbkYMcGPxOAFpJlIJ0gNILqQsBXBTkB5GakD6FOnDZOC+RjKkANeI5MW0i6nA3aIE7k6k +5BsSA1IzUjvDATONwAnzzwcXEOAsyLvCBVw1yAtQlqBVIv0GNJzSK8hfYT0OxKH8PRDmoF0 N1Id0mNIW5HcSKeQvIXINx64gglYBq93nez4XRayoYrNUSAbqmijRi9A1uF8EcPoVqfSoIAU g1IYxWpiUYo9M0HTsS8Dz1hiX9+6T+lUrWBaVcI4VRHb19KI/UIjnbljtjkzxEDPKKSQ150h rljprCBOOvPrGY8uA88s9nGkGSOCPRilINXtEaU4E5QmdpTSxCDBKFHiHc5O52SOhzanhpsG 3pWdQo1qkkd0OfwAsGwtonwMaeq3zbn6m0M5GY/Fd3/ef8uApgYlcwGPSnkrGxozNxpkMdtp rMFSyMDwTxTTB9rHmPxx8VMN5vhNhv76xw3BSobTSvLgUUK5kuDIm0eTWIOo0pyd25xr317S f4thDea9gZNMWRLbR5VRTWN8vgzTRb6Dz0sAdZv40wnoxSejh6EpSpLu8tp12bSh24xiyqEj XrsE+8NJYpravc3Z4cxwZwhXe7K4slZnrhZHo9dLqjCl4NZT8TyTjNGNTnTRN4vlxt0qHnNm ShItyYImspAljokGWeIChOwLBYVMSVIWbnPSWDCyjy/2+wSJexWvkeqQPkHiXsNrpDqkT97a GcuD0jQA+1+HpEXikDRIaiQVkhJJMepyO2FJcbsE4utp0llxP+lsVvo257g+vEHrg9rRfaoE 4BXkm7vF4493b3NSzSZnWeFljKZpLaLUCRWShC2D0g2MmekoKMlrmE4a1WL+rO2HMbZW66FO HrK+qmiQ9Z2AkGEkg5BlCIqUXNfPwDCK2oKS9clM8tQ1YiVTnn/pFO1Hlmy9y4zKgztO+5OC K+eW6/1Cf1peugvqvnIcJFVw/qci80ZFfu7HiZC1OZ9WJ8qovVNqyITR1H6o2s45H+NsspKZ VybWfnSXaC8Kku5YZ6sm42NEeF58Syr7RAEtGwT3yvB5c8S5Mz9sn6Ms3HLRwkwmKS12BFch ypWHLON4NMgyzQjZhyoKmWPXNie3/HAZbcgIMzXaekZvH2GuwrMGJr/SiL5TE9MG8LlW32aA L8XpVEFM74f80digUmSKRvRyI96jyvPeQTjDiNA6Eug2wstIKQbgzjlOERy+3MvXXlruzQNh AKzWbU69ibfEm6osou1zQf/2ybXUXqndiqXSa6UyS6+Szg7h2c05R/qIJbzXiJwT3knk7lZ2 OOUhG7QzGmSDHAiZQ00h63SO5ZxMm7NVrIy8nH58z3t6ngm6+C9CTUAl7rDxXnUX0ypydqvB LZ5N0NDBEjmki/9yDQes0hR3ydBMyqlKFOXOuE+SO06DQecqxkU3GjqdXIUI4g8zGbd49nVG ustal+4Cz5rvRABWW9X+ON00GJZSBGP28KcPklLmFNoolirqc1YstcV60TciKOGHoh5nspCN WB4NshFHELKXNYL7R0GiwA3TgoKnqdtSjMBtcqSkog1jmLVUiTMaEhZ/rzNoUUtv6XAw7oPE DOK1d8AgLcAsbBppzhBg2bBInMkO9ROvt3w17UjAw+3lEjA8sec5UrmpIJ4X5l1TTe1ORZS/ ibz8r1ItE9uY9mqftQU8E1ykOcGfIUwpr98lwsfli/xfrBSvYZyYf+ddF30/dD5IrGq6RpOI rgio/vKQjZ0UDbKxdyFkTRyFjDZqFCnhLa4JvKXNmgHsiO9LY25lh33nJ5/CkB/Z6lvjwdBU nfFIxrtfny6GHNi3ndSSM10L2dyNAwILvQFYMxBX26aF6J9wSZO1yNAuQtWUDrXw5yMOpQNz UE1vgDn99WnTN9t/EQOZJpLk4jykKclFlxlPEiU0pcziWc+4FCuv8FzA/5We11OsoPasT5kF Ks+d+L/G4131Nh699rwbhQXTexcVYEmh5xgyYSWPufqBJe9uNc7FVp5gh4Bngy8Lj3W+BD9J BI7pOOmQh6woORpkRUMRsie0FDLSl8DXHZPPJ2WMByryDFe1kS4MpR6hjSsg0nDhlp0NxLrg xKtBS5pQ0WLLCEZwB8QzorxNhKSZpMSBJQtXpx37Oz4a2FZqZNUlRlAXcjWQ+xlL/g45riL7 UG68Ak7i2uqbxPjEfn3MvGIb/7Ou8FG6OVLaRPlLU90w226wq/0Gu9JfhGfSXk5Yv/CA3mJL cDl5/puDOVUDKCSaLobXxKsMMcfZla6VMfHjE08E5CG7/ttokF3/L4SsTkch45bVhZoqunba WK99Qg5YmhmwYoRuxRW+RfI97+ho8Nixv+8xqAF+D90b5jmvCGDBUT2XDlDD8HrubtaE67U4 DDbBk2dT+pVulWffXsXefY5se3zbwzjkxbr2YF26NpOR5Xjv2rdNqU1gQqdwmGzXHCYdGhPy eVd+mBC0JIAnRJhUxNGd0WZqkTqObqCFp46SGKrjIORf6/u1onW/GB9uidP66VUsXUxlUgoE hF3cICg3zVHHzJY20udAeE99TunchcLe/OhRII/2tPeioT3tV0T74RiKdmmrqMsTcac7KYp0 HXrbRcad1B2PaPHeWLexK7btNjecaCkXXcyQu7SuljKxh0p+bLGFUVuNxqiMB0sBSr4N6w6H 9OvM4/P12kyCq2gc3lceOxPsYTgmHmcd4yrYpATjGZsyyWAUo93iuMEcnfIDAbHeKUVrfeB+ 1bOtnf1cRHnPMrH01Pac4wfKRC5+ophWfEKZvtpk2A3pOHdtVryp3My8qW3oy7kgjpOH7Pa1 0SC7/XWEzBZLIdsEugY91xj0/84TMT72SSWeBwK/fMW+CU8+73jZAW/q9eNNUP9nB+xS+QNf xOdCIuPldotlCk4cKFPslECILRNHOUNck0Qw68iQ8QgjUqfzK9czHhHGlzM7XNeGzr90HQqd nxBmny9cwan1OvH4wnWeHinHcC455hrWTM0z3D1jhS321adWf3Eol318VrfOw/qZjk0d61g1 7D/62vzXHwGZ2zWBoSXvsHDJ7ZqwsUp/MkCX3h4N6FI7Aj0njgL97FxN/S++PsF531UZ8Ch2 6blCAHehZ11GLfcXf9Yudf8iE5h5jIiZeHhD2X7drm/fF6dn7a7iXdm7oB2d36kBumPMm0f7 ZFTB06Xc2k5uAM+c5B1cy832WD/jnoTSJsaGrepTN3PyxaPsrj72yWXPlrTY1KFZaqdLV3eW IaDexX97KHd746xurQfld6zrOMKo4SkBKqr1BR8I6RvOPHPUZLZCOWEV//qOabc251cq/AFP 4GTGrkRtlQKEuj+OgZM3+RVSVCPdUIvwBLNnXuIJpi8tLV86f9H9ZPqEqWTJ3PJlc8t7wXp+ XjSs59+OWM+KF8MhV6ViVyJHdaLoauLhpNU/KGiiQz5Is8FJ5pvDKw/YBgXH/oV9F3zsMucb Srdml2+XxLl1X0b9w0dV2CujKp8phReZk8/gVINYeNd4cxCjBcdfm/f6I3vvy117Yu75M2yo b9eRD/IVu/pzjFKsv1jDLQv3iN1vCHEq0QZCXNqzneswGlD5efzfYB8Zz9IbnPHQjgZ8qq/u VmX5A0sfqsTaPr+38gx5/BxXiPEDTn4e3xnmpDxktgvRICujS7spNOLqjvEzJw/YJnu8EQ4J 3PDGN+8rqAEyGjTFttxtmyRzZNxc0BzNaI4FriQ0RxPGBUvtI+vOagfw/N6RzTdXxggGuS9C 5qeejF0U0MHHktCUTJXq9lGPWLOtiZPLJLMM+w9s2klp0qwjl87h92qfA53QFZu8K7ArUo8e mXd05XP35TZ06gr5nIYzcYWNioZgwF653se4ixDigxDWhG2Qh8z+STTI7BcRMquBQpbQ1sde UKINOa4DttjQ+eP+z7R0bu6LgXfxNWAx3Azcw1eDZTKGOdchFSNdj/TF1WJeQTJYJuD1RCSm 43vtMeZocqz/yHzaJA02ieFV2CRGpknrIsZ6MMAic/YpezY9PrLpC5Lj/EmEgVF2UzYY+oT0 Fku9vD+jIfZ0krkIZlReteKuubDrsU6tG63QKw8Z/1Q0yPhXELJRRgrZzdxmtoA2LNhX57Cv shu+v6Sv1gUVXq+JVDgLSyk8JvuWEknVeZ3hcEqyDEKmHk/wiNEl5bkRQ2z4UmHYBFZiYJR+ 5ttzq67Sf2YsPvra4uIj1L2x9SIMfe2zSnRlknN0DPjBBzjJauqVu7l65oRqtxptDU6w7mds 4+OmGQra2Pe7V/lLGa/Brv0c5X61+KHBMY+zXQ92r+oqvfZ+2mFJOYWJha9qNkqQoRM0hEFZ 8xFFSLgZTm+4x2KuMSLXJeYy9D40Tb2a0qVutC69l4BqYemi0vvnLpy7aCmZv2jp3PL7Su+d S4YPG34FXs5fOr90wfwVc+eAvFp1/Vip876idKladQNEtfD/SZCNFoDOCqXQJagWdBCDTYlD f6VHiUZIgEQwQRL0gWRIgVRIg77QD/rj1DsAYyVccWKUmIVSciAX8mAgDILBMASGwjDIx0Xq cBgBI2EUjIYxcAUUwJUwFq6CcQjENXAtWKEQimA8anEdFMP1MPm/UZdegBnHSjYfQ+kyYK4R gVH0HijUzY82Rup4HCN5dNnWzZxWtnAbX3nEmmUy52dpslUtui8VguXepZ9uyjmasNhkz2nD BZiCTeSJut1qfoyhjkhXJtnu9z6a08c+IgPI37jC1dh4M7VG5lUNpgvy8RhZg+os+vrd23Yr /CweDa51ZQfKxfHI/SiOMjuJcTEYl4GbKxO3WGJv9Nrt47CrMEimru3WoJsbhG2kywlpTFqC K8InzFXeiu6rj7H1Nd6ybth8VZvFdohU4/iwyD+cMLTxymiQNc5AyPolUshEMcNXze2+Clfk j3M08rCs+qsQcQ9fpawffhx2q+pFNV53sR5md56D3T0Uw8d1hItVeIr8A48z7jTb1/WwW13f sVu5W1NvzWYSVLs1m9Xt6je5zZo3tZu5N031CbvVi0KrfHftOUmqso15U1m/2pfSBqmsMtF9 IBhXzDuX6lfWG49TuQoZHWJFHVilRwI85Zx4t1+EfQu5WITregToYiEeEVZxDTZVJw/ZFm00 yLYMRsgMJnGTTWxGFuGWjcTFUd7yFeV/5Yxw2C6qsefsK5wBzlTw2av77nlEWjGvM9fl3WEb sexQTvWfAPJZ8ciy2u4W23cBQwVGB9kDDdrz7GJDUA63gqsAhHZyaBl8G2ckm8/2lBHThTFF WU1ErJDkTzrr3NWxi134QNmZcgl2LWqr9HGupiZpultaKYLF40zQFCfClIXUsT/dRQwKLsvA cMTA9rJU+lN7NMiankbIlEkUMkvl1CUHMz6FD3+hAi2VyahI8lHWkWSn09LcxtGVFQ/Rf+rG iodGV9J/Y2fbS1SnWFLFp6GDiTvGZiggOW6/4WNbGUs3vatA4Y+LKzLEaJfgOoDe4Q0+dvKO Sg8WywSwbHykgAl31b04ncXUwYlSXPe32FhPS3nLEnF96czjvS913emiacznUBdO3dZ1m4vU 3eYabSf8xb1Pd2/dS5pudWV6rDzzgLiQeuI6xh3wiCWmDl7rvyE5YdmNyYnLIKGKyEP250+j QdZcgJBdECDzZ1rJz45VXZcr+z3a1sR/DHaTNRlrxbStGbCGDapd9yG3bErwNlF31of2fDPX dFeXKphiyuJQNZ4cKPNnAvnKMcjWUj6tS8zzv5Nmyw3dYEqwHcyebVgVZzAMsh0og3aJhyuT eLZmDAlxq31Ug1oSWBvXFU7dEEpVB+uY+lmyj9aflMkQqHrUAdvCNRrblC3ykL3ijAbZHj1C 9kMfCtn+lnXkkEIU+MUgybDDzctxv9r5gpHeaQNLE1JBJVh+wOPXdrD48Lilki60g827Nx77 Pt4Vede+FMlcG9+tFVKTuD+pOLQa0WIUZOtxupimcl+2i7JpPeJNBjyrYzwi37jjpF5M/dpO LUu8f1Jy2rsy4whZt+ZMRltSJVRtRXAwbHLDi96V25xnbKJXVJE5w+IXtusPB8Sddy5NHrK3 HokG2VutCJk3mUImbk7FdvfnnmNS44yGOG5A8I7H21rx+IVOPE7Ribx6Ll0j5YwI9V5p8C7y UuRKRf8xIwQlncVeaE0rZ9rFBnx9Bzr6lqd8KSfYk+uXi3sfKvJhvpVAznb79dms6UxoPVP6 3pfxFY22d19wSi59m1OHY+FFBEDTRtauORO8AZGv8otnWfli/eH1Ds66FRgDnL4q7pjxFXtw aS0D2fs3RIPs/TqE7GgKhYwlDy+z+4by1R2HzKf47p/NfKmxCjq00/j1BkYzld9gUGiuquS/ cpq3o4+C9uKyccez41zGsbPb3564c62B1bAZVpjr6MvVwJgj5scSuYnAvKbxiw55wVTVznBw Lu0bTkkNb9MQgmvwxmfK4MR00gZ5jv2O+xxTzNamg9msAb5sWcbnKAe4VkrTzgpbcMOY40yG ZQdz5hsOZhzI1J23ZvOJ0kSz56ozy+6wPRCaZrb+OFpnILqz1gwrOiEmo6VcHrKPTdEg+3g8 QvZJqnTzU5h/jrzy0CCbLotXFiVUwbhTumxQ0TyWTBkjxUoX7sSYyBDe1uXSwk0vIDnH4KTr DbHM1AI9OvN+9TH4/xe7BuN6ud+uAS5ozKkpKGl3qHeIZVLSr543dm9ByX5Hht1QOalG/wZb Q7sCPJN25C0RJf2wWO1ja1gvLaWuUe4Qb1ehVvX96uN8GUm8QdfGeMlavV3PzYaM/qwho391 Yrib9twOlimo89Tbw1YvD9mnUW9+Hsasf72TRiEbgsHFzGTjMjDyBE705dJhRtsI+kAEFDNk rajejEk0ty93N0g54BGHGUv2jGBqSw088N6DuVWJMV0TXehpjOJ1YaKiy1uVf64w2bAMDNWk v+4WGJErShC9FC0PHkgpIrSGJO5uRsoXc4+OEGt+7rJ0/whwFw5IMQRzYZBrUNvgI1BHNlmr RY47J9K8ZO4k5LgwFK8jVWK6deLkXiA7vj0aZMePImR7+opbVxhAZqX5zW0vlo4Q7kuIaqnI D/cm0e1+91LPrnZteI9mAJiY0688Ehf3mSHpH2+sgjVf+0zHoN6IvKKrnjcf+rMmrZvP2Z8G u8X+biR3oOu+C+lD7PGX8fgc0lakJqQXkJqRGpH6mcDypSFsEaNIcUXs5+b++wylNdtbSxMf BWhPjJkGzprX+ygMq7+/rZY5ddvOvdppGlIz08zqXvPByU+3ff5inrSr4yc1Jp8T107ZqGFe OZ8hPP4nA9nJ8miQnfwzQvZCPwrZHQk8T++E6NxlaSyf7FcKx0S/VOUCrDLGl2fjCQe3GKr5 GF06KNrLUqp5Zyqv6O/vu47x6u19X1xjZDWDuWpYb6tqFfuzqYrUgFNUMn4buP+Acp2pAFQ+ b1ZxxrV3cbdAqUNvN7YM8jf7puk2a6BGamiTTzpf4H/GV3jEuq6wLU5XDmyV9QjzecmLBp+1 JpHG8TsK+djqwh2KHXHVyh2xawkOTdatf4PgkN3LtcWMRKt31ujOiOOjjEHrl3+scOg3E6NB 9s19CNmW/hSyKYb954e6aUUHgiA97F/nkyqo9YGQd40favpyvMK5w1wbW2WmClYpdwTLLedz OUNZMt9oRAjmJDsb63xz8arW5+wDBtod/QW+fv5bMPUqHPoHQt2h8incZQPYRlo6EUuLnLjs 2aH0i9K3O6VbpSBw/tzptbvQCo+WgsV9iTWKd/MU6Bdu+QesIYZqMNes1RnAWgN8FVeFC99q Q+2pQxkZj8pD9mNSNMh+pDc/N6RTyAq6S43V8OZ3C6sm1MzVtYLUy+aaIT66dSqq4TVofYVt +diI6kR1C7jZbXf4rWsIThSJOCSgeoQwdZcx/bnpUCXMvVyXlDqXWRsCw+ovRT9HUPkGn6pm A3m8bt0vSboEJrKml33UQuq8h8ipmkMko/YQ2b4mq1tZk1MzOQvsBSWkpt1xc9UI86Mou5Qp sq9F+253gKeZAJufgdZv3g8PPWSpFKG8QOK4J4A5STU3Hm+xkdrebrH//E00yM4rEDK0I+EW u4LYszQ+UothaFPTzjg/VTjGpwuKF/MVvqadUm977U7sXbQgiwOP7wg93bH/nEsKT0uu471w 4iApVLBdwEs360IPpg0Iz7IpZFtrx3FokMp9iYsaXIli3I4umlzLbYLvAgpfHP+oT2dT+D1Y g+fIPgdpWO0YtQJey0Q913rd3cEJ4RXScOSoai+9BfCpnz99MJcxpXdRHm/NaLR0c8162+LN RTV5Hbosech+ezMaZL/HI2RLieD+lX+4t/2v4mKXJRtySMP+o8TJ7h1d+XQp18KaeIuuhf/2 UHZGY1MXBfMl79aud11g2ATY52TFcj6TI8WJVU3WgWDOtuvtopyt9jTb/ES+yZxUZWDzrMrX kvssu1LbpZhOkmC49hbC1hSZC0l+pQhWVgJpGGujdY6qhBwrYT1i7PX6daP80MCcuC9xU1NL mbju3WeT8jTuYIfeb/T90ZVaRxomIshyUvr4pTslBaM1PoNbFrJhqiejQDZMdRYhm2eW4jIq arVvwBot9gZzQu1f3wbupm1if08nVcT5rubdDxwKR7Zd9Yh1KJMx3QxkR6UWrx9qszZgnP9q BcJD51cxlmfJheSKvuyOZZg6MCK1MWUZpsb6151l3BM86zImqMMz8YMuDDbSighp3hb0XvOI ZI2xZHvrXcmmZWASl3LUIrnlYKoms13d5CmYjCvZO9FCJxOrpSjfmuF0WJ13JictS3iAglyU /ykpssWUffAe9N+X1Wv0PyyuJBpkcasRsjszBCvDXlj3zfTcp8nBnJicNecbvlF4DpofYNrL qr85lDP7sQw1A3SYKM5BssEwhUBTtYqB5VqjZSZhBpeuOdwy6Vhp4mqYePSPs2c+MjIWQW+f sItrB976Un97q+P6tcnY9+Zk3rDIYchg4REVgetbmt6uEI7K/vtMaje8VEUfhG3kujk3BihE 474dc2NatMJVrPt64WowRn8x3E3qIa5PS3QVfDZnKE7iGxf3r35csuyRtn8xqC12qNKvM0PO FDM0rWa0YDXPIvlEM6Y4qarRmgfD5SFL0kSDLMmKkE3NpJBFDiYPV1jLrhkUfCCx2Zh0FMyQ Sf9nMgtbodVaN13LQ5ZfjfHTDKQs9GMGGmtNwCU60q3BzR0/+rmpeJ6CNBPJMBEss/DovkFN 7sTjH5CYfZC2Twmtk83UMtgM59uk+VvXoDIMa9W64FQw1QCm1TjArEN4EOwlNCitZmem3m4e gLOrk+qFoyI51q/Hhf8TyYxfuQKyQJGPIUkfM8OI3aHvUqYWqTUe0jw/SR6yftGi/2H9vkPI JmQJ7r9RT0A9vz/bqHA/iP+P8R88Yh34KFn20AOzpy5DO2ukFfbrVhpYokzdp1R7+G9KE6qB NCsEG6BlDmWU8gdzSklK16BgY7uN7bYEP1VSi0rqBMk626Dg9o6CGAyT0dvQteRqBQt/TYbz TDuYqsjbybHnx9gnNG8p5dqtzUoDELqyGIqDO2E+Bc2SAWQ+2gq132qvy5wB6u6gBZsZmN+/ qFGsa7iCAK3hSRd2CcFuUIY9H05OspBlvRUNsqyDCFlBNoVsY9efkpnzthTIoZ5icjbPbEW1 a77pU/lMyaGc7ZsO5ZxCyngcwUPavhmvkTKewuunMropiOuxfKpxNYjueXpWIYStAb0TkxRr BFaAlxOb44f+RVliBw32izZgECRRbmVwaD4odOL9+H+qX8qj5WI9DyIwJo8N/0+ONyaItRbZ IOTs2RA4Jt8f2gowqDEj5KlPbyDX1sV2FVBZspANWRYNsiHvIGRDcoTHuLEnGQ8EV4y+BcqI 3mjvmo/egndQGzzqtxkYUpTvNDsdCDBZmmIl03Kd2w6ZS3llt8ltQx5qJzXfSEAPxf6vNkxG C5qMnbDxFJiVigRmMIyxK1P2KUWriWwq+rR+7CXggvN+tCiLrUrQo0nQ46EgyCO7CVrXYK4N ekqidrfYIToc0eIHohZqwY5zURd5yEbdFg2yUW8hZCSXQiY2YEuptdmGaul86WgzpKr2DF3I UBikXn+v8/6k6sa+tMIPaOOTUYkx9oExVaBph37VMB9zlTgA+Lfn969u1PvL0c/tvAssLvRr tAa1wCXYSfuDyGFqt+H/V6CdUGD76z5T0NJaATZxcNGBtb6zJyAUqoEIFQXmiiMUmhHzxlQO nJ2kPQl00DJeaZAW5TMZOptzrxieb/kl3T/ENeTo07PlIRuXGw2ycZUImSmPQjbTfsW5e3H+ I6i4+vMrdJu0tIG5LgSifzWBOmvOk6SkJT9nTbbaZ82ZSejZGdvBMtEqh0wd6pdmO1qupEWc 8zL94pU45/X14yzazLn7BI+A64eJGGTEseEgQ+vnXIyHOzrTnoUc2KwWaak0lbx0V3gKeTVi 8+loXjgsHkKaeG5ZbA14/hbaICi4ztDHaOjnMxuqMBqcBsAPjWMMilp5yMZHe6Jk2ISBCBk3 kEK2Jkmf7HXsy51tuFDS7ojZkVnbEoyivM60ClyMkyT/CPrSCNzOiNdKXxL3GKuo/b6GXdX+ fkz8/iUBRSDAfnmLAUNXXEFKT4YM8XO+2zGt1hdX86j3YO52g7LWsPxgbrxh3y9f72Tc5nTW YHAT/P8O5MrUns5kd5bhWZwvVsjrL+QZ0q0mhZ++SyztiYS3Kj8ZGAlZms1ZBe6xNnHNuxbX o7G1eRV/ppF/7Zo+kDylahZt4c4hVfKQ3fBxNMimEITsogDZgRBAMbVNKDCfm0Zux0VyLvc4 O7Q2E/uG7lTcjgpgI3GVaPCQ/kWGO5KrGjN2DPTfPqDoifByXkcbizxDg4trqnZ4CZ7ko8vy TARV5DIIXFCj8PBkYixppotxWiIMTfgBu7zlaeVjl9RVNC/raEswPgaizg8vG+OjOywx+ml9 5xha+dwz2G38dVgDLq74RJ2BDHO0OmB3jBt2EX8iZyRDhGt5yKZviQbZ9G6EzD+IQqZDcSn+ RK2B5AnicNjsMvgHCec4rHbp/Enc3dAXzz5GNcYJ6dITRZ3OD9oy7Aa7ySMtgQ32zd6DZKBK b498pnAI4ZbnLRtb7nA18dKWdBquGp+vSTjbYjsXyKr/p3YTn1nfqS9s3ENvfGw6wxWuZjZ1 xDONutCGtPRwaSMJ31PgKiiYksymNmcV6/+gNu7HrIZftdP4zIZf4gobMxrOodychu+1zGqR Ux6yPyyOBtkf/oSQfT1YmDFDTyJvIRG3gZenlY0tv2PJRheccIaaucKm9x+wfRRQNiRhRK9o iNMzBuWT9MZaVeIHtd0/UgDeCxixd6ux4WRTorZKacTOWIlXzCYtZ1XCiQd6QMCHluxLh4Rh 7ocDLa9Clw1mGy7H6XqW9x7KnM3T1e5sloHVp+5mY8BcD/XcXhWZBor62fWcQ/VQ1VenuzHq 33YN5lrNYDbqMsGanWgsyjAy+ebirHUVZr88ZPfmRIPs3nUImXsIhWxE5vhMyCzMNK+FTGsm 0wiZt2R+vXD2ctZclDnn7akrlN7+c/c8cnVMIwyIaYO6U11MDEBygvHUU6/qpxn2xxU9Qb8F 8mtMW9XqU8cxz/rUlGxoKn1KZ2vomlfW4F99ah8t8RR9YBkMB8kgOEwGKcTHLvMr+2sT2XFH x5bOWPHM7Dnrln9f8tj3XCvPJjwBf9YaglvSq1focqDxbz89GDA/lf8ZtCc9FBOHju0vhX9R +M1/sf5FnV6UBE+p0tkk5ZuMW7mbwZWxIp01sbslp+NYsavzlmyW3LxCZ1se0MlvMQ57UBcN sgcnImSHhgprzMYdP7147rZA3zba1KRKdv5BnKIxOkpdrVTuVj75tLBv9fhPOpvkP3jv+p8m NvBEBSPqSt/Wm6tgRHNCXYfjIJkN9MUSXBXWP9QpqfvEQxWdExiw9MOZznEDWDg8jroROIwH LUsxACkum1d+LW1GY2lEHTpfuAaDUIOYY19/tFNnS/XchqDNK1+35I7AFT52c/+26aQIClvu 1W0S7lFBSxFxVvXtqkLdt/OoP5/dHZbN+eQhK3dHg2yJEiFzDhMWTIJiteaHI9RK9K8r93SG K4nxiVz83hHN0h2eQxvEYWVDN512yZM321sjN7PDvkuc+KdcJ+2eFlzHLRO5tizmlod9VsyP qS7Cp7r0WowKvqWDXtnFnz6YbTaYz06sASd4dKfa3w7fgUr2gft3j72dueShdobY3xPrcRaP C+rsGC4GLvKQrWiJBtmKYwjZ6/kUMurDLBjvmP7CELpVKDZISb7W8+jIixTUbhTkhU9MR03Z 1kTwbCkhzebmjGaRS2ngvaeEdwlHvSIGF0rCx4qq7nmTO6bbJZ6734zZxdVrd4XfDnh4Hlis 94U3ooeQF1oXJhuWVbcuPK4w8AR2i82cVWDNqh/REgR83tn1tpYyRegJ7DgTb5n9D0U/1sKZ YLiyn9ICDSY7dz/dzUjlMDJymz2PtytCYK70r69osclDVl0ZDbLqTxGyZkt4v+ydfbVoxBnV h8hsPr9bepLG8amo6IUfNpAPNsLulK5wDhu89b/HPcmlK8sKNWK88FwYfwLcU/0YlniaIxT+ uXMtZwRpFzblbEtZVbsob8YHI33QoAnK7HeMNDT5RhyBdXRvAl4Ej9qdVy7alYLkHRK7Zopx HZnCQLCM9TQ0GDwm+wXs0kG2+ODtHloL41EGa3l9P+OGE8pe3P+64miQratGyLYOFx7Jc/Mn BvjEZrBk6w2NeG5oNxEGrr3f+opUrVjlnH0xfnAnYNyuZBWXDAM6nFts0mMANKbKuh8sJUaw UGuaejNw/XDwrjeGraoArQpOlrgKPSXHFHUQtEbfEfqdmANlIRjqpacyFvwC9ZI2B8q5Mp37 QAhCnDVDYD/uk/jsP4vQ9jOJx1mpEtTykD3GRYPssX4IWeMICpkWw4Zh6AnCEFjbYC29dWU2 zOm6xqWoc7ZUt4pNEodJw4gDEcPkwGXD5JJBEmrk+gh74k8WYLMiLKq+yZftstbpM4rA2vxf tKh6Q3vqUZP96RJrS0IvFiXWTs1APM7YIHWuPGRPR90ve/qfCNnqkeG3qxvbD4RspJlIFkIt g1rI+qC1SBZiIm/b8pa1l6ct0eWCWZdlNesyePPT2udBl+k0f55sXKYwHibMt2dXPVCh8BdV vPLI4dPzQAcv2lpC71P/7BuRa81UElB+xTGrDx81LdxSwhqrSWbjZ9pqnuXFmjjzB3q2kZZj gjttn+xJjZ1KUmONhD+NMdqTN31xKJt9XNlF36x4Kr56M/OtMf75pLOr1sR/8FMgcD4gRZ0l EasJeci2vRsNsm0/IWT2URQyE3nGllbWsW+s2Pxssfm+5TedmJLDY+BY2oRzFvrRG6HZBY24 EmCbXfGGJyHO8DjExFRnr6hoR1h+055sYrOrkthMZ2YiNx7YbN6kt7cs4yrUfsil52eWccvX 2Q6EIHsWIeMRMqtyJFeopDlhUJLjppK+cQgKXfBTUHLYx1VdVlyg5xNNVox+nykuHqNJ50aO bdLZpHsFJSQcBr+Fs3bAow3a/9QBq9xatP5HnTeL+yGykLWsjgbZi/QO04LR4oz5cqYaXSJ9 aCA5bnqiNDdt3dPJTePFZ08xgG76hDWDjkAunJyfnLDMmnFrdoxfF3qMjjaU9vPhb15Da9Jd AgAkgPkGXPddxw1g7zp2cxLf2N/XQt/UV0sAdu/Zy7n4y9PWi1wxYZiLffDlH/WfbXpt8euP QLY1U8rhXq3E8te5wmWf8F2aX4WzP6M8aK5SHMwoBXnIXl0aDbJXTyJkJWMoZGKIgA3+9twq d6c32WijG87V5g+4oDd5lTY5G61LZ5tlbs2TUkWuaojk+sbRRszVg7vhhEmAU2oqH1S4EBU2 g1TjgYrDp28937rw8Mpj8VMbf4q7pfHT01ecjyx3zjdwYX6lzvZFp3Q3AF6ZnGUlKr81awah T3dPyeKbxjE6+CnG0BTm+YobWcMthxPJfq/dOQcsCyaKAY0T6du5wlviMpDttUSDbG8TQjbj CnHGXOuDrMKRQ9ZClnVkzd4hzdTeDp+uRWsZZKNfJwv7Hy6Ck0fOWWZnXjhXG5H7KObS0tUg n78a8+FknD9hkcm+PeThuFcr0FqotX4ff2QTuP/SSTti28lrT1CH0GDkm+qNVU2GsoM5D6Zn x580KrMfTVz8kDVLOVJnO1NmaqcPeE3OscLkXICO37nl2frEJDkeecic30eDrJVaWXEBhUyq ggtwy/fqR2x+95F7Op89pivTtVuznSbRFzgGxPro1XpMlWZHbYyRCC+lud9ySuuAcFg61gZf nll2piJteR+/NL/+sKvuKA1eRtv7Vm4ple5jXXhDCJkzKVA3xn9mPBCa/WgseP6nAzYptK72 0qjxh5/tR0YsGlU5cDZzIlk7DZ7npvJLXWFpX3TS8dLeqTqLKwcyH2LPo2M5uyCCQ9WL+//k 7WiQHaA35cZdKd4t19sv31QpIFIjAyfGc1aFPTn+vNhYnce0cl56UeIB2xKvyEvf2ZrvbSmL dLXl6awB3CvTcW2Qzhp6vmKUR+YkG8/f7Blk40l1nCRndnLc+TgP9V8fxEtpVjOfEfCoQ7JF 73apY7/D1q8/2yh6QlPoLSx6vS9ed8n1eEYXxf27no4Gmes3hMwyVnL/cELxJX1F0ZRdmJiU bTWYzPFkXjprosDoPJHQ6CKgKU+vNoWBKX2fOf2uvqLxlUfC7+d17LckK843JPJ8fWIVP1Kr AGPb5Cy+HE40E17x9r2Oe5caeL5/QjX/Til1BxPs8LJ27UcObYs47dDH353oewYifYY+6TM8 LsWgx2RPLTW5vKvoA8t0kTe/jit/9KsX6w5mFir0Xexjfbkvoer0ocxSXt1VjcdtvKpb64rd zvnnoRPolH+Hf5j7gWiQuf0IWdZVFLLY7S22eWXnAnHbw+u/T6YAt+cOIP+wwRtEa+hSn+9P 3zp5A7R6P02zaoV3Ut4o0Wq6Y7TPaQJ7XeZtGkgpgcgHQT89xtXofHDyQBkbfLD4ztmf7FBj GuMJp4BbvePDY1Cz2gBqrU8MQ7eMghrwrE6ZBZEW+o6r5zcD3mwjVVlr+Y6DpBQ+IxkgvsvP eF5DQElz2Kp3Cc9RAtn1jz3ia08ykHmviAaZl77snDJOGJgRCiRhKNDcluf4uwO24Wrslc7A DD/ZuIN6jOOFeQwLtX/fG6MFIDu/D0zyb8WQ9TkMOAAD0GePxX1HdooNXjAV0gD9HOyAVJbo Qw8aQwJDMux6biTAjo9tAU0gADuuj1fgIvmT4DvtF2aOtYl3IVWEax8U2tugjb0cLEHLnQcC WM8r4V1iESJCuOVLEODqb+l3dggzkL5TqGTc1d/uQ/ei8MhD5ov6gIHvGoQs9mohlK18wNWH 3AJKnJt4L9+1iL6BkYiKev3kU8UBm6QiVzGAu0d5c3ZrnwM2PhCZ/gt392rT4j7220mVchYq yhNWhwsjkKQ4FYZQQ5XkvY0XMDAea7uqi5gYkmUCcmTvEQdbqZ3P4fWIvQf3FpRIkX/hwNas A3unc4WQH3cymcp77l0q8TDqxX3bUnZ34ExID9SCP2NjPbcHxrw7PbvVoN6rs9XsnRnQhTj+ yd1Txbg5/9RsecjOHYgGmf9m+mm9ayhkVX3+uveZvQdsN2F/qX24wksrIsq0CUR6Cjv8lGA2 wvGyIQ6s2fF9DKdbIlQ5ueZnVCcSxi4H8+XBXLNB0/XauwfQf1wReOxdxv1cgHU/G6jCmaxK 8UlsR4BGatJTa53OGFdim46HbaJtzas04lo3UXhaF1rEtK8zrlMdDnjt9As89IMbDqSzSD8g eZG+RvIhvYNEcLE3EEnhIjxT1eLwrmK20TLU98lD9ktzNMguJNBP6wmQpR7Lq6fPHW7nTd1M jbXGrGOgqoPxOCu1e1Vu3syBCETTEnBzu5gd8Ueg+lXHzRiaku2xbWRtw5lGx2OOJxywXefK MwAXh4Oba4MqHge35B2p+p/EgqU1Vggjn3TFRu5o5Ae7Ypgrg2/lrdmQtHGvWOe4ozfntCZi Sp+8cjHFelTybmYsZW7LrKJDD9o37k3xkiBH5GvhaehP1/lSBdvXqkUZU0/IQxawR4MsQL9G 6LtWmDFr1vpYt7jFAiR2lHqH8TipXW0EtcpHvzmz0adwQyjXWmslTOzqtBT4W9osYHeE3TPt cSVCI1lAp3NmG7Togw7deaJBPOMWXJvGgeCmxeuXr/2185+dXvsNwncxbnCJ5F1lbpa+jEqu oZbxfCtXQZ/6nuDq06j0TRDf1vTg/FuWV95MrCz9mJpdOdOe05yxhzl1BcoY5xIhaq5+wpOy l34YpuDIiw76URhZyPI190SBLF/zLP20npVCdoWr4DOrs8DlTVbaCoWjyuZNVtuKnN5kjY2+ 5ic22p6pOTtQ+DILuNmu8Pe1IHg2Rfm8U7KqQUKDBrUZUM06xwbHJocBFaVXe4Qz8SNEHfvJ MagPgspduCo+KOnCrdLZkJlA70CGZvIkQeLLogyEeTZa6+1Is5BKYsVPZtHB+AUHxKcEYikE 7pAK/Soem/FYh8cfVL3clMvXR3P/+Xr6domrUPhQkBpICtK94qB5QrpB9kPhJfchl6WVF/3D ZE/KYQ19cusNzyXxhrFl88pqfOmbY7g/Qaw7xx/HnWR8jjR3RteMbGvf8EeptvZXmjAlbVAZ F/5QlXvgRj3GZjGV6q6hR8i6bDu8qPIncAQO2KRXUC+5X7ks45i2nn740ZRTlUhLancl5VgN fR5J37ytdf3yq7kvWWndMGvV1iTWeMY2I7swbUb2+PQZ2RP6B3OehtYDNkW7PGR9ou2X5SfT N+U+LArvlw15UmdL8G9wpL9xxqYLbuRdDFYgcajczwn3wKXNli0kJRksg7BXJZhN48MwW8ga r4EZBNxy73FTbmtiUi42MCfOcM1ms/Y5gFqf4yDZpzhozmAOZhQJd6botmCCn4bU/bX3QN+G VD1jOGNTevLKpU3DvhhenwkC82FTwD0Z9UnfrPLsRL1b6EpCGY71ebJPpQqF4embrblM4vMO pRj7y0KWHu3lwvwB1Moc4ylk8wLpb0Ctge6x79zrGvCGtb/SUISUvnmHAKCo4Ndb0ze/hNcg wJa++eWIvFFbXz4Cbj0GE2Rdgl1ZSV68ZrNS+Jph4Llr3shpUFbm7M7F/3N35+H/ebsHNmTZ tbvDb74FP+84IfKLPU8Lnx7mvafYDIATjx1XN5h9CX74Ut2gz705MWYVtTeuyxQcwHeOrvPR 1UNHHC7mT8T5W2x9PInBrt5qUzfoKr6xq3eHueUhy4n2NcL8XArZyxMoZNXedWwMbDgLtfQN Igi+Kasgcx7iKuiHhgc3bNbipPTlQL8p9wO0lVa0lSLDNY+tt01KYJlpZms149lnLgRemGXF sga0zzM2CNlnbMPgBlwMK2N3q82McvDuQRV06Zyv/8xIn8LVE1dmjBlW0+cNf/5J2xBDYHXn z+EGruce5wM4BbEheZtRL33DJo7qlYt67UO9qlCv8QZropJZbytKVDHFiWpmRMPkJ1c9LpZq 2hLWSR6yYSuiQZafSD+tN5FCRlUwNAyiT/sqDbv1DWo86nf3aBKRmjSwgTYvskkbezTpzbOa hlE+CH4JofQyOb8EZfz0synXiY1lsLHTDOOMYGY82Y5bSAJI9ut9StMwPSOOUJ00u9/SpTeN MzJmbcOje8elTiBUY+3uZ84WN6R8J37oR28fyH3GwJf6XL3h+xX/xHq+r/z55+BYQL/LNXxj 53Yz8kFG/pjro0E25gz9tN4kCtlbZ1OSDTYw8GQkNjLWT/0TLmWA+qhcI1hoo2+gjTbjTINc egyGYoh1dbdgD9bV/p8lTzVyXqorr8TnC36Qi1tQpMuGRu9PtJSaWJWQwpI/njXSd9d94sf0 Dq/Mjf/MSB06deUj52mx/M8+yY13/3Gxjznxz86W0FY1Xeq/ifrlGenn+iAdbMBZboR06xLg htyoPUKqH1yr7PCbPwBz9fOP6rUTFOAxbyfPm5/Pt9Ml/hBs0+QM4eMaMpBdE+3T6PnX/JF+ Wu86Yb8s0xncnrEPnpxhNUzO5I3hazD2zLcGr+cM7th/2IYrukkYX39Oz7Im5aV6wcqvyzYm HLbxQKwlaSWKeWkEDtuyALIW4BlJ88Icdz88U7pT8H9w59FIyb3JUZVaAOKr+4fLqCxS1S8Y kEjXKZddK6VrQQvgwZMnbA1I14x0LfBbq4oTGI40TUmQh2zi0WiQTXqYfh+vWNiV5byrsprF OImrEBsO/FSM44XZhUeD26GoryW/6Yvyfq+K74Lg9yow5tkl3QieWqj2H7btOnnuPdghRVFS swqMVE1FHZXgXXWd49J67vxvq2fCZfVINVwKG6kivYayN0b7pGD+TXfQ7+NdL71bfmmvSJWx HqVQGeYvhT8BKB0m+zMl9NObOXaSRvs3Mj1PSM+TTVdV5qWJatN09FrcBsc4VN0qnFkFWwnn 1TsaQrm7HLul/AiZFqEuS4+6LEJdFrGuiPQhAv+QCH45yG4tiwbZTOr+50wWNn8ixKoqh4Sa NkRIt5jpDzvQaoYE+SAtCKONVm1AK5Gaa+jRtAJB1YIeTRslpI+STVdVjurR5AIhvSCkW9Zl ukV2p6qSyPOFumQikYfsrgnRILubfvNn1g0UMisj9Sgv9Cc9296j51eH+v2FHnkvCHmij5HS akP8O3vw75Thb3BsDJXY7XglwrLI5V0VAdEUAfopPaCfIkA3RYRuCa59gSRWw7XrVb709QUl s0rkIZsb7Yns/Lnv0g/WTRG+YOCfVepdlYFjH94BIGg1G8jEKu+qxSQG6Oe2P8yFKnpDo0r4 rSpdl7kqjpuIg5d+c5U+9EmbAR5uKZ9lMJAX1pkNwZ3UlzO99k8c8UT4/j07tewgqUXnfpBM hPDfhnuALEB6GCkLSYlkQroTaRRS8T3CevD/xp8MZAt+D0E2LUgRkC1sbrh4k5V+3rX4/64a tr+F1Oj5A175ZXfSH/ACsAo/4NWLiKXvRRNRsfTf/wZYvv2xaCIqDSiCox/BVgq/xSEr4uHw V7djgxQh4uF/NFzUCg1RiA2RkcCHX8SbHqQICfzZ/ItTQ0gOHc4Eftf//nngoTWM9V9pRKdR cyqNRoNHpVr3gvaQV6cExhlj4rAx6eCImZP6ySvNpS6NEmLuqK1Vjv/Lw2yvfbJ6qh4L51NN lEGKyK3LDLCp9Krnb7Xl15UYL7K9id2QEvqttlVBiii6YWHJxYcZhgk0fNl+E0196f0PD3z6 mfvEqW9/6KTvrvzwo7+r+/yFf138HVilmtMpHDEwhBlhSsNxDI30K2rCJ+YU4StUToEdpvuv HeSVbgRUuuRiL+1tLKLtZeWL7vs8XsmK7e35w3j5H/yxtx/Gy/8YLv1hvEHylX/c0fsP4+Uf PBQCOyZIEUX/lnvLRW5NbMicZAR8+hwKuKW3hh++PkpHH6kL1S3T8M+StcKtImmURBQ8bovX MZjLffnahTsfli/+D3Nvv0Ro0d4Q5ZcILdr1CqHe+CBFFIwriY9lMFcaUvIC4pxMbwKM8SgA c9UQr2bDuZcJME7ureUW0+l/23JL0p0qobjkoSKKp3waH8Ng7m+KEpWAilz5FHemgI02SBHl +70Ur2Fp7oBeyvZ7yySU/T1IEWWH7I6/yGAu/ZTkwsWLF5FbF82nv3NZuoCEvy5ZvHjJUjJ+ 8aKl5YsXLBA/1fsf9CcD2JDvswXApN/ajADMsipezWBuSS9FLV8XCEU1QYooOsoWr2Iwl5Uv Ocp9pVBSF6SIkgW3xnMs5jIj1z8HYb8eUbjgCVVsL97EMi4TR7RKkN3TGVjGPdsnloVH5Ita 6acy+vQ2KK2lLKEXMjY5vjtew2Bu3xAIl5WdcJdCKCszHq97nQ5oIv0mai+VF/ft15uAG/6I AjA3EAgM6F3AlFhWGJGTghQhYPrS+AkM5gYCvyo+DZwLBK4N/Oknve/3a3/ZGOiHTKW/BIK/ jfdv/7qDFFHx9Au3xHb+10r/Z/3JGNgfBtCJSjAwGav+w/iJsYz8BG25Jw/ni4m9meY9j8/q bRjO/hmHIebq5Ou8d6TSwAhfgw9SRNH7vomPZ5SGSMuUm6Et9/+ZieXQeAKaC+9fLa/+A/QF QeaSAR8h4MHr42I1ongGZF3CojfiOSYuVhjNIDuwFw/Xc6ymF9zL6evpeq4X9MoDfXtzRcse QVdEc7mEXgovj7ujN+hXLELoxVy5kivemNRbyZW3xatYMVcO8JW7GMJJY12+xdWFFHDSS9XV OzWkl6prs1FpzNXKl6x9St9byXXxWBJziXzJdSMNpBdl679DZcVcGetomJgQaR0ys9QmF85S CcEQsecvRlseGyLGKmxk/caI/FE0R9lrLnN5riEi9yOpLGMW6ZKybaygNuaLKmDIFQgw9Jc7 aQDzPzgOifzrE6QIWA/lU+CMctxSSBoB86GxIsw0SRgXUtwZKfF2yjMqQpDk8iIF3SMKimQL 2XqksNWUL0YwSKmuSDFrRDE4bp2iDMmuI5nqxF/idfZeywusILu3WnaItWCyk+21lp3BWthe a3mfZg3ttZZWsZahWIuu11r2BWsROZKDFFnL51RMPsj9ydV6Qqw1H6LJ/JkVEn4d9cd7eMBB RfNSRJlyVhIQZVKuAb2I/Lu5p0imd5F/z7xMpIyH+LvwYXU6MQoljZdJCH5Y/Wpxl2HAAFUv 3fT3mZRRBZIzumwi//tLM2MZ+Z92trjGo3+d2VtI7Fq0MLa3tbnlKP1FkoVC0cwgRRQ9ejVH iILVaWW7NfwnI9htRMH0d71kBbvNWkLiYrmwg/wvC/48gIK1JDI3QvAX+Vmxil7LfvkVRllZ l6w8I7rKK/x0QHAqkmdgIhh+DVJE7d6BibEX/gc7fRnIv6UfjksUIJdZPHz7PV08DNX+P8GM 1elUCkiRRu3/P/9kkDpXG1o8yDjMc92iH8HB3dqrmz73u+ghRA5GJ1Kkl/kljorRw5JFi5fP Ll2wYMT/K639/+yfzBj+ZSSO4f/B8NCN/amX/FCL5V8vXfJDLRMXzbEtnr9oKSmfe//8JUvn ls+dM5Ysmbtoztzyq8cOH3blaGIrXTrv6vwb586ZXyox5xeOmDB1+vxFD+YvmX0vlXwLpcvq OfLfVc/iivJ750o1yYy1X6+SvFJokEQMo1+niguR/8FWEPkn47d/nUv9tk4bQug/win/F/56 2tJwRa7kt5k4kSJsabiiSPTbevhfcxL/pAV8eFYarniaghQPwg5Sz6huuGInRnW97QgPV3dG ieqGq38TozqxuCwDE8HQcxEwXKMWuzAegjw91xXDNaN7rivig8vbnuNnuOaanuNHI4yfeNk1 8X/Mn0z3xR8NxT0y4Mf/K7QC6xV8fUFP8GN7B18/qSf42iD4sf/J8MuA3+eJaOD32fvvwU+e 0BP8hN7BT769J/gxIfAT/nPhlwE/vSYa+Okv/HvwBwzqCT7XO/gD7u0JflwE+Nx/Kvwy4OeM igZ+TvFl4PfccRyeI3RQbkQ1Pddtw3NepMWTIph6bksOz9kt1hYpK3QrMLJGH+UbCacey35q 11Zhq0jiipTWTTPSIrnk6vxFrHMkSIwgt/E0PDcxTbxrJaNPboGoz7L6qvv6Qm/65F4r6hPB JaNP7g0hfYKMvdTZINZ55bv6w0tJr3U+JtYZwSVX5xOhOoOM+HdVkCLrPEL5EiguQd2UUx79 83M3/q1iD7z/xiuzNsQ8LwlQfv/mv45kDbjFtj77dlIciL2PCpGJOnL/IVYt3HeSi4nyDJQh UbQFGQF5iaKAxF4F3EgZLL0LmCkKsPQqYAtlGN27gK2iAJFDxjvlfSGzfys2WG7M5X112ZiT 6f2BeZQnDzviwf6T2DEqec0GDhEl5fXWtIFLIwJOGVUGVl4a8slspQwfuPd/t1LCf3Jrn4Hv /+/a59K/QUGKMKNBgnOdhBbNvM/8+uxNP70zxr305ysLC+ZNYXc8/fbXHQ/vTMlo0Mx83XcP tUQZax+kEWGeJCT1vLUwfNCt4hJI/vbB8GF6XD+l9bJFO3zYIzLRskEaf//B0YPMZD6sTkQa 8f2gt03Y4cMeF3EOckgdFtEf+RrxKRDxwQuZHhn9WSg2kbozokfGJI+NVQYfnpIpfOVfsTvH 9vIQyvAr/4bTufwDpsOvfj5kCDKNvzp4rxsL/a3Xxl99XGz833q7qTd8WmXPSSHGKOops/Sf 9pyw9Jf/yP7wW3OiLf1vvUJa+it7Y2AiGGSM/1aZdXrY+PWXGH/Mf5L5y2B95+loAfNd6RGT N0VTpuvv2tyz63VGuOQx9gjw79oldH2svDolbdG6vlQldX1sbwxMBINM15fmRut642Vdr/vP 6XwZrOc5o3X9vO8iup7m9ZyCniX7KI+2l4cQniWfiiKwkz7vzbc8Sw6LviXIIVeL8MBACsgP 92dJcMkjblJL64Fwn3/31pMqZZwY4accEnnl8Pjhwa/oWwkqOaf0TyCxzwaUOcBENjUi1zBR EYOCxVqEGeDye/aU6aO+ShYi5/sICaY7iCZcXCodwZAypa8C1ZPXru/vVPe+SnntqrpjqHaB wMbfP3//9jXQc2AiU7W1n1IBsk8jYG7NOVpBP1rB5S8UYO7TKZk0UmSY4F16gJ7vuVC26alK ndhIMTW0GFBGMP2BBuV0HtUx4qsPcvpsDVB9UpUgaCxoHc41627XBIKLuhtvvnHiTTNuvZHc OIIUTiyaAf9z/rKDJA0WCkyD+AhUeDGOSzejVgYk2cLMf7Hw5Q9lYuH9RxM4CBv45Y8iIseJ kkR030JXgilIqlB2BvMDmA3opRiIYTjBLhyiDj1tKIPVhGyIZcU6elaYQSzhCpOCFFHhjFfA bAT6JG0MGyuUWxYEVpIVwXwHA0bJ+CUfFKHQHRPpqpSjbxAp0G7B2otKla9HxYD/WcJAoeDA qrKKryTJ8ta8fzlv8K9vkCLUq2kHhn5AiwGlUo+8mHnJ00Ey4teFxCuxO6hwhhU2HaTnAiPE r68AJoEuzEGF3WIVpAS5ZTDYejGMgUx202fh7IQgRei1fTWY44G+kKdSqiHU6H5BitDq+Qn0 ITET6kN9i360ItXIBQKjVWi49BsHspW/UxauvCBIEZXvzwfzKLBgtbTcYMgZAzPHwHQtCAop cKYcrcVaUo3DUxPwSjk6FmulXTgS2dODFKHiR0uBSUM0qYpoYJeqKJaSUfJLPqqS3zaElWSo kqNVqaDgUB/1aK127iItPKClk7Z2NDdajRVqGRavs1nBm8so6QuElWR7KklL9Q9ShBaBn8Cc ikOOasHicInTFM8tnbNk7lKtgs3rZQbNZDYbgzNoz2ZnssPCze45Y2SqR9MZw0gVv/xpZMzV JSarQ34tNUgRNetyYpR9RIYem4Q9X7jCAvGD4nVMjDLsLHtO6ZnFtWrFpeFIRI3Ff03sfT7O nGKjrUmUD1YyD6zigjOjHIoH/saZeotDMv++NF7DcDjYGcmNXerKMv/+YciVYaykgEL5oZJ5 4sForizz9LKQe1JxUKUq7N2VZX4343Le4N+AIEWo990TGAfhGgX9kjoReamn+U3x79xZ5jkI uTOWE9rEsG/SKKenO8s8Vx5yZ6xOqCLE3ROHLLg5mjvLUt4QzpbqCuuVpXkIzMG61DoRa6FB EUYX1iyLqwd0xkrUSXEt0y+CJ0LigK/BTHkKQbGE+YdsC7PIO2ILUc65pEeNar8GLihAY5Nv Qmb0FhbtitrC27vFFqIBnEuqMqq9GliKdv+ifAvv2CW1sO+1zGfyFT5SFK5QBoCanyUA+i4R Hm3paeRZtW7RyCkA2q9UfettEXwRstYdATPlo8oLfC/Ky1u/IkJex2XyIvgaO0ODS6NEH1QE 8vU+7Y+otyNYrxRxR8h7phQYLRZEuAKM+XF5vLaWRu2/pklRs18YFjX7ZRLNDWS9dltoaGs4 2KcqktyA1JgIXuezYKaNKYTUAMNcD+EgNcyUPaQEzGacbJDp3MjCGYNnFU6dcvXwkVeOHmqx WGYPHT58uGXIyLhbZbXJ7si7XJvgX8+YKbvjnlDMxOmR9/KYKSVIEeK/UYHZJESUSkWs0LcM u0rBskK40XMYZn+TEnI0Cp1QhVji/7R35eFRFdn+3NtLerndnQ6LgCwdJAtLSEJIIEFGkYAM CiIqpBmVhKSBICSYBT4Y0SCK+ITBZRwXxHEdUXkCLviUYREZhAeP1Yd+Rp/oAA4EVERGRxj6 1d36VufWLeYbuf/gud9XH6Tr1PlVnarfOaeqbjrMNZFxbJu6JogBnXKO6XBTg6S0tii+XRmk 0wNDVTmLQbZIiUF6Q4pk8iDNE57x7Qjeesj4sZ1R3Ukr1CD+sQTS25OcjgzZE1SXPxnyM6Jm JH1jQXXxp5dBkBOPzS6LxCDjTIy3BDPOjU24fpdsD04mm3FufmJGSH6jWs4yk82IX89LVTMd xYlU1etWgC1smulv4tk0MzTFqNZ3QxRO+GaydyMpwlUgCpLH6WFaPrP9BtXyQ5V9U0BO43wQ KSRpoTLj6VoxjJGZ8RgIXYiTcrjlRLItSf1ChYFE3hjwqqcBZitmZt6rWnGzK5UsQQFSiB3T 24nylaN5XWcOPKmva7fbqa9Xs+/MLI7ovjPFkGNYqyTENeav7jCq9eVG9ebalyFdXm5XQZqD rWDU94YC/fcAqW6O+S8QUoj8ZlfE7WRriEW5XVj4kN6F7hamuG9sIoz45DCirC3z0s/888GE v/ORpe8eqntfRqc2XsdjUeZ7G1ur0h6zV8l8b3/Cq/hDRPb8rjNz64KE60yRNJJyXGfm1jcS RE3xKRAJ18lY+/97c8Lr+IMaEymvw5jFA730WcxLcbIn4cDixCRITpKRlloY9sBqw7DmbWrm gT3GNtWhbFMFOM82NSsc5S3xrHaXc6u7SNzqyN95CyEre2RiIUgeuMddqq8p80rO6vOavpL7 ySAj5UK9PU4kciqT3h7Pra2bkiv/PDd3amV1Xm5VbNbEvLyJ+VdNLCqaODB/4sDSiQOKcutj M/NzJ1fllUQmV2X3z+sZqSNbyzmyTvN2OGvQO8Z22KHs2YU3imCktmcX5T17uHOXT4/0Or6m 9Kb5N6QM3Tb3+B+9xJU+CKztcNblvY3tsFPZDlPzpbZiWO3KFa2tpj1m+mRd+U6CPoEQkW1N H3MIyBr2oRoCBPB5xOR9FqV42Fk9M/B7tCO25F9ApFbBNUe5i+S6DbwziKwbexhGd8pG149C 1LMIsdVZhAAZntEVjQ2iMI1t9BtXG0Z3mY0+jd3J8Yt5O5OsaJvE3ivgU+mreAXyT6ZWKOlb yD6mO+mXnCp1UqR1D+L0OlzK7cbakEsB049DqAHcGgBBPg6Rc4GwMqeyHtDbsftfOYdr5OkP GkZ2yUaunt5YXwQDtaXtlJc2ifJ++SAqlYRs+dCnY6FbFErZRp7RzTCy22zkUnYna34yOml2 7Fm3T084dp+UZDZgOfas25clHLvPpxgqMSkMEzS1N0zglk3QETqSvCQpSfE6wsQSRTBIs4tL JndX9mDuns9d9QupMw+GARcNMwyYYjZgV/aIF41TR0zGGg4KIwA6lsm/30pgHePUQkv//jCk j3WMdgx1N5WD/ggpT60vnJf4cfas5poTa5vXrW2ePWPtZ5+R/81Y+/WJtZ81z3ibfPB184x1 62a8Pat5BvmAyNSQD4jMv9UIYRH24oBlE375p1x/8OJrXAe9xml4pxTZOwmyTwp2DIdol3wJ +Rcu8QpO3WuJ8CPbv6yJGf7FY/IvSitGJ9+K8nbkWdvHqLlxKaSGgw7F/eQTAf37ZfQ3Qqhu bCf7wjYgZyZp4WBIbyFaGWnnTm6A2JWrBohSEMNBSXd/DofyXqLeXwp91xwQ5P7e407qb0Dr L2Ma9qcZ0+CRpyEc9AouPSzo4dKthUtJnxsR9rGnYf8oYxq85mnYxzbDx3dzl9LBq7nVh/ok qllR4dAQKioQIUcTYFRAWIT9+VFBd4CUQ/m2CtJlB1gKSQ4wkMPkbrajjhclsh1fGe7Jq0QJ VlAwfJZYBFGvfOG3kumesp1DDPfkM7unlexedB5v9MIn90L2iSmyTyTYXZOus9U9nFPZw4mw kN2LzpuNXvjNvVjINlXXAzw3l13wHuXmRLU1ujmERdif7eYYLqF/s+ES/LJLML880tUruOXT m9CIipqq+pzhdbFYRIRytksoLDBcgmR2CeVsl1B0PS8xyr6pkVsdnc71veWrjCFK8hAba6ob FC87yHivx2N6r0eEEvYQK/oaQwyYh1jCdmsLOlBujXTe14RuDWER1pY9ffY947kuYfFzhksI KK/P0VmPy+otOlE5bGe4hCVhwyUEzS6hLbuTzz/GdWsv/dao7qEVagyv7Yb0CHRWxhAk2Wtb 7R0/0zt45vuo7M3fGPdRIeU+Ki3pPorlwPZNoByYU72dQAeGsAhrhwM7AlwHdqqv4cBC6kvK pUUwREtmQD3mSgOydZMvR0TBC3d7RZH8mM52YKcWGg4sVXFgabQDS2d38vQyo5P5WjE62dP/ OKTnQE+lk6nEfaXDNV7R4RWCXtGZLXhF4meFZFfL9oQ9AxJvx9gzfR3lmQh+uAk9E8IirC2e qefVr3DJeHtfioxu7QtWkIwIi7A2kPHRrVwybvqBIiNp2gEjI8IirE1k/Os/eGTsFWqmyOhR 9+RIRoRFWBvI2KtfgEvG8hBFRrJt7oaREWER1iYyLj3GJeNrn1Bk9Kl/kwTJiLAIawcZ/68z l4z/jFNk9ANkYmREWIS1h4y9+7ThkbH36EUUGSX1K0qRjAiLsHaQce4DXDIup682AgA5GBkR FmFtIuO2FVwynvgDRcag+u4BkhFhEdYGMvZpP4tHxj6DDlJkDAH0x8iIsAhrExmruPeMfR4Y S5ExVX11EMmIsAhrBxnfKOSS8RP6aiMMMAgjI8IirD1kzBGu5JExp+djFBnTAK7AyIiwCGsT Ga8bxyXjnK0UGdsAXIWREWER1iYyruS+KJ6z7WWKjG1B/YuFSEaERVgbyPjVkzwy9u0gUWRs B/BrjIwIi7AXgIwstk0VKLa1BxiFoQ9hEdae0Nd3wTe87zzpu8zHjYxvRymuXgIwBiMjwiKs TVw9OZNHxlz3DIqMHQCUP8uKZERYhL3wZMwd8B6XjDctpcjYEWA8RkaERVibyDi3N5eML9C/ 6d8J4DcYGREWYW0i4/7jXDJ+P48i46UAt2JkRFiEtYeMeT0n88iYN/Q4RcbOAJMwMiIswtpE xgX3cMn48F6KjF0AYhgZERZhbSLjXz7lkvHL5ygydgWoxsiIsAhrDxnzpRIeGfPzD1Fk7AYw HSMjwiKsTWScdBeXjPNXUWSMAMzEyIiwCGsTGVfUc8m4h/5CqnSAeoyMCIuwNpHx3BoeGft1 o682upPuYmREWIS1h4z9yhq5ZKxdTJHxMoC5GBkRFmFtIuOTq7lk3LCcImMPgDsxMiIswtpE xu938chYEOxGkTEDYD5GRoRFWHvIWFD0PpeMN39GkTET4F6MjAiLsDaR8YVMLhlX3kuRMQtg EUZGhEVYm8i4vwOXjGfzKDJmAyzGyIiwCGsPGfv3Mb7EWP5NfqW4jOqrFkB6GwhBKaSFg4ER AB3L8gHEwJVEoJNWDO72H/o8CO0hDe5xR8JBhy7uCqhjZbC9/zXlFNt7AixtQrYjLMLaw/Yp W7hsb3DrbO8eDoaS2c7Qdhf3iwn6L8ugqN0L4BFAaiMswtpD7b1VXDIeK6XI2BvgD01IRoRF 2J9PRgbbCosbKbb1AXgSQx/CIqw9oa/wV1fzvsyuMLaPFxkLF31DcTUHYDlGRoRFWJu4um4a l4wfT6XI2BfgWUAyIizC2kLGonZP88hYlLWDImMuwAsYGREWYW0i4/gPuWScTX/nch7ACoyM CIuwNpHxae47CkV/+ZYiYz7AqxgZERZhbSLjKe4vmQxodzVFxn4AqzAyIizC2kPGAaNe5JKx 6vcUGQsAXsfIiLAIaxMZH+T+nZ4Bb66lyNgfYC1GRoRFWJvI+B3wyDjQeRtFxkKAdzAyIizC 2kPGgVe8yyXjDb+jyFgEsB4jI8IirE1kXHgTl4zPfUKRcQDAJoyMCIuwNpFx2wdcMp78iCLj QIAtGBkRFmEvABkZbCsecj/FtmKADzD0ISzC2sS2h/pTbCsB2IGxDWER1ia2HaQzyUEAuzC2 ISzC2sO2kr6fU2y7HGAfxjaERdgLwDbwaiWcYNsN9eUiqCcrYCUgUAI+rdACM2UNbvjEZy0h 0BKNconHIWBINMxz+CdNb4w11NY2TK2Cm2oqJk2PRRpqI1NiDZHq2khVRUNFZHJtXWRErKKq nnw2rra6MhaZUtEQm10xp0QWmxmL1dVUzIiVRG6sq6ipn1lb1xCJ1VTNrK2uISrqIzW1DZHK 2pqaWGVDrCqSnZ83oCdQj9fozPYypbdqoYaxvV4eqPItI8xaQa/VH4GqlWd8rFySB370Mzc9 8GF6hxtr6mJTqusbYnWxqpJIPRlIrG5wSX7f4sLIzIqGqYNzR8Wqqit08dwh/UrH3FBdc1tu /aRKWfeNcklGOvbIhUOqbayrjOlYqVqBBNb4VfO0scPUyuo8SH48lNzr2s8ebdHon7+lisr2 Vk78HPoPWv1Rh0RPg3EoOP6LRUGnqNYyGn7xheus/ENIK1TDwxOCAYHUDkhJFZqEnEAvbTZd yRoOvxI+KwoW4EdLg04hrCD4tUI1PZYx9qznPilhCIaCE/lEwVhFAQP7RAvBtmp6MieBzRj4 yTe8yhxJWqEanvYHfQKp9Xz++o8338Fufvp7K4OXZW3lGLws65BDwQ1qhWrYe31QEkht/Fzo XHP8t/exFfTeK1gpyH2QKCC1bgi6RaO2lYLcTVYjLyuYc96RlxW85VKaB7RCNR9QHvQLpPaf jnKXYhVW+wHzL1Nso3tWqv2ga4IpIqmVBInddtC5tkrbc1qh2o48HjwrkNr6mtrZkyqmT+8H v7iHYbBrfBmKwXSXQhls9J6gWyC15RZNRzcPVJqa7xnKxu4KugRSK7Jbjm0pVlrqgY9qOW5d 0COSWqHggadBTXKdyY3H7XdJFt6kbMILhNEuRbfZGZRN+J/2kgjz2E1vXUyatrci5a3PihH5 B8aanDQ+mCKQ2ksTRmjVdtICh9KWwcfJ18uEjuiu3wJ8cnlnKwXTBhMFpDYej3ezVjBtsagw crhWKAW3/yNYKpDaePyMY1f8m3j8ivgfT4X+du6KH5bGOxOhih/i8bvgX3q+1woFXCeNlU7+ a60vroexwOZ8JAcqZYExVvWclmGSILJbzttE4sUwq6V5p6vMiobztxMaklofG/Pukc5U5S5Q z0eopvcuCAYFZyq9MlkRumxhniB5yOKJp/y4cTC7+/dXk4ELSYSnFNw/LyBpqbIATJew5Pqg RwhIeqLIIPaS8pBHTLGw+0OTCXzIY2G9h45fauWKHh1NXJFc60mzaPzo7glWpn+iMzG9Wstq +cQtw61aPvX3oEtUa1kGXz5BiHh0rrNH/Mwx2eARC+hn3SkRC+gX9pJOk1ovu+WLkZBVyxUb SEtSG2G3fFlKjVh0duWzpLNqLWN1rDyURq8ORpRafT+JUmlaimhOjMtWv6nmKiKNH6bqN8k1 TstaoXVtqlG75ma9rZCuFrrtmkpR6TapV7tAUq54XIAm8ilJYH7BeQj9tNcKZdb1C2XDhVnS ekpKmXn9Q6qZw6ClhXreSWt8V5bpTynSXR6taKOqiBZLrHVa2V9lOb+yIHUsWs1hVQ3h7SZV h3l/X7b+iLq/32SJsqGdqOi2QNnQUUUhH28SrVA2dNJQREsUZY3mWKJMUVFyCIrVWUXZhmka iiqhf7cojfK4rCYXWA8L9UkVNTeByur5e7KQ17Ln76s6iCvbY93zLWrP91ijtMhqOigcN5/0 lG04oaJ0sBr5xpCofHCm/7KJTUCon6qoUx7GWt6YpupL1dcyS+Ugs0qBo/LyVioZfmzjeFlG Dt9Ky3ArDWWqBlIvZ4LdurksjLWxQT3t0V1mq3Rj49ZxkiAAMwpscZAoMM4qcd9yyQzJ6gSh 7IOjpOkMpellWqGafnDaE4k4RJ96WGX9MBTv+Jgo9kQsFO98zBuJSH7v+dw4Q/HunUSxN0LX Uor3zO0hOSzb7v8TyQV7JO2Pqanav45/NEkE6KPJM1qh0PdvaSP9+AsOTQyTf/Q4ma42iskZ W5yPXpG3OD5jHYg+n8sBHXRKXrQPw1Kf/0dii8NwyQe9qh8h5N5r6ZIPhlUPoUoIPrXQXubw QVlN6Jd8jkM9QkAttA0PH1UNHQI0kvro+wJqGR3xy0YKQlJMpHh9pB1xw+pB0xi5JF0NlH21 nX018LOuIMyXHWVffXqhcJIuIBjcbWnLCywtuWpgUQ3CFBAoAUYe0jJYXZRB0GQYqU3LI+bU JqjtAxiut2WF2fWmKK43yNw8XDQPY/q++zLhehnGP9WOSgLlTxnGPzXJbHzJ2vinZpmN79WM L13M5mcY/6fNPOP/tOv8xj/jMxs/zdr4Z9qbje9PGD/t4jW/2fhR8X6O8aPi++c1ftTRxWx8 j6Xxo47eZuMHKON7LlbzM4zvm8Qzvm9pK+Obj2aivq9lmSwKxpw6Rn3fyc3bUULm85uo77SK RutK3JlQiP4OslwBfPlwxmP/+ZSyW9WlKG3+LnJFJ1qKgelPVzELQBcE1t436i/spB7vs/pz vdqfWUvmT74ULPszTu0PJcXqT1miP5qgBeYdKmbx+tDuhogl5p0qJiXFwmxKYGqC5BmkFRrz OVkuTbaL1jfntQteenrUjsbVsPGtVWWL/c/rCpwta3/a16Pb2JkPZEQjI+LSZFmJOeuI+l9U oZUDekaWF/VvkwXaqGuBpWCHqqCNpYKTskCetYJTqoI8KwWScqRTaKlAaqsqUCUY3kkqYBwh qQNmcU4qasU5xuxLk2WZbDIRt3UZLha5LHo2VdWUbTm0JVQKzerK0uSUj7Gbi0qrcDdnPIzd XFRag7u55KeXVuhltFc20nCyooWNwpnlo0/9uejjhtPFQwZOvVZ88Yl3D31xx586dP9dyrg3 /zZRXoms1f6haubhykfm082odErdArFPMKNpBWT/1MnilCiadgsjW07V+XcRZw+MYJ7WqFqa 2He/1TlQNG2eamdNQp8waj7S/lu9LldvqBkz0klI5Cb6dFIz0qmgRHJqb5kwGnc5QqazxOK2 Pto1m4RzB7tl+reJhcAYfPfr1MGTRs2Wg+/+G3XwzVY3KtHeB8xBwR9W+2k+zIj2Pq0cZtC1 VI/zKzlb/2j+w/rWn30JQgQESoCx+POf4S3+UNLi919My59h6+JhvIS5eAwVvGVrMqa+eLF5 6n1hNTgzpr74VWXqJXZ3BvfiTf3gIfrUS1YCAiXAmPrBv+ZNfbjV1Psunsln2Lr0DG/qh7lb 3dPpmXbCmsKdeRNczoCaO3fYqYozkIS7Dl0ecoLgkheQ6SVMYffVax1+Zzyu6klKEcOG0Ii+ 6vWznqlbSQmtpUbKhT7EFHZfu5Pzqjrz9fTIDaVjInWxytq6qpLIiNp65XX0qtrZNbJOU2wW Qy8tUy+DARhOl1S/krgM3mHhdInQq6o1ZYn/B1BLBwhHKCY4ymMAAIHKAQBQSwECFAMUAAgA CABbryFRRygmOMpjAACBygEAEAAgAAAAAAAAAAAApIEAAAAAYnRtb24tbTJhZWJ0LmxvZ1VU DQAH/qdOXwKoTl/+p05fdXgLAAEEAAAAAAQAAAAAUEsFBgAAAAABAAEAXgAAAChkAAAAAA== --------------1E532EBB45443DF8DB21149B-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uGqTEoizTl+wFwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 22:48:08 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +AneEIizTl850QAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 22:48:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 576D0A03FD; Tue, 1 Sep 2020 22:48:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727095AbgIAUsC (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 16:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726091AbgIAUsB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 16:48:01 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8448C061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 13:47:59 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id r4so633115ooq.7 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 13:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=b+piYJczQ7XXBRW1tt3fXRcVGf81aOoZfrtVeQ3iSW4=; b=jJR2/3FXA0lpHWs0rJZRVkzpjykTtoiN50UofWgBGJKqQi0p5IhtxBudw/ce2EpjPn E71XvNfeinwBaBtZOW9H41kS7Ry7X8aCb5XUdFKveu+lBjFNvF+98Lml4tbxlCyKFvQ0 bq7sAKMeIGxo8YgcOaDQmtICiOXIcXMrfyTYjHG2KB7jJcer5xYiCQmhUWoLMLg3wNjM QlQNen9/lJF6XMQYW9GM4pXVW8iCX5jaGGh/Zdahi8l++sIVImzcqYb+UdLf/grG1cmS rMr62axVfHJwR1HwU4zVVx0iYliEiWRKmtUlp9ek6kzRIZpCJ3Q/S+emMrUJVsvZ/Sep 745Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=b+piYJczQ7XXBRW1tt3fXRcVGf81aOoZfrtVeQ3iSW4=; b=Tg6+d8w86b9OuxOi4pbRI+Tm1VNODZGEhj71LbUea9YwN6wNQ0B1mUgHtsYMde9cFy Kv8LF0Y77SL7UKgEec3T+QWTdTAzLYfyf8DjSJly5EJyiM1l4g3bhCOF7wSUoh9rZCbS M0xXViIjalJBkL1vWL3k8mMUNoX0SN5jlaMIkkPyUvvykvFB6dLaovsAqcd7jsd0CSOO TH0/HQM25qQkVLkiaMtQskMinzxyzi2Qm4u8LeOcfP/UAVjLORx5peHVakD8LIaUeojl 3Hjq2xUMW+sR4HuhgPQPuHwBAiKnHA2PJUM5f2jDTvfASaiyYP09lU/Zv2V+g8YnGSxc ZR9Q== X-Gm-Message-State: AOAM53195nWBp2CxztdI+74KIwkZKdKn5ngzeVCmJQk11jS284doECaO OR13tii7oMlzktxM3aSYXJd0RPvSKdyVPCBIxok= X-Google-Smtp-Source: ABdhPJwbq+8vzYpaSoaGn81DZ6ko8klL2BYbl61UioCKYVAy/SUiZ2MDjGuQob0WKrILIss2AzW3+HDRZXvi9MieucY= X-Received: by 2002:a4a:924b:: with SMTP id g11mr2819186ooh.9.1598993278960; Tue, 01 Sep 2020 13:47:58 -0700 (PDT) MIME-Version: 1.0 References: <20200817212554.3844965-1-yudiliu@google.com> <20200817142545.RFC.v2.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> <CABBYNZLRqhB6d5Hm7_RqvUqCJo11D4+pgYLCeWj0j=8dZk0Bcg@mail.gmail.com> <CAHC-ybxshy5zmkAku6suicvjO0Ngofp0+gRyYLX_RXr9YhU94Q@mail.gmail.com> <CAHC-ybxFY_3HWrvnwF5DS-i-YJtYpUuR9K3-MSWJWo=C-CKQHA@mail.gmail.com> <CALWDO_Wsyx3s3SwBejAFdc6SFX=V29DnvPKmo48hd-yy9SqHSg@mail.gmail.com> <CABBYNZJxjYUvui7e-S4TGx21W2U9QvmXhyKNOaWg3RLR4jWg2A@mail.gmail.com> <CALWDO_XV+Hn-U+SgAe_tCcpST0NAo+UjRCBbdS8dzBQZuUCXEg@mail.gmail.com> In-Reply-To: <CALWDO_XV+Hn-U+SgAe_tCcpST0NAo+UjRCBbdS8dzBQZuUCXEg@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 1 Sep 2020 13:47:48 -0700 Message-ID: <CABBYNZJfCMxAKkNvnEUs3vH+XWQLYtyM6-Q9nrB1HPE+tDxKCw@mail.gmail.com> Subject: Re: [RFC PATCH v2 1/1] adapter - D-Bus API for querying the adapter's capabilities To: Alain Michaud <alainmichaud@google.com> Cc: Yu Liu <yudiliu@google.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: 576D0A03FD X-Rspamd-UID: 8346ae Hi Alain, On Tue, Sep 1, 2020 at 12:00 PM Alain Michaud <alainmichaud@google.com> wrote: > > Hi Luiz, > > > On Tue, Sep 1, 2020 at 1:47 PM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Alain, > > > > On Tue, Sep 1, 2020 at 8:43 AM Alain Michaud <alainmichaud@google.com> wrote: > > > > > > Hi Marcel/Luiz, > > > > > > I'd be particularly interested in seeing your opinion on whether this could be better described as some form of SCO socket property... even if this is indeed an adapter property. > > > > Yep, but wasn't that supposed to be what BT_PKT_STATUS is for? I mean > > one can just attempt to read it with getsockopt and in case of returns > > an error it means the controller does not support it, that said it > > doesn't look like we do check the adapter features when using > > BT_PKT_STATUS, should that be checking if HCI_WIDEBAND_SPEECH_ENABLED > > is set? > The problem here is that this will be after the connection is created > and a packet is exchanged. In this context, we'd like to know if the > controller supports it ahead of creating a sco connection so we can > choose to use the headset at all. For example, there are devices and > circumstances where using the device's built-in mic and A2DP will > yield a better experience for the user so the platform may choose that > as a default for the user rather than degrading down to narrow-band. You can use get/setsockopt after bind, so I wonder if that is really a problem here, in fact BT_VOICE wouldn't work if we couldn't use socket options before the connection is made see how it is used in ofono for instance: https://git.kernel.org/pub/scm/network/ofono/ofono.git/tree/src/handsfree-audio.c#n105 Also in order to use WBS one will need to use BT_VOICE anyway, actually that all you need for WBS with mSBC while BT_PKT_STATUS will indicate the possibility to do PLC, not sure why we are mixing these things together or does HFP mandates mSBC to implement PLC nowadays? > > > > Also it doesn't seem we have updated userspace to support > > BT_PKT_STATUS, we should probably have something to test it via > > isotest and perhaps create a iso-tester.c to validate all the options. > > > > > Thanks, > > > Alain > > > > > > On Mon, Aug 31, 2020 at 5:44 PM Yu Liu <yudiliu@google.com> wrote: > > >> > > >> +Alain Michaud > > >> > > >> Hi Marcel, > > >> > > >> Can you please comment on the cl as well as Luiz's suggestion? Thanks. > > >> > > >> On Thu, Aug 20, 2020 at 10:20 AM Yu Liu <yudiliu@google.com> wrote: > > >> > > > >> > Friendly ping for comments from Marcel. Thanks. > > >> > > > >> > > > >> > On Mon, Aug 17, 2020 at 4:17 PM Luiz Augusto von Dentz > > >> > <luiz.dentz@gmail.com> wrote: > > >> > > > > >> > > Hi Marcel, > > >> > > > > >> > > On Mon, Aug 17, 2020 at 4:07 PM Yu Liu <yudiliu@google.com> wrote: > > >> > > > > > >> > > > From: Archie Pusaka <apusaka@chromium.org> > > >> > > > > > >> > > > Initially this is introduced to query whether WBS is supported by the adapter, > > >> > > > the API is generic enough to be extended to support querying others in > > >> > > > the future. > > >> > > > > > >> > > > Reviewed-by: sonnysasaka@chromium.org > > >> > > > > > >> > > > Signed-off-by: Yu Liu <yudiliu@google.com> > > >> > > > --- > > >> > > > > > >> > > > Changes in v2: > > >> > > > - Return an array of strings instead of a dict > > >> > > > > > >> > > > Changes in v1: > > >> > > > - Initial change > > >> > > > > > >> > > > doc/adapter-api.txt | 12 ++++++++++++ > > >> > > > 1 file changed, 12 insertions(+) > > >> > > > > > >> > > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt > > >> > > > index 1a7255750..8fbcadb54 100644 > > >> > > > --- a/doc/adapter-api.txt > > >> > > > +++ b/doc/adapter-api.txt > > >> > > > @@ -204,6 +204,18 @@ Methods void StartDiscovery() > > >> > > > org.bluez.Error.NotReady > > >> > > > org.bluez.Error.Failed > > >> > > > > > >> > > > + array{string} GetCapabilities() > > >> > > > + > > >> > > > + This method returns a list of supported > > >> > > > + capabilities that is populated when the adapter > > >> > > > + initiated. > > >> > > > + > > >> > > > + Possible values: > > >> > > > + "wbs" - Wide band speech > > >> > > > > >> > > Btw, should we stick to use wbs terminology here, or we should > > >> > > actually use the HCI feature/command, because wbs has actually to be > > >> > > implemented by the HFP afaik this is only indicating that the > > >> > > controller is able to notify packets drops, etc, with use of erroneous > > >> > > command. Perhaps we should actually use the term PLC (Packet Loss > > >> > > Concealment) instead since that seems to be the real capability here, > > >> > > afaik WBS does not actually require PLC. > > >> > > > > >> > > > + > > >> > > > + Possible errors: org.bluez.Error.NotReady > > >> > > > + org.bluez.Error.Failed > > >> > > > + > > >> > > > Properties string Address [readonly] > > >> > > > > > >> > > > The Bluetooth device address. > > >> > > > -- > > >> > > > 2.28.0.220.ged08abb693-goog > > >> > > > > > >> > > > > >> > > > > >> > > -- > > >> > > Luiz Augusto von Dentz > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KBbJDEm1Tl+vFwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 01 Sep 2020 22:55:37 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id wGsPC0m1Tl8UpwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 01 Sep 2020 22:55:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2757D417C0; Tue, 1 Sep 2020 22:55:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727818AbgIAUza (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 16:55:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726091AbgIAUz3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 16:55:29 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92FF7C061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 13:55:28 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id r13so3259150ljm.0 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 13:55:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=V5UpJzUE90L64DBS3wKw8YpKexucWe/p4+rJOjr2UYQ=; b=VYh3gR4o4ynPNUoNggh2w4NV+onma3T5eo6+Lqg+JDD2dthFe0Qh56GueiWyqHTVre FvXgAj7eLWj1FHjDD2qG6Gv0jaqFN0+rDy00KaP+z8ciTWguJw9qy2keS8s3FU9Q4U38 F6ivkUdEAc9CHD2pZu8CKkpU779Bo+W/pJL8AyRcVT/CgfPrt2qIrUZxx9qO9azg5zBp lzpWtX0uyd1RAzXKSlHwPVeCiK/yQ+rxTcOcfl2K5ZB4+X4zJo1G8MgtYtY8NWAW49aA esQ0w+l/KMwr2FyqHvp0tH12kyA4k5B/l1xykfU3EyHW+c/Jw/7cvcTq14VallvSL70i 97xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=V5UpJzUE90L64DBS3wKw8YpKexucWe/p4+rJOjr2UYQ=; b=sj3x68LWcJrv4uOpHhUqNlyIFwl0SDflnzDsK8zgIVeIzTiHXI3lVVj+80ylLq5tcS vXdh2eqt752zqSWbsf0EJSHCXr2u/NQqYX+jMzXtM8oQ6H6ADOUBzcw+VZVHf8l9T3d2 BQARBfGwIEjdVCh1fXKqpd+DOHYxZWglmW9MbD3LcnHbcKQgvGiHztBDTEBbLyS2PMMD RsClRrmRFwq6cdfST/ffFDokFv1/Tb5us2XLXAY358Mj/0DTYsixQ2ql/X04x1tXOFtI VgJLssKfB6RCnWJ0Y7Fth5x20bUuef8RyNLETFdzfy5Hb8i/6RagQTz2uQYDYoTWhMAN Kqzw== X-Gm-Message-State: AOAM5307GQPHiT3d3ugPQCEKulDNQ1Q7VhJtzwpApV0MrF7jFta0zmbo ArFkM2Q+EonHzLfk+drsVVhkzXZv0otSXN3r6x03qg== X-Google-Smtp-Source: ABdhPJwHErIMtaSXtfqJzVE1PRQdsJSawM4Nuz0P6p7NnHyuJQL9robZQoaNHaKLCH4f6xoQwBXwzOvle/iPddE/WuI= X-Received: by 2002:a2e:b4c6:: with SMTP id r6mr1481576ljm.274.1598993726032; Tue, 01 Sep 2020 13:55:26 -0700 (PDT) MIME-Version: 1.0 References: <20200817212554.3844965-1-yudiliu@google.com> <20200817142545.RFC.v2.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> <CABBYNZLRqhB6d5Hm7_RqvUqCJo11D4+pgYLCeWj0j=8dZk0Bcg@mail.gmail.com> <CAHC-ybxshy5zmkAku6suicvjO0Ngofp0+gRyYLX_RXr9YhU94Q@mail.gmail.com> <CAHC-ybxFY_3HWrvnwF5DS-i-YJtYpUuR9K3-MSWJWo=C-CKQHA@mail.gmail.com> <CALWDO_Wsyx3s3SwBejAFdc6SFX=V29DnvPKmo48hd-yy9SqHSg@mail.gmail.com> <CABBYNZJxjYUvui7e-S4TGx21W2U9QvmXhyKNOaWg3RLR4jWg2A@mail.gmail.com> <CALWDO_XV+Hn-U+SgAe_tCcpST0NAo+UjRCBbdS8dzBQZuUCXEg@mail.gmail.com> <CABBYNZJfCMxAKkNvnEUs3vH+XWQLYtyM6-Q9nrB1HPE+tDxKCw@mail.gmail.com> In-Reply-To: <CABBYNZJfCMxAKkNvnEUs3vH+XWQLYtyM6-Q9nrB1HPE+tDxKCw@mail.gmail.com> From: Alain Michaud <alainmichaud@google.com> Date: Tue, 1 Sep 2020 16:55:14 -0400 Message-ID: <CALWDO_WSbXfnHr==-=UUdkuTeYkZea_v5hesVZBJ6AkU2CqsUA@mail.gmail.com> Subject: Re: [RFC PATCH v2 1/1] adapter - D-Bus API for querying the adapter's capabilities To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Yu Liu <yudiliu@google.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2757D417C0 X-Rspamd-UID: 05eb05 Hi Luiz, On Tue, Sep 1, 2020 at 4:48 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Alain, > > On Tue, Sep 1, 2020 at 12:00 PM Alain Michaud <alainmichaud@google.com> wrote: > > > > Hi Luiz, > > > > > > On Tue, Sep 1, 2020 at 1:47 PM Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > > > > > > Hi Alain, > > > > > > On Tue, Sep 1, 2020 at 8:43 AM Alain Michaud <alainmichaud@google.com> wrote: > > > > > > > > Hi Marcel/Luiz, > > > > > > > > I'd be particularly interested in seeing your opinion on whether this could be better described as some form of SCO socket property... even if this is indeed an adapter property. > > > > > > Yep, but wasn't that supposed to be what BT_PKT_STATUS is for? I mean > > > one can just attempt to read it with getsockopt and in case of returns > > > an error it means the controller does not support it, that said it > > > doesn't look like we do check the adapter features when using > > > BT_PKT_STATUS, should that be checking if HCI_WIDEBAND_SPEECH_ENABLED > > > is set? > > The problem here is that this will be after the connection is created > > and a packet is exchanged. In this context, we'd like to know if the > > controller supports it ahead of creating a sco connection so we can > > choose to use the headset at all. For example, there are devices and > > circumstances where using the device's built-in mic and A2DP will > > yield a better experience for the user so the platform may choose that > > as a default for the user rather than degrading down to narrow-band. > > You can use get/setsockopt after bind, so I wonder if that is really a > problem here, in fact BT_VOICE wouldn't work if we couldn't use socket > options before the connection is made see how it is used in ofono for > instance: > > https://git.kernel.org/pub/scm/network/ofono/ofono.git/tree/src/handsfree-audio.c#n105 > > Also in order to use WBS one will need to use BT_VOICE anyway, > actually that all you need for WBS with mSBC while BT_PKT_STATUS will > indicate the possibility to do PLC, not sure why we are mixing these > things together or does HFP mandates mSBC to implement PLC nowadays? This is a design choice, one that must be done before a device connected on our platform. Note ChromeOS doesn't use ofono. It's not just about choosing to do mSBC, but rather about which mic the overall platform will use (onboard or from the headset/speaker). > > > > > > > Also it doesn't seem we have updated userspace to support > > > BT_PKT_STATUS, we should probably have something to test it via > > > isotest and perhaps create a iso-tester.c to validate all the options. > > > > > > > Thanks, > > > > Alain > > > > > > > > On Mon, Aug 31, 2020 at 5:44 PM Yu Liu <yudiliu@google.com> wrote: > > > >> > > > >> +Alain Michaud > > > >> > > > >> Hi Marcel, > > > >> > > > >> Can you please comment on the cl as well as Luiz's suggestion? Thanks. > > > >> > > > >> On Thu, Aug 20, 2020 at 10:20 AM Yu Liu <yudiliu@google.com> wrote: > > > >> > > > > >> > Friendly ping for comments from Marcel. Thanks. > > > >> > > > > >> > > > > >> > On Mon, Aug 17, 2020 at 4:17 PM Luiz Augusto von Dentz > > > >> > <luiz.dentz@gmail.com> wrote: > > > >> > > > > > >> > > Hi Marcel, > > > >> > > > > > >> > > On Mon, Aug 17, 2020 at 4:07 PM Yu Liu <yudiliu@google.com> wrote: > > > >> > > > > > > >> > > > From: Archie Pusaka <apusaka@chromium.org> > > > >> > > > > > > >> > > > Initially this is introduced to query whether WBS is supported by the adapter, > > > >> > > > the API is generic enough to be extended to support querying others in > > > >> > > > the future. > > > >> > > > > > > >> > > > Reviewed-by: sonnysasaka@chromium.org > > > >> > > > > > > >> > > > Signed-off-by: Yu Liu <yudiliu@google.com> > > > >> > > > --- > > > >> > > > > > > >> > > > Changes in v2: > > > >> > > > - Return an array of strings instead of a dict > > > >> > > > > > > >> > > > Changes in v1: > > > >> > > > - Initial change > > > >> > > > > > > >> > > > doc/adapter-api.txt | 12 ++++++++++++ > > > >> > > > 1 file changed, 12 insertions(+) > > > >> > > > > > > >> > > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt > > > >> > > > index 1a7255750..8fbcadb54 100644 > > > >> > > > --- a/doc/adapter-api.txt > > > >> > > > +++ b/doc/adapter-api.txt > > > >> > > > @@ -204,6 +204,18 @@ Methods void StartDiscovery() > > > >> > > > org.bluez.Error.NotReady > > > >> > > > org.bluez.Error.Failed > > > >> > > > > > > >> > > > + array{string} GetCapabilities() > > > >> > > > + > > > >> > > > + This method returns a list of supported > > > >> > > > + capabilities that is populated when the adapter > > > >> > > > + initiated. > > > >> > > > + > > > >> > > > + Possible values: > > > >> > > > + "wbs" - Wide band speech > > > >> > > > > > >> > > Btw, should we stick to use wbs terminology here, or we should > > > >> > > actually use the HCI feature/command, because wbs has actually to be > > > >> > > implemented by the HFP afaik this is only indicating that the > > > >> > > controller is able to notify packets drops, etc, with use of erroneous > > > >> > > command. Perhaps we should actually use the term PLC (Packet Loss > > > >> > > Concealment) instead since that seems to be the real capability here, > > > >> > > afaik WBS does not actually require PLC. > > > >> > > > > > >> > > > + > > > >> > > > + Possible errors: org.bluez.Error.NotReady > > > >> > > > + org.bluez.Error.Failed > > > >> > > > + > > > >> > > > Properties string Address [readonly] > > > >> > > > > > > >> > > > The Bluetooth device address. > > > >> > > > -- > > > >> > > > 2.28.0.220.ged08abb693-goog > > > >> > > > > > > >> > > > > > >> > > > > > >> > > -- > > > >> > > Luiz Augusto von Dentz > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qNn9EYfETl+odgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 00:00:39 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id IFuDEIfETl/q5AAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 00:00:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2B710420F4; Wed, 2 Sep 2020 00:00:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729926AbgIAWAd (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 18:00:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729681AbgIAWAc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 18:00:32 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE8C8C061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 15:00:32 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 207so2709228ybd.13 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 15:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=LHOLGhB2FfF4MgoNi7IdLwOC7IIoWZleX+LVSUv6+Y8=; b=iI/ccMdXJsSK2VkuQdZnwb/BVs4pAVn283Xvm21yzRKLsHI07+hIUAee98iq+/1jZR 9q9iYNE2ts6ok3ETlSOlEoOqxsPqYo0+GD2+959vTu477eaSH2gy0e0RFu7BG/823ujy Q2V4W7KlWw4GJE/ZMgZfDqRTExayKgP2skDRI3d/x0ocvSeirS1+cIXJXbhzVRK2n3Bd PgUDOsd8ng0Yrm1E1KOvnNKM17AhdPW7zkXqae9dgbQVaIeyEPsBsi9sfRBApjTH+izT Y3pp9nWZjZaSElTCBho3LQD1v8YCl1qUbUXL/aRvnGndyXvL81UlZ2eLgBP4HTNfVVeU Baxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=LHOLGhB2FfF4MgoNi7IdLwOC7IIoWZleX+LVSUv6+Y8=; b=mQWWaT17HRXgnqr3c+FBDUap7ATtwmVSyA/OJIcwcZ4phsquZsN/sxywY7no7EWgdN 1Q49LkC3Or1dh0JY6w244NKXujCdLsGUWgi101uzri/E/LQorXv1r2MF+JyJPLE/m3E6 2x8QSGzzbInBEi6pGHreSclcNJ/SOMSfLJ3tHr7HZODfodU7dMI3gcxRdKdz/NY46j6V yjaRjn2QxcaR9HGVnS/m9tM8ZmkLVmDzWYtXnhX+8hq39edhiXofn9RtPRiGTvvEiF7W wPt0LmTWaS0UXqt7rAtyWZg9AFEXtWfR1oxkD8ouGotjZdBYeuby1EBmtpqgmaQb9cf4 2+Mw== X-Gm-Message-State: AOAM530k7eB8HJvFScznI0eoQZiFYiW+F/jtIc/9+L3e7yhzuWrWTru1 Q6o3Xi2HPdghcwQu2Dd9wHRDtBW/wJQr3MZif+MW1zpsLBXFi1GJ3DQ1tMHI4fgjWneLXk9J84c v/2tkvvt59RSdo5smAIKUAFBaMs2sr7Xu4GsQkZoYrppc0yYqE57TRsTy9C3gHRn4SbLR04GHrK dyShT4bEQR2vHEV74n X-Google-Smtp-Source: ABdhPJzte4zdzMJBRl06xMGRn0QmNrQZRmFnlcyK/3fj7vcYklSNqldDM5a9et/cc90wVWBEFLARBRQ+Z66iwfVjRIG3 X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:e791:: with SMTP id e139mr5977283ybh.67.1598997631872; Tue, 01 Sep 2020 15:00:31 -0700 (PDT) Date: Tue, 1 Sep 2020 15:00:21 -0700 Message-Id: <20200901220024.662941-1-danielwinkler@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v2 0/3] Expose extended adv feature support via bluez API From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 4.31 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2B710420F4 X-Rspamd-UID: bd8859 Hi Maintainers, This change adds a SupportedFeatures member to the LEAdvertisingManager interface, which allows us to expose support for hardware offloading and setting TX power on advertisements. Best, Daniel Changes in v2: - Expose empty SupportedFeatures if no support available - Doc: Expect empty SupportedFeatures if no support available Daniel Winkler (3): advertising: Add SupportedFeatures to LEAdvertisingManager1 advertising: Add adv SupportedFeatures to bluetoothctl advertising: Add adv SupportedFeatures to doc client/main.c | 1 + doc/advertising-api.txt | 18 +++++++++++++++++ lib/mgmt.h | 2 ++ src/advertising.c | 43 +++++++++++++++++++++++++++++++++++++++-- 4 files changed, 62 insertions(+), 2 deletions(-) -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4OZ6LI7ETl8peAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 00:00:46 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SAZ4Ko7ETl+asAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 00:00:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AC28042110; Wed, 2 Sep 2020 00:00:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729939AbgIAWAl (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 18:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729681AbgIAWAk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 18:00:40 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D2FBC061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 15:00:40 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 207so2709766ybd.13 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 15:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=2pjMPOzpNyrqpjBIOCKze3A6gHCruyIibRIu9fK5k6E=; b=EQylgbEdbO1jIvVdRLO+ImoHZ9mFEHlMeaavDVLhjcc3l7m87tDHb4HHNz1Z2P2i+g N2MEMYiBg+XR5jIEgZf9ETFF7FRYcOu2eKQuxBUvh3MT+GM9Q329hNUWKUfYUz0099RY uSkimyDPd73QRg0/puz5lHgjhiTUN3gZ71V+9U79QcCcYrVmY9qCXoFcw7bAAMYnMdzk oxVbA7qEbkKARRvu03V8ZHN1K8A+yJAdX95DUBwP9bts0n9FuPhTONHSR5ZAcGWCREkt bnoIS9YRQF81mZusnrYlfVJhfXt2ogwYOU6dwKAjPAXfknu+MGFR479LE3uwZQQThdDs c1YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=2pjMPOzpNyrqpjBIOCKze3A6gHCruyIibRIu9fK5k6E=; b=BqjotgAD5zy8UG3V0zY+MoSwtutno8OiHV5GVLN16lwNkbKakDfspSUYlNEIx9OOrI 2H620Eh0CtetntLOZylgofp06pGQ05mE+kAmO13qPWY4g27MFUp4+W3uxS0LJccYkXFP z5fq2D2LOqHgMzcU0XinTm5vOmFOQGUvDq3DUB+Wgngf1nNosFlSIFFr6mgGw7nxfgip vamkHhex545PurRWUz8ATEOu4WqeFTjy8EVPxTcxHhv8T0yy0GGfkSIAETWT7xY0zXd6 A/0n75R5ha2LZ9TzcaEdIVsyQ+Mhcxd15Obr97jf9NdhkAk/y8RWoBX7fBOleGb941xT sGAA== X-Gm-Message-State: AOAM5310kUK7I26l52QGYxHaAbi6GXW+/o+sCkIcZGZc4DhDF5N2VUDy Rnid3y/B5HT4p3Ul4Cmx8+9m5HWaiZmMtSRq6kG8diTBENBMB7gKowFOr3H+wCdyCLqEJm6eTaJ sbuP4wI86khEAhfCM5iKAynooGEFkQFucQAw31JjO+KykyI3jyQklZ9vUPPs/oJANxAFGN3RUvi wvnqSZWcxYGcsBrDRY X-Google-Smtp-Source: ABdhPJwvgDTHCt9+Zhqq30zNVMjzllK0eBLoZmQ9eVV6p5GGviZkHkwTAf/eku4F7uA9uPwULTCFFrqURi4kYvxTpJ+Z X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:c7cd:: with SMTP id w196mr5350640ybe.351.1598997639598; Tue, 01 Sep 2020 15:00:39 -0700 (PDT) Date: Tue, 1 Sep 2020 15:00:22 -0700 In-Reply-To: <20200901220024.662941-1-danielwinkler@google.com> Message-Id: <20200901145820.Bluez.v2.1.Idf2f9f409a4df20b466ba723dd9b729275a5afbf@changeid> Mime-Version: 1.0 References: <20200901220024.662941-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v2 1/3] advertising: Add SupportedFeatures to LEAdvertisingManager1 From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: AC28042110 X-Rspamd-UID: 9a17b9 The new SupportedFeatures member tells advertising clients whether the platform has hardware support for advertising or capability to set tx power of advertisements. Additionally, fix small typo in "secondary_exists" function name. Change is tested on hatch and kukui chromebooks by using dbus-send to verify that SupportedFeatures always exists, and is only populated when extended advertising is available. Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Changes in v2: - Expose empty SupportedFeatures if no support available lib/mgmt.h | 2 ++ src/advertising.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index a800bcab4..38182e576 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -516,6 +516,8 @@ struct mgmt_rp_add_advertising { #define MGMT_ADV_FLAG_SEC_1M (1 << 7) #define MGMT_ADV_FLAG_SEC_2M (1 << 8) #define MGMT_ADV_FLAG_SEC_CODED (1 << 9) +#define MGMT_ADV_FLAG_CAN_SET_TX_POWER (1 << 10) +#define MGMT_ADV_FLAG_HW_OFFLOAD (1 << 11) #define MGMT_OP_REMOVE_ADVERTISING 0x003F struct mgmt_cp_remove_advertising { diff --git a/src/advertising.c b/src/advertising.c index e5f25948d..518d0a80a 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -1321,7 +1321,8 @@ static void append_secondary(struct btd_adv_manager *manager, } } -static gboolean secondary_exits(const GDBusPropertyTable *property, void *data) +static gboolean secondary_exists(const GDBusPropertyTable *property, + void *data) { struct btd_adv_manager *manager = data; @@ -1345,12 +1346,50 @@ static gboolean get_supported_secondary(const GDBusPropertyTable *property, return TRUE; } +static struct adv_feature { + int flag; + const char *name; +} features[] = { + { MGMT_ADV_FLAG_CAN_SET_TX_POWER, "CanSetTxPower" }, + { MGMT_ADV_FLAG_HW_OFFLOAD, "HardwareOffload" }, + { }, +}; + +static void append_features(struct btd_adv_manager *manager, + DBusMessageIter *iter) +{ + struct adv_feature *feat; + + for (feat = features; feat->name; feat++) { + if (manager->supported_flags & feat->flag) + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, + &feat->name); + } +} + +static gboolean get_supported_features(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct btd_adv_manager *manager = data; + DBusMessageIter entry; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &entry); + + append_features(manager, &entry); + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + static const GDBusPropertyTable properties[] = { { "ActiveInstances", "y", get_active_instances, NULL, NULL }, { "SupportedInstances", "y", get_instances, NULL, NULL }, { "SupportedIncludes", "as", get_supported_includes, NULL, NULL }, { "SupportedSecondaryChannels", "as", get_supported_secondary, NULL, - secondary_exits }, + secondary_exists }, + { "SupportedFeatures", "as", get_supported_features, NULL, NULL }, { } }; -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OClPE5TETl+odgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 00:00:52 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8PUmEZTETl8riAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 00:00:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7259E420DF; Wed, 2 Sep 2020 00:00:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729949AbgIAWAr (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 18:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729681AbgIAWAp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 18:00:45 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1705C061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 15:00:45 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id v16so1942555qka.18 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 15:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=hnl7tu+tFkxi4drosybbGZuJGk8hlqywEjZu+JdyxrI=; b=mJOq3nudhJLOQ/5by+6oaYDoAD9icfuqJh7bQE4kcsBrqbUSzqC3dmptvZz+L1Evk4 0aMAKBGLlld7PZtqcTgztVG5gst5lxULxb6NPiWPG9CfuQmBbkp9XIb3xNMW2ZmaG6TA HGBgaaosWcIWW1ftmC/wyDFiDYN0bmYGjsmWgKH4KhuXsvDPuV43tG2TePhLsRXsA/Gy S7nDTvZzMkmCmKPmxmwflQAIvhelZr2ODhntJLWZPvt4KcP6wXuzCiXowT+09HZR+pCp cvx+DZti7y4ck8JsvYsOrRtC34ge3mPy5QamMZht5vE8nLy1bd5W28kNTEbfS8qIz14b NUyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=hnl7tu+tFkxi4drosybbGZuJGk8hlqywEjZu+JdyxrI=; b=s/chXl1IGbtQEdUnf4I2gjgr/0hOIjiOB+mfEO5Y2UY4Ij18w311KHZbhOQakyhlGd KoskxAVs8evjAqVl9RPahgRsApUkcJB/ZXeQp7URvqrR5eteiPoHM8nboukJw2CokT2l AwrR8uc6EYipfBdCjuui+u1Gr5+KXV68HKlcGH503RzBhiR6+BrGogP07PXGlKq3qsWW kut8XnB3WG8mwiJkH7d7xKsxAS6lk5BpwbbZJqQFhS6Ad3jfxIVp9P8GTuPv65QVKPrF Cr9G8/oLbBDqfglFpTW92sTmfYR+s7giEGS5MtNiRXkNizHVLiRa/mesA04tglM9Qi9+ 2PTA== X-Gm-Message-State: AOAM531PdJHvjLveIEvPeMVTBZrH7fKz1jtg6TqjLtsVh3UtDP3NhKt7 cH1Dn6KBnNp+zmyo1liZLMClbVt0WYucIgBMVdF9a3hc/pq5l7xhF2FHx5zb61DcKZpv93B2DS4 QnbH74U7sBNXIirR798f7dX2qH91b7ZrnbSXxODekFfQguD2YCvE8NsdnBDLsAnvTTf2K5VU6iq NkWJIR/C9STJTkF2EA X-Google-Smtp-Source: ABdhPJzjWAmiSZ7Y7fqkGLzJzJAoY7cYni0t4CuOky31bwC5OEEZQVg/AyHWkEhxFA0yXLsVDnm4tb4OxBswIDBY8T/D X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a05:6214:1146:: with SMTP id b6mr3638038qvt.135.1598997644794; Tue, 01 Sep 2020 15:00:44 -0700 (PDT) Date: Tue, 1 Sep 2020 15:00:23 -0700 In-Reply-To: <20200901220024.662941-1-danielwinkler@google.com> Message-Id: <20200901145820.Bluez.v2.2.I33cf8432f94675b635ab429b3125f54048c5b66a@changeid> Mime-Version: 1.0 References: <20200901220024.662941-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v2 2/3] advertising: Add adv SupportedFeatures to bluetoothctl From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7259E420DF X-Rspamd-UID: adc5c4 This change adds SupportedFeatures to be shown in "show" option of bluetoothctl. It was tested with and without kernel support for features to verify that they are shown or not shown correctly. Change was tested by verifying SupportedFeatures were populated correctly in bluetoothctl on hatch and kukui chromebooks Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Changes in v2: None client/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/main.c b/client/main.c index da877b546..6368cd516 100644 --- a/client/main.c +++ b/client/main.c @@ -933,6 +933,7 @@ static void cmd_show(int argc, char *argv[]) print_property(adapter->ad_proxy, "SupportedInstances"); print_property(adapter->ad_proxy, "SupportedIncludes"); print_property(adapter->ad_proxy, "SupportedSecondaryChannels"); + print_property(adapter->ad_proxy, "SupportedFeatures"); } return bt_shell_noninteractive_quit(EXIT_SUCCESS); -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OLVoBJzETl+odgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 00:01:00 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id wKvhApzETl86zwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 00:01:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0630E420D3; Wed, 2 Sep 2020 00:00:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729631AbgIAWAu (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 18:00:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729681AbgIAWAt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 18:00:49 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3BBCC061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 15:00:48 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id l1so2039675qvr.0 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 15:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=CcdNWU+86e5xTiOf7ah/MgfDcwkOxV/DvzlKs8nXLOM=; b=WWlbmm+hACMBMvxtgXeSsmeHJwZDYmBCs29VdHN+qjg60j+XqPybqlx6kj70U0k1Xl LgBfgCqJMrFtcJEkYtXSpGPt9aEC4HYt3lGj3qmTI1ORSs3/TXAOCqp0qROKh97nILE4 J72uySrAIj3aQQxF2GqX9s0oF02RxG7Cn9VLPDC9kvbSACFJc/QPNJiWcnHo4CplQ+ss Ut8Gvu7oC09CAQuNb7C2S/hmEolbeCPMtMT5DmkqhrESEWH+DPBTfY3no8Y18WoCpkEL NuN4RtyrEiUIdpgXAiSeok3Eb2t+GNaLtznwWo5KNwbNhAGpbTs5OgCvZbd5WsthE+Rd 0H4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=CcdNWU+86e5xTiOf7ah/MgfDcwkOxV/DvzlKs8nXLOM=; b=rGIF20GH/Ecwm5q5zKnrl/2fNDjEmn2wf4bEwpf9UPyMcdLwRcvrqAoN8/KwGGsH+T LLgELlwm0by0L3y63oiVNAlpVJREcFn8BlBx1od3zkSTj5CGtrFDZjjU8/WyI16zCbc5 E/ZlNHrCy7iYUGoP7Vv6/OVW1NxeS0zRAcl/wommHmDT/SxVm/yp2MTHqZjFTVg09ogt 9E3OdTM/NTuUjy7QwP6w84VPEsd0usNUBnPPOXfjctPqMico8q6oc+4l2iT+EfQWTKDt K0vUZfRong5VvIqt5si4zCoY4LyDW1chCm2Aqs5c4mdLFQtgjQsHVEzmct24vmNlHAX0 NH6A== X-Gm-Message-State: AOAM533HzuQI/WWiL2ChRqFR5xq0V94DYQQwy9mA37UvhtZys0cMCcvP SW1siH5jq413/YD5b9AjozwcUQA9q44tYf8qJY5J2axkiB3UbzJ2zlHzkpTpCxYVNDUpa1x6ez+ 04Dxl0nj6Iy8MqDM0QplA9Am17Zq/w5Hocf9AumBjsAHO3+4bJOfU6/SvLl7Afe1bgRm+Yx5R0b ypC1u7DjLDvy2xuXdm X-Google-Smtp-Source: ABdhPJyJIYbHREBmZyiDaangNcbGagLACibNHazu9a2hX9ZSdgcqqdmUj4XCHPOxI3b/EPaX0f3a8UY+7HCGpSp7gFqb X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a0c:a342:: with SMTP id u60mr4111883qvu.2.1598997648082; Tue, 01 Sep 2020 15:00:48 -0700 (PDT) Date: Tue, 1 Sep 2020 15:00:24 -0700 In-Reply-To: <20200901220024.662941-1-danielwinkler@google.com> Message-Id: <20200901145820.Bluez.v2.3.Ieb6522963e3f54b0d63dd88ed3ce24a8942ed73e@changeid> Mime-Version: 1.0 References: <20200901220024.662941-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v2 3/3] advertising: Add adv SupportedFeatures to doc From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.58 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0630E420D3 X-Rspamd-UID: 35762b Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Changes in v2: - Doc: Expect empty SupportedFeatures if no support available doc/advertising-api.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt index b0565eab2..90a8a47f6 100644 --- a/doc/advertising-api.txt +++ b/doc/advertising-api.txt @@ -209,3 +209,21 @@ Properties byte ActiveInstances Possible values: "1M" "2M" "Coded" + + array{string} SupportedFeatures [readonly, optional] + + List of supported platform features. If no features + are available on the platform, the SupportedFeatures + array will be empty. + + Possible values: "CanSetTxPower" + + Indicates whether platform can + specify tx power on each + advertising instance. + + "HardwareOffload" + + Indicates whether multiple + advertising will be offloaded + to the controller. -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YPNCFAzQTl87nQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 00:49:48 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id oDexEgzQTl9ujQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 00:49:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 94D2FA147C; Wed, 2 Sep 2020 00:49:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726937AbgIAWtm (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 18:49:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbgIAWtl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 18:49:41 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEE9CC061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 15:49:40 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id 185so2632575oie.11 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 15:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SiuTplZG9JZ32xrHtUa2/phQ6nHZeeGHunAtuf+rBYQ=; b=qpSdIV4PKLCmaNCTqn/4mVtzDZVTiexo3abFunLu0Ax2GI0sQoH8toX4HFCTY8pHnb +1/Kc0xQqmhB46iEKF/oI0eZP5oHCk5nHLbo2z4HWnOtkqy7AMObodhVnC1emn5aFCOA sbJQQ8CwDwMUB0wjPvtmZohuIcoFC73zwE4V7STPELuqE/4e4gqU4vdQJa0VCU/fkEoh 3SasO2Wwmb4HAlgOaXjMNS8f2fiJjLukrVzxGA6EBlQXKvaMS4C/8H4+pPxOZJTb4kIK k2W2ofHlHeQbcbzoxLWqgRWRukeJOK9GwuCeoGRjelTc+Ts+HS59bG/+NSRAPWX1tIHh UoNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SiuTplZG9JZ32xrHtUa2/phQ6nHZeeGHunAtuf+rBYQ=; b=p6zoPhXFQ8TZqw9jiltKG1M4xeqM+KbTr6EtSYqhxTgJEnrxieATwtfBplxlDJxk7I USRbQcprkMp4ErnGYyS0i2GAMFRBsQ9fOdfb2Pwgwtuwp5ZfXyfv6LG9uZsF4Ta38ri/ h99bFcqB2kEzcdmh2QJ4EzbPqPxd0gwiBh3da7lyHNwkeAZ1QH//lKZkSL3Ea33WwG0w yzSyBnRsqEb7qTVTCcknsPTSrOkKWkJK/+0x4+BNuFcFcQ/WqL1GEqpTIrV9+91ZV0Wi t3gYOJW/u5i+4s2kTIlLVTcKrtim0GJRScsrhL2lKxF/B+431LJT9YeJPt+qRDGGsJzH xlnQ== X-Gm-Message-State: AOAM532niVU118g3kFAiTLM3rcxf/tpjk9BQbLAbzfxU+w28VByrsRba Lx/zwJrqK8qlm/LfahkskXETvFiZrvYb6WlGb8U64WRQ X-Google-Smtp-Source: ABdhPJzTVocAVPai1Gn9biAS/4/4dixy7y6FUeyXw1muzLA3j3W6XVSMaOl+a0+plm72Qa3xbvexFMuEED/9BtYHb4A= X-Received: by 2002:a54:478f:: with SMTP id o15mr259948oic.137.1599000580096; Tue, 01 Sep 2020 15:49:40 -0700 (PDT) MIME-Version: 1.0 References: <20200817212554.3844965-1-yudiliu@google.com> <20200817142545.RFC.v2.1.Ibaa1dfd49179a141c19a651f3c2132a28b71b344@changeid> <CABBYNZLRqhB6d5Hm7_RqvUqCJo11D4+pgYLCeWj0j=8dZk0Bcg@mail.gmail.com> <CAHC-ybxshy5zmkAku6suicvjO0Ngofp0+gRyYLX_RXr9YhU94Q@mail.gmail.com> <CAHC-ybxFY_3HWrvnwF5DS-i-YJtYpUuR9K3-MSWJWo=C-CKQHA@mail.gmail.com> <CALWDO_Wsyx3s3SwBejAFdc6SFX=V29DnvPKmo48hd-yy9SqHSg@mail.gmail.com> <CABBYNZJxjYUvui7e-S4TGx21W2U9QvmXhyKNOaWg3RLR4jWg2A@mail.gmail.com> <CALWDO_XV+Hn-U+SgAe_tCcpST0NAo+UjRCBbdS8dzBQZuUCXEg@mail.gmail.com> <CABBYNZJfCMxAKkNvnEUs3vH+XWQLYtyM6-Q9nrB1HPE+tDxKCw@mail.gmail.com> <CALWDO_WSbXfnHr==-=UUdkuTeYkZea_v5hesVZBJ6AkU2CqsUA@mail.gmail.com> In-Reply-To: <CALWDO_WSbXfnHr==-=UUdkuTeYkZea_v5hesVZBJ6AkU2CqsUA@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 1 Sep 2020 15:49:29 -0700 Message-ID: <CABBYNZ+H-T=+=1ZwTkQga2vE5spy5An-SK__8b2fS4GGUzaiaQ@mail.gmail.com> Subject: Re: [RFC PATCH v2 1/1] adapter - D-Bus API for querying the adapter's capabilities To: Alain Michaud <alainmichaud@google.com> Cc: Yu Liu <yudiliu@google.com>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.25 / 15.00 / 200.00 X-Rspamd-Queue-Id: 94D2FA147C X-Rspamd-UID: 7cc655 Hi Alain, On Tue, Sep 1, 2020 at 1:55 PM Alain Michaud <alainmichaud@google.com> wrote: > > Hi Luiz, > > > On Tue, Sep 1, 2020 at 4:48 PM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Alain, > > > > On Tue, Sep 1, 2020 at 12:00 PM Alain Michaud <alainmichaud@google.com> wrote: > > > > > > Hi Luiz, > > > > > > > > > On Tue, Sep 1, 2020 at 1:47 PM Luiz Augusto von Dentz > > > <luiz.dentz@gmail.com> wrote: > > > > > > > > Hi Alain, > > > > > > > > On Tue, Sep 1, 2020 at 8:43 AM Alain Michaud <alainmichaud@google.com> wrote: > > > > > > > > > > Hi Marcel/Luiz, > > > > > > > > > > I'd be particularly interested in seeing your opinion on whether this could be better described as some form of SCO socket property... even if this is indeed an adapter property. > > > > > > > > Yep, but wasn't that supposed to be what BT_PKT_STATUS is for? I mean > > > > one can just attempt to read it with getsockopt and in case of returns > > > > an error it means the controller does not support it, that said it > > > > doesn't look like we do check the adapter features when using > > > > BT_PKT_STATUS, should that be checking if HCI_WIDEBAND_SPEECH_ENABLED > > > > is set? > > > The problem here is that this will be after the connection is created > > > and a packet is exchanged. In this context, we'd like to know if the > > > controller supports it ahead of creating a sco connection so we can > > > choose to use the headset at all. For example, there are devices and > > > circumstances where using the device's built-in mic and A2DP will > > > yield a better experience for the user so the platform may choose that > > > as a default for the user rather than degrading down to narrow-band. > > > > You can use get/setsockopt after bind, so I wonder if that is really a > > problem here, in fact BT_VOICE wouldn't work if we couldn't use socket > > options before the connection is made see how it is used in ofono for > > instance: > > > > https://git.kernel.org/pub/scm/network/ofono/ofono.git/tree/src/handsfree-audio.c#n105 > > > > Also in order to use WBS one will need to use BT_VOICE anyway, > > actually that all you need for WBS with mSBC while BT_PKT_STATUS will > > indicate the possibility to do PLC, not sure why we are mixing these > > things together or does HFP mandates mSBC to implement PLC nowadays? > This is a design choice, one that must be done before a device > connected on our platform. Note ChromeOS doesn't use ofono. It's not > just about choosing to do mSBC, but rather about which mic the overall > platform will use (onboard or from the headset/speaker). Got it, I just don't like the naming because while it is perfectly fine for ChromeOS to choose to only do WBS when BT_PKT_STATUS is available, other platforms my not required that, specially since BlueZ may also be used in carkits/IVI systems which may have been built without PLC support. Regarding the use of oFono, I was using more as an example that you can set socket options before any connection is made, anyway the setting of the erroneous command seems to be done at startup regardless if the userspace will actually require BT_PKT_STATUS or not, so all I'm suggesting is to check if the command was actually used when using BT_PKT_STATUS. > > > > > > > > > > Also it doesn't seem we have updated userspace to support > > > > BT_PKT_STATUS, we should probably have something to test it via > > > > isotest and perhaps create a iso-tester.c to validate all the options. > > > > > > > > > Thanks, > > > > > Alain > > > > > > > > > > On Mon, Aug 31, 2020 at 5:44 PM Yu Liu <yudiliu@google.com> wrote: > > > > >> > > > > >> +Alain Michaud > > > > >> > > > > >> Hi Marcel, > > > > >> > > > > >> Can you please comment on the cl as well as Luiz's suggestion? Thanks. > > > > >> > > > > >> On Thu, Aug 20, 2020 at 10:20 AM Yu Liu <yudiliu@google.com> wrote: > > > > >> > > > > > >> > Friendly ping for comments from Marcel. Thanks. > > > > >> > > > > > >> > > > > > >> > On Mon, Aug 17, 2020 at 4:17 PM Luiz Augusto von Dentz > > > > >> > <luiz.dentz@gmail.com> wrote: > > > > >> > > > > > > >> > > Hi Marcel, > > > > >> > > > > > > >> > > On Mon, Aug 17, 2020 at 4:07 PM Yu Liu <yudiliu@google.com> wrote: > > > > >> > > > > > > > >> > > > From: Archie Pusaka <apusaka@chromium.org> > > > > >> > > > > > > > >> > > > Initially this is introduced to query whether WBS is supported by the adapter, > > > > >> > > > the API is generic enough to be extended to support querying others in > > > > >> > > > the future. > > > > >> > > > > > > > >> > > > Reviewed-by: sonnysasaka@chromium.org > > > > >> > > > > > > > >> > > > Signed-off-by: Yu Liu <yudiliu@google.com> > > > > >> > > > --- > > > > >> > > > > > > > >> > > > Changes in v2: > > > > >> > > > - Return an array of strings instead of a dict > > > > >> > > > > > > > >> > > > Changes in v1: > > > > >> > > > - Initial change > > > > >> > > > > > > > >> > > > doc/adapter-api.txt | 12 ++++++++++++ > > > > >> > > > 1 file changed, 12 insertions(+) > > > > >> > > > > > > > >> > > > diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt > > > > >> > > > index 1a7255750..8fbcadb54 100644 > > > > >> > > > --- a/doc/adapter-api.txt > > > > >> > > > +++ b/doc/adapter-api.txt > > > > >> > > > @@ -204,6 +204,18 @@ Methods void StartDiscovery() > > > > >> > > > org.bluez.Error.NotReady > > > > >> > > > org.bluez.Error.Failed > > > > >> > > > > > > > >> > > > + array{string} GetCapabilities() > > > > >> > > > + > > > > >> > > > + This method returns a list of supported > > > > >> > > > + capabilities that is populated when the adapter > > > > >> > > > + initiated. > > > > >> > > > + > > > > >> > > > + Possible values: > > > > >> > > > + "wbs" - Wide band speech > > > > >> > > > > > > >> > > Btw, should we stick to use wbs terminology here, or we should > > > > >> > > actually use the HCI feature/command, because wbs has actually to be > > > > >> > > implemented by the HFP afaik this is only indicating that the > > > > >> > > controller is able to notify packets drops, etc, with use of erroneous > > > > >> > > command. Perhaps we should actually use the term PLC (Packet Loss > > > > >> > > Concealment) instead since that seems to be the real capability here, > > > > >> > > afaik WBS does not actually require PLC. > > > > >> > > > > > > >> > > > + > > > > >> > > > + Possible errors: org.bluez.Error.NotReady > > > > >> > > > + org.bluez.Error.Failed > > > > >> > > > + > > > > >> > > > Properties string Address [readonly] > > > > >> > > > > > > > >> > > > The Bluetooth device address. > > > > >> > > > -- > > > > >> > > > 2.28.0.220.ged08abb693-goog > > > > >> > > > > > > > >> > > > > > > >> > > > > > > >> > > -- > > > > >> > > Luiz Augusto von Dentz > > > > > > > > > > > > > > > > -- > > > > Luiz Augusto von Dentz > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QOhpHdnVTl/CtAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 01:14:33 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gJSdG9nVTl+asAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 01:14:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8B801A1315; Wed, 2 Sep 2020 01:14:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726183AbgIAXOY (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 19:14:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbgIAXOT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 19:14:19 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3859BC061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 16:14:18 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id z22so2707562oid.1 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 16:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZNKbQkOXJGTu443gjqpGrfwbdl8ocb2o7nv3x7pwM6c=; b=eqoV5xXNzxIqmRyvXPsuvBhUdxf5aM/FM+9wGVj83Lj7XpZFNVNpK8KqN8GmkFejX0 mHmhL7MXpqcuyMgxko4fVArP+IEcGR0AMLj0sevWQYDbQlvF8fp+gf/o0uZYtllPKVPO Kp+9SwWbzlhH8VHjXFtnfFF4lAKm7H6gadYRY5RxX98T8sYrMW43MP9d8UpEQt8KyzJh MSoqkE+1ff4XIZ8wEoNuoRXg3bbA2vBL7k74NHBT6OhWm1HoUp7hJcqxWTFH4qRNq+VO y7gYW6gBJ+zm9HtEaXtokO6xQf0GODaIZZDgbATSjTG99bk/A56LypcT1M/AclcE1fr4 IILg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZNKbQkOXJGTu443gjqpGrfwbdl8ocb2o7nv3x7pwM6c=; b=NcN/7b1vS9WDXKT/SAC8X72p08Qpu4iz0kgREsFF32Ym0ucb4upupqlFcVU3LQdMU7 Ao2GYQYKEsKkqEecCbhbi5h4crWGxSzCEUbOs0KWGNnKD//L3QZC1FzSqoZ4yd+fSCDi sqQ6OWuFuAjeAzoB6/bjar7OGo9OUaN8OlLI1uw/mUUhn6jIxeZZXUhhbk+HS8edKJ/+ ESFNP/MoWtfwXZQUIRNjiwSa8vQW82g1uNFu20R0vi0DrLZ3uWiviQES99cp7qx3OuEk PQe1dwPUTs4uaQmWBi/6naca8h+G7qCEwCFoh+vdGj8LEVW2OSqen02mUgiUBIOSAzlD 4qwg== X-Gm-Message-State: AOAM531eAtKc6HC6b0G+CUX/ALysWgMBJyaz8W2kC7bqZpiv9Jfu4B14 UkPe6q7xXxpVeydf+svO9/qVeDUhVbE0luXWejrUomd53t4= X-Google-Smtp-Source: ABdhPJyUjnIQNBIqzbrrKYCBCWqpmzwadOjFGZGUY5kcs9LjEY5RedqZPO+fbWiP6df/RkaQizyri4o+/GDJzDhKaww= X-Received: by 2002:aca:a9c9:: with SMTP id s192mr310903oie.152.1599002057173; Tue, 01 Sep 2020 16:14:17 -0700 (PDT) MIME-Version: 1.0 References: <67077b05-dc49-3a97-c83f-4090f1cc7cea@gmail.com> <phdhvi$sdh$1@blaine.gmane.org> <8e41e2ae-bef4-d479-9706-49fd214081a6@chini.tk> <phdpkn$q3q$1@blaine.gmane.org> <pht30d$27m$1@blaine.gmane.org> <53d57478-4b61-65a4-7f09-b7e473cc613a@chini.tk> <305017ee-6420-3c44-7842-14776c37207d@gmail.com> <12fa0585-c993-0685-ac76-27d96d539ca2@gmail.com> <9a633975-704c-1a00-3f9f-b93a499947c2@gmail.com> <8bf4641f-4d3e-faf4-f53a-c571b97d9be4@gmail.com> <2bd00ced-f685-9048-5a10-a20028595086@gmail.com> In-Reply-To: <2bd00ced-f685-9048-5a10-a20028595086@gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 1 Sep 2020 16:14:07 -0700 Message-ID: <CABBYNZ+ZqS1LHVjLwt3mQvmFi1y7ogf_Tstvu70-XnDVT3nAAA@mail.gmail.com> Subject: Re: Bluetooth connection disconnects every few minutes To: Julian Sikorski <belegdol@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8B801A1315 X-Rspamd-UID: bb2122 Hi Julian, On Tue, Sep 1, 2020 at 1:42 PM Julian Sikorski <belegdol@gmail.com> wrote: > > W dniu 01.09.2020 o 22:10, Julian Sikorski pisze: > > W dniu 12.08.2018 o 17:49, Julian Sikorski pisze: > >> W dniu 01.08.2018 o 19:46, Julian Sikorski pisze: > >>> W dniu 09.07.2018 o 18:51, Julian Sikorski pisze: > >>>> W dniu 08.07.2018 o 19:46, Georg Chini pisze: > >>>>> On 08.07.2018 15:21, Julian Sikorski wrote: > >>>>>> W dniu 02.07.2018 o 20:09, Julian Sikorski pisze: > >>>>>>> W dniu 02.07.2018 o 18:04, Georg Chini pisze: > >>>>>>>> On 02.07.2018 17:58, Julian Sikorski wrote: > >>>>>>>>> W dniu 29.06.2018 o 21:47, Julian Sikorski pisze: > >>>>>>>>>> Hi list, > >>>>>>>>>> > >>>>>>>>>> I have noticed that the bluetooth connection between my laptop (Intel > >>>>>>>>>> 7260) and my headphones (Sennheiser Momentum Wirelless) is very > >>>>>>>>>> unreliable. While under Windows 10 devices stay connected for > >>>>>>>>>> hours on > >>>>>>>>>> end, under Fedora 28 the connection is lost every few minutes at > >>>>>>>>>> most. > >>>>>>>>>> Often the connection will be reestablished only to be lost again. > >>>>>>>>>> bluetoothd shows messages like: > >>>>>>>>>> > >>>>> > >>>>>>>>>> I am not sure where to look further. Does it look like an issue with > >>>>>>>>>> pulseaudio, or a deeper problem with linux bluetooth stack? Thanks > >>>>>>>>>> for > >>>>>>>>>> your input in advance! > >>>>>>>>>> > >>>>>>>>>> Best regards, > >>>>>>>>>> Julian > >>>>>>>>> This is what is logged by pulseaudio at the time the connection is > >>>>>>>>> lost: > >>>>>>>>> > >>>>>>>>> ( 118.064| 34.694) I: [bluetooth] module-bluez5-device.c: FD error: > >>>>>>>>> POLLERR POLLHUP > >>>>>>>>> ( 118.064| 0.000) I: [bluetooth] bluez5-util.c: Transport > >>>>>>>>> /org/bluez/hci0/dev_00_1B_66_81_8D_76/fd27 auto-released by BlueZ or > >>>>>>>>> already released > >>>>>>>>> ( 118.064| 0.000) I: [pulseaudio] backend-native.c: Lost RFCOMM > >>>>>>>>> connection. > >>>>>>>>> > >>>>>>>>> > >>>>>>>> From what you are writing, it looks to me as if the issue is in the > >>>>>>>> USB > >>>>>>>> stack and the BT dongle keeps disconnecting/connecting. Have you > >>>>>>>> tried another dongle? > >>>>>>> Hi, > >>>>>>> > >>>>>>> I unfortunately do not own any other dongles. I tried getting some > >>>>>>> useful info with btmon but the log seems flooded with way too many > >>>>>>> messages to make anything out. > >>>>>>> > >>>>>> Hi Georg, > >>>>>> > >>>>>> it looks like the problem is more related to how the dongle interacts > >>>>>> with this specific headphone model. I have recently bought another one > >>>>>> for running (AfterShokz Trekz Air) and it works perfectly, connecting > >>>>>> automatically, staying connected and even switching profiles > >>>>>> automatically without issues so far. > >>>>>> The hci0: last event is not cmd complete (0x0f) message seems harmless > >>>>>> as it spams the dmesg output regardless of the device connected (and > >>>>>> also when no device is connected at all. > >>>>>> It appears that whatever is happening it makes the dongle reconnect: > >>>>>> > >>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: USB disconnect, device number 6 > >>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: new full-speed USB device number 7 > >>>>>> using ehci-pci > >>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: New USB device found, > >>>>>> idVendor=8087, idProduct=07dc, bcdDevice= 0.01 > >>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: New USB device strings: Mfr=0, > >>>>>> Product=0, SerialNumber=0 > >>>>>> [nie lip 8 15:14:12 2018] Bluetooth: hci0: read Intel version: > >>>>>> 3707100180012d0d2a > >>>>>> [nie lip 8 15:14:12 2018] Bluetooth: hci0: Intel device is already > >>>>>> patched. patch num: 2a > >>>>>> > >>>>>> Where would you recommend to look for reasons for this behaviour? btmon? > >>>>>> Thank you for the pointers! > >>>>>> > >>>>>> Best regards, > >>>>>> Julian > >>>>>> > >>>>>> > >>>>> Hi Julian, > >>>>> > >>>>> sorry, I have no further ideas. Maybe Luiz can help you to investigate. > >>>>> To me it looks like the headphone is sending something that makes the > >>>>> dongle reset. > >>>>> > >>>>> Regards > >>>>> Georg > >>>> > >>>> Hi Georg, > >>>> > >>>> no worries - hopefully Luiz will find some time to look into this. > >>>> In the meantime I have been getting acquainted with btmon. I have > >>>> managed to pinpoint the exact moment during which sound stops coming > >>>> through the headphones and starts coming through the laptop speakers. In > >>>> the below testcase, it happens at 18:42:58: > >>>> > >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 > >>>> #1825 [hci0] 18:42:58.908586 > >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 > >>>> #1826 [hci0] 18:42:58.928877 > >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > >>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 > >>>> {0x0002} [hci0] 18:43:00.653578 > >>>> Class: 0x000000 > >>>> Major class: Miscellaneous > >>>> Minor class: 0x00 > >>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 > >>>> {0x0001} [hci0] 18:43:00.653578 > >>>> Class: 0x000000 > >>>> Major class: Miscellaneous > >>>> Minor class: 0x00 > >>>> @ MGMT Event: New Settings (0x0006) plen 4 > >>>> {0x0002} [hci0] 18:43:00.653609 > >>>> Current settings: 0x00000ada > >>>> Connectable > >>>> Discoverable > >>>> Bondable > >>>> Secure Simple Pairing > >>>> BR/EDR > >>>> Low Energy > >>>> Secure Connections > >>>> @ MGMT Event: New Settings (0x0006) plen 4 > >>>> {0x0001} [hci0] 18:43:00.653609 > >>>> Current settings: 0x00000ada > >>>> Connectable > >>>> Discoverable > >>>> Bondable > >>>> Secure Simple Pairing > >>>> BR/EDR > >>>> Low Energy > >>>> Secure Connections > >>>> = bluetoothd: Unable to get io data for Headset Voice gateway: > >>>> getpeername: Transport endpoint is not connected.. 18:43:00.654133 > >>>> = Close Index: 7C:5C:F8:B2:DF:08 > >>>> [hci0] 18:43:00.678348 > >>>> @ MGMT Event: Index Removed (0x0005) plen 0 > >>>> {0x0002} [hci0] 18:43:00.678372 > >>>> @ MGMT Event: Index Removed (0x0005) plen 0 > >>>> {0x0001} [hci0] 18:43:00.678372 > >>>> = Delete Index: 7C:5C:F8:B2:DF:08 > >>>> [hci0] 18:43:00.678377 > >>>> = bluetoothd: Endpoint unregistered: sender=:1.1492 > >>>> path=/MediaEndpoint/A2DPSource > >>>> 18:43:00.678966 > >>>> = bluetoothd: Endpoint unregistered: sender=:1.1492 > >>>> path=/MediaEndpoint/A2DPSink > >>>> 18:43:00.678984 > >>>> > >>>> I am copying linux-bluetooth, maybe someone there will have an idea as > >>>> well. Thank you for all your help in advance! > >>>> > >>>> Best regards, > >>>> Julian > >>> > >>> Hi all, > >>> > >>> I tried to get more information using hcidump, but it does not appear > >>> very interesting. I am attaching it here just in case. The last entry > >>> appearing - command complete (read encryption key size) - appears upon > >>> successful connection, not when the connection is dropped. How else > >>> could I try to figure out what is being sent at the time of > >>> disconnection? Thank you! > >>> > >>> Best regards, > >>> Julian > >> > >> Hi list, > >> > >> I just realised I never attached the full btmon dump. Here it goes, the > >> connection drops at 17:32:04: > >> > >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 > >> #1340 [hci0] 17:32:04.774611 > >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > >>> HCI Event: Number of Completed Packets (0x13) plen 5 > >> #1341 [hci0] 17:32:04.783175 > >> Num handles: 1 > >> Handle: 256 > >> Count: 1 > >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 > >> #1342 [hci0] 17:32:04.794981 > >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > >>> HCI Event: Number of Completed Packets (0x13) plen 5 > >> #1343 [hci0] 17:32:04.803054 > >> Num handles: 1 > >> Handle: 256 > >> Count: 1 > >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 > >> #1344 [hci0] 17:32:04.815326 > >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > >>> HCI Event: Number of Completed Packets (0x13) plen 5 > >> #1345 [hci0] 17:32:04.823198 > >> Num handles: 1 > >> Handle: 256 > >> Count: 1 > >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 > >> #1346 [hci0] 17:32:04.835578 > >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 > >> #1347 [hci0] 17:32:04.856093 > >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 > >> #1348 [hci0] 17:32:04.876186 > >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 > >> #1349 [hci0] 17:32:04.896454 > >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > >> < ACL Data TX: Handle 256 flags 0x02 dlen 850 > >> #1350 [hci0] 17:32:04.916869 > >> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} > >> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 > >> {0x0002} [hci0] 17:32:06.637019 > >> Class: 0x000000 > >> Major class: Miscellaneous > >> Minor class: 0x00 > >> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 > >> {0x0001} [hci0] 17:32:06.637019 > >> Class: 0x000000 > >> Major class: Miscellaneous > >> Minor class: 0x00 > >> @ MGMT Event: New Settings (0x0006) plen 4 > >> {0x0002} [hci0] 17:32:06.637034 > >> Current settings: 0x00000ada > >> Connectable > >> Discoverable > >> Bondable > >> Secure Simple Pairing > >> BR/EDR > >> Low Energy > >> Secure Connections > >> @ MGMT Event: New Settings (0x0006) plen 4 > >> {0x0001} [hci0] 17:32:06.637034 > >> Current settings: 0x00000ada > >> Connectable > >> Discoverable > >> Bondable > >> Secure Simple Pairing > >> BR/EDR > >> Low Energy > >> Secure Connections > >> = Close Index: 7C:5C:F8:B2:DF:08 > >> [hci0] 17:32:06.654087 > >> @ MGMT Event: Index Removed (0x0005) plen 0 > >> {0x0002} [hci0] 17:32:06.654114 > >> @ MGMT Event: Index Removed (0x0005) plen 0 > >> {0x0001} [hci0] 17:32:06.654114 > >> = Delete Index: 7C:5C:F8:B2:DF:08 > >> [hci0] 17:32:06.654120 > >> = bluetoothd: Unable to get io data for Headset Voice gateway: > >> getpeername: Transport endpoint is not connected.. 17:32:06.654352 > >> = bluetoothd: Endpoint unregistered: sender=:1.750 > >> path=/MediaEndpoint/A2DPSource > >> 17:32:06.654796 > >> = bluetoothd: Endpoint unregistered: sender=:1.750 > >> path=/MediaEndpoint/A2DPSink > >> 17:32:06.654836 > >> > >> I tried sending the btmon capture as attachment but it appears to be too > >> large for the list, so I uploaded it here instead: > >> > >> https://belegdol.fedorapeople.org/btmon-aug.log Is this perhaps related to https://github.com/bluez/bluez/issues/18, we have a fix already applied upstream for it. > >> Best regards, > >> Julian > >> > > > > Hi all, > > > > I have tried the headset again with kernel-5.8.4, bluez-5.54 and > > pulseaudio-13.99.1. The situation has unfortunately not improved in the > > last two years. > > I am attaching the btmon capture of two connection attempts: > > - the first connects and then almost immediately disconnects > > - the second never succeeds > > Does the capture provide any information as to why the connection is > > failing? If I can provide any more data, please let me know. Thanks! > > > > Best regards, > > Julian > > > If I am not mistaken, the disconnect happens right after #636 > > Best regards, > Julian -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UIoeB3EDT18N4wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 04:29:05 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id gFqEBXEDT1+FLwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 04:29:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 776CC420D4; Wed, 2 Sep 2020 04:29:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726285AbgIBC26 convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Tue, 1 Sep 2020 22:28:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:49568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726122AbgIBC26 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 1 Sep 2020 22:28:58 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Wed, 02 Sep 2020 02:28:56 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: swyterzone@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-60824-62941-K6NX66hUVP@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.47 / 15.00 / 200.00 X-Rspamd-Queue-Id: 776CC420D4 X-Rspamd-UID: b60cf3 https://bugzilla.kernel.org/show_bug.cgi?id=60824 --- Comment #148 from Swyter (swyterzone@gmail.com) --- Yeah, I tested 5.8.2-arch when it came out and it was a bit disappointing, to be honest. Something in that timespan caused a regression. It was still an improvement, because the counterfeit detection worked fine and the dongle talked back and forth, but it suffered from weird connection problems, so it probably didn't play well with some of the Bluetooth stack changes introduced recently. As you said, my patch on kernel 5.7 worked more or less fine. I haven't had time to properly track down the issue or see what happens in newer kernel versions with the patch included (from 5.8.2 onwards, I think). https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/diff/drivers/bluetooth/btusb.c?id=v5.8.2&id2=v5.8.1 But maybe it has ironed out itself. ¯\_(ツ)_/¯ If anyone has time to do some regression testing to narrow down the issue and better document what's going on, it would probably help a lot. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sJyBO1kmT18BaAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 06:58:01 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iBSJOVkmT1+7eQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 06:58:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 16639A11C8; Wed, 2 Sep 2020 06:57:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726193AbgIBE5z (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 00:57:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725808AbgIBE5x (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 00:57:53 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E594DC061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 21:57:52 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id g6so2025471pfi.1 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 21:57:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=CiNatQYsu0DXAewi6I/opfSYQc435ZU+DaUdqjz8hA8=; b=EZetdeYBqr+u9lyboK0cd8KX94wz8IXufDLVq3QKXTb8Re/D27qIf+xerwS4y6joFF cn9PKzDd2MTlXx+ouW8wGo2784Ab8fUHI2Hj02cu7Wxv56P9zAVhWpbin1RchiiqMxvO 06d09SpU1JClj/9OF5fa5NYzGndZgb8WkqUsZyU0a0DfRtOM4Gd7l81Y7775O0UcIp8j /0uEUosa6LD8pjCy/9NQuCCFhNnG9NnoTiS8ufiF/kiN2WUvYI/i32lBEYEkcIGKquqJ o9Kjv0mFF6lbBI+plG35GDdYr8JUcsnC//t8Z0CcXkt6v+bD9mm32FFHwA5Gr0uX81Ym n82w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=CiNatQYsu0DXAewi6I/opfSYQc435ZU+DaUdqjz8hA8=; b=bjvnMmFCQGF2ch3ReZomsUO5mFFul7QC5CDRZV9xY5c6Kont+L6wDV9aktqzLtPXOd ehozVGFJq97cQUF8oMNlFyNxE6ezRqsIdnGsjV8xC5ua+IOHALvw5fPiKUteeLi7b+t+ wMRCUi0hCibY7EhRv9gTlHP2vudxXvQhhktFo6Mq1UQk+8JRNk4xwkCMs1/nEqfkaeKD sdcIJzk5+bqOZ0yHqwt1D558eUFoQrXiD2hEBRSaOTDZYR6tCO/u2i1IzGHh4KEstLgH qjHlCcRbm2jC9BTL9WVPVqE9YpYoY9nV5/fYhxRO4KyTO4U4rvFa08Y8DPHoezdoswai X4Aw== X-Gm-Message-State: AOAM531KIqiQtoLY+vLewp1zINpd73t4CuwzLlrOmHZU1/bkaEXv8fLR BFG9rqoGtH6pfYKJv9g4HrqkPyFzCmDfFy/hAPXOAJmH2Qxf76/KGLElVaApEP0yFlHgrL3zcAv QyHkx2JJ/c/x79pGOOsw9uvY5Tn/XaV7FCQvuEfhl7SBQi2jkFzqdInkmE+80fbyTCpgf6OBejk 5O X-Google-Smtp-Source: ABdhPJy7nyNGkcVVM+aSaLAgmC9pK0Y95ZmdPQXvt2LGhBqSXlT5GlzZUpKZM3OG7/mPayevaufL8x8gBC+3 X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a17:902:a581:b029:cf:9367:8d9d with SMTP id az1-20020a170902a581b02900cf93678d9dmr2167593plb.0.1599022671913; Tue, 01 Sep 2020 21:57:51 -0700 (PDT) Date: Wed, 2 Sep 2020 12:57:45 +0800 Message-Id: <20200902125726.Bluez.v1.1.I732df55cd70d552fc48e87686fb53c3f8ccbefa5@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v1] avrcp: Add handler for GET_TOTAL_NUMBER_OF_ITEMS From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Yun-Hao Chung <howardchung@google.com>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: 16639A11C8 X-Rspamd-UID: 26014f From: Archie Pusaka <apusaka@chromium.org> According to the AVRCP spec, section 4.5, GetTotalNumberOfItems PDU is mandatory for TG supporting category 1 or 3. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Michael Sun <michaelfsun@google.com> --- profiles/audio/avrcp.c | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 5d0256c52..6da73394f 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -79,6 +79,7 @@ #define AVRCP_STATUS_SUCCESS 0x04 #define AVRCP_STATUS_UID_CHANGED 0x05 #define AVRCP_STATUS_DOES_NOT_EXIST 0x09 +#define AVRCP_STATUS_INVALID_SCOPE 0x0a #define AVRCP_STATUS_OUT_OF_BOUNDS 0x0b #define AVRCP_STATUS_INVALID_PLAYER_ID 0x11 #define AVRCP_STATUS_PLAYER_NOT_BROWSABLE 0x12 @@ -211,6 +212,12 @@ struct player_item { char name[0]; } __attribute__ ((packed)); +struct get_total_number_of_items_rsp { + uint8_t status; + uint16_t uid_counter; + uint32_t num_items; +} __attribute__ ((packed)); + struct avrcp_server { struct btd_adapter *adapter; uint32_t tg_record_id; @@ -566,6 +573,9 @@ static void populate_default_features(void) /* supports at least AVRCP 1.4 */ default_features[7] |= (1 << 2); + + /* supports GetTotalNumberOfItems browsing command */ + default_features[8] |= (1 << 3); } static unsigned int attr_get_max_val(uint8_t attr) @@ -2048,10 +2058,56 @@ static void avrcp_handle_get_folder_items(struct avrcp *session, case AVRCP_SCOPE_SEARCH: case AVRCP_SCOPE_NOW_PLAYING: default: + status = AVRCP_STATUS_INVALID_SCOPE; + goto failed; + } + + return; + +failed: + pdu->params[0] = status; + pdu->param_len = htons(1); +} + +static void avrcp_handle_media_player_list_num_items(struct avrcp *session, + struct avrcp_browsing_header *pdu) +{ + struct avrcp_player *player = target_get_player(session); + struct get_total_number_of_items_rsp *rsp; + + rsp = (void *)pdu->params; + rsp->status = AVRCP_STATUS_SUCCESS; + rsp->uid_counter = htons(player_get_uid_counter(player)); + rsp->num_items = htonl(g_slist_length(session->server->players)); + pdu->param_len = htons(sizeof(*rsp)); +} + +static void avrcp_handle_get_total_number_of_items(struct avrcp *session, + struct avrcp_browsing_header *pdu, + uint8_t transaction) +{ + uint8_t scope; + uint8_t status = AVRCP_STATUS_SUCCESS; + + if (ntohs(pdu->param_len) != 1) { status = AVRCP_STATUS_INVALID_PARAM; goto failed; } + scope = pdu->params[0]; + + switch (scope) { + case AVRCP_SCOPE_MEDIA_PLAYER_LIST: + avrcp_handle_media_player_list_num_items(session, pdu); + break; + case AVRCP_SCOPE_MEDIA_PLAYER_VFS: + case AVRCP_SCOPE_SEARCH: + case AVRCP_SCOPE_NOW_PLAYING: + default: + status = AVRCP_STATUS_INVALID_SCOPE; + goto failed; + } + return; failed: @@ -2065,6 +2121,8 @@ static struct browsing_pdu_handler { uint8_t transaction); } browsing_handlers[] = { { AVRCP_GET_FOLDER_ITEMS, avrcp_handle_get_folder_items }, + { AVRCP_GET_TOTAL_NUMBER_OF_ITEMS, + avrcp_handle_get_total_number_of_items }, { }, }; -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8J+gBpM0T18LjgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 07:58:43 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iC4cBZM0T191dgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 07:58:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1E71FA1444; Wed, 2 Sep 2020 07:58:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726140AbgIBF6g (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 01:58:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbgIBF6f (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 01:58:35 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 943B8C061244 for <linux-bluetooth@vger.kernel.org>; Tue, 1 Sep 2020 22:58:34 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id z9so3228076wmk.1 for <linux-bluetooth@vger.kernel.org>; Tue, 01 Sep 2020 22:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=LMkJYniRKsd1ko2QbohaB0IuegDUmqjOhD/emII8lcQ=; b=OiGgC/DB5bxvfd5J5npQyxzvWMQURSpRXh3mycicYJihDdW1/Y/CMyEqtBxJOfW4s/ 85Yylp/YwnAMlKE3Zjw4mbmYcXCpE+AJo2sEfsicyoK7pgY5UG1dM9ZufF2gY+ZjSBhh YW15C5q58P6b98SwxtnTYvDi3edAGWediYDAHUwkvZfgl5FrWsKF61hVYnF5JIjlpPEg w5+tvcK71XqF7QqpHOZRtiFY+JOrRG8MjRBa6L5Z5n0qengAudowSzIPUMwUuPvUl+AX wzvh5s5G1bQC3q7+R8hdQMaDM1hFem8oS+zBx1hgNyivOTE1Bi0gPdsBob5K2FK69VNt 53LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language; bh=LMkJYniRKsd1ko2QbohaB0IuegDUmqjOhD/emII8lcQ=; b=oYczm6N/ilfHqyskgRF+d+7W1fsjLEeldvDNFFYR1RnfS0Hmk37lNSv7+utYb7ioP5 m6EihDCVnERDQljuI3pqZZyKpun62Ed93a/5A5v0CxUX9EgHZI/WQHhYFahqCvZCIGjP DIdcD/tVc96uMnhCgA2qi17lMvudbBtfp33cdZkXN6T1Ovz6yaSWZ7qz1AJyv6bDu/z3 /iEmfaGQmjcy74YpXqdaxwAdClsJWUQ20nylQD8VN5iRa2H0c6PkJe+8CPHdu382knzN f/nR85BLQv6t3y2itJgzBZwMsI6I54+CxRudbvYc0lA0PufTAHYfy5iC+S3HJpoL9D7j nWVg== X-Gm-Message-State: AOAM531Euk8l27We/y/1AhtZ/+dfZxSxzMfKZR5EPPRTiZBdsUmsZuqr 2j+3gd7pjnT+RNU92mOsvt2dyWFZTaA= X-Google-Smtp-Source: ABdhPJzNe/W7APBUToa5u78Hh9hRRkT6CK/uplazWeURIaa8v8rjtMOL1v53oza12pd5uOnyy/f6Aw== X-Received: by 2002:a7b:c308:: with SMTP id k8mr5015943wmj.90.1599026311345; Tue, 01 Sep 2020 22:58:31 -0700 (PDT) Received: from ?IPv6:2a02:908:1982:45e0:80a3:8327:7b91:9429? ([2a02:908:1982:45e0:80a3:8327:7b91:9429]) by smtp.googlemail.com with ESMTPSA id c14sm5116928wrv.12.2020.09.01.22.58.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Sep 2020 22:58:30 -0700 (PDT) Subject: Re: Bluetooth connection disconnects every few minutes To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> References: <67077b05-dc49-3a97-c83f-4090f1cc7cea@gmail.com> <phdhvi$sdh$1@blaine.gmane.org> <8e41e2ae-bef4-d479-9706-49fd214081a6@chini.tk> <phdpkn$q3q$1@blaine.gmane.org> <pht30d$27m$1@blaine.gmane.org> <53d57478-4b61-65a4-7f09-b7e473cc613a@chini.tk> <305017ee-6420-3c44-7842-14776c37207d@gmail.com> <12fa0585-c993-0685-ac76-27d96d539ca2@gmail.com> <9a633975-704c-1a00-3f9f-b93a499947c2@gmail.com> <8bf4641f-4d3e-faf4-f53a-c571b97d9be4@gmail.com> <2bd00ced-f685-9048-5a10-a20028595086@gmail.com> <CABBYNZ+ZqS1LHVjLwt3mQvmFi1y7ogf_Tstvu70-XnDVT3nAAA@mail.gmail.com> From: Julian Sikorski <belegdol@gmail.com> Autocrypt: addr=belegdol@gmail.com; prefer-encrypt=mutual; keydata= mQENBE40CmIBCACj+gI1pIMD0VGrZD4ugde8f3usLc0OE0OnPDXjqelxsC3B/x9BFoQrzfnP qJEtcB6F4V5MuEYutnteeuFsIkLHx6UIe9vr1Ze01XtN7Emsya/AKXaEcXYzUUjVmWn1NjJF ZlX0ML3mIQPERBDEY/aXAj7cVDGvkFVeKWIWE5KRqQWV2rYo0nizZTRYGB0z6KpMninG4hqF KvvpzhDS5ZnxijEYs0YAx0QllI4LjLTH3xLuYMnSbHzFRBh9zUsMttMnZdCudLZC6ZllkjtM ov/kIO35P5ygFJ9xlLyxMFkhXsARDWe3qwJCEHfJgtcblQD/LHuY200fTmrbwTK9Q4uNABEB AAG0JEp1bGlhbiBTaWtvcnNraSA8YmVsZWdkb2xAZ21haWwuY29tPokBOAQTAQIAIgUCTjQK YgIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQLdUZIcIlWSuFYwf+J5lKOXWz+FJW Vn4b8Q237R/SOlZVwVfT9u/EjxGkploecihuzRadwXDMu030zdgo0m4lwEubOD5eMvzpBSYu Dc3fDPT/T5/O7avybt2w83hptPuwU4O0EmNrkgr6pHql1nxEvBpeB8KkJnexJww95Kl1YmBX c1kdRrAShNxiVQDpPnskGtnfK2eTqyuyhECApIVLxMIX5IsqGCpslRUR6e90iHd591iJgRT+ Ji74QjkCQzJJVcKbX5T7HzbUd6mmkZjNbtog3g6WEPkI4Qdw+ZeDlSViN/SKPS2ptMMzxCOT neVuw3c6qM/VUo6AUTPSl+1c1rO2X7ZY5/Z9dCMP9rkBDQRONApiAQgAmurakWU/VVEKiPcM o5IsActeWERRTxgUXmliSp02YtBLYwOBQ6WUmJyhywOR8s3Wh93cHEPgEPI/n+cfytNxvpol liSXp3PZGJAmBSIq13d1lDYJBzDzNjUz6dj9YMV56zcsWbYF25grXbPY4acy/5RQXHWjQ4R9 dtGCMd48dhMH6O0DvsiriRxJQrcXz0mgLSi79KVns4VgIuUuPCwPyF1zNUBs/srbgTuL+On0 GjbK40GnJq/Zw2LhEGeicp0npoc4jshgVTtUXRQrGo04plJNpNg9Tl1UIbsHrjA1qz9yo8GR 4MLgXzcyfM6h+wz6qC8eI7jx4VEZxMhXtalvywARAQABiQEfBBgBAgAJBQJONApiAhsMAAoJ EC3VGSHCJVkrpl0IAJJd8qETlL0XzNZsguk8LwXi0c++iTTbotw/zn1f7CgGsZErm58KqNhR UltAZvK+lOclNPbZRsGzoEdg4TIvSymWVLN6jyblhcqH4G9mxmf6QOLvYR5I02UQiIbKvTvv mFA8bgr2vXPFc8rBmFXrwyC3DOjfrnz23kGattsFWbRA2OBq7bp/05JVoMb4QRA2TIbbvsyQ g0MMs9VldhdVfZcFqU2qKwQs8fBr8BD+OfPeiYndJV4GnfYhK692viMjv/+dgOvYcEgtlFaJ TLeiWvwUUxJ7ai45p+gCHXUYPGwrH4Dm2HAw61vUDkbT5pVOeGlFsvtOVEajnQX+MOV93l4= Message-ID: <21f3b905-566c-00a0-e576-f47ae13019a6@gmail.com> Date: Wed, 2 Sep 2020 07:58:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <CABBYNZ+ZqS1LHVjLwt3mQvmFi1y7ogf_Tstvu70-XnDVT3nAAA@mail.gmail.com> Content-Type: multipart/mixed; boundary="------------EA2EFEED3655352BC8E8D3C6" Content-Language: en-US Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.31 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1E71FA1444 X-Rspamd-UID: b1eb28 This is a multi-part message in MIME format. --------------EA2EFEED3655352BC8E8D3C6 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit W dniu 02.09.2020 o 01:14, Luiz Augusto von Dentz pisze: > Hi Julian, > > On Tue, Sep 1, 2020 at 1:42 PM Julian Sikorski <belegdol@gmail.com> wrote: >> >> W dniu 01.09.2020 o 22:10, Julian Sikorski pisze: >>> W dniu 12.08.2018 o 17:49, Julian Sikorski pisze: >>>> W dniu 01.08.2018 o 19:46, Julian Sikorski pisze: >>>>> W dniu 09.07.2018 o 18:51, Julian Sikorski pisze: >>>>>> W dniu 08.07.2018 o 19:46, Georg Chini pisze: >>>>>>> On 08.07.2018 15:21, Julian Sikorski wrote: >>>>>>>> W dniu 02.07.2018 o 20:09, Julian Sikorski pisze: >>>>>>>>> W dniu 02.07.2018 o 18:04, Georg Chini pisze: >>>>>>>>>> On 02.07.2018 17:58, Julian Sikorski wrote: >>>>>>>>>>> W dniu 29.06.2018 o 21:47, Julian Sikorski pisze: >>>>>>>>>>>> Hi list, >>>>>>>>>>>> >>>>>>>>>>>> I have noticed that the bluetooth connection between my laptop (Intel >>>>>>>>>>>> 7260) and my headphones (Sennheiser Momentum Wirelless) is very >>>>>>>>>>>> unreliable. While under Windows 10 devices stay connected for >>>>>>>>>>>> hours on >>>>>>>>>>>> end, under Fedora 28 the connection is lost every few minutes at >>>>>>>>>>>> most. >>>>>>>>>>>> Often the connection will be reestablished only to be lost again. >>>>>>>>>>>> bluetoothd shows messages like: >>>>>>>>>>>> >>>>>>> >>>>>>>>>>>> I am not sure where to look further. Does it look like an issue with >>>>>>>>>>>> pulseaudio, or a deeper problem with linux bluetooth stack? Thanks >>>>>>>>>>>> for >>>>>>>>>>>> your input in advance! >>>>>>>>>>>> >>>>>>>>>>>> Best regards, >>>>>>>>>>>> Julian >>>>>>>>>>> This is what is logged by pulseaudio at the time the connection is >>>>>>>>>>> lost: >>>>>>>>>>> >>>>>>>>>>> ( 118.064| 34.694) I: [bluetooth] module-bluez5-device.c: FD error: >>>>>>>>>>> POLLERR POLLHUP >>>>>>>>>>> ( 118.064| 0.000) I: [bluetooth] bluez5-util.c: Transport >>>>>>>>>>> /org/bluez/hci0/dev_00_1B_66_81_8D_76/fd27 auto-released by BlueZ or >>>>>>>>>>> already released >>>>>>>>>>> ( 118.064| 0.000) I: [pulseaudio] backend-native.c: Lost RFCOMM >>>>>>>>>>> connection. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> From what you are writing, it looks to me as if the issue is in the >>>>>>>>>> USB >>>>>>>>>> stack and the BT dongle keeps disconnecting/connecting. Have you >>>>>>>>>> tried another dongle? >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> I unfortunately do not own any other dongles. I tried getting some >>>>>>>>> useful info with btmon but the log seems flooded with way too many >>>>>>>>> messages to make anything out. >>>>>>>>> >>>>>>>> Hi Georg, >>>>>>>> >>>>>>>> it looks like the problem is more related to how the dongle interacts >>>>>>>> with this specific headphone model. I have recently bought another one >>>>>>>> for running (AfterShokz Trekz Air) and it works perfectly, connecting >>>>>>>> automatically, staying connected and even switching profiles >>>>>>>> automatically without issues so far. >>>>>>>> The hci0: last event is not cmd complete (0x0f) message seems harmless >>>>>>>> as it spams the dmesg output regardless of the device connected (and >>>>>>>> also when no device is connected at all. >>>>>>>> It appears that whatever is happening it makes the dongle reconnect: >>>>>>>> >>>>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: USB disconnect, device number 6 >>>>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: new full-speed USB device number 7 >>>>>>>> using ehci-pci >>>>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: New USB device found, >>>>>>>> idVendor=8087, idProduct=07dc, bcdDevice= 0.01 >>>>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: New USB device strings: Mfr=0, >>>>>>>> Product=0, SerialNumber=0 >>>>>>>> [nie lip 8 15:14:12 2018] Bluetooth: hci0: read Intel version: >>>>>>>> 3707100180012d0d2a >>>>>>>> [nie lip 8 15:14:12 2018] Bluetooth: hci0: Intel device is already >>>>>>>> patched. patch num: 2a >>>>>>>> >>>>>>>> Where would you recommend to look for reasons for this behaviour? btmon? >>>>>>>> Thank you for the pointers! >>>>>>>> >>>>>>>> Best regards, >>>>>>>> Julian >>>>>>>> >>>>>>>> >>>>>>> Hi Julian, >>>>>>> >>>>>>> sorry, I have no further ideas. Maybe Luiz can help you to investigate. >>>>>>> To me it looks like the headphone is sending something that makes the >>>>>>> dongle reset. >>>>>>> >>>>>>> Regards >>>>>>> Georg >>>>>> >>>>>> Hi Georg, >>>>>> >>>>>> no worries - hopefully Luiz will find some time to look into this. >>>>>> In the meantime I have been getting acquainted with btmon. I have >>>>>> managed to pinpoint the exact moment during which sound stops coming >>>>>> through the headphones and starts coming through the laptop speakers. In >>>>>> the below testcase, it happens at 18:42:58: >>>>>> >>>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>>> #1825 [hci0] 18:42:58.908586 >>>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>>> #1826 [hci0] 18:42:58.928877 >>>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>>>>> {0x0002} [hci0] 18:43:00.653578 >>>>>> Class: 0x000000 >>>>>> Major class: Miscellaneous >>>>>> Minor class: 0x00 >>>>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>>>>> {0x0001} [hci0] 18:43:00.653578 >>>>>> Class: 0x000000 >>>>>> Major class: Miscellaneous >>>>>> Minor class: 0x00 >>>>>> @ MGMT Event: New Settings (0x0006) plen 4 >>>>>> {0x0002} [hci0] 18:43:00.653609 >>>>>> Current settings: 0x00000ada >>>>>> Connectable >>>>>> Discoverable >>>>>> Bondable >>>>>> Secure Simple Pairing >>>>>> BR/EDR >>>>>> Low Energy >>>>>> Secure Connections >>>>>> @ MGMT Event: New Settings (0x0006) plen 4 >>>>>> {0x0001} [hci0] 18:43:00.653609 >>>>>> Current settings: 0x00000ada >>>>>> Connectable >>>>>> Discoverable >>>>>> Bondable >>>>>> Secure Simple Pairing >>>>>> BR/EDR >>>>>> Low Energy >>>>>> Secure Connections >>>>>> = bluetoothd: Unable to get io data for Headset Voice gateway: >>>>>> getpeername: Transport endpoint is not connected.. 18:43:00.654133 >>>>>> = Close Index: 7C:5C:F8:B2:DF:08 >>>>>> [hci0] 18:43:00.678348 >>>>>> @ MGMT Event: Index Removed (0x0005) plen 0 >>>>>> {0x0002} [hci0] 18:43:00.678372 >>>>>> @ MGMT Event: Index Removed (0x0005) plen 0 >>>>>> {0x0001} [hci0] 18:43:00.678372 >>>>>> = Delete Index: 7C:5C:F8:B2:DF:08 >>>>>> [hci0] 18:43:00.678377 >>>>>> = bluetoothd: Endpoint unregistered: sender=:1.1492 >>>>>> path=/MediaEndpoint/A2DPSource >>>>>> 18:43:00.678966 >>>>>> = bluetoothd: Endpoint unregistered: sender=:1.1492 >>>>>> path=/MediaEndpoint/A2DPSink >>>>>> 18:43:00.678984 >>>>>> >>>>>> I am copying linux-bluetooth, maybe someone there will have an idea as >>>>>> well. Thank you for all your help in advance! >>>>>> >>>>>> Best regards, >>>>>> Julian >>>>> >>>>> Hi all, >>>>> >>>>> I tried to get more information using hcidump, but it does not appear >>>>> very interesting. I am attaching it here just in case. The last entry >>>>> appearing - command complete (read encryption key size) - appears upon >>>>> successful connection, not when the connection is dropped. How else >>>>> could I try to figure out what is being sent at the time of >>>>> disconnection? Thank you! >>>>> >>>>> Best regards, >>>>> Julian >>>> >>>> Hi list, >>>> >>>> I just realised I never attached the full btmon dump. Here it goes, the >>>> connection drops at 17:32:04: >>>> >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>> #1340 [hci0] 17:32:04.774611 >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>> HCI Event: Number of Completed Packets (0x13) plen 5 >>>> #1341 [hci0] 17:32:04.783175 >>>> Num handles: 1 >>>> Handle: 256 >>>> Count: 1 >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>> #1342 [hci0] 17:32:04.794981 >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>> HCI Event: Number of Completed Packets (0x13) plen 5 >>>> #1343 [hci0] 17:32:04.803054 >>>> Num handles: 1 >>>> Handle: 256 >>>> Count: 1 >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>> #1344 [hci0] 17:32:04.815326 >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>> HCI Event: Number of Completed Packets (0x13) plen 5 >>>> #1345 [hci0] 17:32:04.823198 >>>> Num handles: 1 >>>> Handle: 256 >>>> Count: 1 >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>> #1346 [hci0] 17:32:04.835578 >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>> #1347 [hci0] 17:32:04.856093 >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>> #1348 [hci0] 17:32:04.876186 >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>> #1349 [hci0] 17:32:04.896454 >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>> #1350 [hci0] 17:32:04.916869 >>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>>> {0x0002} [hci0] 17:32:06.637019 >>>> Class: 0x000000 >>>> Major class: Miscellaneous >>>> Minor class: 0x00 >>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>>> {0x0001} [hci0] 17:32:06.637019 >>>> Class: 0x000000 >>>> Major class: Miscellaneous >>>> Minor class: 0x00 >>>> @ MGMT Event: New Settings (0x0006) plen 4 >>>> {0x0002} [hci0] 17:32:06.637034 >>>> Current settings: 0x00000ada >>>> Connectable >>>> Discoverable >>>> Bondable >>>> Secure Simple Pairing >>>> BR/EDR >>>> Low Energy >>>> Secure Connections >>>> @ MGMT Event: New Settings (0x0006) plen 4 >>>> {0x0001} [hci0] 17:32:06.637034 >>>> Current settings: 0x00000ada >>>> Connectable >>>> Discoverable >>>> Bondable >>>> Secure Simple Pairing >>>> BR/EDR >>>> Low Energy >>>> Secure Connections >>>> = Close Index: 7C:5C:F8:B2:DF:08 >>>> [hci0] 17:32:06.654087 >>>> @ MGMT Event: Index Removed (0x0005) plen 0 >>>> {0x0002} [hci0] 17:32:06.654114 >>>> @ MGMT Event: Index Removed (0x0005) plen 0 >>>> {0x0001} [hci0] 17:32:06.654114 >>>> = Delete Index: 7C:5C:F8:B2:DF:08 >>>> [hci0] 17:32:06.654120 >>>> = bluetoothd: Unable to get io data for Headset Voice gateway: >>>> getpeername: Transport endpoint is not connected.. 17:32:06.654352 >>>> = bluetoothd: Endpoint unregistered: sender=:1.750 >>>> path=/MediaEndpoint/A2DPSource >>>> 17:32:06.654796 >>>> = bluetoothd: Endpoint unregistered: sender=:1.750 >>>> path=/MediaEndpoint/A2DPSink >>>> 17:32:06.654836 >>>> >>>> I tried sending the btmon capture as attachment but it appears to be too >>>> large for the list, so I uploaded it here instead: >>>> >>>> https://belegdol.fedorapeople.org/btmon-aug.log > > Is this perhaps related to https://github.com/bluez/bluez/issues/18, > we have a fix already applied upstream for it. > Hi Luiz, it looks like a different issue. I tried both passing --noplugin=avrcp and applying the two patches mentioned in the github issue to Fedora RPM, neither helped. I am attaching a new btmon capture in case something changed. In this one the disconnect happens after #371. Best regards, Julian >>>> Best regards, >>>> Julian >>>> >>> >>> Hi all, >>> >>> I have tried the headset again with kernel-5.8.4, bluez-5.54 and >>> pulseaudio-13.99.1. The situation has unfortunately not improved in the >>> last two years. >>> I am attaching the btmon capture of two connection attempts: >>> - the first connects and then almost immediately disconnects >>> - the second never succeeds >>> Does the capture provide any information as to why the connection is >>> failing? If I can provide any more data, please let me know. Thanks! >>> >>> Best regards, >>> Julian >>> >> If I am not mistaken, the disconnect happens right after #636 >> >> Best regards, >> Julian > > > --------------EA2EFEED3655352BC8E8D3C6 Content-Type: application/zip; name="btmon-m2aebt-2.zip" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="btmon-m2aebt-2.zip" UEsDBBQACAAIAKo+IlEAAAAAAAAAAN+7AQASACAAYnRtb24tbTJhZWJ0LTIubG9nVVQNAAdQ M09fUzNPX1AzT191eAsAAQQAAAAABAAAAADtnXl8VEW2x0/1knR3Ot3pBEjCYjqAGBkDYQmS yBYQBh02ISKLGkPSLCMkMQkgI2gQHfWJg+M6M464DRJCEBQJsigIoiDjPupocEfxMUNAxWVE 6Vd37ZN03WI+T+8/eO7nUwJdp86v7qnzrVP3NpIZtTUVlZVVwC8GkPga/zVXadEo+JUP4ePl bHzxOSfGzKmYf3V4QaS6Zk5lRTi/18Be/XP75uX1mlnWr2+vqwcOKBnQP5yj/Xq2MixbaW2c nBw+d36ktrKydna4Zv6MmkU1tZF5psu+vfr2VUxT9AZoYBSY54Mnvrt08eyyOXnQ+vK0stP+ rDRf7PNc0EY7lE/OUBqfWAD1M37r4AAWUmIAKTOMaZabKqJRVzlaj6qdV1nRem5+vTnNUfe1 OF2+BbctndkJXK7uTJ+nT3UUs5nsdSVqRsqVoDfk5YuHgi5gXhcaH+td6S1K9YBs/EP510Rd PUC97WS9od4LujuTeDpoHhQbcOvNgYze6eRyqL0C/xNeVubXyYXW0x3rndwLsv18kRg4GDeD OiyBvMzu28kJzC2e5DWrkpRJRqMrTjbvmHoTmgea5GJ3Z5dTu0/BLK+7TpllZ2WWQb2h3ntr u3FJxpgztqDGPJDEnzIyjRXVPlVzRGkuZBQG5uPyDHzModll6C2ErHooPUlo6XhEXMk8Uazs mbV9O73hWQwDlsITkoGTeWAYjzuznvH55owd+owFEVz5nBLBTGVcot5Q7xMPpbmZFn1zOigN Nu+DbG06SXw6isRT2nQErvb8O+ZK0L3vdbNb+Y/6G9T9w5OJUT1KY8ePHTmu+OKx4bF9w0Uj hxfDL+eK3ylWZ0fMnUIJWfwirZ6+y1wkR6tFis+Z1ZdmmjnjdGgy8Wu1+pousaU0khoJ3jQY stvxHYMLOv3quAWxW4hP6tU33dw2qfWrk96w7V3A0iGN27pcQdXS5cUREsz2oR9libd61Uey FF+9Zr8RPZdDmRxPTYdawDroDU2uIQlYKg8pA7fDp9+Gbp2qN+R549WQHeDLya1dCapnqzvY sj02xc56Q452XQnZGXzew9SFC+a7O/I9Jgt65Du92uwMcTTV5xqAKeJ1XItPABz5VuIHHoiJ x1eC1QezjEqQ4HQZi2fYIcGDK4Bpdokxu3i5eucnMrl6XjCMwuNSCs9OvGwuZDfVzCmXsmw7 jfDG51R90gwzp9xB1bJ1TsVnRX3OTjMr3KfIivqck2ZWuH36RHRrwf33vE2WrfW9Fsa643Oq /tzFZk65pTlVX1gly6n6QcsEOZWKcupMvaEbHZIDLBu68FtUcioD2uen5Ye4eb4/35nJIN+d CU6P32Jhi3eZeZTgMhYsPo/qL0438yhmJ7i/qS9J43jVr2PdxnkTdde9kZ5g1uRMvcWODPVL i5NcHTSDMctWrxy7f/4G2LFp/ZTlSY+A6NBYf0NFwMeSXLFCH1+K1/Tf7nHplS8+QGvyY0eu RJcyjIHoVLcm/1pPO0erWuBCnXeZWCSqeasfHyBLb9j2fn7+g3QlxxPSVEvm+NHZGg2v3tBd DMwOJDIP12UpIGJnzdi3TXY8BjtNysktnp014y402fH49Nnq1vGLumZ8pmzN10zaE+s2tNC8 Ll0I2bpWgk9nR7ljsbOSS2LOjPVGzkpzIdsDSoI6h7LOyAbdXOlW/lCkfMCcNext8aQW3a9N ivs52n5ZKOMYQC0/DleJw7WoWQsXn9fR9ktDGR+q1okN4lu49h5puO5/UXqHq9oZd1g2lD0s vsNHxxh3WFbD5oAI6DWPTtWAVubs/cRddluD2K7xmAG+kv+ZUGQx7Vf3Su/qH/Wy+rLmrWka ZUq81dlUiWfz1r/RrD/SZy2Qe3uvVK55ApL7SJczHlGQXPMH/FlRGchKoyx7LwjB+vBsAywF 7iJWpMQKxLYHj7W11a/4+rjm06BZHz1BbnvqM9eaz9NkJ8Q1/9tsnBBdXr+6ksxxndPhiCqP /4K8PtzF3Aa8PnUG2gix+L/elsa85SVzI/UpR4jrLfbKoynmXunzwHDNziJERzPNEHmDquUp Q/RtgzRPT9wp7Y7+LtZt5EvsHhsckyBbyRcOZ5SxVKGPhsT+MR8d9YZ8JI6F7A78gKHsvQEN Nx70Bx36MhnPIrEoNHivB5bAU44vkPhZpKF9s7n3JykxlZybGjpUmYue5NOjb3luajjjQdnB qCHrFvNg5E1QhS3WpaHHXGlUBn2pRWW4ejBK5iebkA/CyrFIXfBsvaH7GMK3+S58w7qeKcei dhDKD+Ync/N8T35CZijZyywesxpKp8ryuGHeUvPE5HcZ+Rm/VTXMe9k8McXsjOMb8lf9KmQr xzeeM0f7FRX/akrRhDGD+/QryM/Ny8ubkdunT5+8c/olB8RzvWFBbK7Gc2XM99qMeyFbea4s Agfze1we4YqvLazUVryIpfBTu3LC48Fsrz6axEuuvfvVmKSRjEjyr3WQrSYjpCqDkvSG5B5Y BnxJnFwunCB+/7F250dSjb1nGRpdE4TBX7vvS7Nq+ZSqpWZePBhrD79h7sd8s9nFhht7t2BS R/fJnljXHn2/rSv9it+31h4bYO5bSUFu23bfit+71x5fYu7dyX4dYcnevfb4MRPjZJ8qYe7d 8Xg1OuvMTScpoHOKNp34VWx0TzNWMS8Rv63EJl+Zi8AJSIcR4sA2Jvxetuc2JoWk3V3nS7t7 DJKlUmPPJCOV+ioDL1Qav+XkmMU5fROS0Hvt3pXVs3orf/5db+Wdeu/yyIKSvLySPsNLBgwo GdinZOD5JecO6F0TqerTe2Z5XmF4ZnlOv4Kzw9WR0vJF4sxpHLjVzBy/B5yOEdYHiMbBv29r a5lljYN3m1mWHOS2bbMsfsNoHL5Y2zAY+AKO1pNAjod/YJTopID+akt7EhLE/+Jk6fJMaZE9 HDROO2A+HPAsHmHmJf+lh96QdclzkN0VzlBuONhRtTZy2OV1utXvNZqCblWsi97QXZW8CSwT 2itawZAaLuVYAcY48fyXfWHO3zlZa9jnTV9D9kTnOOcuVneFGXeW+Nen85eYf1y4oLniSFPz tqbmhfOa3nuP/25eU8uRpvea523mH7Q0z9u2bd7mBc3z+AfcpoJ/wG3+X4NIlmRPD1kQ1cjG W9ebNTLF34p/ENXIxltfMWtkik8l3txdBNYr/qlZc7tQgI0GyJySorxEEG8MTZuk+97WO6Td z1wn3Vbevg5tK9yIl2/aVkiWZH/6tiKA8T9JskfTdWcUaWfnEZASCjjVfaEPNzBeW6TrzYVG HACWBsqRLDUUCBojHBavbdZ1S9G2tRHgCAX8xsbjdLJkNCHkvnsImDIhp6PVhLQzrWg/WXdW FtpPHFoAaD8hWZL9qfuJiLYFgxBtfJ/x1RFtJEuytlTvddsXyo7S6/YsQTC6tBciBCPJkuxP htE4+caOso+lXgrZysl3BLQ6+SbnCuF8rN1rCE7uJkSVkmRJ1p5K+ViHIlmlfKy8M4IxAaA9 VUqSJVmbYHxC+gb4sY11CEY+NIMqI8mSrD0wrvcskMG43rMcwejR/lI3wUiyJGsHjNMel8I4 HX+X4QXIospIsiRrE4wbSqQwbvgjgtEH0I0qI8mSrD0wbnBcL4Nxg+NNBGMSQA+qjCRLsjbB WLxcCmPxegSjH6AnVUaSJVmbYFzxKymMK95DMCYD5FJlJFmStQnGldK/Gr/hsWopqx/0QKwG APoAsUqyJPvTWRXQ9nivHxFtQYD+VBlJlmTtqYyPX/h7Wel7/Fo/gjEFYCCVPpIlWZtgvP2w FMaXxiAYQwDnUWUkWZK1B8YncgfIYHwidzeCMRVgKFVGkiVZm2BcWCeFceFLCMY0gOFUGUmW ZG2C8dlmKYy7KhCM7QBGUWUkWZK1B8aNGUwG48aMBxCM7QEuoMpIsiRrE4ylf5fCOAMQjB0A xlJlJFmStQnGxgIpjI0LEIzpABOoMpIsydoE4/cdpTB+PxvBmAFQTJWRZEnWHhifHD1IBuOT o+sRjJkAl1BlJFmStQnGlUukMK78AsHYEWA6VUaSJVmbYDx+pRTG44cQjJ0ALqfKSLIkaw+M m4bfKYNx0wj8d1M7A8ygykiyJGsTjHeVSmG8axeCsQtAhCojyZKsTTB+NlcK4yH876aeATCH KiPJkqw9MDb1/1QGY1P+LARjFsBcqowkS7I2wXi99KdjNi27CsEYBqiiykiyJGsTjAc2SmE8 8A2CMRughiojyZKsPTBu7tUkg3Fz78EIxq58ulQZSZZkbYJx8XtSGJdchmDsBvA7qowkS7L2 wPhU+1EyGJ9q/waCsTvAtVQZSZZkbYJx+hgpjNPvQTCeCbCUKiPJkqxNMK7aJIXx0SEIxh4A N1JlJFmStQnGaIMMxi2Qj2A8C+BmqowkS7L2wLjlor9IYZx4IYIxB2A5VUaSJdmfA8Z0vblj tN32EWSnQRBGQGookDwaIHNKHwBH8jAxuyuekbJ7expi92yAFXXELsmSrD2F9IH3pTA+eBGC sSfAnUAwkizJ2gPj+qrYz8npqDcE44ZkYB0gFZyOcCjgNOqsO1mfvcDhtiGyH7yz5cVbpd3v dpHuDe/hb0l/BXBPHe0NJEuyP31vENC29ZxtiLZzAP4CRBvJkqwtlXjr0GZZZdw6You0e1Ig 1h3/vLy15E3jeblrKBA81fPy1hm7ZGV46+Kz0MaQC3B/HW0MJEuy9mwMe/8shXE//kkIvQAe AoKRZEnWHhiPSn8sybZOAxGMvQH+RpWRZEnWHhi3jX1YCuNvpyAY8wDqqTKSLMnaBOPNXimM W35AMPJnz7VUGUmWZG2C8ceBMhi3e0MIxr4A66kykizJ2gPj9t/cLIVxSk8EYz+AJ6gykizJ 2gTjjYekMK7+DsHYH6CJKiPJkqxNML6xRwrjN/gvIOQDbKHKSLIkaw+MT3ctlMH49KhJCMYB AE9TZSRZkrUJxqrFUhjvfhzBeC7ATqqMJEuyNsH42gEpjAd3IxgHAjxHlZFkSdYeGJ/xb5HB +Ez/QgRjAcALVBlJlmRtgnHaTCmMy5oQjIUA+6kykizJ2gRj/StSGN/4I4LxPICXqTKSLMna BOM3x2Uw7uh6C4JxEMDrVBlJlmTtgXHH+e9KYazOQTAOBniTKiPJkqxNMN4ZlsL4bC2CcQjA O1QZSZZkbYLxw2MyGHemfIpgHApwgCojyZKsPTDu7F0uhbFkKoJxGMCHVBlJlmRtgnFJlRTG 9asQjEUAn1BlJFmStQnGLzdLYYxegGAcDnCIKiPJkqw9MD6bO10G47Pj7kYwjgA4TJWRZEn2 Z4BRRNv9NyLazgdoodJHsiRrU+l76LjsX2F99ul3pJXxSAZidSTAF1QZSZZk7WF1V1KuDMZd gzYiGEcBfA0EI8mSrD0wTkuRwrj8SQTjrwG+o8pIsiRrzzPjruZzEG2jAX6g0keyJGtT6ftm rOyZcbf7Q1ll3N3zQ8TqBQBRqowkS7L2sLq7uKMUxkUHEYwXAlNHEowkS7I2wPjwcCmM+6oR jL8BlkCVkWRJ1iYYj6XLYHwuA//rcGOA+agykizJ2gPjc0PWSWGc3QXBOBZYMlVGkiVZm2Bc vlIK4+YqBOM4YCGqjCRLsjbB+O52GYx7Ep5CMI4H1o4qI8mSrD0w7smR/rMbeybPRzBOAJZB lZFkSdYmGBeMkMK4aiKC8SJgnagykizJ2gTjnglSGI/7EIwTgWVRZSRZkrUHxufTLpfB+Pz5 lyEYJwHrSpWRZEnWJhhLJ0thvPMuBGMxsB5UGUmWZG2C8a07pTB+vAvBeDGws6kykizJ2gPj C6EsGYwv9O2IYJwMLJcqI8mSrE0wlkifGV9YWodgvARYHlVGkiVZm2BclyGF8bU+CMYpwPpT ZSRZkrUJxhPS/2tjbxj/I8ZTgZ1LlZFkSdYeGPdecK8UxsotCMZpwM6jykiyJGsTjPdKf4z4 3h34HzGeDmwIVUaSJVmbYPxM+v8z7gvch2C8FNhwqowkS7L2wLiv3w4pjJcdQjBeBmwkVUaS JVmbYFx6UgrjuhIE4+XALqDKSLIkaxOMrxZLYTzxIoKxBNgYqowkS7L2wPjiGdUyGF8c0xXB eAWwCVQZSZZkbYJx7jApjPeVIhhLgU2iykiyJGsTjFt3SWE8/AiCcQawS6gykizJ2gPj/s7S Z8b9hQEEYxmwaVQZSZZkfwYYRbTdcj2irRzY5VT6SJZkbaLtn7ch2iLASqm2kSzJ2kPb33Mq EG0zgUWotpEsydpE20IXom0WsNlU20iWZH8G2sCrt5BJ2+cbejpAe7MCVgYMGfj0hg0uUjwk wLs+awuGLYzLG7P4qr1qoDU08qvuim83WPUyo9e4GOrN4b+br7RoFJLR5z86k2bMnR+prays nV0OF1eUzpgbCddWhmdFasNzKsPlpbWl4ZmV1eHRkdLyGv7Z5Mo5ZZHwrNLayMLSRYWKWVUk Ul1ROi9SGC6uLq2oqaqsrg1HKsqrKudUcBc14YrK2nBZZUVFpKw2Uh7O6ZN37tmK/ESltZ7M t5sT8GRGGk7mV1RHZs2pqY1UR8oLwzXceaR6cGGfXgX54arS2tmDe4+NlM8pNcx7F/U9f8Kk ORVX9q6ZUab4LlZaG6XPfz6lyvnVZRFDK0VvYGr9u/kpfSFgdtmcPGh9eWJ27x3W/+zRk8b4 /Jhmqiy++sbPafxB7//e6cc5EXspeCQ4N+ByaL3xA48E33GrPwQ0qDc0MG18IJnx3nMTU1gd y03uqaeWu7WHtE2hHxzMQjx9QMDFQqpCkt7Q0PR7J/7guclvBkLgoFMWdzBRdSDQ7lTDta2G ZiWa2oIbz6rxqmvk1xsa2PVowMd4r+eDJ767dLF4eLfzLAN+8TOygF98xKnqBvSGBk59MOBn vDd6MniyOXrNTWIHU7cxKweX/Q93wHsTIJDgiPW2cXDZ3yzvvLTq1Hc+4wq3OjxZb2h45JJA EuO9PzqvcKtREY2PXNlNjY2xs6Lxc4YFEh2818/84rFzitupY0/qDY29+v3AD4z31lRULpxR OnduX/jFXYKALXKfqQbM2FJQwBY/H0hgvPcKi6GLDw5Uh8Z/z3Ck7rGAm/Feh3hk3SsF6kij 8KGRN9wT8Dh4L+t360rQDrmu1oNvaHL7rXaTm6/lRLtV34LN4Oa1HfwOWCIeunwmH9rBCsrl dzjCyh8EOXn7uEAi472dzCC0GXv7NU51rIDHu0YrQIeNrd9C/K75na0c/KmQO+C90Wg0y9rB n2Y5VCJH6Q05eLB74HzGe6PRE86Xo0ej0aHRB74Kfn5y6Lcrop25Uem30eh18F9dx/WGhB9c NdH/xX83+vS6BAm2+h9KoVITTJDV9WyknznEIxuB14uRVqnZePsUKwzXf8Ix5L0+seaGSleK +l2gcR5BQzfuDQSYKwVnprBCP7mF+T08eaKJ3+0YLJ7+5gi/cdYKeORg8yfJfv2ozEC4JWyb FvCwZL9xahWAve3WoMeRaBH3HSO5fNBjEb0d+zpZbUW70/lWpPR6Ui0G754yzSr0z5/kodd6 RSNf6DfKauSLnwbcDq1XFPD9GSzsMVgX3/HLLykBD1tIv+JIDFtIv76ZT5r3esUjX/9X0Grk W/fzkbw3LB751ospYYvJvvsBn6zWK8iO5lmpODsEVer9h3mVStWPiPEH4yMfdNHOKg6sH0L9 2UqPy7KXte1NQb1LjF6WrbVWY69n6rR5vzYFfuSKRhnU8U/5AeYXfA7BVwe9obB+9kclcCGR tXEkRWH+7D4tzCHQj4XGuRN73KzY9EeOjC0PO9quOcJmZq5jZ28odklqQhpa2M2bmhvO7U7N R/zz/ZHP3tL2+p3WKi2afyuVo5oK/3inw1LlmK7isFI5lKi4ybVSOeTVVHK5itW7iiOHfLqK ZpGuN6zSTXHTG0SXSPVMTbW3qSqa+SDFyGs58yGaD76VvWo986HazF+1VpmiuMlQGY9/03Pk 0DRNJcPyzq/S6uuJ/veV1AFHP0V1p16CXD5Uo/lLMXJZ5PLWeJdM4nJ5G5eCfezQI4qNUr7V kaE2HlZpHni/chLMynJbBWub9nLJ2BTbHDcOfTzZzxgIq8DhIbwKTLY6uB+eOc9v+QahJcCH zlOHdtMbGtoS9oTDTodPe3NmfQkcf8m4Y0/YwvGXvbzhsD/Je6ptXOD46++5Y28Y9yLH3/yh u99pOfY/R/lZsHur52O0VN9fJX81yQ3wq8kTekPq3y9K83/3Cy5N8SFvYc/z5UpTQx7/iNPi yFYecXyxPHD4fG4nZBhInraXIFLe35qPOPFbcot3o7aPcLhfs9qSW7ybtC1Zs1B+WLT6A6Nj u0xL6r2Km+Av+T0Ouliy1nAMUx/SAh0ECpJ2Gc8FOI3UY1oAWtVExHXqJ3wb1l40Kf+31oRW Xw20pC0TfzXwk76CiP+yoyW93c+l0+oLCAG7mcmSwtKSeZ5WWLSACA0YMog/h7RkTtSSMgC6 TfzRpiVzU/zRJqA/Bwi23sxd8Vtvorr1BoQPD6fNJVi+8Nvm1isIfvggOgQqnwqCn50SH3y/ dfCzM+OD79WD7z+dwy8Ifs6jsuDnPH/q4Od8Ex/8VOvgn83ig59kBj/19A2/IPh5N8uCn3fn qYOf91x88D3Wwc97KT74ySj4ntM1/ILgD7xOFvyBj7QJfvyrmZaCoNJzFpIRHB0LUpX4t0dG 8e9vWgraaWrYl/mdCVZU/3pGP/j4jjPvXfdXYMgKe+ulSHbEViLNPE2zHxiGIHr2bSk4r6P2 el80n3HafBbctnRmJ7Ccz0XafJCVaD6TzPnohhaaNZpmwdPBV2rDlprzNU1kJdJcaGrqhvw6 T29Y83bFLlWJiz4315hlq1eO3T9/A+zYtH7K8qRHDAeufzV9/3r3rIlVt545NTw66p+pOBGc Ogru0KTVF/SiU15BvWKQpuWCyMEazUGapYMdikGetYOdmoM8SwfqOTPf2sFbmgPNQrA7FRwV vELSbljEXMGXbZgTrH6hSkoOX4gru4xyDHCLZ1bYRfOUY3VrhUPREVowlcKi1kc+0dNc4SX0 NBe7RE9zhVPoaa711VNvOI1qlSCN4hnNdrAT94/7avuAf9Z+XVA0cPYYx6o/bz340eJHM7r+ IXHyk5+XaK+N47Nd38VGqR/Fv91sKbxde8IRv8FsGZbOn586Wr0lGjZScFpOMfg7jU8PgmI+ bLoWaR7fNyzfAw0r1d4D6RbGgqH1GNaorYT2DbVgRX59xDybGMuJVmT0pEK/S/9bJoLBv3mF L2ehxbf1LWMSeTl3ikeO32wmguDmxx/Qbp4Para8+fGfaDffbPWNSsuUS+OLQlJIm6fgZcaU a9SXGbgXzXh6hezRf/oi49Ff/CUIN2DIQJD805fJkj/YKvmTTqf0F8S6bIjswFx2ISreSjQF S192S/zS+0JacRYsfdnd6tL7xdOZdaZs6WcNN5beb2XAkIFg6WddKFv6UJul950+iy+IdcWP sqWv7Iq/p/s/UEsHCOus+CLHGwAA37sBAFBLAQIUAxQACAAIAKo+IlHrrPgixxsAAN+7AQAS ACAAAAAAAAAAAACkgQAAAABidG1vbi1tMmFlYnQtMi5sb2dVVA0AB1AzT19TM09fUDNPX3V4 CwABBAAAAAAEAAAAAFBLBQYAAAAAAQABAGAAAAAnHAAAAAA= --------------EA2EFEED3655352BC8E8D3C6-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aIZdO7p7T1/QXQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:02:18 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id oILzObp7T1+SwgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:02:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2368CA26F7; Wed, 2 Sep 2020 13:02:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726933AbgIBLCA (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:02:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:45526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbgIBLA6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:00:58 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B4462098B; Wed, 2 Sep 2020 11:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044458; bh=j4+uze57jaKSPdl86kFYD2e9uQbKV5r15/uY12dIyTg=; h=From:To:Cc:Subject:Date:From; b=KQUO8aM0q8lsyoUUjY1fm6YU4t2DKhsqnX34r/3z+mUnF/A0LAw4CpM+HoGp5C8jE ALIP8QBgkZVfrtSQC+aqQvkiNcSo74O8YlA/2qydObCgkoRhhadHuwtgZFMwm+W+Pt XNZGfKbfo3XL74KKdqVUQNqBunRG7kfSVX5o+8Uo= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH 00/10] USB: new USB control message helper functions Date: Wed, 2 Sep 2020 13:01:02 +0200 Message-Id: <20200902110115.1994491-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.36 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2368CA26F7 X-Rspamd-UID: eb03ec In a recent discussion about a USB networking bug found by syzbot, and fixed by Himadri Pandya, the design of the existing usb_control_msg() call was brought up as not being the "nicest" thing to use by Dmitry Vyukov: https://lore.kernel.org/r/CACT4Y+YbDODLRFn8M5QcY4CazhpeCaunJnP_udXtAs0rYoASSg@mail.gmail.com The function makes it hard to get right, in that it will return the number of bytes sent/received, but almost no one checks to see if a short read/write happens. With a malicious, or broken, USB device, this can cause drivers to act on data that they did not anticipate, and sometimes copy internal kernel data out to userspace. So let's fix this up by creating two new functions, usb_control_msg_send() and usb_control_msg_recv(). These functions either complete the full transation, or they return an error, a short send/recv is now an error. They also accept data off of the stack, saving individual drivers the pain of having to constantly allocate memory on their own for tiny messages, thereby saving overall kernel code space. The api also does not require a raw USB "pipe" to be sent to the function, as we know the direction, so just pass in the endpoint number instead, again making it easier on the USB driver author to use. This series first takes a helper function out of the sound core for verifying USB endpoints to be able to use internally, and then adds the new functions, converts over some internal USB code to use them, and then starts to clean up some drivers using these new functions, as an example of the savings that can happen by using these functions. Thanks to Dmitry and Himadri for the idea on how to do all of this. greg k-h Greg Kroah-Hartman (10): USB: move snd_usb_pipe_sanity_check into the USB core USB: add usb_control_msg_send() and usb_control_msg_recv() USB: core: message.c: use usb_control_msg_send() in a few places USB: core: hub.c: use usb_control_msg_send() in a few places USB: legousbtower: use usb_control_msg_recv() sound: usx2y: move to use usb_control_msg_send() sound: 6fire: move to use usb_control_msg_send() and usb_control_msg_recv() sound: line6: move to use usb_control_msg_send() and usb_control_msg_recv() sound: hiface: move to use usb_control_msg_send() Bluetooth: ath3k: use usb_control_msg_send() and usb_control_msg_recv() drivers/bluetooth/ath3k.c | 90 +++++------------ drivers/usb/core/hub.c | 128 +++++++++--------------- drivers/usb/core/message.c | 171 ++++++++++++++++++++++++++++---- drivers/usb/core/urb.c | 29 ++++-- drivers/usb/misc/legousbtower.c | 60 ++++------- include/linux/usb.h | 7 ++ sound/usb/6fire/firmware.c | 38 +++---- sound/usb/helper.c | 16 +-- sound/usb/helper.h | 1 - sound/usb/hiface/pcm.c | 14 ++- sound/usb/line6/driver.c | 69 +++++-------- sound/usb/line6/podhd.c | 17 ++-- sound/usb/line6/toneport.c | 8 +- sound/usb/mixer_scarlett_gen2.c | 2 +- sound/usb/quirks.c | 12 +-- sound/usb/usx2y/us122l.c | 42 ++------ 16 files changed, 345 insertions(+), 359 deletions(-) -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kNUPK8d7T18EaAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:02:31 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id yI7FKcd7T1+rJAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:02:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E1D79A57BB; Wed, 2 Sep 2020 13:02:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbgIBLB6 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:01:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:45744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726526AbgIBLBN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:13 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0C0B214D8; Wed, 2 Sep 2020 11:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044472; bh=E1iutx9WJV6ikxgtXBWCaYP7b/Z6blJgiTOA58pOvyk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gt3NCBHKSdY2RjF68I/q2GKRHZrk3JtGCfRWwDIR9aFOSwqPHhPYgFrw/MEL43Huz CHE4lelNoCwVT4310VKgByrBGxUphAUvZfDjn0OLhQ7Vf7R1/jJ8ahgR0xBzFwuBT8 D1HiUdB2YP2oYhW5TzFInNrihD1IWDfwn3VfTq8A= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH 02/10] USB: add usb_control_msg_send() and usb_control_msg_recv() Date: Wed, 2 Sep 2020 13:01:04 +0200 Message-Id: <20200902110115.1994491-3-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: E1D79A57BB X-Rspamd-UID: 487877 New core functions to make sending/receiving USB control messages easier and saner. In discussions, it turns out that the large majority of users of usb_control_msg() do so in potentially incorrect ways. The most common issue is where a "short" message is received, yet never detected properly due to "incorrect" error handling. Handle all of this in the USB core with two new functions to try to make working with USB control messages simpler. No more need for dynamic data, messages can be on the stack, and only "complete" send/receive will work without causing an error. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/usb/core/message.c | 133 +++++++++++++++++++++++++++++++++++++ include/linux/usb.h | 6 ++ 2 files changed, 139 insertions(+) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 6197938dcc2d..6aa49b237717 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -162,6 +162,139 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, } EXPORT_SYMBOL_GPL(usb_control_msg); +/** + * usb_control_msg_send - Builds a control "send" message, sends it off and waits for completion + * @dev: pointer to the usb device to send the message to + * @endpoint: endpoint to send the message to + * @request: USB message request value + * @requesttype: USB message request type value + * @value: USB message value + * @index: USB message index value + * @driver_data: pointer to the data to send + * @size: length in bytes of the data to send + * @timeout: time in msecs to wait for the message to complete before timing + * out (if 0 the wait is forever) + * + * Context: !in_interrupt () + * + * This function sends a control message to a specified endpoint that is not + * expected to fill in a response (i.e. a "send message") and waits for the + * message to complete, or timeout. + * + * Do not use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb(). If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. + * + * The data pointer can be made to a reference on the stack, or anywhere else, + * as it will not be modified at all. This does not have the restriction that + * usb_control_msg() has where the data pointer must be to dynamically allocated + * memory (i.e. memory that can be successfully DMAed to a device). + * + * Return: If successful, 0 is returned, Otherwise, a negative error number. + */ +int usb_control_msg_send(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + const void *driver_data, __u16 size, int timeout) +{ + unsigned int pipe = usb_sndctrlpipe(dev, endpoint); + int ret; + u8 *data = NULL; + + if (usb_pipe_type_check(dev, pipe)) + return -EINVAL; + + if (size) { + data = kmemdup(driver_data, size, GFP_KERNEL); + if (!data) + return -ENOMEM; + } + + ret = usb_control_msg(dev, pipe, request, requesttype, value, index, + data, size, timeout); + kfree(data); + + if (ret < 0) + return ret; + if (ret == size) + return 0; + return -EINVAL; +} +EXPORT_SYMBOL_GPL(usb_control_msg_send); + +/** + * usb_control_msg_recv - Builds a control "receive" message, sends it off and waits for completion + * @dev: pointer to the usb device to send the message to + * @endpoint: endpoint to send the message to + * @request: USB message request value + * @requesttype: USB message request type value + * @value: USB message value + * @index: USB message index value + * @driver_data: pointer to the data to be filled in by the message + * @size: length in bytes of the data to be received + * @timeout: time in msecs to wait for the message to complete before timing + * out (if 0 the wait is forever) + * + * Context: !in_interrupt () + * + * This function sends a control message to a specified endpoint that is + * expected to fill in a response (i.e. a "receive message") and waits for the + * message to complete, or timeout. + * + * Do not use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb(). If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. + * + * The data pointer can be made to a reference on the stack, or anywhere else + * that can be successfully written to. This function does not have the + * restriction that usb_control_msg() has where the data pointer must be to + * dynamically allocated memory (i.e. memory that can be successfully DMAed to a + * device). + * + * The "whole" message must be properly received from the device in order for + * this function to be successful. If a device returns less than the expected + * amount of data, then the function will fail. Do not use this for messages + * where a variable amount of data might be returned. + * + * Return: If successful, 0 is returned, Otherwise, a negative error number. + */ +int usb_control_msg_recv(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + void *driver_data, __u16 size, int timeout) +{ + unsigned int pipe = usb_rcvctrlpipe(dev, endpoint); + int ret; + u8 *data; + + if (!size || !driver_data || usb_pipe_type_check(dev, pipe)) + return -EINVAL; + + data = kmalloc(size, GFP_KERNEL); + if (!data) + return -ENOMEM; + + ret = usb_control_msg(dev, pipe, request, requesttype, value, index, + data, size, timeout); + + if (ret < 0) + goto exit; + + if (ret == size) { + memcpy(driver_data, data, size); + ret = 0; + } else { + ret = -EINVAL; + } + +exit: + kfree(data); + return ret; +} +EXPORT_SYMBOL_GPL(usb_control_msg_recv); + /** * usb_interrupt_msg - Builds an interrupt urb, sends it off and waits for completion * @usb_dev: pointer to the usb device to send the message to diff --git a/include/linux/usb.h b/include/linux/usb.h index 0b3963d7ec38..a5460f08126e 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1802,6 +1802,12 @@ extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, int timeout); /* wrappers around usb_control_msg() for the most common standard requests */ +int usb_control_msg_send(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + const void *data, __u16 size, int timeout); +int usb_control_msg_recv(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + void *data, __u16 size, int timeout); extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype, unsigned char descindex, void *buf, int size); extern int usb_get_status(struct usb_device *dev, -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yH2EHNl7T1/oogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:02:49 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iES+Gtl7T189rQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:02:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D68F3A5BB0; Wed, 2 Sep 2020 13:02:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726510AbgIBLB5 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:01:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:45468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726124AbgIBLA4 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:00:56 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED8832065E; Wed, 2 Sep 2020 11:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044455; bh=SjaZIwH/tb3JNsYjS5SxojsLOb58EBpAvKy4ZzfcdhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PxWMEIAiuOe+LaXSvA6XNwEqeDVZ8M4g4r147HDTnNZhnZHBuvO2FzAUrEls+SsS1 0TAm7ItoPeKbcQZOoPiEXSuT/+en42csi8D0uC2dcVzmMK+eEyIpR0/rF2pUMlpgWX o7hblx/CJj95taOMG3pgG/oo6o4tqRBu/W/hg6CU= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Eli Billauer <eli.billauer@gmail.com>, Emiliano Ingrassia <ingrassia@epigenesys.com>, Alan Stern <stern@rowland.harvard.edu>, Alexander Tsoy <alexander@tsoy.me>, "Geoffrey D. Bennett" <g@b4.vu>, Jussi Laako <jussi@sonarnerd.net>, Nick Kossifidis <mickflemm@gmail.com>, Dmitry Panchenko <dmitry@d-systems.ee>, Chris Wulff <crwulff@gmail.com>, Jesus Ramos <jesus-ramos@live.com> Subject: [PATCH 01/10] USB: move snd_usb_pipe_sanity_check into the USB core Date: Wed, 2 Sep 2020 13:01:03 +0200 Message-Id: <20200902110115.1994491-2-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.48 / 15.00 / 200.00 X-Rspamd-Queue-Id: D68F3A5BB0 X-Rspamd-UID: 0e1ded snd_usb_pipe_sanity_check() is a great function, so let's move it into the USB core so that other parts of the kernel, including the USB core, can call it. Name it usb_pipe_type_check() to match the existing usb_urb_ep_type_check() call, which now uses this function. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> Cc: Eli Billauer <eli.billauer@gmail.com> Cc: Emiliano Ingrassia <ingrassia@epigenesys.com> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Alexander Tsoy <alexander@tsoy.me> Cc: "Geoffrey D. Bennett" <g@b4.vu> Cc: Jussi Laako <jussi@sonarnerd.net> Cc: Nick Kossifidis <mickflemm@gmail.com> Cc: Dmitry Panchenko <dmitry@d-systems.ee> Cc: Chris Wulff <crwulff@gmail.com> Cc: Jesus Ramos <jesus-ramos@live.com> Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: alsa-devel@alsa-project.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/usb/core/urb.c | 29 ++++++++++++++++++++++------- include/linux/usb.h | 1 + sound/usb/helper.c | 16 +--------------- sound/usb/helper.h | 1 - sound/usb/mixer_scarlett_gen2.c | 2 +- sound/usb/quirks.c | 12 ++++++------ 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 27e83e55a590..45bc2914c1ba 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -192,24 +192,39 @@ static const int pipetypes[4] = { }; /** - * usb_urb_ep_type_check - sanity check of endpoint in the given urb - * @urb: urb to be checked + * usb_pipe_type_check - sanity check of a specific pipe for a usb device + * @dev: struct usb_device to be checked + * @pipe: pipe to check * * This performs a light-weight sanity check for the endpoint in the - * given urb. It returns 0 if the urb contains a valid endpoint, otherwise - * a negative error code. + * given usb device. It returns 0 if the pipe is a valid for the specific usb + * device, otherwise a negative error code. */ -int usb_urb_ep_type_check(const struct urb *urb) +int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe) { const struct usb_host_endpoint *ep; - ep = usb_pipe_endpoint(urb->dev, urb->pipe); + ep = usb_pipe_endpoint(dev, pipe); if (!ep) return -EINVAL; - if (usb_pipetype(urb->pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) + if (usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) return -EINVAL; return 0; } +EXPORT_SYMBOL_GPL(usb_pipe_type_check); + +/** + * usb_urb_ep_type_check - sanity check of endpoint in the given urb + * @urb: urb to be checked + * + * This performs a light-weight sanity check for the endpoint in the + * given urb. It returns 0 if the urb contains a valid endpoint, otherwise + * a negative error code. + */ +int usb_urb_ep_type_check(const struct urb *urb) +{ + return usb_pipe_type_check(urb->dev, urb->pipe); +} EXPORT_SYMBOL_GPL(usb_urb_ep_type_check); /** diff --git a/include/linux/usb.h b/include/linux/usb.h index 20c555db4621..0b3963d7ec38 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1764,6 +1764,7 @@ static inline int usb_urb_dir_out(struct urb *urb) return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; } +int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe); int usb_urb_ep_type_check(const struct urb *urb); void *usb_alloc_coherent(struct usb_device *dev, size_t size, diff --git a/sound/usb/helper.c b/sound/usb/helper.c index 4c12cc5b53fd..cf92d7110773 100644 --- a/sound/usb/helper.c +++ b/sound/usb/helper.c @@ -63,20 +63,6 @@ void *snd_usb_find_csint_desc(void *buffer, int buflen, void *after, u8 dsubtype return NULL; } -/* check the validity of pipe and EP types */ -int snd_usb_pipe_sanity_check(struct usb_device *dev, unsigned int pipe) -{ - static const int pipetypes[4] = { - PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT - }; - struct usb_host_endpoint *ep; - - ep = usb_pipe_endpoint(dev, pipe); - if (!ep || usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) - return -EINVAL; - return 0; -} - /* * Wrapper for usb_control_msg(). * Allocates a temp buffer to prevent dmaing from/to the stack. @@ -89,7 +75,7 @@ int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, void *buf = NULL; int timeout; - if (snd_usb_pipe_sanity_check(dev, pipe)) + if (usb_pipe_type_check(dev, pipe)) return -EINVAL; if (size > 0) { diff --git a/sound/usb/helper.h b/sound/usb/helper.h index 5e8a18b4e7b9..f5b4c6647e4d 100644 --- a/sound/usb/helper.h +++ b/sound/usb/helper.h @@ -7,7 +7,6 @@ unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size); void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype); void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype); -int snd_usb_pipe_sanity_check(struct usb_device *dev, unsigned int pipe); int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size); diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 0ffff7640892..9609c6d9655c 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -1978,7 +1978,7 @@ static int scarlett2_mixer_status_create(struct usb_mixer_interface *mixer) return 0; } - if (snd_usb_pipe_sanity_check(dev, pipe)) + if (usb_pipe_type_check(dev, pipe)) return -EINVAL; mixer->urb = usb_alloc_urb(0, GFP_KERNEL); diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index abf99b814a0f..fc3aab04a0bc 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -846,7 +846,7 @@ static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev) static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 }; void *buf; - if (snd_usb_pipe_sanity_check(dev, usb_sndintpipe(dev, 0x05))) + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x05))) return -EINVAL; buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); if (!buf) @@ -875,7 +875,7 @@ static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev) { int ret; - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) return -EINVAL; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE, @@ -984,7 +984,7 @@ static int snd_usb_axefx3_boot_quirk(struct usb_device *dev) dev_dbg(&dev->dev, "Waiting for Axe-Fx III to boot up...\n"); - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) return -EINVAL; /* If the Axe-Fx III has not fully booted, it will timeout when trying * to enable the audio streaming interface. A more generous timeout is @@ -1018,7 +1018,7 @@ static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, { int err, actual_length; - if (snd_usb_pipe_sanity_check(dev, usb_sndintpipe(dev, 0x01))) + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x01))) return -EINVAL; err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x01), buf, *length, &actual_length, 1000); @@ -1030,7 +1030,7 @@ static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, memset(buf, 0, buf_size); - if (snd_usb_pipe_sanity_check(dev, usb_rcvintpipe(dev, 0x82))) + if (usb_pipe_type_check(dev, usb_rcvintpipe(dev, 0x82))) return -EINVAL; err = usb_interrupt_msg(dev, usb_rcvintpipe(dev, 0x82), buf, buf_size, &actual_length, 1000); @@ -1117,7 +1117,7 @@ static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) { int ret; - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) return -EINVAL; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cFrALt57T18EaAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:02:54 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 0CZVLN57T182NAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:02:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9B1B6A5B6C; Wed, 2 Sep 2020 13:02:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727026AbgIBLCi (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:02:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:45890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726657AbgIBLBZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:25 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5858521582; Wed, 2 Sep 2020 11:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044484; bh=TQYCGifWGQVmBMPr9KtgIH6n55KKlRaC54GjvFdP+6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A3h4bu8QC01c5lZypDBpqAAXKu6k5WnOm/OxNsLhUGCSeCbFVv8coBl8biydycLUi +OVQL2mHaxJwN0H87TiybUomBdxpQmGwv0ADz9uXxC9VwLGcBg3h260DXVmDkdgQxJ hTnIFzbxNoUYN9GMQ+WF0Qe99GnFfbMi4m/wcreo= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH 07/10] sound: 6fire: move to use usb_control_msg_send() and usb_control_msg_recv() Date: Wed, 2 Sep 2020 13:01:09 +0200 Message-Id: <20200902110115.1994491-8-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.51 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9B1B6A5B6C X-Rspamd-UID: d3fedf The usb_control_msg_send() and usb_control_msg_recv() calls can return an error if a "short" write/read happens, so move the driver over to using those calls instead, saving some logic in the wrapper functions that were being used in this driver. This also resolves a long-staging bug where data on the stack was being sent in a USB control message, which was not allowed. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: alsa-devel@alsa-project.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- sound/usb/6fire/firmware.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c index 69137c14d0dc..5b8994070c96 100644 --- a/sound/usb/6fire/firmware.c +++ b/sound/usb/6fire/firmware.c @@ -158,29 +158,17 @@ static int usb6fire_fw_ihex_init(const struct firmware *fw, static int usb6fire_fw_ezusb_write(struct usb_device *device, int type, int value, char *data, int len) { - int ret; - - ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), type, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - value, 0, data, len, HZ); - if (ret < 0) - return ret; - else if (ret != len) - return -EIO; - return 0; + return usb_control_msg_send(device, 0, type, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + value, 0, data, len, HZ); } static int usb6fire_fw_ezusb_read(struct usb_device *device, int type, int value, char *data, int len) { - int ret = usb_control_msg(device, usb_rcvctrlpipe(device, 0), type, - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, - 0, data, len, HZ); - if (ret < 0) - return ret; - else if (ret != len) - return -EIO; - return 0; + return usb_control_msg_recv(device, 0, type, + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + value, 0, data, len, HZ); } static int usb6fire_fw_fpga_write(struct usb_device *device, @@ -230,7 +218,7 @@ static int usb6fire_fw_ezusb_upload( /* upload firmware image */ data = 0x01; /* stop ezusb cpu */ ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1); - if (ret < 0) { + if (ret) { kfree(rec); release_firmware(fw); dev_err(&intf->dev, @@ -242,7 +230,7 @@ static int usb6fire_fw_ezusb_upload( while (usb6fire_fw_ihex_next_record(rec)) { /* write firmware */ ret = usb6fire_fw_ezusb_write(device, 0xa0, rec->address, rec->data, rec->len); - if (ret < 0) { + if (ret) { kfree(rec); release_firmware(fw); dev_err(&intf->dev, @@ -257,7 +245,7 @@ static int usb6fire_fw_ezusb_upload( if (postdata) { /* write data after firmware has been uploaded */ ret = usb6fire_fw_ezusb_write(device, 0xa0, postaddr, postdata, postlen); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to upload ezusb firmware %s: post urb.\n", fwname); @@ -267,7 +255,7 @@ static int usb6fire_fw_ezusb_upload( data = 0x00; /* resume ezusb cpu */ ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to upload ezusb firmware %s: end message.\n", fwname); @@ -302,7 +290,7 @@ static int usb6fire_fw_fpga_upload( end = fw->data + fw->size; ret = usb6fire_fw_ezusb_write(device, 8, 0, NULL, 0); - if (ret < 0) { + if (ret) { kfree(buffer); release_firmware(fw); dev_err(&intf->dev, @@ -327,7 +315,7 @@ static int usb6fire_fw_fpga_upload( kfree(buffer); ret = usb6fire_fw_ezusb_write(device, 9, 0, NULL, 0); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to upload fpga firmware: end urb.\n"); return ret; @@ -363,7 +351,7 @@ int usb6fire_fw_init(struct usb_interface *intf) u8 buffer[12]; ret = usb6fire_fw_ezusb_read(device, 1, 0, buffer, 8); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to receive device firmware state.\n"); return ret; -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GDSLCuR7T1/QXQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:03:00 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4Oc9CeR7T1+rJAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:03:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DA826A28AA; Wed, 2 Sep 2020 13:02:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbgIBLCl (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:02:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:45920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbgIBLB1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:27 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 95EEF215A4; Wed, 2 Sep 2020 11:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044487; bh=4nciSiJuiLfCNDwthm0DHhCLPxmhbcbA96IVDP+fm5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M7HzxDzxQPVsvfs7TUHkC0PUSy8acczLBwrMMXux1FOKUxi9GUr+Y52AGahY94Kf2 pAt8zbr/wOgDktGUIPKUh9Ae7Ug0YBjQrH84jIFYDXOg8XCdNQV6mEnQebwjR+NpYo fnoD5k19JxTQHNrvNx3i5LKytO3PuP4S0JKKHOjo= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH 7/9] sound: line6: convert to use new usb control function... Date: Wed, 2 Sep 2020 13:01:10 +0200 Message-Id: <20200902110115.1994491-9-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: DA826A28AA X-Rspamd-UID: 485334 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- sound/usb/line6/driver.c | 69 +++++++++++++++----------------------- sound/usb/line6/podhd.c | 17 ++++------ sound/usb/line6/toneport.c | 8 ++--- 3 files changed, 37 insertions(+), 57 deletions(-) diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 60674ce4879b..601292c51491 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -337,23 +337,18 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, { struct usb_device *usbdev = line6->usbdev; int ret; - unsigned char *len; + u8 len; unsigned count; if (address > 0xffff || datalen > 0xff) return -EINVAL; - len = kmalloc(1, GFP_KERNEL); - if (!len) - return -ENOMEM; - /* query the serial number: */ - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - (datalen << 8) | 0x21, address, - NULL, 0, LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + (datalen << 8) | 0x21, address, NULL, 0, + LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "read request failed (error %d)\n", ret); goto exit; } @@ -362,45 +357,41 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { mdelay(LINE6_READ_WRITE_STATUS_DELAY); - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | - USB_DIR_IN, - 0x0012, 0x0000, len, 1, - LINE6_TIMEOUT * HZ); - if (ret < 0) { + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0012, 0x0000, &len, 1, + LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "receive length failed (error %d)\n", ret); goto exit; } - if (*len != 0xff) + if (len != 0xff) break; } ret = -EIO; - if (*len == 0xff) { + if (len == 0xff) { dev_err(line6->ifcdev, "read failed after %d retries\n", count); goto exit; - } else if (*len != datalen) { + } else if (len != datalen) { /* should be equal or something went wrong */ dev_err(line6->ifcdev, "length mismatch (expected %d, got %d)\n", - (int)datalen, (int)*len); + (int)datalen, len); goto exit; } /* receive the result: */ - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, - 0x0013, 0x0000, data, datalen, - LINE6_TIMEOUT * HZ); - - if (ret < 0) + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0013, 0x0000, data, datalen, LINE6_TIMEOUT * HZ); + if (ret) dev_err(line6->ifcdev, "read failed (error %d)\n", ret); exit: - kfree(len); return ret; } EXPORT_SYMBOL_GPL(line6_read_data); @@ -423,12 +414,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, if (!status) return -ENOMEM; - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - 0x0022, address, data, datalen, - LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + 0x0022, address, data, datalen, LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "write request failed (error %d)\n", ret); goto exit; @@ -437,14 +426,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { mdelay(LINE6_READ_WRITE_STATUS_DELAY); - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), - 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | - USB_DIR_IN, - 0x0012, 0x0000, - status, 1, LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0012, 0x0000, status, 1, LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "receiving status failed (error %d)\n", ret); goto exit; diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index eef45f7fef0d..a1261f55d62b 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -183,29 +183,25 @@ static const struct attribute_group podhd_dev_attr_group = { static int podhd_dev_start(struct usb_line6_podhd *pod) { int ret; - u8 *init_bytes; + u8 init_bytes[8]; int i; struct usb_device *usbdev = pod->line6.usbdev; - init_bytes = kmalloc(8, GFP_KERNEL); - if (!init_bytes) - return -ENOMEM; - - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), + ret = usb_control_msg_send(usbdev, 0, 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 0x11, 0, NULL, 0, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(pod->line6.ifcdev, "read request failed (error %d)\n", ret); goto exit; } /* NOTE: looks like some kind of ping message */ - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, + ret = usb_control_msg_recv(usbdev, 0, 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 0x11, 0x0, init_bytes, 3, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(pod->line6.ifcdev, "receive length failed (error %d)\n", ret); goto exit; @@ -220,13 +216,12 @@ static int podhd_dev_start(struct usb_line6_podhd *pod) goto exit; } - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), + ret = usb_control_msg_send(usbdev, 0, USB_REQ_SET_FEATURE, USB_TYPE_STANDARD | USB_RECIP_DEVICE | USB_DIR_OUT, 1, 0, NULL, 0, LINE6_TIMEOUT * HZ); exit: - kfree(init_bytes); return ret; } diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 94dd5e7ab2e6..a9b56085b76a 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -126,11 +126,11 @@ static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2) { int ret; - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(&usbdev->dev, "send failed (error %d)\n", ret); return ret; } -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4DrxFmR8T1/QXQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:05:08 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id mGezFWR8T1/Q4gAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:05:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E6829A2A33; Wed, 2 Sep 2020 13:05:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727838AbgIBLDi (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:03:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:45716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbgIBLBK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:10 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1A6792137B; Wed, 2 Sep 2020 11:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044469; bh=gjlI9Gga3bx1Zf/LGWOYJ4nihY5+cfkZy7nlCQlaazY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2XE3WeRuxlNb6+ZPPAgtZXFp7dVh6G/BByCKuHQz2l8cpuv2S/8ruzkJmq3jnnP8M dZs8N8pEDMx5xKbZRkXlsHM17Hx0ONV/GzfFLcj2skOmQY5LyDNcedLKpquF984ESR FdnTGT2VZ/QXSgfFbdoqd2YHbcPKo1ACwoTBVicw= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH 10/10] Bluetooth: ath3k: use usb_control_msg_send() and usb_control_msg_recv() Date: Wed, 2 Sep 2020 13:01:15 +0200 Message-Id: <20200902110115.1994491-14-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.16 / 15.00 / 200.00 X-Rspamd-Queue-Id: E6829A2A33 X-Rspamd-UID: 84df12 The usb_control_msg_send() and usb_control_msg_recv() calls can return an error if a "short" write/read happens, and they can handle data off of the stack, so move the driver over to using those calls instead, saving some logic when dynamically allocating memory. Cc: Marcel Holtmann <marcel@holtmann.org> Cc: Johan Hedberg <johan.hedberg@gmail.com> Cc: linux-bluetooth@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/bluetooth/ath3k.c | 90 +++++++++++---------------------------- 1 file changed, 26 insertions(+), 64 deletions(-) diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index 4ce270513695..1472cccfd0b3 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c @@ -212,19 +212,16 @@ static int ath3k_load_firmware(struct usb_device *udev, BT_DBG("udev %p", udev); - pipe = usb_sndctrlpipe(udev, 0); - send_buf = kmalloc(BULK_SIZE, GFP_KERNEL); if (!send_buf) { BT_ERR("Can't allocate memory chunk for firmware"); return -ENOMEM; } - memcpy(send_buf, firmware->data, FW_HDR_SIZE); - err = usb_control_msg(udev, pipe, USB_REQ_DFU_DNLOAD, USB_TYPE_VENDOR, - 0, 0, send_buf, FW_HDR_SIZE, - USB_CTRL_SET_TIMEOUT); - if (err < 0) { + err = usb_control_msg_send(udev, 0, USB_REQ_DFU_DNLOAD, USB_TYPE_VENDOR, + 0, 0, firmware->data, FW_HDR_SIZE, + USB_CTRL_SET_TIMEOUT); + if (err) { BT_ERR("Can't change to loading configuration err"); goto error; } @@ -259,44 +256,17 @@ static int ath3k_load_firmware(struct usb_device *udev, static int ath3k_get_state(struct usb_device *udev, unsigned char *state) { - int ret, pipe = 0; - char *buf; - - buf = kmalloc(sizeof(*buf), GFP_KERNEL); - if (!buf) - return -ENOMEM; - - pipe = usb_rcvctrlpipe(udev, 0); - ret = usb_control_msg(udev, pipe, ATH3K_GETSTATE, - USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, - buf, sizeof(*buf), USB_CTRL_SET_TIMEOUT); - - *state = *buf; - kfree(buf); - - return ret; + return usb_control_msg_recv(udev, 0, ATH3K_GETSTATE, + USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, + state, 1, USB_CTRL_SET_TIMEOUT); } static int ath3k_get_version(struct usb_device *udev, struct ath3k_version *version) { - int ret, pipe = 0; - struct ath3k_version *buf; - const int size = sizeof(*buf); - - buf = kmalloc(size, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - pipe = usb_rcvctrlpipe(udev, 0); - ret = usb_control_msg(udev, pipe, ATH3K_GETVERSION, - USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, - buf, size, USB_CTRL_SET_TIMEOUT); - - memcpy(version, buf, size); - kfree(buf); - - return ret; + return usb_control_msg_recv(udev, 0, ATH3K_GETVERSION, + USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, + version, sizeof(*version), USB_CTRL_SET_TIMEOUT); } static int ath3k_load_fwfile(struct usb_device *udev, @@ -316,13 +286,10 @@ static int ath3k_load_fwfile(struct usb_device *udev, } size = min_t(uint, count, FW_HDR_SIZE); - memcpy(send_buf, firmware->data, size); - pipe = usb_sndctrlpipe(udev, 0); - ret = usb_control_msg(udev, pipe, ATH3K_DNLOAD, - USB_TYPE_VENDOR, 0, 0, send_buf, - size, USB_CTRL_SET_TIMEOUT); - if (ret < 0) { + ret = usb_control_msg_send(udev, 0, ATH3K_DNLOAD, USB_TYPE_VENDOR, 0, 0, + firmware->data, size, USB_CTRL_SET_TIMEOUT); + if (ret) { BT_ERR("Can't change to loading configuration err"); kfree(send_buf); return ret; @@ -355,23 +322,19 @@ static int ath3k_load_fwfile(struct usb_device *udev, return 0; } -static int ath3k_switch_pid(struct usb_device *udev) +static void ath3k_switch_pid(struct usb_device *udev) { - int pipe = 0; - - pipe = usb_sndctrlpipe(udev, 0); - return usb_control_msg(udev, pipe, USB_REG_SWITCH_VID_PID, - USB_TYPE_VENDOR, 0, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); + usb_control_msg_send(udev, 0, USB_REG_SWITCH_VID_PID, USB_TYPE_VENDOR, + 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } static int ath3k_set_normal_mode(struct usb_device *udev) { unsigned char fw_state; - int pipe = 0, ret; + int ret; ret = ath3k_get_state(udev, &fw_state); - if (ret < 0) { + if (ret) { BT_ERR("Can't get state to change to normal mode err"); return ret; } @@ -381,10 +344,9 @@ static int ath3k_set_normal_mode(struct usb_device *udev) return 0; } - pipe = usb_sndctrlpipe(udev, 0); - return usb_control_msg(udev, pipe, ATH3K_SET_NORMAL_MODE, - USB_TYPE_VENDOR, 0, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, ATH3K_SET_NORMAL_MODE, + USB_TYPE_VENDOR, 0, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); } static int ath3k_load_patch(struct usb_device *udev) @@ -397,7 +359,7 @@ static int ath3k_load_patch(struct usb_device *udev) int ret; ret = ath3k_get_state(udev, &fw_state); - if (ret < 0) { + if (ret) { BT_ERR("Can't get state to change to load ram patch err"); return ret; } @@ -408,7 +370,7 @@ static int ath3k_load_patch(struct usb_device *udev) } ret = ath3k_get_version(udev, &fw_version); - if (ret < 0) { + if (ret) { BT_ERR("Can't get version to change to load ram patch err"); return ret; } @@ -449,13 +411,13 @@ static int ath3k_load_syscfg(struct usb_device *udev) int clk_value, ret; ret = ath3k_get_state(udev, &fw_state); - if (ret < 0) { + if (ret) { BT_ERR("Can't get state to change to load configuration err"); return -EBUSY; } ret = ath3k_get_version(udev, &fw_version); - if (ret < 0) { + if (ret) { BT_ERR("Can't get version to change to load ram patch err"); return ret; } @@ -529,7 +491,7 @@ static int ath3k_probe(struct usb_interface *intf, return ret; } ret = ath3k_set_normal_mode(udev); - if (ret < 0) { + if (ret) { BT_ERR("Set normal mode failed"); return ret; } -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +GbRGmh8T18EaAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:05:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qIKdGWh8T18+rQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:05:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D874CA4567; Wed, 2 Sep 2020 13:05:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbgIBLD3 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:03:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:45770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726528AbgIBLBP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:15 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 621652098B; Wed, 2 Sep 2020 11:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044475; bh=NXgeav573xoVWsJ9e7SLPQ8svoQ2BcSre88zTAW0a84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LN8KTAvshdpXMQxfJz2GAfxA34G5mquJQFmkcoLMqumsTybBV/KzvVmSQj8cEnAPq 5wxM7bZYVIexRH0dBH6DP/uU5J+0naKKCegjXSjrYLmO3nl0dW8OvKbpcZSacQwlzS MtAidBU3SMfrFtUFmUTkntIy31bd96kWh9SGToEQ= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Alan Stern <stern@rowland.harvard.edu>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH 03/10] USB: core: message.c: use usb_control_msg_send() in a few places Date: Wed, 2 Sep 2020 13:01:05 +0200 Message-Id: <20200902110115.1994491-4-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: D874CA4567 X-Rspamd-UID: 3c255a There are a few calls to usb_control_msg() that can be converted to use usb_control_msg_send() instead, so do that in order to make the error checking a bit simpler. Cc: Alan Stern <stern@rowland.harvard.edu> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: linux-usb@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/usb/core/message.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 6aa49b237717..dfd079485c76 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1081,7 +1081,7 @@ int usb_set_isoch_delay(struct usb_device *dev) if (dev->speed < USB_SPEED_SUPER) return 0; - return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + return usb_control_msg_send(dev, 0, USB_REQ_SET_ISOCH_DELAY, USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, dev->hub_delay, 0, NULL, 0, @@ -1203,13 +1203,13 @@ int usb_clear_halt(struct usb_device *dev, int pipe) * (like some ibmcam model 1 units) seem to expect hosts to make * this request for iso endpoints, which can't halt! */ - result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, - USB_ENDPOINT_HALT, endp, NULL, 0, - USB_CTRL_SET_TIMEOUT); + result = usb_control_msg_send(dev, 0, + USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, + USB_ENDPOINT_HALT, endp, NULL, 0, + USB_CTRL_SET_TIMEOUT); /* don't un-halt or force to DATA0 except on success */ - if (result < 0) + if (result) return result; /* NOTE: seems like Microsoft and Apple don't bother verifying @@ -1558,9 +1558,10 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) if (dev->quirks & USB_QUIRK_NO_SET_INTF) ret = -EPIPE; else - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, - alternate, interface, NULL, 0, 5000); + ret = usb_control_msg_send(dev, 0, + USB_REQ_SET_INTERFACE, + USB_RECIP_INTERFACE, alternate, + interface, NULL, 0, 5000); /* 9.4.10 says devices don't need this and are free to STALL the * request if the interface only has one alternate setting. @@ -1570,7 +1571,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) "manual set_interface for iface %d, alt %d\n", interface, alternate); manual = 1; - } else if (ret < 0) { + } else if (ret) { /* Re-instate the old alt setting */ usb_hcd_alloc_bandwidth(dev, NULL, alt, iface->cur_altsetting); usb_enable_lpm(dev); @@ -1718,11 +1719,10 @@ int usb_reset_configuration(struct usb_device *dev) mutex_unlock(hcd->bandwidth_mutex); return retval; } - retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_CONFIGURATION, 0, - config->desc.bConfigurationValue, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); - if (retval < 0) + retval = usb_control_msg_send(dev, 0, USB_REQ_SET_CONFIGURATION, 0, + config->desc.bConfigurationValue, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); + if (retval) goto reset_old_alts; mutex_unlock(hcd->bandwidth_mutex); @@ -2103,10 +2103,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration) } kfree(new_interfaces); - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_CONFIGURATION, 0, configuration, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); - if (ret < 0 && cp) { + ret = usb_control_msg_send(dev, 0, USB_REQ_SET_CONFIGURATION, 0, + configuration, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); + if (ret && cp) { /* * All the old state is gone, so what else can we do? * The device is probably useless now anyway. -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2D1pEul7T1/oogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:03:05 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id iMNTEOl7T18aKwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:03:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4ECE6A5BB3; Wed, 2 Sep 2020 13:03:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727058AbgIBLCm (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:02:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:45858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726654AbgIBLBX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E07621548; Wed, 2 Sep 2020 11:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044482; bh=q1GkWLHnrhLyuAuirgakuk07qJQEXB3APlzotDBfAM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZsA0wR5nOXGHfuvP+1NX07RBGoZ0l9Sw4sGLRoOsFj59Z/PsVVylqeokV6SwPxJu1 4N7rpZ4dO2UwWiqS0FMeoKAdHrTkIHWxydh21+rKPnXk1x0MxXAXufh3OFH3LDW3dp KjbsrgZQTsAKStjwEigDpuzcZJCfrmvdtyPMnors= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH 06/10] sound: usx2y: move to use usb_control_msg_send() Date: Wed, 2 Sep 2020 13:01:08 +0200 Message-Id: <20200902110115.1994491-7-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.78 / 15.00 / 200.00 X-Rspamd-Queue-Id: 4ECE6A5BB3 X-Rspamd-UID: b617f2 The usb_control_msg_send() call can handle data on the stack, as well as returning an error if a "short" write happens, so move the driver over to using that call instead. This ends up removing a helper function that is no longer needed. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: alsa-devel@alsa-project.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- sound/usb/usx2y/us122l.c | 42 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index f86f7a61fb36..e5c5a0d03d8a 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -82,40 +82,13 @@ static int us144_create_usbmidi(struct snd_card *card) &US122L(card)->midi_list, &quirk); } -/* - * Wrapper for usb_control_msg(). - * Allocates a temp buffer to prevent dmaing from/to the stack. - */ -static int us122l_ctl_msg(struct usb_device *dev, unsigned int pipe, - __u8 request, __u8 requesttype, - __u16 value, __u16 index, void *data, - __u16 size, int timeout) -{ - int err; - void *buf = NULL; - - if (size > 0) { - buf = kmemdup(data, size, GFP_KERNEL); - if (!buf) - return -ENOMEM; - } - err = usb_control_msg(dev, pipe, request, requesttype, - value, index, buf, size, timeout); - if (size > 0) { - memcpy(data, buf, size); - kfree(buf); - } - return err; -} - static void pt_info_set(struct usb_device *dev, u8 v) { int ret; - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - 'I', - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - v, 0, NULL, 0, 1000); + ret = usb_control_msg_send(dev, 0, 'I', + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + v, 0, NULL, 0, 1000); snd_printdd(KERN_DEBUG "%i\n", ret); } @@ -305,10 +278,11 @@ static int us122l_set_sample_rate(struct usb_device *dev, int rate) data[0] = rate; data[1] = rate >> 8; data[2] = rate >> 16; - err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, - USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, - UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000); - if (err < 0) + err = usb_control_msg_send(dev, 0, UAC_SET_CUR, + USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, + UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, + 1000); + if (err) snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n", dev->devnum, rate, ep); return err; -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IBiXEvV7T18EaAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:03:17 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id SAo9EfV7T188ywAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:03:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 046D4A5BCF; Wed, 2 Sep 2020 13:03:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727075AbgIBLCo (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:02:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:45848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726618AbgIBLBV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:21 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2CB0621532; Wed, 2 Sep 2020 11:01:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044479; bh=v32AraO7yjFkMJz0mt4d1Okcjvs/K5ZJWJv43lokdps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PE6YtdqFQSObJgm6eKWbFiXFhV2xf0aKsUxyi9CWsQPXJppogOln708tbIh3dtFys Q+Fbx7j5eGQh9xI/QcqEjVbRCIj9S34txmeRZO2R/wE9w9+UgQKdlhEn7XOgiPTqWr xHp2RbTkAWlIIyOsk8RawJUAg7DFpaRFApa5dRNU= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Juergen Stuber <starblue@users.sourceforge.net>, legousb-devel@lists.sourceforge.net Subject: [PATCH 05/10] USB: legousbtower: use usb_control_msg_recv() Date: Wed, 2 Sep 2020 13:01:07 +0200 Message-Id: <20200902110115.1994491-6-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.35 / 15.00 / 200.00 X-Rspamd-Queue-Id: 046D4A5BCF X-Rspamd-UID: 350160 The usb_control_msg_recv() function can handle data on the stack, as well as properly detecting short reads, so move to use that function instead of the older usb_control_msg() call. This ends up removing a lot of extra lines in the driver. Cc: Juergen Stuber <starblue@users.sourceforge.net> Cc: legousb-devel@lists.sourceforge.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/usb/misc/legousbtower.c | 60 +++++++++++---------------------- 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index f922544056de..c3583df4c324 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -308,15 +308,9 @@ static int tower_open(struct inode *inode, struct file *file) int subminor; int retval = 0; struct usb_interface *interface; - struct tower_reset_reply *reset_reply; + struct tower_reset_reply reset_reply; int result; - reset_reply = kmalloc(sizeof(*reset_reply), GFP_KERNEL); - if (!reset_reply) { - retval = -ENOMEM; - goto exit; - } - nonseekable_open(inode, file); subminor = iminor(inode); @@ -347,15 +341,11 @@ static int tower_open(struct inode *inode, struct file *file) } /* reset the tower */ - result = usb_control_msg(dev->udev, - usb_rcvctrlpipe(dev->udev, 0), - LEGO_USB_TOWER_REQUEST_RESET, - USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, - 0, - 0, - reset_reply, - sizeof(*reset_reply), - 1000); + result = usb_control_msg_recv(dev->udev, 0, + LEGO_USB_TOWER_REQUEST_RESET, + USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, + 0, 0, + &reset_reply, sizeof(reset_reply), 1000); if (result < 0) { dev_err(&dev->udev->dev, "LEGO USB Tower reset control request failed\n"); @@ -394,7 +384,6 @@ static int tower_open(struct inode *inode, struct file *file) mutex_unlock(&dev->lock); exit: - kfree(reset_reply); return retval; } @@ -753,7 +742,7 @@ static int tower_probe(struct usb_interface *interface, const struct usb_device_ struct device *idev = &interface->dev; struct usb_device *udev = interface_to_usbdev(interface); struct lego_usb_tower *dev; - struct tower_get_version_reply *get_version_reply = NULL; + struct tower_get_version_reply get_version_reply; int retval = -ENOMEM; int result; @@ -798,34 +787,25 @@ static int tower_probe(struct usb_interface *interface, const struct usb_device_ dev->interrupt_in_interval = interrupt_in_interval ? interrupt_in_interval : dev->interrupt_in_endpoint->bInterval; dev->interrupt_out_interval = interrupt_out_interval ? interrupt_out_interval : dev->interrupt_out_endpoint->bInterval; - get_version_reply = kmalloc(sizeof(*get_version_reply), GFP_KERNEL); - if (!get_version_reply) { - retval = -ENOMEM; - goto error; - } - /* get the firmware version and log it */ - result = usb_control_msg(udev, - usb_rcvctrlpipe(udev, 0), - LEGO_USB_TOWER_REQUEST_GET_VERSION, - USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, - 0, - 0, - get_version_reply, - sizeof(*get_version_reply), - 1000); - if (result != sizeof(*get_version_reply)) { - if (result >= 0) - result = -EIO; + result = usb_control_msg_recv(udev, 0, + LEGO_USB_TOWER_REQUEST_GET_VERSION, + USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, + 0, + 0, + &get_version_reply, + sizeof(get_version_reply), + 1000); + if (!result) { dev_err(idev, "get version request failed: %d\n", result); retval = result; goto error; } dev_info(&interface->dev, "LEGO USB Tower firmware version is %d.%d build %d\n", - get_version_reply->major, - get_version_reply->minor, - le16_to_cpu(get_version_reply->build_no)); + get_version_reply.major, + get_version_reply.minor, + le16_to_cpu(get_version_reply.build_no)); /* we can register the device now, as it is ready */ usb_set_intfdata(interface, dev); @@ -844,11 +824,9 @@ static int tower_probe(struct usb_interface *interface, const struct usb_device_ USB_MAJOR, dev->minor); exit: - kfree(get_version_reply); return retval; error: - kfree(get_version_reply); tower_delete(dev); return retval; } -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oA1MJCB8T1/QXQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:04:00 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mKswIiB8T19OOwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:04:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 641D1A1E24; Wed, 2 Sep 2020 13:03:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbgIBLCi (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:02:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:45956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbgIBLBa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:30 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DB99E2166E; Wed, 2 Sep 2020 11:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044489; bh=tPRhJJgXvDc0IuVKlXjbFRDWA8BX95/8fwQ++InXL5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=07OoVR0jEQGE5aJ5jGecu1PUSSxjmfVizWumbkwRmppmTzi/9M+GYZ6sLUlp/8xsA MatkLBEBframZqC4xWnXZgXV2Gexp07mxPQDdNbBrtzD/tJyKLiaWzNS5FIbLeFx4n BewIUXy+pc/RvMtGbdmQB3kbyYdWeaqMLVXio7Bs= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH 8/9] sound: 6fire: move to use new usb control functions... Date: Wed, 2 Sep 2020 13:01:11 +0200 Message-Id: <20200902110115.1994491-10-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: 641D1A1E24 X-Rspamd-UID: f8ca6e Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- sound/usb/6fire/firmware.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c index 69137c14d0dc..e87bfa97be4e 100644 --- a/sound/usb/6fire/firmware.c +++ b/sound/usb/6fire/firmware.c @@ -158,29 +158,17 @@ static int usb6fire_fw_ihex_init(const struct firmware *fw, static int usb6fire_fw_ezusb_write(struct usb_device *device, int type, int value, char *data, int len) { - int ret; - - ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), type, + return usb_control_msg_send(device, 0, type, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, 0, data, len, HZ); - if (ret < 0) - return ret; - else if (ret != len) - return -EIO; - return 0; } static int usb6fire_fw_ezusb_read(struct usb_device *device, int type, int value, char *data, int len) { - int ret = usb_control_msg(device, usb_rcvctrlpipe(device, 0), type, + return usb_control_msg_recv(device, 0, type, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, 0, data, len, HZ); - if (ret < 0) - return ret; - else if (ret != len) - return -EIO; - return 0; } static int usb6fire_fw_fpga_write(struct usb_device *device, -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qA3XHSR8T1/QXQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:04:04 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +FRLHCR8T19NOwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:04:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E4544A5BB0; Wed, 2 Sep 2020 13:04:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727824AbgIBLDb (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:03:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:45804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726559AbgIBLBT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:19 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B8EB42151B; Wed, 2 Sep 2020 11:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044477; bh=R7mPnEePnjWRqt8MgCneQ6c6MoMy+NKWwiU1AGMwPaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W6zrMfQr7VSt32DOTIIjI7UeViL0gaO0UdUdjdVBw7GP7gPp/e+/1HPClTwu7EEiZ 6tX2n3wTYGDNhtcowoSJNp7kA3pKfQyTM1ozSsZF4izFgvcS0sa5vy9rpvxJgSXHso DS6tGdWu/9SC9bg+QuXJyvUhCsCTUEjHB5mUw68w= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Alan Stern <stern@rowland.harvard.edu> Subject: [PATCH 04/10] USB: core: hub.c: use usb_control_msg_send() in a few places Date: Wed, 2 Sep 2020 13:01:06 +0200 Message-Id: <20200902110115.1994491-5-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: E4544A5BB0 X-Rspamd-UID: 756ac6 There are a few calls to usb_control_msg() that can be converted to use usb_control_msg_send() instead, so do that in order to make the error checking a bit simpler and the code smaller. Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/usb/core/hub.c | 128 +++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 81 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 5b768b80d1ee..b7468517f336 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -410,8 +410,8 @@ static int get_hub_descriptor(struct usb_device *hdev, */ static int clear_hub_feature(struct usb_device *hdev, int feature) { - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - USB_REQ_CLEAR_FEATURE, USB_RT_HUB, feature, 0, NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, USB_REQ_CLEAR_FEATURE, USB_RT_HUB, + feature, 0, NULL, 0, 1000); } /* @@ -419,9 +419,8 @@ static int clear_hub_feature(struct usb_device *hdev, int feature) */ int usb_clear_port_feature(struct usb_device *hdev, int port1, int feature) { - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - USB_REQ_CLEAR_FEATURE, USB_RT_PORT, feature, port1, - NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, USB_REQ_CLEAR_FEATURE, USB_RT_PORT, + feature, port1, NULL, 0, 1000); } /* @@ -429,9 +428,8 @@ int usb_clear_port_feature(struct usb_device *hdev, int port1, int feature) */ static int set_port_feature(struct usb_device *hdev, int port1, int feature) { - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port1, - NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, USB_REQ_SET_FEATURE, USB_RT_PORT, + feature, port1, NULL, 0, 1000); } static char *to_led_name(int selector) @@ -755,15 +753,14 @@ hub_clear_tt_buffer(struct usb_device *hdev, u16 devinfo, u16 tt) /* Need to clear both directions for control ep */ if (((devinfo >> 11) & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_CONTROL) { - int status = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - HUB_CLEAR_TT_BUFFER, USB_RT_PORT, - devinfo ^ 0x8000, tt, NULL, 0, 1000); + int status = usb_control_msg_send(hdev, 0, + HUB_CLEAR_TT_BUFFER, USB_RT_PORT, + devinfo ^ 0x8000, tt, NULL, 0, 1000); if (status) return status; } - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo, - tt, NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, HUB_CLEAR_TT_BUFFER, USB_RT_PORT, + devinfo, tt, NULL, 0, 1000); } /* @@ -1049,11 +1046,10 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) */ if (type != HUB_RESUME) { if (hdev->parent && hub_is_superspeed(hdev)) { - ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - HUB_SET_DEPTH, USB_RT_HUB, - hdev->level - 1, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - if (ret < 0) + ret = usb_control_msg_send(hdev, 0, HUB_SET_DEPTH, USB_RT_HUB, + hdev->level - 1, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); + if (ret) dev_err(hub->intfdev, "set hub depth failed\n"); } @@ -2329,13 +2325,10 @@ static int usb_enumerate_device_otg(struct usb_device *udev) /* enable HNP before suspend, it's simpler */ if (port1 == bus->otg_port) { bus->b_hnp_enable = 1; - err = usb_control_msg(udev, - usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, 0, - USB_DEVICE_B_HNP_ENABLE, - 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - if (err < 0) { + err = usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, 0, + USB_DEVICE_B_HNP_ENABLE, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); + if (err) { /* * OTG MESSAGE: report errors here, * customize to match your product. @@ -2347,13 +2340,10 @@ static int usb_enumerate_device_otg(struct usb_device *udev) } else if (desc->bLength == sizeof (struct usb_otg_descriptor)) { /* Set a_alt_hnp_support for legacy otg device */ - err = usb_control_msg(udev, - usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, 0, - USB_DEVICE_A_ALT_HNP_SUPPORT, - 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - if (err < 0) + err = usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, 0, + USB_DEVICE_A_ALT_HNP_SUPPORT, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); + if (err) dev_err(&udev->dev, "set a_alt_hnp_support failed: %d\n", err); @@ -3121,10 +3111,8 @@ int usb_disable_ltm(struct usb_device *udev) if (!udev->actconfig) return 0; - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_LTM_ENABLE, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_LTM_ENABLE, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } EXPORT_SYMBOL_GPL(usb_disable_ltm); @@ -3143,10 +3131,8 @@ void usb_enable_ltm(struct usb_device *udev) if (!udev->actconfig) return; - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_LTM_ENABLE, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_LTM_ENABLE, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } EXPORT_SYMBOL_GPL(usb_enable_ltm); @@ -3163,17 +3149,14 @@ EXPORT_SYMBOL_GPL(usb_enable_ltm); static int usb_enable_remote_wakeup(struct usb_device *udev) { if (udev->speed < USB_SPEED_SUPER) - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_REMOTE_WAKEUP, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); else - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, - USB_INTRF_FUNC_SUSPEND, - USB_INTRF_FUNC_SUSPEND_RW | - USB_INTRF_FUNC_SUSPEND_LP, - NULL, 0, USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, + USB_INTRF_FUNC_SUSPEND, + USB_INTRF_FUNC_SUSPEND_RW | USB_INTRF_FUNC_SUSPEND_LP, + NULL, 0, USB_CTRL_SET_TIMEOUT); } /* @@ -3189,15 +3172,11 @@ static int usb_enable_remote_wakeup(struct usb_device *udev) static int usb_disable_remote_wakeup(struct usb_device *udev) { if (udev->speed < USB_SPEED_SUPER) - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); else - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, - USB_INTRF_FUNC_SUSPEND, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, + USB_INTRF_FUNC_SUSPEND, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } /* Count of wakeup-enabled devices at or below udev */ @@ -3844,7 +3823,7 @@ static const char * const usb3_lpm_names[] = { */ static int usb_req_set_sel(struct usb_device *udev, enum usb3_link_state state) { - struct usb_set_sel_req *sel_values; + struct usb_set_sel_req sel_values; unsigned long long u1_sel; unsigned long long u1_pel; unsigned long long u2_sel; @@ -3896,27 +3875,14 @@ static int usb_req_set_sel(struct usb_device *udev, enum usb3_link_state state) if (u2_pel > USB3_LPM_MAX_U2_SEL_PEL) u2_pel = USB3_LPM_MAX_U2_SEL_PEL; - /* - * usb_enable_lpm() can be called as part of a failed device reset, - * which may be initiated by an error path of a mass storage driver. - * Therefore, use GFP_NOIO. - */ - sel_values = kmalloc(sizeof *(sel_values), GFP_NOIO); - if (!sel_values) - return -ENOMEM; - - sel_values->u1_sel = u1_sel; - sel_values->u1_pel = u1_pel; - sel_values->u2_sel = cpu_to_le16(u2_sel); - sel_values->u2_pel = cpu_to_le16(u2_pel); + sel_values.u1_sel = u1_sel; + sel_values.u1_pel = u1_pel; + sel_values.u2_sel = cpu_to_le16(u2_sel); + sel_values.u2_pel = cpu_to_le16(u2_pel); - ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_SEL, - USB_RECIP_DEVICE, - 0, 0, - sel_values, sizeof *(sel_values), - USB_CTRL_SET_TIMEOUT); - kfree(sel_values); + ret = usb_control_msg_send(udev, 0, USB_REQ_SET_SEL, USB_RECIP_DEVICE, + 0, 0, &sel_values, sizeof(sel_values), + USB_CTRL_SET_TIMEOUT); return ret; } @@ -4056,7 +4022,7 @@ static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev, * associated with the link state we're about to enable. */ ret = usb_req_set_sel(udev, state); - if (ret < 0) { + if (ret) { dev_warn(&udev->dev, "Set SEL for device-initiated %s failed.\n", usb3_lpm_names[state]); return; -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gP4OIil8T187rwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:04:09 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gJOUICl8T19tmgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:04:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 995F6A29B7; Wed, 2 Sep 2020 13:04:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727852AbgIBLDk (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:03:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:45674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbgIBLBI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:08 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9051420C56; Wed, 2 Sep 2020 11:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044467; bh=BsyY8ht4FSB9XVxHk/tHCCSIf+eK+tfJb4055HBKN6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JhMj8uEwefOIEgOfiwx0qyhkXvOsMwd9jB+RMpq24GLVseDuPaFHqXsK/Ph+RPY3g yYsDcMgQ4iHOIw/UhvpqHm23cJEZ2ATfUjTbxSiTASWCKFBqAo3xykuVqq4IARN62Q 2nqCZgXaWZfZDMkIsNZmpf3w409JObsWYV0hTYck= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH 09/10] sound: hiface: move to use usb_control_msg_send() Date: Wed, 2 Sep 2020 13:01:14 +0200 Message-Id: <20200902110115.1994491-13-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: 995F6A29B7 X-Rspamd-UID: 9be307 The usb_control_msg_send() call can return an error if a "short" write happens, so move the driver over to using that call instead. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: alsa-devel@alsa-project.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- sound/usb/hiface/pcm.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sound/usb/hiface/pcm.c b/sound/usb/hiface/pcm.c index a148caa5f48e..f9c924e3964e 100644 --- a/sound/usb/hiface/pcm.c +++ b/sound/usb/hiface/pcm.c @@ -156,16 +156,14 @@ static int hiface_pcm_set_rate(struct pcm_runtime *rt, unsigned int rate) * This control message doesn't have any ack from the * other side */ - ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), - HIFACE_SET_RATE_REQUEST, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, - rate_value, 0, NULL, 0, 100); - if (ret < 0) { + ret = usb_control_msg_send(device, 0, + HIFACE_SET_RATE_REQUEST, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, + rate_value, 0, NULL, 0, 100); + if (ret) dev_err(&device->dev, "Error setting samplerate %d.\n", rate); - return ret; - } - return 0; + return ret; } static struct pcm_substream *hiface_pcm_get_substream(struct snd_pcm_substream -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CJZ3DTV8T1/oogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:04:21 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UISECzV8T182NAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:04:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id ED823A2959; Wed, 2 Sep 2020 13:04:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727864AbgIBLDm (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:03:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:45652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbgIBLBF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:05 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5FF88207D3; Wed, 2 Sep 2020 11:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044464; bh=/96qgCR3mfNvN+1iDBfVpYHsssSY4lebzEc9IAH7Dmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zV9jGmh7unapsEHtykkj4r3hf8tgnrWnjlC+6GUexrcUjaXk8e/7NXwupVoM8qCi0 CJEnVybMYP49bJmuSMIQAcng64pSkWItjqJo7ohCKcKguszBFaw/Cc1o9k0yuL2fty 9j3Led9+CWmzMvPkZADL1tGVZI+LRVPW9T2yqDik= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH 9/9] sound: hiface: convert to use new usb_control functions... Date: Wed, 2 Sep 2020 13:01:13 +0200 Message-Id: <20200902110115.1994491-12-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: ED823A2959 X-Rspamd-UID: 27fea9 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- sound/usb/hiface/pcm.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sound/usb/hiface/pcm.c b/sound/usb/hiface/pcm.c index a148caa5f48e..feab3f4834c2 100644 --- a/sound/usb/hiface/pcm.c +++ b/sound/usb/hiface/pcm.c @@ -156,14 +156,12 @@ static int hiface_pcm_set_rate(struct pcm_runtime *rt, unsigned int rate) * This control message doesn't have any ack from the * other side */ - ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), - HIFACE_SET_RATE_REQUEST, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, - rate_value, 0, NULL, 0, 100); - if (ret < 0) { + ret = usb_control_msg_send(device, 0, + HIFACE_SET_RATE_REQUEST, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, + rate_value, 0, NULL, 0, 100); + if (ret) dev_err(&device->dev, "Error setting samplerate %d.\n", rate); - return ret; - } return 0; } -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gCErCzt8T1/oogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:04:27 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id OO/nCTt8T188ywAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:04:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 17A46A24CD; Wed, 2 Sep 2020 13:04:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727881AbgIBLDq (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:03:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:45614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbgIBLBD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:01:03 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 242CA20FC3; Wed, 2 Sep 2020 11:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599044462; bh=txJfNlOtWDkA9Ez0nzHnJWQ4h8nWikVeEJ3eWQK5VE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=liRKPch7gWVonq0lyt470eai/AK+bcwkg4NKk1jnkvakvaC7ciKdqV0X6byVjBdNH 8bwwgP2hleORuwNfQxMmW6C1aAIcC0mUoY3y4DnkjJ8X+5Q7CDKymeBMBWY+ifkYya UtCCR4Fmw5SGNAsP8fa5f69tQ+/3wylt7QD030OM= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Vasily Khoruzhick <anarsoul@gmail.com> Subject: [PATCH 08/10] sound: line6: move to use usb_control_msg_send() and usb_control_msg_recv() Date: Wed, 2 Sep 2020 13:01:12 +0200 Message-Id: <20200902110115.1994491-11-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902110115.1994491-1-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.12 / 15.00 / 200.00 X-Rspamd-Queue-Id: 17A46A24CD X-Rspamd-UID: 118232 The usb_control_msg_send() and usb_control_msg_recv() calls can return an error if a "short" write/read happens, and they can handle data off of the stack, so move the driver over to using those calls instead, saving some logic when dynamically allocating memory. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: Vasily Khoruzhick <anarsoul@gmail.com> Cc: alsa-devel@alsa-project.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- sound/usb/line6/driver.c | 69 +++++++++++++++----------------------- sound/usb/line6/podhd.c | 17 ++++------ sound/usb/line6/toneport.c | 8 ++--- 3 files changed, 37 insertions(+), 57 deletions(-) diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 60674ce4879b..601292c51491 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -337,23 +337,18 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, { struct usb_device *usbdev = line6->usbdev; int ret; - unsigned char *len; + u8 len; unsigned count; if (address > 0xffff || datalen > 0xff) return -EINVAL; - len = kmalloc(1, GFP_KERNEL); - if (!len) - return -ENOMEM; - /* query the serial number: */ - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - (datalen << 8) | 0x21, address, - NULL, 0, LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + (datalen << 8) | 0x21, address, NULL, 0, + LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "read request failed (error %d)\n", ret); goto exit; } @@ -362,45 +357,41 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { mdelay(LINE6_READ_WRITE_STATUS_DELAY); - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | - USB_DIR_IN, - 0x0012, 0x0000, len, 1, - LINE6_TIMEOUT * HZ); - if (ret < 0) { + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0012, 0x0000, &len, 1, + LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "receive length failed (error %d)\n", ret); goto exit; } - if (*len != 0xff) + if (len != 0xff) break; } ret = -EIO; - if (*len == 0xff) { + if (len == 0xff) { dev_err(line6->ifcdev, "read failed after %d retries\n", count); goto exit; - } else if (*len != datalen) { + } else if (len != datalen) { /* should be equal or something went wrong */ dev_err(line6->ifcdev, "length mismatch (expected %d, got %d)\n", - (int)datalen, (int)*len); + (int)datalen, len); goto exit; } /* receive the result: */ - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, - 0x0013, 0x0000, data, datalen, - LINE6_TIMEOUT * HZ); - - if (ret < 0) + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0013, 0x0000, data, datalen, LINE6_TIMEOUT * HZ); + if (ret) dev_err(line6->ifcdev, "read failed (error %d)\n", ret); exit: - kfree(len); return ret; } EXPORT_SYMBOL_GPL(line6_read_data); @@ -423,12 +414,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, if (!status) return -ENOMEM; - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - 0x0022, address, data, datalen, - LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + 0x0022, address, data, datalen, LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "write request failed (error %d)\n", ret); goto exit; @@ -437,14 +426,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { mdelay(LINE6_READ_WRITE_STATUS_DELAY); - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), - 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | - USB_DIR_IN, - 0x0012, 0x0000, - status, 1, LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0012, 0x0000, status, 1, LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "receiving status failed (error %d)\n", ret); goto exit; diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index eef45f7fef0d..a1261f55d62b 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -183,29 +183,25 @@ static const struct attribute_group podhd_dev_attr_group = { static int podhd_dev_start(struct usb_line6_podhd *pod) { int ret; - u8 *init_bytes; + u8 init_bytes[8]; int i; struct usb_device *usbdev = pod->line6.usbdev; - init_bytes = kmalloc(8, GFP_KERNEL); - if (!init_bytes) - return -ENOMEM; - - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), + ret = usb_control_msg_send(usbdev, 0, 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 0x11, 0, NULL, 0, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(pod->line6.ifcdev, "read request failed (error %d)\n", ret); goto exit; } /* NOTE: looks like some kind of ping message */ - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, + ret = usb_control_msg_recv(usbdev, 0, 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 0x11, 0x0, init_bytes, 3, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(pod->line6.ifcdev, "receive length failed (error %d)\n", ret); goto exit; @@ -220,13 +216,12 @@ static int podhd_dev_start(struct usb_line6_podhd *pod) goto exit; } - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), + ret = usb_control_msg_send(usbdev, 0, USB_REQ_SET_FEATURE, USB_TYPE_STANDARD | USB_RECIP_DEVICE | USB_DIR_OUT, 1, 0, NULL, 0, LINE6_TIMEOUT * HZ); exit: - kfree(init_bytes); return ret; } diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 94dd5e7ab2e6..a9b56085b76a 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -126,11 +126,11 @@ static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2) { int ret; - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(&usbdev->dev, "send failed (error %d)\n", ret); return ret; } -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8JzYHL+AT1+J8AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 13:23:43 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eNAyG7+AT188ywAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 13:23:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 400E8A2A1D; Wed, 2 Sep 2020 13:23:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726310AbgIBLXf (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 07:23:35 -0400 Received: from mga09.intel.com ([134.134.136.24]:22206 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbgIBLXc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 07:23:32 -0400 IronPort-SDR: OZs/v5oW+sxnuedzK2ZWYU1Ye74M4OsEe5k7ugN0NoSAx1fJ/R0ilLhnocn+XtxC/Bzmy6Wxik HhRlD472xVRA== X-IronPort-AV: E=McAfee;i="6000,8403,9731"; a="158360807" X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="158360807" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2020 04:23:31 -0700 IronPort-SDR: OqNCIjSk4VpEk9lplIyXWdoWV7hgkGe5Iq51Opx0ujwSKJuJVa80CDtRvjRjmjAzIKCfjyV5JS kPXG16VU6E3w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="331402380" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga008.jf.intel.com with ESMTP; 02 Sep 2020 04:23:28 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from <andriy.shevchenko@linux.intel.com>) id 1kDQrN-00Dhr3-5n; Wed, 02 Sep 2020 14:23:25 +0300 Date: Wed, 2 Sep 2020 14:23:25 +0300 From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Alan Stern <stern@rowland.harvard.edu>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Subject: Re: [PATCH 03/10] USB: core: message.c: use usb_control_msg_send() in a few places Message-ID: <20200902112325.GL1891694@smile.fi.intel.com> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-4-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200902110115.1994491-4-gregkh@linuxfoundation.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.50 / 15.00 / 200.00 X-Rspamd-Queue-Id: 400E8A2A1D X-Rspamd-UID: dbf141 On Wed, Sep 02, 2020 at 01:01:05PM +0200, Greg Kroah-Hartman wrote: > There are a few calls to usb_control_msg() that can be converted to use > usb_control_msg_send() instead, so do that in order to make the error > checking a bit simpler. Makes sense. Others will take this as a good example of API in use. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Cc: Alan Stern <stern@rowland.harvard.edu> > Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Cc: linux-usb@vger.kernel.org > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > --- > drivers/usb/core/message.c | 38 +++++++++++++++++++------------------- > 1 file changed, 19 insertions(+), 19 deletions(-) > > diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c > index 6aa49b237717..dfd079485c76 100644 > --- a/drivers/usb/core/message.c > +++ b/drivers/usb/core/message.c > @@ -1081,7 +1081,7 @@ int usb_set_isoch_delay(struct usb_device *dev) > if (dev->speed < USB_SPEED_SUPER) > return 0; > > - return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), > + return usb_control_msg_send(dev, 0, > USB_REQ_SET_ISOCH_DELAY, > USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, > dev->hub_delay, 0, NULL, 0, > @@ -1203,13 +1203,13 @@ int usb_clear_halt(struct usb_device *dev, int pipe) > * (like some ibmcam model 1 units) seem to expect hosts to make > * this request for iso endpoints, which can't halt! > */ > - result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), > - USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, > - USB_ENDPOINT_HALT, endp, NULL, 0, > - USB_CTRL_SET_TIMEOUT); > + result = usb_control_msg_send(dev, 0, > + USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, > + USB_ENDPOINT_HALT, endp, NULL, 0, > + USB_CTRL_SET_TIMEOUT); > > /* don't un-halt or force to DATA0 except on success */ > - if (result < 0) > + if (result) > return result; > > /* NOTE: seems like Microsoft and Apple don't bother verifying > @@ -1558,9 +1558,10 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) > if (dev->quirks & USB_QUIRK_NO_SET_INTF) > ret = -EPIPE; > else > - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), > - USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, > - alternate, interface, NULL, 0, 5000); > + ret = usb_control_msg_send(dev, 0, > + USB_REQ_SET_INTERFACE, > + USB_RECIP_INTERFACE, alternate, > + interface, NULL, 0, 5000); > > /* 9.4.10 says devices don't need this and are free to STALL the > * request if the interface only has one alternate setting. > @@ -1570,7 +1571,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) > "manual set_interface for iface %d, alt %d\n", > interface, alternate); > manual = 1; > - } else if (ret < 0) { > + } else if (ret) { > /* Re-instate the old alt setting */ > usb_hcd_alloc_bandwidth(dev, NULL, alt, iface->cur_altsetting); > usb_enable_lpm(dev); > @@ -1718,11 +1719,10 @@ int usb_reset_configuration(struct usb_device *dev) > mutex_unlock(hcd->bandwidth_mutex); > return retval; > } > - retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), > - USB_REQ_SET_CONFIGURATION, 0, > - config->desc.bConfigurationValue, 0, > - NULL, 0, USB_CTRL_SET_TIMEOUT); > - if (retval < 0) > + retval = usb_control_msg_send(dev, 0, USB_REQ_SET_CONFIGURATION, 0, > + config->desc.bConfigurationValue, 0, > + NULL, 0, USB_CTRL_SET_TIMEOUT); > + if (retval) > goto reset_old_alts; > mutex_unlock(hcd->bandwidth_mutex); > > @@ -2103,10 +2103,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration) > } > kfree(new_interfaces); > > - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), > - USB_REQ_SET_CONFIGURATION, 0, configuration, 0, > - NULL, 0, USB_CTRL_SET_TIMEOUT); > - if (ret < 0 && cp) { > + ret = usb_control_msg_send(dev, 0, USB_REQ_SET_CONFIGURATION, 0, > + configuration, 0, NULL, 0, > + USB_CTRL_SET_TIMEOUT); > + if (ret && cp) { > /* > * All the old state is gone, so what else can we do? > * The device is probably useless now anyway. > -- > 2.28.0 > -- With Best Regards, Andy Shevchenko Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WOD/Ere4T18j1wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 17:22:31 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id APqUEbe4T19VSwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 17:22:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 26174A2223; Wed, 2 Sep 2020 17:22:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727945AbgIBPWK (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 11:22:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:51862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727930AbgIBPV1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 11:21:27 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EADBB20767; Wed, 2 Sep 2020 15:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599060086; bh=x3POqbn4b/hj4C4s0Hk+zf9rTRiYWs7wlVg18R4VMcU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=q+zfeqOR+6hdjoTVnVBLGhd8rHUGFE0NW2iqszVvebJ6RN7fOjeJ9cbCJm8RJFvFj xLJfjWXjni//s3sYQxALkrMTfpdpKnCC6TVeC0gPIy18dZyCtjQEVUFnOAp8OIj8Bt nL0PMy9kYEOiLpMAwsIIX0r/wXP85mGZBdf6ZENw= Date: Wed, 2 Sep 2020 17:21:51 +0200 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: Alan Stern <stern@rowland.harvard.edu> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH 04/10] USB: core: hub.c: use usb_control_msg_send() in a few places Message-ID: <20200902152151.GA2032878@kroah.com> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-5-gregkh@linuxfoundation.org> <20200902145701.GA624583@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200902145701.GA624583@rowland.harvard.edu> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: 26174A2223 X-Rspamd-UID: e4d96f On Wed, Sep 02, 2020 at 10:57:01AM -0400, Alan Stern wrote: > On Wed, Sep 02, 2020 at 01:01:06PM +0200, Greg Kroah-Hartman wrote: > > There are a few calls to usb_control_msg() that can be converted to use > > usb_control_msg_send() instead, so do that in order to make the error > > checking a bit simpler and the code smaller. > > > > Cc: Alan Stern <stern@rowland.harvard.edu> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > One problem in this patch... > > > @@ -3896,27 +3875,14 @@ static int usb_req_set_sel(struct usb_device *udev, enum usb3_link_state state) > > if (u2_pel > USB3_LPM_MAX_U2_SEL_PEL) > > u2_pel = USB3_LPM_MAX_U2_SEL_PEL; > > > > - /* > > - * usb_enable_lpm() can be called as part of a failed device reset, > > - * which may be initiated by an error path of a mass storage driver. > > - * Therefore, use GFP_NOIO. > > - */ > > - sel_values = kmalloc(sizeof *(sel_values), GFP_NOIO); > > - if (!sel_values) > > - return -ENOMEM; > > - > > - sel_values->u1_sel = u1_sel; > > - sel_values->u1_pel = u1_pel; > > - sel_values->u2_sel = cpu_to_le16(u2_sel); > > - sel_values->u2_pel = cpu_to_le16(u2_pel); > > + sel_values.u1_sel = u1_sel; > > + sel_values.u1_pel = u1_pel; > > + sel_values.u2_sel = cpu_to_le16(u2_sel); > > + sel_values.u2_pel = cpu_to_le16(u2_pel); > > > > - ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), > > - USB_REQ_SET_SEL, > > - USB_RECIP_DEVICE, > > - 0, 0, > > - sel_values, sizeof *(sel_values), > > - USB_CTRL_SET_TIMEOUT); > > - kfree(sel_values); > > + ret = usb_control_msg_send(udev, 0, USB_REQ_SET_SEL, USB_RECIP_DEVICE, > > + 0, 0, &sel_values, sizeof(sel_values), > > + USB_CTRL_SET_TIMEOUT); > > This effectively changes GFP_NOIO to GFP_KERNEL. Probably you should > leave this particular call alone. I thought about that, but for some reason thought that usb_control_msg() would eventually call for an allocation with GFP_KERNEL, but I was wrong, usb_internal_control_msg() calls usb_alloc_urb() with GFP_NOIO, my fault. I'll go fix this up, thanks for the review. greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uA1uOl67T1+R5gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 17:33:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id eAuKOF67T19saAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 17:33:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1F122A0979; Wed, 2 Sep 2020 17:33:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728355AbgIBPc1 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 11:32:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:52168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbgIBPWW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 11:22:22 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB09B20767; Wed, 2 Sep 2020 15:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599060142; bh=PafC4luDUVsLd0CvhpVv+0h3RiIUnGou8VQWTyXKaH4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=0vlvv5xkZfFzOch2k7oTHhJc577RFRmad/f4nIOgptOpLm4VyphiT4+lWXH9Ch9Mb f/q94ZLdLFwBvqo5pW9SGyvATymfNUxqK6GeqGoWJIfp5jQpSX0XTTcfwkMkUHfoji 78aMyrwzA/VJvMJl5zab+f+IAe9ZuMdDJ/In0okI= Date: Wed, 2 Sep 2020 17:22:48 +0200 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: Takashi Iwai <tiwai@suse.de> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH 7/9] sound: line6: convert to use new usb control function... Message-ID: <20200902152248.GB2032878@kroah.com> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-9-gregkh@linuxfoundation.org> <s5ha6y89r6u.wl-tiwai@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <s5ha6y89r6u.wl-tiwai@suse.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1F122A0979 X-Rspamd-UID: 52a6f9 On Wed, Sep 02, 2020 at 04:41:29PM +0200, Takashi Iwai wrote: > On Wed, 02 Sep 2020 13:01:10 +0200, > Greg Kroah-Hartman wrote: > > > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > I guess this and a few others with (x/9) are stale patches, right? Ugh, yes, those were still in my directory, my fault for using 'git send-email *patch' :( greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EOS+JL+JT18ccwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 14:02:07 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id EJ4pI7+JT19v4gAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 14:02:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 60C72420D2; Wed, 2 Sep 2020 14:02:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726791AbgIBMBr (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 08:01:47 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:46776 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726657AbgIBMBl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 08:01:41 -0400 Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 02 Sep 2020 05:01:33 -0700 Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 02 Sep 2020 05:01:31 -0700 Received: from gubbaven-linux.qualcomm.com ([10.206.64.32]) by ironmsg02-blr.qualcomm.com with ESMTP; 02 Sep 2020 17:31:07 +0530 Received: by gubbaven-linux.qualcomm.com (Postfix, from userid 2365015) id C91A721B33; Wed, 2 Sep 2020 17:31:06 +0530 (IST) From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org, Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Subject: [PATCH v1] arm64: dts: qcom: sc7180: Remove clock for bluetooth on SC7180 IDP board Date: Wed, 2 Sep 2020 17:31:03 +0530 Message-Id: <1599048063-6900-1-git-send-email-gubbaven@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.82 / 15.00 / 200.00 X-Rspamd-Queue-Id: 60C72420D2 X-Rspamd-UID: 481774 Removed voting for RPMH_RF_CLK2 which is not required as it is getting managed by BT SoC through SW_CTRL line. Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> --- arch/arm64/boot/dts/qcom/sc7180-idp.dts | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/sc7180-idp.dts b/arch/arm64/boot/dts/qcom/sc7180-idp.dts index 4e9149d..b295d01 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-idp.dts +++ b/arch/arm64/boot/dts/qcom/sc7180-idp.dts @@ -348,7 +348,6 @@ vddrf-supply = <&vreg_l2c_1p3>; vddch0-supply = <&vreg_l10c_3p3>; max-speed = <3200000>; - clocks = <&rpmhcc RPMH_RF_CLK2>; }; }; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KNcLDtM8UF8VJQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 02:46:11 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aM9cDNM8UF/+QwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 02:46:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EE334A159B; Thu, 3 Sep 2020 02:46:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726994AbgICApz (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 20:45:55 -0400 Received: from netrider.rowland.org ([192.131.102.5]:42021 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726814AbgICApy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 20:45:54 -0400 Received: (qmail 643241 invoked by uid 1000); 2 Sep 2020 20:45:53 -0400 Date: Wed, 2 Sep 2020 20:45:53 -0400 From: Alan Stern <stern@rowland.harvard.edu> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Eli Billauer <eli.billauer@gmail.com>, Emiliano Ingrassia <ingrassia@epigenesys.com>, Alexander Tsoy <alexander@tsoy.me>, "Geoffrey D. Bennett" <g@b4.vu>, Jussi Laako <jussi@sonarnerd.net>, Nick Kossifidis <mickflemm@gmail.com>, Dmitry Panchenko <dmitry@d-systems.ee>, Chris Wulff <crwulff@gmail.com>, Jesus Ramos <jesus-ramos@live.com> Subject: Re: [PATCH 01/10] USB: move snd_usb_pipe_sanity_check into the USB core Message-ID: <20200903004553.GA642955@rowland.harvard.edu> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-2-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200902110115.1994491-2-gregkh@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.37 / 15.00 / 200.00 X-Rspamd-Queue-Id: EE334A159B X-Rspamd-UID: 67de46 On Wed, Sep 02, 2020 at 01:01:03PM +0200, Greg Kroah-Hartman wrote: > snd_usb_pipe_sanity_check() is a great function, so let's move it into > the USB core so that other parts of the kernel, including the USB core, > can call it. > > Name it usb_pipe_type_check() to match the existing > usb_urb_ep_type_check() call, which now uses this function. > > Cc: Jaroslav Kysela <perex@perex.cz> > Cc: Takashi Iwai <tiwai@suse.com> > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > Cc: Eli Billauer <eli.billauer@gmail.com> > Cc: Emiliano Ingrassia <ingrassia@epigenesys.com> > Cc: Alan Stern <stern@rowland.harvard.edu> > Cc: Alexander Tsoy <alexander@tsoy.me> > Cc: "Geoffrey D. Bennett" <g@b4.vu> > Cc: Jussi Laako <jussi@sonarnerd.net> > Cc: Nick Kossifidis <mickflemm@gmail.com> > Cc: Dmitry Panchenko <dmitry@d-systems.ee> > Cc: Chris Wulff <crwulff@gmail.com> > Cc: Jesus Ramos <jesus-ramos@live.com> > Cc: linux-usb@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: alsa-devel@alsa-project.org > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > --- > diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c > index 27e83e55a590..45bc2914c1ba 100644 > --- a/drivers/usb/core/urb.c > +++ b/drivers/usb/core/urb.c > @@ -192,24 +192,39 @@ static const int pipetypes[4] = { > }; > > /** > - * usb_urb_ep_type_check - sanity check of endpoint in the given urb > - * @urb: urb to be checked > + * usb_pipe_type_check - sanity check of a specific pipe for a usb device > + * @dev: struct usb_device to be checked > + * @pipe: pipe to check > * > * This performs a light-weight sanity check for the endpoint in the > - * given urb. It returns 0 if the urb contains a valid endpoint, otherwise > - * a negative error code. > + * given usb device. It returns 0 if the pipe is a valid for the specific usb -----------------------------------------------------^ Typo. > + * device, otherwise a negative error code. > */ > -int usb_urb_ep_type_check(const struct urb *urb) > +int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe) > { > const struct usb_host_endpoint *ep; > > - ep = usb_pipe_endpoint(urb->dev, urb->pipe); > + ep = usb_pipe_endpoint(dev, pipe); > if (!ep) > return -EINVAL; > - if (usb_pipetype(urb->pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) > + if (usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) > return -EINVAL; > return 0; > } > +EXPORT_SYMBOL_GPL(usb_pipe_type_check); > + > +/** > + * usb_urb_ep_type_check - sanity check of endpoint in the given urb > + * @urb: urb to be checked > + * > + * This performs a light-weight sanity check for the endpoint in the > + * given urb. It returns 0 if the urb contains a valid endpoint, otherwise > + * a negative error code. > + */ > +int usb_urb_ep_type_check(const struct urb *urb) > +{ > + return usb_pipe_type_check(urb->dev, urb->pipe); > +} > EXPORT_SYMBOL_GPL(usb_urb_ep_type_check); Since this routine is used in only one place in the entire kernel, you might as well inline the code there and get rid of the function entirely. > diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c > index abf99b814a0f..fc3aab04a0bc 100644 > --- a/sound/usb/quirks.c > +++ b/sound/usb/quirks.c > @@ -846,7 +846,7 @@ static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev) > static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 }; > void *buf; > > - if (snd_usb_pipe_sanity_check(dev, usb_sndintpipe(dev, 0x05))) > + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x05))) > return -EINVAL; > buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); > if (!buf) > @@ -875,7 +875,7 @@ static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev) > { > int ret; > > - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) > + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) > return -EINVAL; In a few places here this check is completely unnecessary. All it does is verify that the device does have an endpoint 0 and the the type of the endpoint matches the type of the pipe. Well, every USB device always has an endpoint 0, and it is always a bidirectional control endpoint. Therefore a simple static check is all you need: There's no point calling usb_pipe_type_check() when the pipe is of the form usb_{snd|rcv}ctrlpipe(dev, 0). In short, this check should be removed completely; it does nothing. > ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), > 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE, > @@ -984,7 +984,7 @@ static int snd_usb_axefx3_boot_quirk(struct usb_device *dev) > > dev_dbg(&dev->dev, "Waiting for Axe-Fx III to boot up...\n"); > > - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) > + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) Same for this check. > return -EINVAL; > /* If the Axe-Fx III has not fully booted, it will timeout when trying > * to enable the audio streaming interface. A more generous timeout is > @@ -1018,7 +1018,7 @@ static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, > { > int err, actual_length; > > - if (snd_usb_pipe_sanity_check(dev, usb_sndintpipe(dev, 0x01))) > + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x01))) > return -EINVAL; > err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x01), buf, *length, > &actual_length, 1000); > @@ -1030,7 +1030,7 @@ static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, > > memset(buf, 0, buf_size); > > - if (snd_usb_pipe_sanity_check(dev, usb_rcvintpipe(dev, 0x82))) > + if (usb_pipe_type_check(dev, usb_rcvintpipe(dev, 0x82))) > return -EINVAL; > err = usb_interrupt_msg(dev, usb_rcvintpipe(dev, 0x82), buf, buf_size, > &actual_length, 1000); > @@ -1117,7 +1117,7 @@ static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) > { > int ret; > > - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) > + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) And this one. > return -EINVAL; > ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), > 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, Alan Stern Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8JJXFrZcUF/1ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 05:02:14 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SKd5FLZcUF/VHgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 05:02:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5B2D8420C4; Thu, 3 Sep 2020 05:02:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728088AbgICDCF (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 23:02:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbgICDCE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 23:02:04 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD9FDC061244 for <linux-bluetooth@vger.kernel.org>; Wed, 2 Sep 2020 20:02:03 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id a14so1212010qtp.15 for <linux-bluetooth@vger.kernel.org>; Wed, 02 Sep 2020 20:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=iPi5IQAuAg6VdmAUQLYPOaBS4AFQMK7BNHv1zt5oaas=; b=vh5RjQ6FHmaQNjsY3qBg9GI9ZMrEXyqdcyrlmBuWXVgkEkyl86MTGsJkeYxiWdEVdG wAF4d4T29VN0yJ7xzT7zOUXZhoyooFv5kvJCQFEXE9Tm6sZYejy/UwwI3mVWEnuRpYjI 4fmuduMX6Alucf7vuLtat0zc4KPAqfKBGw2Mf+k5Tm9gOQMLII4GJkgNBcuYzcQrf43o 7WZX5lDMxxWwc5bUBQAZy4/Nx4UdO5ppQatoCtKEicO7QcuLNnXgWTh8BTf9KysfQhC1 ZcYExhAgHbj7hTrY1UFoMdnBgsfEqaoZITuDjrEyx/ISdQBAhgl5BVCfN/jbRB9fUDJq KBFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=iPi5IQAuAg6VdmAUQLYPOaBS4AFQMK7BNHv1zt5oaas=; b=p/l9rw52KPNDPFL48sHHN/8FiDIn/VDTR7jd/tLR61sEi+wrJicm9GQYQsloQF0l65 9Fjj7lP5EtH8Pnzduai8y0dT58qku48kHVqYJv1o6YHkvjDJ/G7TqWi8rpYfwCNyPetS 1V5vTkpWvMecF+h8BJqBR7QvBUjGFaHbAfd9HYy1/WE2m7SxGn+7igWQiTmTqhUYbKah oqpUOxUptz2b0m9J+rNDTu8I+Dt/M04UPO7BW6TOG0JqcWr1hh10lL1yFb7nxd596fzS VuPDLrhy73ArUpZBCtMLw3lQn0JCHJOulgPpTGLkbINO+DdtbDtu2R5YUxm2Rys1509w D0Rw== X-Gm-Message-State: AOAM531WoGApl1Av3TdcmIPWzhWCrV8y8ipdSEnMbO3+f7c3j3G+WqPd 6JQ36/hZDNSY6dHq0+DQgcf0+cbb5IgIZQQrzZTpzWePnFUUzCF04szNOL+4IQyL6HxiSJ15/Px LdpW3MV4B04x74yBaUDxnYp2OHU/S2ORoB+zjpg/u/NtDN7LfrjNYrriUgEAWudWZJcDnj3bHGZ ER X-Google-Smtp-Source: ABdhPJzUKm9lxGj82QCW5HMSI2QiaMKZOWj6wCqteYWFLJyULborcs2qu5oduPZodszs1GnpBZCuLQjuJ7YG X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a0c:d803:: with SMTP id h3mr1546022qvj.0.1599102122134; Wed, 02 Sep 2020 20:02:02 -0700 (PDT) Date: Thu, 3 Sep 2020 11:01:44 +0800 Message-Id: <20200903110031.Bluez.v2.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v2 1/2] doc/media-api: Add Press/Hold/Release methods for MediaPlayer1 From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.89 / 15.00 / 200.00 X-Rspamd-Queue-Id: 5B2D8420C4 X-Rspamd-UID: e0e43a From: Archie Pusaka <apusaka@chromium.org> This allows us to send any passthrough command. The button can also be held for an extended amount of time. Reviewed-by: Michael Sun <michaelfsun@chromium.org> --- Changes in v2: * Add Hold and Release methods doc/media-api.txt | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/doc/media-api.txt b/doc/media-api.txt index dabc69936..e98573157 100644 --- a/doc/media-api.txt +++ b/doc/media-api.txt @@ -199,6 +199,35 @@ Methods void Play() Possible Errors: org.bluez.Error.NotSupported org.bluez.Error.Failed + void Press(byte avc_key) + + Press a specific key to send as passthrough command. + The key will be released automatically. Use Hold() + instead if the intention is to hold down the key. + + Possible Errors: org.bluez.Error.InvalidArguments + org.bluez.Error.NotSupported + org.bluez.Error.Failed + + void Hold(byte avc_key) + + Press and hold a specific key to send as passthrough + command. It is your responsibility to make sure that + Release() is called after calling this method. The held + key will also be released when any other method in this + interface is called. + + Possible Errors: org.bluez.Error.InvalidArguments + org.bluez.Error.NotSupported + org.bluez.Error.Failed + + void Release() + + Release the previously held key invoked using Hold(). + + Possible Errors: org.bluez.Error.NotSupported + org.bluez.Error.Failed + Properties string Equalizer [readwrite] Possible values: "off" or "on" -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kGSXFL5cUF/1ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 05:02:22 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 0IixE75cUF+vXQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 05:02:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3778D417C0; Thu, 3 Sep 2020 05:02:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728091AbgICDCQ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 23:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728089AbgICDCO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 23:02:14 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE30CC061244 for <linux-bluetooth@vger.kernel.org>; Wed, 2 Sep 2020 20:02:13 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id g1so1187026qtc.22 for <linux-bluetooth@vger.kernel.org>; Wed, 02 Sep 2020 20:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=B+M+Hw2B1qZsziPCQLtzTmJsNX53hPU89WbdAxaP5gY=; b=QI41U6qLX22ss9KbZk7JB2BTG5y2HOMTAdGdIbZ0YkRwlb0Jnney2yacUVC6bTk4dl ASJ2ZIdAG8zis8lECYcsuPeHBTrq75/mMUrHWhPlsHINNH6E4D9Pbi7nsOGeB81XzcST omc/DePTQz8gM66HwAoOclncOdQaJtl5hp0xXoRV03hGKWxrZIujJ9o+wzeOjCGP6k3y qOXlSRzSteUycXjx3UT/TH2q/Un9qZyMTmvYcMICUYi5qQbfUdXbJk3/Je43Q7wnZkQW +wC6HROga9pxePHlwUii1ojgO3gTC8+oW67Kpsnkqp8JgQdeHI2zb/wFABEQ+UCWufUB 2zkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=B+M+Hw2B1qZsziPCQLtzTmJsNX53hPU89WbdAxaP5gY=; b=O0rHcwjtBWVOPw70e8uyhHlpS3QMSy/ph2j3ABUk+5ScRQfv7WZrHNjAU6cp+4uATU Kayefnmj6qMt8kutnsA6WmVAUmx6euUJr1AYVPGnS64j1rKhE/+VfrDtr36c/q8leXN0 4jG8hhVYdooIKOK8r6ESQGvUMwlZqFUiCkL3MmgFImEOVH+Rt2MF3DTjaEpw/W18qB1m sTyIuHAixL7cPvMjg3IebBkQ27R8gqbge0MbsI3J2aM67ATV34eQA/G1KLuUElYhkV5n xaFxMWd+Mk8pVVHMYC0jGmAkk4xcaTDsq1COc4fqb7/lfZWdQXRU60OebbfN/ehGFwd2 GGtg== X-Gm-Message-State: AOAM530iCO6BoUAEXtdvRSBh0bRXTjK/36a5Enl4Ob6x3p9N8mvR4VP9 T6LyJGGqhQK+Js07nymUQtbn1hhHjD1x9u+S4X2/Uujub5KCrWBE8P7QhJQjIKFHyOPlaaMRZbc WIJRiDFO2XTRh3zpmZS4nazOh4AiHQztQ7MceUuo9j3WGBV8Hc8ZTwMFrLfF6hHZ2MXJIEpJGyL xc X-Google-Smtp-Source: ABdhPJwrhFoBxZvGxOr8ha38rurDZfpU8Ef3B0ZnzsgUvJ9Q01UgRzau5d0LJRa22nEVp5xmw3HrlkrS4Ykv X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a05:6214:10c9:: with SMTP id r9mr19800qvs.0.1599102132782; Wed, 02 Sep 2020 20:02:12 -0700 (PDT) Date: Thu, 3 Sep 2020 11:01:45 +0800 In-Reply-To: <20200903110031.Bluez.v2.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> Message-Id: <20200903110031.Bluez.v2.2.Ia9ec99e1edde324e55c91828218268bc1b614136@changeid> Mime-Version: 1.0 References: <20200903110031.Bluez.v2.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v2 2/2] avrcp: Implement Press/Hold/Release method for MediaPlayer1 From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.17 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3778D417C0 X-Rspamd-UID: 7517c4 From: Archie Pusaka <apusaka@chromium.org> This allows us to send any passthrough command, complete with the support to hold down the key. Using Press() will automatically release the key, while using Hold() will keep the key held until an explicit call to Release() is received. This doesn't allow us to hold multiple keys simultaneously, since according to the AV/C Panel Subunit Specification, part 9.4, when the target receive a pressed command without receiving a release command of the previous key, it will be treated as if the release command is sent but not received. Previously, the rewind and fast_forward keys are unique in terms that they are treated as holdable keys, this patch preserves that behavior of calling Rewind() and FastForward(). A rewind event which is reported via the new Press() method will automatically be released instead. --- Changes in v2: * Implement Hold and Release method * Previously only a key with the repeat_timer will be released on the keypress of other key, now it send release message to whatever key is pressed before and is not released yet. profiles/audio/avctp.c | 54 +++++++++++++++++++++----------- profiles/audio/avctp.h | 5 ++- profiles/audio/avrcp.c | 62 +++++++++++++++++++++++++++++++------ profiles/audio/control.c | 22 ++++++------- profiles/audio/player.c | 67 ++++++++++++++++++++++++++++++++++++++++ profiles/audio/player.h | 33 +++++++++++--------- 6 files changed, 190 insertions(+), 53 deletions(-) diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c index a58623216..f096d22b0 100644 --- a/profiles/audio/avctp.c +++ b/profiles/audio/avctp.c @@ -60,6 +60,8 @@ * command with the pressed value is valid for two seconds */ #define AVC_PRESS_TIMEOUT 2 +/* We need to send hold event before AVC_PRESS time runs out */ +#define AVC_HOLD_TIMEOUT 1 #define CONTROL_TIMEOUT 10 #define BROWSING_TIMEOUT 10 @@ -191,6 +193,7 @@ struct avctp_channel { struct key_pressed { uint16_t op; guint timer; + bool hold; }; struct avctp { @@ -1500,6 +1503,7 @@ static struct avctp *avctp_get_internal(struct btd_device *device) session->device = btd_device_ref(device); session->state = AVCTP_STATE_DISCONNECTED; session->uinput = -1; + session->key.op = AVC_INVALID; server->sessions = g_slist_append(server->sessions, session); @@ -1846,35 +1850,32 @@ static gboolean repeat_timeout(gpointer user_data) { struct avctp *session = user_data; - avctp_passthrough_release(session, session->key.op); avctp_passthrough_press(session, session->key.op); return TRUE; } -static void release_pressed(struct avctp *session) +static int release_pressed(struct avctp *session) { - avctp_passthrough_release(session, session->key.op); + int ret = avctp_passthrough_release(session, session->key.op); if (session->key.timer > 0) g_source_remove(session->key.timer); session->key.timer = 0; + session->key.op = AVC_INVALID; + session->key.hold = false; + + return ret; } -static bool set_pressed(struct avctp *session, uint8_t op) +static bool hold_pressed(struct avctp *session, uint8_t op) { - if (session->key.timer > 0) { - if (session->key.op == op) - return TRUE; - release_pressed(session); - } - - if (op != AVC_FAST_FORWARD && op != AVC_REWIND) + if (session->key.op != op || !session->key.hold) return FALSE; - session->key.op = op; - session->key.timer = g_timeout_add_seconds(AVC_PRESS_TIMEOUT, + if (session->key.timer == 0) + session->key.timer = g_timeout_add_seconds(AVC_HOLD_TIMEOUT, repeat_timeout, session); @@ -1886,26 +1887,43 @@ static gboolean avctp_passthrough_rsp(struct avctp *session, uint8_t code, uint8_t *operands, size_t operand_count, void *user_data) { + uint8_t op = operands[0]; + if (code != AVC_CTYPE_ACCEPTED) return FALSE; - if (set_pressed(session, operands[0])) + if (hold_pressed(session, op)) return FALSE; - avctp_passthrough_release(session, operands[0]); + if (op == session->key.op) + release_pressed(session); return FALSE; } -int avctp_send_passthrough(struct avctp *session, uint8_t op) +int avctp_send_passthrough(struct avctp *session, uint8_t op, bool hold) { - /* Auto release if key pressed */ - if (session->key.timer > 0) + if (op & 0x80) + return -EINVAL; + + /* Release previously unreleased key */ + if (session->key.op != AVC_INVALID && session->key.op != op) release_pressed(session); + session->key.op = op; + session->key.hold = hold; return avctp_passthrough_press(session, op); } +int avctp_send_release_passthrough(struct avctp *session) +{ + if (session->key.op != AVC_INVALID) + return release_pressed(session); + + return 0; +} + + int avctp_send_vendordep(struct avctp *session, uint8_t transaction, uint8_t code, uint8_t subunit, uint8_t *operands, size_t operand_count) diff --git a/profiles/audio/avctp.h b/profiles/audio/avctp.h index c3cd49d88..95d95bbbe 100644 --- a/profiles/audio/avctp.h +++ b/profiles/audio/avctp.h @@ -118,6 +118,7 @@ #define AVC_BLUE 0x7c #define AVC_YELLOW 0x7c #define AVC_VENDOR_UNIQUE 0x7e +#define AVC_INVALID 0xff struct avctp; @@ -182,7 +183,9 @@ unsigned int avctp_register_browsing_pdu_handler(struct avctp *session, GDestroyNotify destroy); gboolean avctp_unregister_browsing_pdu_handler(unsigned int id); -int avctp_send_passthrough(struct avctp *session, uint8_t op); +int avctp_send_passthrough(struct avctp *session, uint8_t op, bool hold); +int avctp_send_release_passthrough(struct avctp *session); + int avctp_send_vendordep(struct avctp *session, uint8_t transaction, uint8_t code, uint8_t subunit, uint8_t *operands, size_t operand_count); diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 5d0256c52..d9471c083 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -2978,20 +2978,38 @@ static bool ct_set_setting(struct media_player *mp, const char *key, static int ct_press(struct avrcp_player *player, uint8_t op) { - int err; - struct avrcp *session; + struct avrcp *session = player->sessions->data; - session = player->sessions->data; if (session == NULL) return -ENOTCONN; set_ct_player(session, player); - err = avctp_send_passthrough(session->conn, op); - if (err < 0) - return err; + return avctp_send_passthrough(session->conn, op, false); +} - return 0; +static int ct_hold(struct avrcp_player *player, uint8_t op) +{ + struct avrcp *session = player->sessions->data; + + if (session == NULL) + return -ENOTCONN; + + set_ct_player(session, player); + + return avctp_send_passthrough(session->conn, op, true); +} + +static int ct_release(struct avrcp_player *player) +{ + struct avrcp *session = player->sessions->data; + + if (session == NULL) + return -ENOTCONN; + + set_ct_player(session, player); + + return avctp_send_release_passthrough(session->conn); } static int ct_play(struct media_player *mp, void *user_data) @@ -3033,14 +3051,37 @@ static int ct_fast_forward(struct media_player *mp, void *user_data) { struct avrcp_player *player = user_data; - return ct_press(player, AVC_FAST_FORWARD); + return ct_hold(player, AVC_FAST_FORWARD); } static int ct_rewind(struct media_player *mp, void *user_data) { struct avrcp_player *player = user_data; - return ct_press(player, AVC_REWIND); + return ct_hold(player, AVC_REWIND); +} + +static int ct_press_key(struct media_player *mp, uint8_t avc_key, + void *user_data) +{ + struct avrcp_player *player = user_data; + + return ct_press(player, avc_key); +} + +static int ct_hold_key(struct media_player *mp, uint8_t avc_key, + void *user_data) +{ + struct avrcp_player *player = user_data; + + return ct_hold(player, avc_key); +} + +static int ct_release_key(struct media_player *mp, void *user_data) +{ + struct avrcp_player *player = user_data; + + return ct_release(player); } static int ct_list_items(struct media_player *mp, const char *name, @@ -3388,6 +3429,9 @@ static const struct media_player_callback ct_cbs = { .previous = ct_previous, .fast_forward = ct_fast_forward, .rewind = ct_rewind, + .press = ct_press_key, + .hold = ct_hold_key, + .release = ct_release_key, .list_items = ct_list_items, .change_folder = ct_change_folder, .search = ct_search, diff --git a/profiles/audio/control.c b/profiles/audio/control.c index 4ab1f9b0f..14744ea94 100644 --- a/profiles/audio/control.c +++ b/profiles/audio/control.c @@ -136,7 +136,7 @@ int control_disconnect(struct btd_service *service) } static DBusMessage *key_pressed(DBusConnection *conn, DBusMessage *msg, - uint8_t op, void *data) + uint8_t op, bool hold, void *data) { struct control *control = data; int err; @@ -147,7 +147,7 @@ static DBusMessage *key_pressed(DBusConnection *conn, DBusMessage *msg, if (!control->target) return btd_error_not_supported(msg); - err = avctp_send_passthrough(control->session, op); + err = avctp_send_passthrough(control->session, op, hold); if (err < 0) return btd_error_failed(msg, strerror(-err)); @@ -157,55 +157,55 @@ static DBusMessage *key_pressed(DBusConnection *conn, DBusMessage *msg, static DBusMessage *control_volume_up(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_VOLUME_UP, data); + return key_pressed(conn, msg, AVC_VOLUME_UP, false, data); } static DBusMessage *control_volume_down(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_VOLUME_DOWN, data); + return key_pressed(conn, msg, AVC_VOLUME_DOWN, false, data); } static DBusMessage *control_play(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_PLAY, data); + return key_pressed(conn, msg, AVC_PLAY, false, data); } static DBusMessage *control_pause(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_PAUSE, data); + return key_pressed(conn, msg, AVC_PAUSE, false, data); } static DBusMessage *control_stop(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_STOP, data); + return key_pressed(conn, msg, AVC_STOP, false, data); } static DBusMessage *control_next(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_FORWARD, data); + return key_pressed(conn, msg, AVC_FORWARD, false, data); } static DBusMessage *control_previous(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_BACKWARD, data); + return key_pressed(conn, msg, AVC_BACKWARD, false, data); } static DBusMessage *control_fast_forward(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_FAST_FORWARD, data); + return key_pressed(conn, msg, AVC_FAST_FORWARD, true, data); } static DBusMessage *control_rewind(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_REWIND, data); + return key_pressed(conn, msg, AVC_REWIND, true, data); } static gboolean control_property_get_connected( diff --git a/profiles/audio/player.c b/profiles/audio/player.c index 09ee979e4..86c25d4b6 100644 --- a/profiles/audio/player.c +++ b/profiles/audio/player.c @@ -570,6 +570,68 @@ static DBusMessage *media_player_rewind(DBusConnection *conn, DBusMessage *msg, return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); } +static DBusMessage *media_player_press(DBusConnection *conn, DBusMessage *msg, + void *data) +{ + struct media_player *mp = data; + struct player_callback *cb = mp->cb; + int err; + uint8_t avc_key; + + if (cb->cbs->press == NULL) + return btd_error_not_supported(msg); + + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_BYTE, &avc_key, + DBUS_TYPE_INVALID)) + return btd_error_invalid_args(msg); + + err = cb->cbs->press(mp, avc_key, cb->user_data); + if (err < 0) + return btd_error_failed(msg, strerror(-err)); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static DBusMessage *media_player_hold(DBusConnection *conn, DBusMessage *msg, + void *data) +{ + struct media_player *mp = data; + struct player_callback *cb = mp->cb; + int err; + uint8_t avc_key; + + if (cb->cbs->hold == NULL) + return btd_error_not_supported(msg); + + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_BYTE, &avc_key, + DBUS_TYPE_INVALID)) + return btd_error_invalid_args(msg); + + err = cb->cbs->hold(mp, avc_key, cb->user_data); + if (err < 0) + return btd_error_failed(msg, strerror(-err)); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static DBusMessage *media_player_release(DBusConnection *conn, DBusMessage *msg, + void *data) +{ + struct media_player *mp = data; + struct player_callback *cb = mp->cb; + int err; + uint8_t avc_key; + + if (cb->cbs->release == NULL) + return btd_error_not_supported(msg); + + err = cb->cbs->release(mp, cb->user_data); + if (err < 0) + return btd_error_failed(msg, strerror(-err)); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + static void parse_folder_list(gpointer data, gpointer user_data) { struct media_item *item = data; @@ -704,6 +766,11 @@ static const GDBusMethodTable media_player_methods[] = { { GDBUS_METHOD("Previous", NULL, NULL, media_player_previous) }, { GDBUS_METHOD("FastForward", NULL, NULL, media_player_fast_forward) }, { GDBUS_METHOD("Rewind", NULL, NULL, media_player_rewind) }, + { GDBUS_METHOD("Press", GDBUS_ARGS({"avc_key", "y"}), NULL, + media_player_press) }, + { GDBUS_METHOD("Hold", GDBUS_ARGS({"avc_key", "y"}), NULL, + media_player_hold) }, + { GDBUS_METHOD("Release", NULL, NULL, media_player_release) }, { } }; diff --git a/profiles/audio/player.h b/profiles/audio/player.h index 536394ca6..e98550064 100644 --- a/profiles/audio/player.h +++ b/profiles/audio/player.h @@ -45,26 +45,31 @@ struct media_player; struct media_item; struct media_player_callback { - bool (*set_setting) (struct media_player *mp, const char *key, + bool (*set_setting)(struct media_player *mp, const char *key, const char *value, void *user_data); - int (*play) (struct media_player *mp, void *user_data); - int (*pause) (struct media_player *mp, void *user_data); - int (*stop) (struct media_player *mp, void *user_data); - int (*next) (struct media_player *mp, void *user_data); - int (*previous) (struct media_player *mp, void *user_data); - int (*fast_forward) (struct media_player *mp, void *user_data); - int (*rewind) (struct media_player *mp, void *user_data); - int (*list_items) (struct media_player *mp, const char *name, + int (*play)(struct media_player *mp, void *user_data); + int (*pause)(struct media_player *mp, void *user_data); + int (*stop)(struct media_player *mp, void *user_data); + int (*next)(struct media_player *mp, void *user_data); + int (*previous)(struct media_player *mp, void *user_data); + int (*fast_forward)(struct media_player *mp, void *user_data); + int (*rewind)(struct media_player *mp, void *user_data); + int (*press)(struct media_player *mp, uint8_t avc_key, + void *user_data); + int (*hold)(struct media_player *mp, uint8_t avc_key, + void *user_data); + int (*release)(struct media_player *mp, void *user_data); + int (*list_items)(struct media_player *mp, const char *name, uint32_t start, uint32_t end, void *user_data); - int (*change_folder) (struct media_player *mp, const char *path, + int (*change_folder)(struct media_player *mp, const char *path, uint64_t uid, void *user_data); - int (*search) (struct media_player *mp, const char *string, + int (*search)(struct media_player *mp, const char *string, void *user_data); - int (*play_item) (struct media_player *mp, const char *name, + int (*play_item)(struct media_player *mp, const char *name, uint64_t uid, void *user_data); - int (*add_to_nowplaying) (struct media_player *mp, const char *name, + int (*add_to_nowplaying)(struct media_player *mp, const char *name, uint64_t uid, void *user_data); - int (*total_items) (struct media_player *mp, const char *name, + int (*total_items)(struct media_player *mp, const char *name, void *user_data); }; -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EKVVGKtjUF8ZvgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 05:31:55 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id gIqTFqtjUF+nYQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 05:31:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6A788420B8; Thu, 3 Sep 2020 05:31:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728219AbgICDbm (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 23:31:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbgICDbe (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 23:31:34 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04FC9C061244 for <linux-bluetooth@vger.kernel.org>; Wed, 2 Sep 2020 20:31:33 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id f2so1902844qkh.3 for <linux-bluetooth@vger.kernel.org>; Wed, 02 Sep 2020 20:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=4NIdV8/+RibROmbtlr8Z5KvR5vcl5+4en+so/W/D6Ew=; b=CSezLu9a1P5lmpUsdoNcaC2vL85sp45RJ0kZS38M/Qf88KppR+4ZnTUW4Hx1ikf3uw RHJlL6zkL4Zp32mIr1qqN5EgtZRhq3cuOVs1L64IPi7HdW7WZBi8vR/eSxg705xFSBAe /Q2c/pIHvqxZbcr+sDJz8uiGSO0jc3EdVQjSDCupt3dviold4XH9RHSazWFkC7nBrc5z R1xyKA8y4yyqUoHAmJgBqYuUYuMQTedP/f95adbzQQrWG6yEzCE/SPc5cGhMfGK1aScM inp9Z9JRX/agWqSCY/Is2DfDmiasLhpEsk1HFA5BvlDjPsBhrlOwlkeRN+toMEz08A7C W6Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=4NIdV8/+RibROmbtlr8Z5KvR5vcl5+4en+so/W/D6Ew=; b=P2oucP1JDE1GDzUJPCaHZeq7cIPIhrbTcu37hI8LqxqYyCAzKThi1ZXQ68a4JtTMAA P13XcT2ah2KfYmj9MZh+jEZvT7UZm2bookowcopjBSOzXIBPt9zFpdRzoTHfHgufE76a VOncN2YRPKo+uUKLAAF5WHUXItKjQYRzCN2HUoCBDu4UTj+YeqkQkwnPOIYq3Xi+b27V sb24VLJ7XEcjDugzbkBHZX/6c37PZ15fQhMy9xpxfOpaY8C1PSzm6rqfeFeqPBQz2E7V qIgyNuoPZyJa6HkMFbBD4W4QLc5HGiwDFihaXaM0OWxq0pxWIjVZpqaU9WNw1ovWT/3D uq8A== X-Gm-Message-State: AOAM530ibaJ2Uorz603P7XtY35FB84Hch4OuSlwRzAQKzeX+sEbYOy50 jCJ7C2ezUOc7u6hGBNdYTsXbvR2wPlw= X-Google-Smtp-Source: ABdhPJzzsJ7Ge1HRAnqNcdJjOL5MzA86CoW8NJzYIvqHwdiA2QyjSeEA+UE+dRmBpWveJ84e/tYZsw== X-Received: by 2002:a37:86c1:: with SMTP id i184mr1274217qkd.189.1599103890247; Wed, 02 Sep 2020 20:31:30 -0700 (PDT) Received: from [172.17.0.2] ([20.190.246.205]) by smtp.gmail.com with ESMTPSA id p205sm1231562qke.2.2020.09.02.20.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2020 20:31:29 -0700 (PDT) Message-ID: <5f506391.1c69fb81.cfed7.8845@mx.google.com> Date: Wed, 02 Sep 2020 20:31:29 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============1064658887671059200==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, apusaka@google.com Subject: RE: [Bluez,v2,1/2] doc/media-api: Add Press/Hold/Release methods for MediaPlayer1 Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200903110031.Bluez.v2.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> References: <20200903110031.Bluez.v2.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ****** X-Rspamd-Score: 7.94 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6A788420B8 X-Rspamd-UID: a4dfce --===============1064658887671059200== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnByb2ZpbGVzL2F1ZGlvL3BsYXllci5jOiBJbiBmdW5jdGlvbiDigJht ZWRpYV9wbGF5ZXJfcmVsZWFzZeKAmToKcHJvZmlsZXMvYXVkaW8vcGxheWVyLmM6NjIzOjEwOiBl cnJvcjogdW51c2VkIHZhcmlhYmxlIOKAmGF2Y19rZXnigJkgWy1XZXJyb3I9dW51c2VkLXZhcmlh YmxlXQogIDYyMyB8ICB1aW50OF90IGF2Y19rZXk7CiAgICAgIHwgICAgICAgICAgXn5+fn5+fgpj YzE6IGFsbCB3YXJuaW5ncyBiZWluZyB0cmVhdGVkIGFzIGVycm9ycwptYWtlWzFdOiAqKiogW01h a2VmaWxlOjg0ODE6IHByb2ZpbGVzL2F1ZGlvL2JsdWV0b290aGQtcGxheWVyLm9dIEVycm9yIDEK bWFrZTogKioqIFtNYWtlZmlsZTo0MDEwOiBhbGxdIEVycm9yIDIKCgoKLS0tClJlZ2FyZHMsCkxp bnV4IEJsdWV0b290aAo= --===============1064658887671059200==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kPZtECxoUF/P1wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 05:51:08 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QHisDixoUF9nPwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 05:51:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ED338420B8; Thu, 3 Sep 2020 05:50:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726821AbgICDu6 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 23:50:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726654AbgICDu6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 23:50:58 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDA09C061244 for <linux-bluetooth@vger.kernel.org>; Wed, 2 Sep 2020 20:50:57 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id p138so1519187yba.12 for <linux-bluetooth@vger.kernel.org>; Wed, 02 Sep 2020 20:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=/FSgf2EPD/YJcQe1a7i0YAGBtiAsMfHL3A3+v0vuBC0=; b=g1v0faM52Nxm06t0CDxXxgCPDG8S8sAmtCSDegQTQdaB1+peSBjIvCRoMd7aQNEG5O BIohBF933VKvuezgZeMLE9/RCAOb9IIWpBwi8IObl2mrtHu7eYE+hwri3BWFJOgB6awY 5RQJS7iCgyC7fRiPeiU8Zwr0hTPXARmO7k7M+F3mzOiHk/WlyuyGqZbwAuZ+WugtPjOh BUdJELaMeb4nlZMm1NM1Gt5ldrtsDDG0gsCfWAYHTNXiu7kprLMU9sQSg1LZYrX9oSvP WXrrvopWxDjwSgAIWG5d1JHwAv+0IBVIQ//mla7Z+87F5wSMLfAvmPolPh9sR0Q5jJGm 4phg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=/FSgf2EPD/YJcQe1a7i0YAGBtiAsMfHL3A3+v0vuBC0=; b=XFjcV2b55tKaG3yA4lHrJttGVF5j1bjCphElQhj2QaQSybDHRDI1UX1yKdvBqg9n0H 3jbTglkyjTOXfjA0x2sIsC6xqc7DdwUaY7qrbgCMJZjOtYNLclHxCVFWJkwBYXZS6+u5 BJ9QpMKjfYIy4CgRECwOkugBd2umyhy5jjA8ip3Q/CO4ZUfvjVP7syO054dcIAZWU5LX sB6BCSfl5GmSKPCUHCgORcgNAhm2YiNO7fp5RyCeAuqfJl0z2E303tEa1CR2bhWv+PDb fOgAhRO3yaG65qX3D80z82f2DdoOyDZkTUxPC0REsxdsmhSeGcPFuqcV8UeI+NH65g+B mMiA== X-Gm-Message-State: AOAM530/kOeaeLJZq0OWY2jnPzrUi7jwm8sTOf2hf6/s0Z5aLwgzH3LC GcDc83Trffbl5OtYF9XKXhJJQcBjkqiMmPJiuoXtsrelPIGLMLoNU76WE1gpvWq1/piuf3KXuwY 9VJtPcl0e4vEI5LXG1MGgB+74GAgPh0vYlMqWEwk9XWM+wxVf+d83BgULoQaOPlrht4ojuqanI8 1H X-Google-Smtp-Source: ABdhPJybbsUs5HOk1fDx9wuuqgx3GoxG4SbzI9tSPChs1O+twa+CMiswd+DiIC9y8QFlrMDEmclcOX/6tx6u X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a25:c004:: with SMTP id c4mr1395166ybf.475.1599105056918; Wed, 02 Sep 2020 20:50:56 -0700 (PDT) Date: Thu, 3 Sep 2020 11:50:37 +0800 Message-Id: <20200903115020.Bluez.v3.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v3 1/2] doc/media-api: Add Press/Hold/Release methods for MediaPlayer1 From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.19 / 15.00 / 200.00 X-Rspamd-Queue-Id: ED338420B8 X-Rspamd-UID: eded1f From: Archie Pusaka <apusaka@chromium.org> This allows us to send any passthrough command. The button can also be held for an extended amount of time. Reviewed-by: Michael Sun <michaelfsun@chromium.org> --- (no changes since v2) Changes in v2: * Add Hold and Release methods doc/media-api.txt | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/doc/media-api.txt b/doc/media-api.txt index dabc69936..e98573157 100644 --- a/doc/media-api.txt +++ b/doc/media-api.txt @@ -199,6 +199,35 @@ Methods void Play() Possible Errors: org.bluez.Error.NotSupported org.bluez.Error.Failed + void Press(byte avc_key) + + Press a specific key to send as passthrough command. + The key will be released automatically. Use Hold() + instead if the intention is to hold down the key. + + Possible Errors: org.bluez.Error.InvalidArguments + org.bluez.Error.NotSupported + org.bluez.Error.Failed + + void Hold(byte avc_key) + + Press and hold a specific key to send as passthrough + command. It is your responsibility to make sure that + Release() is called after calling this method. The held + key will also be released when any other method in this + interface is called. + + Possible Errors: org.bluez.Error.InvalidArguments + org.bluez.Error.NotSupported + org.bluez.Error.Failed + + void Release() + + Release the previously held key invoked using Hold(). + + Possible Errors: org.bluez.Error.NotSupported + org.bluez.Error.Failed + Properties string Equalizer [readwrite] Possible values: "off" or "on" -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sCvxKENoUF+62gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 05:51:31 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id UIAwJ0NoUF+nYQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 05:51:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1A45DA1641; Thu, 3 Sep 2020 05:51:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728291AbgICDvU (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 23:51:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726654AbgICDvQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 23:51:16 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8A2BC061244 for <linux-bluetooth@vger.kernel.org>; Wed, 2 Sep 2020 20:51:16 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id b127so1499393ybh.21 for <linux-bluetooth@vger.kernel.org>; Wed, 02 Sep 2020 20:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=EGjzT6d+Azic/akyGX5B572G3ItSZIgHZP+YnPGKCUI=; b=MdTVz09dj4ZVgBGfZcDwREjhmh5T7p5N0DdqyzYfOsn2m6MkbNqub1UVCYzNg023jS e+Z0Q7pkFvzAEc+zgjdyCUAVQWo0vGG3mc+ZU2XSv4Ml4d/UPMAo75pAMfS2EjnQMFxs yYe8Nj0GBH0aviRwnvyjx8vNEVyxdNgKoMqNVLiRyViDPLmY1Tq6FQmdEYX9Qg6FRkJt 1utJaYXUZ8hHHNLitUwIN+azMo4Xk0mPONMs7tW3F30J5lGSc02C0O9yvK6uSXjhkbKp /x00OIFKGG4pvbixG3J4iYcLJX14x1VgEB0sYy2g6JZJAgqQrQykss2RMxkNfrCkXfV8 b6IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=EGjzT6d+Azic/akyGX5B572G3ItSZIgHZP+YnPGKCUI=; b=CWldvm78iBvNO5hhuyH1Wbk/XR624iksbKoszi3iBjXAbVJ9F1sVbB3txa1eyaHKnZ 8BNQIFsU0FFIXmDQ6kz4mwhXHNNXEQEgkPj3wHOFmVwHnbYUrd/nnannNh9mz2GQ50I3 It8P8FCb0I60RmGwx4Fk/Kjky/d/5flGIZZLuG9m5aDN4IK4Xngfo6j+WnlIbWtbOLwe jKR+8rtcyBt74/KXmrzqm3HKot/1Q6bnleIrSANJ4jcDzR4O1GgskyxebV2+61Dm3yMj c2Cx0cjPWa/1qz85ESyixAQzwygsxLHPlw+mqk+NsJmIRNwgnZ3CWKQJc3zH5HVmbCTu q3pA== X-Gm-Message-State: AOAM533FJ6wscoaetVJ49OEkmcIOKPrhvPSRpGAT6cbxUtDqesqotOKN sjxOYpuuIN8ppQLs82toZmFUu53Vm1ITARa9CovsIlDY3aQwL1HLsVuPg31C8WMG9iTJFp6JUSz CAbT9/VabMPdYdauo1VgrF+JQ4m8okakSOLkiDHpQGbHgNRb7hCkPtyfYK43lavGLQ/Ff74mqec yL X-Google-Smtp-Source: ABdhPJyJ8uZdT72Sw5Qj/MBRZ+WqVFJD+f4vrn2Q88V+Qkz/icvW/yV8s5LrZ9tuTpDd8RVhV37lhWqHT9Ud X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a25:8b09:: with SMTP id i9mr1396988ybl.149.1599105075840; Wed, 02 Sep 2020 20:51:15 -0700 (PDT) Date: Thu, 3 Sep 2020 11:50:39 +0800 In-Reply-To: <20200903115020.Bluez.v3.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> Message-Id: <20200903115020.Bluez.v3.2.Ia9ec99e1edde324e55c91828218268bc1b614136@changeid> Mime-Version: 1.0 References: <20200903115020.Bluez.v3.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [Bluez PATCH v3 2/2] avrcp: Implement Press/Hold/Release method for MediaPlayer1 From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.43 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1A45DA1641 X-Rspamd-UID: 597e06 From: Archie Pusaka <apusaka@chromium.org> This allows us to send any passthrough command, complete with the support to hold down the key. Using Press() will automatically release the key, while using Hold() will keep the key held until an explicit call to Release() is received. This doesn't allow us to hold multiple keys simultaneously, since according to the AV/C Panel Subunit Specification, part 9.4, when the target receive a pressed command without receiving a release command of the previous key, it will be treated as if the release command is sent but not received. Previously, the rewind and fast_forward keys are unique in terms that they are treated as holdable keys, this patch preserves that behavior of calling Rewind() and FastForward(). A rewind event which is reported via the new Press() method will automatically be released instead. --- Changes in v3: * Fix unused variable warning Changes in v2: * Implement Hold and Release method * Previously only a key with the repeat_timer will be released on the keypress of other key, now it send release message to whatever key is pressed before and is not released yet. profiles/audio/avctp.c | 54 +++++++++++++++++++++----------- profiles/audio/avctp.h | 5 ++- profiles/audio/avrcp.c | 62 +++++++++++++++++++++++++++++++------ profiles/audio/control.c | 22 +++++++------- profiles/audio/player.c | 66 ++++++++++++++++++++++++++++++++++++++++ profiles/audio/player.h | 33 +++++++++++--------- 6 files changed, 189 insertions(+), 53 deletions(-) diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c index a58623216..f096d22b0 100644 --- a/profiles/audio/avctp.c +++ b/profiles/audio/avctp.c @@ -60,6 +60,8 @@ * command with the pressed value is valid for two seconds */ #define AVC_PRESS_TIMEOUT 2 +/* We need to send hold event before AVC_PRESS time runs out */ +#define AVC_HOLD_TIMEOUT 1 #define CONTROL_TIMEOUT 10 #define BROWSING_TIMEOUT 10 @@ -191,6 +193,7 @@ struct avctp_channel { struct key_pressed { uint16_t op; guint timer; + bool hold; }; struct avctp { @@ -1500,6 +1503,7 @@ static struct avctp *avctp_get_internal(struct btd_device *device) session->device = btd_device_ref(device); session->state = AVCTP_STATE_DISCONNECTED; session->uinput = -1; + session->key.op = AVC_INVALID; server->sessions = g_slist_append(server->sessions, session); @@ -1846,35 +1850,32 @@ static gboolean repeat_timeout(gpointer user_data) { struct avctp *session = user_data; - avctp_passthrough_release(session, session->key.op); avctp_passthrough_press(session, session->key.op); return TRUE; } -static void release_pressed(struct avctp *session) +static int release_pressed(struct avctp *session) { - avctp_passthrough_release(session, session->key.op); + int ret = avctp_passthrough_release(session, session->key.op); if (session->key.timer > 0) g_source_remove(session->key.timer); session->key.timer = 0; + session->key.op = AVC_INVALID; + session->key.hold = false; + + return ret; } -static bool set_pressed(struct avctp *session, uint8_t op) +static bool hold_pressed(struct avctp *session, uint8_t op) { - if (session->key.timer > 0) { - if (session->key.op == op) - return TRUE; - release_pressed(session); - } - - if (op != AVC_FAST_FORWARD && op != AVC_REWIND) + if (session->key.op != op || !session->key.hold) return FALSE; - session->key.op = op; - session->key.timer = g_timeout_add_seconds(AVC_PRESS_TIMEOUT, + if (session->key.timer == 0) + session->key.timer = g_timeout_add_seconds(AVC_HOLD_TIMEOUT, repeat_timeout, session); @@ -1886,26 +1887,43 @@ static gboolean avctp_passthrough_rsp(struct avctp *session, uint8_t code, uint8_t *operands, size_t operand_count, void *user_data) { + uint8_t op = operands[0]; + if (code != AVC_CTYPE_ACCEPTED) return FALSE; - if (set_pressed(session, operands[0])) + if (hold_pressed(session, op)) return FALSE; - avctp_passthrough_release(session, operands[0]); + if (op == session->key.op) + release_pressed(session); return FALSE; } -int avctp_send_passthrough(struct avctp *session, uint8_t op) +int avctp_send_passthrough(struct avctp *session, uint8_t op, bool hold) { - /* Auto release if key pressed */ - if (session->key.timer > 0) + if (op & 0x80) + return -EINVAL; + + /* Release previously unreleased key */ + if (session->key.op != AVC_INVALID && session->key.op != op) release_pressed(session); + session->key.op = op; + session->key.hold = hold; return avctp_passthrough_press(session, op); } +int avctp_send_release_passthrough(struct avctp *session) +{ + if (session->key.op != AVC_INVALID) + return release_pressed(session); + + return 0; +} + + int avctp_send_vendordep(struct avctp *session, uint8_t transaction, uint8_t code, uint8_t subunit, uint8_t *operands, size_t operand_count) diff --git a/profiles/audio/avctp.h b/profiles/audio/avctp.h index c3cd49d88..95d95bbbe 100644 --- a/profiles/audio/avctp.h +++ b/profiles/audio/avctp.h @@ -118,6 +118,7 @@ #define AVC_BLUE 0x7c #define AVC_YELLOW 0x7c #define AVC_VENDOR_UNIQUE 0x7e +#define AVC_INVALID 0xff struct avctp; @@ -182,7 +183,9 @@ unsigned int avctp_register_browsing_pdu_handler(struct avctp *session, GDestroyNotify destroy); gboolean avctp_unregister_browsing_pdu_handler(unsigned int id); -int avctp_send_passthrough(struct avctp *session, uint8_t op); +int avctp_send_passthrough(struct avctp *session, uint8_t op, bool hold); +int avctp_send_release_passthrough(struct avctp *session); + int avctp_send_vendordep(struct avctp *session, uint8_t transaction, uint8_t code, uint8_t subunit, uint8_t *operands, size_t operand_count); diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 5d0256c52..d9471c083 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -2978,20 +2978,38 @@ static bool ct_set_setting(struct media_player *mp, const char *key, static int ct_press(struct avrcp_player *player, uint8_t op) { - int err; - struct avrcp *session; + struct avrcp *session = player->sessions->data; - session = player->sessions->data; if (session == NULL) return -ENOTCONN; set_ct_player(session, player); - err = avctp_send_passthrough(session->conn, op); - if (err < 0) - return err; + return avctp_send_passthrough(session->conn, op, false); +} - return 0; +static int ct_hold(struct avrcp_player *player, uint8_t op) +{ + struct avrcp *session = player->sessions->data; + + if (session == NULL) + return -ENOTCONN; + + set_ct_player(session, player); + + return avctp_send_passthrough(session->conn, op, true); +} + +static int ct_release(struct avrcp_player *player) +{ + struct avrcp *session = player->sessions->data; + + if (session == NULL) + return -ENOTCONN; + + set_ct_player(session, player); + + return avctp_send_release_passthrough(session->conn); } static int ct_play(struct media_player *mp, void *user_data) @@ -3033,14 +3051,37 @@ static int ct_fast_forward(struct media_player *mp, void *user_data) { struct avrcp_player *player = user_data; - return ct_press(player, AVC_FAST_FORWARD); + return ct_hold(player, AVC_FAST_FORWARD); } static int ct_rewind(struct media_player *mp, void *user_data) { struct avrcp_player *player = user_data; - return ct_press(player, AVC_REWIND); + return ct_hold(player, AVC_REWIND); +} + +static int ct_press_key(struct media_player *mp, uint8_t avc_key, + void *user_data) +{ + struct avrcp_player *player = user_data; + + return ct_press(player, avc_key); +} + +static int ct_hold_key(struct media_player *mp, uint8_t avc_key, + void *user_data) +{ + struct avrcp_player *player = user_data; + + return ct_hold(player, avc_key); +} + +static int ct_release_key(struct media_player *mp, void *user_data) +{ + struct avrcp_player *player = user_data; + + return ct_release(player); } static int ct_list_items(struct media_player *mp, const char *name, @@ -3388,6 +3429,9 @@ static const struct media_player_callback ct_cbs = { .previous = ct_previous, .fast_forward = ct_fast_forward, .rewind = ct_rewind, + .press = ct_press_key, + .hold = ct_hold_key, + .release = ct_release_key, .list_items = ct_list_items, .change_folder = ct_change_folder, .search = ct_search, diff --git a/profiles/audio/control.c b/profiles/audio/control.c index 4ab1f9b0f..14744ea94 100644 --- a/profiles/audio/control.c +++ b/profiles/audio/control.c @@ -136,7 +136,7 @@ int control_disconnect(struct btd_service *service) } static DBusMessage *key_pressed(DBusConnection *conn, DBusMessage *msg, - uint8_t op, void *data) + uint8_t op, bool hold, void *data) { struct control *control = data; int err; @@ -147,7 +147,7 @@ static DBusMessage *key_pressed(DBusConnection *conn, DBusMessage *msg, if (!control->target) return btd_error_not_supported(msg); - err = avctp_send_passthrough(control->session, op); + err = avctp_send_passthrough(control->session, op, hold); if (err < 0) return btd_error_failed(msg, strerror(-err)); @@ -157,55 +157,55 @@ static DBusMessage *key_pressed(DBusConnection *conn, DBusMessage *msg, static DBusMessage *control_volume_up(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_VOLUME_UP, data); + return key_pressed(conn, msg, AVC_VOLUME_UP, false, data); } static DBusMessage *control_volume_down(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_VOLUME_DOWN, data); + return key_pressed(conn, msg, AVC_VOLUME_DOWN, false, data); } static DBusMessage *control_play(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_PLAY, data); + return key_pressed(conn, msg, AVC_PLAY, false, data); } static DBusMessage *control_pause(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_PAUSE, data); + return key_pressed(conn, msg, AVC_PAUSE, false, data); } static DBusMessage *control_stop(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_STOP, data); + return key_pressed(conn, msg, AVC_STOP, false, data); } static DBusMessage *control_next(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_FORWARD, data); + return key_pressed(conn, msg, AVC_FORWARD, false, data); } static DBusMessage *control_previous(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_BACKWARD, data); + return key_pressed(conn, msg, AVC_BACKWARD, false, data); } static DBusMessage *control_fast_forward(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_FAST_FORWARD, data); + return key_pressed(conn, msg, AVC_FAST_FORWARD, true, data); } static DBusMessage *control_rewind(DBusConnection *conn, DBusMessage *msg, void *data) { - return key_pressed(conn, msg, AVC_REWIND, data); + return key_pressed(conn, msg, AVC_REWIND, true, data); } static gboolean control_property_get_connected( diff --git a/profiles/audio/player.c b/profiles/audio/player.c index 09ee979e4..27a7efb7e 100644 --- a/profiles/audio/player.c +++ b/profiles/audio/player.c @@ -570,6 +570,67 @@ static DBusMessage *media_player_rewind(DBusConnection *conn, DBusMessage *msg, return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); } +static DBusMessage *media_player_press(DBusConnection *conn, DBusMessage *msg, + void *data) +{ + struct media_player *mp = data; + struct player_callback *cb = mp->cb; + int err; + uint8_t avc_key; + + if (cb->cbs->press == NULL) + return btd_error_not_supported(msg); + + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_BYTE, &avc_key, + DBUS_TYPE_INVALID)) + return btd_error_invalid_args(msg); + + err = cb->cbs->press(mp, avc_key, cb->user_data); + if (err < 0) + return btd_error_failed(msg, strerror(-err)); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static DBusMessage *media_player_hold(DBusConnection *conn, DBusMessage *msg, + void *data) +{ + struct media_player *mp = data; + struct player_callback *cb = mp->cb; + int err; + uint8_t avc_key; + + if (cb->cbs->hold == NULL) + return btd_error_not_supported(msg); + + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_BYTE, &avc_key, + DBUS_TYPE_INVALID)) + return btd_error_invalid_args(msg); + + err = cb->cbs->hold(mp, avc_key, cb->user_data); + if (err < 0) + return btd_error_failed(msg, strerror(-err)); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static DBusMessage *media_player_release(DBusConnection *conn, DBusMessage *msg, + void *data) +{ + struct media_player *mp = data; + struct player_callback *cb = mp->cb; + int err; + + if (cb->cbs->release == NULL) + return btd_error_not_supported(msg); + + err = cb->cbs->release(mp, cb->user_data); + if (err < 0) + return btd_error_failed(msg, strerror(-err)); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + static void parse_folder_list(gpointer data, gpointer user_data) { struct media_item *item = data; @@ -704,6 +765,11 @@ static const GDBusMethodTable media_player_methods[] = { { GDBUS_METHOD("Previous", NULL, NULL, media_player_previous) }, { GDBUS_METHOD("FastForward", NULL, NULL, media_player_fast_forward) }, { GDBUS_METHOD("Rewind", NULL, NULL, media_player_rewind) }, + { GDBUS_METHOD("Press", GDBUS_ARGS({"avc_key", "y"}), NULL, + media_player_press) }, + { GDBUS_METHOD("Hold", GDBUS_ARGS({"avc_key", "y"}), NULL, + media_player_hold) }, + { GDBUS_METHOD("Release", NULL, NULL, media_player_release) }, { } }; diff --git a/profiles/audio/player.h b/profiles/audio/player.h index 536394ca6..e98550064 100644 --- a/profiles/audio/player.h +++ b/profiles/audio/player.h @@ -45,26 +45,31 @@ struct media_player; struct media_item; struct media_player_callback { - bool (*set_setting) (struct media_player *mp, const char *key, + bool (*set_setting)(struct media_player *mp, const char *key, const char *value, void *user_data); - int (*play) (struct media_player *mp, void *user_data); - int (*pause) (struct media_player *mp, void *user_data); - int (*stop) (struct media_player *mp, void *user_data); - int (*next) (struct media_player *mp, void *user_data); - int (*previous) (struct media_player *mp, void *user_data); - int (*fast_forward) (struct media_player *mp, void *user_data); - int (*rewind) (struct media_player *mp, void *user_data); - int (*list_items) (struct media_player *mp, const char *name, + int (*play)(struct media_player *mp, void *user_data); + int (*pause)(struct media_player *mp, void *user_data); + int (*stop)(struct media_player *mp, void *user_data); + int (*next)(struct media_player *mp, void *user_data); + int (*previous)(struct media_player *mp, void *user_data); + int (*fast_forward)(struct media_player *mp, void *user_data); + int (*rewind)(struct media_player *mp, void *user_data); + int (*press)(struct media_player *mp, uint8_t avc_key, + void *user_data); + int (*hold)(struct media_player *mp, uint8_t avc_key, + void *user_data); + int (*release)(struct media_player *mp, void *user_data); + int (*list_items)(struct media_player *mp, const char *name, uint32_t start, uint32_t end, void *user_data); - int (*change_folder) (struct media_player *mp, const char *path, + int (*change_folder)(struct media_player *mp, const char *path, uint64_t uid, void *user_data); - int (*search) (struct media_player *mp, const char *string, + int (*search)(struct media_player *mp, const char *string, void *user_data); - int (*play_item) (struct media_player *mp, const char *name, + int (*play_item)(struct media_player *mp, const char *name, uint64_t uid, void *user_data); - int (*add_to_nowplaying) (struct media_player *mp, const char *name, + int (*add_to_nowplaying)(struct media_player *mp, const char *name, uint64_t uid, void *user_data); - int (*total_items) (struct media_player *mp, const char *name, + int (*total_items)(struct media_player *mp, const char *name, void *user_data); }; -- 2.28.0.402.g5ffc5be6b7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ME/IOvKPUF/+agEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 08:40:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id qN6eOfKPUF9nDQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 08:40:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A8DAFA12D1; Thu, 3 Sep 2020 08:40:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbgICGkh (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 3 Sep 2020 02:40:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:55582 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725919AbgICGkh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 3 Sep 2020 02:40:37 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 225EBAC1F; Thu, 3 Sep 2020 06:40:37 +0000 (UTC) Date: Thu, 03 Sep 2020 08:40:34 +0200 Message-ID: <s5h5z8v8isd.wl-tiwai@suse.de> From: Takashi Iwai <tiwai@suse.de> To: Alan Stern <stern@rowland.harvard.edu> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Eli Billauer <eli.billauer@gmail.com>, Emiliano Ingrassia <ingrassia@epigenesys.com>, Alexander Tsoy <alexander@tsoy.me>, "Geoffrey D. Bennett" <g@b4.vu>, Jussi Laako <jussi@sonarnerd.net>, Nick Kossifidis <mickflemm@gmail.com>, Dmitry Panchenko <dmitry@d-systems.ee>, Chris Wulff <crwulff@gmail.com>, Jesus Ramos <jesus-ramos@live.com> Subject: Re: [PATCH 01/10] USB: move snd_usb_pipe_sanity_check into the USB core In-Reply-To: <20200903004553.GA642955@rowland.harvard.edu> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-2-gregkh@linuxfoundation.org> <20200903004553.GA642955@rowland.harvard.edu> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.88 / 15.00 / 200.00 X-Rspamd-Queue-Id: A8DAFA12D1 X-Rspamd-UID: 0b7c11 On Thu, 03 Sep 2020 02:45:53 +0200, Alan Stern wrote: > > In a few places here this check is completely unnecessary. All it does > is verify that the device does have an endpoint 0 and the the type of > the endpoint matches the type of the pipe. Well, every USB device > always has an endpoint 0, and it is always a bidirectional control > endpoint. Therefore a simple static check is all you need: There's no > point calling usb_pipe_type_check() when the pipe is of the form > usb_{snd|rcv}ctrlpipe(dev, 0). > > In short, this check should be removed completely; it does nothing. Fair enough, but I think those removals should be in another patch. thanks, Takashi Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WFQ6FMGQT18SlgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 14:32:01 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id QIfQEsGQT1+SBAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 14:32:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0B765A1479; Wed, 2 Sep 2020 14:31:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbgIBMbp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 08:31:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbgIBMbc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 08:31:32 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED746C061244; Wed, 2 Sep 2020 05:31:31 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id t11so2227056plr.5; Wed, 02 Sep 2020 05:31:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=nWY+6erNVM6Xl8glEmPwXLUrDWTRISXUW1W403933l8=; b=VD0OSq39q348n1v0uQAp3k88+WIjjZosqgA9X8iTDSWTjcUIiBYN3MZ9VOTTkyBU/Q Q8A5ixCGv3EdEq1ELmY51HVWXGc6dVFfTsdeZMCnFDhjOZa2FlBInUpVq5Vrea0B3Ij5 8KFVifnTJ3frLnDMCOfvogXrKpMfrvqfZLCnChDBdXM6iRJ7ccpTaCPtYApB6msTmr5a TnM7Y9wvDxm0xsxg79JeuF/yIcTYKrAts5AAKNZD1I2OSDSdVrPUR2F+rRVe/9YNR+5R Faa2IUmCjlH7Il+4Irn4qnbm9MEs4rRa8geygx0mGNnyegeHbk7GuA/2LUGvi/S/7vF1 aabQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nWY+6erNVM6Xl8glEmPwXLUrDWTRISXUW1W403933l8=; b=T8R/J9o7Rx1Lb2PMpTm/M7EP17rwxp8BBwa7K0hkiMvz5s+UVahiGw4BecHsWD7yg8 IC6TB31kb3A8rRSY4/JxyzqYOxt5BqY6xIU3ZWLjbwoKdyVo4Fxoye+QLICcn3BrJNTU 4Vt7PBXsi5GGw8hdKM3WXzIuYq8l87JnHhDn7Xt/dAkoM8jVspthotP5tqY390VicVol cN5wfWkRgQ/4z9JxDnYy7dPkQ8O4H19ZFJKZVj3PsxoOAYJ6ONrB3zqm6p2ycZKrLi5u 83VaJ7KYCjImfADARpW4OMZd0Cr9xHTjOw3QFBEAaAqbFqB82tV3X/D3A+ztCbD3w822 qdLw== X-Gm-Message-State: AOAM533yV5tqpeXSl1HyD2Yrcxsploa1ag5YPaV6M6rJZnxvP89L2EZb KdJxu++3agDHkLTPtXyhnlw= X-Google-Smtp-Source: ABdhPJy5I6Gyc/KFdPbcmJPMUULGfd168li2aLRy3APbEPCpTrTUdoGGSsFGxSMYWgDx+YsfSquKCw== X-Received: by 2002:a17:90a:bf8d:: with SMTP id d13mr2160253pjs.100.1599049891350; Wed, 02 Sep 2020 05:31:31 -0700 (PDT) Received: from localhost ([2001:e42:102:1532:160:16:113:140]) by smtp.gmail.com with ESMTPSA id gx5sm1062511pjb.57.2020.09.02.05.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2020 05:31:30 -0700 (PDT) From: Coiby Xu <coiby.xu@gmail.com> X-Google-Original-From: Coiby Xu <Coiby.Xu@gmail.com> Date: Wed, 2 Sep 2020 20:31:25 +0800 To: Marcel Holtmann <marcel@holtmann.org> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, linux-kernel-mentees@lists.linuxfoundation.org, Greg KH <gregkh@linuxfoundation.org>, syzkaller-bugs@googlegroups.com, syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com, Johan Hedberg <johan.hedberg@gmail.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org>, open list <linux-kernel@vger.kernel.org> Subject: Re: [PATCH] Bluetooth: fix "list_add double add" in hci_conn_complete_evt Message-ID: <20200902122357.ca2fztgah7gwz7yp@Rk> References: <000000000000c57f2d05ac4c5b8e@google.com> <20200823010022.938532-1-coiby.xu@gmail.com> <C0A907BA-9C0D-4124-A2AF-3748055DB062@holtmann.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="yijhrv2ys2svaijk" Content-Disposition: inline In-Reply-To: <C0A907BA-9C0D-4124-A2AF-3748055DB062@holtmann.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.04 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0B765A1479 X-Rspamd-UID: c0ba9e --yijhrv2ys2svaijk Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline On Mon, Aug 31, 2020 at 06:06:18PM +0200, Marcel Holtmann wrote: >Hi Coiby, Hi Marcel, Thank you for reviewing this patch! > >> When two HCI_EV_CONN_COMPLETE event packets with status=0 of the same >> HCI connection are received, device_add would be called twice which >> leads to kobject_add being called twice. Thus duplicate >> (struct hci_conn *conn)->dev.kobj.entry would be inserted into >> (struct hci_conn *conn)->dev.kobj.kset->list. >> >> This issue can be fixed by checking (struct hci_conn *conn)->debugfs. >> If it's not NULL, it means the HCI connection has been completed and we >> won't duplicate the work as for processing the first >> HCI_EV_CONN_COMPLETE event. > >do you have a btmon trace for this happening? Please see the attachment "btmon_output" which is a plain text file. I couldn't find a way to save traces in btsnoop format (the kernel would panic immediately after running the re-producer before QEMU has a chance to write the btsnoop file to the disk image). I've also also attached a simplified re-producer rep9_min.c if it interests you. > >> Reported-and-tested-by: syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com >> Link: https://syzkaller.appspot.com/bug?extid=dd768a260f7358adbaf9 >> Signed-off-by: Coiby Xu <coiby.xu@gmail.com> >> --- >> net/bluetooth/hci_event.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c >> index 4b7fc430793c..1233739ce760 100644 >> --- a/net/bluetooth/hci_event.c >> +++ b/net/bluetooth/hci_event.c >> @@ -2605,6 +2605,11 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) >> } >> >> if (!ev->status) { >> + if (conn->debugfs) { >> + bt_dev_err(hdev, "The connection has been completed"); >> + goto unlock; >> + } >> + > >And instead of doing papering over a hole, I would rather detect that the HCI event is not valid since we already received one for this connection. To check conn->debugfs is what I think could be used to detect this duplicate HCI event. Or you are suggesting this is not sufficient and implement something like a state machine instead? > >Regards > >Marcel > -- Best regards, Coiby --yijhrv2ys2svaijk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=btmon_output Bluetooth monitor ver 5.54 = Note: Linux version 5.8.0+ (x86_64) 0.447880 = Note: Bluetooth subsystem version 2.22 0.447950 @ MGMT Open: btmon (privileged) version 1.18 {0x0001} 0.449370 = New Index: 00:00:00:00:00:00 (Primary,Virtual,hci0) [hci0] 5.834012 @ RAW Open: rep9_ (privileged) version 2.22 {0x0002} 5.840840 = Open Index: 00:00:00:00:00:00 [hci0] 5.843719 < HCI Command: Reset (0x03|0x0003) plen 0 #1 [hci0] 5.844689 > HCI Event: Command Complete (0x0e) plen 252 #2 [hci0] 5.844982 Reset (0x03|0x0003) ncmd 1 invalid packet size 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 ......... < HCI Command: Read Local Supported... (0x04|0x0003) plen 0 #3 [hci0] 5.845194 > HCI Event: Command Complete (0x0e) plen 252 #4 [hci0] 5.845356 Read Local Supported Features (0x04|0x0003) ncmd 1 invalid packet size 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 ......... < HCI Command: Read Local Version In.. (0x04|0x0001) plen 0 #5 [hci0] 5.845522 > HCI Event: Command Complete (0x0e) plen 252 #6 [hci0] 5.845593 Read Local Version Information (0x04|0x0001) ncmd 1 invalid packet size 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 ......... < HCI Command: Read BD ADDR (0x04|0x0009) plen 0 #7 [hci0] 5.845849 > HCI Event: Command Complete (0x0e) plen 10 #8 [hci0] 5.845914 Read BD ADDR (0x04|0x0009) ncmd 1 Status: Success (0x00) [ 50.133219][ T8087] kobject_add_internal failed for hci0:200 with -EEXIST, don't try to register things with the same name in the same directory. [ 50.135031][ T8087] Bluetooth: hci0: failed to register connection device Address: AA:AA:AA:AA:AA:AA (OUI AA-AA-AA) < HCI Command: Read Buffer Size (0x04|0x0005) plen 0 #9 [hci0] 5.846623 > HCI Event: Command Complete (0x0e) plen 11 #10 [hci0] 5.846710 Read Buffer Size (0x04|0x0005) ncmd 1 Status: Success (0x00) ACL MTU: 1021 ACL max packet: 4 SCO MTU: 96 SCO max packet: 6 < HCI Command: Read Class of Device (0x03|0x0023) plen 0 #11 [hci0] 5.846806 > HCI Event: Command Complete (0x0e) plen 252 #12 [hci0] 5.846862 Read Class of Device (0x03|0x0023) ncmd 1 invalid packet size 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 ......... < HCI Command: Read Local Name (0x03|0x0014) plen 0 #13 [hci0] 5.893252 > HCI Event: Command Complete (0x0e) plen 252 #14 [hci0] 5.893318 Read Local Name (0x03|0x0014) ncmd 1 Status: Success (0x00) Name: < HCI Command: Read Voice Setting (0x03|0x0025) plen 0 #15 [hci0] 5.893439 > HCI Event: Command Complete (0x0e) plen 252 #16 [hci0] 5.893490 Read Voice Setting (0x03|0x0025) ncmd 1 invalid packet size 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 ......... < HCI Command: Read Number of Suppo.. (0x03|0x0038) plen 0 #17 [hci0] 5.893559 > HCI Event: Command Complete (0x0e) plen 252 #18 [hci0] 5.893600 Read Number of Supported IAC (0x03|0x0038) ncmd 1 invalid packet size 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 ......... < HCI Command: Read Current IAC LAP (0x03|0x0039) plen 0 #19 [hci0] 5.893666 > HCI Event: Command Complete (0x0e) plen 252 #20 [hci0] 5.893710 Read Current IAC LAP (0x03|0x0039) ncmd 1 Status: Success (0x00) Number of IAC: 0 < HCI Command: Set Event Filter (0x03|0x0005) plen 1 #21 [hci0] 5.893777 Type: Clear All Filters (0x00) > HCI Event: Command Complete (0x0e) plen 252 #22 [hci0] 5.893818 Set Event Filter (0x03|0x0005) ncmd 1 invalid packet size 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 ......... < HCI Command: Write Connection Acc.. (0x03|0x0016) plen 2 #23 [hci0] 5.893884 Timeout: 20000.000 msec (0x7d00) > HCI Event: Command Complete (0x0e) plen 252 #24 [hci0] 5.893925 Write Connection Accept Timeout (0x03|0x0016) ncmd 1 invalid packet size 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 ......... = Index Info: AA:AA:AA:AA:AA.. (Ericsson Technology Licensing) [hci0] 5.894458 @ MGMT Event: Index Added (0x0004) plen 0 {0x0001} [hci0] 5.894531 < HCI Command: Write Scan Enable (0x03|0x001a) plen 1 #25 [hci0] 5.895481 Scan enable: Page Scan (0x02) > HCI Event: Command Complete (0x0e) plen 4 #26 [hci0] 5.895547 Write Scan Enable (0x03|0x001a) ncmd 1 Status: Success (0x00) > HCI Event: Connect Request (0x04) plen 10 #27 [hci0] 5.895786 Address: 10:AA:AA:AA:AA:AA (OUI 10-AA-AA) Class: 0x000000 Major class: Miscellaneous Minor class: 0x00 Link type: ACL (0x01) > HCI Event: Connect Complete (0x03) plen 11 #28 [hci0] 5.895828 Status: Success (0x00) Handle: 200 Address: 10:AA:AA:AA:AA:AA (OUI 10-AA-AA) Link type: ACL (0x01) Encryption: Disabled (0x00) > HCI Event: Connect Complete (0x03) plen 11 #29 [hci0] 5.895842 Status: Success (0x00) Handle: 200 Address: 10:AA:AA:AA:AA:AA (OUI 10-AA-AA) Link type: ACL (0x01) Encryption: Disabled (0x00) @ RAW Close: rep9_ {0x0002} 5.951790 < HCI Command: Accept Connection Re.. (0x01|0x0009) plen 7 #30 [hci0] 6.130913 Address: 10:AA:AA:AA:AA:AA (OUI 10-AA-AA) Role: Slave (0x01) --yijhrv2ys2svaijk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rep9_min.c" // based on the reproducer // https://syzkaller.appspot.com/bug?id=f0ec9a394925aafbdf13d0a7e6af4cff860f0ed6 // wich is autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <pthread.h> #include <sched.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/epoll.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/resource.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/uio.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> #include <linux/capability.h> const int kInitNetNsFd = 239; #define MAX_FDS 30 static long syz_init_net_socket(volatile long domain, volatile long type, volatile long proto) { int netns = open("/proc/self/ns/net", O_RDONLY); if (netns == -1) return netns; int sock = syscall(__NR_socket, domain, type, proto); int err = errno; /** if (setns(netns, 0)) */ /** exit(1); */ close(netns); errno = err; return sock; } #define BTPROTO_HCI 1 #define ACL_LINK 1 #define SCAN_PAGE 2 typedef struct { uint8_t b[6]; } __attribute__((packed)) bdaddr_t; #define HCI_COMMAND_PKT 1 #define HCI_EVENT_PKT 4 #define HCI_VENDOR_PKT 0xff struct hci_command_hdr { uint16_t opcode; uint8_t plen; } __attribute__((packed)); struct hci_event_hdr { uint8_t evt; uint8_t plen; } __attribute__((packed)); #define HCI_EV_CONN_COMPLETE 0x03 struct hci_ev_conn_complete { uint8_t status; uint16_t handle; bdaddr_t bdaddr; uint8_t link_type; uint8_t encr_mode; } __attribute__((packed)); #define HCI_EV_CONN_REQUEST 0x04 struct hci_ev_conn_request { bdaddr_t bdaddr; uint8_t dev_class[3]; uint8_t link_type; } __attribute__((packed)); #define HCI_EV_REMOTE_FEATURES 0x0b struct hci_ev_remote_features { uint8_t status; uint16_t handle; uint8_t features[8]; } __attribute__((packed)); #define HCI_EV_CMD_COMPLETE 0x0e struct hci_ev_cmd_complete { uint8_t ncmd; uint16_t opcode; } __attribute__((packed)); #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a #define HCI_OP_READ_BUFFER_SIZE 0x1005 struct hci_rp_read_buffer_size { uint8_t status; uint16_t acl_mtu; uint8_t sco_mtu; uint16_t acl_max_pkt; uint16_t sco_max_pkt; } __attribute__((packed)); #define HCI_OP_READ_BD_ADDR 0x1009 struct hci_rp_read_bd_addr { uint8_t status; bdaddr_t bdaddr; } __attribute__((packed)); #define HCI_EV_LE_META 0x3e struct hci_ev_le_meta { uint8_t subevent; } __attribute__((packed)); #define HCI_EV_LE_CONN_COMPLETE 0x01 struct hci_ev_le_conn_complete { uint8_t status; uint16_t handle; uint8_t role; uint8_t bdaddr_type; bdaddr_t bdaddr; uint16_t interval; uint16_t latency; uint16_t supervision_timeout; uint8_t clk_accurancy; } __attribute__((packed)); struct hci_dev_req { uint16_t dev_id; uint32_t dev_opt; }; struct vhci_vendor_pkt { uint8_t type; uint8_t opcode; uint16_t id; }; #define HCIDEVUP _IOW('H', 201, int) #define HCISETSCAN _IOW('H', 221, int) static int vhci_fd = -1; static void hci_send_event_packet(int fd, uint8_t evt, void* data, size_t data_len) { struct iovec iv[3]; struct hci_event_hdr hdr; hdr.evt = evt; hdr.plen = data_len; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = data; iv[2].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } static void hci_send_event_cmd_complete(int fd, uint16_t opcode, void* data, size_t data_len) { struct iovec iv[4]; struct hci_event_hdr hdr; hdr.evt = HCI_EV_CMD_COMPLETE; hdr.plen = sizeof(struct hci_ev_cmd_complete) + data_len; struct hci_ev_cmd_complete evt_hdr; evt_hdr.ncmd = 1; evt_hdr.opcode = opcode; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = &evt_hdr; iv[2].iov_len = sizeof(evt_hdr); iv[3].iov_base = data; iv[3].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } #define HCI_HANDLE_1 200 #define HCI_HANDLE_2 201 static void send_complte_ev() { struct hci_ev_conn_complete complete; memset(&complete, 0, sizeof(complete)); complete.status = 0; complete.handle = HCI_HANDLE_1; memset(&complete.bdaddr, 0xaa, 6); *(uint8_t*)&complete.bdaddr.b[5] = 0x10; complete.link_type = ACL_LINK; complete.encr_mode = 0; hci_send_event_packet(vhci_fd, HCI_EV_CONN_COMPLETE, &complete, sizeof(complete)); } static bool process_command_pkt(int fd, char* buf, ssize_t buf_size) { struct hci_command_hdr* hdr = (struct hci_command_hdr*)buf; if (buf_size < (ssize_t)sizeof(struct hci_command_hdr) || hdr->plen != buf_size - sizeof(struct hci_command_hdr)) { exit(1); } switch (hdr->opcode) { case HCI_OP_WRITE_SCAN_ENABLE: { uint8_t status = 0; hci_send_event_cmd_complete(fd, hdr->opcode, &status, sizeof(status)); return true; } case HCI_OP_READ_BD_ADDR: { struct hci_rp_read_bd_addr rp = {0}; rp.status = 0; memset(&rp.bdaddr, 0xaa, 6); hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } case HCI_OP_READ_BUFFER_SIZE: { struct hci_rp_read_buffer_size rp = {0}; rp.status = 0; rp.acl_mtu = 1021; rp.sco_mtu = 96; rp.acl_max_pkt = 4; rp.sco_max_pkt = 6; hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } } char dummy[0xf9] = {0}; hci_send_event_cmd_complete(fd, hdr->opcode, dummy, sizeof(dummy)); return false; } static void* event_thread(void* arg) { while (1) { char buf[1024] = {0}; ssize_t buf_size = read(vhci_fd, buf, sizeof(buf)); if (buf_size < 0) exit(1); if (buf_size > 0 && buf[0] == HCI_COMMAND_PKT) { if (process_command_pkt(vhci_fd, buf + 1, buf_size - 1)) break; } } return NULL; } static void initialize_vhci() { int hci_sock = syz_init_net_socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); if (hci_sock < 0) exit(1); vhci_fd = open("/dev/vhci", O_RDWR); if (vhci_fd == -1) exit(1); struct vhci_vendor_pkt vendor_pkt; if (read(vhci_fd, &vendor_pkt, sizeof(vendor_pkt)) != sizeof(vendor_pkt)) exit(1); if (vendor_pkt.type != HCI_VENDOR_PKT) exit(1); pthread_t th; if (pthread_create(&th, NULL, event_thread, NULL)) exit(1); if (ioctl(hci_sock, HCIDEVUP, vendor_pkt.id) && errno != EALREADY) exit(1); struct hci_dev_req dr = {0}; dr.dev_id = vendor_pkt.id; dr.dev_opt = SCAN_PAGE; if (ioctl(hci_sock, HCISETSCAN, &dr)) exit(1); struct hci_ev_conn_request request; memset(&request, 0, sizeof(request)); memset(&request.bdaddr, 0xaa, 6); *(uint8_t*)&request.bdaddr.b[5] = 0x10; request.link_type = ACL_LINK; hci_send_event_packet(vhci_fd, HCI_EV_CONN_REQUEST, &request, sizeof(request)); send_complte_ev(); send_complte_ev(); pthread_join(th, NULL); close(hci_sock); } int main(void) { initialize_vhci(); return 0; } --yijhrv2ys2svaijk-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YBYPNNqtT1/4OgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 16:36:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id UOZaMtqtT1/0mAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 16:36:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1BCA1420CC; Wed, 2 Sep 2020 16:36:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728122AbgIBOfp (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 10:35:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:57068 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727044AbgIBOfh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 10:35:37 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4F2C7B1AE; Wed, 2 Sep 2020 14:35:36 +0000 (UTC) Date: Wed, 02 Sep 2020 16:35:33 +0200 Message-ID: <s5hh7sg9rgq.wl-tiwai@suse.de> From: Takashi Iwai <tiwai@suse.de> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Eli Billauer <eli.billauer@gmail.com>, Emiliano Ingrassia <ingrassia@epigenesys.com>, Alan Stern <stern@rowland.harvard.edu>, Alexander Tsoy <alexander@tsoy.me>, "Geoffrey D. Bennett" <g@b4.vu>, Jussi Laako <jussi@sonarnerd.net>, Nick Kossifidis <mickflemm@gmail.com>, Dmitry Panchenko <dmitry@d-systems.ee>, Chris Wulff <crwulff@gmail.com>, Jesus Ramos <jesus-ramos@live.com> Subject: Re: [PATCH 01/10] USB: move snd_usb_pipe_sanity_check into the USB core In-Reply-To: <20200902110115.1994491-2-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-2-gregkh@linuxfoundation.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.78 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1BCA1420CC X-Rspamd-UID: 446640 On Wed, 02 Sep 2020 13:01:03 +0200, Greg Kroah-Hartman wrote: > > snd_usb_pipe_sanity_check() is a great function, so let's move it into > the USB core so that other parts of the kernel, including the USB core, > can call it. > > Name it usb_pipe_type_check() to match the existing > usb_urb_ep_type_check() call, which now uses this function. > > Cc: Jaroslav Kysela <perex@perex.cz> > Cc: Takashi Iwai <tiwai@suse.com> > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > Cc: Eli Billauer <eli.billauer@gmail.com> > Cc: Emiliano Ingrassia <ingrassia@epigenesys.com> > Cc: Alan Stern <stern@rowland.harvard.edu> > Cc: Alexander Tsoy <alexander@tsoy.me> > Cc: "Geoffrey D. Bennett" <g@b4.vu> > Cc: Jussi Laako <jussi@sonarnerd.net> > Cc: Nick Kossifidis <mickflemm@gmail.com> > Cc: Dmitry Panchenko <dmitry@d-systems.ee> > Cc: Chris Wulff <crwulff@gmail.com> > Cc: Jesus Ramos <jesus-ramos@live.com> > Cc: linux-usb@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: alsa-devel@alsa-project.org > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Takashi Iwai <tiwai@suse.de> thanks, Takashi > --- > drivers/usb/core/urb.c | 29 ++++++++++++++++++++++------- > include/linux/usb.h | 1 + > sound/usb/helper.c | 16 +--------------- > sound/usb/helper.h | 1 - > sound/usb/mixer_scarlett_gen2.c | 2 +- > sound/usb/quirks.c | 12 ++++++------ > 6 files changed, 31 insertions(+), 30 deletions(-) > > diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c > index 27e83e55a590..45bc2914c1ba 100644 > --- a/drivers/usb/core/urb.c > +++ b/drivers/usb/core/urb.c > @@ -192,24 +192,39 @@ static const int pipetypes[4] = { > }; > > /** > - * usb_urb_ep_type_check - sanity check of endpoint in the given urb > - * @urb: urb to be checked > + * usb_pipe_type_check - sanity check of a specific pipe for a usb device > + * @dev: struct usb_device to be checked > + * @pipe: pipe to check > * > * This performs a light-weight sanity check for the endpoint in the > - * given urb. It returns 0 if the urb contains a valid endpoint, otherwise > - * a negative error code. > + * given usb device. It returns 0 if the pipe is a valid for the specific usb > + * device, otherwise a negative error code. > */ > -int usb_urb_ep_type_check(const struct urb *urb) > +int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe) > { > const struct usb_host_endpoint *ep; > > - ep = usb_pipe_endpoint(urb->dev, urb->pipe); > + ep = usb_pipe_endpoint(dev, pipe); > if (!ep) > return -EINVAL; > - if (usb_pipetype(urb->pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) > + if (usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) > return -EINVAL; > return 0; > } > +EXPORT_SYMBOL_GPL(usb_pipe_type_check); > + > +/** > + * usb_urb_ep_type_check - sanity check of endpoint in the given urb > + * @urb: urb to be checked > + * > + * This performs a light-weight sanity check for the endpoint in the > + * given urb. It returns 0 if the urb contains a valid endpoint, otherwise > + * a negative error code. > + */ > +int usb_urb_ep_type_check(const struct urb *urb) > +{ > + return usb_pipe_type_check(urb->dev, urb->pipe); > +} > EXPORT_SYMBOL_GPL(usb_urb_ep_type_check); > > /** > diff --git a/include/linux/usb.h b/include/linux/usb.h > index 20c555db4621..0b3963d7ec38 100644 > --- a/include/linux/usb.h > +++ b/include/linux/usb.h > @@ -1764,6 +1764,7 @@ static inline int usb_urb_dir_out(struct urb *urb) > return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; > } > > +int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe); > int usb_urb_ep_type_check(const struct urb *urb); > > void *usb_alloc_coherent(struct usb_device *dev, size_t size, > diff --git a/sound/usb/helper.c b/sound/usb/helper.c > index 4c12cc5b53fd..cf92d7110773 100644 > --- a/sound/usb/helper.c > +++ b/sound/usb/helper.c > @@ -63,20 +63,6 @@ void *snd_usb_find_csint_desc(void *buffer, int buflen, void *after, u8 dsubtype > return NULL; > } > > -/* check the validity of pipe and EP types */ > -int snd_usb_pipe_sanity_check(struct usb_device *dev, unsigned int pipe) > -{ > - static const int pipetypes[4] = { > - PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT > - }; > - struct usb_host_endpoint *ep; > - > - ep = usb_pipe_endpoint(dev, pipe); > - if (!ep || usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) > - return -EINVAL; > - return 0; > -} > - > /* > * Wrapper for usb_control_msg(). > * Allocates a temp buffer to prevent dmaing from/to the stack. > @@ -89,7 +75,7 @@ int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, > void *buf = NULL; > int timeout; > > - if (snd_usb_pipe_sanity_check(dev, pipe)) > + if (usb_pipe_type_check(dev, pipe)) > return -EINVAL; > > if (size > 0) { > diff --git a/sound/usb/helper.h b/sound/usb/helper.h > index 5e8a18b4e7b9..f5b4c6647e4d 100644 > --- a/sound/usb/helper.h > +++ b/sound/usb/helper.h > @@ -7,7 +7,6 @@ unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size); > void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype); > void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype); > > -int snd_usb_pipe_sanity_check(struct usb_device *dev, unsigned int pipe); > int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, > __u8 request, __u8 requesttype, __u16 value, __u16 index, > void *data, __u16 size); > diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c > index 0ffff7640892..9609c6d9655c 100644 > --- a/sound/usb/mixer_scarlett_gen2.c > +++ b/sound/usb/mixer_scarlett_gen2.c > @@ -1978,7 +1978,7 @@ static int scarlett2_mixer_status_create(struct usb_mixer_interface *mixer) > return 0; > } > > - if (snd_usb_pipe_sanity_check(dev, pipe)) > + if (usb_pipe_type_check(dev, pipe)) > return -EINVAL; > > mixer->urb = usb_alloc_urb(0, GFP_KERNEL); > diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c > index abf99b814a0f..fc3aab04a0bc 100644 > --- a/sound/usb/quirks.c > +++ b/sound/usb/quirks.c > @@ -846,7 +846,7 @@ static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev) > static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 }; > void *buf; > > - if (snd_usb_pipe_sanity_check(dev, usb_sndintpipe(dev, 0x05))) > + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x05))) > return -EINVAL; > buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); > if (!buf) > @@ -875,7 +875,7 @@ static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev) > { > int ret; > > - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) > + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) > return -EINVAL; > ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), > 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE, > @@ -984,7 +984,7 @@ static int snd_usb_axefx3_boot_quirk(struct usb_device *dev) > > dev_dbg(&dev->dev, "Waiting for Axe-Fx III to boot up...\n"); > > - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) > + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) > return -EINVAL; > /* If the Axe-Fx III has not fully booted, it will timeout when trying > * to enable the audio streaming interface. A more generous timeout is > @@ -1018,7 +1018,7 @@ static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, > { > int err, actual_length; > > - if (snd_usb_pipe_sanity_check(dev, usb_sndintpipe(dev, 0x01))) > + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x01))) > return -EINVAL; > err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x01), buf, *length, > &actual_length, 1000); > @@ -1030,7 +1030,7 @@ static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, > > memset(buf, 0, buf_size); > > - if (snd_usb_pipe_sanity_check(dev, usb_rcvintpipe(dev, 0x82))) > + if (usb_pipe_type_check(dev, usb_rcvintpipe(dev, 0x82))) > return -EINVAL; > err = usb_interrupt_msg(dev, usb_rcvintpipe(dev, 0x82), buf, buf_size, > &actual_length, 1000); > @@ -1117,7 +1117,7 @@ static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) > { > int ret; > > - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) > + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) > return -EINVAL; > ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), > 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, > -- > 2.28.0 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GBUPIxeuT1/4OgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 16:37:11 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id SCCAIReuT1+MPwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 16:37:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3679B4210B; Wed, 2 Sep 2020 16:37:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727845AbgIBOgy (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 10:36:54 -0400 Received: from mx2.suse.de ([195.135.220.15]:57868 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727998AbgIBOgY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 10:36:24 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CAF8BB1AE; Wed, 2 Sep 2020 14:36:23 +0000 (UTC) Date: Wed, 02 Sep 2020 16:36:22 +0200 Message-ID: <s5hft809rfd.wl-tiwai@suse.de> From: Takashi Iwai <tiwai@suse.de> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH 06/10] sound: usx2y: move to use usb_control_msg_send() In-Reply-To: <20200902110115.1994491-7-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-7-gregkh@linuxfoundation.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.10 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3679B4210B X-Rspamd-UID: 5d6d26 On Wed, 02 Sep 2020 13:01:08 +0200, Greg Kroah-Hartman wrote: > > The usb_control_msg_send() call can handle data on the stack, as well as > returning an error if a "short" write happens, so move the driver over > to using that call instead. This ends up removing a helper function > that is no longer needed. > > Cc: Jaroslav Kysela <perex@perex.cz> > Cc: Takashi Iwai <tiwai@suse.com> > Cc: alsa-devel@alsa-project.org > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Takashi Iwai <tiwai@suse.de> thanks, Takashi > --- > sound/usb/usx2y/us122l.c | 42 ++++++++-------------------------------- > 1 file changed, 8 insertions(+), 34 deletions(-) > > diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c > index f86f7a61fb36..e5c5a0d03d8a 100644 > --- a/sound/usb/usx2y/us122l.c > +++ b/sound/usb/usx2y/us122l.c > @@ -82,40 +82,13 @@ static int us144_create_usbmidi(struct snd_card *card) > &US122L(card)->midi_list, &quirk); > } > > -/* > - * Wrapper for usb_control_msg(). > - * Allocates a temp buffer to prevent dmaing from/to the stack. > - */ > -static int us122l_ctl_msg(struct usb_device *dev, unsigned int pipe, > - __u8 request, __u8 requesttype, > - __u16 value, __u16 index, void *data, > - __u16 size, int timeout) > -{ > - int err; > - void *buf = NULL; > - > - if (size > 0) { > - buf = kmemdup(data, size, GFP_KERNEL); > - if (!buf) > - return -ENOMEM; > - } > - err = usb_control_msg(dev, pipe, request, requesttype, > - value, index, buf, size, timeout); > - if (size > 0) { > - memcpy(data, buf, size); > - kfree(buf); > - } > - return err; > -} > - > static void pt_info_set(struct usb_device *dev, u8 v) > { > int ret; > > - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), > - 'I', > - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, > - v, 0, NULL, 0, 1000); > + ret = usb_control_msg_send(dev, 0, 'I', > + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, > + v, 0, NULL, 0, 1000); > snd_printdd(KERN_DEBUG "%i\n", ret); > } > > @@ -305,10 +278,11 @@ static int us122l_set_sample_rate(struct usb_device *dev, int rate) > data[0] = rate; > data[1] = rate >> 8; > data[2] = rate >> 16; > - err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, > - USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, > - UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000); > - if (err < 0) > + err = usb_control_msg_send(dev, 0, UAC_SET_CUR, > + USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, > + UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, > + 1000); > + if (err) > snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n", > dev->devnum, rate, ep); > return err; > -- > 2.28.0 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GA6FExuuT1/4OgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 16:37:15 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id ABC7ERuuT19nhQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 16:37:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AC51242111; Wed, 2 Sep 2020 16:37:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728141AbgIBOhE (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 10:37:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:58314 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728140AbgIBOhC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 10:37:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9AC6FB1AE; Wed, 2 Sep 2020 14:36:59 +0000 (UTC) Date: Wed, 02 Sep 2020 16:36:58 +0200 Message-ID: <s5heenk9red.wl-tiwai@suse.de> From: Takashi Iwai <tiwai@suse.de> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH 07/10] sound: 6fire: move to use usb_control_msg_send() and usb_control_msg_recv() In-Reply-To: <20200902110115.1994491-8-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-8-gregkh@linuxfoundation.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.10 / 15.00 / 200.00 X-Rspamd-Queue-Id: AC51242111 X-Rspamd-UID: ac32bc On Wed, 02 Sep 2020 13:01:09 +0200, Greg Kroah-Hartman wrote: > > The usb_control_msg_send() and usb_control_msg_recv() calls can return > an error if a "short" write/read happens, so move the driver over to > using those calls instead, saving some logic in the wrapper functions > that were being used in this driver. > > This also resolves a long-staging bug where data on the stack was being > sent in a USB control message, which was not allowed. > > Cc: Jaroslav Kysela <perex@perex.cz> > Cc: Takashi Iwai <tiwai@suse.com> > Cc: alsa-devel@alsa-project.org > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Takashi Iwai <tiwai@suse.de> thanks, Takashi > --- > sound/usb/6fire/firmware.c | 38 +++++++++++++------------------------- > 1 file changed, 13 insertions(+), 25 deletions(-) > > diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c > index 69137c14d0dc..5b8994070c96 100644 > --- a/sound/usb/6fire/firmware.c > +++ b/sound/usb/6fire/firmware.c > @@ -158,29 +158,17 @@ static int usb6fire_fw_ihex_init(const struct firmware *fw, > static int usb6fire_fw_ezusb_write(struct usb_device *device, > int type, int value, char *data, int len) > { > - int ret; > - > - ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), type, > - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, > - value, 0, data, len, HZ); > - if (ret < 0) > - return ret; > - else if (ret != len) > - return -EIO; > - return 0; > + return usb_control_msg_send(device, 0, type, > + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, > + value, 0, data, len, HZ); > } > > static int usb6fire_fw_ezusb_read(struct usb_device *device, > int type, int value, char *data, int len) > { > - int ret = usb_control_msg(device, usb_rcvctrlpipe(device, 0), type, > - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, > - 0, data, len, HZ); > - if (ret < 0) > - return ret; > - else if (ret != len) > - return -EIO; > - return 0; > + return usb_control_msg_recv(device, 0, type, > + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, > + value, 0, data, len, HZ); > } > > static int usb6fire_fw_fpga_write(struct usb_device *device, > @@ -230,7 +218,7 @@ static int usb6fire_fw_ezusb_upload( > /* upload firmware image */ > data = 0x01; /* stop ezusb cpu */ > ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1); > - if (ret < 0) { > + if (ret) { > kfree(rec); > release_firmware(fw); > dev_err(&intf->dev, > @@ -242,7 +230,7 @@ static int usb6fire_fw_ezusb_upload( > while (usb6fire_fw_ihex_next_record(rec)) { /* write firmware */ > ret = usb6fire_fw_ezusb_write(device, 0xa0, rec->address, > rec->data, rec->len); > - if (ret < 0) { > + if (ret) { > kfree(rec); > release_firmware(fw); > dev_err(&intf->dev, > @@ -257,7 +245,7 @@ static int usb6fire_fw_ezusb_upload( > if (postdata) { /* write data after firmware has been uploaded */ > ret = usb6fire_fw_ezusb_write(device, 0xa0, postaddr, > postdata, postlen); > - if (ret < 0) { > + if (ret) { > dev_err(&intf->dev, > "unable to upload ezusb firmware %s: post urb.\n", > fwname); > @@ -267,7 +255,7 @@ static int usb6fire_fw_ezusb_upload( > > data = 0x00; /* resume ezusb cpu */ > ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1); > - if (ret < 0) { > + if (ret) { > dev_err(&intf->dev, > "unable to upload ezusb firmware %s: end message.\n", > fwname); > @@ -302,7 +290,7 @@ static int usb6fire_fw_fpga_upload( > end = fw->data + fw->size; > > ret = usb6fire_fw_ezusb_write(device, 8, 0, NULL, 0); > - if (ret < 0) { > + if (ret) { > kfree(buffer); > release_firmware(fw); > dev_err(&intf->dev, > @@ -327,7 +315,7 @@ static int usb6fire_fw_fpga_upload( > kfree(buffer); > > ret = usb6fire_fw_ezusb_write(device, 9, 0, NULL, 0); > - if (ret < 0) { > + if (ret) { > dev_err(&intf->dev, > "unable to upload fpga firmware: end urb.\n"); > return ret; > @@ -363,7 +351,7 @@ int usb6fire_fw_init(struct usb_interface *intf) > u8 buffer[12]; > > ret = usb6fire_fw_ezusb_read(device, 1, 0, buffer, 8); > - if (ret < 0) { > + if (ret) { > dev_err(&intf->dev, > "unable to receive device firmware state.\n"); > return ret; > -- > 2.28.0 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wKSFFaiuT1/hgQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 16:39:36 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id SAsWFKiuT19yogAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 16:39:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D0D27A2D00; Wed, 2 Sep 2020 16:39:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728016AbgIBOiu (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 10:38:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:32894 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727800AbgIBOin (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 10:38:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 23172B1AE; Wed, 2 Sep 2020 14:38:42 +0000 (UTC) Date: Wed, 02 Sep 2020 16:38:40 +0200 Message-ID: <s5hd0349rbj.wl-tiwai@suse.de> From: Takashi Iwai <tiwai@suse.de> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Vasily Khoruzhick <anarsoul@gmail.com> Subject: Re: [PATCH 08/10] sound: line6: move to use usb_control_msg_send() and usb_control_msg_recv() In-Reply-To: <20200902110115.1994491-11-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-11-gregkh@linuxfoundation.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: D0D27A2D00 X-Rspamd-UID: 0446da On Wed, 02 Sep 2020 13:01:12 +0200, Greg Kroah-Hartman wrote: > > The usb_control_msg_send() and usb_control_msg_recv() calls can return > an error if a "short" write/read happens, and they can handle data off > of the stack, so move the driver over to using those calls instead, > saving some logic when dynamically allocating memory. > > Cc: Jaroslav Kysela <perex@perex.cz> > Cc: Takashi Iwai <tiwai@suse.com> > Cc: Vasily Khoruzhick <anarsoul@gmail.com> > Cc: alsa-devel@alsa-project.org > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Takashi Iwai <tiwai@suse.de> thanks, Takashi > --- > sound/usb/line6/driver.c | 69 +++++++++++++++----------------------- > sound/usb/line6/podhd.c | 17 ++++------ > sound/usb/line6/toneport.c | 8 ++--- > 3 files changed, 37 insertions(+), 57 deletions(-) > > diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c > index 60674ce4879b..601292c51491 100644 > --- a/sound/usb/line6/driver.c > +++ b/sound/usb/line6/driver.c > @@ -337,23 +337,18 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, > { > struct usb_device *usbdev = line6->usbdev; > int ret; > - unsigned char *len; > + u8 len; > unsigned count; > > if (address > 0xffff || datalen > 0xff) > return -EINVAL; > > - len = kmalloc(1, GFP_KERNEL); > - if (!len) > - return -ENOMEM; > - > /* query the serial number: */ > - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > - (datalen << 8) | 0x21, address, > - NULL, 0, LINE6_TIMEOUT * HZ); > - > - if (ret < 0) { > + ret = usb_control_msg_send(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > + (datalen << 8) | 0x21, address, NULL, 0, > + LINE6_TIMEOUT * HZ); > + if (ret) { > dev_err(line6->ifcdev, "read request failed (error %d)\n", ret); > goto exit; > } > @@ -362,45 +357,41 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, > for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { > mdelay(LINE6_READ_WRITE_STATUS_DELAY); > > - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | > - USB_DIR_IN, > - 0x0012, 0x0000, len, 1, > - LINE6_TIMEOUT * HZ); > - if (ret < 0) { > + ret = usb_control_msg_recv(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, > + 0x0012, 0x0000, &len, 1, > + LINE6_TIMEOUT * HZ); > + if (ret) { > dev_err(line6->ifcdev, > "receive length failed (error %d)\n", ret); > goto exit; > } > > - if (*len != 0xff) > + if (len != 0xff) > break; > } > > ret = -EIO; > - if (*len == 0xff) { > + if (len == 0xff) { > dev_err(line6->ifcdev, "read failed after %d retries\n", > count); > goto exit; > - } else if (*len != datalen) { > + } else if (len != datalen) { > /* should be equal or something went wrong */ > dev_err(line6->ifcdev, > "length mismatch (expected %d, got %d)\n", > - (int)datalen, (int)*len); > + (int)datalen, len); > goto exit; > } > > /* receive the result: */ > - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, > - 0x0013, 0x0000, data, datalen, > - LINE6_TIMEOUT * HZ); > - > - if (ret < 0) > + ret = usb_control_msg_recv(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, > + 0x0013, 0x0000, data, datalen, LINE6_TIMEOUT * HZ); > + if (ret) > dev_err(line6->ifcdev, "read failed (error %d)\n", ret); > > exit: > - kfree(len); > return ret; > } > EXPORT_SYMBOL_GPL(line6_read_data); > @@ -423,12 +414,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, > if (!status) > return -ENOMEM; > > - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > - 0x0022, address, data, datalen, > - LINE6_TIMEOUT * HZ); > - > - if (ret < 0) { > + ret = usb_control_msg_send(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > + 0x0022, address, data, datalen, LINE6_TIMEOUT * HZ); > + if (ret) { > dev_err(line6->ifcdev, > "write request failed (error %d)\n", ret); > goto exit; > @@ -437,14 +426,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, > for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { > mdelay(LINE6_READ_WRITE_STATUS_DELAY); > > - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), > - 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | > - USB_DIR_IN, > - 0x0012, 0x0000, > - status, 1, LINE6_TIMEOUT * HZ); > - > - if (ret < 0) { > + ret = usb_control_msg_recv(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, > + 0x0012, 0x0000, status, 1, LINE6_TIMEOUT * HZ); > + if (ret) { > dev_err(line6->ifcdev, > "receiving status failed (error %d)\n", ret); > goto exit; > diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c > index eef45f7fef0d..a1261f55d62b 100644 > --- a/sound/usb/line6/podhd.c > +++ b/sound/usb/line6/podhd.c > @@ -183,29 +183,25 @@ static const struct attribute_group podhd_dev_attr_group = { > static int podhd_dev_start(struct usb_line6_podhd *pod) > { > int ret; > - u8 *init_bytes; > + u8 init_bytes[8]; > int i; > struct usb_device *usbdev = pod->line6.usbdev; > > - init_bytes = kmalloc(8, GFP_KERNEL); > - if (!init_bytes) > - return -ENOMEM; > - > - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), > + ret = usb_control_msg_send(usbdev, 0, > 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > 0x11, 0, > NULL, 0, LINE6_TIMEOUT * HZ); > - if (ret < 0) { > + if (ret) { > dev_err(pod->line6.ifcdev, "read request failed (error %d)\n", ret); > goto exit; > } > > /* NOTE: looks like some kind of ping message */ > - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, > + ret = usb_control_msg_recv(usbdev, 0, 0x67, > USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, > 0x11, 0x0, > init_bytes, 3, LINE6_TIMEOUT * HZ); > - if (ret < 0) { > + if (ret) { > dev_err(pod->line6.ifcdev, > "receive length failed (error %d)\n", ret); > goto exit; > @@ -220,13 +216,12 @@ static int podhd_dev_start(struct usb_line6_podhd *pod) > goto exit; > } > > - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), > + ret = usb_control_msg_send(usbdev, 0, > USB_REQ_SET_FEATURE, > USB_TYPE_STANDARD | USB_RECIP_DEVICE | USB_DIR_OUT, > 1, 0, > NULL, 0, LINE6_TIMEOUT * HZ); > exit: > - kfree(init_bytes); > return ret; > } > > diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c > index 94dd5e7ab2e6..a9b56085b76a 100644 > --- a/sound/usb/line6/toneport.c > +++ b/sound/usb/line6/toneport.c > @@ -126,11 +126,11 @@ static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2) > { > int ret; > > - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > - cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); > + ret = usb_control_msg_send(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > + cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); > > - if (ret < 0) { > + if (ret) { > dev_err(&usbdev->dev, "send failed (error %d)\n", ret); > return ret; > } > -- > 2.28.0 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kAEsM+quT19AbwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 16:40:42 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OFKjMequT19R1AAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 16:40:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3E8F3A2A69; Wed, 2 Sep 2020 16:40:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbgIBOkX (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 10:40:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:33680 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726654AbgIBOkR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 10:40:17 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 760A4B1AE; Wed, 2 Sep 2020 14:40:15 +0000 (UTC) Date: Wed, 02 Sep 2020 16:40:14 +0200 Message-ID: <s5hblio9r8x.wl-tiwai@suse.de> From: Takashi Iwai <tiwai@suse.de> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH 09/10] sound: hiface: move to use usb_control_msg_send() In-Reply-To: <20200902110115.1994491-13-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-13-gregkh@linuxfoundation.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.10 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3E8F3A2A69 X-Rspamd-UID: b4bb96 On Wed, 02 Sep 2020 13:01:14 +0200, Greg Kroah-Hartman wrote: > > The usb_control_msg_send() call can return an error if a "short" write > happens, so move the driver over to using that call instead. > > Cc: Jaroslav Kysela <perex@perex.cz> > Cc: Takashi Iwai <tiwai@suse.com> > Cc: alsa-devel@alsa-project.org > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Takashi Iwai <tiwai@suse.de> thanks, Takashi > --- > sound/usb/hiface/pcm.c | 14 ++++++-------- > 1 file changed, 6 insertions(+), 8 deletions(-) > > diff --git a/sound/usb/hiface/pcm.c b/sound/usb/hiface/pcm.c > index a148caa5f48e..f9c924e3964e 100644 > --- a/sound/usb/hiface/pcm.c > +++ b/sound/usb/hiface/pcm.c > @@ -156,16 +156,14 @@ static int hiface_pcm_set_rate(struct pcm_runtime *rt, unsigned int rate) > * This control message doesn't have any ack from the > * other side > */ > - ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), > - HIFACE_SET_RATE_REQUEST, > - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, > - rate_value, 0, NULL, 0, 100); > - if (ret < 0) { > + ret = usb_control_msg_send(device, 0, > + HIFACE_SET_RATE_REQUEST, > + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, > + rate_value, 0, NULL, 0, 100); > + if (ret) > dev_err(&device->dev, "Error setting samplerate %d.\n", rate); > - return ret; > - } > > - return 0; > + return ret; > } > > static struct pcm_substream *hiface_pcm_get_substream(struct snd_pcm_substream > -- > 2.28.0 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oNqXOKGvT1/4OgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 16:43:45 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SDTPNqGvT18IqQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 16:43:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F0C61A3DC6; Wed, 2 Sep 2020 16:43:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727099AbgIBOng (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 10:43:36 -0400 Received: from mx2.suse.de ([195.135.220.15]:34328 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728070AbgIBOlb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 10:41:31 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9BAEDB1C0; Wed, 2 Sep 2020 14:41:30 +0000 (UTC) Date: Wed, 02 Sep 2020 16:41:29 +0200 Message-ID: <s5ha6y89r6u.wl-tiwai@suse.de> From: Takashi Iwai <tiwai@suse.de> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH 7/9] sound: line6: convert to use new usb control function... In-Reply-To: <20200902110115.1994491-9-gregkh@linuxfoundation.org> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-9-gregkh@linuxfoundation.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.07 / 15.00 / 200.00 X-Rspamd-Queue-Id: F0C61A3DC6 X-Rspamd-UID: 7b9b7f On Wed, 02 Sep 2020 13:01:10 +0200, Greg Kroah-Hartman wrote: > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> I guess this and a few others with (x/9) are stale patches, right? thanks, Takashi > --- > sound/usb/line6/driver.c | 69 +++++++++++++++----------------------- > sound/usb/line6/podhd.c | 17 ++++------ > sound/usb/line6/toneport.c | 8 ++--- > 3 files changed, 37 insertions(+), 57 deletions(-) > > diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c > index 60674ce4879b..601292c51491 100644 > --- a/sound/usb/line6/driver.c > +++ b/sound/usb/line6/driver.c > @@ -337,23 +337,18 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, > { > struct usb_device *usbdev = line6->usbdev; > int ret; > - unsigned char *len; > + u8 len; > unsigned count; > > if (address > 0xffff || datalen > 0xff) > return -EINVAL; > > - len = kmalloc(1, GFP_KERNEL); > - if (!len) > - return -ENOMEM; > - > /* query the serial number: */ > - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > - (datalen << 8) | 0x21, address, > - NULL, 0, LINE6_TIMEOUT * HZ); > - > - if (ret < 0) { > + ret = usb_control_msg_send(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > + (datalen << 8) | 0x21, address, NULL, 0, > + LINE6_TIMEOUT * HZ); > + if (ret) { > dev_err(line6->ifcdev, "read request failed (error %d)\n", ret); > goto exit; > } > @@ -362,45 +357,41 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, > for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { > mdelay(LINE6_READ_WRITE_STATUS_DELAY); > > - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | > - USB_DIR_IN, > - 0x0012, 0x0000, len, 1, > - LINE6_TIMEOUT * HZ); > - if (ret < 0) { > + ret = usb_control_msg_recv(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, > + 0x0012, 0x0000, &len, 1, > + LINE6_TIMEOUT * HZ); > + if (ret) { > dev_err(line6->ifcdev, > "receive length failed (error %d)\n", ret); > goto exit; > } > > - if (*len != 0xff) > + if (len != 0xff) > break; > } > > ret = -EIO; > - if (*len == 0xff) { > + if (len == 0xff) { > dev_err(line6->ifcdev, "read failed after %d retries\n", > count); > goto exit; > - } else if (*len != datalen) { > + } else if (len != datalen) { > /* should be equal or something went wrong */ > dev_err(line6->ifcdev, > "length mismatch (expected %d, got %d)\n", > - (int)datalen, (int)*len); > + (int)datalen, len); > goto exit; > } > > /* receive the result: */ > - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, > - 0x0013, 0x0000, data, datalen, > - LINE6_TIMEOUT * HZ); > - > - if (ret < 0) > + ret = usb_control_msg_recv(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, > + 0x0013, 0x0000, data, datalen, LINE6_TIMEOUT * HZ); > + if (ret) > dev_err(line6->ifcdev, "read failed (error %d)\n", ret); > > exit: > - kfree(len); > return ret; > } > EXPORT_SYMBOL_GPL(line6_read_data); > @@ -423,12 +414,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, > if (!status) > return -ENOMEM; > > - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > - 0x0022, address, data, datalen, > - LINE6_TIMEOUT * HZ); > - > - if (ret < 0) { > + ret = usb_control_msg_send(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > + 0x0022, address, data, datalen, LINE6_TIMEOUT * HZ); > + if (ret) { > dev_err(line6->ifcdev, > "write request failed (error %d)\n", ret); > goto exit; > @@ -437,14 +426,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, > for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { > mdelay(LINE6_READ_WRITE_STATUS_DELAY); > > - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), > - 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | > - USB_DIR_IN, > - 0x0012, 0x0000, > - status, 1, LINE6_TIMEOUT * HZ); > - > - if (ret < 0) { > + ret = usb_control_msg_recv(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, > + 0x0012, 0x0000, status, 1, LINE6_TIMEOUT * HZ); > + if (ret) { > dev_err(line6->ifcdev, > "receiving status failed (error %d)\n", ret); > goto exit; > diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c > index eef45f7fef0d..a1261f55d62b 100644 > --- a/sound/usb/line6/podhd.c > +++ b/sound/usb/line6/podhd.c > @@ -183,29 +183,25 @@ static const struct attribute_group podhd_dev_attr_group = { > static int podhd_dev_start(struct usb_line6_podhd *pod) > { > int ret; > - u8 *init_bytes; > + u8 init_bytes[8]; > int i; > struct usb_device *usbdev = pod->line6.usbdev; > > - init_bytes = kmalloc(8, GFP_KERNEL); > - if (!init_bytes) > - return -ENOMEM; > - > - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), > + ret = usb_control_msg_send(usbdev, 0, > 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > 0x11, 0, > NULL, 0, LINE6_TIMEOUT * HZ); > - if (ret < 0) { > + if (ret) { > dev_err(pod->line6.ifcdev, "read request failed (error %d)\n", ret); > goto exit; > } > > /* NOTE: looks like some kind of ping message */ > - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, > + ret = usb_control_msg_recv(usbdev, 0, 0x67, > USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, > 0x11, 0x0, > init_bytes, 3, LINE6_TIMEOUT * HZ); > - if (ret < 0) { > + if (ret) { > dev_err(pod->line6.ifcdev, > "receive length failed (error %d)\n", ret); > goto exit; > @@ -220,13 +216,12 @@ static int podhd_dev_start(struct usb_line6_podhd *pod) > goto exit; > } > > - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), > + ret = usb_control_msg_send(usbdev, 0, > USB_REQ_SET_FEATURE, > USB_TYPE_STANDARD | USB_RECIP_DEVICE | USB_DIR_OUT, > 1, 0, > NULL, 0, LINE6_TIMEOUT * HZ); > exit: > - kfree(init_bytes); > return ret; > } > > diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c > index 94dd5e7ab2e6..a9b56085b76a 100644 > --- a/sound/usb/line6/toneport.c > +++ b/sound/usb/line6/toneport.c > @@ -126,11 +126,11 @@ static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2) > { > int ret; > > - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, > - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > - cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); > + ret = usb_control_msg_send(usbdev, 0, 0x67, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > + cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); > > - if (ret < 0) { > + if (ret) { > dev_err(&usbdev->dev, "send failed (error %d)\n", ret); > return ret; > } > -- > 2.28.0 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CK4xGNmyT1+KnAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 02 Sep 2020 16:57:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WC/GFtmyT18w7QEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 02 Sep 2020 16:57:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 10903A169E; Wed, 2 Sep 2020 16:57:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726922AbgIBO5R (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Wed, 2 Sep 2020 10:57:17 -0400 Received: from netrider.rowland.org ([192.131.102.5]:36775 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726526AbgIBO5C (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 2 Sep 2020 10:57:02 -0400 Received: (qmail 624961 invoked by uid 1000); 2 Sep 2020 10:57:01 -0400 Date: Wed, 2 Sep 2020 10:57:01 -0400 From: Alan Stern <stern@rowland.harvard.edu> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH 04/10] USB: core: hub.c: use usb_control_msg_send() in a few places Message-ID: <20200902145701.GA624583@rowland.harvard.edu> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-5-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200902110115.1994491-5-gregkh@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: 10903A169E X-Rspamd-UID: 11d2eb On Wed, Sep 02, 2020 at 01:01:06PM +0200, Greg Kroah-Hartman wrote: > There are a few calls to usb_control_msg() that can be converted to use > usb_control_msg_send() instead, so do that in order to make the error > checking a bit simpler and the code smaller. > > Cc: Alan Stern <stern@rowland.harvard.edu> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> One problem in this patch... > @@ -3896,27 +3875,14 @@ static int usb_req_set_sel(struct usb_device *udev, enum usb3_link_state state) > if (u2_pel > USB3_LPM_MAX_U2_SEL_PEL) > u2_pel = USB3_LPM_MAX_U2_SEL_PEL; > > - /* > - * usb_enable_lpm() can be called as part of a failed device reset, > - * which may be initiated by an error path of a mass storage driver. > - * Therefore, use GFP_NOIO. > - */ > - sel_values = kmalloc(sizeof *(sel_values), GFP_NOIO); > - if (!sel_values) > - return -ENOMEM; > - > - sel_values->u1_sel = u1_sel; > - sel_values->u1_pel = u1_pel; > - sel_values->u2_sel = cpu_to_le16(u2_sel); > - sel_values->u2_pel = cpu_to_le16(u2_pel); > + sel_values.u1_sel = u1_sel; > + sel_values.u1_pel = u1_pel; > + sel_values.u2_sel = cpu_to_le16(u2_sel); > + sel_values.u2_pel = cpu_to_le16(u2_pel); > > - ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), > - USB_REQ_SET_SEL, > - USB_RECIP_DEVICE, > - 0, 0, > - sel_values, sizeof *(sel_values), > - USB_CTRL_SET_TIMEOUT); > - kfree(sel_values); > + ret = usb_control_msg_send(udev, 0, USB_REQ_SET_SEL, USB_RECIP_DEVICE, > + 0, 0, &sel_values, sizeof(sel_values), > + USB_CTRL_SET_TIMEOUT); This effectively changes GFP_NOIO to GFP_KERNEL. Probably you should leave this particular call alone. Alan Stern Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IBK2DSWcUF+5xwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 09:32:53 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6AD3CyWcUF9kKwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 09:32:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A351342107; Thu, 3 Sep 2020 09:32:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728151AbgICHcf (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 3 Sep 2020 03:32:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:56460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726025AbgICHce (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 3 Sep 2020 03:32:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B389420775; Thu, 3 Sep 2020 07:32:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599118353; bh=a6NQokr4jM352XqY6vw/Xjc9tnmlUORQvxTKs8y3VmQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lY2nENn4PyQnLe86tGBsy7BegX4EZ7tvxXVlNM7BZv6S3N+PmLZ0sqWiCET8GGqTk o68zMMnRNYD7BkFKDl2ntBWB2Sy6A0ODNnz4eHdZJOHHBJgh+vXLe7u5kUJqQS+zhd 95RgxEBPX+1UU5R2KEx32QhMc60fTKCtZT9/LTMc= Date: Thu, 3 Sep 2020 09:32:30 +0200 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: Alan Stern <stern@rowland.harvard.edu> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Eli Billauer <eli.billauer@gmail.com>, Emiliano Ingrassia <ingrassia@epigenesys.com>, Alexander Tsoy <alexander@tsoy.me>, "Geoffrey D. Bennett" <g@b4.vu>, Jussi Laako <jussi@sonarnerd.net>, Nick Kossifidis <mickflemm@gmail.com>, Dmitry Panchenko <dmitry@d-systems.ee>, Chris Wulff <crwulff@gmail.com>, Jesus Ramos <jesus-ramos@live.com> Subject: Re: [PATCH 01/10] USB: move snd_usb_pipe_sanity_check into the USB core Message-ID: <20200903073230.GA162335@kroah.com> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-2-gregkh@linuxfoundation.org> <20200903004553.GA642955@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200903004553.GA642955@rowland.harvard.edu> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.79 / 15.00 / 200.00 X-Rspamd-Queue-Id: A351342107 X-Rspamd-UID: 7341c2 On Wed, Sep 02, 2020 at 08:45:53PM -0400, Alan Stern wrote: > On Wed, Sep 02, 2020 at 01:01:03PM +0200, Greg Kroah-Hartman wrote: > > snd_usb_pipe_sanity_check() is a great function, so let's move it into > > the USB core so that other parts of the kernel, including the USB core, > > can call it. > > > > Name it usb_pipe_type_check() to match the existing > > usb_urb_ep_type_check() call, which now uses this function. > > > > Cc: Jaroslav Kysela <perex@perex.cz> > > Cc: Takashi Iwai <tiwai@suse.com> > > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > > Cc: Eli Billauer <eli.billauer@gmail.com> > > Cc: Emiliano Ingrassia <ingrassia@epigenesys.com> > > Cc: Alan Stern <stern@rowland.harvard.edu> > > Cc: Alexander Tsoy <alexander@tsoy.me> > > Cc: "Geoffrey D. Bennett" <g@b4.vu> > > Cc: Jussi Laako <jussi@sonarnerd.net> > > Cc: Nick Kossifidis <mickflemm@gmail.com> > > Cc: Dmitry Panchenko <dmitry@d-systems.ee> > > Cc: Chris Wulff <crwulff@gmail.com> > > Cc: Jesus Ramos <jesus-ramos@live.com> > > Cc: linux-usb@vger.kernel.org > > Cc: linux-kernel@vger.kernel.org > > Cc: alsa-devel@alsa-project.org > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > --- > > > diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c > > index 27e83e55a590..45bc2914c1ba 100644 > > --- a/drivers/usb/core/urb.c > > +++ b/drivers/usb/core/urb.c > > @@ -192,24 +192,39 @@ static const int pipetypes[4] = { > > }; > > > > /** > > - * usb_urb_ep_type_check - sanity check of endpoint in the given urb > > - * @urb: urb to be checked > > + * usb_pipe_type_check - sanity check of a specific pipe for a usb device > > + * @dev: struct usb_device to be checked > > + * @pipe: pipe to check > > * > > * This performs a light-weight sanity check for the endpoint in the > > - * given urb. It returns 0 if the urb contains a valid endpoint, otherwise > > - * a negative error code. > > + * given usb device. It returns 0 if the pipe is a valid for the specific usb > -----------------------------------------------------^ > Typo. Oops, will fix, thanks. > > > + * device, otherwise a negative error code. > > */ > > -int usb_urb_ep_type_check(const struct urb *urb) > > +int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe) > > { > > const struct usb_host_endpoint *ep; > > > > - ep = usb_pipe_endpoint(urb->dev, urb->pipe); > > + ep = usb_pipe_endpoint(dev, pipe); > > if (!ep) > > return -EINVAL; > > - if (usb_pipetype(urb->pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) > > + if (usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) > > return -EINVAL; > > return 0; > > } > > +EXPORT_SYMBOL_GPL(usb_pipe_type_check); > > + > > +/** > > + * usb_urb_ep_type_check - sanity check of endpoint in the given urb > > + * @urb: urb to be checked > > + * > > + * This performs a light-weight sanity check for the endpoint in the > > + * given urb. It returns 0 if the urb contains a valid endpoint, otherwise > > + * a negative error code. > > + */ > > +int usb_urb_ep_type_check(const struct urb *urb) > > +{ > > + return usb_pipe_type_check(urb->dev, urb->pipe); > > +} > > EXPORT_SYMBOL_GPL(usb_urb_ep_type_check); > > Since this routine is used in only one place in the entire kernel, you > might as well inline the code there and get rid of the function > entirely. Good idea, will do. > > diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c > > index abf99b814a0f..fc3aab04a0bc 100644 > > --- a/sound/usb/quirks.c > > +++ b/sound/usb/quirks.c > > @@ -846,7 +846,7 @@ static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev) > > static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 }; > > void *buf; > > > > - if (snd_usb_pipe_sanity_check(dev, usb_sndintpipe(dev, 0x05))) > > + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x05))) > > return -EINVAL; > > buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); > > if (!buf) > > @@ -875,7 +875,7 @@ static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev) > > { > > int ret; > > > > - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) > > + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) > > return -EINVAL; > > In a few places here this check is completely unnecessary. All it does > is verify that the device does have an endpoint 0 and the the type of > the endpoint matches the type of the pipe. Well, every USB device > always has an endpoint 0, and it is always a bidirectional control > endpoint. I think this was probably added to handle syzbot issues. As long as the USB core does ensure that a USB device has endpoint 0, I agree, these can be removed. I'll go check that and add a follow-on patch to the series to do this, thanks. thanks, greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GPQ0KOncUV8AkAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 04 Sep 2020 08:21:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +J++JuncUV8JxgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 04 Sep 2020 08:21:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=codeaurora.org header.b=L+roDPgf; dkim=pass (1024-bit key) header.d=amazonses.com header.b=A4eMt3P5 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1DCF3A13BE; Fri, 4 Sep 2020 08:21:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726171AbgIDGVS (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 4 Sep 2020 02:21:18 -0400 Received: from a27-188.smtp-out.us-west-2.amazonses.com ([54.240.27.188]:32932 "EHLO a27-188.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725812AbgIDGVQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 4 Sep 2020 02:21:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1599200475; h=From:To:Cc:Subject:Date:Message-Id; bh=4UE+WdooRrLUPdjnUAqjyyYoEy5h+nRczdfaVlmmdgQ=; b=L+roDPgfmGdvRsH+zF3isndXWmoI8JdfBhuFIs6B4a2+bghvOeuwGuLg0MioHz1g 78XGokbnhw4OB8tXpm5xvYDWHiwnhlqm8/gvXkuVhuoUHuLIo/yKYzaodBHGqDHDC6M lYuE1VubZmTpc1jZ+S/RQbuOrFKvkaNsPWUpsat8= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=hsbnp7p3ensaochzwyq5wwmceodymuwv; d=amazonses.com; t=1599200475; h=From:To:Cc:Subject:Date:Message-Id:Feedback-ID; bh=4UE+WdooRrLUPdjnUAqjyyYoEy5h+nRczdfaVlmmdgQ=; b=A4eMt3P5Be+ArF6d3uGjE/jqjgLyiA78sn60Jj454XlytX0JR/A/ICN4WxP7PvXz mZZDXuk8bztPxn1ZE/BErFnN3jYgTlN1U+UGWsB5065pridgVpMSS7tpaWtm0grHUqV bGszdRxRXhWXWM6bWgEYF5iNtsC5aPZ9BuwDjLUM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7C427C433F0 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=rjliao@codeaurora.org From: Rocky Liao <rjliao@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, c-hbandi@codeaurora.org, hemantg@codeaurora.org, mka@chromium.org, Rocky Liao <rjliao@codeaurora.org> Subject: [PATCH v1] Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support Date: Fri, 4 Sep 2020 06:21:15 +0000 Message-ID: <0101017457c6b819-d1292819-1fae-43af-8fb8-3bc572f53cd5-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 2.17.1 X-SES-Outgoing: 2020.09.04-54.240.27.188 Feedback-ID: 1.us-west-2.CZuq2qbDmUIuT3qdvXlRHZZCpfZqZ4GtG9v3VKgRyF0=:AmazonSES Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.52 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1DCF3A13BE X-Rspamd-UID: ba63d1 This patch add support for WCN6855 i.e. patch and nvm download support. Signed-off-by: Rocky Liao <rjliao@codeaurora.org> --- drivers/bluetooth/btusb.c | 42 +++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index fe80588c7bd3..e51e754ca9b8 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver; #define BTUSB_MEDIATEK 0x200000 #define BTUSB_WIDEBAND_SPEECH 0x400000 #define BTUSB_VALID_LE_STATES 0x800000 +#define BTUSB_QCA_WCN6855 0x1000000 static const struct usb_device_id btusb_table[] = { /* Generic Bluetooth USB device */ @@ -273,6 +274,10 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME }, + /* QCA WCN6855 chipset */ + { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 | + BTUSB_WIDEBAND_SPEECH }, + /* Broadcom BCM2035 */ { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU }, @@ -3391,6 +3396,26 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev, return 0; } +static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev, + const bdaddr_t *bdaddr) +{ + struct sk_buff *skb; + u8 buf[6]; + long ret; + + memcpy(buf, bdaddr, sizeof(bdaddr_t)); + + skb = __hci_cmd_sync(hdev, 0xfc14, sizeof(buf), buf, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + ret = PTR_ERR(skb); + bt_dev_err(hdev, "Change address command failed (%ld)", ret); + return ret; + } + kfree_skb(skb); + + return 0; +} + #define QCA_DFU_PACKET_LEN 4096 #define QCA_GET_TARGET_VERSION 0x09 @@ -3428,6 +3453,8 @@ static const struct qca_device_info qca_devices_table[] = { { 0x00000201, 28, 4, 18 }, /* Rome 2.1 */ { 0x00000300, 28, 4, 18 }, /* Rome 3.0 */ { 0x00000302, 28, 4, 18 }, /* Rome 3.2 */ + { 0x00130100, 40, 4, 18 }, /* WCN6855 1.0 */ + { 0x00130200, 40, 4, 18 } /* WCN6855 2.0 */ }; static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request, @@ -3530,7 +3557,7 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, struct qca_rampatch_version *rver; const struct firmware *fw; u32 ver_rom, ver_patch; - u16 rver_rom, rver_patch; + u32 rver_rom, rver_patch; char fwname[64]; int err; @@ -3552,6 +3579,9 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, rver_rom = le16_to_cpu(rver->rom_version); rver_patch = le16_to_cpu(rver->patch_version); + if (ver_rom & ~0xffffU) + rver_rom = *(u16 *)(fw->data + 16) << 16 | rver_rom; + bt_dev_info(hdev, "QCA: patch rome 0x%x build 0x%x, " "firmware rome 0x%x build 0x%x", rver_rom, rver_patch, ver_rom, ver_patch); @@ -3625,9 +3655,6 @@ static int btusb_setup_qca(struct hci_dev *hdev) return err; ver_rom = le32_to_cpu(ver.rom_version); - /* Don't care about high ROM versions */ - if (ver_rom & ~0xffffU) - return 0; for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) { if (ver_rom == qca_devices_table[i].rom_version) @@ -4063,6 +4090,13 @@ static int btusb_probe(struct usb_interface *intf, btusb_check_needs_reset_resume(intf); } + if (id->driver_info & BTUSB_QCA_WCN6855) { + data->setup_on_usb = btusb_setup_qca; + hdev->set_bdaddr = btusb_set_bdaddr_wcn6855; + hdev->cmd_timeout = btusb_qca_cmd_timeout; + set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); + } + if (id->driver_info & BTUSB_AMP) { /* AMP controllers do not support SCO packets */ data->isoc = NULL; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aPoyOH2rUF/v2wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 10:38:21 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id MImDNn2rUF8CCgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 10:38:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A7A46A15C9; Thu, 3 Sep 2020 10:38:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728061AbgICIiO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 3 Sep 2020 04:38:14 -0400 Received: from smtp25.cstnet.cn ([159.226.251.25]:56340 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728027AbgICIiL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 3 Sep 2020 04:38:11 -0400 Received: from localhost.localdomain (unknown [159.226.5.100]) by APP-05 (Coremail) with SMTP id zQCowADHqSLpqFBfX2UMAQ--.23934S2; Thu, 03 Sep 2020 16:27:21 +0800 (CST) From: Xu Wang <vulab@iscas.ac.cn> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Bluetooth: hci_qca: remove redundant null check Date: Thu, 3 Sep 2020 08:27:19 +0000 Message-Id: <20200903082719.85027-1-vulab@iscas.ac.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: zQCowADHqSLpqFBfX2UMAQ--.23934S2 X-Coremail-Antispam: 1UD129KBjvdXoW7JF4UZF47GF1UCF17KF47twb_yoW3tFc_u3 Wkua4xGF4UWr1fAw1jgFs5urWvyFn5uF4v9rn2v34rGryDXr9xZr1qqr98Zr47Ww4xKFnx Aw1UWFy0yr1xCjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb28YjsxI4VWDJwAYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I 6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM2 8CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0 cI8IcVCY1x0267AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI 64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVW8JVWxJw Am72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc2xSY4AK67AK6r43MxAIw28I cxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2 IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI 42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42 IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E 87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07j27KsUUUUU= X-Originating-IP: [159.226.5.100] X-CM-SenderInfo: pyxotu46lvutnvoduhdfq/1tbiCwYIA1z4jaK62gAAst Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: A7A46A15C9 X-Rspamd-UID: 5f5edd Because clk_disable_unprepare already checked NULL clock parameter, so the additional check is unnecessary, just remove it. Signed-off-by: Xu Wang <vulab@iscas.ac.cn> --- drivers/bluetooth/hci_qca.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 20e1dedbc58c..6577356d849b 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -2007,8 +2007,7 @@ static int qca_serdev_probe(struct serdev_device *serdev) err = hci_uart_register_device(&qcadev->serdev_hu, &qca_proto); if (err) { BT_ERR("Rome serdev registration failed"); - if (qcadev->susclk) - clk_disable_unprepare(qcadev->susclk); + clk_disable_unprepare(qcadev->susclk); return err; } } -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SMdtI546UV8sWAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 20:49:02 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id YLo2Ip46UV+TEAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 20:49:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 58EB0A16D3; Thu, 3 Sep 2020 20:48:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728677AbgICSsz (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 3 Sep 2020 14:48:55 -0400 Received: from mga04.intel.com ([192.55.52.120]:4301 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728304AbgICSsy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 3 Sep 2020 14:48:54 -0400 IronPort-SDR: 847C3m88iI1t3pCpCB+MVtPWDPBRBJNVRjyRxWobTCoC25rjykS1iKdVpTLGZiQLEXSglOmklm qQJumFc1g1dQ== X-IronPort-AV: E=McAfee;i="6000,8403,9733"; a="155037267" X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="155037267" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2020 11:48:53 -0700 IronPort-SDR: zlmlb0keiLm9Oo+VY+pLO+INVq+KgL/+scd2WeN0ehbEGz8unYDKYO5mC0m8K16TUKzoivGynd In/R6CXTsakQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="339391380" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 03 Sep 2020 11:48:52 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 24E26E1; Thu, 3 Sep 2020 21:48:51 +0300 (EEST) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH v1 2/4] Bluetooth: hci_intel: drop strange le16_to_cpu() against u8 values Date: Thu, 3 Sep 2020 21:48:48 +0300 Message-Id: <20200903184850.53055-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> References: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.03 / 15.00 / 200.00 X-Rspamd-Queue-Id: 58EB0A16D3 X-Rspamd-UID: ab255d Sparse rightfully complains: hci_intel.c:696:26: warning: cast to restricted __le16 hci_intel.c:701:26: warning: cast to restricted __le16 hci_intel.c:702:26: warning: cast to restricted __le16 hci_intel.c:703:26: warning: cast to restricted __le16 hci_intel.c:725:26: warning: cast to restricted __le16 hci_intel.c:730:26: warning: cast to restricted __le16 hci_intel.c:731:26: warning: cast to restricted __le16 hci_intel.c:732:26: warning: cast to restricted __le16 because we access non-restricted types with le16_to_cpu(). More confusion is added by using above against u8. On big-endian architecture we will get all zeroes. I bet it's not what should be in such case. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/bluetooth/hci_intel.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c index 703d774be5a6..50e4fc6813c2 100644 --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -693,14 +693,11 @@ static int intel_setup(struct hci_uart *hu) case 0x0b: /* SfP */ case 0x0c: /* WsP */ snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.sfi", - le16_to_cpu(ver.hw_variant), - le16_to_cpu(params.dev_revid)); + ver.hw_variant, le16_to_cpu(params.dev_revid)); break; case 0x12: /* ThP */ snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u-%u.sfi", - le16_to_cpu(ver.hw_variant), - le16_to_cpu(ver.hw_revision), - le16_to_cpu(ver.fw_revision)); + ver.hw_variant, ver.hw_revision, ver.fw_revision); break; default: bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)", @@ -722,14 +719,11 @@ static int intel_setup(struct hci_uart *hu) case 0x0b: /* SfP */ case 0x0c: /* WsP */ snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.ddc", - le16_to_cpu(ver.hw_variant), - le16_to_cpu(params.dev_revid)); + ver.hw_variant, le16_to_cpu(params.dev_revid)); break; case 0x12: /* ThP */ snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u-%u.ddc", - le16_to_cpu(ver.hw_variant), - le16_to_cpu(ver.hw_revision), - le16_to_cpu(ver.fw_revision)); + ver.hw_variant, ver.hw_revision, ver.fw_revision); break; default: bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)", -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cP9nGaU6UV+UUQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 20:49:09 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0DUPGKU6UV9y9AEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 20:49:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B7C1BA1D46; Thu, 3 Sep 2020 20:49:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728688AbgICSs4 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 3 Sep 2020 14:48:56 -0400 Received: from mga18.intel.com ([134.134.136.126]:5597 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728358AbgICSsy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 3 Sep 2020 14:48:54 -0400 IronPort-SDR: cX7RIt8mOU9XYajnDl8i51bOwBDXPgS4OEJo31cH8SY0sLMYopnmbYi7y/CBKk5FCNHNf7B5dT FZVQ9mRG5clw== X-IronPort-AV: E=McAfee;i="6000,8403,9733"; a="145339778" X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="145339778" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2020 11:48:53 -0700 IronPort-SDR: AxVQagXXeA9mwAZXm0ncCysWDVDq2yVqPWetu9TCqE+KkzD+ZO9kD09mywrPxHMVB7ZQLlZgs0 W8qiAOwuPK0A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="284172582" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 03 Sep 2020 11:48:51 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1A27C11C; Thu, 3 Sep 2020 21:48:50 +0300 (EEST) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH v1 1/4] Bluetooth: hci_intel: enable on new platform Date: Thu, 3 Sep 2020 21:48:47 +0300 Message-Id: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: B7C1BA1D46 X-Rspamd-UID: 0c084e On new Intel platform the device is provided with INT33E3 ID. Append it to the list. This will require ACPI_GPIO_QUIRK_ONLY_GPIOIO to be enabled because the relevant ASL looks like: UartSerialBusV2 ( ... ) GpioInt ( ... ) { ... } GpioIo ( ... ) { ... } which means that first GPIO resource is an interrupt, while we are expecting it to be reset one (output). Do the same for host-wake because in case of GpioInt() the platform_get_irq() will do the job and should return correct Linux IRQ number. That said, host-wake GPIO can only be GpioIo() resource. While here, drop commas in terminator lines. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/bluetooth/hci_intel.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c index f1299da6eed8..703d774be5a6 100644 --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -1076,7 +1076,8 @@ static const struct hci_uart_proto intel_proto = { #ifdef CONFIG_ACPI static const struct acpi_device_id intel_acpi_match[] = { { "INT33E1", 0 }, - { }, + { "INT33E3", 0 }, + { } }; MODULE_DEVICE_TABLE(acpi, intel_acpi_match); #endif @@ -1138,9 +1139,9 @@ static const struct acpi_gpio_params reset_gpios = { 0, 0, false }; static const struct acpi_gpio_params host_wake_gpios = { 1, 0, false }; static const struct acpi_gpio_mapping acpi_hci_intel_gpios[] = { - { "reset-gpios", &reset_gpios, 1 }, - { "host-wake-gpios", &host_wake_gpios, 1 }, - { }, + { "reset-gpios", &reset_gpios, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, + { "host-wake-gpios", &host_wake_gpios, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, + { } }; static int intel_probe(struct platform_device *pdev) -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SFujHao6UV9vSgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 20:49:14 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8O9iHKo6UV9wQAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 20:49:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8162BA11F9; Thu, 3 Sep 2020 20:49:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728852AbgICSs5 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 3 Sep 2020 14:48:57 -0400 Received: from mga03.intel.com ([134.134.136.65]:2719 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728312AbgICSsy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 3 Sep 2020 14:48:54 -0400 IronPort-SDR: bf7bqfuTGKMG01nEz0iB7v7SF1q2X4oeTDFLVvg/iMvpAAh+jyfplUd8AMaY9oHl67GjRCocdV kwXRPSFtYf9Q== X-IronPort-AV: E=McAfee;i="6000,8403,9733"; a="157648334" X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="157648334" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2020 11:48:53 -0700 IronPort-SDR: vbaEYy4SvjTnc5ZeAisbk3O8Wau4H4/kRKXTmU+66LMX2a5N0JQGh8EV2sgABdhPNB6Lc14XvA qg1olUTIKJ4A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="282774887" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 03 Sep 2020 11:48:52 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3535621D; Thu, 3 Sep 2020 21:48:51 +0300 (EEST) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH v1 4/4] Bluetooth: hci_intel: sort headers alphabetically Date: Thu, 3 Sep 2020 21:48:50 +0300 Message-Id: <20200903184850.53055-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> References: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8162BA11F9 X-Rspamd-UID: b4316a Sort headers alphabetically to increase readability and make maintenance easier. While here, update copyright year. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/bluetooth/hci_intel.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c index b20a40fab83e..17f51bc17bb5 100644 --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -3,21 +3,21 @@ * * Bluetooth HCI UART driver for Intel devices * - * Copyright (C) 2015 Intel Corporation + * Copyright (C) 2015,2020 Intel Corporation */ -#include <linux/kernel.h> +#include <linux/acpi.h> #include <linux/errno.h> -#include <linux/skbuff.h> #include <linux/firmware.h> -#include <linux/module.h> -#include <linux/wait.h> -#include <linux/tty.h> -#include <linux/platform_device.h> #include <linux/gpio/consumer.h> -#include <linux/acpi.h> #include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/skbuff.h> +#include <linux/tty.h> +#include <linux/wait.h> #include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iEaNMK86UV8sWAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 20:49:19 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iKFvL686UV/s5AEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 20:49:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9CCC3A1486; Thu, 3 Sep 2020 20:49:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728975AbgICSs6 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 3 Sep 2020 14:48:58 -0400 Received: from mga01.intel.com ([192.55.52.88]:63136 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728419AbgICSsy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 3 Sep 2020 14:48:54 -0400 IronPort-SDR: G7Y5XBluCA/hm+mqBLsNsIBP+DtII0b4kM/Lt7wU2EJVEhQEQta4HWgIv3/1V2u7qC13RU63rj lkS5OeVWsj4w== X-IronPort-AV: E=McAfee;i="6000,8403,9733"; a="175694214" X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="175694214" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2020 11:48:53 -0700 IronPort-SDR: DMaS1KQ6rL7UZZnHjyRqP4fak2kr+mHgcGlxhj4ny2Rfp4aIRJlqwP0JGYZ1noXfjzOzGIwez6 6eIYJKBTlh8A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="302317754" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 03 Sep 2020 11:48:52 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2B957182; Thu, 3 Sep 2020 21:48:51 +0300 (EEST) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH v1 3/4] Bluetooth: hci_intel: switch to list_for_each_entry() Date: Thu, 3 Sep 2020 21:48:49 +0300 Message-Id: <20200903184850.53055-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> References: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9CCC3A1486 X-Rspamd-UID: c0a76c There is no need to have list_for_each() followed by list_entry() when we simply may use list_for_each_entry() directly. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/bluetooth/hci_intel.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c index 50e4fc6813c2..b20a40fab83e 100644 --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -288,7 +288,7 @@ static irqreturn_t intel_irq(int irq, void *dev_id) static int intel_set_power(struct hci_uart *hu, bool powered) { - struct list_head *p; + struct intel_device *idev; int err = -ENODEV; if (!hu->tty->dev) @@ -296,10 +296,7 @@ static int intel_set_power(struct hci_uart *hu, bool powered) mutex_lock(&intel_device_list_lock); - list_for_each(p, &intel_device_list) { - struct intel_device *idev = list_entry(p, struct intel_device, - list); - + list_for_each_entry(idev, &intel_device_list, list) { /* tty device and pdev device should share the same parent * which is the UART port. */ @@ -362,19 +359,16 @@ static int intel_set_power(struct hci_uart *hu, bool powered) static void intel_busy_work(struct work_struct *work) { - struct list_head *p; struct intel_data *intel = container_of(work, struct intel_data, busy_work); + struct intel_device *idev; if (!intel->hu->tty->dev) return; /* Link is busy, delay the suspend */ mutex_lock(&intel_device_list_lock); - list_for_each(p, &intel_device_list) { - struct intel_device *idev = list_entry(p, struct intel_device, - list); - + list_for_each_entry(idev, &intel_device_list, list) { if (intel->hu->tty->dev->parent == idev->pdev->dev.parent) { pm_runtime_get(&idev->pdev->dev); pm_runtime_mark_last_busy(&idev->pdev->dev); @@ -533,7 +527,7 @@ static int intel_setup(struct hci_uart *hu) struct sk_buff *skb; struct intel_version ver; struct intel_boot_params params; - struct list_head *p; + struct intel_device *idev; const struct firmware *fw; char fwname[64]; u32 boot_param; @@ -833,13 +827,11 @@ static int intel_setup(struct hci_uart *hu) * until further LPM TX notification. */ mutex_lock(&intel_device_list_lock); - list_for_each(p, &intel_device_list) { - struct intel_device *dev = list_entry(p, struct intel_device, - list); + list_for_each_entry(idev, &intel_device_list, list) { if (!hu->tty->dev) break; - if (hu->tty->dev->parent == dev->pdev->dev.parent) { - if (device_may_wakeup(&dev->pdev->dev)) { + if (hu->tty->dev->parent == idev->pdev->dev.parent) { + if (device_may_wakeup(&idev->pdev->dev)) { set_bit(STATE_LPM_ENABLED, &intel->flags); set_bit(STATE_TX_ACTIVE, &intel->flags); } @@ -993,7 +985,7 @@ static int intel_recv(struct hci_uart *hu, const void *data, int count) static int intel_enqueue(struct hci_uart *hu, struct sk_buff *skb) { struct intel_data *intel = hu->priv; - struct list_head *p; + struct intel_device *idev; BT_DBG("hu %p skb %p", hu, skb); @@ -1004,10 +996,7 @@ static int intel_enqueue(struct hci_uart *hu, struct sk_buff *skb) * completed before enqueuing any packet. */ mutex_lock(&intel_device_list_lock); - list_for_each(p, &intel_device_list) { - struct intel_device *idev = list_entry(p, struct intel_device, - list); - + list_for_each_entry(idev, &intel_device_list, list) { if (hu->tty->dev->parent == idev->pdev->dev.parent) { pm_runtime_get_sync(&idev->pdev->dev); pm_runtime_mark_last_busy(&idev->pdev->dev); -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wBsnJbw9UV8VYQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 21:02:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WD60I7w9UV/izwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 21:02:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9513FA23E7; Thu, 3 Sep 2020 21:02:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728358AbgICTCO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 3 Sep 2020 15:02:14 -0400 Received: from mga17.intel.com ([192.55.52.151]:29911 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbgICTCN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 3 Sep 2020 15:02:13 -0400 IronPort-SDR: QYQ4U4p/L+pDAiAJIW3orUItcMoQ52394xMu187rfDtYRywSer+OBCQai2vOQNOIGOPkLfcK0Q MWz+7ohQMCeg== X-IronPort-AV: E=McAfee;i="6000,8403,9733"; a="137694639" X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="137694639" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2020 12:02:12 -0700 IronPort-SDR: J+Bg+f+8Fz4oQgcr4JR6ww78HGr9P7Lt6n8mjdjgrEfR5qt3p05pa5vlQhcLl8iHIoeKc8ENL0 pF05fQbQ08hA== X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="447014137" Received: from akothalk-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.126.243]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2020 12:02:12 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] mesh: Remove unused timing variable tx_start Date: Thu, 3 Sep 2020 12:02:05 -0700 Message-Id: <20200903190205.9439-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9513FA23E7 X-Rspamd-UID: 96ef8c In model.c, tx_Start is a static variable, dynamically set, but never used. Is removed now. --- mesh/model.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mesh/model.c b/mesh/model.c index ed2a75215..5716f5e22 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -80,8 +80,6 @@ struct mod_forward { static struct l_queue *mesh_virtuals; -static struct timeval tx_start; - static bool is_internal(uint32_t id) { if (id == CONFIG_SRV_MODEL || id == CONFIG_CLI_MODEL) @@ -1018,8 +1016,6 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, return MESH_ERROR_DOES_NOT_EXIST; } - gettimeofday(&tx_start, NULL); - if (IS_UNASSIGNED(mod->pub->addr)) return MESH_ERROR_DOES_NOT_EXIST; @@ -1049,8 +1045,6 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, if (src == 0) src = node_get_primary(node); - gettimeofday(&tx_start, NULL); - if (IS_UNASSIGNED(dst)) return false; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QB0RGYVLUV+GlAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 22:01:09 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6FO2F4VLUV9FkAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 22:01:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7F7CB4211D; Thu, 3 Sep 2020 22:01:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728304AbgICUBD (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 3 Sep 2020 16:01:03 -0400 Received: from mga06.intel.com ([134.134.136.31]:2699 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727065AbgICUBB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 3 Sep 2020 16:01:01 -0400 IronPort-SDR: uMFoPrMrNI3sWUUcul3GdPAVeqHc6fmp27MaccpcZmk4tGIIa5t9tHYBh3sQUKsM71r/l9k5M8 mKEKqI6bWqUA== X-IronPort-AV: E=McAfee;i="6000,8403,9733"; a="219204048" X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="219204048" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2020 13:00:59 -0700 IronPort-SDR: kpSrKLv33wOUejiIr55KbYdmP5jebuUYB4l2y2RY3tQhJSEELUK+VGalXOa3JaReVEYFDAAqpC BmxpOxs0u8Ig== X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="298164616" Received: from akothalk-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.126.243]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2020 13:00:59 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] mesh: Align option names with functionality Date: Thu, 3 Sep 2020 13:00:52 -0700 Message-Id: <20200903200052.11005-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.56 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7F7CB4211D X-Rspamd-UID: b12b43 Change option "config" ('c') to "storage" ('s) to specify a custom storage directory for node configuration. Change option 'f' (long name was missing) to "config" ('c') to specify a custom mesh configuration file to override the default mesh-main.conf --- mesh/main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mesh/main.c b/mesh/main.c index 1a4e6ba76..5a3cbf290 100644 --- a/mesh/main.c +++ b/mesh/main.c @@ -39,14 +39,15 @@ #include "mesh/mesh-io.h" #include "mesh/util.h" -static const char *config_dir; +static const char *storage_dir; static const char *mesh_conf_fname; static enum mesh_io_type io_type; static void *io_opts; static const struct option main_options[] = { { "io", required_argument, NULL, 'i' }, - { "config", optional_argument, NULL, 'c' }, + { "storage", required_argument, NULL, 's' }, + { "config", required_argument, NULL, 'c' }, { "nodetach", no_argument, NULL, 'n' }, { "debug", no_argument, NULL, 'd' }, { "dbus-debug", no_argument, NULL, 'b' }, @@ -108,7 +109,7 @@ static void request_name_callback(struct l_dbus *dbus, bool success, return; } - if (!mesh_init(config_dir, mesh_conf_fname, io_type, io_opts, + if (!mesh_init(storage_dir, mesh_conf_fname, io_type, io_opts, mesh_ready_callback, dbus)) { l_error("Failed to initialize mesh"); l_main_quit(); @@ -195,7 +196,7 @@ int main(int argc, char *argv[]) for (;;) { int opt; - opt = getopt_long(argc, argv, "i:c:f:ndbh", main_options, NULL); + opt = getopt_long(argc, argv, "i:s:c:ndbh", main_options, NULL); if (opt < 0) break; @@ -213,10 +214,10 @@ int main(int argc, char *argv[]) case 'd': enable_debug(); break; - case 'c': - config_dir = optarg; + case 's': + storage_dir = optarg; break; - case 'f': + case 'c': mesh_conf_fname = optarg; break; case 'b': -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YCPoDNdRUV9PvQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 22:28:07 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id sB1UC9dRUV+nMgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 22:28:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EEC1FA13BE; Thu, 3 Sep 2020 22:28:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729206AbgICU2B (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 3 Sep 2020 16:28:01 -0400 Received: from mga04.intel.com ([192.55.52.120]:12143 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729209AbgICU17 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 3 Sep 2020 16:27:59 -0400 IronPort-SDR: AfxCKH/H3/7q8k2G2DyUoSvMl0O3B6VcPg/5KQYz8r2C9EWE7+vKU75GG3ZEywr5SJXvPdff+E xs0SMj0R5/Kg== X-IronPort-AV: E=McAfee;i="6000,8403,9733"; a="155050294" X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="155050294" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2020 13:27:55 -0700 IronPort-SDR: 145vYdKLpOvw2zaQO/bIUVphcNAQ8ssSPObMfjftbhkxOQP63sImlNwqGgl2qdhZwcLn+WL1X2 O5gKYqI37H3Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="405588196" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga001.fm.intel.com with ESMTP; 03 Sep 2020 13:27:55 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 3 Sep 2020 13:27:54 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 3 Sep 2020 13:27:54 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.177) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Thu, 3 Sep 2020 13:27:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RwFrHowKP4IZvveuPaCLpjUi4hEzYDTqFr+spVsF6xLd8NySVKzCMt6JA4T46DKZ4yaTADxxDy6qIjs4gXTUlUTZubCNmsgh56jdn1Ig4sNBqq/xPZKtGOMlzhp9C0QcfO7P9n+qfK50f8QQrLVJ95jD0rICwf+GzOUIbDXlK2pWXOYaFmNBUhZkQVwjgKQQYl+oaEut+A7L58MK1SgRpg5e5CLsPX86PhznOFqLVf4tSEWSjy4lT0T2FS4o6+2j8yiVKAB+Qob2qQ+CiITQJ4ifvCXaimWsxDqRyBdMO8mQPgNS0nf5FUJxaYqwl6MtGlUEe+DHZ6dzu9u5VsHaVg== 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-SenderADCheck; bh=K/GTOrxwaKTZs6hz6cwGdflMgSj5GuzVae1cFmFGVIg=; b=Rzf9zw4/Hq+0OgQBL36TXvPLmSIJ0Z/m1wSD5Nzj4gFmcIJmOYZCBbqN6xvlB1QiYO3o4luNwUFH3YMKiNOLn0qcO4y3DSqMUg5kqgEWfyRwEtoaTFsQaR9bebe3tNTupiNI/xSKmY7lSd9EpZeARfakMoICbGIfm8CNqN8bYBP19MMtstE/rrUEctJBe1oqiNaSJgT1BJjGVo4WMLl8Chx/2/PLnxrZvu4ArygbL+1L7fPl5Km+B7axjx2PYS5SfRbKY0XlaEqr5e+I5qzGh7XM8Nf23ke29i77tpnzQI/y/5kjiXhrSPinSLh2z/DioBSBtgsigMRVnkZuEBPwsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K/GTOrxwaKTZs6hz6cwGdflMgSj5GuzVae1cFmFGVIg=; b=iuolNzxtVWiuK8hbHuSHD5wrpFCid0Vxlf2q4/y63Kzw7a52CcIXtzLc+oR5az/ikxixlzLMtHpBoRZEO4fReN/aq5PnjjzmVp2YaipZKvUhI3MItWFZwRec3nrnCBWhoLID93hPfY/75lXaNEsqKWNvE8wz4s6fVzMJo1TdB2E= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MW3PR11MB4698.namprd11.prod.outlook.com (2603:10b6:303:5a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.15; Thu, 3 Sep 2020 20:27:44 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3348.016; Thu, 3 Sep 2020 20:27:44 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: Remove unused timing variable tx_start Thread-Topic: [PATCH BlueZ] mesh: Remove unused timing variable tx_start Thread-Index: AQHWgiTBdlm/C5bEUkajkMHcU9KB5KlXXRCA Date: Thu, 3 Sep 2020 20:27:44 +0000 Message-ID: <a4e57397b7e50bd1a64d3f213f9e70d8d8818d44.camel@intel.com> References: <20200903190205.9439-1-inga.stotland@intel.com> In-Reply-To: <20200903190205.9439-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.55.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5e2623dc-e861-449e-7501-08d85047d090 x-ms-traffictypediagnostic: MW3PR11MB4698: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MW3PR11MB4698828BB60F0F1922A5BC3CE12C0@MW3PR11MB4698.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:565; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: D6rdvtvXyb7eoUDNijCtMA0vLZn8iULcQy+Z3/EM4gWVzfMRvU7D5ZiOQ86uOOlz60906m9x91t1pJVAsVXKg4hcp9VudNJlhLXpZyF7AZ78h0lodgp3NmzIdgLYfXcDHMRaWDxx1269JMqibwa32Of26MI2QayJ66XMUl+k+gqEF+LOs2VEzDrqExPyHHOKyK3BnbfrKPK/f5fWov+nH2E95WRugFsrDcJ/nn08hTpjsCVRO9UExLOJQ73kua2MGXUlUHZjYHJTVORrvJQQv7HjIs6rzMSzwVAu+GcCkuM4/R0YQGp+z36gz/7fwQheHtvQmD7qgyPoBfEvRi8SDA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(346002)(136003)(39860400002)(366004)(396003)(110136005)(6636002)(71200400001)(5660300002)(6486002)(36756003)(6506007)(66446008)(316002)(66556008)(66476007)(64756008)(66946007)(186003)(76116006)(91956017)(26005)(86362001)(478600001)(8936002)(8676002)(83380400001)(2906002)(2616005)(6512007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: ICHB1eyGktLqzLzofb9NNDZltbzfMkIYQsfUzcS5fDtuNqZJ0qIYCRPT3hNRQJvZyBZ7/jZTSc3XvV0zS11oBwqoaBhZvXzTtu7BDZbZzW/Ob6jyhKZC2nSAYn0eYB5OvvvXDY7Et4eXH1ZXdpOISjt5o3WKr645CrRlOorBHHLe6PpSQuokuDDtgvAIq5Ld3XXH1Rzgtkf7oSHkVwNpmnE6N7DM8/z+8gw5AoA5DzI/QBLxhW4nVuC+YUpGMFPmh7DSGwphgln75IYtl/7zv8OaqcI6nP2J6gFK2wBMKbx3d7GYt0doKT5OqhlGOR84TBGa6YZ9gxiAJHZ0gyvdFbNX/QoCAC/H9gsd3AwQfoAYSyCWyFqehDlWQgoNzv7tEEp7brRbBRJFJJhinETHddpJgOu2IkSgwb5jMi80yAdjggqdlSOSIBVil9h+LYMbGshZekKgOAbRIHJO5MPiHeVTZI71nRC+vKeDw81nMkuqsn1kxXIhCe7jWGoBcLxXnUJr51vLNbaSKoCZ4kKTzDfkSYOe9BcXKP7vNSN+jCbz3L5aJ/WC9qbwg4aSwJ6juuMkdK9/B/4rS15w1XVnCYkoHvYKDJpe5V15cCDpuW99UMMhgA1mBZcJzZSl+e0lbHPn8coQbdIpGBuaAmfXHQ== Content-Type: text/plain; charset="utf-8" Content-ID: <B5F6A341248DD24AA861D74B30D59331@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e2623dc-e861-449e-7501-08d85047d090 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Sep 2020 20:27:44.3439 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BeElU7HYYeXD7C/Cy2PP1fdQl0p9pPLU3gaoNBlsTq5kf16U6YJdF8ARIXZ6ItHXCoVX8caxVBQEF2Ovui1tPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4698 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: EEC1FA13BE X-Rspamd-UID: ef2450 QXBwbGllZA0KT24gVGh1LCAyMDIwLTA5LTAzIGF0IDEyOjAyIC0wNzAwLCBJbmdhIFN0b3RsYW5k IHdyb3RlOg0KPiBJbiBtb2RlbC5jLCB0eF9TdGFydCBpcyBhIHN0YXRpYyB2YXJpYWJsZSwgZHlu YW1pY2FsbHkgc2V0LCBidXQNCj4gbmV2ZXIgdXNlZC4gSXMgcmVtb3ZlZCBub3cuDQo+IC0tLQ0K PiAgbWVzaC9tb2RlbC5jIHwgNiAtLS0tLS0NCj4gIDEgZmlsZSBjaGFuZ2VkLCA2IGRlbGV0aW9u cygtKQ0KPiANCj4gZGlmZiAtLWdpdCBhL21lc2gvbW9kZWwuYyBiL21lc2gvbW9kZWwuYw0KPiBp bmRleCBlZDJhNzUyMTUuLjU3MTZmNWUyMiAxMDA2NDQNCj4gLS0tIGEvbWVzaC9tb2RlbC5jDQo+ ICsrKyBiL21lc2gvbW9kZWwuYw0KPiBAQCAtODAsOCArODAsNiBAQCBzdHJ1Y3QgbW9kX2Zvcndh cmQgew0KPiAgDQo+ICBzdGF0aWMgc3RydWN0IGxfcXVldWUgKm1lc2hfdmlydHVhbHM7DQo+ICAN Cj4gLXN0YXRpYyBzdHJ1Y3QgdGltZXZhbCB0eF9zdGFydDsNCj4gLQ0KPiAgc3RhdGljIGJvb2wg aXNfaW50ZXJuYWwodWludDMyX3QgaWQpDQo+ICB7DQo+ICAJaWYgKGlkID09IENPTkZJR19TUlZf TU9ERUwgfHwgaWQgPT0gQ09ORklHX0NMSV9NT0RFTCkNCj4gQEAgLTEwMTgsOCArMTAxNiw2IEBA IGludCBtZXNoX21vZGVsX3B1Ymxpc2goc3RydWN0IG1lc2hfbm9kZSAqbm9kZSwgdWludDMyX3Qg aWQsIHVpbnQxNl90IHNyYywNCj4gIAkJcmV0dXJuIE1FU0hfRVJST1JfRE9FU19OT1RfRVhJU1Q7 DQo+ICAJfQ0KPiAgDQo+IC0JZ2V0dGltZW9mZGF5KCZ0eF9zdGFydCwgTlVMTCk7DQo+IC0NCj4g IAlpZiAoSVNfVU5BU1NJR05FRChtb2QtPnB1Yi0+YWRkcikpDQo+ICAJCXJldHVybiBNRVNIX0VS Uk9SX0RPRVNfTk9UX0VYSVNUOw0KPiAgDQo+IEBAIC0xMDQ5LDggKzEwNDUsNiBAQCBib29sIG1l c2hfbW9kZWxfc2VuZChzdHJ1Y3QgbWVzaF9ub2RlICpub2RlLCB1aW50MTZfdCBzcmMsIHVpbnQx Nl90IGRzdCwNCj4gIAlpZiAoc3JjID09IDApDQo+ICAJCXNyYyA9IG5vZGVfZ2V0X3ByaW1hcnko bm9kZSk7DQo+ICANCj4gLQlnZXR0aW1lb2ZkYXkoJnR4X3N0YXJ0LCBOVUxMKTsNCj4gLQ0KPiAg CWlmIChJU19VTkFTU0lHTkVEKGRzdCkpDQo+ICAJCXJldHVybiBmYWxzZTsNCj4gIA0K Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2NGuM/dfUV8SGQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 03 Sep 2020 23:28:23 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id oJ+wMvdfUV9tqAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 03 Sep 2020 23:28:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 16404A12D1; Thu, 3 Sep 2020 23:28:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728134AbgICV2P (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Thu, 3 Sep 2020 17:28:15 -0400 Received: from mga05.intel.com ([192.55.52.43]:38966 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728015AbgICV2N (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 3 Sep 2020 17:28:13 -0400 IronPort-SDR: PHgEmU4GoVdUxgpDvRWnoz3WbRpr3B2kbB95CrteDg+hiOgk9I5A3SqDeh8nZnZaGZUeIyGW32 lm+wAHhWrUWA== X-IronPort-AV: E=McAfee;i="6000,8403,9733"; a="242480206" X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="242480206" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2020 14:28:07 -0700 IronPort-SDR: ASpMO4+JO0WzkPsVDJKEnc4Pn/TcZmonf1dwF07HOsHlqknFaTKqTb4qDPvF6kf83BQx3X6mNj i9uxiPmfVCGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,387,1592895600"; d="scan'208";a="298187054" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by orsmga003.jf.intel.com with ESMTP; 03 Sep 2020 14:28:08 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 3 Sep 2020 14:28:07 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 3 Sep 2020 14:28:07 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 3 Sep 2020 14:28:07 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.172) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Thu, 3 Sep 2020 14:28:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R53get7VsZRXG9SXTgJQBJ2MQQ1m1S3U6dq5DAlU9GbHClr91oyY7qGlZDyArLMqKt6KldhhpBoKaTcgLIPdKlcgtDUDwneJDK3jqlp7X5O0Jlihk7q1DFOgqRrZFllsHriVHxIhj0BcKCngJ557T+AOP9fTcsUVUXSYe13igUzCeLO5Oij8woFNJLRajg5GzgQMu29T5cjFysg5XuoMdoIX4aJJASCa5pLoC5ci0bZSF8g85u3M2NJBrRmcnFICtf5D4t77bwbQr0LVl4PTZAT1MEWPIMxqdu/Dghw0k8VxRX+Zp++h7GuA9lyItXsy4T78JCDUvHtoVXiGWydaAQ== 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-SenderADCheck; bh=MMhfnpdW5jRrD0u+oTmIo/44FBaSDpfWdv/+ihhGt20=; b=U+pLVzgwWHz04XGzt2rT1tiKSwn0y5UMhYfiw4RGd7kC2itFEouEW0apyuunBxfkgZRs9xVO6ftli2/kwQeMyslj4eN9nfa+P3WIPgo3Gf1zmxbmujvZioasWUBa/sw0sobb2x6m5a9e4dXP73kgJ3UUlcGYYfpp6dT2KVsV8bOL0+tP/8YytF6ySdisvMqAHUPqwXNIJ3ROm1WHxXrwWFdfKdagMiGjSGBsBs7GwvT8cTXUpPh8RDSPwNtjwBmKcVhA6Ce/FQlQJs8n7OtEruBfLoEfpy3b5EOh36XLm+sVVbzJJdSBTHm4dlY9QhPJ/+7Ll4YMgz9HcU6R28wpYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MMhfnpdW5jRrD0u+oTmIo/44FBaSDpfWdv/+ihhGt20=; b=oWb0YGVphLdWBkEwsip4wy2ny7mCzKJsloHVM4Mfa9aMw0jW+gopUSbPQIsuO8H8D2j7nVUobQR6N7SLYiqHSY+dhRp6MEDmwJZT2CutKMBZD1HIwmMIJqmG0A3NPlV7akE6wPIHzSiT2PgCbYYquW4pwi2+wgsc2So+VjNK1lk= Received: from MW3PR11MB4539.namprd11.prod.outlook.com (2603:10b6:303:2f::13) by MWHPR11MB1903.namprd11.prod.outlook.com (2603:10b6:300:10e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.15; Thu, 3 Sep 2020 21:28:06 +0000 Received: from MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225]) by MW3PR11MB4539.namprd11.prod.outlook.com ([fe80::6832:48b9:8cd2:7225%6]) with mapi id 15.20.3348.016; Thu, 3 Sep 2020 21:28:05 +0000 From: "Gix, Brian" <brian.gix@intel.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Stotland, Inga" <inga.stotland@intel.com> Subject: Re: [PATCH BlueZ] mesh: Align option names with functionality Thread-Topic: [PATCH BlueZ] mesh: Align option names with functionality Thread-Index: AQHWgi0DW/VshLDcYkKI1ojjvVsdJKlXbd6A Date: Thu, 3 Sep 2020 21:28:05 +0000 Message-ID: <8debd6d1d3bdc97cb898fa77ecf7ef3be5de8198.camel@intel.com> References: <20200903200052.11005-1-inga.stotland@intel.com> In-Reply-To: <20200903200052.11005-1-inga.stotland@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Evolution 3.34.4 (3.34.4-1.fc31) authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.54.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2acc826d-ad29-425e-d5da-08d850503f23 x-ms-traffictypediagnostic: MWHPR11MB1903: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <MWHPR11MB19035D13C4AC8152C3323288E12C0@MWHPR11MB1903.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:3513; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cGVLWFdwIMmKCqgnNZvI30zmPgA3VS/9+G59HBdTE7t0doDgdu/ga1ZHgz92EEWLwwXNXFWe5ah0gUvAPU6IT34xOz5S3/ycRqCBt15k0FIVOFeAWk4JnKPwo1HY5rEJ5SKBxlUy/HUYG0oeLWGAS/x6nzE/5y2M9Q1XwZ4DbvotYKjI/HSAoXg822lITzQm53JdXP+eCYCmZ7bGK8EBT/+sFRTM3Cvlrm7SakYaY3frJwsFpBaWlOyx9AOD5oVwTSO/HhhIIg0WVMpeYATmCg3vVxuGKHg8COXjxEm4FHpcy3cirg8oKJYDg/4PCYIvzeSn/w9LR5qB/N+eHVv5nQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4539.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(376002)(396003)(366004)(39860400002)(136003)(2906002)(86362001)(36756003)(5660300002)(186003)(478600001)(8676002)(6506007)(6486002)(6512007)(6636002)(83380400001)(316002)(66556008)(8936002)(71200400001)(66476007)(91956017)(66446008)(2616005)(66946007)(64756008)(110136005)(76116006)(26005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: /Q1Q0+q3Crw8FyrJzA+WhoShrLLYgS/inEj5+gbeFUsGkW7BD22tuJWx6QnPUBO5PxCQ2uUJjFJrAmfOxytsFI7jBN1LroaNAk0gA5l1Djb1vEJRy1r5DsSb60BLOhzNor6DfK2Rbrg2lhNIGaHVqeHR4ne2GyC3ZEc1J1uZeA0/8R32QcF1y5QUob7sxWROqkLl8qHhQW1B9q/RbAd+1wHixtDT6vK4FBs1sMMR4uDtAsEYeFQLWEKVp3As+WrlBtXgpXCvFlyWm4VpdWdQoxIn5rxx8W+FivOrk3535P4NljUHQukTj7OShpsH6jycs2M6tHdFNF8cWFlx1SR84/h5zz2/GOIX+JdtPpsBcMSVZddkEQ/1xEFD7py4G2ABrcx+N7CuGbiHz4D5uAz3oobIHlxEz2xmW8aGE7hthnD0qkjen24owu329REqkZ6+gJI/BsZ6rv/niwvcLHHgbXX+/qB9yqL9itlFRjdSIx8msQEtbiiFM+GAnS+lf/OXBCqSxTzQVECewiIZ3hqHqhl5h4PioqhC7HxQ3z6hjw7BSdJw0Gi7hdGaa0imWfCMrzRCZ4wwf1yj5i7CP2M1wpioKGDmV0C+Nxx177VqTRnWLO1Mc9zXPioSnSI9onfiMkZqL+fTOu2o/wTC4npeiQ== Content-Type: text/plain; charset="utf-8" Content-ID: <09A403034A27984C9016A596A0E4AADA@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4539.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2acc826d-ad29-425e-d5da-08d850503f23 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Sep 2020 21:28:05.7633 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: uEaQPZ2MMMdJ8NNmrfqGpebKpgIWY29f92mBqQB1i7k5dPVOc7P2UXeRMftRE4OtLHdpoDrmBD+5C8OkUbt2hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1903 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.54 / 15.00 / 200.00 X-Rspamd-Queue-Id: 16404A12D1 X-Rspamd-UID: 893802 QXBwbGllZA0KDQpPbiBUaHUsIDIwMjAtMDktMDMgYXQgMTM6MDAgLTA3MDAsIEluZ2EgU3RvdGxh bmQgd3JvdGU6DQo+IENoYW5nZSBvcHRpb24gImNvbmZpZyIgKCdjJykgdG8gInN0b3JhZ2UiICgn cykgdG8gc3BlY2lmeQ0KPiBhIGN1c3RvbSBzdG9yYWdlIGRpcmVjdG9yeSBmb3Igbm9kZSBjb25m aWd1cmF0aW9uLg0KPiANCj4gQ2hhbmdlIG9wdGlvbiAnZicgKGxvbmcgbmFtZSB3YXMgbWlzc2lu ZykgdG8gImNvbmZpZyIgKCdjJykNCj4gdG8gc3BlY2lmeSBhIGN1c3RvbSBtZXNoIGNvbmZpZ3Vy YXRpb24gZmlsZSB0byBvdmVycmlkZSB0aGUNCj4gZGVmYXVsdCBtZXNoLW1haW4uY29uZg0KPiAt LS0NCj4gIG1lc2gvbWFpbi5jIHwgMTUgKysrKysrKystLS0tLS0tDQo+ICAxIGZpbGUgY2hhbmdl ZCwgOCBpbnNlcnRpb25zKCspLCA3IGRlbGV0aW9ucygtKQ0KPiANCj4gZGlmZiAtLWdpdCBhL21l c2gvbWFpbi5jIGIvbWVzaC9tYWluLmMNCj4gaW5kZXggMWE0ZTZiYTc2Li41YTNjYmYyOTAgMTAw NjQ0DQo+IC0tLSBhL21lc2gvbWFpbi5jDQo+ICsrKyBiL21lc2gvbWFpbi5jDQo+IEBAIC0zOSwx NCArMzksMTUgQEANCj4gICNpbmNsdWRlICJtZXNoL21lc2gtaW8uaCINCj4gICNpbmNsdWRlICJt ZXNoL3V0aWwuaCINCj4gIA0KPiAtc3RhdGljIGNvbnN0IGNoYXIgKmNvbmZpZ19kaXI7DQo+ICtz dGF0aWMgY29uc3QgY2hhciAqc3RvcmFnZV9kaXI7DQo+ICBzdGF0aWMgY29uc3QgY2hhciAqbWVz aF9jb25mX2ZuYW1lOw0KPiAgc3RhdGljIGVudW0gbWVzaF9pb190eXBlIGlvX3R5cGU7DQo+ICBz dGF0aWMgdm9pZCAqaW9fb3B0czsNCj4gIA0KPiAgc3RhdGljIGNvbnN0IHN0cnVjdCBvcHRpb24g bWFpbl9vcHRpb25zW10gPSB7DQo+ICAJeyAiaW8iLAkJcmVxdWlyZWRfYXJndW1lbnQsCU5VTEws ICdpJyB9LA0KPiAtCXsgImNvbmZpZyIsCW9wdGlvbmFsX2FyZ3VtZW50LAlOVUxMLCAnYycgfSwN Cj4gKwl7ICJzdG9yYWdlIiwJcmVxdWlyZWRfYXJndW1lbnQsCU5VTEwsICdzJyB9LA0KPiArCXsg ImNvbmZpZyIsCXJlcXVpcmVkX2FyZ3VtZW50LAlOVUxMLCAnYycgfSwNCj4gIAl7ICJub2RldGFj aCIsCW5vX2FyZ3VtZW50LAkJTlVMTCwgJ24nIH0sDQo+ICAJeyAiZGVidWciLAlub19hcmd1bWVu dCwJCU5VTEwsICdkJyB9LA0KPiAgCXsgImRidXMtZGVidWciLAlub19hcmd1bWVudCwJCU5VTEws ICdiJyB9LA0KPiBAQCAtMTA4LDcgKzEwOSw3IEBAIHN0YXRpYyB2b2lkIHJlcXVlc3RfbmFtZV9j YWxsYmFjayhzdHJ1Y3QgbF9kYnVzICpkYnVzLCBib29sIHN1Y2Nlc3MsDQo+ICAJCXJldHVybjsN Cj4gIAl9DQo+ICANCj4gLQlpZiAoIW1lc2hfaW5pdChjb25maWdfZGlyLCBtZXNoX2NvbmZfZm5h bWUsIGlvX3R5cGUsIGlvX29wdHMsDQo+ICsJaWYgKCFtZXNoX2luaXQoc3RvcmFnZV9kaXIsIG1l c2hfY29uZl9mbmFtZSwgaW9fdHlwZSwgaW9fb3B0cywNCj4gIAkJCQkJbWVzaF9yZWFkeV9jYWxs YmFjaywgZGJ1cykpIHsNCj4gIAkJbF9lcnJvcigiRmFpbGVkIHRvIGluaXRpYWxpemUgbWVzaCIp Ow0KPiAgCQlsX21haW5fcXVpdCgpOw0KPiBAQCAtMTk1LDcgKzE5Niw3IEBAIGludCBtYWluKGlu dCBhcmdjLCBjaGFyICphcmd2W10pDQo+ICAJZm9yICg7Oykgew0KPiAgCQlpbnQgb3B0Ow0KPiAg DQo+IC0JCW9wdCA9IGdldG9wdF9sb25nKGFyZ2MsIGFyZ3YsICJpOmM6ZjpuZGJoIiwgbWFpbl9v cHRpb25zLCBOVUxMKTsNCj4gKwkJb3B0ID0gZ2V0b3B0X2xvbmcoYXJnYywgYXJndiwgImk6czpj Om5kYmgiLCBtYWluX29wdGlvbnMsIE5VTEwpOw0KPiAgCQlpZiAob3B0IDwgMCkNCj4gIAkJCWJy ZWFrOw0KPiAgDQo+IEBAIC0yMTMsMTAgKzIxNCwxMCBAQCBpbnQgbWFpbihpbnQgYXJnYywgY2hh ciAqYXJndltdKQ0KPiAgCQljYXNlICdkJzoNCj4gIAkJCWVuYWJsZV9kZWJ1ZygpOw0KPiAgCQkJ YnJlYWs7DQo+IC0JCWNhc2UgJ2MnOg0KPiAtCQkJY29uZmlnX2RpciA9IG9wdGFyZzsNCj4gKwkJ Y2FzZSAncyc6DQo+ICsJCQlzdG9yYWdlX2RpciA9IG9wdGFyZzsNCj4gIAkJCWJyZWFrOw0KPiAt CQljYXNlICdmJzoNCj4gKwkJY2FzZSAnYyc6DQo+ICAJCQltZXNoX2NvbmZfZm5hbWUgPSBvcHRh cmc7DQo+ICAJCQlicmVhazsNCj4gIAkJY2FzZSAnYic6DQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aGq8JdJSUl/sSgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 04 Sep 2020 16:44:34 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id oCwyJNJSUl8jaQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 04 Sep 2020 16:44:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 31CA842102; Fri, 4 Sep 2020 16:44:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730460AbgIDOoO (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 4 Sep 2020 10:44:14 -0400 Received: from mail-io1-f77.google.com ([209.85.166.77]:52007 "EHLO mail-io1-f77.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730388AbgIDOoK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 4 Sep 2020 10:44:10 -0400 Received: by mail-io1-f77.google.com with SMTP id q12so4421532iob.18 for <linux-bluetooth@vger.kernel.org>; Fri, 04 Sep 2020 07:44:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=GE20mkCJFx34V9csXbBi5MpSPEm23j5O5gEKMXhuGs4=; b=jTxTV3FSjJPPYofjYJrVk43LQrfKGwPrA+Vjot0+fx7Ymm/iWFUX+y6/+g34qRkKyu LLpDMOof1FDUbqCdPmc0FjCJ5XKSO3JWnN/4a3wpjWdVrKx9gUeqUhnQ44fbwDltAeSy 1rGGsomwpIVe4CI4n0Gcp36l3b48ZILA1Wd4soJTGDlan0FzRm7Km62ArxE2fo5QgDmG ofhSWce7UU20kRRTsRqO28QVulJnM0k5vQvWD8fEKA1ykEgt26FJMBWIXPbYbWh3kvKI 9/S7p91UnnR4Jh+XdVlvFJJNY6IGO7W6Wi6iH0kDcsAg8wjvD6to9ufJqTroc59pLCkB u3tQ== X-Gm-Message-State: AOAM533cd3V59D88TLcfGPJ/YyyZByLYFo+buWgkxwt1WwzF1L6F3ebN SLeWfpB4cB3LVjHgnqijffHtKpSfXQc/F1kHM1kZTEj+fEEn X-Google-Smtp-Source: ABdhPJxZCmzJJSBtD6oipaJudDBJ1GQFFB0c3Y+RmR7v/iFXEsAA2X6Ph+jfCB/546LXa6E6JWGbeRIObehShZ2GPeZnQjV295Tv MIME-Version: 1.0 X-Received: by 2002:a05:6e02:1303:: with SMTP id g3mr4832562ilr.218.1599230649567; Fri, 04 Sep 2020 07:44:09 -0700 (PDT) Date: Fri, 04 Sep 2020 07:44:09 -0700 In-Reply-To: <00000000000055e1a9059f9e169f@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000c8101605ae7de686@google.com> Subject: Re: KASAN: use-after-free Write in refcount_warn_saturate From: syzbot <syzbot+7dd7f2f77a7a01d1dc14@syzkaller.appspotmail.com> To: abhishekpandit@chromium.org, alainm@chromium.org, davem@davemloft.net, johan.hedberg@gmail.com, johan.hedberg@intel.com, josua.mayer@jm0.eu, jukka.rissanen@linux.intel.com, keescook@chromium.org, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, mcchou@chromium.org, mike@foundries.io, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.33 / 15.00 / 200.00 X-Rspamd-Queue-Id: 31CA842102 X-Rspamd-UID: 4b28d7 syzbot suspects this issue was fixed by commit: commit b83764f9220a4a14525657466f299850bbc98de9 Author: Miao-chen Chou <mcchou@chromium.org> Date: Tue Jun 30 03:15:00 2020 +0000 Bluetooth: Fix kernel oops triggered by hci_adv_monitors_clear() bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=10f92e3e900000 start commit: c0842fbc random32: move the pseudo-random 32-bit definitio.. git tree: upstream kernel config: https://syzkaller.appspot.com/x/.config?x=cf567e8c7428377e dashboard link: https://syzkaller.appspot.com/bug?extid=7dd7f2f77a7a01d1dc14 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15b606dc900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=123e87cc900000 If the result looks correct, please mark the issue as fixed by replying with: #syz fix: Bluetooth: Fix kernel oops triggered by hci_adv_monitors_clear() For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qMTHJWXBUl8A6QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 05 Sep 2020 00:36:21 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iHOPJGXBUl8x2wAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 05 Sep 2020 00:36:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A50E6420F7; Sat, 5 Sep 2020 00:36:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728185AbgIDWgL (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 4 Sep 2020 18:36:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728076AbgIDWgL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 4 Sep 2020 18:36:11 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34175C061244 for <linux-bluetooth@vger.kernel.org>; Fri, 4 Sep 2020 15:36:08 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id a2so7270308otr.11 for <linux-bluetooth@vger.kernel.org>; Fri, 04 Sep 2020 15:36:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4NleXdVdbpx9b00tfVBJqgckh877rdnwVriN+/Ekhxw=; b=OIOreoCoXSdHZQi8zB1BiO680FlVNsumY5Hylh8Xzh9Z0HCv62gBs4vZf4zm9Eio0M NviNXDOZlehUi/N0mPVuwnVLOP/AZKfUMAsn1N2HGHGc+3zCn60s8bG5GnUWa1iYgSke doxuezLKFy2T2pu1yY5o+AQW7/S+HPb7UcTozMKl1R4FsI4DPNFnVdnM6P/zw46nfkNB QnQZtsHbRPvYrz0ImGRzVwAVLbnYg19f+2UmXRvfU6Nzftw7jNmy1ls3XX2w6P/52Jos 0UcjSnsf0YKekdavDTLmQz8+gH0mpAf3Q9CpVmhRP9Vvk17kke01sTigfyZXJkYNv3ax GO/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4NleXdVdbpx9b00tfVBJqgckh877rdnwVriN+/Ekhxw=; b=eVr8Cek17CO/NhSpylYpOdjcPBcD6wuoOYS1C0CpO3L39ABAF4WHd7AByAuOvYUcta L6kqaNut3hjX9gjQYdnnM21zjmzSgZOUTnNJqwjrLaOeeFjfz96bqM4cLHdam4Wdu67m dzExLmJtMMNUbuKm0XQNL171B6+9TjC1R+DVRrf8ITPXZdL/bDLzGxGEQAfc/0RrU5Jq PdzYmpzBoFUK+JUcsWjxzpqbG9SfNmdCtnUSh4id5ySCaSEalj+6UJnYUvTOlm0J9V2T WnmW3MoEq+IqZZC3jeTN/WwfNTHAI+G+Dixyn6h3K5l4vIKOmdxeamtaeqzc5AkqjdFt 8qdQ== X-Gm-Message-State: AOAM5309mbd9U9JQ6Wn5xRbahpMCupMjww2Gn8eeKki1OxjApWLlnPu5 3Oz5ma3v70CHjGcB7JUQ5UCZxTdtx5oCvK1l9X0= X-Google-Smtp-Source: ABdhPJywT5Btr2LUWf8mkdAXicgmQyZz89ZI4VDzln6AxZWvamghCN1nDuveORmpQ3TF3O5SAb5CbcIo7ol+FGVqsp4= X-Received: by 2002:a9d:429:: with SMTP id 38mr6743513otc.88.1599258967511; Fri, 04 Sep 2020 15:36:07 -0700 (PDT) MIME-Version: 1.0 References: <20200903115020.Bluez.v3.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> In-Reply-To: <20200903115020.Bluez.v3.1.I6767a68b7e7b6cfb6d8046ee8b66c8e7d008d3e6@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 4 Sep 2020 15:35:53 -0700 Message-ID: <CABBYNZL4wN0mNhSqmCevGnOcFsgbh+FhFrrZLRtkGh97sZhckQ@mail.gmail.com> Subject: Re: [Bluez PATCH v3 1/2] doc/media-api: Add Press/Hold/Release methods for MediaPlayer1 To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.23 / 15.00 / 200.00 X-Rspamd-Queue-Id: A50E6420F7 X-Rspamd-UID: 5939a7 Hi Archie, On Wed, Sep 2, 2020 at 8:50 PM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > This allows us to send any passthrough command. The button can also > be held for an extended amount of time. > > Reviewed-by: Michael Sun <michaelfsun@chromium.org> > --- > > (no changes since v2) > > Changes in v2: > * Add Hold and Release methods > > doc/media-api.txt | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/doc/media-api.txt b/doc/media-api.txt > index dabc69936..e98573157 100644 > --- a/doc/media-api.txt > +++ b/doc/media-api.txt > @@ -199,6 +199,35 @@ Methods void Play() > Possible Errors: org.bluez.Error.NotSupported > org.bluez.Error.Failed > > + void Press(byte avc_key) > + > + Press a specific key to send as passthrough command. > + The key will be released automatically. Use Hold() > + instead if the intention is to hold down the key. > + > + Possible Errors: org.bluez.Error.InvalidArguments > + org.bluez.Error.NotSupported > + org.bluez.Error.Failed > + > + void Hold(byte avc_key) > + > + Press and hold a specific key to send as passthrough > + command. It is your responsibility to make sure that > + Release() is called after calling this method. The held > + key will also be released when any other method in this > + interface is called. > + > + Possible Errors: org.bluez.Error.InvalidArguments > + org.bluez.Error.NotSupported > + org.bluez.Error.Failed > + > + void Release() > + > + Release the previously held key invoked using Hold(). > + > + Possible Errors: org.bluez.Error.NotSupported > + org.bluez.Error.Failed > + > Properties string Equalizer [readwrite] > > Possible values: "off" or "on" > -- > 2.28.0.402.g5ffc5be6b7-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kLQvMVbyUl9qBwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 05 Sep 2020 04:05:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id ULhKL1byUl9tYQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 05 Sep 2020 04:05:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 52DF2A1260; Sat, 5 Sep 2020 04:05:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726575AbgIECEi (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Fri, 4 Sep 2020 22:04:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbgIECEh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 4 Sep 2020 22:04:37 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E780C061244; Fri, 4 Sep 2020 19:04:36 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id b16so4010366pjp.0; Fri, 04 Sep 2020 19:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n+kZoKqKGDj4sxz/spgYXr9LUZZuZ+0ogBgOuprttQg=; b=uhSZsLneznox8j/wfTxJSSTDG30ykKmjtFg76kdzEeZLYy/fOrBdy2QgFGXwCKlf00 TBtbJTueT11YFsFBkNqv2h7LKAf4bUOoigdlQZxT3U99VyTdqLoEeKJMYm/RYODVk6Fs LwjgGVYTI9gNPsPUxZFkT92XD244ihXCTgyY/bDaeEZ0LLT2OUgeWv5JDxBnbua2IP8i FrCxFp05KjRAaU5qD/0WwO8oHm86YSF9W3aksgUToopVNjzUclLczjEciCwoUGMlh5IJ 6QSlRmCNY5K7ztgh6WsrLaCr38Jf+9hTlyY/D7Qr9r17CPEPIEErx7p2wCVsD538JqFb llRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n+kZoKqKGDj4sxz/spgYXr9LUZZuZ+0ogBgOuprttQg=; b=dehFF2cN3brBxg/Wr5stzwLBdZG3sH/saP1j1LH/wx6s1VpFkvy3nNqmWqXqWJe3Wb RvJzLl8R5bnz2/De/eu31N42M315Mr+JVtpBJBeID6VjhgI364BucnVvIYAt7P5SQzGc 8+zeJbtoBbvI7FJ5LRzzdA0ZNQs+s8GMZBgtNjeO7RPm2S5fME+p37AFPFtWlKd9D4Q0 wEQ0yEfTCpDa1NFzUeTzEW+CRG1prVWbgu7R5qwYIqV+zPFhqZDaTev8sSGt+bfTBzZP 9oeRBixPuwMUBmTJaxKh1v9PRsy9jb027owyo2zXay3TgK2umSi/p1ZcpuGmefbbVLal /RmQ== X-Gm-Message-State: AOAM533UG0HQU+h9S0SmP4niNiS94Ze364hLUmTx2P9Zn7YFejxEWOex zcQYwXa3imkG/mc+NQfGcyDFqFRAqAW3io7q X-Google-Smtp-Source: ABdhPJxseGxIt0034578p+AgKbObcHKZ69MVPLi1F41nrP4o5X6UV+hRLg5jABu0zSRgG8VcoBhCAw== X-Received: by 2002:a17:90b:4d0f:: with SMTP id mw15mr10517822pjb.174.1599271474699; Fri, 04 Sep 2020 19:04:34 -0700 (PDT) Received: from localhost.localdomain ([49.207.195.77]) by smtp.gmail.com with ESMTPSA id x19sm2245332pge.22.2020.09.04.19.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 19:04:33 -0700 (PDT) From: Anant Thazhemadam <anant.thazhemadam@gmail.com> To: linux-kernel-mentees@lists.linuxfoundation.org Cc: Anant Thazhemadam <anant.thazhemadam@gmail.com>, Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH] Fix uninit-value in hci_chan_lookup_handle Date: Sat, 5 Sep 2020 07:34:10 +0530 Message-Id: <20200905020410.20350-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.05 / 15.00 / 200.00 X-Rspamd-Queue-Id: 52DF2A1260 X-Rspamd-UID: 91043e When the amount of data stored in the location corresponding to iov_iter *from is less then 4, some data seems to go uninitialized. Updating this condition accordingly, makes sense both intuitively and logically as well, since the other check for extreme condition done is if len > HCI_MAX_FRAME_SIZE, which is HCI_MAX_ACL_SIZE (which is 1024) + 4; which itself gives some idea about what must be the ideal mininum size. Reported-and-tested by: syzbot+4c14a8f574461e1c3659@syzkaller.appspotmail.com Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com> --- If there is some explicit reason why len < 4 doesn't work, and only len < 2 works, please do let me know. The commit message that introduced the initial change (512b2268156a4e15ebf897f9a883bdee153a54b7) wasn't exactly very helpful in this respect, and I couldn't find a whole lot of discussion regarding this either. drivers/bluetooth/hci_vhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 8ab26dec5f6e..0c49821d7b98 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c @@ -159,7 +159,7 @@ static inline ssize_t vhci_get_user(struct vhci_data *data, __u8 pkt_type, opcode; int ret; - if (len < 2 || len > HCI_MAX_FRAME_SIZE) + if (len < 4 || len > HCI_MAX_FRAME_SIZE) return -EINVAL; skb = bt_skb_alloc(len, GFP_KERNEL); -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6K0kGLGBU1+/hgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 05 Sep 2020 14:16:49 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id ILKPFrGBU1+2LAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 05 Sep 2020 14:16:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6D04EA1ACA; Sat, 5 Sep 2020 14:16:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728482AbgIEMQ1 (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 5 Sep 2020 08:16:27 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:34072 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726597AbgIEMQ0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 5 Sep 2020 08:16:26 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 1BBD328909026AC3E515; Sat, 5 Sep 2020 20:16:23 +0800 (CST) Received: from localhost (10.174.179.108) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Sat, 5 Sep 2020 20:16:16 +0800 From: YueHaibing <yuehaibing@huawei.com> To: <marcel@holtmann.org>, <johan.hedberg@gmail.com>, <matthias.bgg@gmail.com>, <sean.wang@mediatek.com> CC: <linux-bluetooth@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-mediatek@lists.infradead.org>, <linux-kernel@vger.kernel.org>, YueHaibing <yuehaibing@huawei.com> Subject: [PATCH -next] Bluetooth: btmtksdio: use NULL instead of zero Date: Sat, 5 Sep 2020 20:15:49 +0800 Message-ID: <20200905121549.32936-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.179.108] X-CFilter-Loop: Reflected Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.75 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6D04EA1ACA X-Rspamd-UID: 4f32e3 Fix sparse warnings: drivers/bluetooth/btmtksdio.c:499:57: warning: Using plain integer as NULL pointer drivers/bluetooth/btmtksdio.c:533:57: warning: Using plain integer as NULL pointer Signed-off-by: YueHaibing <yuehaibing@huawei.com> --- drivers/bluetooth/btmtksdio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c index c7ab7a23bd67..ba45c59bd9f3 100644 --- a/drivers/bluetooth/btmtksdio.c +++ b/drivers/bluetooth/btmtksdio.c @@ -496,7 +496,7 @@ static void btmtksdio_interrupt(struct sdio_func *func) sdio_claim_host(bdev->func); /* Disable interrupt */ - sdio_writel(func, C_INT_EN_CLR, MTK_REG_CHLPCR, 0); + sdio_writel(func, C_INT_EN_CLR, MTK_REG_CHLPCR, NULL); int_status = sdio_readl(func, MTK_REG_CHISR, NULL); @@ -530,7 +530,7 @@ static void btmtksdio_interrupt(struct sdio_func *func) } /* Enable interrupt */ - sdio_writel(func, C_INT_EN_SET, MTK_REG_CHLPCR, 0); + sdio_writel(func, C_INT_EN_SET, MTK_REG_CHLPCR, NULL); pm_runtime_mark_last_busy(bdev->dev); pm_runtime_put_autosuspend(bdev->dev); -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uAyVNxaNU19voQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 05 Sep 2020 15:05:26 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id uLDZNRaNU1+2ewAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 05 Sep 2020 15:05:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2BB13A26EB; Sat, 5 Sep 2020 15:05:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726582AbgIENFR (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 5 Sep 2020 09:05:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726261AbgIENFQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 5 Sep 2020 09:05:16 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22379C061244 for <linux-bluetooth@vger.kernel.org>; Sat, 5 Sep 2020 06:05:15 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id lo4so12082957ejb.8 for <linux-bluetooth@vger.kernel.org>; Sat, 05 Sep 2020 06:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=4NtQf52lSgyRznUwKj19VkNFxxHthnzpd8hCC9wl9Z0=; b=ApzMgCsRYxcpsCglYXDkBwUsUrivTFcrEekGRcNY3mNjz3rB/HaazwmUKG2cw7syQ4 AqmKfeCiP0K4lX9spX51x4Gas13YdZW4Y5lKZhuxddGeNA45d2RCkrXLApmv5mjTdT02 6HENXONEwVSh56DQUP+A8OPYRecOG47n2xwpTy6ZPI+gv9iKjS3COQyGHodY/PEUWOu8 1iL/3DTvJMfYioHocVaUfWH/UB5mIfEXIPygtIbng8cMERLcRlMCva34BXE6MJ5Fllg2 zWe8wrcjU2zXB+k8NEoiZFU8Hahw6gZIS+qwzS39XrsVNcZo2GPnrZMcf9Nbvhp0xr/i WQaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4NtQf52lSgyRznUwKj19VkNFxxHthnzpd8hCC9wl9Z0=; b=H8YkkOA/+rN1JyW4SZexLcCMTLfOQFyA+X9xktqX3E9T7ZEJXvxrCWRgpsQbBT0lIq hAdW+L7/q3t+tCDDdCjrx5se2Iwl8g2C+K0t1TuMKSC3AnR68wN2CFllrS7u5NDJSB2c L+9pdSeBW6xxNwZGbQzdZ4l/moqvW1/+D7BHWtSc3Q/IfaWUUb7VtReMjci90m+9mpYj TgN14Gvv9h0scHTCOzjiC1wPsmnznISnzfODi8AzdLtWVXZgFGicAArUbTdxvR9E6l5x LLsBjkpF0a4C2g4I65ij7mT439ni2eWzoa395WvayCoynPHShY7ATNuX0HKUf5H5ds+6 9cQQ== X-Gm-Message-State: AOAM530ccLsjq0ouQHbkls4tOb5rq6mRem+dccYudLmgkEWVYg0lRavB dGQFwTmenTHx1ns6dCQ1QLn/qK48sXw= X-Google-Smtp-Source: ABdhPJxyPx/67JIFKVEVPrGZkLDcZtVrqWXrlLh4tDdOg70xB8D9oaCQVKLaeignH6im4EPzNBK48A== X-Received: by 2002:a17:906:2a49:: with SMTP id k9mr12785719eje.117.1599311113717; Sat, 05 Sep 2020 06:05:13 -0700 (PDT) Received: from ?IPv6:2a02:908:1982:45e0:d671:de7a:8bdd:70e1? ([2a02:908:1982:45e0:d671:de7a:8bdd:70e1]) by smtp.gmail.com with ESMTPSA id g20sm8935318edh.62.2020.09.05.06.05.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 05 Sep 2020 06:05:12 -0700 (PDT) Subject: Re: Bluetooth connection disconnects every few minutes From: Julian Sikorski <belegdol@gmail.com> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> References: <67077b05-dc49-3a97-c83f-4090f1cc7cea@gmail.com> <phdhvi$sdh$1@blaine.gmane.org> <8e41e2ae-bef4-d479-9706-49fd214081a6@chini.tk> <phdpkn$q3q$1@blaine.gmane.org> <pht30d$27m$1@blaine.gmane.org> <53d57478-4b61-65a4-7f09-b7e473cc613a@chini.tk> <305017ee-6420-3c44-7842-14776c37207d@gmail.com> <12fa0585-c993-0685-ac76-27d96d539ca2@gmail.com> <9a633975-704c-1a00-3f9f-b93a499947c2@gmail.com> <8bf4641f-4d3e-faf4-f53a-c571b97d9be4@gmail.com> <2bd00ced-f685-9048-5a10-a20028595086@gmail.com> <CABBYNZ+ZqS1LHVjLwt3mQvmFi1y7ogf_Tstvu70-XnDVT3nAAA@mail.gmail.com> <21f3b905-566c-00a0-e576-f47ae13019a6@gmail.com> Message-ID: <727b6dfa-b666-9cc3-1e5f-2715700d38f6@gmail.com> Date: Sat, 5 Sep 2020 15:05:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <21f3b905-566c-00a0-e576-f47ae13019a6@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.60 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2BB13A26EB X-Rspamd-UID: 48e275 W dniu 02.09.2020 o 07:58, Julian Sikorski pisze: > W dniu 02.09.2020 o 01:14, Luiz Augusto von Dentz pisze: >> Hi Julian, >> >> On Tue, Sep 1, 2020 at 1:42 PM Julian Sikorski <belegdol@gmail.com> wrote: >>> >>> W dniu 01.09.2020 o 22:10, Julian Sikorski pisze: >>>> W dniu 12.08.2018 o 17:49, Julian Sikorski pisze: >>>>> W dniu 01.08.2018 o 19:46, Julian Sikorski pisze: >>>>>> W dniu 09.07.2018 o 18:51, Julian Sikorski pisze: >>>>>>> W dniu 08.07.2018 o 19:46, Georg Chini pisze: >>>>>>>> On 08.07.2018 15:21, Julian Sikorski wrote: >>>>>>>>> W dniu 02.07.2018 o 20:09, Julian Sikorski pisze: >>>>>>>>>> W dniu 02.07.2018 o 18:04, Georg Chini pisze: >>>>>>>>>>> On 02.07.2018 17:58, Julian Sikorski wrote: >>>>>>>>>>>> W dniu 29.06.2018 o 21:47, Julian Sikorski pisze: >>>>>>>>>>>>> Hi list, >>>>>>>>>>>>> >>>>>>>>>>>>> I have noticed that the bluetooth connection between my laptop (Intel >>>>>>>>>>>>> 7260) and my headphones (Sennheiser Momentum Wirelless) is very >>>>>>>>>>>>> unreliable. While under Windows 10 devices stay connected for >>>>>>>>>>>>> hours on >>>>>>>>>>>>> end, under Fedora 28 the connection is lost every few minutes at >>>>>>>>>>>>> most. >>>>>>>>>>>>> Often the connection will be reestablished only to be lost again. >>>>>>>>>>>>> bluetoothd shows messages like: >>>>>>>>>>>>> >>>>>>>> >>>>>>>>>>>>> I am not sure where to look further. Does it look like an issue with >>>>>>>>>>>>> pulseaudio, or a deeper problem with linux bluetooth stack? Thanks >>>>>>>>>>>>> for >>>>>>>>>>>>> your input in advance! >>>>>>>>>>>>> >>>>>>>>>>>>> Best regards, >>>>>>>>>>>>> Julian >>>>>>>>>>>> This is what is logged by pulseaudio at the time the connection is >>>>>>>>>>>> lost: >>>>>>>>>>>> >>>>>>>>>>>> ( 118.064| 34.694) I: [bluetooth] module-bluez5-device.c: FD error: >>>>>>>>>>>> POLLERR POLLHUP >>>>>>>>>>>> ( 118.064| 0.000) I: [bluetooth] bluez5-util.c: Transport >>>>>>>>>>>> /org/bluez/hci0/dev_00_1B_66_81_8D_76/fd27 auto-released by BlueZ or >>>>>>>>>>>> already released >>>>>>>>>>>> ( 118.064| 0.000) I: [pulseaudio] backend-native.c: Lost RFCOMM >>>>>>>>>>>> connection. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>> From what you are writing, it looks to me as if the issue is in the >>>>>>>>>>> USB >>>>>>>>>>> stack and the BT dongle keeps disconnecting/connecting. Have you >>>>>>>>>>> tried another dongle? >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> I unfortunately do not own any other dongles. I tried getting some >>>>>>>>>> useful info with btmon but the log seems flooded with way too many >>>>>>>>>> messages to make anything out. >>>>>>>>>> >>>>>>>>> Hi Georg, >>>>>>>>> >>>>>>>>> it looks like the problem is more related to how the dongle interacts >>>>>>>>> with this specific headphone model. I have recently bought another one >>>>>>>>> for running (AfterShokz Trekz Air) and it works perfectly, connecting >>>>>>>>> automatically, staying connected and even switching profiles >>>>>>>>> automatically without issues so far. >>>>>>>>> The hci0: last event is not cmd complete (0x0f) message seems harmless >>>>>>>>> as it spams the dmesg output regardless of the device connected (and >>>>>>>>> also when no device is connected at all. >>>>>>>>> It appears that whatever is happening it makes the dongle reconnect: >>>>>>>>> >>>>>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: USB disconnect, device number 6 >>>>>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: new full-speed USB device number 7 >>>>>>>>> using ehci-pci >>>>>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: New USB device found, >>>>>>>>> idVendor=8087, idProduct=07dc, bcdDevice= 0.01 >>>>>>>>> [nie lip 8 15:14:12 2018] usb 2-1.4: New USB device strings: Mfr=0, >>>>>>>>> Product=0, SerialNumber=0 >>>>>>>>> [nie lip 8 15:14:12 2018] Bluetooth: hci0: read Intel version: >>>>>>>>> 3707100180012d0d2a >>>>>>>>> [nie lip 8 15:14:12 2018] Bluetooth: hci0: Intel device is already >>>>>>>>> patched. patch num: 2a >>>>>>>>> >>>>>>>>> Where would you recommend to look for reasons for this behaviour? btmon? >>>>>>>>> Thank you for the pointers! >>>>>>>>> >>>>>>>>> Best regards, >>>>>>>>> Julian >>>>>>>>> >>>>>>>>> >>>>>>>> Hi Julian, >>>>>>>> >>>>>>>> sorry, I have no further ideas. Maybe Luiz can help you to investigate. >>>>>>>> To me it looks like the headphone is sending something that makes the >>>>>>>> dongle reset. >>>>>>>> >>>>>>>> Regards >>>>>>>> Georg >>>>>>> >>>>>>> Hi Georg, >>>>>>> >>>>>>> no worries - hopefully Luiz will find some time to look into this. >>>>>>> In the meantime I have been getting acquainted with btmon. I have >>>>>>> managed to pinpoint the exact moment during which sound stops coming >>>>>>> through the headphones and starts coming through the laptop speakers. In >>>>>>> the below testcase, it happens at 18:42:58: >>>>>>> >>>>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>>>> #1825 [hci0] 18:42:58.908586 >>>>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>>>> #1826 [hci0] 18:42:58.928877 >>>>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>>>>>> {0x0002} [hci0] 18:43:00.653578 >>>>>>> Class: 0x000000 >>>>>>> Major class: Miscellaneous >>>>>>> Minor class: 0x00 >>>>>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>>>>>> {0x0001} [hci0] 18:43:00.653578 >>>>>>> Class: 0x000000 >>>>>>> Major class: Miscellaneous >>>>>>> Minor class: 0x00 >>>>>>> @ MGMT Event: New Settings (0x0006) plen 4 >>>>>>> {0x0002} [hci0] 18:43:00.653609 >>>>>>> Current settings: 0x00000ada >>>>>>> Connectable >>>>>>> Discoverable >>>>>>> Bondable >>>>>>> Secure Simple Pairing >>>>>>> BR/EDR >>>>>>> Low Energy >>>>>>> Secure Connections >>>>>>> @ MGMT Event: New Settings (0x0006) plen 4 >>>>>>> {0x0001} [hci0] 18:43:00.653609 >>>>>>> Current settings: 0x00000ada >>>>>>> Connectable >>>>>>> Discoverable >>>>>>> Bondable >>>>>>> Secure Simple Pairing >>>>>>> BR/EDR >>>>>>> Low Energy >>>>>>> Secure Connections >>>>>>> = bluetoothd: Unable to get io data for Headset Voice gateway: >>>>>>> getpeername: Transport endpoint is not connected.. 18:43:00.654133 >>>>>>> = Close Index: 7C:5C:F8:B2:DF:08 >>>>>>> [hci0] 18:43:00.678348 >>>>>>> @ MGMT Event: Index Removed (0x0005) plen 0 >>>>>>> {0x0002} [hci0] 18:43:00.678372 >>>>>>> @ MGMT Event: Index Removed (0x0005) plen 0 >>>>>>> {0x0001} [hci0] 18:43:00.678372 >>>>>>> = Delete Index: 7C:5C:F8:B2:DF:08 >>>>>>> [hci0] 18:43:00.678377 >>>>>>> = bluetoothd: Endpoint unregistered: sender=:1.1492 >>>>>>> path=/MediaEndpoint/A2DPSource >>>>>>> 18:43:00.678966 >>>>>>> = bluetoothd: Endpoint unregistered: sender=:1.1492 >>>>>>> path=/MediaEndpoint/A2DPSink >>>>>>> 18:43:00.678984 >>>>>>> >>>>>>> I am copying linux-bluetooth, maybe someone there will have an idea as >>>>>>> well. Thank you for all your help in advance! >>>>>>> >>>>>>> Best regards, >>>>>>> Julian >>>>>> >>>>>> Hi all, >>>>>> >>>>>> I tried to get more information using hcidump, but it does not appear >>>>>> very interesting. I am attaching it here just in case. The last entry >>>>>> appearing - command complete (read encryption key size) - appears upon >>>>>> successful connection, not when the connection is dropped. How else >>>>>> could I try to figure out what is being sent at the time of >>>>>> disconnection? Thank you! >>>>>> >>>>>> Best regards, >>>>>> Julian >>>>> >>>>> Hi list, >>>>> >>>>> I just realised I never attached the full btmon dump. Here it goes, the >>>>> connection drops at 17:32:04: >>>>> >>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>> #1340 [hci0] 17:32:04.774611 >>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>>> HCI Event: Number of Completed Packets (0x13) plen 5 >>>>> #1341 [hci0] 17:32:04.783175 >>>>> Num handles: 1 >>>>> Handle: 256 >>>>> Count: 1 >>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>> #1342 [hci0] 17:32:04.794981 >>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>>> HCI Event: Number of Completed Packets (0x13) plen 5 >>>>> #1343 [hci0] 17:32:04.803054 >>>>> Num handles: 1 >>>>> Handle: 256 >>>>> Count: 1 >>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>> #1344 [hci0] 17:32:04.815326 >>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>>> HCI Event: Number of Completed Packets (0x13) plen 5 >>>>> #1345 [hci0] 17:32:04.823198 >>>>> Num handles: 1 >>>>> Handle: 256 >>>>> Count: 1 >>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>> #1346 [hci0] 17:32:04.835578 >>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>> #1347 [hci0] 17:32:04.856093 >>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>> #1348 [hci0] 17:32:04.876186 >>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>> #1349 [hci0] 17:32:04.896454 >>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>> < ACL Data TX: Handle 256 flags 0x02 dlen 850 >>>>> #1350 [hci0] 17:32:04.916869 >>>>> Channel: 450 len 846 [PSM 25 mode 0] {chan 2} >>>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>>>> {0x0002} [hci0] 17:32:06.637019 >>>>> Class: 0x000000 >>>>> Major class: Miscellaneous >>>>> Minor class: 0x00 >>>>> @ MGMT Event: Class Of Device Changed (0x0007) plen 3 >>>>> {0x0001} [hci0] 17:32:06.637019 >>>>> Class: 0x000000 >>>>> Major class: Miscellaneous >>>>> Minor class: 0x00 >>>>> @ MGMT Event: New Settings (0x0006) plen 4 >>>>> {0x0002} [hci0] 17:32:06.637034 >>>>> Current settings: 0x00000ada >>>>> Connectable >>>>> Discoverable >>>>> Bondable >>>>> Secure Simple Pairing >>>>> BR/EDR >>>>> Low Energy >>>>> Secure Connections >>>>> @ MGMT Event: New Settings (0x0006) plen 4 >>>>> {0x0001} [hci0] 17:32:06.637034 >>>>> Current settings: 0x00000ada >>>>> Connectable >>>>> Discoverable >>>>> Bondable >>>>> Secure Simple Pairing >>>>> BR/EDR >>>>> Low Energy >>>>> Secure Connections >>>>> = Close Index: 7C:5C:F8:B2:DF:08 >>>>> [hci0] 17:32:06.654087 >>>>> @ MGMT Event: Index Removed (0x0005) plen 0 >>>>> {0x0002} [hci0] 17:32:06.654114 >>>>> @ MGMT Event: Index Removed (0x0005) plen 0 >>>>> {0x0001} [hci0] 17:32:06.654114 >>>>> = Delete Index: 7C:5C:F8:B2:DF:08 >>>>> [hci0] 17:32:06.654120 >>>>> = bluetoothd: Unable to get io data for Headset Voice gateway: >>>>> getpeername: Transport endpoint is not connected.. 17:32:06.654352 >>>>> = bluetoothd: Endpoint unregistered: sender=:1.750 >>>>> path=/MediaEndpoint/A2DPSource >>>>> 17:32:06.654796 >>>>> = bluetoothd: Endpoint unregistered: sender=:1.750 >>>>> path=/MediaEndpoint/A2DPSink >>>>> 17:32:06.654836 >>>>> >>>>> I tried sending the btmon capture as attachment but it appears to be too >>>>> large for the list, so I uploaded it here instead: >>>>> >>>>> https://belegdol.fedorapeople.org/btmon-aug.log >> >> Is this perhaps related to https://github.com/bluez/bluez/issues/18, >> we have a fix already applied upstream for it. >> > > Hi Luiz, > > it looks like a different issue. I tried both passing --noplugin=avrcp > and applying the two patches mentioned in the github issue to Fedora > RPM, neither helped. I am attaching a new btmon capture in case > something changed. In this one the disconnect happens after #371. > > Best regards, > Julian Hi Luiz, I have now tested the same headset (Sennheiser Momentum Wireless aka M2 AEBT) with another machine, this time a desktop equipped with Intel 3168NGW dongle. With this machine everything appears to be working flawlessly, with no disconnection happening for several minutes. I have uploaded the btmon log to my dropbox as it is too large to attach here: https://www.dropbox.com/s/ttetss50jqlvi35/m2-aebt-desktop.zip?dl=0 Hopefully there is something in the log indicating as to why the headset keeps disconnecting from the laptop. The laptop is equipped with Intel 7260 dongle. Best regards, Julian >>>>> Best regards, >>>>> Julian >>>>> >>>> >>>> Hi all, >>>> >>>> I have tried the headset again with kernel-5.8.4, bluez-5.54 and >>>> pulseaudio-13.99.1. The situation has unfortunately not improved in the >>>> last two years. >>>> I am attaching the btmon capture of two connection attempts: >>>> - the first connects and then almost immediately disconnects >>>> - the second never succeeds >>>> Does the capture provide any information as to why the connection is >>>> failing? If I can provide any more data, please let me know. Thanks! >>>> >>>> Best regards, >>>> Julian >>>> >>> If I am not mistaken, the disconnect happens right after #636 >>> >>> Best regards, >>> Julian >> >> >> > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WA73Lk82VF/wIgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 06 Sep 2020 03:07:27 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CFS8LU82VF8Z6gEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 06 Sep 2020 03:07:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1A573420D3; Sun, 6 Sep 2020 03:07:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728758AbgIFBHH (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sat, 5 Sep 2020 21:07:07 -0400 Received: from mail-io1-f79.google.com ([209.85.166.79]:53568 "EHLO mail-io1-f79.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728563AbgIFBHG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 5 Sep 2020 21:07:06 -0400 Received: by mail-io1-f79.google.com with SMTP id w9so6253419ior.20 for <linux-bluetooth@vger.kernel.org>; Sat, 05 Sep 2020 18:07:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=uErToetCtxM2LxDa/nunGNpiTq3iUJM6c1gSOFYhqVE=; b=knZtwpSrWEVZlaP4czMzUuE8KvsLDdH+ifoTn28ET5A70qm2fvN6vomk1/PPVUa+LM epwEMs70U7MEL0dljdjfQbHo7VD21AjaHck94oZTLM3+DysY6ryAqoqVF9CnUZprAbet VDvQSdUl9XwV9xHtHfm/CwjNH31ilPB7lOCxs+NJNbyeC23MteThDJ19eEl+lIC+WVf8 1fADxA4TEw71Q10Zynnkv1ihJ2aKr+iBQsC3jMp1tU730u2Ryf4Z2MopYmpzATrgbKgA xF/cIGKk6hD75ipYJz73XV9cptpNGAD5Sm2c5VdYmnEosbztjFE2dgP1rzYkgGSk7wpm vHGA== X-Gm-Message-State: AOAM5326yLd8fJFreaIbhh3Q4MoKoQ9AzyR4REcnM9Y2ekvkokiaYnXZ t3TxVTrqN69ASCGIDyStgfELYKlTqLES458NEoB0oazcRFpw X-Google-Smtp-Source: ABdhPJym3N6qwjYEE5uH53mipM2L77NAqTDZN1skGYxJ5p38lVrxFf0yXeNgvWFwORCMUNrX5wE8e7Ubtqufgb0mrh/6nKA86/PQ MIME-Version: 1.0 X-Received: by 2002:a5d:8042:: with SMTP id b2mr13018336ior.60.1599354425033; Sat, 05 Sep 2020 18:07:05 -0700 (PDT) Date: Sat, 05 Sep 2020 18:07:05 -0700 In-Reply-To: <0000000000000cce30059f4e27e9@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000005fc62d05ae9ab8c2@google.com> Subject: Re: WARNING: refcount bug in l2cap_chan_put From: syzbot <syzbot+198362c76088d1515529@syzkaller.appspotmail.com> To: abhishekpandit@chromium.org, alainm@chromium.org, bliniob53@gmail.com, davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, luiz.dentz@gmail.com, marcel@holtmann.org, mcchou@chromium.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.01 / 15.00 / 200.00 X-Rspamd-Queue-Id: 1A573420D3 X-Rspamd-UID: 530cf3 syzbot suspects this issue was fixed by commit: commit b83764f9220a4a14525657466f299850bbc98de9 Author: Miao-chen Chou <mcchou@chromium.org> Date: Tue Jun 30 03:15:00 2020 +0000 Bluetooth: Fix kernel oops triggered by hci_adv_monitors_clear() bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11aaff5d900000 start commit: fffe3ae0 Merge tag 'for-linus-hmm' of git://git.kernel.org.. git tree: upstream kernel config: https://syzkaller.appspot.com/x/.config?x=18bb86f2e4ebfda2 dashboard link: https://syzkaller.appspot.com/bug?extid=198362c76088d1515529 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=152a482c900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=109b781a900000 If the result looks correct, please mark the issue as fixed by replying with: #syz fix: Bluetooth: Fix kernel oops triggered by hci_adv_monitors_clear() For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YJA8NzV0VF9//wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 06 Sep 2020 07:31:33 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 2BmXNTV0VF+bDwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 06 Sep 2020 07:31:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 360B042103; Sun, 6 Sep 2020 07:31:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726165AbgIFFbJ (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 6 Sep 2020 01:31:09 -0400 Received: from mail-il1-f208.google.com ([209.85.166.208]:44748 "EHLO mail-il1-f208.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725497AbgIFFbI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 6 Sep 2020 01:31:08 -0400 Received: by mail-il1-f208.google.com with SMTP id j11so7837420ilr.11 for <linux-bluetooth@vger.kernel.org>; Sat, 05 Sep 2020 22:31:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=AkAlyJgLNh08fM+adXYaVRQxqHnsf7ozrxDfshPlvlo=; b=jlzYQ/qt9MpyZR4TR6gMqqOHhYAdcVYF1po60zuYye/2hAp7iPlNR4jr1n5cXgJFIt QJU4M1qkyfHprYQVFp9+mwptNjDQiMs8GRuFUxWUEd7KnnoYfyK8GtcNDIUcaZ4nnZGc Bu4nSzy6dHdva80dnGtxr60/KExNzpR5oaZl1Feueh7hW1VCZZoBoOMKP0jPaSXqmnzz 5J/QNkLf6J/p05FXUg0OBzft5R4N+qfehjbfqz7JJBKYodYOO9OX5H+c2vqMHt3wY0n6 MGJji7+7IZiZ5J5qit2C+XjpBVZd4iiA10JzepTooCTMMQ/oAzSJKGb1dbFAZwfo927x hu2Q== X-Gm-Message-State: AOAM532nfXPTEZ7uhuNHqe/4CFRDLfU7WosnQDMSbsXG+WKlgy6hbG4d yB+7Su6kgZ+JCwc71Gh/8W4tEZcDsBHaoPxI1KpFkIQolFiN X-Google-Smtp-Source: ABdhPJwZOylw0u4Wo0Y6MQf20PT2tvuW4TXOi8u8DYia+/JL+8Tk/MjaNqQtmwfTZ13rTOIRf/mXOEYmGdgD6b9BLhL/1p4LDdw/ MIME-Version: 1.0 X-Received: by 2002:a92:99cb:: with SMTP id t72mr14005144ilk.172.1599370267186; Sat, 05 Sep 2020 22:31:07 -0700 (PDT) Date: Sat, 05 Sep 2020 22:31:07 -0700 In-Reply-To: <0000000000008b9e0705a38afe52@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000a3de6505ae9e6831@google.com> Subject: Re: WARNING: refcount bug in do_enable_set From: syzbot <syzbot+2e9900a1e1b3c9c96a77@syzkaller.appspotmail.com> To: Markus.Elfring@web.de, abhishekpandit@chromium.org, alainm@chromium.org, davem@davemloft.net, hdanton@sina.com, johan.hedberg@gmail.com, koulihong@huawei.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, mcchou@chromium.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.93 / 15.00 / 200.00 X-Rspamd-Queue-Id: 360B042103 X-Rspamd-UID: 5ba698 syzbot suspects this issue was fixed by commit: commit b83764f9220a4a14525657466f299850bbc98de9 Author: Miao-chen Chou <mcchou@chromium.org> Date: Tue Jun 30 03:15:00 2020 +0000 Bluetooth: Fix kernel oops triggered by hci_adv_monitors_clear() bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=115a4245900000 start commit: fffe3ae0 Merge tag 'for-linus-hmm' of git://git.kernel.org.. git tree: upstream kernel config: https://syzkaller.appspot.com/x/.config?x=226c7a97d80bec54 dashboard link: https://syzkaller.appspot.com/bug?extid=2e9900a1e1b3c9c96a77 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12b3efea900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11131284900000 If the result looks correct, please mark the issue as fixed by replying with: #syz fix: Bluetooth: Fix kernel oops triggered by hci_adv_monitors_clear() For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GCF+JdkhVV/vbwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 06 Sep 2020 19:52:25 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0G78I9khVV9nEgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 06 Sep 2020 19:52:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3DBC4A12D1; Sun, 6 Sep 2020 19:52:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729089AbgIFRwS convert rfc822-to-8bit (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 6 Sep 2020 13:52:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:36510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728928AbgIFRwR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 6 Sep 2020 13:52:17 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 209173] New: laptop boot takes 1.20 minutes - i cant seem to find anything wrong other than bluetooth in Dmesg Date: Sun, 06 Sep 2020 17:52:15 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: high X-Bugzilla-Who: thiviyan@gmail.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version cf_kernel_version rep_platform op_sys cf_tree bug_status bug_severity priority component assigned_to reporter cf_regression attachments.created Message-ID: <bug-209173-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3DBC4A12D1 X-Rspamd-UID: 4b567b https://bugzilla.kernel.org/show_bug.cgi?id=209173 Bug ID: 209173 Summary: laptop boot takes 1.20 minutes - i cant seem to find anything wrong other than bluetooth in Dmesg Product: Drivers Version: 2.5 Kernel Version: 5.7.0 Hardware: Intel OS: Linux Tree: Mainline Status: NEW Severity: high Priority: P1 Component: Bluetooth Assignee: linux-bluetooth@vger.kernel.org Reporter: thiviyan@gmail.com Regression: No Created attachment 292379 --> https://bugzilla.kernel.org/attachment.cgi?id=292379&action=edit dmesg -T output expected behavior : system supposed to boot within less than 20 seconds current behavior : it take around 1.30 Minutes to reach user space. its loads normally when i try live usb disk without the RTL8822be drivers loaded for wifi and bluetooth but when i try the os which is installed in HDD with all the drivers it takes a long time to boot. i am not sure if its the problem caused by the wifi/bluetooth drivers(i have no complains on their connectivity) tried solutions : checked UUID of swap and it maches. tried couple different cmdline options in grub none fixed the issue. i have attached the dmesg -T output and systemd-analyze critical-chain outputs. OS: Kali GNU/Linux Rolling x Host: 81FV Lenovo Legion Y53 Kernel: 5.7.0-kali3-amd64 CPU: Intel i5-8300H (8) @ 4. GPU: NVIDIA GeForce GTX 1050 GPU: Intel UHD Graphics 630 Memory: 3807MiB / 23995MiB -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0LxyI0ydVV9e7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 04:39:08 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UF1FIUydVV8zIgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 04:39:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8F9B2420CF; Mon, 7 Sep 2020 04:39:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726318AbgIGCjC (ORCPT <rfc822;woutergordts@mailbox.org> + 1 other); Sun, 6 Sep 2020 22:39:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726259AbgIGCjA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 6 Sep 2020 22:39:00 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54C74C061573 for <linux-bluetooth@vger.kernel.org>; Sun, 6 Sep 2020 19:38:58 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id g4so14140166wrs.5 for <linux-bluetooth@vger.kernel.org>; Sun, 06 Sep 2020 19:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=y+9Hq78tnOIICkVeQNlHi/iq6rMPlgaPjzotk9Rd2Z4=; b=OxwG7PwXWIXAXOlyLg6Gt82MdXFXXxOmcq8AJgBW3HsWvj59NCOk7i/bd2znp4xrIy ASLqR0lIgAJtTS0c0ceQ+KpGjYjm9I5h7Mku36NhWlpBKCkAcGOlqr10hhQa8KyoFRUC 3F/N2CzjHRebNlS3PY0GrGwsVvmHC18hRG+ouH12VrayAZZ92irr8u1aLvB+mhGxCjsT UOi7SfmHBFTUgEj8R1NSp/Eknj3baJMu8WCADV6iTn6OS4B3bfIZeoAdebEH2Tz/3kKe Wcodn5gsChZp9kgCD3XIKBDK+UCL7z3I2G9y2w/Lz9mTM39tmn1xHxc1hEn9EsQF8Whc VcqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=y+9Hq78tnOIICkVeQNlHi/iq6rMPlgaPjzotk9Rd2Z4=; b=GS8fa7rpv7F1TnqXPowyC8ZF6rsqOYMkxa3Rb1Of/XwK0FtyyLYVf22mxa1+xA3WFA HtcYzBu/oasoeIf+pkLV/JYz/SrCwaLzTBV+qEbJPQx+boSjRC/boxDnYjuNRanltq41 uX2HdvbbR3EjgYPtR/W3OoloacAmXWsWjmILZQJEFJzJwp3bZQ8SpecaIDWHsJgEzG2x cZPPrgUElkhvs0h0JlWNDoQIkzFi5gcdzCrcPb5N4sQMUK/vx8A1tYXOKgJrqAikgK/2 Fz3NCH0eCdwsaobiIsSmMBd8GLp1xkp2hWe6csXAozEBdfGPT/fPfCFNOwEHuBgXlbrp YQag== X-Gm-Message-State: AOAM531KRTaVRaQihNJWlhD1j0x3v9faFnhR2knCKbTOrZXhWt0NGGJD 3k5RwNMl3qaOSV6jJBxk9hUVZ+bfHYOMyV4qDE2iCvkNfaM= X-Google-Smtp-Source: ABdhPJx2EmPyd6UaFIgWzNeVfzcXqrJXBY36ubn9F8YZMLUp5IhGgMWyrOO09h2PqwQtG2NHzPs/EXH97cJCZ2tikRc= X-Received: by 2002:a5d:6a45:: with SMTP id t5mr20680994wrw.58.1599446337038; Sun, 06 Sep 2020 19:38:57 -0700 (PDT) MIME-Version: 1.0 References: <20200901113736.Bluez.v2.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> In-Reply-To: <20200901113736.Bluez.v2.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> From: Archie Pusaka <apusaka@google.com> Date: Mon, 7 Sep 2020 10:38:46 +0800 Message-ID: <CAJQfnxEopr6GzSsjbq4wQaWaw9QZDu_hmZMJF9_bS7i4nU5owQ@mail.gmail.com> Subject: Re: [Bluez PATCH v2] device: don't wait for timeout if RemoveDevice is called To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.50 / 15.00 / 200.00 X-Rspamd-Queue-Id: 8F9B2420CF X-Rspamd-UID: d15ce7 Hi Bluez maintainers, Could you take another look at this patch? Thanks, Archie On Tue, 1 Sep 2020 at 11:37, Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > RemoveDevice on adapter interface used to remove a device, even when > the device is connected. However, since the introduction of the new > 30 seconds timeout when setting a device as temporary, RemoveDevice > doesn't immediately remove a connected device, but only disconnects > it and waits for the timer to expire before effectively removes it. > > This patch removes the device as soon as it gets disconnected, > provided the disconnection is triggered by a call to RemoveDevice. > The regular timeout still applies for other cases. > > Tested manually by calling RemoveDevice on a connected device, > and with ChromeOS autotest setup. > > Reviewed-by: Daniel Winkler <danielwinkler@google.com> > > Signed-off-by: Archie Pusaka <apusaka@chromium.org> > --- > > Changes in v2: > * Rebasing to HEAD > > src/adapter.c | 2 -- > src/adapter.h | 2 ++ > src/device.c | 11 +++++++++++ > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index 1435e2bd7..ffd05aa0b 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -79,8 +79,6 @@ > #include "advertising.h" > #include "eir.h" > > -#define ADAPTER_INTERFACE "org.bluez.Adapter1" > - > #define MODE_OFF 0x00 > #define MODE_CONNECTABLE 0x01 > #define MODE_DISCOVERABLE 0x02 > diff --git a/src/adapter.h b/src/adapter.h > index f8ac20261..f835c984f 100644 > --- a/src/adapter.h > +++ b/src/adapter.h > @@ -26,6 +26,8 @@ > #include <dbus/dbus.h> > #include <glib.h> > > +#define ADAPTER_INTERFACE "org.bluez.Adapter1" > + > #define MAX_NAME_LENGTH 248 > > /* Invalid SSP passkey value used to indicate negative replies */ > diff --git a/src/device.c b/src/device.c > index df440ce09..f20270017 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -3007,6 +3007,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > { > struct bearer_state *state = get_state(device, bdaddr_type); > DBusMessage *reply; > + bool remove_device = false; > > if (!state->connected) > return; > @@ -3036,6 +3037,10 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > while (device->disconnects) { > DBusMessage *msg = device->disconnects->data; > > + if (dbus_message_is_method_call(msg, ADAPTER_INTERFACE, > + "RemoveDevice")) > + remove_device = true; > + > g_dbus_send_reply(dbus_conn, msg, DBUS_TYPE_INVALID); > device->disconnects = g_slist_remove(device->disconnects, msg); > dbus_message_unref(msg); > @@ -3061,6 +3066,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > > g_dbus_emit_property_changed(dbus_conn, device->path, > DEVICE_INTERFACE, "Connected"); > + > + if (remove_device) > + btd_adapter_remove_device(device->adapter, device); > } > > guint device_add_disconnect_watch(struct btd_device *device, > @@ -4477,6 +4485,9 @@ void device_remove(struct btd_device *device, gboolean remove_stored) > disconnect_all(device); > } > > + if (device->temporary_timer > 0) > + g_source_remove(device->temporary_timer); > + > if (device->store_id > 0) { > g_source_remove(device->store_id); > device->store_id = 0; > -- > 2.28.0.402.g5ffc5be6b7-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sPM2ERFCVl/xuAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 16:22:09 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EE9MDhFCVl+fhAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 16:22:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7508F408AE; Mon, 7 Sep 2020 16:22:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729806AbgIGOVZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 10:21:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:49280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729594AbgIGOSz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:18:55 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8F2292064B; Mon, 7 Sep 2020 14:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599488180; bh=+hBkQu9s4/gMzHCxciSjjnQi2QtLKwBklfRKGdDcWQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ubElOFB8q/iIS1SIkvwxPAzakDy+zGpi/JPWEGV+l+oSadsydiBT5sTCirXySPLqt uFcwgKNn3JXhKu8BvcomGRstBQE9qN2SN/qJLdtwM9id25z1Lv/0d/Bbt72IA2dTay GkXCdq92evvVCma8kdDninKnSyiW/ZPpouX25gls= Date: Mon, 7 Sep 2020 16:16:34 +0200 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: Alan Stern <stern@rowland.harvard.edu> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Eli Billauer <eli.billauer@gmail.com>, Emiliano Ingrassia <ingrassia@epigenesys.com>, Alexander Tsoy <alexander@tsoy.me>, "Geoffrey D. Bennett" <g@b4.vu>, Jussi Laako <jussi@sonarnerd.net>, Nick Kossifidis <mickflemm@gmail.com>, Dmitry Panchenko <dmitry@d-systems.ee>, Chris Wulff <crwulff@gmail.com>, Jesus Ramos <jesus-ramos@live.com> Subject: Re: [PATCH 01/10] USB: move snd_usb_pipe_sanity_check into the USB core Message-ID: <20200907141634.GA3733019@kroah.com> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-2-gregkh@linuxfoundation.org> <20200903004553.GA642955@rowland.harvard.edu> <20200903073230.GA162335@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200903073230.GA162335@kroah.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.80 / 15.00 / 200.00 X-Rspamd-Queue-Id: 7508F408AE X-Rspamd-UID: fde0e5 On Thu, Sep 03, 2020 at 09:32:30AM +0200, Greg Kroah-Hartman wrote: > On Wed, Sep 02, 2020 at 08:45:53PM -0400, Alan Stern wrote: > > On Wed, Sep 02, 2020 at 01:01:03PM +0200, Greg Kroah-Hartman wrote: > > > snd_usb_pipe_sanity_check() is a great function, so let's move it into > > > the USB core so that other parts of the kernel, including the USB core, > > > can call it. > > > > > > Name it usb_pipe_type_check() to match the existing > > > usb_urb_ep_type_check() call, which now uses this function. > > > > > > Cc: Jaroslav Kysela <perex@perex.cz> > > > Cc: Takashi Iwai <tiwai@suse.com> > > > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > > > Cc: Eli Billauer <eli.billauer@gmail.com> > > > Cc: Emiliano Ingrassia <ingrassia@epigenesys.com> > > > Cc: Alan Stern <stern@rowland.harvard.edu> > > > Cc: Alexander Tsoy <alexander@tsoy.me> > > > Cc: "Geoffrey D. Bennett" <g@b4.vu> > > > Cc: Jussi Laako <jussi@sonarnerd.net> > > > Cc: Nick Kossifidis <mickflemm@gmail.com> > > > Cc: Dmitry Panchenko <dmitry@d-systems.ee> > > > Cc: Chris Wulff <crwulff@gmail.com> > > > Cc: Jesus Ramos <jesus-ramos@live.com> > > > Cc: linux-usb@vger.kernel.org > > > Cc: linux-kernel@vger.kernel.org > > > Cc: alsa-devel@alsa-project.org > > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > > --- > > > > > diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c > > > index 27e83e55a590..45bc2914c1ba 100644 > > > --- a/drivers/usb/core/urb.c > > > +++ b/drivers/usb/core/urb.c > > > @@ -192,24 +192,39 @@ static const int pipetypes[4] = { > > > }; > > > > > > /** > > > - * usb_urb_ep_type_check - sanity check of endpoint in the given urb > > > - * @urb: urb to be checked > > > + * usb_pipe_type_check - sanity check of a specific pipe for a usb device > > > + * @dev: struct usb_device to be checked > > > + * @pipe: pipe to check > > > * > > > * This performs a light-weight sanity check for the endpoint in the > > > - * given urb. It returns 0 if the urb contains a valid endpoint, otherwise > > > - * a negative error code. > > > + * given usb device. It returns 0 if the pipe is a valid for the specific usb > > -----------------------------------------------------^ > > Typo. > > Oops, will fix, thanks. > > > > > > > + * device, otherwise a negative error code. > > > */ > > > -int usb_urb_ep_type_check(const struct urb *urb) > > > +int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe) > > > { > > > const struct usb_host_endpoint *ep; > > > > > > - ep = usb_pipe_endpoint(urb->dev, urb->pipe); > > > + ep = usb_pipe_endpoint(dev, pipe); > > > if (!ep) > > > return -EINVAL; > > > - if (usb_pipetype(urb->pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) > > > + if (usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) > > > return -EINVAL; > > > return 0; > > > } > > > +EXPORT_SYMBOL_GPL(usb_pipe_type_check); > > > + > > > +/** > > > + * usb_urb_ep_type_check - sanity check of endpoint in the given urb > > > + * @urb: urb to be checked > > > + * > > > + * This performs a light-weight sanity check for the endpoint in the > > > + * given urb. It returns 0 if the urb contains a valid endpoint, otherwise > > > + * a negative error code. > > > + */ > > > +int usb_urb_ep_type_check(const struct urb *urb) > > > +{ > > > + return usb_pipe_type_check(urb->dev, urb->pipe); > > > +} > > > EXPORT_SYMBOL_GPL(usb_urb_ep_type_check); > > > > Since this routine is used in only one place in the entire kernel, you > > might as well inline the code there and get rid of the function > > entirely. > > Good idea, will do. No, wait, the USB sound drivers call it a lot, so it needs to stick around for now until we clean that up. thanks, greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eNACIyVJVl/RXgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 16:52:21 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gF2jHyVJVl8q9QAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 16:52:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BCD43A0B09; Mon, 7 Sep 2020 16:52:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730031AbgIGOvS (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 10:51:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:58454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730019AbgIGOvC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE3772176B; Mon, 7 Sep 2020 14:51:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490261; bh=7qCTpFFNqVHtpIMDAKfKXUS+bFE7hzcYks7b6ByyYYk=; h=From:To:Cc:Subject:Date:From; b=i7cbHqNM8H80YrBKKrffwXGThOtzzgcasGBvFkRfT7FH9nFjKPReIo6OfblvqC8J8 dcFzGdDcEzRsAq9FHSI69+mXJXBePLE+tU9T7CxLvPOaFBeO7Qt7ENNJqN0ouv/WHx p+qTucob7AxMxRRcAJKUFp7Nutzrjr2zfrQTAv1Y= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH v2 00/11] USB: new USB control message helper functions Date: Mon, 7 Sep 2020 16:50:57 +0200 Message-Id: <20200907145108.3766613-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.57 / 15.00 / 200.00 X-Rspamd-Queue-Id: BCD43A0B09 X-Rspamd-UID: 1e3be2 In a recent discussion about a USB networking bug found by syzbot, and fixed by Himadri Pandya, the design of the existing usb_control_msg() call was brought up as not being the "nicest" thing to use by Dmitry Vyukov: https://lore.kernel.org/r/CACT4Y+YbDODLRFn8M5QcY4CazhpeCaunJnP_udXtAs0rYoASSg@mail.gmail.com The function makes it hard to get right, in that it will return the number of bytes sent/received, but almost no one checks to see if a short read/write happens. With a malicious, or broken, USB device, this can cause drivers to act on data that they did not anticipate, and sometimes copy internal kernel data out to userspace. So let's fix this up by creating two new functions, usb_control_msg_send() and usb_control_msg_recv(). These functions either complete the full transation, or they return an error, a short send/recv is now an error. They also accept data off of the stack, saving individual drivers the pain of having to constantly allocate memory on their own for tiny messages, thereby saving overall kernel code space. The api also does not require a raw USB "pipe" to be sent to the function, as we know the direction, so just pass in the endpoint number instead, again making it easier on the USB driver author to use. This series first takes a helper function out of the sound core for verifying USB endpoints to be able to use internally, and then adds the new functions, converts over some internal USB code to use them, and then starts to clean up some drivers using these new functions, as an example of the savings that can happen by using these functions. Thanks to Dmitry and Himadri for the idea on how to do all of this. greg k-h Changes from v1: - added acks from Takashi Iwai - dropped changes to one function in patch 04 thanks to review from Alan Stern - typo fix in comment in patch 01 - added new patch 11 to remove some unneeded checks in the sound drivers for endpoint statuses that would always be true. *** BLURB HERE *** Greg Kroah-Hartman (11): USB: move snd_usb_pipe_sanity_check into the USB core USB: add usb_control_msg_send() and usb_control_msg_recv() USB: core: message.c: use usb_control_msg_send() in a few places USB: core: hub.c: use usb_control_msg_send() in a few places USB: legousbtower: use usb_control_msg_recv() sound: usx2y: move to use usb_control_msg_send() sound: 6fire: move to use usb_control_msg_send() and usb_control_msg_recv() sound: line6: move to use usb_control_msg_send() and usb_control_msg_recv() sound: hiface: move to use usb_control_msg_send() Bluetooth: ath3k: use usb_control_msg_send() and usb_control_msg_recv() ALSA: remove calls to usb_pipe_type_check for control endpoints drivers/bluetooth/ath3k.c | 90 +++++------------ drivers/usb/core/hub.c | 99 ++++++++---------- drivers/usb/core/message.c | 171 ++++++++++++++++++++++++++++---- drivers/usb/core/urb.c | 31 ++++-- drivers/usb/misc/legousbtower.c | 60 ++++------- include/linux/usb.h | 7 ++ sound/usb/6fire/firmware.c | 38 +++---- sound/usb/helper.c | 16 +-- sound/usb/helper.h | 1 - sound/usb/hiface/pcm.c | 14 ++- sound/usb/line6/driver.c | 69 +++++-------- sound/usb/line6/podhd.c | 17 ++-- sound/usb/line6/toneport.c | 8 +- sound/usb/mixer_scarlett_gen2.c | 2 +- sound/usb/quirks.c | 12 +-- sound/usb/usx2y/us122l.c | 42 ++------ 16 files changed, 335 insertions(+), 342 deletions(-) -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AITXFyxJVl/RXgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 16:52:28 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eL3xFCxJVl+eTwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 16:52:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B25FFA0B0C; Mon, 7 Sep 2020 16:52:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730040AbgIGOwO (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 10:52:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:58394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730017AbgIGOvA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:00 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 49690207C3; Mon, 7 Sep 2020 14:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490258; bh=VyYPJEj5Ta05TnAL4Uqngww5JY0W3tZR+jtP4bI3fM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AO0NWMVeiykJuFlIG2+j/MgHbQ1A9SkfAaTHndL7x8pAgyokDPAePFPyq4+eMfyoJ iulHCmkqToL92A4X1uEeI8AjdoLKZWWY7nECRBYr05PHYN6LFOqgRvJuN1Aw8nZwgg AEJObpCRRN8wzpUSgvETVNQzKrE63S6eRb42pSiU= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Eli Billauer <eli.billauer@gmail.com>, Emiliano Ingrassia <ingrassia@epigenesys.com>, Alan Stern <stern@rowland.harvard.edu>, Alexander Tsoy <alexander@tsoy.me>, "Geoffrey D. Bennett" <g@b4.vu>, Jussi Laako <jussi@sonarnerd.net>, Nick Kossifidis <mickflemm@gmail.com>, Dmitry Panchenko <dmitry@d-systems.ee>, Chris Wulff <crwulff@gmail.com>, Jesus Ramos <jesus-ramos@live.com>, Takashi Iwai <tiwai@suse.de> Subject: [PATCH v2 01/11] USB: move snd_usb_pipe_sanity_check into the USB core Date: Mon, 7 Sep 2020 16:50:58 +0200 Message-Id: <20200907145108.3766613-2-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907145108.3766613-1-gregkh@linuxfoundation.org> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.84 / 15.00 / 200.00 X-Rspamd-Queue-Id: B25FFA0B0C X-Rspamd-UID: 21d6f7 snd_usb_pipe_sanity_check() is a great function, so let's move it into the USB core so that other parts of the kernel, including the USB core, can call it. Name it usb_pipe_type_check() to match the existing usb_urb_ep_type_check() call, which now uses this function. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> Cc: Eli Billauer <eli.billauer@gmail.com> Cc: Emiliano Ingrassia <ingrassia@epigenesys.com> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Alexander Tsoy <alexander@tsoy.me> Cc: "Geoffrey D. Bennett" <g@b4.vu> Cc: Jussi Laako <jussi@sonarnerd.net> Cc: Nick Kossifidis <mickflemm@gmail.com> Cc: Dmitry Panchenko <dmitry@d-systems.ee> Cc: Chris Wulff <crwulff@gmail.com> Cc: Jesus Ramos <jesus-ramos@live.com> Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: alsa-devel@alsa-project.org Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v2: - use usb_pipe_type_check() instead of usb_urb_ep_type_check in urb.c - fix typo in function description - both changes thanks to Alan Stern's review comments - added Takashi Iwai's reviewed-by drivers/usb/core/urb.c | 31 +++++++++++++++++++++++-------- include/linux/usb.h | 1 + sound/usb/helper.c | 16 +--------------- sound/usb/helper.h | 1 - sound/usb/mixer_scarlett_gen2.c | 2 +- sound/usb/quirks.c | 12 ++++++------ 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 27e83e55a590..357b149b20d3 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -192,24 +192,39 @@ static const int pipetypes[4] = { }; /** - * usb_urb_ep_type_check - sanity check of endpoint in the given urb - * @urb: urb to be checked + * usb_pipe_type_check - sanity check of a specific pipe for a usb device + * @dev: struct usb_device to be checked + * @pipe: pipe to check * * This performs a light-weight sanity check for the endpoint in the - * given urb. It returns 0 if the urb contains a valid endpoint, otherwise - * a negative error code. + * given usb device. It returns 0 if the pipe is valid for the specific usb + * device, otherwise a negative error code. */ -int usb_urb_ep_type_check(const struct urb *urb) +int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe) { const struct usb_host_endpoint *ep; - ep = usb_pipe_endpoint(urb->dev, urb->pipe); + ep = usb_pipe_endpoint(dev, pipe); if (!ep) return -EINVAL; - if (usb_pipetype(urb->pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) + if (usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) return -EINVAL; return 0; } +EXPORT_SYMBOL_GPL(usb_pipe_type_check); + +/** + * usb_urb_ep_type_check - sanity check of endpoint in the given urb + * @urb: urb to be checked + * + * This performs a light-weight sanity check for the endpoint in the + * given urb. It returns 0 if the urb contains a valid endpoint, otherwise + * a negative error code. + */ +int usb_urb_ep_type_check(const struct urb *urb) +{ + return usb_pipe_type_check(urb->dev, urb->pipe); +} EXPORT_SYMBOL_GPL(usb_urb_ep_type_check); /** @@ -474,7 +489,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) */ /* Check that the pipe's type matches the endpoint's type */ - if (usb_urb_ep_type_check(urb)) + if (usb_pipe_type_check(urb->dev, urb->pipe)) dev_WARN(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n", usb_pipetype(urb->pipe), pipetypes[xfertype]); diff --git a/include/linux/usb.h b/include/linux/usb.h index 20c555db4621..0b3963d7ec38 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1764,6 +1764,7 @@ static inline int usb_urb_dir_out(struct urb *urb) return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; } +int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe); int usb_urb_ep_type_check(const struct urb *urb); void *usb_alloc_coherent(struct usb_device *dev, size_t size, diff --git a/sound/usb/helper.c b/sound/usb/helper.c index 4c12cc5b53fd..cf92d7110773 100644 --- a/sound/usb/helper.c +++ b/sound/usb/helper.c @@ -63,20 +63,6 @@ void *snd_usb_find_csint_desc(void *buffer, int buflen, void *after, u8 dsubtype return NULL; } -/* check the validity of pipe and EP types */ -int snd_usb_pipe_sanity_check(struct usb_device *dev, unsigned int pipe) -{ - static const int pipetypes[4] = { - PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT - }; - struct usb_host_endpoint *ep; - - ep = usb_pipe_endpoint(dev, pipe); - if (!ep || usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) - return -EINVAL; - return 0; -} - /* * Wrapper for usb_control_msg(). * Allocates a temp buffer to prevent dmaing from/to the stack. @@ -89,7 +75,7 @@ int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, void *buf = NULL; int timeout; - if (snd_usb_pipe_sanity_check(dev, pipe)) + if (usb_pipe_type_check(dev, pipe)) return -EINVAL; if (size > 0) { diff --git a/sound/usb/helper.h b/sound/usb/helper.h index 5e8a18b4e7b9..f5b4c6647e4d 100644 --- a/sound/usb/helper.h +++ b/sound/usb/helper.h @@ -7,7 +7,6 @@ unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size); void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype); void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype); -int snd_usb_pipe_sanity_check(struct usb_device *dev, unsigned int pipe); int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size); diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 0ffff7640892..9609c6d9655c 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -1978,7 +1978,7 @@ static int scarlett2_mixer_status_create(struct usb_mixer_interface *mixer) return 0; } - if (snd_usb_pipe_sanity_check(dev, pipe)) + if (usb_pipe_type_check(dev, pipe)) return -EINVAL; mixer->urb = usb_alloc_urb(0, GFP_KERNEL); diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index abf99b814a0f..fc3aab04a0bc 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -846,7 +846,7 @@ static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev) static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 }; void *buf; - if (snd_usb_pipe_sanity_check(dev, usb_sndintpipe(dev, 0x05))) + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x05))) return -EINVAL; buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); if (!buf) @@ -875,7 +875,7 @@ static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev) { int ret; - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) return -EINVAL; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE, @@ -984,7 +984,7 @@ static int snd_usb_axefx3_boot_quirk(struct usb_device *dev) dev_dbg(&dev->dev, "Waiting for Axe-Fx III to boot up...\n"); - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) return -EINVAL; /* If the Axe-Fx III has not fully booted, it will timeout when trying * to enable the audio streaming interface. A more generous timeout is @@ -1018,7 +1018,7 @@ static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, { int err, actual_length; - if (snd_usb_pipe_sanity_check(dev, usb_sndintpipe(dev, 0x01))) + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x01))) return -EINVAL; err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x01), buf, *length, &actual_length, 1000); @@ -1030,7 +1030,7 @@ static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, memset(buf, 0, buf_size); - if (snd_usb_pipe_sanity_check(dev, usb_rcvintpipe(dev, 0x82))) + if (usb_pipe_type_check(dev, usb_rcvintpipe(dev, 0x82))) return -EINVAL; err = usb_interrupt_msg(dev, usb_rcvintpipe(dev, 0x82), buf, buf_size, &actual_length, 1000); @@ -1117,7 +1117,7 @@ static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) { int ret; - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) return -EINVAL; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6M9PAqRKVl/RXgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 16:58:44 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gJvHOqNKVl+MIQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 16:58:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A9EEDA01C4; Mon, 7 Sep 2020 16:58:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730099AbgIGO6Z (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 10:58:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:32888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730081AbgIGO4a (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:56:30 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 136EF21532; Mon, 7 Sep 2020 14:56:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490589; bh=CxyQpGP9n8TbvTWZlcMnPBvQvdoM8Roi6NJr/4wY+3A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lLzcZLnJRYwJRZpj3pSMH+uuomTwjStzPuS6HLjLIR8uWd1c17Y4ebZXRr69gGDbk XzOwh+xBK4S0GODqAZ9+JB/lT9bmvkpwmYARCwsKMtJ5kSbtocsB4b0nmXhOEwQg8b HtSakIDPyMr4ieHYrnhthaO4x/1FviU5JovhMFEA= Date: Mon, 7 Sep 2020 16:56:44 +0200 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>, himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Alan Stern <stern@rowland.harvard.edu>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: Re: [PATCH v2 03/11] USB: core: message.c: use usb_control_msg_send() in a few places Message-ID: <20200907145644.GA3767938@kroah.com> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> <20200907145108.3766613-4-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200907145108.3766613-4-gregkh@linuxfoundation.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.71 / 15.00 / 200.00 X-Rspamd-Queue-Id: A9EEDA01C4 X-Rspamd-UID: ad83fa On Mon, Sep 07, 2020 at 04:51:00PM +0200, Greg Kroah-Hartman wrote: > There are a few calls to usb_control_msg() that can be converted to use > usb_control_msg_send() instead, so do that in order to make the error > checking a bit simpler. > > Cc: Alan Stern <stern@rowland.harvard.edu> > Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Cc: linux-usb@vger.kernel.org > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Oops, Andy, sorry, you gave me a Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> on the previous version of this, I'll add it next round, or when it's queued up. thanks, greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wAY6GLNRVl8RbwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:28:51 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id OJlaFbNRVl9vPAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:28:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0D46AA0B09; Mon, 7 Sep 2020 17:28:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730180AbgIGP2k (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:28:40 -0400 Received: from netrider.rowland.org ([192.131.102.5]:39509 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1730115AbgIGPPp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 11:15:45 -0400 Received: (qmail 763212 invoked by uid 1000); 7 Sep 2020 11:08:58 -0400 Date: Mon, 7 Sep 2020 11:08:58 -0400 From: Alan Stern <stern@rowland.harvard.edu> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH v2 04/11] USB: core: hub.c: use usb_control_msg_send() in a few places Message-ID: <20200907150858.GD762136@rowland.harvard.edu> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> <20200907145108.3766613-5-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200907145108.3766613-5-gregkh@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.03 / 15.00 / 200.00 X-Rspamd-Queue-Id: 0D46AA0B09 X-Rspamd-UID: d27a14 On Mon, Sep 07, 2020 at 04:51:01PM +0200, Greg Kroah-Hartman wrote: > There are a few calls to usb_control_msg() that can be converted to use > usb_control_msg_send() instead, so do that in order to make the error > checking a bit simpler and the code smaller. > > Cc: Alan Stern <stern@rowland.harvard.edu> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > --- > v2: > - dropped changes to usb_req_set_sel() thanks to review from Alan > @@ -4056,7 +4035,7 @@ static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev, > * associated with the link state we're about to enable. > */ > ret = usb_req_set_sel(udev, state); > - if (ret < 0) { > + if (ret) { > dev_warn(&udev->dev, "Set SEL for device-initiated %s failed.\n", > usb3_lpm_names[state]); > return; Did this change survive by mistake? Actually, it looks like usb_req_set_sel needs to check the value returned by usb_control_msg -- a perfect example of the sort of thing you were trying to fix in the first place! Alan Stern Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uHzSB4JSVl9NdwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:32:18 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id EB6lBIJSVl+BuQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:32:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 22BCD40994; Mon, 7 Sep 2020 17:32:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730174AbgIGPcI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:32:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:58920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730026AbgIGOvu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:50 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CF88921D1A; Mon, 7 Sep 2020 14:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490289; bh=QkHCdP+HSp94bJnlBpjYKa/KAoOjp/oPWOpwsQOF274=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=If90dhouW6N4/r8is7BQs/yBjxud6qO6c5+ufUOQf8CXsy3gv1V2w2PGAy49dIHm/ G3ml1sY6lzQGW8SXyG1noSerdbf5dAVtP+nfveAVGBwAmVmMOwFsajNut8Ka3mvAIA 93XNYS89t/ZaY7XxlmUeAC8YAvdGBivshk5xJf/8= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Takashi Iwai <tiwai@suse.de> Subject: [PATCH v2 09/11] sound: hiface: move to use usb_control_msg_send() Date: Mon, 7 Sep 2020 16:51:06 +0200 Message-Id: <20200907145108.3766613-10-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907145108.3766613-1-gregkh@linuxfoundation.org> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.16 / 15.00 / 200.00 X-Rspamd-Queue-Id: 22BCD40994 X-Rspamd-UID: 503b24 The usb_control_msg_send() call can return an error if a "short" write happens, so move the driver over to using that call instead. Cc: Jaroslav Kysela <perex@perex.cz> Cc: alsa-devel@alsa-project.org Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v2: - Added reviewed-by from Takashi sound/usb/hiface/pcm.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sound/usb/hiface/pcm.c b/sound/usb/hiface/pcm.c index a148caa5f48e..f9c924e3964e 100644 --- a/sound/usb/hiface/pcm.c +++ b/sound/usb/hiface/pcm.c @@ -156,16 +156,14 @@ static int hiface_pcm_set_rate(struct pcm_runtime *rt, unsigned int rate) * This control message doesn't have any ack from the * other side */ - ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), - HIFACE_SET_RATE_REQUEST, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, - rate_value, 0, NULL, 0, 100); - if (ret < 0) { + ret = usb_control_msg_send(device, 0, + HIFACE_SET_RATE_REQUEST, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, + rate_value, 0, NULL, 0, 100); + if (ret) dev_err(&device->dev, "Error setting samplerate %d.\n", rate); - return ret; - } - return 0; + return ret; } static struct pcm_substream *hiface_pcm_get_substream(struct snd_pcm_substream -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YKwnF4hSVl9NdwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:32:24 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IJ1gFIhSVl/TxAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:32:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9CFD340994; Mon, 7 Sep 2020 17:32:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730186AbgIGPcL (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:32:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:58592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730028AbgIGOvu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:50 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C18FA217BA; Mon, 7 Sep 2020 14:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490274; bh=jxLO7PEataV5luZRkq/UdmKiDOteLqmmXKbbFJ+l/YU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iOU1baU2mmQQJHiyztQoYqPcykN3rOpD5PArxaec2zSSmqbNDqf8u6jfBGRG7JDjB I1HsMg+mUuRmtyrUIBXAwRbJox2WTxTkChcMON3bvTneSH7GSnd4kkekdFcBmoWtvF SAZctyqe6hBT6FJBoiLU6qBY28oR2nexgHXjMBCQ= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Alan Stern <stern@rowland.harvard.edu>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH v2 03/11] USB: core: message.c: use usb_control_msg_send() in a few places Date: Mon, 7 Sep 2020 16:51:00 +0200 Message-Id: <20200907145108.3766613-4-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907145108.3766613-1-gregkh@linuxfoundation.org> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.29 / 15.00 / 200.00 X-Rspamd-Queue-Id: 9CFD340994 X-Rspamd-UID: 38cc1e There are a few calls to usb_control_msg() that can be converted to use usb_control_msg_send() instead, so do that in order to make the error checking a bit simpler. Cc: Alan Stern <stern@rowland.harvard.edu> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: linux-usb@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v2: - no change from v1 drivers/usb/core/message.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 6aa49b237717..dfd079485c76 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1081,7 +1081,7 @@ int usb_set_isoch_delay(struct usb_device *dev) if (dev->speed < USB_SPEED_SUPER) return 0; - return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + return usb_control_msg_send(dev, 0, USB_REQ_SET_ISOCH_DELAY, USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, dev->hub_delay, 0, NULL, 0, @@ -1203,13 +1203,13 @@ int usb_clear_halt(struct usb_device *dev, int pipe) * (like some ibmcam model 1 units) seem to expect hosts to make * this request for iso endpoints, which can't halt! */ - result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, - USB_ENDPOINT_HALT, endp, NULL, 0, - USB_CTRL_SET_TIMEOUT); + result = usb_control_msg_send(dev, 0, + USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, + USB_ENDPOINT_HALT, endp, NULL, 0, + USB_CTRL_SET_TIMEOUT); /* don't un-halt or force to DATA0 except on success */ - if (result < 0) + if (result) return result; /* NOTE: seems like Microsoft and Apple don't bother verifying @@ -1558,9 +1558,10 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) if (dev->quirks & USB_QUIRK_NO_SET_INTF) ret = -EPIPE; else - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, - alternate, interface, NULL, 0, 5000); + ret = usb_control_msg_send(dev, 0, + USB_REQ_SET_INTERFACE, + USB_RECIP_INTERFACE, alternate, + interface, NULL, 0, 5000); /* 9.4.10 says devices don't need this and are free to STALL the * request if the interface only has one alternate setting. @@ -1570,7 +1571,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) "manual set_interface for iface %d, alt %d\n", interface, alternate); manual = 1; - } else if (ret < 0) { + } else if (ret) { /* Re-instate the old alt setting */ usb_hcd_alloc_bandwidth(dev, NULL, alt, iface->cur_altsetting); usb_enable_lpm(dev); @@ -1718,11 +1719,10 @@ int usb_reset_configuration(struct usb_device *dev) mutex_unlock(hcd->bandwidth_mutex); return retval; } - retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_CONFIGURATION, 0, - config->desc.bConfigurationValue, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); - if (retval < 0) + retval = usb_control_msg_send(dev, 0, USB_REQ_SET_CONFIGURATION, 0, + config->desc.bConfigurationValue, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); + if (retval) goto reset_old_alts; mutex_unlock(hcd->bandwidth_mutex); @@ -2103,10 +2103,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration) } kfree(new_interfaces); - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_CONFIGURATION, 0, configuration, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); - if (ret < 0 && cp) { + ret = usb_control_msg_send(dev, 0, USB_REQ_SET_CONFIGURATION, 0, + configuration, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); + if (ret && cp) { /* * All the old state is gone, so what else can we do? * The device is probably useless now anyway. -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YM+oBJRSVl8RbwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:32:36 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MEQXAZRSVl9cgQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:32:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 399CF40978; Mon, 7 Sep 2020 17:32:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730195AbgIGPcS (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:32:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:58566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730027AbgIGOvu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:50 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2730E215A4; Mon, 7 Sep 2020 14:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490271; bh=h4qo13MuKIBOL36f408Cp8YPzjpxFs19uVUOnTY6W1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=liinFBkFyHLaJLIeSey9AzpTVwo5tAq0lxmr747pa6hxz84x2NY96OcOTKndkh0XD KV2QLRR7HfaN1g4yS+xd2LBRulccUYEUBCqiwu+w/Y44/YXFkAEBTYnZmdFRXMMOrG ///n3xyMGV/pjWpxQjfL2rYb/dkDjwh1OjQTPC/c= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH v2 02/11] USB: add usb_control_msg_send() and usb_control_msg_recv() Date: Mon, 7 Sep 2020 16:50:59 +0200 Message-Id: <20200907145108.3766613-3-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907145108.3766613-1-gregkh@linuxfoundation.org> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: 399CF40978 X-Rspamd-UID: 3f898a New core functions to make sending/receiving USB control messages easier and saner. In discussions, it turns out that the large majority of users of usb_control_msg() do so in potentially incorrect ways. The most common issue is where a "short" message is received, yet never detected properly due to "incorrect" error handling. Handle all of this in the USB core with two new functions to try to make working with USB control messages simpler. No more need for dynamic data, messages can be on the stack, and only "complete" send/receive will work without causing an error. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v2: - no change from v1 drivers/usb/core/message.c | 133 +++++++++++++++++++++++++++++++++++++ include/linux/usb.h | 6 ++ 2 files changed, 139 insertions(+) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 6197938dcc2d..6aa49b237717 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -162,6 +162,139 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, } EXPORT_SYMBOL_GPL(usb_control_msg); +/** + * usb_control_msg_send - Builds a control "send" message, sends it off and waits for completion + * @dev: pointer to the usb device to send the message to + * @endpoint: endpoint to send the message to + * @request: USB message request value + * @requesttype: USB message request type value + * @value: USB message value + * @index: USB message index value + * @driver_data: pointer to the data to send + * @size: length in bytes of the data to send + * @timeout: time in msecs to wait for the message to complete before timing + * out (if 0 the wait is forever) + * + * Context: !in_interrupt () + * + * This function sends a control message to a specified endpoint that is not + * expected to fill in a response (i.e. a "send message") and waits for the + * message to complete, or timeout. + * + * Do not use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb(). If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. + * + * The data pointer can be made to a reference on the stack, or anywhere else, + * as it will not be modified at all. This does not have the restriction that + * usb_control_msg() has where the data pointer must be to dynamically allocated + * memory (i.e. memory that can be successfully DMAed to a device). + * + * Return: If successful, 0 is returned, Otherwise, a negative error number. + */ +int usb_control_msg_send(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + const void *driver_data, __u16 size, int timeout) +{ + unsigned int pipe = usb_sndctrlpipe(dev, endpoint); + int ret; + u8 *data = NULL; + + if (usb_pipe_type_check(dev, pipe)) + return -EINVAL; + + if (size) { + data = kmemdup(driver_data, size, GFP_KERNEL); + if (!data) + return -ENOMEM; + } + + ret = usb_control_msg(dev, pipe, request, requesttype, value, index, + data, size, timeout); + kfree(data); + + if (ret < 0) + return ret; + if (ret == size) + return 0; + return -EINVAL; +} +EXPORT_SYMBOL_GPL(usb_control_msg_send); + +/** + * usb_control_msg_recv - Builds a control "receive" message, sends it off and waits for completion + * @dev: pointer to the usb device to send the message to + * @endpoint: endpoint to send the message to + * @request: USB message request value + * @requesttype: USB message request type value + * @value: USB message value + * @index: USB message index value + * @driver_data: pointer to the data to be filled in by the message + * @size: length in bytes of the data to be received + * @timeout: time in msecs to wait for the message to complete before timing + * out (if 0 the wait is forever) + * + * Context: !in_interrupt () + * + * This function sends a control message to a specified endpoint that is + * expected to fill in a response (i.e. a "receive message") and waits for the + * message to complete, or timeout. + * + * Do not use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb(). If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. + * + * The data pointer can be made to a reference on the stack, or anywhere else + * that can be successfully written to. This function does not have the + * restriction that usb_control_msg() has where the data pointer must be to + * dynamically allocated memory (i.e. memory that can be successfully DMAed to a + * device). + * + * The "whole" message must be properly received from the device in order for + * this function to be successful. If a device returns less than the expected + * amount of data, then the function will fail. Do not use this for messages + * where a variable amount of data might be returned. + * + * Return: If successful, 0 is returned, Otherwise, a negative error number. + */ +int usb_control_msg_recv(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + void *driver_data, __u16 size, int timeout) +{ + unsigned int pipe = usb_rcvctrlpipe(dev, endpoint); + int ret; + u8 *data; + + if (!size || !driver_data || usb_pipe_type_check(dev, pipe)) + return -EINVAL; + + data = kmalloc(size, GFP_KERNEL); + if (!data) + return -ENOMEM; + + ret = usb_control_msg(dev, pipe, request, requesttype, value, index, + data, size, timeout); + + if (ret < 0) + goto exit; + + if (ret == size) { + memcpy(driver_data, data, size); + ret = 0; + } else { + ret = -EINVAL; + } + +exit: + kfree(data); + return ret; +} +EXPORT_SYMBOL_GPL(usb_control_msg_recv); + /** * usb_interrupt_msg - Builds an interrupt urb, sends it off and waits for completion * @usb_dev: pointer to the usb device to send the message to diff --git a/include/linux/usb.h b/include/linux/usb.h index 0b3963d7ec38..a5460f08126e 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1802,6 +1802,12 @@ extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, int timeout); /* wrappers around usb_control_msg() for the most common standard requests */ +int usb_control_msg_send(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + const void *data, __u16 size, int timeout); +int usb_control_msg_recv(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + void *data, __u16 size, int timeout); extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype, unsigned char descindex, void *buf, int size); extern int usb_get_status(struct usb_device *dev, -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qMnnI6VSVl8RbwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:32:53 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id uCDyIKVSVl+OQAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:32:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 57B8640988; Mon, 7 Sep 2020 17:32:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730144AbgIGPcV (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:32:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:58752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730034AbgIGOvu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:50 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EBA2821941; Mon, 7 Sep 2020 14:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490284; bh=ZsWVCgDo0Rt7GjR+jKLMd25e1+x4CXawRQPMOPI72AQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w+oGDZcJ1AnOFW2GymIMwpD+SMrJcU6Knt41xKMT4+uFM/gD2RHsHdtPuI5c8p63F NNLou5ZlmHty966X5NXZtQUAMk2Z42LPXavnperqdrom0JEW+g2DGjpXWXgzWKN+fo omnbgb3Zf3YXUICszGOMaFFrApnKWAenl2BqMDtk= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Takashi Iwai <tiwai@suse.de> Subject: [PATCH v2 07/11] sound: 6fire: move to use usb_control_msg_send() and usb_control_msg_recv() Date: Mon, 7 Sep 2020 16:51:04 +0200 Message-Id: <20200907145108.3766613-8-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907145108.3766613-1-gregkh@linuxfoundation.org> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: 57B8640988 X-Rspamd-UID: ddde5c The usb_control_msg_send() and usb_control_msg_recv() calls can return an error if a "short" write/read happens, so move the driver over to using those calls instead, saving some logic in the wrapper functions that were being used in this driver. This also resolves a long-staging bug where data on the stack was being sent in a USB control message, which was not allowed. Cc: Jaroslav Kysela <perex@perex.cz> Cc: alsa-devel@alsa-project.org Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v2: - Added reviewed-by from Takashi sound/usb/6fire/firmware.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c index 69137c14d0dc..5b8994070c96 100644 --- a/sound/usb/6fire/firmware.c +++ b/sound/usb/6fire/firmware.c @@ -158,29 +158,17 @@ static int usb6fire_fw_ihex_init(const struct firmware *fw, static int usb6fire_fw_ezusb_write(struct usb_device *device, int type, int value, char *data, int len) { - int ret; - - ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), type, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - value, 0, data, len, HZ); - if (ret < 0) - return ret; - else if (ret != len) - return -EIO; - return 0; + return usb_control_msg_send(device, 0, type, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + value, 0, data, len, HZ); } static int usb6fire_fw_ezusb_read(struct usb_device *device, int type, int value, char *data, int len) { - int ret = usb_control_msg(device, usb_rcvctrlpipe(device, 0), type, - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, - 0, data, len, HZ); - if (ret < 0) - return ret; - else if (ret != len) - return -EIO; - return 0; + return usb_control_msg_recv(device, 0, type, + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + value, 0, data, len, HZ); } static int usb6fire_fw_fpga_write(struct usb_device *device, @@ -230,7 +218,7 @@ static int usb6fire_fw_ezusb_upload( /* upload firmware image */ data = 0x01; /* stop ezusb cpu */ ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1); - if (ret < 0) { + if (ret) { kfree(rec); release_firmware(fw); dev_err(&intf->dev, @@ -242,7 +230,7 @@ static int usb6fire_fw_ezusb_upload( while (usb6fire_fw_ihex_next_record(rec)) { /* write firmware */ ret = usb6fire_fw_ezusb_write(device, 0xa0, rec->address, rec->data, rec->len); - if (ret < 0) { + if (ret) { kfree(rec); release_firmware(fw); dev_err(&intf->dev, @@ -257,7 +245,7 @@ static int usb6fire_fw_ezusb_upload( if (postdata) { /* write data after firmware has been uploaded */ ret = usb6fire_fw_ezusb_write(device, 0xa0, postaddr, postdata, postlen); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to upload ezusb firmware %s: post urb.\n", fwname); @@ -267,7 +255,7 @@ static int usb6fire_fw_ezusb_upload( data = 0x00; /* resume ezusb cpu */ ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to upload ezusb firmware %s: end message.\n", fwname); @@ -302,7 +290,7 @@ static int usb6fire_fw_fpga_upload( end = fw->data + fw->size; ret = usb6fire_fw_ezusb_write(device, 8, 0, NULL, 0); - if (ret < 0) { + if (ret) { kfree(buffer); release_firmware(fw); dev_err(&intf->dev, @@ -327,7 +315,7 @@ static int usb6fire_fw_fpga_upload( kfree(buffer); ret = usb6fire_fw_ezusb_write(device, 9, 0, NULL, 0); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to upload fpga firmware: end urb.\n"); return ret; @@ -363,7 +351,7 @@ int usb6fire_fw_init(struct usb_interface *intf) u8 buffer[12]; ret = usb6fire_fw_ezusb_read(device, 1, 0, buffer, 8); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to receive device firmware state.\n"); return ret; -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MKHZJ/BWVl8MVwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:51:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aNtHJPBWVl/+5QEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:51:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2BF97A016D; Mon, 7 Sep 2020 17:51:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730132AbgIGPcD (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:32:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:58924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730036AbgIGOvv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:51 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 449E121974; Mon, 7 Sep 2020 14:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490287; bh=mnt6coJiWDnqqDNAc4NKmK+R7FoiAibhMjPeDUbyw1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHvLB47FyktBthiQZu4LrMKJQE5p5A9dpYZY6oULtRHbaRsiu97NbusIILlhR7OFl MmnLnAHBEkndsXjceyu2IjYNwZ3QrVy7AgFK4pljcTpGXWZ8mpGiLhPUlDjBn3eU12 AXpWPC9QAPDepI6B2xbWwxgl1x8ZnJ4uACNejo/M= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Vasily Khoruzhick <anarsoul@gmail.com>, Takashi Iwai <tiwai@suse.de> Subject: [PATCH v2 08/11] sound: line6: move to use usb_control_msg_send() and usb_control_msg_recv() Date: Mon, 7 Sep 2020 16:51:05 +0200 Message-Id: <20200907145108.3766613-9-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907145108.3766613-1-gregkh@linuxfoundation.org> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.10 / 15.00 / 200.00 X-Rspamd-Queue-Id: 2BF97A016D X-Rspamd-UID: 1b45a5 The usb_control_msg_send() and usb_control_msg_recv() calls can return an error if a "short" write/read happens, and they can handle data off of the stack, so move the driver over to using those calls instead, saving some logic when dynamically allocating memory. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Vasily Khoruzhick <anarsoul@gmail.com> Cc: alsa-devel@alsa-project.org Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v2: - Added reviewed-by from Takashi sound/usb/line6/driver.c | 69 +++++++++++++++----------------------- sound/usb/line6/podhd.c | 17 ++++------ sound/usb/line6/toneport.c | 8 ++--- 3 files changed, 37 insertions(+), 57 deletions(-) diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 60674ce4879b..601292c51491 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -337,23 +337,18 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, { struct usb_device *usbdev = line6->usbdev; int ret; - unsigned char *len; + u8 len; unsigned count; if (address > 0xffff || datalen > 0xff) return -EINVAL; - len = kmalloc(1, GFP_KERNEL); - if (!len) - return -ENOMEM; - /* query the serial number: */ - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - (datalen << 8) | 0x21, address, - NULL, 0, LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + (datalen << 8) | 0x21, address, NULL, 0, + LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "read request failed (error %d)\n", ret); goto exit; } @@ -362,45 +357,41 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { mdelay(LINE6_READ_WRITE_STATUS_DELAY); - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | - USB_DIR_IN, - 0x0012, 0x0000, len, 1, - LINE6_TIMEOUT * HZ); - if (ret < 0) { + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0012, 0x0000, &len, 1, + LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "receive length failed (error %d)\n", ret); goto exit; } - if (*len != 0xff) + if (len != 0xff) break; } ret = -EIO; - if (*len == 0xff) { + if (len == 0xff) { dev_err(line6->ifcdev, "read failed after %d retries\n", count); goto exit; - } else if (*len != datalen) { + } else if (len != datalen) { /* should be equal or something went wrong */ dev_err(line6->ifcdev, "length mismatch (expected %d, got %d)\n", - (int)datalen, (int)*len); + (int)datalen, len); goto exit; } /* receive the result: */ - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, - 0x0013, 0x0000, data, datalen, - LINE6_TIMEOUT * HZ); - - if (ret < 0) + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0013, 0x0000, data, datalen, LINE6_TIMEOUT * HZ); + if (ret) dev_err(line6->ifcdev, "read failed (error %d)\n", ret); exit: - kfree(len); return ret; } EXPORT_SYMBOL_GPL(line6_read_data); @@ -423,12 +414,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, if (!status) return -ENOMEM; - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - 0x0022, address, data, datalen, - LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + 0x0022, address, data, datalen, LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "write request failed (error %d)\n", ret); goto exit; @@ -437,14 +426,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { mdelay(LINE6_READ_WRITE_STATUS_DELAY); - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), - 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | - USB_DIR_IN, - 0x0012, 0x0000, - status, 1, LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0012, 0x0000, status, 1, LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "receiving status failed (error %d)\n", ret); goto exit; diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index eef45f7fef0d..a1261f55d62b 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -183,29 +183,25 @@ static const struct attribute_group podhd_dev_attr_group = { static int podhd_dev_start(struct usb_line6_podhd *pod) { int ret; - u8 *init_bytes; + u8 init_bytes[8]; int i; struct usb_device *usbdev = pod->line6.usbdev; - init_bytes = kmalloc(8, GFP_KERNEL); - if (!init_bytes) - return -ENOMEM; - - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), + ret = usb_control_msg_send(usbdev, 0, 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 0x11, 0, NULL, 0, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(pod->line6.ifcdev, "read request failed (error %d)\n", ret); goto exit; } /* NOTE: looks like some kind of ping message */ - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, + ret = usb_control_msg_recv(usbdev, 0, 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 0x11, 0x0, init_bytes, 3, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(pod->line6.ifcdev, "receive length failed (error %d)\n", ret); goto exit; @@ -220,13 +216,12 @@ static int podhd_dev_start(struct usb_line6_podhd *pod) goto exit; } - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), + ret = usb_control_msg_send(usbdev, 0, USB_REQ_SET_FEATURE, USB_TYPE_STANDARD | USB_RECIP_DEVICE | USB_DIR_OUT, 1, 0, NULL, 0, LINE6_TIMEOUT * HZ); exit: - kfree(init_bytes); return ret; } diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 94dd5e7ab2e6..a9b56085b76a 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -126,11 +126,11 @@ static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2) { int ret; - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(&usbdev->dev, "send failed (error %d)\n", ret); return ret; } -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IBK7ISNXVl+FrgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:52:03 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 6ENfHyNXVl8QfgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:52:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 15383A01F5; Mon, 7 Sep 2020 17:51:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730214AbgIGPvg (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:51:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:58642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730029AbgIGOvu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:50 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 515BD218AC; Mon, 7 Sep 2020 14:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490277; bh=hkO0EMVvCu8X7CeNAbfTmSK1pWFJrTzl3nDdebnZHHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zgTDrp7IPbcWgWNaaD690SP+mq2VsJpUKvsnVgZIc8ntfUU/bjkTDvxpZQEo2M/mE Ob9YzTDMdNI3mym+y907RGeutk8dZShkABagM/ShmcOwO7IjuexA1gpjfz7EgIxyg+ /HsNxeWuxRRH0vGn2j8mY0AVJDBQXDeiW44Ad6zw= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Alan Stern <stern@rowland.harvard.edu> Subject: [PATCH v2 04/11] USB: core: hub.c: use usb_control_msg_send() in a few places Date: Mon, 7 Sep 2020 16:51:01 +0200 Message-Id: <20200907145108.3766613-5-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907145108.3766613-1-gregkh@linuxfoundation.org> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.83 / 15.00 / 200.00 X-Rspamd-Queue-Id: 15383A01F5 X-Rspamd-UID: d056c3 There are a few calls to usb_control_msg() that can be converted to use usb_control_msg_send() instead, so do that in order to make the error checking a bit simpler and the code smaller. Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v2: - dropped changes to usb_req_set_sel() thanks to review from Alan drivers/usb/core/hub.c | 99 +++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 60 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 5b768b80d1ee..bbb41993d4ba 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -410,8 +410,8 @@ static int get_hub_descriptor(struct usb_device *hdev, */ static int clear_hub_feature(struct usb_device *hdev, int feature) { - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - USB_REQ_CLEAR_FEATURE, USB_RT_HUB, feature, 0, NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, USB_REQ_CLEAR_FEATURE, USB_RT_HUB, + feature, 0, NULL, 0, 1000); } /* @@ -419,9 +419,8 @@ static int clear_hub_feature(struct usb_device *hdev, int feature) */ int usb_clear_port_feature(struct usb_device *hdev, int port1, int feature) { - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - USB_REQ_CLEAR_FEATURE, USB_RT_PORT, feature, port1, - NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, USB_REQ_CLEAR_FEATURE, USB_RT_PORT, + feature, port1, NULL, 0, 1000); } /* @@ -429,9 +428,8 @@ int usb_clear_port_feature(struct usb_device *hdev, int port1, int feature) */ static int set_port_feature(struct usb_device *hdev, int port1, int feature) { - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port1, - NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, USB_REQ_SET_FEATURE, USB_RT_PORT, + feature, port1, NULL, 0, 1000); } static char *to_led_name(int selector) @@ -755,15 +753,14 @@ hub_clear_tt_buffer(struct usb_device *hdev, u16 devinfo, u16 tt) /* Need to clear both directions for control ep */ if (((devinfo >> 11) & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_CONTROL) { - int status = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - HUB_CLEAR_TT_BUFFER, USB_RT_PORT, - devinfo ^ 0x8000, tt, NULL, 0, 1000); + int status = usb_control_msg_send(hdev, 0, + HUB_CLEAR_TT_BUFFER, USB_RT_PORT, + devinfo ^ 0x8000, tt, NULL, 0, 1000); if (status) return status; } - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo, - tt, NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, HUB_CLEAR_TT_BUFFER, USB_RT_PORT, + devinfo, tt, NULL, 0, 1000); } /* @@ -1049,11 +1046,10 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) */ if (type != HUB_RESUME) { if (hdev->parent && hub_is_superspeed(hdev)) { - ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - HUB_SET_DEPTH, USB_RT_HUB, - hdev->level - 1, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - if (ret < 0) + ret = usb_control_msg_send(hdev, 0, HUB_SET_DEPTH, USB_RT_HUB, + hdev->level - 1, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); + if (ret) dev_err(hub->intfdev, "set hub depth failed\n"); } @@ -2329,13 +2325,10 @@ static int usb_enumerate_device_otg(struct usb_device *udev) /* enable HNP before suspend, it's simpler */ if (port1 == bus->otg_port) { bus->b_hnp_enable = 1; - err = usb_control_msg(udev, - usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, 0, - USB_DEVICE_B_HNP_ENABLE, - 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - if (err < 0) { + err = usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, 0, + USB_DEVICE_B_HNP_ENABLE, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); + if (err) { /* * OTG MESSAGE: report errors here, * customize to match your product. @@ -2347,13 +2340,10 @@ static int usb_enumerate_device_otg(struct usb_device *udev) } else if (desc->bLength == sizeof (struct usb_otg_descriptor)) { /* Set a_alt_hnp_support for legacy otg device */ - err = usb_control_msg(udev, - usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, 0, - USB_DEVICE_A_ALT_HNP_SUPPORT, - 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - if (err < 0) + err = usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, 0, + USB_DEVICE_A_ALT_HNP_SUPPORT, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); + if (err) dev_err(&udev->dev, "set a_alt_hnp_support failed: %d\n", err); @@ -3121,10 +3111,8 @@ int usb_disable_ltm(struct usb_device *udev) if (!udev->actconfig) return 0; - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_LTM_ENABLE, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_LTM_ENABLE, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } EXPORT_SYMBOL_GPL(usb_disable_ltm); @@ -3143,10 +3131,8 @@ void usb_enable_ltm(struct usb_device *udev) if (!udev->actconfig) return; - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_LTM_ENABLE, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_LTM_ENABLE, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } EXPORT_SYMBOL_GPL(usb_enable_ltm); @@ -3163,17 +3149,14 @@ EXPORT_SYMBOL_GPL(usb_enable_ltm); static int usb_enable_remote_wakeup(struct usb_device *udev) { if (udev->speed < USB_SPEED_SUPER) - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_REMOTE_WAKEUP, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); else - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, - USB_INTRF_FUNC_SUSPEND, - USB_INTRF_FUNC_SUSPEND_RW | - USB_INTRF_FUNC_SUSPEND_LP, - NULL, 0, USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, + USB_INTRF_FUNC_SUSPEND, + USB_INTRF_FUNC_SUSPEND_RW | USB_INTRF_FUNC_SUSPEND_LP, + NULL, 0, USB_CTRL_SET_TIMEOUT); } /* @@ -3189,15 +3172,11 @@ static int usb_enable_remote_wakeup(struct usb_device *udev) static int usb_disable_remote_wakeup(struct usb_device *udev) { if (udev->speed < USB_SPEED_SUPER) - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); else - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, - USB_INTRF_FUNC_SUSPEND, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, + USB_INTRF_FUNC_SUSPEND, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } /* Count of wakeup-enabled devices at or below udev */ @@ -4056,7 +4035,7 @@ static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev, * associated with the link state we're about to enable. */ ret = usb_req_set_sel(udev, state); - if (ret < 0) { + if (ret) { dev_warn(&udev->dev, "Set SEL for device-initiated %s failed.\n", usb3_lpm_names[state]); return; -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SLbGJj5XVl/+vgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:52:30 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MIpjIz5XVl/4BQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:52:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 72BBA4086A; Mon, 7 Sep 2020 17:52:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730241AbgIGPv4 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:51:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:58724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730032AbgIGOvt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:49 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7EC682192A; Mon, 7 Sep 2020 14:51:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490282; bh=lDALoKxKeoNU19umSgu7/gECsPlcvRr4daWW6F49vJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jWeyiTf6p56aKUhjCPl9Aae18HDw0lXVJW1WmGB1/g9ybbeBolPaPWADBQvjKvAoR isUT+CSMu3H9HSDKP45X2Ohg0KKGEIJhojaI1F0j2mWUwnSmAtipNeYiQ2UyvPkxZi FnUesZluOgIluJoQR39SP7/bIdRAzxmeykRfRZVY= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Takashi Iwai <tiwai@suse.de> Subject: [PATCH v2 06/11] sound: usx2y: move to use usb_control_msg_send() Date: Mon, 7 Sep 2020 16:51:03 +0200 Message-Id: <20200907145108.3766613-7-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907145108.3766613-1-gregkh@linuxfoundation.org> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.15 / 15.00 / 200.00 X-Rspamd-Queue-Id: 72BBA4086A X-Rspamd-UID: de83b0 The usb_control_msg_send() call can handle data on the stack, as well as returning an error if a "short" write happens, so move the driver over to using that call instead. This ends up removing a helper function that is no longer needed. Cc: Jaroslav Kysela <perex@perex.cz> Cc: alsa-devel@alsa-project.org Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v2: - Added reviewed-by from Takashi sound/usb/usx2y/us122l.c | 42 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index f86f7a61fb36..e5c5a0d03d8a 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -82,40 +82,13 @@ static int us144_create_usbmidi(struct snd_card *card) &US122L(card)->midi_list, &quirk); } -/* - * Wrapper for usb_control_msg(). - * Allocates a temp buffer to prevent dmaing from/to the stack. - */ -static int us122l_ctl_msg(struct usb_device *dev, unsigned int pipe, - __u8 request, __u8 requesttype, - __u16 value, __u16 index, void *data, - __u16 size, int timeout) -{ - int err; - void *buf = NULL; - - if (size > 0) { - buf = kmemdup(data, size, GFP_KERNEL); - if (!buf) - return -ENOMEM; - } - err = usb_control_msg(dev, pipe, request, requesttype, - value, index, buf, size, timeout); - if (size > 0) { - memcpy(data, buf, size); - kfree(buf); - } - return err; -} - static void pt_info_set(struct usb_device *dev, u8 v) { int ret; - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - 'I', - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - v, 0, NULL, 0, 1000); + ret = usb_control_msg_send(dev, 0, 'I', + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + v, 0, NULL, 0, 1000); snd_printdd(KERN_DEBUG "%i\n", ret); } @@ -305,10 +278,11 @@ static int us122l_set_sample_rate(struct usb_device *dev, int rate) data[0] = rate; data[1] = rate >> 8; data[2] = rate >> 16; - err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, - USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, - UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000); - if (err < 0) + err = usb_control_msg_send(dev, 0, UAC_SET_CUR, + USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, + UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, + 1000); + if (err) snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n", dev->devnum, rate, ep); return err; -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eCdENVdXVl82xQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:52:55 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gEadMldXVl/u6AEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:52:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 651FA4096B; Mon, 7 Sep 2020 17:52:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730278AbgIGPwi (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:52:38 -0400 Received: from mga17.intel.com ([192.55.52.151]:25785 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730221AbgIGPwe (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 11:52:34 -0400 IronPort-SDR: XLendpVzhN8Mt4KG5/sHo+UV+ChOat8WTxaIMm+uZ3LxioFTEqDPeohrIl6Z6l32MRP34fxeXL QiKrR/wwhlxA== X-IronPort-AV: E=McAfee;i="6000,8403,9737"; a="138066938" X-IronPort-AV: E=Sophos;i="5.76,402,1592895600"; d="scan'208";a="138066938" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 08:52:29 -0700 IronPort-SDR: OKawkKFMoTnSGMbguXThLtl8NtjcwhxLsewqqLKPYgFmHyfSdylAm5yyICdAjMpdfR2/DEblnQ njoVBfvoFnZg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,402,1592895600"; d="scan'208";a="333197015" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga008.jf.intel.com with ESMTP; 07 Sep 2020 08:52:26 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from <andriy.shevchenko@linux.intel.com>) id 1kFJNC-00EzvH-KL; Mon, 07 Sep 2020 18:48:02 +0300 Date: Mon, 7 Sep 2020 18:48:02 +0300 From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Alan Stern <stern@rowland.harvard.edu>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Subject: Re: [PATCH v2 03/11] USB: core: message.c: use usb_control_msg_send() in a few places Message-ID: <20200907154802.GO1891694@smile.fi.intel.com> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> <20200907145108.3766613-4-gregkh@linuxfoundation.org> <20200907145644.GA3767938@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200907145644.GA3767938@kroah.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.48 / 15.00 / 200.00 X-Rspamd-Queue-Id: 651FA4096B X-Rspamd-UID: 4da365 On Mon, Sep 07, 2020 at 04:56:44PM +0200, Greg Kroah-Hartman wrote: > On Mon, Sep 07, 2020 at 04:51:00PM +0200, Greg Kroah-Hartman wrote: > > There are a few calls to usb_control_msg() that can be converted to use > > usb_control_msg_send() instead, so do that in order to make the error > > checking a bit simpler. > > > > Cc: Alan Stern <stern@rowland.harvard.edu> > > Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> > > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > Cc: linux-usb@vger.kernel.org > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > Oops, Andy, sorry, you gave me a Reviewed-by: Andy Shevchenko > <andriy.shevchenko@linux.intel.com> on the previous version of this, > I'll add it next round, or when it's queued up. NP! Whatever works better for you. -- With Best Regards, Andy Shevchenko Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yJZlHYFXVl+FrgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:53:37 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 8F6bGoFXVl+VcQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:53:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 12FAFA0B0B; Mon, 7 Sep 2020 17:53:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730235AbgIGPxV (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:53:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:58522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729974AbgIGOvK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:10 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8AEA12177B; Mon, 7 Sep 2020 14:51:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490269; bh=MDm/x39065SOo01K6qZuV7PZJI+UXbxgaHzoKWMO8tc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tNZrtEWO45CRF+E/OrbMnOHpLv6PCX/TNkRXj1BARuZF1Ju9YXW3C/eh95H133hvx TZEBI66qkmXv8rHm5cCT1r2WvSZ70JTVlrj+0rsnHajlpnOJ5/cd2KH0SbUel4og6U cfnz8gsno2H98HW+mHktnzmjDSF9q4uQwOFl+ISo= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Alexander Tsoy <alexander@tsoy.me>, Alan Stern <stern@rowland.harvard.edu> Subject: [PATCH v2 11/11] ALSA: remove calls to usb_pipe_type_check for control endpoints Date: Mon, 7 Sep 2020 16:51:08 +0200 Message-Id: <20200907145108.3766613-12-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907145108.3766613-1-gregkh@linuxfoundation.org> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.33 / 15.00 / 200.00 X-Rspamd-Queue-Id: 12FAFA0B0B X-Rspamd-UID: 813dd2 A USB device will always haev a bi-directional endpoint 0, that's just how the devices work, so no need to check for that in a few quirk tests as it will always pass. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: Alexander Tsoy <alexander@tsoy.me> Cc: alsa-devel@alsa-project.org Reported-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v2: - new patch, was not in v1 series, suggested by Alan. sound/usb/quirks.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index fc3aab04a0bc..35da4aa918c7 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -875,8 +875,6 @@ static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev) { int ret; - if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) - return -EINVAL; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1, 0, NULL, 0, 1000); @@ -984,8 +982,6 @@ static int snd_usb_axefx3_boot_quirk(struct usb_device *dev) dev_dbg(&dev->dev, "Waiting for Axe-Fx III to boot up...\n"); - if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) - return -EINVAL; /* If the Axe-Fx III has not fully booted, it will timeout when trying * to enable the audio streaming interface. A more generous timeout is * used here to detect when the Axe-Fx III has finished booting as the @@ -1117,8 +1113,6 @@ static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) { int ret; - if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) - return -EINVAL; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0x0, 0, NULL, 0, 1000); -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qKzLJZtXVl8vxQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:54:03 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id SD74IZtXVl/u6AEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:54:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DABE7A0195; Mon, 7 Sep 2020 17:53:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730227AbgIGPxP (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:53:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:58686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730015AbgIGOvt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:49 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02F9621924; Mon, 7 Sep 2020 14:51:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490279; bh=bOtNvPKd1buomuDeBpZzqGRO3R6GMfbAEg8/sDVnLbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1MHmCQfOr4X3wWjX6IQ3rwja05HHJTOw+UvuGXj0aN6axRPVil/jBk5r/UJEAR4aO Ssbim/0ObmcFTIK+FT6ffbI0q1Xr0aQYGv6PpRiWAJcwz7wCDbppmvBgjycqVqWR4J V5iFfXj0xM9h7kuUXf4PoM2CFpwjAufNO9gR0z9k= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Juergen Stuber <starblue@users.sourceforge.net>, legousb-devel@lists.sourceforge.net Subject: [PATCH v2 05/11] USB: legousbtower: use usb_control_msg_recv() Date: Mon, 7 Sep 2020 16:51:02 +0200 Message-Id: <20200907145108.3766613-6-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907145108.3766613-1-gregkh@linuxfoundation.org> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.34 / 15.00 / 200.00 X-Rspamd-Queue-Id: DABE7A0195 X-Rspamd-UID: d39ab5 The usb_control_msg_recv() function can handle data on the stack, as well as properly detecting short reads, so move to use that function instead of the older usb_control_msg() call. This ends up removing a lot of extra lines in the driver. Cc: Juergen Stuber <starblue@users.sourceforge.net> Cc: legousb-devel@lists.sourceforge.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v2: - no change from v1 drivers/usb/misc/legousbtower.c | 60 +++++++++++---------------------- 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index f922544056de..c3583df4c324 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -308,15 +308,9 @@ static int tower_open(struct inode *inode, struct file *file) int subminor; int retval = 0; struct usb_interface *interface; - struct tower_reset_reply *reset_reply; + struct tower_reset_reply reset_reply; int result; - reset_reply = kmalloc(sizeof(*reset_reply), GFP_KERNEL); - if (!reset_reply) { - retval = -ENOMEM; - goto exit; - } - nonseekable_open(inode, file); subminor = iminor(inode); @@ -347,15 +341,11 @@ static int tower_open(struct inode *inode, struct file *file) } /* reset the tower */ - result = usb_control_msg(dev->udev, - usb_rcvctrlpipe(dev->udev, 0), - LEGO_USB_TOWER_REQUEST_RESET, - USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, - 0, - 0, - reset_reply, - sizeof(*reset_reply), - 1000); + result = usb_control_msg_recv(dev->udev, 0, + LEGO_USB_TOWER_REQUEST_RESET, + USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, + 0, 0, + &reset_reply, sizeof(reset_reply), 1000); if (result < 0) { dev_err(&dev->udev->dev, "LEGO USB Tower reset control request failed\n"); @@ -394,7 +384,6 @@ static int tower_open(struct inode *inode, struct file *file) mutex_unlock(&dev->lock); exit: - kfree(reset_reply); return retval; } @@ -753,7 +742,7 @@ static int tower_probe(struct usb_interface *interface, const struct usb_device_ struct device *idev = &interface->dev; struct usb_device *udev = interface_to_usbdev(interface); struct lego_usb_tower *dev; - struct tower_get_version_reply *get_version_reply = NULL; + struct tower_get_version_reply get_version_reply; int retval = -ENOMEM; int result; @@ -798,34 +787,25 @@ static int tower_probe(struct usb_interface *interface, const struct usb_device_ dev->interrupt_in_interval = interrupt_in_interval ? interrupt_in_interval : dev->interrupt_in_endpoint->bInterval; dev->interrupt_out_interval = interrupt_out_interval ? interrupt_out_interval : dev->interrupt_out_endpoint->bInterval; - get_version_reply = kmalloc(sizeof(*get_version_reply), GFP_KERNEL); - if (!get_version_reply) { - retval = -ENOMEM; - goto error; - } - /* get the firmware version and log it */ - result = usb_control_msg(udev, - usb_rcvctrlpipe(udev, 0), - LEGO_USB_TOWER_REQUEST_GET_VERSION, - USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, - 0, - 0, - get_version_reply, - sizeof(*get_version_reply), - 1000); - if (result != sizeof(*get_version_reply)) { - if (result >= 0) - result = -EIO; + result = usb_control_msg_recv(udev, 0, + LEGO_USB_TOWER_REQUEST_GET_VERSION, + USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, + 0, + 0, + &get_version_reply, + sizeof(get_version_reply), + 1000); + if (!result) { dev_err(idev, "get version request failed: %d\n", result); retval = result; goto error; } dev_info(&interface->dev, "LEGO USB Tower firmware version is %d.%d build %d\n", - get_version_reply->major, - get_version_reply->minor, - le16_to_cpu(get_version_reply->build_no)); + get_version_reply.major, + get_version_reply.minor, + le16_to_cpu(get_version_reply.build_no)); /* we can register the device now, as it is ready */ usb_set_intfdata(interface, dev); @@ -844,11 +824,9 @@ static int tower_probe(struct usb_interface *interface, const struct usb_device_ USB_MAJOR, dev->minor); exit: - kfree(get_version_reply); return retval; error: - kfree(get_version_reply); tower_delete(dev); return retval; } -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QM5FAa5XVl/+vgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:54:22 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2E6LOa1XVl+BuQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:54:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 84F27A01EA; Mon, 7 Sep 2020 17:54:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730223AbgIGPyH (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:54:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:58486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730022AbgIGOvH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:51:07 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC57B21481; Mon, 7 Sep 2020 14:51:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599490266; bh=lAWlK3q7dlSU3BX9UUth7FV/aMVc82HxwZZSp4H5Db4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lkNxOAr6D47I4QX0kM9cVJLJb6KQjj/GJaUaWXjiH8FhsjbURGG+G+VMs34hNWDq2 CKXS0cBXxyyACxxrXpfI+2fbjTCrWSUOVFlgdW+5vPPtYUCy46eL1TIb4/MsqjF0Z+ cMaBbQnw64NbDt9pqzu5Jd5KjbG+heuNRbK61JDA= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH v2 10/11] Bluetooth: ath3k: use usb_control_msg_send() and usb_control_msg_recv() Date: Mon, 7 Sep 2020 16:51:07 +0200 Message-Id: <20200907145108.3766613-11-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907145108.3766613-1-gregkh@linuxfoundation.org> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: 84F27A01EA X-Rspamd-UID: 520b95 The usb_control_msg_send() and usb_control_msg_recv() calls can return an error if a "short" write/read happens, and they can handle data off of the stack, so move the driver over to using those calls instead, saving some logic when dynamically allocating memory. Cc: Marcel Holtmann <marcel@holtmann.org> Cc: Johan Hedberg <johan.hedberg@gmail.com> Cc: linux-bluetooth@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v2: - no change from v1 drivers/bluetooth/ath3k.c | 90 +++++++++++---------------------------- 1 file changed, 26 insertions(+), 64 deletions(-) diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index 4ce270513695..1472cccfd0b3 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c @@ -212,19 +212,16 @@ static int ath3k_load_firmware(struct usb_device *udev, BT_DBG("udev %p", udev); - pipe = usb_sndctrlpipe(udev, 0); - send_buf = kmalloc(BULK_SIZE, GFP_KERNEL); if (!send_buf) { BT_ERR("Can't allocate memory chunk for firmware"); return -ENOMEM; } - memcpy(send_buf, firmware->data, FW_HDR_SIZE); - err = usb_control_msg(udev, pipe, USB_REQ_DFU_DNLOAD, USB_TYPE_VENDOR, - 0, 0, send_buf, FW_HDR_SIZE, - USB_CTRL_SET_TIMEOUT); - if (err < 0) { + err = usb_control_msg_send(udev, 0, USB_REQ_DFU_DNLOAD, USB_TYPE_VENDOR, + 0, 0, firmware->data, FW_HDR_SIZE, + USB_CTRL_SET_TIMEOUT); + if (err) { BT_ERR("Can't change to loading configuration err"); goto error; } @@ -259,44 +256,17 @@ static int ath3k_load_firmware(struct usb_device *udev, static int ath3k_get_state(struct usb_device *udev, unsigned char *state) { - int ret, pipe = 0; - char *buf; - - buf = kmalloc(sizeof(*buf), GFP_KERNEL); - if (!buf) - return -ENOMEM; - - pipe = usb_rcvctrlpipe(udev, 0); - ret = usb_control_msg(udev, pipe, ATH3K_GETSTATE, - USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, - buf, sizeof(*buf), USB_CTRL_SET_TIMEOUT); - - *state = *buf; - kfree(buf); - - return ret; + return usb_control_msg_recv(udev, 0, ATH3K_GETSTATE, + USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, + state, 1, USB_CTRL_SET_TIMEOUT); } static int ath3k_get_version(struct usb_device *udev, struct ath3k_version *version) { - int ret, pipe = 0; - struct ath3k_version *buf; - const int size = sizeof(*buf); - - buf = kmalloc(size, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - pipe = usb_rcvctrlpipe(udev, 0); - ret = usb_control_msg(udev, pipe, ATH3K_GETVERSION, - USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, - buf, size, USB_CTRL_SET_TIMEOUT); - - memcpy(version, buf, size); - kfree(buf); - - return ret; + return usb_control_msg_recv(udev, 0, ATH3K_GETVERSION, + USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, + version, sizeof(*version), USB_CTRL_SET_TIMEOUT); } static int ath3k_load_fwfile(struct usb_device *udev, @@ -316,13 +286,10 @@ static int ath3k_load_fwfile(struct usb_device *udev, } size = min_t(uint, count, FW_HDR_SIZE); - memcpy(send_buf, firmware->data, size); - pipe = usb_sndctrlpipe(udev, 0); - ret = usb_control_msg(udev, pipe, ATH3K_DNLOAD, - USB_TYPE_VENDOR, 0, 0, send_buf, - size, USB_CTRL_SET_TIMEOUT); - if (ret < 0) { + ret = usb_control_msg_send(udev, 0, ATH3K_DNLOAD, USB_TYPE_VENDOR, 0, 0, + firmware->data, size, USB_CTRL_SET_TIMEOUT); + if (ret) { BT_ERR("Can't change to loading configuration err"); kfree(send_buf); return ret; @@ -355,23 +322,19 @@ static int ath3k_load_fwfile(struct usb_device *udev, return 0; } -static int ath3k_switch_pid(struct usb_device *udev) +static void ath3k_switch_pid(struct usb_device *udev) { - int pipe = 0; - - pipe = usb_sndctrlpipe(udev, 0); - return usb_control_msg(udev, pipe, USB_REG_SWITCH_VID_PID, - USB_TYPE_VENDOR, 0, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); + usb_control_msg_send(udev, 0, USB_REG_SWITCH_VID_PID, USB_TYPE_VENDOR, + 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } static int ath3k_set_normal_mode(struct usb_device *udev) { unsigned char fw_state; - int pipe = 0, ret; + int ret; ret = ath3k_get_state(udev, &fw_state); - if (ret < 0) { + if (ret) { BT_ERR("Can't get state to change to normal mode err"); return ret; } @@ -381,10 +344,9 @@ static int ath3k_set_normal_mode(struct usb_device *udev) return 0; } - pipe = usb_sndctrlpipe(udev, 0); - return usb_control_msg(udev, pipe, ATH3K_SET_NORMAL_MODE, - USB_TYPE_VENDOR, 0, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, ATH3K_SET_NORMAL_MODE, + USB_TYPE_VENDOR, 0, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); } static int ath3k_load_patch(struct usb_device *udev) @@ -397,7 +359,7 @@ static int ath3k_load_patch(struct usb_device *udev) int ret; ret = ath3k_get_state(udev, &fw_state); - if (ret < 0) { + if (ret) { BT_ERR("Can't get state to change to load ram patch err"); return ret; } @@ -408,7 +370,7 @@ static int ath3k_load_patch(struct usb_device *udev) } ret = ath3k_get_version(udev, &fw_version); - if (ret < 0) { + if (ret) { BT_ERR("Can't get version to change to load ram patch err"); return ret; } @@ -449,13 +411,13 @@ static int ath3k_load_syscfg(struct usb_device *udev) int clk_value, ret; ret = ath3k_get_state(udev, &fw_state); - if (ret < 0) { + if (ret) { BT_ERR("Can't get state to change to load configuration err"); return -EBUSY; } ret = ath3k_get_version(udev, &fw_version); - if (ret < 0) { + if (ret) { BT_ERR("Can't get version to change to load ram patch err"); return ret; } @@ -529,7 +491,7 @@ static int ath3k_probe(struct usb_interface *intf, return ret; } ret = ath3k_set_normal_mode(udev); - if (ret < 0) { + if (ret) { BT_ERR("Set normal mode failed"); return ret; } -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oGxwCrJYVl/+vgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 17:58:42 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id uGnqB7JYVl/jDwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 17:58:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 24FA94096A; Mon, 7 Sep 2020 17:58:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730247AbgIGP6A (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 11:58:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:58230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730010AbgIGOua (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:50:30 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02CC821481; Mon, 7 Sep 2020 14:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599489714; bh=vyE2X1zQKzP1YNOY504/+A2IyiOqZJITaebb9PZflls=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c6hSYHs20N7asJxie1tfww4JQBkA2E6D0wkvqfpBxR6REkJBlWNdSnD0BGokzdT4l 8FQxIwgIf1zsTzXYN8FnnKoBqJnlW6WjlPKXiD9ZcSdMdk6dD4ajO6FaxA1iJCtkaB l0gAZvE0zqwF3JbPujEb6oKOdpp5kkpqGisnALyw= Date: Mon, 7 Sep 2020 16:42:09 +0200 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: Takashi Iwai <tiwai@suse.de> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Eli Billauer <eli.billauer@gmail.com>, Emiliano Ingrassia <ingrassia@epigenesys.com>, Alan Stern <stern@rowland.harvard.edu>, Alexander Tsoy <alexander@tsoy.me>, "Geoffrey D. Bennett" <g@b4.vu>, Jussi Laako <jussi@sonarnerd.net>, Nick Kossifidis <mickflemm@gmail.com>, Dmitry Panchenko <dmitry@d-systems.ee>, Chris Wulff <crwulff@gmail.com>, Jesus Ramos <jesus-ramos@live.com> Subject: Re: [PATCH 01/10] USB: move snd_usb_pipe_sanity_check into the USB core Message-ID: <20200907144209.GA3751762@kroah.com> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-2-gregkh@linuxfoundation.org> <s5hh7sg9rgq.wl-tiwai@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <s5hh7sg9rgq.wl-tiwai@suse.de> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.10 / 15.00 / 200.00 X-Rspamd-Queue-Id: 24FA94096A X-Rspamd-UID: 1353b5 On Wed, Sep 02, 2020 at 04:35:33PM +0200, Takashi Iwai wrote: > On Wed, 02 Sep 2020 13:01:03 +0200, > Greg Kroah-Hartman wrote: > > > > snd_usb_pipe_sanity_check() is a great function, so let's move it into > > the USB core so that other parts of the kernel, including the USB core, > > can call it. > > > > Name it usb_pipe_type_check() to match the existing > > usb_urb_ep_type_check() call, which now uses this function. > > > > Cc: Jaroslav Kysela <perex@perex.cz> > > Cc: Takashi Iwai <tiwai@suse.com> > > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > > Cc: Eli Billauer <eli.billauer@gmail.com> > > Cc: Emiliano Ingrassia <ingrassia@epigenesys.com> > > Cc: Alan Stern <stern@rowland.harvard.edu> > > Cc: Alexander Tsoy <alexander@tsoy.me> > > Cc: "Geoffrey D. Bennett" <g@b4.vu> > > Cc: Jussi Laako <jussi@sonarnerd.net> > > Cc: Nick Kossifidis <mickflemm@gmail.com> > > Cc: Dmitry Panchenko <dmitry@d-systems.ee> > > Cc: Chris Wulff <crwulff@gmail.com> > > Cc: Jesus Ramos <jesus-ramos@live.com> > > Cc: linux-usb@vger.kernel.org > > Cc: linux-kernel@vger.kernel.org > > Cc: alsa-devel@alsa-project.org > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > Reviewed-by: Takashi Iwai <tiwai@suse.de> Thanks for the reviews of all of these. greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kPdXJVZgVl/2/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 07 Sep 2020 18:31:18 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OAg5IlZgVl+I2gEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 07 Sep 2020 18:31:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 09B144097E; Mon, 7 Sep 2020 18:31:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730594AbgIGQbG (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 7 Sep 2020 12:31:06 -0400 Received: from netrider.rowland.org ([192.131.102.5]:38197 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1729801AbgIGOY2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 7 Sep 2020 10:24:28 -0400 Received: (qmail 762519 invoked by uid 1000); 7 Sep 2020 10:24:27 -0400 Date: Mon, 7 Sep 2020 10:24:27 -0400 From: Alan Stern <stern@rowland.harvard.edu> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Eli Billauer <eli.billauer@gmail.com>, Emiliano Ingrassia <ingrassia@epigenesys.com>, Alexander Tsoy <alexander@tsoy.me>, "Geoffrey D. Bennett" <g@b4.vu>, Jussi Laako <jussi@sonarnerd.net>, Nick Kossifidis <mickflemm@gmail.com>, Dmitry Panchenko <dmitry@d-systems.ee>, Chris Wulff <crwulff@gmail.com>, Jesus Ramos <jesus-ramos@live.com> Subject: Re: [PATCH 01/10] USB: move snd_usb_pipe_sanity_check into the USB core Message-ID: <20200907142427.GB762136@rowland.harvard.edu> References: <20200902110115.1994491-1-gregkh@linuxfoundation.org> <20200902110115.1994491-2-gregkh@linuxfoundation.org> <20200903004553.GA642955@rowland.harvard.edu> <20200903073230.GA162335@kroah.com> <20200907141634.GA3733019@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200907141634.GA3733019@kroah.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.02 / 15.00 / 200.00 X-Rspamd-Queue-Id: 09B144097E X-Rspamd-UID: 056d6a On Mon, Sep 07, 2020 at 04:16:34PM +0200, Greg Kroah-Hartman wrote: > On Thu, Sep 03, 2020 at 09:32:30AM +0200, Greg Kroah-Hartman wrote: > > On Wed, Sep 02, 2020 at 08:45:53PM -0400, Alan Stern wrote: > > > Since this routine is used in only one place in the entire kernel, you > > > might as well inline the code there and get rid of the function > > > entirely. > > > > Good idea, will do. > > No, wait, the USB sound drivers call it a lot, so it needs to stick > around for now until we clean that up. Argh. I must have run "git grep" from within drivers/usb/core. My mistake. Alan Stern Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eLMRCdEzV1+SUwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 08 Sep 2020 09:33:37 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wF8vBtEzV1+43QAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 08 Sep 2020 09:33:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 37CBE4086A; Tue, 8 Sep 2020 09:33:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729525AbgIHHdZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 8 Sep 2020 03:33:25 -0400 Received: from mail-il1-f208.google.com ([209.85.166.208]:36484 "EHLO mail-il1-f208.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729319AbgIHHdV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 8 Sep 2020 03:33:21 -0400 Received: by mail-il1-f208.google.com with SMTP id f20so11443703ilg.3 for <linux-bluetooth@vger.kernel.org>; Tue, 08 Sep 2020 00:33:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=DrM2WCpXJni+pWF+DYDXi6ZPwROH9NKgPGVrwdvcC8Y=; b=looVw3+lPXgeBcfsCzcM4jnfrs8vV5eVAYR1OLIoJqXmk1j1K6DD5kKuLWwUnWVfRG 9LWk2N1HxKs1T7x+rXNuu66gBr43YoCM7u/kYyGHElNHwUBrzzIROIVPq/Qz8JMg4Bcu aRe5IxHlEzfhPhcr3EE0jNIySJ3VW61twn31iit9Gu9CT5uc8p8aRBOBCeeNcdzjNdnv h4ZRukTTl/v5HnSndUVpOPZ30qMs4z5NAZKK04QZZ/1q+QNpEWEwCx+PoLJO0U8pcDgF FbAvVdvQL3LYalG2gqbz9WT01g1bnznSLHb662P6RZjgcWYalhpjQ4y3RuAkYGCpCbku dwvA== X-Gm-Message-State: AOAM532ma/S1o77YF6rmujjAV9GW4YM3ZFH6i/2oGKRxf2lYSmPJHBpk ncPrsPhB99AqZqW1I3qq0UlQLhTXndFmgazeIs5gVfju6Pur X-Google-Smtp-Source: ABdhPJxwxola6tjl5Xs6+98Cwd4t1PyoPXL1Rdc31C+ffEV6FNz4YYMQcG8FHq4dtiLGPk6Dfu1FjSLLkOH+GfEAiInawEhOqtpv MIME-Version: 1.0 X-Received: by 2002:a6b:e718:: with SMTP id b24mr20719449ioh.9.1599550399960; Tue, 08 Sep 2020 00:33:19 -0700 (PDT) Date: Tue, 08 Sep 2020 00:33:19 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000063dca305aec85988@google.com> Subject: BUG: spinlock bad magic in lock_sock_nested From: syzbot <syzbot+eb47d1a545390e9fd5bf@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 37CBE4086A X-Rspamd-UID: 53901b Hello, syzbot found the following issue on: HEAD commit: 0f091e43 netlabel: remove unused param from audit_log_form.. git tree: net-next console output: https://syzkaller.appspot.com/x/log.txt?x=1171cbb6900000 kernel config: https://syzkaller.appspot.com/x/.config?x=61025c6fd3261bb1 dashboard link: https://syzkaller.appspot.com/bug?extid=eb47d1a545390e9fd5bf compiler: gcc (GCC) 10.1.0-syz 20200507 Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+eb47d1a545390e9fd5bf@syzkaller.appspotmail.com BUG: spinlock bad magic on CPU#0, kworker/0:2/2721 lock: 0xffff88809395b088, .magic: ffff8880, .owner: <none>/-1, .owner_cpu: 4 CPU: 0 PID: 2721 Comm: kworker/0:2 Not tainted 5.9.0-rc1-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18f/0x20d lib/dump_stack.c:118 debug_spin_lock_before kernel/locking/spinlock_debug.c:83 [inline] do_raw_spin_lock+0x216/0x2b0 kernel/locking/spinlock_debug.c:112 spin_lock_bh include/linux/spinlock.h:359 [inline] lock_sock_nested+0x3b/0x110 net/core/sock.c:3034 l2cap_sock_teardown_cb+0x88/0x400 net/bluetooth/l2cap_sock.c:1520 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:823 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 general protection fault, probably for non-canonical address 0xff16fb65bf176ca9: 0000 [#1] PREEMPT SMP KASAN KASAN: maybe wild-memory-access in range [0xf8b7fb2df8bb6548-0xf8b7fb2df8bb654f] CPU: 0 PID: 2721 Comm: kworker/0:2 Not tainted 5.9.0-rc1-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout RIP: 0010:__pv_queued_spin_lock_slowpath+0x538/0xaf0 kernel/locking/qspinlock.c:471 Code: 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 50 05 00 00 4a 03 1c e5 00 59 84 89 48 b8 00 00 00 00 00 fc ff df 48 89 da 48 c1 ea 03 <80> 3c 02 00 0f 85 20 05 00 00 4c 8d 6b 14 48 89 6c 24 08 48 8b 2c RSP: 0018:ffffc9000947f9c8 EFLAGS: 00010a07 RAX: dffffc0000000000 RBX: f8b7fb2df8bb654f RCX: ffffffff815b03df RDX: 1f16ff65bf176ca9 RSI: 0000000000000002 RDI: ffffffff8984fd38 RBP: ffff88809395b088 R08: 0000000000000001 R09: ffff88809395b08b R10: ffffed101272b611 R11: 0000000000000160 R12: 0000000000001487 R13: 0000000000000001 R14: 0000000000040000 R15: ffff8880ae636b80 FS: 0000000000000000(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fb5e095ddb8 CR3: 000000005badb000 CR4: 00000000001506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt.h:656 [inline] queued_spin_lock_slowpath arch/x86/include/asm/qspinlock.h:51 [inline] queued_spin_lock include/asm-generic/qspinlock.h:85 [inline] do_raw_spin_lock+0x200/0x2b0 kernel/locking/spinlock_debug.c:113 spin_lock_bh include/linux/spinlock.h:359 [inline] lock_sock_nested+0x3b/0x110 net/core/sock.c:3034 l2cap_sock_teardown_cb+0x88/0x400 net/bluetooth/l2cap_sock.c:1520 l2cap_chan_del+0xad/0x1300 net/bluetooth/l2cap_core.c:618 l2cap_chan_close+0x118/0xb10 net/bluetooth/l2cap_core.c:823 l2cap_chan_timeout+0x173/0x450 net/bluetooth/l2cap_core.c:436 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 kthread+0x3b5/0x4a0 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Modules linked in: ---[ end trace cdfef0620d680c8c ]--- RIP: 0010:__pv_queued_spin_lock_slowpath+0x538/0xaf0 kernel/locking/qspinlock.c:471 Code: 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 50 05 00 00 4a 03 1c e5 00 59 84 89 48 b8 00 00 00 00 00 fc ff df 48 89 da 48 c1 ea 03 <80> 3c 02 00 0f 85 20 05 00 00 4c 8d 6b 14 48 89 6c 24 08 48 8b 2c RSP: 0018:ffffc9000947f9c8 EFLAGS: 00010a07 RAX: dffffc0000000000 RBX: f8b7fb2df8bb654f RCX: ffffffff815b03df RDX: 1f16ff65bf176ca9 RSI: 0000000000000002 RDI: ffffffff8984fd38 RBP: ffff88809395b088 R08: 0000000000000001 R09: ffff88809395b08b R10: ffffed101272b611 R11: 0000000000000160 R12: 0000000000001487 R13: 0000000000000001 R14: 0000000000040000 R15: ffff8880ae636b80 FS: 0000000000000000(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fb5e095ddb8 CR3: 000000005badb000 CR4: 00000000001506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KFykLBq6V1/H/wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 08 Sep 2020 19:06:34 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2ECaKRq6V19sCAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 08 Sep 2020 19:06:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B956940966; Tue, 8 Sep 2020 19:06:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732058AbgIHRG1 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 8 Sep 2020 13:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730654AbgIHRGT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 8 Sep 2020 13:06:19 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4971EC061573 for <linux-bluetooth@vger.kernel.org>; Tue, 8 Sep 2020 10:06:18 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id z1so4109412ooj.3 for <linux-bluetooth@vger.kernel.org>; Tue, 08 Sep 2020 10:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LDm3kOOwZrm2QQjfz7xq1xnQphD/165ThX8L1IGFITE=; b=Uy6ZvZa8ZthOO0f/XKbVhw1t9cqU6AIiEGtcDEvaGzBfPXp1gGJp0OmtI5yDVDQO4s OTFGVBBsXdCue2Aw9d76UnWGHoNAZcqIlzPfffwneU/3NsXySM3oFu61TAig4X5zsItS X74ML6hRDX2ydUx/XpPponer38INWu0ANApdt71XoONlpBo0CA98llMqwumJvAeCFeX6 PJpurLsfBTjn9r8o7EMAChQtIO+t3rjWgfMy9JnA4CII6bXQ+c8TN/dNDlHdUyG3SMyY 25oUb8FRfpgZqjZGjgPXt2M1K75HD/tYxgCXrelea0TM1hNePdJk2UqYGJb+eT74uFyI 4M/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LDm3kOOwZrm2QQjfz7xq1xnQphD/165ThX8L1IGFITE=; b=AfXj8aVFUS9EsBKMuijQXY28/cbOjyXB9tL7bVXmVshx3OVnsItRnhyZSGjj+H80y+ XQErWxgIG1vRpTtBKeOd6hM/ZOjwz+SNu59QIRDEZHH3WbeRQwkHwrS/vf9MO6OxxZhu 2LgBUBFeM8gcJhJmmJArPZiGYBZn1j4KQrGFum0uBdh5WFdvmFWiP/o4oOVGfJbmJTN5 GwdrUszFprrFY1tEVCOEgLv12+5L/ixDEdFHrUM6fcyblsa/31AJ41Jbu2QYWDcrWCdQ 23CTsyIU+gqlv+xlcaRhhPyquTJg0C2rXJ2g6oH5iRoxiLW8ajGMeHV/Tfm4D6bf7GMr r7fQ== X-Gm-Message-State: AOAM532XTDje0dQcbUOS3shNVeTuKLp+gxW8fNdHp7pzd01w7WX8xdVe 2bCMbI/fKt/98YmlxokxFaeinO/2d5xAJsUAm2I= X-Google-Smtp-Source: ABdhPJy4GveSdvCnUx1V1J+ldUmBHQagnUaKxiNkLrGsyyzuJHaMaxzADGzGgK71aXMiNi3DsjsguquJuHX03zL/J/c= X-Received: by 2002:a4a:924b:: with SMTP id g11mr19245760ooh.9.1599584777461; Tue, 08 Sep 2020 10:06:17 -0700 (PDT) MIME-Version: 1.0 References: <20200819121048.BlueZ.v1.1.I3a57ea1eb3e3f5b87abc44ea478fc83817627ffc@changeid> <20200819121048.BlueZ.v1.2.I045d6f668c141c6b834ba6b31fc81618c0a7b8e8@changeid> In-Reply-To: <20200819121048.BlueZ.v1.2.I045d6f668c141c6b834ba6b31fc81618c0a7b8e8@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 8 Sep 2020 10:06:06 -0700 Message-ID: <CABBYNZLeqA=i_JdcJUD-Q-6p_8DtMpmmW=gg4yvQrJ77jRG4sw@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 2/4] client: Implement more interfaces of ADV monitor in bluetoothctl To: Howard Chung <howardchung@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Manish Mandlik <mmandlik@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: B956940966 X-Rspamd-UID: cc46d5 Hi Howard, On Tue, Aug 18, 2020 at 9:15 PM Howard Chung <howardchung@google.com> wrote: > > This patch creates a submenu in bluetoothctl and implements several > commands. > > new commands: > [bluetooth]# menu advmon > [bluetooth]# add-pattern-monitor or_patterns -10,10,-30,5 1,2,ab0011 > Advertisement Monitor 0 added > [bluetooth]# get-pattern-monitor all > Advertisement Monitor 0 > path: /org/bluez/adv_monitor_app/0 > type: or_patterns > rssi: > high threshold: -10 > high threshold timer: 10 > low threshold: -30 > low threshold timer: 5 > pattern 1: > start position: 1 > AD data type: 2 > content: ab0011 > [bluetooth]# get-supported-info > Supported Features: > Supported Moniter Types: or_patterns > [bluetooth]# remove-pattern-monitor 0 > Monitor 0 deleted > > Signed-off-by: Howard Chung <howardchung@google.com> > --- > > client/advertisement_monitor.c | 328 ++++++++++++++++++++++++++++++++- > client/advertisement_monitor.h | 4 + > client/main.c | 70 +++++++ > 3 files changed, 399 insertions(+), 3 deletions(-) > > diff --git a/client/advertisement_monitor.c b/client/advertisement_monitor.c > index bd2309537..ec8f23711 100644 > --- a/client/advertisement_monitor.c > +++ b/client/advertisement_monitor.c > @@ -29,6 +29,7 @@ > #include <string.h> > > #include "gdbus/gdbus.h" > +#include "src/shared/ad.h" > #include "src/shared/util.h" > #include "src/shared/shell.h" > #include "advertisement_monitor.h" > @@ -36,6 +37,27 @@ > #define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" > #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" > > +struct rssi_setting { > + int16_t high_threshold; > + uint16_t high_timer; > + int16_t low_threshold; > + uint16_t low_timer; > +}; > + > +struct pattern { > + uint8_t start_pos; > + uint8_t ad_data_type; > + uint8_t content_len; > + uint8_t content[BT_AD_MAX_DATA_LEN]; > +}; > + > +struct adv_monitor { > + uint8_t idx; > + char *type; > + struct rssi_setting *rssi; > + GSList *patterns; > +}; > + > struct adv_monitor_manager { > GSList *supported_types; > GSList *supported_features; > @@ -43,6 +65,9 @@ struct adv_monitor_manager { > gboolean app_registered; > } manager = { NULL, NULL, NULL, FALSE }; > > +static uint8_t adv_mon_idx; > +static GSList *adv_mons; > + > static void set_supported_list(GSList **list, DBusMessageIter *iter) > { > char *str; > @@ -138,7 +163,10 @@ static void unregister_reply(DBusMessage *message, void *user_data) > > void adv_monitor_register_app(DBusConnection *conn) > { > - if (manager.supported_types == NULL || manager.app_registered == TRUE || > + if (manager.app_registered == TRUE) { > + bt_shell_printf("Advertisement Monitor already registered\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } else if (manager.supported_types == NULL || > g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", > register_setup, register_reply, > NULL, NULL) == FALSE) { > @@ -150,8 +178,10 @@ void adv_monitor_register_app(DBusConnection *conn) > > void adv_monitor_unregister_app(DBusConnection *conn) > { > - if (manager.app_registered == FALSE || > - g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", > + if (manager.app_registered == FALSE) { > + bt_shell_printf("Advertisement Monitor not registered\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } else if (g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", > unregister_setup, unregister_reply, > NULL, NULL) == FALSE) { > bt_shell_printf("Failed to unregister Advertisement Monitor\n"); > @@ -159,3 +189,295 @@ void adv_monitor_unregister_app(DBusConnection *conn) > } > manager.app_registered = FALSE; > } > + > +static void free_pattern(void *user_data) > +{ > + struct pattern *p = user_data; > + > + g_free(p); > +} > + > +static void free_adv_monitor(void *user_data) > +{ > + struct adv_monitor *adv_monitor = user_data; > + > + g_free(adv_monitor->type); > + g_free(adv_monitor->rssi); > + g_slist_free_full(adv_monitor->patterns, free_pattern); > + g_free(adv_monitor); > +} > + > +static uint8_t str2bytearray(char *str, uint8_t *arr) > +{ > + int idx, len = strlen(str), arr_len = 0; > + > + if (len%2 != 0) > + return 0; > + > + for (idx = 0; idx < len; idx += 2) { > + if (sscanf(str+idx, "%2hhx", &arr[arr_len++]) < 1) > + return 0; > + } > + return arr_len; > +} > + > +static struct rssi_setting *parse_rssi(char *rssi_str) > +{ > + struct rssi_setting *rssi; > + int16_t high_threshold, low_threshold; > + uint16_t high_timer, low_timer; > + > + if (sscanf(rssi_str, "%hd,%hu,%hd,%hu", &high_threshold, &high_timer, > + &low_threshold, &low_timer) < 4) > + return NULL; > + > + rssi = g_malloc0(sizeof(struct rssi_setting)); > + > + if (!rssi) { > + bt_shell_printf("Failed to allocate rssi_setting"); > + bt_shell_noninteractive_quit(EXIT_FAILURE); > + return NULL; > + } > + > + rssi->high_threshold = high_threshold; > + rssi->high_timer = high_timer; > + rssi->low_threshold = low_threshold; > + rssi->low_timer = low_timer; > + > + return rssi; > +} > + > +static struct pattern *parse_pattern(char *pattern) > +{ > + uint8_t start_pos, ad_data_type; > + char content_str[BT_AD_MAX_DATA_LEN]; > + struct pattern *pat; > + > + if (sscanf(pattern, "%hhu,%hhu,%s", &start_pos, &ad_data_type, > + content_str) < 3) > + return NULL; > + > + pat = g_malloc0(sizeof(struct pattern)); > + > + if (!pat) { > + bt_shell_printf("Failed to allocate pattern"); > + bt_shell_noninteractive_quit(EXIT_FAILURE); > + return NULL; > + } > + > + pat->start_pos = start_pos; > + pat->ad_data_type = ad_data_type; > + pat->content_len = str2bytearray(content_str, pat->content); > + if (pat->content_len == 0) { > + free_pattern(pat); > + return NULL; > + } > + > + return pat; > +} > + > +static GSList *parse_patterns(char *pattern_list[], int num) > +{ > + GSList *patterns = NULL; > + int cnt; > + > + if (num == 0) { > + bt_shell_printf("No pattern provided\n"); > + return NULL; > + } > + > + for (cnt = 0; cnt < num; cnt++) { > + struct pattern *pattern; > + > + pattern = parse_pattern(pattern_list[cnt]); > + if (pattern == NULL) { > + g_slist_free_full(patterns, free_pattern); > + return NULL; > + } > + patterns = g_slist_append(patterns, pattern); > + } > + > + return patterns; > +} > + > +static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) > +{ > + const struct adv_monitor *adv_monitor = a; > + uint8_t idx = *(uint8_t *)b; > + > + return adv_monitor->idx != idx; > +} > + > +static struct adv_monitor *find_adv_monitor_with_idx(uint8_t monitor_idx) > +{ > + GSList *list; > + > + list = g_slist_find_custom(adv_mons, &monitor_idx, > + cmp_adv_monitor_with_idx); > + > + if (list) > + return (struct adv_monitor *)list->data; > + return NULL; > +} > + > +static void print_bytearray(char *prefix, uint8_t *arr, uint8_t len) > +{ > + int idx; > + > + bt_shell_printf("%s", prefix); > + for (idx = 0; idx < len; idx++) > + bt_shell_printf("%02hhx", arr[idx]); > + bt_shell_printf("\n"); > +} > + > +static void print_adv_monitor(struct adv_monitor *adv_monitor) > +{ > + GSList *l; > + > + bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); > + bt_shell_printf("\ttype: %s\n", adv_monitor->type); > + if (adv_monitor->rssi) { > + bt_shell_printf("\trssi:\n"); > + bt_shell_printf("\t\thigh threshold: %hd\n", > + adv_monitor->rssi->high_threshold); > + bt_shell_printf("\t\thigh threshold timer: %hu\n", > + adv_monitor->rssi->high_timer); > + bt_shell_printf("\t\tlow threshold: %hd\n", > + adv_monitor->rssi->low_threshold); > + bt_shell_printf("\t\tlow threshold timer: %hu\n", > + adv_monitor->rssi->low_timer); > + } > + > + if (adv_monitor->patterns) { > + int idx = 1; > + > + for (l = adv_monitor->patterns; l; l = g_slist_next(l), idx++) { > + struct pattern *pattern = l->data; > + > + bt_shell_printf("\tpattern %d:\n", idx); > + bt_shell_printf("\t\tstart position: %hhu\n", > + pattern->start_pos); > + bt_shell_printf("\t\tAD data type: %hhu\n", > + pattern->ad_data_type); > + print_bytearray("\t\tcontent: ", pattern->content, > + pattern->content_len); > + } > + } > +} > + > +void adv_monitor_add_monitor(DBusConnection *conn, int argc, char *argv[]) > +{ > + struct adv_monitor *adv_monitor; > + struct rssi_setting *rssi; > + GSList *patterns = NULL; > + char *type; > + > + if (g_slist_length(adv_mons) >= UINT8_MAX) { > + bt_shell_printf("Number of advertisement monitor exceeds " > + "the limit"); > + return; > + } > + > + while (find_adv_monitor_with_idx(adv_mon_idx)) > + adv_mon_idx += 1; > + > + type = argv[1]; > + > + if (strcmp(argv[2], "-") == 0) > + rssi = NULL; > + else { > + rssi = parse_rssi(argv[2]); > + if (rssi == NULL) { > + bt_shell_printf("RSSIThresholdAndTimers malformed\n"); > + return; > + } > + } > + > + patterns = parse_patterns(argv+3, argc-3); > + if (patterns == NULL) { > + bt_shell_printf("pattern-list malformed\n"); > + return; > + } > + > + adv_monitor = g_malloc0(sizeof(struct adv_monitor)); > + > + if (!adv_monitor) { > + bt_shell_printf("Failed to allocate adv_monitor"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + > + adv_monitor->idx = adv_mon_idx; > + adv_monitor->type = g_strdup(type); > + adv_monitor->rssi = rssi; > + adv_monitor->patterns = patterns; > + > + adv_mons = g_slist_append(adv_mons, adv_monitor); > + bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); > +} > + > +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx) > +{ > + struct adv_monitor *adv_monitor; > + GSList *l; > + > + if (monitor_idx < 0) { > + for (l = adv_mons; l; l = g_slist_next(l)) { > + adv_monitor = l->data; > + print_adv_monitor(adv_monitor); > + } > + return; > + } > + > + adv_monitor = find_adv_monitor_with_idx(monitor_idx); > + > + if (adv_monitor == NULL) { > + bt_shell_printf("Can't find monitor with index %d\n", > + monitor_idx); > + return; > + } > + > + print_adv_monitor(adv_monitor); > +} > + > +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) > +{ > + struct adv_monitor *adv_monitor; > + > + if (monitor_idx < 0) { > + g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); > + return; > + } > + > + adv_monitor = find_adv_monitor_with_idx(monitor_idx); > + if (adv_monitor == NULL) { > + bt_shell_printf("Can't find monitor with index %d\n", > + monitor_idx); > + return; > + } > + > + adv_mons = g_slist_remove(adv_mons, adv_monitor); > + free_adv_monitor(adv_monitor); > + bt_shell_printf("Monitor %d deleted\n", monitor_idx); > +} > + > +static void print_supported_list(GSList *list) > +{ > + GSList *iter; > + > + for (iter = list; iter; iter = g_slist_next(iter)) { > + char *data = iter->data; > + > + printf(" %s", data); > + } > +} > + > +void adv_monitor_get_supported_info(void) > +{ > + bt_shell_printf("Supported Features:"); > + print_supported_list(manager.supported_features); > + bt_shell_printf("\n"); > + > + bt_shell_printf("Supported Moniter Types:"); > + print_supported_list(manager.supported_types); > + bt_shell_printf("\n"); > +} > diff --git a/client/advertisement_monitor.h b/client/advertisement_monitor.h > index 77b0b62c6..f2a0caf77 100644 > --- a/client/advertisement_monitor.h > +++ b/client/advertisement_monitor.h > @@ -21,3 +21,7 @@ void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); > void adv_monitor_remove_manager(DBusConnection *conn); > void adv_monitor_register_app(DBusConnection *conn); > void adv_monitor_unregister_app(DBusConnection *conn); > +void adv_monitor_add_monitor(DBusConnection *conn, int argc, char *argv[]); > +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx); > +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx); > +void adv_monitor_get_supported_info(void); > diff --git a/client/main.c b/client/main.c > index 7ddd13aa0..2b63ee62a 100644 > --- a/client/main.c > +++ b/client/main.c > @@ -2686,6 +2686,53 @@ static void cmd_ad_clear(int argc, char *argv[]) > return bt_shell_noninteractive_quit(EXIT_FAILURE); > } > > +static void print_add_monitor_usage(void) > +{ > + bt_shell_usage(); > + bt_shell_printf("RSSIThresholdAndTimers format:\n" > + "\t<high-rssi>,<high-timeout>,<low-rssi>,<low-timeout>\n" > + "\tor single '-' for not using RSSI as filter\n"); > + bt_shell_printf("pattern format:\n" > + "\t<start_position>,<ad_data_type>,<content_of_pattern>\n"); > + bt_shell_printf("e.g.\n" > + "\tadd-pattern-monitor or_patterns -10,10,-20,20 1,2,01ab55\n"); btshell parameters are space separated not comma. > +} > + > +static void cmd_adv_monitor_add_monitor(int argc, char *argv[]) > +{ > + if (argc < 3) > + print_add_monitor_usage(); > + else > + adv_monitor_add_monitor(dbus_conn, argc, argv); > +} > + > +static void cmd_adv_monitor_print_monitor(int argc, char *argv[]) > +{ > + int monitor_idx; > + > + if (strcmp(argv[1], "all") == 0) > + monitor_idx = -1; > + else > + monitor_idx = atoi(argv[1]); > + adv_monitor_print_monitor(dbus_conn, monitor_idx); > +} > + > +static void cmd_adv_monitor_remove_monitor(int argc, char *argv[]) > +{ > + int monitor_idx; > + > + if (strcmp(argv[1], "all") == 0) > + monitor_idx = -1; > + else > + monitor_idx = atoi(argv[1]); > + adv_monitor_remove_monitor(dbus_conn, monitor_idx); > +} > + > +static void cmd_adv_monitor_get_supported_info(int argc, char *argv[]) > +{ > + adv_monitor_get_supported_info(); > +} > + > static const struct bt_shell_menu advertise_menu = { > .name = "advertise", > .desc = "Advertise Options Submenu", > @@ -2722,6 +2769,28 @@ static const struct bt_shell_menu advertise_menu = { > { } }, > }; > > +static const struct bt_shell_menu advertise_monitor_menu = { > + .name = "advmon", I'd use monitor instead of advmon here. > + .desc = "Advertisement Monitor Options Submenu", > + .entries = { > + { "add-pattern-monitor", "<type-of-monitor/help> " > + "[RSSIThresholdAndTimers] " > + "[patterns=pattern1 pattern2 ...]", > + cmd_adv_monitor_add_monitor, > + "Add pattern monitor" }, > + { "get-pattern-monitor", "<monitor-id/all>", > + cmd_adv_monitor_print_monitor, > + "Get advertisement monitor" }, > + { "remove-pattern-monitor", "<monitor-id/all>", > + cmd_adv_monitor_remove_monitor, > + "Remove advertisement monitor" }, > + { "get-supported-info", NULL, > + cmd_adv_monitor_get_supported_info, > + "Get advertisement manager supported " > + "features and supported monitor types" }, We could probably drop the monitor from the commands here which should leave us at: add-pattern get-pattern remote-pattern supported-info > + { } }, > +}; > + > static const struct bt_shell_menu scan_menu = { > .name = "scan", > .desc = "Scan Options Submenu", > @@ -2897,6 +2966,7 @@ int main(int argc, char *argv[]) > bt_shell_init(argc, argv, &opt); > bt_shell_set_menu(&main_menu); > bt_shell_add_submenu(&advertise_menu); > + bt_shell_add_submenu(&advertise_monitor_menu); > bt_shell_add_submenu(&scan_menu); > bt_shell_add_submenu(&gatt_menu); > bt_shell_set_prompt(PROMPT_OFF); > -- > 2.28.0.220.ged08abb693-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4LUEBli9V1/yFwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 08 Sep 2020 19:20:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6IzsAli9V1+D7wAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 08 Sep 2020 19:20:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AADB8A0B6C; Tue, 8 Sep 2020 19:20:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731779AbgIHRUB (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 8 Sep 2020 13:20:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728494AbgIHRTu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 8 Sep 2020 13:19:50 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41C1CC061573 for <linux-bluetooth@vger.kernel.org>; Tue, 8 Sep 2020 10:19:50 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id w16so17203524oia.2 for <linux-bluetooth@vger.kernel.org>; Tue, 08 Sep 2020 10:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=D0Tpz6iiGOH9jKWx+vYGwwElkU9D2IqTxybE7t8fGbQ=; b=TxXz2aEFkK9new76IPz1OGB4Uaf37ewDVDcMYsFsyqFCjH5BoL6nxFiaG3HcgCYUTF GRgag4KfiXXh0Nm8u1W6uMgoxOz1CAI0XOgysUIC9g2saeM0NdGVpEa0YByq+u9I+aZz E6PURQCBF6/tLq/zy1p8faVbrFd8dP2f9cT4EhjC21LpxBW7nsaQAMKYdjZp+G1Hyx9w Ct+w1RgS326PbIhyje3pBas3lML2lZdFNNFYUJiuo6haSl33lFQzsE5gjCgIxEu+uqLS CxwEWAQ4Zx8xY29hpYImISkDo+EzWR34WwRKZljYoCipnJ8MZoyjNeIX19pJEqMGOYbh qcMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=D0Tpz6iiGOH9jKWx+vYGwwElkU9D2IqTxybE7t8fGbQ=; b=Oyci7oZ+1vOKhqdfXRp3zcDNP4O9otXPxPLUYZBVuDWxl5M0sbRTSj/slNN/q/fte1 udywFG9mUy3oBbqxdw5zOcE4WbUYKeRk7S1fws1Hk5bdSItBhwCiWbY7gNLgqm/7wmZ6 2XqPk1eKRgX2P+kepF39CgtTqcj0z45MY2UiStliurJ+o9nG+6xUExNesjr/XUhQGQ7/ 3Py2enb2nUyQuwOnuK0N9boDnmkRoXmNEnyrLPdVF4Couh6a3zvweJGsDqOJDDhamWCo qffjhVYdsT3xU9P8uTQv24Es14nBlwo9oYcZ68OtyewXtPhof+o4KT9ac5XLAnkQCH9C 63+w== X-Gm-Message-State: AOAM533pmiqbjuHv9AjdQ3Wbwchu3/p3MpQaobh9GTpE9QoM+pcTo2o/ jCIxDF/v1Kz/Jivgm60UcBkko1tVDgCV+sXaECU= X-Google-Smtp-Source: ABdhPJy4gG3wUMZ3EHdLBh5tlp5OJ9orIYeEEqiRmsLPzGDVee74sBqAYxCYmib4WNJIhF30OQdC4Pagl9Jc4mUsaVk= X-Received: by 2002:aca:aad0:: with SMTP id t199mr6800oie.48.1599585589523; Tue, 08 Sep 2020 10:19:49 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> In-Reply-To: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 8 Sep 2020 10:19:38 -0700 Message-ID: <CABBYNZLoGG8_f-8Vr=FW-mVe1uFsz-ob3-=tuk_c90kqhtLMVg@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.95 / 15.00 / 200.00 X-Rspamd-Queue-Id: AADB8A0B6C X-Rspamd-UID: 398c48 Hi Miao, On Tue, Aug 18, 2020 at 3:30 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > This introduces the org.bluez.AdvertisementMonitorManager1 without > implementing handlers of methods and properties. > > The following test was performed. > - Upon adapter registration, the info line of creating an ADV monitor > manager gets printed, and system bus emits the interface events of > org.bluez.AdvertisementMonitorManager1. > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > > Makefile.am | 3 +- > src/adapter.c | 14 +++++ > src/adapter.h | 3 + > src/adv_monitor.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++ > src/adv_monitor.h | 32 ++++++++++ > 5 files changed, 200 insertions(+), 1 deletion(-) > create mode 100644 src/adv_monitor.c > create mode 100644 src/adv_monitor.h > > diff --git a/Makefile.am b/Makefile.am > index 7719c06f8..b14ee950e 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -293,7 +293,8 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ > src/gatt-client.h src/gatt-client.c \ > src/device.h src/device.c \ > src/dbus-common.c src/dbus-common.h \ > - src/eir.h src/eir.c > + src/eir.h src/eir.c \ > + src/adv_monitor.h src/adv_monitor.c Id just name it monitor.{c, h} > src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ > gdbus/libgdbus-internal.la \ > src/libshared-glib.la \ > diff --git a/src/adapter.c b/src/adapter.c > index 5e896a9f0..41e9de286 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -77,6 +77,7 @@ > #include "attrib-server.h" > #include "gatt-database.h" > #include "advertising.h" > +#include "adv_monitor.h" > #include "eir.h" > > #define ADAPTER_INTERFACE "org.bluez.Adapter1" > @@ -272,6 +273,8 @@ struct btd_adapter { > struct btd_gatt_database *database; > struct btd_adv_manager *adv_manager; > > + struct btd_adv_monitor_manager *adv_monitor_manager; > + > gboolean initialized; > > GSList *pin_callbacks; > @@ -6346,6 +6349,9 @@ static void adapter_remove(struct btd_adapter *adapter) > btd_adv_manager_destroy(adapter->adv_manager); > adapter->adv_manager = NULL; > > + btd_adv_monitor_manager_destroy(adapter->adv_monitor_manager); > + adapter->adv_monitor_manager = NULL; > + > g_slist_free(adapter->pin_callbacks); > adapter->pin_callbacks = NULL; > > @@ -8623,6 +8629,14 @@ static int adapter_register(struct btd_adapter *adapter) > > adapter->adv_manager = btd_adv_manager_new(adapter, adapter->mgmt); > > + adapter->adv_monitor_manager = btd_adv_monitor_manager_create( > + adapter, adapter->mgmt); > + if (!adapter->adv_monitor_manager) { > + btd_error(adapter->dev_id, > + "Failed to create Adv Monitor Manager for adapter"); > + return -EINVAL; > + } > + > db = btd_gatt_database_get_db(adapter->database); > adapter->db_id = gatt_db_register(db, services_modified, > services_modified, > diff --git a/src/adapter.h b/src/adapter.h > index f8ac20261..5cb467141 100644 > --- a/src/adapter.h > +++ b/src/adapter.h > @@ -26,6 +26,9 @@ > #include <dbus/dbus.h> > #include <glib.h> > > +#include "lib/bluetooth.h" > +#include "lib/sdp.h" > + It might be better to have this included locally in a .c file needing them. > #define MAX_NAME_LENGTH 248 > > /* Invalid SSP passkey value used to indicate negative replies */ > diff --git a/src/adv_monitor.c b/src/adv_monitor.c > new file mode 100644 > index 000000000..7044d3cca > --- /dev/null > +++ b/src/adv_monitor.c > @@ -0,0 +1,149 @@ > +/* > + * > + * BlueZ - Bluetooth protocol stack for Linux > + * > + * Copyright (C) 2020 Google LLC > + * > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + */ > + > +#ifdef HAVE_CONFIG_H > +#include <config.h> > +#endif > + > +#define _GNU_SOURCE > +#include <stdint.h> > + > +#include <glib.h> > +#include <dbus/dbus.h> > +#include <gdbus/gdbus.h> > + > +#include "adapter.h" > +#include "dbus-common.h" > +#include "log.h" > +#include "src/shared/mgmt.h" > + > +#include "adv_monitor.h" > + > +#define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" > + > +struct btd_adv_monitor_manager { > + struct btd_adapter *adapter; > + struct mgmt *mgmt; > + uint16_t adapter_id; > + char *path; > +}; > + > +static const GDBusMethodTable adv_monitor_methods[] = { > + { GDBUS_METHOD("RegisterMonitor", > + GDBUS_ARGS({ "application", "o" }), > + NULL, NULL) }, > + { GDBUS_ASYNC_METHOD("UnregisterMonitor", > + GDBUS_ARGS({ "application", "o" }), > + NULL, NULL) }, > + { } > +}; > + > +static const GDBusPropertyTable adv_monitor_properties[] = { > + {"SupportedMonitorTypes", "as", NULL, NULL, NULL}, > + {"SupportedFeatures", "as", NULL, NULL, NULL}, > + { } > +}; > + > +/* Allocates a manager object */ > +static struct btd_adv_monitor_manager *manager_new( > + struct btd_adapter *adapter, > + struct mgmt *mgmt) > +{ > + struct btd_adv_monitor_manager *manager; > + > + if (!adapter || !mgmt) > + return NULL; > + > + manager = g_new0(struct btd_adv_monitor_manager, 1); Use new0. > + if (!manager) > + return NULL; > + > + manager->adapter = adapter; > + manager->mgmt = mgmt_ref(mgmt); > + manager->adapter_id = btd_adapter_get_index(adapter); > + manager->path = g_strdup(adapter_get_path(manager->adapter)); If we are doing to reference the adapter we don't really need the duplicate its path since we can just use adapter_get_path. > + > + return manager; > +} > + > +/* Frees a manager object */ > +static void manager_free(struct btd_adv_monitor_manager *manager) > +{ > + manager->adapter = NULL; No need to assign NULL if you are going to free the whole object at the end. > + mgmt_unref(manager->mgmt); > + manager->mgmt = NULL; Ditto. > + g_free(manager->path); > + manager->path = NULL; Ditto. > + > + g_free(manager); > +} > + > +/* Destroys a manager object and unregisters its D-Bus interface */ > +static void manager_destroy(struct btd_adv_monitor_manager *manager) > +{ > + if (!manager) > + return; > + > + g_dbus_unregister_interface(btd_get_dbus_connection(), > + manager->path, > + ADV_MONITOR_MGR_INTERFACE); > + > + manager_free(manager); > +} > + > +/* Creates a manager and registers its D-Bus interface */ > +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( > + struct btd_adapter *adapter, > + struct mgmt *mgmt) > +{ > + struct btd_adv_monitor_manager *manager; > + > + manager = manager_new(adapter, mgmt); > + if (!manager) > + return NULL; > + > + if (g_dbus_register_interface(btd_get_dbus_connection(), manager->path, > + ADV_MONITOR_MGR_INTERFACE, > + adv_monitor_methods, NULL, > + adv_monitor_properties, manager, NULL) > + == FALSE) { We haven't been consistent with boolean checks but lately we start using more the ! form instead of == FALSE. > + btd_error(manager->adapter_id, > + "Failed to register " > + ADV_MONITOR_MGR_INTERFACE); > + manager_free(manager); > + return NULL; > + } > + > + btd_info(manager->adapter_id, > + "Adv Monitor Manager created for adapter %s", > + adapter_get_path(manager->adapter)); > + > + return manager; > +} > + > +/* Destroys a manager and unregisters its D-Bus interface */ > +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) > +{ > + if (!manager) > + return; > + > + btd_info(manager->adapter_id, "Destroy Adv Monitor Manager"); > + > + manager_destroy(manager); > +} > diff --git a/src/adv_monitor.h b/src/adv_monitor.h > new file mode 100644 > index 000000000..69ea348f8 > --- /dev/null > +++ b/src/adv_monitor.h > @@ -0,0 +1,32 @@ > +/* > + * > + * BlueZ - Bluetooth protocol stack for Linux > + * > + * Copyright (C) 2020 Google LLC > + * > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + */ > + > +#ifndef __ADV_MONITOR_H > +#define __ADV_MONITOR_H > + > +struct mgmt; > +struct btd_adapter; > +struct btd_adv_monitor_manager; > + > +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( > + struct btd_adapter *adapter, > + struct mgmt *mgmt); > +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); > + > +#endif /* __ADV_MONITOR_H */ > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +CMOK4G+V1+GwgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 08 Sep 2020 19:25:21 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id uMc+KIG+V1/ujAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 08 Sep 2020 19:25:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 101B140942; Tue, 8 Sep 2020 19:25:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728620AbgIHRZL (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 8 Sep 2020 13:25:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728248AbgIHRZB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 8 Sep 2020 13:25:01 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66CE5C061573 for <linux-bluetooth@vger.kernel.org>; Tue, 8 Sep 2020 10:25:01 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id a2so15495315otr.11 for <linux-bluetooth@vger.kernel.org>; Tue, 08 Sep 2020 10:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=arPHdIb7XQtSkTkswlvjV8UQZrEs63VZ5dfRo8URKtA=; b=NRpz301jZ9yykIMdIBKRXdGY0fJ5aiBatyXMyv9mpjHDTZGv9VKUwE8+X8Y8bEWbwT 6lHbPwH3hPzoBqhKRYEA27h4kv8Ds0slxnaCLjBDP19cX/pHSrmEp+rDrBWjaiRuhSz6 usOuKRGLVG/J7/6pDuvkIHBISqrahei+6CXb2TZJ8MJOd2kcwfSGstkBE9aRTVghUf7i YnAAkrw2bfY+T2Fobp/77JL9kUVdOVgTJnbSDfEe871/tfoB7g//jcm0l6YjXb4y2LR4 HsWkNZRuNk8lDI4wvU49iRjPOF9KmEJjTUkBaj7FPYRPS6XkWf2agcObmT7ubzAP5GuL kVXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=arPHdIb7XQtSkTkswlvjV8UQZrEs63VZ5dfRo8URKtA=; b=dstOwTo7GyiCAIQzJbULCMMqmWJHG5/C8U7+isqWGa7F3z3pLiODVCK7t90iCYO0Ey qHR8Es01hWY3CaaXIxFIBnN9IIZ2qAdO6eetHAFy+DFZonX4UZNHlI9pPXFiYMxOJ4sR NKxAjHreyD8XZOzRQ3fVYYBqPsXAIhDp11uQfqVLTREVbpkIZgqTseZquWWF3jQgVDbp ZoaFMUL3tBnMzSgUlV2ODgnXLzaxv+/vbBl/NJrdCgGYRXvqDCW4Yxt7vGoJDbyd9PQr Q03VfM8J8LrmX7AIizFy6QjdQ8Xatp20NTRmWyfY75PWyfn8DxbA1fo9pZ9yy6f4gJsb F1gw== X-Gm-Message-State: AOAM533+CUTnwcqOTNrm2xnSmzUPYmg4nK33Q6Q9RVERy+0sJnOiH3El 8kpFthMT/Yx+OiU/6tPmX+Bg7iDe2K5CfA37O+o= X-Google-Smtp-Source: ABdhPJxrbfNQtoLwDci7M6sQB3oA3bRX6ABStxQdtpM4NJKKgzONX6JPDZhxDkC5sP6U1oanKjJfjRdtUu7XBzI8fPY= X-Received: by 2002:a9d:2208:: with SMTP id o8mr80981ota.362.1599585900722; Tue, 08 Sep 2020 10:25:00 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <20200818152612.BlueZ.v1.3.I19ff9cdbd40fe453db0e81aec8bf94dd9490dce3@changeid> In-Reply-To: <20200818152612.BlueZ.v1.3.I19ff9cdbd40fe453db0e81aec8bf94dd9490dce3@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 8 Sep 2020 10:24:50 -0700 Message-ID: <CABBYNZ+EgjjuiyiUaFDAhM1tzmvh6+w5ERA4omtfNgYy86ek7A@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 3/7] adv_monitor: Implement RegisterMonitor() To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.60 / 15.00 / 200.00 X-Rspamd-Queue-Id: 101B140942 X-Rspamd-UID: baaab8 Hi Miao, On Tue, Aug 18, 2020 at 3:31 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > This implements the RegisterMonitor() method handler of ADV monitor > manager interface. > > The following tests were performed. > - Issue a RegisterMonitor() call with a valid path and expect a > success as return. > - Issue a RegisterMonitor() call with an invalid path and expect > org.bluez.Error.InvalidArguments as return. > - Issue two Registermonitor() calls with the same path and expect > org.bluez.Error.AlreadyExists. > - Verify the values of the registered paths with logging. > - Verify D-Bus disconnection callback was triggered when the client detach > from D-Bus. > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > > src/adv_monitor.c | 167 +++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 166 insertions(+), 1 deletion(-) > > diff --git a/src/adv_monitor.c b/src/adv_monitor.c > index 4d02237e8..3d27ad18b 100644 > --- a/src/adv_monitor.c > +++ b/src/adv_monitor.c > @@ -22,7 +22,9 @@ > #endif > > #define _GNU_SOURCE > +#include <errno.h> > #include <stdint.h> > +#include <string.h> > > #include <glib.h> > #include <dbus/dbus.h> > @@ -34,7 +36,9 @@ > #include "adapter.h" > #include "dbus-common.h" > #include "log.h" > +#include "src/error.h" > #include "src/shared/mgmt.h" > +#include "src/shared/queue.h" > #include "src/shared/util.h" > > #include "adv_monitor.h" > @@ -52,12 +56,170 @@ struct btd_adv_monitor_manager { > uint16_t max_num_monitors; > uint8_t max_num_patterns; > > + struct queue *apps; /* apps who registered for Adv monitoring */ > }; > > +struct adv_monitor_app { > + struct btd_adv_monitor_manager *manager; > + char *owner; > + char *path; > + > + DBusMessage *reg; > + GDBusClient *client; > +}; > + > +struct app_match_data { > + const char *owner; > + const char *path; > +}; > + > +/* Replies to an app's D-Bus message and unref it */ > +static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) > +{ > + if (!app || !app->reg || !reply) > + return; > + > + g_dbus_send_message(btd_get_dbus_connection(), reply); > + dbus_message_unref(app->reg); > + app->reg = NULL; > +} > + > +/* Destroys an app object along with related D-Bus handlers */ > +static void app_destroy(void *data) > +{ > + struct adv_monitor_app *app = data; > + > + if (!app) > + return; > + > + DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); > + > + if (app->reg) { > + app_reply_msg(app, btd_error_failed(app->reg, > + "Adv Monitor app destroyed")); > + } > + > + if (app->client) { > + g_dbus_client_set_disconnect_watch(app->client, NULL, NULL); > + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, > + NULL); > + g_dbus_client_set_ready_watch(app->client, NULL, NULL); > + g_dbus_client_unref(app->client); > + app->client = NULL; > + } > + > + g_free(app->owner); > + app->owner = NULL; > + g_free(app->path); > + app->path = NULL; Same comment as before, if the whole object would be free then there is no need to reset each individual field. > + > + g_free(app); > +} > + > +/* Handles a D-Bus disconnection event of an app */ > +static void app_disconnect_cb(DBusConnection *conn, void *user_data) > +{ > + struct adv_monitor_app *app = user_data; > + > + btd_info(app->manager->adapter_id, "Adv Monitor app %s disconnected " > + "from D-Bus", app->owner); > + if (app && queue_remove(app->manager->apps, app)) > + app_destroy(app); > +} > + > +/* Creates an app object, initiates it and sets D-Bus event handlers */ > +static struct adv_monitor_app *app_create(DBusConnection *conn, > + const char *sender, const char *path, > + struct btd_adv_monitor_manager *manager) > +{ > + struct adv_monitor_app *app; > + > + if (!path || !sender || !manager) > + return NULL; > + > + app = g_new0(struct adv_monitor_app, 1); Please use new0 instead of g_new0 in new code. > + if (!app) > + return NULL; > + > + app->owner = g_strdup(sender); > + app->path = g_strdup(path); > + app->manager = manager; > + app->reg = NULL; > + > + app->client = g_dbus_client_new(conn, sender, path); > + if (!app->client) { > + app_destroy(app); > + return NULL; > + } > + > + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); > + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); > + g_dbus_client_set_ready_watch(app->client, NULL, NULL); > + > + return app; > +} > + > +/* Matches an app based on its owner and path */ > +static bool app_match(const void *a, const void *b) > +{ > + const struct adv_monitor_app *app = a; > + const struct app_match_data *match = b; > + > + if (match->owner && strcmp(app->owner, match->owner)) > + return false; > + > + if (match->path && strcmp(app->path, match->path)) > + return false; > + > + return true; > +} > + > +/* Handles a RegisterMonitor D-Bus call */ > +static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, > + void *user_data) > +{ > + DBusMessageIter args; > + struct app_match_data match; > + struct adv_monitor_app *app; > + struct btd_adv_monitor_manager *manager = user_data; > + > + if (!dbus_message_iter_init(msg, &args)) > + return btd_error_invalid_args(msg); > + > + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) > + return btd_error_invalid_args(msg); > + > + dbus_message_iter_get_basic(&args, &match.path); > + > + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) > + return btd_error_invalid_args(msg); > + > + match.owner = dbus_message_get_sender(msg); > + > + if (queue_find(manager->apps, app_match, &match)) > + return btd_error_already_exists(msg); > + > + app = app_create(conn, match.owner, match.path, manager); > + if (!app) { > + btd_error(manager->adapter_id, > + "Failed to reserve %s for Adv Monitor app %s", > + match.path, match.owner); > + return btd_error_failed(msg, > + "Failed to create Adv Monitor app"); > + } > + > + queue_push_tail(manager->apps, app); > + > + btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", > + match.path, match.owner); > + > + return dbus_message_new_method_return(msg); > +} > + > static const GDBusMethodTable adv_monitor_methods[] = { > { GDBUS_METHOD("RegisterMonitor", > GDBUS_ARGS({ "application", "o" }), > - NULL, NULL) }, > + NULL, register_monitor) }, > { GDBUS_ASYNC_METHOD("UnregisterMonitor", > GDBUS_ARGS({ "application", "o" }), > NULL, NULL) }, > @@ -157,6 +319,7 @@ static struct btd_adv_monitor_manager *manager_new( > manager->mgmt = mgmt_ref(mgmt); > manager->adapter_id = btd_adapter_get_index(adapter); > manager->path = g_strdup(adapter_get_path(manager->adapter)); > + manager->apps = queue_new(); > > return manager; > } > @@ -170,6 +333,8 @@ static void manager_free(struct btd_adv_monitor_manager *manager) > g_free(manager->path); > manager->path = NULL; > > + queue_destroy(manager->apps, app_destroy); > + > g_free(manager); > } > > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0PM3EyfBV1+GwgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 08 Sep 2020 19:36:39 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UIVRECfBV1/fagEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 08 Sep 2020 19:36:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 07FB3A0218; Tue, 8 Sep 2020 19:36:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731733AbgIHRgY (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 8 Sep 2020 13:36:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728442AbgIHRgK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 8 Sep 2020 13:36:10 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70EA0C061573 for <linux-bluetooth@vger.kernel.org>; Tue, 8 Sep 2020 10:36:10 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id y6so17221745oie.5 for <linux-bluetooth@vger.kernel.org>; Tue, 08 Sep 2020 10:36:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6IT6jlx4ooAJTfGdAfVsWYOzy6thYmHOEjy7EfS+raM=; b=tV/rijj+RqvYfflo+G1ygAlNTRK9LxhqiVnDSwsZV1oeI2brPk/K8uGynRgcf3xulM ORbpSBTyudFpZFo2+JQq1gMFnYo5E73n8r+UuHMMuI4yaRGfn9z2LgIzwnAea750SntY N+WjBEYVv0VnA652C68zmniL0PP2iBZDbJFM9y8qif+srCeQzL/ew7CPN2S0RYgL3c9g JrlzDJ/DWvwy8HA7YJza6UuciHcBFXxMCG+9gfcqM8GUjhKp3PpT3s9SrNclJ/weRayX 0SMDkAeMZVOqk71Oyc6cC8CIqacIhXXiubl+yQQ/JHnsCkhe2iFz4KTVphu1JTS4aCLJ zMtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6IT6jlx4ooAJTfGdAfVsWYOzy6thYmHOEjy7EfS+raM=; b=bsS7UG8rgoK6exHM4sAHP2RfybuEVPtZSIGk2V7KyjDqc8e1CRv/c7F3M5MkWb+NN/ KQd8/WLILq7lZTxJdLSdw9M4zyMlbq+2/V/CAMiu3rrAuws3EUYQIQ8/DMuWF80DoIkk lppa5vUnn6u69dj8gh/wjDhxOmzydy+qg634LwpZU55uU6aUs9pqXoeuZZcGsO/xbeNt 13Au7BJZXej77HdUhWwp5pAYtINOL6Q1zkX39I9NZMAkCQ8sUt91BUfZnni+W0JhdZPd RUctybxdwAgEAj2egyM/BQz+/PSQWkqfFtsFT2ICmhAc+l8+uVxemVx30EfFNapXvR7X YBng== X-Gm-Message-State: AOAM533yC5alKdRb0/R+41osny8q7fm7SXFfVeReVdLzo8nR3d3hpVNV cMfvnLnc6hbCgIEqAqdxQpe4CR5ZJru/I5jc2mo= X-Google-Smtp-Source: ABdhPJxzge0xo+XdcTdL1RahHz2/c3PmIxbsh1LNVyO/sMEacCiVuXnCKk930XipC4ZsIfCk2/++lbsO+2s366Ke5FA= X-Received: by 2002:aca:1b01:: with SMTP id b1mr14877oib.137.1599586569619; Tue, 08 Sep 2020 10:36:09 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <20200818152612.BlueZ.v1.6.I47744c7eef31f44cf393dea2b3e437d7b41cef79@changeid> In-Reply-To: <20200818152612.BlueZ.v1.6.I47744c7eef31f44cf393dea2b3e437d7b41cef79@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 8 Sep 2020 10:35:58 -0700 Message-ID: <CABBYNZJtWjhXZ9YSPLLiuP_KTzfCxox7KCOtJJvgnHY8PMZQwg@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 6/7] adv_monitor: Handle D-Bus proxy event of an ADV monitor To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.77 / 15.00 / 200.00 X-Rspamd-Queue-Id: 07FB3A0218 X-Rspamd-UID: c29599 Hi Miao, On Tue, Aug 18, 2020 at 3:31 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > This adds two handlers, one for adding and one for removing, of D-Bus proxy > events. The handler of property changes is set to NULL as intended, > since for simplicity no further changes on monitor's properties would > affect the ongoing monitoring. > > The following test steps were performed with bluetoothctl. > - After registering the root path, expose two monitors and verify that > the proxy added event are received. > - Have two monitors added, unexpose the monitors, and verify that the > proxy removed events are received for those two monitors. > - Have two monitors added, unregister the monitors and verify that the > proxy removed events are received for those two monitors. > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > --- > > src/adv_monitor.c | 492 ++++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 479 insertions(+), 13 deletions(-) > > diff --git a/src/adv_monitor.c b/src/adv_monitor.c > index b5ea5ee99..23fbc2b45 100644 > --- a/src/adv_monitor.c > +++ b/src/adv_monitor.c > @@ -37,14 +37,23 @@ > #include "dbus-common.h" > #include "log.h" > #include "src/error.h" > +#include "src/shared/ad.h" > #include "src/shared/mgmt.h" > #include "src/shared/queue.h" > #include "src/shared/util.h" > > #include "adv_monitor.h" > > +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" > #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" > > +#define ADV_MONITOR_UNSET_RSSI 127 /* dBm */ > +#define ADV_MONITOR_MAX_RSSI 20 /* dBm */ > +#define ADV_MONITOR_MIN_RSSI -127 /* dBm */ > +#define ADV_MONITOR_UNSET_TIMER 0 /* second */ > +#define ADV_MONITOR_MIN_TIMER 1 /* second */ > +#define ADV_MONITOR_MAX_TIMER 300 /* second */ > + > struct btd_adv_monitor_manager { > struct btd_adapter *adapter; > struct mgmt *mgmt; > @@ -66,6 +75,43 @@ struct adv_monitor_app { > > DBusMessage *reg; > GDBusClient *client; > + > + struct queue *monitors; > +}; > + > +enum monitor_type { > + MONITOR_TYPE_NONE, > + MONITOR_TYPE_OR_PATTERNS, > +}; > + > +enum monitor_state { > + MONITOR_STATE_NEW, /* New but not yet init'ed with actual values */ > + MONITOR_STATE_FAILED, /* Failed to be init'ed */ > + MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ > + MONITOR_STATE_HONORED, /* Accepted by kernel */ > +}; > + > +struct pattern { > + uint8_t ad_type; > + uint8_t offset; > + uint8_t length; > + uint8_t value[BT_AD_MAX_DATA_LEN]; > +}; > + > +struct adv_monitor { > + struct adv_monitor_app *app; > + GDBusProxy *proxy; > + char *path; > + > + enum monitor_state state; /* MONITOR_STATE_* */ > + > + int8_t high_rssi; /* high RSSI threshold */ > + uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ > + int8_t low_rssi; /* low RSSI threshold */ > + uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ > + > + enum monitor_type type; /* MONITOR_TYPE_* */ > + struct queue *patterns; > }; > > struct app_match_data { > @@ -73,6 +119,14 @@ struct app_match_data { > const char *path; > }; > > +const struct adv_monitor_type { > + enum monitor_type type; > + const char *name; > +} supported_types[] = { > + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, > + { }, > +}; > + > /* Replies to an app's D-Bus message and unref it */ > static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) > { > @@ -84,6 +138,52 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) > app->reg = NULL; > } > > +/* Frees a pattern */ > +static void pattern_free(void *data) > +{ > + struct pattern *pattern = data; > + > + if (!pattern) > + return; > + > + g_free(pattern); > +} > + > +/* Frees a monitor object */ > +static void monitor_free(void *data) > +{ > + struct adv_monitor *monitor = data; > + > + if (!monitor) > + return; > + > + monitor->app = NULL; > + g_dbus_proxy_unref(monitor->proxy); > + monitor->proxy = NULL; > + g_free(monitor->path); > + monitor->path = NULL; > + > + queue_destroy(monitor->patterns, pattern_free); > + monitor->patterns = NULL; > + > + g_free(monitor); > +} > + > +/* Calls Release() method of the remote Adv Monitor */ > +static void monitor_release(void *data, void *user_data) > +{ > + struct adv_monitor *monitor = data; > + > + if (!monitor) > + return; > + > + DBG("Calling Release() on Adv Monitor of owner %s at path %s", > + monitor->app->owner, monitor->path); > + > + g_dbus_proxy_method_call(monitor->proxy, "Release", NULL, NULL, NULL, > + NULL); > +} > + > /* Destroys an app object along with related D-Bus handlers */ > static void app_destroy(void *data) > { > @@ -94,6 +194,9 @@ static void app_destroy(void *data) > > DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); > > + queue_foreach(app->monitors, monitor_release, NULL); > + queue_destroy(app->monitors, monitor_free); > + > if (app->reg) { > app_reply_msg(app, btd_error_failed(app->reg, > "Adv Monitor app destroyed")); > @@ -139,6 +242,372 @@ static void app_ready_cb(GDBusClient *client, void *user_data) > app_reply_msg(app, dbus_message_new_method_return(app->reg)); > } > > +/* Allocates an Adv Monitor */ > +static struct adv_monitor *monitor_new(struct adv_monitor_app *app, > + GDBusProxy *proxy) > +{ > + struct adv_monitor *monitor; > + > + if (!app || !proxy) > + return NULL; > + > + monitor = g_new0(struct adv_monitor, 1); new0 > + if (!monitor) > + return NULL; > + > + monitor->app = app; > + monitor->proxy = g_dbus_proxy_ref(proxy); > + monitor->path = g_strdup(g_dbus_proxy_get_path(proxy)); > + > + monitor->state = MONITOR_STATE_NEW; > + > + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; > + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; > + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; > + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; > + > + monitor->type = MONITOR_TYPE_NONE; > + monitor->patterns = NULL; > + > + return monitor; > +} > + > +/* Matches a monitor based on its D-Bus path */ > +static bool monitor_match(const void *a, const void *b) > +{ > + const GDBusProxy *proxy = b; > + const struct adv_monitor *monitor = a; > + > + if (!proxy || !monitor) > + return false; > + > + if (strcmp(g_dbus_proxy_get_path(proxy), monitor->path) != 0) > + return false; > + > + return true; > +} > + > +/* Retrieves Type from the remote Adv Monitor object, verifies the value and > + * update the local Adv Monitor > + */ > +static bool parse_monitor_type(struct adv_monitor *monitor, const char *path) > +{ > + DBusMessageIter iter; > + const struct adv_monitor_type *t; > + const char *type_str; > + uint16_t adapter_id = monitor->app->manager->adapter_id; > + > + if (!g_dbus_proxy_get_property(monitor->proxy, "Type", &iter)) { > + btd_error(adapter_id, "Failed to retrieve property Type from " > + "the Adv Monitor at path %s", path); > + return false; > + } > + > + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) > + goto failed; > + > + dbus_message_iter_get_basic(&iter, &type_str); > + > + for (t = supported_types; t->name; t++) { > + if (strcmp(t->name, type_str) == 0) { > + monitor->type = t->type; > + return true; > + } > + } > + > +failed: > + btd_error(adapter_id, "Invalid argument of property Type of the Adv " > + "Monitor at path %s", path); > + > + return false; > +} > + > +/* Retrieves RSSIThresholdsAndTimers from the remote Adv Monitor object, > + * verifies the values and update the local Adv Monitor > + */ > +static bool parse_rssi_and_timeout(struct adv_monitor *monitor, > + const char *path) > +{ > + DBusMessageIter prop_struct, iter; > + int16_t h_rssi, l_rssi; > + uint16_t h_rssi_timer, l_rssi_timer; > + uint16_t adapter_id = monitor->app->manager->adapter_id; > + > + /* Property RSSIThresholdsAndTimers is optional */ > + if (!g_dbus_proxy_get_property(monitor->proxy, > + "RSSIThresholdsAndTimers", > + &prop_struct)) { > + DBG("Adv Monitor at path %s provides no RSSI thresholds and " > + "timeouts", path); > + return true; > + } > + > + if (dbus_message_iter_get_arg_type(&prop_struct) != DBUS_TYPE_STRUCT) > + goto failed; > + > + dbus_message_iter_recurse(&prop_struct, &iter); > + > + /* Extract HighRSSIThreshold */ > + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) > + goto failed; > + dbus_message_iter_get_basic(&iter, &h_rssi); > + if (!dbus_message_iter_next(&iter)) > + goto failed; > + > + /* Extract HighRSSIThresholdTimer */ > + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) > + goto failed; > + dbus_message_iter_get_basic(&iter, &h_rssi_timer); > + if (!dbus_message_iter_next(&iter)) > + goto failed; > + > + /* Extract LowRSSIThreshold */ > + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) > + goto failed; > + dbus_message_iter_get_basic(&iter, &l_rssi); > + if (!dbus_message_iter_next(&iter)) > + goto failed; > + > + /* Extract LowRSSIThresholdTimer */ > + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) > + goto failed; > + dbus_message_iter_get_basic(&iter, &l_rssi_timer); > + > + /* Verify the values of RSSIs and their timers. For simplicity, we > + * enforce the all-or-none rule to these fields. In other words, either > + * all are set to the unset values or all are set within valid ranges. > + */ > + if (h_rssi == ADV_MONITOR_UNSET_RSSI && > + l_rssi == ADV_MONITOR_UNSET_RSSI && > + h_rssi_timer == ADV_MONITOR_UNSET_TIMER && > + l_rssi_timer == ADV_MONITOR_UNSET_TIMER) { > + goto done; > + } > + > + if (h_rssi < ADV_MONITOR_MIN_RSSI || h_rssi > ADV_MONITOR_MAX_RSSI || > + l_rssi < ADV_MONITOR_MIN_RSSI || > + l_rssi > ADV_MONITOR_MAX_RSSI || h_rssi <= l_rssi) { > + goto failed; > + } > + > + if (h_rssi_timer < ADV_MONITOR_MIN_TIMER || > + h_rssi_timer > ADV_MONITOR_MAX_TIMER || > + l_rssi_timer < ADV_MONITOR_MIN_TIMER || > + l_rssi_timer > ADV_MONITOR_MAX_TIMER) { > + goto failed; > + } > + > + monitor->high_rssi = h_rssi; > + monitor->low_rssi = l_rssi; > + monitor->high_rssi_timeout = h_rssi_timer; > + monitor->low_rssi_timeout = l_rssi_timer; > + > +done: > + DBG("Adv Monitor at %s initiated with high RSSI threshold %d, high " > + "RSSI threshold timeout %d, low RSSI threshold %d, low RSSI " > + "threshold timeout %d", path, monitor->high_rssi, > + monitor->high_rssi_timeout, monitor->low_rssi, > + monitor->low_rssi_timeout); > + > + return true; > + > +failed: > + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; > + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; > + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; > + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; > + > + btd_error(adapter_id, "Invalid argument of property " > + "RSSIThresholdsAndTimers of the Adv Monitor at path %s", > + path); > + > + return false; > +} > + > +/* Retrieves Patterns from the remote Adv Monitor object, verifies the values > + * and update the local Adv Monitor > + */ > +static bool parse_patterns(struct adv_monitor *monitor, const char *path) > +{ > + DBusMessageIter array, array_iter; > + uint16_t num_patterns = 0; > + uint16_t adapter_id = monitor->app->manager->adapter_id; > + > + if (!g_dbus_proxy_get_property(monitor->proxy, "Patterns", &array)) { > + btd_error(adapter_id, "Failed to retrieve property Patterns " > + "from the Adv Monitor at path %s", path); > + return false; > + } > + > + monitor->patterns = queue_new(); > + > + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY || > + dbus_message_iter_get_element_type(&array) != > + DBUS_TYPE_STRUCT) { > + goto failed; > + } > + > + dbus_message_iter_recurse(&array, &array_iter); > + > + while (dbus_message_iter_get_arg_type(&array_iter) == > + DBUS_TYPE_STRUCT) { > + int value_len; > + uint8_t *value; > + uint8_t offset, ad_type; > + struct pattern *pattern; > + DBusMessageIter struct_iter, value_iter; > + > + dbus_message_iter_recurse(&array_iter, &struct_iter); > + > + // Extract start position > + if (dbus_message_iter_get_arg_type(&struct_iter) != > + DBUS_TYPE_BYTE) { > + goto failed; > + } > + dbus_message_iter_get_basic(&struct_iter, &offset); > + if (!dbus_message_iter_next(&struct_iter)) > + goto failed; > + > + // Extract AD data type > + if (dbus_message_iter_get_arg_type(&struct_iter) != > + DBUS_TYPE_BYTE) { > + goto failed; > + } > + dbus_message_iter_get_basic(&struct_iter, &ad_type); > + if (!dbus_message_iter_next(&struct_iter)) > + goto failed; > + > + // Extract value of a pattern > + if (dbus_message_iter_get_arg_type(&struct_iter) != > + DBUS_TYPE_ARRAY) { > + goto failed; > + } > + dbus_message_iter_recurse(&struct_iter, &value_iter); > + dbus_message_iter_get_fixed_array(&value_iter, &value, > + &value_len); > + > + // Verify the values > + if (offset > BT_AD_MAX_DATA_LEN - 1) > + goto failed; > + > + if (ad_type > BT_AD_3D_INFO_DATA && > + ad_type != BT_AD_MANUFACTURER_DATA > + || ad_type < BT_AD_FLAGS) { > + goto failed; > + } > + > + if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) > + goto failed; > + > + pattern = g_new0(struct pattern, 1); new0 > + if (!pattern) > + goto failed; > + > + pattern->ad_type = ad_type; > + pattern->offset = offset; > + pattern->length = value_len; > + g_memmove(pattern->value, value, pattern->length); This looks wrong, we shouldn't be changing the memory value points to, this might be equivalent to memcpy so Id just use that instead. > + > + queue_push_tail(monitor->patterns, pattern); > + > + dbus_message_iter_next(&array_iter); > + } > + > + /* There must be at least one pattern. */ > + if (queue_isempty(monitor->patterns)) > + goto failed; > + > + return true; > + > +failed: > + queue_destroy(monitor->patterns, pattern_free); > + monitor->patterns = NULL; > + > + btd_error(adapter_id, "Invalid argument of property Patterns of the " > + "Adv Monitor at path %s", path); > + > + return false; > +} > + > +/* Processes the content of the remote Adv Monitor */ > +static bool monitor_process(struct adv_monitor *monitor, > + struct adv_monitor_app *app) > +{ > + const char *path = g_dbus_proxy_get_path(monitor->proxy); > + > + monitor->state = MONITOR_STATE_FAILED; > + > + if (!parse_monitor_type(monitor, path)) > + goto done; > + > + if (!parse_rssi_and_timeout(monitor, path)) > + goto done; > + > + if (monitor->type == MONITOR_TYPE_OR_PATTERNS && > + parse_patterns(monitor, path)) { > + monitor->state = MONITOR_STATE_INITED; > + } > + > +done: > + return monitor->state != MONITOR_STATE_FAILED; > +} > + > +/* Handles an Adv Monitor D-Bus proxy added event */ > +static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) > +{ > + struct adv_monitor *monitor; > + struct adv_monitor_app *app = user_data; > + uint16_t adapter_id = app->manager->adapter_id; > + const char *path = g_dbus_proxy_get_path(proxy); > + const char *iface = g_dbus_proxy_get_interface(proxy); > + > + if (strcmp(iface, ADV_MONITOR_INTERFACE) != 0 || > + !g_str_has_prefix(path, app->path)) { > + return; > + } > + > + if (queue_find(app->monitors, monitor_match, proxy)) { > + btd_error(adapter_id, "Adv Monitor proxy already exists with " > + "path %s", path); > + return; > + } > + > + monitor = monitor_new(app, proxy); > + if (!monitor) { > + btd_error(adapter_id, "Failed to allocate an Adv Monitor for " > + "the object at %s", path); > + return; > + } > + > + if (!monitor_process(monitor, app)) { > + monitor_release(monitor, NULL); > + monitor_free(monitor); > + DBG("Adv Monitor at path %s released due to invalid content", > + path); > + return; > + } > + > + queue_push_tail(app->monitors, monitor); > + > + DBG("Adv Monitor allocated for the object at path %s", path); > +} > + > +/* Handles the removal of an Adv Monitor D-Bus proxy */ > +static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) > +{ > + struct adv_monitor *monitor; > + struct adv_monitor_app *app = user_data; > + > + monitor = queue_remove_if(app->monitors, monitor_match, proxy); > + if (monitor) { > + DBG("Adv Monitor removed for the object at path %s", > + monitor->path); > + > + /* The object was gone, so we don't need to call Release() */ > + monitor_free(monitor); > + } > +} > + > /* Creates an app object, initiates it and sets D-Bus event handlers */ > static struct adv_monitor_app *app_create(DBusConnection *conn, > DBusMessage *msg, const char *sender, > @@ -165,8 +634,17 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, > return NULL; > } > > + app->monitors = queue_new(); > + > g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); > - g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); > + > + /* Note that any property changes on a monitor object would not affect > + * the content of the corresponding monitor. > + */ > + g_dbus_client_set_proxy_handlers(app->client, monitor_proxy_added_cb, > + monitor_proxy_removed_cb, NULL, > + app); > + > g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); > > app->reg = dbus_message_ref(msg); > @@ -273,18 +751,6 @@ static const GDBusMethodTable adv_monitor_methods[] = { > { } > }; > > -enum monitor_type { > - MONITOR_TYPE_OR_PATTERNS, > -}; > - > -const struct adv_monitor_type { > - enum monitor_type type; > - const char *name; > -} supported_types[] = { > - { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, > - { }, > -}; > - > /* Gets SupportedMonitorTypes property */ > static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, > DBusMessageIter *iter, > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4N7UOT3CV18biwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 08 Sep 2020 19:41:17 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +NTnNj3CV1+bdgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 08 Sep 2020 19:41:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DB1B0A0B3E; Tue, 8 Sep 2020 19:41:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732014AbgIHRkW (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 8 Sep 2020 13:40:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731995AbgIHRkG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 8 Sep 2020 13:40:06 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB828C061573 for <linux-bluetooth@vger.kernel.org>; Tue, 8 Sep 2020 10:40:05 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id x19so17261139oix.3 for <linux-bluetooth@vger.kernel.org>; Tue, 08 Sep 2020 10:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ePGggpstFNkFEEnTmmuscQ1dhqKn/sONJ384rV4WzoA=; b=bOnuZLcBaNNO2Ev4vohQEajD0KiV6UmoWjrGkPUlfpamdosEbQpIQUSV8G58euzytQ uFlyS8sNk11PsKByyYgr8k9FzLxHHQmXorG7dH4WE7YenMUTtPTk8QnDVvMZyZU5vsTc BOyacvRCd0dFC2jozjdY9wMyP9e3t6x+VMhv7pQvQw+S8ZNE0pGdtuXujOfUCxtFjDA9 aQqxklNCu725PSJxxhxl2TKuJaQCrbYXQ/MjrtG8y/ITAcFIa9irOLq1U9vy0PiX1HXF 0kquodIA4ecnXhWvGjKqk8yppZbxyvTBywnYDUcgWfhNTARRYIRQTCx/GcYRJkOnhfWm m3PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ePGggpstFNkFEEnTmmuscQ1dhqKn/sONJ384rV4WzoA=; b=sit568Bu6BDUnEH0txjqcSLwdFm/RZO/0XTgKhB3k+444MMuES7jQCtj2+Fl9jQ7e4 xvkvnxYsja2X8ziP+NZuUaMIs02HGKmcS3dKCApUWhr3hbkwix2gPXk2DCwom3ORM3I3 QmltBgmEIgioGghUs5CYrtpMJklQzPKBZQfdbR0py1fCxVckPzEKqCl8Br+7pFE+ue8j EpWhfQDwC8KXaRiPSq0aZS0KyDfy7JJ5wWjkzCyPaJYaDdnuCJl43+jeobAeHtlhJHWQ FdKDe/9fGDrDCL9dHZWE4kQ77SGvmdhOi4z2H6922ug+tXJzmLnRnM+j9xVKamXDaiG2 cRIQ== X-Gm-Message-State: AOAM532U4gDb4gr3qYuMbAnic1TTpJAiC3dd8Lx5wTRQQEdQUIc/Fgwd zR1qxDIjKX46KVzREn+T4c4/csHHcTed4t0seLI= X-Google-Smtp-Source: ABdhPJx95TC36KFLhC2TPIH7NxoPHbzdrgeC9JWqLpINuaR9t+DkWqw55xQI0hzrjsHFGNb0WZ2MTWtrYErvBTHvui0= X-Received: by 2002:aca:aad0:: with SMTP id t199mr60893oie.48.1599586805263; Tue, 08 Sep 2020 10:40:05 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <20200818152612.BlueZ.v1.7.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> In-Reply-To: <20200818152612.BlueZ.v1.7.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 8 Sep 2020 10:39:54 -0700 Message-ID: <CABBYNZLCZ9FCEH=Z3sHzsg-jw_4CvnbMxBNbQem=x0JE_+y7NA@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 7/7] doc/advertisement-monitor-api: Update Advertisement Monitor API description To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.44 / 15.00 / 200.00 X-Rspamd-Queue-Id: DB1B0A0B3E X-Rspamd-UID: ea1633 Hi Miao, On Tue, Aug 18, 2020 at 3:34 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > This modifies the following description to Advertisement Monitor API. > - Add org.bluez.Error.Failed to RegisterMonitor() method. > - Add more description about the usage of RegisterMonitor() and > UnregisterMonitor() methods. > - Add description about the ranges for the fields in property > RSSIThresholdsAndTimers. > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > --- > > doc/advertisement-monitor-api.txt | 34 +++++++++++++++++++++++-------- > 1 file changed, 25 insertions(+), 9 deletions(-) > > diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt > index 74adbfae9..e09b6fd25 100644 > --- a/doc/advertisement-monitor-api.txt > +++ b/doc/advertisement-monitor-api.txt > @@ -49,7 +49,7 @@ Properties string Type [read-only] > org.bluez.AdvertisementMonitorManager1 for the available > options. > > - (Int16, Uint16, Int16, Uint16) RSSIThreshholdsAndTimers [read-only, optional] > + (Int16, Uint16, Int16, Uint16) RSSIThresholdsAndTimers [read-only, optional] > > This contains HighRSSIThreshold, HighRSSIThresholdTimer, > LowRSSIThreshold, LowRSSIThresholdTimer in order. The > @@ -66,7 +66,11 @@ Properties string Type [read-only] > RSSIs of the received advertisement(s) during > LowRSSIThresholdTimer do not reach LowRSSIThreshold. > > - array{(uint8, uint8, string)} Patterns [read-only, optional] > + The valid range of a RSSI is -127 to +20 dBm while 127 > + dBm indicates unset. The valid range of a timer is 1 to > + 300 seconds while 0 indicates unset. > + > + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] > > If Type is set to 0x01, this must exist and has at least > one entry in the array. > @@ -80,8 +84,9 @@ Properties string Type [read-only] > See https://www.bluetooth.com/specifications/ > assigned-numbers/generic-access-profile/ for > the possible allowed value. > - string content_of_pattern > - This is the value of the pattern. > + array{byte} content_of_pattern > + This is the value of the pattern. The maximum > + length of the bytes is 31. > > Advertisement Monitor Manager hierarchy > ======================================= > @@ -91,20 +96,31 @@ Object path /org/bluez/{hci0,hci1,...} > > Methods void RegisterMonitor(object application) > > - This registers a hierarchy of advertisement monitors. > + This registers the root path of a hierarchy of > + advertisement monitors. > The application object path together with the D-Bus > system bus connection ID define the identification of > the application registering advertisement monitors. > + Once a root path is registered by a client via this > + method, the client can freely expose/unexpose > + advertisement monitors without re-registering the root > + path again. After use, the client should call > + UnregisterMonitor() method to invalidate the > + advertisement monitors. > > Possible errors: org.bluez.Error.InvalidArguments > org.bluez.Error.AlreadyExists > + org.bluez.Error.Failed > > void UnregisterMonitor(object application) > > - This unregisters advertisement monitors that have been > - previously registered. The object path parameter must > - match the same value that has been used on > - registration. > + This unregisters a hierarchy of advertisement monitors > + that has been previously registered. The object path > + parameter must match the same value that has been used > + on registration. Upon unregistration, the advertisement > + monitor(s) should expect to receive Release() method as > + the signal that the advertisement monitor(s) has been > + deactivated. > > Possible errors: org.bluez.Error.InvalidArguments > org.bluez.Error.DoesNotExist > -- > 2.26.2 These are still experimental so you will need to use EXPERIMENTAL version when declaring the methods/properties so it only gets enabled when the experimental flag is passed to bluetoothd. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QJixLxvnV18huwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 08 Sep 2020 22:18:35 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 0KNPLRvnV1/J7AAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 08 Sep 2020 22:18:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3E4BC40866; Tue, 8 Sep 2020 22:18:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731230AbgIHUHT (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 8 Sep 2020 16:07:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730240AbgIHUHP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 8 Sep 2020 16:07:15 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B33C1C061573; Tue, 8 Sep 2020 13:07:14 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id f18so61712pfa.10; Tue, 08 Sep 2020 13:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J2k9xpa9l+tbRJ/+vvItQDXmC64/jEuH8zJsr0tf6oA=; b=CrmexfeQlkBwXK5cG+ePO2sdpsUPZnONXxWr/hg8KJjUjcaV7j/aXOa2NIQiuCONLC 90PGOGuGJhs+tn/dOaOybPQI3hkDS9/DYthQ4whqkws8ZDBOxHCqgZ9XQE/r1QO1SGHt X3nIm8ttt4u91GG04u4UY4Bz9DZFr8zMg4JqV2Hd+WSMRI7t2FqSQW3pqmmHs0NvrUia zwRwSHSpIbU9SQm2gT3tA6M+scVRa1erkkve0Ylf9GJqUJJOxh5ecCoK+RqswTulVpFI bKRF/HqLkmb2i/japcvxpqX7E6ulyFgq1VRhJcXTzZ77FJH0PuByZFK1tQlTpc1PoKty IXFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J2k9xpa9l+tbRJ/+vvItQDXmC64/jEuH8zJsr0tf6oA=; b=efQAlW8HF63VCa6F4rU2vQT476JUqY63uTwkyTbsEnNT+TolPp3D8nblkpKEnokPcF E0HspIzVt4Dkbv8nbpLfTrB/4eOu78G+T/urfDKbmICNMMtYOfDg9fHiOiTDkYA0pikf jKEGFDmc3ViXgIFCzC1ksE/ztBqSAsDlNJFiwIqq/x9nWkdCsZKFo3jv3hcgT9vbcAi6 VJdRAwuuv5sBR3j5h1ZlPCG8L1MmmhTWxZTZt3/pir9DgM0HnbLi61ElDCEO1Lk3RKNF XlZc3964Kec3swq6rwerFXFMGNP3E69OLpdqzUtguVgKRIYaZuhz3AkFkQyPEuUTt/Xr dDdg== X-Gm-Message-State: AOAM530Xo81Rne4sQfcR2XX3hUHEu1Uiha+hY/76F2YZhXpJwDs1rOR8 7YXWTioBLgPLQ9tdLBrp4g== X-Google-Smtp-Source: ABdhPJxwCwMDHBJXt83pjdnBKyh00EzfcLx4+iauDRFDYP1OihfBxFjkVtwmkrQFVz2ZgIbAEjY48w== X-Received: by 2002:a63:fd01:: with SMTP id d1mr319176pgh.350.1599595634182; Tue, 08 Sep 2020 13:07:14 -0700 (PDT) Received: from localhost.localdomain (n11212042027.netvigator.com. [112.120.42.27]) by smtp.gmail.com with ESMTPSA id y24sm237023pfn.161.2020.09.08.13.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 13:07:13 -0700 (PDT) From: Peilin Ye <yepeilin.cs@gmail.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Cc: Peilin Ye <yepeilin.cs@gmail.com>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, syzkaller-bugs@googlegroups.com Subject: [Linux-kernel-mentees] [PATCH] Bluetooth: Fix memory leak in read_adv_mon_features() Date: Tue, 8 Sep 2020 16:06:35 -0400 Message-Id: <20200908200635.1099360-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <00000000000033913705acedbd6b@google.com> References: <00000000000033913705acedbd6b@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.30 / 15.00 / 200.00 X-Rspamd-Queue-Id: 3E4BC40866 X-Rspamd-UID: 4ede65 read_adv_mon_features() is leaking memory. Free `rp` before returning. Fixes: e5e1e7fd470c ("Bluetooth: Add handler of MGMT_OP_READ_ADV_MONITOR_FEATURES") Reported-and-tested-by: syzbot+f7f6e564f4202d8601c6@syzkaller.appspotmail.com Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> --- net/bluetooth/mgmt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5bbe71002fb9..f96251f818fc 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -4157,7 +4157,7 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev, { struct adv_monitor *monitor = NULL; struct mgmt_rp_read_adv_monitor_features *rp = NULL; - int handle; + int handle, err; size_t rp_size = 0; __u32 supported = 0; __u16 num_handles = 0; @@ -4192,9 +4192,13 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev, if (num_handles) memcpy(&rp->handles, &handles, (num_handles * sizeof(u16))); - return mgmt_cmd_complete(sk, hdev->id, - MGMT_OP_READ_ADV_MONITOR_FEATURES, - MGMT_STATUS_SUCCESS, rp, rp_size); + err = mgmt_cmd_complete(sk, hdev->id, + MGMT_OP_READ_ADV_MONITOR_FEATURES, + MGMT_STATUS_SUCCESS, rp, rp_size); + + kfree(rp); + + return err; } static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev, -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oM27IaBTWF9OPgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 06:01:36 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id mEiRH6BTWF+IowAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 06:01:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6EC2EA0B0C; Wed, 9 Sep 2020 06:01:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725856AbgIIEB1 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 00:01:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725300AbgIIEB0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 00:01:26 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62CE0C061573 for <linux-bluetooth@vger.kernel.org>; Tue, 8 Sep 2020 21:01:24 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id u21so1501941eja.2 for <linux-bluetooth@vger.kernel.org>; Tue, 08 Sep 2020 21:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ICo08fkw0ndkMnrFj48qiB6kFz4pwYBOgvKGrVqQdYY=; b=AZNdVXrXydT18d0PINrbW86ZeKVXeKFGcF68K5ss5+t2cBrWm3OxeIpxiQCfmWxkMo 3umgOYZgEc0aIwrS7Z/fOqd+CL9NdWJVdVZavnKndmcTF7FTfGpEqt3grswQA5g57df3 yFWqkaYtQfBC42QGHlGB71Ia7NXprFIibICUhWybExL8gCm5ahwq9GONl04vcKT6xFSA PCqNBkFcRv3QESMabAUbDHxeFq1GbQ82ByMxLyidtLxPe+TGoEBBjkyY2TvN30FBBB9c u0+62S+dyLiQgrIueJW2/AaRaf7FzXxu4dAQtNa+BS8tuM5j7TWgBnI2sbFbdr3qNlqd 05iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ICo08fkw0ndkMnrFj48qiB6kFz4pwYBOgvKGrVqQdYY=; b=b0gNXUitWi9hMUwOxGkJAs+c4aH5aUSrBZmpx0kObnDuEI98Uw/WT2ALa42X/5hNSA RU4vu2qRXA69P88ouZnsiaYv/KFajNDYzZHj/O+hdJYIHQwpPf0PeuhMmli2rrdEOPUM Lr6MMMuIrKtNlro2hbrMfrv1iI7TbkjVACNeyNUWeFfIjy/8QaRCkGAkXuIQZd8wRpQg xY2GEu1FLFxB5wkLWCYDNpIbeSMcdSODFj4OR24LfAlkS/xQiOmIIlVY/CW2dgj6RXLE wv1FYpKqR7VpAso+PxaZsNDW7KlJJ9phZOGlBXW73rC6q0tr76yELPw52DQMWdYReUDr rNPg== X-Gm-Message-State: AOAM530+czMZ6NgTtgDTh0waPbBCfcKh8LqZOXWSu2cbn58ZbNZwMmVD EaV8kY7WkcIpf90ZorMylcYEiX/jR869o3ySv2EUWA== X-Google-Smtp-Source: ABdhPJw3OBoOxyLxGNY79DIw61cEMquS/zcLuesHD4fo6CzpBdlZQMEWMOFIbugDnxKT/vOSZwJJg6+auvnajyjUyiY= X-Received: by 2002:a17:906:9386:: with SMTP id l6mr1684312ejx.302.1599624083151; Tue, 08 Sep 2020 21:01:23 -0700 (PDT) MIME-Version: 1.0 References: <20200819121048.BlueZ.v1.1.I3a57ea1eb3e3f5b87abc44ea478fc83817627ffc@changeid> <20200819121048.BlueZ.v1.2.I045d6f668c141c6b834ba6b31fc81618c0a7b8e8@changeid> <CABBYNZLeqA=i_JdcJUD-Q-6p_8DtMpmmW=gg4yvQrJ77jRG4sw@mail.gmail.com> In-Reply-To: <CABBYNZLeqA=i_JdcJUD-Q-6p_8DtMpmmW=gg4yvQrJ77jRG4sw@mail.gmail.com> From: Yun-hao Chung <howardchung@google.com> Date: Wed, 9 Sep 2020 12:01:12 +0800 Message-ID: <CAPHZWUc0ZKcEwNcy5uzetyutszcQg16fa7_Ph9n3eRV0U6H-eQ@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 2/4] client: Implement more interfaces of ADV monitor in bluetoothctl To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Manish Mandlik <mmandlik@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: 6EC2EA0B0C X-Rspamd-UID: 375c08 Hi Luiz, Thanks for the comments. On Wed, Sep 9, 2020 at 1:06 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Howard, > > On Tue, Aug 18, 2020 at 9:15 PM Howard Chung <howardchung@google.com> wrote: > > > > This patch creates a submenu in bluetoothctl and implements several > > commands. > > > > new commands: > > [bluetooth]# menu advmon > > [bluetooth]# add-pattern-monitor or_patterns -10,10,-30,5 1,2,ab0011 > > Advertisement Monitor 0 added > > [bluetooth]# get-pattern-monitor all > > Advertisement Monitor 0 > > path: /org/bluez/adv_monitor_app/0 > > type: or_patterns > > rssi: > > high threshold: -10 > > high threshold timer: 10 > > low threshold: -30 > > low threshold timer: 5 > > pattern 1: > > start position: 1 > > AD data type: 2 > > content: ab0011 > > [bluetooth]# get-supported-info > > Supported Features: > > Supported Moniter Types: or_patterns > > [bluetooth]# remove-pattern-monitor 0 > > Monitor 0 deleted > > > > Signed-off-by: Howard Chung <howardchung@google.com> > > --- > > > > client/advertisement_monitor.c | 328 ++++++++++++++++++++++++++++++++- > > client/advertisement_monitor.h | 4 + > > client/main.c | 70 +++++++ > > 3 files changed, 399 insertions(+), 3 deletions(-) > > > > diff --git a/client/advertisement_monitor.c b/client/advertisement_monitor.c > > index bd2309537..ec8f23711 100644 > > --- a/client/advertisement_monitor.c > > +++ b/client/advertisement_monitor.c > > @@ -29,6 +29,7 @@ > > #include <string.h> > > > > #include "gdbus/gdbus.h" > > +#include "src/shared/ad.h" > > #include "src/shared/util.h" > > #include "src/shared/shell.h" > > #include "advertisement_monitor.h" > > @@ -36,6 +37,27 @@ > > #define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" > > #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" > > > > +struct rssi_setting { > > + int16_t high_threshold; > > + uint16_t high_timer; > > + int16_t low_threshold; > > + uint16_t low_timer; > > +}; > > + > > +struct pattern { > > + uint8_t start_pos; > > + uint8_t ad_data_type; > > + uint8_t content_len; > > + uint8_t content[BT_AD_MAX_DATA_LEN]; > > +}; > > + > > +struct adv_monitor { > > + uint8_t idx; > > + char *type; > > + struct rssi_setting *rssi; > > + GSList *patterns; > > +}; > > + > > struct adv_monitor_manager { > > GSList *supported_types; > > GSList *supported_features; > > @@ -43,6 +65,9 @@ struct adv_monitor_manager { > > gboolean app_registered; > > } manager = { NULL, NULL, NULL, FALSE }; > > > > +static uint8_t adv_mon_idx; > > +static GSList *adv_mons; > > + > > static void set_supported_list(GSList **list, DBusMessageIter *iter) > > { > > char *str; > > @@ -138,7 +163,10 @@ static void unregister_reply(DBusMessage *message, void *user_data) > > > > void adv_monitor_register_app(DBusConnection *conn) > > { > > - if (manager.supported_types == NULL || manager.app_registered == TRUE || > > + if (manager.app_registered == TRUE) { > > + bt_shell_printf("Advertisement Monitor already registered\n"); > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > + } else if (manager.supported_types == NULL || > > g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", > > register_setup, register_reply, > > NULL, NULL) == FALSE) { > > @@ -150,8 +178,10 @@ void adv_monitor_register_app(DBusConnection *conn) > > > > void adv_monitor_unregister_app(DBusConnection *conn) > > { > > - if (manager.app_registered == FALSE || > > - g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", > > + if (manager.app_registered == FALSE) { > > + bt_shell_printf("Advertisement Monitor not registered\n"); > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > + } else if (g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", > > unregister_setup, unregister_reply, > > NULL, NULL) == FALSE) { > > bt_shell_printf("Failed to unregister Advertisement Monitor\n"); > > @@ -159,3 +189,295 @@ void adv_monitor_unregister_app(DBusConnection *conn) > > } > > manager.app_registered = FALSE; > > } > > + > > +static void free_pattern(void *user_data) > > +{ > > + struct pattern *p = user_data; > > + > > + g_free(p); > > +} > > + > > +static void free_adv_monitor(void *user_data) > > +{ > > + struct adv_monitor *adv_monitor = user_data; > > + > > + g_free(adv_monitor->type); > > + g_free(adv_monitor->rssi); > > + g_slist_free_full(adv_monitor->patterns, free_pattern); > > + g_free(adv_monitor); > > +} > > + > > +static uint8_t str2bytearray(char *str, uint8_t *arr) > > +{ > > + int idx, len = strlen(str), arr_len = 0; > > + > > + if (len%2 != 0) > > + return 0; > > + > > + for (idx = 0; idx < len; idx += 2) { > > + if (sscanf(str+idx, "%2hhx", &arr[arr_len++]) < 1) > > + return 0; > > + } > > + return arr_len; > > +} > > + > > +static struct rssi_setting *parse_rssi(char *rssi_str) > > +{ > > + struct rssi_setting *rssi; > > + int16_t high_threshold, low_threshold; > > + uint16_t high_timer, low_timer; > > + > > + if (sscanf(rssi_str, "%hd,%hu,%hd,%hu", &high_threshold, &high_timer, > > + &low_threshold, &low_timer) < 4) > > + return NULL; > > + > > + rssi = g_malloc0(sizeof(struct rssi_setting)); > > + > > + if (!rssi) { > > + bt_shell_printf("Failed to allocate rssi_setting"); > > + bt_shell_noninteractive_quit(EXIT_FAILURE); > > + return NULL; > > + } > > + > > + rssi->high_threshold = high_threshold; > > + rssi->high_timer = high_timer; > > + rssi->low_threshold = low_threshold; > > + rssi->low_timer = low_timer; > > + > > + return rssi; > > +} > > + > > +static struct pattern *parse_pattern(char *pattern) > > +{ > > + uint8_t start_pos, ad_data_type; > > + char content_str[BT_AD_MAX_DATA_LEN]; > > + struct pattern *pat; > > + > > + if (sscanf(pattern, "%hhu,%hhu,%s", &start_pos, &ad_data_type, > > + content_str) < 3) > > + return NULL; > > + > > + pat = g_malloc0(sizeof(struct pattern)); > > + > > + if (!pat) { > > + bt_shell_printf("Failed to allocate pattern"); > > + bt_shell_noninteractive_quit(EXIT_FAILURE); > > + return NULL; > > + } > > + > > + pat->start_pos = start_pos; > > + pat->ad_data_type = ad_data_type; > > + pat->content_len = str2bytearray(content_str, pat->content); > > + if (pat->content_len == 0) { > > + free_pattern(pat); > > + return NULL; > > + } > > + > > + return pat; > > +} > > + > > +static GSList *parse_patterns(char *pattern_list[], int num) > > +{ > > + GSList *patterns = NULL; > > + int cnt; > > + > > + if (num == 0) { > > + bt_shell_printf("No pattern provided\n"); > > + return NULL; > > + } > > + > > + for (cnt = 0; cnt < num; cnt++) { > > + struct pattern *pattern; > > + > > + pattern = parse_pattern(pattern_list[cnt]); > > + if (pattern == NULL) { > > + g_slist_free_full(patterns, free_pattern); > > + return NULL; > > + } > > + patterns = g_slist_append(patterns, pattern); > > + } > > + > > + return patterns; > > +} > > + > > +static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) > > +{ > > + const struct adv_monitor *adv_monitor = a; > > + uint8_t idx = *(uint8_t *)b; > > + > > + return adv_monitor->idx != idx; > > +} > > + > > +static struct adv_monitor *find_adv_monitor_with_idx(uint8_t monitor_idx) > > +{ > > + GSList *list; > > + > > + list = g_slist_find_custom(adv_mons, &monitor_idx, > > + cmp_adv_monitor_with_idx); > > + > > + if (list) > > + return (struct adv_monitor *)list->data; > > + return NULL; > > +} > > + > > +static void print_bytearray(char *prefix, uint8_t *arr, uint8_t len) > > +{ > > + int idx; > > + > > + bt_shell_printf("%s", prefix); > > + for (idx = 0; idx < len; idx++) > > + bt_shell_printf("%02hhx", arr[idx]); > > + bt_shell_printf("\n"); > > +} > > + > > +static void print_adv_monitor(struct adv_monitor *adv_monitor) > > +{ > > + GSList *l; > > + > > + bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); > > + bt_shell_printf("\ttype: %s\n", adv_monitor->type); > > + if (adv_monitor->rssi) { > > + bt_shell_printf("\trssi:\n"); > > + bt_shell_printf("\t\thigh threshold: %hd\n", > > + adv_monitor->rssi->high_threshold); > > + bt_shell_printf("\t\thigh threshold timer: %hu\n", > > + adv_monitor->rssi->high_timer); > > + bt_shell_printf("\t\tlow threshold: %hd\n", > > + adv_monitor->rssi->low_threshold); > > + bt_shell_printf("\t\tlow threshold timer: %hu\n", > > + adv_monitor->rssi->low_timer); > > + } > > + > > + if (adv_monitor->patterns) { > > + int idx = 1; > > + > > + for (l = adv_monitor->patterns; l; l = g_slist_next(l), idx++) { > > + struct pattern *pattern = l->data; > > + > > + bt_shell_printf("\tpattern %d:\n", idx); > > + bt_shell_printf("\t\tstart position: %hhu\n", > > + pattern->start_pos); > > + bt_shell_printf("\t\tAD data type: %hhu\n", > > + pattern->ad_data_type); > > + print_bytearray("\t\tcontent: ", pattern->content, > > + pattern->content_len); > > + } > > + } > > +} > > + > > +void adv_monitor_add_monitor(DBusConnection *conn, int argc, char *argv[]) > > +{ > > + struct adv_monitor *adv_monitor; > > + struct rssi_setting *rssi; > > + GSList *patterns = NULL; > > + char *type; > > + > > + if (g_slist_length(adv_mons) >= UINT8_MAX) { > > + bt_shell_printf("Number of advertisement monitor exceeds " > > + "the limit"); > > + return; > > + } > > + > > + while (find_adv_monitor_with_idx(adv_mon_idx)) > > + adv_mon_idx += 1; > > + > > + type = argv[1]; > > + > > + if (strcmp(argv[2], "-") == 0) > > + rssi = NULL; > > + else { > > + rssi = parse_rssi(argv[2]); > > + if (rssi == NULL) { > > + bt_shell_printf("RSSIThresholdAndTimers malformed\n"); > > + return; > > + } > > + } > > + > > + patterns = parse_patterns(argv+3, argc-3); > > + if (patterns == NULL) { > > + bt_shell_printf("pattern-list malformed\n"); > > + return; > > + } > > + > > + adv_monitor = g_malloc0(sizeof(struct adv_monitor)); > > + > > + if (!adv_monitor) { > > + bt_shell_printf("Failed to allocate adv_monitor"); > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > + } > > + > > + adv_monitor->idx = adv_mon_idx; > > + adv_monitor->type = g_strdup(type); > > + adv_monitor->rssi = rssi; > > + adv_monitor->patterns = patterns; > > + > > + adv_mons = g_slist_append(adv_mons, adv_monitor); > > + bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); > > +} > > + > > +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx) > > +{ > > + struct adv_monitor *adv_monitor; > > + GSList *l; > > + > > + if (monitor_idx < 0) { > > + for (l = adv_mons; l; l = g_slist_next(l)) { > > + adv_monitor = l->data; > > + print_adv_monitor(adv_monitor); > > + } > > + return; > > + } > > + > > + adv_monitor = find_adv_monitor_with_idx(monitor_idx); > > + > > + if (adv_monitor == NULL) { > > + bt_shell_printf("Can't find monitor with index %d\n", > > + monitor_idx); > > + return; > > + } > > + > > + print_adv_monitor(adv_monitor); > > +} > > + > > +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) > > +{ > > + struct adv_monitor *adv_monitor; > > + > > + if (monitor_idx < 0) { > > + g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); > > + return; > > + } > > + > > + adv_monitor = find_adv_monitor_with_idx(monitor_idx); > > + if (adv_monitor == NULL) { > > + bt_shell_printf("Can't find monitor with index %d\n", > > + monitor_idx); > > + return; > > + } > > + > > + adv_mons = g_slist_remove(adv_mons, adv_monitor); > > + free_adv_monitor(adv_monitor); > > + bt_shell_printf("Monitor %d deleted\n", monitor_idx); > > +} > > + > > +static void print_supported_list(GSList *list) > > +{ > > + GSList *iter; > > + > > + for (iter = list; iter; iter = g_slist_next(iter)) { > > + char *data = iter->data; > > + > > + printf(" %s", data); > > + } > > +} > > + > > +void adv_monitor_get_supported_info(void) > > +{ > > + bt_shell_printf("Supported Features:"); > > + print_supported_list(manager.supported_features); > > + bt_shell_printf("\n"); > > + > > + bt_shell_printf("Supported Moniter Types:"); > > + print_supported_list(manager.supported_types); > > + bt_shell_printf("\n"); > > +} > > diff --git a/client/advertisement_monitor.h b/client/advertisement_monitor.h > > index 77b0b62c6..f2a0caf77 100644 > > --- a/client/advertisement_monitor.h > > +++ b/client/advertisement_monitor.h > > @@ -21,3 +21,7 @@ void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); > > void adv_monitor_remove_manager(DBusConnection *conn); > > void adv_monitor_register_app(DBusConnection *conn); > > void adv_monitor_unregister_app(DBusConnection *conn); > > +void adv_monitor_add_monitor(DBusConnection *conn, int argc, char *argv[]); > > +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx); > > +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx); > > +void adv_monitor_get_supported_info(void); > > diff --git a/client/main.c b/client/main.c > > index 7ddd13aa0..2b63ee62a 100644 > > --- a/client/main.c > > +++ b/client/main.c > > @@ -2686,6 +2686,53 @@ static void cmd_ad_clear(int argc, char *argv[]) > > return bt_shell_noninteractive_quit(EXIT_FAILURE); > > } > > > > +static void print_add_monitor_usage(void) > > +{ > > + bt_shell_usage(); > > + bt_shell_printf("RSSIThresholdAndTimers format:\n" > > + "\t<high-rssi>,<high-timeout>,<low-rssi>,<low-timeout>\n" > > + "\tor single '-' for not using RSSI as filter\n"); > > + bt_shell_printf("pattern format:\n" > > + "\t<start_position>,<ad_data_type>,<content_of_pattern>\n"); > > + bt_shell_printf("e.g.\n" > > + "\tadd-pattern-monitor or_patterns -10,10,-20,20 1,2,01ab55\n"); > > btshell parameters are space separated not comma. The reason we use commas is because RSSIThresholdAndTimers is an all-or-none property, it's clearer for users to either input all the four parameters or a single '-' to leave it unset. For a similar reason, a valid pattern requires all of the three parameters provided. If we want to avoid comma for maintaining consistency, we could have command usage like: add-pattern or_patterns -10 10 -20 20 1 2 01ab55 // single content with RSSI filter add-pattern or_patterns - 1 2 01ab55 // single content without RSSI filter Let me know if this is OK with you and other suggestions are welcome. > > > +} > > + > > +static void cmd_adv_monitor_add_monitor(int argc, char *argv[]) > > +{ > > + if (argc < 3) > > + print_add_monitor_usage(); > > + else > > + adv_monitor_add_monitor(dbus_conn, argc, argv); > > +} > > + > > +static void cmd_adv_monitor_print_monitor(int argc, char *argv[]) > > +{ > > + int monitor_idx; > > + > > + if (strcmp(argv[1], "all") == 0) > > + monitor_idx = -1; > > + else > > + monitor_idx = atoi(argv[1]); > > + adv_monitor_print_monitor(dbus_conn, monitor_idx); > > +} > > + > > +static void cmd_adv_monitor_remove_monitor(int argc, char *argv[]) > > +{ > > + int monitor_idx; > > + > > + if (strcmp(argv[1], "all") == 0) > > + monitor_idx = -1; > > + else > > + monitor_idx = atoi(argv[1]); > > + adv_monitor_remove_monitor(dbus_conn, monitor_idx); > > +} > > + > > +static void cmd_adv_monitor_get_supported_info(int argc, char *argv[]) > > +{ > > + adv_monitor_get_supported_info(); > > +} > > + > > static const struct bt_shell_menu advertise_menu = { > > .name = "advertise", > > .desc = "Advertise Options Submenu", > > @@ -2722,6 +2769,28 @@ static const struct bt_shell_menu advertise_menu = { > > { } }, > > }; > > > > +static const struct bt_shell_menu advertise_monitor_menu = { > > + .name = "advmon", > > I'd use monitor instead of advmon here. Will address these in the next patch. Thanks! > > > + .desc = "Advertisement Monitor Options Submenu", > > + .entries = { > > + { "add-pattern-monitor", "<type-of-monitor/help> " > > + "[RSSIThresholdAndTimers] " > > + "[patterns=pattern1 pattern2 ...]", > > + cmd_adv_monitor_add_monitor, > > + "Add pattern monitor" }, > > + { "get-pattern-monitor", "<monitor-id/all>", > > + cmd_adv_monitor_print_monitor, > > + "Get advertisement monitor" }, > > + { "remove-pattern-monitor", "<monitor-id/all>", > > + cmd_adv_monitor_remove_monitor, > > + "Remove advertisement monitor" }, > > + { "get-supported-info", NULL, > > + cmd_adv_monitor_get_supported_info, > > + "Get advertisement manager supported " > > + "features and supported monitor types" }, > > We could probably drop the monitor from the commands here which should > leave us at: > > add-pattern > get-pattern > remote-pattern > supported-info > > > + { } }, > > +}; > > + > > static const struct bt_shell_menu scan_menu = { > > .name = "scan", > > .desc = "Scan Options Submenu", > > @@ -2897,6 +2966,7 @@ int main(int argc, char *argv[]) > > bt_shell_init(argc, argv, &opt); > > bt_shell_set_menu(&main_menu); > > bt_shell_add_submenu(&advertise_menu); > > + bt_shell_add_submenu(&advertise_monitor_menu); > > bt_shell_add_submenu(&scan_menu); > > bt_shell_add_submenu(&gatt_menu); > > bt_shell_set_prompt(PROMPT_OFF); > > -- > > 2.28.0.220.ged08abb693-goog > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MNumIKxgWF/z5QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 06:57:16 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id sFaaHaxgWF/YPwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 06:57:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B7B5B408B3; Wed, 9 Sep 2020 06:57:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725863AbgIIE5I (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 00:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbgIIE5H (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 00:57:07 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE96AC061573 for <linux-bluetooth@vger.kernel.org>; Tue, 8 Sep 2020 21:57:06 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id y5so1231325otg.5 for <linux-bluetooth@vger.kernel.org>; Tue, 08 Sep 2020 21:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oVi1r4YRVW0wg7Lu6Dor+0mZqhFWgMJsSgSEzdCbZ4E=; b=QOZn4s7W0ZEj1AvndQweoK0c0bpOw2WB0/s2I5nAPsHQ3bLgT7uz4to6MzzrTgr9kM f3D8bfuXI7ffVINDPQ/oVeCnsI7cQoSoLornqpoO0myMWeEBWtrPZHabPzlfpSDP/QrX wuvCYA11blF/uvSUlq9N/litjspKeSUcFSdh5kzplUCUfgNf2I6yXWHw0nfaz9DJ5N7Q RIVYcqs13gWqsY/EaaePqRTsL09P3JpwqJ5a1qa7kJXk3RvvQCT7/vE6/+4vv2DBE3Zl eoG0ycsfkUaMIYrblV47FjgLM1g8ELsVJIeSwJXCv1LFxzJZJV9XZxU/dZaPbU/Mr/BS FNdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oVi1r4YRVW0wg7Lu6Dor+0mZqhFWgMJsSgSEzdCbZ4E=; b=AqNJe95RP7s7vnT1tlom5aZ4mQKcwTuJqL6YA3J3fqe8OzAL2NyGxYecQbrZnTChTW KN+LpQqE5FtFen7AirpDFE0+BR6TX2jfrRkP3N7/GN+G609jW4XG5/R8yUN7LUGRqT4m ar31knsbpIVhEhPoWRDkXBCbhrHEujLJ67vBrMPBX4vfTFhjJ5QRxHV48Mr6nrwlPwFd vf2wp6z/ysBh1XzjruB2D8nMgr+cX8w6IVPOqO98F/QnUIrY7A0JN5vM7hs8puS6aZFu FYxZgXO9cWmV+YqTMLgFwZ9s3CFVefsuW4xdlvK8QennIogMPv0mhOMA+LfO66aw5XYV LTuA== X-Gm-Message-State: AOAM533UGn44P+dcfCQnlpYy8PdAdfc4iQnCJzHO8gK3gdL/00CIXt5F vcX9aMCD3KBXVVLTr7KXj0hfQmHhvV8eF1NB0ANTkfSS X-Google-Smtp-Source: ABdhPJwNxd3lfsQmg6VQINSCzrfEzE5PCDINQNxnFsc0AlnguQ7pXLRwvFzS24sMGQ5qBVMzc09fx5rJgdJpyjCrsj0= X-Received: by 2002:a9d:429:: with SMTP id 38mr1689486otc.88.1599627426089; Tue, 08 Sep 2020 21:57:06 -0700 (PDT) MIME-Version: 1.0 References: <20200819121048.BlueZ.v1.1.I3a57ea1eb3e3f5b87abc44ea478fc83817627ffc@changeid> <20200819121048.BlueZ.v1.2.I045d6f668c141c6b834ba6b31fc81618c0a7b8e8@changeid> <CABBYNZLeqA=i_JdcJUD-Q-6p_8DtMpmmW=gg4yvQrJ77jRG4sw@mail.gmail.com> <CAPHZWUc0ZKcEwNcy5uzetyutszcQg16fa7_Ph9n3eRV0U6H-eQ@mail.gmail.com> In-Reply-To: <CAPHZWUc0ZKcEwNcy5uzetyutszcQg16fa7_Ph9n3eRV0U6H-eQ@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 8 Sep 2020 21:56:54 -0700 Message-ID: <CABBYNZJgVG-HLRjrwUE2AUzuOX4Ct_irSkzhRZewziQk7U0YLQ@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 2/4] client: Implement more interfaces of ADV monitor in bluetoothctl To: Yun-hao Chung <howardchung@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Manish Mandlik <mmandlik@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.18 / 15.00 / 200.00 X-Rspamd-Queue-Id: B7B5B408B3 X-Rspamd-UID: c6d447 Hi Yun-hao, On Tue, Sep 8, 2020 at 9:01 PM Yun-hao Chung <howardchung@google.com> wrote: > > Hi Luiz, > > Thanks for the comments. > > > On Wed, Sep 9, 2020 at 1:06 AM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Howard, > > > > On Tue, Aug 18, 2020 at 9:15 PM Howard Chung <howardchung@google.com> wrote: > > > > > > This patch creates a submenu in bluetoothctl and implements several > > > commands. > > > > > > new commands: > > > [bluetooth]# menu advmon > > > [bluetooth]# add-pattern-monitor or_patterns -10,10,-30,5 1,2,ab0011 > > > Advertisement Monitor 0 added > > > [bluetooth]# get-pattern-monitor all > > > Advertisement Monitor 0 > > > path: /org/bluez/adv_monitor_app/0 > > > type: or_patterns > > > rssi: > > > high threshold: -10 > > > high threshold timer: 10 > > > low threshold: -30 > > > low threshold timer: 5 > > > pattern 1: > > > start position: 1 > > > AD data type: 2 > > > content: ab0011 > > > [bluetooth]# get-supported-info > > > Supported Features: > > > Supported Moniter Types: or_patterns > > > [bluetooth]# remove-pattern-monitor 0 > > > Monitor 0 deleted > > > > > > Signed-off-by: Howard Chung <howardchung@google.com> > > > --- > > > > > > client/advertisement_monitor.c | 328 ++++++++++++++++++++++++++++++++- > > > client/advertisement_monitor.h | 4 + > > > client/main.c | 70 +++++++ > > > 3 files changed, 399 insertions(+), 3 deletions(-) > > > > > > diff --git a/client/advertisement_monitor.c b/client/advertisement_monitor.c > > > index bd2309537..ec8f23711 100644 > > > --- a/client/advertisement_monitor.c > > > +++ b/client/advertisement_monitor.c > > > @@ -29,6 +29,7 @@ > > > #include <string.h> > > > > > > #include "gdbus/gdbus.h" > > > +#include "src/shared/ad.h" > > > #include "src/shared/util.h" > > > #include "src/shared/shell.h" > > > #include "advertisement_monitor.h" > > > @@ -36,6 +37,27 @@ > > > #define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" > > > #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" > > > > > > +struct rssi_setting { > > > + int16_t high_threshold; > > > + uint16_t high_timer; > > > + int16_t low_threshold; > > > + uint16_t low_timer; > > > +}; > > > + > > > +struct pattern { > > > + uint8_t start_pos; > > > + uint8_t ad_data_type; > > > + uint8_t content_len; > > > + uint8_t content[BT_AD_MAX_DATA_LEN]; > > > +}; > > > + > > > +struct adv_monitor { > > > + uint8_t idx; > > > + char *type; > > > + struct rssi_setting *rssi; > > > + GSList *patterns; > > > +}; > > > + > > > struct adv_monitor_manager { > > > GSList *supported_types; > > > GSList *supported_features; > > > @@ -43,6 +65,9 @@ struct adv_monitor_manager { > > > gboolean app_registered; > > > } manager = { NULL, NULL, NULL, FALSE }; > > > > > > +static uint8_t adv_mon_idx; > > > +static GSList *adv_mons; > > > + > > > static void set_supported_list(GSList **list, DBusMessageIter *iter) > > > { > > > char *str; > > > @@ -138,7 +163,10 @@ static void unregister_reply(DBusMessage *message, void *user_data) > > > > > > void adv_monitor_register_app(DBusConnection *conn) > > > { > > > - if (manager.supported_types == NULL || manager.app_registered == TRUE || > > > + if (manager.app_registered == TRUE) { > > > + bt_shell_printf("Advertisement Monitor already registered\n"); > > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > > + } else if (manager.supported_types == NULL || > > > g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", > > > register_setup, register_reply, > > > NULL, NULL) == FALSE) { > > > @@ -150,8 +178,10 @@ void adv_monitor_register_app(DBusConnection *conn) > > > > > > void adv_monitor_unregister_app(DBusConnection *conn) > > > { > > > - if (manager.app_registered == FALSE || > > > - g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", > > > + if (manager.app_registered == FALSE) { > > > + bt_shell_printf("Advertisement Monitor not registered\n"); > > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > > + } else if (g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", > > > unregister_setup, unregister_reply, > > > NULL, NULL) == FALSE) { > > > bt_shell_printf("Failed to unregister Advertisement Monitor\n"); > > > @@ -159,3 +189,295 @@ void adv_monitor_unregister_app(DBusConnection *conn) > > > } > > > manager.app_registered = FALSE; > > > } > > > + > > > +static void free_pattern(void *user_data) > > > +{ > > > + struct pattern *p = user_data; > > > + > > > + g_free(p); > > > +} > > > + > > > +static void free_adv_monitor(void *user_data) > > > +{ > > > + struct adv_monitor *adv_monitor = user_data; > > > + > > > + g_free(adv_monitor->type); > > > + g_free(adv_monitor->rssi); > > > + g_slist_free_full(adv_monitor->patterns, free_pattern); > > > + g_free(adv_monitor); > > > +} > > > + > > > +static uint8_t str2bytearray(char *str, uint8_t *arr) > > > +{ > > > + int idx, len = strlen(str), arr_len = 0; > > > + > > > + if (len%2 != 0) > > > + return 0; > > > + > > > + for (idx = 0; idx < len; idx += 2) { > > > + if (sscanf(str+idx, "%2hhx", &arr[arr_len++]) < 1) > > > + return 0; > > > + } > > > + return arr_len; > > > +} > > > + > > > +static struct rssi_setting *parse_rssi(char *rssi_str) > > > +{ > > > + struct rssi_setting *rssi; > > > + int16_t high_threshold, low_threshold; > > > + uint16_t high_timer, low_timer; > > > + > > > + if (sscanf(rssi_str, "%hd,%hu,%hd,%hu", &high_threshold, &high_timer, > > > + &low_threshold, &low_timer) < 4) > > > + return NULL; > > > + > > > + rssi = g_malloc0(sizeof(struct rssi_setting)); > > > + > > > + if (!rssi) { > > > + bt_shell_printf("Failed to allocate rssi_setting"); > > > + bt_shell_noninteractive_quit(EXIT_FAILURE); > > > + return NULL; > > > + } > > > + > > > + rssi->high_threshold = high_threshold; > > > + rssi->high_timer = high_timer; > > > + rssi->low_threshold = low_threshold; > > > + rssi->low_timer = low_timer; > > > + > > > + return rssi; > > > +} > > > + > > > +static struct pattern *parse_pattern(char *pattern) > > > +{ > > > + uint8_t start_pos, ad_data_type; > > > + char content_str[BT_AD_MAX_DATA_LEN]; > > > + struct pattern *pat; > > > + > > > + if (sscanf(pattern, "%hhu,%hhu,%s", &start_pos, &ad_data_type, > > > + content_str) < 3) > > > + return NULL; > > > + > > > + pat = g_malloc0(sizeof(struct pattern)); > > > + > > > + if (!pat) { > > > + bt_shell_printf("Failed to allocate pattern"); > > > + bt_shell_noninteractive_quit(EXIT_FAILURE); > > > + return NULL; > > > + } > > > + > > > + pat->start_pos = start_pos; > > > + pat->ad_data_type = ad_data_type; > > > + pat->content_len = str2bytearray(content_str, pat->content); > > > + if (pat->content_len == 0) { > > > + free_pattern(pat); > > > + return NULL; > > > + } > > > + > > > + return pat; > > > +} > > > + > > > +static GSList *parse_patterns(char *pattern_list[], int num) > > > +{ > > > + GSList *patterns = NULL; > > > + int cnt; > > > + > > > + if (num == 0) { > > > + bt_shell_printf("No pattern provided\n"); > > > + return NULL; > > > + } > > > + > > > + for (cnt = 0; cnt < num; cnt++) { > > > + struct pattern *pattern; > > > + > > > + pattern = parse_pattern(pattern_list[cnt]); > > > + if (pattern == NULL) { > > > + g_slist_free_full(patterns, free_pattern); > > > + return NULL; > > > + } > > > + patterns = g_slist_append(patterns, pattern); > > > + } > > > + > > > + return patterns; > > > +} > > > + > > > +static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) > > > +{ > > > + const struct adv_monitor *adv_monitor = a; > > > + uint8_t idx = *(uint8_t *)b; > > > + > > > + return adv_monitor->idx != idx; > > > +} > > > + > > > +static struct adv_monitor *find_adv_monitor_with_idx(uint8_t monitor_idx) > > > +{ > > > + GSList *list; > > > + > > > + list = g_slist_find_custom(adv_mons, &monitor_idx, > > > + cmp_adv_monitor_with_idx); > > > + > > > + if (list) > > > + return (struct adv_monitor *)list->data; > > > + return NULL; > > > +} > > > + > > > +static void print_bytearray(char *prefix, uint8_t *arr, uint8_t len) > > > +{ > > > + int idx; > > > + > > > + bt_shell_printf("%s", prefix); > > > + for (idx = 0; idx < len; idx++) > > > + bt_shell_printf("%02hhx", arr[idx]); > > > + bt_shell_printf("\n"); > > > +} > > > + > > > +static void print_adv_monitor(struct adv_monitor *adv_monitor) > > > +{ > > > + GSList *l; > > > + > > > + bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); > > > + bt_shell_printf("\ttype: %s\n", adv_monitor->type); > > > + if (adv_monitor->rssi) { > > > + bt_shell_printf("\trssi:\n"); > > > + bt_shell_printf("\t\thigh threshold: %hd\n", > > > + adv_monitor->rssi->high_threshold); > > > + bt_shell_printf("\t\thigh threshold timer: %hu\n", > > > + adv_monitor->rssi->high_timer); > > > + bt_shell_printf("\t\tlow threshold: %hd\n", > > > + adv_monitor->rssi->low_threshold); > > > + bt_shell_printf("\t\tlow threshold timer: %hu\n", > > > + adv_monitor->rssi->low_timer); > > > + } > > > + > > > + if (adv_monitor->patterns) { > > > + int idx = 1; > > > + > > > + for (l = adv_monitor->patterns; l; l = g_slist_next(l), idx++) { > > > + struct pattern *pattern = l->data; > > > + > > > + bt_shell_printf("\tpattern %d:\n", idx); > > > + bt_shell_printf("\t\tstart position: %hhu\n", > > > + pattern->start_pos); > > > + bt_shell_printf("\t\tAD data type: %hhu\n", > > > + pattern->ad_data_type); > > > + print_bytearray("\t\tcontent: ", pattern->content, > > > + pattern->content_len); > > > + } > > > + } > > > +} > > > + > > > +void adv_monitor_add_monitor(DBusConnection *conn, int argc, char *argv[]) > > > +{ > > > + struct adv_monitor *adv_monitor; > > > + struct rssi_setting *rssi; > > > + GSList *patterns = NULL; > > > + char *type; > > > + > > > + if (g_slist_length(adv_mons) >= UINT8_MAX) { > > > + bt_shell_printf("Number of advertisement monitor exceeds " > > > + "the limit"); > > > + return; > > > + } > > > + > > > + while (find_adv_monitor_with_idx(adv_mon_idx)) > > > + adv_mon_idx += 1; > > > + > > > + type = argv[1]; > > > + > > > + if (strcmp(argv[2], "-") == 0) > > > + rssi = NULL; > > > + else { > > > + rssi = parse_rssi(argv[2]); > > > + if (rssi == NULL) { > > > + bt_shell_printf("RSSIThresholdAndTimers malformed\n"); > > > + return; > > > + } > > > + } > > > + > > > + patterns = parse_patterns(argv+3, argc-3); > > > + if (patterns == NULL) { > > > + bt_shell_printf("pattern-list malformed\n"); > > > + return; > > > + } > > > + > > > + adv_monitor = g_malloc0(sizeof(struct adv_monitor)); > > > + > > > + if (!adv_monitor) { > > > + bt_shell_printf("Failed to allocate adv_monitor"); > > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > > + } > > > + > > > + adv_monitor->idx = adv_mon_idx; > > > + adv_monitor->type = g_strdup(type); > > > + adv_monitor->rssi = rssi; > > > + adv_monitor->patterns = patterns; > > > + > > > + adv_mons = g_slist_append(adv_mons, adv_monitor); > > > + bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); > > > +} > > > + > > > +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx) > > > +{ > > > + struct adv_monitor *adv_monitor; > > > + GSList *l; > > > + > > > + if (monitor_idx < 0) { > > > + for (l = adv_mons; l; l = g_slist_next(l)) { > > > + adv_monitor = l->data; > > > + print_adv_monitor(adv_monitor); > > > + } > > > + return; > > > + } > > > + > > > + adv_monitor = find_adv_monitor_with_idx(monitor_idx); > > > + > > > + if (adv_monitor == NULL) { > > > + bt_shell_printf("Can't find monitor with index %d\n", > > > + monitor_idx); > > > + return; > > > + } > > > + > > > + print_adv_monitor(adv_monitor); > > > +} > > > + > > > +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) > > > +{ > > > + struct adv_monitor *adv_monitor; > > > + > > > + if (monitor_idx < 0) { > > > + g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); > > > + return; > > > + } > > > + > > > + adv_monitor = find_adv_monitor_with_idx(monitor_idx); > > > + if (adv_monitor == NULL) { > > > + bt_shell_printf("Can't find monitor with index %d\n", > > > + monitor_idx); > > > + return; > > > + } > > > + > > > + adv_mons = g_slist_remove(adv_mons, adv_monitor); > > > + free_adv_monitor(adv_monitor); > > > + bt_shell_printf("Monitor %d deleted\n", monitor_idx); > > > +} > > > + > > > +static void print_supported_list(GSList *list) > > > +{ > > > + GSList *iter; > > > + > > > + for (iter = list; iter; iter = g_slist_next(iter)) { > > > + char *data = iter->data; > > > + > > > + printf(" %s", data); > > > + } > > > +} > > > + > > > +void adv_monitor_get_supported_info(void) > > > +{ > > > + bt_shell_printf("Supported Features:"); > > > + print_supported_list(manager.supported_features); > > > + bt_shell_printf("\n"); > > > + > > > + bt_shell_printf("Supported Moniter Types:"); > > > + print_supported_list(manager.supported_types); > > > + bt_shell_printf("\n"); > > > +} > > > diff --git a/client/advertisement_monitor.h b/client/advertisement_monitor.h > > > index 77b0b62c6..f2a0caf77 100644 > > > --- a/client/advertisement_monitor.h > > > +++ b/client/advertisement_monitor.h > > > @@ -21,3 +21,7 @@ void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); > > > void adv_monitor_remove_manager(DBusConnection *conn); > > > void adv_monitor_register_app(DBusConnection *conn); > > > void adv_monitor_unregister_app(DBusConnection *conn); > > > +void adv_monitor_add_monitor(DBusConnection *conn, int argc, char *argv[]); > > > +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx); > > > +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx); > > > +void adv_monitor_get_supported_info(void); > > > diff --git a/client/main.c b/client/main.c > > > index 7ddd13aa0..2b63ee62a 100644 > > > --- a/client/main.c > > > +++ b/client/main.c > > > @@ -2686,6 +2686,53 @@ static void cmd_ad_clear(int argc, char *argv[]) > > > return bt_shell_noninteractive_quit(EXIT_FAILURE); > > > } > > > > > > +static void print_add_monitor_usage(void) > > > +{ > > > + bt_shell_usage(); > > > + bt_shell_printf("RSSIThresholdAndTimers format:\n" > > > + "\t<high-rssi>,<high-timeout>,<low-rssi>,<low-timeout>\n" > > > + "\tor single '-' for not using RSSI as filter\n"); > > > + bt_shell_printf("pattern format:\n" > > > + "\t<start_position>,<ad_data_type>,<content_of_pattern>\n"); > > > + bt_shell_printf("e.g.\n" > > > + "\tadd-pattern-monitor or_patterns -10,10,-20,20 1,2,01ab55\n"); > > > > btshell parameters are space separated not comma. > > The reason we use commas is because RSSIThresholdAndTimers is an > all-or-none property, it's clearer for users to either input all the > four parameters or a single '-' to leave it unset. > For a similar reason, a valid pattern requires all of the three > parameters provided. If we want to avoid comma for maintaining > consistency, we could have command usage like: > > add-pattern or_patterns -10 10 -20 20 1 2 01ab55 // single content > with RSSI filter > add-pattern or_patterns - 1 2 01ab55 // single > content without RSSI filter > > Let me know if this is OK with you and other suggestions are welcome. Actually it might be better to have good defaults on these or have something like: <rssi-range=low,high> then parse the input to check if comma has been passed otherwise we can assume only the high (or low if that value means better signal) rssi has been passed. <timeout=low,high> same as above. Also I would consider merging the type into the command itself: add-or-pattern-rssi -10,-20 10,1 01ab55 add-or-pattern 1 2 01ab55 That way the bt_shell parsing of the command description can actually detect if enough parameters have been given since we can't really have short of overloading command with different arguments as it would make it rather confusing to use since there are no types to detect which version the user is trying to use. > > > > > +} > > > + > > > +static void cmd_adv_monitor_add_monitor(int argc, char *argv[]) > > > +{ > > > + if (argc < 3) > > > + print_add_monitor_usage(); > > > + else > > > + adv_monitor_add_monitor(dbus_conn, argc, argv); > > > +} > > > + > > > +static void cmd_adv_monitor_print_monitor(int argc, char *argv[]) > > > +{ > > > + int monitor_idx; > > > + > > > + if (strcmp(argv[1], "all") == 0) > > > + monitor_idx = -1; > > > + else > > > + monitor_idx = atoi(argv[1]); > > > + adv_monitor_print_monitor(dbus_conn, monitor_idx); > > > +} > > > + > > > +static void cmd_adv_monitor_remove_monitor(int argc, char *argv[]) > > > +{ > > > + int monitor_idx; > > > + > > > + if (strcmp(argv[1], "all") == 0) > > > + monitor_idx = -1; > > > + else > > > + monitor_idx = atoi(argv[1]); > > > + adv_monitor_remove_monitor(dbus_conn, monitor_idx); > > > +} > > > + > > > +static void cmd_adv_monitor_get_supported_info(int argc, char *argv[]) > > > +{ > > > + adv_monitor_get_supported_info(); > > > +} > > > + > > > static const struct bt_shell_menu advertise_menu = { > > > .name = "advertise", > > > .desc = "Advertise Options Submenu", > > > @@ -2722,6 +2769,28 @@ static const struct bt_shell_menu advertise_menu = { > > > { } }, > > > }; > > > > > > +static const struct bt_shell_menu advertise_monitor_menu = { > > > + .name = "advmon", > > > > I'd use monitor instead of advmon here. > > Will address these in the next patch. Thanks! > > > > > > + .desc = "Advertisement Monitor Options Submenu", > > > + .entries = { > > > + { "add-pattern-monitor", "<type-of-monitor/help> " > > > + "[RSSIThresholdAndTimers] " > > > + "[patterns=pattern1 pattern2 ...]", > > > + cmd_adv_monitor_add_monitor, > > > + "Add pattern monitor" }, > > > + { "get-pattern-monitor", "<monitor-id/all>", > > > + cmd_adv_monitor_print_monitor, > > > + "Get advertisement monitor" }, > > > + { "remove-pattern-monitor", "<monitor-id/all>", > > > + cmd_adv_monitor_remove_monitor, > > > + "Remove advertisement monitor" }, > > > + { "get-supported-info", NULL, > > > + cmd_adv_monitor_get_supported_info, > > > + "Get advertisement manager supported " > > > + "features and supported monitor types" }, > > > > We could probably drop the monitor from the commands here which should > > leave us at: > > > > add-pattern > > get-pattern > > remote-pattern > > supported-info > > > > > + { } }, > > > +}; > > > + > > > static const struct bt_shell_menu scan_menu = { > > > .name = "scan", > > > .desc = "Scan Options Submenu", > > > @@ -2897,6 +2966,7 @@ int main(int argc, char *argv[]) > > > bt_shell_init(argc, argv, &opt); > > > bt_shell_set_menu(&main_menu); > > > bt_shell_add_submenu(&advertise_menu); > > > + bt_shell_add_submenu(&advertise_monitor_menu); > > > bt_shell_add_submenu(&scan_menu); > > > bt_shell_add_submenu(&gatt_menu); > > > bt_shell_set_prompt(PROMPT_OFF); > > > -- > > > 2.28.0.220.ged08abb693-goog > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CIRFAcGBWF/WCgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 09:18:25 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ECtEOsCBWF+ojQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 09:18:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EFD7EA0B19; Wed, 9 Sep 2020 09:18:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727880AbgIIHSD (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 03:18:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725772AbgIIHR7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 03:17:59 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AF3AC061573; Wed, 9 Sep 2020 00:17:58 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id l191so1418823pgd.5; Wed, 09 Sep 2020 00:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=64Bt6kd9gxNJLRVuqcxKj5M+pb5+qbe839Gm0r/zIvo=; b=BOZkXJ6/UZfd/Smz8exM0/GCMabLwdZY0S7okls6rxu14xZzEAcX+7DHmsZISbkkg1 yI+W8ytZ2T8AY61EhOAtxyLw/FXWXvZ8zE3VvXxr0LX0FbUVdMosXzPdv7nuDZzbWrkz Mq+leo06/a5x3b+9W+6QJAP+RWsyDJrKakDSaqjR+ch+HTVPMwA9vL25n4E5ufexmJfx 5RuG0VmZbBZydIVVUfcO+9WXm3igrUCRTWEIvanjZY4RmigvsMwz8KyfXu7TDXj/DuGZ 6uQ8GIDFcht7e76ccDGhc/3kIpHbgTIfiJpCWNpM8Bqdg88VJuTWxAKDS8rVfZYDUBLN YyNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=64Bt6kd9gxNJLRVuqcxKj5M+pb5+qbe839Gm0r/zIvo=; b=Y4UYQGpzbXyxbhQZ1aliF6qPEQZzplLB6I+ccPiRFr1nycbAdokz4qsPJHczBahpXA xUXkHHDO1cw3CvGQl/OoHuULY0UPRCs+seMKNEY6ToEREgukGt7CoqpEQxGvGCvM9oHH VmDgPQyXFEUiu9WW6UP19dWTdHYjB+/gBwIq8NcljM+nlIDi1kl+n6WyPiiDbu1Qtve0 rWJ54RgD4ydPjcLTGtNW0Zq96wylaDzp3794Z6kdzAya83DCyKQmzJiOG4goNNVS3Q8F 5cZ4Vkmv44w4oZ6i7v4PM+yHvRo8yPDXUZCqf9eP13GBAHBEh+tviJgSowQxyBJ1nse5 YWIQ== X-Gm-Message-State: AOAM530UuglL65IWHw1WU0h5LWsBEVIuGGPmzlQ+Pn/18I104/MI1wFP WZTSA7Ze0ZLyjXW9Hyoo1A== X-Google-Smtp-Source: ABdhPJxuGhKjFWPHlV7tWVd/A6dvlcDQsvdVZO4mWSI4b/JsVgqaXXITNfUrG/50JWsRL7CjUveweg== X-Received: by 2002:a17:902:7203:b029:d0:cbe1:e73a with SMTP id ba3-20020a1709027203b02900d0cbe1e73amr2786781plb.21.1599635878103; Wed, 09 Sep 2020 00:17:58 -0700 (PDT) Received: from localhost.localdomain (n11212042027.netvigator.com. [112.120.42.27]) by smtp.gmail.com with ESMTPSA id y3sm1699661pfb.18.2020.09.09.00.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 00:17:57 -0700 (PDT) From: Peilin Ye <yepeilin.cs@gmail.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Cc: Peilin Ye <yepeilin.cs@gmail.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH net v2] Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt() Date: Wed, 9 Sep 2020 03:17:00 -0400 Message-Id: <20200909071700.1100748-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200805180902.684024-1-yepeilin.cs@gmail.com> References: <20200805180902.684024-1-yepeilin.cs@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.80 / 15.00 / 15.00 X-Rspamd-Queue-Id: EFD7EA0B19 X-Rspamd-UID: e3df58 `num_reports` is not being properly checked. A malformed event packet with a large `num_reports` number makes hci_le_direct_adv_report_evt() read out of bounds. Fix it. Cc: stable@vger.kernel.org Fixes: 2f010b55884e ("Bluetooth: Add support for handling LE Direct Advertising Report events") Reported-and-tested-by: syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=24ebd650e20bd263ca01 Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> --- Change in v2: - add "Cc: stable@" tag. net/bluetooth/hci_event.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 4b7fc430793c..aec43ae488d1 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5863,21 +5863,19 @@ static void hci_le_direct_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb) { u8 num_reports = skb->data[0]; - void *ptr = &skb->data[1]; + struct hci_ev_le_direct_adv_info *ev = (void *)&skb->data[1]; - hci_dev_lock(hdev); + if (!num_reports || skb->len < num_reports * sizeof(*ev) + 1) + return; - while (num_reports--) { - struct hci_ev_le_direct_adv_info *ev = ptr; + hci_dev_lock(hdev); + for (; num_reports; num_reports--, ev++) process_adv_report(hdev, ev->evt_type, &ev->bdaddr, ev->bdaddr_type, &ev->direct_addr, ev->direct_addr_type, ev->rssi, NULL, 0, false); - ptr += sizeof(*ev); - } - hci_dev_unlock(hdev); } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MKxTAr2DWF9EOgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 09:26:53 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 6AvqOryDWF+4gQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 09:26:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 647F8A0B19; Wed, 9 Sep 2020 09:26:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725991AbgIIH0i (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 03:26:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725772AbgIIH0d (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 03:26:33 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7C6CC061573; Wed, 9 Sep 2020 00:26:32 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id d6so1371411pfn.9; Wed, 09 Sep 2020 00:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NB8HBUKnl+eWfZNHIQZWAbfkL9C5IcAO+9Z1lg426u8=; b=hNAVYHr5uxDesz7m8yBEg9nTrnbnzLgkuYvjloOejB/N6d8aae8dTdQu2xhhan0Vtl viJO7ZNo030PGxkXyTbUWpTLuecLUIQqkBS8LH3U7RamoG+oAkaDuHOi1A+4PZjSmPqi EoBVK7TpvxlDjdnHPXyH3Yt8wyrKOK8XGgzfYVPpmIKGXeE12M8psa9BW0zZQJ/aHR+4 KF/ZtkQjl2s+FQdRkBIGBmzK0/R0Z4NYX3mb0hIpGiLpkbIV26/G31SgEorcqReRRZiM ikR/C5UVkQ4ft+STBWWOMXlnHbrPVrbPt6HloxfdmkPRVFO2/z1j6cGnR0nhUwxzeynF JkHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NB8HBUKnl+eWfZNHIQZWAbfkL9C5IcAO+9Z1lg426u8=; b=t12lx9coJGdoCnAhFce6SBCJ5KTJ+px911baX2lT8OOkEaJBI7YwISalcBHIRJnQPM 1ghh+kbzWyfS1NOsc0f8HreEG+nesx+v3DOnEkoyCR2qF/JIrT6t+ImlHlMaA2hlGyvC OH4C6LOSjmFDHcnkLuiqol6/a5ue9ikaZuWj69QEOuMwshx1dwol/LhFJ8o09sD7sCA5 ejd9FImKnhExzDMakc9ZQb7im3W4hXMA4oiePsnf3F5oiDJkZ9pXnRk6zrGS7acRBHc6 TnsCsinPiS27wMv0a/UW1a/14y4RHlnv+lTef9jM0AWt5QB/JPVUPwg8alb6YrOVTTDP MWhA== X-Gm-Message-State: AOAM533U9m8ANTHHsZQ7JFppywn+2ugCSnohk/6FKMLGGdTdZicbJnvd dMjhkviDCGu5N4Vx4//0ww== X-Google-Smtp-Source: ABdhPJxgN58H3LqRJckQL6qJXd2ZuTLY65XPV2ud3K7OCYkyiqQA+x1vw7hC5sQIXpCuHOBgInDgkQ== X-Received: by 2002:a17:902:c38a:: with SMTP id g10mr2551819plg.23.1599636392271; Wed, 09 Sep 2020 00:26:32 -0700 (PDT) Received: from localhost.localdomain (n11212042027.netvigator.com. [112.120.42.27]) by smtp.gmail.com with ESMTPSA id r10sm1129570pjp.49.2020.09.09.00.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 00:26:31 -0700 (PDT) From: Peilin Ye <yepeilin.cs@gmail.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Cc: Peilin Ye <yepeilin.cs@gmail.com>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, syzkaller-bugs@googlegroups.com Subject: [Linux-kernel-mentees] [PATCH v2] Bluetooth: Fix memory leak in read_adv_mon_features() Date: Wed, 9 Sep 2020 03:25:51 -0400 Message-Id: <20200909072551.1101031-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200908200635.1099360-1-yepeilin.cs@gmail.com> References: <20200908200635.1099360-1-yepeilin.cs@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: 647F8A0B19 X-Rspamd-UID: ce0a1a read_adv_mon_features() is leaking memory. Free `rp` before returning. Fixes: e5e1e7fd470c ("Bluetooth: Add handler of MGMT_OP_READ_ADV_MONITOR_FEATURES") Reported-and-tested-by: syzbot+f7f6e564f4202d8601c6@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=f7f6e564f4202d8601c6 Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> --- I forgot the "Link:" tag yesterday. Sorry about that. Change in v2: - add a proper "Link:" tag. net/bluetooth/mgmt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5bbe71002fb9..f96251f818fc 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -4157,7 +4157,7 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev, { struct adv_monitor *monitor = NULL; struct mgmt_rp_read_adv_monitor_features *rp = NULL; - int handle; + int handle, err; size_t rp_size = 0; __u32 supported = 0; __u16 num_handles = 0; @@ -4192,9 +4192,13 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev, if (num_handles) memcpy(&rp->handles, &handles, (num_handles * sizeof(u16))); - return mgmt_cmd_complete(sk, hdev->id, - MGMT_OP_READ_ADV_MONITOR_FEATURES, - MGMT_STATUS_SUCCESS, rp, rp_size); + err = mgmt_cmd_complete(sk, hdev->id, + MGMT_OP_READ_ADV_MONITOR_FEATURES, + MGMT_STATUS_SUCCESS, rp, rp_size); + + kfree(rp); + + return err; } static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev, -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mKVCNLGEWF9EOgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 09:30:57 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id qFKSMbGEWF/RDQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 09:30:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9E549A0B36; Wed, 9 Sep 2020 09:30:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726535AbgIIHau (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 03:30:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725826AbgIIHat (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 03:30:49 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 376C3C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 00:30:48 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id a12so1559865eds.13 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 00:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Hx+rSk1fmMLiDUeJ3DtZalmNDvYOxyF0voYD6yeiSoA=; b=k23RvCOwsATe12WbFyWWRSfkwOdvPjd3snlX2Vbg+0AIgonkMb/w2yXPYC8ODUeWJk O+8wegEVDY9XkOMAzzmBH0gdTGWQwfuldQMvYcJyml28SLa9sHn4TvMG7IZ59ZK4e556 LaNyKCbkJP345sB1wnhcPEVgJgWwTks34/2x5IxdeVBvDdNHOq1lWOfBGRmkB8Lhm/51 lnodQAav1+HLEbPedIkRhy2bI/rgBusc6mmwhng7vy3Sl0EZFO0YtdWGEmiUJIuauPcA fINC3iEIc0rIaSbriFnLpEL0k+uAxC+sviaObzKFYC8GMUDEQ6oa+jnFcyy8EQFQ0bdd q6jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Hx+rSk1fmMLiDUeJ3DtZalmNDvYOxyF0voYD6yeiSoA=; b=OBs0x7caFPgf4ucHTAnzaSh4ct1X+FMtmtDLEMCBS/QtWQZVTKiKxgW/xiof4B0m0C RsPlxpv/pKss/5NMDgxlfdBsCV5waMls+sS2y38TIklDuFkNgmUbsgW7MjJBSwrhUMbn ODDRUMWYwLXLyleKCbsQxxbixr0IvJJago5puNeS7CG29icuBKn/eGUSKZBiOXUrvycJ Y+9ERN8IW7STnTgiHcfi0i3T2W1JAeda6LpI9QqRTaeg6x4bPylnvZhjNf66GHZS1TrP aGIiJYpycObYLJGOn3bYEIRD3xLnDvPEbCoXroz3xA7JhXIAKHF4O0Y2R4YEDfctp0T3 f5Lw== X-Gm-Message-State: AOAM530DmXpl+qcXPF4x41YZztHY1MHjLa90ScVm4tgnIMOvN82ew7L9 Vio3cvxLPJmCWj0LEeZH8MWQsUP0O33NLEW4N2T9ZQ== X-Google-Smtp-Source: ABdhPJw0l6eApRKF9kRG7V0jiUbONzJCp+LYoEE8gNTQQTuSxSBsN9J7+/BoMljLlLJttgH9tcCRp5kCKpmio6kdcdY= X-Received: by 2002:a05:6402:6d6:: with SMTP id n22mr2707748edy.79.1599636646356; Wed, 09 Sep 2020 00:30:46 -0700 (PDT) MIME-Version: 1.0 References: <20200819121048.BlueZ.v1.1.I3a57ea1eb3e3f5b87abc44ea478fc83817627ffc@changeid> <20200819121048.BlueZ.v1.2.I045d6f668c141c6b834ba6b31fc81618c0a7b8e8@changeid> <CABBYNZLeqA=i_JdcJUD-Q-6p_8DtMpmmW=gg4yvQrJ77jRG4sw@mail.gmail.com> <CAPHZWUc0ZKcEwNcy5uzetyutszcQg16fa7_Ph9n3eRV0U6H-eQ@mail.gmail.com> <CABBYNZJgVG-HLRjrwUE2AUzuOX4Ct_irSkzhRZewziQk7U0YLQ@mail.gmail.com> In-Reply-To: <CABBYNZJgVG-HLRjrwUE2AUzuOX4Ct_irSkzhRZewziQk7U0YLQ@mail.gmail.com> From: Yun-hao Chung <howardchung@google.com> Date: Wed, 9 Sep 2020 15:30:34 +0800 Message-ID: <CAPHZWUd4tntgsLRaH1ouvNGMBmRP-hUOYJJrFikqq6CDF--dFQ@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 2/4] client: Implement more interfaces of ADV monitor in bluetoothctl To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Manish Mandlik <mmandlik@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.61 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9E549A0B36 X-Rspamd-UID: 8e2bd4 Split commands into add-or-pattern-rssi and add-or-pattern make sense to me. However, allowing users to pass only one argument on <rssi-range> could cause some ambiguity when the provided value is between the default low-rssi and high-rssi. Also high-timeout is not necessary to be higher or lower than low-timeout. I'm thinking another option: What if we force users to pass the comma then we know which value should be set. For example: add-or-pattern-rssi -10, ,1 1 2 01ab55 would only update low-rssi and high-timeout. The rest of the two parameters remain as default. On Wed, Sep 9, 2020 at 12:57 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Yun-hao, > > On Tue, Sep 8, 2020 at 9:01 PM Yun-hao Chung <howardchung@google.com> wrote: > > > > Hi Luiz, > > > > Thanks for the comments. > > > > > > On Wed, Sep 9, 2020 at 1:06 AM Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > > > > > > Hi Howard, > > > > > > On Tue, Aug 18, 2020 at 9:15 PM Howard Chung <howardchung@google.com> wrote: > > > > > > > > This patch creates a submenu in bluetoothctl and implements several > > > > commands. > > > > > > > > new commands: > > > > [bluetooth]# menu advmon > > > > [bluetooth]# add-pattern-monitor or_patterns -10,10,-30,5 1,2,ab0011 > > > > Advertisement Monitor 0 added > > > > [bluetooth]# get-pattern-monitor all > > > > Advertisement Monitor 0 > > > > path: /org/bluez/adv_monitor_app/0 > > > > type: or_patterns > > > > rssi: > > > > high threshold: -10 > > > > high threshold timer: 10 > > > > low threshold: -30 > > > > low threshold timer: 5 > > > > pattern 1: > > > > start position: 1 > > > > AD data type: 2 > > > > content: ab0011 > > > > [bluetooth]# get-supported-info > > > > Supported Features: > > > > Supported Moniter Types: or_patterns > > > > [bluetooth]# remove-pattern-monitor 0 > > > > Monitor 0 deleted > > > > > > > > Signed-off-by: Howard Chung <howardchung@google.com> > > > > --- > > > > > > > > client/advertisement_monitor.c | 328 ++++++++++++++++++++++++++++++++- > > > > client/advertisement_monitor.h | 4 + > > > > client/main.c | 70 +++++++ > > > > 3 files changed, 399 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/client/advertisement_monitor.c b/client/advertisement_monitor.c > > > > index bd2309537..ec8f23711 100644 > > > > --- a/client/advertisement_monitor.c > > > > +++ b/client/advertisement_monitor.c > > > > @@ -29,6 +29,7 @@ > > > > #include <string.h> > > > > > > > > #include "gdbus/gdbus.h" > > > > +#include "src/shared/ad.h" > > > > #include "src/shared/util.h" > > > > #include "src/shared/shell.h" > > > > #include "advertisement_monitor.h" > > > > @@ -36,6 +37,27 @@ > > > > #define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" > > > > #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" > > > > > > > > +struct rssi_setting { > > > > + int16_t high_threshold; > > > > + uint16_t high_timer; > > > > + int16_t low_threshold; > > > > + uint16_t low_timer; > > > > +}; > > > > + > > > > +struct pattern { > > > > + uint8_t start_pos; > > > > + uint8_t ad_data_type; > > > > + uint8_t content_len; > > > > + uint8_t content[BT_AD_MAX_DATA_LEN]; > > > > +}; > > > > + > > > > +struct adv_monitor { > > > > + uint8_t idx; > > > > + char *type; > > > > + struct rssi_setting *rssi; > > > > + GSList *patterns; > > > > +}; > > > > + > > > > struct adv_monitor_manager { > > > > GSList *supported_types; > > > > GSList *supported_features; > > > > @@ -43,6 +65,9 @@ struct adv_monitor_manager { > > > > gboolean app_registered; > > > > } manager = { NULL, NULL, NULL, FALSE }; > > > > > > > > +static uint8_t adv_mon_idx; > > > > +static GSList *adv_mons; > > > > + > > > > static void set_supported_list(GSList **list, DBusMessageIter *iter) > > > > { > > > > char *str; > > > > @@ -138,7 +163,10 @@ static void unregister_reply(DBusMessage *message, void *user_data) > > > > > > > > void adv_monitor_register_app(DBusConnection *conn) > > > > { > > > > - if (manager.supported_types == NULL || manager.app_registered == TRUE || > > > > + if (manager.app_registered == TRUE) { > > > > + bt_shell_printf("Advertisement Monitor already registered\n"); > > > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > > > + } else if (manager.supported_types == NULL || > > > > g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", > > > > register_setup, register_reply, > > > > NULL, NULL) == FALSE) { > > > > @@ -150,8 +178,10 @@ void adv_monitor_register_app(DBusConnection *conn) > > > > > > > > void adv_monitor_unregister_app(DBusConnection *conn) > > > > { > > > > - if (manager.app_registered == FALSE || > > > > - g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", > > > > + if (manager.app_registered == FALSE) { > > > > + bt_shell_printf("Advertisement Monitor not registered\n"); > > > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > > > + } else if (g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", > > > > unregister_setup, unregister_reply, > > > > NULL, NULL) == FALSE) { > > > > bt_shell_printf("Failed to unregister Advertisement Monitor\n"); > > > > @@ -159,3 +189,295 @@ void adv_monitor_unregister_app(DBusConnection *conn) > > > > } > > > > manager.app_registered = FALSE; > > > > } > > > > + > > > > +static void free_pattern(void *user_data) > > > > +{ > > > > + struct pattern *p = user_data; > > > > + > > > > + g_free(p); > > > > +} > > > > + > > > > +static void free_adv_monitor(void *user_data) > > > > +{ > > > > + struct adv_monitor *adv_monitor = user_data; > > > > + > > > > + g_free(adv_monitor->type); > > > > + g_free(adv_monitor->rssi); > > > > + g_slist_free_full(adv_monitor->patterns, free_pattern); > > > > + g_free(adv_monitor); > > > > +} > > > > + > > > > +static uint8_t str2bytearray(char *str, uint8_t *arr) > > > > +{ > > > > + int idx, len = strlen(str), arr_len = 0; > > > > + > > > > + if (len%2 != 0) > > > > + return 0; > > > > + > > > > + for (idx = 0; idx < len; idx += 2) { > > > > + if (sscanf(str+idx, "%2hhx", &arr[arr_len++]) < 1) > > > > + return 0; > > > > + } > > > > + return arr_len; > > > > +} > > > > + > > > > +static struct rssi_setting *parse_rssi(char *rssi_str) > > > > +{ > > > > + struct rssi_setting *rssi; > > > > + int16_t high_threshold, low_threshold; > > > > + uint16_t high_timer, low_timer; > > > > + > > > > + if (sscanf(rssi_str, "%hd,%hu,%hd,%hu", &high_threshold, &high_timer, > > > > + &low_threshold, &low_timer) < 4) > > > > + return NULL; > > > > + > > > > + rssi = g_malloc0(sizeof(struct rssi_setting)); > > > > + > > > > + if (!rssi) { > > > > + bt_shell_printf("Failed to allocate rssi_setting"); > > > > + bt_shell_noninteractive_quit(EXIT_FAILURE); > > > > + return NULL; > > > > + } > > > > + > > > > + rssi->high_threshold = high_threshold; > > > > + rssi->high_timer = high_timer; > > > > + rssi->low_threshold = low_threshold; > > > > + rssi->low_timer = low_timer; > > > > + > > > > + return rssi; > > > > +} > > > > + > > > > +static struct pattern *parse_pattern(char *pattern) > > > > +{ > > > > + uint8_t start_pos, ad_data_type; > > > > + char content_str[BT_AD_MAX_DATA_LEN]; > > > > + struct pattern *pat; > > > > + > > > > + if (sscanf(pattern, "%hhu,%hhu,%s", &start_pos, &ad_data_type, > > > > + content_str) < 3) > > > > + return NULL; > > > > + > > > > + pat = g_malloc0(sizeof(struct pattern)); > > > > + > > > > + if (!pat) { > > > > + bt_shell_printf("Failed to allocate pattern"); > > > > + bt_shell_noninteractive_quit(EXIT_FAILURE); > > > > + return NULL; > > > > + } > > > > + > > > > + pat->start_pos = start_pos; > > > > + pat->ad_data_type = ad_data_type; > > > > + pat->content_len = str2bytearray(content_str, pat->content); > > > > + if (pat->content_len == 0) { > > > > + free_pattern(pat); > > > > + return NULL; > > > > + } > > > > + > > > > + return pat; > > > > +} > > > > + > > > > +static GSList *parse_patterns(char *pattern_list[], int num) > > > > +{ > > > > + GSList *patterns = NULL; > > > > + int cnt; > > > > + > > > > + if (num == 0) { > > > > + bt_shell_printf("No pattern provided\n"); > > > > + return NULL; > > > > + } > > > > + > > > > + for (cnt = 0; cnt < num; cnt++) { > > > > + struct pattern *pattern; > > > > + > > > > + pattern = parse_pattern(pattern_list[cnt]); > > > > + if (pattern == NULL) { > > > > + g_slist_free_full(patterns, free_pattern); > > > > + return NULL; > > > > + } > > > > + patterns = g_slist_append(patterns, pattern); > > > > + } > > > > + > > > > + return patterns; > > > > +} > > > > + > > > > +static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) > > > > +{ > > > > + const struct adv_monitor *adv_monitor = a; > > > > + uint8_t idx = *(uint8_t *)b; > > > > + > > > > + return adv_monitor->idx != idx; > > > > +} > > > > + > > > > +static struct adv_monitor *find_adv_monitor_with_idx(uint8_t monitor_idx) > > > > +{ > > > > + GSList *list; > > > > + > > > > + list = g_slist_find_custom(adv_mons, &monitor_idx, > > > > + cmp_adv_monitor_with_idx); > > > > + > > > > + if (list) > > > > + return (struct adv_monitor *)list->data; > > > > + return NULL; > > > > +} > > > > + > > > > +static void print_bytearray(char *prefix, uint8_t *arr, uint8_t len) > > > > +{ > > > > + int idx; > > > > + > > > > + bt_shell_printf("%s", prefix); > > > > + for (idx = 0; idx < len; idx++) > > > > + bt_shell_printf("%02hhx", arr[idx]); > > > > + bt_shell_printf("\n"); > > > > +} > > > > + > > > > +static void print_adv_monitor(struct adv_monitor *adv_monitor) > > > > +{ > > > > + GSList *l; > > > > + > > > > + bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); > > > > + bt_shell_printf("\ttype: %s\n", adv_monitor->type); > > > > + if (adv_monitor->rssi) { > > > > + bt_shell_printf("\trssi:\n"); > > > > + bt_shell_printf("\t\thigh threshold: %hd\n", > > > > + adv_monitor->rssi->high_threshold); > > > > + bt_shell_printf("\t\thigh threshold timer: %hu\n", > > > > + adv_monitor->rssi->high_timer); > > > > + bt_shell_printf("\t\tlow threshold: %hd\n", > > > > + adv_monitor->rssi->low_threshold); > > > > + bt_shell_printf("\t\tlow threshold timer: %hu\n", > > > > + adv_monitor->rssi->low_timer); > > > > + } > > > > + > > > > + if (adv_monitor->patterns) { > > > > + int idx = 1; > > > > + > > > > + for (l = adv_monitor->patterns; l; l = g_slist_next(l), idx++) { > > > > + struct pattern *pattern = l->data; > > > > + > > > > + bt_shell_printf("\tpattern %d:\n", idx); > > > > + bt_shell_printf("\t\tstart position: %hhu\n", > > > > + pattern->start_pos); > > > > + bt_shell_printf("\t\tAD data type: %hhu\n", > > > > + pattern->ad_data_type); > > > > + print_bytearray("\t\tcontent: ", pattern->content, > > > > + pattern->content_len); > > > > + } > > > > + } > > > > +} > > > > + > > > > +void adv_monitor_add_monitor(DBusConnection *conn, int argc, char *argv[]) > > > > +{ > > > > + struct adv_monitor *adv_monitor; > > > > + struct rssi_setting *rssi; > > > > + GSList *patterns = NULL; > > > > + char *type; > > > > + > > > > + if (g_slist_length(adv_mons) >= UINT8_MAX) { > > > > + bt_shell_printf("Number of advertisement monitor exceeds " > > > > + "the limit"); > > > > + return; > > > > + } > > > > + > > > > + while (find_adv_monitor_with_idx(adv_mon_idx)) > > > > + adv_mon_idx += 1; > > > > + > > > > + type = argv[1]; > > > > + > > > > + if (strcmp(argv[2], "-") == 0) > > > > + rssi = NULL; > > > > + else { > > > > + rssi = parse_rssi(argv[2]); > > > > + if (rssi == NULL) { > > > > + bt_shell_printf("RSSIThresholdAndTimers malformed\n"); > > > > + return; > > > > + } > > > > + } > > > > + > > > > + patterns = parse_patterns(argv+3, argc-3); > > > > + if (patterns == NULL) { > > > > + bt_shell_printf("pattern-list malformed\n"); > > > > + return; > > > > + } > > > > + > > > > + adv_monitor = g_malloc0(sizeof(struct adv_monitor)); > > > > + > > > > + if (!adv_monitor) { > > > > + bt_shell_printf("Failed to allocate adv_monitor"); > > > > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > > > > + } > > > > + > > > > + adv_monitor->idx = adv_mon_idx; > > > > + adv_monitor->type = g_strdup(type); > > > > + adv_monitor->rssi = rssi; > > > > + adv_monitor->patterns = patterns; > > > > + > > > > + adv_mons = g_slist_append(adv_mons, adv_monitor); > > > > + bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); > > > > +} > > > > + > > > > +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx) > > > > +{ > > > > + struct adv_monitor *adv_monitor; > > > > + GSList *l; > > > > + > > > > + if (monitor_idx < 0) { > > > > + for (l = adv_mons; l; l = g_slist_next(l)) { > > > > + adv_monitor = l->data; > > > > + print_adv_monitor(adv_monitor); > > > > + } > > > > + return; > > > > + } > > > > + > > > > + adv_monitor = find_adv_monitor_with_idx(monitor_idx); > > > > + > > > > + if (adv_monitor == NULL) { > > > > + bt_shell_printf("Can't find monitor with index %d\n", > > > > + monitor_idx); > > > > + return; > > > > + } > > > > + > > > > + print_adv_monitor(adv_monitor); > > > > +} > > > > + > > > > +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) > > > > +{ > > > > + struct adv_monitor *adv_monitor; > > > > + > > > > + if (monitor_idx < 0) { > > > > + g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); > > > > + return; > > > > + } > > > > + > > > > + adv_monitor = find_adv_monitor_with_idx(monitor_idx); > > > > + if (adv_monitor == NULL) { > > > > + bt_shell_printf("Can't find monitor with index %d\n", > > > > + monitor_idx); > > > > + return; > > > > + } > > > > + > > > > + adv_mons = g_slist_remove(adv_mons, adv_monitor); > > > > + free_adv_monitor(adv_monitor); > > > > + bt_shell_printf("Monitor %d deleted\n", monitor_idx); > > > > +} > > > > + > > > > +static void print_supported_list(GSList *list) > > > > +{ > > > > + GSList *iter; > > > > + > > > > + for (iter = list; iter; iter = g_slist_next(iter)) { > > > > + char *data = iter->data; > > > > + > > > > + printf(" %s", data); > > > > + } > > > > +} > > > > + > > > > +void adv_monitor_get_supported_info(void) > > > > +{ > > > > + bt_shell_printf("Supported Features:"); > > > > + print_supported_list(manager.supported_features); > > > > + bt_shell_printf("\n"); > > > > + > > > > + bt_shell_printf("Supported Moniter Types:"); > > > > + print_supported_list(manager.supported_types); > > > > + bt_shell_printf("\n"); > > > > +} > > > > diff --git a/client/advertisement_monitor.h b/client/advertisement_monitor.h > > > > index 77b0b62c6..f2a0caf77 100644 > > > > --- a/client/advertisement_monitor.h > > > > +++ b/client/advertisement_monitor.h > > > > @@ -21,3 +21,7 @@ void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); > > > > void adv_monitor_remove_manager(DBusConnection *conn); > > > > void adv_monitor_register_app(DBusConnection *conn); > > > > void adv_monitor_unregister_app(DBusConnection *conn); > > > > +void adv_monitor_add_monitor(DBusConnection *conn, int argc, char *argv[]); > > > > +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx); > > > > +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx); > > > > +void adv_monitor_get_supported_info(void); > > > > diff --git a/client/main.c b/client/main.c > > > > index 7ddd13aa0..2b63ee62a 100644 > > > > --- a/client/main.c > > > > +++ b/client/main.c > > > > @@ -2686,6 +2686,53 @@ static void cmd_ad_clear(int argc, char *argv[]) > > > > return bt_shell_noninteractive_quit(EXIT_FAILURE); > > > > } > > > > > > > > +static void print_add_monitor_usage(void) > > > > +{ > > > > + bt_shell_usage(); > > > > + bt_shell_printf("RSSIThresholdAndTimers format:\n" > > > > + "\t<high-rssi>,<high-timeout>,<low-rssi>,<low-timeout>\n" > > > > + "\tor single '-' for not using RSSI as filter\n"); > > > > + bt_shell_printf("pattern format:\n" > > > > + "\t<start_position>,<ad_data_type>,<content_of_pattern>\n"); > > > > + bt_shell_printf("e.g.\n" > > > > + "\tadd-pattern-monitor or_patterns -10,10,-20,20 1,2,01ab55\n"); > > > > > > btshell parameters are space separated not comma. > > > > The reason we use commas is because RSSIThresholdAndTimers is an > > all-or-none property, it's clearer for users to either input all the > > four parameters or a single '-' to leave it unset. > > For a similar reason, a valid pattern requires all of the three > > parameters provided. If we want to avoid comma for maintaining > > consistency, we could have command usage like: > > > > add-pattern or_patterns -10 10 -20 20 1 2 01ab55 // single content > > with RSSI filter > > add-pattern or_patterns - 1 2 01ab55 // single > > content without RSSI filter > > > > Let me know if this is OK with you and other suggestions are welcome. > > Actually it might be better to have good defaults on these or have > something like: > > <rssi-range=low,high> then parse the input to check if comma has been > passed otherwise we can assume only the high (or low if that value > means better signal) rssi has been passed. > <timeout=low,high> same as above. > > Also I would consider merging the type into the command itself: > > add-or-pattern-rssi -10,-20 10,1 01ab55 > add-or-pattern 1 2 01ab55 > > That way the bt_shell parsing of the command description can actually > detect if enough parameters have been given since we can't really have > short of overloading command with different arguments as it would make > it rather confusing to use since there are no types to detect which > version the user is trying to use. > > > > > > > > +} > > > > + > > > > +static void cmd_adv_monitor_add_monitor(int argc, char *argv[]) > > > > +{ > > > > + if (argc < 3) > > > > + print_add_monitor_usage(); > > > > + else > > > > + adv_monitor_add_monitor(dbus_conn, argc, argv); > > > > +} > > > > + > > > > +static void cmd_adv_monitor_print_monitor(int argc, char *argv[]) > > > > +{ > > > > + int monitor_idx; > > > > + > > > > + if (strcmp(argv[1], "all") == 0) > > > > + monitor_idx = -1; > > > > + else > > > > + monitor_idx = atoi(argv[1]); > > > > + adv_monitor_print_monitor(dbus_conn, monitor_idx); > > > > +} > > > > + > > > > +static void cmd_adv_monitor_remove_monitor(int argc, char *argv[]) > > > > +{ > > > > + int monitor_idx; > > > > + > > > > + if (strcmp(argv[1], "all") == 0) > > > > + monitor_idx = -1; > > > > + else > > > > + monitor_idx = atoi(argv[1]); > > > > + adv_monitor_remove_monitor(dbus_conn, monitor_idx); > > > > +} > > > > + > > > > +static void cmd_adv_monitor_get_supported_info(int argc, char *argv[]) > > > > +{ > > > > + adv_monitor_get_supported_info(); > > > > +} > > > > + > > > > static const struct bt_shell_menu advertise_menu = { > > > > .name = "advertise", > > > > .desc = "Advertise Options Submenu", > > > > @@ -2722,6 +2769,28 @@ static const struct bt_shell_menu advertise_menu = { > > > > { } }, > > > > }; > > > > > > > > +static const struct bt_shell_menu advertise_monitor_menu = { > > > > + .name = "advmon", > > > > > > I'd use monitor instead of advmon here. > > > > Will address these in the next patch. Thanks! > > > > > > > > > + .desc = "Advertisement Monitor Options Submenu", > > > > + .entries = { > > > > + { "add-pattern-monitor", "<type-of-monitor/help> " > > > > + "[RSSIThresholdAndTimers] " > > > > + "[patterns=pattern1 pattern2 ...]", > > > > + cmd_adv_monitor_add_monitor, > > > > + "Add pattern monitor" }, > > > > + { "get-pattern-monitor", "<monitor-id/all>", > > > > + cmd_adv_monitor_print_monitor, > > > > + "Get advertisement monitor" }, > > > > + { "remove-pattern-monitor", "<monitor-id/all>", > > > > + cmd_adv_monitor_remove_monitor, > > > > + "Remove advertisement monitor" }, > > > > + { "get-supported-info", NULL, > > > > + cmd_adv_monitor_get_supported_info, > > > > + "Get advertisement manager supported " > > > > + "features and supported monitor types" }, > > > > > > We could probably drop the monitor from the commands here which should > > > leave us at: > > > > > > add-pattern > > > get-pattern > > > remote-pattern > > > supported-info > > > > > > > + { } }, > > > > +}; > > > > + > > > > static const struct bt_shell_menu scan_menu = { > > > > .name = "scan", > > > > .desc = "Scan Options Submenu", > > > > @@ -2897,6 +2966,7 @@ int main(int argc, char *argv[]) > > > > bt_shell_init(argc, argv, &opt); > > > > bt_shell_set_menu(&main_menu); > > > > bt_shell_add_submenu(&advertise_menu); > > > > + bt_shell_add_submenu(&advertise_monitor_menu); > > > > bt_shell_add_submenu(&scan_menu); > > > > bt_shell_add_submenu(&gatt_menu); > > > > bt_shell_set_prompt(PROMPT_OFF); > > > > -- > > > > 2.28.0.220.ged08abb693-goog > > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +Da6NEmXWF9j2wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 10:50:17 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id GEPXMUmXWF9CzwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 10:50:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EEEBAA0B47; Wed, 9 Sep 2020 10:50:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729449AbgIIItj (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 04:49:39 -0400 Received: from mail-il1-f205.google.com ([209.85.166.205]:37449 "EHLO mail-il1-f205.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728647AbgIIItY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 04:49:24 -0400 Received: by mail-il1-f205.google.com with SMTP id z14so1511822ils.4 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 01:49:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=Hmc2r7eesuS8hDT5sY5ndDBpeHvg0B9Mp2Q2pIVeAhQ=; b=uY9Qboi9N/YojYQUYLDvGE7HQAFUt/CBXX17Nyi+Kt2nT9eo9xDxIVeWOBXX2dA4GL d+HAkVX0SIEOnJLJ7ud+hokgJiGUYi4TWUqPHItAKh4kED/R+FW0BjS8C5r427FUYp/z 3dCpUTiwY2mv+Lz6ZwT8pdZlqcYsmAEdhcMuaSYa9oJEZ2ubfSXo3ADjL/IhcsWOKv40 14hRUQGirj6Fu+Ux6kxy2N4HnoYbXmzM8LNTEcLJU2JXplh2bc7ucwX/6+EOxkxY1NG2 p3m7SjvAMv3Ru2jCQ7Hi6qxcqiPUg/V6wj9M1D7R15RCEs3TqmAHNm91+TXvW8sIUrRr jRAQ== X-Gm-Message-State: AOAM531EF0dfi3PMGyzj/E5JAqHwZAioXAg7rqeAgnBmrBvAPsDuN/+l whC/BaYpoK1cyZlltuFPM+RYGjUPIUi6efYn1pYYEM1w+103 X-Google-Smtp-Source: ABdhPJxoMRKRTwWdxdXUfgMHZQIkaFn/xWyh4vyruirgPIBRjn9gLzghekwhJjrYO7UQ2Zc99DWXrwQldvZR/amubDmOOitKbaCk MIME-Version: 1.0 X-Received: by 2002:a92:c002:: with SMTP id q2mr2827066ild.171.1599641363124; Wed, 09 Sep 2020 01:49:23 -0700 (PDT) Date: Wed, 09 Sep 2020 01:49:23 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000003798d705aedd870d@google.com> Subject: memory leak in mgmt_cmd_status From: syzbot <syzbot+80f5bab4eb14d14e7386@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.68 / 15.00 / 15.00 X-Rspamd-Queue-Id: EEEBAA0B47 X-Rspamd-UID: 1bc0bf Hello, syzbot found the following issue on: HEAD commit: 6f6a73c8 Merge tag 'drm-fixes-2020-09-08' of git://anongit.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=152e3245900000 kernel config: https://syzkaller.appspot.com/x/.config?x=7954285d6e960c0f dashboard link: https://syzkaller.appspot.com/bug?extid=80f5bab4eb14d14e7386 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16877335900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+80f5bab4eb14d14e7386@syzkaller.appspotmail.com 2020/09/09 02:38:52 executed programs: 3 2020/09/09 02:38:58 executed programs: 5 2020/09/09 02:39:03 executed programs: 7 BUG: memory leak unreferenced object 0xffff888119d41a00 (size 224): comm "kworker/u5:0", pid 1520, jiffies 4294954656 (age 28.430s) hex dump (first 32 bytes): d0 30 1c 2b 81 88 ff ff d0 30 1c 2b 81 88 ff ff .0.+.....0.+.... 00 00 00 00 00 00 00 00 00 30 1c 2b 81 88 ff ff .........0.+.... backtrace: [<000000007a3b2b8a>] __alloc_skb+0x5e/0x250 net/core/skbuff.c:198 [<000000003fe180cd>] alloc_skb include/linux/skbuff.h:1094 [inline] [<000000003fe180cd>] mgmt_cmd_status+0x31/0x140 net/bluetooth/mgmt_util.c:102 [<00000000a98852de>] mgmt_set_discoverable_complete+0x18e/0x1c0 net/bluetooth/mgmt.c:1351 [<000000000d6aa222>] discoverable_update_work+0x7a/0xa0 net/bluetooth/hci_request.c:2595 [<00000000159838c7>] process_one_work+0x213/0x4d0 kernel/workqueue.c:2269 [<0000000087b95ef0>] worker_thread+0x58/0x4b0 kernel/workqueue.c:2415 [<0000000059403542>] kthread+0x164/0x190 kernel/kthread.c:292 [<00000000d35ee226>] ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kJ93MLijWF+fTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 11:43:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id WB6nLbijWF8LDgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 11:43:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9741DA0377; Wed, 9 Sep 2020 11:43:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730174AbgIIJnC (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 05:43:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730022AbgIIJml (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 05:42:41 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 322CDC061795 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 02:42:40 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id l126so1676804pfd.5 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 02:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cJ2b5yC6U6sZBSPpf2NMndA3c8MuYwyg/EbWONDGDEQ=; b=lRr0iV7jW0zq00Y+PI9+C7cOPYDyM1oIQtYgXGw2Jok5nCprEdhOZiwh5Vp+h7I5bK sDVm/tVXX/1Feq/Yn7thUALZCMh8wcsS13njzNpVOyy+NKgPOQxkgpwOHjheAOj5H8PN jPS12IkBQ5rM8aOk+DU5/JDyzG2RLZTleokG0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cJ2b5yC6U6sZBSPpf2NMndA3c8MuYwyg/EbWONDGDEQ=; b=O8W/dnhycoOGBFZx3n/a7insUjUPIGTPapkacNEvuX3tQtAkkZ/npa6hh1s1rC1uyC yfpWpm+lsdere/S4fcweb5y8zi0qt5TdpO5kIOXCqM10fFeI9swvSc59W/8UPSdAAJbk xqDMtmf76nxb53Tk3SmoeHYJdPlLK3sY7XfK/uFom6oT5KSvzV1nhXnYrwCpgXQboeyX 86wLKk2/Icisf5SozlWwTjxjfDNOBEXStSkbjoRWOgRmO6yyIThNV5CZJVRtvzcWxouv yapMKdkPsQkdFkdmCzaudE6qh6paf0Y8Yqv5LX6B721HBKqzoZG9lJ/jc/WSqN6Rtdcg mm3w== X-Gm-Message-State: AOAM530RzVmDg2kXZ5/1sOOr0bdDxrbd/wzkvUfblojU4JA4umEm3QBj 5btwsNv7Fiks6TsT/Ec5YgH3lgZ781mgh2bN X-Google-Smtp-Source: ABdhPJy0kQhiImzPyvMTXIoe3S5XBcVzI1ubsHTbbUHt8tNPKWinvH0asFzNdG96HgDS858kUtEN9w== X-Received: by 2002:a17:902:9349:b029:d0:cb2d:f26c with SMTP id g9-20020a1709029349b02900d0cb2df26cmr156960plp.5.1599644559530; Wed, 09 Sep 2020 02:42:39 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id a23sm1692275pgv.86.2020.09.09.02.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 02:42:39 -0700 (PDT) From: Joseph Hwang <josephsih@chromium.org> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Joseph Hwang <josephsih@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 2/2] Bluetooth: sco: expose WBS packet length in socket option Date: Wed, 9 Sep 2020 17:42:02 +0800 Message-Id: <20200909174129.v2.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog In-Reply-To: <20200909094202.3863687-1-josephsih@chromium.org> References: <20200909094202.3863687-1-josephsih@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.25 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9741DA0377 X-Rspamd-UID: 18c622 It is desirable to expose the wideband speech packet length via a socket option to the user space so that the user space can set the value correctly in configuring the sco connection. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Signed-off-by: Joseph Hwang <josephsih@chromium.org> --- (no changes since v1) net/bluetooth/sco.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index dcf7f96ff417e6..79ffcdef0b7ad5 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -1001,6 +1001,12 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, err = -EFAULT; break; + case BT_SNDMTU: + case BT_RCVMTU: + if (put_user(sco_pi(sk)->conn->mtu, (u32 __user *)optval)) + err = -EFAULT; + break; + default: err = -ENOPROTOOPT; break; -- 2.28.0.526.ge36021eeef-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wDiABA6kWF9udAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 11:44:46 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CIaYAQ6kWF/SUQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 11:44:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 29CFC4096F; Wed, 9 Sep 2020 11:44:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730242AbgIIJnZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 05:43:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729865AbgIIJmg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 05:42:36 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4845C061757 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 02:42:35 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id d6so1658724pfn.9 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 02:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LM8k8PH144bWX32V81bl75ySx0lFv/PzcP9daHe+hWQ=; b=JcM5Yd/IXdWAIh4gsWrVP3HdA6WElnrDWDk5l4ya3I60zj+1HjARAK0+x6mzB0ujBd lX7ywlj0rd48abSwN9kOWF1w2Z1l5yjFya/frkXvJF+D66IK5ywe4hDGhR/nrv8JNi2D wz5Zi/uG2Hh1qKDsvgAPX2UxC+Eb+9O7tuRWE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LM8k8PH144bWX32V81bl75ySx0lFv/PzcP9daHe+hWQ=; b=S+Z8k+gVy4BJ58kkyl7HnerFiz0iGl+P9Zu4Pnp6H8wb9X+eltAGUomefTeIi387GB NvO7fuGjDDROhsMGygURrEiH5hS8wd0B+9BOCwjhIm0Y5k3oJEwR2iNKcFqTRYFyW8AE IImFg8eHo0PsZMn1RxG4c/DGkkbWQA8D08esS8NjzNpx7DZWxDIhejFYOGLDNL7D1G23 ZxgshHYU8sZvBXY0mNh+odsnRTk9b+GnKmAN4Bjm2QcFlzWTFQVugEvXHFc4M9VuFNXj V7ZVm8ndsSLLh3Gx4fuet/HT0/7ds4IjzpnARBryhQaVp6sBaZ0SWAObMyzmE5z3GB7j rImw== X-Gm-Message-State: AOAM533ctMqxxRFN8xB5ez/Ej2ATucPey7TZCgNYWHvnHsM8YUnwn2nh 1OZ6KC5e7IjP+iEdG36O00AqnL74UzGAzRTI X-Google-Smtp-Source: ABdhPJwYRo0TowgGsBXgHgPUfP4VvsQRLtOvXZKYp67wUUhQCuoYO8pkD40Xhy3cIVN1ajxD4VzqnA== X-Received: by 2002:a63:4b47:: with SMTP id k7mr2365937pgl.437.1599644554905; Wed, 09 Sep 2020 02:42:34 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id a23sm1692275pgv.86.2020.09.09.02.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 02:42:34 -0700 (PDT) From: Joseph Hwang <josephsih@chromium.org> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Joseph Hwang <josephsih@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 1/2] Bluetooth: btusb: define HCI packet sizes of USB Alts Date: Wed, 9 Sep 2020 17:42:01 +0800 Message-Id: <20200909174129.v2.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog In-Reply-To: <20200909094202.3863687-1-josephsih@chromium.org> References: <20200909094202.3863687-1-josephsih@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.13 / 15.00 / 15.00 X-Rspamd-Queue-Id: 29CFC4096F X-Rspamd-UID: f031c0 It is desirable to define the HCI packet payload sizes of USB alternate settings so that they can be exposed to user space. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Signed-off-by: Joseph Hwang <josephsih@chromium.org> --- Changes in v2: - 1/2: Used sco_mtu instead of a new sco_pkt_len member in hdev. - 1/2: Do not overwrite hdev->sco_mtu in hci_cc_read_buffer_size if it has been set in the USB interface. - 2/2: Used BT_SNDMTU/BT_RCVMTU instead of creating a new opt name. - 2/2: Used the existing conn->mtu instead of creating a new member in struct sco_pinfo. - 2/2: Noted that the old SCO_OPTIONS in sco_sock_getsockopt_old() would just work as it uses sco_pi(sk)->conn->mtu. drivers/bluetooth/btusb.c | 43 +++++++++++++++++++++++++++++---------- net/bluetooth/hci_event.c | 7 ++++++- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index fe80588c7bd3a8..a710233382afff 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -459,6 +459,22 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { #define BTUSB_WAKEUP_DISABLE 14 #define BTUSB_USE_ALT1_FOR_WBS 15 +/* Per core spec 5, vol 4, part B, table 2.1, + * list the hci packet payload sizes for various ALT settings. + * This is used to set the packet length for the wideband speech. + * If a controller does not probe its usb alt setting, the default + * value will be 0. Any clients at upper layers should interpret it + * as a default value and set a proper packet length accordingly. + * + * To calculate the HCI packet payload length: + * for alternate settings 1 - 5: + * hci_packet_size = suggested_max_packet_size * 3 (packets) - + * 3 (HCI header octets) + * for alternate setting 6: + * hci_packet_size = suggested_max_packet_size - 3 (HCI header octets) + */ +static const int hci_packet_size_usb_alt[] = { 0, 24, 48, 72, 96, 144, 60 }; + struct btusb_data { struct hci_dev *hdev; struct usb_device *udev; @@ -3959,6 +3975,15 @@ static int btusb_probe(struct usb_interface *intf, hdev->notify = btusb_notify; hdev->prevent_wake = btusb_prevent_wake; + if (id->driver_info & BTUSB_AMP) { + /* AMP controllers do not support SCO packets */ + data->isoc = NULL; + } else { + /* Interface orders are hardcoded in the specification */ + data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); + data->isoc_ifnum = ifnum_base + 1; + } + #ifdef CONFIG_PM err = btusb_config_oob_wake(hdev); if (err) @@ -4022,6 +4047,10 @@ static int btusb_probe(struct usb_interface *intf, hdev->set_diag = btintel_set_diag; hdev->set_bdaddr = btintel_set_bdaddr; hdev->cmd_timeout = btusb_intel_cmd_timeout; + + if (btusb_find_altsetting(data, 6)) + hdev->sco_mtu = hci_packet_size_usb_alt[6]; + set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); @@ -4063,15 +4092,6 @@ static int btusb_probe(struct usb_interface *intf, btusb_check_needs_reset_resume(intf); } - if (id->driver_info & BTUSB_AMP) { - /* AMP controllers do not support SCO packets */ - data->isoc = NULL; - } else { - /* Interface orders are hardcoded in the specification */ - data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); - data->isoc_ifnum = ifnum_base + 1; - } - if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) && (id->driver_info & BTUSB_REALTEK)) { hdev->setup = btrtl_setup_realtek; @@ -4083,9 +4103,10 @@ static int btusb_probe(struct usb_interface *intf, * (DEVICE_REMOTE_WAKEUP) */ set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); - if (btusb_find_altsetting(data, 1)) + if (btusb_find_altsetting(data, 1)) { set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); - else + hdev->sco_mtu = hci_packet_size_usb_alt[1]; + } else bt_dev_err(hdev, "Device does not support ALT setting 1"); } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 33d8458fdd4adc..b3e9247fdbcfa1 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -730,7 +730,12 @@ static void hci_cc_read_buffer_size(struct hci_dev *hdev, struct sk_buff *skb) return; hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); - hdev->sco_mtu = rp->sco_mtu; + /* Set sco_mtu only when not yet. + * The sco_mtu would be set in btusb.c + * if the host controller interface is USB. + */ + if (hdev->sco_mtu == 0) + hdev->sco_mtu = rp->sco_mtu; hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); -- 2.28.0.526.ge36021eeef-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KGbTFjikWF9udAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 11:45:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UHLUEzikWF97hgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 11:45:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F03E6A0B55; Wed, 9 Sep 2020 11:45:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730205AbgIIJpR (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 05:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728360AbgIIJma (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 05:42:30 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EF3AC061756 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 02:42:30 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id 5so1683131pgl.4 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 02:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jlaTjOBgc0QZjU31Izm6AsUUQrjtSK2SvcixEKeEsE8=; b=lCHL9DHS53o+bnJKp6cYHHdrWZYOKVCR6NbsR2WBJpkMdvT7ap6vGvxUUyAwT/WgDb wauu3XqVuJHpZCvEb6gG93hDYcCML1aTllTQJZBSGrU97UBjtLSTvSdIGjg/1YZddSf0 PgtPlCU6NmuYASDFXLwDqXY2dF20J4mT2Suew= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jlaTjOBgc0QZjU31Izm6AsUUQrjtSK2SvcixEKeEsE8=; b=PbNtzQw4QPC6RF+uUYckC3fpuhm4vFO1sDaloN7Q9N4Pf9E7SyCFO/WayhEa3owCtw Dh61+eewBfI2XIErG2UbQOhRDuRmje9O9aCAR7PPMY7ay7kfxM08X047iWa5htJM8hmx fw9i79oiVR/PYTQpHeFCYhNDl49MguAJwEy7zK7HA1SF1Tu8s4LwrYzHF+5xYvXFyeqy lJZ3AxgIWI319X2SjIVh5kv5RmX/hZFZIRfx7c9hrtHzg6LujMWvLhGVDXlLhBIt4bf0 D+IoBVhmHGU8ZHflC9QthZy5wCgNFXXvUEl7vTO67Gb0qemwzWvNgfDxp/hWWFrIjYe4 a8FQ== X-Gm-Message-State: AOAM531iChj6uXjsPmzr6bLyVBnMtAvs5QEA3al9BiT80/X6UDotOQhR Rt8NOk1JGzOITG+XTxznOFYlP6EHJymdOCPZ X-Google-Smtp-Source: ABdhPJxD1LhB03iJ0WDmnlt6k5koTHmIjLIFvh5wJ+EJEWXscCXa5QmNf2+TsW5xKjfw8a18oFyatQ== X-Received: by 2002:a62:3146:0:b029:13e:d13d:a08e with SMTP id x67-20020a6231460000b029013ed13da08emr125438pfx.37.1599644549498; Wed, 09 Sep 2020 02:42:29 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id a23sm1692275pgv.86.2020.09.09.02.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 02:42:28 -0700 (PDT) From: Joseph Hwang <josephsih@chromium.org> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Joseph Hwang <josephsih@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 0/2] To support the HFP WBS, a chip vendor may choose a particular Date: Wed, 9 Sep 2020 17:42:00 +0800 Message-Id: <20200909094202.3863687-1-josephsih@chromium.org> X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.98 / 15.00 / 15.00 X-Rspamd-Queue-Id: F03E6A0B55 X-Rspamd-UID: e7ad08 USB alternate seeting of which the packet size is distinct. The patches are to expose the packet size to user space so that the user space does not need to hard code those values. We have verified this patch on Chromebooks which use - Realtek 8822CE controller with USB alt setting 1 - Intel controller with USB alt setting 6 Our user space audio server, cras, can get the correct packet length from the socket option. Changes in v2: - 1/2: Used sco_mtu instead of a new sco_pkt_len member in hdev. - 1/2: Do not overwrite hdev->sco_mtu in hci_cc_read_buffer_size if it has been set in the USB interface. - 2/2: Used BT_SNDMTU/BT_RCVMTU instead of creating a new opt name. - 2/2: Used the existing conn->mtu instead of creating a new member in struct sco_pinfo. - 2/2: Noted that the old SCO_OPTIONS in sco_sock_getsockopt_old() would just work as it uses sco_pi(sk)->conn->mtu. Joseph Hwang (2): Bluetooth: btusb: define HCI packet sizes of USB Alts Bluetooth: sco: expose WBS packet length in socket option drivers/bluetooth/btusb.c | 43 +++++++++++++++++++++++++++++---------- net/bluetooth/hci_event.c | 7 ++++++- net/bluetooth/sco.c | 6 ++++++ 3 files changed, 44 insertions(+), 12 deletions(-) -- 2.28.0.526.ge36021eeef-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WIbGHkC8WF/wIQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 13:28:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UC5WHEC8WF+I/QAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 13:28:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A9AFEA0B2A; Wed, 9 Sep 2020 13:27:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728709AbgIILGm (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 07:06:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:51494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727055AbgIILGe (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 07:06:34 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9041D207DE; Wed, 9 Sep 2020 11:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599649577; bh=yzAVVTGejCUdvUjaQabL2dAqIR8EN08fQBJMkB8pdBA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NFcIcQ/0JBDUyaDGa+cShYbmKdhfVzFonCO0aevmzDLjjkrTYxuSOb7ZHNKK9zb7W s1w+mr3agpxd3e+Mp1agfx1A93cWg8zC9JEyT/po9tCM6LXJLXVd9JDf4gLsTuowbm lhnGMjiUrLYuUANxNMP33v5RA2P55UVf+7M5wJgw= Received: by pali.im (Postfix) id 55B817A9; Wed, 9 Sep 2020 13:06:15 +0200 (CEST) Date: Wed, 9 Sep 2020 13:06:15 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Joseph Hwang <josephsih@chromium.org> Cc: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v2 1/2] Bluetooth: btusb: define HCI packet sizes of USB Alts Message-ID: <20200909110615.qbwb3m34l2mkv743@pali> References: <20200909094202.3863687-1-josephsih@chromium.org> <20200909174129.v2.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200909174129.v2.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.62 / 15.00 / 15.00 X-Rspamd-Queue-Id: A9AFEA0B2A X-Rspamd-UID: 45935c On Wednesday 09 September 2020 17:42:01 Joseph Hwang wrote: > It is desirable to define the HCI packet payload sizes of > USB alternate settings so that they can be exposed to user > space. > > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > --- > > Changes in v2: > - 1/2: Used sco_mtu instead of a new sco_pkt_len member in hdev. > - 1/2: Do not overwrite hdev->sco_mtu in hci_cc_read_buffer_size > if it has been set in the USB interface. > - 2/2: Used BT_SNDMTU/BT_RCVMTU instead of creating a new opt name. > - 2/2: Used the existing conn->mtu instead of creating a new member > in struct sco_pinfo. > - 2/2: Noted that the old SCO_OPTIONS in sco_sock_getsockopt_old() > would just work as it uses sco_pi(sk)->conn->mtu. > > drivers/bluetooth/btusb.c | 43 +++++++++++++++++++++++++++++---------- > net/bluetooth/hci_event.c | 7 ++++++- > 2 files changed, 38 insertions(+), 12 deletions(-) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index fe80588c7bd3a8..a710233382afff 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -459,6 +459,22 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { > #define BTUSB_WAKEUP_DISABLE 14 > #define BTUSB_USE_ALT1_FOR_WBS 15 > > +/* Per core spec 5, vol 4, part B, table 2.1, > + * list the hci packet payload sizes for various ALT settings. > + * This is used to set the packet length for the wideband speech. > + * If a controller does not probe its usb alt setting, the default > + * value will be 0. Any clients at upper layers should interpret it > + * as a default value and set a proper packet length accordingly. > + * > + * To calculate the HCI packet payload length: > + * for alternate settings 1 - 5: > + * hci_packet_size = suggested_max_packet_size * 3 (packets) - > + * 3 (HCI header octets) > + * for alternate setting 6: > + * hci_packet_size = suggested_max_packet_size - 3 (HCI header octets) Hello! What is value for 'suggested_max_packet_size' used in above calculation algorithm? > + */ > +static const int hci_packet_size_usb_alt[] = { 0, 24, 48, 72, 96, 144, 60 }; > + > struct btusb_data { > struct hci_dev *hdev; > struct usb_device *udev; > @@ -3959,6 +3975,15 @@ static int btusb_probe(struct usb_interface *intf, > hdev->notify = btusb_notify; > hdev->prevent_wake = btusb_prevent_wake; > > + if (id->driver_info & BTUSB_AMP) { > + /* AMP controllers do not support SCO packets */ > + data->isoc = NULL; > + } else { > + /* Interface orders are hardcoded in the specification */ > + data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); > + data->isoc_ifnum = ifnum_base + 1; > + } > + > #ifdef CONFIG_PM > err = btusb_config_oob_wake(hdev); > if (err) > @@ -4022,6 +4047,10 @@ static int btusb_probe(struct usb_interface *intf, > hdev->set_diag = btintel_set_diag; > hdev->set_bdaddr = btintel_set_bdaddr; > hdev->cmd_timeout = btusb_intel_cmd_timeout; > + > + if (btusb_find_altsetting(data, 6)) > + hdev->sco_mtu = hci_packet_size_usb_alt[6]; > + > set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); > set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); > set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); > @@ -4063,15 +4092,6 @@ static int btusb_probe(struct usb_interface *intf, > btusb_check_needs_reset_resume(intf); > } > > - if (id->driver_info & BTUSB_AMP) { > - /* AMP controllers do not support SCO packets */ > - data->isoc = NULL; > - } else { > - /* Interface orders are hardcoded in the specification */ > - data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); > - data->isoc_ifnum = ifnum_base + 1; > - } > - > if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) && > (id->driver_info & BTUSB_REALTEK)) { > hdev->setup = btrtl_setup_realtek; > @@ -4083,9 +4103,10 @@ static int btusb_probe(struct usb_interface *intf, > * (DEVICE_REMOTE_WAKEUP) > */ > set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); > - if (btusb_find_altsetting(data, 1)) > + if (btusb_find_altsetting(data, 1)) { > set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); > - else > + hdev->sco_mtu = hci_packet_size_usb_alt[1]; > + } else > bt_dev_err(hdev, "Device does not support ALT setting 1"); > } > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 33d8458fdd4adc..b3e9247fdbcfa1 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -730,7 +730,12 @@ static void hci_cc_read_buffer_size(struct hci_dev *hdev, struct sk_buff *skb) > return; > > hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); > - hdev->sco_mtu = rp->sco_mtu; > + /* Set sco_mtu only when not yet. > + * The sco_mtu would be set in btusb.c > + * if the host controller interface is USB. > + */ > + if (hdev->sco_mtu == 0) > + hdev->sco_mtu = rp->sco_mtu; Should not hdev->sco_mtu contains minimum from the rp->sco_mtu and your calculated value defined in hci_packet_size_usb_alt[i]? Socket MTU cannot be bigger then value rp->sco_mtu, right? > hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); > hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); > > -- > 2.28.0.526.ge36021eeef-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +LTPLc34WF8WpAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 17:46:21 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2GkfK834WF8k/gEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 17:46:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4E38AA0B38; Wed, 9 Sep 2020 17:46:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730491AbgIIPp7 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 11:45:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:46132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730474AbgIIPpe (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 11:45:34 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3EBA1207DE; Wed, 9 Sep 2020 11:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599649899; bh=gk5ai7/vsUBs2dl7VhzTb79HWtwuO4OdRiCJ/geHW4g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xt32yCIJZrUnpBjf6/MToHhOH5aK0XvmwKj0BwuSH4Fcsie9nQ0R0tHFTEEnVTFIP 29njlrTtNhos9A/wOErrHOF4fNWmUSFQ9GV2x/XbjDPYvt+u9vNWaHJT8TSYsNQWbr xUrm/P+mViuyxOWWowDpQZ7V6BMBiafgTH9hvMDw= Received: by pali.im (Postfix) id B61AE7A9; Wed, 9 Sep 2020 13:11:36 +0200 (CEST) Date: Wed, 9 Sep 2020 13:11:36 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Joseph Hwang <josephsih@chromium.org> Cc: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v2 2/2] Bluetooth: sco: expose WBS packet length in socket option Message-ID: <20200909111136.ghp5p56m4cxfjreo@pali> References: <20200909094202.3863687-1-josephsih@chromium.org> <20200909174129.v2.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200909174129.v2.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.62 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4E38AA0B38 X-Rspamd-UID: 30a1e7 On Wednesday 09 September 2020 17:42:02 Joseph Hwang wrote: > It is desirable to expose the wideband speech packet length via > a socket option to the user space so that the user space can set > the value correctly in configuring the sco connection. Hello! I'm fine with change below, but I would suggest to put more details into commit message. This change has nothing to do with wideband nor with exporting socket option to userspace -- which is already done via SCO_OPTIONS option. Also it is relevant to SCO socket with any codec data, not only wideband. This commit description should rather mention that it defines new getsockopt options BT_SNDMTU/BT_RCVMTU for SCO socket to be compatible with other bluetooth sockets and that these options return same value as option SCO_OPTIONS which is already present on existing kernels. > > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > --- > > (no changes since v1) > > net/bluetooth/sco.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c > index dcf7f96ff417e6..79ffcdef0b7ad5 100644 > --- a/net/bluetooth/sco.c > +++ b/net/bluetooth/sco.c > @@ -1001,6 +1001,12 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, > err = -EFAULT; > break; > > + case BT_SNDMTU: > + case BT_RCVMTU: > + if (put_user(sco_pi(sk)->conn->mtu, (u32 __user *)optval)) > + err = -EFAULT; > + break; > + > default: > err = -ENOPROTOOPT; > break; > -- > 2.28.0.526.ge36021eeef-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YBdnDRj+WF8zvwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 18:08:56 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0OQxChj+WF8RxAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 18:08:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B3D9240866; Wed, 9 Sep 2020 18:08:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728643AbgIIQCY (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 12:02:24 -0400 Received: from mga06.intel.com ([134.134.136.31]:24720 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730588AbgIIP6l (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 11:58:41 -0400 IronPort-SDR: HfHz0HYwYzcxBjcfjkD1C9aIUTuzD7kyyKf/NoCG7KuonPhnss/MzaE03t2Et+vm/NeA9j5AiU PwQQb1cg2prA== X-IronPort-AV: E=McAfee;i="6000,8403,9739"; a="219914229" X-IronPort-AV: E=Sophos;i="5.76,409,1592895600"; d="scan'208";a="219914229" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2020 08:58:34 -0700 IronPort-SDR: IxS2NNZPAt2NRkBv9utGp2ZLBkdzxhLw/E5scRDzqhT/M++Tk2UWKTt0kNUyh6hNiaeJlEgkzL t8tpg9ojlopw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,409,1592895600"; d="scan'208";a="333863841" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga008.jf.intel.com with ESMTP; 09 Sep 2020 08:58:33 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from <andriy.shevchenko@linux.intel.com>) id 1kG2UQ-00FTRF-Ib; Wed, 09 Sep 2020 18:58:30 +0300 Date: Wed, 9 Sep 2020 18:58:30 +0300 From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org Subject: Re: [PATCH v1 1/4] Bluetooth: hci_intel: enable on new platform Message-ID: <20200909155830.GE1891694@smile.fi.intel.com> References: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.73 / 15.00 / 15.00 X-Rspamd-Queue-Id: B3D9240866 X-Rspamd-UID: 122f30 On Thu, Sep 03, 2020 at 09:48:47PM +0300, Andy Shevchenko wrote: > On new Intel platform the device is provided with INT33E3 ID. > Append it to the list. > > This will require ACPI_GPIO_QUIRK_ONLY_GPIOIO to be enabled because > the relevant ASL looks like: > > UartSerialBusV2 ( ... ) > GpioInt ( ... ) { ... } > GpioIo ( ... ) { ... } > > which means that first GPIO resource is an interrupt, while we are expecting it > to be reset one (output). Do the same for host-wake because in case of > GpioInt() the platform_get_irq() will do the job and should return correct > Linux IRQ number. That said, host-wake GPIO can only be GpioIo() resource. > > While here, drop commas in terminator lines. Any comments? > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > drivers/bluetooth/hci_intel.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c > index f1299da6eed8..703d774be5a6 100644 > --- a/drivers/bluetooth/hci_intel.c > +++ b/drivers/bluetooth/hci_intel.c > @@ -1076,7 +1076,8 @@ static const struct hci_uart_proto intel_proto = { > #ifdef CONFIG_ACPI > static const struct acpi_device_id intel_acpi_match[] = { > { "INT33E1", 0 }, > - { }, > + { "INT33E3", 0 }, > + { } > }; > MODULE_DEVICE_TABLE(acpi, intel_acpi_match); > #endif > @@ -1138,9 +1139,9 @@ static const struct acpi_gpio_params reset_gpios = { 0, 0, false }; > static const struct acpi_gpio_params host_wake_gpios = { 1, 0, false }; > > static const struct acpi_gpio_mapping acpi_hci_intel_gpios[] = { > - { "reset-gpios", &reset_gpios, 1 }, > - { "host-wake-gpios", &host_wake_gpios, 1 }, > - { }, > + { "reset-gpios", &reset_gpios, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, > + { "host-wake-gpios", &host_wake_gpios, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, > + { } > }; > > static int intel_probe(struct platform_device *pdev) > -- > 2.28.0 > -- With Best Regards, Andy Shevchenko Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SKtOIsEPWV+dKQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 19:24:17 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +HHMHsEPWV+ZUAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 19:24:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A595F4096B; Wed, 9 Sep 2020 19:24:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730674AbgIIQ6M convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 12:58:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:51918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730677AbgIIPvT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 11:51:19 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Wed, 09 Sep 2020 14:12:34 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Maltahlgaming@gmail.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-60824-62941-ApvqxbMfJC@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.79 / 15.00 / 15.00 X-Rspamd-Queue-Id: A595F4096B X-Rspamd-UID: 59bec3 https://bugzilla.kernel.org/show_bug.cgi?id=60824 Maltahlgaming@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |Maltahlgaming@gmail.com --- Comment #151 from Maltahlgaming@gmail.com --- (In reply to Real Name from comment #150) > (In reply to vic from comment #149) > > Does anyone here know if it supports BLE on Microsoft Windows? > > Mine at least doesn't. Trying to pair a device as BLE device doesn't do > anything. > > I was assessing if there was anything to get from the Windows driver but it > seemingly doesn't have anything new to offer. But I'm far from an expert, so > anyone with more knowledge is invited to chime in. I have tried with my own fake CSR Bluetooth 5.0 adapter on Windows 10 and that works fine after i manually override the default plug and play driver with the generic bluetooth dongle driver in Device Manager. I could connect and use BLE devices without issues but on Linux it can see other devices but not connect regardless of bluetooth version. Details on the dongle from Linux Kernel 5.8.3 > Bus 001 Device 020: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 224 Wireless bDeviceSubClass 1 Radio Frequency bDeviceProtocol 1 Bluetooth bMaxPacketSize0 64 idVendor 0x0a12 Cambridge Silicon Radio, Ltd idProduct 0x0001 Bluetooth Dongle (HCI mode) bcdDevice 88.91 iManufacturer 0 iProduct 2 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x00b1 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower 100mA > -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WDP6KacvWV9xnAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 09 Sep 2020 21:40:23 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AG5RJ6cvWV9thgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 09 Sep 2020 21:40:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 63E0C408AE; Wed, 9 Sep 2020 21:40:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726226AbgIITkQ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 15:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725772AbgIITkQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 15:40:16 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB61EC061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 12:40:15 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id c78so3258042ybf.6 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 12:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=mVmjxlDiU2KnidTRFEq6fyxwn9W4wZsX/zi+fKeDAo8=; b=ISt9R3Curlc/gQu89vI860EnN4xzu+m2uBESotHk5xyvH7H+7x8cnVdhp2znSG4HCw Ah0Nz9McfvkGVU8Y9l4mqNLTsb68x/NNpY+FRn3HCBN+otXnYDfZtmQl8R7dzyqhs8MR 88axNp/W39Wisa+zywVJHmlY+PYOLk4mnTB39yh4ZpjAR+2BvXbRmVzg7nTDpHzbx4Ts GCJf6Zij6I+9jiw8h23y+iIpwagI21TKxmS17AHh26uICxmioCxzw/9+cIuuMlfE59db XvgXv4MMmRveXIDocc4VvvuGd3CBOkn5xq67m4sqJGDY5jlgODD7NzSTBzQQZ34c2YyR NiUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=mVmjxlDiU2KnidTRFEq6fyxwn9W4wZsX/zi+fKeDAo8=; b=RdHpJXmrgav2qRu2+9bLNjODYu4GYYFqQeZMWWMPLSz4KWC40gA+UooUB4McA1lPun TxD8pzO5Li+D4MbCThzERBx99hgZkUIIsVcdBUTsJdddWTSdtoD/lIB67tGdCIO6+AG1 0oj1OCr1lXNKVW38CXR0RntrYl0MjgOdoJ+AxqzGAiA8wJ9AWOcI+0k75qxUkHomV6yd DgQKRv7SuXfunJSWKOwaaNLRjsOCMUzBct+WtUFJvBqScYg8ePi0iK722i19ScSRykVI tpupI5l+aMlzWziDTH8/EQW8CfVswu+N7QiYlsZTuOJO9lgPv2Bbk8XE1JXzzhbRgNk3 kq4g== X-Gm-Message-State: AOAM5301MuAQBFBZHXYxYyYsI/pgS/FH0IwGmFCzMGJ5oTumNEf8pEME LDqDWqKuS7vRpzia4M8rUEu5zzlzxvVJVg== X-Google-Smtp-Source: ABdhPJyPoC7UuA9JaWb6Vi5OyCFRUFwLjDUyqI0lV/SpeUarTC8wzOaVoWN9WRFa2KqSb4tq4Aqg32Ow1l3pgQ== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:e50e]) (user=mmandlik job=sendgmr) by 2002:a25:e655:: with SMTP id d82mr8569827ybh.347.1599680414871; Wed, 09 Sep 2020 12:40:14 -0700 (PDT) Date: Wed, 9 Sep 2020 12:40:01 -0700 Message-Id: <20200909123943.BlueZ.v2.1.I588558f1e38231193d6e955a4008ce54712d5c89@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog Subject: [BlueZ PATCH v2] Disable auto-connect on device remove From: Manish Mandlik <mmandlik@google.com> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: alainm@chromium.org, chromeos-bluetooth-upstreaming@chromium.org, sonnysasaka@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik <mmandlik@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.27 / 15.00 / 15.00 X-Rspamd-Queue-Id: 63E0C408AE X-Rspamd-UID: 0b94cd Auto-connect is not disabled when a device is removed. So in case the pairing is cancelled, the device is removed, but it stays in the kernel auto-connect list. This causes future advertisement from that device to trigger a pairing even if the user has already cancelled the pairing. This patch disables auto-connect on device remove. Signed-off-by: Manish Mandlik <mmandlik@google.com> --- Changes in v2: - Disable auto-connect on device remove instead of pairing cancel as this is the main culprit of the issue. - Updated the title from "Disable auto-connect on cancel pair" to "Disable auto-connect on device remove" src/device.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/device.c b/src/device.c index df440ce09..8f73ce4d3 100644 --- a/src/device.c +++ b/src/device.c @@ -4447,6 +4447,11 @@ void device_remove(struct btd_device *device, gboolean remove_stored) { DBG("Removing device %s", device->path); + if (device->auto_connect) { + device->disable_auto_connect = TRUE; + device_set_auto_connect(device, FALSE); + } + if (device->bonding) { uint8_t status; -- 2.28.0.526.ge36021eeef-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GLxhKXuSWV+2NQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 04:42:03 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EGOJJnuSWV9eOAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 04:42:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5A8F34086A; Thu, 10 Sep 2020 04:41:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730466AbgIJCl4 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 22:41:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730550AbgIJCHb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 22:07:31 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D09A2C06179A for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 16:17:57 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id i17so4095887oig.10 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 16:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bjnyjKd25dOcqGH9+s24M9hfWxRB0eNJKTA9Gi7wA6I=; b=fa6hbvzhSU6l05lBT6QBfJzUoJpXUw1f8EljefohFjMJmbo65cAtsHIUgyJK5otEBn hKq8gC0cTPhmPsXqmd0kdAcAauReMkUbZ1zsuxLsh7rz44cV+yC86WVRVWs2xdHeWEnS scVZy8k4bgHNYDscHJKipiTKD4thWuPxlQxJj3dYas7qyZLE72EhUFl8fcGvad/3ZmU+ PtyiMPqvHGQaF0voUfB1o7vFRkiBkHo+CAbwqmtFndJG9OF8r/Ox+ojujv4aC80EFDY2 xf0d8rMwTLPx1KhKGsUNzrWYP/y8zrML9VbpSl7ULqLsiUQNkBldOXp15BCiScMEdtUl vlMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bjnyjKd25dOcqGH9+s24M9hfWxRB0eNJKTA9Gi7wA6I=; b=S0krRJ8gOUnrvhXJZpCEYDwyCJcznmq8e9R464pAei18C0YFfHOZtm7sijaDp/XSFU fo5Xsu2NYjlRN4fHRss6WtFedk9etDbrFCeDTy1UmyTZijsE3mxC/6fbkfRkffk0HmFR VIkZ0o6Jhhrp4somKpbv1QHaez6xSJsc4oZkTMTpOhykPwkUxog4NTXbpXBkQARHMqSO n4oCuCpumTW6SNhoCL+SB0+yJ4tVEpJF9EhT+H0LB4F2/UpT7ndvRliaUE2lxt6XlxAE Lg19bOtfbw3/eMGox/bXk1kIDLtRopWL8w4aWoIXlxqsfjVfYbcXGPH1d9VMFYqGuxZL 7M1g== X-Gm-Message-State: AOAM5327meC161Lhs5D4CPt/M8uyKsjSR594YAKicDwTerPjC/ou4lck I8gxFLus68HUj/P2+qKqUIJLTAUWKZ/s4mPtT3QKnq3u X-Google-Smtp-Source: ABdhPJzyy7tre9zx1WHEu93cKQpqz3KqB/Mvr+tjTr2n1B2zC7SM+K0kMBQubfxWQ6byxJAtCCppOkxXE73owtY/+/w= X-Received: by 2002:aca:a9c9:: with SMTP id s192mr2012232oie.152.1599693476783; Wed, 09 Sep 2020 16:17:56 -0700 (PDT) MIME-Version: 1.0 References: <20200909123943.BlueZ.v2.1.I588558f1e38231193d6e955a4008ce54712d5c89@changeid> In-Reply-To: <20200909123943.BlueZ.v2.1.I588558f1e38231193d6e955a4008ce54712d5c89@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 9 Sep 2020 16:17:46 -0700 Message-ID: <CABBYNZKyxXQY8H+M1iAWvti-s5J7VejeYEJDqOfJCJEZ075+4A@mail.gmail.com> Subject: Re: [BlueZ PATCH v2] Disable auto-connect on device remove To: Manish Mandlik <mmandlik@google.com> Cc: Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5A8F34086A X-Rspamd-UID: 33f384 Hi Manish, On Wed, Sep 9, 2020 at 12:40 PM Manish Mandlik <mmandlik@google.com> wrote: > > Auto-connect is not disabled when a device is removed. So in case the > pairing is cancelled, the device is removed, but it stays in the kernel > auto-connect list. This causes future advertisement from that device to > trigger a pairing even if the user has already cancelled the pairing. > > This patch disables auto-connect on device remove. > > Signed-off-by: Manish Mandlik <mmandlik@google.com> > --- > > Changes in v2: > - Disable auto-connect on device remove instead of pairing cancel as this > is the main culprit of the issue. > - Updated the title from "Disable auto-connect on cancel pair" to "Disable > auto-connect on device remove" > > src/device.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/src/device.c b/src/device.c > index df440ce09..8f73ce4d3 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -4447,6 +4447,11 @@ void device_remove(struct btd_device *device, gboolean remove_stored) > { > DBG("Removing device %s", device->path); > > + if (device->auto_connect) { > + device->disable_auto_connect = TRUE; > + device_set_auto_connect(device, FALSE); > + } > + > if (device->bonding) { > uint8_t status; > > -- > 2.28.0.526.ge36021eeef-goog > Appled, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4DeQB6uTWV+2NQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 04:47:07 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cCPgBKuTWV8zlQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 04:47:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 82556A0B24; Thu, 10 Sep 2020 04:47:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730416AbgIJCAc (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 22:00:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730150AbgIJByT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 21:54:19 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05CD7C061389 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 16:54:08 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id j7so14223plk.11 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 16:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gTez5zBL4O/mFCX1yAYIY6uoJGixvvecrhH5yeefCRU=; b=SxkcIkqSWelb6AuUlXuHUzy1a16hhmWXJWuq8Eo/23y2lOyPcWQDUSskXt1hEJUyn6 u1wOiYNDBdX/GAOiEZ/EkYArPHBOHNGFUNcC9AVgOMGKko3iXNgtwmArngx7TwMORv1T Q14fEfQF9K7z06eGlkuJ30cEupLsJdCrymIDQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gTez5zBL4O/mFCX1yAYIY6uoJGixvvecrhH5yeefCRU=; b=EdRBASCggXyFS7lNosDGcVA2aKF8VpPkQzRJtxq/S8q7PH+yrZXomR6Zr3Hauzot1o rA/QUgwBz8FGO2Tf+eV3FA9tkyT5XS98usC+CgX06s95ENrZfCPM1Vg8kIWJs2ZZtkUt ft6SRWJwA3WVbw9m1Ouct53orCNgv/I0TfoTMyd+w2JiCj9lzb8EWh0LQC74YO1YvJwm XbzrZhhkVXotxsikOOhzfyQ7uYapAI/4JpDgt33NWI2XYi3qKPooY3e5oVxLaV7JuaNW Ve2apMQFWrYIebi7E8yYwrgaLmCqVwEInp0nDAr7Zaz5qJj8iLRKtF7KzpmuPyyw0V9w 4JXw== X-Gm-Message-State: AOAM530Q0EN0QLci+fV9gUdpAkfYqaU/9jKjTg0p/OWYWTwF+9qTI4ad f1s0oTVbczN/yrhOUiHvUzRMKA== X-Google-Smtp-Source: ABdhPJypCzWo/RzU1A0vkyKGMWGcM+gWL4C+xJq9bpuP3YaGcMPrw6MsySxwiLzgR4TsTQNBxd3ARg== X-Received: by 2002:a17:90a:4ec4:: with SMTP id v4mr2793960pjl.62.1599695646992; Wed, 09 Sep 2020 16:54:06 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id h14sm3817937pfe.67.2020.09.09.16.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 16:54:06 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH] Bluetooth: Re-order clearing suspend tasks Date: Wed, 9 Sep 2020 16:53:59 -0700 Message-Id: <20200909165317.1.Ie55bb8dde9847e8005f24402f3f2d66ea09cd7b2@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.75 / 15.00 / 15.00 X-Rspamd-Queue-Id: 82556A0B24 X-Rspamd-UID: 19108a Unregister_pm_notifier is a blocking call so suspend tasks should be cleared beforehand. Otherwise, the notifier will wait for completion before returning (and we encounter a 2s timeout on resume). Fixes: 0e9952804ec9c8 (Bluetooth: Clear suspend tasks on unregister) Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Should have caught that unregister_pm_notifier was blocking last time but when testing the earlier patch, I got unlucky and saw that the error message was never hit (the suspend timeout). When re-testing this patch on the same device, I was able to reproduce the problem on an older build with the 0e9952804ec9c8 but not on a newer build with the same patch. Changing the order correctly fixes it everywhere. Confirmed this by adding debug logs in btusb_disconnect and hci_suspend_notifier to confirm what order things were getting called. Sorry about the churn. Next I'm going try to do something about the palm shaped indentation on my forehead... net/bluetooth/hci_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index efc0fe2b47dac2..be9cdf5dabe5dc 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3794,8 +3794,8 @@ void hci_unregister_dev(struct hci_dev *hdev) cancel_work_sync(&hdev->power_on); - unregister_pm_notifier(&hdev->suspend_notifier); hci_suspend_clear_tasks(hdev); + unregister_pm_notifier(&hdev->suspend_notifier); cancel_work_sync(&hdev->suspend_prepare); hci_dev_do_close(hdev); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UAVmF7KTWV+2NQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 04:47:14 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iPbuFLKTWV+USwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 04:47:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F024640134; Thu, 10 Sep 2020 04:47:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730411AbgIJCAZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 9 Sep 2020 22:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729521AbgIJBk6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 9 Sep 2020 21:40:58 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EBE9C061344 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 18:40:58 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id u13so3380400pgh.1 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 18:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gTez5zBL4O/mFCX1yAYIY6uoJGixvvecrhH5yeefCRU=; b=b0zJlrJ3/FxkSGhXn87cvP+RTMUhelRrCM1riW4kT7+txcP800FsUvP6kSl1Tx+BQ9 nlnSbaIdcJf/ctfzMo8lklWjGAlMfBcz670pLHXNIAzEyKNqQRUVeGBFLUGnDrDQvmmo LiL1peql9jifg/8mL5CDMgP9HFRyzTX8uyAco= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gTez5zBL4O/mFCX1yAYIY6uoJGixvvecrhH5yeefCRU=; b=EDhYX+8QyW/IqGScP2neKGWshOUoYtFVcd/QLnynfu0FFPgJo51p/VHUeU/XTBe+07 9dKGvo+yy3fuJ0qf/jB3ls5dedcfZX8oERz8ivuWXBUaeRZgRDu5dv8u5MBDeXwm8dAh u7uiWo9LpHp9TjAUqbs7PLg3/+e7SLebUq+20Nq7572YltfY44kT6/yUn+vrW7xuseGb mxHWZCjOPGu6fEtqWmXkh+vMEnGX0wS0oh1/z60+2BcdXhWyonJrZ2BqSjOaNzhgIKsZ I9Q9XwhaOuDLaFRBeCs13PtGsU1Nms+v1dZc/mqf4wdA96whncHSIW31YPYeY4zPnedm ZzJw== X-Gm-Message-State: AOAM531f2QmpfrkA7KUG1qfWbAo1zUQJqoxuPmlajqcXRQjvKd/nBzTY j74x25QEwlC84nAAv+BZMJIah6r3QzH8CA== X-Google-Smtp-Source: ABdhPJzBPsq3OhqI1wKePrmNY399SC3c/Mj0s1LcqZge53ktq1ymQHWKSBttbMamebJGRQYDAMFBPA== X-Received: by 2002:a63:d25:: with SMTP id c37mr2501235pgl.403.1599702057352; Wed, 09 Sep 2020 18:40:57 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id j19sm3885366pfi.51.2020.09.09.18.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 18:40:56 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: marcel@holtmann.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH] Bluetooth: Re-order clearing suspend tasks Date: Wed, 9 Sep 2020 18:40:06 -0700 Message-Id: <20200909183952.1.Ie55bb8dde9847e8005f24402f3f2d66ea09cd7b2@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.70 / 15.00 / 15.00 X-Rspamd-Queue-Id: F024640134 X-Rspamd-UID: 93fd65 Unregister_pm_notifier is a blocking call so suspend tasks should be cleared beforehand. Otherwise, the notifier will wait for completion before returning (and we encounter a 2s timeout on resume). Fixes: 0e9952804ec9c8 (Bluetooth: Clear suspend tasks on unregister) Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Should have caught that unregister_pm_notifier was blocking last time but when testing the earlier patch, I got unlucky and saw that the error message was never hit (the suspend timeout). When re-testing this patch on the same device, I was able to reproduce the problem on an older build with the 0e9952804ec9c8 but not on a newer build with the same patch. Changing the order correctly fixes it everywhere. Confirmed this by adding debug logs in btusb_disconnect and hci_suspend_notifier to confirm what order things were getting called. Sorry about the churn. Next I'm going try to do something about the palm shaped indentation on my forehead... net/bluetooth/hci_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index efc0fe2b47dac2..be9cdf5dabe5dc 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3794,8 +3794,8 @@ void hci_unregister_dev(struct hci_dev *hdev) cancel_work_sync(&hdev->power_on); - unregister_pm_notifier(&hdev->suspend_notifier); hci_suspend_clear_tasks(hdev); + unregister_pm_notifier(&hdev->suspend_notifier); cancel_work_sync(&hdev->suspend_prepare); hci_dev_do_close(hdev); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OAXSE/asWV/LgAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:35:02 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EHk5EPasWV/tWQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:35:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 72A40A0B2C; Thu, 10 Sep 2020 06:34:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725887AbgIJEer (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:34:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbgIJEen (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:34:43 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1163CC061573; Wed, 9 Sep 2020 21:34:42 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id l191so3561231pgd.5; Wed, 09 Sep 2020 21:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mLWBFcBZV8fmFx5Xk0PVn4QE4aV7gSoFbhf906XUkPs=; b=NjJMhcLe4iQ8X5gqAeC+mPeQdB0ZCqaUU7mPw3W/D1GX/8B2q+7jyxu01ySUanM1AP XWLRdQ4Ygmq6foo4o51n6qzzhlMY8jt0AuBbbm5ZGfPvBftrhAlI5jR1j9d9rUgO48Zv 3nt3vC+NKv+yMvAwRrd9oBZghO/4msxbwX1MkPD/pMaLsWI1twbeLVt0jlqh6RQjNPqv Q26XqLtkZuJuP/6N1v3qcx9UkIfpsRWUbMIDIHhtC5yect8TFVWqO6rRLCXAUFzUDmdd 37JxvHGTFtLPc5FV00qdssrm+rSevrHMgr9hB4//8nNwkTrWo33AxIHH3j5/lwv5J4Sz UsXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mLWBFcBZV8fmFx5Xk0PVn4QE4aV7gSoFbhf906XUkPs=; b=oMFTiQp4ZJ4UG4i4oHwt2b/M7CDzl5f7IXHidHqe8nUVnn7vq7uMN2D5P6g0wYElNA a4iejcthTRzmbMw2GWDXOrNZWdWHEj/aIxUnDE3TpoJFQ+8rynz9+ua+F49yhvrF3cAB v1xw87dRImSUfEAknyaX/qHL0ohSF41ft5kfyzev+xdBqfGc1Y4+4icvKWb+K/49G+ja iUNG41LgUPoU7gagBC7qn43ga//Iabnn7dT0T3RziCcnuEo26xLJ/4Jw27BilfozuHKR tUWyCSi9R0ScF1Q4PuBkHdG/AyG0cIiI30xOdkXTqfLhbO2qIJNJRL5x5z09eLIk6TJD zxvQ== X-Gm-Message-State: AOAM532WYkwv18xdJPVRoNMKGy3q6dMTEt+L87Xp+91h7cw3q5R8KNmi frKPFhg/Nj1lmuELCYuU6O0= X-Google-Smtp-Source: ABdhPJzFKv4KxelRN1MBEhwmEPGdlzS/d7UG1Dn2QL3AG6VpQwxMK6fYsIxpdOIV7ceTnSwts2E6Vw== X-Received: by 2002:a63:471b:: with SMTP id u27mr3050649pga.139.1599712481765; Wed, 09 Sep 2020 21:34:41 -0700 (PDT) Received: from localhost.localdomain ([45.118.165.148]) by smtp.googlemail.com with ESMTPSA id s19sm4384211pfc.69.2020.09.09.21.34.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 21:34:40 -0700 (PDT) From: Anmol Karn <anmol.karan123@gmail.com> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, anmol.karan123@gmail.com, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Subject: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer dereference in hci_event_packet() Date: Thu, 10 Sep 2020 10:04:24 +0530 Message-Id: <20200910043424.19894-1-anmol.karan123@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.31 / 15.00 / 15.00 X-Rspamd-Queue-Id: 72A40A0B2C X-Rspamd-UID: ec2dfc Prevent hci_phy_link_complete_evt() from dereferencing 'hcon->amp_mgr' as NULL. Fix it by adding pointer check for it. Reported-and-tested-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=0bef568258653cff272f Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> --- net/bluetooth/hci_event.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 4b7fc430793c..871e16804433 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4936,6 +4936,11 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, return; } + if (IS_ERR_OR_NULL(hcon->amp_mgr)) { + hci_dev_unlock(hdev); + return; + } + if (ev->status) { hci_conn_del(hcon); hci_dev_unlock(hdev); -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EMwiFVWtWV/LgAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:36:37 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 0FLAElWtWV+axwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:36:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 171B4A0B10; Thu, 10 Sep 2020 06:36:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725887AbgIJEga (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:36:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbgIJEgW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:36:22 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F413EC061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:36:21 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id j7so296378plk.11 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5aM6VVrTht1FceKkAVmX0ix4M6IUKIpD0QpYq5ZNVn8=; b=Jl+1xnuKFW9ub7ltdSqSvR119Ahfu3I5FYR9J5jAl227l5CdvWp6wgmJW85rYhhTKb 8Kk3HVXVgO+3aMn4rxrC74RKNczyaYVA7cxb47OyLTR06oaZRKbVeBe0ggVPzto9YWAM csH3A/7zWxlg+Y8yfX7V9TMOvx7+6gL/TbrC0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5aM6VVrTht1FceKkAVmX0ix4M6IUKIpD0QpYq5ZNVn8=; b=jlYMVaGmBamdklp5gvXZghd+Wc3YjNjb+h0vBeqDn+dhf4g/gS26l1PEJzlauL05Rs cUpaUw42r/LbSCVz2/W2+qohRnHzczVq1/bFhHg6cze6UqI2c5HY9oXAt81d/ucXsIHO JlP/QcglMYuXc7uJjM0yVFXUoJPQ7aCVaRt/11jImdNoUm2TCKOXaUDY3ZJK/i0FTQfU rtksQTfzggDpuxhBl/FX5M2SUKkzLiHPCwxArmBytqavACf39HVmwP86PDF30cFqv4f+ od4PVcqL+TrJE3YFdxG8YAp1+PUVN1ubZV8Y1X9OttQS9m5l5rYdVuxIcfs2P7toRp+C qc/Q== X-Gm-Message-State: AOAM533tmqKNddpTeTbFrW9AfPcLrPcIBnl7W8p51Oc3ySpEDDuwTdHf sMC9936lTGEdIDAzD7ypxYv934qm6crqqA== X-Google-Smtp-Source: ABdhPJxoLuV75GFsH3LQk38zdw2SofziWDLx6Mg+4cIgoXx8zIxCYBJ7pVqt2ug4IzEpTZGa7HR+aw== X-Received: by 2002:a17:902:b604:: with SMTP id b4mr3689066pls.120.1599712581112; Wed, 09 Sep 2020 21:36:21 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y4sm4149820pfq.215.2020.09.09.21.36.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:36:20 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v2 1/7] PRE-UPSTREAM: adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Date: Wed, 9 Sep 2020 21:35:32 -0700 Message-Id: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: 171B4A0B10 X-Rspamd-UID: bad257 This introduces the org.bluez.AdvertisementMonitorManager1 without implementing handlers of methods and properties. The following test was performed. - Upon adapter registration, the info line of creating an ADV monitor manager gets printed, and system bus emits the interface events of org.bluez.AdvertisementMonitorManager1. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Changes in v2: -Use new0 instead of g_new0 -Remove the reset of manager members -Make methods/property experimental Makefile.am | 3 +- src/adapter.c | 14 +++++ src/adapter.h | 3 + src/adv_monitor.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++ src/adv_monitor.h | 32 ++++++++++ 5 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 src/adv_monitor.c create mode 100644 src/adv_monitor.h diff --git a/Makefile.am b/Makefile.am index 7719c06f8..b14ee950e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -293,7 +293,8 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ src/gatt-client.h src/gatt-client.c \ src/device.h src/device.c \ src/dbus-common.c src/dbus-common.h \ - src/eir.h src/eir.c + src/eir.h src/eir.c \ + src/adv_monitor.h src/adv_monitor.c src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ gdbus/libgdbus-internal.la \ src/libshared-glib.la \ diff --git a/src/adapter.c b/src/adapter.c index 1435e2bd7..de327dc98 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -77,6 +77,7 @@ #include "attrib-server.h" #include "gatt-database.h" #include "advertising.h" +#include "adv_monitor.h" #include "eir.h" #define ADAPTER_INTERFACE "org.bluez.Adapter1" @@ -272,6 +273,8 @@ struct btd_adapter { struct btd_gatt_database *database; struct btd_adv_manager *adv_manager; + struct btd_adv_monitor_manager *adv_monitor_manager; + gboolean initialized; GSList *pin_callbacks; @@ -6360,6 +6363,9 @@ static void adapter_remove(struct btd_adapter *adapter) btd_adv_manager_destroy(adapter->adv_manager); adapter->adv_manager = NULL; + btd_adv_monitor_manager_destroy(adapter->adv_monitor_manager); + adapter->adv_monitor_manager = NULL; + g_slist_free(adapter->pin_callbacks); adapter->pin_callbacks = NULL; @@ -8633,6 +8639,14 @@ static int adapter_register(struct btd_adapter *adapter) adapter->adv_manager = btd_adv_manager_new(adapter, adapter->mgmt); + adapter->adv_monitor_manager = btd_adv_monitor_manager_create( + adapter, adapter->mgmt); + if (!adapter->adv_monitor_manager) { + btd_error(adapter->dev_id, + "Failed to create Adv Monitor Manager for adapter"); + return -EINVAL; + } + db = btd_gatt_database_get_db(adapter->database); adapter->db_id = gatt_db_register(db, services_modified, services_modified, diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..5cb467141 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -26,6 +26,9 @@ #include <dbus/dbus.h> #include <glib.h> +#include "lib/bluetooth.h" +#include "lib/sdp.h" + #define MAX_NAME_LENGTH 248 /* Invalid SSP passkey value used to indicate negative replies */ diff --git a/src/adv_monitor.c b/src/adv_monitor.c new file mode 100644 index 000000000..8e7dad8dd --- /dev/null +++ b/src/adv_monitor.c @@ -0,0 +1,148 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdint.h> + +#include <glib.h> +#include <dbus/dbus.h> +#include <gdbus/gdbus.h> + +#include "adapter.h" +#include "dbus-common.h" +#include "log.h" +#include "src/shared/mgmt.h" +#include "src/shared/util.h" + +#include "adv_monitor.h" + +#define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" + +struct btd_adv_monitor_manager { + struct btd_adapter *adapter; + struct mgmt *mgmt; + uint16_t adapter_id; + char *path; +}; + +static const GDBusMethodTable adv_monitor_methods[] = { + { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { } +}; + +static const GDBusPropertyTable adv_monitor_properties[] = { + {"SupportedMonitorTypes", "as", NULL, NULL, NULL, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, + {"SupportedFeatures", "as", NULL, NULL, NULL}, + { } +}; + +/* Allocates a manager object */ +static struct btd_adv_monitor_manager *manager_new( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + if (!adapter || !mgmt) + return NULL; + + manager = new0(struct btd_adv_monitor_manager, 1); + if (!manager) + return NULL; + + manager->adapter = adapter; + manager->mgmt = mgmt_ref(mgmt); + manager->adapter_id = btd_adapter_get_index(adapter); + manager->path = g_strdup(adapter_get_path(manager->adapter)); + + return manager; +} + +/* Frees a manager object */ +static void manager_free(struct btd_adv_monitor_manager *manager) +{ + mgmt_unref(manager->mgmt); + free(manager->path); + + free(manager); +} + +/* Destroys a manager object and unregisters its D-Bus interface */ +static void manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + g_dbus_unregister_interface(btd_get_dbus_connection(), + manager->path, + ADV_MONITOR_MGR_INTERFACE); + + manager_free(manager); +} + +/* Creates a manager and registers its D-Bus interface */ +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + manager = manager_new(adapter, mgmt); + if (!manager) + return NULL; + + if (!g_dbus_register_interface(btd_get_dbus_connection(), manager->path, + ADV_MONITOR_MGR_INTERFACE, + adv_monitor_methods, NULL, + adv_monitor_properties, manager, + NULL)) { + btd_error(manager->adapter_id, + "Failed to register " + ADV_MONITOR_MGR_INTERFACE); + manager_free(manager); + return NULL; + } + + btd_info(manager->adapter_id, + "Adv Monitor Manager created for adapter %s", + adapter_get_path(manager->adapter)); + + return manager; +} + +/* Destroys a manager and unregisters its D-Bus interface */ +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + btd_info(manager->adapter_id, "Destroy Adv Monitor Manager"); + + manager_destroy(manager); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h new file mode 100644 index 000000000..69ea348f8 --- /dev/null +++ b/src/adv_monitor.h @@ -0,0 +1,32 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifndef __ADV_MONITOR_H +#define __ADV_MONITOR_H + +struct mgmt; +struct btd_adapter; +struct btd_adv_monitor_manager; + +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt); +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); + +#endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eJxYJGytWV/7ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:37:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WJtyIWytWV/jewAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:37:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7F955A0B2C; Thu, 10 Sep 2020 06:36:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726215AbgIJEgx (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbgIJEgr (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:36:47 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48CA6C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:36:47 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id g29so3582161pgl.2 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zLi61UtegLxZoRPn4T9W5e3L/HqdjAdjheNWCNy6w+M=; b=gXiTUIaNvECszPA0axiTD/Ygvahp9PvRXjW6IzWyozubqI72bwXJa3r8+40Hi4lZU2 OR9PXo/SWrt83UyMAANKCN/KTq/e0ARItO1nOFskJbuHM8EGhHivoRQKxQR0c709QW73 cIz6Uj4LYvS5T/9+bentuw7SKVo2318TyY4GQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zLi61UtegLxZoRPn4T9W5e3L/HqdjAdjheNWCNy6w+M=; b=CafiI0ZcglnMhjFA+Lxru69Z+yKpAuiNr9lV/Zu6gRhqdgXvT1T4RpvkWOl9+YuieR LoJ248p/z6nsi/9YWRhCBfyHbbvuxBipJMVz3f4x1QycrtjqvqGS3Suw4kXUAwZLGuZa rEC+ObGKfgChhpIsiqIOYza4xfPv5Uz7RemFfy5cmDGUeK87e8V53lYFdk97kglX+3QC d03m8YTLdNTbJ+UeJSuwpIrqgqCHhIcJ2GaH8vhZCyBFTuXnthaeT+2+Tw/ayMzI7JhE cD5xRgt6wSJJG2RU9VxHtuEVTiTeB9UKcaJ/ddkkxm4Lp+RCaRy3UD6AIlhNPumkWeAf EKhw== X-Gm-Message-State: AOAM533cMs1RyR4cMR1vCVbDurcRfb3HNXW2elHWNTawC7Ly8vdfGmMR BW0LrM/ygawdKfyJhRqzmyRDBHj1lkrlfw== X-Google-Smtp-Source: ABdhPJwHFrvxsHABu6Z3KByav3ToikQr89a3seZRE8YHFDSaxPPMh+WPVvJxkKhkYZF7VYtoey4TEw== X-Received: by 2002:a62:e40a:0:b029:138:8fd6:7fd5 with SMTP id r10-20020a62e40a0000b02901388fd67fd5mr3754452pfh.1.1599712605364; Wed, 09 Sep 2020 21:36:45 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y4sm4149820pfq.215.2020.09.09.21.36.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:36:44 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v2 2/7] PRE-UPSTREAM: adv_monitor: Implement Get functions of Adv monitor manager properties Date: Wed, 9 Sep 2020 21:35:34 -0700 Message-Id: <20200909213423.BlueZ.v2.2.I9960e45d36be3edb5f17de025e7eb8257d3cddef@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7F955A0B2C X-Rspamd-UID: 363c7b This implements the Get functions of SupportedMonitorTypes and SupportedFeatures. The following test was performed. - Issue dbus-send to read SupportedMonitorTypes and SupportedFeatures. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v1) src/adv_monitor.c | 128 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 5 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 8e7dad8dd..54e67bf2c 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -28,6 +28,9 @@ #include <dbus/dbus.h> #include <gdbus/gdbus.h> +#include "lib/bluetooth.h" +#include "lib/mgmt.h" + #include "adapter.h" #include "dbus-common.h" #include "log.h" @@ -43,6 +46,12 @@ struct btd_adv_monitor_manager { struct mgmt *mgmt; uint16_t adapter_id; char *path; + + uint32_t supported_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ + uint32_t enabled_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ + uint16_t max_num_monitors; + uint8_t max_num_patterns; + }; static const GDBusMethodTable adv_monitor_methods[] = { @@ -55,10 +64,78 @@ static const GDBusMethodTable adv_monitor_methods[] = { { } }; +enum monitor_type { + MONITOR_TYPE_OR_PATTERNS, +}; + +const struct adv_monitor_type { + enum monitor_type type; + const char *name; +} supported_types[] = { + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, + { }, +}; + +/* Gets SupportedMonitorTypes property */ +static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, + DBusMessageIter *iter, + void *data) +{ + DBusMessageIter entry; + const struct adv_monitor_type *t; + struct btd_adv_monitor_manager *manager = data; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, + &entry); + + for (t = supported_types; t->name; t++) { + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, + &t->name); + } + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + +const struct adv_monitor_feature { + uint32_t mask; + const char *name; +} supported_features[] = { + { MGMT_ADV_MONITOR_FEATURE_MASK_OR_PATTERNS, "controller-patterns" }, + { } +}; + +/* Gets SupportedFeatures property */ +static gboolean get_supported_features(const GDBusPropertyTable *property, + DBusMessageIter *iter, + void *data) +{ + DBusMessageIter entry; + const struct adv_monitor_feature *f; + struct btd_adv_monitor_manager *manager = data; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, + &entry); + + for (f = supported_features; f->name; f++) { + if (manager->supported_features & f->mask) { + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, + &f->name); + } + } + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + static const GDBusPropertyTable adv_monitor_properties[] = { - {"SupportedMonitorTypes", "as", NULL, NULL, NULL, + {"SupportedMonitorTypes", "as", get_supported_monitor_types, NULL, NULL, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, - {"SupportedFeatures", "as", NULL, NULL, NULL}, + {"SupportedFeatures", "as", get_supported_features, NULL, NULL}, { } }; @@ -106,6 +183,42 @@ static void manager_destroy(struct btd_adv_monitor_manager *manager) manager_free(manager); } +/* Initiates manager's members based on the return of + * MGMT_OP_READ_ADV_MONITOR_FEATURES + */ +static void read_adv_monitor_features_cb(uint8_t status, uint16_t length, + const void *param, + void *user_data) +{ + const struct mgmt_rp_read_adv_monitor_features *rp = param; + struct btd_adv_monitor_manager *manager = user_data; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(manager->adapter_id, "Failed to Read Adv Monitor " + "Features with status 0x%02x", status); + return; + } + + if (length < sizeof(*rp)) { + btd_error(manager->adapter_id, + "Wrong size of Read Adv Monitor Features " + "response"); + return; + } + + manager->supported_features = le32_to_cpu(rp->supported_features); + manager->enabled_features = le32_to_cpu(rp->enabled_features); + manager->max_num_monitors = le16_to_cpu(rp->max_num_handles); + manager->max_num_patterns = rp->max_num_patterns; + + btd_info(manager->adapter_id, "Adv Monitor Manager created with " + "supported features:0x%08x, enabled features:0x%08x, " + "max number of supported monitors:%d, " + "max number of supported patterns:%d", + manager->supported_features, manager->enabled_features, + manager->max_num_monitors, manager->max_num_patterns); +} + /* Creates a manager and registers its D-Bus interface */ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct btd_adapter *adapter, @@ -129,9 +242,14 @@ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( return NULL; } - btd_info(manager->adapter_id, - "Adv Monitor Manager created for adapter %s", - adapter_get_path(manager->adapter)); + if (!mgmt_send(manager->mgmt, MGMT_OP_READ_ADV_MONITOR_FEATURES, + manager->adapter_id, 0, NULL, + read_adv_monitor_features_cb, manager, NULL)) { + btd_error(manager->adapter_id, + "Failed to send Read Adv Monitor Features"); + manager_destroy(manager); + return NULL; + } return manager; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2I0CGn+tWV/7ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:37:19 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id oCNDF3+tWV+C7wEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:37:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 12CFAA0218; Thu, 10 Sep 2020 06:37:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726079AbgIJEhM (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbgIJEhF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:37:05 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C535BC061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:37:03 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id c196so4047374pfc.0 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AJPZOT5B0nuolz+Ul8NKg3I9PVUhFT9btrB6Oqu6yw8=; b=Isz5pQRvhWQj419nYxiGBKgSx6hLqGyxJQqIZFuOVhuOo55ZDuIbD+KRhpCU7wK/gK pRocr2IqvW06GW08EdVjq1g0GefSjO7aLmvbpZ/OkzJ3RJZIN5VETSO71tEeFo6eP6YY 5ql5rPhB7HwC5hErfzLPe9GyJOIU5Z4dzs+D4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AJPZOT5B0nuolz+Ul8NKg3I9PVUhFT9btrB6Oqu6yw8=; b=QOkmakalhfIgplsXB1iUsWhZ9OarZVgmaHh98W6BYD2koQ/reKWX66XCC98JODW+0p wFVcExrsVvmuMJ1w3fy7hBB3MS6jp52WXkUWBRWgN4X5xtdDsULJ9sKhc+d8PY1bcoPF D2kzvTe+hRaEs2TPQnMGNJ6P1V7IRG6fv0IWUzo3hAKm3xrr4ukdr5JUcL8EAFPKGjBM ZCe1euTTXI2StANZAbpgEsiQ/9yz8/ljaxedn9KaIG/BBfzm1+PDgVkspD9t70CSCgHJ 5GmIkWuYy8t/nmDrUYy5uYW3px0+Pg8AY0puNt2lqEZPPOTl0G8nzkARXSbItVr4szNU CFag== X-Gm-Message-State: AOAM531nm8FSPwrJgxsdm/nPbToGSnshPBwCTI4IjRmBnUeGAyUsG03g 8ArjC4R+cNota4uuDdfpDUpvj8ZXeVboAA== X-Google-Smtp-Source: ABdhPJx5FlxjeVUW0iiEp7FboC5Jdy9JvxAjzH3Dhn4g8ErFp+gksu+1oGDJBny29jxO6An80BkEHA== X-Received: by 2002:a63:4e5e:: with SMTP id o30mr2983925pgl.324.1599712622909; Wed, 09 Sep 2020 21:37:02 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y4sm4149820pfq.215.2020.09.09.21.37.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:37:02 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v2 3/7] PRE-UPSTREAM: adv_monitor: Implement RegisterMonitor() Date: Wed, 9 Sep 2020 21:35:36 -0700 Message-Id: <20200909213423.BlueZ.v2.3.I19ff9cdbd40fe453db0e81aec8bf94dd9490dce3@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: 12CFAA0218 X-Rspamd-UID: 4c920a This implements the RegisterMonitor() method handler of ADV monitor manager interface. The following tests were performed. - Issue a RegisterMonitor() call with a valid path and expect a success as return. - Issue a RegisterMonitor() call with an invalid path and expect org.bluez.Error.InvalidArguments as return. - Issue two Registermonitor() calls with the same path and expect org.bluez.Error.AlreadyExists. - Verify the values of the registered paths with logging. - Verify D-Bus disconnection callback was triggered when the client detach from D-Bus. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Changes in v2: - Use new0() instead of g_new0() - Remove the reset of app members src/adv_monitor.c | 164 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 163 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 54e67bf2c..b8b55d2fc 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -22,7 +22,9 @@ #endif #define _GNU_SOURCE +#include <errno.h> #include <stdint.h> +#include <string.h> #include <glib.h> #include <dbus/dbus.h> @@ -34,7 +36,9 @@ #include "adapter.h" #include "dbus-common.h" #include "log.h" +#include "src/error.h" #include "src/shared/mgmt.h" +#include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" @@ -52,12 +56,167 @@ struct btd_adv_monitor_manager { uint16_t max_num_monitors; uint8_t max_num_patterns; + struct queue *apps; /* apps who registered for Adv monitoring */ }; +struct adv_monitor_app { + struct btd_adv_monitor_manager *manager; + char *owner; + char *path; + + DBusMessage *reg; + GDBusClient *client; +}; + +struct app_match_data { + const char *owner; + const char *path; +}; + +/* Replies to an app's D-Bus message and unref it */ +static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) +{ + if (!app || !app->reg || !reply) + return; + + g_dbus_send_message(btd_get_dbus_connection(), reply); + dbus_message_unref(app->reg); + app->reg = NULL; +} + +/* Destroys an app object along with related D-Bus handlers */ +static void app_destroy(void *data) +{ + struct adv_monitor_app *app = data; + + if (!app) + return; + + DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); + + if (app->reg) { + app_reply_msg(app, btd_error_failed(app->reg, + "Adv Monitor app destroyed")); + } + + if (app->client) { + g_dbus_client_set_disconnect_watch(app->client, NULL, NULL); + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, + NULL); + g_dbus_client_set_ready_watch(app->client, NULL, NULL); + g_dbus_client_unref(app->client); + } + + g_free(app->owner); + g_free(app->path); + + free(app); +} + +/* Handles a D-Bus disconnection event of an app */ +static void app_disconnect_cb(DBusConnection *conn, void *user_data) +{ + struct adv_monitor_app *app = user_data; + + btd_info(app->manager->adapter_id, "Adv Monitor app %s disconnected " + "from D-Bus", app->owner); + if (app && queue_remove(app->manager->apps, app)) + app_destroy(app); +} + +/* Creates an app object, initiates it and sets D-Bus event handlers */ +static struct adv_monitor_app *app_create(DBusConnection *conn, + const char *sender, const char *path, + struct btd_adv_monitor_manager *manager) +{ + struct adv_monitor_app *app; + + if (!path || !sender || !manager) + return NULL; + + app = new0(struct adv_monitor_app, 1); + if (!app) + return NULL; + + app->owner = g_strdup(sender); + app->path = g_strdup(path); + app->manager = manager; + app->reg = NULL; + + app->client = g_dbus_client_new(conn, sender, path); + if (!app->client) { + app_destroy(app); + return NULL; + } + + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); + g_dbus_client_set_ready_watch(app->client, NULL, NULL); + + return app; +} + +/* Matches an app based on its owner and path */ +static bool app_match(const void *a, const void *b) +{ + const struct adv_monitor_app *app = a; + const struct app_match_data *match = b; + + if (match->owner && strcmp(app->owner, match->owner)) + return false; + + if (match->path && strcmp(app->path, match->path)) + return false; + + return true; +} + +/* Handles a RegisterMonitor D-Bus call */ +static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, + void *user_data) +{ + DBusMessageIter args; + struct app_match_data match; + struct adv_monitor_app *app; + struct btd_adv_monitor_manager *manager = user_data; + + if (!dbus_message_iter_init(msg, &args)) + return btd_error_invalid_args(msg); + + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) + return btd_error_invalid_args(msg); + + dbus_message_iter_get_basic(&args, &match.path); + + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) + return btd_error_invalid_args(msg); + + match.owner = dbus_message_get_sender(msg); + + if (queue_find(manager->apps, app_match, &match)) + return btd_error_already_exists(msg); + + app = app_create(conn, match.owner, match.path, manager); + if (!app) { + btd_error(manager->adapter_id, + "Failed to reserve %s for Adv Monitor app %s", + match.path, match.owner); + return btd_error_failed(msg, + "Failed to create Adv Monitor app"); + } + + queue_push_tail(manager->apps, app); + + btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", + match.path, match.owner); + + return dbus_message_new_method_return(msg); +} + static const GDBusMethodTable adv_monitor_methods[] = { { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), - NULL, NULL) }, + NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, NULL) }, @@ -157,6 +316,7 @@ static struct btd_adv_monitor_manager *manager_new( manager->mgmt = mgmt_ref(mgmt); manager->adapter_id = btd_adapter_get_index(adapter); manager->path = g_strdup(adapter_get_path(manager->adapter)); + manager->apps = queue_new(); return manager; } @@ -167,6 +327,8 @@ static void manager_free(struct btd_adv_monitor_manager *manager) mgmt_unref(manager->mgmt); free(manager->path); + queue_destroy(manager->apps, app_destroy); + free(manager); } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QOYjBoitWV/LgAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:37:28 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UIq5AoitWV+M/wEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:37:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 10A93A0218; Thu, 10 Sep 2020 06:37:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725913AbgIJEhV (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbgIJEhQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:37:16 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0D00C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:37:15 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id k15so3886701pfc.12 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wgoIVPRWXVNntcbMbldt7TpPEHI4+Eh2hW+gjZOt2Js=; b=mMZIaj0NZ9xEAHaaPZidEIAITW8us9QoZ94vAL+aQsJXbN8IMFMwnlNlzXXsyWr2zO Bj5C6trz+gbSyKL1s7kn+dmBYE/+04JoFwQCc35z1sCd23gaaEtLV3PwRiBjkRZ5BIHS OHqossIt7YsJMSQoau5JQf37NlaFMahOXIURA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wgoIVPRWXVNntcbMbldt7TpPEHI4+Eh2hW+gjZOt2Js=; b=kK/8XIEP+fDmtIqxtJ/ngN3527VI0V/XROrahzBxEHp4QetkYJl5nRL6OPp7zOu0B2 osgp/2acOM1uGrfpEgRCn/nkDmHObsjjb7BYL40L6dkrrhV3HxdIH5hwDdEKwNhZwRya sSjgkjvrAdVc+YwUXuWJn5PIXFSEB3h+dAjgBZ/henJGRJkX+3uf0iPm8jC8jGrzGaVn 75uST6AE7La26h7Iw/e/MZJcOVqTSBsLeLi6h3g6D1/WoWh06OZ1bjYshbFmT2f1KXiU BHtB3RtmJMMbC6HOwb7rFPmm07j/+H/dBmD5oOSUY5nP3vfHSlkv8RoyPZojLtHUWK++ EmRw== X-Gm-Message-State: AOAM530NdoKHzK7v9yCegGBoZRzhMeZObFjzDa7+NRKWYrSAj59Vfc4Q ApTa/Mwj8u+IwLeWfE/R9tA/5iQaICmlhA== X-Google-Smtp-Source: ABdhPJy3jqcGuJmD+yt4DwMgs2oXrRep81aESmkWSzzWikwtlNguSlpyLRrwDmBfhq0qHvF30S0T7A== X-Received: by 2002:a62:3007:0:b029:13c:1611:6526 with SMTP id w7-20020a6230070000b029013c16116526mr3659217pfw.6.1599712635178; Wed, 09 Sep 2020 21:37:15 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y4sm4149820pfq.215.2020.09.09.21.37.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:37:14 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v2 4/7] PRE-UPSTREAM: adv_monitor: Implement UnregisterMonitor() Date: Wed, 9 Sep 2020 21:35:38 -0700 Message-Id: <20200909213423.BlueZ.v2.4.I335e42ab9a238261c2492c308ce77c959f631483@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: 10A93A0218 X-Rspamd-UID: 90e300 This implements the UnregisterMonitor() method handler of ADV monitor manager interface. The following tests were performed. - Issue a UnregisterMonitor() call with a nonexistent path and expect org.bluez.Error.DoesNotExist as the return. - Issue a UnregisterMonitor() call with a invalid path and expect org.bluez.Error.InvalidArguments as the return. - Issue RegisterMonitor() with a path, issue UnregisterMonitor() and expect a successful method call return. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v1) src/adv_monitor.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index b8b55d2fc..1a38e6994 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -213,13 +213,48 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, return dbus_message_new_method_return(msg); } +/* Handles UnregisterMonitor D-Bus call */ +static DBusMessage *unregister_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + DBusMessageIter args; + struct app_match_data match; + struct adv_monitor_app *app; + struct btd_adv_monitor_manager *manager = user_data; + + if (!dbus_message_iter_init(msg, &args)) + return btd_error_invalid_args(msg); + + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) + return btd_error_invalid_args(msg); + + dbus_message_iter_get_basic(&args, &match.path); + + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) + return btd_error_invalid_args(msg); + + match.owner = dbus_message_get_sender(msg); + + app = queue_find(manager->apps, app_match, &match); + if (!app) + return btd_error_does_not_exist(msg); + + queue_remove(manager->apps, app); + app_destroy(app); + + btd_info(manager->adapter_id, "Path %s removed along with Adv Monitor " + "app %s", match.path, match.owner); + + return dbus_message_new_method_return(msg); +} + static const GDBusMethodTable adv_monitor_methods[] = { { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", GDBUS_ARGS({ "application", "o" }), - NULL, NULL) }, + NULL, unregister_monitor) }, { } }; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0GDuA9GtWV/7ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:38:41 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2ES/ANGtWV9j/gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:38:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D5407A097B; Thu, 10 Sep 2020 06:38:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726231AbgIJEiG (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:38:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726324AbgIJEhf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:37:35 -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 4733DC061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:37:32 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id a8so297953plm.2 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:37:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DTPWYPs/pjfsOoexcMwgn/tJlgN2sDx7AxjUE535+Hc=; b=a3AM/fAEvDT9fjJrsUlYOmHaBfNbDK68CJ0TIj6TX3aEOxmcT4w5ABZ12U9Tv1WC0A HxgOZNMjwZIwZvRVBGtEILVSsygcU+p1QeMiAZvNMABrH/l6rmdxUJzadp76WRdkN5bo gTKon61Vv6G0jVa+/vN3OArrZLaEEenU6F1f4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DTPWYPs/pjfsOoexcMwgn/tJlgN2sDx7AxjUE535+Hc=; b=XZ5N3Jd1sCMWLOdQHoKC+GpNNY7UQdH1Uqe/NARuUyEsJpMJiYiBexnPQGvs7lBfSI AR9QH3a34CGvqI6IjEASRq8xUXNlJBXv+qEmFeF2p8/srQtpOU6dMy4w8NN7p6zilJgm JM9BgTYwafjDDDITBivZmxpPhchj6taaX73lLB1YhvDc+7hX+iGUntOB1IhOpakOPh0D xQ+ETqzh/uAtdq16/1LAIBJhZ59mi+d4CKVC/gzWtPbq78z0uI5dvKwmTRrxtN9J5LDh LomyCgUsKI7UOiaaC86l8FD0NxjAj2C/01COF/CyIDR+ncPm6kK2cJHsN6RRUMrBzKxe abdQ== X-Gm-Message-State: AOAM5306CBrJD1vBP7BD2dSuMM5FT5pazBIQGk9gCghNzrQXH9jx8tOz fCNb3Qt1keNwUtX7PotcKN411jtccVoVfA== X-Google-Smtp-Source: ABdhPJybrvAeQhhlWBWpKUugjFJ87Etrb9+dC25d/Tj0QTZSg5hFXimg+6YjY7n1AVPXLMQmOeAXEA== X-Received: by 2002:a17:902:bf4c:: with SMTP id u12mr3686542pls.97.1599712649397; Wed, 09 Sep 2020 21:37:29 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y4sm4149820pfq.215.2020.09.09.21.37.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:37:28 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v2 5/7] PRE-UPSTREAM: adv_monitor: Handle D-Bus client ready events Date: Wed, 9 Sep 2020 21:35:40 -0700 Message-Id: <20200909213423.BlueZ.v2.5.Id5b1ced1530cb21559bc1dcf29d8764b0c7df825@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.09 / 15.00 / 15.00 X-Rspamd-Queue-Id: D5407A097B X-Rspamd-UID: b08dbc This adds a handler of client ready events. The handler replies to the RegisterMonitor() method call. The following tests were performed. - Call RegisterMonitor() and expect to receive a return. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 1a38e6994..23fdc9b14 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -124,9 +124,22 @@ static void app_disconnect_cb(DBusConnection *conn, void *user_data) app_destroy(app); } +/* Handles the ready signal of Adv Monitor app */ +static void app_ready_cb(GDBusClient *client, void *user_data) +{ + struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + + btd_info(adapter_id, "Path %s reserved for Adv Monitor app %s", + app->path, app->owner); + + app_reply_msg(app, dbus_message_new_method_return(app->reg)); +} + /* Creates an app object, initiates it and sets D-Bus event handlers */ static struct adv_monitor_app *app_create(DBusConnection *conn, - const char *sender, const char *path, + DBusMessage *msg, const char *sender, + const char *path, struct btd_adv_monitor_manager *manager) { struct adv_monitor_app *app; @@ -151,7 +164,9 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); - g_dbus_client_set_ready_watch(app->client, NULL, NULL); + g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); + + app->reg = dbus_message_ref(msg); return app; } @@ -196,7 +211,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, if (queue_find(manager->apps, app_match, &match)) return btd_error_already_exists(msg); - app = app_create(conn, match.owner, match.path, manager); + app = app_create(conn, msg, match.owner, match.path, manager); if (!app) { btd_error(manager->adapter_id, "Failed to reserve %s for Adv Monitor app %s", @@ -207,10 +222,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, queue_push_tail(manager->apps, app); - btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", - match.path, match.owner); - - return dbus_message_new_method_return(msg); + return NULL; } /* Handles UnregisterMonitor D-Bus call */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0LZ/IdetWV/LgAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:38:47 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id iL/QHtetWV+S2gEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:38:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 28A06A0218; Thu, 10 Sep 2020 06:38:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725913AbgIJEif (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:38:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726433AbgIJEhs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:37:48 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 443DEC061756 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:37:48 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d16so284549pll.13 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/vY0+mEyZ/SlMy9WNLgOv0mu+n8ZfetJOqGExXjY+jc=; b=I2k7MW2e0ZthTWZ0ksFCmgVUA06Vmtjeb1nc7ryaQ3nUUyz7dxF7NEIF0BXnzVIc7y BC01ThxjMSmuHz/jtCwPipw1yQ6qh/8xMrFtoLNOefwm/HWbpSJgS5w5w7r6vj8ZfJUp NZulEc/YjNR5bpxrETNMgZ6GNpWrwvbEd9QvA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/vY0+mEyZ/SlMy9WNLgOv0mu+n8ZfetJOqGExXjY+jc=; b=sYCZMAsL7aOWCWBA7339GrZgCQX8UGj90x/KoJBeC83BJoNj14Kx2kcdt/cviWZCo+ i305w7nIfQtQFrQBjgeHb7kYvcCezNrs4W0lHfyGniDiOpQCkqD2IcvUzrgys5J17yAv HetqkMDRyG7JBqctyHUrvDT3nGlP/q2SjG9jDbGRUGV3uR3uAEmXKxCBXYuajIGuNCGm mkDSb5u17NMOv7fPg6tS7u3+uRROeb6PNgHNGMDJG6L92oQdJN6EdYaDO+M5DHOKhXqw aawxyQ0KpqjwV9cLcuNC5pLHx/vLIonIWOpH65eAlBbvCVEodN99hTrDYEwMpAzd5faN oYKQ== X-Gm-Message-State: AOAM533a4sWIW4NktA4kFDtYmP06HeSMBpec8ntA5/V5nEQCj7WCHxzk 1/iWeKbhWWJ1GadAXzG51yke8xKvr80dwg== X-Google-Smtp-Source: ABdhPJzkUnWv4hM3eyChlWmfJpLVvx8fjDxozxZNGcFr26e7ZL8sOU83rnQ9WKwc3SILNjtpm8iDHQ== X-Received: by 2002:a17:90a:9412:: with SMTP id r18mr3535253pjo.177.1599712667122; Wed, 09 Sep 2020 21:37:47 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y4sm4149820pfq.215.2020.09.09.21.37.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:37:46 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v2 6/7] PRE-UPSTREAM: adv_monitor: Handle D-Bus proxy event of an ADV monitor Date: Wed, 9 Sep 2020 21:35:42 -0700 Message-Id: <20200909213423.BlueZ.v2.6.I47744c7eef31f44cf393dea2b3e437d7b41cef79@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.09 / 15.00 / 15.00 X-Rspamd-Queue-Id: 28A06A0218 X-Rspamd-UID: 2c009d This adds two handlers, one for adding and one for removing, of D-Bus proxy events. The handler of property changes is set to NULL as intended, since for simplicity no further changes on monitor's properties would affect the ongoing monitoring. The following test steps were performed with bluetoothctl. - After registering the root path, expose two monitors and verify that the proxy added event are received. - Have two monitors added, unexpose the monitors, and verify that the proxy removed events are received for those two monitors. - Have two monitors added, unregister the monitors and verify that the proxy removed events are received for those two monitors. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v2: - Use new0() instead of g_new0() - Remove the reset of monitor members - Use memcpy() instead of g_memmove() src/adv_monitor.c | 488 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 475 insertions(+), 13 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 23fdc9b14..b07d886bf 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -37,14 +37,23 @@ #include "dbus-common.h" #include "log.h" #include "src/error.h" +#include "src/shared/ad.h" #include "src/shared/mgmt.h" #include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" +#define ADV_MONITOR_UNSET_RSSI 127 /* dBm */ +#define ADV_MONITOR_MAX_RSSI 20 /* dBm */ +#define ADV_MONITOR_MIN_RSSI -127 /* dBm */ +#define ADV_MONITOR_UNSET_TIMER 0 /* second */ +#define ADV_MONITOR_MIN_TIMER 1 /* second */ +#define ADV_MONITOR_MAX_TIMER 300 /* second */ + struct btd_adv_monitor_manager { struct btd_adapter *adapter; struct mgmt *mgmt; @@ -66,6 +75,43 @@ struct adv_monitor_app { DBusMessage *reg; GDBusClient *client; + + struct queue *monitors; +}; + +enum monitor_type { + MONITOR_TYPE_NONE, + MONITOR_TYPE_OR_PATTERNS, +}; + +enum monitor_state { + MONITOR_STATE_NEW, /* New but not yet init'ed with actual values */ + MONITOR_STATE_FAILED, /* Failed to be init'ed */ + MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ + MONITOR_STATE_HONORED, /* Accepted by kernel */ +}; + +struct pattern { + uint8_t ad_type; + uint8_t offset; + uint8_t length; + uint8_t value[BT_AD_MAX_DATA_LEN]; +}; + +struct adv_monitor { + struct adv_monitor_app *app; + GDBusProxy *proxy; + char *path; + + enum monitor_state state; /* MONITOR_STATE_* */ + + int8_t high_rssi; /* high RSSI threshold */ + uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ + int8_t low_rssi; /* low RSSI threshold */ + uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ + + enum monitor_type type; /* MONITOR_TYPE_* */ + struct queue *patterns; }; struct app_match_data { @@ -73,6 +119,14 @@ struct app_match_data { const char *path; }; +const struct adv_monitor_type { + enum monitor_type type; + const char *name; +} supported_types[] = { + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, + { }, +}; + /* Replies to an app's D-Bus message and unref it */ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) { @@ -84,6 +138,48 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) app->reg = NULL; } +/* Frees a pattern */ +static void pattern_free(void *data) +{ + struct pattern *pattern = data; + + if (!pattern) + return; + + free(pattern); +} + +/* Frees a monitor object */ +static void monitor_free(void *data) +{ + struct adv_monitor *monitor = data; + + if (!monitor) + return; + + g_dbus_proxy_unref(monitor->proxy); + g_free(monitor->path); + + queue_destroy(monitor->patterns, pattern_free); + + free(monitor); +} + +/* Calls Release() method of the remote Adv Monitor */ +static void monitor_release(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + + if (!monitor) + return; + + DBG("Calling Release() on Adv Monitor of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "Release", NULL, NULL, NULL, + NULL); +} + /* Destroys an app object along with related D-Bus handlers */ static void app_destroy(void *data) { @@ -94,6 +190,9 @@ static void app_destroy(void *data) DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); + queue_foreach(app->monitors, monitor_release, NULL); + queue_destroy(app->monitors, monitor_free); + if (app->reg) { app_reply_msg(app, btd_error_failed(app->reg, "Adv Monitor app destroyed")); @@ -136,6 +235,372 @@ static void app_ready_cb(GDBusClient *client, void *user_data) app_reply_msg(app, dbus_message_new_method_return(app->reg)); } +/* Allocates an Adv Monitor */ +static struct adv_monitor *monitor_new(struct adv_monitor_app *app, + GDBusProxy *proxy) +{ + struct adv_monitor *monitor; + + if (!app || !proxy) + return NULL; + + monitor = new0(struct adv_monitor, 1); + if (!monitor) + return NULL; + + monitor->app = app; + monitor->proxy = g_dbus_proxy_ref(proxy); + monitor->path = g_strdup(g_dbus_proxy_get_path(proxy)); + + monitor->state = MONITOR_STATE_NEW; + + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + + monitor->type = MONITOR_TYPE_NONE; + monitor->patterns = NULL; + + return monitor; +} + +/* Matches a monitor based on its D-Bus path */ +static bool monitor_match(const void *a, const void *b) +{ + const GDBusProxy *proxy = b; + const struct adv_monitor *monitor = a; + + if (!proxy || !monitor) + return false; + + if (strcmp(g_dbus_proxy_get_path(proxy), monitor->path) != 0) + return false; + + return true; +} + +/* Retrieves Type from the remote Adv Monitor object, verifies the value and + * update the local Adv Monitor + */ +static bool parse_monitor_type(struct adv_monitor *monitor, const char *path) +{ + DBusMessageIter iter; + const struct adv_monitor_type *t; + const char *type_str; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (!g_dbus_proxy_get_property(monitor->proxy, "Type", &iter)) { + btd_error(adapter_id, "Failed to retrieve property Type from " + "the Adv Monitor at path %s", path); + return false; + } + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + goto failed; + + dbus_message_iter_get_basic(&iter, &type_str); + + for (t = supported_types; t->name; t++) { + if (strcmp(t->name, type_str) == 0) { + monitor->type = t->type; + return true; + } + } + +failed: + btd_error(adapter_id, "Invalid argument of property Type of the Adv " + "Monitor at path %s", path); + + return false; +} + +/* Retrieves RSSIThresholdsAndTimers from the remote Adv Monitor object, + * verifies the values and update the local Adv Monitor + */ +static bool parse_rssi_and_timeout(struct adv_monitor *monitor, + const char *path) +{ + DBusMessageIter prop_struct, iter; + int16_t h_rssi, l_rssi; + uint16_t h_rssi_timer, l_rssi_timer; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + /* Property RSSIThresholdsAndTimers is optional */ + if (!g_dbus_proxy_get_property(monitor->proxy, + "RSSIThresholdsAndTimers", + &prop_struct)) { + DBG("Adv Monitor at path %s provides no RSSI thresholds and " + "timeouts", path); + return true; + } + + if (dbus_message_iter_get_arg_type(&prop_struct) != DBUS_TYPE_STRUCT) + goto failed; + + dbus_message_iter_recurse(&prop_struct, &iter); + + /* Extract HighRSSIThreshold */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) + goto failed; + dbus_message_iter_get_basic(&iter, &h_rssi); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract HighRSSIThresholdTimer */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) + goto failed; + dbus_message_iter_get_basic(&iter, &h_rssi_timer); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract LowRSSIThreshold */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) + goto failed; + dbus_message_iter_get_basic(&iter, &l_rssi); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract LowRSSIThresholdTimer */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) + goto failed; + dbus_message_iter_get_basic(&iter, &l_rssi_timer); + + /* Verify the values of RSSIs and their timers. For simplicity, we + * enforce the all-or-none rule to these fields. In other words, either + * all are set to the unset values or all are set within valid ranges. + */ + if (h_rssi == ADV_MONITOR_UNSET_RSSI && + l_rssi == ADV_MONITOR_UNSET_RSSI && + h_rssi_timer == ADV_MONITOR_UNSET_TIMER && + l_rssi_timer == ADV_MONITOR_UNSET_TIMER) { + goto done; + } + + if (h_rssi < ADV_MONITOR_MIN_RSSI || h_rssi > ADV_MONITOR_MAX_RSSI || + l_rssi < ADV_MONITOR_MIN_RSSI || + l_rssi > ADV_MONITOR_MAX_RSSI || h_rssi <= l_rssi) { + goto failed; + } + + if (h_rssi_timer < ADV_MONITOR_MIN_TIMER || + h_rssi_timer > ADV_MONITOR_MAX_TIMER || + l_rssi_timer < ADV_MONITOR_MIN_TIMER || + l_rssi_timer > ADV_MONITOR_MAX_TIMER) { + goto failed; + } + + monitor->high_rssi = h_rssi; + monitor->low_rssi = l_rssi; + monitor->high_rssi_timeout = h_rssi_timer; + monitor->low_rssi_timeout = l_rssi_timer; + +done: + DBG("Adv Monitor at %s initiated with high RSSI threshold %d, high " + "RSSI threshold timeout %d, low RSSI threshold %d, low RSSI " + "threshold timeout %d", path, monitor->high_rssi, + monitor->high_rssi_timeout, monitor->low_rssi, + monitor->low_rssi_timeout); + + return true; + +failed: + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + + btd_error(adapter_id, "Invalid argument of property " + "RSSIThresholdsAndTimers of the Adv Monitor at path %s", + path); + + return false; +} + +/* Retrieves Patterns from the remote Adv Monitor object, verifies the values + * and update the local Adv Monitor + */ +static bool parse_patterns(struct adv_monitor *monitor, const char *path) +{ + DBusMessageIter array, array_iter; + uint16_t num_patterns = 0; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (!g_dbus_proxy_get_property(monitor->proxy, "Patterns", &array)) { + btd_error(adapter_id, "Failed to retrieve property Patterns " + "from the Adv Monitor at path %s", path); + return false; + } + + monitor->patterns = queue_new(); + + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY || + dbus_message_iter_get_element_type(&array) != + DBUS_TYPE_STRUCT) { + goto failed; + } + + dbus_message_iter_recurse(&array, &array_iter); + + while (dbus_message_iter_get_arg_type(&array_iter) == + DBUS_TYPE_STRUCT) { + int value_len; + uint8_t *value; + uint8_t offset, ad_type; + struct pattern *pattern; + DBusMessageIter struct_iter, value_iter; + + dbus_message_iter_recurse(&array_iter, &struct_iter); + + // Extract start position + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_BYTE) { + goto failed; + } + dbus_message_iter_get_basic(&struct_iter, &offset); + if (!dbus_message_iter_next(&struct_iter)) + goto failed; + + // Extract AD data type + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_BYTE) { + goto failed; + } + dbus_message_iter_get_basic(&struct_iter, &ad_type); + if (!dbus_message_iter_next(&struct_iter)) + goto failed; + + // Extract value of a pattern + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_ARRAY) { + goto failed; + } + dbus_message_iter_recurse(&struct_iter, &value_iter); + dbus_message_iter_get_fixed_array(&value_iter, &value, + &value_len); + + // Verify the values + if (offset > BT_AD_MAX_DATA_LEN - 1) + goto failed; + + if (ad_type > BT_AD_3D_INFO_DATA && + ad_type != BT_AD_MANUFACTURER_DATA + || ad_type < BT_AD_FLAGS) { + goto failed; + } + + if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) + goto failed; + + pattern = new0(struct pattern, 1); + if (!pattern) + goto failed; + + pattern->ad_type = ad_type; + pattern->offset = offset; + pattern->length = value_len; + memcpy(pattern->value, value, pattern->length); + + queue_push_tail(monitor->patterns, pattern); + + dbus_message_iter_next(&array_iter); + } + + /* There must be at least one pattern. */ + if (queue_isempty(monitor->patterns)) + goto failed; + + return true; + +failed: + queue_destroy(monitor->patterns, pattern_free); + monitor->patterns = NULL; + + btd_error(adapter_id, "Invalid argument of property Patterns of the " + "Adv Monitor at path %s", path); + + return false; +} + +/* Processes the content of the remote Adv Monitor */ +static bool monitor_process(struct adv_monitor *monitor, + struct adv_monitor_app *app) +{ + const char *path = g_dbus_proxy_get_path(monitor->proxy); + + monitor->state = MONITOR_STATE_FAILED; + + if (!parse_monitor_type(monitor, path)) + goto done; + + if (!parse_rssi_and_timeout(monitor, path)) + goto done; + + if (monitor->type == MONITOR_TYPE_OR_PATTERNS && + parse_patterns(monitor, path)) { + monitor->state = MONITOR_STATE_INITED; + } + +done: + return monitor->state != MONITOR_STATE_FAILED; +} + +/* Handles an Adv Monitor D-Bus proxy added event */ +static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) +{ + struct adv_monitor *monitor; + struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + const char *path = g_dbus_proxy_get_path(proxy); + const char *iface = g_dbus_proxy_get_interface(proxy); + + if (strcmp(iface, ADV_MONITOR_INTERFACE) != 0 || + !g_str_has_prefix(path, app->path)) { + return; + } + + if (queue_find(app->monitors, monitor_match, proxy)) { + btd_error(adapter_id, "Adv Monitor proxy already exists with " + "path %s", path); + return; + } + + monitor = monitor_new(app, proxy); + if (!monitor) { + btd_error(adapter_id, "Failed to allocate an Adv Monitor for " + "the object at %s", path); + return; + } + + if (!monitor_process(monitor, app)) { + monitor_release(monitor, NULL); + monitor_free(monitor); + DBG("Adv Monitor at path %s released due to invalid content", + path); + return; + } + + queue_push_tail(app->monitors, monitor); + + DBG("Adv Monitor allocated for the object at path %s", path); +} + +/* Handles the removal of an Adv Monitor D-Bus proxy */ +static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) +{ + struct adv_monitor *monitor; + struct adv_monitor_app *app = user_data; + + monitor = queue_remove_if(app->monitors, monitor_match, proxy); + if (monitor) { + DBG("Adv Monitor removed for the object at path %s", + monitor->path); + + /* The object was gone, so we don't need to call Release() */ + monitor_free(monitor); + } +} + /* Creates an app object, initiates it and sets D-Bus event handlers */ static struct adv_monitor_app *app_create(DBusConnection *conn, DBusMessage *msg, const char *sender, @@ -162,8 +627,17 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, return NULL; } + app->monitors = queue_new(); + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); - g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); + + /* Note that any property changes on a monitor object would not affect + * the content of the corresponding monitor. + */ + g_dbus_client_set_proxy_handlers(app->client, monitor_proxy_added_cb, + monitor_proxy_removed_cb, NULL, + app); + g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); app->reg = dbus_message_ref(msg); @@ -270,18 +744,6 @@ static const GDBusMethodTable adv_monitor_methods[] = { { } }; -enum monitor_type { - MONITOR_TYPE_OR_PATTERNS, -}; - -const struct adv_monitor_type { - enum monitor_type type; - const char *name; -} supported_types[] = { - { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, - { }, -}; - /* Gets SupportedMonitorTypes property */ static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, DBusMessageIter *iter, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QJ5kEuCtWV/LgAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:38:56 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id EPcqD+CtWV+C7wEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:38:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A1826A0B2D; Thu, 10 Sep 2020 06:38:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726345AbgIJEik (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:38:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726612AbgIJEig (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:38:36 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5EC7C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:38:35 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id g29so3584296pgl.2 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:38:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OwcQPbWK9wBBKShQmm51i7xxWQDNt4zUBesrzpNnDCQ=; b=R7NQ3PQE0aZ0JhPX44PwcsKwYpCKaHUHx2NVfARomjcVco8wG6Taa7jOOfWD8ujXFl 7XeldgTgFjT6ZjvtQwRWd/fQvmoJYi32w5CSXeeBf6DA3x7MuKanhKvFOQKabVwp7wCF wt5He55q490tuVtxPgEj+gC1iXJiw7iWEw5Sg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OwcQPbWK9wBBKShQmm51i7xxWQDNt4zUBesrzpNnDCQ=; b=EhL9o9kuIvTc1EYv8wy5H9QTb5VcBP5Af3PnwHS3AWuUV559PSMKb44NQRSHhPYkCY bU3uF8F6p4+BMwHTmXCDupjUNCVIT2rNV9TvXlyGRUU3EmCA76kqAMj+cawZZate6RBK qxtiWrq2R81Jr8CQ65dWCnBgxEGCknE3mbmSJAD839ldnattQpVz2aFHsp4d0TC0Y4gc i5opBgnvK6mNObFWBdcPsW5B/ZDHnL8kswnBNWmH2q1ybn2F/ojZYBAJdKMKAs9MUviK Wc9wE1W6DZyqcCcQ+BNBEPebqHPog4mwDLCIWRRbx/O35uNSX0FiSkw0Cd6TPqI3ARIH gyIg== X-Gm-Message-State: AOAM532r0mDazDPP29+51wbcWf761lnD9yQ3gCQuhq65LeOuvkwVqw5g GX+282fpWAsywsyATq95TU1h46LuVNUILw== X-Google-Smtp-Source: ABdhPJz+5RaXIqT8f3AdADKzxAUoo15JNBX5cbprejOmiqFlFuA3fi1UOgp1zbKKNEsnx5noZk71jA== X-Received: by 2002:a65:4c0f:: with SMTP id u15mr2871310pgq.296.1599712713533; Wed, 09 Sep 2020 21:38:33 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y4sm4149820pfq.215.2020.09.09.21.38.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:38:32 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v2 7/7] doc: Update Advertisement Monitor API description Date: Wed, 9 Sep 2020 21:35:44 -0700 Message-Id: <20200909213423.BlueZ.v2.7.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.73 / 15.00 / 15.00 X-Rspamd-Queue-Id: A1826A0B2D X-Rspamd-UID: 3acb14 This modifies the following description to Advertisement Monitor API. - Add org.bluez.Error.Failed to RegisterMonitor() method. - Add more description about the usage of RegisterMonitor() and UnregisterMonitor() methods. - Add description about the ranges for the fields in property RSSIThresholdsAndTimers. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) doc/advertisement-monitor-api.txt | 34 +++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index 74adbfae9..e09b6fd25 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -49,7 +49,7 @@ Properties string Type [read-only] org.bluez.AdvertisementMonitorManager1 for the available options. - (Int16, Uint16, Int16, Uint16) RSSIThreshholdsAndTimers [read-only, optional] + (Int16, Uint16, Int16, Uint16) RSSIThresholdsAndTimers [read-only, optional] This contains HighRSSIThreshold, HighRSSIThresholdTimer, LowRSSIThreshold, LowRSSIThresholdTimer in order. The @@ -66,7 +66,11 @@ Properties string Type [read-only] RSSIs of the received advertisement(s) during LowRSSIThresholdTimer do not reach LowRSSIThreshold. - array{(uint8, uint8, string)} Patterns [read-only, optional] + The valid range of a RSSI is -127 to +20 dBm while 127 + dBm indicates unset. The valid range of a timer is 1 to + 300 seconds while 0 indicates unset. + + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] If Type is set to 0x01, this must exist and has at least one entry in the array. @@ -80,8 +84,9 @@ Properties string Type [read-only] See https://www.bluetooth.com/specifications/ assigned-numbers/generic-access-profile/ for the possible allowed value. - string content_of_pattern - This is the value of the pattern. + array{byte} content_of_pattern + This is the value of the pattern. The maximum + length of the bytes is 31. Advertisement Monitor Manager hierarchy ======================================= @@ -91,20 +96,31 @@ Object path /org/bluez/{hci0,hci1,...} Methods void RegisterMonitor(object application) - This registers a hierarchy of advertisement monitors. + This registers the root path of a hierarchy of + advertisement monitors. The application object path together with the D-Bus system bus connection ID define the identification of the application registering advertisement monitors. + Once a root path is registered by a client via this + method, the client can freely expose/unexpose + advertisement monitors without re-registering the root + path again. After use, the client should call + UnregisterMonitor() method to invalidate the + advertisement monitors. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.AlreadyExists + org.bluez.Error.Failed void UnregisterMonitor(object application) - This unregisters advertisement monitors that have been - previously registered. The object path parameter must - match the same value that has been used on - registration. + This unregisters a hierarchy of advertisement monitors + that has been previously registered. The object path + parameter must match the same value that has been used + on registration. Upon unregistration, the advertisement + monitor(s) should expect to receive Release() method as + the signal that the advertisement monitor(s) has been + deactivated. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.DoesNotExist -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OL0dM6auWV96qgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:42:14 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UBV6L6auWV+U9QEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:42:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2069D40876; Thu, 10 Sep 2020 06:42:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725887AbgIJEmH (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:42:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgIJEmE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:42:04 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE0DC061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:42:03 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d16so288951pll.13 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ku7StIItobDQpZNzzTw010eLm24wM3HDjZ2DFx/1Eho=; b=O2PiiEWZoXapjaiVwF8hMiTBrI/nMsPZEBYgOIYuc0PiRHNuj9kOpHkgjt4xKTzFD4 rXZQHxGosk8vbFTWNcp76vBAj0Jh4xANzH6QAbV+agQHN7kIVqVONMm/j9HYABiFdGPd im0lbtdvfVCGKKhN1n2Uda/q8nqwaBWZm/+Q0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ku7StIItobDQpZNzzTw010eLm24wM3HDjZ2DFx/1Eho=; b=kuMejZU3mWr0aJ4gER+HAENeJdO8s9rsaPBV4FAaXHyDjqWL4EMS8wZA/nl8Lwhb+q m8r40jm1dJ7tI3XG+ZUkHkfZCA51xUyDrlXCbaUknIzCO+4gBDkoJoxy2/wStfGJN4vG D5NqA6/j8YbgJmqsUw2fXMogiNDCCbyeBOIn+Qy4ujMvbd0BI0rk8/zVivgQlSp2wicD v3ilLWkb312k5XQ5aT9SJhx6eKcCoWd2KQ6nA52j9UI34dPTg1YUqKVCbqM9EGQ7r60V YvSDFpi1V95Sj/COeUKVThaZkwap0zw/ZV3S9nVRQ2+ZEnIKja4SNNx98w31obIdohn9 Fc/g== X-Gm-Message-State: AOAM533B9i+YOYlIMHGHSIUmk3R0PTDcgzrblaFKJJRa+/6iPN2XuvhZ d5hVFbrqnLratshhf6FlLUz9CHoeE90Ipw== X-Google-Smtp-Source: ABdhPJz24uC3vUHtgFac0XqrMTFwhjR8eajnPJOemAV30Y1G9V2kbyZrPVXfM59tdznUgek9sTIBnQ== X-Received: by 2002:a17:902:8509:b029:d0:cbe1:e746 with SMTP id bj9-20020a1709028509b02900d0cbe1e746mr3822130plb.33.1599712921761; Wed, 09 Sep 2020 21:42:01 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k4sm644888pjl.10.2020.09.09.21.42.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:42:01 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v3 1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Date: Wed, 9 Sep 2020 21:41:24 -0700 Message-Id: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2069D40876 X-Rspamd-UID: 834768 This introduces the org.bluez.AdvertisementMonitorManager1 without implementing handlers of methods and properties. The following test was performed. - Upon adapter registration, the info line of creating an ADV monitor manager gets printed, and system bus emits the interface events of org.bluez.AdvertisementMonitorManager1. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v2) Changes in v2: -Use new0 instead of g_new0 -Remove the reset of manager members -Make methods/property experimental Makefile.am | 3 +- src/adapter.c | 14 +++++ src/adapter.h | 3 + src/adv_monitor.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++ src/adv_monitor.h | 32 ++++++++++ 5 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 src/adv_monitor.c create mode 100644 src/adv_monitor.h diff --git a/Makefile.am b/Makefile.am index 7719c06f8..b14ee950e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -293,7 +293,8 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ src/gatt-client.h src/gatt-client.c \ src/device.h src/device.c \ src/dbus-common.c src/dbus-common.h \ - src/eir.h src/eir.c + src/eir.h src/eir.c \ + src/adv_monitor.h src/adv_monitor.c src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ gdbus/libgdbus-internal.la \ src/libshared-glib.la \ diff --git a/src/adapter.c b/src/adapter.c index 1435e2bd7..de327dc98 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -77,6 +77,7 @@ #include "attrib-server.h" #include "gatt-database.h" #include "advertising.h" +#include "adv_monitor.h" #include "eir.h" #define ADAPTER_INTERFACE "org.bluez.Adapter1" @@ -272,6 +273,8 @@ struct btd_adapter { struct btd_gatt_database *database; struct btd_adv_manager *adv_manager; + struct btd_adv_monitor_manager *adv_monitor_manager; + gboolean initialized; GSList *pin_callbacks; @@ -6360,6 +6363,9 @@ static void adapter_remove(struct btd_adapter *adapter) btd_adv_manager_destroy(adapter->adv_manager); adapter->adv_manager = NULL; + btd_adv_monitor_manager_destroy(adapter->adv_monitor_manager); + adapter->adv_monitor_manager = NULL; + g_slist_free(adapter->pin_callbacks); adapter->pin_callbacks = NULL; @@ -8633,6 +8639,14 @@ static int adapter_register(struct btd_adapter *adapter) adapter->adv_manager = btd_adv_manager_new(adapter, adapter->mgmt); + adapter->adv_monitor_manager = btd_adv_monitor_manager_create( + adapter, adapter->mgmt); + if (!adapter->adv_monitor_manager) { + btd_error(adapter->dev_id, + "Failed to create Adv Monitor Manager for adapter"); + return -EINVAL; + } + db = btd_gatt_database_get_db(adapter->database); adapter->db_id = gatt_db_register(db, services_modified, services_modified, diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..5cb467141 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -26,6 +26,9 @@ #include <dbus/dbus.h> #include <glib.h> +#include "lib/bluetooth.h" +#include "lib/sdp.h" + #define MAX_NAME_LENGTH 248 /* Invalid SSP passkey value used to indicate negative replies */ diff --git a/src/adv_monitor.c b/src/adv_monitor.c new file mode 100644 index 000000000..8e7dad8dd --- /dev/null +++ b/src/adv_monitor.c @@ -0,0 +1,148 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdint.h> + +#include <glib.h> +#include <dbus/dbus.h> +#include <gdbus/gdbus.h> + +#include "adapter.h" +#include "dbus-common.h" +#include "log.h" +#include "src/shared/mgmt.h" +#include "src/shared/util.h" + +#include "adv_monitor.h" + +#define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" + +struct btd_adv_monitor_manager { + struct btd_adapter *adapter; + struct mgmt *mgmt; + uint16_t adapter_id; + char *path; +}; + +static const GDBusMethodTable adv_monitor_methods[] = { + { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { } +}; + +static const GDBusPropertyTable adv_monitor_properties[] = { + {"SupportedMonitorTypes", "as", NULL, NULL, NULL, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, + {"SupportedFeatures", "as", NULL, NULL, NULL}, + { } +}; + +/* Allocates a manager object */ +static struct btd_adv_monitor_manager *manager_new( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + if (!adapter || !mgmt) + return NULL; + + manager = new0(struct btd_adv_monitor_manager, 1); + if (!manager) + return NULL; + + manager->adapter = adapter; + manager->mgmt = mgmt_ref(mgmt); + manager->adapter_id = btd_adapter_get_index(adapter); + manager->path = g_strdup(adapter_get_path(manager->adapter)); + + return manager; +} + +/* Frees a manager object */ +static void manager_free(struct btd_adv_monitor_manager *manager) +{ + mgmt_unref(manager->mgmt); + free(manager->path); + + free(manager); +} + +/* Destroys a manager object and unregisters its D-Bus interface */ +static void manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + g_dbus_unregister_interface(btd_get_dbus_connection(), + manager->path, + ADV_MONITOR_MGR_INTERFACE); + + manager_free(manager); +} + +/* Creates a manager and registers its D-Bus interface */ +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + manager = manager_new(adapter, mgmt); + if (!manager) + return NULL; + + if (!g_dbus_register_interface(btd_get_dbus_connection(), manager->path, + ADV_MONITOR_MGR_INTERFACE, + adv_monitor_methods, NULL, + adv_monitor_properties, manager, + NULL)) { + btd_error(manager->adapter_id, + "Failed to register " + ADV_MONITOR_MGR_INTERFACE); + manager_free(manager); + return NULL; + } + + btd_info(manager->adapter_id, + "Adv Monitor Manager created for adapter %s", + adapter_get_path(manager->adapter)); + + return manager; +} + +/* Destroys a manager and unregisters its D-Bus interface */ +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + btd_info(manager->adapter_id, "Destroy Adv Monitor Manager"); + + manager_destroy(manager); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h new file mode 100644 index 000000000..69ea348f8 --- /dev/null +++ b/src/adv_monitor.h @@ -0,0 +1,32 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifndef __ADV_MONITOR_H +#define __ADV_MONITOR_H + +struct mgmt; +struct btd_adapter; +struct btd_adv_monitor_manager; + +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt); +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); + +#endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6P+SNLKuWV/7ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:42:26 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SCGIMbKuWV+njAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:42:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8C9CC40961; Thu, 10 Sep 2020 06:42:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725912AbgIJEmU (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgIJEmQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:42:16 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37125C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:42:16 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id v15so3570420pgh.6 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zLi61UtegLxZoRPn4T9W5e3L/HqdjAdjheNWCNy6w+M=; b=mNCcUETrSu4J2M5L+AAySz4MvYfQY3feIqA4hLyjHt/wbAGoX2kVRZUnWIZbfN5HHz 935JdnQDDEmWcS70AtOEwDqb+gZs0FJxIAd3ONu7hfkO+l9fzxKNKywh922FFsVclJHj h4VpUSDZqgg65RAXmljutzZpD/OJ7bMn52TJ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zLi61UtegLxZoRPn4T9W5e3L/HqdjAdjheNWCNy6w+M=; b=Q6sbdAGG45uWRqKkpoIrK5q2mElX/M4lzvNk+QgOqhGR2fiSjd+9nT4ixd9tQIkfuy cchVxVHkLSrXHmSCU2J1OIJHB9v9GlO84PaE75tdOPfPwRXG76VIj9L/4my0TgGg3qB3 pgJlreiFOH5T9y5QFkkmFVJjNbBUf5++EJXrF7S9rG5MTmLXTGC1IVDcFvZEnJtAlzi2 2jxdv1hdY2CGUdAXqYiZ7Nh1ksRlnICLG+gY35hpP+vq1BqXNmCdOMjBmauw5QuDi856 9MbbZuJ6L+HEWXteOOqJwYz6g1biVMUNNsoho8GokR0sbHJTstGuXOGAr+p2yZ6/AmwY iinA== X-Gm-Message-State: AOAM530PldC6nJTGxLVNwUrItHTFu1Vs4H6zn2L3YUVImiY51WEEsM31 +S2jOwXIgah/DW1K8ycA6d2KW2Fu9PaV/g== X-Google-Smtp-Source: ABdhPJxy/HuhFeimU+UuLjQ03fU2cdPjG6RTwnDDlWyrsaWZ5LGfbCUYy3nXsczIxHMLzizes3jAUA== X-Received: by 2002:aa7:9484:: with SMTP id z4mr3708258pfk.32.1599712935382; Wed, 09 Sep 2020 21:42:15 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k4sm644888pjl.10.2020.09.09.21.42.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:42:14 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v3 2/7] adv_monitor: Implement Get functions of Adv monitor manager properties Date: Wed, 9 Sep 2020 21:41:26 -0700 Message-Id: <20200909214058.BlueZ.v3.2.I9960e45d36be3edb5f17de025e7eb8257d3cddef@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.03 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8C9CC40961 X-Rspamd-UID: 64331a This implements the Get functions of SupportedMonitorTypes and SupportedFeatures. The following test was performed. - Issue dbus-send to read SupportedMonitorTypes and SupportedFeatures. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v1) src/adv_monitor.c | 128 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 5 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 8e7dad8dd..54e67bf2c 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -28,6 +28,9 @@ #include <dbus/dbus.h> #include <gdbus/gdbus.h> +#include "lib/bluetooth.h" +#include "lib/mgmt.h" + #include "adapter.h" #include "dbus-common.h" #include "log.h" @@ -43,6 +46,12 @@ struct btd_adv_monitor_manager { struct mgmt *mgmt; uint16_t adapter_id; char *path; + + uint32_t supported_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ + uint32_t enabled_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ + uint16_t max_num_monitors; + uint8_t max_num_patterns; + }; static const GDBusMethodTable adv_monitor_methods[] = { @@ -55,10 +64,78 @@ static const GDBusMethodTable adv_monitor_methods[] = { { } }; +enum monitor_type { + MONITOR_TYPE_OR_PATTERNS, +}; + +const struct adv_monitor_type { + enum monitor_type type; + const char *name; +} supported_types[] = { + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, + { }, +}; + +/* Gets SupportedMonitorTypes property */ +static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, + DBusMessageIter *iter, + void *data) +{ + DBusMessageIter entry; + const struct adv_monitor_type *t; + struct btd_adv_monitor_manager *manager = data; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, + &entry); + + for (t = supported_types; t->name; t++) { + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, + &t->name); + } + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + +const struct adv_monitor_feature { + uint32_t mask; + const char *name; +} supported_features[] = { + { MGMT_ADV_MONITOR_FEATURE_MASK_OR_PATTERNS, "controller-patterns" }, + { } +}; + +/* Gets SupportedFeatures property */ +static gboolean get_supported_features(const GDBusPropertyTable *property, + DBusMessageIter *iter, + void *data) +{ + DBusMessageIter entry; + const struct adv_monitor_feature *f; + struct btd_adv_monitor_manager *manager = data; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, + &entry); + + for (f = supported_features; f->name; f++) { + if (manager->supported_features & f->mask) { + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, + &f->name); + } + } + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + static const GDBusPropertyTable adv_monitor_properties[] = { - {"SupportedMonitorTypes", "as", NULL, NULL, NULL, + {"SupportedMonitorTypes", "as", get_supported_monitor_types, NULL, NULL, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, - {"SupportedFeatures", "as", NULL, NULL, NULL}, + {"SupportedFeatures", "as", get_supported_features, NULL, NULL}, { } }; @@ -106,6 +183,42 @@ static void manager_destroy(struct btd_adv_monitor_manager *manager) manager_free(manager); } +/* Initiates manager's members based on the return of + * MGMT_OP_READ_ADV_MONITOR_FEATURES + */ +static void read_adv_monitor_features_cb(uint8_t status, uint16_t length, + const void *param, + void *user_data) +{ + const struct mgmt_rp_read_adv_monitor_features *rp = param; + struct btd_adv_monitor_manager *manager = user_data; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(manager->adapter_id, "Failed to Read Adv Monitor " + "Features with status 0x%02x", status); + return; + } + + if (length < sizeof(*rp)) { + btd_error(manager->adapter_id, + "Wrong size of Read Adv Monitor Features " + "response"); + return; + } + + manager->supported_features = le32_to_cpu(rp->supported_features); + manager->enabled_features = le32_to_cpu(rp->enabled_features); + manager->max_num_monitors = le16_to_cpu(rp->max_num_handles); + manager->max_num_patterns = rp->max_num_patterns; + + btd_info(manager->adapter_id, "Adv Monitor Manager created with " + "supported features:0x%08x, enabled features:0x%08x, " + "max number of supported monitors:%d, " + "max number of supported patterns:%d", + manager->supported_features, manager->enabled_features, + manager->max_num_monitors, manager->max_num_patterns); +} + /* Creates a manager and registers its D-Bus interface */ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct btd_adapter *adapter, @@ -129,9 +242,14 @@ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( return NULL; } - btd_info(manager->adapter_id, - "Adv Monitor Manager created for adapter %s", - adapter_get_path(manager->adapter)); + if (!mgmt_send(manager->mgmt, MGMT_OP_READ_ADV_MONITOR_FEATURES, + manager->adapter_id, 0, NULL, + read_adv_monitor_features_cb, manager, NULL)) { + btd_error(manager->adapter_id, + "Failed to send Read Adv Monitor Features"); + manager_destroy(manager); + return NULL; + } return manager; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WKfDKMOuWV/7ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:42:43 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8ISmJcOuWV+aPwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:42:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 61F2F40973; Thu, 10 Sep 2020 06:42:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725971AbgIJEme (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:42:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgIJEmd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:42:33 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 217EFC061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:42:33 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id f2so1546531pgd.3 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cCiSbDYma1JX3/ppPcLiSTD2+RUYqgnTWTodHKHNHqE=; b=haz1qVZbZPnEXsN4vQYhLRUjJ1awUzhiPmtGHk4kefBufO2kofSOwDWEoIhDrvjMOS 9QcwjfS0hchJxP0M1fbyyXAFNXav/bHJs8XsA6tBggBWaxdd92bACCvuIw+z6BgzpPYy YNdNgJKaDhE2Px2vthIuBC+Yc758KHkTau7iI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cCiSbDYma1JX3/ppPcLiSTD2+RUYqgnTWTodHKHNHqE=; b=fFkoGCKFT0uEcLR9ICX1L7bn/489qqv7hrJIbcbaOJ7kgibM7yVWFWCNLKWcccV7gK 6ha+o5q/j1o0JN1hT76RANTbbKIEHDzoByh598zQIXdfYQHJP9Cr4ohEZy38Riw/J+rj A78IZKK1Dd9NLyCgAKCdSQbzzbOvWr/DLH+J1EGLlx03G4inuaW7Dxyyt2x7eD7yZ9L9 FEZeOD1ldg6l0Qb8LzuI/T7138iOYqMXe9Mp0lGr5ADRKf0TcOIk7bkCXkbe6uv479Q1 QS3oU7hL+6HvOWaRKLz79tr7fhJy4dSjPYDWU99VjRo05kXSbk4SUWc3Ja3d0OmkKTkE N+bg== X-Gm-Message-State: AOAM532onP6eoxXKgz5XcPHqmQ95SDf6op5O9h/YVk2iunpPkdnXU2c3 k1uLgY4ne2MZt8WGXf5OXD2eh9ztFcjLEg== X-Google-Smtp-Source: ABdhPJw4gSvDgjFgBIbep1jp+D2wrnyBjEACi53uG2IKMyHqsnkDZd4wh/Y4awB21qgonikD1Pt9QQ== X-Received: by 2002:a63:a70d:: with SMTP id d13mr716383pgf.65.1599712950590; Wed, 09 Sep 2020 21:42:30 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k4sm644888pjl.10.2020.09.09.21.42.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:42:29 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v3 3/7] adv_monitor: Implement RegisterMonitor() Date: Wed, 9 Sep 2020 21:41:28 -0700 Message-Id: <20200909214058.BlueZ.v3.3.I19ff9cdbd40fe453db0e81aec8bf94dd9490dce3@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: 61F2F40973 X-Rspamd-UID: 3f5fe3 This implements the RegisterMonitor() method handler of ADV monitor manager interface. The following tests were performed. - Issue a RegisterMonitor() call with a valid path and expect a success as return. - Issue a RegisterMonitor() call with an invalid path and expect org.bluez.Error.InvalidArguments as return. - Issue two Registermonitor() calls with the same path and expect org.bluez.Error.AlreadyExists. - Verify the values of the registered paths with logging. - Verify D-Bus disconnection callback was triggered when the client detach from D-Bus. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v2) Changes in v2: - Use new0() instead of g_new0() - Remove the reset of app members src/adv_monitor.c | 164 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 163 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 54e67bf2c..b8b55d2fc 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -22,7 +22,9 @@ #endif #define _GNU_SOURCE +#include <errno.h> #include <stdint.h> +#include <string.h> #include <glib.h> #include <dbus/dbus.h> @@ -34,7 +36,9 @@ #include "adapter.h" #include "dbus-common.h" #include "log.h" +#include "src/error.h" #include "src/shared/mgmt.h" +#include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" @@ -52,12 +56,167 @@ struct btd_adv_monitor_manager { uint16_t max_num_monitors; uint8_t max_num_patterns; + struct queue *apps; /* apps who registered for Adv monitoring */ }; +struct adv_monitor_app { + struct btd_adv_monitor_manager *manager; + char *owner; + char *path; + + DBusMessage *reg; + GDBusClient *client; +}; + +struct app_match_data { + const char *owner; + const char *path; +}; + +/* Replies to an app's D-Bus message and unref it */ +static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) +{ + if (!app || !app->reg || !reply) + return; + + g_dbus_send_message(btd_get_dbus_connection(), reply); + dbus_message_unref(app->reg); + app->reg = NULL; +} + +/* Destroys an app object along with related D-Bus handlers */ +static void app_destroy(void *data) +{ + struct adv_monitor_app *app = data; + + if (!app) + return; + + DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); + + if (app->reg) { + app_reply_msg(app, btd_error_failed(app->reg, + "Adv Monitor app destroyed")); + } + + if (app->client) { + g_dbus_client_set_disconnect_watch(app->client, NULL, NULL); + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, + NULL); + g_dbus_client_set_ready_watch(app->client, NULL, NULL); + g_dbus_client_unref(app->client); + } + + g_free(app->owner); + g_free(app->path); + + free(app); +} + +/* Handles a D-Bus disconnection event of an app */ +static void app_disconnect_cb(DBusConnection *conn, void *user_data) +{ + struct adv_monitor_app *app = user_data; + + btd_info(app->manager->adapter_id, "Adv Monitor app %s disconnected " + "from D-Bus", app->owner); + if (app && queue_remove(app->manager->apps, app)) + app_destroy(app); +} + +/* Creates an app object, initiates it and sets D-Bus event handlers */ +static struct adv_monitor_app *app_create(DBusConnection *conn, + const char *sender, const char *path, + struct btd_adv_monitor_manager *manager) +{ + struct adv_monitor_app *app; + + if (!path || !sender || !manager) + return NULL; + + app = new0(struct adv_monitor_app, 1); + if (!app) + return NULL; + + app->owner = g_strdup(sender); + app->path = g_strdup(path); + app->manager = manager; + app->reg = NULL; + + app->client = g_dbus_client_new(conn, sender, path); + if (!app->client) { + app_destroy(app); + return NULL; + } + + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); + g_dbus_client_set_ready_watch(app->client, NULL, NULL); + + return app; +} + +/* Matches an app based on its owner and path */ +static bool app_match(const void *a, const void *b) +{ + const struct adv_monitor_app *app = a; + const struct app_match_data *match = b; + + if (match->owner && strcmp(app->owner, match->owner)) + return false; + + if (match->path && strcmp(app->path, match->path)) + return false; + + return true; +} + +/* Handles a RegisterMonitor D-Bus call */ +static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, + void *user_data) +{ + DBusMessageIter args; + struct app_match_data match; + struct adv_monitor_app *app; + struct btd_adv_monitor_manager *manager = user_data; + + if (!dbus_message_iter_init(msg, &args)) + return btd_error_invalid_args(msg); + + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) + return btd_error_invalid_args(msg); + + dbus_message_iter_get_basic(&args, &match.path); + + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) + return btd_error_invalid_args(msg); + + match.owner = dbus_message_get_sender(msg); + + if (queue_find(manager->apps, app_match, &match)) + return btd_error_already_exists(msg); + + app = app_create(conn, match.owner, match.path, manager); + if (!app) { + btd_error(manager->adapter_id, + "Failed to reserve %s for Adv Monitor app %s", + match.path, match.owner); + return btd_error_failed(msg, + "Failed to create Adv Monitor app"); + } + + queue_push_tail(manager->apps, app); + + btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", + match.path, match.owner); + + return dbus_message_new_method_return(msg); +} + static const GDBusMethodTable adv_monitor_methods[] = { { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), - NULL, NULL) }, + NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, NULL) }, @@ -157,6 +316,7 @@ static struct btd_adv_monitor_manager *manager_new( manager->mgmt = mgmt_ref(mgmt); manager->adapter_id = btd_adapter_get_index(adapter); manager->path = g_strdup(adapter_get_path(manager->adapter)); + manager->apps = queue_new(); return manager; } @@ -167,6 +327,8 @@ static void manager_free(struct btd_adv_monitor_manager *manager) mgmt_unref(manager->mgmt); free(manager->path); + queue_destroy(manager->apps, app_destroy); + free(manager); } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sN0sNs6uWV/LgAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:42:54 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +I/MMs6uWV9OWQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:42:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 84BCA40968; Thu, 10 Sep 2020 06:42:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726079AbgIJEmr (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:42:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgIJEmq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:42:46 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27D63C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:42:46 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d16so289621pll.13 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wgoIVPRWXVNntcbMbldt7TpPEHI4+Eh2hW+gjZOt2Js=; b=c/G21twhE3vqjwC7Mil15+hpuCfBHlF/bSWjwhf0tDlfBOKffQDVIoXoBeevLzZnOB ezo7Zc20aIX4bC24CtGa9p2GbHQnt407Hc/cZQTw+dv7CsoSF9A5kssGwAIbO116PsXk DmoP3DWMigoYyzebiew3auQpzlyxYctvkaOHo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wgoIVPRWXVNntcbMbldt7TpPEHI4+Eh2hW+gjZOt2Js=; b=lgDaBAmVwtzVAmiJOmdrj4bg4kUefRkgB1xgP0cF+bTE4YdF7ltixboUzlZ0NzBo5G +wljfrpk/6P2J35/+20QLoY1U1piIVryV8wYSiPPw75Vb6uLiMWnM0jz2PL99fkMGQvY LZYXcR7mzzt7E1J32JTzhW7Oi3gqlS0BpcnGd4ltJW+zZJ0fgM+2+GHsQOujY6bhUThE +ZBMdX/KEYxQMF0Y8SEs+GTQxdjKfe35RzU7EM0vHqkEhI3+2lhIWqtmU5tcUNB9FtK/ msuBrnRqI8GU1lyYaIN/qBweDBg+9aNgNuQPYU1nheCcqwLFsDVhPITiPRj1Ay3aF2U4 QU3w== X-Gm-Message-State: AOAM531DHw/PT/MNtbaMGcvDUe5LdmEhNfFUIA7/6c2/HkJDWQKIYNK6 sCh1q3Y7uJN2ulYU1u8RrZGJKoXB8lO0RA== X-Google-Smtp-Source: ABdhPJzZgcg7AuKV+NvveWUxz++oRUMA3zuyB+nk06Gc/+jY/MqJnDYgK4e9DfVJM/4bxbSX9rmBsA== X-Received: by 2002:a17:902:8d8f:b029:d0:cc02:8527 with SMTP id v15-20020a1709028d8fb02900d0cc028527mr3881909plo.33.1599712965143; Wed, 09 Sep 2020 21:42:45 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k4sm644888pjl.10.2020.09.09.21.42.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:42:44 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v3 4/7] adv_monitor: Implement UnregisterMonitor() Date: Wed, 9 Sep 2020 21:41:30 -0700 Message-Id: <20200909214058.BlueZ.v3.4.I335e42ab9a238261c2492c308ce77c959f631483@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: 84BCA40968 X-Rspamd-UID: 86a98b This implements the UnregisterMonitor() method handler of ADV monitor manager interface. The following tests were performed. - Issue a UnregisterMonitor() call with a nonexistent path and expect org.bluez.Error.DoesNotExist as the return. - Issue a UnregisterMonitor() call with a invalid path and expect org.bluez.Error.InvalidArguments as the return. - Issue RegisterMonitor() with a path, issue UnregisterMonitor() and expect a successful method call return. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v1) src/adv_monitor.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index b8b55d2fc..1a38e6994 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -213,13 +213,48 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, return dbus_message_new_method_return(msg); } +/* Handles UnregisterMonitor D-Bus call */ +static DBusMessage *unregister_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + DBusMessageIter args; + struct app_match_data match; + struct adv_monitor_app *app; + struct btd_adv_monitor_manager *manager = user_data; + + if (!dbus_message_iter_init(msg, &args)) + return btd_error_invalid_args(msg); + + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) + return btd_error_invalid_args(msg); + + dbus_message_iter_get_basic(&args, &match.path); + + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) + return btd_error_invalid_args(msg); + + match.owner = dbus_message_get_sender(msg); + + app = queue_find(manager->apps, app_match, &match); + if (!app) + return btd_error_does_not_exist(msg); + + queue_remove(manager->apps, app); + app_destroy(app); + + btd_info(manager->adapter_id, "Path %s removed along with Adv Monitor " + "app %s", match.path, match.owner); + + return dbus_message_new_method_return(msg); +} + static const GDBusMethodTable adv_monitor_methods[] = { { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", GDBUS_ARGS({ "application", "o" }), - NULL, NULL) }, + NULL, unregister_monitor) }, { } }; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qCxSGuOuWV96qgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:43:15 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WBmgFuOuWV9v+AAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:43:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 54326408B3; Thu, 10 Sep 2020 06:43:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725887AbgIJEnI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:43:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgIJEnG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:43:06 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96231C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:43:03 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id u13so3586764pgh.1 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DTPWYPs/pjfsOoexcMwgn/tJlgN2sDx7AxjUE535+Hc=; b=S12pr/60AGJ8cBIcJ8HaItq3gfbeKYmBPVMMHUWJp0i8mt7Yqymj6bMA4mejpAq2Nu fwnejG9Bb3szmber0LOaHfC6xDT0mr5F4/FZVtFanLOtEaxzuBjr+Bw6rbWOD3FwwQea u184kylDi07tEBhL8DZWDBdBv73xIbmlTFYKQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DTPWYPs/pjfsOoexcMwgn/tJlgN2sDx7AxjUE535+Hc=; b=uQUZx0Q0TXtHEA6LZ6GIv7q0ncRhdlLRACqr1phym1gF3l9T2DFWfW/cnwKI4TmTuF 8sFKEjKgrilS70HRMdKcn0Rtu8EiLk8vFUeev2JDAmIJvNUn4+6bDqbkwZ60YEsWvfre d6C5UCWdIriSrIEU12tuGC4LJ0hkH9Mog8zh+1AKuYD4WTx0G1OuNfu5bKcq3Z4l/XLC /QgkakShXstDoAZ/3o/CYQhzdpaKh0geyzAYV0cYkF1AFQZwZUEtUGSYYcyZYP5BAyLI SmYMn3m0ahGEQQuoImNcB7kb2lbIpq/3EA/t0Cuucm25Nw9RguVTFHMN8SKv2+96wQRd vuNA== X-Gm-Message-State: AOAM530yZm7oQQ6abwqoQL7cPkVpwUINJ0hKnu1ual2xYGx1lT7pSmIu LgolgTtjlNTdSPJP+IhiMRruUQ/tEBnNfA== X-Google-Smtp-Source: ABdhPJy3JA7rv/2gF/ChM7cIVMenNLeB3nbt0KjYYLmnLtVKDdsPNZoDIv0Wi4PTb7rxUJltJk7H7A== X-Received: by 2002:a63:d4a:: with SMTP id 10mr2963901pgn.175.1599712980461; Wed, 09 Sep 2020 21:43:00 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k4sm644888pjl.10.2020.09.09.21.42.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:42:59 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v3 5/7] adv_monitor: Handle D-Bus client ready events Date: Wed, 9 Sep 2020 21:41:32 -0700 Message-Id: <20200909214058.BlueZ.v3.5.Id5b1ced1530cb21559bc1dcf29d8764b0c7df825@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.09 / 15.00 / 15.00 X-Rspamd-Queue-Id: 54326408B3 X-Rspamd-UID: 2764c4 This adds a handler of client ready events. The handler replies to the RegisterMonitor() method call. The following tests were performed. - Call RegisterMonitor() and expect to receive a return. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 1a38e6994..23fdc9b14 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -124,9 +124,22 @@ static void app_disconnect_cb(DBusConnection *conn, void *user_data) app_destroy(app); } +/* Handles the ready signal of Adv Monitor app */ +static void app_ready_cb(GDBusClient *client, void *user_data) +{ + struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + + btd_info(adapter_id, "Path %s reserved for Adv Monitor app %s", + app->path, app->owner); + + app_reply_msg(app, dbus_message_new_method_return(app->reg)); +} + /* Creates an app object, initiates it and sets D-Bus event handlers */ static struct adv_monitor_app *app_create(DBusConnection *conn, - const char *sender, const char *path, + DBusMessage *msg, const char *sender, + const char *path, struct btd_adv_monitor_manager *manager) { struct adv_monitor_app *app; @@ -151,7 +164,9 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); - g_dbus_client_set_ready_watch(app->client, NULL, NULL); + g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); + + app->reg = dbus_message_ref(msg); return app; } @@ -196,7 +211,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, if (queue_find(manager->apps, app_match, &match)) return btd_error_already_exists(msg); - app = app_create(conn, match.owner, match.path, manager); + app = app_create(conn, msg, match.owner, match.path, manager); if (!app) { btd_error(manager->adapter_id, "Failed to reserve %s for Adv Monitor app %s", @@ -207,10 +222,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, queue_push_tail(manager->apps, app); - btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", - match.path, match.owner); - - return dbus_message_new_method_return(msg); + return NULL; } /* Handles UnregisterMonitor D-Bus call */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QMAWJfCuWV96qgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:43:28 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gDiyIfCuWV+U9QEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:43:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C058A4086C; Thu, 10 Sep 2020 06:43:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725971AbgIJEnU (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:43:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgIJEnR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:43:17 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0848C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:43:17 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id x18so302824pll.6 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Or/eiyaOvU3jAqUaMpITQ6DaEt5eU+RuO6myI++hZZ8=; b=jwnMghW77kRC3wX3IefUXdob3lnKT7a07fI4Tn1MnqFs1SxNkIQX/eAU3d7aQPhpLj SEDds5J/M71k9PZ2n8jRQ1SdyMgzYLEXCFwykZ5FN9jjHtMB6Eawh4T9a+dnZ5RR/095 4aANjdBT2ywXT0UnKYAhjN/Hs2FuCXC+bfmhw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Or/eiyaOvU3jAqUaMpITQ6DaEt5eU+RuO6myI++hZZ8=; b=E8d4EPjqJ0IURuwJHZ2RTp5RZWjpXq2pPxbOANuuFRGcAwKkISu5Lc9Le/D4efUUD+ 9xzl7hxlsDKzjVYrvgGpXenlNaxg+SDA64ifDJNNYnabbAw6cb3RolnUob1vBKkCexLc 9+heWN3jk6dJshFW7lT9+Rnpjwh9JWn+o+m8r0LygKr0p03gOl02q8npKnUD9iSE7F/+ XQp3n84m5u6P8uo+ud9Jsb4MDwd1zD0CfAG7VVTUN07/fhCVvMrcXW0/r1L0ok5aY+AH efO+T18CIz5Qk/zJda6VNZV+xkV63wpFcQu+Y/HSTCa5PnZDjETtT50CPRRVX843Ds7K KcCA== X-Gm-Message-State: AOAM530NqfUPIrSxh7Qf+ugbHjGyxD2mKGjAmlER9hvNhUBo3jvcpU2v RJdIxrhmE1cuBnOkFOjqcHgritlVOh5lwQ== X-Google-Smtp-Source: ABdhPJwEiOpEuSxlCcf3EjgBraGfOXZa/Jk3Anx1oeWC7FIg3WskHPoF+2U6sV1mmwIfUMENSy895A== X-Received: by 2002:a17:902:b686:: with SMTP id c6mr3795807pls.154.1599712995839; Wed, 09 Sep 2020 21:43:15 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k4sm644888pjl.10.2020.09.09.21.43.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:43:15 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v3 6/7] adv_monitor: Handle D-Bus proxy event of an ADV monitor Date: Wed, 9 Sep 2020 21:41:34 -0700 Message-Id: <20200909214058.BlueZ.v3.6.I47744c7eef31f44cf393dea2b3e437d7b41cef79@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.09 / 15.00 / 15.00 X-Rspamd-Queue-Id: C058A4086C X-Rspamd-UID: e56011 This adds two handlers, one for adding and one for removing, of D-Bus proxy events. The handler of property changes is set to NULL as intended, since for simplicity no further changes on monitor's properties would affect the ongoing monitoring. The following test steps were performed with bluetoothctl. - After registering the root path, expose two monitors and verify that the proxy added event are received. - Have two monitors added, unexpose the monitors, and verify that the proxy removed events are received for those two monitors. - Have two monitors added, unregister the monitors and verify that the proxy removed events are received for those two monitors. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v2) Changes in v2: - Use new0() instead of g_new0() - Remove the reset of monitor members - Use memcpy() instead of g_memmove() src/adv_monitor.c | 488 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 475 insertions(+), 13 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 23fdc9b14..b07d886bf 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -37,14 +37,23 @@ #include "dbus-common.h" #include "log.h" #include "src/error.h" +#include "src/shared/ad.h" #include "src/shared/mgmt.h" #include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" +#define ADV_MONITOR_UNSET_RSSI 127 /* dBm */ +#define ADV_MONITOR_MAX_RSSI 20 /* dBm */ +#define ADV_MONITOR_MIN_RSSI -127 /* dBm */ +#define ADV_MONITOR_UNSET_TIMER 0 /* second */ +#define ADV_MONITOR_MIN_TIMER 1 /* second */ +#define ADV_MONITOR_MAX_TIMER 300 /* second */ + struct btd_adv_monitor_manager { struct btd_adapter *adapter; struct mgmt *mgmt; @@ -66,6 +75,43 @@ struct adv_monitor_app { DBusMessage *reg; GDBusClient *client; + + struct queue *monitors; +}; + +enum monitor_type { + MONITOR_TYPE_NONE, + MONITOR_TYPE_OR_PATTERNS, +}; + +enum monitor_state { + MONITOR_STATE_NEW, /* New but not yet init'ed with actual values */ + MONITOR_STATE_FAILED, /* Failed to be init'ed */ + MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ + MONITOR_STATE_HONORED, /* Accepted by kernel */ +}; + +struct pattern { + uint8_t ad_type; + uint8_t offset; + uint8_t length; + uint8_t value[BT_AD_MAX_DATA_LEN]; +}; + +struct adv_monitor { + struct adv_monitor_app *app; + GDBusProxy *proxy; + char *path; + + enum monitor_state state; /* MONITOR_STATE_* */ + + int8_t high_rssi; /* high RSSI threshold */ + uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ + int8_t low_rssi; /* low RSSI threshold */ + uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ + + enum monitor_type type; /* MONITOR_TYPE_* */ + struct queue *patterns; }; struct app_match_data { @@ -73,6 +119,14 @@ struct app_match_data { const char *path; }; +const struct adv_monitor_type { + enum monitor_type type; + const char *name; +} supported_types[] = { + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, + { }, +}; + /* Replies to an app's D-Bus message and unref it */ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) { @@ -84,6 +138,48 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) app->reg = NULL; } +/* Frees a pattern */ +static void pattern_free(void *data) +{ + struct pattern *pattern = data; + + if (!pattern) + return; + + free(pattern); +} + +/* Frees a monitor object */ +static void monitor_free(void *data) +{ + struct adv_monitor *monitor = data; + + if (!monitor) + return; + + g_dbus_proxy_unref(monitor->proxy); + g_free(monitor->path); + + queue_destroy(monitor->patterns, pattern_free); + + free(monitor); +} + +/* Calls Release() method of the remote Adv Monitor */ +static void monitor_release(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + + if (!monitor) + return; + + DBG("Calling Release() on Adv Monitor of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "Release", NULL, NULL, NULL, + NULL); +} + /* Destroys an app object along with related D-Bus handlers */ static void app_destroy(void *data) { @@ -94,6 +190,9 @@ static void app_destroy(void *data) DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); + queue_foreach(app->monitors, monitor_release, NULL); + queue_destroy(app->monitors, monitor_free); + if (app->reg) { app_reply_msg(app, btd_error_failed(app->reg, "Adv Monitor app destroyed")); @@ -136,6 +235,372 @@ static void app_ready_cb(GDBusClient *client, void *user_data) app_reply_msg(app, dbus_message_new_method_return(app->reg)); } +/* Allocates an Adv Monitor */ +static struct adv_monitor *monitor_new(struct adv_monitor_app *app, + GDBusProxy *proxy) +{ + struct adv_monitor *monitor; + + if (!app || !proxy) + return NULL; + + monitor = new0(struct adv_monitor, 1); + if (!monitor) + return NULL; + + monitor->app = app; + monitor->proxy = g_dbus_proxy_ref(proxy); + monitor->path = g_strdup(g_dbus_proxy_get_path(proxy)); + + monitor->state = MONITOR_STATE_NEW; + + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + + monitor->type = MONITOR_TYPE_NONE; + monitor->patterns = NULL; + + return monitor; +} + +/* Matches a monitor based on its D-Bus path */ +static bool monitor_match(const void *a, const void *b) +{ + const GDBusProxy *proxy = b; + const struct adv_monitor *monitor = a; + + if (!proxy || !monitor) + return false; + + if (strcmp(g_dbus_proxy_get_path(proxy), monitor->path) != 0) + return false; + + return true; +} + +/* Retrieves Type from the remote Adv Monitor object, verifies the value and + * update the local Adv Monitor + */ +static bool parse_monitor_type(struct adv_monitor *monitor, const char *path) +{ + DBusMessageIter iter; + const struct adv_monitor_type *t; + const char *type_str; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (!g_dbus_proxy_get_property(monitor->proxy, "Type", &iter)) { + btd_error(adapter_id, "Failed to retrieve property Type from " + "the Adv Monitor at path %s", path); + return false; + } + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + goto failed; + + dbus_message_iter_get_basic(&iter, &type_str); + + for (t = supported_types; t->name; t++) { + if (strcmp(t->name, type_str) == 0) { + monitor->type = t->type; + return true; + } + } + +failed: + btd_error(adapter_id, "Invalid argument of property Type of the Adv " + "Monitor at path %s", path); + + return false; +} + +/* Retrieves RSSIThresholdsAndTimers from the remote Adv Monitor object, + * verifies the values and update the local Adv Monitor + */ +static bool parse_rssi_and_timeout(struct adv_monitor *monitor, + const char *path) +{ + DBusMessageIter prop_struct, iter; + int16_t h_rssi, l_rssi; + uint16_t h_rssi_timer, l_rssi_timer; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + /* Property RSSIThresholdsAndTimers is optional */ + if (!g_dbus_proxy_get_property(monitor->proxy, + "RSSIThresholdsAndTimers", + &prop_struct)) { + DBG("Adv Monitor at path %s provides no RSSI thresholds and " + "timeouts", path); + return true; + } + + if (dbus_message_iter_get_arg_type(&prop_struct) != DBUS_TYPE_STRUCT) + goto failed; + + dbus_message_iter_recurse(&prop_struct, &iter); + + /* Extract HighRSSIThreshold */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) + goto failed; + dbus_message_iter_get_basic(&iter, &h_rssi); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract HighRSSIThresholdTimer */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) + goto failed; + dbus_message_iter_get_basic(&iter, &h_rssi_timer); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract LowRSSIThreshold */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) + goto failed; + dbus_message_iter_get_basic(&iter, &l_rssi); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract LowRSSIThresholdTimer */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) + goto failed; + dbus_message_iter_get_basic(&iter, &l_rssi_timer); + + /* Verify the values of RSSIs and their timers. For simplicity, we + * enforce the all-or-none rule to these fields. In other words, either + * all are set to the unset values or all are set within valid ranges. + */ + if (h_rssi == ADV_MONITOR_UNSET_RSSI && + l_rssi == ADV_MONITOR_UNSET_RSSI && + h_rssi_timer == ADV_MONITOR_UNSET_TIMER && + l_rssi_timer == ADV_MONITOR_UNSET_TIMER) { + goto done; + } + + if (h_rssi < ADV_MONITOR_MIN_RSSI || h_rssi > ADV_MONITOR_MAX_RSSI || + l_rssi < ADV_MONITOR_MIN_RSSI || + l_rssi > ADV_MONITOR_MAX_RSSI || h_rssi <= l_rssi) { + goto failed; + } + + if (h_rssi_timer < ADV_MONITOR_MIN_TIMER || + h_rssi_timer > ADV_MONITOR_MAX_TIMER || + l_rssi_timer < ADV_MONITOR_MIN_TIMER || + l_rssi_timer > ADV_MONITOR_MAX_TIMER) { + goto failed; + } + + monitor->high_rssi = h_rssi; + monitor->low_rssi = l_rssi; + monitor->high_rssi_timeout = h_rssi_timer; + monitor->low_rssi_timeout = l_rssi_timer; + +done: + DBG("Adv Monitor at %s initiated with high RSSI threshold %d, high " + "RSSI threshold timeout %d, low RSSI threshold %d, low RSSI " + "threshold timeout %d", path, monitor->high_rssi, + monitor->high_rssi_timeout, monitor->low_rssi, + monitor->low_rssi_timeout); + + return true; + +failed: + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + + btd_error(adapter_id, "Invalid argument of property " + "RSSIThresholdsAndTimers of the Adv Monitor at path %s", + path); + + return false; +} + +/* Retrieves Patterns from the remote Adv Monitor object, verifies the values + * and update the local Adv Monitor + */ +static bool parse_patterns(struct adv_monitor *monitor, const char *path) +{ + DBusMessageIter array, array_iter; + uint16_t num_patterns = 0; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (!g_dbus_proxy_get_property(monitor->proxy, "Patterns", &array)) { + btd_error(adapter_id, "Failed to retrieve property Patterns " + "from the Adv Monitor at path %s", path); + return false; + } + + monitor->patterns = queue_new(); + + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY || + dbus_message_iter_get_element_type(&array) != + DBUS_TYPE_STRUCT) { + goto failed; + } + + dbus_message_iter_recurse(&array, &array_iter); + + while (dbus_message_iter_get_arg_type(&array_iter) == + DBUS_TYPE_STRUCT) { + int value_len; + uint8_t *value; + uint8_t offset, ad_type; + struct pattern *pattern; + DBusMessageIter struct_iter, value_iter; + + dbus_message_iter_recurse(&array_iter, &struct_iter); + + // Extract start position + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_BYTE) { + goto failed; + } + dbus_message_iter_get_basic(&struct_iter, &offset); + if (!dbus_message_iter_next(&struct_iter)) + goto failed; + + // Extract AD data type + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_BYTE) { + goto failed; + } + dbus_message_iter_get_basic(&struct_iter, &ad_type); + if (!dbus_message_iter_next(&struct_iter)) + goto failed; + + // Extract value of a pattern + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_ARRAY) { + goto failed; + } + dbus_message_iter_recurse(&struct_iter, &value_iter); + dbus_message_iter_get_fixed_array(&value_iter, &value, + &value_len); + + // Verify the values + if (offset > BT_AD_MAX_DATA_LEN - 1) + goto failed; + + if (ad_type > BT_AD_3D_INFO_DATA && + ad_type != BT_AD_MANUFACTURER_DATA + || ad_type < BT_AD_FLAGS) { + goto failed; + } + + if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) + goto failed; + + pattern = new0(struct pattern, 1); + if (!pattern) + goto failed; + + pattern->ad_type = ad_type; + pattern->offset = offset; + pattern->length = value_len; + memcpy(pattern->value, value, pattern->length); + + queue_push_tail(monitor->patterns, pattern); + + dbus_message_iter_next(&array_iter); + } + + /* There must be at least one pattern. */ + if (queue_isempty(monitor->patterns)) + goto failed; + + return true; + +failed: + queue_destroy(monitor->patterns, pattern_free); + monitor->patterns = NULL; + + btd_error(adapter_id, "Invalid argument of property Patterns of the " + "Adv Monitor at path %s", path); + + return false; +} + +/* Processes the content of the remote Adv Monitor */ +static bool monitor_process(struct adv_monitor *monitor, + struct adv_monitor_app *app) +{ + const char *path = g_dbus_proxy_get_path(monitor->proxy); + + monitor->state = MONITOR_STATE_FAILED; + + if (!parse_monitor_type(monitor, path)) + goto done; + + if (!parse_rssi_and_timeout(monitor, path)) + goto done; + + if (monitor->type == MONITOR_TYPE_OR_PATTERNS && + parse_patterns(monitor, path)) { + monitor->state = MONITOR_STATE_INITED; + } + +done: + return monitor->state != MONITOR_STATE_FAILED; +} + +/* Handles an Adv Monitor D-Bus proxy added event */ +static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) +{ + struct adv_monitor *monitor; + struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + const char *path = g_dbus_proxy_get_path(proxy); + const char *iface = g_dbus_proxy_get_interface(proxy); + + if (strcmp(iface, ADV_MONITOR_INTERFACE) != 0 || + !g_str_has_prefix(path, app->path)) { + return; + } + + if (queue_find(app->monitors, monitor_match, proxy)) { + btd_error(adapter_id, "Adv Monitor proxy already exists with " + "path %s", path); + return; + } + + monitor = monitor_new(app, proxy); + if (!monitor) { + btd_error(adapter_id, "Failed to allocate an Adv Monitor for " + "the object at %s", path); + return; + } + + if (!monitor_process(monitor, app)) { + monitor_release(monitor, NULL); + monitor_free(monitor); + DBG("Adv Monitor at path %s released due to invalid content", + path); + return; + } + + queue_push_tail(app->monitors, monitor); + + DBG("Adv Monitor allocated for the object at path %s", path); +} + +/* Handles the removal of an Adv Monitor D-Bus proxy */ +static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) +{ + struct adv_monitor *monitor; + struct adv_monitor_app *app = user_data; + + monitor = queue_remove_if(app->monitors, monitor_match, proxy); + if (monitor) { + DBG("Adv Monitor removed for the object at path %s", + monitor->path); + + /* The object was gone, so we don't need to call Release() */ + monitor_free(monitor); + } +} + /* Creates an app object, initiates it and sets D-Bus event handlers */ static struct adv_monitor_app *app_create(DBusConnection *conn, DBusMessage *msg, const char *sender, @@ -162,8 +627,17 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, return NULL; } + app->monitors = queue_new(); + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); - g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); + + /* Note that any property changes on a monitor object would not affect + * the content of the corresponding monitor. + */ + g_dbus_client_set_proxy_handlers(app->client, monitor_proxy_added_cb, + monitor_proxy_removed_cb, NULL, + app); + g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); app->reg = dbus_message_ref(msg); @@ -270,18 +744,6 @@ static const GDBusMethodTable adv_monitor_methods[] = { { } }; -enum monitor_type { - MONITOR_TYPE_OR_PATTERNS, -}; - -const struct adv_monitor_type { - enum monitor_type type; - const char *name; -} supported_types[] = { - { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, - { }, -}; - /* Gets SupportedMonitorTypes property */ static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, DBusMessageIter *iter, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uKkzAQOvWV96qgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:43:47 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CDQgOgKvWV+K8AAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:43:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1F67740961; Thu, 10 Sep 2020 06:43:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726160AbgIJEnj (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgIJEng (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:43:36 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8E06C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:43:36 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id w186so3565435pgb.8 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OwcQPbWK9wBBKShQmm51i7xxWQDNt4zUBesrzpNnDCQ=; b=c3huFSrX3k9Le+Pyy5XkkbQf8S2ASR7MD0v/8JgLC9VI9QhJNqDqbIlGYPWuBGw8O+ T5GTSx2heO1crmv89dfkNtPC7Zzjdhnvaq5e4YPJTh6AUAlQMcDIngiMmeO0SqYJsMot eyOwblTCkPjDR3vXBEz0slLWHljKqjTmNOfs8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OwcQPbWK9wBBKShQmm51i7xxWQDNt4zUBesrzpNnDCQ=; b=IXEsqm1vdKAOWOYrNV2+RMhxheuJLfDIKnQ8IQSWD+vBoO9D7b/yx8OtieHxt59pkD qybiiPj4q1fFu9VyPcm8Xs15rwCtK5JDxTHWszehBUdc8MYUhMqVuSfkpX40RTmf/5Id AE0GCClXNHeT+tn5KDatQdJP4vKiQHtjXVTAWtlFRnU9ykE5hy3Oj6K7PqUR+NwCr91H b7n90OIRvHtlj9y8ezsClO2+50hvWZPvqWqgLuhLf/jBCdjGUlGOmmZOqkBRsRU3n7aX iC3iaYf5XnM7Nil/G8QBgik1fF/BxiMDr54N1t2g8HFU7Z2uwwrOLSjT1r+5PKyyofpY T9xA== X-Gm-Message-State: AOAM533I4K+CHdzWr/xj2qstdyLa07P6BcpydctpRI5jgP7VZg43WAKt hiEBHemhIItELlEyEnd7uYP2NB8GfYE4qw== X-Google-Smtp-Source: ABdhPJzNj2lgZ3l2qbp/gAEnsjhR9qcwx/NxqS96KXkjNxtf3AWCbebwcXy+F+vQ6BAbT13cFC3ssw== X-Received: by 2002:a62:1c4a:0:b029:13e:d13d:a136 with SMTP id c71-20020a621c4a0000b029013ed13da136mr3669674pfc.30.1599713015843; Wed, 09 Sep 2020 21:43:35 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k4sm644888pjl.10.2020.09.09.21.43.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2020 21:43:34 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v3 7/7] doc: Update Advertisement Monitor API description Date: Wed, 9 Sep 2020 21:41:36 -0700 Message-Id: <20200909214058.BlueZ.v3.7.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.75 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1F67740961 X-Rspamd-UID: 25f25b This modifies the following description to Advertisement Monitor API. - Add org.bluez.Error.Failed to RegisterMonitor() method. - Add more description about the usage of RegisterMonitor() and UnregisterMonitor() methods. - Add description about the ranges for the fields in property RSSIThresholdsAndTimers. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) doc/advertisement-monitor-api.txt | 34 +++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index 74adbfae9..e09b6fd25 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -49,7 +49,7 @@ Properties string Type [read-only] org.bluez.AdvertisementMonitorManager1 for the available options. - (Int16, Uint16, Int16, Uint16) RSSIThreshholdsAndTimers [read-only, optional] + (Int16, Uint16, Int16, Uint16) RSSIThresholdsAndTimers [read-only, optional] This contains HighRSSIThreshold, HighRSSIThresholdTimer, LowRSSIThreshold, LowRSSIThresholdTimer in order. The @@ -66,7 +66,11 @@ Properties string Type [read-only] RSSIs of the received advertisement(s) during LowRSSIThresholdTimer do not reach LowRSSIThreshold. - array{(uint8, uint8, string)} Patterns [read-only, optional] + The valid range of a RSSI is -127 to +20 dBm while 127 + dBm indicates unset. The valid range of a timer is 1 to + 300 seconds while 0 indicates unset. + + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] If Type is set to 0x01, this must exist and has at least one entry in the array. @@ -80,8 +84,9 @@ Properties string Type [read-only] See https://www.bluetooth.com/specifications/ assigned-numbers/generic-access-profile/ for the possible allowed value. - string content_of_pattern - This is the value of the pattern. + array{byte} content_of_pattern + This is the value of the pattern. The maximum + length of the bytes is 31. Advertisement Monitor Manager hierarchy ======================================= @@ -91,20 +96,31 @@ Object path /org/bluez/{hci0,hci1,...} Methods void RegisterMonitor(object application) - This registers a hierarchy of advertisement monitors. + This registers the root path of a hierarchy of + advertisement monitors. The application object path together with the D-Bus system bus connection ID define the identification of the application registering advertisement monitors. + Once a root path is registered by a client via this + method, the client can freely expose/unexpose + advertisement monitors without re-registering the root + path again. After use, the client should call + UnregisterMonitor() method to invalidate the + advertisement monitors. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.AlreadyExists + org.bluez.Error.Failed void UnregisterMonitor(object application) - This unregisters advertisement monitors that have been - previously registered. The object path parameter must - match the same value that has been used on - registration. + This unregisters a hierarchy of advertisement monitors + that has been previously registered. The object path + parameter must match the same value that has been used + on registration. Upon unregistration, the advertisement + monitor(s) should expect to receive Release() method as + the signal that the advertisement monitor(s) has been + deactivated. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.DoesNotExist -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kG+wE1WxWV8RtwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:53:41 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id KOiIEVWxWV9v+AAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:53:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5CA4D400F9; Thu, 10 Sep 2020 06:53:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725981AbgIJExd (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:53:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgIJExa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:53:30 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57ACDC061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:53:30 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id a15so6475557ljk.2 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fpw2FWDzfPkYdf9A6lJBI6poyNed/Ldpp5XTVu6JlO8=; b=KQ8p7VH9tbAoZLKJ7vCx/MRbXvzSE2r5fS50ASi1jmjG4u/eITqhEmneDONvHLXwJ3 FwjLtA3HwdJjUTN8AThtz+4Cb4ZpuZIWCXfjjzAA0o430x8v5R9U3xN6zd4fj3flne1N EQq1jQEfEVsw1qfrl++dqXHbQwcV+8VkxP+hs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fpw2FWDzfPkYdf9A6lJBI6poyNed/Ldpp5XTVu6JlO8=; b=kT2XJ2jmftpnFfyvC99iQAILwe8hPLIgMEvR4nbXs8Zwt9gYTH+5qAoGQ3Yz9gY1wx TW3WS0jrZjuSagLmg2f+O0G01VSI33YQThTnx7hwEc25NQIZr84bcyq1qigFBlXYUVpq cHkBm2bpyF1t6F44oMb4V0uGGXJuAOf7IWp8duO1hXA9BM23mZ/HoWxK8l3szHYhgtRq TXG6J9OVTVBN7VWOUwr7KCWe2XoxRhOqjM7glGeoNsqPb8D7vXw8xYiuK46uU769D3BZ peLP9u+C9rQJLo8jYMBe3RYyrXmyUlj5XwbtG5bs/ynjF2AowwlYjextjDD7wgYRCw/a 5wvA== X-Gm-Message-State: AOAM532iF7xHtWDzUAg/DGtKkFzUGMFl81BgRgGzd4Yjv7fywJLdYZZd JVBCW0rxysEpcPJmij0oRtfcAkqunUflwXqU2CTW7Q== X-Google-Smtp-Source: ABdhPJx8eN+/6bWQE1W+iAAnNP3mVVebokcHBlwPT/N9EuUI66/V650S2mzhSVXcFxw1CAADF92XdzbEEh2Gvw6J+yU= X-Received: by 2002:a2e:3615:: with SMTP id d21mr3622385lja.333.1599713607720; Wed, 09 Sep 2020 21:53:27 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <20200818152612.BlueZ.v1.7.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> <CABBYNZLCZ9FCEH=Z3sHzsg-jw_4CvnbMxBNbQem=x0JE_+y7NA@mail.gmail.com> In-Reply-To: <CABBYNZLCZ9FCEH=Z3sHzsg-jw_4CvnbMxBNbQem=x0JE_+y7NA@mail.gmail.com> From: Miao-chen Chou <mcchou@chromium.org> Date: Wed, 9 Sep 2020 21:53:16 -0700 Message-ID: <CABmPvSEMoJEfpFPgnytgr+ig6TquAtg2kN+WpvAJ1oX6jUs6+Q@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 7/7] doc/advertisement-monitor-api: Update Advertisement Monitor API description To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5CA4D400F9 X-Rspamd-UID: 267321 Hi Luiz, On Tue, Sep 8, 2020 at 10:40 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Miao, > > On Tue, Aug 18, 2020 at 3:34 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > This modifies the following description to Advertisement Monitor API. > > - Add org.bluez.Error.Failed to RegisterMonitor() method. > > - Add more description about the usage of RegisterMonitor() and > > UnregisterMonitor() methods. > > - Add description about the ranges for the fields in property > > RSSIThresholdsAndTimers. > > > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > > --- > > > > doc/advertisement-monitor-api.txt | 34 +++++++++++++++++++++++-------- > > 1 file changed, 25 insertions(+), 9 deletions(-) > > > > diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt > > index 74adbfae9..e09b6fd25 100644 > > --- a/doc/advertisement-monitor-api.txt > > +++ b/doc/advertisement-monitor-api.txt > > @@ -49,7 +49,7 @@ Properties string Type [read-only] > > org.bluez.AdvertisementMonitorManager1 for the available > > options. > > > > - (Int16, Uint16, Int16, Uint16) RSSIThreshholdsAndTimers [read-only, optional] > > + (Int16, Uint16, Int16, Uint16) RSSIThresholdsAndTimers [read-only, optional] > > > > This contains HighRSSIThreshold, HighRSSIThresholdTimer, > > LowRSSIThreshold, LowRSSIThresholdTimer in order. The > > @@ -66,7 +66,11 @@ Properties string Type [read-only] > > RSSIs of the received advertisement(s) during > > LowRSSIThresholdTimer do not reach LowRSSIThreshold. > > > > - array{(uint8, uint8, string)} Patterns [read-only, optional] > > + The valid range of a RSSI is -127 to +20 dBm while 127 > > + dBm indicates unset. The valid range of a timer is 1 to > > + 300 seconds while 0 indicates unset. > > + > > + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] > > > > If Type is set to 0x01, this must exist and has at least > > one entry in the array. > > @@ -80,8 +84,9 @@ Properties string Type [read-only] > > See https://www.bluetooth.com/specifications/ > > assigned-numbers/generic-access-profile/ for > > the possible allowed value. > > - string content_of_pattern > > - This is the value of the pattern. > > + array{byte} content_of_pattern > > + This is the value of the pattern. The maximum > > + length of the bytes is 31. > > > > Advertisement Monitor Manager hierarchy > > ======================================= > > @@ -91,20 +96,31 @@ Object path /org/bluez/{hci0,hci1,...} > > > > Methods void RegisterMonitor(object application) > > > > - This registers a hierarchy of advertisement monitors. > > + This registers the root path of a hierarchy of > > + advertisement monitors. > > The application object path together with the D-Bus > > system bus connection ID define the identification of > > the application registering advertisement monitors. > > + Once a root path is registered by a client via this > > + method, the client can freely expose/unexpose > > + advertisement monitors without re-registering the root > > + path again. After use, the client should call > > + UnregisterMonitor() method to invalidate the > > + advertisement monitors. > > > > Possible errors: org.bluez.Error.InvalidArguments > > org.bluez.Error.AlreadyExists > > + org.bluez.Error.Failed > > > > void UnregisterMonitor(object application) > > > > - This unregisters advertisement monitors that have been > > - previously registered. The object path parameter must > > - match the same value that has been used on > > - registration. > > + This unregisters a hierarchy of advertisement monitors > > + that has been previously registered. The object path > > + parameter must match the same value that has been used > > + on registration. Upon unregistration, the advertisement > > + monitor(s) should expect to receive Release() method as > > + the signal that the advertisement monitor(s) has been > > + deactivated. > > > > Possible errors: org.bluez.Error.InvalidArguments > > org.bluez.Error.DoesNotExist > > -- > > 2.26.2 > > These are still experimental so you will need to use EXPERIMENTAL > version when declaring the methods/properties so it only gets enabled > when the experimental flag is passed to bluetoothd. g_dbus_register_interface() does not allow to have all methods and properties marked as experimental, so at least SupportedFeatures should be non-experimental. > > > -- > Luiz Augusto von Dentz Thanks, Miao Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4EH9Ooa0WV+AvgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 07:07:18 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id AMduOIa0WV8P/gAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 07:07:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7856D40975; Thu, 10 Sep 2020 07:07:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726080AbgIJFHD (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 01:07:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:34680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbgIJFHC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 01:07:02 -0400 Received: from sol.localdomain (172-10-235-113.lightspeed.sntcca.sbcglobal.net [172.10.235.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D4780207EA; Thu, 10 Sep 2020 05:07:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599714421; bh=Lbn9xs8qkCiA5rfVxd87HIU11Jf2P/zukvdmNIBKwyI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=o1BMPBgqOfPecIA0rAE70qWdPtpP8hT+87oOV2DoyELHE4VoyuGG5Vo6u54f5uUfa EX1Rk+GohPhVUaTxSJZoreGFkuRW2w9da2ZKQggM6YptawuzWTjNjYCr8ByBTz9DHf FQyaSUL31uH7WE9aZ1wQ6HmaKBEO3pKfyjYUJUlg= Date: Wed, 9 Sep 2020 22:06:59 -0700 From: Eric Biggers <ebiggers@kernel.org> To: Anmol Karn <anmol.karan123@gmail.com> Cc: marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Subject: Re: [PATCH] net: bluetooth: Fix null pointer dereference in hci_event_packet() Message-ID: <20200910050659.GD828@sol.localdomain> References: <20200910043424.19894-1-anmol.karan123@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200910043424.19894-1-anmol.karan123@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -7.19 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7856D40975 X-Rspamd-UID: d71e1b On Thu, Sep 10, 2020 at 10:04:24AM +0530, Anmol Karn wrote: > Prevent hci_phy_link_complete_evt() from dereferencing 'hcon->amp_mgr' > as NULL. Fix it by adding pointer check for it. > > Reported-and-tested-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com > Link: https://syzkaller.appspot.com/bug?extid=0bef568258653cff272f > Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> > --- > net/bluetooth/hci_event.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 4b7fc430793c..871e16804433 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -4936,6 +4936,11 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > return; > } > > + if (IS_ERR_OR_NULL(hcon->amp_mgr)) { > + hci_dev_unlock(hdev); > + return; > + } > + In patches that fix a NULL pointer dereference, please include a brief explanation of why the pointer can be NULL, including what it means semantically; and why the proposed change is the best fix for the problem. Also, why IS_ERR_OR_NULL()? - Eric Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ALdgH4XBWV99BwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 08:02:45 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id CMNUHIXBWV+46QAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 08:02:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7E32640873; Thu, 10 Sep 2020 08:02:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726816AbgIJGCZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 02:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725885AbgIJGCS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 02:02:18 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EBC2C061573; Wed, 9 Sep 2020 23:02:18 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id s2so2502090pjr.4; Wed, 09 Sep 2020 23:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1p1Yvpbl2hUtzS0Tbph8bRvhvEzrq/brMLlo+7qJTmo=; b=g88HRhuzR/tEUwOcTqCszmjAXNiJCm0J1vOe3sumDx3uHfUPjReXHmKT0PJpUGjbxz bCaYFJiGreJYRkyHL7n7izvSJPMLq9/tKv/Fqq09cLPKqrLyLl3sB3HdaMyemi2IV/Gy T40tnjziOVI/j7zTSWEHdgu0WxCDRfgpoyiImuf2W6fpRSq+HdIhR6CFtHVEJrC5ybbQ hyc2e9t+l638olaiw54lHUFjKF2O9wVjDtN5dn01LQ9PlWyOlQDEVgbty1smMbVcSgPk Fnc/gjwFzfa22dmde9gU0EoLkuvAOMEJmxubwlLBrgWXojL6oNGAZnDlepN0gjKmQwbe I7Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1p1Yvpbl2hUtzS0Tbph8bRvhvEzrq/brMLlo+7qJTmo=; b=N65G8WEoUZD/9u96DjWvoPsBXiOpb+uxl838TbCOWWQK4+jwzXOtSLsgZQpjMOHiKN FjpBJNU6vYb78/DAXLJyRxRU5eak4fSY0n5Irre0conrtxSQ+EbK3R1HeBDR89fyNjMg ijzdjk0lVLJFXizDgQgVVTnV4ejaNETzB8F9Drwvrxi+TqNh6MPMGP/1J976I+oNlOFR WYqXiatwHqsqqdtCYg4wL/IWHKcwYrG5ybqwuITOE0/O+AYYm5jkfRZyAjLEU5HqCsan GJQ8xBblAozAP4CLl99xZzesCTsHHH52LiBn1BINjgNQoH9IisS09wkaXgt24TV+RQOU dq2Q== X-Gm-Message-State: AOAM532O6UJoEKVdtlk3q7FdHciDcTZABK8qG9X968ezb8z+MFbMhFK1 ejAR+gOnyUShBQqVgo63Gqw= X-Google-Smtp-Source: ABdhPJzZ/CS0vTHPATpbUVEI5Yr2tYgH4VeZ6BMrwtFl2Cq9kNkZf1EdtQhp3tBvECFs97TwVRV6BQ== X-Received: by 2002:a17:90a:bc8d:: with SMTP id x13mr3938065pjr.229.1599717737265; Wed, 09 Sep 2020 23:02:17 -0700 (PDT) Received: from Thinkpad ([45.118.165.156]) by smtp.gmail.com with ESMTPSA id l23sm3831070pgt.16.2020.09.09.23.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 23:02:16 -0700 (PDT) Date: Thu, 10 Sep 2020 11:32:08 +0530 From: Anmol Karn <anmol.karan123@gmail.com> To: Eric Biggers <ebiggers@kernel.org> Cc: marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Subject: Re: [PATCH] net: bluetooth: Fix null pointer dereference in hci_event_packet() Message-ID: <20200910060208.GA22165@Thinkpad> References: <20200910043424.19894-1-anmol.karan123@gmail.com> <20200910050659.GD828@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200910050659.GD828@sol.localdomain> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.84 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7E32640873 X-Rspamd-UID: 1e3a2a On Wed, Sep 09, 2020 at 10:06:59PM -0700, Eric Biggers wrote: > On Thu, Sep 10, 2020 at 10:04:24AM +0530, Anmol Karn wrote: > > Prevent hci_phy_link_complete_evt() from dereferencing 'hcon->amp_mgr' > > as NULL. Fix it by adding pointer check for it. > > > > Reported-and-tested-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com > > Link: https://syzkaller.appspot.com/bug?extid=0bef568258653cff272f > > Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> > > --- > > net/bluetooth/hci_event.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > index 4b7fc430793c..871e16804433 100644 > > --- a/net/bluetooth/hci_event.c > > +++ b/net/bluetooth/hci_event.c > > @@ -4936,6 +4936,11 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > > return; > > } > > > > + if (IS_ERR_OR_NULL(hcon->amp_mgr)) { > > + hci_dev_unlock(hdev); > > + return; > > + } > > + > Hello Sir, > In patches that fix a NULL pointer dereference, please include a brief > explanation of why the pointer can be NULL, including what it means > semantically; and why the proposed change is the best fix for the problem. > I will surely add more explaination in v2. > Also, why IS_ERR_OR_NULL()? > I used IS_ERR_OR_NULL() to check if the 'hcon->amp_mgr' is a valid pointer or not, and unregister the 'hcon' and signal error, but will make changes in v2 with only NULL check included, if you think it's incorrect to use IS_ERR check here along with NULL. Thanks, Anmol Karn Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EC3+FO3BWV8Y9AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 08:04:29 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iNvGEe3BWV/tWQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 08:04:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A7CD140980; Thu, 10 Sep 2020 08:04:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725885AbgIJGEP (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 02:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725981AbgIJGEL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 02:04:11 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B349C061756 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 23:04:10 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id f2so1640529pgd.3 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 23:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qmrRE/cAzT6Pa5rmjyA2UxqDEd0+8qsdczMgIJaVlsU=; b=LEZWoPjI4LA8Dv/MZRYuK82FFHbjI9L98lH14pFMFTBbD0RoCkuSYaZTurrF3ogbrJ IduTS4B46X3HuwdMjZzBoVS79Orz/g76vTulGQrv4p7RvV6YxqthIMO8H0BjwcGUkkUC /fbvwqhXI6uoZMEvZvmLXSebliXRf50ScUhn8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qmrRE/cAzT6Pa5rmjyA2UxqDEd0+8qsdczMgIJaVlsU=; b=X2z5J27p5A03LlUGizZbUiS43qkyB9QGqH7bYL2dv+qelnrKB60haWWBSUrmK/7SBg PIbKVXsaLw1Fu1lrhZAb8kHUQMFNJWFggIObJIAz7Y5CpDMSyxr6THAtsI4TRF2e/ysr Gv7x5htYEmifzMcNiivJ/uOUEZb8LqBGPj4J4CKuXNZMYkg9Zk3l1jFOOuw5xoYMIUJt qH63rnBzmm+4eG6r7xN14kwQ5S9sJkH3/6horNcOj8894n/k/spLIp1PbKZqTS1qbkwz U7c3YiIiKwcBTirElX3cqqZtn2rOoHk2JfFIdEw+l4NIuGExoa4RwkCARCoptIzgO2QF Vx9g== X-Gm-Message-State: AOAM532Y3Lr8fDZSnC4p8706CKwtdVqeTdfopTAyCR1my/QbC/sJO2X1 GhevwytmmjdmWARVDmppbTqHwt7sc9zOxRbV X-Google-Smtp-Source: ABdhPJzGYrjJX62SBHU9URsZeDFcnsOS7Ix3hXjVRHeu8ZxSdmNkacTKI+nxmWp+LcsGGhb1Usfuew== X-Received: by 2002:aa7:9494:: with SMTP id z20mr3939184pfk.144.1599717849282; Wed, 09 Sep 2020 23:04:09 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id j14sm893236pjz.21.2020.09.09.23.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 23:04:08 -0700 (PDT) From: Joseph Hwang <josephsih@chromium.org> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Joseph Hwang <josephsih@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 0/2] To support the HFP WBS, a chip vendor may choose a particular Date: Thu, 10 Sep 2020 14:04:00 +0800 Message-Id: <20200910060403.144524-1-josephsih@chromium.org> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.73 / 15.00 / 15.00 X-Rspamd-Queue-Id: A7CD140980 X-Rspamd-UID: 4e336c USB alternate seeting of which the packet size is distinct. The patches are to expose the packet size to user space so that the user space does not need to hard code those values. We have verified this patch on Chromebooks which use - Realtek 8822CE controller with USB alt setting 1 - Intel controller with USB alt setting 6 Our user space audio server, cras, can get the correct packet length from the socket option. Changes in v3: - Set hdev->sco_mtu to rp->sco_mtu if the latter is smaller. - Fixed the commit message. Changes in v2: - Used sco_mtu instead of a new sco_pkt_len member in hdev. - Do not overwrite hdev->sco_mtu in hci_cc_read_buffer_size if it has been set in the USB interface. - Used BT_SNDMTU/BT_RCVMTU instead of creating a new opt name. - Used the existing conn->mtu instead of creating a new member in struct sco_pinfo. - Noted that the old SCO_OPTIONS in sco_sock_getsockopt_old() would just work as it uses sco_pi(sk)->conn->mtu. Joseph Hwang (2): Bluetooth: btusb: define HCI packet sizes of USB Alts Bluetooth: sco: new getsockopt options BT_SNDMTU/BT_RCVMTU drivers/bluetooth/btusb.c | 45 +++++++++++++++++++++++++++++---------- net/bluetooth/hci_event.c | 14 +++++++++++- net/bluetooth/sco.c | 6 ++++++ 3 files changed, 53 insertions(+), 12 deletions(-) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qCTEIwrCWV8Y9AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 08:04:58 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ePXzIArCWV9bMQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 08:04:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5DF394097A; Thu, 10 Sep 2020 08:04:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726932AbgIJGEv (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 02:04:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726746AbgIJGE2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 02:04:28 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE85AC061795 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 23:04:19 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id 34so3639871pgo.13 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 23:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uk2jhSlsyW0uEicGAMvJSDRERxJgCUtBRzjLszfNMEM=; b=ogGgIj8KanMA8t16REBPMJqN3hNG+13+3sebCcyTt+DetY1CQsREBYjwwl9/aoCJ+B rLLdYxsaBCtFoV5xtQAQvk0YgtUunOYQlh/9uZi2h4aS7VXxHS40Miif6HgcVgncgW09 Ffl52LwJX72tEZzV/pKa9OP6Yp5WLTcvef/ds= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uk2jhSlsyW0uEicGAMvJSDRERxJgCUtBRzjLszfNMEM=; b=RTIuiUpdqCJcHJCRNddHzF6z6ZfXmvEe2bWZ8K6rOnP7yHdNb0rCRwAmRD+oVV2UXn eibtDBNE6mj4HPIOjQNLP//uOhOZGS5ElO2VJVx3rAfGYHAH+kEGV3xMpifTkvm/zKt7 z9wWvTSH1vkGlGvaZL1bpC26Tr+HxN+LEpnevrb1scP7xwDtuLQUbf5U5hQgOCaYLIlB nmvMHW3w3WuMfKFZesnQ3vxe2b7ATIqQI+z0ay7/JkJjPpvlv9Ip+YHZnxotretTFHZC iH/mdpW+RH3N/HePBKUnlTpOxtKQzGhAL6Tajyocq4jx5l23t9y+8pS7fjznDEgZT/Z6 qIKw== X-Gm-Message-State: AOAM533BzxMpiM2j9M8pYjg/V0bqEV7SzYv8Yijyeb5dbAyyFOx4wx8V SfzhyTwFgCa3eNOTOYdPQXHSTv0/iZslhXce X-Google-Smtp-Source: ABdhPJwe0+uwzDRgDCuX9b8VJcjpJiSEscjJ/j45LhdykkKdSMSbbDczNEseCea386az0fz/SY3oCw== X-Received: by 2002:aa7:9edb:0:b029:13e:d13d:a059 with SMTP id r27-20020aa79edb0000b029013ed13da059mr4077835pfq.31.1599717858904; Wed, 09 Sep 2020 23:04:18 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id j14sm893236pjz.21.2020.09.09.23.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 23:04:18 -0700 (PDT) From: Joseph Hwang <josephsih@chromium.org> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Joseph Hwang <josephsih@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 2/2] Bluetooth: sco: new getsockopt options BT_SNDMTU/BT_RCVMTU Date: Thu, 10 Sep 2020 14:04:02 +0800 Message-Id: <20200910140342.v3.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200910060403.144524-1-josephsih@chromium.org> References: <20200910060403.144524-1-josephsih@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.65 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5DF394097A X-Rspamd-UID: 7a6468 This patch defines new getsockopt options BT_SNDMTU/BT_RCVMTU for SCO socket to be compatible with other bluetooth sockets. These new options return the same value as option SCO_OPTIONS which is already present on existing kernels. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Signed-off-by: Joseph Hwang <josephsih@chromium.org> --- Changes in v3: - Fixed the commit message. Changes in v2: - Used BT_SNDMTU/BT_RCVMTU instead of creating a new opt name. - Used the existing conn->mtu instead of creating a new member in struct sco_pinfo. - Noted that the old SCO_OPTIONS in sco_sock_getsockopt_old() would just work as it uses sco_pi(sk)->conn->mtu. net/bluetooth/sco.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index dcf7f96ff417e6..79ffcdef0b7ad5 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -1001,6 +1001,12 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, err = -EFAULT; break; + case BT_SNDMTU: + case BT_RCVMTU: + if (put_user(sco_pi(sk)->conn->mtu, (u32 __user *)optval)) + err = -EFAULT; + break; + default: err = -ENOPROTOOPT; break; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sMzZKyDCWV+//QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 08:05:20 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id mFnwJyDCWV/hzQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 08:05:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EEEEA4097A; Thu, 10 Sep 2020 08:05:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728936AbgIJGFM (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 02:05:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbgIJGEP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 02:04:15 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13B2FC061757 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 23:04:15 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id u3so2511270pjr.3 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 23:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vZWQw2MqezQSjPCg0Dku6/BdcAwBC3dDRSyH4V8pXAg=; b=SQZNXcqU0ZuZn0AJkjqfkWCEklXGWMXhKkzRoLq85tYAhNvLeQZSzS+KpCuZ4KpW72 wwTVKXiK5Htjys+hkHZ4/YNhZ+CMji2am9sulpMpqCVjWq14byniLkA0VLeLPIRZJUKi 4m85yH8ncqbDTCRcwW9Wx+9C7mtjIdGEjrx54= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vZWQw2MqezQSjPCg0Dku6/BdcAwBC3dDRSyH4V8pXAg=; b=T4t36uruVQ0ZCRnhc3bXqfpnoUOE6p0KJOEMeEbOuEp63RhX75F1wDH+EyJ19rpUwl hsGmBKIXWAfmnL05km4l+7eeGu7mE/OV0lnj4Yb4U1wLG+E9snydpGBAxMVIZJ3weGUB UXPMS6qTaUx4HnGTRBOSNa/YqycSbhVbt7naQzPHxdqvM9S5Z7QALSlQ0WZQaEOmtgvo mTrkXgN+c0TxcqSltvMDDdDA6pDMT9LSvWuLImiQFGiaYI32rZ4JTMK1djikBkERNE6H 0GNwcGdifBJgp60yNHtYZZVi8lZez48I5siXNRBPSOfFF2h92iYwiKvcR8v+gsc7EK+/ /oQA== X-Gm-Message-State: AOAM532TGyOg7cQ1QyQsq0ua3E8frEKftu7lPHhHAFqawrEDD+pZxRxK SBNp47Ub3w3rDb08JVhk9LA6dlgLjRmPbhz7 X-Google-Smtp-Source: ABdhPJyxgMEM0piakxuNRBDbU1TVf/izPnfSQ3fQIf5qgxZExhxTcQhq8L6R1tcELWl8gyxoUEj3Dg== X-Received: by 2002:a17:90b:3105:: with SMTP id gc5mr3924629pjb.225.1599717854210; Wed, 09 Sep 2020 23:04:14 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id j14sm893236pjz.21.2020.09.09.23.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 23:04:13 -0700 (PDT) From: Joseph Hwang <josephsih@chromium.org> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Joseph Hwang <josephsih@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 1/2] Bluetooth: btusb: define HCI packet sizes of USB Alts Date: Thu, 10 Sep 2020 14:04:01 +0800 Message-Id: <20200910140342.v3.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200910060403.144524-1-josephsih@chromium.org> References: <20200910060403.144524-1-josephsih@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: EEEEA4097A X-Rspamd-UID: 16b87c It is desirable to define the HCI packet payload sizes of USB alternate settings so that they can be exposed to user space. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Signed-off-by: Joseph Hwang <josephsih@chromium.org> --- Changes in v3: - Set hdev->sco_mtu to rp->sco_mtu if the latter is smaller. Changes in v2: - Used sco_mtu instead of a new sco_pkt_len member in hdev. - Do not overwrite hdev->sco_mtu in hci_cc_read_buffer_size if it has been set in the USB interface. drivers/bluetooth/btusb.c | 45 +++++++++++++++++++++++++++++---------- net/bluetooth/hci_event.c | 14 +++++++++++- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index fe80588c7bd3a8..651d5731a6c6cf 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -459,6 +459,24 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { #define BTUSB_WAKEUP_DISABLE 14 #define BTUSB_USE_ALT1_FOR_WBS 15 +/* Per core spec 5, vol 4, part B, table 2.1, + * list the hci packet payload sizes for various ALT settings. + * This is used to set the packet length for the wideband speech. + * If a controller does not probe its usb alt setting, the default + * value will be 0. Any clients at upper layers should interpret it + * as a default value and set a proper packet length accordingly. + * + * To calculate the HCI packet payload length: + * for alternate settings 1 - 5: + * hci_packet_size = suggested_max_packet_size * 3 (packets) - + * 3 (HCI header octets) + * for alternate setting 6: + * hci_packet_size = suggested_max_packet_size - 3 (HCI header octets) + * where suggested_max_packet_size is {9, 17, 25, 33, 49, 63} + * for alt settings 1 - 6. + */ +static const int hci_packet_size_usb_alt[] = { 0, 24, 48, 72, 96, 144, 60 }; + struct btusb_data { struct hci_dev *hdev; struct usb_device *udev; @@ -3959,6 +3977,15 @@ static int btusb_probe(struct usb_interface *intf, hdev->notify = btusb_notify; hdev->prevent_wake = btusb_prevent_wake; + if (id->driver_info & BTUSB_AMP) { + /* AMP controllers do not support SCO packets */ + data->isoc = NULL; + } else { + /* Interface orders are hardcoded in the specification */ + data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); + data->isoc_ifnum = ifnum_base + 1; + } + #ifdef CONFIG_PM err = btusb_config_oob_wake(hdev); if (err) @@ -4022,6 +4049,10 @@ static int btusb_probe(struct usb_interface *intf, hdev->set_diag = btintel_set_diag; hdev->set_bdaddr = btintel_set_bdaddr; hdev->cmd_timeout = btusb_intel_cmd_timeout; + + if (btusb_find_altsetting(data, 6)) + hdev->sco_mtu = hci_packet_size_usb_alt[6]; + set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); @@ -4063,15 +4094,6 @@ static int btusb_probe(struct usb_interface *intf, btusb_check_needs_reset_resume(intf); } - if (id->driver_info & BTUSB_AMP) { - /* AMP controllers do not support SCO packets */ - data->isoc = NULL; - } else { - /* Interface orders are hardcoded in the specification */ - data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); - data->isoc_ifnum = ifnum_base + 1; - } - if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) && (id->driver_info & BTUSB_REALTEK)) { hdev->setup = btrtl_setup_realtek; @@ -4083,9 +4105,10 @@ static int btusb_probe(struct usb_interface *intf, * (DEVICE_REMOTE_WAKEUP) */ set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); - if (btusb_find_altsetting(data, 1)) + if (btusb_find_altsetting(data, 1)) { set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); - else + hdev->sco_mtu = hci_packet_size_usb_alt[1]; + } else bt_dev_err(hdev, "Device does not support ALT setting 1"); } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 33d8458fdd4adc..1869dc7ebbb5ac 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -730,7 +730,19 @@ static void hci_cc_read_buffer_size(struct hci_dev *hdev, struct sk_buff *skb) return; hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); - hdev->sco_mtu = rp->sco_mtu; + /* If the host controller interface is USB, the hdev->sco_mtu is + * set in btusb.c and is not expected to be larger than the max sco + * buffer size returned from the controller in rp->sco_mtu. + */ + if (hdev->sco_mtu > 0) { + if (rp->sco_mtu < hdev->sco_mtu) { + BT_ERR("sco mtu %d changed to max sco buffer size %d", + hdev->sco_mtu, rp->sco_mtu); + hdev->sco_mtu = rp->sco_mtu; + } + } else { + hdev->sco_mtu = rp->sco_mtu; + } hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YMThIQuwWV/LgAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:48:11 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id sDrsHguwWV+S2gEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:48:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7576040134; Thu, 10 Sep 2020 06:48:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725885AbgIJEr7 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:47:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgIJEru (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:47:50 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 304B8C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:47:48 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id o5so4801806qke.12 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=/PI89umKW0pAnG0notwsHzZB9en2DbzgnAf0XUhw6Gk=; b=LKw2n8xKEL89vN/79eSapuaGBiniRJsRbEQMmZZa5d50mcTGt9vyD8Gdvp6Fq8FV6B 3fO9HZLg3YWIXvuMHI2gyJdlmryrzFzCgpSgk8RvrQQj/rqRPT3owAfb3uFVlFwgCr/w LPYqefaO4/8Cpr1WO1irrtYthgfhRVwZByR7ljDFNZujovu7uGWFjHKAdkTcf/8JZ3Y4 JkYNks++q+XSCYrSAdw8FXryH+JbNdsqjP+AwCLuzhhKZPfTwezIuhQyXoX5GuyfiaGI DXp095FoSCqu3Wom3a+iAAx0o5YnwKHwnQV5u4YbKN7slUXHuXDyhbbs2sNHxfcN5cdh UPvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=/PI89umKW0pAnG0notwsHzZB9en2DbzgnAf0XUhw6Gk=; b=gstoPdUtxN2oni9AR+R4fq7dpK5YgmND18XdphpjsU3ByJkRCNrGEeANobso/G1wx+ JYkvkeGZiJ7nyQz3UW3HsWyw1WSjBJLrbphy4EQGKV++T6iiv/v8hLMFnF3w7SD06CfS dSWVBq9+EURdZTJZjeMh9IHNFFcqvd7lagggA4J9uOCiDw78XJJLnWx6GefbrGWCx7zI A5QGubqhVFlPpy1B7AbXP5Te+hrKPHVRA8jY/GhE7/+7YjYW1O7KxhqmojkgUObCUVvz YQDE0y+eN0FxX6S6CDZjwZ7pCp6I3QP5GNMkctTbqKPhb3gGI4v5eOs126hkofFKTEuF u5Jw== X-Gm-Message-State: AOAM5335DRUhEMlkC+a18qG7OVLuIhh9m+4ZXYc5YrRBQ9fwjA9/0pbA pHg87Edu2FbxLCOmdvrWkGSc88YAAmnH7g== X-Google-Smtp-Source: ABdhPJwKLoZwq9LMiKh0xMwKvERnUmZBAruUa8fi/xVL7IRxq8DE5ttzcXiC5TIvdsg06K1wK0hOTw== X-Received: by 2002:a37:a781:: with SMTP id q123mr6491715qke.436.1599713267903; Wed, 09 Sep 2020 21:47:47 -0700 (PDT) Received: from [172.17.0.2] ([40.84.25.207]) by smtp.gmail.com with ESMTPSA id u55sm6146212qtu.42.2020.09.09.21.47.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 21:47:47 -0700 (PDT) Message-ID: <5f59aff3.1c69fb81.6cc41.f176@mx.google.com> Date: Wed, 09 Sep 2020 21:47:47 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============1697491141037719967==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v2,1/7] PRE-UPSTREAM: adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.72 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7576040134 X-Rspamd-UID: e04359 --===============1697491141037719967== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #99: FILE: src/adv_monitor.c:1: +/* WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #253: FILE: src/adv_monitor.h:1: +/* - total: 0 errors, 2 warnings, 236 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============1697491141037719967==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OMR/HxSwWV/LgAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:48:20 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UBkbHBSwWV9OWQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:48:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 66C2C4086C; Thu, 10 Sep 2020 06:48:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725913AbgIJEsN (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbgIJErz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:47:55 -0400 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC18AC061756 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:47:53 -0700 (PDT) Received: by mail-qt1-x832.google.com with SMTP id y11so3876482qtn.9 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=OjW+XcA/Wsl8A4PR8l9Bo2YagaelsACryuZHy/wV6t0=; b=PAnmZw29L2ducS4BxgVHihoos47EYipBhdjfN9uJj40yjXAjPT3CxOxxgat6yFKO8C SP96rgPzdIswugYExptMBHbZOiCvkkdRp0f61iGNZHAeTFhTCthv4quCr3Ceoo2SMqAy Trodsutj/ISJs5btafodk+Ft6E/MFqN2bwN5zdjCljmqF4fJubyczmtVk+JWnb4auM9z CSUaBiTVznnfJPYcv+Q1O2E2aqqrmvrJjO4S4jC6s+PmchbTZ+n+J6srKQw1cmvMKE/o IEQMbM8a7nB45oIy4lX/s616bp18WQ1qRsPsgdeHEdFcLkg/w7RcJaTR+Gvrr5PYUP5f WsyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=OjW+XcA/Wsl8A4PR8l9Bo2YagaelsACryuZHy/wV6t0=; b=ANB1rsh/s3SzYshgLSj1GU+wcHT4lu+d9/S/7rJIa7O0PMTfvB1DEdCcpKYHVJhlf4 xZYdjcpXb2yUS9nxQiVEMTs+Ya94ecq+QITOn6yxwjKocV5zNMvLaMzYaH2dlag/oZyy 9KnhO8UjtrwMxc+H0DH0VgNo6mtWuogHKKMI8X4zpYFWQoiypzEcdjqMm6EQ1PFccMfb 6UsT3uVBckrs5d8lHaBkYSGsV6CWAPnJLvs7ABSwm3Tbx5iTPEam6GYvAEXTiB2AT41+ pw5Z5QZNpciNEkScDby7UvVN8bfCiu/vrw1pI4t0HqDi5o+VFqsV5tWFKyy7zb4sodPP 1jYw== X-Gm-Message-State: AOAM533ggvMILwG5BVOAplwmRDByY1zPOFqZ7uEivLISzqSDkL4CHgwS 90C8SR29ZX2d2CSeGhGOsTypliOToHihrg== X-Google-Smtp-Source: ABdhPJwHbeFMIaFZ6qAmMQjYsULhPZ8w6+eZg09crcfJwlAus4+hJV7WNUWFq1dp3ceLR42B1F0jGA== X-Received: by 2002:ac8:5d43:: with SMTP id g3mr6527553qtx.295.1599713272884; Wed, 09 Sep 2020 21:47:52 -0700 (PDT) Received: from [172.17.0.2] ([52.254.71.168]) by smtp.gmail.com with ESMTPSA id z2sm5240853qkg.40.2020.09.09.21.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 21:47:52 -0700 (PDT) Message-ID: <5f59aff8.1c69fb81.b7415.83be@mx.google.com> Date: Wed, 09 Sep 2020 21:47:52 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3379336798535123357==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v3,1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.72 / 15.00 / 15.00 X-Rspamd-Queue-Id: 66C2C4086C X-Rspamd-UID: 28a4d3 --===============3379336798535123357== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #99: FILE: src/adv_monitor.c:1: +/* WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #253: FILE: src/adv_monitor.h:1: +/* - total: 0 errors, 2 warnings, 236 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============3379336798535123357==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KJhGOhqwWV/LgAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:48:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aExVNxqwWV8P/gAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:48:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A740A40961; Thu, 10 Sep 2020 06:48:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725971AbgIJEsP (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgIJEsA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:48:00 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB6B6C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:47:59 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id k25so3907618qtu.4 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=dRJXS6ZKSWz+MF1RiAgo9X2u0aseXPtPiJ6GHIkJpRk=; b=I7py7RlJ2hGlvd86wNvkon657dwVWoj5Ct/TlH8OdVDVOcT53GkQBbqyv7X7VEAVH+ Z+vsen4QSfNqeMVXj2brnhJQlUwxOcCwDbpbPA9jejd9AJmb/WKukuXn8IExp30S9DSp NGPZIBug2O/b7VTjcw6AvxR8Wed5CkH1efxICbf3xwnWngUqbZVOX8HZ6wGkGiNT5WAx VXIfcwgPr3byuw2S181hv4ZSqvTr1vEcYQNtQ6DA+NKfafcuBcEhGO9rBGurX3CtQEzx A3NvC4ShZhhBQaZgNAVu2vb2u6bUtdwcGzMysNHEJBHeAPCLbOqJDd50BpNX4ZVb+nOX WTkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=dRJXS6ZKSWz+MF1RiAgo9X2u0aseXPtPiJ6GHIkJpRk=; b=pSqkGm7UNx/XtJ80BJ9/5Q2SdUDGNolnJIv5pxAhFM3XT5iiblO/MOFNBY7DlAvw4i 1pZtLI0F3FTSbFl7aMb/Ucu6N0vEJUZM/+OQguMGheVHyBIwMjyaJD04WbJgDzDd3rSV UyK49hBLRMcQi1o4hLq73Q6U9eUIJbSBQ1DxhgEcIm1/kwGstCiBOIOogEOy1nkw9Qze kz4z3NzA3NBXO7kLigGOz5kYAe3Gi237NUh+fD6XUCNuowH14y8VluY5YPmEQuEVtosF HpQCE+lgK3ZOzydTUoXCnivrHx4wSNV8O9/EP7OOkN8n1cf4JwMKRA4FxHxGCEpTR7cs Cpiw== X-Gm-Message-State: AOAM531c+EJrPTXU4nJGL3sNf6ZGp8wU00B0tAwCydEnmURrFRCNfn/W hL+TiUzvFLKGcCQsj/1w9TM6hm502qHOeA== X-Google-Smtp-Source: ABdhPJxOABUD0h+HZGeunL2TheQnMt82LLsHZhS5+wFMZ3pLtKXBFo3Y03D5Xx5b9vV5zPdXEW7Lxg== X-Received: by 2002:ac8:4d07:: with SMTP id w7mr6434161qtv.243.1599713278438; Wed, 09 Sep 2020 21:47:58 -0700 (PDT) Received: from [172.17.0.2] ([40.84.25.207]) by smtp.gmail.com with ESMTPSA id g37sm5667580qtk.76.2020.09.09.21.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 21:47:58 -0700 (PDT) Message-ID: <5f59affe.1c69fb81.298d4.accb@mx.google.com> Date: Wed, 09 Sep 2020 21:47:58 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============8446680284482479787==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v2,1/7] PRE-UPSTREAM: adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.68 / 15.00 / 15.00 X-Rspamd-Queue-Id: A740A40961 X-Rspamd-UID: 7d6991 --===============8446680284482479787== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 1: T1 Title exceeds max length (85>72): "PRE-UPSTREAM: adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface" --- Regards, Linux Bluetooth --===============8446680284482479787==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GNOdDSGwWV/7ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:48:33 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8CtICiGwWV9j/gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:48:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 10C11408B5; Thu, 10 Sep 2020 06:48:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725992AbgIJEsT (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725887AbgIJEsC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:48:02 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AA63C061757 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:48:00 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id y11so3876590qtn.9 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:48:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=wAuESQ5dCEhkjNiNxWhtQHwcrrqfz0y6AMYdbWMZAJc=; b=c8ENxH9EYhzsyv/nSGXofPgfAuTNlnmd+iz1ubdh0qfyWmOWIcUNT4EiUCGYCY9JE5 O4S6QqZrSPv+fQ3ZZ32ixG6xpwhgu/iGBTv/APIAxXeD5oTKM9RL9TmgIxoI8P3lEQPI +Ngbk2psVEtSNnN2o6ty+vEuZaJETOcdtJjI6D+Xtcy5OSU152BLKTU+QehdDLgMoixB TNGkPVZhrZkA/JzbcFgfgjUzrLbD33nlP37GZ6HGGS1pBHoFFV7+F702ZrXwAHcZ3mAT 1mXLAn6G7Uidcp/zQmbjylVYz0yx6kKEdlQ8bNIIOpAwTM08TnZ6Upv3BE82vyS9Xdnd UW8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=wAuESQ5dCEhkjNiNxWhtQHwcrrqfz0y6AMYdbWMZAJc=; b=PTCIqIlWX0Z7XPeQGVrDzwHllPjpHUh6XjuQW5/FWl1ueKe5nq/kvQGUOD7k1/Jgjv k6zNX7cftZcQORga4rl1Hadhl410FJ8UHzx5XgsERCeU4WsG+/x+ZPOV5Cenlb6L3T7M DY6DYhWs/wRKjtxbGePyl854e1qVAVAmqDZNgKDse3K0V5mN1S/caGlwpjf9t6gZFP3d z/lUwxPe7RgNcfmS83sgtM0lUnIqoYUiZzIDS9KpU9fG9qzG2mUX6U3/luygPnM2Xo5l P+G0FyTOXU0S1v0EPMapngldZ3Tv9+lULFcU6TxkfLxi1o/y3j1AHae2wtmo0pqnoJ9G VI8w== X-Gm-Message-State: AOAM533AUaE40mx1+v4yua2L26ubdVV1wezYFN72m4i3vsPgaqZbapu3 Il5lDbnjGpDF5Vzvse3NLeB2yHW/CIb6lg== X-Google-Smtp-Source: ABdhPJxMvgT1qYaFFqxftvXfledSU8CCMOdRX3EOzRzQ+vAsh0Ebu6zV/fopfFRXrUMh69pXuiOQcg== X-Received: by 2002:ac8:4d1a:: with SMTP id w26mr6446247qtv.220.1599713279443; Wed, 09 Sep 2020 21:47:59 -0700 (PDT) Received: from [172.17.0.2] ([40.84.25.207]) by smtp.gmail.com with ESMTPSA id i66sm5140602qkc.63.2020.09.09.21.47.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 21:47:59 -0700 (PDT) Message-ID: <5f59afff.1c69fb81.a663e.8e17@mx.google.com> Date: Wed, 09 Sep 2020 21:47:59 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============5369202452627928207==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v2,2/7] PRE-UPSTREAM: adv_monitor: Implement Get functions of Adv monitor manager properties Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200909213423.BlueZ.v2.2.I9960e45d36be3edb5f17de025e7eb8257d3cddef@changeid> References: <20200909213423.BlueZ.v2.2.I9960e45d36be3edb5f17de025e7eb8257d3cddef@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.76 / 15.00 / 15.00 X-Rspamd-Queue-Id: 10C11408B5 X-Rspamd-UID: 897765 --===============5369202452627928207== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 1: T1 Title exceeds max length (84>72): "PRE-UPSTREAM: adv_monitor: Implement Get functions of Adv monitor manager properties" --- Regards, Linux Bluetooth --===============5369202452627928207==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6A16HMqwWV/7ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:51:22 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id cMtGGcqwWV+S2gEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:51:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 456AFA0B39; Thu, 10 Sep 2020 06:51:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725933AbgIJEvM (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:51:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgIJEuw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:50:52 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28EE3C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:50:52 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id p4so4879459qkf.0 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=Wc2qau40+T5BtEtGzMisIH3Qu5gv/bAE2QA5+U6OI/U=; b=Bet7Dl8m2m4jVFMI00jmpz6JUj7OCXHi94awSiF02281DuZ41mxe8ErgZjOdY5eYuH jkgrfAzT7ZcVNvPzKepkiHXWV13dGjeJGdU6XS4C/m+AE24KBFsYrkxhO/29m61SwX3E QoFuOScqTSKvzyUksEiLnk+Uf4Q1fl6HZY4xozOGrw6MURZe51/CLvekaWB1Tz62EXBl cXfzHInnohVRYYhYIgYL2dWcngEJHqWCL7ogbNR2//dP+vCpa4/z7FtZ6gnEQFa2PIyb 2fi/hMVnnjqyyPOw/OB1DaiFdCHkUFJVaL55PqJft5aTOepQ3B5NmV+Vm5zjM+kuPhSr zA5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=Wc2qau40+T5BtEtGzMisIH3Qu5gv/bAE2QA5+U6OI/U=; b=iJrUCmDc3aqJpqAbYKFqk/n9/QjOgJWdy2xTgEbrfJ/3G34zS2py/uRmA7kCnDWH/+ +6SsK7V800NwK2xiw45jC7omnVmONXEjU9eFsNWUAIka7XdCyvIx6qq1iQsfYsceNr2s jXmBgFg53ZZLxkcWWNK8Zdd9JPLGUV/UD8iEeJTz2YuZy37KE2X7x55t8+1udCAywsY2 OE/OGHgQZZq/J17/wUpnik6KMxCYViushsDh0/pPE22mVnVmQ/GYizhsqXPGf7TbZD05 OYT703lZCtgDZ+MFjjy/vnC8PQkKu1bRlOzwyw1zekUdBrX6GjgS8tRMfkVN7W1sthUa Sb1w== X-Gm-Message-State: AOAM532ua2LqHzA24SsZ64tYo0vWdVBaUvLkyF4xB6j/EPM3n4uBRIa4 tgvf5cDQDjFX4bQ5GF83PbqWOnKY1ShwoA== X-Google-Smtp-Source: ABdhPJzCgLiefa9iGY28yv2uBFsrq5T0M2r7ewviE9gJEjeptaJ0dB0zy+eBKgoj6lg4U1gdW+OW/w== X-Received: by 2002:a05:620a:716:: with SMTP id 22mr6276038qkc.356.1599713450661; Wed, 09 Sep 2020 21:50:50 -0700 (PDT) Received: from [172.17.0.2] ([40.84.25.207]) by smtp.gmail.com with ESMTPSA id o13sm4920512qkm.16.2020.09.09.21.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 21:50:50 -0700 (PDT) Message-ID: <5f59b0aa.1c69fb81.1a202.6e98@mx.google.com> Date: Wed, 09 Sep 2020 21:50:50 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============7665840508942177531==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v2,1/7] PRE-UPSTREAM: adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909213423.BlueZ.v2.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.88 / 15.00 / 15.00 X-Rspamd-Queue-Id: 456AFA0B39 X-Rspamd-UID: 6cf947 --===============7665840508942177531== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnNyYy9hZHZfbW9uaXRvci5jOiBJbiBmdW5jdGlvbiDigJhtb25pdG9y X21hdGNo4oCZOgpzcmMvYWR2X21vbml0b3IuYzoyNzc6MzU6IGVycm9yOiBwYXNzaW5nIGFyZ3Vt ZW50IDEgb2Yg4oCYZ19kYnVzX3Byb3h5X2dldF9wYXRo4oCZIGRpc2NhcmRzIOKAmGNvbnN04oCZ IHF1YWxpZmllciBmcm9tIHBvaW50ZXIgdGFyZ2V0IHR5cGUgWy1XZXJyb3I9ZGlzY2FyZGVkLXF1 YWxpZmllcnNdCiAgMjc3IHwgIGlmIChzdHJjbXAoZ19kYnVzX3Byb3h5X2dldF9wYXRoKHByb3h5 KSwgbW9uaXRvci0+cGF0aCkgIT0gMCkKICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgXn5+fn4KSW4gZmlsZSBpbmNsdWRlZCBmcm9tIHNyYy9hZHZfbW9uaXRvci5jOjMx OgouL2dkYnVzL2dkYnVzLmg6MzM2OjEzOiBub3RlOiBleHBlY3RlZCDigJhHREJ1c1Byb3h5ICri gJkge2FrYSDigJhzdHJ1Y3QgR0RCdXNQcm94eSAq4oCZfSBidXQgYXJndW1lbnQgaXMgb2YgdHlw ZSDigJhjb25zdCBHREJ1c1Byb3h5ICrigJkge2FrYSDigJhjb25zdCBzdHJ1Y3QgR0RCdXNQcm94 eSAq4oCZfQogIDMzNiB8IGNvbnN0IGNoYXIgKmdfZGJ1c19wcm94eV9nZXRfcGF0aChHREJ1c1By b3h5ICpwcm94eSk7CiAgICAgIHwgICAgICAgICAgICAgXn5+fn5+fn5+fn5+fn5+fn5+fn5+CnNy Yy9hZHZfbW9uaXRvci5jOiBJbiBmdW5jdGlvbiDigJhwYXJzZV9wYXR0ZXJuc+KAmToKc3JjL2Fk dl9tb25pdG9yLmM6NDg2OjM2OiBlcnJvcjogc3VnZ2VzdCBwYXJlbnRoZXNlcyBhcm91bmQg4oCY JibigJkgd2l0aGluIOKAmHx84oCZIFstV2Vycm9yPXBhcmVudGhlc2VzXQogIDQ4NiB8ICAgaWYg KGFkX3R5cGUgPiBCVF9BRF8zRF9JTkZPX0RBVEEgJiYKc3JjL2Fkdl9tb25pdG9yLmM6NDI2OjEx OiBlcnJvcjogdW51c2VkIHZhcmlhYmxlIOKAmG51bV9wYXR0ZXJuc+KAmSBbLVdlcnJvcj11bnVz ZWQtdmFyaWFibGVdCiAgNDI2IHwgIHVpbnQxNl90IG51bV9wYXR0ZXJucyA9IDA7CiAgICAgIHwg ICAgICAgICAgIF5+fn5+fn5+fn5+fgpzcmMvYWR2X21vbml0b3IuYzogSW4gZnVuY3Rpb24g4oCY Z2V0X3N1cHBvcnRlZF9tb25pdG9yX3R5cGVz4oCZOgpzcmMvYWR2X21vbml0b3IuYzo3NTQ6MzQ6 IGVycm9yOiB1bnVzZWQgdmFyaWFibGUg4oCYbWFuYWdlcuKAmSBbLVdlcnJvcj11bnVzZWQtdmFy aWFibGVdCiAgNzU0IHwgIHN0cnVjdCBidGRfYWR2X21vbml0b3JfbWFuYWdlciAqbWFuYWdlciA9 IGRhdGE7CiAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXn5+fn5+fgpj YzE6IGFsbCB3YXJuaW5ncyBiZWluZyB0cmVhdGVkIGFzIGVycm9ycwptYWtlWzFdOiAqKiogW01h a2VmaWxlOjkyNzI6IHNyYy9ibHVldG9vdGhkLWFkdl9tb25pdG9yLm9dIEVycm9yIDEKbWFrZTog KioqIFtNYWtlZmlsZTo0MDE0OiBhbGxdIEVycm9yIDIKCgoKLS0tClJlZ2FyZHMsCkxpbnV4IEJs dWV0b290aAo= --===============7665840508942177531==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +IVHA9GwWV/7ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:51:29 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SEwbANGwWV+M/wEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:51:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0B5D9A097B; Thu, 10 Sep 2020 06:51:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726431AbgIJEvU (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:51:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbgIJEvB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:51:01 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C241C061757 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:50:58 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id w186so4874488qkd.1 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:50:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=iyG2yc7oujFwDny2rBdGvywMFOjLXj5gCk7vHUEQnQI=; b=jkQglmNgAkv4mog5p8mSJcfdllHRMoWJvqz/2Io0FP76rhRRrfK2DZFlsXILkibfJ2 NyCj0jMyW8gxiuuYmQvvr4JrUSKKMk5KNoUTPE53QJwZQMheHVTK4S2ZBURVrS//NMWv BRJvOTkxggX+/kt0Jnj8WRqt1C4iu6NRjsl7AXeghFx2gBYyKaCsQSka6Z0Prepc2mIt zL8oPK0SzZqHbr162mLXY3U9F/S/U1FW8STUj3y0RMHeVRa5WVOJgLExiEI5A1vtoPI2 t/GvruxxM84xQ/6lLXtJtXFV5MxtWoSO1PYOvo+4NLbCvSNStLCcg92Kvs3h+/kacff7 6H4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=iyG2yc7oujFwDny2rBdGvywMFOjLXj5gCk7vHUEQnQI=; b=ZSJ2eD4iCA6+WK3/De8lkZ79Kxoz+lBoATL1CH24yoIxu0xVCkB/ov/0cbvY5oD3AI G84N/ezLrbP+45qOialowoc6DUiu16uvnhYaXTTSomTJ1Ff/IIpsApHLpHC0PgHKZwyv XGAncIrnk9OZdsGswWEXxbH4xxkl4z9Q/5IeSRWaPa0CgCF6cjn/8QuhsnJtkECHy1C0 E09w4NA0wAJwdLGD4lEVVJ5WaWO0yZqycLQsxfzrBUFY1BfMZCM5vNQBgYtei+kx8gxA aGsBlJleD7z7Mvo7itG2wKEw9gzaclTLDVE9Pc1UnVWLkmWou/CifKDeRl3LP0rOC/ed 9oRw== X-Gm-Message-State: AOAM533zzpMTWJZP7qmw88LNWOOjEOZ9PyoOhv4fUexTGGtn/tQkVCVS 8kJkeZMIbl4UVrvsnFAUuHDXT511s2Oomw== X-Google-Smtp-Source: ABdhPJykZlmYR9Ab7DMa6ELXcbfvHiGQdO341uBC8/wajNiA9Q5Ok9xOtgqkUZBsYT4MHQjXkbGfHA== X-Received: by 2002:a05:620a:13e8:: with SMTP id h8mr6228300qkl.322.1599713457723; Wed, 09 Sep 2020 21:50:57 -0700 (PDT) Received: from [172.17.0.2] ([52.254.71.168]) by smtp.gmail.com with ESMTPSA id w59sm5637539qtd.1.2020.09.09.21.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 21:50:57 -0700 (PDT) Message-ID: <5f59b0b1.1c69fb81.ec0c2.af3e@mx.google.com> Date: Wed, 09 Sep 2020 21:50:57 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============5268216710086389930==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v3,1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200909214058.BlueZ.v3.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.88 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0B5D9A097B X-Rspamd-UID: 07cc74 --===============5268216710086389930== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnNyYy9hZHZfbW9uaXRvci5jOiBJbiBmdW5jdGlvbiDigJhtb25pdG9y X21hdGNo4oCZOgpzcmMvYWR2X21vbml0b3IuYzoyNzc6MzU6IGVycm9yOiBwYXNzaW5nIGFyZ3Vt ZW50IDEgb2Yg4oCYZ19kYnVzX3Byb3h5X2dldF9wYXRo4oCZIGRpc2NhcmRzIOKAmGNvbnN04oCZ IHF1YWxpZmllciBmcm9tIHBvaW50ZXIgdGFyZ2V0IHR5cGUgWy1XZXJyb3I9ZGlzY2FyZGVkLXF1 YWxpZmllcnNdCiAgMjc3IHwgIGlmIChzdHJjbXAoZ19kYnVzX3Byb3h5X2dldF9wYXRoKHByb3h5 KSwgbW9uaXRvci0+cGF0aCkgIT0gMCkKICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgXn5+fn4KSW4gZmlsZSBpbmNsdWRlZCBmcm9tIHNyYy9hZHZfbW9uaXRvci5jOjMx OgouL2dkYnVzL2dkYnVzLmg6MzM2OjEzOiBub3RlOiBleHBlY3RlZCDigJhHREJ1c1Byb3h5ICri gJkge2FrYSDigJhzdHJ1Y3QgR0RCdXNQcm94eSAq4oCZfSBidXQgYXJndW1lbnQgaXMgb2YgdHlw ZSDigJhjb25zdCBHREJ1c1Byb3h5ICrigJkge2FrYSDigJhjb25zdCBzdHJ1Y3QgR0RCdXNQcm94 eSAq4oCZfQogIDMzNiB8IGNvbnN0IGNoYXIgKmdfZGJ1c19wcm94eV9nZXRfcGF0aChHREJ1c1By b3h5ICpwcm94eSk7CiAgICAgIHwgICAgICAgICAgICAgXn5+fn5+fn5+fn5+fn5+fn5+fn5+CnNy Yy9hZHZfbW9uaXRvci5jOiBJbiBmdW5jdGlvbiDigJhwYXJzZV9wYXR0ZXJuc+KAmToKc3JjL2Fk dl9tb25pdG9yLmM6NDg2OjM2OiBlcnJvcjogc3VnZ2VzdCBwYXJlbnRoZXNlcyBhcm91bmQg4oCY JibigJkgd2l0aGluIOKAmHx84oCZIFstV2Vycm9yPXBhcmVudGhlc2VzXQogIDQ4NiB8ICAgaWYg KGFkX3R5cGUgPiBCVF9BRF8zRF9JTkZPX0RBVEEgJiYKc3JjL2Fkdl9tb25pdG9yLmM6NDI2OjEx OiBlcnJvcjogdW51c2VkIHZhcmlhYmxlIOKAmG51bV9wYXR0ZXJuc+KAmSBbLVdlcnJvcj11bnVz ZWQtdmFyaWFibGVdCiAgNDI2IHwgIHVpbnQxNl90IG51bV9wYXR0ZXJucyA9IDA7CiAgICAgIHwg ICAgICAgICAgIF5+fn5+fn5+fn5+fgpzcmMvYWR2X21vbml0b3IuYzogSW4gZnVuY3Rpb24g4oCY Z2V0X3N1cHBvcnRlZF9tb25pdG9yX3R5cGVz4oCZOgpzcmMvYWR2X21vbml0b3IuYzo3NTQ6MzQ6 IGVycm9yOiB1bnVzZWQgdmFyaWFibGUg4oCYbWFuYWdlcuKAmSBbLVdlcnJvcj11bnVzZWQtdmFy aWFibGVdCiAgNzU0IHwgIHN0cnVjdCBidGRfYWR2X21vbml0b3JfbWFuYWdlciAqbWFuYWdlciA9 IGRhdGE7CiAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXn5+fn5+fgpj YzE6IGFsbCB3YXJuaW5ncyBiZWluZyB0cmVhdGVkIGFzIGVycm9ycwptYWtlWzFdOiAqKiogW01h a2VmaWxlOjkyNzI6IHNyYy9ibHVldG9vdGhkLWFkdl9tb25pdG9yLm9dIEVycm9yIDEKbWFrZTog KioqIFtNYWtlZmlsZTo0MDE0OiBhbGxdIEVycm9yIDIKCgoKLS0tClJlZ2FyZHMsCkxpbnV4IEJs dWV0b290aAo= --===============5268216710086389930==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0PgCNBGxWV/7ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:52:33 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id gH0IMRGxWV+njAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:52:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8B3854086A; Thu, 10 Sep 2020 06:52:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726079AbgIJEwZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:52:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725981AbgIJEwV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:52:21 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57200C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:52:21 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id k25so6404504ljg.9 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=L5II68IKO1dIiGrC/s2Rycfyj2FmICgmM5WKX4TH4LY=; b=GFkdBbML4vO8FWESwqrSXTpLhGfDxqAi7CcGQ0iMOsUBCbfgyBbHljATg50p/Q2ScV t0jv0JaHso0TkTvK9TKA93CpnDY/Fg5FxtI+sMjbJPDLqcieSpD8YC0z0qWNr2r1xHhe GoZFvX/6xnDYnSEwPUbDDbQKRkObjDxbjz2AE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=L5II68IKO1dIiGrC/s2Rycfyj2FmICgmM5WKX4TH4LY=; b=GK3BJf+Y+D2hOqaDXLrdP4Q3Vsl6m9eFSXAOT9Iq5uCB+1pvBFjbHOkbwPOGB/8rpK m1DZpFS+eKsOfHvHnEUFHO6TiS1/0sjvTvZi/fpjsSuiSPIY0fDCJIHtvUKXMncN66Lg cn52gT2uKS1bvZpqCmHTZvNGNGEkunm9AnudjoQwQkfjmZtOLfBQIMKhwWkuVcf6VzA0 NkyuInN63U4CzRWVoaykb1kzBhlG6tzES2fDqTStb3Vg6ab9BFE6pf2irMdDJ9i6qWZY m+zkLehz4CfJfO8QWkmtgMSPITQB4qru9DqhdXi/nne/VXsGRgB/FRkB5VyTZH8RUFiP eZwg== X-Gm-Message-State: AOAM53055awGGTPQU6c4M0ZjAjal4Hf1Ko5at7EccAbgCf41bvZwWpV0 E4dpfhoBM7cyCGo2LJZ4UJ+XrMwcnsV8dAfwAZJW+Q== X-Google-Smtp-Source: ABdhPJz6RqNyN9HkNcEz5//OnLv7be99VU5paGhxJsfwWGNSC7/LClUN9E0wrLRgO7BJDRWTvkM8OdMpAdPqh0V0VLw= X-Received: by 2002:a2e:9c15:: with SMTP id s21mr3510428lji.27.1599713539688; Wed, 09 Sep 2020 21:52:19 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <CABBYNZLoGG8_f-8Vr=FW-mVe1uFsz-ob3-=tuk_c90kqhtLMVg@mail.gmail.com> In-Reply-To: <CABBYNZLoGG8_f-8Vr=FW-mVe1uFsz-ob3-=tuk_c90kqhtLMVg@mail.gmail.com> From: Miao-chen Chou <mcchou@chromium.org> Date: Wed, 9 Sep 2020 21:52:08 -0700 Message-ID: <CABmPvSHWTr+v5jKbBDWus5RRZBprzrwb5UiT0jn4hJVqv0vbug@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.14 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8B3854086A X-Rspamd-UID: 2be022 Hi Luiz, On Tue, Sep 8, 2020 at 10:19 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Miao, > > On Tue, Aug 18, 2020 at 3:30 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > This introduces the org.bluez.AdvertisementMonitorManager1 without > > implementing handlers of methods and properties. > > > > The following test was performed. > > - Upon adapter registration, the info line of creating an ADV monitor > > manager gets printed, and system bus emits the interface events of > > org.bluez.AdvertisementMonitorManager1. > > > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > --- > > > > Makefile.am | 3 +- > > src/adapter.c | 14 +++++ > > src/adapter.h | 3 + > > src/adv_monitor.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++ > > src/adv_monitor.h | 32 ++++++++++ > > 5 files changed, 200 insertions(+), 1 deletion(-) > > create mode 100644 src/adv_monitor.c > > create mode 100644 src/adv_monitor.h > > > > diff --git a/Makefile.am b/Makefile.am > > index 7719c06f8..b14ee950e 100644 > > --- a/Makefile.am > > +++ b/Makefile.am > > @@ -293,7 +293,8 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ > > src/gatt-client.h src/gatt-client.c \ > > src/device.h src/device.c \ > > src/dbus-common.c src/dbus-common.h \ > > - src/eir.h src/eir.c > > + src/eir.h src/eir.c \ > > + src/adv_monitor.h src/adv_monitor.c > > Id just name it monitor.{c, h} It'd be preferable to avoid confusion by specifying "adv_" as the prefix, since there is the other "monitor" (btmon) in BlueZ. Besides, we also name the corresponding system configuration values by "adv_monitor". > > > src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ > > gdbus/libgdbus-internal.la \ > > src/libshared-glib.la \ > > diff --git a/src/adapter.c b/src/adapter.c > > index 5e896a9f0..41e9de286 100644 > > --- a/src/adapter.c > > +++ b/src/adapter.c > > @@ -77,6 +77,7 @@ > > #include "attrib-server.h" > > #include "gatt-database.h" > > #include "advertising.h" > > +#include "adv_monitor.h" > > #include "eir.h" > > > > #define ADAPTER_INTERFACE "org.bluez.Adapter1" > > @@ -272,6 +273,8 @@ struct btd_adapter { > > struct btd_gatt_database *database; > > struct btd_adv_manager *adv_manager; > > > > + struct btd_adv_monitor_manager *adv_monitor_manager; > > + > > gboolean initialized; > > > > GSList *pin_callbacks; > > @@ -6346,6 +6349,9 @@ static void adapter_remove(struct btd_adapter *adapter) > > btd_adv_manager_destroy(adapter->adv_manager); > > adapter->adv_manager = NULL; > > > > + btd_adv_monitor_manager_destroy(adapter->adv_monitor_manager); > > + adapter->adv_monitor_manager = NULL; > > + > > g_slist_free(adapter->pin_callbacks); > > adapter->pin_callbacks = NULL; > > > > @@ -8623,6 +8629,14 @@ static int adapter_register(struct btd_adapter *adapter) > > > > adapter->adv_manager = btd_adv_manager_new(adapter, adapter->mgmt); > > > > + adapter->adv_monitor_manager = btd_adv_monitor_manager_create( > > + adapter, adapter->mgmt); > > + if (!adapter->adv_monitor_manager) { > > + btd_error(adapter->dev_id, > > + "Failed to create Adv Monitor Manager for adapter"); > > + return -EINVAL; > > + } > > + > > db = btd_gatt_database_get_db(adapter->database); > > adapter->db_id = gatt_db_register(db, services_modified, > > services_modified, > > diff --git a/src/adapter.h b/src/adapter.h > > index f8ac20261..5cb467141 100644 > > --- a/src/adapter.h > > +++ b/src/adapter.h > > @@ -26,6 +26,9 @@ > > #include <dbus/dbus.h> > > #include <glib.h> > > > > +#include "lib/bluetooth.h" > > +#include "lib/sdp.h" > > + > > It might be better to have this included locally in a .c file needing them. > This fixes the complaint from the compiler where the symbols referred adapter.h was not found. This was revealed due to the circular dependency between adv_monitor and adapter where adv_monitor needs to include adapter.h for calling btd_adapter_get_index(), and adv_monitor doesn't have these two includes. In other words, adapter.h has been relying on other headers to include lib/sdp.h and lib/bluetooth.h which was not a good pattern in the first place. Besides, adapter.h does refer to symbols from lib/bluetooth.h and lib/sdp.h, so it makes sense to have them here. > > #define MAX_NAME_LENGTH 248 > > > > /* Invalid SSP passkey value used to indicate negative replies */ > > diff --git a/src/adv_monitor.c b/src/adv_monitor.c > > new file mode 100644 > > index 000000000..7044d3cca > > --- /dev/null > > +++ b/src/adv_monitor.c > > @@ -0,0 +1,149 @@ > > +/* > > + * > > + * BlueZ - Bluetooth protocol stack for Linux > > + * > > + * Copyright (C) 2020 Google LLC > > + * > > + * > > + * This program is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU Lesser General Public > > + * License as published by the Free Software Foundation; either > > + * version 2.1 of the License, or (at your option) any later version. > > + * > > + * This program is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > + * Lesser General Public License for more details. > > + * > > + */ > > + > > +#ifdef HAVE_CONFIG_H > > +#include <config.h> > > +#endif > > + > > +#define _GNU_SOURCE > > +#include <stdint.h> > > + > > +#include <glib.h> > > +#include <dbus/dbus.h> > > +#include <gdbus/gdbus.h> > > + > > +#include "adapter.h" > > +#include "dbus-common.h" > > +#include "log.h" > > +#include "src/shared/mgmt.h" > > + > > +#include "adv_monitor.h" > > + > > +#define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" > > + > > +struct btd_adv_monitor_manager { > > + struct btd_adapter *adapter; > > + struct mgmt *mgmt; > > + uint16_t adapter_id; > > + char *path; > > +}; > > + > > +static const GDBusMethodTable adv_monitor_methods[] = { > > + { GDBUS_METHOD("RegisterMonitor", > > + GDBUS_ARGS({ "application", "o" }), > > + NULL, NULL) }, > > + { GDBUS_ASYNC_METHOD("UnregisterMonitor", > > + GDBUS_ARGS({ "application", "o" }), > > + NULL, NULL) }, > > + { } > > +}; > > + > > +static const GDBusPropertyTable adv_monitor_properties[] = { > > + {"SupportedMonitorTypes", "as", NULL, NULL, NULL}, > > + {"SupportedFeatures", "as", NULL, NULL, NULL}, > > + { } > > +}; > > + > > +/* Allocates a manager object */ > > +static struct btd_adv_monitor_manager *manager_new( > > + struct btd_adapter *adapter, > > + struct mgmt *mgmt) > > +{ > > + struct btd_adv_monitor_manager *manager; > > + > > + if (!adapter || !mgmt) > > + return NULL; > > + > > + manager = g_new0(struct btd_adv_monitor_manager, 1); > > Use new0. > > > + if (!manager) > > + return NULL; > > + > > + manager->adapter = adapter; > > + manager->mgmt = mgmt_ref(mgmt); > > + manager->adapter_id = btd_adapter_get_index(adapter); > > + manager->path = g_strdup(adapter_get_path(manager->adapter)); > > If we are doing to reference the adapter we don't really need the > duplicate its path since we can just use adapter_get_path. As a part of adapter bring-down, the adv monitor manager would be destroyed too, and we should avoid accessing adapter's resource(s) during the bring-down to avoid incorrect values. By making a copy of the path, the code would be less error-prone since the adv monitor manager does not depend on the unknown state of the adapter. > > > + > > + return manager; > > +} > > + > > +/* Frees a manager object */ > > +static void manager_free(struct btd_adv_monitor_manager *manager) > > +{ > > + manager->adapter = NULL; > > No need to assign NULL if you are going to free the whole object at the end. Done. > > > + mgmt_unref(manager->mgmt); > > + manager->mgmt = NULL; > > Ditto. Done. > > > + g_free(manager->path); > > + manager->path = NULL; > > Ditto. Done. > > > + > > + g_free(manager); > > +} > > + > > +/* Destroys a manager object and unregisters its D-Bus interface */ > > +static void manager_destroy(struct btd_adv_monitor_manager *manager) > > +{ > > + if (!manager) > > + return; > > + > > + g_dbus_unregister_interface(btd_get_dbus_connection(), > > + manager->path, > > + ADV_MONITOR_MGR_INTERFACE); > > + > > + manager_free(manager); > > +} > > + > > +/* Creates a manager and registers its D-Bus interface */ > > +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( > > + struct btd_adapter *adapter, > > + struct mgmt *mgmt) > > +{ > > + struct btd_adv_monitor_manager *manager; > > + > > + manager = manager_new(adapter, mgmt); > > + if (!manager) > > + return NULL; > > + > > + if (g_dbus_register_interface(btd_get_dbus_connection(), manager->path, > > + ADV_MONITOR_MGR_INTERFACE, > > + adv_monitor_methods, NULL, > > + adv_monitor_properties, manager, NULL) > > + == FALSE) { > > We haven't been consistent with boolean checks but lately we start > using more the ! form instead of == FALSE. Done. Thanks, Miao > > > + btd_error(manager->adapter_id, > > + "Failed to register " > > + ADV_MONITOR_MGR_INTERFACE); > > + manager_free(manager); > > + return NULL; > > + } > > + > > + btd_info(manager->adapter_id, > > + "Adv Monitor Manager created for adapter %s", > > + adapter_get_path(manager->adapter)); > > + > > + return manager; > > +} > > + > > +/* Destroys a manager and unregisters its D-Bus interface */ > > +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) > > +{ > > + if (!manager) > > + return; > > + > > + btd_info(manager->adapter_id, "Destroy Adv Monitor Manager"); > > + > > + manager_destroy(manager); > > +} > > diff --git a/src/adv_monitor.h b/src/adv_monitor.h > > new file mode 100644 > > index 000000000..69ea348f8 > > --- /dev/null > > +++ b/src/adv_monitor.h > > @@ -0,0 +1,32 @@ > > +/* > > + * > > + * BlueZ - Bluetooth protocol stack for Linux > > + * > > + * Copyright (C) 2020 Google LLC > > + * > > + * > > + * This program is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU Lesser General Public > > + * License as published by the Free Software Foundation; either > > + * version 2.1 of the License, or (at your option) any later version. > > + * > > + * This program is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > + * Lesser General Public License for more details. > > + * > > + */ > > + > > +#ifndef __ADV_MONITOR_H > > +#define __ADV_MONITOR_H > > + > > +struct mgmt; > > +struct btd_adapter; > > +struct btd_adv_monitor_manager; > > + > > +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( > > + struct btd_adapter *adapter, > > + struct mgmt *mgmt); > > +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); > > + > > +#endif /* __ADV_MONITOR_H */ > > -- > > 2.26.2 > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id Nd4vIiSxWV8RtwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:52:52 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id qLpMHiSxWV9j/gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:52:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BCD9B408B3; Thu, 10 Sep 2020 06:52:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726227AbgIJEwp (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725868AbgIJEwm (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:52:42 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5D1DC061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:52:41 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id u21so6435248ljl.6 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:52:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HDBgmWxbn9H5Rwy9IbT/P7gu3wkwpD9NyaConvJZ2QQ=; b=GFYiK871pFfywqy5jPo7o5rUokVvPpgBV/dvIlddPN9fmBsp/oGe7hZccaVM8TRDov NCSeAKgAEaK3CN9niHgkWJhgnTQpej6+LhUlLe2iCpCtMFI32Z7qlZ5Gjqeo3L/I9+Gc bQZFr0al4Z6BeVW4dri5vyJ0bbsut407q9MiU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HDBgmWxbn9H5Rwy9IbT/P7gu3wkwpD9NyaConvJZ2QQ=; b=TvzilW3Q6LUgn+SZmN1VDztCvFd1Y0UfbdazxVQMOVpeTsxdi6hx74DiVJwRMV1DRZ tYnkTZIaWP7nKbpaPwGKff+cSUltxFhXTxR1t2OH0v8/s5kkzNN7r+0AjPqD9e/msRyM lsLzMkXWw0jkJUHDukiLuMksCmIZumdhE5Jsc6UFIdFykEM4peISZ5xPoCuIywA9IuZg rbloPrh6/D/1i26F1nW0MKH5N7JVPqdlIpwUEhzs6QTjdGUO/e8gk7Z4OiwQkJsZC3Ze ehq5MQWKw0s3O2W7j12NOqbP+BnvyIGDZYB9B8U/oqx007Qh9CWpK1XSdk7V7a9I5mRM 4yOQ== X-Gm-Message-State: AOAM533HZtSVj0CbUxE7XV2BXNtxkE1fjLT8Ym788YXHfov8/aPufDSr rIaA4dFRuWAhIDA+FsTNJPknozb59ZMXMLpk0ZXSww== X-Google-Smtp-Source: ABdhPJw85A3XmEhpl77VC09n0+DDKSkqdJFNhGhgasZMg4DMWTzs37/TIB6xeLfrrdwl3LaIsP9bFQirQ3X+KhCDXRI= X-Received: by 2002:a2e:8552:: with SMTP id u18mr3552639ljj.359.1599713560083; Wed, 09 Sep 2020 21:52:40 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <20200818152612.BlueZ.v1.3.I19ff9cdbd40fe453db0e81aec8bf94dd9490dce3@changeid> <CABBYNZ+EgjjuiyiUaFDAhM1tzmvh6+w5ERA4omtfNgYy86ek7A@mail.gmail.com> In-Reply-To: <CABBYNZ+EgjjuiyiUaFDAhM1tzmvh6+w5ERA4omtfNgYy86ek7A@mail.gmail.com> From: Miao-chen Chou <mcchou@chromium.org> Date: Wed, 9 Sep 2020 21:52:29 -0700 Message-ID: <CABmPvSG67wepg0wggf-r=wRhn_Lp8GgJ8Br5+fJg60=z=A5+yw@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 3/7] adv_monitor: Implement RegisterMonitor() To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.64 / 15.00 / 15.00 X-Rspamd-Queue-Id: BCD9B408B3 X-Rspamd-UID: cc5c17 Hi Luiz, On Tue, Sep 8, 2020 at 10:25 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Miao, > > On Tue, Aug 18, 2020 at 3:31 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > This implements the RegisterMonitor() method handler of ADV monitor > > manager interface. > > > > The following tests were performed. > > - Issue a RegisterMonitor() call with a valid path and expect a > > success as return. > > - Issue a RegisterMonitor() call with an invalid path and expect > > org.bluez.Error.InvalidArguments as return. > > - Issue two Registermonitor() calls with the same path and expect > > org.bluez.Error.AlreadyExists. > > - Verify the values of the registered paths with logging. > > - Verify D-Bus disconnection callback was triggered when the client detach > > from D-Bus. > > > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > --- > > > > src/adv_monitor.c | 167 +++++++++++++++++++++++++++++++++++++++++++++- > > 1 file changed, 166 insertions(+), 1 deletion(-) > > > > diff --git a/src/adv_monitor.c b/src/adv_monitor.c > > index 4d02237e8..3d27ad18b 100644 > > --- a/src/adv_monitor.c > > +++ b/src/adv_monitor.c > > @@ -22,7 +22,9 @@ > > #endif > > > > #define _GNU_SOURCE > > +#include <errno.h> > > #include <stdint.h> > > +#include <string.h> > > > > #include <glib.h> > > #include <dbus/dbus.h> > > @@ -34,7 +36,9 @@ > > #include "adapter.h" > > #include "dbus-common.h" > > #include "log.h" > > +#include "src/error.h" > > #include "src/shared/mgmt.h" > > +#include "src/shared/queue.h" > > #include "src/shared/util.h" > > > > #include "adv_monitor.h" > > @@ -52,12 +56,170 @@ struct btd_adv_monitor_manager { > > uint16_t max_num_monitors; > > uint8_t max_num_patterns; > > > > + struct queue *apps; /* apps who registered for Adv monitoring */ > > }; > > > > +struct adv_monitor_app { > > + struct btd_adv_monitor_manager *manager; > > + char *owner; > > + char *path; > > + > > + DBusMessage *reg; > > + GDBusClient *client; > > +}; > > + > > +struct app_match_data { > > + const char *owner; > > + const char *path; > > +}; > > + > > +/* Replies to an app's D-Bus message and unref it */ > > +static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) > > +{ > > + if (!app || !app->reg || !reply) > > + return; > > + > > + g_dbus_send_message(btd_get_dbus_connection(), reply); > > + dbus_message_unref(app->reg); > > + app->reg = NULL; > > +} > > + > > +/* Destroys an app object along with related D-Bus handlers */ > > +static void app_destroy(void *data) > > +{ > > + struct adv_monitor_app *app = data; > > + > > + if (!app) > > + return; > > + > > + DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); > > + > > + if (app->reg) { > > + app_reply_msg(app, btd_error_failed(app->reg, > > + "Adv Monitor app destroyed")); > > + } > > + > > + if (app->client) { > > + g_dbus_client_set_disconnect_watch(app->client, NULL, NULL); > > + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, > > + NULL); > > + g_dbus_client_set_ready_watch(app->client, NULL, NULL); > > + g_dbus_client_unref(app->client); > > + app->client = NULL; > > + } > > + > > + g_free(app->owner); > > + app->owner = NULL; > > + g_free(app->path); > > + app->path = NULL; > > Same comment as before, if the whole object would be free then there > is no need to reset each individual field. Done. > > > + > > + g_free(app); > > +} > > + > > +/* Handles a D-Bus disconnection event of an app */ > > +static void app_disconnect_cb(DBusConnection *conn, void *user_data) > > +{ > > + struct adv_monitor_app *app = user_data; > > + > > + btd_info(app->manager->adapter_id, "Adv Monitor app %s disconnected " > > + "from D-Bus", app->owner); > > + if (app && queue_remove(app->manager->apps, app)) > > + app_destroy(app); > > +} > > + > > +/* Creates an app object, initiates it and sets D-Bus event handlers */ > > +static struct adv_monitor_app *app_create(DBusConnection *conn, > > + const char *sender, const char *path, > > + struct btd_adv_monitor_manager *manager) > > +{ > > + struct adv_monitor_app *app; > > + > > + if (!path || !sender || !manager) > > + return NULL; > > + > > + app = g_new0(struct adv_monitor_app, 1); > > Please use new0 instead of g_new0 in new code. Done. > > > + if (!app) > > + return NULL; > > + > > + app->owner = g_strdup(sender); > > + app->path = g_strdup(path); > > + app->manager = manager; > > + app->reg = NULL; > > + > > + app->client = g_dbus_client_new(conn, sender, path); > > + if (!app->client) { > > + app_destroy(app); > > + return NULL; > > + } > > + > > + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); > > + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); > > + g_dbus_client_set_ready_watch(app->client, NULL, NULL); > > + > > + return app; > > +} > > + > > +/* Matches an app based on its owner and path */ > > +static bool app_match(const void *a, const void *b) > > +{ > > + const struct adv_monitor_app *app = a; > > + const struct app_match_data *match = b; > > + > > + if (match->owner && strcmp(app->owner, match->owner)) > > + return false; > > + > > + if (match->path && strcmp(app->path, match->path)) > > + return false; > > + > > + return true; > > +} > > + > > +/* Handles a RegisterMonitor D-Bus call */ > > +static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, > > + void *user_data) > > +{ > > + DBusMessageIter args; > > + struct app_match_data match; > > + struct adv_monitor_app *app; > > + struct btd_adv_monitor_manager *manager = user_data; > > + > > + if (!dbus_message_iter_init(msg, &args)) > > + return btd_error_invalid_args(msg); > > + > > + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) > > + return btd_error_invalid_args(msg); > > + > > + dbus_message_iter_get_basic(&args, &match.path); > > + > > + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) > > + return btd_error_invalid_args(msg); > > + > > + match.owner = dbus_message_get_sender(msg); > > + > > + if (queue_find(manager->apps, app_match, &match)) > > + return btd_error_already_exists(msg); > > + > > + app = app_create(conn, match.owner, match.path, manager); > > + if (!app) { > > + btd_error(manager->adapter_id, > > + "Failed to reserve %s for Adv Monitor app %s", > > + match.path, match.owner); > > + return btd_error_failed(msg, > > + "Failed to create Adv Monitor app"); > > + } > > + > > + queue_push_tail(manager->apps, app); > > + > > + btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", > > + match.path, match.owner); > > + > > + return dbus_message_new_method_return(msg); > > +} > > + > > static const GDBusMethodTable adv_monitor_methods[] = { > > { GDBUS_METHOD("RegisterMonitor", > > GDBUS_ARGS({ "application", "o" }), > > - NULL, NULL) }, > > + NULL, register_monitor) }, > > { GDBUS_ASYNC_METHOD("UnregisterMonitor", > > GDBUS_ARGS({ "application", "o" }), > > NULL, NULL) }, > > @@ -157,6 +319,7 @@ static struct btd_adv_monitor_manager *manager_new( > > manager->mgmt = mgmt_ref(mgmt); > > manager->adapter_id = btd_adapter_get_index(adapter); > > manager->path = g_strdup(adapter_get_path(manager->adapter)); > > + manager->apps = queue_new(); > > > > return manager; > > } > > @@ -170,6 +333,8 @@ static void manager_free(struct btd_adv_monitor_manager *manager) > > g_free(manager->path); > > manager->path = NULL; > > > > + queue_destroy(manager->apps, app_destroy); > > + > > g_free(manager); > > } > > > > -- > > 2.26.2 > > > > > -- > Luiz Augusto von Dentz Thanks, Miao Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6G0vEUGxWV/LgAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 06:53:21 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id cFQKDkGxWV+G9AEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 06:53:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9DC804086A; Thu, 10 Sep 2020 06:53:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726600AbgIJExM (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 00:53:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725981AbgIJExF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 00:53:05 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFE63C061573 for <linux-bluetooth@vger.kernel.org>; Wed, 9 Sep 2020 21:53:04 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id u21so6435939ljl.6 for <linux-bluetooth@vger.kernel.org>; Wed, 09 Sep 2020 21:53:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BZNWrm+gtstAC90dpi7HeJQJ7pNUj+SVExRa1Mq75FY=; b=eTDznI5NT6mr2SiIOyQB/yfbffUmIcfbYXRXSqvCJaQJ2RAM91QHNNBODpcB6GA9gV ZQuuEsPnqK0n20YVrIfDuJMeRioT9KbqeCvk45naesraP7C9pBh0qiWHwTS2rfn7D4Uf dwOG1/yKAvfCLaKc0wGYTsGQoMIcQkcvDAcRA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BZNWrm+gtstAC90dpi7HeJQJ7pNUj+SVExRa1Mq75FY=; b=ifzenaGKrFoqyBKmgL0wQYJxLFc78FbmmOUAuxDHH9V6iGD5LFX44rV3i9ZY24Bevv SUsxK3qZzZ7n/c8z4QTIM8PjNG0gDEqr8HLoUgi4wuoNth0ZK8iIwdF/MXOovfTfj8pE CjEXBRGCCNSv87TTL9hbS4LBnsiwNPbDCFX3Y0NzG7Dp0kn6tcaiMTrmqEcmSsiso7Uo PU8uVRG5Rnhg+3o4BZfrrdXHOz2wXQwA5Ilnx6y1I4SeaReN374Ny7Y2buTs0Dp+uUKL Zq+xYRltV6gqoKP/zknRtXBa2mA+JAiB5qdvY8WG62hpMKlDeYG6+eevIc+3lInd8SOL uoQg== X-Gm-Message-State: AOAM531+LwE4jrs4Xu1CQLsaeAKNBwrozfUYoddNzsWFgB9K2jR3XFXz sUULXjFDTv1h1VguRDj2Rg3C9z5h1EgFZZ+zjH9IBw== X-Google-Smtp-Source: ABdhPJynf8UEyq3A8ZXh1XrZDFQiN9S4Xm9AoX1kIlJjeJQg9d9U+xR9RQHwkm5xXfvesygT7+YUln4fel/KEtH/aLE= X-Received: by 2002:a2e:5d2:: with SMTP id 201mr3406157ljf.73.1599713583095; Wed, 09 Sep 2020 21:53:03 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <20200818152612.BlueZ.v1.6.I47744c7eef31f44cf393dea2b3e437d7b41cef79@changeid> <CABBYNZJtWjhXZ9YSPLLiuP_KTzfCxox7KCOtJJvgnHY8PMZQwg@mail.gmail.com> In-Reply-To: <CABBYNZJtWjhXZ9YSPLLiuP_KTzfCxox7KCOtJJvgnHY8PMZQwg@mail.gmail.com> From: Miao-chen Chou <mcchou@chromium.org> Date: Wed, 9 Sep 2020 21:52:52 -0700 Message-ID: <CABmPvSH=EXA+wainX4R=hNTxqkTQ-QzhbB4oo95AFN+ureTbcA@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 6/7] adv_monitor: Handle D-Bus proxy event of an ADV monitor To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.82 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9DC804086A X-Rspamd-UID: 2e8dc6 Hi Luiz, On Tue, Sep 8, 2020 at 10:36 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Miao, > > On Tue, Aug 18, 2020 at 3:31 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > This adds two handlers, one for adding and one for removing, of D-Bus proxy > > events. The handler of property changes is set to NULL as intended, > > since for simplicity no further changes on monitor's properties would > > affect the ongoing monitoring. > > > > The following test steps were performed with bluetoothctl. > > - After registering the root path, expose two monitors and verify that > > the proxy added event are received. > > - Have two monitors added, unexpose the monitors, and verify that the > > proxy removed events are received for those two monitors. > > - Have two monitors added, unregister the monitors and verify that the > > proxy removed events are received for those two monitors. > > > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > > --- > > > > src/adv_monitor.c | 492 ++++++++++++++++++++++++++++++++++++++++++++-- > > 1 file changed, 479 insertions(+), 13 deletions(-) > > > > diff --git a/src/adv_monitor.c b/src/adv_monitor.c > > index b5ea5ee99..23fbc2b45 100644 > > --- a/src/adv_monitor.c > > +++ b/src/adv_monitor.c > > @@ -37,14 +37,23 @@ > > #include "dbus-common.h" > > #include "log.h" > > #include "src/error.h" > > +#include "src/shared/ad.h" > > #include "src/shared/mgmt.h" > > #include "src/shared/queue.h" > > #include "src/shared/util.h" > > > > #include "adv_monitor.h" > > > > +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" > > #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" > > > > +#define ADV_MONITOR_UNSET_RSSI 127 /* dBm */ > > +#define ADV_MONITOR_MAX_RSSI 20 /* dBm */ > > +#define ADV_MONITOR_MIN_RSSI -127 /* dBm */ > > +#define ADV_MONITOR_UNSET_TIMER 0 /* second */ > > +#define ADV_MONITOR_MIN_TIMER 1 /* second */ > > +#define ADV_MONITOR_MAX_TIMER 300 /* second */ > > + > > struct btd_adv_monitor_manager { > > struct btd_adapter *adapter; > > struct mgmt *mgmt; > > @@ -66,6 +75,43 @@ struct adv_monitor_app { > > > > DBusMessage *reg; > > GDBusClient *client; > > + > > + struct queue *monitors; > > +}; > > + > > +enum monitor_type { > > + MONITOR_TYPE_NONE, > > + MONITOR_TYPE_OR_PATTERNS, > > +}; > > + > > +enum monitor_state { > > + MONITOR_STATE_NEW, /* New but not yet init'ed with actual values */ > > + MONITOR_STATE_FAILED, /* Failed to be init'ed */ > > + MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ > > + MONITOR_STATE_HONORED, /* Accepted by kernel */ > > +}; > > + > > +struct pattern { > > + uint8_t ad_type; > > + uint8_t offset; > > + uint8_t length; > > + uint8_t value[BT_AD_MAX_DATA_LEN]; > > +}; > > + > > +struct adv_monitor { > > + struct adv_monitor_app *app; > > + GDBusProxy *proxy; > > + char *path; > > + > > + enum monitor_state state; /* MONITOR_STATE_* */ > > + > > + int8_t high_rssi; /* high RSSI threshold */ > > + uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ > > + int8_t low_rssi; /* low RSSI threshold */ > > + uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ > > + > > + enum monitor_type type; /* MONITOR_TYPE_* */ > > + struct queue *patterns; > > }; > > > > struct app_match_data { > > @@ -73,6 +119,14 @@ struct app_match_data { > > const char *path; > > }; > > > > +const struct adv_monitor_type { > > + enum monitor_type type; > > + const char *name; > > +} supported_types[] = { > > + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, > > + { }, > > +}; > > + > > /* Replies to an app's D-Bus message and unref it */ > > static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) > > { > > @@ -84,6 +138,52 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) > > app->reg = NULL; > > } > > > > +/* Frees a pattern */ > > +static void pattern_free(void *data) > > +{ > > + struct pattern *pattern = data; > > + > > + if (!pattern) > > + return; > > + > > + g_free(pattern); > > +} > > + > > +/* Frees a monitor object */ > > +static void monitor_free(void *data) > > +{ > > + struct adv_monitor *monitor = data; > > + > > + if (!monitor) > > + return; > > + > > + monitor->app = NULL; > > + g_dbus_proxy_unref(monitor->proxy); > > + monitor->proxy = NULL; > > + g_free(monitor->path); > > + monitor->path = NULL; > > + > > + queue_destroy(monitor->patterns, pattern_free); > > + monitor->patterns = NULL; > > + > > + g_free(monitor); > > +} > > + > > +/* Calls Release() method of the remote Adv Monitor */ > > +static void monitor_release(void *data, void *user_data) > > +{ > > + struct adv_monitor *monitor = data; > > + > > + if (!monitor) > > + return; > > + > > + DBG("Calling Release() on Adv Monitor of owner %s at path %s", > > + monitor->app->owner, monitor->path); > > + > > + g_dbus_proxy_method_call(monitor->proxy, "Release", NULL, NULL, NULL, > > + NULL); > > +} > > + > > /* Destroys an app object along with related D-Bus handlers */ > > static void app_destroy(void *data) > > { > > @@ -94,6 +194,9 @@ static void app_destroy(void *data) > > > > DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); > > > > + queue_foreach(app->monitors, monitor_release, NULL); > > + queue_destroy(app->monitors, monitor_free); > > + > > if (app->reg) { > > app_reply_msg(app, btd_error_failed(app->reg, > > "Adv Monitor app destroyed")); > > @@ -139,6 +242,372 @@ static void app_ready_cb(GDBusClient *client, void *user_data) > > app_reply_msg(app, dbus_message_new_method_return(app->reg)); > > } > > > > +/* Allocates an Adv Monitor */ > > +static struct adv_monitor *monitor_new(struct adv_monitor_app *app, > > + GDBusProxy *proxy) > > +{ > > + struct adv_monitor *monitor; > > + > > + if (!app || !proxy) > > + return NULL; > > + > > + monitor = g_new0(struct adv_monitor, 1); > > new0 Done. > > > + if (!monitor) > > + return NULL; > > + > > + monitor->app = app; > > + monitor->proxy = g_dbus_proxy_ref(proxy); > > + monitor->path = g_strdup(g_dbus_proxy_get_path(proxy)); > > + > > + monitor->state = MONITOR_STATE_NEW; > > + > > + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; > > + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; > > + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; > > + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; > > + > > + monitor->type = MONITOR_TYPE_NONE; > > + monitor->patterns = NULL; > > + > > + return monitor; > > +} > > + > > +/* Matches a monitor based on its D-Bus path */ > > +static bool monitor_match(const void *a, const void *b) > > +{ > > + const GDBusProxy *proxy = b; > > + const struct adv_monitor *monitor = a; > > + > > + if (!proxy || !monitor) > > + return false; > > + > > + if (strcmp(g_dbus_proxy_get_path(proxy), monitor->path) != 0) > > + return false; > > + > > + return true; > > +} > > + > > +/* Retrieves Type from the remote Adv Monitor object, verifies the value and > > + * update the local Adv Monitor > > + */ > > +static bool parse_monitor_type(struct adv_monitor *monitor, const char *path) > > +{ > > + DBusMessageIter iter; > > + const struct adv_monitor_type *t; > > + const char *type_str; > > + uint16_t adapter_id = monitor->app->manager->adapter_id; > > + > > + if (!g_dbus_proxy_get_property(monitor->proxy, "Type", &iter)) { > > + btd_error(adapter_id, "Failed to retrieve property Type from " > > + "the Adv Monitor at path %s", path); > > + return false; > > + } > > + > > + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) > > + goto failed; > > + > > + dbus_message_iter_get_basic(&iter, &type_str); > > + > > + for (t = supported_types; t->name; t++) { > > + if (strcmp(t->name, type_str) == 0) { > > + monitor->type = t->type; > > + return true; > > + } > > + } > > + > > +failed: > > + btd_error(adapter_id, "Invalid argument of property Type of the Adv " > > + "Monitor at path %s", path); > > + > > + return false; > > +} > > + > > +/* Retrieves RSSIThresholdsAndTimers from the remote Adv Monitor object, > > + * verifies the values and update the local Adv Monitor > > + */ > > +static bool parse_rssi_and_timeout(struct adv_monitor *monitor, > > + const char *path) > > +{ > > + DBusMessageIter prop_struct, iter; > > + int16_t h_rssi, l_rssi; > > + uint16_t h_rssi_timer, l_rssi_timer; > > + uint16_t adapter_id = monitor->app->manager->adapter_id; > > + > > + /* Property RSSIThresholdsAndTimers is optional */ > > + if (!g_dbus_proxy_get_property(monitor->proxy, > > + "RSSIThresholdsAndTimers", > > + &prop_struct)) { > > + DBG("Adv Monitor at path %s provides no RSSI thresholds and " > > + "timeouts", path); > > + return true; > > + } > > + > > + if (dbus_message_iter_get_arg_type(&prop_struct) != DBUS_TYPE_STRUCT) > > + goto failed; > > + > > + dbus_message_iter_recurse(&prop_struct, &iter); > > + > > + /* Extract HighRSSIThreshold */ > > + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) > > + goto failed; > > + dbus_message_iter_get_basic(&iter, &h_rssi); > > + if (!dbus_message_iter_next(&iter)) > > + goto failed; > > + > > + /* Extract HighRSSIThresholdTimer */ > > + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) > > + goto failed; > > + dbus_message_iter_get_basic(&iter, &h_rssi_timer); > > + if (!dbus_message_iter_next(&iter)) > > + goto failed; > > + > > + /* Extract LowRSSIThreshold */ > > + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) > > + goto failed; > > + dbus_message_iter_get_basic(&iter, &l_rssi); > > + if (!dbus_message_iter_next(&iter)) > > + goto failed; > > + > > + /* Extract LowRSSIThresholdTimer */ > > + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) > > + goto failed; > > + dbus_message_iter_get_basic(&iter, &l_rssi_timer); > > + > > + /* Verify the values of RSSIs and their timers. For simplicity, we > > + * enforce the all-or-none rule to these fields. In other words, either > > + * all are set to the unset values or all are set within valid ranges. > > + */ > > + if (h_rssi == ADV_MONITOR_UNSET_RSSI && > > + l_rssi == ADV_MONITOR_UNSET_RSSI && > > + h_rssi_timer == ADV_MONITOR_UNSET_TIMER && > > + l_rssi_timer == ADV_MONITOR_UNSET_TIMER) { > > + goto done; > > + } > > + > > + if (h_rssi < ADV_MONITOR_MIN_RSSI || h_rssi > ADV_MONITOR_MAX_RSSI || > > + l_rssi < ADV_MONITOR_MIN_RSSI || > > + l_rssi > ADV_MONITOR_MAX_RSSI || h_rssi <= l_rssi) { > > + goto failed; > > + } > > + > > + if (h_rssi_timer < ADV_MONITOR_MIN_TIMER || > > + h_rssi_timer > ADV_MONITOR_MAX_TIMER || > > + l_rssi_timer < ADV_MONITOR_MIN_TIMER || > > + l_rssi_timer > ADV_MONITOR_MAX_TIMER) { > > + goto failed; > > + } > > + > > + monitor->high_rssi = h_rssi; > > + monitor->low_rssi = l_rssi; > > + monitor->high_rssi_timeout = h_rssi_timer; > > + monitor->low_rssi_timeout = l_rssi_timer; > > + > > +done: > > + DBG("Adv Monitor at %s initiated with high RSSI threshold %d, high " > > + "RSSI threshold timeout %d, low RSSI threshold %d, low RSSI " > > + "threshold timeout %d", path, monitor->high_rssi, > > + monitor->high_rssi_timeout, monitor->low_rssi, > > + monitor->low_rssi_timeout); > > + > > + return true; > > + > > +failed: > > + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; > > + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; > > + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; > > + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; > > + > > + btd_error(adapter_id, "Invalid argument of property " > > + "RSSIThresholdsAndTimers of the Adv Monitor at path %s", > > + path); > > + > > + return false; > > +} > > + > > +/* Retrieves Patterns from the remote Adv Monitor object, verifies the values > > + * and update the local Adv Monitor > > + */ > > +static bool parse_patterns(struct adv_monitor *monitor, const char *path) > > +{ > > + DBusMessageIter array, array_iter; > > + uint16_t num_patterns = 0; > > + uint16_t adapter_id = monitor->app->manager->adapter_id; > > + > > + if (!g_dbus_proxy_get_property(monitor->proxy, "Patterns", &array)) { > > + btd_error(adapter_id, "Failed to retrieve property Patterns " > > + "from the Adv Monitor at path %s", path); > > + return false; > > + } > > + > > + monitor->patterns = queue_new(); > > + > > + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY || > > + dbus_message_iter_get_element_type(&array) != > > + DBUS_TYPE_STRUCT) { > > + goto failed; > > + } > > + > > + dbus_message_iter_recurse(&array, &array_iter); > > + > > + while (dbus_message_iter_get_arg_type(&array_iter) == > > + DBUS_TYPE_STRUCT) { > > + int value_len; > > + uint8_t *value; > > + uint8_t offset, ad_type; > > + struct pattern *pattern; > > + DBusMessageIter struct_iter, value_iter; > > + > > + dbus_message_iter_recurse(&array_iter, &struct_iter); > > + > > + // Extract start position > > + if (dbus_message_iter_get_arg_type(&struct_iter) != > > + DBUS_TYPE_BYTE) { > > + goto failed; > > + } > > + dbus_message_iter_get_basic(&struct_iter, &offset); > > + if (!dbus_message_iter_next(&struct_iter)) > > + goto failed; > > + > > + // Extract AD data type > > + if (dbus_message_iter_get_arg_type(&struct_iter) != > > + DBUS_TYPE_BYTE) { > > + goto failed; > > + } > > + dbus_message_iter_get_basic(&struct_iter, &ad_type); > > + if (!dbus_message_iter_next(&struct_iter)) > > + goto failed; > > + > > + // Extract value of a pattern > > + if (dbus_message_iter_get_arg_type(&struct_iter) != > > + DBUS_TYPE_ARRAY) { > > + goto failed; > > + } > > + dbus_message_iter_recurse(&struct_iter, &value_iter); > > + dbus_message_iter_get_fixed_array(&value_iter, &value, > > + &value_len); > > + > > + // Verify the values > > + if (offset > BT_AD_MAX_DATA_LEN - 1) > > + goto failed; > > + > > + if (ad_type > BT_AD_3D_INFO_DATA && > > + ad_type != BT_AD_MANUFACTURER_DATA > > + || ad_type < BT_AD_FLAGS) { > > + goto failed; > > + } > > + > > + if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) > > + goto failed; > > + > > + pattern = g_new0(struct pattern, 1); > > new0 Done. > > > + if (!pattern) > > + goto failed; > > + > > + pattern->ad_type = ad_type; > > + pattern->offset = offset; > > + pattern->length = value_len; > > + g_memmove(pattern->value, value, pattern->length); > > This looks wrong, we shouldn't be changing the memory value points to, > this might be equivalent to memcpy so Id just use that instead. Done. > > > + > > + queue_push_tail(monitor->patterns, pattern); > > + > > + dbus_message_iter_next(&array_iter); > > + } > > + > > + /* There must be at least one pattern. */ > > + if (queue_isempty(monitor->patterns)) > > + goto failed; > > + > > + return true; > > + > > +failed: > > + queue_destroy(monitor->patterns, pattern_free); > > + monitor->patterns = NULL; > > + > > + btd_error(adapter_id, "Invalid argument of property Patterns of the " > > + "Adv Monitor at path %s", path); > > + > > + return false; > > +} > > + > > +/* Processes the content of the remote Adv Monitor */ > > +static bool monitor_process(struct adv_monitor *monitor, > > + struct adv_monitor_app *app) > > +{ > > + const char *path = g_dbus_proxy_get_path(monitor->proxy); > > + > > + monitor->state = MONITOR_STATE_FAILED; > > + > > + if (!parse_monitor_type(monitor, path)) > > + goto done; > > + > > + if (!parse_rssi_and_timeout(monitor, path)) > > + goto done; > > + > > + if (monitor->type == MONITOR_TYPE_OR_PATTERNS && > > + parse_patterns(monitor, path)) { > > + monitor->state = MONITOR_STATE_INITED; > > + } > > + > > +done: > > + return monitor->state != MONITOR_STATE_FAILED; > > +} > > + > > +/* Handles an Adv Monitor D-Bus proxy added event */ > > +static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) > > +{ > > + struct adv_monitor *monitor; > > + struct adv_monitor_app *app = user_data; > > + uint16_t adapter_id = app->manager->adapter_id; > > + const char *path = g_dbus_proxy_get_path(proxy); > > + const char *iface = g_dbus_proxy_get_interface(proxy); > > + > > + if (strcmp(iface, ADV_MONITOR_INTERFACE) != 0 || > > + !g_str_has_prefix(path, app->path)) { > > + return; > > + } > > + > > + if (queue_find(app->monitors, monitor_match, proxy)) { > > + btd_error(adapter_id, "Adv Monitor proxy already exists with " > > + "path %s", path); > > + return; > > + } > > + > > + monitor = monitor_new(app, proxy); > > + if (!monitor) { > > + btd_error(adapter_id, "Failed to allocate an Adv Monitor for " > > + "the object at %s", path); > > + return; > > + } > > + > > + if (!monitor_process(monitor, app)) { > > + monitor_release(monitor, NULL); > > + monitor_free(monitor); > > + DBG("Adv Monitor at path %s released due to invalid content", > > + path); > > + return; > > + } > > + > > + queue_push_tail(app->monitors, monitor); > > + > > + DBG("Adv Monitor allocated for the object at path %s", path); > > +} > > + > > +/* Handles the removal of an Adv Monitor D-Bus proxy */ > > +static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) > > +{ > > + struct adv_monitor *monitor; > > + struct adv_monitor_app *app = user_data; > > + > > + monitor = queue_remove_if(app->monitors, monitor_match, proxy); > > + if (monitor) { > > + DBG("Adv Monitor removed for the object at path %s", > > + monitor->path); > > + > > + /* The object was gone, so we don't need to call Release() */ > > + monitor_free(monitor); > > + } > > +} > > + > > /* Creates an app object, initiates it and sets D-Bus event handlers */ > > static struct adv_monitor_app *app_create(DBusConnection *conn, > > DBusMessage *msg, const char *sender, > > @@ -165,8 +634,17 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, > > return NULL; > > } > > > > + app->monitors = queue_new(); > > + > > g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); > > - g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); > > + > > + /* Note that any property changes on a monitor object would not affect > > + * the content of the corresponding monitor. > > + */ > > + g_dbus_client_set_proxy_handlers(app->client, monitor_proxy_added_cb, > > + monitor_proxy_removed_cb, NULL, > > + app); > > + > > g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); > > > > app->reg = dbus_message_ref(msg); > > @@ -273,18 +751,6 @@ static const GDBusMethodTable adv_monitor_methods[] = { > > { } > > }; > > > > -enum monitor_type { > > - MONITOR_TYPE_OR_PATTERNS, > > -}; > > - > > -const struct adv_monitor_type { > > - enum monitor_type type; > > - const char *name; > > -} supported_types[] = { > > - { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, > > - { }, > > -}; > > - > > /* Gets SupportedMonitorTypes property */ > > static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, > > DBusMessageIter *iter, > > -- > > 2.26.2 > > > > > -- > Luiz Augusto von Dentz Thanks, Miao Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2Bu2FBXlWV8d+wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 10:34:29 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id yPJ0ERXlWV+4UQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 10:34:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0CDEA40983; Thu, 10 Sep 2020 10:34:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730431AbgIJIds (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 04:33:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:46546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730273AbgIJIUf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 04:20:35 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9878720732; Thu, 10 Sep 2020 08:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599726002; bh=+uYj31dIE6aLQLGtOUfoRlwyftNHQyhq7bqNm1EFOzs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kMedj2nqh7AnwsubKUx2cDGygfPeMZ/DC22/dIFpecBdxjizUINcIlzCJEoaIbbIN UWw0szHE23w4EXoWTQS5bdHpXZJn+r4Qn69vCnYUsWm6z4fAaxGT/Xg3uOtH4R0Mwv MHIGn/OTGcDdKwWYo8ufZTdtJgupVMoBGdzsB9ys= Received: by pali.im (Postfix) id 736C6582; Thu, 10 Sep 2020 10:20:00 +0200 (CEST) Date: Thu, 10 Sep 2020 10:20:00 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Joseph Hwang <josephsih@chromium.org> Cc: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v3 2/2] Bluetooth: sco: new getsockopt options BT_SNDMTU/BT_RCVMTU Message-ID: <20200910082000.aiw74ll3z776yqgh@pali> References: <20200910060403.144524-1-josephsih@chromium.org> <20200910140342.v3.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200910140342.v3.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.72 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0CDEA40983 X-Rspamd-UID: 9b489e On Thursday 10 September 2020 14:04:02 Joseph Hwang wrote: > This patch defines new getsockopt options BT_SNDMTU/BT_RCVMTU > for SCO socket to be compatible with other bluetooth sockets. > These new options return the same value as option SCO_OPTIONS > which is already present on existing kernels. > > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Signed-off-by: Joseph Hwang <josephsih@chromium.org> Looks good, Reviewed-by: Pali Rohár <pali@kernel.org> > --- > > Changes in v3: > - Fixed the commit message. > > Changes in v2: > - Used BT_SNDMTU/BT_RCVMTU instead of creating a new opt name. > - Used the existing conn->mtu instead of creating a new member > in struct sco_pinfo. > - Noted that the old SCO_OPTIONS in sco_sock_getsockopt_old() > would just work as it uses sco_pi(sk)->conn->mtu. > > net/bluetooth/sco.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c > index dcf7f96ff417e6..79ffcdef0b7ad5 100644 > --- a/net/bluetooth/sco.c > +++ b/net/bluetooth/sco.c > @@ -1001,6 +1001,12 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, > err = -EFAULT; > break; > > + case BT_SNDMTU: > + case BT_RCVMTU: > + if (put_user(sco_pi(sk)->conn->mtu, (u32 __user *)optval)) > + err = -EFAULT; > + break; > + > default: > err = -ENOPROTOOPT; > break; > -- > 2.28.0.618.gf4bc123cb7-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aKgEO2LlWV85mQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 10:35:46 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +FM1OGLlWV+ORAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 10:35:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 075734097B; Thu, 10 Sep 2020 10:35:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730206AbgIJIeQ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 04:34:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:45754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730233AbgIJISq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 04:18:46 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E79C12067C; Thu, 10 Sep 2020 08:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599725925; bh=SD0dmJJv6vSBrUN7jvV2f2sRRzybcerT3eKetcVqdQw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uEINzhZcpaEtvEKwQMgt6n/OBSCCc3nE3T7XkwdRNunnBiXTVTl07NW7DRlLUa5gs nOxa12Qm6wVU+JDb4DLdTBa5ho+WxQrShDZ447/Vpjj57UKaonLgIdbVhfd9mkZ+jx u/fVgau+DWMn+eg09xHeeP5XLzkgCAX7lK9HwGfQ= Received: by pali.im (Postfix) id 49AEE582; Thu, 10 Sep 2020 10:18:42 +0200 (CEST) Date: Thu, 10 Sep 2020 10:18:42 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Joseph Hwang <josephsih@chromium.org> Cc: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v3 1/2] Bluetooth: btusb: define HCI packet sizes of USB Alts Message-ID: <20200910081842.yunymr2l4fnle5nl@pali> References: <20200910060403.144524-1-josephsih@chromium.org> <20200910140342.v3.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200910140342.v3.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.27 / 15.00 / 15.00 X-Rspamd-Queue-Id: 075734097B X-Rspamd-UID: f4baf9 On Thursday 10 September 2020 14:04:01 Joseph Hwang wrote: > It is desirable to define the HCI packet payload sizes of > USB alternate settings so that they can be exposed to user > space. > > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > --- > > Changes in v3: > - Set hdev->sco_mtu to rp->sco_mtu if the latter is smaller. > > Changes in v2: > - Used sco_mtu instead of a new sco_pkt_len member in hdev. > - Do not overwrite hdev->sco_mtu in hci_cc_read_buffer_size > if it has been set in the USB interface. > > drivers/bluetooth/btusb.c | 45 +++++++++++++++++++++++++++++---------- > net/bluetooth/hci_event.c | 14 +++++++++++- > 2 files changed, 47 insertions(+), 12 deletions(-) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index fe80588c7bd3a8..651d5731a6c6cf 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -459,6 +459,24 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { > #define BTUSB_WAKEUP_DISABLE 14 > #define BTUSB_USE_ALT1_FOR_WBS 15 > > +/* Per core spec 5, vol 4, part B, table 2.1, > + * list the hci packet payload sizes for various ALT settings. > + * This is used to set the packet length for the wideband speech. > + * If a controller does not probe its usb alt setting, the default > + * value will be 0. Any clients at upper layers should interpret it > + * as a default value and set a proper packet length accordingly. > + * > + * To calculate the HCI packet payload length: > + * for alternate settings 1 - 5: > + * hci_packet_size = suggested_max_packet_size * 3 (packets) - > + * 3 (HCI header octets) > + * for alternate setting 6: > + * hci_packet_size = suggested_max_packet_size - 3 (HCI header octets) > + * where suggested_max_packet_size is {9, 17, 25, 33, 49, 63} > + * for alt settings 1 - 6. Thank you for update, now I see what you mean! > + */ > +static const int hci_packet_size_usb_alt[] = { 0, 24, 48, 72, 96, 144, 60 }; Now the another question, why you are using hci_packet_size_usb_alt[1] and hci_packet_size_usb_alt[6] values from this array? > + > struct btusb_data { > struct hci_dev *hdev; > struct usb_device *udev; > @@ -3959,6 +3977,15 @@ static int btusb_probe(struct usb_interface *intf, > hdev->notify = btusb_notify; > hdev->prevent_wake = btusb_prevent_wake; > > + if (id->driver_info & BTUSB_AMP) { > + /* AMP controllers do not support SCO packets */ > + data->isoc = NULL; > + } else { > + /* Interface orders are hardcoded in the specification */ > + data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); > + data->isoc_ifnum = ifnum_base + 1; > + } > + > #ifdef CONFIG_PM > err = btusb_config_oob_wake(hdev); > if (err) > @@ -4022,6 +4049,10 @@ static int btusb_probe(struct usb_interface *intf, > hdev->set_diag = btintel_set_diag; > hdev->set_bdaddr = btintel_set_bdaddr; > hdev->cmd_timeout = btusb_intel_cmd_timeout; > + > + if (btusb_find_altsetting(data, 6)) > + hdev->sco_mtu = hci_packet_size_usb_alt[6]; Why you are setting this sco_mtu only for Intel adapter? Is not this whole code generic to USB? > + > set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); > set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); > set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); > @@ -4063,15 +4094,6 @@ static int btusb_probe(struct usb_interface *intf, > btusb_check_needs_reset_resume(intf); > } > > - if (id->driver_info & BTUSB_AMP) { > - /* AMP controllers do not support SCO packets */ > - data->isoc = NULL; > - } else { > - /* Interface orders are hardcoded in the specification */ > - data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); > - data->isoc_ifnum = ifnum_base + 1; > - } > - > if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) && > (id->driver_info & BTUSB_REALTEK)) { > hdev->setup = btrtl_setup_realtek; > @@ -4083,9 +4105,10 @@ static int btusb_probe(struct usb_interface *intf, > * (DEVICE_REMOTE_WAKEUP) > */ > set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); > - if (btusb_find_altsetting(data, 1)) > + if (btusb_find_altsetting(data, 1)) { > set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); > - else > + hdev->sco_mtu = hci_packet_size_usb_alt[1]; And this part of code which you write is Realtek specific. I thought that this is something generic to bluetooth usb as you pointed to bluetooth documentation "core spec 5, vol 4, part B, table 2.1". > + } else > bt_dev_err(hdev, "Device does not support ALT setting 1"); > } Also this patch seems to be for me incomplete or not fully correct as USB altsetting is chosen in function btusb_work() and it depends on selected AIR mode (which is configured by another setsockopt). So despite what is written in commit message, this patch looks for me like some hack for Intel and Realtek bluetooth adapters and does not solve problems in vendor independent manner. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yL2SCn8AWl+ZwAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 12:31:27 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id COoKCH8AWl8iTgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 12:31:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DD0B5A016F; Thu, 10 Sep 2020 12:31:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730413AbgIJKbT (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 06:31:19 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:15346 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726600AbgIJKbO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 06:31:14 -0400 Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 10 Sep 2020 03:31:13 -0700 Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 10 Sep 2020 03:31:12 -0700 Received: from gubbaven-linux.qualcomm.com ([10.206.64.32]) by ironmsg01-blr.qualcomm.com with ESMTP; 10 Sep 2020 16:00:44 +0530 Received: by gubbaven-linux.qualcomm.com (Postfix, from userid 2365015) id BE530213A1; Thu, 10 Sep 2020 16:00:45 +0530 (IST) From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org, Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Subject: [RESEND v1 1/2] Bluetooth: hci_serdev: Close UART port if NON_PERSISTENT_SETUP is set Date: Thu, 10 Sep 2020 16:00:42 +0530 Message-Id: <1599733843-20311-2-git-send-email-gubbaven@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599733843-20311-1-git-send-email-gubbaven@codeaurora.org> References: <1599733843-20311-1-git-send-email-gubbaven@codeaurora.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.07 / 15.00 / 15.00 X-Rspamd-Queue-Id: DD0B5A016F X-Rspamd-UID: a83c3a When HCI_QUIRK_NON_PERSISTENT_SETUP is set by drivers, it indicates that BT SoC will be completely powered OFF during BT OFF. On next BT ON firmware must be downloaded again. Holding UART port open during BT OFF is draining the battery. Now during BT OFF, UART port is closed if qurik HCI_QUIRK_NON_PERSISTENT_SETUP is set by clearing HCI_UART_PROTO_READY proto flag. On next BT ON, UART port is opened if HCI_UART_PROTO_READY proto flag is cleared. Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> --- drivers/bluetooth/hci_serdev.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index 3977bba..ef96ad0 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -113,8 +113,22 @@ static int hci_uart_flush(struct hci_dev *hdev) /* Initialize device */ static int hci_uart_open(struct hci_dev *hdev) { + struct hci_uart *hu = hci_get_drvdata(hdev); + int err; + BT_DBG("%s %p", hdev->name, hdev); + /* When Quirk HCI_QUIRK_NON_PERSISTENT_SETUP is set by + * driver, BT SoC is completely turned OFF during + * BT OFF. Upon next BT ON UART port should be opened. + */ + if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) { + err = serdev_device_open(hu->serdev); + if (err) + return err; + set_bit(HCI_UART_PROTO_READY, &hu->flags); + } + /* Undo clearing this from hci_uart_close() */ hdev->flush = hci_uart_flush; @@ -124,11 +138,25 @@ static int hci_uart_open(struct hci_dev *hdev) /* Close device */ static int hci_uart_close(struct hci_dev *hdev) { + struct hci_uart *hu = hci_get_drvdata(hdev); + BT_DBG("hdev %p", hdev); + if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) + return 0; + hci_uart_flush(hdev); hdev->flush = NULL; + /* When QUIRK HCI_QUIRK_NON_PERSISTENT_SETUP is set by driver, + * BT SOC is completely powered OFF during BT OFF, holding port + * open may drain the battery. + */ + if (test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) { + clear_bit(HCI_UART_PROTO_READY, &hu->flags); + serdev_device_close(hu->serdev); + } + return 0; } @@ -354,8 +382,6 @@ void hci_uart_unregister_device(struct hci_uart *hu) { struct hci_dev *hdev = hu->hdev; - clear_bit(HCI_UART_PROTO_READY, &hu->flags); - cancel_work_sync(&hu->init_ready); if (test_bit(HCI_UART_REGISTERED, &hu->flags)) hci_unregister_dev(hdev); @@ -364,6 +390,10 @@ void hci_uart_unregister_device(struct hci_uart *hu) cancel_work_sync(&hu->write_work); hu->proto->close(hu); - serdev_device_close(hu->serdev); + + if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) { + clear_bit(HCI_UART_PROTO_READY, &hu->flags); + serdev_device_close(hu->serdev); + } } EXPORT_SYMBOL_GPL(hci_uart_unregister_device); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ILEULooAWl/LsQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 12:31:38 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YGsiK4oAWl+leQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 12:31:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0CCE7A0218; Thu, 10 Sep 2020 12:31:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730306AbgIJKbR (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 06:31:17 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:15346 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725913AbgIJKbM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 06:31:12 -0400 Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 10 Sep 2020 03:31:12 -0700 Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 10 Sep 2020 03:31:10 -0700 Received: from gubbaven-linux.qualcomm.com ([10.206.64.32]) by ironmsg01-blr.qualcomm.com with ESMTP; 10 Sep 2020 16:00:44 +0530 Received: by gubbaven-linux.qualcomm.com (Postfix, from userid 2365015) id B073B21993; Thu, 10 Sep 2020 16:00:45 +0530 (IST) From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org, Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Subject: [RESEND v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set Date: Thu, 10 Sep 2020 16:00:41 +0530 Message-Id: <1599733843-20311-1-git-send-email-gubbaven@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.84 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0CCE7A0218 X-Rspamd-UID: 409713 When HCI_QUIRK_NON_PERSISTENT_SETUP is set by drivers, it indicates that BT SoC will be completely powered OFF during BT OFF. On next BT ON firmware must be downloaded again. Holding UART port open during BT OFF is draining the battery. Now during BT OFF, UART port is closed if qurik HCI_QUIRK_NON_PERSISTENT_SETUP is set by clearing HCI_UART_PROTO_READY proto flag. On next BT ON, UART port is opened if HCI_UART_PROTO_READY proto flag is cleared. Venkata Lakshmi Narayana Gubba (2): Bluetooth: hci_serdev: Close UART port if NON_PERSISTENT_SETUP is set Bluetooth: hci_qca: Remove duplicate power off in proto close drivers/bluetooth/hci_qca.c | 5 ++--- drivers/bluetooth/hci_serdev.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CNciCKgAWl/LsQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 12:32:08 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kCAsBagAWl8gQQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 12:32:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AE1BAA0B0E; Thu, 10 Sep 2020 12:32:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730567AbgIJKbf (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 06:31:35 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:15633 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729275AbgIJKbP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 06:31:15 -0400 Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 10 Sep 2020 03:31:15 -0700 Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 10 Sep 2020 03:31:14 -0700 Received: from gubbaven-linux.qualcomm.com ([10.206.64.32]) by ironmsg01-blr.qualcomm.com with ESMTP; 10 Sep 2020 16:00:45 +0530 Received: by gubbaven-linux.qualcomm.com (Postfix, from userid 2365015) id D569721B5F; Thu, 10 Sep 2020 16:00:45 +0530 (IST) From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org, Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Subject: [RESEND v1 2/2] Bluetooth: hci_qca: Remove duplicate power off in proto close Date: Thu, 10 Sep 2020 16:00:43 +0530 Message-Id: <1599733843-20311-3-git-send-email-gubbaven@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599733843-20311-1-git-send-email-gubbaven@codeaurora.org> References: <1599733843-20311-1-git-send-email-gubbaven@codeaurora.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.08 / 15.00 / 15.00 X-Rspamd-Queue-Id: AE1BAA0B0E X-Rspamd-UID: 1894cc During serdev unregister, hdev->shutdown is called before proto close. Removing duplicates power OFF call. Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> --- drivers/bluetooth/hci_qca.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 20e1ded..f0d9ee3 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -693,8 +693,6 @@ static int qca_close(struct hci_uart *hu) destroy_workqueue(qca->workqueue); qca->hu = NULL; - qca_power_shutdown(hu); - kfree_skb(qca->rx_skb); hu->priv = NULL; @@ -2032,8 +2030,9 @@ static int qca_serdev_probe(struct serdev_device *serdev) static void qca_serdev_remove(struct serdev_device *serdev) { struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev); + struct qca_power *power = qcadev->bt_power; - if (qca_is_wcn399x(qcadev->btsoc_type)) + if (qca_is_wcn399x(qcadev->btsoc_type) && power->vregs_on) qca_power_shutdown(&qcadev->serdev_hu); else if (qcadev->susclk) clk_disable_unprepare(qcadev->susclk); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KG5zCkgBWl/LsQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 12:34:48 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id kFJxBkgBWl9qqQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 12:34:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B2FCE4098C; Thu, 10 Sep 2020 12:34:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbgIJKef (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 06:34:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729413AbgIJKeO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 06:34:14 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E651C061757 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 03:34:08 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id w126so3261746qka.5 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 03:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=Zpwn8gvMJpxff1Ws3zTTj/vOYLQA3DOLwBZC5xvqpwM=; b=VqeeXAZTCFsGyXW/CvnYnxrPu/IJREt9iwRCl+24a+ACrEHcecUpQsEy0OLRQiM0GR h7qEYMGfFtO+gCnFCSMDUST0QwkapPnNzCEl+4zqFgptCcxobkTM1Plfy1NY+MjgEkmn 2ukSl87QMQYiTCLja7/W75KAh9hz5IlLoihpDz4RHci0XNhDoZoETpeZ4Hn8VO0IAuU8 56SAe62OmcPCazQMy20OXb/8NIMzgr+pEez/BAmDhoINiBkvGBpO7mX8IaxyQHEHnIPE TU2nfwZOgYUUqOUXywnZAJwm57DSzR4MvNmf00kltcONV1rXQwcJMPnc5D+4zrxIAToy 9upg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=Zpwn8gvMJpxff1Ws3zTTj/vOYLQA3DOLwBZC5xvqpwM=; b=uYmR1QEuLwCNyS2jbWdsT/ATg0c9rppmBIM92sRXb+8A05uEMus/yp06W8fKzUwFVg y29T4juQqNDeP24EKOTcRS0g/nsoCxj5nx8ss3GmQB5syNUL7YS1L7x06ohMw+ySFLJj L0muVT/iktURhbjmxle7GG3ZM5tOe22+h2KV4eTqewqa7v8azyNAO3uAthhYJbm1tmM2 Yhv2WTM1k6xJ2lmsphbbL1m71x0xrwvnR/alQ87975xsEmk1ojK7gBdoNpWjdzUSmiMz 1o0oQXzg8qXtbd4T0VZQiDr322zyRCDb1z0FyRdKhTHkbihMM5+Ce7POBf5GIXGyWAIp ayNg== X-Gm-Message-State: AOAM532WXk1sQSEgwFiyd3ulgVlA0H9QwvE8M3LUZlUbXajGtEzMfHqP Uc8HiUd/n0T6ZEjUGsu3BF8vm21jF1qcFYJjlBaqdMpCk3AP5khqcCWiFsRlSOa8WmDmn9okmQ+ RaxA9B5+XuYqGS8JbrW45CvaYyxjBq4EQBMka1duZeZYHeR8IMcRLvKRwbKg1c/GNpggNLrWI33 qLxrKrP5qArzw= X-Google-Smtp-Source: ABdhPJx3gattaCXPEmv0BwIxj4mHNnUO5EkxymphX3zmvwdglS23T6+hstqPOZZq7Phi7wymn+FqWjYwj1nkOlaUTQ== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:4891:: with SMTP id bv17mr8255883qvb.23.1599734047055; Thu, 10 Sep 2020 03:34:07 -0700 (PDT) Date: Thu, 10 Sep 2020 18:33:59 +0800 Message-Id: <20200910183329.BlueZ.v2.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog Subject: [BlueZ PATCH v2 1/4] PRE-UPSTREAM: client: Implement basic interface of ADV monitor in bluetoothctl From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.18 / 15.00 / 15.00 X-Rspamd-Queue-Id: B2FCE4098C X-Rspamd-UID: aeb307 This patch implements some basic functions for ADV monitor in bluetoothctl [bluetooth]# show ... Advertisement Monitor Features: SupportedMonitorTypes: or_patterns Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v2: - Update the add-pattern usage - Fix storage class declaration issue Makefile.tools | 2 + client/advertisement_monitor.c | 161 +++++++++++++++++++++++++++++++++ client/advertisement_monitor.h | 23 +++++ client/main.c | 28 ++++++ 4 files changed, 214 insertions(+) create mode 100644 client/advertisement_monitor.c create mode 100644 client/advertisement_monitor.h diff --git a/Makefile.tools b/Makefile.tools index 9b9236609..88d9684a7 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -7,6 +7,8 @@ client_bluetoothctl_SOURCES = client/main.c \ client/agent.h client/agent.c \ client/advertising.h \ client/advertising.c \ + client/advertisement_monitor.h \ + client/advertisement_monitor.c \ client/gatt.h client/gatt.c client_bluetoothctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \ $(GLIB_LIBS) $(DBUS_LIBS) -lreadline diff --git a/client/advertisement_monitor.c b/client/advertisement_monitor.c new file mode 100644 index 000000000..a3218fa02 --- /dev/null +++ b/client/advertisement_monitor.c @@ -0,0 +1,161 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdbool.h> +#include <string.h> + +#include "gdbus/gdbus.h" +#include "src/shared/util.h" +#include "src/shared/shell.h" +#include "advertisement_monitor.h" + +#define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" + +static struct adv_monitor_manager { + GSList *supported_types; + GSList *supported_features; + GDBusProxy *proxy; + gboolean app_registered; +} manager = { NULL, NULL, NULL, FALSE }; + +static void set_supported_list(GSList **list, DBusMessageIter *iter) +{ + char *str; + DBusMessageIter subiter; + + dbus_message_iter_recurse(iter, &subiter); + while (dbus_message_iter_get_arg_type(&subiter) == + DBUS_TYPE_STRING) { + dbus_message_iter_get_basic(&subiter, &str); + *list = g_slist_append(*list, str); + dbus_message_iter_next(&subiter); + } +} + +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy) +{ + DBusMessageIter iter; + + if (manager.proxy != NULL || manager.supported_types != NULL || + manager.supported_features != NULL) { + bt_shell_printf("advertisement monitor manager already " + "added\n"); + return; + } + + manager.proxy = proxy; + + if (g_dbus_proxy_get_property(proxy, "SupportedMonitorTypes", &iter)) + set_supported_list(&(manager.supported_types), &iter); + + if (g_dbus_proxy_get_property(proxy, "SupportedFeatures", &iter)) + set_supported_list(&(manager.supported_features), &iter); + +} + +void adv_monitor_remove_manager(DBusConnection *conn) +{ + if (manager.supported_types != NULL) + g_slist_free(g_steal_pointer(&(manager.supported_types))); + if (manager.supported_features != NULL) + g_slist_free(g_steal_pointer(&(manager.supported_features))); + manager.proxy = NULL; + manager.app_registered = FALSE; +} + +static void register_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = ADV_MONITOR_APP_PATH; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +static void register_reply(DBusMessage *message, void *user_data) +{ + DBusConnection *conn = user_data; + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == FALSE) { + bt_shell_printf("AdvertisementMonitor path registered\n"); + } else { + bt_shell_printf("Failed to register path: %s\n", error.name); + dbus_error_free(&error); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } +} + +static void unregister_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = ADV_MONITOR_APP_PATH; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +static void unregister_reply(DBusMessage *message, void *user_data) +{ + DBusConnection *conn = user_data; + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == FALSE) { + bt_shell_printf("AdvertisementMonitor path unregistered\n"); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + bt_shell_printf("Failed to unregister Advertisement Monitor:" + " %s\n", error.name); + dbus_error_free(&error); + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + +void adv_monitor_register_app(DBusConnection *conn) +{ + if (manager.supported_types == NULL || manager.app_registered == TRUE || + g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", + register_setup, register_reply, + NULL, NULL) == FALSE) { + bt_shell_printf("Failed to register Advertisement Monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + manager.app_registered = TRUE; +} + +void adv_monitor_unregister_app(DBusConnection *conn) +{ + if (manager.app_registered == FALSE || + g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", + unregister_setup, unregister_reply, + NULL, NULL) == FALSE) { + bt_shell_printf("Failed to unregister Advertisement Monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + manager.app_registered = FALSE; +} diff --git a/client/advertisement_monitor.h b/client/advertisement_monitor.h new file mode 100644 index 000000000..77b0b62c6 --- /dev/null +++ b/client/advertisement_monitor.h @@ -0,0 +1,23 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); +void adv_monitor_remove_manager(DBusConnection *conn); +void adv_monitor_register_app(DBusConnection *conn); +void adv_monitor_unregister_app(DBusConnection *conn); diff --git a/client/main.c b/client/main.c index da877b546..6bca738a0 100644 --- a/client/main.c +++ b/client/main.c @@ -41,6 +41,7 @@ #include "agent.h" #include "gatt.h" #include "advertising.h" +#include "advertisement_monitor.h" /* String display constants */ #define COLORED_NEW COLOR_GREEN "NEW" COLOR_OFF @@ -58,6 +59,7 @@ static char *auto_register_agent = NULL; struct adapter { GDBusProxy *proxy; GDBusProxy *ad_proxy; + GDBusProxy *adv_monitor_proxy; GList *devices; }; @@ -528,6 +530,19 @@ static void ad_manager_added(GDBusProxy *proxy) adapter->ad_proxy = proxy; } +static void admon_manager_added(GDBusProxy *proxy) +{ + struct adapter *adapter; + + adapter = find_ctrl(ctrl_list, g_dbus_proxy_get_path(proxy)); + if (!adapter) + adapter = adapter_new(proxy); + + adapter->adv_monitor_proxy = proxy; + adv_monitor_add_manager(dbus_conn, proxy); + adv_monitor_register_app(dbus_conn); +} + static void proxy_added(GDBusProxy *proxy, void *user_data) { const char *interface; @@ -560,6 +575,9 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) ad_manager_added(proxy); } else if (!strcmp(interface, "org.bluez.Battery1")) { battery_added(proxy); + } else if (!strcmp(interface, + "org.bluez.AdvertisementMonitorManager1")) { + admon_manager_added(proxy); } } @@ -653,6 +671,9 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) ad_unregister(dbus_conn, NULL); } else if (!strcmp(interface, "org.bluez.Battery1")) { battery_removed(proxy); + } else if (!strcmp(interface, + "org.bluez.AdvertisementMonitorManager1")) { + adv_monitor_remove_manager(dbus_conn); } } @@ -935,6 +956,13 @@ static void cmd_show(int argc, char *argv[]) print_property(adapter->ad_proxy, "SupportedSecondaryChannels"); } + if (adapter->adv_monitor_proxy) { + bt_shell_printf("Advertisement Monitor Features:\n"); + print_property(adapter->adv_monitor_proxy, + "SupportedMonitorTypes"); + print_property(adapter->adv_monitor_proxy, "SupportedFeatures"); + } + return bt_shell_noninteractive_quit(EXIT_SUCCESS); } -- 2.28.0.526.ge36021eeef-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IAtHOE8BWl/LsQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 12:34:55 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id OJItNU8BWl8MAwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 12:34:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8F18840962; Thu, 10 Sep 2020 12:34:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729413AbgIJKei (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 06:34:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730150AbgIJKeO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 06:34:14 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6DA9C0613ED for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 03:34:11 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id c78so5044612ybf.6 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 03:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=xCMcRsMmWYoQlCQ5W1NxkosyVWQq/eQfJQimgO2sIgI=; b=umD1BI4YTXW719C8MHDboWensW1rZHnE5Go/7OlGd3G3+JjlbkCla9jQuRrnph1CHJ T4IA2zkkNXtg7gaOhAH269TS4sUSPUb9Ex0wAkmAu3xBP9pHVw8al/t6/cWzvYyLeAN4 ZsVFWzdX132qUkgWftKCReQKprj9QGx23ugraWSNfvuelu6XVjPsiz6AochKGKxxfjYo 5wV+Kr7mfeqF+wowrg5uAeDa9pyuDUclKDUqqJvCGzBxHBWnzcv7CvUuFGi5tJCwQ7mm BGNNXL5aUGI4SVqeGAHseHjIUYRAzGC6pPPJ91GBhwGrTr6AwOawCQ+0ASMoZVJw8VR6 4oyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xCMcRsMmWYoQlCQ5W1NxkosyVWQq/eQfJQimgO2sIgI=; b=fxgxYYQIGuiK4T68FhU0lHICuHuDc3CNo9NS9RU5HQqhvy5rHmyivLV2qv56gMEp6y s5meMogyBZkTKgyuTr+t1qhub1qLhHgToMcrNwZK2lZkXkA/QCR83n6SmWXuYWI0FSmq 6se7iNMjgUE7aQj2aZuAyfCfTKZjfR7jql31wCdLDYc/DwRMvglQHs3awMjz1nQ0zU6e fAAAd2UvC3AJ8ylr9rH6hZ26SmYCWdw/N2qJsRVmPzagfMOA8zI2RWjfxnItIieuIh98 GB6pRMdGFxa9SiedKST31nRF11KmrTup9xbRTR3XNIrBv1jHO08yAKaWKIhjJQ9gdmU0 XYqw== X-Gm-Message-State: AOAM532w6Z6vax4ZGQEF1SQ56IBgT+m6pfGYtFuy+46qsA1geLjhGQNo rhK3+f3/eRZ4LDijD+GhC7Nz0K+fWsXgZs4sH5Of7SBygYKPvhFSmpLUAQSmGUKU/xfgwKBjnhz Cq/KzPJezFea6p/YRTROXaej4gcu/hBUIX1XM9Vld197ES3lllARkCLW8au3bXfWWKmDGqdXDY2 7j7poYpb5CZU4= X-Google-Smtp-Source: ABdhPJzJ0YrG+W30bEkYBu7mkiFk978sKk+b6dU000TJnPLJauGyhyRUlBfhADTYgZ1WRV6Y8UpPv7+LDWgZexGjoQ== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a25:e683:: with SMTP id d125mr11685194ybh.1.1599734050841; Thu, 10 Sep 2020 03:34:10 -0700 (PDT) Date: Thu, 10 Sep 2020 18:34:00 +0800 In-Reply-To: <20200910183329.BlueZ.v2.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200910183329.BlueZ.v2.2.Iec6b15e23f4228b80f9b364eb76515d146d592d5@changeid> Mime-Version: 1.0 References: <20200910183329.BlueZ.v2.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog Subject: [BlueZ PATCH v2 2/4] PRE-UPSTREAM: client: Implement more interfaces of ADV monitor in bluetoothctl From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.18 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8F18840962 X-Rspamd-UID: 74c443 This patch creates a submenu in bluetoothctl and implements several commands. new commands: [bluetooth]# menu monitor [bluetooth]# add-or-pattern 1 2 ab0011 Advertisement Monitor 0 added [bluetooth]# add-or-pattern-rssi -80, ,5 1 2 aa 3 4 ff Advertisement Monitor 1 added [bluetooth]# get-pattern all Advertisement Monitor 0 path: /org/bluez/adv_monitor_app/0 type: or_patterns pattern 1: start position: 1 AD data type: 2 content: ab0011 Advertisement Monitor 1 path: /org/bluez/adv_monitor_app/1 type: or_patterns rssi: high threshold: -50 high threshold timer: 5 low threshold: -80 low threshold timer: 5 pattern 1: start position: 1 AD data type: 2 content: aa pattern 2: start position: 3 AD data type: 4 content: ff [bluetooth]# get-supported-info Supported Features: Supported Moniter Types: or_patterns [bluetooth]# remove-pattern 0 Monitor 0 deleted Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v2: - Update add-pattern usage client/advertisement_monitor.c | 352 ++++++++++++++++++++++++++++++++- client/advertisement_monitor.h | 10 + client/main.c | 109 ++++++++++ 3 files changed, 468 insertions(+), 3 deletions(-) diff --git a/client/advertisement_monitor.c b/client/advertisement_monitor.c index a3218fa02..0b2f7f407 100644 --- a/client/advertisement_monitor.c +++ b/client/advertisement_monitor.c @@ -29,6 +29,7 @@ #include <string.h> #include "gdbus/gdbus.h" +#include "src/shared/ad.h" #include "src/shared/util.h" #include "src/shared/shell.h" #include "advertisement_monitor.h" @@ -36,6 +37,27 @@ #define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" +struct rssi_setting { + int16_t high_threshold; + uint16_t high_timer; + int16_t low_threshold; + uint16_t low_timer; +}; + +struct pattern { + uint8_t start_pos; + uint8_t ad_data_type; + uint8_t content_len; + uint8_t content[BT_AD_MAX_DATA_LEN]; +}; + +struct adv_monitor { + uint8_t idx; + char *type; + struct rssi_setting *rssi; + GSList *patterns; +}; + static struct adv_monitor_manager { GSList *supported_types; GSList *supported_features; @@ -43,6 +65,9 @@ static struct adv_monitor_manager { gboolean app_registered; } manager = { NULL, NULL, NULL, FALSE }; +static uint8_t adv_mon_idx; +static GSList *adv_mons; + static void set_supported_list(GSList **list, DBusMessageIter *iter) { char *str; @@ -138,7 +163,10 @@ static void unregister_reply(DBusMessage *message, void *user_data) void adv_monitor_register_app(DBusConnection *conn) { - if (manager.supported_types == NULL || manager.app_registered == TRUE || + if (manager.app_registered == TRUE) { + bt_shell_printf("Advertisement Monitor already registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } else if (manager.supported_types == NULL || g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", register_setup, register_reply, NULL, NULL) == FALSE) { @@ -150,8 +178,10 @@ void adv_monitor_register_app(DBusConnection *conn) void adv_monitor_unregister_app(DBusConnection *conn) { - if (manager.app_registered == FALSE || - g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", + if (manager.app_registered == FALSE) { + bt_shell_printf("Advertisement Monitor not registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } else if (g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", unregister_setup, unregister_reply, NULL, NULL) == FALSE) { bt_shell_printf("Failed to unregister Advertisement Monitor\n"); @@ -159,3 +189,319 @@ void adv_monitor_unregister_app(DBusConnection *conn) } manager.app_registered = FALSE; } + +static void free_pattern(void *user_data) +{ + struct pattern *p = user_data; + + g_free(p); +} + +static void free_adv_monitor(void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + g_free(adv_monitor->type); + g_free(adv_monitor->rssi); + g_slist_free_full(adv_monitor->patterns, free_pattern); + g_free(adv_monitor); +} + +static uint8_t str2bytearray(char *str, uint8_t *arr) +{ + int idx, len = strlen(str), arr_len = 0; + + if (len%2 != 0) + return 0; + + for (idx = 0; idx < len; idx += 2) { + if (sscanf(str+idx, "%2hhx", &arr[arr_len++]) < 1) + return 0; + } + return arr_len; +} + +static void parse_rssi_value_pair(char *value_pair, int *low, int *high) +{ + char *val1, *val2; + bool flag = value_pair[0] == ','; + + val1 = strtok(value_pair, ","); + + if (!val1) + return; + + val2 = strtok(NULL, ","); + + if (!val2) { + if (!flag) + *low = atoi(val1); + else + *high = atoi(val1); + } else { + *low = atoi(val1); + *high = atoi(val2); + } +} + +static struct rssi_setting *parse_rssi(char *range, char *timeout) +{ + struct rssi_setting *rssi; + int high_threshold, low_threshold, high_timer, low_timer; + + high_threshold = RSSI_DEFAULT_HIGH_THRESHOLD; + low_threshold = RSSI_DEFAULT_LOW_THRESHOLD; + high_timer = RSSI_DEFAULT_HIGH_TIMEOUT; + low_timer = RSSI_DEFAULT_LOW_TIMEOUT; + + parse_rssi_value_pair(range, &low_threshold, &high_threshold); + parse_rssi_value_pair(timeout, &low_timer, &high_timer); + + rssi = g_malloc0(sizeof(struct rssi_setting)); + + if (!rssi) { + bt_shell_printf("Failed to allocate rssi_setting"); + bt_shell_noninteractive_quit(EXIT_FAILURE); + return NULL; + } + + rssi->high_threshold = high_threshold; + rssi->high_timer = high_timer; + rssi->low_threshold = low_threshold; + rssi->low_timer = low_timer; + + return rssi; +} + +static struct pattern *parse_pattern(char *parameter_list[]) +{ + struct pattern *pat; + + pat = g_malloc0(sizeof(struct pattern)); + + if (!pat) { + bt_shell_printf("Failed to allocate pattern"); + bt_shell_noninteractive_quit(EXIT_FAILURE); + return NULL; + } + + pat->start_pos = atoi(parameter_list[0]); + pat->ad_data_type = atoi(parameter_list[1]); + pat->content_len = str2bytearray(parameter_list[2], pat->content); + if (pat->content_len == 0) { + free_pattern(pat); + return NULL; + } + + return pat; +} + +static GSList *parse_patterns(char *pattern_list[], int num) +{ + GSList *patterns = NULL; + int cnt; + + if (num == 0) { + bt_shell_printf("No pattern provided\n"); + return NULL; + } + + if (num%3) { + bt_shell_printf("Expected %d more arguments\n", 3 - num%3); + return NULL; + } + + for (cnt = 0; cnt < num; cnt += 3) { + struct pattern *pattern; + + pattern = parse_pattern(pattern_list+cnt); + if (pattern == NULL) { + g_slist_free_full(patterns, free_pattern); + return NULL; + } + patterns = g_slist_append(patterns, pattern); + } + + return patterns; +} + +static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) +{ + const struct adv_monitor *adv_monitor = a; + uint8_t idx = *(uint8_t *)b; + + return adv_monitor->idx != idx; +} + +static struct adv_monitor *find_adv_monitor_with_idx(uint8_t monitor_idx) +{ + GSList *list; + + list = g_slist_find_custom(adv_mons, &monitor_idx, + cmp_adv_monitor_with_idx); + + if (list) + return (struct adv_monitor *)list->data; + return NULL; +} + +static void print_bytearray(char *prefix, uint8_t *arr, uint8_t len) +{ + int idx; + + bt_shell_printf("%s", prefix); + for (idx = 0; idx < len; idx++) + bt_shell_printf("%02hhx", arr[idx]); + bt_shell_printf("\n"); +} + +static void print_adv_monitor(struct adv_monitor *adv_monitor) +{ + GSList *l; + + bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); + bt_shell_printf("\ttype: %s\n", adv_monitor->type); + if (adv_monitor->rssi) { + bt_shell_printf("\trssi:\n"); + bt_shell_printf("\t\thigh threshold: %hd\n", + adv_monitor->rssi->high_threshold); + bt_shell_printf("\t\thigh threshold timer: %hu\n", + adv_monitor->rssi->high_timer); + bt_shell_printf("\t\tlow threshold: %hd\n", + adv_monitor->rssi->low_threshold); + bt_shell_printf("\t\tlow threshold timer: %hu\n", + adv_monitor->rssi->low_timer); + } + + if (adv_monitor->patterns) { + int idx = 1; + + for (l = adv_monitor->patterns; l; l = g_slist_next(l), idx++) { + struct pattern *pattern = l->data; + + bt_shell_printf("\tpattern %d:\n", idx); + bt_shell_printf("\t\tstart position: %hhu\n", + pattern->start_pos); + bt_shell_printf("\t\tAD data type: %hhu\n", + pattern->ad_data_type); + print_bytearray("\t\tcontent: ", pattern->content, + pattern->content_len); + } + } +} + +void adv_monitor_add_monitor(DBusConnection *conn, char *type, + gboolean rssi_enabled, int argc, char *argv[]) +{ + struct adv_monitor *adv_monitor; + struct rssi_setting *rssi; + GSList *patterns = NULL; + + if (g_slist_length(adv_mons) >= UINT8_MAX) { + bt_shell_printf("Number of advertisement monitor exceeds " + "the limit"); + return; + } + + while (find_adv_monitor_with_idx(adv_mon_idx)) + adv_mon_idx += 1; + + if (rssi_enabled == FALSE) + rssi = NULL; + else { + rssi = parse_rssi(argv[1], argv[2]); + if (rssi == NULL) + return; + + argv += 2; + argc -= 2; + } + + patterns = parse_patterns(argv+1, argc-1); + if (patterns == NULL) { + bt_shell_printf("pattern-list malformed\n"); + return; + } + + adv_monitor = g_malloc0(sizeof(struct adv_monitor)); + + if (!adv_monitor) { + bt_shell_printf("Failed to allocate adv_monitor"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + adv_monitor->idx = adv_mon_idx; + adv_monitor->type = g_strdup(type); + adv_monitor->rssi = rssi; + adv_monitor->patterns = patterns; + + adv_mons = g_slist_append(adv_mons, adv_monitor); + bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); +} + +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx) +{ + struct adv_monitor *adv_monitor; + GSList *l; + + if (monitor_idx < 0) { + for (l = adv_mons; l; l = g_slist_next(l)) { + adv_monitor = l->data; + print_adv_monitor(adv_monitor); + } + return; + } + + adv_monitor = find_adv_monitor_with_idx(monitor_idx); + + if (adv_monitor == NULL) { + bt_shell_printf("Can't find monitor with index %d\n", + monitor_idx); + return; + } + + print_adv_monitor(adv_monitor); +} + +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) +{ + struct adv_monitor *adv_monitor; + + if (monitor_idx < 0) { + g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); + return; + } + + adv_monitor = find_adv_monitor_with_idx(monitor_idx); + if (adv_monitor == NULL) { + bt_shell_printf("Can't find monitor with index %d\n", + monitor_idx); + return; + } + + adv_mons = g_slist_remove(adv_mons, adv_monitor); + free_adv_monitor(adv_monitor); + bt_shell_printf("Monitor %d deleted\n", monitor_idx); +} + +static void print_supported_list(GSList *list) +{ + GSList *iter; + + for (iter = list; iter; iter = g_slist_next(iter)) { + char *data = iter->data; + + printf(" %s", data); + } +} + +void adv_monitor_get_supported_info(void) +{ + bt_shell_printf("Supported Features:"); + print_supported_list(manager.supported_features); + bt_shell_printf("\n"); + + bt_shell_printf("Supported Moniter Types:"); + print_supported_list(manager.supported_types); + bt_shell_printf("\n"); +} diff --git a/client/advertisement_monitor.h b/client/advertisement_monitor.h index 77b0b62c6..12c01bd3f 100644 --- a/client/advertisement_monitor.h +++ b/client/advertisement_monitor.h @@ -17,7 +17,17 @@ * */ +#define RSSI_DEFAULT_HIGH_THRESHOLD -50 +#define RSSI_DEFAULT_LOW_THRESHOLD -70 +#define RSSI_DEFAULT_HIGH_TIMEOUT 10 +#define RSSI_DEFAULT_LOW_TIMEOUT 5 + void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); void adv_monitor_remove_manager(DBusConnection *conn); void adv_monitor_register_app(DBusConnection *conn); void adv_monitor_unregister_app(DBusConnection *conn); +void adv_monitor_add_monitor(DBusConnection *conn, char *type, + gboolean rssi_enabled, int argc, char *argv[]); +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx); +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx); +void adv_monitor_get_supported_info(void); diff --git a/client/main.c b/client/main.c index 6bca738a0..b0fda4dbe 100644 --- a/client/main.c +++ b/client/main.c @@ -2719,6 +2719,85 @@ static void cmd_ad_clear(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_FAILURE); } +static void print_add_or_pattern_with_rssi_usage(void) +{ + bt_shell_printf("rssi-range format:\n" + "\t<low-rssi>,<high-rssi>\n" + "\tBoth parameters can be skipped, in that case the\n" + "\tparamter will be set to its pre-defined value\n"); + bt_shell_printf("\tPre-defined low-rssi,high-rssi: %d,%d\n", + RSSI_DEFAULT_LOW_THRESHOLD, + RSSI_DEFAULT_HIGH_THRESHOLD); + bt_shell_printf("timeout format:\n" + "\t<low-rssi>,<high-rssi>\n" + "\tBoth parameters can be skipped, in that case the\n" + "\tparamter will be set to its pre-defined value\n"); + bt_shell_printf("\tPre-defined low-timeout,high-timeout: %d,%d\n", + RSSI_DEFAULT_LOW_TIMEOUT, + RSSI_DEFAULT_HIGH_TIMEOUT); + bt_shell_printf("pattern format:\n" + "\t<start_position> <ad_data_type> <content_of_pattern>\n"); + bt_shell_printf("e.g.\n" + "\tadd-or-pattern-rssi -10, ,10 1 2 01ab55\n"); + bt_shell_printf("or\n" + "\tadd-or-pattern-rssi -50,-30 , 1 2 01ab55 3 4 23cd66\n"); +} + +static void print_add_or_pattern_usage(void) +{ + bt_shell_printf("pattern format:\n" + "\t<start_position> <ad_data_type> <content_of_pattern>\n"); + bt_shell_printf("e.g.\n" + "\tadd-or-pattern 1 2 01ab55 3 4 23cd66\n"); +} + +static void cmd_adv_monitor_print_usage(int argc, char *argv[]) +{ + if (strcmp(argv[1], "add-or-pattern") == 0) + print_add_or_pattern_usage(); + else if (strcmp(argv[1], "add-or-pattern-rssi") == 0) + print_add_or_pattern_with_rssi_usage(); + else + bt_shell_printf("Invalid argument %s", argv[1]); +} + +static void cmd_adv_monitor_add_or_monitor_with_rssi(int argc, char *argv[]) +{ + adv_monitor_add_monitor(dbus_conn, "or_patterns", TRUE, argc, argv); +} + +static void cmd_adv_monitor_add_or_monitor(int argc, char *argv[]) +{ + adv_monitor_add_monitor(dbus_conn, "or_patterns", FALSE, argc, argv); +} + +static void cmd_adv_monitor_print_monitor(int argc, char *argv[]) +{ + int monitor_idx; + + if (strcmp(argv[1], "all") == 0) + monitor_idx = -1; + else + monitor_idx = atoi(argv[1]); + adv_monitor_print_monitor(dbus_conn, monitor_idx); +} + +static void cmd_adv_monitor_remove_monitor(int argc, char *argv[]) +{ + int monitor_idx; + + if (strcmp(argv[1], "all") == 0) + monitor_idx = -1; + else + monitor_idx = atoi(argv[1]); + adv_monitor_remove_monitor(dbus_conn, monitor_idx); +} + +static void cmd_adv_monitor_get_supported_info(int argc, char *argv[]) +{ + adv_monitor_get_supported_info(); +} + static const struct bt_shell_menu advertise_menu = { .name = "advertise", .desc = "Advertise Options Submenu", @@ -2755,6 +2834,35 @@ static const struct bt_shell_menu advertise_menu = { { } }, }; +static const struct bt_shell_menu advertise_monitor_menu = { + .name = "monitor", + .desc = "Advertisement Monitor Options Submenu", + .entries = { + { "add-or-pattern-rssi", "<rssi-range=low,high> <timeout=low,high> " + "[patterns=pattern1 pattern2 ...]", + cmd_adv_monitor_add_or_monitor_with_rssi, + "Add 'or pattern' type monitor with RSSI " + "filter" }, + { "add-or-pattern", "[patterns=pattern1 pattern2 ...]", + cmd_adv_monitor_add_or_monitor, + "Add 'or pattern' type monitor without RSSI " + "filter" }, + { "get-pattern", "<monitor-id/all>", + cmd_adv_monitor_print_monitor, + "Get advertisement monitor" }, + { "remove-pattern", "<monitor-id/all>", + cmd_adv_monitor_remove_monitor, + "Remove advertisement monitor" }, + { "get-supported-info", NULL, + cmd_adv_monitor_get_supported_info, + "Get advertisement manager supported " + "features and supported monitor types" }, + { "print-usage", "<add-or-pattern/add-or-pattern-rssi>", + cmd_adv_monitor_print_usage, + "Print the command usage"}, + { } }, +}; + static const struct bt_shell_menu scan_menu = { .name = "scan", .desc = "Scan Options Submenu", @@ -2932,6 +3040,7 @@ int main(int argc, char *argv[]) bt_shell_init(argc, argv, &opt); bt_shell_set_menu(&main_menu); bt_shell_add_submenu(&advertise_menu); + bt_shell_add_submenu(&advertise_monitor_menu); bt_shell_add_submenu(&scan_menu); bt_shell_add_submenu(&gatt_menu); bt_shell_set_prompt(PROMPT_OFF); -- 2.28.0.526.ge36021eeef-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SKP7NlkBWl+ZwAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 12:35:05 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 2PskNFkBWl/mTQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 12:35:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 52E7340974; Thu, 10 Sep 2020 12:34:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730099AbgIJKep (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 06:34:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730166AbgIJKeQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 06:34:16 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81252C061786 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 03:34:15 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id s33so3831003qth.1 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 03:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=yqjMGeyvRPcaWoCHc/xHlQCmAUnozMo/7KYsVvNF8Rk=; b=hf/8jNuNyUdSLaIkwfuMpcGCCBuv4mR2r28rhCpUCaOtzaGoWpejmC5I+qR16qfuOB kdXZYruJvFdDZMotXMb//7mq1kE8p8MjFxl4Kr7ih5ArJRXnREFHh/oh+3o5XDDn7z/4 jlsy+z9ms26eFlZmNdys/k36dAfJ7TnDwIWP8xhSMDXli9NObsZZmRXZ8VLe6kTuGSIk H+D8/Gjb8FyAFei2EC/tE9PQpHjg+6OWm5BmLQoSGh7YfyHtcHK6KCQPZs4DqkwDWbnZ bDF3urOmu6vU9976ZZTlYZo8T4vBv+k2tK85yVXedQExMTs0XBX/82QxObEOkBfvrqcj c//w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=yqjMGeyvRPcaWoCHc/xHlQCmAUnozMo/7KYsVvNF8Rk=; b=W4A4JKPVcOYgiRlsLKt56dCjWrBk65WM2a2L3iyhLmWI2/Jjg7a3vmS3tr+S7WMV+d b7JftzXfAu0JVcJuQA46ITh4IKwOqbUEfDniWpKxKAX+reEuRBYEgLo+rhBQW+RaUR+D S64vj7qvf6EEL6JJ7WmBYao7gEzIKBly04kO41AbBvTMecyY9Mc2Yl19ytgohrrl0SQ/ FWbKx1cXqV1aoA54cKeX4jQfRQFp+YBCp8H4eXimWzeCNaraSaxR3odGRrfe5D20Dqn0 e62PnPKG2Q8iqsDimc8vWH17HmHhLI0/N+fCoD85ucjyX4jNXYcik2qmf7iBjc30rCZX vqHw== X-Gm-Message-State: AOAM532XmWzd9Z+Swr18H+uFobdPgc3vgu/NjbL2UOqeR4XQ9QAosUG5 5+0KerZi7K+f1l7C4A/5LTSnOo0x3+71aMxCF8EQk90KZKs4sLMQopGUmsuOIgse3yBfmBTbYZ+ MkxLMb9SLvk7jT0ljvsu70w6y5FK5UhrtmjEMXPMhPDJ++by4Gf/OH8cDGnflmjlhwRcznBwRli lNgjxBeD4kDic= X-Google-Smtp-Source: ABdhPJxCdKWq9ZotVPwQg72/OSYpzXvq7fTImFLK2DSXv0+f8qjy0qnWvimCTIcAem1IPd1gdMKNEJIfTS0ILYrsuw== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:42b3:: with SMTP id e19mr8349992qvr.6.1599734054647; Thu, 10 Sep 2020 03:34:14 -0700 (PDT) Date: Thu, 10 Sep 2020 18:34:01 +0800 In-Reply-To: <20200910183329.BlueZ.v2.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200910183329.BlueZ.v2.3.I680cda25cec9c45ca2b2c5ac3a8e437772ea76d9@changeid> Mime-Version: 1.0 References: <20200910183329.BlueZ.v2.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog Subject: [BlueZ PATCH v2 3/4] PRE-UPSTREAM: client: Expose ADV monitor objects From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.18 / 15.00 / 15.00 X-Rspamd-Queue-Id: 52E7340974 X-Rspamd-UID: fb4dc1 This adds logic to expose user-defined advertisement monitor to dbus and also implements methods for exposed objects. Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) client/advertisement_monitor.c | 185 ++++++++++++++++++++++++++++++++- 1 file changed, 182 insertions(+), 3 deletions(-) diff --git a/client/advertisement_monitor.c b/client/advertisement_monitor.c index 0b2f7f407..b83ec823b 100644 --- a/client/advertisement_monitor.c +++ b/client/advertisement_monitor.c @@ -53,6 +53,7 @@ struct pattern { struct adv_monitor { uint8_t idx; + char *path; char *type; struct rssi_setting *rssi; GSList *patterns; @@ -68,6 +69,163 @@ static struct adv_monitor_manager { static uint8_t adv_mon_idx; static GSList *adv_mons; +static void remove_adv_monitor(void *data, void *user_data); + +static DBusMessage *release_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + bt_shell_printf("Advertisement monitor %d released\n", + adv_monitor->idx); + remove_adv_monitor(adv_monitor, conn); + + return dbus_message_new_method_return(msg); +} + +static DBusMessage *activate_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + bt_shell_printf("Advertisement monitor %d activated\n", + adv_monitor->idx); + return dbus_message_new_method_return(msg); +} + +static DBusMessage *device_found_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + const char *device; + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device, + DBUS_TYPE_INVALID); + bt_shell_printf("Advertisement monitor %d found device %s\n", + adv_monitor->idx, device); + return dbus_message_new_method_return(msg); +} + +static DBusMessage *device_lost_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + const char *device; + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device, + DBUS_TYPE_INVALID); + bt_shell_printf("Advertisement monitor %d lost device %s\n", + adv_monitor->idx, device); + return dbus_message_new_method_return(msg); +} + +static const GDBusMethodTable adv_monitor_methods[] = { + { GDBUS_ASYNC_METHOD("Release", NULL, NULL, release_adv_monitor) }, + { GDBUS_ASYNC_METHOD("Activate", NULL, NULL, activate_adv_monitor) }, + { GDBUS_ASYNC_METHOD("DeviceFound", GDBUS_ARGS({ "device", "o" }), + NULL, device_found_adv_monitor) }, + { GDBUS_ASYNC_METHOD("DeviceLost", GDBUS_ARGS({ "device", "o" }), + NULL, device_lost_adv_monitor) }, + { } +}; + + +static gboolean get_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, + &adv_monitor->type); + return TRUE; +} + +static gboolean get_rssi(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + struct rssi_setting *rssi = adv_monitor->rssi; + DBusMessageIter data_iter; + + dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, + NULL, &data_iter); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_INT16, + &rssi->high_threshold); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_UINT16, + &rssi->high_timer); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_INT16, + &rssi->low_threshold); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_UINT16, + &rssi->low_timer); + dbus_message_iter_close_container(iter, &data_iter); + return TRUE; +} + +static gboolean rssi_exists(const GDBusPropertyTable *property, void *data) +{ + struct adv_monitor *adv_monitor = data; + + return adv_monitor->rssi != NULL; +} + +static void append_pattern_content_to_dbus(DBusMessageIter *iter, + struct pattern *pattern) +{ + DBusMessageIter data_iter; + int idx; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE_AS_STRING, &data_iter); + for (idx = 0; idx < pattern->content_len; idx++) + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->content[idx]); + dbus_message_iter_close_container(iter, &data_iter); +} + +static void append_pattern_to_dbus(void *data, void *user_data) +{ + struct pattern *pattern = data; + DBusMessageIter *array_iter = user_data; + DBusMessageIter data_iter; + + dbus_message_iter_open_container(array_iter, DBUS_TYPE_STRUCT, + NULL, &data_iter); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->start_pos); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->ad_data_type); + append_pattern_content_to_dbus(&data_iter, pattern); + dbus_message_iter_close_container(array_iter, &data_iter); +} + +static gboolean get_patterns(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + DBusMessageIter array_iter; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "(yyay)", + &array_iter); + g_slist_foreach(adv_monitor->patterns, append_pattern_to_dbus, + &array_iter); + dbus_message_iter_close_container(iter, &array_iter); + return TRUE; +} + +static gboolean pattern_exists(const GDBusPropertyTable *property, void *data) +{ + struct adv_monitor *adv_monitor = data; + + return adv_monitor->patterns != NULL; +} + +static const GDBusPropertyTable adv_monitor_props[] = { + { "Type", "s", get_type }, + { "RSSIThresholdsAndTimers", "(nqnq)", get_rssi, NULL, rssi_exists }, + { "Patterns", "a(yyay)", get_patterns, NULL, pattern_exists }, + { } +}; + static void set_supported_list(GSList **list, DBusMessageIter *iter) { char *str; @@ -201,6 +359,7 @@ static void free_adv_monitor(void *user_data) { struct adv_monitor *adv_monitor = user_data; + g_free(adv_monitor->path); g_free(adv_monitor->type); g_free(adv_monitor->rssi); g_slist_free_full(adv_monitor->patterns, free_pattern); @@ -325,6 +484,16 @@ static GSList *parse_patterns(char *pattern_list[], int num) return patterns; } +static void remove_adv_monitor(void *data, void *user_data) +{ + struct adv_monitor *adv_monitor = data; + DBusConnection *conn = user_data; + + adv_mons = g_slist_remove(adv_mons, adv_monitor); + g_dbus_unregister_interface(conn, adv_monitor->path, + ADV_MONITOR_INTERFACE); +} + static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) { const struct adv_monitor *adv_monitor = a; @@ -360,6 +529,7 @@ static void print_adv_monitor(struct adv_monitor *adv_monitor) GSList *l; bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); + bt_shell_printf("\tpath: %s\n", adv_monitor->path); bt_shell_printf("\ttype: %s\n", adv_monitor->type); if (adv_monitor->rssi) { bt_shell_printf("\trssi:\n"); @@ -434,6 +604,16 @@ void adv_monitor_add_monitor(DBusConnection *conn, char *type, adv_monitor->type = g_strdup(type); adv_monitor->rssi = rssi; adv_monitor->patterns = patterns; + adv_monitor->path = g_strdup_printf("%s/%hhu", ADV_MONITOR_APP_PATH, + adv_mon_idx); + if (g_dbus_register_interface(conn, adv_monitor->path, + ADV_MONITOR_INTERFACE, + adv_monitor_methods, NULL, + adv_monitor_props, adv_monitor, + free_adv_monitor) == FALSE) { + bt_shell_printf("Failed to register advertisement monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } adv_mons = g_slist_append(adv_mons, adv_monitor); bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); @@ -468,7 +648,7 @@ void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) struct adv_monitor *adv_monitor; if (monitor_idx < 0) { - g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); + g_slist_foreach(adv_mons, remove_adv_monitor, conn); return; } @@ -479,8 +659,7 @@ void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) return; } - adv_mons = g_slist_remove(adv_mons, adv_monitor); - free_adv_monitor(adv_monitor); + remove_adv_monitor(adv_monitor, conn); bt_shell_printf("Monitor %d deleted\n", monitor_idx); } -- 2.28.0.526.ge36021eeef-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WCdzK/6zWl/LJgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:17:18 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id CG4vKP6zWl+XvgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:17:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 893B4A020E; Fri, 11 Sep 2020 01:17:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725550AbgIJXRK (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:17:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgIJXRH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:17:07 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D300BC061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:17:06 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id s65so4123536pgb.0 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hqPIB5nqb0Ac+Qss3diCOrBXw8J/be3CkEyRsnuvTz4=; b=ja9giBZDpeA4DNIIwPPcsfo2hPRecx7vem9YbG1ceuKuaHdueteUwPxw7+ExfBqTcY FWzij1hpAbLyqpPR4WB//ed0/wAfeYrOUHUMHbGHuLjTgDa94AR2/FSq5Ai4WtT5CgKR jX77TtuIvKsM5ZTex1ZlvlIIrWBXbQROH/zqE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hqPIB5nqb0Ac+Qss3diCOrBXw8J/be3CkEyRsnuvTz4=; b=SoH8p2f0nSHP61atepjrRHL7Qpu7LNLZgqOepGwXDGkibbQ2icxin0r+k0I/mGlc2i Ge9NL+kTT2Q7TdBqwoNngXbyCQVJYNVx4i+jEa81qZAmAu7PyQrdL4Z2Ip6nbq44s6bN K0VeorgLVBmsoqUwChToUsm1JvQJRWRsoeW5g8a9ZtBFiAoKJk5+9YkGzmZcbUWUMJX2 9yb/fIyLsGwgHkAu5DFKvGJ60iCmLeScwghPK1nOJtib8nTm1AHAJObz4Chp+nZagiu8 rKSPYyzi7hu8n41IibRN4MgZeOaNouwHPt5USKr8CyNAX2Xi5KQtDDaxdE++EnQSDXk/ +eDQ== X-Gm-Message-State: AOAM533q6v1391bqUH0+9rwe2hIwHjFJ0rYRDfY6o+OUpQw3Q/m61KyX qLubXp55RLsLGeMfCG+hSlzA42ziYcScWg== X-Google-Smtp-Source: ABdhPJzY3B2TV0SuF9CNu2GfnNEbYepbDHG2Q6uptZdrSQf/7bYhvQMznDxc7MTpVOGxe/g6qmRdgA== X-Received: by 2002:aa7:8e85:: with SMTP id a5mr7434236pfr.96.1599779824476; Thu, 10 Sep 2020 16:17:04 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k29sm76790pgf.21.2020.09.10.16.17.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2020 16:17:03 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v4 4/8] adv_monitor: Implement RegisterMonitor() Date: Thu, 10 Sep 2020 16:15:48 -0700 Message-Id: <20200910161528.BlueZ.v4.4.I19ff9cdbd40fe453db0e81aec8bf94dd9490dce3@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.31 / 15.00 / 15.00 X-Rspamd-Queue-Id: 893B4A020E X-Rspamd-UID: cc68e2 This implements the RegisterMonitor() method handler of ADV monitor manager interface. The following tests were performed. - Issue a RegisterMonitor() call with a valid path and expect a success as return. - Issue a RegisterMonitor() call with an invalid path and expect org.bluez.Error.InvalidArguments as return. - Issue two Registermonitor() calls with the same path and expect org.bluez.Error.AlreadyExists. - Verify the values of the registered paths with logging. - Verify D-Bus disconnection callback was triggered when the client detach from D-Bus. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v2) Changes in v2: - Use new0() instead of g_new0() - Remove the reset of app members src/adv_monitor.c | 165 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 164 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index fc37b0145..abc1bf228 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -22,7 +22,9 @@ #endif #define _GNU_SOURCE +#include <errno.h> #include <stdint.h> +#include <string.h> #include <glib.h> #include <dbus/dbus.h> @@ -34,7 +36,9 @@ #include "adapter.h" #include "dbus-common.h" #include "log.h" +#include "src/error.h" #include "src/shared/mgmt.h" +#include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" @@ -50,12 +54,168 @@ struct btd_adv_monitor_manager { uint32_t enabled_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ uint16_t max_num_monitors; uint8_t max_num_patterns; + + struct queue *apps; /* apps who registered for Adv monitoring */ +}; + +struct adv_monitor_app { + struct btd_adv_monitor_manager *manager; + char *owner; + char *path; + + DBusMessage *reg; + GDBusClient *client; }; +struct app_match_data { + const char *owner; + const char *path; +}; + +/* Replies to an app's D-Bus message and unref it */ +static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) +{ + if (!app || !app->reg || !reply) + return; + + g_dbus_send_message(btd_get_dbus_connection(), reply); + dbus_message_unref(app->reg); + app->reg = NULL; +} + +/* Destroys an app object along with related D-Bus handlers */ +static void app_destroy(void *data) +{ + struct adv_monitor_app *app = data; + + if (!app) + return; + + DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); + + if (app->reg) { + app_reply_msg(app, btd_error_failed(app->reg, + "Adv Monitor app destroyed")); + } + + if (app->client) { + g_dbus_client_set_disconnect_watch(app->client, NULL, NULL); + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, + NULL); + g_dbus_client_set_ready_watch(app->client, NULL, NULL); + g_dbus_client_unref(app->client); + } + + g_free(app->owner); + g_free(app->path); + + free(app); +} + +/* Handles a D-Bus disconnection event of an app */ +static void app_disconnect_cb(DBusConnection *conn, void *user_data) +{ + struct adv_monitor_app *app = user_data; + + btd_info(app->manager->adapter_id, "Adv Monitor app %s disconnected " + "from D-Bus", app->owner); + if (app && queue_remove(app->manager->apps, app)) + app_destroy(app); +} + +/* Creates an app object, initiates it and sets D-Bus event handlers */ +static struct adv_monitor_app *app_create(DBusConnection *conn, + const char *sender, const char *path, + struct btd_adv_monitor_manager *manager) +{ + struct adv_monitor_app *app; + + if (!path || !sender || !manager) + return NULL; + + app = new0(struct adv_monitor_app, 1); + if (!app) + return NULL; + + app->owner = g_strdup(sender); + app->path = g_strdup(path); + app->manager = manager; + app->reg = NULL; + + app->client = g_dbus_client_new(conn, sender, path); + if (!app->client) { + app_destroy(app); + return NULL; + } + + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); + g_dbus_client_set_ready_watch(app->client, NULL, NULL); + + return app; +} + +/* Matches an app based on its owner and path */ +static bool app_match(const void *a, const void *b) +{ + const struct adv_monitor_app *app = a; + const struct app_match_data *match = b; + + if (match->owner && strcmp(app->owner, match->owner)) + return false; + + if (match->path && strcmp(app->path, match->path)) + return false; + + return true; +} + +/* Handles a RegisterMonitor D-Bus call */ +static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, + void *user_data) +{ + DBusMessageIter args; + struct app_match_data match; + struct adv_monitor_app *app; + struct btd_adv_monitor_manager *manager = user_data; + + if (!dbus_message_iter_init(msg, &args)) + return btd_error_invalid_args(msg); + + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) + return btd_error_invalid_args(msg); + + dbus_message_iter_get_basic(&args, &match.path); + + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) + return btd_error_invalid_args(msg); + + match.owner = dbus_message_get_sender(msg); + + if (queue_find(manager->apps, app_match, &match)) + return btd_error_already_exists(msg); + + app = app_create(conn, match.owner, match.path, manager); + if (!app) { + btd_error(manager->adapter_id, + "Failed to reserve %s for Adv Monitor app %s", + match.path, match.owner); + return btd_error_failed(msg, + "Failed to create Adv Monitor app"); + } + + queue_push_tail(manager->apps, app); + + btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", + match.path, match.owner); + + return dbus_message_new_method_return(msg); +} + static const GDBusMethodTable adv_monitor_methods[] = { { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), - NULL, NULL) }, + NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, NULL) }, @@ -155,6 +315,7 @@ static struct btd_adv_monitor_manager *manager_new( manager->adapter = adapter; manager->mgmt = mgmt_ref(mgmt); manager->adapter_id = btd_adapter_get_index(adapter); + manager->apps = queue_new(); return manager; } @@ -164,6 +325,8 @@ static void manager_free(struct btd_adv_monitor_manager *manager) { mgmt_unref(manager->mgmt); + queue_destroy(manager->apps, app_destroy); + free(manager); } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GECHNAW0Wl/4NAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:17:25 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8OCiMQW0Wl8j5gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:17:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CB2DAA0B2D; Fri, 11 Sep 2020 01:17:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725562AbgIJXRT (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:17:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgIJXRQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:17:16 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A0FDC061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:17:16 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id a9so781890pjg.1 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=554fiM1qbjL10Yr8XVdwM4O4WwfqkbRQmuBHrzW8EqY=; b=jDFj7+Ognfqh6YlXUClMycJdh8hQI1W3NpnvuDm/+srgIbLlZORBtb2hyxiZUeaMpO sYsW11z6abZO69sm4DlAITpfiQZYtO6Eic/QaQ4ghe9667VibpN3tIrqRFrRdfINUnpi nKuYoE4C8nU1Lc+cCD0bxYRHbW6bj2tVbt6S8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=554fiM1qbjL10Yr8XVdwM4O4WwfqkbRQmuBHrzW8EqY=; b=ZdP0GC8NjaoRtvpTGJpTtObNeI7rf3erCKaQcib2NvVFbEhwv7BtBZRvdJDL0i0J9V 3kNAiew1wMKbWDU4EUFylBf9v9TlUO4xOt0zNgNDWvw2bt7GqkoymqKQmUjOaQSal40n 8iazbtDqR7mx2RV2PbH8zXTklYPYohzNinXSxvSkzOk4UipFcBjd7PcUW9El7axUqL7W r/j26HOuzfLYMntM2a8T2lrFLieHGNxQ+78Wnb/vHyJ4oLlEL3XGwQO0g/sj4g70B0zM InP/PKbgSZ7vgaM8PET3Q79GfeQw9FPNGnLNnD6mm6y23zaCnlfqXIcdpfKNkVQfwqLC ujuQ== X-Gm-Message-State: AOAM531wE82C5NpvCql9ek0TRYmwPab8AeA/w3VglLmS0W//5/Hw0XEp Ir7KrCkMt6ACbIIfOXigqlXQcjqHOqpUug== X-Google-Smtp-Source: ABdhPJytV0wcir94uRBlia9JEBXIB5N8oc88V3cPMpkq+BvMIBI5f6sopivM6H3dWSqwCCqjFnNO1A== X-Received: by 2002:a17:90b:50f:: with SMTP id r15mr2057467pjz.15.1599779835475; Thu, 10 Sep 2020 16:17:15 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k29sm76790pgf.21.2020.09.10.16.17.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2020 16:17:14 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v4 5/8] adv_monitor: Implement UnregisterMonitor() Date: Thu, 10 Sep 2020 16:15:50 -0700 Message-Id: <20200910161528.BlueZ.v4.5.I335e42ab9a238261c2492c308ce77c959f631483@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.31 / 15.00 / 15.00 X-Rspamd-Queue-Id: CB2DAA0B2D X-Rspamd-UID: 7dc859 This implements the UnregisterMonitor() method handler of ADV monitor manager interface. The following tests were performed. - Issue a UnregisterMonitor() call with a nonexistent path and expect org.bluez.Error.DoesNotExist as the return. - Issue a UnregisterMonitor() call with a invalid path and expect org.bluez.Error.InvalidArguments as the return. - Issue RegisterMonitor() with a path, issue UnregisterMonitor() and expect a successful method call return. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v1) src/adv_monitor.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index abc1bf228..c6c538cf1 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -212,13 +212,48 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, return dbus_message_new_method_return(msg); } +/* Handles UnregisterMonitor D-Bus call */ +static DBusMessage *unregister_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + DBusMessageIter args; + struct app_match_data match; + struct adv_monitor_app *app; + struct btd_adv_monitor_manager *manager = user_data; + + if (!dbus_message_iter_init(msg, &args)) + return btd_error_invalid_args(msg); + + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) + return btd_error_invalid_args(msg); + + dbus_message_iter_get_basic(&args, &match.path); + + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) + return btd_error_invalid_args(msg); + + match.owner = dbus_message_get_sender(msg); + + app = queue_find(manager->apps, app_match, &match); + if (!app) + return btd_error_does_not_exist(msg); + + queue_remove(manager->apps, app); + app_destroy(app); + + btd_info(manager->adapter_id, "Path %s removed along with Adv Monitor " + "app %s", match.path, match.owner); + + return dbus_message_new_method_return(msg); +} + static const GDBusMethodTable adv_monitor_methods[] = { { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", GDBUS_ARGS({ "application", "o" }), - NULL, NULL) }, + NULL, unregister_monitor) }, { } }; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0EnzKRO0Wl/4NAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:17:39 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4BYUJxO0Wl9tsAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:17:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8C4DEA0B48; Fri, 11 Sep 2020 01:17:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725535AbgIJXRb (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:17:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgIJXRa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:17:30 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09D43C061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:17:29 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id b17so783032pji.1 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F+vA4llepriglkR7TLKcIvpKkfU9TuzTMON9/uPXqmc=; b=DLUP4Jqm0YlmbFegDepNnIcPaFzMHYIT8vOTtZLjKy+k3PJADc0a7mEVv1EetQr2zS 5bI80/KmS2JqQ75P/ClKp9LP4H+sZAEbSA19ARvAIVZwNO4act4u78fgKrYS73SU4vVN PQxR7VGut3SAMQjDkiRpHABzaNe8OBg+Q04CI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F+vA4llepriglkR7TLKcIvpKkfU9TuzTMON9/uPXqmc=; b=goUGaNXcE0FWQd47LuJk80wAJoUsuDCxs55VElPpUa67F8oE0fEm+yjAJQfdwBQs5b MjHQpbEgkHrNaskdNI2HxSHGHzMPxB9YFg7K1HYFFYDIMjg8rgtfQa7q/gktAExtuBfv Y9ooiUlLE/JBnaILd0TESd6eD3VqHpRwxc8eEfgqkyiNC/BByCAOHBal6ObLIYxeVVQ0 OkiKtx7lCxWcrOS6kM4xRo9E1Ay03o7qG+c1ag7rfjvxqPDBRUJaIahiFAkv/N/1ZNEi O1sOQzj9VADAhkfnTGR2My+zYI62Q4UwDyxM8UTVgub4q1OHLViB4QJ45NEOro/g0M/S wdYg== X-Gm-Message-State: AOAM533HH5Ll8c1H/ubxl2IiXL5oxf3n/CWgdf2pafChgboEj4aY3Hdk I3g+60USUpVsM4f/eN9Ndb6lgFY53yRshw== X-Google-Smtp-Source: ABdhPJxZ5+LCJX19/os0kHAw4AcQHGv3tzBLXHw+RjCi5yrzcZ4MZElgvYas5ho1XAwmtYS04doF3g== X-Received: by 2002:a17:90a:e98d:: with SMTP id v13mr2069082pjy.79.1599779849063; Thu, 10 Sep 2020 16:17:29 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k29sm76790pgf.21.2020.09.10.16.17.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2020 16:17:28 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 6/8] adv_monitor: Handle D-Bus client ready events Date: Thu, 10 Sep 2020 16:15:52 -0700 Message-Id: <20200910161528.BlueZ.v4.6.Id5b1ced1530cb21559bc1dcf29d8764b0c7df825@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.19 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8C4DEA0B48 X-Rspamd-UID: 9708a7 This adds a handler of client ready events. The handler replies to the RegisterMonitor() method call. The following tests were performed. - Call RegisterMonitor() and expect to receive a return. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index c6c538cf1..8ef13512a 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -123,9 +123,22 @@ static void app_disconnect_cb(DBusConnection *conn, void *user_data) app_destroy(app); } +/* Handles the ready signal of Adv Monitor app */ +static void app_ready_cb(GDBusClient *client, void *user_data) +{ + struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + + btd_info(adapter_id, "Path %s reserved for Adv Monitor app %s", + app->path, app->owner); + + app_reply_msg(app, dbus_message_new_method_return(app->reg)); +} + /* Creates an app object, initiates it and sets D-Bus event handlers */ static struct adv_monitor_app *app_create(DBusConnection *conn, - const char *sender, const char *path, + DBusMessage *msg, const char *sender, + const char *path, struct btd_adv_monitor_manager *manager) { struct adv_monitor_app *app; @@ -150,7 +163,9 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); - g_dbus_client_set_ready_watch(app->client, NULL, NULL); + g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); + + app->reg = dbus_message_ref(msg); return app; } @@ -195,7 +210,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, if (queue_find(manager->apps, app_match, &match)) return btd_error_already_exists(msg); - app = app_create(conn, match.owner, match.path, manager); + app = app_create(conn, msg, match.owner, match.path, manager); if (!app) { btd_error(manager->adapter_id, "Failed to reserve %s for Adv Monitor app %s", @@ -206,10 +221,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, queue_push_tail(manager->apps, app); - btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", - match.path, match.owner); - - return dbus_message_new_method_return(msg); + return NULL; } /* Handles UnregisterMonitor D-Bus call */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gA0oE2cBWl/LsQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 12:35:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id mOIBEGcBWl/hzQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 12:35:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AAD00408B1; Thu, 10 Sep 2020 12:35:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729876AbgIJKe7 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 06:34:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730189AbgIJKeW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 06:34:22 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F05DC061795 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 03:34:19 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id i23so3333146pju.7 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 03:34:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=Mz2x8H2u+dcISQMEODChynSBMMwhzWBKqD5b3CthGT4=; b=qUhGnMCQKFD46o0jnL3hhbDCU1tGBAzXBpowlUBYQVGWU0gnGDGIehZudVn+W1SAzi PvQmMGl6OlNrE1pCeC+Q+4DJ7ojRyvby5q6qi4jHHDCREzOGM4f28H5az4uYg/xZtiRY ueZeH2Mue0UlY762ddqCHanOXErpMjBC39g1D+Mf9qCjhSPE8ggTsta+czW53LT153Ne Km++8a52NHJVcftlTDj7V9fGiBg/0TshPd5oiHTrLsWyY8XQzO99IlGrqsFukcRUDtMX BT/XStT9x7eic/XYUIbGa8A9TBo+qvfgsX+kdMEVe9G31GdGUbyP1EEulZLjjkz3Vpmw b7LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Mz2x8H2u+dcISQMEODChynSBMMwhzWBKqD5b3CthGT4=; b=FUHN1lG7AafY2MIzIQ7V3P5ducDDqEVBBviG8P1INaxMGf6M8y58RgeeIfkH2z/OMo Yn8OG50PDdCYNGzc9YyV3ga+WRo+VjoPUhZwZSvI968v1pWRN3UeKbA7Fg8gXQGPayt5 4U+cTlFpn0xzIwzBIr/ARHATHrXa242x5Mm8ySrOfg0YSUH5EoBrYDrwhxAUrDS1vxBn I0bkM6snNc1QOGtejTwNqHu5cJnf+19CWEYemNrWTMLIpjuPsWNvCIfr9fgLSUOBgiLx 5pXAhHD1C7/LluhpaXjlJ/njWkymJXrknaW9iUim462kqqZi98h97mCiiB/wRPhLfO59 3HjQ== X-Gm-Message-State: AOAM532plbZi1zOcFEGouZ/yAxn4exgJ6zFsmxhqBUhlJQpBR+bOyrl+ srbeU2UnVqIodSOYAV/g4T0HF40wjeafqy+WKfRpIGeR0Ze6m9iWDn4k4lxUHfuivRxym67uSOw vPXJUJcMGov5mdyXMAAjGUH4+9ZE5lH+AcUdFQnYL/Gt3hUI8qCcS2dWVYrIRa/he/chfeq6Nek nilL8rvPNQ2TE= X-Google-Smtp-Source: ABdhPJwjGjw9TjJ20kbaO9rR8ecmccjeWVqky0iCLkQP1ZHcbC2vhz5HuSFfv47Xn2sBXJK3ri0V+EEh2Z3F3fM/qQ== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:902:8306:b029:d0:cbe1:e7aa with SMTP id bd6-20020a1709028306b02900d0cbe1e7aamr5041899plb.27.1599734058598; Thu, 10 Sep 2020 03:34:18 -0700 (PDT) Date: Thu, 10 Sep 2020 18:34:02 +0800 In-Reply-To: <20200910183329.BlueZ.v2.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200910183329.BlueZ.v2.4.Ieffbe3452565ace2af46a63501c767c8798fd88c@changeid> Mime-Version: 1.0 References: <20200910183329.BlueZ.v2.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog Subject: [BlueZ PATCH v2 4/4] PRE-UPSTREAM: core: Add AdvertisementMonitor to bluetooth.conf From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.18 / 15.00 / 15.00 X-Rspamd-Queue-Id: AAD00408B1 X-Rspamd-UID: 248ac7 AdvertisementMonitor must be included in bluetooth.conf in order to be able to call Release Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/bluetooth.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bluetooth.conf b/src/bluetooth.conf index 8a1e25801..b6c614908 100644 --- a/src/bluetooth.conf +++ b/src/bluetooth.conf @@ -10,6 +10,7 @@ <policy user="root"> <allow own="org.bluez"/> <allow send_destination="org.bluez"/> + <allow send_interface="org.bluez.AdvertisementMonitor1"/> <allow send_interface="org.bluez.Agent1"/> <allow send_interface="org.bluez.MediaEndpoint1"/> <allow send_interface="org.bluez.MediaPlayer1"/> -- 2.28.0.526.ge36021eeef-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EMG2Dim0Wl/LJgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:18:01 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qKg+DCm0Wl9aagAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:18:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C4520A020E; Fri, 11 Sep 2020 01:17:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725601AbgIJXRy (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgIJXRv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:17:51 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3A69C061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:17:51 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d9so5756493pfd.3 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qcUGlkvWtlX2fwpLjG1y90oiELKWIBkxGQC7+535lKc=; b=kltYVLKW1f5YRMDvXRgg6LtFlAgRm7PUzRtKowYtAce0xERE3k2eLFca4yv1NbDNyu 0UGWO9/lv2xzHFQxutdKdRA0HCbenvwtsyYAiRH6uEQKSyjkMiclT2HB+eSxP3wEKWpy bSnrb4nIf80GYRAITAiTRZS9keNlnVSx5iiiI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qcUGlkvWtlX2fwpLjG1y90oiELKWIBkxGQC7+535lKc=; b=jqjrB2M1Y1FB72R+NyB5d3+EKeHpfqJ9zEjidzjjmJ0tEjXQlrfHL0SudLAq6PTOp5 XofT5tWYNbRiHUqj53TN12H/wvS/YKuk0PJjkiIAVtqbuGvX0GY0X3zbxgy1856riFOO O05bsCQUFjBLcSpaC7xxhzWopatyhTRkHZojBZkg9O9xp1T9SWV6pCTNqHq0Bvw11Yms 4FkZy2h1pvuigvC8gcb5QW8YXvR8LZU4RGWzdM3n7PM/HuY9l3u9F4oSznqZcwO6aI9P m0CcvVEG9t9SOtCfHKvjXE657f+iE5uCOD15f4P1yY+eW6VhwksOqeVzByqDklWl2GHI q9Kw== X-Gm-Message-State: AOAM532eQA+67O1wDpN9brh1NC2S1nVXUY0gzh7/1kVzylu4rpGYrqsN 6KYOE7DR9A7beKoucSld7k8AHotEMekZFg== X-Google-Smtp-Source: ABdhPJxMc2m+of1KTnKqhOXtbw9hWHRP0aRGJdILq2guOp2JmUuVV5l1IcXKeAZ/ES0clKjaE8c4/Q== X-Received: by 2002:a17:902:8ecc:b029:d1:7cd1:8d5b with SMTP id x12-20020a1709028eccb02900d17cd18d5bmr7792655plo.42.1599779869097; Thu, 10 Sep 2020 16:17:49 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k29sm76790pgf.21.2020.09.10.16.17.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2020 16:17:48 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 7/8] adv_monitor: Handle D-Bus proxy event of an ADV monitor Date: Thu, 10 Sep 2020 16:15:54 -0700 Message-Id: <20200910161528.BlueZ.v4.7.I47744c7eef31f44cf393dea2b3e437d7b41cef79@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.19 / 15.00 / 15.00 X-Rspamd-Queue-Id: C4520A020E X-Rspamd-UID: 6ce3c6 This adds two handlers, one for adding and one for removing, of D-Bus proxy events. The handler of property changes is set to NULL as intended, since for simplicity no further changes on monitor's properties would affect the ongoing monitoring. The following test steps were performed with bluetoothctl. - After registering the root path, expose two monitors and verify that the proxy added event are received. - Have two monitors added, unexpose the monitors, and verify that the proxy removed events are received for those two monitors. - Have two monitors added, unregister the monitors and verify that the proxy removed events are received for those two monitors. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v2) Changes in v2: - Use new0() instead of g_new0() - Remove the reset of monitor members - Use memcpy() instead of g_memmove() src/adv_monitor.c | 488 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 475 insertions(+), 13 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 8ef13512a..236f7b0dc 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -37,14 +37,23 @@ #include "dbus-common.h" #include "log.h" #include "src/error.h" +#include "src/shared/ad.h" #include "src/shared/mgmt.h" #include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" +#define ADV_MONITOR_UNSET_RSSI 127 /* dBm */ +#define ADV_MONITOR_MAX_RSSI 20 /* dBm */ +#define ADV_MONITOR_MIN_RSSI -127 /* dBm */ +#define ADV_MONITOR_UNSET_TIMER 0 /* second */ +#define ADV_MONITOR_MIN_TIMER 1 /* second */ +#define ADV_MONITOR_MAX_TIMER 300 /* second */ + struct btd_adv_monitor_manager { struct btd_adapter *adapter; struct mgmt *mgmt; @@ -65,6 +74,43 @@ struct adv_monitor_app { DBusMessage *reg; GDBusClient *client; + + struct queue *monitors; +}; + +enum monitor_type { + MONITOR_TYPE_NONE, + MONITOR_TYPE_OR_PATTERNS, +}; + +enum monitor_state { + MONITOR_STATE_NEW, /* New but not yet init'ed with actual values */ + MONITOR_STATE_FAILED, /* Failed to be init'ed */ + MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ + MONITOR_STATE_HONORED, /* Accepted by kernel */ +}; + +struct pattern { + uint8_t ad_type; + uint8_t offset; + uint8_t length; + uint8_t value[BT_AD_MAX_DATA_LEN]; +}; + +struct adv_monitor { + struct adv_monitor_app *app; + GDBusProxy *proxy; + char *path; + + enum monitor_state state; /* MONITOR_STATE_* */ + + int8_t high_rssi; /* high RSSI threshold */ + uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ + int8_t low_rssi; /* low RSSI threshold */ + uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ + + enum monitor_type type; /* MONITOR_TYPE_* */ + struct queue *patterns; }; struct app_match_data { @@ -72,6 +118,14 @@ struct app_match_data { const char *path; }; +const struct adv_monitor_type { + enum monitor_type type; + const char *name; +} supported_types[] = { + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, + { }, +}; + /* Replies to an app's D-Bus message and unref it */ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) { @@ -83,6 +137,48 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) app->reg = NULL; } +/* Frees a pattern */ +static void pattern_free(void *data) +{ + struct pattern *pattern = data; + + if (!pattern) + return; + + free(pattern); +} + +/* Frees a monitor object */ +static void monitor_free(void *data) +{ + struct adv_monitor *monitor = data; + + if (!monitor) + return; + + g_dbus_proxy_unref(monitor->proxy); + g_free(monitor->path); + + queue_destroy(monitor->patterns, pattern_free); + + free(monitor); +} + +/* Calls Release() method of the remote Adv Monitor */ +static void monitor_release(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + + if (!monitor) + return; + + DBG("Calling Release() on Adv Monitor of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "Release", NULL, NULL, NULL, + NULL); +} + /* Destroys an app object along with related D-Bus handlers */ static void app_destroy(void *data) { @@ -93,6 +189,9 @@ static void app_destroy(void *data) DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); + queue_foreach(app->monitors, monitor_release, NULL); + queue_destroy(app->monitors, monitor_free); + if (app->reg) { app_reply_msg(app, btd_error_failed(app->reg, "Adv Monitor app destroyed")); @@ -135,6 +234,372 @@ static void app_ready_cb(GDBusClient *client, void *user_data) app_reply_msg(app, dbus_message_new_method_return(app->reg)); } +/* Allocates an Adv Monitor */ +static struct adv_monitor *monitor_new(struct adv_monitor_app *app, + GDBusProxy *proxy) +{ + struct adv_monitor *monitor; + + if (!app || !proxy) + return NULL; + + monitor = new0(struct adv_monitor, 1); + if (!monitor) + return NULL; + + monitor->app = app; + monitor->proxy = g_dbus_proxy_ref(proxy); + monitor->path = g_strdup(g_dbus_proxy_get_path(proxy)); + + monitor->state = MONITOR_STATE_NEW; + + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + + monitor->type = MONITOR_TYPE_NONE; + monitor->patterns = NULL; + + return monitor; +} + +/* Matches a monitor based on its D-Bus path */ +static bool monitor_match(const void *a, const void *b) +{ + const GDBusProxy *proxy = b; + const struct adv_monitor *monitor = a; + + if (!proxy || !monitor) + return false; + + if (strcmp(g_dbus_proxy_get_path(proxy), monitor->path) != 0) + return false; + + return true; +} + +/* Retrieves Type from the remote Adv Monitor object, verifies the value and + * update the local Adv Monitor + */ +static bool parse_monitor_type(struct adv_monitor *monitor, const char *path) +{ + DBusMessageIter iter; + const struct adv_monitor_type *t; + const char *type_str; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (!g_dbus_proxy_get_property(monitor->proxy, "Type", &iter)) { + btd_error(adapter_id, "Failed to retrieve property Type from " + "the Adv Monitor at path %s", path); + return false; + } + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + goto failed; + + dbus_message_iter_get_basic(&iter, &type_str); + + for (t = supported_types; t->name; t++) { + if (strcmp(t->name, type_str) == 0) { + monitor->type = t->type; + return true; + } + } + +failed: + btd_error(adapter_id, "Invalid argument of property Type of the Adv " + "Monitor at path %s", path); + + return false; +} + +/* Retrieves RSSIThresholdsAndTimers from the remote Adv Monitor object, + * verifies the values and update the local Adv Monitor + */ +static bool parse_rssi_and_timeout(struct adv_monitor *monitor, + const char *path) +{ + DBusMessageIter prop_struct, iter; + int16_t h_rssi, l_rssi; + uint16_t h_rssi_timer, l_rssi_timer; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + /* Property RSSIThresholdsAndTimers is optional */ + if (!g_dbus_proxy_get_property(monitor->proxy, + "RSSIThresholdsAndTimers", + &prop_struct)) { + DBG("Adv Monitor at path %s provides no RSSI thresholds and " + "timeouts", path); + return true; + } + + if (dbus_message_iter_get_arg_type(&prop_struct) != DBUS_TYPE_STRUCT) + goto failed; + + dbus_message_iter_recurse(&prop_struct, &iter); + + /* Extract HighRSSIThreshold */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) + goto failed; + dbus_message_iter_get_basic(&iter, &h_rssi); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract HighRSSIThresholdTimer */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) + goto failed; + dbus_message_iter_get_basic(&iter, &h_rssi_timer); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract LowRSSIThreshold */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) + goto failed; + dbus_message_iter_get_basic(&iter, &l_rssi); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract LowRSSIThresholdTimer */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) + goto failed; + dbus_message_iter_get_basic(&iter, &l_rssi_timer); + + /* Verify the values of RSSIs and their timers. For simplicity, we + * enforce the all-or-none rule to these fields. In other words, either + * all are set to the unset values or all are set within valid ranges. + */ + if (h_rssi == ADV_MONITOR_UNSET_RSSI && + l_rssi == ADV_MONITOR_UNSET_RSSI && + h_rssi_timer == ADV_MONITOR_UNSET_TIMER && + l_rssi_timer == ADV_MONITOR_UNSET_TIMER) { + goto done; + } + + if (h_rssi < ADV_MONITOR_MIN_RSSI || h_rssi > ADV_MONITOR_MAX_RSSI || + l_rssi < ADV_MONITOR_MIN_RSSI || + l_rssi > ADV_MONITOR_MAX_RSSI || h_rssi <= l_rssi) { + goto failed; + } + + if (h_rssi_timer < ADV_MONITOR_MIN_TIMER || + h_rssi_timer > ADV_MONITOR_MAX_TIMER || + l_rssi_timer < ADV_MONITOR_MIN_TIMER || + l_rssi_timer > ADV_MONITOR_MAX_TIMER) { + goto failed; + } + + monitor->high_rssi = h_rssi; + monitor->low_rssi = l_rssi; + monitor->high_rssi_timeout = h_rssi_timer; + monitor->low_rssi_timeout = l_rssi_timer; + +done: + DBG("Adv Monitor at %s initiated with high RSSI threshold %d, high " + "RSSI threshold timeout %d, low RSSI threshold %d, low RSSI " + "threshold timeout %d", path, monitor->high_rssi, + monitor->high_rssi_timeout, monitor->low_rssi, + monitor->low_rssi_timeout); + + return true; + +failed: + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + + btd_error(adapter_id, "Invalid argument of property " + "RSSIThresholdsAndTimers of the Adv Monitor at path %s", + path); + + return false; +} + +/* Retrieves Patterns from the remote Adv Monitor object, verifies the values + * and update the local Adv Monitor + */ +static bool parse_patterns(struct adv_monitor *monitor, const char *path) +{ + DBusMessageIter array, array_iter; + uint16_t num_patterns = 0; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (!g_dbus_proxy_get_property(monitor->proxy, "Patterns", &array)) { + btd_error(adapter_id, "Failed to retrieve property Patterns " + "from the Adv Monitor at path %s", path); + return false; + } + + monitor->patterns = queue_new(); + + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY || + dbus_message_iter_get_element_type(&array) != + DBUS_TYPE_STRUCT) { + goto failed; + } + + dbus_message_iter_recurse(&array, &array_iter); + + while (dbus_message_iter_get_arg_type(&array_iter) == + DBUS_TYPE_STRUCT) { + int value_len; + uint8_t *value; + uint8_t offset, ad_type; + struct pattern *pattern; + DBusMessageIter struct_iter, value_iter; + + dbus_message_iter_recurse(&array_iter, &struct_iter); + + // Extract start position + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_BYTE) { + goto failed; + } + dbus_message_iter_get_basic(&struct_iter, &offset); + if (!dbus_message_iter_next(&struct_iter)) + goto failed; + + // Extract AD data type + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_BYTE) { + goto failed; + } + dbus_message_iter_get_basic(&struct_iter, &ad_type); + if (!dbus_message_iter_next(&struct_iter)) + goto failed; + + // Extract value of a pattern + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_ARRAY) { + goto failed; + } + dbus_message_iter_recurse(&struct_iter, &value_iter); + dbus_message_iter_get_fixed_array(&value_iter, &value, + &value_len); + + // Verify the values + if (offset > BT_AD_MAX_DATA_LEN - 1) + goto failed; + + if (ad_type > BT_AD_3D_INFO_DATA && + ad_type != BT_AD_MANUFACTURER_DATA + || ad_type < BT_AD_FLAGS) { + goto failed; + } + + if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) + goto failed; + + pattern = new0(struct pattern, 1); + if (!pattern) + goto failed; + + pattern->ad_type = ad_type; + pattern->offset = offset; + pattern->length = value_len; + memcpy(pattern->value, value, pattern->length); + + queue_push_tail(monitor->patterns, pattern); + + dbus_message_iter_next(&array_iter); + } + + /* There must be at least one pattern. */ + if (queue_isempty(monitor->patterns)) + goto failed; + + return true; + +failed: + queue_destroy(monitor->patterns, pattern_free); + monitor->patterns = NULL; + + btd_error(adapter_id, "Invalid argument of property Patterns of the " + "Adv Monitor at path %s", path); + + return false; +} + +/* Processes the content of the remote Adv Monitor */ +static bool monitor_process(struct adv_monitor *monitor, + struct adv_monitor_app *app) +{ + const char *path = g_dbus_proxy_get_path(monitor->proxy); + + monitor->state = MONITOR_STATE_FAILED; + + if (!parse_monitor_type(monitor, path)) + goto done; + + if (!parse_rssi_and_timeout(monitor, path)) + goto done; + + if (monitor->type == MONITOR_TYPE_OR_PATTERNS && + parse_patterns(monitor, path)) { + monitor->state = MONITOR_STATE_INITED; + } + +done: + return monitor->state != MONITOR_STATE_FAILED; +} + +/* Handles an Adv Monitor D-Bus proxy added event */ +static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) +{ + struct adv_monitor *monitor; + struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + const char *path = g_dbus_proxy_get_path(proxy); + const char *iface = g_dbus_proxy_get_interface(proxy); + + if (strcmp(iface, ADV_MONITOR_INTERFACE) != 0 || + !g_str_has_prefix(path, app->path)) { + return; + } + + if (queue_find(app->monitors, monitor_match, proxy)) { + btd_error(adapter_id, "Adv Monitor proxy already exists with " + "path %s", path); + return; + } + + monitor = monitor_new(app, proxy); + if (!monitor) { + btd_error(adapter_id, "Failed to allocate an Adv Monitor for " + "the object at %s", path); + return; + } + + if (!monitor_process(monitor, app)) { + monitor_release(monitor, NULL); + monitor_free(monitor); + DBG("Adv Monitor at path %s released due to invalid content", + path); + return; + } + + queue_push_tail(app->monitors, monitor); + + DBG("Adv Monitor allocated for the object at path %s", path); +} + +/* Handles the removal of an Adv Monitor D-Bus proxy */ +static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) +{ + struct adv_monitor *monitor; + struct adv_monitor_app *app = user_data; + + monitor = queue_remove_if(app->monitors, monitor_match, proxy); + if (monitor) { + DBG("Adv Monitor removed for the object at path %s", + monitor->path); + + /* The object was gone, so we don't need to call Release() */ + monitor_free(monitor); + } +} + /* Creates an app object, initiates it and sets D-Bus event handlers */ static struct adv_monitor_app *app_create(DBusConnection *conn, DBusMessage *msg, const char *sender, @@ -161,8 +626,17 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, return NULL; } + app->monitors = queue_new(); + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); - g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); + + /* Note that any property changes on a monitor object would not affect + * the content of the corresponding monitor. + */ + g_dbus_client_set_proxy_handlers(app->client, monitor_proxy_added_cb, + monitor_proxy_removed_cb, NULL, + app); + g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); app->reg = dbus_message_ref(msg); @@ -269,18 +743,6 @@ static const GDBusMethodTable adv_monitor_methods[] = { { } }; -enum monitor_type { - MONITOR_TYPE_OR_PATTERNS, -}; - -const struct adv_monitor_type { - enum monitor_type type; - const char *name; -} supported_types[] = { - { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, - { }, -}; - /* Gets SupportedMonitorTypes property */ static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, DBusMessageIter *iter, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YGmIIXIFWl+ZwAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 12:52:34 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id ACaTHnIFWl+nOQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 12:52:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=oracle.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D5D3E4097B; Thu, 10 Sep 2020 12:52:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730357AbgIJKv5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 06:51:57 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37704 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730326AbgIJKtt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 06:49:49 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08AAYPWK177381; Thu, 10 Sep 2020 10:49:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=fN/ETYUSmj9/pRoUk3iHgY2Npxy2z+BXnfBD/U2xvEE=; b=a68PNyTuR/Ya7gDF83LDKZQwcJPvMkAb8MTEijJIo8fXjvS5/dm2yiB8iBvckb6OO4/V yR1giJXwGSHbLA6bJgRepaaLySl/LcC01ieNDGys7GTX6TcHtikMJbTS26UOsvAw4a9W aAdXPBGpbBL1Tx/GqkI/L7T7LWg1/36uU2Hkmd6HnGEcocw3vJhJlug+qGVHcBqO7bJX kQYf7e+l0+sVFw5cGLjN+jOVt7HOuG3t1cdCyNrIJQrEGNfzWtEtdGK48DGcSuEomfDk 93MRfMYzfeZugwO4tH6FUIIxGCayOxvU3wPFIQN0leeWDXjlzH69xGeyA3A90zn+ofpc wg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 33c3an76nw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Sep 2020 10:49:33 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08AAkerQ067429; Thu, 10 Sep 2020 10:49:33 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 33cmm0rd75-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Sep 2020 10:49:32 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 08AAnRgq022266; Thu, 10 Sep 2020 10:49:27 GMT Received: from kadam (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 10 Sep 2020 03:49:27 -0700 Date: Thu, 10 Sep 2020 13:49:18 +0300 From: Dan Carpenter <dan.carpenter@oracle.com> To: Anmol Karn <anmol.karan123@gmail.com> Cc: marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Subject: Re: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer dereference in hci_event_packet() Message-ID: <20200910104918.GF12635@kadam> References: <20200910043424.19894-1-anmol.karan123@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200910043424.19894-1-anmol.karan123@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9739 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009100099 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9739 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 priorityscore=1501 clxscore=1011 bulkscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 mlxscore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009100098 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.30 / 15.00 / 15.00 X-Rspamd-Queue-Id: D5D3E4097B X-Rspamd-UID: ed0810 On Thu, Sep 10, 2020 at 10:04:24AM +0530, Anmol Karn wrote: > Prevent hci_phy_link_complete_evt() from dereferencing 'hcon->amp_mgr' > as NULL. Fix it by adding pointer check for it. > > Reported-and-tested-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com > Link: https://syzkaller.appspot.com/bug?extid=0bef568258653cff272f > Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> > --- > net/bluetooth/hci_event.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 4b7fc430793c..871e16804433 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -4936,6 +4936,11 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > return; > } > > + if (IS_ERR_OR_NULL(hcon->amp_mgr)) { It can't be an error pointer. Shouldn't we call hci_conn_del() on this path? Try to find the Fixes tag to explain how this bug was introduced. (Don't rush to send a v2. The patch requires quite a bit more digging and detective work before it is ready). > + hci_dev_unlock(hdev); > + return; > + } > + > if (ev->status) { > hci_conn_del(hcon); > hci_dev_unlock(hdev); regards, dan carpenter Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ELciILAFWl8o1AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 12:53:36 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id GIN0HbAFWl+taAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 12:53:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0F5DDA0B49; Thu, 10 Sep 2020 12:53:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730401AbgIJKw7 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 06:52:59 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:46355 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730474AbgIJKuw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 06:50:52 -0400 Received: from ironmsg07-lv.qualcomm.com (HELO ironmsg07-lv.qulacomm.com) ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 10 Sep 2020 03:50:37 -0700 Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg07-lv.qulacomm.com with ESMTP/TLS/AES256-SHA; 10 Sep 2020 03:50:35 -0700 Received: from gubbaven-linux.qualcomm.com ([10.206.64.32]) by ironmsg02-blr.qualcomm.com with ESMTP; 10 Sep 2020 16:20:11 +0530 Received: by gubbaven-linux.qualcomm.com (Postfix, from userid 2365015) id 8518521993; Thu, 10 Sep 2020 16:20:10 +0530 (IST) From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org, Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Subject: [RESEND v1] arm64: dts: qcom: sc7180: Remove clock for bluetooth on SC7180 IDP board Date: Thu, 10 Sep 2020 16:19:40 +0530 Message-Id: <1599734980-22580-1-git-send-email-gubbaven@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.08 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0F5DDA0B49 X-Rspamd-UID: 0507a1 Removed voting for RPMH_RF_CLK2 which is not required as it is getting managed by BT SoC through SW_CTRL line. Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> --- arch/arm64/boot/dts/qcom/sc7180-idp.dts | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/sc7180-idp.dts b/arch/arm64/boot/dts/qcom/sc7180-idp.dts index 4e9149d..b295d01 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-idp.dts +++ b/arch/arm64/boot/dts/qcom/sc7180-idp.dts @@ -348,7 +348,6 @@ vddrf-supply = <&vreg_l2c_1p3>; vddch0-supply = <&vreg_l10c_3p3>; max-speed = <3200000>; - clocks = <&rpmhcc RPMH_RF_CLK2>; }; }; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2GE0BURjWl9DgQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 19:32:52 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uCA1AURjWl9MIwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 19:32:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7003540971; Thu, 10 Sep 2020 19:32:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbgIJRcj (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 13:32:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbgIJRbR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 13:31:17 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69700C061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 10:31:17 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id c10so6004476otm.13 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 10:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zLOL42WhH5FDVrNrUe2dZwNkTM/X4NgsReg97pw0a4U=; b=K9C0Cm3Vz2EC0wIiTdGkNrH6m1lXVeVvdVNnWboeuRptj21fj8un67TkWhmiPpPRbA qSzPZMtVTpEAFkQ+wmoyt6nxMjSqNt58nhQhShe34cdhnF9Q8uMFBWs5CmIhATqO1+ks GttfggaZ9cQ7S+cWOw3fu5r57v+AvktErZmJTYYJX/3SXplxjPpKGgWIhIIabOwzZQLS h/ti/Lk+QgCH+kPHaxr9m6gHoYLS8pEPIMKRuH0Bva4OvK29q/NXSPUgxMjHc6KxA4NV V0RVVhIdUmtrKfuW/eCSMi8a8PmKlLFLrqmpTk2jNvQ0bVmVPeaWupP9Szu2IXgmLBPc 84rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zLOL42WhH5FDVrNrUe2dZwNkTM/X4NgsReg97pw0a4U=; b=sR8SQ31CgkCPE7YGLd01w90P2vCPVakqbjVcVWbAZJNnMouVEWDp8RVC8zMVtIYqZn 4vopcTsugfL+mkoKhnZI29BYzeePl8wJbZBrU3+DNRSrCNU3wOpMN+6uWTbEnfuwbydT HApP7giP4mk+cHpYjacxhGdsNfva1BKJ+pdm6bcURxL5Da63G3GuC6ru26uMGIyuVJD4 YUL4Es0/B+UQr2iLLqPmFIoCfrYpttIMUa0v4Rhjfy83KEDZt8CB/CYYreUniKucC+eP rhm2FLtweDHgGW+IdPJFh/Aep8XgZCKPKmuEMjHta/8TxMAMqsznRht/HVEue4p6J8Oi kokg== X-Gm-Message-State: AOAM531jFpK/vyNuJJhJcZKK28H5XLWlzsu6dfUw8j+KnNwszm2X0htq OaCDFC2s6UyLetja+LUVIz2iSdlzADavrfR9Zc8= X-Google-Smtp-Source: ABdhPJyI0GjrcVo93ihV8TnKCILCw9OLaeywYcFxN+X0m7ycZO7/i5eXjP5RE0G0vzmz+4XrGO5nJofk+8hB6ySyeqU= X-Received: by 2002:a9d:2208:: with SMTP id o8mr4418050ota.362.1599759075415; Thu, 10 Sep 2020 10:31:15 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <CABBYNZLoGG8_f-8Vr=FW-mVe1uFsz-ob3-=tuk_c90kqhtLMVg@mail.gmail.com> <CABmPvSHWTr+v5jKbBDWus5RRZBprzrwb5UiT0jn4hJVqv0vbug@mail.gmail.com> In-Reply-To: <CABmPvSHWTr+v5jKbBDWus5RRZBprzrwb5UiT0jn4hJVqv0vbug@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 10 Sep 2020 10:31:04 -0700 Message-ID: <CABBYNZK1nyC=hEHYwa03Q-urzk5WtJv9R-dnAmfpRvLJ0wOqKQ@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.65 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7003540971 X-Rspamd-UID: f47fe4 Hi Miao, On Wed, Sep 9, 2020 at 9:52 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > Hi Luiz, > > On Tue, Sep 8, 2020 at 10:19 AM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Miao, > > > > On Tue, Aug 18, 2020 at 3:30 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > > > This introduces the org.bluez.AdvertisementMonitorManager1 without > > > implementing handlers of methods and properties. > > > > > > The following test was performed. > > > - Upon adapter registration, the info line of creating an ADV monitor > > > manager gets printed, and system bus emits the interface events of > > > org.bluez.AdvertisementMonitorManager1. > > > > > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > > > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > > --- > > > > > > Makefile.am | 3 +- > > > src/adapter.c | 14 +++++ > > > src/adapter.h | 3 + > > > src/adv_monitor.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++ > > > src/adv_monitor.h | 32 ++++++++++ > > > 5 files changed, 200 insertions(+), 1 deletion(-) > > > create mode 100644 src/adv_monitor.c > > > create mode 100644 src/adv_monitor.h > > > > > > diff --git a/Makefile.am b/Makefile.am > > > index 7719c06f8..b14ee950e 100644 > > > --- a/Makefile.am > > > +++ b/Makefile.am > > > @@ -293,7 +293,8 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ > > > src/gatt-client.h src/gatt-client.c \ > > > src/device.h src/device.c \ > > > src/dbus-common.c src/dbus-common.h \ > > > - src/eir.h src/eir.c > > > + src/eir.h src/eir.c \ > > > + src/adv_monitor.h src/adv_monitor.c > > > > Id just name it monitor.{c, h} > It'd be preferable to avoid confusion by specifying "adv_" as the > prefix, since there is the other "monitor" (btmon) in BlueZ. Besides, > we also name the corresponding system configuration values by > "adv_monitor". Actually btmon is a tool though, but perhaps you are saying it would conflict with commit tagging/prefixing since we usually use monitor: for btmon changes, that is a fair point. We could perhaps just with advertising.c, but Im fine with adv_monitor as well. > > > > > src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ > > > gdbus/libgdbus-internal.la \ > > > src/libshared-glib.la \ > > > diff --git a/src/adapter.c b/src/adapter.c > > > index 5e896a9f0..41e9de286 100644 > > > --- a/src/adapter.c > > > +++ b/src/adapter.c > > > @@ -77,6 +77,7 @@ > > > #include "attrib-server.h" > > > #include "gatt-database.h" > > > #include "advertising.h" > > > +#include "adv_monitor.h" > > > #include "eir.h" > > > > > > #define ADAPTER_INTERFACE "org.bluez.Adapter1" > > > @@ -272,6 +273,8 @@ struct btd_adapter { > > > struct btd_gatt_database *database; > > > struct btd_adv_manager *adv_manager; > > > > > > + struct btd_adv_monitor_manager *adv_monitor_manager; > > > + > > > gboolean initialized; > > > > > > GSList *pin_callbacks; > > > @@ -6346,6 +6349,9 @@ static void adapter_remove(struct btd_adapter *adapter) > > > btd_adv_manager_destroy(adapter->adv_manager); > > > adapter->adv_manager = NULL; > > > > > > + btd_adv_monitor_manager_destroy(adapter->adv_monitor_manager); > > > + adapter->adv_monitor_manager = NULL; > > > + > > > g_slist_free(adapter->pin_callbacks); > > > adapter->pin_callbacks = NULL; > > > > > > @@ -8623,6 +8629,14 @@ static int adapter_register(struct btd_adapter *adapter) > > > > > > adapter->adv_manager = btd_adv_manager_new(adapter, adapter->mgmt); > > > > > > + adapter->adv_monitor_manager = btd_adv_monitor_manager_create( > > > + adapter, adapter->mgmt); > > > + if (!adapter->adv_monitor_manager) { > > > + btd_error(adapter->dev_id, > > > + "Failed to create Adv Monitor Manager for adapter"); > > > + return -EINVAL; > > > + } > > > + > > > db = btd_gatt_database_get_db(adapter->database); > > > adapter->db_id = gatt_db_register(db, services_modified, > > > services_modified, > > > diff --git a/src/adapter.h b/src/adapter.h > > > index f8ac20261..5cb467141 100644 > > > --- a/src/adapter.h > > > +++ b/src/adapter.h > > > @@ -26,6 +26,9 @@ > > > #include <dbus/dbus.h> > > > #include <glib.h> > > > > > > +#include "lib/bluetooth.h" > > > +#include "lib/sdp.h" > > > + > > > > It might be better to have this included locally in a .c file needing them. > > > This fixes the complaint from the compiler where the symbols referred > adapter.h was not found. This was revealed due to the circular > dependency between adv_monitor and adapter where adv_monitor needs to > include adapter.h for calling btd_adapter_get_index(), and adv_monitor > doesn't have these two includes. In other words, adapter.h has been > relying on other headers to include lib/sdp.h and lib/bluetooth.h > which was not a good pattern in the first place. Besides, adapter.h > does refer to symbols from lib/bluetooth.h and lib/sdp.h, so it makes > sense to have them here. Then let's have a separate patch and clean up the includes so we don't have includes duplicates everywhere. > > > #define MAX_NAME_LENGTH 248 > > > > > > /* Invalid SSP passkey value used to indicate negative replies */ > > > diff --git a/src/adv_monitor.c b/src/adv_monitor.c > > > new file mode 100644 > > > index 000000000..7044d3cca > > > --- /dev/null > > > +++ b/src/adv_monitor.c > > > @@ -0,0 +1,149 @@ > > > +/* > > > + * > > > + * BlueZ - Bluetooth protocol stack for Linux > > > + * > > > + * Copyright (C) 2020 Google LLC > > > + * > > > + * > > > + * This program is free software; you can redistribute it and/or > > > + * modify it under the terms of the GNU Lesser General Public > > > + * License as published by the Free Software Foundation; either > > > + * version 2.1 of the License, or (at your option) any later version. > > > + * > > > + * This program is distributed in the hope that it will be useful, > > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > > + * Lesser General Public License for more details. > > > + * > > > + */ > > > + > > > +#ifdef HAVE_CONFIG_H > > > +#include <config.h> > > > +#endif > > > + > > > +#define _GNU_SOURCE > > > +#include <stdint.h> > > > + > > > +#include <glib.h> > > > +#include <dbus/dbus.h> > > > +#include <gdbus/gdbus.h> > > > + > > > +#include "adapter.h" > > > +#include "dbus-common.h" > > > +#include "log.h" > > > +#include "src/shared/mgmt.h" > > > + > > > +#include "adv_monitor.h" > > > + > > > +#define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" > > > + > > > +struct btd_adv_monitor_manager { > > > + struct btd_adapter *adapter; > > > + struct mgmt *mgmt; > > > + uint16_t adapter_id; > > > + char *path; > > > +}; > > > + > > > +static const GDBusMethodTable adv_monitor_methods[] = { > > > + { GDBUS_METHOD("RegisterMonitor", > > > + GDBUS_ARGS({ "application", "o" }), > > > + NULL, NULL) }, > > > + { GDBUS_ASYNC_METHOD("UnregisterMonitor", > > > + GDBUS_ARGS({ "application", "o" }), > > > + NULL, NULL) }, > > > + { } > > > +}; > > > + > > > +static const GDBusPropertyTable adv_monitor_properties[] = { > > > + {"SupportedMonitorTypes", "as", NULL, NULL, NULL}, > > > + {"SupportedFeatures", "as", NULL, NULL, NULL}, > > > + { } > > > +}; > > > + > > > +/* Allocates a manager object */ > > > +static struct btd_adv_monitor_manager *manager_new( > > > + struct btd_adapter *adapter, > > > + struct mgmt *mgmt) > > > +{ > > > + struct btd_adv_monitor_manager *manager; > > > + > > > + if (!adapter || !mgmt) > > > + return NULL; > > > + > > > + manager = g_new0(struct btd_adv_monitor_manager, 1); > > > > Use new0. > > > > > + if (!manager) > > > + return NULL; > > > + > > > + manager->adapter = adapter; > > > + manager->mgmt = mgmt_ref(mgmt); > > > + manager->adapter_id = btd_adapter_get_index(adapter); > > > + manager->path = g_strdup(adapter_get_path(manager->adapter)); > > > > If we are doing to reference the adapter we don't really need the > > duplicate its path since we can just use adapter_get_path. > As a part of adapter bring-down, the adv monitor manager would be > destroyed too, and we should avoid accessing adapter's resource(s) > during the bring-down to avoid incorrect values. By making a copy of > the path, the code would be less error-prone since the adv monitor > manager does not depend on the unknown state of the adapter. Normally we do that by having the instance attached to the adapter, so when the adapter needs to be freed it would cleanup all objects depending on it so we can guarantee its resources are not released ahead of time. Note that while we are not focusing too hard in reducing the footprint of the stack I believe that is a good practice in the long run, specially when that involve heap allocation. > > > > > + > > > + return manager; > > > +} > > > + > > > +/* Frees a manager object */ > > > +static void manager_free(struct btd_adv_monitor_manager *manager) > > > +{ > > > + manager->adapter = NULL; > > > > No need to assign NULL if you are going to free the whole object at the end. > Done. > > > > > + mgmt_unref(manager->mgmt); > > > + manager->mgmt = NULL; > > > > Ditto. > Done. > > > > > + g_free(manager->path); > > > + manager->path = NULL; > > > > Ditto. > Done. > > > > > + > > > + g_free(manager); > > > +} > > > + > > > +/* Destroys a manager object and unregisters its D-Bus interface */ > > > +static void manager_destroy(struct btd_adv_monitor_manager *manager) > > > +{ > > > + if (!manager) > > > + return; > > > + > > > + g_dbus_unregister_interface(btd_get_dbus_connection(), > > > + manager->path, > > > + ADV_MONITOR_MGR_INTERFACE); > > > + > > > + manager_free(manager); > > > +} > > > + > > > +/* Creates a manager and registers its D-Bus interface */ > > > +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( > > > + struct btd_adapter *adapter, > > > + struct mgmt *mgmt) > > > +{ > > > + struct btd_adv_monitor_manager *manager; > > > + > > > + manager = manager_new(adapter, mgmt); > > > + if (!manager) > > > + return NULL; > > > + > > > + if (g_dbus_register_interface(btd_get_dbus_connection(), manager->path, > > > + ADV_MONITOR_MGR_INTERFACE, > > > + adv_monitor_methods, NULL, > > > + adv_monitor_properties, manager, NULL) > > > + == FALSE) { > > > > We haven't been consistent with boolean checks but lately we start > > using more the ! form instead of == FALSE. > Done. > > Thanks, > Miao > > > > > > > + btd_error(manager->adapter_id, > > > + "Failed to register " > > > + ADV_MONITOR_MGR_INTERFACE); > > > + manager_free(manager); > > > + return NULL; > > > + } > > > + > > > + btd_info(manager->adapter_id, > > > + "Adv Monitor Manager created for adapter %s", > > > + adapter_get_path(manager->adapter)); > > > + > > > + return manager; > > > +} > > > + > > > +/* Destroys a manager and unregisters its D-Bus interface */ > > > +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) > > > +{ > > > + if (!manager) > > > + return; > > > + > > > + btd_info(manager->adapter_id, "Destroy Adv Monitor Manager"); > > > + > > > + manager_destroy(manager); > > > +} > > > diff --git a/src/adv_monitor.h b/src/adv_monitor.h > > > new file mode 100644 > > > index 000000000..69ea348f8 > > > --- /dev/null > > > +++ b/src/adv_monitor.h > > > @@ -0,0 +1,32 @@ > > > +/* > > > + * > > > + * BlueZ - Bluetooth protocol stack for Linux > > > + * > > > + * Copyright (C) 2020 Google LLC > > > + * > > > + * > > > + * This program is free software; you can redistribute it and/or > > > + * modify it under the terms of the GNU Lesser General Public > > > + * License as published by the Free Software Foundation; either > > > + * version 2.1 of the License, or (at your option) any later version. > > > + * > > > + * This program is distributed in the hope that it will be useful, > > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > > + * Lesser General Public License for more details. > > > + * > > > + */ > > > + > > > +#ifndef __ADV_MONITOR_H > > > +#define __ADV_MONITOR_H > > > + > > > +struct mgmt; > > > +struct btd_adapter; > > > +struct btd_adv_monitor_manager; > > > + > > > +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( > > > + struct btd_adapter *adapter, > > > + struct mgmt *mgmt); > > > +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); > > > + > > > +#endif /* __ADV_MONITOR_H */ > > > -- > > > 2.26.2 > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0PENIUVmWl9QnQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 19:45:41 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iPIMHkVmWl+fOgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 19:45:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6611640981; Thu, 10 Sep 2020 19:45:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727028AbgIJRp1 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 13:45:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726973AbgIJRnf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 13:43:35 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3978C061757 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 10:43:34 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id y6so6725322oie.5 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 10:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=j7kn8gB+kxU9eN3AY5RgvnfQYBYcgCoCiotDOEu3YVQ=; b=RIuUCBKa38+6vQSbBxQpMWorkPP1vG4k9gO3j5pgusJ7yhasdtWiwHFFxmzqseyilv YWbDbRfXKRpQzvhhrDbtIdF5kf+oN1udLVBy02Mgeq0jqRD+X6+kt3FqwxdF35czXa/Z GprHcxoV/pwbMesovBpZmffZwE2HDniDWofmhOiLE3+R+jUNnxARctjCPiUQjO+8l8Na RUvDfmFSN7Oefi+Pyfw9OsP7ZR6/s/nIbbXyVP/DwqhTNMnR/NmVElh4S1VsmCzSyl0H O3yJ1AeNTro3SmYgNVn4Iv/6mHeQQ1111sPSKmzS1FSEW84rBPtSMxfMkp09Onq083ON 71DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=j7kn8gB+kxU9eN3AY5RgvnfQYBYcgCoCiotDOEu3YVQ=; b=J2AvoqfxFmVSDwqHiYW/dr/XrwQfU5y4rJdNA4O6gpcM76AUQQhks06OXxRucCyFm4 wca90UlC/uwgmYX9/QsT2kPceJz5MOTZtF4rpA4qRzMcxCqq2g+9WcxQEvl4vbIZTX4i Z75O3kg08KP5jALVZ/7Q+IxGv1VSb5bJVuemQ2lNr9YY6RT0uOQf5IWmVTOhh/RvxiVG S5ItrQDJvKbrBqTSIrB4E5qcHmGtts4aW1EEa2yQ4kP3gCiDaOcvX7bUYCQw+Td6n3Ti 9QGFh6BpdrkJk5j5R+4ONkJ5PcL95dMfKYOTpdVAjfw3bgblqnJMSmBPT0ykCmPbCM24 uEIw== X-Gm-Message-State: AOAM532mWFXx7YsRGTVbKUr0H/vU+fWhz2ZGmPIxC+BXAtRgSFN4UwYE UwxW8DmSOLPhoWznJeX6pHkAIotm+YiSkjs44SRvEMgUvL8= X-Google-Smtp-Source: ABdhPJxfzEqk07uyyHZyQ9x0mTwShhBJySeDS0r0rVF3/X5GJbLrkNfieGA18+HMOLAXQywCFoBlItyR42Yi4BPajNE= X-Received: by 2002:aca:aad0:: with SMTP id t199mr685707oie.48.1599759813999; Thu, 10 Sep 2020 10:43:33 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <20200818152612.BlueZ.v1.7.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> <CABBYNZLCZ9FCEH=Z3sHzsg-jw_4CvnbMxBNbQem=x0JE_+y7NA@mail.gmail.com> <CABmPvSEMoJEfpFPgnytgr+ig6TquAtg2kN+WpvAJ1oX6jUs6+Q@mail.gmail.com> In-Reply-To: <CABmPvSEMoJEfpFPgnytgr+ig6TquAtg2kN+WpvAJ1oX6jUs6+Q@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 10 Sep 2020 10:43:23 -0700 Message-ID: <CABBYNZKTQsHP9r_WqrQTkof3DQ5kRXTHNBcXRkR8k2d==vDmxQ@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 7/7] doc/advertisement-monitor-api: Update Advertisement Monitor API description To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.48 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6611640981 X-Rspamd-UID: bfcc84 Hi Miao, On Wed, Sep 9, 2020 at 9:53 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > Hi Luiz, > > On Tue, Sep 8, 2020 at 10:40 AM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Miao, > > > > On Tue, Aug 18, 2020 at 3:34 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > > > This modifies the following description to Advertisement Monitor API. > > > - Add org.bluez.Error.Failed to RegisterMonitor() method. > > > - Add more description about the usage of RegisterMonitor() and > > > UnregisterMonitor() methods. > > > - Add description about the ranges for the fields in property > > > RSSIThresholdsAndTimers. > > > > > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > > > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > > > --- > > > > > > doc/advertisement-monitor-api.txt | 34 +++++++++++++++++++++++-------- > > > 1 file changed, 25 insertions(+), 9 deletions(-) > > > > > > diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt > > > index 74adbfae9..e09b6fd25 100644 > > > --- a/doc/advertisement-monitor-api.txt > > > +++ b/doc/advertisement-monitor-api.txt > > > @@ -49,7 +49,7 @@ Properties string Type [read-only] > > > org.bluez.AdvertisementMonitorManager1 for the available > > > options. > > > > > > - (Int16, Uint16, Int16, Uint16) RSSIThreshholdsAndTimers [read-only, optional] > > > + (Int16, Uint16, Int16, Uint16) RSSIThresholdsAndTimers [read-only, optional] > > > > > > This contains HighRSSIThreshold, HighRSSIThresholdTimer, > > > LowRSSIThreshold, LowRSSIThresholdTimer in order. The > > > @@ -66,7 +66,11 @@ Properties string Type [read-only] > > > RSSIs of the received advertisement(s) during > > > LowRSSIThresholdTimer do not reach LowRSSIThreshold. > > > > > > - array{(uint8, uint8, string)} Patterns [read-only, optional] > > > + The valid range of a RSSI is -127 to +20 dBm while 127 > > > + dBm indicates unset. The valid range of a timer is 1 to > > > + 300 seconds while 0 indicates unset. > > > + > > > + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] > > > > > > If Type is set to 0x01, this must exist and has at least > > > one entry in the array. > > > @@ -80,8 +84,9 @@ Properties string Type [read-only] > > > See https://www.bluetooth.com/specifications/ > > > assigned-numbers/generic-access-profile/ for > > > the possible allowed value. > > > - string content_of_pattern > > > - This is the value of the pattern. > > > + array{byte} content_of_pattern > > > + This is the value of the pattern. The maximum > > > + length of the bytes is 31. > > > > > > Advertisement Monitor Manager hierarchy > > > ======================================= > > > @@ -91,20 +96,31 @@ Object path /org/bluez/{hci0,hci1,...} > > > > > > Methods void RegisterMonitor(object application) > > > > > > - This registers a hierarchy of advertisement monitors. > > > + This registers the root path of a hierarchy of > > > + advertisement monitors. > > > The application object path together with the D-Bus > > > system bus connection ID define the identification of > > > the application registering advertisement monitors. > > > + Once a root path is registered by a client via this > > > + method, the client can freely expose/unexpose > > > + advertisement monitors without re-registering the root > > > + path again. After use, the client should call > > > + UnregisterMonitor() method to invalidate the > > > + advertisement monitors. > > > > > > Possible errors: org.bluez.Error.InvalidArguments > > > org.bluez.Error.AlreadyExists > > > + org.bluez.Error.Failed > > > > > > void UnregisterMonitor(object application) > > > > > > - This unregisters advertisement monitors that have been > > > - previously registered. The object path parameter must > > > - match the same value that has been used on > > > - registration. > > > + This unregisters a hierarchy of advertisement monitors > > > + that has been previously registered. The object path > > > + parameter must match the same value that has been used > > > + on registration. Upon unregistration, the advertisement > > > + monitor(s) should expect to receive Release() method as > > > + the signal that the advertisement monitor(s) has been > > > + deactivated. > > > > > > Possible errors: org.bluez.Error.InvalidArguments > > > org.bluez.Error.DoesNotExist > > > -- > > > 2.26.2 > > > > These are still experimental so you will need to use EXPERIMENTAL > > version when declaring the methods/properties so it only gets enabled > > when the experimental flag is passed to bluetoothd. > g_dbus_register_interface() does not allow to have all methods and > properties marked as experimental, so at least SupportedFeatures > should be non-experimental. You will need to do something like the following: if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) You can see how it was used in adv_manager: https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=d6e9539e31c6bb5afd39ec6f09c518d232e6345d > > > > > > -- > > Luiz Augusto von Dentz > > Thanks, > Miao -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OJJkF8WRWl/ItgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 10 Sep 2020 22:51:17 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kPioFMWRWl9MIwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 10 Sep 2020 22:51:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EA1924096B; Thu, 10 Sep 2020 22:51:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727853AbgIJUuw (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 16:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730068AbgIJO6n (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 10:58:43 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD8A8C061795; Thu, 10 Sep 2020 07:58:40 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id k13so1044584plk.3; Thu, 10 Sep 2020 07:58:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=c+jIOhRgqonxn9gWi6l8ZpfFwoQ7z7WBsHFiC8anX4Q=; b=XlGQF9XuctO2DJYPSPyHeW/lhATtADGhO23JHJstE97qMSAVFSOSjRevCHH7cLnmaa jKTk78ZhaxVjcb8GFw6y0ZK8/pc8YFnqe4Lgfvm350Yr4zOuigj1OwYcEZBH3Fa4Hopd f2JXQHcI7zIHWelYGT6BuO83OC2dMWcNELYXUx4ZjPMrYWABvYwXh5wvauERBXEA/KCj zCt73zratrDhMlwwRpv+qOG+TmdiqmVO5iKLq0V6KvZD3HDG8fJW3c7nnv6bHUbecrJX YSQ8qskzWdy9o9G+gn160C00yYczl8y5zKz5xQ/4lfR4AV2VL6BYF64Yo15qph5FiK4V D1Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=c+jIOhRgqonxn9gWi6l8ZpfFwoQ7z7WBsHFiC8anX4Q=; b=k1iFeVdRvPFwGcc0KG0CviBRulCH75QjTnk6SXPF0lHxkYlyHfFA19DEGfmF+urN5h H3+B6NPyJ/iuqWO8us4gURIUrpOT7I9F9bUu0mOGWQOIGSOhOgaxyPUANtKjkMB37EoC h3yZDlRt9rtaJN3YFKVCTAb7k06eWGU9ue1hE+QO1x+70mWpEdqRjzCd0EgPDr4ZamVQ R9HN7EsZHB21qcSFH3vjYeoUVeFRheuG6itE/Vljqetj63N5d7XgZ5VSQFCRZU60HYQG 4ZPCuvHpMioau1V361I9AxZgGAOXD2o/UE9CU2J9nda9cukoEIdUZjrjXGS+ZJRFWzbr L6og== X-Gm-Message-State: AOAM530NfY/T/L/SLP+oICPO8LR/KgGsSoZpsQb8TTs8+9hkzMfSIusK Paor6MEoIkLzDsdjg17/m9c= X-Google-Smtp-Source: ABdhPJyTyJInU3Ew5guC7S18EaBMn+CWm5koR7QxwkkRlVYQ2qn3nQcqOq07OGTmQ8ifN6WumFExOg== X-Received: by 2002:a17:90a:81:: with SMTP id a1mr336645pja.136.1599749920004; Thu, 10 Sep 2020 07:58:40 -0700 (PDT) Received: from Thinkpad ([45.118.165.135]) by smtp.gmail.com with ESMTPSA id j2sm5424250pga.12.2020.09.10.07.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 07:58:39 -0700 (PDT) Date: Thu, 10 Sep 2020 20:28:31 +0530 From: Anmol Karn <anmol.karan123@gmail.com> To: Dan Carpenter <dan.carpenter@oracle.com> Cc: marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Subject: Re: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer dereference in hci_event_packet() Message-ID: <20200910145831.GA33757@Thinkpad> References: <20200910043424.19894-1-anmol.karan123@gmail.com> <20200910104918.GF12635@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200910104918.GF12635@kadam> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.87 / 15.00 / 15.00 X-Rspamd-Queue-Id: EA1924096B X-Rspamd-UID: 93880d On Thu, Sep 10, 2020 at 01:49:18PM +0300, Dan Carpenter wrote: > On Thu, Sep 10, 2020 at 10:04:24AM +0530, Anmol Karn wrote: > > Prevent hci_phy_link_complete_evt() from dereferencing 'hcon->amp_mgr' > > as NULL. Fix it by adding pointer check for it. > > > > Reported-and-tested-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com > > Link: https://syzkaller.appspot.com/bug?extid=0bef568258653cff272f > > Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> > > --- > > net/bluetooth/hci_event.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > index 4b7fc430793c..871e16804433 100644 > > --- a/net/bluetooth/hci_event.c > > +++ b/net/bluetooth/hci_event.c > > @@ -4936,6 +4936,11 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > > return; > > } > > > > + if (IS_ERR_OR_NULL(hcon->amp_mgr)) { > > It can't be an error pointer. Shouldn't we call hci_conn_del() on this > path? Try to find the Fixes tag to explain how this bug was introduced. > > (Don't rush to send a v2. The patch requires quite a bit more digging > and detective work before it is ready). > > > + hci_dev_unlock(hdev); > > + return; > > + } > > + > > if (ev->status) { > > hci_conn_del(hcon); > > hci_dev_unlock(hdev); > > regards, > dan carpenter > Sure sir, will work on it, thanks for your review. Anmol Karn Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wPg2C7ezWl/LJgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:16:07 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qI4HCLezWl+XvgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:16:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BFA5CA015E; Fri, 11 Sep 2020 01:16:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725468AbgIJXP7 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgIJXP6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:15:58 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED714C061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:15:57 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id md22so1833087pjb.0 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:15:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2F5IK3qZINJFDEk93oe4o+MOz1G8iOkBit6CICWcYW8=; b=jfRasZRMcAvd4x1ZNWM1q00IZXvYjePr/UPbQO/ByaYen9gfVeFY3ku86CfOaFK9zO 1zW+VSnpqxBNcVbmL7i6KkDNLsYLsprwxpt33134exD1lttWz0Pt5hKQmjzU9cggkFrw 7NC0GbyBtcSXokbtRquCpNmX7j04Zs/qR8xGI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2F5IK3qZINJFDEk93oe4o+MOz1G8iOkBit6CICWcYW8=; b=dwCglpFW+2D4XQJ6QwVupHX3h9Fy9dex3B+WB7zIg5gwUwC7EWCWEk/8vim0aDrfTR Ermpt3DwmvCBWXsRCyjWGUyMsKeSoVAIgxwTbMauRbOjp5Yp+wgGONJYwA4WT7uZZkGi +PXFPTGcl9cbVFJKN6gImW/+r0yq1+ks2aw13897jsqyxFIigGemifArAmtBxlhNFYT7 UBQjISWBjs7op/vn83haoEPHQOS0fbxsSU/c8Stu635R44zEupBImHGAVCxKPLbCb7LY ruWk0Wl1AS0p1GJwSED0HnN0fwAgPtfVQ7z12NtAE63yYjoIq2J1wXLLTV9LZnVdLmSb Myew== X-Gm-Message-State: AOAM530P4Yn8A2hWFiORs5juj9ENILwNSST9dQqm7/556WiBZf6ZEzj0 imOvqB5hovgUIFPDvphJ+gbVCq7VqCpBNQ== X-Google-Smtp-Source: ABdhPJzpMByzqa+jMtoioFNTdJjgfYt+tVzwWXGSXdO8JiL9GFXv3cn+VNGz7GfgdTg+wV0y3HDKtQ== X-Received: by 2002:a17:90a:a111:: with SMTP id s17mr2175091pjp.28.1599779757122; Thu, 10 Sep 2020 16:15:57 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k29sm76790pgf.21.2020.09.10.16.15.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2020 16:15:56 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 1/8] adapter: Remove indirect dependency of headers Date: Thu, 10 Sep 2020 16:15:42 -0700 Message-Id: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.38 / 15.00 / 15.00 X-Rspamd-Queue-Id: BFA5CA015E X-Rspamd-UID: 0d49a6 Given that adapter.h refers symbols from lib/bluetooth.h and lib/sdp.h, these two headers should be included directly in adapter.h. Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adapter.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..c70a7b0da 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -26,6 +26,9 @@ #include <dbus/dbus.h> #include <glib.h> +#include <lib/bluetooth.h> +#include <lib/sdp.h> + #define MAX_NAME_LENGTH 248 /* Invalid SSP passkey value used to indicate negative replies */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iLTUL9uzWl/4NAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:16:43 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id WOIzLduzWl9m4gEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:16:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7F1AFA020E; Fri, 11 Sep 2020 01:16:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725535AbgIJXQh (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:16:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgIJXQg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:16:36 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53DE7C061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:16:35 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id q4so769622pjh.5 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L7YRHIBwgxu+HNJl5jw/YP+Lqt16XnCV/vha56q9iUU=; b=EeYqLRi/rSZiDzGeNbXOVjyWkE9BcGJ5ve0zP4HnwVqGB+wZ8BGJ7lpCJr2VWUYShf BskNWMN1RDeD/dHk5Px7a9moQNOxE/H4ym5M+mhqc48UMkgIx2j7YhoBAjwj1oHJY6ml aWZzgFCbLyOAkZw4E+0FzL4T8RsHM+oHf2Ii0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L7YRHIBwgxu+HNJl5jw/YP+Lqt16XnCV/vha56q9iUU=; b=jN2Y2hZCQZcVpaTwRE5dHu7ZNutfCjhbgzSDHzG1RNQPzQCc1vTiElgtRNYGEFv+bY +9lQcpjuBZd4JfVO5BFlZc8spoV0Ukq78Da+zs9Vv/mfBKTKQR/uUrfbNhUudw7xxt5h 9hJbf5MFHK3N0+yKPY0OoMy+ixUh4YLSyp5Jtzt88OCyhlk5VBY6zp8PMe0S6tEZNPac YV5zebVEoLHlHNWebTZ/8qZezaKaLEq1N8uJFd5HNAIotQhuuKlpEDCbT8fTVpmTAJ+G vhpZgx5UOmTSQwqZx8CLA6GyjLVrzw88D5iYIsKovafvcC+07kT9ogZ8NOjZfOz/sNfE 9Fbw== X-Gm-Message-State: AOAM532rjTgJDdT82lcy1o39KW7/lDnm1zxyPHzepNIgcB7/Vyq1OcT1 2kitspVGmZE+lX1u0g6FgclFsOnfhrAo1Q== X-Google-Smtp-Source: ABdhPJxJ116swXHwZjyxzaIdIsY3gd1VPhx/7NEJDmdsixwLrJjwVPJM3xsveYtHZCTVJ9m+Nhk/dQ== X-Received: by 2002:a17:90a:ca17:: with SMTP id x23mr2054236pjt.96.1599779792885; Thu, 10 Sep 2020 16:16:32 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k29sm76790pgf.21.2020.09.10.16.16.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2020 16:16:32 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v4 2/8] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Date: Thu, 10 Sep 2020 16:15:44 -0700 Message-Id: <20200910161528.BlueZ.v4.2.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.54 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7F1AFA020E X-Rspamd-UID: ad21bf This introduces the org.bluez.AdvertisementMonitorManager1 without implementing handlers of methods and properties. The following test was performed. - Upon adapter registration, the info line of creating an ADV monitor manager gets printed, and system bus emits the interface events of org.bluez.AdvertisementMonitorManager1. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Changes in v4: -Create the Adv Monitor Manager only if the experimental flag is in place and mark all properties and methods experimental. Changes in v2: -Use new0 instead of g_new0 -Remove the reset of manager members -Make methods/property experimental Makefile.am | 3 +- src/adapter.c | 23 ++++++++ src/adv_monitor.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++ src/adv_monitor.h | 32 ++++++++++ 4 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 src/adv_monitor.c create mode 100644 src/adv_monitor.h diff --git a/Makefile.am b/Makefile.am index 7719c06f8..b14ee950e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -293,7 +293,8 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ src/gatt-client.h src/gatt-client.c \ src/device.h src/device.c \ src/dbus-common.c src/dbus-common.h \ - src/eir.h src/eir.c + src/eir.h src/eir.c \ + src/adv_monitor.h src/adv_monitor.c src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ gdbus/libgdbus-internal.la \ src/libshared-glib.la \ diff --git a/src/adapter.c b/src/adapter.c index 1435e2bd7..df628a7fd 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -77,6 +77,7 @@ #include "attrib-server.h" #include "gatt-database.h" #include "advertising.h" +#include "adv_monitor.h" #include "eir.h" #define ADAPTER_INTERFACE "org.bluez.Adapter1" @@ -272,6 +273,8 @@ struct btd_adapter { struct btd_gatt_database *database; struct btd_adv_manager *adv_manager; + struct btd_adv_monitor_manager *adv_monitor_manager; + gboolean initialized; GSList *pin_callbacks; @@ -6360,6 +6363,9 @@ static void adapter_remove(struct btd_adapter *adapter) btd_adv_manager_destroy(adapter->adv_manager); adapter->adv_manager = NULL; + btd_adv_monitor_manager_destroy(adapter->adv_monitor_manager); + adapter->adv_monitor_manager = NULL; + g_slist_free(adapter->pin_callbacks); adapter->pin_callbacks = NULL; @@ -8633,6 +8639,23 @@ static int adapter_register(struct btd_adapter *adapter) adapter->adv_manager = btd_adv_manager_new(adapter, adapter->mgmt); + if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) { + if (adapter->supported_settings & MGMT_SETTING_LE) { + adapter->adv_monitor_manager = + btd_adv_monitor_manager_create(adapter, + adapter->mgmt); + if (!adapter->adv_monitor_manager) { + btd_error(adapter->dev_id, + "Failed to create Adv Monitor " + "Manager for adapter"); + return -EINVAL; + } + } else { + btd_info(adapter->dev_id, "Adv Monitor Manager " + "skipped, LE unavailable"); + } + } + db = btd_gatt_database_get_db(adapter->database); adapter->db_id = gatt_db_register(db, services_modified, services_modified, diff --git a/src/adv_monitor.c b/src/adv_monitor.c new file mode 100644 index 000000000..ad3f64cbe --- /dev/null +++ b/src/adv_monitor.c @@ -0,0 +1,147 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdint.h> + +#include <glib.h> +#include <dbus/dbus.h> +#include <gdbus/gdbus.h> + +#include "adapter.h" +#include "dbus-common.h" +#include "log.h" +#include "src/shared/mgmt.h" +#include "src/shared/util.h" + +#include "adv_monitor.h" + +#define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" + +struct btd_adv_monitor_manager { + struct btd_adapter *adapter; + struct mgmt *mgmt; + uint16_t adapter_id; +}; + +static const GDBusMethodTable adv_monitor_methods[] = { + { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { } +}; + +static const GDBusPropertyTable adv_monitor_properties[] = { + {"SupportedMonitorTypes", "as", NULL, NULL, NULL, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, + {"SupportedFeatures", "as", NULL, NULL, NULL, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, + { } +}; + +/* Allocates a manager object */ +static struct btd_adv_monitor_manager *manager_new( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + if (!adapter || !mgmt) + return NULL; + + manager = new0(struct btd_adv_monitor_manager, 1); + if (!manager) + return NULL; + + manager->adapter = adapter; + manager->mgmt = mgmt_ref(mgmt); + manager->adapter_id = btd_adapter_get_index(adapter); + + return manager; +} + +/* Frees a manager object */ +static void manager_free(struct btd_adv_monitor_manager *manager) +{ + mgmt_unref(manager->mgmt); + + free(manager); +} + +/* Destroys a manager object and unregisters its D-Bus interface */ +static void manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + g_dbus_unregister_interface(btd_get_dbus_connection(), + adapter_get_path(manager->adapter), + ADV_MONITOR_MGR_INTERFACE); + + manager_free(manager); +} + +/* Creates a manager and registers its D-Bus interface */ +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + manager = manager_new(adapter, mgmt); + if (!manager) + return NULL; + + if (!g_dbus_register_interface(btd_get_dbus_connection(), + adapter_get_path(manager->adapter), + ADV_MONITOR_MGR_INTERFACE, + adv_monitor_methods, NULL, + adv_monitor_properties, manager, + NULL)) { + btd_error(manager->adapter_id, + "Failed to register " + ADV_MONITOR_MGR_INTERFACE); + manager_free(manager); + return NULL; + } + + btd_info(manager->adapter_id, + "Adv Monitor Manager created for adapter %s", + adapter_get_path(manager->adapter)); + + return manager; +} + +/* Destroys a manager and unregisters its D-Bus interface */ +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + btd_info(manager->adapter_id, "Destroy Adv Monitor Manager"); + + manager_destroy(manager); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h new file mode 100644 index 000000000..69ea348f8 --- /dev/null +++ b/src/adv_monitor.h @@ -0,0 +1,32 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifndef __ADV_MONITOR_H +#define __ADV_MONITOR_H + +struct mgmt; +struct btd_adapter; +struct btd_adv_monitor_manager; + +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt); +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); + +#endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2IGGLu+zWl/LJgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:17:03 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CC9mK++zWl8CCQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:17:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AD9AAA010E; Fri, 11 Sep 2020 01:16:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725536AbgIJXQ4 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:16:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgIJXQv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:16:51 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82FFCC061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:16:51 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id n14so5749132pff.6 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:16:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BejR8qAus2RHmqZfVAIMNzptugCWKxms8mfB3nvBKeY=; b=AYzdn/enarf2RpwkQ1oM3+B63VtG+xB+s8kMFgzATyu4UrM0OV+fHDcgt/syO/CkwB 8Ah6/7aGRgIT73+dulZALiq1i5Sbw0spGrKiJo4nIHye3BkXF+b6o2iv4+UqQVlPHQUq t1cUi65gl0aHFPFtwhWmnBxANjKKzfrSZ8eRw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BejR8qAus2RHmqZfVAIMNzptugCWKxms8mfB3nvBKeY=; b=XiMh4sek3xpaPcxlHXSkb1qXKoa2CCD/EspKigDFoH2kK4BKGQFeIMq662onHNp0IG xloWVoojiPWpuGaiUts94q5BFEj1h518wuw2Grxc0Ut8XUdPsrdl3nAL6nFWDArQjV2U szvakWm/N4c69Dpyv/EdxJNMcd+JH0Zx24cSjRBXZvwMCWvHxR/xG3bMWVZ80FkSPj7s 2YRBmmWS5yhlX+FsChyXQ3wkZHKFkwY1loRtaUrz5M1ccyt4jcBQn+FHruDjf1SDJn/U poo3tsSsbNHMygTLFGdmHEgoMSjrxyEjdMeLPXBhVmxvMxTF0JYYzDXuuUBg4xlWrjdy Ydkg== X-Gm-Message-State: AOAM531NDvgnEwYrn6uuukP8KFZDc4IUhY6QJTGCkrsPGY1TfaWHdPbk JlY207UzfCTmq1MZCf2zYIxiu00qFEnh+Q== X-Google-Smtp-Source: ABdhPJzw6st7wlMuktjKldEWunmclmZbl1BTElU19YBJk0keUs55vdA2sEPxj1ZUFTqVQAHeNekHOA== X-Received: by 2002:aa7:9409:: with SMTP id x9mr7965749pfo.142.1599779810715; Thu, 10 Sep 2020 16:16:50 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k29sm76790pgf.21.2020.09.10.16.16.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2020 16:16:50 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v4 3/8] adv_monitor: Implement Get functions of Adv monitor manager properties Date: Thu, 10 Sep 2020 16:15:46 -0700 Message-Id: <20200910161528.BlueZ.v4.3.I9960e45d36be3edb5f17de025e7eb8257d3cddef@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.31 / 15.00 / 15.00 X-Rspamd-Queue-Id: AD9AAA010E X-Rspamd-UID: 6df3dd This implements the Get functions of SupportedMonitorTypes and SupportedFeatures. The following test was performed. - Issue dbus-send to read SupportedMonitorTypes and SupportedFeatures. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v1) src/adv_monitor.c | 127 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 5 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index ad3f64cbe..fc37b0145 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -28,6 +28,9 @@ #include <dbus/dbus.h> #include <gdbus/gdbus.h> +#include "lib/bluetooth.h" +#include "lib/mgmt.h" + #include "adapter.h" #include "dbus-common.h" #include "log.h" @@ -42,6 +45,11 @@ struct btd_adv_monitor_manager { struct btd_adapter *adapter; struct mgmt *mgmt; uint16_t adapter_id; + + uint32_t supported_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ + uint32_t enabled_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ + uint16_t max_num_monitors; + uint8_t max_num_patterns; }; static const GDBusMethodTable adv_monitor_methods[] = { @@ -54,10 +62,78 @@ static const GDBusMethodTable adv_monitor_methods[] = { { } }; +enum monitor_type { + MONITOR_TYPE_OR_PATTERNS, +}; + +const struct adv_monitor_type { + enum monitor_type type; + const char *name; +} supported_types[] = { + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, + { }, +}; + +/* Gets SupportedMonitorTypes property */ +static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, + DBusMessageIter *iter, + void *data) +{ + DBusMessageIter entry; + const struct adv_monitor_type *t; + struct btd_adv_monitor_manager *manager = data; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, + &entry); + + for (t = supported_types; t->name; t++) { + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, + &t->name); + } + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + +const struct adv_monitor_feature { + uint32_t mask; + const char *name; +} supported_features[] = { + { MGMT_ADV_MONITOR_FEATURE_MASK_OR_PATTERNS, "controller-patterns" }, + { } +}; + +/* Gets SupportedFeatures property */ +static gboolean get_supported_features(const GDBusPropertyTable *property, + DBusMessageIter *iter, + void *data) +{ + DBusMessageIter entry; + const struct adv_monitor_feature *f; + struct btd_adv_monitor_manager *manager = data; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, + &entry); + + for (f = supported_features; f->name; f++) { + if (manager->supported_features & f->mask) { + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, + &f->name); + } + } + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + static const GDBusPropertyTable adv_monitor_properties[] = { - {"SupportedMonitorTypes", "as", NULL, NULL, NULL, + {"SupportedMonitorTypes", "as", get_supported_monitor_types, NULL, NULL, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, - {"SupportedFeatures", "as", NULL, NULL, NULL, + {"SupportedFeatures", "as", get_supported_features, NULL, NULL, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, { } }; @@ -104,6 +180,42 @@ static void manager_destroy(struct btd_adv_monitor_manager *manager) manager_free(manager); } +/* Initiates manager's members based on the return of + * MGMT_OP_READ_ADV_MONITOR_FEATURES + */ +static void read_adv_monitor_features_cb(uint8_t status, uint16_t length, + const void *param, + void *user_data) +{ + const struct mgmt_rp_read_adv_monitor_features *rp = param; + struct btd_adv_monitor_manager *manager = user_data; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(manager->adapter_id, "Failed to Read Adv Monitor " + "Features with status 0x%02x", status); + return; + } + + if (length < sizeof(*rp)) { + btd_error(manager->adapter_id, + "Wrong size of Read Adv Monitor Features " + "response"); + return; + } + + manager->supported_features = le32_to_cpu(rp->supported_features); + manager->enabled_features = le32_to_cpu(rp->enabled_features); + manager->max_num_monitors = le16_to_cpu(rp->max_num_handles); + manager->max_num_patterns = rp->max_num_patterns; + + btd_info(manager->adapter_id, "Adv Monitor Manager created with " + "supported features:0x%08x, enabled features:0x%08x, " + "max number of supported monitors:%d, " + "max number of supported patterns:%d", + manager->supported_features, manager->enabled_features, + manager->max_num_monitors, manager->max_num_patterns); +} + /* Creates a manager and registers its D-Bus interface */ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct btd_adapter *adapter, @@ -128,9 +240,14 @@ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( return NULL; } - btd_info(manager->adapter_id, - "Adv Monitor Manager created for adapter %s", - adapter_get_path(manager->adapter)); + if (!mgmt_send(manager->mgmt, MGMT_OP_READ_ADV_MONITOR_FEATURES, + manager->adapter_id, 0, NULL, + read_adv_monitor_features_cb, manager, NULL)) { + btd_error(manager->adapter_id, + "Failed to send Read Adv Monitor Features"); + manager_destroy(manager); + return NULL; + } return manager; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qEHsHzS0Wl/LJgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:18:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id sJcnHTS0Wl9aagAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:18:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id ED0E3A016F; Fri, 11 Sep 2020 01:18:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725562AbgIJXSF (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:18:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgIJXSD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:18:03 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1E80C061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:18:02 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id x123so5742514pfc.7 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OwcQPbWK9wBBKShQmm51i7xxWQDNt4zUBesrzpNnDCQ=; b=hMfupg7qDjfXkmunwm5bLnNs2RQTsaUyZvoSbHGXPuxnBNRo/kk0+rg99gBhYFwyWj RWXbUha50lxLrosBzNOCmDQ3BGKmA6p2ULd91LqOIcwAcfsGHXlupM1FFchpbydsEV+P n3JDyxrOpnSMb3ENcIXnBESDAmqwZ0leVxCRU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OwcQPbWK9wBBKShQmm51i7xxWQDNt4zUBesrzpNnDCQ=; b=fnlAUd4Cpzd7mZoz8Y1x+OQe7XUqOhQ6mgXVPhx9eSwoXULMJDEhXuBO01nz8Q7dFt 5TeCapf70BK43L5NnBuX2uAHYhyytOhTUkxDmZJJTHBkRwZySLXlQ8NlUihhP6pYinPW D0NAtui99IfJwKivO1C0MSo4cAbZgWVCuWCmaerVYQlGEoaiIici/LgQM5/f3ISxfmiT 2ANDhGwSsU9AxPtzgsVkyvGa50kwfz97yi4sBM/cwCyejZMvLFhWXWoLWGnF1k/Jzwbl uPMofel0/F+oLsOwICXDS0s8EwXa6UfAB9J5+JSZlFbvTsiM5Wqy1KW90D3qcx3psB/A uD9w== X-Gm-Message-State: AOAM532SP5J7ei3/l4rot63cVTDU+GGFMgy801KfafGhivfMpSrsMqON iiSmar2zOHwaYePVxzwGwRiDg46IC+9f3g== X-Google-Smtp-Source: ABdhPJzGs/I3r7GTdRO38SVjmTT3AOSidBJHUP78dslrtp29w5XT6CsYYYX708Dv8rRt7kdM9sv58w== X-Received: by 2002:a17:902:a40e:: with SMTP id p14mr7526567plq.4.1599779881464; Thu, 10 Sep 2020 16:18:01 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id k29sm76790pgf.21.2020.09.10.16.18.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2020 16:18:00 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 8/8] doc: Update Advertisement Monitor API description Date: Thu, 10 Sep 2020 16:15:56 -0700 Message-Id: <20200910161528.BlueZ.v4.8.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.82 / 15.00 / 15.00 X-Rspamd-Queue-Id: ED0E3A016F X-Rspamd-UID: 447ee8 This modifies the following description to Advertisement Monitor API. - Add org.bluez.Error.Failed to RegisterMonitor() method. - Add more description about the usage of RegisterMonitor() and UnregisterMonitor() methods. - Add description about the ranges for the fields in property RSSIThresholdsAndTimers. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) doc/advertisement-monitor-api.txt | 34 +++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index 74adbfae9..e09b6fd25 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -49,7 +49,7 @@ Properties string Type [read-only] org.bluez.AdvertisementMonitorManager1 for the available options. - (Int16, Uint16, Int16, Uint16) RSSIThreshholdsAndTimers [read-only, optional] + (Int16, Uint16, Int16, Uint16) RSSIThresholdsAndTimers [read-only, optional] This contains HighRSSIThreshold, HighRSSIThresholdTimer, LowRSSIThreshold, LowRSSIThresholdTimer in order. The @@ -66,7 +66,11 @@ Properties string Type [read-only] RSSIs of the received advertisement(s) during LowRSSIThresholdTimer do not reach LowRSSIThreshold. - array{(uint8, uint8, string)} Patterns [read-only, optional] + The valid range of a RSSI is -127 to +20 dBm while 127 + dBm indicates unset. The valid range of a timer is 1 to + 300 seconds while 0 indicates unset. + + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] If Type is set to 0x01, this must exist and has at least one entry in the array. @@ -80,8 +84,9 @@ Properties string Type [read-only] See https://www.bluetooth.com/specifications/ assigned-numbers/generic-access-profile/ for the possible allowed value. - string content_of_pattern - This is the value of the pattern. + array{byte} content_of_pattern + This is the value of the pattern. The maximum + length of the bytes is 31. Advertisement Monitor Manager hierarchy ======================================= @@ -91,20 +96,31 @@ Object path /org/bluez/{hci0,hci1,...} Methods void RegisterMonitor(object application) - This registers a hierarchy of advertisement monitors. + This registers the root path of a hierarchy of + advertisement monitors. The application object path together with the D-Bus system bus connection ID define the identification of the application registering advertisement monitors. + Once a root path is registered by a client via this + method, the client can freely expose/unexpose + advertisement monitors without re-registering the root + path again. After use, the client should call + UnregisterMonitor() method to invalidate the + advertisement monitors. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.AlreadyExists + org.bluez.Error.Failed void UnregisterMonitor(object application) - This unregisters advertisement monitors that have been - previously registered. The object path parameter must - match the same value that has been used on - registration. + This unregisters a hierarchy of advertisement monitors + that has been previously registered. The object path + parameter must match the same value that has been used + on registration. Upon unregistration, the advertisement + monitor(s) should expect to receive Release() method as + the signal that the advertisement monitor(s) has been + deactivated. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.DoesNotExist -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sJu2DH8eW19fagEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 08:51:43 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id gKfxCX8eW1/xaAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 08:51:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 43565A0B2B; Fri, 11 Sep 2020 08:51:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725791AbgIKGvR (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 02:51:17 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:57501 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725769AbgIKGvN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 02:51:13 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 024E7CED19; Fri, 11 Sep 2020 08:58:06 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v1 3/4] Bluetooth: hci_intel: switch to list_for_each_entry() From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200903184850.53055-3-andriy.shevchenko@linux.intel.com> Date: Fri, 11 Sep 2020 08:51:11 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <C4F05E7F-B874-4D36-A6CD-0B691DCF27D6@holtmann.org> References: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> <20200903184850.53055-3-andriy.shevchenko@linux.intel.com> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.66 / 15.00 / 15.00 X-Rspamd-Queue-Id: 43565A0B2B X-Rspamd-UID: 690cac Hi Andy, > There is no need to have list_for_each() followed by list_entry() > when we simply may use list_for_each_entry() directly. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > drivers/bluetooth/hci_intel.c | 31 ++++++++++--------------------- > 1 file changed, 10 insertions(+), 21 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KHPwN74fW18qiwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 08:57:02 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0BB2Nb4fW1/BtwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 08:57:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3BD6740971; Fri, 11 Sep 2020 08:56:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725768AbgIKG4s convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 02:56:48 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:48119 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725497AbgIKG4s (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 02:56:48 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 15FBBCED19; Fri, 11 Sep 2020 09:03:41 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v1] Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <0101017457c6b810-cb8b79ae-4663-436b-83d0-4c70c245bd25-000000@us-west-2.amazonses.com> Date: Fri, 11 Sep 2020 08:56:45 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, c-hbandi@codeaurora.org, hemantg@codeaurora.org, mka@chromium.org Content-Transfer-Encoding: 8BIT Message-Id: <2E48211B-D62D-43D8-9C97-014966FBB2CB@holtmann.org> References: <0101017457c6b810-cb8b79ae-4663-436b-83d0-4c70c245bd25-000000@us-west-2.amazonses.com> To: Rocky Liao <rjliao@codeaurora.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.09 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3BD6740971 X-Rspamd-UID: c56091 Hi Rocky, > This patch add support for WCN6855 i.e. patch and nvm download > support. > > Signed-off-by: Rocky Liao <rjliao@codeaurora.org> > --- > drivers/bluetooth/btusb.c | 42 +++++++++++++++++++++++++++++++++++---- > 1 file changed, 38 insertions(+), 4 deletions(-) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index fe80588c7bd3..e51e754ca9b8 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver; > #define BTUSB_MEDIATEK 0x200000 > #define BTUSB_WIDEBAND_SPEECH 0x400000 > #define BTUSB_VALID_LE_STATES 0x800000 > +#define BTUSB_QCA_WCN6855 0x1000000 > > static const struct usb_device_id btusb_table[] = { > /* Generic Bluetooth USB device */ > @@ -273,6 +274,10 @@ static const struct usb_device_id blacklist_table[] = { > { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME }, > { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME }, > > + /* QCA WCN6855 chipset */ > + { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 | > + BTUSB_WIDEBAND_SPEECH }, > + > /* Broadcom BCM2035 */ > { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, > { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU }, > @@ -3391,6 +3396,26 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev, > return 0; > } > > +static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev, > + const bdaddr_t *bdaddr) > +{ > + struct sk_buff *skb; > + u8 buf[6]; > + long ret; > + > + memcpy(buf, bdaddr, sizeof(bdaddr_t)); > + > + skb = __hci_cmd_sync(hdev, 0xfc14, sizeof(buf), buf, HCI_INIT_TIMEOUT); > + if (IS_ERR(skb)) { > + ret = PTR_ERR(skb); > + bt_dev_err(hdev, "Change address command failed (%ld)", ret); > + return ret; > + } > + kfree_skb(skb); > + > + return 0; > +} What is wrong with using qca_set_bdaddr() function. > + > #define QCA_DFU_PACKET_LEN 4096 > > #define QCA_GET_TARGET_VERSION 0x09 > @@ -3428,6 +3453,8 @@ static const struct qca_device_info qca_devices_table[] = { > { 0x00000201, 28, 4, 18 }, /* Rome 2.1 */ > { 0x00000300, 28, 4, 18 }, /* Rome 3.0 */ > { 0x00000302, 28, 4, 18 }, /* Rome 3.2 */ > + { 0x00130100, 40, 4, 18 }, /* WCN6855 1.0 */ > + { 0x00130200, 40, 4, 18 } /* WCN6855 2.0 */ > }; > > static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request, > @@ -3530,7 +3557,7 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, > struct qca_rampatch_version *rver; > const struct firmware *fw; > u32 ver_rom, ver_patch; > - u16 rver_rom, rver_patch; > + u32 rver_rom, rver_patch; > char fwname[64]; > int err; > > @@ -3552,6 +3579,9 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, > rver_rom = le16_to_cpu(rver->rom_version); > rver_patch = le16_to_cpu(rver->patch_version); > > + if (ver_rom & ~0xffffU) > + rver_rom = *(u16 *)(fw->data + 16) << 16 | rver_rom; > + You will require proper unaligned access unless you can guarantee things are aligned properly. And since I assume the firmware data is in a specific endian format, you need to convert it correctly. In addition, you change the variables to u32, but still use le16_to_cpu function above. Something is not adding up. Have you actually run a sparse check? > bt_dev_info(hdev, "QCA: patch rome 0x%x build 0x%x, " > "firmware rome 0x%x build 0x%x", > rver_rom, rver_patch, ver_rom, ver_patch); > @@ -3625,9 +3655,6 @@ static int btusb_setup_qca(struct hci_dev *hdev) > return err; > > ver_rom = le32_to_cpu(ver.rom_version); > - /* Don't care about high ROM versions */ > - if (ver_rom & ~0xffffU) > - return 0; > > for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) { > if (ver_rom == qca_devices_table[i].rom_version) > @@ -4063,6 +4090,13 @@ static int btusb_probe(struct usb_interface *intf, > btusb_check_needs_reset_resume(intf); > } > > + if (id->driver_info & BTUSB_QCA_WCN6855) { > + data->setup_on_usb = btusb_setup_qca; > + hdev->set_bdaddr = btusb_set_bdaddr_wcn6855; > + hdev->cmd_timeout = btusb_qca_cmd_timeout; > + set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); > + } > + Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8Dc/ICwgW18qiwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 08:58:52 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WHnpHCwgW1/B9AAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 08:58:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6AB9A40941; Fri, 11 Sep 2020 08:58:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725797AbgIKG6k convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 02:58:40 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:40536 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbgIKG6j (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 02:58:39 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id EF163CED1A; Fri, 11 Sep 2020 09:05:32 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH -next] Bluetooth: btmtksdio: use NULL instead of zero From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200905121549.32936-1-yuehaibing@huawei.com> Date: Fri, 11 Sep 2020 08:58:37 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, Matthias Brugger <matthias.bgg@gmail.com>, Sean Wang <sean.wang@mediatek.com>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <6B0D45D0-7390-4DCF-B85B-8DD0C6EAC8A2@holtmann.org> References: <20200905121549.32936-1-yuehaibing@huawei.com> To: YueHaibing <yuehaibing@huawei.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.62 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6AB9A40941 X-Rspamd-UID: d1ba6a Hi Yue, > Fix sparse warnings: > > drivers/bluetooth/btmtksdio.c:499:57: warning: Using plain integer as NULL pointer > drivers/bluetooth/btmtksdio.c:533:57: warning: Using plain integer as NULL pointer > > Signed-off-by: YueHaibing <yuehaibing@huawei.com> > --- > drivers/bluetooth/btmtksdio.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aOm3Cma0Wl/LJgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:19:02 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 0MIZCGa0Wl9FJAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:19:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A9694A0B0E; Fri, 11 Sep 2020 01:18:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725379AbgIJXSw (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:18:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725300AbgIJXSt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:18:49 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF453C061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:18:48 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id y4so10326816ljk.8 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7I1EYmWwJI62cSqzcr9blHF+mIPytz6lXOFRTJnTZCM=; b=SKBEX+frANYmPwvNTTqDpi3hkq+oeH0dhFH5233ibqOCScXNSIPMJ/J3AbQT2sCutn 1M4aAvtqEwTrC71129WXXdGhkAMc7FQ1rt4hcktg4o7EAQw+a+PsllYmM9hbM7Srn8pa +8biAoB6yAiqcl/nTR6VbOs4wpntV86+HkxIk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7I1EYmWwJI62cSqzcr9blHF+mIPytz6lXOFRTJnTZCM=; b=sYLoACUrrVSK1vTtuAKF9HGgOc+0D5AdO3OTv/TnCmgPKkLATWTALi6UoVNz/8Rmn2 kQEVkMLcM5qJAQrG5TO49pUKxAjDjQ3M7Vhzm50/fgSMF4FJpnEo6xBjqNwyC4XfDdEJ 8ca5XXJLaEXSOmvuhbLKfm7tkoZzak564sHrVHpfPVqgu6mVZ8kSOJLlQrEIv8i/pSg9 l+b7UwhIyk05npzXrD/OR8Zn1Zw8g/BCA0+N6WCfEF6Acx0HLEH6HvuaNuKmyxNvWGXV rBOEsLeEPSoQb5ZHiNfJJ+7vbCWAxUJ4BeC1u3W95L4ZZ0OthYt9qp9VeTtvdVRof69G 5XKA== X-Gm-Message-State: AOAM531+z5WcM9XxrEkoys579S4UIkxHETd1ex6EYct/frFAB9ck/r10 rpnPFNwW2PJT8lyUBgd8EjUELZLXs8NAtB0zL0gqjQ== X-Google-Smtp-Source: ABdhPJzqKa7d+rcp1GTSQyGOdMU78dRKeeXDzm3UYnVK3WZAr2H0dGT7PwZb01+nUo8a2u/z+5g/Al9cOjd4SVBZ6Mo= X-Received: by 2002:a2e:804f:: with SMTP id p15mr5711692ljg.199.1599779927107; Thu, 10 Sep 2020 16:18:47 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <CABBYNZLoGG8_f-8Vr=FW-mVe1uFsz-ob3-=tuk_c90kqhtLMVg@mail.gmail.com> <CABmPvSHWTr+v5jKbBDWus5RRZBprzrwb5UiT0jn4hJVqv0vbug@mail.gmail.com> <CABBYNZK1nyC=hEHYwa03Q-urzk5WtJv9R-dnAmfpRvLJ0wOqKQ@mail.gmail.com> In-Reply-To: <CABBYNZK1nyC=hEHYwa03Q-urzk5WtJv9R-dnAmfpRvLJ0wOqKQ@mail.gmail.com> From: Miao-chen Chou <mcchou@chromium.org> Date: Thu, 10 Sep 2020 16:18:35 -0700 Message-ID: <CABmPvSG8D-bTgFOMsJiLe5+m9VCyJjNnXyT0MOP8sSqX77sS=w@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.16 / 15.00 / 15.00 X-Rspamd-Queue-Id: A9694A0B0E X-Rspamd-UID: da5819 Hi Luiz, On Thu, Sep 10, 2020 at 10:31 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Miao, > > On Wed, Sep 9, 2020 at 9:52 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > Hi Luiz, > > > > On Tue, Sep 8, 2020 at 10:19 AM Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > > > > > > Hi Miao, > > > > > > On Tue, Aug 18, 2020 at 3:30 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > > > > > This introduces the org.bluez.AdvertisementMonitorManager1 without > > > > implementing handlers of methods and properties. > > > > > > > > The following test was performed. > > > > - Upon adapter registration, the info line of creating an ADV monitor > > > > manager gets printed, and system bus emits the interface events of > > > > org.bluez.AdvertisementMonitorManager1. > > > > > > > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > > > > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > > > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > > > --- > > > > > > > > Makefile.am | 3 +- > > > > src/adapter.c | 14 +++++ > > > > src/adapter.h | 3 + > > > > src/adv_monitor.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++ > > > > src/adv_monitor.h | 32 ++++++++++ > > > > 5 files changed, 200 insertions(+), 1 deletion(-) > > > > create mode 100644 src/adv_monitor.c > > > > create mode 100644 src/adv_monitor.h > > > > > > > > diff --git a/Makefile.am b/Makefile.am > > > > index 7719c06f8..b14ee950e 100644 > > > > --- a/Makefile.am > > > > +++ b/Makefile.am > > > > @@ -293,7 +293,8 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ > > > > src/gatt-client.h src/gatt-client.c \ > > > > src/device.h src/device.c \ > > > > src/dbus-common.c src/dbus-common.h \ > > > > - src/eir.h src/eir.c > > > > + src/eir.h src/eir.c \ > > > > + src/adv_monitor.h src/adv_monitor.c > > > > > > Id just name it monitor.{c, h} > > It'd be preferable to avoid confusion by specifying "adv_" as the > > prefix, since there is the other "monitor" (btmon) in BlueZ. Besides, > > we also name the corresponding system configuration values by > > "adv_monitor". > > Actually btmon is a tool though, but perhaps you are saying it would > conflict with commit tagging/prefixing since we usually use monitor: > for btmon changes, that is a fair point. We could perhaps just with > advertising.c, but Im fine with adv_monitor as well. > Yes, that's what I meant here. Then let's keep it as adv_monitor. > > > > > > > src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ > > > > gdbus/libgdbus-internal.la \ > > > > src/libshared-glib.la \ > > > > diff --git a/src/adapter.c b/src/adapter.c > > > > index 5e896a9f0..41e9de286 100644 > > > > --- a/src/adapter.c > > > > +++ b/src/adapter.c > > > > @@ -77,6 +77,7 @@ > > > > #include "attrib-server.h" > > > > #include "gatt-database.h" > > > > #include "advertising.h" > > > > +#include "adv_monitor.h" > > > > #include "eir.h" > > > > > > > > #define ADAPTER_INTERFACE "org.bluez.Adapter1" > > > > @@ -272,6 +273,8 @@ struct btd_adapter { > > > > struct btd_gatt_database *database; > > > > struct btd_adv_manager *adv_manager; > > > > > > > > + struct btd_adv_monitor_manager *adv_monitor_manager; > > > > + > > > > gboolean initialized; > > > > > > > > GSList *pin_callbacks; > > > > @@ -6346,6 +6349,9 @@ static void adapter_remove(struct btd_adapter *adapter) > > > > btd_adv_manager_destroy(adapter->adv_manager); > > > > adapter->adv_manager = NULL; > > > > > > > > + btd_adv_monitor_manager_destroy(adapter->adv_monitor_manager); > > > > + adapter->adv_monitor_manager = NULL; > > > > + > > > > g_slist_free(adapter->pin_callbacks); > > > > adapter->pin_callbacks = NULL; > > > > > > > > @@ -8623,6 +8629,14 @@ static int adapter_register(struct btd_adapter *adapter) > > > > > > > > adapter->adv_manager = btd_adv_manager_new(adapter, adapter->mgmt); > > > > > > > > + adapter->adv_monitor_manager = btd_adv_monitor_manager_create( > > > > + adapter, adapter->mgmt); > > > > + if (!adapter->adv_monitor_manager) { > > > > + btd_error(adapter->dev_id, > > > > + "Failed to create Adv Monitor Manager for adapter"); > > > > + return -EINVAL; > > > > + } > > > > + > > > > db = btd_gatt_database_get_db(adapter->database); > > > > adapter->db_id = gatt_db_register(db, services_modified, > > > > services_modified, > > > > diff --git a/src/adapter.h b/src/adapter.h > > > > index f8ac20261..5cb467141 100644 > > > > --- a/src/adapter.h > > > > +++ b/src/adapter.h > > > > @@ -26,6 +26,9 @@ > > > > #include <dbus/dbus.h> > > > > #include <glib.h> > > > > > > > > +#include "lib/bluetooth.h" > > > > +#include "lib/sdp.h" > > > > + > > > > > > It might be better to have this included locally in a .c file needing them. > > > > > This fixes the complaint from the compiler where the symbols referred > > adapter.h was not found. This was revealed due to the circular > > dependency between adv_monitor and adapter where adv_monitor needs to > > include adapter.h for calling btd_adapter_get_index(), and adv_monitor > > doesn't have these two includes. In other words, adapter.h has been > > relying on other headers to include lib/sdp.h and lib/bluetooth.h > > which was not a good pattern in the first place. Besides, adapter.h > > does refer to symbols from lib/bluetooth.h and lib/sdp.h, so it makes > > sense to have them here. > > Then let's have a separate patch and clean up the includes so we don't > have includes duplicates everywhere. > I believe these headers are the only two where adapter.h refers to the symbols. And I will split the changes as a separate one. > > > > #define MAX_NAME_LENGTH 248 > > > > > > > > /* Invalid SSP passkey value used to indicate negative replies */ > > > > diff --git a/src/adv_monitor.c b/src/adv_monitor.c > > > > new file mode 100644 > > > > index 000000000..7044d3cca > > > > --- /dev/null > > > > +++ b/src/adv_monitor.c > > > > @@ -0,0 +1,149 @@ > > > > +/* > > > > + * > > > > + * BlueZ - Bluetooth protocol stack for Linux > > > > + * > > > > + * Copyright (C) 2020 Google LLC > > > > + * > > > > + * > > > > + * This program is free software; you can redistribute it and/or > > > > + * modify it under the terms of the GNU Lesser General Public > > > > + * License as published by the Free Software Foundation; either > > > > + * version 2.1 of the License, or (at your option) any later version. > > > > + * > > > > + * This program is distributed in the hope that it will be useful, > > > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > > > + * Lesser General Public License for more details. > > > > + * > > > > + */ > > > > + > > > > +#ifdef HAVE_CONFIG_H > > > > +#include <config.h> > > > > +#endif > > > > + > > > > +#define _GNU_SOURCE > > > > +#include <stdint.h> > > > > + > > > > +#include <glib.h> > > > > +#include <dbus/dbus.h> > > > > +#include <gdbus/gdbus.h> > > > > + > > > > +#include "adapter.h" > > > > +#include "dbus-common.h" > > > > +#include "log.h" > > > > +#include "src/shared/mgmt.h" > > > > + > > > > +#include "adv_monitor.h" > > > > + > > > > +#define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" > > > > + > > > > +struct btd_adv_monitor_manager { > > > > + struct btd_adapter *adapter; > > > > + struct mgmt *mgmt; > > > > + uint16_t adapter_id; > > > > + char *path; > > > > +}; > > > > + > > > > +static const GDBusMethodTable adv_monitor_methods[] = { > > > > + { GDBUS_METHOD("RegisterMonitor", > > > > + GDBUS_ARGS({ "application", "o" }), > > > > + NULL, NULL) }, > > > > + { GDBUS_ASYNC_METHOD("UnregisterMonitor", > > > > + GDBUS_ARGS({ "application", "o" }), > > > > + NULL, NULL) }, > > > > + { } > > > > +}; > > > > + > > > > +static const GDBusPropertyTable adv_monitor_properties[] = { > > > > + {"SupportedMonitorTypes", "as", NULL, NULL, NULL}, > > > > + {"SupportedFeatures", "as", NULL, NULL, NULL}, > > > > + { } > > > > +}; > > > > + > > > > +/* Allocates a manager object */ > > > > +static struct btd_adv_monitor_manager *manager_new( > > > > + struct btd_adapter *adapter, > > > > + struct mgmt *mgmt) > > > > +{ > > > > + struct btd_adv_monitor_manager *manager; > > > > + > > > > + if (!adapter || !mgmt) > > > > + return NULL; > > > > + > > > > + manager = g_new0(struct btd_adv_monitor_manager, 1); > > > > > > Use new0. > > > > > > > + if (!manager) > > > > + return NULL; > > > > + > > > > + manager->adapter = adapter; > > > > + manager->mgmt = mgmt_ref(mgmt); > > > > + manager->adapter_id = btd_adapter_get_index(adapter); > > > > + manager->path = g_strdup(adapter_get_path(manager->adapter)); > > > > > > If we are doing to reference the adapter we don't really need the > > > duplicate its path since we can just use adapter_get_path. > > As a part of adapter bring-down, the adv monitor manager would be > > destroyed too, and we should avoid accessing adapter's resource(s) > > during the bring-down to avoid incorrect values. By making a copy of > > the path, the code would be less error-prone since the adv monitor > > manager does not depend on the unknown state of the adapter. > > Normally we do that by having the instance attached to the adapter, so > when the adapter needs to be freed it would cleanup all objects > depending on it so we can guarantee its resources are not released > ahead of time. Note that while we are not focusing too hard in > reducing the footprint of the stack I believe that is a good practice > in the long run, specially when that involve heap allocation. > Agree and I also check the procedure of adapter bring-down, the path would still be valid when invoking btd_adv_monitor_manager_destroy(), so it should be safe. > > > > > > > + > > > > + return manager; > > > > +} > > > > + > > > > +/* Frees a manager object */ > > > > +static void manager_free(struct btd_adv_monitor_manager *manager) > > > > +{ > > > > + manager->adapter = NULL; > > > > > > No need to assign NULL if you are going to free the whole object at the end. > > Done. > > > > > > > + mgmt_unref(manager->mgmt); > > > > + manager->mgmt = NULL; > > > > > > Ditto. > > Done. > > > > > > > + g_free(manager->path); > > > > + manager->path = NULL; > > > > > > Ditto. > > Done. > > > > > > > + > > > > + g_free(manager); > > > > +} > > > > + > > > > +/* Destroys a manager object and unregisters its D-Bus interface */ > > > > +static void manager_destroy(struct btd_adv_monitor_manager *manager) > > > > +{ > > > > + if (!manager) > > > > + return; > > > > + > > > > + g_dbus_unregister_interface(btd_get_dbus_connection(), > > > > + manager->path, > > > > + ADV_MONITOR_MGR_INTERFACE); > > > > + > > > > + manager_free(manager); > > > > +} > > > > + > > > > +/* Creates a manager and registers its D-Bus interface */ > > > > +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( > > > > + struct btd_adapter *adapter, > > > > + struct mgmt *mgmt) > > > > +{ > > > > + struct btd_adv_monitor_manager *manager; > > > > + > > > > + manager = manager_new(adapter, mgmt); > > > > + if (!manager) > > > > + return NULL; > > > > + > > > > + if (g_dbus_register_interface(btd_get_dbus_connection(), manager->path, > > > > + ADV_MONITOR_MGR_INTERFACE, > > > > + adv_monitor_methods, NULL, > > > > + adv_monitor_properties, manager, NULL) > > > > + == FALSE) { > > > > > > We haven't been consistent with boolean checks but lately we start > > > using more the ! form instead of == FALSE. > > Done. > > > > Thanks, > > Miao > > > > > > > > > > > + btd_error(manager->adapter_id, > > > > + "Failed to register " > > > > + ADV_MONITOR_MGR_INTERFACE); > > > > + manager_free(manager); > > > > + return NULL; > > > > + } > > > > + > > > > + btd_info(manager->adapter_id, > > > > + "Adv Monitor Manager created for adapter %s", > > > > + adapter_get_path(manager->adapter)); > > > > + > > > > + return manager; > > > > +} > > > > + > > > > +/* Destroys a manager and unregisters its D-Bus interface */ > > > > +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) > > > > +{ > > > > + if (!manager) > > > > + return; > > > > + > > > > + btd_info(manager->adapter_id, "Destroy Adv Monitor Manager"); > > > > + > > > > + manager_destroy(manager); > > > > +} > > > > diff --git a/src/adv_monitor.h b/src/adv_monitor.h > > > > new file mode 100644 > > > > index 000000000..69ea348f8 > > > > --- /dev/null > > > > +++ b/src/adv_monitor.h > > > > @@ -0,0 +1,32 @@ > > > > +/* > > > > + * > > > > + * BlueZ - Bluetooth protocol stack for Linux > > > > + * > > > > + * Copyright (C) 2020 Google LLC > > > > + * > > > > + * > > > > + * This program is free software; you can redistribute it and/or > > > > + * modify it under the terms of the GNU Lesser General Public > > > > + * License as published by the Free Software Foundation; either > > > > + * version 2.1 of the License, or (at your option) any later version. > > > > + * > > > > + * This program is distributed in the hope that it will be useful, > > > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > > > + * Lesser General Public License for more details. > > > > + * > > > > + */ > > > > + > > > > +#ifndef __ADV_MONITOR_H > > > > +#define __ADV_MONITOR_H > > > > + > > > > +struct mgmt; > > > > +struct btd_adapter; > > > > +struct btd_adv_monitor_manager; > > > > + > > > > +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( > > > > + struct btd_adapter *adapter, > > > > + struct mgmt *mgmt); > > > > +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); > > > > + > > > > +#endif /* __ADV_MONITOR_H */ > > > > -- > > > > 2.26.2 > > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Regards, Miao Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kFN+KvogW1/WkQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 09:02:18 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aGqwJ/ogW1/LtwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 09:02:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 07484A0B11; Fri, 11 Sep 2020 09:02:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725767AbgIKHCD convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 03:02:03 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:42917 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgIKHCB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 03:02:01 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 530AECED19; Fri, 11 Sep 2020 09:08:55 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [Linux-kernel-mentees] [PATCH v2] Bluetooth: Fix memory leak in read_adv_mon_features() From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200909072551.1101031-1-yepeilin.cs@gmail.com> Date: Fri, 11 Sep 2020 09:01:59 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, open list <linux-kernel@vger.kernel.org>, linux-kernel-mentees@lists.linuxfoundation.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: 8BIT Message-Id: <15999FE1-5227-4D55-8E3C-39142725FDA5@holtmann.org> References: <20200908200635.1099360-1-yepeilin.cs@gmail.com> <20200909072551.1101031-1-yepeilin.cs@gmail.com> To: Peilin Ye <yepeilin.cs@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.03 / 15.00 / 15.00 X-Rspamd-Queue-Id: 07484A0B11 X-Rspamd-UID: 40d234 Hi Peilin, > read_adv_mon_features() is leaking memory. Free `rp` before returning. > > Fixes: e5e1e7fd470c ("Bluetooth: Add handler of MGMT_OP_READ_ADV_MONITOR_FEATURES") > Reported-and-tested-by: syzbot+f7f6e564f4202d8601c6@syzkaller.appspotmail.com > Link: https://syzkaller.appspot.com/bug?extid=f7f6e564f4202d8601c6 > Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> > --- > I forgot the "Link:" tag yesterday. Sorry about that. > > Change in v2: > - add a proper "Link:" tag. > > net/bluetooth/mgmt.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gNqwCJUhW1/WkQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 09:04:53 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id eEijBZUhW18+kQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 09:04:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 64E27A0B6B; Fri, 11 Sep 2020 09:04:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725825AbgIKHEd convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 03:04:33 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:41326 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgIKHE3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 03:04:29 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id EAC5BCED19; Fri, 11 Sep 2020 09:11:23 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v1 1/4] Bluetooth: hci_intel: enable on new platform From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> Date: Fri, 11 Sep 2020 09:04:28 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <BB2D5D56-F018-4FF7-8DF8-198B3C8CE025@holtmann.org> References: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.72 / 15.00 / 15.00 X-Rspamd-Queue-Id: 64E27A0B6B X-Rspamd-UID: 8d382f Hi Andy, > On new Intel platform the device is provided with INT33E3 ID. > Append it to the list. > > This will require ACPI_GPIO_QUIRK_ONLY_GPIOIO to be enabled because > the relevant ASL looks like: > > UartSerialBusV2 ( ... ) > GpioInt ( ... ) { ... } > GpioIo ( ... ) { ... } > > which means that first GPIO resource is an interrupt, while we are expecting it > to be reset one (output). Do the same for host-wake because in case of > GpioInt() the platform_get_irq() will do the job and should return correct > Linux IRQ number. That said, host-wake GPIO can only be GpioIo() resource. > > While here, drop commas in terminator lines. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > drivers/bluetooth/hci_intel.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sIJYC/chW1/WkQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 09:06:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4EE1CPchW19HJwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 09:06:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5B24E4097C; Fri, 11 Sep 2020 09:06:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725890AbgIKHGL (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 03:06:11 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:32837 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725812AbgIKHGH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 03:06:07 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 91787CED19; Fri, 11 Sep 2020 09:13:00 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: Re-order clearing suspend tasks From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200909165317.1.Ie55bb8dde9847e8005f24402f3f2d66ea09cd7b2@changeid> Date: Fri, 11 Sep 2020 09:06:04 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Content-Transfer-Encoding: 7bit Message-Id: <E430CF8E-218C-4C64-B963-57AE70CD11CB@holtmann.org> References: <20200909165317.1.Ie55bb8dde9847e8005f24402f3f2d66ea09cd7b2@changeid> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.71 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5B24E4097C X-Rspamd-UID: 02b437 Hi Abhishek, > Unregister_pm_notifier is a blocking call so suspend tasks should be > cleared beforehand. Otherwise, the notifier will wait for completion > before returning (and we encounter a 2s timeout on resume). > > Fixes: 0e9952804ec9c8 (Bluetooth: Clear suspend tasks on unregister) > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > Should have caught that unregister_pm_notifier was blocking last time > but when testing the earlier patch, I got unlucky and saw that the error > message was never hit (the suspend timeout). > > When re-testing this patch on the same device, I was able to reproduce > the problem on an older build with the 0e9952804ec9c8 but not on a newer > build with the same patch. Changing the order correctly fixes it > everywhere. Confirmed this by adding debug logs in btusb_disconnect and > hci_suspend_notifier to confirm what order things were getting called. > > Sorry about the churn. Next I'm going try to do something about the palm > shaped indentation on my forehead... > > net/bluetooth/hci_core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OCRXOI4iW1/WkQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 09:09:02 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id CKPzM44iW1/vMwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 09:09:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8D8504097D; Fri, 11 Sep 2020 09:08:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725763AbgIKHIt (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 03:08:49 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:42702 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgIKHIt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 03:08:49 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id CBB8FCED19; Fri, 11 Sep 2020 09:15:42 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v3 2/2] Bluetooth: sco: new getsockopt options BT_SNDMTU/BT_RCVMTU From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200910140342.v3.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> Date: Fri, 11 Sep 2020 09:08:46 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, =?utf-8?Q?Pali_Roh=C3=A1r?= <pali@kernel.org>, chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <758FB16C-5210-4790-8B54-6BA400CB208D@holtmann.org> References: <20200910060403.144524-1-josephsih@chromium.org> <20200910140342.v3.2.I03247d3813c6dcbcdbeab26d068f9fd765edb1f5@changeid> To: Joseph Hwang <josephsih@chromium.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8D8504097D X-Rspamd-UID: c7693e Hi Joseph, > This patch defines new getsockopt options BT_SNDMTU/BT_RCVMTU > for SCO socket to be compatible with other bluetooth sockets. > These new options return the same value as option SCO_OPTIONS > which is already present on existing kernels. > > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > --- > > Changes in v3: > - Fixed the commit message. > > Changes in v2: > - Used BT_SNDMTU/BT_RCVMTU instead of creating a new opt name. > - Used the existing conn->mtu instead of creating a new member > in struct sco_pinfo. > - Noted that the old SCO_OPTIONS in sco_sock_getsockopt_old() > would just work as it uses sco_pi(sk)->conn->mtu. > > net/bluetooth/sco.c | 6 ++++++ > 1 file changed, 6 insertions(+) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OD3hCJi0Wl9MdgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:19:52 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id mNrrBZi0Wl8bYQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:19:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1010F4096E; Fri, 11 Sep 2020 01:19:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725769AbgIJXT2 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:19:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725280AbgIJXTY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:19:24 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA222C061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:19:22 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id s205so10363980lja.7 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/7AucZqvu579iulSUU1SYvC0/k1Tat5DA+g3riwowxU=; b=nLOI6/JIxbBHNnpC3p+Au/rVkeEC3FyE+mSBpRc9xCFiQQ3Ce0pxHTfiQALzOP70ky IgW3z1YtZVQP1V3Xh3wvZ/XNrPvZYHb4IlT4XfET6QgPIrQNtQLpydn3MrSkiVas5RtR Yhon18I/QAkcDlP1YblEvqewU8EC8IbK2dmbs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/7AucZqvu579iulSUU1SYvC0/k1Tat5DA+g3riwowxU=; b=Gp5HTzDIa4aHEe7OaIu64uolb2ci/yuF231i2N5lsFGFbLUXemIAVWLT1DbSTHp1qu zs/rjvEX5W85WGx3OYxxeG2qOjQ41fgAQyyEy0TP1wr2xJskriUsvQMdCMEf2u3yG8xp pOjG5/k4gALmIX/3uw8Rn68YxnKFPlyvZgPriWcvpcN8uOUTJwL1RfkdW9iBV6mvAyQc S+RzEH+xoXk9Ykl0IOZjAiPypWLaxxadpvuP+/E8n7oBF+jDNs7yia0kbfDyXaYpTEiO odJbFSzqIHYBS436YXJiunJYJvgSG0vA/tOQQxBhdvFAgv4iE6BY28EFPh/sPMxvX6+X yXVw== X-Gm-Message-State: AOAM530qTuee0UVJI0aaMzkzD5DLm79TdWp3dcgQpzerFurSos89NZbd fB636N8fKfpnc9GXaYf918x+jCVWPhqRHzVE38Kt8UFFdfU= X-Google-Smtp-Source: ABdhPJyARvKcs5Xuu5X8ZVllTM1EPTTaoRzH5udy8UT5ug+0U0u/5iSBRc0jzJvgGuEBB7+xk8/UUhgnzyjGKn+435o= X-Received: by 2002:a2e:b051:: with SMTP id d17mr5365075ljl.190.1599779961328; Thu, 10 Sep 2020 16:19:21 -0700 (PDT) MIME-Version: 1.0 References: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <20200818152612.BlueZ.v1.7.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> <CABBYNZLCZ9FCEH=Z3sHzsg-jw_4CvnbMxBNbQem=x0JE_+y7NA@mail.gmail.com> <CABmPvSEMoJEfpFPgnytgr+ig6TquAtg2kN+WpvAJ1oX6jUs6+Q@mail.gmail.com> <CABBYNZKTQsHP9r_WqrQTkof3DQ5kRXTHNBcXRkR8k2d==vDmxQ@mail.gmail.com> In-Reply-To: <CABBYNZKTQsHP9r_WqrQTkof3DQ5kRXTHNBcXRkR8k2d==vDmxQ@mail.gmail.com> From: Miao-chen Chou <mcchou@chromium.org> Date: Thu, 10 Sep 2020 16:19:10 -0700 Message-ID: <CABmPvSHfb1w-DwvJkHHo4y_mpxdfpswQ8n7fJ4RmOPyOFYdavw@mail.gmail.com> Subject: Re: [BlueZ PATCH v1 7/7] doc/advertisement-monitor-api: Update Advertisement Monitor API description To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.99 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1010F4096E X-Rspamd-UID: 4bf748 Hi Luiz, On Thu, Sep 10, 2020 at 10:43 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Miao, > > On Wed, Sep 9, 2020 at 9:53 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > Hi Luiz, > > > > On Tue, Sep 8, 2020 at 10:40 AM Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > > > > > > Hi Miao, > > > > > > On Tue, Aug 18, 2020 at 3:34 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > > > > > This modifies the following description to Advertisement Monitor API. > > > > - Add org.bluez.Error.Failed to RegisterMonitor() method. > > > > - Add more description about the usage of RegisterMonitor() and > > > > UnregisterMonitor() methods. > > > > - Add description about the ranges for the fields in property > > > > RSSIThresholdsAndTimers. > > > > > > > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > > > > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > > > > --- > > > > > > > > doc/advertisement-monitor-api.txt | 34 +++++++++++++++++++++++-------- > > > > 1 file changed, 25 insertions(+), 9 deletions(-) > > > > > > > > diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt > > > > index 74adbfae9..e09b6fd25 100644 > > > > --- a/doc/advertisement-monitor-api.txt > > > > +++ b/doc/advertisement-monitor-api.txt > > > > @@ -49,7 +49,7 @@ Properties string Type [read-only] > > > > org.bluez.AdvertisementMonitorManager1 for the available > > > > options. > > > > > > > > - (Int16, Uint16, Int16, Uint16) RSSIThreshholdsAndTimers [read-only, optional] > > > > + (Int16, Uint16, Int16, Uint16) RSSIThresholdsAndTimers [read-only, optional] > > > > > > > > This contains HighRSSIThreshold, HighRSSIThresholdTimer, > > > > LowRSSIThreshold, LowRSSIThresholdTimer in order. The > > > > @@ -66,7 +66,11 @@ Properties string Type [read-only] > > > > RSSIs of the received advertisement(s) during > > > > LowRSSIThresholdTimer do not reach LowRSSIThreshold. > > > > > > > > - array{(uint8, uint8, string)} Patterns [read-only, optional] > > > > + The valid range of a RSSI is -127 to +20 dBm while 127 > > > > + dBm indicates unset. The valid range of a timer is 1 to > > > > + 300 seconds while 0 indicates unset. > > > > + > > > > + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] > > > > > > > > If Type is set to 0x01, this must exist and has at least > > > > one entry in the array. > > > > @@ -80,8 +84,9 @@ Properties string Type [read-only] > > > > See https://www.bluetooth.com/specifications/ > > > > assigned-numbers/generic-access-profile/ for > > > > the possible allowed value. > > > > - string content_of_pattern > > > > - This is the value of the pattern. > > > > + array{byte} content_of_pattern > > > > + This is the value of the pattern. The maximum > > > > + length of the bytes is 31. > > > > > > > > Advertisement Monitor Manager hierarchy > > > > ======================================= > > > > @@ -91,20 +96,31 @@ Object path /org/bluez/{hci0,hci1,...} > > > > > > > > Methods void RegisterMonitor(object application) > > > > > > > > - This registers a hierarchy of advertisement monitors. > > > > + This registers the root path of a hierarchy of > > > > + advertisement monitors. > > > > The application object path together with the D-Bus > > > > system bus connection ID define the identification of > > > > the application registering advertisement monitors. > > > > + Once a root path is registered by a client via this > > > > + method, the client can freely expose/unexpose > > > > + advertisement monitors without re-registering the root > > > > + path again. After use, the client should call > > > > + UnregisterMonitor() method to invalidate the > > > > + advertisement monitors. > > > > > > > > Possible errors: org.bluez.Error.InvalidArguments > > > > org.bluez.Error.AlreadyExists > > > > + org.bluez.Error.Failed > > > > > > > > void UnregisterMonitor(object application) > > > > > > > > - This unregisters advertisement monitors that have been > > > > - previously registered. The object path parameter must > > > > - match the same value that has been used on > > > > - registration. > > > > + This unregisters a hierarchy of advertisement monitors > > > > + that has been previously registered. The object path > > > > + parameter must match the same value that has been used > > > > + on registration. Upon unregistration, the advertisement > > > > + monitor(s) should expect to receive Release() method as > > > > + the signal that the advertisement monitor(s) has been > > > > + deactivated. > > > > > > > > Possible errors: org.bluez.Error.InvalidArguments > > > > org.bluez.Error.DoesNotExist > > > > -- > > > > 2.26.2 > > > > > > These are still experimental so you will need to use EXPERIMENTAL > > > version when declaring the methods/properties so it only gets enabled > > > when the experimental flag is passed to bluetoothd. > > g_dbus_register_interface() does not allow to have all methods and > > properties marked as experimental, so at least SupportedFeatures > > should be non-experimental. > > You will need to do something like the following: > > if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) > > You can see how it was used in adv_manager: > > https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=d6e9539e31c6bb5afd39ec6f09c518d232e6345d > Thanks for the pointer. Please see v4 for the changes. > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > Thanks, > > Miao > > > > -- > Luiz Augusto von Dentz Regards, Miao Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KCd0Moy2Wl85hgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:28:12 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2B83MIy2Wl9YnQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:28:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4E751408AE; Fri, 11 Sep 2020 01:28:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725294AbgIJX2F (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:28:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725275AbgIJX2D (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:28:03 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B661C061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:28:01 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id z2so6291437qtv.12 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:28:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=pR9XyGv7DcrE5nJAweJ//E5dVpLXEl2DyKqrzYmUXr0=; b=LOfPIQw0cMvO9xTe8b1l/AXJ0ECI8guXCCK3RS/eO8tqYYkQhR9OoC63l1Po8fj2Hf 9DAx1fkirv9uKVV3pUEoowtmxv4JE82y4Rk+ZfAt2HtYJXBqnwX4iC0FRvcayelzb53a 7j5r/f4ZFdtWWvFOW7To2XQJD3wEEYlLAjSrjSHciHDtfAGX/5SG0lSWU1+cP8uzbJxY rNYuS0mz2ZaTCvmC6R7Oy+s1uUgl2gI5kaYozLKzmXU+ZMaeIT1Sr1hd/PdCOmQs5jYV SUqqUZUVOMDQdwcm62RMWXgOVilKLlbk23bEUqcwjndQpxGLUAeFA3gpcvvGOSAibz40 pfVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=pR9XyGv7DcrE5nJAweJ//E5dVpLXEl2DyKqrzYmUXr0=; b=pfJtGc0R+89WjYw2tYbao+6qy262dk0EyzLfaW8HuoVxmvG/gmtGCh/GvuygwSkeuu p6bQBLCrCjT7TSf6sVp/2z3ZdLbVzFl6X97KQn7u3g1Vt+8dWtaszear5wfx1CK0N068 StV7oUJSzhFxHjDd5HbL8BB8LwOsRQWUybn7U5xhz1mgQtsA8zjz3ZcF8LfifbBX/62a jAze/IrRHwJlbWZT8x8395Q7X6mUxzh7Q242Shqbi61KoH78nsNBN0BAd88VVLItIemW sbzzApOHfDxPjSkZVgVA+WoycCj9pm433YkmQyOolIhdb3L2JC+mzRkl7EWuVuqPbWLy /zRQ== X-Gm-Message-State: AOAM531Ps7NC5/rgrzRG66xtU4DflTDst3meuf1fY4tSSno/d5Mbo2iL 13EdrVKNAVE6l0Z0geusGRMI6xbaKhruww== X-Google-Smtp-Source: ABdhPJw2RoCk5bM4oFEug24Lue6k1WLA6QqV5I4hWhIHSdL+OENHQV8Sb1Cv3bJbBf8i6xA+kyO5Gw== X-Received: by 2002:ac8:4f4b:: with SMTP id i11mr10176247qtw.379.1599780479991; Thu, 10 Sep 2020 16:27:59 -0700 (PDT) Received: from [172.17.0.2] ([52.247.3.217]) by smtp.gmail.com with ESMTPSA id w44sm363431qth.9.2020.09.10.16.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 16:27:59 -0700 (PDT) Message-ID: <5f5ab67f.1c69fb81.a94e4.274c@mx.google.com> Date: Thu, 10 Sep 2020 16:27:59 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============8045557263980472809==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v4,2/8] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200910161528.BlueZ.v4.2.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200910161528.BlueZ.v4.2.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.46 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4E751408AE X-Rspamd-UID: 43f63e --===============8045557263980472809== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #94: FILE: src/adv_monitor.c:1: +/* WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #247: FILE: src/adv_monitor.h:1: +/* - total: 0 errors, 2 warnings, 235 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============8045557263980472809==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AKHzFRi3Wl9UmQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:30:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id ENmUExi3Wl9mBQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:30:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B1B7B40962; Fri, 11 Sep 2020 01:30:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725298AbgIJXa0 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725290AbgIJXaW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:30:22 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C14FC061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:30:21 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id t20so6315306qtr.8 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:30:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=U+i5XPme3vC7jaZs/WDFR2wUocv1CUJ4TPmfGK9KY2E=; b=XTLezDG/JZuCpgWsq5zvIVBiUVAN+YgmfMpYvdqExrhfDExrl/ND0kesHJkVxpHR/G SBJj915893Yh7j6kReroHLI4KO2jtWFM/P2pTDOxL94Kuyyr+v2VlUfy++KvvoTYRPg3 eNqqIIu/+wPUhFMkFw/8R+elNrDfHRiqnkBOCwPmcGgxRrFoMprekZfN5QwoH7zRlA3/ 3MMV8ar4QprAC92yn2geZliooXq2+i7LypXdgLCVvml5SmgtebwoGYbcO3GurvEhhIsd UBuiYxGNPkQgGu8wFuz8wLY2k9Kp/c9z7vAg9KSjsoPs4NV0ZyvxQQ/PbVbT5HZC0eVP 3zow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=U+i5XPme3vC7jaZs/WDFR2wUocv1CUJ4TPmfGK9KY2E=; b=eXKluQX56xXDb1TkJGwWkHScPzCpvgFIPUdwGedjZ8mvqLO+cXeoghqGzHVKtLavdV MUBWLlQQcnRZeJiI6bH/X+gxCxikoHJG2IuhDf+AbZGBu+4FjJSdMW3jOFN2CAJis4A/ 3/byJugOBUTPmtu482rdKl8TmIc0FGoGWl+umoW6k5VEHTwItnDAsm8sM9zqiMl4UQa9 VrL/4LzJRDtAWIXEP9BbYuaFtVRZK3soOuQ5i2fGMYunce4S7lwDfO7rjKKJBZzQO17A e7k27ja9DZwGsxqVzTWxnRATz6KqjMQ5bNn1BFmwF9pmV01HSaNkbXxw5OsKDKAIbwD3 gn8g== X-Gm-Message-State: AOAM532kURIIKkyA304oFrb6Iy6b8IuuUxoXxuIk4KthWlkh5th9jlVp 0stQRwO4iQsQT5R5vgbw24UE08vOQAODqA== X-Google-Smtp-Source: ABdhPJwq/xcsNxZhY02tkciQgjjpauc/6JPIq+IZnKj+p97jQdi05YpW1t7EKnWSPDWPPLuC9HRHGQ== X-Received: by 2002:ac8:743:: with SMTP id k3mr10778540qth.182.1599780620689; Thu, 10 Sep 2020 16:30:20 -0700 (PDT) Received: from [172.17.0.2] ([52.247.3.217]) by smtp.gmail.com with ESMTPSA id x6sm646155qke.54.2020.09.10.16.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 16:30:20 -0700 (PDT) Message-ID: <5f5ab70c.1c69fb81.12f26.3d94@mx.google.com> Date: Thu, 10 Sep 2020 16:30:20 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============6985360745229033016==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v4,1/8] adapter: Remove indirect dependency of headers Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 4.01 / 15.00 / 15.00 X-Rspamd-Queue-Id: B1B7B40962 X-Rspamd-UID: a23269 --===============6985360745229033016== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnNyYy9hZHZfbW9uaXRvci5jOiBJbiBmdW5jdGlvbiDigJhtb25pdG9y X21hdGNo4oCZOgpzcmMvYWR2X21vbml0b3IuYzoyNzY6MzU6IGVycm9yOiBwYXNzaW5nIGFyZ3Vt ZW50IDEgb2Yg4oCYZ19kYnVzX3Byb3h5X2dldF9wYXRo4oCZIGRpc2NhcmRzIOKAmGNvbnN04oCZ IHF1YWxpZmllciBmcm9tIHBvaW50ZXIgdGFyZ2V0IHR5cGUgWy1XZXJyb3I9ZGlzY2FyZGVkLXF1 YWxpZmllcnNdCiAgMjc2IHwgIGlmIChzdHJjbXAoZ19kYnVzX3Byb3h5X2dldF9wYXRoKHByb3h5 KSwgbW9uaXRvci0+cGF0aCkgIT0gMCkKICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgXn5+fn4KSW4gZmlsZSBpbmNsdWRlZCBmcm9tIHNyYy9hZHZfbW9uaXRvci5jOjMx OgouL2dkYnVzL2dkYnVzLmg6MzM2OjEzOiBub3RlOiBleHBlY3RlZCDigJhHREJ1c1Byb3h5ICri gJkge2FrYSDigJhzdHJ1Y3QgR0RCdXNQcm94eSAq4oCZfSBidXQgYXJndW1lbnQgaXMgb2YgdHlw ZSDigJhjb25zdCBHREJ1c1Byb3h5ICrigJkge2FrYSDigJhjb25zdCBzdHJ1Y3QgR0RCdXNQcm94 eSAq4oCZfQogIDMzNiB8IGNvbnN0IGNoYXIgKmdfZGJ1c19wcm94eV9nZXRfcGF0aChHREJ1c1By b3h5ICpwcm94eSk7CiAgICAgIHwgICAgICAgICAgICAgXn5+fn5+fn5+fn5+fn5+fn5+fn5+CnNy Yy9hZHZfbW9uaXRvci5jOiBJbiBmdW5jdGlvbiDigJhwYXJzZV9wYXR0ZXJuc+KAmToKc3JjL2Fk dl9tb25pdG9yLmM6NDg1OjM2OiBlcnJvcjogc3VnZ2VzdCBwYXJlbnRoZXNlcyBhcm91bmQg4oCY JibigJkgd2l0aGluIOKAmHx84oCZIFstV2Vycm9yPXBhcmVudGhlc2VzXQogIDQ4NSB8ICAgaWYg KGFkX3R5cGUgPiBCVF9BRF8zRF9JTkZPX0RBVEEgJiYKc3JjL2Fkdl9tb25pdG9yLmM6NDI1OjEx OiBlcnJvcjogdW51c2VkIHZhcmlhYmxlIOKAmG51bV9wYXR0ZXJuc+KAmSBbLVdlcnJvcj11bnVz ZWQtdmFyaWFibGVdCiAgNDI1IHwgIHVpbnQxNl90IG51bV9wYXR0ZXJucyA9IDA7CiAgICAgIHwg ICAgICAgICAgIF5+fn5+fn5+fn5+fgpzcmMvYWR2X21vbml0b3IuYzogSW4gZnVuY3Rpb24g4oCY Z2V0X3N1cHBvcnRlZF9tb25pdG9yX3R5cGVz4oCZOgpzcmMvYWR2X21vbml0b3IuYzo3NTM6MzQ6 IGVycm9yOiB1bnVzZWQgdmFyaWFibGUg4oCYbWFuYWdlcuKAmSBbLVdlcnJvcj11bnVzZWQtdmFy aWFibGVdCiAgNzUzIHwgIHN0cnVjdCBidGRfYWR2X21vbml0b3JfbWFuYWdlciAqbWFuYWdlciA9 IGRhdGE7CiAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXn5+fn5+fgpj YzE6IGFsbCB3YXJuaW5ncyBiZWluZyB0cmVhdGVkIGFzIGVycm9ycwptYWtlWzFdOiAqKiogW01h a2VmaWxlOjkyNzI6IHNyYy9ibHVldG9vdGhkLWFkdl9tb25pdG9yLm9dIEVycm9yIDEKbWFrZTog KioqIFtNYWtlZmlsZTo0MDE0OiBhbGxdIEVycm9yIDIKCgoKLS0tClJlZ2FyZHMsCkxpbnV4IEJs dWV0b290aAo= --===============6985360745229033016==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qJ44MHy5Wl9CrAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:40:44 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yN0OLXy5Wl+P4QAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:40:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5DF1140015; Fri, 11 Sep 2020 01:40:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725777AbgIJXkb (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:40:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725648AbgIJXk1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:40:27 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2C27C061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:40:26 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id z17so4505579lfi.12 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:40:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LL+0tAnbh6vsc5NLzOGUZJ2LiSX5vj0sdF2jqns5ZEk=; b=Hjq7AZLuC2zzMKTEDWd4ZqgkY1LwfdOHUdbuh8Xf6iZsAwfGFujyQAyB2BM4Y2UO+m 9wMmuURMrN1oD/ubD4LqETRskgJjN1RHGJydHYgAIYlEyZmJFOoNClTlHs2Qw0nhso8D n3wzp5jcvHCPp982o4qxQyN4loXyJIwJIFmj0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LL+0tAnbh6vsc5NLzOGUZJ2LiSX5vj0sdF2jqns5ZEk=; b=jY30Xw/CjSowTpKRDOQjPQoUocRiePKm6gspJoyvPtuldOmjVojf/0q0vH510q0L6v 7UjJuw9jEsILkPoxPCdOw+Ru93QnhjS/utCGL+ss6Zp4Se/RABeh9Pr22cJFG1Z/qyhO E9mYRSG7uABxA+ONB903Smmfa0xGYZyKdH7wahymCfBnTOwDHnIROvIbG6G0AJsUSekP 7rPGoWqBgZ9zh83GVxuvD6FdC3g08hlibmdTzRBj0c74N8N1badtizYsaQbn0aEamQWV DF89Lr7qxGv/kEhprwlxCItWM0HrxVk2ha3eCT8Ab670efhmn8EyqT3fKOS1gxQAdlh7 AO/w== X-Gm-Message-State: AOAM531OzGEQphvvQTLz/T6OlPZRhNY99Q3SdxCYPgbE7ulc/nIA9cxo NevCVvXefA4hAHHbxS9FzfySVThQh1Z18FbeQl9NCWUu2R0= X-Google-Smtp-Source: ABdhPJw74mjAXvOR2iBexESgyIU/D6q96PAzM1bifGw0/kisRDVFArMn+CtASOjpHVdofm8I2sALZbu1FSxdJXGa26M= X-Received: by 2002:a19:915b:: with SMTP id y27mr5396514lfj.134.1599781225251; Thu, 10 Sep 2020 16:40:25 -0700 (PDT) MIME-Version: 1.0 References: <20200910161528.BlueZ.v4.2.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <5f5ab67f.1c69fb81.a94e4.274c@mx.google.com> In-Reply-To: <5f5ab67f.1c69fb81.a94e4.274c@mx.google.com> From: Miao-chen Chou <mcchou@chromium.org> Date: Thu, 10 Sep 2020 16:40:14 -0700 Message-ID: <CABmPvSF1FhoFoz_1yk+eAo-h+xUo2cT4ZHfjN0y37xFLt7wK=A@mail.gmail.com> Subject: Re: [BlueZ,v4,2/8] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5DF1140015 X-Rspamd-UID: 2ca84b Hi Luiz, The style check was modified recently,so we are not sure about this particular license warning. Can you provide some guidance here? Thanks, Miao On Thu, Sep 10, 2020 at 4:28 PM <bluez.test.bot@gmail.com> wrote: > > > This is automated email and please do not reply to this email! > > Dear submitter, > > Thank you for submitting the patches to the linux bluetooth mailing list. > While we are preparing for reviewing the patches, we found the following > issue/warning. > > Test Result: > checkpatch Failed > > Outputs: > WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 > #94: FILE: src/adv_monitor.c:1: > +/* > > WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 > #247: FILE: src/adv_monitor.h:1: > +/* > > - total: 0 errors, 2 warnings, 235 lines checked > > NOTE: For some of the reported defects, checkpatch may be able to > mechanically convert to the typical style using --fix or --fix-inplace. > > Your patch has style problems, please review. > > NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO > > NOTE: If any of the errors are false positives, please report > them to the maintainer, see CHECKPATCH in MAINTAINERS. > > > > --- > Regards, > Linux Bluetooth Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ePELK/e8Wl8A0AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 01:55:35 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SKAXKPe8Wl/GTAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 01:55:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D833640675; Fri, 11 Sep 2020 01:55:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725283AbgIJXz1 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 19:55:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725275AbgIJXz1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 19:55:27 -0400 Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE0E6C061573 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:55:26 -0700 (PDT) Received: by mail-oo1-xc29.google.com with SMTP id g26so1870510ooa.9 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 16:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3vcjE6W6V++z0bkq1Mpk4DTV5iecE6QoABm3PzOwgSU=; b=pxT5rD0MHT/Z21mcAwb3BSAhf+RWTgeKQhJiN7DbGZFNXWqB02veq7Fr7We+gqeoZP yG6Eaj5aHNgyGHD4tLRp8cIUYWgZmF3TESXFWDr9V9YdWpBh+g4Ojdu6cDhhQAPWfWq/ 8qYaNXM97ATZYzGfOrfHP2F8TGaartqwT3RZ7fxS+DDBS3NnUoZFbag06XLF8RZgxCpA eAYuTXWn3fvCvwruZeDKtw1rSjD718T8ZON+wUyHqURO5fEjkBRUJMeBzASfnUlH/PT4 HAIcMFabfrE6JOAEvOShrkJiFES5N7cj2CrLeY/fUQJ0FlkWhobsnMAUUNjbsydis36Q JnqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3vcjE6W6V++z0bkq1Mpk4DTV5iecE6QoABm3PzOwgSU=; b=nX2aOfrtXHFLqi2zMxAP8TJdixIZHSg6tE68+sMJoJ1rfp6GILdIBAXY3T0ps9gFuK EhNt1Tm6uLQI/oTz62plnJm68bQCccXkkejZwsZCPrwjaY716SepUGFy8U3o+UaJDEQz jeD6IUt26FL2f0vTdiEWA0qf/xtz1s0Bk2DtBiUxQCIPsasOAmYin4Y5LdHLVvfFdScp QZyXxz0KbyhpA0sLlrEqqgJO1OmY+Unam/FiLJUyUKGbp8GmjPYAiEZVXi9FZP99fVKD eghee2ex80+ExrBlru8dTB1h9iBir9Ga7kTUxdsvbQShkHRHaqoH56l+Cczu6Yq0RqOm K8hA== X-Gm-Message-State: AOAM532qk273NacPGMD5sxE3jYlxsQfZmnLlkGCqZxKl2IkTDWNqhqF5 3uqG96f9KnByW/Afjyox4vuDpF+ChWxPVJV57JE= X-Google-Smtp-Source: ABdhPJwHj0CO+cUg9W+TSFQS52+9qwAZ1CT9gnaCVDGJINLC5L7bp0LjXRBaQJOTK0ELFDc5m8bWue1BaYEh6Do1/KE= X-Received: by 2002:a4a:8dd5:: with SMTP id a21mr6308111ool.17.1599782124216; Thu, 10 Sep 2020 16:55:24 -0700 (PDT) MIME-Version: 1.0 References: <20200910161528.BlueZ.v4.2.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> <5f5ab67f.1c69fb81.a94e4.274c@mx.google.com> <CABmPvSF1FhoFoz_1yk+eAo-h+xUo2cT4ZHfjN0y37xFLt7wK=A@mail.gmail.com> In-Reply-To: <CABmPvSF1FhoFoz_1yk+eAo-h+xUo2cT4ZHfjN0y37xFLt7wK=A@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 10 Sep 2020 16:55:12 -0700 Message-ID: <CABBYNZJu0X=49XKvJYQH9LT5M9-KBbxXCi+4Anh=50bN12cZVQ@mail.gmail.com> Subject: Re: [BlueZ,v4,2/8] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.17 / 15.00 / 15.00 X-Rspamd-Queue-Id: D833640675 X-Rspamd-UID: e02304 Hi Miao, On Thu, Sep 10, 2020 at 4:44 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > Hi Luiz, > > The style check was modified recently,so we are not sure about this > particular license warning. Can you provide some guidance here? Don't worry about that, I will be working to support the SDPX license identifier but that is something we can ignore for now. > Thanks, > Miao > > On Thu, Sep 10, 2020 at 4:28 PM <bluez.test.bot@gmail.com> wrote: > > > > > > This is automated email and please do not reply to this email! > > > > Dear submitter, > > > > Thank you for submitting the patches to the linux bluetooth mailing list. > > While we are preparing for reviewing the patches, we found the following > > issue/warning. > > > > Test Result: > > checkpatch Failed > > > > Outputs: > > WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 > > #94: FILE: src/adv_monitor.c:1: > > +/* > > > > WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 > > #247: FILE: src/adv_monitor.h:1: > > +/* > > > > - total: 0 errors, 2 warnings, 235 lines checked > > > > NOTE: For some of the reported defects, checkpatch may be able to > > mechanically convert to the typical style using --fix or --fix-inplace. > > > > Your patch has style problems, please review. > > > > NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO > > > > NOTE: If any of the errors are false positives, please report > > them to the maintainer, see CHECKPATCH in MAINTAINERS. > > > > > > > > --- > > Regards, > > Linux Bluetooth -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4De0AaXnWl9gdQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 04:57:41 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id yLLcOaTnWl80MwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 04:57:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6D3484081B; Fri, 11 Sep 2020 04:57:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725300AbgIKC5d (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 10 Sep 2020 22:57:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbgIKC53 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 10 Sep 2020 22:57:29 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D931C061756 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 19:57:27 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id o5so9875695wrn.13 for <linux-bluetooth@vger.kernel.org>; Thu, 10 Sep 2020 19:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NV4ByKEQVi2N8GtAg0l18wtkd1/SUu1feziU5QiC7tw=; b=I9oWkBTRMAwO+G7Sm3zSbQVj8KOsuBdm8i7siYrmWqrGplYlVsYS1NVrOIdt5Wx38a he3xW79HtZiVYvj3I/jQkZjZMnrtRjwMG8hKF3AoYOazZpIhsRBsmIE5PYa433u7WG/E cjPad7bO8XIdUWpDeZGFtuZiXZQxL2O7H2/8eHZqvo/74J9yPaFLpRBn+SwQl7uLT94d 01XQVWKhSnT2dQjWW2ZEjRM3gD9Q7kT0XGBP7f38FSPqY2NES2sKXJktH1GgXqOtUV2S kQq97J2uMKCGMGhcowsfkmKjuZT2G6jOn0OWAqyDCM2U+K3bjGJqRGAvdG/e+ncL46JD ZhmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NV4ByKEQVi2N8GtAg0l18wtkd1/SUu1feziU5QiC7tw=; b=UWsnaDQEZdjBfZWRAkGevj6utIPFBkVpUywscgpU2c/3U8QFCwL7JwNSud3hCuBdOi ptiscpn73gP/cKz/OfeLt0cDtQ8rfgWy+VC2PvgU1/RBl+vAk5ME+eeJX6GbI6w0Vbe7 Z9NTOB70KrCbyiFrqn3E4QiFNXL3RE14N+lLo5zurWRHDsEUXFiT2CVlZ1tSXrtEcLLv bU8nCnss60bEtjFq+dUnMGmhbM8od8kZg/XgnB+H7/dHbqjeuCrt/TsdpZ+86NXKMIr3 KCUMXvXOFU56vfb0WhSv7fL6OVmq8i3auE78w/Ik8qphAOYm5FalgFybIXvKjjthYs5s FOjg== X-Gm-Message-State: AOAM531c9iIv53Z/ykbyAxOE0JLSAlsZ8mxlNp95qt2aA/Dzch9zEuok OeXwIic2Q2pLRa+4UWapuSia0sjJa3NiPbVnz0s82Egh9N6ytw== X-Google-Smtp-Source: ABdhPJwv5JLpgBUdapgQr5lqqYC/NgaxhHxyEyJXLrnfc1JM4trqdB1LnrH0b5/pAuSU4Fv1zffCPbw0SrOx0Oy3Sx8= X-Received: by 2002:adf:fa0c:: with SMTP id m12mr11610778wrr.406.1599793046194; Thu, 10 Sep 2020 19:57:26 -0700 (PDT) MIME-Version: 1.0 References: <20200901113736.Bluez.v2.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> <CAJQfnxEopr6GzSsjbq4wQaWaw9QZDu_hmZMJF9_bS7i4nU5owQ@mail.gmail.com> <CAJQfnxFyLR_rbZPt_ag68SSp7M1LkZ=0L2dZ-XP5ZZ-fwTEMrw@mail.gmail.com> In-Reply-To: <CAJQfnxFyLR_rbZPt_ag68SSp7M1LkZ=0L2dZ-XP5ZZ-fwTEMrw@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Fri, 11 Sep 2020 10:57:14 +0800 Message-ID: <CAJQfnxG7oiLviJ0pgG1Fh314rYzey1TOj5MUeVayKRTLnH73KA@mail.gmail.com> Subject: Re: [Bluez PATCH v2] device: don't wait for timeout if RemoveDevice is called To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.42 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6D3484081B X-Rspamd-UID: c2dc8b Hi Bluez maintainers, May I bother you to review this patch? Thanks, Archie On Fri, 11 Sep 2020 at 10:56, Archie Pusaka <apusaka@google.com> wrote: > > Hi Bluez maintainers, > > May I bother you to review this patch? > > Thanks, > Archie > > On Mon, 7 Sep 2020 at 10:38, Archie Pusaka <apusaka@google.com> wrote: >> >> Hi Bluez maintainers, >> >> Could you take another look at this patch? >> >> Thanks, >> Archie >> >> On Tue, 1 Sep 2020 at 11:37, Archie Pusaka <apusaka@google.com> wrote: >> > >> > From: Archie Pusaka <apusaka@chromium.org> >> > >> > RemoveDevice on adapter interface used to remove a device, even when >> > the device is connected. However, since the introduction of the new >> > 30 seconds timeout when setting a device as temporary, RemoveDevice >> > doesn't immediately remove a connected device, but only disconnects >> > it and waits for the timer to expire before effectively removes it. >> > >> > This patch removes the device as soon as it gets disconnected, >> > provided the disconnection is triggered by a call to RemoveDevice. >> > The regular timeout still applies for other cases. >> > >> > Tested manually by calling RemoveDevice on a connected device, >> > and with ChromeOS autotest setup. >> > >> > Reviewed-by: Daniel Winkler <danielwinkler@google.com> >> > >> > Signed-off-by: Archie Pusaka <apusaka@chromium.org> >> > --- >> > >> > Changes in v2: >> > * Rebasing to HEAD >> > >> > src/adapter.c | 2 -- >> > src/adapter.h | 2 ++ >> > src/device.c | 11 +++++++++++ >> > 3 files changed, 13 insertions(+), 2 deletions(-) >> > >> > diff --git a/src/adapter.c b/src/adapter.c >> > index 1435e2bd7..ffd05aa0b 100644 >> > --- a/src/adapter.c >> > +++ b/src/adapter.c >> > @@ -79,8 +79,6 @@ >> > #include "advertising.h" >> > #include "eir.h" >> > >> > -#define ADAPTER_INTERFACE "org.bluez.Adapter1" >> > - >> > #define MODE_OFF 0x00 >> > #define MODE_CONNECTABLE 0x01 >> > #define MODE_DISCOVERABLE 0x02 >> > diff --git a/src/adapter.h b/src/adapter.h >> > index f8ac20261..f835c984f 100644 >> > --- a/src/adapter.h >> > +++ b/src/adapter.h >> > @@ -26,6 +26,8 @@ >> > #include <dbus/dbus.h> >> > #include <glib.h> >> > >> > +#define ADAPTER_INTERFACE "org.bluez.Adapter1" >> > + >> > #define MAX_NAME_LENGTH 248 >> > >> > /* Invalid SSP passkey value used to indicate negative replies */ >> > diff --git a/src/device.c b/src/device.c >> > index df440ce09..f20270017 100644 >> > --- a/src/device.c >> > +++ b/src/device.c >> > @@ -3007,6 +3007,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) >> > { >> > struct bearer_state *state = get_state(device, bdaddr_type); >> > DBusMessage *reply; >> > + bool remove_device = false; >> > >> > if (!state->connected) >> > return; >> > @@ -3036,6 +3037,10 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) >> > while (device->disconnects) { >> > DBusMessage *msg = device->disconnects->data; >> > >> > + if (dbus_message_is_method_call(msg, ADAPTER_INTERFACE, >> > + "RemoveDevice")) >> > + remove_device = true; >> > + >> > g_dbus_send_reply(dbus_conn, msg, DBUS_TYPE_INVALID); >> > device->disconnects = g_slist_remove(device->disconnects, msg); >> > dbus_message_unref(msg); >> > @@ -3061,6 +3066,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) >> > >> > g_dbus_emit_property_changed(dbus_conn, device->path, >> > DEVICE_INTERFACE, "Connected"); >> > + >> > + if (remove_device) >> > + btd_adapter_remove_device(device->adapter, device); >> > } >> > >> > guint device_add_disconnect_watch(struct btd_device *device, >> > @@ -4477,6 +4485,9 @@ void device_remove(struct btd_device *device, gboolean remove_stored) >> > disconnect_all(device); >> > } >> > >> > + if (device->temporary_timer > 0) >> > + g_source_remove(device->temporary_timer); >> > + >> > if (device->store_id > 0) { >> > g_source_remove(device->store_id); >> > device->store_id = 0; >> > -- >> > 2.28.0.402.g5ffc5be6b7-goog >> > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oFD3F2weW1/EQgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 08:51:24 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id eKK3FGweW1/xaAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 08:51:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F1F37A0170; Fri, 11 Sep 2020 08:51:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725800AbgIKGvR (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 02:51:17 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:44643 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725785AbgIKGvQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 02:51:16 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id B471FCED1B; Fri, 11 Sep 2020 08:58:10 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: hci_qca: remove redundant null check From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200903082719.85027-1-vulab@iscas.ac.cn> Date: Fri, 11 Sep 2020 08:51:15 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <95E38C5D-0F97-4BDA-AC14-F4DBBD1F214A@holtmann.org> References: <20200903082719.85027-1-vulab@iscas.ac.cn> To: Xu Wang <vulab@iscas.ac.cn> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.64 / 15.00 / 15.00 X-Rspamd-Queue-Id: F1F37A0170 X-Rspamd-UID: 55eaed Hi Xu, > Because clk_disable_unprepare already checked > NULL clock parameter, so the additional check is > unnecessary, just remove it. > > Signed-off-by: Xu Wang <vulab@iscas.ac.cn> > --- > drivers/bluetooth/hci_qca.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ELvJC3keW19bYQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 08:51:37 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EDudCHkeW1+0AwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 08:51:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3555BA010E; Fri, 11 Sep 2020 08:51:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725795AbgIKGvR (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 02:51:17 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:46408 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbgIKGvN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 02:51:13 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 00165CED1A; Fri, 11 Sep 2020 08:58:07 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v1 2/4] Bluetooth: hci_intel: drop strange le16_to_cpu() against u8 values From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200903184850.53055-2-andriy.shevchenko@linux.intel.com> Date: Fri, 11 Sep 2020 08:51:12 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <CD9DE84B-CA69-4420-8D6D-6C51ADEBB84E@holtmann.org> References: <20200903184850.53055-1-andriy.shevchenko@linux.intel.com> <20200903184850.53055-2-andriy.shevchenko@linux.intel.com> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.59 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3555BA010E X-Rspamd-UID: 4f4d3b Hi Andy, > Sparse rightfully complains: > > hci_intel.c:696:26: warning: cast to restricted __le16 > hci_intel.c:701:26: warning: cast to restricted __le16 > hci_intel.c:702:26: warning: cast to restricted __le16 > hci_intel.c:703:26: warning: cast to restricted __le16 > hci_intel.c:725:26: warning: cast to restricted __le16 > hci_intel.c:730:26: warning: cast to restricted __le16 > hci_intel.c:731:26: warning: cast to restricted __le16 > hci_intel.c:732:26: warning: cast to restricted __le16 > > because we access non-restricted types with le16_to_cpu(). > More confusion is added by using above against u8. On big-endian > architecture we will get all zeroes. I bet it's not what should be > in such case. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > drivers/bluetooth/hci_intel.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aMPCJfoiW18qiwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 09:10:50 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eMqGIvoiW18t6QAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 09:10:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5992440965; Fri, 11 Sep 2020 09:10:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725764AbgIKHKn (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 03:10:43 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:36124 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgIKHKl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 03:10:41 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 8C07CCED19; Fri, 11 Sep 2020 09:17:35 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [RESEND v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <1599733843-20311-1-git-send-email-gubbaven@codeaurora.org> Date: Fri, 11 Sep 2020 09:10:39 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, Matthias Kaehlcke <mka@chromium.org>, open list <linux-kernel@vger.kernel.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, Hemantg <hemantg@codeaurora.org>, MSM <linux-arm-msm@vger.kernel.org>, Balakrishna Godavarthi <bgodavar@codeaurora.org>, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org Content-Transfer-Encoding: 7bit Message-Id: <C4C12227-FA4E-47F9-A161-6ADE490AAA91@holtmann.org> References: <1599733843-20311-1-git-send-email-gubbaven@codeaurora.org> To: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.18 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5992440965 X-Rspamd-UID: 00077e Hi Venkata, > When HCI_QUIRK_NON_PERSISTENT_SETUP is set by drivers, > it indicates that BT SoC will be completely powered OFF > during BT OFF. On next BT ON firmware must be downloaded > again. Holding UART port open during BT OFF is draining > the battery. Now during BT OFF, UART port is closed if > qurik HCI_QUIRK_NON_PERSISTENT_SETUP is set by clearing > HCI_UART_PROTO_READY proto flag. On next BT ON, UART > port is opened if HCI_UART_PROTO_READY proto flag is cleared. > > Venkata Lakshmi Narayana Gubba (2): > Bluetooth: hci_serdev: Close UART port if NON_PERSISTENT_SETUP is set > Bluetooth: hci_qca: Remove duplicate power off in proto close > > drivers/bluetooth/hci_qca.c | 5 ++--- > drivers/bluetooth/hci_serdev.c | 36 +++++++++++++++++++++++++++++++++--- > 2 files changed, 35 insertions(+), 6 deletions(-) both patches have been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qNUcBkEjW1/WkQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 09:12:01 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iAyBA0EjW1/MtwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 09:12:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C5FDB4096A; Fri, 11 Sep 2020 09:11:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725784AbgIKHLr convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 03:11:47 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:35719 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgIKHLr (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 03:11:47 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 5DF1FCED1A; Fri, 11 Sep 2020 09:18:41 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [RESEND v1] arm64: dts: qcom: sc7180: Remove clock for bluetooth on SC7180 IDP board From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <1599734980-22580-1-git-send-email-gubbaven@codeaurora.org> Date: Fri, 11 Sep 2020 09:11:45 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org Content-Transfer-Encoding: 8BIT Message-Id: <C8D04890-4F62-4EEB-9113-BAFFF46E32BD@holtmann.org> References: <1599734980-22580-1-git-send-email-gubbaven@codeaurora.org> To: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.09 / 15.00 / 15.00 X-Rspamd-Queue-Id: C5FDB4096A X-Rspamd-UID: a6cf96 Hi, > Removed voting for RPMH_RF_CLK2 which is not required as it is > getting managed by BT SoC through SW_CTRL line. > > Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> > --- > arch/arm64/boot/dts/qcom/sc7180-idp.dts | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/arch/arm64/boot/dts/qcom/sc7180-idp.dts b/arch/arm64/boot/dts/qcom/sc7180-idp.dts > index 4e9149d..b295d01 100644 > --- a/arch/arm64/boot/dts/qcom/sc7180-idp.dts > +++ b/arch/arm64/boot/dts/qcom/sc7180-idp.dts > @@ -348,7 +348,6 @@ > vddrf-supply = <&vreg_l2c_1p3>; > vddch0-supply = <&vreg_l10c_3p3>; > max-speed = <3200000>; > - clocks = <&rpmhcc RPMH_RF_CLK2>; > }; > }; is anybody picking up this patch or should I take it through the bluetooth-next tree? Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UDSvDeMkW18qiwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 09:18:59 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6BW7CuMkW1+/ugEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 09:18:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2B3D5A0B21; Fri, 11 Sep 2020 09:18:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725822AbgIKHSn (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 03:18:43 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:54149 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725536AbgIKHSl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 03:18:41 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id C6F92CED19; Fri, 11 Sep 2020 09:25:34 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH 0/2] Bluetooth: Report extended adv capabilities to userspace From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200825233151.1580920-1-danielwinkler@google.com> Date: Fri, 11 Sep 2020 09:18:38 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, open list <linux-kernel@vger.kernel.org>, netdev@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <EDA4EEF8-F025-4C14-BD01-D4391F083B35@holtmann.org> References: <20200825233151.1580920-1-danielwinkler@google.com> To: Daniel Winkler <danielwinkler@google.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.46 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2B3D5A0B21 X-Rspamd-UID: 36432c Hi Daniel, > This series improves the kernel/controller support that is reported > to userspace for the following extended advertising features: > > 1. If extended advertising is available, the number of hardware slots > is used and reported, rather than the fixed default of 5. If no hardware > support is available, default is used as before for software rotation. > > 2. New flags indicating general hardware offloading and ability to > set tx power level. These are kept as two separate flags because in > the future vendor commands may allow tx power to be set without > hardware offloading support. > > > Daniel Winkler (2): > bluetooth: Report num supported adv instances for hw offloading > bluetooth: Add MGMT capability flags for tx power and ext advertising > > include/net/bluetooth/mgmt.h | 2 ++ > net/bluetooth/hci_core.c | 2 +- > net/bluetooth/mgmt.c | 8 +++++--- > 3 files changed, 8 insertions(+), 4 deletions(-) both patches have been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4AcrLk8lW1+vkwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 09:20:47 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id EE3CK08lW18+kQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 09:20:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 18BBDA0B59; Fri, 11 Sep 2020 09:20:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725800AbgIKHUk convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 03:20:40 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:35767 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbgIKHUc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 03:20:32 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 45DA4CED19; Fri, 11 Sep 2020 09:27:26 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH 0/3] Bluetooth: Emit events for suspend/resume From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200729014225.1842177-1-abhishekpandit@chromium.org> Date: Fri, 11 Sep 2020 09:20:30 +0200 Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>, chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Content-Transfer-Encoding: 8BIT Message-Id: <5A859E7E-5BD4-4DBD-A44A-AD6E4950DB81@holtmann.org> References: <20200729014225.1842177-1-abhishekpandit@chromium.org> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.69 / 15.00 / 15.00 X-Rspamd-Queue-Id: 18BBDA0B59 X-Rspamd-UID: 870c16 Hi Abhishek, > This series adds the suspend/resume events suggested in > https://patchwork.kernel.org/patch/11663455/. > > I have tested it with some userspace changes that monitors the > controller resumed event to trigger audio device reconnection and > verified that the events are correctly emitted. > > Please take a look. > Abhishek > > > Abhishek Pandit-Subedi (3): > Bluetooth: Add mgmt suspend and resume events > Bluetooth: Add suspend reason for device disconnect > Bluetooth: Emit controller suspend and resume events > > include/net/bluetooth/hci_core.h | 6 +++ > include/net/bluetooth/mgmt.h | 16 +++++++ > net/bluetooth/hci_core.c | 26 +++++++++++- > net/bluetooth/hci_event.c | 73 ++++++++++++++++++++++++++++++++ > net/bluetooth/mgmt.c | 28 ++++++++++++ > 5 files changed, 148 insertions(+), 1 deletion(-) can you please re-send this series. Unfortunately it seems I only have the cover letter, but lost the patches. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MNaZCmVJW18RpAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 11:54:45 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UHieB2VJW1+YjAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 11:54:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 070C4A0B20; Fri, 11 Sep 2020 11:54:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725842AbgIKJvH (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 05:51:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725850AbgIKJuw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 05:50:52 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C3C2C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 02:50:52 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id w12so9304478qki.6 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 02:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7+YB150D6uTSzeam8wDwxc4/nXEIj6cULZv/r5XpRdg=; b=WJ99KnLQLMiA2C/j9bGNXyqQNzXh7o4k9154iQIKFC7RIR2wM4K5+xUkP2JyEfeGdq VqIVhWvoA5/xrGSnREoG0EpBxpVZWhoUD9dXjgU4cmGR7d260VTsbiRhbVhWDSIWTYFO BRlBhRkGvQFSBaWAd3oSnay0tqHKJTSJp51xAFY0KXI+ts4XfIe1BrTiCBf7r0AD4x5J aV14C0MCgI9VD6WN0UtXJuBA3mftfDr40Bere8sORH+PL1Pgrqx9Yr8Fs26jaHpzB0fY VnGughG5oxsb8IXRil08p5FceB+8UFZHKmIueA8UEcL12r9DpAkN13pJnFVWrggiTAeU 5VrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7+YB150D6uTSzeam8wDwxc4/nXEIj6cULZv/r5XpRdg=; b=r+2Wy/tcWWQy1NV2CkzIjLw5Y6FqX+OULdpoxQi1Frde6s4AnrfMsDe1G/chERWXod Emc0rTgmTKvpK5/MxKeO5GYcVDDqmCYMiTlTLskx+aZxmlM2lCDickLJOQvUxUvwge+J oMGHkn01FSgIEocewqw3twaMMaocw8ZYEavFzQuEnzljQlTm5tzg+hVALSHPRQ0+0l/m Pw7T0g897n/COpzyZai7eKMppMxg8dcjJzxavw9krf1WfgkJCIkBshZlqSP062KJ84gX ZuI1tWEmNF3se1aPRT/M6aHSSbfXGI3RHmL3hONI1T/FjnlLUoswaVqj8wb53KicXbh8 xKFw== X-Gm-Message-State: AOAM532vWS1Hqn1NlOYGj+j/AV71G+oB/VdjMjf3QDmnuZ65s3XGrHf8 CT/QZUlHahMdghkRgevqkYhmWHv/lXmlUi5aanvTeQ== X-Google-Smtp-Source: ABdhPJzTGVt1bygn8LBeAGsK317G+dy3Zg6KVBNayxKhUV57gMSqjWNhJaeGkalL0nTqBrRgM7yi2x8Vi4mAZmPYr7w= X-Received: by 2002:a37:9b82:: with SMTP id d124mr777282qke.8.1599817851439; Fri, 11 Sep 2020 02:50:51 -0700 (PDT) MIME-Version: 1.0 References: <000000000000e8fb4b05ac58372e@google.com> In-Reply-To: <000000000000e8fb4b05ac58372e@google.com> From: Dmitry Vyukov <dvyukov@google.com> Date: Fri, 11 Sep 2020 11:50:39 +0200 Message-ID: <CACT4Y+Z2Sz8kHxaQNuupfck7X0rUtr4ghDty9ahDTUm2H41Mwg@mail.gmail.com> Subject: Re: KASAN: use-after-free Read in hci_get_auth_info To: syzbot <syzbot+13010b6a10bbd82cc79c@syzkaller.appspotmail.com> Cc: David Miller <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, Jakub Kicinski <kuba@kernel.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, netdev <netdev@vger.kernel.org>, syzkaller-bugs <syzkaller-bugs@googlegroups.com>, Anant Thazhemadam <anant.thazhemadam@gmail.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.52 / 15.00 / 15.00 X-Rspamd-Queue-Id: 070C4A0B20 X-Rspamd-UID: 7a1a27 On Sat, Aug 8, 2020 at 8:56 AM syzbot <syzbot+13010b6a10bbd82cc79c@syzkaller.appspotmail.com> wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit: d6efb3ac Merge tag 'tty-5.9-rc1' of git://git.kernel.org/p.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=14ad2134900000 > kernel config: https://syzkaller.appspot.com/x/.config?x=61ec43e42a83feae > dashboard link: https://syzkaller.appspot.com/bug?extid=13010b6a10bbd82cc79c > compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12fd9bc6900000 > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+13010b6a10bbd82cc79c@syzkaller.appspotmail.com +Anant who had some questions re this issue. > ================================================================== > BUG: KASAN: use-after-free in __mutex_waiter_is_first kernel/locking/mutex.c:200 [inline] > BUG: KASAN: use-after-free in __mutex_lock_common+0x12cd/0x2fc0 kernel/locking/mutex.c:1040 > Read of size 8 at addr ffff88808e668060 by task syz-executor.4/19584 > > CPU: 0 PID: 19584 Comm: syz-executor.4 Not tainted 5.8.0-syzkaller #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 > Call Trace: > __dump_stack lib/dump_stack.c:77 [inline] > dump_stack+0x1f0/0x31e lib/dump_stack.c:118 > print_address_description+0x66/0x5a0 mm/kasan/report.c:383 > __kasan_report mm/kasan/report.c:513 [inline] > kasan_report+0x132/0x1d0 mm/kasan/report.c:530 > __mutex_waiter_is_first kernel/locking/mutex.c:200 [inline] > __mutex_lock_common+0x12cd/0x2fc0 kernel/locking/mutex.c:1040 > __mutex_lock kernel/locking/mutex.c:1103 [inline] > mutex_lock_nested+0x1a/0x20 kernel/locking/mutex.c:1118 > hci_get_auth_info+0x69/0x3a0 net/bluetooth/hci_conn.c:1689 > hci_sock_bound_ioctl net/bluetooth/hci_sock.c:957 [inline] > hci_sock_ioctl+0x5ae/0x750 net/bluetooth/hci_sock.c:1060 > sock_do_ioctl+0x7b/0x260 net/socket.c:1047 > sock_ioctl+0x4aa/0x690 net/socket.c:1198 > vfs_ioctl fs/ioctl.c:48 [inline] > ksys_ioctl fs/ioctl.c:753 [inline] > __do_sys_ioctl fs/ioctl.c:762 [inline] > __se_sys_ioctl+0xf9/0x160 fs/ioctl.c:760 > do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > RIP: 0033:0x45ccd9 > Code: 2d b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb b5 fb ff c3 66 2e 0f 1f 84 00 00 00 00 > RSP: 002b:00007f113a564c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 > RAX: ffffffffffffffda RBX: 000000000001d300 RCX: 000000000045ccd9 > RDX: 0000000020000000 RSI: 00000000800448d7 RDI: 0000000000000005 > RBP: 000000000078bf40 R08: 0000000000000000 R09: 0000000000000000 > R10: 0000000000000000 R11: 0000000000000246 R12: 000000000078bf0c > R13: 00007ffd62ea93af R14: 00007f113a5659c0 R15: 000000000078bf0c > > Allocated by task 6822: > save_stack mm/kasan/common.c:48 [inline] > set_track mm/kasan/common.c:56 [inline] > __kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494 > kmem_cache_alloc_trace+0x234/0x300 mm/slab.c:3551 > kmalloc include/linux/slab.h:555 [inline] > kzalloc include/linux/slab.h:669 [inline] > hci_alloc_dev+0x4c/0x1aa0 net/bluetooth/hci_core.c:3543 > __vhci_create_device drivers/bluetooth/hci_vhci.c:99 [inline] > vhci_create_device+0x113/0x520 drivers/bluetooth/hci_vhci.c:148 > process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 > worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 > kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 > > Freed by task 9965: > save_stack mm/kasan/common.c:48 [inline] > set_track mm/kasan/common.c:56 [inline] > kasan_set_free_info mm/kasan/common.c:316 [inline] > __kasan_slab_free+0x114/0x170 mm/kasan/common.c:455 > __cache_free mm/slab.c:3426 [inline] > kfree+0x10a/0x220 mm/slab.c:3757 > bt_host_release+0x18/0x20 net/bluetooth/hci_sysfs.c:86 > device_release+0x70/0x1a0 drivers/base/core.c:1796 > kobject_cleanup lib/kobject.c:704 [inline] > kobject_release lib/kobject.c:735 [inline] > kref_put include/linux/kref.h:65 [inline] > kobject_put+0x1a0/0x2c0 lib/kobject.c:752 > vhci_release+0x7b/0xc0 drivers/bluetooth/hci_vhci.c:341 > __fput+0x2f0/0x750 fs/file_table.c:281 > task_work_run+0x137/0x1c0 kernel/task_work.c:135 > exit_task_work include/linux/task_work.h:25 [inline] > do_exit+0x5f3/0x1f20 kernel/exit.c:806 > do_group_exit+0x161/0x2d0 kernel/exit.c:903 > __do_sys_exit_group+0x13/0x20 kernel/exit.c:914 > __ia32_sys_exit_group+0x0/0x40 kernel/exit.c:912 > __x64_sys_exit_group+0x37/0x40 kernel/exit.c:912 > do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > The buggy address belongs to the object at ffff88808e668000 > which belongs to the cache kmalloc-8k of size 8192 > The buggy address is located 96 bytes inside of > 8192-byte region [ffff88808e668000, ffff88808e66a000) > The buggy address belongs to the page: > page:ffffea0002399a00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea0002399a00 order:2 compound_mapcount:0 compound_pincount:0 > flags: 0xfffe0000010200(slab|head) > raw: 00fffe0000010200 ffffea000217a208 ffffea0001e6c008 ffff8880aa4021c0 > raw: 0000000000000000 ffff88808e668000 0000000100000001 0000000000000000 > page dumped because: kasan: bad access detected > > Memory state around the buggy address: > ffff88808e667f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc > ffff88808e667f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc > >ffff88808e668000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > ^ > ffff88808e668080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > ffff88808e668100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > ================================================================== > > > --- > This report is generated by a bot. It may contain errors. > See https://goo.gl/tpsmEJ for more information about syzbot. > syzbot engineers can be reached at syzkaller@googlegroups.com. > > syzbot will keep track of this issue. See: > https://goo.gl/tpsmEJ#status for how to communicate with syzbot. > syzbot can test patches for this issue, for details see: > https://goo.gl/tpsmEJ#testing-patches > > -- > You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group. > To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/000000000000e8fb4b05ac58372e%40google.com. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ECLkKrRjW1+htgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 13:47:00 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id OIduJ7RjW1/xXgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 13:47:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 44C7D40941; Fri, 11 Sep 2020 13:46:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725822AbgIKLpx (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 07:45:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725803AbgIKLol (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 07:44:41 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD48DC0613ED for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 04:44:40 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id l126so7130554pfd.5 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 04:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Q18azJC5D1cvYz5vDthfR7Zqd2AvwFwi9A+uqGSXyDA=; b=YHy1N9xUfGGLEnVGBdWUISlD/1FxSLOt3E6Q11tLVanuwc1jGIarlk8QgNV5DrXGMI ft9xm4bUkMDf+jMdUSU02c6ekDjYhTRcyktezNLLJ/A1iLl7wMMc/uvhX7Q0/a+Kx3RO vWLWtshEJbDl3DnBGeck5qsWqCHKSXsFKP15s06tG4Iv3gwzz6bxAprXeDQb3+SmSLw/ BSjliDcJyoiUPQZIZ5L9iK0jpriewPfnFcNpuREVvCchna9umGgPOLBqGfZ6p6SVR9nE wCF9zf7Dhnc0GQqEjOWmkGB/AWJU/NXWQ+wh7oswWwQJbxXuF5Sg6ZfHBarHsR9UbJnT PSFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Q18azJC5D1cvYz5vDthfR7Zqd2AvwFwi9A+uqGSXyDA=; b=K+LF7mfmi/j3zD2fzf/DmeaBRIGjN3yYhfzwXVxZiZ/t0iiQXlSvPg+PHt72ICh0ll Wi+gSJRKXsLOruGB7Ufw07ioOUw44L3xOb0tB/S2fyqP4QJKWt9l9Erirt6QCKHtPM7x es+jQXU/cxrYZRBp15oGH3P+zm5gPMW1XYvkNjRmBNJhpODDiq1qkFQ3jg3RvBVbU0C+ zC40m0GcbKpfOYpit5WRukfr3AfJUY+nzGeZKcEntpSMPMjQgzNInlyAXzTbU+/fVyg/ 6BqEYJjsW7YZ1yeKVrHmORPhCiCRbeaZXW7sbQjIaOhoNklh2CJq62FmZ+JzL9p/19v/ naBQ== X-Gm-Message-State: AOAM530ftGOtCA1GrhySGjBvwvdeLkDP0axrdUaF+hj8AkJx4I2Fc8GC InYZLgvpZFxiTc1JzZZrVKh8fAN2/8wvXA== X-Google-Smtp-Source: ABdhPJxW6ZMhsCylqNveuw7p1QBeKZSsWPjz5InZC1C4uHadKORW/2z0Ssp9PtEVud3rtiCzHYId7g== X-Received: by 2002:a17:902:8342:: with SMTP id z2mr1689277pln.3.1599824679776; Fri, 11 Sep 2020 04:44:39 -0700 (PDT) Received: from localhost.localdomain ([122.171.170.126]) by smtp.gmail.com with ESMTPSA id k2sm2135675pfi.169.2020.09.11.04.44.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 04:44:38 -0700 (PDT) From: Kiran K <kiraank@gmail.com> X-Google-Original-From: Kiran K <kiran.k@intel.com> To: linux-bluetooth@vger.kernel.org Cc: kiraank@gmail.com, Kiran K <kiran.k@intel.com> Subject: [PATCH v1] Bluetooth: btintel: Refactor firmware download function Date: Fri, 11 Sep 2020 17:14:17 +0530 Message-Id: <1599824657-19464-1-git-send-email-kiran.k@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.84 / 15.00 / 15.00 X-Rspamd-Queue-Id: 44C7D40941 X-Rspamd-UID: b2674c Split firmware download code into two functions - one to download header and other to download payload. This patch enhances readability and reusabiltiy of code Signed-off-by: Kiran K <kiran.k@intel.com> Reviewed-by: Chethan T N <chethan.tumkur.narayan@intel.com> Reviewed-by: Sathish Narasimman <Sathish.Narasimman@intel.com> Reviewed-by: Srivatsa Ravishankar <ravishankar.srivatsa@intel.com> --- drivers/bluetooth/btintel.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index 5fa5be3..4ad0800 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -19,6 +19,7 @@ #define VERSION "0.1" #define BDADDR_INTEL (&(bdaddr_t) {{0x00, 0x8b, 0x9e, 0x19, 0x03, 0x00}}) +#define RSA_HEADER_LEN 644 int btintel_check_bdaddr(struct hci_dev *hdev) { @@ -626,12 +627,10 @@ int btintel_read_boot_params(struct hci_dev *hdev, } EXPORT_SYMBOL_GPL(btintel_read_boot_params); -int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, - u32 *boot_param) +static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev, + const struct firmware *fw) { int err; - const u8 *fw_ptr; - u32 frag_len; /* Start the firmware download transaction with the Init fragment * represented by the 128 bytes of CSS header. @@ -660,8 +659,21 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, goto done; } - fw_ptr = fw->data + 644; +done: + return err; +} + +static int btintel_download_firmware_payload(struct hci_dev *hdev, + const struct firmware *fw, + u32 *boot_param, size_t offset) +{ + int err; + const u8 *fw_ptr; + u32 frag_len; + + fw_ptr = fw->data + offset; frag_len = 0; + err = -EINVAL; while (fw_ptr - fw->data < fw->size) { struct hci_command_hdr *cmd = (void *)(fw_ptr + frag_len); @@ -707,6 +719,19 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw, done: return err; } + +int btintel_download_firmware(struct hci_dev *hdev, + const struct firmware *fw, + u32 *boot_param) +{ + int err; + + err = btintel_sfi_rsa_header_secure_send(hdev, fw); + if (err) + return err; + + return btintel_download_firmware_payload(hdev, fw, boot_param, RSA_HEADER_LEN); +} EXPORT_SYMBOL_GPL(btintel_download_firmware); void btintel_reset_to_bootloader(struct hci_dev *hdev) -- 2.7.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GDxODV5pW1+q8AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 14:11:10 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AGIHCl5pW1/PXgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 14:11:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 53982A0B3E; Fri, 11 Sep 2020 14:11:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725790AbgIKMK6 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 08:10:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725787AbgIKMKT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 08:10:19 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98610C0613ED for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:09:46 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id o14so3870823qve.7 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=qIId3xI6bPeFIzMnGT1Pmld70e1Pp7+xu29Zf+ONNsE=; b=oIo5XJv8pbo6JEiRClunbNoPo0YnjMnNG207G3Xf0vsX8AABDlxOiRUlewAdmG9zHI Osyq0KnAiyJ4qlD7HEeiz3PcD+VgJych6Ds7us3Or1233nKoBn34AKtJbz1xgYXEiz2d 3CrTT7ELsOX9g/Sus6DcRci1nQ9kRpcFA5hNBCUOGf5P+w4cPzgUOs+8UO6kwyqv7uLN +S26++P8LSwnALBnqL1cbvSMTy3CXCZr22gjFDOXASvC+/Sp1ISt4AK4HkIKVI2lnUkT L8WX3PIlsuyAD6093qM/cBmmDMKVjK1iQPbPymbLVUwmu6EXowvxGFqtBwgimQZsgHpL CJVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qIId3xI6bPeFIzMnGT1Pmld70e1Pp7+xu29Zf+ONNsE=; b=YCWo+iyLp9pKHsE6kz8ltrSKzI8HM4RgZJWhrFVav2Ih7k7jOINuYv2yFYk7A8FkbG 6ttn4NOLOIwJdV45OKXrJHqJKAfyIjCDaZP52AonXsMSc59Dsg0CCiaiC9rNg0eZOVur a6Lo7a0zHIR7cDGss/dn7sNv4ddIsvGitH9U8gFenRGFDZZByvLAlFj+E2K41pamwXfF qfVKXK6EfvlwHujM3p9m1W+qweouCNf5WTBSYbJ0mj5MZzwQgTWx0ZfQzu2hxj9HGhn4 bOM2jVqq4k9UHvAjFwa3gxdLIEAGokv2HeoXc1FQSUTdWrlfrMprEKvRNiM6H7U8BBI2 EFmA== X-Gm-Message-State: AOAM530JjkUbCE1v0/l4RWY52MWsBboHB2iE9qnKfNLki/a52LLkPU42 Y9/tVLr6+jakYMfSaBHTdOprVVxEPC2jSal5yi0SyY36mxhh4kaaEQRt5iG2NsLxa4mklwabV4M T4cmdzqGHbmzCVPd3TJjuv4UHh9kjQit9we5mQQFTp2YsGJj+PXa1SZz9WMumz/tilE0/TsvVZ+ 2VW/6WDbZ6L0M= X-Google-Smtp-Source: ABdhPJzmKUMKxEWNeUHzuwkis0sb+EWR/ibfD/Kd70xVhwuSDYkbElUUGqDiq6ZgMr2Zk3d2aoC97iuTHelPmZfgEA== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a0c:f44e:: with SMTP id h14mr1587919qvm.4.1599826185384; Fri, 11 Sep 2020 05:09:45 -0700 (PDT) Date: Fri, 11 Sep 2020 20:09:28 +0800 In-Reply-To: <20200911200839.BlueZ.v3.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200911200839.BlueZ.v3.3.I680cda25cec9c45ca2b2c5ac3a8e437772ea76d9@changeid> Mime-Version: 1.0 References: <20200911200839.BlueZ.v3.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v3 3/4] PRE-UPSTREAM: client: Expose ADV monitor objects From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mmandlik@chromium.org, mcchou@chromium.org, luiz.von.dentz@intel.com, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.22 / 15.00 / 15.00 X-Rspamd-Queue-Id: 53982A0B3E X-Rspamd-UID: ea6616 This adds logic to expose user-defined advertisement monitor to dbus and also implements methods for exposed objects. Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) client/adv_monitor.c | 185 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 182 insertions(+), 3 deletions(-) diff --git a/client/adv_monitor.c b/client/adv_monitor.c index 49c0dd01d..bb833ffea 100644 --- a/client/adv_monitor.c +++ b/client/adv_monitor.c @@ -53,6 +53,7 @@ struct pattern { struct adv_monitor { uint8_t idx; + char *path; char *type; struct rssi_setting *rssi; GSList *patterns; @@ -68,6 +69,163 @@ static struct adv_monitor_manager { static uint8_t adv_mon_idx; static GSList *adv_mons; +static void remove_adv_monitor(void *data, void *user_data); + +static DBusMessage *release_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + bt_shell_printf("Advertisement monitor %d released\n", + adv_monitor->idx); + remove_adv_monitor(adv_monitor, conn); + + return dbus_message_new_method_return(msg); +} + +static DBusMessage *activate_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + bt_shell_printf("Advertisement monitor %d activated\n", + adv_monitor->idx); + return dbus_message_new_method_return(msg); +} + +static DBusMessage *device_found_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + const char *device; + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device, + DBUS_TYPE_INVALID); + bt_shell_printf("Advertisement monitor %d found device %s\n", + adv_monitor->idx, device); + return dbus_message_new_method_return(msg); +} + +static DBusMessage *device_lost_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + const char *device; + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device, + DBUS_TYPE_INVALID); + bt_shell_printf("Advertisement monitor %d lost device %s\n", + adv_monitor->idx, device); + return dbus_message_new_method_return(msg); +} + +static const GDBusMethodTable adv_monitor_methods[] = { + { GDBUS_ASYNC_METHOD("Release", NULL, NULL, release_adv_monitor) }, + { GDBUS_ASYNC_METHOD("Activate", NULL, NULL, activate_adv_monitor) }, + { GDBUS_ASYNC_METHOD("DeviceFound", GDBUS_ARGS({ "device", "o" }), + NULL, device_found_adv_monitor) }, + { GDBUS_ASYNC_METHOD("DeviceLost", GDBUS_ARGS({ "device", "o" }), + NULL, device_lost_adv_monitor) }, + { } +}; + + +static gboolean get_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, + &adv_monitor->type); + return TRUE; +} + +static gboolean get_rssi(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + struct rssi_setting *rssi = adv_monitor->rssi; + DBusMessageIter data_iter; + + dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, + NULL, &data_iter); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_INT16, + &rssi->high_threshold); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_UINT16, + &rssi->high_timer); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_INT16, + &rssi->low_threshold); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_UINT16, + &rssi->low_timer); + dbus_message_iter_close_container(iter, &data_iter); + return TRUE; +} + +static gboolean rssi_exists(const GDBusPropertyTable *property, void *data) +{ + struct adv_monitor *adv_monitor = data; + + return adv_monitor->rssi != NULL; +} + +static void append_pattern_content_to_dbus(DBusMessageIter *iter, + struct pattern *pattern) +{ + DBusMessageIter data_iter; + int idx; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE_AS_STRING, &data_iter); + for (idx = 0; idx < pattern->content_len; idx++) + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->content[idx]); + dbus_message_iter_close_container(iter, &data_iter); +} + +static void append_pattern_to_dbus(void *data, void *user_data) +{ + struct pattern *pattern = data; + DBusMessageIter *array_iter = user_data; + DBusMessageIter data_iter; + + dbus_message_iter_open_container(array_iter, DBUS_TYPE_STRUCT, + NULL, &data_iter); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->start_pos); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->ad_data_type); + append_pattern_content_to_dbus(&data_iter, pattern); + dbus_message_iter_close_container(array_iter, &data_iter); +} + +static gboolean get_patterns(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + DBusMessageIter array_iter; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "(yyay)", + &array_iter); + g_slist_foreach(adv_monitor->patterns, append_pattern_to_dbus, + &array_iter); + dbus_message_iter_close_container(iter, &array_iter); + return TRUE; +} + +static gboolean pattern_exists(const GDBusPropertyTable *property, void *data) +{ + struct adv_monitor *adv_monitor = data; + + return adv_monitor->patterns != NULL; +} + +static const GDBusPropertyTable adv_monitor_props[] = { + { "Type", "s", get_type }, + { "RSSIThresholdsAndTimers", "(nqnq)", get_rssi, NULL, rssi_exists }, + { "Patterns", "a(yyay)", get_patterns, NULL, pattern_exists }, + { } +}; + static void set_supported_list(GSList **list, DBusMessageIter *iter) { char *str; @@ -201,6 +359,7 @@ static void free_adv_monitor(void *user_data) { struct adv_monitor *adv_monitor = user_data; + g_free(adv_monitor->path); g_free(adv_monitor->type); g_free(adv_monitor->rssi); g_slist_free_full(adv_monitor->patterns, free_pattern); @@ -325,6 +484,16 @@ static GSList *parse_patterns(char *pattern_list[], int num) return patterns; } +static void remove_adv_monitor(void *data, void *user_data) +{ + struct adv_monitor *adv_monitor = data; + DBusConnection *conn = user_data; + + adv_mons = g_slist_remove(adv_mons, adv_monitor); + g_dbus_unregister_interface(conn, adv_monitor->path, + ADV_MONITOR_INTERFACE); +} + static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) { const struct adv_monitor *adv_monitor = a; @@ -360,6 +529,7 @@ static void print_adv_monitor(struct adv_monitor *adv_monitor) GSList *l; bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); + bt_shell_printf("\tpath: %s\n", adv_monitor->path); bt_shell_printf("\ttype: %s\n", adv_monitor->type); if (adv_monitor->rssi) { bt_shell_printf("\trssi:\n"); @@ -434,6 +604,16 @@ void adv_monitor_add_monitor(DBusConnection *conn, char *type, adv_monitor->type = g_strdup(type); adv_monitor->rssi = rssi; adv_monitor->patterns = patterns; + adv_monitor->path = g_strdup_printf("%s/%hhu", ADV_MONITOR_APP_PATH, + adv_mon_idx); + if (g_dbus_register_interface(conn, adv_monitor->path, + ADV_MONITOR_INTERFACE, + adv_monitor_methods, NULL, + adv_monitor_props, adv_monitor, + free_adv_monitor) == FALSE) { + bt_shell_printf("Failed to register advertisement monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } adv_mons = g_slist_append(adv_mons, adv_monitor); bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); @@ -468,7 +648,7 @@ void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) struct adv_monitor *adv_monitor; if (monitor_idx < 0) { - g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); + g_slist_foreach(adv_mons, remove_adv_monitor, conn); return; } @@ -479,8 +659,7 @@ void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) return; } - adv_mons = g_slist_remove(adv_mons, adv_monitor); - free_adv_monitor(adv_monitor); + remove_adv_monitor(adv_monitor, conn); bt_shell_printf("Monitor %d deleted\n", monitor_idx); } -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +O5PHoZpW1+JEQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 14:11:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id +GmMG4ZpW19mxAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 14:11:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E09CAA0B50; Fri, 11 Sep 2020 14:11:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725852AbgIKMLB (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 08:11:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbgIKMJs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 08:09:48 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B660DC061757 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:09:41 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id q2so6837555pfc.17 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=p9sD2Axl5zUzpyNH9eTboePnANbrOFugW8nMQboWduY=; b=ZzriICdJz7t+dbDamYVtO1nX1qnu8DofWF7De5ZT+yV+AMG9iU05oWppiFHOnWhDMY KnNbQ3x/H9Xum0LLysUR5S1x2gdTL0oHyJFmkSauHVtmhIhR0seV1Oz/ANLLkq+bdQLt cyKusH4fxvDrfpWdziFh+7gTMROqIG6pNt50Ad3OsAOVqDBwxXA9T9R6kUP1fNhfvZsP CA5uJ99vp7yy08YXgtIB9300XSDpqHWtBucLadYRl3YyGE1bvsq7mOr4QDkrf9vaXDE1 l8xuzVxT2uIp2lZcCLXnNhBt5wAxwB4k7CXYwKRkwtJr7cOA+p7l+qHSyZif5+1CZFJT rYYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=p9sD2Axl5zUzpyNH9eTboePnANbrOFugW8nMQboWduY=; b=qnz4cuLLP+d290IN1IAhpePN7G+GyfsCbpOrdPWOjlNg4oRzzZ0QGsI/H3FxKxrHKD kXOjZPocrEufmdSKzYjtzmDItn+NXQs46xH4LbVrJI55YirRSw2vr9Dswh44+F8e4Nq2 BKhWtINHiv220d6mppa8qSuQ/c8e5HacrwDpFTtgEPrqHc0AfX6M1MHHh5x2jMalOVQx rMB/lf5SHTBaQ8cZ9Eal5yy347cdNuJvze7w1q2SVDSQT1i6oL0XgQ9wlqiESR0Oflw5 1btK/+xQRtiUVXoKtWFpXNTsDZLhc+3I6kJXlsIYgYwba/E39S2tkv9m5EIlOG6mDc4w 2Lng== X-Gm-Message-State: AOAM530PRxf5WM7s1QuPU6A7h4tTzHk/tJm1FwBRCqWZHwBQiRItY/55 D5pwwCmqM1ECBNzXDTSZey724AYgiV0d3dFyvmQds+svX6gDCl/QqJNuWNR+dAp0nTEQKiPkHKM cpsiWItvc5BYTIZGcRIGtd5Ci1eA/y/e3pLe7Mwqcy9LWPDhgFLs8E8V/wiDX10ZYtdHLPAitzt i9JFd5y9uSJwM= X-Google-Smtp-Source: ABdhPJzyvBWEVkbAvRwLYboy8Lt8B0JHMTBkIvNgJxjZw5e6xNylVEWbLQWnJmvTrIUZbnY3G43Vu6iCOOOVJ5yYpw== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:90b:15c6:: with SMTP id lh6mr24753pjb.0.1599826180765; Fri, 11 Sep 2020 05:09:40 -0700 (PDT) Date: Fri, 11 Sep 2020 20:09:27 +0800 In-Reply-To: <20200911200839.BlueZ.v3.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200911200839.BlueZ.v3.2.Iec6b15e23f4228b80f9b364eb76515d146d592d5@changeid> Mime-Version: 1.0 References: <20200911200839.BlueZ.v3.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v3 2/4] PRE-UPSTREAM: client: Implement more interfaces of ADV monitor in bluetoothctl From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mmandlik@chromium.org, mcchou@chromium.org, luiz.von.dentz@intel.com, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: E09CAA0B50 X-Rspamd-UID: 1f91d6 This patch creates a submenu in bluetoothctl and implements several commands. new commands: [bluetooth]# menu monitor [bluetooth]# add-or-pattern 1 2 ab0011 Advertisement Monitor 0 added [bluetooth]# add-or-pattern-rssi -80, ,5 1 2 aa 3 4 ff Advertisement Monitor 1 added [bluetooth]# get-pattern all Advertisement Monitor 0 path: /org/bluez/adv_monitor_app/0 type: or_patterns pattern 1: start position: 1 AD data type: 2 content: ab0011 Advertisement Monitor 1 path: /org/bluez/adv_monitor_app/1 type: or_patterns rssi: high threshold: -50 high threshold timer: 5 low threshold: -80 low threshold timer: 5 pattern 1: start position: 1 AD data type: 2 content: aa pattern 2: start position: 3 AD data type: 4 content: ff [bluetooth]# get-supported-info Supported Features: Supported Moniter Types: or_patterns [bluetooth]# remove-pattern 0 Monitor 0 deleted Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v2) Changes in v2: - Update the add-pattern usage client/adv_monitor.c | 352 ++++++++++++++++++++++++++++++++++++++++++- client/adv_monitor.h | 10 ++ client/main.c | 109 ++++++++++++++ 3 files changed, 468 insertions(+), 3 deletions(-) diff --git a/client/adv_monitor.c b/client/adv_monitor.c index 2a62389d9..49c0dd01d 100644 --- a/client/adv_monitor.c +++ b/client/adv_monitor.c @@ -29,6 +29,7 @@ #include <string.h> #include "gdbus/gdbus.h" +#include "src/shared/ad.h" #include "src/shared/util.h" #include "src/shared/shell.h" #include "adv_monitor.h" @@ -36,6 +37,27 @@ #define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" +struct rssi_setting { + int16_t high_threshold; + uint16_t high_timer; + int16_t low_threshold; + uint16_t low_timer; +}; + +struct pattern { + uint8_t start_pos; + uint8_t ad_data_type; + uint8_t content_len; + uint8_t content[BT_AD_MAX_DATA_LEN]; +}; + +struct adv_monitor { + uint8_t idx; + char *type; + struct rssi_setting *rssi; + GSList *patterns; +}; + static struct adv_monitor_manager { GSList *supported_types; GSList *supported_features; @@ -43,6 +65,9 @@ static struct adv_monitor_manager { gboolean app_registered; } manager = { NULL, NULL, NULL, FALSE }; +static uint8_t adv_mon_idx; +static GSList *adv_mons; + static void set_supported_list(GSList **list, DBusMessageIter *iter) { char *str; @@ -138,7 +163,10 @@ static void unregister_reply(DBusMessage *message, void *user_data) void adv_monitor_register_app(DBusConnection *conn) { - if (manager.supported_types == NULL || manager.app_registered == TRUE || + if (manager.app_registered == TRUE) { + bt_shell_printf("Advertisement Monitor already registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } else if (manager.supported_types == NULL || g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", register_setup, register_reply, NULL, NULL) == FALSE) { @@ -150,8 +178,10 @@ void adv_monitor_register_app(DBusConnection *conn) void adv_monitor_unregister_app(DBusConnection *conn) { - if (manager.app_registered == FALSE || - g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", + if (manager.app_registered == FALSE) { + bt_shell_printf("Advertisement Monitor not registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } else if (g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", unregister_setup, unregister_reply, NULL, NULL) == FALSE) { bt_shell_printf("Failed to unregister Advertisement Monitor\n"); @@ -159,3 +189,319 @@ void adv_monitor_unregister_app(DBusConnection *conn) } manager.app_registered = FALSE; } + +static void free_pattern(void *user_data) +{ + struct pattern *p = user_data; + + g_free(p); +} + +static void free_adv_monitor(void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + g_free(adv_monitor->type); + g_free(adv_monitor->rssi); + g_slist_free_full(adv_monitor->patterns, free_pattern); + g_free(adv_monitor); +} + +static uint8_t str2bytearray(char *str, uint8_t *arr) +{ + int idx, len = strlen(str), arr_len = 0; + + if (len%2 != 0) + return 0; + + for (idx = 0; idx < len; idx += 2) { + if (sscanf(str+idx, "%2hhx", &arr[arr_len++]) < 1) + return 0; + } + return arr_len; +} + +static void parse_rssi_value_pair(char *value_pair, int *low, int *high) +{ + char *val1, *val2; + bool flag = value_pair[0] == ','; + + val1 = strtok(value_pair, ","); + + if (!val1) + return; + + val2 = strtok(NULL, ","); + + if (!val2) { + if (!flag) + *low = atoi(val1); + else + *high = atoi(val1); + } else { + *low = atoi(val1); + *high = atoi(val2); + } +} + +static struct rssi_setting *parse_rssi(char *range, char *timeout) +{ + struct rssi_setting *rssi; + int high_threshold, low_threshold, high_timer, low_timer; + + high_threshold = RSSI_DEFAULT_HIGH_THRESHOLD; + low_threshold = RSSI_DEFAULT_LOW_THRESHOLD; + high_timer = RSSI_DEFAULT_HIGH_TIMEOUT; + low_timer = RSSI_DEFAULT_LOW_TIMEOUT; + + parse_rssi_value_pair(range, &low_threshold, &high_threshold); + parse_rssi_value_pair(timeout, &low_timer, &high_timer); + + rssi = g_malloc0(sizeof(struct rssi_setting)); + + if (!rssi) { + bt_shell_printf("Failed to allocate rssi_setting"); + bt_shell_noninteractive_quit(EXIT_FAILURE); + return NULL; + } + + rssi->high_threshold = high_threshold; + rssi->high_timer = high_timer; + rssi->low_threshold = low_threshold; + rssi->low_timer = low_timer; + + return rssi; +} + +static struct pattern *parse_pattern(char *parameter_list[]) +{ + struct pattern *pat; + + pat = g_malloc0(sizeof(struct pattern)); + + if (!pat) { + bt_shell_printf("Failed to allocate pattern"); + bt_shell_noninteractive_quit(EXIT_FAILURE); + return NULL; + } + + pat->start_pos = atoi(parameter_list[0]); + pat->ad_data_type = atoi(parameter_list[1]); + pat->content_len = str2bytearray(parameter_list[2], pat->content); + if (pat->content_len == 0) { + free_pattern(pat); + return NULL; + } + + return pat; +} + +static GSList *parse_patterns(char *pattern_list[], int num) +{ + GSList *patterns = NULL; + int cnt; + + if (num == 0) { + bt_shell_printf("No pattern provided\n"); + return NULL; + } + + if (num%3) { + bt_shell_printf("Expected %d more arguments\n", 3 - num%3); + return NULL; + } + + for (cnt = 0; cnt < num; cnt += 3) { + struct pattern *pattern; + + pattern = parse_pattern(pattern_list+cnt); + if (pattern == NULL) { + g_slist_free_full(patterns, free_pattern); + return NULL; + } + patterns = g_slist_append(patterns, pattern); + } + + return patterns; +} + +static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) +{ + const struct adv_monitor *adv_monitor = a; + uint8_t idx = *(uint8_t *)b; + + return adv_monitor->idx != idx; +} + +static struct adv_monitor *find_adv_monitor_with_idx(uint8_t monitor_idx) +{ + GSList *list; + + list = g_slist_find_custom(adv_mons, &monitor_idx, + cmp_adv_monitor_with_idx); + + if (list) + return (struct adv_monitor *)list->data; + return NULL; +} + +static void print_bytearray(char *prefix, uint8_t *arr, uint8_t len) +{ + int idx; + + bt_shell_printf("%s", prefix); + for (idx = 0; idx < len; idx++) + bt_shell_printf("%02hhx", arr[idx]); + bt_shell_printf("\n"); +} + +static void print_adv_monitor(struct adv_monitor *adv_monitor) +{ + GSList *l; + + bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); + bt_shell_printf("\ttype: %s\n", adv_monitor->type); + if (adv_monitor->rssi) { + bt_shell_printf("\trssi:\n"); + bt_shell_printf("\t\thigh threshold: %hd\n", + adv_monitor->rssi->high_threshold); + bt_shell_printf("\t\thigh threshold timer: %hu\n", + adv_monitor->rssi->high_timer); + bt_shell_printf("\t\tlow threshold: %hd\n", + adv_monitor->rssi->low_threshold); + bt_shell_printf("\t\tlow threshold timer: %hu\n", + adv_monitor->rssi->low_timer); + } + + if (adv_monitor->patterns) { + int idx = 1; + + for (l = adv_monitor->patterns; l; l = g_slist_next(l), idx++) { + struct pattern *pattern = l->data; + + bt_shell_printf("\tpattern %d:\n", idx); + bt_shell_printf("\t\tstart position: %hhu\n", + pattern->start_pos); + bt_shell_printf("\t\tAD data type: %hhu\n", + pattern->ad_data_type); + print_bytearray("\t\tcontent: ", pattern->content, + pattern->content_len); + } + } +} + +void adv_monitor_add_monitor(DBusConnection *conn, char *type, + gboolean rssi_enabled, int argc, char *argv[]) +{ + struct adv_monitor *adv_monitor; + struct rssi_setting *rssi; + GSList *patterns = NULL; + + if (g_slist_length(adv_mons) >= UINT8_MAX) { + bt_shell_printf("Number of advertisement monitor exceeds " + "the limit"); + return; + } + + while (find_adv_monitor_with_idx(adv_mon_idx)) + adv_mon_idx += 1; + + if (rssi_enabled == FALSE) + rssi = NULL; + else { + rssi = parse_rssi(argv[1], argv[2]); + if (rssi == NULL) + return; + + argv += 2; + argc -= 2; + } + + patterns = parse_patterns(argv+1, argc-1); + if (patterns == NULL) { + bt_shell_printf("pattern-list malformed\n"); + return; + } + + adv_monitor = g_malloc0(sizeof(struct adv_monitor)); + + if (!adv_monitor) { + bt_shell_printf("Failed to allocate adv_monitor"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + adv_monitor->idx = adv_mon_idx; + adv_monitor->type = g_strdup(type); + adv_monitor->rssi = rssi; + adv_monitor->patterns = patterns; + + adv_mons = g_slist_append(adv_mons, adv_monitor); + bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); +} + +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx) +{ + struct adv_monitor *adv_monitor; + GSList *l; + + if (monitor_idx < 0) { + for (l = adv_mons; l; l = g_slist_next(l)) { + adv_monitor = l->data; + print_adv_monitor(adv_monitor); + } + return; + } + + adv_monitor = find_adv_monitor_with_idx(monitor_idx); + + if (adv_monitor == NULL) { + bt_shell_printf("Can't find monitor with index %d\n", + monitor_idx); + return; + } + + print_adv_monitor(adv_monitor); +} + +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) +{ + struct adv_monitor *adv_monitor; + + if (monitor_idx < 0) { + g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); + return; + } + + adv_monitor = find_adv_monitor_with_idx(monitor_idx); + if (adv_monitor == NULL) { + bt_shell_printf("Can't find monitor with index %d\n", + monitor_idx); + return; + } + + adv_mons = g_slist_remove(adv_mons, adv_monitor); + free_adv_monitor(adv_monitor); + bt_shell_printf("Monitor %d deleted\n", monitor_idx); +} + +static void print_supported_list(GSList *list) +{ + GSList *iter; + + for (iter = list; iter; iter = g_slist_next(iter)) { + char *data = iter->data; + + printf(" %s", data); + } +} + +void adv_monitor_get_supported_info(void) +{ + bt_shell_printf("Supported Features:"); + print_supported_list(manager.supported_features); + bt_shell_printf("\n"); + + bt_shell_printf("Supported Moniter Types:"); + print_supported_list(manager.supported_types); + bt_shell_printf("\n"); +} diff --git a/client/adv_monitor.h b/client/adv_monitor.h index 77b0b62c6..12c01bd3f 100644 --- a/client/adv_monitor.h +++ b/client/adv_monitor.h @@ -17,7 +17,17 @@ * */ +#define RSSI_DEFAULT_HIGH_THRESHOLD -50 +#define RSSI_DEFAULT_LOW_THRESHOLD -70 +#define RSSI_DEFAULT_HIGH_TIMEOUT 10 +#define RSSI_DEFAULT_LOW_TIMEOUT 5 + void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); void adv_monitor_remove_manager(DBusConnection *conn); void adv_monitor_register_app(DBusConnection *conn); void adv_monitor_unregister_app(DBusConnection *conn); +void adv_monitor_add_monitor(DBusConnection *conn, char *type, + gboolean rssi_enabled, int argc, char *argv[]); +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx); +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx); +void adv_monitor_get_supported_info(void); diff --git a/client/main.c b/client/main.c index 75f8bc462..2b0243308 100644 --- a/client/main.c +++ b/client/main.c @@ -2719,6 +2719,85 @@ static void cmd_ad_clear(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_FAILURE); } +static void print_add_or_pattern_with_rssi_usage(void) +{ + bt_shell_printf("rssi-range format:\n" + "\t<low-rssi>,<high-rssi>\n" + "\tBoth parameters can be skipped, in that case the\n" + "\tparamter will be set to its pre-defined value\n"); + bt_shell_printf("\tPre-defined low-rssi,high-rssi: %d,%d\n", + RSSI_DEFAULT_LOW_THRESHOLD, + RSSI_DEFAULT_HIGH_THRESHOLD); + bt_shell_printf("timeout format:\n" + "\t<low-rssi>,<high-rssi>\n" + "\tBoth parameters can be skipped, in that case the\n" + "\tparamter will be set to its pre-defined value\n"); + bt_shell_printf("\tPre-defined low-timeout,high-timeout: %d,%d\n", + RSSI_DEFAULT_LOW_TIMEOUT, + RSSI_DEFAULT_HIGH_TIMEOUT); + bt_shell_printf("pattern format:\n" + "\t<start_position> <ad_data_type> <content_of_pattern>\n"); + bt_shell_printf("e.g.\n" + "\tadd-or-pattern-rssi -10, ,10 1 2 01ab55\n"); + bt_shell_printf("or\n" + "\tadd-or-pattern-rssi -50,-30 , 1 2 01ab55 3 4 23cd66\n"); +} + +static void print_add_or_pattern_usage(void) +{ + bt_shell_printf("pattern format:\n" + "\t<start_position> <ad_data_type> <content_of_pattern>\n"); + bt_shell_printf("e.g.\n" + "\tadd-or-pattern 1 2 01ab55 3 4 23cd66\n"); +} + +static void cmd_adv_monitor_print_usage(int argc, char *argv[]) +{ + if (strcmp(argv[1], "add-or-pattern") == 0) + print_add_or_pattern_usage(); + else if (strcmp(argv[1], "add-or-pattern-rssi") == 0) + print_add_or_pattern_with_rssi_usage(); + else + bt_shell_printf("Invalid argument %s", argv[1]); +} + +static void cmd_adv_monitor_add_or_monitor_with_rssi(int argc, char *argv[]) +{ + adv_monitor_add_monitor(dbus_conn, "or_patterns", TRUE, argc, argv); +} + +static void cmd_adv_monitor_add_or_monitor(int argc, char *argv[]) +{ + adv_monitor_add_monitor(dbus_conn, "or_patterns", FALSE, argc, argv); +} + +static void cmd_adv_monitor_print_monitor(int argc, char *argv[]) +{ + int monitor_idx; + + if (strcmp(argv[1], "all") == 0) + monitor_idx = -1; + else + monitor_idx = atoi(argv[1]); + adv_monitor_print_monitor(dbus_conn, monitor_idx); +} + +static void cmd_adv_monitor_remove_monitor(int argc, char *argv[]) +{ + int monitor_idx; + + if (strcmp(argv[1], "all") == 0) + monitor_idx = -1; + else + monitor_idx = atoi(argv[1]); + adv_monitor_remove_monitor(dbus_conn, monitor_idx); +} + +static void cmd_adv_monitor_get_supported_info(int argc, char *argv[]) +{ + adv_monitor_get_supported_info(); +} + static const struct bt_shell_menu advertise_menu = { .name = "advertise", .desc = "Advertise Options Submenu", @@ -2755,6 +2834,35 @@ static const struct bt_shell_menu advertise_menu = { { } }, }; +static const struct bt_shell_menu advertise_monitor_menu = { + .name = "monitor", + .desc = "Advertisement Monitor Options Submenu", + .entries = { + { "add-or-pattern-rssi", "<rssi-range=low,high> <timeout=low,high> " + "[patterns=pattern1 pattern2 ...]", + cmd_adv_monitor_add_or_monitor_with_rssi, + "Add 'or pattern' type monitor with RSSI " + "filter" }, + { "add-or-pattern", "[patterns=pattern1 pattern2 ...]", + cmd_adv_monitor_add_or_monitor, + "Add 'or pattern' type monitor without RSSI " + "filter" }, + { "get-pattern", "<monitor-id/all>", + cmd_adv_monitor_print_monitor, + "Get advertisement monitor" }, + { "remove-pattern", "<monitor-id/all>", + cmd_adv_monitor_remove_monitor, + "Remove advertisement monitor" }, + { "get-supported-info", NULL, + cmd_adv_monitor_get_supported_info, + "Get advertisement manager supported " + "features and supported monitor types" }, + { "print-usage", "<add-or-pattern/add-or-pattern-rssi>", + cmd_adv_monitor_print_usage, + "Print the command usage"}, + { } }, +}; + static const struct bt_shell_menu scan_menu = { .name = "scan", .desc = "Scan Options Submenu", @@ -2932,6 +3040,7 @@ int main(int argc, char *argv[]) bt_shell_init(argc, argv, &opt); bt_shell_set_menu(&main_menu); bt_shell_add_submenu(&advertise_menu); + bt_shell_add_submenu(&advertise_monitor_menu); bt_shell_add_submenu(&scan_menu); bt_shell_add_submenu(&gatt_menu); bt_shell_set_prompt(PROMPT_OFF); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yMGbOdFpW1971QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 14:13:05 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gN5CNtFpW1+ZWgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 14:13:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C9898A0B36; Fri, 11 Sep 2020 14:12:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725875AbgIKMLd (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 08:11:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725803AbgIKMJn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 08:09:43 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11003C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:09:37 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id w64so5775452qkc.14 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=H97sd2VMcEYlgRPbkz3+uoOUi+oIFZnIzyaV5V/RIzk=; b=DMpK6PYno1QRfWatKPCOosuNcI1vVCb3CZe1zEMOYxuq90swW7ZUcsuJunMWF9lgF1 hgbqV9NSG1iAsaUIc+fnLN2E3tAroHFxKWnn3YWYJYFTet1dmRkeF6aU2JcwPV/+7L1N Q/twRvGtLtRaaaFokFp2wEalxvHaSjWy4QD7EDNjLplD2v/z3/gFkcIIvoiisBfHlst1 TjXb8l8GSLyyADIlEQSUUe1IOe6S8uDKv02Lb0lrK9EQCznGGJ5eJSNxQZf2iTohTyJm f0ch6q2mRgWzMPRPcF67Wb6Au4kDx5op+FmOaEKLGJrs1monvkPBBWux9S52eu6jF4q/ LUKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=H97sd2VMcEYlgRPbkz3+uoOUi+oIFZnIzyaV5V/RIzk=; b=W3vMilWaJ2TQhhEi1WuBokDT59URJxVXy8n2fVsNaUlhZM/u2TktsoH4GOi8Q2Bc+j Hi8IECFk6S1GAHgvgg0QGsbtI+IGCyNmuqVFxsmy/yK/BVbJFdKI3oRX3wn6phiszznC FgpV2KyaI4BauMsD9gpUY+27vfxsDnn+IVrzAOcrqZlVvnZsX2IZILhArkhLqgt0GLhB a2uq50RAZrFy/i+LM3T1IRypxlIDFJMow1J2EQxpHINRMNo1VXzUg2T7fZDxbQA5dkpO UvMsozccAuQ5c1yThHXXNWjlpGBgG/WUpMeO3HuBiGsRbxlGCQ/Ud/yYuRuxcZ+XBf9q JzSw== X-Gm-Message-State: AOAM533YA4AWBq7v0dLQHydSbDEKSlgW75uLLJrdt1ODDjE6WS31Hn7v dQqzrUt8NtdlgagZBGb7MPuPueuDNkq4JcMuNaI0tBckVCUeQbH265DQFvt1ZhTVJJ6ARWNvAUQ vwctXInA+LU7355p94rpcsJnRWi/14C+YAoDUjN2Q35nWVIlCtRMR/FC77yBUVP9Q1+mQZSgA3H JGWNdklHsQi6o= X-Google-Smtp-Source: ABdhPJyrxulY0ZPJnplwenh/iF1iepceGch7EeU4NlzJOTqTPLCEMj7JFhQSQiiYJOV8v9wFFnmR0Q3nbk0kBQDiEg== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a0c:f194:: with SMTP id m20mr1626575qvl.9.1599826176016; Fri, 11 Sep 2020 05:09:36 -0700 (PDT) Date: Fri, 11 Sep 2020 20:09:26 +0800 Message-Id: <20200911200839.BlueZ.v3.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v3 1/4] PRE-UPSTREAM: client: Implement basic interface of ADV monitor in bluetoothctl From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mmandlik@chromium.org, mcchou@chromium.org, luiz.von.dentz@intel.com, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: C9898A0B36 X-Rspamd-UID: ecd2b3 This patch implements some basic functions for ADV monitor in bluetoothctl [bluetooth]# show ... Advertisement Monitor Features: SupportedMonitorTypes: or_patterns Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v3: - Rename advertisement_monitor to adv_monitor Changes in v2: - Update the add-pattern usage - Fix styling issue in patch 1 - Fix storage class declaration issue Makefile.tools | 2 + client/adv_monitor.c | 161 +++++++++++++++++++++++++++++++++++++++++++ client/adv_monitor.h | 23 +++++++ client/main.c | 28 ++++++++ 4 files changed, 214 insertions(+) create mode 100644 client/adv_monitor.c create mode 100644 client/adv_monitor.h diff --git a/Makefile.tools b/Makefile.tools index 9b9236609..ed0fbf8a3 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -7,6 +7,8 @@ client_bluetoothctl_SOURCES = client/main.c \ client/agent.h client/agent.c \ client/advertising.h \ client/advertising.c \ + client/adv_monitor.h \ + client/adv_monitor.c \ client/gatt.h client/gatt.c client_bluetoothctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \ $(GLIB_LIBS) $(DBUS_LIBS) -lreadline diff --git a/client/adv_monitor.c b/client/adv_monitor.c new file mode 100644 index 000000000..2a62389d9 --- /dev/null +++ b/client/adv_monitor.c @@ -0,0 +1,161 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdbool.h> +#include <string.h> + +#include "gdbus/gdbus.h" +#include "src/shared/util.h" +#include "src/shared/shell.h" +#include "adv_monitor.h" + +#define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" + +static struct adv_monitor_manager { + GSList *supported_types; + GSList *supported_features; + GDBusProxy *proxy; + gboolean app_registered; +} manager = { NULL, NULL, NULL, FALSE }; + +static void set_supported_list(GSList **list, DBusMessageIter *iter) +{ + char *str; + DBusMessageIter subiter; + + dbus_message_iter_recurse(iter, &subiter); + while (dbus_message_iter_get_arg_type(&subiter) == + DBUS_TYPE_STRING) { + dbus_message_iter_get_basic(&subiter, &str); + *list = g_slist_append(*list, str); + dbus_message_iter_next(&subiter); + } +} + +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy) +{ + DBusMessageIter iter; + + if (manager.proxy != NULL || manager.supported_types != NULL || + manager.supported_features != NULL) { + bt_shell_printf("advertisement monitor manager already " + "added\n"); + return; + } + + manager.proxy = proxy; + + if (g_dbus_proxy_get_property(proxy, "SupportedMonitorTypes", &iter)) + set_supported_list(&(manager.supported_types), &iter); + + if (g_dbus_proxy_get_property(proxy, "SupportedFeatures", &iter)) + set_supported_list(&(manager.supported_features), &iter); + +} + +void adv_monitor_remove_manager(DBusConnection *conn) +{ + if (manager.supported_types != NULL) + g_slist_free(g_steal_pointer(&(manager.supported_types))); + if (manager.supported_features != NULL) + g_slist_free(g_steal_pointer(&(manager.supported_features))); + manager.proxy = NULL; + manager.app_registered = FALSE; +} + +static void register_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = ADV_MONITOR_APP_PATH; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +static void register_reply(DBusMessage *message, void *user_data) +{ + DBusConnection *conn = user_data; + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == FALSE) { + bt_shell_printf("AdvertisementMonitor path registered\n"); + } else { + bt_shell_printf("Failed to register path: %s\n", error.name); + dbus_error_free(&error); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } +} + +static void unregister_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = ADV_MONITOR_APP_PATH; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +static void unregister_reply(DBusMessage *message, void *user_data) +{ + DBusConnection *conn = user_data; + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == FALSE) { + bt_shell_printf("AdvertisementMonitor path unregistered\n"); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + bt_shell_printf("Failed to unregister Advertisement Monitor:" + " %s\n", error.name); + dbus_error_free(&error); + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + +void adv_monitor_register_app(DBusConnection *conn) +{ + if (manager.supported_types == NULL || manager.app_registered == TRUE || + g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", + register_setup, register_reply, + NULL, NULL) == FALSE) { + bt_shell_printf("Failed to register Advertisement Monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + manager.app_registered = TRUE; +} + +void adv_monitor_unregister_app(DBusConnection *conn) +{ + if (manager.app_registered == FALSE || + g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", + unregister_setup, unregister_reply, + NULL, NULL) == FALSE) { + bt_shell_printf("Failed to unregister Advertisement Monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + manager.app_registered = FALSE; +} diff --git a/client/adv_monitor.h b/client/adv_monitor.h new file mode 100644 index 000000000..77b0b62c6 --- /dev/null +++ b/client/adv_monitor.h @@ -0,0 +1,23 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); +void adv_monitor_remove_manager(DBusConnection *conn); +void adv_monitor_register_app(DBusConnection *conn); +void adv_monitor_unregister_app(DBusConnection *conn); diff --git a/client/main.c b/client/main.c index da877b546..75f8bc462 100644 --- a/client/main.c +++ b/client/main.c @@ -41,6 +41,7 @@ #include "agent.h" #include "gatt.h" #include "advertising.h" +#include "adv_monitor.h" /* String display constants */ #define COLORED_NEW COLOR_GREEN "NEW" COLOR_OFF @@ -58,6 +59,7 @@ static char *auto_register_agent = NULL; struct adapter { GDBusProxy *proxy; GDBusProxy *ad_proxy; + GDBusProxy *adv_monitor_proxy; GList *devices; }; @@ -528,6 +530,19 @@ static void ad_manager_added(GDBusProxy *proxy) adapter->ad_proxy = proxy; } +static void admon_manager_added(GDBusProxy *proxy) +{ + struct adapter *adapter; + + adapter = find_ctrl(ctrl_list, g_dbus_proxy_get_path(proxy)); + if (!adapter) + adapter = adapter_new(proxy); + + adapter->adv_monitor_proxy = proxy; + adv_monitor_add_manager(dbus_conn, proxy); + adv_monitor_register_app(dbus_conn); +} + static void proxy_added(GDBusProxy *proxy, void *user_data) { const char *interface; @@ -560,6 +575,9 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) ad_manager_added(proxy); } else if (!strcmp(interface, "org.bluez.Battery1")) { battery_added(proxy); + } else if (!strcmp(interface, + "org.bluez.AdvertisementMonitorManager1")) { + admon_manager_added(proxy); } } @@ -653,6 +671,9 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) ad_unregister(dbus_conn, NULL); } else if (!strcmp(interface, "org.bluez.Battery1")) { battery_removed(proxy); + } else if (!strcmp(interface, + "org.bluez.AdvertisementMonitorManager1")) { + adv_monitor_remove_manager(dbus_conn); } } @@ -935,6 +956,13 @@ static void cmd_show(int argc, char *argv[]) print_property(adapter->ad_proxy, "SupportedSecondaryChannels"); } + if (adapter->adv_monitor_proxy) { + bt_shell_printf("Advertisement Monitor Features:\n"); + print_property(adapter->adv_monitor_proxy, + "SupportedMonitorTypes"); + print_property(adapter->adv_monitor_proxy, "SupportedFeatures"); + } + return bt_shell_noninteractive_quit(EXIT_SUCCESS); } -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UL5RBABqW19/zAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 14:13:52 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id UIf+AQBqW19uwgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 14:13:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 90DC1A0B0F; Fri, 11 Sep 2020 14:13:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725818AbgIKMML (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 08:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725813AbgIKMKp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 08:10:45 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDC67C061786 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:09:50 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 78so5960289pgf.5 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=Mx6dIe1hDH83C2Uvj8bO8v9+XJULtPHkuvI4kGsXlTU=; b=tQLDZxIy/tzQaswMkrU95LGQMuZ8szJIH57vivJhYO4bEJny3gbd8LssjMK/+pzPS2 7REI1TMPjV/l9RKFISmXEdRwxVAEYiVTwsVVVXStN9bJ/49owkdwCGtRzn6n/av3jWxJ GFU4V9zYqV2QMNFO0XngR8/AqxMMRlrE/biuz9XkXFu+2kjBz3dRWDz5ZdOA5x4EfcJt 2cDdCFbO6gthGCsxkgGhCBRLyGwVAKOFWsdqLhqfe3AMzluzJ/2tctKpmhDWL9W6Xawz +YLBTRqTQAm0O+N5WZNVcngaUjhsoLjaqGZpT7COYU++xnPS8IyjldI4A7BqTedY2zBB wBUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Mx6dIe1hDH83C2Uvj8bO8v9+XJULtPHkuvI4kGsXlTU=; b=TfTBYIP4fMQFLBXrAanpmNh9GEPIq9cErceBOt8K6VYhg2SBz9na51Q1ASDevFhTwq jbYLFNOkbuLmcdHwfYT8CwQlTlw74gW1Dt9r2HXAcj9LD1sEjm+SgQ7P4CO8//mWKFX/ uofCE0ykbbldh3RI46Q6qWaJyQM7oCgfCAjDjBuClCt3yIkxD7xmT9YfeDNda0fMPIdt s3IQ5ZMbdtnoEKSIvtH7xRBuSpIDgC1cEV4gTmEvvfdFSy35/0fxMDYT1s/7P3EOHmu5 +2nosRbniJShjOWNy8vE1auxkncZU++VI5nPzoIxB+bzzNxh/BhkRsGpKf8wDlikyKHt 1LyQ== X-Gm-Message-State: AOAM532U2UfhYmpcNkrBx8+5qDXqYSuPzHrhR0/8C1w5OuXfxaqeBueq 1hdm/YjUqy9zRp+UcqbNBbSR0kWWjv4SCIpIUVdzJ1lPVGS6WB3UFptaMIn1tRqEU91VWUF2YrY b3e4CFXjva4Es2QoLVdczqLqfFfRQdeeaBTixjFdPGUYCsXpKTaJuyB237J7C1FbGdOMOFZSqHy AnrQtKyRYS844= X-Google-Smtp-Source: ABdhPJwsSBErXN5V6v8ghPcAuA7OgBD2dFzYFXgL1KyIUqAr0nAGiIn8UTis2ctbLNZAcEk+J3Hq2Mpa4avT6TqPTg== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a62:7a05:: with SMTP id v5mr1932342pfc.18.1599826190013; Fri, 11 Sep 2020 05:09:50 -0700 (PDT) Date: Fri, 11 Sep 2020 20:09:29 +0800 In-Reply-To: <20200911200839.BlueZ.v3.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200911200839.BlueZ.v3.4.Ieffbe3452565ace2af46a63501c767c8798fd88c@changeid> Mime-Version: 1.0 References: <20200911200839.BlueZ.v3.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v3 4/4] PRE-UPSTREAM: core: Add AdvertisementMonitor to bluetooth.conf From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mmandlik@chromium.org, mcchou@chromium.org, luiz.von.dentz@intel.com, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: 90DC1A0B0F X-Rspamd-UID: fc9e14 AdvertisementMonitor must be included in bluetooth.conf in order to be able to call Release Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/bluetooth.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bluetooth.conf b/src/bluetooth.conf index 8a1e25801..b6c614908 100644 --- a/src/bluetooth.conf +++ b/src/bluetooth.conf @@ -10,6 +10,7 @@ <policy user="root"> <allow own="org.bluez"/> <allow send_destination="org.bluez"/> + <allow send_interface="org.bluez.AdvertisementMonitor1"/> <allow send_interface="org.bluez.Agent1"/> <allow send_interface="org.bluez.MediaEndpoint1"/> <allow send_interface="org.bluez.MediaPlayer1"/> -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wNPmBwJzW19EtgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 14:52:18 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sOpBBQJzW1/geQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 14:52:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BD8A140966; Fri, 11 Sep 2020 14:52:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725997AbgIKMv3 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 08:51:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbgIKMug (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 08:50:36 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90824C061795 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:50:35 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id e16so11400584wrm.2 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9zpvoIknYzOcak/srr5UyAFlRBj0Vd0whcdZwIrzcFc=; b=Mgs8WOrammTSYbbtT4z5MyWKNphx+gqBJfNtCzwQEs8SKVKRxzk4AauhBD+sMuuD7X Fz26Pq8/7WahNMa8mO7G4N3qN+y7B0pquw+JWo7Brm9fFwGZDZAojkHLLd/nnyjYpECJ X1HBDg5xeoiwfApJY8YXsFDAOTO3bSZoMvJ8Sue41cGGOtsshiu24AdJ2FJwZ2gTQdzU 1LX0m5R684S+MWj+McKRFpW3vQm/6U8vcudTJ+1gxAo9snd0ogbAowU3A1ibXRI9y+IR qWn+R6tcWlbwWgVMUXDXjXdD/VhxNIaQXass1Fqwt+32kwLsi9rg+RY8cumsdoBfDD37 2n4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9zpvoIknYzOcak/srr5UyAFlRBj0Vd0whcdZwIrzcFc=; b=Sy7LnW+NnmAaaMoGFRCaeWHi4ms7eV6Ydr0lkzzPlOUm0tawNarFXrXGKbNBUsZjEk rx9tC8RvnSaDgCKrKNx5M4Wjb8NKJOGTBYQr69iXnlHOGEtlNrbHvLOlPvUByede5xiR gvWYbzog87ODFjU2Q0c49YHb1UY/B27v7D+TH6s/LbEG0AwzUjm5Uvoxaig7EULJ0c1C 7anrh2KO0Pqo1O8saRsEyzpwxvBW2oi5pLiU81QRAXs03b5Qga5JzrtOoIztmhm/aI98 pgTZwo/RvZbBdkwGpichHOrc+eAchjSeupu/1+wQOMuvdBtsTwrTWw1R67s1A+Y0ZPxT PUig== X-Gm-Message-State: AOAM530FWw/FN+E+CwTSvalgZg/Oz9ecF0IKDn2hP7EYhSAFtgeP8Gf0 lN/i3i2gAodO+mBEufSrXirCz3/9PVZNomGRrwKG8TWRjJ/WoA== X-Google-Smtp-Source: ABdhPJw94WKu3PC0Ny+QNdJTsv1zKbw7tOaXQB1Y+KyCWa4OHaeGwGISe7g8foAhM4Th9911C/fRvwlh88AFXI8Y4Qk= X-Received: by 2002:adf:8544:: with SMTP id 62mr1928192wrh.262.1599828633777; Fri, 11 Sep 2020 05:50:33 -0700 (PDT) MIME-Version: 1.0 References: <20200902125726.Bluez.v1.1.I732df55cd70d552fc48e87686fb53c3f8ccbefa5@changeid> In-Reply-To: <20200902125726.Bluez.v1.1.I732df55cd70d552fc48e87686fb53c3f8ccbefa5@changeid> From: Archie Pusaka <apusaka@google.com> Date: Fri, 11 Sep 2020 20:50:22 +0800 Message-ID: <CAJQfnxEHOx9mipC=y6NbTpXmmsowqXVCFbVUA4RVN4ncuwWD8Q@mail.gmail.com> Subject: Re: [Bluez PATCH v1] avrcp: Add handler for GET_TOTAL_NUMBER_OF_ITEMS To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Yun-Hao Chung <howardchung@google.com>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.69 / 15.00 / 15.00 X-Rspamd-Queue-Id: BD8A140966 X-Rspamd-UID: 164f14 Hi Bluez maintainers, Could you take another look at this patch? Thanks, Archie On Wed, 2 Sep 2020 at 12:57, Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > According to the AVRCP spec, section 4.5, GetTotalNumberOfItems PDU > is mandatory for TG supporting category 1 or 3. > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > Reviewed-by: Michael Sun <michaelfsun@google.com> > --- > > profiles/audio/avrcp.c | 58 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 58 insertions(+) > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > index 5d0256c52..6da73394f 100644 > --- a/profiles/audio/avrcp.c > +++ b/profiles/audio/avrcp.c > @@ -79,6 +79,7 @@ > #define AVRCP_STATUS_SUCCESS 0x04 > #define AVRCP_STATUS_UID_CHANGED 0x05 > #define AVRCP_STATUS_DOES_NOT_EXIST 0x09 > +#define AVRCP_STATUS_INVALID_SCOPE 0x0a > #define AVRCP_STATUS_OUT_OF_BOUNDS 0x0b > #define AVRCP_STATUS_INVALID_PLAYER_ID 0x11 > #define AVRCP_STATUS_PLAYER_NOT_BROWSABLE 0x12 > @@ -211,6 +212,12 @@ struct player_item { > char name[0]; > } __attribute__ ((packed)); > > +struct get_total_number_of_items_rsp { > + uint8_t status; > + uint16_t uid_counter; > + uint32_t num_items; > +} __attribute__ ((packed)); > + > struct avrcp_server { > struct btd_adapter *adapter; > uint32_t tg_record_id; > @@ -566,6 +573,9 @@ static void populate_default_features(void) > > /* supports at least AVRCP 1.4 */ > default_features[7] |= (1 << 2); > + > + /* supports GetTotalNumberOfItems browsing command */ > + default_features[8] |= (1 << 3); > } > > static unsigned int attr_get_max_val(uint8_t attr) > @@ -2048,10 +2058,56 @@ static void avrcp_handle_get_folder_items(struct avrcp *session, > case AVRCP_SCOPE_SEARCH: > case AVRCP_SCOPE_NOW_PLAYING: > default: > + status = AVRCP_STATUS_INVALID_SCOPE; > + goto failed; > + } > + > + return; > + > +failed: > + pdu->params[0] = status; > + pdu->param_len = htons(1); > +} > + > +static void avrcp_handle_media_player_list_num_items(struct avrcp *session, > + struct avrcp_browsing_header *pdu) > +{ > + struct avrcp_player *player = target_get_player(session); > + struct get_total_number_of_items_rsp *rsp; > + > + rsp = (void *)pdu->params; > + rsp->status = AVRCP_STATUS_SUCCESS; > + rsp->uid_counter = htons(player_get_uid_counter(player)); > + rsp->num_items = htonl(g_slist_length(session->server->players)); > + pdu->param_len = htons(sizeof(*rsp)); > +} > + > +static void avrcp_handle_get_total_number_of_items(struct avrcp *session, > + struct avrcp_browsing_header *pdu, > + uint8_t transaction) > +{ > + uint8_t scope; > + uint8_t status = AVRCP_STATUS_SUCCESS; > + > + if (ntohs(pdu->param_len) != 1) { > status = AVRCP_STATUS_INVALID_PARAM; > goto failed; > } > > + scope = pdu->params[0]; > + > + switch (scope) { > + case AVRCP_SCOPE_MEDIA_PLAYER_LIST: > + avrcp_handle_media_player_list_num_items(session, pdu); > + break; > + case AVRCP_SCOPE_MEDIA_PLAYER_VFS: > + case AVRCP_SCOPE_SEARCH: > + case AVRCP_SCOPE_NOW_PLAYING: > + default: > + status = AVRCP_STATUS_INVALID_SCOPE; > + goto failed; > + } > + > return; > > failed: > @@ -2065,6 +2121,8 @@ static struct browsing_pdu_handler { > uint8_t transaction); > } browsing_handlers[] = { > { AVRCP_GET_FOLDER_ITEMS, avrcp_handle_get_folder_items }, > + { AVRCP_GET_TOTAL_NUMBER_OF_ITEMS, > + avrcp_handle_get_total_number_of_items }, > { }, > }; > > -- > 2.28.0.402.g5ffc5be6b7-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MKQ6NzrnW1+nbQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 23:08:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gGFONDrnW18FDwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 23:08:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 46FE840966; Fri, 11 Sep 2020 23:08:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725895AbgIKVHv (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 17:07:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725849AbgIKVH2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 17:07:28 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AF1BC061757 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 14:07:26 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id l126so8274321pfd.5 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 14:07:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sVR9Vb4R3YNyl8BUOPHylCL5AwGFXPKzpdpN3YK2NSs=; b=FZmYI8NOZEYoS4h4TKsgjM8f5mBvp1E/CkXpw/byuJQC2or60GQAUwlWyuLGTTkWJQ JNnGYJKIc5H/aQXaI6IbuokuNfdvmasFv/rtyYq2+XzQXNe3A1LJcMnAE6X/8dCdYjs0 co8QwfC3omuZdZ3TDGwfhIKMZ2mRCK5wWno0E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sVR9Vb4R3YNyl8BUOPHylCL5AwGFXPKzpdpN3YK2NSs=; b=ip7czS7rcM2aOlsJXYab1K/6xzU061LcZgc9v98NRRPVInyCTNLadk63D4DVsN6EDP bFBc6v8179D5LffUO7mwqhRby/vasZTJ2M0Z80UrhYBLt0A/Xsp7yRDJP/ekeijarUu+ g0ww8mbMxfP8F6pUIBy9C5hmhDIWFXUjaHEmzoJY1Lag8Oosbb6pEEJNRyMUHtBOeo/4 1Vaq+365UCW2arFwit+HZrPfJxcSBfOSC3mbvLLoqku6Ti5UT5rnh59ywQT1LjnYogsa 0Od8ycEkOkNA/5iqVr6k8a/Epc1oqvWBv1FiHUUVRyK5IIkOF6bQn/0SZLJNF0Q3fN+o uSew== X-Gm-Message-State: AOAM5309u5kv7By+uPFGgAIoSjxA6qD7G+E4K2nv9C6OSkpU5dwsSVzT Bnpgv/exL58aiUTNbXULOQxJwQ== X-Google-Smtp-Source: ABdhPJxlSSy9RxtXJFzD7hbrCJ7Ygdy35XD49t16Twl+/5tprqpPrs711fkwsdlgTW9P97QJhPKbFQ== X-Received: by 2002:a63:5003:: with SMTP id e3mr3128100pgb.274.1599858445949; Fri, 11 Sep 2020 14:07:25 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id c128sm3308764pfb.126.2020.09.11.14.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 14:07:25 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH v2 3/3] Bluetooth: Emit controller suspend and resume events Date: Fri, 11 Sep 2020 14:07:13 -0700 Message-Id: <20200911140700.v2.3.I905caec7d7bf0eb7a3ed9899b5afb9aebaf6f8a8@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911210713.4066465-1-abhishekpandit@chromium.org> References: <20200911210713.4066465-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.22 / 15.00 / 15.00 X-Rspamd-Queue-Id: 46FE840966 X-Rspamd-UID: 5b47a2 Emit controller suspend and resume events when we are ready for suspend and we've resumed from suspend. The controller suspend event will report whatever suspend state was successfully entered. The controller resume event will check the first HCI event that was received after we finished preparing for suspend and, if it was a connection event, store the address of the peer that caused the event. If it was not a connection event, we mark the wake reason as an unexpected event. Here is a sample btmon trace with these events: @ MGMT Event: Controller Suspended (0x002d) plen 1 Suspend state: Page scanning and/or passive scanning (2) @ MGMT Event: Controller Resumed (0x002e) plen 8 Wake reason: Remote wake due to peer device connection (2) LE Address: CD:F3:CD:13:C5:9A (OUI CD-F3-CD) Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Changes in v2: None include/net/bluetooth/hci_core.h | 3 ++ include/net/bluetooth/mgmt.h | 4 ++ net/bluetooth/hci_core.c | 26 +++++++++++- net/bluetooth/hci_event.c | 73 ++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 02a6ee056b2374..9873e1c8cd163b 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -484,6 +484,9 @@ struct hci_dev { enum suspended_state suspend_state; bool scanning_paused; bool suspended; + u8 wake_reason; + bdaddr_t wake_addr; + u8 wake_addr_type; wait_queue_head_t suspend_wait_q; DECLARE_BITMAP(suspend_tasks, __SUSPEND_NUM_TASKS); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index a4b8935e0db97a..6b55155e05e977 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -1042,3 +1042,7 @@ struct mgmt_ev_controller_resume { __u8 wake_reason; struct mgmt_addr_info addr; } __packed; + +#define MGMT_WAKE_REASON_NON_BT_WAKE 0x0 +#define MGMT_WAKE_REASON_UNEXPECTED 0x1 +#define MGMT_WAKE_REASON_REMOTE_WAKE 0x2 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index ef32b12f150cd1..8a2645a8330137 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3497,12 +3497,24 @@ static int hci_change_suspend_state(struct hci_dev *hdev, return hci_suspend_wait_event(hdev); } +static void hci_clear_wake_reason(struct hci_dev *hdev) +{ + hci_dev_lock(hdev); + + hdev->wake_reason = 0; + bacpy(&hdev->wake_addr, BDADDR_ANY); + hdev->wake_addr_type = 0; + + hci_dev_unlock(hdev); +} + static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action, void *data) { struct hci_dev *hdev = container_of(nb, struct hci_dev, suspend_notifier); int ret = 0; + u8 state = BT_RUNNING; /* If powering down, wait for completion. */ if (mgmt_powering_down(hdev)) { @@ -3523,15 +3535,27 @@ static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action, * - Second, program event filter/whitelist and enable scan */ ret = hci_change_suspend_state(hdev, BT_SUSPEND_DISCONNECT); + if (!ret) + state = BT_SUSPEND_DISCONNECT; /* Only configure whitelist if disconnect succeeded and wake * isn't being prevented. */ - if (!ret && !(hdev->prevent_wake && hdev->prevent_wake(hdev))) + if (!ret && !(hdev->prevent_wake && hdev->prevent_wake(hdev))) { ret = hci_change_suspend_state(hdev, BT_SUSPEND_CONFIGURE_WAKE); + if (!ret) + state = BT_SUSPEND_CONFIGURE_WAKE; + } + + hci_clear_wake_reason(hdev); + mgmt_suspending(hdev, state); + } else if (action == PM_POST_SUSPEND) { ret = hci_change_suspend_state(hdev, BT_RUNNING); + + mgmt_resuming(hdev, hdev->wake_reason, &hdev->wake_addr, + hdev->wake_addr_type); } done: diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 33d8458fdd4adc..a68be50097ac35 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -6000,6 +6000,76 @@ static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, return true; } +static void hci_store_wake_reason(struct hci_dev *hdev, u8 event, + struct sk_buff *skb) +{ + struct hci_ev_le_advertising_info *adv; + struct hci_ev_le_direct_adv_info *direct_adv; + struct hci_ev_le_ext_adv_report *ext_adv; + const struct hci_ev_conn_complete *conn_complete = (void *)skb->data; + const struct hci_ev_conn_request *conn_request = (void *)skb->data; + + hci_dev_lock(hdev); + + /* If we are currently suspended and this is the first BT event seen, + * save the wake reason associated with the event. + */ + if (!hdev->suspended || hdev->wake_reason) + goto unlock; + + /* Default to remote wake. Values for wake_reason are documented in the + * Bluez mgmt api docs. + */ + hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; + + /* Once configured for remote wakeup, we should only wake up for + * reconnections. It's useful to see which device is waking us up so + * keep track of the bdaddr of the connection event that woke us up. + */ + if (event == HCI_EV_CONN_REQUEST) { + bacpy(&hdev->wake_addr, &conn_complete->bdaddr); + hdev->wake_addr_type = BDADDR_BREDR; + } else if (event == HCI_EV_CONN_COMPLETE) { + bacpy(&hdev->wake_addr, &conn_request->bdaddr); + hdev->wake_addr_type = BDADDR_BREDR; + } else if (event == HCI_EV_LE_META) { + struct hci_ev_le_meta *le_ev = (void *)skb->data; + u8 subevent = le_ev->subevent; + u8 *ptr = &skb->data[sizeof(*le_ev)]; + u8 num_reports = *ptr; + + if ((subevent == HCI_EV_LE_ADVERTISING_REPORT || + subevent == HCI_EV_LE_DIRECT_ADV_REPORT || + subevent == HCI_EV_LE_EXT_ADV_REPORT) && + num_reports) { + adv = (void *)(ptr + 1); + direct_adv = (void *)(ptr + 1); + ext_adv = (void *)(ptr + 1); + + switch (subevent) { + case HCI_EV_LE_ADVERTISING_REPORT: + bacpy(&hdev->wake_addr, &adv->bdaddr); + hdev->wake_addr_type = adv->bdaddr_type; + break; + + case HCI_EV_LE_DIRECT_ADV_REPORT: + bacpy(&hdev->wake_addr, &direct_adv->bdaddr); + hdev->wake_addr_type = direct_adv->bdaddr_type; + break; + case HCI_EV_LE_EXT_ADV_REPORT: + bacpy(&hdev->wake_addr, &ext_adv->bdaddr); + hdev->wake_addr_type = ext_adv->bdaddr_type; + break; + } + } + } else { + hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; + } + +unlock: + hci_dev_unlock(hdev); +} + void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_event_hdr *hdr = (void *) skb->data; @@ -6033,6 +6103,9 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) skb_pull(skb, HCI_EVENT_HDR_SIZE); + /* Store wake reason if we're suspended */ + hci_store_wake_reason(hdev, event, skb); + switch (event) { case HCI_EV_INQUIRY_COMPLETE: hci_inquiry_complete_evt(hdev, skb); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WOVBNU/nW1+nbQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 23:08:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id CHrxMU/nW1+tvgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 23:08:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A12C3408B3; Fri, 11 Sep 2020 23:08:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725926AbgIKVIE (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 17:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbgIKVHZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 17:07:25 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 573A6C061798 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 14:07:25 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id mm21so2299912pjb.4 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 14:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wU19sqHhymvGkZ+Wtm/wcCxdG23VTDS4BHk0Ix+WsKo=; b=QbdSpYW3TXnEKB1YFeOgVyVcBLHQoeZiyQf7i9l3sXc4VLJHTkYvR7c7H9uYAuWWBj UZJ3YN62xrHi+9wyGU6TSokv41guE5JvLIBEBOqay24uPoEsKKAgS56Ih3uB9iClsK2K KxrAZ222wjojTh5F5FgRBc4DwX6LdiUJcfQ5k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wU19sqHhymvGkZ+Wtm/wcCxdG23VTDS4BHk0Ix+WsKo=; b=gL8yXDy64PJ+w/y//8CfVvYJs2Z6wmNszWGpRa2Wfn90FFFV9gnAfSpwZ+ocAFHFKu lDIZ1EGiuK7BC6icpWSfTeRD1O4UEHeJ9vyaWhCuFCUc1sBYK0X0BmkkAUHDKHF6R+bT kdejsGq1lrLomMQ4M2Q2Jr6GJpae2IjV5qbGIVX31Xj0NVtImKXJNTNfAVc9J8hx7J8t NpqrXG6oFCeyxhBplAcSiOr8wQbLKdDpX/SXd4hBv7+G9wFFnNqzVSevhf0QpEp7VFji PHmdtvAVutSnUqLBr2Ma/+bbPJRqX4vR+JPMKmYQkoDEWDKQ1Ljalgo/xB9phchLXJD4 +f0A== X-Gm-Message-State: AOAM530QqCDcPsoGyLLxbPorCL/v8tjWLRaIHkoqE4szwKazamtiFYsF paeiHEaQrJLXtZysj0NhbN32pA== X-Google-Smtp-Source: ABdhPJzoDtUtsRcEkFhHjmLfW0b3yjW/F9XLj9QgRtZ4xY1h2BESVzUrlq1IfGD9568wpsQcKubqfg== X-Received: by 2002:a17:90b:2347:: with SMTP id ms7mr3835734pjb.135.1599858444876; Fri, 11 Sep 2020 14:07:24 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id c128sm3308764pfb.126.2020.09.11.14.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 14:07:24 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH v2 2/3] Bluetooth: Add suspend reason for device disconnect Date: Fri, 11 Sep 2020 14:07:12 -0700 Message-Id: <20200911140700.v2.2.Ib9bb75b65362d32104df86ffad479761680bb2cb@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911210713.4066465-1-abhishekpandit@chromium.org> References: <20200911210713.4066465-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.13 / 15.00 / 15.00 X-Rspamd-Queue-Id: A12C3408B3 X-Rspamd-UID: 2ca807 Update device disconnect event with reason 0x5 to indicate that device disconnected because the controller is suspending. Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- Changes in v2: None include/net/bluetooth/mgmt.h | 1 + net/bluetooth/mgmt.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index e19e33c7b65c34..a4b8935e0db97a 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -842,6 +842,7 @@ struct mgmt_ev_device_connected { #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 #define MGMT_DEV_DISCONN_REMOTE 0x03 #define MGMT_DEV_DISCONN_AUTH_FAILURE 0x04 +#define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND 0x05 #define MGMT_EV_DEVICE_DISCONNECTED 0x000C struct mgmt_ev_device_disconnected { diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index db48ee3c213cbd..0b711ad80f6bd1 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -8270,6 +8270,10 @@ void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, ev.addr.type = link_to_bdaddr(link_type, addr_type); ev.reason = reason; + /* Report disconnects due to suspend */ + if (hdev->suspended) + ev.reason = MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND; + mgmt_event(MGMT_EV_DEVICE_DISCONNECTED, hdev, &ev, sizeof(ev), sk); if (sk) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +FYnG1TnW1+kbQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 23:08:36 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id kBH7F1TnW18WtAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 23:08:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F201040962; Fri, 11 Sep 2020 23:08:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725911AbgIKVIE (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 17:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725828AbgIKVH0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 17:07:26 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F75BC061796 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 14:07:24 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id bd2so1449957plb.7 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 14:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q0EDfG7U4ZsAEWdz2bw53WcEhGvs/CQ/qZmbkCldzx8=; b=ex1Sl7Uz5mh12J+bs6llV1eFKhakw2Wom2mdEmwWqf4rpbgzAw6QYWoOCFiSwnHERc vAJ62kngwukDM245INL9WqPLR0P6gIK29OQ6KgOvoCi24Jo9Co0APBvPZA6oVai92dSS 5t2S/Ii+brIAbQrzJ77wQKErW0gUIeORvBgsc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q0EDfG7U4ZsAEWdz2bw53WcEhGvs/CQ/qZmbkCldzx8=; b=jbS4AYQ+xw4U/EUcTVC+dLj/bAAtmzLPhlw7+SxUnNH/qzJDgasl9tJ6bSUU7y9Qf3 2dUeTLEf8WTuVbD9vtl4qUcoYvtBSKh4U8aBuLjhdlYVoZUgaL8chnTwuJC2vTHIPf6i S3tlVlIW8XEeyGjKaGTB/tdlpIB7AaQXB3iddGIBgc6eZugkIp5+BOBOZsmWtbfKwCbP 0RWkY5UPDn2gnKtBaewOocJ/UAHCHSwOoLo1aOAuuvQq7Z2S/0r5tr5HHT0S168UkMS0 /cSoqZmyZVe5Rgb38nLEJeL3lpfy0157+LOfYRODmjRgad5RXk2lDxnbtI/0BXAvScId GobQ== X-Gm-Message-State: AOAM532lon78j0EO57vKSiG2Os+PbrYy1hNUbXz5b5+Ee6mmOXPMaoGV M4Wtd8xt97vnsPNDuO9MhXTT7g== X-Google-Smtp-Source: ABdhPJwjV//LWKkRlmziKhmehZRNQek4ZJQNFtvQDNBHlDqxB2Lc8nfxYwDTAKmwwMuCEdn2iB1oPw== X-Received: by 2002:a17:90a:ebd7:: with SMTP id cf23mr3817171pjb.126.1599858443601; Fri, 11 Sep 2020 14:07:23 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id c128sm3308764pfb.126.2020.09.11.14.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 14:07:23 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH v2 1/3] Bluetooth: Add mgmt suspend and resume events Date: Fri, 11 Sep 2020 14:07:11 -0700 Message-Id: <20200911140700.v2.1.I1b721ef9da5c79d8515018d806801da4eacaf563@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911210713.4066465-1-abhishekpandit@chromium.org> References: <20200911210713.4066465-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.88 / 15.00 / 15.00 X-Rspamd-Queue-Id: F201040962 X-Rspamd-UID: a274cc Add the controller suspend and resume events, which will signal when Bluetooth has completed preparing for suspend and when it's ready for resume. Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- Changes in v2: - Added suspend/resume events to list of mgmt events include/net/bluetooth/hci_core.h | 3 +++ include/net/bluetooth/mgmt.h | 11 +++++++++++ net/bluetooth/mgmt.c | 26 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 8caac20556b499..02a6ee056b2374 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1750,6 +1750,9 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, s8 rssi, u8 *name, u8 name_len); void mgmt_discovering(struct hci_dev *hdev, u8 discovering); +void mgmt_suspending(struct hci_dev *hdev, u8 state); +void mgmt_resuming(struct hci_dev *hdev, u8 reason, bdaddr_t *bdaddr, + u8 addr_type); bool mgmt_powering_down(struct hci_dev *hdev); void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent); void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk, bool persistent); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 9ad505b9e694e4..e19e33c7b65c34 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -1030,3 +1030,14 @@ struct mgmt_ev_adv_monitor_added { struct mgmt_ev_adv_monitor_removed { __le16 monitor_handle; } __packed; + +#define MGMT_EV_CONTROLLER_SUSPEND 0x002d +struct mgmt_ev_controller_suspend { + __u8 suspend_state; +} __packed; + +#define MGMT_EV_CONTROLLER_RESUME 0x002e +struct mgmt_ev_controller_resume { + __u8 wake_reason; + struct mgmt_addr_info addr; +} __packed; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index e1d12494d16e14..db48ee3c213cbd 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -163,6 +163,8 @@ static const u16 mgmt_events[] = { MGMT_EV_PHY_CONFIGURATION_CHANGED, MGMT_EV_EXP_FEATURE_CHANGED, MGMT_EV_DEVICE_FLAGS_CHANGED, + MGMT_EV_CONTROLLER_SUSPEND, + MGMT_EV_CONTROLLER_RESUME, }; static const u16 mgmt_untrusted_commands[] = { @@ -8874,6 +8876,30 @@ void mgmt_discovering(struct hci_dev *hdev, u8 discovering) mgmt_event(MGMT_EV_DISCOVERING, hdev, &ev, sizeof(ev), NULL); } +void mgmt_suspending(struct hci_dev *hdev, u8 state) +{ + struct mgmt_ev_controller_suspend ev; + + ev.suspend_state = state; + mgmt_event(MGMT_EV_CONTROLLER_SUSPEND, hdev, &ev, sizeof(ev), NULL); +} + +void mgmt_resuming(struct hci_dev *hdev, u8 reason, bdaddr_t *bdaddr, + u8 addr_type) +{ + struct mgmt_ev_controller_resume ev; + + ev.wake_reason = reason; + if (bdaddr) { + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = addr_type; + } else { + memset(&ev.addr, 0, sizeof(ev.addr)); + } + + mgmt_event(MGMT_EV_CONTROLLER_RESUME, hdev, &ev, sizeof(ev), NULL); +} + static struct hci_mgmt_chan chan = { .channel = HCI_CHANNEL_CONTROL, .handler_count = ARRAY_SIZE(mgmt_handlers), -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +FDDFhRzW19yHQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 14:52:36 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id WO87ExRzW19DmgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 14:52:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DDBE84081F; Fri, 11 Sep 2020 14:52:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725850AbgIKMwL (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 08:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbgIKMuV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 08:50:21 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30231C061786 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:50:20 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id t10so11388483wrv.1 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 05:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xHXq+qbTwT1oiw0iWkZ04umRIfDUZBSQvLrUtjixjAE=; b=QtHGzHGRHluMVpFObRS8xYeQNADcXN58be9Ho4YCS9cGv5yZyJIm6mRGBlBuliuRwz thjhLpUqfJok9kRurUrdVW+VofJUnJjv2WC5La6pSXDYIhWKrwxbxfoFPuSwyhGETisu TyWpRTnyngPZxRYSq9wNXMMglWrVTYTpP6d+T9pQ2s+6tJOYY4mdD1lEZPhXkpNYroHM 0vZZzMsOefGtN425P+/8bXAIOXYG8bc4z+ArGCfQqizU9a/CJBxzx/f+lRuXrZtKYL2c z7BveapoqZUpqwWUTAcLS+ePQDGHfvmJ0b3F9V+QOjhMsxOrNkeqFyMT/LFfdRmgKL/W Tgsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xHXq+qbTwT1oiw0iWkZ04umRIfDUZBSQvLrUtjixjAE=; b=GCjKt7vjdI3JFgM8d0Ni+s1T1AYSFJhT+STDF3XEd+tDQlVabYHIzOx60fZrJodGRf Nqc9BGB7cwimcnOry8sFTUO3yydxFy/opPoFCfFIChrT8G5a8RcJ+XY1jX/98g2FEblx n2uBDWoKndXnAXm6fMZE3D+E4QwfG9t4Yw752pqoU/SUcktV9F+4oA0SlFLezve9FYWc lCZhigwbtoCwvQbhalRi+oreaf26cBRYTFzsZ0Ego9yTENujqU2PDZeYLRVgPCG0B7AD 62LfwzvkHqDWOXqW/miUDeSqPE+pfda6/I3Z2pth1TxnjfiPpkJB60jpyEpv2XO8W+g0 s4MQ== X-Gm-Message-State: AOAM533fdSmdVqKBlz1Li/O30kwH4jvtUlDMbpV3lyuxHhTmIsqkgf0q VSWA2CLL8kAA79u/XZJ0nD6/+v2arHxilCAkQ1K5/t/jxZR3+w== X-Google-Smtp-Source: ABdhPJwqxbeXO3d2lKd3Bo2RUBD9VFkl3yBYi8Z2STHJhfinRqdeyGrESTFYSa6n7VQ0h5hX/hAIRkFnIhUstpjf3rs= X-Received: by 2002:adf:dcc3:: with SMTP id x3mr1917679wrm.120.1599828618505; Fri, 11 Sep 2020 05:50:18 -0700 (PDT) MIME-Version: 1.0 References: <20200901115913.Bluez.v2.1.Ieeae14ab680eda03474551fdb7a0a020f950e9c1@changeid> In-Reply-To: <20200901115913.Bluez.v2.1.Ieeae14ab680eda03474551fdb7a0a020f950e9c1@changeid> From: Archie Pusaka <apusaka@google.com> Date: Fri, 11 Sep 2020 20:50:07 +0800 Message-ID: <CAJQfnxEx8E0Gt-em5CPX0hBRTkr_eLB6KSzyPoM17v=hrehaeg@mail.gmail.com> Subject: Re: [Bluez PATCH v2] audio/transport: Don't set volume if it's invalid To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: DDBE84081F X-Rspamd-UID: 7afac4 Hi Bluez maintainers, Could you take another look at this patch? Thanks, Archie On Tue, 1 Sep 2020 at 12:00, Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > Adding a check inside media_transport_update_volume to prevent > the volume being updated with an invalid value. > --- > > Changes in v2: > * Move the check from media.c:set_configuration > > profiles/audio/transport.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c > index a2c4f7dfb..dd1c553a2 100644 > --- a/profiles/audio/transport.c > +++ b/profiles/audio/transport.c > @@ -941,6 +941,9 @@ void media_transport_update_volume(struct media_transport *transport, > { > struct a2dp_transport *a2dp = transport->data; > > + if (volume < 0) > + return; > + > /* Check if volume really changed */ > if (a2dp->volume == volume) > return; > -- > 2.28.0.402.g5ffc5be6b7-goog > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CK+aA5/6W1/6xwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 00:30:55 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kHCQAJ/6W195XwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 00:30:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 05DD64087F; Sat, 12 Sep 2020 00:30:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725852AbgIKWaq (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 18:30:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbgIKWaq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 18:30:46 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2AB1C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:30:45 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id c196so8519071pfc.0 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3M5SvCzzgfbDImYwv4ANfKfHC0RVuBjaLjddB0TA9FE=; b=cQoYM7/8JVY9YmTZ/R0KXZ2uWKTiAVEXXMxgfNmfwfSzvad4BmOXgrv+jICxU0e3pT qX5x0L/hVOcFEt70baAu7JbaVwFYuuv2asBNq3IgvqAxGqwKXSNWuhphxaFdDhYhEiIL K7VPQ+XcfbCDixLzlrSaN1axsiYUpz3nliVPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3M5SvCzzgfbDImYwv4ANfKfHC0RVuBjaLjddB0TA9FE=; b=t3aTDGYQ1Tvov2tO+T3RQcOQL039lgyGXSAkqLN7z0XavP2G+6xPe3gfugpaOHXFi/ xK/coTVm8MeY3tCqYdBtACMMbcrLLD6J+u4kDGKuJyOBJMImfFE82zQBdZENc144hI6k 07BzL/Si+G79zPWQDFEikXKPUsuwGOrg8JrfOaFQD73MvQIeBpGG/A+iBgvC+ZH4GOKG G4eJ2hhY1/WXfmq7AndUhl+Iourth6kE/rQvtPUGnFa5Vc0rt4iHlnx06WeYQDiq8FW2 hZxNDAIBUVIR4IRaPj9T9AOj9crX/02Y/nHH3AJ2w2zKamU+iY/Nd2u1UP0vK7SNEyrX YwUw== X-Gm-Message-State: AOAM532mDm4oETm41GsSW11U+E2TO8sAQLxHBHfKBfL5FJJnlI99bzR3 rQXhHldicfHOtfqDA88adHqagA== X-Google-Smtp-Source: ABdhPJzceMEBLuu7mcSfWTFDJYK5Yc7NYfdhs0/o6tePmHziL9TDUYQFApCD+vsoQQoqiP4vAPl/KA== X-Received: by 2002:a63:ec03:: with SMTP id j3mr2948350pgh.299.1599863445013; Fri, 11 Sep 2020 15:30:45 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id m14sm3123742pfo.202.2020.09.11.15.30.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 15:30:44 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v4 0/4] adapter: Reconnect audio when resuming from suspend Date: Fri, 11 Sep 2020 15:30:33 -0700 Message-Id: <20200911223037.4127188-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.36 / 15.00 / 15.00 X-Rspamd-Queue-Id: 05DD64087F X-Rspamd-UID: 274bec Hi Luiz and Marcel, This is a quality of life improvement for the behavior of audio devices during system suspend. This depends on a kernel change that emits suspend/resume events: https://patchwork.kernel.org/project/bluetooth/list/?series=325771 Right now, audio devices will be disconnected as part of suspend but won't be reconnected when the system resumes without user interaction. This is annoying to some users as it causes an interruption to their normal work flow. This change reconnects audio devices that were disconnected for suspend using the following logic: * In the device disconnect callback, mark any devices with the A2DP service uuid for reconnect. The reconnect will not be queued until resume. * In the controller resume callback, queue any policy items that are marked to reconnect on resume for connection with the ResumeDelay value (default = 2s). A reconnect is queued after the controller resumes and the delay between resume and reconnect is configurable via the ResumeDelay key in the Policy settings. The 2s delay was chosen arbitrarily and I think anywhere up to 10s is probably ok. A longer delay is better to account for spurious wakeups and Wi-Fi reconnection time (avoiding any co-ex issues) at the downside of reconnection speed. Here are the tests I have done with this: - Single suspend and verified the headphones reconnect - Suspend stress test for 25 iterations and verify both Wi-Fi and Bluetooth audio reconnect on resume. (Ran with wake minimum time of 10s) - Suspend test with wake time = 1s to verify that BT reconnect isn't attempted. Ran 5 iterations with low wake time and then let it stay awake to confirm reconnect finally completed on last resume. - Suspend test with wake time between 1s - 4s. Ran with 5 iterations and verified it connected several times in the middle and finally at the end. I've tested this on a Pixelbook Go (AC-9260 controller) and HP Chromebook 14a (RTL8822CE controller) with GID6B headset. I've also tested this with the Pixel Buds 2. These earbuds actually reconnect automatically to the Chromebook (even without this policy change) and I verified that the new changes don't break the reconnection mechanism. Thanks Abhishek Changes in v4: - Set reconnect timer in disconnect if resume events aren't supported - Only set reconnect timer if adapter matches current notification - Refactor changes in src/adapter to its own commit - Refactor enabling A2DP_SINK_UUID into its own commit Changes in v3: - Refactored resume notification to use btd_adapter_driver - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 - Added A2DP_SINK_UUID to default reconnect list Changes in v2: - Refactored to use policy instead of connecting directly in adapter Abhishek Pandit-Subedi (4): adapter: Refactor kernel feature globals adapter: Handle controller resume and notify drivers policy: Enable reconnect for a2dp-sink in defaults policy: Reconnect audio on controller resume plugins/policy.c | 87 +++++++++++++++++++++++++++++++++------- src/adapter.c | 102 +++++++++++++++++++++++++++++++++-------------- src/adapter.h | 11 +++++ src/main.c | 1 + src/main.conf | 11 ++++- 5 files changed, 168 insertions(+), 44 deletions(-) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0FKWGaX6W1+4zAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 00:31:01 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id ePjwFqX6W18r4QAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 00:31:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 23A42408B1; Sat, 12 Sep 2020 00:30:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725882AbgIKWau (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 18:30:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbgIKWas (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 18:30:48 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 546C2C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:30:46 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a9so2396077pjg.1 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:30:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OnwnVWpP4inUT436hX2fJ8GmPl2qnLl+Eqc8u11ZD5Q=; b=lcs7yKThNKj7hYz0eK+/VxqfKRHX4R6HXMuGDYrV9CKWsyoApUR3lyxr437Pz0tLsZ mdvDZWJo4eF3psQKfO+INtlnwRaZmgDdArBZ/PPU1CcOHKeG++Y34BC+o9oKRjkZ9t4u w4ggWzNuwggJz4zCADKpSUuH1e9xPHeG84u0U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OnwnVWpP4inUT436hX2fJ8GmPl2qnLl+Eqc8u11ZD5Q=; b=YNGK4+AbkLgIpNSZxaLZC/8M+hJ7ZBlKyso/HMzAWjVUu7wPTcwJnLnAZ6mL6yFNEz gBEpTPTW3NDuP/torzo7T+buvbjSDTvnCzI+DMs2bsvx3wszsYREM/0CCPCCDHhTrHyl NVI+YQo9ognJx9WDEgXYI1KyErdk0rkbivrC1WadZ0y6llgAKBWNsNqmSJMOLeikuRu3 VE9rnyhgw/WDz0vzECd5kfeyu/3bGE9RHoR1pKEG6roRP31wgOSJKD72vMYmERtwp/cW BulKW+VCnoLVrJhzs+qTj/j+MuXWLad3vN58CFd+vRlN4FuAz1cjwjtIFK4PhXhZhHeQ TYXQ== X-Gm-Message-State: AOAM532rUDY3bVpDN9mjTFRHcGWVy4oD8CLgWSEuvx0QkhtsY8YQbsJ9 2js4Yda4w2DZHX3KLtemdXAJMQ== X-Google-Smtp-Source: ABdhPJxQV64BK/wqN6el8V0WnFBr6xi5lAMrAnvJGqnUr+UjKKTpb8QbvnxoVldkxNExkzh79TXwTg== X-Received: by 2002:a17:90b:245:: with SMTP id fz5mr3949591pjb.131.1599863445873; Fri, 11 Sep 2020 15:30:45 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id m14sm3123742pfo.202.2020.09.11.15.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 15:30:45 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v4 1/4] adapter: Refactor kernel feature globals Date: Fri, 11 Sep 2020 15:30:34 -0700 Message-Id: <20200911153010.Bluez.v4.1.Ib9712d2bf5d4b3f90c5bc835742aea8c7cd239e4@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911223037.4127188-1-abhishekpandit@chromium.org> References: <20200911223037.4127188-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.57 / 15.00 / 15.00 X-Rspamd-Queue-Id: 23A42408B1 X-Rspamd-UID: 85efbe Move all the kernel specific feature globals into a single kernel_features bitfield and replace all uses with the bitfield instead. --- Changes in v4: None Changes in v3: None Changes in v2: None src/adapter.c | 59 ++++++++++++++++++++++++++------------------------- src/adapter.h | 9 ++++++++ 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 1435e2bd7..e700a78d5 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -116,13 +116,7 @@ static const struct mgmt_blocked_key_info blocked_keys[] = { static DBusConnection *dbus_conn = NULL; -static bool kernel_conn_control = false; - -static bool kernel_blocked_keys_supported = false; - -static bool kernel_set_system_config = false; - -static bool kernel_exp_features = false; +static uint32_t kernel_features = 0; static GList *adapter_list = NULL; static unsigned int adapter_remaining = 0; @@ -678,7 +672,7 @@ static bool set_discoverable(struct btd_adapter *adapter, uint8_t mode, DBG("sending set mode command for index %u", adapter->dev_id); - if (kernel_conn_control) { + if (has_kernel_features(KERNEL_CONN_CONTROL)) { if (mode) set_mode(adapter, MGMT_OP_SET_CONNECTABLE, mode); else @@ -1334,7 +1328,7 @@ static void trigger_passive_scanning(struct btd_adapter *adapter) * no need to start any discovery. The kernel will keep scanning * as long as devices are in its auto-connection list. */ - if (kernel_conn_control) + if (has_kernel_features(KERNEL_CONN_CONTROL)) return; /* @@ -1385,7 +1379,7 @@ static void stop_passive_scanning_complete(uint8_t status, uint16_t length, * no need to stop any discovery. The kernel will handle the * auto-connection by itself. */ - if (kernel_conn_control) + if (has_kernel_features(KERNEL_CONN_CONTROL)) return; /* @@ -2816,7 +2810,7 @@ static void property_set_mode_complete(uint8_t status, uint16_t length, static void clear_discoverable(struct btd_adapter *adapter) { - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; if (!(adapter->current_settings & MGMT_SETTING_DISCOVERABLE)) @@ -2876,7 +2870,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, break; case MGMT_SETTING_DISCOVERABLE: - if (kernel_conn_control) { + if (has_kernel_features(KERNEL_CONN_CONTROL)) { if (mode) { set_mode(adapter, MGMT_OP_SET_CONNECTABLE, mode); @@ -4193,7 +4187,8 @@ static void load_default_system_params(struct btd_adapter *adapter) size_t len = 0; unsigned int err; - if (!main_opts.default_params.num_entries || !kernel_set_system_config) + if (!main_opts.default_params.num_entries || + !has_kernel_features(KERNEL_SET_SYSTEM_CONFIG)) return; params = malloc0(sizeof(*params) * @@ -4878,7 +4873,7 @@ int adapter_connect_list_add(struct btd_adapter *adapter, * adapter_auto_connect_add() function is used to maintain what to * connect. */ - if (kernel_conn_control) + if (has_kernel_features(KERNEL_CONN_CONTROL)) return 0; if (g_slist_find(adapter->connect_list, device)) { @@ -4918,7 +4913,7 @@ void adapter_connect_list_remove(struct btd_adapter *adapter, if (device == adapter->connect_le) adapter->connect_le = NULL; - if (kernel_conn_control) + if (has_kernel_features(KERNEL_CONN_CONTROL)) return; if (!g_slist_find(adapter->connect_list, device)) { @@ -4980,7 +4975,7 @@ void adapter_whitelist_add(struct btd_adapter *adapter, struct btd_device *dev) { struct mgmt_cp_add_device cp; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; memset(&cp, 0, sizeof(cp)); @@ -5019,7 +5014,7 @@ void adapter_whitelist_remove(struct btd_adapter *adapter, struct btd_device *de { struct mgmt_cp_remove_device cp; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; memset(&cp, 0, sizeof(cp)); @@ -5075,7 +5070,7 @@ void adapter_auto_connect_add(struct btd_adapter *adapter, uint8_t bdaddr_type; unsigned int id; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; if (g_slist_find(adapter->connect_list, device)) { @@ -5147,7 +5142,7 @@ void adapter_set_device_wakeable(struct btd_adapter *adapter, const bdaddr_t *bdaddr; uint8_t bdaddr_type; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; bdaddr = device_get_address(device); @@ -5224,7 +5219,7 @@ void adapter_auto_connect_remove(struct btd_adapter *adapter, uint8_t bdaddr_type; unsigned int id; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; if (!g_slist_find(adapter->connect_list, device)) { @@ -6764,7 +6759,7 @@ connect_le: * If kernel background scan is used then the kernel is * responsible for connecting. */ - if (kernel_conn_control) + if (has_kernel_features(KERNEL_CONN_CONTROL)) return; /* @@ -8964,7 +8959,7 @@ static int clear_devices(struct btd_adapter *adapter) { struct mgmt_cp_remove_device cp; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return 0; memset(&cp, 0, sizeof(cp)); @@ -9282,7 +9277,7 @@ static void read_info_complete(uint8_t status, uint16_t length, (missing_settings & MGMT_SETTING_FAST_CONNECTABLE)) set_mode(adapter, MGMT_OP_SET_FAST_CONNECTABLE, 0x01); - if (kernel_exp_features) + if (has_kernel_features(KERNEL_EXP_FEATURES)) read_exp_features(adapter); err = adapter_register(adapter); @@ -9403,7 +9398,8 @@ static void read_info_complete(uint8_t status, uint16_t length, set_name(adapter, btd_adapter_get_name(adapter)); - if (kernel_blocked_keys_supported && !set_blocked_keys(adapter)) { + if (has_kernel_features(KERNEL_BLOCKED_KEYS_SUPPORTED) && + !set_blocked_keys(adapter)) { btd_error(adapter->dev_id, "Failed to set blocked keys for index %u", adapter->dev_id); @@ -9414,7 +9410,7 @@ static void read_info_complete(uint8_t status, uint16_t length, !(adapter->current_settings & MGMT_SETTING_BONDABLE)) set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01); - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) set_mode(adapter, MGMT_OP_SET_CONNECTABLE, 0x01); else if (adapter->current_settings & MGMT_SETTING_CONNECTABLE) set_mode(adapter, MGMT_OP_SET_CONNECTABLE, 0x00); @@ -9590,19 +9586,19 @@ static void read_commands_complete(uint8_t status, uint16_t length, switch (op) { case MGMT_OP_ADD_DEVICE: DBG("enabling kernel-side connection control"); - kernel_conn_control = true; + kernel_features |= KERNEL_CONN_CONTROL; break; case MGMT_OP_SET_BLOCKED_KEYS: DBG("kernel supports the set_blocked_keys op"); - kernel_blocked_keys_supported = true; + kernel_features |= KERNEL_BLOCKED_KEYS_SUPPORTED; break; case MGMT_OP_SET_DEF_SYSTEM_CONFIG: DBG("kernel supports set system confic"); - kernel_set_system_config = true; + kernel_features |= KERNEL_SET_SYSTEM_CONFIG; break; case MGMT_OP_READ_EXP_FEATURES_INFO: DBG("kernel supports exp features"); - kernel_exp_features = true; + kernel_features |= KERNEL_EXP_FEATURES; break; default: break; @@ -9768,3 +9764,8 @@ bool btd_le_connect_before_pairing(void) return false; } + +bool has_kernel_features(uint32_t features) +{ + return !!(kernel_features & features); +} diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..b0ed4915f 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -233,3 +233,12 @@ void btd_adapter_for_each_device(struct btd_adapter *adapter, void *data); bool btd_le_connect_before_pairing(void); + +enum kernel_features { + KERNEL_CONN_CONTROL = 1 << 0, + KERNEL_BLOCKED_KEYS_SUPPORTED = 1 << 1, + KERNEL_SET_SYSTEM_CONFIG = 1 << 2, + KERNEL_EXP_FEATURES = 1 << 3, +}; + +bool has_kernel_features(uint32_t feature); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cBQTMav6W1+4zAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 00:31:07 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +D65Lav6W18pNgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 00:31:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 81DE2408B1; Sat, 12 Sep 2020 00:31:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725888AbgIKWay (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 18:30:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbgIKWas (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 18:30:48 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30CD5C061757 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:30:47 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id m5so7537842pgj.9 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WaLvyDrpSOjFqABkikbrubyIQ9gGcpKW8XM7vdEOdKA=; b=Ybrt8GDp4U0Ref+E7puBcHWfPDeqZwmnDzBVdD7Dl8dM4XCcdjemh+UcuyJ+GCBIeN VvfI56mOhtYfsip2ICar2nX41HBqhyjAy9YYZq+KHS0C20b3RjnHBK4UgqDYPE3UujpY zOthAQCPCBOpf8Okk9WkZ3HNUFV7O4GpwwJJ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WaLvyDrpSOjFqABkikbrubyIQ9gGcpKW8XM7vdEOdKA=; b=P3yRDpl/rs8FCF2QGvlolt6ePE/WaS4rCGQgBRD+u3VlsDAm8qpRn7+fso3q+fi66n wEx31A3sVadKOOW8QkYizpuExMIV54ey8ArKnZ+i1OY/N8jKIlJX65GxZfnsbNL7/qd9 XQ0fctpzdJ8AL8YkojXxR04EOBkZznebJIzjgxDeRkjNv9MlykVFkYI/l7LEDVV2BAXE PE8M3POc2C0SQX3UnBP8bhYB3hKn2hpDaQaCId1UxuBs2OZfc8faKL6cAcquHM1lWqGA JSWZePQnaDlxid6gw3svVcdy6KSJ4Iw49dJ+cvld3TxU+Rg89D+4ipgXZUEpqfit95IU iW1w== X-Gm-Message-State: AOAM5323O8noDa3r8+9ds9KpQccgRjTLh4LgHYPZ6v363YE5+JPo5ZfQ r4zPThhs/GY33Fetv50N5uzHxA== X-Google-Smtp-Source: ABdhPJxzXgcnx5kETwJRmZa8l8Bd1kKZiC5t6POvTuSOOmCYl77EML9xgKIdBOEEM4sOOkg+JeI9uw== X-Received: by 2002:a63:464c:: with SMTP id v12mr3182389pgk.130.1599863446753; Fri, 11 Sep 2020 15:30:46 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id m14sm3123742pfo.202.2020.09.11.15.30.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 15:30:46 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v4 2/4] adapter: Handle controller resume and notify drivers Date: Fri, 11 Sep 2020 15:30:35 -0700 Message-Id: <20200911153010.Bluez.v4.2.Ic6aa9c03323b5ef0265e5b5b36986af05d9ecd26@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911223037.4127188-1-abhishekpandit@chromium.org> References: <20200911223037.4127188-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.57 / 15.00 / 15.00 X-Rspamd-Queue-Id: 81DE2408B1 X-Rspamd-UID: fd4571 Register for controller resume notification and notify the adapter drivers when it occurs. Also adds the resume event kernel feature to make sure the kernel supports this event. --- Changes in v4: None Changes in v3: None Changes in v2: None src/adapter.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/adapter.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index e700a78d5..d77d83d11 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -8771,6 +8771,33 @@ static void connected_callback(uint16_t index, uint16_t length, eir_data_free(&eir_data); } +static void controller_resume_notify(struct btd_adapter *adapter) +{ + GSList *l; + + for (l = adapter->drivers; l; l = g_slist_next(l)) { + struct btd_adapter_driver *driver = l->data; + if (driver->resume) + driver->resume(adapter); + } +} + +static void controller_resume_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_ev_controller_resume *ev = param; + struct btd_adapter *adapter = user_data; + + if (length < sizeof(*ev)) { + btd_error(adapter->dev_id, "Too small device resume event"); + return; + } + + info("Controller resume with wake event 0x%x", ev->wake_reason); + + controller_resume_notify(adapter); +} + static void device_blocked_callback(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9394,6 +9421,11 @@ static void read_info_complete(uint8_t status, uint16_t length, user_passkey_notify_callback, adapter, NULL); + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, + adapter->dev_id, + controller_resume_callback, + adapter, NULL); + set_dev_class(adapter); set_name(adapter, btd_adapter_get_name(adapter)); @@ -9604,6 +9636,17 @@ static void read_commands_complete(uint8_t status, uint16_t length, break; } } + + for (i = 0; i < num_events; i++) { + uint16_t ev = get_le16(rp->opcodes + num_commands + i); + + switch(ev) { + case MGMT_EV_CONTROLLER_RESUME: + DBG("kernel supports suspend/resume events"); + kernel_features |= KERNEL_HAS_RESUME_EVT; + break; + } + } } static void read_version_complete(uint8_t status, uint16_t length, diff --git a/src/adapter.h b/src/adapter.h index b0ed4915f..fae2e9d3d 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -113,6 +113,7 @@ struct btd_adapter_driver { const char *name; int (*probe) (struct btd_adapter *adapter); void (*remove) (struct btd_adapter *adapter); + void (*resume) (struct btd_adapter *adapter); }; typedef void (*service_auth_cb) (DBusError *derr, void *user_data); @@ -239,6 +240,7 @@ enum kernel_features { KERNEL_BLOCKED_KEYS_SUPPORTED = 1 << 1, KERNEL_SET_SYSTEM_CONFIG = 1 << 2, KERNEL_EXP_FEATURES = 1 << 3, + KERNEL_HAS_RESUME_EVT = 1 << 4, }; bool has_kernel_features(uint32_t feature); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oN9mBbL6W1+4zAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 00:31:14 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id qFQLArL6W1929gAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 00:31:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DBF1440869; Sat, 12 Sep 2020 00:31:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725890AbgIKWa5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 18:30:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725856AbgIKWat (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 18:30:49 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DACAC0613ED for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:30:48 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id c3so1540359plz.5 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g/SMny2P7BvcZfQfCGZTxLxuPv+qDCSbc/fXi3RUGtg=; b=YIdW57fXDJDPfJWC84dOakS/JRR6DU97MKMfmWJpbZIypmzyrNVthU+rRju0soXp+F LZ4UhZW5A/q2Vz4RmRTQyYHbiQQ+vD5H8IyL/xOKr0bWn04Yybdp/UqQ7W/uQmnFZpch /wkhy/gBXI7DapM0ZkfIW4inEWRjM+/JAaC1o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g/SMny2P7BvcZfQfCGZTxLxuPv+qDCSbc/fXi3RUGtg=; b=kkZXfKjYD3L3QKEHEHDmgjQWEB1GWRXmLix9lS2n+DMPUcbMDQQb6qSFbefO4G5a6S CEFR2c74Q93L1JcWmCGDjlM95QVylpjt48MMWKsMT+6mhsrG7jbIbfSKhEAHxDEbQFk+ lSScIP2441ub+8Ql5faMfESYqQg4PMtUOe+L0oddJc22yCf9kLxdayOwrK7zYmX8J2CE 1Xlz9PXrIoyg9ptp23wNq7VofZDgypjMo+Q+Y6AxePjxQcfOeL6gd5bLq2Lx5rD8pp9T CVgc8J6p0r8UZGOmiL92knncFFBPakXNTzu0wyLk8qj9sMUSzENugNHueZurSyuk792u mcYQ== X-Gm-Message-State: AOAM533af5MWA8oc1gQGSB/g42PDY+ASpmWeIEONDwxIvhdnSLIWGdPz Hj26AYKiJCmllGgfrEej796Pvg== X-Google-Smtp-Source: ABdhPJwLGFTOzzcZN+YqPO2iA5iID3TEeLsKHWJ+dgWu385NEjN3j7Q8ErYQ5JjH5Ptg5l2U6ZyaSw== X-Received: by 2002:a17:902:aa4b:b029:d0:cbe1:e739 with SMTP id c11-20020a170902aa4bb02900d0cbe1e739mr4589998plr.20.1599863447681; Fri, 11 Sep 2020 15:30:47 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id m14sm3123742pfo.202.2020.09.11.15.30.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 15:30:47 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v4 3/4] policy: Enable reconnect for a2dp-sink in defaults Date: Fri, 11 Sep 2020 15:30:36 -0700 Message-Id: <20200911153010.Bluez.v4.3.Ic87c0fbb00fe76356cee8f78a82b29a47fc6d438@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911223037.4127188-1-abhishekpandit@chromium.org> References: <20200911223037.4127188-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.57 / 15.00 / 15.00 X-Rspamd-Queue-Id: DBF1440869 X-Rspamd-UID: 7b71fe Add a2dp-sink to default reconnects list. --- Changes in v4: None Changes in v3: None Changes in v2: None plugins/policy.c | 3 ++- src/main.conf | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/policy.c b/plugins/policy.c index de51e58b9..c18ca8d1f 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -65,7 +65,8 @@ struct reconnect_data { }; static const char *default_reconnect[] = { - HSP_AG_UUID, HFP_AG_UUID, A2DP_SOURCE_UUID, NULL }; + HSP_AG_UUID, HFP_AG_UUID, A2DP_SOURCE_UUID, + A2DP_SINK_UUID, NULL }; static char **reconnect_uuids = NULL; static const size_t default_attempts = 7; diff --git a/src/main.conf b/src/main.conf index 42f7e41c5..e1d77cc47 100644 --- a/src/main.conf +++ b/src/main.conf @@ -186,7 +186,7 @@ # timeout). The policy plugin should contain a sane set of values by # default, but this list can be overridden here. By setting the list to # empty the reconnection feature gets disabled. -#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb +#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb,0000110b-0000-1000-8000-00805f9b34fb # ReconnectAttempts define the number of attempts to reconnect after a link # lost. Setting the value to 0 disables reconnecting feature. -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8JqQL8X6W1+4zAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 00:31:33 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AMDMLMX6W18nDAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 00:31:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6B7AE40618; Sat, 12 Sep 2020 00:31:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725895AbgIKWbD (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 18:31:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725887AbgIKWax (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 18:30:53 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 658CBC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:30:49 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id w7so8384310pfi.4 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bpdlpNcK/8y7A9u/to7Zf4xpQk2+RMyT+URstWuCPjo=; b=aMZSqJ/loMI3q7f+XP+yXBzHFyD2RdL0ud7O5SkGnmVnWmGbayiV9iqEEEd8nhkyMc /nODOytSN3YsPLPH4y1WW4r3Dlx2uKE5swaVzfLoMD61OWAhinMP9c3lAUM8OuL9QfmJ GtuRu0uC0LX5EPDpWjAOWHw1Jm1S4SUh58bF8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bpdlpNcK/8y7A9u/to7Zf4xpQk2+RMyT+URstWuCPjo=; b=LZkU+Vk81dHNRXcxIOHq37TXanl6HpZ/7z1wV3HSNx4FDRD6lVcvPeWYVRJscajQ3k EgDl9NlVv/tlo0EOBcTvqtXWdznQwxo3VAqMk6Cl5DvTuuNbb5l4tKxE2SEJo+WAZHrj 7fvrQsCb9dRrER7OF7T6USg63A5BUeeN8A4taNYeW3cqdFid08pEu1QB1/r4WUlMdjbm VOsH8sC+ttv61wXdIRi9Ghiw5a+B2xkXlWz1tFibRlc+Fo7HFdRfKqrcxaJj7JRVjZB7 pZg6Dz6tPPKOpBuv8CLLMJgxsj18vGXZg/VorXLBlIOTLXqTNoX9xQCaHDs82qpXEA3q 1EMQ== X-Gm-Message-State: AOAM5326Iv8eC8WOzO200fi31WkUsLnzjUmnsF8pt896Sq12D8Hbn962 UIUP+ho0Tz07BdSgG7DO76jCYg== X-Google-Smtp-Source: ABdhPJz8yTMI8Y/B3X5nyxyMNzQ8V83GVmsMVhHeB/rmBeuMMUYAi6X9VyzniDiFn5CizznTBfklrg== X-Received: by 2002:a63:6c0a:: with SMTP id h10mr3232681pgc.11.1599863448732; Fri, 11 Sep 2020 15:30:48 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id m14sm3123742pfo.202.2020.09.11.15.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 15:30:48 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v4 4/4] policy: Reconnect audio on controller resume Date: Fri, 11 Sep 2020 15:30:37 -0700 Message-Id: <20200911153010.Bluez.v4.4.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911223037.4127188-1-abhishekpandit@chromium.org> References: <20200911223037.4127188-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.57 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6B7AE40618 X-Rspamd-UID: bb6a70 During system suspend, all peer devices are disconnected. On resume, HID devices will reconnect but audio devices stay disconnected. As a quality of life improvement, mark audio devices that were disconnected due to suspend and attempt to reconnect them when the controller resumes (after a delay for better co-existence with Wi-Fi). --- Changes in v4: - Set reconnect timer in disconnect if resume events aren't supported - Only set reconnect timer if adapter matches current notification - Refactor changes in src/adapter to its own commit - Refactor enabling A2DP_SINK_UUID into its own commit Changes in v3: - Refactored resume notification to use btd_adapter_driver - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 - Added A2DP_SINK_UUID to default reconnect list Changes in v2: - Refactored to use policy instead of connecting directly in adapter plugins/policy.c | 84 ++++++++++++++++++++++++++++++++++++++++-------- src/main.c | 1 + src/main.conf | 9 ++++++ 3 files changed, 81 insertions(+), 13 deletions(-) diff --git a/plugins/policy.c b/plugins/policy.c index c18ca8d1f..6bd389518 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -62,6 +62,7 @@ struct reconnect_data { guint timer; bool active; unsigned int attempt; + bool on_resume; }; static const char *default_reconnect[] = { @@ -76,6 +77,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; static int *reconnect_intervals = NULL; static size_t reconnect_intervals_len = 0; +static const int default_resume_delay = 2; +static int resume_delay; + static GSList *reconnects = NULL; static unsigned int service_id = 0; @@ -712,6 +716,9 @@ static gboolean reconnect_timeout(gpointer data) /* Mark the GSource as invalid */ reconnect->timer = 0; + /* Mark any reconnect on resume as handled */ + reconnect->on_resume = false; + err = btd_device_connect_services(reconnect->dev, reconnect->services); if (err < 0) { error("Reconnecting services failed: %s (%d)", @@ -725,14 +732,17 @@ static gboolean reconnect_timeout(gpointer data) return FALSE; } -static void reconnect_set_timer(struct reconnect_data *reconnect) +static void reconnect_set_timer(struct reconnect_data *reconnect, int timeout) { - static int timeout = 0; + static int interval_timeout = 0; reconnect->active = true; if (reconnect->attempt < reconnect_intervals_len) - timeout = reconnect_intervals[reconnect->attempt]; + interval_timeout = reconnect_intervals[reconnect->attempt]; + + if (timeout < 0) + timeout = interval_timeout; DBG("attempt %u/%zu %d seconds", reconnect->attempt + 1, reconnect_attempts, timeout); @@ -744,10 +754,14 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) static void disconnect_cb(struct btd_device *dev, uint8_t reason) { struct reconnect_data *reconnect; + struct btd_service *service; + struct policy_data *data; DBG("reason %u", reason); - if (reason != MGMT_DEV_DISCONN_TIMEOUT) + /* Only attempt reconnect for the following reasons */ + if (reason != MGMT_DEV_DISCONN_TIMEOUT && + reason != MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND) return; reconnect = reconnect_find(dev); @@ -756,10 +770,47 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) reconnect_reset(reconnect); - DBG("Device %s identified for auto-reconnection", - device_get_path(dev)); + DBG("Device %s identified for auto-reconnection", device_get_path(dev)); + + switch(reason) + { + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: + if (btd_device_get_service(dev, A2DP_SINK_UUID)) { + DBG("%s configured to reconnect on resume", + device_get_path(dev)); - reconnect_set_timer(reconnect); + reconnect->on_resume = true; + + /* If the kernel supports resume events, it is + * preferable to set the reconnect timer there as it is + * a more predictable delay. + */ + if (!has_kernel_features(KERNEL_HAS_RESUME_EVT)) + reconnect_set_timer(reconnect, resume_delay); + } + break; + case MGMT_DEV_DISCONN_TIMEOUT: + reconnect_set_timer(reconnect, -1); + break; + default: + DBG("Developer error. Reason = %d", reason); + break; + } +} + +static void policy_adapter_resume(struct btd_adapter *adapter) +{ + GSList *l; + + /* Check if devices on this adapter need to be reconnected on resume */ + for (l = reconnects; l; l = g_slist_next(l)) { + struct reconnect_data *reconnect = l->data; + + if (reconnect->on_resume && + device_get_adapter(reconnect->dev) == adapter) { + reconnect_set_timer(reconnect, resume_delay); + } + } } static void conn_fail_cb(struct btd_device *dev, uint8_t status) @@ -787,14 +838,15 @@ static void conn_fail_cb(struct btd_device *dev, uint8_t status) return; } - reconnect_set_timer(reconnect); + reconnect_set_timer(reconnect, -1); } static int policy_adapter_probe(struct btd_adapter *adapter) { DBG(""); - btd_adapter_restore_powered(adapter); + if (auto_enable) + btd_adapter_restore_powered(adapter); return 0; } @@ -802,6 +854,7 @@ static int policy_adapter_probe(struct btd_adapter *adapter) static struct btd_adapter_driver policy_driver = { .name = "policy", .probe = policy_adapter_probe, + .resume = policy_adapter_resume, }; static int policy_init(void) @@ -855,14 +908,20 @@ static int policy_init(void) auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", NULL); + resume_delay = g_key_file_get_integer( + conf, "Policy", "ResumeDelay", &gerr); + + if (gerr) { + g_clear_error(&gerr); + resume_delay = default_resume_delay; + } done: if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { btd_add_disconnect_cb(disconnect_cb); btd_add_conn_fail_cb(conn_fail_cb); } - if (auto_enable) - btd_register_adapter_driver(&policy_driver); + btd_register_adapter_driver(&policy_driver); return 0; } @@ -883,8 +942,7 @@ static void policy_exit(void) btd_service_remove_state_cb(service_id); - if (auto_enable) - btd_unregister_adapter_driver(&policy_driver); + btd_unregister_adapter_driver(&policy_driver); } BLUETOOTH_PLUGIN_DEFINE(policy, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, diff --git a/src/main.c b/src/main.c index b37c32948..038f867b5 100644 --- a/src/main.c +++ b/src/main.c @@ -131,6 +131,7 @@ static const char *policy_options[] = { "ReconnectAttempts", "ReconnectIntervals", "AutoEnable", + "ResumeDelay", NULL }; diff --git a/src/main.conf b/src/main.conf index e1d77cc47..9f882e65a 100644 --- a/src/main.conf +++ b/src/main.conf @@ -202,3 +202,12 @@ # This includes adapters present on start as well as adapters that are plugged # in later on. Defaults to 'false'. #AutoEnable=false + +# Audio devices that were disconnected due to suspend will be reconnected on +# resume. ResumeDelay determines the delay between when the controller +# resumes from suspend and a connection attempt is made. A longer delay is +# better for better co-existence with Wi-Fi. +# The value is in seconds. +# Default: 2 +#ResumeDelay = 2 + -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UA6QLw77W1/6xwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 00:32:46 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id GC8iLQ77W18z5wAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 00:32:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E4357A0AAE; Sat, 12 Sep 2020 00:32:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725934AbgIKWc3 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 18:32:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbgIKWc1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 18:32:27 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 271CCC061757 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:32:27 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id gf14so2336953pjb.5 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5fqnO0t2+Ll5MSYJEMtNvP+VNTh8EknO1EV/7yDUvkg=; b=EPXQA1SPomdGDXZu2xay/okEIXVEzDSIwhmerPylv6hnMl4XmTzRnRewEG4vkbU0r4 4CzBgYyeGKx9I2Yl+0zemaccCpnrmtycDQmYYqqMmZt0iOsIl5gwNiLmcj7z3ylcyaKo fIGTEmI4Bd1lcOmOlxgGM3rk5P7lYd0Sx26+Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5fqnO0t2+Ll5MSYJEMtNvP+VNTh8EknO1EV/7yDUvkg=; b=ZHvC3b+K9qZs4caBvEB7bBApYXRrcvDwOg/C8j/DaZHJbuaN1v8qGVfkgfDZ7gqdkC lchvBkR1412LAWC0MOOBj2Py8f4SXaiEbDkJ7LzAGJpm2zWwIJJUsOBiwaR3J02sysKT w+Fkznuwvbic7X85I6EEpxw6qEQgy+d3gAHP+m6x/jtZt2WNhJ8LYvjizMej3r5F0TXy o+mM6gkVYkSqY93kj1wOVQX9a+CoXGkvV6OopqoazXkTx1lY4CahMXfWd5Mta65ajHkA 07c0VycaK9W01UfgWSIn9HpjskH9C1/mKFoZfBSO+bLVOto8fVRk7iPMVSz6LTBRDtbp TvJA== X-Gm-Message-State: AOAM531fKUjC1ayNS1zi1yYGQCwVBTipW4nzg2c2U5xDQJi5CRvAqDYK h4RM5kajzyafW+jvfDjo4CttDw== X-Google-Smtp-Source: ABdhPJw4KYhLZWrM8MzihLuYw4E30t5O+Y6VUTIE1WR3NPjAkywR4DujrtHCB/dKdL1Re5o04wfhiw== X-Received: by 2002:a17:902:d888:b029:d0:cb2d:f274 with SMTP id b8-20020a170902d888b02900d0cb2df274mr4451761plz.13.1599863546718; Fri, 11 Sep 2020 15:32:26 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id l9sm2905230pgg.29.2020.09.11.15.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 15:32:26 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Daniel Winkler <danielwinkler@google.com>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [RESEND PATCH] bluetooth: Set ext scan response only when it exists Date: Fri, 11 Sep 2020 15:32:20 -0700 Message-Id: <20200911153141.RESEND.1.Ib022565452fde0c02fbcf619950ef868715dd243@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.02 / 15.00 / 15.00 X-Rspamd-Queue-Id: E4357A0AAE X-Rspamd-UID: 391e45 Only set extended scan response only when it exists. Otherwise, clear the scan response data. Per the core spec v5.2, Vol 4, Part E, 7.8.55 If the advertising set is non-scannable and the Host uses this command other than to discard existing data, the Controller shall return the error code Invalid HCI Command Parameters (0x12). On WCN3991, the controller correctly responds with Invalid Parameters when this is sent. That error causes __hci_req_hci_power_on to fail with -EINVAL and LE devices can't connect because background scanning isn't configured. Here is an hci trace of where this issue occurs during power on: < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25 Handle: 0x00 Properties: 0x0010 Use legacy advertising PDUs: ADV_NONCONN_IND Min advertising interval: 181.250 msec (0x0122) Max advertising interval: 181.250 msec (0x0122) Channel map: 37, 38, 39 (0x07) Own address type: Random (0x01) Peer address type: Public (0x00) Peer address: 00:00:00:00:00:00 (OUI 00-00-00) Filter policy: Allow Scan Request from Any, Allow Connect... TX power: 127 dbm (0x7f) Primary PHY: LE 1M (0x01) Secondary max skip: 0x00 Secondary PHY: LE 1M (0x01) SID: 0x00 Scan request notifications: Disabled (0x00) > HCI Event: Command Complete (0x0e) plen 5 LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 1 Status: Success (0x00) TX power (selected): 9 dbm (0x09) < HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7 Advertising handle: 0x00 Advertising random address: 08:FD:55:ED:22:28 (OUI 08-FD-55) > HCI Event: Command Complete (0x0e) plen 4 LE Set Advertising Set Random Address (0x08|0x0035) ncmd Status: Success (0x00) < HCI Command: LE Set Extended Scan Response Data (0x08|0x0038) plen 35 Handle: 0x00 Operation: Complete scan response data (0x03) Fragment preference: Minimize fragmentation (0x01) Data length: 0x0d Name (short): Chromebook > HCI Event: Command Complete (0x0e) plen 4 LE Set Extended Scan Response Data (0x08|0x0038) ncmd 1 Status: Invalid HCI Command Parameters (0x12) Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Daniel Winkler <danielwinkler@google.com> --- net/bluetooth/hci_request.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index e0269192f2e536..e17bc8a1c66ddd 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1533,11 +1533,14 @@ void __hci_req_update_scan_rsp_data(struct hci_request *req, u8 instance) memset(&cp, 0, sizeof(cp)); - if (instance) + /* Extended scan response data doesn't allow a response to be + * set if the instance isn't scannable. + */ + if (get_adv_instance_scan_rsp_len(hdev, instance)) len = create_instance_scan_rsp_data(hdev, instance, cp.data); else - len = create_default_scan_rsp_data(hdev, cp.data); + len = 0; if (hdev->scan_rsp_data_len == len && !memcmp(cp.data, hdev->scan_rsp_data, len)) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uIN5JxScW19q1QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 17:47:32 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id EGKqJBScW1/zmwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 17:47:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6F3C3A0AF0; Fri, 11 Sep 2020 17:47:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726575AbgIKPqc (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 11:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726074AbgIKPoC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 11:44:02 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DD2EC0613ED for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 08:44:02 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id y5so8705982otg.5 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 08:44:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u6rIMAYi8YQ+iHRx2SZ568AIEDi3Qgp+XMjB0kWcHNI=; b=OCaWXHqabF5JRwYd3qv+b7U8DNGeVhSelbamEm+sHyDOJbsD8V2vAOPh8TLnAZbkvA LklsBfMjbzkVwwyZQ+jXmf7zbpF+ZPe6P8IkBtXAP05DNIid8UQE8sYhnxlkqUj6tRZ3 9eJ8zL/yCpjGymoChlxIlt1mQW+MCnGtUl8HVkaR7lT3U66hoJmolxy+3LMes3d1zznG oEIgapWwOTj27Cx81vuyoLyRN0tZEk14hMxcEceTVQEL8YQBHzfeGn1FxI/kiT9YNR3Z 4O5/zpLCoSJeSSGvczIPxdcMKmhKu/QsjJrAllSYj1wq1ctP7g/Ahro0ywSUNw5GlF9w lcJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=u6rIMAYi8YQ+iHRx2SZ568AIEDi3Qgp+XMjB0kWcHNI=; b=HOqRIeOvRdJJUNT9KJ8Vi6ufhZpj8ipdKuZ8o1U5pHIocF8c+aXqtcgE7tTJ/kxWcL CWKcq2bVXAC+PFK/Y8iYF+37M/mt5+tssa3g+Szmqaq/fM0FwY7BsK2z/OpRHJ20jjEz roNLMzxW7OXF1C4HMUihDns5MxA6jFMQ/D0E964qBfCVoRSDdfw4v6bru+cGMspNmXd6 cluK29lhmnqXFdL+m464F2qYjFJUiGjFArNyM+nEIg+Z1kgcKP1gDnzZ0crSlSEHlWqg H1Qb/xbjbhP5xnQkxm5ualumRoKExYXpGFy3MaiFGCzlUQANxtg5s1YoMtNpEA3ig8m7 37nw== X-Gm-Message-State: AOAM530AB9xu3m/bdAjMNdtHwMlk03vHlrIWQLziOVC7rCgkiW5MGn2q J1O8/iYsKG2q1oGQf+YuHujSa6CrqcCe4qxZzWg= X-Google-Smtp-Source: ABdhPJyuiKTIj9KCL7tOayUd9SRhKG7iUS646HUcsrHS8UysZOxdLmAa5lBHnbVcKVP7kE7qKCBauaO2H84VERiU8q4= X-Received: by 2002:a9d:429:: with SMTP id 38mr1482226otc.88.1599839040717; Fri, 11 Sep 2020 08:44:00 -0700 (PDT) MIME-Version: 1.0 References: <20200901115913.Bluez.v2.1.Ieeae14ab680eda03474551fdb7a0a020f950e9c1@changeid> In-Reply-To: <20200901115913.Bluez.v2.1.Ieeae14ab680eda03474551fdb7a0a020f950e9c1@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 11 Sep 2020 08:43:50 -0700 Message-ID: <CABBYNZLsYsV51nFLFp0pfkMm-oLtNAw1_eXAdx2dxOeQgMA5eg@mail.gmail.com> Subject: Re: [Bluez PATCH v2] audio/transport: Don't set volume if it's invalid To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.57 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6F3C3A0AF0 X-Rspamd-UID: 6dba00 Hi Archie, On Mon, Aug 31, 2020 at 9:00 PM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > Adding a check inside media_transport_update_volume to prevent > the volume being updated with an invalid value. > --- > > Changes in v2: > * Move the check from media.c:set_configuration > > profiles/audio/transport.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c > index a2c4f7dfb..dd1c553a2 100644 > --- a/profiles/audio/transport.c > +++ b/profiles/audio/transport.c > @@ -941,6 +941,9 @@ void media_transport_update_volume(struct media_transport *transport, > { > struct a2dp_transport *a2dp = transport->data; > > + if (volume < 0) > + return; > + > /* Check if volume really changed */ > if (a2dp->volume == volume) > return; > -- > 2.28.0.402.g5ffc5be6b7-goog > Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YCNjN1ycW19q1QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 17:48:44 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id mItwNFycW1+RRAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 17:48:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 57B1C40675; Fri, 11 Sep 2020 17:48:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726551AbgIKPsX (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 11:48:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbgIKPnj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 11:43:39 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68D40C061756 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 08:43:39 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id g10so8685087otq.9 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 08:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XzDgWNnuKrqNaQUU+av4P/MQZuzcjuXvW2alEkzqcAM=; b=OfFDLjYVZq93cM8+BpkOhGQw1cPxXC81jWiU+/nucVDw3SCbOdqHuD/FLIDqL58ajM +SApiaXhKPmTlQjjZKNU3IaEjj3UxdXrhN4mDUlYiilGfFMWlIVfePin7V6fxtnALZSr EEgZKNLMEmFKHI4q9UtG9hyzNGMnUHF3Kpeo41PrPV5hbXc9sXdSm8iHMFFbMxVbXgdk KMNWNZiqHyVMjFO8lZQGeai5LyD5qjzLeGRQQE+P1HK3CH197mG38ZBzi8CUUxs0O62o V3zfmKZMmpONTiZPZPDwVNjK5VSw23ghalE0KwwG2nMJp2gXFv19KZXPvsh8pj5zarHM /lKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XzDgWNnuKrqNaQUU+av4P/MQZuzcjuXvW2alEkzqcAM=; b=fJVfcgBtOXjBw2o8OVhmf/dY0wFGKXkacbU/v2n3gdtWqVhnk6I5spAhJN5um82r78 FtcVehsxpDgKrPVvlpLpSNm0Zl0cCTzumrm5PznWDxMBt3RF+/oko8enogGofOFJJ+/8 h4ZEaUSXvY//PLuTOg4NSXFT1HgQL1GshEBEyyo0FVfZd0FL/E6toXTpRRb9QNN8UgmJ WrKqGWJoJYlfsWMOz+BPLpDRv/CO5L5xKLW954et1ZjTgZ2/Rbmxnbo7Og8SXMmPNW4u q25EyyTdaBq/5MQ2oE2DXRj6YxLQnj8usITx0bPvTflG9TywuHmuhg/VvTVkPuQyK4II RiOQ== X-Gm-Message-State: AOAM530zohdwmjvBYnG+7zQmNUPYHvnS9sU5Hqyc82x9gYSlIhflDWQv rOzNHdQeDV8wZwGNM28+9VVUOzls1B819wW0Bms= X-Google-Smtp-Source: ABdhPJwh6sVu9L6n9x7JEhC/Ei8IrRlZTQuLMXw1B6/hn7VvgDURleyxoc/J0+Zac2Bt0iI/AS2Vh5oVa1MOkNmfITw= X-Received: by 2002:a9d:4695:: with SMTP id z21mr1573352ote.91.1599839018223; Fri, 11 Sep 2020 08:43:38 -0700 (PDT) MIME-Version: 1.0 References: <20200902125726.Bluez.v1.1.I732df55cd70d552fc48e87686fb53c3f8ccbefa5@changeid> In-Reply-To: <20200902125726.Bluez.v1.1.I732df55cd70d552fc48e87686fb53c3f8ccbefa5@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 11 Sep 2020 08:43:27 -0700 Message-ID: <CABBYNZKtMFwYZFwzoO=G54YQJVMyyyJF45eaPM9pM4_5d9j-dA@mail.gmail.com> Subject: Re: [Bluez PATCH v1] avrcp: Add handler for GET_TOTAL_NUMBER_OF_ITEMS To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Yun-Hao Chung <howardchung@google.com>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.69 / 15.00 / 15.00 X-Rspamd-Queue-Id: 57B1C40675 X-Rspamd-UID: 09f7e6 Hi Archie, On Tue, Sep 1, 2020 at 9:57 PM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > According to the AVRCP spec, section 4.5, GetTotalNumberOfItems PDU > is mandatory for TG supporting category 1 or 3. > > Reviewed-by: Yun-Hao Chung <howardchung@google.com> > Reviewed-by: Michael Sun <michaelfsun@google.com> > --- > > profiles/audio/avrcp.c | 58 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 58 insertions(+) > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > index 5d0256c52..6da73394f 100644 > --- a/profiles/audio/avrcp.c > +++ b/profiles/audio/avrcp.c > @@ -79,6 +79,7 @@ > #define AVRCP_STATUS_SUCCESS 0x04 > #define AVRCP_STATUS_UID_CHANGED 0x05 > #define AVRCP_STATUS_DOES_NOT_EXIST 0x09 > +#define AVRCP_STATUS_INVALID_SCOPE 0x0a > #define AVRCP_STATUS_OUT_OF_BOUNDS 0x0b > #define AVRCP_STATUS_INVALID_PLAYER_ID 0x11 > #define AVRCP_STATUS_PLAYER_NOT_BROWSABLE 0x12 > @@ -211,6 +212,12 @@ struct player_item { > char name[0]; > } __attribute__ ((packed)); > > +struct get_total_number_of_items_rsp { > + uint8_t status; > + uint16_t uid_counter; > + uint32_t num_items; > +} __attribute__ ((packed)); > + > struct avrcp_server { > struct btd_adapter *adapter; > uint32_t tg_record_id; > @@ -566,6 +573,9 @@ static void populate_default_features(void) > > /* supports at least AVRCP 1.4 */ > default_features[7] |= (1 << 2); > + > + /* supports GetTotalNumberOfItems browsing command */ > + default_features[8] |= (1 << 3); > } > > static unsigned int attr_get_max_val(uint8_t attr) > @@ -2048,10 +2058,56 @@ static void avrcp_handle_get_folder_items(struct avrcp *session, > case AVRCP_SCOPE_SEARCH: > case AVRCP_SCOPE_NOW_PLAYING: > default: > + status = AVRCP_STATUS_INVALID_SCOPE; > + goto failed; > + } > + > + return; > + > +failed: > + pdu->params[0] = status; > + pdu->param_len = htons(1); > +} > + > +static void avrcp_handle_media_player_list_num_items(struct avrcp *session, > + struct avrcp_browsing_header *pdu) > +{ > + struct avrcp_player *player = target_get_player(session); > + struct get_total_number_of_items_rsp *rsp; > + > + rsp = (void *)pdu->params; > + rsp->status = AVRCP_STATUS_SUCCESS; > + rsp->uid_counter = htons(player_get_uid_counter(player)); > + rsp->num_items = htonl(g_slist_length(session->server->players)); > + pdu->param_len = htons(sizeof(*rsp)); > +} > + > +static void avrcp_handle_get_total_number_of_items(struct avrcp *session, > + struct avrcp_browsing_header *pdu, > + uint8_t transaction) > +{ > + uint8_t scope; > + uint8_t status = AVRCP_STATUS_SUCCESS; > + > + if (ntohs(pdu->param_len) != 1) { > status = AVRCP_STATUS_INVALID_PARAM; > goto failed; > } > > + scope = pdu->params[0]; > + > + switch (scope) { > + case AVRCP_SCOPE_MEDIA_PLAYER_LIST: > + avrcp_handle_media_player_list_num_items(session, pdu); > + break; > + case AVRCP_SCOPE_MEDIA_PLAYER_VFS: > + case AVRCP_SCOPE_SEARCH: > + case AVRCP_SCOPE_NOW_PLAYING: > + default: > + status = AVRCP_STATUS_INVALID_SCOPE; > + goto failed; > + } > + > return; > > failed: > @@ -2065,6 +2121,8 @@ static struct browsing_pdu_handler { > uint8_t transaction); > } browsing_handlers[] = { > { AVRCP_GET_FOLDER_ITEMS, avrcp_handle_get_folder_items }, > + { AVRCP_GET_TOTAL_NUMBER_OF_ITEMS, > + avrcp_handle_get_total_number_of_items }, > { }, > }; > > -- > 2.28.0.402.g5ffc5be6b7-goog > Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oEV5FBKuW1+ULQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 19:04:18 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id uF22EBKuW19icwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 19:04:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D541DA0B1B; Fri, 11 Sep 2020 19:04:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726296AbgIKRD5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 13:03:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbgIKRD1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 13:03:27 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 052A2C061757 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 10:03:26 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id n14so7835205pff.6 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 10:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:from:to:cc:subject:date:mime-version :content-transfer-encoding; bh=qRtDh97ORt4HovJLKdTF3WD92y4b2IDBRblpYLEE9bs=; b=dJVxsJcX8QwG1cCd9nM0kqLVfSwuDe4APIAa8BtNHYsyMYxCBw/p1N7EcZeTKxdpe7 cS4veSRiTv6M4LDyxP7mtZ6iQo0YvYef4Kdh/7oPYjo+cKFv0BsACj+S7oXqn69EISpt 8NQxsdKS26ru+HxYdjZyNsxGvxZgnuK4jl1Jg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:date:mime-version :content-transfer-encoding; bh=qRtDh97ORt4HovJLKdTF3WD92y4b2IDBRblpYLEE9bs=; b=Vl+NcX74+X9/rwMGPmOEGEugnnialN7QTlugpszEGZR5b547jqFYZbJl8zfs0KBqYZ 9FeA+RtmSyG2eEnNStPUiXhsvzvG/QygySmxl9XYOJKPRZyil5IAEE+DmH81SNRVH2Ju S3gcFTK/d1MD4BzMW+f7PWrf2PwBuj+PGLlknz8AO5WNoo+Pep/9wKELlA9RkBZxf0Zk /Dy+zqjEkQVZUtiDm8ow40tGGgdr8faBUukZE9/2MSj/62l56aeKGlvbmLekICWCvIzq M0PfljfOONoGX6VaflG+zR+PYPSy+sT/esY0sIKhmKsQ2zzOWHJW1GH4bL3Px8SJTDh3 7+1A== X-Gm-Message-State: AOAM530DYIynr6vxcloEoaksdY7HKRbeKi62aK+WmCyT2rrBUXwg8DgW KVJ+7/diK3qq2szge0+DJkhnPg== X-Google-Smtp-Source: ABdhPJw7sDOAisikq+F/mVJQrRg8pbzocfSBl45sp+09hdh3wWhJ9hDo4+UdBQZMAetb42PEHKjHIw== X-Received: by 2002:a63:f1d:: with SMTP id e29mr2319480pgl.358.1599843805452; Fri, 11 Sep 2020 10:03:25 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id q16sm3103738pfj.117.2020.09.11.10.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 10:03:24 -0700 (PDT) Message-ID: <5f5baddc.1c69fb81.8c960.760a@mx.google.com> X-Google-Original-Message-ID: <20200911100258.RESEND Bluez.v2.1.I9181af521cf0fba8f4315c9b89975848d437d6dd@changeid> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [RESEND Bluez PATCH v2] doc: Add Suspend and Resume events Date: Fri, 11 Sep 2020 10:03:17 -0700 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.14 / 15.00 / 15.00 X-Rspamd-Queue-Id: D541DA0B1B X-Rspamd-UID: 65c2ba Add Controller Suspend Event and Controller Resume Event to identify suspend or resume of the Bluetooth stack has occurred. Also update Device Disconnected Event to indicate a new disconnect reason: "Connection terminated by local host for suspend" Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Re-sending along with kernel changes. Changes in v2: - Moved Wake_Reason to first value - Reduced Wake_Reason to not Bluetooth, unexpected event and remote wake doc/mgmt-api.txt | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index ca0d38469..e7a713824 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -3834,6 +3834,7 @@ Device Disconnected Event 2 Connection terminated by local host 3 Connection terminated by remote host 4 Connection terminated due to authentication failure + 5 Connection terminated by local host for suspend Note that the local/remote distinction just determines which side terminated the low-level connection, regardless of the @@ -4577,3 +4578,50 @@ Advertisement Monitor Removed Event The event will only be sent to management sockets other than the one through which the command was sent. + + +Controller Suspend Event +======================== + + Event code: 0x002d + Controller Index: <controller_id> + Event Parameters: Suspend_State (1 octet) + + This event indicates that the controller is suspended for host suspend. + + Possible values for the Suspend_State parameter: + 0 Running (not disconnected) + 1 Disconnected and not scanning + 2 Page scanning and/or passive scanning. + + The value 0 is used for the running state and may be sent if the + controller could not be configured to suspend properly. + + This event will be sent to all management sockets. + + +Controller Resume Event +======================= + + Event code: 0x002e + Controller Index: <controller_id> + Event Parameters: Wake_Reason (1 octet) + Address (6 octets) + Address_Type (1 octet) + + This event indicates that the controller has resumed from suspend. + + Possible values for the Wake_Reason parameter: + 0 Resume from non-Bluetooth wake source + 1 Wake due to unexpected event + 2 Remote wake due to peer device connection + + Currently, we expect that only peer reconnections should wake us from + the suspended state. Any other events that occurred while the system + should have been suspended results in wake due to unexpected event. + + If the Wake_Reason is Remote wake due to connection, the address of the + peer device that caused the event will be shared in Address and + Address_Type. Otherwise, Address and Address_Type will both be zero. + + This event will be sent to all management sockets. -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UA93BsSwW19dUQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 19:15:48 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id GLT5AsSwW1+ZKQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 19:15:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 463E1A0B0F; Fri, 11 Sep 2020 19:15:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726228AbgIKRPF (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 13:15:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725710AbgIKRNT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 13:13:19 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE6CCC06179A for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 10:13:13 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id b17so2003605pji.1 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 10:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=14bPozYieqfHUM2JtvGo8R2UBkHMLrvThIi182GvG+I=; b=bZvtE3QrEvm8CZ8XtYT0Y3OLqPKCw+nNi8kIGhMnpxuYkmxoyoqIipKuS9Eb/YR4H6 8/qdKimJJ9GnwRRgF0C64ME4K3+1hGiLEqHCg5uqkP0vF8bbt2r9VBiSKZejlhIgJfT0 /fQ7Wqe0XuM/zM1zWhY8w3Ju63GauXLQn34Vg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=14bPozYieqfHUM2JtvGo8R2UBkHMLrvThIi182GvG+I=; b=NYbUIj4YZQRbD/D+F4inqcMwfF4fKgPeuzrUTYvJKNi2zU9d4XDocm0371ZCNMskX0 Of/5dxEghk9vT8VKbMWXSacOBDWNHVpxVQN57EesiQlRTrUIBOqWze7lXhi7ABhKkBgC MdeY2g+ep/qJy7lKm8Xdw381yoiKPyOlqeuG547xtIpJnAjEjdAggYUwxsHXQFhYr16+ SgIGujA5cW4Cy9X7Gj7hhlOYxh5uyaajjI9iJkn5MkrZKTfnFIC1sqQSp+tbHNBYDkwl b42nNTjrfn33qzBbO23wLtd4vtw1V5pgfod0PbVERnwHwYqt6+QDF/OyeG0USRP8EWg/ zXVg== X-Gm-Message-State: AOAM532D91NtFMm+x1ojEX4ZaD1RhU0dg8LBgrOnZWVbrNFAY84VK09n SudRzW7Pv8x8ME55Y2To9hpmew== X-Google-Smtp-Source: ABdhPJzrVoLvmYUJt7gXWG+GlxjSZFaqJNgeBictKPSlRR5p3H8wccaZE1GGSiHdeFUEqMvnqkhAuA== X-Received: by 2002:a17:90a:4803:: with SMTP id a3mr3088770pjh.192.1599844393419; Fri, 11 Sep 2020 10:13:13 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id h9sm2787452pfc.28.2020.09.11.10.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 10:13:12 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [RESEND PATCH 2/3] Bluetooth: Add suspend reason for device disconnect Date: Fri, 11 Sep 2020 10:13:05 -0700 Message-Id: <20200911101255.RESEND.2.Ib9bb75b65362d32104df86ffad479761680bb2cb@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911171306.3758642-1-abhishekpandit@chromium.org> References: <20200911171306.3758642-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.22 / 15.00 / 15.00 X-Rspamd-Queue-Id: 463E1A0B0F X-Rspamd-UID: 8cac79 Update device disconnect event with reason 0x5 to indicate that device disconnected because the controller is suspending. Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- include/net/bluetooth/mgmt.h | 1 + net/bluetooth/mgmt.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index e19e33c7b65c34..a4b8935e0db97a 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -842,6 +842,7 @@ struct mgmt_ev_device_connected { #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 #define MGMT_DEV_DISCONN_REMOTE 0x03 #define MGMT_DEV_DISCONN_AUTH_FAILURE 0x04 +#define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND 0x05 #define MGMT_EV_DEVICE_DISCONNECTED 0x000C struct mgmt_ev_device_disconnected { diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 1475a47edb080b..e33f45e20ed1e7 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -8268,6 +8268,10 @@ void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, ev.addr.type = link_to_bdaddr(link_type, addr_type); ev.reason = reason; + /* Report disconnects due to suspend */ + if (hdev->suspended) + ev.reason = MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND; + mgmt_event(MGMT_EV_DEVICE_DISCONNECTED, hdev, &ev, sizeof(ev), sk); if (sk) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uJnINdWwW193FgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 19:16:05 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 4IFSMtWwW1+ORAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 19:16:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 663E1A0B18; Fri, 11 Sep 2020 19:16:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725992AbgIKRPD (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 13:15:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726306AbgIKRNV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 13:13:21 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3802EC0617A0 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 10:13:15 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id t14so7074160pgl.10 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 10:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QYynaXim+pXR2WZF/f2L4YViEpHTsA0HAsGlrH1psqM=; b=IHfcMdCaVdMs1n8Gen4SO+2cTFU54AFAZFQqYjyF3NAbYLvmQ/tifJu5KM5kfnBfrD z1PIZNhLjkvC2mCjZY0Y6PXkYKOuuf9mluNkaNGg3orOqxMDvcoIt6dWcd0CzWmMUE1U En8AqvF6KuoC5ZpvxEOxzw3uDraGR8IYBdBF4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QYynaXim+pXR2WZF/f2L4YViEpHTsA0HAsGlrH1psqM=; b=hKhM/P1u0dgQ3MRBW1rVw7f+vo7foYfanHCA3up2rwgbpuhpTKgYAqrMZmUzlrCJkz uJ4Pu9zHkoSSs9fsL7eImUEGbNSIOyvWgN3joKgCj2Z8NYGfUzdfnOnR4THv5K3xdsi6 ba1Qrfsqqgr+cyn1zWoG0E1uvim0by0PP/Fj3z0mccUTIAbUIvo8s3m311c8ADG0LgMZ nqR1XAM6h+0QVYFiqwfI1gn6zsrXG4lSTNXk4mRyGZAIbkdEC9JB4p/ItNU57T76yS8y L5iEgunLuITCj6e5Zm4iV4g3l2KTjbCk4jutdJOIgoqjho8XSzwtSty4/tYz9ZB6LwLf Kkww== X-Gm-Message-State: AOAM533H1sNeMFfwnNvfBmV67WFIKDqm4zqc9Ux6oqWSw0Ey0jx7RwRg 3PCg3vssKSzhufsh+gjjOfcTVA== X-Google-Smtp-Source: ABdhPJyvFx2DkSx0RCcM/Z9U/Nqid1O7rjskD5qFsSGh0XhkaBezmgGuXBk0csBuB+LMBL2CRJSaJQ== X-Received: by 2002:a63:7018:: with SMTP id l24mr2249682pgc.55.1599844394630; Fri, 11 Sep 2020 10:13:14 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id h9sm2787452pfc.28.2020.09.11.10.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 10:13:14 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [RESEND PATCH 3/3] Bluetooth: Emit controller suspend and resume events Date: Fri, 11 Sep 2020 10:13:06 -0700 Message-Id: <20200911101255.RESEND.3.I905caec7d7bf0eb7a3ed9899b5afb9aebaf6f8a8@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911171306.3758642-1-abhishekpandit@chromium.org> References: <20200911171306.3758642-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.22 / 15.00 / 15.00 X-Rspamd-Queue-Id: 663E1A0B18 X-Rspamd-UID: 3f972a Emit controller suspend and resume events when we are ready for suspend and we've resumed from suspend. The controller suspend event will report whatever suspend state was successfully entered. The controller resume event will check the first HCI event that was received after we finished preparing for suspend and, if it was a connection event, store the address of the peer that caused the event. If it was not a connection event, we mark the wake reason as an unexpected event. Here is a sample btmon trace with these events: @ MGMT Event: Controller Suspended (0x002d) plen 1 Suspend state: Page scanning and/or passive scanning (2) @ MGMT Event: Controller Resumed (0x002e) plen 8 Wake reason: Remote wake due to peer device connection (2) LE Address: CD:F3:CD:13:C5:9A (OUI CD-F3-CD) Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- include/net/bluetooth/hci_core.h | 3 ++ include/net/bluetooth/mgmt.h | 4 ++ net/bluetooth/hci_core.c | 26 +++++++++++- net/bluetooth/hci_event.c | 73 ++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 02a6ee056b2374..9873e1c8cd163b 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -484,6 +484,9 @@ struct hci_dev { enum suspended_state suspend_state; bool scanning_paused; bool suspended; + u8 wake_reason; + bdaddr_t wake_addr; + u8 wake_addr_type; wait_queue_head_t suspend_wait_q; DECLARE_BITMAP(suspend_tasks, __SUSPEND_NUM_TASKS); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index a4b8935e0db97a..6b55155e05e977 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -1042,3 +1042,7 @@ struct mgmt_ev_controller_resume { __u8 wake_reason; struct mgmt_addr_info addr; } __packed; + +#define MGMT_WAKE_REASON_NON_BT_WAKE 0x0 +#define MGMT_WAKE_REASON_UNEXPECTED 0x1 +#define MGMT_WAKE_REASON_REMOTE_WAKE 0x2 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index ef32b12f150cd1..8a2645a8330137 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3497,12 +3497,24 @@ static int hci_change_suspend_state(struct hci_dev *hdev, return hci_suspend_wait_event(hdev); } +static void hci_clear_wake_reason(struct hci_dev *hdev) +{ + hci_dev_lock(hdev); + + hdev->wake_reason = 0; + bacpy(&hdev->wake_addr, BDADDR_ANY); + hdev->wake_addr_type = 0; + + hci_dev_unlock(hdev); +} + static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action, void *data) { struct hci_dev *hdev = container_of(nb, struct hci_dev, suspend_notifier); int ret = 0; + u8 state = BT_RUNNING; /* If powering down, wait for completion. */ if (mgmt_powering_down(hdev)) { @@ -3523,15 +3535,27 @@ static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action, * - Second, program event filter/whitelist and enable scan */ ret = hci_change_suspend_state(hdev, BT_SUSPEND_DISCONNECT); + if (!ret) + state = BT_SUSPEND_DISCONNECT; /* Only configure whitelist if disconnect succeeded and wake * isn't being prevented. */ - if (!ret && !(hdev->prevent_wake && hdev->prevent_wake(hdev))) + if (!ret && !(hdev->prevent_wake && hdev->prevent_wake(hdev))) { ret = hci_change_suspend_state(hdev, BT_SUSPEND_CONFIGURE_WAKE); + if (!ret) + state = BT_SUSPEND_CONFIGURE_WAKE; + } + + hci_clear_wake_reason(hdev); + mgmt_suspending(hdev, state); + } else if (action == PM_POST_SUSPEND) { ret = hci_change_suspend_state(hdev, BT_RUNNING); + + mgmt_resuming(hdev, hdev->wake_reason, &hdev->wake_addr, + hdev->wake_addr_type); } done: diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 33d8458fdd4adc..a68be50097ac35 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -6000,6 +6000,76 @@ static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, return true; } +static void hci_store_wake_reason(struct hci_dev *hdev, u8 event, + struct sk_buff *skb) +{ + struct hci_ev_le_advertising_info *adv; + struct hci_ev_le_direct_adv_info *direct_adv; + struct hci_ev_le_ext_adv_report *ext_adv; + const struct hci_ev_conn_complete *conn_complete = (void *)skb->data; + const struct hci_ev_conn_request *conn_request = (void *)skb->data; + + hci_dev_lock(hdev); + + /* If we are currently suspended and this is the first BT event seen, + * save the wake reason associated with the event. + */ + if (!hdev->suspended || hdev->wake_reason) + goto unlock; + + /* Default to remote wake. Values for wake_reason are documented in the + * Bluez mgmt api docs. + */ + hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; + + /* Once configured for remote wakeup, we should only wake up for + * reconnections. It's useful to see which device is waking us up so + * keep track of the bdaddr of the connection event that woke us up. + */ + if (event == HCI_EV_CONN_REQUEST) { + bacpy(&hdev->wake_addr, &conn_complete->bdaddr); + hdev->wake_addr_type = BDADDR_BREDR; + } else if (event == HCI_EV_CONN_COMPLETE) { + bacpy(&hdev->wake_addr, &conn_request->bdaddr); + hdev->wake_addr_type = BDADDR_BREDR; + } else if (event == HCI_EV_LE_META) { + struct hci_ev_le_meta *le_ev = (void *)skb->data; + u8 subevent = le_ev->subevent; + u8 *ptr = &skb->data[sizeof(*le_ev)]; + u8 num_reports = *ptr; + + if ((subevent == HCI_EV_LE_ADVERTISING_REPORT || + subevent == HCI_EV_LE_DIRECT_ADV_REPORT || + subevent == HCI_EV_LE_EXT_ADV_REPORT) && + num_reports) { + adv = (void *)(ptr + 1); + direct_adv = (void *)(ptr + 1); + ext_adv = (void *)(ptr + 1); + + switch (subevent) { + case HCI_EV_LE_ADVERTISING_REPORT: + bacpy(&hdev->wake_addr, &adv->bdaddr); + hdev->wake_addr_type = adv->bdaddr_type; + break; + + case HCI_EV_LE_DIRECT_ADV_REPORT: + bacpy(&hdev->wake_addr, &direct_adv->bdaddr); + hdev->wake_addr_type = direct_adv->bdaddr_type; + break; + case HCI_EV_LE_EXT_ADV_REPORT: + bacpy(&hdev->wake_addr, &ext_adv->bdaddr); + hdev->wake_addr_type = ext_adv->bdaddr_type; + break; + } + } + } else { + hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; + } + +unlock: + hci_dev_unlock(hdev); +} + void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_event_hdr *hdr = (void *) skb->data; @@ -6033,6 +6103,9 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) skb_pull(skb, HCI_EVENT_HDR_SIZE); + /* Store wake reason if we're suspended */ + hci_store_wake_reason(hdev, event, skb); + switch (event) { case HCI_EV_INQUIRY_COMPLETE: hci_inquiry_complete_evt(hdev, skb); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ELw1NQexW1+ULQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 19:16:55 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id gCbMMgexW19UwAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 19:16:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 87FE040876; Fri, 11 Sep 2020 19:16:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725786AbgIKRQW (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 13:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726296AbgIKRNR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 13:13:17 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B62A1C061798 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 10:13:12 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id f2so5070721pgd.3 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 10:13:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mbot9ybxN7CEBjkJx2/zfixlDiQJfoliZ9FJfemsvkc=; b=dkngZxcJsfiwaoaeeA5ivGItvOj+ltwumQrEg2V2Fb6waCKmwZnjPEH4f4GucgxVLB 5dw95RVIXR7dHD+f1E9ucpz2A3/rbkTFTnco1FwjNge2jtemQnNxvrRRKr+KfkzRDqJQ +oLDdyDVAapClSi2quq12dscrXXbs1KAohowQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mbot9ybxN7CEBjkJx2/zfixlDiQJfoliZ9FJfemsvkc=; b=WmNaBEN22Li/Ww0aqALonc3/tBWS29fPWRjT7AI4NAou82BB8tnOTHWRNIkbLbK0Qj oscxPPbGNNsv5ldg/nG7FkOAJBjDzKEtkiZ2YmNR5HDxpvhxIsvntzlHNVo/DDZMTQ5s QgM46WnhhtJ5OiYAkasfHu+Dkl9O1N+LuNhh2fCe6RuFoCZgKAsp2PtPxYrHbmGelhNL ixsAOAj9GdsCl4DZ/C1/2aAbaJ2tYv996wClesRYcW59Ty7InlCuOqwR+Gz4+lr7AuuA y+Vxhjy/LpHk72AWWdfVMUuKB8hzisWNiUFYalpOoI6TfY5J0BZMxmUQKJr6J15IypZX DaGg== X-Gm-Message-State: AOAM5325nj0hG7G1zGA9fIVqqsEtTS3YhbJZcSIawthFBuvuXOCjZazM 01HsnPusRi8IpPxlVNuYBOvZJg== X-Google-Smtp-Source: ABdhPJxZSSZY4mIQBJ0os+Tl+NKbSD61XqIC+eZsymowPVyQeWCMOMXGMvOnS58X3crxD9bFA3MAlw== X-Received: by 2002:a63:b20d:: with SMTP id x13mr385059pge.136.1599844392256; Fri, 11 Sep 2020 10:13:12 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id h9sm2787452pfc.28.2020.09.11.10.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 10:13:11 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [RESEND PATCH 1/3] Bluetooth: Add mgmt suspend and resume events Date: Fri, 11 Sep 2020 10:13:04 -0700 Message-Id: <20200911101255.RESEND.1.I1b721ef9da5c79d8515018d806801da4eacaf563@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911171306.3758642-1-abhishekpandit@chromium.org> References: <20200911171306.3758642-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.22 / 15.00 / 15.00 X-Rspamd-Queue-Id: 87FE040876 X-Rspamd-UID: b4d435 Add the controller suspend and resume events, which will signal when Bluetooth has completed preparing for suspend and when it's ready for resume. Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- include/net/bluetooth/hci_core.h | 3 +++ include/net/bluetooth/mgmt.h | 11 +++++++++++ net/bluetooth/mgmt.c | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 8caac20556b499..02a6ee056b2374 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1750,6 +1750,9 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, s8 rssi, u8 *name, u8 name_len); void mgmt_discovering(struct hci_dev *hdev, u8 discovering); +void mgmt_suspending(struct hci_dev *hdev, u8 state); +void mgmt_resuming(struct hci_dev *hdev, u8 reason, bdaddr_t *bdaddr, + u8 addr_type); bool mgmt_powering_down(struct hci_dev *hdev); void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent); void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk, bool persistent); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 9ad505b9e694e4..e19e33c7b65c34 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -1030,3 +1030,14 @@ struct mgmt_ev_adv_monitor_added { struct mgmt_ev_adv_monitor_removed { __le16 monitor_handle; } __packed; + +#define MGMT_EV_CONTROLLER_SUSPEND 0x002d +struct mgmt_ev_controller_suspend { + __u8 suspend_state; +} __packed; + +#define MGMT_EV_CONTROLLER_RESUME 0x002e +struct mgmt_ev_controller_resume { + __u8 wake_reason; + struct mgmt_addr_info addr; +} __packed; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index e1d12494d16e14..1475a47edb080b 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -8874,6 +8874,30 @@ void mgmt_discovering(struct hci_dev *hdev, u8 discovering) mgmt_event(MGMT_EV_DISCOVERING, hdev, &ev, sizeof(ev), NULL); } +void mgmt_suspending(struct hci_dev *hdev, u8 state) +{ + struct mgmt_ev_controller_suspend ev; + + ev.suspend_state = state; + mgmt_event(MGMT_EV_CONTROLLER_SUSPEND, hdev, &ev, sizeof(ev), NULL); +} + +void mgmt_resuming(struct hci_dev *hdev, u8 reason, bdaddr_t *bdaddr, + u8 addr_type) +{ + struct mgmt_ev_controller_resume ev; + + ev.wake_reason = reason; + if (bdaddr) { + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = addr_type; + } else { + memset(&ev.addr, 0, sizeof(ev.addr)); + } + + mgmt_event(MGMT_EV_CONTROLLER_RESUME, hdev, &ev, sizeof(ev), NULL); +} + static struct hci_mgmt_chan chan = { .channel = HCI_CHANNEL_CONTROL, .handler_count = ARRAY_SIZE(mgmt_handlers), -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KGDTK1CxW193FgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 19:18:08 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id sIr2KFCxW19LXQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 19:18:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C62FB408B3; Fri, 11 Sep 2020 19:18:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726076AbgIKRR5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 13:17:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbgIKRNM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 13:13:12 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EE44C061786 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 10:13:11 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id l191so7092676pgd.5 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 10:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9xx/aNqVyo8F+vwS35kGQGZUtQETH2qUMc7jEIvGGiw=; b=GZDyuoKHjUGYRo0q4YPBblihRY7pVBrudliixlJ7RLgVwDc+Kb5t+Undpb8QD8ma1k LxcEc4G4bBSIQ2egiR316Cnaz8Lb6jVplZhJXxXv4s5AQPe7Bhs1z9tnzvyqBP56gnxi fxVvfLI3EnCu4SpB/ycK4W7PuhQE1S57liyYA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9xx/aNqVyo8F+vwS35kGQGZUtQETH2qUMc7jEIvGGiw=; b=TnCnbk+TFYXnEgpKEp/Lg0hAvl/wh/MMF3ufZnZlZnStibh6CKxh4ofQ5bjjKF8Qmf /q3L3jJFcDXtxCSEQ4ob0pK2BVTBtZv7VpUlHIuxRAYjqEq2Ef7u6dfhs73YA3xCcgID Qqizq2LJ1PHHA5mNiNoJGsBOP5fDTOSQxCxZ6G6O+H2+La1Xt1XrAgrXA7lGBnf/Yvne Xri7PBfthXFwoOCkf8Z9kMpSnKU0ydASNb5cleXC6zcMYnfNcRSTbY3tdm0x7H3AJ9Rz LRuc8FNEpn0nfYoZlTS8anzf71bHsoOG5tjB+M3z5yeo0FlmyPg311hJNARvGQAOibR2 yF5w== X-Gm-Message-State: AOAM530KFyQsQq/4ljFCVxaOAxIs5j7l2j9GoyPITBNHOtliDWIMnafF /GKcBcOFO9iwZGK2MZ+7J9HSBA== X-Google-Smtp-Source: ABdhPJydKYhFb52mw7so7AX3H27Z2tg1yZLck6RxPp1D+3/fVJBJsaDGZl3UZMOdjs43ONG+bWVCPA== X-Received: by 2002:a63:4d5:: with SMTP id 204mr2422300pge.0.1599844391141; Fri, 11 Sep 2020 10:13:11 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id h9sm2787452pfc.28.2020.09.11.10.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 10:13:10 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [RESEND PATCH 0/3] Bluetooth: Emit events for suspend/resume Date: Fri, 11 Sep 2020 10:13:03 -0700 Message-Id: <20200911171306.3758642-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.71 / 15.00 / 15.00 X-Rspamd-Queue-Id: C62FB408B3 X-Rspamd-UID: af4e62 Hi Marcel, This series adds the suspend/resume events suggested in https://patchwork.kernel.org/patch/11771001/. I have tested it with some userspace changes that monitors the controller resumed event to trigger audio device reconnection and verified that the events are correctly emitted. Patch for btmon changes: https://patchwork.kernel.org/patch/11743863/ Please take a look. Abhishek Abhishek Pandit-Subedi (3): Bluetooth: Add mgmt suspend and resume events Bluetooth: Add suspend reason for device disconnect Bluetooth: Emit controller suspend and resume events include/net/bluetooth/hci_core.h | 6 +++ include/net/bluetooth/mgmt.h | 16 +++++++ net/bluetooth/hci_core.c | 26 +++++++++++- net/bluetooth/hci_event.c | 73 ++++++++++++++++++++++++++++++++ net/bluetooth/mgmt.c | 28 ++++++++++++ 5 files changed, 148 insertions(+), 1 deletion(-) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0AggDDXnW1+nbQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 11 Sep 2020 23:08:05 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8EPNCDXnW19WxAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 11 Sep 2020 23:08:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6781C40675; Fri, 11 Sep 2020 23:08:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725852AbgIKVH2 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 17:07:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbgIKVHY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 17:07:24 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E8A2C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 14:07:23 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id z19so8265008pfn.8 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 14:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jgFgQZn5QUo1XXE/gnomBtbR6UbPde/+9+WpoRrQOPw=; b=Q4u5rcfPt7QTOe1vp5gVHput9CRbaDUMGiQLJKMd3JvvKLhJd/6okyvWJ+Y87FeDgD 61cHLgCITFeG4q7KdUqlzC1VCy7kPPEKuphbwB9zz+WvBD2BRCLVH8yCVxTXvYxC7f2J +Koa3GNxLfZaGRyAzkTafgMeDasWx9LGxrE4c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jgFgQZn5QUo1XXE/gnomBtbR6UbPde/+9+WpoRrQOPw=; b=nN0X2bsMJgNea3+IA3UFLl4tSsPmqG/w68VOByg1TP93kqjuSE4bSu6WmoPK3l+WbS SwpaHf3D6TQgCG5iXk1i1td3F4WsKVZdaP6ndcpIEwk4N/FQSDW8NWbg6dWyrmdi/CIh qQ93J74biZodU4qGqhWttkW7CyECFIxSOHv+xbinFwJGRsHoHwRBatJKKz7QkqneYRI6 au4TgJOo3BUkMJakf3s6sDc6dNJirb/zIB7OPjI0Nr6oN0VO4WRk25eYgJY2U+OzVoaB 8K41YA/7Q2YSjeK8PxqqfsaqcHSwvUKigchjdPOtTr7692PK0T1WTsvUnAaAkiLi9Liw 5cbw== X-Gm-Message-State: AOAM532UIcXvOPOx/izqPmYSZce2sIekN1NB4hI0z457KuRXbVyZd/zd 2t1Pa1rz01OUtoUlQL3zAG1Arw== X-Google-Smtp-Source: ABdhPJxRjwcNmLDTUlVLFGgGCsT6fXlVuUlJYNls9NwgRdY9arpE0quJZbmaUT8ai2G7WqhKVwnAHw== X-Received: by 2002:a62:e90b:0:b029:13e:b622:3241 with SMTP id j11-20020a62e90b0000b029013eb6223241mr3834613pfh.12.1599858442536; Fri, 11 Sep 2020 14:07:22 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id c128sm3308764pfb.126.2020.09.11.14.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 14:07:22 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH v2 0/3] Bluetooth: Emit events for suspend/resume Date: Fri, 11 Sep 2020 14:07:10 -0700 Message-Id: <20200911210713.4066465-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.71 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6781C40675 X-Rspamd-UID: b0391f Hi Marcel, This series adds the suspend/resume events suggested in https://patchwork.kernel.org/patch/11771001/. I have tested it with some userspace changes that monitors the controller resumed event to trigger audio device reconnection and verified that the events are correctly emitted. Patch for btmon changes: https://patchwork.kernel.org/patch/11743863/ Please take a look. Abhishek Changes in v2: - Added suspend/resume events to list of mgmt events Abhishek Pandit-Subedi (3): Bluetooth: Add mgmt suspend and resume events Bluetooth: Add suspend reason for device disconnect Bluetooth: Emit controller suspend and resume events include/net/bluetooth/hci_core.h | 6 +++ include/net/bluetooth/mgmt.h | 16 +++++++ net/bluetooth/hci_core.c | 26 +++++++++++- net/bluetooth/hci_event.c | 73 ++++++++++++++++++++++++++++++++ net/bluetooth/mgmt.c | 30 +++++++++++++ 5 files changed, 150 insertions(+), 1 deletion(-) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QJ5RKk37W1/6xwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 00:33:49 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0IfRJk37W18nDAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 00:33:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2D7DCA0185; Sat, 12 Sep 2020 00:33:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725945AbgIKWdb (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 18:33:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbgIKWdY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 18:33:24 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE1D1C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:33:23 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id y1so1245223pgk.8 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 15:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iF8TeyEikj2biNaQshg9KmYrlvScdBVXMRfciSkg73c=; b=Yd9JMHZ4gRDa89ZRRST+nnkKT5nMC4F4WZV+lxJDsSchgQvCyDFn/qTDUiuNjvoM5T f74Q0IKIkVbhjKrrDb/TTVAo5MZmTBHEcSd6xcU+/4CPOZrUR/lYXWa6y3eQHZOXrIU5 WbIcq2/QrYHhNZS8vhNJiOEZR2gTp7eEP/Nko= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iF8TeyEikj2biNaQshg9KmYrlvScdBVXMRfciSkg73c=; b=qQH9wOguzAnrHE9gIFep2IKmVBxNHsq67gfli5kbTXWA85omQZy4c0aFed74kXOmGG n/4G+ZHap6WfD1j5sWOlVjBHUg0HoOIJPXK6Lq6j7fLSpAUvbSnAROmJ0pW3wRKc7N49 Vl0xKxQ0+5q7vv8Edl6o6kz5JPPM3NKTqKnw9JseP7k6ieLjIAEZA+IB6m7feeGgMofO 8k3nQsxjHZZI4w8tXdm2BtFEV/rd2+dEl80ofc3M1q7bTrSxs4vCcNjirHJS/LF4Fety KedalSkMfzEa4bnGt/NmlcHBeS4pbrhF1HPuE7imDlLc114+UN83JOTwGM9ehpBStdxl jbeg== X-Gm-Message-State: AOAM5339b8e/oz+qkFB5Di/w+HzTU842xOlygbxksL85Lwdxm2gbm3Nh zyAsiqw6aLlEO6FFG5NbEQFh5w== X-Google-Smtp-Source: ABdhPJz33TmyqHCPoZmtb9fB7qGdH/76wHh1Tqbf++au1bjlFFSi6FxvuJEn/lmaLEoqiBUxAoCvIA== X-Received: by 2002:a63:3d0e:: with SMTP id k14mr3282477pga.219.1599863603371; Fri, 11 Sep 2020 15:33:23 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id n128sm2546314pga.5.2020.09.11.15.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 15:33:22 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Balakrishna Godavarthi <bgodavar@codeaurora.org>, Manish Mandlik <mmandlik@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Subject: [RESEND PATCH] Bluetooth: Only mark socket zapped after unlocking Date: Fri, 11 Sep 2020 15:33:18 -0700 Message-Id: <20200911153256.RESEND.1.Ic1b9d93cf2d393e3efda4c2977639c095d276311@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.79 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2D7DCA0185 X-Rspamd-UID: 0bc647 Since l2cap_sock_teardown_cb doesn't acquire the channel lock before setting the socket as zapped, it could potentially race with l2cap_sock_release which frees the socket. Thus, wait until the cleanup is complete before marking the socket as zapped. This race was reproduced on a JBL GO speaker after the remote device rejected L2CAP connection due to resource unavailability. Here is a dmesg log with debug logs from a repro of this bug: [ 3465.424086] Bluetooth: hci_core.c:hci_acldata_packet() hci0 len 16 handle 0x0003 flags 0x0002 [ 3465.424090] Bluetooth: hci_conn.c:hci_conn_enter_active_mode() hcon 00000000cfedd07d mode 0 [ 3465.424094] Bluetooth: l2cap_core.c:l2cap_recv_acldata() conn 000000007eae8952 len 16 flags 0x2 [ 3465.424098] Bluetooth: l2cap_core.c:l2cap_recv_frame() len 12, cid 0x0001 [ 3465.424102] Bluetooth: l2cap_core.c:l2cap_raw_recv() conn 000000007eae8952 [ 3465.424175] Bluetooth: l2cap_core.c:l2cap_sig_channel() code 0x03 len 8 id 0x0c [ 3465.424180] Bluetooth: l2cap_core.c:l2cap_connect_create_rsp() dcid 0x0045 scid 0x0000 result 0x02 status 0x00 [ 3465.424189] Bluetooth: l2cap_core.c:l2cap_chan_put() chan 000000006acf9bff orig refcnt 4 [ 3465.424196] Bluetooth: l2cap_core.c:l2cap_chan_del() chan 000000006acf9bff, conn 000000007eae8952, err 111, state BT_CONNECT [ 3465.424203] Bluetooth: l2cap_sock.c:l2cap_sock_teardown_cb() chan 000000006acf9bff state BT_CONNECT [ 3465.424221] Bluetooth: l2cap_core.c:l2cap_chan_put() chan 000000006acf9bff orig refcnt 3 [ 3465.424226] Bluetooth: hci_core.h:hci_conn_drop() hcon 00000000cfedd07d orig refcnt 6 [ 3465.424234] BUG: spinlock bad magic on CPU#2, kworker/u17:0/159 [ 3465.425626] Bluetooth: hci_sock.c:hci_sock_sendmsg() sock 000000002bb0cb64 sk 00000000a7964053 [ 3465.430330] lock: 0xffffff804410aac0, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0 [ 3465.430332] Causing a watchdog bite! Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reported-by: Balakrishna Godavarthi <bgodavar@codeaurora.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- We had some more data available (outside of dmesg and oops) that led us to suspect a race between l2cap_sock_teardown_cb and l2cap_sock_release. I've left this out of the commit message since it's not an oops or dmesg logs. Crash stack from CPU4: -- -24 |spin_bug( | [X19] lock = 0xFFFFFF810BDB1EC0, | [X20] msg = 0xFFFFFFD143FD7960) -25 |debug_spin_lock_before(inline) | [X19] lock = 0xFFFFFF810BDB1EC0 -25 |do_raw_spin_lock( | [X19] lock = 0xFFFFFF810BDB1EC0) -26 |raw_spin_lock_irqsave( | [X19] lock = 0xFFFFFF810BDB1EC0) -27 |skb_peek(inline) -27 |__skb_dequeue(inline) -27 |skb_dequeue( | [X20] list = 0xFFFFFF810BDB1EA8) | [locdesc] flags = 12297829382473034410 -28 |skb_queue_purge( | [X19] list = 0xFFFFFF810BDB1EA8 -> ( | [D:0xFFFFFF810BDB1EA8] next = 0x0, | [D:0xFFFFFF810BDB1EB0] prev = 0x0, | [D:0xFFFFFF810BDB1EB8] qlen = 0, | [D:0xFFFFFF810BDB1EC0] lock = ([D:0xFFFFFF810BDB1EC0] rlock = ([D:0xFFFFFF810BDB1EC0] raw_lock | [X0] skb = ??? -29 |l2cap_seq_list_free(inline) | [locdesc] seq_list = 0xFFFFFF810BDB1ED8 -> ( | [D:0xFFFFFF810BDB1ED8] head = 0, | [D:0xFFFFFF810BDB1EDA] tail = 0, | [D:0xFFFFFF810BDB1EDC] mask = 0, | [D:0xFFFFFF810BDB1EE0] list = 0x0) -29 |l2cap_chan_del( | [X19] chan = 0xFFFFFF810BDB1C00, | ?) -30 |l2cap_chan_unlock(inline) -30 |l2cap_connect_create_rsp(inline) | [X20] conn = 0xFFFFFF81231F2600 | [locdesc] err = 0 | [X27] chan = 0xFFFFFF810BDB1C00 -30 |l2cap_bredr_sig_cmd(inline) | [X20] conn = 0xFFFFFF81231F2600 | [locdesc] err = 0 -30 |l2cap_sig_channel(inline) | [X20] conn = 0xFFFFFF81231F2600 | [X19] skb = 0xFFFFFF813DE4C040 | [X28] data = 0xFFFFFF8131582014 | [locdesc] cmd_len = 43690 -30 |l2cap_recv_frame( | [X20] conn = 0xFFFFFF81231F2600, | [X19] skb = 0xFFFFFF813DE4C040) | [locdesc] psm = 43690 -31 |l2cap_recv_acldata( | ?, | [X19] skb = 0xFFFFFF813DE4C040, | ?) | [X21] len = 16 -32 |hci_rx_work( | ?) | [X21] hdev = 0xFFFFFF8133A02000 -33 |__read_once_size(inline) | [locdesc] size = 4 -33 |atomic_read(inline) | [locdesc] __u = ([locdesc] __val = -1431655766, [locdesc] __c = (170)) -33 |static_key_count(inline) -33 |static_key_false(inline) -33 |trace_workqueue_execute_end(inline) | [X22] work = 0xFFFFFF8133A02838 -33 |process_one_work( | [X19] worker = 0xFFFFFF8133FE4500, | [X22] work = 0xFFFFFF8133A02838) | [locdesc] work_color = -1431655766 -34 |__read_once_size(inline) | [locdesc] size = 8 -34 |list_empty(inline) | [locdesc] __u = ([locdesc] __val = 0xAAAAAAAAAAAAAAAA, [locdesc] __c = (170)) -34 |worker_thread( | [X19] __worker = 0xFFFFFF8133FE4500) | [X19] worker = 0xFFFFFF8133FE4500 -35 |kthread( | [X20] _create = 0xFFFFFF8133FB3A00) | [X20] create = 0xFFFFFF8133FB3A00 | [X0] ret = ??? -36 |ret_from_fork(asm) net/bluetooth/l2cap_sock.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index e1a3e66b175402..e7cfe28140c39b 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1521,8 +1521,6 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err) parent = bt_sk(sk)->parent; - sock_set_flag(sk, SOCK_ZAPPED); - switch (chan->state) { case BT_OPEN: case BT_BOUND: @@ -1549,8 +1547,11 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err) break; } - release_sock(sk); + + /* Only zap after cleanup to avoid use after free race */ + sock_set_flag(sk, SOCK_ZAPPED); + } static void l2cap_sock_state_change_cb(struct l2cap_chan *chan, int state, -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cK9FEwNwXF/J7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:51:47 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QEgrEANwXF++4AAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:51:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 32E4EA0B1D; Sat, 12 Sep 2020 08:51:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725837AbgILGve (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:51:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbgILGv1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:51:27 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39A20C061757 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:51:26 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id j10so6351532qvk.11 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=jEo9swi/0dqO3HOSpVsqcg0CYWt3m3OF8SnW99CIgko=; b=RTO6O/MBEYoZDP7CHBMbWHozhmDi8rcBv2N9TBPTraHS1C9WipS5IoBINjw9Yndjy3 LNHSQk5tYEkBc6jsKmzyRYOxYzDxmMgjW/TiuiW1gwv4YVbVecEo8F4fR8LtnzQ6UdYV ySF5+7iQkaML6q8+nhwU4fowIENzE29gkO56i9XGwki6fbNUt1+kIVtoNN6GE9y4R4TO sspm0rhE89ogVQt4/0RZpCi1q0WDgh9ecmPdUOnSu+51cWxEC3iukAJax/9R5YjR1Sxh JPTOClcdT/g4irlqiqSX7v43LUp+HWIFtptMs75ZCGIBATwYdycnuE1eVF25l7HNKsae ax8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=jEo9swi/0dqO3HOSpVsqcg0CYWt3m3OF8SnW99CIgko=; b=pILKIcONaVRbDXx9kdCd77pv+u/jl8IWsa9m1w0/fBG/KBHdv2Mam5wBEuJ8lnLFik LamrMFgA19YMugLtAa/HSpA7rgy50GNyAgNRbkF0eLLQ34+32Cp+kOC/p8Mo82b/GAne i8bTuu8SJLN84EudKKev7EUIyKsXndP/mUsgijNCKh8wiw9serhp37aQdMD0hG4rgJep nyw8/oWBFPvf6Fn/ubrLe81K9r1MPoyktZvt7QpWeQgTovI4Ek1iQ2vmLdCVZf8LTpb5 771CBJBQoVKEc1RfXu03Pn62+t+wtxYtRMp+tycrvKglVuHzUtrtFzr0BFK106u2eEp7 HmtA== X-Gm-Message-State: AOAM533a30xwZ8FuZv4X8GJE3J60jEQtHNSAzuaVCfTaNhw4MYQNcOH2 vqJEAEzCWAxrqIBGJaUXgV+E1krcNMJTOA== X-Google-Smtp-Source: ABdhPJwmSsTyfiBacZ+aQzZCl+AxB+JxbKWgxpcUB1UXeVaXm9JwP4lnR/iocL3l6LnR/GTrr78+yg== X-Received: by 2002:a0c:c304:: with SMTP id f4mr5301062qvi.8.1599893485177; Fri, 11 Sep 2020 23:51:25 -0700 (PDT) Received: from [172.17.0.2] ([40.84.17.224]) by smtp.gmail.com with ESMTPSA id x59sm5891253qte.14.2020.09.11.23.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 23:51:24 -0700 (PDT) Message-ID: <5f5c6fec.1c69fb81.37dac.f57e@mx.google.com> Date: Fri, 11 Sep 2020 23:51:24 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============2710110518128234941==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, tedd.an@linux.intel.com Subject: RE: [BlueZ,05/17] emulator: Add SPDX License Identifier Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200912062357.23926-6-tedd.an@linux.intel.com> References: <20200912062357.23926-6-tedd.an@linux.intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: 32E4EA0B1D X-Rspamd-UID: ad2c4a --===============2710110518128234941== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'emulator/amp.h', please use '/*' instead #54: FILE: emulator/amp.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #54: FILE: emulator/amp.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'emulator/btdev.h', please use '/*' instead #81: FILE: emulator/btdev.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #81: FILE: emulator/btdev.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'emulator/bthost.h', please use '/*' instead #99: FILE: emulator/bthost.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #99: FILE: emulator/bthost.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'emulator/hciemu.h', please use '/*' instead #117: FILE: emulator/hciemu.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #117: FILE: emulator/hciemu.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'emulator/le.h', please use '/*' instead #144: FILE: emulator/le.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #144: FILE: emulator/le.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'emulator/phy.h', please use '/*' instead #171: FILE: emulator/phy.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #171: FILE: emulator/phy.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'emulator/serial.h', please use '/*' instead #189: FILE: emulator/serial.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #189: FILE: emulator/serial.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'emulator/server.h', please use '/*' instead #207: FILE: emulator/server.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #207: FILE: emulator/server.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'emulator/vhci.h', please use '/*' instead #234: FILE: emulator/vhci.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #234: FILE: emulator/vhci.h:1: +// SPDX-License-Identifier: LGPL-2.1-or-later - total: 0 errors, 18 warnings, 88 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============2710110518128234941==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uFaWGQlwXF/LHgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:51:53 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id oMEFFglwXF8n0QAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:51:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6B874A0B1C; Sat, 12 Sep 2020 08:51:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725825AbgILGvi (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:51:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbgILGv2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:51:28 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEEF8C0613ED for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:51:27 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id g72so12125998qke.8 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=UNvSwneC3lW+y+Venzokn4WMeSbjIHLO72zq8UysDdY=; b=Y0eNKGxbw2NoO0UhyJ1OhLZvP0QE8nTFaTMN3wLp2cB6bxHMxXw7XO9ukB+oxXnjAF bPe5OJKVessvih5jJEDT/2FtFYivNUz4S8ddpQAe2GLaEUxu5V1TMHnq6Iu/H62nglIl twBuKIIPVu+AeQ1i+o7d6bUJAA+DNpwn+Ex7a5BLgSAKgQVWl9TgTKH4/GISD/neescD 1cM4/bFKUGd7/oz55wG+tsj5ThdhGv3Xf7PijJYXF+MN6jhdDVhO1+lr1cs4aCBg6Thp P82/g5FDTPXswQ+3VjGgSKIz2F+mnmahmNg+J2+DOUC5jMcxVqy4r5JS2mbwm/hSYbOG YDmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=UNvSwneC3lW+y+Venzokn4WMeSbjIHLO72zq8UysDdY=; b=JG0b653FmXngP2P0ylcxIP6AFLc/r4Q5nJ7bSvmJDOWXOS3lENTvJFHhNvuLZaSsOX laj7HsBKuTXtNyKUWuKfjRVJVXUZ9IkPXYUlyPwBYXSgtJrnZMHh9OixFxxQF3dfS/QS yr+jNe+FCYI1pLvVskJHJpn119oo2MD8tMFw8On4oTT+PYLVQnmAWXLSh27kiLE+zV4E j4Ufq7jqtNedH1m2ntGnLZ+iIuKC2wbeueUDd6WvP75mWMVIgOi+8XvNxa1tIrR5xYfh RlE5TzBhufvIjVv71iMv94qtWyNyUSsDtGt74DgVUXzksdLVHCwSu0Hd5HEe5POiaDv9 X83A== X-Gm-Message-State: AOAM532izyPkQX3MlgmaGFR1BJNyFR+kGQABfiXOMCXujblGVWV3sraL BaRd5p16QT9OgxDo2kTrNCAF3fNWjYRWYQ== X-Google-Smtp-Source: ABdhPJzNJcQ1+fA1492hFnJDrG28jgCgDHaSJhIjC0OQBceFcwf3jqr6nXJwF8Gsw2dlKEuR3R48Vw== X-Received: by 2002:a37:6892:: with SMTP id d140mr4535699qkc.58.1599893483208; Fri, 11 Sep 2020 23:51:23 -0700 (PDT) Received: from [172.17.0.2] ([40.84.17.224]) by smtp.gmail.com with ESMTPSA id b190sm763988qkd.45.2020.09.11.23.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 23:51:22 -0700 (PDT) Message-ID: <5f5c6fea.1c69fb81.43f41.1e35@mx.google.com> Date: Fri, 11 Sep 2020 23:51:22 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3487050300692952400==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, tedd.an@linux.intel.com Subject: RE: [BlueZ,03/17] btio: Add SPDX License Identifier Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200912062357.23926-4-tedd.an@linux.intel.com> References: <20200912062357.23926-4-tedd.an@linux.intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.92 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6B874A0B1C X-Rspamd-UID: 263e1b --===============3487050300692952400== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'btio/btio.h', please use '/*' instead #31: FILE: btio/btio.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #31: FILE: btio/btio.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later - total: 0 errors, 2 warnings, 8 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============3487050300692952400==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OJ3JMw9wXF/LHgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:51:59 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id EDARMQ9wXF8bSAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:51:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 79314A0377; Sat, 12 Sep 2020 08:51:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725839AbgILGvi (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:51:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725833AbgILGv2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:51:28 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CABCFC061786 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:51:27 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id q10so6373523qvs.1 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=DRgLgheDgaTzIsNwst0UPPo4qnSXc9Nu/gQeniCRqPU=; b=dIg9Gq4pgh7G/iIMQJUFXYQRyMbuevSKgybUu2gZLQzHZXge3rxzbp/xciTbS6b7pY CIW4T5KVhRcnEgxwwgRNUHV6QlYuFDurWzusSBMZDFgRGkLpDM1AMArw3rTmGGupbcSf PDEV0thCHDQ+4JggtSBYCXFOaM8MaFI55pRwcBPs81eJ0T1avCgravU9ainhbtCTMxfp R4wd6GsKyIKJibZHIbnGBlVEPxfHWl3qynHUSnhlY1bxsKShpSS0eA/Ya7tDMkpBzt2P WhpGczp/+jI3qLUooPfmb15SHp1imn4g1mxwPYOnraz8gPB+B2klfhlwIm7c1icDO2/p sMVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=DRgLgheDgaTzIsNwst0UPPo4qnSXc9Nu/gQeniCRqPU=; b=UOnAaBfbVFmfGyY6EcLp4Crsqpxe8WQoF6tQkzLiH8r6eJGj0AA9G8cyJDv4wZxXX4 4hr7rpiHATle/I5MOYujb+JNAGCxIfZhp5ikZ+KtufTJC26TrCrTRGuJDv3g0VEizzSg BLg44O4cSYoYs1ELHOegUaGFARSX8wIGd0w94WesNpRHnS7K5FK0MePlQFNYE3xXuREO 4IPpJH47snUTCax4rSj54BXRfgaqCkJMUCh9k07Bn1OskuFzwPdy0SWwcL9ChPbL5pqu jbdBSNIghRySdW/hNM523H6pKZLLUZn6Fww9IIP599jA9fgrzeyxR3B8x3E5GYkfRUrE +vbA== X-Gm-Message-State: AOAM53390eRRZ60l7F4irsWJF58LDOYrOq+BSv3uuNFD+AM8+Bb9SXjm cQh6cc/lD3Xt47YwsSg1ICQue8kUQh921Q== X-Google-Smtp-Source: ABdhPJwS7u8Snj5z6ppNGotIH+xEs+e2L8gtJY9fspEmpMfipXl0BP6A/7RVMN6C6vcOfLXuoEK3sg== X-Received: by 2002:ad4:4f8f:: with SMTP id em15mr5100445qvb.65.1599893486139; Fri, 11 Sep 2020 23:51:26 -0700 (PDT) Received: from [172.17.0.2] ([40.84.17.224]) by smtp.gmail.com with ESMTPSA id 203sm6013182qke.59.2020.09.11.23.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 23:51:25 -0700 (PDT) Message-ID: <5f5c6fed.1c69fb81.ecf77.009b@mx.google.com> Date: Fri, 11 Sep 2020 23:51:25 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============1496939985822898260==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, tedd.an@linux.intel.com Subject: RE: [BlueZ,11/17] obexd: Add SPDX License Identifer Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200912062357.23926-12-tedd.an@linux.intel.com> References: <20200912062357.23926-12-tedd.an@linux.intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.58 / 15.00 / 15.00 X-Rspamd-Queue-Id: 79314A0377 X-Rspamd-UID: 948c07 --===============1496939985822898260== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/bluetooth.h', please use '/*' instead #94: FILE: obexd/client/bluetooth.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #94: FILE: obexd/client/bluetooth.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/driver.h', please use '/*' instead #112: FILE: obexd/client/driver.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #112: FILE: obexd/client/driver.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/ftp.h', please use '/*' instead #130: FILE: obexd/client/ftp.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #130: FILE: obexd/client/ftp.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/manager.h', please use '/*' instead #148: FILE: obexd/client/manager.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #148: FILE: obexd/client/manager.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/map-event.h', please use '/*' instead #166: FILE: obexd/client/map-event.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #166: FILE: obexd/client/map-event.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/map.h', please use '/*' instead #184: FILE: obexd/client/map.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #184: FILE: obexd/client/map.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/opp.h', please use '/*' instead #211: FILE: obexd/client/opp.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #211: FILE: obexd/client/opp.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/pbap.h', please use '/*' instead #229: FILE: obexd/client/pbap.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #229: FILE: obexd/client/pbap.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/session.h', please use '/*' instead #247: FILE: obexd/client/session.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #247: FILE: obexd/client/session.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/sync.h', please use '/*' instead #265: FILE: obexd/client/sync.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #265: FILE: obexd/client/sync.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/transfer.h', please use '/*' instead #283: FILE: obexd/client/transfer.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #283: FILE: obexd/client/transfer.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/client/transport.h', please use '/*' instead #301: FILE: obexd/client/transport.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #301: FILE: obexd/client/transport.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/plugins/filesystem.h', please use '/*' instead #328: FILE: obexd/plugins/filesystem.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #328: FILE: obexd/plugins/filesystem.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/plugins/ftp.h', please use '/*' instead #346: FILE: obexd/plugins/ftp.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #346: FILE: obexd/plugins/ftp.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/plugins/messages.h', please use '/*' instead #391: FILE: obexd/plugins/messages.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #391: FILE: obexd/plugins/messages.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/plugins/phonebook.h', please use '/*' instead #454: FILE: obexd/plugins/phonebook.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #454: FILE: obexd/plugins/phonebook.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/plugins/vcard.h', please use '/*' instead #481: FILE: obexd/plugins/vcard.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #481: FILE: obexd/plugins/vcard.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/src/log.h', please use '/*' instead #499: FILE: obexd/src/log.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #499: FILE: obexd/src/log.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/src/manager.h', please use '/*' instead #526: FILE: obexd/src/manager.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #526: FILE: obexd/src/manager.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/src/map_ap.h', please use '/*' instead #535: FILE: obexd/src/map_ap.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #535: FILE: obexd/src/map_ap.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/src/mimetype.h', please use '/*' instead #553: FILE: obexd/src/mimetype.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #553: FILE: obexd/src/mimetype.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/src/obex-priv.h', please use '/*' instead #562: FILE: obexd/src/obex-priv.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #562: FILE: obexd/src/obex-priv.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/src/obex.h', please use '/*' instead #580: FILE: obexd/src/obex.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #580: FILE: obexd/src/obex.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/src/obexd.h', please use '/*' instead #589: FILE: obexd/src/obexd.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #589: FILE: obexd/src/obexd.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/src/plugin.h', please use '/*' instead #607: FILE: obexd/src/plugin.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #607: FILE: obexd/src/plugin.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/src/server.h', please use '/*' instead #625: FILE: obexd/src/server.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #625: FILE: obexd/src/server.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/src/service.h', please use '/*' instead #643: FILE: obexd/src/service.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #643: FILE: obexd/src/service.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'obexd/src/transport.h', please use '/*' instead #661: FILE: obexd/src/transport.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #661: FILE: obexd/src/transport.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later - total: 0 errors, 56 warnings, 260 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============1496939985822898260==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8H9qAgQmXF9D2wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 03:36:04 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id sKRWOwMmXF8CeAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 03:36:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B44CBA016F; Sat, 12 Sep 2020 03:35:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725832AbgILBfk (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 11 Sep 2020 21:35:40 -0400 Received: from mail-il1-f200.google.com ([209.85.166.200]:45592 "EHLO mail-il1-f200.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725562AbgILBfR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 11 Sep 2020 21:35:17 -0400 Received: by mail-il1-f200.google.com with SMTP id m80so8399634ilb.12 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 18:35:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=1Au+jF0U9NdQpjmGSupuqP1uY7GjUPeo4ovRK8rNqtg=; b=etFx3k8N2VCLjQln5HhTFfcmrKCkNRz+SPVU1uPRxz3b3j2LoI+erPcx463s+nvmMk +X7LTcIFpBteWHN359zRUYLYZa2FjeOk3ttWK4V/8p7ASWPhfx0T5eFluonC2G1bnnlz ThnQZeDPz8P+kt0lpjEB6jAQfeAmZWbujmnhc8PVc66BIEsxxARZBzt0+LwXSd2sHvkw WA+rs6N/70vdWzicFyO5q+6mRwPa7YZ8rXAi5BF866yneaUBfOopnN8s2hDFJ2LR2Z4j lVNNWNk2vyiXNdFiKTD4dc1yFVmRpcWHEmV4Cj2mapYxtnhPkj91agrNozzF1CZ7qXOu 9MmQ== X-Gm-Message-State: AOAM531xY66moPzTZNgZPgPaZ6rNQC9b0CRUb3ZeoPPUcwSDRN/xadX8 XUUmSMz0PBiTWioaRJ2bt2LmAO6wxk0B3WVMfrjMGwrmelMZ X-Google-Smtp-Source: ABdhPJykGvkkfF0TalkCAFdl6JKCUiPAmVhfOt5G9R1UhpC7B/l/0I/FrHN9AfoIj2ouf2dGbvl10ZQCmRDRvIvA/3F/8kp7mqZ8 MIME-Version: 1.0 X-Received: by 2002:a6b:fb0c:: with SMTP id h12mr3621463iog.98.1599874514946; Fri, 11 Sep 2020 18:35:14 -0700 (PDT) Date: Fri, 11 Sep 2020 18:35:14 -0700 In-Reply-To: <0000000000004991e705ac9d1a83@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000026136505af13d0ab@google.com> Subject: Re: inconsistent lock state in sco_conn_del From: syzbot <syzbot+65684128cd7c35bc66a1@syzkaller.appspotmail.com> To: davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.45 / 15.00 / 15.00 X-Rspamd-Queue-Id: B44CBA016F X-Rspamd-UID: 5f7d18 syzbot has found a reproducer for the following issue on: HEAD commit: e8878ab8 Merge tag 'spi-fix-v5.9-rc4' of git://git.kernel... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=12130759900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c61610091f4ca8c4 dashboard link: https://syzkaller.appspot.com/bug?extid=65684128cd7c35bc66a1 compiler: gcc (GCC) 10.1.0-syz 20200507 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=121ef0fd900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16c3a853900000 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+65684128cd7c35bc66a1@syzkaller.appspotmail.com ================================ WARNING: inconsistent lock state 5.9.0-rc4-syzkaller #0 Not tainted -------------------------------- inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage. syz-executor675/31233 [HC0[0]:SC0[0]:HE1:SE1] takes: ffff8880a75c50a0 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.?.}-{2:2}, at: spin_lock include/linux/spinlock.h:354 [inline] ffff8880a75c50a0 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.?.}-{2:2}, at: sco_conn_del+0x128/0x270 net/bluetooth/sco.c:176 {IN-SOFTIRQ-W} state was registered at: lock_acquire+0x1f3/0xae0 kernel/locking/lockdep.c:5006 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:354 [inline] sco_sock_timeout+0x24/0x140 net/bluetooth/sco.c:83 call_timer_fn+0x1ac/0x760 kernel/time/timer.c:1413 expire_timers kernel/time/timer.c:1458 [inline] __run_timers.part.0+0x67c/0xaa0 kernel/time/timer.c:1755 __run_timers kernel/time/timer.c:1736 [inline] run_timer_softirq+0xae/0x1a0 kernel/time/timer.c:1768 __do_softirq+0x1f7/0xa91 kernel/softirq.c:298 asm_call_on_stack+0xf/0x20 arch/x86/entry/entry_64.S:706 __run_on_irqstack arch/x86/include/asm/irq_stack.h:22 [inline] run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:48 [inline] do_softirq_own_stack+0x9d/0xd0 arch/x86/kernel/irq_64.c:77 invoke_softirq kernel/softirq.c:393 [inline] __irq_exit_rcu kernel/softirq.c:423 [inline] irq_exit_rcu+0x235/0x280 kernel/softirq.c:435 sysvec_apic_timer_interrupt+0x51/0xf0 arch/x86/kernel/apic/apic.c:1091 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:581 unwind_next_frame+0x139a/0x1f90 arch/x86/kernel/unwind_orc.c:607 arch_stack_walk+0x81/0xf0 arch/x86/kernel/stacktrace.c:25 stack_trace_save+0x8c/0xc0 kernel/stacktrace.c:123 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48 kasan_set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:461 slab_post_alloc_hook mm/slab.h:518 [inline] slab_alloc mm/slab.c:3312 [inline] kmem_cache_alloc+0x13a/0x3a0 mm/slab.c:3482 __d_alloc+0x2a/0x950 fs/dcache.c:1709 d_alloc+0x4a/0x230 fs/dcache.c:1788 d_alloc_parallel+0xe9/0x18e0 fs/dcache.c:2540 lookup_open.isra.0+0x9ac/0x1350 fs/namei.c:3030 open_last_lookups fs/namei.c:3177 [inline] path_openat+0x96d/0x2730 fs/namei.c:3365 do_filp_open+0x17e/0x3c0 fs/namei.c:3395 do_sys_openat2+0x16d/0x420 fs/open.c:1168 do_sys_open fs/open.c:1184 [inline] __do_sys_open fs/open.c:1192 [inline] __se_sys_open fs/open.c:1188 [inline] __x64_sys_open+0x119/0x1c0 fs/open.c:1188 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 irq event stamp: 853 hardirqs last enabled at (853): [<ffffffff87f733af>] __raw_spin_unlock_irq include/linux/spinlock_api_smp.h:168 [inline] hardirqs last enabled at (853): [<ffffffff87f733af>] _raw_spin_unlock_irq+0x1f/0x80 kernel/locking/spinlock.c:199 hardirqs last disabled at (852): [<ffffffff87f73764>] __raw_spin_lock_irq include/linux/spinlock_api_smp.h:126 [inline] hardirqs last disabled at (852): [<ffffffff87f73764>] _raw_spin_lock_irq+0xa4/0xd0 kernel/locking/spinlock.c:167 softirqs last enabled at (0): [<ffffffff8144c929>] copy_process+0x1a99/0x6920 kernel/fork.c:2018 softirqs last disabled at (0): [<0000000000000000>] 0x0 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(slock-AF_BLUETOOTH-BTPROTO_SCO); <Interrupt> lock(slock-AF_BLUETOOTH-BTPROTO_SCO); *** DEADLOCK *** 3 locks held by syz-executor675/31233: #0: ffff88809f104f40 (&hdev->req_lock){+.+.}-{3:3}, at: hci_dev_do_close+0xf5/0x1080 net/bluetooth/hci_core.c:1720 #1: ffff88809f104078 (&hdev->lock){+.+.}-{3:3}, at: hci_dev_do_close+0x253/0x1080 net/bluetooth/hci_core.c:1757 #2: ffffffff8a9188c8 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_disconn_cfm include/net/bluetooth/hci_core.h:1435 [inline] #2: ffffffff8a9188c8 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_conn_hash_flush+0xc7/0x220 net/bluetooth/hci_conn.c:1557 stack backtrace: CPU: 1 PID: 31233 Comm: syz-executor675 Not tainted 5.9.0-rc4-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x198/0x1fd lib/dump_stack.c:118 print_usage_bug kernel/locking/lockdep.c:4020 [inline] valid_state kernel/locking/lockdep.c:3361 [inline] mark_lock_irq kernel/locking/lockdep.c:3560 [inline] mark_lock.cold+0x7a/0x7f kernel/locking/lockdep.c:4006 mark_usage kernel/locking/lockdep.c:3923 [inline] __lock_acquire+0x876/0x5570 kernel/locking/lockdep.c:4380 lock_acquire+0x1f3/0xae0 kernel/locking/lockdep.c:5006 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:354 [inline] sco_conn_del+0x128/0x270 net/bluetooth/sco.c:176 sco_disconn_cfm net/bluetooth/sco.c:1178 [inline] sco_disconn_cfm+0x62/0x80 net/bluetooth/sco.c:1171 hci_disconn_cfm include/net/bluetooth/hci_core.h:1438 [inline] hci_conn_hash_flush+0x114/0x220 net/bluetooth/hci_conn.c:1557 hci_dev_do_close+0x5c6/0x1080 net/bluetooth/hci_core.c:1770 hci_unregister_dev+0x1bd/0xe30 net/bluetooth/hci_core.c:3790 vhci_release+0x70/0xe0 drivers/bluetooth/hci_vhci.c:340 __fput+0x285/0x920 fs/file_table.c:281 task_work_run+0xdd/0x190 kernel/task_work.c:141 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0xb7d/0x29f0 kernel/exit.c:806 do_group_exit+0x125/0x310 kernel/exit.c:903 get_signal+0x428/0x1f00 kernel/signal.c:2757 arch_do_signal+0x82/0x2520 arch/x86/kernel/signal.c:811 exit_to_user_mode_loop kernel/entry/common.c:159 [inline] exit_to_user_mode_prepare+0x1ae/0x200 kernel/entry/common.c:190 syscall_exit_to_user_mode+0x7e/0x2e0 kernel/entry/common.c:265 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x447279 Code: Bad RIP value. RSP: 002b:00007fd19f624d88 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca RAX: fffffffffffffe00 RBX: 00000000006dcc28 RCX: 0000000000447279 RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00000000006dcc28 RBP: 00000000006dcc20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dcc2c R13: 0000000000000004 R14: 0000000000000003 R15: 00007fd19f6256d0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qL2EHxRwXF/J7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:52:04 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id GGHZGxRwXF8bSAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:52:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F17DCA0AAE; Sat, 12 Sep 2020 08:51:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725846AbgILGvr (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:51:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725833AbgILGvl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:51:41 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F3A8C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:51:39 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id u3so2730090pjr.3 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2F5IK3qZINJFDEk93oe4o+MOz1G8iOkBit6CICWcYW8=; b=HF1cdL7LkzySUoFcS6SEPOOi32SNENwEdE4wRna7j0ZrAVhi7iRfBCF3NK7yNk8I1u h3/LNS0vVkcIDsqn2affif8Wa2l9J19NQVXcrHEVOqFpZnCpvP1U4HvBbMl2FFUM+xzg 8tfT7UhPHFdiDktvo0VdrYpWV4HjhF5YckHp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2F5IK3qZINJFDEk93oe4o+MOz1G8iOkBit6CICWcYW8=; b=EDlu1D8IEVjgC1tSQ751kGe0vK1v4Qvc+Aktub1LR5g4ZXZvyftctvXs/aiU5jTT63 +9oS2seC/J0aSMdKfZ/TCFzA2rQvnp7Uur+y9P0hryaNz/IlGtGBnDvAZDdPcmL1zzFu OAK4VjWj2MxOjb2rgyhk9CgNXo8xiJeqAUg4LDbZMYZz6fKzff2cfFrcEivGlNVGzUdv X0y12jr+fN3AxCCoXFbljU60YnpeY6bq1vtwbVYGaVtQUPC0OuJgBtypX7JUQ5Y06mR9 88VyKekRS3ZRSZC13CKzpR0qY1BhlsvxgirmyYjAe81BzLRD9hDcn5PAI086IGDYq7gl IBNg== X-Gm-Message-State: AOAM531tkMADWcLvRu+Mj8sNYxIyWhCdeGfovdNb4RIQwIDqcDJkQKNm 2lIeeKiAuVUVzr6ZdUKUyQxnHVmS9JKXSA== X-Google-Smtp-Source: ABdhPJwl/dx7ZLSoOZk+GXtc7pp7Oda0oTb4tfbKaybpgmV2jS5BUSPTzeIXPr02tuDIQGiyWICdMg== X-Received: by 2002:a17:90a:fc8:: with SMTP id 66mr768684pjz.217.1599893498321; Fri, 11 Sep 2020 23:51:38 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id hg16sm3440913pjb.37.2020.09.11.23.51.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 23:51:37 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v5 1/8] adapter: Remove indirect dependency of headers Date: Fri, 11 Sep 2020 23:51:19 -0700 Message-Id: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.73 / 15.00 / 15.00 X-Rspamd-Queue-Id: F17DCA0AAE X-Rspamd-UID: 87c958 Given that adapter.h refers symbols from lib/bluetooth.h and lib/sdp.h, these two headers should be included directly in adapter.h. Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adapter.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..c70a7b0da 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -26,6 +26,9 @@ #include <dbus/dbus.h> #include <glib.h> +#include <lib/bluetooth.h> +#include <lib/sdp.h> + #define MAX_NAME_LENGTH 248 /* Invalid SSP passkey value used to indicate negative replies */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AHmmHClwXF/J7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:52:25 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id qHW0GSlwXF9A9QAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:52:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2BB92A0B19; Sat, 12 Sep 2020 08:52:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725813AbgILGwS (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:52:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725833AbgILGwK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:52:10 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 043B5C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:52:10 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id f2so5971890pgd.3 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:52:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6NkIUnCBg/W8FDg9bJf6d5T8R+Lpd4X8IBezpCyIGhk=; b=Rp21n4TtghI3Zr0dSLH0ebfRtVoWLrZIVaUt0PsARv+E2+RvjNr3PC/iNaUY+et/oY wQ984XmxEnIYQnK0PDcU02eml/NSxk1w0JlG70Vtk5k8Lj52oevbUWOlk0g77HA0BloJ ecpU9FwJ7NByHgZCST79B7svXtyPJd0nBrl38= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6NkIUnCBg/W8FDg9bJf6d5T8R+Lpd4X8IBezpCyIGhk=; b=nkROa4nz+PpRiAsoHhB7uV/MlJn8IoZcmVmLaFIGftWFbk+QM8e6ZEzi4Cp+jwltLd ncw2kGfj/7384xMOWqZ+AyezISLgBt5F9hyfx3/YlHrZu55WOg2yTinhSWKDJA9pLX9l d2d1bmXq/dnbJmpENmWQOPQEArOpkZbHFUvBxHFUc10gEnl1VQusAvax13yRomwAQwue QBZ7qdXSvK595uzxKPg0b6q+UYAJSKIm1/LNWgTGY/oyt4zt03CYEIkMSKg9qxMNxYvP S58wezAtRcaGuRLVOsC0ollg/eICO/DSbYCeSnLTf+OYTWMwf8cuEN1B4+nYREc4zxNv Y6VQ== X-Gm-Message-State: AOAM531Dt6b8w6rmkQvLtbiIMd7UkYJXo0KIgiM7qqkq4PdkrDX6R7Qu 3r+JSe074RReZ6zGipn8VKv/DW5LlUw9YQ== X-Google-Smtp-Source: ABdhPJzc/WjFrdMXyjzOUr4zUBSRZcQNc57aGReftgP7+4XD4dnVhChSy5a6sR1Z+SXqK/5XhcqwDQ== X-Received: by 2002:aa7:94a4:: with SMTP id a4mr5371155pfl.49.1599893524466; Fri, 11 Sep 2020 23:52:04 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id hg16sm3440913pjb.37.2020.09.11.23.52.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 23:52:03 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v5 2/8] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Date: Fri, 11 Sep 2020 23:51:21 -0700 Message-Id: <20200911235104.BlueZ.v5.2.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.43 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2BB92A0B19 X-Rspamd-UID: 04e245 This introduces the org.bluez.AdvertisementMonitorManager1 without implementing handlers of methods and properties. The following test was performed. - Upon adapter registration, the info line of creating an ADV monitor manager gets printed, and system bus emits the interface events of org.bluez.AdvertisementMonitorManager1. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v4) Changes in v4: -Create the Adv Monitor Manager only if the experimental flag is in place and mark all properties and methods experimental. Changes in v2: -Use new0 instead of g_new0 -Remove the reset of manager members -Make methods/property experimental Makefile.am | 3 +- src/adapter.c | 23 ++++++++ src/adv_monitor.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++ src/adv_monitor.h | 32 ++++++++++ 4 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 src/adv_monitor.c create mode 100644 src/adv_monitor.h diff --git a/Makefile.am b/Makefile.am index 725fbe48d..22b4fa30c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -293,7 +293,8 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ src/gatt-client.h src/gatt-client.c \ src/device.h src/device.c \ src/dbus-common.c src/dbus-common.h \ - src/eir.h src/eir.c + src/eir.h src/eir.c \ + src/adv_monitor.h src/adv_monitor.c src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ gdbus/libgdbus-internal.la \ src/libshared-glib.la \ diff --git a/src/adapter.c b/src/adapter.c index 1435e2bd7..df628a7fd 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -77,6 +77,7 @@ #include "attrib-server.h" #include "gatt-database.h" #include "advertising.h" +#include "adv_monitor.h" #include "eir.h" #define ADAPTER_INTERFACE "org.bluez.Adapter1" @@ -272,6 +273,8 @@ struct btd_adapter { struct btd_gatt_database *database; struct btd_adv_manager *adv_manager; + struct btd_adv_monitor_manager *adv_monitor_manager; + gboolean initialized; GSList *pin_callbacks; @@ -6360,6 +6363,9 @@ static void adapter_remove(struct btd_adapter *adapter) btd_adv_manager_destroy(adapter->adv_manager); adapter->adv_manager = NULL; + btd_adv_monitor_manager_destroy(adapter->adv_monitor_manager); + adapter->adv_monitor_manager = NULL; + g_slist_free(adapter->pin_callbacks); adapter->pin_callbacks = NULL; @@ -8633,6 +8639,23 @@ static int adapter_register(struct btd_adapter *adapter) adapter->adv_manager = btd_adv_manager_new(adapter, adapter->mgmt); + if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) { + if (adapter->supported_settings & MGMT_SETTING_LE) { + adapter->adv_monitor_manager = + btd_adv_monitor_manager_create(adapter, + adapter->mgmt); + if (!adapter->adv_monitor_manager) { + btd_error(adapter->dev_id, + "Failed to create Adv Monitor " + "Manager for adapter"); + return -EINVAL; + } + } else { + btd_info(adapter->dev_id, "Adv Monitor Manager " + "skipped, LE unavailable"); + } + } + db = btd_gatt_database_get_db(adapter->database); adapter->db_id = gatt_db_register(db, services_modified, services_modified, diff --git a/src/adv_monitor.c b/src/adv_monitor.c new file mode 100644 index 000000000..ad3f64cbe --- /dev/null +++ b/src/adv_monitor.c @@ -0,0 +1,147 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdint.h> + +#include <glib.h> +#include <dbus/dbus.h> +#include <gdbus/gdbus.h> + +#include "adapter.h" +#include "dbus-common.h" +#include "log.h" +#include "src/shared/mgmt.h" +#include "src/shared/util.h" + +#include "adv_monitor.h" + +#define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" + +struct btd_adv_monitor_manager { + struct btd_adapter *adapter; + struct mgmt *mgmt; + uint16_t adapter_id; +}; + +static const GDBusMethodTable adv_monitor_methods[] = { + { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { } +}; + +static const GDBusPropertyTable adv_monitor_properties[] = { + {"SupportedMonitorTypes", "as", NULL, NULL, NULL, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, + {"SupportedFeatures", "as", NULL, NULL, NULL, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, + { } +}; + +/* Allocates a manager object */ +static struct btd_adv_monitor_manager *manager_new( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + if (!adapter || !mgmt) + return NULL; + + manager = new0(struct btd_adv_monitor_manager, 1); + if (!manager) + return NULL; + + manager->adapter = adapter; + manager->mgmt = mgmt_ref(mgmt); + manager->adapter_id = btd_adapter_get_index(adapter); + + return manager; +} + +/* Frees a manager object */ +static void manager_free(struct btd_adv_monitor_manager *manager) +{ + mgmt_unref(manager->mgmt); + + free(manager); +} + +/* Destroys a manager object and unregisters its D-Bus interface */ +static void manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + g_dbus_unregister_interface(btd_get_dbus_connection(), + adapter_get_path(manager->adapter), + ADV_MONITOR_MGR_INTERFACE); + + manager_free(manager); +} + +/* Creates a manager and registers its D-Bus interface */ +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + manager = manager_new(adapter, mgmt); + if (!manager) + return NULL; + + if (!g_dbus_register_interface(btd_get_dbus_connection(), + adapter_get_path(manager->adapter), + ADV_MONITOR_MGR_INTERFACE, + adv_monitor_methods, NULL, + adv_monitor_properties, manager, + NULL)) { + btd_error(manager->adapter_id, + "Failed to register " + ADV_MONITOR_MGR_INTERFACE); + manager_free(manager); + return NULL; + } + + btd_info(manager->adapter_id, + "Adv Monitor Manager created for adapter %s", + adapter_get_path(manager->adapter)); + + return manager; +} + +/* Destroys a manager and unregisters its D-Bus interface */ +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + btd_info(manager->adapter_id, "Destroy Adv Monitor Manager"); + + manager_destroy(manager); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h new file mode 100644 index 000000000..69ea348f8 --- /dev/null +++ b/src/adv_monitor.h @@ -0,0 +1,32 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifndef __ADV_MONITOR_H +#define __ADV_MONITOR_H + +struct mgmt; +struct btd_adapter; +struct btd_adv_monitor_manager; + +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt); +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); + +#endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eMwgLC9wXF/J7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:52:31 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2BrQKC9wXF8TYgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:52:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 87846A015F; Sat, 12 Sep 2020 08:52:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725857AbgILGwW (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:52:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725833AbgILGwT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:52:19 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3BC8C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:52:19 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id kk9so2732963pjb.2 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:52:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OIsvcCCe4eEzn40v5J1tH5z/WLp46x3UEfdIUBIffwU=; b=iQEJlcx0UPQ/rre2YHa6Cz+hUs97ueji945vqIfBLQXxlJmWR+ugRTQKaccbjUfTrC xU0n50oI6wBCldbIm7dvvK/7TM1OfMxc7jfwuMxYmC0qmlI7J/z4/TPAnuaw0W0L+wcN m4D4lYGXNU60LM+neAKxHsewJsnwQx0Opsbgw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OIsvcCCe4eEzn40v5J1tH5z/WLp46x3UEfdIUBIffwU=; b=bjjdLMyO03B05C5Pf/O9DVrv9/0+oP+ArSJ/bO5XmbHFyPn8mw1E7sZR6JlHS8Fevr 0Wbv/mgAWf/SzqkNuZF+czbA+9tvT7689DXpk3/c6Zk3Vp/1m/R0i5oWEnImLx8WBexK HCpR0G0oQiuCOWGtvhmnuSGYkbj5kZrDew4rdj+6ffESXVPvBQHKEKtTGpQ+VGH6JXoD zOPqP/CDfJcEhpeCmMqGPhnJZsx8z2pzueDgsvuNVKoxAqQYuaNm4gDCnJi5I6TtGe3q K4FIlOtHa26744N9wAv9QRH1AL1TD6yasAL0EHJ3POlTWlkiignFezF3G8ZTBTJyQOhj gDEw== X-Gm-Message-State: AOAM533nB6lLxH/Jl/Yxo4OW5hqtV4LtW4d/5qecSnBY3ffTNXLX1KgE qgBLFAwTWUZKjXZ9cqWmJPpPBZEEng+n2g== X-Google-Smtp-Source: ABdhPJz8AyHkDMKYKwekYXelrG3s6YYBVlc1p5JstlHjY3sMpgAfT/TSWT8/ZxPS0Yqes97xIYhy1Q== X-Received: by 2002:a17:90b:1918:: with SMTP id mp24mr5246474pjb.110.1599893538347; Fri, 11 Sep 2020 23:52:18 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id hg16sm3440913pjb.37.2020.09.11.23.52.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 23:52:17 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v5 3/8] adv_monitor: Implement Get functions of Adv monitor manager properties Date: Fri, 11 Sep 2020 23:51:23 -0700 Message-Id: <20200911235104.BlueZ.v5.3.I9960e45d36be3edb5f17de025e7eb8257d3cddef@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.33 / 15.00 / 15.00 X-Rspamd-Queue-Id: 87846A015F X-Rspamd-UID: 3f39d4 This implements the Get functions of SupportedMonitorTypes and SupportedFeatures. The following test was performed. - Issue dbus-send to read SupportedMonitorTypes and SupportedFeatures. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- Changes in v5: - Remove unused variable. src/adv_monitor.c | 126 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 121 insertions(+), 5 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index ad3f64cbe..48aa6838d 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -28,6 +28,9 @@ #include <dbus/dbus.h> #include <gdbus/gdbus.h> +#include "lib/bluetooth.h" +#include "lib/mgmt.h" + #include "adapter.h" #include "dbus-common.h" #include "log.h" @@ -42,6 +45,11 @@ struct btd_adv_monitor_manager { struct btd_adapter *adapter; struct mgmt *mgmt; uint16_t adapter_id; + + uint32_t supported_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ + uint32_t enabled_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ + uint16_t max_num_monitors; + uint8_t max_num_patterns; }; static const GDBusMethodTable adv_monitor_methods[] = { @@ -54,10 +62,77 @@ static const GDBusMethodTable adv_monitor_methods[] = { { } }; +enum monitor_type { + MONITOR_TYPE_OR_PATTERNS, +}; + +const struct adv_monitor_type { + enum monitor_type type; + const char *name; +} supported_types[] = { + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, + { }, +}; + +/* Gets SupportedMonitorTypes property */ +static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, + DBusMessageIter *iter, + void *data) +{ + DBusMessageIter entry; + const struct adv_monitor_type *t; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, + &entry); + + for (t = supported_types; t->name; t++) { + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, + &t->name); + } + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + +const struct adv_monitor_feature { + uint32_t mask; + const char *name; +} supported_features[] = { + { MGMT_ADV_MONITOR_FEATURE_MASK_OR_PATTERNS, "controller-patterns" }, + { } +}; + +/* Gets SupportedFeatures property */ +static gboolean get_supported_features(const GDBusPropertyTable *property, + DBusMessageIter *iter, + void *data) +{ + DBusMessageIter entry; + const struct adv_monitor_feature *f; + struct btd_adv_monitor_manager *manager = data; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, + &entry); + + for (f = supported_features; f->name; f++) { + if (manager->supported_features & f->mask) { + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, + &f->name); + } + } + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + static const GDBusPropertyTable adv_monitor_properties[] = { - {"SupportedMonitorTypes", "as", NULL, NULL, NULL, + {"SupportedMonitorTypes", "as", get_supported_monitor_types, NULL, NULL, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, - {"SupportedFeatures", "as", NULL, NULL, NULL, + {"SupportedFeatures", "as", get_supported_features, NULL, NULL, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, { } }; @@ -104,6 +179,42 @@ static void manager_destroy(struct btd_adv_monitor_manager *manager) manager_free(manager); } +/* Initiates manager's members based on the return of + * MGMT_OP_READ_ADV_MONITOR_FEATURES + */ +static void read_adv_monitor_features_cb(uint8_t status, uint16_t length, + const void *param, + void *user_data) +{ + const struct mgmt_rp_read_adv_monitor_features *rp = param; + struct btd_adv_monitor_manager *manager = user_data; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(manager->adapter_id, "Failed to Read Adv Monitor " + "Features with status 0x%02x", status); + return; + } + + if (length < sizeof(*rp)) { + btd_error(manager->adapter_id, + "Wrong size of Read Adv Monitor Features " + "response"); + return; + } + + manager->supported_features = le32_to_cpu(rp->supported_features); + manager->enabled_features = le32_to_cpu(rp->enabled_features); + manager->max_num_monitors = le16_to_cpu(rp->max_num_handles); + manager->max_num_patterns = rp->max_num_patterns; + + btd_info(manager->adapter_id, "Adv Monitor Manager created with " + "supported features:0x%08x, enabled features:0x%08x, " + "max number of supported monitors:%d, " + "max number of supported patterns:%d", + manager->supported_features, manager->enabled_features, + manager->max_num_monitors, manager->max_num_patterns); +} + /* Creates a manager and registers its D-Bus interface */ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct btd_adapter *adapter, @@ -128,9 +239,14 @@ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( return NULL; } - btd_info(manager->adapter_id, - "Adv Monitor Manager created for adapter %s", - adapter_get_path(manager->adapter)); + if (!mgmt_send(manager->mgmt, MGMT_OP_READ_ADV_MONITOR_FEATURES, + manager->adapter_id, 0, NULL, + read_adv_monitor_features_cb, manager, NULL)) { + btd_error(manager->adapter_id, + "Failed to send Read Adv Monitor Features"); + manager_destroy(manager); + return NULL; + } return manager; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aCTxLDtwXF/LHgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:52:43 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cOeCKjtwXF93ugEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:52:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AA86FA0161; Sat, 12 Sep 2020 08:52:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725860AbgILGwg (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725833AbgILGwf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:52:35 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A49C4C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:52:35 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id kk9so2733111pjb.2 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NscPETvDxS800m3xtngM2kzXRvW04Lroe1FFyy7LBW0=; b=hRvq+xze8IMPfZMNAW8A7fDQtMTUHYZGyAgJmu3NOh2Ihcr9wCkM9wFSAeSyxK0JcG /SP6956u19NGvqLfNH4Ek1QFCmm6rYQ3LfsyD2GQKPI58JAHHG1ikexP6qTzxrSEgBE1 PudIj0YQGUAgzl1UtBnOcurA5XFKf5Mu/K3fk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NscPETvDxS800m3xtngM2kzXRvW04Lroe1FFyy7LBW0=; b=IqkR3Gn5KyTRy0KfaUkssPrbU9Y6w09AWrv3FSxIlqVR5ahQlYUtK6cr+5GcjJgzwk kNxvO9kZuh8Fwn1EFv+Ge8TZZ0AifTda0YqbEnZcznrKaWnfuxXFPpZ6xDvdbvvJtkgB FtmP2a1S6GF8WZigjYQtLkfmqEzwLJgsbglVs+a4kC9teci1lLUFf28Nez+EOwfteofl 3kj5qNSAvrCcixDOoYOJYYkXQ7Ji7zOh3yICXeVlE0zLgtXiuDNCZC2OV8+wjaorI2iF wPtcEmeN5jYPZJ+rA949UphQpOTt6xW6ySUTSpdwXacVt+FjX5QytA7V764k+dq5yu6m rIlA== X-Gm-Message-State: AOAM530mZKozB3Wk2NWMEa4VYC6IZ/t6PTTNMWapD4mvKABFYuhbvf0W zY2k+QhgfXNcmRF8NHkO3PNMXuoYXwGXMQ== X-Google-Smtp-Source: ABdhPJzeESfe7REojwZehpK9CCbJZ6vLan84u9Sgv9/Wcx8jWQtQeTaqJefsQQFrp9/LlKZRnk/BOA== X-Received: by 2002:a17:90b:905:: with SMTP id bo5mr4730756pjb.73.1599893552246; Fri, 11 Sep 2020 23:52:32 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id hg16sm3440913pjb.37.2020.09.11.23.52.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 23:52:31 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v5 4/8] adv_monitor: Implement RegisterMonitor() Date: Fri, 11 Sep 2020 23:51:25 -0700 Message-Id: <20200911235104.BlueZ.v5.4.I19ff9cdbd40fe453db0e81aec8bf94dd9490dce3@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.33 / 15.00 / 15.00 X-Rspamd-Queue-Id: AA86FA0161 X-Rspamd-UID: ba66b5 This implements the RegisterMonitor() method handler of ADV monitor manager interface. The following tests were performed. - Issue a RegisterMonitor() call with a valid path and expect a success as return. - Issue a RegisterMonitor() call with an invalid path and expect org.bluez.Error.InvalidArguments as return. - Issue two Registermonitor() calls with the same path and expect org.bluez.Error.AlreadyExists. - Verify the values of the registered paths with logging. - Verify D-Bus disconnection callback was triggered when the client detach from D-Bus. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v2) Changes in v2: - Use new0() instead of g_new0() - Remove the reset of app members src/adv_monitor.c | 165 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 164 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 48aa6838d..b9bffe9ba 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -22,7 +22,9 @@ #endif #define _GNU_SOURCE +#include <errno.h> #include <stdint.h> +#include <string.h> #include <glib.h> #include <dbus/dbus.h> @@ -34,7 +36,9 @@ #include "adapter.h" #include "dbus-common.h" #include "log.h" +#include "src/error.h" #include "src/shared/mgmt.h" +#include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" @@ -50,12 +54,168 @@ struct btd_adv_monitor_manager { uint32_t enabled_features; /* MGMT_ADV_MONITOR_FEATURE_MASK_* */ uint16_t max_num_monitors; uint8_t max_num_patterns; + + struct queue *apps; /* apps who registered for Adv monitoring */ +}; + +struct adv_monitor_app { + struct btd_adv_monitor_manager *manager; + char *owner; + char *path; + + DBusMessage *reg; + GDBusClient *client; }; +struct app_match_data { + const char *owner; + const char *path; +}; + +/* Replies to an app's D-Bus message and unref it */ +static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) +{ + if (!app || !app->reg || !reply) + return; + + g_dbus_send_message(btd_get_dbus_connection(), reply); + dbus_message_unref(app->reg); + app->reg = NULL; +} + +/* Destroys an app object along with related D-Bus handlers */ +static void app_destroy(void *data) +{ + struct adv_monitor_app *app = data; + + if (!app) + return; + + DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); + + if (app->reg) { + app_reply_msg(app, btd_error_failed(app->reg, + "Adv Monitor app destroyed")); + } + + if (app->client) { + g_dbus_client_set_disconnect_watch(app->client, NULL, NULL); + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, + NULL); + g_dbus_client_set_ready_watch(app->client, NULL, NULL); + g_dbus_client_unref(app->client); + } + + g_free(app->owner); + g_free(app->path); + + free(app); +} + +/* Handles a D-Bus disconnection event of an app */ +static void app_disconnect_cb(DBusConnection *conn, void *user_data) +{ + struct adv_monitor_app *app = user_data; + + btd_info(app->manager->adapter_id, "Adv Monitor app %s disconnected " + "from D-Bus", app->owner); + if (app && queue_remove(app->manager->apps, app)) + app_destroy(app); +} + +/* Creates an app object, initiates it and sets D-Bus event handlers */ +static struct adv_monitor_app *app_create(DBusConnection *conn, + const char *sender, const char *path, + struct btd_adv_monitor_manager *manager) +{ + struct adv_monitor_app *app; + + if (!path || !sender || !manager) + return NULL; + + app = new0(struct adv_monitor_app, 1); + if (!app) + return NULL; + + app->owner = g_strdup(sender); + app->path = g_strdup(path); + app->manager = manager; + app->reg = NULL; + + app->client = g_dbus_client_new(conn, sender, path); + if (!app->client) { + app_destroy(app); + return NULL; + } + + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); + g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); + g_dbus_client_set_ready_watch(app->client, NULL, NULL); + + return app; +} + +/* Matches an app based on its owner and path */ +static bool app_match(const void *a, const void *b) +{ + const struct adv_monitor_app *app = a; + const struct app_match_data *match = b; + + if (match->owner && strcmp(app->owner, match->owner)) + return false; + + if (match->path && strcmp(app->path, match->path)) + return false; + + return true; +} + +/* Handles a RegisterMonitor D-Bus call */ +static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, + void *user_data) +{ + DBusMessageIter args; + struct app_match_data match; + struct adv_monitor_app *app; + struct btd_adv_monitor_manager *manager = user_data; + + if (!dbus_message_iter_init(msg, &args)) + return btd_error_invalid_args(msg); + + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) + return btd_error_invalid_args(msg); + + dbus_message_iter_get_basic(&args, &match.path); + + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) + return btd_error_invalid_args(msg); + + match.owner = dbus_message_get_sender(msg); + + if (queue_find(manager->apps, app_match, &match)) + return btd_error_already_exists(msg); + + app = app_create(conn, match.owner, match.path, manager); + if (!app) { + btd_error(manager->adapter_id, + "Failed to reserve %s for Adv Monitor app %s", + match.path, match.owner); + return btd_error_failed(msg, + "Failed to create Adv Monitor app"); + } + + queue_push_tail(manager->apps, app); + + btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", + match.path, match.owner); + + return dbus_message_new_method_return(msg); +} + static const GDBusMethodTable adv_monitor_methods[] = { { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), - NULL, NULL) }, + NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, NULL) }, @@ -154,6 +314,7 @@ static struct btd_adv_monitor_manager *manager_new( manager->adapter = adapter; manager->mgmt = mgmt_ref(mgmt); manager->adapter_id = btd_adapter_get_index(adapter); + manager->apps = queue_new(); return manager; } @@ -163,6 +324,8 @@ static void manager_free(struct btd_adv_monitor_manager *manager) { mgmt_unref(manager->mgmt); + queue_destroy(manager->apps, app_destroy); + free(manager); } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6OisGFFwXF/J7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:53:05 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CGG4FVFwXF/20gEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:53:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 452B2A0B19; Sat, 12 Sep 2020 08:53:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725809AbgILGw6 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:52:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgILGwx (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:52:53 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBF4DC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:52:53 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id o20so8829070pfp.11 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mz85lM3MNsgaNxHaUhiGB5YmYwpOvI1NblLuzVVsi74=; b=E/rj1/rW1EwGdypeIse8DXXZycqbfWcJBU8Z6TVggfdll6OvXrWbJcGO0s6PNDrjFy WF78aGQTmEh3oYpqyKPlakQOOKU/xKsqCnUWQvHEKZNJxFDQW7auyFqlXdOyTICfYkBd I5EC/XyumkRvmdvL9U8s2YfTHA0ahlFgs7IlE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mz85lM3MNsgaNxHaUhiGB5YmYwpOvI1NblLuzVVsi74=; b=tfy17P4gI0aKBSGDgLqpu3fa3K5lu1WgPu/qiSeLxBFw6xkOzbmmJiZqkHrSspPedH LlUjUjGioht84StVisOypbJiWQa/It6gLJFb+AbeiPt1Fp1fhbUPaNqsqQFaEp0bygSb O1sLsIBq4BYSc4OD8VqoqRIlqpyEfwRZltvJFjl8TNQEaXCANx1+pbs4YMZrJ6yebR3z EQgLktQDqKjOey8DkcaXeZsJNRymMjkrBN9I6XTKfwwUoL0FOiejp3taqGIdurob5/lg gIn5ogNoJRHoJvIVf0JMAf6SWw76X2LFE0C/gg2NB7Yv0a57uTjhYcNcjrGLvmiXCJ6W GH2g== X-Gm-Message-State: AOAM532H23aQV63mAssOQtEQuGWLjB0Ks+fa7dgutpzG2c5SdTeuM3kB NesV0z4bEOxWVOVlzWuCk3UAHy5J4GFYPQ== X-Google-Smtp-Source: ABdhPJyNwZicRhOncWZidW0IshWhLKC0hFakxuzKsMTef8yFTp/dz4b0VZEr9VOSf4V7hJ0Q9I/lag== X-Received: by 2002:aa7:8051:0:b029:13e:d13d:a04e with SMTP id y17-20020aa780510000b029013ed13da04emr5154821pfm.20.1599893570578; Fri, 11 Sep 2020 23:52:50 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id hg16sm3440913pjb.37.2020.09.11.23.52.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 23:52:49 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v5 5/8] adv_monitor: Implement UnregisterMonitor() Date: Fri, 11 Sep 2020 23:51:27 -0700 Message-Id: <20200911235104.BlueZ.v5.5.I335e42ab9a238261c2492c308ce77c959f631483@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.33 / 15.00 / 15.00 X-Rspamd-Queue-Id: 452B2A0B19 X-Rspamd-UID: ed5222 This implements the UnregisterMonitor() method handler of ADV monitor manager interface. The following tests were performed. - Issue a UnregisterMonitor() call with a nonexistent path and expect org.bluez.Error.DoesNotExist as the return. - Issue a UnregisterMonitor() call with a invalid path and expect org.bluez.Error.InvalidArguments as the return. - Issue RegisterMonitor() with a path, issue UnregisterMonitor() and expect a successful method call return. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v1) src/adv_monitor.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index b9bffe9ba..d9c5c7262 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -212,13 +212,48 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, return dbus_message_new_method_return(msg); } +/* Handles UnregisterMonitor D-Bus call */ +static DBusMessage *unregister_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + DBusMessageIter args; + struct app_match_data match; + struct adv_monitor_app *app; + struct btd_adv_monitor_manager *manager = user_data; + + if (!dbus_message_iter_init(msg, &args)) + return btd_error_invalid_args(msg); + + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) + return btd_error_invalid_args(msg); + + dbus_message_iter_get_basic(&args, &match.path); + + if (!strlen(match.path) || !g_str_has_prefix(match.path, "/")) + return btd_error_invalid_args(msg); + + match.owner = dbus_message_get_sender(msg); + + app = queue_find(manager->apps, app_match, &match); + if (!app) + return btd_error_does_not_exist(msg); + + queue_remove(manager->apps, app); + app_destroy(app); + + btd_info(manager->adapter_id, "Path %s removed along with Adv Monitor " + "app %s", match.path, match.owner); + + return dbus_message_new_method_return(msg); +} + static const GDBusMethodTable adv_monitor_methods[] = { { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", GDBUS_ARGS({ "application", "o" }), - NULL, NULL) }, + NULL, unregister_monitor) }, { } }; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8O/UCVtwXF/J7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:53:15 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 0CC9BltwXF8DBQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:53:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7A4ACA0377; Sat, 12 Sep 2020 08:53:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725863AbgILGxH (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:53:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725820AbgILGxG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:53:06 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AF0AC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:53:05 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id z17so230737pgc.4 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:53:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RLAHje7mxdYZVFhm6OOBd+D/Egwin3uGosM21JIKgVI=; b=f2BUGv4XG8xOly4EQ+suED7Nxz1XFP4+LsAdkLCHV1pMPS8Xaqey/L1mJl0xc0vVtx o8igdXXLZiNQ1jE5dN00chMa+I+h5skznJcDib0MXMeLOGYbNsidXX9q4wHUPXebMIuR q2Ko94Alt18p4mhOTtzssWOMZSFzWfiYhyPjM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RLAHje7mxdYZVFhm6OOBd+D/Egwin3uGosM21JIKgVI=; b=N7FsGO1JQcQe7mqvLGJmIlO+0M6/HOAu9zCZ2M9pVkfgAsxLiAIL9ks7iwdeJEY68J wLKHFPnO+8og5KPtvE3uVRDfUN9mysPkh+ki5DpmT4x/wguZ2L67/9dtLlXP5rzWz5G0 SCUZkQZr//tutoFkRspqTHfGyiyLmscvHxwkt77BdY+CuFR2SyRhd2h1zwRdL5y7PFUy PqCQDFBcKFiieIJkPw8tYPYA0MaqacDck0OLJ7Qr2ebt8eTndSfS42F16Ugvf8K0D5gG +usj+Wt0Vz4LUd1G1DVh0ujzsquYuPqe9/dl1D6m40UzZqjHWJPM2S1cqNhAzbmS8MEb Ymxw== X-Gm-Message-State: AOAM532fKKjo3ZCjYmBsLPp0dvRn6PEOwGvmiDfcnn0B6b+zMKStsImS XjxfAt+/YYu211Q7KpD1x/yLAEuOOAY4yQ== X-Google-Smtp-Source: ABdhPJy7dl2yoraHrrg6dnNgElYilg9VMJSr/2OwWaqvuQ7Lfqubd5EjNUmXxSp0VCZsPmolJVlDoQ== X-Received: by 2002:a62:17cd:0:b029:13c:1611:652b with SMTP id 196-20020a6217cd0000b029013c1611652bmr5413095pfx.11.1599893584795; Fri, 11 Sep 2020 23:53:04 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id hg16sm3440913pjb.37.2020.09.11.23.53.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 23:53:04 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v5 6/8] adv_monitor: Handle D-Bus client ready events Date: Fri, 11 Sep 2020 23:51:29 -0700 Message-Id: <20200911235104.BlueZ.v5.6.Id5b1ced1530cb21559bc1dcf29d8764b0c7df825@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.08 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7A4ACA0377 X-Rspamd-UID: 145013 This adds a handler of client ready events. The handler replies to the RegisterMonitor() method call. The following tests were performed. - Call RegisterMonitor() and expect to receive a return. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index d9c5c7262..b42a47b9c 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -123,9 +123,22 @@ static void app_disconnect_cb(DBusConnection *conn, void *user_data) app_destroy(app); } +/* Handles the ready signal of Adv Monitor app */ +static void app_ready_cb(GDBusClient *client, void *user_data) +{ + struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + + btd_info(adapter_id, "Path %s reserved for Adv Monitor app %s", + app->path, app->owner); + + app_reply_msg(app, dbus_message_new_method_return(app->reg)); +} + /* Creates an app object, initiates it and sets D-Bus event handlers */ static struct adv_monitor_app *app_create(DBusConnection *conn, - const char *sender, const char *path, + DBusMessage *msg, const char *sender, + const char *path, struct btd_adv_monitor_manager *manager) { struct adv_monitor_app *app; @@ -150,7 +163,9 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); - g_dbus_client_set_ready_watch(app->client, NULL, NULL); + g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); + + app->reg = dbus_message_ref(msg); return app; } @@ -195,7 +210,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, if (queue_find(manager->apps, app_match, &match)) return btd_error_already_exists(msg); - app = app_create(conn, match.owner, match.path, manager); + app = app_create(conn, msg, match.owner, match.path, manager); if (!app) { btd_error(manager->adapter_id, "Failed to reserve %s for Adv Monitor app %s", @@ -206,10 +221,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg, queue_push_tail(manager->apps, app); - btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s", - match.path, match.owner); - - return dbus_message_new_method_return(msg); + return NULL; } /* Handles UnregisterMonitor D-Bus call */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aIyZHNZqXF/J7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:29:42 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 4E41GdZqXF8T2wAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:29:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2023AA015E; Sat, 12 Sep 2020 08:29:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725817AbgILG32 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:29:28 -0400 Received: from mga17.intel.com ([192.55.52.151]:11160 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbgILG3V (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:29:21 -0400 IronPort-SDR: S7Zxnzcm0J1v/Ppkv+rE21XmFYigHEE9rZHPjP7149CTGt6T3Gm0w3tqXBGnYq0svlspjLfZuo 7UJ2WzdG2YLg== X-IronPort-AV: E=McAfee;i="6000,8403,9741"; a="138912322" X-IronPort-AV: E=Sophos;i="5.76,419,1592895600"; d="scan'208";a="138912322" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 23:24:18 -0700 IronPort-SDR: 3RBHlbSMhJWXoK98XTo0CTn/ZR6oP54jCLpBOYNCNX/Xzf2MCoSea2ILsCscPnrbhB1BRP/lKb y4jmHb7rMYfg== X-IronPort-AV: E=Sophos;i="5.76,419,1592895600"; d="scan'208";a="342519251" Received: from han1-mobl3.jf.intel.com ([10.255.228.79]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 23:24:18 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ 04/17] client: Add SPDX License Identifer Date: Fri, 11 Sep 2020 23:23:44 -0700 Message-Id: <20200912062357.23926-5-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200912062357.23926-1-tedd.an@linux.intel.com> References: <20200912062357.23926-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.26 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2023AA015E X-Rspamd-UID: f9731c From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 9 License: GPL-2.0-or-later client/advertising.h client/display.c client/main.c client/display.h client/agent.h client/gatt.c client/agent.c client/advertising.c client/gatt.h --- client/advertising.c | 1 + client/advertising.h | 1 + client/agent.c | 1 + client/agent.h | 1 + client/display.c | 1 + client/display.h | 1 + client/gatt.c | 1 + client/gatt.h | 1 + client/main.c | 1 + 9 files changed, 9 insertions(+) diff --git a/client/advertising.c b/client/advertising.c index 1aa28e749..2bba5eca5 100644 --- a/client/advertising.c +++ b/client/advertising.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/client/advertising.h b/client/advertising.h index 9967e657b..b2c7a1244 100644 --- a/client/advertising.h +++ b/client/advertising.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/client/agent.c b/client/agent.c index 4def1b478..b1e36e5d1 100644 --- a/client/agent.c +++ b/client/agent.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/client/agent.h b/client/agent.h index 30f302cdc..3ee7526db 100644 --- a/client/agent.h +++ b/client/agent.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/client/display.c b/client/display.c index 05613865b..f3d451ed8 100644 --- a/client/display.c +++ b/client/display.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/client/display.h b/client/display.h index e991d191a..9e416e9f8 100644 --- a/client/display.h +++ b/client/display.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/client/gatt.c b/client/gatt.c index e5bab6dd0..3552491d8 100644 --- a/client/gatt.c +++ b/client/gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/client/gatt.h b/client/gatt.h index 09ca618d3..da347e06d 100644 --- a/client/gatt.h +++ b/client/gatt.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/client/main.c b/client/main.c index da877b546..abe0cf307 100644 --- a/client/main.c +++ b/client/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8C3EGANsXF/J7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:34:43 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WLodFgNsXF/00wEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:34:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EFF2C4096A; Sat, 12 Sep 2020 08:34:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725817AbgILGeg (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:34:36 -0400 Received: from mga17.intel.com ([192.55.52.151]:11516 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgILGe2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:34:28 -0400 IronPort-SDR: Mwnvr9Km4OACPcjO5fASeQk5m6BqLF8KtoCJt6fpY7T4ZTaJOoJRdOdzdYSMzZRSWfe05p3cOj xG2FFlgV1daw== X-IronPort-AV: E=McAfee;i="6000,8403,9741"; a="138912324" X-IronPort-AV: E=Sophos;i="5.76,419,1592895600"; d="scan'208";a="138912324" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 23:24:18 -0700 IronPort-SDR: 3NguPU7YZuKcLIUsoFCwcHXZRgRbz7L4/0r9S7tkuXxfoEU2gvC0uvg1uZ13DIlStJc4Poi614 01E5vEm/9VQg== X-IronPort-AV: E=Sophos;i="5.76,419,1592895600"; d="scan'208";a="342519254" Received: from han1-mobl3.jf.intel.com ([10.255.228.79]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 23:24:18 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ 05/17] emulator: Add SPDX License Identifier Date: Fri, 11 Sep 2020 23:23:45 -0700 Message-Id: <20200912062357.23926-6-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200912062357.23926-1-tedd.an@linux.intel.com> References: <20200912062357.23926-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.26 / 15.00 / 15.00 X-Rspamd-Queue-Id: EFF2C4096A X-Rspamd-UID: b35ce6 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 20 GPL-2.0-or-later : 2 License: LGPL-2.1-or-later emulator/server.c emulator/amp.c emulator/hciemu.c emulator/vhci.c emulator/btdev.c emulator/serial.h emulator/le.h emulator/le.c emulator/main.c emulator/amp.h emulator/hciemu.h emulator/bthost.h emulator/btdev.h emulator/vhci.h emulator/serial.c emulator/phy.c emulator/smp.c emulator/phy.h emulator/bthost.c emulator/server.h License: GPL-2.0-or-later emulator/b1ee.c emulator/hfp.c --- emulator/amp.c | 1 + emulator/amp.h | 1 + emulator/b1ee.c | 1 + emulator/btdev.c | 1 + emulator/btdev.h | 1 + emulator/bthost.c | 1 + emulator/bthost.h | 1 + emulator/hciemu.c | 1 + emulator/hciemu.h | 1 + emulator/hfp.c | 1 + emulator/le.c | 1 + emulator/le.h | 1 + emulator/main.c | 1 + emulator/phy.c | 1 + emulator/phy.h | 1 + emulator/serial.c | 1 + emulator/serial.h | 1 + emulator/server.c | 1 + emulator/server.h | 1 + emulator/smp.c | 1 + emulator/vhci.c | 1 + emulator/vhci.h | 1 + 22 files changed, 22 insertions(+) diff --git a/emulator/amp.c b/emulator/amp.c index 605c6c825..33e6ff476 100644 --- a/emulator/amp.c +++ b/emulator/amp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/amp.h b/emulator/amp.h index 189dfb7d4..0c948a38c 100644 --- a/emulator/amp.h +++ b/emulator/amp.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/b1ee.c b/emulator/b1ee.c index 377181b01..d84b4587f 100644 --- a/emulator/b1ee.c +++ b/emulator/b1ee.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/btdev.c b/emulator/btdev.c index e9c3811f8..05bf76cb2 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/btdev.h b/emulator/btdev.h index a9f71b281..7a6ca9571 100644 --- a/emulator/btdev.h +++ b/emulator/btdev.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/bthost.c b/emulator/bthost.c index 71d5f97bb..40a40ea3c 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/bthost.h b/emulator/bthost.h index 2b347136f..d190d38bc 100644 --- a/emulator/bthost.h +++ b/emulator/bthost.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/hciemu.c b/emulator/hciemu.c index ac861cce2..ef5dc35d5 100644 --- a/emulator/hciemu.c +++ b/emulator/hciemu.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/hciemu.h b/emulator/hciemu.h index 4c8858bb6..5c70aa2fd 100644 --- a/emulator/hciemu.h +++ b/emulator/hciemu.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/hfp.c b/emulator/hfp.c index 29ec63e7d..533f6dbb4 100644 --- a/emulator/hfp.c +++ b/emulator/hfp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/le.c b/emulator/le.c index 1c8ba280b..9980475b3 100644 --- a/emulator/le.c +++ b/emulator/le.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/le.h b/emulator/le.h index 5e832e8e5..7d977292c 100644 --- a/emulator/le.h +++ b/emulator/le.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/main.c b/emulator/main.c index 75cb79c7b..9d613f75b 100644 --- a/emulator/main.c +++ b/emulator/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/phy.c b/emulator/phy.c index beb8bbbe4..0711495fa 100644 --- a/emulator/phy.c +++ b/emulator/phy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/phy.h b/emulator/phy.h index d5efa5180..192bb567b 100644 --- a/emulator/phy.h +++ b/emulator/phy.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/serial.c b/emulator/serial.c index 1c324d531..9ae73f102 100644 --- a/emulator/serial.c +++ b/emulator/serial.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/serial.h b/emulator/serial.h index 4e5a56f88..75aff38cb 100644 --- a/emulator/serial.h +++ b/emulator/serial.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/server.c b/emulator/server.c index c28b15ebf..3fb348ac3 100644 --- a/emulator/server.c +++ b/emulator/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/server.h b/emulator/server.h index bf725e788..a169c4c09 100644 --- a/emulator/server.h +++ b/emulator/server.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/smp.c b/emulator/smp.c index c30de3666..ae06ae9aa 100644 --- a/emulator/smp.c +++ b/emulator/smp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/vhci.c b/emulator/vhci.c index f79b34f46..58ae0a5f8 100644 --- a/emulator/vhci.c +++ b/emulator/vhci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/emulator/vhci.h b/emulator/vhci.h index 1ec7191f8..dcb8860e2 100644 --- a/emulator/vhci.h +++ b/emulator/vhci.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sBOuHwlsXF+o4gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:34:49 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id cI+7HAlsXF++4AAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:34:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7BD174086C; Sat, 12 Sep 2020 08:34:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725821AbgILGeg (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:34:36 -0400 Received: from mga17.intel.com ([192.55.52.151]:11516 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725813AbgILGef (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:34:35 -0400 IronPort-SDR: kjgk45xUeqiRtyn5hbZEYcTQxorjxiUrzjRoBpG4tH8rbJfe97spPP9XIYCbWHp0yUD/8jGVuW 4r1LwVInywyg== X-IronPort-AV: E=McAfee;i="6000,8403,9741"; a="138912320" X-IronPort-AV: E=Sophos;i="5.76,419,1592895600"; d="scan'208";a="138912320" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 23:24:18 -0700 IronPort-SDR: ZGEMZkur2SdI5sFqAHjwra4ZuW1ZANyulrMQKFlUgonsmTbCsEo1w6kbqxKqc5pX4O0u67mhF+ 4tb7Oz/wjp0A== X-IronPort-AV: E=Sophos;i="5.76,419,1592895600"; d="scan'208";a="342519247" Received: from han1-mobl3.jf.intel.com ([10.255.228.79]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 23:24:17 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ 03/17] btio: Add SPDX License Identifier Date: Fri, 11 Sep 2020 23:23:43 -0700 Message-Id: <20200912062357.23926-4-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200912062357.23926-1-tedd.an@linux.intel.com> References: <20200912062357.23926-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.26 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7BD174086C X-Rspamd-UID: 2d3310 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 2 License: GPL-2.0-or-later btio/btio.h btio/btio.c --- btio/btio.c | 1 + btio/btio.h | 1 + 2 files changed, 2 insertions(+) diff --git a/btio/btio.c b/btio/btio.c index 844d6007f..42874e13c 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/btio/btio.h b/btio/btio.h index 23e0ef72b..e15f52a7c 100644 --- a/btio/btio.h +++ b/btio/btio.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qIhPESFtXF+o4gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:39:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SFmwDSFtXF8fTwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:39:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7A304A0B19; Sat, 12 Sep 2020 08:39:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725817AbgILGjW (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:39:22 -0400 Received: from mga17.intel.com ([192.55.52.151]:3839 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725801AbgILGjT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:39:19 -0400 IronPort-SDR: dnMr2K9ooN6tk/NvuDIqJtLdPshi54ap/QeQtscWuxvD4rGKBlzxF9gvoz3y8YaUxBcIlSYWA7 bFLG+C/cG7Eg== X-IronPort-AV: E=McAfee;i="6000,8403,9741"; a="138912337" X-IronPort-AV: E=Sophos;i="5.76,419,1592895600"; d="scan'208";a="138912337" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 23:24:20 -0700 IronPort-SDR: mxyIdSQIgYYzdmcTj+vKz8XNlp2w898qEB8bE2Pc8dq9o4kURN1C/s0gqtvUvs5VczVNHRjpvs 9uk6h76SU+FA== X-IronPort-AV: E=Sophos;i="5.76,419,1592895600"; d="scan'208";a="342519275" Received: from han1-mobl3.jf.intel.com ([10.255.228.79]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 23:24:20 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ 11/17] obexd: Add SPDX License Identifer Date: Fri, 11 Sep 2020 23:23:51 -0700 Message-Id: <20200912062357.23926-12-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200912062357.23926-1-tedd.an@linux.intel.com> References: <20200912062357.23926-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.26 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7A304A0B19 X-Rspamd-UID: dd4b50 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 65 License: GPL-2.0-or-later obexd/src/mimetype.c obexd/src/transport.h obexd/src/server.c obexd/src/obex.c obexd/src/log.h obexd/src/service.h obexd/src/plugin.h obexd/src/plugin.c obexd/src/main.c obexd/src/mimetype.h obexd/src/transport.c obexd/src/obexd.h obexd/src/obex.h obexd/src/obex-priv.h obexd/src/log.c obexd/src/map_ap.h obexd/src/manager.c obexd/src/service.c obexd/src/server.h obexd/src/manager.h obexd/plugins/opp.c obexd/plugins/vcard.h obexd/plugins/pbap.c obexd/plugins/vcard.c obexd/plugins/messages.h obexd/plugins/phonebook.h obexd/plugins/pcsuite.c obexd/plugins/messages-tracker.c obexd/plugins/phonebook-tracker.c obexd/plugins/irmc.c obexd/plugins/ftp.c obexd/plugins/ftp.h obexd/plugins/filesystem.c obexd/plugins/messages-dummy.c obexd/plugins/phonebook-ebook.c obexd/plugins/syncevolution.c obexd/plugins/bluetooth.c obexd/plugins/phonebook-dummy.c obexd/plugins/filesystem.h obexd/plugins/mas.c obexd/client/transport.h obexd/client/opp.c obexd/client/pbap.c obexd/client/transfer.h obexd/client/opp.h obexd/client/driver.c obexd/client/map-event.h obexd/client/bluetooth.h obexd/client/sync.h obexd/client/transport.c obexd/client/pbap.h obexd/client/driver.h obexd/client/transfer.c obexd/client/ftp.c obexd/client/map.h obexd/client/ftp.h obexd/client/bluetooth.c obexd/client/manager.c obexd/client/session.h obexd/client/session.c obexd/client/map.c obexd/client/sync.c obexd/client/map-event.c obexd/client/mns.c obexd/client/manager.h --- obexd/client/bluetooth.c | 1 + obexd/client/bluetooth.h | 1 + obexd/client/driver.c | 1 + obexd/client/driver.h | 1 + obexd/client/ftp.c | 1 + obexd/client/ftp.h | 1 + obexd/client/manager.c | 1 + obexd/client/manager.h | 1 + obexd/client/map-event.c | 1 + obexd/client/map-event.h | 1 + obexd/client/map.c | 1 + obexd/client/map.h | 1 + obexd/client/mns.c | 1 + obexd/client/opp.c | 1 + obexd/client/opp.h | 1 + obexd/client/pbap.c | 1 + obexd/client/pbap.h | 1 + obexd/client/session.c | 1 + obexd/client/session.h | 1 + obexd/client/sync.c | 1 + obexd/client/sync.h | 1 + obexd/client/transfer.c | 1 + obexd/client/transfer.h | 1 + obexd/client/transport.c | 1 + obexd/client/transport.h | 1 + obexd/plugins/bluetooth.c | 1 + obexd/plugins/filesystem.c | 1 + obexd/plugins/filesystem.h | 1 + obexd/plugins/ftp.c | 1 + obexd/plugins/ftp.h | 1 + obexd/plugins/irmc.c | 1 + obexd/plugins/mas.c | 1 + obexd/plugins/messages-dummy.c | 1 + obexd/plugins/messages-tracker.c | 1 + obexd/plugins/messages.h | 1 + obexd/plugins/opp.c | 1 + obexd/plugins/pbap.c | 1 + obexd/plugins/pcsuite.c | 1 + obexd/plugins/phonebook-dummy.c | 1 + obexd/plugins/phonebook-ebook.c | 1 + obexd/plugins/phonebook-tracker.c | 1 + obexd/plugins/phonebook.h | 1 + obexd/plugins/syncevolution.c | 1 + obexd/plugins/vcard.c | 1 + obexd/plugins/vcard.h | 1 + obexd/src/log.c | 1 + obexd/src/log.h | 1 + obexd/src/main.c | 1 + obexd/src/manager.c | 1 + obexd/src/manager.h | 1 + obexd/src/map_ap.h | 1 + obexd/src/mimetype.c | 1 + obexd/src/mimetype.h | 1 + obexd/src/obex-priv.h | 1 + obexd/src/obex.c | 1 + obexd/src/obex.h | 1 + obexd/src/obexd.h | 1 + obexd/src/plugin.c | 1 + obexd/src/plugin.h | 1 + obexd/src/server.c | 1 + obexd/src/server.h | 1 + obexd/src/service.c | 1 + obexd/src/service.h | 1 + obexd/src/transport.c | 1 + obexd/src/transport.h | 1 + 65 files changed, 65 insertions(+) diff --git a/obexd/client/bluetooth.c b/obexd/client/bluetooth.c index 0c043e0ac..d7100a36c 100644 --- a/obexd/client/bluetooth.c +++ b/obexd/client/bluetooth.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/bluetooth.h b/obexd/client/bluetooth.h index 968e131e0..1d1e85c68 100644 --- a/obexd/client/bluetooth.h +++ b/obexd/client/bluetooth.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/driver.c b/obexd/client/driver.c index 0dae35601..773a6efe4 100644 --- a/obexd/client/driver.c +++ b/obexd/client/driver.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/client/driver.h b/obexd/client/driver.h index 0112219d5..a503a1751 100644 --- a/obexd/client/driver.h +++ b/obexd/client/driver.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/client/ftp.c b/obexd/client/ftp.c index 5e30654af..b260dc298 100644 --- a/obexd/client/ftp.c +++ b/obexd/client/ftp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/ftp.h b/obexd/client/ftp.h index 3d9096863..280872bd0 100644 --- a/obexd/client/ftp.h +++ b/obexd/client/ftp.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/manager.c b/obexd/client/manager.c index fbcad6da4..4782203e0 100644 --- a/obexd/client/manager.c +++ b/obexd/client/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/manager.h b/obexd/client/manager.h index e4068de44..d8fed0c83 100644 --- a/obexd/client/manager.h +++ b/obexd/client/manager.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/client/map-event.c b/obexd/client/map-event.c index e164e863c..7b7e227e5 100644 --- a/obexd/client/map-event.c +++ b/obexd/client/map-event.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX diff --git a/obexd/client/map-event.h b/obexd/client/map-event.h index 5414b2621..db7cc0a20 100644 --- a/obexd/client/map-event.h +++ b/obexd/client/map-event.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX diff --git a/obexd/client/map.c b/obexd/client/map.c index 23be2d6b2..e352499a3 100644 --- a/obexd/client/map.c +++ b/obexd/client/map.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/map.h b/obexd/client/map.h index 86f6b9512..eadd8371a 100644 --- a/obexd/client/map.h +++ b/obexd/client/map.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/mns.c b/obexd/client/mns.c index 4912cb90f..47c75c8e1 100644 --- a/obexd/client/mns.c +++ b/obexd/client/mns.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/client/opp.c b/obexd/client/opp.c index 92785f66e..4a08540f7 100644 --- a/obexd/client/opp.c +++ b/obexd/client/opp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/opp.h b/obexd/client/opp.h index a23e94e00..3c727ddd8 100644 --- a/obexd/client/opp.h +++ b/obexd/client/opp.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c index 3f5665fcd..1b1edb1ea 100644 --- a/obexd/client/pbap.c +++ b/obexd/client/pbap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/pbap.h b/obexd/client/pbap.h index ce56258b5..b28a6bf09 100644 --- a/obexd/client/pbap.h +++ b/obexd/client/pbap.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/session.c b/obexd/client/session.c index 5bd2d2670..43e86551e 100644 --- a/obexd/client/session.c +++ b/obexd/client/session.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/session.h b/obexd/client/session.h index b561b7e58..aebc17d21 100644 --- a/obexd/client/session.h +++ b/obexd/client/session.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/sync.c b/obexd/client/sync.c index 548c318c3..90a2bcb0e 100644 --- a/obexd/client/sync.c +++ b/obexd/client/sync.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/sync.h b/obexd/client/sync.h index 8adc5f8d6..2e6e628c7 100644 --- a/obexd/client/sync.h +++ b/obexd/client/sync.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c index b53dffa21..489c03743 100644 --- a/obexd/client/transfer.c +++ b/obexd/client/transfer.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/transfer.h b/obexd/client/transfer.h index b6b835d18..dea9e97ca 100644 --- a/obexd/client/transfer.h +++ b/obexd/client/transfer.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/transport.c b/obexd/client/transport.c index 4cd770672..3467f7001 100644 --- a/obexd/client/transport.c +++ b/obexd/client/transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/client/transport.h b/obexd/client/transport.h index b035cfc45..e9f7d1193 100644 --- a/obexd/client/transport.h +++ b/obexd/client/transport.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c index ba1e0a99a..955616010 100644 --- a/obexd/plugins/bluetooth.c +++ b/obexd/plugins/bluetooth.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c index 48239a8bc..e50338fb3 100644 --- a/obexd/plugins/filesystem.c +++ b/obexd/plugins/filesystem.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/filesystem.h b/obexd/plugins/filesystem.h index f95773beb..397d74673 100644 --- a/obexd/plugins/filesystem.h +++ b/obexd/plugins/filesystem.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c index 3ee18a619..cf58cd3a8 100644 --- a/obexd/plugins/ftp.c +++ b/obexd/plugins/ftp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/ftp.h b/obexd/plugins/ftp.h index f06de8490..8de21ac2c 100644 --- a/obexd/plugins/ftp.h +++ b/obexd/plugins/ftp.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/irmc.c b/obexd/plugins/irmc.c index fcf5340e7..782afb485 100644 --- a/obexd/plugins/irmc.c +++ b/obexd/plugins/irmc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX IrMC Sync Server diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c index f73c3e9d8..ac379d622 100644 --- a/obexd/plugins/mas.c +++ b/obexd/plugins/mas.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c index 3eca9ef4c..63632c9c3 100644 --- a/obexd/plugins/messages-dummy.c +++ b/obexd/plugins/messages-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/messages-tracker.c b/obexd/plugins/messages-tracker.c index 60f3a807e..3d0a20069 100644 --- a/obexd/plugins/messages-tracker.c +++ b/obexd/plugins/messages-tracker.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/messages.h b/obexd/plugins/messages.h index 00a16b1ae..83a45cb43 100644 --- a/obexd/plugins/messages.h +++ b/obexd/plugins/messages.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/opp.c b/obexd/plugins/opp.c index 5bb766770..c0747856f 100644 --- a/obexd/plugins/opp.c +++ b/obexd/plugins/opp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c index d5a3046ae..0dc5e4cfc 100644 --- a/obexd/plugins/pbap.c +++ b/obexd/plugins/pbap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c index 43ab409e9..1b37f3e81 100644 --- a/obexd/plugins/pcsuite.c +++ b/obexd/plugins/pcsuite.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c index 9279ef29a..edcacf420 100644 --- a/obexd/plugins/phonebook-dummy.c +++ b/obexd/plugins/phonebook-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/phonebook-ebook.c b/obexd/plugins/phonebook-ebook.c index c422585df..2230148d6 100644 --- a/obexd/plugins/phonebook-ebook.c +++ b/obexd/plugins/phonebook-ebook.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c index c1d14078b..ea1811786 100644 --- a/obexd/plugins/phonebook-tracker.c +++ b/obexd/plugins/phonebook-tracker.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Phonebook access through D-Bus vCard and call history service * diff --git a/obexd/plugins/phonebook.h b/obexd/plugins/phonebook.h index 70a9cb797..28110a971 100644 --- a/obexd/plugins/phonebook.h +++ b/obexd/plugins/phonebook.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/syncevolution.c b/obexd/plugins/syncevolution.c index 854505a58..32e772a1e 100644 --- a/obexd/plugins/syncevolution.c +++ b/obexd/plugins/syncevolution.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c index dc7c3b3e6..40269f4e2 100644 --- a/obexd/plugins/vcard.c +++ b/obexd/plugins/vcard.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * OBEX Server * diff --git a/obexd/plugins/vcard.h b/obexd/plugins/vcard.h index 22c3f6899..933636fa7 100644 --- a/obexd/plugins/vcard.h +++ b/obexd/plugins/vcard.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * OBEX Server * diff --git a/obexd/src/log.c b/obexd/src/log.c index 8e2ebaab2..769c7183c 100644 --- a/obexd/src/log.c +++ b/obexd/src/log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/log.h b/obexd/src/log.h index d9fb8678f..e0b69bd50 100644 --- a/obexd/src/log.h +++ b/obexd/src/log.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/main.c b/obexd/src/main.c index 139f1412c..462fd796c 100644 --- a/obexd/src/main.c +++ b/obexd/src/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/manager.c b/obexd/src/manager.c index a4af627cb..a3cbd3fa9 100644 --- a/obexd/src/manager.c +++ b/obexd/src/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/manager.h b/obexd/src/manager.h index d709af5a8..ffabd7608 100644 --- a/obexd/src/manager.h +++ b/obexd/src/manager.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/map_ap.h b/obexd/src/map_ap.h index da108fe6e..40664c89d 100644 --- a/obexd/src/map_ap.h +++ b/obexd/src/map_ap.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/mimetype.c b/obexd/src/mimetype.c index c8b040a43..7dac1ee98 100644 --- a/obexd/src/mimetype.c +++ b/obexd/src/mimetype.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/mimetype.h b/obexd/src/mimetype.h index 79529b890..6cba7507b 100644 --- a/obexd/src/mimetype.h +++ b/obexd/src/mimetype.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/obex-priv.h b/obexd/src/obex-priv.h index 355a7f87b..8fe936e0d 100644 --- a/obexd/src/obex-priv.h +++ b/obexd/src/obex-priv.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/obex.c b/obexd/src/obex.c index 2850d3a37..d9b6b93d4 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/obex.h b/obexd/src/obex.h index 67593f11b..5acb333fd 100644 --- a/obexd/src/obex.h +++ b/obexd/src/obex.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/obexd.h b/obexd/src/obexd.h index 42c3c4d97..0f2805c4e 100644 --- a/obexd/src/obexd.h +++ b/obexd/src/obexd.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/plugin.c b/obexd/src/plugin.c index a1962b91d..fcfd0b182 100644 --- a/obexd/src/plugin.c +++ b/obexd/src/plugin.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/plugin.h b/obexd/src/plugin.h index 13d77695f..4d824a4f5 100644 --- a/obexd/src/plugin.h +++ b/obexd/src/plugin.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/server.c b/obexd/src/server.c index db854233b..5e3ed7283 100644 --- a/obexd/src/server.c +++ b/obexd/src/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/server.h b/obexd/src/server.h index 278c35fce..222b2ef80 100644 --- a/obexd/src/server.h +++ b/obexd/src/server.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/service.c b/obexd/src/service.c index c088535e9..faa39329f 100644 --- a/obexd/src/service.c +++ b/obexd/src/service.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/service.h b/obexd/src/service.h index 5d9d325fb..57fc95897 100644 --- a/obexd/src/service.h +++ b/obexd/src/service.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/transport.c b/obexd/src/transport.c index 4984643e2..b6b7f7a61 100644 --- a/obexd/src/transport.c +++ b/obexd/src/transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/transport.h b/obexd/src/transport.h index 97e10d05f..948b97cf2 100644 --- a/obexd/src/transport.h +++ b/obexd/src/transport.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wKnDDjFtXF/J7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:39:45 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iDMGDDFtXF9Y4wAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:39:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3C33DA0B1C; Sat, 12 Sep 2020 08:39:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725821AbgILGji (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:39:38 -0400 Received: from mga17.intel.com ([192.55.52.151]:3861 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725801AbgILGjg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:39:36 -0400 IronPort-SDR: oIQJlD4nSuj0zax8MhVcnaPoc9/QoMIAzYzFC7efvdigga42UwfenWfV3VRd7QfiWxMr6pHVHR +1W5FmGYLf5A== X-IronPort-AV: E=McAfee;i="6000,8403,9741"; a="138912340" X-IronPort-AV: E=Sophos;i="5.76,419,1592895600"; d="scan'208";a="138912340" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 23:24:21 -0700 IronPort-SDR: G+bI7229//KCZTvZtNJzpweY9mRCLgeVspaDTKq8HlH7o63y9+FKngcuC7D8XTX27tqh99uT4N 2qItUSWHOW5g== X-IronPort-AV: E=Sophos;i="5.76,419,1592895600"; d="scan'208";a="342519281" Received: from han1-mobl3.jf.intel.com ([10.255.228.79]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 23:24:20 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ 13/17] plugins: Add SPDX License Identifer Date: Fri, 11 Sep 2020 23:23:53 -0700 Message-Id: <20200912062357.23926-14-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200912062357.23926-1-tedd.an@linux.intel.com> References: <20200912062357.23926-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.91 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3C33DA0B1C X-Rspamd-UID: 5f5f4d From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 7 License: GPL-2.0-or-later plugins/autopair.c plugins/hostname.c plugins/neard.c plugins/policy.c plugins/sixaxis.c plugins/wiimote.c plugins/external-dummy.c --- plugins/autopair.c | 1 + plugins/external-dummy.c | 1 + plugins/hostname.c | 1 + plugins/neard.c | 1 + plugins/policy.c | 1 + plugins/sixaxis.c | 1 + plugins/wiimote.c | 1 + 7 files changed, 7 insertions(+) diff --git a/plugins/autopair.c b/plugins/autopair.c index 3089430a8..381d91c8f 100644 --- a/plugins/autopair.c +++ b/plugins/autopair.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/external-dummy.c b/plugins/external-dummy.c index 536ad0663..78377b021 100644 --- a/plugins/external-dummy.c +++ b/plugins/external-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/hostname.c b/plugins/hostname.c index 4f9dfe6d8..32f15b3a5 100644 --- a/plugins/hostname.c +++ b/plugins/hostname.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/neard.c b/plugins/neard.c index 6ffcd6e10..1fefc5015 100644 --- a/plugins/neard.c +++ b/plugins/neard.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/policy.c b/plugins/policy.c index de51e58b9..86eb25ee9 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c index 939fed759..8350d63f8 100644 --- a/plugins/sixaxis.c +++ b/plugins/sixaxis.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/wiimote.c b/plugins/wiimote.c index 0ced27514..9441a7681 100644 --- a/plugins/wiimote.c +++ b/plugins/wiimote.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KDFPKrBvXF/J7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:50:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6FAYJ7BvXF8lRwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:50:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 748F3A0377; Sat, 12 Sep 2020 08:50:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725814AbgILGuR (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:50:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgILGuR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:50:17 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BAB7C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:50:17 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id 7so7975642pgm.11 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2F5IK3qZINJFDEk93oe4o+MOz1G8iOkBit6CICWcYW8=; b=knx/vDdp2ikbYFIZuV4k+QJjodS/ahJZgTZuC6ePrx+RE8wliaRTR0Sv1KWnC4uJP2 IvJeb4eycDhGl2bNtaS8F6STBD814f+wH3ivLAXA7kfQaJ3PZVwo0OockY8gX6S79GCT 51yINhH1loU8M9W1VNjkffK7D7ERZKRRAVomA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2F5IK3qZINJFDEk93oe4o+MOz1G8iOkBit6CICWcYW8=; b=b1BzezFiSmu1jLbTRYm2prRYYCBbr08JSb7u7a5w42oGDCXwEbusJVCL1w8Ge2ITEX fX6tTEk59R2IQjcLKbqyAK3T7efu5FQT+3LtO5yv8qU7YiX97sXDYyNuTTigftdpx6Go ngtBiNqfgF/YFRVekyhjQC4PIexu9oOVTHzX6Y7mgIRX42HSscRyxsYQtHZ5EIQOcxp2 JbjrWIixxDYIai1s/RczhxDpfoSBJhEH/jbDXK0rogXEDjLVLpG0OOR37tT6I4bPtrdQ 0tfqVM8FAfD+bRc5xKwQtkLGEGOZVC1y/lbttDZsqPKey2ILJq22OsWK2D947hEnTuLB CnDw== X-Gm-Message-State: AOAM533FPesJUrCsCUDCQ93XZqVxSv2QHePVXquUqmDp7adjzzcfBDiy G6zMy52XEiKVEVoO2123+v0sl4500uzbMA== X-Google-Smtp-Source: ABdhPJwnG3zZJKY82hnEz5p5VNCCWg7/+GghC3lXTlEp/0Shd3k2Df2kpKDe8ZEJ5u87sGhTaISprA== X-Received: by 2002:aa7:9592:0:b029:13e:d13d:a054 with SMTP id z18-20020aa795920000b029013ed13da054mr5286825pfj.26.1599893415956; Fri, 11 Sep 2020 23:50:15 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id 131sm4162467pfc.20.2020.09.11.23.50.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 23:50:15 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v5 1/8] adapter: Remove indirect dependency of headers Date: Fri, 11 Sep 2020 23:49:59 -0700 Message-Id: <20200911234949.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.73 / 15.00 / 15.00 X-Rspamd-Queue-Id: 748F3A0377 X-Rspamd-UID: 5e6497 Given that adapter.h refers symbols from lib/bluetooth.h and lib/sdp.h, these two headers should be included directly in adapter.h. Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adapter.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..c70a7b0da 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -26,6 +26,9 @@ #include <dbus/dbus.h> #include <glib.h> +#include <lib/bluetooth.h> +#include <lib/sdp.h> + #define MAX_NAME_LENGTH 248 /* Invalid SSP passkey value used to indicate negative replies */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id COxbMsZvXF/LHgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:50:46 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oBDFL8ZvXF93ugEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:50:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 75A70A0AAE; Sat, 12 Sep 2020 08:50:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725823AbgILGuj (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:50:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgILGui (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:50:38 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EAFEC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:50:38 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id s65so6926111pgb.0 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6NkIUnCBg/W8FDg9bJf6d5T8R+Lpd4X8IBezpCyIGhk=; b=K72CKhJq0knAwZpQEG9H1GmylENRstHAaG9XcrLIjxX73+IgJzUhpU9hOh9p5CWd3D zGlejHonbgGmI5Tx5D6JwJNBryZXzaRW19aPlHywgSQqnxrF3rSYn7OmZ5cIsPdsk3+b OmMohJc6fUX7xiMUloKqZKZJehGGX8AFy91JY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6NkIUnCBg/W8FDg9bJf6d5T8R+Lpd4X8IBezpCyIGhk=; b=Pg+iieSPpsn+CKQRRO51W1/WDUl/+XzRIOLOR6k0ZX8Rvzb7k/p0m9FqyeAfuZwOJK 8Dn2Z85vR1QP4yWRtvMMyS1mXraG437zicbOs4t3CGyS2UJVxXJJNb9WOSIrep3Ud+I1 tBTa7Mex7tLHq4m5e9RkXhcfEuN/bWmBCnu9WzKAjxIERWUUqecmw5f2wrAg5zGa/KjB WDxeMcV5SF6RhRoqqpXf5W9bjmPIZXyvfqZi5uruv+hXWQkLd6Oqvt1I/YI5YpddKNkD b1xozyqTKlzEM36fMDcTKZmPZo+1ZaU1wbhCMyt5krOKOjFzBsMVWvMId7FO8u27Wx+X BFsw== X-Gm-Message-State: AOAM533omLqRi4tbyJPezr2ZcdLJcv2wZWlAXqdjzZwAKLg1DvF2WS8f NCZn9ZxGa25BgAeXsvitqmlRwTbU6DGwHA== X-Google-Smtp-Source: ABdhPJyObEj4fifAF05XHAAWoBOSQdEPZZ3GkE7MoC+k48iCN0EPi1A7sP5hWknXTQBqf6NMOOUVHg== X-Received: by 2002:a63:c705:: with SMTP id n5mr4099523pgg.19.1599893437357; Fri, 11 Sep 2020 23:50:37 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id 131sm4162467pfc.20.2020.09.11.23.50.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 23:50:36 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v5 2/8] PRE-UPSTREAM: adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Date: Fri, 11 Sep 2020 23:50:01 -0700 Message-Id: <20200911234949.BlueZ.v5.2.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200911234949.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200911234949.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: 75A70A0AAE X-Rspamd-UID: 0216a0 This introduces the org.bluez.AdvertisementMonitorManager1 without implementing handlers of methods and properties. The following test was performed. - Upon adapter registration, the info line of creating an ADV monitor manager gets printed, and system bus emits the interface events of org.bluez.AdvertisementMonitorManager1. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- (no changes since v4) Changes in v4: -Create the Adv Monitor Manager only if the experimental flag is in place and mark all properties and methods experimental. Changes in v2: -Use new0 instead of g_new0 -Remove the reset of manager members -Make methods/property experimental Makefile.am | 3 +- src/adapter.c | 23 ++++++++ src/adv_monitor.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++ src/adv_monitor.h | 32 ++++++++++ 4 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 src/adv_monitor.c create mode 100644 src/adv_monitor.h diff --git a/Makefile.am b/Makefile.am index 725fbe48d..22b4fa30c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -293,7 +293,8 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ src/gatt-client.h src/gatt-client.c \ src/device.h src/device.c \ src/dbus-common.c src/dbus-common.h \ - src/eir.h src/eir.c + src/eir.h src/eir.c \ + src/adv_monitor.h src/adv_monitor.c src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ gdbus/libgdbus-internal.la \ src/libshared-glib.la \ diff --git a/src/adapter.c b/src/adapter.c index 1435e2bd7..df628a7fd 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -77,6 +77,7 @@ #include "attrib-server.h" #include "gatt-database.h" #include "advertising.h" +#include "adv_monitor.h" #include "eir.h" #define ADAPTER_INTERFACE "org.bluez.Adapter1" @@ -272,6 +273,8 @@ struct btd_adapter { struct btd_gatt_database *database; struct btd_adv_manager *adv_manager; + struct btd_adv_monitor_manager *adv_monitor_manager; + gboolean initialized; GSList *pin_callbacks; @@ -6360,6 +6363,9 @@ static void adapter_remove(struct btd_adapter *adapter) btd_adv_manager_destroy(adapter->adv_manager); adapter->adv_manager = NULL; + btd_adv_monitor_manager_destroy(adapter->adv_monitor_manager); + adapter->adv_monitor_manager = NULL; + g_slist_free(adapter->pin_callbacks); adapter->pin_callbacks = NULL; @@ -8633,6 +8639,23 @@ static int adapter_register(struct btd_adapter *adapter) adapter->adv_manager = btd_adv_manager_new(adapter, adapter->mgmt); + if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) { + if (adapter->supported_settings & MGMT_SETTING_LE) { + adapter->adv_monitor_manager = + btd_adv_monitor_manager_create(adapter, + adapter->mgmt); + if (!adapter->adv_monitor_manager) { + btd_error(adapter->dev_id, + "Failed to create Adv Monitor " + "Manager for adapter"); + return -EINVAL; + } + } else { + btd_info(adapter->dev_id, "Adv Monitor Manager " + "skipped, LE unavailable"); + } + } + db = btd_gatt_database_get_db(adapter->database); adapter->db_id = gatt_db_register(db, services_modified, services_modified, diff --git a/src/adv_monitor.c b/src/adv_monitor.c new file mode 100644 index 000000000..ad3f64cbe --- /dev/null +++ b/src/adv_monitor.c @@ -0,0 +1,147 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdint.h> + +#include <glib.h> +#include <dbus/dbus.h> +#include <gdbus/gdbus.h> + +#include "adapter.h" +#include "dbus-common.h" +#include "log.h" +#include "src/shared/mgmt.h" +#include "src/shared/util.h" + +#include "adv_monitor.h" + +#define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" + +struct btd_adv_monitor_manager { + struct btd_adapter *adapter; + struct mgmt *mgmt; + uint16_t adapter_id; +}; + +static const GDBusMethodTable adv_monitor_methods[] = { + { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", + GDBUS_ARGS({ "application", "o" }), + NULL, NULL) }, + { } +}; + +static const GDBusPropertyTable adv_monitor_properties[] = { + {"SupportedMonitorTypes", "as", NULL, NULL, NULL, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, + {"SupportedFeatures", "as", NULL, NULL, NULL, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, + { } +}; + +/* Allocates a manager object */ +static struct btd_adv_monitor_manager *manager_new( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + if (!adapter || !mgmt) + return NULL; + + manager = new0(struct btd_adv_monitor_manager, 1); + if (!manager) + return NULL; + + manager->adapter = adapter; + manager->mgmt = mgmt_ref(mgmt); + manager->adapter_id = btd_adapter_get_index(adapter); + + return manager; +} + +/* Frees a manager object */ +static void manager_free(struct btd_adv_monitor_manager *manager) +{ + mgmt_unref(manager->mgmt); + + free(manager); +} + +/* Destroys a manager object and unregisters its D-Bus interface */ +static void manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + g_dbus_unregister_interface(btd_get_dbus_connection(), + adapter_get_path(manager->adapter), + ADV_MONITOR_MGR_INTERFACE); + + manager_free(manager); +} + +/* Creates a manager and registers its D-Bus interface */ +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt) +{ + struct btd_adv_monitor_manager *manager; + + manager = manager_new(adapter, mgmt); + if (!manager) + return NULL; + + if (!g_dbus_register_interface(btd_get_dbus_connection(), + adapter_get_path(manager->adapter), + ADV_MONITOR_MGR_INTERFACE, + adv_monitor_methods, NULL, + adv_monitor_properties, manager, + NULL)) { + btd_error(manager->adapter_id, + "Failed to register " + ADV_MONITOR_MGR_INTERFACE); + manager_free(manager); + return NULL; + } + + btd_info(manager->adapter_id, + "Adv Monitor Manager created for adapter %s", + adapter_get_path(manager->adapter)); + + return manager; +} + +/* Destroys a manager and unregisters its D-Bus interface */ +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) +{ + if (!manager) + return; + + btd_info(manager->adapter_id, "Destroy Adv Monitor Manager"); + + manager_destroy(manager); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h new file mode 100644 index 000000000..69ea348f8 --- /dev/null +++ b/src/adv_monitor.h @@ -0,0 +1,32 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifndef __ADV_MONITOR_H +#define __ADV_MONITOR_H + +struct mgmt; +struct btd_adapter; +struct btd_adv_monitor_manager; + +struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( + struct btd_adapter *adapter, + struct mgmt *mgmt); +void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); + +#endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8CYmNvxvXF/J7QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:51:40 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id KG76MvxvXF93ugEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:51:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C7BBDA015E; Sat, 12 Sep 2020 08:51:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725836AbgILGvc (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgILGv0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:51:26 -0400 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD8BBC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:51:25 -0700 (PDT) Received: by mail-qv1-xf32.google.com with SMTP id q10so6373507qvs.1 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:51:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=W0otCJb0t2exDZa01G6rEt6eaiFdxQucf1NvvEpIOI8=; b=O9b9GbDHEF1+xpCqb9iWvbaaLMQLrMtAcl38JqT9OHj4evlbCVZTo2+I9NTag9eFwr EM+FhoKKe0FPJu5rPdFxPuE2HafN8sEWHeNED9mH2mTHCsDhdt8Q7SaLdRaxFQF0AKUs CWIKDNVFRjztfWbNoH9okvQf5Y6HewZZ0vn59Z4RL9vitum6uSxEHvdUerBf8cmRiVs4 kafo01kQYGBRX7G45aKfz73UFF+UspidGi30f/h3wD7kXYsTnuY3NcukAtVNazrTSBCW mkori1MIYjzE0izkD758mebymITi5ohKjasoNZBmAvIqahcDCY4pWoOeCSln7IRCigiU v98A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=W0otCJb0t2exDZa01G6rEt6eaiFdxQucf1NvvEpIOI8=; b=EcKtu9tPGC0DM3COg/oSZ5OOh0m8SghiDFplYU7XYeepmbCzbVquvaWky4Lax6/fiD hEN3+KPfArLqqyQ/+zrxnmLITM+lOuzw65/pRU7X74D3xzpf8fJjZ5ZLLCzAKuoZUPJD 69YH41YZCw2qkciAzYMdcCXJotO87w/4fZ8HYXakJzyinSiyG/bBhmz4LMLcukwdl7N4 yHkB/r8v5aQ6SejX/9FrSO4idJ9PeO8g7H5q+EkJ4Kr16Mq7TVWnbuX3FVP0aJBHn14r 4XL0m4L9JIRGAQ8RgugTz0UD4GWXp+4dQCnreqDqOppQi6xT5j0h1bt9FVzt0H+lI3Pf O8Rg== X-Gm-Message-State: AOAM531KMOcOGYjMADagSGBxCrnn3x5Vli3lDjmJmmbxsbQTVWWjDhed n8+Meo2bXVZkkxjiN0CRd20yGrdsSqIYlQ== X-Google-Smtp-Source: ABdhPJyA/54hdT1Q81HZ2cRvVceHyoaGIO4Y7UCb8ruDWGs0bTZZ3LrCHC5NQQrE/W4fuXMTuMWhCw== X-Received: by 2002:a0c:e5cf:: with SMTP id u15mr5296017qvm.14.1599893484257; Fri, 11 Sep 2020 23:51:24 -0700 (PDT) Received: from [172.17.0.2] ([40.84.17.224]) by smtp.gmail.com with ESMTPSA id r34sm6310970qtr.18.2020.09.11.23.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 23:51:23 -0700 (PDT) Message-ID: <5f5c6feb.1c69fb81.ac4d3.0c03@mx.google.com> Date: Fri, 11 Sep 2020 23:51:23 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============6419365277445898984==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, tedd.an@linux.intel.com Subject: RE: [BlueZ,04/17] client: Add SPDX License Identifer Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200912062357.23926-5-tedd.an@linux.intel.com> References: <20200912062357.23926-5-tedd.an@linux.intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ****** X-Rspamd-Score: 8.18 / 15.00 / 15.00 X-Rspamd-Queue-Id: C7BBDA015E X-Rspamd-UID: e22ec1 --===============6419365277445898984== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'client/advertising.h', please use '/*' instead #38: FILE: client/advertising.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #38: FILE: client/advertising.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'client/agent.h', please use '/*' instead #56: FILE: client/agent.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #56: FILE: client/agent.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'client/display.h', please use '/*' instead #74: FILE: client/display.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #74: FILE: client/display.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'client/gatt.h', please use '/*' instead #92: FILE: client/gatt.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #92: FILE: client/gatt.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later - total: 0 errors, 8 warnings, 36 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============6419365277445898984==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4PSoHWtwXF/LHgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:53:31 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EHGlGmtwXF93ugEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:53:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 073F7A0B19; Sat, 12 Sep 2020 08:53:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725805AbgILGxY (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:53:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbgILGxW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:53:22 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88D1FC061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:53:22 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id a9so2795593pjg.1 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:53:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aY3276GneRydqPoayVEg0zkMPiEA/HmAsJVn7x9OMvE=; b=D+pwM4xjt7QIwsqbgwzGugZ70IWH32rFptqffYeT4rJ5GD1EG/pSsBg1k+WKEfI2xS fRhaSO+Fs/N1i6194m6DdQBpEelxKLkS5TNUf3iq5OxHoxNJ+bVOv8rBB+fOkmgtqAxn /+GLHU5jHVxvIfH/ajHyBDV5sjjCB/1d+qFjE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aY3276GneRydqPoayVEg0zkMPiEA/HmAsJVn7x9OMvE=; b=oWnsS97u/sKEew8X59Afp8tm5HdHHv+RhOdlsZCpzNugz6Mr0k8L0W3+pQ4DmBShfT DaOjc4E2Hb20LrZ5Q4hMOax8IphYnCheS2XCFainTS9YHE91xJf2mwPobVQIE9UDOSZp crZw0lcJ3kayFMYqLOmPTR+fmRRNV1b84+tPAHaWrPdwVnu6ia+cAzCIS3+XQtTBQjnR /9CcuyUYzlESa8+NVBnUmEV6jPYf00L5km33zjIWWdSluLJ2+jalq4t3nbHj8Y14yn8a JVZAkRK+VyPcPGAm/WApBWHe6VbSuiM8t4q4iXvOxOi1vcTBAmNB4xVM8u8bcw7rG7Tn C/vA== X-Gm-Message-State: AOAM5309tjcAjfrmWpfISPDczNDeEjzR/JGonFd0TKzlZOIj4HQ8adg9 aMTa2/LKZBh8XVTv3rTJn7905xkaXKEr/A== X-Google-Smtp-Source: ABdhPJzmprcmtflnB2iIzbuO7KT9Lp16lx8ycpkIQLxb30m45O9fDpzau94whc/kaHSmphQbvz6Hcw== X-Received: by 2002:a17:90a:120f:: with SMTP id f15mr5492928pja.120.1599893601564; Fri, 11 Sep 2020 23:53:21 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id hg16sm3440913pjb.37.2020.09.11.23.53.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 23:53:20 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v5 7/8] adv_monitor: Handle D-Bus proxy event of an ADV monitor Date: Fri, 11 Sep 2020 23:51:31 -0700 Message-Id: <20200911235104.BlueZ.v5.7.I47744c7eef31f44cf393dea2b3e437d7b41cef79@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.08 / 15.00 / 15.00 X-Rspamd-Queue-Id: 073F7A0B19 X-Rspamd-UID: 1aa115 This adds two handlers, one for adding and one for removing, of D-Bus proxy events. The handler of property changes is set to NULL as intended, since for simplicity no further changes on monitor's properties would affect the ongoing monitoring. The following test steps were performed with bluetoothctl. - After registering the root path, expose two monitors and verify that the proxy added event are received. - Have two monitors added, unexpose the monitors, and verify that the proxy removed events are received for those two monitors. - Have two monitors added, unregister the monitors and verify that the proxy removed events are received for those two monitors. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v5: - Removed unused variable and added parentheses - Use g_strcmp0() instead of strcmp() due to const char * Changes in v2: - Use new0() instead of g_new0() - Remove the reset of monitor members - Use memcpy() instead of g_memmove() src/adv_monitor.c | 487 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 474 insertions(+), 13 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index b42a47b9c..737da1c90 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -37,14 +37,23 @@ #include "dbus-common.h" #include "log.h" #include "src/error.h" +#include "src/shared/ad.h" #include "src/shared/mgmt.h" #include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" +#define ADV_MONITOR_UNSET_RSSI 127 /* dBm */ +#define ADV_MONITOR_MAX_RSSI 20 /* dBm */ +#define ADV_MONITOR_MIN_RSSI -127 /* dBm */ +#define ADV_MONITOR_UNSET_TIMER 0 /* second */ +#define ADV_MONITOR_MIN_TIMER 1 /* second */ +#define ADV_MONITOR_MAX_TIMER 300 /* second */ + struct btd_adv_monitor_manager { struct btd_adapter *adapter; struct mgmt *mgmt; @@ -65,6 +74,43 @@ struct adv_monitor_app { DBusMessage *reg; GDBusClient *client; + + struct queue *monitors; +}; + +enum monitor_type { + MONITOR_TYPE_NONE, + MONITOR_TYPE_OR_PATTERNS, +}; + +enum monitor_state { + MONITOR_STATE_NEW, /* New but not yet init'ed with actual values */ + MONITOR_STATE_FAILED, /* Failed to be init'ed */ + MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ + MONITOR_STATE_HONORED, /* Accepted by kernel */ +}; + +struct pattern { + uint8_t ad_type; + uint8_t offset; + uint8_t length; + uint8_t value[BT_AD_MAX_DATA_LEN]; +}; + +struct adv_monitor { + struct adv_monitor_app *app; + GDBusProxy *proxy; + char *path; + + enum monitor_state state; /* MONITOR_STATE_* */ + + int8_t high_rssi; /* high RSSI threshold */ + uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ + int8_t low_rssi; /* low RSSI threshold */ + uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ + + enum monitor_type type; /* MONITOR_TYPE_* */ + struct queue *patterns; }; struct app_match_data { @@ -72,6 +118,14 @@ struct app_match_data { const char *path; }; +const struct adv_monitor_type { + enum monitor_type type; + const char *name; +} supported_types[] = { + { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, + { }, +}; + /* Replies to an app's D-Bus message and unref it */ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) { @@ -83,6 +137,48 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) app->reg = NULL; } +/* Frees a pattern */ +static void pattern_free(void *data) +{ + struct pattern *pattern = data; + + if (!pattern) + return; + + free(pattern); +} + +/* Frees a monitor object */ +static void monitor_free(void *data) +{ + struct adv_monitor *monitor = data; + + if (!monitor) + return; + + g_dbus_proxy_unref(monitor->proxy); + g_free(monitor->path); + + queue_destroy(monitor->patterns, pattern_free); + + free(monitor); +} + +/* Calls Release() method of the remote Adv Monitor */ +static void monitor_release(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + + if (!monitor) + return; + + DBG("Calling Release() on Adv Monitor of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "Release", NULL, NULL, NULL, + NULL); +} + /* Destroys an app object along with related D-Bus handlers */ static void app_destroy(void *data) { @@ -93,6 +189,9 @@ static void app_destroy(void *data) DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); + queue_foreach(app->monitors, monitor_release, NULL); + queue_destroy(app->monitors, monitor_free); + if (app->reg) { app_reply_msg(app, btd_error_failed(app->reg, "Adv Monitor app destroyed")); @@ -135,6 +234,371 @@ static void app_ready_cb(GDBusClient *client, void *user_data) app_reply_msg(app, dbus_message_new_method_return(app->reg)); } +/* Allocates an Adv Monitor */ +static struct adv_monitor *monitor_new(struct adv_monitor_app *app, + GDBusProxy *proxy) +{ + struct adv_monitor *monitor; + + if (!app || !proxy) + return NULL; + + monitor = new0(struct adv_monitor, 1); + if (!monitor) + return NULL; + + monitor->app = app; + monitor->proxy = g_dbus_proxy_ref(proxy); + monitor->path = g_strdup(g_dbus_proxy_get_path(proxy)); + + monitor->state = MONITOR_STATE_NEW; + + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + + monitor->type = MONITOR_TYPE_NONE; + monitor->patterns = NULL; + + return monitor; +} + +/* Matches a monitor based on its D-Bus path */ +static bool monitor_match(const void *a, const void *b) +{ + const GDBusProxy *proxy = b; + const struct adv_monitor *monitor = a; + + if (!proxy || !monitor) + return false; + + if (g_strcmp0(g_dbus_proxy_get_path(proxy), monitor->path) != 0) + return false; + + return true; +} + +/* Retrieves Type from the remote Adv Monitor object, verifies the value and + * update the local Adv Monitor + */ +static bool parse_monitor_type(struct adv_monitor *monitor, const char *path) +{ + DBusMessageIter iter; + const struct adv_monitor_type *t; + const char *type_str; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (!g_dbus_proxy_get_property(monitor->proxy, "Type", &iter)) { + btd_error(adapter_id, "Failed to retrieve property Type from " + "the Adv Monitor at path %s", path); + return false; + } + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + goto failed; + + dbus_message_iter_get_basic(&iter, &type_str); + + for (t = supported_types; t->name; t++) { + if (strcmp(t->name, type_str) == 0) { + monitor->type = t->type; + return true; + } + } + +failed: + btd_error(adapter_id, "Invalid argument of property Type of the Adv " + "Monitor at path %s", path); + + return false; +} + +/* Retrieves RSSIThresholdsAndTimers from the remote Adv Monitor object, + * verifies the values and update the local Adv Monitor + */ +static bool parse_rssi_and_timeout(struct adv_monitor *monitor, + const char *path) +{ + DBusMessageIter prop_struct, iter; + int16_t h_rssi, l_rssi; + uint16_t h_rssi_timer, l_rssi_timer; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + /* Property RSSIThresholdsAndTimers is optional */ + if (!g_dbus_proxy_get_property(monitor->proxy, + "RSSIThresholdsAndTimers", + &prop_struct)) { + DBG("Adv Monitor at path %s provides no RSSI thresholds and " + "timeouts", path); + return true; + } + + if (dbus_message_iter_get_arg_type(&prop_struct) != DBUS_TYPE_STRUCT) + goto failed; + + dbus_message_iter_recurse(&prop_struct, &iter); + + /* Extract HighRSSIThreshold */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) + goto failed; + dbus_message_iter_get_basic(&iter, &h_rssi); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract HighRSSIThresholdTimer */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) + goto failed; + dbus_message_iter_get_basic(&iter, &h_rssi_timer); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract LowRSSIThreshold */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT16) + goto failed; + dbus_message_iter_get_basic(&iter, &l_rssi); + if (!dbus_message_iter_next(&iter)) + goto failed; + + /* Extract LowRSSIThresholdTimer */ + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT16) + goto failed; + dbus_message_iter_get_basic(&iter, &l_rssi_timer); + + /* Verify the values of RSSIs and their timers. For simplicity, we + * enforce the all-or-none rule to these fields. In other words, either + * all are set to the unset values or all are set within valid ranges. + */ + if (h_rssi == ADV_MONITOR_UNSET_RSSI && + l_rssi == ADV_MONITOR_UNSET_RSSI && + h_rssi_timer == ADV_MONITOR_UNSET_TIMER && + l_rssi_timer == ADV_MONITOR_UNSET_TIMER) { + goto done; + } + + if (h_rssi < ADV_MONITOR_MIN_RSSI || h_rssi > ADV_MONITOR_MAX_RSSI || + l_rssi < ADV_MONITOR_MIN_RSSI || + l_rssi > ADV_MONITOR_MAX_RSSI || h_rssi <= l_rssi) { + goto failed; + } + + if (h_rssi_timer < ADV_MONITOR_MIN_TIMER || + h_rssi_timer > ADV_MONITOR_MAX_TIMER || + l_rssi_timer < ADV_MONITOR_MIN_TIMER || + l_rssi_timer > ADV_MONITOR_MAX_TIMER) { + goto failed; + } + + monitor->high_rssi = h_rssi; + monitor->low_rssi = l_rssi; + monitor->high_rssi_timeout = h_rssi_timer; + monitor->low_rssi_timeout = l_rssi_timer; + +done: + DBG("Adv Monitor at %s initiated with high RSSI threshold %d, high " + "RSSI threshold timeout %d, low RSSI threshold %d, low RSSI " + "threshold timeout %d", path, monitor->high_rssi, + monitor->high_rssi_timeout, monitor->low_rssi, + monitor->low_rssi_timeout); + + return true; + +failed: + monitor->high_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; + monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + + btd_error(adapter_id, "Invalid argument of property " + "RSSIThresholdsAndTimers of the Adv Monitor at path %s", + path); + + return false; +} + +/* Retrieves Patterns from the remote Adv Monitor object, verifies the values + * and update the local Adv Monitor + */ +static bool parse_patterns(struct adv_monitor *monitor, const char *path) +{ + DBusMessageIter array, array_iter; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (!g_dbus_proxy_get_property(monitor->proxy, "Patterns", &array)) { + btd_error(adapter_id, "Failed to retrieve property Patterns " + "from the Adv Monitor at path %s", path); + return false; + } + + monitor->patterns = queue_new(); + + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY || + dbus_message_iter_get_element_type(&array) != + DBUS_TYPE_STRUCT) { + goto failed; + } + + dbus_message_iter_recurse(&array, &array_iter); + + while (dbus_message_iter_get_arg_type(&array_iter) == + DBUS_TYPE_STRUCT) { + int value_len; + uint8_t *value; + uint8_t offset, ad_type; + struct pattern *pattern; + DBusMessageIter struct_iter, value_iter; + + dbus_message_iter_recurse(&array_iter, &struct_iter); + + // Extract start position + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_BYTE) { + goto failed; + } + dbus_message_iter_get_basic(&struct_iter, &offset); + if (!dbus_message_iter_next(&struct_iter)) + goto failed; + + // Extract AD data type + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_BYTE) { + goto failed; + } + dbus_message_iter_get_basic(&struct_iter, &ad_type); + if (!dbus_message_iter_next(&struct_iter)) + goto failed; + + // Extract value of a pattern + if (dbus_message_iter_get_arg_type(&struct_iter) != + DBUS_TYPE_ARRAY) { + goto failed; + } + dbus_message_iter_recurse(&struct_iter, &value_iter); + dbus_message_iter_get_fixed_array(&value_iter, &value, + &value_len); + + // Verify the values + if (offset > BT_AD_MAX_DATA_LEN - 1) + goto failed; + + if ((ad_type > BT_AD_3D_INFO_DATA && + ad_type != BT_AD_MANUFACTURER_DATA) || + ad_type < BT_AD_FLAGS) { + goto failed; + } + + if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) + goto failed; + + pattern = new0(struct pattern, 1); + if (!pattern) + goto failed; + + pattern->ad_type = ad_type; + pattern->offset = offset; + pattern->length = value_len; + memcpy(pattern->value, value, pattern->length); + + queue_push_tail(monitor->patterns, pattern); + + dbus_message_iter_next(&array_iter); + } + + /* There must be at least one pattern. */ + if (queue_isempty(monitor->patterns)) + goto failed; + + return true; + +failed: + queue_destroy(monitor->patterns, pattern_free); + monitor->patterns = NULL; + + btd_error(adapter_id, "Invalid argument of property Patterns of the " + "Adv Monitor at path %s", path); + + return false; +} + +/* Processes the content of the remote Adv Monitor */ +static bool monitor_process(struct adv_monitor *monitor, + struct adv_monitor_app *app) +{ + const char *path = g_dbus_proxy_get_path(monitor->proxy); + + monitor->state = MONITOR_STATE_FAILED; + + if (!parse_monitor_type(monitor, path)) + goto done; + + if (!parse_rssi_and_timeout(monitor, path)) + goto done; + + if (monitor->type == MONITOR_TYPE_OR_PATTERNS && + parse_patterns(monitor, path)) { + monitor->state = MONITOR_STATE_INITED; + } + +done: + return monitor->state != MONITOR_STATE_FAILED; +} + +/* Handles an Adv Monitor D-Bus proxy added event */ +static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) +{ + struct adv_monitor *monitor; + struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + const char *path = g_dbus_proxy_get_path(proxy); + const char *iface = g_dbus_proxy_get_interface(proxy); + + if (strcmp(iface, ADV_MONITOR_INTERFACE) != 0 || + !g_str_has_prefix(path, app->path)) { + return; + } + + if (queue_find(app->monitors, monitor_match, proxy)) { + btd_error(adapter_id, "Adv Monitor proxy already exists with " + "path %s", path); + return; + } + + monitor = monitor_new(app, proxy); + if (!monitor) { + btd_error(adapter_id, "Failed to allocate an Adv Monitor for " + "the object at %s", path); + return; + } + + if (!monitor_process(monitor, app)) { + monitor_release(monitor, NULL); + monitor_free(monitor); + DBG("Adv Monitor at path %s released due to invalid content", + path); + return; + } + + queue_push_tail(app->monitors, monitor); + + DBG("Adv Monitor allocated for the object at path %s", path); +} + +/* Handles the removal of an Adv Monitor D-Bus proxy */ +static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) +{ + struct adv_monitor *monitor; + struct adv_monitor_app *app = user_data; + + monitor = queue_remove_if(app->monitors, monitor_match, proxy); + if (monitor) { + DBG("Adv Monitor removed for the object at path %s", + monitor->path); + + /* The object was gone, so we don't need to call Release() */ + monitor_free(monitor); + } +} + /* Creates an app object, initiates it and sets D-Bus event handlers */ static struct adv_monitor_app *app_create(DBusConnection *conn, DBusMessage *msg, const char *sender, @@ -161,8 +625,17 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, return NULL; } + app->monitors = queue_new(); + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); - g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL); + + /* Note that any property changes on a monitor object would not affect + * the content of the corresponding monitor. + */ + g_dbus_client_set_proxy_handlers(app->client, monitor_proxy_added_cb, + monitor_proxy_removed_cb, NULL, + app); + g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); app->reg = dbus_message_ref(msg); @@ -269,18 +742,6 @@ static const GDBusMethodTable adv_monitor_methods[] = { { } }; -enum monitor_type { - MONITOR_TYPE_OR_PATTERNS, -}; - -const struct adv_monitor_type { - enum monitor_type type; - const char *name; -} supported_types[] = { - { MONITOR_TYPE_OR_PATTERNS, "or_patterns" }, - { }, -}; - /* Gets SupportedMonitorTypes property */ static gboolean get_supported_monitor_types(const GDBusPropertyTable *property, DBusMessageIter *iter, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MIUaFzyTXV/zywEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 05:34:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gOknFDyTXV97aAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 05:34:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 443FAA0B3F; Sun, 13 Sep 2020 05:34:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725920AbgIMDeE (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 23:34:04 -0400 Received: from mga05.intel.com ([192.55.52.43]:59032 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbgIMDeC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 23:34:02 -0400 IronPort-SDR: P25pixIZsokZgZ0lrtJG9b9mjDfevYw5Mq4x+S3GMVWztXccLeWQKATlFrX8MGTBRYil0Evbnr ChqfgfwVv3ng== X-IronPort-AV: E=McAfee;i="6000,8403,9742"; a="243784902" X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="243784902" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:00 -0700 IronPort-SDR: JaCNDCOm99ghO/oZjvF+na2jO7R/PehdpR6j1FK6aq/9IPnfgm6Kce2aVFKEZU+IKCMOvv8KVu 6DfWxQSHYBZQ== X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="301347228" Received: from han1-mobl3.jf.intel.com ([10.251.29.101]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:00 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v2 13/17] plugins: Add SPDX License Identifier Date: Sat, 12 Sep 2020 20:33:37 -0700 Message-Id: <20200913033341.4639-14-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200913033341.4639-1-tedd.an@linux.intel.com> References: <20200913033341.4639-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: 443FAA0B3F X-Rspamd-UID: ce3cb1 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 7 License: GPL-2.0-or-later plugins/autopair.c plugins/hostname.c plugins/neard.c plugins/policy.c plugins/sixaxis.c plugins/wiimote.c plugins/external-dummy.c --- plugins/autopair.c | 1 + plugins/external-dummy.c | 1 + plugins/hostname.c | 1 + plugins/neard.c | 1 + plugins/policy.c | 1 + plugins/sixaxis.c | 1 + plugins/wiimote.c | 1 + 7 files changed, 7 insertions(+) diff --git a/plugins/autopair.c b/plugins/autopair.c index 3089430a8..381d91c8f 100644 --- a/plugins/autopair.c +++ b/plugins/autopair.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/external-dummy.c b/plugins/external-dummy.c index 536ad0663..78377b021 100644 --- a/plugins/external-dummy.c +++ b/plugins/external-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/hostname.c b/plugins/hostname.c index 4f9dfe6d8..32f15b3a5 100644 --- a/plugins/hostname.c +++ b/plugins/hostname.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/neard.c b/plugins/neard.c index 6ffcd6e10..1fefc5015 100644 --- a/plugins/neard.c +++ b/plugins/neard.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/policy.c b/plugins/policy.c index de51e58b9..86eb25ee9 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c index 939fed759..8350d63f8 100644 --- a/plugins/sixaxis.c +++ b/plugins/sixaxis.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/plugins/wiimote.c b/plugins/wiimote.c index 0ced27514..9441a7681 100644 --- a/plugins/wiimote.c +++ b/plugins/wiimote.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QD/cEkOTXV/zywEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 05:34:27 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WNfUD0OTXV9K6wEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 05:34:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 90D24A0B41; Sun, 13 Sep 2020 05:34:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725923AbgIMDeE (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 23:34:04 -0400 Received: from mga04.intel.com ([192.55.52.120]:11485 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725910AbgIMDeC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 23:34:02 -0400 IronPort-SDR: uRYEFfP5KfyNLW+3sJHOabLUkYp5ACOaYSL2AeLEFpCWsPBTAztaGyA+NvXypYmVREojtNSaWj MV6CIEvd9shA== X-IronPort-AV: E=McAfee;i="6000,8403,9742"; a="156354725" X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="156354725" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:00 -0700 IronPort-SDR: KXX3lBg7jUhYwHzXRtHEEV63CjwZmbyS+8Jkrfuaixy79rHGanqgRBsTfCDGxSbc5SIpXd8nMu 49B9mrfUPOfg== X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="301347223" Received: from han1-mobl3.jf.intel.com ([10.251.29.101]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:00 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v2 11/17] obexd: Add SPDX License Identifier Date: Sat, 12 Sep 2020 20:33:35 -0700 Message-Id: <20200913033341.4639-12-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200913033341.4639-1-tedd.an@linux.intel.com> References: <20200913033341.4639-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: 90D24A0B41 X-Rspamd-UID: 37e303 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 65 License: GPL-2.0-or-later obexd/src/mimetype.c obexd/src/transport.h obexd/src/server.c obexd/src/obex.c obexd/src/log.h obexd/src/service.h obexd/src/plugin.h obexd/src/plugin.c obexd/src/main.c obexd/src/mimetype.h obexd/src/transport.c obexd/src/obexd.h obexd/src/obex.h obexd/src/obex-priv.h obexd/src/log.c obexd/src/map_ap.h obexd/src/manager.c obexd/src/service.c obexd/src/server.h obexd/src/manager.h obexd/plugins/opp.c obexd/plugins/vcard.h obexd/plugins/pbap.c obexd/plugins/vcard.c obexd/plugins/messages.h obexd/plugins/phonebook.h obexd/plugins/pcsuite.c obexd/plugins/messages-tracker.c obexd/plugins/phonebook-tracker.c obexd/plugins/irmc.c obexd/plugins/ftp.c obexd/plugins/ftp.h obexd/plugins/filesystem.c obexd/plugins/messages-dummy.c obexd/plugins/phonebook-ebook.c obexd/plugins/syncevolution.c obexd/plugins/bluetooth.c obexd/plugins/phonebook-dummy.c obexd/plugins/filesystem.h obexd/plugins/mas.c obexd/client/transport.h obexd/client/opp.c obexd/client/pbap.c obexd/client/transfer.h obexd/client/opp.h obexd/client/driver.c obexd/client/map-event.h obexd/client/bluetooth.h obexd/client/sync.h obexd/client/transport.c obexd/client/pbap.h obexd/client/driver.h obexd/client/transfer.c obexd/client/ftp.c obexd/client/map.h obexd/client/ftp.h obexd/client/bluetooth.c obexd/client/manager.c obexd/client/session.h obexd/client/session.c obexd/client/map.c obexd/client/sync.c obexd/client/map-event.c obexd/client/mns.c obexd/client/manager.h --- obexd/client/bluetooth.c | 1 + obexd/client/bluetooth.h | 1 + obexd/client/driver.c | 1 + obexd/client/driver.h | 1 + obexd/client/ftp.c | 1 + obexd/client/ftp.h | 1 + obexd/client/manager.c | 1 + obexd/client/manager.h | 1 + obexd/client/map-event.c | 1 + obexd/client/map-event.h | 1 + obexd/client/map.c | 1 + obexd/client/map.h | 1 + obexd/client/mns.c | 1 + obexd/client/opp.c | 1 + obexd/client/opp.h | 1 + obexd/client/pbap.c | 1 + obexd/client/pbap.h | 1 + obexd/client/session.c | 1 + obexd/client/session.h | 1 + obexd/client/sync.c | 1 + obexd/client/sync.h | 1 + obexd/client/transfer.c | 1 + obexd/client/transfer.h | 1 + obexd/client/transport.c | 1 + obexd/client/transport.h | 1 + obexd/plugins/bluetooth.c | 1 + obexd/plugins/filesystem.c | 1 + obexd/plugins/filesystem.h | 1 + obexd/plugins/ftp.c | 1 + obexd/plugins/ftp.h | 1 + obexd/plugins/irmc.c | 1 + obexd/plugins/mas.c | 1 + obexd/plugins/messages-dummy.c | 1 + obexd/plugins/messages-tracker.c | 1 + obexd/plugins/messages.h | 1 + obexd/plugins/opp.c | 1 + obexd/plugins/pbap.c | 1 + obexd/plugins/pcsuite.c | 1 + obexd/plugins/phonebook-dummy.c | 1 + obexd/plugins/phonebook-ebook.c | 1 + obexd/plugins/phonebook-tracker.c | 1 + obexd/plugins/phonebook.h | 1 + obexd/plugins/syncevolution.c | 1 + obexd/plugins/vcard.c | 1 + obexd/plugins/vcard.h | 1 + obexd/src/log.c | 1 + obexd/src/log.h | 1 + obexd/src/main.c | 1 + obexd/src/manager.c | 1 + obexd/src/manager.h | 1 + obexd/src/map_ap.h | 1 + obexd/src/mimetype.c | 1 + obexd/src/mimetype.h | 1 + obexd/src/obex-priv.h | 1 + obexd/src/obex.c | 1 + obexd/src/obex.h | 1 + obexd/src/obexd.h | 1 + obexd/src/plugin.c | 1 + obexd/src/plugin.h | 1 + obexd/src/server.c | 1 + obexd/src/server.h | 1 + obexd/src/service.c | 1 + obexd/src/service.h | 1 + obexd/src/transport.c | 1 + obexd/src/transport.h | 1 + 65 files changed, 65 insertions(+) diff --git a/obexd/client/bluetooth.c b/obexd/client/bluetooth.c index 0c043e0ac..d7100a36c 100644 --- a/obexd/client/bluetooth.c +++ b/obexd/client/bluetooth.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/bluetooth.h b/obexd/client/bluetooth.h index 968e131e0..0db50299e 100644 --- a/obexd/client/bluetooth.h +++ b/obexd/client/bluetooth.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client diff --git a/obexd/client/driver.c b/obexd/client/driver.c index 0dae35601..773a6efe4 100644 --- a/obexd/client/driver.c +++ b/obexd/client/driver.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/client/driver.h b/obexd/client/driver.h index 0112219d5..e84281cef 100644 --- a/obexd/client/driver.h +++ b/obexd/client/driver.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/client/ftp.c b/obexd/client/ftp.c index 5e30654af..b260dc298 100644 --- a/obexd/client/ftp.c +++ b/obexd/client/ftp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/ftp.h b/obexd/client/ftp.h index 3d9096863..797f34aec 100644 --- a/obexd/client/ftp.h +++ b/obexd/client/ftp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client diff --git a/obexd/client/manager.c b/obexd/client/manager.c index fbcad6da4..4782203e0 100644 --- a/obexd/client/manager.c +++ b/obexd/client/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/manager.h b/obexd/client/manager.h index e4068de44..83d58f588 100644 --- a/obexd/client/manager.h +++ b/obexd/client/manager.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/client/map-event.c b/obexd/client/map-event.c index e164e863c..7b7e227e5 100644 --- a/obexd/client/map-event.c +++ b/obexd/client/map-event.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX diff --git a/obexd/client/map-event.h b/obexd/client/map-event.h index 5414b2621..fdfdb11f0 100644 --- a/obexd/client/map-event.h +++ b/obexd/client/map-event.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX diff --git a/obexd/client/map.c b/obexd/client/map.c index 23be2d6b2..e352499a3 100644 --- a/obexd/client/map.c +++ b/obexd/client/map.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/map.h b/obexd/client/map.h index 86f6b9512..79b1856ca 100644 --- a/obexd/client/map.h +++ b/obexd/client/map.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client diff --git a/obexd/client/mns.c b/obexd/client/mns.c index 4912cb90f..47c75c8e1 100644 --- a/obexd/client/mns.c +++ b/obexd/client/mns.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/client/opp.c b/obexd/client/opp.c index 92785f66e..4a08540f7 100644 --- a/obexd/client/opp.c +++ b/obexd/client/opp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/opp.h b/obexd/client/opp.h index a23e94e00..095a8ff7c 100644 --- a/obexd/client/opp.h +++ b/obexd/client/opp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c index 3f5665fcd..1b1edb1ea 100644 --- a/obexd/client/pbap.c +++ b/obexd/client/pbap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/pbap.h b/obexd/client/pbap.h index ce56258b5..070ecad8b 100644 --- a/obexd/client/pbap.h +++ b/obexd/client/pbap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client diff --git a/obexd/client/session.c b/obexd/client/session.c index 5bd2d2670..43e86551e 100644 --- a/obexd/client/session.c +++ b/obexd/client/session.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/session.h b/obexd/client/session.h index b561b7e58..e0fb0056a 100644 --- a/obexd/client/session.h +++ b/obexd/client/session.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client diff --git a/obexd/client/sync.c b/obexd/client/sync.c index 548c318c3..90a2bcb0e 100644 --- a/obexd/client/sync.c +++ b/obexd/client/sync.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/sync.h b/obexd/client/sync.h index 8adc5f8d6..52f12132d 100644 --- a/obexd/client/sync.h +++ b/obexd/client/sync.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c index b53dffa21..489c03743 100644 --- a/obexd/client/transfer.c +++ b/obexd/client/transfer.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client diff --git a/obexd/client/transfer.h b/obexd/client/transfer.h index b6b835d18..f49ec44ee 100644 --- a/obexd/client/transfer.h +++ b/obexd/client/transfer.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client diff --git a/obexd/client/transport.c b/obexd/client/transport.c index 4cd770672..3467f7001 100644 --- a/obexd/client/transport.c +++ b/obexd/client/transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/client/transport.h b/obexd/client/transport.h index b035cfc45..4927383a0 100644 --- a/obexd/client/transport.h +++ b/obexd/client/transport.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c index ba1e0a99a..955616010 100644 --- a/obexd/plugins/bluetooth.c +++ b/obexd/plugins/bluetooth.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c index 48239a8bc..e50338fb3 100644 --- a/obexd/plugins/filesystem.c +++ b/obexd/plugins/filesystem.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/filesystem.h b/obexd/plugins/filesystem.h index f95773beb..726ac592a 100644 --- a/obexd/plugins/filesystem.h +++ b/obexd/plugins/filesystem.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c index 3ee18a619..cf58cd3a8 100644 --- a/obexd/plugins/ftp.c +++ b/obexd/plugins/ftp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/ftp.h b/obexd/plugins/ftp.h index f06de8490..ca6cca469 100644 --- a/obexd/plugins/ftp.h +++ b/obexd/plugins/ftp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/plugins/irmc.c b/obexd/plugins/irmc.c index fcf5340e7..782afb485 100644 --- a/obexd/plugins/irmc.c +++ b/obexd/plugins/irmc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX IrMC Sync Server diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c index f73c3e9d8..ac379d622 100644 --- a/obexd/plugins/mas.c +++ b/obexd/plugins/mas.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c index 3eca9ef4c..63632c9c3 100644 --- a/obexd/plugins/messages-dummy.c +++ b/obexd/plugins/messages-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/messages-tracker.c b/obexd/plugins/messages-tracker.c index 60f3a807e..3d0a20069 100644 --- a/obexd/plugins/messages-tracker.c +++ b/obexd/plugins/messages-tracker.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/messages.h b/obexd/plugins/messages.h index 00a16b1ae..0f8ac6d83 100644 --- a/obexd/plugins/messages.h +++ b/obexd/plugins/messages.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/plugins/opp.c b/obexd/plugins/opp.c index 5bb766770..c0747856f 100644 --- a/obexd/plugins/opp.c +++ b/obexd/plugins/opp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c index d5a3046ae..0dc5e4cfc 100644 --- a/obexd/plugins/pbap.c +++ b/obexd/plugins/pbap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c index 43ab409e9..1b37f3e81 100644 --- a/obexd/plugins/pcsuite.c +++ b/obexd/plugins/pcsuite.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c index 9279ef29a..edcacf420 100644 --- a/obexd/plugins/phonebook-dummy.c +++ b/obexd/plugins/phonebook-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/phonebook-ebook.c b/obexd/plugins/phonebook-ebook.c index c422585df..2230148d6 100644 --- a/obexd/plugins/phonebook-ebook.c +++ b/obexd/plugins/phonebook-ebook.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c index c1d14078b..ea1811786 100644 --- a/obexd/plugins/phonebook-tracker.c +++ b/obexd/plugins/phonebook-tracker.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Phonebook access through D-Bus vCard and call history service * diff --git a/obexd/plugins/phonebook.h b/obexd/plugins/phonebook.h index 70a9cb797..7e306b48b 100644 --- a/obexd/plugins/phonebook.h +++ b/obexd/plugins/phonebook.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/plugins/syncevolution.c b/obexd/plugins/syncevolution.c index 854505a58..32e772a1e 100644 --- a/obexd/plugins/syncevolution.c +++ b/obexd/plugins/syncevolution.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c index dc7c3b3e6..40269f4e2 100644 --- a/obexd/plugins/vcard.c +++ b/obexd/plugins/vcard.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * OBEX Server * diff --git a/obexd/plugins/vcard.h b/obexd/plugins/vcard.h index 22c3f6899..3d330f5fd 100644 --- a/obexd/plugins/vcard.h +++ b/obexd/plugins/vcard.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * OBEX Server * diff --git a/obexd/src/log.c b/obexd/src/log.c index 8e2ebaab2..769c7183c 100644 --- a/obexd/src/log.c +++ b/obexd/src/log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/log.h b/obexd/src/log.h index d9fb8678f..2777eb4a3 100644 --- a/obexd/src/log.h +++ b/obexd/src/log.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/src/main.c b/obexd/src/main.c index 139f1412c..462fd796c 100644 --- a/obexd/src/main.c +++ b/obexd/src/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/manager.c b/obexd/src/manager.c index a4af627cb..a3cbd3fa9 100644 --- a/obexd/src/manager.c +++ b/obexd/src/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/manager.h b/obexd/src/manager.h index d709af5a8..5b78537e2 100644 --- a/obexd/src/manager.h +++ b/obexd/src/manager.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/src/map_ap.h b/obexd/src/map_ap.h index da108fe6e..32e272796 100644 --- a/obexd/src/map_ap.h +++ b/obexd/src/map_ap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/src/mimetype.c b/obexd/src/mimetype.c index c8b040a43..7dac1ee98 100644 --- a/obexd/src/mimetype.c +++ b/obexd/src/mimetype.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/mimetype.h b/obexd/src/mimetype.h index 79529b890..c9a55152f 100644 --- a/obexd/src/mimetype.h +++ b/obexd/src/mimetype.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/src/obex-priv.h b/obexd/src/obex-priv.h index 355a7f87b..627925710 100644 --- a/obexd/src/obex-priv.h +++ b/obexd/src/obex-priv.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/src/obex.c b/obexd/src/obex.c index 2850d3a37..d9b6b93d4 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/obex.h b/obexd/src/obex.h index 67593f11b..3e3236b66 100644 --- a/obexd/src/obex.h +++ b/obexd/src/obex.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/src/obexd.h b/obexd/src/obexd.h index 42c3c4d97..3e8291dd9 100644 --- a/obexd/src/obexd.h +++ b/obexd/src/obexd.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/src/plugin.c b/obexd/src/plugin.c index a1962b91d..fcfd0b182 100644 --- a/obexd/src/plugin.c +++ b/obexd/src/plugin.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/plugin.h b/obexd/src/plugin.h index 13d77695f..3e5af163c 100644 --- a/obexd/src/plugin.h +++ b/obexd/src/plugin.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/src/server.c b/obexd/src/server.c index db854233b..5e3ed7283 100644 --- a/obexd/src/server.c +++ b/obexd/src/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/server.h b/obexd/src/server.h index 278c35fce..6c6e8429a 100644 --- a/obexd/src/server.h +++ b/obexd/src/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/src/service.c b/obexd/src/service.c index c088535e9..faa39329f 100644 --- a/obexd/src/service.c +++ b/obexd/src/service.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/service.h b/obexd/src/service.h index 5d9d325fb..cb3b6f33a 100644 --- a/obexd/src/service.h +++ b/obexd/src/service.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server diff --git a/obexd/src/transport.c b/obexd/src/transport.c index 4984643e2..b6b7f7a61 100644 --- a/obexd/src/transport.c +++ b/obexd/src/transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server diff --git a/obexd/src/transport.h b/obexd/src/transport.h index 97e10d05f..bea398c85 100644 --- a/obexd/src/transport.h +++ b/obexd/src/transport.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uAXnLUmTXV9hxwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 05:34:33 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2PIdK0mTXV9K6wEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 05:34:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 616AFA0B41; Sun, 13 Sep 2020 05:34:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725921AbgIMDeJ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 23:34:09 -0400 Received: from mga05.intel.com ([192.55.52.43]:59033 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725919AbgIMDeD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 23:34:03 -0400 IronPort-SDR: 0YYVAw4L0QB+SD57SWVnQ6QrKZsgWuGD0RWcU4R/bc/t6D56YrVwM6qVTlKkqOtC2iARc49NBV cT/wcDfNcLTA== X-IronPort-AV: E=McAfee;i="6000,8403,9742"; a="243784904" X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="243784904" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:01 -0700 IronPort-SDR: I7KWPwph3noo98XSxMflVVo1O4C7jDmFC5Ae7Vf1FU12EFx1DPqbrG1zkx/xuW9EGr8o1fGhds Cn6fy7EAAtfw== X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="301347235" Received: from han1-mobl3.jf.intel.com ([10.251.29.101]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:00 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v2 15/17] unit: Add SPDX License Identifier Date: Sat, 12 Sep 2020 20:33:39 -0700 Message-Id: <20200913033341.4639-16-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200913033341.4639-1-tedd.an@linux.intel.com> References: <20200913033341.4639-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: 616AFA0B41 X-Rspamd-UID: 65ef29 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 25 LGPL-2.1-or-later : 1 GPL-2.0-only : 2 BSD-2-Clause : 1 License: GPL-2.0-or-later unit/test-hog.c unit/test-eir.c unit/test-gobex-header.c unit/test-crc.c unit/test-avrcp.c unit/test-ringbuf.c unit/test-gobex-apparam.c unit/test-gobex.c unit/test-hfp.c unit/test-textfile.c unit/test-avdtp.c unit/test-sdp.c unit/test-gatt.c unit/test-avctp.c unit/test-gattrib.c unit/test-queue.c unit/test-gobex-packet.c unit/test-uuid.c unit/test-crypto.c unit/test-uhid.c unit/test-gdbus-client.c unit/test-midi.c unit/test-lib.c unit/test-mgmt.c unit/test-gobex-transfer.c License: LGPL-2.1-or-later unit/test-mesh-crypto.c License: GPL-2.0-only unit/util.h unit/util.c License: BSD-2-Clause unit/test-ecc.c --- unit/test-avctp.c | 1 + unit/test-avdtp.c | 1 + unit/test-avrcp.c | 1 + unit/test-crc.c | 1 + unit/test-crypto.c | 1 + unit/test-ecc.c | 1 + unit/test-eir.c | 1 + unit/test-gatt.c | 1 + unit/test-gattrib.c | 1 + unit/test-gdbus-client.c | 1 + unit/test-gobex-apparam.c | 1 + unit/test-gobex-header.c | 1 + unit/test-gobex-packet.c | 1 + unit/test-gobex-transfer.c | 1 + unit/test-gobex.c | 1 + unit/test-hfp.c | 1 + unit/test-hog.c | 1 + unit/test-lib.c | 1 + unit/test-mesh-crypto.c | 1 + unit/test-mgmt.c | 1 + unit/test-midi.c | 1 + unit/test-queue.c | 1 + unit/test-ringbuf.c | 1 + unit/test-sdp.c | 1 + unit/test-textfile.c | 1 + unit/test-uhid.c | 1 + unit/test-uuid.c | 1 + unit/util.c | 1 + unit/util.h | 1 + 29 files changed, 29 insertions(+) diff --git a/unit/test-avctp.c b/unit/test-avctp.c index c92618bab..ca69d454e 100644 --- a/unit/test-avctp.c +++ b/unit/test-avctp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c index 13c03d037..8081b3e66 100644 --- a/unit/test-avdtp.c +++ b/unit/test-avdtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c index adf25f002..e7470ba19 100644 --- a/unit/test-avrcp.c +++ b/unit/test-avrcp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-crc.c b/unit/test-crc.c index 791fa5137..04097eb83 100644 --- a/unit/test-crc.c +++ b/unit/test-crc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-crypto.c b/unit/test-crypto.c index 46c7c0e5c..173885019 100644 --- a/unit/test-crypto.c +++ b/unit/test-crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-ecc.c b/unit/test-ecc.c index d9136814d..e87bebf52 100644 --- a/unit/test-ecc.c +++ b/unit/test-ecc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: BSD-2-Clause /* * Copyright (c) 2013, Kenneth MacKay * All rights reserved. diff --git a/unit/test-eir.c b/unit/test-eir.c index 421d0db13..f6da5e6d3 100644 --- a/unit/test-eir.c +++ b/unit/test-eir.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-gatt.c b/unit/test-gatt.c index 0b77df51c..735c47da0 100644 --- a/unit/test-gatt.c +++ b/unit/test-gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-gattrib.c b/unit/test-gattrib.c index 416e59635..39ac3da8c 100644 --- a/unit/test-gattrib.c +++ b/unit/test-gattrib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c index ccf706713..7f1d9a32b 100644 --- a/unit/test-gdbus-client.c +++ b/unit/test-gdbus-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-gobex-apparam.c b/unit/test-gobex-apparam.c index 59393c681..2e85b1d2b 100644 --- a/unit/test-gobex-apparam.c +++ b/unit/test-gobex-apparam.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration diff --git a/unit/test-gobex-header.c b/unit/test-gobex-header.c index 3450f8123..f50c10f9c 100644 --- a/unit/test-gobex-header.c +++ b/unit/test-gobex-header.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration diff --git a/unit/test-gobex-packet.c b/unit/test-gobex-packet.c index d382ee5b3..1c7cb993b 100644 --- a/unit/test-gobex-packet.c +++ b/unit/test-gobex-packet.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c index 3f8905c0b..61bfddef8 100644 --- a/unit/test-gobex-transfer.c +++ b/unit/test-gobex-transfer.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration diff --git a/unit/test-gobex.c b/unit/test-gobex.c index 1afb7ceff..022579005 100644 --- a/unit/test-gobex.c +++ b/unit/test-gobex.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration diff --git a/unit/test-hfp.c b/unit/test-hfp.c index 890eee659..f625537e8 100644 --- a/unit/test-hfp.c +++ b/unit/test-hfp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-hog.c b/unit/test-hog.c index e257fbd88..66025334d 100644 --- a/unit/test-hog.c +++ b/unit/test-hog.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-lib.c b/unit/test-lib.c index 1dd5d92cf..9c4ee64c1 100644 --- a/unit/test-lib.c +++ b/unit/test-lib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-mesh-crypto.c b/unit/test-mesh-crypto.c index ed37ae1a7..e65b4ee5f 100644 --- a/unit/test-mesh-crypto.c +++ b/unit/test-mesh-crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-mgmt.c b/unit/test-mgmt.c index c67678b9a..b20bd1918 100644 --- a/unit/test-mgmt.c +++ b/unit/test-mgmt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-midi.c b/unit/test-midi.c index 593bc5a5c..66c096b46 100644 --- a/unit/test-midi.c +++ b/unit/test-midi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-queue.c b/unit/test-queue.c index d912a6416..c502e68da 100644 --- a/unit/test-queue.c +++ b/unit/test-queue.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-ringbuf.c b/unit/test-ringbuf.c index ef3bf0a50..f3ba2673e 100644 --- a/unit/test-ringbuf.c +++ b/unit/test-ringbuf.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-sdp.c b/unit/test-sdp.c index 03501d021..3c40b411a 100644 --- a/unit/test-sdp.c +++ b/unit/test-sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-textfile.c b/unit/test-textfile.c index 4b43898d6..d939443f9 100644 --- a/unit/test-textfile.c +++ b/unit/test-textfile.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-uhid.c b/unit/test-uhid.c index 320cd54d4..42c39a770 100644 --- a/unit/test-uhid.c +++ b/unit/test-uhid.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/test-uuid.c b/unit/test-uuid.c index 7c6789e39..e0753b816 100644 --- a/unit/test-uuid.c +++ b/unit/test-uuid.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/unit/util.c b/unit/util.c index c8054d2e4..31dec37df 100644 --- a/unit/util.c +++ b/unit/util.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * * OBEX library with GLib integration diff --git a/unit/util.h b/unit/util.h index b13fd2f16..01a482985 100644 --- a/unit/util.h +++ b/unit/util.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * * OBEX library with GLib integration -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oJrTFIFwXF/LHgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 08:53:53 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id gOuMEYFwXF/20gEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 08:53:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B8D93A015E; Sat, 12 Sep 2020 08:53:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725845AbgILGxo (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 02:53:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725788AbgILGxn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 02:53:43 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CEF6C061573 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:53:43 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id g21so630015plq.1 for <linux-bluetooth@vger.kernel.org>; Fri, 11 Sep 2020 23:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OwcQPbWK9wBBKShQmm51i7xxWQDNt4zUBesrzpNnDCQ=; b=VUAa6hsso6AxvZIAOLvHCOTOGf49bGrrlP8lT0AAYhKo3lBtBu9/wFkhEsurDPv9yG /fiouEnhWVJQtA7um9S5oIGwFr69DFyrNzgzkVqMbL7TdL1haF2fP4j1i+ubZM7fX2Zh uPggCleCAQVvcWxkiCvU1hr7PQ1r1TQ/fdA8E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OwcQPbWK9wBBKShQmm51i7xxWQDNt4zUBesrzpNnDCQ=; b=tLT8Cb3ITTGyA5ey8jKWgCKMtZDII6o/CkIw+kbPaYRUnUxKcTMvGkn3bnb3wJrayI RwcYw6PytnD46xQZp9zbZvTOfLcnJPnvmAgtYuBFZWb1+EvqF+RyOibEwEVxOCdyWX4H 6V+4hN0s7em/nAzC2cpKQpbuF3Mj6kgACOj1hhtg7rLjALTExkJ1devFQhYo1yv/JrNi b9Z5Hi/Vtj7FfN3QxLrtaGQmVEMtvjrFxjcv4K+DZTeF7iI9wzaCjeRiehZ0UfbfdBAL wSCRIdzGMHa0X007Jgy9g+ZIn4ZONiODbYywBARdOL8/3wMk4htc/mm4naYkJLQh2nBd iQtw== X-Gm-Message-State: AOAM532Zq1c5pAx7qZsk89zDQw4d0oJPh7n7fQp+R4W47j0XTJ4nYiUp As4S3ARNj+P7VRq4+PZLR6z4kBsKSCr4pw== X-Google-Smtp-Source: ABdhPJx1kXgjv2O53os36lS2ZXvgPiEfssZ0hPqH+xwLJiPSOwaznEhzQGf798yGdiXfeNIrLtl7GA== X-Received: by 2002:a17:90b:1098:: with SMTP id gj24mr5576621pjb.55.1599893620619; Fri, 11 Sep 2020 23:53:40 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id hg16sm3440913pjb.37.2020.09.11.23.53.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 23:53:39 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v5 8/8] doc: Update Advertisement Monitor API description Date: Fri, 11 Sep 2020 23:51:33 -0700 Message-Id: <20200911235104.BlueZ.v5.8.Iee7e9d13c78dd02c5b283a203dea11a4a4ffa7cc@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: B8D93A015E X-Rspamd-UID: f13bb6 This modifies the following description to Advertisement Monitor API. - Add org.bluez.Error.Failed to RegisterMonitor() method. - Add more description about the usage of RegisterMonitor() and UnregisterMonitor() methods. - Add description about the ranges for the fields in property RSSIThresholdsAndTimers. Reviewed-by: Yun-Hao Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) doc/advertisement-monitor-api.txt | 34 +++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index 74adbfae9..e09b6fd25 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -49,7 +49,7 @@ Properties string Type [read-only] org.bluez.AdvertisementMonitorManager1 for the available options. - (Int16, Uint16, Int16, Uint16) RSSIThreshholdsAndTimers [read-only, optional] + (Int16, Uint16, Int16, Uint16) RSSIThresholdsAndTimers [read-only, optional] This contains HighRSSIThreshold, HighRSSIThresholdTimer, LowRSSIThreshold, LowRSSIThresholdTimer in order. The @@ -66,7 +66,11 @@ Properties string Type [read-only] RSSIs of the received advertisement(s) during LowRSSIThresholdTimer do not reach LowRSSIThreshold. - array{(uint8, uint8, string)} Patterns [read-only, optional] + The valid range of a RSSI is -127 to +20 dBm while 127 + dBm indicates unset. The valid range of a timer is 1 to + 300 seconds while 0 indicates unset. + + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] If Type is set to 0x01, this must exist and has at least one entry in the array. @@ -80,8 +84,9 @@ Properties string Type [read-only] See https://www.bluetooth.com/specifications/ assigned-numbers/generic-access-profile/ for the possible allowed value. - string content_of_pattern - This is the value of the pattern. + array{byte} content_of_pattern + This is the value of the pattern. The maximum + length of the bytes is 31. Advertisement Monitor Manager hierarchy ======================================= @@ -91,20 +96,31 @@ Object path /org/bluez/{hci0,hci1,...} Methods void RegisterMonitor(object application) - This registers a hierarchy of advertisement monitors. + This registers the root path of a hierarchy of + advertisement monitors. The application object path together with the D-Bus system bus connection ID define the identification of the application registering advertisement monitors. + Once a root path is registered by a client via this + method, the client can freely expose/unexpose + advertisement monitors without re-registering the root + path again. After use, the client should call + UnregisterMonitor() method to invalidate the + advertisement monitors. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.AlreadyExists + org.bluez.Error.Failed void UnregisterMonitor(object application) - This unregisters advertisement monitors that have been - previously registered. The object path parameter must - match the same value that has been used on - registration. + This unregisters a hierarchy of advertisement monitors + that has been previously registered. The object path + parameter must match the same value that has been used + on registration. Upon unregistration, the advertisement + monitor(s) should expect to receive Release() method as + the signal that the advertisement monitor(s) has been + deactivated. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.DoesNotExist -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QPcnMlCTXV9hxwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 05:34:40 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id IJvoLlCTXV8xmwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 05:34:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D6D81A0B3E; Sun, 13 Sep 2020 05:34:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725926AbgIMDeL (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 23:34:11 -0400 Received: from mga05.intel.com ([192.55.52.43]:59032 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725918AbgIMDeD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 23:34:03 -0400 IronPort-SDR: IFW/dd8aLjWOf3lbqD2pAkJ09yfaq6a8sMndaIbW/gC4Uoty05Av+3ERX4Gd1cPhhoTv+4B1xd oCiDndYtgWNw== X-IronPort-AV: E=McAfee;i="6000,8403,9742"; a="243784903" X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="243784903" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:00 -0700 IronPort-SDR: T1rAZR+DSkJCaAHl7VOnsfVGafrdviywweIXyZPbxNh00bk7INr8GX+uUCOfwUYbFersHQg/Fp Yf5lR+FNdejA== X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="301347233" Received: from han1-mobl3.jf.intel.com ([10.251.29.101]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:00 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v2 14/17] profiles: Add SPDX License Identifier Date: Sat, 12 Sep 2020 20:33:38 -0700 Message-Id: <20200913033341.4639-15-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200913033341.4639-1-tedd.an@linux.intel.com> References: <20200913033341.4639-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: D6D81A0B3E X-Rspamd-UID: 448eed From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 72 LGPL-2.1-or-later : 6 License: GPL-2.0-or-later profiles/deviceinfo/dis.c profiles/deviceinfo/deviceinfo.c profiles/health/hdp_types.h profiles/health/mcap.c profiles/health/hdp_manager.c profiles/health/hdp_main.c profiles/health/mcap.h profiles/health/hdp_util.h profiles/health/hdp_manager.h profiles/health/hdp_util.c profiles/health/hdp.c profiles/health/hdp.h profiles/network/server.c profiles/network/connection.h profiles/network/connection.c profiles/network/manager.c profiles/network/bnep.c profiles/network/server.h profiles/network/bnep.h profiles/battery/battery.c profiles/cups/cups.h profiles/cups/sdp.c profiles/cups/main.c profiles/cups/spp.c profiles/cups/hcrp.c profiles/scanparam/scpp.c profiles/scanparam/scan.c profiles/audio/transport.h profiles/audio/avdtp.h profiles/audio/source.c profiles/audio/player.c profiles/audio/avctp.c profiles/audio/control.h profiles/audio/a2dp.c profiles/audio/source.h profiles/audio/transport.c profiles/audio/sink.c profiles/audio/avrcp.h profiles/audio/avdtp.c profiles/audio/a2dp.h profiles/audio/avrcp.c profiles/audio/media.h profiles/audio/avctp.h profiles/audio/control.c profiles/audio/sink.h profiles/audio/player.h profiles/audio/media.c profiles/sap/server.c profiles/sap/sap-dummy.c profiles/sap/main.c profiles/sap/sap.h profiles/sap/manager.c profiles/sap/server.h profiles/sap/manager.h profiles/iap/main.c profiles/gap/gas.c profiles/midi/midi.c profiles/midi/libmidi.c profiles/midi/libmidi.h profiles/input/server.c profiles/input/suspend.h profiles/input/uhid_copy.h profiles/input/device.c profiles/input/hog.c profiles/input/device.h profiles/input/hidp_defs.h profiles/input/manager.c profiles/input/suspend-none.c profiles/input/sixaxis.h profiles/input/hog-lib.c profiles/input/suspend-dummy.c profiles/input/server.h License: LGPL-2.1-or-later profiles/deviceinfo/dis.h profiles/battery/bas.h profiles/battery/bas.c profiles/scanparam/scpp.h profiles/audio/a2dp-codecs.h profiles/input/hog-lib.h --- profiles/audio/a2dp-codecs.h | 1 + profiles/audio/a2dp.c | 1 + profiles/audio/a2dp.h | 1 + profiles/audio/avctp.c | 1 + profiles/audio/avctp.h | 1 + profiles/audio/avdtp.c | 1 + profiles/audio/avdtp.h | 1 + profiles/audio/avrcp.c | 1 + profiles/audio/avrcp.h | 1 + profiles/audio/control.c | 1 + profiles/audio/control.h | 1 + profiles/audio/media.c | 1 + profiles/audio/media.h | 1 + profiles/audio/player.c | 1 + profiles/audio/player.h | 1 + profiles/audio/sink.c | 1 + profiles/audio/sink.h | 1 + profiles/audio/source.c | 1 + profiles/audio/source.h | 1 + profiles/audio/transport.c | 1 + profiles/audio/transport.h | 1 + profiles/battery/bas.c | 1 + profiles/battery/bas.h | 1 + profiles/battery/battery.c | 1 + profiles/cups/cups.h | 1 + profiles/cups/hcrp.c | 1 + profiles/cups/main.c | 1 + profiles/cups/sdp.c | 1 + profiles/cups/spp.c | 1 + profiles/deviceinfo/deviceinfo.c | 1 + profiles/deviceinfo/dis.c | 1 + profiles/deviceinfo/dis.h | 1 + profiles/gap/gas.c | 1 + profiles/health/hdp.c | 1 + profiles/health/hdp.h | 1 + profiles/health/hdp_main.c | 1 + profiles/health/hdp_manager.c | 1 + profiles/health/hdp_manager.h | 1 + profiles/health/hdp_types.h | 1 + profiles/health/hdp_util.c | 1 + profiles/health/hdp_util.h | 1 + profiles/health/mcap.c | 1 + profiles/health/mcap.h | 1 + profiles/iap/main.c | 1 + profiles/input/device.c | 1 + profiles/input/device.h | 1 + profiles/input/hidp_defs.h | 1 + profiles/input/hog-lib.c | 1 + profiles/input/hog-lib.h | 1 + profiles/input/hog.c | 1 + profiles/input/manager.c | 1 + profiles/input/server.c | 1 + profiles/input/server.h | 1 + profiles/input/sixaxis.h | 1 + profiles/input/suspend-dummy.c | 1 + profiles/input/suspend-none.c | 1 + profiles/input/suspend.h | 1 + profiles/input/uhid_copy.h | 1 + profiles/midi/libmidi.c | 1 + profiles/midi/libmidi.h | 1 + profiles/midi/midi.c | 1 + profiles/network/bnep.c | 1 + profiles/network/bnep.h | 1 + profiles/network/connection.c | 1 + profiles/network/connection.h | 1 + profiles/network/manager.c | 1 + profiles/network/server.c | 1 + profiles/network/server.h | 1 + profiles/sap/main.c | 1 + profiles/sap/manager.c | 1 + profiles/sap/manager.h | 1 + profiles/sap/sap-dummy.c | 1 + profiles/sap/sap.h | 1 + profiles/sap/server.c | 1 + profiles/sap/server.h | 1 + profiles/scanparam/scan.c | 1 + profiles/scanparam/scpp.c | 1 + profiles/scanparam/scpp.h | 1 + 78 files changed, 78 insertions(+) diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h index 93e9d3523..f94a25112 100644 --- a/profiles/audio/a2dp-codecs.h +++ b/profiles/audio/a2dp-codecs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c index 2feea66c0..e8c60a3b2 100644 --- a/profiles/audio/a2dp.c +++ b/profiles/audio/a2dp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/a2dp.h b/profiles/audio/a2dp.h index 19466a428..a1bceafaf 100644 --- a/profiles/audio/a2dp.h +++ b/profiles/audio/a2dp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c index f096d22b0..a7621b412 100644 --- a/profiles/audio/avctp.c +++ b/profiles/audio/avctp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/avctp.h b/profiles/audio/avctp.h index 95d95bbbe..69a07736b 100644 --- a/profiles/audio/avctp.h +++ b/profiles/audio/avctp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 782268c08..08fc0c62f 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h index 011fea89e..171c1a2d1 100644 --- a/profiles/audio/avdtp.h +++ b/profiles/audio/avdtp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 5ef98acd1..0bce23c0e 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index 159ccf846..f3938c192 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/control.c b/profiles/audio/control.c index 14744ea94..57a673995 100644 --- a/profiles/audio/control.c +++ b/profiles/audio/control.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/control.h b/profiles/audio/control.h index aab2631b6..d7d192bdd 100644 --- a/profiles/audio/control.h +++ b/profiles/audio/control.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 02bf82a49..d07b3a165 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/media.h b/profiles/audio/media.h index 53694f4c6..540b2826b 100644 --- a/profiles/audio/media.h +++ b/profiles/audio/media.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/player.c b/profiles/audio/player.c index 27a7efb7e..530c06364 100644 --- a/profiles/audio/player.c +++ b/profiles/audio/player.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/player.h b/profiles/audio/player.h index e98550064..536dc2293 100644 --- a/profiles/audio/player.h +++ b/profiles/audio/player.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c index 7c5e77577..d190e9753 100644 --- a/profiles/audio/sink.c +++ b/profiles/audio/sink.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/sink.h b/profiles/audio/sink.h index 93c62a206..fb1301b11 100644 --- a/profiles/audio/sink.h +++ b/profiles/audio/sink.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/source.c b/profiles/audio/source.c index 0ac20fe40..2d840a7c4 100644 --- a/profiles/audio/source.c +++ b/profiles/audio/source.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/source.h b/profiles/audio/source.h index a014c68d6..7c332528e 100644 --- a/profiles/audio/source.h +++ b/profiles/audio/source.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index dd1c553a2..fe20c988c 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index 78024372f..c226f74f3 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/battery/bas.c b/profiles/battery/bas.c index de369fd3c..51c28fa3b 100644 --- a/profiles/battery/bas.c +++ b/profiles/battery/bas.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/battery/bas.h b/profiles/battery/bas.h index 3e175b5b5..4d85e1e6c 100644 --- a/profiles/battery/bas.h +++ b/profiles/battery/bas.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c index c9a1af4b9..da46858f6 100644 --- a/profiles/battery/battery.c +++ b/profiles/battery/battery.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/cups/cups.h b/profiles/cups/cups.h index f4e0c01cd..98bf7a596 100644 --- a/profiles/cups/cups.h +++ b/profiles/cups/cups.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/cups/hcrp.c b/profiles/cups/hcrp.c index edaa2cdfd..a3be5dbe9 100644 --- a/profiles/cups/hcrp.c +++ b/profiles/cups/hcrp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/cups/main.c b/profiles/cups/main.c index 1fac7267f..c91e4a4b4 100644 --- a/profiles/cups/main.c +++ b/profiles/cups/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/cups/sdp.c b/profiles/cups/sdp.c index de9cd4eeb..d79bd9540 100644 --- a/profiles/cups/sdp.c +++ b/profiles/cups/sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/cups/spp.c b/profiles/cups/spp.c index 2f1e270f4..b19a322ee 100644 --- a/profiles/cups/spp.c +++ b/profiles/cups/spp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/deviceinfo/deviceinfo.c b/profiles/deviceinfo/deviceinfo.c index fa94efe7f..cd68b469a 100644 --- a/profiles/deviceinfo/deviceinfo.c +++ b/profiles/deviceinfo/deviceinfo.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/deviceinfo/dis.c b/profiles/deviceinfo/dis.c index 6126a776c..ca4a96206 100644 --- a/profiles/deviceinfo/dis.c +++ b/profiles/deviceinfo/dis.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/deviceinfo/dis.h b/profiles/deviceinfo/dis.h index 305ba1ad0..914f9497d 100644 --- a/profiles/deviceinfo/dis.h +++ b/profiles/deviceinfo/dis.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/gap/gas.c b/profiles/gap/gas.c index dffa31314..a0a3d9da6 100644 --- a/profiles/gap/gas.c +++ b/profiles/gap/gas.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c index a8354936b..8a8698769 100644 --- a/profiles/health/hdp.c +++ b/profiles/health/hdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/health/hdp.h b/profiles/health/hdp.h index 6e78b0947..9f1c25908 100644 --- a/profiles/health/hdp.h +++ b/profiles/health/hdp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/health/hdp_main.c b/profiles/health/hdp_main.c index 2c4bbe298..23f6eac0d 100644 --- a/profiles/health/hdp_main.c +++ b/profiles/health/hdp_main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/health/hdp_manager.c b/profiles/health/hdp_manager.c index 401adf6e9..01a1e1c22 100644 --- a/profiles/health/hdp_manager.c +++ b/profiles/health/hdp_manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/health/hdp_manager.h b/profiles/health/hdp_manager.h index 1cab4d008..99f151a56 100644 --- a/profiles/health/hdp_manager.h +++ b/profiles/health/hdp_manager.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/health/hdp_types.h b/profiles/health/hdp_types.h index b34b5e031..44f3b286f 100644 --- a/profiles/health/hdp_types.h +++ b/profiles/health/hdp_types.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c index 64debfc6b..736ec6efa 100644 --- a/profiles/health/hdp_util.c +++ b/profiles/health/hdp_util.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/health/hdp_util.h b/profiles/health/hdp_util.h index 35e1196b2..5048e708a 100644 --- a/profiles/health/hdp_util.h +++ b/profiles/health/hdp_util.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c index ba43e6e96..ecd1491a2 100644 --- a/profiles/health/mcap.c +++ b/profiles/health/mcap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/health/mcap.h b/profiles/health/mcap.h index 69873ca82..c52c07cd9 100644 --- a/profiles/health/mcap.h +++ b/profiles/health/mcap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/iap/main.c b/profiles/iap/main.c index 2fd34c067..3ce6a4eac 100644 --- a/profiles/iap/main.c +++ b/profiles/iap/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/device.c b/profiles/input/device.c index 375314e7d..d3f49c4a0 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/device.h b/profiles/input/device.h index f61e8a558..a1394f92b 100644 --- a/profiles/input/device.h +++ b/profiles/input/device.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/hidp_defs.h b/profiles/input/hidp_defs.h index bb9231dbb..533750efb 100644 --- a/profiles/input/hidp_defs.h +++ b/profiles/input/hidp_defs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c index e96c969b7..9b0770cf1 100644 --- a/profiles/input/hog-lib.c +++ b/profiles/input/hog-lib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/hog-lib.h b/profiles/input/hog-lib.h index 415dc63d2..f90017069 100644 --- a/profiles/input/hog-lib.h +++ b/profiles/input/hog-lib.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/hog.c b/profiles/input/hog.c index 130f696a9..7a3ecd0f5 100644 --- a/profiles/input/hog.c +++ b/profiles/input/hog.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/manager.c b/profiles/input/manager.c index bf4acb4ed..7ef9a90db 100644 --- a/profiles/input/manager.c +++ b/profiles/input/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/server.c b/profiles/input/server.c index 2bd5e92e4..f5cac6860 100644 --- a/profiles/input/server.c +++ b/profiles/input/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/server.h b/profiles/input/server.h index 74159bbd7..f4b15a462 100644 --- a/profiles/input/server.h +++ b/profiles/input/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/sixaxis.h b/profiles/input/sixaxis.h index 8e6f3cc18..871cb1c8f 100644 --- a/profiles/input/sixaxis.h +++ b/profiles/input/sixaxis.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-dummy.c index 542ae2592..84c5b6762 100644 --- a/profiles/input/suspend-dummy.c +++ b/profiles/input/suspend-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/suspend-none.c b/profiles/input/suspend-none.c index c619bb11e..51cf20912 100644 --- a/profiles/input/suspend-none.c +++ b/profiles/input/suspend-none.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/suspend.h b/profiles/input/suspend.h index bfee3cfef..0e8131d5a 100644 --- a/profiles/input/suspend.h +++ b/profiles/input/suspend.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/input/uhid_copy.h b/profiles/input/uhid_copy.h index 0ef73d4cc..f8d817e49 100644 --- a/profiles/input/uhid_copy.h +++ b/profiles/input/uhid_copy.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef __UHID_H_ #define __UHID_H_ diff --git a/profiles/midi/libmidi.c b/profiles/midi/libmidi.c index cb2787db1..40d4b017a 100644 --- a/profiles/midi/libmidi.c +++ b/profiles/midi/libmidi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/midi/libmidi.h b/profiles/midi/libmidi.h index 9d94065b6..e112f2aad 100644 --- a/profiles/midi/libmidi.h +++ b/profiles/midi/libmidi.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/midi/midi.c b/profiles/midi/midi.c index 1ee5cb16f..fc902996a 100644 --- a/profiles/midi/midi.c +++ b/profiles/midi/midi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c index d0ad9e483..4e017435f 100644 --- a/profiles/network/bnep.c +++ b/profiles/network/bnep.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/network/bnep.h b/profiles/network/bnep.h index e9f4c1cf2..ad1d50543 100644 --- a/profiles/network/bnep.h +++ b/profiles/network/bnep.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/network/connection.c b/profiles/network/connection.c index 170841de6..050bfd5a7 100644 --- a/profiles/network/connection.c +++ b/profiles/network/connection.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/network/connection.h b/profiles/network/connection.h index 4a8b43bc8..2e9a3459b 100644 --- a/profiles/network/connection.h +++ b/profiles/network/connection.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/network/manager.c b/profiles/network/manager.c index 41377fb83..aa0c06111 100644 --- a/profiles/network/manager.c +++ b/profiles/network/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/network/server.c b/profiles/network/server.c index c462677ed..d8f202818 100644 --- a/profiles/network/server.c +++ b/profiles/network/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/network/server.h b/profiles/network/server.h index a76e6f7b2..a431e7e50 100644 --- a/profiles/network/server.h +++ b/profiles/network/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/sap/main.c b/profiles/sap/main.c index cd707ff3e..967ec85d4 100644 --- a/profiles/sap/main.c +++ b/profiles/sap/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * diff --git a/profiles/sap/manager.c b/profiles/sap/manager.c index b62239780..4e59fc6c2 100644 --- a/profiles/sap/manager.c +++ b/profiles/sap/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * diff --git a/profiles/sap/manager.h b/profiles/sap/manager.h index 6601a034e..3373aa3a3 100644 --- a/profiles/sap/manager.h +++ b/profiles/sap/manager.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * BlueZ - Bluetooth protocol stack for Linux * diff --git a/profiles/sap/sap-dummy.c b/profiles/sap/sap-dummy.c index 53463ca7c..eca630961 100644 --- a/profiles/sap/sap-dummy.c +++ b/profiles/sap/sap-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * diff --git a/profiles/sap/sap.h b/profiles/sap/sap.h index 6e78d6c2d..8e5738821 100644 --- a/profiles/sap/sap.h +++ b/profiles/sap/sap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * BlueZ - Bluetooth protocol stack for Linux * diff --git a/profiles/sap/server.c b/profiles/sap/server.c index 5de682a33..8f4ba4725 100644 --- a/profiles/sap/server.c +++ b/profiles/sap/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * diff --git a/profiles/sap/server.h b/profiles/sap/server.h index 4bf9296ad..97ba34741 100644 --- a/profiles/sap/server.h +++ b/profiles/sap/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * BlueZ - Bluetooth protocol stack for Linux * diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c index d72be3dff..4471ef119 100644 --- a/profiles/scanparam/scan.c +++ b/profiles/scanparam/scan.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/scanparam/scpp.c b/profiles/scanparam/scpp.c index df65d2c1e..b92ff1aae 100644 --- a/profiles/scanparam/scpp.c +++ b/profiles/scanparam/scpp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/profiles/scanparam/scpp.h b/profiles/scanparam/scpp.h index 048fb9f23..260fc8a96 100644 --- a/profiles/scanparam/scpp.h +++ b/profiles/scanparam/scpp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2L0eFFiTXV/zywEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 05:34:48 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gIS4EFiTXV/VGgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 05:34:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E49A7A0B48; Sun, 13 Sep 2020 05:34:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725927AbgIMDeU (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 23:34:20 -0400 Received: from mga05.intel.com ([192.55.52.43]:59033 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725910AbgIMDeJ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 23:34:09 -0400 IronPort-SDR: IZgXSGH1gMaOAjMsRELmhSq5NNveNtwiTjECmStHiXRU1tUIrnjTcOZUqbq1vhPhS/L7LmYwrm k6+u9KU+WNlQ== X-IronPort-AV: E=McAfee;i="6000,8403,9742"; a="243784905" X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="243784905" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:01 -0700 IronPort-SDR: zCJ1Wec+p1aRp0vDE0H2l+uhJSqqlroFNcZqupwZ7XrLFm3pcgbjguKqoLLn//rU8imqy7WY0E ++vhxiQNM5jA== X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="301347240" Received: from han1-mobl3.jf.intel.com ([10.251.29.101]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:00 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v2 16/17] src: Add SPDX License Identifier Date: Sat, 12 Sep 2020 20:33:40 -0700 Message-Id: <20200913033341.4639-17-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200913033341.4639-1-tedd.an@linux.intel.com> References: <20200913033341.4639-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: E49A7A0B48 X-Rspamd-UID: c45200 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 51 LGPL-2.1-or-later : 60 BSD-2-Clause : 2 License: GPL-2.0-or-later src/attrib-server.h src/advertising.h src/textfile.c src/attrib-server.c src/uinput.h src/log.h src/eir.h src/sdpd.h src/sdpd-request.c src/service.h src/sdpd-database.c src/adapter.h src/plugin.h src/uuid-helper.h src/plugin.c src/main.c src/sdp-xml.c src/error.h src/oui.c src/device.c src/agent.h src/sdp-client.c src/oui.h src/device.h src/gatt-database.c src/error.c src/backtrace.c src/sdpd-server.c src/adapter.c src/log.c src/agent.c src/backtrace.h src/sdp-xml.h src/hcid.h src/dbus-common.h src/uuid-helper.c src/storage.c src/profile.c src/advertising.c src/storage.h src/dbus-common.c src/profile.h src/sdpd-service.c src/eir.c src/sdp-client.h src/gatt-database.h src/gatt-client.h src/rfkill.c src/gatt-client.c src/service.c src/textfile.h License: LGPL-2.1-or-later src/shared/mainloop-glib.c src/shared/btp.c src/shared/tester.c src/shared/btsnoop.c src/shared/gatt-helpers.h src/shared/log.h src/shared/util.h src/shared/mainloop-ell.c src/shared/hci-crypto.c src/shared/mainloop.c src/shared/hfp.h src/shared/mainloop-notify.c src/shared/io-mainloop.c src/shared/btsnoop.h src/shared/uhid.h src/shared/util.c src/shared/ringbuf.c src/shared/btp.h src/shared/shell.h src/shared/io-glib.c src/shared/queue.h src/shared/gatt-server.h src/shared/crypto.c src/shared/crypto.h src/shared/io-ell.c src/shared/timeout-glib.c src/shared/mgmt.c src/shared/gatt-db.c src/shared/mainloop-notify.h src/shared/hfp.c src/shared/timeout-ell.c src/shared/shell.c src/shared/hci.c src/shared/log.c src/shared/ringbuf.h src/shared/gatt-helpers.c src/shared/queue.c src/shared/tty.h src/shared/timeout-mainloop.c src/shared/tester.h src/shared/gap.h src/shared/mgmt.h src/shared/gatt-db.h src/shared/uhid.c src/shared/mainloop.h src/shared/timeout.h src/shared/att-types.h src/shared/pcap.c src/shared/gap.c src/shared/att.c src/shared/pcap.h src/shared/hci.h src/shared/gatt-client.h src/shared/io.h src/shared/gatt-client.c src/shared/ad.c src/shared/att.h src/shared/gatt-server.c src/shared/hci-crypto.h src/shared/ad.h License: BSD-2-Clause src/shared/ecc.h src/shared/ecc.c --- src/adapter.c | 1 + src/adapter.h | 1 + src/advertising.c | 1 + src/advertising.h | 1 + src/agent.c | 1 + src/agent.h | 1 + src/attrib-server.c | 1 + src/attrib-server.h | 1 + src/backtrace.c | 1 + src/backtrace.h | 1 + src/dbus-common.c | 1 + src/dbus-common.h | 1 + src/device.c | 1 + src/device.h | 1 + src/eir.c | 1 + src/eir.h | 1 + src/error.c | 1 + src/error.h | 1 + src/gatt-client.c | 1 + src/gatt-client.h | 1 + src/gatt-database.c | 1 + src/gatt-database.h | 1 + src/hcid.h | 1 + src/log.c | 1 + src/log.h | 1 + src/main.c | 1 + src/oui.c | 1 + src/oui.h | 1 + src/plugin.c | 1 + src/plugin.h | 1 + src/profile.c | 1 + src/profile.h | 1 + src/rfkill.c | 1 + src/sdp-client.c | 1 + src/sdp-client.h | 1 + src/sdp-xml.c | 1 + src/sdp-xml.h | 1 + src/sdpd-database.c | 1 + src/sdpd-request.c | 1 + src/sdpd-server.c | 1 + src/sdpd-service.c | 1 + src/sdpd.h | 1 + src/service.c | 1 + src/service.h | 1 + src/shared/ad.c | 1 + src/shared/ad.h | 1 + src/shared/att-types.h | 1 + src/shared/att.c | 1 + src/shared/att.h | 1 + src/shared/btp.c | 1 + src/shared/btp.h | 1 + src/shared/btsnoop.c | 1 + src/shared/btsnoop.h | 1 + src/shared/crypto.c | 1 + src/shared/crypto.h | 1 + src/shared/ecc.c | 1 + src/shared/ecc.h | 1 + src/shared/gap.c | 1 + src/shared/gap.h | 1 + src/shared/gatt-client.c | 1 + src/shared/gatt-client.h | 1 + src/shared/gatt-db.c | 1 + src/shared/gatt-db.h | 1 + src/shared/gatt-helpers.c | 1 + src/shared/gatt-helpers.h | 1 + src/shared/gatt-server.c | 1 + src/shared/gatt-server.h | 1 + src/shared/hci-crypto.c | 1 + src/shared/hci-crypto.h | 1 + src/shared/hci.c | 1 + src/shared/hci.h | 1 + src/shared/hfp.c | 1 + src/shared/hfp.h | 1 + src/shared/io-ell.c | 1 + src/shared/io-glib.c | 1 + src/shared/io-mainloop.c | 1 + src/shared/io.h | 1 + src/shared/log.c | 1 + src/shared/log.h | 1 + src/shared/mainloop-ell.c | 1 + src/shared/mainloop-glib.c | 1 + src/shared/mainloop-notify.c | 1 + src/shared/mainloop-notify.h | 1 + src/shared/mainloop.c | 1 + src/shared/mainloop.h | 1 + src/shared/mgmt.c | 1 + src/shared/mgmt.h | 1 + src/shared/pcap.c | 1 + src/shared/pcap.h | 1 + src/shared/queue.c | 1 + src/shared/queue.h | 1 + src/shared/ringbuf.c | 1 + src/shared/ringbuf.h | 1 + src/shared/shell.c | 1 + src/shared/shell.h | 1 + src/shared/tester.c | 1 + src/shared/tester.h | 1 + src/shared/timeout-ell.c | 1 + src/shared/timeout-glib.c | 1 + src/shared/timeout-mainloop.c | 1 + src/shared/timeout.h | 1 + src/shared/tty.h | 1 + src/shared/uhid.c | 1 + src/shared/uhid.h | 1 + src/shared/util.c | 1 + src/shared/util.h | 1 + src/storage.c | 1 + src/storage.h | 1 + src/textfile.c | 1 + src/textfile.h | 1 + src/uinput.h | 1 + src/uuid-helper.c | 1 + src/uuid-helper.h | 1 + 113 files changed, 113 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 1435e2bd7..9b4a3523e 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..ced0bb6e9 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/advertising.c b/src/advertising.c index e5f25948d..3856ff32d 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/advertising.h b/src/advertising.h index 50d86674b..79c559431 100644 --- a/src/advertising.h +++ b/src/advertising.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/agent.c b/src/agent.c index e0ffcd22f..5df15fc7c 100644 --- a/src/agent.c +++ b/src/agent.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/agent.h b/src/agent.h index 1438b9e6d..06dc8c765 100644 --- a/src/agent.h +++ b/src/agent.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/attrib-server.c b/src/attrib-server.c index 7c15a4e8f..877179a41 100644 --- a/src/attrib-server.c +++ b/src/attrib-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/attrib-server.h b/src/attrib-server.h index 063cb6621..69d60c1a8 100644 --- a/src/attrib-server.h +++ b/src/attrib-server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/backtrace.c b/src/backtrace.c index c43873354..c5bbeeaf9 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/backtrace.h b/src/backtrace.h index b3eef6dd9..3094f1aaa 100644 --- a/src/backtrace.h +++ b/src/backtrace.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/dbus-common.c b/src/dbus-common.c index 6e2097a2d..f099647bb 100644 --- a/src/dbus-common.c +++ b/src/dbus-common.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/dbus-common.h b/src/dbus-common.h index fbf4acd28..f1bbe28d3 100644 --- a/src/dbus-common.h +++ b/src/dbus-common.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * diff --git a/src/device.c b/src/device.c index 8f73ce4d3..83f928c30 100644 --- a/src/device.c +++ b/src/device.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/device.h b/src/device.h index 3cd090786..2c081662e 100644 --- a/src/device.h +++ b/src/device.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/eir.c b/src/eir.c index fa52a2bd8..61ce1728d 100644 --- a/src/eir.c +++ b/src/eir.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/eir.h b/src/eir.h index c868177a6..929472098 100644 --- a/src/eir.h +++ b/src/eir.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/error.c b/src/error.c index 89517075e..e01636f68 100644 --- a/src/error.c +++ b/src/error.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/error.h b/src/error.h index 7c8cad066..158afe556 100644 --- a/src/error.h +++ b/src/error.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/gatt-client.c b/src/gatt-client.c index 20c3fbec2..d618af607 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/gatt-client.h b/src/gatt-client.h index 92a925546..e277ed1f8 100644 --- a/src/gatt-client.h +++ b/src/gatt-client.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/gatt-database.c b/src/gatt-database.c index e7e4a36a6..a83ec336e 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/gatt-database.h b/src/gatt-database.h index 154d3243f..9d0de0bbc 100644 --- a/src/gatt-database.h +++ b/src/gatt-database.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/hcid.h b/src/hcid.h index 3624ba6ea..e77c6a030 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/log.c b/src/log.c index a42c5941d..76c501809 100644 --- a/src/log.c +++ b/src/log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/log.h b/src/log.h index e83431151..77887088c 100644 --- a/src/log.h +++ b/src/log.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/main.c b/src/main.c index b37c32948..73b34d0ce 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/oui.c b/src/oui.c index 8059c0a89..32cad253c 100644 --- a/src/oui.c +++ b/src/oui.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/oui.h b/src/oui.h index 2ddc27fef..3696a981e 100644 --- a/src/oui.h +++ b/src/oui.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/plugin.c b/src/plugin.c index 39310a7db..30cc02274 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/plugin.h b/src/plugin.h index 89c7b8515..3335ed54d 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/profile.c b/src/profile.c index 6961a107b..8f417dbb1 100644 --- a/src/profile.c +++ b/src/profile.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/profile.h b/src/profile.h index 95523e50a..b5dac8e88 100644 --- a/src/profile.h +++ b/src/profile.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/rfkill.c b/src/rfkill.c index fb2d11306..8f63f464d 100644 --- a/src/rfkill.c +++ b/src/rfkill.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/sdp-client.c b/src/sdp-client.c index b92a083af..e3f26d764 100644 --- a/src/sdp-client.c +++ b/src/sdp-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/sdp-client.h b/src/sdp-client.h index 3a7212fd2..70d669d07 100644 --- a/src/sdp-client.h +++ b/src/sdp-client.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/sdp-xml.c b/src/sdp-xml.c index 6f831737d..8f7f0c314 100644 --- a/src/sdp-xml.c +++ b/src/sdp-xml.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/sdp-xml.h b/src/sdp-xml.h index 80a4f446d..bb99b0954 100644 --- a/src/sdp-xml.h +++ b/src/sdp-xml.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/sdpd-database.c b/src/sdpd-database.c index 843b6d02b..518ef7a2f 100644 --- a/src/sdpd-database.c +++ b/src/sdpd-database.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/sdpd-request.c b/src/sdpd-request.c index deaed266f..a3d6443ff 100644 --- a/src/sdpd-request.c +++ b/src/sdpd-request.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/sdpd-server.c b/src/sdpd-server.c index ef35309ce..a3903ea57 100644 --- a/src/sdpd-server.c +++ b/src/sdpd-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/sdpd-service.c b/src/sdpd-service.c index c3ee3eb48..bf03082f8 100644 --- a/src/sdpd-service.c +++ b/src/sdpd-service.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/sdpd.h b/src/sdpd.h index 49cd98a2b..a4dd38e87 100644 --- a/src/sdpd.h +++ b/src/sdpd.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/service.c b/src/service.c index e4d747a6e..072e937e6 100644 --- a/src/service.c +++ b/src/service.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/service.h b/src/service.h index 6f1edfb8f..a56e1be4b 100644 --- a/src/service.h +++ b/src/service.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/ad.c b/src/shared/ad.c index 14a2709b1..819b8b4cb 100644 --- a/src/shared/ad.c +++ b/src/shared/ad.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/ad.h b/src/shared/ad.h index 17e3b631b..809e7bbdc 100644 --- a/src/shared/ad.h +++ b/src/shared/ad.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/att-types.h b/src/shared/att-types.h index 99b108990..5fa0bc7b4 100644 --- a/src/shared/att-types.h +++ b/src/shared/att-types.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/att.c b/src/shared/att.c index 58f23dfcb..89500ebc7 100644 --- a/src/shared/att.c +++ b/src/shared/att.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/att.h b/src/shared/att.h index ed20bb5b8..401eba9e7 100644 --- a/src/shared/att.h +++ b/src/shared/att.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/btp.c b/src/shared/btp.c index 7eea241a2..f5833e42b 100644 --- a/src/shared/btp.c +++ b/src/shared/btp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/btp.h b/src/shared/btp.h index f0ac3a1ee..f9a1b1dd7 100644 --- a/src/shared/btp.h +++ b/src/shared/btp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/btsnoop.c b/src/shared/btsnoop.c index f0d074743..31f671c20 100644 --- a/src/shared/btsnoop.c +++ b/src/shared/btsnoop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/btsnoop.h b/src/shared/btsnoop.h index 5fb084aa2..b20723a64 100644 --- a/src/shared/btsnoop.h +++ b/src/shared/btsnoop.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/crypto.c b/src/shared/crypto.c index 5cc88ce4a..430d82573 100644 --- a/src/shared/crypto.c +++ b/src/shared/crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/crypto.h b/src/shared/crypto.h index d17daa835..30749df8d 100644 --- a/src/shared/crypto.h +++ b/src/shared/crypto.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/ecc.c b/src/shared/ecc.c index 1b45e0d0a..04c7dd9d6 100644 --- a/src/shared/ecc.c +++ b/src/shared/ecc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: BSD-2-Clause /* * Copyright (c) 2013, Kenneth MacKay * All rights reserved. diff --git a/src/shared/ecc.h b/src/shared/ecc.h index 8c15e4ee8..f7b155452 100644 --- a/src/shared/ecc.h +++ b/src/shared/ecc.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ /* * Copyright (c) 2013, Kenneth MacKay * All rights reserved. diff --git a/src/shared/gap.c b/src/shared/gap.c index 0b8d073c5..b9df64139 100644 --- a/src/shared/gap.c +++ b/src/shared/gap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/gap.h b/src/shared/gap.h index 52c264a8e..dcfefcd1f 100644 --- a/src/shared/gap.h +++ b/src/shared/gap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index f15466673..b596ef3f9 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/gatt-client.h b/src/shared/gatt-client.h index 10900168b..f3cb6bc47 100644 --- a/src/shared/gatt-client.h +++ b/src/shared/gatt-client.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index e939ddc3a..b9e4187a5 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h index 5bf19d302..a15789ef4 100644 --- a/src/shared/gatt-db.h +++ b/src/shared/gatt-db.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c index 6b39bb161..75f75ee59 100644 --- a/src/shared/gatt-helpers.c +++ b/src/shared/gatt-helpers.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/gatt-helpers.h b/src/shared/gatt-helpers.h index dd9dd1c44..4923d27ae 100644 --- a/src/shared/gatt-helpers.h +++ b/src/shared/gatt-helpers.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c index 28ac2d68d..295b1811b 100644 --- a/src/shared/gatt-server.c +++ b/src/shared/gatt-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/gatt-server.h b/src/shared/gatt-server.h index a2492d275..88db54c16 100644 --- a/src/shared/gatt-server.h +++ b/src/shared/gatt-server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/hci-crypto.c b/src/shared/hci-crypto.c index f7507472b..cd635a670 100644 --- a/src/shared/hci-crypto.c +++ b/src/shared/hci-crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/hci-crypto.h b/src/shared/hci-crypto.h index b090c2410..420626c93 100644 --- a/src/shared/hci-crypto.h +++ b/src/shared/hci-crypto.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/hci.c b/src/shared/hci.c index 262e93d5a..e931e1e03 100644 --- a/src/shared/hci.c +++ b/src/shared/hci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/hci.h b/src/shared/hci.h index dba0f11db..b44f56f75 100644 --- a/src/shared/hci.h +++ b/src/shared/hci.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/hfp.c b/src/shared/hfp.c index f4747b4ca..7da48bd2b 100644 --- a/src/shared/hfp.c +++ b/src/shared/hfp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/hfp.h b/src/shared/hfp.h index 2eb783849..859303d95 100644 --- a/src/shared/hfp.h +++ b/src/shared/hfp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/io-ell.c b/src/shared/io-ell.c index 6748982c7..47f44475b 100644 --- a/src/shared/io-ell.c +++ b/src/shared/io-ell.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/io-glib.c b/src/shared/io-glib.c index d62de4e10..a518780d7 100644 --- a/src/shared/io-glib.c +++ b/src/shared/io-glib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/io-mainloop.c b/src/shared/io-mainloop.c index 2306c3479..0fcb21968 100644 --- a/src/shared/io-mainloop.c +++ b/src/shared/io-mainloop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/io.h b/src/shared/io.h index 8bc1111d0..1944470a3 100644 --- a/src/shared/io.h +++ b/src/shared/io.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/log.c b/src/shared/log.c index 7c8b71220..d8f6442fc 100644 --- a/src/shared/log.c +++ b/src/shared/log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/log.h b/src/shared/log.h index c72ab735b..7dab6126c 100644 --- a/src/shared/log.h +++ b/src/shared/log.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/mainloop-ell.c b/src/shared/mainloop-ell.c index 63e254ac6..7bb447378 100644 --- a/src/shared/mainloop-ell.c +++ b/src/shared/mainloop-ell.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/mainloop-glib.c b/src/shared/mainloop-glib.c index 2508a1fb2..4913e544e 100644 --- a/src/shared/mainloop-glib.c +++ b/src/shared/mainloop-glib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/mainloop-notify.c b/src/shared/mainloop-notify.c index 1de714a0e..f9b1efca5 100644 --- a/src/shared/mainloop-notify.c +++ b/src/shared/mainloop-notify.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/mainloop-notify.h b/src/shared/mainloop-notify.h index 721b5fbed..5b4cf08ac 100644 --- a/src/shared/mainloop-notify.h +++ b/src/shared/mainloop-notify.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/mainloop.c b/src/shared/mainloop.c index 8a8e2c022..0b8f91bb2 100644 --- a/src/shared/mainloop.c +++ b/src/shared/mainloop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/mainloop.h b/src/shared/mainloop.h index 1ede62797..34cb6d557 100644 --- a/src/shared/mainloop.h +++ b/src/shared/mainloop.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c index 277e361a6..8c356d84d 100644 --- a/src/shared/mgmt.c +++ b/src/shared/mgmt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h index 7caeb3844..f80e18364 100644 --- a/src/shared/mgmt.h +++ b/src/shared/mgmt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/pcap.c b/src/shared/pcap.c index 0d887e24c..5c41b896d 100644 --- a/src/shared/pcap.c +++ b/src/shared/pcap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/pcap.h b/src/shared/pcap.h index b47de62e8..96b927ee3 100644 --- a/src/shared/pcap.h +++ b/src/shared/pcap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/queue.c b/src/shared/queue.c index 60df11143..4efb12e23 100644 --- a/src/shared/queue.c +++ b/src/shared/queue.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/queue.h b/src/shared/queue.h index 8cd817cc0..b03ac74ae 100644 --- a/src/shared/queue.h +++ b/src/shared/queue.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/ringbuf.c b/src/shared/ringbuf.c index 8cf0b5b19..8cc32aac0 100644 --- a/src/shared/ringbuf.c +++ b/src/shared/ringbuf.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/ringbuf.h b/src/shared/ringbuf.h index adf471a43..4452853fe 100644 --- a/src/shared/ringbuf.h +++ b/src/shared/ringbuf.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/shell.c b/src/shared/shell.c index d58e2d7d1..30d2fbbb4 100644 --- a/src/shared/shell.c +++ b/src/shared/shell.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/shell.h b/src/shared/shell.h index e14d58381..8d03dec06 100644 --- a/src/shared/shell.h +++ b/src/shared/shell.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/tester.c b/src/shared/tester.c index 62e5c1aae..eb15694ed 100644 --- a/src/shared/tester.c +++ b/src/shared/tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/tester.h b/src/shared/tester.h index 96e8dc901..796e57c92 100644 --- a/src/shared/tester.h +++ b/src/shared/tester.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/timeout-ell.c b/src/shared/timeout-ell.c index 8419d4617..5081d2f66 100644 --- a/src/shared/timeout-ell.c +++ b/src/shared/timeout-ell.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/timeout-glib.c b/src/shared/timeout-glib.c index fd71ca430..91494538c 100644 --- a/src/shared/timeout-glib.c +++ b/src/shared/timeout-glib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/timeout-mainloop.c b/src/shared/timeout-mainloop.c index 971124a2e..7cbec435f 100644 --- a/src/shared/timeout-mainloop.c +++ b/src/shared/timeout-mainloop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/timeout.h b/src/shared/timeout.h index 4930ce162..cab335dd4 100644 --- a/src/shared/timeout.h +++ b/src/shared/timeout.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/tty.h b/src/shared/tty.h index 66ec09f31..9b7ca9688 100644 --- a/src/shared/tty.h +++ b/src/shared/tty.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/uhid.c b/src/shared/uhid.c index 71a4e04ba..09d4e2de2 100644 --- a/src/shared/uhid.c +++ b/src/shared/uhid.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/uhid.h b/src/shared/uhid.h index dbdca852d..0c7e79aa4 100644 --- a/src/shared/uhid.h +++ b/src/shared/uhid.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/util.c b/src/shared/util.c index 4ecf31a03..2ba8a2a3a 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/shared/util.h b/src/shared/util.h index 9193068d1..3753ce2c6 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/storage.c b/src/storage.c index 8cbb5b270..a764e4a6f 100644 --- a/src/storage.c +++ b/src/storage.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/storage.h b/src/storage.h index 1c0ad57ec..2d766542d 100644 --- a/src/storage.h +++ b/src/storage.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/textfile.c b/src/textfile.c index 371651bd8..4f7ed3d72 100644 --- a/src/textfile.c +++ b/src/textfile.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/textfile.h b/src/textfile.h index f01629e43..87dfdabd5 100644 --- a/src/textfile.h +++ b/src/textfile.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/uinput.h b/src/uinput.h index 20e0941d1..3b96b331a 100644 --- a/src/uinput.h +++ b/src/uinput.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/uuid-helper.c b/src/uuid-helper.c index 2c897d86c..df90c7992 100644 --- a/src/uuid-helper.c +++ b/src/uuid-helper.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/src/uuid-helper.h b/src/uuid-helper.h index c0d7f9eec..304bc71c3 100644 --- a/src/uuid-helper.h +++ b/src/uuid-helper.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eEx9J9t4XF/LHgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 09:29:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UMBhJNt4XF+xgAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 09:29:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9038440618; Sat, 12 Sep 2020 09:29:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725859AbgILH3W (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 03:29:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725820AbgILH3U (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 03:29:20 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2088EC061573 for <linux-bluetooth@vger.kernel.org>; Sat, 12 Sep 2020 00:29:20 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id o5so12151511qke.12 for <linux-bluetooth@vger.kernel.org>; Sat, 12 Sep 2020 00:29:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=i/o0X33HGBCzKetBjXz7CGLqnszwCjMaz1oe3js2hn0=; b=Sxj0db2l/AWxUFfGuK6FVaLnbO97WsOn1XKNKRXzwmXVKbqBwqGtN455Ft67ZrqOYy SUmNTAy1xy2z6yBPaONYgnSW45CFV0tlpAlY5O3qP6lhHDF+6HZrlU8Al9cbvp1VJIxm 2TyjHwn+FNYd8fQRtbeZguzbF79OzsZRB6bteKQCtVdKMJygoV8wTOQFfZuDqAmIcaOj mN7JLtdPYyxSnhUJftpm2geLI0JROoGKIqzPtroMOecRx2VwQFkeVXgKwKBlHPeoeQHV wEbaRaVd6qVLdwHPOEWtue3qxJumbvItOZOj8nW8IJvHuvGQnnkdu+TDNgxSCXVbsbEC fdNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=i/o0X33HGBCzKetBjXz7CGLqnszwCjMaz1oe3js2hn0=; b=AicSIZbgKB2kjOHcQ8QvTaXT46NcULtY2zf1snyPZbjavHTUthFmLSN2UKNLFfstHN ZC909v7fHNIfm2hafSum1+3Q8zyh0BqadQTikkBz+XBitUDX9uNN3zl+7pskxxwy+7+M 2O2McezyT9G9/E4t+0v5wb0E8gtw9RoInkUDnU07dOWLmuBLGZw839/EeGewNT4bL4Rs ALfVGP+Dt/rgqY0zQeJTx114gFXcRdGUW0hVdFTQUD7j5Pdwz7CyPdZO2fSHkW7HPjuW 2XW21ghYXjFhLwI+OQKv7UsknMCYcUr/98ncJ5TRwn+2XE3ZRpTOcrSGvuHXkE5ias37 L+ag== X-Gm-Message-State: AOAM531KHuY00ZzYsT3v6OXhGQOTT6xe5kkoqHRbOHZh2waY6KrVmv0O vZKJdWajV2qonLR2MRipLuSztjfL+duemQ== X-Google-Smtp-Source: ABdhPJwPKcwIxpe+22zSjyUBTCDgJ/RYP7M4p+1HMZXwwD09I9JByUpUVQcffPWt9VVhs2HEiwsSLw== X-Received: by 2002:a05:620a:222:: with SMTP id u2mr4706940qkm.218.1599895757867; Sat, 12 Sep 2020 00:29:17 -0700 (PDT) Received: from [172.17.0.2] ([20.36.204.96]) by smtp.gmail.com with ESMTPSA id x197sm5635873qkb.17.2020.09.12.00.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 00:29:17 -0700 (PDT) Message-ID: <5f5c78cd.1c69fb81.72417.e857@mx.google.com> Date: Sat, 12 Sep 2020 00:29:17 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============5872809771856964816==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v5,2/8] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200911235104.BlueZ.v5.2.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> References: <20200911235104.BlueZ.v5.2.I205718871f4e636958904f3cfb171cfd381c54b1@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.58 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9038440618 X-Rspamd-UID: 44949d --===============5872809771856964816== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #94: FILE: src/adv_monitor.c:1: +/* WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #247: FILE: src/adv_monitor.h:1: +/* - total: 0 errors, 2 warnings, 235 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============5872809771856964816==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2ILRHop5XF/LHgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 09:32:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wGyUG4p5XF95+gAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 09:32:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 792D240969; Sat, 12 Sep 2020 09:32:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725817AbgILHcT (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 03:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725808AbgILHcS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 03:32:18 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A7C6C061573 for <linux-bluetooth@vger.kernel.org>; Sat, 12 Sep 2020 00:32:18 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id z2so9693435qtv.12 for <linux-bluetooth@vger.kernel.org>; Sat, 12 Sep 2020 00:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=yovLI8ZEhh1gh7DqDB6gLtvUWYfVe6sEpqCKxlDnes8=; b=DvWaVO6WqGJr4rNWUq4OFv4+bjajEdCsPrxfssh33HiehF1pQFxOfRtoP0TSiU1RIq Mw33B+UZh2ZvPIfovIFoSozeSGuT3KNME9vrQaG8q8QKgmGhROGwd6lWKYKUoodYno4K mQ0flVB84c3vzA+v7/cYkenzwpIPXNclR/g7RpBrBPFkZusE0bJ/8zYXkIXtwMdwVT3H RZFSom0NrK0GbzzbA2+uqgIiEpO2cQ23UEPmiUR+L9HBbcU6+wcHMROWHstziIQGcE6W c14VcHVVPSqkv+a/XEPe8BuTUsz9KFzLAxZtpQGwne0N3AeU0udnreM9KhwkO2t9isWR EGXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=yovLI8ZEhh1gh7DqDB6gLtvUWYfVe6sEpqCKxlDnes8=; b=Y5TFfV73rZ3zFewlE7DSNysJenU/n3rpai+SpUK9uv/OEy05AKU2bjdJs2oM7snhOr RBRvZyvnw3WTuNVndQiDrdNVIL14M9hRbkfBHUUHkCM3eNlqF1gUH5PV329Pah3cFQOi AptMAX5HWs7sGO8vL93QqOUtbWA0lemOKiCy74LK8IFDg+jo4JJJxdNj5yyoV+WUeUui EX+ZX8NyZwXsH+ELLKRwnd4bZOlrgYQnP5+lnhQuJ8n1DAd2cFmUdj17TZMG0JvOpe9w Jd9or43EasPH1EgTxa4Th6wy+L2LxH/3lSlVBntXdieVV6isy8PSWwNnIO2KXuBOuYtW KFVw== X-Gm-Message-State: AOAM531ckI+C3d5E/ch0i7IGMZUWxyXSUD44eArBt35G/hzEhwwAulFY CpmYk92PBcwMSv7/PgKukdPcX4V13/te2g== X-Google-Smtp-Source: ABdhPJw6qLy07StL7gYdnvmtmMbhAVGg5O2hSGncJibP98NWSJI1GhDC8scd+LiemRfiNMSk/nt4oQ== X-Received: by 2002:ac8:47d4:: with SMTP id d20mr5171714qtr.199.1599895933400; Sat, 12 Sep 2020 00:32:13 -0700 (PDT) Received: from [172.17.0.2] ([20.36.204.96]) by smtp.gmail.com with ESMTPSA id n203sm5655296qke.66.2020.09.12.00.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 00:32:13 -0700 (PDT) Message-ID: <5f5c797d.1c69fb81.c5cc3.f44f@mx.google.com> Date: Sat, 12 Sep 2020 00:32:13 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============7141646533610779256==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v5,1/8] adapter: Remove indirect dependency of headers Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> References: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: 792D240969 X-Rspamd-UID: ac72c5 --===============7141646533610779256== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnNyYy9hZHZfbW9uaXRvci5jOiBJbiBmdW5jdGlvbiDigJhtb25pdG9y X21hdGNo4oCZOgpzcmMvYWR2X21vbml0b3IuYzoyNzY6Mzg6IGVycm9yOiBwYXNzaW5nIGFyZ3Vt ZW50IDEgb2Yg4oCYZ19kYnVzX3Byb3h5X2dldF9wYXRo4oCZIGRpc2NhcmRzIOKAmGNvbnN04oCZ IHF1YWxpZmllciBmcm9tIHBvaW50ZXIgdGFyZ2V0IHR5cGUgWy1XZXJyb3I9ZGlzY2FyZGVkLXF1 YWxpZmllcnNdCiAgMjc2IHwgIGlmIChnX3N0cmNtcDAoZ19kYnVzX3Byb3h5X2dldF9wYXRoKHBy b3h5KSwgbW9uaXRvci0+cGF0aCkgIT0gMCkKICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgXn5+fn4KSW4gZmlsZSBpbmNsdWRlZCBmcm9tIHNyYy9hZHZfbW9uaXRv ci5jOjMxOgouL2dkYnVzL2dkYnVzLmg6MzM2OjEzOiBub3RlOiBleHBlY3RlZCDigJhHREJ1c1By b3h5ICrigJkge2FrYSDigJhzdHJ1Y3QgR0RCdXNQcm94eSAq4oCZfSBidXQgYXJndW1lbnQgaXMg b2YgdHlwZSDigJhjb25zdCBHREJ1c1Byb3h5ICrigJkge2FrYSDigJhjb25zdCBzdHJ1Y3QgR0RC dXNQcm94eSAq4oCZfQogIDMzNiB8IGNvbnN0IGNoYXIgKmdfZGJ1c19wcm94eV9nZXRfcGF0aChH REJ1c1Byb3h5ICpwcm94eSk7CiAgICAgIHwgICAgICAgICAgICAgXn5+fn5+fn5+fn5+fn5+fn5+ fn5+CmNjMTogYWxsIHdhcm5pbmdzIGJlaW5nIHRyZWF0ZWQgYXMgZXJyb3JzCm1ha2VbMV06ICoq KiBbTWFrZWZpbGU6OTI3Mjogc3JjL2JsdWV0b290aGQtYWR2X21vbml0b3Iub10gRXJyb3IgMQpt YWtlOiAqKiogW01ha2VmaWxlOjQwMTQ6IGFsbF0gRXJyb3IgMgoKCgotLS0KUmVnYXJkcywKTGlu dXggQmx1ZXRvb3RoCg== --===============7141646533610779256==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gK9UHH16XF/LHgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 09:36:29 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id OMb8GH16XF/9CgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 09:36:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8412DA0AAE; Sat, 12 Sep 2020 09:36:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725832AbgILHgG (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 03:36:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbgILHgD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 03:36:03 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C78AFC061573; Sat, 12 Sep 2020 00:36:03 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id d6so8887169pfn.9; Sat, 12 Sep 2020 00:36:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=yYff2w6zlApOTzpZkutXOi9traPBbtwOxlc9tQk8BEM=; b=ZyEAXGRTCfDJ2C44NKeQntFzg/c6PLNgJoZkMV6VfQf9VbcqxSrEyq97A9n2lGEZn9 eGVQoslijGaDhRrgoQ0jv1L4ZRyQG4AXI1gdCLlthZmD0ehqrD9NnP0IOTgZt9/m3oua DrgWNWLi0jy1hiddHKq1QcjPRmkMCtUttwKb88zLn5wE9barXBjq7Yk2i0BtNErqBQLC q+X2CNSmvGqAcYvLakhnzI/RXdKM08vyaegXdglMfTQ482cg1BKfeFJHOqrNXTtf30pY G2Ah4X46Yrelys300zVEkzmn6TiTilwP/H1rlHOaVnzvhXQ2BHH+GS5Pfpqo79pykue8 xOdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=yYff2w6zlApOTzpZkutXOi9traPBbtwOxlc9tQk8BEM=; b=licDfG0+ufqtgwkCkSxFYVtdKS7aUoDJMBjU0UZE8i5gxKZ53Ssogog09SnAQhBOZS MAQcIEs+l7p2gwd1kEpauFT/Q0/9t+F0BxaXmZwcFG2iX0JD4pO2S1/FfueLjK5mjhH9 Axwn/t6WWP77hX1NDpy/Km7JTzWdiWsyIcUgms+uNqJ0kfuOuh54E4848onelXM9OecD aJepIIsEiR6KQjKEnKGa5maDppMcptdZkBLjERBJHYuHYjTZqRoRhlO/sp1NLw2hS3yy S2fH6+SNfIMdAFvsJJZf1eY2VR00fwjUJP+bTWW2wr9oqMlgADpQlwnSQvJZH5XAQ7K7 ZVfw== X-Gm-Message-State: AOAM531Nvjn6zqw6gu1013X5APgoi0nQWXI17KJFzVgK+76Hg/zZ/vkZ e3rrsh37eQshqd7M9Gfp7Do= X-Google-Smtp-Source: ABdhPJxu8IcukOIJI1s0BZL8A6kNS9HU/8+niTwFoTZlQ/bxh93pdbXAW7OLkjrea/0pcLPu4TC0Fw== X-Received: by 2002:a63:205d:: with SMTP id r29mr4090921pgm.278.1599896163066; Sat, 12 Sep 2020 00:36:03 -0700 (PDT) Received: from [192.168.0.104] ([49.207.202.95]) by smtp.gmail.com with ESMTPSA id y25sm4252568pfn.71.2020.09.12.00.35.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 12 Sep 2020 00:36:02 -0700 (PDT) Subject: Re: KASAN: use-after-free Read in hci_get_auth_info To: Dmitry Vyukov <dvyukov@google.com>, syzbot <syzbot+13010b6a10bbd82cc79c@syzkaller.appspotmail.com> Cc: David Miller <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, Jakub Kicinski <kuba@kernel.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, netdev <netdev@vger.kernel.org>, syzkaller-bugs <syzkaller-bugs@googlegroups.com> References: <000000000000e8fb4b05ac58372e@google.com> <CACT4Y+Z2Sz8kHxaQNuupfck7X0rUtr4ghDty9ahDTUm2H41Mwg@mail.gmail.com> From: Anant Thazhemadam <anant.thazhemadam@gmail.com> Message-ID: <f3724ef6-7c89-5c24-685e-00327046e144@gmail.com> Date: Sat, 12 Sep 2020 13:05:56 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: <CACT4Y+Z2Sz8kHxaQNuupfck7X0rUtr4ghDty9ahDTUm2H41Mwg@mail.gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.51 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8412DA0AAE X-Rspamd-UID: 96a4ab On 11-09-2020 15:20, Dmitry Vyukov wrote: > On Sat, Aug 8, 2020 at 8:56 AM syzbot > <syzbot+13010b6a10bbd82cc79c@syzkaller.appspotmail.com> wrote: >> Hello, >> >> syzbot found the following issue on: >> >> HEAD commit: d6efb3ac Merge tag 'tty-5.9-rc1' of git://git.kernel.org/p.. >> git tree: upstream >> console output: https://syzkaller.appspot.com/x/log.txt?x=14ad2134900000 >> kernel config: https://syzkaller.appspot.com/x/.config?x=61ec43e42a83feae >> dashboard link: https://syzkaller.appspot.com/bug?extid=13010b6a10bbd82cc79c >> compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) >> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12fd9bc6900000 >> >> IMPORTANT: if you fix the issue, please add the following tag to the commit: >> Reported-by: syzbot+13010b6a10bbd82cc79c@syzkaller.appspotmail.com > +Anant who had some questions re this issue. This bug doesn't seem to be getting triggered anymore for the appropriate kernel(s). However, given that neither the cause bisection, nor the fix bisection seem to have suceeded, it makes it all the more difficult to zero down on the commit that might've fixed this bug. Would it be okay to consider this a one-off, or invalid and close it off? (unless someone can point out the commit that fixed this, of course). Thanks for CCing me onto this, Dmitry. Thanks, Anant > >> ================================================================== >> BUG: KASAN: use-after-free in __mutex_waiter_is_first kernel/locking/mutex.c:200 [inline] >> BUG: KASAN: use-after-free in __mutex_lock_common+0x12cd/0x2fc0 kernel/locking/mutex.c:1040 >> Read of size 8 at addr ffff88808e668060 by task syz-executor.4/19584 >> >> CPU: 0 PID: 19584 Comm: syz-executor.4 Not tainted 5.8.0-syzkaller #0 >> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 >> Call Trace: >> __dump_stack lib/dump_stack.c:77 [inline] >> dump_stack+0x1f0/0x31e lib/dump_stack.c:118 >> print_address_description+0x66/0x5a0 mm/kasan/report.c:383 >> __kasan_report mm/kasan/report.c:513 [inline] >> kasan_report+0x132/0x1d0 mm/kasan/report.c:530 >> __mutex_waiter_is_first kernel/locking/mutex.c:200 [inline] >> __mutex_lock_common+0x12cd/0x2fc0 kernel/locking/mutex.c:1040 >> __mutex_lock kernel/locking/mutex.c:1103 [inline] >> mutex_lock_nested+0x1a/0x20 kernel/locking/mutex.c:1118 >> hci_get_auth_info+0x69/0x3a0 net/bluetooth/hci_conn.c:1689 >> hci_sock_bound_ioctl net/bluetooth/hci_sock.c:957 [inline] >> hci_sock_ioctl+0x5ae/0x750 net/bluetooth/hci_sock.c:1060 >> sock_do_ioctl+0x7b/0x260 net/socket.c:1047 >> sock_ioctl+0x4aa/0x690 net/socket.c:1198 >> vfs_ioctl fs/ioctl.c:48 [inline] >> ksys_ioctl fs/ioctl.c:753 [inline] >> __do_sys_ioctl fs/ioctl.c:762 [inline] >> __se_sys_ioctl+0xf9/0x160 fs/ioctl.c:760 >> do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 >> entry_SYSCALL_64_after_hwframe+0x44/0xa9 >> RIP: 0033:0x45ccd9 >> Code: 2d b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb b5 fb ff c3 66 2e 0f 1f 84 00 00 00 00 >> RSP: 002b:00007f113a564c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 >> RAX: ffffffffffffffda RBX: 000000000001d300 RCX: 000000000045ccd9 >> RDX: 0000000020000000 RSI: 00000000800448d7 RDI: 0000000000000005 >> RBP: 000000000078bf40 R08: 0000000000000000 R09: 0000000000000000 >> R10: 0000000000000000 R11: 0000000000000246 R12: 000000000078bf0c >> R13: 00007ffd62ea93af R14: 00007f113a5659c0 R15: 000000000078bf0c >> >> Allocated by task 6822: >> save_stack mm/kasan/common.c:48 [inline] >> set_track mm/kasan/common.c:56 [inline] >> __kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494 >> kmem_cache_alloc_trace+0x234/0x300 mm/slab.c:3551 >> kmalloc include/linux/slab.h:555 [inline] >> kzalloc include/linux/slab.h:669 [inline] >> hci_alloc_dev+0x4c/0x1aa0 net/bluetooth/hci_core.c:3543 >> __vhci_create_device drivers/bluetooth/hci_vhci.c:99 [inline] >> vhci_create_device+0x113/0x520 drivers/bluetooth/hci_vhci.c:148 >> process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 >> worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 >> kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 >> ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 >> >> Freed by task 9965: >> save_stack mm/kasan/common.c:48 [inline] >> set_track mm/kasan/common.c:56 [inline] >> kasan_set_free_info mm/kasan/common.c:316 [inline] >> __kasan_slab_free+0x114/0x170 mm/kasan/common.c:455 >> __cache_free mm/slab.c:3426 [inline] >> kfree+0x10a/0x220 mm/slab.c:3757 >> bt_host_release+0x18/0x20 net/bluetooth/hci_sysfs.c:86 >> device_release+0x70/0x1a0 drivers/base/core.c:1796 >> kobject_cleanup lib/kobject.c:704 [inline] >> kobject_release lib/kobject.c:735 [inline] >> kref_put include/linux/kref.h:65 [inline] >> kobject_put+0x1a0/0x2c0 lib/kobject.c:752 >> vhci_release+0x7b/0xc0 drivers/bluetooth/hci_vhci.c:341 >> __fput+0x2f0/0x750 fs/file_table.c:281 >> task_work_run+0x137/0x1c0 kernel/task_work.c:135 >> exit_task_work include/linux/task_work.h:25 [inline] >> do_exit+0x5f3/0x1f20 kernel/exit.c:806 >> do_group_exit+0x161/0x2d0 kernel/exit.c:903 >> __do_sys_exit_group+0x13/0x20 kernel/exit.c:914 >> __ia32_sys_exit_group+0x0/0x40 kernel/exit.c:912 >> __x64_sys_exit_group+0x37/0x40 kernel/exit.c:912 >> do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 >> entry_SYSCALL_64_after_hwframe+0x44/0xa9 >> >> The buggy address belongs to the object at ffff88808e668000 >> which belongs to the cache kmalloc-8k of size 8192 >> The buggy address is located 96 bytes inside of >> 8192-byte region [ffff88808e668000, ffff88808e66a000) >> The buggy address belongs to the page: >> page:ffffea0002399a00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea0002399a00 order:2 compound_mapcount:0 compound_pincount:0 >> flags: 0xfffe0000010200(slab|head) >> raw: 00fffe0000010200 ffffea000217a208 ffffea0001e6c008 ffff8880aa4021c0 >> raw: 0000000000000000 ffff88808e668000 0000000100000001 0000000000000000 >> page dumped because: kasan: bad access detected >> >> Memory state around the buggy address: >> ffff88808e667f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >> ffff88808e667f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >>> ffff88808e668000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >> ^ >> ffff88808e668080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >> ffff88808e668100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >> ================================================================== >> >> >> --- >> This report is generated by a bot. It may contain errors. >> See https://goo.gl/tpsmEJ for more information about syzbot. >> syzbot engineers can be reached at syzkaller@googlegroups.com. >> >> syzbot will keep track of this issue. See: >> https://goo.gl/tpsmEJ#status for how to communicate with syzbot. >> syzbot can test patches for this issue, for details see: >> https://goo.gl/tpsmEJ#testing-patches >> >> -- >> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com. >> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/000000000000e8fb4b05ac58372e%40google.com. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uP3vCaOQXF/FigAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 11:10:59 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id eLqEB6OQXF/rgAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 11:10:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E72DE40869; Sat, 12 Sep 2020 11:10:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725845AbgILJKo (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 05:10:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgILJKn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 05:10:43 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D708C061573; Sat, 12 Sep 2020 02:10:41 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id kk9so2839904pjb.2; Sat, 12 Sep 2020 02:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=7PYEesOAlpZ6EGj+ZnorXol6wlG+lLB6E3fRAdDw39I=; b=lockxSqeqPWAPyWQut+klsJTsZpv/mmjtq1Ew3/fyzkXskyq9Dl+ybw70ltuZfRtuX difHzAuL51vYSHWAir+mRZza4wHpdP1pHV46ko9Ga5U8IC05HBFJ/JQLzq0KctECG1wK Uk5zt8nBHZ7qwgxnidBiRryGNMHkruOBUJ84m3Oa1b3ueDgwn7cmfAFA2QyjHJgnDhnK 02r7kfVpw8R9LZ9Qa23uE6dTIzKnUBFgwI15ECSB4BWGVugVmo2yL+EHGjWnM2AwOGgM akRHdwx7b97bDLm9VorOZpH96KvLzuFVMCpRGBdU7rrOJwizb1VMv55gBXsQOcDQwg7e fM8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7PYEesOAlpZ6EGj+ZnorXol6wlG+lLB6E3fRAdDw39I=; b=eqHeFpMuZp8NISlnO5jaK+fIQMWR2yWSA31NmK0IWJane6V/33W74F3bc07szdlglA X7NUq9ghhJxjQ3ANY0bmuyLASdkx3i+F1sT81lzyUMQz5kMxuoqkdwDqXQHYVaKPd198 WQkAwQlE5JGMNdldcV6sqrr5wV5cPoix8gAWBmxmHLi98FEOD5mD11h66JaE3rR2FCU8 85ZzS3YolplvyTrZumNuN96Gh+MvBYCGCb9Qbo6i3mKuQqyP+Smu6JaZtIM1CPhGfHbJ rOrzu5DAJHyqNpyueqjAFZ0AfV3kR055HUAH4uj+Q/LuOCj4fs9GDn/fzeqKz7qkEsfX rzPQ== X-Gm-Message-State: AOAM532pz5Fl3XzjOQrztcQVYoobuPubUVIraSM+OICluzNXLNvwffsD J0S+9lEi7DJTDRrztzQB/90= X-Google-Smtp-Source: ABdhPJxAqItjHVWxp6Lt4YSjOiMy5z9xtkVG0MWQy8GWhKJivsm6O70ySfZCGPyc1Pzc/2mtPgU9bA== X-Received: by 2002:a17:90b:617:: with SMTP id gb23mr5593370pjb.36.1599901837539; Sat, 12 Sep 2020 02:10:37 -0700 (PDT) Received: from Thinkpad ([45.118.165.151]) by smtp.gmail.com with ESMTPSA id ca6sm3870611pjb.53.2020.09.12.02.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 02:10:36 -0700 (PDT) Date: Sat, 12 Sep 2020 14:40:28 +0530 From: Anmol Karn <anmol.karan123@gmail.com> To: Dan Carpenter <dan.carpenter@oracle.com> Cc: marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Subject: Re: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer dereference in hci_event_packet() Message-ID: <20200912091028.GA67109@Thinkpad> References: <20200910043424.19894-1-anmol.karan123@gmail.com> <20200910104918.GF12635@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200910104918.GF12635@kadam> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.87 / 15.00 / 15.00 X-Rspamd-Queue-Id: E72DE40869 X-Rspamd-UID: 528a97 On Thu, Sep 10, 2020 at 01:49:18PM +0300, Dan Carpenter wrote: > On Thu, Sep 10, 2020 at 10:04:24AM +0530, Anmol Karn wrote: > > Prevent hci_phy_link_complete_evt() from dereferencing 'hcon->amp_mgr' > > as NULL. Fix it by adding pointer check for it. > > > > Reported-and-tested-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com > > Link: https://syzkaller.appspot.com/bug?extid=0bef568258653cff272f > > Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> > > --- > > net/bluetooth/hci_event.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > index 4b7fc430793c..871e16804433 100644 > > --- a/net/bluetooth/hci_event.c > > +++ b/net/bluetooth/hci_event.c > > @@ -4936,6 +4936,11 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > > return; > > } > > > > + if (IS_ERR_OR_NULL(hcon->amp_mgr)) { > > It can't be an error pointer. Shouldn't we call hci_conn_del() on this > path? Try to find the Fixes tag to explain how this bug was introduced. > > (Don't rush to send a v2. The patch requires quite a bit more digging > and detective work before it is ready). > > > + hci_dev_unlock(hdev); > > + return; > > + } > > + > > if (ev->status) { > > hci_conn_del(hcon); > > hci_dev_unlock(hdev); > > regards, > dan carpenter > Sir, I need little advice in continuing with this Patch, I have looked into the Bisected logs and the problem occurs from this commit: 941992d29447 ("ethernet: amd: use IS_ENABLED() instead of checking for built-in or module") Here is a diff of patch which i modified from last patch, diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 4b7fc430793c..6ce435064e0b 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4936,6 +4936,12 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, return; } + if (!hcon->amp_mgr) { + hci_conn_del(hcon); + hci_dev_unlock(hdev); + return; + } + if (ev->status) { hci_conn_del(hcon); hci_dev_unlock(hdev); The value of 'hcon->amp_mgr' getting NULL due to hci_conn_hash_lookup_handle call , and there is not any checks there for the members of hcon, which enables hci_phy_link_complete_evt() to dereference 'hcon->amp_mgr' as NULL. please suggest improvements to this patch. Regards, Anmol Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2HhWF0OdXF9X5wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 12:04:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YChPFEOdXF/bdQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 12:04:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 918ED40942; Sat, 12 Sep 2020 12:04:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725832AbgILKEm convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 06:04:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:41142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725813AbgILKEk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 06:04:40 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 204765] debugfs: File 'le_min_key_size' in directory 'hci0' already present! Date: Sat, 12 Sep 2020 10:04:39 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: maarten.fonville@gmail.com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: CODE_FIX X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-204765-62941-N8mQiCKdd3@https.bugzilla.kernel.org/> In-Reply-To: <bug-204765-62941@https.bugzilla.kernel.org/> References: <bug-204765-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.49 / 15.00 / 15.00 X-Rspamd-Queue-Id: 918ED40942 X-Rspamd-UID: 495878 https://bugzilla.kernel.org/show_bug.cgi?id=204765 Maarten Fonville (maarten.fonville@gmail.com) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maarten.fonville@gmail.com --- Comment #10 from Maarten Fonville (maarten.fonville@gmail.com) --- I am suddenly seeing the same error after suspend/hibernation on my laptop with my Microsoft Surface bluetooth mouse, using latest Ubuntu kernel 5.4.0-47-generic #51-Ubuntu SMP Fri Sep 4 19:50:52 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux: [82250.719088] Bluetooth: hci0: Bootloader revision 0.0 build 26 week 38 2015 [82250.720091] Bluetooth: hci0: Device revision is 16 [82250.720092] Bluetooth: hci0: Secure boot is enabled [82250.720093] Bluetooth: hci0: OTP lock is enabled [82250.720094] Bluetooth: hci0: API lock is enabled [82250.720094] Bluetooth: hci0: Debug lock is disabled [82250.720095] Bluetooth: hci0: Minimum firmware build 1 week 10 2014 [82250.720099] Bluetooth: hci0: Found device firmware: intel/ibt-12-16.sfi [82250.722178] done. [82250.757394] PM: suspend exit [82250.980766] Generic FE-GE Realtek PHY r8169-200:00: attached PHY driver [Generic FE-GE Realtek PHY] (mii_bus:phy_addr=r8169-200:00, irq=IGNORE) [82251.091652] r8169 0000:02:00.0 enp2s0: Link is Down [82252.225425] Bluetooth: hci0: Waiting for firmware download to complete [82252.226105] Bluetooth: hci0: Firmware loaded in 1472555 usecs [82252.226211] Bluetooth: hci0: Waiting for device to boot [82252.238154] Bluetooth: hci0: Device booted in 11754 usecs [82252.238165] Bluetooth: hci0: Found Intel DDC parameters: intel/ibt-12-16.ddc [82252.241173] Bluetooth: hci0: Applying Intel DDC parameters completed [82326.333382] Lockdown: systemd-logind: hibernation is restricted; see man kernel_lockdown.7 [82358.148284] debugfs: File 'le_min_key_size' in directory 'hci0' already present! [82358.148303] debugfs: File 'le_max_key_size' in directory 'hci0' already present! -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CP+WOTDGXF/92AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 14:59:28 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MLDBNTDGXF/rIgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 14:59:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E574AA0AAE; Sat, 12 Sep 2020 14:59:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725885AbgILM7O (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 08:59:14 -0400 Received: from mail-il1-f207.google.com ([209.85.166.207]:50927 "EHLO mail-il1-f207.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725848AbgILM7I (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 08:59:08 -0400 Received: by mail-il1-f207.google.com with SMTP id u20so4149ilk.17 for <linux-bluetooth@vger.kernel.org>; Sat, 12 Sep 2020 05:59:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=WYtWFHRSU717tB4AOlbQFrWP5bISa+QXam+Bz0rRjMY=; b=aZH8/ab7fD3sJXV6ii1HCnGN1d3RUBPVLx/ezjHJMUr09RAZ6jkzIwAy0JFMLpXVL4 Yu2lY/sCHQ5n7wlAzorEhaPT/qp715jRz8s2T1cg7wN3XMYrwZ2n/rZOqKOWvZc5t8K9 GEqh26BaClwy+AjLZYoCdRUTEyKlyMKxRnVXNfsq1oLubBrJA4qNT/8JPPhlWsvWaqTX 37O4wUTcXjS0zkxqx72LbmrVESUD8RFk1d7pA7nK0wjt6ylU6BHhjTrbyhg212ORrNQ+ ae32zR3L5jUKcVleapHouSBHJlfGgYhcQf3jZ7Ao9TzqOT0DybrceNzC6yMoTyMpZAGs W0Sw== X-Gm-Message-State: AOAM533IeCfYU3ZFnDw8Ep8CuQX3FjFfllThnfn6vV+1CYmnDB8aqBbr nEzMKL6W2XLaqB64OeW4VrNBIxeBI+JDemBG9f5ToHTRoX6/ X-Google-Smtp-Source: ABdhPJwLcoK9/BOVvUqW1qoKASa59qg2Z8rU3mVu/ovDZnFvptvji8E0w4KbtYZRK0MK1BCQIgrBtsl0DqKZRNCFZ2x3MA/XMcfx MIME-Version: 1.0 X-Received: by 2002:a5d:995a:: with SMTP id v26mr5175295ios.176.1599915547769; Sat, 12 Sep 2020 05:59:07 -0700 (PDT) Date: Sat, 12 Sep 2020 05:59:07 -0700 In-Reply-To: <0000000000004991e705ac9d1a83@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000e5419905af1d5d2b@google.com> Subject: Re: inconsistent lock state in sco_conn_del From: syzbot <syzbot+65684128cd7c35bc66a1@syzkaller.appspotmail.com> To: cgroups@vger.kernel.org, davem@davemloft.net, hannes@cmpxchg.org, johan.hedberg@gmail.com, keescook@chromium.org, kennyyu@fb.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, lizefan@huawei.com, luto@amacapital.net, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, tj@kernel.org, wad@chromium.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.53 / 15.00 / 15.00 X-Rspamd-Queue-Id: E574AA0AAE X-Rspamd-UID: e2f70c syzbot has bisected this issue to: commit 135b8b37bd91cc82f83e98fca109b80375f5317e Author: Kenny Yu <kennyyu@fb.com> Date: Tue Jun 21 18:04:36 2016 +0000 cgroup: Add pids controller event when fork fails because of pid limit bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=12f6d80d900000 start commit: e8878ab8 Merge tag 'spi-fix-v5.9-rc4' of git://git.kernel... git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=11f6d80d900000 console output: https://syzkaller.appspot.com/x/log.txt?x=16f6d80d900000 kernel config: https://syzkaller.appspot.com/x/.config?x=c61610091f4ca8c4 dashboard link: https://syzkaller.appspot.com/bug?extid=65684128cd7c35bc66a1 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=121ef0fd900000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16c3a853900000 Reported-by: syzbot+65684128cd7c35bc66a1@syzkaller.appspotmail.com Fixes: 135b8b37bd91 ("cgroup: Add pids controller event when fork fails because of pid limit") For information about bisection process see: https://goo.gl/tpsmEJ#bisection Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oHpiBTTvXF9liwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 12 Sep 2020 17:54:28 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yDpGAjTvXF94kwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 12 Sep 2020 17:54:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 30EF440618; Sat, 12 Sep 2020 17:54:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725854AbgILPyU convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 11:54:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:35936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725846AbgILPyP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 11:54:15 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Sat, 12 Sep 2020 15:54:12 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: anupamsr@yahoo.com X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-60824-62941-9PnlMrId9b@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.16 / 15.00 / 15.00 X-Rspamd-Queue-Id: 30EF440618 X-Rspamd-UID: f065e6 https://bugzilla.kernel.org/show_bug.cgi?id=60824 Anupam Srivastava (anupamsr@yahoo.com) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anupamsr@yahoo.com --- Comment #153 from Anupam Srivastava (anupamsr@yahoo.com) --- As a complete newbie in kernel space I wanted to pitch in and say that there are many types of cheap Chinese USB-Bluetooth chips in market that are just a tinsy bit different: Bus 001 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 224 Wireless bDeviceSubClass 1 Radio Frequency bDeviceProtocol 1 Bluetooth bMaxPacketSize0 64 idVendor 0x0a12 Cambridge Silicon Radio, Ltd idProduct 0x0001 Bluetooth Dongle (HCI mode) bcdDevice 25.20 iManufacturer 0 iProduct 2 CSR8510 A10 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x00b1 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA The device gets detected but doesn't respond to any commands including 'power up'. I am thinking if it will be possible to have a proper support of such device in Linux. They do ship with drivers for Windows. If anyone would be so kind to point me to start pointing I would be very interested in hacking some support for it. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cAGSCzaTXV/zywEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 05:34:14 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id qONhCDaTXV8ymwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 05:34:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AFFBDA0B3F; Sun, 13 Sep 2020 05:34:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725916AbgIMDeC (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 23:34:02 -0400 Received: from mga04.intel.com ([192.55.52.120]:11485 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725899AbgIMDeA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 23:34:00 -0400 IronPort-SDR: RaIX+sT5IeIKAKcBQqngOq8hTgdz/pxVGO0jQJDJ4m+7e2MUHaahX3HDYdhCYeYiFAV2srljj9 e4ZMmgwl+Eww== X-IronPort-AV: E=McAfee;i="6000,8403,9742"; a="156354723" X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="156354723" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:33:59 -0700 IronPort-SDR: F83DnkvVUuqVntE2vnajK0+mQqjSIBUvGHL5Kq40a3B6vrtX+O+OjSL1Pc9+dDcz5+tzMDiNTq JzIUq0laG7kw== X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="301347195" Received: from han1-mobl3.jf.intel.com ([10.251.29.101]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:33:59 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v2 03/17] btio: Add SPDX License Identifier Date: Sat, 12 Sep 2020 20:33:27 -0700 Message-Id: <20200913033341.4639-4-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200913033341.4639-1-tedd.an@linux.intel.com> References: <20200913033341.4639-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: AFFBDA0B3F X-Rspamd-UID: 225c69 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 2 License: GPL-2.0-or-later btio/btio.h btio/btio.c --- btio/btio.c | 1 + btio/btio.h | 1 + 2 files changed, 2 insertions(+) diff --git a/btio/btio.c b/btio/btio.c index 844d6007f..42874e13c 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/btio/btio.h b/btio/btio.h index 23e0ef72b..f1f8c99a9 100644 --- a/btio/btio.h +++ b/btio/btio.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uCu5A2CTXV9hxwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 05:34:56 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id +OgEAWCTXV+EFgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 05:34:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 65B17A016F; Sun, 13 Sep 2020 05:34:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725928AbgIMDeZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 23:34:25 -0400 Received: from mga05.intel.com ([192.55.52.43]:59036 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbgIMDeJ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 23:34:09 -0400 IronPort-SDR: bzTVK7CA/lN0nLMBFIueVDZHcLtcFHzKSjztr3KslkpxM+ybNlSCkFYgD1I7g8e+ZFB2FYC+xU nBiYkH6kG2Xg== X-IronPort-AV: E=McAfee;i="6000,8403,9742"; a="243784906" X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="243784906" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:01 -0700 IronPort-SDR: OFzwL87C2/XOiCqMEMk8V9k7c9kfKSHTbpFSGoylP6Bo8XeutIH88PsUVmFXbRUnxY+Q6ZgrUd tj2vtWnHDl/Q== X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="301347243" Received: from han1-mobl3.jf.intel.com ([10.251.29.101]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:34:01 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v2 17/17] tools: Add SPDX License Identifier Date: Sat, 12 Sep 2020 20:33:41 -0700 Message-Id: <20200913033341.4639-18-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200913033341.4639-1-tedd.an@linux.intel.com> References: <20200913033341.4639-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.78 / 15.00 / 15.00 X-Rspamd-Queue-Id: 65B17A016F X-Rspamd-UID: 6949c9 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 102 MIT : 2 LGPL-2.1-or-later : 38 GPL-2.0-only : 2 License: GPL-2.0-or-later tools/csr_usb.c tools/l2cap-tester.c tools/hcisecfilter.c tools/ciptool.c tools/csr_bcsp.c tools/btsnoop.c tools/check-selftest.c tools/bccmd.c tools/hci-tester.c tools/hcitool.c tools/btiotest.c tools/oobtest.c tools/btinfo.c tools/hwdb.c tools/hciattach_bcm43xx.c tools/mgmt-tester.c tools/hex2hcd.c tools/hciattach_st.c tools/smp-tester.c tools/bluetooth-player.c tools/hciattach_tialt.c tools/gap-tester.c tools/bluemoon.c tools/bneptest.c tools/gatt-service.c tools/csr_3wire.c tools/rctest.c tools/rfcomm-tester.c tools/hcieventmask.c tools/hciattach_ti.c tools/seq2bseq.c tools/scotest.c tools/bcmfw.c tools/hciconfig.c tools/btattach.c tools/l2ping.c tools/obexctl.c tools/l2test.c tools/hciattach_intel.c tools/csr.h tools/hciattach.h tools/create-image.c tools/bnep-tester.c tools/userchan-tester.c tools/rfcomm.c tools/btmon-logger.c tools/hcidump.c tools/csr_hci.c tools/rtlfw.c tools/hciattach_qualcomm.c tools/btproxy.c tools/nokfw.c tools/hciattach_ath3k.c tools/3dsp.c tools/bdaddr.c tools/sco-tester.c tools/hciattach.c tools/amptest.c tools/btgatt-server.c tools/btgatt-client.c tools/cltest.c tools/ibeacon.c tools/mcaptest.c tools/hid2hci.c tools/btmgmt.c tools/advtest.c tools/eddystone.c tools/csr_h4.c tools/avtest.c tools/mpris-proxy.c tools/csr.c tools/avinfo.c tools/sdptool.c tools/btconfig.c tools/parser/parser.h tools/parser/obex.c tools/parser/amp.c tools/parser/sdp.c tools/parser/tcpip.c tools/parser/sap.c tools/parser/cmtp.c tools/parser/avctp.c tools/parser/lmp.c tools/parser/ppp.c tools/parser/rfcomm.h tools/parser/hci.c tools/parser/sdp.h tools/parser/parser.c tools/parser/rfcomm.c tools/parser/avdtp.c tools/parser/avrcp.c tools/parser/ericsson.c tools/parser/hcrp.c tools/parser/bpa.c tools/parser/hidp.c tools/parser/bnep.c tools/parser/capi.c tools/parser/att.c tools/parser/l2cap.c tools/parser/smp.c tools/parser/csr.c tools/parser/l2cap.h License: MIT tools/ubcsp.c tools/ubcsp.h License: LGPL-2.1-or-later tools/test-runner.c tools/btpclient.c tools/meshctl.c tools/mesh-cfgclient.c tools/mesh/model.h tools/mesh/util.h tools/mesh/config-model.h tools/mesh/cfgcli.h tools/mesh/mesh-db.c tools/mesh/mesh-db.h tools/mesh/keys.c tools/mesh/util.c tools/mesh/agent.h tools/mesh/remote.c tools/mesh/keys.h tools/mesh/agent.c tools/mesh/cfgcli.c tools/mesh/remote.h tools/mesh-gatt/prov.c tools/mesh-gatt/util.h tools/mesh-gatt/prov.h tools/mesh-gatt/net.c tools/mesh-gatt/util.c tools/mesh-gatt/prov-db.h tools/mesh-gatt/crypto.c tools/mesh-gatt/crypto.h tools/mesh-gatt/gatt.c tools/mesh-gatt/config-server.c tools/mesh-gatt/keys.h tools/mesh-gatt/onoff-model.c tools/mesh-gatt/net.h tools/mesh-gatt/gatt.h tools/mesh-gatt/node.c tools/mesh-gatt/config-client.c tools/mesh-gatt/mesh-net.h tools/mesh-gatt/node.h tools/mesh-gatt/onoff-model.h tools/mesh-gatt/prov-db.c License: GPL-2.0-only tools/obex-server-tool.c tools/obex-client-tool.c --- tools/3dsp.c | 1 + tools/advtest.c | 1 + tools/amptest.c | 1 + tools/avinfo.c | 1 + tools/avtest.c | 1 + tools/bccmd.c | 1 + tools/bcmfw.c | 1 + tools/bdaddr.c | 1 + tools/bluemoon.c | 1 + tools/bluetooth-player.c | 1 + tools/bnep-tester.c | 1 + tools/bneptest.c | 1 + tools/btattach.c | 1 + tools/btconfig.c | 1 + tools/btgatt-client.c | 1 + tools/btgatt-server.c | 1 + tools/btinfo.c | 1 + tools/btiotest.c | 1 + tools/btmgmt.c | 1 + tools/btmon-logger.c | 1 + tools/btpclient.c | 1 + tools/btproxy.c | 1 + tools/btsnoop.c | 1 + tools/check-selftest.c | 1 + tools/ciptool.c | 1 + tools/cltest.c | 1 + tools/create-image.c | 1 + tools/csr.c | 1 + tools/csr.h | 1 + tools/csr_3wire.c | 1 + tools/csr_bcsp.c | 1 + tools/csr_h4.c | 1 + tools/csr_hci.c | 1 + tools/csr_usb.c | 1 + tools/eddystone.c | 1 + tools/gap-tester.c | 1 + tools/gatt-service.c | 1 + tools/hci-tester.c | 1 + tools/hciattach.c | 1 + tools/hciattach.h | 1 + tools/hciattach_ath3k.c | 1 + tools/hciattach_bcm43xx.c | 1 + tools/hciattach_intel.c | 1 + tools/hciattach_qualcomm.c | 1 + tools/hciattach_st.c | 1 + tools/hciattach_ti.c | 1 + tools/hciattach_tialt.c | 1 + tools/hciconfig.c | 1 + tools/hcidump.c | 1 + tools/hcieventmask.c | 1 + tools/hcisecfilter.c | 1 + tools/hcitool.c | 1 + tools/hex2hcd.c | 1 + tools/hid2hci.c | 1 + tools/hwdb.c | 1 + tools/ibeacon.c | 1 + tools/l2cap-tester.c | 1 + tools/l2ping.c | 1 + tools/l2test.c | 1 + tools/mcaptest.c | 1 + tools/mesh-cfgclient.c | 1 + tools/mesh-gatt/config-client.c | 1 + tools/mesh-gatt/config-server.c | 1 + tools/mesh-gatt/crypto.c | 1 + tools/mesh-gatt/crypto.h | 1 + tools/mesh-gatt/gatt.c | 1 + tools/mesh-gatt/gatt.h | 1 + tools/mesh-gatt/keys.h | 1 + tools/mesh-gatt/mesh-net.h | 1 + tools/mesh-gatt/net.c | 1 + tools/mesh-gatt/net.h | 1 + tools/mesh-gatt/node.c | 1 + tools/mesh-gatt/node.h | 1 + tools/mesh-gatt/onoff-model.c | 1 + tools/mesh-gatt/onoff-model.h | 1 + tools/mesh-gatt/prov-db.c | 1 + tools/mesh-gatt/prov-db.h | 1 + tools/mesh-gatt/prov.c | 1 + tools/mesh-gatt/prov.h | 1 + tools/mesh-gatt/util.c | 1 + tools/mesh-gatt/util.h | 1 + tools/mesh/agent.c | 1 + tools/mesh/agent.h | 1 + tools/mesh/cfgcli.c | 1 + tools/mesh/cfgcli.h | 1 + tools/mesh/config-model.h | 1 + tools/mesh/keys.c | 1 + tools/mesh/keys.h | 1 + tools/mesh/mesh-db.c | 1 + tools/mesh/mesh-db.h | 1 + tools/mesh/model.h | 1 + tools/mesh/remote.c | 1 + tools/mesh/remote.h | 1 + tools/mesh/util.c | 1 + tools/mesh/util.h | 1 + tools/meshctl.c | 1 + tools/mgmt-tester.c | 1 + tools/mpris-proxy.c | 1 + tools/nokfw.c | 1 + tools/obex-client-tool.c | 1 + tools/obex-server-tool.c | 1 + tools/obexctl.c | 1 + tools/oobtest.c | 1 + tools/parser/amp.c | 1 + tools/parser/att.c | 1 + tools/parser/avctp.c | 1 + tools/parser/avdtp.c | 1 + tools/parser/avrcp.c | 1 + tools/parser/bnep.c | 1 + tools/parser/bpa.c | 1 + tools/parser/capi.c | 1 + tools/parser/cmtp.c | 1 + tools/parser/csr.c | 1 + tools/parser/ericsson.c | 1 + tools/parser/hci.c | 1 + tools/parser/hcrp.c | 1 + tools/parser/hidp.c | 1 + tools/parser/l2cap.c | 1 + tools/parser/l2cap.h | 1 + tools/parser/lmp.c | 1 + tools/parser/obex.c | 1 + tools/parser/parser.c | 1 + tools/parser/parser.h | 1 + tools/parser/ppp.c | 1 + tools/parser/rfcomm.c | 1 + tools/parser/rfcomm.h | 1 + tools/parser/sap.c | 1 + tools/parser/sdp.c | 1 + tools/parser/sdp.h | 1 + tools/parser/smp.c | 1 + tools/parser/tcpip.c | 1 + tools/rctest.c | 1 + tools/rfcomm-tester.c | 1 + tools/rfcomm.c | 1 + tools/rtlfw.c | 1 + tools/sco-tester.c | 1 + tools/scotest.c | 1 + tools/sdptool.c | 1 + tools/seq2bseq.c | 1 + tools/smp-tester.c | 1 + tools/test-runner.c | 1 + tools/ubcsp.c | 1 + tools/ubcsp.h | 1 + tools/userchan-tester.c | 1 + 144 files changed, 144 insertions(+) diff --git a/tools/3dsp.c b/tools/3dsp.c index 77a70c037..617bfdfbf 100644 --- a/tools/3dsp.c +++ b/tools/3dsp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/advtest.c b/tools/advtest.c index 050b570df..bdc2421ca 100644 --- a/tools/advtest.c +++ b/tools/advtest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/amptest.c b/tools/amptest.c index 557470781..f452d2471 100644 --- a/tools/amptest.c +++ b/tools/amptest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/avinfo.c b/tools/avinfo.c index e45b50918..26e9d1431 100644 --- a/tools/avinfo.c +++ b/tools/avinfo.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/avtest.c b/tools/avtest.c index 59fb1da8a..1a1427b2e 100644 --- a/tools/avtest.c +++ b/tools/avtest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/bccmd.c b/tools/bccmd.c index 2c215ace7..a75415963 100644 --- a/tools/bccmd.c +++ b/tools/bccmd.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/bcmfw.c b/tools/bcmfw.c index 80d8e71a2..9769016ab 100644 --- a/tools/bcmfw.c +++ b/tools/bcmfw.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/bdaddr.c b/tools/bdaddr.c index 952e99077..fb0772c2a 100644 --- a/tools/bdaddr.c +++ b/tools/bdaddr.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/bluemoon.c b/tools/bluemoon.c index 800541110..ff676d32d 100644 --- a/tools/bluemoon.c +++ b/tools/bluemoon.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c index c1005c9b7..c8553f75e 100644 --- a/tools/bluetooth-player.c +++ b/tools/bluetooth-player.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/bnep-tester.c b/tools/bnep-tester.c index ec4ad2668..95176f0a1 100644 --- a/tools/bnep-tester.c +++ b/tools/bnep-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/bneptest.c b/tools/bneptest.c index 8bc7596b6..694eb4420 100644 --- a/tools/bneptest.c +++ b/tools/bneptest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/btattach.c b/tools/btattach.c index 56315d050..dc9ea642e 100644 --- a/tools/btattach.c +++ b/tools/btattach.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/btconfig.c b/tools/btconfig.c index c1ef5834a..c7e97d1dd 100644 --- a/tools/btconfig.c +++ b/tools/btconfig.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c index bc762dba1..c148728bb 100644 --- a/tools/btgatt-client.c +++ b/tools/btgatt-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * diff --git a/tools/btgatt-server.c b/tools/btgatt-server.c index 5b7857b00..5d44a5bf4 100644 --- a/tools/btgatt-server.c +++ b/tools/btgatt-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * diff --git a/tools/btinfo.c b/tools/btinfo.c index 5e609739c..93e4d96ec 100644 --- a/tools/btinfo.c +++ b/tools/btinfo.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/btiotest.c b/tools/btiotest.c index 6c778e3c5..bf23a00da 100644 --- a/tools/btiotest.c +++ b/tools/btiotest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 48c9e5887..7c658c617 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * diff --git a/tools/btmon-logger.c b/tools/btmon-logger.c index 9c23d3c5e..79cab1e2c 100644 --- a/tools/btmon-logger.c +++ b/tools/btmon-logger.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/btpclient.c b/tools/btpclient.c index f9c693056..ad89678b8 100644 --- a/tools/btpclient.c +++ b/tools/btpclient.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/btproxy.c b/tools/btproxy.c index a98bbb73f..10340da7c 100644 --- a/tools/btproxy.c +++ b/tools/btproxy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/btsnoop.c b/tools/btsnoop.c index 9f304377c..164bd0fed 100644 --- a/tools/btsnoop.c +++ b/tools/btsnoop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/check-selftest.c b/tools/check-selftest.c index 0de6362da..ff8c8740a 100644 --- a/tools/check-selftest.c +++ b/tools/check-selftest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/ciptool.c b/tools/ciptool.c index b898ae8b7..cc1caffcb 100644 --- a/tools/ciptool.c +++ b/tools/ciptool.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/cltest.c b/tools/cltest.c index 44a17a892..3629f70e0 100644 --- a/tools/cltest.c +++ b/tools/cltest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/create-image.c b/tools/create-image.c index ca9d0112c..0afb95873 100644 --- a/tools/create-image.c +++ b/tools/create-image.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/csr.c b/tools/csr.c index 61bdaa0cf..87f87510a 100644 --- a/tools/csr.c +++ b/tools/csr.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/csr.h b/tools/csr.h index cc245a550..aeba8bfb3 100644 --- a/tools/csr.h +++ b/tools/csr.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/csr_3wire.c b/tools/csr_3wire.c index 33fcf389a..befc4dfa9 100644 --- a/tools/csr_3wire.c +++ b/tools/csr_3wire.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/csr_bcsp.c b/tools/csr_bcsp.c index e3eea34df..5a8cdd2bd 100644 --- a/tools/csr_bcsp.c +++ b/tools/csr_bcsp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/csr_h4.c b/tools/csr_h4.c index 2dcaec1e5..892685812 100644 --- a/tools/csr_h4.c +++ b/tools/csr_h4.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/csr_hci.c b/tools/csr_hci.c index d2e4ab9c6..b0425aa32 100644 --- a/tools/csr_hci.c +++ b/tools/csr_hci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/csr_usb.c b/tools/csr_usb.c index 32fdf1f14..3c7cb922c 100644 --- a/tools/csr_usb.c +++ b/tools/csr_usb.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/eddystone.c b/tools/eddystone.c index 4764c677c..4303a16ba 100644 --- a/tools/eddystone.c +++ b/tools/eddystone.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/gap-tester.c b/tools/gap-tester.c index 2aa404267..6c0a4ec0b 100644 --- a/tools/gap-tester.c +++ b/tools/gap-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/gatt-service.c b/tools/gatt-service.c index 374a4c9df..c276e4f1a 100644 --- a/tools/gatt-service.c +++ b/tools/gatt-service.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hci-tester.c b/tools/hci-tester.c index 7873e7aea..6a7e0a63e 100644 --- a/tools/hci-tester.c +++ b/tools/hci-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hciattach.c b/tools/hciattach.c index 9a02173bf..7e601563b 100644 --- a/tools/hciattach.c +++ b/tools/hciattach.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hciattach.h b/tools/hciattach.h index 249aab49e..9965661eb 100644 --- a/tools/hciattach.h +++ b/tools/hciattach.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c index eb2a2aeb6..9e09b2440 100644 --- a/tools/hciattach_ath3k.c +++ b/tools/hciattach_ath3k.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2009-2010 Atheros Communications Inc. * diff --git a/tools/hciattach_bcm43xx.c b/tools/hciattach_bcm43xx.c index be82cd011..4ebae6744 100644 --- a/tools/hciattach_bcm43xx.c +++ b/tools/hciattach_bcm43xx.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hciattach_intel.c b/tools/hciattach_intel.c index 0f0b60f2b..e54b4b6ac 100644 --- a/tools/hciattach_intel.c +++ b/tools/hciattach_intel.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hciattach_qualcomm.c b/tools/hciattach_qualcomm.c index 29d15a5fe..f13768d2a 100644 --- a/tools/hciattach_qualcomm.c +++ b/tools/hciattach_qualcomm.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hciattach_st.c b/tools/hciattach_st.c index b34964cb7..3163d9e11 100644 --- a/tools/hciattach_st.c +++ b/tools/hciattach_st.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hciattach_ti.c b/tools/hciattach_ti.c index 183839443..c254b203d 100644 --- a/tools/hciattach_ti.c +++ b/tools/hciattach_ti.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hciattach_tialt.c b/tools/hciattach_tialt.c index 78498edcf..605888716 100644 --- a/tools/hciattach_tialt.c +++ b/tools/hciattach_tialt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hciconfig.c b/tools/hciconfig.c index ddc17c4b5..ddb796c75 100644 --- a/tools/hciconfig.c +++ b/tools/hciconfig.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hcidump.c b/tools/hcidump.c index 33d429b6c..6d4577d73 100644 --- a/tools/hcidump.c +++ b/tools/hcidump.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hcieventmask.c b/tools/hcieventmask.c index b5f818d30..e75cfe2e2 100644 --- a/tools/hcieventmask.c +++ b/tools/hcieventmask.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hcisecfilter.c b/tools/hcisecfilter.c index 18c903334..9c56bf7a3 100644 --- a/tools/hcisecfilter.c +++ b/tools/hcisecfilter.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hcitool.c b/tools/hcitool.c index 9250c41f2..e2587b80b 100644 --- a/tools/hcitool.c +++ b/tools/hcitool.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hex2hcd.c b/tools/hex2hcd.c index 1148bbb46..9a5cbafb5 100644 --- a/tools/hex2hcd.c +++ b/tools/hex2hcd.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/hid2hci.c b/tools/hid2hci.c index 1e0f7aa2a..2110c0624 100644 --- a/tools/hid2hci.c +++ b/tools/hid2hci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * hid2hci : switch the radio on devices that support * it from HID to HCI and back diff --git a/tools/hwdb.c b/tools/hwdb.c index 8a42dce39..12e885a45 100644 --- a/tools/hwdb.c +++ b/tools/hwdb.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/ibeacon.c b/tools/ibeacon.c index 40078d5ed..141f3a9a0 100644 --- a/tools/ibeacon.c +++ b/tools/ibeacon.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c index 1ef4e9213..00df9fd6d 100644 --- a/tools/l2cap-tester.c +++ b/tools/l2cap-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/l2ping.c b/tools/l2ping.c index db120a550..2c980b5c2 100644 --- a/tools/l2ping.c +++ b/tools/l2ping.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/l2test.c b/tools/l2test.c index 0d846ed93..d136d094b 100644 --- a/tools/l2test.c +++ b/tools/l2test.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mcaptest.c b/tools/mcaptest.c index 82663d8de..eeed9f97e 100644 --- a/tools/mcaptest.c +++ b/tools/mcaptest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 3987e3179..e8dbe6aa1 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/config-client.c b/tools/mesh-gatt/config-clien= t.c index bfc788258..bac767083 100644 --- a/tools/mesh-gatt/config-client.c +++ b/tools/mesh-gatt/config-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/config-server.c b/tools/mesh-gatt/config-serve= r.c index 9e9b93959..284726482 100644 --- a/tools/mesh-gatt/config-server.c +++ b/tools/mesh-gatt/config-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/crypto.c b/tools/mesh-gatt/crypto.c index 493b502ca..04d4d1f34 100644 --- a/tools/mesh-gatt/crypto.c +++ b/tools/mesh-gatt/crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/crypto.h b/tools/mesh-gatt/crypto.h index e8f16f35d..a28754c17 100644 --- a/tools/mesh-gatt/crypto.h +++ b/tools/mesh-gatt/crypto.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/gatt.c b/tools/mesh-gatt/gatt.c index 1bd9868df..3828c6092 100644 --- a/tools/mesh-gatt/gatt.c +++ b/tools/mesh-gatt/gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/gatt.h b/tools/mesh-gatt/gatt.h index 2878587b1..9a8377638 100644 --- a/tools/mesh-gatt/gatt.h +++ b/tools/mesh-gatt/gatt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/keys.h b/tools/mesh-gatt/keys.h index 477ff1309..1f96b92a4 100644 --- a/tools/mesh-gatt/keys.h +++ b/tools/mesh-gatt/keys.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/mesh-net.h b/tools/mesh-gatt/mesh-net.h index 76a98224c..405a93436 100644 --- a/tools/mesh-gatt/mesh-net.h +++ b/tools/mesh-gatt/mesh-net.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/net.c b/tools/mesh-gatt/net.c index d74e1f5a5..5e8d89463 100644 --- a/tools/mesh-gatt/net.c +++ b/tools/mesh-gatt/net.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/net.h b/tools/mesh-gatt/net.h index b388d616c..30943be1a 100644 --- a/tools/mesh-gatt/net.h +++ b/tools/mesh-gatt/net.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/node.c b/tools/mesh-gatt/node.c index 6afa6d6ab..7a9340cf7 100644 --- a/tools/mesh-gatt/node.c +++ b/tools/mesh-gatt/node.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/node.h b/tools/mesh-gatt/node.h index a5b5c7520..3370809fb 100644 --- a/tools/mesh-gatt/node.h +++ b/tools/mesh-gatt/node.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/onoff-model.c b/tools/mesh-gatt/onoff-model.c index be519c969..83a9f6424 100644 --- a/tools/mesh-gatt/onoff-model.c +++ b/tools/mesh-gatt/onoff-model.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/onoff-model.h b/tools/mesh-gatt/onoff-model.h index 31599056d..a9fdb300e 100644 --- a/tools/mesh-gatt/onoff-model.h +++ b/tools/mesh-gatt/onoff-model.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/prov-db.c b/tools/mesh-gatt/prov-db.c index 44096e1e1..db8cf8875 100644 --- a/tools/mesh-gatt/prov-db.c +++ b/tools/mesh-gatt/prov-db.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/prov-db.h b/tools/mesh-gatt/prov-db.h index b8584a8c3..50e88266e 100644 --- a/tools/mesh-gatt/prov-db.h +++ b/tools/mesh-gatt/prov-db.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/prov.c b/tools/mesh-gatt/prov.c index 598c94ebf..ccde8114a 100644 --- a/tools/mesh-gatt/prov.c +++ b/tools/mesh-gatt/prov.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/prov.h b/tools/mesh-gatt/prov.h index 2587df8fb..71b40e57c 100644 --- a/tools/mesh-gatt/prov.h +++ b/tools/mesh-gatt/prov.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/util.c b/tools/mesh-gatt/util.c index 564665e5d..998df6024 100644 --- a/tools/mesh-gatt/util.c +++ b/tools/mesh-gatt/util.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh-gatt/util.h b/tools/mesh-gatt/util.h index dba2c480b..09f9313ae 100644 --- a/tools/mesh-gatt/util.h +++ b/tools/mesh-gatt/util.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/agent.c b/tools/mesh/agent.c index 0258a3803..83b7d0af4 100644 --- a/tools/mesh/agent.c +++ b/tools/mesh/agent.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/agent.h b/tools/mesh/agent.h index 7f95798f1..38609e97a 100644 --- a/tools/mesh/agent.h +++ b/tools/mesh/agent.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c index 292bb7e19..f7d30b092 100644 --- a/tools/mesh/cfgcli.c +++ b/tools/mesh/cfgcli.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/cfgcli.h b/tools/mesh/cfgcli.h index 89a67f5de..9e544c71e 100644 --- a/tools/mesh/cfgcli.h +++ b/tools/mesh/cfgcli.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/config-model.h b/tools/mesh/config-model.h index f08d3b890..c5dbb8c5a 100644 --- a/tools/mesh/config-model.h +++ b/tools/mesh/config-model.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/keys.c b/tools/mesh/keys.c index c4070cb75..743488a9e 100644 --- a/tools/mesh/keys.c +++ b/tools/mesh/keys.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/keys.h b/tools/mesh/keys.h index fa51044ef..ebd78a184 100644 --- a/tools/mesh/keys.h +++ b/tools/mesh/keys.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/mesh-db.c b/tools/mesh/mesh-db.c index 7f2d5b358..12219daa5 100644 --- a/tools/mesh/mesh-db.c +++ b/tools/mesh/mesh-db.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/mesh-db.h b/tools/mesh/mesh-db.h index 49af33e87..5e6073522 100644 --- a/tools/mesh/mesh-db.h +++ b/tools/mesh/mesh-db.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/model.h b/tools/mesh/model.h index 35bb80efc..2d78badec 100644 --- a/tools/mesh/model.h +++ b/tools/mesh/model.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/remote.c b/tools/mesh/remote.c index f68ef4b41..809d55996 100644 --- a/tools/mesh/remote.c +++ b/tools/mesh/remote.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/remote.h b/tools/mesh/remote.h index 482817c5a..75daeecc8 100644 --- a/tools/mesh/remote.h +++ b/tools/mesh/remote.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/util.c b/tools/mesh/util.c index 41a629177..788013cd0 100644 --- a/tools/mesh/util.c +++ b/tools/mesh/util.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mesh/util.h b/tools/mesh/util.h index 3b6a2f521..602be83ff 100644 --- a/tools/mesh/util.h +++ b/tools/mesh/util.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/meshctl.c b/tools/meshctl.c index 57998fded..1c7cdff18 100644 --- a/tools/meshctl.c +++ b/tools/meshctl.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index 337a05b45..500159324 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/mpris-proxy.c b/tools/mpris-proxy.c index 617f80586..37591a533 100644 --- a/tools/mpris-proxy.c +++ b/tools/mpris-proxy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/nokfw.c b/tools/nokfw.c index 6209642b5..467656e48 100644 --- a/tools/nokfw.c +++ b/tools/nokfw.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/obex-client-tool.c b/tools/obex-client-tool.c index 3d61c00d7..3fe70cb95 100644 --- a/tools/obex-client-tool.c +++ b/tools/obex-client-tool.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * * OBEX library with GLib integration diff --git a/tools/obex-server-tool.c b/tools/obex-server-tool.c index b20dfaa6b..27a80d19a 100644 --- a/tools/obex-server-tool.c +++ b/tools/obex-server-tool.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * * OBEX library with GLib integration diff --git a/tools/obexctl.c b/tools/obexctl.c index 0709f692c..2efd27508 100644 --- a/tools/obexctl.c +++ b/tools/obexctl.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/oobtest.c b/tools/oobtest.c index c228b65b1..cb1caf723 100644 --- a/tools/oobtest.c +++ b/tools/oobtest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/amp.c b/tools/parser/amp.c index 7c85fb96c..aeaf2732e 100644 --- a/tools/parser/amp.c +++ b/tools/parser/amp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/att.c b/tools/parser/att.c index 688ed48a2..3c8b537fb 100644 --- a/tools/parser/att.c +++ b/tools/parser/att.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/avctp.c b/tools/parser/avctp.c index 5038443a4..d399e0f3f 100644 --- a/tools/parser/avctp.c +++ b/tools/parser/avctp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/avdtp.c b/tools/parser/avdtp.c index 18569c895..5130b42af 100644 --- a/tools/parser/avdtp.c +++ b/tools/parser/avdtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/avrcp.c b/tools/parser/avrcp.c index dfc6d0580..d9c3f0e7a 100644 --- a/tools/parser/avrcp.c +++ b/tools/parser/avrcp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/bnep.c b/tools/parser/bnep.c index c3bbae74f..23f3c93a3 100644 --- a/tools/parser/bnep.c +++ b/tools/parser/bnep.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/bpa.c b/tools/parser/bpa.c index aac010b39..28584dc92 100644 --- a/tools/parser/bpa.c +++ b/tools/parser/bpa.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/capi.c b/tools/parser/capi.c index ef6ac0664..f0bdd17da 100644 --- a/tools/parser/capi.c +++ b/tools/parser/capi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/cmtp.c b/tools/parser/cmtp.c index e7ac4b55c..32d7e6ac6 100644 --- a/tools/parser/cmtp.c +++ b/tools/parser/cmtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/csr.c b/tools/parser/csr.c index 718baab32..c751809fd 100644 --- a/tools/parser/csr.c +++ b/tools/parser/csr.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/ericsson.c b/tools/parser/ericsson.c index d148c93f7..c0ee1d960 100644 --- a/tools/parser/ericsson.c +++ b/tools/parser/ericsson.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/hci.c b/tools/parser/hci.c index 41f6fe087..72c0e959f 100644 --- a/tools/parser/hci.c +++ b/tools/parser/hci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/hcrp.c b/tools/parser/hcrp.c index 7c46cb6ea..1f8999d95 100644 --- a/tools/parser/hcrp.c +++ b/tools/parser/hcrp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/hidp.c b/tools/parser/hidp.c index 703049a7a..b2624489b 100644 --- a/tools/parser/hidp.c +++ b/tools/parser/hidp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/l2cap.c b/tools/parser/l2cap.c index e43761cf7..eb7684bac 100644 --- a/tools/parser/l2cap.c +++ b/tools/parser/l2cap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/l2cap.h b/tools/parser/l2cap.h index 788aef006..298ce25a6 100644 --- a/tools/parser/l2cap.h +++ b/tools/parser/l2cap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/lmp.c b/tools/parser/lmp.c index a7879fb37..1f24a39de 100644 --- a/tools/parser/lmp.c +++ b/tools/parser/lmp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/obex.c b/tools/parser/obex.c index 51719aa9c..9830ac588 100644 --- a/tools/parser/obex.c +++ b/tools/parser/obex.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/parser.c b/tools/parser/parser.c index 61c5b1cda..57ab44b7e 100644 --- a/tools/parser/parser.c +++ b/tools/parser/parser.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/parser.h b/tools/parser/parser.h index b7e1d7568..3b939e1a2 100644 --- a/tools/parser/parser.h +++ b/tools/parser/parser.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/ppp.c b/tools/parser/ppp.c index 55aaa60fe..90e7304a8 100644 --- a/tools/parser/ppp.c +++ b/tools/parser/ppp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/rfcomm.c b/tools/parser/rfcomm.c index d800b7e6d..5704d8dd7 100644 --- a/tools/parser/rfcomm.c +++ b/tools/parser/rfcomm.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/rfcomm.h b/tools/parser/rfcomm.h index a9faa0bf8..fa7df9597 100644 --- a/tools/parser/rfcomm.h +++ b/tools/parser/rfcomm.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/sap.c b/tools/parser/sap.c index 0a875fc7c..250cbff4b 100644 --- a/tools/parser/sap.c +++ b/tools/parser/sap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/sdp.c b/tools/parser/sdp.c index 7477037b8..e235dd188 100644 --- a/tools/parser/sdp.c +++ b/tools/parser/sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/sdp.h b/tools/parser/sdp.h index ed55a23ea..bf329c1ef 100644 --- a/tools/parser/sdp.h +++ b/tools/parser/sdp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/smp.c b/tools/parser/smp.c index 817e08e85..fa444c6cc 100644 --- a/tools/parser/smp.c +++ b/tools/parser/smp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/parser/tcpip.c b/tools/parser/tcpip.c index 8ccfb007c..a96b345a6 100644 --- a/tools/parser/tcpip.c +++ b/tools/parser/tcpip.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/rctest.c b/tools/rctest.c index bc8ed875d..0fac6ebcb 100644 --- a/tools/rctest.c +++ b/tools/rctest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/rfcomm-tester.c b/tools/rfcomm-tester.c index 2d3be27d8..4635ac8d3 100644 --- a/tools/rfcomm-tester.c +++ b/tools/rfcomm-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/rfcomm.c b/tools/rfcomm.c index 177d8f828..4880b0c2d 100644 --- a/tools/rfcomm.c +++ b/tools/rfcomm.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/rtlfw.c b/tools/rtlfw.c index 375f07592..50bf70480 100644 --- a/tools/rtlfw.c +++ b/tools/rtlfw.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/sco-tester.c b/tools/sco-tester.c index 651fbe01d..594c36619 100644 --- a/tools/sco-tester.c +++ b/tools/sco-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/scotest.c b/tools/scotest.c index 08bc8a8d2..d48dbe5ca 100644 --- a/tools/scotest.c +++ b/tools/scotest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/sdptool.c b/tools/sdptool.c index 3c5d840d9..5c00c69cc 100644 --- a/tools/sdptool.c +++ b/tools/sdptool.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/seq2bseq.c b/tools/seq2bseq.c index 9268ecd06..20e91810a 100644 --- a/tools/seq2bseq.c +++ b/tools/seq2bseq.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/smp-tester.c b/tools/smp-tester.c index c32519e0c..c6bfde920 100644 --- a/tools/smp-tester.c +++ b/tools/smp-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/test-runner.c b/tools/test-runner.c index bd3c73001..c735a2ba9 100644 --- a/tools/test-runner.c +++ b/tools/test-runner.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux diff --git a/tools/ubcsp.c b/tools/ubcsp.c index b3f883a03..ff96c3107 100644 --- a/tools/ubcsp.c +++ b/tools/ubcsp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: MIT=0D /*=0D *=0D * BlueZ - Bluetooth protocol stack for Linux=0D diff --git a/tools/ubcsp.h b/tools/ubcsp.h index 6a74e9a16..2a54146cd 100644 --- a/tools/ubcsp.h +++ b/tools/ubcsp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: MIT */=0D /*=0D *=0D * BlueZ - Bluetooth protocol stack for Linux=0D diff --git a/tools/userchan-tester.c b/tools/userchan-tester.c index 8fb088827..50cdfb238 100644 --- a/tools/userchan-tester.c +++ b/tools/userchan-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux --=20 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AFdROV6UXV/zywEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 05:39:10 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id CEw6NV6UXV8ymwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 05:39:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 09242A017B; Sun, 13 Sep 2020 05:39:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725920AbgIMDjB (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sat, 12 Sep 2020 23:39:01 -0400 Received: from mga17.intel.com ([192.55.52.151]:47404 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgIMDi7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sat, 12 Sep 2020 23:38:59 -0400 IronPort-SDR: a2I3ZEVf+kiD4rq5u+Ir636Pb2mvnU4U0awObFyy6Dkp/wYs+rMx12bGC9RBKAvargA5zHGoto DBKomeQ2U+Pw== X-IronPort-AV: E=McAfee;i="6000,8403,9742"; a="138973030" X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="138973030" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:33:59 -0700 IronPort-SDR: PMf+aqsvCmAAAqC1i0n00Ln1pBo7Gk3rdOjNUBrKUspx+emTKvzJt3sZ5GEvRs3XKuZK202TJW j/gdV1MSswTw== X-IronPort-AV: E=Sophos;i="5.76,421,1592895600"; d="scan'208";a="301347206" Received: from han1-mobl3.jf.intel.com ([10.251.29.101]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 20:33:59 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v2 06/17] gdbus: Add SPDX License Identifier Date: Sat, 12 Sep 2020 20:33:30 -0700 Message-Id: <20200913033341.4639-7-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200913033341.4639-1-tedd.an@linux.intel.com> References: <20200913033341.4639-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: 09242A017B X-Rspamd-UID: c340f1 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 6 License: GPL-2.0-or-later gdbus/mainloop.c gdbus/object.c gdbus/polkit.c gdbus/client.c gdbus/watch.c gdbus/gdbus.h --- gdbus/client.c | 1 + gdbus/gdbus.h | 1 + gdbus/mainloop.c | 1 + gdbus/object.c | 1 + gdbus/polkit.c | 1 + gdbus/watch.c | 1 + 6 files changed, 6 insertions(+) diff --git a/gdbus/client.c b/gdbus/client.c index 86e1c7693..6caa2143d 100644 --- a/gdbus/client.c +++ b/gdbus/client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h index 1a601c591..60e3e8bb5 100644 --- a/gdbus/gdbus.h +++ b/gdbus/gdbus.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * D-Bus helper library diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c index b90a8447c..e39eeb117 100644 --- a/gdbus/mainloop.c +++ b/gdbus/mainloop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library diff --git a/gdbus/object.c b/gdbus/object.c index 49b578087..80ac8d7a7 100644 --- a/gdbus/object.c +++ b/gdbus/object.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library diff --git a/gdbus/polkit.c b/gdbus/polkit.c index 9e95fa384..e66a50c2f 100644 --- a/gdbus/polkit.c +++ b/gdbus/polkit.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library diff --git a/gdbus/watch.c b/gdbus/watch.c index 447e48671..83e8bd8be 100644 --- a/gdbus/watch.c +++ b/gdbus/watch.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wGahGYLOXV/4swAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 09:47:14 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4FTDFoLOXV8ewwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 09:47:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 242E6A0B40; Sun, 13 Sep 2020 09:47:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725936AbgIMHq7 convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 13 Sep 2020 03:46:59 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:47646 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbgIMHq6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 13 Sep 2020 03:46:58 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 5C168CECC4; Sun, 13 Sep 2020 09:53:50 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [RESEND PATCH] Bluetooth: Only mark socket zapped after unlocking From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200911153256.RESEND.1.Ic1b9d93cf2d393e3efda4c2977639c095d276311@changeid> Date: Sun, 13 Sep 2020 09:46:53 +0200 Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, Balakrishna Godavarthi <bgodavar@codeaurora.org>, Manish Mandlik <mmandlik@chromium.org>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org>, open list <linux-kernel@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org> Content-Transfer-Encoding: 8BIT Message-Id: <6C5505B2-3C70-4484-9A1A-4425AE397640@holtmann.org> References: <20200911153256.RESEND.1.Ic1b9d93cf2d393e3efda4c2977639c095d276311@changeid> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.09 / 15.00 / 15.00 X-Rspamd-Queue-Id: 242E6A0B40 X-Rspamd-UID: 691a17 Hi Abhishek, > Since l2cap_sock_teardown_cb doesn't acquire the channel lock before > setting the socket as zapped, it could potentially race with > l2cap_sock_release which frees the socket. Thus, wait until the cleanup > is complete before marking the socket as zapped. > > This race was reproduced on a JBL GO speaker after the remote device > rejected L2CAP connection due to resource unavailability. > > Here is a dmesg log with debug logs from a repro of this bug: > [ 3465.424086] Bluetooth: hci_core.c:hci_acldata_packet() hci0 len 16 handle 0x0003 flags 0x0002 > [ 3465.424090] Bluetooth: hci_conn.c:hci_conn_enter_active_mode() hcon 00000000cfedd07d mode 0 > [ 3465.424094] Bluetooth: l2cap_core.c:l2cap_recv_acldata() conn 000000007eae8952 len 16 flags 0x2 > [ 3465.424098] Bluetooth: l2cap_core.c:l2cap_recv_frame() len 12, cid 0x0001 > [ 3465.424102] Bluetooth: l2cap_core.c:l2cap_raw_recv() conn 000000007eae8952 > [ 3465.424175] Bluetooth: l2cap_core.c:l2cap_sig_channel() code 0x03 len 8 id 0x0c > [ 3465.424180] Bluetooth: l2cap_core.c:l2cap_connect_create_rsp() dcid 0x0045 scid 0x0000 result 0x02 status 0x00 > [ 3465.424189] Bluetooth: l2cap_core.c:l2cap_chan_put() chan 000000006acf9bff orig refcnt 4 > [ 3465.424196] Bluetooth: l2cap_core.c:l2cap_chan_del() chan 000000006acf9bff, conn 000000007eae8952, err 111, state BT_CONNECT > [ 3465.424203] Bluetooth: l2cap_sock.c:l2cap_sock_teardown_cb() chan 000000006acf9bff state BT_CONNECT > [ 3465.424221] Bluetooth: l2cap_core.c:l2cap_chan_put() chan 000000006acf9bff orig refcnt 3 > [ 3465.424226] Bluetooth: hci_core.h:hci_conn_drop() hcon 00000000cfedd07d orig refcnt 6 > [ 3465.424234] BUG: spinlock bad magic on CPU#2, kworker/u17:0/159 > [ 3465.425626] Bluetooth: hci_sock.c:hci_sock_sendmsg() sock 000000002bb0cb64 sk 00000000a7964053 > [ 3465.430330] lock: 0xffffff804410aac0, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0 > [ 3465.430332] Causing a watchdog bite! > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Reported-by: Balakrishna Godavarthi <bgodavar@codeaurora.org> > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > --- > We had some more data available (outside of dmesg and oops) that led us > to suspect a race between l2cap_sock_teardown_cb and l2cap_sock_release. > I've left this out of the commit message since it's not an oops or dmesg > logs. > > Crash stack from CPU4: > -- > -24 |spin_bug( > | [X19] lock = 0xFFFFFF810BDB1EC0, > | [X20] msg = 0xFFFFFFD143FD7960) > -25 |debug_spin_lock_before(inline) > | [X19] lock = 0xFFFFFF810BDB1EC0 > -25 |do_raw_spin_lock( > | [X19] lock = 0xFFFFFF810BDB1EC0) > -26 |raw_spin_lock_irqsave( > | [X19] lock = 0xFFFFFF810BDB1EC0) > -27 |skb_peek(inline) > -27 |__skb_dequeue(inline) > -27 |skb_dequeue( > | [X20] list = 0xFFFFFF810BDB1EA8) > | [locdesc] flags = 12297829382473034410 > -28 |skb_queue_purge( > | [X19] list = 0xFFFFFF810BDB1EA8 -> ( > | [D:0xFFFFFF810BDB1EA8] next = 0x0, > | [D:0xFFFFFF810BDB1EB0] prev = 0x0, > | [D:0xFFFFFF810BDB1EB8] qlen = 0, > | [D:0xFFFFFF810BDB1EC0] lock = ([D:0xFFFFFF810BDB1EC0] rlock = ([D:0xFFFFFF810BDB1EC0] raw_lock > | [X0] skb = ??? > -29 |l2cap_seq_list_free(inline) > | [locdesc] seq_list = 0xFFFFFF810BDB1ED8 -> ( > | [D:0xFFFFFF810BDB1ED8] head = 0, > | [D:0xFFFFFF810BDB1EDA] tail = 0, > | [D:0xFFFFFF810BDB1EDC] mask = 0, > | [D:0xFFFFFF810BDB1EE0] list = 0x0) > -29 |l2cap_chan_del( > | [X19] chan = 0xFFFFFF810BDB1C00, > | ?) > -30 |l2cap_chan_unlock(inline) > -30 |l2cap_connect_create_rsp(inline) > | [X20] conn = 0xFFFFFF81231F2600 > | [locdesc] err = 0 > | [X27] chan = 0xFFFFFF810BDB1C00 > -30 |l2cap_bredr_sig_cmd(inline) > | [X20] conn = 0xFFFFFF81231F2600 > | [locdesc] err = 0 > -30 |l2cap_sig_channel(inline) > | [X20] conn = 0xFFFFFF81231F2600 > | [X19] skb = 0xFFFFFF813DE4C040 > | [X28] data = 0xFFFFFF8131582014 > | [locdesc] cmd_len = 43690 > -30 |l2cap_recv_frame( > | [X20] conn = 0xFFFFFF81231F2600, > | [X19] skb = 0xFFFFFF813DE4C040) > | [locdesc] psm = 43690 > -31 |l2cap_recv_acldata( > | ?, > | [X19] skb = 0xFFFFFF813DE4C040, > | ?) > | [X21] len = 16 > -32 |hci_rx_work( > | ?) > | [X21] hdev = 0xFFFFFF8133A02000 > -33 |__read_once_size(inline) > | [locdesc] size = 4 > -33 |atomic_read(inline) > | [locdesc] __u = ([locdesc] __val = -1431655766, [locdesc] __c = (170)) > -33 |static_key_count(inline) > -33 |static_key_false(inline) > -33 |trace_workqueue_execute_end(inline) > | [X22] work = 0xFFFFFF8133A02838 > -33 |process_one_work( > | [X19] worker = 0xFFFFFF8133FE4500, > | [X22] work = 0xFFFFFF8133A02838) > | [locdesc] work_color = -1431655766 > -34 |__read_once_size(inline) > | [locdesc] size = 8 > -34 |list_empty(inline) > | [locdesc] __u = ([locdesc] __val = 0xAAAAAAAAAAAAAAAA, [locdesc] __c = (170)) > -34 |worker_thread( > | [X19] __worker = 0xFFFFFF8133FE4500) > | [X19] worker = 0xFFFFFF8133FE4500 > -35 |kthread( > | [X20] _create = 0xFFFFFF8133FB3A00) > | [X20] create = 0xFFFFFF8133FB3A00 > | [X0] ret = ??? > -36 |ret_from_fork(asm) > > net/bluetooth/l2cap_sock.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IDNNKOTOXV9xmAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 09:48:52 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id IAykJeTOXV8I1AAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 09:48:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 55B21A0AF0; Sun, 13 Sep 2020 09:48:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725918AbgIMHsb (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 13 Sep 2020 03:48:31 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:35942 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725899AbgIMHsa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 13 Sep 2020 03:48:30 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 9362FCECC4; Sun, 13 Sep 2020 09:55:24 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [RESEND PATCH] bluetooth: Set ext scan response only when it exists From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200911153141.RESEND.1.Ib022565452fde0c02fbcf619950ef868715dd243@changeid> Date: Sun, 13 Sep 2020 09:48:28 +0200 Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, Daniel Winkler <danielwinkler@google.com>, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Content-Transfer-Encoding: 7bit Message-Id: <A3FDD177-8552-4BDD-941A-0BD8FF495AFE@holtmann.org> References: <20200911153141.RESEND.1.Ib022565452fde0c02fbcf619950ef868715dd243@changeid> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: 55B21A0AF0 X-Rspamd-UID: fc0afb Hi Abhishek, > Only set extended scan response only when it exists. Otherwise, clear > the scan response data. > > Per the core spec v5.2, Vol 4, Part E, 7.8.55 > > If the advertising set is non-scannable and the Host uses this command > other than to discard existing data, the Controller shall return the > error code Invalid HCI Command Parameters (0x12). > > On WCN3991, the controller correctly responds with Invalid Parameters > when this is sent. That error causes __hci_req_hci_power_on to fail > with -EINVAL and LE devices can't connect because background scanning > isn't configured. > > Here is an hci trace of where this issue occurs during power on: > > < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25 > Handle: 0x00 > Properties: 0x0010 > Use legacy advertising PDUs: ADV_NONCONN_IND > Min advertising interval: 181.250 msec (0x0122) > Max advertising interval: 181.250 msec (0x0122) > Channel map: 37, 38, 39 (0x07) > Own address type: Random (0x01) > Peer address type: Public (0x00) > Peer address: 00:00:00:00:00:00 (OUI 00-00-00) > Filter policy: Allow Scan Request from Any, Allow Connect... > TX power: 127 dbm (0x7f) > Primary PHY: LE 1M (0x01) > Secondary max skip: 0x00 > Secondary PHY: LE 1M (0x01) > SID: 0x00 > Scan request notifications: Disabled (0x00) >> HCI Event: Command Complete (0x0e) plen 5 > LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 1 > Status: Success (0x00) > TX power (selected): 9 dbm (0x09) > < HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7 > Advertising handle: 0x00 > Advertising random address: 08:FD:55:ED:22:28 (OUI 08-FD-55) >> HCI Event: Command Complete (0x0e) plen 4 > LE Set Advertising Set Random Address (0x08|0x0035) ncmd > Status: Success (0x00) > < HCI Command: LE Set Extended Scan Response Data (0x08|0x0038) plen 35 > Handle: 0x00 > Operation: Complete scan response data (0x03) > Fragment preference: Minimize fragmentation (0x01) > Data length: 0x0d > Name (short): Chromebook >> HCI Event: Command Complete (0x0e) plen 4 > LE Set Extended Scan Response Data (0x08|0x0038) ncmd 1 > Status: Invalid HCI Command Parameters (0x12) > > Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Reviewed-by: Daniel Winkler <danielwinkler@google.com> > --- > > net/bluetooth/hci_request.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MCw+EAPRXV9xmAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 09:57:55 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id eGdZDQPRXV+7cQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 09:57:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E34BB40675; Sun, 13 Sep 2020 09:57:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725918AbgIMH5Y (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 13 Sep 2020 03:57:24 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:50350 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgIMH5V (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 13 Sep 2020 03:57:21 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 74188CECC4; Sun, 13 Sep 2020 10:04:15 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v2 0/3] Bluetooth: Emit events for suspend/resume From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200911210713.4066465-1-abhishekpandit@chromium.org> Date: Sun, 13 Sep 2020 09:57:19 +0200 Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>, chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, Johan Hedberg <johan.hedberg@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski <kuba@kernel.org> Content-Transfer-Encoding: 7bit Message-Id: <BF8FE78A-77AF-4788-A819-B275D851309A@holtmann.org> References: <20200911210713.4066465-1-abhishekpandit@chromium.org> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.77 / 15.00 / 15.00 X-Rspamd-Queue-Id: E34BB40675 X-Rspamd-UID: c6c228 Hi Abhishek, > This series adds the suspend/resume events suggested in > https://patchwork.kernel.org/patch/11771001/. > > I have tested it with some userspace changes that monitors the > controller resumed event to trigger audio device reconnection and > verified that the events are correctly emitted. > > Patch for btmon changes: https://patchwork.kernel.org/patch/11743863/ > > Please take a look. > Abhishek > > Changes in v2: > - Added suspend/resume events to list of mgmt events > > Abhishek Pandit-Subedi (3): > Bluetooth: Add mgmt suspend and resume events > Bluetooth: Add suspend reason for device disconnect > Bluetooth: Emit controller suspend and resume events > > include/net/bluetooth/hci_core.h | 6 +++ > include/net/bluetooth/mgmt.h | 16 +++++++ > net/bluetooth/hci_core.c | 26 +++++++++++- > net/bluetooth/hci_event.c | 73 ++++++++++++++++++++++++++++++++ > net/bluetooth/mgmt.c | 30 +++++++++++++ > 5 files changed, 150 insertions(+), 1 deletion(-) All 3 patches have been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GHqQI0vRXV/4swAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 13 Sep 2020 09:59:07 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qFu4IEvRXV8qmQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 13 Sep 2020 09:59:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 64AE140965; Sun, 13 Sep 2020 09:59:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725918AbgIMH7A (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 13 Sep 2020 03:59:00 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:52930 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgIMH66 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 13 Sep 2020 03:58:58 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id E268DCECC4; Sun, 13 Sep 2020 10:05:52 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v1] Bluetooth: btintel: Refactor firmware download function From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <1599824657-19464-1-git-send-email-kiran.k@intel.com> Date: Sun, 13 Sep 2020 09:58:56 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Kiran K <kiran.k@intel.com> Content-Transfer-Encoding: 7bit Message-Id: <02F01161-2498-4A89-A8B5-3F19D62143E0@holtmann.org> References: <1599824657-19464-1-git-send-email-kiran.k@intel.com> To: Kiran K <kiraank@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.65 / 15.00 / 15.00 X-Rspamd-Queue-Id: 64AE140965 X-Rspamd-UID: 07a5b4 Hi Kiran, > Split firmware download code into two functions - one to download > header and other to download payload. This patch enhances readability > and reusabiltiy of code > > Signed-off-by: Kiran K <kiran.k@intel.com> > Reviewed-by: Chethan T N <chethan.tumkur.narayan@intel.com> > Reviewed-by: Sathish Narasimman <Sathish.Narasimman@intel.com> > Reviewed-by: Srivatsa Ravishankar <ravishankar.srivatsa@intel.com> > --- > drivers/bluetooth/btintel.c | 35 ++++++++++++++++++++++++++++++----- > 1 file changed, 30 insertions(+), 5 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +Ll+KYKwXl+0ogEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 01:51:30 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sBiYJoKwXl+ijAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 01:51:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=linaro.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2E007A01B4; Mon, 14 Sep 2020 01:51:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725975AbgIMXvX (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 13 Sep 2020 19:51:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725950AbgIMXvV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 13 Sep 2020 19:51:21 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92F5EC06174A for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 16:51:21 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id o16so15294965qkj.10 for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 16:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=XLWo34hVmrRnf5YKo6+XZqj/MmF2UL5Q5POaUTSSFD4=; b=Oxb/XftV9EJLx2usmOAADNyqYCAUr9ixeBY4PxTr9dbotHOeaxq7pDy6oMZhPlPqvS JpF7WsxeZ2vlWZsk9CRndihWd0BD6+Xz33ANgiZEfT/0Z4a641vatesd4TM3XcvdbF+U uCVzQY/MYDik5l1IVpOd+wvmUcrM4aVmGcBaVYu6ynXh/Ln4o2ZXMq4Y4HG/2TgiSGqg e7W0xODdKoBsAvbJ+cQmvAOIIs8tm4Io2o3TtfO6EHaKFK6iaXzIpp5hIJ6hhGspBX01 WOa4vPHS8jGQRSyGfKaPIUSYvYBlfV5YQ4J+vquXArURpkFQeeiUYOQRh0PnEiYo2sJ+ kfJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=XLWo34hVmrRnf5YKo6+XZqj/MmF2UL5Q5POaUTSSFD4=; b=rD6/rlHwHfkgcHa+10RUvgf45rqIbWiWbdfqY79qbrFZk2tsPk97lqJLJmfGQn69FD NbicMHEahforEx8NNV8oIwYKpVIUP5hDNI9v856IWwDeGc1W+Mxaqj8Di3N3LJn8HBGv ZnN9aqe6hCNETWScPtq62oPoKg4fuddGNaqCbjXewGmMovsCrvcdPN/xMv9TamXnIFMz EnFLqB//4B7CU1gocFG5EtyPsSsjtwiShuFrI/JL/DYWjnDDTeiM+Q+dDErowrEb7/88 uncc9AVlngmZAL/fh2rF5iR4jk7PTklGenljduLoWwaprfFXLyVGC1yrbOZgOyJLUZbU 4Omg== X-Gm-Message-State: AOAM532rOhHJGCmNlz5i1wRvijl1axiSJZPcGbr32fV81/zAdmq4yOsB L4aLMd1RKM6GLjQtwrKCFRY80A== X-Google-Smtp-Source: ABdhPJwyMYMBmANq3AG/NorWJ3U6hjr9n5RXkcGdotOIi3gXPMKLWDHHS8TA2LSD1U+xVfHdpE0UvQ== X-Received: by 2002:a05:620a:958:: with SMTP id w24mr10923317qkw.65.1600041080727; Sun, 13 Sep 2020 16:51:20 -0700 (PDT) Received: from uller (ec2-34-197-84-77.compute-1.amazonaws.com. [34.197.84.77]) by smtp.gmail.com with ESMTPSA id u13sm12022354qtv.57.2020.09.13.16.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 16:51:20 -0700 (PDT) Date: Sun, 13 Sep 2020 23:51:18 +0000 From: Bjorn Andersson <bjorn.andersson@linaro.org> To: Marcel Holtmann <marcel@holtmann.org> Cc: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>, Johan Hedberg <johan.hedberg@gmail.com>, mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org Subject: Re: [RESEND v1] arm64: dts: qcom: sc7180: Remove clock for bluetooth on SC7180 IDP board Message-ID: <20200913235118.GD472@uller> References: <1599734980-22580-1-git-send-email-gubbaven@codeaurora.org> <C8D04890-4F62-4EEB-9113-BAFFF46E32BD@holtmann.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <C8D04890-4F62-4EEB-9113-BAFFF46E32BD@holtmann.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.17 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2E007A01B4 X-Rspamd-UID: a7c308 On Fri 11 Sep 07:11 UTC 2020, Marcel Holtmann wrote: > Hi, > Hi Marcel, > > Removed voting for RPMH_RF_CLK2 which is not required as it is > > getting managed by BT SoC through SW_CTRL line. > > > > Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> > > --- > > arch/arm64/boot/dts/qcom/sc7180-idp.dts | 1 - > > 1 file changed, 1 deletion(-) > > > > diff --git a/arch/arm64/boot/dts/qcom/sc7180-idp.dts b/arch/arm64/boot/dts/qcom/sc7180-idp.dts > > index 4e9149d..b295d01 100644 > > --- a/arch/arm64/boot/dts/qcom/sc7180-idp.dts > > +++ b/arch/arm64/boot/dts/qcom/sc7180-idp.dts > > @@ -348,7 +348,6 @@ > > vddrf-supply = <&vreg_l2c_1p3>; > > vddch0-supply = <&vreg_l10c_3p3>; > > max-speed = <3200000>; > > - clocks = <&rpmhcc RPMH_RF_CLK2>; > > }; > > }; > > is anybody picking up this patch or should I take it through the bluetooth-next tree? > I've now picked it through the qcom tree. Thanks, Bjorn Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uAFsERfiXl89YgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 05:23:03 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id AHpoDhfiXl+ragAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 05:23:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3E150A0B44; Mon, 14 Sep 2020 05:22:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725982AbgINDWy (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 13 Sep 2020 23:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725965AbgINDWr (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 13 Sep 2020 23:22:47 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E31EC06174A for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 20:22:46 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id u128so15401584ybg.17 for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 20:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=EnBy+dhGK+KU7s14UMNaacLXhV3/ZJibQx2NZUdPjao=; b=mndusJc1ci82hhpnqhA4908SlHU5VY/cMLeJpIP3FHXtgrJO/eBuMpbSLfaSe33cud GfCeFjX/khAapiWdAbbe+CQdRZfCmnrA1IZUymBLqf0vSVo0ZCfhTO0Z1QkYq2nmd2PI V8COz+/UMOLRH5fAGKpqmavrImUf31gJzPHYwrwAapkee+zozfMQtIT0wR4rdPfK5o42 iHQ6hY3QyLqdgyCVhB2rvfdy6DXXrgMdWycPOCBoNT1dgcQCEPiQsfVPWbrsIY7zzAx9 MqCISvg/dj7UmVXTPW3eu84qKgRisDLVlYVqgmvhSo9bJAsbG5RfXuXXbBzsi1oFZyZO PwtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=EnBy+dhGK+KU7s14UMNaacLXhV3/ZJibQx2NZUdPjao=; b=mZh/cwS4X016psswZcOFX1MWReQcc+oKO3rvcW5XzA8nnpNhxD5LL0KsrD6uJ7mSYC NfAPXCZQG+B7IqzOM8tYucWiWBXxNohL9G2hu8O4g09JmFgoylTPJU6IPA2bPJHcMrTH 6yXw5T0a3BQGtTlaSRe+xHKDQpnfMlaxFkJFdggb51jJJbk1eLO6+aukb674RaNNkdsN 38EPp5cKkylHrCgmJlbHMWPznI9KZdzqS5ylCKbccw2XxdSDsuvCVYBnOOdv4RaULGWY vKhMDhBj3mA7Cw9oh26YmThLfRGmVp8bxmAC6i13KxfhidQqdPMHcxyfuhmrCPbETMb6 SDVA== X-Gm-Message-State: AOAM531Uy/xxSiR/5Gf3cWb5N1+2LmxH01sYcr3PS54+mH+lhoa82Jpk tWpkNauaZpTKsC0+lYjJO55XWR/tev+f9qhl7KrWAJWlE6xFqpxwA9HVRg9LDMplXnmuyzd26Ka dcSUl5R4yg6CqSU6FfLZLeGkVIcYBjyRJ1b2zmkAnZXG5sYL8zDiouVfrAai/I4jc0cQvPVov16 wKakMBr+unHS8= X-Google-Smtp-Source: ABdhPJw622upNuKdruRy6J4qYSM9lAq/ePD+ZqVxk1tkUaJtFDfbqKrMRKDquWyK4xLU8Zvc39d5hHkaXzxFktnBWg== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a25:301:: with SMTP id 1mr17154522ybd.255.1600053763881; Sun, 13 Sep 2020 20:22:43 -0700 (PDT) Date: Mon, 14 Sep 2020 11:22:30 +0800 Message-Id: <20200914112137.BlueZ.v4.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v4 1/4] client: Implement basic interface of ADV monitor in bluetoothctl From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, luiz.von.dentz@intel.com, mmandlik@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3E150A0B44 X-Rspamd-UID: a90764 This patch implements some basic functions for ADV monitor in bluetoothctl [bluetooth]# show ... Advertisement Monitor Features: SupportedMonitorTypes: or_patterns Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v4: - Remove PRE-UPSTREAM in commit title Changes in v3: - Rename advertisement_monitor to adv_monitor Changes in v2: - Update the add-pattern usage - Fix styling issue in patch 1 - Fix storage class declaration issue Makefile.tools | 2 + client/adv_monitor.c | 161 +++++++++++++++++++++++++++++++++++++++++++ client/adv_monitor.h | 23 +++++++ client/main.c | 28 ++++++++ 4 files changed, 214 insertions(+) create mode 100644 client/adv_monitor.c create mode 100644 client/adv_monitor.h diff --git a/Makefile.tools b/Makefile.tools index 9b9236609..ed0fbf8a3 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -7,6 +7,8 @@ client_bluetoothctl_SOURCES = client/main.c \ client/agent.h client/agent.c \ client/advertising.h \ client/advertising.c \ + client/adv_monitor.h \ + client/adv_monitor.c \ client/gatt.h client/gatt.c client_bluetoothctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \ $(GLIB_LIBS) $(DBUS_LIBS) -lreadline diff --git a/client/adv_monitor.c b/client/adv_monitor.c new file mode 100644 index 000000000..2a62389d9 --- /dev/null +++ b/client/adv_monitor.c @@ -0,0 +1,161 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdbool.h> +#include <string.h> + +#include "gdbus/gdbus.h" +#include "src/shared/util.h" +#include "src/shared/shell.h" +#include "adv_monitor.h" + +#define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" + +static struct adv_monitor_manager { + GSList *supported_types; + GSList *supported_features; + GDBusProxy *proxy; + gboolean app_registered; +} manager = { NULL, NULL, NULL, FALSE }; + +static void set_supported_list(GSList **list, DBusMessageIter *iter) +{ + char *str; + DBusMessageIter subiter; + + dbus_message_iter_recurse(iter, &subiter); + while (dbus_message_iter_get_arg_type(&subiter) == + DBUS_TYPE_STRING) { + dbus_message_iter_get_basic(&subiter, &str); + *list = g_slist_append(*list, str); + dbus_message_iter_next(&subiter); + } +} + +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy) +{ + DBusMessageIter iter; + + if (manager.proxy != NULL || manager.supported_types != NULL || + manager.supported_features != NULL) { + bt_shell_printf("advertisement monitor manager already " + "added\n"); + return; + } + + manager.proxy = proxy; + + if (g_dbus_proxy_get_property(proxy, "SupportedMonitorTypes", &iter)) + set_supported_list(&(manager.supported_types), &iter); + + if (g_dbus_proxy_get_property(proxy, "SupportedFeatures", &iter)) + set_supported_list(&(manager.supported_features), &iter); + +} + +void adv_monitor_remove_manager(DBusConnection *conn) +{ + if (manager.supported_types != NULL) + g_slist_free(g_steal_pointer(&(manager.supported_types))); + if (manager.supported_features != NULL) + g_slist_free(g_steal_pointer(&(manager.supported_features))); + manager.proxy = NULL; + manager.app_registered = FALSE; +} + +static void register_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = ADV_MONITOR_APP_PATH; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +static void register_reply(DBusMessage *message, void *user_data) +{ + DBusConnection *conn = user_data; + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == FALSE) { + bt_shell_printf("AdvertisementMonitor path registered\n"); + } else { + bt_shell_printf("Failed to register path: %s\n", error.name); + dbus_error_free(&error); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } +} + +static void unregister_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = ADV_MONITOR_APP_PATH; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +static void unregister_reply(DBusMessage *message, void *user_data) +{ + DBusConnection *conn = user_data; + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == FALSE) { + bt_shell_printf("AdvertisementMonitor path unregistered\n"); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + bt_shell_printf("Failed to unregister Advertisement Monitor:" + " %s\n", error.name); + dbus_error_free(&error); + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + +void adv_monitor_register_app(DBusConnection *conn) +{ + if (manager.supported_types == NULL || manager.app_registered == TRUE || + g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", + register_setup, register_reply, + NULL, NULL) == FALSE) { + bt_shell_printf("Failed to register Advertisement Monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + manager.app_registered = TRUE; +} + +void adv_monitor_unregister_app(DBusConnection *conn) +{ + if (manager.app_registered == FALSE || + g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", + unregister_setup, unregister_reply, + NULL, NULL) == FALSE) { + bt_shell_printf("Failed to unregister Advertisement Monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + manager.app_registered = FALSE; +} diff --git a/client/adv_monitor.h b/client/adv_monitor.h new file mode 100644 index 000000000..77b0b62c6 --- /dev/null +++ b/client/adv_monitor.h @@ -0,0 +1,23 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); +void adv_monitor_remove_manager(DBusConnection *conn); +void adv_monitor_register_app(DBusConnection *conn); +void adv_monitor_unregister_app(DBusConnection *conn); diff --git a/client/main.c b/client/main.c index da877b546..75f8bc462 100644 --- a/client/main.c +++ b/client/main.c @@ -41,6 +41,7 @@ #include "agent.h" #include "gatt.h" #include "advertising.h" +#include "adv_monitor.h" /* String display constants */ #define COLORED_NEW COLOR_GREEN "NEW" COLOR_OFF @@ -58,6 +59,7 @@ static char *auto_register_agent = NULL; struct adapter { GDBusProxy *proxy; GDBusProxy *ad_proxy; + GDBusProxy *adv_monitor_proxy; GList *devices; }; @@ -528,6 +530,19 @@ static void ad_manager_added(GDBusProxy *proxy) adapter->ad_proxy = proxy; } +static void admon_manager_added(GDBusProxy *proxy) +{ + struct adapter *adapter; + + adapter = find_ctrl(ctrl_list, g_dbus_proxy_get_path(proxy)); + if (!adapter) + adapter = adapter_new(proxy); + + adapter->adv_monitor_proxy = proxy; + adv_monitor_add_manager(dbus_conn, proxy); + adv_monitor_register_app(dbus_conn); +} + static void proxy_added(GDBusProxy *proxy, void *user_data) { const char *interface; @@ -560,6 +575,9 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) ad_manager_added(proxy); } else if (!strcmp(interface, "org.bluez.Battery1")) { battery_added(proxy); + } else if (!strcmp(interface, + "org.bluez.AdvertisementMonitorManager1")) { + admon_manager_added(proxy); } } @@ -653,6 +671,9 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) ad_unregister(dbus_conn, NULL); } else if (!strcmp(interface, "org.bluez.Battery1")) { battery_removed(proxy); + } else if (!strcmp(interface, + "org.bluez.AdvertisementMonitorManager1")) { + adv_monitor_remove_manager(dbus_conn); } } @@ -935,6 +956,13 @@ static void cmd_show(int argc, char *argv[]) print_property(adapter->ad_proxy, "SupportedSecondaryChannels"); } + if (adapter->adv_monitor_proxy) { + bt_shell_printf("Advertisement Monitor Features:\n"); + print_property(adapter->adv_monitor_proxy, + "SupportedMonitorTypes"); + print_property(adapter->adv_monitor_proxy, "SupportedFeatures"); + } + return bt_shell_noninteractive_quit(EXIT_SUCCESS); } -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UFcjEh7iXl89YgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 05:23:10 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YA0zDx7iXl8neQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 05:23:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EF8ADA0B3D; Mon, 14 Sep 2020 05:23:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725983AbgINDWy (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 13 Sep 2020 23:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725973AbgINDWw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 13 Sep 2020 23:22:52 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B4D8C061788 for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 20:22:52 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id b18so11063761qto.4 for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 20:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=YW+W6VPmCcUxZ0aKiaV5YI57Jl28Wn5E2tIC1a3e4wo=; b=EcF2brSmvrhgJqYWBuG++Nydgv5/jlTLD8CaRojWP1RYRkS69g9FxNYw1bUs4WtmhM zQ/QVQofVjzIxKmA2JU5nskcIFf4DgmjbLJYV2tCmYfXZtHCEbxrRHx/y2gKp2NkRbCk TK8cHpQOY4za9D+4ioF0ZTVBq80t8JzF+djygvGsPH6oYNTSioEq1gF0pU9udJaLVXaj 54GrpLemd6/Rc+zNpwxlphtt8ZWyEZZBY17jealGoQoHElx81H4d3f+S+JNtnDQubtdu e8X1XUbpX3J9beFtbaRZFYrRjSP/OUzEsm/QCaaUTqYkLV84lVFgX9GsY13+guB+MC1P pTkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=YW+W6VPmCcUxZ0aKiaV5YI57Jl28Wn5E2tIC1a3e4wo=; b=IBxPjn7pzhDmKBUQ6r/miKePXlcSWVUOg5IHUWgC/legHr8ehcDxeihHPRoYerV7zo NPCs9WrwD3TPLluGdkkPdbIKnZ2jrhVGZkvkE6ynUpzIR+ppc8chp0KopBr2xe+fMFIL 0p98A2gVR37Cwk8rDSqW2b9RrYXqnEJ4Qcg0dg37sNAIxYBJ/Kt1GWNSRW/ArF7rUI5u ehK4hZ/U2DPRzWFCp3Kk01Xjk3Iwjdnz+Bc+scHRr8oqr1Vc6EsRmh3FcRqRilDkt9vt YGylFk0P1TWU0Ihx19sXUKO/2Ti4tPUfwvrL215Ch5YcRqDoEghYsEj2RReGQxP9UQ4j ziHQ== X-Gm-Message-State: AOAM530gA6WQW+K63RXZo/z2Qu+BQ+NUH1Hz2GRmHC9ASN3X8YWtaff3 ChHldPHbrbo9v8/BpmhwIX/U9WHceZKkqEnV+ghiGmbKrchxIYkkKvG1hmLsg/kPe2MSjdGN2DI hol6S2uSL3NQl9rnvR92mPRbniNjxDrPgDT3n2u7lwCQOzIhLfcZRF84TLl0vstUaFGdpyMlo8P p98AU7Bq2Urns= X-Google-Smtp-Source: ABdhPJxI9yOBiZfYsQy2CFlnXhGhirO09U6556yXKIyc1iodIPY5fap/fZYq0cb1y1M8gMAfVs3FsScAmqWtEacWFA== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a0c:8645:: with SMTP id p63mr11527589qva.21.1600053771128; Sun, 13 Sep 2020 20:22:51 -0700 (PDT) Date: Mon, 14 Sep 2020 11:22:32 +0800 In-Reply-To: <20200914112137.BlueZ.v4.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200914112137.BlueZ.v4.3.I680cda25cec9c45ca2b2c5ac3a8e437772ea76d9@changeid> Mime-Version: 1.0 References: <20200914112137.BlueZ.v4.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v4 3/4] client: Expose ADV monitor objects From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, luiz.von.dentz@intel.com, mmandlik@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.11 / 15.00 / 15.00 X-Rspamd-Queue-Id: EF8ADA0B3D X-Rspamd-UID: 4bd911 This adds logic to expose user-defined advertisement monitor to dbus and also implements methods for exposed objects. Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v4: - Remove PRE-UPSTREAM in commit title Reviewed-by: Miao-chen Chou <mcchou@chromium.org> client/adv_monitor.c | 185 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 182 insertions(+), 3 deletions(-) diff --git a/client/adv_monitor.c b/client/adv_monitor.c index 49c0dd01d..bb833ffea 100644 --- a/client/adv_monitor.c +++ b/client/adv_monitor.c @@ -53,6 +53,7 @@ struct pattern { struct adv_monitor { uint8_t idx; + char *path; char *type; struct rssi_setting *rssi; GSList *patterns; @@ -68,6 +69,163 @@ static struct adv_monitor_manager { static uint8_t adv_mon_idx; static GSList *adv_mons; +static void remove_adv_monitor(void *data, void *user_data); + +static DBusMessage *release_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + bt_shell_printf("Advertisement monitor %d released\n", + adv_monitor->idx); + remove_adv_monitor(adv_monitor, conn); + + return dbus_message_new_method_return(msg); +} + +static DBusMessage *activate_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + bt_shell_printf("Advertisement monitor %d activated\n", + adv_monitor->idx); + return dbus_message_new_method_return(msg); +} + +static DBusMessage *device_found_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + const char *device; + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device, + DBUS_TYPE_INVALID); + bt_shell_printf("Advertisement monitor %d found device %s\n", + adv_monitor->idx, device); + return dbus_message_new_method_return(msg); +} + +static DBusMessage *device_lost_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + const char *device; + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device, + DBUS_TYPE_INVALID); + bt_shell_printf("Advertisement monitor %d lost device %s\n", + adv_monitor->idx, device); + return dbus_message_new_method_return(msg); +} + +static const GDBusMethodTable adv_monitor_methods[] = { + { GDBUS_ASYNC_METHOD("Release", NULL, NULL, release_adv_monitor) }, + { GDBUS_ASYNC_METHOD("Activate", NULL, NULL, activate_adv_monitor) }, + { GDBUS_ASYNC_METHOD("DeviceFound", GDBUS_ARGS({ "device", "o" }), + NULL, device_found_adv_monitor) }, + { GDBUS_ASYNC_METHOD("DeviceLost", GDBUS_ARGS({ "device", "o" }), + NULL, device_lost_adv_monitor) }, + { } +}; + + +static gboolean get_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, + &adv_monitor->type); + return TRUE; +} + +static gboolean get_rssi(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + struct rssi_setting *rssi = adv_monitor->rssi; + DBusMessageIter data_iter; + + dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, + NULL, &data_iter); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_INT16, + &rssi->high_threshold); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_UINT16, + &rssi->high_timer); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_INT16, + &rssi->low_threshold); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_UINT16, + &rssi->low_timer); + dbus_message_iter_close_container(iter, &data_iter); + return TRUE; +} + +static gboolean rssi_exists(const GDBusPropertyTable *property, void *data) +{ + struct adv_monitor *adv_monitor = data; + + return adv_monitor->rssi != NULL; +} + +static void append_pattern_content_to_dbus(DBusMessageIter *iter, + struct pattern *pattern) +{ + DBusMessageIter data_iter; + int idx; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE_AS_STRING, &data_iter); + for (idx = 0; idx < pattern->content_len; idx++) + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->content[idx]); + dbus_message_iter_close_container(iter, &data_iter); +} + +static void append_pattern_to_dbus(void *data, void *user_data) +{ + struct pattern *pattern = data; + DBusMessageIter *array_iter = user_data; + DBusMessageIter data_iter; + + dbus_message_iter_open_container(array_iter, DBUS_TYPE_STRUCT, + NULL, &data_iter); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->start_pos); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->ad_data_type); + append_pattern_content_to_dbus(&data_iter, pattern); + dbus_message_iter_close_container(array_iter, &data_iter); +} + +static gboolean get_patterns(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + DBusMessageIter array_iter; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "(yyay)", + &array_iter); + g_slist_foreach(adv_monitor->patterns, append_pattern_to_dbus, + &array_iter); + dbus_message_iter_close_container(iter, &array_iter); + return TRUE; +} + +static gboolean pattern_exists(const GDBusPropertyTable *property, void *data) +{ + struct adv_monitor *adv_monitor = data; + + return adv_monitor->patterns != NULL; +} + +static const GDBusPropertyTable adv_monitor_props[] = { + { "Type", "s", get_type }, + { "RSSIThresholdsAndTimers", "(nqnq)", get_rssi, NULL, rssi_exists }, + { "Patterns", "a(yyay)", get_patterns, NULL, pattern_exists }, + { } +}; + static void set_supported_list(GSList **list, DBusMessageIter *iter) { char *str; @@ -201,6 +359,7 @@ static void free_adv_monitor(void *user_data) { struct adv_monitor *adv_monitor = user_data; + g_free(adv_monitor->path); g_free(adv_monitor->type); g_free(adv_monitor->rssi); g_slist_free_full(adv_monitor->patterns, free_pattern); @@ -325,6 +484,16 @@ static GSList *parse_patterns(char *pattern_list[], int num) return patterns; } +static void remove_adv_monitor(void *data, void *user_data) +{ + struct adv_monitor *adv_monitor = data; + DBusConnection *conn = user_data; + + adv_mons = g_slist_remove(adv_mons, adv_monitor); + g_dbus_unregister_interface(conn, adv_monitor->path, + ADV_MONITOR_INTERFACE); +} + static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) { const struct adv_monitor *adv_monitor = a; @@ -360,6 +529,7 @@ static void print_adv_monitor(struct adv_monitor *adv_monitor) GSList *l; bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); + bt_shell_printf("\tpath: %s\n", adv_monitor->path); bt_shell_printf("\ttype: %s\n", adv_monitor->type); if (adv_monitor->rssi) { bt_shell_printf("\trssi:\n"); @@ -434,6 +604,16 @@ void adv_monitor_add_monitor(DBusConnection *conn, char *type, adv_monitor->type = g_strdup(type); adv_monitor->rssi = rssi; adv_monitor->patterns = patterns; + adv_monitor->path = g_strdup_printf("%s/%hhu", ADV_MONITOR_APP_PATH, + adv_mon_idx); + if (g_dbus_register_interface(conn, adv_monitor->path, + ADV_MONITOR_INTERFACE, + adv_monitor_methods, NULL, + adv_monitor_props, adv_monitor, + free_adv_monitor) == FALSE) { + bt_shell_printf("Failed to register advertisement monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } adv_mons = g_slist_append(adv_mons, adv_monitor); bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); @@ -468,7 +648,7 @@ void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) struct adv_monitor *adv_monitor; if (monitor_idx < 0) { - g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); + g_slist_foreach(adv_mons, remove_adv_monitor, conn); return; } @@ -479,8 +659,7 @@ void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) return; } - adv_mons = g_slist_remove(adv_mons, adv_monitor); - free_adv_monitor(adv_monitor); + remove_adv_monitor(adv_monitor, conn); bt_shell_printf("Monitor %d deleted\n", monitor_idx); } -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6GvaOiTiXl89YgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 05:23:16 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4IOHNyTiXl8tFQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 05:23:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 662DEA0B36; Mon, 14 Sep 2020 05:23:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725986AbgINDW4 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 13 Sep 2020 23:22:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbgINDWv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 13 Sep 2020 23:22:51 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09164C061787 for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 20:22:50 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id y53so11060679qth.2 for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 20:22:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=YIsn/22ZcZqe7nW9GshapUJQV8UlKBoZrOAtlrHoHic=; b=I+BT3mk0ZfdAhhqv7d5IKo/0+q4XAn+bnbxDmfnhwimT0ikhvL4pZUw2LjZ3Fllgqc rk1ujEk1rr6m1cpa/fZ7/rYYWo/OPLHxPzpwbF9/nqW72J2lk77E+KO3HxJyZqKVAfDt ScVeK9GsA18siegZaV4M+35w+k3HQu84S+q3JLmBDPwoKkSlKsROtz/rs7WCFoPUkMjZ ISUVWQtjNBj8kOnKpRFpN3kjbVhoXv6jX3dNwjlVXK956jJponzKVMWw6bRe5TBS/Y77 LZOHQ7QS6s0vq+FNBc04ceKpz4bQ9jnnLtG7besA4qH343StezDMJ/WopuDCjCIHA6ZP iEfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=YIsn/22ZcZqe7nW9GshapUJQV8UlKBoZrOAtlrHoHic=; b=eznh4slf490jZshQn7T5G7bKWRkcITofL9h22FJAeLTKhreTfplfhKCWrruBpgc0W7 apUi8IjKevSgL/r0AiItUowdIowPvKoaYKQerbelRDp8gwRxc7WN2mQQdu2yWTCGXeUW hxpnkkqcSspEGltgPOorVrN1oslr7Nf2Go65i1J+HlWT9NxiBL0iVOpdQEhAUY65jKdM rnwr+5G2Zo2ZFbLABLj2RFM7ROQ6GTVcbHQitdipCP0wLFJsbZXp9rCVxplFr5kBU5AC UxPy8GlJzqPNpACz1dMvO9OQwbsogq6owxc15VAjieIEletXSy3WDiTYJ1xJd6zOyRZA R0qg== X-Gm-Message-State: AOAM532vvcVe/qC5AkSpplQ71kJR/ZwTlrYVC9xddttkDAyEUAOBibBA OV9Cqz3pdhONHQy+jEUAfmync81k2gZ3aVfYQ0RcGY4R2hM+gSJZzCWJitukUZJNcUE7DBBK35/ /wphugPP5miAe6uIXp3cybQaw4VkUxMrmCW9G04FtJgfIYZEWjJLmzHRvtCwPbu+eFBswkZO86y L3YOdxJftFMFs= X-Google-Smtp-Source: ABdhPJyclfH2ZQ374g7PKwLdUPUAbsexA+u5orl4TWXu2MvuCKrD43aqGY9qQuHuza2WsbgxrKLJHAU4a+dcKeD8qQ== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:55ce:: with SMTP id bt14mr11351385qvb.2.1600053767399; Sun, 13 Sep 2020 20:22:47 -0700 (PDT) Date: Mon, 14 Sep 2020 11:22:31 +0800 In-Reply-To: <20200914112137.BlueZ.v4.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200914112137.BlueZ.v4.2.Iec6b15e23f4228b80f9b364eb76515d146d592d5@changeid> Mime-Version: 1.0 References: <20200914112137.BlueZ.v4.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v4 2/4] client: Implement more interfaces of ADV monitor in bluetoothctl From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, luiz.von.dentz@intel.com, mmandlik@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: 662DEA0B36 X-Rspamd-UID: 44790b This patch creates a submenu in bluetoothctl and implements several commands. new commands: [bluetooth]# menu monitor [bluetooth]# add-or-pattern 1 2 ab0011 Advertisement Monitor 0 added [bluetooth]# add-or-pattern-rssi -80, ,5 1 2 aa 3 4 ff Advertisement Monitor 1 added [bluetooth]# get-pattern all Advertisement Monitor 0 path: /org/bluez/adv_monitor_app/0 type: or_patterns pattern 1: start position: 1 AD data type: 2 content: ab0011 Advertisement Monitor 1 path: /org/bluez/adv_monitor_app/1 type: or_patterns rssi: high threshold: -50 high threshold timer: 5 low threshold: -80 low threshold timer: 5 pattern 1: start position: 1 AD data type: 2 content: aa pattern 2: start position: 3 AD data type: 4 content: ff [bluetooth]# get-supported-info Supported Features: Supported Moniter Types: or_patterns [bluetooth]# remove-pattern 0 Monitor 0 deleted Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v4: - Remove PRE-UPSTREAM in commit title Changes in v2: - Update the add-pattern usage client/adv_monitor.c | 352 ++++++++++++++++++++++++++++++++++++++++++- client/adv_monitor.h | 10 ++ client/main.c | 109 ++++++++++++++ 3 files changed, 468 insertions(+), 3 deletions(-) diff --git a/client/adv_monitor.c b/client/adv_monitor.c index 2a62389d9..49c0dd01d 100644 --- a/client/adv_monitor.c +++ b/client/adv_monitor.c @@ -29,6 +29,7 @@ #include <string.h> #include "gdbus/gdbus.h" +#include "src/shared/ad.h" #include "src/shared/util.h" #include "src/shared/shell.h" #include "adv_monitor.h" @@ -36,6 +37,27 @@ #define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" +struct rssi_setting { + int16_t high_threshold; + uint16_t high_timer; + int16_t low_threshold; + uint16_t low_timer; +}; + +struct pattern { + uint8_t start_pos; + uint8_t ad_data_type; + uint8_t content_len; + uint8_t content[BT_AD_MAX_DATA_LEN]; +}; + +struct adv_monitor { + uint8_t idx; + char *type; + struct rssi_setting *rssi; + GSList *patterns; +}; + static struct adv_monitor_manager { GSList *supported_types; GSList *supported_features; @@ -43,6 +65,9 @@ static struct adv_monitor_manager { gboolean app_registered; } manager = { NULL, NULL, NULL, FALSE }; +static uint8_t adv_mon_idx; +static GSList *adv_mons; + static void set_supported_list(GSList **list, DBusMessageIter *iter) { char *str; @@ -138,7 +163,10 @@ static void unregister_reply(DBusMessage *message, void *user_data) void adv_monitor_register_app(DBusConnection *conn) { - if (manager.supported_types == NULL || manager.app_registered == TRUE || + if (manager.app_registered == TRUE) { + bt_shell_printf("Advertisement Monitor already registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } else if (manager.supported_types == NULL || g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", register_setup, register_reply, NULL, NULL) == FALSE) { @@ -150,8 +178,10 @@ void adv_monitor_register_app(DBusConnection *conn) void adv_monitor_unregister_app(DBusConnection *conn) { - if (manager.app_registered == FALSE || - g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", + if (manager.app_registered == FALSE) { + bt_shell_printf("Advertisement Monitor not registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } else if (g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", unregister_setup, unregister_reply, NULL, NULL) == FALSE) { bt_shell_printf("Failed to unregister Advertisement Monitor\n"); @@ -159,3 +189,319 @@ void adv_monitor_unregister_app(DBusConnection *conn) } manager.app_registered = FALSE; } + +static void free_pattern(void *user_data) +{ + struct pattern *p = user_data; + + g_free(p); +} + +static void free_adv_monitor(void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + g_free(adv_monitor->type); + g_free(adv_monitor->rssi); + g_slist_free_full(adv_monitor->patterns, free_pattern); + g_free(adv_monitor); +} + +static uint8_t str2bytearray(char *str, uint8_t *arr) +{ + int idx, len = strlen(str), arr_len = 0; + + if (len%2 != 0) + return 0; + + for (idx = 0; idx < len; idx += 2) { + if (sscanf(str+idx, "%2hhx", &arr[arr_len++]) < 1) + return 0; + } + return arr_len; +} + +static void parse_rssi_value_pair(char *value_pair, int *low, int *high) +{ + char *val1, *val2; + bool flag = value_pair[0] == ','; + + val1 = strtok(value_pair, ","); + + if (!val1) + return; + + val2 = strtok(NULL, ","); + + if (!val2) { + if (!flag) + *low = atoi(val1); + else + *high = atoi(val1); + } else { + *low = atoi(val1); + *high = atoi(val2); + } +} + +static struct rssi_setting *parse_rssi(char *range, char *timeout) +{ + struct rssi_setting *rssi; + int high_threshold, low_threshold, high_timer, low_timer; + + high_threshold = RSSI_DEFAULT_HIGH_THRESHOLD; + low_threshold = RSSI_DEFAULT_LOW_THRESHOLD; + high_timer = RSSI_DEFAULT_HIGH_TIMEOUT; + low_timer = RSSI_DEFAULT_LOW_TIMEOUT; + + parse_rssi_value_pair(range, &low_threshold, &high_threshold); + parse_rssi_value_pair(timeout, &low_timer, &high_timer); + + rssi = g_malloc0(sizeof(struct rssi_setting)); + + if (!rssi) { + bt_shell_printf("Failed to allocate rssi_setting"); + bt_shell_noninteractive_quit(EXIT_FAILURE); + return NULL; + } + + rssi->high_threshold = high_threshold; + rssi->high_timer = high_timer; + rssi->low_threshold = low_threshold; + rssi->low_timer = low_timer; + + return rssi; +} + +static struct pattern *parse_pattern(char *parameter_list[]) +{ + struct pattern *pat; + + pat = g_malloc0(sizeof(struct pattern)); + + if (!pat) { + bt_shell_printf("Failed to allocate pattern"); + bt_shell_noninteractive_quit(EXIT_FAILURE); + return NULL; + } + + pat->start_pos = atoi(parameter_list[0]); + pat->ad_data_type = atoi(parameter_list[1]); + pat->content_len = str2bytearray(parameter_list[2], pat->content); + if (pat->content_len == 0) { + free_pattern(pat); + return NULL; + } + + return pat; +} + +static GSList *parse_patterns(char *pattern_list[], int num) +{ + GSList *patterns = NULL; + int cnt; + + if (num == 0) { + bt_shell_printf("No pattern provided\n"); + return NULL; + } + + if (num%3) { + bt_shell_printf("Expected %d more arguments\n", 3 - num%3); + return NULL; + } + + for (cnt = 0; cnt < num; cnt += 3) { + struct pattern *pattern; + + pattern = parse_pattern(pattern_list+cnt); + if (pattern == NULL) { + g_slist_free_full(patterns, free_pattern); + return NULL; + } + patterns = g_slist_append(patterns, pattern); + } + + return patterns; +} + +static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) +{ + const struct adv_monitor *adv_monitor = a; + uint8_t idx = *(uint8_t *)b; + + return adv_monitor->idx != idx; +} + +static struct adv_monitor *find_adv_monitor_with_idx(uint8_t monitor_idx) +{ + GSList *list; + + list = g_slist_find_custom(adv_mons, &monitor_idx, + cmp_adv_monitor_with_idx); + + if (list) + return (struct adv_monitor *)list->data; + return NULL; +} + +static void print_bytearray(char *prefix, uint8_t *arr, uint8_t len) +{ + int idx; + + bt_shell_printf("%s", prefix); + for (idx = 0; idx < len; idx++) + bt_shell_printf("%02hhx", arr[idx]); + bt_shell_printf("\n"); +} + +static void print_adv_monitor(struct adv_monitor *adv_monitor) +{ + GSList *l; + + bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); + bt_shell_printf("\ttype: %s\n", adv_monitor->type); + if (adv_monitor->rssi) { + bt_shell_printf("\trssi:\n"); + bt_shell_printf("\t\thigh threshold: %hd\n", + adv_monitor->rssi->high_threshold); + bt_shell_printf("\t\thigh threshold timer: %hu\n", + adv_monitor->rssi->high_timer); + bt_shell_printf("\t\tlow threshold: %hd\n", + adv_monitor->rssi->low_threshold); + bt_shell_printf("\t\tlow threshold timer: %hu\n", + adv_monitor->rssi->low_timer); + } + + if (adv_monitor->patterns) { + int idx = 1; + + for (l = adv_monitor->patterns; l; l = g_slist_next(l), idx++) { + struct pattern *pattern = l->data; + + bt_shell_printf("\tpattern %d:\n", idx); + bt_shell_printf("\t\tstart position: %hhu\n", + pattern->start_pos); + bt_shell_printf("\t\tAD data type: %hhu\n", + pattern->ad_data_type); + print_bytearray("\t\tcontent: ", pattern->content, + pattern->content_len); + } + } +} + +void adv_monitor_add_monitor(DBusConnection *conn, char *type, + gboolean rssi_enabled, int argc, char *argv[]) +{ + struct adv_monitor *adv_monitor; + struct rssi_setting *rssi; + GSList *patterns = NULL; + + if (g_slist_length(adv_mons) >= UINT8_MAX) { + bt_shell_printf("Number of advertisement monitor exceeds " + "the limit"); + return; + } + + while (find_adv_monitor_with_idx(adv_mon_idx)) + adv_mon_idx += 1; + + if (rssi_enabled == FALSE) + rssi = NULL; + else { + rssi = parse_rssi(argv[1], argv[2]); + if (rssi == NULL) + return; + + argv += 2; + argc -= 2; + } + + patterns = parse_patterns(argv+1, argc-1); + if (patterns == NULL) { + bt_shell_printf("pattern-list malformed\n"); + return; + } + + adv_monitor = g_malloc0(sizeof(struct adv_monitor)); + + if (!adv_monitor) { + bt_shell_printf("Failed to allocate adv_monitor"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + adv_monitor->idx = adv_mon_idx; + adv_monitor->type = g_strdup(type); + adv_monitor->rssi = rssi; + adv_monitor->patterns = patterns; + + adv_mons = g_slist_append(adv_mons, adv_monitor); + bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); +} + +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx) +{ + struct adv_monitor *adv_monitor; + GSList *l; + + if (monitor_idx < 0) { + for (l = adv_mons; l; l = g_slist_next(l)) { + adv_monitor = l->data; + print_adv_monitor(adv_monitor); + } + return; + } + + adv_monitor = find_adv_monitor_with_idx(monitor_idx); + + if (adv_monitor == NULL) { + bt_shell_printf("Can't find monitor with index %d\n", + monitor_idx); + return; + } + + print_adv_monitor(adv_monitor); +} + +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) +{ + struct adv_monitor *adv_monitor; + + if (monitor_idx < 0) { + g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); + return; + } + + adv_monitor = find_adv_monitor_with_idx(monitor_idx); + if (adv_monitor == NULL) { + bt_shell_printf("Can't find monitor with index %d\n", + monitor_idx); + return; + } + + adv_mons = g_slist_remove(adv_mons, adv_monitor); + free_adv_monitor(adv_monitor); + bt_shell_printf("Monitor %d deleted\n", monitor_idx); +} + +static void print_supported_list(GSList *list) +{ + GSList *iter; + + for (iter = list; iter; iter = g_slist_next(iter)) { + char *data = iter->data; + + printf(" %s", data); + } +} + +void adv_monitor_get_supported_info(void) +{ + bt_shell_printf("Supported Features:"); + print_supported_list(manager.supported_features); + bt_shell_printf("\n"); + + bt_shell_printf("Supported Moniter Types:"); + print_supported_list(manager.supported_types); + bt_shell_printf("\n"); +} diff --git a/client/adv_monitor.h b/client/adv_monitor.h index 77b0b62c6..12c01bd3f 100644 --- a/client/adv_monitor.h +++ b/client/adv_monitor.h @@ -17,7 +17,17 @@ * */ +#define RSSI_DEFAULT_HIGH_THRESHOLD -50 +#define RSSI_DEFAULT_LOW_THRESHOLD -70 +#define RSSI_DEFAULT_HIGH_TIMEOUT 10 +#define RSSI_DEFAULT_LOW_TIMEOUT 5 + void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); void adv_monitor_remove_manager(DBusConnection *conn); void adv_monitor_register_app(DBusConnection *conn); void adv_monitor_unregister_app(DBusConnection *conn); +void adv_monitor_add_monitor(DBusConnection *conn, char *type, + gboolean rssi_enabled, int argc, char *argv[]); +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx); +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx); +void adv_monitor_get_supported_info(void); diff --git a/client/main.c b/client/main.c index 75f8bc462..2b0243308 100644 --- a/client/main.c +++ b/client/main.c @@ -2719,6 +2719,85 @@ static void cmd_ad_clear(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_FAILURE); } +static void print_add_or_pattern_with_rssi_usage(void) +{ + bt_shell_printf("rssi-range format:\n" + "\t<low-rssi>,<high-rssi>\n" + "\tBoth parameters can be skipped, in that case the\n" + "\tparamter will be set to its pre-defined value\n"); + bt_shell_printf("\tPre-defined low-rssi,high-rssi: %d,%d\n", + RSSI_DEFAULT_LOW_THRESHOLD, + RSSI_DEFAULT_HIGH_THRESHOLD); + bt_shell_printf("timeout format:\n" + "\t<low-rssi>,<high-rssi>\n" + "\tBoth parameters can be skipped, in that case the\n" + "\tparamter will be set to its pre-defined value\n"); + bt_shell_printf("\tPre-defined low-timeout,high-timeout: %d,%d\n", + RSSI_DEFAULT_LOW_TIMEOUT, + RSSI_DEFAULT_HIGH_TIMEOUT); + bt_shell_printf("pattern format:\n" + "\t<start_position> <ad_data_type> <content_of_pattern>\n"); + bt_shell_printf("e.g.\n" + "\tadd-or-pattern-rssi -10, ,10 1 2 01ab55\n"); + bt_shell_printf("or\n" + "\tadd-or-pattern-rssi -50,-30 , 1 2 01ab55 3 4 23cd66\n"); +} + +static void print_add_or_pattern_usage(void) +{ + bt_shell_printf("pattern format:\n" + "\t<start_position> <ad_data_type> <content_of_pattern>\n"); + bt_shell_printf("e.g.\n" + "\tadd-or-pattern 1 2 01ab55 3 4 23cd66\n"); +} + +static void cmd_adv_monitor_print_usage(int argc, char *argv[]) +{ + if (strcmp(argv[1], "add-or-pattern") == 0) + print_add_or_pattern_usage(); + else if (strcmp(argv[1], "add-or-pattern-rssi") == 0) + print_add_or_pattern_with_rssi_usage(); + else + bt_shell_printf("Invalid argument %s", argv[1]); +} + +static void cmd_adv_monitor_add_or_monitor_with_rssi(int argc, char *argv[]) +{ + adv_monitor_add_monitor(dbus_conn, "or_patterns", TRUE, argc, argv); +} + +static void cmd_adv_monitor_add_or_monitor(int argc, char *argv[]) +{ + adv_monitor_add_monitor(dbus_conn, "or_patterns", FALSE, argc, argv); +} + +static void cmd_adv_monitor_print_monitor(int argc, char *argv[]) +{ + int monitor_idx; + + if (strcmp(argv[1], "all") == 0) + monitor_idx = -1; + else + monitor_idx = atoi(argv[1]); + adv_monitor_print_monitor(dbus_conn, monitor_idx); +} + +static void cmd_adv_monitor_remove_monitor(int argc, char *argv[]) +{ + int monitor_idx; + + if (strcmp(argv[1], "all") == 0) + monitor_idx = -1; + else + monitor_idx = atoi(argv[1]); + adv_monitor_remove_monitor(dbus_conn, monitor_idx); +} + +static void cmd_adv_monitor_get_supported_info(int argc, char *argv[]) +{ + adv_monitor_get_supported_info(); +} + static const struct bt_shell_menu advertise_menu = { .name = "advertise", .desc = "Advertise Options Submenu", @@ -2755,6 +2834,35 @@ static const struct bt_shell_menu advertise_menu = { { } }, }; +static const struct bt_shell_menu advertise_monitor_menu = { + .name = "monitor", + .desc = "Advertisement Monitor Options Submenu", + .entries = { + { "add-or-pattern-rssi", "<rssi-range=low,high> <timeout=low,high> " + "[patterns=pattern1 pattern2 ...]", + cmd_adv_monitor_add_or_monitor_with_rssi, + "Add 'or pattern' type monitor with RSSI " + "filter" }, + { "add-or-pattern", "[patterns=pattern1 pattern2 ...]", + cmd_adv_monitor_add_or_monitor, + "Add 'or pattern' type monitor without RSSI " + "filter" }, + { "get-pattern", "<monitor-id/all>", + cmd_adv_monitor_print_monitor, + "Get advertisement monitor" }, + { "remove-pattern", "<monitor-id/all>", + cmd_adv_monitor_remove_monitor, + "Remove advertisement monitor" }, + { "get-supported-info", NULL, + cmd_adv_monitor_get_supported_info, + "Get advertisement manager supported " + "features and supported monitor types" }, + { "print-usage", "<add-or-pattern/add-or-pattern-rssi>", + cmd_adv_monitor_print_usage, + "Print the command usage"}, + { } }, +}; + static const struct bt_shell_menu scan_menu = { .name = "scan", .desc = "Scan Options Submenu", @@ -2932,6 +3040,7 @@ int main(int argc, char *argv[]) bt_shell_init(argc, argv, &opt); bt_shell_set_menu(&main_menu); bt_shell_add_submenu(&advertise_menu); + bt_shell_add_submenu(&advertise_monitor_menu); bt_shell_add_submenu(&scan_menu); bt_shell_add_submenu(&gatt_menu); bt_shell_set_prompt(PROMPT_OFF); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6FScAyviXl89YgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 05:23:23 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id cJxSACviXl/EsgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 05:23:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 118DEA097B; Mon, 14 Sep 2020 05:23:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725996AbgINDXA (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 13 Sep 2020 23:23:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbgINDW5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 13 Sep 2020 23:22:57 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D529C06174A for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 20:22:57 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id k3so4863883ybk.16 for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 20:22:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=hgJmWEI4GT2qEDxyV07Ti/eWso4JqJxp8nq9KEqgHMo=; b=VVOgBM6ncyldlSn5vj4zzSng5QsdAnTeutiVU+6LKtRgzWANfpnmdvyzNRk/FBF9yW 8pMqXC+wTDdTI73QgJJKVCs0uUuS/8P80hwGqaNY9UPOSUAUW9Th0BWvgOFzzTOxVMwh POSePJeXcRCsjIUCPKa3Mkztsg7z/olS/vMHZBsfgbsAnOJrsg5r3veYquJbKkuk46yQ IAlOUPmzcirrhvylzgC7ewy1xcsl8vemC+c+h5uqiHAfNV7ighB9u7E+h+Vlxqrn1bxP DF3+aOVJUNihcLVbr3vCgabGPNdWCnNdNYyaRSIC4KP4KXegWHNhfmff6K0SN/fPl29g hYBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=hgJmWEI4GT2qEDxyV07Ti/eWso4JqJxp8nq9KEqgHMo=; b=HJlrIWjlx0U73mF+qhD5Nk5YVrQihkdJ2beyPsUihzX2xpoPRrnCTKz0p1XeT+jxKX t7z67csgIcsq3488rvpUA6EMGfrW80up7LMVTjVik7NXCfk+nmArusOzIgZWPZI6A1Ed 3Ii2GLwliQs4gF0eu3bYoMQiY/A/xcxxvrfIa3rrYTq1Kd/nicklxRrcYkqrdmgtMrIJ 0rd/icEov4HvjWLrGuS+1p0FjZz4MFoEwKEDPqNEZ27r/LMt049vTw6iuUMblhdxX2qH XBtAqgNBsNJsM8yIVkg+69hb+gVJun5DS8UIrSsL0TEF37j4YQrqwAPj9ngSdaMNY+Jy ljvA== X-Gm-Message-State: AOAM533pe3MAcE36t7CIVR81W+xOl8aTwNg7W9NU8EYSgZ3SJwbhi+x7 HTPWF0o6uD9Rcwvr8yuntTLb9HZEUU3xq8nt/CVUjeJ4VB1jFBnl3JhwmaBvoJt3dtmP69Mis/b o+RUbiFmlOauNerqPDQzvKWzuF887HrXmOo700Wj6S0tDKxezN3oIcRjztgG/uJH9URS2XEL16w 3Lx0ATNbnBMNM= X-Google-Smtp-Source: ABdhPJw9pEgPCnh4+MLBmUP68pMTnFHy6cgmcNEOZfPF3vl/Uj8k/uVvYSFgwPgEbn+2JHzX5XzX5MaLZHh7LRZyPw== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a25:c2c7:: with SMTP id s190mr16699397ybf.161.1600053774769; Sun, 13 Sep 2020 20:22:54 -0700 (PDT) Date: Mon, 14 Sep 2020 11:22:33 +0800 In-Reply-To: <20200914112137.BlueZ.v4.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200914112137.BlueZ.v4.4.Ieffbe3452565ace2af46a63501c767c8798fd88c@changeid> Mime-Version: 1.0 References: <20200914112137.BlueZ.v4.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v4 4/4] core: Add AdvertisementMonitor to bluetooth.conf From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, luiz.von.dentz@intel.com, mmandlik@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: 118DEA097B X-Rspamd-UID: 6a59b3 AdvertisementMonitor must be included in bluetooth.conf in order to be able to call Release Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v4: - Remove PRE-UPSTREAM in commit title Reviewed-by: Miao-chen Chou <mcchou@chromium.org> src/bluetooth.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bluetooth.conf b/src/bluetooth.conf index 8a1e25801..b6c614908 100644 --- a/src/bluetooth.conf +++ b/src/bluetooth.conf @@ -10,6 +10,7 @@ <policy user="root"> <allow own="org.bluez"/> <allow send_destination="org.bluez"/> + <allow send_interface="org.bluez.AdvertisementMonitor1"/> <allow send_interface="org.bluez.Agent1"/> <allow send_interface="org.bluez.MediaEndpoint1"/> <allow send_interface="org.bluez.MediaPlayer1"/> -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iEfZC00JX1/C7QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 08:10:21 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id KIz9B00JX1+k4AAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 08:10:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 97A024097E; Mon, 14 Sep 2020 08:10:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726217AbgINGKD (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 02:10:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726143AbgINGKA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 02:10:00 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC6FC061788 for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 23:10:00 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id f4so9045473qvw.15 for <linux-bluetooth@vger.kernel.org>; Sun, 13 Sep 2020 23:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=1LyqgXu5Psw2sRR9U9KlRbCocKTP6YVjaIZ4PjZiU+Y=; b=V3nCmh4thAbVQp2hGyxmLWma5N2ViDlIZ+TDiSUZr4fZHj7guP414BaaRaWtH1NGo0 NeutxRBMTdP2qJBVXhcnvOrCLV8z5uW+9V2/QkOQUt+Jp1glwFyb+YCTLW6AXK61OPmj G8AFK/g6VCZG+9ur/ybHT9KvpRJHXfST7hoC7EdxCU3eyRllTuuXyz2n99z+NOvYsz2X MKFYmsv4kTr4QnilTZqgJwtK1dartDySmPsp0HmPrkCL+oay7eRNaGkU426Cm7hgC3az Js49DVbE3lRNQ7GQW3RkoCADRuucSAYnwYeXTUGcr2OtE0Musakaso2ijgwIbM/XaZKk ViqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=1LyqgXu5Psw2sRR9U9KlRbCocKTP6YVjaIZ4PjZiU+Y=; b=YFLUSyxYFKEMF9pbWSToOruvZdakwuNWR+IQrSRGyXQzWPsLeXQm5v0U2+F9mHdRLy r06tIf4hwNQYwuL2agFyJHUpr+/YA0wu2AlHAbldXiH8eyoAYVSxybmL836rZ23PQcbl cfUr/YDL13lLApKE6PT5LpVcJ7Ejvyi6/mpT7xG0gQ2R0kHB3AJP91xC39AcAJ6Xrt5Z 2bb1IRez2JFZigNbDUgdm36pWmDOH6vzbxmdZxmPVHZvAhYs3nx7+8kf9PcXZb3Pv5NV 0hmJyhvacKJgx0N43GqWsYkDNGYm34NUezDYd/HMa/+9o/l/Yihh92uxUjYjHmmjUYKq 8IdA== X-Gm-Message-State: AOAM532LeRCQgZR3eXmuMpyujvjkei2lyzSy038lZBm1QE7CF/n8klX1 M/XV5sOuCUf07CG5Z5uiyCvrOesPp+cwnaYqA/SHUdU2k1H4a4aWDcSvopRt1SR6bbBhaB9X8ju x6WSW2GqFxt42f7Yb07a2ZKeNagq7KStoUhm31G39Re9wx/oLa6jk2tZSeMPtRPUCW00IQBw1BF tJ X-Google-Smtp-Source: ABdhPJzvHkSdpHwe5gE0sOLW9Z4gApRjvYi3FzBxkhNq5OI1N8Pc28i8LA1732q5sil5it2v2PQ+g20+j/hR X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a05:6214:903:: with SMTP id dj3mr7569613qvb.14.1600063797823; Sun, 13 Sep 2020 23:09:57 -0700 (PDT) Date: Mon, 14 Sep 2020 14:09:52 +0800 Message-Id: <20200914140931.Bluez.v1.1.I59718e11885aba51acaa2b4263a1f446c94626a8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH v1] avrcp: issue ADDRESSED_PLAYED_CHANGED_EVENT on player addition/removal From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Michael Sun <michaelfsun@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.53 / 15.00 / 15.00 X-Rspamd-Queue-Id: 97A024097E X-Rspamd-UID: a56479 From: Archie Pusaka <apusaka@chromium.org> There is a possibility of us assigning a session to a different player upon addition/deletion of some player. If this happens, we should issue the notification event ADDRESSED_PLAYED_CHANGED_EVENT as well. Reviewed-by: Michael Sun <michaelfsun@google.com> Signed-off-by: Archie Pusaka <apusaka@chromium.org> --- profiles/audio/avrcp.c | 90 +++++++++++++++++++++++++++++++----------- 1 file changed, 67 insertions(+), 23 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 5ef98acd1..373616426 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -251,6 +251,7 @@ struct avrcp_player { uint8_t *features; char *path; guint changed_id; + bool pending_player_changed; struct pending_list_items *p; char *change_path; @@ -784,8 +785,8 @@ static uint16_t player_settings_changed(struct avrcp_player *player, return size; } -void avrcp_player_event(struct avrcp_player *player, uint8_t id, - const void *data) +static void avrcp_send_event(struct avrcp_player *player, GSList *sessions, + uint8_t id, const void *data) { uint8_t buf[AVRCP_HEADER_LENGTH + 9]; struct avrcp_header *pdu = (void *) buf; @@ -793,7 +794,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, uint16_t size; GSList *l; - if (player->sessions == NULL) + if (sessions == NULL) return; memset(buf, 0, sizeof(buf)); @@ -804,7 +805,8 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, DBG("id=%u", id); - if (id != AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED && player->changed_id) { + if (id != AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED && + player->pending_player_changed) { code = AVC_CTYPE_REJECTED; size = 1; pdu->params[0] = AVRCP_STATUS_ADDRESSED_PLAYER_CHANGED; @@ -834,8 +836,8 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, break; case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: size = 5; - memcpy(&pdu->params[1], &player->id, sizeof(uint16_t)); - memcpy(&pdu->params[3], &player->uid_counter, sizeof(uint16_t)); + bt_put_be16(player->id, &pdu->params[1]); + bt_put_be16(player->uid_counter, &pdu->params[3]); break; case AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED: size = 1; @@ -848,7 +850,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, done: pdu->params_len = htons(size); - for (l = player->sessions; l; l = l->next) { + for (l = sessions; l; l = l->next) { struct avrcp *session = l->data; int err; @@ -870,6 +872,21 @@ done: return; } +void avrcp_player_event(struct avrcp_player *player, uint8_t id, + const void *data) +{ + avrcp_send_event(player, player->sessions, id, data); +} + +static void avrcp_player_single_session_event(struct avrcp_player *player, + struct avrcp *session, uint8_t id, const void *data) +{ + GSList *session_list = g_slist_append(NULL, session); + + avrcp_send_event(player, session_list, id, data); + g_slist_free(session_list); +} + static const char *metadata_to_str(uint32_t id) { switch (id) { @@ -1796,7 +1813,8 @@ static struct avrcp_player *find_tg_player(struct avrcp *session, uint16_t id) static gboolean notify_addressed_player_changed(gpointer user_data) { - struct avrcp_player *player = user_data; + struct avrcp *session = user_data; + struct avrcp_player *player = target_get_player(session); uint8_t events[6] = { AVRCP_EVENT_STATUS_CHANGED, AVRCP_EVENT_TRACK_CHANGED, AVRCP_EVENT_TRACK_REACHED_START, @@ -1806,17 +1824,21 @@ static gboolean notify_addressed_player_changed(gpointer user_data) }; uint8_t i; - avrcp_player_event(player, AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED, NULL); + avrcp_player_single_session_event(player, session, + AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED, NULL); /* * TG shall complete all player specific * notifications with AV/C C-Type REJECTED * with error code as Addressed Player Changed. */ + player->pending_player_changed = true; for (i = 0; i < sizeof(events); i++) - avrcp_player_event(player, events[i], NULL); + avrcp_player_single_session_event(player, session, events[i], + NULL); player->changed_id = 0; + player->pending_player_changed = false; return FALSE; } @@ -1826,6 +1848,7 @@ static uint8_t avrcp_handle_set_addressed_player(struct avrcp *session, uint8_t transaction) { struct avrcp_player *player; + struct avrcp_player *old_player; uint16_t len = ntohs(pdu->params_len); uint16_t player_id = 0; uint8_t status; @@ -1839,21 +1862,32 @@ static uint8_t avrcp_handle_set_addressed_player(struct avrcp *session, player = find_tg_player(session, player_id); pdu->packet_type = AVRCP_PACKET_TYPE_SINGLE; - if (player) { - player->addressed = true; - status = AVRCP_STATUS_SUCCESS; - pdu->params_len = htons(len); - pdu->params[0] = status; - } else { + if (!player) { status = AVRCP_STATUS_INVALID_PLAYER_ID; goto err; } + old_player = target_get_player(session); + + if (old_player != player) { + if (old_player) + old_player->sessions = g_slist_remove( + old_player->sessions, session); + + session->target->player = player; + player->sessions = g_slist_append(player->sessions, session); + } + + player->addressed = true; + status = AVRCP_STATUS_SUCCESS; + pdu->params_len = htons(len); + pdu->params[0] = status; + /* Don't emit player changed immediately since PTS expect the * response of SetAddressedPlayer before the event. */ player->changed_id = g_idle_add(notify_addressed_player_changed, - player); + session); return AVC_CTYPE_ACCEPTED; @@ -4137,6 +4171,7 @@ static void target_init(struct avrcp *session) int8_t init_volume; target->player = player; player->sessions = g_slist_prepend(player->sessions, session); + player->addressed = true; init_volume = media_player_get_device_volume(session->dev); media_transport_update_device_volume(session->dev, init_volume); @@ -4430,11 +4465,12 @@ struct avrcp_player *avrcp_register_player(struct btd_adapter *adapter, target->player = player; player->sessions = g_slist_append(player->sessions, session); + player->addressed = true; + notify_addressed_player_changed(session); } } - avrcp_player_event(player, - AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED, NULL); + avrcp_player_event(player, AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED, NULL); return player; } @@ -4442,9 +4478,11 @@ struct avrcp_player *avrcp_register_player(struct btd_adapter *adapter, void avrcp_unregister_player(struct avrcp_player *player) { struct avrcp_server *server = player->server; + struct avrcp_player *substitute; GSList *l; server->players = g_slist_remove(server->players, player); + substitute = g_slist_nth_data(server->players, 0); /* Remove player from sessions using it */ for (l = player->sessions; l; l = l->next) { @@ -4454,12 +4492,18 @@ void avrcp_unregister_player(struct avrcp_player *player) if (target == NULL) continue; - if (target->player == player) - target->player = g_slist_nth_data(server->players, 0); + if (target->player == player) { + target->player = substitute; + if (substitute) { + substitute->addressed = true; + substitute->sessions = g_slist_append( + substitute->sessions, session); + notify_addressed_player_changed(session); + } + } } - avrcp_player_event(player, - AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED, NULL); + avrcp_player_event(player, AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED, NULL); player_destroy(player); } -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KKgCN+01X1/OkAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 11:20:45 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iEJSM+01X1+iPwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 11:20:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=mg.codeaurora.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 25B3F4086C; Mon, 14 Sep 2020 11:20:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726242AbgINJUg (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 05:20:36 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:45601 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726233AbgINJUb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 05:20:31 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1600075230; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=CcQAVMd8qwmuMuqTTV1Jxc2LM4qV+7AZwrdzJla0o/I=; b=cs4LZEMKBtTaYGfHxL5ZJzT13DCTdSWJKG6JSCSt5Z+r/MQY9pFLaY4+ikhNCdipzmmL8/ua nMbf+/a/XJqdiprgqNg/7MTUnNSutLjI4h1UFw405egR8J56UbkNklY5U+0OCIqp7v5Luvke f5a7pQYDJwLm3jwuUyhZ5NAoAYQ= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI2MTA3ZSIsICJsaW51eC1ibHVldG9vdGhAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-east-1.postgun.com with SMTP id 5f5f35c7ba408b30ce1ce208 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 14 Sep 2020 09:20:07 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 81D4FC433C8; Mon, 14 Sep 2020 09:20:06 +0000 (UTC) Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: rjliao) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7BD01C433C8; Mon, 14 Sep 2020 09:20:05 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 14 Sep 2020 17:20:05 +0800 From: Rocky Liao <rjliao@codeaurora.org> To: Marcel Holtmann <marcel@holtmann.org> Cc: Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, c-hbandi@codeaurora.org, hemantg@codeaurora.org, mka@chromium.org, linux-bluetooth-owner@vger.kernel.org Subject: Re: [PATCH v1] Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support In-Reply-To: <2E48211B-D62D-43D8-9C97-014966FBB2CB@holtmann.org> References: <0101017457c6b810-cb8b79ae-4663-436b-83d0-4c70c245bd25-000000@us-west-2.amazonses.com> <2E48211B-D62D-43D8-9C97-014966FBB2CB@holtmann.org> Message-ID: <c177f408186da437db722d855a01c846@codeaurora.org> X-Sender: rjliao@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.57 / 15.00 / 15.00 X-Rspamd-Queue-Id: 25B3F4086C X-Rspamd-UID: bb2dcc Hi Marcel, 在 2020-09-11 14:56,Marcel Holtmann 写道: > Hi Rocky, > >> This patch add support for WCN6855 i.e. patch and nvm download >> support. >> >> Signed-off-by: Rocky Liao <rjliao@codeaurora.org> >> --- >> drivers/bluetooth/btusb.c | 42 +++++++++++++++++++++++++++++++++++---- >> 1 file changed, 38 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c >> index fe80588c7bd3..e51e754ca9b8 100644 >> --- a/drivers/bluetooth/btusb.c >> +++ b/drivers/bluetooth/btusb.c >> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver; >> #define BTUSB_MEDIATEK 0x200000 >> #define BTUSB_WIDEBAND_SPEECH 0x400000 >> #define BTUSB_VALID_LE_STATES 0x800000 >> +#define BTUSB_QCA_WCN6855 0x1000000 >> >> static const struct usb_device_id btusb_table[] = { >> /* Generic Bluetooth USB device */ >> @@ -273,6 +274,10 @@ static const struct usb_device_id >> blacklist_table[] = { >> { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME }, >> { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME }, >> >> + /* QCA WCN6855 chipset */ >> + { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 | >> + BTUSB_WIDEBAND_SPEECH }, >> + >> /* Broadcom BCM2035 */ >> { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, >> { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU }, >> @@ -3391,6 +3396,26 @@ static int btusb_set_bdaddr_ath3012(struct >> hci_dev *hdev, >> return 0; >> } >> >> +static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev, >> + const bdaddr_t *bdaddr) >> +{ >> + struct sk_buff *skb; >> + u8 buf[6]; >> + long ret; >> + >> + memcpy(buf, bdaddr, sizeof(bdaddr_t)); >> + >> + skb = __hci_cmd_sync(hdev, 0xfc14, sizeof(buf), buf, >> HCI_INIT_TIMEOUT); >> + if (IS_ERR(skb)) { >> + ret = PTR_ERR(skb); >> + bt_dev_err(hdev, "Change address command failed (%ld)", ret); >> + return ret; >> + } >> + kfree_skb(skb); >> + >> + return 0; >> +} > > What is wrong with using qca_set_bdaddr() function. > WCN6855 is using different VSC to set the bt addr >> + >> #define QCA_DFU_PACKET_LEN 4096 >> >> #define QCA_GET_TARGET_VERSION 0x09 >> @@ -3428,6 +3453,8 @@ static const struct qca_device_info >> qca_devices_table[] = { >> { 0x00000201, 28, 4, 18 }, /* Rome 2.1 */ >> { 0x00000300, 28, 4, 18 }, /* Rome 3.0 */ >> { 0x00000302, 28, 4, 18 }, /* Rome 3.2 */ >> + { 0x00130100, 40, 4, 18 }, /* WCN6855 1.0 */ >> + { 0x00130200, 40, 4, 18 } /* WCN6855 2.0 */ >> }; >> >> static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 >> request, >> @@ -3530,7 +3557,7 @@ static int btusb_setup_qca_load_rampatch(struct >> hci_dev *hdev, >> struct qca_rampatch_version *rver; >> const struct firmware *fw; >> u32 ver_rom, ver_patch; >> - u16 rver_rom, rver_patch; >> + u32 rver_rom, rver_patch; >> char fwname[64]; >> int err; >> >> @@ -3552,6 +3579,9 @@ static int btusb_setup_qca_load_rampatch(struct >> hci_dev *hdev, >> rver_rom = le16_to_cpu(rver->rom_version); >> rver_patch = le16_to_cpu(rver->patch_version); >> >> + if (ver_rom & ~0xffffU) >> + rver_rom = *(u16 *)(fw->data + 16) << 16 | rver_rom; >> + > > You will require proper unaligned access unless you can guarantee > things are aligned properly. And since I assume the firmware data is > in a specific endian format, you need to convert it correctly. > > In addition, you change the variables to u32, but still use > le16_to_cpu function above. Something is not adding up. Have you > actually run a sparse check? > I missed the endian requirement and will updata the patch soon. >> bt_dev_info(hdev, "QCA: patch rome 0x%x build 0x%x, " >> "firmware rome 0x%x build 0x%x", >> rver_rom, rver_patch, ver_rom, ver_patch); >> @@ -3625,9 +3655,6 @@ static int btusb_setup_qca(struct hci_dev *hdev) >> return err; >> >> ver_rom = le32_to_cpu(ver.rom_version); >> - /* Don't care about high ROM versions */ >> - if (ver_rom & ~0xffffU) >> - return 0; >> >> for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) { >> if (ver_rom == qca_devices_table[i].rom_version) >> @@ -4063,6 +4090,13 @@ static int btusb_probe(struct usb_interface >> *intf, >> btusb_check_needs_reset_resume(intf); >> } >> >> + if (id->driver_info & BTUSB_QCA_WCN6855) { >> + data->setup_on_usb = btusb_setup_qca; >> + hdev->set_bdaddr = btusb_set_bdaddr_wcn6855; >> + hdev->cmd_timeout = btusb_qca_cmd_timeout; >> + set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); >> + } >> + > > Regards > > Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GD9LA683X1/LkAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 11:28:15 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OKGtAK83X1+tsQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 11:28:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=mg.codeaurora.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0881040618; Mon, 14 Sep 2020 11:28:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726264AbgINJ2A (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 05:28:00 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:43086 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbgINJ16 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 05:27:58 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1600075677; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=sB/nZ+FaUDTpKOU4zLhwL7vIAbiIAn4bVQMvEhkJDNs=; b=bQpu//sZc7ZvVXNWCQBtbYeWcmKB7K6WG/r0sfYydpI0VasOz+VtN4GlGWClISLyGSebH8zO AJr1gSqXDQwM1RmFdu7zVJkpPCXuneuYHHry9TFIrgJLZmNIuG3dkLs+IiAhWD88f+FlHoaz ErbzPE3dPHiBZxTp0mMgFUuHVSY= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI2MTA3ZSIsICJsaW51eC1ibHVldG9vdGhAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-east-1.postgun.com with SMTP id 5f5f379c238e1efa370bcccc (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 14 Sep 2020 09:27:56 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id ED104C433F0; Mon, 14 Sep 2020 09:27:55 +0000 (UTC) Received: from rocky-Inspiron-7590.qca.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rjliao) by smtp.codeaurora.org (Postfix) with ESMTPSA id 804D4C433CA; Mon, 14 Sep 2020 09:27:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 804D4C433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=rjliao@codeaurora.org From: Rocky Liao <rjliao@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, Rocky Liao <rjliao@codeaurora.org> Subject: [PATCH v2] Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support Date: Mon, 14 Sep 2020 17:27:44 +0800 Message-Id: <20200914092744.17464-1-rjliao@codeaurora.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <0101017457c6b819-d1292819-1fae-43af-8fb8-3bc572f53cd5-000000@us-west-2.amazonses.com> References: <0101017457c6b819-d1292819-1fae-43af-8fb8-3bc572f53cd5-000000@us-west-2.amazonses.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.57 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0881040618 X-Rspamd-UID: a4b8f5 This patch add support for WCN6855 i.e. patch and nvm download support. Signed-off-by: Rocky Liao <rjliao@codeaurora.org> --- drivers/bluetooth/btusb.c | 50 ++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index fe80588c7bd3..789e8d5e829e 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver; #define BTUSB_MEDIATEK 0x200000 #define BTUSB_WIDEBAND_SPEECH 0x400000 #define BTUSB_VALID_LE_STATES 0x800000 +#define BTUSB_QCA_WCN6855 0x1000000 static const struct usb_device_id btusb_table[] = { /* Generic Bluetooth USB device */ @@ -273,6 +274,10 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME }, + /* QCA WCN6855 chipset */ + { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 | + BTUSB_WIDEBAND_SPEECH }, + /* Broadcom BCM2035 */ { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU }, @@ -3391,6 +3396,26 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev, return 0; } +static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev, + const bdaddr_t *bdaddr) +{ + struct sk_buff *skb; + u8 buf[6]; + long ret; + + memcpy(buf, bdaddr, sizeof(bdaddr_t)); + + skb = __hci_cmd_sync(hdev, 0xfc14, sizeof(buf), buf, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + ret = PTR_ERR(skb); + bt_dev_err(hdev, "Change address command failed (%ld)", ret); + return ret; + } + kfree_skb(skb); + + return 0; +} + #define QCA_DFU_PACKET_LEN 4096 #define QCA_GET_TARGET_VERSION 0x09 @@ -3428,6 +3453,8 @@ static const struct qca_device_info qca_devices_table[] = { { 0x00000201, 28, 4, 18 }, /* Rome 2.1 */ { 0x00000300, 28, 4, 18 }, /* Rome 3.0 */ { 0x00000302, 28, 4, 18 }, /* Rome 3.2 */ + { 0x00130100, 40, 4, 18 }, /* WCN6855 1.0 */ + { 0x00130200, 40, 4, 18 } /* WCN6855 2.0 */ }; static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request, @@ -3529,8 +3556,8 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, { struct qca_rampatch_version *rver; const struct firmware *fw; - u32 ver_rom, ver_patch; - u16 rver_rom, rver_patch; + u32 ver_rom, ver_patch, rver_rom; + u16 rver_rom_low, rver_rom_high, rver_patch; char fwname[64]; int err; @@ -3549,9 +3576,16 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, bt_dev_info(hdev, "using rampatch file: %s", fwname); rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset); - rver_rom = le16_to_cpu(rver->rom_version); + rver_rom_low = le16_to_cpu(rver->rom_version); rver_patch = le16_to_cpu(rver->patch_version); + if (ver_rom & ~0xffffU) { + rver_rom_high = le16_to_cpu(*(__le16 *)(fw->data + 16)); + rver_rom = le32_to_cpu(rver_rom_high << 16 | rver_rom_low); + } else { + rver_rom = (__force u32)rver_rom_low; + } + bt_dev_info(hdev, "QCA: patch rome 0x%x build 0x%x, " "firmware rome 0x%x build 0x%x", rver_rom, rver_patch, ver_rom, ver_patch); @@ -3625,9 +3659,6 @@ static int btusb_setup_qca(struct hci_dev *hdev) return err; ver_rom = le32_to_cpu(ver.rom_version); - /* Don't care about high ROM versions */ - if (ver_rom & ~0xffffU) - return 0; for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) { if (ver_rom == qca_devices_table[i].rom_version) @@ -4063,6 +4094,13 @@ static int btusb_probe(struct usb_interface *intf, btusb_check_needs_reset_resume(intf); } + if (id->driver_info & BTUSB_QCA_WCN6855) { + data->setup_on_usb = btusb_setup_qca; + hdev->set_bdaddr = btusb_set_bdaddr_wcn6855; + hdev->cmd_timeout = btusb_qca_cmd_timeout; + set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); + } + if (id->driver_info & BTUSB_AMP) { /* AMP controllers do not support SCO packets */ data->isoc = NULL; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OHUqHlFwX18aMgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 15:29:53 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MPqwGlFwX19XJQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 15:29:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3F6A5A0B7A; Mon, 14 Sep 2020 15:29:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726301AbgINN2G (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 09:28:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbgINNZn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 09:25:43 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D51C0C06178B for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 06:25:42 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id z19so12618528pfn.8 for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 06:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=r4wEGA0i1h+TaaI8ogIOqXo9gZlNAqNjwv5dvfMH8kk=; b=eqO6Kn+N8c05rS9slIhX4PnaY7dkE1cO/fF7pc3OV4AZWVgs7MaiIfygP8Xl4EVCRg 0r4YSI31FtQWM2+V3rBIdkQiqCVUQxTuNu7dbZnRP2/arUwB7px+63UxN0HG8bXRZ3Ve dVmdrPMke0F+V0ixrvNvEAzBNWPfSG9PDv5qn5I/LdH8CfDYrwmWGwpe5bKL5PDsyryf GXJDbLGlfn9YztBmOYkt8AZZLSwTEwaKqOd7fXaziqWNMxmLPdFHe+GO4fTpDinYjoTG h1Uc5xQtQLqjI5uThyO6CZSCR7prCDJ8lqesuOsIM6/7OmWxhJ0unm4VhGqXwgFfdSfs oO1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=r4wEGA0i1h+TaaI8ogIOqXo9gZlNAqNjwv5dvfMH8kk=; b=fskj/boE4R819vJ6JPK4f/1iLk+PqD5yR4oDWeQNh4izIKsaalMAa5jsHByH20kMWi N1KM5clCnsXoeOIqjNee9vK6np7+joQde7B6lEUgCPOLFN4LfDCymPdBvwiqTtx38rBN E9Zu9scC+RE7vmc5mmG52nRYiN/UxjMM0CHdYwBod2TLYIVWfcYxidsckI6GgugmP3VJ JCELhxG9hTAJ/vuak2r8T1JOtqUsDQPXByXmKIKY3N7kg+oCMg56AZOT9RPGq7iJkfwL LVaXMXFpkV0ey9IKGlatUNX5kj5Sx+EdBBz5Z7U5Ze6DEUhj5Ftg514iEt06W2kq5flT 74vw== X-Gm-Message-State: AOAM532jEbifldDC88hFWtkzmyeWSF91+O3YAwjYDwS38CG+UsFnV3mm letOIbUULL85QWQ+mi0AnzCQZvmQLEm/Hg== X-Google-Smtp-Source: ABdhPJxlYeqiUhV9SAJ4vAVnYnMgwhLcs6M3HsG7DenGHV3z34D9IkhIKtsxfzv6U2OL0Ul4jU4B4g== X-Received: by 2002:a62:8c86:: with SMTP id m128mr13387687pfd.111.1600089941491; Mon, 14 Sep 2020 06:25:41 -0700 (PDT) Received: from localhost.localdomain ([171.61.74.206]) by smtp.gmail.com with ESMTPSA id m20sm10776707pfa.115.2020.09.14.06.25.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 06:25:40 -0700 (PDT) From: Kiran K <kiraank@gmail.com> X-Google-Original-From: Kiran K <kiran.k@intel.com> To: linux-bluetooth@vger.kernel.org Cc: chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com, kiraank@gmail.com, Kiran K <kiran.k@intel.com>, Amit K Bag <amit.k.bag@intel.com>, Raghuram Hegde <raghuram.hegde@intel.com> Subject: [PATCH v1 2/2] Bluetooth: btintel: Functions to send firmware header / payload Date: Mon, 14 Sep 2020 18:55:06 +0530 Message-Id: <1600089906-9852-2-git-send-email-kiran.k@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600089906-9852-1-git-send-email-kiran.k@intel.com> References: <1600089906-9852-1-git-send-email-kiran.k@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.17 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3F6A5A0B7A X-Rspamd-UID: 3b83cf New generation controllers supports ECDSA secure boot engine. This patch adds, 1) function to send ECDSA header 2) function to download complete firmware for new generation Intel controllers Signed-off-by: Kiran K <kiran.k@intel.com> Signed-off-by: Amit K Bag <amit.k.bag@intel.com> Signed-off-by: Raghuram Hegde <raghuram.hegde@intel.com> Reviewed-by: Chethan T N <chethan.tumkur.narayan@intel.com> Reviewed-by: Srivatsa Ravishankar <ravishankar.srivatsa@intel.com> --- drivers/bluetooth/btintel.c | 119 +++++++++++++++++++++++++++++++++++++++++++- drivers/bluetooth/btintel.h | 12 +++++ 2 files changed, 129 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index e99fc6e..88ce5f0 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -18,8 +18,11 @@ #define VERSION "0.1" -#define BDADDR_INTEL (&(bdaddr_t) {{0x00, 0x8b, 0x9e, 0x19, 0x03, 0x00}}) -#define RSA_HEADER_LEN 644 +#define BDADDR_INTEL (&(bdaddr_t){{0x00, 0x8b, 0x9e, 0x19, 0x03, 0x00}}) +#define RSA_HEADER_LEN 644 +#define CSS_HEADER_OFFSET 8 +#define ECDSA_OFFSET 644 +#define ECDSA_HEADER_LEN 320 int btintel_check_bdaddr(struct hci_dev *hdev) { @@ -801,6 +804,41 @@ static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev, return err; } +static int btintel_sfi_ecdsa_header_secure_send(struct hci_dev *hdev, + const struct firmware *fw) +{ + int err; + + /* Start the firmware download transaction with the Init fragment + * represented by the 128 bytes of CSS header. + */ + err = btintel_secure_send(hdev, 0x00, 128, fw->data + 644); + if (err < 0) { + bt_dev_err(hdev, "Failed to send firmware header (%d)", err); + return err; + } + + /* Send the 96 bytes of public key information from the firmware + * as the PKey fragment. + */ + err = btintel_secure_send(hdev, 0x03, 96, fw->data + 644 + 128); + if (err < 0) { + bt_dev_err(hdev, "Failed to send firmware pkey (%d)", err); + return err; + } + + /* Send the 96 bytes of signature information from the firmware + * as the Sign fragment + */ + err = btintel_secure_send(hdev, 0x02, 96, fw->data + 644 + 224); + if (err < 0) { + bt_dev_err(hdev, "Failed to send firmware signature (%d)", + err); + return err; + } + return 0; +} + static int btintel_download_firmware_payload(struct hci_dev *hdev, const struct firmware *fw, u32 *boot_param, size_t offset) @@ -873,6 +911,83 @@ int btintel_download_firmware(struct hci_dev *hdev, } EXPORT_SYMBOL_GPL(btintel_download_firmware); +int btintel_download_firmware_newgen(struct hci_dev *hdev, + const struct firmware *fw, u32 *boot_param, + u8 hw_variant, u8 sbe_type) +{ + int err; + u32 css_header_ver; + + /* iBT hardware variants 0x0b, 0x0c, 0x11, 0x12, 0x13, 0x14 support + * only RSA secure boot engine. Hence, the corresponding sfi file will + * have RSA header of 644 bytes followed by Command Buffer. + * + * iBT hardware variants 0x17, 0x18 onwards support both RSA and ECDSA + * secure boot engine. As a result, the corresponding sfi file will + * have RSA header of 644, ECDSA header of 320 bytes followed by + * Command Buffer. + * + * CSS Header byte positions 0x08 to 0x0B represent the CSS Header + * version: RSA(0x00010000) , ECDSA (0x00020000) + */ + css_header_ver = get_unaligned_le32(fw->data + CSS_HEADER_OFFSET); + if (css_header_ver != 0x00010000) { + bt_dev_err(hdev, "Invalid CSS Header version"); + return -EINVAL; + } + + if (hw_variant <= 0x14) { + if (sbe_type != 0x00) { + bt_dev_err(hdev, "Invalid SBE type for hardware variant (%d)", + hw_variant); + return -EINVAL; + } + + err = btintel_sfi_rsa_header_secure_send(hdev, fw); + if (err) + return err; + + err = btintel_download_firmware_payload(hdev, fw, boot_param, RSA_HEADER_LEN); + if (err) + return err; + } else if (hw_variant >= 0x17) { + /* Check if CSS header for ECDSA follows the RSA header */ + if (fw->data[ECDSA_OFFSET] != 0x06) + return -EINVAL; + + /* Check if the CSS Header version is ECDSA(0x00020000) */ + css_header_ver = get_unaligned_le32(fw->data + ECDSA_OFFSET + CSS_HEADER_OFFSET); + if (css_header_ver != 0x00020000) { + bt_dev_err(hdev, "Invalid CSS Header version"); + return -EINVAL; + } + + if (sbe_type == 0x00) { + err = btintel_sfi_rsa_header_secure_send(hdev, fw); + if (err) + return err; + + err = btintel_download_firmware_payload(hdev, fw, + boot_param, + RSA_HEADER_LEN + ECDSA_HEADER_LEN); + if (err) + return err; + } else if (sbe_type == 0x01) { + err = btintel_sfi_ecdsa_header_secure_send(hdev, fw); + if (err) + return err; + + err = btintel_download_firmware_payload(hdev, fw, + boot_param, + RSA_HEADER_LEN + ECDSA_HEADER_LEN); + if (err) + return err; + } + } + return 0; +} +EXPORT_SYMBOL_GPL(btintel_download_firmware_newgen); + void btintel_reset_to_bootloader(struct hci_dev *hdev) { struct intel_reset params; diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 829e1fc..09346ae 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -159,6 +159,10 @@ int btintel_read_boot_params(struct hci_dev *hdev, struct intel_boot_params *params); int btintel_download_firmware(struct hci_dev *dev, const struct firmware *fw, u32 *boot_param); +int btintel_download_firmware_newgen(struct hci_dev *hdev, + const struct firmware *fw, + u32 *boot_param, u8 hw_variant, + u8 sbe_type); void btintel_reset_to_bootloader(struct hci_dev *hdev); int btintel_read_debug_features(struct hci_dev *hdev, struct intel_debug_features *features); @@ -270,6 +274,14 @@ static inline int btintel_download_firmware(struct hci_dev *dev, return -EOPNOTSUPP; } +static inline int btintel_download_firmware_newgen(struct hci_dev *hdev, + const struct firmware *fw, + u32 *boot_param, + u8 hw_variant, u8 sbe_type) +{ + return -EOPNOTSUPP; +} + static inline void btintel_reset_to_bootloader(struct hci_dev *hdev) { } -- 2.7.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ICcnBVBxX18aMgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 15:34:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SFXPAVBxX1+1SQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 15:34:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C693A40968; Mon, 14 Sep 2020 15:34:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726598AbgINNc6 convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 09:32:58 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:50590 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726683AbgINN24 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 09:28:56 -0400 Received: from marcel-macpro.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id BD319CECDD; Mon, 14 Sep 2020 15:35:50 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v2] Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200914092744.17464-1-rjliao@codeaurora.org> Date: Mon, 14 Sep 2020 15:28:53 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <4FCC6630-8350-4E4A-B156-42B2F3581BFD@holtmann.org> References: <0101017457c6b819-d1292819-1fae-43af-8fb8-3bc572f53cd5-000000@us-west-2.amazonses.com> <20200914092744.17464-1-rjliao@codeaurora.org> To: Rocky Liao <rjliao@codeaurora.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.01 / 15.00 / 15.00 X-Rspamd-Queue-Id: C693A40968 X-Rspamd-UID: 14c537 Hi Rocky, > This patch add support for WCN6855 i.e. patch and nvm download > support. > > Signed-off-by: Rocky Liao <rjliao@codeaurora.org> > --- > drivers/bluetooth/btusb.c | 50 ++++++++++++++++++++++++++++++++++----- > 1 file changed, 44 insertions(+), 6 deletions(-) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index fe80588c7bd3..789e8d5e829e 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver; > #define BTUSB_MEDIATEK 0x200000 > #define BTUSB_WIDEBAND_SPEECH 0x400000 > #define BTUSB_VALID_LE_STATES 0x800000 > +#define BTUSB_QCA_WCN6855 0x1000000 > > static const struct usb_device_id btusb_table[] = { > /* Generic Bluetooth USB device */ > @@ -273,6 +274,10 @@ static const struct usb_device_id blacklist_table[] = { > { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME }, > { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME }, > > + /* QCA WCN6855 chipset */ > + { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 | > + BTUSB_WIDEBAND_SPEECH }, > + > /* Broadcom BCM2035 */ > { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, > { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU }, > @@ -3391,6 +3396,26 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev, > return 0; > } > > +static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev, > + const bdaddr_t *bdaddr) > +{ > + struct sk_buff *skb; > + u8 buf[6]; > + long ret; > + > + memcpy(buf, bdaddr, sizeof(bdaddr_t)); > + > + skb = __hci_cmd_sync(hdev, 0xfc14, sizeof(buf), buf, HCI_INIT_TIMEOUT); > + if (IS_ERR(skb)) { > + ret = PTR_ERR(skb); > + bt_dev_err(hdev, "Change address command failed (%ld)", ret); > + return ret; > + } > + kfree_skb(skb); > + > + return 0; > +} > + > #define QCA_DFU_PACKET_LEN 4096 > > #define QCA_GET_TARGET_VERSION 0x09 > @@ -3428,6 +3453,8 @@ static const struct qca_device_info qca_devices_table[] = { > { 0x00000201, 28, 4, 18 }, /* Rome 2.1 */ > { 0x00000300, 28, 4, 18 }, /* Rome 3.0 */ > { 0x00000302, 28, 4, 18 }, /* Rome 3.2 */ > + { 0x00130100, 40, 4, 18 }, /* WCN6855 1.0 */ > + { 0x00130200, 40, 4, 18 } /* WCN6855 2.0 */ > }; > > static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request, > @@ -3529,8 +3556,8 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, > { > struct qca_rampatch_version *rver; > const struct firmware *fw; > - u32 ver_rom, ver_patch; > - u16 rver_rom, rver_patch; > + u32 ver_rom, ver_patch, rver_rom; > + u16 rver_rom_low, rver_rom_high, rver_patch; > char fwname[64]; > int err; > > @@ -3549,9 +3576,16 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, > bt_dev_info(hdev, "using rampatch file: %s", fwname); > > rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset); > - rver_rom = le16_to_cpu(rver->rom_version); > + rver_rom_low = le16_to_cpu(rver->rom_version); > rver_patch = le16_to_cpu(rver->patch_version); > > + if (ver_rom & ~0xffffU) { > + rver_rom_high = le16_to_cpu(*(__le16 *)(fw->data + 16)); > + rver_rom = le32_to_cpu(rver_rom_high << 16 | rver_rom_low); > + } else { > + rver_rom = (__force u32)rver_rom_low; > + } > + I don’t get this. Is anything wrong with get_unaligned_le32 etc.? My brain just hurts with your casting and pointer magic. Maybe the whole rver logic needs a clean up first. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wAfkDYh7X18VbgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 16:17:44 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8P/7CYh7X19ChQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 16:17:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ABC0E40017; Mon, 14 Sep 2020 16:17:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726515AbgINORb convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 10:17:31 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:53460 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbgINN02 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 09:26:28 -0400 Received: from marcel-macpro.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id DC189CECDD; Mon, 14 Sep 2020 15:32:44 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v1] Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <c177f408186da437db722d855a01c846@codeaurora.org> Date: Mon, 14 Sep 2020 15:25:47 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, open list <linux-kernel@vger.kernel.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, MSM <linux-arm-msm@vger.kernel.org>, Balakrishna Godavarthi <bgodavar@codeaurora.org>, c-hbandi@codeaurora.org, Hemantg <hemantg@codeaurora.org>, mka@chromium.org, linux-bluetooth-owner@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <0C779191-3BD1-40BF-83E6-733F9C78EA03@holtmann.org> References: <0101017457c6b810-cb8b79ae-4663-436b-83d0-4c70c245bd25-000000@us-west-2.amazonses.com> <2E48211B-D62D-43D8-9C97-014966FBB2CB@holtmann.org> <c177f408186da437db722d855a01c846@codeaurora.org> To: Rocky Liao <rjliao@codeaurora.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.66 / 15.00 / 15.00 X-Rspamd-Queue-Id: ABC0E40017 X-Rspamd-UID: f5e31b Hi Rocky, >>> This patch add support for WCN6855 i.e. patch and nvm download >>> support. >>> Signed-off-by: Rocky Liao <rjliao@codeaurora.org> >>> --- >>> drivers/bluetooth/btusb.c | 42 +++++++++++++++++++++++++++++++++++---- >>> 1 file changed, 38 insertions(+), 4 deletions(-) >>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c >>> index fe80588c7bd3..e51e754ca9b8 100644 >>> --- a/drivers/bluetooth/btusb.c >>> +++ b/drivers/bluetooth/btusb.c >>> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver; >>> #define BTUSB_MEDIATEK 0x200000 >>> #define BTUSB_WIDEBAND_SPEECH 0x400000 >>> #define BTUSB_VALID_LE_STATES 0x800000 >>> +#define BTUSB_QCA_WCN6855 0x1000000 >>> static const struct usb_device_id btusb_table[] = { >>> /* Generic Bluetooth USB device */ >>> @@ -273,6 +274,10 @@ static const struct usb_device_id blacklist_table[] = { >>> { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME }, >>> { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME }, >>> + /* QCA WCN6855 chipset */ >>> + { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 | >>> + BTUSB_WIDEBAND_SPEECH }, >>> + >>> /* Broadcom BCM2035 */ >>> { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, >>> { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU }, >>> @@ -3391,6 +3396,26 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev, >>> return 0; >>> } >>> +static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev, >>> + const bdaddr_t *bdaddr) >>> +{ >>> + struct sk_buff *skb; >>> + u8 buf[6]; >>> + long ret; >>> + >>> + memcpy(buf, bdaddr, sizeof(bdaddr_t)); >>> + >>> + skb = __hci_cmd_sync(hdev, 0xfc14, sizeof(buf), buf, HCI_INIT_TIMEOUT); >>> + if (IS_ERR(skb)) { >>> + ret = PTR_ERR(skb); >>> + bt_dev_err(hdev, "Change address command failed (%ld)", ret); >>> + return ret; >>> + } >>> + kfree_skb(skb); >>> + >>> + return 0; >>> +} >> What is wrong with using qca_set_bdaddr() function. > WCN6855 is using different VSC to set the bt addr int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) { struct sk_buff *skb; int err; skb = __hci_cmd_sync_ev(hdev, EDL_WRITE_BD_ADDR_OPCODE, 6, bdaddr, HCI_EV_VENDOR, HCI_INIT_TIMEOUT); if (IS_ERR(skb)) { err = PTR_ERR(skb); bt_dev_err(hdev, "QCA Change address cmd failed (%d)", err); return err; } kfree_skb(skb); return 0; } EXPORT_SYMBOL_GPL(qca_set_bdaddr); I see that the other command is using HCI_EV_VENDOR, but is that on purpose or an accident? Might want to confirm with the btmon trace. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cEHxKp17X1961gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 16:18:05 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6A4dKJ17X1+w1gAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 16:18:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D3CEEA0170; Mon, 14 Sep 2020 16:17:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726714AbgINORL (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 10:17:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbgINNZj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 09:25:39 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7491C06178A for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 06:25:39 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id x123so12627371pfc.7 for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 06:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2D93YQlVq3/F7NWnGdwtrXN5hz11APEKsPD3SeHWzpw=; b=IdrGKrX8iSl5vhvbBky4xLfFI/DFJDgxELSOu7RVLpjRbP0LQsGqSp0cCI/u69gG5i HeoCiCXvNIbyAGXZ9helnn1180JUI5PMMYmfh37RmkcTOF7fCNXSWUtW2t+REAti0Hrh srkT+GtLZxWYBp87Gvtd0plF9bpF7Xci4q1uu9vaWHAsUR0FWfZ/XciwFoZ6fYxgl0Lk DNLxwDFyk7zC1G/90NwZidaPerthi7I8ArQ3z4WOhoOjcl6ZJ7shZ5p+TeO3BZy+tqCR NfKCHezhBsNdKtp79wOu6EGcJWMWD6miTpZv55tC7ceU49mT51DBbBtwWLkF4J54mRn1 EfSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2D93YQlVq3/F7NWnGdwtrXN5hz11APEKsPD3SeHWzpw=; b=uTjrApBAkc3SzGblYmUfOjU/ECqxNgYvwAPX09HvU/+QNRlCMoEqfIHG1Dp/uEm4mo j246Yb+/+EGxtVrnpjImAPmMbikX0+FyAw+ceXP8IuB5VTAI+z+Nek0gXu0y3xzpPLFW Dr+4b7CJFvsk2RX+janovyr07ThtN1unex3D6+0wgEVcHfrs4l8B/Vm+cWpL02CvXRSg xcD6JD48HTw1prg1xTP9rRj4N2KdO//cAu2bhKpYZEXTH6nJwxFCS2UTzcByr5WirmcV 7T9llnbLLIx4O2Aj2Yu6jR44Edjz8f54T6JqHf5HAHO9Dai2rVWKFxMnkgm+cfAAab5g GFeg== X-Gm-Message-State: AOAM531x8SRJBb5KG/Bh9hOZDi91clWq+VC1vz7C/rH2CPW4hJKA99+2 KHleZGu5GdUrbBpzN5lteHet5/HDcGso4g== X-Google-Smtp-Source: ABdhPJxZYyAxhxf65G28vtUPOO2VXNhT/iUVIl6lcPPy+W7GFriVSRkbeTwW7HpypOJVYB736dP7ag== X-Received: by 2002:a63:806:: with SMTP id 6mr3675459pgi.71.1600089938553; Mon, 14 Sep 2020 06:25:38 -0700 (PDT) Received: from localhost.localdomain ([171.61.74.206]) by smtp.gmail.com with ESMTPSA id m20sm10776707pfa.115.2020.09.14.06.25.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 06:25:37 -0700 (PDT) From: Kiran K <kiraank@gmail.com> X-Google-Original-From: Kiran K <kiran.k@intel.com> To: linux-bluetooth@vger.kernel.org Cc: chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com, kiraank@gmail.com, Kiran K <kiran.k@intel.com>, Amit K Bag <amit.k.bag@intel.com>, Raghuram Hegde <raghuram.hegde@intel.com> Subject: [PATCH v1 1/2] Bluetooth: btintel: Add infrastructure to read controller information Date: Mon, 14 Sep 2020 18:55:05 +0530 Message-Id: <1600089906-9852-1-git-send-email-kiran.k@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.82 / 15.00 / 15.00 X-Rspamd-Queue-Id: D3CEEA0170 X-Rspamd-UID: d1a270 New generation Intel controllers returns version information in TLV format. This patch adds, 1) Enums, structures for TLV 2) function to read controller information, parse TLV data and populate intel_version_tlv structure 3) function to print version information Signed-off-by: Kiran K <kiran.k@intel.com> Signed-off-by: Amit K Bag <amit.k.bag@intel.com> Signed-off-by: Raghuram Hegde <raghuram.hegde@intel.com> Reviewed-by: Chethan T N <chethan.tumkur.narayan@intel.com> Reviewed-by: Srivatsa Ravishankar <ravishankar.srivatsa@intel.com> --- drivers/bluetooth/btintel.c | 138 ++++++++++++++++++++++++++++++++++++++++++++ drivers/bluetooth/btintel.h | 79 +++++++++++++++++++++++++ 2 files changed, 217 insertions(+) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index dc6f1a9..e99fc6e 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -361,6 +361,144 @@ int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver) } EXPORT_SYMBOL_GPL(btintel_read_version); +void btintel_version_info_tlv(struct hci_dev *hdev, struct intel_version_tlv *version) +{ + const char *variant; + + switch (version->img_type) { + case 0x01: + variant = "Bootloader"; + bt_dev_info(hdev, "Device revision is %u", version->dev_rev_id); + bt_dev_info(hdev, "Secure boot is %s", + version->secure_boot ? "enabled" : "disabled"); + bt_dev_info(hdev, "OTP lock is %s", + version->otp_lock ? "enabled" : "disabled"); + bt_dev_info(hdev, "API lock is %s", + version->api_lock ? "enabled" : "disabled"); + bt_dev_info(hdev, "Debug lock is %s", + version->debug_lock ? "enabled" : "disabled"); + bt_dev_info(hdev, "Minimum firmware build %u week %u %u", + version->min_fw_build_nn, version->min_fw_build_cw, + 2000 + version->min_fw_build_yy); + break; + case 0x03: + variant = "Firmware"; + break; + default: + bt_dev_err(hdev, "Unsupported image type(%02x)", version->img_type); + goto done; + } + + bt_dev_info(hdev, "%s timestamp %u.%u buildtype %u build %u", variant, + 2000 + (version->timestamp >> 8), version->timestamp & 0xff, + version->build_type, version->build_num); + +done: + return; +} +EXPORT_SYMBOL_GPL(btintel_version_info_tlv); + +int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *version) +{ + struct sk_buff *skb; + const u8 param[1] = { 0xFF }; + + if (!version) + return -EINVAL; + + skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Reading Intel version information failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + + if (skb->data[0]) { + bt_dev_err(hdev, "Intel Read Version command failed (%02x)", + skb->data[0]); + kfree_skb(skb); + return -EIO; + } + + /* Consume Command Complete Status field */ + skb_pull(skb, 1); + + /* Event parameters contatin multiple TLVs. Read each of them + * and only keep the required data. Also, it use existing legacy + * version field like hw_platform, hw_variant, and fw_variant + * to keep the existing setup flow + */ + while (skb->len) { + struct intel_tlv *tlv; + + tlv = (struct intel_tlv *)skb->data; + switch (tlv->type) { + case INTEL_TLV_CNVI_TOP: + version->cnvi_top = get_unaligned_le32(tlv->val); + break; + case INTEL_TLV_CNVR_TOP: + version->cnvr_top = get_unaligned_le32(tlv->val); + break; + case INTEL_TLV_CNVI_BT: + version->cnvi_bt = get_unaligned_le32(tlv->val); + break; + case INTEL_TLV_CNVR_BT: + version->cnvr_bt = get_unaligned_le32(tlv->val); + break; + case INTEL_TLV_DEV_REV_ID: + version->dev_rev_id = get_unaligned_le16(tlv->val); + break; + case INTEL_TLV_IMAGE_TYPE: + version->img_type = tlv->val[0]; + break; + case INTEL_TLV_TIME_STAMP: + version->timestamp = get_unaligned_le16(tlv->val); + break; + case INTEL_TLV_BUILD_TYPE: + version->build_type = tlv->val[0]; + break; + case INTEL_TLV_BUILD_NUM: + version->build_num = get_unaligned_le32(tlv->val); + break; + case INTEL_TLV_SECURE_BOOT: + version->secure_boot = tlv->val[0]; + break; + case INTEL_TLV_OTP_LOCK: + version->otp_lock = tlv->val[0]; + break; + case INTEL_TLV_API_LOCK: + version->api_lock = tlv->val[0]; + break; + case INTEL_TLV_DEBUG_LOCK: + version->debug_lock = tlv->val[0]; + break; + case INTEL_TLV_MIN_FW: + version->min_fw_build_nn = tlv->val[0]; + version->min_fw_build_cw = tlv->val[1]; + version->min_fw_build_yy = tlv->val[2]; + break; + case INTEL_TLV_LIMITED_CCE: + version->limited_cce = tlv->val[0]; + break; + case INTEL_TLV_SBE_TYPE: + version->sbe_type = tlv->val[0]; + break; + case INTEL_TLV_OTP_BDADDR: + memcpy(&version->otp_bd_addr, tlv->val, tlv->len); + break; + default: + /* Ignore rest of information */ + break; + } + /* consume the current tlv and move to next*/ + skb_pull(skb, tlv->len + sizeof(*tlv)); + } + + kfree_skb(skb); + return 0; +} +EXPORT_SYMBOL_GPL(btintel_read_version_tlv); + /* ------- REGMAP IBT SUPPORT ------- */ #define IBT_REG_MODE_8BIT 0x00 diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 08e2060..829e1fc 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -6,6 +6,72 @@ * Copyright (C) 2015 Intel Corporation */ +/* List of tlv type */ +enum { + INTEL_TLV_CNVI_TOP = 0x10, + INTEL_TLV_CNVR_TOP, + INTEL_TLV_CNVI_BT, + INTEL_TLV_CNVR_BT, + INTEL_TLV_CNVI_OTP, + INTEL_TLV_CNVR_OTP, + INTEL_TLV_DEV_REV_ID, + INTEL_TLV_USB_VENDOR_ID, + INTEL_TLV_USB_PRODUCT_ID, + INTEL_TLV_PCIE_VENDOR_ID, + INTEL_TLV_PCIE_DEVICE_ID, + INTEL_TLV_PCIE_SUBSYSTEM_ID, + INTEL_TLV_IMAGE_TYPE, + INTEL_TLV_TIME_STAMP, + INTEL_TLV_BUILD_TYPE, + INTEL_TLV_BUILD_NUM, + INTEL_TLV_FW_BUILD_PRODUCT, + INTEL_TLV_FW_BUILD_HW, + INTEL_TLV_FW_STEP, + INTEL_TLV_BT_SPEC, + INTEL_TLV_MFG_NAME, + INTEL_TLV_HCI_REV, + INTEL_TLV_LMP_SUBVER, + INTEL_TLV_OTP_PATCH_VER, + INTEL_TLV_SECURE_BOOT, + INTEL_TLV_KEY_FROM_HDR, + INTEL_TLV_OTP_LOCK, + INTEL_TLV_API_LOCK, + INTEL_TLV_DEBUG_LOCK, + INTEL_TLV_MIN_FW, + INTEL_TLV_LIMITED_CCE, + INTEL_TLV_SBE_TYPE, + INTEL_TLV_OTP_BDADDR, + INTEL_TLV_UNLOCKED_STATE +}; + +struct intel_tlv { + u8 type; + u8 len; + u8 val[0]; +} __packed; + +struct intel_version_tlv { + u32 cnvi_top; + u32 cnvr_top; + u32 cnvi_bt; + u32 cnvr_bt; + u16 dev_rev_id; + u8 img_type; + u16 timestamp; + u8 build_type; + u32 build_num; + u8 secure_boot; + u8 otp_lock; + u8 api_lock; + u8 debug_lock; + u8 min_fw_build_nn; + u8 min_fw_build_cw; + u8 min_fw_build_yy; + u8 limited_cce; + u8 sbe_type; + bdaddr_t otp_bd_addr; +}; + struct intel_version { u8 status; u8 hw_platform; @@ -77,12 +143,14 @@ int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable); void btintel_hw_error(struct hci_dev *hdev, u8 code); void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver); +void btintel_version_info_tlv(struct hci_dev *hdev, struct intel_version_tlv *version); int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen, const void *param); int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name); int btintel_set_event_mask(struct hci_dev *hdev, bool debug); int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug); int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver); +int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *ver); struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read, u16 opcode_write); @@ -137,6 +205,11 @@ static inline void btintel_version_info(struct hci_dev *hdev, { } +static inline void btintel_version_info_tlv(struct hci_dev *hdev, + struct intel_version_tlv *version) +{ +} + static inline int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen, const void *param) { @@ -165,6 +238,12 @@ static inline int btintel_read_version(struct hci_dev *hdev, return -EOPNOTSUPP; } +static inline int btintel_read_version_tlv(struct hci_dev *hdev, + struct intel_version_tlv *ver) +{ + return -EOPNOTSUPP; +} + static inline struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read, u16 opcode_write) -- 2.7.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4I7WLRWLX18zyQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 17:24:05 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id sEJ/KRWLX1+BFwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 17:24:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DEAF640942; Mon, 14 Sep 2020 17:23:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726168AbgINPXq (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 11:23:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:38582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgINPXL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:23:11 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2BE5B20639; Mon, 14 Sep 2020 15:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600096990; bh=EBqqQRsDxhvM1nw92/w69eMe9mZazFwm//Ofb5xCjvc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NhxFEZ5hFRzKcHM5UdRESvNf5RWMR93f2OaogAsqv4akh7DGDkhvKhkLXVh3XCM0k bsyO24n6WDGAe+S0tayv+05GZAfma4r1iry3NA2mq4riIC66xgJYRRiAOYGhZ3L7Wk KZNptsHILBCJ9AFv6G0mXT/Pfdx9wAbjVpWcRzH4= Date: Mon, 14 Sep 2020 17:23:09 +0200 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: Alan Stern <stern@rowland.harvard.edu> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH v2 04/11] USB: core: hub.c: use usb_control_msg_send() in a few places Message-ID: <20200914152309.GA3394411@kroah.com> References: <20200907145108.3766613-1-gregkh@linuxfoundation.org> <20200907145108.3766613-5-gregkh@linuxfoundation.org> <20200907150858.GD762136@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200907150858.GD762136@rowland.harvard.edu> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.14 / 15.00 / 15.00 X-Rspamd-Queue-Id: DEAF640942 X-Rspamd-UID: dd11d1 On Mon, Sep 07, 2020 at 11:08:58AM -0400, Alan Stern wrote: > On Mon, Sep 07, 2020 at 04:51:01PM +0200, Greg Kroah-Hartman wrote: > > There are a few calls to usb_control_msg() that can be converted to use > > usb_control_msg_send() instead, so do that in order to make the error > > checking a bit simpler and the code smaller. > > > > Cc: Alan Stern <stern@rowland.harvard.edu> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > --- > > v2: > > - dropped changes to usb_req_set_sel() thanks to review from Alan > > > @@ -4056,7 +4035,7 @@ static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev, > > * associated with the link state we're about to enable. > > */ > > ret = usb_req_set_sel(udev, state); > > - if (ret < 0) { > > + if (ret) { > > dev_warn(&udev->dev, "Set SEL for device-initiated %s failed.\n", > > usb3_lpm_names[state]); > > return; > > Did this change survive by mistake? > > Actually, it looks like usb_req_set_sel needs to check the value > returned by usb_control_msg -- a perfect example of the sort of thing > you were trying to fix in the first place! Ugh, good catch, and yes, the original code is buggy :) thanks, greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UKvwLCicX1999QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 18:36:56 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id wJKNKSicX19pwgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 18:36:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 13B914096E; Mon, 14 Sep 2020 18:36:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726379AbgINQd7 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 12:33:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:47812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726055AbgINPiQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:16 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC67C208DB; Mon, 14 Sep 2020 15:38:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097892; bh=K8GDmgIFok61DBUhIpFd8GKKp/6PoQOtGoTpJAfvjV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f8A/tP09/VdJtaE+8mhb6hj4aJFUw7hWS4RjTJvFMbVRTV5DlQoZSeJ/dbIyjjK6P otm4FHhaHt6yHc8pfIbd0RU0UCXy1svPu77Xkmmpo7xGIg1W+cIY1YOaIUF32oqnhW wz1S8q3dSA8dQD+UQq7ICE8A2tAgWVYdTZ+JU19w= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH v3 02/11] USB: add usb_control_msg_send() and usb_control_msg_recv() Date: Mon, 14 Sep 2020 17:37:47 +0200 Message-Id: <20200914153756.3412156-3-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914153756.3412156-1-gregkh@linuxfoundation.org> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: 13B914096E X-Rspamd-UID: ad2514 New core functions to make sending/receiving USB control messages easier and saner. In discussions, it turns out that the large majority of users of usb_control_msg() do so in potentially incorrect ways. The most common issue is where a "short" message is received, yet never detected properly due to "incorrect" error handling. Handle all of this in the USB core with two new functions to try to make working with USB control messages simpler. No more need for dynamic data, messages can be on the stack, and only "complete" send/receive will work without causing an error. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v3: - no change from v2 v2: - no change from v1 drivers/usb/core/message.c | 133 +++++++++++++++++++++++++++++++++++++ include/linux/usb.h | 6 ++ 2 files changed, 139 insertions(+) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index ae1de9cc4b09..1dc53b12a26a 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -162,6 +162,139 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, } EXPORT_SYMBOL_GPL(usb_control_msg); +/** + * usb_control_msg_send - Builds a control "send" message, sends it off and waits for completion + * @dev: pointer to the usb device to send the message to + * @endpoint: endpoint to send the message to + * @request: USB message request value + * @requesttype: USB message request type value + * @value: USB message value + * @index: USB message index value + * @driver_data: pointer to the data to send + * @size: length in bytes of the data to send + * @timeout: time in msecs to wait for the message to complete before timing + * out (if 0 the wait is forever) + * + * Context: !in_interrupt () + * + * This function sends a control message to a specified endpoint that is not + * expected to fill in a response (i.e. a "send message") and waits for the + * message to complete, or timeout. + * + * Do not use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb(). If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. + * + * The data pointer can be made to a reference on the stack, or anywhere else, + * as it will not be modified at all. This does not have the restriction that + * usb_control_msg() has where the data pointer must be to dynamically allocated + * memory (i.e. memory that can be successfully DMAed to a device). + * + * Return: If successful, 0 is returned, Otherwise, a negative error number. + */ +int usb_control_msg_send(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + const void *driver_data, __u16 size, int timeout) +{ + unsigned int pipe = usb_sndctrlpipe(dev, endpoint); + int ret; + u8 *data = NULL; + + if (usb_pipe_type_check(dev, pipe)) + return -EINVAL; + + if (size) { + data = kmemdup(driver_data, size, GFP_KERNEL); + if (!data) + return -ENOMEM; + } + + ret = usb_control_msg(dev, pipe, request, requesttype, value, index, + data, size, timeout); + kfree(data); + + if (ret < 0) + return ret; + if (ret == size) + return 0; + return -EINVAL; +} +EXPORT_SYMBOL_GPL(usb_control_msg_send); + +/** + * usb_control_msg_recv - Builds a control "receive" message, sends it off and waits for completion + * @dev: pointer to the usb device to send the message to + * @endpoint: endpoint to send the message to + * @request: USB message request value + * @requesttype: USB message request type value + * @value: USB message value + * @index: USB message index value + * @driver_data: pointer to the data to be filled in by the message + * @size: length in bytes of the data to be received + * @timeout: time in msecs to wait for the message to complete before timing + * out (if 0 the wait is forever) + * + * Context: !in_interrupt () + * + * This function sends a control message to a specified endpoint that is + * expected to fill in a response (i.e. a "receive message") and waits for the + * message to complete, or timeout. + * + * Do not use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb(). If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. + * + * The data pointer can be made to a reference on the stack, or anywhere else + * that can be successfully written to. This function does not have the + * restriction that usb_control_msg() has where the data pointer must be to + * dynamically allocated memory (i.e. memory that can be successfully DMAed to a + * device). + * + * The "whole" message must be properly received from the device in order for + * this function to be successful. If a device returns less than the expected + * amount of data, then the function will fail. Do not use this for messages + * where a variable amount of data might be returned. + * + * Return: If successful, 0 is returned, Otherwise, a negative error number. + */ +int usb_control_msg_recv(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + void *driver_data, __u16 size, int timeout) +{ + unsigned int pipe = usb_rcvctrlpipe(dev, endpoint); + int ret; + u8 *data; + + if (!size || !driver_data || usb_pipe_type_check(dev, pipe)) + return -EINVAL; + + data = kmalloc(size, GFP_KERNEL); + if (!data) + return -ENOMEM; + + ret = usb_control_msg(dev, pipe, request, requesttype, value, index, + data, size, timeout); + + if (ret < 0) + goto exit; + + if (ret == size) { + memcpy(driver_data, data, size); + ret = 0; + } else { + ret = -EINVAL; + } + +exit: + kfree(data); + return ret; +} +EXPORT_SYMBOL_GPL(usb_control_msg_recv); + /** * usb_interrupt_msg - Builds an interrupt urb, sends it off and waits for completion * @usb_dev: pointer to the usb device to send the message to diff --git a/include/linux/usb.h b/include/linux/usb.h index 0b3963d7ec38..a5460f08126e 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1802,6 +1802,12 @@ extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, int timeout); /* wrappers around usb_control_msg() for the most common standard requests */ +int usb_control_msg_send(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + const void *data, __u16 size, int timeout); +int usb_control_msg_recv(struct usb_device *dev, __u8 endpoint, __u8 request, + __u8 requesttype, __u16 value, __u16 index, + void *data, __u16 size, int timeout); extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype, unsigned char descindex, void *buf, int size); extern int usb_get_status(struct usb_device *dev, -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qAyIBFKcX1/tzAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 18:37:38 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id EDC0AVKcX1+MoQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 18:37:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 40BACA0170; Mon, 14 Sep 2020 18:37:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726116AbgINQh2 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 12:37:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:47716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbgINPiQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:16 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 460A0217BA; Mon, 14 Sep 2020 15:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097886; bh=Lac+oh0BmkC+rJKg3GvLrnq3erNRzPkU1hCh3fX7DZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s+qqpD6SUDjRr4uC3qrwB0h4mkyNZeQPS3scNncX7vvfUHm1q8c2CW7jqWlWvlYkO hDoFChKszsshTdleYvOk/xbGGFuFTdKRfvmDTR/tquWqXrONldN7SDiMYV+eF8hW5A dPCeqVoBJDL+RgdgfxR2GShvIVfJ6Kzz5lhVOubw= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH v3 10/11] Bluetooth: ath3k: use usb_control_msg_send() and usb_control_msg_recv() Date: Mon, 14 Sep 2020 17:37:55 +0200 Message-Id: <20200914153756.3412156-11-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914153756.3412156-1-gregkh@linuxfoundation.org> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: 40BACA0170 X-Rspamd-UID: 6907c2 The usb_control_msg_send() and usb_control_msg_recv() calls can return an error if a "short" write/read happens, and they can handle data off of the stack, so move the driver over to using those calls instead, saving some logic when dynamically allocating memory. Cc: Marcel Holtmann <marcel@holtmann.org> Cc: Johan Hedberg <johan.hedberg@gmail.com> Cc: linux-bluetooth@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v3: - no change from v2 v2: - no change from v1 drivers/bluetooth/ath3k.c | 90 +++++++++++---------------------------- 1 file changed, 26 insertions(+), 64 deletions(-) diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index 4ce270513695..1472cccfd0b3 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c @@ -212,19 +212,16 @@ static int ath3k_load_firmware(struct usb_device *udev, BT_DBG("udev %p", udev); - pipe = usb_sndctrlpipe(udev, 0); - send_buf = kmalloc(BULK_SIZE, GFP_KERNEL); if (!send_buf) { BT_ERR("Can't allocate memory chunk for firmware"); return -ENOMEM; } - memcpy(send_buf, firmware->data, FW_HDR_SIZE); - err = usb_control_msg(udev, pipe, USB_REQ_DFU_DNLOAD, USB_TYPE_VENDOR, - 0, 0, send_buf, FW_HDR_SIZE, - USB_CTRL_SET_TIMEOUT); - if (err < 0) { + err = usb_control_msg_send(udev, 0, USB_REQ_DFU_DNLOAD, USB_TYPE_VENDOR, + 0, 0, firmware->data, FW_HDR_SIZE, + USB_CTRL_SET_TIMEOUT); + if (err) { BT_ERR("Can't change to loading configuration err"); goto error; } @@ -259,44 +256,17 @@ static int ath3k_load_firmware(struct usb_device *udev, static int ath3k_get_state(struct usb_device *udev, unsigned char *state) { - int ret, pipe = 0; - char *buf; - - buf = kmalloc(sizeof(*buf), GFP_KERNEL); - if (!buf) - return -ENOMEM; - - pipe = usb_rcvctrlpipe(udev, 0); - ret = usb_control_msg(udev, pipe, ATH3K_GETSTATE, - USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, - buf, sizeof(*buf), USB_CTRL_SET_TIMEOUT); - - *state = *buf; - kfree(buf); - - return ret; + return usb_control_msg_recv(udev, 0, ATH3K_GETSTATE, + USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, + state, 1, USB_CTRL_SET_TIMEOUT); } static int ath3k_get_version(struct usb_device *udev, struct ath3k_version *version) { - int ret, pipe = 0; - struct ath3k_version *buf; - const int size = sizeof(*buf); - - buf = kmalloc(size, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - pipe = usb_rcvctrlpipe(udev, 0); - ret = usb_control_msg(udev, pipe, ATH3K_GETVERSION, - USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, - buf, size, USB_CTRL_SET_TIMEOUT); - - memcpy(version, buf, size); - kfree(buf); - - return ret; + return usb_control_msg_recv(udev, 0, ATH3K_GETVERSION, + USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, + version, sizeof(*version), USB_CTRL_SET_TIMEOUT); } static int ath3k_load_fwfile(struct usb_device *udev, @@ -316,13 +286,10 @@ static int ath3k_load_fwfile(struct usb_device *udev, } size = min_t(uint, count, FW_HDR_SIZE); - memcpy(send_buf, firmware->data, size); - pipe = usb_sndctrlpipe(udev, 0); - ret = usb_control_msg(udev, pipe, ATH3K_DNLOAD, - USB_TYPE_VENDOR, 0, 0, send_buf, - size, USB_CTRL_SET_TIMEOUT); - if (ret < 0) { + ret = usb_control_msg_send(udev, 0, ATH3K_DNLOAD, USB_TYPE_VENDOR, 0, 0, + firmware->data, size, USB_CTRL_SET_TIMEOUT); + if (ret) { BT_ERR("Can't change to loading configuration err"); kfree(send_buf); return ret; @@ -355,23 +322,19 @@ static int ath3k_load_fwfile(struct usb_device *udev, return 0; } -static int ath3k_switch_pid(struct usb_device *udev) +static void ath3k_switch_pid(struct usb_device *udev) { - int pipe = 0; - - pipe = usb_sndctrlpipe(udev, 0); - return usb_control_msg(udev, pipe, USB_REG_SWITCH_VID_PID, - USB_TYPE_VENDOR, 0, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); + usb_control_msg_send(udev, 0, USB_REG_SWITCH_VID_PID, USB_TYPE_VENDOR, + 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } static int ath3k_set_normal_mode(struct usb_device *udev) { unsigned char fw_state; - int pipe = 0, ret; + int ret; ret = ath3k_get_state(udev, &fw_state); - if (ret < 0) { + if (ret) { BT_ERR("Can't get state to change to normal mode err"); return ret; } @@ -381,10 +344,9 @@ static int ath3k_set_normal_mode(struct usb_device *udev) return 0; } - pipe = usb_sndctrlpipe(udev, 0); - return usb_control_msg(udev, pipe, ATH3K_SET_NORMAL_MODE, - USB_TYPE_VENDOR, 0, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, ATH3K_SET_NORMAL_MODE, + USB_TYPE_VENDOR, 0, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); } static int ath3k_load_patch(struct usb_device *udev) @@ -397,7 +359,7 @@ static int ath3k_load_patch(struct usb_device *udev) int ret; ret = ath3k_get_state(udev, &fw_state); - if (ret < 0) { + if (ret) { BT_ERR("Can't get state to change to load ram patch err"); return ret; } @@ -408,7 +370,7 @@ static int ath3k_load_patch(struct usb_device *udev) } ret = ath3k_get_version(udev, &fw_version); - if (ret < 0) { + if (ret) { BT_ERR("Can't get version to change to load ram patch err"); return ret; } @@ -449,13 +411,13 @@ static int ath3k_load_syscfg(struct usb_device *udev) int clk_value, ret; ret = ath3k_get_state(udev, &fw_state); - if (ret < 0) { + if (ret) { BT_ERR("Can't get state to change to load configuration err"); return -EBUSY; } ret = ath3k_get_version(udev, &fw_version); - if (ret < 0) { + if (ret) { BT_ERR("Can't get version to change to load ram patch err"); return ret; } @@ -529,7 +491,7 @@ static int ath3k_probe(struct usb_interface *intf, return ret; } ret = ath3k_set_normal_mode(udev); - if (ret < 0) { + if (ret) { BT_ERR("Set normal mode failed"); return ret; } -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EIM9FrqOX18zyQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 17:39:38 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id IO2sE7qOX18GMAEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 17:39:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2FD984086A; Mon, 14 Sep 2020 17:39:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726411AbgINPis (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 11:38:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:48286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726378AbgINPij (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:39 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F421F221E7; Mon, 14 Sep 2020 15:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097901; bh=/066gaXTRI/JoOta71UI68G+5ZR5XUo8+Ltf/2wY7Ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MycOoNW+ObWwBb5aQUDT+pAaKqtZxPcFaWtw76k/Gx3CrTRmodhyFG+S3Re5wLckQ aQWyJqsubww1/5832drCVnoMS6ddhoAfRuyImw5U2S7v62FpnpqYAuutczgilYKCnO fwMexSfJ6tqdsPbXGQwKkFy8W1dMhxrnMpmz+9JI= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Takashi Iwai <tiwai@suse.de> Subject: [PATCH v3 06/11] sound: usx2y: move to use usb_control_msg_send() Date: Mon, 14 Sep 2020 17:37:51 +0200 Message-Id: <20200914153756.3412156-7-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914153756.3412156-1-gregkh@linuxfoundation.org> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.30 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2FD984086A X-Rspamd-UID: 77d23c The usb_control_msg_send() call can handle data on the stack, as well as returning an error if a "short" write happens, so move the driver over to using that call instead. This ends up removing a helper function that is no longer needed. Cc: Jaroslav Kysela <perex@perex.cz> Cc: alsa-devel@alsa-project.org Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v3: - minor changes requested by checkpatch.pl v2: - Added reviewed-by from Takashi sound/usb/usx2y/us122l.c | 42 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index f86f7a61fb36..6d35303b0948 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -82,40 +82,13 @@ static int us144_create_usbmidi(struct snd_card *card) &US122L(card)->midi_list, &quirk); } -/* - * Wrapper for usb_control_msg(). - * Allocates a temp buffer to prevent dmaing from/to the stack. - */ -static int us122l_ctl_msg(struct usb_device *dev, unsigned int pipe, - __u8 request, __u8 requesttype, - __u16 value, __u16 index, void *data, - __u16 size, int timeout) -{ - int err; - void *buf = NULL; - - if (size > 0) { - buf = kmemdup(data, size, GFP_KERNEL); - if (!buf) - return -ENOMEM; - } - err = usb_control_msg(dev, pipe, request, requesttype, - value, index, buf, size, timeout); - if (size > 0) { - memcpy(data, buf, size); - kfree(buf); - } - return err; -} - static void pt_info_set(struct usb_device *dev, u8 v) { int ret; - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - 'I', - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - v, 0, NULL, 0, 1000); + ret = usb_control_msg_send(dev, 0, 'I', + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + v, 0, NULL, 0, 1000); snd_printdd(KERN_DEBUG "%i\n", ret); } @@ -305,10 +278,11 @@ static int us122l_set_sample_rate(struct usb_device *dev, int rate) data[0] = rate; data[1] = rate >> 8; data[2] = rate >> 16; - err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, - USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, - UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000); - if (err < 0) + err = usb_control_msg_send(dev, 0, UAC_SET_CUR, + USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT, + UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, + 1000); + if (err) snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n", dev->devnum, rate, ep); return err; -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MFVeDc6OX18AcgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 17:39:58 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SMJyCs6OX1/5kwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 17:39:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 63B50A0B2C; Mon, 14 Sep 2020 17:39:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726450AbgINPjr (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 11:39:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:48290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726379AbgINPik (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:40 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 39577221E8; Mon, 14 Sep 2020 15:38:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097903; bh=ZF6e8qPp/x3cgiilsgfoCgjGrTbb3zvBv90RHrPV+xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=slOTrpDgeHjQbWkHqV4jrt+Wl87Mpt9WiyvTGUvE3nwYjwvIJhBuF+Tmgb3oKkZWt Y9v5C6qorLQEPWlS5MmGgEyKRsXDX8KyjqOnIaFvWb9h6uwdlRNETi+mx3ZQimhZca rji9N8mMnksjjNs6soNvXHdAHCmED+6rI4UUf5tQ= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Takashi Iwai <tiwai@suse.de> Subject: [PATCH v3 07/11] sound: 6fire: move to use usb_control_msg_send() and usb_control_msg_recv() Date: Mon, 14 Sep 2020 17:37:52 +0200 Message-Id: <20200914153756.3412156-8-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914153756.3412156-1-gregkh@linuxfoundation.org> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.08 / 15.00 / 15.00 X-Rspamd-Queue-Id: 63B50A0B2C X-Rspamd-UID: 6e44dd The usb_control_msg_send() and usb_control_msg_recv() calls can return an error if a "short" write/read happens, so move the driver over to using those calls instead, saving some logic in the wrapper functions that were being used in this driver. This also resolves a long-staging bug where data on the stack was being sent in a USB control message, which was not allowed. Cc: Jaroslav Kysela <perex@perex.cz> Cc: alsa-devel@alsa-project.org Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v3: - no change from v2 v2: - Added reviewed-by from Takashi sound/usb/6fire/firmware.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c index 69137c14d0dc..5b8994070c96 100644 --- a/sound/usb/6fire/firmware.c +++ b/sound/usb/6fire/firmware.c @@ -158,29 +158,17 @@ static int usb6fire_fw_ihex_init(const struct firmware *fw, static int usb6fire_fw_ezusb_write(struct usb_device *device, int type, int value, char *data, int len) { - int ret; - - ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), type, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - value, 0, data, len, HZ); - if (ret < 0) - return ret; - else if (ret != len) - return -EIO; - return 0; + return usb_control_msg_send(device, 0, type, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + value, 0, data, len, HZ); } static int usb6fire_fw_ezusb_read(struct usb_device *device, int type, int value, char *data, int len) { - int ret = usb_control_msg(device, usb_rcvctrlpipe(device, 0), type, - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, - 0, data, len, HZ); - if (ret < 0) - return ret; - else if (ret != len) - return -EIO; - return 0; + return usb_control_msg_recv(device, 0, type, + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + value, 0, data, len, HZ); } static int usb6fire_fw_fpga_write(struct usb_device *device, @@ -230,7 +218,7 @@ static int usb6fire_fw_ezusb_upload( /* upload firmware image */ data = 0x01; /* stop ezusb cpu */ ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1); - if (ret < 0) { + if (ret) { kfree(rec); release_firmware(fw); dev_err(&intf->dev, @@ -242,7 +230,7 @@ static int usb6fire_fw_ezusb_upload( while (usb6fire_fw_ihex_next_record(rec)) { /* write firmware */ ret = usb6fire_fw_ezusb_write(device, 0xa0, rec->address, rec->data, rec->len); - if (ret < 0) { + if (ret) { kfree(rec); release_firmware(fw); dev_err(&intf->dev, @@ -257,7 +245,7 @@ static int usb6fire_fw_ezusb_upload( if (postdata) { /* write data after firmware has been uploaded */ ret = usb6fire_fw_ezusb_write(device, 0xa0, postaddr, postdata, postlen); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to upload ezusb firmware %s: post urb.\n", fwname); @@ -267,7 +255,7 @@ static int usb6fire_fw_ezusb_upload( data = 0x00; /* resume ezusb cpu */ ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to upload ezusb firmware %s: end message.\n", fwname); @@ -302,7 +290,7 @@ static int usb6fire_fw_fpga_upload( end = fw->data + fw->size; ret = usb6fire_fw_ezusb_write(device, 8, 0, NULL, 0); - if (ret < 0) { + if (ret) { kfree(buffer); release_firmware(fw); dev_err(&intf->dev, @@ -327,7 +315,7 @@ static int usb6fire_fw_fpga_upload( kfree(buffer); ret = usb6fire_fw_ezusb_write(device, 9, 0, NULL, 0); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to upload fpga firmware: end urb.\n"); return ret; @@ -363,7 +351,7 @@ int usb6fire_fw_init(struct usb_interface *intf) u8 buffer[12]; ret = usb6fire_fw_ezusb_read(device, 1, 0, buffer, 8); - if (ret < 0) { + if (ret) { dev_err(&intf->dev, "unable to receive device firmware state.\n"); return ret; -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0Dl0DpCPX18zyQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 17:43:12 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UAlaC5CPX183FQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 17:43:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 20C25A0B1A; Mon, 14 Sep 2020 17:43:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726486AbgINPm4 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 11:42:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:48034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbgINPik (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:40 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB91322204; Mon, 14 Sep 2020 15:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097908; bh=tGgg30b0UwGAiVeeMU334OIR6bWHk4P6xBpiFv81zpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lnWE3OQEG5NmPV6Q3zBx67lv6nmYQZgaDVZ68K1p7Fv13rDNI9D/au2COJEFfHxty LV8TMYWiHkYFQEcdCLd+zGnRfQIu31e3pOmzxi0wl8zvMyB/+eQzD8tjB+IiTZjjcZ nYXusKOZULgAsa/Sv40W8NCHgQFBzWxdnPxu8nbQ= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Takashi Iwai <tiwai@suse.de> Subject: [PATCH v3 09/11] sound: hiface: move to use usb_control_msg_send() Date: Mon, 14 Sep 2020 17:37:54 +0200 Message-Id: <20200914153756.3412156-10-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914153756.3412156-1-gregkh@linuxfoundation.org> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.08 / 15.00 / 15.00 X-Rspamd-Queue-Id: 20C25A0B1A X-Rspamd-UID: e5a8db The usb_control_msg_send() call can return an error if a "short" write happens, so move the driver over to using that call instead. Cc: Jaroslav Kysela <perex@perex.cz> Cc: alsa-devel@alsa-project.org Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v3: - no change from v2 v2: - Added reviewed-by from Takashi sound/usb/hiface/pcm.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sound/usb/hiface/pcm.c b/sound/usb/hiface/pcm.c index a148caa5f48e..f9c924e3964e 100644 --- a/sound/usb/hiface/pcm.c +++ b/sound/usb/hiface/pcm.c @@ -156,16 +156,14 @@ static int hiface_pcm_set_rate(struct pcm_runtime *rt, unsigned int rate) * This control message doesn't have any ack from the * other side */ - ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), - HIFACE_SET_RATE_REQUEST, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, - rate_value, 0, NULL, 0, 100); - if (ret < 0) { + ret = usb_control_msg_send(device, 0, + HIFACE_SET_RATE_REQUEST, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, + rate_value, 0, NULL, 0, 100); + if (ret) dev_err(&device->dev, "Error setting samplerate %d.\n", rate); - return ret; - } - return 0; + return ret; } static struct pcm_substream *hiface_pcm_get_substream(struct snd_pcm_substream -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QDjJBMiPX18zyQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 17:44:08 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id GEGqAciPX1/roQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 17:44:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4F2D0A0B50; Mon, 14 Sep 2020 17:44:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726478AbgINPm4 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 11:42:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:48294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbgINPik (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:40 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 96F76221F0; Mon, 14 Sep 2020 15:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097906; bh=9e9ZbvMGYk/Ejz0s9gld8mWLyBfUmNRh8gmdGNZ//Vw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WFV00sYPH5iGgMgQ1McSQ7D8AQH69Ut47xObQdZ5OVRKlLtMK/L3RiVy5XiPHTPx8 LhUw+tqv2+TB/TbU8aHYgasjMi9b4nWrlHxUyitVJkYbgpy/02ztqU+l40noTn8Wxk 85cSJqJ3o6Htt3anFz5qtG3o3oXXSjOEXryd4sjA= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Vasily Khoruzhick <anarsoul@gmail.com>, Takashi Iwai <tiwai@suse.de> Subject: [PATCH v3 08/11] sound: line6: move to use usb_control_msg_send() and usb_control_msg_recv() Date: Mon, 14 Sep 2020 17:37:53 +0200 Message-Id: <20200914153756.3412156-9-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914153756.3412156-1-gregkh@linuxfoundation.org> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.25 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4F2D0A0B50 X-Rspamd-UID: 3b0fc2 The usb_control_msg_send() and usb_control_msg_recv() calls can return an error if a "short" write/read happens, and they can handle data off of the stack, so move the driver over to using those calls instead, saving some logic when dynamically allocating memory. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Vasily Khoruzhick <anarsoul@gmail.com> Cc: alsa-devel@alsa-project.org Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v3: - no change from v2 v2: - Added reviewed-by from Takashi sound/usb/line6/driver.c | 69 +++++++++++++++----------------------- sound/usb/line6/podhd.c | 17 ++++------ sound/usb/line6/toneport.c | 8 ++--- 3 files changed, 37 insertions(+), 57 deletions(-) diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 60674ce4879b..601292c51491 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -337,23 +337,18 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, { struct usb_device *usbdev = line6->usbdev; int ret; - unsigned char *len; + u8 len; unsigned count; if (address > 0xffff || datalen > 0xff) return -EINVAL; - len = kmalloc(1, GFP_KERNEL); - if (!len) - return -ENOMEM; - /* query the serial number: */ - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - (datalen << 8) | 0x21, address, - NULL, 0, LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + (datalen << 8) | 0x21, address, NULL, 0, + LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "read request failed (error %d)\n", ret); goto exit; } @@ -362,45 +357,41 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data, for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { mdelay(LINE6_READ_WRITE_STATUS_DELAY); - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | - USB_DIR_IN, - 0x0012, 0x0000, len, 1, - LINE6_TIMEOUT * HZ); - if (ret < 0) { + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0012, 0x0000, &len, 1, + LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "receive length failed (error %d)\n", ret); goto exit; } - if (*len != 0xff) + if (len != 0xff) break; } ret = -EIO; - if (*len == 0xff) { + if (len == 0xff) { dev_err(line6->ifcdev, "read failed after %d retries\n", count); goto exit; - } else if (*len != datalen) { + } else if (len != datalen) { /* should be equal or something went wrong */ dev_err(line6->ifcdev, "length mismatch (expected %d, got %d)\n", - (int)datalen, (int)*len); + (int)datalen, len); goto exit; } /* receive the result: */ - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, - 0x0013, 0x0000, data, datalen, - LINE6_TIMEOUT * HZ); - - if (ret < 0) + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0013, 0x0000, data, datalen, LINE6_TIMEOUT * HZ); + if (ret) dev_err(line6->ifcdev, "read failed (error %d)\n", ret); exit: - kfree(len); return ret; } EXPORT_SYMBOL_GPL(line6_read_data); @@ -423,12 +414,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, if (!status) return -ENOMEM; - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - 0x0022, address, data, datalen, - LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + 0x0022, address, data, datalen, LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "write request failed (error %d)\n", ret); goto exit; @@ -437,14 +426,10 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data, for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { mdelay(LINE6_READ_WRITE_STATUS_DELAY); - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), - 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | - USB_DIR_IN, - 0x0012, 0x0000, - status, 1, LINE6_TIMEOUT * HZ); - - if (ret < 0) { + ret = usb_control_msg_recv(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0012, 0x0000, status, 1, LINE6_TIMEOUT * HZ); + if (ret) { dev_err(line6->ifcdev, "receiving status failed (error %d)\n", ret); goto exit; diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index eef45f7fef0d..a1261f55d62b 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -183,29 +183,25 @@ static const struct attribute_group podhd_dev_attr_group = { static int podhd_dev_start(struct usb_line6_podhd *pod) { int ret; - u8 *init_bytes; + u8 init_bytes[8]; int i; struct usb_device *usbdev = pod->line6.usbdev; - init_bytes = kmalloc(8, GFP_KERNEL); - if (!init_bytes) - return -ENOMEM; - - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), + ret = usb_control_msg_send(usbdev, 0, 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 0x11, 0, NULL, 0, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(pod->line6.ifcdev, "read request failed (error %d)\n", ret); goto exit; } /* NOTE: looks like some kind of ping message */ - ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, + ret = usb_control_msg_recv(usbdev, 0, 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 0x11, 0x0, init_bytes, 3, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(pod->line6.ifcdev, "receive length failed (error %d)\n", ret); goto exit; @@ -220,13 +216,12 @@ static int podhd_dev_start(struct usb_line6_podhd *pod) goto exit; } - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), + ret = usb_control_msg_send(usbdev, 0, USB_REQ_SET_FEATURE, USB_TYPE_STANDARD | USB_RECIP_DEVICE | USB_DIR_OUT, 1, 0, NULL, 0, LINE6_TIMEOUT * HZ); exit: - kfree(init_bytes); return ret; } diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 94dd5e7ab2e6..a9b56085b76a 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -126,11 +126,11 @@ static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2) { int ret; - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); + ret = usb_control_msg_send(usbdev, 0, 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); - if (ret < 0) { + if (ret) { dev_err(&usbdev->dev, "send failed (error %d)\n", ret); return ret; } -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QHNuFd+PX1+SfwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 17:44:31 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 2BpgEd+PX1/6oQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 17:44:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B556DA0B5B; Mon, 14 Sep 2020 17:44:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726358AbgINPmm (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 11:42:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:48288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbgINPik (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:40 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 73829221E2; Mon, 14 Sep 2020 15:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097899; bh=8To8b45SvPEq9MjkRfebDfExlpsyiXy6jdQvQm0TeRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pHj+R4/AbObwYmuIHLUXXsxSxegRFd5quurZJ3DrNmVXo7WC3oNs0dIYQcxbmkn3Y oHAn/ps1GWP5iiEeG0lSALtuEQkhPTBOVLilNqImZ5iACDVLply1UHN7nVCWdeIpBj s/I4n6qfc3XuZJRXZMrhGd7fbodIdmtLGeEUMFCw= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Juergen Stuber <starblue@users.sourceforge.net>, legousb-devel@lists.sourceforge.net Subject: [PATCH v3 05/11] USB: legousbtower: use usb_control_msg_recv() Date: Mon, 14 Sep 2020 17:37:50 +0200 Message-Id: <20200914153756.3412156-6-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914153756.3412156-1-gregkh@linuxfoundation.org> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.59 / 15.00 / 15.00 X-Rspamd-Queue-Id: B556DA0B5B X-Rspamd-UID: 4d53d2 The usb_control_msg_recv() function can handle data on the stack, as well as properly detecting short reads, so move to use that function instead of the older usb_control_msg() call. This ends up removing a lot of extra lines in the driver. Cc: Juergen Stuber <starblue@users.sourceforge.net> Cc: legousb-devel@lists.sourceforge.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v3: - no change from v2 v2: - no change from v1 drivers/usb/misc/legousbtower.c | 60 +++++++++++---------------------- 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index f922544056de..c3583df4c324 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -308,15 +308,9 @@ static int tower_open(struct inode *inode, struct file *file) int subminor; int retval = 0; struct usb_interface *interface; - struct tower_reset_reply *reset_reply; + struct tower_reset_reply reset_reply; int result; - reset_reply = kmalloc(sizeof(*reset_reply), GFP_KERNEL); - if (!reset_reply) { - retval = -ENOMEM; - goto exit; - } - nonseekable_open(inode, file); subminor = iminor(inode); @@ -347,15 +341,11 @@ static int tower_open(struct inode *inode, struct file *file) } /* reset the tower */ - result = usb_control_msg(dev->udev, - usb_rcvctrlpipe(dev->udev, 0), - LEGO_USB_TOWER_REQUEST_RESET, - USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, - 0, - 0, - reset_reply, - sizeof(*reset_reply), - 1000); + result = usb_control_msg_recv(dev->udev, 0, + LEGO_USB_TOWER_REQUEST_RESET, + USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, + 0, 0, + &reset_reply, sizeof(reset_reply), 1000); if (result < 0) { dev_err(&dev->udev->dev, "LEGO USB Tower reset control request failed\n"); @@ -394,7 +384,6 @@ static int tower_open(struct inode *inode, struct file *file) mutex_unlock(&dev->lock); exit: - kfree(reset_reply); return retval; } @@ -753,7 +742,7 @@ static int tower_probe(struct usb_interface *interface, const struct usb_device_ struct device *idev = &interface->dev; struct usb_device *udev = interface_to_usbdev(interface); struct lego_usb_tower *dev; - struct tower_get_version_reply *get_version_reply = NULL; + struct tower_get_version_reply get_version_reply; int retval = -ENOMEM; int result; @@ -798,34 +787,25 @@ static int tower_probe(struct usb_interface *interface, const struct usb_device_ dev->interrupt_in_interval = interrupt_in_interval ? interrupt_in_interval : dev->interrupt_in_endpoint->bInterval; dev->interrupt_out_interval = interrupt_out_interval ? interrupt_out_interval : dev->interrupt_out_endpoint->bInterval; - get_version_reply = kmalloc(sizeof(*get_version_reply), GFP_KERNEL); - if (!get_version_reply) { - retval = -ENOMEM; - goto error; - } - /* get the firmware version and log it */ - result = usb_control_msg(udev, - usb_rcvctrlpipe(udev, 0), - LEGO_USB_TOWER_REQUEST_GET_VERSION, - USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, - 0, - 0, - get_version_reply, - sizeof(*get_version_reply), - 1000); - if (result != sizeof(*get_version_reply)) { - if (result >= 0) - result = -EIO; + result = usb_control_msg_recv(udev, 0, + LEGO_USB_TOWER_REQUEST_GET_VERSION, + USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, + 0, + 0, + &get_version_reply, + sizeof(get_version_reply), + 1000); + if (!result) { dev_err(idev, "get version request failed: %d\n", result); retval = result; goto error; } dev_info(&interface->dev, "LEGO USB Tower firmware version is %d.%d build %d\n", - get_version_reply->major, - get_version_reply->minor, - le16_to_cpu(get_version_reply->build_no)); + get_version_reply.major, + get_version_reply.minor, + le16_to_cpu(get_version_reply.build_no)); /* we can register the device now, as it is ready */ usb_set_intfdata(interface, dev); @@ -844,11 +824,9 @@ static int tower_probe(struct usb_interface *interface, const struct usb_device_ USB_MAJOR, dev->minor); exit: - kfree(get_version_reply); return retval; error: - kfree(get_version_reply); tower_delete(dev); return retval; } -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6E/JDRGQX1/ykgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 17:45:21 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id wAq3ChGQX1+TGQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 17:45:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 16CF4A0B48; Mon, 14 Sep 2020 17:45:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726294AbgINPo5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 11:44:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:48034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbgINPiX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BB2BB21D1B; Mon, 14 Sep 2020 15:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097894; bh=CYH1CsDc34T5/TtGxDDRATTjQ8lmYfcbJULfT9sMhfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OO5CdqsX4I7wtBZYJAWDR7ATAHG4GgHsny6IA9UlBIgUXXkeKY6KUdkufxzkJgcD3 iJRCXa0q66paNHfIDTNMWgQoIMjfB1PP5gMUFsITSuCjjEd5Sqtq2rGsm3c79riJ1S GV3cRB75CKBRdjKtTTFjyutxxDcZ65xqetS/CeQQ= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Alan Stern <stern@rowland.harvard.edu>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH v3 03/11] USB: core: message.c: use usb_control_msg_send() in a few places Date: Mon, 14 Sep 2020 17:37:48 +0200 Message-Id: <20200914153756.3412156-4-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914153756.3412156-1-gregkh@linuxfoundation.org> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: 16CF4A0B48 X-Rspamd-UID: a99663 There are a few calls to usb_control_msg() that can be converted to use usb_control_msg_send() instead, so do that in order to make the error checking a bit simpler. Cc: Alan Stern <stern@rowland.harvard.edu> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: linux-usb@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v3: - Added Andy's Reviewed-by: v2: - no change from v1 drivers/usb/core/message.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 1dc53b12a26a..1580694e3b95 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1081,7 +1081,7 @@ int usb_set_isoch_delay(struct usb_device *dev) if (dev->speed < USB_SPEED_SUPER) return 0; - return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + return usb_control_msg_send(dev, 0, USB_REQ_SET_ISOCH_DELAY, USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, dev->hub_delay, 0, NULL, 0, @@ -1203,13 +1203,13 @@ int usb_clear_halt(struct usb_device *dev, int pipe) * (like some ibmcam model 1 units) seem to expect hosts to make * this request for iso endpoints, which can't halt! */ - result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, - USB_ENDPOINT_HALT, endp, NULL, 0, - USB_CTRL_SET_TIMEOUT); + result = usb_control_msg_send(dev, 0, + USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, + USB_ENDPOINT_HALT, endp, NULL, 0, + USB_CTRL_SET_TIMEOUT); /* don't un-halt or force to DATA0 except on success */ - if (result < 0) + if (result) return result; /* NOTE: seems like Microsoft and Apple don't bother verifying @@ -1571,9 +1571,10 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) if (dev->quirks & USB_QUIRK_NO_SET_INTF) ret = -EPIPE; else - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, - alternate, interface, NULL, 0, 5000); + ret = usb_control_msg_send(dev, 0, + USB_REQ_SET_INTERFACE, + USB_RECIP_INTERFACE, alternate, + interface, NULL, 0, 5000); /* 9.4.10 says devices don't need this and are free to STALL the * request if the interface only has one alternate setting. @@ -1583,7 +1584,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) "manual set_interface for iface %d, alt %d\n", interface, alternate); manual = 1; - } else if (ret < 0) { + } else if (ret) { /* Re-instate the old alt setting */ usb_hcd_alloc_bandwidth(dev, NULL, alt, iface->cur_altsetting); usb_enable_lpm(dev); @@ -1707,11 +1708,10 @@ int usb_reset_configuration(struct usb_device *dev) mutex_unlock(hcd->bandwidth_mutex); return retval; } - retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_CONFIGURATION, 0, - config->desc.bConfigurationValue, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); - if (retval < 0) { + retval = usb_control_msg_send(dev, 0, USB_REQ_SET_CONFIGURATION, 0, + config->desc.bConfigurationValue, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); + if (retval) { usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL); usb_enable_lpm(dev); mutex_unlock(hcd->bandwidth_mutex); @@ -2096,10 +2096,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration) } kfree(new_interfaces); - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_CONFIGURATION, 0, configuration, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT); - if (ret < 0 && cp) { + ret = usb_control_msg_send(dev, 0, USB_REQ_SET_CONFIGURATION, 0, + configuration, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); + if (ret && cp) { /* * All the old state is gone, so what else can we do? * The device is probably useless now anyway. -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uN8EMSGQX18bMQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 17:45:37 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QHrCLSGQX19lBgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 17:45:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EB9654086C; Mon, 14 Sep 2020 17:45:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726531AbgINPpQ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 11:45:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:47530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726361AbgINPiR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:17 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9653320756; Mon, 14 Sep 2020 15:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097879; bh=F6wx4MSBrpIsyo0PjXnFqRdWk4FAf3xNPNdZqRxUOjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uxmpb5dAseFTtzeqwU5/m3+f4svSXA6VkUsSSStY8DXLPf1ai8UksyQJ9GmfbAWtc rJjp3DXqYaUYnxNHEz8gLc7K/w1yEX9U+zdZxRPz4G9h/003iWh2WP1xnqgA3OCZc/ WRB1JvAe7uoGgXgncKCZGxGOcXZnzJDuIa4j1nsc= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Eli Billauer <eli.billauer@gmail.com>, Emiliano Ingrassia <ingrassia@epigenesys.com>, Alan Stern <stern@rowland.harvard.edu>, Alexander Tsoy <alexander@tsoy.me>, "Geoffrey D. Bennett" <g@b4.vu>, Jussi Laako <jussi@sonarnerd.net>, Nick Kossifidis <mickflemm@gmail.com>, Dmitry Panchenko <dmitry@d-systems.ee>, Chris Wulff <crwulff@gmail.com>, Jesus Ramos <jesus-ramos@live.com>, Takashi Iwai <tiwai@suse.de> Subject: [PATCH v3 01/11] USB: move snd_usb_pipe_sanity_check into the USB core Date: Mon, 14 Sep 2020 17:37:46 +0200 Message-Id: <20200914153756.3412156-2-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914153756.3412156-1-gregkh@linuxfoundation.org> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.27 / 15.00 / 15.00 X-Rspamd-Queue-Id: EB9654086C X-Rspamd-UID: 21ba15 snd_usb_pipe_sanity_check() is a great function, so let's move it into the USB core so that other parts of the kernel, including the USB core, can call it. Name it usb_pipe_type_check() to match the existing usb_urb_ep_type_check() call, which now uses this function. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> Cc: Eli Billauer <eli.billauer@gmail.com> Cc: Emiliano Ingrassia <ingrassia@epigenesys.com> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Alexander Tsoy <alexander@tsoy.me> Cc: "Geoffrey D. Bennett" <g@b4.vu> Cc: Jussi Laako <jussi@sonarnerd.net> Cc: Nick Kossifidis <mickflemm@gmail.com> Cc: Dmitry Panchenko <dmitry@d-systems.ee> Cc: Chris Wulff <crwulff@gmail.com> Cc: Jesus Ramos <jesus-ramos@live.com> Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: alsa-devel@alsa-project.org Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v3: - no change from v2 v2: - use usb_pipe_type_check() instead of usb_urb_ep_type_check in urb.c - fix typo in function description - both changes thanks to Alan Stern's review comments - added Takashi Iwai's reviewed-by drivers/usb/core/urb.c | 31 +++++++++++++++++++++++-------- include/linux/usb.h | 1 + sound/usb/helper.c | 16 +--------------- sound/usb/helper.h | 1 - sound/usb/mixer_scarlett_gen2.c | 2 +- sound/usb/quirks.c | 12 ++++++------ 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 27e83e55a590..357b149b20d3 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -192,24 +192,39 @@ static const int pipetypes[4] = { }; /** - * usb_urb_ep_type_check - sanity check of endpoint in the given urb - * @urb: urb to be checked + * usb_pipe_type_check - sanity check of a specific pipe for a usb device + * @dev: struct usb_device to be checked + * @pipe: pipe to check * * This performs a light-weight sanity check for the endpoint in the - * given urb. It returns 0 if the urb contains a valid endpoint, otherwise - * a negative error code. + * given usb device. It returns 0 if the pipe is valid for the specific usb + * device, otherwise a negative error code. */ -int usb_urb_ep_type_check(const struct urb *urb) +int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe) { const struct usb_host_endpoint *ep; - ep = usb_pipe_endpoint(urb->dev, urb->pipe); + ep = usb_pipe_endpoint(dev, pipe); if (!ep) return -EINVAL; - if (usb_pipetype(urb->pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) + if (usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) return -EINVAL; return 0; } +EXPORT_SYMBOL_GPL(usb_pipe_type_check); + +/** + * usb_urb_ep_type_check - sanity check of endpoint in the given urb + * @urb: urb to be checked + * + * This performs a light-weight sanity check for the endpoint in the + * given urb. It returns 0 if the urb contains a valid endpoint, otherwise + * a negative error code. + */ +int usb_urb_ep_type_check(const struct urb *urb) +{ + return usb_pipe_type_check(urb->dev, urb->pipe); +} EXPORT_SYMBOL_GPL(usb_urb_ep_type_check); /** @@ -474,7 +489,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) */ /* Check that the pipe's type matches the endpoint's type */ - if (usb_urb_ep_type_check(urb)) + if (usb_pipe_type_check(urb->dev, urb->pipe)) dev_WARN(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n", usb_pipetype(urb->pipe), pipetypes[xfertype]); diff --git a/include/linux/usb.h b/include/linux/usb.h index 20c555db4621..0b3963d7ec38 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1764,6 +1764,7 @@ static inline int usb_urb_dir_out(struct urb *urb) return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; } +int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe); int usb_urb_ep_type_check(const struct urb *urb); void *usb_alloc_coherent(struct usb_device *dev, size_t size, diff --git a/sound/usb/helper.c b/sound/usb/helper.c index 4c12cc5b53fd..cf92d7110773 100644 --- a/sound/usb/helper.c +++ b/sound/usb/helper.c @@ -63,20 +63,6 @@ void *snd_usb_find_csint_desc(void *buffer, int buflen, void *after, u8 dsubtype return NULL; } -/* check the validity of pipe and EP types */ -int snd_usb_pipe_sanity_check(struct usb_device *dev, unsigned int pipe) -{ - static const int pipetypes[4] = { - PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT - }; - struct usb_host_endpoint *ep; - - ep = usb_pipe_endpoint(dev, pipe); - if (!ep || usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) - return -EINVAL; - return 0; -} - /* * Wrapper for usb_control_msg(). * Allocates a temp buffer to prevent dmaing from/to the stack. @@ -89,7 +75,7 @@ int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, void *buf = NULL; int timeout; - if (snd_usb_pipe_sanity_check(dev, pipe)) + if (usb_pipe_type_check(dev, pipe)) return -EINVAL; if (size > 0) { diff --git a/sound/usb/helper.h b/sound/usb/helper.h index 5e8a18b4e7b9..f5b4c6647e4d 100644 --- a/sound/usb/helper.h +++ b/sound/usb/helper.h @@ -7,7 +7,6 @@ unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size); void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype); void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype); -int snd_usb_pipe_sanity_check(struct usb_device *dev, unsigned int pipe); int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size); diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 0ffff7640892..9609c6d9655c 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -1978,7 +1978,7 @@ static int scarlett2_mixer_status_create(struct usb_mixer_interface *mixer) return 0; } - if (snd_usb_pipe_sanity_check(dev, pipe)) + if (usb_pipe_type_check(dev, pipe)) return -EINVAL; mixer->urb = usb_alloc_urb(0, GFP_KERNEL); diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 75bbdc691243..1b482848e73b 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -856,7 +856,7 @@ static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev) static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 }; void *buf; - if (snd_usb_pipe_sanity_check(dev, usb_sndintpipe(dev, 0x05))) + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x05))) return -EINVAL; buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); if (!buf) @@ -885,7 +885,7 @@ static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev) { int ret; - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) return -EINVAL; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE, @@ -994,7 +994,7 @@ static int snd_usb_axefx3_boot_quirk(struct usb_device *dev) dev_dbg(&dev->dev, "Waiting for Axe-Fx III to boot up...\n"); - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) return -EINVAL; /* If the Axe-Fx III has not fully booted, it will timeout when trying * to enable the audio streaming interface. A more generous timeout is @@ -1028,7 +1028,7 @@ static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, { int err, actual_length; - if (snd_usb_pipe_sanity_check(dev, usb_sndintpipe(dev, 0x01))) + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x01))) return -EINVAL; err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x01), buf, *length, &actual_length, 1000); @@ -1040,7 +1040,7 @@ static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, memset(buf, 0, buf_size); - if (snd_usb_pipe_sanity_check(dev, usb_rcvintpipe(dev, 0x82))) + if (usb_pipe_type_check(dev, usb_rcvintpipe(dev, 0x82))) return -EINVAL; err = usb_interrupt_msg(dev, usb_rcvintpipe(dev, 0x82), buf, buf_size, &actual_length, 1000); @@ -1127,7 +1127,7 @@ static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) { int ret; - if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) + if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) return -EINVAL; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IFnEIWibX1999QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 18:33:44 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yBENHmibX19X2AEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 18:33:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id AF6E440969; Mon, 14 Sep 2020 18:33:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726498AbgINPpG (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 11:45:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:48036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726163AbgINPiX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC3DB21D41; Mon, 14 Sep 2020 15:38:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097896; bh=XYLL0KUMv9QFPVZiQoCBglWmF6MD1JN+dd5eHYK5nys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0RLRsiGw9J2HBRKIUDSkJWq/Wk+SLqdTbiRnMNsax1+8/6zw0h38/xrtWyJsYH7ir j2EtHv9H2WhVDq5qBZLxfUo1+xEFswCPCdKLRRmeMryiXmTolxO5IB2E4cJd1qCTR+ 5C/KkJF39VnFJy6YJBV/l40mEs1Eju5mU018bPFo= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Alan Stern <stern@rowland.harvard.edu> Subject: [PATCH v3 04/11] USB: core: hub.c: use usb_control_msg_send() in a few places Date: Mon, 14 Sep 2020 17:37:49 +0200 Message-Id: <20200914153756.3412156-5-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914153756.3412156-1-gregkh@linuxfoundation.org> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.52 / 15.00 / 15.00 X-Rspamd-Queue-Id: AF6E440969 X-Rspamd-UID: 622de3 There are a few calls to usb_control_msg() that can be converted to use usb_control_msg_send() instead, so do that in order to make the error checking a bit simpler and the code smaller. Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v3: - drop change in usb_enable_link_state() as it was not needed now thanks to review from Alan - minor changes requested by checkpatch.pl v2: - dropped changes to usb_req_set_sel() thanks to review from Alan drivers/usb/core/hub.c | 99 +++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 59 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 5b768b80d1ee..5742ddeb0455 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -410,8 +410,8 @@ static int get_hub_descriptor(struct usb_device *hdev, */ static int clear_hub_feature(struct usb_device *hdev, int feature) { - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - USB_REQ_CLEAR_FEATURE, USB_RT_HUB, feature, 0, NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, USB_REQ_CLEAR_FEATURE, USB_RT_HUB, + feature, 0, NULL, 0, 1000); } /* @@ -419,9 +419,8 @@ static int clear_hub_feature(struct usb_device *hdev, int feature) */ int usb_clear_port_feature(struct usb_device *hdev, int port1, int feature) { - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - USB_REQ_CLEAR_FEATURE, USB_RT_PORT, feature, port1, - NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, USB_REQ_CLEAR_FEATURE, USB_RT_PORT, + feature, port1, NULL, 0, 1000); } /* @@ -429,9 +428,8 @@ int usb_clear_port_feature(struct usb_device *hdev, int port1, int feature) */ static int set_port_feature(struct usb_device *hdev, int port1, int feature) { - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port1, - NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, USB_REQ_SET_FEATURE, USB_RT_PORT, + feature, port1, NULL, 0, 1000); } static char *to_led_name(int selector) @@ -755,15 +753,14 @@ hub_clear_tt_buffer(struct usb_device *hdev, u16 devinfo, u16 tt) /* Need to clear both directions for control ep */ if (((devinfo >> 11) & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_CONTROL) { - int status = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - HUB_CLEAR_TT_BUFFER, USB_RT_PORT, - devinfo ^ 0x8000, tt, NULL, 0, 1000); + int status = usb_control_msg_send(hdev, 0, + HUB_CLEAR_TT_BUFFER, USB_RT_PORT, + devinfo ^ 0x8000, tt, NULL, 0, 1000); if (status) return status; } - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo, - tt, NULL, 0, 1000); + return usb_control_msg_send(hdev, 0, HUB_CLEAR_TT_BUFFER, USB_RT_PORT, + devinfo, tt, NULL, 0, 1000); } /* @@ -1049,11 +1046,10 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) */ if (type != HUB_RESUME) { if (hdev->parent && hub_is_superspeed(hdev)) { - ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), - HUB_SET_DEPTH, USB_RT_HUB, - hdev->level - 1, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - if (ret < 0) + ret = usb_control_msg_send(hdev, 0, HUB_SET_DEPTH, USB_RT_HUB, + hdev->level - 1, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); + if (ret) dev_err(hub->intfdev, "set hub depth failed\n"); } @@ -2329,13 +2325,10 @@ static int usb_enumerate_device_otg(struct usb_device *udev) /* enable HNP before suspend, it's simpler */ if (port1 == bus->otg_port) { bus->b_hnp_enable = 1; - err = usb_control_msg(udev, - usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, 0, - USB_DEVICE_B_HNP_ENABLE, - 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - if (err < 0) { + err = usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, 0, + USB_DEVICE_B_HNP_ENABLE, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); + if (err) { /* * OTG MESSAGE: report errors here, * customize to match your product. @@ -2347,13 +2340,10 @@ static int usb_enumerate_device_otg(struct usb_device *udev) } else if (desc->bLength == sizeof (struct usb_otg_descriptor)) { /* Set a_alt_hnp_support for legacy otg device */ - err = usb_control_msg(udev, - usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, 0, - USB_DEVICE_A_ALT_HNP_SUPPORT, - 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - if (err < 0) + err = usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, 0, + USB_DEVICE_A_ALT_HNP_SUPPORT, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); + if (err) dev_err(&udev->dev, "set a_alt_hnp_support failed: %d\n", err); @@ -3121,10 +3111,8 @@ int usb_disable_ltm(struct usb_device *udev) if (!udev->actconfig) return 0; - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_LTM_ENABLE, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_LTM_ENABLE, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } EXPORT_SYMBOL_GPL(usb_disable_ltm); @@ -3143,10 +3131,8 @@ void usb_enable_ltm(struct usb_device *udev) if (!udev->actconfig) return; - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_LTM_ENABLE, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_LTM_ENABLE, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } EXPORT_SYMBOL_GPL(usb_enable_ltm); @@ -3163,17 +3149,14 @@ EXPORT_SYMBOL_GPL(usb_enable_ltm); static int usb_enable_remote_wakeup(struct usb_device *udev) { if (udev->speed < USB_SPEED_SUPER) - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_REMOTE_WAKEUP, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); else - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, - USB_INTRF_FUNC_SUSPEND, - USB_INTRF_FUNC_SUSPEND_RW | - USB_INTRF_FUNC_SUSPEND_LP, - NULL, 0, USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, + USB_INTRF_FUNC_SUSPEND, + USB_INTRF_FUNC_SUSPEND_RW | USB_INTRF_FUNC_SUSPEND_LP, + NULL, 0, USB_CTRL_SET_TIMEOUT); } /* @@ -3189,15 +3172,13 @@ static int usb_enable_remote_wakeup(struct usb_device *udev) static int usb_disable_remote_wakeup(struct usb_device *udev) { if (udev->speed < USB_SPEED_SUPER) - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, - USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); else - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, - USB_INTRF_FUNC_SUSPEND, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); + return usb_control_msg_send(udev, 0, USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, + USB_INTRF_FUNC_SUSPEND, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); } /* Count of wakeup-enabled devices at or below udev */ -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iMzuKn6bX184PQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 18:34:06 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id QJF6J36bX1/TiAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 18:34:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=oracle.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9D4A840732; Mon, 14 Sep 2020 18:34:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726137AbgINQd4 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 12:33:56 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37796 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbgINPoj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:44:39 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08EFiFC6141963; Mon, 14 Sep 2020 15:44:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=eq4LTC2Yd5sfvcCLwppvKF+HmjZnZ6bst/Dh6vKmwQ4=; b=RLRAX6BrM34Ih+gjIw+Epxc9xBzMUxjRCzA49x9waBmG5ROyH122zIRNrKiJcl9F4jMG o5vlXfAT76qxk9mGooEGm/w6UYM4CCE3WCBuFtR+4iaDo4nWs6vrmB8arGC7QccFXZSe VtHLWWOWHlPYBIcfMkraiW/aC9MBB7N2cvKZt3LkD1WKoJbZL147JheLdjJKGzCnX0Ss IeoCGLYVBe9oQ4aZyDIr/uu9HrZapDkRL6gUQ2umnPvjwv4HxsI4nQKDZdgQARax9ZdL G5UdZXSmS3zQytLdUz5zKalVJIjdKEvbw6goCGJZhgXmGY10EVQtklnmB5CNlCMbejZk Vw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 33j91d916q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 14 Sep 2020 15:44:18 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08EFPMNK113211; Mon, 14 Sep 2020 15:44:17 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 33h881tn8s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Sep 2020 15:44:17 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 08EFiDnQ017022; Mon, 14 Sep 2020 15:44:14 GMT Received: from kadam (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 14 Sep 2020 15:44:13 +0000 Date: Mon, 14 Sep 2020 18:44:05 +0300 From: Dan Carpenter <dan.carpenter@oracle.com> To: Anmol Karn <anmol.karan123@gmail.com> Cc: marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Subject: Re: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer dereference in hci_event_packet() Message-ID: <20200914154405.GC18329@kadam> References: <20200910043424.19894-1-anmol.karan123@gmail.com> <20200910104918.GF12635@kadam> <20200912091028.GA67109@Thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200912091028.GA67109@Thinkpad> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9744 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009140125 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9744 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009140126 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.19 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9D4A840732 X-Rspamd-UID: 70ae81 On Sat, Sep 12, 2020 at 02:40:28PM +0530, Anmol Karn wrote: > On Thu, Sep 10, 2020 at 01:49:18PM +0300, Dan Carpenter wrote: > > On Thu, Sep 10, 2020 at 10:04:24AM +0530, Anmol Karn wrote: > > > Prevent hci_phy_link_complete_evt() from dereferencing 'hcon->amp_mgr' > > > as NULL. Fix it by adding pointer check for it. > > > > > > Reported-and-tested-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com > > > Link: https://syzkaller.appspot.com/bug?extid=0bef568258653cff272f > > > Signed-off-by: Anmol Karn <anmol.karan123@gmail.com> > > > --- > > > net/bluetooth/hci_event.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > > index 4b7fc430793c..871e16804433 100644 > > > --- a/net/bluetooth/hci_event.c > > > +++ b/net/bluetooth/hci_event.c > > > @@ -4936,6 +4936,11 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > > > return; > > > } > > > > > > + if (IS_ERR_OR_NULL(hcon->amp_mgr)) { > > > > It can't be an error pointer. Shouldn't we call hci_conn_del() on this > > path? Try to find the Fixes tag to explain how this bug was introduced. > > > > (Don't rush to send a v2. The patch requires quite a bit more digging > > and detective work before it is ready). > > > > > + hci_dev_unlock(hdev); > > > + return; > > > + } > > > + > > > if (ev->status) { > > > hci_conn_del(hcon); > > > hci_dev_unlock(hdev); > > > > regards, > > dan carpenter > > > > Sir, > > I need little advice in continuing with this Patch, > > I have looked into the Bisected logs and the problem occurs from this commit: > > 941992d29447 ("ethernet: amd: use IS_ENABLED() instead of checking for built-in or module") > That's just the patch which made the code testable by syzbot. It didn't introduce the bug. > > Here is a diff of patch which i modified from last patch, > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 4b7fc430793c..6ce435064e0b 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -4936,6 +4936,12 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > return; > } > > + if (!hcon->amp_mgr) { > + hci_conn_del(hcon); > + hci_dev_unlock(hdev); I have no idea if calling hci_conn_del() is really the correct, thing. I don't know the code at all. Anyway, do some research and figure out for sure what the correct thing is. Also look for similar bugs in other places where hcon->amp_mgr is dereferenced. For example, amp_read_loc_assoc_final_data() seems to have a similar bug. regards, dan carpenter Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6ASRDmCcX184PQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 18:37:52 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +JylC2CcX18akwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 18:37:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 92524A0B09; Mon, 14 Sep 2020 18:37:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726299AbgINQhb (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 12:37:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:47772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbgINPiQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:16 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0F5892193E; Mon, 14 Sep 2020 15:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097889; bh=RoTPtd9qHHuk1GM7mtTLP95n0k7SzFhORIof1s3mXI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=an12vcgsLuq8dJy3avIewd9JstauxKo62seMlj12DUNw3bW7UjfEsJsX6MQnWjpUq ZNSgQKrQh4ZtDER7l7MUuGRfIuAhBOrjUQm/iYdmvY1VLD0rRlB14FWBcZyPlDhumj uRXdoq4OFhaqzm0J4VpPvm6Tc8OKPDUrUR6f/kAg= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Alexander Tsoy <alexander@tsoy.me>, Alan Stern <stern@rowland.harvard.edu> Subject: [PATCH v3 11/11] ALSA: remove calls to usb_pipe_type_check for control endpoints Date: Mon, 14 Sep 2020 17:37:56 +0200 Message-Id: <20200914153756.3412156-12-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914153756.3412156-1-gregkh@linuxfoundation.org> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.82 / 15.00 / 15.00 X-Rspamd-Queue-Id: 92524A0B09 X-Rspamd-UID: 056645 A USB device will always haev a bi-directional endpoint 0, that's just how the devices work, so no need to check for that in a few quirk tests as it will always pass. Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: Alexander Tsoy <alexander@tsoy.me> Cc: alsa-devel@alsa-project.org Reported-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- v3: - no change from v2 v2: - new patch, was not in v1 series, suggested by Alan. sound/usb/quirks.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 1b482848e73b..395d1ea6f03f 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -885,8 +885,6 @@ static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev) { int ret; - if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) - return -EINVAL; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1, 0, NULL, 0, 1000); @@ -994,8 +992,6 @@ static int snd_usb_axefx3_boot_quirk(struct usb_device *dev) dev_dbg(&dev->dev, "Waiting for Axe-Fx III to boot up...\n"); - if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) - return -EINVAL; /* If the Axe-Fx III has not fully booted, it will timeout when trying * to enable the audio streaming interface. A more generous timeout is * used here to detect when the Axe-Fx III has finished booting as the @@ -1127,8 +1123,6 @@ static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) { int ret; - if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0))) - return -EINVAL; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0x0, 0, NULL, 0, 1000); -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yFT+LxLdX1/BhwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 23:13:54 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 2E5cLBLdX19oQgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 23:13:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6627640941; Mon, 14 Sep 2020 23:13:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726050AbgINVNq (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 17:13:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725926AbgINVNn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 17:13:43 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC92AC06174A for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 14:13:41 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id j185so727747vsc.3 for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 14:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1izYfSwKbgx1WFJ5THQP2t+HL2wzkylz4XkOUpp8gFQ=; b=m3WcWU3IdjOAqZt0dUAzEssHPkHcx3d7HXAZ59qQIsjSM58JxAGvaVuMDyxPnKPIJs UJuzsgGCoz3RcX59gpE7cbUtvwunY9Ovr1vTx1B9T3MLkTCGqYvOwXQYfq1CwPE2InTC MBa6tfykWjbE26PhvhfxF157C9jIHgeWamXgM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1izYfSwKbgx1WFJ5THQP2t+HL2wzkylz4XkOUpp8gFQ=; b=t9IcHR33mA6bxI3FCEIFj5UDZPVsvs2Vza66Tf0uHIK+nUB7TPcbzE6S8FGKTiuewv JIkxPy6x3NMKCoZ7WJOZtkuQP1j8YDkb64cLOfztJXtjfA96eRqqk9a7NrJHPA8Ysf+b GVL0Wy915lTa6IJcH0SZdGslJ70ZrJF4xtQAm7rkROnvrIKdl9sfjA9r4v/stOl76bGl rXxPGWnf2EiAq/W2OeUiYqpASsG/XcEWg4tE6cjUh0EOx2VpyMm6M56bseVgH4cRlA4f qYO4B7ePfZKa2foEEzMW9jycUFOaMgsi4M3ges0Z0Q56U49fv+2vCTtDIIsj2E5OmRaj QZtQ== X-Gm-Message-State: AOAM530vbfm5BRLjrHzYR8uWOTe8WfEVQ199EFzLYzloWgzsAEjCW0tw 3p8jW2xQkj3VQ/xeEhrhKsJuH7CgglTnUOxcB/LNGg== X-Google-Smtp-Source: ABdhPJwcgAGuODq867ZbjR6LoNR1AgjEvHNOVsDw+VAcKlf/u57lk1P3KamynzEAdqeAwn14iAFLrvwoO1OW2R6VegM= X-Received: by 2002:a67:ed0d:: with SMTP id l13mr8048884vsp.114.1600118020912; Mon, 14 Sep 2020 14:13:40 -0700 (PDT) MIME-Version: 1.0 References: <20200911223037.4127188-1-abhishekpandit@chromium.org> <20200911153010.Bluez.v4.1.Ib9712d2bf5d4b3f90c5bc835742aea8c7cd239e4@changeid> <CABBYNZKk=tgUgF6UrYfGxS5fv9b9WBbFAo-iZiMe9z1OECJUEQ@mail.gmail.com> In-Reply-To: <CABBYNZKk=tgUgF6UrYfGxS5fv9b9WBbFAo-iZiMe9z1OECJUEQ@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Mon, 14 Sep 2020 14:13:29 -0700 Message-ID: <CANFp7mUQy=WYXOH5LLacRnNHkUdFfOL=n6fm+8hW07yfTrQmCQ@mail.gmail.com> Subject: Re: [Bluez PATCH v4 1/4] adapter: Refactor kernel feature globals To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6627640941 X-Rspamd-UID: 7e17a1 Hi Luiz, On Mon, Sep 14, 2020 at 12:59 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Abhishek, > > On Fri, Sep 11, 2020 at 3:30 PM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > Move all the kernel specific feature globals into a single > > kernel_features bitfield and replace all uses with the bitfield instead. > > --- > > > > Changes in v4: None > > Changes in v3: None > > Changes in v2: None > > > > src/adapter.c | 59 ++++++++++++++++++++++++++------------------------- > > src/adapter.h | 9 ++++++++ > > 2 files changed, 39 insertions(+), 29 deletions(-) > > > > diff --git a/src/adapter.c b/src/adapter.c > > index 1435e2bd7..e700a78d5 100644 > > --- a/src/adapter.c > > +++ b/src/adapter.c > > @@ -116,13 +116,7 @@ static const struct mgmt_blocked_key_info blocked_keys[] = { > > > > static DBusConnection *dbus_conn = NULL; > > > > -static bool kernel_conn_control = false; > > - > > -static bool kernel_blocked_keys_supported = false; > > - > > -static bool kernel_set_system_config = false; > > - > > -static bool kernel_exp_features = false; > > +static uint32_t kernel_features = 0; > > > > static GList *adapter_list = NULL; > > static unsigned int adapter_remaining = 0; > > @@ -678,7 +672,7 @@ static bool set_discoverable(struct btd_adapter *adapter, uint8_t mode, > > > > DBG("sending set mode command for index %u", adapter->dev_id); > > > > - if (kernel_conn_control) { > > + if (has_kernel_features(KERNEL_CONN_CONTROL)) { > > if (mode) > > set_mode(adapter, MGMT_OP_SET_CONNECTABLE, mode); > > else > > @@ -1334,7 +1328,7 @@ static void trigger_passive_scanning(struct btd_adapter *adapter) > > * no need to start any discovery. The kernel will keep scanning > > * as long as devices are in its auto-connection list. > > */ > > - if (kernel_conn_control) > > + if (has_kernel_features(KERNEL_CONN_CONTROL)) > > return; > > > > /* > > @@ -1385,7 +1379,7 @@ static void stop_passive_scanning_complete(uint8_t status, uint16_t length, > > * no need to stop any discovery. The kernel will handle the > > * auto-connection by itself. > > */ > > - if (kernel_conn_control) > > + if (has_kernel_features(KERNEL_CONN_CONTROL)) > > return; > > > > /* > > @@ -2816,7 +2810,7 @@ static void property_set_mode_complete(uint8_t status, uint16_t length, > > > > static void clear_discoverable(struct btd_adapter *adapter) > > { > > - if (!kernel_conn_control) > > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > > return; > > > > if (!(adapter->current_settings & MGMT_SETTING_DISCOVERABLE)) > > @@ -2876,7 +2870,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, > > > > break; > > case MGMT_SETTING_DISCOVERABLE: > > - if (kernel_conn_control) { > > + if (has_kernel_features(KERNEL_CONN_CONTROL)) { > > if (mode) { > > set_mode(adapter, MGMT_OP_SET_CONNECTABLE, > > mode); > > @@ -4193,7 +4187,8 @@ static void load_default_system_params(struct btd_adapter *adapter) > > size_t len = 0; > > unsigned int err; > > > > - if (!main_opts.default_params.num_entries || !kernel_set_system_config) > > + if (!main_opts.default_params.num_entries || > > + !has_kernel_features(KERNEL_SET_SYSTEM_CONFIG)) > > return; > > > > params = malloc0(sizeof(*params) * > > @@ -4878,7 +4873,7 @@ int adapter_connect_list_add(struct btd_adapter *adapter, > > * adapter_auto_connect_add() function is used to maintain what to > > * connect. > > */ > > - if (kernel_conn_control) > > + if (has_kernel_features(KERNEL_CONN_CONTROL)) > > return 0; > > > > if (g_slist_find(adapter->connect_list, device)) { > > @@ -4918,7 +4913,7 @@ void adapter_connect_list_remove(struct btd_adapter *adapter, > > if (device == adapter->connect_le) > > adapter->connect_le = NULL; > > > > - if (kernel_conn_control) > > + if (has_kernel_features(KERNEL_CONN_CONTROL)) > > return; > > > > if (!g_slist_find(adapter->connect_list, device)) { > > @@ -4980,7 +4975,7 @@ void adapter_whitelist_add(struct btd_adapter *adapter, struct btd_device *dev) > > { > > struct mgmt_cp_add_device cp; > > > > - if (!kernel_conn_control) > > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > > return; > > > > memset(&cp, 0, sizeof(cp)); > > @@ -5019,7 +5014,7 @@ void adapter_whitelist_remove(struct btd_adapter *adapter, struct btd_device *de > > { > > struct mgmt_cp_remove_device cp; > > > > - if (!kernel_conn_control) > > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > > return; > > > > memset(&cp, 0, sizeof(cp)); > > @@ -5075,7 +5070,7 @@ void adapter_auto_connect_add(struct btd_adapter *adapter, > > uint8_t bdaddr_type; > > unsigned int id; > > > > - if (!kernel_conn_control) > > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > > return; > > > > if (g_slist_find(adapter->connect_list, device)) { > > @@ -5147,7 +5142,7 @@ void adapter_set_device_wakeable(struct btd_adapter *adapter, > > const bdaddr_t *bdaddr; > > uint8_t bdaddr_type; > > > > - if (!kernel_conn_control) > > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > > return; > > > > bdaddr = device_get_address(device); > > @@ -5224,7 +5219,7 @@ void adapter_auto_connect_remove(struct btd_adapter *adapter, > > uint8_t bdaddr_type; > > unsigned int id; > > > > - if (!kernel_conn_control) > > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > > return; > > > > if (!g_slist_find(adapter->connect_list, device)) { > > @@ -6764,7 +6759,7 @@ connect_le: > > * If kernel background scan is used then the kernel is > > * responsible for connecting. > > */ > > - if (kernel_conn_control) > > + if (has_kernel_features(KERNEL_CONN_CONTROL)) > > return; > > > > /* > > @@ -8964,7 +8959,7 @@ static int clear_devices(struct btd_adapter *adapter) > > { > > struct mgmt_cp_remove_device cp; > > > > - if (!kernel_conn_control) > > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > > return 0; > > > > memset(&cp, 0, sizeof(cp)); > > @@ -9282,7 +9277,7 @@ static void read_info_complete(uint8_t status, uint16_t length, > > (missing_settings & MGMT_SETTING_FAST_CONNECTABLE)) > > set_mode(adapter, MGMT_OP_SET_FAST_CONNECTABLE, 0x01); > > > > - if (kernel_exp_features) > > + if (has_kernel_features(KERNEL_EXP_FEATURES)) > > read_exp_features(adapter); > > > > err = adapter_register(adapter); > > @@ -9403,7 +9398,8 @@ static void read_info_complete(uint8_t status, uint16_t length, > > > > set_name(adapter, btd_adapter_get_name(adapter)); > > > > - if (kernel_blocked_keys_supported && !set_blocked_keys(adapter)) { > > + if (has_kernel_features(KERNEL_BLOCKED_KEYS_SUPPORTED) && > > + !set_blocked_keys(adapter)) { > > btd_error(adapter->dev_id, > > "Failed to set blocked keys for index %u", > > adapter->dev_id); > > @@ -9414,7 +9410,7 @@ static void read_info_complete(uint8_t status, uint16_t length, > > !(adapter->current_settings & MGMT_SETTING_BONDABLE)) > > set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01); > > > > - if (!kernel_conn_control) > > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > > set_mode(adapter, MGMT_OP_SET_CONNECTABLE, 0x01); > > else if (adapter->current_settings & MGMT_SETTING_CONNECTABLE) > > set_mode(adapter, MGMT_OP_SET_CONNECTABLE, 0x00); > > @@ -9590,19 +9586,19 @@ static void read_commands_complete(uint8_t status, uint16_t length, > > switch (op) { > > case MGMT_OP_ADD_DEVICE: > > DBG("enabling kernel-side connection control"); > > - kernel_conn_control = true; > > + kernel_features |= KERNEL_CONN_CONTROL; > > break; > > case MGMT_OP_SET_BLOCKED_KEYS: > > DBG("kernel supports the set_blocked_keys op"); > > - kernel_blocked_keys_supported = true; > > + kernel_features |= KERNEL_BLOCKED_KEYS_SUPPORTED; > > break; > > case MGMT_OP_SET_DEF_SYSTEM_CONFIG: > > DBG("kernel supports set system confic"); > > - kernel_set_system_config = true; > > + kernel_features |= KERNEL_SET_SYSTEM_CONFIG; > > break; > > case MGMT_OP_READ_EXP_FEATURES_INFO: > > DBG("kernel supports exp features"); > > - kernel_exp_features = true; > > + kernel_features |= KERNEL_EXP_FEATURES; > > break; > > default: > > break; > > @@ -9768,3 +9764,8 @@ bool btd_le_connect_before_pairing(void) > > > > return false; > > } > > + > > +bool has_kernel_features(uint32_t features) > > +{ > > + return !!(kernel_features & features); > > Don't think we need the !! here, the use () should already be enough, > or change it to return (kernel_features & features) ? true : false; if > you think that is more readable. Will change this to `return (kernel_features & features)`. > > > +} > > diff --git a/src/adapter.h b/src/adapter.h > > index f8ac20261..b0ed4915f 100644 > > --- a/src/adapter.h > > +++ b/src/adapter.h > > @@ -233,3 +233,12 @@ void btd_adapter_for_each_device(struct btd_adapter *adapter, > > void *data); > > > > bool btd_le_connect_before_pairing(void); > > + > > +enum kernel_features { > > + KERNEL_CONN_CONTROL = 1 << 0, > > + KERNEL_BLOCKED_KEYS_SUPPORTED = 1 << 1, > > + KERNEL_SET_SYSTEM_CONFIG = 1 << 2, > > + KERNEL_EXP_FEATURES = 1 << 3, > > +}; > > + > > +bool has_kernel_features(uint32_t feature); > > -- > > 2.28.0.618.gf4bc123cb7-goog > > > > > -- > Luiz Augusto von Dentz Any other concerns in this series? If not, will send the new patch series right away. Abhishek Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KLVYEHqcX184PQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 18:38:18 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SK2oDHqcX19pwgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 18:38:18 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 743C4A0B47; Mon, 14 Sep 2020 18:38:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726162AbgINQhb (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 12:37:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:47608 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726020AbgINPiQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 11:38:16 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 28CD120EDD; Mon, 14 Sep 2020 15:38:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600097881; bh=eMnr+X3ACCBlvUcal7w11UX5fuuRTjnCIruIdTho9mY=; h=From:To:Cc:Subject:Date:From; b=0Ax3veUWya2pauThyCeqC044APqyL6V/aqtPNVrTaTYfcQqtVxDnXxkIcr1psOgIM TTYoB4t4vYmxxKpa21YExO0UKGXlblUkC6KCLR4AbaHKorJkvArXPcCV4/ReplxRoa auKSCyMB+dvEXpOu5HePg0CKpK0OLbUQsm3atgvI= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH v3 00/11] USB: new USB control message helper functions Date: Mon, 14 Sep 2020 17:37:45 +0200 Message-Id: <20200914153756.3412156-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.83 / 15.00 / 15.00 X-Rspamd-Queue-Id: 743C4A0B47 X-Rspamd-UID: f90fa0 In a recent discussion about a USB networking bug found by syzbot, and fixed by Himadri Pandya, the design of the existing usb_control_msg() call was brought up as not being the "nicest" thing to use by Dmitry Vyukov: https://lore.kernel.org/r/CACT4Y+YbDODLRFn8M5QcY4CazhpeCaunJnP_udXtAs0rYoASSg@mail.gmail.com The function makes it hard to get right, in that it will return the number of bytes sent/received, but almost no one checks to see if a short read/write happens. With a malicious, or broken, USB device, this can cause drivers to act on data that they did not anticipate, and sometimes copy internal kernel data out to userspace. So let's fix this up by creating two new functions, usb_control_msg_send() and usb_control_msg_recv(). These functions either complete the full transation, or they return an error, a short send/recv is now an error. They also accept data off of the stack, saving individual drivers the pain of having to constantly allocate memory on their own for tiny messages, thereby saving overall kernel code space. The api also does not require a raw USB "pipe" to be sent to the function, as we know the direction, so just pass in the endpoint number instead, again making it easier on the USB driver author to use. This series first takes a helper function out of the sound core for verifying USB endpoints to be able to use internally, and then adds the new functions, converts over some internal USB code to use them, and then starts to clean up some drivers using these new functions, as an example of the savings that can happen by using these functions. Thanks to Dmitry and Himadri for the idea on how to do all of this. greg k-h ----- Changes from v2: - add Andy's reviewed-by: to patch 3 - remove unneeded change in usb_enable_link_state() in hub.c in patch 4 Changes from v1: - added acks from Takashi Iwai - dropped changes to one function in patch 04 thanks to review from Alan Stern - typo fix in comment in patch 01 - added new patch 11 to remove some unneeded checks in the sound drivers for endpoint statuses that would always be true. Greg Kroah-Hartman (11): USB: move snd_usb_pipe_sanity_check into the USB core USB: add usb_control_msg_send() and usb_control_msg_recv() USB: core: message.c: use usb_control_msg_send() in a few places USB: core: hub.c: use usb_control_msg_send() in a few places USB: legousbtower: use usb_control_msg_recv() sound: usx2y: move to use usb_control_msg_send() sound: 6fire: move to use usb_control_msg_send() and usb_control_msg_recv() sound: line6: move to use usb_control_msg_send() and usb_control_msg_recv() sound: hiface: move to use usb_control_msg_send() Bluetooth: ath3k: use usb_control_msg_send() and usb_control_msg_recv() ALSA: remove calls to usb_pipe_type_check for control endpoints drivers/bluetooth/ath3k.c | 90 +++++------------ drivers/usb/core/hub.c | 99 ++++++++---------- drivers/usb/core/message.c | 171 ++++++++++++++++++++++++++++---- drivers/usb/core/urb.c | 31 ++++-- drivers/usb/misc/legousbtower.c | 60 ++++------- include/linux/usb.h | 7 ++ sound/usb/6fire/firmware.c | 38 +++---- sound/usb/helper.c | 16 +-- sound/usb/helper.h | 1 - sound/usb/hiface/pcm.c | 14 ++- sound/usb/line6/driver.c | 69 +++++-------- sound/usb/line6/podhd.c | 17 ++-- sound/usb/line6/toneport.c | 8 +- sound/usb/mixer_scarlett_gen2.c | 2 +- sound/usb/quirks.c | 12 +-- sound/usb/usx2y/us122l.c | 42 ++------ 16 files changed, 336 insertions(+), 341 deletions(-) -- 2.28.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4FZpHn2pX1+czgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 19:33:49 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0FEiG32pX19+NQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 19:33:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 03116A015F; Mon, 14 Sep 2020 19:33:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726327AbgINRdh (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 13:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726373AbgINRdG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 13:33:06 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98622C06174A for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 10:33:05 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id m12so698594otr.0 for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 10:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gtKD+2cA9bRZX6C2303ZKrkz3oYqs84Ek3RNXj49zqo=; b=VpO1ZkaM4tV5n3Y8iQrNUeV4Gj4UDPYFoLFBv2sEneSSPMYupUmjJO/QCk9vzgxFAI vz9eEGbNc6Zx77OpsM8O0hvBR7kVS++3XVjpypkidGX4SWL3RbvR9DyaXK3Lm/ALaeh0 eIrOEcTK/5mWE6Bdl4KB6toMvBJvzrEmgW40Y/pXfaTalWZHdUoKk3BUvKdPQ3LcaE4G k61DDDN7gQq8KQ/+e/l4FABGFgRem6ZLp75M1SOyMQbH7oEp5CbDYJYYfmdbKgeMU8Nh Hff29+5K/Vjpb8NavDv8f5w+iv7ngDaukoThtDjTznKKx22Doiv6OkfWQfOudOsUeE8e Vv5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gtKD+2cA9bRZX6C2303ZKrkz3oYqs84Ek3RNXj49zqo=; b=ZIFEofcasLQnIegDaceBrwH4rM9ZXGXUeVzU6BjODclYFGjoJY3Ol6tp8NgR6gK2d1 evmvlHwNWK6EJBNSiaJLE6QJTd22lWEn0ODAlhY9Q7bnIyRs24S9ddud6cBxpZbUThZt Vqa2VnRGzph6l76cS5tD8MNc+UiEdeqtU85XPq0ZmFJcLfl8jA8Sq2HKFLCao9ZDXIev OJLbzTqKweHKu1KGozKTfnULn5SBQuoGB6xYdk2qu6vryXXEao0Qj99HqM5/7vvJ1OTp BhRwtACb58Ncxjb219D7uitj02hEB8sc6EkVvMnS2XFlheAMocyUku9mkBFu2rfPRBCA R8BA== X-Gm-Message-State: AOAM531klioAGzDw++nUrKTrWlxYMPNkaspPbW7E86mKaihzAV4/dlBr Eou6ji/as0FqsR7Q0FciyQLkJoMcSCCatKT/AEo= X-Google-Smtp-Source: ABdhPJxQRFEG2lGqZcCHp/nUGH4+svkOL2xTVsD5NSe62d4Rij3X4jEeV4lQvrDnUZ63vdVPu4IlCwKZ4SSEZ/hPJrE= X-Received: by 2002:a9d:4695:: with SMTP id z21mr10044227ote.91.1600104784692; Mon, 14 Sep 2020 10:33:04 -0700 (PDT) MIME-Version: 1.0 References: <20200912062357.23926-1-tedd.an@linux.intel.com> <20200912062357.23926-14-tedd.an@linux.intel.com> In-Reply-To: <20200912062357.23926-14-tedd.an@linux.intel.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 14 Sep 2020 10:32:52 -0700 Message-ID: <CABBYNZLiUJi8qZnZgBAMGwu8bKM1RoeiDcjZ5AK6jfWJ7ShTpw@mail.gmail.com> Subject: Re: [BlueZ 13/17] plugins: Add SPDX License Identifer To: Tedd Ho-Jeong An <tedd.an@linux.intel.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Tedd Ho-Jeong An <tedd.an@intel.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.83 / 15.00 / 15.00 X-Rspamd-Queue-Id: 03116A015F X-Rspamd-UID: b42092 Hi Tedd, On Fri, Sep 11, 2020 at 11:41 PM <tedd.an@linux.intel.com> wrote: > > From: Tedd Ho-Jeong An <tedd.an@intel.com> > > This patch adds SPDX License Identifier. > > ------------------------------------- > License COUNT > ------------------------------------- > GPL-2.0-or-later : 7 I guess all GPL 2.0 or later can be updated to GPL 2.1 or later. > License: GPL-2.0-or-later > plugins/autopair.c > plugins/hostname.c > plugins/neard.c > plugins/policy.c > plugins/sixaxis.c > plugins/wiimote.c > plugins/external-dummy.c > --- > plugins/autopair.c | 1 + > plugins/external-dummy.c | 1 + > plugins/hostname.c | 1 + > plugins/neard.c | 1 + > plugins/policy.c | 1 + > plugins/sixaxis.c | 1 + > plugins/wiimote.c | 1 + > 7 files changed, 7 insertions(+) > > diff --git a/plugins/autopair.c b/plugins/autopair.c > index 3089430a8..381d91c8f 100644 > --- a/plugins/autopair.c > +++ b/plugins/autopair.c > @@ -1,3 +1,4 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later Why are you using C++ // comments on the .c files and /* */ comments on .h? Also it looks like you are keeping the old license text which should no longer be necessary. > /* > * > * BlueZ - Bluetooth protocol stack for Linux > diff --git a/plugins/external-dummy.c b/plugins/external-dummy.c > index 536ad0663..78377b021 100644 > --- a/plugins/external-dummy.c > +++ b/plugins/external-dummy.c > @@ -1,3 +1,4 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > /* > * > * BlueZ - Bluetooth protocol stack for Linux > diff --git a/plugins/hostname.c b/plugins/hostname.c > index 4f9dfe6d8..32f15b3a5 100644 > --- a/plugins/hostname.c > +++ b/plugins/hostname.c > @@ -1,3 +1,4 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > /* > * > * BlueZ - Bluetooth protocol stack for Linux > diff --git a/plugins/neard.c b/plugins/neard.c > index 6ffcd6e10..1fefc5015 100644 > --- a/plugins/neard.c > +++ b/plugins/neard.c > @@ -1,3 +1,4 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > /* > * > * BlueZ - Bluetooth protocol stack for Linux > diff --git a/plugins/policy.c b/plugins/policy.c > index de51e58b9..86eb25ee9 100644 > --- a/plugins/policy.c > +++ b/plugins/policy.c > @@ -1,3 +1,4 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > /* > * > * BlueZ - Bluetooth protocol stack for Linux > diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c > index 939fed759..8350d63f8 100644 > --- a/plugins/sixaxis.c > +++ b/plugins/sixaxis.c > @@ -1,3 +1,4 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > /* > * > * BlueZ - Bluetooth protocol stack for Linux > diff --git a/plugins/wiimote.c b/plugins/wiimote.c > index 0ced27514..9441a7681 100644 > --- a/plugins/wiimote.c > +++ b/plugins/wiimote.c > @@ -1,3 +1,4 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > /* > * > * BlueZ - Bluetooth protocol stack for Linux > -- > 2.25.4 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EJbRI7CrX1/GrgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 19:43:12 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id WMipIbCrX1+hfwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 19:43:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D06A74086D; Mon, 14 Sep 2020 19:43:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725944AbgINRnG (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 13:43:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726208AbgINMX2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 08:23:28 -0400 Received: from mail-yb1-xb43.google.com (mail-yb1-xb43.google.com [IPv6:2607:f8b0:4864:20::b43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2F9EC0698C4 for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 05:18:40 -0700 (PDT) Received: by mail-yb1-xb43.google.com with SMTP id h20so11651064ybj.8 for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 05:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=95MkvjALtD+pWjI9L+dX9jS5l3VsX/dwVwk6PdF2H90=; b=BUvMIK5XM9/nSld70H/GBdIBvh2rIH9jwVh7E1IIo3gf+O+eVnOdStAbg+NveSxK7z e/XTV+vzv/3uHTlycyTHZ6NAP3kzlg0reNW4YWL71VPf1wB8oGisMQBQgAgMNPIx3cnN Vvdt2NZHPLkg9yIAdHfj9DXEGJdPO7P5XqRo7dAiPsBeZhDsOwN1CtuCy4G+Msha0XO0 JslegxXzxikldWKnjhEcEWvtQKwuSqXWQJRSm0llo1ZOmwPqN/v29jLjAWYhfeJHfWgq FcK3c/fpRNXSvH2lCrn/2KY4t2uEbmR4g5XA1l31V2d0hsN7k0jwLeisbZ0ZByI78EPU CfCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=95MkvjALtD+pWjI9L+dX9jS5l3VsX/dwVwk6PdF2H90=; b=EAMfSOZJPfLciSAd5Dk3L3VoOpco1jNvBWXkHLAN1BdV4uuiEM34K119H6v7OweGYI MnDiojR7aHOzIdy4ifeCZ1nT1yU94aG/GCQjdwnaIMNDVQzu4J1lsnMTojYhtnbPcjk4 XEUWkbABVy31PKRlEnJWcYdOVSkCuMETcFLgCMDWnITarGgoKsVOCfgMsDwQj90RRk6v YyFsb5bpVUnihNVN4VT7tOWFaCKkbg82jm4/AYdcv7BcllFCmOEL+YT2000EOFgoQHpq HvHOZVhWC8JypFiaK1aJRLrnzIiIzg+n6jt0uqWKRr4s3zz1DDz0hl92wJue7iexafUl Y1rQ== X-Gm-Message-State: AOAM533jfpgy8ymdUNzZEj0F4cXE36eRIFzpOR17Hnu5Eb6HidXGLDMd pXw1ew0O11n+h5ijzL5x+WkV/uOt8nzR5uGztYEONQ== X-Google-Smtp-Source: ABdhPJxjgaCTkVcsuVGglaPfAZXtOAa3ztmw6wM6ggRMFf1DI4xOOd4Bkak99KEX4rW77bs7qnBN4tc79sW8Wyszurk= X-Received: by 2002:a25:db88:: with SMTP id g130mr20706294ybf.193.1600085919205; Mon, 14 Sep 2020 05:18:39 -0700 (PDT) MIME-Version: 1.0 References: <20200910060403.144524-1-josephsih@chromium.org> <20200910140342.v3.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> <20200910081842.yunymr2l4fnle5nl@pali> In-Reply-To: <20200910081842.yunymr2l4fnle5nl@pali> From: Joseph Hwang <josephsih@google.com> Date: Mon, 14 Sep 2020 20:18:27 +0800 Message-ID: <CAHFy418Ln9ONHGVhg513g0v+GxUZMDtLpe5NFONO3HuAZz=r7g@mail.gmail.com> Subject: Re: [PATCH v3 1/2] Bluetooth: btusb: define HCI packet sizes of USB Alts To: =?UTF-8?Q?Pali_Roh=C3=A1r?= <pali@kernel.org> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, chromeos-bluetooth-upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.98 / 15.00 / 15.00 X-Rspamd-Queue-Id: D06A74086D X-Rspamd-UID: b5edfa On Thu, Sep 10, 2020 at 4:18 PM Pali Roh=C3=A1r <pali@kernel.org> wrote: > > On Thursday 10 September 2020 14:04:01 Joseph Hwang wrote: > > It is desirable to define the HCI packet payload sizes of > > USB alternate settings so that they can be exposed to user > > space. > > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > > --- > > > > Changes in v3: > > - Set hdev->sco_mtu to rp->sco_mtu if the latter is smaller. > > > > Changes in v2: > > - Used sco_mtu instead of a new sco_pkt_len member in hdev. > > - Do not overwrite hdev->sco_mtu in hci_cc_read_buffer_size > > if it has been set in the USB interface. > > > > drivers/bluetooth/btusb.c | 45 +++++++++++++++++++++++++++++---------- > > net/bluetooth/hci_event.c | 14 +++++++++++- > > 2 files changed, 47 insertions(+), 12 deletions(-) > > > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > > index fe80588c7bd3a8..651d5731a6c6cf 100644 > > --- a/drivers/bluetooth/btusb.c > > +++ b/drivers/bluetooth/btusb.c > > @@ -459,6 +459,24 @@ static const struct dmi_system_id btusb_needs_rese= t_resume_table[] =3D { > > #define BTUSB_WAKEUP_DISABLE 14 > > #define BTUSB_USE_ALT1_FOR_WBS 15 > > > > +/* Per core spec 5, vol 4, part B, table 2.1, > > + * list the hci packet payload sizes for various ALT settings. > > + * This is used to set the packet length for the wideband speech. > > + * If a controller does not probe its usb alt setting, the default > > + * value will be 0. Any clients at upper layers should interpret it > > + * as a default value and set a proper packet length accordingly. > > + * > > + * To calculate the HCI packet payload length: > > + * for alternate settings 1 - 5: > > + * hci_packet_size =3D suggested_max_packet_size * 3 (packets) - > > + * 3 (HCI header octets) > > + * for alternate setting 6: > > + * hci_packet_size =3D suggested_max_packet_size - 3 (HCI header o= ctets) > > + * where suggested_max_packet_size is {9, 17, 25, 33, 49, 63} > > + * for alt settings 1 - 6. > > Thank you for update, now I see what you mean! > > > + */ > > +static const int hci_packet_size_usb_alt[] =3D { 0, 24, 48, 72, 96, 14= 4, 60 }; > > Now the another question, why you are using hci_packet_size_usb_alt[1] > and hci_packet_size_usb_alt[6] values from this array? Will answer it per the spec in the next patch series. > > > + > > struct btusb_data { > > struct hci_dev *hdev; > > struct usb_device *udev; > > @@ -3959,6 +3977,15 @@ static int btusb_probe(struct usb_interface *int= f, > > hdev->notify =3D btusb_notify; > > hdev->prevent_wake =3D btusb_prevent_wake; > > > > + if (id->driver_info & BTUSB_AMP) { > > + /* AMP controllers do not support SCO packets */ > > + data->isoc =3D NULL; > > + } else { > > + /* Interface orders are hardcoded in the specification */ > > + data->isoc =3D usb_ifnum_to_if(data->udev, ifnum_base + 1= ); > > + data->isoc_ifnum =3D ifnum_base + 1; > > + } > > + > > #ifdef CONFIG_PM > > err =3D btusb_config_oob_wake(hdev); > > if (err) > > @@ -4022,6 +4049,10 @@ static int btusb_probe(struct usb_interface *int= f, > > hdev->set_diag =3D btintel_set_diag; > > hdev->set_bdaddr =3D btintel_set_bdaddr; > > hdev->cmd_timeout =3D btusb_intel_cmd_timeout; > > + > > + if (btusb_find_altsetting(data, 6)) > > + hdev->sco_mtu =3D hci_packet_size_usb_alt[6]; > > Why you are setting this sco_mtu only for Intel adapter? Is not this > whole code generic to USB? Please refer to the answer to the Realtek adapter below. Thanks. > > > + > > set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks)= ; > > set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); > > set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); > > @@ -4063,15 +4094,6 @@ static int btusb_probe(struct usb_interface *int= f, > > btusb_check_needs_reset_resume(intf); > > } > > > > - if (id->driver_info & BTUSB_AMP) { > > - /* AMP controllers do not support SCO packets */ > > - data->isoc =3D NULL; > > - } else { > > - /* Interface orders are hardcoded in the specification */ > > - data->isoc =3D usb_ifnum_to_if(data->udev, ifnum_base + 1= ); > > - data->isoc_ifnum =3D ifnum_base + 1; > > - } > > - > > if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) && > > (id->driver_info & BTUSB_REALTEK)) { > > hdev->setup =3D btrtl_setup_realtek; > > @@ -4083,9 +4105,10 @@ static int btusb_probe(struct usb_interface *int= f, > > * (DEVICE_REMOTE_WAKEUP) > > */ > > set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); > > - if (btusb_find_altsetting(data, 1)) > > + if (btusb_find_altsetting(data, 1)) { > > set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); > > - else > > + hdev->sco_mtu =3D hci_packet_size_usb_alt[1]; > > And this part of code which you write is Realtek specific. We currently only have Intel and Realtek platforms to test with. If making it generic without proper testing platforms is fine, I will make it generic. Or do you think it might be better to make it customized with particular vendors for now; and make it generic later when it works well with sufficient vendors? > > I thought that this is something generic to bluetooth usb as you pointed > to bluetooth documentation "core spec 5, vol 4, part B, table 2.1". > > > + } else > > bt_dev_err(hdev, "Device does not support ALT set= ting 1"); > > } > > Also this patch seems to be for me incomplete or not fully correct as > USB altsetting is chosen in function btusb_work() and it depends on > selected AIR mode (which is configured by another setsockopt). > > So despite what is written in commit message, this patch looks for me > like some hack for Intel and Realtek bluetooth adapters and does not > solve problems in vendor independent manner. You are right that sco_mtu should be changed according to the air mode. Here are some issues to handle and what I plan to do. I would like to solicit your comments before I submit the next series. [Issue 1] The air mode is determined in btusb_work() which is triggered by hci_sync_conn_complete_evt(). So =E2=80=9Cconn->mtu =3D hdev->sco_mtu=E2=80=9D should not be done in sco_conn_add() in the early connecting stage. Instead, it will be moved to near the end of hci_sync_conn_complete_evt(). [Issue 2] The btusb_work() is performed by a worker. There would be a timing issue here if we let btusb_work() to do =E2=80=9Chdev->sco_mtu =3D hci_packet_size_usb_alt[i]=E2=80=9D because there is no guarantee how soon = the btusb_work() can be finished and get =E2=80=9Chdev->sco_mtu=E2=80=9D value = set correctly. In order to avoid the potential race condition, I suggest to determine air_mode in btusb_notify() before schedule_work(&data->work) is executed so that =E2=80=9Chdev->sco_mtu =3D hci_packet_size_usb_alt[i]=E2=80=9D is guaranteed to be performed when btusb_notify() finished. In this way, hci_sync_conn_complete_evt() can set conn->mtu correctly as described in [Issue 1] above. [Issue 3] Concerning CVSD: The above flow is good when the transparent mode is selected. When it is the CVSD mode, we should set hdev->sco_mtu and conn->mtu back to the original mtu size returned by hci_cc_read_buffer_size(). This is because we do not have a reliable way to determine what size is used with CVSD. AFAIK, controllers connected through USB use 48 bytes; and controllers connected through UART use 60 bytes. It seems to me that these numbers are not recorded in the kernel(?). It seems beyond the scope of this patch to set the proper value for CVSD. So we will let hdev->sco_mtu and conn->mtu go back to their original values and are not affected by this patch. I am wondering if such directions of fixing this patch look good to you? Thanks and regards! Joseph --=20 Joseph Shyh-In Hwang Email: josephsih@google.com Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cEqVBSqxX1/GrgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 20:06:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id uKBtAiqxX1/HgAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 20:06:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B4B48A0B49; Mon, 14 Sep 2020 20:06:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725979AbgINSGW (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 14:06:22 -0400 Received: from netrider.rowland.org ([192.131.102.5]:47267 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1725957AbgINSGR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 14:06:17 -0400 Received: (qmail 972913 invoked by uid 1000); 14 Sep 2020 14:06:16 -0400 Date: Mon, 14 Sep 2020 14:06:16 -0400 From: Alan Stern <stern@rowland.harvard.edu> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH v3 04/11] USB: core: hub.c: use usb_control_msg_send() in a few places Message-ID: <20200914180616.GB972479@rowland.harvard.edu> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> <20200914153756.3412156-5-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200914153756.3412156-5-gregkh@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.14 / 15.00 / 15.00 X-Rspamd-Queue-Id: B4B48A0B49 X-Rspamd-UID: e8fd53 On Mon, Sep 14, 2020 at 05:37:49PM +0200, Greg Kroah-Hartman wrote: > There are a few calls to usb_control_msg() that can be converted to use > usb_control_msg_send() instead, so do that in order to make the error > checking a bit simpler and the code smaller. > > Cc: Alan Stern <stern@rowland.harvard.edu> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > --- > v3: > - drop change in usb_enable_link_state() as it was not needed now > thanks to review from Alan > - minor changes requested by checkpatch.pl > > v2: > - dropped changes to usb_req_set_sel() thanks to review from Alan > > drivers/usb/core/hub.c | 99 +++++++++++++++++------------------------- > 1 file changed, 40 insertions(+), 59 deletions(-) Reviewed-by: Alan Stern <stern@rowland.harvard.edu> Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sLnzAZG4X1/BNAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 20:38:09 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id cI8BO5C4X1/etgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 20:38:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4B77CA015F; Mon, 14 Sep 2020 20:38:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbgINShz (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 14:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbgINShu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 14:37:50 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0CC8C06174A; Mon, 14 Sep 2020 11:37:43 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id d6so298117pfn.9; Mon, 14 Sep 2020 11:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=cIjnkNboqpSpjKpr5bq8lUzIhrcoSiXnXhmqYN4ei3c=; b=AafhezfwbH68K+RdqYxFPc1vR/a0IPjGkG+E9FLkVV/sAW8WWA2tWv2LkHWbhH54eg aT6l3xw3ZSGubZ4Vn8U7NMCoaxBLUe+a7WDwDsTjTDF3Z70v2/SJWfdcAC16TIzj6w98 ssZ9YuPz7yaoVBPrzIsIOWSZt4Ua+hYjFqeWwSEUgVD3003lc0zQsOiN2WFufdp7OxMj S5ieMvoGp5u17M4Kr6xdPhx6qOItpgoYPviJq5c97rdWid5GiQoOqMgHrTHJJaxpr7yk khD2PorC+YRbeBtFTB172VG91hPad9ue00nFRfrgBhEkGxKV+ZbjUcPNnmorQZf0Iwuq 4q2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=cIjnkNboqpSpjKpr5bq8lUzIhrcoSiXnXhmqYN4ei3c=; b=jmMSv7VU3C/oM9eav8WGbyDZTSC0oHzsliBnpioAfFyjVcxqONdJomVj7mw7B66+73 b3txwADX4h6fsbha9Yo7aGYTfaNJkdq3e/QZZgjZybghrNVUUmD28ceWoIfq9gqi/73z 6aYOdEG0OkbkmRaPyLudItwgjZzmvq+rpXur6eduRiAtYSsMYuLXM9oCre5CyTq+Xbpm NQCbUw3vLRx3t24+rvOjYs9dbj/5+o/nGW17NnOi05tfyMwjzP4Gewh4M9fRXHDUtmum jCFD/lmRt6VPDKj44uw2i9ZLRXw+G+tdCtVSCltjQ/nhUWuKymnwXtcElmvSKfzX9YVm SLiw== X-Gm-Message-State: AOAM532THpfzrAmImm+2fjbudAR9wHsbxw1yAr8mxi2HU5eTvL+XagDH JyYlK7mPPsMzLLa2JgGXd2EtKTPG1LKpG/eL X-Google-Smtp-Source: ABdhPJxd+HIKMi83DPmS+Gm/5/k9uEYuw6a1koLz6/IjZhZtYPnN26smI7fZ5TQp37DTMyGAWcSAQg== X-Received: by 2002:a62:864e:: with SMTP id x75mr14212709pfd.60.1600108662974; Mon, 14 Sep 2020 11:37:42 -0700 (PDT) Received: from Thinkpad ([45.118.167.207]) by smtp.gmail.com with ESMTPSA id r144sm11769496pfc.63.2020.09.14.11.37.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 11:37:42 -0700 (PDT) Date: Tue, 15 Sep 2020 00:07:34 +0530 From: Anmol Karn <anmol.karan123@gmail.com> To: Dan Carpenter <dan.carpenter@oracle.com> Cc: marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, syzbot+0bef568258653cff272f@syzkaller.appspotmail.com Subject: Re: [Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer dereference in hci_event_packet() Message-ID: <20200914183734.GA213347@Thinkpad> References: <20200910043424.19894-1-anmol.karan123@gmail.com> <20200910104918.GF12635@kadam> <20200912091028.GA67109@Thinkpad> <20200914154405.GC18329@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200914154405.GC18329@kadam> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.88 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4B77CA015F X-Rspamd-UID: 45889a Hello Sir, > > I have looked into the Bisected logs and the problem occurs from this commit: > > > > 941992d29447 ("ethernet: amd: use IS_ENABLED() instead of checking for built-in or module") > > > > That's just the patch which made the code testable by syzbot. It didn't > introduce the bug. > > > > > Here is a diff of patch which i modified from last patch, > > > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > index 4b7fc430793c..6ce435064e0b 100644 > > --- a/net/bluetooth/hci_event.c > > +++ b/net/bluetooth/hci_event.c > > @@ -4936,6 +4936,12 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev, > > return; > > } > > > > + if (!hcon->amp_mgr) { > > + hci_conn_del(hcon); > > + hci_dev_unlock(hdev); > > I have no idea if calling hci_conn_del() is really the correct, thing. > I don't know the code at all. Anyway, do some research and figure out > for sure what the correct thing is. I have created my patch on the basis of the already applied conditions handling in this function, i.e whenever NULL dereference occurs, connection cleanup is required hence, hci_conn_del() is used here. Will see if anything else could be done. > > Also look for similar bugs in other places where hcon->amp_mgr is > dereferenced. For example, amp_read_loc_assoc_final_data() seems to > have a similar bug. > Sure sir will look into it. > regards, > dan carpenter > Thanks, Anmol Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WD0pFF3FX18Q5QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 21:32:45 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OGeqEF3FX1++6gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 21:32:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8DA65A0B10; Mon, 14 Sep 2020 21:32:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725964AbgINTci (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 15:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbgINTcg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 15:32:36 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA806C06174A for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 12:32:35 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id d189so1053396oig.12 for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 12:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=klkmiZuflFnynmQu7+bx3xxH+rD82oKvx4CnHuw6du8=; b=YdTd919WQh8TI0cn+Uzmz+bFN1nZce8+7WNgw+E1Bs55Nu8L4KOD7+V+KbZvp9xOrz ELDXsrHLnZk9UofBpEuiRCmvltjTdLBsggBKvpbieOX/rwnGMNiiD+K9pytP+u9EsSPU HS9D3yR7z1JZJPpi+AcmHIl1GUCKe3ZyT8314ZsmE/Mpq8wtWHjrgpdGfOds3sX8S/HL oWPsgJNB80+v3L66MICzTl4dOU+SRKSuoHy3+eXTLHZcvtVw39sWJXRCpKC7EkfvYMBh j1fOSWoZKMuZmJhoZURfyj2VyGMz28XWeyradUS0dMz3o5ZcmbL+iJHNQnX05KEcRpvH OTmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=klkmiZuflFnynmQu7+bx3xxH+rD82oKvx4CnHuw6du8=; b=OxhTS92x85wyhSg5jeN2kEK+21LKQwgvLFTmNs+LXfXHUxFj04A7JWMSwn7N5tPcN/ ajl248UirPOPa0OPz67gYA0UEfDdNvMsfpZfrhkwLf97Arp+KK001sWI0TEuDqP8WC0Q 7ha8wIxM5kLl9Ib1WLp2Yb3JiIPysukAvpn+NXHoYRhyYoq6qyym5JsgIBDzGrbBGi4t OIIP5h6uzKSEMTOdgXAwNniDViyaj5O16UL4RZ+OMZX+jZx5khuuouvaWYGte6BXFaX9 LlphEj5N0QxXEpYE8f+MlZTHDqH536asbzhvCbnVCvVfw7HLeH+kdbxoUCoZ3u2e9H8I 4BSw== X-Gm-Message-State: AOAM531mLxkhMJxlwQCG8WGjrYEkoVufxjJoPLgsnI1o8UXlyqZMyyxS Z+4En8iaj83Zu88ll2G4068VBz25s2XrBvS6iusXBMM7 X-Google-Smtp-Source: ABdhPJyekD3EXYCRh/p+frBYmg/6G54DO69AmFQOp2fEaA/l/IslSMOC12FdZv41ID3/2zqVW2sAG63JwgoIv3aFmD4= X-Received: by 2002:aca:a9c9:: with SMTP id s192mr626656oie.152.1600111954835; Mon, 14 Sep 2020 12:32:34 -0700 (PDT) MIME-Version: 1.0 References: <20200829000803.20286-1-tedd.an@intel.com> In-Reply-To: <20200829000803.20286-1-tedd.an@intel.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 14 Sep 2020 12:32:23 -0700 Message-ID: <CABBYNZ+sz2Gik0EEnA529igypkAYA_G+ZZo8bXh9ThZXOjvO8A@mail.gmail.com> Subject: Re: [V3 1/3] btp: Update connect event structure To: "An, Tedd" <tedd.an@intel.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.84 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8DA65A0B10 X-Rspamd-UID: 238a25 Hi Tedd, On Fri, Aug 28, 2020 at 5:12 PM <tedd.an@intel.com> wrote: > > From: Tedd Ho-Jeong An <tedd.an@intel.com> > > This patch updates the connect event struct to align withe the btp spec. > > Opcode 0x82 - Device Connected event > Controller Index: <controller id> > Event parameters: Address_Type (1 octet) > Address (6 octets) > Connection Interval (2 octets) > Connection Latency (2 octets) > Supervision Timeout (2 octets) > --- > src/shared/btp.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/src/shared/btp.h b/src/shared/btp.h > index f0ac3a1ee..cc71a71df 100644 > --- a/src/shared/btp.h > +++ b/src/shared/btp.h > @@ -259,6 +259,9 @@ struct btp_device_found_ev { > struct btp_gap_device_connected_ev { > uint8_t address_type; > bdaddr_t address; > + uint16_t connection_interval; > + uint16_t connection_latency; > + uint16_t supervision_timeout; > } __packed; > > #define BTP_EV_GAP_DEVICE_DISCONNECTED 0x83 > -- > 2.25.4 > Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SItPAPzIX1+rvQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 21:48:12 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0BoJOfvIX19r/AEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 21:48:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7BEFB40964; Mon, 14 Sep 2020 21:48:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725961AbgINTsE (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 15:48:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbgINTsC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 15:48:02 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CE31C06174A for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 12:48:02 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id n61so980489ota.10 for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 12:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Et2xm/t5C3XsheatROAc6iQ3qXz0y/UpsJtU8kvodnE=; b=BgisvXfIeMj8Z+EqvbV/F0KKMhKPVQjRmHMLdzbaX4jAZjNZQj2cV3icwToNmZPNyp KKQ6EJ5S7D6haLBgeMMdgu10hX+bd02UHs7lCC2eA1XJRFRGH7ChRNLrgQerbxSRJpV5 Ob5vsE7/Z7NwNsFYYmZr/8zh1zeBj+E1OyWpu8oEmbAFpKO0AYDnrN7spFZs6k1NrDzd QI1366Qv1YKoVAcWKTGbNJKCrwqJ+XmXgK/rKsxoeUYGPxZvARU1Q2VO4UVer2fXysNO U7K8JhUXLgMuYIlhfZu0dpKfq/XnldfTMOsBSu1zxp4LlgWKS38sKdKnzdG4nk06Ha62 5erw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Et2xm/t5C3XsheatROAc6iQ3qXz0y/UpsJtU8kvodnE=; b=gMVnUhssnsa4woPWJ1uvts4h+N5d3VcnVzQTPvt49H69Sks4FVo6M78FDpZmMf/2Aw t4dijSuHeAQIUEBHXh+yTISLiICvVcu/2m4WbZG2MN2dZn/nrDTpBaTyA1jcfObwF+CH EF1BjZVhRr1dS18Hz+/LiNW2m9axsLTId2LL3yP8YdCVx1nfYkxcOjTG0jHz0AQHwEx0 rrCt5qj6qGoTk1RePJx1hJL98bJcPvaVQadN6VjrXhbb+KYZo6pGmjUnxgi5ik78onsv ALys9chmJfnmcMnBcSDZijkcIwNbH8yEqd906rhWgJvAEBQfu0tgoMgGAaHW7Hty4ie2 5DdA== X-Gm-Message-State: AOAM530v6PSkqvuPRMjbQvXxmvDjaUHXMsV0cm2nQ2gMFbMyF1HBzIvd MPRy9UCOVP1fE+WJT2n8ZHRqSPJuXFu/8GN8kXA= X-Google-Smtp-Source: ABdhPJy+uMm43Lf54YVFeWtj+gBddmRwp0ixvotw+h6luorijEqjuQU4JDvMNhdNw5F+2V98ggZrbxSD9+nUiYjTQz0= X-Received: by 2002:a9d:4695:: with SMTP id z21mr10409735ote.91.1600112881654; Mon, 14 Sep 2020 12:48:01 -0700 (PDT) MIME-Version: 1.0 References: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> In-Reply-To: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 14 Sep 2020 12:47:50 -0700 Message-ID: <CABBYNZJeXkqmx1h85bxFBqJ4eDVfaPQJ9P1m_HApbJj48zT+_A@mail.gmail.com> Subject: Re: [BlueZ PATCH v5 1/8] adapter: Remove indirect dependency of headers To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.90 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7BEFB40964 X-Rspamd-UID: 537939 Hi Miao, On Fri, Sep 11, 2020 at 11:53 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > Given that adapter.h refers symbols from lib/bluetooth.h and lib/sdp.h, > these two headers should be included directly in adapter.h. > > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > --- > > (no changes since v1) > > src/adapter.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/src/adapter.h b/src/adapter.h > index f8ac20261..c70a7b0da 100644 > --- a/src/adapter.h > +++ b/src/adapter.h > @@ -26,6 +26,9 @@ > #include <dbus/dbus.h> > #include <glib.h> > > +#include <lib/bluetooth.h> > +#include <lib/sdp.h> > + > #define MAX_NAME_LENGTH 248 > > /* Invalid SSP passkey value used to indicate negative replies */ > -- > 2.26.2 Applied, thanks. Note that I did introduce a path to fix the build problem with g_dbus_proxy_get_path. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +BbqH87LX1/XTwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 22:00:14 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id wLbVHM7LX18jowEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 22:00:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E27F9A0B1A; Mon, 14 Sep 2020 22:00:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726022AbgINUAB (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 16:00:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725964AbgINT77 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 15:59:59 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B306C06174A for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 12:59:59 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id i17so1151708oig.10 for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 12:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zGN5I9LgHN+DhLe8/+o3YXmY2cN3FrYdeDnwLsEJz4Q=; b=IQu9R27Pw5uLu3gnj7q6zsiHQBgLSM9iMUCXQzvljntSFdn/yk4MRO9pwpsvsTRYLA Zfy6YQ4RiPXfu9IPkqL1dXAm5NlPpRird7HRT8dPLwI8/AXg1p+PxUxd2oz3bu+IBYtl b5jpeibX+Xd6ltITwL78JTvlcyKMOM9MxOIfWqcbzIVVEowYTObJvB+0GDNWMVeC1uaV hhQsZcrrRclyJ5cYQfQMcRrNz18ye6lEy+BRFtD2huP7JggiXbmrtma9X5umsH1JUD+o 5qAwhlWqUzOeyrBUf0W/Ckmi8oEJsqe5kHiwc+VHqTRQbf4tLLaztHi4mfSGw7KS2Tqk RpEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zGN5I9LgHN+DhLe8/+o3YXmY2cN3FrYdeDnwLsEJz4Q=; b=ay1xdSztSszyZRXIdiUyG+lBvd+xiOE4wY5EdY7TdHmph59Q1BOcdEVX61yHFByAWh DF/zDZ+49QKoMNLBIhH7aGi931V+Lp5JL3K1CqjNNIQ02bESIBqFblBcLUf0ykJKLai6 Igqd7yWBH1Dd5fYFNyqqzu0O1ltq3/CN6BVy3JVcH2PDO9OSX4E7HU7Ze0RJKNSf94Az 3hZfUjZbjyptyLNjYZwt/kuDiHJyfzBlAphlo1V5F9IoI6qmPMLAVA47qsJqFFHAJNb4 v0M08pxYTM9P3QyCL0fB8dJJZM9lUGg80DjFO9UwLtK+skE3TOoH7yIDlOXAKtyLMtnK GqpA== X-Gm-Message-State: AOAM530yjb6Ir5fcPHdg50neCDwBZ579eK9yEg6iEDLrreBNO0VbbPXo 5RK+6njfPg3jvKUkVpjefngUwvRnXT8ZJdkmbq8SWrny X-Google-Smtp-Source: ABdhPJza6u9FYFjtOGAUSZUNoOcT1KiUZD3544Ai50+TVGzs9ArpKuapy5KMzMIgGcyAca56J6t3u6ktmRUhv6RB63Y= X-Received: by 2002:aca:aad0:: with SMTP id t199mr691787oie.48.1600113598290; Mon, 14 Sep 2020 12:59:58 -0700 (PDT) MIME-Version: 1.0 References: <20200911223037.4127188-1-abhishekpandit@chromium.org> <20200911153010.Bluez.v4.1.Ib9712d2bf5d4b3f90c5bc835742aea8c7cd239e4@changeid> In-Reply-To: <20200911153010.Bluez.v4.1.Ib9712d2bf5d4b3f90c5bc835742aea8c7cd239e4@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 14 Sep 2020 12:59:47 -0700 Message-ID: <CABBYNZKk=tgUgF6UrYfGxS5fv9b9WBbFAo-iZiMe9z1OECJUEQ@mail.gmail.com> Subject: Re: [Bluez PATCH v4 1/4] adapter: Refactor kernel feature globals To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.85 / 15.00 / 15.00 X-Rspamd-Queue-Id: E27F9A0B1A X-Rspamd-UID: efb48a Hi Abhishek, On Fri, Sep 11, 2020 at 3:30 PM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Move all the kernel specific feature globals into a single > kernel_features bitfield and replace all uses with the bitfield instead. > --- > > Changes in v4: None > Changes in v3: None > Changes in v2: None > > src/adapter.c | 59 ++++++++++++++++++++++++++------------------------- > src/adapter.h | 9 ++++++++ > 2 files changed, 39 insertions(+), 29 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index 1435e2bd7..e700a78d5 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -116,13 +116,7 @@ static const struct mgmt_blocked_key_info blocked_keys[] = { > > static DBusConnection *dbus_conn = NULL; > > -static bool kernel_conn_control = false; > - > -static bool kernel_blocked_keys_supported = false; > - > -static bool kernel_set_system_config = false; > - > -static bool kernel_exp_features = false; > +static uint32_t kernel_features = 0; > > static GList *adapter_list = NULL; > static unsigned int adapter_remaining = 0; > @@ -678,7 +672,7 @@ static bool set_discoverable(struct btd_adapter *adapter, uint8_t mode, > > DBG("sending set mode command for index %u", adapter->dev_id); > > - if (kernel_conn_control) { > + if (has_kernel_features(KERNEL_CONN_CONTROL)) { > if (mode) > set_mode(adapter, MGMT_OP_SET_CONNECTABLE, mode); > else > @@ -1334,7 +1328,7 @@ static void trigger_passive_scanning(struct btd_adapter *adapter) > * no need to start any discovery. The kernel will keep scanning > * as long as devices are in its auto-connection list. > */ > - if (kernel_conn_control) > + if (has_kernel_features(KERNEL_CONN_CONTROL)) > return; > > /* > @@ -1385,7 +1379,7 @@ static void stop_passive_scanning_complete(uint8_t status, uint16_t length, > * no need to stop any discovery. The kernel will handle the > * auto-connection by itself. > */ > - if (kernel_conn_control) > + if (has_kernel_features(KERNEL_CONN_CONTROL)) > return; > > /* > @@ -2816,7 +2810,7 @@ static void property_set_mode_complete(uint8_t status, uint16_t length, > > static void clear_discoverable(struct btd_adapter *adapter) > { > - if (!kernel_conn_control) > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > return; > > if (!(adapter->current_settings & MGMT_SETTING_DISCOVERABLE)) > @@ -2876,7 +2870,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, > > break; > case MGMT_SETTING_DISCOVERABLE: > - if (kernel_conn_control) { > + if (has_kernel_features(KERNEL_CONN_CONTROL)) { > if (mode) { > set_mode(adapter, MGMT_OP_SET_CONNECTABLE, > mode); > @@ -4193,7 +4187,8 @@ static void load_default_system_params(struct btd_adapter *adapter) > size_t len = 0; > unsigned int err; > > - if (!main_opts.default_params.num_entries || !kernel_set_system_config) > + if (!main_opts.default_params.num_entries || > + !has_kernel_features(KERNEL_SET_SYSTEM_CONFIG)) > return; > > params = malloc0(sizeof(*params) * > @@ -4878,7 +4873,7 @@ int adapter_connect_list_add(struct btd_adapter *adapter, > * adapter_auto_connect_add() function is used to maintain what to > * connect. > */ > - if (kernel_conn_control) > + if (has_kernel_features(KERNEL_CONN_CONTROL)) > return 0; > > if (g_slist_find(adapter->connect_list, device)) { > @@ -4918,7 +4913,7 @@ void adapter_connect_list_remove(struct btd_adapter *adapter, > if (device == adapter->connect_le) > adapter->connect_le = NULL; > > - if (kernel_conn_control) > + if (has_kernel_features(KERNEL_CONN_CONTROL)) > return; > > if (!g_slist_find(adapter->connect_list, device)) { > @@ -4980,7 +4975,7 @@ void adapter_whitelist_add(struct btd_adapter *adapter, struct btd_device *dev) > { > struct mgmt_cp_add_device cp; > > - if (!kernel_conn_control) > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > return; > > memset(&cp, 0, sizeof(cp)); > @@ -5019,7 +5014,7 @@ void adapter_whitelist_remove(struct btd_adapter *adapter, struct btd_device *de > { > struct mgmt_cp_remove_device cp; > > - if (!kernel_conn_control) > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > return; > > memset(&cp, 0, sizeof(cp)); > @@ -5075,7 +5070,7 @@ void adapter_auto_connect_add(struct btd_adapter *adapter, > uint8_t bdaddr_type; > unsigned int id; > > - if (!kernel_conn_control) > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > return; > > if (g_slist_find(adapter->connect_list, device)) { > @@ -5147,7 +5142,7 @@ void adapter_set_device_wakeable(struct btd_adapter *adapter, > const bdaddr_t *bdaddr; > uint8_t bdaddr_type; > > - if (!kernel_conn_control) > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > return; > > bdaddr = device_get_address(device); > @@ -5224,7 +5219,7 @@ void adapter_auto_connect_remove(struct btd_adapter *adapter, > uint8_t bdaddr_type; > unsigned int id; > > - if (!kernel_conn_control) > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > return; > > if (!g_slist_find(adapter->connect_list, device)) { > @@ -6764,7 +6759,7 @@ connect_le: > * If kernel background scan is used then the kernel is > * responsible for connecting. > */ > - if (kernel_conn_control) > + if (has_kernel_features(KERNEL_CONN_CONTROL)) > return; > > /* > @@ -8964,7 +8959,7 @@ static int clear_devices(struct btd_adapter *adapter) > { > struct mgmt_cp_remove_device cp; > > - if (!kernel_conn_control) > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > return 0; > > memset(&cp, 0, sizeof(cp)); > @@ -9282,7 +9277,7 @@ static void read_info_complete(uint8_t status, uint16_t length, > (missing_settings & MGMT_SETTING_FAST_CONNECTABLE)) > set_mode(adapter, MGMT_OP_SET_FAST_CONNECTABLE, 0x01); > > - if (kernel_exp_features) > + if (has_kernel_features(KERNEL_EXP_FEATURES)) > read_exp_features(adapter); > > err = adapter_register(adapter); > @@ -9403,7 +9398,8 @@ static void read_info_complete(uint8_t status, uint16_t length, > > set_name(adapter, btd_adapter_get_name(adapter)); > > - if (kernel_blocked_keys_supported && !set_blocked_keys(adapter)) { > + if (has_kernel_features(KERNEL_BLOCKED_KEYS_SUPPORTED) && > + !set_blocked_keys(adapter)) { > btd_error(adapter->dev_id, > "Failed to set blocked keys for index %u", > adapter->dev_id); > @@ -9414,7 +9410,7 @@ static void read_info_complete(uint8_t status, uint16_t length, > !(adapter->current_settings & MGMT_SETTING_BONDABLE)) > set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01); > > - if (!kernel_conn_control) > + if (!has_kernel_features(KERNEL_CONN_CONTROL)) > set_mode(adapter, MGMT_OP_SET_CONNECTABLE, 0x01); > else if (adapter->current_settings & MGMT_SETTING_CONNECTABLE) > set_mode(adapter, MGMT_OP_SET_CONNECTABLE, 0x00); > @@ -9590,19 +9586,19 @@ static void read_commands_complete(uint8_t status, uint16_t length, > switch (op) { > case MGMT_OP_ADD_DEVICE: > DBG("enabling kernel-side connection control"); > - kernel_conn_control = true; > + kernel_features |= KERNEL_CONN_CONTROL; > break; > case MGMT_OP_SET_BLOCKED_KEYS: > DBG("kernel supports the set_blocked_keys op"); > - kernel_blocked_keys_supported = true; > + kernel_features |= KERNEL_BLOCKED_KEYS_SUPPORTED; > break; > case MGMT_OP_SET_DEF_SYSTEM_CONFIG: > DBG("kernel supports set system confic"); > - kernel_set_system_config = true; > + kernel_features |= KERNEL_SET_SYSTEM_CONFIG; > break; > case MGMT_OP_READ_EXP_FEATURES_INFO: > DBG("kernel supports exp features"); > - kernel_exp_features = true; > + kernel_features |= KERNEL_EXP_FEATURES; > break; > default: > break; > @@ -9768,3 +9764,8 @@ bool btd_le_connect_before_pairing(void) > > return false; > } > + > +bool has_kernel_features(uint32_t features) > +{ > + return !!(kernel_features & features); Don't think we need the !! here, the use () should already be enough, or change it to return (kernel_features & features) ? true : false; if you think that is more readable. > +} > diff --git a/src/adapter.h b/src/adapter.h > index f8ac20261..b0ed4915f 100644 > --- a/src/adapter.h > +++ b/src/adapter.h > @@ -233,3 +233,12 @@ void btd_adapter_for_each_device(struct btd_adapter *adapter, > void *data); > > bool btd_le_connect_before_pairing(void); > + > +enum kernel_features { > + KERNEL_CONN_CONTROL = 1 << 0, > + KERNEL_BLOCKED_KEYS_SUPPORTED = 1 << 1, > + KERNEL_SET_SYSTEM_CONFIG = 1 << 2, > + KERNEL_EXP_FEATURES = 1 << 3, > +}; > + > +bool has_kernel_features(uint32_t feature); > -- > 2.28.0.618.gf4bc123cb7-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OB6mKxrSX18m3QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 14 Sep 2020 22:27:06 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oMu7KBrSX1/5FgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 14 Sep 2020 22:27:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6F65040618; Mon, 14 Sep 2020 22:27:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726336AbgINU04 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 16:26:56 -0400 Received: from mga02.intel.com ([134.134.136.20]:26566 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbgINU0m (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 16:26:42 -0400 IronPort-SDR: qBdsz+KkdLea0NMLZUdVdqMUIsbDAZNRYfC8hbbk4xby1W5aF2V8JOlNjcrYvK+ZLCIgNvNenl pTo2qaL0SYRw== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="146847472" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="146847472" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 13:26:37 -0700 IronPort-SDR: yCkQfVz25Gwz7JvndaYWPnJxy6WpXPXBmH0iMFv5QOKrfLD3zXdbVOjcWUzKkPMajU4xDKvIjp A8PVIa7mUcAg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="306307503" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga006.jf.intel.com with ESMTP; 14 Sep 2020 13:26:36 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 14 Sep 2020 13:26:36 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 14 Sep 2020 13:26:36 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.170) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Mon, 14 Sep 2020 13:26:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z+oQNzHFLvobEM0uXu1U/BA6GkDobnpdKLaP/af5/UEbPLsHoxOURU72/NLyqFPkLBeP5dzjfE5orYbDpzs2RsRTKkYWqE7KRdMeQVdDmZKGA+w62FLUy1Zo6KXQ4CU1l/goxcWYoPoptnXZ18BY2l9hW2+klZ2JiSxSavyDDrV0KFKKlG4boVtLJDCovMlTNVx//FX2i0YEj4T+K8YohEUjNeFaPlojNzCnewlDL9HCMC0HB9FqwSobIT2+SYZ2DXRY7LsaMJ7OYr4utt6v5rQ4FDIGjgSx9D8LUr05fOkskPD31fj02sdswLir9auhqyyNq14tI6Two36kh3y/8w== 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-SenderADCheck; bh=05XU9X1DwqNXj1T7WQA8oZt+kjLQsOBzbOpfyZ1iCAQ=; b=Dvs92uUe9rzPVxbLyRd4zHTUQISDB6rB8W3JxTMSg9kkmDEvzKe5bgUb+5kqcdiVqsCrW9BTH/rxZ7WjfKfTsRwFz2XGF4Oi6thWkcpHC3AjhnvyGFNWR5aSutwLyMMfbNdeBiX5QYIIGmGaFdHEMJnkkQ5EGHpHwxE6wNmorPRuEzoT0Qm4YtHqIFZGQuPo4RMffMJcLpnTmG+ZtTgh6R82LgTgQ5k8TuY0JIlvp0fJhIce548SAxLhgCe7md6Zpx3bO+DhtAN2ittskEwSg8A4dVv9BGEx/R6YXZOStL7ACpAA7rScgs5i1ZFj2p2xZqIz9Ofc0WhRuyJBHT9gRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=05XU9X1DwqNXj1T7WQA8oZt+kjLQsOBzbOpfyZ1iCAQ=; b=Tp3u9yAFufxPKXqVrE0ug7FfMT2z28cCZomsqMoKw4sFpLBfB8bbAzOMl55zdzh7nPg6rGnwcMDWtlf6T/z62PvS8PFtoCueX0pJUp9YbwLNxMb6ncuWPDliyDADhVVlAAXu9y4VFSsLT6fEGA1QtsJ3KRMVtcOgD8klmmqYFCQ= Received: from MW3PR11MB4748.namprd11.prod.outlook.com (2603:10b6:303:2e::9) by MWHPR11MB1357.namprd11.prod.outlook.com (2603:10b6:300:2b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Mon, 14 Sep 2020 20:26:34 +0000 Received: from MW3PR11MB4748.namprd11.prod.outlook.com ([fe80::243f:4543:6dfd:ff22]) by MW3PR11MB4748.namprd11.prod.outlook.com ([fe80::243f:4543:6dfd:ff22%4]) with mapi id 15.20.3348.016; Mon, 14 Sep 2020 20:26:34 +0000 From: "An, Tedd" <tedd.an@intel.com> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>, Tedd Ho-Jeong An <tedd.an@linux.intel.com> CC: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Subject: Re: [BlueZ 13/17] plugins: Add SPDX License Identifer Thread-Topic: [BlueZ 13/17] plugins: Add SPDX License Identifer Thread-Index: AQHWiM1eQSpy2EkukUmtVvat2FRFBaloaIoA//+7LoA= Date: Mon, 14 Sep 2020 20:26:34 +0000 Message-ID: <A8434ACD-6E35-4A52-93ED-64FC110AF335@intel.com> References: <20200912062357.23926-1-tedd.an@linux.intel.com> <20200912062357.23926-14-tedd.an@linux.intel.com> <CABBYNZLiUJi8qZnZgBAMGwu8bKM1RoeiDcjZ5AK6jfWJ7ShTpw@mail.gmail.com> In-Reply-To: <CABBYNZLiUJi8qZnZgBAMGwu8bKM1RoeiDcjZ5AK6jfWJ7ShTpw@mail.gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/16.40.20081000 authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [73.164.224.32] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4101810a-1ee7-4b30-babc-08d858ec797b x-ms-traffictypediagnostic: MWHPR11MB1357: x-microsoft-antispam-prvs: <MWHPR11MB13572CD73CA9C93528D89CA2FF230@MWHPR11MB1357.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:5236; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WrBmDvH/C+psnjJ5ufHcELC/6l2uOPGeDz/antonmMlUVpcului8Bp5/SAj6RDe8awl8JZviP4zWAUzV0jk404gsN4FKU1B6GTWaASB8jsVBagSKEgKrylDPk3+X0bwJtQ/s1JvufnaprhdIMS6H8d4/7mbkgII+2sqe92u5UIEXphgKP9zYRIOSaaiM1M/9dqdy/2bXZBo6yeKFStvnLDSWhfVINu1TPmYddQSzHga+Z2I6dHCLCTAKzyFBAbPnFuateDY6ywgZe3OdqCOmzRL/8gvJ952V9OfGksA6skoZDzDMcvwsfXq0kn4ojt47xON+BimMla1NAkx7SJHhoQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4748.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(346002)(366004)(39860400002)(110136005)(6506007)(8676002)(5660300002)(71200400001)(66476007)(83380400001)(76116006)(66446008)(64756008)(66556008)(66946007)(2616005)(26005)(6486002)(478600001)(4326008)(186003)(316002)(33656002)(86362001)(36756003)(2906002)(8936002)(53546011)(6512007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: wQYSRMotFhFCLtYTiBR4Paxq2Wn0E/kA3lxjfu1FdQiQMuJRtXFZurhLTQ/B0Y1UY9U9g6MLdLH6DLaplyTchGSP+cFNqwaGpd1yCDwecYWS1V5/Pm5AJtVJJ/81JFPRg3yxH9d4pwvkx/6K/DqyxAvgM4KqgmNBjaAMCe8F8tqkknQqFITX6UBRkWDy8vY3VWcb/LhsNpkmvtJsVSZxg+x1dy+9repFQJYaK2atwGjwXW4Y92jg7pUzE/zV0XXy+p89e1Cbb4oF7u2WKO1WOIsFrj/XhpkKyAZhAOe2MKffe+SyBKckMU3aQh3p83bUd6MIAQ/PBA+hqPMStOxyFkSPYRRYWnfuJ2ssx6TD6yDTwhGMX0IqUp7rObdFt6273cAOv9kxhR6imJau2A5wFFKcU/OS2vL0wBOjltaGrzaQqfI/xIiKI8+C/ue159T6hC6cDsg85h/pxq1CXOtxa1jnwF5t31BySHqLJM9vMM6Qf1xdoSD4RFT6t1NGYOoIDA+jILMccDr17Ke2FZR2pFZvWxiOpFc54o5/00Dp6i0evBjD1Hns3yXHWhw1krFSdtGyRbrydtyarZUnPopNBWEuvHFKcm3vhzgoAUt7KYCiYZSab5KYb7FjTJpAET5y/dICFlyMbx8gKsvnIMrx9g== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="utf-8" Content-ID: <E40F3A3FA23B9E4985E100B5D0510399@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4748.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4101810a-1ee7-4b30-babc-08d858ec797b X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Sep 2020 20:26:34.6075 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 6jDKwEH7eekJwodaLML0Ye2j0SX0mpQdwvtLcc6fbm9KVL0ILitSTUroNZUVFklaB7lnCnTTqydGrgcL/E+m6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1357 X-OriginatorOrg: intel.com Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.73 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6F65040618 X-Rspamd-UID: 20332d SGkgTHVpeiwNCg0KSSByZWFsaXplZCB0aGF0IHRoZXJlIGlzIG5vIEdQTCAyLjEgb3IgbGF0ZXIu DQoNCk9ubHkgZm9yIExHUEwgMi4xIG9yIGxhdGVyLi4uDQpJIHdpbGwga2VlcCBhcyBpcy4NCg0K UmVnYXJkcywNClRlZGQNCg0K77u/T24gOS8xNC8yMCwgMTA6MzMgQU0sICJMdWl6IEF1Z3VzdG8g dm9uIERlbnR6IiA8bHVpei5kZW50ekBnbWFpbC5jb20+IHdyb3RlOg0KDQogICAgSGkgVGVkZCwN Cg0KICAgIE9uIEZyaSwgU2VwIDExLCAyMDIwIGF0IDExOjQxIFBNIDx0ZWRkLmFuQGxpbnV4Lmlu dGVsLmNvbT4gd3JvdGU6DQogICAgPg0KICAgID4gRnJvbTogVGVkZCBIby1KZW9uZyBBbiA8dGVk ZC5hbkBpbnRlbC5jb20+DQogICAgPg0KICAgID4gVGhpcyBwYXRjaCBhZGRzIFNQRFggTGljZW5z ZSBJZGVudGlmaWVyLg0KICAgID4NCiAgICA+IC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0NCiAgICA+ICAgICAgICBMaWNlbnNlICAgICAgICAgICAgQ09VTlQNCiAgICA+IC0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0NCiAgICA+ICBHUEwtMi4wLW9yLWxh dGVyICAgICA6ICAgICAgNw0KDQogICAgSSBndWVzcyBhbGwgR1BMIDIuMCBvciBsYXRlciBjYW4g YmUgdXBkYXRlZCB0byBHUEwgMi4xIG9yIGxhdGVyLg0KDQogICAgPiBMaWNlbnNlOiBHUEwtMi4w LW9yLWxhdGVyDQogICAgPiAgICBwbHVnaW5zL2F1dG9wYWlyLmMNCiAgICA+ICAgIHBsdWdpbnMv aG9zdG5hbWUuYw0KICAgID4gICAgcGx1Z2lucy9uZWFyZC5jDQogICAgPiAgICBwbHVnaW5zL3Bv bGljeS5jDQogICAgPiAgICBwbHVnaW5zL3NpeGF4aXMuYw0KICAgID4gICAgcGx1Z2lucy93aWlt b3RlLmMNCiAgICA+ICAgIHBsdWdpbnMvZXh0ZXJuYWwtZHVtbXkuYw0KICAgID4gLS0tDQogICAg PiAgcGx1Z2lucy9hdXRvcGFpci5jICAgICAgIHwgMSArDQogICAgPiAgcGx1Z2lucy9leHRlcm5h bC1kdW1teS5jIHwgMSArDQogICAgPiAgcGx1Z2lucy9ob3N0bmFtZS5jICAgICAgIHwgMSArDQog ICAgPiAgcGx1Z2lucy9uZWFyZC5jICAgICAgICAgIHwgMSArDQogICAgPiAgcGx1Z2lucy9wb2xp Y3kuYyAgICAgICAgIHwgMSArDQogICAgPiAgcGx1Z2lucy9zaXhheGlzLmMgICAgICAgIHwgMSAr DQogICAgPiAgcGx1Z2lucy93aWltb3RlLmMgICAgICAgIHwgMSArDQogICAgPiAgNyBmaWxlcyBj aGFuZ2VkLCA3IGluc2VydGlvbnMoKykNCiAgICA+DQogICAgPiBkaWZmIC0tZ2l0IGEvcGx1Z2lu cy9hdXRvcGFpci5jIGIvcGx1Z2lucy9hdXRvcGFpci5jDQogICAgPiBpbmRleCAzMDg5NDMwYTgu LjM4MWQ5MWM4ZiAxMDA2NDQNCiAgICA+IC0tLSBhL3BsdWdpbnMvYXV0b3BhaXIuYw0KICAgID4g KysrIGIvcGx1Z2lucy9hdXRvcGFpci5jDQogICAgPiBAQCAtMSwzICsxLDQgQEANCiAgICA+ICsv LyBTUERYLUxpY2Vuc2UtSWRlbnRpZmllcjogR1BMLTIuMC1vci1sYXRlcg0KDQogICAgV2h5IGFy ZSB5b3UgdXNpbmcgQysrIC8vIGNvbW1lbnRzIG9uIHRoZSAuYyBmaWxlcyBhbmQgLyogKi8gY29t bWVudHMNCiAgICBvbiAuaD8gQWxzbyBpdCBsb29rcyBsaWtlIHlvdSBhcmUga2VlcGluZyB0aGUg b2xkIGxpY2Vuc2UgdGV4dCB3aGljaA0KICAgIHNob3VsZCBubyBsb25nZXIgYmUgbmVjZXNzYXJ5 Lg0KDQogICAgPiAgLyoNCiAgICA+ICAgKg0KICAgID4gICAqICBCbHVlWiAtIEJsdWV0b290aCBw cm90b2NvbCBzdGFjayBmb3IgTGludXgNCiAgICA+IGRpZmYgLS1naXQgYS9wbHVnaW5zL2V4dGVy bmFsLWR1bW15LmMgYi9wbHVnaW5zL2V4dGVybmFsLWR1bW15LmMNCiAgICA+IGluZGV4IDUzNmFk MDY2My4uNzgzNzdiMDIxIDEwMDY0NA0KICAgID4gLS0tIGEvcGx1Z2lucy9leHRlcm5hbC1kdW1t eS5jDQogICAgPiArKysgYi9wbHVnaW5zL2V4dGVybmFsLWR1bW15LmMNCiAgICA+IEBAIC0xLDMg KzEsNCBAQA0KICAgID4gKy8vIFNQRFgtTGljZW5zZS1JZGVudGlmaWVyOiBHUEwtMi4wLW9yLWxh dGVyDQogICAgPiAgLyoNCiAgICA+ICAgKg0KICAgID4gICAqICBCbHVlWiAtIEJsdWV0b290aCBw cm90b2NvbCBzdGFjayBmb3IgTGludXgNCiAgICA+IGRpZmYgLS1naXQgYS9wbHVnaW5zL2hvc3Ru YW1lLmMgYi9wbHVnaW5zL2hvc3RuYW1lLmMNCiAgICA+IGluZGV4IDRmOWRmZTZkOC4uMzJmMTVi M2E1IDEwMDY0NA0KICAgID4gLS0tIGEvcGx1Z2lucy9ob3N0bmFtZS5jDQogICAgPiArKysgYi9w bHVnaW5zL2hvc3RuYW1lLmMNCiAgICA+IEBAIC0xLDMgKzEsNCBAQA0KICAgID4gKy8vIFNQRFgt TGljZW5zZS1JZGVudGlmaWVyOiBHUEwtMi4wLW9yLWxhdGVyDQogICAgPiAgLyoNCiAgICA+ICAg Kg0KICAgID4gICAqICBCbHVlWiAtIEJsdWV0b290aCBwcm90b2NvbCBzdGFjayBmb3IgTGludXgN CiAgICA+IGRpZmYgLS1naXQgYS9wbHVnaW5zL25lYXJkLmMgYi9wbHVnaW5zL25lYXJkLmMNCiAg ICA+IGluZGV4IDZmZmNkNmUxMC4uMWZlZmM1MDE1IDEwMDY0NA0KICAgID4gLS0tIGEvcGx1Z2lu cy9uZWFyZC5jDQogICAgPiArKysgYi9wbHVnaW5zL25lYXJkLmMNCiAgICA+IEBAIC0xLDMgKzEs NCBAQA0KICAgID4gKy8vIFNQRFgtTGljZW5zZS1JZGVudGlmaWVyOiBHUEwtMi4wLW9yLWxhdGVy DQogICAgPiAgLyoNCiAgICA+ICAgKg0KICAgID4gICAqICBCbHVlWiAtIEJsdWV0b290aCBwcm90 b2NvbCBzdGFjayBmb3IgTGludXgNCiAgICA+IGRpZmYgLS1naXQgYS9wbHVnaW5zL3BvbGljeS5j IGIvcGx1Z2lucy9wb2xpY3kuYw0KICAgID4gaW5kZXggZGU1MWU1OGI5Li44NmViMjVlZTkgMTAw NjQ0DQogICAgPiAtLS0gYS9wbHVnaW5zL3BvbGljeS5jDQogICAgPiArKysgYi9wbHVnaW5zL3Bv bGljeS5jDQogICAgPiBAQCAtMSwzICsxLDQgQEANCiAgICA+ICsvLyBTUERYLUxpY2Vuc2UtSWRl bnRpZmllcjogR1BMLTIuMC1vci1sYXRlcg0KICAgID4gIC8qDQogICAgPiAgICoNCiAgICA+ICAg KiAgQmx1ZVogLSBCbHVldG9vdGggcHJvdG9jb2wgc3RhY2sgZm9yIExpbnV4DQogICAgPiBkaWZm IC0tZ2l0IGEvcGx1Z2lucy9zaXhheGlzLmMgYi9wbHVnaW5zL3NpeGF4aXMuYw0KICAgID4gaW5k ZXggOTM5ZmVkNzU5Li44MzUwZDYzZjggMTAwNjQ0DQogICAgPiAtLS0gYS9wbHVnaW5zL3NpeGF4 aXMuYw0KICAgID4gKysrIGIvcGx1Z2lucy9zaXhheGlzLmMNCiAgICA+IEBAIC0xLDMgKzEsNCBA QA0KICAgID4gKy8vIFNQRFgtTGljZW5zZS1JZGVudGlmaWVyOiBHUEwtMi4wLW9yLWxhdGVyDQog ICAgPiAgLyoNCiAgICA+ICAgKg0KICAgID4gICAqICBCbHVlWiAtIEJsdWV0b290aCBwcm90b2Nv bCBzdGFjayBmb3IgTGludXgNCiAgICA+IGRpZmYgLS1naXQgYS9wbHVnaW5zL3dpaW1vdGUuYyBi L3BsdWdpbnMvd2lpbW90ZS5jDQogICAgPiBpbmRleCAwY2VkMjc1MTQuLjk0NDFhNzY4MSAxMDA2 NDQNCiAgICA+IC0tLSBhL3BsdWdpbnMvd2lpbW90ZS5jDQogICAgPiArKysgYi9wbHVnaW5zL3dp aW1vdGUuYw0KICAgID4gQEAgLTEsMyArMSw0IEBADQogICAgPiArLy8gU1BEWC1MaWNlbnNlLUlk ZW50aWZpZXI6IEdQTC0yLjAtb3ItbGF0ZXINCiAgICA+ICAvKg0KICAgID4gICAqDQogICAgPiAg ICogIEJsdWVaIC0gQmx1ZXRvb3RoIHByb3RvY29sIHN0YWNrIGZvciBMaW51eA0KICAgID4gLS0N CiAgICA+IDIuMjUuNA0KICAgID4NCg0KDQogICAgLS0gDQogICAgTHVpeiBBdWd1c3RvIHZvbiBE ZW50eg0KDQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8PKVCUkFYF/jTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:05:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id WEA+BkkFYF9UzQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:05:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 083C0A0B10; Tue, 15 Sep 2020 02:05:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726043AbgIOAFT (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:19 -0400 Received: from mga05.intel.com ([192.55.52.43]:46783 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbgIOAFS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:18 -0400 IronPort-SDR: RhVHztxvHBf4sW9M2kEBYmnh7ck/Q74cLXQ6g5Coeurj3oVa8tZPmMs8Gzexu6Wtw32eWvcgGE Xc/dAAOkp+jQ== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="244009334" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="244009334" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:12 -0700 IronPort-SDR: VFRpicknkIgqge/RR/4u31kNZgd+luG9tu8b8d0cTIZGNkkkj9CHUkmDF/NrUkChcV/M2syD0o THPy+BcpAJ+g== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333086" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:12 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 00/17] Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:40 -0700 Message-Id: <20200915000457.22988-1-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.54 / 15.00 / 15.00 X-Rspamd-Queue-Id: 083C0A0B10 X-Rspamd-UID: f0d225 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch series adds SPDX License Identifier to the source/heade files based on the existing license header and removes the license text. The SDPX License Identifier is added in form of a comment based on file type with the same rule from the Linxu kernel source, and added to the first line of the file. C source: // SPDX-License-Identifer: <License> C header: /* SPDX-License-Identifer: <License> */ For SPDX-License Identifier, it used the identifer from the SPDX License list page(https://spdx.org/licenses). For the summary, currently BlueZ sources have following licenses: ------------------------------------------- License File Count ------------------------------------------- GPL-2.0-or-later : 393 LGPL-2.1-or-later : 273 BSD-2-Clause : 3 GPL-2.0-only : 5 MIT : 2 Apache-2.0 : 80 N/A : 1325 Note that N/A includes the following files/folders - .git/ - doc/ - Build related files (Makefile, etc) - Configuration files - Test scripts (python, etc) Tedd Ho-Jeong An (17): android: Add SPDX License Identifier attrib: Add SPDX License Identifier btio: Add SPDX License Identifier client: Add SPDX License Identifier emulator: Add SPDX License Identifier gdbus: Add SPDX License Identifier gobex: Add SPDX License Identifier lib: Add SPDX License Identifier mesh: Add SPDX License Identifier monitor: Add SPDX License Identifier obexd: Add SPDX License Identifier peripheral: Add SPDX License Identifier plugins: Add SPDX License Identifier profiles: Add SPDX License Identifier unit: Add SPDX License Identifier src: Add SPDX License Identifier tools: Add SPDX License Identifier android/a2dp-sink.c | 15 +-------------- android/a2dp-sink.h | 15 +-------------- android/a2dp.c | 15 +-------------- android/a2dp.h | 15 +-------------- android/audio-msg.h | 15 +-------------- android/audio_utils/resampler.c | 12 +----------- android/audio_utils/resampler.h | 12 +----------- android/avctp.c | 15 +-------------- android/avctp.h | 15 +-------------- android/avdtp.c | 15 +-------------- android/avdtp.h | 15 +-------------- android/avdtptest.c | 15 +-------------- android/avrcp-lib.c | 15 +-------------- android/avrcp-lib.h | 15 +-------------- android/avrcp.c | 15 +-------------- android/avrcp.h | 15 +-------------- android/bluetooth.c | 15 +-------------- android/bluetooth.h | 15 +-------------- android/bluetoothd-snoop.c | 15 +-------------- android/bluetoothd-wrapper.c | 13 +------------ android/client/haltest.c | 13 +------------ android/client/history.c | 13 +------------ android/client/history.h | 13 +------------ android/client/if-audio.c | 13 +------------ android/client/if-av-sink.c | 13 +------------ android/client/if-av.c | 13 +------------ android/client/if-bt.c | 13 +------------ android/client/if-gatt.c | 13 +------------ android/client/if-hf-client.c | 13 +------------ android/client/if-hf.c | 13 +------------ android/client/if-hh.c | 13 +------------ android/client/if-hl.c | 13 +------------ android/client/if-main.h | 13 +------------ android/client/if-mce.c | 13 +------------ android/client/if-pan.c | 13 +------------ android/client/if-rc-ctrl.c | 13 +------------ android/client/if-rc.c | 13 +------------ android/client/if-sco.c | 13 +------------ android/client/if-sock.c | 13 +------------ android/client/pollhandler.c | 13 +------------ android/client/pollhandler.h | 13 +------------ android/client/tabcompletion.c | 13 +------------ android/client/terminal.c | 13 +------------ android/client/terminal.h | 13 +------------ android/compat/readline/history.h | 15 +-------------- android/compat/readline/readline.h | 15 +-------------- android/compat/wordexp.h | 15 +-------------- android/cutils/properties.h | 15 +-------------- android/gatt.c | 15 +-------------- android/gatt.h | 15 +-------------- android/hal-a2dp-sink.c | 13 +------------ android/hal-a2dp.c | 13 +------------ android/hal-audio-aptx.c | 13 +------------ android/hal-audio-sbc.c | 13 +------------ android/hal-audio.c | 13 +------------ android/hal-audio.h | 13 +------------ android/hal-avrcp-ctrl.c | 13 +------------ android/hal-avrcp.c | 13 +------------ android/hal-bluetooth.c | 13 +------------ android/hal-gatt.c | 13 +------------ android/hal-handsfree-client.c | 13 +------------ android/hal-handsfree.c | 13 +------------ android/hal-health.c | 13 +------------ android/hal-hidhost.c | 13 +------------ android/hal-ipc.c | 13 +------------ android/hal-ipc.h | 13 +------------ android/hal-log.h | 13 +------------ android/hal-map-client.c | 13 +------------ android/hal-msg.h | 15 +-------------- android/hal-pan.c | 13 +------------ android/hal-sco.c | 13 +------------ android/hal-socket.c | 13 +------------ android/hal-utils.c | 13 +------------ android/hal-utils.h | 13 +------------ android/hal.h | 13 +------------ android/handsfree-client.c | 15 +-------------- android/handsfree-client.h | 15 +-------------- android/handsfree.c | 15 +-------------- android/handsfree.h | 15 +-------------- android/hardware/audio.h | 12 +----------- android/hardware/audio_effect.h | 12 +----------- android/hardware/bluetooth.h | 12 +----------- android/hardware/bt_av.h | 12 +----------- android/hardware/bt_gatt.h | 12 +----------- android/hardware/bt_gatt_client.h | 12 +----------- android/hardware/bt_gatt_server.h | 12 +----------- android/hardware/bt_gatt_types.h | 12 +----------- android/hardware/bt_hf.h | 12 +----------- android/hardware/bt_hf_client.h | 12 +----------- android/hardware/bt_hh.h | 12 +----------- android/hardware/bt_hl.h | 12 +----------- android/hardware/bt_mce.h | 12 +----------- android/hardware/bt_pan.h | 12 +----------- android/hardware/bt_rc.h | 12 +----------- android/hardware/bt_sock.h | 12 +----------- android/hardware/hardware.c | 12 +----------- android/hardware/hardware.h | 12 +----------- android/health.c | 15 +-------------- android/health.h | 15 +-------------- android/hidhost.c | 15 +-------------- android/hidhost.h | 15 +-------------- android/ipc-common.h | 15 +-------------- android/ipc-tester.c | 15 +-------------- android/ipc.c | 15 +-------------- android/ipc.h | 15 +-------------- android/log.c | 15 +-------------- android/main.c | 15 +-------------- android/map-client.c | 15 +-------------- android/map-client.h | 15 +-------------- android/pan.c | 15 +-------------- android/pan.h | 15 +-------------- android/sco-msg.h | 15 +-------------- android/sco.c | 15 +-------------- android/sco.h | 15 +-------------- android/socket.c | 15 +-------------- android/socket.h | 15 +-------------- android/system-emulator.c | 15 +-------------- android/system/audio.h | 12 +----------- android/test-ipc.c | 15 +-------------- android/tester-a2dp.c | 13 +------------ android/tester-avrcp.c | 13 +------------ android/tester-bluetooth.c | 13 +------------ android/tester-gatt.c | 13 +------------ android/tester-hdp.c | 13 +------------ android/tester-hidhost.c | 13 +------------ android/tester-main.c | 13 +------------ android/tester-main.h | 15 +-------------- android/tester-map-client.c | 13 +------------ android/tester-pan.c | 13 +------------ android/tester-socket.c | 13 +------------ android/utils.h | 15 +-------------- attrib/att-database.h | 15 +-------------- attrib/att.c | 15 +-------------- attrib/att.h | 15 +-------------- attrib/gatt-service.c | 15 +-------------- attrib/gatt-service.h | 15 +-------------- attrib/gatt.c | 15 +-------------- attrib/gatt.h | 15 +-------------- attrib/gattrib.c | 15 +-------------- attrib/gattrib.h | 15 +-------------- attrib/gatttool.c | 15 +-------------- attrib/gatttool.h | 15 +-------------- attrib/interactive.c | 15 +-------------- attrib/utils.c | 15 +-------------- btio/btio.c | 15 +-------------- btio/btio.h | 15 +-------------- client/advertising.c | 15 +-------------- client/advertising.h | 15 +-------------- client/agent.c | 15 +-------------- client/agent.h | 15 +-------------- client/display.c | 15 +-------------- client/display.h | 15 +-------------- client/gatt.c | 15 +-------------- client/gatt.h | 15 +-------------- client/main.c | 15 +-------------- emulator/amp.c | 15 +-------------- emulator/amp.h | 15 +-------------- emulator/b1ee.c | 15 +-------------- emulator/btdev.c | 15 +-------------- emulator/btdev.h | 15 +-------------- emulator/bthost.c | 15 +-------------- emulator/bthost.h | 15 +-------------- emulator/hciemu.c | 15 +-------------- emulator/hciemu.h | 15 +-------------- emulator/hfp.c | 15 +-------------- emulator/le.c | 15 +-------------- emulator/le.h | 15 +-------------- emulator/main.c | 15 +-------------- emulator/phy.c | 15 +-------------- emulator/phy.h | 15 +-------------- emulator/serial.c | 15 +-------------- emulator/serial.h | 15 +-------------- emulator/server.c | 15 +-------------- emulator/server.h | 15 +-------------- emulator/smp.c | 15 +-------------- emulator/vhci.c | 15 +-------------- emulator/vhci.h | 15 +-------------- gdbus/client.c | 15 +-------------- gdbus/gdbus.h | 15 +-------------- gdbus/mainloop.c | 15 +-------------- gdbus/object.c | 15 +-------------- gdbus/polkit.c | 15 +-------------- gdbus/watch.c | 15 +-------------- gobex/gobex-apparam.c | 15 +-------------- gobex/gobex-apparam.h | 15 +-------------- gobex/gobex-debug.h | 15 +-------------- gobex/gobex-defs.c | 15 +-------------- gobex/gobex-defs.h | 15 +-------------- gobex/gobex-header.c | 15 +-------------- gobex/gobex-header.h | 15 +-------------- gobex/gobex-packet.c | 15 +-------------- gobex/gobex-packet.h | 15 +-------------- gobex/gobex-transfer.c | 15 +-------------- gobex/gobex.c | 15 +-------------- gobex/gobex.h | 15 +-------------- lib/a2mp.h | 15 +-------------- lib/amp.h | 10 +--------- lib/bluetooth.c | 15 +-------------- lib/bluetooth.h | 15 +-------------- lib/bnep.h | 15 +-------------- lib/cmtp.h | 15 +-------------- lib/hci.c | 15 +-------------- lib/hci.h | 15 +-------------- lib/hci_lib.h | 15 +-------------- lib/hidp.h | 15 +-------------- lib/l2cap.h | 15 +-------------- lib/mgmt.h | 15 +-------------- lib/rfcomm.h | 15 +-------------- lib/sco.h | 15 +-------------- lib/sdp.c | 15 +-------------- lib/sdp.h | 15 +-------------- lib/sdp_lib.h | 15 +-------------- lib/uuid.c | 15 +-------------- lib/uuid.h | 15 +-------------- mesh/agent.c | 11 +---------- mesh/agent.h | 11 +---------- mesh/appkey.c | 11 +---------- mesh/appkey.h | 11 +---------- mesh/cfgmod-server.c | 11 +---------- mesh/cfgmod.h | 11 +---------- mesh/crypto.c | 11 +---------- mesh/crypto.h | 11 +---------- mesh/dbus.c | 11 +---------- mesh/dbus.h | 11 +---------- mesh/error.h | 11 +---------- mesh/friend.c | 11 +---------- mesh/friend.h | 11 +---------- mesh/keyring.c | 11 +---------- mesh/keyring.h | 11 +---------- mesh/main.c | 11 +---------- mesh/manager.c | 11 +---------- mesh/manager.h | 11 +---------- mesh/mesh-config-json.c | 11 +---------- mesh/mesh-config.h | 11 +---------- mesh/mesh-defs.h | 12 +----------- mesh/mesh-io-api.h | 11 +---------- mesh/mesh-io-generic.c | 11 +---------- mesh/mesh-io-generic.h | 11 +---------- mesh/mesh-io.c | 11 +---------- mesh/mesh-io.h | 11 +---------- mesh/mesh-mgmt.c | 11 +---------- mesh/mesh-mgmt.h | 11 +---------- mesh/mesh.c | 11 +---------- mesh/mesh.h | 11 +---------- mesh/model.c | 11 +---------- mesh/model.h | 11 +---------- mesh/net-keys.c | 11 +---------- mesh/net-keys.h | 11 +---------- mesh/net.c | 11 +---------- mesh/net.h | 11 +---------- mesh/node.c | 11 +---------- mesh/node.h | 11 +---------- mesh/pb-adv.c | 11 +---------- mesh/pb-adv.h | 11 +---------- mesh/prov-acceptor.c | 11 +---------- mesh/prov-initiator.c | 11 +---------- mesh/prov.h | 11 +---------- mesh/provision.h | 11 +---------- mesh/rpl.c | 11 +---------- mesh/rpl.h | 11 +---------- mesh/util.c | 11 +---------- mesh/util.h | 11 +---------- monitor/a2dp.c | 15 +-------------- monitor/a2dp.h | 15 +-------------- monitor/analyze.c | 15 +-------------- monitor/analyze.h | 15 +-------------- monitor/avctp.c | 15 +-------------- monitor/avctp.h | 15 +-------------- monitor/avdtp.c | 15 +-------------- monitor/avdtp.h | 15 +-------------- monitor/bnep.c | 15 +-------------- monitor/bnep.h | 15 +-------------- monitor/broadcom.c | 15 +-------------- monitor/broadcom.h | 15 +-------------- monitor/bt.h | 15 +-------------- monitor/control.c | 15 +-------------- monitor/control.h | 15 +-------------- monitor/crc.c | 15 +-------------- monitor/crc.h | 15 +-------------- monitor/display.c | 15 +-------------- monitor/display.h | 15 +-------------- monitor/ellisys.c | 15 +-------------- monitor/ellisys.h | 15 +-------------- monitor/hcidump.c | 15 +-------------- monitor/hcidump.h | 15 +-------------- monitor/hwdb.c | 15 +-------------- monitor/hwdb.h | 15 +-------------- monitor/intel.c | 15 +-------------- monitor/intel.h | 15 +-------------- monitor/jlink.c | 15 +-------------- monitor/jlink.h | 15 +-------------- monitor/keys.c | 15 +-------------- monitor/keys.h | 15 +-------------- monitor/l2cap.c | 15 +-------------- monitor/l2cap.h | 15 +-------------- monitor/ll.c | 15 +-------------- monitor/ll.h | 15 +-------------- monitor/lmp.c | 15 +-------------- monitor/lmp.h | 15 +-------------- monitor/main.c | 15 +-------------- monitor/packet.c | 15 +-------------- monitor/packet.h | 15 +-------------- monitor/rfcomm.c | 15 +-------------- monitor/rfcomm.h | 15 +-------------- monitor/sdp.c | 15 +-------------- monitor/sdp.h | 15 +-------------- monitor/tty.h | 15 +-------------- monitor/vendor.c | 15 +-------------- monitor/vendor.h | 15 +-------------- obexd/client/bluetooth.c | 15 +-------------- obexd/client/bluetooth.h | 15 +-------------- obexd/client/driver.c | 15 +-------------- obexd/client/driver.h | 15 +-------------- obexd/client/ftp.c | 15 +-------------- obexd/client/ftp.h | 15 +-------------- obexd/client/manager.c | 15 +-------------- obexd/client/manager.h | 15 +-------------- obexd/client/map-event.c | 15 +-------------- obexd/client/map-event.h | 15 +-------------- obexd/client/map.c | 15 +-------------- obexd/client/map.h | 15 +-------------- obexd/client/mns.c | 15 +-------------- obexd/client/opp.c | 15 +-------------- obexd/client/opp.h | 15 +-------------- obexd/client/pbap.c | 15 +-------------- obexd/client/pbap.h | 15 +-------------- obexd/client/session.c | 15 +-------------- obexd/client/session.h | 15 +-------------- obexd/client/sync.c | 15 +-------------- obexd/client/sync.h | 15 +-------------- obexd/client/transfer.c | 15 +-------------- obexd/client/transfer.h | 15 +-------------- obexd/client/transport.c | 15 +-------------- obexd/client/transport.h | 15 +-------------- obexd/plugins/bluetooth.c | 15 +-------------- obexd/plugins/filesystem.c | 15 +-------------- obexd/plugins/filesystem.h | 15 +-------------- obexd/plugins/ftp.c | 15 +-------------- obexd/plugins/ftp.h | 15 +-------------- obexd/plugins/irmc.c | 15 +-------------- obexd/plugins/mas.c | 15 +-------------- obexd/plugins/messages-dummy.c | 15 +-------------- obexd/plugins/messages-tracker.c | 15 +-------------- obexd/plugins/messages.h | 15 +-------------- obexd/plugins/opp.c | 15 +-------------- obexd/plugins/pbap.c | 15 +-------------- obexd/plugins/pcsuite.c | 15 +-------------- obexd/plugins/phonebook-dummy.c | 15 +-------------- obexd/plugins/phonebook-ebook.c | 15 +-------------- obexd/plugins/phonebook-tracker.c | 15 +-------------- obexd/plugins/phonebook.h | 15 +-------------- obexd/plugins/syncevolution.c | 15 +-------------- obexd/plugins/vcard.c | 15 +-------------- obexd/plugins/vcard.h | 15 +-------------- obexd/src/log.c | 15 +-------------- obexd/src/log.h | 15 +-------------- obexd/src/main.c | 15 +-------------- obexd/src/manager.c | 15 +-------------- obexd/src/manager.h | 15 +-------------- obexd/src/map_ap.h | 15 +-------------- obexd/src/mimetype.c | 15 +-------------- obexd/src/mimetype.h | 15 +-------------- obexd/src/obex-priv.h | 15 +-------------- obexd/src/obex.c | 15 +-------------- obexd/src/obex.h | 15 +-------------- obexd/src/obexd.h | 15 +-------------- obexd/src/plugin.c | 15 +-------------- obexd/src/plugin.h | 15 +-------------- obexd/src/server.c | 15 +-------------- obexd/src/server.h | 15 +-------------- obexd/src/service.c | 15 +-------------- obexd/src/service.h | 15 +-------------- obexd/src/transport.c | 15 +-------------- obexd/src/transport.h | 15 +-------------- peripheral/attach.c | 15 +-------------- peripheral/attach.h | 15 +-------------- peripheral/efivars.c | 15 +-------------- peripheral/efivars.h | 15 +-------------- peripheral/gap.c | 15 +-------------- peripheral/gap.h | 15 +-------------- peripheral/gatt.c | 15 +-------------- peripheral/gatt.h | 15 +-------------- peripheral/log.c | 15 +-------------- peripheral/log.h | 15 +-------------- peripheral/main.c | 15 +-------------- plugins/autopair.c | 15 +-------------- plugins/external-dummy.c | 15 +-------------- plugins/hostname.c | 15 +-------------- plugins/neard.c | 15 +-------------- plugins/policy.c | 15 +-------------- plugins/sixaxis.c | 15 +-------------- plugins/wiimote.c | 15 +-------------- profiles/audio/a2dp-codecs.h | 15 +-------------- profiles/audio/a2dp.c | 15 +-------------- profiles/audio/a2dp.h | 15 +-------------- profiles/audio/avctp.c | 15 +-------------- profiles/audio/avctp.h | 15 +-------------- profiles/audio/avdtp.c | 15 +-------------- profiles/audio/avdtp.h | 15 +-------------- profiles/audio/avrcp.c | 15 +-------------- profiles/audio/avrcp.h | 15 +-------------- profiles/audio/control.c | 15 +-------------- profiles/audio/control.h | 15 +-------------- profiles/audio/media.c | 15 +-------------- profiles/audio/media.h | 15 +-------------- profiles/audio/player.c | 15 +-------------- profiles/audio/player.h | 15 +-------------- profiles/audio/sink.c | 15 +-------------- profiles/audio/sink.h | 15 +-------------- profiles/audio/source.c | 15 +-------------- profiles/audio/source.h | 15 +-------------- profiles/audio/transport.c | 15 +-------------- profiles/audio/transport.h | 15 +-------------- profiles/battery/bas.c | 15 +-------------- profiles/battery/bas.h | 15 +-------------- profiles/battery/battery.c | 10 +--------- profiles/cups/cups.h | 15 +-------------- profiles/cups/hcrp.c | 15 +-------------- profiles/cups/main.c | 15 +-------------- profiles/cups/sdp.c | 15 +-------------- profiles/cups/spp.c | 15 +-------------- profiles/deviceinfo/deviceinfo.c | 15 +-------------- profiles/deviceinfo/dis.c | 15 +-------------- profiles/deviceinfo/dis.h | 15 +-------------- profiles/gap/gas.c | 10 +--------- profiles/health/hdp.c | 15 +-------------- profiles/health/hdp.h | 15 +-------------- profiles/health/hdp_main.c | 15 +-------------- profiles/health/hdp_manager.c | 15 +-------------- profiles/health/hdp_manager.h | 15 +-------------- profiles/health/hdp_types.h | 15 +-------------- profiles/health/hdp_util.c | 15 +-------------- profiles/health/hdp_util.h | 15 +-------------- profiles/health/mcap.c | 15 +-------------- profiles/health/mcap.h | 15 +-------------- profiles/iap/main.c | 15 +-------------- profiles/input/device.c | 15 +-------------- profiles/input/device.h | 15 +-------------- profiles/input/hidp_defs.h | 15 +-------------- profiles/input/hog-lib.c | 15 +-------------- profiles/input/hog-lib.h | 15 +-------------- profiles/input/hog.c | 15 +-------------- profiles/input/manager.c | 15 +-------------- profiles/input/server.c | 15 +-------------- profiles/input/server.h | 15 +-------------- profiles/input/sixaxis.h | 15 +-------------- profiles/input/suspend-dummy.c | 15 +-------------- profiles/input/suspend-none.c | 15 +-------------- profiles/input/suspend.h | 15 +-------------- profiles/midi/libmidi.c | 16 +--------------- profiles/midi/libmidi.h | 16 +--------------- profiles/midi/midi.c | 20 +------------------- profiles/network/bnep.c | 15 +-------------- profiles/network/bnep.h | 15 +-------------- profiles/network/connection.c | 15 +-------------- profiles/network/connection.h | 15 +-------------- profiles/network/manager.c | 15 +-------------- profiles/network/server.c | 15 +-------------- profiles/network/server.h | 15 +-------------- profiles/sap/main.c | 14 +------------- profiles/sap/manager.c | 14 +------------- profiles/sap/manager.h | 14 +------------- profiles/sap/sap-dummy.c | 14 +------------- profiles/sap/sap.h | 14 +------------- profiles/sap/server.c | 14 +------------- profiles/sap/server.h | 14 +------------- profiles/scanparam/scan.c | 15 +-------------- profiles/scanparam/scpp.c | 15 +-------------- profiles/scanparam/scpp.h | 15 +-------------- src/adapter.c | 15 +-------------- src/adapter.h | 15 +-------------- src/adv_monitor.c | 11 +---------- src/adv_monitor.h | 11 +---------- src/advertising.c | 11 +---------- src/advertising.h | 11 +---------- src/agent.c | 15 +-------------- src/agent.h | 15 +-------------- src/attrib-server.c | 15 +-------------- src/attrib-server.h | 15 +-------------- src/backtrace.c | 15 +-------------- src/backtrace.h | 15 +-------------- src/dbus-common.c | 15 +-------------- src/dbus-common.h | 15 +-------------- src/device.c | 15 +-------------- src/device.h | 15 +-------------- src/eir.c | 15 +-------------- src/eir.h | 15 +-------------- src/error.c | 15 +-------------- src/error.h | 15 +-------------- src/gatt-client.c | 11 +---------- src/gatt-client.h | 11 +---------- src/gatt-database.c | 11 +---------- src/gatt-database.h | 11 +---------- src/hcid.h | 15 +-------------- src/log.c | 15 +-------------- src/log.h | 15 +-------------- src/main.c | 15 +-------------- src/oui.c | 15 +-------------- src/oui.h | 15 +-------------- src/plugin.c | 15 +-------------- src/plugin.h | 15 +-------------- src/profile.c | 15 +-------------- src/profile.h | 15 +-------------- src/rfkill.c | 15 +-------------- src/sdp-client.c | 15 +-------------- src/sdp-client.h | 15 +-------------- src/sdp-xml.c | 15 +-------------- src/sdp-xml.h | 15 +-------------- src/sdpd-database.c | 15 +-------------- src/sdpd-request.c | 15 +-------------- src/sdpd-server.c | 15 +-------------- src/sdpd-service.c | 15 +-------------- src/sdpd.h | 15 +-------------- src/service.c | 15 +-------------- src/service.h | 15 +-------------- src/shared/ad.c | 15 +-------------- src/shared/ad.h | 15 +-------------- src/shared/att-types.h | 15 +-------------- src/shared/att.c | 15 +-------------- src/shared/att.h | 15 +-------------- src/shared/btp.c | 15 +-------------- src/shared/btp.h | 15 +-------------- src/shared/btsnoop.c | 15 +-------------- src/shared/btsnoop.h | 15 +-------------- src/shared/crypto.c | 15 +-------------- src/shared/crypto.h | 15 +-------------- src/shared/ecc.c | 21 +-------------------- src/shared/ecc.h | 21 +-------------------- src/shared/gap.c | 15 +-------------- src/shared/gap.h | 15 +-------------- src/shared/gatt-client.c | 15 +-------------- src/shared/gatt-client.h | 15 +-------------- src/shared/gatt-db.c | 15 +-------------- src/shared/gatt-db.h | 15 +-------------- src/shared/gatt-helpers.c | 15 +-------------- src/shared/gatt-helpers.h | 15 +-------------- src/shared/gatt-server.c | 15 +-------------- src/shared/gatt-server.h | 15 +-------------- src/shared/hci-crypto.c | 15 +-------------- src/shared/hci-crypto.h | 15 +-------------- src/shared/hci.c | 15 +-------------- src/shared/hci.h | 15 +-------------- src/shared/hfp.c | 15 +-------------- src/shared/hfp.h | 15 +-------------- src/shared/io-ell.c | 15 +-------------- src/shared/io-glib.c | 15 +-------------- src/shared/io-mainloop.c | 15 +-------------- src/shared/io.h | 15 +-------------- src/shared/log.c | 15 +-------------- src/shared/log.h | 15 +-------------- src/shared/mainloop-ell.c | 12 +----------- src/shared/mainloop-glib.c | 15 +-------------- src/shared/mainloop-notify.c | 15 +-------------- src/shared/mainloop-notify.h | 15 +-------------- src/shared/mainloop.c | 15 +-------------- src/shared/mainloop.h | 15 +-------------- src/shared/mgmt.c | 15 +-------------- src/shared/mgmt.h | 15 +-------------- src/shared/pcap.c | 15 +-------------- src/shared/pcap.h | 15 +-------------- src/shared/queue.c | 15 +-------------- src/shared/queue.h | 15 +-------------- src/shared/ringbuf.c | 15 +-------------- src/shared/ringbuf.h | 15 +-------------- src/shared/shell.c | 15 +-------------- src/shared/shell.h | 15 +-------------- src/shared/tester.c | 15 +-------------- src/shared/tester.h | 15 +-------------- src/shared/timeout-ell.c | 11 +---------- src/shared/timeout-glib.c | 11 +---------- src/shared/timeout-mainloop.c | 11 +---------- src/shared/timeout.h | 11 +---------- src/shared/tty.h | 15 +-------------- src/shared/uhid.c | 15 +-------------- src/shared/uhid.h | 15 +-------------- src/shared/util.c | 15 +-------------- src/shared/util.h | 15 +-------------- src/storage.c | 15 +-------------- src/storage.h | 15 +-------------- src/textfile.c | 15 +-------------- src/textfile.h | 15 +-------------- src/uinput.h | 15 +-------------- src/uuid-helper.c | 15 +-------------- src/uuid-helper.h | 15 +-------------- tools/3dsp.c | 15 +-------------- tools/advtest.c | 15 +-------------- tools/amptest.c | 15 +-------------- tools/avinfo.c | 15 +-------------- tools/avtest.c | 15 +-------------- tools/bccmd.c | 15 +-------------- tools/bcmfw.c | 15 +-------------- tools/bdaddr.c | 15 +-------------- tools/bluemoon.c | 15 +-------------- tools/bluetooth-player.c | 15 +-------------- tools/bnep-tester.c | 15 +-------------- tools/bneptest.c | 15 +-------------- tools/btattach.c | 15 +-------------- tools/btconfig.c | 15 +-------------- tools/btgatt-client.c | 15 +-------------- tools/btgatt-server.c | 11 +---------- tools/btinfo.c | 15 +-------------- tools/btiotest.c | 15 +-------------- tools/btmgmt.c | 15 +-------------- tools/btmon-logger.c | 15 +-------------- tools/btpclient.c | 15 +-------------- tools/btpclientctl.c | 15 +-------------- tools/btproxy.c | 15 +-------------- tools/btsnoop.c | 15 +-------------- tools/check-selftest.c | 15 +-------------- tools/ciptool.c | 15 +-------------- tools/cltest.c | 15 +-------------- tools/create-image.c | 15 +-------------- tools/csr.c | 15 +-------------- tools/csr.h | 15 +-------------- tools/csr_3wire.c | 15 +-------------- tools/csr_bcsp.c | 15 +-------------- tools/csr_h4.c | 15 +-------------- tools/csr_hci.c | 15 +-------------- tools/csr_usb.c | 15 +-------------- tools/eddystone.c | 15 +-------------- tools/gap-tester.c | 15 +-------------- tools/gatt-service.c | 15 +-------------- tools/hci-tester.c | 15 +-------------- tools/hciattach.c | 15 +-------------- tools/hciattach.h | 15 +-------------- tools/hciattach_ath3k.c | 15 +-------------- tools/hciattach_bcm43xx.c | 15 +-------------- tools/hciattach_intel.c | 15 +-------------- tools/hciattach_qualcomm.c | 15 +-------------- tools/hciattach_st.c | 15 +-------------- tools/hciattach_ti.c | 15 +-------------- tools/hciattach_tialt.c | 15 +-------------- tools/hciconfig.c | 15 +-------------- tools/hcidump.c | 15 +-------------- tools/hcieventmask.c | 15 +-------------- tools/hcisecfilter.c | 15 +-------------- tools/hcitool.c | 15 +-------------- tools/hex2hcd.c | 15 +-------------- tools/hid2hci.c | 15 +-------------- tools/hwdb.c | 15 +-------------- tools/ibeacon.c | 15 +-------------- tools/l2cap-tester.c | 15 +-------------- tools/l2ping.c | 15 +-------------- tools/l2test.c | 15 +-------------- tools/mcaptest.c | 15 +-------------- tools/mesh-cfgclient.c | 11 +---------- tools/mesh-gatt/config-client.c | 15 +-------------- tools/mesh-gatt/config-server.c | 15 +-------------- tools/mesh-gatt/crypto.c | 15 +-------------- tools/mesh-gatt/crypto.h | 15 +-------------- tools/mesh-gatt/gatt.c | 15 +-------------- tools/mesh-gatt/gatt.h | 15 +-------------- tools/mesh-gatt/keys.h | 15 +-------------- tools/mesh-gatt/mesh-net.h | 15 +-------------- tools/mesh-gatt/net.c | 15 +-------------- tools/mesh-gatt/net.h | 15 +-------------- tools/mesh-gatt/node.c | 15 +-------------- tools/mesh-gatt/node.h | 15 +-------------- tools/mesh-gatt/onoff-model.c | 15 +-------------- tools/mesh-gatt/onoff-model.h | 15 +-------------- tools/mesh-gatt/prov-db.c | 15 +-------------- tools/mesh-gatt/prov-db.h | 15 +-------------- tools/mesh-gatt/prov.c | 15 +-------------- tools/mesh-gatt/prov.h | 15 +-------------- tools/mesh-gatt/util.c | 15 +-------------- tools/mesh-gatt/util.h | 15 +-------------- tools/mesh/agent.c | 15 +-------------- tools/mesh/agent.h | 15 +-------------- tools/mesh/cfgcli.c | 12 +----------- tools/mesh/cfgcli.h | 12 +----------- tools/mesh/config-model.h | 15 +-------------- tools/mesh/keys.c | 12 +----------- tools/mesh/keys.h | 12 +----------- tools/mesh/mesh-db.c | 11 +---------- tools/mesh/mesh-db.h | 11 +---------- tools/mesh/model.h | 12 +----------- tools/mesh/remote.c | 11 +---------- tools/mesh/remote.h | 11 +---------- tools/mesh/util.c | 11 +---------- tools/mesh/util.h | 11 +---------- tools/meshctl.c | 15 +-------------- tools/mgmt-tester.c | 15 +-------------- tools/mpris-proxy.c | 15 +-------------- tools/nokfw.c | 15 +-------------- tools/obex-client-tool.c | 14 +------------- tools/obex-server-tool.c | 14 +------------- tools/obexctl.c | 15 +-------------- tools/oobtest.c | 15 +-------------- tools/parser/amp.c | 15 +-------------- tools/parser/att.c | 15 +-------------- tools/parser/avctp.c | 15 +-------------- tools/parser/avdtp.c | 15 +-------------- tools/parser/avrcp.c | 15 +-------------- tools/parser/bnep.c | 15 +-------------- tools/parser/bpa.c | 15 +-------------- tools/parser/capi.c | 15 +-------------- tools/parser/cmtp.c | 15 +-------------- tools/parser/csr.c | 15 +-------------- tools/parser/ericsson.c | 15 +-------------- tools/parser/hci.c | 15 +-------------- tools/parser/hcrp.c | 15 +-------------- tools/parser/hidp.c | 15 +-------------- tools/parser/l2cap.c | 15 +-------------- tools/parser/l2cap.h | 15 +-------------- tools/parser/lmp.c | 15 +-------------- tools/parser/obex.c | 15 +-------------- tools/parser/parser.c | 15 +-------------- tools/parser/parser.h | 15 +-------------- tools/parser/ppp.c | 15 +-------------- tools/parser/rfcomm.c | 15 +-------------- tools/parser/rfcomm.h | 15 +-------------- tools/parser/sap.c | 15 +-------------- tools/parser/sdp.c | 15 +-------------- tools/parser/sdp.h | 15 +-------------- tools/parser/smp.c | 15 +-------------- tools/parser/tcpip.c | 15 +-------------- tools/rctest.c | 15 +-------------- tools/rfcomm-tester.c | 15 +-------------- tools/rfcomm.c | 15 +-------------- tools/rtlfw.c | 15 +-------------- tools/sco-tester.c | 15 +-------------- tools/scotest.c | 15 +-------------- tools/sdptool.c | 15 +-------------- tools/seq2bseq.c | 15 +-------------- tools/smp-tester.c | 15 +-------------- tools/test-runner.c | 15 +-------------- tools/ubcsp.c | 20 +------------------- tools/ubcsp.h | 20 +------------------- tools/userchan-tester.c | 15 +-------------- unit/test-avctp.c | 15 +-------------- unit/test-avdtp.c | 15 +-------------- unit/test-avrcp.c | 15 +-------------- unit/test-crc.c | 15 +-------------- unit/test-crypto.c | 15 +-------------- unit/test-ecc.c | 21 +-------------------- unit/test-eir.c | 15 +-------------- unit/test-gatt.c | 15 +-------------- unit/test-gattrib.c | 15 +-------------- unit/test-gdbus-client.c | 15 +-------------- unit/test-gobex-apparam.c | 15 +-------------- unit/test-gobex-header.c | 15 +-------------- unit/test-gobex-packet.c | 15 +-------------- unit/test-gobex-transfer.c | 15 +-------------- unit/test-gobex.c | 15 +-------------- unit/test-hfp.c | 15 +-------------- unit/test-hog.c | 15 +-------------- unit/test-lib.c | 15 +-------------- unit/test-mesh-crypto.c | 11 +---------- unit/test-mgmt.c | 15 +-------------- unit/test-midi.c | 16 +--------------- unit/test-queue.c | 15 +-------------- unit/test-ringbuf.c | 15 +-------------- unit/test-sdp.c | 15 +-------------- unit/test-textfile.c | 15 +-------------- unit/test-uhid.c | 15 +-------------- unit/test-uuid.c | 15 +-------------- unit/util.c | 14 +------------- unit/util.h | 14 +------------- 758 files changed, 758 insertions(+), 10148 deletions(-) -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +MHLFU8FYF/jTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:05:35 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id eEJWEk8FYF8M1QAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:05:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5B1A8A0B1F; Tue, 15 Sep 2020 02:05:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726106AbgIOAFW (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:22 -0400 Received: from mga09.intel.com ([134.134.136.24]:37077 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726073AbgIOAFV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:21 -0400 IronPort-SDR: koDL7gn7BLZd2OK5QiNz1K7y1Gv3VO/cPxpU57myl788F0irIdNI/LezGzduoE9x2nQ4THOgCQ 3TkUMZ7OuWsQ== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112016" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112016" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:19 -0700 IronPort-SDR: Sf7JuREqVGnfDZ5bP6Cjc7JT8n6rr7jIsnhufGgeGqDGoJT5JHPfNXvulgkcQowYWjkpAzd01h /TcsDTFC3rOA== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333121" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:19 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 03/17] btio: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:43 -0700 Message-Id: <20200915000457.22988-4-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5B1A8A0B1F X-Rspamd-UID: f90005 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 2 License: GPL-2.0-or-later btio/btio.h btio/btio.c --- btio/btio.c | 15 +-------------- btio/btio.h | 15 +-------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/btio/btio.c b/btio/btio.c index 844d6007f..c18b6a012 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2009-2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/btio/btio.h b/btio/btio.h index 23e0ef72b..f0259cf1d 100644 --- a/btio/btio.h +++ b/btio/btio.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2009-2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef BT_IO_H #define BT_IO_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WLzsK1UFYF85SwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:05:41 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id yJChKFUFYF9FogAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:05:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 70661A0B10; Tue, 15 Sep 2020 02:05:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726061AbgIOAF1 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:27 -0400 Received: from mga09.intel.com ([134.134.136.24]:37077 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbgIOAFX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:23 -0400 IronPort-SDR: ajrnIUkUuf6tx1gThOJZGiLd44c9cq7AB6N51H8B6/Nx4MKZjdaJMZG5PjaYEJfGoiuKb67NUr 9PR0rX72SulQ== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112020" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112020" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:21 -0700 IronPort-SDR: AFlnE0MHrZnHOnj2sqJis+hylWukG7dkCFQb3cKKWtbKFrnar/aQn6p5fo9t5S/jyPtZPyXd1N 0mVZtR6XPq0g== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333132" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:20 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 04/17] client: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:44 -0700 Message-Id: <20200915000457.22988-5-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 7.28 / 15.00 / 15.00 X-Rspamd-Queue-Id: 70661A0B10 X-Rspamd-UID: 8eaa21 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 9 License: GPL-2.0-or-later client/advertising.h client/display.c client/main.c client/display.h client/agent.h client/gatt.c client/agent.c client/advertising.c client/gatt.h --- client/advertising.c | 15 +-------------- client/advertising.h | 15 +-------------- client/agent.c | 15 +-------------- client/agent.h | 15 +-------------- client/display.c | 15 +-------------- client/display.h | 15 +-------------- client/gatt.c | 15 +-------------- client/gatt.h | 15 +-------------- client/main.c | 15 +-------------- 9 files changed, 9 insertions(+), 126 deletions(-) diff --git a/client/advertising.c b/client/advertising.c index 1aa28e749..c1a00502e 100644 --- a/client/advertising.c +++ b/client/advertising.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2016 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/advertising.h b/client/advertising.h index 9967e657b..25e6aee99 100644 --- a/client/advertising.h +++ b/client/advertising.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2016 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void ad_register(DBusConnection *conn, GDBusProxy *manager, const char *type); diff --git a/client/agent.c b/client/agent.c index 4def1b478..c8e1560e7 100644 --- a/client/agent.c +++ b/client/agent.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/agent.h b/client/agent.h index 30f302cdc..5d902a717 100644 --- a/client/agent.h +++ b/client/agent.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void agent_register(DBusConnection *conn, GDBusProxy *manager, diff --git a/client/display.c b/client/display.c index 05613865b..a590a1388 100644 --- a/client/display.c +++ b/client/display.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/display.h b/client/display.h index e991d191a..eb5bd1153 100644 --- a/client/display.h +++ b/client/display.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define COLOR_OFF "\x1B[0m" diff --git a/client/gatt.c b/client/gatt.c index e5bab6dd0..21fd38ecf 100644 --- a/client/gatt.c +++ b/client/gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/gatt.h b/client/gatt.h index 09ca618d3..fc2b8a8a6 100644 --- a/client/gatt.h +++ b/client/gatt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void gatt_add_service(GDBusProxy *proxy); diff --git a/client/main.c b/client/main.c index da877b546..9aaa0106e 100644 --- a/client/main.c +++ b/client/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cKcDOlsFYF/jTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:05:47 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id qC9fN1sFYF8M1QAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:05:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C7FDEA0B0C; Tue, 15 Sep 2020 02:05:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726089AbgIOAF2 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:28 -0400 Received: from mga09.intel.com ([134.134.136.24]:37102 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726117AbgIOAF0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:26 -0400 IronPort-SDR: uydYAy0+YbpINgppLvy5ywHMXPCIs9jz2HGmmSIMw4j1GE//pV9fswls8/LJaVcIkO4ravJ0so FCcHQCqu0gkA== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112028" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112028" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:24 -0700 IronPort-SDR: o8IiZDfnpY7sSpDRsVDELJrnlq/i5yLD5UUsn2VtqlcWS2d9l279kbAKW+T67z9QOSKHEzv7sd 3CNSK1t1rc3A== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333141" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:23 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 06/17] gdbus: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:46 -0700 Message-Id: <20200915000457.22988-7-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.03 / 15.00 / 15.00 X-Rspamd-Queue-Id: C7FDEA0B0C X-Rspamd-UID: 60b390 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 6 License: GPL-2.0-or-later gdbus/mainloop.c gdbus/object.c gdbus/polkit.c gdbus/client.c gdbus/watch.c gdbus/gdbus.h --- gdbus/client.c | 15 +-------------- gdbus/gdbus.h | 15 +-------------- gdbus/mainloop.c | 15 +-------------- gdbus/object.c | 15 +-------------- gdbus/polkit.c | 15 +-------------- gdbus/watch.c | 15 +-------------- 6 files changed, 6 insertions(+), 84 deletions(-) diff --git a/gdbus/client.c b/gdbus/client.c index 84e076994..3b7faa4e4 100644 --- a/gdbus/client.c +++ b/gdbus/client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h index 9bdff9eba..28b802296 100644 --- a/gdbus/gdbus.h +++ b/gdbus/gdbus.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GDBUS_H diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c index b90a8447c..a04ebb19b 100644 --- a/gdbus/mainloop.c +++ b/gdbus/mainloop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gdbus/object.c b/gdbus/object.c index 49b578087..50a8b4ff1 100644 --- a/gdbus/object.c +++ b/gdbus/object.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gdbus/polkit.c b/gdbus/polkit.c index 9e95fa384..80e024fad 100644 --- a/gdbus/polkit.c +++ b/gdbus/polkit.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gdbus/watch.c b/gdbus/watch.c index 447e48671..25f367613 100644 --- a/gdbus/watch.c +++ b/gdbus/watch.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UOe+CWYFYF85SwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:05:58 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 8Fw9B2YFYF+N9wAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:05:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7180EA0195; Tue, 15 Sep 2020 02:05:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbgIOAF3 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:29 -0400 Received: from mga09.intel.com ([134.134.136.24]:37100 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726073AbgIOAFZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:25 -0400 IronPort-SDR: O1OJxT28WHFXALtg0xGa5YupVPw1RaDXuuxsWBx06ysz9qu9m6s7rBu6+QUFUl52RihPYzteBU 9KdZUQu4unCQ== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112025" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112025" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:22 -0700 IronPort-SDR: GL/iA0OIQ7CZuWY9ZUu80soAYeBiwmMC2nZrI9SjfCKjIKv9gdX4+CnIc226e/wb3dOJ7z5oMm saj9iG4Qmprg== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333136" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:22 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 05/17] emulator: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:45 -0700 Message-Id: <20200915000457.22988-6-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.05 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7180EA0195 X-Rspamd-UID: 52e986 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 20 GPL-2.0-or-later : 2 License: LGPL-2.1-or-later emulator/server.c emulator/amp.c emulator/hciemu.c emulator/vhci.c emulator/btdev.c emulator/serial.h emulator/le.h emulator/le.c emulator/main.c emulator/amp.h emulator/hciemu.h emulator/bthost.h emulator/btdev.h emulator/vhci.h emulator/serial.c emulator/phy.c emulator/smp.c emulator/phy.h emulator/bthost.c emulator/server.h License: GPL-2.0-or-later emulator/b1ee.c emulator/hfp.c --- emulator/amp.c | 15 +-------------- emulator/amp.h | 15 +-------------- emulator/b1ee.c | 15 +-------------- emulator/btdev.c | 15 +-------------- emulator/btdev.h | 15 +-------------- emulator/bthost.c | 15 +-------------- emulator/bthost.h | 15 +-------------- emulator/hciemu.c | 15 +-------------- emulator/hciemu.h | 15 +-------------- emulator/hfp.c | 15 +-------------- emulator/le.c | 15 +-------------- emulator/le.h | 15 +-------------- emulator/main.c | 15 +-------------- emulator/phy.c | 15 +-------------- emulator/phy.h | 15 +-------------- emulator/serial.c | 15 +-------------- emulator/serial.h | 15 +-------------- emulator/server.c | 15 +-------------- emulator/server.h | 15 +-------------- emulator/smp.c | 15 +-------------- emulator/vhci.c | 15 +-------------- emulator/vhci.h | 15 +-------------- 22 files changed, 22 insertions(+), 308 deletions(-) diff --git a/emulator/amp.c b/emulator/amp.c index 605c6c825..49d2df7b3 100644 --- a/emulator/amp.c +++ b/emulator/amp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/amp.h b/emulator/amp.h index 189dfb7d4..cee360c44 100644 --- a/emulator/amp.h +++ b/emulator/amp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/emulator/b1ee.c b/emulator/b1ee.c index 377181b01..53b85f221 100644 --- a/emulator/b1ee.c +++ b/emulator/b1ee.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/btdev.c b/emulator/btdev.c index e9c3811f8..9a8c9b654 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/btdev.h b/emulator/btdev.h index a9f71b281..7cb265f1c 100644 --- a/emulator/btdev.h +++ b/emulator/btdev.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/emulator/bthost.c b/emulator/bthost.c index 71d5f97bb..1c05c7496 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/bthost.h b/emulator/bthost.h index 2b347136f..3841f98a1 100644 --- a/emulator/bthost.h +++ b/emulator/bthost.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/emulator/hciemu.c b/emulator/hciemu.c index ac861cce2..fa8905ed7 100644 --- a/emulator/hciemu.c +++ b/emulator/hciemu.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/hciemu.h b/emulator/hciemu.h index 4c8858bb6..c8ec80d8d 100644 --- a/emulator/hciemu.h +++ b/emulator/hciemu.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/emulator/hfp.c b/emulator/hfp.c index 29ec63e7d..bbf785ee3 100644 --- a/emulator/hfp.c +++ b/emulator/hfp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/le.c b/emulator/le.c index 1c8ba280b..4ffe3b16d 100644 --- a/emulator/le.c +++ b/emulator/le.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/le.h b/emulator/le.h index 5e832e8e5..21d2b4828 100644 --- a/emulator/le.h +++ b/emulator/le.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/emulator/main.c b/emulator/main.c index 75cb79c7b..cb77025aa 100644 --- a/emulator/main.c +++ b/emulator/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/phy.c b/emulator/phy.c index beb8bbbe4..4517ad107 100644 --- a/emulator/phy.c +++ b/emulator/phy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/phy.h b/emulator/phy.h index d5efa5180..9ee8f397c 100644 --- a/emulator/phy.h +++ b/emulator/phy.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/emulator/serial.c b/emulator/serial.c index 1c324d531..b44af0dcc 100644 --- a/emulator/serial.c +++ b/emulator/serial.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/serial.h b/emulator/serial.h index 4e5a56f88..1dce15f51 100644 --- a/emulator/serial.h +++ b/emulator/serial.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/emulator/server.c b/emulator/server.c index c28b15ebf..3b07a7156 100644 --- a/emulator/server.c +++ b/emulator/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/server.h b/emulator/server.h index bf725e788..294e86525 100644 --- a/emulator/server.h +++ b/emulator/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/emulator/smp.c b/emulator/smp.c index c30de3666..7c05ba342 100644 --- a/emulator/smp.c +++ b/emulator/smp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/vhci.c b/emulator/vhci.c index f79b34f46..84e16330f 100644 --- a/emulator/vhci.c +++ b/emulator/vhci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/vhci.h b/emulator/vhci.h index 1ec7191f8..24b36bd60 100644 --- a/emulator/vhci.h +++ b/emulator/vhci.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kNzEHnMFYF/jTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:06:11 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6FHIG3MFYF9FogAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:06:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F09C1A0B35; Tue, 15 Sep 2020 02:06:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726122AbgIOAFg (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:36 -0400 Received: from mga09.intel.com ([134.134.136.24]:37077 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbgIOAFb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:31 -0400 IronPort-SDR: imstoPoSw58qrdo9GXSO7ZqWmfAz35bOPELDildO4420tCq5+UH31iw5vLtGQMrkXSdWWSjYeU Upagi73vVe8Q== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112031" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112031" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:25 -0700 IronPort-SDR: Tfbf9/SgP0qGS+XJMKPJNfm5mpXZTDle2l7Wnny8W+g+x7LIMpYfWPuc2u3MzxmCJGRuL1Z4oq 08TAq18DEiRw== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333148" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:25 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 07/17] gobex: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:47 -0700 Message-Id: <20200915000457.22988-8-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: F09C1A0B35 X-Rspamd-UID: 3d73f5 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 12 License: GPL-2.0-or-later gobex/gobex-defs.h gobex/gobex-transfer.c gobex/gobex.c gobex/gobex-apparam.h gobex/gobex-header.h gobex/gobex-header.c gobex/gobex.h gobex/gobex-packet.h gobex/gobex-defs.c gobex/gobex-debug.h gobex/gobex-apparam.c gobex/gobex-packet.c --- gobex/gobex-apparam.c | 15 +-------------- gobex/gobex-apparam.h | 15 +-------------- gobex/gobex-debug.h | 15 +-------------- gobex/gobex-defs.c | 15 +-------------- gobex/gobex-defs.h | 15 +-------------- gobex/gobex-header.c | 15 +-------------- gobex/gobex-header.h | 15 +-------------- gobex/gobex-packet.c | 15 +-------------- gobex/gobex-packet.h | 15 +-------------- gobex/gobex-transfer.c | 15 +-------------- gobex/gobex.c | 15 +-------------- gobex/gobex.h | 15 +-------------- 12 files changed, 12 insertions(+), 168 deletions(-) diff --git a/gobex/gobex-apparam.c b/gobex/gobex-apparam.c index b16cee11a..818180cb1 100644 --- a/gobex/gobex-apparam.c +++ b/gobex/gobex-apparam.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2012 Intel Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-apparam.h b/gobex/gobex-apparam.h index 6c0860928..ace615225 100644 --- a/gobex/gobex-apparam.h +++ b/gobex/gobex-apparam.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2012 Intel Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_APPARAM_H diff --git a/gobex/gobex-debug.h b/gobex/gobex-debug.h index a98653d83..eeb2209f0 100644 --- a/gobex/gobex-debug.h +++ b/gobex/gobex-debug.h @@ -1,22 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_DEBUG_H diff --git a/gobex/gobex-defs.c b/gobex/gobex-defs.c index 1c7c39a16..811be762b 100644 --- a/gobex/gobex-defs.c +++ b/gobex/gobex-defs.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-defs.h b/gobex/gobex-defs.h index 326e3cb09..84351205d 100644 --- a/gobex/gobex-defs.h +++ b/gobex/gobex-defs.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_DEFS_H diff --git a/gobex/gobex-header.c b/gobex/gobex-header.c index c594999a5..011d33d1a 100644 --- a/gobex/gobex-header.c +++ b/gobex/gobex-header.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-header.h b/gobex/gobex-header.h index 6600b1b4a..129f35ba1 100644 --- a/gobex/gobex-header.h +++ b/gobex/gobex-header.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_HEADER_H diff --git a/gobex/gobex-packet.c b/gobex/gobex-packet.c index a89f5b6d3..11937a5a5 100644 --- a/gobex/gobex-packet.c +++ b/gobex/gobex-packet.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-packet.h b/gobex/gobex-packet.h index 1d94ccf20..ed153bac5 100644 --- a/gobex/gobex-packet.h +++ b/gobex/gobex-packet.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_PACKET_H diff --git a/gobex/gobex-transfer.c b/gobex/gobex-transfer.c index e96e61fbc..c94d018b2 100644 --- a/gobex/gobex-transfer.c +++ b/gobex/gobex-transfer.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex.c b/gobex/gobex.c index d68a85eb6..54e3b0814 100644 --- a/gobex/gobex.c +++ b/gobex/gobex.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex.h b/gobex/gobex.h index a94d9246e..f16e4426c 100644 --- a/gobex/gobex.h +++ b/gobex/gobex.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yOA6MGwFYF/jTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:06:04 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WE03LWwFYF9LQQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:06:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3F2F4A0185; Tue, 15 Sep 2020 02:05:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726153AbgIOAF3 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:29 -0400 Received: from mga09.intel.com ([134.134.136.24]:37104 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgIOAF2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:28 -0400 IronPort-SDR: 1LfT4HBvB1BV2ue19bdy9f8KApUEuRs52t/SyZdBSaKug3j1QDBHiZs4KY9bMKW3QcSDp8OxKM 7L0RH0FSyt6A== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112032" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112032" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:27 -0700 IronPort-SDR: 5zyPuOWkufsXVB4/iIN1GIYYck79Z8yWYzh4NJpH6aP6x4tkiy9/cTEzEFX0rfkmePnzIoHbCn ufiA00DeRq3g== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333155" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:26 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 08/17] lib: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:48 -0700 Message-Id: <20200915000457.22988-9-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.00 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3F2F4A0185 X-Rspamd-UID: 1a05aa From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 18 GPL-2.0-only : 1 License: GPL-2.0-or-later lib/sco.h lib/sdp.c lib/a2mp.h lib/uuid.h lib/bluetooth.h lib/hidp.h lib/rfcomm.h lib/hci.c lib/sdp.h lib/sdp_lib.h lib/bluetooth.c lib/mgmt.h lib/hci.h lib/uuid.c lib/l2cap.h lib/bnep.h lib/hci_lib.h lib/cmtp.h License: GPL-2.0-only lib/amp.h --- lib/a2mp.h | 15 +-------------- lib/amp.h | 10 +--------- lib/bluetooth.c | 15 +-------------- lib/bluetooth.h | 15 +-------------- lib/bnep.h | 15 +-------------- lib/cmtp.h | 15 +-------------- lib/hci.c | 15 +-------------- lib/hci.h | 15 +-------------- lib/hci_lib.h | 15 +-------------- lib/hidp.h | 15 +-------------- lib/l2cap.h | 15 +-------------- lib/mgmt.h | 15 +-------------- lib/rfcomm.h | 15 +-------------- lib/sco.h | 15 +-------------- lib/sdp.c | 15 +-------------- lib/sdp.h | 15 +-------------- lib/sdp_lib.h | 15 +-------------- lib/uuid.c | 15 +-------------- lib/uuid.h | 15 +-------------- 19 files changed, 19 insertions(+), 261 deletions(-) diff --git a/lib/a2mp.h b/lib/a2mp.h index da937d133..556b342f7 100644 --- a/lib/a2mp.h +++ b/lib/a2mp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * Copyright (c) 2012 Code Aurora Forum. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __A2MP_H diff --git a/lib/amp.h b/lib/amp.h index 27aab1de0..8acb5ab40 100644 --- a/lib/amp.h +++ b/lib/amp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,15 +6,6 @@ * Copyright (C) 2010-2011 Code Aurora Forum. All rights reserved. * Copyright (C) 2012 Intel Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifndef __AMP_H diff --git a/lib/bluetooth.c b/lib/bluetooth.c index 5a8b57f25..0aecb50e1 100644 --- a/lib/bluetooth.c +++ b/lib/bluetooth.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/lib/bluetooth.h b/lib/bluetooth.h index 4a52ecb78..1619f5f08 100644 --- a/lib/bluetooth.h +++ b/lib/bluetooth.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __BLUETOOTH_H diff --git a/lib/bnep.h b/lib/bnep.h index e7c2c87cf..a0d39058c 100644 --- a/lib/bnep.h +++ b/lib/bnep.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __BNEP_H diff --git a/lib/cmtp.h b/lib/cmtp.h index ce937bd0d..7ba8bfc3b 100644 --- a/lib/cmtp.h +++ b/lib/cmtp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __CMTP_H diff --git a/lib/hci.c b/lib/hci.c index 9960c4490..4bd33f241 100644 --- a/lib/hci.c +++ b/lib/hci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/lib/hci.h b/lib/hci.h index 232d5bd9e..0ca20421a 100644 --- a/lib/hci.h +++ b/lib/hci.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HCI_H diff --git a/lib/hci_lib.h b/lib/hci_lib.h index 55aeb1760..6b1a548b5 100644 --- a/lib/hci_lib.h +++ b/lib/hci_lib.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HCI_LIB_H diff --git a/lib/hidp.h b/lib/hidp.h index c5e6a7808..da42a1b9e 100644 --- a/lib/hidp.h +++ b/lib/hidp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HIDP_H diff --git a/lib/l2cap.h b/lib/l2cap.h index 5ce94c4ee..9197800df 100644 --- a/lib/l2cap.h +++ b/lib/l2cap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (c) 2012 Code Aurora Forum. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __L2CAP_H diff --git a/lib/mgmt.h b/lib/mgmt.h index 46d894ae9..6aa0f5f88 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * BlueZ - Bluetooth protocol stack for Linux * @@ -5,20 +6,6 @@ * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __packed diff --git a/lib/rfcomm.h b/lib/rfcomm.h index ad6c0e1c3..0347ddc36 100644 --- a/lib/rfcomm.h +++ b/lib/rfcomm.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __RFCOMM_H diff --git a/lib/sco.h b/lib/sco.h index 75336a50e..307d81f81 100644 --- a/lib/sco.h +++ b/lib/sco.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __SCO_H diff --git a/lib/sdp.c b/lib/sdp.c index 84311eda1..532039a23 100644 --- a/lib/sdp.c +++ b/lib/sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/lib/sdp.h b/lib/sdp.h index f586eb5eb..6f05d4321 100644 --- a/lib/sdp.h +++ b/lib/sdp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __SDP_H diff --git a/lib/sdp_lib.h b/lib/sdp_lib.h index 3ded3934c..22776b678 100644 --- a/lib/sdp_lib.h +++ b/lib/sdp_lib.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __SDP_LIB_H diff --git a/lib/uuid.c b/lib/uuid.c index d4c7002f5..a09321dc6 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/lib/uuid.h b/lib/uuid.h index c7e6269f1..1a4029b68 100644 --- a/lib/uuid.h +++ b/lib/uuid.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __BLUETOOTH_UUID_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mDgSBHwFYF85SwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:06:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id eJrdAHwFYF8BLgEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:06:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D09B1A0B14; Tue, 15 Sep 2020 02:06:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726156AbgIOAFh (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:37 -0400 Received: from mga09.intel.com ([134.134.136.24]:37105 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbgIOAFc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:32 -0400 IronPort-SDR: 32urIuYvMzcr2+tj7qFXVZJwV5mlRSWCj1rlD8qYk10ujyqwPKLiHg0QlD3Z7HacEuP/uiY0SG NCly2JDrol9g== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112033" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112033" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:28 -0700 IronPort-SDR: 5nIMtZlyWlzRBg+VpbTby9+Bq6p3PjhWaoINE0PUQ4ZlkkqNOnPO6HgTJfkWpLVeoKm3iNoh5f 2QGMJFpoVT8Q== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333161" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:28 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 09/17] mesh: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:49 -0700 Message-Id: <20200915000457.22988-10-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 4.28 / 15.00 / 15.00 X-Rspamd-Queue-Id: D09B1A0B14 X-Rspamd-UID: 039104 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 48 License: LGPL-2.1-or-later mesh/mesh-mgmt.h mesh/mesh-mgmt.c mesh/net-keys.c mesh/mesh-io-api.h mesh/mesh.h mesh/net-keys.h mesh/model.h mesh/util.h mesh/appkey.c mesh/cfgmod.h mesh/appkey.h mesh/prov.h mesh/prov-acceptor.c mesh/net.c mesh/dbus.h mesh/friend.h mesh/mesh-io-generic.c mesh/main.c mesh/util.c mesh/dbus.c mesh/error.h mesh/mesh-config-json.c mesh/agent.h mesh/pb-adv.c mesh/crypto.c mesh/crypto.h mesh/friend.c mesh/pb-adv.h mesh/provision.h mesh/mesh-config.h mesh/mesh-io-generic.h mesh/agent.c mesh/cfgmod-server.c mesh/mesh-io.h mesh/keyring.h mesh/net.h mesh/keyring.c mesh/mesh-defs.h mesh/mesh.c mesh/rpl.c mesh/manager.c mesh/model.c mesh/mesh-io.c mesh/node.c mesh/prov-initiator.c mesh/rpl.h mesh/node.h mesh/manager.h --- mesh/agent.c | 11 +---------- mesh/agent.h | 11 +---------- mesh/appkey.c | 11 +---------- mesh/appkey.h | 11 +---------- mesh/cfgmod-server.c | 11 +---------- mesh/cfgmod.h | 11 +---------- mesh/crypto.c | 11 +---------- mesh/crypto.h | 11 +---------- mesh/dbus.c | 11 +---------- mesh/dbus.h | 11 +---------- mesh/error.h | 11 +---------- mesh/friend.c | 11 +---------- mesh/friend.h | 11 +---------- mesh/keyring.c | 11 +---------- mesh/keyring.h | 11 +---------- mesh/main.c | 11 +---------- mesh/manager.c | 11 +---------- mesh/manager.h | 11 +---------- mesh/mesh-config-json.c | 11 +---------- mesh/mesh-config.h | 11 +---------- mesh/mesh-defs.h | 12 +----------- mesh/mesh-io-api.h | 11 +---------- mesh/mesh-io-generic.c | 11 +---------- mesh/mesh-io-generic.h | 11 +---------- mesh/mesh-io.c | 11 +---------- mesh/mesh-io.h | 11 +---------- mesh/mesh-mgmt.c | 11 +---------- mesh/mesh-mgmt.h | 11 +---------- mesh/mesh.c | 11 +---------- mesh/mesh.h | 11 +---------- mesh/model.c | 11 +---------- mesh/model.h | 11 +---------- mesh/net-keys.c | 11 +---------- mesh/net-keys.h | 11 +---------- mesh/net.c | 11 +---------- mesh/net.h | 11 +---------- mesh/node.c | 11 +---------- mesh/node.h | 11 +---------- mesh/pb-adv.c | 11 +---------- mesh/pb-adv.h | 11 +---------- mesh/prov-acceptor.c | 11 +---------- mesh/prov-initiator.c | 11 +---------- mesh/prov.h | 11 +---------- mesh/provision.h | 11 +---------- mesh/rpl.c | 11 +---------- mesh/rpl.h | 11 +---------- mesh/util.c | 11 +---------- mesh/util.h | 11 +---------- 48 files changed, 48 insertions(+), 481 deletions(-) diff --git a/mesh/agent.c b/mesh/agent.c index 4d200416f..b0d523d16 100644 --- a/mesh/agent.c +++ b/mesh/agent.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/agent.h b/mesh/agent.h index 6cc3d0f71..6664c2226 100644 --- a/mesh/agent.h +++ b/mesh/agent.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_agent; diff --git a/mesh/appkey.c b/mesh/appkey.c index a4771bd7d..7efb8f5c4 100644 --- a/mesh/appkey.c +++ b/mesh/appkey.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2017-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/appkey.h b/mesh/appkey.h index 23b474a0a..3bb70445b 100644 --- a/mesh/appkey.h +++ b/mesh/appkey.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ /* TODO: get this number from configuration */ diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 2e5da863a..0009a1bee 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 6d73656a7..f47a42c60 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define CONFIG_SRV_MODEL SET_ID(SIG_VENDOR, 0x0000) diff --git a/mesh/crypto.c b/mesh/crypto.c index 70b96c51b..da227ebbb 100644 --- a/mesh/crypto.c +++ b/mesh/crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/crypto.h b/mesh/crypto.h index 7d3f89cde..2f31dc3de 100644 --- a/mesh/crypto.h +++ b/mesh/crypto.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include <stdbool.h> diff --git a/mesh/dbus.c b/mesh/dbus.c index 63ea420ed..a7abdc428 100644 --- a/mesh/dbus.c +++ b/mesh/dbus.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/dbus.h b/mesh/dbus.h index 89d6b1d31..8f00434d6 100644 --- a/mesh/dbus.h +++ b/mesh/dbus.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define BLUEZ_MESH_PATH "/org/bluez/mesh" diff --git a/mesh/error.h b/mesh/error.h index 2809915b0..6d9ccdb59 100644 --- a/mesh/error.h +++ b/mesh/error.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ /* diff --git a/mesh/friend.c b/mesh/friend.c index d27da9592..1e67704b8 100644 --- a/mesh/friend.c +++ b/mesh/friend.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/friend.h b/mesh/friend.h index 2351dee31..ba6053426 100644 --- a/mesh/friend.h +++ b/mesh/friend.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define OP_FRND_REQUEST 0x8040 diff --git a/mesh/keyring.c b/mesh/keyring.c index e8dd1e463..bbe501063 100644 --- a/mesh/keyring.c +++ b/mesh/keyring.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/keyring.h b/mesh/keyring.h index 2fab6b0dc..c2d38e9ff 100644 --- a/mesh/keyring.h +++ b/mesh/keyring.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct keyring_net_key { diff --git a/mesh/main.c b/mesh/main.c index 5a3cbf290..4356e3f65 100644 --- a/mesh/main.c +++ b/mesh/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2017-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/manager.c b/mesh/manager.c index 8ef681366..d70993e3b 100644 --- a/mesh/manager.c +++ b/mesh/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/manager.h b/mesh/manager.h index 5a4c7d94a..a45a1f1c4 100644 --- a/mesh/manager.h +++ b/mesh/manager.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ bool manager_dbus_init(struct l_dbus *dbus); diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 30c90170d..ec9ecb786 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 738cff9dd..420775829 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define MIN_COMP_SIZE 14 diff --git a/mesh/mesh-defs.h b/mesh/mesh-defs.h index 1a41e987b..43bdf5aab 100644 --- a/mesh/mesh-defs.h +++ b/mesh/mesh-defs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,17 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * */ #define MESH_AD_TYPE_PROVISION 0x29 diff --git a/mesh/mesh-io-api.h b/mesh/mesh-io-api.h index 7a5b49c60..61f79f224 100644 --- a/mesh/mesh-io-api.h +++ b/mesh/mesh-io-api.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_io_private; diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c index 67304d201..4eb7f27ce 100644 --- a/mesh/mesh-io-generic.c +++ b/mesh/mesh-io-generic.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-io-generic.h b/mesh/mesh-io-generic.h index 4bf4d5cb7..915e376bf 100644 --- a/mesh/mesh-io-generic.h +++ b/mesh/mesh-io-generic.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ extern const struct mesh_io_api mesh_io_generic; diff --git a/mesh/mesh-io.c b/mesh/mesh-io.c index c4eaecefd..62fc5d12e 100644 --- a/mesh/mesh-io.c +++ b/mesh/mesh-io.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-io.h b/mesh/mesh-io.h index fc0422020..b11c6c6e1 100644 --- a/mesh/mesh-io.h +++ b/mesh/mesh-io.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_io; diff --git a/mesh/mesh-mgmt.c b/mesh/mesh-mgmt.c index 2cf2ebac2..754093dbc 100644 --- a/mesh/mesh-mgmt.c +++ b/mesh/mesh-mgmt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 SILVAIR sp. z o.o. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-mgmt.h b/mesh/mesh-mgmt.h index 93ad7995e..90ac14e73 100644 --- a/mesh/mesh-mgmt.h +++ b/mesh/mesh-mgmt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 SILVAIR sp. z o.o. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include <stdbool.h> diff --git a/mesh/mesh.c b/mesh/mesh.c index bc170371d..f29e8b6be 100644 --- a/mesh/mesh.c +++ b/mesh/mesh.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh.h b/mesh/mesh.h index eb887723d..0f77ebc58 100644 --- a/mesh/mesh.h +++ b/mesh/mesh.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define BLUEZ_MESH_NAME "org.bluez.mesh" diff --git a/mesh/model.c b/mesh/model.c index 5716f5e22..c8eb8c607 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/model.h b/mesh/model.h index 2eec761a0..8df4f205f 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_model; diff --git a/mesh/net-keys.c b/mesh/net-keys.c index 7dfabf922..e42cac70c 100644 --- a/mesh/net-keys.c +++ b/mesh/net-keys.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/net-keys.h b/mesh/net-keys.h index 4f480fcda..70b3d22c3 100644 --- a/mesh/net-keys.h +++ b/mesh/net-keys.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define BEACON_TYPE_SNB 0x01 diff --git a/mesh/net.c b/mesh/net.c index 6c7311732..01a475d74 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/net.h b/mesh/net.h index 7bec6d0fc..4dbc94b8b 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifndef __packed diff --git a/mesh/node.c b/mesh/node.c index f7ac5ff67..76d8fd6e9 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2017-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/node.h b/mesh/node.h index 7874b8692..30d53db33 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_net; diff --git a/mesh/pb-adv.c b/mesh/pb-adv.c index ae5b81391..c74dae79f 100644 --- a/mesh/pb-adv.c +++ b/mesh/pb-adv.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/pb-adv.h b/mesh/pb-adv.h index 80d53d234..5b1e03dae 100644 --- a/mesh/pb-adv.h +++ b/mesh/pb-adv.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ bool pb_adv_reg(bool initiator, mesh_prov_open_func_t open_cb, diff --git a/mesh/prov-acceptor.c b/mesh/prov-acceptor.c index 96f7e15ad..a03ee1ce5 100644 --- a/mesh/prov-acceptor.c +++ b/mesh/prov-acceptor.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/prov-initiator.c b/mesh/prov-initiator.c index 4de4df62d..8399282ee 100644 --- a/mesh/prov-initiator.c +++ b/mesh/prov-initiator.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/prov.h b/mesh/prov.h index 11b20b31f..99e864c50 100644 --- a/mesh/prov.h +++ b/mesh/prov.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifndef __packed diff --git a/mesh/provision.h b/mesh/provision.h index 1d78ed8e2..1a11b691b 100644 --- a/mesh/provision.h +++ b/mesh/provision.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ diff --git a/mesh/rpl.c b/mesh/rpl.c index 792c52ad6..7cea8e346 100644 --- a/mesh/rpl.c +++ b/mesh/rpl.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/rpl.h b/mesh/rpl.h index 2bbbdc9b9..9e988e7c5 100644 --- a/mesh/rpl.h +++ b/mesh/rpl.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_rpl { diff --git a/mesh/util.c b/mesh/util.c index 7d283331a..308e7d998 100644 --- a/mesh/util.c +++ b/mesh/util.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/util.h b/mesh/util.h index 93c2d8687..085ec3330 100644 --- a/mesh/util.h +++ b/mesh/util.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ uint32_t get_timestamp_secs(void); -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WP3ZG4IFYF/jTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:06:26 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oJ7kGIIFYF+/MQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:06:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 27B0AA0185; Tue, 15 Sep 2020 02:06:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726161AbgIOAFm (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:42 -0400 Received: from mga09.intel.com ([134.134.136.24]:37105 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbgIOAFh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:37 -0400 IronPort-SDR: tDnSSDDBaepl0vrcqRwMW7/nBDD/RAE0NqbpLgvWBHLCODR/PK3jb5l9yBdm3l5fMBQvjx9N5d mRuwWtefTtKg== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112045" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112045" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:34 -0700 IronPort-SDR: +HOr/HIrX3frJHBvQWqXBoNktKqZw5VlXpP0KqNta+pJcp2uJ5bqodKVYHqYv4pbr0BMwn7Uub h8HXm7wKkv2A== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333189" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:33 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 12/17] peripheral: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:52 -0700 Message-Id: <20200915000457.22988-13-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.28 / 15.00 / 15.00 X-Rspamd-Queue-Id: 27B0AA0185 X-Rspamd-UID: b1d153 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 11 License: LGPL-2.1-or-later peripheral/log.h peripheral/main.c peripheral/efivars.c peripheral/attach.h peripheral/gatt.c peripheral/attach.c peripheral/log.c peripheral/gap.h peripheral/efivars.h peripheral/gap.c peripheral/gatt.h --- peripheral/attach.c | 15 +-------------- peripheral/attach.h | 15 +-------------- peripheral/efivars.c | 15 +-------------- peripheral/efivars.h | 15 +-------------- peripheral/gap.c | 15 +-------------- peripheral/gap.h | 15 +-------------- peripheral/gatt.c | 15 +-------------- peripheral/gatt.h | 15 +-------------- peripheral/log.c | 15 +-------------- peripheral/log.h | 15 +-------------- peripheral/main.c | 15 +-------------- 11 files changed, 11 insertions(+), 154 deletions(-) diff --git a/peripheral/attach.c b/peripheral/attach.c index 1de02ac04..f7dc7ecea 100644 --- a/peripheral/attach.c +++ b/peripheral/attach.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/peripheral/attach.h b/peripheral/attach.h index f76e2fba2..c8d787d76 100644 --- a/peripheral/attach.h +++ b/peripheral/attach.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void attach_start(void); diff --git a/peripheral/efivars.c b/peripheral/efivars.c index 3cc213c0c..74fceed3e 100644 --- a/peripheral/efivars.c +++ b/peripheral/efivars.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/peripheral/efivars.h b/peripheral/efivars.h index 430d14330..5dac95395 100644 --- a/peripheral/efivars.h +++ b/peripheral/efivars.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define EFIVARS_NON_VOLATILE 0x00000001 diff --git a/peripheral/gap.c b/peripheral/gap.c index 52a7bed9b..b12e08b3d 100644 --- a/peripheral/gap.c +++ b/peripheral/gap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/peripheral/gap.h b/peripheral/gap.h index 6d6737810..da307a2ad 100644 --- a/peripheral/gap.h +++ b/peripheral/gap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/peripheral/gatt.c b/peripheral/gatt.c index bbbf3f59f..ff1354cb4 100644 --- a/peripheral/gatt.c +++ b/peripheral/gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/peripheral/gatt.h b/peripheral/gatt.h index 5b68f3573..7e2418a70 100644 --- a/peripheral/gatt.h +++ b/peripheral/gatt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/peripheral/log.c b/peripheral/log.c index d5834eb72..ac674b2df 100644 --- a/peripheral/log.c +++ b/peripheral/log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/peripheral/log.h b/peripheral/log.h index 36619b36e..29d1d6ac0 100644 --- a/peripheral/log.h +++ b/peripheral/log.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void log_open(void); diff --git a/peripheral/main.c b/peripheral/main.c index 75427ab3a..6ce729178 100644 --- a/peripheral/main.c +++ b/peripheral/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id HQ8zE5EFYF8mYQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:06:41 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id yITCDpEFYF+N9wAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:06:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 375D8A0B0A; Tue, 15 Sep 2020 02:06:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726158AbgIOAFy (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:54 -0400 Received: from mga09.intel.com ([134.134.136.24]:37077 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbgIOAFo (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:44 -0400 IronPort-SDR: pqr3YZcLEiPO4ocFkNEkPCqXxHjF+hmrcBRnhaGEz29DViwxxjL9cqQIo7ZU+N3mCZaBnbUshF BoTKhmFyl1aQ== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112043" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112043" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:33 -0700 IronPort-SDR: RiqeH9Jz7u3v3Ld/Syj+jY9D5KRh6YLg+YO9rBtKjNymKxqSpl6CG51KP9KITEYbqs/fcZlUfu hICAZUr0/hVw== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333178" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:32 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 11/17] obexd: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:51 -0700 Message-Id: <20200915000457.22988-12-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.68 / 15.00 / 15.00 X-Rspamd-Queue-Id: 375D8A0B0A X-Rspamd-UID: 911c35 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 65 License: GPL-2.0-or-later obexd/src/mimetype.c obexd/src/transport.h obexd/src/server.c obexd/src/obex.c obexd/src/log.h obexd/src/service.h obexd/src/plugin.h obexd/src/plugin.c obexd/src/main.c obexd/src/mimetype.h obexd/src/transport.c obexd/src/obexd.h obexd/src/obex.h obexd/src/obex-priv.h obexd/src/log.c obexd/src/map_ap.h obexd/src/manager.c obexd/src/service.c obexd/src/server.h obexd/src/manager.h obexd/plugins/opp.c obexd/plugins/vcard.h obexd/plugins/pbap.c obexd/plugins/vcard.c obexd/plugins/messages.h obexd/plugins/phonebook.h obexd/plugins/pcsuite.c obexd/plugins/messages-tracker.c obexd/plugins/phonebook-tracker.c obexd/plugins/irmc.c obexd/plugins/ftp.c obexd/plugins/ftp.h obexd/plugins/filesystem.c obexd/plugins/messages-dummy.c obexd/plugins/phonebook-ebook.c obexd/plugins/syncevolution.c obexd/plugins/bluetooth.c obexd/plugins/phonebook-dummy.c obexd/plugins/filesystem.h obexd/plugins/mas.c obexd/client/transport.h obexd/client/opp.c obexd/client/pbap.c obexd/client/transfer.h obexd/client/opp.h obexd/client/driver.c obexd/client/map-event.h obexd/client/bluetooth.h obexd/client/sync.h obexd/client/transport.c obexd/client/pbap.h obexd/client/driver.h obexd/client/transfer.c obexd/client/ftp.c obexd/client/map.h obexd/client/ftp.h obexd/client/bluetooth.c obexd/client/manager.c obexd/client/session.h obexd/client/session.c obexd/client/map.c obexd/client/sync.c obexd/client/map-event.c obexd/client/mns.c obexd/client/manager.h --- obexd/client/bluetooth.c | 15 +-------------- obexd/client/bluetooth.h | 15 +-------------- obexd/client/driver.c | 15 +-------------- obexd/client/driver.h | 15 +-------------- obexd/client/ftp.c | 15 +-------------- obexd/client/ftp.h | 15 +-------------- obexd/client/manager.c | 15 +-------------- obexd/client/manager.h | 15 +-------------- obexd/client/map-event.c | 15 +-------------- obexd/client/map-event.h | 15 +-------------- obexd/client/map.c | 15 +-------------- obexd/client/map.h | 15 +-------------- obexd/client/mns.c | 15 +-------------- obexd/client/opp.c | 15 +-------------- obexd/client/opp.h | 15 +-------------- obexd/client/pbap.c | 15 +-------------- obexd/client/pbap.h | 15 +-------------- obexd/client/session.c | 15 +-------------- obexd/client/session.h | 15 +-------------- obexd/client/sync.c | 15 +-------------- obexd/client/sync.h | 15 +-------------- obexd/client/transfer.c | 15 +-------------- obexd/client/transfer.h | 15 +-------------- obexd/client/transport.c | 15 +-------------- obexd/client/transport.h | 15 +-------------- obexd/plugins/bluetooth.c | 15 +-------------- obexd/plugins/filesystem.c | 15 +-------------- obexd/plugins/filesystem.h | 15 +-------------- obexd/plugins/ftp.c | 15 +-------------- obexd/plugins/ftp.h | 15 +-------------- obexd/plugins/irmc.c | 15 +-------------- obexd/plugins/mas.c | 15 +-------------- obexd/plugins/messages-dummy.c | 15 +-------------- obexd/plugins/messages-tracker.c | 15 +-------------- obexd/plugins/messages.h | 15 +-------------- obexd/plugins/opp.c | 15 +-------------- obexd/plugins/pbap.c | 15 +-------------- obexd/plugins/pcsuite.c | 15 +-------------- obexd/plugins/phonebook-dummy.c | 15 +-------------- obexd/plugins/phonebook-ebook.c | 15 +-------------- obexd/plugins/phonebook-tracker.c | 15 +-------------- obexd/plugins/phonebook.h | 15 +-------------- obexd/plugins/syncevolution.c | 15 +-------------- obexd/plugins/vcard.c | 15 +-------------- obexd/plugins/vcard.h | 15 +-------------- obexd/src/log.c | 15 +-------------- obexd/src/log.h | 15 +-------------- obexd/src/main.c | 15 +-------------- obexd/src/manager.c | 15 +-------------- obexd/src/manager.h | 15 +-------------- obexd/src/map_ap.h | 15 +-------------- obexd/src/mimetype.c | 15 +-------------- obexd/src/mimetype.h | 15 +-------------- obexd/src/obex-priv.h | 15 +-------------- obexd/src/obex.c | 15 +-------------- obexd/src/obex.h | 15 +-------------- obexd/src/obexd.h | 15 +-------------- obexd/src/plugin.c | 15 +-------------- obexd/src/plugin.h | 15 +-------------- obexd/src/server.c | 15 +-------------- obexd/src/server.h | 15 +-------------- obexd/src/service.c | 15 +-------------- obexd/src/service.h | 15 +-------------- obexd/src/transport.c | 15 +-------------- obexd/src/transport.h | 15 +-------------- 65 files changed, 65 insertions(+), 910 deletions(-) diff --git a/obexd/client/bluetooth.c b/obexd/client/bluetooth.c index 0c043e0ac..ca2c023fb 100644 --- a/obexd/client/bluetooth.c +++ b/obexd/client/bluetooth.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/bluetooth.h b/obexd/client/bluetooth.h index 968e131e0..4d5ba9c21 100644 --- a/obexd/client/bluetooth.h +++ b/obexd/client/bluetooth.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int bluetooth_init(void); diff --git a/obexd/client/driver.c b/obexd/client/driver.c index 0dae35601..195cdd2f1 100644 --- a/obexd/client/driver.c +++ b/obexd/client/driver.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/driver.h b/obexd/client/driver.h index 0112219d5..cc4cace7b 100644 --- a/obexd/client/driver.h +++ b/obexd/client/driver.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obc_driver { diff --git a/obexd/client/ftp.c b/obexd/client/ftp.c index 5e30654af..160e0636a 100644 --- a/obexd/client/ftp.c +++ b/obexd/client/ftp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/ftp.h b/obexd/client/ftp.h index 3d9096863..1326c8522 100644 --- a/obexd/client/ftp.h +++ b/obexd/client/ftp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int ftp_init(void); diff --git a/obexd/client/manager.c b/obexd/client/manager.c index fbcad6da4..75f1bfb04 100644 --- a/obexd/client/manager.c +++ b/obexd/client/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/manager.h b/obexd/client/manager.h index e4068de44..d4fdf8a1b 100644 --- a/obexd/client/manager.h +++ b/obexd/client/manager.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int client_manager_init(void); diff --git a/obexd/client/map-event.c b/obexd/client/map-event.c index e164e863c..c988ef3dd 100644 --- a/obexd/client/map-event.c +++ b/obexd/client/map-event.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX @@ -5,20 +6,6 @@ * Copyright (C) 2013 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/map-event.h b/obexd/client/map-event.h index 5414b2621..bb127b0f4 100644 --- a/obexd/client/map-event.h +++ b/obexd/client/map-event.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX @@ -5,20 +6,6 @@ * Copyright (C) 2013 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obc_session; diff --git a/obexd/client/map.c b/obexd/client/map.c index 23be2d6b2..74828cddb 100644 --- a/obexd/client/map.c +++ b/obexd/client/map.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client * * Copyright (C) 2011 Bartosz Szatkowski <bulislaw@linux.com> for Comarch * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/map.h b/obexd/client/map.h index 86f6b9512..15228ed0a 100644 --- a/obexd/client/map.h +++ b/obexd/client/map.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client * * Copyright (C) 2011 Bartosz Szatkowski <bulislaw@linux.com> for Comarch * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int map_init(void); diff --git a/obexd/client/mns.c b/obexd/client/mns.c index 4912cb90f..e52505642 100644 --- a/obexd/client/mns.c +++ b/obexd/client/mns.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2013 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/opp.c b/obexd/client/opp.c index 92785f66e..90d0c0c8e 100644 --- a/obexd/client/opp.c +++ b/obexd/client/opp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/opp.h b/obexd/client/opp.h index a23e94e00..ecc3e05ed 100644 --- a/obexd/client/opp.h +++ b/obexd/client/opp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int opp_init(void); diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c index 3f5665fcd..1a2bacc9f 100644 --- a/obexd/client/pbap.c +++ b/obexd/client/pbap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/pbap.h b/obexd/client/pbap.h index ce56258b5..8107f81bf 100644 --- a/obexd/client/pbap.h +++ b/obexd/client/pbap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int pbap_init(void); diff --git a/obexd/client/session.c b/obexd/client/session.c index 5bd2d2670..6955a8089 100644 --- a/obexd/client/session.c +++ b/obexd/client/session.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2011-2012 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/session.h b/obexd/client/session.h index b561b7e58..2c646df1a 100644 --- a/obexd/client/session.h +++ b/obexd/client/session.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2011-2012 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/obexd/client/sync.c b/obexd/client/sync.c index 548c318c3..92faf4434 100644 --- a/obexd/client/sync.c +++ b/obexd/client/sync.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/sync.h b/obexd/client/sync.h index 8adc5f8d6..5d8844c4f 100644 --- a/obexd/client/sync.h +++ b/obexd/client/sync.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int sync_init(void); diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c index b53dffa21..744d8f106 100644 --- a/obexd/client/transfer.c +++ b/obexd/client/transfer.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2011-2012 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/transfer.h b/obexd/client/transfer.h index b6b835d18..323332a62 100644 --- a/obexd/client/transfer.h +++ b/obexd/client/transfer.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2011-2012 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obc_transfer; diff --git a/obexd/client/transport.c b/obexd/client/transport.c index 4cd770672..4e442e9b5 100644 --- a/obexd/client/transport.c +++ b/obexd/client/transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/transport.h b/obexd/client/transport.h index b035cfc45..e1f1a5c53 100644 --- a/obexd/client/transport.h +++ b/obexd/client/transport.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef void (*obc_transport_func)(GIOChannel *io, GError *err, diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c index ba1e0a99a..d232d3fd5 100644 --- a/obexd/plugins/bluetooth.c +++ b/obexd/plugins/bluetooth.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c index 48239a8bc..8e53c181c 100644 --- a/obexd/plugins/filesystem.c +++ b/obexd/plugins/filesystem.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/filesystem.h b/obexd/plugins/filesystem.h index f95773beb..63cda985e 100644 --- a/obexd/plugins/filesystem.h +++ b/obexd/plugins/filesystem.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ ssize_t string_read(void *object, void *buf, size_t count); diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c index 3ee18a619..f60cf143d 100644 --- a/obexd/plugins/ftp.c +++ b/obexd/plugins/ftp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/ftp.h b/obexd/plugins/ftp.h index f06de8490..b9934b23b 100644 --- a/obexd/plugins/ftp.h +++ b/obexd/plugins/ftp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void *ftp_connect(struct obex_session *os, int *err); diff --git a/obexd/plugins/irmc.c b/obexd/plugins/irmc.c index fcf5340e7..cd143e7a3 100644 --- a/obexd/plugins/irmc.c +++ b/obexd/plugins/irmc.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX IrMC Sync Server * * Copyright (C) 2010 Marcel Mol <marcel@mesa.nl> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c index f73c3e9d8..5d00bc563 100644 --- a/obexd/plugins/mas.c +++ b/obexd/plugins/mas.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2010-2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c index 3eca9ef4c..34199fa05 100644 --- a/obexd/plugins/messages-dummy.c +++ b/obexd/plugins/messages-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2010-2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/messages-tracker.c b/obexd/plugins/messages-tracker.c index 60f3a807e..4ce9f221d 100644 --- a/obexd/plugins/messages-tracker.c +++ b/obexd/plugins/messages-tracker.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2010-2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/messages.h b/obexd/plugins/messages.h index 00a16b1ae..535ec303c 100644 --- a/obexd/plugins/messages.h +++ b/obexd/plugins/messages.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2010-2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <glib.h> diff --git a/obexd/plugins/opp.c b/obexd/plugins/opp.c index 5bb766770..860161303 100644 --- a/obexd/plugins/opp.c +++ b/obexd/plugins/opp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c index d5a3046ae..efae92cd8 100644 --- a/obexd/plugins/pbap.c +++ b/obexd/plugins/pbap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c index 43ab409e9..b2232ea09 100644 --- a/obexd/plugins/pcsuite.c +++ b/obexd/plugins/pcsuite.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c index 9279ef29a..4d0b70504 100644 --- a/obexd/plugins/phonebook-dummy.c +++ b/obexd/plugins/phonebook-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/phonebook-ebook.c b/obexd/plugins/phonebook-ebook.c index c422585df..30be9d921 100644 --- a/obexd/plugins/phonebook-ebook.c +++ b/obexd/plugins/phonebook-ebook.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c index c1d14078b..30f945b84 100644 --- a/obexd/plugins/phonebook-tracker.c +++ b/obexd/plugins/phonebook-tracker.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Phonebook access through D-Bus vCard and call history service * * Copyright (C) 2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/phonebook.h b/obexd/plugins/phonebook.h index 70a9cb797..c73ae73b8 100644 --- a/obexd/plugins/phonebook.h +++ b/obexd/plugins/phonebook.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define EOL "\r\n" diff --git a/obexd/plugins/syncevolution.c b/obexd/plugins/syncevolution.c index 854505a58..88744f28a 100644 --- a/obexd/plugins/syncevolution.c +++ b/obexd/plugins/syncevolution.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c index dc7c3b3e6..0a727b729 100644 --- a/obexd/plugins/vcard.c +++ b/obexd/plugins/vcard.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * OBEX Server * * Copyright (C) 2008-2010 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/vcard.h b/obexd/plugins/vcard.h index 22c3f6899..880660ffa 100644 --- a/obexd/plugins/vcard.h +++ b/obexd/plugins/vcard.h @@ -1,22 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * OBEX Server * * Copyright (C) 2008-2010 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ enum phonebook_number_type { diff --git a/obexd/src/log.c b/obexd/src/log.c index 8e2ebaab2..6c29064e3 100644 --- a/obexd/src/log.c +++ b/obexd/src/log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/log.h b/obexd/src/log.h index d9fb8678f..7dc74d542 100644 --- a/obexd/src/log.h +++ b/obexd/src/log.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void info(const char *format, ...) __attribute__((format(printf, 1, 2))); diff --git a/obexd/src/main.c b/obexd/src/main.c index 139f1412c..629a3b4c1 100644 --- a/obexd/src/main.c +++ b/obexd/src/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/manager.c b/obexd/src/manager.c index a4af627cb..01741fe62 100644 --- a/obexd/src/manager.c +++ b/obexd/src/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/manager.h b/obexd/src/manager.h index d709af5a8..8fa12d15d 100644 --- a/obexd/src/manager.h +++ b/obexd/src/manager.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <dbus/dbus.h> diff --git a/obexd/src/map_ap.h b/obexd/src/map_ap.h index da108fe6e..59efc49de 100644 --- a/obexd/src/map_ap.h +++ b/obexd/src/map_ap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2010-2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ /* List of OBEX application parameters tags as per MAP specification. */ diff --git a/obexd/src/mimetype.c b/obexd/src/mimetype.c index c8b040a43..212f24b18 100644 --- a/obexd/src/mimetype.c +++ b/obexd/src/mimetype.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/mimetype.h b/obexd/src/mimetype.h index 79529b890..e1c14f405 100644 --- a/obexd/src/mimetype.h +++ b/obexd/src/mimetype.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef gboolean (*obex_object_io_func) (void *object, int flags, int err, diff --git a/obexd/src/obex-priv.h b/obexd/src/obex-priv.h index 355a7f87b..db409e7e4 100644 --- a/obexd/src/obex-priv.h +++ b/obexd/src/obex-priv.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obex_session { diff --git a/obexd/src/obex.c b/obexd/src/obex.c index 2850d3a37..9f992ec18 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/obex.h b/obexd/src/obex.h index 67593f11b..755be1caf 100644 --- a/obexd/src/obex.h +++ b/obexd/src/obex.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <unistd.h> diff --git a/obexd/src/obexd.h b/obexd/src/obexd.h index 42c3c4d97..fe312a65b 100644 --- a/obexd/src/obexd.h +++ b/obexd/src/obexd.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define OBEX_OPP (1 << 1) diff --git a/obexd/src/plugin.c b/obexd/src/plugin.c index a1962b91d..0df9d5258 100644 --- a/obexd/src/plugin.c +++ b/obexd/src/plugin.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/plugin.h b/obexd/src/plugin.h index 13d77695f..703878460 100644 --- a/obexd/src/plugin.h +++ b/obexd/src/plugin.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obex_plugin_desc { diff --git a/obexd/src/server.c b/obexd/src/server.c index db854233b..a8fc45092 100644 --- a/obexd/src/server.c +++ b/obexd/src/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/server.h b/obexd/src/server.h index 278c35fce..c31236ec0 100644 --- a/obexd/src/server.h +++ b/obexd/src/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obex_server { diff --git a/obexd/src/service.c b/obexd/src/service.c index c088535e9..0f4e420e8 100644 --- a/obexd/src/service.c +++ b/obexd/src/service.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/service.h b/obexd/src/service.h index 5d9d325fb..e3aee3bf3 100644 --- a/obexd/src/service.h +++ b/obexd/src/service.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define OBEX_PORT_RANDOM UINT16_MAX diff --git a/obexd/src/transport.c b/obexd/src/transport.c index 4984643e2..4b5895e5d 100644 --- a/obexd/src/transport.c +++ b/obexd/src/transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/transport.h b/obexd/src/transport.h index 97e10d05f..3a16b7620 100644 --- a/obexd/src/transport.h +++ b/obexd/src/transport.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obex_transport_driver { -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0ImyOaYFYF85SwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:07:02 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id kLQRNqYFYF/JYAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:07:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B82A1A0195; Tue, 15 Sep 2020 02:06:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726184AbgIOAFz (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:55 -0400 Received: from mga09.intel.com ([134.134.136.24]:37105 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbgIOAFw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:52 -0400 IronPort-SDR: ApmCtbNOn0y2bEEAfdPBMGaSurcZJi7JKzrUPet2iIHHsHDCIY+7wVyqC/He1wDdMkR3Gh8JLz u7NPER7OsYlg== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112056" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112056" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:38 -0700 IronPort-SDR: o+/LyK8JKsU2m/P6ny2ZiIMOCV39cuneAk3xGZJB69MONprWW99az6btXZaqybI72JkkyxaEpd fxV4DrIc7yTA== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333204" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:38 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 15/17] unit: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:55 -0700 Message-Id: <20200915000457.22988-16-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.05 / 15.00 / 15.00 X-Rspamd-Queue-Id: B82A1A0195 X-Rspamd-UID: d19204 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 25 LGPL-2.1-or-later : 1 GPL-2.0-only : 2 BSD-2-Clause : 1 License: GPL-2.0-or-later unit/test-hog.c unit/test-eir.c unit/test-gobex-header.c unit/test-crc.c unit/test-avrcp.c unit/test-ringbuf.c unit/test-gobex-apparam.c unit/test-gobex.c unit/test-hfp.c unit/test-textfile.c unit/test-avdtp.c unit/test-sdp.c unit/test-gatt.c unit/test-avctp.c unit/test-gattrib.c unit/test-queue.c unit/test-gobex-packet.c unit/test-uuid.c unit/test-crypto.c unit/test-uhid.c unit/test-gdbus-client.c unit/test-midi.c unit/test-lib.c unit/test-mgmt.c unit/test-gobex-transfer.c License: LGPL-2.1-or-later unit/test-mesh-crypto.c License: GPL-2.0-only unit/util.h unit/util.c License: BSD-2-Clause unit/test-ecc.c --- unit/test-avctp.c | 15 +-------------- unit/test-avdtp.c | 15 +-------------- unit/test-avrcp.c | 15 +-------------- unit/test-crc.c | 15 +-------------- unit/test-crypto.c | 15 +-------------- unit/test-ecc.c | 21 +-------------------- unit/test-eir.c | 15 +-------------- unit/test-gatt.c | 15 +-------------- unit/test-gattrib.c | 15 +-------------- unit/test-gdbus-client.c | 15 +-------------- unit/test-gobex-apparam.c | 15 +-------------- unit/test-gobex-header.c | 15 +-------------- unit/test-gobex-packet.c | 15 +-------------- unit/test-gobex-transfer.c | 15 +-------------- unit/test-gobex.c | 15 +-------------- unit/test-hfp.c | 15 +-------------- unit/test-hog.c | 15 +-------------- unit/test-lib.c | 15 +-------------- unit/test-mesh-crypto.c | 11 +---------- unit/test-mgmt.c | 15 +-------------- unit/test-midi.c | 16 +--------------- unit/test-queue.c | 15 +-------------- unit/test-ringbuf.c | 15 +-------------- unit/test-sdp.c | 15 +-------------- unit/test-textfile.c | 15 +-------------- unit/test-uhid.c | 15 +-------------- unit/test-uuid.c | 15 +-------------- unit/util.c | 14 +------------- unit/util.h | 14 +------------- 29 files changed, 29 insertions(+), 407 deletions(-) diff --git a/unit/test-avctp.c b/unit/test-avctp.c index c92618bab..fa7db59c8 100644 --- a/unit/test-avctp.c +++ b/unit/test-avctp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c index 13c03d037..f5340d6f3 100644 --- a/unit/test-avdtp.c +++ b/unit/test-avdtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c index adf25f002..34a70377d 100644 --- a/unit/test-avrcp.c +++ b/unit/test-avrcp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-crc.c b/unit/test-crc.c index 791fa5137..107c95e13 100644 --- a/unit/test-crc.c +++ b/unit/test-crc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-crypto.c b/unit/test-crypto.c index 46c7c0e5c..3a88b4a52 100644 --- a/unit/test-crypto.c +++ b/unit/test-crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-ecc.c b/unit/test-ecc.c index d9136814d..b838cc29b 100644 --- a/unit/test-ecc.c +++ b/unit/test-ecc.c @@ -1,27 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause /* * Copyright (c) 2013, Kenneth MacKay * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-eir.c b/unit/test-eir.c index 421d0db13..e05a37d01 100644 --- a/unit/test-eir.c +++ b/unit/test-eir.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gatt.c b/unit/test-gatt.c index 0b77df51c..6a49210c5 100644 --- a/unit/test-gatt.c +++ b/unit/test-gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gattrib.c b/unit/test-gattrib.c index 416e59635..9c7dea094 100644 --- a/unit/test-gattrib.c +++ b/unit/test-gattrib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Google, Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c index ccf706713..514c58b8e 100644 --- a/unit/test-gdbus-client.c +++ b/unit/test-gdbus-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gobex-apparam.c b/unit/test-gobex-apparam.c index 59393c681..330a7819a 100644 --- a/unit/test-gobex-apparam.c +++ b/unit/test-gobex-apparam.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2012 Intel Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gobex-header.c b/unit/test-gobex-header.c index 3450f8123..941e18d47 100644 --- a/unit/test-gobex-header.c +++ b/unit/test-gobex-header.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gobex-packet.c b/unit/test-gobex-packet.c index d382ee5b3..2664bef4e 100644 --- a/unit/test-gobex-packet.c +++ b/unit/test-gobex-packet.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c index 3f8905c0b..4f652dea8 100644 --- a/unit/test-gobex-transfer.c +++ b/unit/test-gobex-transfer.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gobex.c b/unit/test-gobex.c index 1afb7ceff..6fbfa183e 100644 --- a/unit/test-gobex.c +++ b/unit/test-gobex.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-hfp.c b/unit/test-hfp.c index 890eee659..f504724d7 100644 --- a/unit/test-hfp.c +++ b/unit/test-hfp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <sys/socket.h> diff --git a/unit/test-hog.c b/unit/test-hog.c index e257fbd88..e6d4affc4 100644 --- a/unit/test-hog.c +++ b/unit/test-hog.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-lib.c b/unit/test-lib.c index 1dd5d92cf..8395c2a73 100644 --- a/unit/test-lib.c +++ b/unit/test-lib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2013 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-mesh-crypto.c b/unit/test-mesh-crypto.c index ed37ae1a7..12709dace 100644 --- a/unit/test-mesh-crypto.c +++ b/unit/test-mesh-crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-mgmt.c b/unit/test-mgmt.c index c67678b9a..1b71e562f 100644 --- a/unit/test-mgmt.c +++ b/unit/test-mgmt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-midi.c b/unit/test-midi.c index 593bc5a5c..644fcdc6d 100644 --- a/unit/test-midi.c +++ b/unit/test-midi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,21 +6,6 @@ * Copyright (C) 2015,2016 Felipe F. Tonello <eu@felipetonello.com> * Copyright (C) 2016 ROLI Ltd. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-queue.c b/unit/test-queue.c index d912a6416..46018ef9c 100644 --- a/unit/test-queue.c +++ b/unit/test-queue.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-ringbuf.c b/unit/test-ringbuf.c index ef3bf0a50..b1cf51115 100644 --- a/unit/test-ringbuf.c +++ b/unit/test-ringbuf.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-sdp.c b/unit/test-sdp.c index 03501d021..d3a885f19 100644 --- a/unit/test-sdp.c +++ b/unit/test-sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-textfile.c b/unit/test-textfile.c index 4b43898d6..a1485a543 100644 --- a/unit/test-textfile.c +++ b/unit/test-textfile.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-uhid.c b/unit/test-uhid.c index 320cd54d4..001d39a3d 100644 --- a/unit/test-uhid.c +++ b/unit/test-uhid.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-uuid.c b/unit/test-uuid.c index 7c6789e39..0889630cf 100644 --- a/unit/test-uuid.c +++ b/unit/test-uuid.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/util.c b/unit/util.c index c8054d2e4..e7804d884 100644 --- a/unit/util.c +++ b/unit/util.c @@ -1,22 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/util.h b/unit/util.h index b13fd2f16..d5d0f19c5 100644 --- a/unit/util.h +++ b/unit/util.h @@ -1,22 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define TEST_BUF_MAX 5 -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mBFnK64FYF/jTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:07:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id kCc+KK4FYF9YaQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:07:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0EA14A0B1F; Tue, 15 Sep 2020 02:07:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726169AbgIOAFn (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:05:43 -0400 Received: from mga09.intel.com ([134.134.136.24]:37104 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726136AbgIOAFj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:39 -0400 IronPort-SDR: V/nKsfKh/XiAZBm/KxjNyZovTxKZiCCB2YwCu5W8rY8ZDjiUOcb8LG97q/M0HPFRbQaC2XxG8B 6ZJhxWH665gA== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112038" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112038" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:30 -0700 IronPort-SDR: hR0fGCjvmDEhySBE6vxNHipelQ7pAezDu5B4EKwRnF678wTH69Hry0uP63QeJFtFWnsw/ZDk64 3MwzWvuqk3dA== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333170" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:30 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 10/17] monitor: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:50 -0700 Message-Id: <20200915000457.22988-11-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.29 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0EA14A0B1F X-Rspamd-UID: 7aa340 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 47 License: LGPL-2.1-or-later monitor/bt.h monitor/hcidump.h monitor/avdtp.h monitor/crc.c monitor/sdp.c monitor/hwdb.c monitor/intel.h monitor/avctp.c monitor/control.h monitor/display.c monitor/a2dp.c monitor/ll.c monitor/ll.h monitor/jlink.h monitor/broadcom.h monitor/lmp.c monitor/keys.c monitor/ellisys.c monitor/main.c monitor/ellisys.h monitor/hwdb.h monitor/display.h monitor/jlink.c monitor/rfcomm.h monitor/packet.c monitor/crc.h monitor/keys.h monitor/sdp.h monitor/rfcomm.c monitor/avdtp.c monitor/a2dp.h monitor/avctp.h monitor/vendor.h monitor/hcidump.c monitor/intel.c monitor/tty.h monitor/control.c monitor/lmp.h monitor/analyze.c monitor/bnep.c monitor/l2cap.c monitor/vendor.c monitor/packet.h monitor/broadcom.c monitor/analyze.h monitor/l2cap.h monitor/bnep.h --- monitor/a2dp.c | 15 +-------------- monitor/a2dp.h | 15 +-------------- monitor/analyze.c | 15 +-------------- monitor/analyze.h | 15 +-------------- monitor/avctp.c | 15 +-------------- monitor/avctp.h | 15 +-------------- monitor/avdtp.c | 15 +-------------- monitor/avdtp.h | 15 +-------------- monitor/bnep.c | 15 +-------------- monitor/bnep.h | 15 +-------------- monitor/broadcom.c | 15 +-------------- monitor/broadcom.h | 15 +-------------- monitor/bt.h | 15 +-------------- monitor/control.c | 15 +-------------- monitor/control.h | 15 +-------------- monitor/crc.c | 15 +-------------- monitor/crc.h | 15 +-------------- monitor/display.c | 15 +-------------- monitor/display.h | 15 +-------------- monitor/ellisys.c | 15 +-------------- monitor/ellisys.h | 15 +-------------- monitor/hcidump.c | 15 +-------------- monitor/hcidump.h | 15 +-------------- monitor/hwdb.c | 15 +-------------- monitor/hwdb.h | 15 +-------------- monitor/intel.c | 15 +-------------- monitor/intel.h | 15 +-------------- monitor/jlink.c | 15 +-------------- monitor/jlink.h | 15 +-------------- monitor/keys.c | 15 +-------------- monitor/keys.h | 15 +-------------- monitor/l2cap.c | 15 +-------------- monitor/l2cap.h | 15 +-------------- monitor/ll.c | 15 +-------------- monitor/ll.h | 15 +-------------- monitor/lmp.c | 15 +-------------- monitor/lmp.h | 15 +-------------- monitor/main.c | 15 +-------------- monitor/packet.c | 15 +-------------- monitor/packet.h | 15 +-------------- monitor/rfcomm.c | 15 +-------------- monitor/rfcomm.h | 15 +-------------- monitor/sdp.c | 15 +-------------- monitor/sdp.h | 15 +-------------- monitor/tty.h | 15 +-------------- monitor/vendor.c | 15 +-------------- monitor/vendor.h | 15 +-------------- 47 files changed, 47 insertions(+), 658 deletions(-) diff --git a/monitor/a2dp.c b/monitor/a2dp.c index 4a1d0e1c4..ac2e1a228 100644 --- a/monitor/a2dp.c +++ b/monitor/a2dp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2018 Pali Rohár <pali.rohar@gmail.com> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/a2dp.h b/monitor/a2dp.h index 72a8f1f45..814c8ed90 100644 --- a/monitor/a2dp.h +++ b/monitor/a2dp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool a2dp_codec_cap(uint8_t codec, uint8_t losc, struct l2cap_frame *frame); diff --git a/monitor/analyze.c b/monitor/analyze.c index 4dc2891a1..784f9a0a4 100644 --- a/monitor/analyze.c +++ b/monitor/analyze.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/analyze.h b/monitor/analyze.h index c643d3502..774ac9db5 100644 --- a/monitor/analyze.h +++ b/monitor/analyze.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void analyze_trace(const char *path); diff --git a/monitor/avctp.c b/monitor/avctp.c index 6c2c2cac0..dc03195a8 100644 --- a/monitor/avctp.c +++ b/monitor/avctp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/avctp.h b/monitor/avctp.h index 2613f14f3..1cca5a756 100644 --- a/monitor/avctp.h +++ b/monitor/avctp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void avctp_packet(const struct l2cap_frame *frame); diff --git a/monitor/avdtp.c b/monitor/avdtp.c index 6a342a282..9fe72d240 100644 --- a/monitor/avdtp.c +++ b/monitor/avdtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/avdtp.h b/monitor/avdtp.h index f77d82ee2..1bc4dd03d 100644 --- a/monitor/avdtp.h +++ b/monitor/avdtp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void avdtp_packet(const struct l2cap_frame *frame); diff --git a/monitor/bnep.c b/monitor/bnep.c index 6af54e0c5..3b8b284a9 100644 --- a/monitor/bnep.c +++ b/monitor/bnep.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/bnep.h b/monitor/bnep.h index 38340d6c1..3ccc1b766 100644 --- a/monitor/bnep.h +++ b/monitor/bnep.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void bnep_packet(const struct l2cap_frame *frame); diff --git a/monitor/broadcom.c b/monitor/broadcom.c index 787ff2950..4f8455583 100644 --- a/monitor/broadcom.c +++ b/monitor/broadcom.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/broadcom.h b/monitor/broadcom.h index ceda0e18b..5cb51d81d 100644 --- a/monitor/broadcom.h +++ b/monitor/broadcom.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/bt.h b/monitor/bt.h index 37e81e8a3..aca847d7c 100644 --- a/monitor/bt.h +++ b/monitor/bt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/control.c b/monitor/control.c index 273075888..962da4980 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/control.h b/monitor/control.h index ddf485f1f..29616c4f1 100644 --- a/monitor/control.h +++ b/monitor/control.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/crc.c b/monitor/crc.c index 912b37ebc..8d0e31db9 100644 --- a/monitor/crc.c +++ b/monitor/crc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/crc.h b/monitor/crc.h index 772388b80..c59775100 100644 --- a/monitor/crc.h +++ b/monitor/crc.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/display.c b/monitor/display.c index 990395425..b11b71d5d 100644 --- a/monitor/display.c +++ b/monitor/display.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/display.h b/monitor/display.h index 98073b99e..f3a614b81 100644 --- a/monitor/display.h +++ b/monitor/display.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/monitor/ellisys.c b/monitor/ellisys.c index e533eeceb..61ac24c23 100644 --- a/monitor/ellisys.c +++ b/monitor/ellisys.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/ellisys.h b/monitor/ellisys.h index 8be888dfe..c0c4ff192 100644 --- a/monitor/ellisys.h +++ b/monitor/ellisys.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/hcidump.c b/monitor/hcidump.c index 8b6f846d3..690b9b913 100644 --- a/monitor/hcidump.c +++ b/monitor/hcidump.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/hcidump.h b/monitor/hcidump.h index c90865068..d32b33c81 100644 --- a/monitor/hcidump.h +++ b/monitor/hcidump.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int hcidump_tracing(void); diff --git a/monitor/hwdb.c b/monitor/hwdb.c index f2431fad8..22de9edfb 100644 --- a/monitor/hwdb.c +++ b/monitor/hwdb.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/hwdb.h b/monitor/hwdb.h index 79f505a2d..5789b6507 100644 --- a/monitor/hwdb.h +++ b/monitor/hwdb.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/intel.c b/monitor/intel.c index 41e70ba0c..18840f3e7 100644 --- a/monitor/intel.c +++ b/monitor/intel.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/intel.h b/monitor/intel.h index 573b23f3f..bf00ad491 100644 --- a/monitor/intel.h +++ b/monitor/intel.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/jlink.c b/monitor/jlink.c index afa9d9323..9aaa4ebd8 100644 --- a/monitor/jlink.c +++ b/monitor/jlink.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2018 Codecoup * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/jlink.h b/monitor/jlink.h index d7c76704c..e445e553c 100644 --- a/monitor/jlink.h +++ b/monitor/jlink.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2018 Codecoup * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int jlink_init(void); diff --git a/monitor/keys.c b/monitor/keys.c index e60aa9386..d2fa3b23f 100644 --- a/monitor/keys.c +++ b/monitor/keys.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/keys.h b/monitor/keys.h index 61ec50a4c..e40c90fa9 100644 --- a/monitor/keys.h +++ b/monitor/keys.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/l2cap.c b/monitor/l2cap.c index 41c766863..ca1997a0c 100644 --- a/monitor/l2cap.c +++ b/monitor/l2cap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/l2cap.h b/monitor/l2cap.h index 07864caee..e46042db4 100644 --- a/monitor/l2cap.h +++ b/monitor/l2cap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/ll.c b/monitor/ll.c index 4b3f567bd..cf93647e0 100644 --- a/monitor/ll.c +++ b/monitor/ll.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/ll.h b/monitor/ll.h index 98e0bf489..35d631363 100644 --- a/monitor/ll.h +++ b/monitor/ll.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/lmp.c b/monitor/lmp.c index 3088c5ee2..0d17f5c98 100644 --- a/monitor/lmp.c +++ b/monitor/lmp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/lmp.h b/monitor/lmp.h index 9564c7779..d29ad8e46 100644 --- a/monitor/lmp.h +++ b/monitor/lmp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/main.c b/monitor/main.c index 24ec3c567..e6a40703c 100644 --- a/monitor/main.c +++ b/monitor/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/packet.c b/monitor/packet.c index bef134095..d83552f74 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/packet.h b/monitor/packet.h index 3a139ecb7..409bf0e54 100644 --- a/monitor/packet.h +++ b/monitor/packet.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c index 94d28de31..9b88a3440 100644 --- a/monitor/rfcomm.c +++ b/monitor/rfcomm.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/rfcomm.h b/monitor/rfcomm.h index c15735234..81ab55b21 100644 --- a/monitor/rfcomm.h +++ b/monitor/rfcomm.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define RFCOMM_SABM 0x2f diff --git a/monitor/sdp.c b/monitor/sdp.c index 575eda536..10bc0a121 100644 --- a/monitor/sdp.c +++ b/monitor/sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/sdp.h b/monitor/sdp.h index c8a9bb0cd..4fffb30f9 100644 --- a/monitor/sdp.h +++ b/monitor/sdp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void sdp_packet(const struct l2cap_frame *frame); diff --git a/monitor/tty.h b/monitor/tty.h index f0ba0c5c0..87b3fd53c 100644 --- a/monitor/tty.h +++ b/monitor/tty.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2016 Intel Corporation * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/vendor.c b/monitor/vendor.c index 3dda2ae3b..ecbfcf2eb 100644 --- a/monitor/vendor.c +++ b/monitor/vendor.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/vendor.h b/monitor/vendor.h index f5792b3c5..c70552b66 100644 --- a/monitor/vendor.h +++ b/monitor/vendor.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iK1nMLcFYF/jTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:07:19 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AKjKLbcFYF9FogAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:07:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C8345A0B35; Tue, 15 Sep 2020 02:07:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726095AbgIOAGB (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:06:01 -0400 Received: from mga09.intel.com ([134.134.136.24]:37105 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbgIOAFn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:43 -0400 IronPort-SDR: tEYOD2n5LcQV+98rjF2UqhgTGeKB0vu1z2eihVFRLZUHLlPyeQG08ICOQoOvB86HhUu2B/E8Me UNOKgyQaNkvA== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112049" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112049" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:35 -0700 IronPort-SDR: RRMh1NKVJWboJE8cTp216m25pkOfUysCUfmnTPOpAI4/TaR7bxwlm+155VPlRv/a10hytqsfsO aWohXXL/EApw== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333194" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:35 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 13/17] plugins: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:53 -0700 Message-Id: <20200915000457.22988-14-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 4.22 / 15.00 / 15.00 X-Rspamd-Queue-Id: C8345A0B35 X-Rspamd-UID: b967f6 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 7 License: GPL-2.0-or-later plugins/autopair.c plugins/hostname.c plugins/neard.c plugins/policy.c plugins/sixaxis.c plugins/wiimote.c plugins/external-dummy.c --- plugins/autopair.c | 15 +-------------- plugins/external-dummy.c | 15 +-------------- plugins/hostname.c | 15 +-------------- plugins/neard.c | 15 +-------------- plugins/policy.c | 15 +-------------- plugins/sixaxis.c | 15 +-------------- plugins/wiimote.c | 15 +-------------- 7 files changed, 7 insertions(+), 98 deletions(-) diff --git a/plugins/autopair.c b/plugins/autopair.c index 3089430a8..665a4f4a6 100644 --- a/plugins/autopair.c +++ b/plugins/autopair.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/external-dummy.c b/plugins/external-dummy.c index 536ad0663..1c209e8b7 100644 --- a/plugins/external-dummy.c +++ b/plugins/external-dummy.c @@ -1,21 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/hostname.c b/plugins/hostname.c index 4f9dfe6d8..f7ab9e8bc 100644 --- a/plugins/hostname.c +++ b/plugins/hostname.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/neard.c b/plugins/neard.c index 6ffcd6e10..ff5de11f4 100644 --- a/plugins/neard.c +++ b/plugins/neard.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2013 Tieto Poland * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/policy.c b/plugins/policy.c index de51e58b9..bf7cf03bb 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013 Intel Corporation. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c index 939fed759..1ec9ba9fc 100644 --- a/plugins/sixaxis.c +++ b/plugins/sixaxis.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2013 Szymon Janc <szymon.janc@gmail.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/wiimote.c b/plugins/wiimote.c index 0ced27514..9c4e0a58b 100644 --- a/plugins/wiimote.c +++ b/plugins/wiimote.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011-2012 David Herrmann <dh.herrmann@googlemail.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GJR6H8EFYF/jTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 02:07:29 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 0L2HHMEFYF8HwgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 02:07:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EFF9CA0B0A; Tue, 15 Sep 2020 02:07:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726106AbgIOAGI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 20:06:08 -0400 Received: from mga09.intel.com ([134.134.136.24]:37104 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726159AbgIOAF5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 20:05:57 -0400 IronPort-SDR: qR71FR4IAbAuEL7+orRtDND7ihs7VsIKLu5OviyTJL0FXxh1T9ouKmFQYPDNxK0xsxa39NIMo/ roeMXhuqG0Cg== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="160112054" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="160112054" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:37 -0700 IronPort-SDR: DzlAfKJveLcVTdfth6RiXc/x5Iyu1eU/JnGhPvR2RzisHa0vMrjqhg2YqUmfYceJUUKjswS2Q9 kCuEjtJ97dgg== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="507333200" Received: from azvasil-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.254.127.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 17:05:36 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v3 14/17] profiles: Add SPDX License Identifier Date: Mon, 14 Sep 2020 17:04:54 -0700 Message-Id: <20200915000457.22988-15-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.36 / 15.00 / 15.00 X-Rspamd-Queue-Id: EFF9CA0B0A X-Rspamd-UID: a4ef98 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 72 LGPL-2.1-or-later : 6 License: GPL-2.0-or-later profiles/deviceinfo/dis.c profiles/deviceinfo/deviceinfo.c profiles/health/hdp_types.h profiles/health/mcap.c profiles/health/hdp_manager.c profiles/health/hdp_main.c profiles/health/mcap.h profiles/health/hdp_util.h profiles/health/hdp_manager.h profiles/health/hdp_util.c profiles/health/hdp.c profiles/health/hdp.h profiles/network/server.c profiles/network/connection.h profiles/network/connection.c profiles/network/manager.c profiles/network/bnep.c profiles/network/server.h profiles/network/bnep.h profiles/battery/battery.c profiles/cups/cups.h profiles/cups/sdp.c profiles/cups/main.c profiles/cups/spp.c profiles/cups/hcrp.c profiles/scanparam/scpp.c profiles/scanparam/scan.c profiles/audio/transport.h profiles/audio/avdtp.h profiles/audio/source.c profiles/audio/player.c profiles/audio/avctp.c profiles/audio/control.h profiles/audio/a2dp.c profiles/audio/source.h profiles/audio/transport.c profiles/audio/sink.c profiles/audio/avrcp.h profiles/audio/avdtp.c profiles/audio/a2dp.h profiles/audio/avrcp.c profiles/audio/media.h profiles/audio/avctp.h profiles/audio/control.c profiles/audio/sink.h profiles/audio/player.h profiles/audio/media.c profiles/sap/server.c profiles/sap/sap-dummy.c profiles/sap/main.c profiles/sap/sap.h profiles/sap/manager.c profiles/sap/server.h profiles/sap/manager.h profiles/iap/main.c profiles/gap/gas.c profiles/midi/midi.c profiles/midi/libmidi.c profiles/midi/libmidi.h profiles/input/server.c profiles/input/suspend.h profiles/input/uhid_copy.h profiles/input/device.c profiles/input/hog.c profiles/input/device.h profiles/input/hidp_defs.h profiles/input/manager.c profiles/input/suspend-none.c profiles/input/sixaxis.h profiles/input/hog-lib.c profiles/input/suspend-dummy.c profiles/input/server.h License: LGPL-2.1-or-later profiles/deviceinfo/dis.h profiles/battery/bas.h profiles/battery/bas.c profiles/scanparam/scpp.h profiles/audio/a2dp-codecs.h profiles/input/hog-lib.h --- profiles/audio/a2dp-codecs.h | 15 +-------------- profiles/audio/a2dp.c | 15 +-------------- profiles/audio/a2dp.h | 15 +-------------- profiles/audio/avctp.c | 15 +-------------- profiles/audio/avctp.h | 15 +-------------- profiles/audio/avdtp.c | 15 +-------------- profiles/audio/avdtp.h | 15 +-------------- profiles/audio/avrcp.c | 15 +-------------- profiles/audio/avrcp.h | 15 +-------------- profiles/audio/control.c | 15 +-------------- profiles/audio/control.h | 15 +-------------- profiles/audio/media.c | 15 +-------------- profiles/audio/media.h | 15 +-------------- profiles/audio/player.c | 15 +-------------- profiles/audio/player.h | 15 +-------------- profiles/audio/sink.c | 15 +-------------- profiles/audio/sink.h | 15 +-------------- profiles/audio/source.c | 15 +-------------- profiles/audio/source.h | 15 +-------------- profiles/audio/transport.c | 15 +-------------- profiles/audio/transport.h | 15 +-------------- profiles/battery/bas.c | 15 +-------------- profiles/battery/bas.h | 15 +-------------- profiles/battery/battery.c | 10 +--------- profiles/cups/cups.h | 15 +-------------- profiles/cups/hcrp.c | 15 +-------------- profiles/cups/main.c | 15 +-------------- profiles/cups/sdp.c | 15 +-------------- profiles/cups/spp.c | 15 +-------------- profiles/deviceinfo/deviceinfo.c | 15 +-------------- profiles/deviceinfo/dis.c | 15 +-------------- profiles/deviceinfo/dis.h | 15 +-------------- profiles/gap/gas.c | 10 +--------- profiles/health/hdp.c | 15 +-------------- profiles/health/hdp.h | 15 +-------------- profiles/health/hdp_main.c | 15 +-------------- profiles/health/hdp_manager.c | 15 +-------------- profiles/health/hdp_manager.h | 15 +-------------- profiles/health/hdp_types.h | 15 +-------------- profiles/health/hdp_util.c | 15 +-------------- profiles/health/hdp_util.h | 15 +-------------- profiles/health/mcap.c | 15 +-------------- profiles/health/mcap.h | 15 +-------------- profiles/iap/main.c | 15 +-------------- profiles/input/device.c | 15 +-------------- profiles/input/device.h | 15 +-------------- profiles/input/hidp_defs.h | 15 +-------------- profiles/input/hog-lib.c | 15 +-------------- profiles/input/hog-lib.h | 15 +-------------- profiles/input/hog.c | 15 +-------------- profiles/input/manager.c | 15 +-------------- profiles/input/server.c | 15 +-------------- profiles/input/server.h | 15 +-------------- profiles/input/sixaxis.h | 15 +-------------- profiles/input/suspend-dummy.c | 15 +-------------- profiles/input/suspend-none.c | 15 +-------------- profiles/input/suspend.h | 15 +-------------- profiles/midi/libmidi.c | 16 +--------------- profiles/midi/libmidi.h | 16 +--------------- profiles/midi/midi.c | 20 +------------------- profiles/network/bnep.c | 15 +-------------- profiles/network/bnep.h | 15 +-------------- profiles/network/connection.c | 15 +-------------- profiles/network/connection.h | 15 +-------------- profiles/network/manager.c | 15 +-------------- profiles/network/server.c | 15 +-------------- profiles/network/server.h | 15 +-------------- profiles/sap/main.c | 14 +------------- profiles/sap/manager.c | 14 +------------- profiles/sap/manager.h | 14 +------------- profiles/sap/sap-dummy.c | 14 +------------- profiles/sap/sap.h | 14 +------------- profiles/sap/server.c | 14 +------------- profiles/sap/server.h | 14 +------------- profiles/scanparam/scan.c | 15 +-------------- profiles/scanparam/scpp.c | 15 +-------------- profiles/scanparam/scpp.h | 15 +-------------- 77 files changed, 77 insertions(+), 1068 deletions(-) diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h index 93e9d3523..6f5670947 100644 --- a/profiles/audio/a2dp-codecs.h +++ b/profiles/audio/a2dp-codecs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2018 Pali Rohár <pali.rohar@gmail.com> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <endian.h> diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c index 2feea66c0..4ec99278a 100644 --- a/profiles/audio/a2dp.c +++ b/profiles/audio/a2dp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/a2dp.h b/profiles/audio/a2dp.h index 19466a428..b40bd4736 100644 --- a/profiles/audio/a2dp.h +++ b/profiles/audio/a2dp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct a2dp_sep; diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c index f096d22b0..c959b4f49 100644 --- a/profiles/audio/avctp.c +++ b/profiles/audio/avctp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 Texas Instruments, Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/avctp.h b/profiles/audio/avctp.h index 95d95bbbe..23e3732cd 100644 --- a/profiles/audio/avctp.h +++ b/profiles/audio/avctp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define AVCTP_CONTROL_PSM 23 diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 782268c08..5fbe50761 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h index 011fea89e..7a1c109c2 100644 --- a/profiles/audio/avdtp.h +++ b/profiles/audio/avdtp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef enum { diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 5ef98acd1..ed436de3b 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 Texas Instruments, Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index 159ccf846..dcc580e37 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ /* player attributes */ diff --git a/profiles/audio/control.c b/profiles/audio/control.c index 14744ea94..619afc13d 100644 --- a/profiles/audio/control.c +++ b/profiles/audio/control.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 Texas Instruments, Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/control.h b/profiles/audio/control.h index aab2631b6..b9207a7b7 100644 --- a/profiles/audio/control.h +++ b/profiles/audio/control.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define AUDIO_CONTROL_INTERFACE "org.bluez.MediaControl1" diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 02bf82a49..74064d398 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/media.h b/profiles/audio/media.h index 53694f4c6..96bea9db4 100644 --- a/profiles/audio/media.h +++ b/profiles/audio/media.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct media_endpoint; diff --git a/profiles/audio/player.c b/profiles/audio/player.c index 27a7efb7e..d34b39168 100644 --- a/profiles/audio/player.c +++ b/profiles/audio/player.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> * Copyright (C) 2012-2012 Intel Corporation * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/player.h b/profiles/audio/player.h index e98550064..69f08735b 100644 --- a/profiles/audio/player.h +++ b/profiles/audio/player.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2012-2012 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef enum { diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c index 7c5e77577..134d157bc 100644 --- a/profiles/audio/sink.c +++ b/profiles/audio/sink.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/sink.h b/profiles/audio/sink.h index 93c62a206..495e612f1 100644 --- a/profiles/audio/sink.h +++ b/profiles/audio/sink.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef enum { diff --git a/profiles/audio/source.c b/profiles/audio/source.c index 0ac20fe40..fca85d4cb 100644 --- a/profiles/audio/source.c +++ b/profiles/audio/source.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2009 Joao Paulo Rechi Vita * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/source.h b/profiles/audio/source.h index a014c68d6..35ce0b163 100644 --- a/profiles/audio/source.h +++ b/profiles/audio/source.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2009 Joao Paulo Rechi Vita * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef enum { diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index dd1c553a2..8248014ae 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index 78024372f..51a67ea74 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct media_transport; diff --git a/profiles/battery/bas.c b/profiles/battery/bas.c index de369fd3c..3c6173b61 100644 --- a/profiles/battery/bas.c +++ b/profiles/battery/bas.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can rebastribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is bastributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/battery/bas.h b/profiles/battery/bas.h index 3e175b5b5..cd503a498 100644 --- a/profiles/battery/bas.h +++ b/profiles/battery/bas.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can rebastribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is bastributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct bt_bas; diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c index c9a1af4b9..13c80d05c 100644 --- a/profiles/battery/battery.c +++ b/profiles/battery/battery.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,15 +7,6 @@ * Copyright (C) 2014 Google Inc. * Copyright (C) 2017 Red Hat Inc. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifdef HAVE_CONFIG_H diff --git a/profiles/cups/cups.h b/profiles/cups/cups.h index f4e0c01cd..bdaa89498 100644 --- a/profiles/cups/cups.h +++ b/profiles/cups/cups.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ enum { /**** Backend exit codes ****/ diff --git a/profiles/cups/hcrp.c b/profiles/cups/hcrp.c index edaa2cdfd..3038fe2f8 100644 --- a/profiles/cups/hcrp.c +++ b/profiles/cups/hcrp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/cups/main.c b/profiles/cups/main.c index 1fac7267f..144a0fd78 100644 --- a/profiles/cups/main.c +++ b/profiles/cups/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/cups/sdp.c b/profiles/cups/sdp.c index de9cd4eeb..81a26281c 100644 --- a/profiles/cups/sdp.c +++ b/profiles/cups/sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/cups/spp.c b/profiles/cups/spp.c index 2f1e270f4..6e910a722 100644 --- a/profiles/cups/spp.c +++ b/profiles/cups/spp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/deviceinfo/deviceinfo.c b/profiles/deviceinfo/deviceinfo.c index fa94efe7f..b6dc0ab2e 100644 --- a/profiles/deviceinfo/deviceinfo.c +++ b/profiles/deviceinfo/deviceinfo.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Texas Instruments, Inc. * Copyright (C) 2015 Google Inc. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/deviceinfo/dis.c b/profiles/deviceinfo/dis.c index 6126a776c..87fa63306 100644 --- a/profiles/deviceinfo/dis.c +++ b/profiles/deviceinfo/dis.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012 Texas Instruments, Inc. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/deviceinfo/dis.h b/profiles/deviceinfo/dis.h index 305ba1ad0..7b6f4f123 100644 --- a/profiles/deviceinfo/dis.h +++ b/profiles/deviceinfo/dis.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct bt_dis; diff --git a/profiles/gap/gas.c b/profiles/gap/gas.c index dffa31314..ea3249be9 100644 --- a/profiles/gap/gas.c +++ b/profiles/gap/gas.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,15 +6,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * Copyright (C) 2014 Google Inc. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c index a8354936b..9f906932d 100644 --- a/profiles/health/hdp.c +++ b/profiles/health/hdp.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/hdp.h b/profiles/health/hdp.h index 6e78b0947..114453493 100644 --- a/profiles/health/hdp.h +++ b/profiles/health/hdp.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int hdp_adapter_register(struct btd_adapter *btd_adapter); diff --git a/profiles/health/hdp_main.c b/profiles/health/hdp_main.c index 2c4bbe298..4a0edf9c8 100644 --- a/profiles/health/hdp_main.c +++ b/profiles/health/hdp_main.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/hdp_manager.c b/profiles/health/hdp_manager.c index 401adf6e9..23c6a4926 100644 --- a/profiles/health/hdp_manager.c +++ b/profiles/health/hdp_manager.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/hdp_manager.h b/profiles/health/hdp_manager.h index 1cab4d008..55b51ef34 100644 --- a/profiles/health/hdp_manager.h +++ b/profiles/health/hdp_manager.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int hdp_manager_init(void); diff --git a/profiles/health/hdp_types.h b/profiles/health/hdp_types.h index b34b5e031..805b3bae2 100644 --- a/profiles/health/hdp_types.h +++ b/profiles/health/hdp_types.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HDP_TYPES_H__ diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c index 64debfc6b..ab3b78f6a 100644 --- a/profiles/health/hdp_util.c +++ b/profiles/health/hdp_util.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/hdp_util.h b/profiles/health/hdp_util.h index 35e1196b2..0b556f568 100644 --- a/profiles/health/hdp_util.h +++ b/profiles/health/hdp_util.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HDP_UTIL_H__ diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c index ba43e6e96..32365fd50 100644 --- a/profiles/health/mcap.c +++ b/profiles/health/mcap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Signove * Copyright (C) 2014 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/mcap.h b/profiles/health/mcap.h index 69873ca82..5a94c8b63 100644 --- a/profiles/health/mcap.h +++ b/profiles/health/mcap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Signove * Copyright (C) 2014 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define MCAP_VERSION 0x0100 /* current version 01.00 */ diff --git a/profiles/iap/main.c b/profiles/iap/main.c index 2fd34c067..9a04f5cc0 100644 --- a/profiles/iap/main.c +++ b/profiles/iap/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/device.c b/profiles/input/device.c index 375314e7d..326a3bcb9 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2014 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/device.h b/profiles/input/device.h index f61e8a558..cf0389417 100644 --- a/profiles/input/device.h +++ b/profiles/input/device.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define L2CAP_PSM_HIDP_CTRL 0x11 diff --git a/profiles/input/hidp_defs.h b/profiles/input/hidp_defs.h index bb9231dbb..0d1febdff 100644 --- a/profiles/input/hidp_defs.h +++ b/profiles/input/hidp_defs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2014 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HIDP_DEFS_H diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c index e96c969b7..78018aad3 100644 --- a/profiles/input/hog-lib.c +++ b/profiles/input/hog-lib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/hog-lib.h b/profiles/input/hog-lib.h index 415dc63d2..a79648976 100644 --- a/profiles/input/hog-lib.h +++ b/profiles/input/hog-lib.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct bt_hog; diff --git a/profiles/input/hog.c b/profiles/input/hog.c index 130f696a9..91de4c70f 100644 --- a/profiles/input/hog.c +++ b/profiles/input/hog.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/manager.c b/profiles/input/manager.c index bf4acb4ed..92789a003 100644 --- a/profiles/input/manager.c +++ b/profiles/input/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/server.c b/profiles/input/server.c index 2bd5e92e4..d8b413744 100644 --- a/profiles/input/server.c +++ b/profiles/input/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/server.h b/profiles/input/server.h index 74159bbd7..50f4b6135 100644 --- a/profiles/input/server.h +++ b/profiles/input/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int server_start(const bdaddr_t *src); diff --git a/profiles/input/sixaxis.h b/profiles/input/sixaxis.h index 8e6f3cc18..a3cda70e4 100644 --- a/profiles/input/sixaxis.h +++ b/profiles/input/sixaxis.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2013 Szymon Janc <szymon.janc@gmail.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef _SIXAXIS_H_ diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-dummy.c index 542ae2592..c6527ee88 100644 --- a/profiles/input/suspend-dummy.c +++ b/profiles/input/suspend-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/suspend-none.c b/profiles/input/suspend-none.c index c619bb11e..9da0111c8 100644 --- a/profiles/input/suspend-none.c +++ b/profiles/input/suspend-none.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/suspend.h b/profiles/input/suspend.h index bfee3cfef..1de1aeacd 100644 --- a/profiles/input/suspend.h +++ b/profiles/input/suspend.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef void (*suspend_event) (void); diff --git a/profiles/midi/libmidi.c b/profiles/midi/libmidi.c index cb2787db1..5b77cd3f5 100644 --- a/profiles/midi/libmidi.c +++ b/profiles/midi/libmidi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,21 +6,6 @@ * Copyright (C) 2015,2016 Felipe F. Tonello <eu@felipetonello.com> * Copyright (C) 2016 ROLI Ltd. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * */ #include <glib.h> diff --git a/profiles/midi/libmidi.h b/profiles/midi/libmidi.h index 9d94065b6..41f522dd4 100644 --- a/profiles/midi/libmidi.h +++ b/profiles/midi/libmidi.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,21 +6,6 @@ * Copyright (C) 2015,2016 Felipe F. Tonello <eu@felipetonello.com> * Copyright (C) 2016 ROLI Ltd. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * */ #ifndef LIBMIDI_H diff --git a/profiles/midi/midi.c b/profiles/midi/midi.c index 1ee5cb16f..737d1b5f6 100644 --- a/profiles/midi/midi.c +++ b/profiles/midi/midi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,25 +6,6 @@ * Copyright (C) 2015,2016 Felipe F. Tonello <eu@felipetonello.com> * Copyright (C) 2016 ROLI Ltd. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Information about this plugin: - * - * This plugin implements the MIDI over Bluetooth Low-Energy (BLE-MIDI) 1.0 - * specification as published by MMA in November/2015. - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c index d0ad9e483..4dde55786 100644 --- a/profiles/network/bnep.c +++ b/profiles/network/bnep.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/network/bnep.h b/profiles/network/bnep.h index e9f4c1cf2..493a2b036 100644 --- a/profiles/network/bnep.h +++ b/profiles/network/bnep.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct bnep; diff --git a/profiles/network/connection.c b/profiles/network/connection.c index 170841de6..74d9d8944 100644 --- a/profiles/network/connection.c +++ b/profiles/network/connection.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/network/connection.h b/profiles/network/connection.h index 4a8b43bc8..aa7e36e37 100644 --- a/profiles/network/connection.h +++ b/profiles/network/connection.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int connection_register(struct btd_service *service); diff --git a/profiles/network/manager.c b/profiles/network/manager.c index 41377fb83..a2650d6f0 100644 --- a/profiles/network/manager.c +++ b/profiles/network/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/network/server.c b/profiles/network/server.c index c462677ed..96738f26c 100644 --- a/profiles/network/server.c +++ b/profiles/network/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/network/server.h b/profiles/network/server.h index a76e6f7b2..32369219d 100644 --- a/profiles/network/server.h +++ b/profiles/network/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int server_init(gboolean secure); diff --git a/profiles/sap/main.c b/profiles/sap/main.c index cd707ff3e..321ed3282 100644 --- a/profiles/sap/main.c +++ b/profiles/sap/main.c @@ -1,21 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 Instituto Nokia de Tecnologia - INdT * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H diff --git a/profiles/sap/manager.c b/profiles/sap/manager.c index b62239780..6670f397c 100644 --- a/profiles/sap/manager.c +++ b/profiles/sap/manager.c @@ -1,21 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 Instituto Nokia de Tecnologia - INdT * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H diff --git a/profiles/sap/manager.h b/profiles/sap/manager.h index 6601a034e..2a1f5a6d1 100644 --- a/profiles/sap/manager.h +++ b/profiles/sap/manager.h @@ -1,21 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 Instituto Nokia de Tecnologia - INdT * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ int sap_manager_init(void); diff --git a/profiles/sap/sap-dummy.c b/profiles/sap/sap-dummy.c index 53463ca7c..92adea384 100644 --- a/profiles/sap/sap-dummy.c +++ b/profiles/sap/sap-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * @@ -7,19 +8,6 @@ * Author: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> * for ST-Ericsson * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H diff --git a/profiles/sap/sap.h b/profiles/sap/sap.h index 6e78d6c2d..30ed7c50c 100644 --- a/profiles/sap/sap.h +++ b/profiles/sap/sap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * BlueZ - Bluetooth protocol stack for Linux * @@ -8,19 +9,6 @@ * Author: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> * for ST-Ericsson. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdint.h> diff --git a/profiles/sap/server.c b/profiles/sap/server.c index 5de682a33..b0a454ced 100644 --- a/profiles/sap/server.c +++ b/profiles/sap/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * @@ -9,19 +10,6 @@ * Author: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> * for ST-Ericsson. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H diff --git a/profiles/sap/server.h b/profiles/sap/server.h index 4bf9296ad..b774230f5 100644 --- a/profiles/sap/server.h +++ b/profiles/sap/server.h @@ -1,21 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 ST-Ericsson SA * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ int sap_server_register(struct btd_adapter *adapter); diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c index d72be3dff..004783bf7 100644 --- a/profiles/scanparam/scan.c +++ b/profiles/scanparam/scan.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/scanparam/scpp.c b/profiles/scanparam/scpp.c index df65d2c1e..da38a6aaa 100644 --- a/profiles/scanparam/scpp.c +++ b/profiles/scanparam/scpp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/scanparam/scpp.h b/profiles/scanparam/scpp.h index 048fb9f23..c3cc5f156 100644 --- a/profiles/scanparam/scpp.h +++ b/profiles/scanparam/scpp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can rescpptribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is scpptributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct bt_scpp; -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oLb3KVgvYF+F0wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 05:04:56 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id OLZ7J1gvYF8uMAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 05:04:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2DE6D4086A; Tue, 15 Sep 2020 05:04:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726219AbgIODEi (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 14 Sep 2020 23:04:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726123AbgIODEc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 14 Sep 2020 23:04:32 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A93AC06174A for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 20:04:29 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 193so1963559ybi.8 for <linux-bluetooth@vger.kernel.org>; Mon, 14 Sep 2020 20:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=bEfG59MOHeBRkMqWRj6tWVU09859XSfXvoiJ0BUkxNU=; b=afh7Ohz0yqOkDJtgWZOxXgbKwgn5dSHhgEDmkfjbMoN2QlqMyO1OyRwiMoSkewO9p7 PxdWy0d+sg6ChGPwSK4dlGIaVvynxmdBVgdvpJLOFJ1uMH0M6qV2LTaWwKmFLajAuoId Z5todCNC2oBsGAZLXLWGAS62hdJNK+wfKXtlkCwKrJUOl16Ap8vW3uDvRs+30NSHi+DG 7Fjeb6VFGK57jp2OEuQFL824HfuAMDuMKL69zyaBDR7ByO2f4OzQxnRum5Vv8o4QZlHP y3E9Rbs88pJbDuN9xCiK20zWEZ7RBs83wAjsSms9BrqP0WbQf2gLu8B061Uz5SfUixAE 0EhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=bEfG59MOHeBRkMqWRj6tWVU09859XSfXvoiJ0BUkxNU=; b=ZKS/JtQYDkoVcQ4qsXxUHJPNLqVy4AiKS2P0YPvNtIOp+jisHb4SOhyT8+bQ89Ww6m GbzyfSnZepA6saWKyaEtxIi88+apFNBnF3d7CQwAiRUWsVj+3/Hl/l7P/7Vj6Ea8qk5/ ArLQNRCv3p/p5mrvM9sFVAjlGDCHe79cZjn74igy1Gt7VYbx6HyL7wdIqyohSSg5efWC 6JtMtQu/sFSAJQufz2JaXPQ8txzwtGyeC95pT/ydCmwdLfhfUPFZmaerD43M8dN/wtXj ymUuW3A3/tADzhCxSOqtPHHaV4rzcSn51yrq2X5RyNe+KwynfTatiePOi+n0NEWcPsdT LnLg== X-Gm-Message-State: AOAM530oDZFIn0hgCPaVOCzDxjJoheJpmiZpJNLuUaV+Xh4txPgdFobl lGd+tTyhWnONsE9kfLyv8chrWNdZrYoztQKq54zC52l9zojWBqYkIPbrHizESDWXndjvGEosSV4 SdryDbjPNKqwxPfjnJV32C6p4+miDIaf94R8mQM3hCVm/vu088naLzt1uiXXLTCc0vdhPWWKzMS nP X-Google-Smtp-Source: ABdhPJzMCGtl/U78KiOh+n5hL85TfmD48JC9kQKfXbwuXPKAlbgA94nyZ0eshDFsY/4HO7UOoEsRQFzKJ3DJ X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a25:c7cd:: with SMTP id w196mr25006698ybe.265.1600139068585; Mon, 14 Sep 2020 20:04:28 -0700 (PDT) Date: Tue, 15 Sep 2020 11:04:19 +0800 Message-Id: <20200915110347.Bluez.v3.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH v3] device: don't wait for timeout if RemoveDevice is called From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.56 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2DE6D4086A X-Rspamd-UID: 3cbf04 From: Archie Pusaka <apusaka@chromium.org> RemoveDevice on adapter interface used to remove a device, even when the device is connected. However, since the introduction of the new 30 seconds timeout when setting a device as temporary, RemoveDevice doesn't immediately remove a connected device, but only disconnects it and waits for the timer to expire before effectively removes it. This patch removes the device as soon as it gets disconnected, provided the disconnection is triggered by a call to RemoveDevice. The regular timeout still applies for other cases. Tested manually by calling RemoveDevice on a connected device, and with ChromeOS autotest setup. Reviewed-by: Daniel Winkler <danielwinkler@google.com> --- Changes in v3: * Rebasing again Changes in v2: * Rebasing to HEAD src/adapter.c | 2 -- src/adapter.h | 2 ++ src/device.c | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index df628a7fd..4e27bd74b 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -80,8 +80,6 @@ #include "adv_monitor.h" #include "eir.h" -#define ADAPTER_INTERFACE "org.bluez.Adapter1" - #define MODE_OFF 0x00 #define MODE_CONNECTABLE 0x01 #define MODE_DISCOVERABLE 0x02 diff --git a/src/adapter.h b/src/adapter.h index c70a7b0da..2f1e4b737 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -29,6 +29,8 @@ #include <lib/bluetooth.h> #include <lib/sdp.h> +#define ADAPTER_INTERFACE "org.bluez.Adapter1" + #define MAX_NAME_LENGTH 248 /* Invalid SSP passkey value used to indicate negative replies */ diff --git a/src/device.c b/src/device.c index 8f73ce4d3..3e7784034 100644 --- a/src/device.c +++ b/src/device.c @@ -3007,6 +3007,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) { struct bearer_state *state = get_state(device, bdaddr_type); DBusMessage *reply; + bool remove_device = false; if (!state->connected) return; @@ -3036,6 +3037,10 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) while (device->disconnects) { DBusMessage *msg = device->disconnects->data; + if (dbus_message_is_method_call(msg, ADAPTER_INTERFACE, + "RemoveDevice")) + remove_device = true; + g_dbus_send_reply(dbus_conn, msg, DBUS_TYPE_INVALID); device->disconnects = g_slist_remove(device->disconnects, msg); dbus_message_unref(msg); @@ -3061,6 +3066,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) g_dbus_emit_property_changed(dbus_conn, device->path, DEVICE_INTERFACE, "Connected"); + + if (remove_device) + btd_adapter_remove_device(device->adapter, device); } guint device_add_disconnect_watch(struct btd_device *device, @@ -4482,6 +4490,9 @@ void device_remove(struct btd_device *device, gboolean remove_stored) disconnect_all(device); } + if (device->temporary_timer > 0) + g_source_remove(device->temporary_timer); + if (device->store_id > 0) { g_source_remove(device->store_id); device->store_id = 0; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MMYpK5RrYF89XgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 09:21:56 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QM9AKJRrYF/C4gAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 09:21:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=codecoup-pl.20150623.gappssmtp.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C217040677; Tue, 15 Sep 2020 09:21:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726091AbgIOHVq (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 03:21:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbgIOHVe (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 03:21:34 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C56ECC06174A for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 00:21:31 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id y17so1981802lfa.8 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 00:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codecoup-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:organization:in-reply-to :references:mime-version:content-transfer-encoding; bh=mGotMBILfjNE3/sVTsY9j6q55X0EbUizZbrRI4I1XXE=; b=LNl00lZaTvQ63No1WUU/wfhkCQnlE3C+f6nEUXMXgSaE6DnxzjFT5gKLU5+bdXsw5C 4sWuc8lLq25nK8hEBMAlftXrON3EuBRRMABFGOXkTD9RkDtsUsE0T3smiH3rF1oWrm+l 7wAfATzstjrGyBP7d+qR7GR/8S5xJfEDzXzSslfJSynTCuOs1k1V749YLR1bR2HASFNw ckRjaNkHKF2y/oZ9QPiW0OxuqtNOLAdT+ouxSN1eXYgS1pJQ4Bjy1406oK3VnBRshQOB PHgY8YCtDcn9JCdog8QVrETcKtOLzJUz0bF5pmRdcjsqgtGXNv2Uk5oabTp0LksbvcCk 6rFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :in-reply-to:references:mime-version:content-transfer-encoding; bh=mGotMBILfjNE3/sVTsY9j6q55X0EbUizZbrRI4I1XXE=; b=Gl+StLB1m2LptvpYXgbRoi2CksVJQuh+SB9jb7Cu3abt3WcNJQ0ONNguwSuge6/9qs 6KYhYb+MWtJJ0KaCx+MQmXjCNGbXjfj8SNjToNLWGKMIDn2ofTtAT23wXiv5hNyg3K7J J2enrdZoIoNLtm81GDibGdzeiW8aiJ/HNE2qByEzkUTnk1BHWukWoUHoCRtc55UH+Lba fu+CmQqxrihs6o/SsAHAtynMLGpO5CKxsHT61bh8GVJr//aJMkAvVCVFT7+UpgmBcDAP YBjXIp38mu6wL7TKmESkPrevbbb9J+kfIHbL/FaTioBqA+5Wavl7P09bvOPYDmk/zKEj IaRg== X-Gm-Message-State: AOAM531phHfHS4tlLgo665d/JwKtw8PWxUNyUTt8d+OvCTwAzGvZ1aOM v8VILLO9HfMCme0Nsj+0a/0hpKEvvOZpDpL4 X-Google-Smtp-Source: ABdhPJx3yz59ZjGQ3U2DKpnrfsPQ+Qs8pBGcgh+AJMwqW/S6a9di1ORwClF+9rcfW4cV1qt8bn2faA== X-Received: by 2002:a19:ed13:: with SMTP id y19mr6245738lfy.187.1600154489322; Tue, 15 Sep 2020 00:21:29 -0700 (PDT) Received: from ix.localnet ([95.143.243.62]) by smtp.gmail.com with ESMTPSA id 16sm3907240ljr.3.2020.09.15.00.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 00:21:28 -0700 (PDT) From: Szymon Janc <szymon.janc@codecoup.pl> To: linux-bluetooth@vger.kernel.org, tedd.an@linux.intel.com Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: Re: [BlueZ v3 00/17] Add SPDX License Identifier Date: Tue, 15 Sep 2020 09:21:27 +0200 Message-ID: <4586934.31r3eYUQgx@ix> Organization: CODECOUP In-Reply-To: <20200915000457.22988-1-tedd.an@linux.intel.com> References: <20200915000457.22988-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.90 / 15.00 / 15.00 X-Rspamd-Queue-Id: C217040677 X-Rspamd-UID: c2f919 Hi, On Tuesday, 15 September 2020 02:04:40 CEST tedd.an@linux.intel.com wrote: > From: Tedd Ho-Jeong An <tedd.an@intel.com> > > This patch series adds SPDX License Identifier to the source/heade files > based on the existing license header and removes the license text. > > The SDPX License Identifier is added in form of a comment based on file > type with the same rule from the Linxu kernel source, and added to the > first line of the file. > > C source: // SPDX-License-Identifer: <License> Why C++ style comments in C source? > C header: /* SPDX-License-Identifer: <License> */ > > For SPDX-License Identifier, it used the identifer from the SPDX License > list page(https://spdx.org/licenses). INAL but SPDX identifier itself is insufficied for license compliance. If we really want to (I don't have strong opinion about this) remove license headers in favour of only having SPDX then we need files with licenses text etc to be part of distribution. Pretty much the same what kernel folks did. > For the summary, currently BlueZ sources have following licenses: > > ------------------------------------------- > License File Count > ------------------------------------------- > GPL-2.0-or-later : 393 > LGPL-2.1-or-later : 273 > BSD-2-Clause : 3 > GPL-2.0-only : 5 > MIT : 2 > Apache-2.0 : 80 > N/A : 1325 > > Note that N/A includes the following files/folders > - .git/ > - doc/ > - Build related files (Makefile, etc) > - Configuration files > - Test scripts (python, etc) > > Tedd Ho-Jeong An (17): > android: Add SPDX License Identifier > attrib: Add SPDX License Identifier > btio: Add SPDX License Identifier > client: Add SPDX License Identifier > emulator: Add SPDX License Identifier > gdbus: Add SPDX License Identifier > gobex: Add SPDX License Identifier > lib: Add SPDX License Identifier > mesh: Add SPDX License Identifier > monitor: Add SPDX License Identifier > obexd: Add SPDX License Identifier > peripheral: Add SPDX License Identifier > plugins: Add SPDX License Identifier > profiles: Add SPDX License Identifier > unit: Add SPDX License Identifier > src: Add SPDX License Identifier > tools: Add SPDX License Identifier > > android/a2dp-sink.c | 15 +-------------- > android/a2dp-sink.h | 15 +-------------- > android/a2dp.c | 15 +-------------- > android/a2dp.h | 15 +-------------- > android/audio-msg.h | 15 +-------------- > android/audio_utils/resampler.c | 12 +----------- > android/audio_utils/resampler.h | 12 +----------- > android/avctp.c | 15 +-------------- > android/avctp.h | 15 +-------------- > android/avdtp.c | 15 +-------------- > android/avdtp.h | 15 +-------------- > android/avdtptest.c | 15 +-------------- > android/avrcp-lib.c | 15 +-------------- > android/avrcp-lib.h | 15 +-------------- > android/avrcp.c | 15 +-------------- > android/avrcp.h | 15 +-------------- > android/bluetooth.c | 15 +-------------- > android/bluetooth.h | 15 +-------------- > android/bluetoothd-snoop.c | 15 +-------------- > android/bluetoothd-wrapper.c | 13 +------------ > android/client/haltest.c | 13 +------------ > android/client/history.c | 13 +------------ > android/client/history.h | 13 +------------ > android/client/if-audio.c | 13 +------------ > android/client/if-av-sink.c | 13 +------------ > android/client/if-av.c | 13 +------------ > android/client/if-bt.c | 13 +------------ > android/client/if-gatt.c | 13 +------------ > android/client/if-hf-client.c | 13 +------------ > android/client/if-hf.c | 13 +------------ > android/client/if-hh.c | 13 +------------ > android/client/if-hl.c | 13 +------------ > android/client/if-main.h | 13 +------------ > android/client/if-mce.c | 13 +------------ > android/client/if-pan.c | 13 +------------ > android/client/if-rc-ctrl.c | 13 +------------ > android/client/if-rc.c | 13 +------------ > android/client/if-sco.c | 13 +------------ > android/client/if-sock.c | 13 +------------ > android/client/pollhandler.c | 13 +------------ > android/client/pollhandler.h | 13 +------------ > android/client/tabcompletion.c | 13 +------------ > android/client/terminal.c | 13 +------------ > android/client/terminal.h | 13 +------------ > android/compat/readline/history.h | 15 +-------------- > android/compat/readline/readline.h | 15 +-------------- > android/compat/wordexp.h | 15 +-------------- > android/cutils/properties.h | 15 +-------------- > android/gatt.c | 15 +-------------- > android/gatt.h | 15 +-------------- > android/hal-a2dp-sink.c | 13 +------------ > android/hal-a2dp.c | 13 +------------ > android/hal-audio-aptx.c | 13 +------------ > android/hal-audio-sbc.c | 13 +------------ > android/hal-audio.c | 13 +------------ > android/hal-audio.h | 13 +------------ > android/hal-avrcp-ctrl.c | 13 +------------ > android/hal-avrcp.c | 13 +------------ > android/hal-bluetooth.c | 13 +------------ > android/hal-gatt.c | 13 +------------ > android/hal-handsfree-client.c | 13 +------------ > android/hal-handsfree.c | 13 +------------ > android/hal-health.c | 13 +------------ > android/hal-hidhost.c | 13 +------------ > android/hal-ipc.c | 13 +------------ > android/hal-ipc.h | 13 +------------ > android/hal-log.h | 13 +------------ > android/hal-map-client.c | 13 +------------ > android/hal-msg.h | 15 +-------------- > android/hal-pan.c | 13 +------------ > android/hal-sco.c | 13 +------------ > android/hal-socket.c | 13 +------------ > android/hal-utils.c | 13 +------------ > android/hal-utils.h | 13 +------------ > android/hal.h | 13 +------------ > android/handsfree-client.c | 15 +-------------- > android/handsfree-client.h | 15 +-------------- > android/handsfree.c | 15 +-------------- > android/handsfree.h | 15 +-------------- > android/hardware/audio.h | 12 +----------- > android/hardware/audio_effect.h | 12 +----------- > android/hardware/bluetooth.h | 12 +----------- > android/hardware/bt_av.h | 12 +----------- > android/hardware/bt_gatt.h | 12 +----------- > android/hardware/bt_gatt_client.h | 12 +----------- > android/hardware/bt_gatt_server.h | 12 +----------- > android/hardware/bt_gatt_types.h | 12 +----------- > android/hardware/bt_hf.h | 12 +----------- > android/hardware/bt_hf_client.h | 12 +----------- > android/hardware/bt_hh.h | 12 +----------- > android/hardware/bt_hl.h | 12 +----------- > android/hardware/bt_mce.h | 12 +----------- > android/hardware/bt_pan.h | 12 +----------- > android/hardware/bt_rc.h | 12 +----------- > android/hardware/bt_sock.h | 12 +----------- > android/hardware/hardware.c | 12 +----------- > android/hardware/hardware.h | 12 +----------- > android/health.c | 15 +-------------- > android/health.h | 15 +-------------- > android/hidhost.c | 15 +-------------- > android/hidhost.h | 15 +-------------- > android/ipc-common.h | 15 +-------------- > android/ipc-tester.c | 15 +-------------- > android/ipc.c | 15 +-------------- > android/ipc.h | 15 +-------------- > android/log.c | 15 +-------------- > android/main.c | 15 +-------------- > android/map-client.c | 15 +-------------- > android/map-client.h | 15 +-------------- > android/pan.c | 15 +-------------- > android/pan.h | 15 +-------------- > android/sco-msg.h | 15 +-------------- > android/sco.c | 15 +-------------- > android/sco.h | 15 +-------------- > android/socket.c | 15 +-------------- > android/socket.h | 15 +-------------- > android/system-emulator.c | 15 +-------------- > android/system/audio.h | 12 +----------- > android/test-ipc.c | 15 +-------------- > android/tester-a2dp.c | 13 +------------ > android/tester-avrcp.c | 13 +------------ > android/tester-bluetooth.c | 13 +------------ > android/tester-gatt.c | 13 +------------ > android/tester-hdp.c | 13 +------------ > android/tester-hidhost.c | 13 +------------ > android/tester-main.c | 13 +------------ > android/tester-main.h | 15 +-------------- > android/tester-map-client.c | 13 +------------ > android/tester-pan.c | 13 +------------ > android/tester-socket.c | 13 +------------ > android/utils.h | 15 +-------------- > attrib/att-database.h | 15 +-------------- > attrib/att.c | 15 +-------------- > attrib/att.h | 15 +-------------- > attrib/gatt-service.c | 15 +-------------- > attrib/gatt-service.h | 15 +-------------- > attrib/gatt.c | 15 +-------------- > attrib/gatt.h | 15 +-------------- > attrib/gattrib.c | 15 +-------------- > attrib/gattrib.h | 15 +-------------- > attrib/gatttool.c | 15 +-------------- > attrib/gatttool.h | 15 +-------------- > attrib/interactive.c | 15 +-------------- > attrib/utils.c | 15 +-------------- > btio/btio.c | 15 +-------------- > btio/btio.h | 15 +-------------- > client/advertising.c | 15 +-------------- > client/advertising.h | 15 +-------------- > client/agent.c | 15 +-------------- > client/agent.h | 15 +-------------- > client/display.c | 15 +-------------- > client/display.h | 15 +-------------- > client/gatt.c | 15 +-------------- > client/gatt.h | 15 +-------------- > client/main.c | 15 +-------------- > emulator/amp.c | 15 +-------------- > emulator/amp.h | 15 +-------------- > emulator/b1ee.c | 15 +-------------- > emulator/btdev.c | 15 +-------------- > emulator/btdev.h | 15 +-------------- > emulator/bthost.c | 15 +-------------- > emulator/bthost.h | 15 +-------------- > emulator/hciemu.c | 15 +-------------- > emulator/hciemu.h | 15 +-------------- > emulator/hfp.c | 15 +-------------- > emulator/le.c | 15 +-------------- > emulator/le.h | 15 +-------------- > emulator/main.c | 15 +-------------- > emulator/phy.c | 15 +-------------- > emulator/phy.h | 15 +-------------- > emulator/serial.c | 15 +-------------- > emulator/serial.h | 15 +-------------- > emulator/server.c | 15 +-------------- > emulator/server.h | 15 +-------------- > emulator/smp.c | 15 +-------------- > emulator/vhci.c | 15 +-------------- > emulator/vhci.h | 15 +-------------- > gdbus/client.c | 15 +-------------- > gdbus/gdbus.h | 15 +-------------- > gdbus/mainloop.c | 15 +-------------- > gdbus/object.c | 15 +-------------- > gdbus/polkit.c | 15 +-------------- > gdbus/watch.c | 15 +-------------- > gobex/gobex-apparam.c | 15 +-------------- > gobex/gobex-apparam.h | 15 +-------------- > gobex/gobex-debug.h | 15 +-------------- > gobex/gobex-defs.c | 15 +-------------- > gobex/gobex-defs.h | 15 +-------------- > gobex/gobex-header.c | 15 +-------------- > gobex/gobex-header.h | 15 +-------------- > gobex/gobex-packet.c | 15 +-------------- > gobex/gobex-packet.h | 15 +-------------- > gobex/gobex-transfer.c | 15 +-------------- > gobex/gobex.c | 15 +-------------- > gobex/gobex.h | 15 +-------------- > lib/a2mp.h | 15 +-------------- > lib/amp.h | 10 +--------- > lib/bluetooth.c | 15 +-------------- > lib/bluetooth.h | 15 +-------------- > lib/bnep.h | 15 +-------------- > lib/cmtp.h | 15 +-------------- > lib/hci.c | 15 +-------------- > lib/hci.h | 15 +-------------- > lib/hci_lib.h | 15 +-------------- > lib/hidp.h | 15 +-------------- > lib/l2cap.h | 15 +-------------- > lib/mgmt.h | 15 +-------------- > lib/rfcomm.h | 15 +-------------- > lib/sco.h | 15 +-------------- > lib/sdp.c | 15 +-------------- > lib/sdp.h | 15 +-------------- > lib/sdp_lib.h | 15 +-------------- > lib/uuid.c | 15 +-------------- > lib/uuid.h | 15 +-------------- > mesh/agent.c | 11 +---------- > mesh/agent.h | 11 +---------- > mesh/appkey.c | 11 +---------- > mesh/appkey.h | 11 +---------- > mesh/cfgmod-server.c | 11 +---------- > mesh/cfgmod.h | 11 +---------- > mesh/crypto.c | 11 +---------- > mesh/crypto.h | 11 +---------- > mesh/dbus.c | 11 +---------- > mesh/dbus.h | 11 +---------- > mesh/error.h | 11 +---------- > mesh/friend.c | 11 +---------- > mesh/friend.h | 11 +---------- > mesh/keyring.c | 11 +---------- > mesh/keyring.h | 11 +---------- > mesh/main.c | 11 +---------- > mesh/manager.c | 11 +---------- > mesh/manager.h | 11 +---------- > mesh/mesh-config-json.c | 11 +---------- > mesh/mesh-config.h | 11 +---------- > mesh/mesh-defs.h | 12 +----------- > mesh/mesh-io-api.h | 11 +---------- > mesh/mesh-io-generic.c | 11 +---------- > mesh/mesh-io-generic.h | 11 +---------- > mesh/mesh-io.c | 11 +---------- > mesh/mesh-io.h | 11 +---------- > mesh/mesh-mgmt.c | 11 +---------- > mesh/mesh-mgmt.h | 11 +---------- > mesh/mesh.c | 11 +---------- > mesh/mesh.h | 11 +---------- > mesh/model.c | 11 +---------- > mesh/model.h | 11 +---------- > mesh/net-keys.c | 11 +---------- > mesh/net-keys.h | 11 +---------- > mesh/net.c | 11 +---------- > mesh/net.h | 11 +---------- > mesh/node.c | 11 +---------- > mesh/node.h | 11 +---------- > mesh/pb-adv.c | 11 +---------- > mesh/pb-adv.h | 11 +---------- > mesh/prov-acceptor.c | 11 +---------- > mesh/prov-initiator.c | 11 +---------- > mesh/prov.h | 11 +---------- > mesh/provision.h | 11 +---------- > mesh/rpl.c | 11 +---------- > mesh/rpl.h | 11 +---------- > mesh/util.c | 11 +---------- > mesh/util.h | 11 +---------- > monitor/a2dp.c | 15 +-------------- > monitor/a2dp.h | 15 +-------------- > monitor/analyze.c | 15 +-------------- > monitor/analyze.h | 15 +-------------- > monitor/avctp.c | 15 +-------------- > monitor/avctp.h | 15 +-------------- > monitor/avdtp.c | 15 +-------------- > monitor/avdtp.h | 15 +-------------- > monitor/bnep.c | 15 +-------------- > monitor/bnep.h | 15 +-------------- > monitor/broadcom.c | 15 +-------------- > monitor/broadcom.h | 15 +-------------- > monitor/bt.h | 15 +-------------- > monitor/control.c | 15 +-------------- > monitor/control.h | 15 +-------------- > monitor/crc.c | 15 +-------------- > monitor/crc.h | 15 +-------------- > monitor/display.c | 15 +-------------- > monitor/display.h | 15 +-------------- > monitor/ellisys.c | 15 +-------------- > monitor/ellisys.h | 15 +-------------- > monitor/hcidump.c | 15 +-------------- > monitor/hcidump.h | 15 +-------------- > monitor/hwdb.c | 15 +-------------- > monitor/hwdb.h | 15 +-------------- > monitor/intel.c | 15 +-------------- > monitor/intel.h | 15 +-------------- > monitor/jlink.c | 15 +-------------- > monitor/jlink.h | 15 +-------------- > monitor/keys.c | 15 +-------------- > monitor/keys.h | 15 +-------------- > monitor/l2cap.c | 15 +-------------- > monitor/l2cap.h | 15 +-------------- > monitor/ll.c | 15 +-------------- > monitor/ll.h | 15 +-------------- > monitor/lmp.c | 15 +-------------- > monitor/lmp.h | 15 +-------------- > monitor/main.c | 15 +-------------- > monitor/packet.c | 15 +-------------- > monitor/packet.h | 15 +-------------- > monitor/rfcomm.c | 15 +-------------- > monitor/rfcomm.h | 15 +-------------- > monitor/sdp.c | 15 +-------------- > monitor/sdp.h | 15 +-------------- > monitor/tty.h | 15 +-------------- > monitor/vendor.c | 15 +-------------- > monitor/vendor.h | 15 +-------------- > obexd/client/bluetooth.c | 15 +-------------- > obexd/client/bluetooth.h | 15 +-------------- > obexd/client/driver.c | 15 +-------------- > obexd/client/driver.h | 15 +-------------- > obexd/client/ftp.c | 15 +-------------- > obexd/client/ftp.h | 15 +-------------- > obexd/client/manager.c | 15 +-------------- > obexd/client/manager.h | 15 +-------------- > obexd/client/map-event.c | 15 +-------------- > obexd/client/map-event.h | 15 +-------------- > obexd/client/map.c | 15 +-------------- > obexd/client/map.h | 15 +-------------- > obexd/client/mns.c | 15 +-------------- > obexd/client/opp.c | 15 +-------------- > obexd/client/opp.h | 15 +-------------- > obexd/client/pbap.c | 15 +-------------- > obexd/client/pbap.h | 15 +-------------- > obexd/client/session.c | 15 +-------------- > obexd/client/session.h | 15 +-------------- > obexd/client/sync.c | 15 +-------------- > obexd/client/sync.h | 15 +-------------- > obexd/client/transfer.c | 15 +-------------- > obexd/client/transfer.h | 15 +-------------- > obexd/client/transport.c | 15 +-------------- > obexd/client/transport.h | 15 +-------------- > obexd/plugins/bluetooth.c | 15 +-------------- > obexd/plugins/filesystem.c | 15 +-------------- > obexd/plugins/filesystem.h | 15 +-------------- > obexd/plugins/ftp.c | 15 +-------------- > obexd/plugins/ftp.h | 15 +-------------- > obexd/plugins/irmc.c | 15 +-------------- > obexd/plugins/mas.c | 15 +-------------- > obexd/plugins/messages-dummy.c | 15 +-------------- > obexd/plugins/messages-tracker.c | 15 +-------------- > obexd/plugins/messages.h | 15 +-------------- > obexd/plugins/opp.c | 15 +-------------- > obexd/plugins/pbap.c | 15 +-------------- > obexd/plugins/pcsuite.c | 15 +-------------- > obexd/plugins/phonebook-dummy.c | 15 +-------------- > obexd/plugins/phonebook-ebook.c | 15 +-------------- > obexd/plugins/phonebook-tracker.c | 15 +-------------- > obexd/plugins/phonebook.h | 15 +-------------- > obexd/plugins/syncevolution.c | 15 +-------------- > obexd/plugins/vcard.c | 15 +-------------- > obexd/plugins/vcard.h | 15 +-------------- > obexd/src/log.c | 15 +-------------- > obexd/src/log.h | 15 +-------------- > obexd/src/main.c | 15 +-------------- > obexd/src/manager.c | 15 +-------------- > obexd/src/manager.h | 15 +-------------- > obexd/src/map_ap.h | 15 +-------------- > obexd/src/mimetype.c | 15 +-------------- > obexd/src/mimetype.h | 15 +-------------- > obexd/src/obex-priv.h | 15 +-------------- > obexd/src/obex.c | 15 +-------------- > obexd/src/obex.h | 15 +-------------- > obexd/src/obexd.h | 15 +-------------- > obexd/src/plugin.c | 15 +-------------- > obexd/src/plugin.h | 15 +-------------- > obexd/src/server.c | 15 +-------------- > obexd/src/server.h | 15 +-------------- > obexd/src/service.c | 15 +-------------- > obexd/src/service.h | 15 +-------------- > obexd/src/transport.c | 15 +-------------- > obexd/src/transport.h | 15 +-------------- > peripheral/attach.c | 15 +-------------- > peripheral/attach.h | 15 +-------------- > peripheral/efivars.c | 15 +-------------- > peripheral/efivars.h | 15 +-------------- > peripheral/gap.c | 15 +-------------- > peripheral/gap.h | 15 +-------------- > peripheral/gatt.c | 15 +-------------- > peripheral/gatt.h | 15 +-------------- > peripheral/log.c | 15 +-------------- > peripheral/log.h | 15 +-------------- > peripheral/main.c | 15 +-------------- > plugins/autopair.c | 15 +-------------- > plugins/external-dummy.c | 15 +-------------- > plugins/hostname.c | 15 +-------------- > plugins/neard.c | 15 +-------------- > plugins/policy.c | 15 +-------------- > plugins/sixaxis.c | 15 +-------------- > plugins/wiimote.c | 15 +-------------- > profiles/audio/a2dp-codecs.h | 15 +-------------- > profiles/audio/a2dp.c | 15 +-------------- > profiles/audio/a2dp.h | 15 +-------------- > profiles/audio/avctp.c | 15 +-------------- > profiles/audio/avctp.h | 15 +-------------- > profiles/audio/avdtp.c | 15 +-------------- > profiles/audio/avdtp.h | 15 +-------------- > profiles/audio/avrcp.c | 15 +-------------- > profiles/audio/avrcp.h | 15 +-------------- > profiles/audio/control.c | 15 +-------------- > profiles/audio/control.h | 15 +-------------- > profiles/audio/media.c | 15 +-------------- > profiles/audio/media.h | 15 +-------------- > profiles/audio/player.c | 15 +-------------- > profiles/audio/player.h | 15 +-------------- > profiles/audio/sink.c | 15 +-------------- > profiles/audio/sink.h | 15 +-------------- > profiles/audio/source.c | 15 +-------------- > profiles/audio/source.h | 15 +-------------- > profiles/audio/transport.c | 15 +-------------- > profiles/audio/transport.h | 15 +-------------- > profiles/battery/bas.c | 15 +-------------- > profiles/battery/bas.h | 15 +-------------- > profiles/battery/battery.c | 10 +--------- > profiles/cups/cups.h | 15 +-------------- > profiles/cups/hcrp.c | 15 +-------------- > profiles/cups/main.c | 15 +-------------- > profiles/cups/sdp.c | 15 +-------------- > profiles/cups/spp.c | 15 +-------------- > profiles/deviceinfo/deviceinfo.c | 15 +-------------- > profiles/deviceinfo/dis.c | 15 +-------------- > profiles/deviceinfo/dis.h | 15 +-------------- > profiles/gap/gas.c | 10 +--------- > profiles/health/hdp.c | 15 +-------------- > profiles/health/hdp.h | 15 +-------------- > profiles/health/hdp_main.c | 15 +-------------- > profiles/health/hdp_manager.c | 15 +-------------- > profiles/health/hdp_manager.h | 15 +-------------- > profiles/health/hdp_types.h | 15 +-------------- > profiles/health/hdp_util.c | 15 +-------------- > profiles/health/hdp_util.h | 15 +-------------- > profiles/health/mcap.c | 15 +-------------- > profiles/health/mcap.h | 15 +-------------- > profiles/iap/main.c | 15 +-------------- > profiles/input/device.c | 15 +-------------- > profiles/input/device.h | 15 +-------------- > profiles/input/hidp_defs.h | 15 +-------------- > profiles/input/hog-lib.c | 15 +-------------- > profiles/input/hog-lib.h | 15 +-------------- > profiles/input/hog.c | 15 +-------------- > profiles/input/manager.c | 15 +-------------- > profiles/input/server.c | 15 +-------------- > profiles/input/server.h | 15 +-------------- > profiles/input/sixaxis.h | 15 +-------------- > profiles/input/suspend-dummy.c | 15 +-------------- > profiles/input/suspend-none.c | 15 +-------------- > profiles/input/suspend.h | 15 +-------------- > profiles/midi/libmidi.c | 16 +--------------- > profiles/midi/libmidi.h | 16 +--------------- > profiles/midi/midi.c | 20 +------------------- > profiles/network/bnep.c | 15 +-------------- > profiles/network/bnep.h | 15 +-------------- > profiles/network/connection.c | 15 +-------------- > profiles/network/connection.h | 15 +-------------- > profiles/network/manager.c | 15 +-------------- > profiles/network/server.c | 15 +-------------- > profiles/network/server.h | 15 +-------------- > profiles/sap/main.c | 14 +------------- > profiles/sap/manager.c | 14 +------------- > profiles/sap/manager.h | 14 +------------- > profiles/sap/sap-dummy.c | 14 +------------- > profiles/sap/sap.h | 14 +------------- > profiles/sap/server.c | 14 +------------- > profiles/sap/server.h | 14 +------------- > profiles/scanparam/scan.c | 15 +-------------- > profiles/scanparam/scpp.c | 15 +-------------- > profiles/scanparam/scpp.h | 15 +-------------- > src/adapter.c | 15 +-------------- > src/adapter.h | 15 +-------------- > src/adv_monitor.c | 11 +---------- > src/adv_monitor.h | 11 +---------- > src/advertising.c | 11 +---------- > src/advertising.h | 11 +---------- > src/agent.c | 15 +-------------- > src/agent.h | 15 +-------------- > src/attrib-server.c | 15 +-------------- > src/attrib-server.h | 15 +-------------- > src/backtrace.c | 15 +-------------- > src/backtrace.h | 15 +-------------- > src/dbus-common.c | 15 +-------------- > src/dbus-common.h | 15 +-------------- > src/device.c | 15 +-------------- > src/device.h | 15 +-------------- > src/eir.c | 15 +-------------- > src/eir.h | 15 +-------------- > src/error.c | 15 +-------------- > src/error.h | 15 +-------------- > src/gatt-client.c | 11 +---------- > src/gatt-client.h | 11 +---------- > src/gatt-database.c | 11 +---------- > src/gatt-database.h | 11 +---------- > src/hcid.h | 15 +-------------- > src/log.c | 15 +-------------- > src/log.h | 15 +-------------- > src/main.c | 15 +-------------- > src/oui.c | 15 +-------------- > src/oui.h | 15 +-------------- > src/plugin.c | 15 +-------------- > src/plugin.h | 15 +-------------- > src/profile.c | 15 +-------------- > src/profile.h | 15 +-------------- > src/rfkill.c | 15 +-------------- > src/sdp-client.c | 15 +-------------- > src/sdp-client.h | 15 +-------------- > src/sdp-xml.c | 15 +-------------- > src/sdp-xml.h | 15 +-------------- > src/sdpd-database.c | 15 +-------------- > src/sdpd-request.c | 15 +-------------- > src/sdpd-server.c | 15 +-------------- > src/sdpd-service.c | 15 +-------------- > src/sdpd.h | 15 +-------------- > src/service.c | 15 +-------------- > src/service.h | 15 +-------------- > src/shared/ad.c | 15 +-------------- > src/shared/ad.h | 15 +-------------- > src/shared/att-types.h | 15 +-------------- > src/shared/att.c | 15 +-------------- > src/shared/att.h | 15 +-------------- > src/shared/btp.c | 15 +-------------- > src/shared/btp.h | 15 +-------------- > src/shared/btsnoop.c | 15 +-------------- > src/shared/btsnoop.h | 15 +-------------- > src/shared/crypto.c | 15 +-------------- > src/shared/crypto.h | 15 +-------------- > src/shared/ecc.c | 21 +-------------------- > src/shared/ecc.h | 21 +-------------------- > src/shared/gap.c | 15 +-------------- > src/shared/gap.h | 15 +-------------- > src/shared/gatt-client.c | 15 +-------------- > src/shared/gatt-client.h | 15 +-------------- > src/shared/gatt-db.c | 15 +-------------- > src/shared/gatt-db.h | 15 +-------------- > src/shared/gatt-helpers.c | 15 +-------------- > src/shared/gatt-helpers.h | 15 +-------------- > src/shared/gatt-server.c | 15 +-------------- > src/shared/gatt-server.h | 15 +-------------- > src/shared/hci-crypto.c | 15 +-------------- > src/shared/hci-crypto.h | 15 +-------------- > src/shared/hci.c | 15 +-------------- > src/shared/hci.h | 15 +-------------- > src/shared/hfp.c | 15 +-------------- > src/shared/hfp.h | 15 +-------------- > src/shared/io-ell.c | 15 +-------------- > src/shared/io-glib.c | 15 +-------------- > src/shared/io-mainloop.c | 15 +-------------- > src/shared/io.h | 15 +-------------- > src/shared/log.c | 15 +-------------- > src/shared/log.h | 15 +-------------- > src/shared/mainloop-ell.c | 12 +----------- > src/shared/mainloop-glib.c | 15 +-------------- > src/shared/mainloop-notify.c | 15 +-------------- > src/shared/mainloop-notify.h | 15 +-------------- > src/shared/mainloop.c | 15 +-------------- > src/shared/mainloop.h | 15 +-------------- > src/shared/mgmt.c | 15 +-------------- > src/shared/mgmt.h | 15 +-------------- > src/shared/pcap.c | 15 +-------------- > src/shared/pcap.h | 15 +-------------- > src/shared/queue.c | 15 +-------------- > src/shared/queue.h | 15 +-------------- > src/shared/ringbuf.c | 15 +-------------- > src/shared/ringbuf.h | 15 +-------------- > src/shared/shell.c | 15 +-------------- > src/shared/shell.h | 15 +-------------- > src/shared/tester.c | 15 +-------------- > src/shared/tester.h | 15 +-------------- > src/shared/timeout-ell.c | 11 +---------- > src/shared/timeout-glib.c | 11 +---------- > src/shared/timeout-mainloop.c | 11 +---------- > src/shared/timeout.h | 11 +---------- > src/shared/tty.h | 15 +-------------- > src/shared/uhid.c | 15 +-------------- > src/shared/uhid.h | 15 +-------------- > src/shared/util.c | 15 +-------------- > src/shared/util.h | 15 +-------------- > src/storage.c | 15 +-------------- > src/storage.h | 15 +-------------- > src/textfile.c | 15 +-------------- > src/textfile.h | 15 +-------------- > src/uinput.h | 15 +-------------- > src/uuid-helper.c | 15 +-------------- > src/uuid-helper.h | 15 +-------------- > tools/3dsp.c | 15 +-------------- > tools/advtest.c | 15 +-------------- > tools/amptest.c | 15 +-------------- > tools/avinfo.c | 15 +-------------- > tools/avtest.c | 15 +-------------- > tools/bccmd.c | 15 +-------------- > tools/bcmfw.c | 15 +-------------- > tools/bdaddr.c | 15 +-------------- > tools/bluemoon.c | 15 +-------------- > tools/bluetooth-player.c | 15 +-------------- > tools/bnep-tester.c | 15 +-------------- > tools/bneptest.c | 15 +-------------- > tools/btattach.c | 15 +-------------- > tools/btconfig.c | 15 +-------------- > tools/btgatt-client.c | 15 +-------------- > tools/btgatt-server.c | 11 +---------- > tools/btinfo.c | 15 +-------------- > tools/btiotest.c | 15 +-------------- > tools/btmgmt.c | 15 +-------------- > tools/btmon-logger.c | 15 +-------------- > tools/btpclient.c | 15 +-------------- > tools/btpclientctl.c | 15 +-------------- > tools/btproxy.c | 15 +-------------- > tools/btsnoop.c | 15 +-------------- > tools/check-selftest.c | 15 +-------------- > tools/ciptool.c | 15 +-------------- > tools/cltest.c | 15 +-------------- > tools/create-image.c | 15 +-------------- > tools/csr.c | 15 +-------------- > tools/csr.h | 15 +-------------- > tools/csr_3wire.c | 15 +-------------- > tools/csr_bcsp.c | 15 +-------------- > tools/csr_h4.c | 15 +-------------- > tools/csr_hci.c | 15 +-------------- > tools/csr_usb.c | 15 +-------------- > tools/eddystone.c | 15 +-------------- > tools/gap-tester.c | 15 +-------------- > tools/gatt-service.c | 15 +-------------- > tools/hci-tester.c | 15 +-------------- > tools/hciattach.c | 15 +-------------- > tools/hciattach.h | 15 +-------------- > tools/hciattach_ath3k.c | 15 +-------------- > tools/hciattach_bcm43xx.c | 15 +-------------- > tools/hciattach_intel.c | 15 +-------------- > tools/hciattach_qualcomm.c | 15 +-------------- > tools/hciattach_st.c | 15 +-------------- > tools/hciattach_ti.c | 15 +-------------- > tools/hciattach_tialt.c | 15 +-------------- > tools/hciconfig.c | 15 +-------------- > tools/hcidump.c | 15 +-------------- > tools/hcieventmask.c | 15 +-------------- > tools/hcisecfilter.c | 15 +-------------- > tools/hcitool.c | 15 +-------------- > tools/hex2hcd.c | 15 +-------------- > tools/hid2hci.c | 15 +-------------- > tools/hwdb.c | 15 +-------------- > tools/ibeacon.c | 15 +-------------- > tools/l2cap-tester.c | 15 +-------------- > tools/l2ping.c | 15 +-------------- > tools/l2test.c | 15 +-------------- > tools/mcaptest.c | 15 +-------------- > tools/mesh-cfgclient.c | 11 +---------- > tools/mesh-gatt/config-client.c | 15 +-------------- > tools/mesh-gatt/config-server.c | 15 +-------------- > tools/mesh-gatt/crypto.c | 15 +-------------- > tools/mesh-gatt/crypto.h | 15 +-------------- > tools/mesh-gatt/gatt.c | 15 +-------------- > tools/mesh-gatt/gatt.h | 15 +-------------- > tools/mesh-gatt/keys.h | 15 +-------------- > tools/mesh-gatt/mesh-net.h | 15 +-------------- > tools/mesh-gatt/net.c | 15 +-------------- > tools/mesh-gatt/net.h | 15 +-------------- > tools/mesh-gatt/node.c | 15 +-------------- > tools/mesh-gatt/node.h | 15 +-------------- > tools/mesh-gatt/onoff-model.c | 15 +-------------- > tools/mesh-gatt/onoff-model.h | 15 +-------------- > tools/mesh-gatt/prov-db.c | 15 +-------------- > tools/mesh-gatt/prov-db.h | 15 +-------------- > tools/mesh-gatt/prov.c | 15 +-------------- > tools/mesh-gatt/prov.h | 15 +-------------- > tools/mesh-gatt/util.c | 15 +-------------- > tools/mesh-gatt/util.h | 15 +-------------- > tools/mesh/agent.c | 15 +-------------- > tools/mesh/agent.h | 15 +-------------- > tools/mesh/cfgcli.c | 12 +----------- > tools/mesh/cfgcli.h | 12 +----------- > tools/mesh/config-model.h | 15 +-------------- > tools/mesh/keys.c | 12 +----------- > tools/mesh/keys.h | 12 +----------- > tools/mesh/mesh-db.c | 11 +---------- > tools/mesh/mesh-db.h | 11 +---------- > tools/mesh/model.h | 12 +----------- > tools/mesh/remote.c | 11 +---------- > tools/mesh/remote.h | 11 +---------- > tools/mesh/util.c | 11 +---------- > tools/mesh/util.h | 11 +---------- > tools/meshctl.c | 15 +-------------- > tools/mgmt-tester.c | 15 +-------------- > tools/mpris-proxy.c | 15 +-------------- > tools/nokfw.c | 15 +-------------- > tools/obex-client-tool.c | 14 +------------- > tools/obex-server-tool.c | 14 +------------- > tools/obexctl.c | 15 +-------------- > tools/oobtest.c | 15 +-------------- > tools/parser/amp.c | 15 +-------------- > tools/parser/att.c | 15 +-------------- > tools/parser/avctp.c | 15 +-------------- > tools/parser/avdtp.c | 15 +-------------- > tools/parser/avrcp.c | 15 +-------------- > tools/parser/bnep.c | 15 +-------------- > tools/parser/bpa.c | 15 +-------------- > tools/parser/capi.c | 15 +-------------- > tools/parser/cmtp.c | 15 +-------------- > tools/parser/csr.c | 15 +-------------- > tools/parser/ericsson.c | 15 +-------------- > tools/parser/hci.c | 15 +-------------- > tools/parser/hcrp.c | 15 +-------------- > tools/parser/hidp.c | 15 +-------------- > tools/parser/l2cap.c | 15 +-------------- > tools/parser/l2cap.h | 15 +-------------- > tools/parser/lmp.c | 15 +-------------- > tools/parser/obex.c | 15 +-------------- > tools/parser/parser.c | 15 +-------------- > tools/parser/parser.h | 15 +-------------- > tools/parser/ppp.c | 15 +-------------- > tools/parser/rfcomm.c | 15 +-------------- > tools/parser/rfcomm.h | 15 +-------------- > tools/parser/sap.c | 15 +-------------- > tools/parser/sdp.c | 15 +-------------- > tools/parser/sdp.h | 15 +-------------- > tools/parser/smp.c | 15 +-------------- > tools/parser/tcpip.c | 15 +-------------- > tools/rctest.c | 15 +-------------- > tools/rfcomm-tester.c | 15 +-------------- > tools/rfcomm.c | 15 +-------------- > tools/rtlfw.c | 15 +-------------- > tools/sco-tester.c | 15 +-------------- > tools/scotest.c | 15 +-------------- > tools/sdptool.c | 15 +-------------- > tools/seq2bseq.c | 15 +-------------- > tools/smp-tester.c | 15 +-------------- > tools/test-runner.c | 15 +-------------- > tools/ubcsp.c | 20 +------------------- > tools/ubcsp.h | 20 +------------------- > tools/userchan-tester.c | 15 +-------------- > unit/test-avctp.c | 15 +-------------- > unit/test-avdtp.c | 15 +-------------- > unit/test-avrcp.c | 15 +-------------- > unit/test-crc.c | 15 +-------------- > unit/test-crypto.c | 15 +-------------- > unit/test-ecc.c | 21 +-------------------- > unit/test-eir.c | 15 +-------------- > unit/test-gatt.c | 15 +-------------- > unit/test-gattrib.c | 15 +-------------- > unit/test-gdbus-client.c | 15 +-------------- > unit/test-gobex-apparam.c | 15 +-------------- > unit/test-gobex-header.c | 15 +-------------- > unit/test-gobex-packet.c | 15 +-------------- > unit/test-gobex-transfer.c | 15 +-------------- > unit/test-gobex.c | 15 +-------------- > unit/test-hfp.c | 15 +-------------- > unit/test-hog.c | 15 +-------------- > unit/test-lib.c | 15 +-------------- > unit/test-mesh-crypto.c | 11 +---------- > unit/test-mgmt.c | 15 +-------------- > unit/test-midi.c | 16 +--------------- > unit/test-queue.c | 15 +-------------- > unit/test-ringbuf.c | 15 +-------------- > unit/test-sdp.c | 15 +-------------- > unit/test-textfile.c | 15 +-------------- > unit/test-uhid.c | 15 +-------------- > unit/test-uuid.c | 15 +-------------- > unit/util.c | 14 +------------- > unit/util.h | 14 +------------- > 758 files changed, 758 insertions(+), 10148 deletions(-) -- pozdrawiam Szymon Janc Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sLlvFwmBYF8KwwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 10:53:29 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id kKugFAmBYF+eKAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 10:53:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4A5FD40017; Tue, 15 Sep 2020 10:53:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726235AbgIOIxU (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 04:53:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726123AbgIOIxO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 04:53:14 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E845C061788 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 01:53:13 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id d6so1529528pfn.9 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 01:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oSkXbP+J1TMjFBWegElSl4Q/t7muEHtw5BSMl1QhD/A=; b=bEGK3MH/KPcY/OY47ViPoat0bty5dX+hrA6NxHMHsXcBuOfJqR6FPMQQXpXhZgYigI JmgoZ4NtwzxGaSAd/RD23Dh1RXab8nON6MsVV6Pkl+v4tsUE/pilohW3ZU1WU5l0O6Sn lmXgcRxOCKEJ+BiIj/xEwzMSJx9odazEmrqWk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oSkXbP+J1TMjFBWegElSl4Q/t7muEHtw5BSMl1QhD/A=; b=ku1Ed+R2y8W/kam7lpTdTkAOP+dLOLCb6xFss6eE/80U7HbZMcxQghD2+O8ltjByet 3ZT17d5VWGqY5hXJAxZXF+rP6vJC5C6PGlzaeMsPlTImcie3qPYRP+pXyIrLPhEqAcfq S6EWuwhxxBchAUHdXSopyq72GB8iccroHkyuhGWDCvNqpCGtwvYqTeBa++aizt9IZ8K0 WkjAxwGJNohtcnGJegm0rH1AlpgMhzlvhJC7MWrmc9R2qAN1AOOZp3Jaz5c/32vUv5hQ 5uFcPrVPHvFIRIG1g0EQfyzZyZ7fuxqbe4p5xQxbOH9Azf8LRkNNG3WoOkoBvXXHTL3j lddg== X-Gm-Message-State: AOAM532Yn4Hp+UKrnw61YpQ5xJ+cfXjGfhETbt5fqpzRSlkqnUsu4aQ8 rdldRRV6ipEK0qBh52m7Xt9iDA== X-Google-Smtp-Source: ABdhPJxPgY2cVxs+wfsepzZjYz4wG5cYt8PMDDotZxERLscCPzUpGidDwul7+Hj5ACF0S8AxFvoZtQ== X-Received: by 2002:a05:6a00:1513:b029:142:2501:34de with SMTP id q19-20020a056a001513b0290142250134demr945662pfu.55.1600159993183; Tue, 15 Sep 2020 01:53:13 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:3e52:82ff:fe5e:cc9d]) by smtp.gmail.com with ESMTPSA id c1sm12707157pfi.136.2020.09.15.01.53.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Sep 2020 01:53:12 -0700 (PDT) From: Claire Chang <tientzu@chromium.org> To: marcel@holtmann.org, johan.hedberg@gmail.com, davem@davemloft.net, kuba@kernel.org Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Claire Chang <tientzu@chromium.org> Subject: [PATCH] Bluetooth: Move force_bredr_smp debugfs into hci_debugfs_create_bredr Date: Tue, 15 Sep 2020 16:53:07 +0800 Message-Id: <20200915085307.1171598-1-tientzu@chromium.org> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 4.18 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4A5FD40017 X-Rspamd-UID: d9677e Avoid multiple attempts to create the debugfs entery, force_bredr_smp, by moving it from the SMP registration to the BR/EDR controller init section. hci_debugfs_create_bredr is only called when HCI_SETUP and HCI_CONFIG is not set. Signed-off-by: Claire Chang <tientzu@chromium.org> --- net/bluetooth/hci_debugfs.c | 50 +++++++++++++++++++++++++++++++++++++ net/bluetooth/smp.c | 44 ++------------------------------ net/bluetooth/smp.h | 2 ++ 3 files changed, 54 insertions(+), 42 deletions(-) diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c index 5e8af2658e44..4626e0289a97 100644 --- a/net/bluetooth/hci_debugfs.c +++ b/net/bluetooth/hci_debugfs.c @@ -494,6 +494,45 @@ static int auto_accept_delay_get(void *data, u64 *val) DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get, auto_accept_delay_set, "%llu\n"); +static ssize_t force_bredr_smp_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct hci_dev *hdev = file->private_data; + char buf[3]; + + buf[0] = hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP) ? 'Y' : 'N'; + buf[1] = '\n'; + buf[2] = '\0'; + return simple_read_from_buffer(user_buf, count, ppos, buf, 2); +} + +static ssize_t force_bredr_smp_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct hci_dev *hdev = file->private_data; + bool enable; + int err; + + err = kstrtobool_from_user(user_buf, count, &enable); + if (err) + return err; + + err = smp_force_bredr(hdev, enable); + if (err) + return err; + + return count; +} + +static const struct file_operations force_bredr_smp_fops = { + .open = simple_open, + .read = force_bredr_smp_read, + .write = force_bredr_smp_write, + .llseek = default_llseek, +}; + static int idle_timeout_set(void *data, u64 val) { struct hci_dev *hdev = data; @@ -589,6 +628,17 @@ void hci_debugfs_create_bredr(struct hci_dev *hdev) debugfs_create_file("voice_setting", 0444, hdev->debugfs, hdev, &voice_setting_fops); + /* If the controller does not support BR/EDR Secure Connections + * feature, then the BR/EDR SMP channel shall not be present. + * + * To test this with Bluetooth 4.0 controllers, create a debugfs + * switch that allows forcing BR/EDR SMP support and accepting + * cross-transport pairing on non-AES encrypted connections. + */ + if (!lmp_sc_capable(hdev)) + debugfs_create_file("force_bredr_smp", 0644, hdev->debugfs, + hdev, &force_bredr_smp_fops); + if (lmp_ssp_capable(hdev)) { debugfs_create_file("ssp_debug_mode", 0444, hdev->debugfs, hdev, &ssp_debug_mode_fops); diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 433227f96c73..8b817e4358fd 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -3353,31 +3353,8 @@ static void smp_del_chan(struct l2cap_chan *chan) l2cap_chan_put(chan); } -static ssize_t force_bredr_smp_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +int smp_force_bredr(struct hci_dev *hdev, bool enable) { - struct hci_dev *hdev = file->private_data; - char buf[3]; - - buf[0] = hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP) ? 'Y': 'N'; - buf[1] = '\n'; - buf[2] = '\0'; - return simple_read_from_buffer(user_buf, count, ppos, buf, 2); -} - -static ssize_t force_bredr_smp_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct hci_dev *hdev = file->private_data; - bool enable; - int err; - - err = kstrtobool_from_user(user_buf, count, &enable); - if (err) - return err; - if (enable == hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP)) return -EALREADY; @@ -3399,16 +3376,9 @@ static ssize_t force_bredr_smp_write(struct file *file, hci_dev_change_flag(hdev, HCI_FORCE_BREDR_SMP); - return count; + return 0; } -static const struct file_operations force_bredr_smp_fops = { - .open = simple_open, - .read = force_bredr_smp_read, - .write = force_bredr_smp_write, - .llseek = default_llseek, -}; - int smp_register(struct hci_dev *hdev) { struct l2cap_chan *chan; @@ -3433,17 +3403,7 @@ int smp_register(struct hci_dev *hdev) hdev->smp_data = chan; - /* If the controller does not support BR/EDR Secure Connections - * feature, then the BR/EDR SMP channel shall not be present. - * - * To test this with Bluetooth 4.0 controllers, create a debugfs - * switch that allows forcing BR/EDR SMP support and accepting - * cross-transport pairing on non-AES encrypted connections. - */ if (!lmp_sc_capable(hdev)) { - debugfs_create_file("force_bredr_smp", 0644, hdev->debugfs, - hdev, &force_bredr_smp_fops); - /* Flag can be already set here (due to power toggle) */ if (!hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP)) return 0; diff --git a/net/bluetooth/smp.h b/net/bluetooth/smp.h index 121edadd5f8d..fc35a8bf358e 100644 --- a/net/bluetooth/smp.h +++ b/net/bluetooth/smp.h @@ -193,6 +193,8 @@ bool smp_irk_matches(struct hci_dev *hdev, const u8 irk[16], int smp_generate_rpa(struct hci_dev *hdev, const u8 irk[16], bdaddr_t *rpa); int smp_generate_oob(struct hci_dev *hdev, u8 hash[16], u8 rand[16]); +int smp_force_bredr(struct hci_dev *hdev, bool enable); + int smp_register(struct hci_dev *hdev); void smp_unregister(struct hci_dev *hdev); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EGleLZuJYF9lOQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 11:30:03 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id qP+0KpuJYF/VggAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 11:30:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=mg.codeaurora.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E794640967; Tue, 15 Sep 2020 11:29:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgIOJ3r (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 05:29:47 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:58176 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726269AbgIOJ3p (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 05:29:45 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1600162184; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=hHIbfLl6RWvz4DJdAyYziC/fu0CysGUZFrToZk/mxTE=; b=u17xLSH27B6rA+QdffKfKNH1/D3bk7e78DCxMztVVI226/FUiOTrprpaCsHhAi8wpeQH1GiD P3rO4EmJbPW+q+AQgloDHIKb7GpsuwCGN0FRcTOjrcYVBNsO6mbxuzHONiNXcvArDtHwWuVv tAzVFdv9wzBhnHpYAkL77VQIWJY= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI2MTA3ZSIsICJsaW51eC1ibHVldG9vdGhAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-west-2.postgun.com with SMTP id 5f60897cd7b4e269137b8d62 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 15 Sep 2020 09:29:32 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id B259EC433F0; Tue, 15 Sep 2020 09:29:32 +0000 (UTC) Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: rjliao) by smtp.codeaurora.org (Postfix) with ESMTPSA id DE217C433CA; Tue, 15 Sep 2020 09:29:31 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 15 Sep 2020 17:29:31 +0800 From: Rocky Liao <rjliao@codeaurora.org> To: Marcel Holtmann <marcel@holtmann.org> Cc: Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v2] Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support In-Reply-To: <4FCC6630-8350-4E4A-B156-42B2F3581BFD@holtmann.org> References: <0101017457c6b819-d1292819-1fae-43af-8fb8-3bc572f53cd5-000000@us-west-2.amazonses.com> <20200914092744.17464-1-rjliao@codeaurora.org> <4FCC6630-8350-4E4A-B156-42B2F3581BFD@holtmann.org> Message-ID: <c9912094c4627b34f49458ae36c9cd25@codeaurora.org> X-Sender: rjliao@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.68 / 15.00 / 15.00 X-Rspamd-Queue-Id: E794640967 X-Rspamd-UID: 96e036 Hi Marcel, 在 2020-09-14 21:28,Marcel Holtmann 写道: > Hi Rocky, > >> This patch add support for WCN6855 i.e. patch and nvm download >> support. >> >> Signed-off-by: Rocky Liao <rjliao@codeaurora.org> >> --- >> drivers/bluetooth/btusb.c | 50 ++++++++++++++++++++++++++++++++++----- >> 1 file changed, 44 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c >> index fe80588c7bd3..789e8d5e829e 100644 >> --- a/drivers/bluetooth/btusb.c >> +++ b/drivers/bluetooth/btusb.c >> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver; >> #define BTUSB_MEDIATEK 0x200000 >> #define BTUSB_WIDEBAND_SPEECH 0x400000 >> #define BTUSB_VALID_LE_STATES 0x800000 >> +#define BTUSB_QCA_WCN6855 0x1000000 >> >> static const struct usb_device_id btusb_table[] = { >> /* Generic Bluetooth USB device */ >> @@ -273,6 +274,10 @@ static const struct usb_device_id >> blacklist_table[] = { >> { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME }, >> { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME }, >> >> + /* QCA WCN6855 chipset */ >> + { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 | >> + BTUSB_WIDEBAND_SPEECH }, >> + >> /* Broadcom BCM2035 */ >> { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, >> { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU }, >> @@ -3391,6 +3396,26 @@ static int btusb_set_bdaddr_ath3012(struct >> hci_dev *hdev, >> return 0; >> } >> >> +static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev, >> + const bdaddr_t *bdaddr) >> +{ >> + struct sk_buff *skb; >> + u8 buf[6]; >> + long ret; >> + >> + memcpy(buf, bdaddr, sizeof(bdaddr_t)); >> + >> + skb = __hci_cmd_sync(hdev, 0xfc14, sizeof(buf), buf, >> HCI_INIT_TIMEOUT); >> + if (IS_ERR(skb)) { >> + ret = PTR_ERR(skb); >> + bt_dev_err(hdev, "Change address command failed (%ld)", ret); >> + return ret; >> + } >> + kfree_skb(skb); >> + >> + return 0; >> +} >> + >> #define QCA_DFU_PACKET_LEN 4096 >> >> #define QCA_GET_TARGET_VERSION 0x09 >> @@ -3428,6 +3453,8 @@ static const struct qca_device_info >> qca_devices_table[] = { >> { 0x00000201, 28, 4, 18 }, /* Rome 2.1 */ >> { 0x00000300, 28, 4, 18 }, /* Rome 3.0 */ >> { 0x00000302, 28, 4, 18 }, /* Rome 3.2 */ >> + { 0x00130100, 40, 4, 18 }, /* WCN6855 1.0 */ >> + { 0x00130200, 40, 4, 18 } /* WCN6855 2.0 */ >> }; >> >> static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 >> request, >> @@ -3529,8 +3556,8 @@ static int btusb_setup_qca_load_rampatch(struct >> hci_dev *hdev, >> { >> struct qca_rampatch_version *rver; >> const struct firmware *fw; >> - u32 ver_rom, ver_patch; >> - u16 rver_rom, rver_patch; >> + u32 ver_rom, ver_patch, rver_rom; >> + u16 rver_rom_low, rver_rom_high, rver_patch; >> char fwname[64]; >> int err; >> >> @@ -3549,9 +3576,16 @@ static int btusb_setup_qca_load_rampatch(struct >> hci_dev *hdev, >> bt_dev_info(hdev, "using rampatch file: %s", fwname); >> >> rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset); >> - rver_rom = le16_to_cpu(rver->rom_version); >> + rver_rom_low = le16_to_cpu(rver->rom_version); >> rver_patch = le16_to_cpu(rver->patch_version); >> >> + if (ver_rom & ~0xffffU) { >> + rver_rom_high = le16_to_cpu(*(__le16 *)(fw->data + 16)); >> + rver_rom = le32_to_cpu(rver_rom_high << 16 | rver_rom_low); >> + } else { >> + rver_rom = (__force u32)rver_rom_low; >> + } >> + > > I don’t get this. Is anything wrong with get_unaligned_le32 etc.? > > My brain just hurts with your casting and pointer magic. Maybe the > whole rver logic needs a clean up first. > It's not a 4 bytes le data, for example the version stream is 0x13, 0x00, 0x00, 0x01 and we need to convert it to 0x00130100. So we have to convert it to 2 u16 value then combine them to a u32. > Regards > > Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +E68M5HyYF8LDAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 18:57:53 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qGznMJHyYF+zXwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 18:57:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DBAD8A0B33; Tue, 15 Sep 2020 18:57:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726586AbgIOQ5H (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 12:57:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727685AbgIOQwa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 12:52:30 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22778C061788 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 09:51:24 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id c10so3848573otm.13 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 09:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vZJ5c1oNq+PSxzLvAz6o8y4iFvnbqXrW0+p9q2WgnWU=; b=CUfXU1IkphycK6bsRwjflyuwE1/Em2IzPeqsbuVF34bcaPNQLzbGwk1mMZposk5ytP cBA1etA0WnkgscwRRK9xXLU+xokgCoukPb8T4/VF1Lo4e7F+7bAiTHh1Aje+uv3RRPpT qBEZ60QP2t8zg3JT92AFTllXyhW1FoKu6JmtS57M8OAv8aHQ7nf0ZjilA5Lc+DnZtKBq BSjDC2qrvPzURPONKJxdBgjGh21bTdmaAI6DosdUmCtIg/XpM7CRuOGgiTnHVxcgOyju vCwRSQJWU3tov7sYF6g6cNfsYB3unEEHyDJxMfS69xwS7wWwaQDBkZ2856ezU/PYujoi qJ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vZJ5c1oNq+PSxzLvAz6o8y4iFvnbqXrW0+p9q2WgnWU=; b=n+OCETZ+pU0ChlSJHVBxkd7K7hDjJ80GX2t9dTPfzBoymHNUSAUdQDD8GQBMKfFZmF eGDOsSsOZI0mOYc7FOgIwvkHfIH+tgphnFBIWndwjSwPkJXoq5/h7RwuGYsuxBKOFPzh ICorghw8EQwbRTdoFDooHaLBxatyV5iTnl1zbSUtnKILW1AwOKbfaIjpHaamJFqmFXU/ 9GAVH2FzXd+s94hjlD1/TLz0X+IHkKwvZZeflHTJSlgieudTYtli++ar9nD9aeqolglb dViFix3m2CxFGMBGlydWTGowVoRFqnHDP4li+h/QkWTF0sVl+EjCoDcqSf0dT11kpLe3 vWQg== X-Gm-Message-State: AOAM532l+MLuDU4ALHqU5LFiOHpvjquE1caGTG5alBNqD0v5jTnUImB6 PeQxoB5bDyA2rRDfuKowXn40Wj1M0qcdCBrCil4= X-Google-Smtp-Source: ABdhPJxhUHXJFxe9onWBC/pAzZbGIRjTdV/gF/IjfEU8TbaxsJC9Ub+nrOO8pPWuR3iCqcpP49s9nZooE8buK3ToCFE= X-Received: by 2002:a9d:5a8:: with SMTP id 37mr5439144otd.362.1600188683403; Tue, 15 Sep 2020 09:51:23 -0700 (PDT) MIME-Version: 1.0 References: <20200915110347.Bluez.v3.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> In-Reply-To: <20200915110347.Bluez.v3.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 15 Sep 2020 09:51:12 -0700 Message-ID: <CABBYNZKQhnQDaTQ_e-FA6hCEW5ZChaOdOQ-qCx3gpQXSPBD29g@mail.gmail.com> Subject: Re: [Bluez PATCH v3] device: don't wait for timeout if RemoveDevice is called To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: DBAD8A0B33 X-Rspamd-UID: 71c683 Hi Archie, On Mon, Sep 14, 2020 at 8:04 PM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > RemoveDevice on adapter interface used to remove a device, even when > the device is connected. However, since the introduction of the new > 30 seconds timeout when setting a device as temporary, RemoveDevice > doesn't immediately remove a connected device, but only disconnects > it and waits for the timer to expire before effectively removes it. > > This patch removes the device as soon as it gets disconnected, > provided the disconnection is triggered by a call to RemoveDevice. > The regular timeout still applies for other cases. > > Tested manually by calling RemoveDevice on a connected device, > and with ChromeOS autotest setup. > > Reviewed-by: Daniel Winkler <danielwinkler@google.com> > --- > > Changes in v3: > * Rebasing again > > Changes in v2: > * Rebasing to HEAD > > src/adapter.c | 2 -- > src/adapter.h | 2 ++ > src/device.c | 11 +++++++++++ > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index df628a7fd..4e27bd74b 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -80,8 +80,6 @@ > #include "adv_monitor.h" > #include "eir.h" > > -#define ADAPTER_INTERFACE "org.bluez.Adapter1" > - > #define MODE_OFF 0x00 > #define MODE_CONNECTABLE 0x01 > #define MODE_DISCOVERABLE 0x02 > diff --git a/src/adapter.h b/src/adapter.h > index c70a7b0da..2f1e4b737 100644 > --- a/src/adapter.h > +++ b/src/adapter.h > @@ -29,6 +29,8 @@ > #include <lib/bluetooth.h> > #include <lib/sdp.h> > > +#define ADAPTER_INTERFACE "org.bluez.Adapter1" > + > #define MAX_NAME_LENGTH 248 > > /* Invalid SSP passkey value used to indicate negative replies */ > diff --git a/src/device.c b/src/device.c > index 8f73ce4d3..3e7784034 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -3007,6 +3007,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > { > struct bearer_state *state = get_state(device, bdaddr_type); > DBusMessage *reply; > + bool remove_device = false; > > if (!state->connected) > return; > @@ -3036,6 +3037,10 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > while (device->disconnects) { > DBusMessage *msg = device->disconnects->data; > > + if (dbus_message_is_method_call(msg, ADAPTER_INTERFACE, > + "RemoveDevice")) > + remove_device = true; > + > g_dbus_send_reply(dbus_conn, msg, DBUS_TYPE_INVALID); > device->disconnects = g_slist_remove(device->disconnects, msg); > dbus_message_unref(msg); > @@ -3061,6 +3066,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > > g_dbus_emit_property_changed(dbus_conn, device->path, > DEVICE_INTERFACE, "Connected"); > + > + if (remove_device) > + btd_adapter_remove_device(device->adapter, device); > } > > guint device_add_disconnect_watch(struct btd_device *device, > @@ -4482,6 +4490,9 @@ void device_remove(struct btd_device *device, gboolean remove_stored) > disconnect_all(device); > } > > + if (device->temporary_timer > 0) > + g_source_remove(device->temporary_timer); > + > if (device->store_id > 0) { > g_source_remove(device->store_id); > device->store_id = 0; > -- > 2.28.0.618.gf4bc123cb7-goog > Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EF7VFkb9YF+ZqgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 19:43:34 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0CLOEUb9YF80NgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 19:43:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8367B40732; Tue, 15 Sep 2020 19:43:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727937AbgIORmX (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 13:42:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727966AbgIORmB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 13:42:01 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18DDBC06178C for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 10:42:01 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id o20so2345398pfp.11 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 10:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1Lb3TTPN31sY7TtlFDspcb6ha7dyHPbWFWNXvetWXH4=; b=Nysth9fd/ZV6IC4NHMhMej61IFXdbe2fQXQBsN40g28Lf2dOBUSoGAYX1ci0mia8Xv Ogg5au63B8NiuDT889dycIMGI+5KI/H6tSDNhhtDkeBcEF4Ti0kbdJVkbYvbyakcNJ3k vvJpJtkQQDeSKU4nFqG2PYe+JoYQ11EsQwETk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1Lb3TTPN31sY7TtlFDspcb6ha7dyHPbWFWNXvetWXH4=; b=hGtPyXb7+yMEYnx1EDQX9ztYd9zkvouqfm6x48X9cz27LHWubeA9eEcNYkyD3JhBzU jDDuleNATZZVrsB7OPWAxC4SH+3FHZvBmspIbddztz3qs6mEew+ZzMYbOZTj/b4xLtgW Q7nw9qiJtwogvWB1we5pVRIm8CWBJh18r3liZWgJStGtN1kYoLO5/k3/nuTBJWxCe2aO PuZ5JVkptxaLsGeY6HWp5ZTRK/5yaYzgl66mSnNwg43EWrUIoFMvpsvj8boe7quRRjQA yZRU+ScSq0iF4+yvRqObJHYaQkuNQ1m9kZdsHx5ltku5eH8q38RrIVLsxrQ2bt7huRLl KXZw== X-Gm-Message-State: AOAM532Rg1quqjbDKEFajNoM7IWZdxnWD3lC48emM91rOaYdV+SkyJic ku6uFRBcT8IikgxXftSZ9ioiJg== X-Google-Smtp-Source: ABdhPJySXv6MhYQq8gmSLar8/L0BArCo0bDPe8Fe04nb+Z5EY51eLuDgXS//A4YMvD3gcaGzKD+h+w== X-Received: by 2002:a63:2bd1:: with SMTP id r200mr15353887pgr.20.1600191720565; Tue, 15 Sep 2020 10:42:00 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id y29sm15490232pfq.207.2020.09.15.10.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 10:42:00 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v5 4/4] policy: Reconnect audio on controller resume Date: Tue, 15 Sep 2020 10:41:46 -0700 Message-Id: <20200915104127.Bluez.v5.4.I26efd89de3a70af1cd9775d457d0c10f4aafd4cb@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200915174146.1693687-1-abhishekpandit@chromium.org> References: <20200915174146.1693687-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.60 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8367B40732 X-Rspamd-UID: abe240 During system suspend, all peer devices are disconnected. On resume, HID devices will reconnect but audio devices stay disconnected. As a quality of life improvement, mark audio devices that were disconnected due to suspend and attempt to reconnect them when the controller resumes (after a delay for better co-existence with Wi-Fi). --- Changes in v5: None Changes in v4: - Set reconnect timer in disconnect if resume events aren't supported - Only set reconnect timer if adapter matches current notification - Refactor changes in src/adapter to its own commit - Refactor enabling A2DP_SINK_UUID into its own commit Changes in v3: - Refactored resume notification to use btd_adapter_driver - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 - Added A2DP_SINK_UUID to default reconnect list Changes in v2: - Refactored to use policy instead of connecting directly in adapter plugins/policy.c | 84 ++++++++++++++++++++++++++++++++++++++++-------- src/main.c | 1 + src/main.conf | 9 ++++++ 3 files changed, 81 insertions(+), 13 deletions(-) diff --git a/plugins/policy.c b/plugins/policy.c index c18ca8d1f..6bd389518 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -62,6 +62,7 @@ struct reconnect_data { guint timer; bool active; unsigned int attempt; + bool on_resume; }; static const char *default_reconnect[] = { @@ -76,6 +77,9 @@ static const int default_intervals[] = { 1, 2, 4, 8, 16, 32, 64 }; static int *reconnect_intervals = NULL; static size_t reconnect_intervals_len = 0; +static const int default_resume_delay = 2; +static int resume_delay; + static GSList *reconnects = NULL; static unsigned int service_id = 0; @@ -712,6 +716,9 @@ static gboolean reconnect_timeout(gpointer data) /* Mark the GSource as invalid */ reconnect->timer = 0; + /* Mark any reconnect on resume as handled */ + reconnect->on_resume = false; + err = btd_device_connect_services(reconnect->dev, reconnect->services); if (err < 0) { error("Reconnecting services failed: %s (%d)", @@ -725,14 +732,17 @@ static gboolean reconnect_timeout(gpointer data) return FALSE; } -static void reconnect_set_timer(struct reconnect_data *reconnect) +static void reconnect_set_timer(struct reconnect_data *reconnect, int timeout) { - static int timeout = 0; + static int interval_timeout = 0; reconnect->active = true; if (reconnect->attempt < reconnect_intervals_len) - timeout = reconnect_intervals[reconnect->attempt]; + interval_timeout = reconnect_intervals[reconnect->attempt]; + + if (timeout < 0) + timeout = interval_timeout; DBG("attempt %u/%zu %d seconds", reconnect->attempt + 1, reconnect_attempts, timeout); @@ -744,10 +754,14 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) static void disconnect_cb(struct btd_device *dev, uint8_t reason) { struct reconnect_data *reconnect; + struct btd_service *service; + struct policy_data *data; DBG("reason %u", reason); - if (reason != MGMT_DEV_DISCONN_TIMEOUT) + /* Only attempt reconnect for the following reasons */ + if (reason != MGMT_DEV_DISCONN_TIMEOUT && + reason != MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND) return; reconnect = reconnect_find(dev); @@ -756,10 +770,47 @@ static void disconnect_cb(struct btd_device *dev, uint8_t reason) reconnect_reset(reconnect); - DBG("Device %s identified for auto-reconnection", - device_get_path(dev)); + DBG("Device %s identified for auto-reconnection", device_get_path(dev)); + + switch(reason) + { + case MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND: + if (btd_device_get_service(dev, A2DP_SINK_UUID)) { + DBG("%s configured to reconnect on resume", + device_get_path(dev)); - reconnect_set_timer(reconnect); + reconnect->on_resume = true; + + /* If the kernel supports resume events, it is + * preferable to set the reconnect timer there as it is + * a more predictable delay. + */ + if (!has_kernel_features(KERNEL_HAS_RESUME_EVT)) + reconnect_set_timer(reconnect, resume_delay); + } + break; + case MGMT_DEV_DISCONN_TIMEOUT: + reconnect_set_timer(reconnect, -1); + break; + default: + DBG("Developer error. Reason = %d", reason); + break; + } +} + +static void policy_adapter_resume(struct btd_adapter *adapter) +{ + GSList *l; + + /* Check if devices on this adapter need to be reconnected on resume */ + for (l = reconnects; l; l = g_slist_next(l)) { + struct reconnect_data *reconnect = l->data; + + if (reconnect->on_resume && + device_get_adapter(reconnect->dev) == adapter) { + reconnect_set_timer(reconnect, resume_delay); + } + } } static void conn_fail_cb(struct btd_device *dev, uint8_t status) @@ -787,14 +838,15 @@ static void conn_fail_cb(struct btd_device *dev, uint8_t status) return; } - reconnect_set_timer(reconnect); + reconnect_set_timer(reconnect, -1); } static int policy_adapter_probe(struct btd_adapter *adapter) { DBG(""); - btd_adapter_restore_powered(adapter); + if (auto_enable) + btd_adapter_restore_powered(adapter); return 0; } @@ -802,6 +854,7 @@ static int policy_adapter_probe(struct btd_adapter *adapter) static struct btd_adapter_driver policy_driver = { .name = "policy", .probe = policy_adapter_probe, + .resume = policy_adapter_resume, }; static int policy_init(void) @@ -855,14 +908,20 @@ static int policy_init(void) auto_enable = g_key_file_get_boolean(conf, "Policy", "AutoEnable", NULL); + resume_delay = g_key_file_get_integer( + conf, "Policy", "ResumeDelay", &gerr); + + if (gerr) { + g_clear_error(&gerr); + resume_delay = default_resume_delay; + } done: if (reconnect_uuids && reconnect_uuids[0] && reconnect_attempts) { btd_add_disconnect_cb(disconnect_cb); btd_add_conn_fail_cb(conn_fail_cb); } - if (auto_enable) - btd_register_adapter_driver(&policy_driver); + btd_register_adapter_driver(&policy_driver); return 0; } @@ -883,8 +942,7 @@ static void policy_exit(void) btd_service_remove_state_cb(service_id); - if (auto_enable) - btd_unregister_adapter_driver(&policy_driver); + btd_unregister_adapter_driver(&policy_driver); } BLUETOOTH_PLUGIN_DEFINE(policy, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, diff --git a/src/main.c b/src/main.c index b37c32948..038f867b5 100644 --- a/src/main.c +++ b/src/main.c @@ -131,6 +131,7 @@ static const char *policy_options[] = { "ReconnectAttempts", "ReconnectIntervals", "AutoEnable", + "ResumeDelay", NULL }; diff --git a/src/main.conf b/src/main.conf index e1d77cc47..9f882e65a 100644 --- a/src/main.conf +++ b/src/main.conf @@ -202,3 +202,12 @@ # This includes adapters present on start as well as adapters that are plugged # in later on. Defaults to 'false'. #AutoEnable=false + +# Audio devices that were disconnected due to suspend will be reconnected on +# resume. ResumeDelay determines the delay between when the controller +# resumes from suspend and a connection attempt is made. A longer delay is +# better for better co-existence with Wi-Fi. +# The value is in seconds. +# Default: 2 +#ResumeDelay = 2 + -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QNJmLIT9YF+Q7AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 19:44:36 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id eMVIKYT9YF9YQwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 19:44:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 007864000F; Tue, 15 Sep 2020 19:44:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727723AbgIORmU (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 13:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727937AbgIORl5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 13:41:57 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3109C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 10:41:56 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id bd2so1724050plb.7 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 10:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mSVukHJaf23dU18xrmYveJEVtHAOgsrL/FM6fto8MZ0=; b=iL0KxC3JRJNuDjTFZsEYYrqoKEgxAtpjRiXqy436MhG07ru7gDqa1a7R3MsDjmDSY8 Z6g7JzpYn0N11Lsbz2mjNuYm4QtAT5fH4MuxjHDPYow0U/QeLI765Jox8ermxjrEre1R wuvmzubPUJAi++Wd7AUVbfw0qZSYQSAWblpp4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mSVukHJaf23dU18xrmYveJEVtHAOgsrL/FM6fto8MZ0=; b=c1PkMZS2p820SQcVY8yUh3N7lwUKuyfNeNlpOXu3frJFOUin3+O7WHBQb6bC168OOb qAAKMjq8A7o9PFHbaYpstC1U2c5T0Hr/5/9Yx3DgKH4J/yTb5PDdyCI3Aj+XKeNCD31k B/fkj8MsRQoBZbJxVnVCUbG4k5R9Xh/pKdIiucZzgCV9dXPDM2Wi4+IkWGnO5ng5fV2N rOXNxbyiyTd/KkcryBFrSgnZsqKwssVV8j4GO7Ei5Rsdl9C4ewQvGUWd/cULREliFHv6 613nXLKUqe0IqxXA862gwugB8LsmeJbbFQgeaP97OSLzIUp1+L9vbFtGqaCON/XVJrEI gn4w== X-Gm-Message-State: AOAM533l7sB3xZOFrQruIPKuKerZ4ipv+0jjAIUV523DsNWkQRvE0m6c W75xiuPb9iqlbHEi2jraZhiFMg== X-Google-Smtp-Source: ABdhPJywvk6gs4v3oj8E7xFuwTHAL28fQaX+WXa7jY6xwOS32lw/CwWN5z+fwYDg+dgrvnfAD6tFnQ== X-Received: by 2002:a17:90a:cb0f:: with SMTP id z15mr446612pjt.76.1600191716217; Tue, 15 Sep 2020 10:41:56 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id y29sm15490232pfq.207.2020.09.15.10.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 10:41:55 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v5 0/4] adapter: Reconnect audio when resuming from suspend Date: Tue, 15 Sep 2020 10:41:42 -0700 Message-Id: <20200915174146.1693687-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.74 / 15.00 / 15.00 X-Rspamd-Queue-Id: 007864000F X-Rspamd-UID: 0cbca1 Hi Luiz and Marcel, This is a quality of life improvement for the behavior of audio devices during system suspend. This depends on a kernel change that emits suspend/resume events: https://patchwork.kernel.org/project/bluetooth/list/?series=325771 Right now, audio devices will be disconnected as part of suspend but won't be reconnected when the system resumes without user interaction. This is annoying to some users as it causes an interruption to their normal work flow. This change reconnects audio devices that were disconnected for suspend using the following logic: * In the device disconnect callback, mark any devices with the A2DP service uuid for reconnect. The reconnect will not be queued until resume. * In the controller resume callback, queue any policy items that are marked to reconnect on resume for connection with the ResumeDelay value (default = 2s). A reconnect is queued after the controller resumes and the delay between resume and reconnect is configurable via the ResumeDelay key in the Policy settings. The 2s delay was chosen arbitrarily and I think anywhere up to 10s is probably ok. A longer delay is better to account for spurious wakeups and Wi-Fi reconnection time (avoiding any co-ex issues) at the downside of reconnection speed. Here are the tests I have done with this: - Single suspend and verified the headphones reconnect - Suspend stress test for 25 iterations and verify both Wi-Fi and Bluetooth audio reconnect on resume. (Ran with wake minimum time of 10s) - Suspend test with wake time = 1s to verify that BT reconnect isn't attempted. Ran 5 iterations with low wake time and then let it stay awake to confirm reconnect finally completed on last resume. - Suspend test with wake time between 1s - 4s. Ran with 5 iterations and verified it connected several times in the middle and finally at the end. I've tested this on a Pixelbook Go (AC-9260 controller) and HP Chromebook 14a (RTL8822CE controller) with GID6B headset. I've also tested this with the Pixel Buds 2. These earbuds actually reconnect automatically to the Chromebook (even without this policy change) and I verified that the new changes don't break the reconnection mechanism. Thanks Abhishek Changes in v5: - Remove use of !! in has_kernel_features Changes in v4: - Set reconnect timer in disconnect if resume events aren't supported - Only set reconnect timer if adapter matches current notification - Refactor changes in src/adapter to its own commit - Refactor enabling A2DP_SINK_UUID into its own commit Changes in v3: - Refactored resume notification to use btd_adapter_driver - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 - Added A2DP_SINK_UUID to default reconnect list Changes in v2: - Refactored to use policy instead of connecting directly in adapter Abhishek Pandit-Subedi (4): adapter: Refactor kernel feature globals adapter: Handle controller resume and notify drivers policy: Enable reconnect for a2dp-sink in defaults policy: Reconnect audio on controller resume plugins/policy.c | 87 +++++++++++++++++++++++++++++++++------- src/adapter.c | 102 +++++++++++++++++++++++++++++++++-------------- src/adapter.h | 11 +++++ src/main.c | 1 + src/main.conf | 11 ++++- 5 files changed, 168 insertions(+), 44 deletions(-) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +HcqJMb9YF+Q7AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 19:45:42 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id GEHqIMb9YF++WwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 19:45:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 85FEA4086D; Tue, 15 Sep 2020 19:45:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727881AbgIORnY (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 13:43:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727962AbgIORmA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 13:42:00 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB10AC06178B for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 10:41:59 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id a9so169573pjg.1 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 10:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=etTtXFZ+lu630ZAqLK4CGu9TZoeAs1sQTeV8Ne2d0us=; b=OLQmmhykEbiDObMY6ZoX0TLRp1ikCpRQyFIyK1sjIC0ENWMNyGSUAxdt+OD97awO3+ 6YKkwfzsOP2C5Q18SyYf0T8YUUOAxj+g4zbJ5rStZUVB8g/TCbbSRHTR1MNG4Lw9h3eG Q9XkScCXCbLPD0sRs7YQEysLZLNHya8dG2vdg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=etTtXFZ+lu630ZAqLK4CGu9TZoeAs1sQTeV8Ne2d0us=; b=Wtot8YXLdN29U1UvlsTtXAJwaKoW4NJEeQStue0bkhFXjEnLDq00dpsasPMQHCx3wJ nuB+U76hB7kos1t23Q+H1cACHsjJpVTFufO9R2z2p/2ryOuzRFDJrjqm1XWpcnmDt6YC jdo7xgicp2KSWNbh1TUnQJhKoh5TLDYZgQQme3MEqPhydTTfwLIZcSrMxcgEHRT7juhN KdQCPFlyz/taxOL1K7qUvCq7qjSvuWMXG+IvJDGad0FtTbjgiQ9u/LC/3EnLVi3AwPBJ ukRIujWIZs6hZEXUzQXDMCDcCfVKkHTtsk+pB4MG5WOsurVvIBGtYyRU1GCHltIaJRxA 7JnA== X-Gm-Message-State: AOAM531IlYzcvUkum+GEw35AGV7lwd1sop1kAxQEdD7tMykdGYiQPKBw EHXmwSU/T4mwjsNmJqCdF3wKOQ== X-Google-Smtp-Source: ABdhPJy67haYqzSnqDJzk9iacHskFZpn5BMblVFqIjsigk+6rRYwzns2rmgFVA5iCQcPxWU4wrtgAA== X-Received: by 2002:a17:90a:dd46:: with SMTP id u6mr456402pjv.67.1600191719475; Tue, 15 Sep 2020 10:41:59 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id y29sm15490232pfq.207.2020.09.15.10.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 10:41:58 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v5 3/4] policy: Enable reconnect for a2dp-sink in defaults Date: Tue, 15 Sep 2020 10:41:45 -0700 Message-Id: <20200915104127.Bluez.v5.3.Ic87c0fbb00fe76356cee8f78a82b29a47fc6d438@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200915174146.1693687-1-abhishekpandit@chromium.org> References: <20200915174146.1693687-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.60 / 15.00 / 15.00 X-Rspamd-Queue-Id: 85FEA4086D X-Rspamd-UID: 0b8d70 Add a2dp-sink to default reconnects list. --- Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None plugins/policy.c | 3 ++- src/main.conf | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/policy.c b/plugins/policy.c index de51e58b9..c18ca8d1f 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -65,7 +65,8 @@ struct reconnect_data { }; static const char *default_reconnect[] = { - HSP_AG_UUID, HFP_AG_UUID, A2DP_SOURCE_UUID, NULL }; + HSP_AG_UUID, HFP_AG_UUID, A2DP_SOURCE_UUID, + A2DP_SINK_UUID, NULL }; static char **reconnect_uuids = NULL; static const size_t default_attempts = 7; diff --git a/src/main.conf b/src/main.conf index 42f7e41c5..e1d77cc47 100644 --- a/src/main.conf +++ b/src/main.conf @@ -186,7 +186,7 @@ # timeout). The policy plugin should contain a sane set of values by # default, but this list can be overridden here. By setting the list to # empty the reconnection feature gets disabled. -#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb +#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb,0000110b-0000-1000-8000-00805f9b34fb # ReconnectAttempts define the number of attempts to reconnect after a link # lost. Setting the value to 0 disables reconnecting feature. -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KBlJAt/9YF9r3AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 19:46:07 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qKe2Ot79YF+/igEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 19:46:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D15BA4000F; Tue, 15 Sep 2020 19:45:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727962AbgIORn0 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 13:43:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727965AbgIORl7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 13:41:59 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9403C06178A for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 10:41:58 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id 7so2339128pgm.11 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 10:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vd5r3TeLsaCA/FonKoaEEnRN1IsGwZeTfuAzbxCS9yE=; b=Hf+jhrcNZa13owORLbemg2thCh3yoSHlopNqRTy3NhCi64Q5cxIY9uh3MlBm9VYqqD oZ8QezExrZQcda/PDQ+rS3YMxsNmumyGImBpM4BNdQI5l1rzlYxn8TcVpE+smxeowz/L 1TJ1A1fAMx7HVRa1C/Qi/gQ01fWcmRtLgGfvI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vd5r3TeLsaCA/FonKoaEEnRN1IsGwZeTfuAzbxCS9yE=; b=LwCmN/K8a2LI3dvKZGDTC7v2hyzJED2ldvkJzC3BcA9veKR64+zRsumYAv02vhwQqb RzkMznAfxXdQWAozlYiJKlh/orpo/R41y2XEfaZLxDH0ZpjUxKxKTaXwBoxrX6GCJWzI v9yBccv1hw6UVgsgcDvsLHDoxKjwkFDIoPvfNeyA8LdLWbmwa+3CiXt1mBohKkpZ/tB3 o6bh7tATGKUkXKmYV1DBSLmCZsCsI2XenwwMLnpDVOwwjKwDwhS1tRxOFRGaCJu3XN6k p92bux6lOYBz4BbtCpYolqB/7q+8VxoLdqJ9uBdRhwByM38OyuYY78Pjw6sYC5kkdmOe QERA== X-Gm-Message-State: AOAM530bPXS4TgE5lx9TM2i9TFF40Rg2cwI6wSr63HczmlvrPsKwGo5R 1ZVfhgdudfixT9e7yoQfbRXSQQ== X-Google-Smtp-Source: ABdhPJxTU0++yIPdbLfM/+8c2lhdjnTFDnCqLC+YOaES7uoI4DwX5gX8W8wKeqrqxOt4dBGdMbw0Zw== X-Received: by 2002:a63:d648:: with SMTP id d8mr15441341pgj.4.1600191718408; Tue, 15 Sep 2020 10:41:58 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id y29sm15490232pfq.207.2020.09.15.10.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 10:41:57 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v5 2/4] adapter: Handle controller resume and notify drivers Date: Tue, 15 Sep 2020 10:41:44 -0700 Message-Id: <20200915104127.Bluez.v5.2.Ic6aa9c03323b5ef0265e5b5b36986af05d9ecd26@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200915174146.1693687-1-abhishekpandit@chromium.org> References: <20200915174146.1693687-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.83 / 15.00 / 15.00 X-Rspamd-Queue-Id: D15BA4000F X-Rspamd-UID: 1e0875 Register for controller resume notification and notify the adapter drivers when it occurs. Also adds the resume event kernel feature to make sure the kernel supports this event. --- Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None src/adapter.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/adapter.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 88b5202d9..b431097f2 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -8771,6 +8771,33 @@ static void connected_callback(uint16_t index, uint16_t length, eir_data_free(&eir_data); } +static void controller_resume_notify(struct btd_adapter *adapter) +{ + GSList *l; + + for (l = adapter->drivers; l; l = g_slist_next(l)) { + struct btd_adapter_driver *driver = l->data; + if (driver->resume) + driver->resume(adapter); + } +} + +static void controller_resume_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_ev_controller_resume *ev = param; + struct btd_adapter *adapter = user_data; + + if (length < sizeof(*ev)) { + btd_error(adapter->dev_id, "Too small device resume event"); + return; + } + + info("Controller resume with wake event 0x%x", ev->wake_reason); + + controller_resume_notify(adapter); +} + static void device_blocked_callback(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9394,6 +9421,11 @@ static void read_info_complete(uint8_t status, uint16_t length, user_passkey_notify_callback, adapter, NULL); + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, + adapter->dev_id, + controller_resume_callback, + adapter, NULL); + set_dev_class(adapter); set_name(adapter, btd_adapter_get_name(adapter)); @@ -9604,6 +9636,17 @@ static void read_commands_complete(uint8_t status, uint16_t length, break; } } + + for (i = 0; i < num_events; i++) { + uint16_t ev = get_le16(rp->opcodes + num_commands + i); + + switch(ev) { + case MGMT_EV_CONTROLLER_RESUME: + DBG("kernel supports suspend/resume events"); + kernel_features |= KERNEL_HAS_RESUME_EVT; + break; + } + } } static void read_version_complete(uint8_t status, uint16_t length, diff --git a/src/adapter.h b/src/adapter.h index b0ed4915f..fae2e9d3d 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -113,6 +113,7 @@ struct btd_adapter_driver { const char *name; int (*probe) (struct btd_adapter *adapter); void (*remove) (struct btd_adapter *adapter); + void (*resume) (struct btd_adapter *adapter); }; typedef void (*service_auth_cb) (DBusError *derr, void *user_data); @@ -239,6 +240,7 @@ enum kernel_features { KERNEL_BLOCKED_KEYS_SUPPORTED = 1 << 1, KERNEL_SET_SYSTEM_CONFIG = 1 << 2, KERNEL_EXP_FEATURES = 1 << 3, + KERNEL_HAS_RESUME_EVT = 1 << 4, }; bool has_kernel_features(uint32_t feature); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iEW1GKT+YF9r3AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 19:49:24 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id iB4MFqT+YF8/PAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 19:49:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F292E40968; Tue, 15 Sep 2020 19:48:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727916AbgIORoR (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 13:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727803AbgIORl6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 13:41:58 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB9B0C061788 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 10:41:57 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id jw11so166250pjb.0 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 10:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K68OMwlpExv+H2CPFTDq3E7u55gF4Q0V8948rZscVcY=; b=K4iPadvg0nNgSbx6It9gMhlMf8f3iAUys9Jl6j7LYXIlIvdjbXFt2Gsla5ytYqS0Z2 KwWR1KmWId7wMR44ZW0EghB1L8nFOskYcaUFgkkv/RUmCCzC/4zICqtFgbvVx2q/7zDE TTTdmrVU5Umn6U1ix4G3Azv+gJ/05M9AmZBnU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K68OMwlpExv+H2CPFTDq3E7u55gF4Q0V8948rZscVcY=; b=AgwuxRsFP5RfDUt+cFkc0+NyZqqweAw+mdBR9ldFuGewpwiHcm2OWTeAi/H1ZpVoum 1ZBwjYujR1u5X2qp8dLHdxgoKWPHIxK4dpicogBbptPmqgrTgPowUBX3T4U8CVB3sq+z gxnJapGxodhrhKABa+OOpI58nQOls+nVOrhwhEKDh0p1mEBiOuKuFwV0Syn3aVkPdYwl W5UEKbh9bTLaPQXWIZKQymMRICjdWuHtALAnZqrwv0SBK4otIrYVmI8d0WdHZ/CjfYIR Sjcsv4q9npZ41Hi7MVnt9/WmZD3jToCAEtti2uO7bNDK0q6OvcUcanRXYm0k8p2a6sOx J3gA== X-Gm-Message-State: AOAM5337vKhGBtB6So2Cl54G20Lgdlh3MuScOKpUomUne4UORxmCAGgW vXvssg8e3lGlg6Is9wNz+PFUkQ== X-Google-Smtp-Source: ABdhPJwc68XJZ8R6iQvfVf8UExhHudfNU97Pet9GhVy5uDvY3ltTqkxf80GZUXznPoCphv5OvrSTBA== X-Received: by 2002:a17:90a:1548:: with SMTP id y8mr423325pja.113.1600191717370; Tue, 15 Sep 2020 10:41:57 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id y29sm15490232pfq.207.2020.09.15.10.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 10:41:56 -0700 (PDT) From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [Bluez PATCH v5 1/4] adapter: Refactor kernel feature globals Date: Tue, 15 Sep 2020 10:41:43 -0700 Message-Id: <20200915104127.Bluez.v5.1.Ib9712d2bf5d4b3f90c5bc835742aea8c7cd239e4@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200915174146.1693687-1-abhishekpandit@chromium.org> References: <20200915174146.1693687-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.29 / 15.00 / 15.00 X-Rspamd-Queue-Id: F292E40968 X-Rspamd-UID: 0ac31d Move all the kernel specific feature globals into a single kernel_features bitfield and replace all uses with the bitfield instead. --- Changes in v5: - Remove use of !! in has_kernel_features Changes in v4: None Changes in v3: None Changes in v2: None src/adapter.c | 59 ++++++++++++++++++++++++++------------------------- src/adapter.h | 9 ++++++++ 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 1435e2bd7..88b5202d9 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -116,13 +116,7 @@ static const struct mgmt_blocked_key_info blocked_keys[] = { static DBusConnection *dbus_conn = NULL; -static bool kernel_conn_control = false; - -static bool kernel_blocked_keys_supported = false; - -static bool kernel_set_system_config = false; - -static bool kernel_exp_features = false; +static uint32_t kernel_features = 0; static GList *adapter_list = NULL; static unsigned int adapter_remaining = 0; @@ -678,7 +672,7 @@ static bool set_discoverable(struct btd_adapter *adapter, uint8_t mode, DBG("sending set mode command for index %u", adapter->dev_id); - if (kernel_conn_control) { + if (has_kernel_features(KERNEL_CONN_CONTROL)) { if (mode) set_mode(adapter, MGMT_OP_SET_CONNECTABLE, mode); else @@ -1334,7 +1328,7 @@ static void trigger_passive_scanning(struct btd_adapter *adapter) * no need to start any discovery. The kernel will keep scanning * as long as devices are in its auto-connection list. */ - if (kernel_conn_control) + if (has_kernel_features(KERNEL_CONN_CONTROL)) return; /* @@ -1385,7 +1379,7 @@ static void stop_passive_scanning_complete(uint8_t status, uint16_t length, * no need to stop any discovery. The kernel will handle the * auto-connection by itself. */ - if (kernel_conn_control) + if (has_kernel_features(KERNEL_CONN_CONTROL)) return; /* @@ -2816,7 +2810,7 @@ static void property_set_mode_complete(uint8_t status, uint16_t length, static void clear_discoverable(struct btd_adapter *adapter) { - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; if (!(adapter->current_settings & MGMT_SETTING_DISCOVERABLE)) @@ -2876,7 +2870,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting, break; case MGMT_SETTING_DISCOVERABLE: - if (kernel_conn_control) { + if (has_kernel_features(KERNEL_CONN_CONTROL)) { if (mode) { set_mode(adapter, MGMT_OP_SET_CONNECTABLE, mode); @@ -4193,7 +4187,8 @@ static void load_default_system_params(struct btd_adapter *adapter) size_t len = 0; unsigned int err; - if (!main_opts.default_params.num_entries || !kernel_set_system_config) + if (!main_opts.default_params.num_entries || + !has_kernel_features(KERNEL_SET_SYSTEM_CONFIG)) return; params = malloc0(sizeof(*params) * @@ -4878,7 +4873,7 @@ int adapter_connect_list_add(struct btd_adapter *adapter, * adapter_auto_connect_add() function is used to maintain what to * connect. */ - if (kernel_conn_control) + if (has_kernel_features(KERNEL_CONN_CONTROL)) return 0; if (g_slist_find(adapter->connect_list, device)) { @@ -4918,7 +4913,7 @@ void adapter_connect_list_remove(struct btd_adapter *adapter, if (device == adapter->connect_le) adapter->connect_le = NULL; - if (kernel_conn_control) + if (has_kernel_features(KERNEL_CONN_CONTROL)) return; if (!g_slist_find(adapter->connect_list, device)) { @@ -4980,7 +4975,7 @@ void adapter_whitelist_add(struct btd_adapter *adapter, struct btd_device *dev) { struct mgmt_cp_add_device cp; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; memset(&cp, 0, sizeof(cp)); @@ -5019,7 +5014,7 @@ void adapter_whitelist_remove(struct btd_adapter *adapter, struct btd_device *de { struct mgmt_cp_remove_device cp; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; memset(&cp, 0, sizeof(cp)); @@ -5075,7 +5070,7 @@ void adapter_auto_connect_add(struct btd_adapter *adapter, uint8_t bdaddr_type; unsigned int id; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; if (g_slist_find(adapter->connect_list, device)) { @@ -5147,7 +5142,7 @@ void adapter_set_device_wakeable(struct btd_adapter *adapter, const bdaddr_t *bdaddr; uint8_t bdaddr_type; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; bdaddr = device_get_address(device); @@ -5224,7 +5219,7 @@ void adapter_auto_connect_remove(struct btd_adapter *adapter, uint8_t bdaddr_type; unsigned int id; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return; if (!g_slist_find(adapter->connect_list, device)) { @@ -6764,7 +6759,7 @@ connect_le: * If kernel background scan is used then the kernel is * responsible for connecting. */ - if (kernel_conn_control) + if (has_kernel_features(KERNEL_CONN_CONTROL)) return; /* @@ -8964,7 +8959,7 @@ static int clear_devices(struct btd_adapter *adapter) { struct mgmt_cp_remove_device cp; - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) return 0; memset(&cp, 0, sizeof(cp)); @@ -9282,7 +9277,7 @@ static void read_info_complete(uint8_t status, uint16_t length, (missing_settings & MGMT_SETTING_FAST_CONNECTABLE)) set_mode(adapter, MGMT_OP_SET_FAST_CONNECTABLE, 0x01); - if (kernel_exp_features) + if (has_kernel_features(KERNEL_EXP_FEATURES)) read_exp_features(adapter); err = adapter_register(adapter); @@ -9403,7 +9398,8 @@ static void read_info_complete(uint8_t status, uint16_t length, set_name(adapter, btd_adapter_get_name(adapter)); - if (kernel_blocked_keys_supported && !set_blocked_keys(adapter)) { + if (has_kernel_features(KERNEL_BLOCKED_KEYS_SUPPORTED) && + !set_blocked_keys(adapter)) { btd_error(adapter->dev_id, "Failed to set blocked keys for index %u", adapter->dev_id); @@ -9414,7 +9410,7 @@ static void read_info_complete(uint8_t status, uint16_t length, !(adapter->current_settings & MGMT_SETTING_BONDABLE)) set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01); - if (!kernel_conn_control) + if (!has_kernel_features(KERNEL_CONN_CONTROL)) set_mode(adapter, MGMT_OP_SET_CONNECTABLE, 0x01); else if (adapter->current_settings & MGMT_SETTING_CONNECTABLE) set_mode(adapter, MGMT_OP_SET_CONNECTABLE, 0x00); @@ -9590,19 +9586,19 @@ static void read_commands_complete(uint8_t status, uint16_t length, switch (op) { case MGMT_OP_ADD_DEVICE: DBG("enabling kernel-side connection control"); - kernel_conn_control = true; + kernel_features |= KERNEL_CONN_CONTROL; break; case MGMT_OP_SET_BLOCKED_KEYS: DBG("kernel supports the set_blocked_keys op"); - kernel_blocked_keys_supported = true; + kernel_features |= KERNEL_BLOCKED_KEYS_SUPPORTED; break; case MGMT_OP_SET_DEF_SYSTEM_CONFIG: DBG("kernel supports set system confic"); - kernel_set_system_config = true; + kernel_features |= KERNEL_SET_SYSTEM_CONFIG; break; case MGMT_OP_READ_EXP_FEATURES_INFO: DBG("kernel supports exp features"); - kernel_exp_features = true; + kernel_features |= KERNEL_EXP_FEATURES; break; default: break; @@ -9768,3 +9764,8 @@ bool btd_le_connect_before_pairing(void) return false; } + +bool has_kernel_features(uint32_t features) +{ + return (kernel_features & features); +} diff --git a/src/adapter.h b/src/adapter.h index f8ac20261..b0ed4915f 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -233,3 +233,12 @@ void btd_adapter_for_each_device(struct btd_adapter *adapter, void *data); bool btd_le_connect_before_pairing(void); + +enum kernel_features { + KERNEL_CONN_CONTROL = 1 << 0, + KERNEL_BLOCKED_KEYS_SUPPORTED = 1 << 1, + KERNEL_SET_SYSTEM_CONFIG = 1 << 2, + KERNEL_EXP_FEATURES = 1 << 3, +}; + +bool has_kernel_features(uint32_t feature); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8EIuJtsFYV+sQwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 20:20:11 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2ChFI9sFYV9CqgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 20:20:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9343F4096D; Tue, 15 Sep 2020 20:20:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727965AbgIOSQO (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 14:16:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbgIOSO1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 14:14:27 -0400 Received: from mail-ua1-x944.google.com (mail-ua1-x944.google.com [IPv6:2607:f8b0:4864:20::944]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8976C061797 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 11:14:11 -0700 (PDT) Received: by mail-ua1-x944.google.com with SMTP id v5so1341889uau.10 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 11:14:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+dYOdscKsLLbuPXyrWmnbIC4+odjPdewltY6CArt7Y0=; b=En+9bYzKmMSm1MCAH971ZxSd8zQOumDWZsYHYHKPFKZrOie95wQOzOtkKNFSFGCu2b /BYIA5KB1Iwbwv1uNEkc8RTe1V1tQB/Vyarazg02/DVdDKXImqgRG+dFbKzHNL9E+yoJ d8N6MwKIeOl13LvUnauhrWCf5SUUkA0G8QAxk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+dYOdscKsLLbuPXyrWmnbIC4+odjPdewltY6CArt7Y0=; b=ldaNFSUJmEJ/UoQ3KoVNuVfBq+QW+bfbRrVLR1fmgQYUPAjO0268E9CEejx9ZsSNW7 BPnL4WPg7MlPPfpjNUgW6jdfwf6HQLxISU96ZG7+RJAnztUnufgfmsQMQjJJ5ycWy+7p lm4iCEg14ULSSQjYiYSSGWZzQJrJgLIVZLTL/yaVzwQn/VLoSUxbQ1bEESRzXozl/M65 MsDDPiZeyeeYBdjH/au0UUJKsX5j7iNQ86IOpP2w2wnLfu/edyPgMAAtSUi5XzAWsp5j 6HcfnJOq5OYpwzfs9OX32BOWKSnsqRBqP5a0aAOcqgRRPn0co0/jipMM7D/XOCk2JqdV Vgrg== X-Gm-Message-State: AOAM530ov5wNJKibJQ2Xd1zUHzS55o98S7gwLnCVAXpUNLKpF4lTdJSe uiMAsnI+nLuz91NvqANCj5a0coaRNZJV1Wqijg+tNA== X-Google-Smtp-Source: ABdhPJxVgliY4UpLgJqE5mvRPmBH1jvEe9zl/fVRHlWynZA/7aPhC83faqv66D6Mr9/j7veRPo9NBaBSRo+uncOxzBA= X-Received: by 2002:ab0:136f:: with SMTP id h44mr10190880uae.60.1600193650552; Tue, 15 Sep 2020 11:14:10 -0700 (PDT) MIME-Version: 1.0 References: <20200915174146.1693687-1-abhishekpandit@chromium.org> <CABBYNZLmyr5a_WoMwkmBsr2Y8LvnY1xiH724Y2BDOAe5zHFJjw@mail.gmail.com> In-Reply-To: <CABBYNZLmyr5a_WoMwkmBsr2Y8LvnY1xiH724Y2BDOAe5zHFJjw@mail.gmail.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Tue, 15 Sep 2020 11:13:59 -0700 Message-ID: <CANFp7mWYbfZz7vnCTvisox=QpAyyYa72p9uwcqO13w0xgrXdNA@mail.gmail.com> Subject: Re: [Bluez PATCH v5 0/4] adapter: Reconnect audio when resuming from suspend To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.96 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9343F4096D X-Rspamd-UID: 27db6e Awesome, thanks! On Tue, Sep 15, 2020 at 11:05 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Abhishek, > > On Tue, Sep 15, 2020 at 10:41 AM Abhishek Pandit-Subedi > <abhishekpandit@chromium.org> wrote: > > > > > > Hi Luiz and Marcel, > > > > This is a quality of life improvement for the behavior of audio devices > > during system suspend. This depends on a kernel change that emits > > suspend/resume events: > > > > https://patchwork.kernel.org/project/bluetooth/list/?series=325771 > > > > Right now, audio devices will be disconnected as part of suspend but > > won't be reconnected when the system resumes without user interaction. > > This is annoying to some users as it causes an interruption to their > > normal work flow. > > > > This change reconnects audio devices that were disconnected for suspend > > using the following logic: > > > > * In the device disconnect callback, mark any devices with the A2DP > > service uuid for reconnect. The reconnect will not be queued until > > resume. > > * In the controller resume callback, queue any policy items that are > > marked to reconnect on resume for connection with the ResumeDelay > > value (default = 2s). > > > > A reconnect is queued after the controller resumes and the delay > > between resume and reconnect is configurable via the ResumeDelay key in > > the Policy settings. The 2s delay was chosen arbitrarily and I think > > anywhere up to 10s is probably ok. A longer delay is better to account > > for spurious wakeups and Wi-Fi reconnection time (avoiding any co-ex > > issues) at the downside of reconnection speed. > > > > Here are the tests I have done with this: > > - Single suspend and verified the headphones reconnect > > - Suspend stress test for 25 iterations and verify both Wi-Fi and > > Bluetooth audio reconnect on resume. (Ran with wake minimum time of > > 10s) > > - Suspend test with wake time = 1s to verify that BT reconnect isn't > > attempted. Ran 5 iterations with low wake time and then let it stay > > awake to confirm reconnect finally completed on last resume. > > - Suspend test with wake time between 1s - 4s. Ran with 5 iterations and > > verified it connected several times in the middle and finally at the > > end. > > > > I've tested this on a Pixelbook Go (AC-9260 controller) and HP > > Chromebook 14a (RTL8822CE controller) with GID6B headset. > > > > I've also tested this with the Pixel Buds 2. These earbuds actually > > reconnect automatically to the Chromebook (even without this policy > > change) and I verified that the new changes don't break the reconnection > > mechanism. > > > > Thanks > > Abhishek > > > > > > Changes in v5: > > - Remove use of !! in has_kernel_features > > It seems I end up merging the old version by mistake, but I fixed this > one change myself and added btd_ prefix to it since that is required > to be exported for plugins that are not built-in. > > > Changes in v4: > > - Set reconnect timer in disconnect if resume events aren't supported > > - Only set reconnect timer if adapter matches current notification > > - Refactor changes in src/adapter to its own commit > > - Refactor enabling A2DP_SINK_UUID into its own commit > > > > Changes in v3: > > - Refactored resume notification to use btd_adapter_driver > > - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 > > - Added A2DP_SINK_UUID to default reconnect list > > > > Changes in v2: > > - Refactored to use policy instead of connecting directly in adapter > > > > Abhishek Pandit-Subedi (4): > > adapter: Refactor kernel feature globals > > adapter: Handle controller resume and notify drivers > > policy: Enable reconnect for a2dp-sink in defaults > > policy: Reconnect audio on controller resume > > > > plugins/policy.c | 87 +++++++++++++++++++++++++++++++++------- > > src/adapter.c | 102 +++++++++++++++++++++++++++++++++-------------- > > src/adapter.h | 11 +++++ > > src/main.c | 1 + > > src/main.conf | 11 ++++- > > 5 files changed, 168 insertions(+), 44 deletions(-) > > > > -- > > 2.28.0.618.gf4bc123cb7-goog > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OGxHDwMJYV/ODAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 20:33:39 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id kJhrDAMJYV+J2wAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 20:33:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 50091A020E; Tue, 15 Sep 2020 20:33:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727984AbgIOSdP (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 14:33:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727961AbgIOSNI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 14:13:08 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F96CC061788 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 11:05:16 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id g10so4103514otq.9 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 11:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DckkTMToW/Pd08x0QOBy7IYkr6sSl78D8segN8Yf5Tc=; b=JMBQuVkqCjfCvc5R+aQmYagSsW9rZgC91ygi5XK3BYXSJj4ZZ+zFlT1y6rVbEoYfSk wv5QOn7X+XllvXasyXij9i6Li08oahcN+wd/nkSjnC8XHYM65ImtKZ/ThPYMhlx/C9ue s8RZ3sf28dSaOf8nA5BJZ4G8RoqqV5utAvO2k9pJk3kS6C/qNSVDjCkLLdYQrhO6w2ER KjYLODNJVNTU44AUDlq/sK4FSkPvb4O51HwjkO7swRA1J/KJGSoJczMmiRA2pOdHaWrm cOai9u4giKLRHi/p3VjRkU/AUuKoaGB+hWvzo39NPMYWLcaybCN+s5HE3gO1GVwY/9p4 x08g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DckkTMToW/Pd08x0QOBy7IYkr6sSl78D8segN8Yf5Tc=; b=Cc+ElL59pqIy8EB7RrW1di14tkiT1VDImdGjitEN05i6xfHpzVdaiH8awgXeSX+lE+ xH90pDTbTGCnG9Z+I5f1rTEvkOKwyPRqp+XHFR9EXfMd0LaeEdOTnw9DdaCsBFhnB7Sr BM4qTISX3okO85dGV8zg0zy6Z95iS6ooRbe3tpkpfCljCINZQMTnPZM2vBOXPmh2NVlY xSgRJJq43g67wbNhLX8FCxszpJgRGvCIQds2y+/L8nH0goua2pXWyGFC4CoTyWt4W2VP hpcYwPi4mJwIcoFEYWd9uQ+JRqD80ZUgMpvN9YxepOpQRqDWKsRzdqHwi+BkxX8Aa97P 0vBA== X-Gm-Message-State: AOAM5336dliwnMYCu6xTBxJH9ICPOF+Y8gIPedT5ahhdZ9qkZ4ZXDJas t7N0MVuQheD9jLUjVKyC9U1Frur2WLo/bMPZZPaCAet6 X-Google-Smtp-Source: ABdhPJzScZwRugytri4AJ5+tTWKsNt2A4cQ9px+E2jeWLEUy+dlOF4CrREPP6IuC9q3SCBT9g3rSNlTellC2706uPOk= X-Received: by 2002:a9d:5a8:: with SMTP id 37mr5657965otd.362.1600193115793; Tue, 15 Sep 2020 11:05:15 -0700 (PDT) MIME-Version: 1.0 References: <20200915174146.1693687-1-abhishekpandit@chromium.org> In-Reply-To: <20200915174146.1693687-1-abhishekpandit@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 15 Sep 2020 11:05:04 -0700 Message-ID: <CABBYNZLmyr5a_WoMwkmBsr2Y8LvnY1xiH724Y2BDOAe5zHFJjw@mail.gmail.com> Subject: Re: [Bluez PATCH v5 0/4] adapter: Reconnect audio when resuming from suspend To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.12 / 15.00 / 15.00 X-Rspamd-Queue-Id: 50091A020E X-Rspamd-UID: 6a7b36 Hi Abhishek, On Tue, Sep 15, 2020 at 10:41 AM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > > Hi Luiz and Marcel, > > This is a quality of life improvement for the behavior of audio devices > during system suspend. This depends on a kernel change that emits > suspend/resume events: > > https://patchwork.kernel.org/project/bluetooth/list/?series=325771 > > Right now, audio devices will be disconnected as part of suspend but > won't be reconnected when the system resumes without user interaction. > This is annoying to some users as it causes an interruption to their > normal work flow. > > This change reconnects audio devices that were disconnected for suspend > using the following logic: > > * In the device disconnect callback, mark any devices with the A2DP > service uuid for reconnect. The reconnect will not be queued until > resume. > * In the controller resume callback, queue any policy items that are > marked to reconnect on resume for connection with the ResumeDelay > value (default = 2s). > > A reconnect is queued after the controller resumes and the delay > between resume and reconnect is configurable via the ResumeDelay key in > the Policy settings. The 2s delay was chosen arbitrarily and I think > anywhere up to 10s is probably ok. A longer delay is better to account > for spurious wakeups and Wi-Fi reconnection time (avoiding any co-ex > issues) at the downside of reconnection speed. > > Here are the tests I have done with this: > - Single suspend and verified the headphones reconnect > - Suspend stress test for 25 iterations and verify both Wi-Fi and > Bluetooth audio reconnect on resume. (Ran with wake minimum time of > 10s) > - Suspend test with wake time = 1s to verify that BT reconnect isn't > attempted. Ran 5 iterations with low wake time and then let it stay > awake to confirm reconnect finally completed on last resume. > - Suspend test with wake time between 1s - 4s. Ran with 5 iterations and > verified it connected several times in the middle and finally at the > end. > > I've tested this on a Pixelbook Go (AC-9260 controller) and HP > Chromebook 14a (RTL8822CE controller) with GID6B headset. > > I've also tested this with the Pixel Buds 2. These earbuds actually > reconnect automatically to the Chromebook (even without this policy > change) and I verified that the new changes don't break the reconnection > mechanism. > > Thanks > Abhishek > > > Changes in v5: > - Remove use of !! in has_kernel_features It seems I end up merging the old version by mistake, but I fixed this one change myself and added btd_ prefix to it since that is required to be exported for plugins that are not built-in. > Changes in v4: > - Set reconnect timer in disconnect if resume events aren't supported > - Only set reconnect timer if adapter matches current notification > - Refactor changes in src/adapter to its own commit > - Refactor enabling A2DP_SINK_UUID into its own commit > > Changes in v3: > - Refactored resume notification to use btd_adapter_driver > - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 > - Added A2DP_SINK_UUID to default reconnect list > > Changes in v2: > - Refactored to use policy instead of connecting directly in adapter > > Abhishek Pandit-Subedi (4): > adapter: Refactor kernel feature globals > adapter: Handle controller resume and notify drivers > policy: Enable reconnect for a2dp-sink in defaults > policy: Reconnect audio on controller resume > > plugins/policy.c | 87 +++++++++++++++++++++++++++++++++------- > src/adapter.c | 102 +++++++++++++++++++++++++++++++++-------------- > src/adapter.h | 11 +++++ > src/main.c | 1 + > src/main.conf | 11 ++++- > 5 files changed, 168 insertions(+), 44 deletions(-) > > -- > 2.28.0.618.gf4bc123cb7-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AA1aAlYWYV+sQwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 21:30:30 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SB2mOlUWYV9nygEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 21:30:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0EA0EA0B1E; Tue, 15 Sep 2020 21:30:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727909AbgIOT3y (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 15:29:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727653AbgIOT3k (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 15:29:40 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4183C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 12:29:33 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id u4so3815451ljd.10 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 12:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VKidKktc0S1Z/jV12RUT77V60BgHZyP6LKFdtmWca74=; b=AFjSuofb3fIC9UwOKOzBilqlj92UYCwMjnlc/w1ENjqv6dW+68g3oL+12WUQz8GGBh 1+VlxjOh+mOCcT/zYDrBm8AOG34XYJQFkj/PY1eFEYpJo0wv1wL8jVNQq4CE+GY0TNCp mro5JqT00zK3TMg+yfIcnolAyFK3rV4CgQupA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VKidKktc0S1Z/jV12RUT77V60BgHZyP6LKFdtmWca74=; b=h2+Mv8eR7RJNWbKDOnDHN06O+6l/eF3T6fJ2LZfEntZ7e6gRPLkisQTKKjErN/SwXg RdFQO0WeuS2fdnNxgLpELTNdiM9NE8+dUrngphysQbMiApXQMqBltpr0h1dJJRRymYmC e9l+nPZFAOc2c048pG6O93ULt6ba0H/5/ZpGda6bpS6oKz+ja8ad8YjMJoxd+PFAQuql lyHVisaZqKpKkbW+fks6U2GUIGNoEl/Bs6Q3YgkzpEBfmZ8yAUsqPg2zLJRKJBdd0uPR /bqrZXpUrNyOrGkBN7XCYCGBrdrr1Q/S7MZa56/TRUNRY+biNxJIgnAOs24pZjO+zZ/H fEuA== X-Gm-Message-State: AOAM533EXIlTJqvyp3gesepJ4kkfUj28F7JsqVgQjnQjZGXvML3wHQYD /Y83LXgh5e9UeKQb8ZxbhnTTGyon/VIXE5HlonTBAdOYGDCDog== X-Google-Smtp-Source: ABdhPJxvUSqfKnB0sUqgEJybeFI4PsgzbJGUO1R5olnaJFgOserSMvmGrDPbDePyKl8DNK/6+R4pE8VCcsuLUWbGvEA= X-Received: by 2002:a2e:b051:: with SMTP id d17mr6839865ljl.190.1600198172033; Tue, 15 Sep 2020 12:29:32 -0700 (PDT) MIME-Version: 1.0 References: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> <CABBYNZJeXkqmx1h85bxFBqJ4eDVfaPQJ9P1m_HApbJj48zT+_A@mail.gmail.com> In-Reply-To: <CABBYNZJeXkqmx1h85bxFBqJ4eDVfaPQJ9P1m_HApbJj48zT+_A@mail.gmail.com> From: Miao-chen Chou <mcchou@chromium.org> Date: Tue, 15 Sep 2020 12:29:21 -0700 Message-ID: <CABmPvSEZoYCSE_421Qu2b=z91NxajNxWNahA5xcOMqgPmV-ivA@mail.gmail.com> Subject: Re: [BlueZ PATCH v5 1/8] adapter: Remove indirect dependency of headers To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.04 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0EA0EA0B1E X-Rspamd-UID: 8b4036 Hi Luiz, Thanks for the extra fix to get this series through! We're waiting for further comments on https://patchwork.kernel.org/project/bluetooth/list/?series=348071. Regards, Miao On Mon, Sep 14, 2020 at 12:48 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Miao, > > On Fri, Sep 11, 2020 at 11:53 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > Given that adapter.h refers symbols from lib/bluetooth.h and lib/sdp.h, > > these two headers should be included directly in adapter.h. > > > > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > > --- > > > > (no changes since v1) > > > > src/adapter.h | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/src/adapter.h b/src/adapter.h > > index f8ac20261..c70a7b0da 100644 > > --- a/src/adapter.h > > +++ b/src/adapter.h > > @@ -26,6 +26,9 @@ > > #include <dbus/dbus.h> > > #include <glib.h> > > > > +#include <lib/bluetooth.h> > > +#include <lib/sdp.h> > > + > > #define MAX_NAME_LENGTH 248 > > > > /* Invalid SSP passkey value used to indicate negative replies */ > > -- > > 2.26.2 > > Applied, thanks. Note that I did introduce a path to fix the build > problem with g_dbus_proxy_get_path. > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SJDZFtYbYV/2IwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 21:53:58 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id MI7sE9YbYV9UkwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 21:53:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A6DF4A0185; Tue, 15 Sep 2020 21:53:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727389AbgIOTxm (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 15:53:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727835AbgIOTxd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 15:53:33 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3141C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 12:53:32 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id o8so4465381otl.4 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 12:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Id/8pc9vmGXdJuxDyR0dvGreEIK/xqFKlzD5b57ynwI=; b=Hw+Fn54adGj3qBWwfLTpymSdDyMbJpl0HfrOac25KTx2Os0wwI0a+EZwnQQKzvqwWs liYlKE1Ax6ElQ+m29e154goj84Qv3TxbrrA3tMOAd3HsZA6HFQwtR7wHJwg/O7YSOoOx Ggq2dOPr+vXcPigG0AcuRbclPiIoB1kwLkvRgKZZQXmu7/zUsJcJgqdlfc8WrbnGmiz5 5TfhrzpGeUN317RXJoRA0nW9hs6Py3Rbp4qMUMrFrxQos5W8MsOroCpBVtPS7pgqu6vy YKfF9/N2QKmL8P+hh6pm/jIf25miKTccZEBz8yNY4Mb8Td4C1orlgm+KdpL+DmeSGMUt H5WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Id/8pc9vmGXdJuxDyR0dvGreEIK/xqFKlzD5b57ynwI=; b=slXwrUdo48gV/i1ej/tm0RpFhGugXq8GsLz8JFtpGxGoHMaf4QH9tpaoXS6SZD1ZaS 0y+eqzlnvJ2D6XnA9sZ1ebzYGVjXbgdss8oXu7lUP1ED5Q+YWRJZ8WDA6+EDdHlWeVG2 cLXJiXQgTFKfvuZlz124Q7i11EMoaL34v8ytS5tRlnKtremGmpCkuHbbLTtW5RytU30W gu24GtJea/+lzR5+O6Z+bs3+uNGBDRu2U7hTTwhGMRPMvxXFUixZWnY8WVMXJCiGwvIS 99iap/G41g/RWdaW0qaheTrEiAICCIP0/G17KCpUBXXYffPxNJxTSwbt53WsXnyUF6wZ peHg== X-Gm-Message-State: AOAM531B+uO5XAqVyNPwiWsN2OnGfMmzwXTMM+mqxt4AN/MWcQGBHtXJ NOy/2Qg07wSifaDPmOteLeWVwmGw3J4FptuXzyM= X-Google-Smtp-Source: ABdhPJyfpV352hk3wFvjH2p0YgEZO79l1IBI+MDkuJZGYlQMG2vzZH1cQkv00uQXcA6j8jPoo4c55wbc62i1lU1l2GA= X-Received: by 2002:a05:6830:22e6:: with SMTP id t6mr7913295otc.88.1600199612065; Tue, 15 Sep 2020 12:53:32 -0700 (PDT) MIME-Version: 1.0 References: <20200911235104.BlueZ.v5.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid> <CABBYNZJeXkqmx1h85bxFBqJ4eDVfaPQJ9P1m_HApbJj48zT+_A@mail.gmail.com> <CABmPvSEZoYCSE_421Qu2b=z91NxajNxWNahA5xcOMqgPmV-ivA@mail.gmail.com> In-Reply-To: <CABmPvSEZoYCSE_421Qu2b=z91NxajNxWNahA5xcOMqgPmV-ivA@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 15 Sep 2020 12:53:20 -0700 Message-ID: <CABBYNZ+VT9JMMsSh4AysjqJJzuLn5jY=NSsXEKKyAzAdjMDwcw@mail.gmail.com> Subject: Re: [BlueZ PATCH v5 1/8] adapter: Remove indirect dependency of headers To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.51 / 15.00 / 15.00 X-Rspamd-Queue-Id: A6DF4A0185 X-Rspamd-UID: c187e4 Hi Miao, On Tue, Sep 15, 2020 at 12:29 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > Hi Luiz, > > Thanks for the extra fix to get this series through! We're waiting for > further comments on > https://patchwork.kernel.org/project/bluetooth/list/?series=348071. Weird, I don't seem to have received this series. > Regards, > Miao > > On Mon, Sep 14, 2020 at 12:48 PM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Miao, > > > > On Fri, Sep 11, 2020 at 11:53 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > > > Given that adapter.h refers symbols from lib/bluetooth.h and lib/sdp.h, > > > these two headers should be included directly in adapter.h. > > > > > > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > > > --- > > > > > > (no changes since v1) > > > > > > src/adapter.h | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/src/adapter.h b/src/adapter.h > > > index f8ac20261..c70a7b0da 100644 > > > --- a/src/adapter.h > > > +++ b/src/adapter.h > > > @@ -26,6 +26,9 @@ > > > #include <dbus/dbus.h> > > > #include <glib.h> > > > > > > +#include <lib/bluetooth.h> > > > +#include <lib/sdp.h> > > > + > > > #define MAX_NAME_LENGTH 248 > > > > > > /* Invalid SSP passkey value used to indicate negative replies */ > > > -- > > > 2.26.2 > > > > Applied, thanks. Note that I did introduce a path to fix the build > > problem with g_dbus_proxy_get_path. > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GPqUAwy8YV99LgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 09:17:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id aA2GOwu8YV+1GAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 09:17:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 98411408AE; Wed, 16 Sep 2020 09:17:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726262AbgIPHRN (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 03:17:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbgIPHRL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 03:17:11 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33175C061788 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 00:17:10 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id c19so5393391qkk.20 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 00:17:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=jI/5VReMm0tTNSWTPn8NUEGnZNxUSUFoa3fJlfjTJJo=; b=pj27Jc1YVh47n8UPHdgaT/laL75+FvslrGhcq1J5HJnlAptYsh+OCt6nvfbezucZHO rkkb3c6sArikpmgJCH9UX+Aog6HhG7QFwEVc/od0yZ+i3RSjiQvy0KqOhVvFDP/NxGof P8iSKdMwD1KLc/kGOe60HabBTl3PIOCnvAnQamWbNz6I9HdRIPn9JULaQWsvhEgQL1eD 1Ih0yGvfawU6qQer1bzVRQKp7cQyemZIa776Lb1U9ZLz2Fj8cBHQkL82B3N+6qy4Xu0P zPCprlWgQx2otjm2XG1zDwuZbS3GZxyaIsCkC+9QXE4O2faFXyfq6wEyIQQzkMAIlrjm TSOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jI/5VReMm0tTNSWTPn8NUEGnZNxUSUFoa3fJlfjTJJo=; b=l/0KPm+kWUMJGGa2922jflGlNhjYMcSKmx+qrpzMSO6pNAQzZkGD4vbv7+2hVehmmC pxgsCSPKmpXIe/TegpX9uPeVN+cxFhESmNdCmbDbW14L0+zFa/uf7IfXI0PpvHJNzhv+ wj0lsa+Jn2TXg5EUb2st0AaTC3XHZKPROgVOt/5VvJxMkZ3Y7TUyxjWQaCH6pJqNIYWO KyuWEbcky9Rv7Tnd49Tf5KShV0CY9U0PcHHs/ddJF9tRHVLhUzcrxa+G4q2lts0V/j7d CkoNoTSDc/t1feJhS+wRBPjnCZjD2e5/lt11cgaZ0h1SMnw7h/9PcCLM0HVgeTGFjMlP c2Yw== X-Gm-Message-State: AOAM5313qV7Th5PprOJvzhbnBme5xQcY5rIX5OAaJ8uMXYJx8NDQyEF8 rgnOxgEDiy2ne/Wam2mZ+1sBCELX4BKADcnkcv4e8vLRhoZHLGQezNByzvykp1JzPbGZ3mfY45C 78Yuv91/6cS1LjaDvelPZMLC7AQPCka2zNfM7arwoACJ3ZDDyaLbQCoWhZJWh6WJ6UuUlJLHNlR ZLNmn09Fx3asM= X-Google-Smtp-Source: ABdhPJxtKfd+ASL9Pkb1wuiVvivO2YSVOAYdi9KRT9dWnDfSn89fGSGfrPHK0JnU+wUgVa2D2ym2OY+x5axGSHPHUQ== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:4f30:: with SMTP id fc16mr21833088qvb.6.1600240629267; Wed, 16 Sep 2020 00:17:09 -0700 (PDT) Date: Wed, 16 Sep 2020 15:16:51 +0800 In-Reply-To: <20200916151617.BlueZ.v5.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200916151617.BlueZ.v5.3.I680cda25cec9c45ca2b2c5ac3a8e437772ea76d9@changeid> Mime-Version: 1.0 References: <20200916151617.BlueZ.v5.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v5 3/4] client: Expose ADV monitor objects From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, mmandlik@chromium.org, mcchou@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.20 / 15.00 / 15.00 X-Rspamd-Queue-Id: 98411408AE X-Rspamd-UID: f5452f This adds logic to expose user-defined advertisement monitor to dbus and also implements methods for exposed objects. Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v4) Changes in v4: - Remove PRE-UPSTREAM in commit title Reviewed-by: Miao-chen Chou <mcchou@chromium.org> client/adv_monitor.c | 185 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 182 insertions(+), 3 deletions(-) diff --git a/client/adv_monitor.c b/client/adv_monitor.c index d4914b7b1..22bb3c670 100644 --- a/client/adv_monitor.c +++ b/client/adv_monitor.c @@ -53,6 +53,7 @@ struct pattern { struct adv_monitor { uint8_t idx; + char *path; char *type; struct rssi_setting *rssi; GSList *patterns; @@ -68,6 +69,163 @@ static struct adv_monitor_manager { static uint8_t adv_mon_idx; static GSList *adv_mons; +static void remove_adv_monitor(void *data, void *user_data); + +static DBusMessage *release_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + bt_shell_printf("Advertisement monitor %d released\n", + adv_monitor->idx); + remove_adv_monitor(adv_monitor, conn); + + return dbus_message_new_method_return(msg); +} + +static DBusMessage *activate_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + bt_shell_printf("Advertisement monitor %d activated\n", + adv_monitor->idx); + return dbus_message_new_method_return(msg); +} + +static DBusMessage *device_found_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + const char *device; + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device, + DBUS_TYPE_INVALID); + bt_shell_printf("Advertisement monitor %d found device %s\n", + adv_monitor->idx, device); + return dbus_message_new_method_return(msg); +} + +static DBusMessage *device_lost_adv_monitor(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + const char *device; + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device, + DBUS_TYPE_INVALID); + bt_shell_printf("Advertisement monitor %d lost device %s\n", + adv_monitor->idx, device); + return dbus_message_new_method_return(msg); +} + +static const GDBusMethodTable adv_monitor_methods[] = { + { GDBUS_ASYNC_METHOD("Release", NULL, NULL, release_adv_monitor) }, + { GDBUS_ASYNC_METHOD("Activate", NULL, NULL, activate_adv_monitor) }, + { GDBUS_ASYNC_METHOD("DeviceFound", GDBUS_ARGS({ "device", "o" }), + NULL, device_found_adv_monitor) }, + { GDBUS_ASYNC_METHOD("DeviceLost", GDBUS_ARGS({ "device", "o" }), + NULL, device_lost_adv_monitor) }, + { } +}; + + +static gboolean get_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, + &adv_monitor->type); + return TRUE; +} + +static gboolean get_rssi(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + struct rssi_setting *rssi = adv_monitor->rssi; + DBusMessageIter data_iter; + + dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, + NULL, &data_iter); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_INT16, + &rssi->high_threshold); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_UINT16, + &rssi->high_timer); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_INT16, + &rssi->low_threshold); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_UINT16, + &rssi->low_timer); + dbus_message_iter_close_container(iter, &data_iter); + return TRUE; +} + +static gboolean rssi_exists(const GDBusPropertyTable *property, void *data) +{ + struct adv_monitor *adv_monitor = data; + + return adv_monitor->rssi != NULL; +} + +static void append_pattern_content_to_dbus(DBusMessageIter *iter, + struct pattern *pattern) +{ + DBusMessageIter data_iter; + int idx; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE_AS_STRING, &data_iter); + for (idx = 0; idx < pattern->content_len; idx++) + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->content[idx]); + dbus_message_iter_close_container(iter, &data_iter); +} + +static void append_pattern_to_dbus(void *data, void *user_data) +{ + struct pattern *pattern = data; + DBusMessageIter *array_iter = user_data; + DBusMessageIter data_iter; + + dbus_message_iter_open_container(array_iter, DBUS_TYPE_STRUCT, + NULL, &data_iter); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->start_pos); + dbus_message_iter_append_basic(&data_iter, DBUS_TYPE_BYTE, + &pattern->ad_data_type); + append_pattern_content_to_dbus(&data_iter, pattern); + dbus_message_iter_close_container(array_iter, &data_iter); +} + +static gboolean get_patterns(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + DBusMessageIter array_iter; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "(yyay)", + &array_iter); + g_slist_foreach(adv_monitor->patterns, append_pattern_to_dbus, + &array_iter); + dbus_message_iter_close_container(iter, &array_iter); + return TRUE; +} + +static gboolean pattern_exists(const GDBusPropertyTable *property, void *data) +{ + struct adv_monitor *adv_monitor = data; + + return adv_monitor->patterns != NULL; +} + +static const GDBusPropertyTable adv_monitor_props[] = { + { "Type", "s", get_type }, + { "RSSIThresholdsAndTimers", "(nqnq)", get_rssi, NULL, rssi_exists }, + { "Patterns", "a(yyay)", get_patterns, NULL, pattern_exists }, + { } +}; + static void set_supported_list(GSList **list, DBusMessageIter *iter) { char *str; @@ -200,6 +358,7 @@ static void free_adv_monitor(void *user_data) { struct adv_monitor *adv_monitor = user_data; + g_free(adv_monitor->path); g_free(adv_monitor->type); g_free(adv_monitor->rssi); g_slist_free_full(adv_monitor->patterns, free_pattern); @@ -324,6 +483,16 @@ static GSList *parse_patterns(char *pattern_list[], int num) return patterns; } +static void remove_adv_monitor(void *data, void *user_data) +{ + struct adv_monitor *adv_monitor = data; + DBusConnection *conn = user_data; + + adv_mons = g_slist_remove(adv_mons, adv_monitor); + g_dbus_unregister_interface(conn, adv_monitor->path, + ADV_MONITOR_INTERFACE); +} + static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) { const struct adv_monitor *adv_monitor = a; @@ -359,6 +528,7 @@ static void print_adv_monitor(struct adv_monitor *adv_monitor) GSList *l; bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); + bt_shell_printf("\tpath: %s\n", adv_monitor->path); bt_shell_printf("\ttype: %s\n", adv_monitor->type); if (adv_monitor->rssi) { bt_shell_printf("\trssi:\n"); @@ -433,6 +603,16 @@ void adv_monitor_add_monitor(DBusConnection *conn, char *type, adv_monitor->type = g_strdup(type); adv_monitor->rssi = rssi; adv_monitor->patterns = patterns; + adv_monitor->path = g_strdup_printf("%s/%hhu", ADV_MONITOR_APP_PATH, + adv_mon_idx); + if (g_dbus_register_interface(conn, adv_monitor->path, + ADV_MONITOR_INTERFACE, + adv_monitor_methods, NULL, + adv_monitor_props, adv_monitor, + free_adv_monitor) == FALSE) { + bt_shell_printf("Failed to register advertisement monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } adv_mons = g_slist_append(adv_mons, adv_monitor); bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); @@ -467,7 +647,7 @@ void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) struct adv_monitor *adv_monitor; if (monitor_idx < 0) { - g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); + g_slist_foreach(adv_mons, remove_adv_monitor, conn); return; } @@ -478,8 +658,7 @@ void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) return; } - adv_mons = g_slist_remove(adv_mons, adv_monitor); - free_adv_monitor(adv_monitor); + remove_adv_monitor(adv_monitor, conn); bt_shell_printf("Monitor %d deleted\n", monitor_idx); } -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eIyLFRK8YV8R+gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 09:17:38 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id EKoKExK8YV9RTwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 09:17:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2753B40967; Wed, 16 Sep 2020 09:17:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726359AbgIPHRW (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 03:17:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726172AbgIPHRP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 03:17:15 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D7D5C061788 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 00:17:15 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id i196so1156129pgc.8 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 00:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=/616tPVzI5drLVga8v2z0esoWN1KtNkrALjdF3/yzcs=; b=mYcGRXqib4+CZhdWggECEZywwDwXvzm0oXykEa2nbGDBPpfVPAXq0qGO2OvgTtqbaP GT95PHs/sBRaPZDy9qEm1uxfpvW9OE9UeT+0CPO0fnL1c1erb7xsMPaUDib/pWn4m/Sh VQ9//0W9OeaW0COezLyWapGW3XKk3YJGDqVPCrBZ5K5SZNu06kg1VFKsbzvXOrf5d/nL LeVfu+zgobavmjem176REed1F95s4yEZuzZrefiGExABWUlmqWIGknBl+9Wrle4TSjAA +eiFRW7etGRFj+X7nHZJoEHSfmkJNypPmYdpqNj41NCFl1rZGNsdNEhUc3cBGcUTWwsZ QNPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/616tPVzI5drLVga8v2z0esoWN1KtNkrALjdF3/yzcs=; b=OADmBOPKv1wINQDO247yS4vwQ5FCeiCVa02SEBZSZc662QwmuSKSe8UdEZJj2evo3u qoDOajojU9hENfpPbZRIqyH8s7AuC8a2K4U2M8nbkN3oGWToee6iI7rnmJJpygcC4OpG +EbadDWc6gd7MoqFRzjVAFNZeG5hv7GIxqvLqPx1WKvZYFEphzJNFl0fLWcWPm7o6nxO Q2WV8aTdXYeGpUEOvw0Iw5wqikKGSp+vuPEJ8tRJDUEKFgckas4uIdhYNPJkQBEEv1au taVj6NnIZd0Of6qWW/TAJKk7XDfXQ5kRvSf0y4X6WKAvMBIblQN11IjEsQqpDPYcsR5D NYPw== X-Gm-Message-State: AOAM531gVH99F49jL0f4C7s1IJubrnQevfnyW6lVXGWJV7TF2qNUMmlC 6Qugh+4MmHbzCklYO3LWw8Z2m+tdRW7HAaMSM6rxp3Gl+4YZpXk5R0QuSUSJuy3TrjV2e9WxO5r Zgk/hymxhZfgdcs0wElHA0y0DBJ2lkqiVaxfCYM8pKOwutCa8u0xZBPWcv4BmOru0TUms3UHs0t OAzponEaAVeSo= X-Google-Smtp-Source: ABdhPJw/o1x3aNHEkNFEfrNyiZeKO3ygZO3KZYnijBB8bR+9RY77lZseYqzaK4wYiwoK2oJjOmdWotWyslAXHj1Ubg== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:902:c14b:b029:d1:ec9a:aaae with SMTP id 11-20020a170902c14bb02900d1ec9aaaaemr2115689plj.62.1600240633333; Wed, 16 Sep 2020 00:17:13 -0700 (PDT) Date: Wed, 16 Sep 2020 15:16:52 +0800 In-Reply-To: <20200916151617.BlueZ.v5.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200916151617.BlueZ.v5.4.Ieffbe3452565ace2af46a63501c767c8798fd88c@changeid> Mime-Version: 1.0 References: <20200916151617.BlueZ.v5.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v5 4/4] core: Add AdvertisementMonitor to bluetooth.conf From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, mmandlik@chromium.org, mcchou@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.10 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2753B40967 X-Rspamd-UID: decfb7 AdvertisementMonitor must be included in bluetooth.conf in order to be able to call Release Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v4) Changes in v4: - Remove PRE-UPSTREAM in commit title Reviewed-by: Miao-chen Chou <mcchou@chromium.org> src/bluetooth.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bluetooth.conf b/src/bluetooth.conf index 8a1e25801..b6c614908 100644 --- a/src/bluetooth.conf +++ b/src/bluetooth.conf @@ -10,6 +10,7 @@ <policy user="root"> <allow own="org.bluez"/> <allow send_destination="org.bluez"/> + <allow send_interface="org.bluez.AdvertisementMonitor1"/> <allow send_interface="org.bluez.Agent1"/> <allow send_interface="org.bluez.MediaEndpoint1"/> <allow send_interface="org.bluez.MediaPlayer1"/> -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gAxhDagfYV+XrgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 22:10:16 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qNzoCqgfYV+oSwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 22:10:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EEEEF40017; Tue, 15 Sep 2020 22:10:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727953AbgIOUJH (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 16:09:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbgIOUIk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 16:08:40 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 634D0C061788 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 13:08:37 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id t3so1084551ook.8 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 13:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=qzH3qyKDcNmD9f8uTEY/0v4yXNJbPF9Xm/l/XfyVneQ=; b=RI/+8QzBmfUpNiNIen6zdNLiK5reeOmNzN0CozZ0zwiY3x+N1SpOquA1jpg/OfkhG5 NMtZnDTva2eZyzETByNlW4/NoezB3OgRmXp8Po5rhk3lDKF9Fx2vpNl2KqfcnpuSbQV/ m3EGB9MGJqkbhpR5o45WKdHB/ivt+iLbmAUxqP00uhdPRNejbkrDTWlrHGAxEvEwLaq+ lXMszQ/UPyrKt1RomnlVz8JC2H46cUx3RRMJjPq59yfGAzDjCRVMBnqd2Lh7UeTSaGr7 PFsfZ9ULxJ7vQ0TNAuTT7xoSr02LGA9T3LG0tUnRaC1n/6dRPus8bS1P3QXi0Xpow9q9 oyfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=qzH3qyKDcNmD9f8uTEY/0v4yXNJbPF9Xm/l/XfyVneQ=; b=ihmR4RankU1snAHDJsNNaOCfi6BGtmIEB7XFJhk6Z45+LIlGbsAx+2P5PKZM6Akxqu c90fzbrwftyR8RkJRIp+vJiMC8HorHesMo7Y+meQQmFXHUQVx2fvSSiHT2wgf7m9prME TmvZyaFxlQLBxuQsiuPY19P7Q+pUaoEZxi7jR2a/AYUE3WWZ1a6ZTTDBbm4Fwb3LVR+Q hTSfMtuLctWKRlLjvDdRT14e+g1aVeyRjstG8oQZiz0r0SAzQvz+5v2L/fUt4iKtfQDq 7/PGJmrojt37CiF1ySy+/fiDQnjY/42hMq2rGID6ie8BnKafAv4PDHSktbi1DwK67QfU a6hg== X-Gm-Message-State: AOAM530VknUgJ/kaXxMeKWGuUihLZWYZn1Nrjq6pgtod9kG+Y8AkRG9K pucJSO0wPiQyaxvwCglzJGBRmIIyUOLAKzHJyMY= X-Google-Smtp-Source: ABdhPJwR9GzbsfyNWilVE+ca/ygPXiIfpeQPfgTZeLA41ZFjLrO8KPEJLggc7inMSNl+ACRCpaP/i9MCWVTqOiFRDXc= X-Received: by 2002:a4a:bf12:: with SMTP id r18mr11393911oop.9.1600200516678; Tue, 15 Sep 2020 13:08:36 -0700 (PDT) MIME-Version: 1.0 References: <20200914112137.BlueZ.v4.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> In-Reply-To: <20200914112137.BlueZ.v4.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 15 Sep 2020 13:08:25 -0700 Message-ID: <CABBYNZLf64nFjJo6PqoVViDbkfmOqpiQcRjPrKrgtqgP-Y42Fw@mail.gmail.com> Subject: Re: [BlueZ PATCH v4 1/4] client: Implement basic interface of ADV monitor in bluetoothctl To: Howard Chung <howardchung@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org>, Luiz Augusto Von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.15 / 15.00 / 15.00 X-Rspamd-Queue-Id: EEEEF40017 X-Rspamd-UID: 2732e2 Hi Howard, On Sun, Sep 13, 2020 at 8:26 PM Howard Chung <howardchung@google.com> wrote= : > > This patch implements some basic functions for ADV monitor in > bluetoothctl > > [bluetooth]# show > ... > Advertisement Monitor Features: > SupportedMonitorTypes: or_patterns > > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > --- > > Changes in v4: > - Remove PRE-UPSTREAM in commit title > > Changes in v3: > - Rename advertisement_monitor to adv_monitor > > Changes in v2: > - Update the add-pattern usage > - Fix styling issue in patch 1 > - Fix storage class declaration issue > > Makefile.tools | 2 + > client/adv_monitor.c | 161 +++++++++++++++++++++++++++++++++++++++++++ > client/adv_monitor.h | 23 +++++++ > client/main.c | 28 ++++++++ > 4 files changed, 214 insertions(+) > create mode 100644 client/adv_monitor.c > create mode 100644 client/adv_monitor.h > > diff --git a/Makefile.tools b/Makefile.tools > index 9b9236609..ed0fbf8a3 100644 > --- a/Makefile.tools > +++ b/Makefile.tools > @@ -7,6 +7,8 @@ client_bluetoothctl_SOURCES =3D client/main.c \ > client/agent.h client/agent.c \ > client/advertising.h \ > client/advertising.c \ > + client/adv_monitor.h \ > + client/adv_monitor.c \ > client/gatt.h client/gatt.c > client_bluetoothctl_LDADD =3D gdbus/libgdbus-internal.la src/libshared-g= lib.la \ > $(GLIB_LIBS) $(DBUS_LIBS) -lreadline > diff --git a/client/adv_monitor.c b/client/adv_monitor.c > new file mode 100644 > index 000000000..2a62389d9 > --- /dev/null > +++ b/client/adv_monitor.c > @@ -0,0 +1,161 @@ > +/* > + * > + * BlueZ - Bluetooth protocol stack for Linux > + * > + * Copyright (C) 2020 Google LLC > + * > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + */ > + > +#ifdef HAVE_CONFIG_H > +#include <config.h> > +#endif > + > +#define _GNU_SOURCE > +#include <stdio.h> > +#include <stdlib.h> > +#include <stdint.h> > +#include <stdbool.h> > +#include <string.h> > + > +#include "gdbus/gdbus.h" > +#include "src/shared/util.h" > +#include "src/shared/shell.h" > +#include "adv_monitor.h" > + > +#define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" > +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" > + > +static struct adv_monitor_manager { > + GSList *supported_types; > + GSList *supported_features; > + GDBusProxy *proxy; > + gboolean app_registered; > +} manager =3D { NULL, NULL, NULL, FALSE }; > + > +static void set_supported_list(GSList **list, DBusMessageIter *iter) > +{ > + char *str; > + DBusMessageIter subiter; > + > + dbus_message_iter_recurse(iter, &subiter); > + while (dbus_message_iter_get_arg_type(&subiter) =3D=3D > + DBUS_TYPE_STRING) { > + dbus_message_iter_get_basic(&subiter, &str); > + *list =3D g_slist_append(*list, str); > + dbus_message_iter_next(&subiter); > + } > +} > + > +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy) > +{ > + DBusMessageIter iter; > + > + if (manager.proxy !=3D NULL || manager.supported_types !=3D NULL = || > + manager.supported_features !=3D N= ULL) { > + bt_shell_printf("advertisement monitor manager already " > + "added\n"); > + return; > + } > + > + manager.proxy =3D proxy; > + > + if (g_dbus_proxy_get_property(proxy, "SupportedMonitorTypes", &it= er)) > + set_supported_list(&(manager.supported_types), &iter); > + > + if (g_dbus_proxy_get_property(proxy, "SupportedFeatures", &iter)) > + set_supported_list(&(manager.supported_features), &iter); > + > +} > + > +void adv_monitor_remove_manager(DBusConnection *conn) > +{ > + if (manager.supported_types !=3D NULL) > + g_slist_free(g_steal_pointer(&(manager.supported_types)))= ; > + if (manager.supported_features !=3D NULL) > + g_slist_free(g_steal_pointer(&(manager.supported_features= ))); > + manager.proxy =3D NULL; > + manager.app_registered =3D FALSE; > +} > + > +static void register_setup(DBusMessageIter *iter, void *user_data) > +{ > + const char *path =3D ADV_MONITOR_APP_PATH; > + > + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path= ); > +} > + > +static void register_reply(DBusMessage *message, void *user_data) > +{ > + DBusConnection *conn =3D user_data; > + DBusError error; > + > + dbus_error_init(&error); > + > + if (dbus_set_error_from_message(&error, message) =3D=3D FALSE) { > + bt_shell_printf("AdvertisementMonitor path registered\n")= ; Missing bt_shell_noninteractive_quit(EXIT_SUCCESS); > + } else { > + bt_shell_printf("Failed to register path: %s\n", error.na= me); > + dbus_error_free(&error); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } Test dbus_set_error_from_message(&error, message) alone, I actually would recommend not using =3D=3D TRUE/FALSE on new code. So I would have done without the use of else clause: if (!dbus_set_error_from_message) ... return bt_shell_noninteractive_quit(EXIT_FAILURE); bt_shell_noninteractive_quit(EXIT_SUCCESS); > +} > + > +static void unregister_setup(DBusMessageIter *iter, void *user_data) > +{ > + const char *path =3D ADV_MONITOR_APP_PATH; > + > + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path= ); > +} > + > +static void unregister_reply(DBusMessage *message, void *user_data) > +{ > + DBusConnection *conn =3D user_data; > + DBusError error; > + > + dbus_error_init(&error); > + > + if (dbus_set_error_from_message(&error, message) =3D=3D FALSE) { > + bt_shell_printf("AdvertisementMonitor path unregistered\n= "); > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > + } > + > + bt_shell_printf("Failed to unregister Advertisement Monitor:" > + " %s\n", error.name); > + dbus_error_free(&error); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > +} > + > +void adv_monitor_register_app(DBusConnection *conn) > +{ > + if (manager.supported_types =3D=3D NULL || manager.app_registered= =3D=3D TRUE || > + g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor"= , > + register_setup, register_reply, > + NULL, NULL) =3D=3D FALSE) { > + bt_shell_printf("Failed to register Advertisement Monitor= \n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + manager.app_registered =3D TRUE; > +} > + > +void adv_monitor_unregister_app(DBusConnection *conn) > +{ > + if (manager.app_registered =3D=3D FALSE || > + g_dbus_proxy_method_call(manager.proxy, "UnregisterMonito= r", > + unregister_setup, unregister_repl= y, > + NULL, NULL) =3D=3D FALSE) { > + bt_shell_printf("Failed to unregister Advertisement Monit= or\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + manager.app_registered =3D FALSE; > +} > diff --git a/client/adv_monitor.h b/client/adv_monitor.h > new file mode 100644 > index 000000000..77b0b62c6 > --- /dev/null > +++ b/client/adv_monitor.h > @@ -0,0 +1,23 @@ > +/* > + * > + * BlueZ - Bluetooth protocol stack for Linux > + * > + * Copyright (C) 2020 Google LLC > + * > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + */ > + > +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); > +void adv_monitor_remove_manager(DBusConnection *conn); > +void adv_monitor_register_app(DBusConnection *conn); > +void adv_monitor_unregister_app(DBusConnection *conn); > diff --git a/client/main.c b/client/main.c > index da877b546..75f8bc462 100644 > --- a/client/main.c > +++ b/client/main.c > @@ -41,6 +41,7 @@ > #include "agent.h" > #include "gatt.h" > #include "advertising.h" > +#include "adv_monitor.h" > > /* String display constants */ > #define COLORED_NEW COLOR_GREEN "NEW" COLOR_OFF > @@ -58,6 +59,7 @@ static char *auto_register_agent =3D NULL; > struct adapter { > GDBusProxy *proxy; > GDBusProxy *ad_proxy; > + GDBusProxy *adv_monitor_proxy; > GList *devices; > }; > > @@ -528,6 +530,19 @@ static void ad_manager_added(GDBusProxy *proxy) > adapter->ad_proxy =3D proxy; > } > > +static void admon_manager_added(GDBusProxy *proxy) > +{ > + struct adapter *adapter; > + > + adapter =3D find_ctrl(ctrl_list, g_dbus_proxy_get_path(proxy)); > + if (!adapter) > + adapter =3D adapter_new(proxy); > + > + adapter->adv_monitor_proxy =3D proxy; > + adv_monitor_add_manager(dbus_conn, proxy); > + adv_monitor_register_app(dbus_conn); > +} > + > static void proxy_added(GDBusProxy *proxy, void *user_data) > { > const char *interface; > @@ -560,6 +575,9 @@ static void proxy_added(GDBusProxy *proxy, void *user= _data) > ad_manager_added(proxy); > } else if (!strcmp(interface, "org.bluez.Battery1")) { > battery_added(proxy); > + } else if (!strcmp(interface, > + "org.bluez.AdvertisementMonitorManager1")= ) { > + admon_manager_added(proxy); > } > } > > @@ -653,6 +671,9 @@ static void proxy_removed(GDBusProxy *proxy, void *us= er_data) > ad_unregister(dbus_conn, NULL); > } else if (!strcmp(interface, "org.bluez.Battery1")) { > battery_removed(proxy); > + } else if (!strcmp(interface, > + "org.bluez.AdvertisementMonitorManager1")) { > + adv_monitor_remove_manager(dbus_conn); > } > } > > @@ -935,6 +956,13 @@ static void cmd_show(int argc, char *argv[]) > print_property(adapter->ad_proxy, "SupportedSecondaryChan= nels"); > } > > + if (adapter->adv_monitor_proxy) { > + bt_shell_printf("Advertisement Monitor Features:\n"); > + print_property(adapter->adv_monitor_proxy, > + "SupportedMonitorTypes"); > + print_property(adapter->adv_monitor_proxy, "SupportedFeat= ures"); > + } > + > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > } > > -- > 2.28.0.618.gf4bc123cb7-goog Doesn't compile: make --no-print-directory all-am CC client/adv_monitor.o client/adv_monitor.c: In function =E2=80=98register_reply=E2=80=99: client/adv_monitor.c:283:18: error: unused variable =E2=80=98conn=E2=80=99 [-Werror=3Dunused-variable] 283 | DBusConnection *conn =3D user_data; | ^~~~ client/adv_monitor.c: In function =E2=80=98unregister_reply=E2=80=99: client/adv_monitor.c:306:18: error: unused variable =E2=80=98conn=E2=80=99 [-Werror=3Dunused-variable] 306 | DBusConnection *conn =3D user_data; | ^~~~ cc1: all warnings being treated as errors --=20 Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +PWXOAkgYV+XrgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 22:11:53 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id YEaKMwkgYV828wEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 22:11:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 056EDA0B12; Tue, 15 Sep 2020 22:11:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727814AbgIOULn (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 16:11:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbgIOULN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 16:11:13 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DBBFC06174A for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 13:11:13 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id i17so5320337oig.10 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 13:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=b3Pr8mG2uVT082OW/aQRisjFqmTOS1DY/g5gNhBY0sA=; b=nDEw96g8uANpXzUVlR2RqkVzrY3WWzXd6qPlK+EZXPGSADETAZquMHOG5DvhX7PIA2 xklaR5/jFp7H/R9rutPG0mrPmEE+DONkz9ou524H9FNR7peEDPvegKlm7l1Y6Rf4pVmm O22BGGOb+nctKOEedi4C6Wvnsx+jXCVo1koVeaY9lTDBmsDhw20VeY1cc5H6uioFubvw EPvRUGoer4r/L5U+CrjONavG9Seq2M5tZ5yK/oUmqNbT++zY7mIKlc0ZAwqEaSLhO7on gFG1OrrAr+Tta2gJMQdekQRc1JSQRUWiM1KSqxObvwMAUQWDXCweFhioFuEpKJjwJs4W bhDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=b3Pr8mG2uVT082OW/aQRisjFqmTOS1DY/g5gNhBY0sA=; b=cew55pZv0oSQbMbq9shKi14kqOeyjz3vqTXwW7EYF+8CdHurIoDRfe9PveN0KJWjxX lazHHs7pQD3jSdHXqueDq9bG/QGNs/fpooDX8FeRSuTpILZa9jHPALWVTG5OaURqnrIr VPU6E3pT9slJXiVklUzyZqarKZEKztkCy1cxOrol1omDZHXFPIMDTv4Xuv2Ius9Ey0iX pCcTBUm4NaZ6T5FcFl+0UT187K0/nwKU6H2F1R48OyTdsSi4sGBmDtKv79X1qd/30srJ A48XLdCSXCpZE3eVHeyjFMr5bsHrRc97uvD1mx21ymhxRu2trM38Wsm0MjoxChLINPc1 vSrw== X-Gm-Message-State: AOAM533j/5vNuEXz1mKwFJrsWUSssfp5Ao1yc0yB6NYVU9BPEoeDDTUB KONMY3UV1W7IQbf+valiVYrNsUZZGXS0ohPY6y8Zdys1 X-Google-Smtp-Source: ABdhPJykipMYcPksSGSQ8fteqLy6/1uJTUXLu96W0tGxPY/5NSbM+DkL0tNE8Bc6bN8uRQmwGL4XvBJrPYuTDR+hKrk= X-Received: by 2002:aca:3e08:: with SMTP id l8mr657031oia.152.1600200671360; Tue, 15 Sep 2020 13:11:11 -0700 (PDT) MIME-Version: 1.0 References: <20200915000457.22988-1-tedd.an@linux.intel.com> <4586934.31r3eYUQgx@ix> <CABBYNZLc+yNVH7pA8J-z_yhpF59jC_JenEEFqRtzPMUXB-=y5Q@mail.gmail.com> <e36c87b8cf8f6af3f63eaf5dd2616336e10d0874.camel@intel.com> In-Reply-To: <e36c87b8cf8f6af3f63eaf5dd2616336e10d0874.camel@intel.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 15 Sep 2020 13:10:59 -0700 Message-ID: <CABBYNZJLyVGZw+1jwfGnGopFMvmFks6Je8sfE0ixTcgw2nKrRQ@mail.gmail.com> Subject: Re: [BlueZ v3 00/17] Add SPDX License Identifier To: "An, Tedd" <tedd.an@intel.com> Cc: "szymon.janc@codecoup.pl" <szymon.janc@codecoup.pl>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.55 / 15.00 / 15.00 X-Rspamd-Queue-Id: 056EDA0B12 X-Rspamd-UID: 8b40d8 Hi Tedd, On Tue, Sep 15, 2020 at 1:05 PM An, Tedd <tedd.an@intel.com> wrote: > > Hi Liuz, > > On Tue, 2020-09-15 at 09:34 -0700, Luiz Augusto von Dentz wrote: > > Hi Szymon, > > > > On Tue, Sep 15, 2020 at 12:24 AM Szymon Janc <szymon.janc@codecoup.pl> wrote: > > > Hi, > > > > > > On Tuesday, 15 September 2020 02:04:40 CEST tedd.an@linux.intel.com wrote: > > > > From: Tedd Ho-Jeong An <tedd.an@intel.com> > > > > > > > > This patch series adds SPDX License Identifier to the source/heade files > > > > based on the existing license header and removes the license text. > > > > > > > > The SDPX License Identifier is added in form of a comment based on file > > > > type with the same rule from the Linxu kernel source, and added to the > > > > first line of the file. > > > > > > > > C source: // SPDX-License-Identifer: <License> > > > > > > Why C++ style comments in C source? > > > > > > > C header: /* SPDX-License-Identifer: <License> */ > > > > > > > > For SPDX-License Identifier, it used the identifer from the SPDX License > > > > list page(https://spdx.org/licenses). > > > > > > INAL but SPDX identifier itself is insufficied for license compliance. > > > > > > If we really want to (I don't have strong opinion about this) remove license > > > headers in favour of only having SPDX then we need files with licenses text > > > etc to be part of distribution. Pretty much the same what kernel folks did. > > > > We should probably create a LICENSES directory with the full license > > text, but for the source files the SPDX identifier should be enough, > > something like: > > > > LICENSES/ > > ./preferred/{GPL-2.0, LGPL-2.1, BSD-2-Clause, MIT} > > ./dual/Apache-2.0 > > > > The kernel don't seem to be using or-later variant of GPL perhaps to > > avoid (L)GPL 3.0 clauses. > > I will add them. > > > > > > > For the summary, currently BlueZ sources have following licenses: > > > > > > > > ------------------------------------------- > > > > License File Count > > > > ------------------------------------------- > > > > GPL-2.0-or-later : 393 > > > > LGPL-2.1-or-later : 273 > > > > BSD-2-Clause : 3 > > > > GPL-2.0-only : 5 > > > > MIT : 2 > > > > Apache-2.0 : 80 > > > > N/A : 1325 > > > > > > > > Note that N/A includes the following files/folders > > > > - .git/ > > > > - doc/ > > > > - Build related files (Makefile, etc) > > > > In Zephyr we do have license for build related files, not sure what > > license we should use though, perhaps LGPL is better for these. > > Does GPL makes more sense? As far as I understand, LGPL is more for library, and > BlueZ Makefile combined the rules for binary and library. Yep, I actually meant GPL here and LGPL for python scripts so they can be used elsewhere. > > > > > > - Configuration files > > > > - Test scripts (python, etc) > > > > The tests scripts we might want to have license as well, LGPL might be > > a better here as well. > > > > > > Tedd Ho-Jeong An (17): > > > > android: Add SPDX License Identifier > > > > attrib: Add SPDX License Identifier > > > > btio: Add SPDX License Identifier > > > > client: Add SPDX License Identifier > > > > emulator: Add SPDX License Identifier > > > > gdbus: Add SPDX License Identifier > > > > gobex: Add SPDX License Identifier > > > > lib: Add SPDX License Identifier > > > > mesh: Add SPDX License Identifier > > > > monitor: Add SPDX License Identifier > > > > obexd: Add SPDX License Identifier > > > > peripheral: Add SPDX License Identifier > > > > plugins: Add SPDX License Identifier > > > > profiles: Add SPDX License Identifier > > > > unit: Add SPDX License Identifier > > > > src: Add SPDX License Identifier > > > > tools: Add SPDX License Identifier > > > > > > > > android/a2dp-sink.c | 15 +-------------- > > > > android/a2dp-sink.h | 15 +-------------- > > > > android/a2dp.c | 15 +-------------- > > > > android/a2dp.h | 15 +-------------- > > > > android/audio-msg.h | 15 +-------------- > > > > android/audio_utils/resampler.c | 12 +----------- > > > > android/audio_utils/resampler.h | 12 +----------- > > > > android/avctp.c | 15 +-------------- > > > > android/avctp.h | 15 +-------------- > > > > android/avdtp.c | 15 +-------------- > > > > android/avdtp.h | 15 +-------------- > > > > android/avdtptest.c | 15 +-------------- > > > > android/avrcp-lib.c | 15 +-------------- > > > > android/avrcp-lib.h | 15 +-------------- > > > > android/avrcp.c | 15 +-------------- > > > > android/avrcp.h | 15 +-------------- > > > > android/bluetooth.c | 15 +-------------- > > > > android/bluetooth.h | 15 +-------------- > > > > android/bluetoothd-snoop.c | 15 +-------------- > > > > android/bluetoothd-wrapper.c | 13 +------------ > > > > android/client/haltest.c | 13 +------------ > > > > android/client/history.c | 13 +------------ > > > > android/client/history.h | 13 +------------ > > > > android/client/if-audio.c | 13 +------------ > > > > android/client/if-av-sink.c | 13 +------------ > > > > android/client/if-av.c | 13 +------------ > > > > android/client/if-bt.c | 13 +------------ > > > > android/client/if-gatt.c | 13 +------------ > > > > android/client/if-hf-client.c | 13 +------------ > > > > android/client/if-hf.c | 13 +------------ > > > > android/client/if-hh.c | 13 +------------ > > > > android/client/if-hl.c | 13 +------------ > > > > android/client/if-main.h | 13 +------------ > > > > android/client/if-mce.c | 13 +------------ > > > > android/client/if-pan.c | 13 +------------ > > > > android/client/if-rc-ctrl.c | 13 +------------ > > > > android/client/if-rc.c | 13 +------------ > > > > android/client/if-sco.c | 13 +------------ > > > > android/client/if-sock.c | 13 +------------ > > > > android/client/pollhandler.c | 13 +------------ > > > > android/client/pollhandler.h | 13 +------------ > > > > android/client/tabcompletion.c | 13 +------------ > > > > android/client/terminal.c | 13 +------------ > > > > android/client/terminal.h | 13 +------------ > > > > android/compat/readline/history.h | 15 +-------------- > > > > android/compat/readline/readline.h | 15 +-------------- > > > > android/compat/wordexp.h | 15 +-------------- > > > > android/cutils/properties.h | 15 +-------------- > > > > android/gatt.c | 15 +-------------- > > > > android/gatt.h | 15 +-------------- > > > > android/hal-a2dp-sink.c | 13 +------------ > > > > android/hal-a2dp.c | 13 +------------ > > > > android/hal-audio-aptx.c | 13 +------------ > > > > android/hal-audio-sbc.c | 13 +------------ > > > > android/hal-audio.c | 13 +------------ > > > > android/hal-audio.h | 13 +------------ > > > > android/hal-avrcp-ctrl.c | 13 +------------ > > > > android/hal-avrcp.c | 13 +------------ > > > > android/hal-bluetooth.c | 13 +------------ > > > > android/hal-gatt.c | 13 +------------ > > > > android/hal-handsfree-client.c | 13 +------------ > > > > android/hal-handsfree.c | 13 +------------ > > > > android/hal-health.c | 13 +------------ > > > > android/hal-hidhost.c | 13 +------------ > > > > android/hal-ipc.c | 13 +------------ > > > > android/hal-ipc.h | 13 +------------ > > > > android/hal-log.h | 13 +------------ > > > > android/hal-map-client.c | 13 +------------ > > > > android/hal-msg.h | 15 +-------------- > > > > android/hal-pan.c | 13 +------------ > > > > android/hal-sco.c | 13 +------------ > > > > android/hal-socket.c | 13 +------------ > > > > android/hal-utils.c | 13 +------------ > > > > android/hal-utils.h | 13 +------------ > > > > android/hal.h | 13 +------------ > > > > android/handsfree-client.c | 15 +-------------- > > > > android/handsfree-client.h | 15 +-------------- > > > > android/handsfree.c | 15 +-------------- > > > > android/handsfree.h | 15 +-------------- > > > > android/hardware/audio.h | 12 +----------- > > > > android/hardware/audio_effect.h | 12 +----------- > > > > android/hardware/bluetooth.h | 12 +----------- > > > > android/hardware/bt_av.h | 12 +----------- > > > > android/hardware/bt_gatt.h | 12 +----------- > > > > android/hardware/bt_gatt_client.h | 12 +----------- > > > > android/hardware/bt_gatt_server.h | 12 +----------- > > > > android/hardware/bt_gatt_types.h | 12 +----------- > > > > android/hardware/bt_hf.h | 12 +----------- > > > > android/hardware/bt_hf_client.h | 12 +----------- > > > > android/hardware/bt_hh.h | 12 +----------- > > > > android/hardware/bt_hl.h | 12 +----------- > > > > android/hardware/bt_mce.h | 12 +----------- > > > > android/hardware/bt_pan.h | 12 +----------- > > > > android/hardware/bt_rc.h | 12 +----------- > > > > android/hardware/bt_sock.h | 12 +----------- > > > > android/hardware/hardware.c | 12 +----------- > > > > android/hardware/hardware.h | 12 +----------- > > > > android/health.c | 15 +-------------- > > > > android/health.h | 15 +-------------- > > > > android/hidhost.c | 15 +-------------- > > > > android/hidhost.h | 15 +-------------- > > > > android/ipc-common.h | 15 +-------------- > > > > android/ipc-tester.c | 15 +-------------- > > > > android/ipc.c | 15 +-------------- > > > > android/ipc.h | 15 +-------------- > > > > android/log.c | 15 +-------------- > > > > android/main.c | 15 +-------------- > > > > android/map-client.c | 15 +-------------- > > > > android/map-client.h | 15 +-------------- > > > > android/pan.c | 15 +-------------- > > > > android/pan.h | 15 +-------------- > > > > android/sco-msg.h | 15 +-------------- > > > > android/sco.c | 15 +-------------- > > > > android/sco.h | 15 +-------------- > > > > android/socket.c | 15 +-------------- > > > > android/socket.h | 15 +-------------- > > > > android/system-emulator.c | 15 +-------------- > > > > android/system/audio.h | 12 +----------- > > > > android/test-ipc.c | 15 +-------------- > > > > android/tester-a2dp.c | 13 +------------ > > > > android/tester-avrcp.c | 13 +------------ > > > > android/tester-bluetooth.c | 13 +------------ > > > > android/tester-gatt.c | 13 +------------ > > > > android/tester-hdp.c | 13 +------------ > > > > android/tester-hidhost.c | 13 +------------ > > > > android/tester-main.c | 13 +------------ > > > > android/tester-main.h | 15 +-------------- > > > > android/tester-map-client.c | 13 +------------ > > > > android/tester-pan.c | 13 +------------ > > > > android/tester-socket.c | 13 +------------ > > > > android/utils.h | 15 +-------------- > > > > attrib/att-database.h | 15 +-------------- > > > > attrib/att.c | 15 +-------------- > > > > attrib/att.h | 15 +-------------- > > > > attrib/gatt-service.c | 15 +-------------- > > > > attrib/gatt-service.h | 15 +-------------- > > > > attrib/gatt.c | 15 +-------------- > > > > attrib/gatt.h | 15 +-------------- > > > > attrib/gattrib.c | 15 +-------------- > > > > attrib/gattrib.h | 15 +-------------- > > > > attrib/gatttool.c | 15 +-------------- > > > > attrib/gatttool.h | 15 +-------------- > > > > attrib/interactive.c | 15 +-------------- > > > > attrib/utils.c | 15 +-------------- > > > > btio/btio.c | 15 +-------------- > > > > btio/btio.h | 15 +-------------- > > > > client/advertising.c | 15 +-------------- > > > > client/advertising.h | 15 +-------------- > > > > client/agent.c | 15 +-------------- > > > > client/agent.h | 15 +-------------- > > > > client/display.c | 15 +-------------- > > > > client/display.h | 15 +-------------- > > > > client/gatt.c | 15 +-------------- > > > > client/gatt.h | 15 +-------------- > > > > client/main.c | 15 +-------------- > > > > emulator/amp.c | 15 +-------------- > > > > emulator/amp.h | 15 +-------------- > > > > emulator/b1ee.c | 15 +-------------- > > > > emulator/btdev.c | 15 +-------------- > > > > emulator/btdev.h | 15 +-------------- > > > > emulator/bthost.c | 15 +-------------- > > > > emulator/bthost.h | 15 +-------------- > > > > emulator/hciemu.c | 15 +-------------- > > > > emulator/hciemu.h | 15 +-------------- > > > > emulator/hfp.c | 15 +-------------- > > > > emulator/le.c | 15 +-------------- > > > > emulator/le.h | 15 +-------------- > > > > emulator/main.c | 15 +-------------- > > > > emulator/phy.c | 15 +-------------- > > > > emulator/phy.h | 15 +-------------- > > > > emulator/serial.c | 15 +-------------- > > > > emulator/serial.h | 15 +-------------- > > > > emulator/server.c | 15 +-------------- > > > > emulator/server.h | 15 +-------------- > > > > emulator/smp.c | 15 +-------------- > > > > emulator/vhci.c | 15 +-------------- > > > > emulator/vhci.h | 15 +-------------- > > > > gdbus/client.c | 15 +-------------- > > > > gdbus/gdbus.h | 15 +-------------- > > > > gdbus/mainloop.c | 15 +-------------- > > > > gdbus/object.c | 15 +-------------- > > > > gdbus/polkit.c | 15 +-------------- > > > > gdbus/watch.c | 15 +-------------- > > > > gobex/gobex-apparam.c | 15 +-------------- > > > > gobex/gobex-apparam.h | 15 +-------------- > > > > gobex/gobex-debug.h | 15 +-------------- > > > > gobex/gobex-defs.c | 15 +-------------- > > > > gobex/gobex-defs.h | 15 +-------------- > > > > gobex/gobex-header.c | 15 +-------------- > > > > gobex/gobex-header.h | 15 +-------------- > > > > gobex/gobex-packet.c | 15 +-------------- > > > > gobex/gobex-packet.h | 15 +-------------- > > > > gobex/gobex-transfer.c | 15 +-------------- > > > > gobex/gobex.c | 15 +-------------- > > > > gobex/gobex.h | 15 +-------------- > > > > lib/a2mp.h | 15 +-------------- > > > > lib/amp.h | 10 +--------- > > > > lib/bluetooth.c | 15 +-------------- > > > > lib/bluetooth.h | 15 +-------------- > > > > lib/bnep.h | 15 +-------------- > > > > lib/cmtp.h | 15 +-------------- > > > > lib/hci.c | 15 +-------------- > > > > lib/hci.h | 15 +-------------- > > > > lib/hci_lib.h | 15 +-------------- > > > > lib/hidp.h | 15 +-------------- > > > > lib/l2cap.h | 15 +-------------- > > > > lib/mgmt.h | 15 +-------------- > > > > lib/rfcomm.h | 15 +-------------- > > > > lib/sco.h | 15 +-------------- > > > > lib/sdp.c | 15 +-------------- > > > > lib/sdp.h | 15 +-------------- > > > > lib/sdp_lib.h | 15 +-------------- > > > > lib/uuid.c | 15 +-------------- > > > > lib/uuid.h | 15 +-------------- > > > > mesh/agent.c | 11 +---------- > > > > mesh/agent.h | 11 +---------- > > > > mesh/appkey.c | 11 +---------- > > > > mesh/appkey.h | 11 +---------- > > > > mesh/cfgmod-server.c | 11 +---------- > > > > mesh/cfgmod.h | 11 +---------- > > > > mesh/crypto.c | 11 +---------- > > > > mesh/crypto.h | 11 +---------- > > > > mesh/dbus.c | 11 +---------- > > > > mesh/dbus.h | 11 +---------- > > > > mesh/error.h | 11 +---------- > > > > mesh/friend.c | 11 +---------- > > > > mesh/friend.h | 11 +---------- > > > > mesh/keyring.c | 11 +---------- > > > > mesh/keyring.h | 11 +---------- > > > > mesh/main.c | 11 +---------- > > > > mesh/manager.c | 11 +---------- > > > > mesh/manager.h | 11 +---------- > > > > mesh/mesh-config-json.c | 11 +---------- > > > > mesh/mesh-config.h | 11 +---------- > > > > mesh/mesh-defs.h | 12 +----------- > > > > mesh/mesh-io-api.h | 11 +---------- > > > > mesh/mesh-io-generic.c | 11 +---------- > > > > mesh/mesh-io-generic.h | 11 +---------- > > > > mesh/mesh-io.c | 11 +---------- > > > > mesh/mesh-io.h | 11 +---------- > > > > mesh/mesh-mgmt.c | 11 +---------- > > > > mesh/mesh-mgmt.h | 11 +---------- > > > > mesh/mesh.c | 11 +---------- > > > > mesh/mesh.h | 11 +---------- > > > > mesh/model.c | 11 +---------- > > > > mesh/model.h | 11 +---------- > > > > mesh/net-keys.c | 11 +---------- > > > > mesh/net-keys.h | 11 +---------- > > > > mesh/net.c | 11 +---------- > > > > mesh/net.h | 11 +---------- > > > > mesh/node.c | 11 +---------- > > > > mesh/node.h | 11 +---------- > > > > mesh/pb-adv.c | 11 +---------- > > > > mesh/pb-adv.h | 11 +---------- > > > > mesh/prov-acceptor.c | 11 +---------- > > > > mesh/prov-initiator.c | 11 +---------- > > > > mesh/prov.h | 11 +---------- > > > > mesh/provision.h | 11 +---------- > > > > mesh/rpl.c | 11 +---------- > > > > mesh/rpl.h | 11 +---------- > > > > mesh/util.c | 11 +---------- > > > > mesh/util.h | 11 +---------- > > > > monitor/a2dp.c | 15 +-------------- > > > > monitor/a2dp.h | 15 +-------------- > > > > monitor/analyze.c | 15 +-------------- > > > > monitor/analyze.h | 15 +-------------- > > > > monitor/avctp.c | 15 +-------------- > > > > monitor/avctp.h | 15 +-------------- > > > > monitor/avdtp.c | 15 +-------------- > > > > monitor/avdtp.h | 15 +-------------- > > > > monitor/bnep.c | 15 +-------------- > > > > monitor/bnep.h | 15 +-------------- > > > > monitor/broadcom.c | 15 +-------------- > > > > monitor/broadcom.h | 15 +-------------- > > > > monitor/bt.h | 15 +-------------- > > > > monitor/control.c | 15 +-------------- > > > > monitor/control.h | 15 +-------------- > > > > monitor/crc.c | 15 +-------------- > > > > monitor/crc.h | 15 +-------------- > > > > monitor/display.c | 15 +-------------- > > > > monitor/display.h | 15 +-------------- > > > > monitor/ellisys.c | 15 +-------------- > > > > monitor/ellisys.h | 15 +-------------- > > > > monitor/hcidump.c | 15 +-------------- > > > > monitor/hcidump.h | 15 +-------------- > > > > monitor/hwdb.c | 15 +-------------- > > > > monitor/hwdb.h | 15 +-------------- > > > > monitor/intel.c | 15 +-------------- > > > > monitor/intel.h | 15 +-------------- > > > > monitor/jlink.c | 15 +-------------- > > > > monitor/jlink.h | 15 +-------------- > > > > monitor/keys.c | 15 +-------------- > > > > monitor/keys.h | 15 +-------------- > > > > monitor/l2cap.c | 15 +-------------- > > > > monitor/l2cap.h | 15 +-------------- > > > > monitor/ll.c | 15 +-------------- > > > > monitor/ll.h | 15 +-------------- > > > > monitor/lmp.c | 15 +-------------- > > > > monitor/lmp.h | 15 +-------------- > > > > monitor/main.c | 15 +-------------- > > > > monitor/packet.c | 15 +-------------- > > > > monitor/packet.h | 15 +-------------- > > > > monitor/rfcomm.c | 15 +-------------- > > > > monitor/rfcomm.h | 15 +-------------- > > > > monitor/sdp.c | 15 +-------------- > > > > monitor/sdp.h | 15 +-------------- > > > > monitor/tty.h | 15 +-------------- > > > > monitor/vendor.c | 15 +-------------- > > > > monitor/vendor.h | 15 +-------------- > > > > obexd/client/bluetooth.c | 15 +-------------- > > > > obexd/client/bluetooth.h | 15 +-------------- > > > > obexd/client/driver.c | 15 +-------------- > > > > obexd/client/driver.h | 15 +-------------- > > > > obexd/client/ftp.c | 15 +-------------- > > > > obexd/client/ftp.h | 15 +-------------- > > > > obexd/client/manager.c | 15 +-------------- > > > > obexd/client/manager.h | 15 +-------------- > > > > obexd/client/map-event.c | 15 +-------------- > > > > obexd/client/map-event.h | 15 +-------------- > > > > obexd/client/map.c | 15 +-------------- > > > > obexd/client/map.h | 15 +-------------- > > > > obexd/client/mns.c | 15 +-------------- > > > > obexd/client/opp.c | 15 +-------------- > > > > obexd/client/opp.h | 15 +-------------- > > > > obexd/client/pbap.c | 15 +-------------- > > > > obexd/client/pbap.h | 15 +-------------- > > > > obexd/client/session.c | 15 +-------------- > > > > obexd/client/session.h | 15 +-------------- > > > > obexd/client/sync.c | 15 +-------------- > > > > obexd/client/sync.h | 15 +-------------- > > > > obexd/client/transfer.c | 15 +-------------- > > > > obexd/client/transfer.h | 15 +-------------- > > > > obexd/client/transport.c | 15 +-------------- > > > > obexd/client/transport.h | 15 +-------------- > > > > obexd/plugins/bluetooth.c | 15 +-------------- > > > > obexd/plugins/filesystem.c | 15 +-------------- > > > > obexd/plugins/filesystem.h | 15 +-------------- > > > > obexd/plugins/ftp.c | 15 +-------------- > > > > obexd/plugins/ftp.h | 15 +-------------- > > > > obexd/plugins/irmc.c | 15 +-------------- > > > > obexd/plugins/mas.c | 15 +-------------- > > > > obexd/plugins/messages-dummy.c | 15 +-------------- > > > > obexd/plugins/messages-tracker.c | 15 +-------------- > > > > obexd/plugins/messages.h | 15 +-------------- > > > > obexd/plugins/opp.c | 15 +-------------- > > > > obexd/plugins/pbap.c | 15 +-------------- > > > > obexd/plugins/pcsuite.c | 15 +-------------- > > > > obexd/plugins/phonebook-dummy.c | 15 +-------------- > > > > obexd/plugins/phonebook-ebook.c | 15 +-------------- > > > > obexd/plugins/phonebook-tracker.c | 15 +-------------- > > > > obexd/plugins/phonebook.h | 15 +-------------- > > > > obexd/plugins/syncevolution.c | 15 +-------------- > > > > obexd/plugins/vcard.c | 15 +-------------- > > > > obexd/plugins/vcard.h | 15 +-------------- > > > > obexd/src/log.c | 15 +-------------- > > > > obexd/src/log.h | 15 +-------------- > > > > obexd/src/main.c | 15 +-------------- > > > > obexd/src/manager.c | 15 +-------------- > > > > obexd/src/manager.h | 15 +-------------- > > > > obexd/src/map_ap.h | 15 +-------------- > > > > obexd/src/mimetype.c | 15 +-------------- > > > > obexd/src/mimetype.h | 15 +-------------- > > > > obexd/src/obex-priv.h | 15 +-------------- > > > > obexd/src/obex.c | 15 +-------------- > > > > obexd/src/obex.h | 15 +-------------- > > > > obexd/src/obexd.h | 15 +-------------- > > > > obexd/src/plugin.c | 15 +-------------- > > > > obexd/src/plugin.h | 15 +-------------- > > > > obexd/src/server.c | 15 +-------------- > > > > obexd/src/server.h | 15 +-------------- > > > > obexd/src/service.c | 15 +-------------- > > > > obexd/src/service.h | 15 +-------------- > > > > obexd/src/transport.c | 15 +-------------- > > > > obexd/src/transport.h | 15 +-------------- > > > > peripheral/attach.c | 15 +-------------- > > > > peripheral/attach.h | 15 +-------------- > > > > peripheral/efivars.c | 15 +-------------- > > > > peripheral/efivars.h | 15 +-------------- > > > > peripheral/gap.c | 15 +-------------- > > > > peripheral/gap.h | 15 +-------------- > > > > peripheral/gatt.c | 15 +-------------- > > > > peripheral/gatt.h | 15 +-------------- > > > > peripheral/log.c | 15 +-------------- > > > > peripheral/log.h | 15 +-------------- > > > > peripheral/main.c | 15 +-------------- > > > > plugins/autopair.c | 15 +-------------- > > > > plugins/external-dummy.c | 15 +-------------- > > > > plugins/hostname.c | 15 +-------------- > > > > plugins/neard.c | 15 +-------------- > > > > plugins/policy.c | 15 +-------------- > > > > plugins/sixaxis.c | 15 +-------------- > > > > plugins/wiimote.c | 15 +-------------- > > > > profiles/audio/a2dp-codecs.h | 15 +-------------- > > > > profiles/audio/a2dp.c | 15 +-------------- > > > > profiles/audio/a2dp.h | 15 +-------------- > > > > profiles/audio/avctp.c | 15 +-------------- > > > > profiles/audio/avctp.h | 15 +-------------- > > > > profiles/audio/avdtp.c | 15 +-------------- > > > > profiles/audio/avdtp.h | 15 +-------------- > > > > profiles/audio/avrcp.c | 15 +-------------- > > > > profiles/audio/avrcp.h | 15 +-------------- > > > > profiles/audio/control.c | 15 +-------------- > > > > profiles/audio/control.h | 15 +-------------- > > > > profiles/audio/media.c | 15 +-------------- > > > > profiles/audio/media.h | 15 +-------------- > > > > profiles/audio/player.c | 15 +-------------- > > > > profiles/audio/player.h | 15 +-------------- > > > > profiles/audio/sink.c | 15 +-------------- > > > > profiles/audio/sink.h | 15 +-------------- > > > > profiles/audio/source.c | 15 +-------------- > > > > profiles/audio/source.h | 15 +-------------- > > > > profiles/audio/transport.c | 15 +-------------- > > > > profiles/audio/transport.h | 15 +-------------- > > > > profiles/battery/bas.c | 15 +-------------- > > > > profiles/battery/bas.h | 15 +-------------- > > > > profiles/battery/battery.c | 10 +--------- > > > > profiles/cups/cups.h | 15 +-------------- > > > > profiles/cups/hcrp.c | 15 +-------------- > > > > profiles/cups/main.c | 15 +-------------- > > > > profiles/cups/sdp.c | 15 +-------------- > > > > profiles/cups/spp.c | 15 +-------------- > > > > profiles/deviceinfo/deviceinfo.c | 15 +-------------- > > > > profiles/deviceinfo/dis.c | 15 +-------------- > > > > profiles/deviceinfo/dis.h | 15 +-------------- > > > > profiles/gap/gas.c | 10 +--------- > > > > profiles/health/hdp.c | 15 +-------------- > > > > profiles/health/hdp.h | 15 +-------------- > > > > profiles/health/hdp_main.c | 15 +-------------- > > > > profiles/health/hdp_manager.c | 15 +-------------- > > > > profiles/health/hdp_manager.h | 15 +-------------- > > > > profiles/health/hdp_types.h | 15 +-------------- > > > > profiles/health/hdp_util.c | 15 +-------------- > > > > profiles/health/hdp_util.h | 15 +-------------- > > > > profiles/health/mcap.c | 15 +-------------- > > > > profiles/health/mcap.h | 15 +-------------- > > > > profiles/iap/main.c | 15 +-------------- > > > > profiles/input/device.c | 15 +-------------- > > > > profiles/input/device.h | 15 +-------------- > > > > profiles/input/hidp_defs.h | 15 +-------------- > > > > profiles/input/hog-lib.c | 15 +-------------- > > > > profiles/input/hog-lib.h | 15 +-------------- > > > > profiles/input/hog.c | 15 +-------------- > > > > profiles/input/manager.c | 15 +-------------- > > > > profiles/input/server.c | 15 +-------------- > > > > profiles/input/server.h | 15 +-------------- > > > > profiles/input/sixaxis.h | 15 +-------------- > > > > profiles/input/suspend-dummy.c | 15 +-------------- > > > > profiles/input/suspend-none.c | 15 +-------------- > > > > profiles/input/suspend.h | 15 +-------------- > > > > profiles/midi/libmidi.c | 16 +--------------- > > > > profiles/midi/libmidi.h | 16 +--------------- > > > > profiles/midi/midi.c | 20 +------------------- > > > > profiles/network/bnep.c | 15 +-------------- > > > > profiles/network/bnep.h | 15 +-------------- > > > > profiles/network/connection.c | 15 +-------------- > > > > profiles/network/connection.h | 15 +-------------- > > > > profiles/network/manager.c | 15 +-------------- > > > > profiles/network/server.c | 15 +-------------- > > > > profiles/network/server.h | 15 +-------------- > > > > profiles/sap/main.c | 14 +------------- > > > > profiles/sap/manager.c | 14 +------------- > > > > profiles/sap/manager.h | 14 +------------- > > > > profiles/sap/sap-dummy.c | 14 +------------- > > > > profiles/sap/sap.h | 14 +------------- > > > > profiles/sap/server.c | 14 +------------- > > > > profiles/sap/server.h | 14 +------------- > > > > profiles/scanparam/scan.c | 15 +-------------- > > > > profiles/scanparam/scpp.c | 15 +-------------- > > > > profiles/scanparam/scpp.h | 15 +-------------- > > > > src/adapter.c | 15 +-------------- > > > > src/adapter.h | 15 +-------------- > > > > src/adv_monitor.c | 11 +---------- > > > > src/adv_monitor.h | 11 +---------- > > > > src/advertising.c | 11 +---------- > > > > src/advertising.h | 11 +---------- > > > > src/agent.c | 15 +-------------- > > > > src/agent.h | 15 +-------------- > > > > src/attrib-server.c | 15 +-------------- > > > > src/attrib-server.h | 15 +-------------- > > > > src/backtrace.c | 15 +-------------- > > > > src/backtrace.h | 15 +-------------- > > > > src/dbus-common.c | 15 +-------------- > > > > src/dbus-common.h | 15 +-------------- > > > > src/device.c | 15 +-------------- > > > > src/device.h | 15 +-------------- > > > > src/eir.c | 15 +-------------- > > > > src/eir.h | 15 +-------------- > > > > src/error.c | 15 +-------------- > > > > src/error.h | 15 +-------------- > > > > src/gatt-client.c | 11 +---------- > > > > src/gatt-client.h | 11 +---------- > > > > src/gatt-database.c | 11 +---------- > > > > src/gatt-database.h | 11 +---------- > > > > src/hcid.h | 15 +-------------- > > > > src/log.c | 15 +-------------- > > > > src/log.h | 15 +-------------- > > > > src/main.c | 15 +-------------- > > > > src/oui.c | 15 +-------------- > > > > src/oui.h | 15 +-------------- > > > > src/plugin.c | 15 +-------------- > > > > src/plugin.h | 15 +-------------- > > > > src/profile.c | 15 +-------------- > > > > src/profile.h | 15 +-------------- > > > > src/rfkill.c | 15 +-------------- > > > > src/sdp-client.c | 15 +-------------- > > > > src/sdp-client.h | 15 +-------------- > > > > src/sdp-xml.c | 15 +-------------- > > > > src/sdp-xml.h | 15 +-------------- > > > > src/sdpd-database.c | 15 +-------------- > > > > src/sdpd-request.c | 15 +-------------- > > > > src/sdpd-server.c | 15 +-------------- > > > > src/sdpd-service.c | 15 +-------------- > > > > src/sdpd.h | 15 +-------------- > > > > src/service.c | 15 +-------------- > > > > src/service.h | 15 +-------------- > > > > src/shared/ad.c | 15 +-------------- > > > > src/shared/ad.h | 15 +-------------- > > > > src/shared/att-types.h | 15 +-------------- > > > > src/shared/att.c | 15 +-------------- > > > > src/shared/att.h | 15 +-------------- > > > > src/shared/btp.c | 15 +-------------- > > > > src/shared/btp.h | 15 +-------------- > > > > src/shared/btsnoop.c | 15 +-------------- > > > > src/shared/btsnoop.h | 15 +-------------- > > > > src/shared/crypto.c | 15 +-------------- > > > > src/shared/crypto.h | 15 +-------------- > > > > src/shared/ecc.c | 21 +-------------------- > > > > src/shared/ecc.h | 21 +-------------------- > > > > src/shared/gap.c | 15 +-------------- > > > > src/shared/gap.h | 15 +-------------- > > > > src/shared/gatt-client.c | 15 +-------------- > > > > src/shared/gatt-client.h | 15 +-------------- > > > > src/shared/gatt-db.c | 15 +-------------- > > > > src/shared/gatt-db.h | 15 +-------------- > > > > src/shared/gatt-helpers.c | 15 +-------------- > > > > src/shared/gatt-helpers.h | 15 +-------------- > > > > src/shared/gatt-server.c | 15 +-------------- > > > > src/shared/gatt-server.h | 15 +-------------- > > > > src/shared/hci-crypto.c | 15 +-------------- > > > > src/shared/hci-crypto.h | 15 +-------------- > > > > src/shared/hci.c | 15 +-------------- > > > > src/shared/hci.h | 15 +-------------- > > > > src/shared/hfp.c | 15 +-------------- > > > > src/shared/hfp.h | 15 +-------------- > > > > src/shared/io-ell.c | 15 +-------------- > > > > src/shared/io-glib.c | 15 +-------------- > > > > src/shared/io-mainloop.c | 15 +-------------- > > > > src/shared/io.h | 15 +-------------- > > > > src/shared/log.c | 15 +-------------- > > > > src/shared/log.h | 15 +-------------- > > > > src/shared/mainloop-ell.c | 12 +----------- > > > > src/shared/mainloop-glib.c | 15 +-------------- > > > > src/shared/mainloop-notify.c | 15 +-------------- > > > > src/shared/mainloop-notify.h | 15 +-------------- > > > > src/shared/mainloop.c | 15 +-------------- > > > > src/shared/mainloop.h | 15 +-------------- > > > > src/shared/mgmt.c | 15 +-------------- > > > > src/shared/mgmt.h | 15 +-------------- > > > > src/shared/pcap.c | 15 +-------------- > > > > src/shared/pcap.h | 15 +-------------- > > > > src/shared/queue.c | 15 +-------------- > > > > src/shared/queue.h | 15 +-------------- > > > > src/shared/ringbuf.c | 15 +-------------- > > > > src/shared/ringbuf.h | 15 +-------------- > > > > src/shared/shell.c | 15 +-------------- > > > > src/shared/shell.h | 15 +-------------- > > > > src/shared/tester.c | 15 +-------------- > > > > src/shared/tester.h | 15 +-------------- > > > > src/shared/timeout-ell.c | 11 +---------- > > > > src/shared/timeout-glib.c | 11 +---------- > > > > src/shared/timeout-mainloop.c | 11 +---------- > > > > src/shared/timeout.h | 11 +---------- > > > > src/shared/tty.h | 15 +-------------- > > > > src/shared/uhid.c | 15 +-------------- > > > > src/shared/uhid.h | 15 +-------------- > > > > src/shared/util.c | 15 +-------------- > > > > src/shared/util.h | 15 +-------------- > > > > src/storage.c | 15 +-------------- > > > > src/storage.h | 15 +-------------- > > > > src/textfile.c | 15 +-------------- > > > > src/textfile.h | 15 +-------------- > > > > src/uinput.h | 15 +-------------- > > > > src/uuid-helper.c | 15 +-------------- > > > > src/uuid-helper.h | 15 +-------------- > > > > tools/3dsp.c | 15 +-------------- > > > > tools/advtest.c | 15 +-------------- > > > > tools/amptest.c | 15 +-------------- > > > > tools/avinfo.c | 15 +-------------- > > > > tools/avtest.c | 15 +-------------- > > > > tools/bccmd.c | 15 +-------------- > > > > tools/bcmfw.c | 15 +-------------- > > > > tools/bdaddr.c | 15 +-------------- > > > > tools/bluemoon.c | 15 +-------------- > > > > tools/bluetooth-player.c | 15 +-------------- > > > > tools/bnep-tester.c | 15 +-------------- > > > > tools/bneptest.c | 15 +-------------- > > > > tools/btattach.c | 15 +-------------- > > > > tools/btconfig.c | 15 +-------------- > > > > tools/btgatt-client.c | 15 +-------------- > > > > tools/btgatt-server.c | 11 +---------- > > > > tools/btinfo.c | 15 +-------------- > > > > tools/btiotest.c | 15 +-------------- > > > > tools/btmgmt.c | 15 +-------------- > > > > tools/btmon-logger.c | 15 +-------------- > > > > tools/btpclient.c | 15 +-------------- > > > > tools/btpclientctl.c | 15 +-------------- > > > > tools/btproxy.c | 15 +-------------- > > > > tools/btsnoop.c | 15 +-------------- > > > > tools/check-selftest.c | 15 +-------------- > > > > tools/ciptool.c | 15 +-------------- > > > > tools/cltest.c | 15 +-------------- > > > > tools/create-image.c | 15 +-------------- > > > > tools/csr.c | 15 +-------------- > > > > tools/csr.h | 15 +-------------- > > > > tools/csr_3wire.c | 15 +-------------- > > > > tools/csr_bcsp.c | 15 +-------------- > > > > tools/csr_h4.c | 15 +-------------- > > > > tools/csr_hci.c | 15 +-------------- > > > > tools/csr_usb.c | 15 +-------------- > > > > tools/eddystone.c | 15 +-------------- > > > > tools/gap-tester.c | 15 +-------------- > > > > tools/gatt-service.c | 15 +-------------- > > > > tools/hci-tester.c | 15 +-------------- > > > > tools/hciattach.c | 15 +-------------- > > > > tools/hciattach.h | 15 +-------------- > > > > tools/hciattach_ath3k.c | 15 +-------------- > > > > tools/hciattach_bcm43xx.c | 15 +-------------- > > > > tools/hciattach_intel.c | 15 +-------------- > > > > tools/hciattach_qualcomm.c | 15 +-------------- > > > > tools/hciattach_st.c | 15 +-------------- > > > > tools/hciattach_ti.c | 15 +-------------- > > > > tools/hciattach_tialt.c | 15 +-------------- > > > > tools/hciconfig.c | 15 +-------------- > > > > tools/hcidump.c | 15 +-------------- > > > > tools/hcieventmask.c | 15 +-------------- > > > > tools/hcisecfilter.c | 15 +-------------- > > > > tools/hcitool.c | 15 +-------------- > > > > tools/hex2hcd.c | 15 +-------------- > > > > tools/hid2hci.c | 15 +-------------- > > > > tools/hwdb.c | 15 +-------------- > > > > tools/ibeacon.c | 15 +-------------- > > > > tools/l2cap-tester.c | 15 +-------------- > > > > tools/l2ping.c | 15 +-------------- > > > > tools/l2test.c | 15 +-------------- > > > > tools/mcaptest.c | 15 +-------------- > > > > tools/mesh-cfgclient.c | 11 +---------- > > > > tools/mesh-gatt/config-client.c | 15 +-------------- > > > > tools/mesh-gatt/config-server.c | 15 +-------------- > > > > tools/mesh-gatt/crypto.c | 15 +-------------- > > > > tools/mesh-gatt/crypto.h | 15 +-------------- > > > > tools/mesh-gatt/gatt.c | 15 +-------------- > > > > tools/mesh-gatt/gatt.h | 15 +-------------- > > > > tools/mesh-gatt/keys.h | 15 +-------------- > > > > tools/mesh-gatt/mesh-net.h | 15 +-------------- > > > > tools/mesh-gatt/net.c | 15 +-------------- > > > > tools/mesh-gatt/net.h | 15 +-------------- > > > > tools/mesh-gatt/node.c | 15 +-------------- > > > > tools/mesh-gatt/node.h | 15 +-------------- > > > > tools/mesh-gatt/onoff-model.c | 15 +-------------- > > > > tools/mesh-gatt/onoff-model.h | 15 +-------------- > > > > tools/mesh-gatt/prov-db.c | 15 +-------------- > > > > tools/mesh-gatt/prov-db.h | 15 +-------------- > > > > tools/mesh-gatt/prov.c | 15 +-------------- > > > > tools/mesh-gatt/prov.h | 15 +-------------- > > > > tools/mesh-gatt/util.c | 15 +-------------- > > > > tools/mesh-gatt/util.h | 15 +-------------- > > > > tools/mesh/agent.c | 15 +-------------- > > > > tools/mesh/agent.h | 15 +-------------- > > > > tools/mesh/cfgcli.c | 12 +----------- > > > > tools/mesh/cfgcli.h | 12 +----------- > > > > tools/mesh/config-model.h | 15 +-------------- > > > > tools/mesh/keys.c | 12 +----------- > > > > tools/mesh/keys.h | 12 +----------- > > > > tools/mesh/mesh-db.c | 11 +---------- > > > > tools/mesh/mesh-db.h | 11 +---------- > > > > tools/mesh/model.h | 12 +----------- > > > > tools/mesh/remote.c | 11 +---------- > > > > tools/mesh/remote.h | 11 +---------- > > > > tools/mesh/util.c | 11 +---------- > > > > tools/mesh/util.h | 11 +---------- > > > > tools/meshctl.c | 15 +-------------- > > > > tools/mgmt-tester.c | 15 +-------------- > > > > tools/mpris-proxy.c | 15 +-------------- > > > > tools/nokfw.c | 15 +-------------- > > > > tools/obex-client-tool.c | 14 +------------- > > > > tools/obex-server-tool.c | 14 +------------- > > > > tools/obexctl.c | 15 +-------------- > > > > tools/oobtest.c | 15 +-------------- > > > > tools/parser/amp.c | 15 +-------------- > > > > tools/parser/att.c | 15 +-------------- > > > > tools/parser/avctp.c | 15 +-------------- > > > > tools/parser/avdtp.c | 15 +-------------- > > > > tools/parser/avrcp.c | 15 +-------------- > > > > tools/parser/bnep.c | 15 +-------------- > > > > tools/parser/bpa.c | 15 +-------------- > > > > tools/parser/capi.c | 15 +-------------- > > > > tools/parser/cmtp.c | 15 +-------------- > > > > tools/parser/csr.c | 15 +-------------- > > > > tools/parser/ericsson.c | 15 +-------------- > > > > tools/parser/hci.c | 15 +-------------- > > > > tools/parser/hcrp.c | 15 +-------------- > > > > tools/parser/hidp.c | 15 +-------------- > > > > tools/parser/l2cap.c | 15 +-------------- > > > > tools/parser/l2cap.h | 15 +-------------- > > > > tools/parser/lmp.c | 15 +-------------- > > > > tools/parser/obex.c | 15 +-------------- > > > > tools/parser/parser.c | 15 +-------------- > > > > tools/parser/parser.h | 15 +-------------- > > > > tools/parser/ppp.c | 15 +-------------- > > > > tools/parser/rfcomm.c | 15 +-------------- > > > > tools/parser/rfcomm.h | 15 +-------------- > > > > tools/parser/sap.c | 15 +-------------- > > > > tools/parser/sdp.c | 15 +-------------- > > > > tools/parser/sdp.h | 15 +-------------- > > > > tools/parser/smp.c | 15 +-------------- > > > > tools/parser/tcpip.c | 15 +-------------- > > > > tools/rctest.c | 15 +-------------- > > > > tools/rfcomm-tester.c | 15 +-------------- > > > > tools/rfcomm.c | 15 +-------------- > > > > tools/rtlfw.c | 15 +-------------- > > > > tools/sco-tester.c | 15 +-------------- > > > > tools/scotest.c | 15 +-------------- > > > > tools/sdptool.c | 15 +-------------- > > > > tools/seq2bseq.c | 15 +-------------- > > > > tools/smp-tester.c | 15 +-------------- > > > > tools/test-runner.c | 15 +-------------- > > > > tools/ubcsp.c | 20 +------------------- > > > > tools/ubcsp.h | 20 +------------------- > > > > tools/userchan-tester.c | 15 +-------------- > > > > unit/test-avctp.c | 15 +-------------- > > > > unit/test-avdtp.c | 15 +-------------- > > > > unit/test-avrcp.c | 15 +-------------- > > > > unit/test-crc.c | 15 +-------------- > > > > unit/test-crypto.c | 15 +-------------- > > > > unit/test-ecc.c | 21 +-------------------- > > > > unit/test-eir.c | 15 +-------------- > > > > unit/test-gatt.c | 15 +-------------- > > > > unit/test-gattrib.c | 15 +-------------- > > > > unit/test-gdbus-client.c | 15 +-------------- > > > > unit/test-gobex-apparam.c | 15 +-------------- > > > > unit/test-gobex-header.c | 15 +-------------- > > > > unit/test-gobex-packet.c | 15 +-------------- > > > > unit/test-gobex-transfer.c | 15 +-------------- > > > > unit/test-gobex.c | 15 +-------------- > > > > unit/test-hfp.c | 15 +-------------- > > > > unit/test-hog.c | 15 +-------------- > > > > unit/test-lib.c | 15 +-------------- > > > > unit/test-mesh-crypto.c | 11 +---------- > > > > unit/test-mgmt.c | 15 +-------------- > > > > unit/test-midi.c | 16 +--------------- > > > > unit/test-queue.c | 15 +-------------- > > > > unit/test-ringbuf.c | 15 +-------------- > > > > unit/test-sdp.c | 15 +-------------- > > > > unit/test-textfile.c | 15 +-------------- > > > > unit/test-uhid.c | 15 +-------------- > > > > unit/test-uuid.c | 15 +-------------- > > > > unit/util.c | 14 +------------- > > > > unit/util.h | 14 +------------- > > > > 758 files changed, 758 insertions(+), 10148 deletions(-) > > > > > > -- > > > pozdrawiam > > > Szymon Janc > > > > > > > > > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6DeFGfAuYV8qcwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 15 Sep 2020 23:15:28 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OG/YFvAuYV9xHQEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 15 Sep 2020 23:15:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 95B5E4081B; Tue, 15 Sep 2020 23:15:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727848AbgIOVPK (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 17:15:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727928AbgIOVOt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 17:14:49 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E61B5C06178B for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 14:14:48 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 125so4790727ybg.12 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 14:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=K+OfCoM6oTmkFdqxGs+YSyPIFR+NJtTdbrbahx+pi8o=; b=Bfbb6PAjFKNPNmBiLhOhqp8uf+5dfGDcVtfLcv83W6I4mmz8leffU/S6ATJ0NoEcAS v1VM7hSpryC5Zauqdu6RcvSUTpFZwn0SROVOg8yfdiPto085QZO2xD+JPI0lb5kBTuK5 sRXkaD5z5MkbrYn2N/Eu/MAMtEUePcvEBd33t7RdW3i4TuR6llHN4ezRrgipgYs2+33i IhBVEV/aHL1iMHk7sX1HiMGJVcDCemlIYsORCB84pLS6RjpT6RNH+MlgKDSi2A6p6Bbz IKK1p5CaBXGfFWRijvbhUT/GCHri9hZhxul8R6Cm7YmExyGEfivaE0P6MZucOBtoFRX5 n95g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=K+OfCoM6oTmkFdqxGs+YSyPIFR+NJtTdbrbahx+pi8o=; b=O4bwU5Oh4XaKmPtiF99iIC+z0062xsdb2xa+OVOgRVVJqGywE7uzbQRGHCc5DBCxGX ZDMg1PIvaMt8RJvljsnOqW1Vw3ApyLKYRiSGzRvZMsNV5vfUQMGEakYkvz0DcNZfL/GM fRlbwqykLi4g9sH/u80bO84oZjD/3pLpxDC4/7obQjNXytBrpjZqlm7I7B+KzjQCVauL J2bRDIyNPCfE7Xq5bfgJo0NK4h31wpMj7rJGbKDQ2A3jpO/MLPIUdonPaj0wKPCGlsgF VQkoznRv6jnl8/XNQ1KZ9Lnn4aZHU0DaR/6/CbR/auBYMomca9Fko2UQfTGHFxg0PRIV 2nBg== X-Gm-Message-State: AOAM531M9zKzM6M3zKUtf+OEQocvgYrkU+0z0hY5988AuLjHlVpgN242 hDrxXnq8UqwDvodCqMTtm7SzDLXS6h2ACb70rGrO6kNnZQT2oFEDlRWdeKaTn0pUl5dTh/eMEAL RB0Ke9MqcUz5P20Tbse+1eldbZvSHB6AusF0roNJRSYl4Qbz5fy/DEMPT3hWsX4WYcxFDtIeaqd 33+3eFeKQcuIVE6JOg X-Google-Smtp-Source: ABdhPJyww2+5qPFKot6oq/w5hjYv4FO0/obmugq2VwsJRMK9d8CCeO5bHaloVjkf47P7tieu34FzW1yIWD4tngmvw+TY X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:3783:: with SMTP id e125mr8595152yba.423.1600204487979; Tue, 15 Sep 2020 14:14:47 -0700 (PDT) Date: Tue, 15 Sep 2020 14:14:27 -0700 Message-Id: <20200915141229.1.Icfac86f8dfa0813bba6c7604c420d11c3820b4ab@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH] Bluetooth: pause/resume advertising around suspend From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.49 / 15.00 / 15.00 X-Rspamd-Queue-Id: 95B5E4081B X-Rspamd-UID: 70b333 Currently, the controller will continue advertising when the system enters suspend. This patch makes sure that all advertising instances are paused when entering suspend, and resumed when suspend exits. The Advertising and Suspend/Resume test suites were both run on this change on 4.19 kernel with both hardware offloaded multi-advertising and software rotated multi-advertising. In addition, a new test was added that performs the following steps: * Register 3 advertisements via bluez RegisterAdvertisement * Verify reception of all advertisements by remote peer * Enter suspend on DUT * Verify failure to receive all advertisements by remote peer * Exit suspend on DUT * Verify reception of all advertisements by remote peer Signed-off-by: Daniel Winkler <danielwinkler@google.com> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- net/bluetooth/hci_request.c | 67 +++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 10 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index e17bc8a1c66ddd..413e3a5aabf544 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1111,6 +1111,53 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) set_bit(SUSPEND_SCAN_ENABLE, req->hdev->suspend_tasks); } +static void cancel_adv_timeout(struct hci_dev *hdev) +{ + if (hdev->adv_instance_timeout) { + hdev->adv_instance_timeout = 0; + cancel_delayed_work(&hdev->adv_instance_expire); + } +} + +/* This function requires the caller holds hdev->lock */ +static void hci_suspend_adv_instances(struct hci_request *req) +{ + bt_dev_dbg(req->hdev, "Suspending advertising instances"); + + /* Call to disable any advertisements active on the controller. + * This will succeed even if no advertisements are configured. + */ + __hci_req_disable_advertising(req); + + /* If we are using software rotation, pause the loop */ + if (!ext_adv_capable(req->hdev)) + cancel_adv_timeout(req->hdev); +} + +/* This function requires the caller holds hdev->lock */ +static void hci_resume_adv_instances(struct hci_request *req) +{ + struct adv_info *adv; + + bt_dev_dbg(req->hdev, "Resuming advertising instances"); + + if (ext_adv_capable(req->hdev)) { + /* Call for each tracked instance to be re-enabled */ + list_for_each_entry(adv, &req->hdev->adv_instances, list) { + __hci_req_enable_ext_advertising(req, + adv->instance); + } + + } else { + /* Schedule for most recent instance to be restarted and begin + * the software rotation loop + */ + __hci_req_schedule_adv_instance(req, + req->hdev->cur_adv_instance, + true); + } +} + static void suspend_req_complete(struct hci_dev *hdev, u8 status, u16 opcode) { bt_dev_dbg(hdev, "Request complete opcode=0x%x, status=0x%x", opcode, @@ -1153,7 +1200,7 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) hdev->discovery_paused = true; hdev->discovery_old_state = old_state; - /* Stop advertising */ + /* Stop directed advertising */ old_state = hci_dev_test_flag(hdev, HCI_ADVERTISING); if (old_state) { set_bit(SUSPEND_PAUSE_ADVERTISING, hdev->suspend_tasks); @@ -1162,6 +1209,10 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) &hdev->discov_off, 0); } + /* Pause other advertisements */ + if (hdev->adv_instance_cnt) + hci_suspend_adv_instances(&req); + hdev->advertising_paused = true; hdev->advertising_old_state = old_state; /* Disable page scan */ @@ -1212,7 +1263,7 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) /* Reset passive/background scanning to normal */ hci_req_config_le_suspend_scan(&req); - /* Unpause advertising */ + /* Unpause directed advertising */ hdev->advertising_paused = false; if (hdev->advertising_old_state) { set_bit(SUSPEND_UNPAUSE_ADVERTISING, @@ -1223,6 +1274,10 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) hdev->advertising_old_state = 0; } + /* Resume other advertisements */ + if (hdev->adv_instance_cnt) + hci_resume_adv_instances(&req); + /* Unpause discovery */ hdev->discovery_paused = false; if (hdev->discovery_old_state != DISCOVERY_STOPPED && @@ -2186,14 +2241,6 @@ int __hci_req_schedule_adv_instance(struct hci_request *req, u8 instance, return 0; } -static void cancel_adv_timeout(struct hci_dev *hdev) -{ - if (hdev->adv_instance_timeout) { - hdev->adv_instance_timeout = 0; - cancel_delayed_work(&hdev->adv_instance_expire); - } -} - /* For a single instance: * - force == true: The instance will be removed even when its remaining * lifetime is not zero. -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kANvDFI9YV/SuwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 00:16:50 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qP+ACVI9YV8j7AEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 00:16:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 71AB6A0979; Wed, 16 Sep 2020 00:16:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727745AbgIOWQI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 18:16:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727740AbgIOQes (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 12:34:48 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F943C06174A for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 09:34:48 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id o6so3863358ota.2 for <linux-bluetooth@vger.kernel.org>; Tue, 15 Sep 2020 09:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uuDQch+egM8HVXUKs7iBQotvqU5GOcChb8ExpOd/1Vs=; b=O0xS2DSWoDtAF6KwozIuWIeEYhGzcPpGvWPdq0W8q4BPmwSUiZtuvF2t53fxXF70Q3 T6bq3yP73sgv6V7xn96wQ2h/I+O1riOt4q6zfxX518OBl8ayzBv7IybWT+WV6fXQbItL sDaOdcBm2wvAZx0xFM7lRZ992LSrbhSSSWxno9v1K8lqVyqkADqAhrl/kM91OWolVHCj DQl7MaQ/fa9rC/BAoEKLnKm2OupF9BiXikQzzNZZ8H1zt3fjxkQtrD/KB0kdSXlEvpiS Ri3NObtsR7uu8NJy0wmxq8ululaZOTmz4M7sn0MeG6nkYkh7fDGRMaf4XkH4flkDe0Ry 1IMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uuDQch+egM8HVXUKs7iBQotvqU5GOcChb8ExpOd/1Vs=; b=YNHs3ZVsi8mzweh7SDKdlaLDXPZro7yGnoiJphiblvFEtkrtH4Ki1X4Lrjh1Ohiaoi wn0lYGNRjvHZo9xqax6uyhYVoSCG51rqi70c46gMt6N/gqioYiB0jcmb6NVqU05EvOzF ibfJElb93DJUK5ogqaDZxxmd2LLFRmgO7AMFq8WPkBImpX1F7wEP2QTEmIi0JOWFDzu1 MM+j+Z1tm5Yh1mwKbGiCa/dU8y684hiQh4TQCkcl8bfkCaGnP3ZrpVHMqavM1N/NNMeg BliAM60cWyCU0RvAh454HC+Cjpmq6j8foivsXZqOw4YEToIlZXnPGj1AvkwXu46ISUZB UarA== X-Gm-Message-State: AOAM532O1TqPy4eVVNiVJT22WkOSOih+WDDQNQyARDBL765BcmwpIsDs H7Dsau4qDpzjR+/thaDyWL1POSUxWGfFFl0Atag= X-Google-Smtp-Source: ABdhPJzi3Got9n4I77pfE91vY4NcmuuprQ2vlhxH6/tJRDUd/dpVDFubxDbL6BlLg1S8pThGVChwT31/kz8cm1YwdFw= X-Received: by 2002:a9d:4695:: with SMTP id z21mr13637037ote.91.1600187687307; Tue, 15 Sep 2020 09:34:47 -0700 (PDT) MIME-Version: 1.0 References: <20200915000457.22988-1-tedd.an@linux.intel.com> <4586934.31r3eYUQgx@ix> In-Reply-To: <4586934.31r3eYUQgx@ix> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 15 Sep 2020 09:34:35 -0700 Message-ID: <CABBYNZLc+yNVH7pA8J-z_yhpF59jC_JenEEFqRtzPMUXB-=y5Q@mail.gmail.com> Subject: Re: [BlueZ v3 00/17] Add SPDX License Identifier To: Szymon Janc <szymon.janc@codecoup.pl> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Tedd Ho-Jeong An <tedd.an@linux.intel.com>, Tedd Ho-Jeong An <tedd.an@intel.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.55 / 15.00 / 15.00 X-Rspamd-Queue-Id: 71AB6A0979 X-Rspamd-UID: 5541ba Hi Szymon, On Tue, Sep 15, 2020 at 12:24 AM Szymon Janc <szymon.janc@codecoup.pl> wrote: > > Hi, > > On Tuesday, 15 September 2020 02:04:40 CEST tedd.an@linux.intel.com wrote: > > From: Tedd Ho-Jeong An <tedd.an@intel.com> > > > > This patch series adds SPDX License Identifier to the source/heade files > > based on the existing license header and removes the license text. > > > > The SDPX License Identifier is added in form of a comment based on file > > type with the same rule from the Linxu kernel source, and added to the > > first line of the file. > > > > C source: // SPDX-License-Identifer: <License> > > Why C++ style comments in C source? > > > C header: /* SPDX-License-Identifer: <License> */ > > > > For SPDX-License Identifier, it used the identifer from the SPDX License > > list page(https://spdx.org/licenses). > > INAL but SPDX identifier itself is insufficied for license compliance. > > If we really want to (I don't have strong opinion about this) remove license > headers in favour of only having SPDX then we need files with licenses text > etc to be part of distribution. Pretty much the same what kernel folks did. We should probably create a LICENSES directory with the full license text, but for the source files the SPDX identifier should be enough, something like: LICENSES/ ./preferred/{GPL-2.0, LGPL-2.1, BSD-2-Clause, MIT} ./dual/Apache-2.0 The kernel don't seem to be using or-later variant of GPL perhaps to avoid (L)GPL 3.0 clauses. > > For the summary, currently BlueZ sources have following licenses: > > > > ------------------------------------------- > > License File Count > > ------------------------------------------- > > GPL-2.0-or-later : 393 > > LGPL-2.1-or-later : 273 > > BSD-2-Clause : 3 > > GPL-2.0-only : 5 > > MIT : 2 > > Apache-2.0 : 80 > > N/A : 1325 > > > > Note that N/A includes the following files/folders > > - .git/ > > - doc/ > > - Build related files (Makefile, etc) In Zephyr we do have license for build related files, not sure what license we should use though, perhaps LGPL is better for these. > > - Configuration files > > - Test scripts (python, etc) The tests scripts we might want to have license as well, LGPL might be a better here as well. > > > > Tedd Ho-Jeong An (17): > > android: Add SPDX License Identifier > > attrib: Add SPDX License Identifier > > btio: Add SPDX License Identifier > > client: Add SPDX License Identifier > > emulator: Add SPDX License Identifier > > gdbus: Add SPDX License Identifier > > gobex: Add SPDX License Identifier > > lib: Add SPDX License Identifier > > mesh: Add SPDX License Identifier > > monitor: Add SPDX License Identifier > > obexd: Add SPDX License Identifier > > peripheral: Add SPDX License Identifier > > plugins: Add SPDX License Identifier > > profiles: Add SPDX License Identifier > > unit: Add SPDX License Identifier > > src: Add SPDX License Identifier > > tools: Add SPDX License Identifier > > > > android/a2dp-sink.c | 15 +-------------- > > android/a2dp-sink.h | 15 +-------------- > > android/a2dp.c | 15 +-------------- > > android/a2dp.h | 15 +-------------- > > android/audio-msg.h | 15 +-------------- > > android/audio_utils/resampler.c | 12 +----------- > > android/audio_utils/resampler.h | 12 +----------- > > android/avctp.c | 15 +-------------- > > android/avctp.h | 15 +-------------- > > android/avdtp.c | 15 +-------------- > > android/avdtp.h | 15 +-------------- > > android/avdtptest.c | 15 +-------------- > > android/avrcp-lib.c | 15 +-------------- > > android/avrcp-lib.h | 15 +-------------- > > android/avrcp.c | 15 +-------------- > > android/avrcp.h | 15 +-------------- > > android/bluetooth.c | 15 +-------------- > > android/bluetooth.h | 15 +-------------- > > android/bluetoothd-snoop.c | 15 +-------------- > > android/bluetoothd-wrapper.c | 13 +------------ > > android/client/haltest.c | 13 +------------ > > android/client/history.c | 13 +------------ > > android/client/history.h | 13 +------------ > > android/client/if-audio.c | 13 +------------ > > android/client/if-av-sink.c | 13 +------------ > > android/client/if-av.c | 13 +------------ > > android/client/if-bt.c | 13 +------------ > > android/client/if-gatt.c | 13 +------------ > > android/client/if-hf-client.c | 13 +------------ > > android/client/if-hf.c | 13 +------------ > > android/client/if-hh.c | 13 +------------ > > android/client/if-hl.c | 13 +------------ > > android/client/if-main.h | 13 +------------ > > android/client/if-mce.c | 13 +------------ > > android/client/if-pan.c | 13 +------------ > > android/client/if-rc-ctrl.c | 13 +------------ > > android/client/if-rc.c | 13 +------------ > > android/client/if-sco.c | 13 +------------ > > android/client/if-sock.c | 13 +------------ > > android/client/pollhandler.c | 13 +------------ > > android/client/pollhandler.h | 13 +------------ > > android/client/tabcompletion.c | 13 +------------ > > android/client/terminal.c | 13 +------------ > > android/client/terminal.h | 13 +------------ > > android/compat/readline/history.h | 15 +-------------- > > android/compat/readline/readline.h | 15 +-------------- > > android/compat/wordexp.h | 15 +-------------- > > android/cutils/properties.h | 15 +-------------- > > android/gatt.c | 15 +-------------- > > android/gatt.h | 15 +-------------- > > android/hal-a2dp-sink.c | 13 +------------ > > android/hal-a2dp.c | 13 +------------ > > android/hal-audio-aptx.c | 13 +------------ > > android/hal-audio-sbc.c | 13 +------------ > > android/hal-audio.c | 13 +------------ > > android/hal-audio.h | 13 +------------ > > android/hal-avrcp-ctrl.c | 13 +------------ > > android/hal-avrcp.c | 13 +------------ > > android/hal-bluetooth.c | 13 +------------ > > android/hal-gatt.c | 13 +------------ > > android/hal-handsfree-client.c | 13 +------------ > > android/hal-handsfree.c | 13 +------------ > > android/hal-health.c | 13 +------------ > > android/hal-hidhost.c | 13 +------------ > > android/hal-ipc.c | 13 +------------ > > android/hal-ipc.h | 13 +------------ > > android/hal-log.h | 13 +------------ > > android/hal-map-client.c | 13 +------------ > > android/hal-msg.h | 15 +-------------- > > android/hal-pan.c | 13 +------------ > > android/hal-sco.c | 13 +------------ > > android/hal-socket.c | 13 +------------ > > android/hal-utils.c | 13 +------------ > > android/hal-utils.h | 13 +------------ > > android/hal.h | 13 +------------ > > android/handsfree-client.c | 15 +-------------- > > android/handsfree-client.h | 15 +-------------- > > android/handsfree.c | 15 +-------------- > > android/handsfree.h | 15 +-------------- > > android/hardware/audio.h | 12 +----------- > > android/hardware/audio_effect.h | 12 +----------- > > android/hardware/bluetooth.h | 12 +----------- > > android/hardware/bt_av.h | 12 +----------- > > android/hardware/bt_gatt.h | 12 +----------- > > android/hardware/bt_gatt_client.h | 12 +----------- > > android/hardware/bt_gatt_server.h | 12 +----------- > > android/hardware/bt_gatt_types.h | 12 +----------- > > android/hardware/bt_hf.h | 12 +----------- > > android/hardware/bt_hf_client.h | 12 +----------- > > android/hardware/bt_hh.h | 12 +----------- > > android/hardware/bt_hl.h | 12 +----------- > > android/hardware/bt_mce.h | 12 +----------- > > android/hardware/bt_pan.h | 12 +----------- > > android/hardware/bt_rc.h | 12 +----------- > > android/hardware/bt_sock.h | 12 +----------- > > android/hardware/hardware.c | 12 +----------- > > android/hardware/hardware.h | 12 +----------- > > android/health.c | 15 +-------------- > > android/health.h | 15 +-------------- > > android/hidhost.c | 15 +-------------- > > android/hidhost.h | 15 +-------------- > > android/ipc-common.h | 15 +-------------- > > android/ipc-tester.c | 15 +-------------- > > android/ipc.c | 15 +-------------- > > android/ipc.h | 15 +-------------- > > android/log.c | 15 +-------------- > > android/main.c | 15 +-------------- > > android/map-client.c | 15 +-------------- > > android/map-client.h | 15 +-------------- > > android/pan.c | 15 +-------------- > > android/pan.h | 15 +-------------- > > android/sco-msg.h | 15 +-------------- > > android/sco.c | 15 +-------------- > > android/sco.h | 15 +-------------- > > android/socket.c | 15 +-------------- > > android/socket.h | 15 +-------------- > > android/system-emulator.c | 15 +-------------- > > android/system/audio.h | 12 +----------- > > android/test-ipc.c | 15 +-------------- > > android/tester-a2dp.c | 13 +------------ > > android/tester-avrcp.c | 13 +------------ > > android/tester-bluetooth.c | 13 +------------ > > android/tester-gatt.c | 13 +------------ > > android/tester-hdp.c | 13 +------------ > > android/tester-hidhost.c | 13 +------------ > > android/tester-main.c | 13 +------------ > > android/tester-main.h | 15 +-------------- > > android/tester-map-client.c | 13 +------------ > > android/tester-pan.c | 13 +------------ > > android/tester-socket.c | 13 +------------ > > android/utils.h | 15 +-------------- > > attrib/att-database.h | 15 +-------------- > > attrib/att.c | 15 +-------------- > > attrib/att.h | 15 +-------------- > > attrib/gatt-service.c | 15 +-------------- > > attrib/gatt-service.h | 15 +-------------- > > attrib/gatt.c | 15 +-------------- > > attrib/gatt.h | 15 +-------------- > > attrib/gattrib.c | 15 +-------------- > > attrib/gattrib.h | 15 +-------------- > > attrib/gatttool.c | 15 +-------------- > > attrib/gatttool.h | 15 +-------------- > > attrib/interactive.c | 15 +-------------- > > attrib/utils.c | 15 +-------------- > > btio/btio.c | 15 +-------------- > > btio/btio.h | 15 +-------------- > > client/advertising.c | 15 +-------------- > > client/advertising.h | 15 +-------------- > > client/agent.c | 15 +-------------- > > client/agent.h | 15 +-------------- > > client/display.c | 15 +-------------- > > client/display.h | 15 +-------------- > > client/gatt.c | 15 +-------------- > > client/gatt.h | 15 +-------------- > > client/main.c | 15 +-------------- > > emulator/amp.c | 15 +-------------- > > emulator/amp.h | 15 +-------------- > > emulator/b1ee.c | 15 +-------------- > > emulator/btdev.c | 15 +-------------- > > emulator/btdev.h | 15 +-------------- > > emulator/bthost.c | 15 +-------------- > > emulator/bthost.h | 15 +-------------- > > emulator/hciemu.c | 15 +-------------- > > emulator/hciemu.h | 15 +-------------- > > emulator/hfp.c | 15 +-------------- > > emulator/le.c | 15 +-------------- > > emulator/le.h | 15 +-------------- > > emulator/main.c | 15 +-------------- > > emulator/phy.c | 15 +-------------- > > emulator/phy.h | 15 +-------------- > > emulator/serial.c | 15 +-------------- > > emulator/serial.h | 15 +-------------- > > emulator/server.c | 15 +-------------- > > emulator/server.h | 15 +-------------- > > emulator/smp.c | 15 +-------------- > > emulator/vhci.c | 15 +-------------- > > emulator/vhci.h | 15 +-------------- > > gdbus/client.c | 15 +-------------- > > gdbus/gdbus.h | 15 +-------------- > > gdbus/mainloop.c | 15 +-------------- > > gdbus/object.c | 15 +-------------- > > gdbus/polkit.c | 15 +-------------- > > gdbus/watch.c | 15 +-------------- > > gobex/gobex-apparam.c | 15 +-------------- > > gobex/gobex-apparam.h | 15 +-------------- > > gobex/gobex-debug.h | 15 +-------------- > > gobex/gobex-defs.c | 15 +-------------- > > gobex/gobex-defs.h | 15 +-------------- > > gobex/gobex-header.c | 15 +-------------- > > gobex/gobex-header.h | 15 +-------------- > > gobex/gobex-packet.c | 15 +-------------- > > gobex/gobex-packet.h | 15 +-------------- > > gobex/gobex-transfer.c | 15 +-------------- > > gobex/gobex.c | 15 +-------------- > > gobex/gobex.h | 15 +-------------- > > lib/a2mp.h | 15 +-------------- > > lib/amp.h | 10 +--------- > > lib/bluetooth.c | 15 +-------------- > > lib/bluetooth.h | 15 +-------------- > > lib/bnep.h | 15 +-------------- > > lib/cmtp.h | 15 +-------------- > > lib/hci.c | 15 +-------------- > > lib/hci.h | 15 +-------------- > > lib/hci_lib.h | 15 +-------------- > > lib/hidp.h | 15 +-------------- > > lib/l2cap.h | 15 +-------------- > > lib/mgmt.h | 15 +-------------- > > lib/rfcomm.h | 15 +-------------- > > lib/sco.h | 15 +-------------- > > lib/sdp.c | 15 +-------------- > > lib/sdp.h | 15 +-------------- > > lib/sdp_lib.h | 15 +-------------- > > lib/uuid.c | 15 +-------------- > > lib/uuid.h | 15 +-------------- > > mesh/agent.c | 11 +---------- > > mesh/agent.h | 11 +---------- > > mesh/appkey.c | 11 +---------- > > mesh/appkey.h | 11 +---------- > > mesh/cfgmod-server.c | 11 +---------- > > mesh/cfgmod.h | 11 +---------- > > mesh/crypto.c | 11 +---------- > > mesh/crypto.h | 11 +---------- > > mesh/dbus.c | 11 +---------- > > mesh/dbus.h | 11 +---------- > > mesh/error.h | 11 +---------- > > mesh/friend.c | 11 +---------- > > mesh/friend.h | 11 +---------- > > mesh/keyring.c | 11 +---------- > > mesh/keyring.h | 11 +---------- > > mesh/main.c | 11 +---------- > > mesh/manager.c | 11 +---------- > > mesh/manager.h | 11 +---------- > > mesh/mesh-config-json.c | 11 +---------- > > mesh/mesh-config.h | 11 +---------- > > mesh/mesh-defs.h | 12 +----------- > > mesh/mesh-io-api.h | 11 +---------- > > mesh/mesh-io-generic.c | 11 +---------- > > mesh/mesh-io-generic.h | 11 +---------- > > mesh/mesh-io.c | 11 +---------- > > mesh/mesh-io.h | 11 +---------- > > mesh/mesh-mgmt.c | 11 +---------- > > mesh/mesh-mgmt.h | 11 +---------- > > mesh/mesh.c | 11 +---------- > > mesh/mesh.h | 11 +---------- > > mesh/model.c | 11 +---------- > > mesh/model.h | 11 +---------- > > mesh/net-keys.c | 11 +---------- > > mesh/net-keys.h | 11 +---------- > > mesh/net.c | 11 +---------- > > mesh/net.h | 11 +---------- > > mesh/node.c | 11 +---------- > > mesh/node.h | 11 +---------- > > mesh/pb-adv.c | 11 +---------- > > mesh/pb-adv.h | 11 +---------- > > mesh/prov-acceptor.c | 11 +---------- > > mesh/prov-initiator.c | 11 +---------- > > mesh/prov.h | 11 +---------- > > mesh/provision.h | 11 +---------- > > mesh/rpl.c | 11 +---------- > > mesh/rpl.h | 11 +---------- > > mesh/util.c | 11 +---------- > > mesh/util.h | 11 +---------- > > monitor/a2dp.c | 15 +-------------- > > monitor/a2dp.h | 15 +-------------- > > monitor/analyze.c | 15 +-------------- > > monitor/analyze.h | 15 +-------------- > > monitor/avctp.c | 15 +-------------- > > monitor/avctp.h | 15 +-------------- > > monitor/avdtp.c | 15 +-------------- > > monitor/avdtp.h | 15 +-------------- > > monitor/bnep.c | 15 +-------------- > > monitor/bnep.h | 15 +-------------- > > monitor/broadcom.c | 15 +-------------- > > monitor/broadcom.h | 15 +-------------- > > monitor/bt.h | 15 +-------------- > > monitor/control.c | 15 +-------------- > > monitor/control.h | 15 +-------------- > > monitor/crc.c | 15 +-------------- > > monitor/crc.h | 15 +-------------- > > monitor/display.c | 15 +-------------- > > monitor/display.h | 15 +-------------- > > monitor/ellisys.c | 15 +-------------- > > monitor/ellisys.h | 15 +-------------- > > monitor/hcidump.c | 15 +-------------- > > monitor/hcidump.h | 15 +-------------- > > monitor/hwdb.c | 15 +-------------- > > monitor/hwdb.h | 15 +-------------- > > monitor/intel.c | 15 +-------------- > > monitor/intel.h | 15 +-------------- > > monitor/jlink.c | 15 +-------------- > > monitor/jlink.h | 15 +-------------- > > monitor/keys.c | 15 +-------------- > > monitor/keys.h | 15 +-------------- > > monitor/l2cap.c | 15 +-------------- > > monitor/l2cap.h | 15 +-------------- > > monitor/ll.c | 15 +-------------- > > monitor/ll.h | 15 +-------------- > > monitor/lmp.c | 15 +-------------- > > monitor/lmp.h | 15 +-------------- > > monitor/main.c | 15 +-------------- > > monitor/packet.c | 15 +-------------- > > monitor/packet.h | 15 +-------------- > > monitor/rfcomm.c | 15 +-------------- > > monitor/rfcomm.h | 15 +-------------- > > monitor/sdp.c | 15 +-------------- > > monitor/sdp.h | 15 +-------------- > > monitor/tty.h | 15 +-------------- > > monitor/vendor.c | 15 +-------------- > > monitor/vendor.h | 15 +-------------- > > obexd/client/bluetooth.c | 15 +-------------- > > obexd/client/bluetooth.h | 15 +-------------- > > obexd/client/driver.c | 15 +-------------- > > obexd/client/driver.h | 15 +-------------- > > obexd/client/ftp.c | 15 +-------------- > > obexd/client/ftp.h | 15 +-------------- > > obexd/client/manager.c | 15 +-------------- > > obexd/client/manager.h | 15 +-------------- > > obexd/client/map-event.c | 15 +-------------- > > obexd/client/map-event.h | 15 +-------------- > > obexd/client/map.c | 15 +-------------- > > obexd/client/map.h | 15 +-------------- > > obexd/client/mns.c | 15 +-------------- > > obexd/client/opp.c | 15 +-------------- > > obexd/client/opp.h | 15 +-------------- > > obexd/client/pbap.c | 15 +-------------- > > obexd/client/pbap.h | 15 +-------------- > > obexd/client/session.c | 15 +-------------- > > obexd/client/session.h | 15 +-------------- > > obexd/client/sync.c | 15 +-------------- > > obexd/client/sync.h | 15 +-------------- > > obexd/client/transfer.c | 15 +-------------- > > obexd/client/transfer.h | 15 +-------------- > > obexd/client/transport.c | 15 +-------------- > > obexd/client/transport.h | 15 +-------------- > > obexd/plugins/bluetooth.c | 15 +-------------- > > obexd/plugins/filesystem.c | 15 +-------------- > > obexd/plugins/filesystem.h | 15 +-------------- > > obexd/plugins/ftp.c | 15 +-------------- > > obexd/plugins/ftp.h | 15 +-------------- > > obexd/plugins/irmc.c | 15 +-------------- > > obexd/plugins/mas.c | 15 +-------------- > > obexd/plugins/messages-dummy.c | 15 +-------------- > > obexd/plugins/messages-tracker.c | 15 +-------------- > > obexd/plugins/messages.h | 15 +-------------- > > obexd/plugins/opp.c | 15 +-------------- > > obexd/plugins/pbap.c | 15 +-------------- > > obexd/plugins/pcsuite.c | 15 +-------------- > > obexd/plugins/phonebook-dummy.c | 15 +-------------- > > obexd/plugins/phonebook-ebook.c | 15 +-------------- > > obexd/plugins/phonebook-tracker.c | 15 +-------------- > > obexd/plugins/phonebook.h | 15 +-------------- > > obexd/plugins/syncevolution.c | 15 +-------------- > > obexd/plugins/vcard.c | 15 +-------------- > > obexd/plugins/vcard.h | 15 +-------------- > > obexd/src/log.c | 15 +-------------- > > obexd/src/log.h | 15 +-------------- > > obexd/src/main.c | 15 +-------------- > > obexd/src/manager.c | 15 +-------------- > > obexd/src/manager.h | 15 +-------------- > > obexd/src/map_ap.h | 15 +-------------- > > obexd/src/mimetype.c | 15 +-------------- > > obexd/src/mimetype.h | 15 +-------------- > > obexd/src/obex-priv.h | 15 +-------------- > > obexd/src/obex.c | 15 +-------------- > > obexd/src/obex.h | 15 +-------------- > > obexd/src/obexd.h | 15 +-------------- > > obexd/src/plugin.c | 15 +-------------- > > obexd/src/plugin.h | 15 +-------------- > > obexd/src/server.c | 15 +-------------- > > obexd/src/server.h | 15 +-------------- > > obexd/src/service.c | 15 +-------------- > > obexd/src/service.h | 15 +-------------- > > obexd/src/transport.c | 15 +-------------- > > obexd/src/transport.h | 15 +-------------- > > peripheral/attach.c | 15 +-------------- > > peripheral/attach.h | 15 +-------------- > > peripheral/efivars.c | 15 +-------------- > > peripheral/efivars.h | 15 +-------------- > > peripheral/gap.c | 15 +-------------- > > peripheral/gap.h | 15 +-------------- > > peripheral/gatt.c | 15 +-------------- > > peripheral/gatt.h | 15 +-------------- > > peripheral/log.c | 15 +-------------- > > peripheral/log.h | 15 +-------------- > > peripheral/main.c | 15 +-------------- > > plugins/autopair.c | 15 +-------------- > > plugins/external-dummy.c | 15 +-------------- > > plugins/hostname.c | 15 +-------------- > > plugins/neard.c | 15 +-------------- > > plugins/policy.c | 15 +-------------- > > plugins/sixaxis.c | 15 +-------------- > > plugins/wiimote.c | 15 +-------------- > > profiles/audio/a2dp-codecs.h | 15 +-------------- > > profiles/audio/a2dp.c | 15 +-------------- > > profiles/audio/a2dp.h | 15 +-------------- > > profiles/audio/avctp.c | 15 +-------------- > > profiles/audio/avctp.h | 15 +-------------- > > profiles/audio/avdtp.c | 15 +-------------- > > profiles/audio/avdtp.h | 15 +-------------- > > profiles/audio/avrcp.c | 15 +-------------- > > profiles/audio/avrcp.h | 15 +-------------- > > profiles/audio/control.c | 15 +-------------- > > profiles/audio/control.h | 15 +-------------- > > profiles/audio/media.c | 15 +-------------- > > profiles/audio/media.h | 15 +-------------- > > profiles/audio/player.c | 15 +-------------- > > profiles/audio/player.h | 15 +-------------- > > profiles/audio/sink.c | 15 +-------------- > > profiles/audio/sink.h | 15 +-------------- > > profiles/audio/source.c | 15 +-------------- > > profiles/audio/source.h | 15 +-------------- > > profiles/audio/transport.c | 15 +-------------- > > profiles/audio/transport.h | 15 +-------------- > > profiles/battery/bas.c | 15 +-------------- > > profiles/battery/bas.h | 15 +-------------- > > profiles/battery/battery.c | 10 +--------- > > profiles/cups/cups.h | 15 +-------------- > > profiles/cups/hcrp.c | 15 +-------------- > > profiles/cups/main.c | 15 +-------------- > > profiles/cups/sdp.c | 15 +-------------- > > profiles/cups/spp.c | 15 +-------------- > > profiles/deviceinfo/deviceinfo.c | 15 +-------------- > > profiles/deviceinfo/dis.c | 15 +-------------- > > profiles/deviceinfo/dis.h | 15 +-------------- > > profiles/gap/gas.c | 10 +--------- > > profiles/health/hdp.c | 15 +-------------- > > profiles/health/hdp.h | 15 +-------------- > > profiles/health/hdp_main.c | 15 +-------------- > > profiles/health/hdp_manager.c | 15 +-------------- > > profiles/health/hdp_manager.h | 15 +-------------- > > profiles/health/hdp_types.h | 15 +-------------- > > profiles/health/hdp_util.c | 15 +-------------- > > profiles/health/hdp_util.h | 15 +-------------- > > profiles/health/mcap.c | 15 +-------------- > > profiles/health/mcap.h | 15 +-------------- > > profiles/iap/main.c | 15 +-------------- > > profiles/input/device.c | 15 +-------------- > > profiles/input/device.h | 15 +-------------- > > profiles/input/hidp_defs.h | 15 +-------------- > > profiles/input/hog-lib.c | 15 +-------------- > > profiles/input/hog-lib.h | 15 +-------------- > > profiles/input/hog.c | 15 +-------------- > > profiles/input/manager.c | 15 +-------------- > > profiles/input/server.c | 15 +-------------- > > profiles/input/server.h | 15 +-------------- > > profiles/input/sixaxis.h | 15 +-------------- > > profiles/input/suspend-dummy.c | 15 +-------------- > > profiles/input/suspend-none.c | 15 +-------------- > > profiles/input/suspend.h | 15 +-------------- > > profiles/midi/libmidi.c | 16 +--------------- > > profiles/midi/libmidi.h | 16 +--------------- > > profiles/midi/midi.c | 20 +------------------- > > profiles/network/bnep.c | 15 +-------------- > > profiles/network/bnep.h | 15 +-------------- > > profiles/network/connection.c | 15 +-------------- > > profiles/network/connection.h | 15 +-------------- > > profiles/network/manager.c | 15 +-------------- > > profiles/network/server.c | 15 +-------------- > > profiles/network/server.h | 15 +-------------- > > profiles/sap/main.c | 14 +------------- > > profiles/sap/manager.c | 14 +------------- > > profiles/sap/manager.h | 14 +------------- > > profiles/sap/sap-dummy.c | 14 +------------- > > profiles/sap/sap.h | 14 +------------- > > profiles/sap/server.c | 14 +------------- > > profiles/sap/server.h | 14 +------------- > > profiles/scanparam/scan.c | 15 +-------------- > > profiles/scanparam/scpp.c | 15 +-------------- > > profiles/scanparam/scpp.h | 15 +-------------- > > src/adapter.c | 15 +-------------- > > src/adapter.h | 15 +-------------- > > src/adv_monitor.c | 11 +---------- > > src/adv_monitor.h | 11 +---------- > > src/advertising.c | 11 +---------- > > src/advertising.h | 11 +---------- > > src/agent.c | 15 +-------------- > > src/agent.h | 15 +-------------- > > src/attrib-server.c | 15 +-------------- > > src/attrib-server.h | 15 +-------------- > > src/backtrace.c | 15 +-------------- > > src/backtrace.h | 15 +-------------- > > src/dbus-common.c | 15 +-------------- > > src/dbus-common.h | 15 +-------------- > > src/device.c | 15 +-------------- > > src/device.h | 15 +-------------- > > src/eir.c | 15 +-------------- > > src/eir.h | 15 +-------------- > > src/error.c | 15 +-------------- > > src/error.h | 15 +-------------- > > src/gatt-client.c | 11 +---------- > > src/gatt-client.h | 11 +---------- > > src/gatt-database.c | 11 +---------- > > src/gatt-database.h | 11 +---------- > > src/hcid.h | 15 +-------------- > > src/log.c | 15 +-------------- > > src/log.h | 15 +-------------- > > src/main.c | 15 +-------------- > > src/oui.c | 15 +-------------- > > src/oui.h | 15 +-------------- > > src/plugin.c | 15 +-------------- > > src/plugin.h | 15 +-------------- > > src/profile.c | 15 +-------------- > > src/profile.h | 15 +-------------- > > src/rfkill.c | 15 +-------------- > > src/sdp-client.c | 15 +-------------- > > src/sdp-client.h | 15 +-------------- > > src/sdp-xml.c | 15 +-------------- > > src/sdp-xml.h | 15 +-------------- > > src/sdpd-database.c | 15 +-------------- > > src/sdpd-request.c | 15 +-------------- > > src/sdpd-server.c | 15 +-------------- > > src/sdpd-service.c | 15 +-------------- > > src/sdpd.h | 15 +-------------- > > src/service.c | 15 +-------------- > > src/service.h | 15 +-------------- > > src/shared/ad.c | 15 +-------------- > > src/shared/ad.h | 15 +-------------- > > src/shared/att-types.h | 15 +-------------- > > src/shared/att.c | 15 +-------------- > > src/shared/att.h | 15 +-------------- > > src/shared/btp.c | 15 +-------------- > > src/shared/btp.h | 15 +-------------- > > src/shared/btsnoop.c | 15 +-------------- > > src/shared/btsnoop.h | 15 +-------------- > > src/shared/crypto.c | 15 +-------------- > > src/shared/crypto.h | 15 +-------------- > > src/shared/ecc.c | 21 +-------------------- > > src/shared/ecc.h | 21 +-------------------- > > src/shared/gap.c | 15 +-------------- > > src/shared/gap.h | 15 +-------------- > > src/shared/gatt-client.c | 15 +-------------- > > src/shared/gatt-client.h | 15 +-------------- > > src/shared/gatt-db.c | 15 +-------------- > > src/shared/gatt-db.h | 15 +-------------- > > src/shared/gatt-helpers.c | 15 +-------------- > > src/shared/gatt-helpers.h | 15 +-------------- > > src/shared/gatt-server.c | 15 +-------------- > > src/shared/gatt-server.h | 15 +-------------- > > src/shared/hci-crypto.c | 15 +-------------- > > src/shared/hci-crypto.h | 15 +-------------- > > src/shared/hci.c | 15 +-------------- > > src/shared/hci.h | 15 +-------------- > > src/shared/hfp.c | 15 +-------------- > > src/shared/hfp.h | 15 +-------------- > > src/shared/io-ell.c | 15 +-------------- > > src/shared/io-glib.c | 15 +-------------- > > src/shared/io-mainloop.c | 15 +-------------- > > src/shared/io.h | 15 +-------------- > > src/shared/log.c | 15 +-------------- > > src/shared/log.h | 15 +-------------- > > src/shared/mainloop-ell.c | 12 +----------- > > src/shared/mainloop-glib.c | 15 +-------------- > > src/shared/mainloop-notify.c | 15 +-------------- > > src/shared/mainloop-notify.h | 15 +-------------- > > src/shared/mainloop.c | 15 +-------------- > > src/shared/mainloop.h | 15 +-------------- > > src/shared/mgmt.c | 15 +-------------- > > src/shared/mgmt.h | 15 +-------------- > > src/shared/pcap.c | 15 +-------------- > > src/shared/pcap.h | 15 +-------------- > > src/shared/queue.c | 15 +-------------- > > src/shared/queue.h | 15 +-------------- > > src/shared/ringbuf.c | 15 +-------------- > > src/shared/ringbuf.h | 15 +-------------- > > src/shared/shell.c | 15 +-------------- > > src/shared/shell.h | 15 +-------------- > > src/shared/tester.c | 15 +-------------- > > src/shared/tester.h | 15 +-------------- > > src/shared/timeout-ell.c | 11 +---------- > > src/shared/timeout-glib.c | 11 +---------- > > src/shared/timeout-mainloop.c | 11 +---------- > > src/shared/timeout.h | 11 +---------- > > src/shared/tty.h | 15 +-------------- > > src/shared/uhid.c | 15 +-------------- > > src/shared/uhid.h | 15 +-------------- > > src/shared/util.c | 15 +-------------- > > src/shared/util.h | 15 +-------------- > > src/storage.c | 15 +-------------- > > src/storage.h | 15 +-------------- > > src/textfile.c | 15 +-------------- > > src/textfile.h | 15 +-------------- > > src/uinput.h | 15 +-------------- > > src/uuid-helper.c | 15 +-------------- > > src/uuid-helper.h | 15 +-------------- > > tools/3dsp.c | 15 +-------------- > > tools/advtest.c | 15 +-------------- > > tools/amptest.c | 15 +-------------- > > tools/avinfo.c | 15 +-------------- > > tools/avtest.c | 15 +-------------- > > tools/bccmd.c | 15 +-------------- > > tools/bcmfw.c | 15 +-------------- > > tools/bdaddr.c | 15 +-------------- > > tools/bluemoon.c | 15 +-------------- > > tools/bluetooth-player.c | 15 +-------------- > > tools/bnep-tester.c | 15 +-------------- > > tools/bneptest.c | 15 +-------------- > > tools/btattach.c | 15 +-------------- > > tools/btconfig.c | 15 +-------------- > > tools/btgatt-client.c | 15 +-------------- > > tools/btgatt-server.c | 11 +---------- > > tools/btinfo.c | 15 +-------------- > > tools/btiotest.c | 15 +-------------- > > tools/btmgmt.c | 15 +-------------- > > tools/btmon-logger.c | 15 +-------------- > > tools/btpclient.c | 15 +-------------- > > tools/btpclientctl.c | 15 +-------------- > > tools/btproxy.c | 15 +-------------- > > tools/btsnoop.c | 15 +-------------- > > tools/check-selftest.c | 15 +-------------- > > tools/ciptool.c | 15 +-------------- > > tools/cltest.c | 15 +-------------- > > tools/create-image.c | 15 +-------------- > > tools/csr.c | 15 +-------------- > > tools/csr.h | 15 +-------------- > > tools/csr_3wire.c | 15 +-------------- > > tools/csr_bcsp.c | 15 +-------------- > > tools/csr_h4.c | 15 +-------------- > > tools/csr_hci.c | 15 +-------------- > > tools/csr_usb.c | 15 +-------------- > > tools/eddystone.c | 15 +-------------- > > tools/gap-tester.c | 15 +-------------- > > tools/gatt-service.c | 15 +-------------- > > tools/hci-tester.c | 15 +-------------- > > tools/hciattach.c | 15 +-------------- > > tools/hciattach.h | 15 +-------------- > > tools/hciattach_ath3k.c | 15 +-------------- > > tools/hciattach_bcm43xx.c | 15 +-------------- > > tools/hciattach_intel.c | 15 +-------------- > > tools/hciattach_qualcomm.c | 15 +-------------- > > tools/hciattach_st.c | 15 +-------------- > > tools/hciattach_ti.c | 15 +-------------- > > tools/hciattach_tialt.c | 15 +-------------- > > tools/hciconfig.c | 15 +-------------- > > tools/hcidump.c | 15 +-------------- > > tools/hcieventmask.c | 15 +-------------- > > tools/hcisecfilter.c | 15 +-------------- > > tools/hcitool.c | 15 +-------------- > > tools/hex2hcd.c | 15 +-------------- > > tools/hid2hci.c | 15 +-------------- > > tools/hwdb.c | 15 +-------------- > > tools/ibeacon.c | 15 +-------------- > > tools/l2cap-tester.c | 15 +-------------- > > tools/l2ping.c | 15 +-------------- > > tools/l2test.c | 15 +-------------- > > tools/mcaptest.c | 15 +-------------- > > tools/mesh-cfgclient.c | 11 +---------- > > tools/mesh-gatt/config-client.c | 15 +-------------- > > tools/mesh-gatt/config-server.c | 15 +-------------- > > tools/mesh-gatt/crypto.c | 15 +-------------- > > tools/mesh-gatt/crypto.h | 15 +-------------- > > tools/mesh-gatt/gatt.c | 15 +-------------- > > tools/mesh-gatt/gatt.h | 15 +-------------- > > tools/mesh-gatt/keys.h | 15 +-------------- > > tools/mesh-gatt/mesh-net.h | 15 +-------------- > > tools/mesh-gatt/net.c | 15 +-------------- > > tools/mesh-gatt/net.h | 15 +-------------- > > tools/mesh-gatt/node.c | 15 +-------------- > > tools/mesh-gatt/node.h | 15 +-------------- > > tools/mesh-gatt/onoff-model.c | 15 +-------------- > > tools/mesh-gatt/onoff-model.h | 15 +-------------- > > tools/mesh-gatt/prov-db.c | 15 +-------------- > > tools/mesh-gatt/prov-db.h | 15 +-------------- > > tools/mesh-gatt/prov.c | 15 +-------------- > > tools/mesh-gatt/prov.h | 15 +-------------- > > tools/mesh-gatt/util.c | 15 +-------------- > > tools/mesh-gatt/util.h | 15 +-------------- > > tools/mesh/agent.c | 15 +-------------- > > tools/mesh/agent.h | 15 +-------------- > > tools/mesh/cfgcli.c | 12 +----------- > > tools/mesh/cfgcli.h | 12 +----------- > > tools/mesh/config-model.h | 15 +-------------- > > tools/mesh/keys.c | 12 +----------- > > tools/mesh/keys.h | 12 +----------- > > tools/mesh/mesh-db.c | 11 +---------- > > tools/mesh/mesh-db.h | 11 +---------- > > tools/mesh/model.h | 12 +----------- > > tools/mesh/remote.c | 11 +---------- > > tools/mesh/remote.h | 11 +---------- > > tools/mesh/util.c | 11 +---------- > > tools/mesh/util.h | 11 +---------- > > tools/meshctl.c | 15 +-------------- > > tools/mgmt-tester.c | 15 +-------------- > > tools/mpris-proxy.c | 15 +-------------- > > tools/nokfw.c | 15 +-------------- > > tools/obex-client-tool.c | 14 +------------- > > tools/obex-server-tool.c | 14 +------------- > > tools/obexctl.c | 15 +-------------- > > tools/oobtest.c | 15 +-------------- > > tools/parser/amp.c | 15 +-------------- > > tools/parser/att.c | 15 +-------------- > > tools/parser/avctp.c | 15 +-------------- > > tools/parser/avdtp.c | 15 +-------------- > > tools/parser/avrcp.c | 15 +-------------- > > tools/parser/bnep.c | 15 +-------------- > > tools/parser/bpa.c | 15 +-------------- > > tools/parser/capi.c | 15 +-------------- > > tools/parser/cmtp.c | 15 +-------------- > > tools/parser/csr.c | 15 +-------------- > > tools/parser/ericsson.c | 15 +-------------- > > tools/parser/hci.c | 15 +-------------- > > tools/parser/hcrp.c | 15 +-------------- > > tools/parser/hidp.c | 15 +-------------- > > tools/parser/l2cap.c | 15 +-------------- > > tools/parser/l2cap.h | 15 +-------------- > > tools/parser/lmp.c | 15 +-------------- > > tools/parser/obex.c | 15 +-------------- > > tools/parser/parser.c | 15 +-------------- > > tools/parser/parser.h | 15 +-------------- > > tools/parser/ppp.c | 15 +-------------- > > tools/parser/rfcomm.c | 15 +-------------- > > tools/parser/rfcomm.h | 15 +-------------- > > tools/parser/sap.c | 15 +-------------- > > tools/parser/sdp.c | 15 +-------------- > > tools/parser/sdp.h | 15 +-------------- > > tools/parser/smp.c | 15 +-------------- > > tools/parser/tcpip.c | 15 +-------------- > > tools/rctest.c | 15 +-------------- > > tools/rfcomm-tester.c | 15 +-------------- > > tools/rfcomm.c | 15 +-------------- > > tools/rtlfw.c | 15 +-------------- > > tools/sco-tester.c | 15 +-------------- > > tools/scotest.c | 15 +-------------- > > tools/sdptool.c | 15 +-------------- > > tools/seq2bseq.c | 15 +-------------- > > tools/smp-tester.c | 15 +-------------- > > tools/test-runner.c | 15 +-------------- > > tools/ubcsp.c | 20 +------------------- > > tools/ubcsp.h | 20 +------------------- > > tools/userchan-tester.c | 15 +-------------- > > unit/test-avctp.c | 15 +-------------- > > unit/test-avdtp.c | 15 +-------------- > > unit/test-avrcp.c | 15 +-------------- > > unit/test-crc.c | 15 +-------------- > > unit/test-crypto.c | 15 +-------------- > > unit/test-ecc.c | 21 +-------------------- > > unit/test-eir.c | 15 +-------------- > > unit/test-gatt.c | 15 +-------------- > > unit/test-gattrib.c | 15 +-------------- > > unit/test-gdbus-client.c | 15 +-------------- > > unit/test-gobex-apparam.c | 15 +-------------- > > unit/test-gobex-header.c | 15 +-------------- > > unit/test-gobex-packet.c | 15 +-------------- > > unit/test-gobex-transfer.c | 15 +-------------- > > unit/test-gobex.c | 15 +-------------- > > unit/test-hfp.c | 15 +-------------- > > unit/test-hog.c | 15 +-------------- > > unit/test-lib.c | 15 +-------------- > > unit/test-mesh-crypto.c | 11 +---------- > > unit/test-mgmt.c | 15 +-------------- > > unit/test-midi.c | 16 +--------------- > > unit/test-queue.c | 15 +-------------- > > unit/test-ringbuf.c | 15 +-------------- > > unit/test-sdp.c | 15 +-------------- > > unit/test-textfile.c | 15 +-------------- > > unit/test-uhid.c | 15 +-------------- > > unit/test-uuid.c | 15 +-------------- > > unit/util.c | 14 +------------- > > unit/util.h | 14 +------------- > > 758 files changed, 758 insertions(+), 10148 deletions(-) > > > -- > pozdrawiam > Szymon Janc > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KOJxFQRFYV9JBgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 00:49:40 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QEtdEgRFYV+TZwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 00:49:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 37E96A0B09; Wed, 16 Sep 2020 00:49:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727507AbgIOWtM (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 18:49:12 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:4730 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727479AbgIOPod (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 11:44:33 -0400 Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 15 Sep 2020 08:43:54 -0700 Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg-lv-alpha.qualcomm.com with ESMTP/TLS/AES256-SHA; 15 Sep 2020 08:43:52 -0700 Received: from gubbaven-linux.qualcomm.com ([10.206.64.32]) by ironmsg02-blr.qualcomm.com with ESMTP; 15 Sep 2020 21:13:28 +0530 Received: by gubbaven-linux.qualcomm.com (Postfix, from userid 2365015) id 7A68421B97; Tue, 15 Sep 2020 21:13:27 +0530 (IST) From: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org, Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Subject: [PATCH v1] Bluetooth: Use NVM files based on SoC ID for WCN3991 Date: Tue, 15 Sep 2020 21:13:25 +0530 Message-Id: <1600184605-31611-1-git-send-email-gubbaven@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.65 / 15.00 / 15.00 X-Rspamd-Queue-Id: 37E96A0B09 X-Rspamd-UID: a87ad1 This change will allow to use different NVM file based on WCN3991 BT SoC ID.Need to use different NVM file based on fab location for WCN3991 BT SoC. Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> --- drivers/bluetooth/btqca.c | 41 +++++++++++++++++++++++++---------------- drivers/bluetooth/btqca.h | 13 ++++++++----- drivers/bluetooth/hci_qca.c | 11 +++++------ 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c index ce9dcff..a7e72f1 100644 --- a/drivers/bluetooth/btqca.c +++ b/drivers/bluetooth/btqca.c @@ -14,12 +14,11 @@ #define VERSION "0.1" -int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, +int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver, enum qca_btsoc_type soc_type) { struct sk_buff *skb; struct edl_event_hdr *edl; - struct qca_btsoc_version *ver; char cmd; int err = 0; u8 event_type = HCI_EV_VENDOR; @@ -70,9 +69,9 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, } if (soc_type >= QCA_WCN3991) - memmove(&edl->data, &edl->data[1], sizeof(*ver)); - - ver = (struct qca_btsoc_version *)(edl->data); + memcpy(ver, &edl->data[1], sizeof(*ver)); + else + memcpy(ver, &edl->data, sizeof(*ver)); bt_dev_info(hdev, "QCA Product ID :0x%08x", le32_to_cpu(ver->product_id)); @@ -83,13 +82,7 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, bt_dev_info(hdev, "QCA Patch Version:0x%08x", le16_to_cpu(ver->patch_ver)); - /* QCA chipset version can be decided by patch and SoC - * version, combination with upper 2 bytes from SoC - * and lower 2 bytes from patch will be used. - */ - *soc_version = (le32_to_cpu(ver->soc_id) << 16) | - (le16_to_cpu(ver->rom_ver) & 0x0000ffff); - if (*soc_version == 0) + if (le32_to_cpu(ver->soc_id) == 0 || le16_to_cpu(ver->rom_ver) == 0) err = -EILSEQ; out: @@ -446,15 +439,25 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome); int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, - enum qca_btsoc_type soc_type, u32 soc_ver, + enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, const char *firmware_name) { struct qca_fw_config config; int err; u8 rom_ver = 0; + u32 soc_ver; bt_dev_dbg(hdev, "QCA setup on UART"); + /* QCA chipset version can be decided by patch and SoC + * version, combination with upper 2 bytes from SoC + * and lower 2 bytes from patch will be used. + */ + soc_ver = (le32_to_cpu(ver.soc_id) << 16) | + (le16_to_cpu(ver.rom_ver) & 0x0000ffff); + + bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); + config.user_baud_rate = baudrate; /* Download rampatch file */ @@ -491,9 +494,15 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, if (firmware_name) snprintf(config.fwname, sizeof(config.fwname), "qca/%s", firmware_name); - else if (qca_is_wcn399x(soc_type)) - snprintf(config.fwname, sizeof(config.fwname), - "qca/crnv%02x.bin", rom_ver); + else if (qca_is_wcn399x(soc_type)) { + if (ver.soc_id == QCA_WCN3991_SOC_ID) { + snprintf(config.fwname, sizeof(config.fwname), + "qca/crnv%02xu.bin", rom_ver); + } else { + snprintf(config.fwname, sizeof(config.fwname), + "qca/crnv%02x.bin", rom_ver); + } + } else if (soc_type == QCA_QCA6390) snprintf(config.fwname, sizeof(config.fwname), "qca/htnv%02x.bin", rom_ver); diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h index d81b74c..d01a9f5 100644 --- a/drivers/bluetooth/btqca.h +++ b/drivers/bluetooth/btqca.h @@ -34,6 +34,8 @@ #define QCA_HCI_CC_OPCODE 0xFC00 #define QCA_HCI_CC_SUCCESS 0x00 +#define QCA_WCN3991_SOC_ID (0x40014320) + enum qca_baudrate { QCA_BAUDRATE_115200 = 0, QCA_BAUDRATE_57600, @@ -136,9 +138,9 @@ enum qca_btsoc_type { int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr); int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, - enum qca_btsoc_type soc_type, u32 soc_ver, + enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, const char *firmware_name); -int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, +int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver, enum qca_btsoc_type); int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); int qca_send_pre_shutdown_cmd(struct hci_dev *hdev); @@ -155,13 +157,14 @@ static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdad } static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, - enum qca_btsoc_type soc_type, u32 soc_ver, - const char *firmware_name) + enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, + const char *firmware_name) { return -EOPNOTSUPP; } -static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, +static inline int qca_read_soc_version(struct hci_dev *hdev, + struct qca_btsoc_version *ver, enum qca_btsoc_type) { return -EOPNOTSUPP; diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 244b8fe..4c32c60 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -1649,7 +1649,7 @@ static int qca_setup(struct hci_uart *hu) enum qca_btsoc_type soc_type = qca_soc_type(hu); const char *firmware_name = qca_get_firmware_name(hu); int ret; - int soc_ver = 0; + struct qca_btsoc_version ver; ret = qca_check_speeds(hu); if (ret) @@ -1678,7 +1678,7 @@ static int qca_setup(struct hci_uart *hu) if (qca_is_wcn399x(soc_type)) { set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks); - ret = qca_read_soc_version(hdev, &soc_ver, soc_type); + ret = qca_read_soc_version(hdev, &ver, soc_type); if (ret) return ret; } else { @@ -1697,15 +1697,14 @@ static int qca_setup(struct hci_uart *hu) if (!qca_is_wcn399x(soc_type)) { /* Get QCA version information */ - ret = qca_read_soc_version(hdev, &soc_ver, soc_type); + ret = qca_read_soc_version(hdev, &ver, soc_type); if (ret) return ret; } - bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); /* Setup patch / NVM configurations */ - ret = qca_uart_setup(hdev, qca_baudrate, soc_type, soc_ver, - firmware_name); + ret = qca_uart_setup(hdev, qca_baudrate, soc_type, ver, + firmware_name); if (!ret) { set_bit(QCA_IBS_ENABLED, &qca->flags); qca_debugfs_init(hdev); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CFfWM29eYV9C6gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 02:38:07 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uIb+MG9eYV91cgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 02:38:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CFB23A013F; Wed, 16 Sep 2020 02:38:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726701AbgIPA1c convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 20:27:32 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:40526 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726775AbgIOOHH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 10:07:07 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 563C7CECEF; Tue, 15 Sep 2020 16:03:57 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v2] Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <c9912094c4627b34f49458ae36c9cd25@codeaurora.org> Date: Tue, 15 Sep 2020 15:57:00 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, open list <linux-kernel@vger.kernel.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, linux-arm-msm@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <A89496D5-1CDD-499E-B167-FA2064BDF1A7@holtmann.org> References: <0101017457c6b819-d1292819-1fae-43af-8fb8-3bc572f53cd5-000000@us-west-2.amazonses.com> <20200914092744.17464-1-rjliao@codeaurora.org> <4FCC6630-8350-4E4A-B156-42B2F3581BFD@holtmann.org> <c9912094c4627b34f49458ae36c9cd25@codeaurora.org> To: Rocky Liao <rjliao@codeaurora.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.28 / 15.00 / 15.00 X-Rspamd-Queue-Id: CFB23A013F X-Rspamd-UID: c04e11 Hi Rocky, >>> This patch add support for WCN6855 i.e. patch and nvm download >>> support. >>> Signed-off-by: Rocky Liao <rjliao@codeaurora.org> >>> --- >>> drivers/bluetooth/btusb.c | 50 ++++++++++++++++++++++++++++++++++----- >>> 1 file changed, 44 insertions(+), 6 deletions(-) >>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c >>> index fe80588c7bd3..789e8d5e829e 100644 >>> --- a/drivers/bluetooth/btusb.c >>> +++ b/drivers/bluetooth/btusb.c >>> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver; >>> #define BTUSB_MEDIATEK 0x200000 >>> #define BTUSB_WIDEBAND_SPEECH 0x400000 >>> #define BTUSB_VALID_LE_STATES 0x800000 >>> +#define BTUSB_QCA_WCN6855 0x1000000 >>> static const struct usb_device_id btusb_table[] = { >>> /* Generic Bluetooth USB device */ >>> @@ -273,6 +274,10 @@ static const struct usb_device_id blacklist_table[] = { >>> { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME }, >>> { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME }, >>> + /* QCA WCN6855 chipset */ >>> + { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 | >>> + BTUSB_WIDEBAND_SPEECH }, >>> + >>> /* Broadcom BCM2035 */ >>> { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, >>> { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU }, >>> @@ -3391,6 +3396,26 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev, >>> return 0; >>> } >>> +static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev, >>> + const bdaddr_t *bdaddr) >>> +{ >>> + struct sk_buff *skb; >>> + u8 buf[6]; >>> + long ret; >>> + >>> + memcpy(buf, bdaddr, sizeof(bdaddr_t)); >>> + >>> + skb = __hci_cmd_sync(hdev, 0xfc14, sizeof(buf), buf, HCI_INIT_TIMEOUT); >>> + if (IS_ERR(skb)) { >>> + ret = PTR_ERR(skb); >>> + bt_dev_err(hdev, "Change address command failed (%ld)", ret); >>> + return ret; >>> + } >>> + kfree_skb(skb); >>> + >>> + return 0; >>> +} >>> + >>> #define QCA_DFU_PACKET_LEN 4096 >>> #define QCA_GET_TARGET_VERSION 0x09 >>> @@ -3428,6 +3453,8 @@ static const struct qca_device_info qca_devices_table[] = { >>> { 0x00000201, 28, 4, 18 }, /* Rome 2.1 */ >>> { 0x00000300, 28, 4, 18 }, /* Rome 3.0 */ >>> { 0x00000302, 28, 4, 18 }, /* Rome 3.2 */ >>> + { 0x00130100, 40, 4, 18 }, /* WCN6855 1.0 */ >>> + { 0x00130200, 40, 4, 18 } /* WCN6855 2.0 */ >>> }; >>> static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request, >>> @@ -3529,8 +3556,8 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, >>> { >>> struct qca_rampatch_version *rver; >>> const struct firmware *fw; >>> - u32 ver_rom, ver_patch; >>> - u16 rver_rom, rver_patch; >>> + u32 ver_rom, ver_patch, rver_rom; >>> + u16 rver_rom_low, rver_rom_high, rver_patch; >>> char fwname[64]; >>> int err; >>> @@ -3549,9 +3576,16 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, >>> bt_dev_info(hdev, "using rampatch file: %s", fwname); >>> rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset); >>> - rver_rom = le16_to_cpu(rver->rom_version); >>> + rver_rom_low = le16_to_cpu(rver->rom_version); >>> rver_patch = le16_to_cpu(rver->patch_version); >>> + if (ver_rom & ~0xffffU) { >>> + rver_rom_high = le16_to_cpu(*(__le16 *)(fw->data + 16)); >>> + rver_rom = le32_to_cpu(rver_rom_high << 16 | rver_rom_low); >>> + } else { >>> + rver_rom = (__force u32)rver_rom_low; >>> + } >>> + >> I don’t get this. Is anything wrong with get_unaligned_le32 etc.? >> My brain just hurts with your casting and pointer magic. Maybe the >> whole rver logic needs a clean up first. > It's not a 4 bytes le data, for example the version stream is 0x13, 0x00, 0x00, 0x01 and we need to convert it to 0x00130100. So we have to convert it to 2 u16 value then combine them to a u32. what is it then? Is it big endian formatted. If it is not a 32-bit value, then don’t store it as one. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GMp8MlJyYV/7BgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 04:02:58 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AAtwL1JyYV8J/QAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 04:02:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=mg.codeaurora.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 75BCAA0161; Wed, 16 Sep 2020 04:02:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726254AbgIPCCu (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 15 Sep 2020 22:02:50 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:31102 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbgIPCCt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 15 Sep 2020 22:02:49 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1600221768; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=Ip2VN/FNmvU+7orc2a6pZAYO/+IWNOcQEXEYPx0uFJM=; b=HyhmVcTDo9skeQ+KNby4XXVD84qbqxJ2BU554OCr91VuDH5iF8zgI9+l6UCepNpVGN1WQd14 1gkMPWSFBpWoAUllnodBE9lakTh7t+O9Lfa1QXFSMGMWzoCqGHk+FTk7GUCcy5Y0Ti9zP8b5 l8UOEkIVq/TyUuq+H7fMUB0yE5U= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI2MTA3ZSIsICJsaW51eC1ibHVldG9vdGhAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-east-1.postgun.com with SMTP id 5f617247238e1efa37cf6305 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 16 Sep 2020 02:02:47 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 0D02CC433FE; Wed, 16 Sep 2020 02:02:47 +0000 (UTC) Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: rjliao) by smtp.codeaurora.org (Postfix) with ESMTPSA id 85A11C433C8; Wed, 16 Sep 2020 02:02:46 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Wed, 16 Sep 2020 10:02:46 +0800 From: Rocky Liao <rjliao@codeaurora.org> To: Marcel Holtmann <marcel@holtmann.org> Cc: Johan Hedberg <johan.hedberg@gmail.com>, open list <linux-kernel@vger.kernel.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, linux-arm-msm@vger.kernel.org, linux-bluetooth-owner@vger.kernel.org Subject: Re: [PATCH v2] Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support In-Reply-To: <A89496D5-1CDD-499E-B167-FA2064BDF1A7@holtmann.org> References: <0101017457c6b819-d1292819-1fae-43af-8fb8-3bc572f53cd5-000000@us-west-2.amazonses.com> <20200914092744.17464-1-rjliao@codeaurora.org> <4FCC6630-8350-4E4A-B156-42B2F3581BFD@holtmann.org> <c9912094c4627b34f49458ae36c9cd25@codeaurora.org> <A89496D5-1CDD-499E-B167-FA2064BDF1A7@holtmann.org> Message-ID: <212f6f38e3279dbaa6d5593f2260a0c9@codeaurora.org> X-Sender: rjliao@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.84 / 15.00 / 15.00 X-Rspamd-Queue-Id: 75BCAA0161 X-Rspamd-UID: d8be55 Hi Marcel, 在 2020-09-15 21:57,Marcel Holtmann 写道: > Hi Rocky, > >>>> This patch add support for WCN6855 i.e. patch and nvm download >>>> support. >>>> Signed-off-by: Rocky Liao <rjliao@codeaurora.org> >>>> --- >>>> drivers/bluetooth/btusb.c | 50 >>>> ++++++++++++++++++++++++++++++++++----- >>>> 1 file changed, 44 insertions(+), 6 deletions(-) >>>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c >>>> index fe80588c7bd3..789e8d5e829e 100644 >>>> --- a/drivers/bluetooth/btusb.c >>>> +++ b/drivers/bluetooth/btusb.c >>>> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver; >>>> #define BTUSB_MEDIATEK 0x200000 >>>> #define BTUSB_WIDEBAND_SPEECH 0x400000 >>>> #define BTUSB_VALID_LE_STATES 0x800000 >>>> +#define BTUSB_QCA_WCN6855 0x1000000 >>>> static const struct usb_device_id btusb_table[] = { >>>> /* Generic Bluetooth USB device */ >>>> @@ -273,6 +274,10 @@ static const struct usb_device_id >>>> blacklist_table[] = { >>>> { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME }, >>>> { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME }, >>>> + /* QCA WCN6855 chipset */ >>>> + { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 | >>>> + BTUSB_WIDEBAND_SPEECH }, >>>> + >>>> /* Broadcom BCM2035 */ >>>> { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, >>>> { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU }, >>>> @@ -3391,6 +3396,26 @@ static int btusb_set_bdaddr_ath3012(struct >>>> hci_dev *hdev, >>>> return 0; >>>> } >>>> +static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev, >>>> + const bdaddr_t *bdaddr) >>>> +{ >>>> + struct sk_buff *skb; >>>> + u8 buf[6]; >>>> + long ret; >>>> + >>>> + memcpy(buf, bdaddr, sizeof(bdaddr_t)); >>>> + >>>> + skb = __hci_cmd_sync(hdev, 0xfc14, sizeof(buf), buf, >>>> HCI_INIT_TIMEOUT); >>>> + if (IS_ERR(skb)) { >>>> + ret = PTR_ERR(skb); >>>> + bt_dev_err(hdev, "Change address command failed (%ld)", ret); >>>> + return ret; >>>> + } >>>> + kfree_skb(skb); >>>> + >>>> + return 0; >>>> +} >>>> + >>>> #define QCA_DFU_PACKET_LEN 4096 >>>> #define QCA_GET_TARGET_VERSION 0x09 >>>> @@ -3428,6 +3453,8 @@ static const struct qca_device_info >>>> qca_devices_table[] = { >>>> { 0x00000201, 28, 4, 18 }, /* Rome 2.1 */ >>>> { 0x00000300, 28, 4, 18 }, /* Rome 3.0 */ >>>> { 0x00000302, 28, 4, 18 }, /* Rome 3.2 */ >>>> + { 0x00130100, 40, 4, 18 }, /* WCN6855 1.0 */ >>>> + { 0x00130200, 40, 4, 18 } /* WCN6855 2.0 */ >>>> }; >>>> static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 >>>> request, >>>> @@ -3529,8 +3556,8 @@ static int >>>> btusb_setup_qca_load_rampatch(struct hci_dev *hdev, >>>> { >>>> struct qca_rampatch_version *rver; >>>> const struct firmware *fw; >>>> - u32 ver_rom, ver_patch; >>>> - u16 rver_rom, rver_patch; >>>> + u32 ver_rom, ver_patch, rver_rom; >>>> + u16 rver_rom_low, rver_rom_high, rver_patch; >>>> char fwname[64]; >>>> int err; >>>> @@ -3549,9 +3576,16 @@ static int >>>> btusb_setup_qca_load_rampatch(struct hci_dev *hdev, >>>> bt_dev_info(hdev, "using rampatch file: %s", fwname); >>>> rver = (struct qca_rampatch_version *)(fw->data + >>>> info->ver_offset); >>>> - rver_rom = le16_to_cpu(rver->rom_version); >>>> + rver_rom_low = le16_to_cpu(rver->rom_version); >>>> rver_patch = le16_to_cpu(rver->patch_version); >>>> + if (ver_rom & ~0xffffU) { >>>> + rver_rom_high = le16_to_cpu(*(__le16 *)(fw->data + 16)); >>>> + rver_rom = le32_to_cpu(rver_rom_high << 16 | rver_rom_low); >>>> + } else { >>>> + rver_rom = (__force u32)rver_rom_low; >>>> + } >>>> + >>> I don’t get this. Is anything wrong with get_unaligned_le32 etc.? >>> My brain just hurts with your casting and pointer magic. Maybe the >>> whole rver logic needs a clean up first. >> It's not a 4 bytes le data, for example the version stream is 0x13, >> 0x00, 0x00, 0x01 and we need to convert it to 0x00130100. So we have >> to convert it to 2 u16 value then combine them to a u32. > > what is it then? Is it big endian formatted. If it is not a 32-bit > value, then don’t store it as one. > OK, let me refine the patch to a more readable format. > Regards > > Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aA6dCvu7YV99LgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 09:17:15 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wAcOB/u7YV/RCwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 09:17:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 07CD540964; Wed, 16 Sep 2020 09:17:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726210AbgIPHRE (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 03:17:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726068AbgIPHRD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 03:17:03 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1602AC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 00:17:03 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id e28so3349167pgm.15 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 00:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=cWZeVLgiIS+2wh6pBORQRboLsHbieihMlsn38o9JgxU=; b=QjneQPVOkaCrXizWoqvlhAmstEUYm+MuZh0J4TLQQhVyFeSirGp5lrMIfri9spzN/c dt5DmwhTstfcXbO3ufFEvqGVc/e0jCwORj5DkZOu0nDRw0CCfuAw2C981jI9YQ3p7Yj7 InMsd+nn7B9HYeXoY0XuP+UprN1lSnQBMNbTo7GFjQRx95eSvBpaeMeXDGAxpOfkV9IO Dqa6/B5r2mTUHQtJIIgoL2tsjmmKK7G2pCxDSPUvz4VN0nGf08h9osxPQ6LPEB3/E7PX l4pgG6xoMxDIf5di5WS7bTJRbGyhmuuzCqyhOFNND+UUZP5k9j0RRYLgiKMjHNqVdM/3 95bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=cWZeVLgiIS+2wh6pBORQRboLsHbieihMlsn38o9JgxU=; b=FQSe+U6uV4cFFuZ8KYHJ4CFsdSbPrxwpiv9Siu0fJnkKU0Xx33SCdtW59/Zs26vDJo v49QQuPiuAhJZ/tfJ9k/Yxy8ESsZUTeGmemF4vjhRm5luc9uVd7mcDRGm5cQ6SlEsl5G 4awX619tmtzCSivZKIHEQPgJgNq0uBb9hmsm8D0dG83fLQEkIPmd0oAhKk319B/l4oRu xPBpZPvLaed4FMY0rpyZLoCAMXlWnYq65Z+qqSd/4NVWqVx42UXSWBfHNpr8kQwCEC3w 1D/fFQAi2EMJtlO+IeqOG78wgl1BN1/sN0dBVe6cf7GiFfX3zSoCZ2qIO1jEDNySmZb3 ZDDA== X-Gm-Message-State: AOAM530ZgptzOkmWj9jwx2XXr3L/M3lS2RWRSTM3Iy663+f9lE9gbQ12 8KZdHP7zfS7Lo+Y0kQytYePayCJR0WWhs5QnKWtNtGKsIvg+FXu2PALmXaCr+58lQTyJRBd2wBD smiDQXQlCFjRBi1d6rdsrfCt8nlfhNUJjweEeblJhuTjqdEu6E+1eL8K3yUOAtKJCzvHEeHM4+E nY+o/YFNF64Ns= X-Google-Smtp-Source: ABdhPJw9+po2UXCtmownjpx6rPsHH1kjExY3SLKPFXHtyU6NGF/1e119Xw/6EhYeGqqc3X8Tfl34XLXkqyMESEhboA== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:90b:941:: with SMTP id dw1mr299106pjb.1.1600240621957; Wed, 16 Sep 2020 00:17:01 -0700 (PDT) Date: Wed, 16 Sep 2020 15:16:49 +0800 Message-Id: <20200916151617.BlueZ.v5.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v5 1/4] client: Implement basic interface of ADV monitor in bluetoothctl From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, mmandlik@chromium.org, mcchou@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.15 / 15.00 / 15.00 X-Rspamd-Queue-Id: 07CD540964 X-Rspamd-UID: 10bda2 This patch implements some basic functions for ADV monitor in bluetoothctl [bluetooth]# show ... Advertisement Monitor Features: SupportedMonitorTypes: or_patterns Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v5: - Rephrase condition == TRUE/FALSE to condition/!condition - Add bt_shell_noninteractive_quit(EXIT_SUCCESS) in register_reply - Remove unused variable 'conn' - Move a change regarding checking the status of app registered from patch 2/4 to 1/4 Changes in v4: - Remove PRE-UPSTREAM in commit title Changes in v3: - Rename advertisement_monitor to adv_monitor Changes in v2: - Update the add-pattern usage - Fix styling issue in patch 1 - Fix storage class declaration issue Makefile.tools | 2 + client/adv_monitor.c | 165 +++++++++++++++++++++++++++++++++++++++++++ client/adv_monitor.h | 23 ++++++ client/main.c | 28 ++++++++ 4 files changed, 218 insertions(+) create mode 100644 client/adv_monitor.c create mode 100644 client/adv_monitor.h diff --git a/Makefile.tools b/Makefile.tools index 9b9236609..ed0fbf8a3 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -7,6 +7,8 @@ client_bluetoothctl_SOURCES = client/main.c \ client/agent.h client/agent.c \ client/advertising.h \ client/advertising.c \ + client/adv_monitor.h \ + client/adv_monitor.c \ client/gatt.h client/gatt.c client_bluetoothctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \ $(GLIB_LIBS) $(DBUS_LIBS) -lreadline diff --git a/client/adv_monitor.c b/client/adv_monitor.c new file mode 100644 index 000000000..dda0eaf90 --- /dev/null +++ b/client/adv_monitor.c @@ -0,0 +1,165 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdbool.h> +#include <string.h> + +#include "gdbus/gdbus.h" +#include "src/shared/util.h" +#include "src/shared/shell.h" +#include "adv_monitor.h" + +#define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" + +static struct adv_monitor_manager { + GSList *supported_types; + GSList *supported_features; + GDBusProxy *proxy; + gboolean app_registered; +} manager = { NULL, NULL, NULL, FALSE }; + +static void set_supported_list(GSList **list, DBusMessageIter *iter) +{ + char *str; + DBusMessageIter subiter; + + dbus_message_iter_recurse(iter, &subiter); + while (dbus_message_iter_get_arg_type(&subiter) == + DBUS_TYPE_STRING) { + dbus_message_iter_get_basic(&subiter, &str); + *list = g_slist_append(*list, str); + dbus_message_iter_next(&subiter); + } +} + +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy) +{ + DBusMessageIter iter; + + if (manager.proxy != NULL || manager.supported_types != NULL || + manager.supported_features != NULL) { + bt_shell_printf("advertisement monitor manager already " + "added\n"); + return; + } + + manager.proxy = proxy; + + if (g_dbus_proxy_get_property(proxy, "SupportedMonitorTypes", &iter)) + set_supported_list(&(manager.supported_types), &iter); + + if (g_dbus_proxy_get_property(proxy, "SupportedFeatures", &iter)) + set_supported_list(&(manager.supported_features), &iter); + +} + +void adv_monitor_remove_manager(DBusConnection *conn) +{ + if (manager.supported_types != NULL) + g_slist_free(g_steal_pointer(&(manager.supported_types))); + if (manager.supported_features != NULL) + g_slist_free(g_steal_pointer(&(manager.supported_features))); + manager.proxy = NULL; + manager.app_registered = FALSE; +} + +static void register_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = ADV_MONITOR_APP_PATH; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +static void register_reply(DBusMessage *message, void *user_data) +{ + DBusError error; + + dbus_error_init(&error); + + if (!dbus_set_error_from_message(&error, message)) { + bt_shell_printf("AdvertisementMonitor path registered\n"); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + bt_shell_printf("Failed to register path: %s\n", error.name); + dbus_error_free(&error); + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + +static void unregister_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = ADV_MONITOR_APP_PATH; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +static void unregister_reply(DBusMessage *message, void *user_data) +{ + DBusError error; + + dbus_error_init(&error); + + if (!dbus_set_error_from_message(&error, message)) { + bt_shell_printf("AdvertisementMonitor path unregistered\n"); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + bt_shell_printf("Failed to unregister Advertisement Monitor:" + " %s\n", error.name); + dbus_error_free(&error); + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + +void adv_monitor_register_app(DBusConnection *conn) +{ + if (manager.app_registered) { + bt_shell_printf("Advertisement Monitor already registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } else if (manager.supported_types == NULL || + !g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", + register_setup, register_reply, + NULL, NULL)) { + bt_shell_printf("Failed to register Advertisement Monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + manager.app_registered = TRUE; +} + +void adv_monitor_unregister_app(DBusConnection *conn) +{ + if (!manager.app_registered) { + bt_shell_printf("Advertisement Monitor not registered\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } else if (!g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", + unregister_setup, unregister_reply, + NULL, NULL)) { + bt_shell_printf("Failed to unregister Advertisement Monitor\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + manager.app_registered = FALSE; +} diff --git a/client/adv_monitor.h b/client/adv_monitor.h new file mode 100644 index 000000000..77b0b62c6 --- /dev/null +++ b/client/adv_monitor.h @@ -0,0 +1,23 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); +void adv_monitor_remove_manager(DBusConnection *conn); +void adv_monitor_register_app(DBusConnection *conn); +void adv_monitor_unregister_app(DBusConnection *conn); diff --git a/client/main.c b/client/main.c index da877b546..75f8bc462 100644 --- a/client/main.c +++ b/client/main.c @@ -41,6 +41,7 @@ #include "agent.h" #include "gatt.h" #include "advertising.h" +#include "adv_monitor.h" /* String display constants */ #define COLORED_NEW COLOR_GREEN "NEW" COLOR_OFF @@ -58,6 +59,7 @@ static char *auto_register_agent = NULL; struct adapter { GDBusProxy *proxy; GDBusProxy *ad_proxy; + GDBusProxy *adv_monitor_proxy; GList *devices; }; @@ -528,6 +530,19 @@ static void ad_manager_added(GDBusProxy *proxy) adapter->ad_proxy = proxy; } +static void admon_manager_added(GDBusProxy *proxy) +{ + struct adapter *adapter; + + adapter = find_ctrl(ctrl_list, g_dbus_proxy_get_path(proxy)); + if (!adapter) + adapter = adapter_new(proxy); + + adapter->adv_monitor_proxy = proxy; + adv_monitor_add_manager(dbus_conn, proxy); + adv_monitor_register_app(dbus_conn); +} + static void proxy_added(GDBusProxy *proxy, void *user_data) { const char *interface; @@ -560,6 +575,9 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) ad_manager_added(proxy); } else if (!strcmp(interface, "org.bluez.Battery1")) { battery_added(proxy); + } else if (!strcmp(interface, + "org.bluez.AdvertisementMonitorManager1")) { + admon_manager_added(proxy); } } @@ -653,6 +671,9 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) ad_unregister(dbus_conn, NULL); } else if (!strcmp(interface, "org.bluez.Battery1")) { battery_removed(proxy); + } else if (!strcmp(interface, + "org.bluez.AdvertisementMonitorManager1")) { + adv_monitor_remove_manager(dbus_conn); } } @@ -935,6 +956,13 @@ static void cmd_show(int argc, char *argv[]) print_property(adapter->ad_proxy, "SupportedSecondaryChannels"); } + if (adapter->adv_monitor_proxy) { + bt_shell_printf("Advertisement Monitor Features:\n"); + print_property(adapter->adv_monitor_proxy, + "SupportedMonitorTypes"); + print_property(adapter->adv_monitor_proxy, "SupportedFeatures"); + } + return bt_shell_noninteractive_quit(EXIT_SUCCESS); } -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2EHBHwW8YV9Q+gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 09:17:25 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QKuOHAW8YV+O0QEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 09:17:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B2DCD40981; Wed, 16 Sep 2020 09:17:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbgIPHRM (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 03:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726068AbgIPHRI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 03:17:08 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0D55C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 00:17:07 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id u6so5360292qte.8 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 00:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=/sZaUwkMRhy5nGDqEj/npb5gumg8a9ZMAwv0bXjQQfY=; b=itClPvXihlayARe++RPVG8CSXs69gWYE2L3+mgHIq1X7FQgMCfvACy2YL02SCbFMpe VCp2ZFLHujKhbT0ddlq0PyaJZXhVT4oDfd/pqiKM9/Ic40YAk/jDcw/zDQ7dBBYxtUvU oqDKdxLr6QjN1ZVO/JPsT6THzU9SwAVwY5TSU3mE0IT1odVLqm9kG/migWkfolzz94eq mYOFZJTf9w1zpMHV3T/NX10uuUllbaV4SJCYmd6bUCLmcA73Z1SnpUeh6VjQffB4Vhaq dbaocYkcr7kr2s9IL7/5hMMLCwBOVhWrQR86tsNdz4t8r9gwcurwA5qoyQurHM30qaBB 6BEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/sZaUwkMRhy5nGDqEj/npb5gumg8a9ZMAwv0bXjQQfY=; b=s+hP33AoOsAFloIHaOJRR4PyLfRMAlrfwohywqZGjz9NnZgQiQOnC1lV9+CYPZpdHm FFykgVQYXXsW28AXQ0rJkR2C00WUOyN8IEAdosNm8w1Rsdo7J4gkETLfGMDFz1mchpMK Mf6CRKv6xE0tycWUt8BHbjZqaeJzuj+WeyTi9tWbMQA9O4MA0K+u75+fsM1XivSMAADL T4sIG5eA0iPXI8hclpUKvIHI1fdL4Oiegd5dr8tYUrXDEDI+WNxHsH894Na3mp4+2CvZ b2WjPk/FXG2z/pioa89o2XNHxGzRggkImwUIwiYgarTLCX30c8ZLeB+tiUAwtbDYQ4g0 pwxg== X-Gm-Message-State: AOAM530FH82GE2Cw0kkq5+6OhiBCPck4aCbS0vklK9celF1FFOzF5mIk bYYDQL3JNC1U4pnr/dNiT50GOd3w3clonblT+kPYErkpBgesD+4lFXu8MKxU5rcfXPH7FpoDcht zb/eaHzqnsJEXVsCJ29eEoO9KYesRMrFv34yMxycqyRgJsBuqYEAadmF4tF16SaC9RzeGprEaec ig7e8GOZOIi8k= X-Google-Smtp-Source: ABdhPJxrkoph8jzWjPDbb2/sxrKWgQVECfA7gaDehYfzSyRzx5/7w/AMJaG5xkAcTHmJ5HHogEQCq0GfneaOwKwFMA== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:5387:: with SMTP id i7mr5454479qvv.43.1600240625860; Wed, 16 Sep 2020 00:17:05 -0700 (PDT) Date: Wed, 16 Sep 2020 15:16:50 +0800 In-Reply-To: <20200916151617.BlueZ.v5.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> Message-Id: <20200916151617.BlueZ.v5.2.Iec6b15e23f4228b80f9b364eb76515d146d592d5@changeid> Mime-Version: 1.0 References: <20200916151617.BlueZ.v5.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v5 2/4] client: Implement more interfaces of ADV monitor in bluetoothctl From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, mmandlik@chromium.org, mcchou@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.15 / 15.00 / 15.00 X-Rspamd-Queue-Id: B2DCD40981 X-Rspamd-UID: 8e0935 This patch creates a submenu in bluetoothctl and implements several commands. new commands: [bluetooth]# menu monitor [bluetooth]# add-or-pattern 1 2 ab0011 Advertisement Monitor 0 added [bluetooth]# add-or-pattern-rssi -80, ,5 1 2 aa 3 4 ff Advertisement Monitor 1 added [bluetooth]# get-pattern all Advertisement Monitor 0 path: /org/bluez/adv_monitor_app/0 type: or_patterns pattern 1: start position: 1 AD data type: 2 content: ab0011 Advertisement Monitor 1 path: /org/bluez/adv_monitor_app/1 type: or_patterns rssi: high threshold: -50 high threshold timer: 5 low threshold: -80 low threshold timer: 5 pattern 1: start position: 1 AD data type: 2 content: aa pattern 2: start position: 3 AD data type: 4 content: ff [bluetooth]# get-supported-info Supported Features: Supported Moniter Types: or_patterns [bluetooth]# remove-pattern 0 Monitor 0 deleted Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v5: - Move a change regarding checking the status of app registered to patch 1/4 Changes in v4: - Remove PRE-UPSTREAM in commit title Changes in v2: - Update the add-pattern usage client/adv_monitor.c | 341 +++++++++++++++++++++++++++++++++++++++++++ client/adv_monitor.h | 10 ++ client/main.c | 109 ++++++++++++++ 3 files changed, 460 insertions(+) diff --git a/client/adv_monitor.c b/client/adv_monitor.c index dda0eaf90..d4914b7b1 100644 --- a/client/adv_monitor.c +++ b/client/adv_monitor.c @@ -29,6 +29,7 @@ #include <string.h> #include "gdbus/gdbus.h" +#include "src/shared/ad.h" #include "src/shared/util.h" #include "src/shared/shell.h" #include "adv_monitor.h" @@ -36,6 +37,27 @@ #define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" +struct rssi_setting { + int16_t high_threshold; + uint16_t high_timer; + int16_t low_threshold; + uint16_t low_timer; +}; + +struct pattern { + uint8_t start_pos; + uint8_t ad_data_type; + uint8_t content_len; + uint8_t content[BT_AD_MAX_DATA_LEN]; +}; + +struct adv_monitor { + uint8_t idx; + char *type; + struct rssi_setting *rssi; + GSList *patterns; +}; + static struct adv_monitor_manager { GSList *supported_types; GSList *supported_features; @@ -43,6 +65,9 @@ static struct adv_monitor_manager { gboolean app_registered; } manager = { NULL, NULL, NULL, FALSE }; +static uint8_t adv_mon_idx; +static GSList *adv_mons; + static void set_supported_list(GSList **list, DBusMessageIter *iter) { char *str; @@ -163,3 +188,319 @@ void adv_monitor_unregister_app(DBusConnection *conn) } manager.app_registered = FALSE; } + +static void free_pattern(void *user_data) +{ + struct pattern *p = user_data; + + g_free(p); +} + +static void free_adv_monitor(void *user_data) +{ + struct adv_monitor *adv_monitor = user_data; + + g_free(adv_monitor->type); + g_free(adv_monitor->rssi); + g_slist_free_full(adv_monitor->patterns, free_pattern); + g_free(adv_monitor); +} + +static uint8_t str2bytearray(char *str, uint8_t *arr) +{ + int idx, len = strlen(str), arr_len = 0; + + if (len%2 != 0) + return 0; + + for (idx = 0; idx < len; idx += 2) { + if (sscanf(str+idx, "%2hhx", &arr[arr_len++]) < 1) + return 0; + } + return arr_len; +} + +static void parse_rssi_value_pair(char *value_pair, int *low, int *high) +{ + char *val1, *val2; + bool flag = value_pair[0] == ','; + + val1 = strtok(value_pair, ","); + + if (!val1) + return; + + val2 = strtok(NULL, ","); + + if (!val2) { + if (!flag) + *low = atoi(val1); + else + *high = atoi(val1); + } else { + *low = atoi(val1); + *high = atoi(val2); + } +} + +static struct rssi_setting *parse_rssi(char *range, char *timeout) +{ + struct rssi_setting *rssi; + int high_threshold, low_threshold, high_timer, low_timer; + + high_threshold = RSSI_DEFAULT_HIGH_THRESHOLD; + low_threshold = RSSI_DEFAULT_LOW_THRESHOLD; + high_timer = RSSI_DEFAULT_HIGH_TIMEOUT; + low_timer = RSSI_DEFAULT_LOW_TIMEOUT; + + parse_rssi_value_pair(range, &low_threshold, &high_threshold); + parse_rssi_value_pair(timeout, &low_timer, &high_timer); + + rssi = g_malloc0(sizeof(struct rssi_setting)); + + if (!rssi) { + bt_shell_printf("Failed to allocate rssi_setting"); + bt_shell_noninteractive_quit(EXIT_FAILURE); + return NULL; + } + + rssi->high_threshold = high_threshold; + rssi->high_timer = high_timer; + rssi->low_threshold = low_threshold; + rssi->low_timer = low_timer; + + return rssi; +} + +static struct pattern *parse_pattern(char *parameter_list[]) +{ + struct pattern *pat; + + pat = g_malloc0(sizeof(struct pattern)); + + if (!pat) { + bt_shell_printf("Failed to allocate pattern"); + bt_shell_noninteractive_quit(EXIT_FAILURE); + return NULL; + } + + pat->start_pos = atoi(parameter_list[0]); + pat->ad_data_type = atoi(parameter_list[1]); + pat->content_len = str2bytearray(parameter_list[2], pat->content); + if (pat->content_len == 0) { + free_pattern(pat); + return NULL; + } + + return pat; +} + +static GSList *parse_patterns(char *pattern_list[], int num) +{ + GSList *patterns = NULL; + int cnt; + + if (num == 0) { + bt_shell_printf("No pattern provided\n"); + return NULL; + } + + if (num%3) { + bt_shell_printf("Expected %d more arguments\n", 3 - num%3); + return NULL; + } + + for (cnt = 0; cnt < num; cnt += 3) { + struct pattern *pattern; + + pattern = parse_pattern(pattern_list+cnt); + if (pattern == NULL) { + g_slist_free_full(patterns, free_pattern); + return NULL; + } + patterns = g_slist_append(patterns, pattern); + } + + return patterns; +} + +static gint cmp_adv_monitor_with_idx(gconstpointer a, gconstpointer b) +{ + const struct adv_monitor *adv_monitor = a; + uint8_t idx = *(uint8_t *)b; + + return adv_monitor->idx != idx; +} + +static struct adv_monitor *find_adv_monitor_with_idx(uint8_t monitor_idx) +{ + GSList *list; + + list = g_slist_find_custom(adv_mons, &monitor_idx, + cmp_adv_monitor_with_idx); + + if (list) + return (struct adv_monitor *)list->data; + return NULL; +} + +static void print_bytearray(char *prefix, uint8_t *arr, uint8_t len) +{ + int idx; + + bt_shell_printf("%s", prefix); + for (idx = 0; idx < len; idx++) + bt_shell_printf("%02hhx", arr[idx]); + bt_shell_printf("\n"); +} + +static void print_adv_monitor(struct adv_monitor *adv_monitor) +{ + GSList *l; + + bt_shell_printf("Advertisement Monitor %d\n", adv_monitor->idx); + bt_shell_printf("\ttype: %s\n", adv_monitor->type); + if (adv_monitor->rssi) { + bt_shell_printf("\trssi:\n"); + bt_shell_printf("\t\thigh threshold: %hd\n", + adv_monitor->rssi->high_threshold); + bt_shell_printf("\t\thigh threshold timer: %hu\n", + adv_monitor->rssi->high_timer); + bt_shell_printf("\t\tlow threshold: %hd\n", + adv_monitor->rssi->low_threshold); + bt_shell_printf("\t\tlow threshold timer: %hu\n", + adv_monitor->rssi->low_timer); + } + + if (adv_monitor->patterns) { + int idx = 1; + + for (l = adv_monitor->patterns; l; l = g_slist_next(l), idx++) { + struct pattern *pattern = l->data; + + bt_shell_printf("\tpattern %d:\n", idx); + bt_shell_printf("\t\tstart position: %hhu\n", + pattern->start_pos); + bt_shell_printf("\t\tAD data type: %hhu\n", + pattern->ad_data_type); + print_bytearray("\t\tcontent: ", pattern->content, + pattern->content_len); + } + } +} + +void adv_monitor_add_monitor(DBusConnection *conn, char *type, + gboolean rssi_enabled, int argc, char *argv[]) +{ + struct adv_monitor *adv_monitor; + struct rssi_setting *rssi; + GSList *patterns = NULL; + + if (g_slist_length(adv_mons) >= UINT8_MAX) { + bt_shell_printf("Number of advertisement monitor exceeds " + "the limit"); + return; + } + + while (find_adv_monitor_with_idx(adv_mon_idx)) + adv_mon_idx += 1; + + if (rssi_enabled == FALSE) + rssi = NULL; + else { + rssi = parse_rssi(argv[1], argv[2]); + if (rssi == NULL) + return; + + argv += 2; + argc -= 2; + } + + patterns = parse_patterns(argv+1, argc-1); + if (patterns == NULL) { + bt_shell_printf("pattern-list malformed\n"); + return; + } + + adv_monitor = g_malloc0(sizeof(struct adv_monitor)); + + if (!adv_monitor) { + bt_shell_printf("Failed to allocate adv_monitor"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + adv_monitor->idx = adv_mon_idx; + adv_monitor->type = g_strdup(type); + adv_monitor->rssi = rssi; + adv_monitor->patterns = patterns; + + adv_mons = g_slist_append(adv_mons, adv_monitor); + bt_shell_printf("Advertisement Monitor %d added\n", adv_monitor->idx); +} + +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx) +{ + struct adv_monitor *adv_monitor; + GSList *l; + + if (monitor_idx < 0) { + for (l = adv_mons; l; l = g_slist_next(l)) { + adv_monitor = l->data; + print_adv_monitor(adv_monitor); + } + return; + } + + adv_monitor = find_adv_monitor_with_idx(monitor_idx); + + if (adv_monitor == NULL) { + bt_shell_printf("Can't find monitor with index %d\n", + monitor_idx); + return; + } + + print_adv_monitor(adv_monitor); +} + +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx) +{ + struct adv_monitor *adv_monitor; + + if (monitor_idx < 0) { + g_slist_free_full(g_steal_pointer(&adv_mons), free_adv_monitor); + return; + } + + adv_monitor = find_adv_monitor_with_idx(monitor_idx); + if (adv_monitor == NULL) { + bt_shell_printf("Can't find monitor with index %d\n", + monitor_idx); + return; + } + + adv_mons = g_slist_remove(adv_mons, adv_monitor); + free_adv_monitor(adv_monitor); + bt_shell_printf("Monitor %d deleted\n", monitor_idx); +} + +static void print_supported_list(GSList *list) +{ + GSList *iter; + + for (iter = list; iter; iter = g_slist_next(iter)) { + char *data = iter->data; + + printf(" %s", data); + } +} + +void adv_monitor_get_supported_info(void) +{ + bt_shell_printf("Supported Features:"); + print_supported_list(manager.supported_features); + bt_shell_printf("\n"); + + bt_shell_printf("Supported Moniter Types:"); + print_supported_list(manager.supported_types); + bt_shell_printf("\n"); +} diff --git a/client/adv_monitor.h b/client/adv_monitor.h index 77b0b62c6..12c01bd3f 100644 --- a/client/adv_monitor.h +++ b/client/adv_monitor.h @@ -17,7 +17,17 @@ * */ +#define RSSI_DEFAULT_HIGH_THRESHOLD -50 +#define RSSI_DEFAULT_LOW_THRESHOLD -70 +#define RSSI_DEFAULT_HIGH_TIMEOUT 10 +#define RSSI_DEFAULT_LOW_TIMEOUT 5 + void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); void adv_monitor_remove_manager(DBusConnection *conn); void adv_monitor_register_app(DBusConnection *conn); void adv_monitor_unregister_app(DBusConnection *conn); +void adv_monitor_add_monitor(DBusConnection *conn, char *type, + gboolean rssi_enabled, int argc, char *argv[]); +void adv_monitor_print_monitor(DBusConnection *conn, int monitor_idx); +void adv_monitor_remove_monitor(DBusConnection *conn, int monitor_idx); +void adv_monitor_get_supported_info(void); diff --git a/client/main.c b/client/main.c index 75f8bc462..2b0243308 100644 --- a/client/main.c +++ b/client/main.c @@ -2719,6 +2719,85 @@ static void cmd_ad_clear(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_FAILURE); } +static void print_add_or_pattern_with_rssi_usage(void) +{ + bt_shell_printf("rssi-range format:\n" + "\t<low-rssi>,<high-rssi>\n" + "\tBoth parameters can be skipped, in that case the\n" + "\tparamter will be set to its pre-defined value\n"); + bt_shell_printf("\tPre-defined low-rssi,high-rssi: %d,%d\n", + RSSI_DEFAULT_LOW_THRESHOLD, + RSSI_DEFAULT_HIGH_THRESHOLD); + bt_shell_printf("timeout format:\n" + "\t<low-rssi>,<high-rssi>\n" + "\tBoth parameters can be skipped, in that case the\n" + "\tparamter will be set to its pre-defined value\n"); + bt_shell_printf("\tPre-defined low-timeout,high-timeout: %d,%d\n", + RSSI_DEFAULT_LOW_TIMEOUT, + RSSI_DEFAULT_HIGH_TIMEOUT); + bt_shell_printf("pattern format:\n" + "\t<start_position> <ad_data_type> <content_of_pattern>\n"); + bt_shell_printf("e.g.\n" + "\tadd-or-pattern-rssi -10, ,10 1 2 01ab55\n"); + bt_shell_printf("or\n" + "\tadd-or-pattern-rssi -50,-30 , 1 2 01ab55 3 4 23cd66\n"); +} + +static void print_add_or_pattern_usage(void) +{ + bt_shell_printf("pattern format:\n" + "\t<start_position> <ad_data_type> <content_of_pattern>\n"); + bt_shell_printf("e.g.\n" + "\tadd-or-pattern 1 2 01ab55 3 4 23cd66\n"); +} + +static void cmd_adv_monitor_print_usage(int argc, char *argv[]) +{ + if (strcmp(argv[1], "add-or-pattern") == 0) + print_add_or_pattern_usage(); + else if (strcmp(argv[1], "add-or-pattern-rssi") == 0) + print_add_or_pattern_with_rssi_usage(); + else + bt_shell_printf("Invalid argument %s", argv[1]); +} + +static void cmd_adv_monitor_add_or_monitor_with_rssi(int argc, char *argv[]) +{ + adv_monitor_add_monitor(dbus_conn, "or_patterns", TRUE, argc, argv); +} + +static void cmd_adv_monitor_add_or_monitor(int argc, char *argv[]) +{ + adv_monitor_add_monitor(dbus_conn, "or_patterns", FALSE, argc, argv); +} + +static void cmd_adv_monitor_print_monitor(int argc, char *argv[]) +{ + int monitor_idx; + + if (strcmp(argv[1], "all") == 0) + monitor_idx = -1; + else + monitor_idx = atoi(argv[1]); + adv_monitor_print_monitor(dbus_conn, monitor_idx); +} + +static void cmd_adv_monitor_remove_monitor(int argc, char *argv[]) +{ + int monitor_idx; + + if (strcmp(argv[1], "all") == 0) + monitor_idx = -1; + else + monitor_idx = atoi(argv[1]); + adv_monitor_remove_monitor(dbus_conn, monitor_idx); +} + +static void cmd_adv_monitor_get_supported_info(int argc, char *argv[]) +{ + adv_monitor_get_supported_info(); +} + static const struct bt_shell_menu advertise_menu = { .name = "advertise", .desc = "Advertise Options Submenu", @@ -2755,6 +2834,35 @@ static const struct bt_shell_menu advertise_menu = { { } }, }; +static const struct bt_shell_menu advertise_monitor_menu = { + .name = "monitor", + .desc = "Advertisement Monitor Options Submenu", + .entries = { + { "add-or-pattern-rssi", "<rssi-range=low,high> <timeout=low,high> " + "[patterns=pattern1 pattern2 ...]", + cmd_adv_monitor_add_or_monitor_with_rssi, + "Add 'or pattern' type monitor with RSSI " + "filter" }, + { "add-or-pattern", "[patterns=pattern1 pattern2 ...]", + cmd_adv_monitor_add_or_monitor, + "Add 'or pattern' type monitor without RSSI " + "filter" }, + { "get-pattern", "<monitor-id/all>", + cmd_adv_monitor_print_monitor, + "Get advertisement monitor" }, + { "remove-pattern", "<monitor-id/all>", + cmd_adv_monitor_remove_monitor, + "Remove advertisement monitor" }, + { "get-supported-info", NULL, + cmd_adv_monitor_get_supported_info, + "Get advertisement manager supported " + "features and supported monitor types" }, + { "print-usage", "<add-or-pattern/add-or-pattern-rssi>", + cmd_adv_monitor_print_usage, + "Print the command usage"}, + { } }, +}; + static const struct bt_shell_menu scan_menu = { .name = "scan", .desc = "Scan Options Submenu", @@ -2932,6 +3040,7 @@ int main(int argc, char *argv[]) bt_shell_init(argc, argv, &opt); bt_shell_set_menu(&main_menu); bt_shell_add_submenu(&advertise_menu); + bt_shell_add_submenu(&advertise_monitor_menu); bt_shell_add_submenu(&scan_menu); bt_shell_add_submenu(&gatt_menu); bt_shell_set_prompt(PROMPT_OFF); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wI8nBrHVYV+0ogAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 11:06:57 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id OA6BAbHVYV9+owAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 11:06:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9256CA0B1B; Wed, 16 Sep 2020 11:06:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726571AbgIPJGe (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 05:06:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:46238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbgIPJGb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 05:06:31 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B20F921974; Wed, 16 Sep 2020 09:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600247190; bh=Dfwbci88DTkyCRzDTgwvZH7qGaycD4hKjVm1q2R6nDI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bsWQuzvWoVSuUq700Adg7BMCU+7Pad8dakDZORQGKVPwk48j/EqXdFnRrGzLT44TS oWbbT033KjoAt97oXXS1a6qmCQwJ9WUqELN0czuU7AO8AfvZBv/JXdcnYCjj9M+5kf GQRn/mLUWDrHjqL9HyfVntGTUcmgZZMahsKZZ84w= Date: Wed, 16 Sep 2020 11:06:41 +0200 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: Alan Stern <stern@rowland.harvard.edu> Cc: himadrispandya@gmail.com, dvyukov@google.com, linux-usb@vger.kernel.org, perex@perex.cz, tiwai@suse.com, stern@rowland.harvard.ed, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH v3 04/11] USB: core: hub.c: use usb_control_msg_send() in a few places Message-ID: <20200916090641.GA710715@kroah.com> References: <20200914153756.3412156-1-gregkh@linuxfoundation.org> <20200914153756.3412156-5-gregkh@linuxfoundation.org> <20200914180616.GB972479@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200914180616.GB972479@rowland.harvard.edu> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9256CA0B1B X-Rspamd-UID: a54b17 On Mon, Sep 14, 2020 at 02:06:16PM -0400, Alan Stern wrote: > On Mon, Sep 14, 2020 at 05:37:49PM +0200, Greg Kroah-Hartman wrote: > > There are a few calls to usb_control_msg() that can be converted to use > > usb_control_msg_send() instead, so do that in order to make the error > > checking a bit simpler and the code smaller. > > > > Cc: Alan Stern <stern@rowland.harvard.edu> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > --- > > v3: > > - drop change in usb_enable_link_state() as it was not needed now > > thanks to review from Alan > > - minor changes requested by checkpatch.pl > > > > v2: > > - dropped changes to usb_req_set_sel() thanks to review from Alan > > > > drivers/usb/core/hub.c | 99 +++++++++++++++++------------------------- > > 1 file changed, 40 insertions(+), 59 deletions(-) > > Reviewed-by: Alan Stern <stern@rowland.harvard.edu> Thanks for the review! greg k-h Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kNeLOVpTYl/EJAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 20:03:06 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YFeKNlpTYl/PfAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 20:03:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1D575A016F; Wed, 16 Sep 2020 20:02:56 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727780AbgIPSCr (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 14:02:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727775AbgIPSCd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 14:02:33 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 049B3C061788 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 11:02:31 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id k15so4409618pfc.12 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 11:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=oKK+R4vB+7dRT25SkGFNImJ3MtLBDRDqIznhx0nRzAs=; b=RAv+ZcfpNEyAbGataYWi56XvH+C0d2XlA3emc1lqWb35HAVu5yFwWC1CUAL88Z3rz8 O113BD6SSZ7xE1R6gCYR+5Uiv8Wz4wRppiA+tTQym8I/NnqdG+l6StU2B0twqgdGYvAS wUJLqUDnBrTeDpBjWcEAif4I6ydTNJmouwBy4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=oKK+R4vB+7dRT25SkGFNImJ3MtLBDRDqIznhx0nRzAs=; b=SVAUL3y72DRxq5z/i8dAqCu066LHHJco9/mFVnTYNov44DDYx0x+s+N2QlYD+VYoMR aOeUqvy8UuaFLrii1mjcKg9SXwXHiKW/JNtxuCfetKu0BzEWprWFCciD3LZTAILEFvFj YtP+fV5gyUPV53XKwlTrOd5y4XpnXKox9kd6BcgR7fv8ungPtbv39D7+SCnZ7iQteTO5 7WseGDEo1rwmWg7BSZI/p4r+1WkJmCNyW+ZUiaRuuMr1psMLO1i5spLR999twVSAfQlY HMR+BpRs2xN2V3Nss2IEZTY5giK14GG21cLthKFlWBJsYp5fDCfQoN7BgAKBP73EeLIU q5Bg== X-Gm-Message-State: AOAM5328rYZZEh5lR4GMsgKKy3MG4ILUi1FIFsMUi22W3HsqwahWpWMK vInf1fYSEAvgVnfyki+OHzGMgQ== X-Google-Smtp-Source: ABdhPJyByD4aTCPLAJcpe/mnCOM1dCgtz7cfGxhzyAuNU3s+nJ2bpn6PbSwbInUI7LZr3ekI7PjsjQ== X-Received: by 2002:a62:3044:0:b029:142:2501:398b with SMTP id w65-20020a6230440000b02901422501398bmr7496943pfw.80.1600279350855; Wed, 16 Sep 2020 11:02:30 -0700 (PDT) Received: from localhost ([2620:15c:202:1:f693:9fff:fef4:e70a]) by smtp.gmail.com with ESMTPSA id z1sm17315402pfz.70.2020.09.16.11.02.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Sep 2020 11:02:30 -0700 (PDT) Date: Wed, 16 Sep 2020 11:02:29 -0700 From: Matthias Kaehlcke <mka@chromium.org> To: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> Cc: marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org Subject: Re: [PATCH v1] Bluetooth: Use NVM files based on SoC ID for WCN3991 Message-ID: <20200916180229.GA3560556@google.com> References: <1600184605-31611-1-git-send-email-gubbaven@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1600184605-31611-1-git-send-email-gubbaven@codeaurora.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.13 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1D575A016F X-Rspamd-UID: 2b0bf0 Hi Venkata, I agree with Marcel that the version magic is confusing ... On Tue, Sep 15, 2020 at 09:13:25PM +0530, Venkata Lakshmi Narayana Gubba wrote: > This change will allow to use different NVM file based > on WCN3991 BT SoC ID.Need to use different NVM file based on > fab location for WCN3991 BT SoC. > > Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> > --- > drivers/bluetooth/btqca.c | 41 +++++++++++++++++++++++++---------------- > drivers/bluetooth/btqca.h | 13 ++++++++----- > drivers/bluetooth/hci_qca.c | 11 +++++------ > 3 files changed, 38 insertions(+), 27 deletions(-) > > diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c > index ce9dcff..a7e72f1 100644 > --- a/drivers/bluetooth/btqca.c > +++ b/drivers/bluetooth/btqca.c > @@ -14,12 +14,11 @@ > > #define VERSION "0.1" > > -int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, > +int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver, > enum qca_btsoc_type soc_type) > { > struct sk_buff *skb; > struct edl_event_hdr *edl; > - struct qca_btsoc_version *ver; > char cmd; > int err = 0; > u8 event_type = HCI_EV_VENDOR; > @@ -70,9 +69,9 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, > } > > if (soc_type >= QCA_WCN3991) > - memmove(&edl->data, &edl->data[1], sizeof(*ver)); > - > - ver = (struct qca_btsoc_version *)(edl->data); > + memcpy(ver, &edl->data[1], sizeof(*ver)); > + else > + memcpy(ver, &edl->data, sizeof(*ver)); > > bt_dev_info(hdev, "QCA Product ID :0x%08x", > le32_to_cpu(ver->product_id)); > @@ -83,13 +82,7 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, > bt_dev_info(hdev, "QCA Patch Version:0x%08x", > le16_to_cpu(ver->patch_ver)); > > - /* QCA chipset version can be decided by patch and SoC > - * version, combination with upper 2 bytes from SoC > - * and lower 2 bytes from patch will be used. > - */ > - *soc_version = (le32_to_cpu(ver->soc_id) << 16) | > - (le16_to_cpu(ver->rom_ver) & 0x0000ffff); > - if (*soc_version == 0) > + if (le32_to_cpu(ver->soc_id) == 0 || le16_to_cpu(ver->rom_ver) == 0) > err = -EILSEQ; > > out: > @@ -446,15 +439,25 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) > EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome); > > int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, > - enum qca_btsoc_type soc_type, u32 soc_ver, > + enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, > const char *firmware_name) > { > struct qca_fw_config config; > int err; > u8 rom_ver = 0; > + u32 soc_ver; > > bt_dev_dbg(hdev, "QCA setup on UART"); > > + /* QCA chipset version can be decided by patch and SoC > + * version, combination with upper 2 bytes from SoC > + * and lower 2 bytes from patch will be used. > + */ > + soc_ver = (le32_to_cpu(ver.soc_id) << 16) | > + (le16_to_cpu(ver.rom_ver) & 0x0000ffff); > + Can we at least do the leN_to_cpu conversions in qca_read_soc_version() as previously to make this less clunky? And/or define a macro to extract 'soc_ver' to unclunkify this further. > + bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); > + > config.user_baud_rate = baudrate; > > /* Download rampatch file */ > @@ -491,9 +494,15 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, > if (firmware_name) > snprintf(config.fwname, sizeof(config.fwname), > "qca/%s", firmware_name); > - else if (qca_is_wcn399x(soc_type)) > - snprintf(config.fwname, sizeof(config.fwname), > - "qca/crnv%02x.bin", rom_ver); > + else if (qca_is_wcn399x(soc_type)) { > + if (ver.soc_id == QCA_WCN3991_SOC_ID) { > + snprintf(config.fwname, sizeof(config.fwname), > + "qca/crnv%02xu.bin", rom_ver); > + } else { > + snprintf(config.fwname, sizeof(config.fwname), > + "qca/crnv%02x.bin", rom_ver); > + } > + } > else if (soc_type == QCA_QCA6390) > snprintf(config.fwname, sizeof(config.fwname), > "qca/htnv%02x.bin", rom_ver); > diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h > index d81b74c..d01a9f5 100644 > --- a/drivers/bluetooth/btqca.h > +++ b/drivers/bluetooth/btqca.h > @@ -34,6 +34,8 @@ > #define QCA_HCI_CC_OPCODE 0xFC00 > #define QCA_HCI_CC_SUCCESS 0x00 > > +#define QCA_WCN3991_SOC_ID (0x40014320) The QCA_ prefix seems a bit verbose, given that this is a QCA driver and WCN3991 uniquely identifies the chip. Having the prefix just needlessly clutters conditions, I suggest to just call it SOC_ID_WCN3991. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IN2uITtUYl/EJAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 20:06:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sOSmHjtUYl98qQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 20:06:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A29BF40979; Wed, 16 Sep 2020 20:06:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727760AbgIPSCT (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 14:02:19 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:41719 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727752AbgIPSCL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 14:02:11 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id B0D7ECED03; Wed, 16 Sep 2020 16:29:44 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: pause/resume advertising around suspend From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200915141229.1.Icfac86f8dfa0813bba6c7604c420d11c3820b4ab@changeid> Date: Wed, 16 Sep 2020 16:22:47 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, open list <linux-kernel@vger.kernel.org>, netdev@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <21AC2E8F-BEC6-431D-89BB-8F2E3EDFBBC1@holtmann.org> References: <20200915141229.1.Icfac86f8dfa0813bba6c7604c420d11c3820b4ab@changeid> To: Daniel Winkler <danielwinkler@google.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.41 / 15.00 / 15.00 X-Rspamd-Queue-Id: A29BF40979 X-Rspamd-UID: c8f66b Hi Daniel, > Currently, the controller will continue advertising when the system > enters suspend. This patch makes sure that all advertising instances are > paused when entering suspend, and resumed when suspend exits. > > The Advertising and Suspend/Resume test suites were both run on this > change on 4.19 kernel with both hardware offloaded multi-advertising and > software rotated multi-advertising. In addition, a new test was added > that performs the following steps: > * Register 3 advertisements via bluez RegisterAdvertisement > * Verify reception of all advertisements by remote peer > * Enter suspend on DUT > * Verify failure to receive all advertisements by remote peer > * Exit suspend on DUT > * Verify reception of all advertisements by remote peer > > Signed-off-by: Daniel Winkler <danielwinkler@google.com> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > --- > > net/bluetooth/hci_request.c | 67 +++++++++++++++++++++++++++++++------ > 1 file changed, 57 insertions(+), 10 deletions(-) Patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KL71ANByYl/N0AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 22:17:20 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 2Jk6Os9yYl/WRgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 22:17:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D1662A0185; Wed, 16 Sep 2020 22:17:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728006AbgIPUQ0 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 16:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728261AbgIPUQK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 16:16:10 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6347BC061788 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:10 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id 6so7116469qko.8 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=MdhjrW4vcBDFIsP592gsDVtZRkvVNqCEWObBUfpScyE=; b=S/LoxaBxieC8lVQIkT05JmeKWV2q00m0KOl6lbdUZjttEi6gPmAODOXo+OXyxqrhp5 jxPED41CrMMYGGYzgcLlvcapQJkQdfTUu9i2QXM7GJj+w4SlufZvPPq7CGx+WtQs5XXo I7YllF7a+UdR+tYaO2wRl5ZyHZ08LTfmccXArvii4SlsuqhTQSdMvOeJoNCanj/J/7Wq Vk8TR0Obzm/HN+IlfEHsaQMXotor2YyiQBI+pjYMRM8fXogZlhgu+SnJz3gWWC4Fqk3b iMPaxRdAqigrr2GENqry48MO3EbiyvN+S1Mii7DlJQe0FygQPQ4B5YRNsIT0vZcGSpL4 sXdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=MdhjrW4vcBDFIsP592gsDVtZRkvVNqCEWObBUfpScyE=; b=RiO+YbaK/0yHT7tBo2NzGx0ZJCSz5FNF1XSVbsUO1ySftW37UjxrmLcMtIX5zuIC7f t04iujXV0v2kfybTT467/pQ1nizcqAwMBBWSxggxE9L4Gfp/wUB4qPFhtfBRcqvreU7e VWGq8tI0zerLr5wQXOblijYJ5PsavwZxruvs+vPM4QP2UoHAUnSpkqte7xcwTMC3G3vr /nLpp/s7flepecJ3cMGWth8XGaIs0sqPs6Og4A+H3vJ2B75KLeiQljXti/rUXBvF1pk3 aXzCzTtEblDW49wKTRxhtXkmSU2B1dBfA9ksPV7Mk0PB/c2XZg2TvWAQ1f8Y7UURqEv2 f1bA== X-Gm-Message-State: AOAM533k66Pfc8W2bc/dU+43N2YfKBGC8w+v4ICkM1nJt3NSUSDHLfVy GwBnbwefhQUgMh1kZwILS6MMbq3oUtsSVFT3rlHeUsww7x9MGyc6iyCCGun4EOHsrpITcrZ5XRf IbDC/1RsQjqk4I6FBnv/EwXcogEQ/mPRk4SldY3mU41GNxcnNzZFdm+ym8w/QXAkqHZ/QZlNbNE ps5L13BDlspqo2jPQE X-Google-Smtp-Source: ABdhPJywYsxto73uCa5oqtF8W1GKrdTZFnMdhJn+ZM5F44wJqwc0/cZMV6OE3nz415keyKpfasZRfYqZsOwq7WwwtBWA X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:ad4:57a7:: with SMTP id g7mr25361605qvx.10.1600287369377; Wed, 16 Sep 2020 13:16:09 -0700 (PDT) Date: Wed, 16 Sep 2020 13:15:56 -0700 Message-Id: <20200916201602.1223002-1-danielwinkler@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH 0/6] Bluetooth: Add new MGMT interface for advertising add From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.19 / 15.00 / 15.00 X-Rspamd-Queue-Id: D1662A0185 X-Rspamd-UID: 72844d Hi Maintainers, This patch series defines the new two-call MGMT interface for adding new advertising instances. Similarly to the hci advertising commands, a mgmt call to set parameters is expected to be first, followed by a mgmt call to set advertising data/scan response. The members of the parameters request are optional; the caller defines a "params" bitfield in the structure that indicates which parameters were intentionally set, and others are set to defaults. The main feature here is the introduction of min/max parameters and tx power that can be requested by the client. Min/max parameters will be used both with and without extended advertising support, and tx power will be used with extended advertising support. After a call for hci advertising parameters, a new TX_POWER_SELECTED event will be emitted to alert userspace to the actual chosen tx power. Additionally, to inform userspace of the controller LE Tx power capabilities for the client's benefit, this series also adds an MGMT command to query controller capabilities, which returns a flexible TLV format for future flexibility. All changes have been tested on hatch (extended advertising) and kukui (no extended advertising) chromebooks with manual testing verifying correctness of parameters/data in btmon traces, and our automated test suite of 25 single- and multi-advertising usage scenarios. A separate patch series will add support in bluetoothd. Thanks in advance for your feedback! Daniel Winkler Daniel Winkler (6): Bluetooth: Add helper to set adv data Bluetooth: Break add adv into two mgmt commands Bluetooth: Use intervals and tx power from mgmt cmds Bluetooth: Emit tx power chosen on ext adv params completion Bluetooth: Query LE tx power on startup Bluetooth: Add MGMT command for controller capabilities include/net/bluetooth/hci.h | 7 + include/net/bluetooth/hci_core.h | 14 +- include/net/bluetooth/mgmt.h | 48 ++++ net/bluetooth/hci_core.c | 47 +++- net/bluetooth/hci_event.c | 22 ++ net/bluetooth/hci_request.c | 29 ++- net/bluetooth/mgmt.c | 420 ++++++++++++++++++++++++++++++- 7 files changed, 561 insertions(+), 26 deletions(-) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wJmEEt1yYl/j2wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 22:17:33 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id sAh+D91yYl/WRgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 22:17:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B241AA0B2B; Wed, 16 Sep 2020 22:17:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727219AbgIPUQv (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 16:16:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727145AbgIPUQe (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 16:16:34 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CEF9C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:17 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id i199so8167138ybg.22 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=ToSnX8V2D1upjBIlNrW3uCJ/HI8k/JL9fDv0qFjO2D8=; b=vL478tsYWA7BYu1aZHIUiFUWgq91HuXU6OODg57Tk1DU6ydUDA5yOGsIL9LbiP7Xr4 xFytVQ4xxYX7vWxhaUm1pJaLRWb+2zCr3n7cUHPLdVKUPD7RlBKVnPNUbdV49+PJKOjy iye/rD2uBv2e6s+Yp3MM8HwaoiBdvJsx/OZawOsuDnWFMLjoObfgTWTX2k+PRCHSJ/9B OSKWJl0AKvVfsH+ffdJ1DmbWRG33VJS2oYrilrWSlvcgqfW516P6PDVYR6wWK6WNEu0u +PxLbVk38T6XTX7U/oqYolb1/H1D8/Euc6fKHvHtRjFcAo+rstDiI1MFT08KqlFZq29h 4tYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ToSnX8V2D1upjBIlNrW3uCJ/HI8k/JL9fDv0qFjO2D8=; b=rYZXmcqZQO0iTcs/YkUmXhAitbLqtMJoxjVXoiq3fAVCyJbKSvNxp+bOaekTgyiemX sAP7IuOrRWuDywvIAiLgsrUfvL1o+D/fNB+4DuYnP20iOljsu929HU+EOC13P7HW1IMH fhfO1smtf6iaHT0OYTqqX6E9w+BaE3yjQs5AwI3MIfiyq4RWhJU71yFftxRtK5h7PxJ3 3a8J3xAYBvMLiUxlPIrpFBqcFLbpSxKnkvuXP0XuW6qbDsXlRbD3NghRZLT7tgfcb0mL mEK9eG+0dlV1SqoBX7fNxjYWpzza/TffvM5zNelf8CMjg0Ax/PLBfBZ8zGelLiavYLyJ 3iEw== X-Gm-Message-State: AOAM530qfnRrsgj3IBrR4/zeTTmWdis2ImO2VyPTqezqpzyQSanUUDkJ 38daK7hFe7OAcaW5BW4+IPZ6agGsetPc0kpi8RFd7D1cIpEMOus7M3UV4NcdCetS7ak85IAlCGl 6vXUvqs228IljaeUvr2m8hjV7G8eBnC+SzsigR5tF92VxIhEdBYrRApEppxdktxrFtTYkW/4KSW zYiEACzasyy6s190mT X-Google-Smtp-Source: ABdhPJynIOAOT3cKcE9mOpi1dSkkWI0SRrZTVfjc8VgXXHGlnRPdBQ1yOcqAflqyWjz6Nx1NH+/JZna8iwQK8WOVQsyB X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a05:6902:4d1:: with SMTP id v17mr35743659ybs.389.1600287375986; Wed, 16 Sep 2020 13:16:15 -0700 (PDT) Date: Wed, 16 Sep 2020 13:15:59 -0700 In-Reply-To: <20200916201602.1223002-1-danielwinkler@google.com> Message-Id: <20200916131430.3.I74255537fa99ed3c0025321008b361c6ad90a431@changeid> Mime-Version: 1.0 References: <20200916201602.1223002-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH 3/6] Bluetooth: Use intervals and tx power from mgmt cmds From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.61 / 15.00 / 15.00 X-Rspamd-Queue-Id: B241AA0B2B X-Rspamd-UID: 2d5385 This patch takes the min/max intervals and tx power optionally provided in mgmt interface, stores them in the advertisement struct, and uses them when configuring the hci requests. While tx power is not used if extended advertising is unavailable, software rotation will use the min and max advertising intervals specified by the client. This change is validated manually by ensuring the min/max intervals are propagated to the controller on both hatch (extended advertising) and kukui (no extended advertising) chromebooks, and that tx power is propagated correctly on hatch. These tests are performed with multiple advertisements simultaneously. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- include/net/bluetooth/hci_core.h | 5 ++++- net/bluetooth/hci_core.c | 8 +++++--- net/bluetooth/hci_request.c | 29 +++++++++++++++++++---------- net/bluetooth/mgmt.c | 8 ++++++-- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 48d144ae8b57d6..ab168f46b6d909 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -230,6 +230,8 @@ struct adv_info { __u16 scan_rsp_len; __u8 scan_rsp_data[HCI_MAX_AD_LENGTH]; __s8 tx_power; + __u32 min_interval; + __u32 max_interval; bdaddr_t random_addr; bool rpa_expired; struct delayed_work rpa_expired_cb; @@ -1292,7 +1294,8 @@ struct adv_info *hci_get_next_instance(struct hci_dev *hdev, u8 instance); int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, u16 adv_data_len, u8 *adv_data, u16 scan_rsp_len, u8 *scan_rsp_data, - u16 timeout, u16 duration); + u16 timeout, u16 duration, s8 tx_power, + u32 min_interval, u32 max_interval); int hci_set_adv_instance_data(struct hci_dev *hdev, u8 instance, u16 adv_data_len, u8 *adv_data, u16 scan_rsp_len, u8 *scan_rsp_data); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 3f73f147826409..3a2332f4a9bba2 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2951,7 +2951,8 @@ static void adv_instance_rpa_expired(struct work_struct *work) int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, u16 adv_data_len, u8 *adv_data, u16 scan_rsp_len, u8 *scan_rsp_data, - u16 timeout, u16 duration) + u16 timeout, u16 duration, s8 tx_power, + u32 min_interval, u32 max_interval) { struct adv_info *adv_instance; @@ -2979,6 +2980,9 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, adv_instance->flags = flags; adv_instance->adv_data_len = adv_data_len; adv_instance->scan_rsp_len = scan_rsp_len; + adv_instance->min_interval = min_interval; + adv_instance->max_interval = max_interval; + adv_instance->tx_power = tx_power; if (adv_data_len) memcpy(adv_instance->adv_data, adv_data, adv_data_len); @@ -2995,8 +2999,6 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, else adv_instance->duration = duration; - adv_instance->tx_power = HCI_TX_POWER_INVALID; - INIT_DELAYED_WORK(&adv_instance->rpa_expired_cb, adv_instance_rpa_expired); diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index e17bc8a1c66ddd..30bf0d0e406d9a 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1370,6 +1370,7 @@ static bool is_advertising_allowed(struct hci_dev *hdev, bool connectable) void __hci_req_enable_advertising(struct hci_request *req) { struct hci_dev *hdev = req->hdev; + struct adv_info *adv_instance; struct hci_cp_le_set_adv_param cp; u8 own_addr_type, enable = 0x01; bool connectable; @@ -1377,6 +1378,7 @@ void __hci_req_enable_advertising(struct hci_request *req) u32 flags; flags = get_adv_instance_flags(hdev, hdev->cur_adv_instance); + adv_instance = hci_find_adv_instance(hdev, hdev->cur_adv_instance); /* If the "connectable" instance flag was not set, then choose between * ADV_IND and ADV_NONCONN_IND based on the global connectable setting. @@ -1408,11 +1410,16 @@ void __hci_req_enable_advertising(struct hci_request *req) memset(&cp, 0, sizeof(cp)); - if (connectable) { - cp.type = LE_ADV_IND; - + if (adv_instance) { + adv_min_interval = adv_instance->min_interval; + adv_max_interval = adv_instance->max_interval; + } else { adv_min_interval = hdev->le_adv_min_interval; adv_max_interval = hdev->le_adv_max_interval; + } + + if (connectable) { + cp.type = LE_ADV_IND; } else { if (get_cur_adv_instance_scan_rsp_len(hdev)) cp.type = LE_ADV_SCAN_IND; @@ -1423,9 +1430,6 @@ void __hci_req_enable_advertising(struct hci_request *req) hci_dev_test_flag(hdev, HCI_LIMITED_DISCOVERABLE)) { adv_min_interval = DISCOV_LE_FAST_ADV_INT_MIN; adv_max_interval = DISCOV_LE_FAST_ADV_INT_MAX; - } else { - adv_min_interval = hdev->le_adv_min_interval; - adv_max_interval = hdev->le_adv_max_interval; } } @@ -1942,9 +1946,15 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance) memset(&cp, 0, sizeof(cp)); - /* In ext adv set param interval is 3 octets */ - hci_cpu_to_le24(hdev->le_adv_min_interval, cp.min_interval); - hci_cpu_to_le24(hdev->le_adv_max_interval, cp.max_interval); + if (adv_instance) { + hci_cpu_to_le24(adv_instance->min_interval, cp.min_interval); + hci_cpu_to_le24(adv_instance->max_interval, cp.max_interval); + cp.tx_power = adv_instance->tx_power; + } else { + hci_cpu_to_le24(hdev->le_adv_min_interval, cp.min_interval); + hci_cpu_to_le24(hdev->le_adv_max_interval, cp.max_interval); + cp.tx_power = HCI_ADV_TX_POWER_NO_PREFERENCE; + } secondary_adv = (flags & MGMT_ADV_FLAG_SEC_MASK); @@ -1967,7 +1977,6 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance) cp.own_addr_type = own_addr_type; cp.channel_map = hdev->le_adv_channel_map; - cp.tx_power = 127; cp.handle = instance; if (flags & MGMT_ADV_FLAG_SEC_2M) { diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 421b6784a114f9..717c97affb1554 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -7524,7 +7524,10 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, cp->adv_data_len, cp->data, cp->scan_rsp_len, cp->data + cp->adv_data_len, - timeout, duration); + timeout, duration, + HCI_ADV_TX_POWER_NO_PREFERENCE, + hdev->le_adv_min_interval, + hdev->le_adv_max_interval); if (err < 0) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, MGMT_STATUS_FAILED); @@ -7722,7 +7725,8 @@ static int add_ext_adv_params(struct sock *sk, struct hci_dev *hdev, /* Create advertising instance with no advertising or response data */ err = hci_add_adv_instance(hdev, cp->instance, flags, - 0, NULL, 0, NULL, timeout, duration); + 0, NULL, 0, NULL, timeout, duration, + tx_power, min_interval, max_interval); if (err < 0) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gCpDJvJyYl/j2wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 22:17:54 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SGPXIvJyYl+jJgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 22:17:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5057EA013F; Wed, 16 Sep 2020 22:17:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726890AbgIPURi (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 16:17:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728326AbgIPUQq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 16:16:46 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B66AC061220 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:23 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id di5so5516499qvb.13 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=mV/LFuTshHzotksH3grmXFg7Xs0h6PleCimRLiw3IeY=; b=EQRl+RIO/iMmVWfKcZ8ED17Om52TeR9DzT0HzQt62GI8XYzbTx4iSE/e53TWLeRrC4 SinrfVtyjrg8237Bs3Z5Y6SWftmvQrUM2sPw4RnMoJ5vk10M2ZWGgSsoXIBGfqPA3DZW dRiCE4KtBUMZZNXBlXikUyz/9lx9HSLDr/p1IjtZnwFCNbEYGhOtEnek7cUlCDGJ81RW byBJJkGtNWPwky/MpFaZ8fHoDZpF4odneqa6wytQFAdaoV5xhvHMH8Nm5kYI/J+BiSyH BThka3ZSKn46911pMjZGg8Q+1xXtdHCnJDIMl/URjQcO3oXG6Fpo6hfqmf9FQwAApsZL mGzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=mV/LFuTshHzotksH3grmXFg7Xs0h6PleCimRLiw3IeY=; b=tLlgR8/VWwIJg4eO58wXER+8OkHlj9HieASLa4di3m5a40duWQ7Iv3b0A+m+rhkPE1 mZ/nPR5xzoYoKc7p5gyavK0WNd/tqhbRVNBz5g6GoSQW29jrBcHRo4NSt44Ju2IBqarv OgBilYGJmg8s5Mb6g0jImsNECRlv4wtJrQ6PUAxi+mon2T94Zm87IhUZvtQSrFX+b+Sm e3aL1e9/tLlCsZ4atkcUMWNPHVoH8RgWlyPMBPKffl1pY5FnqIZH/Vg81ou48V7ZItK8 15ryixKRF2hLASsJWMtByhnZ79pB8d6vnRFLFhVhWZCNfQJ2iWqQiQ0UJakFiSwpWrzE NjRg== X-Gm-Message-State: AOAM530GRZ184EVblYinnAdok9HT3Slz/ovowvCb4vSE1/pdgTNooZ3O JyWD00imF29pHNTWoyE58X2OtpCG/I3Ih4Sz6aCl0W3X71yGqPpX3oY/+CXDETku9YI6MoR8xIE TdEOsJEvotPouViFpC38ozG8yYmvsoEtZe44L5yEe7A6d5uVO3Dlcu7LD1OgFxMM2SPOSjQLfWu b3BGPtSk1QlZMbDTD1 X-Google-Smtp-Source: ABdhPJx9rr/wInvexTzLGszPhP52de+s7E+VegnMknnOC50bFToSeEmk3oEZlbiKA9jVdE7FHbXQXJRUfSF8TKP5DSid X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a0c:c244:: with SMTP id w4mr25344793qvh.12.1600287382444; Wed, 16 Sep 2020 13:16:22 -0700 (PDT) Date: Wed, 16 Sep 2020 13:16:02 -0700 In-Reply-To: <20200916201602.1223002-1-danielwinkler@google.com> Message-Id: <20200916131430.6.I5068c01cae3cea674a96e103a0cf4d8c81425a4f@changeid> Mime-Version: 1.0 References: <20200916201602.1223002-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH 6/6] Bluetooth: Add MGMT command for controller capabilities From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.14 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5057EA013F X-Rspamd-UID: 0a59c1 For advertising, we wish to know the LE tx power capabilities of the controller in userspace, so this patch adds a new MGMT command to query controller capabilities. The data returned is in TLV format, so it can be easily used to convey any data determined to be useful in the future, but for now it simply contains LE min and max tx power. The change was tested by manually verifying that the new MGMT command returns the tx power range as expected in userspace. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- include/net/bluetooth/mgmt.h | 9 +++++++++ net/bluetooth/mgmt.c | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index db64cf4747554c..9aa792e5efc8d0 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -815,6 +815,15 @@ struct mgmt_rp_add_ext_adv_data { __u8 instance; } __packed; +#define MGMT_CAP_LE_TX_PWR_MIN 0x0000 +#define MGMT_CAP_LE_TX_PWR_MAX 0x0001 + +#define MGMT_OP_READ_CONTROLLER_CAP 0x0056 +#define MGMT_OP_READ_CONTROLLER_CAP_SIZE 0 +struct mgmt_rp_read_controller_cap { + __u8 capabilities[0]; +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { __le16 opcode; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index b9347ff1a1e961..d2e5bc4b3ddb8f 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -124,6 +124,7 @@ static const u16 mgmt_commands[] = { MGMT_OP_REMOVE_ADV_MONITOR, MGMT_OP_ADD_EXT_ADV_PARAMS, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_OP_READ_CONTROLLER_CAP, }; static const u16 mgmt_events[] = { @@ -181,6 +182,7 @@ static const u16 mgmt_untrusted_commands[] = { MGMT_OP_READ_EXP_FEATURES_INFO, MGMT_OP_READ_DEF_SYSTEM_CONFIG, MGMT_OP_READ_DEF_RUNTIME_CONFIG, + MGMT_OP_READ_CONTROLLER_CAP, }; static const u16 mgmt_untrusted_events[] = { @@ -4356,6 +4358,42 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev, return err; } +static int read_controller_cap(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) +{ + u8 i = 0; + + /* This command will return its data in TVL format. Currently we only + * wish to include LE tx power parameters, so this struct can be given + * a fixed size as data types are not changing. + */ + struct { + struct mgmt_tlv entry; + __s8 value; + } __packed cap[2]; + + BT_DBG("request for %s", hdev->name); + memset(cap, 0, sizeof(cap)); + + hci_dev_lock(hdev); + + /* Append LE tx power bounds */ + cap[i].entry.type = MGMT_CAP_LE_TX_PWR_MIN; + cap[i].entry.length = sizeof(__s8); + cap[i].value = hdev->min_le_tx_power; + i++; + + cap[i].entry.type = MGMT_CAP_LE_TX_PWR_MAX; + cap[i].entry.length = sizeof(__s8); + cap[i].value = hdev->max_le_tx_power; + i++; + + hci_dev_unlock(hdev); + + return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_READ_CONTROLLER_CAP, + MGMT_STATUS_SUCCESS, cap, sizeof(cap)); +} + static void read_local_oob_data_complete(struct hci_dev *hdev, u8 status, u16 opcode, struct sk_buff *skb) { @@ -8208,6 +8246,7 @@ static const struct hci_mgmt_handler mgmt_handlers[] = { HCI_MGMT_VAR_LEN }, { add_ext_adv_data, MGMT_ADD_EXT_ADV_DATA_SIZE, HCI_MGMT_VAR_LEN }, + { read_controller_cap, MGMT_OP_READ_CONTROLLER_CAP_SIZE }, }; void mgmt_index_added(struct hci_dev *hdev) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8GHmAwdzYl/j2wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 22:18:15 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id aBeZAAdzYl9JAgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 22:18:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D04ACA0B37; Wed, 16 Sep 2020 22:18:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728224AbgIPURy (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 16:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727725AbgIPUQq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 16:16:46 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F4C0C06121E for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:21 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id di5so5516448qvb.13 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=JEGDhDy0i0NXGVogNpEKp6N3BhWlDVgJ1Ss+eXstDS8=; b=Cr0pbVi/P8EJnHlXGCs6MoDzp6ikdg7g9weO0ajM9wg7h12zQtMVqRq8k4pOdQKwTb 7ftjslmmczWg8PBJagPtJ9YFKljqpRsM/Tq1mE0S7ct3bVlz2yJFplk3yr1yt2MbLFFh 48LtzIoHhTwfi9ZiDpbVked8e3L3fgkLP16LEULNLeCWqntrU0QbcLmJ/8a2u80xwM7j 6Dl/BYP5x0SzYNssjpzXI2IYFxcpiU/0FpYQ2LpioIDHCS+c+uLkt/PduxRB6VWXF3so tpgSjCtFtmdz6ASPmJDX7nJNQGHGMqzE8n1J4lx33fvDS14475vkP83oGOYh/th9RkjT 03MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=JEGDhDy0i0NXGVogNpEKp6N3BhWlDVgJ1Ss+eXstDS8=; b=a50XGjWSbwPkUYTKXDFF7XOgzE85viLlC4u8FHSpPadUCuen1J4+XPNNRXBmoywMhU whRCpYukEx0NnlKcRUS5FczLVnE1FihXEDhKJ7LBI81PWsR59kC/nPXe/PAHlPIq79Dh uLkoYmCebrSMJearPYYUQDZLsokMS617A8D7OkksAln+4zNrhMM2fyVhw9KkBEDBpbgB 0FQ4NFMzc4EdMKf7LFe4VS6t22C+9glwSAhJXOsage1Zk5DV/cmH2sh547NcDmQ/jkns fF2jGFQFkTBOdh+0IIdT+fXbyfR3dSDBqInVEWki/NF0NhrnkE+X7uOHLC6vghOOMaN7 MNXQ== X-Gm-Message-State: AOAM5310Ewsf/9Tjq8WbRnrsi2i6s5QfJ4iNWvTdFssWoKgLlt0ABLK5 J0+n/gmb2goPJBainqX+B4zQN+thTXq3PLGBo9eYyapCK89SVuJljfKUU+GMFVBGeX0PKKiPU+U Pbg1LEJEqEgMj+l1l5K720CuZR7DqIQ9nGOBkk8VZZiBITSFD2LbwLuC96wMWeZEXHXcxvS2LXf WSrQDKH/UTgj/6NxQm X-Google-Smtp-Source: ABdhPJwRasF3+ybFhcwR2eBIZaGWRgKaYBBuDmJGK4uF+WJlagHiIvooM9IhAqq257N5hWKnFmDtqegPm4TTFBubAGKI X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:ad4:58aa:: with SMTP id ea10mr8827403qvb.58.1600287380260; Wed, 16 Sep 2020 13:16:20 -0700 (PDT) Date: Wed, 16 Sep 2020 13:16:01 -0700 In-Reply-To: <20200916201602.1223002-1-danielwinkler@google.com> Message-Id: <20200916131430.5.Ibedcb7af24f1c01a680de4cc8cc5a98951588393@changeid> Mime-Version: 1.0 References: <20200916201602.1223002-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH 5/6] Bluetooth: Query LE tx power on startup From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.96 / 15.00 / 15.00 X-Rspamd-Queue-Id: D04ACA0B37 X-Rspamd-UID: 0ca4d9 Queries tx power via HCI_LE_Read_Transmit_Power command when the hci device is initialized, and stores resulting min/max LE power in hdev struct. If command isn't available (< BT5 support), min/max values both default to HCI_TX_POWER_INVALID. This patch is manually verified by ensuring BT5 devices correctly query and receive controller tx power range. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- include/net/bluetooth/hci.h | 7 +++++++ include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_core.c | 8 ++++++++ net/bluetooth/hci_event.c | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index c8e67042a3b14c..c1504aa3d9cfd5 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1797,6 +1797,13 @@ struct hci_cp_le_set_adv_set_rand_addr { bdaddr_t bdaddr; } __packed; +#define HCI_OP_LE_READ_TRANSMIT_POWER 0x204b +struct hci_rp_le_read_transmit_power { + __u8 status; + __s8 min_le_tx_power; + __s8 max_le_tx_power; +} __packed; + #define HCI_OP_LE_READ_BUFFER_SIZE_V2 0x2060 struct hci_rp_le_read_buffer_size_v2 { __u8 status; diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 667b9d37099dec..c1f5b5c4109215 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -381,6 +381,8 @@ struct hci_dev { __u16 def_page_timeout; __u16 def_multi_adv_rotation_duration; __u16 def_le_autoconnect_timeout; + __s8 min_le_tx_power; + __s8 max_le_tx_power; __u16 pkt_type; __u16 esco_type; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 3a2332f4a9bba2..6bff1c09be3b42 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -741,6 +741,12 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt) hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL); } + if (hdev->commands[38] & 0x80) { + /* Read LE Min/Max Tx Power*/ + hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER, + 0, NULL); + } + if (hdev->commands[26] & 0x40) { /* Read LE White List Size */ hci_req_add(req, HCI_OP_LE_READ_WHITE_LIST_SIZE, @@ -3654,6 +3660,8 @@ struct hci_dev *hci_alloc_dev(void) hdev->le_num_of_adv_sets = HCI_MAX_ADV_INSTANCES; hdev->def_multi_adv_rotation_duration = HCI_DEFAULT_ADV_DURATION; hdev->def_le_autoconnect_timeout = HCI_LE_AUTOCONN_TIMEOUT; + hdev->min_le_tx_power = HCI_TX_POWER_INVALID; + hdev->max_le_tx_power = HCI_TX_POWER_INVALID; hdev->rpa_timeout = HCI_DEFAULT_RPA_TIMEOUT; hdev->discov_interleaved_timeout = DISCOV_INTERLEAVED_TIMEOUT; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 9a24fd99d9e08e..beb35680f3a83a 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1202,6 +1202,20 @@ static void hci_cc_le_set_adv_set_random_addr(struct hci_dev *hdev, hci_dev_unlock(hdev); } +static void hci_cc_le_read_transmit_power(struct hci_dev *hdev, + struct sk_buff *skb) +{ + struct hci_rp_le_read_transmit_power *rp = (void *)skb->data; + + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); + + if (rp->status) + return; + + hdev->min_le_tx_power = rp->min_le_tx_power; + hdev->max_le_tx_power = rp->max_le_tx_power; +} + static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb) { __u8 *sent, status = *((__u8 *) skb->data); @@ -3577,6 +3591,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, hci_cc_le_set_adv_set_random_addr(hdev, skb); break; + case HCI_OP_LE_READ_TRANSMIT_POWER: + hci_cc_le_read_transmit_power(hdev, skb); + break; + default: BT_DBG("%s opcode 0x%4.4x", hdev->name, *opcode); break; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QCXfLlxzYl/j2wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 22:19:40 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mOb/K1xzYl++iwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 22:19:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 38C2840964; Wed, 16 Sep 2020 22:19:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727725AbgIPUTM (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 16:19:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728309AbgIPUQq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 16:16:46 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16875C061355 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:19 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id g10so7156968qto.1 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=a60adGDxqttpuFcY7jkALjROpt4E168K4TU36LymXcQ=; b=eA0nBtfTtG7rvNCSw/DDYVnI09PSqUgQFZkOgBxrmPPULPry28kBQ0zp0YUbhQRjOY X/E8NDeG2osSs/7lD3gCsOLOu6QL8awcC5TyO4wVvGV1l4WEs3zzPorZGkf+tG0Ri2c8 j/KmtiLW/tqXu9JkGdHN2Ul/PEKR3PGhKDj8Y56rE96mQ5a4BD1wPiIY9/IcPJHyLeFS iHodk/vtswNP5kuPqaFTYFghWdGKDEh6aPduQ6vJLD5OsSPO1fMQXHjQ1TxAOR1+lU6P J/WzPQC5hevNpKvZmCd5aQ8LADPabI+kYKMJuoI+pPQhlN8YDxjFM4IfqB3WMIsxuGR2 uVow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=a60adGDxqttpuFcY7jkALjROpt4E168K4TU36LymXcQ=; b=A12CVnNGMYm4j6oEXIyMEVnQXxIpl8eglxa72TAlXD4E/V8oyypTAlalmXVkptoULF VadGJzEDw4+gqRAhLPICuDcLI/L9vD/ZWGkz9Mt2FlDGOlF/ZSXal5Ny7R6T8fJ74vRl IB70udsNlxglyq3t+V9MuTDqKye389e0dYMHTu9ZYmvlXw7bXrx+gOvZq4/mBVoFetDu cXEowIoTVCMFgvQspGYggZvUrLzwiGPjOKZwfhjr3J8KN6mnbsdxlQHx0Xlj5DPpyn0u NpmGTk5X4N6xpVnrKPzN7uJhHIZ+6rzvofuqYfwlgIESsqUanP6i8lgy9m2w2Z0fplb2 YY5g== X-Gm-Message-State: AOAM531ljk5bju/2s7VeRERJEjaEaG1CgbkXGJ7Hg9NVBxAIeaXdS8ge tJwJlFhErr5G4DMEUGgVwcUfz0fxpe4DzrDLHaeLJzXGu+2FsZzgQhNe8EZRTpW6PE74Ex+blAz 3Jdgni0OkIT2Q+BDY0Lx7d7j8qT+Ijcr39oWv1ziSUQME0ZGKP44EQNmB+hSj9CNMSBwKtE94Qj vTZKyJTo5UnhngZLDe X-Google-Smtp-Source: ABdhPJzfBMACV3i9Ag2je48WjOHXDjCnBloIo08bMmmfrF6UQkcJ9p9JN/Tx9z7Yh/AB7BqsJ+OmUXhXeqT6/JFDXhz1 X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:ad4:5653:: with SMTP id bl19mr24887200qvb.7.1600287378198; Wed, 16 Sep 2020 13:16:18 -0700 (PDT) Date: Wed, 16 Sep 2020 13:16:00 -0700 In-Reply-To: <20200916201602.1223002-1-danielwinkler@google.com> Message-Id: <20200916131430.4.I34169001276125c476e86ece0b4802c36aa08bca@changeid> Mime-Version: 1.0 References: <20200916201602.1223002-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH 4/6] Bluetooth: Emit tx power chosen on ext adv params completion From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.85 / 15.00 / 15.00 X-Rspamd-Queue-Id: 38C2840964 X-Rspamd-UID: d66543 Our hci call to set extended advertising parameters returns the actual tx power selected by the controller. This patch signals a new TX_POWER_SELECTED mgmt event to alert the caller of the actual tx power that is being used. This is important because the power selected will not necessarily match the power requested by the user. This patch is manually verified by ensuring the tx power selected event is signalled and caught by bluetoothd. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- include/net/bluetooth/hci_core.h | 2 ++ include/net/bluetooth/mgmt.h | 6 ++++++ net/bluetooth/hci_event.c | 4 ++++ net/bluetooth/mgmt.c | 11 +++++++++++ 4 files changed, 23 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index ab168f46b6d909..667b9d37099dec 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1781,6 +1781,8 @@ void mgmt_advertising_added(struct sock *sk, struct hci_dev *hdev, u8 instance); void mgmt_advertising_removed(struct sock *sk, struct hci_dev *hdev, u8 instance); +void mgmt_adv_tx_power_selected(struct hci_dev *hdev, u8 instance, + s8 tx_power); int mgmt_phy_configuration_changed(struct hci_dev *hdev, struct sock *skip); u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency, diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 859f0d3cd6ea38..db64cf4747554c 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -1079,3 +1079,9 @@ struct mgmt_ev_controller_resume { #define MGMT_WAKE_REASON_NON_BT_WAKE 0x0 #define MGMT_WAKE_REASON_UNEXPECTED 0x1 #define MGMT_WAKE_REASON_REMOTE_WAKE 0x2 + +#define MGMT_EV_ADV_TX_POWER_SELECTED 0x002f +struct mgmt_ev_adv_tx_power_selected { + __u8 instance; + __s8 tx_power; +} __packed; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index bd306ba3ade545..9a24fd99d9e08e 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1749,6 +1749,10 @@ static void hci_cc_set_ext_adv_param(struct hci_dev *hdev, struct sk_buff *skb) } /* Update adv data as tx power is known now */ hci_req_update_adv_data(hdev, hdev->cur_adv_instance); + + if (cp->handle) + mgmt_adv_tx_power_selected(hdev, cp->handle, rp->tx_power); + hci_dev_unlock(hdev); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 717c97affb1554..b9347ff1a1e961 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -167,6 +167,7 @@ static const u16 mgmt_events[] = { MGMT_EV_DEVICE_FLAGS_CHANGED, MGMT_EV_CONTROLLER_SUSPEND, MGMT_EV_CONTROLLER_RESUME, + MGMT_EV_ADV_TX_POWER_SELECTED, }; static const u16 mgmt_untrusted_commands[] = { @@ -1152,6 +1153,16 @@ void mgmt_advertising_removed(struct sock *sk, struct hci_dev *hdev, mgmt_event(MGMT_EV_ADVERTISING_REMOVED, hdev, &ev, sizeof(ev), sk); } +void mgmt_adv_tx_power_selected(struct hci_dev *hdev, u8 instance, s8 tx_power) +{ + struct mgmt_ev_adv_tx_power_selected ev; + + ev.instance = instance; + ev.tx_power = tx_power; + + mgmt_event(MGMT_EV_ADV_TX_POWER_SELECTED, hdev, &ev, sizeof(ev), NULL); +} + static void cancel_adv_timeout(struct hci_dev *hdev) { if (hdev->adv_instance_timeout) { -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AGwWI6pzYl/N0AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 22:20:58 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CAJxIKpzYl9JAgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 22:20:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id AA332A0B10; Wed, 16 Sep 2020 22:20:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728326AbgIPUUJ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 16:20:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728273AbgIPUQN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 16:16:13 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67FCFC06178B for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:12 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id 60so7063076qtf.21 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=ouJiHCy9pxH2T5sj1WvYnJy8YM/MOUySnAX+tlwL2Gg=; b=UH8BwLtkHWhbvtlrnOx6o/E+DHvd5pUr9rXriuBNxKQ8cgR4HYRcjlG+1Uhz8PsJmJ iszKYxgls1Lm7qMJE++pD96lGlHyUh6T0EQt7h+KYlbxQNyRF/225JVRS1z1M+f2ktnv am1k7dS8Ju9FsCpWZDUHpgA7ZyF8ETcqT5BSEwwzq33wM3QmAAsObTZHr7aAmTnsrdX5 ePRCv3rBzh64mrTm/pMOgQ8mi7T/yuxblGUjCdKoGi1ZXR6paZ3NSB+GlzlHa5GUrs2l df5UN0cmCy7Wd7NDRDmV/WikaCe3inVRL2MehUEmzlsWoAxkHQ7m7YNdNN65NsAGLy/E qb6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ouJiHCy9pxH2T5sj1WvYnJy8YM/MOUySnAX+tlwL2Gg=; b=Xk6oJDNin+aOa5Sz7gftQP/BaFEuNvmjXoNh7XmeamqAKCJfZ1IETvTab5m3naSLpc XG3wlGS72sOrDG1Vtd9pq2ZkAnYsEtgu+xvCdgVIijyPEhBctmDzYLRpGsN81ARr4Vzk K1LYDNeOrKEs9dLSQtmJrEc+XNEVxI31LYWWDXA3nVHsjKBmHTMJZwqnZhkBN2SKS9qZ YeSJpRjKWTo7jPpEHSIxx/e2pinga1dbLo666Q3/Fsoy+Zl42RWj7fIfwfp5zF8IZyRU yGmBKl7fWakxLfbQq9NhaMptMu85tf0s2OPgU1s0IrifVOa2G4g9Zn2bQJpb2qZwqmYl yktQ== X-Gm-Message-State: AOAM530T1wE+lC+5axP41+D+DAbpu8R39FEDfzA+aQiDr6IMI9v4RSl4 eLrabE8Rm3Hz8Bm0nC3di81HSzpEOsxSkSxTGm1AYmmv0d327drIVp+glXzWY8XjPqRx64Wl2W2 RIHLUoB2CHC2BSHYFM3ZyBFQMr+RXx34ANSfo1AQbYjsR/k+1Q0D/BRtwjhiO2b+13Qdj7olVAe 00jiXAH1J77/7BRQG1 X-Google-Smtp-Source: ABdhPJyOpQ4N29pZDC8hPDv7B7QRLfS+4nlHD81FOSX8Yz1lGNTqb8jjD+/PxRtpoZl1uLpN42r/+zYEa3sofnMw/bLj X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:ad4:57cc:: with SMTP id y12mr8902976qvx.48.1600287371193; Wed, 16 Sep 2020 13:16:11 -0700 (PDT) Date: Wed, 16 Sep 2020 13:15:57 -0700 In-Reply-To: <20200916201602.1223002-1-danielwinkler@google.com> Message-Id: <20200916131430.1.I5f4fa6a76fe81f977f78f06b7e68ff1c76c6bddf@changeid> Mime-Version: 1.0 References: <20200916201602.1223002-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH 1/6] Bluetooth: Add helper to set adv data From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.52 / 15.00 / 15.00 X-Rspamd-Queue-Id: AA332A0B10 X-Rspamd-UID: 1d8e80 We wish to handle advertising data separately from advertising parameters in our new MGMT requests. This change adds a helper that allows the advertising data and scan response to be updated for an existing advertising instance. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_core.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9873e1c8cd163b..300b3572d479e1 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1291,6 +1291,9 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, u16 adv_data_len, u8 *adv_data, u16 scan_rsp_len, u8 *scan_rsp_data, u16 timeout, u16 duration); +int hci_set_adv_instance_data(struct hci_dev *hdev, u8 instance, + u16 adv_data_len, u8 *adv_data, + u16 scan_rsp_len, u8 *scan_rsp_data); int hci_remove_adv_instance(struct hci_dev *hdev, u8 instance); void hci_adv_instances_set_rpa_expired(struct hci_dev *hdev, bool rpa_expired); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 8a2645a8330137..3f73f147826409 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3005,6 +3005,37 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, return 0; } +/* This function requires the caller holds hdev->lock */ +int hci_set_adv_instance_data(struct hci_dev *hdev, u8 instance, + u16 adv_data_len, u8 *adv_data, + u16 scan_rsp_len, u8 *scan_rsp_data) +{ + struct adv_info *adv_instance; + + adv_instance = hci_find_adv_instance(hdev, instance); + + /* If advertisement doesn't exist, we can't modify its data */ + if (!adv_instance) + return -ENOENT; + + if (adv_data_len) { + memset(adv_instance->adv_data, 0, + sizeof(adv_instance->adv_data)); + memcpy(adv_instance->adv_data, adv_data, adv_data_len); + adv_instance->adv_data_len = adv_data_len; + } + + if (scan_rsp_len) { + memset(adv_instance->scan_rsp_data, 0, + sizeof(adv_instance->scan_rsp_data)); + memcpy(adv_instance->scan_rsp_data, + scan_rsp_data, scan_rsp_len); + adv_instance->scan_rsp_len = scan_rsp_len; + } + + return 0; +} + /* This function requires the caller holds hdev->lock */ void hci_adv_monitors_clear(struct hci_dev *hdev) { -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oNd4HmJzYl+2VgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 22:19:46 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6IgtG2JzYl86GwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 22:19:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D1E7340971; Wed, 16 Sep 2020 22:19:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728365AbgIPUT3 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 16:19:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728287AbgIPUQS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 16:16:18 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 915BCC061352 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:15 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id b14so3912613pls.12 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 13:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=bBclFmx7g5tiBe29zWHfbwOtKlTZdcXOCblGDGmxSug=; b=VHs8qMsnXmgCv0zbl+CE6dYNvrRlwFPN7+6U9mZ2Yi2BtBkhTa6qtlKbR/oVVOzCgm IYK+a6N+kPZGAIMo4OOKw+8KZdlqlMuS3nonlX8Fp+0VaT9hQlg4bJEXxRtwTTCHNH2y zQ84QZepwK1U3GnAi7WMN9RgLzurzqIuRD5d16IIqUYBkjLv6hs8rn1gnHOht+BRO2/J vKFrw0K7+QYCIwyJ34x3ef/y6cs7oVIekNRqDh2NQ6XTrXbCyKsZN361R1l+qcspv2RP HKB7NzWS24yLTqc8jNdP6Sj96C7G4G1YTtFHiib32UHB5YMSATGaaHofPLVuyKsfX04w tb4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bBclFmx7g5tiBe29zWHfbwOtKlTZdcXOCblGDGmxSug=; b=svfXHZRTYqyUyup0LhBqtJDYBaJTvhSjk0gZ5s5//ghOKgspt3hYaq9oA30Iuophxn 91Fbm8v1u60ueE1V+MM90F6bUHUIIqTYOUC6Gs9dEkK8XFEJadHKYzuU30RBg9vKCxZx S8kjS6FWOdj6XZVD/JZ31EUWQwOuUskcyEQm/UJiF19NPWlVAx6/Xtt7rndV3KwLNVIx l7TXSvqiZX4Rm5qQLJ2P2Ws/niSnlcr3EQl/FYeLxjgrz5fGQRIQJSqG84P1fj4xy2rE ySFtKbPldEj0DT92ksxCEl0vTxCHJBdyEij5RLepfBwP9mwk6Vx/vT58+naNP7yZh31z D8tA== X-Gm-Message-State: AOAM530CZbCnd8KHuMqI7O5Z9Rm/GPjx6baGXs83dMes7c7rtSWp1B8H cESpu6hm0dfQr7gF/cnjFiSp2tQjXtE7CxoSi402NTJhjyADksaFuoJ2zsVNSmt/UfbXbX0K8vv Ht0xWKjqGZ050GczzWIRQL4SA7CcV3iawMme0KV1ij66rgElCiasAAEm40+Cw+tddF/N4zsa4Nb amHviUuUgpIpr0kUNB X-Google-Smtp-Source: ABdhPJzsrkaDe43Z64eHp/v1Nu1OnKW4yZSVY9tilgz3Y0d1IavkoPo6JFta0XpNZt16rh34+K+or8PKYhW3WBv18TL9 X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a17:902:eb54:b029:d1:f365:a668 with SMTP id i20-20020a170902eb54b02900d1f365a668mr3009819pli.69.1600287373580; Wed, 16 Sep 2020 13:16:13 -0700 (PDT) Date: Wed, 16 Sep 2020 13:15:58 -0700 In-Reply-To: <20200916201602.1223002-1-danielwinkler@google.com> Message-Id: <20200916131430.2.Id8bee28ed00d158d0894b32c0cd94baa5a012605@changeid> Mime-Version: 1.0 References: <20200916201602.1223002-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH 2/6] Bluetooth: Break add adv into two mgmt commands From: Daniel Winkler <danielwinkler@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.54 / 15.00 / 15.00 X-Rspamd-Queue-Id: D1E7340971 X-Rspamd-UID: a19a62 This patch adds support for the new advertising add interface, with the first command setting advertising parameters and the second to set advertising data. The set parameters command allows the caller to leave some fields "unset", with a params bitfield defining which params were purposefully set. Unset parameters will be given defaults when calling hci_add_adv_instance. The data passed to the param mgmt command is allowed to be flexible, so in the future if bluetoothd passes a larger structure with new params, the mgmt command will ignore the unknown members at the end. This change has been validated on both hatch (extended advertising) and kukui (no extended advertising) chromebooks running bluetoothd that support this new interface. I ran the following manual tests: - Set several (3) advertisements using modified test_advertisement.py - For each, validate correct data and parameters in btmon trace - Verified both for software rotation and extended adv Automatic test suite also run, testing many (25) scenarios of single and multi-advertising for data/parameter correctness. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- include/net/bluetooth/hci_core.h | 2 + include/net/bluetooth/mgmt.h | 33 +++ net/bluetooth/mgmt.c | 364 ++++++++++++++++++++++++++++++- 3 files changed, 388 insertions(+), 11 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 300b3572d479e1..48d144ae8b57d6 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -238,6 +238,8 @@ struct adv_info { #define HCI_MAX_ADV_INSTANCES 5 #define HCI_DEFAULT_ADV_DURATION 2 +#define HCI_ADV_TX_POWER_NO_PREFERENCE 0x7F + struct adv_pattern { struct list_head list; __u8 ad_type; diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 6b55155e05e977..859f0d3cd6ea38 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -782,6 +782,39 @@ struct mgmt_rp_remove_adv_monitor { __le16 monitor_handle; } __packed; +#define MGMT_ADV_PARAM_DURATION BIT(0) +#define MGMT_ADV_PARAM_TIMEOUT BIT(1) +#define MGMT_ADV_PARAM_INTERVALS BIT(2) +#define MGMT_ADV_PARAM_TX_POWER BIT(3) + +#define MGMT_OP_ADD_EXT_ADV_PARAMS 0x0054 +struct mgmt_cp_add_ext_adv_params { + __u8 instance; + __le32 flags; + __le16 params; + __le16 duration; + __le16 timeout; + __le32 min_interval; + __le32 max_interval; + __s8 tx_power; +} __packed; +#define MGMT_ADD_EXT_ADV_PARAMS_MIN_SIZE 20 +struct mgmt_rp_add_ext_adv_params { + __u8 instance; +} __packed; + +#define MGMT_OP_ADD_EXT_ADV_DATA 0x0055 +struct mgmt_cp_add_ext_adv_data { + __u8 instance; + __u8 adv_data_len; + __u8 scan_rsp_len; + __u8 data[]; +} __packed; +#define MGMT_ADD_EXT_ADV_DATA_SIZE 3 +struct mgmt_rp_add_ext_adv_data { + __u8 instance; +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { __le16 opcode; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 0b711ad80f6bd1..421b6784a114f9 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -122,6 +122,8 @@ static const u16 mgmt_commands[] = { MGMT_OP_READ_ADV_MONITOR_FEATURES, MGMT_OP_ADD_ADV_PATTERNS_MONITOR, MGMT_OP_REMOVE_ADV_MONITOR, + MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_OP_ADD_EXT_ADV_DATA, }; static const u16 mgmt_events[] = { @@ -7372,6 +7374,31 @@ static bool tlv_data_is_valid(struct hci_dev *hdev, u32 adv_flags, u8 *data, return true; } +static bool requested_adv_flags_are_valid(struct hci_dev *hdev, u32 adv_flags) +{ + u32 supported_flags, phy_flags; + + /* The current implementation only supports a subset of the specified + * flags. Also need to check mutual exclusiveness of sec flags. + */ + supported_flags = get_supported_adv_flags(hdev); + phy_flags = adv_flags & MGMT_ADV_FLAG_SEC_MASK; + if (adv_flags & ~supported_flags || + ((phy_flags && (phy_flags ^ (phy_flags & -phy_flags))))) + return false; + + return true; +} + +static bool adv_busy(struct hci_dev *hdev) +{ + return (pending_find(MGMT_OP_ADD_ADVERTISING, hdev) || + pending_find(MGMT_OP_REMOVE_ADVERTISING, hdev) || + pending_find(MGMT_OP_SET_LE, hdev) || + pending_find(MGMT_OP_ADD_EXT_ADV_PARAMS, hdev) || + pending_find(MGMT_OP_ADD_EXT_ADV_DATA, hdev)); +} + static void add_advertising_complete(struct hci_dev *hdev, u8 status, u16 opcode) { @@ -7386,6 +7413,8 @@ static void add_advertising_complete(struct hci_dev *hdev, u8 status, hci_dev_lock(hdev); cmd = pending_find(MGMT_OP_ADD_ADVERTISING, hdev); + if (!cmd) + cmd = pending_find(MGMT_OP_ADD_EXT_ADV_DATA, hdev); list_for_each_entry_safe(adv_instance, n, &hdev->adv_instances, list) { if (!adv_instance->pending) @@ -7430,7 +7459,6 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, struct mgmt_cp_add_advertising *cp = data; struct mgmt_rp_add_advertising rp; u32 flags; - u32 supported_flags, phy_flags; u8 status; u16 timeout, duration; unsigned int prev_instance_cnt = hdev->adv_instance_cnt; @@ -7466,13 +7494,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, timeout = __le16_to_cpu(cp->timeout); duration = __le16_to_cpu(cp->duration); - /* The current implementation only supports a subset of the specified - * flags. Also need to check mutual exclusiveness of sec flags. - */ - supported_flags = get_supported_adv_flags(hdev); - phy_flags = flags & MGMT_ADV_FLAG_SEC_MASK; - if (flags & ~supported_flags || - ((phy_flags && (phy_flags ^ (phy_flags & -phy_flags))))) + if (!requested_adv_flags_are_valid(hdev, flags)) return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, MGMT_STATUS_INVALID_PARAMS); @@ -7484,9 +7506,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, goto unlock; } - if (pending_find(MGMT_OP_ADD_ADVERTISING, hdev) || - pending_find(MGMT_OP_REMOVE_ADVERTISING, hdev) || - pending_find(MGMT_OP_SET_LE, hdev)) { + if (adv_busy(hdev)) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, MGMT_STATUS_BUSY); goto unlock; @@ -7577,6 +7597,324 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, return err; } +static void add_ext_adv_params_complete(struct hci_dev *hdev, u8 status, + u16 opcode) +{ + struct mgmt_pending_cmd *cmd; + struct mgmt_cp_add_ext_adv_params *cp; + struct mgmt_rp_add_ext_adv_params rp; + struct adv_info *adv_instance; + + BT_DBG("%s", hdev->name); + + hci_dev_lock(hdev); + + cmd = pending_find(MGMT_OP_ADD_EXT_ADV_PARAMS, hdev); + + if (!cmd) + goto unlock; + + cp = cmd->param; + rp.instance = cp->instance; + + if (status) { + adv_instance = hci_find_adv_instance(hdev, cp->instance); + + /* If this advertisement was previously advertising and we + * failed to update it, we signal that it has been removed and + * delete its structure + */ + if (!adv_instance->pending) + mgmt_advertising_removed(cmd->sk, hdev, cp->instance); + + hci_remove_adv_instance(hdev, cp->instance); + + mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, + mgmt_status(status)); + + } else { + mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, + mgmt_status(status), &rp, sizeof(rp)); + } + + mgmt_pending_remove(cmd); + +unlock: + hci_dev_unlock(hdev); +} + +static int add_ext_adv_params(struct sock *sk, struct hci_dev *hdev, + void *data, u16 data_len) +{ + struct mgmt_cp_add_ext_adv_params *cp = data; + struct mgmt_rp_add_ext_adv_params rp; + struct mgmt_pending_cmd *cmd = NULL; + struct adv_info *adv_instance; + struct hci_request req; + u32 flags, min_interval, max_interval; + u16 params, timeout, duration; + u8 status; + s8 tx_power; + int err; + + BT_DBG("%s", hdev->name); + + status = mgmt_le_support(hdev); + if (status) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + status); + + if (cp->instance < 1 || cp->instance > hdev->le_num_of_adv_sets) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_INVALID_PARAMS); + + /* The purpose of breaking add_advertising into two separate MGMT calls + * for params and data is to allow more parameters to be added to this + * structure in the future. For this reason, we verify that we have the + * bare minimum structure we know of when the interface was defined. Any + * extra parameters we don't know about will be ignored in this request. + */ + if (data_len < MGMT_ADD_EXT_ADV_PARAMS_MIN_SIZE) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, + MGMT_STATUS_INVALID_PARAMS); + + flags = __le32_to_cpu(cp->flags); + params = __le16_to_cpu(cp->params); + + if (!requested_adv_flags_are_valid(hdev, flags)) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_INVALID_PARAMS); + + hci_dev_lock(hdev); + + /* In new interface, we require that we are powered to register */ + if (!hdev_is_powered(hdev)) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_REJECTED); + goto unlock; + } + + if (adv_busy(hdev)) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_BUSY); + goto unlock; + } + + /* Parse defined parameters from request, use defaults otherwise */ + timeout = (params & MGMT_ADV_PARAM_TIMEOUT) ? + __le16_to_cpu(cp->timeout) : 0; + + duration = (params & MGMT_ADV_PARAM_DURATION) ? + __le16_to_cpu(cp->duration) : + hdev->def_multi_adv_rotation_duration; + + min_interval = (params & MGMT_ADV_PARAM_INTERVALS) ? + __le32_to_cpu(cp->min_interval) : + hdev->le_adv_min_interval; + + max_interval = (params & MGMT_ADV_PARAM_INTERVALS) ? + __le32_to_cpu(cp->max_interval) : + hdev->le_adv_max_interval; + + tx_power = (params & MGMT_ADV_PARAM_INTERVALS) ? + cp->tx_power : + HCI_ADV_TX_POWER_NO_PREFERENCE; + + /* Create advertising instance with no advertising or response data */ + err = hci_add_adv_instance(hdev, cp->instance, flags, + 0, NULL, 0, NULL, timeout, duration); + + if (err < 0) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_FAILED); + goto unlock; + } + + hdev->cur_adv_instance = cp->instance; + /* Submit request for advertising params if ext adv available */ + if (ext_adv_capable(hdev)) { + hci_req_init(&req, hdev); + adv_instance = hci_find_adv_instance(hdev, cp->instance); + + /* Updating parameters of an active instance will return a + * Command Disallowed error, so we must first disable the + * instance if it is active. + */ + if (!adv_instance->pending) + __hci_req_disable_ext_adv_instance(&req, cp->instance); + + __hci_req_setup_ext_adv_instance(&req, cp->instance); + + err = hci_req_run(&req, add_ext_adv_params_complete); + + if (!err) + cmd = mgmt_pending_add(sk, MGMT_OP_ADD_EXT_ADV_PARAMS, + hdev, data, data_len); + if (!cmd) { + err = -ENOMEM; + hci_remove_adv_instance(hdev, cp->instance); + goto unlock; + } + + } else { + rp.instance = cp->instance; + err = mgmt_cmd_complete(sk, hdev->id, + MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_SUCCESS, &rp, sizeof(rp)); + } + +unlock: + hci_dev_unlock(hdev); + + return err; +} + +static int add_ext_adv_data(struct sock *sk, struct hci_dev *hdev, void *data, + u16 data_len) +{ + struct mgmt_cp_add_ext_adv_data *cp = data; + struct mgmt_rp_add_ext_adv_data rp; + u8 schedule_instance = 0; + struct adv_info *next_instance; + struct adv_info *adv_instance; + int err = 0; + struct mgmt_pending_cmd *cmd; + struct hci_request req; + + BT_DBG("%s", hdev->name); + + hci_dev_lock(hdev); + + adv_instance = hci_find_adv_instance(hdev, cp->instance); + + if (!adv_instance) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_INVALID_PARAMS); + goto unlock; + } + + /* In new interface, we require that we are powered to register */ + if (!hdev_is_powered(hdev)) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_REJECTED); + goto clear_new_instance; + } + + if (adv_busy(hdev)) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_BUSY); + goto clear_new_instance; + } + + /* Validate new data */ + if (!tlv_data_is_valid(hdev, adv_instance->flags, cp->data, + cp->adv_data_len, true) || + !tlv_data_is_valid(hdev, adv_instance->flags, cp->data + + cp->adv_data_len, cp->scan_rsp_len, false)) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_INVALID_PARAMS); + goto clear_new_instance; + } + + /* Set the data in the advertising instance */ + hci_set_adv_instance_data(hdev, cp->instance, cp->adv_data_len, + cp->data, cp->scan_rsp_len, + cp->data + cp->adv_data_len); + + /* We're good to go, update advertising data, parameters, and start + * advertising. + */ + + hci_req_init(&req, hdev); + + hci_req_add(&req, HCI_OP_READ_LOCAL_NAME, 0, NULL); + + if (ext_adv_capable(hdev)) { + __hci_req_update_adv_data(&req, cp->instance); + __hci_req_update_scan_rsp_data(&req, cp->instance); + __hci_req_enable_ext_advertising(&req, cp->instance); + + } else { + /* If using software rotation, determine next instance to use */ + + if (hdev->cur_adv_instance == cp->instance) { + /* If the currently advertised instance is being changed + * then cancel the current advertising and schedule the + * next instance. If there is only one instance then the + * overridden advertising data will be visible right + * away + */ + cancel_adv_timeout(hdev); + + next_instance = hci_get_next_instance(hdev, + cp->instance); + if (next_instance) + schedule_instance = next_instance->instance; + } else if (!hdev->adv_instance_timeout) { + /* Immediately advertise the new instance if no other + * instance is currently being advertised. + */ + schedule_instance = cp->instance; + } + + /* If the HCI_ADVERTISING flag is set or there is no instance to + * be advertised then we have no HCI communication to make. + * Simply return. + */ + if (hci_dev_test_flag(hdev, HCI_ADVERTISING) || + !schedule_instance) { + if (adv_instance->pending) { + mgmt_advertising_added(sk, hdev, cp->instance); + adv_instance->pending = false; + } + rp.instance = cp->instance; + err = mgmt_cmd_complete(sk, hdev->id, + MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_SUCCESS, &rp, + sizeof(rp)); + goto unlock; + } + + err = __hci_req_schedule_adv_instance(&req, schedule_instance, + true); + } + + cmd = mgmt_pending_add(sk, MGMT_OP_ADD_EXT_ADV_DATA, hdev, data, + data_len); + if (!cmd) { + err = -ENOMEM; + goto clear_new_instance; + } + + if (!err) + err = hci_req_run(&req, add_advertising_complete); + + if (err < 0) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_FAILED); + mgmt_pending_remove(cmd); + goto clear_new_instance; + } + + /* We were successful in updating data, so trigger advertising_added + * event if this is an instance that wasn't previously advertising. If + * a failure occurs in the requests we initiated, we will remove the + * instance again in add_advertising_complete + */ + if (adv_instance->pending) + mgmt_advertising_added(sk, hdev, cp->instance); + + goto unlock; + +clear_new_instance: + hci_remove_adv_instance(hdev, cp->instance); + +unlock: + hci_dev_unlock(hdev); + + return err; +} + static void remove_advertising_complete(struct hci_dev *hdev, u8 status, u16 opcode) { @@ -7851,6 +8189,10 @@ static const struct hci_mgmt_handler mgmt_handlers[] = { { add_adv_patterns_monitor,MGMT_ADD_ADV_PATTERNS_MONITOR_SIZE, HCI_MGMT_VAR_LEN }, { remove_adv_monitor, MGMT_REMOVE_ADV_MONITOR_SIZE }, + { add_ext_adv_params, MGMT_ADD_EXT_ADV_PARAMS_MIN_SIZE, + HCI_MGMT_VAR_LEN }, + { add_ext_adv_data, MGMT_ADD_EXT_ADV_DATA_SIZE, + HCI_MGMT_VAR_LEN }, }; void mgmt_index_added(struct hci_dev *hdev) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cHOoGXV4Yl9KIgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 22:41:25 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4NfCFnV4Yl/KFAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 22:41:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C7F58A017C; Wed, 16 Sep 2020 22:41:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728320AbgIPUkx (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 16:40:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726763AbgIPREy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 13:04:54 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EFC4C02C2BD for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 09:39:37 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id i17so8792499oig.10 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 09:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4T/t9mVdAvOOOseWLYn1uXmcACQz9WRAYDnt0w3qa7A=; b=gZEpwUI8r8q64JSIi95Zezc5PyFZSnDScfsPsTHS7kiWXC//MZP+d5qWutf0rUwxZr mQjnDtc0ZiId55nWLIcvQfx8ZdzuR2CpPlmtqPow4J4e7FKewsGZ/SjXTyoJhWmS0ltJ lm5dk7wqm5beLpx6QnvHTTr4EaxML5GRF237aTf3kzf/9FzCCAtRLgujZEeFd7csG+iB zCdvMh4y9nSKoF9CO/SiBBmGyNdly0C/VT8OKPZxatCL96jxEpnxLI0u2mOTS0wu/JUr 3tMiAKCSJYiypP7yz46nhTNta9MlMHN3/9CjrLz3c+w2OXFp9OgyMbndqn4A99OyrvSK 8NJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4T/t9mVdAvOOOseWLYn1uXmcACQz9WRAYDnt0w3qa7A=; b=ibEMA0Nf50if/78FHmxZIcs+P/f2EonxAIE/mCCX4n7+ruCg3Y+8Jdr9Wj66Z4aSiS KfF3aKqtoR+qW33Wf2u8FCF6jECCB9g4SKSRNwna53DFu9MRqeIUrrgNM8zRAUOWQC71 OoPpRiTn40YkXUhpZkt2avzvHR2KSGNoOmajAzPGF67QqapQkXPgtkaR9Kx9nfVdN+BN hDVTmHyqPdLseXtH+MlGjviZy0x1R1zP59uI7utPF5LFflmDwhZBSDBfvMAv253Bjb4W IlJoSuPLDbZVDeePhAaOqZMWbV9AUd+FS/bSuv7OnKgyRUydOLlzz/UJZclEqJ3aEMr1 0nLg== X-Gm-Message-State: AOAM533dcQ2AhRYGfyT7TCPF/+l9ISnlhLOOV8S1f5qVSHjt12FiMXml H9RWFU2QLW9MTm+47cpSSHj+HsaYUCkq2B565sE= X-Google-Smtp-Source: ABdhPJxRkasUcGEbrAFpNyhA7vhkICd/wlf0VeC8qqkGysCYse4TsgzYPGCG0J46cfNda8ALPnlOOTE9aSkLq+Rv9SA= X-Received: by 2002:aca:38d7:: with SMTP id f206mr3400230oia.48.1600274376210; Wed, 16 Sep 2020 09:39:36 -0700 (PDT) MIME-Version: 1.0 References: <20200916151617.BlueZ.v5.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> In-Reply-To: <20200916151617.BlueZ.v5.1.I8e067a74d324751fc788f53e0c14f60923683d01@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 16 Sep 2020 09:39:24 -0700 Message-ID: <CABBYNZJ6ROUaDiRPAZOH4QCD+aPwO0CPqD=DJW1eBw5CsP+=Vg@mail.gmail.com> Subject: Re: [BlueZ PATCH v5 1/4] client: Implement basic interface of ADV monitor in bluetoothctl To: Howard Chung <howardchung@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Luiz Augusto Von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.26 / 15.00 / 15.00 X-Rspamd-Queue-Id: C7F58A017C X-Rspamd-UID: 1c0ee5 Hi Howard, On Wed, Sep 16, 2020 at 12:20 AM Howard Chung <howardchung@google.com> wrote: > > This patch implements some basic functions for ADV monitor in > bluetoothctl > > [bluetooth]# show > ... > Advertisement Monitor Features: > SupportedMonitorTypes: or_patterns > > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > --- > > Changes in v5: > - Rephrase condition == TRUE/FALSE to condition/!condition > - Add bt_shell_noninteractive_quit(EXIT_SUCCESS) in register_reply > - Remove unused variable 'conn' > - Move a change regarding checking the status of app registered from patch 2/4 > to 1/4 > > Changes in v4: > - Remove PRE-UPSTREAM in commit title > > Changes in v3: > - Rename advertisement_monitor to adv_monitor > > Changes in v2: > - Update the add-pattern usage > - Fix styling issue in patch 1 > - Fix storage class declaration issue > > Makefile.tools | 2 + > client/adv_monitor.c | 165 +++++++++++++++++++++++++++++++++++++++++++ > client/adv_monitor.h | 23 ++++++ > client/main.c | 28 ++++++++ > 4 files changed, 218 insertions(+) > create mode 100644 client/adv_monitor.c > create mode 100644 client/adv_monitor.h > > diff --git a/Makefile.tools b/Makefile.tools > index 9b9236609..ed0fbf8a3 100644 > --- a/Makefile.tools > +++ b/Makefile.tools > @@ -7,6 +7,8 @@ client_bluetoothctl_SOURCES = client/main.c \ > client/agent.h client/agent.c \ > client/advertising.h \ > client/advertising.c \ > + client/adv_monitor.h \ > + client/adv_monitor.c \ > client/gatt.h client/gatt.c > client_bluetoothctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \ > $(GLIB_LIBS) $(DBUS_LIBS) -lreadline > diff --git a/client/adv_monitor.c b/client/adv_monitor.c > new file mode 100644 > index 000000000..dda0eaf90 > --- /dev/null > +++ b/client/adv_monitor.c > @@ -0,0 +1,165 @@ > +/* > + * > + * BlueZ - Bluetooth protocol stack for Linux > + * > + * Copyright (C) 2020 Google LLC > + * > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + */ > + > +#ifdef HAVE_CONFIG_H > +#include <config.h> > +#endif > + > +#define _GNU_SOURCE > +#include <stdio.h> > +#include <stdlib.h> > +#include <stdint.h> > +#include <stdbool.h> > +#include <string.h> > + > +#include "gdbus/gdbus.h" > +#include "src/shared/util.h" > +#include "src/shared/shell.h" > +#include "adv_monitor.h" > + > +#define ADV_MONITOR_APP_PATH "/org/bluez/adv_monitor_app" > +#define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" > + > +static struct adv_monitor_manager { > + GSList *supported_types; > + GSList *supported_features; > + GDBusProxy *proxy; > + gboolean app_registered; > +} manager = { NULL, NULL, NULL, FALSE }; > + > +static void set_supported_list(GSList **list, DBusMessageIter *iter) > +{ > + char *str; > + DBusMessageIter subiter; > + > + dbus_message_iter_recurse(iter, &subiter); > + while (dbus_message_iter_get_arg_type(&subiter) == > + DBUS_TYPE_STRING) { > + dbus_message_iter_get_basic(&subiter, &str); > + *list = g_slist_append(*list, str); > + dbus_message_iter_next(&subiter); > + } > +} > + > +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy) > +{ > + DBusMessageIter iter; > + > + if (manager.proxy != NULL || manager.supported_types != NULL || > + manager.supported_features != NULL) { > + bt_shell_printf("advertisement monitor manager already " > + "added\n"); > + return; > + } > + > + manager.proxy = proxy; > + > + if (g_dbus_proxy_get_property(proxy, "SupportedMonitorTypes", &iter)) > + set_supported_list(&(manager.supported_types), &iter); > + > + if (g_dbus_proxy_get_property(proxy, "SupportedFeatures", &iter)) > + set_supported_list(&(manager.supported_features), &iter); > + > +} > + > +void adv_monitor_remove_manager(DBusConnection *conn) > +{ > + if (manager.supported_types != NULL) > + g_slist_free(g_steal_pointer(&(manager.supported_types))); > + if (manager.supported_features != NULL) > + g_slist_free(g_steal_pointer(&(manager.supported_features))); > + manager.proxy = NULL; > + manager.app_registered = FALSE; > +} > + > +static void register_setup(DBusMessageIter *iter, void *user_data) > +{ > + const char *path = ADV_MONITOR_APP_PATH; > + > + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); > +} > + > +static void register_reply(DBusMessage *message, void *user_data) > +{ > + DBusError error; > + > + dbus_error_init(&error); > + > + if (!dbus_set_error_from_message(&error, message)) { > + bt_shell_printf("AdvertisementMonitor path registered\n"); > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > + } > + > + bt_shell_printf("Failed to register path: %s\n", error.name); > + dbus_error_free(&error); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > +} > + > +static void unregister_setup(DBusMessageIter *iter, void *user_data) > +{ > + const char *path = ADV_MONITOR_APP_PATH; > + > + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); > +} > + > +static void unregister_reply(DBusMessage *message, void *user_data) > +{ > + DBusError error; > + > + dbus_error_init(&error); > + > + if (!dbus_set_error_from_message(&error, message)) { > + bt_shell_printf("AdvertisementMonitor path unregistered\n"); > + return bt_shell_noninteractive_quit(EXIT_SUCCESS); > + } > + > + bt_shell_printf("Failed to unregister Advertisement Monitor:" > + " %s\n", error.name); > + dbus_error_free(&error); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > +} > + > +void adv_monitor_register_app(DBusConnection *conn) > +{ > + if (manager.app_registered) { > + bt_shell_printf("Advertisement Monitor already registered\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } else if (manager.supported_types == NULL || > + !g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor", > + register_setup, register_reply, > + NULL, NULL)) { > + bt_shell_printf("Failed to register Advertisement Monitor\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + manager.app_registered = TRUE; > +} > + > +void adv_monitor_unregister_app(DBusConnection *conn) > +{ > + if (!manager.app_registered) { > + bt_shell_printf("Advertisement Monitor not registered\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } else if (!g_dbus_proxy_method_call(manager.proxy, "UnregisterMonitor", > + unregister_setup, unregister_reply, > + NULL, NULL)) { > + bt_shell_printf("Failed to unregister Advertisement Monitor\n"); > + return bt_shell_noninteractive_quit(EXIT_FAILURE); > + } > + manager.app_registered = FALSE; > +} > diff --git a/client/adv_monitor.h b/client/adv_monitor.h > new file mode 100644 > index 000000000..77b0b62c6 > --- /dev/null > +++ b/client/adv_monitor.h > @@ -0,0 +1,23 @@ > +/* > + * > + * BlueZ - Bluetooth protocol stack for Linux > + * > + * Copyright (C) 2020 Google LLC > + * > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + */ > + > +void adv_monitor_add_manager(DBusConnection *conn, GDBusProxy *proxy); > +void adv_monitor_remove_manager(DBusConnection *conn); > +void adv_monitor_register_app(DBusConnection *conn); > +void adv_monitor_unregister_app(DBusConnection *conn); > diff --git a/client/main.c b/client/main.c > index da877b546..75f8bc462 100644 > --- a/client/main.c > +++ b/client/main.c > @@ -41,6 +41,7 @@ > #include "agent.h" > #include "gatt.h" > #include "advertising.h" > +#include "adv_monitor.h" > > /* String display constants */ > #define COLORED_NEW COLOR_GREEN "NEW" COLOR_OFF > @@ -58,6 +59,7 @@ static char *auto_register_agent = NULL; > struct adapter { > GDBusProxy *proxy; > GDBusProxy *ad_proxy; > + GDBusProxy *adv_monitor_proxy; > GList *devices; > }; > > @@ -528,6 +530,19 @@ static void ad_manager_added(GDBusProxy *proxy) > adapter->ad_proxy = proxy; > } > > +static void admon_manager_added(GDBusProxy *proxy) > +{ > + struct adapter *adapter; > + > + adapter = find_ctrl(ctrl_list, g_dbus_proxy_get_path(proxy)); > + if (!adapter) > + adapter = adapter_new(proxy); > + > + adapter->adv_monitor_proxy = proxy; > + adv_monitor_add_manager(dbus_conn, proxy); > + adv_monitor_register_app(dbus_conn); > +} > + > static void proxy_added(GDBusProxy *proxy, void *user_data) > { > const char *interface; > @@ -560,6 +575,9 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) > ad_manager_added(proxy); > } else if (!strcmp(interface, "org.bluez.Battery1")) { > battery_added(proxy); > + } else if (!strcmp(interface, > + "org.bluez.AdvertisementMonitorManager1")) { > + admon_manager_added(proxy); > } > } > > @@ -653,6 +671,9 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) > ad_unregister(dbus_conn, NULL); > } else if (!strcmp(interface, "org.bluez.Battery1")) { > battery_removed(proxy); > + } else if (!strcmp(interface, > + "org.bluez.AdvertisementMonitorManager1")) { > + adv_monitor_remove_manager(dbus_conn); > } > } > > @@ -935,6 +956,13 @@ static void cmd_show(int argc, char *argv[]) > print_property(adapter->ad_proxy, "SupportedSecondaryChannels"); > } > > + if (adapter->adv_monitor_proxy) { > + bt_shell_printf("Advertisement Monitor Features:\n"); > + print_property(adapter->adv_monitor_proxy, > + "SupportedMonitorTypes"); > + print_property(adapter->adv_monitor_proxy, "SupportedFeatures"); > + } > + > return bt_shell_noninteractive_quit(EXIT_SUCCESS); > } > > -- > 2.28.0.618.gf4bc123cb7-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UMQmCxl5Yl/N0AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 22:44:09 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id yN3sCBl5Yl+wKgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 22:44:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 93B1BA01F5; Wed, 16 Sep 2020 22:43:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728410AbgIPUnn convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 16:43:43 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:52797 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbgIPRD2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 13:03:28 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 6372ECED04; Wed, 16 Sep 2020 16:34:38 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v1] Bluetooth: Use NVM files based on SoC ID for WCN3991 From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <1600184605-31611-1-git-send-email-gubbaven@codeaurora.org> Date: Wed, 16 Sep 2020 16:27:41 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, Matthias Kaehlcke <mka@chromium.org>, open list <linux-kernel@vger.kernel.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, Hemantg <hemantg@codeaurora.org>, MSM <linux-arm-msm@vger.kernel.org>, Balakrishna Godavarthi <bgodavar@codeaurora.org>, Rocky Liao <rjliao@codeaurora.org>, hbandi@codeaurora.org, abhishekpandit@chromium.org Content-Transfer-Encoding: 8BIT Message-Id: <A07A6C72-55B6-4DE6-BA4A-987ED4DB88E0@holtmann.org> References: <1600184605-31611-1-git-send-email-gubbaven@codeaurora.org> To: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.06 / 15.00 / 15.00 X-Rspamd-Queue-Id: 93B1BA01F5 X-Rspamd-UID: 261b6e Hi Venkata, > This change will allow to use different NVM file based > on WCN3991 BT SoC ID.Need to use different NVM file based on > fab location for WCN3991 BT SoC. > > Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org> > --- > drivers/bluetooth/btqca.c | 41 +++++++++++++++++++++++++---------------- > drivers/bluetooth/btqca.h | 13 ++++++++----- > drivers/bluetooth/hci_qca.c | 11 +++++------ > 3 files changed, 38 insertions(+), 27 deletions(-) > > diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c > index ce9dcff..a7e72f1 100644 > --- a/drivers/bluetooth/btqca.c > +++ b/drivers/bluetooth/btqca.c > @@ -14,12 +14,11 @@ > > #define VERSION "0.1" > > -int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, > +int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver, > enum qca_btsoc_type soc_type) > { > struct sk_buff *skb; > struct edl_event_hdr *edl; > - struct qca_btsoc_version *ver; > char cmd; > int err = 0; > u8 event_type = HCI_EV_VENDOR; > @@ -70,9 +69,9 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, > } > > if (soc_type >= QCA_WCN3991) > - memmove(&edl->data, &edl->data[1], sizeof(*ver)); > - > - ver = (struct qca_btsoc_version *)(edl->data); > + memcpy(ver, &edl->data[1], sizeof(*ver)); any reason to use &edl->data[1] and not just edl->data + 1? > + else > + memcpy(ver, &edl->data, sizeof(*ver)); > > bt_dev_info(hdev, "QCA Product ID :0x%08x", > le32_to_cpu(ver->product_id)); > @@ -83,13 +82,7 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, > bt_dev_info(hdev, "QCA Patch Version:0x%08x", > le16_to_cpu(ver->patch_ver)); > > - /* QCA chipset version can be decided by patch and SoC > - * version, combination with upper 2 bytes from SoC > - * and lower 2 bytes from patch will be used. > - */ > - *soc_version = (le32_to_cpu(ver->soc_id) << 16) | > - (le16_to_cpu(ver->rom_ver) & 0x0000ffff); > - if (*soc_version == 0) > + if (le32_to_cpu(ver->soc_id) == 0 || le16_to_cpu(ver->rom_ver) == 0) > err = -EILSEQ; > > out: > @@ -446,15 +439,25 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) > EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome); > > int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, > - enum qca_btsoc_type soc_type, u32 soc_ver, > + enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, > const char *firmware_name) > { > struct qca_fw_config config; > int err; > u8 rom_ver = 0; > + u32 soc_ver; > > bt_dev_dbg(hdev, "QCA setup on UART"); > > + /* QCA chipset version can be decided by patch and SoC > + * version, combination with upper 2 bytes from SoC > + * and lower 2 bytes from patch will be used. > + */ > + soc_ver = (le32_to_cpu(ver.soc_id) << 16) | > + (le16_to_cpu(ver.rom_ver) & 0x0000ffff); Please indent this properly. I am also confused about the 0x0000ffff since it is just 16-bit value in the first place. Also where do you want to shift the 32-bit value to. Frankly, I find all this version magic kinda questionable. > + > + bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); > + > config.user_baud_rate = baudrate; > > /* Download rampatch file */ > @@ -491,9 +494,15 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, > if (firmware_name) > snprintf(config.fwname, sizeof(config.fwname), > "qca/%s", firmware_name); > - else if (qca_is_wcn399x(soc_type)) > - snprintf(config.fwname, sizeof(config.fwname), > - "qca/crnv%02x.bin", rom_ver); > + else if (qca_is_wcn399x(soc_type)) { > + if (ver.soc_id == QCA_WCN3991_SOC_ID) { > + snprintf(config.fwname, sizeof(config.fwname), > + "qca/crnv%02xu.bin", rom_ver); > + } else { > + snprintf(config.fwname, sizeof(config.fwname), > + "qca/crnv%02x.bin", rom_ver); > + } > + } > else if (soc_type == QCA_QCA6390) > snprintf(config.fwname, sizeof(config.fwname), > "qca/htnv%02x.bin", rom_ver); > diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h > index d81b74c..d01a9f5 100644 > --- a/drivers/bluetooth/btqca.h > +++ b/drivers/bluetooth/btqca.h > @@ -34,6 +34,8 @@ > #define QCA_HCI_CC_OPCODE 0xFC00 > #define QCA_HCI_CC_SUCCESS 0x00 > > +#define QCA_WCN3991_SOC_ID (0x40014320) > + > enum qca_baudrate { > QCA_BAUDRATE_115200 = 0, > QCA_BAUDRATE_57600, > @@ -136,9 +138,9 @@ enum qca_btsoc_type { > > int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr); > int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, > - enum qca_btsoc_type soc_type, u32 soc_ver, > + enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, > const char *firmware_name); > -int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, > +int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver, > enum qca_btsoc_type); > int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); > int qca_send_pre_shutdown_cmd(struct hci_dev *hdev); > @@ -155,13 +157,14 @@ static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdad > } > > static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, > - enum qca_btsoc_type soc_type, u32 soc_ver, > - const char *firmware_name) > + enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, > + const char *firmware_name) Please use proper indentation. > { > return -EOPNOTSUPP; > } > > -static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, > +static inline int qca_read_soc_version(struct hci_dev *hdev, > + struct qca_btsoc_version *ver, > enum qca_btsoc_type) > { > return -EOPNOTSUPP; > diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c > index 244b8fe..4c32c60 100644 > --- a/drivers/bluetooth/hci_qca.c > +++ b/drivers/bluetooth/hci_qca.c > @@ -1649,7 +1649,7 @@ static int qca_setup(struct hci_uart *hu) > enum qca_btsoc_type soc_type = qca_soc_type(hu); > const char *firmware_name = qca_get_firmware_name(hu); > int ret; > - int soc_ver = 0; > + struct qca_btsoc_version ver; > > ret = qca_check_speeds(hu); > if (ret) > @@ -1678,7 +1678,7 @@ static int qca_setup(struct hci_uart *hu) > if (qca_is_wcn399x(soc_type)) { > set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks); > > - ret = qca_read_soc_version(hdev, &soc_ver, soc_type); > + ret = qca_read_soc_version(hdev, &ver, soc_type); > if (ret) > return ret; > } else { > @@ -1697,15 +1697,14 @@ static int qca_setup(struct hci_uart *hu) > > if (!qca_is_wcn399x(soc_type)) { > /* Get QCA version information */ > - ret = qca_read_soc_version(hdev, &soc_ver, soc_type); > + ret = qca_read_soc_version(hdev, &ver, soc_type); > if (ret) > return ret; > } > > - bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); > /* Setup patch / NVM configurations */ > - ret = qca_uart_setup(hdev, qca_baudrate, soc_type, soc_ver, > - firmware_name); > + ret = qca_uart_setup(hdev, qca_baudrate, soc_type, ver, > + firmware_name); > if (!ret) { > set_bit(QCA_IBS_ENABLED, &qca->flags); > qca_debugfs_init(hdev); Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aC3KE658Yl+2VgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 22:59:26 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sJQxEa58Yl9QDgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 22:59:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B4A0940873; Wed, 16 Sep 2020 22:59:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726558AbgIPU5B convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 16:57:01 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:54936 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726547AbgIPQwh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 12:52:37 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id A8E8ECED06; Wed, 16 Sep 2020 16:38:02 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v1 2/2] Bluetooth: btintel: Functions to send firmware header / payload From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <1600089906-9852-2-git-send-email-kiran.k@intel.com> Date: Wed, 16 Sep 2020 16:31:05 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Chethan T N <chethan.tumkur.narayan@intel.com>, "Srivatsa, Ravishankar" <ravishankar.srivatsa@intel.com>, Kiran K <kiran.k@intel.com>, Amit K Bag <amit.k.bag@intel.com>, Raghuram Hegde <raghuram.hegde@intel.com> Content-Transfer-Encoding: 8BIT Message-Id: <B90409E2-DC93-4084-8D7F-AF285634CC93@holtmann.org> References: <1600089906-9852-1-git-send-email-kiran.k@intel.com> <1600089906-9852-2-git-send-email-kiran.k@intel.com> To: Kiran K <kiraank@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.14 / 15.00 / 15.00 X-Rspamd-Queue-Id: B4A0940873 X-Rspamd-UID: 09cda1 Hi Kiran, > New generation controllers supports ECDSA secure boot engine. > This patch adds, > > 1) function to send ECDSA header > > 2) function to download complete firmware for new generation Intel > controllers > > Signed-off-by: Kiran K <kiran.k@intel.com> > Signed-off-by: Amit K Bag <amit.k.bag@intel.com> > Signed-off-by: Raghuram Hegde <raghuram.hegde@intel.com> > Reviewed-by: Chethan T N <chethan.tumkur.narayan@intel.com> > Reviewed-by: Srivatsa Ravishankar <ravishankar.srivatsa@intel.com> > --- > drivers/bluetooth/btintel.c | 119 +++++++++++++++++++++++++++++++++++++++++++- > drivers/bluetooth/btintel.h | 12 +++++ > 2 files changed, 129 insertions(+), 2 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qNEbKb58Yl+2VgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 16 Sep 2020 22:59:42 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8M5wJb58Yl9JAgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 16 Sep 2020 22:59:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1269A40966; Wed, 16 Sep 2020 22:59:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726250AbgIPU5t convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 16:57:49 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:58377 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbgIPQwW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 12:52:22 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id 5C907CED05; Wed, 16 Sep 2020 16:38:00 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v1 1/2] Bluetooth: btintel: Add infrastructure to read controller information From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <1600089906-9852-1-git-send-email-kiran.k@intel.com> Date: Wed, 16 Sep 2020 16:31:03 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com, Kiran K <kiran.k@intel.com>, Amit K Bag <amit.k.bag@intel.com>, Raghuram Hegde <raghuram.hegde@intel.com> Content-Transfer-Encoding: 8BIT Message-Id: <52CFB547-C5C4-4116-B163-4DBA50E6BB7E@holtmann.org> References: <1600089906-9852-1-git-send-email-kiran.k@intel.com> To: Kiran K <kiraank@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.75 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1269A40966 X-Rspamd-UID: cb28a5 Hi Kiran, > New generation Intel controllers returns version information in TLV > format. This patch adds, > > 1) Enums, structures for TLV > > 2) function to read controller information, parse TLV data and populate > intel_version_tlv structure > > 3) function to print version information > > Signed-off-by: Kiran K <kiran.k@intel.com> > Signed-off-by: Amit K Bag <amit.k.bag@intel.com> > Signed-off-by: Raghuram Hegde <raghuram.hegde@intel.com> > Reviewed-by: Chethan T N <chethan.tumkur.narayan@intel.com> > Reviewed-by: Srivatsa Ravishankar <ravishankar.srivatsa@intel.com> > --- > drivers/bluetooth/btintel.c | 138 ++++++++++++++++++++++++++++++++++++++++++++ > drivers/bluetooth/btintel.h | 79 +++++++++++++++++++++++++ > 2 files changed, 217 insertions(+) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eA3lDXaRYl/kVQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 00:28:06 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gAsFC3aRYl+UdQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 00:28:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3727A40873; Thu, 17 Sep 2020 00:28:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726413AbgIPW15 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 18:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726187AbgIPW14 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 18:27:56 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E91E5C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 14:11:37 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id k13so3870514plk.3 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 14:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uaBOivbSeuNB6paHYocO1okQ12WIK70+yzK78KNdDVk=; b=mMwc52S1gF9Yp50WUYa63bnvfbMRQQmkQsRz9DpZDAom++Uc3fmAZ4KpoDWI419dtp L9r67gtRmMHtnA+gGvCRHteUWw+s204rbn8ZdKhM0hBHunLcLxwqsJ/HncXZdMux9iSV xudFWYJG3mDLZEQovHQ57GHPXW7vT7Iio/6i0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uaBOivbSeuNB6paHYocO1okQ12WIK70+yzK78KNdDVk=; b=s9X540kavN+7Zo8zzBhmyZBC4HImFTVgt9W4jVeOsEVzxIrXKFCePQP8yCjrDz62wn IiVL2ZX8r6pIGHWwIHdFUfjTY9AaIqepO+Wxqg2+O6CKRqWRkFQYdhH1mcQTERVkeL69 K4lBLSJXllwq/lsNEWXTs0HVQjflcnCUSfKBKQX+F5FPzLoojxKUwQYPfO80vKDQOJUC pZ3tbDGN/azx18GzJ2iQ5ILZg1IQahbeD6mBj5wnkee2wYTpRE16bNikLJZbHdPthD3r PaHnnkTaybfjPm80pn21t5mDr06DJLgG8o8d7hWCpdLCuckamo95TV+EU7Vl9gNjlzrN VGJQ== X-Gm-Message-State: AOAM530fkX8Lvj5VQzKhoN97v4VwvWUUdVIkGNDGMA3NNl9JopBTLUv2 345OyabnBSqzw7ox2fPibyj2ObjqbC6m8w== X-Google-Smtp-Source: ABdhPJyKqZIjgfoxjrzcffrY1M32S7CXdyzxkCr1QBgkfVlg93okeUjgDo2Wo6CXfEr099oFixFqVw== X-Received: by 2002:a17:902:cf8f:b029:d0:90a3:24e9 with SMTP id l15-20020a170902cf8fb02900d090a324e9mr24665669ply.8.1600290696525; Wed, 16 Sep 2020 14:11:36 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id 64sm18483010pfz.204.2020.09.16.14.11.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 14:11:35 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org> Subject: [PATCH BlueZ] a2dp: Keep track of ref ownership of a2dp_setup Date: Wed, 16 Sep 2020 14:11:22 -0700 Message-Id: <20200916211122.127881-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.50 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3727A40873 X-Rspamd-UID: 365c2f Currently transport_cb and abort_cfm make assumption that they have an a2dp_setup reference held as a result of open_ind invocation. In the field this is not always true, for example when the peer device opens an L2CAP channel for AVDTP transport channel without sending AVDTP_OPEN request through the AVDTP signaling channel first. Although in this case the peer device does not behave correctly, we should protect this possible crash from happening by making sure that transport_cb and abort_cfm are really holding a reference of a2dp_setup object before trying to unref them. After grabbing a reference, open_ind stores the pointer in stream->pending_open_data. If this field is set, that means there is a pending AVDTP_OPEN command and it needs to be unref-fed later once and only once: when the transport channel is created (transport_cb) or when the AVDTP_OPEN command is aborted (abort_cfm). If this field is not set, nothing should unref it. This enforces that the reference counting is correct regardless of the behavior of the peer device. A sample crash stack trace from Chrome OS: * thread #1, stop reason = signal SIGSEGV * frame #0: 0x0c64f0e8 bluetoothd`queue_remove_all at queue.c:351 frame #1: 0x0c64f086 bluetoothd`queue_destroy at queue.c:73 frame #2: 0x0c6022b0 bluetoothd`setup_unref at a2dp.c:222 frame #3: 0x0c604942 bluetoothd`transport_cb at a2dp.c:2229 frame #4: 0x0c61e35c bluetoothd`accept_cb at btio.c:203 frame #5: 0xf679523c libglib-2.0.so.0`g_main_context_dispatch at gmain.c:3182 frame #6: 0xf67954aa libglib-2.0.so.0`g_main_context_iterate at gmain.c:3920 frame #7: 0xf679569a libglib-2.0.so.0`g_main_loop_run at gmain.c:4116 frame #8: 0x0c65a5a0 bluetoothd`mainloop_run at mainloop-glib.c:79 frame #9: 0x0c65a7ea bluetoothd`mainloop_run_with_signal at mainloop-notify.c:201 frame #10: 0x0c6477ec bluetoothd`main at main.c:772 frame #11: 0xf65bc0a2 libc.so.6`__libc_start_main at libc-start.c:308 --- profiles/audio/a2dp.c | 24 ++++++++++++++++-------- profiles/audio/avdtp.c | 17 +++++++++++++++++ profiles/audio/avdtp.h | 3 +++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c index 2feea66c0..9e96f8c4b 100644 --- a/profiles/audio/a2dp.c +++ b/profiles/audio/a2dp.c @@ -927,10 +927,16 @@ static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep, else DBG("Source %p: Open_Ind", sep); + if (avdtp_stream_get_pending_open_data(stream)) { + warn("Pending open data already exists"); + return FALSE; + } + setup = a2dp_setup_get(session); if (!setup) return FALSE; + avdtp_stream_set_pending_open_data(stream, setup); setup->stream = stream; if (!err && setup->chan) @@ -1285,14 +1291,13 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, void *user_data) { struct a2dp_sep *a2dp_sep = user_data; - struct a2dp_setup *setup; + struct a2dp_setup *setup = avdtp_stream_get_pending_open_data(stream); if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK) DBG("Sink %p: Abort_Cfm", sep); else DBG("Source %p: Abort_Cfm", sep); - setup = find_setup_by_session(session); if (!setup) return; @@ -1302,6 +1307,7 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, } setup_unref(setup); + avdtp_stream_set_pending_open_data(stream, NULL); } static gboolean reconf_ind(struct avdtp *session, struct avdtp_local_sep *sep, @@ -2216,11 +2222,12 @@ fail: static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) { - struct a2dp_setup *setup = user_data; + struct avdtp_stream *stream = user_data; + struct a2dp_setup *setup = avdtp_stream_get_pending_open_data(stream); uint16_t omtu, imtu; - if (!g_slist_find(setups, setup)) { - warn("bt_io_accept: setup %p no longer valid", setup); + if (!setup) { + warn("transport_cb: pending open data does not exist"); g_io_channel_shutdown(io, TRUE, NULL); return; } @@ -2238,8 +2245,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) goto drop; } - if (!avdtp_stream_set_transport(setup->stream, - g_io_channel_unix_get_fd(io), + if (!avdtp_stream_set_transport(stream, g_io_channel_unix_get_fd(io), imtu, omtu)) goto drop; @@ -2249,6 +2255,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) setup->io = NULL; setup_unref(setup); + avdtp_stream_set_pending_open_data(stream, NULL); return; @@ -2297,7 +2304,8 @@ static void confirm_cb(GIOChannel *io, gpointer data) goto drop; } - if (!bt_io_accept(io, transport_cb, setup, NULL, &err)) { + if (!bt_io_accept(io, transport_cb, setup->stream, NULL, + &err)) { error("bt_io_accept: %s", err->message); g_error_free(err); goto drop; diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 782268c08..74b9f8dfa 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -366,6 +366,8 @@ struct avdtp_stream { GSList *caps; GSList *callbacks; struct avdtp_service_capability *codec; + void *pending_open_data; /* Data when the transport channel + * opening is pending */ guint io_id; /* Transport GSource ID */ guint timer; /* Waiting for other side to close or open * the transport channel */ @@ -727,6 +729,11 @@ static void stream_free(void *data) g_slist_free_full(stream->callbacks, g_free); g_slist_free_full(stream->caps, g_free); + /* pending_open_data must have been unref-ed and unset before freeing + * avdtp_stream. Otherwise, it is a reference leak bug. + */ + assert(!stream->pending_open_data); + g_free(stream); } @@ -3147,6 +3154,16 @@ struct avdtp_remote_sep *avdtp_stream_get_remote_sep( return NULL; } +void avdtp_stream_set_pending_open_data(struct avdtp_stream *stream, void *data) +{ + stream->pending_open_data = data; +} + +void *avdtp_stream_get_pending_open_data(struct avdtp_stream *stream) +{ + return stream->pending_open_data; +} + gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd, size_t imtu, size_t omtu) { diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h index 011fea89e..92ce65ed3 100644 --- a/profiles/audio/avdtp.h +++ b/profiles/audio/avdtp.h @@ -260,6 +260,9 @@ gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream, GSList *caps); struct avdtp_remote_sep *avdtp_stream_get_remote_sep( struct avdtp_stream *stream); +void avdtp_stream_set_pending_open_data(struct avdtp_stream *stream, + void *data); +void *avdtp_stream_get_pending_open_data(struct avdtp_stream *stream); unsigned int avdtp_add_state_cb(struct btd_device *dev, avdtp_session_state_cb cb, void *user_data); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CBFZLiiTYl/kVQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 00:35:20 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id +Ko2KyiTYl9nMAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 00:35:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3FF6940875; Thu, 17 Sep 2020 00:35:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726348AbgIPWfM (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 18:35:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbgIPWfK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 18:35:10 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9BBBC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:35:05 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id w7so4854413pfi.4 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=z4BsBm4/JaybyWDiNEa/bs5RXulRrirwodkdVtO+qdI=; b=XqxtSK1rf9GqTXNLezWlbuk12soFDktvIyV8otXHyvVqzOmtklfCcTA0lcncgqylZx kx9lGP3OtWm9TLVlNKgXTSg7qdkwebNzUKqb2Fu4pnthQTCOY7TBf+qQwrP33xNYuHV/ Sf1q19C+RtZo4LkvBVkixXws22lUEizKi7pjA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=z4BsBm4/JaybyWDiNEa/bs5RXulRrirwodkdVtO+qdI=; b=IGYxOyIHVWZtOP6icu2YLvdUJdogQR0DpbUI/V/kxi6DGjy6Vcdlp5/tutxfpI1F8W WOO+taxR+8H3oJL23z4ggZy5mbrpU0P103fguzTP+WS5o84YNjA/fBuBHMD7TAt6tYv3 JZHxgGYwx/TfckUxPblc4tjxS2mirWqeay4eLiu7XZXopNpLR+deOB4XMYSDhievzS4f SOQbp5DRFx5pblibXV8IapZxjWA4tF++rw25bh19t0viKyMz8nrivcoGg2223GyZ6B0Z dHGtA1H/vZL7MeKvSKPvQ+F+enBv4sgurRpw2vhmQYttequXTV8FNnYoja2DWgz/hJy1 dSUw== X-Gm-Message-State: AOAM532ch1TkBkX7iCBGlTFRY41iDKG1qeJvdu2czy7Df7/0KO+3aHHq OR8fRbneZrE9Uu7c211rARq+xx9wUTtC0Q== X-Google-Smtp-Source: ABdhPJzpNUtm/OPWyWRWcP/DdaN79qAcO2K4cLzAmN0w+AXcEAhfTQCjClZXn0HXumcqq46fdcRhyQ== X-Received: by 2002:a62:1850:0:b029:142:2501:35e8 with SMTP id 77-20020a6218500000b0290142250135e8mr7991711pfy.72.1600295704821; Wed, 16 Sep 2020 15:35:04 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id e27sm17945805pfj.62.2020.09.16.15.35.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 15:35:03 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Miao-chen Chou <mcchou@chromium.org>, Yoni Shavit <yshavit@chromium.org>, Alain Michaud <alainm@chromium.org> Subject: [PATCH BlueZ v2] sixaxis: Fix crash caused by return of udev_device_get_property_value Date: Wed, 16 Sep 2020 15:34:53 -0700 Message-Id: <20200916223453.22537-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.30 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3FF6940875 X-Rspamd-UID: 5376b7 From: Miao-chen Chou <mcchou@chromium.org> This adds a NULL check before calling sscanf(). Reviewed-by: Yoni Shavit <yshavit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- plugins/sixaxis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c index 939fed759..996f85dd6 100644 --- a/plugins/sixaxis.c +++ b/plugins/sixaxis.c @@ -411,7 +411,7 @@ get_pairing_type_for_device(struct udev_device *udevice, uint16_t *bus, hid_id = udev_device_get_property_value(hid_parent, "HID_ID"); - if (sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3) + if (!hid_id || sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3) return NULL; cp = get_pairing(vid, pid); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0MISHviTYl8megAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 00:38:48 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id IIJ5G/iTYl85twAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 00:38:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 58EFEA0218; Thu, 17 Sep 2020 00:38:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726760AbgIPWif (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 18:38:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbgIPWie (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 18:38:34 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26D7CC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:38:34 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id q13so59630ejo.9 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FA/vn/pf1ZmH6gVwWqHYRwnpefavwAOiKTwEHHpEftE=; b=bHdM/kQnKvHwc1ZN+MIc2/ajoKWIMMQtMUTFw2OeqV00Mu0JR46km0ENl9gQ0V5Sc/ aQM8L0+vdwxiDiPeP4G0Cux2XOyj0mWoEVbyYNw09USRS1PGEF2GV+Px3t+VQQ6Bq0hM Ahxu72v7CzmkJJrMDO5Qom6LsvxvVDTdRo3DU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FA/vn/pf1ZmH6gVwWqHYRwnpefavwAOiKTwEHHpEftE=; b=TY3qhlRQ+I2V2bqzROlFoGKM2l7cjH2VWsqiedqJZ6jdIonhrGSiDoyKKe0ICEMely BeNEqTImSgZAOUjpud/yBepEbIs2a/UDvg4XiufdtGoNp+K9fzYidBxXekFnPnuZgaAs AgB+s8KQStQCYuX+cXItaXCasppql+v0vSOVpl7IIfm544k3rcmWjsrqARUrgnXomNyI 2Xlsd60SAnTZPSaLlaZo0J9e2oKG9ZdQ7klfeyAW4mediwTKrWSuMcrPGBY1eFU6DYBw b/8w/Ofseq687qK6Ainez/Mis3cMV3AufmaB9TnmQrbsXxfZLD3Dja9ypbUz3uv3ohFr Mf9w== X-Gm-Message-State: AOAM5305gwUUZI/hLJGtCIZg39nh7ltU0lyLW/pneXl81YQDE81+SZzP Nw36SNGAafdfjqQvdbbV/M/OMKDid2bNGA== X-Google-Smtp-Source: ABdhPJw53kG0ZTuX/E9hYMV/Lsu1cXxmoy/NffJJ8CW81facYzBOFP5uqrEqCKYBhHgbZ5bOLN4G2g== X-Received: by 2002:a17:907:20d0:: with SMTP id qq16mr4677571ejb.65.1600295907974; Wed, 16 Sep 2020 15:38:27 -0700 (PDT) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com. [209.85.221.54]) by smtp.gmail.com with ESMTPSA id j10sm13450743ejf.116.2020.09.16.15.38.27 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Sep 2020 15:38:27 -0700 (PDT) Received: by mail-wr1-f54.google.com with SMTP id g4so8491308wrs.5 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:38:27 -0700 (PDT) X-Received: by 2002:a5d:5307:: with SMTP id e7mr5881775wrv.215.1600295906572; Wed, 16 Sep 2020 15:38:26 -0700 (PDT) MIME-Version: 1.0 References: <20200821061643.16278-1-sonnysasaka@chromium.org> In-Reply-To: <20200821061643.16278-1-sonnysasaka@chromium.org> From: Sonny Sasaka <sonnysasaka@chromium.org> Date: Wed, 16 Sep 2020 15:38:15 -0700 X-Gmail-Original-Message-ID: <CAO271m=UWgjM1nLWzrwfvG4r3V7c6wdPDJk7EvRtW4cgsLXqhg@mail.gmail.com> Message-ID: <CAO271m=UWgjM1nLWzrwfvG4r3V7c6wdPDJk7EvRtW4cgsLXqhg@mail.gmail.com> Subject: Re: [PATCH BlueZ 1/2] gatt: StartNotify is not allowed when device is disconnecting To: BlueZ <linux-bluetooth@vger.kernel.org> Cc: Joseph Hwang <josephsih@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.75 / 15.00 / 15.00 X-Rspamd-Queue-Id: 58EFEA0218 X-Rspamd-UID: 15719a Dear BlueZ maintainers, Friendly ping to review this patch. Thanks! On Thu, Aug 20, 2020 at 11:17 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > From: Joseph Hwang <josephsih@chromium.org> > > This patch fixed a bluetoothd crash in register_notify_cb(). The > crash is incurred by an exception that under some situation, a > characteristic may be freed when register_notify_cb() is invoked. > > When a device is disconnecting, the device interface would hold valid > for a while until the disconnection procedure between the client and > the server is completed. If another process happens to request to start > notification of a characteristic on the disconnecting device, it may > incur a problem. In this case, the client would still send the > StartNotify request since the characteristic object is still valid. > However, the characteristic may be freed soon and become invalid > when the corresponding callback function is invoked later. This > leads to the bluetoothd crash due to the segmentation fault. > > To handle the exception, if another process requests to start > notification when the device is disconnecting, it should reject the > request. > > Tested on Chrome OS that this patch fixes bluetoothd crash in > register_notify_cb(). > > --- > src/gatt-client.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/src/gatt-client.c b/src/gatt-client.c > index 20c3fbec2..c706307c7 100644 > --- a/src/gatt-client.c > +++ b/src/gatt-client.c > @@ -1545,6 +1545,12 @@ static DBusMessage *characteristic_start_notify(DBusConnection *conn, > const char *sender = dbus_message_get_sender(msg); > struct async_dbus_op *op; > struct notify_client *client; > + struct btd_device *device = chrc->service->client->device; > + > + if (device_is_disconnecting(device)) { > + error("Device is disconnecting. StartNotify is not allowed."); > + return btd_error_not_connected(msg); > + } > > if (chrc->notify_io) > return btd_error_not_permitted(msg, "Notify acquired"); > -- > 2.26.2 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YBKHLlmUYl/kVQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 00:40:25 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id GPmzK1mUYl+zvAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 00:40:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C5CC6A0170; Thu, 17 Sep 2020 00:40:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726489AbgIPWkO (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 18:40:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726187AbgIPWkN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 18:40:13 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0096CC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:40:12 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id j2so200042eds.9 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Gv5Ym7Y65u7UpAXs48lxQYYvj7ha6lG/xcFtbTRD8zI=; b=H3r6+T3lprSi9LqwoZJK0zuMM9U8FaF/TNFQbuwOTd5OvetcZ6kPTEIbjnl8Ma7QVn st1OLTsPVcGlIsGPOGpCRbTpY/o5hH2XhNmjlNHwvP0kgs7zcZZV1be8+rerIjAmDXpx sO3M3DuF5/ps6BjVRJDuGOLGrsOGcdyafsM7A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Gv5Ym7Y65u7UpAXs48lxQYYvj7ha6lG/xcFtbTRD8zI=; b=bA1MUP7vbeKLN4vD3iYCBbT1AtRCUVaXR+vpWLOrz/Ms0CBKFHsrDsdKN0ge5T3LV8 IAFQHxHCYVlXqy3j7NUjCGLDQZFRV2e/KcY3RevfUNLErZ1q52SajbZYL6pe27ekge7Z wRu/ZZSFraI5Q36Fq6aJG7TTOf/Kl61rmHvBaTJRGdceEJWCoS+R77tD4d1NIBzV1LoC K4u1fhtq6xyv3r5ioOXKgE37IDJG6c/X9dP/fEXtBE/VKdXNlxH34Vyy9WRWGa2Ejb+A CT07pGHwntcVXdAY+3ZFTwoRf7HehpsESVEIUSAC8jFuJU3LGE8XLYBwy8qSpplzpyuh 3xvQ== X-Gm-Message-State: AOAM530aBUxoVkqQfOqk/UbgQYO/HZeREE7oBHvVJBCORrJ9XG3zxcR9 odS5BKBrzlCySx0wWKMEOrk0Wk/YqxBnQw== X-Google-Smtp-Source: ABdhPJzxK/0kyalzBSHSAUWK8lbvtWwkMQeDWEvdI0Wwt1hLepZFo6a1lXGKcJ/78nYcIm0MirQaPg== X-Received: by 2002:aa7:c054:: with SMTP id k20mr30373740edo.224.1600296011255; Wed, 16 Sep 2020 15:40:11 -0700 (PDT) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com. [209.85.128.47]) by smtp.gmail.com with ESMTPSA id cf7sm15036479edb.78.2020.09.16.15.40.10 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Sep 2020 15:40:10 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id e17so128647wme.0 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:40:10 -0700 (PDT) X-Received: by 2002:a05:600c:2312:: with SMTP id 18mr601790wmo.141.1600296009905; Wed, 16 Sep 2020 15:40:09 -0700 (PDT) MIME-Version: 1.0 References: <20200814190909.361764-1-sonnysasaka@chromium.org> In-Reply-To: <20200814190909.361764-1-sonnysasaka@chromium.org> From: Sonny Sasaka <sonnysasaka@chromium.org> Date: Wed, 16 Sep 2020 15:39:58 -0700 X-Gmail-Original-Message-ID: <CAO271m=+2vqnmWK=M5ySfSYYBsKqAJbjmCDnjj4C_BxD3vQ5gQ@mail.gmail.com> Message-ID: <CAO271m=+2vqnmWK=M5ySfSYYBsKqAJbjmCDnjj4C_BxD3vQ5gQ@mail.gmail.com> Subject: Re: [PATCH v2] Bluetooth: Fix auto-creation of hci_conn at Conn Complete event To: BlueZ <linux-bluetooth@vger.kernel.org> Cc: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: C5CC6A0170 X-Rspamd-UID: 2f3c98 Dear maintainers, Friendly ping to review this patch. Thanks! On Fri, Aug 14, 2020 at 12:09 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > Currently the code auto-creates hci_conn only if the remote address has > been discovered before. This may not be the case. For example, the > remote device may trigger connection after reboot at already-paired > state so there is no inquiry result found, but it is still correct to > create the hci_conn when Connection Complete event is received. > > A better guard is to check against bredr allowlist. Devices in the > allowlist have been given permission to auto-connect. > > Fixes: 4f40afc6c764 ("Bluetooth: Handle BR/EDR devices during suspend") > Signed-off-by: Sonny Sasaka <sonnysasaka@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > --- > net/bluetooth/hci_event.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 33d8458fdd4a..6b83da1790ee 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -2566,7 +2566,6 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) > static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) > { > struct hci_ev_conn_complete *ev = (void *) skb->data; > - struct inquiry_entry *ie; > struct hci_conn *conn; > > BT_DBG("%s", hdev->name); > @@ -2575,13 +2574,19 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) > > conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); > if (!conn) { > - /* Connection may not exist if auto-connected. Check the inquiry > - * cache to see if we've already discovered this bdaddr before. > - * If found and link is an ACL type, create a connection class > + /* Connection may not exist if auto-connected. Check the bredr > + * allowlist to see if this device is allowed to auto connect. > + * If link is an ACL type, create a connection class > * automatically. > + * > + * Auto-connect will only occur if the event filter is > + * programmed with a given address. Right now, event filter is > + * only used during suspend. > */ > - ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); > - if (ie && ev->link_type == ACL_LINK) { > + if (ev->link_type == ACL_LINK && > + hci_bdaddr_list_lookup_with_flags(&hdev->whitelist, > + &ev->bdaddr, > + BDADDR_BREDR)) { > conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, > HCI_ROLE_SLAVE); > if (!conn) { > -- > 2.26.2 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SIfjH56UYl/kVQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 00:41:34 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8PmKHJ6UYl+4YgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 00:41:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 23F5140017; Thu, 17 Sep 2020 00:41:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726611AbgIPWl1 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 18:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726600AbgIPWl0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 18:41:26 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5465DC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:41:23 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id j11so173210ejk.0 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=a+YMNe2j0claVsXWfMbHbK1oBa6IOCR2AWkVXO3KhqY=; b=GuwMFELiy0OMXISrfLEPt1g/oULXEINC02f3YHeKOTZhnNq61xo4z47ZvCRGDVXrET fnk36DRTGAMSsGH5+lfki8do9zfBa9e9gK2XpGspnE2wIiPofjBg8VnJm52GR8At4lHF wHhVVbNgmWclAyusRD0kzv4luH9gUsPu1nYAQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=a+YMNe2j0claVsXWfMbHbK1oBa6IOCR2AWkVXO3KhqY=; b=n/ElACGnBuciXSAMT48t/sIwRNyiGBwUKj8ErnjSWUtv1qXI5Zm6shztS26YSfDe3V 70hWtwZLFJEbxD+N5uBvV7AQQkcuaxdtAryCjwzOctRIV0Hk+DOiMdwg+WWO6SjwoXjv fUWyCtHuFdc/yxNWW740jngx1V3sz5M5lG7C8z7IrtwrTe8YfajosPGZiIRb8804N9K0 Vv7HG9GX3U58zKay9JHY3uV6NWpJHtiP6tzxKKmv7kvTCzQS63/D5ziGf2dINfGFud+g yTP4Tr0gW2R4Y66J2xU4v9T4D7o6FkUuTJeEBz3Z/C8y/W2iMmvS14CToLNaToF5XANT wBvw== X-Gm-Message-State: AOAM531IJ2ft9NuJ2Px6IcGDIlLadjALLmkYx07i9L2HbO2t0MvaDGHd pI9MzbEUF5fVVa6mVSYpHvWfiuaY6iUFHA== X-Google-Smtp-Source: ABdhPJz0Ks2VsQQUsIZV+/p7Cejp1Yzbb2s+QtO35xuub2tATQT+Oj6vLnZBOtRwAG28MgEGEBk+MQ== X-Received: by 2002:a17:906:16c8:: with SMTP id t8mr28759651ejd.272.1600296081742; Wed, 16 Sep 2020 15:41:21 -0700 (PDT) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com. [209.85.128.50]) by smtp.gmail.com with ESMTPSA id s21sm15067346edw.23.2020.09.16.15.41.20 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Sep 2020 15:41:21 -0700 (PDT) Received: by mail-wm1-f50.google.com with SMTP id l9so132623wme.3 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:41:20 -0700 (PDT) X-Received: by 2002:a1c:7f14:: with SMTP id a20mr6996267wmd.95.1600296080441; Wed, 16 Sep 2020 15:41:20 -0700 (PDT) MIME-Version: 1.0 References: <20200813002819.359374-1-sonnysasaka@chromium.org> In-Reply-To: <20200813002819.359374-1-sonnysasaka@chromium.org> From: Sonny Sasaka <sonnysasaka@chromium.org> Date: Wed, 16 Sep 2020 15:41:09 -0700 X-Gmail-Original-Message-ID: <CAO271mneguPsiJRNjW44oGEHZSuYof0og9+cHxByqoOntjevYw@mail.gmail.com> Message-ID: <CAO271mneguPsiJRNjW44oGEHZSuYof0og9+cHxByqoOntjevYw@mail.gmail.com> Subject: Re: [PATCH BlueZ] checkpatch: Ignore SPDX license tag To: BlueZ <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.83 / 15.00 / 15.00 X-Rspamd-Queue-Id: 23F5140017 X-Rspamd-UID: 5f5b74 Dear BlueZ maintainers, I saw recent patches that BlueZ started adding SPDX license tags to file headers. Is this where the convention is going? If so, please ignore this patch. On Wed, Aug 12, 2020 at 5:28 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > BlueZ does not use SPDX license tag on file headers. > > --- > .checkpatch.conf | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/.checkpatch.conf b/.checkpatch.conf > index 419733832..72c3529c3 100644 > --- a/.checkpatch.conf > +++ b/.checkpatch.conf > @@ -12,3 +12,4 @@ > --ignore PREFER_PACKED > --ignore COMMIT_MESSAGE > --ignore SSCANF_TO_KSTRTO > +--ignore SPDX_LICENSE_TAG > -- > 2.26.2 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aKwjE/qWYl8megAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 00:51:38 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id +LdEEPqWYl+8gAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 00:51:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1D76940873; Thu, 17 Sep 2020 00:51:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726285AbgIPWvb (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 18:51:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726187AbgIPWvb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 18:51:31 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0EDCC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:51:29 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id 16so280597qkf.4 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=QdPdHxhh2X030UI9Pl73zrxQxSQW5ssC98IxPG2SNYk=; b=k4z+RlvnnCKiVC2fUWmD5/ReTRGYsDltRmPOgYAi3zFofExp+dYf6f0rkz90sdTww4 x01U9YEL1gz4NH2p8ZRkoS0OCjnBpQZ6xWwKufF+n0X9li5kcT2prha2jh4OtZgG0AfY RzcZrL3P60pHIFc6CgmaXRvmQaXFSZpPGvFkY90o/uBAk2RHYqvVmxAsEZhTOs8r+Pev 7NUFhmQ/pcnCH3erCNlvFd/h8DwqMPBirbZZsd5DnFB9rXJ5ddrkfdfOiieQZnznhUtL hITyYPEFOuK8zihf4mz9PO+XeLQGT5Yqasn+7MI8nWlHVpmMOGvvsGuTpxT3Fo7cKOrc KBEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=QdPdHxhh2X030UI9Pl73zrxQxSQW5ssC98IxPG2SNYk=; b=b3ayQB3R4UzivpyThMmLvZocMyBp8xX7AneFmUTNTwYoxLzUh7xbTqs2QNiVPMWPya sJfnFFQoSyuKWnfT54Obr9Togf4QnBt2Hirp82CqjABCEdAy7fgwDcWmObWoAeQt8+Cx vzplL5xijJwSBYjHggALHTLj9wYiGXjupxGz6O6D/QRhVEAw+R085NfYemb4qt3iIoLL 6xl5/gKUn7/TSCEpb6FQQDyUd0wmRJHbUz2CQfkpLAO0rtMazizYa4OYaQlzffO3XiSD nBDfmnmueLKmV1MCI68fgny1D03VhTfpbQlCOS6MaheEXd5CDalOjh0x9FI/38zg9F3i W/qw== X-Gm-Message-State: AOAM533qfGV8NtFgv5EBCsVqn24MiWzx0NdFf1ex+GUDXMYo+kHnnWR5 uPLgzKOj6vm2EPNkIft9Pz3pAR2pY5dWhw== X-Google-Smtp-Source: ABdhPJybFj8OiCkmpUv1Lq+2tEG7nOIzrWGK+FINfroGDeaBxZpg5x7yhrZ7YgEIQZ7zJreXu11C9g== X-Received: by 2002:a37:a953:: with SMTP id s80mr25068224qke.152.1600296685785; Wed, 16 Sep 2020 15:51:25 -0700 (PDT) Received: from [172.17.0.2] ([20.190.218.1]) by smtp.gmail.com with ESMTPSA id d9sm21087337qtg.51.2020.09.16.15.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 15:51:25 -0700 (PDT) Message-ID: <5f6296ed.1c69fb81.edc3f.f566@mx.google.com> Date: Wed, 16 Sep 2020 15:51:25 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============0362790845663508504==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, sonnysasaka@chromium.org Subject: RE: [BlueZ] a2dp: Keep track of ref ownership of a2dp_setup Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200916211122.127881-1-sonnysasaka@chromium.org> References: <20200916211122.127881-1-sonnysasaka@chromium.org> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.02 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1D76940873 X-Rspamd-UID: c82dee --===============0362790845663508504== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #31: frame #5: 0xf679523c libglib-2.0.so.0`g_main_context_dispatch at gmain.c:3182 WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line #137: FILE: profiles/audio/avdtp.c:370: + * opening is pending */ - total: 0 errors, 2 warnings, 122 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============0362790845663508504==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WKSjIwCXYl/xnAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 00:51:44 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 8DbRIACXYl/EzAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 00:51:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 788914081B; Thu, 17 Sep 2020 00:51:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726420AbgIPWve (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 18:51:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726280AbgIPWvd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 18:51:33 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7887DC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:51:31 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id cr8so32364qvb.10 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 15:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=guefPuweQWMbhZw1fyLePLDNYNLTNtUl2ljOokMfoCY=; b=fARVxxdKtxIyThikSxun0sQisEP//gjWBhQ1EeyZmoVzzvF7Ec0rhwIVQHmnAjpt6P ip1VKj3K+dHefOh+rZoXnM25n6vsE6Q+3ssAXveNau9h6Ug8YGGMIcFOVW+apIuDnN/x +iJWkDq/bVer79IEhzxRqZC59J0g6Ap7WN3CWKl9EAcbsHM9qV/pTbUs2Q0cy6vF5Ed/ 77pwnR+Cl2pBMfMYTUfgtFYrqkG2ZU9gux5o9w/jedx8IBGgsq0IcI9G4CKoV1yu6Oxd 3YTb0kKQtGFg4URMKKt3SaEThL8NTutQEmtxUmE7Wxvtv6q8ZgE2GgT7g3lTZQ9A9sYc s87w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=guefPuweQWMbhZw1fyLePLDNYNLTNtUl2ljOokMfoCY=; b=QTnscURLL23SflnSsxho0QIqrOWRLlH8feJ//vZc0CzYKePzbo1mNUWZFaGz8Le1IO dCAAwZG12/1vJa1aQjtXpd5OMpYuLDuwWEoW/S3+ToqGRS4eciSqiWhoKWZf71iAUoiN fQ90shFV8gNMgCqFxUxOQK7gwBFGymbJC7PH43yJuSVTZ9B3h8lrD/xkVh53iW9RtsLo PFEHFeH8tfEQN2WLqhkmguMUkukojljRcu57Qn1fN5Sbjti1bPYik6mtK+Kc7LYqW4Nk naYIyR3xefcOuWhRpTTBWauDVS8NMVKhzdjo8zLhfzYrZVy6ZNVeDYSFd/LajehzD0ay hSnQ== X-Gm-Message-State: AOAM530s15SyuvsfTvCXY7dnpuabRHCeMhmkVuTaEcW7rP6c5LOBJop3 AYnLzUoFwHVA1MeOozcssblGK/bqxTcBIA== X-Google-Smtp-Source: ABdhPJyeFS4XDk7abjBzVN9XWQB4lLBiRwqFnhQ6aTzm6E0rmM2Zhe98gl9kM42SoF6T0/B2C6+Hpw== X-Received: by 2002:ad4:4891:: with SMTP id bv17mr25446319qvb.20.1600296688805; Wed, 16 Sep 2020 15:51:28 -0700 (PDT) Received: from [172.17.0.2] ([20.190.218.1]) by smtp.gmail.com with ESMTPSA id r5sm19837523qtd.87.2020.09.16.15.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 15:51:28 -0700 (PDT) Message-ID: <5f6296f0.1c69fb81.b0d4e.9db0@mx.google.com> Date: Wed, 16 Sep 2020 15:51:28 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============4868024934633137905==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, sonnysasaka@chromium.org Subject: RE: [BlueZ] a2dp: Keep track of ref ownership of a2dp_setup Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200916211122.127881-1-sonnysasaka@chromium.org> References: <20200916211122.127881-1-sonnysasaka@chromium.org> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.68 / 15.00 / 15.00 X-Rspamd-Queue-Id: 788914081B X-Rspamd-UID: 987b8a --===============4868024934633137905== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 28: B1 Line exceeds max length (81>80): " frame #5: 0xf679523c libglib-2.0.so.0`g_main_context_dispatch at gmain.c:3182" 32: B1 Line exceeds max length (85>80): " frame #9: 0x0c65a7ea bluetoothd`mainloop_run_with_signal at mainloop-notify.c:201" --- Regards, Linux Bluetooth --===============4868024934633137905==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aO+qDDmfYl8pKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:26:49 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oBwwCTmfYl9smgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:26:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3F182A0161; Thu, 17 Sep 2020 01:26:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726869AbgIPX0I (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:26:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgIPX0G (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:26:06 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EEECC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:06 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id k14so181141qvw.20 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=E+m79sGOPfqC1NVoAVBQ73IS8QIMVn3x2pbxmIfIMJk=; b=VW18xMOTg2HToPZhkvfx/Eztw/EyvSeYj/TGQvKYaQeWKdNZ4ggf5GPWpS0K8XGomr jRurrCIiwLQV8sE7q88M+plybJ2YvsWNNN8p9jLwHY9xnSmHhCMGffWYecjDH4F5Ixuf 5LiWuD/YNatkZPOalPRqywjgzNJnX4iXykTYo1GcTjDv99F1F50xWx1nUy+tHuUhriIK TVV+iw77AphPRVhq8D1K1vjxj6Q6JxZhf40ATQOdkPoWiG6kdvR50o1EQqGPaxs5Qbl4 3NpioeE2UhZbEq5MwDyTfmIZvECb6vVOKvkPW/uruZYduZ40zq2Ya+zC1zea9Hu5fV/0 2rSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=E+m79sGOPfqC1NVoAVBQ73IS8QIMVn3x2pbxmIfIMJk=; b=pL2j+3OHfphjSuPIuKHxApFg3rW5aS6EK3GRcAM+nTFx9ZXE0B7fg+s4mR8QA2Eqj4 VkV50opuILAHbkTRXyxwcAJ8EaZeXxPX7H9tIiyA82kn6Qut+2oMFIYfEjAaaaJRUicb +bPm0fhkStG18x68iUYmV4HhVbP5TCLjZP2K4nz2S8NJd5kE4l/dFZBeRAxe8lJ9ogOZ Cc0dcIjTjsTQH6HBuXAKSqfjqZZgnfddE7NIDC6D379afYXArLjvsCqgnnGUJMpkHr/p yRkv3ENgiE6cHJ87r2UOA4uk4H6eIrOMx/eoJ2tqZwxT9ADCYk/moEsLC0NkBzr3q3D/ Bgsg== X-Gm-Message-State: AOAM530iktbXcU5rUbXs0/sYHY6a8yHUfRlwoTbgvFnfIJ7vzPx9JsbS wl0F5amCDW4MS6vOquJaAeMDm3yE/1DqTWBHOJtc X-Google-Smtp-Source: ABdhPJyTltNPH911TT2GP8+ZXBABtzTTh3lKKRDKpPP0t5fn88hR/viqqV3rNxXakZa/jVP0DVmHrEPRAkgwU3kcdUKz X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a0c:f2c1:: with SMTP id c1mr17616086qvm.30.1600298765472; Wed, 16 Sep 2020 16:26:05 -0700 (PDT) Date: Wed, 16 Sep 2020 16:25:39 -0700 In-Reply-To: <20200916232542.1584854-1-danielwinkler@google.com> Message-Id: <20200916162155.Bluez.7.Ic9eec7749b769aa5bf73a0d8e9a31be83f232f1c@changeid> Mime-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH 07/10] client: Add SupportedCapabilities to bluetoothctl From: Daniel Winkler <danielwinkler@google.com> To: luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.37 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3F182A0161 X-Rspamd-UID: 3ec518 This patch adds the new "SupportedCapabilities" property to the bluetoothctl "show" view. The change is tested by verifying bluetoothctl shows the desired properties. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- client/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/main.c b/client/main.c index 2b0243308..cb8ef54ad 100644 --- a/client/main.c +++ b/client/main.c @@ -954,6 +954,7 @@ static void cmd_show(int argc, char *argv[]) print_property(adapter->ad_proxy, "SupportedInstances"); print_property(adapter->ad_proxy, "SupportedIncludes"); print_property(adapter->ad_proxy, "SupportedSecondaryChannels"); + print_property(adapter->ad_proxy, "SupportedCapabilities"); } if (adapter->adv_monitor_proxy) { -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OLD6Ej+fYl8pKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:26:55 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id MN3iDz+fYl+4YgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:26:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4ABD3A0161; Thu, 17 Sep 2020 01:26:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726900AbgIPX0J (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:26:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgIPX0I (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:26:08 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12E5EC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:08 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id z27so134888qtu.3 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=ga5rzsLM7wD43uaJwfTEAl0x1p4eifUEMxC6y8O/SMU=; b=q/Ervwp0jNtca48zrcoaWpfd4F8xuao5CHjO9/BmRPsXA0+6G7QSNuSjiPmUJtiCYc QzUpDmjk39UegKyJRMMbB2WwKMIm/alV9xerVwHInRR7t6vOJGOu+SLAOve9saZvWg1W j1vr3Nrw9QGLZ2CqX/nhsllo0NayCiLdWexjcWYMUcWHZf9+jwT4uNlneKsdY/5ka+0s 4tc2bBhLcqvBGTiBweL5sJGiUGYgWT0dH8tKc4mH//E07n9hyUI+XGP+RzGEYnlOxgtS BMi0+z4u8z2cjiNbSOk5EWvbxNITUecEd5AjC86kDYs8RxbLeA/1mKzbkyNLty4NPBq3 HIIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ga5rzsLM7wD43uaJwfTEAl0x1p4eifUEMxC6y8O/SMU=; b=JaNLI1eFTcenoj51gjrElXVC4JHs5eAChhRcC7FGnDzHogKrsLVF5U5oDPDEb/zAyV hYHk6W7VBMU1RDxAPelDgGCVyvzzyUNiogncJQ9SYzHDkkE3vfoBPqio3YqWakFTD8cN GOnkxqacNZ3A58XZiASjhh7vcZsWEbCA/3nDWVhafdX1azvBAW61PvMRkT/KjPVyEi0W n0qaCoG9AQQ1h7atLDA2iutILwdHxJr2yppKrz66L4O/oVvNY0QYqlmBL/QVpRMe6bEI no+2Z/QMIutqJjADcI8Xi9ej6G/ObwtH85cshA7C9L9zfty/UBcO/NgMer+3nBzIkfvN 3Tiw== X-Gm-Message-State: AOAM531iCpbXhcWOciawWWzYtpTE69AP7LJ8tCb6DJlH4z5+2AA5gEeT wlcYTaXvYAOp0prvJ4aUCAMB3Taj2vM4qeXn/UJg X-Google-Smtp-Source: ABdhPJwir1zZSyhC49bW+kWtVgrCuYOXxBihYJryBKw87eEoSYasYpHnLN0NgKSf9+jN3jcv/5zS0rLBTErc4cPpHUax X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a0c:f30f:: with SMTP id j15mr9497774qvl.51.1600298767278; Wed, 16 Sep 2020 16:26:07 -0700 (PDT) Date: Wed, 16 Sep 2020 16:25:40 -0700 In-Reply-To: <20200916232542.1584854-1-danielwinkler@google.com> Message-Id: <20200916162155.Bluez.8.I2884e6456c272dadb3d70a629674027f23b0393e@changeid> Mime-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH 08/10] monitor: Add new MGMT adv commands and events to monitor From: Daniel Winkler <danielwinkler@google.com> To: luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.40 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4ABD3A0161 X-Rspamd-UID: 50d0db This change adds the following to packet monitor: -Add Ext Adv Params command and response -Add Ext Adv Data command and response -Add Advertising Power Selected event This patch was manually tested by registering advertisements with various features and verifying in btmon log. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- monitor/packet.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index bef134095..5d1e6868e 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -11872,6 +11872,26 @@ static void mgmt_print_adv_flags(uint32_t flags) " (0x%8.8x)", mask); } +static const struct bitfield_data mgmt_adv_params_table[] = { + { 0, "Use Duration parameter" }, + { 1, "Use Timeout parameter" }, + { 2, "Use Interval parameters" }, + { 3, "Use TX Power parameter" }, + { } +}; + +static void mgmt_print_adv_params(uint16_t flags) +{ + uint32_t mask; + + print_field("Enabled parameters: 0x%4.4x", flags); + + mask = print_bitfield(2, flags, mgmt_adv_params_table); + if (mask) + print_text(COLOR_UNKNOWN_ADV_FLAG, " Unknown advertising param" + " (0x%8.8x)", mask); +} + static void mgmt_print_store_hint(uint8_t hint) { const char *str; @@ -13163,6 +13183,53 @@ static void mgmt_set_device_flags_rsp(const void *data, uint16_t size) mgmt_print_address(data, type); } +static void mgmt_add_ext_adv_params_cmd(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + uint32_t flags = get_le32(data + 1); + uint16_t params = get_le16(data + 5); + uint16_t duration = get_le16(data + 7); + uint16_t timeout = get_le16(data + 9); + uint32_t min_interval = get_le32(data + 11); + uint32_t max_interval = get_le32(data + 15); + int8_t tx_power = get_s8(data + 19); + + print_field("Instance: %u", instance); + mgmt_print_adv_flags(flags); + mgmt_print_adv_params(params); + print_field("Duration: %u", duration); + print_field("Timeout: %u", timeout); + print_ext_slot_625("Min advertising interval", &min_interval); + print_ext_slot_625("Max advertising interval", &max_interval); + print_power_level(tx_power, NULL); +} + +static void mgmt_add_ext_adv_params_rsp(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + + print_field("Instance: %u", instance); +} + +static void mgmt_add_ext_adv_data_cmd(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + uint8_t adv_data_len = get_u8(data + 1); + uint8_t scan_rsp_len = get_u8(data + 2); + + print_field("Instance: %u", instance); + print_field("Advertising data length: %u", adv_data_len); + print_eir(data + 3, adv_data_len, false); + print_field("Scan response length: %u", scan_rsp_len); + print_eir(data + 3 + adv_data_len, scan_rsp_len, false); +} + +static void mgmt_add_ext_adv_data_rsp(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + + print_field("Instance: %u", instance); +} struct mgmt_data { uint16_t opcode; @@ -13395,6 +13462,12 @@ static const struct mgmt_data mgmt_command_table[] = { { 0x0050, "Set Device Flags", mgmt_set_device_flags_cmd, 11, true, mgmt_set_device_flags_rsp, 7, true}, + { 0x0054, "Add Ext Adv Params", + mgmt_add_ext_adv_params_cmd, 20, false, + mgmt_add_ext_adv_params_rsp, 1, true }, + { 0x0055, "Add Ext Adv Data", + mgmt_add_ext_adv_data_cmd, 3, false, + mgmt_add_ext_adv_data_rsp, 1, true }, { } }; @@ -13847,6 +13920,15 @@ static void mgmt_controller_resume_evt(const void *data, uint16_t size) mgmt_print_address(data, addr_type); } +static void mgmt_adv_power_selected_evt(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + int8_t tx_power = get_s8(data + 1); + + print_field("Instance: %u", instance); + print_power_level(tx_power, NULL); +} + static const struct mgmt_data mgmt_event_table[] = { { 0x0001, "Command Complete", mgmt_command_complete_evt, 3, false }, @@ -13932,6 +14014,8 @@ static const struct mgmt_data mgmt_event_table[] = { mgmt_controller_suspend_evt, 1, true }, { 0x002e, "Controller Resumed", mgmt_controller_resume_evt, 8, true }, + { 0x002f, "Advertising Power Selected", + mgmt_adv_power_selected_evt, 2, true }, { } }; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CHsqJUmaYl/xnAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:05:45 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sPjkIUmaYl+4YgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:05:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8EDD3A0B10; Thu, 17 Sep 2020 01:05:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726622AbgIPXFj (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:05:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbgIPXFi (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:05:38 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AA06C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:05:38 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id u126so187256oif.13 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dZzF8IF7OE/onHztdIfetKyvDD+3RLdrnkG6RLH0aeI=; b=lL6McyBzkj8lZOCug8DaVsj9tG4rjzviriNTARZSKRfMDefDwxk1jViOYR6vLgBDEi pWEKpSGMYffwiA5Xo9m5IhAVU9QaLq7jLOEyOwrE3l99RSLn4NfXPz2ZI4aacuWRUcQm Y9YpsIbXUWSqlM78aT30sk3VEylIeI3uy0uscbXZHQvcSRtL3BfuoNlQULC3rs7brRHR FKG42akPRYk/seopppWgncCdEp7MXrvpNSbsmpsfuftmdynm5gsZLvjvcvrxuoAxJPCA pW6X52v6USiNYxAKUgdJ6+l1khOe+WSY1eTkTHsUL1Ypk3mTXSur5sRiNcfB9pt8161J zKpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dZzF8IF7OE/onHztdIfetKyvDD+3RLdrnkG6RLH0aeI=; b=EVw8S5OaGM6juIPQq0XWT7TkrNh0AIkSFrwvxG+MXkZSYSBwosJUTfFQu4kk9Mbnt8 Yl31qUjy7U9IWCdyBVgsZbYha9/ZnBIkz76n3Pf4Dv+fCLTeEthTHFGOtQJ5kcKildDk j4gK+XOJbY+EUyAWpVO/F+nDFPZeINnFVM3FWRmChGJXIeNQCP+/ucT+4tSPfxBGV1gD 33i0TUZ5/6+014XBmqr9l9Lkw7URnOh2EKYG3uDrr7nKs1rK9oIef9yDD14GreHYcQoI D8Mr01OxSwsNOpBD1Il/q64hOO7vi2mL5sW6YFaNDcqlZ/QbAojYKJfTB0JKoVji6dc1 QRQg== X-Gm-Message-State: AOAM532XrNc+VDqUSoemYuFeRd8QLxcl/H22zt7zF1h1PhdnXSRCajpq GZWFzExHHtbP0sCu0BN7nWjGv0AKn6N7vEx11/8wfAgx X-Google-Smtp-Source: ABdhPJx6+FfNZAnGsEEsMI5WPomeDp2X+jxTv2dO92UqmSpxmMeadicr0YTQwo9AhgmmzkK/TPh00d6sEH4RAhShYxY= X-Received: by 2002:aca:3e08:: with SMTP id l8mr4280336oia.152.1600297537287; Wed, 16 Sep 2020 16:05:37 -0700 (PDT) MIME-Version: 1.0 References: <20200813002819.359374-1-sonnysasaka@chromium.org> <CAO271mneguPsiJRNjW44oGEHZSuYof0og9+cHxByqoOntjevYw@mail.gmail.com> In-Reply-To: <CAO271mneguPsiJRNjW44oGEHZSuYof0og9+cHxByqoOntjevYw@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 16 Sep 2020 16:05:13 -0700 Message-ID: <CABBYNZL1jaVfvxAZ0GVEa2A0i_8bw_=ynYPL7z20H0ZkDVF3xA@mail.gmail.com> Subject: Re: [PATCH BlueZ] checkpatch: Ignore SPDX license tag To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: BlueZ <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.78 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8EDD3A0B10 X-Rspamd-UID: fd4937 Hi Sonny, On Wed, Sep 16, 2020 at 3:43 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > Dear BlueZ maintainers, > > I saw recent patches that BlueZ started adding SPDX license tags to > file headers. Is this where the convention is going? If so, please > ignore this patch. Yes, it is better that way so we don't have to keep up with the license on every file and will probably attempt do some automation to check if SDPX Identifier is proper. > On Wed, Aug 12, 2020 at 5:28 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > > > BlueZ does not use SPDX license tag on file headers. > > > > --- > > .checkpatch.conf | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/.checkpatch.conf b/.checkpatch.conf > > index 419733832..72c3529c3 100644 > > --- a/.checkpatch.conf > > +++ b/.checkpatch.conf > > @@ -12,3 +12,4 @@ > > --ignore PREFER_PACKED > > --ignore COMMIT_MESSAGE > > --ignore SSCANF_TO_KSTRTO > > +--ignore SPDX_LICENSE_TAG > > -- > > 2.26.2 > > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UNzaFkWfYl8pKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:27:01 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id KF/7E0WfYl/EzAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:27:01 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 66F42A0161; Thu, 17 Sep 2020 01:26:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726912AbgIPX0L (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:26:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgIPX0K (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:26:10 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C7CC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:10 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id y6so389473ybi.11 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=UdDPzO9OECkeo70fdtQdo6JOo5V7BHm0lOgDeLw00GE=; b=pN44wtddLVSWcWAfpjNRZ/C2EljFnOW8pU69igLU/NLa9aym0SV+Rem6pzEKPje3OJ xpdwI7soeGun/PR4AhLKidwOG2zqZZqwfPxAxbsv4xv86yQ2ahmv/Be9XwXwogaBkFf+ D3CyBPvvtYodl+wCVTbemhsMqqhOZJSYtbAf5RnAkCPi4rGHFyMvefSy5ZGhVkOgHj1A C/yGQ04AduvUdXPFEexAinn0wZX6XfK8SD3Es6x7X7DmJwsL2kSIfyN0GflWBkBzdN7I X5to0ES4z2N/NIQoJtNxT80OQ7K8cPc4kMDJISnXtQmj5ydXFbS54WMO/X+7TqgFhFV+ Es2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=UdDPzO9OECkeo70fdtQdo6JOo5V7BHm0lOgDeLw00GE=; b=GQlN2pDRiBrzSCZDcuRjGS+r0OGyqOK90MQajJVPRDBfjTjdo6mWyauvxWqmMNb+R0 XuwvITPpYudRNPraOgicOwBYavgnn3qLRYvEIVKifSdADFPIdcf6exm5VIleVcCTaoQn MLIwCmzTcV2inf8RDpo8rEm19IGhHObk10uOYlb77IoRvRvnSdEvfK/xUPEgnlzbkH9z uz7i1t3eQkkTYQpSpYIF15wtSaDNAa5PrdBcRdbgTyHms9KJU6eI/MNiOeabr3M+kN8T aYBD5JElCJ2os7FbCIHXrXtYa9/+8GKyOkq//W8YA5p2AiuT/ORvj4WyQbl5W2F3i6fu QyUA== X-Gm-Message-State: AOAM530TMItIwYQZtG7XdkwzRlmVSWcWPIf8SWh0mZ0xiRqyesXXUUuM tbJ0i47RYJTEBmwE+3xoUZo8f2xNdOd9MCXvqQSz X-Google-Smtp-Source: ABdhPJwVp1Y4v4huZ5Sz8BrFVkxmSlUInExt6o5RL0MqZ/4kJRxO+Azk05BT459om59z5PThbW7tjyEnvU77BuMW1lcq X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:a305:: with SMTP id d5mr11744783ybi.180.1600298769343; Wed, 16 Sep 2020 16:26:09 -0700 (PDT) Date: Wed, 16 Sep 2020 16:25:41 -0700 In-Reply-To: <20200916232542.1584854-1-danielwinkler@google.com> Message-Id: <20200916162155.Bluez.9.Ifaa96e71a871158e5d9d454073b2b6846eae339f@changeid> Mime-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH 09/10] doc/advertising-api: update API with new interface From: Daniel Winkler <danielwinkler@google.com> To: luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 4.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: 66F42A0161 X-Rspamd-UID: 506df1 This updates the advertising documentation to include the following features: LE Advertising Manager: - New SupportedCapabilities property LE Advertisement: - New min/max interval properties - New tx power property Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- doc/advertising-api.txt | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt index b0565eab2..3215a52f7 100644 --- a/doc/advertising-api.txt +++ b/doc/advertising-api.txt @@ -138,6 +138,33 @@ Properties string Type "2M" "Coded" + uint32 MinInterval + + Minimum advertising interval to be used by the + advertising set, in .625 millisecond slots. + Time = N * .625 ms, where N has range + [0x000020, 0xFFFFFF]. If the provided MinInterval is + larger than the provided MaxInterval, the registration + will return failure. + + uint32 MaxInterval + + Maximum advertising interval to be used by the + advertising set, in .625 millisecond slots. + Time = N * .625 ms, where N has range + [0x000020, 0xFFFFFF]. If the provided MinInterval is + larger than the provided MaxInterval, the registration + will return failure. + + int16 TxPower + + Requested transmission power of this advertising set. + The provided value is used only if the "CanSetTxPower" + feature is enabled on the Advertising Manager. The + provided value must be in range [-127 to +20], where + units are in dBm. + + LE Advertising Manager hierarchy ================================ @@ -209,3 +236,26 @@ Properties byte ActiveInstances Possible values: "1M" "2M" "Coded" + + dict SupportedCapabilities + + Enumerates Advertising-related controller capabilities + useful to the client. + + Possible Values: + + byte MaxAdvLen + + Max advertising data length + + byte MaxScnRspLen + + Max advertising scan response length + + int16 MinTxPower + + Min advertising tx power (dBm) + + int16 MaxTxPower + + Max advertising tx power (dBm) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eN2vLEufYl8oKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:27:07 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6H1DKUufYl+UdQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:27:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7F8B9A0B12; Thu, 17 Sep 2020 01:27:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726939AbgIPX0N (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:26:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgIPX0M (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:26:12 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AB20C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:12 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id q2so407089ybo.5 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=69uV63sz9ZbKOkQ0qL0A6yR+4VihlUhYQyT6cjQqu5s=; b=INgXm6qmENLTljZ/eb/4QMJH3j5sljg/m2+ENI0fseJ+aOcC1NYbq7LnYyKTz3X/VQ hAH1eKlHmNu4A95rVVAKY/6ZiQnnmp6MyaQmop6veAxPUq4Atgsp1vXCYiLl5K9sKtMI IzHeE/vZt3Ea42wLT9EWowbCdu3TCEXyz75zmbzWgHxK8Jm5BO1t22A5ShPhWy9Wk7cp tt0aE0MuIBvRGS3S7ACUB4KEdaX+9qzZRxn/GSKqs8hj6HPhI4BwunRyTHtkwr5fc84s sq7klySqkIorlnxQ+IRCZLnpf0PuwxR3eeCA70ZEZ+GU46seX9D3KXF+YeFHu0TKzBQy AZWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=69uV63sz9ZbKOkQ0qL0A6yR+4VihlUhYQyT6cjQqu5s=; b=Q1B5xibDRG1tG33NcAM8LJlZz71zzBiZYZPo506j4idTDhbpwgYpmf8tLxcM3TO+OJ Ros5ym2FlS2erqyOvMYi7n8+Q5qdZFe6bukpE8Cke6ZdpO4Oi1fuGPqSmkUsQZCsnAbm SvJl3AigoEQk9UkED4id4harjxdC6YZt1nrTj9kKtKRiZL/u/Xu4zCZ78DeNuOAMNRww BPzbA/zxgM1ll4f/ulpOJ0nDkBpwzfgPAqkVv2Rr0E0n0YdHDy7JFKEmdkCrw0wrOo0s xpM7JnDLfVNa0oXIDq4kJOOb/DRC9ELO2KbQWKqD+e8UBHOp86gltUHaXkI3Pk8we2+N HorA== X-Gm-Message-State: AOAM530HbCaGmPMpB73Hc+EYKkPmxPw7oSTXMxAQ/0tUvi8PEs9j753A CgcDhzxn+mUNe3ITf3OIPKWCzBErL5dqjEj7Lu0p X-Google-Smtp-Source: ABdhPJz9oYOKtc754+4qBs/EXI5mjKSt7oGa0zLQAFtdOfuIpLWan3aTC1BoNVSDU75iqFFf1zIoDlRFadJgWXwOQDye X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a05:6902:6d4:: with SMTP id m20mr8276299ybt.118.1600298771472; Wed, 16 Sep 2020 16:26:11 -0700 (PDT) Date: Wed, 16 Sep 2020 16:25:42 -0700 In-Reply-To: <20200916232542.1584854-1-danielwinkler@google.com> Message-Id: <20200916162155.Bluez.10.If15d3d09724ded2bcc7240d29f6888f2ad12e723@changeid> Mime-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH 10/10] doc/mgmt-api: Add new MGMT interfaces to mgmt-api From: Daniel Winkler <danielwinkler@google.com> To: luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7F8B9A0B12 X-Rspamd-UID: 14f946 This patch adds the following to mgmt-api: - Add Extended Advertising Parameters Command - Add Extended Advertising Data Command - Read Controller Capabilities Command - Advertisement Tx Power Selected Event Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- doc/mgmt-api.txt | 243 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index ca0d38469..6e8914611 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -3574,6 +3574,235 @@ Remove Advertisement Monitor Command Busy +Add Extended Advertising Parameters Command +======================= + + Command Code: 0x0054 + Controller Index: <controller id> + Command Parameters: Instance (1 Octet) + Flags (4 Octets) + Params (2 Octets) + Duration (2 Octets) + Timeout (2 Octets) + MinInterval (4 Octets) + MaxInterval (4 Octets) + TxPower (1 Octet) + Return Parameters: Instance (1 Octet) + + + This command is used to configure the parameters for Bluetooth Low + Energy advertising instance. This command is expected to be followed + by an Add Extended Advertising Data command to complete and enable + the advertising instance. + + Added advertising information with this command will not be visible + immediately if advertising is enabled via the Set Advertising + command. The usage of the Set Advertising command takes precedence + over this command. Instance information is stored and will be + advertised once advertising via Set Advertising has been disabled. + + The Instance identifier is a value between 1 and the number of + supported instances. The value 0 is reserved. + + With the Flags value the type of advertising is controlled and + the following flags are defined: + + 0 Switch into Connectable mode + 1 Advertise as Discoverable + 2 Advertise as Limited Discoverable + 3 Add Flags field to Adv_Data + 4 Add TX Power field to Adv_Data + 5 Add Appearance field to Scan_Rsp + 6 Add Local Name in Scan_Rsp + 7 Secondary Channel with LE 1M + 8 Secondary Channel with LE 2M + 9 Secondary Channel with LE Coded + + When the connectable flag is set, then the controller will use + undirected connectable advertising. The value of the connectable + setting can be overwritten this way. This is useful to switch a + controller into connectable mode only for LE operation. This is + similar to the mode 0x02 from the Set Advertising command. + + When the connectable flag is not set, then the controller will + use advertising based on the connectable setting. When using + non-connectable or scannable advertising, the controller will + be programmed with a non-resolvable random address. When the + system is connectable, then the identity address or resolvable + private address will be used. + + Using the connectable flag is useful for peripheral mode support + where BR/EDR (and/or LE) is controlled by Add Device. This allows + making the peripheral connectable without having to interfere + with the global connectable setting. + + Secondary channel flags can be used to advertise in secondary + channel with the corresponding PHYs. These flag bits are mutually + exclusive and setting multiple will result in Invalid Parameter + error. Choosing either LE 1M or LE 2M will result in using + extended advertising on the primary channel with LE 1M and the + respectively LE 1M or LE 2M on the secondary channel. Choosing + LE Coded will result in using extended advertising on the primary + and secondary channels with LE Coded. Choosing none of these flags + will result in legacy advertising. + + To allow future parameters to be optionally extended in this structure, + the Params member is used to specify which of the structure fields were + purposefully set by the caller. Unspecified parameters will be given + sensible defaults by the kernel before the advertisement is registered. + The Params bit field uses the following bit to parameter relationship: + + 0 The Duration parameter should be used + 1 The Timeout parameter should be used + 2 The Interval parameters should be used + 3 The Tx Power parameter should be used + + The Duration parameter configures the length of an Instance. The + value is in seconds. The default is 2 seconds. + + If only one advertising Instance has been added, then the Duration + value will be ignored. It only applies for the case where multiple + Instances are configured. In that case every Instance will be + available for the Duration time and after that it switches to + the next one. This is a simple round-robin based approach. + + The Timeout parameter configures the life-time of an Instance. In + case the value 0 is used it indicates no expiration time. If a + timeout value is provided, then the advertising Instance will be + automatically removed when the timeout passes. The value for the + timeout is in seconds. Powering down a controller will invalidate + all advertising Instances and it is not possible to add a new + Instance with a timeout when the controller is powered down. + + When a Timeout is provided, then the Duration subtracts from + the actual Timeout value of that Instance. For example an Instance + with Timeout of 5 and Duration of 2 will be scheduled exactly 3 + times, twice with 2 seconds and once with one second. Other + Instances have no influence on the Timeout. + + MinInterval and MaxInterval define the minimum and maximum advertising + intervals, with units as number of .625ms advertising slots. The Max + interval is expected to be greater than or equal to the Min interval, + and both must have values in the range [0x000020, 0xFFFFFF]. If either + condition is not met, the registration will fail. + + The provided Tx Power parameter will only be used if the controller + supports it, which can be determined by the presence of the + CanSetTxPower member of the Read Advertising Features command. + + The acceptable range for requested Tx Power is defined in the spec + (Version 5.2 | Vol 4, Part E, page 2585) to be [-127, +20] dBm, and the + controller will select a power value up to the requested one. The + transmission power selected by the controller is not guaranteed + to match the requested one, but the caller can determine the power + chosen by the controller by listening for the Tx Power Selected MGMT + event that follows this command. If the requested Tx Power is outside + the valid range, the registration will fail. + + Re-adding an already existing instance (i.e. issuing the Add Extended + Advertising Parameters command with an Instance identifier of an + existing instance) will update that instance's configuration. + + An instance being added or changed while another instance is + being advertised will not be visible immediately but only when + the new/changed instance is being scheduled by the round robin + advertising algorithm. + + Changes to an instance that is currently being advertised will + cancel that instance and switch to the next instance. The changes + will be visible the next time the instance is scheduled for + advertising. In case a single instance is active, this means + that changes will be visible right away. + + LE must already be enabled, and the controller must be powered, + otherwise a "rejected" status will be returned. + + This command generates a Command Complete event on success or a + Command Status event on failure. + + Possible errors: Failed + Rejected + Not Supported + Invalid Parameters + Busy + + +Add Extended Advertising Data Command +======================= + + Command Code: 0x0055 + Controller Index: <controller id> + Command Parameters: Instance (1 Octet) + Advertising Data Length (1 Octet) + Scan Response Length (1 Octet) + Advertising Data (0-255 Octets) + Scan Response (0-255 Octets) + Return Parameters: Instance (1 Octet) + + The Add Extended Advertising Data command is used to update the + advertising data of an existing advertising instance known to the + kernel. It is expected to be called after an Add Extended Advertising + Parameters command, as part of the advertisement registration + process. + + If extended advertising is available, this call will initiate HCI + commands to set the instance's advertising data, set scan response + data, and then enable the instance. If extended advertising is + unavailable, the advertising instance structure maintained in kernel + will have its advertising data and scan response updated, and the + instance will either be scheduled immediately or left in the queue + for later advertisement as part of round-robin advertisement rotation + in software. + + If Scan_Rsp_Len is zero and the flags defined in Add Extended + Advertising Parameters command do not have connectable flag set and + the global connectable setting is off, then non-connectable + advertising is used. If Scan_Rsp_Len is larger than zero and + connectable flag is not set and the global advertising is off, + then scannable advertising is used. This small difference is + supported to provide less air traffic for devices implementing + broadcaster role. + + If the Instance provided does not match a known instance, or if the + provided advertising data or scan response are in an unrecognized + format, an "Invalid Parameters" status will be returned. + + If a "Set LE" or Advertising command is still in progress, a "Busy" + status will be returned. + + If the controller is not powered, a "rejected" status will be returned. + + This command generates a Command Complete event on success or a + Command Status event on failure. + + Possible errors: Failed + Rejected + Invalid Parameters + Busy + + +Read Controller Capabilities Command +==================================== + + Command Code: 0x0056 + Controller Index: <controller id> + Command Parameters: + Return Parameters: Parameter1 { + Capability_Tag (2 Octet) + Value_Length (1 Octet) + Value (0-255 Octets) + } + Parameter2 { } + ... + + This command is used to read a list of controller capabilities. + + Currently defined Capability_Tag values are: + + 0x0000 Minimum Supported LE Tx Power (dBm) + 0x0001 Maximum Supported LE Tx Power (dBm) + + Command Complete Event ====================== @@ -4577,3 +4806,17 @@ Advertisement Monitor Removed Event The event will only be sent to management sockets other than the one through which the command was sent. + + +Advertisement Tx Power Selected Event +=================================== + + Event Code: 0x002f + Controller Index: <controller id> + Event Parameters: Instance (1 Octet) + TxPower (1 Octet) + + This event indicates that the controller selected a transmission + power for an advertising instance. The event is emitted on platforms + that support extended advertising after an Add Extended Advertising + Parameters command is submitted. \ No newline at end of file -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qHhkB46fYl/4NwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:28:14 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id ABq0BI6fYl+p6QAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:28:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D4C9E4087F; Thu, 17 Sep 2020 01:28:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726373AbgIPX2H (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:28:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbgIPX2G (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:28:06 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 744FAC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:28:06 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id 4so111567ooh.11 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3SddsxFv/5tz1O3GGP3NqbO56lrjVtwhe4TX79+z8PE=; b=Mp2L3iQv6rCy2gLpg7XqbisUNJuWUoXNcBhf+d0hP8oMsnJMh2tbyee/D837MkbjZs bjVAmtOBRpFXfl5AMgOu8AUt0axgPDrZXQIQqkjAsQIgN2/bo0i4nKUzdx2hQcbAQqE9 4XqFWRn9eBM7y1x9eLODg1tjsc7PaCp7ULDmCrPH5Ne/Vdku+zaIL+lIH8obELsN15m8 H6NRUwYLMyLmZvlm7cv4PPrlidEYPbnXy8hE5BNNSaFYFtelujXlmCSJGERmd8BNxHTl Y/xP2E+Ii561IBbEfG28oSrm3Tb7KX/vMROnhDdOfLGXfzUzFvKcXhEuLWZNpgfUB0Mf OQJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3SddsxFv/5tz1O3GGP3NqbO56lrjVtwhe4TX79+z8PE=; b=sjCYf/O/7AAMAyS6rwHYTuKnct2Rng574CGlIMZLx+YumVkQEkAxW31cOYt5hL2KD0 FJ6dw3LN2BEnn4I2p2YkwBciHr02fgcBAveBUFSJls0zmPl3uQiaVvaRRmdWWU2AU1Av KamN/Weu1NaFLozWXwhivgu7+73cgZRDUBrWm9C3wna07GBSmA27AuPQZ1HhRB5CJiAf FLAHvZ02ogSJPkodyjdh4rcBGwJDpmqPbL/8JDkFIdQRuL5Hwir5V58W0Fg7ICT+V2kc 7fC8WttxlIX7gaoUM5N0mt7GWIhl7fmKYXHMrl+SgSQG1vrXKgb75qbWMzyZe9+xHCYP PjWQ== X-Gm-Message-State: AOAM531oo+XBzzis1QPiFr1O12jshYaF86CafZzB71sgsi/iLfvvj/A8 Mc2B6Y7JRldJbyYop9CHsFvlvXNuukdkYq8eCh5MoFlO1Ng= X-Google-Smtp-Source: ABdhPJyYLhgzeHwpqUCNuOvDSNaU62jaTyfvjgfBDLkAoKq4wWxgaPmDN4r8y1VBiE386y4JWFpxB3PVkLzUOeB0KSU= X-Received: by 2002:a4a:5896:: with SMTP id f144mr4835658oob.49.1600298885333; Wed, 16 Sep 2020 16:28:05 -0700 (PDT) MIME-Version: 1.0 References: <20200916211122.127881-1-sonnysasaka@chromium.org> In-Reply-To: <20200916211122.127881-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 16 Sep 2020 16:27:54 -0700 Message-ID: <CABBYNZKwZBM-3=jBvNVL7oHa133GGnZ5f8roNyrAR-hXNOVuhA@mail.gmail.com> Subject: Re: [PATCH BlueZ] a2dp: Keep track of ref ownership of a2dp_setup To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.85 / 15.00 / 15.00 X-Rspamd-Queue-Id: D4C9E4087F X-Rspamd-UID: 91b5fe Hi Sonny, On Wed, Sep 16, 2020 at 3:31 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > Currently transport_cb and abort_cfm make assumption that they have an > a2dp_setup reference held as a result of open_ind invocation. In the > field this is not always true, for example when the peer device opens an > L2CAP channel for AVDTP transport channel without sending AVDTP_OPEN > request through the AVDTP signaling channel first. Although in this case > the peer device does not behave correctly, we should protect this > possible crash from happening by making sure that transport_cb and > abort_cfm are really holding a reference of a2dp_setup object before > trying to unref them. > > After grabbing a reference, open_ind stores the pointer in > stream->pending_open_data. If this field is set, that means there is a > pending AVDTP_OPEN command and it needs to be unref-fed later once and > only once: when the transport channel is created (transport_cb) or when > the AVDTP_OPEN command is aborted (abort_cfm). If this field is not set, > nothing should unref it. This enforces that the reference counting is > correct regardless of the behavior of the peer device. While I agree that we should handle this properly and never crash I think we can take a more generic approach by attaching a user_data to the stream, see my comments bellow. > A sample crash stack trace from Chrome OS: > * thread #1, stop reason = signal SIGSEGV > * frame #0: 0x0c64f0e8 bluetoothd`queue_remove_all at queue.c:351 > frame #1: 0x0c64f086 bluetoothd`queue_destroy at queue.c:73 > frame #2: 0x0c6022b0 bluetoothd`setup_unref at a2dp.c:222 > frame #3: 0x0c604942 bluetoothd`transport_cb at a2dp.c:2229 > frame #4: 0x0c61e35c bluetoothd`accept_cb at btio.c:203 > frame #5: 0xf679523c libglib-2.0.so.0`g_main_context_dispatch at gmain.c:3182 > frame #6: 0xf67954aa libglib-2.0.so.0`g_main_context_iterate at gmain.c:3920 > frame #7: 0xf679569a libglib-2.0.so.0`g_main_loop_run at gmain.c:4116 > frame #8: 0x0c65a5a0 bluetoothd`mainloop_run at mainloop-glib.c:79 > frame #9: 0x0c65a7ea bluetoothd`mainloop_run_with_signal at mainloop-notify.c:201 > frame #10: 0x0c6477ec bluetoothd`main at main.c:772 > frame #11: 0xf65bc0a2 libc.so.6`__libc_start_main at libc-start.c:308 > > --- > profiles/audio/a2dp.c | 24 ++++++++++++++++-------- > profiles/audio/avdtp.c | 17 +++++++++++++++++ > profiles/audio/avdtp.h | 3 +++ > 3 files changed, 36 insertions(+), 8 deletions(-) > > diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c > index 2feea66c0..9e96f8c4b 100644 > --- a/profiles/audio/a2dp.c > +++ b/profiles/audio/a2dp.c > @@ -927,10 +927,16 @@ static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep, > else > DBG("Source %p: Open_Ind", sep); > > + if (avdtp_stream_get_pending_open_data(stream)) { > + warn("Pending open data already exists"); > + return FALSE; > + } > + Not really clear why you need to check if there is a setup already in pending state here, if that is the case then that should be fixed in avdtp.c since it is not support to call open again if it is already pending. > setup = a2dp_setup_get(session); > if (!setup) > return FALSE; > > + avdtp_stream_set_pending_open_data(stream, setup); Id like this to be handle generically in with something like: avdtp_stream_set_user_data(session, setup, destroy) setup = avdtp_stream_get_user_data(session) This should avoid lookups in the likes of a2dp_setup_get and ensure that the setup lifetime is tied to the stream. > setup->stream = stream; > > if (!err && setup->chan) > @@ -1285,14 +1291,13 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, > void *user_data) > { > struct a2dp_sep *a2dp_sep = user_data; > - struct a2dp_setup *setup; > + struct a2dp_setup *setup = avdtp_stream_get_pending_open_data(stream); Abort can be called while in configured state as well, anyway if we go ahead with the idea of attaching the setup to the avdtp_stream then this would be just a matter of calling avdtp_stream_get_user_data. > > if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK) > DBG("Sink %p: Abort_Cfm", sep); > else > DBG("Source %p: Abort_Cfm", sep); > > - setup = find_setup_by_session(session); > if (!setup) > return; > > @@ -1302,6 +1307,7 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, > } > > setup_unref(setup); > + avdtp_stream_set_pending_open_data(stream, NULL); This would then be avdtp_stream_set_user_data(stream, NULL, NULL), or better yet wait the destroy function to be called which should then do setup_unref to destroy the setup. > } > > static gboolean reconf_ind(struct avdtp *session, struct avdtp_local_sep *sep, > @@ -2216,11 +2222,12 @@ fail: > > static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > { > - struct a2dp_setup *setup = user_data; > + struct avdtp_stream *stream = user_data; > + struct a2dp_setup *setup = avdtp_stream_get_pending_open_data(stream); > uint16_t omtu, imtu; > > - if (!g_slist_find(setups, setup)) { > - warn("bt_io_accept: setup %p no longer valid", setup); > + if (!setup) { > + warn("transport_cb: pending open data does not exist"); > g_io_channel_shutdown(io, TRUE, NULL); > return; > } > @@ -2238,8 +2245,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > goto drop; > } > > - if (!avdtp_stream_set_transport(setup->stream, > - g_io_channel_unix_get_fd(io), > + if (!avdtp_stream_set_transport(stream, g_io_channel_unix_get_fd(io), > imtu, omtu)) > goto drop; > > @@ -2249,6 +2255,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > setup->io = NULL; > > setup_unref(setup); > + avdtp_stream_set_pending_open_data(stream, NULL); Ditto. > return; > > @@ -2297,7 +2304,8 @@ static void confirm_cb(GIOChannel *io, gpointer data) > goto drop; > } > > - if (!bt_io_accept(io, transport_cb, setup, NULL, &err)) { > + if (!bt_io_accept(io, transport_cb, setup->stream, NULL, > + &err)) { > error("bt_io_accept: %s", err->message); > g_error_free(err); > goto drop; > diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c > index 782268c08..74b9f8dfa 100644 > --- a/profiles/audio/avdtp.c > +++ b/profiles/audio/avdtp.c > @@ -366,6 +366,8 @@ struct avdtp_stream { > GSList *caps; > GSList *callbacks; > struct avdtp_service_capability *codec; > + void *pending_open_data; /* Data when the transport channel > + * opening is pending */ > guint io_id; /* Transport GSource ID */ > guint timer; /* Waiting for other side to close or open > * the transport channel */ > @@ -727,6 +729,11 @@ static void stream_free(void *data) > g_slist_free_full(stream->callbacks, g_free); > g_slist_free_full(stream->caps, g_free); > > + /* pending_open_data must have been unref-ed and unset before freeing > + * avdtp_stream. Otherwise, it is a reference leak bug. > + */ > + assert(!stream->pending_open_data); > + > g_free(stream); > } > > @@ -3147,6 +3154,16 @@ struct avdtp_remote_sep *avdtp_stream_get_remote_sep( > return NULL; > } > > +void avdtp_stream_set_pending_open_data(struct avdtp_stream *stream, void *data) > +{ > + stream->pending_open_data = data; > +} > + > +void *avdtp_stream_get_pending_open_data(struct avdtp_stream *stream) > +{ > + return stream->pending_open_data; > +} > + > gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd, > size_t imtu, size_t omtu) > { > diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h > index 011fea89e..92ce65ed3 100644 > --- a/profiles/audio/avdtp.h > +++ b/profiles/audio/avdtp.h > @@ -260,6 +260,9 @@ gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream, > GSList *caps); > struct avdtp_remote_sep *avdtp_stream_get_remote_sep( > struct avdtp_stream *stream); > +void avdtp_stream_set_pending_open_data(struct avdtp_stream *stream, > + void *data); > +void *avdtp_stream_get_pending_open_data(struct avdtp_stream *stream); > > unsigned int avdtp_add_state_cb(struct btd_device *dev, > avdtp_session_state_cb cb, void *user_data); > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GG0MKOKfYl8pKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:29:38 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id GExiJeKfYl8udQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:29:38 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A91B7A01F5; Thu, 17 Sep 2020 01:29:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726409AbgIPX3a (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:29:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbgIPX33 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:29:29 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38AC6C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:29:29 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id b17so255777pji.1 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jJtM6SWc5ZprJqMDDK5XKhZigjMAkpVWMtpZC0dehHA=; b=UK37IqGVbuC4KpqXMsFpnuuRHM4BtO9YmaDyAzwwVzLpG7H+o8gb+uis7gcg3jqZS5 tVAVSOejG4y/MVUDLBM0DR/FKJ4EWoOcQi+ZgVdVoPyDBow76x8nNwskzGyEYUAYWf2s /4QdHAzQ6CiOtz6vP7Bv2glbZOfR8lOOTIILw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jJtM6SWc5ZprJqMDDK5XKhZigjMAkpVWMtpZC0dehHA=; b=ev7NGPugx85R0uWYKh5Sd6qa2qtMg0HdOwuef5ayK9ZwNU2Javf1ggET4Y9sz+O/Me 8ASAcw+04mLRYoY2RaRC8gqfXEwvvQACyW6Y0ObNmvb74fbaurURtgFEfOK0XkwGyWEl IVTYk/YvOZI7okh8oK6dTSU+tnT41oLVVCF104V7g8SWlz71mWvRWoSknpwnIblos+c/ fdcfEiSNAO226g0OJmiW46DzR6cnyR1yYULA7j3Tx8OK49D/kHNUUjVnpnFDAz3Toe33 IsGQWRYtdpWi9cHiiaqwEQnBkA/kHVDlYB2x1KaB3PZ2zaM8CVZzS0cnyULpcukROlvh zI9Q== X-Gm-Message-State: AOAM533rB3Dh6rzpsZJ0nTgqNNOrZO2LyQgGUK0vGDIAPD0bniBcRBlq C5mZ47XcQZ/NADV4ILoXt/jN3NCb9WfxfQ== X-Google-Smtp-Source: ABdhPJzO09u3HbXY+6gsdxh8qsbkrvXf8kZLhLYQoWorNow32Lw0OlDHuj6L+y4FuMw6JG7Bk1zXKQ== X-Received: by 2002:a17:902:d711:b029:d1:c6b5:ae5f with SMTP id w17-20020a170902d711b02900d1c6b5ae5fmr17157192ply.38.1600298968370; Wed, 16 Sep 2020 16:29:28 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id d77sm18211112pfd.121.2020.09.16.16.29.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 16:29:27 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org> Subject: [PATCH BlueZ] doc/coding-style: Allow spaces after tabs for indenting wrapped lines Date: Wed, 16 Sep 2020 16:29:24 -0700 Message-Id: <20200916232924.129991-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.65 / 15.00 / 15.00 X-Rspamd-Queue-Id: A91B7A01F5 X-Rspamd-UID: f4e826 The "only tabs for indentation" rule was enforced long ago to align with Linux kernel net coding style. This is no longer the case today so we are relaxing the coding style to allow spaces after tabs if it can increase readability. --- doc/coding-style.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/coding-style.txt b/doc/coding-style.txt index f0bf880e3..6a7415847 100644 --- a/doc/coding-style.txt +++ b/doc/coding-style.txt @@ -104,9 +104,16 @@ void btd_adapter_register_pin_cb(struct btd_adapter *adapter, void btd_adapter_register_pin_cb(struct btd_adapter *adapter, btd_adapter_pin_cb_t cb) +5) +void btd_adapter_register_pin_cb(struct btd_adapter *adapter, + btd_adapter_pin_cb_t cb) + The referred style for line wrapping is to indent as far as possible to the right without hitting the 80 columns limit. +It is acceptable to add padding with spaces after tabs to increase +readability, for example to indent function arguments at the parenthesis. + M5: Space when doing type casting ================================= -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CLwABImhYl8pKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:36:41 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8HgJAYmhYl/upAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:36:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 52B21A0170; Thu, 17 Sep 2020 01:36:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726309AbgIPXge (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:36:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726269AbgIPXgb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:36:31 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6DC7C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:36:30 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id v20so321424oiv.3 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QEEqKPIelJrYe7KB747zLJeJa6uzs/9sM6BKF6loCK0=; b=Yk5XAoHKQJHShNP7OnJHXxIOT0dp2+SmDYvczGF/ih5M+zSRsYO2bzGkToWBAUgp5K Hny4d+b4P0TSB8AOPrtxQ2fG4mOD5S793ObNpHHO1MFh+gq0WuIMQF7DF5/wrjoIcCqM sJgMr4Jd02X/KV9/lNwAyJFarJHrZVfj0jO9NqZ7rZCryxXHNY8u8e7d+VKZ9HYQr8wQ NTKGx+6BBnPEhTwrdji4EAO2zX6yzetlS5do5yF/6u/iO8E972SO3STERFS4m8j7jI1j 1hmJ0KWLrQzEqmboL4R3fscDotoIyXZRdqM03bHgpRZbtDxHCzwKyCdaLNfI1c5ascrj aorA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QEEqKPIelJrYe7KB747zLJeJa6uzs/9sM6BKF6loCK0=; b=jJ7gJjftLOaQGnCWtYMVR+CB9VIbACIQoAEbQuAieY/8usLyP583tXhq1S8oAU7SjW 5xGzcJduWWVe6jDKaMJ3r45Yy6gAjs69a5Bi18JhNdR3iTYS71QY8DP5g4FhNFNzmWN+ tN6gSSed1BAVdpFhAwCx7u+5EO3H4P1xD4UhTEukZC4elpcmU4FULirMuKRC+qFhTHRO wmsYI2f7bNzxPX7iMiJoB6JryUDgNkbbEqGw/DKyuJl8TP5elGuu1mHDB5SM/5Z8lJEY BIHVvG0LLPkE+iICykr8AsP33goEqoVe+z3k7WGWasWI2b7rVaa1anA1B76u4cReT/Dl hL3A== X-Gm-Message-State: AOAM533ztmMd43/n9T6mISbgpdDT8aH8D/Y/w8r6ypk9Q8jwaKCRVd4g mBlyzvERwwSedcVAGtUPL+2FzraZCBZl/LRhFlCRunG1 X-Google-Smtp-Source: ABdhPJwVMaS92EjHb3dCx4HGB12tJfy8nI/CMDc28j286BZUwfZiPiT9YyMqZlV9Kxc8mSja1oeSpuglHC7/XDwJ7jQ= X-Received: by 2002:aca:38d7:: with SMTP id f206mr4278793oia.48.1600299390104; Wed, 16 Sep 2020 16:36:30 -0700 (PDT) MIME-Version: 1.0 References: <20200916232924.129991-1-sonnysasaka@chromium.org> In-Reply-To: <20200916232924.129991-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 16 Sep 2020 16:36:18 -0700 Message-ID: <CABBYNZ+CVzVW+L7eC3=f3siDZwqdpxecZ7r6oZ410MPhqj2omQ@mail.gmail.com> Subject: Re: [PATCH BlueZ] doc/coding-style: Allow spaces after tabs for indenting wrapped lines To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.68 / 15.00 / 15.00 X-Rspamd-Queue-Id: 52B21A0170 X-Rspamd-UID: 319e5a Hi Marcel, On Wed, Sep 16, 2020 at 4:31 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > The "only tabs for indentation" rule was enforced long ago to align with > Linux kernel net coding style. This is no longer the case today so we > are relaxing the coding style to allow spaces after tabs if it can > increase readability. > > --- > doc/coding-style.txt | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/doc/coding-style.txt b/doc/coding-style.txt > index f0bf880e3..6a7415847 100644 > --- a/doc/coding-style.txt > +++ b/doc/coding-style.txt > @@ -104,9 +104,16 @@ void btd_adapter_register_pin_cb(struct btd_adapter *adapter, > void btd_adapter_register_pin_cb(struct btd_adapter *adapter, > btd_adapter_pin_cb_t cb) > > +5) > +void btd_adapter_register_pin_cb(struct btd_adapter *adapter, > + btd_adapter_pin_cb_t cb) > + > The referred style for line wrapping is to indent as far as possible to the > right without hitting the 80 columns limit. > > +It is acceptable to add padding with spaces after tabs to increase > +readability, for example to indent function arguments at the parenthesis. > + @Marcel: Any thoughts on this change? Id like to apply this so we make the life of people contributing to both kernel and userspace easier. > M5: Space when doing type casting > ================================= > > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CPlqAoGjYl9yiAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:45:05 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id oCyoOoCjYl9PyQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:45:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C53AF4086A; Thu, 17 Sep 2020 01:44:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726525AbgIPXo4 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:44:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbgIPXoz (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:44:55 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 698C5C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:44:54 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id g26so120877ooa.9 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:44:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NY7OPE1F+WqL1N+o17129KaKPHeO1x4YyMh0/VE8XNE=; b=kGrspViE6B7bAbfSfrMwb16hypxheTzqdjGxecGWtUKcz/Wh448xtcgDZ5cW1Jwet4 rDX3oRGQE8R2DJrckc72VPyXKrwfFYpu46z4m99D1sZejtV5hJkGtzJr1IaBCNtvxNkn TBmTsPHzBGYCsS6GQCe5YHg+Kj+0Gy/0og209lV1vcAh+6XFTVchKRrh0qyA5FCOUBw/ eywvQgZyjXlsMGacykHzwIHXyJ9DewmKebKBTXdRTyqOWXHci3mu+rWCT9ZQ1purt/i0 U+qcFhmHljGFkePIMNhtND4hSe0a5ymkTAgt6QubjdNbexjsiHsB88mKn51jC4pT7M/w an5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NY7OPE1F+WqL1N+o17129KaKPHeO1x4YyMh0/VE8XNE=; b=PVAMdG70lnRlFkRsZ9BuDmQCKs/6zYOU32kbMyumgmFn/xXcowxfVFXtKwNEOvtZ0p AZ91K+cgVhwGW3XoaHtK4am1wuPHeM/4Qd9y5cM5LmrEeqI+5WP5uWcENl41hotm4CPN OOokXaBE96fCx9BPKP7l4q0COSuOIbCuDjs7xRMuwemDmWGFhc7b/6vsLtuJ3Me6B26P WnkLmrt1rFrvxTkNfZcqCkzDhwvZlJ7Lt+WMw5RJMpODyqBu1Tguvp+TB7p6VM6RT9vN WOvscz9lqOnxuJuNoPc4myKkhOTIbPzMGq1j0UmBs9b54GroGQ+Uhe8WCoYsVXNSSnej POjA== X-Gm-Message-State: AOAM530zqwgjYyEfVVKC0NmNR4PlaXXqVVHSiEHppxaJ5xP/GsRYgvmM 308sM9vYOfjqOEoRBlgnbvIqOiqEI/xz94a+Ckw= X-Google-Smtp-Source: ABdhPJyWy9x+nSAtZierqgirLVBHfm7i6uwczsjOZspYd6gjMtYtvUrwAR7+mzQAwh1ZF9JVx7T4OQpx/XpvnWWgS6Q= X-Received: by 2002:a4a:8dd5:: with SMTP id a21mr19277607ool.17.1600299892243; Wed, 16 Sep 2020 16:44:52 -0700 (PDT) MIME-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> <20200916162155.Bluez.1.I50d9faa25e9da6e71d77c83c7d47a5b135e88799@changeid> In-Reply-To: <20200916162155.Bluez.1.I50d9faa25e9da6e71d77c83c7d47a5b135e88799@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 16 Sep 2020 16:44:40 -0700 Message-ID: <CABBYNZJ5KrfkdTDWP_ugqcb_ybzrF2nAUeP=cE37cm86VG4GZQ@mail.gmail.com> Subject: Re: [Bluez PATCH 01/10] advertising: Detect if extended advertising mgmt commands are supported To: Daniel Winkler <danielwinkler@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.96 / 15.00 / 15.00 X-Rspamd-Queue-Id: C53AF4086A X-Rspamd-UID: 11f499 Hi Daniel, On Wed, Sep 16, 2020 at 4:25 PM Daniel Winkler <danielwinkler@google.com> wrote: > > We need to know if kernel supports the new MGMT interface. To do so, we > call MGMT_OP_READ_COMMANDS when our manager is created and check if the > new commands are available. This will then be used to route our requests > for new advertisements. > > The change is tested by manually verifying that the correct MGMT > commands are used when the feature is and is not available in kernel. > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > --- > > src/advertising.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/src/advertising.c b/src/advertising.c > index e5f25948d..172a83907 100644 > --- a/src/advertising.c > +++ b/src/advertising.c > @@ -57,6 +57,7 @@ struct btd_adv_manager { > uint8_t max_ads; > uint32_t supported_flags; > unsigned int instance_bitmap; > + bool extended_add_cmds; > }; > > #define AD_TYPE_BROADCAST 0 > @@ -1407,6 +1408,51 @@ static void read_adv_features_callback(uint8_t status, uint16_t length, > remove_advertising(manager, 0); > } > > +static void read_commands_complete(uint8_t status, uint16_t length, > + const void *param, void *user_data) > +{ > + struct btd_adv_manager *manager = user_data; > + const struct mgmt_rp_read_commands *rp = param; > + uint16_t num_commands, num_events; > + size_t expected_len; > + int i; > + > + if (status != MGMT_STATUS_SUCCESS) { > + error("Failed to read supported commands: %s (0x%02x)", > + mgmt_errstr(status), status); > + return; > + } > + > + if (length < sizeof(*rp)) { > + error("Wrong size of read commands response"); > + return; > + } > + > + num_commands = btohs(rp->num_commands); > + num_events = btohs(rp->num_events); > + > + expected_len = sizeof(*rp) + num_commands * sizeof(uint16_t) + > + num_events * sizeof(uint16_t); > + > + if (length < expected_len) { > + error("Too small reply for supported commands: (%u != %zu)", > + length, expected_len); > + return; > + } > + > + for (i = 0; i < num_commands; i++) { > + uint16_t op = get_le16(rp->opcodes + i); > + > + switch (op) { > + case MGMT_OP_ADD_EXT_ADV_PARAMS: > + manager->extended_add_cmds = true; > + break; > + default: > + break; > + } > + } > +} I wouldn't duplicate the handling of MGMT_OP_READ_COMMANDS, so I would move this to adapter.c and instead use btd_has_kernel_features in advertising.c > static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, > struct mgmt *mgmt) > { > @@ -1426,6 +1472,7 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, > manager->mgmt_index = btd_adapter_get_index(adapter); > manager->clients = queue_new(); > manager->supported_flags = MGMT_ADV_FLAG_LOCAL_NAME; > + manager->extended_add_cmds = false; > > if (!g_dbus_register_interface(btd_get_dbus_connection(), > adapter_get_path(manager->adapter), > @@ -1442,6 +1489,13 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, > goto fail; > } > > + /* Determine if kernel supports extended advertising add command. We > + * don't care if this request fails, as we will fall back to legacy > + * add_advertising by default > + */ > + mgmt_send(manager->mgmt, MGMT_OP_READ_COMMANDS, MGMT_INDEX_NONE, 0, > + NULL, read_commands_complete, manager, NULL); > + > return manager; > > fail: > -- > 2.28.0.618.gf4bc123cb7-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8G2mNzGlYl/DtwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:52:17 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id mFFQNDGlYl9sxQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:52:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 316A340015; Thu, 17 Sep 2020 01:52:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726550AbgIPXwI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726409AbgIPXwH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:52:07 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82A03C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:52:06 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id o8so246098otl.4 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:52:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/dOZpGAyEkhicuzwk7bQFgubOIonm4Qkms9cAEQj4YY=; b=N/o6z4/6inucRGhe9Hqkcudxl8FCtleWrI46/Bjdh8BMUDNGA7oe0CCqSrZ4XKSLhs Rs//ZXdW+9jeXNf/KQ42qYqCUdXYm7kUj8ufrl4uJJBKIQlXBKg9CnazKROH1tDMpdg4 W1bthPOSuItMXygpYJfrbAH/wfggSMuh19UuFTfiLsNfRv9c3Etapm6Gq9I9U13AyhwB wUjVy4cbqFMaKGDJoWgExTaTBppmNWtcg/hee07xzaY4eWYr4OI8PqtJavKKl7oKGNyX 8Dz0wCV+KZHM7VEWjAiSc7eJIdJdoTTLJ2qmErmnyieAjtzQZObfq4L5kVIB2EKpzKag h8NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/dOZpGAyEkhicuzwk7bQFgubOIonm4Qkms9cAEQj4YY=; b=m+FFNpNJcwyKZLjgaxGtpjt61eRXRukf8LvscnqJMO4zlNhqpAYuAx4olQnQkOPwAx ejw+tSJagpEzeMhCL/WwSij/x3AsxYjwo6VYlGDYwrzjTXz0eS2QkgFlRuF7IWqwRmE0 0aXLZL5sETs7EXpnsfuFDgSQCbEglSW8jcbYfXsNOVGVEQfQfpkAFfauDNQIQaVOfNen jep5lnLKbSDPX+8cxE80eDrXr6tCxFjyGVy8R9L3SVBtfjDvEvmzqj95yyMbN2rnZBa5 xMy2IYyakfnpTWqE3bf9JL6pzlJiAq2eNZrZ2OTvvWZAQNhaO9qAo0HVTRc/ad7I6wT9 JGkQ== X-Gm-Message-State: AOAM5320eprRWuq6KXMw8+8tPhbrahwFCKbnaEKRdTUDzPdEV1x4jgav PuW1Ov9HEELXBXdpNlx9HrDFeVqMYfHcbDYrhruAS4j8 X-Google-Smtp-Source: ABdhPJwLxySAPFJEvZo0fmcsNHkbVjw3b8LoYK3Vj0Q86FOLAt58XdfWy0wGAa85kmuZ2v8QqRB3MwQYhLqmhy/wWSU= X-Received: by 2002:a9d:5a8:: with SMTP id 37mr9775720otd.362.1600300325719; Wed, 16 Sep 2020 16:52:05 -0700 (PDT) MIME-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> <20200916162155.Bluez.2.Ic4a3667da774f5f34477d5168a68a9280657e2da@changeid> In-Reply-To: <20200916162155.Bluez.2.Ic4a3667da774f5f34477d5168a68a9280657e2da@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 16 Sep 2020 16:51:54 -0700 Message-ID: <CABBYNZ+5DW4eM_r0xZKRuWGbbA-y64VYnGiFTBo7hu4E7G-qZw@mail.gmail.com> Subject: Re: [Bluez PATCH 02/10] advertising: Parse intervals and tx power from adv To: Daniel Winkler <danielwinkler@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.01 / 15.00 / 15.00 X-Rspamd-Queue-Id: 316A340015 X-Rspamd-UID: 96876a Hi Daniel, On Wed, Sep 16, 2020 at 4:25 PM Daniel Winkler <danielwinkler@google.com> wrote: > > This change adds parsers for the advertising intervals and tx power > properties of the LEAdvertisement1 object. It validates that each field > adheres to the 5.2 spec, and that min and max intervals are compatible > with each other, i.e. that min interval is less than max interval. > > A note here for maintainers: The tx power that is sent in the hci > parameter command is an int8_t, but as far as I can tell, there is no > clean way to use a signed 8-bit integer in dbus. The dbus byte type > seems incompatible with negative values in high-level languages (python) > without awkward usage manipulation on the client side. For this reason, > I chose to use an int16_t type for the tx power dbus field, which is > then downcasted to the int8_t in bluetoothd, which at least makes the > signed-ness of the type crystal clear to the dbus client that uses it. > > This change is manually verified by ensuring the intervals and tx power > parameters are correctly parsed from the LEAdvertisement1 object, and > that the parse fails if the parameters are incorrect or not compatible > with each other. > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > --- > > src/advertising.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 89 insertions(+) > > diff --git a/src/advertising.c b/src/advertising.c > index 172a83907..82ee87313 100644 > --- a/src/advertising.c > +++ b/src/advertising.c > @@ -63,6 +63,11 @@ struct btd_adv_manager { > #define AD_TYPE_BROADCAST 0 > #define AD_TYPE_PERIPHERAL 1 > > +/* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2585 > + * defines tx power value indicating no preference > + */ > +#define ADV_TX_POWER_NO_PREFERENCE 0x7F > + > struct btd_adv_client { > struct btd_adv_manager *manager; > char *owner; > @@ -83,6 +88,9 @@ struct btd_adv_client { > struct bt_ad *data; > struct bt_ad *scan; > uint8_t instance; > + uint32_t min_interval; > + uint32_t max_interval; > + int8_t tx_power; > }; > > struct dbus_obj_match { > @@ -946,6 +954,74 @@ static bool parse_secondary(DBusMessageIter *iter, > return false; > } > > +static bool parse_min_interval(DBusMessageIter *iter, > + struct btd_adv_client *client) > +{ > + if (!iter) > + return false; > + > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) > + return false; > + > + dbus_message_iter_get_basic(iter, &client->min_interval); > + > + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2584 > + * defines acceptable interval range > + */ > + if (client->min_interval < 0x20 || client->min_interval > 0xFFFFFF) { > + client->min_interval = 0; > + return false; > + } > + > + return true; > +} > + > +static bool parse_max_interval(DBusMessageIter *iter, > + struct btd_adv_client *client) > +{ > + if (!iter) > + return false; > + > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) > + return false; > + > + dbus_message_iter_get_basic(iter, &client->max_interval); > + > + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2584 > + * defines acceptable interval range > + */ > + if (client->max_interval < 0x20 || client->max_interval > 0xFFFFFF) { > + client->max_interval = 0; > + return false; > + } > + > + return true; > +} > + > +static bool parse_tx_power(DBusMessageIter *iter, > + struct btd_adv_client *client) > +{ > + int16_t val; > + > + if (!iter) > + return false; > + > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INT16) > + return false; > + > + dbus_message_iter_get_basic(iter, &val); > + > + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2585 > + * defines acceptable tx power range > + */ > + if (val < -127 || val > 20) > + return false; > + > + client->tx_power = val; > + > + return true; > +} > + > static struct adv_parser { > const char *name; > bool (*func)(DBusMessageIter *iter, struct btd_adv_client *client); > @@ -964,6 +1040,9 @@ static struct adv_parser { > { "Discoverable", parse_discoverable }, > { "DiscoverableTimeout", parse_discoverable_timeout }, > { "SecondaryChannel", parse_secondary }, > + { "MinInterval", parse_min_interval }, > + { "MaxInterval", parse_max_interval }, We will need to these to the D-Bus documentation if you want to extend it. > + { "TxPower", parse_tx_power }, TxPower is already part of the include, or you want the ability to set an arbitrary TxPower? > { }, > }; > > @@ -1092,6 +1171,13 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client) > goto fail; > } > > + if (client->min_interval > client->max_interval) { > + /* Min interval must not be bigger than max interval */ > + error("MinInterval must be less than MaxInterval (%lu > %lu)", > + client->min_interval, client->max_interval); > + goto fail; > + } > + > err = refresh_adv(client, add_adv_callback, &client->add_adv_id); > if (!err) > return NULL; > @@ -1167,6 +1253,9 @@ static struct btd_adv_client *client_create(struct btd_adv_manager *manager, > > client->manager = manager; > client->appearance = UINT16_MAX; > + client->tx_power = ADV_TX_POWER_NO_PREFERENCE; > + client->min_interval = 0; > + client->max_interval = 0; > > return client; > > -- > 2.28.0.618.gf4bc123cb7-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ODuwLOioYl/4NwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 02:08:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8MsUKuioYl9LoQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 02:08:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 13CC7408B5; Thu, 17 Sep 2020 02:08:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726009AbgIQAH7 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 20:07:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726007AbgIQAH6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 20:07:58 -0400 X-Greylist: delayed 316 seconds by postgrey-1.27 at vger.kernel.org; Wed, 16 Sep 2020 20:07:58 EDT Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3D41C061788 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 17:02:41 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id r7so480588ejs.11 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 17:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vGLCFIVcgI24OiWenGBKe8BW0rwzw4fcxjxBsHEuLsE=; b=f7QCgfXmLzHqBY1cv2X4I5qGYUqFAoe2rvk/uMDZ3u3tJsfCFDQJ0oSgX2dWEMNlK4 56ks0CoFLs56M0QTBp/cgM9EL0STAJN1wtYOckLxXYD4Xdc1VKp9MtQEIwCzZvZlLxvx 0uGVNL+pjuIePvAsJBkgwlSyWEJl9241p0vTpLUe/bnULB4Wsu2naJjfebuKb5vbGU5e JogFoFZMOstimpEndyRganlk2PLK2DbWIqIrD/emAwc8/dx/vyMmwLMh5/NzdVZ3tW6Y +w7hoavAVkgqmgONuEC7+uosp5KoQJEiYyQ7+0s5lvfFgpaKvbGvj0Uo3XWG7XoaXPIj 1snw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vGLCFIVcgI24OiWenGBKe8BW0rwzw4fcxjxBsHEuLsE=; b=iHNcJ97HFzlzpZ52M2WKYuMscASKL0YSQx2t4YpukiWF0erg/DzwIAaPtHmgLKWDGO ryq1TTtjrtsvFoz3yO+Bkjerx/45Amb2+O56ASbVWvigyjVivnvPr4ryj+6Iaf1w+Hsl pwcGGs2A6TiH1EHJ7F533zKwWJh/gLsM13cd6emy2sdKt+O5U0/INFqPIErohP/08/sH UJ2MVVgT5sQiwpnshS6Wbq6HULGg0iKMakK3YAeKof8qz6+42uzhQ4abhBSztScchZ8D paczL43ho4ghYvOGSWry41jr2UopdTVU7FX9SncZSqY2zXozQzxMcK2m/joi8Y2BqYdc GbYQ== X-Gm-Message-State: AOAM533aKVNzvykNIwl/C+0zrmZ/7ca74l+Y4WnooZqYeL0G01zh+S4I ZTGD/vI9DFWIMQTAj1lBQyfmA5KaGalCFBl8OjD+XA== X-Google-Smtp-Source: ABdhPJy7sY1Mukd0GzKcmrjzT7YaMRYEnmb4UUIz/yy40C1JenDIdgOuEPd6rRsfQ9lSO3ZmPR5b+VMA8lmIkxz8eEo= X-Received: by 2002:a17:906:d045:: with SMTP id bo5mr27234847ejb.320.1600300960102; Wed, 16 Sep 2020 17:02:40 -0700 (PDT) MIME-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> <20200916162155.Bluez.2.Ic4a3667da774f5f34477d5168a68a9280657e2da@changeid> <CABBYNZ+5DW4eM_r0xZKRuWGbbA-y64VYnGiFTBo7hu4E7G-qZw@mail.gmail.com> <CAP2xMbsSXX6VVuJTKeqkmgV-AJMdfku3LB7n4yrMdo+2yJk7HQ@mail.gmail.com> <CABBYNZ+Tb+pxae+6puQ=NwZD3mSdDxXZBucAwmyMNOJxX++Wrw@mail.gmail.com> In-Reply-To: <CABBYNZ+Tb+pxae+6puQ=NwZD3mSdDxXZBucAwmyMNOJxX++Wrw@mail.gmail.com> From: Daniel Winkler <danielwinkler@google.com> Date: Wed, 16 Sep 2020 17:02:29 -0700 Message-ID: <CAP2xMbvp9WtKn5ANEcZxXmby3zde+F-5aQibPq07UWBc-fsocA@mail.gmail.com> Subject: Re: [Bluez PATCH 02/10] advertising: Parse intervals and tx power from adv To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -7.73 / 15.00 / 15.00 X-Rspamd-Queue-Id: 13CC7408B5 X-Rspamd-UID: 4b6455 Hello Luiz, Yes, there is a separate kernel patch series that allows the TxPower parameter to be set on a per-instance basis. This only applies to controllers supporting extended advertising, so another bluez patch series (awaiting review at https://patchwork.kernel.org/patch/11749533/) allows the client to check if the controller supports it first. This information is clarified in the later patches in this series, where the advertising api is updated. Thanks! Daniel On Wed, Sep 16, 2020 at 4:58 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Daniel, > > On Wed, Sep 16, 2020 at 4:53 PM Daniel Winkler <danielwinkler@google.com> wrote: > > > > Hello Luiz, > > > > The patch allows the client to set an arbitrary TxPower, different from the include property. > > Does the controller honor this setting? Can we really set a TxPower > per instance? If it doesn't then this can possibly break proximity > logic on the scanner side. > > > Best, > > Daniel > > > > On Wed, Sep 16, 2020 at 4:52 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > >> > >> Hi Daniel, > >> > >> On Wed, Sep 16, 2020 at 4:25 PM Daniel Winkler <danielwinkler@google.com> wrote: > >> > > >> > This change adds parsers for the advertising intervals and tx power > >> > properties of the LEAdvertisement1 object. It validates that each field > >> > adheres to the 5.2 spec, and that min and max intervals are compatible > >> > with each other, i.e. that min interval is less than max interval. > >> > > >> > A note here for maintainers: The tx power that is sent in the hci > >> > parameter command is an int8_t, but as far as I can tell, there is no > >> > clean way to use a signed 8-bit integer in dbus. The dbus byte type > >> > seems incompatible with negative values in high-level languages (python) > >> > without awkward usage manipulation on the client side. For this reason, > >> > I chose to use an int16_t type for the tx power dbus field, which is > >> > then downcasted to the int8_t in bluetoothd, which at least makes the > >> > signed-ness of the type crystal clear to the dbus client that uses it. > >> > > >> > This change is manually verified by ensuring the intervals and tx power > >> > parameters are correctly parsed from the LEAdvertisement1 object, and > >> > that the parse fails if the parameters are incorrect or not compatible > >> > with each other. > >> > > >> > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > >> > --- > >> > > >> > src/advertising.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ > >> > 1 file changed, 89 insertions(+) > >> > > >> > diff --git a/src/advertising.c b/src/advertising.c > >> > index 172a83907..82ee87313 100644 > >> > --- a/src/advertising.c > >> > +++ b/src/advertising.c > >> > @@ -63,6 +63,11 @@ struct btd_adv_manager { > >> > #define AD_TYPE_BROADCAST 0 > >> > #define AD_TYPE_PERIPHERAL 1 > >> > > >> > +/* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2585 > >> > + * defines tx power value indicating no preference > >> > + */ > >> > +#define ADV_TX_POWER_NO_PREFERENCE 0x7F > >> > + > >> > struct btd_adv_client { > >> > struct btd_adv_manager *manager; > >> > char *owner; > >> > @@ -83,6 +88,9 @@ struct btd_adv_client { > >> > struct bt_ad *data; > >> > struct bt_ad *scan; > >> > uint8_t instance; > >> > + uint32_t min_interval; > >> > + uint32_t max_interval; > >> > + int8_t tx_power; > >> > }; > >> > > >> > struct dbus_obj_match { > >> > @@ -946,6 +954,74 @@ static bool parse_secondary(DBusMessageIter *iter, > >> > return false; > >> > } > >> > > >> > +static bool parse_min_interval(DBusMessageIter *iter, > >> > + struct btd_adv_client *client) > >> > +{ > >> > + if (!iter) > >> > + return false; > >> > + > >> > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) > >> > + return false; > >> > + > >> > + dbus_message_iter_get_basic(iter, &client->min_interval); > >> > + > >> > + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2584 > >> > + * defines acceptable interval range > >> > + */ > >> > + if (client->min_interval < 0x20 || client->min_interval > 0xFFFFFF) { > >> > + client->min_interval = 0; > >> > + return false; > >> > + } > >> > + > >> > + return true; > >> > +} > >> > + > >> > +static bool parse_max_interval(DBusMessageIter *iter, > >> > + struct btd_adv_client *client) > >> > +{ > >> > + if (!iter) > >> > + return false; > >> > + > >> > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) > >> > + return false; > >> > + > >> > + dbus_message_iter_get_basic(iter, &client->max_interval); > >> > + > >> > + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2584 > >> > + * defines acceptable interval range > >> > + */ > >> > + if (client->max_interval < 0x20 || client->max_interval > 0xFFFFFF) { > >> > + client->max_interval = 0; > >> > + return false; > >> > + } > >> > + > >> > + return true; > >> > +} > >> > + > >> > +static bool parse_tx_power(DBusMessageIter *iter, > >> > + struct btd_adv_client *client) > >> > +{ > >> > + int16_t val; > >> > + > >> > + if (!iter) > >> > + return false; > >> > + > >> > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INT16) > >> > + return false; > >> > + > >> > + dbus_message_iter_get_basic(iter, &val); > >> > + > >> > + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2585 > >> > + * defines acceptable tx power range > >> > + */ > >> > + if (val < -127 || val > 20) > >> > + return false; > >> > + > >> > + client->tx_power = val; > >> > + > >> > + return true; > >> > +} > >> > + > >> > static struct adv_parser { > >> > const char *name; > >> > bool (*func)(DBusMessageIter *iter, struct btd_adv_client *client); > >> > @@ -964,6 +1040,9 @@ static struct adv_parser { > >> > { "Discoverable", parse_discoverable }, > >> > { "DiscoverableTimeout", parse_discoverable_timeout }, > >> > { "SecondaryChannel", parse_secondary }, > >> > + { "MinInterval", parse_min_interval }, > >> > + { "MaxInterval", parse_max_interval }, > >> > >> We will need to these to the D-Bus documentation if you want to extend it. > >> > >> > + { "TxPower", parse_tx_power }, > >> > >> TxPower is already part of the include, or you want the ability to set > >> an arbitrary TxPower? > >> > >> > { }, > >> > }; > >> > > >> > @@ -1092,6 +1171,13 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client) > >> > goto fail; > >> > } > >> > > >> > + if (client->min_interval > client->max_interval) { > >> > + /* Min interval must not be bigger than max interval */ > >> > + error("MinInterval must be less than MaxInterval (%lu > %lu)", > >> > + client->min_interval, client->max_interval); > >> > + goto fail; > >> > + } > >> > + > >> > err = refresh_adv(client, add_adv_callback, &client->add_adv_id); > >> > if (!err) > >> > return NULL; > >> > @@ -1167,6 +1253,9 @@ static struct btd_adv_client *client_create(struct btd_adv_manager *manager, > >> > > >> > client->manager = manager; > >> > client->appearance = UINT16_MAX; > >> > + client->tx_power = ADV_TX_POWER_NO_PREFERENCE; > >> > + client->min_interval = 0; > >> > + client->max_interval = 0; > >> > > >> > return client; > >> > > >> > -- > >> > 2.28.0.618.gf4bc123cb7-goog > >> > > >> > >> > >> -- > >> Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eDDJKTCrYl+/5gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 02:17:52 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cLtIJzCrYl9LoQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 02:17:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 28AD4A0170; Thu, 17 Sep 2020 02:17:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726007AbgIQARb (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 20:17:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgIQARa (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 20:17:30 -0400 X-Greylist: delayed 572 seconds by postgrey-1.27 at vger.kernel.org; Wed, 16 Sep 2020 20:17:30 EDT Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30A56C061797 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 17:17:30 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id a3so411342oib.4 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 17:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rbjSy2gcW5T8/jgPNs6ByC2L9lU5F0205z1v1qv0Y0A=; b=E9mfOvr3iqR2HRvMHaEUPDjIDirYVQrfmUu5CJfBzM2FoEHijkYMfly+QK9Skeulhj vzkX6BXOcCKBFeDOrNSKR9Xq96/6i6YXXmse9sdfK3ITow81AVe7EBVfC0ZUtDXzHHLr f5oLJG9XvKSurBqG9+M7afNX5x2EdNSilPpKsrxc0kgX+lkf1LOmiYnbKl56i2gfPoR0 MxY21oBi4clhoRvgsOYL/OBfn5MTeXZSmOsMG2dECLOVB5za+ebTnqCet9sauoH0OwuL tWOlwCPlgw/fJ3CPuZs1NwjgCV7mzpn8uYLRcyxVKC3vuacSfGOl+HIrhTWIlZBsNi2b F79g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rbjSy2gcW5T8/jgPNs6ByC2L9lU5F0205z1v1qv0Y0A=; b=EKx2n4Q//FgBWzM9OB4Zm7Vkwo6eRy3j8pWDqxoYRRlhZxTACZq/1lmyT5fhAskDKL 02WWgynT7ose0W57ZwqSUheln76sFMA4YBuhuRg7btPQ6jB5GyEhhIQnfLhYkN4CJbMs FIMmM5pOUEoan78ROxVd5uDpEyBMZycpWH2FXJYhH7nFlhBlgliwrsYfEVb/O6Ds8zfr CtvmqWHzV3VC8CzuivMBq4QXtrslZxz74I9ncxeUfn+zC8jODydI7U0qg7XleWxg3wST 6Aok0ty+/7B1e3cWYoWtGO8j5LcSTlSSqTHJLWmieFIEP3Wjbu271QtwyA+f2sLRBzt+ eSVg== X-Gm-Message-State: AOAM532awhD1UgIL4c2pxWbTvXE8MhX2ptzVJKlvJuTW6swNeLacsvMS Ddd8E8PlBYetyq4oTmxXJBUE6o2gpSuRTJLmxuk= X-Google-Smtp-Source: ABdhPJxweE1Xu9xoRVMB28v1eCtr6UegQHbnGomiNdJ0IKYhokuhNvc8XeIqh1nJWt5bxEbeR5u6qHS562UQ2OJ5QX4= X-Received: by 2002:aca:3e08:: with SMTP id l8mr4412989oia.152.1600301849422; Wed, 16 Sep 2020 17:17:29 -0700 (PDT) MIME-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> <20200916162155.Bluez.10.If15d3d09724ded2bcc7240d29f6888f2ad12e723@changeid> In-Reply-To: <20200916162155.Bluez.10.If15d3d09724ded2bcc7240d29f6888f2ad12e723@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 16 Sep 2020 17:17:18 -0700 Message-ID: <CABBYNZKKu55vC2vzCCN5iE5N66=RBj8T_+XfRDQMS1eYins04g@mail.gmail.com> Subject: Re: [Bluez PATCH 10/10] doc/mgmt-api: Add new MGMT interfaces to mgmt-api To: Daniel Winkler <danielwinkler@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.01 / 15.00 / 15.00 X-Rspamd-Queue-Id: 28AD4A0170 X-Rspamd-UID: 9065ea Hi Daniel, On Wed, Sep 16, 2020 at 4:26 PM Daniel Winkler <danielwinkler@google.com> wrote: > > This patch adds the following to mgmt-api: > - Add Extended Advertising Parameters Command > - Add Extended Advertising Data Command > - Read Controller Capabilities Command > - Advertisement Tx Power Selected Event > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > --- > > doc/mgmt-api.txt | 243 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 243 insertions(+) > > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt > index ca0d38469..6e8914611 100644 > --- a/doc/mgmt-api.txt > +++ b/doc/mgmt-api.txt > @@ -3574,6 +3574,235 @@ Remove Advertisement Monitor Command > Busy > > > +Add Extended Advertising Parameters Command > +======================= > + > + Command Code: 0x0054 > + Controller Index: <controller id> > + Command Parameters: Instance (1 Octet) > + Flags (4 Octets) > + Params (2 Octets) > + Duration (2 Octets) > + Timeout (2 Octets) > + MinInterval (4 Octets) > + MaxInterval (4 Octets) > + TxPower (1 Octet) > + Return Parameters: Instance (1 Octet) > + There seems to be an extra empty like here. > + This command is used to configure the parameters for Bluetooth Low > + Energy advertising instance. This command is expected to be followed > + by an Add Extended Advertising Data command to complete and enable > + the advertising instance. > + > + Added advertising information with this command will not be visible > + immediately if advertising is enabled via the Set Advertising > + command. The usage of the Set Advertising command takes precedence > + over this command. Instance information is stored and will be > + advertised once advertising via Set Advertising has been disabled. > + > + The Instance identifier is a value between 1 and the number of > + supported instances. The value 0 is reserved. > + > + With the Flags value the type of advertising is controlled and > + the following flags are defined: > + > + 0 Switch into Connectable mode > + 1 Advertise as Discoverable > + 2 Advertise as Limited Discoverable > + 3 Add Flags field to Adv_Data > + 4 Add TX Power field to Adv_Data > + 5 Add Appearance field to Scan_Rsp > + 6 Add Local Name in Scan_Rsp > + 7 Secondary Channel with LE 1M > + 8 Secondary Channel with LE 2M > + 9 Secondary Channel with LE Coded > + > + When the connectable flag is set, then the controller will use > + undirected connectable advertising. The value of the connectable > + setting can be overwritten this way. This is useful to switch a > + controller into connectable mode only for LE operation. This is > + similar to the mode 0x02 from the Set Advertising command. > + > + When the connectable flag is not set, then the controller will > + use advertising based on the connectable setting. When using > + non-connectable or scannable advertising, the controller will > + be programmed with a non-resolvable random address. When the > + system is connectable, then the identity address or resolvable > + private address will be used. > + > + Using the connectable flag is useful for peripheral mode support > + where BR/EDR (and/or LE) is controlled by Add Device. This allows > + making the peripheral connectable without having to interfere > + with the global connectable setting. > + > + Secondary channel flags can be used to advertise in secondary > + channel with the corresponding PHYs. These flag bits are mutually > + exclusive and setting multiple will result in Invalid Parameter > + error. Choosing either LE 1M or LE 2M will result in using > + extended advertising on the primary channel with LE 1M and the > + respectively LE 1M or LE 2M on the secondary channel. Choosing > + LE Coded will result in using extended advertising on the primary > + and secondary channels with LE Coded. Choosing none of these flags > + will result in legacy advertising. > + > + To allow future parameters to be optionally extended in this structure, > + the Params member is used to specify which of the structure fields were > + purposefully set by the caller. Unspecified parameters will be given > + sensible defaults by the kernel before the advertisement is registered. > + The Params bit field uses the following bit to parameter relationship: > + > + 0 The Duration parameter should be used > + 1 The Timeout parameter should be used > + 2 The Interval parameters should be used > + 3 The Tx Power parameter should be used > + > + The Duration parameter configures the length of an Instance. The > + value is in seconds. The default is 2 seconds. > + > + If only one advertising Instance has been added, then the Duration > + value will be ignored. It only applies for the case where multiple > + Instances are configured. In that case every Instance will be > + available for the Duration time and after that it switches to > + the next one. This is a simple round-robin based approach. > + > + The Timeout parameter configures the life-time of an Instance. In > + case the value 0 is used it indicates no expiration time. If a > + timeout value is provided, then the advertising Instance will be > + automatically removed when the timeout passes. The value for the > + timeout is in seconds. Powering down a controller will invalidate > + all advertising Instances and it is not possible to add a new > + Instance with a timeout when the controller is powered down. > + > + When a Timeout is provided, then the Duration subtracts from > + the actual Timeout value of that Instance. For example an Instance > + with Timeout of 5 and Duration of 2 will be scheduled exactly 3 > + times, twice with 2 seconds and once with one second. Other > + Instances have no influence on the Timeout. > + > + MinInterval and MaxInterval define the minimum and maximum advertising > + intervals, with units as number of .625ms advertising slots. The Max > + interval is expected to be greater than or equal to the Min interval, > + and both must have values in the range [0x000020, 0xFFFFFF]. If either > + condition is not met, the registration will fail. > + > + The provided Tx Power parameter will only be used if the controller > + supports it, which can be determined by the presence of the > + CanSetTxPower member of the Read Advertising Features command. > + > + The acceptable range for requested Tx Power is defined in the spec > + (Version 5.2 | Vol 4, Part E, page 2585) to be [-127, +20] dBm, and the > + controller will select a power value up to the requested one. The > + transmission power selected by the controller is not guaranteed > + to match the requested one, but the caller can determine the power > + chosen by the controller by listening for the Tx Power Selected MGMT > + event that follows this command. If the requested Tx Power is outside > + the valid range, the registration will fail. > + > + Re-adding an already existing instance (i.e. issuing the Add Extended > + Advertising Parameters command with an Instance identifier of an > + existing instance) will update that instance's configuration. > + > + An instance being added or changed while another instance is > + being advertised will not be visible immediately but only when > + the new/changed instance is being scheduled by the round robin > + advertising algorithm. > + > + Changes to an instance that is currently being advertised will > + cancel that instance and switch to the next instance. The changes > + will be visible the next time the instance is scheduled for > + advertising. In case a single instance is active, this means > + that changes will be visible right away. > + > + LE must already be enabled, and the controller must be powered, > + otherwise a "rejected" status will be returned. > + > + This command generates a Command Complete event on success or a > + Command Status event on failure. > + > + Possible errors: Failed > + Rejected > + Not Supported > + Invalid Parameters > + Busy > + > + > +Add Extended Advertising Data Command > +======================= > + > + Command Code: 0x0055 > + Controller Index: <controller id> > + Command Parameters: Instance (1 Octet) > + Advertising Data Length (1 Octet) > + Scan Response Length (1 Octet) > + Advertising Data (0-255 Octets) > + Scan Response (0-255 Octets) > + Return Parameters: Instance (1 Octet) > + > + The Add Extended Advertising Data command is used to update the > + advertising data of an existing advertising instance known to the > + kernel. It is expected to be called after an Add Extended Advertising > + Parameters command, as part of the advertisement registration > + process. > + > + If extended advertising is available, this call will initiate HCI > + commands to set the instance's advertising data, set scan response > + data, and then enable the instance. If extended advertising is > + unavailable, the advertising instance structure maintained in kernel > + will have its advertising data and scan response updated, and the > + instance will either be scheduled immediately or left in the queue > + for later advertisement as part of round-robin advertisement rotation > + in software. > + > + If Scan_Rsp_Len is zero and the flags defined in Add Extended > + Advertising Parameters command do not have connectable flag set and > + the global connectable setting is off, then non-connectable > + advertising is used. If Scan_Rsp_Len is larger than zero and > + connectable flag is not set and the global advertising is off, > + then scannable advertising is used. This small difference is > + supported to provide less air traffic for devices implementing > + broadcaster role. > + > + If the Instance provided does not match a known instance, or if the > + provided advertising data or scan response are in an unrecognized > + format, an "Invalid Parameters" status will be returned. > + > + If a "Set LE" or Advertising command is still in progress, a "Busy" > + status will be returned. > + > + If the controller is not powered, a "rejected" status will be returned. > + > + This command generates a Command Complete event on success or a > + Command Status event on failure. > + > + Possible errors: Failed > + Rejected > + Invalid Parameters > + Busy > + > + > +Read Controller Capabilities Command > +==================================== > + > + Command Code: 0x0056 > + Controller Index: <controller id> > + Command Parameters: > + Return Parameters: Parameter1 { > + Capability_Tag (2 Octet) > + Value_Length (1 Octet) > + Value (0-255 Octets) > + } > + Parameter2 { } > + ... > + > + This command is used to read a list of controller capabilities. > + > + Currently defined Capability_Tag values are: > + > + 0x0000 Minimum Supported LE Tx Power (dBm) > + 0x0001 Maximum Supported LE Tx Power (dBm) > + > + > Command Complete Event > ====================== > > @@ -4577,3 +4806,17 @@ Advertisement Monitor Removed Event > > The event will only be sent to management sockets other than the > one through which the command was sent. > + > + > +Advertisement Tx Power Selected Event > +=================================== > + > + Event Code: 0x002f > + Controller Index: <controller id> > + Event Parameters: Instance (1 Octet) > + TxPower (1 Octet) > + > + This event indicates that the controller selected a transmission > + power for an advertising instance. The event is emitted on platforms > + that support extended advertising after an Add Extended Advertising > + Parameters command is submitted. > \ No newline at end of file > -- > 2.28.0.618.gf4bc123cb7-goog I see you had the documentation at the end, this should probably go in the beginning so we can agree on the API first. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wDoOEEirYl+/5gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 02:18:16 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id cDJpDUirYl8yHwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 02:18:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 18507A0118; Thu, 17 Sep 2020 02:18:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726079AbgIQASD (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 20:18:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726040AbgIQASA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 20:18:00 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3C7DC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:58:45 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id y5so251713otg.5 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=05klGwQ04S9Ub6h6w3OPrfzCfcZrDDETUet72RYGoyw=; b=L/Nxv048HAY469MlzTttW9CqOASARqZovgQ6rwZtluvoWmBGsHaqDvVJqoggINm27c 9ODVZcxuy+W5VSuB3gNcb4EcdfHNDlwTPOLS1CnypH7CFSArMlbbeUJ8xKS7SZ5SNd8L ceL0HUrmIN/Br6NXC16TSp0xmN8amIDs75bovRKARZ2pXDmpVkbpEHPyas1G2QsVVPEj gB/Ez8xGRy2mTbTwssxS1yrfeTrHYz7VGAphhfefSXkWgjAEEVK/fXCrKQXWJbo/UuEW 7mcRfmkGmLGA93Bo000VSeQ+AwEQjqtAckQW1cJcIfTWsarv6uD4k97W3++6SlHmJoqz aNCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=05klGwQ04S9Ub6h6w3OPrfzCfcZrDDETUet72RYGoyw=; b=Z5XAqiQtEIGoc5AswZ9EuzSnxVhx1sIzJ77sBpEbQXy7hBV1ds7hlknkYkEdBZWIf0 QeYJTYQNDpKHDzgx+jIO2dfNhon5ZnhCJeELqtAcXcJ7RUxZcYl8FYzTL/KwXAsHEn10 CDBMA18v2AE/oejPQtgX2nzy7pVF9oXQwtLHVVIszoKuzwOGHz7HPZSjkWCQIC2K4YcZ vFb0Cfb8/xAgeBGLQ46n8LjvUoScf3IdnUNH7cqr1yW3yev4WmnQq4zhvvRsoXiNvXNn 1apPJt6U81EDnRcj/4QAFAyxIyellcyp2RF6VPpNZjwNOnZjgsqdzadVxnluovi8iK6o 64pQ== X-Gm-Message-State: AOAM533v0dlQ9F+0oxub2KCg8oBfibzAS8tcw1r0xTAG1ydVWCexAhg9 BCpbjtcy0Q2hY443IYh9p3RnTjQ6H2ZqwGLqOow= X-Google-Smtp-Source: ABdhPJwBoXmqu7ntFh7CLZOAMzGju32Zjzriv5XpESD+4fNNgymN+8LX4N/WqZD4Ujg6OAzTHismZjpTJ9ja6ZcI+P0= X-Received: by 2002:a9d:5a8:: with SMTP id 37mr9787445otd.362.1600300724504; Wed, 16 Sep 2020 16:58:44 -0700 (PDT) MIME-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> <20200916162155.Bluez.2.Ic4a3667da774f5f34477d5168a68a9280657e2da@changeid> <CABBYNZ+5DW4eM_r0xZKRuWGbbA-y64VYnGiFTBo7hu4E7G-qZw@mail.gmail.com> <CAP2xMbsSXX6VVuJTKeqkmgV-AJMdfku3LB7n4yrMdo+2yJk7HQ@mail.gmail.com> In-Reply-To: <CAP2xMbsSXX6VVuJTKeqkmgV-AJMdfku3LB7n4yrMdo+2yJk7HQ@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Wed, 16 Sep 2020 16:58:33 -0700 Message-ID: <CABBYNZ+Tb+pxae+6puQ=NwZD3mSdDxXZBucAwmyMNOJxX++Wrw@mail.gmail.com> Subject: Re: [Bluez PATCH 02/10] advertising: Parse intervals and tx power from adv To: Daniel Winkler <danielwinkler@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.36 / 15.00 / 15.00 X-Rspamd-Queue-Id: 18507A0118 X-Rspamd-UID: 68fe2b Hi Daniel, On Wed, Sep 16, 2020 at 4:53 PM Daniel Winkler <danielwinkler@google.com> wrote: > > Hello Luiz, > > The patch allows the client to set an arbitrary TxPower, different from the include property. Does the controller honor this setting? Can we really set a TxPower per instance? If it doesn't then this can possibly break proximity logic on the scanner side. > Best, > Daniel > > On Wed, Sep 16, 2020 at 4:52 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: >> >> Hi Daniel, >> >> On Wed, Sep 16, 2020 at 4:25 PM Daniel Winkler <danielwinkler@google.com> wrote: >> > >> > This change adds parsers for the advertising intervals and tx power >> > properties of the LEAdvertisement1 object. It validates that each field >> > adheres to the 5.2 spec, and that min and max intervals are compatible >> > with each other, i.e. that min interval is less than max interval. >> > >> > A note here for maintainers: The tx power that is sent in the hci >> > parameter command is an int8_t, but as far as I can tell, there is no >> > clean way to use a signed 8-bit integer in dbus. The dbus byte type >> > seems incompatible with negative values in high-level languages (python) >> > without awkward usage manipulation on the client side. For this reason, >> > I chose to use an int16_t type for the tx power dbus field, which is >> > then downcasted to the int8_t in bluetoothd, which at least makes the >> > signed-ness of the type crystal clear to the dbus client that uses it. >> > >> > This change is manually verified by ensuring the intervals and tx power >> > parameters are correctly parsed from the LEAdvertisement1 object, and >> > that the parse fails if the parameters are incorrect or not compatible >> > with each other. >> > >> > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> >> > --- >> > >> > src/advertising.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ >> > 1 file changed, 89 insertions(+) >> > >> > diff --git a/src/advertising.c b/src/advertising.c >> > index 172a83907..82ee87313 100644 >> > --- a/src/advertising.c >> > +++ b/src/advertising.c >> > @@ -63,6 +63,11 @@ struct btd_adv_manager { >> > #define AD_TYPE_BROADCAST 0 >> > #define AD_TYPE_PERIPHERAL 1 >> > >> > +/* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2585 >> > + * defines tx power value indicating no preference >> > + */ >> > +#define ADV_TX_POWER_NO_PREFERENCE 0x7F >> > + >> > struct btd_adv_client { >> > struct btd_adv_manager *manager; >> > char *owner; >> > @@ -83,6 +88,9 @@ struct btd_adv_client { >> > struct bt_ad *data; >> > struct bt_ad *scan; >> > uint8_t instance; >> > + uint32_t min_interval; >> > + uint32_t max_interval; >> > + int8_t tx_power; >> > }; >> > >> > struct dbus_obj_match { >> > @@ -946,6 +954,74 @@ static bool parse_secondary(DBusMessageIter *iter, >> > return false; >> > } >> > >> > +static bool parse_min_interval(DBusMessageIter *iter, >> > + struct btd_adv_client *client) >> > +{ >> > + if (!iter) >> > + return false; >> > + >> > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) >> > + return false; >> > + >> > + dbus_message_iter_get_basic(iter, &client->min_interval); >> > + >> > + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2584 >> > + * defines acceptable interval range >> > + */ >> > + if (client->min_interval < 0x20 || client->min_interval > 0xFFFFFF) { >> > + client->min_interval = 0; >> > + return false; >> > + } >> > + >> > + return true; >> > +} >> > + >> > +static bool parse_max_interval(DBusMessageIter *iter, >> > + struct btd_adv_client *client) >> > +{ >> > + if (!iter) >> > + return false; >> > + >> > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) >> > + return false; >> > + >> > + dbus_message_iter_get_basic(iter, &client->max_interval); >> > + >> > + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2584 >> > + * defines acceptable interval range >> > + */ >> > + if (client->max_interval < 0x20 || client->max_interval > 0xFFFFFF) { >> > + client->max_interval = 0; >> > + return false; >> > + } >> > + >> > + return true; >> > +} >> > + >> > +static bool parse_tx_power(DBusMessageIter *iter, >> > + struct btd_adv_client *client) >> > +{ >> > + int16_t val; >> > + >> > + if (!iter) >> > + return false; >> > + >> > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INT16) >> > + return false; >> > + >> > + dbus_message_iter_get_basic(iter, &val); >> > + >> > + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2585 >> > + * defines acceptable tx power range >> > + */ >> > + if (val < -127 || val > 20) >> > + return false; >> > + >> > + client->tx_power = val; >> > + >> > + return true; >> > +} >> > + >> > static struct adv_parser { >> > const char *name; >> > bool (*func)(DBusMessageIter *iter, struct btd_adv_client *client); >> > @@ -964,6 +1040,9 @@ static struct adv_parser { >> > { "Discoverable", parse_discoverable }, >> > { "DiscoverableTimeout", parse_discoverable_timeout }, >> > { "SecondaryChannel", parse_secondary }, >> > + { "MinInterval", parse_min_interval }, >> > + { "MaxInterval", parse_max_interval }, >> >> We will need to these to the D-Bus documentation if you want to extend it. >> >> > + { "TxPower", parse_tx_power }, >> >> TxPower is already part of the include, or you want the ability to set >> an arbitrary TxPower? >> >> > { }, >> > }; >> > >> > @@ -1092,6 +1171,13 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client) >> > goto fail; >> > } >> > >> > + if (client->min_interval > client->max_interval) { >> > + /* Min interval must not be bigger than max interval */ >> > + error("MinInterval must be less than MaxInterval (%lu > %lu)", >> > + client->min_interval, client->max_interval); >> > + goto fail; >> > + } >> > + >> > err = refresh_adv(client, add_adv_callback, &client->add_adv_id); >> > if (!err) >> > return NULL; >> > @@ -1167,6 +1253,9 @@ static struct btd_adv_client *client_create(struct btd_adv_manager *manager, >> > >> > client->manager = manager; >> > client->appearance = UINT16_MAX; >> > + client->tx_power = ADV_TX_POWER_NO_PREFERENCE; >> > + client->min_interval = 0; >> > + client->max_interval = 0; >> > >> > return client; >> > >> > -- >> > 2.28.0.618.gf4bc123cb7-goog >> > >> >> >> -- >> Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0JpVDVKeYl+G2gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:22:58 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id KLI+ClKeYl+p6QAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:22:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 0B5154081F; Thu, 17 Sep 2020 01:22:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726397AbgIPXWu (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:22:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbgIPXWs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:22:48 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95D71C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:22:47 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id l17so313390edq.12 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qMsguu8tJLPB5Vgo+RL9WgHX2Yp6h0a1DLW8ySVT02U=; b=AmHXne3YhBQCkkgDfCre4DBbLLDFt/9aqLpqwbv3EX13EmkJWIISxNslkTbNwI0E++ xmKypgK0mzCPBdj4zzrkShsGzaCYPFI4bjp/nUNzLmU7h1eiTEXbjpPQqqdqFUPJardw n/MBBHEFLnr4G+aBI9vUfhmDIVGU1sv2ZiY18= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qMsguu8tJLPB5Vgo+RL9WgHX2Yp6h0a1DLW8ySVT02U=; b=YfsCj/pk5hf1QD9HJvtgNDXAsUdstAi/m4WwSOSSC0hgOICnVclL66Mh4JqMLiVx5S 5huhYWZFcNjbSoNDu0SLlR+CCgY+oS9iUoN+G0pmZG3x7OQjx3ZpL2VjblzaJ5y9srf/ ngjxP03ww1jMHDRWJzAtH+CYnj93a078CIjWYPEIDq17NOA6zFYNqVUPQ1XO8vdkrWHh kp597Wr2D2C5aXA/6CbB4FIZ4cWe+27iGJFKSOAOYixvbA3B+RPKT1M35kIRED3Iw5m5 Pv5jQXJiaA5KKnRqaUGQAz/WnBAtwZ5tMhWr0bMLZoBjjEvQ465wtQh7ti1BERC+vqCb vICw== X-Gm-Message-State: AOAM5320FIwJJMHziHbrvsGxeNdtTUyWG+1JF6WKQuw5Dg+WMXn3U70s iuEYFhg71iqkM5apg3D6O/+K1Jwvh3p5LA== X-Google-Smtp-Source: ABdhPJyEaHne5vptjZFye8ehjHRADcGAWC818ri9PTeA2BoIIsnDoLrSLP3ara1MizQ5fUC/lsdoTA== X-Received: by 2002:a50:fe07:: with SMTP id f7mr31416640edt.173.1600298565174; Wed, 16 Sep 2020 16:22:45 -0700 (PDT) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com. [209.85.221.45]) by smtp.gmail.com with ESMTPSA id r15sm14974237edv.94.2020.09.16.16.22.44 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Sep 2020 16:22:44 -0700 (PDT) Received: by mail-wr1-f45.google.com with SMTP id j2so45579wrx.7 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:22:44 -0700 (PDT) X-Received: by 2002:a5d:574c:: with SMTP id q12mr28880581wrw.253.1600298563795; Wed, 16 Sep 2020 16:22:43 -0700 (PDT) MIME-Version: 1.0 References: <20200813002819.359374-1-sonnysasaka@chromium.org> <CAO271mneguPsiJRNjW44oGEHZSuYof0og9+cHxByqoOntjevYw@mail.gmail.com> <CABBYNZL1jaVfvxAZ0GVEa2A0i_8bw_=ynYPL7z20H0ZkDVF3xA@mail.gmail.com> In-Reply-To: <CABBYNZL1jaVfvxAZ0GVEa2A0i_8bw_=ynYPL7z20H0ZkDVF3xA@mail.gmail.com> From: Sonny Sasaka <sonnysasaka@chromium.org> Date: Wed, 16 Sep 2020 16:22:32 -0700 X-Gmail-Original-Message-ID: <CAO271mmH3r-S-4fDgraQ892JvxbJhwdDsTLKVJMBigm5+aLHfw@mail.gmail.com> Message-ID: <CAO271mmH3r-S-4fDgraQ892JvxbJhwdDsTLKVJMBigm5+aLHfw@mail.gmail.com> Subject: Re: [PATCH BlueZ] checkpatch: Ignore SPDX license tag To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: BlueZ <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.19 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0B5154081F X-Rspamd-UID: 703ea1 Hi Luiz, Thanks for the clarification. Please do ignore this patch then. On Wed, Sep 16, 2020 at 4:05 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Sonny, > > On Wed, Sep 16, 2020 at 3:43 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > > > Dear BlueZ maintainers, > > > > I saw recent patches that BlueZ started adding SPDX license tags to > > file headers. Is this where the convention is going? If so, please > > ignore this patch. > > Yes, it is better that way so we don't have to keep up with the > license on every file and will probably attempt do some automation to > check if SDPX Identifier is proper. > > > On Wed, Aug 12, 2020 at 5:28 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > > > > > BlueZ does not use SPDX license tag on file headers. > > > > > > --- > > > .checkpatch.conf | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/.checkpatch.conf b/.checkpatch.conf > > > index 419733832..72c3529c3 100644 > > > --- a/.checkpatch.conf > > > +++ b/.checkpatch.conf > > > @@ -12,3 +12,4 @@ > > > --ignore PREFER_PACKED > > > --ignore COMMIT_MESSAGE > > > --ignore SSCANF_TO_KSTRTO > > > +--ignore SPDX_LICENSE_TAG > > > -- > > > 2.26.2 > > > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qBlwGVXmYl8ZqgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 06:30:13 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wKioFlXmYl+UhAAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 06:30:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DD971A0B12; Thu, 17 Sep 2020 06:30:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726055AbgIQEaG (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 00:30:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQEaF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 00:30:05 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CD9DC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:30:05 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id y1so602002pgk.8 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+TD3v7UAVWHCDzf41YKy6vU75ZLiejjugH1t0skQm7g=; b=eENsEc4G6T+1dGFQM99qD3a535oJX7lQVb/ptcArLVIJGLPA1gjZV4AncrFLaoVSAO SXiz9i2HeybAa00zSX+EYk4LTvRpPzJsJDy2D9U55N5ARfQtjYKvDIYEet8dTfUZHTBv 1HTMEeF4Tm3xKyNfZhMDviy2MQ9FV8GLPIh+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+TD3v7UAVWHCDzf41YKy6vU75ZLiejjugH1t0skQm7g=; b=EUT043oXnJziOGdxEQZiOuVVDtrcAtJSm4jqNfiqDpBzvZnPavRV9tjK6KWojI1Kf3 YFYqsdsauInayGst1Da5gZtMC4j3NS0tNMQTdR9WaYXrWHmPtu62B5CFjXxzU+dS/aNj 5+GbdpOnkybaabH+K1modtlEPqlo4+PM0XuEAwrEkw//cjC712X1ZWYm32Mnht4Lm2qa zFMJqjz1bkKJ629Op/xTMkiZN2WN8cOORsvb6D+Xi2cdYrTKngGN5AJ9Ftah3BXGM2Wg qpndIrWYgd1nctGfDDbsrchIRB3/4ly1pv+hdOPKFH+RAayvmSfal2WM+jZ0tnHP9k2E R9yg== X-Gm-Message-State: AOAM533FBR1qYZDWnyb1nClyGst1l8gdzvJG0zSTL4u+Lm3QJRANKZ06 YOP2ImdHERFgGRKyukaAzCkDeldNOhMSFg== X-Google-Smtp-Source: ABdhPJxrKVqVJrVrSQUflTu+0JnbbM/yQNkokFDM4CZWBoMN2hJ+YaxncJOMEkIpk4k4bKReGBDryQ== X-Received: by 2002:a05:6a00:14cb:b029:142:2501:34eb with SMTP id w11-20020a056a0014cbb0290142250134ebmr9336088pfu.68.1600317003718; Wed, 16 Sep 2020 21:30:03 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id 99sm4169562pjo.40.2020.09.16.21.30.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 21:30:02 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, chromeos-bluetooth-upstreaming@chromium.org, Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Manish Mandlik <mmandlik@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v1 1/8] adv_monitor: Implement RSSI Filter logic for background scanning Date: Wed, 16 Sep 2020 21:29:45 -0700 Message-Id: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.90 / 15.00 / 15.00 X-Rspamd-Queue-Id: DD971A0B12 X-Rspamd-UID: 747cef From: Manish Mandlik <mmandlik@google.com> This patch implements the RSSI Filter logic for background scanning. This was unit-tested by running tests in unit/test-adv-monitor.c unit/test-adv-monitor.c file. Verified all tests PASS by running: USE="-bluez-next bluez-upstream" FEATURES=test emerge-hatch bluez Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Howard Chung <howardchung@google.com> --- doc/advertisement-monitor-api.txt | 5 + src/adapter.c | 1 + src/adv_monitor.c | 286 +++++++++++++++++++++++++++++- src/adv_monitor.h | 4 + 4 files changed, 292 insertions(+), 4 deletions(-) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index e09b6fd25..92c8ffc38 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -70,6 +70,11 @@ Properties string Type [read-only] dBm indicates unset. The valid range of a timer is 1 to 300 seconds while 0 indicates unset. + If the peer device advertising interval is greater than the + HighRSSIThresholdTimer, the device will never be found. Similarly, + if it is greater than LowRSSIThresholdTimer, the device will be + considered as lost. Consider configuring these values accordingly. + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] If Type is set to 0x01, this must exist and has at least diff --git a/src/adapter.c b/src/adapter.c index b2bd8b3f1..415d6e06b 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -1227,6 +1227,7 @@ void btd_adapter_remove_device(struct btd_adapter *adapter, adapter->connect_list = g_slist_remove(adapter->connect_list, dev); adapter->devices = g_slist_remove(adapter->devices, dev); + btd_adv_monitor_device_remove(adapter->adv_monitor_manager, dev); adapter->discovery_found = g_slist_remove(adapter->discovery_found, dev); diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 737da1c90..7baa5317f 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -35,6 +35,7 @@ #include "adapter.h" #include "dbus-common.h" +#include "device.h" #include "log.h" #include "src/error.h" #include "src/shared/ad.h" @@ -44,6 +45,8 @@ #include "adv_monitor.h" +static void monitor_device_free(void *data); + #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" @@ -104,15 +107,36 @@ struct adv_monitor { enum monitor_state state; /* MONITOR_STATE_* */ - int8_t high_rssi; /* high RSSI threshold */ - uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ - int8_t low_rssi; /* low RSSI threshold */ - uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ + int8_t high_rssi; /* High RSSI threshold */ + uint16_t high_rssi_timeout; /* High RSSI threshold timeout */ + int8_t low_rssi; /* Low RSSI threshold */ + uint16_t low_rssi_timeout; /* Low RSSI threshold timeout */ + struct queue *devices; /* List of adv_monitor_device objects */ enum monitor_type type; /* MONITOR_TYPE_* */ struct queue *patterns; }; +/* Some data like last_seen, timer/timeout values need to be maintained + * per device. struct adv_monitor_device maintains such data. + */ +struct adv_monitor_device { + struct adv_monitor *monitor; + struct btd_device *device; + + time_t high_rssi_first_seen; /* Start time when RSSI climbs above + * the high RSSI threshold + */ + time_t low_rssi_first_seen; /* Start time when RSSI drops below + * the low RSSI threshold + */ + time_t last_seen; /* Time when last Adv was received */ + bool device_found; /* State of the device - lost/found */ + guint device_lost_timer; /* Timer to track if the device goes + * offline/out-of-range + */ +}; + struct app_match_data { const char *owner; const char *path; @@ -159,6 +183,9 @@ static void monitor_free(void *data) g_dbus_proxy_unref(monitor->proxy); g_free(monitor->path); + queue_destroy(monitor->devices, monitor_device_free); + monitor->devices = NULL; + queue_destroy(monitor->patterns, pattern_free); free(monitor); @@ -257,6 +284,7 @@ static struct adv_monitor *monitor_new(struct adv_monitor_app *app, monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->devices = queue_new(); monitor->type = MONITOR_TYPE_NONE; monitor->patterns = NULL; @@ -932,3 +960,253 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) manager_destroy(manager); } + +/* Matches a device based on btd_device object */ +static bool monitor_device_match(const void *a, const void *b) +{ + const struct adv_monitor_device *dev = a; + const struct btd_device *device = b; + + if (!dev) + return false; + + if (dev->device != device) + return false; + + return true; +} + +/* Frees a monitor device object */ +static void monitor_device_free(void *data) +{ + struct adv_monitor_device *dev = data; + + if (!dev) + return; + + if (dev->device_lost_timer) { + g_source_remove(dev->device_lost_timer); + dev->device_lost_timer = 0; + } + + dev->monitor = NULL; + dev->device = NULL; + + g_free(dev); +} + +/* Removes a device from monitor->devices list */ +static void remove_device_from_monitor(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct btd_device *device = user_data; + struct adv_monitor_device *dev = NULL; + + if (!monitor) + return; + + dev = queue_remove_if(monitor->devices, monitor_device_match, device); + if (dev) { + DBG("Device removed from the Adv Monitor at path %s", + monitor->path); + monitor_device_free(dev); + } +} + +/* Removes a device from every monitor in an app */ +static void remove_device_from_app(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + struct btd_device *device = user_data; + + if (!app) + return; + + queue_foreach(app->monitors, remove_device_from_monitor, device); +} + +/* Removes a device from every monitor in all apps */ +void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, + struct btd_device *device) +{ + if (!manager || !device) + return; + + queue_foreach(manager->apps, remove_device_from_app, device); +} + +/* Creates a device object to track the per-device information */ +static struct adv_monitor_device *monitor_device_create( + struct adv_monitor *monitor, + struct btd_device *device) +{ + struct adv_monitor_device *dev = NULL; + + dev = g_try_malloc0(sizeof(struct adv_monitor_device)); + if (!dev) + return NULL; + + dev->monitor = monitor; + dev->device = device; + + queue_push_tail(monitor->devices, dev); + + return dev; +} + +/* Includes found/lost device's object path into the dbus message */ +static void report_device_state_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = device_get_path(user_data); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +/* Handles a situation where the device goes offline/out-of-range */ +static gboolean handle_device_lost_timeout(gpointer user_data) +{ + struct adv_monitor_device *dev = user_data; + struct adv_monitor *monitor = dev->monitor; + time_t curr_time = time(NULL); + + DBG("Device Lost timeout triggered for device %p " + "for the Adv Monitor at path %s", dev->device, monitor->path); + + dev->device_lost_timer = 0; + + if (dev->device_found && dev->last_seen) { + /* We were tracking for the Low RSSI filter. Check if there is + * any Adv received after the timeout function is invoked. + * If not, report the Device Lost event. + */ + if (difftime(curr_time, dev->last_seen) >= + monitor->low_rssi_timeout) { + dev->device_found = false; + + DBG("Calling DeviceLost() on Adv Monitor of owner %s " + "at path %s", monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "DeviceLost", + report_device_state_setup, + NULL, dev->device, NULL); + } + } + + return FALSE; +} + +/* Filters an Adv based on its RSSI value */ +static void adv_monitor_filter_rssi(struct adv_monitor *monitor, + struct btd_device *device, int8_t rssi) +{ + struct adv_monitor_device *dev = NULL; + time_t curr_time = time(NULL); + uint16_t adapter_id = monitor->app->manager->adapter_id; + + /* If the RSSI thresholds and timeouts are not specified, report the + * DeviceFound() event without tracking for the RSSI as the Adv has + * already matched the pattern filter. + */ + if (monitor->high_rssi == ADV_MONITOR_UNSET_RSSI && + monitor->low_rssi == ADV_MONITOR_UNSET_RSSI && + monitor->high_rssi_timeout == ADV_MONITOR_UNSET_TIMER && + monitor->low_rssi_timeout == ADV_MONITOR_UNSET_TIMER) { + DBG("Calling DeviceFound() on Adv Monitor of owner %s " + "at path %s", monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "DeviceFound", + report_device_state_setup, NULL, + device, NULL); + + return; + } + + dev = queue_find(monitor->devices, monitor_device_match, device); + if (!dev) + dev = monitor_device_create(monitor, device); + if (!dev) { + btd_error(adapter_id, "Failed to create Adv Monitor " + "device object."); + return; + } + + if (dev->device_lost_timer) { + g_source_remove(dev->device_lost_timer); + dev->device_lost_timer = 0; + } + + /* Reset the timings of found/lost if a device has been offline for + * longer than the high/low timeouts. + */ + if (dev->last_seen) { + if (difftime(curr_time, dev->last_seen) > + monitor->high_rssi_timeout) { + dev->high_rssi_first_seen = 0; + } + + if (difftime(curr_time, dev->last_seen) > + monitor->low_rssi_timeout) { + dev->low_rssi_first_seen = 0; + } + } + dev->last_seen = curr_time; + + /* Check for the found devices (if the device is not already found) */ + if (!dev->device_found && rssi > monitor->high_rssi) { + if (dev->high_rssi_first_seen) { + if (difftime(curr_time, dev->high_rssi_first_seen) >= + monitor->high_rssi_timeout) { + dev->device_found = true; + + DBG("Calling DeviceFound() on Adv Monitor " + "of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call( + monitor->proxy, "DeviceFound", + report_device_state_setup, NULL, + dev->device, NULL); + } + } else { + dev->high_rssi_first_seen = curr_time; + } + } else { + dev->high_rssi_first_seen = 0; + } + + /* Check for the lost devices (only if the device is already found, as + * it doesn't make any sense to report the Device Lost event if the + * device is not found yet) + */ + if (dev->device_found && rssi < monitor->low_rssi) { + if (dev->low_rssi_first_seen) { + if (difftime(curr_time, dev->low_rssi_first_seen) >= + monitor->low_rssi_timeout) { + dev->device_found = false; + + DBG("Calling DeviceLost() on Adv Monitor " + "of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call( + monitor->proxy, "DeviceLost", + report_device_state_setup, NULL, + dev->device, NULL); + } + } else { + dev->low_rssi_first_seen = curr_time; + } + } else { + dev->low_rssi_first_seen = 0; + } + + /* Setup a timer to track if the device goes offline/out-of-range, only + * if we are tracking for the Low RSSI Threshold. If we are tracking + * the High RSSI Threshold, nothing needs to be done. + */ + if (dev->device_found) { + dev->device_lost_timer = + g_timeout_add_seconds(monitor->low_rssi_timeout, + handle_device_lost_timeout, dev); + } +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 69ea348f8..14508e7d1 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -21,6 +21,7 @@ #define __ADV_MONITOR_H struct mgmt; +struct btd_device; struct btd_adapter; struct btd_adv_monitor_manager; @@ -29,4 +30,7 @@ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct mgmt *mgmt); void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); +void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, + struct btd_device *device); + #endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gCCCAA2fYl8oKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:26:05 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ULvVNwyfYl+4YgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:26:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F2CDDA0161; Thu, 17 Sep 2020 01:25:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726703AbgIPXZy (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbgIPXZw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:25:52 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA90CC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:25:51 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id r9so360498ybd.20 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=5VqPIiOtUqaGVZkI9SNh9ZvqzIGC8rBwWvJX1ib7LmM=; b=Zh+sW3pyztmP7nAARrr1tB6GMmz6Xsxr8sFItA0pQa4bY/xOG5uMHus4fca2t2ciA0 UvywXzjtCMqtb/u3yll4GTmKRzjh94Hd4J+zCjdQzAt3sSCIfd0wiU0iA7MUEGcoFWMW bTyO6jS4ZBP54pZTVLhGyeTiUyIXCm1zn2wC3m3n98lxfFBu3ufni4+YwmYoie08Wp7y 53CgAOLcbw3JQHPDlR/n+zp/p1sTGXsIPUbxWfcaR2+ZCK6XsWkmTg/zZwAH2niFAmIT tN5goGtum1rQi4CjsnFcpK8qfTI7CqGeGpT49EzwLlD9MVKWpPVMCNy5sWbICxBOC09r OUGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=5VqPIiOtUqaGVZkI9SNh9ZvqzIGC8rBwWvJX1ib7LmM=; b=JLlGXX6cgtythW1Jpi1kVBF7ZAWPQwZmxynuHCqbGUhNUl8mzXYqVEgzPZn6Q8m/ZJ E8u9XWuwdiA7e3tDE9kTNCm6Q3mPhRKLQIikbeUTcuCxSYGXHhj9WkYiYWAzFrohWkaE 8zd3FPI041Wvt8TxO+c/N73CJM6900fiv8X+dGg2lxNx3L3CHUfl8s7GZp4te3PF230V 6ep6p0w3gvKzDXYUl5rDbrbh2t+m4jr3KfdTWDa+wD0sRPH2AQ+MBoaV5lPGmKIMZKYa l96a0Jt4ai0d+nBUGGiztICV0VLaInrC1T9BDtCvWaYkgG+b8EJAg6edTZE1AHJs+itU 8Y0w== X-Gm-Message-State: AOAM532yyEdiWPwOoHxqxwzK1pHb1o2/cuoFqgxhM+EU+NkpmU0uKw+K JaAashzRn/MFFJFMiPWTFUsSFAH4vcEhuQ5V7COl X-Google-Smtp-Source: ABdhPJxdHxL3Fk3YvsJQjOTENpu98RPKaJSc4Ng2OVqpLMJCCahrSxHb9Y6w4vq6Pyp6AJQR4qHGNde5NHyv9q17uQNJ X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:5a56:: with SMTP id o83mr34602706ybb.55.1600298751096; Wed, 16 Sep 2020 16:25:51 -0700 (PDT) Date: Wed, 16 Sep 2020 16:25:32 -0700 Message-Id: <20200916232542.1584854-1-danielwinkler@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH 00/10] Bluetooth: Add new MGMT interface for advertising add From: Daniel Winkler <danielwinkler@google.com> To: luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ***** X-Rspamd-Score: 6.10 / 15.00 / 15.00 X-Rspamd-Queue-Id: F2CDDA0161 X-Rspamd-UID: 9e186a Hi Maintainers, This patch series defines the new two-call MGMT interface in userspace for adding advertising instances. Bluez will detect if kernel supports the new MGMT commands, and use them if so. Each new advertising instance will be configured by a MGMT call to set advertising parameters, followed by a MGMT call to set advertising data. The new data pipeline is meant to be unnoticeable from the clients' perspective, with the exception of new intervals and tx power support, and new exposed advertising manager properties. All changes have been tested on hatch (extended advertising) and kukui (no extended advertising) chromebooks with manual testing verifying correctness of parameters/data in btmon traces, and our automated test suite of 25 single- and multi-advertising usage scenarios. Thank you in advance for your review! Daniel Winkler Daniel Winkler (10): advertising: Detect if extended advertising mgmt commands are supported advertising: Parse intervals and tx power from adv advertising: Use new mgmt interface for advertising add advertising: Catch tx power selected event and handle it advertising: Query LE TX range at manager initialization advertising: Expose SupportedCapabilities for advertising client: Add SupportedCapabilities to bluetoothctl monitor: Add new MGMT adv commands and events to monitor doc/advertising-api: update API with new interface doc/mgmt-api: Add new MGMT interfaces to mgmt-api client/main.c | 1 + doc/advertising-api.txt | 50 +++++ doc/mgmt-api.txt | 243 ++++++++++++++++++++ lib/mgmt.h | 45 ++++ monitor/packet.c | 84 +++++++ src/advertising.c | 476 ++++++++++++++++++++++++++++++++++++++-- 6 files changed, 884 insertions(+), 15 deletions(-) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +BI+IBOfYl8oKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:26:11 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 0Gr9HBOfYl/QTgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:26:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 17D4EA0B0B; Thu, 17 Sep 2020 01:26:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbgIPXZ5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbgIPXZy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:25:54 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A2B4C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:25:54 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id a13so201676qvl.6 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:25:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=+huwA4s3GAFhv45nHY4OvTaynBIxEfkWAWQB5QE2L54=; b=uwbghoe4ssspaSoLZHEcVPdKVJc3GC7g1/QIREF/6902DhbhPNUn3bqEfJvLn/RzPE Nhc4eT2WcHSlXATu1DbUD6rUWOX1K62UpRXVMQonKqMCIHhrDOwy+AEuXM1Gd/Dr+k6S D0L6SMAUd4eviI6EzdNQxtoTRaeIkLaFBI26vLaGC4cFqYVCbgNJxEWecm3aFHJvm1wp /HI3amMOSurMbOCXBlQGG4XIOAR9k1Ui3UtQd+CZbHYe/9/SujX4+ramnNZbTBottv1w tKGz0kinQ3pQuBmJAFqnLS2Ig7++ar3xbRo3CN/0p1KlCWpPr9UcKZFLcPT7avmtOgze 0OqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+huwA4s3GAFhv45nHY4OvTaynBIxEfkWAWQB5QE2L54=; b=i1Z6f9Pj2OQbNupj6RgP/yEdsDTCH4xoiBJnHy/ufcn2ecqx0yJx26HC+E9Ez574Rg HzAzGMcKyBtjyLwX6tXdQL9cqF2RZUD+1utgLz1Gkbhx1R30OuD/m6VaM2k8KGOqHj7Y ZDFGLD/y2ssgpKDDzQVP49xoZ2ULgREBLGZLezwWF/XMiHtByyCZw3bt4G+vwcxfNolL TSXXKpDmx1x9dtq+kJtmHLnwUtf2ZcCvvdBFDrPul/x+GgTcA4nf+cGuS8DRf5JCIbM/ 2owf5bz1FWU+winCMjnbZHp4u35M4rQcQeTX1hOD71otCfAxA/foFk2MBoCgM1OFG7VV M+xA== X-Gm-Message-State: AOAM533oJnOUEsFuzKSQ7stJsOMcuiSOlrSebEb4pTP3i0jCmjlVzIrB z6u8jJd7Emfw7YHPSQj9wJ2OMFuhg81YAW2+6sst X-Google-Smtp-Source: ABdhPJwtDxkV5u7l6zrBENrrmQ6NvJBaNyScwtPPsc57GvJrU9AcqdvzPCeZfAKwaDYDSifsU8N6/Ba5GKvOkJKmpvW8 X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a0c:8246:: with SMTP id h64mr9715968qva.54.1600298753081; Wed, 16 Sep 2020 16:25:53 -0700 (PDT) Date: Wed, 16 Sep 2020 16:25:33 -0700 In-Reply-To: <20200916232542.1584854-1-danielwinkler@google.com> Message-Id: <20200916162155.Bluez.1.I50d9faa25e9da6e71d77c83c7d47a5b135e88799@changeid> Mime-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH 01/10] advertising: Detect if extended advertising mgmt commands are supported From: Daniel Winkler <danielwinkler@google.com> To: luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.40 / 15.00 / 15.00 X-Rspamd-Queue-Id: 17D4EA0B0B X-Rspamd-UID: 8bc384 We need to know if kernel supports the new MGMT interface. To do so, we call MGMT_OP_READ_COMMANDS when our manager is created and check if the new commands are available. This will then be used to route our requests for new advertisements. The change is tested by manually verifying that the correct MGMT commands are used when the feature is and is not available in kernel. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- src/advertising.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/advertising.c b/src/advertising.c index e5f25948d..172a83907 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -57,6 +57,7 @@ struct btd_adv_manager { uint8_t max_ads; uint32_t supported_flags; unsigned int instance_bitmap; + bool extended_add_cmds; }; #define AD_TYPE_BROADCAST 0 @@ -1407,6 +1408,51 @@ static void read_adv_features_callback(uint8_t status, uint16_t length, remove_advertising(manager, 0); } +static void read_commands_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct btd_adv_manager *manager = user_data; + const struct mgmt_rp_read_commands *rp = param; + uint16_t num_commands, num_events; + size_t expected_len; + int i; + + if (status != MGMT_STATUS_SUCCESS) { + error("Failed to read supported commands: %s (0x%02x)", + mgmt_errstr(status), status); + return; + } + + if (length < sizeof(*rp)) { + error("Wrong size of read commands response"); + return; + } + + num_commands = btohs(rp->num_commands); + num_events = btohs(rp->num_events); + + expected_len = sizeof(*rp) + num_commands * sizeof(uint16_t) + + num_events * sizeof(uint16_t); + + if (length < expected_len) { + error("Too small reply for supported commands: (%u != %zu)", + length, expected_len); + return; + } + + for (i = 0; i < num_commands; i++) { + uint16_t op = get_le16(rp->opcodes + i); + + switch (op) { + case MGMT_OP_ADD_EXT_ADV_PARAMS: + manager->extended_add_cmds = true; + break; + default: + break; + } + } +} + static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, struct mgmt *mgmt) { @@ -1426,6 +1472,7 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, manager->mgmt_index = btd_adapter_get_index(adapter); manager->clients = queue_new(); manager->supported_flags = MGMT_ADV_FLAG_LOCAL_NAME; + manager->extended_add_cmds = false; if (!g_dbus_register_interface(btd_get_dbus_connection(), adapter_get_path(manager->adapter), @@ -1442,6 +1489,13 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, goto fail; } + /* Determine if kernel supports extended advertising add command. We + * don't care if this request fails, as we will fall back to legacy + * add_advertising by default + */ + mgmt_send(manager->mgmt, MGMT_OP_READ_COMMANDS, MGMT_INDEX_NONE, 0, + NULL, read_commands_complete, manager, NULL); + return manager; fail: -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yHZeJhmfYl8oKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:26:17 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YIjfIxmfYl9LoQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:26:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9CA07A0B17; Thu, 17 Sep 2020 01:26:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726742AbgIPXZ5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726731AbgIPXZ5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:25:57 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37F9DC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:25:56 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id p13so409894ybe.4 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=zx9Y03QWb8BNYfZ72/GnCJ0C/Svhms4y9N7CxG393LA=; b=fZ3CAxTfX2LjadVjg66T+bvLiW5pSHYoRjb1kbL1D6R4rTaXW8vM++LeGGpAYNWwaZ fFL9fnyDzCVNCQBp3jdE9NQwfe61d1QuQ4SMIIuh8MF5HGvGylgByzhEDbz5ABZCepor 5tZI7bbZlXipSUw/KT77E/ZxJQnciLqu/t0v6ZomN81YfhM5bUEkuGc6NGH+bt/Qp8B2 rL4Mei1UIA5D6JFmW7IFTv8cInLR/waqdze8np/B7OInc6E6gwNuFNRQO8PlAYIoVgiA oR+2LQUCZn7CuJI10FFA8gIW32BmC1ylcLFWzvq3WT7suttFLM8RsNph8LC8KMkgV/W+ 54bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=zx9Y03QWb8BNYfZ72/GnCJ0C/Svhms4y9N7CxG393LA=; b=A+dEL5n0/mmbOHxeuIMhwq489kX0nJKpTUTNS7W4d9mgAdJaT5fcBr2Jf9PU4ajm0g n5bQZ0AzJJt8NtHbB5nwV2WVD/5d5QshjvGlTa9Yg0gaPaYfHmMQVXqb8Hg7wHTvwsY7 MYeaN2GHQpDkQ3sRDPxlJS73JxRNxjz92xht6hsFPSSyVms7KgOf1qKWfP6KprX1NlIg DwRgTvKD0OOUFtOxU71t4FAaBm1C4MdgkhzalpPWSZBkrPNY1rNhGrJzOeuBF1O3eHI1 GONJM0/lq2YmlIuuVLW8sEBpuntn+bQM79lKCUCYfaPl7piSfz3Gox0xcrrEKACCvH59 VXkg== X-Gm-Message-State: AOAM531sz6piR+VYGy2CwmPLhv+AZsLND1WldtQe9ZEtkybmVD2+m4eD i/YWlZvro5GBSsrwbA4PO0vbd2g/8IycG2orAu7b X-Google-Smtp-Source: ABdhPJxhB4qjTqAAoBhxpCKngQTIbV+27jBJl34UL4gHdjhcBqywaNiZNm0vu5WtZD43Uw5bOmY/R5XyM5cRpsbA2FoM X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:6c05:: with SMTP id h5mr35164839ybc.433.1600298755450; Wed, 16 Sep 2020 16:25:55 -0700 (PDT) Date: Wed, 16 Sep 2020 16:25:34 -0700 In-Reply-To: <20200916232542.1584854-1-danielwinkler@google.com> Message-Id: <20200916162155.Bluez.2.Ic4a3667da774f5f34477d5168a68a9280657e2da@changeid> Mime-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH 02/10] advertising: Parse intervals and tx power from adv From: Daniel Winkler <danielwinkler@google.com> To: luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9CA07A0B17 X-Rspamd-UID: b6cfba This change adds parsers for the advertising intervals and tx power properties of the LEAdvertisement1 object. It validates that each field adheres to the 5.2 spec, and that min and max intervals are compatible with each other, i.e. that min interval is less than max interval. A note here for maintainers: The tx power that is sent in the hci parameter command is an int8_t, but as far as I can tell, there is no clean way to use a signed 8-bit integer in dbus. The dbus byte type seems incompatible with negative values in high-level languages (python) without awkward usage manipulation on the client side. For this reason, I chose to use an int16_t type for the tx power dbus field, which is then downcasted to the int8_t in bluetoothd, which at least makes the signed-ness of the type crystal clear to the dbus client that uses it. This change is manually verified by ensuring the intervals and tx power parameters are correctly parsed from the LEAdvertisement1 object, and that the parse fails if the parameters are incorrect or not compatible with each other. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- src/advertising.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/src/advertising.c b/src/advertising.c index 172a83907..82ee87313 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -63,6 +63,11 @@ struct btd_adv_manager { #define AD_TYPE_BROADCAST 0 #define AD_TYPE_PERIPHERAL 1 +/* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2585 + * defines tx power value indicating no preference + */ +#define ADV_TX_POWER_NO_PREFERENCE 0x7F + struct btd_adv_client { struct btd_adv_manager *manager; char *owner; @@ -83,6 +88,9 @@ struct btd_adv_client { struct bt_ad *data; struct bt_ad *scan; uint8_t instance; + uint32_t min_interval; + uint32_t max_interval; + int8_t tx_power; }; struct dbus_obj_match { @@ -946,6 +954,74 @@ static bool parse_secondary(DBusMessageIter *iter, return false; } +static bool parse_min_interval(DBusMessageIter *iter, + struct btd_adv_client *client) +{ + if (!iter) + return false; + + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) + return false; + + dbus_message_iter_get_basic(iter, &client->min_interval); + + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2584 + * defines acceptable interval range + */ + if (client->min_interval < 0x20 || client->min_interval > 0xFFFFFF) { + client->min_interval = 0; + return false; + } + + return true; +} + +static bool parse_max_interval(DBusMessageIter *iter, + struct btd_adv_client *client) +{ + if (!iter) + return false; + + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) + return false; + + dbus_message_iter_get_basic(iter, &client->max_interval); + + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2584 + * defines acceptable interval range + */ + if (client->max_interval < 0x20 || client->max_interval > 0xFFFFFF) { + client->max_interval = 0; + return false; + } + + return true; +} + +static bool parse_tx_power(DBusMessageIter *iter, + struct btd_adv_client *client) +{ + int16_t val; + + if (!iter) + return false; + + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INT16) + return false; + + dbus_message_iter_get_basic(iter, &val); + + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2585 + * defines acceptable tx power range + */ + if (val < -127 || val > 20) + return false; + + client->tx_power = val; + + return true; +} + static struct adv_parser { const char *name; bool (*func)(DBusMessageIter *iter, struct btd_adv_client *client); @@ -964,6 +1040,9 @@ static struct adv_parser { { "Discoverable", parse_discoverable }, { "DiscoverableTimeout", parse_discoverable_timeout }, { "SecondaryChannel", parse_secondary }, + { "MinInterval", parse_min_interval }, + { "MaxInterval", parse_max_interval }, + { "TxPower", parse_tx_power }, { }, }; @@ -1092,6 +1171,13 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client) goto fail; } + if (client->min_interval > client->max_interval) { + /* Min interval must not be bigger than max interval */ + error("MinInterval must be less than MaxInterval (%lu > %lu)", + client->min_interval, client->max_interval); + goto fail; + } + err = refresh_adv(client, add_adv_callback, &client->add_adv_id); if (!err) return NULL; @@ -1167,6 +1253,9 @@ static struct btd_adv_client *client_create(struct btd_adv_manager *manager, client->manager = manager; client->appearance = UINT16_MAX; + client->tx_power = ADV_TX_POWER_NO_PREFERENCE; + client->min_interval = 0; + client->max_interval = 0; return client; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gD9CMB+fYl8pKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:26:23 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id IM+SLR+fYl+4YgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:26:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B43F1A01F5; Thu, 17 Sep 2020 01:26:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgIPX0B (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:26:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726731AbgIPX0A (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:26:00 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C24AC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:00 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id r128so99049qkc.9 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=3Gv2h6Y33PNU5maObWHRnY34pFguxERvrCFOTuDaK1I=; b=OlVd74VnuAOjp0KkIozGsSyIwRgXhHSHBQ3Ru+dKUxnl1XvGpZppbQmdpNCn9Zpkyb 57hRTgzG/uws5apQjfgq6H0X5pMlBPSJQjZx2zOU80evDN+P4esfYI1VO3SzojX8Tn5O K4LigxjDz6CGEtj7kztPVUElFrVyggwJ0MTMlUYaoqXLByRyoBtLJfw9bGO3UU04uNBA 7UEXy3e2XND9DsCtg/5DakHbjqHhiKfnUibnD+McM4rGzpXRbltRrcraefZFJ48SaS7N Fd4upvA5tAd20VxKn1duFRhNYCWx/h0/VpnP/Tfajhxjwij+/ElG57RomCll3cjyMv29 Dkqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=3Gv2h6Y33PNU5maObWHRnY34pFguxERvrCFOTuDaK1I=; b=ZnxqfaOJTu0+f92Kn4dzRbubRj90OmUzjZ0tHV9ROsUrBGTOS7y+nJYn8X8ozCwham 9bbBhBeAFNInY7/P1QgJkMC8JV4RHlvgz0c1m4sN6Nb410+4ckgRINVsKHjEIdxh409c QYPnLSmRCQe4a8nhDYXOhfMo8k+o9SBeHBPvgfBtN+Ey7moMrXsgCaB7iGdyAXrNpEEu lumxcD3/1MzT7lZzpDBiNZ7iIQ5Ibe5PxDCWngoZMEbxRG8b4zIljFgFecD1d4jw8pgi ITrMj7AN/Br+60v2u5jCfdKVicxGzxQ5JkVTqxvxFJIUjpQNo79om+9ppfmewuvPHaH/ osmg== X-Gm-Message-State: AOAM532M8ez+cHKEE+G5wgzyIIYd1lqIUwZO6uYSJJsHT5nwVO1linJb 5SzAwfz/Cemxj+EpM/IKYufGroXxrgzaG26HXk+Q X-Google-Smtp-Source: ABdhPJy2cLkZ+qaqTzd2UONEmYJuM5szArdjhG3kchEo9ONpeVZCVd7vR8/hqmrsE9jP1S+nN0/jPmKaN4mTcGc2lGdT X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a0c:8c4c:: with SMTP id o12mr8977581qvb.46.1600298759734; Wed, 16 Sep 2020 16:25:59 -0700 (PDT) Date: Wed, 16 Sep 2020 16:25:36 -0700 In-Reply-To: <20200916232542.1584854-1-danielwinkler@google.com> Message-Id: <20200916162155.Bluez.4.Ia7689bc6f45cf6b8e13a95cd1da4f96fbfc3ac14@changeid> Mime-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH 04/10] advertising: Catch tx power selected event and handle it From: Daniel Winkler <danielwinkler@google.com> To: luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.40 / 15.00 / 15.00 X-Rspamd-Queue-Id: B43F1A01F5 X-Rspamd-UID: 3087f9 The new Tx Power Selected MGMT event will alert bluetoothd that an advertising instance has been assigned a tx power. This is intended to be used to then update the client of their instance's tx power. Towards this goal, this patch does the following: - When adv manager is created, register a handler for tx selected event - On callback, identify the relevant advertising instance, and call for a property set with the new value. If the client exposes this method, it will be called with the new value selected by the controller. To test, I modified the example-advertisement python script to implement the Set dbus method, and verified that it is called after advertisement registration on a device with extended advertising. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- lib/mgmt.h | 6 ++++++ src/advertising.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index 9874be004..97f8dd9b4 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -1002,6 +1002,12 @@ struct mgmt_ev_controller_resume { uint8_t wake_reason; } __packed; +#define MGMT_EV_ADV_TX_POWER_SELECTED 0x002f +struct mgmt_ev_adv_tx_power_selected { + uint8_t instance; + int8_t tx_power; +} __packed; + static const char *mgmt_op[] = { "<0x0000>", "Read Version", diff --git a/src/advertising.c b/src/advertising.c index 008ce0073..0269c9224 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -113,6 +113,17 @@ static bool match_client(const void *a, const void *b) return true; } +static bool match_client_by_instance(const void *a, const void *b) +{ + const struct btd_adv_client *client = a; + const uint8_t *instance = b; + + if (client && client->instance == *instance) + return true; + + return false; +} + static void client_free(void *data) { struct btd_adv_client *client = data; @@ -1673,6 +1684,22 @@ static void read_adv_features_callback(uint8_t status, uint16_t length, remove_advertising(manager, 0); } +static void tx_power_selected(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_ev_adv_tx_power_selected *ev = param; + struct btd_adv_client *client; + struct btd_adv_manager *manager = user_data; + dbus_int16_t tx_power = ev->tx_power; + + client = queue_find(manager->clients, match_client_by_instance, + &ev->instance); + + if (client) + g_dbus_proxy_set_property_basic(client->proxy, "TxPower", + DBUS_TYPE_INT16, &tx_power, NULL, NULL, NULL); +} + static void read_commands_complete(uint8_t status, uint16_t length, const void *param, void *user_data) { @@ -1716,6 +1743,11 @@ static void read_commands_complete(uint8_t status, uint16_t length, break; } } + + if (manager->extended_add_cmds) + mgmt_register(manager->mgmt, MGMT_EV_ADV_TX_POWER_SELECTED, + manager->mgmt_index, tx_power_selected, + manager, NULL); } static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yKDZOiafYl8pKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:26:30 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 4Jg/OCafYl9nwQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:26:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E22E9A0170; Thu, 17 Sep 2020 01:26:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726802AbgIPX0C (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:26:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726764AbgIPX0B (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:26:01 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8EF0C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:00 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id a8so23009pjk.5 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=TTQ8hdC1Cc1dBUroL41pt+qfr8CyeoljaFPSpZe/4mU=; b=NlwDYFKhuolBFJNLXWFmGNSpX4DSBAtdQPiYS8dshvz1nLboi9qVSSOU/dD09nhVVH SRmYxF+L7P2DR13+OM+rkx6Cd8UXwKwhiZ++Mp5xfMASZbz+4KIbm2zfmBBKYoOxb9eS MOXwZvv2l5Ixpt/xjqdrc2NEhYxZ5uKwkNXXS3Oxq0ecZdaDAj9og6VCgQoKjylbPRSa B+601J8XqV9pVdgcXpvg0AHBwvkSdJY2TfsCDO5Z+6dOICNuSG3posG8RtIZ53qlO2M5 iUYyj8ojR8ZeYzcRM6VWv+XDhDWV6C38xn+C41F7gK25pWsOz9BokBeLhxIDheZms8sa KcjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=TTQ8hdC1Cc1dBUroL41pt+qfr8CyeoljaFPSpZe/4mU=; b=VUX6S76jRnem7W2I7FyoSPIuECAdYkZIeesBeC7GYAUD4ja8fZRo4HnMvvC8LqxBUb 3mLaWF30GrEjROUxxGxAwyGx0asR4L1Jw9SER5s8xqOHGjvRgdWZfeON+tNFVcRSjfNu b9MJONsVTS9VKdvGXFZ7i0dBUlLjkZDlmnGIZlww+JSYIQV/o8+J1+qXoa6F/wmQSzU0 NB3DfDZLB0faR91Ej3uinMwVyLU0ciLYkTJG16gabRy41iQ4/5MnW4zsFHoIOcOqOYRn 0/zXAUGE44//1nJjZbnMvN5Dw30s9Br41B32fTkphlC6bDpory3ic/iyl/zgn1ZnSq17 3ucA== X-Gm-Message-State: AOAM533MJ9ZlDVsPVqYvXSpzTJAlTvTWH/06p6QntY0zF9bN3AcPalwu W2/sWEQl601bcCEBfA16X+Ov3m5zKLa9BA14IxJG X-Google-Smtp-Source: ABdhPJwfZWuiJoT8d8yXLdUrOupjdZbYfIHLw28sSAsHORF1HFKHe9SdYWF1+OpPQ1nuPBx4kbNXOzVttoteNlV+buuO X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a17:90a:db0f:: with SMTP id g15mr6002943pjv.145.1600298757562; Wed, 16 Sep 2020 16:25:57 -0700 (PDT) Date: Wed, 16 Sep 2020 16:25:35 -0700 In-Reply-To: <20200916232542.1584854-1-danielwinkler@google.com> Message-Id: <20200916162155.Bluez.3.Ia49df7ccded97ceb4ff1d1b0decc49d03d088a84@changeid> Mime-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH 03/10] advertising: Use new mgmt interface for advertising add From: Daniel Winkler <danielwinkler@google.com> To: luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: E22E9A0170 X-Rspamd-UID: 7120b2 This patch allows bluetoothd to use the new extended advertising add mgmt interface if it is available. The new interface will be used by default, as it allows the client to set advertising intervals, and tx power if the controller and kernel support extended advertising. Each new registered advertisement will submit two requests to kernel; the first sets the advertising parameters for the advertising instance, and the second sets the advertising data and scan response for the instance. This change has been tested extensively on Hatch (extended advertising) and Kukui (no extended advertising) chromebooks. Manual tests do the following: - Configure advertisement with custom intervals, tx power with valid and invalid values and combinations - Ensure that with valid parameters, they are propagated and set in hci requests. With invalid parameters, ensure that the registration fails. Automatic tests verify 25 advertising usage scenarios involving single and multi-advertising registration, over-registration, parameter validation, etc. These tests don't test new intervals and tx power, but validate that the new MGMT interface does not regress compatibility in these 25 scenarios. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- lib/mgmt.h | 31 +++++++ src/advertising.c | 208 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 224 insertions(+), 15 deletions(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index 46d894ae9..9874be004 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -713,6 +713,37 @@ struct mgmt_rp_remove_adv_monitor { uint16_t monitor_handle; } __packed; +#define MGMT_ADV_PARAM_DURATION (1 << 0) +#define MGMT_ADV_PARAM_TIMEOUT (1 << 1) +#define MGMT_ADV_PARAM_INTERVALS (1 << 2) +#define MGMT_ADV_PARAM_TX_POWER (1 << 3) + +#define MGMT_OP_ADD_EXT_ADV_PARAMS 0x0054 +struct mgmt_cp_add_ext_adv_params { + uint8_t instance; + uint32_t flags; + uint16_t params; + uint16_t duration; + uint16_t timeout; + uint32_t min_interval; + uint32_t max_interval; + int8_t tx_power; +} __packed; +struct mgmt_rp_add_ext_adv_params { + uint8_t instance; +} __packed; + +#define MGMT_OP_ADD_EXT_ADV_DATA 0x0055 +struct mgmt_cp_add_ext_adv_data { + uint8_t instance; + uint8_t adv_data_len; + uint8_t scan_rsp_len; + uint8_t data[0]; +} __packed; +struct mgmt_rp_add_ext_adv_data { + uint8_t instance; +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { uint16_t opcode; diff --git a/src/advertising.c b/src/advertising.c index 82ee87313..008ce0073 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -91,6 +91,7 @@ struct btd_adv_client { uint32_t min_interval; uint32_t max_interval; int8_t tx_power; + mgmt_request_func_t refresh_done_func; }; struct dbus_obj_match { @@ -797,19 +798,9 @@ static uint8_t *generate_scan_rsp(struct btd_adv_client *client, return bt_ad_generate(client->scan, len); } -static int refresh_adv(struct btd_adv_client *client, mgmt_request_func_t func, - unsigned int *mgmt_id) +static int get_adv_flags(struct btd_adv_client *client) { - struct mgmt_cp_add_advertising *cp; - uint8_t param_len; - uint8_t *adv_data; - size_t adv_data_len; - uint8_t *scan_rsp; - size_t scan_rsp_len = -1; uint32_t flags = 0; - unsigned int mgmt_ret; - - DBG("Refreshing advertisement: %s", client->path); if (client->type == AD_TYPE_PERIPHERAL) { flags = MGMT_ADV_FLAG_CONNECTABLE; @@ -821,6 +812,26 @@ static int refresh_adv(struct btd_adv_client *client, mgmt_request_func_t func, flags |= client->flags; + return flags; +} + +static int refresh_legacy_adv(struct btd_adv_client *client, + mgmt_request_func_t func, + unsigned int *mgmt_id) +{ + struct mgmt_cp_add_advertising *cp; + uint8_t param_len; + uint8_t *adv_data; + size_t adv_data_len; + uint8_t *scan_rsp; + size_t scan_rsp_len = -1; + uint32_t flags = 0; + unsigned int mgmt_ret; + + DBG("Refreshing advertisement: %s", client->path); + + flags = get_adv_flags(client); + adv_data = generate_adv_data(client, &flags, &adv_data_len); if (!adv_data || (adv_data_len > calc_max_adv_len(client, flags))) { error("Advertising data too long or couldn't be generated."); @@ -873,6 +884,76 @@ static int refresh_adv(struct btd_adv_client *client, mgmt_request_func_t func, return 0; } +static void add_adv_params_callback(uint8_t status, uint16_t length, + const void *param, void *user_data); + +static int refresh_extended_adv(struct btd_adv_client *client, + mgmt_request_func_t func, unsigned int *mgmt_id) +{ + struct mgmt_cp_add_ext_adv_params cp; + uint32_t flags = 0; + uint16_t included_params = 0; + unsigned int mgmt_ret = 0; + + DBG("Refreshing advertisement parameters: %s", client->path); + + flags = get_adv_flags(client); + + memset(&cp, 0, sizeof(cp)); + cp.flags = htobl(flags); + cp.instance = client->instance; + + /* Not all advertising instances will use all possible parameters. The + * included_params bit field tells the kernel which parameters are + * relevant, and sensible defaults will be used for the rest + */ + + if (client->duration) { + cp.duration = client->duration; + included_params |= MGMT_ADV_PARAM_DURATION; + } + + if (client->min_interval && client->max_interval) { + cp.min_interval = client->min_interval; + cp.max_interval = client->max_interval; + included_params |= MGMT_ADV_PARAM_INTERVALS; + } + + if (client->tx_power != ADV_TX_POWER_NO_PREFERENCE) { + cp.tx_power = client->tx_power; + included_params |= MGMT_ADV_PARAM_TX_POWER; + } + + cp.params = included_params; + + mgmt_ret = mgmt_send(client->manager->mgmt, MGMT_OP_ADD_EXT_ADV_PARAMS, + client->manager->mgmt_index, sizeof(cp), &cp, + add_adv_params_callback, client, NULL); + + if (!mgmt_ret) { + error("Failed to request extended advertising parameters"); + return -EINVAL; + } + + /* Store callback, called after we set advertising data */ + client->refresh_done_func = func; + + if (mgmt_id) + *mgmt_id = mgmt_ret; + + + return 0; +} + +static int refresh_advertisement(struct btd_adv_client *client, + mgmt_request_func_t func, unsigned int *mgmt_id) +{ + if (client->manager->extended_add_cmds) + return refresh_extended_adv(client, func, mgmt_id); + + return refresh_legacy_adv(client, func, mgmt_id); +} + static gboolean client_discoverable_timeout(void *user_data) { struct btd_adv_client *client = user_data; @@ -883,7 +964,7 @@ static gboolean client_discoverable_timeout(void *user_data) bt_ad_clear_flags(client->data); - refresh_adv(client, NULL, NULL); + refresh_advertisement(client, NULL, NULL); return FALSE; } @@ -1057,7 +1138,8 @@ static void properties_changed(GDBusProxy *proxy, const char *name, continue; if (parser->func(iter, client)) { - refresh_adv(client, NULL, NULL); + refresh_advertisement(client, NULL, NULL); + break; } } @@ -1120,6 +1202,96 @@ done: add_client_complete(client, status); } +static void add_adv_params_callback(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct btd_adv_client *client = user_data; + const struct mgmt_rp_add_ext_adv_params *rp = param; + struct mgmt_cp_add_ext_adv_data *cp; + uint8_t param_len; + uint8_t *adv_data; + size_t adv_data_len; + uint8_t *scan_rsp; + size_t scan_rsp_len = -1; + uint32_t flags = 0; + unsigned int mgmt_ret; + + if (status) + goto fail; + + if (!param || length < sizeof(*rp)) { + status = MGMT_STATUS_FAILED; + goto fail; + } + + DBG("Refreshing advertisement data: %s", client->path); + + client->instance = rp->instance; + + flags = get_adv_flags(client); + + adv_data = generate_adv_data(client, &flags, &adv_data_len); + if (!adv_data || (adv_data_len > calc_max_adv_len(client, flags))) { + error("Advertising data too long or couldn't be generated."); + status = -EINVAL; + goto fail; + } + + scan_rsp = generate_scan_rsp(client, &flags, &scan_rsp_len); + if (!scan_rsp && scan_rsp_len) { + error("Scan data couldn't be generated."); + free(adv_data); + status = -EINVAL; + goto fail; + } + + param_len = sizeof(struct mgmt_cp_add_advertising) + adv_data_len + + scan_rsp_len; + + cp = malloc0(param_len); + if (!cp) { + error("Couldn't allocate for MGMT!"); + free(adv_data); + free(scan_rsp); + status = -EINVAL; + goto fail; + } + + cp->instance = client->instance; + cp->adv_data_len = adv_data_len; + cp->scan_rsp_len = scan_rsp_len; + memcpy(cp->data, adv_data, adv_data_len); + memcpy(cp->data + adv_data_len, scan_rsp, scan_rsp_len); + + free(adv_data); + free(scan_rsp); + + /* Submit request to update instance data */ + mgmt_ret = mgmt_send(client->manager->mgmt, MGMT_OP_ADD_EXT_ADV_DATA, + client->manager->mgmt_index, param_len, cp, + client->refresh_done_func, client, NULL); + + /* Clear the callback */ + client->refresh_done_func = NULL; + + if (!mgmt_ret) { + error("Failed to add Advertising Data"); + free(cp); + status = -EINVAL; + goto fail; + } + + if (client->add_adv_id) + client->add_adv_id = mgmt_ret; + + free(cp); + return; + +fail: + /* Failure for any reason ends this advertising request */ + add_client_complete(client, status); +} + static DBusMessage *parse_advertisement(struct btd_adv_client *client) { struct adv_parser *parser; @@ -1178,7 +1350,9 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client) goto fail; } - err = refresh_adv(client, add_adv_callback, &client->add_adv_id); + err = refresh_advertisement(client, add_adv_callback, + &client->add_adv_id); + if (!err) return NULL; @@ -1257,6 +1431,8 @@ static struct btd_adv_client *client_create(struct btd_adv_manager *manager, client->min_interval = 0; client->max_interval = 0; + client->refresh_done_func = NULL; + return client; fail: @@ -1624,7 +1800,9 @@ void btd_adv_manager_destroy(struct btd_adv_manager *manager) static void manager_refresh(void *data, void *user_data) { - refresh_adv(data, user_data, NULL); + struct btd_adv_client *client = data; + + refresh_advertisement(client, user_data, NULL); } void btd_adv_manager_refresh(struct btd_adv_manager *manager) -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UDgIBi2fYl8pKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:26:37 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QMfSAi2fYl/YEAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:26:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 13C82A0170; Thu, 17 Sep 2020 01:26:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726373AbgIPX0F (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726764AbgIPX0C (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:26:02 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61FB2C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:02 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id v3so386271yba.12 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=RDn4qmzaK+DPbn7H086U+3kMev3mJs6C/TacCte6F1o=; b=ZrQUzovlfLclHjijnf3c0MwYzd7EtyV1jNyxR97xAwpM1zKcq5it0WwVwUtVoJWy7z 9ep4Ds97ODBev9BUViAomluXpjLP2Lxgf6DiIQ4BM74rp791inS5F9UiJFjMSWql7zkA C2SIgSFHjHPyYixcdOvjuGbA64IAkclxir89T0hMz/qahu8PDHj/2sereroYi2t8+02q +mA5PSRgktoyQzl6nKISOodxWGyrkYFlNQeBDe1bUC32r9oKlybxC4ryUeHXs6QNUha6 502M0jwfUStjmHCzVwf3yha/xRojV1Dgc37YbcUKy1GqLNpPakHN9UaOEkkWEIG3h/QK ahkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=RDn4qmzaK+DPbn7H086U+3kMev3mJs6C/TacCte6F1o=; b=AJLxK6B1kqxCKsc3Hn+F1sRpN8CW95NQFvMAYqb+8jrK9l0d1ymGO/gGJCVQeSaZEb zV2dTi+bTP7+OZf0iHtGL1KzXRdGLvIWgbPk49toq6PSfJG9qugAZdQ/pcGG9sMiHR26 nhWOwvzIQXBKn3/VTnc5axp8v3w/Obh+hwCYngSNrBgnzBGwNa/Uk38YRNBX7DmJukqQ 6NFtmhy858tZXgSOjtuSjbIUToI9DvaIzpufPDfee11aRx413u+JB2gElFs3Qlnw8U+X 7B7qGmB8UUgK0VsT53eIS/ACK4PfgvgW4S+4nMi9oqmT8N+0a/M6KtlDPfS38H7Py0bq v83A== X-Gm-Message-State: AOAM531G+crXUrsvA5gOT3GtZROli7yNS12FLEg8euj2XMHD2T7YBl64 KucNqXw/OQF1TJ+L+LbPFp93bKi/0pb6KIrhnLBq X-Google-Smtp-Source: ABdhPJxYBlMUSl2gGaVuCpcMYKztsQYUb9Ky1V8qms2lZouU442XpUqu67XjDaxG2BCMJZw/xTlCctN/RbMseeu1P7Va X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:3585:: with SMTP id c127mr8325177yba.374.1600298761623; Wed, 16 Sep 2020 16:26:01 -0700 (PDT) Date: Wed, 16 Sep 2020 16:25:37 -0700 In-Reply-To: <20200916232542.1584854-1-danielwinkler@google.com> Message-Id: <20200916162155.Bluez.5.I187f71748b9bd93f6bf97ec4a195216109c3ea06@changeid> Mime-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH 05/10] advertising: Query LE TX range at manager initialization From: Daniel Winkler <danielwinkler@google.com> To: luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: 13C82A0170 X-Rspamd-UID: aa7699 This patch calls the new MGMT command to get controller capabilities, and parses the min and max LE tx power range when the manager is initialized. This will be used to populate a client-facing dbus entry so that the client will know the advertising capabilities of the controller before registering an advertisement. This patch is tested by manually verifying the data is parsed correctly from the MGMT response. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- lib/mgmt.h | 8 +++++++ src/advertising.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index 97f8dd9b4..dbabb513f 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -744,6 +744,14 @@ struct mgmt_rp_add_ext_adv_data { uint8_t instance; } __packed; +#define MGMT_CAP_LE_TX_PWR_MIN 0x0001 +#define MGMT_CAP_LE_TX_PWR_MAX 0x0002 + +#define MGMT_OP_READ_CONTROLLER_CAP 0x0056 +struct mgmt_rp_read_controller_cap { + uint8_t capabilities[0]; /* mgmt_tlv */ +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { uint16_t opcode; diff --git a/src/advertising.c b/src/advertising.c index 0269c9224..02aa11934 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -58,6 +58,8 @@ struct btd_adv_manager { uint32_t supported_flags; unsigned int instance_bitmap; bool extended_add_cmds; + int8_t min_tx_power; + int8_t max_tx_power; }; #define AD_TYPE_BROADCAST 0 @@ -1750,6 +1752,54 @@ static void read_commands_complete(uint8_t status, uint16_t length, manager, NULL); } +static void read_controller_cap_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct btd_adv_manager *manager = user_data; + const uint8_t *ptr = param; + uint16_t offset = 0; + + /* Both capabilities we care about are stored as int8_t. If we later + * want to track other types, this structure will need to change + */ + const struct { + struct mgmt_tlv entry; + int8_t value; + } __packed * cap; + + while (offset < length) { + /* Since TLV entries can have variable length, offset tracks how + * far into the member we are, so that cap is always pointing + * to the beginning of a valid struct + */ + cap = (void *)&ptr[offset]; + switch (cap->entry.type) { + case MGMT_CAP_LE_TX_PWR_MIN: + if (cap->entry.length != + sizeof(manager->min_tx_power)) { + error("TX power had unexpected length %d", + cap->entry.length); + break; + } + memcpy(&manager->min_tx_power, &cap->value, + cap->entry.length); + break; + case MGMT_CAP_LE_TX_PWR_MAX: + if (cap->entry.length != + sizeof(manager->min_tx_power)) { + error("TX power had unexpected length %d", + cap->entry.length); + break; + } + memcpy(&manager->max_tx_power, &cap->value, + cap->entry.length); + break; + } + + offset += sizeof(cap->entry) + cap->entry.length; + } +} + static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, struct mgmt *mgmt) { @@ -1770,6 +1820,8 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, manager->clients = queue_new(); manager->supported_flags = MGMT_ADV_FLAG_LOCAL_NAME; manager->extended_add_cmds = false; + manager->min_tx_power = ADV_TX_POWER_NO_PREFERENCE; + manager->max_tx_power = ADV_TX_POWER_NO_PREFERENCE; if (!g_dbus_register_interface(btd_get_dbus_connection(), adapter_get_path(manager->adapter), @@ -1793,6 +1845,13 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, mgmt_send(manager->mgmt, MGMT_OP_READ_COMMANDS, MGMT_INDEX_NONE, 0, NULL, read_commands_complete, manager, NULL); + /* Query controller capabilities. This will be used to display valid + * advertising tx power range to the client. + */ + mgmt_send(manager->mgmt, MGMT_OP_READ_CONTROLLER_CAP, + manager->mgmt_index, 0, NULL, + read_controller_cap_complete, manager, NULL); + return manager; fail: -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aNXqCTOfYl8pKAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 01:26:43 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mD9nBzOfYl9nlQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 01:26:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3111AA0B10; Thu, 17 Sep 2020 01:26:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726764AbgIPX0F (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 16 Sep 2020 19:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgIPX0E (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 16 Sep 2020 19:26:04 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4724EC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:04 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id g189so389018ybg.9 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 16:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=gLuLjClfnxVK5qrLMV6N0yEMaNbvlz3r2lsErbvwRmM=; b=NzopJ8vmUcd4umxiXHqIoXJOUPhjs8z6IyuvpxHLydN8ltvQqj3a87Mp6j+voWuEZB rmdxdQpPwMaD5wrPpxBiPiE6feJrgDwXN5X8toVCPHaYILmhlcIqE2VnkRIt29WhcLpq tMv+85aEeYzHRuvBhqoa5aUu27WENKif9S3VtYjx5Izj5qNYyQ1SWtZhhb6pwmMN+eeX rfVbM2rff7PH553UnIPI9LBCy4MfoGSPmsq13G7GT17tIYBxFEPP3tPd2ywq9/05z//c WZDkMZC6uJTYI2dwA+MsEkBQJu9PejNW0bPp3G3MMXMRZm3zTIYaNMhPgevxnhZQqirK J5GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gLuLjClfnxVK5qrLMV6N0yEMaNbvlz3r2lsErbvwRmM=; b=dG3ErB+OVswD77+onlfnslDK28Q0bZai2NDPA0veAdRVoYGaAOlyoMh1Z0R9KwFmXK RC2Qyks7xMG0gh9nC4qIN831SJgVJ9HBZTRQr4ZT2qf/h6BesAq7SECY2IUaa3fXZxAQ EyX+6ZSt65kAgkX4WALYr1K7XCnYzxGbM81BVDlezHnID+nK1kNKERDHOGVOvUFF0YU9 vuufFymr15hacEqQLI9Lrx6+1KRgKBnsEn1A3ysYamT0II8nd4WA0uGuuXIF0RkUUR8J Bn/j2Lvc7N553Pt7Ewame4ZiG/SZBSLd/Kwq9h7hv3xLP0tKQIiRdP0fIqIoeguzLmhN mWvg== X-Gm-Message-State: AOAM533knfxD+QFUNHxvacQ4uX60TPNDbajF0P3mCDKpJhqQldzoVfPE hw/Kw1clAdVfLqFOpw/ZysSOlpfcKuArsE+DB7NR X-Google-Smtp-Source: ABdhPJwmQlIQLlRdgxNjGJru8bJiaFcDYpzwIOP1A9ZgkoFRWh5b6HAuz+FTESFXl/y6aBgVnvIbmLPg1224CDt0WkNm X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:ab2b:: with SMTP id u40mr41014451ybi.496.1600298763531; Wed, 16 Sep 2020 16:26:03 -0700 (PDT) Date: Wed, 16 Sep 2020 16:25:38 -0700 In-Reply-To: <20200916232542.1584854-1-danielwinkler@google.com> Message-Id: <20200916162155.Bluez.6.I4e536cf2c9b6c5571b4b3800dfb8338fce8e4421@changeid> Mime-Version: 1.0 References: <20200916232542.1584854-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [Bluez PATCH 06/10] advertising: Expose SupportedCapabilities for advertising From: Daniel Winkler <danielwinkler@google.com> To: luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.55 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3111AA0B10 X-Rspamd-UID: 72fd84 To help our advertising clients understand the device capabilities, this patch adds a SupportedCapabilities dbus endpoint for the advertising manager. The primary reason behind this is to provide the valid LE tx power range the controller supports (populated if controller supports BT5), so a client can know the valid power range before requesting a tx power for their advertisement. I also thought it would be useful to indicate the max advertising data length and scan response length in this endpoint, since some clients will find it useful to set their advertising data (currently experimental feature) or scan response data (possible future feature) directly. This patch has been tested on Hatch (BT5 support) and Kukui (No BT5 support) chromebooks to verify that the dbus endpoint contains the correct data. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> --- lib/mgmt.h | 4 ++-- src/advertising.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index dbabb513f..5f752ecd5 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -744,8 +744,8 @@ struct mgmt_rp_add_ext_adv_data { uint8_t instance; } __packed; -#define MGMT_CAP_LE_TX_PWR_MIN 0x0001 -#define MGMT_CAP_LE_TX_PWR_MAX 0x0002 +#define MGMT_CAP_LE_TX_PWR_MIN 0x0000 +#define MGMT_CAP_LE_TX_PWR_MAX 0x0001 #define MGMT_OP_READ_CONTROLLER_CAP 0x0056 struct mgmt_rp_read_controller_cap { diff --git a/src/advertising.c b/src/advertising.c index 02aa11934..df7436b1d 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -1624,12 +1624,46 @@ static gboolean get_supported_secondary(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_supported_cap(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct btd_adv_manager *manager = data; + DBusMessageIter dict; + int16_t min_tx_power = manager->min_tx_power; + int16_t max_tx_power = manager->max_tx_power; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, + &dict); + + if (min_tx_power != ADV_TX_POWER_NO_PREFERENCE) + dict_append_entry(&dict, "MinTxPower", DBUS_TYPE_INT16, + &min_tx_power); + + if (max_tx_power != ADV_TX_POWER_NO_PREFERENCE) + dict_append_entry(&dict, "MaxTxPower", DBUS_TYPE_INT16, + &max_tx_power); + + dict_append_entry(&dict, "MaxAdvLen", DBUS_TYPE_BYTE, + &manager->max_adv_len); + dict_append_entry(&dict, "MaxScnRspLen", DBUS_TYPE_BYTE, + &manager->max_scan_rsp_len); + + dbus_message_iter_close_container(iter, &dict); + + return TRUE; +} + static const GDBusPropertyTable properties[] = { { "ActiveInstances", "y", get_active_instances, NULL, NULL }, { "SupportedInstances", "y", get_instances, NULL, NULL }, { "SupportedIncludes", "as", get_supported_includes, NULL, NULL }, { "SupportedSecondaryChannels", "as", get_supported_secondary, NULL, secondary_exits }, + { "SupportedCapabilities", "a{sv}", get_supported_cap, NULL, NULL}, { } }; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IH1+AmbmYl/RYAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 06:30:30 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id eAbnOmXmYl+rlgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 06:30:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 73E4FA0B55; Thu, 17 Sep 2020 06:30:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726072AbgIQEaX (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 00:30:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQEaW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 00:30:22 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25F79C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:30:22 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id z18so429105pfg.0 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tvB+lIaE0kyS699vcytQm7GY0BeMARJCH099CoEsjEE=; b=a3Rqeux033TBeasa3hhzqcjCNTQUbpIJuFdaCYxgpl4khhXi6lvp1XJSR204KQOxmk OSS4VDOiW5fH4IbpmnEtkXmiu5zk0/1KwceoptWkxt7NB1tSJbcxC6EvWnsxKyGUif0l HnFPO1NpeT72ms6foatrIUd4p8AjXc0RI8PGw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tvB+lIaE0kyS699vcytQm7GY0BeMARJCH099CoEsjEE=; b=o6MK9PgT+mYZG3JEhAMAYI0R+gHz2RPWDxj/0MGP3n2dFxeYtkMjs6GJr1HyILwrQH KjCd4S8n2Rd0Gs/0Jq82OUTA7W99uQyl5Cx4nx2stKIlsXaHQ+SQ6Rao9Svi3eWttxHo bGPxg60MyjI/0Tf+k0FYkN5d9/mJzuD0faJ0oco57Vs8B4hogVHZBuohzqCMIMKzco/y 7gwWdV71+2CjMjK2Uh/Q8uPayCFlaDrnPaC1YWHsZGRfcsv9w/x+MpBqhN1uBtIn4pCA U+g8SXO1/5zpxzM4DUDbkvQ2pqUZddg6IdGVuZpFNrnsVVNl6sWfHfpgc7GaV1IREux7 qitg== X-Gm-Message-State: AOAM530XKLY7P6pyx6rmUH8TASpYGVakUP7o1Qap2/NEu29rdKmIwCHo lvACeSiC+fes1b7pczAdPpfjMSzdHdIUAw== X-Google-Smtp-Source: ABdhPJxwEKqSORsR0MNUrLepJRmSjdc9TMWq3pyjP/03TB3pcwNy1kdPE2NWI3KRRukcQCrBJNQJdA== X-Received: by 2002:a05:6a00:7ce:b029:142:2501:35ea with SMTP id n14-20020a056a0007ceb0290142250135eamr9693939pfu.74.1600317021032; Wed, 16 Sep 2020 21:30:21 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id 99sm4169562pjo.40.2020.09.16.21.30.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 21:30:20 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, chromeos-bluetooth-upstreaming@chromium.org, Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Manish Mandlik <mmandlik@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v1 2/8] adv_monitor: Implement unit tests for RSSI Filter Date: Wed, 16 Sep 2020 21:29:47 -0700 Message-Id: <20200916212926.BlueZ.v1.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.52 / 15.00 / 15.00 X-Rspamd-Queue-Id: 73E4FA0B55 X-Rspamd-UID: 933483 From: Manish Mandlik <mmandlik@google.com> This patch implements unit tests for the background scanning RSSI Filtering logic. Verified all tests PASS by running tests in unit/test-adv-monitor.c USE="-bluez-next bluez-upstream" FEATURES=test emerge-hatch bluez Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Makefile.am | 9 + doc/test-coverage.txt | 3 +- src/adv_monitor.c | 79 ++++++++ src/adv_monitor.h | 10 + unit/test-adv-monitor.c | 391 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 491 insertions(+), 1 deletion(-) create mode 100644 unit/test-adv-monitor.c diff --git a/Makefile.am b/Makefile.am index 22b4fa30c..6918f02b0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -527,6 +527,15 @@ unit_test_gattrib_LDADD = lib/libbluetooth-internal.la \ src/libshared-glib.la \ $(GLIB_LIBS) $(DBUS_LIBS) -ldl -lrt +unit_tests += unit/test-adv-monitor + +unit_test_adv_monitor_SOURCES = unit/test-adv-monitor.c \ + src/adv_monitor.h src/adv_monitor.c \ + src/device.h src/device.c \ + src/log.h src/log.c +unit_test_adv_monitor_LDADD = gdbus/libgdbus-internal.la \ + src/libshared-glib.la $(GLIB_LIBS) $(DBUS_LIBS) + if MIDI unit_tests += unit/test-midi unit_test_midi_CPPFLAGS = $(AM_CPPFLAGS) $(ALSA_CFLAGS) -DMIDI_TEST diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt index 741492a3e..5296983e6 100644 --- a/doc/test-coverage.txt +++ b/doc/test-coverage.txt @@ -30,8 +30,9 @@ test-gobex-transfer 36 OBEX transfer handling test-gdbus-client 13 D-Bus client handling test-gatt 180 GATT qualification test cases test-hog 6 HID Over GATT qualification test cases +test-adv-monitor 5 Advertisement Monitor test cases ----- - 761 + 766 Automated end-to-end testing diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 7baa5317f..046f5953f 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -1210,3 +1210,82 @@ static void adv_monitor_filter_rssi(struct adv_monitor *monitor, handle_device_lost_timeout, dev); } } + +/* Creates the dummy adv_monitor object for unit tests */ +void *btd_adv_monitor_rssi_test_setup(int8_t high_rssi, uint16_t high_timeout, + int8_t low_rssi, uint16_t low_timeout) +{ + struct adv_monitor *test_monitor = NULL; + + test_monitor = g_new0(struct adv_monitor, 1); + if (!test_monitor) + return NULL; + + test_monitor->app = g_new0(struct adv_monitor_app, 1); + if (!test_monitor->app) + goto app_failed; + + test_monitor->app->manager = g_new0(struct btd_adv_monitor_manager, 1); + if (!test_monitor->app->manager) + goto manager_failed; + + test_monitor->high_rssi = high_rssi; + test_monitor->high_rssi_timeout = high_timeout; + test_monitor->low_rssi = low_rssi; + test_monitor->low_rssi_timeout = low_timeout; + test_monitor->devices = queue_new(); + + return test_monitor; + +manager_failed: + g_free(test_monitor->app); + +app_failed: + g_free(test_monitor); + + return NULL; +} + +/* Cleanup after unit test is done */ +void btd_adv_monitor_rssi_test_teardown(void *monitor_obj) +{ + struct adv_monitor *monitor = monitor_obj; + + if (!monitor) + return; + + queue_destroy(monitor->devices, monitor_device_free); + g_free(monitor); +} + +/* Returns the current state of device - found/lost, used in unit tests */ +bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj) +{ + struct adv_monitor *monitor = monitor_obj; + struct btd_device *device = device_obj; + struct adv_monitor_device *dev = NULL; + + if (!monitor || !device) + return false; + + dev = queue_find(monitor->devices, monitor_device_match, device); + if (!dev) + return false; + + return dev->device_found; +} + +/* Helper function for the RSSI Filter unit tests */ +bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, + int8_t adv_rssi) +{ + struct adv_monitor *monitor = monitor_obj; + struct btd_device *device = device_obj; + + if (!monitor || !device) + return false; + + adv_monitor_filter_rssi(monitor, device, adv_rssi); + + return btd_adv_monitor_test_device_state(monitor, device); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 14508e7d1..351e7f9aa 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -33,4 +33,14 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, struct btd_device *device); +/* Following functions are the helper functions used for RSSI Filter unit tests + * defined in unit/test-adv-monitor.c + */ +void *btd_adv_monitor_rssi_test_setup(int8_t high_rssi, uint16_t high_timeout, + int8_t low_rssi, uint16_t low_timeout); +void btd_adv_monitor_rssi_test_teardown(void *monitor_obj); +bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj); +bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, + int8_t adv_rssi); + #endif /* __ADV_MONITOR_H */ diff --git a/unit/test-adv-monitor.c b/unit/test-adv-monitor.c new file mode 100644 index 000000000..c9aab2bee --- /dev/null +++ b/unit/test-adv-monitor.c @@ -0,0 +1,391 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <glib.h> +#include <stdbool.h> +#include <stdint.h> +#include <unistd.h> + +#include "src/log.h" +#include "src/shared/tester.h" + +#include "src/adv_monitor.h" + +#define define_test(name, type, data, setup_fn, test_fn, teardown_fn) \ + do { \ + static struct test_data test; \ + test.test_type = type; \ + test.test_name = g_strdup(name); \ + if (type == TEST_RSSI_FILTER) { \ + test.rssi_filter_test_data = &data; \ + test.rssi_filter_test_data->test_info = &test; \ + } \ + tester_add(name, &test, setup_fn, test_fn, teardown_fn);\ + } while (0) + +#define ADV_INTERVAL 1 /* Advertisement interval in seconds */ +#define OUT_OF_RANGE -128 +#define END_OF_RSSI_TEST {0} + +#define RSSI_TEST_DONE(test_step) \ + (!test_step.adv_rssi && !test_step.duration && !test_step.result) + +#define DUMMY_BTD_DEVICE_OBJ ((void *) 0xF00) + +enum test_type { + TEST_RSSI_FILTER = 0, + TEST_CONTENT_FILTER, +}; + +enum result { + RESULT_DEVICE_NOT_FOUND = false, /* Initial state of a device */ + RESULT_DEVICE_FOUND = true, /* Device state when the + * Content/RSSI Filter match + */ + RESULT_DEVICE_LOST = false, /* Device state when the Low + * RSSI Filter match or if it + * goes offline/out-of-range + */ +}; + +struct rssi_filter_test { + void *adv_monitor_obj; /* struct adv_monitor object */ + void *btd_device_obj; /* struct btd_device object */ + struct test_data *test_info; + + const struct { + int8_t high_rssi_threshold; /* High RSSI threshold */ + uint16_t high_rssi_timeout; /* High RSSI threshold timeout*/ + int8_t low_rssi_threshold; /* Low RSSI threshold */ + uint16_t low_rssi_timeout; /* Low RSSI threshold timeout */ + } rssi_filter; + + time_t start_time; /* Start time of the test */ + uint16_t resume_step; /* Store the current sub-step of the + * test before suspending that test + */ + guint out_of_range_timer; /* Timer to simulate device offline */ + + const struct { + int8_t adv_rssi; /* Advertisement RSSI */ + uint16_t duration; /* Advertisement duration in seconds */ + enum result result; /* Device state after every step */ + } test_steps[]; +}; + +/* Parent data structure to hold the test data and information, + * used by tester_* functions and callbacks. + */ +struct test_data { + enum test_type test_type; + char *test_name; + + union { + struct rssi_filter_test *rssi_filter_test_data; + }; +}; + +/* RSSI Filter Test 1: + * - The Device Lost event should NOT get triggered even if the Adv RSSI is + * lower than LowRSSIThresh for more than LowRSSITimeout before finding + * the device first. + * - Similarly, the Device Found event should NOT get triggered if the Adv RSSI + * is greater than LowRSSIThresh but lower than HighRSSIThresh. + */ +static struct rssi_filter_test rssi_data_1 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-70, 6, RESULT_DEVICE_NOT_FOUND}, + {-50, 6, RESULT_DEVICE_NOT_FOUND}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 2: + * - The Device Found event should get triggered when the Adv RSSI is higher + * than HighRSSIThresh for more than HighRSSITimeout. + * - Once the device is found, the Device Lost event should NOT get triggered + * if the Adv RSSI drops below HighRSSIThresh but it is not lower than + * LowRSSIThresh. + * - When the Adv RSSI drops below LowRSSIThresh for more than LowRSSITimeout, + * the Device Lost event should get triggered. + */ +static struct rssi_filter_test rssi_data_2 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-30, 6, RESULT_DEVICE_FOUND}, + {-50, 6, RESULT_DEVICE_FOUND}, + {-70, 6, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 3: + * - The Device Found event should get triggered only when the Adv RSSI is + * higher than HighRSSIThresh for more than HighRSSITimeout. + * - If the Adv RSSI drops below HighRSSIThresh, timer should reset and start + * counting once the Adv RSSI is above HighRSSIThresh. + * - Similarly, when tracking the Low RSSI, timer should reset when the Adv RSSI + * goes above LowRSSIThresh. The Device Lost event should get triggered only + * when the Adv RSSI is lower than LowRSSIThresh for more than LowRSSITimeout. + */ +static struct rssi_filter_test rssi_data_3 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-30, 2, RESULT_DEVICE_NOT_FOUND}, + {-50, 6, RESULT_DEVICE_NOT_FOUND}, + {-30, 4, RESULT_DEVICE_NOT_FOUND}, + {-30, 2, RESULT_DEVICE_FOUND}, + {-70, 2, RESULT_DEVICE_FOUND}, + {-50, 6, RESULT_DEVICE_FOUND}, + {-70, 4, RESULT_DEVICE_FOUND}, + {-70, 2, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 4: + * - While tracking the High RSSI, timer should reset if the device goes + * offline/out-of-range for more than HighRSSITimeout. + * - Once the device is found, if the device goes offline/out-of-range for + * more than LowRSSITimeout, the Device Lost event should get triggered. + */ +static struct rssi_filter_test rssi_data_4 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + { -30, 2, RESULT_DEVICE_NOT_FOUND}, + {OUT_OF_RANGE, 6, RESULT_DEVICE_NOT_FOUND}, + { -30, 4, RESULT_DEVICE_NOT_FOUND}, + { -30, 2, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 6, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 5: + * - The Device Found event should get triggered only once even if the Adv RSSI + * stays higher than HighRSSIThresh for a longer period of time. + * - Once the device is found, while tracking the Low RSSI, timer should reset + * when the Adv RSSI goes above LowRSSIThresh. + * - The timer should NOT reset if the device goes offline/out-of-range for + * a very short period of time and comes back online/in-range before + * the timeouts. + */ +static struct rssi_filter_test rssi_data_5 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + { -30, 2, RESULT_DEVICE_NOT_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_NOT_FOUND}, + { -30, 2, RESULT_DEVICE_FOUND}, + { -30, 3, RESULT_DEVICE_FOUND}, + { -30, 3, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_FOUND}, + { -50, 6, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* Initialize the data required for RSSI Filter test */ +static void setup_rssi_filter_test(gpointer data) +{ + struct rssi_filter_test *test = data; + + test->adv_monitor_obj = btd_adv_monitor_rssi_test_setup( + test->rssi_filter.high_rssi_threshold, + test->rssi_filter.high_rssi_timeout, + test->rssi_filter.low_rssi_threshold, + test->rssi_filter.low_rssi_timeout); + + /* The RSSI Filter logic uses btd_device object only as a key in the + * adv_monitor->devices list, it is never dereferenced nor used to + * perform any operations related to btd_device. So we can use any + * dummy address for unit testing. + */ + test->btd_device_obj = DUMMY_BTD_DEVICE_OBJ; + + tester_setup_complete(); +} + +/* Cleanup after the RSSI Filter test is done */ +static void teardown_rssi_filter_test(gpointer data) +{ + struct rssi_filter_test *test = data; + + btd_adv_monitor_rssi_test_teardown(test->adv_monitor_obj); + + tester_teardown_complete(); +} + +/* Execute the sub-steps of RSSI Filter test */ +static gboolean test_rssi_filter(gpointer data) +{ + struct rssi_filter_test *test = data; + time_t start_time = time(NULL); + bool ret = false; + + uint16_t i = 0; + uint16_t j = 0; + + /* If this is not the beginning of test, return to the sub-step + * before that test was suspended + */ + if (test->resume_step) { + start_time = test->start_time; + i = test->resume_step; + + /* Clear the test resume timer */ + g_source_remove(test->out_of_range_timer); + test->out_of_range_timer = 0; + + /* Check state of the device - found/lost, while device was + * offline/out-of-range + */ + ret = btd_adv_monitor_test_device_state(test->adv_monitor_obj, + test->btd_device_obj); + tester_debug("%s: [t=%.0lf, step=%d] Test resume, " + "device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + ret ? "true" : "false"); + g_assert(ret == test->test_steps[i].result); + + i++; + } + + while (!RSSI_TEST_DONE(test->test_steps[i])) { + if (test->test_steps[i].adv_rssi == OUT_OF_RANGE) { + /* Simulate device offline/out-of-range by suspending + * the test. + * + * Note: All tester_* functions run sequentially by + * adding a next function to the main loop using + * g_idle_add(). If a timeout function is added using + * g_timeout_add_*(), it doesn't really get invoked as + * soon as the timer expires. Instead, it is invoked + * once the current function returns and the timer has + * expired. So, to give handle_device_lost_timeout() + * function a chance to run at the correct time, we + * must save the current state and exit from this + * function while we simulate the device offline. We can + * come back later to continue with the remaining steps. + */ + test->resume_step = i; + test->start_time = start_time; + test->out_of_range_timer = g_timeout_add_seconds( + test->test_steps[i].duration, + test_rssi_filter, data); + + /* Check the device state before suspending the test */ + ret = btd_adv_monitor_test_device_state( + test->adv_monitor_obj, + test->btd_device_obj); + tester_debug("%s: [t=%.0lf, step=%d] Test suspend, " + "device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + ret ? "true" : "false"); + return FALSE; + } + + for (j = 0; j < test->test_steps[i].duration; j++) { + ret = btd_adv_monitor_test_rssi( + test->adv_monitor_obj, + test->btd_device_obj, + test->test_steps[i].adv_rssi); + tester_debug("%s: [t=%.0lf, step=%d] Test " + "advertisement RSSI %d, device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + test->test_steps[i].adv_rssi, + ret ? "true" : "false"); + + /* Sleep for a second to simulate receiving + * advertisement once every second + */ + sleep(ADV_INTERVAL); + } + g_assert(ret == test->test_steps[i].result); + + i++; + } + + tester_debug("%s: [t=%.0lf] Test done", test->test_info->test_name, + difftime(time(NULL), start_time)); + + tester_test_passed(); + + return FALSE; +} + +/* Handler function to prepare for a test */ +static void setup_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + setup_rssi_filter_test(test->rssi_filter_test_data); +} + +/* Handler function to cleanup after the test is done */ +static void teardown_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + teardown_rssi_filter_test(test->rssi_filter_test_data); +} + +/* Handler function to execute a test with the given data set */ +static void test_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + test_rssi_filter(test->rssi_filter_test_data); +} + +int main(int argc, char *argv[]) +{ + tester_init(&argc, &argv); + + __btd_log_init("*", 0); + + define_test("/advmon/rssi/1", TEST_RSSI_FILTER, rssi_data_1, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/2", TEST_RSSI_FILTER, rssi_data_2, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/3", TEST_RSSI_FILTER, rssi_data_3, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/4", TEST_RSSI_FILTER, rssi_data_4, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/5", TEST_RSSI_FILTER, rssi_data_5, + setup_handler, test_handler, teardown_handler); + + return tester_run(); +} -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AEtNOo30Yl8YTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 07:30:53 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id cEn7No30Yl/PqwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 07:30:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 97ACE40963; Thu, 17 Sep 2020 07:30:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726311AbgIQFaL (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 01:30:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726269AbgIQFaI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 01:30:08 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A92EC061788 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:30:07 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id b3so1128028ybg.23 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=ygbRGR9MwQmhVfnOPf7/bfPQRgvGhgJ28URwKmtcTXY=; b=fLZlyxtD0aKEcvA+dEYTYrEvrvvko2Dbwk39ayqkCi3IVgAoZ2lGWWQLlSkz7NCtZt Gxl17cg91T1SEeE3eFkQV3YfMYi8ACcRKW88i3MTs9ZuNBQKPqTdObZFhMS6W9Tuk6p6 7xMhwuzMtJVrv3CO9DQd6HDlt5sgfnhnvscmuQNxGaKEalmzEEsdgdd/cX/T1xX7I4Rr 3YasPxPPbNlw0Oobkc8Kri8QCyDtLTy9CuzVqtCohi6J80rDk0ogYK2tksgssNzH7wAi 9XDM/HFhN9tsgOJx0BRamQltRGpK/lnP8/fh+PCBNktQCogE54XodNeAruDxBpKOMNcv si3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ygbRGR9MwQmhVfnOPf7/bfPQRgvGhgJ28URwKmtcTXY=; b=UNJHywyPOEvXBmMlYfuB5e7vcue2XeegxegZu/GjtPrgg18S3MtEjQCF4RbG9Yli3u YFoYUJ+OdCGeEaTSw46YYgApF+7chOrOKiR803foZjiaoThqMye96wrLlQi5YQOEIYu+ oiP0UaQcIsU0zbJw9ncspOMm1fM+9Iwp37zlJpCF8P0gjbWTvckVqHZsYvoCNivHOpu2 CBCrS9jVmJfaJ3ok3XqpaeIP0x/5FoEOySl+oHakZ5eXnEyjtZBf8J5QPXz4GW8V+sdL WmftlzGGftII0tCjYcc1cMZlmmxtcq/oYXaLP+qZZfqSmnxsJhpAVdT6eCAds4k9iYze ZSfg== X-Gm-Message-State: AOAM531sgMPfecFKxvy/4OvWHONYZIhY6Q9nijOaZ8G9Bjy4y6D5DiBN aPJi47mVpKoHAEyLwJ7Q4cOfoAj2GCIEu23SffUBIX19YhJKZ0X09KHzyt3UfbV5CSa99kAgAGP TDrq57uyByeoZHijtR+AhzSOpoJQJGDEw1DlKY3WdNKuvCVpIbkm16mkF0vXjDgUhTnxKBqr3Py Q7Hszjxer52Yo= X-Google-Smtp-Source: ABdhPJzRjYVShJdRorG6MaSccBe6ZdX1e3S2/18Yaiab0f2LybTKVk9bv/O83Y1YB3R7mSO5Sq+2PCBsGO7y2bLfyQ== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a25:23d6:: with SMTP id j205mr21425311ybj.76.1600320606780; Wed, 16 Sep 2020 22:30:06 -0700 (PDT) Date: Thu, 17 Sep 2020 13:29:43 +0800 In-Reply-To: <20200917132836.BlueZ.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200917132836.BlueZ.6.I756c1fecc03bcc0cd94400b4992cd7e743f4b3e2@changeid> Mime-Version: 1.0 References: <20200917132836.BlueZ.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH 6/6] Bluetooth: Add toggle to switch off interleave scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, marcel@holtmann.org, mmandlik@chromium.org, howardchung@google.com, luiz.dentz@gmail.com, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: 97ACE40963 X-Rspamd-UID: 2b9aeb This patch add a configurable parameter to switch off the interleave scan feature. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> --- include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 1 + net/bluetooth/hci_request.c | 3 ++- net/bluetooth/mgmt_config.c | 6 ++++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 179350f869fdb..c3253f1cac0c2 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -363,6 +363,7 @@ struct hci_dev { __u32 clock; __u16 advmon_allowlist_duration; __u16 advmon_no_filter_duration; + __u16 enable_advmon_interleave_scan; __u16 devid_source; __u16 devid_vendor; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6c8850149265a..4608715860cce 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3595,6 +3595,7 @@ struct hci_dev *hci_alloc_dev(void) /* The default values will be chosen in the future */ hdev->advmon_allowlist_duration = 300; hdev->advmon_no_filter_duration = 500; + hdev->enable_advmon_interleave_scan = 0x0001; /* Default to enable */ hdev->sniff_max_interval = 800; hdev->sniff_min_interval = 80; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 1fcf6736811e4..bb38e1dead68f 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -500,7 +500,8 @@ static void __hci_update_background_scan(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) hci_req_add_le_scan_disable(req, false); - if (!update_adv_monitor_scan_state(hdev)) { + if (!hdev->enable_advmon_interleave_scan || + !update_adv_monitor_scan_state(hdev)) { hci_req_add_le_passive_scan(req); bt_dev_dbg(hdev, "%s starting background scanning", hdev->name); diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index 6dc3e43dcaa9f..4df6de44ee438 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -69,6 +69,7 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, def_le_autoconnect_timeout), HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), + HDEV_PARAM_U16(0x001f, enable_advmon_interleave_scan), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -143,6 +144,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x001c: case 0x001d: case 0x001e: + case 0x001f: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -264,6 +266,10 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, hdev->advmon_no_filter_duration = TLV_GET_LE16(buffer); break; + case 0x0001f: + hdev->enable_advmon_interleave_scan = + TLV_GET_LE16(buffer); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GJBLIKn0Yl9aagEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 07:31:21 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id gP4sHan0Yl9IzwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 07:31:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7A4DB400B3; Thu, 17 Sep 2020 07:31:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726280AbgIQFaI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 01:30:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgIQFaE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 01:30:04 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A029C061788 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:30:04 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id v14so753095qvq.10 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=XmWCE7age5UnMwS5JxN69B5KWt/qREsunjUKP7hacM0=; b=TohQyaKedV/7Ibhkoc0hUwGYUEX+/BNWsSL89N2gO0v+tE9tqhLwpg6tZeaw4GUbZo 4HhpI/j7aAxBG2p8cW/hQfog/Kmro0dyRPtJQtGNmyH54sBGaXykSOQGiR/ASZmrz8BF tB78F/5HihiYxkviq3wgYXKfaYCMIF+MQqfbpXGGxHWVrp06DGKXlmhcBOx929fO4+VY fJ449NLpfNWft19izeqkHXiNKFEvYfZa1hQnlrx2VsjAIbgz1MzSDAimpkHRCDpoC6bK ePgoYsCEivmmA6gpPsZYqOuNoETRSoKI10bgfJU+B7xe6W6Huuf2ythSEi2yJIlqmoJr Zblg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=XmWCE7age5UnMwS5JxN69B5KWt/qREsunjUKP7hacM0=; b=pClwaY9BskqtjhX3fz5vxiq3PlfC1cFs6eLejk3TGiUp/nOBSfwJG4mCEvjhxozI9T cn0HAHhJF4egPwEdHVft9swtpbeKm1n3wNphjFgoYRD7AJp+5t6BULmdWQxHxKi1o3MQ mY9ASFsXb+ZN0wCDm0fHU19kJcSROOPZPOLubFaSgl7mvkQYIJ6sVNekVps8IUmc1175 QLvXGDM1b7tgVyPKUho2u1bIUvEdUkZJJLIcLNvBlZb+aG2tJJ5MrkC0k8rGT9XIcgiF JWReJ3YIXEW7HmiDZVNb1P4HAqVsbhHGwINuUjw/48v+mTX6LpN/OExyHtFU23ZMHojc 9ASg== X-Gm-Message-State: AOAM533fYcVXuIIJ3PDam/QlCZoJMYkSJhbBz+Eahatl1PsqdVixFq4U /zZLIfmP/SV32IL6kQRbit9Wk/yfxw+HFB6sfWuQz3zPG1+Z8YhecPacYZEeuI4ZBkCSjpHHmN3 7BqydCyFDMUlhDUMWaVYmLM+YyycTh5zejNNmjQ9LXHURpjD+EQgWM2zui7ThcsgwdoMu8WtMy0 ZO26DXfWPnUIo= X-Google-Smtp-Source: ABdhPJwtM46x5bZUFvh2+P9WwAGt7EnNMSpRF+abYwADScuXGTd4JUZBu0FtOj7Xlb0a4eiqNhvSTg7TGV+oMTOq8A== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a0c:d848:: with SMTP id i8mr27007933qvj.31.1600320603105; Wed, 16 Sep 2020 22:30:03 -0700 (PDT) Date: Thu, 17 Sep 2020 13:29:42 +0800 In-Reply-To: <20200917132836.BlueZ.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200917132836.BlueZ.5.I21e5741249e78c560ca377499ba06b56c7214985@changeid> Mime-Version: 1.0 References: <20200917132836.BlueZ.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH 5/6] Bluetooth: Handle active scan case From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, marcel@holtmann.org, mmandlik@chromium.org, howardchung@google.com, luiz.dentz@gmail.com, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.55 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7A4DB400B3 X-Rspamd-UID: 506542 This patch adds code to handle the active scan during interleave scan. The interleave scan will be canceled when users start active scan, and it will be restarted after active scan stopped. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- net/bluetooth/hci_request.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index d9082019b6386..1fcf6736811e4 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -3085,8 +3085,10 @@ static int active_scan(struct hci_request *req, unsigned long opt) * running. Thus, we should temporarily stop it in order to set the * discovery scanning parameters. */ - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { hci_req_add_le_scan_disable(req, false); + cancel_interleave_scan(hdev); + } /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KAlvCnfmYl8ZqgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 06:30:47 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 8ITjBnfmYl8PWgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 06:30:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 320C0A0B31; Thu, 17 Sep 2020 06:30:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbgIQEah (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 00:30:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQEaf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 00:30:35 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F2ABC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:30:35 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id r19so456147pls.1 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=15iigfckPLPHxTZgQ+Du6K7alTokeIkLjffUWpPPJZc=; b=VBtXSo11rnnjR9fcIdMniRGmUtsYZUk1uu4ulSE65IG7MQKpL+OYFMqRjYSGYQprkq 6Br4mHsrl2g1L9YldRH/tMVZlo+/xo2RfboC69UbwVbwG6HQNLKy47FtmdiJz9E5EUoy YVW5OWhzhQJwYQKII6zoUW0rO0K0S1xgo+b80= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=15iigfckPLPHxTZgQ+Du6K7alTokeIkLjffUWpPPJZc=; b=JcxwMX1Ib66UJFJ1kSdgvmXYxq6sWsAjvGipxu2sW8gnanLATfhedZsmoCiIl96/8k w8lwi8V3zYBOi+DLxN45N3ERUsEsnLAEmHe+pR+dwM+0oG2pqcuCpdNDldJHHfVTOZXK HxgGc9R9IU/ez8/FplaJGWv2iBzZKzWnPaFZJWBSBd7fI2CdaleGAMd6OFPuvJcmSGZc 5L6UNmpHuCZmlgscWgGVhVdboKup8LP8Lnws6ss7pt24Uqvjg89r5qqYyevItLL9qf6F 9rv+MW2eS7tt/sDvN7U1WiTSxeRYPREv9zC6KhaTssMGfmFfauT/qqmGP+7hpF3lwMoF n/HA== X-Gm-Message-State: AOAM531+qVqdogVtmt9plctayARUWUwPQlKmxDDO9Umy07McM2vM2b7R K+lS2RAPe211NgKiMLHkKcpNMyr8cEyCPg== X-Google-Smtp-Source: ABdhPJwEX2V5IhDSDS+hf+O/P6Z7tEDVrE+FSfcF452WSdASV2D1y7/+rY1r7Auac5zmN7QnGIdEAw== X-Received: by 2002:a17:902:6bc3:b029:d1:e609:7a29 with SMTP id m3-20020a1709026bc3b02900d1e6097a29mr8986103plt.46.1600317034432; Wed, 16 Sep 2020 21:30:34 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id 99sm4169562pjo.40.2020.09.16.21.30.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 21:30:33 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, chromeos-bluetooth-upstreaming@chromium.org, Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v1 3/8] adv_monitor: Implement Adv matching based on stored monitors Date: Wed, 16 Sep 2020 21:29:49 -0700 Message-Id: <20200916212926.BlueZ.v1.3.I578ae5e76fcf7243206a27d4f5a25783662a5f14@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: 320C0A0B31 X-Rspamd-UID: 08cae4 This implements create an entry point in adapter to start the matching of Adv based on all monitors and invoke the RSSI tracking for Adv reporting. Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- src/adapter.c | 35 +++++-- src/adv_monitor.c | 238 +++++++++++++++++++++++++++++++++++++++++----- src/adv_monitor.h | 19 ++++ 3 files changed, 260 insertions(+), 32 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 415d6e06b..d33ce7124 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6614,6 +6614,15 @@ static void update_found_devices(struct btd_adapter *adapter, bool name_known, discoverable; char addr[18]; bool duplicate = false; + GSList *matched_monitors; + + /* During the background scanning, update the device only when the data + * match at least one Adv monitor + */ + matched_monitors = btd_adv_monitor_content_filter( + adapter->adv_monitor_manager, data, data_len); + if (!adapter->discovering && !matched_monitors) + return; memset(&eir_data, 0, sizeof(eir_data)); eir_parse(&eir_data, data, data_len); @@ -6659,18 +6668,22 @@ static void update_found_devices(struct btd_adapter *adapter, device_store_cached_name(dev, eir_data.name); /* - * Only skip devices that are not connected, are temporary and there - * is no active discovery session ongoing. + * Only skip devices that are not connected, are temporary, and there + * is no active discovery session ongoing and no matched Adv monitors */ - if (!btd_device_is_connected(dev) && (device_is_temporary(dev) && - !adapter->discovery_list)) { + if (!btd_device_is_connected(dev) && + (device_is_temporary(dev) && !adapter->discovery_list) && + !matched_monitors) { eir_data_free(&eir_data); return; } - /* Don't continue if not discoverable or if filter don't match */ - if (!discoverable || (adapter->filtered_discovery && - !is_filter_match(adapter->discovery_list, &eir_data, rssi))) { + /* If there is no matched Adv monitors, don't continue if not + * discoverable or if active discovery filter don't match. + */ + if (!matched_monitors && (!discoverable || + (adapter->filtered_discovery && !is_filter_match( + adapter->discovery_list, &eir_data, rssi)))) { eir_data_free(&eir_data); return; } @@ -6727,6 +6740,14 @@ static void update_found_devices(struct btd_adapter *adapter, eir_data_free(&eir_data); + /* After the device is updated, notify the matched Adv monitors */ + if (matched_monitors) { + btd_adv_monitor_notify_monitors(adapter->adv_monitor_manager, + dev, rssi, matched_monitors); + g_slist_free(matched_monitors); + matched_monitors = NULL; + } + /* * Only if at least one client has requested discovery, maintain * list of found devices and name confirming for legacy devices. diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 046f5953f..4f86384e9 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -38,15 +38,12 @@ #include "device.h" #include "log.h" #include "src/error.h" -#include "src/shared/ad.h" #include "src/shared/mgmt.h" #include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" -static void monitor_device_free(void *data); - #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" @@ -93,7 +90,7 @@ enum monitor_state { MONITOR_STATE_HONORED, /* Accepted by kernel */ }; -struct pattern { +struct btd_adv_monitor_pattern { uint8_t ad_type; uint8_t offset; uint8_t length; @@ -142,6 +139,23 @@ struct app_match_data { const char *path; }; +struct adv_content_filter_info { + uint8_t eir_len; + const uint8_t *eir; + + bool matched; /* Intermediate state per monitor */ + GSList *matched_monitors; /* List of matched monitors */ +}; + +struct adv_rssi_filter_info { + struct btd_device *device; + int8_t rssi; +}; + +static void monitor_device_free(void *data); +static void adv_monitor_filter_rssi(struct adv_monitor *monitor, + struct btd_device *device, int8_t rssi); + const struct adv_monitor_type { enum monitor_type type; const char *name; @@ -164,7 +178,7 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) /* Frees a pattern */ static void pattern_free(void *data) { - struct pattern *pattern = data; + struct btd_adv_monitor_pattern *pattern = data; if (!pattern) return; @@ -172,6 +186,12 @@ static void pattern_free(void *data) free(pattern); } +void btd_adv_monitor_test_pattern_destroy( + struct btd_adv_monitor_pattern *pattern) +{ + pattern_free(pattern); +} + /* Frees a monitor object */ static void monitor_free(void *data) { @@ -444,6 +464,42 @@ failed: return false; } +/* Allocates and initiates a pattern with the given content */ +static struct btd_adv_monitor_pattern *pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value) +{ + struct btd_adv_monitor_pattern *pattern; + + if (offset > BT_AD_MAX_DATA_LEN - 1) + return NULL; + + if ((ad_type > BT_AD_3D_INFO_DATA && + ad_type != BT_AD_MANUFACTURER_DATA) || + ad_type < BT_AD_FLAGS) { + return NULL; + } + + if (!value || !length || offset + length > BT_AD_MAX_DATA_LEN) + return NULL; + + pattern = new0(struct btd_adv_monitor_pattern, 1); + if (!pattern) + return NULL; + + pattern->ad_type = ad_type; + pattern->offset = offset; + pattern->length = length; + memcpy(pattern->value, value, pattern->length); + + return pattern; +} + +struct btd_adv_monitor_pattern *btd_adv_monitor_test_pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value) +{ + return pattern_create(ad_type, offset, length, value); +} + /* Retrieves Patterns from the remote Adv Monitor object, verifies the values * and update the local Adv Monitor */ @@ -473,7 +529,7 @@ static bool parse_patterns(struct adv_monitor *monitor, const char *path) int value_len; uint8_t *value; uint8_t offset, ad_type; - struct pattern *pattern; + struct btd_adv_monitor_pattern *pattern; DBusMessageIter struct_iter, value_iter; dbus_message_iter_recurse(&array_iter, &struct_iter); @@ -505,28 +561,10 @@ static bool parse_patterns(struct adv_monitor *monitor, const char *path) dbus_message_iter_get_fixed_array(&value_iter, &value, &value_len); - // Verify the values - if (offset > BT_AD_MAX_DATA_LEN - 1) - goto failed; - - if ((ad_type > BT_AD_3D_INFO_DATA && - ad_type != BT_AD_MANUFACTURER_DATA) || - ad_type < BT_AD_FLAGS) { - goto failed; - } - - if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) - goto failed; - - pattern = new0(struct pattern, 1); + pattern = pattern_create(ad_type, offset, value_len, value); if (!pattern) goto failed; - pattern->ad_type = ad_type; - pattern->offset = offset; - pattern->length = value_len; - memcpy(pattern->value, value, pattern->length); - queue_push_tail(monitor->patterns, pattern); dbus_message_iter_next(&array_iter); @@ -961,6 +999,156 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) manager_destroy(manager); } +/* Matches the content based on the given pattern */ +bool btd_adv_monitor_pattern_match( + const uint8_t *eir, uint8_t eir_len, + const struct btd_adv_monitor_pattern *pattern) +{ + const uint8_t *data; + uint8_t idx = 0; + uint8_t field_len, data_len, data_type; + + while (idx < eir_len - 1) { + field_len = eir[0]; + + /* Check for the end of EIR */ + if (field_len == 0) + break; + + idx += field_len + 1; + + /* Do not continue filtering if got incorrect length */ + if (idx >= eir_len) + break; + + data = &eir[2]; + data_type = eir[1]; + data_len = field_len - 1; + + eir += field_len + 1; + + if (data_type != pattern->ad_type) + continue; + + if (data_len < pattern->offset + pattern->length) + continue; + + if (pattern->offset + pattern->length > BT_AD_MAX_DATA_LEN) + continue; + + if (!memcmp(data + pattern->offset, pattern->value, + pattern->length)) + return true; + } + + return false; +} + +/* Processes the content matching based on a pattern */ +static void adv_match_per_pattern(void *data, void *user_data) +{ + struct btd_adv_monitor_pattern *pattern = data; + struct adv_content_filter_info *info = user_data; + const uint8_t *eir = info->eir; + + if (!pattern || info->matched) + return; + + info->matched = btd_adv_monitor_pattern_match(info->eir, info->eir_len, + pattern); +} + +/* Processes the content matching based pattern(s) of a monitor */ +static void adv_match_per_monitor(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct adv_content_filter_info *info = user_data; + + if (!monitor && monitor->state != MONITOR_STATE_HONORED) + return; + + /* Reset the intermediate matched status */ + info->matched = false; + + if (monitor->type == MONITOR_TYPE_OR_PATTERNS) { + queue_foreach(monitor->patterns, adv_match_per_pattern, info); + if (info->matched) + goto matched; + } + + return; + +matched: + info->matched_monitors = g_slist_prepend(info->matched_monitors, + monitor); +} + +/* Processes the content matching for the monitor(s) of an app */ +static void adv_match_per_app(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + + if (!app) + return; + + queue_foreach(app->monitors, adv_match_per_monitor, user_data); +} + +/* Processes the content matching for every app without RSSI filtering and + * notifying monitors. The caller is responsible of releasing the memory of the + * list but not the data. + * Returns the list of monitors whose content match eir. + */ +GSList *btd_adv_monitor_content_filter(struct btd_adv_monitor_manager *manager, + const uint8_t *eir, uint8_t eir_len) +{ + if (!manager || !eir || !eir_len) + return NULL; + + struct adv_content_filter_info info = { + .eir_len = eir_len, + .eir = eir, + .matched_monitors = NULL, + }; + + queue_foreach(manager->apps, adv_match_per_app, &info); + + return info.matched_monitors; +} + +/* Wraps adv_monitor_filter_rssi() to processes the content-matched monitor with + * RSSI filtering and notifies it on device found/lost event + */ +static void monitor_filter_rssi(gpointer a, gpointer b) +{ + struct adv_monitor *monitor = a; + struct adv_rssi_filter_info *info = b; + + if (!monitor || !info) + return; + + adv_monitor_filter_rssi(monitor, info->device, info->rssi); +} + +/* Processes every content-matched monitor with RSSI filtering and notifies on + * device found/lost event. The caller is responsible of releasing the memory + * of matched_monitors list but not its data. + */ +void btd_adv_monitor_notify_monitors(struct btd_adv_monitor_manager *manager, + struct btd_device *device, int8_t rssi, + GSList *matched_monitors) +{ + if (!manager || !device || !matched_monitors) + return; + + struct adv_rssi_filter_info info = { + .device = device, + .rssi = rssi, + }; + + g_slist_foreach(matched_monitors, monitor_filter_rssi, &info); +} + /* Matches a device based on btd_device object */ static bool monitor_device_match(const void *a, const void *b) { diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 351e7f9aa..b660f5941 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -20,16 +20,28 @@ #ifndef __ADV_MONITOR_H #define __ADV_MONITOR_H +#include <glib.h> + +#include "src/shared/ad.h" + struct mgmt; struct btd_device; struct btd_adapter; struct btd_adv_monitor_manager; +struct btd_adv_monitor_pattern; struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct btd_adapter *adapter, struct mgmt *mgmt); void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); +GSList *btd_adv_monitor_content_filter(struct btd_adv_monitor_manager *manager, + const uint8_t *eir, uint8_t eir_len); + +void btd_adv_monitor_notify_monitors(struct btd_adv_monitor_manager *manager, + struct btd_device *device, int8_t rssi, + GSList *matched_monitors); + void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, struct btd_device *device); @@ -42,5 +54,12 @@ void btd_adv_monitor_rssi_test_teardown(void *monitor_obj); bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj); bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, int8_t adv_rssi); +struct btd_adv_monitor_pattern *btd_adv_monitor_test_pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value); +void btd_adv_monitor_test_pattern_destroy( + struct btd_adv_monitor_pattern *pattern); +bool btd_adv_monitor_pattern_match( + const uint8_t *eir, uint8_t eir_len, + const struct btd_adv_monitor_pattern *pattern); #endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sBReFK70Yl/a4AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 07:31:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CFzCEK70Yl9JYQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 07:31:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A917C40971; Thu, 17 Sep 2020 07:31:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726354AbgIQFaz (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 01:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbgIQFaB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 01:30:01 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AD00C061788 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:30:00 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id 205so844098qkd.2 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=7nkg26OctKifdMOC9ynUWWxtGcGNDDYGKPUOkQnY3w4=; b=U8+7NojOYti39Ndb55+oUUZODqy28ZqLq7usV9TXykszcGEUcIaGxINuFHmsczZGR7 y3wcHneEG/GwcGYsVuZMKJ+g9s0sobZain0ZpNeEFZSTsEnGN0pzzxhPMQ91tuiK/Nup 9WDvmOCD3KN87jlt8fRKIkSIjWrAoNOmpr8qgqhh8bagUQFzGsKXIm/d9isNsvnlgfpg 7k5JtoN2e3/t7abbv2N93nlK2oM1cH9K2AHDBwBrL/6i0dC/NVGtO1Ud1U3EULXSdAwz 7Ki8K6qrbYU7amPKnroGPJbyzTbgWoQrn3oFgmtWFzphOboIuE1mAKVwaABQj7YiDt5X ZsgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=7nkg26OctKifdMOC9ynUWWxtGcGNDDYGKPUOkQnY3w4=; b=NrsOWfYYSlsSTLMUM9AUT0QQwGd53QT+dqqScEbNH6COe5lQrBmgamUeE0LF2AJRxv MeI48MjVnCMWYmfS9wY6zseGzLOfaGwDysOhTdgiIJtBPYw07yKXlAP0kW1+H8YB9BOZ wYbRajn9cP7WRl/vB9+1NlvRwi4l6YE1Du6yyWUI7ce8EGH3yw7pYAzKT9x3VUw3E7b/ DSr0AZfJSHBDBwTmGofYukG+Zc4FEIpWImx9tG3lvRGFogHkmINWEnx32mYv1lGhpAl+ vtc03HjDE8m8enGMzq0Z9C9F0yIE4GO3mAVYYhUoojlCLHQulQ7P4KGSRSZGYTXlz3Pv V+pA== X-Gm-Message-State: AOAM530Miayo28LS0HF1k0E4GqocXDGzxYwVQI//42YaIbSBhgcLhkon DXYnf6w6H2q88ziI7p7NJ2I2d9mTxhp4gY4fJiPVbKd509Wqgul4INw6WhA1rcWDchsPDWCSKMT M6J2R9HAUYS3adZ/XoF9ccV/XAay+IW1zUreSL//wmmhi8/zrGvzQBGszRy4IEjLem3AtIxwLLT h8jn4te1zhkdg= X-Google-Smtp-Source: ABdhPJx9ZmYekTuJ/BhlyqGQ4czVqNMFjtGq/Gk82PXi4hOOI1yccVgQZUa5Uncin2WGcIFeqGQy/QNzj8A0cEkccA== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a0c:e0c3:: with SMTP id x3mr10242050qvk.43.1600320599505; Wed, 16 Sep 2020 22:29:59 -0700 (PDT) Date: Thu, 17 Sep 2020 13:29:41 +0800 In-Reply-To: <20200917132836.BlueZ.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200917132836.BlueZ.4.I3774a8f0d748c7c6ec3402c4adcead32810c9164@changeid> Mime-Version: 1.0 References: <20200917132836.BlueZ.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH 4/6] Bluetooth: Handle system suspend resume case From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, marcel@holtmann.org, mmandlik@chromium.org, howardchung@google.com, luiz.dentz@gmail.com, alainm@chromium.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.88 / 15.00 / 15.00 X-Rspamd-Queue-Id: A917C40971 X-Rspamd-UID: 5c3b53 This patch adds code to handle the system suspension during interleave scan. The interleave scan will be canceled when the system is going to sleep, and will be restarted after waking up. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- net/bluetooth/hci_request.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 89443b48d90ce..d9082019b6386 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1081,6 +1081,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) filter_policy |= 0x02; if (hdev->suspended) { + /* Block suspend notifier on response */ + set_bit(SUSPEND_SCAN_ENABLE, hdev->suspend_tasks); + window = hdev->le_scan_window_suspend; interval = hdev->le_scan_int_suspend; } else if (hci_is_le_conn_scanning(hdev)) { @@ -1167,10 +1170,8 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ - hci_req_add_le_passive_scan(req); + __hci_update_background_scan(req); - /* Block suspend notifier on response */ - set_bit(SUSPEND_SCAN_ENABLE, req->hdev->suspend_tasks); } static void cancel_adv_timeout(struct hci_dev *hdev) @@ -1282,8 +1283,10 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan); /* Disable LE passive scan if enabled */ - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { + cancel_interleave_scan(hdev); hci_req_add_le_scan_disable(&req, false); + } /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WKY5BLv0Yl9aagEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 07:31:39 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id iPSQAbv0Yl9IzwAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 07:31:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2E46640968; Thu, 17 Sep 2020 07:31:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726375AbgIQFbL (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 01:31:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726187AbgIQF3y (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 01:29:54 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7E94C061788 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:29:52 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id m186so92720qkf.12 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:29:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=iN2CxHeMNgWaifXzqNK0PvVkokPY17tdMHt/mMLio+0=; b=nrIqOSlka6gtQA/RNk0dOAyWdFk1JRuotnAsgOi4qPsbqcEhwnvkcHDzjNXMTHchAW sXhWyBjoCzGM7UibTywYYwkI62nicmbZaWCAUya0veldw469JT5qps31uB1GnE4+YsJa DOFulqEQ8dT5ZWZKc3yRNn1NOq74s7naWuJ4aPOLwf3U3BzhzPIAooWHhCOOrQbZCKRT 3j3HRkslX5TI4xaHyEh1m7oH+kNkkfB4DApDmjBPY50Uu4cCaskv6LUilb/XAcMOsryw Snv+OqzXw9bLaiykWU1qA5fSPqtexYAGSd+FAm/fS1bmjWIxt3mdnhQvVlQKMHu7RdvI 9wlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=iN2CxHeMNgWaifXzqNK0PvVkokPY17tdMHt/mMLio+0=; b=gRfsTyWWRKh6j3MsRymwBFam9aG+pL/85e4UeF7EMP1s33UWxXGvgO+q33hEe7kTXh FfgbpHeKK/daBfjjtJvexYHoM7ihDzIp6XC1YHRpw5MOtey40dlsYIlxcVJy0enOG0Q+ gDowhO6kojfCzlurYtM5oNFXbWtrhK5V9eqo4BQUP3DNOaMqKd/L6JuFW7GOun09hASy A0/klqeJIqs0co51Ys7ulG1A6uAW5fwsG5GBzP4KbCNLG/0Bs5IIh4nNwJ1d1Qwe13Vg /IwZWCzbF/IpgVPWxVJWSQNsmfp29FQRDWZrcy8JK3WBhGip9fL5/Hrp7nM1DnXW0boR WCiw== X-Gm-Message-State: AOAM533kGzWPk/drwfWC470ExV13D05/fNdZ3usmV6RkOGJTDNDi74ty LTDVl+DYd3RdhLN8BDbJ5bdwvaUumxHZb49ptfjGNMdRx/ipxtL7wW8sIf4zRrI5pEevTlvw/z4 0jReUKWcD3zyDzd1bApUHn/fcsVF9M7jTHJlOGUj7DxAFoVxDsglH0f/uOnV0tDubjz3Rjnrthx vcuprweFR37Mo= X-Google-Smtp-Source: ABdhPJxh6ZM7nWp+f56ZHzsBJQta1PXhiAYtNC+IKmQct9nghl9r42M5HOw/4ZPapXC7Rh/zWov0/Z9I9u+dwlWNEQ== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:5006:: with SMTP id s6mr10447990qvo.51.1600320591974; Wed, 16 Sep 2020 22:29:51 -0700 (PDT) Date: Thu, 17 Sep 2020 13:29:39 +0800 In-Reply-To: <20200917132836.BlueZ.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200917132836.BlueZ.2.I8aafface41460f81241717da0498419a533bd165@changeid> Mime-Version: 1.0 References: <20200917132836.BlueZ.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH 2/6] Bluetooth: Set scan parameters for ADV Monitor From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, marcel@holtmann.org, mmandlik@chromium.org, howardchung@google.com, luiz.dentz@gmail.com, alainm@chromium.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.20 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2E46640968 X-Rspamd-UID: e053fd Set scan parameters when there is at least one Advertisement monitor. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- net/bluetooth/hci_request.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 413e3a5aabf54..d2b06f5c93804 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1027,6 +1027,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) } else if (hci_is_le_conn_scanning(hdev)) { window = hdev->le_scan_window_connect; interval = hdev->le_scan_int_connect; + } else if (hci_is_adv_monitoring(hdev)) { + window = hdev->le_scan_window_adv_monitor; + interval = hdev->le_scan_int_adv_monitor; } else { window = hdev->le_scan_window; interval = hdev->le_scan_interval; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SFcULr/0Yl8YTgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 07:31:43 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id sOPwKr/0Yl8f0AAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 07:31:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 279494086A; Thu, 17 Sep 2020 07:31:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726153AbgIQF3u (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 01:29:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726072AbgIQF3u (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 01:29:50 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E056BC061756 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:29:49 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id l1so763339qvr.0 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=DZtn9Rr5NAewp1qZv3hmsmsuQTNnLlGeDd7GB4F/76U=; b=N5U4fkyXuSJJo80wRUSBbIGDBA3w3e+zfqT8bI/6fqISU81t+RiYolHSLlsTvDD19M xjSY3EkS66Pg6nTWAfsAMszpfpx/k1bH0dAwzGAkqAiS35tTV9xqJysEccv+1kZnP/xr 4LeXHMQXLFZ0mkry9aoUkV0IxLTVIHGv6VoRNyraUdBGsGxjvyrAmEL9+6lCOcbqCU/6 ffRKh03667e2hOaNrprKQRxp6HeqietvqwpIGd43ki0BKutqaMI9X49iqoLqGYMg+D8z cdo5fFARDhZeRM5RlYxWuw3CHSU0ORRCSB21QPhNCZHqjw27+I2yEXQaHlapIcXd84bE /yQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=DZtn9Rr5NAewp1qZv3hmsmsuQTNnLlGeDd7GB4F/76U=; b=prmwjF/Z6y7yKnYHccz1gb9uFX9/mQ+0CMRbR6DjJjPxGRNRbu1YMp1koDqWIZ1fKY BN5TAixMbt/XsXVg6q9MewPo32wS22va1lBVByoSaGRKNIK1F0WzemVcCFpX209N4VUf 3R3SHsJe+FuV7K2yZCXrj6l7pGPxN9BDAdSKau0cd8CqT/CCxiwP11bzhF5V9ouN9jxw h3L63P4BqrxeynIgBL/LEocbA3hs+1nLcrkEl3nOg+5eFLiJNXuEG4sjvt8IjiliCOZG vY496HFX00x55OUD+GcQ/uB6TRsWWDKkNB+8Ja5DHS6RoxemJIxxIcckVFXY0BpYRwkc 4HaQ== X-Gm-Message-State: AOAM531S0zERetOmqhNOLjsu0zsnNkoBReGbfOIA94rO/KEs1WxNwSZy ATy4SeUwXdAPZSdr52IZdq4NUgIzsAI34zGllduTtHuuv7jCaGbC5LIjJaAOcz39lmHKCNUAO6P nY7GjjNvq26PnWw1XtG8wHl2CMpPSqd7QiJJvIX0GCWQ9RDreXhHVT+L8vn2+YN+3BnTNXUTdaj V2VFlD217houc= X-Google-Smtp-Source: ABdhPJxBxxNGWgG//JG92tXqEKNVQMibAYANYD7k1sVUyTqLXpM98PAOyJ1XVSkQqbQ9sd3NjaACQu/QPCpkCcX6lQ== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a0c:fe8b:: with SMTP id d11mr10852077qvs.48.1600320588288; Wed, 16 Sep 2020 22:29:48 -0700 (PDT) Date: Thu, 17 Sep 2020 13:29:38 +0800 Message-Id: <20200917132836.BlueZ.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH 1/6] Bluetooth: Update Adv monitor count upon removal From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, marcel@holtmann.org, mmandlik@chromium.org, howardchung@google.com, luiz.dentz@gmail.com, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.77 / 15.00 / 15.00 X-Rspamd-Queue-Id: 279494086A X-Rspamd-UID: 0ef8dd From: Miao-chen Chou <mcchou@chromium.org> This fixes the count of Adv monitor upon monitor removal. The following test was performed. - Start two btmgmt consoles, issue a btmgmt advmon-remove command on one console and observe a MGMT_EV_ADV_MONITOR_REMOVED event on the other. Signed-off-by: Howard Chung <howardchung@google.com> Signed-off-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- net/bluetooth/hci_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 8a2645a833013..f30a1f5950e15 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3061,6 +3061,7 @@ static int free_adv_monitor(int id, void *ptr, void *data) idr_remove(&hdev->adv_monitors_idr, monitor->handle); hci_free_adv_monitor(monitor); + hdev->adv_monitors_cnt--; return 0; } @@ -3077,6 +3078,7 @@ int hci_remove_adv_monitor(struct hci_dev *hdev, u16 handle) idr_remove(&hdev->adv_monitors_idr, monitor->handle); hci_free_adv_monitor(monitor); + hdev->adv_monitors_cnt--; } else { /* Remove all monitors if handle is 0. */ idr_for_each(&hdev->adv_monitors_idr, &free_adv_monitor, hdev); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KJvOBBkAY18OwgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:20:09 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id QIR7ARkAY18RKgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:20:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 00E3640875; Thu, 17 Sep 2020 08:20:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726180AbgIQGT7 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:19:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQGT6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:19:58 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 523C4C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:19:56 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id y1so744195pgk.8 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/MBaGN18T5ClGzqvtrP9gRU0RypRFw+AxswImwVO7R4=; b=NaH8GR0wDG3D3HrHL+vUvMsnyBy+z1TdX7i5S0IeDebsOfhFfuOqo/BEmgQZG11jGm lcqoYEg0OHHx/VpH9Y5NMspkmh/dnemH24v64KPQVz6Fu7yets8jdX4kFH6YFYekG5T5 7oKIu8+FOpto/Brp5VkbPpElIPxcSPmqNvNgA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/MBaGN18T5ClGzqvtrP9gRU0RypRFw+AxswImwVO7R4=; b=CqXISSk6nus6FxX5aS2++kfh2uctfRNCXdmUYeng3/woh05jL0OVseuAVMD03ZAUqu klSH0OUnGxZfv8W78E9XjVSUUJl/aImVCf0rXqMUPPxASKtx9gW1Gf24g8xpFWOlYmyS Vhctim+4VNoKbvd2o0lC3cQaP+2EipHmqwUMwX3lVvtAo7hGmtYivj3o41tySjMPLI5w B4+OC0qm3jVzNztMEnTCKI2LIS+LNNJHtq2+dFjuKn40ToqHMbQeNJCEsoq82ZO0xmk0 9qd+iJFYyzZbZGYPEYO2D6yqDUAhDRhQj0GifFmwMmbtdtxnUfIeweUkbKQH1OyNjyUJ Junw== X-Gm-Message-State: AOAM532I6GY6YXXWsXr7NnMiWyD1QjR2eXKeatBzqqrqbo1GI2GOt7vZ NfnQJJ5QtkZikCm/omRveJBQ+t1z40hmsg== X-Google-Smtp-Source: ABdhPJzh4sqfwnEU9/q5izXWTdDybFXILcU/4n9EDD3ZTYe30RB1jaNHxLeRIpaIYGZYscxBEMGEkQ== X-Received: by 2002:a63:cc16:: with SMTP id x22mr20640481pgf.414.1600323595235; Wed, 16 Sep 2020 23:19:55 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id g23sm19264943pfh.133.2020.09.16.23.19.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 23:19:54 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v2 1/8] adv_monitor: Implement RSSI Filter logic for background scanning Date: Wed, 16 Sep 2020 23:19:40 -0700 Message-Id: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.90 / 15.00 / 15.00 X-Rspamd-Queue-Id: 00E3640875 X-Rspamd-UID: ff148d From: Manish Mandlik <mmandlik@google.com> This patch implements the RSSI Filter logic for background scanning. This was unit-tested by running tests in unit/test-adv-monitor.c unit/test-adv-monitor.c file. Verified all tests PASS by running: USE="-bluez-next bluez-upstream" FEATURES=test emerge-hatch bluez Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Howard Chung <howardchung@google.com> --- (no changes since v1) doc/advertisement-monitor-api.txt | 5 + src/adapter.c | 1 + src/adv_monitor.c | 286 +++++++++++++++++++++++++++++- src/adv_monitor.h | 4 + 4 files changed, 292 insertions(+), 4 deletions(-) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index e09b6fd25..92c8ffc38 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -70,6 +70,11 @@ Properties string Type [read-only] dBm indicates unset. The valid range of a timer is 1 to 300 seconds while 0 indicates unset. + If the peer device advertising interval is greater than the + HighRSSIThresholdTimer, the device will never be found. Similarly, + if it is greater than LowRSSIThresholdTimer, the device will be + considered as lost. Consider configuring these values accordingly. + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] If Type is set to 0x01, this must exist and has at least diff --git a/src/adapter.c b/src/adapter.c index b2bd8b3f1..415d6e06b 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -1227,6 +1227,7 @@ void btd_adapter_remove_device(struct btd_adapter *adapter, adapter->connect_list = g_slist_remove(adapter->connect_list, dev); adapter->devices = g_slist_remove(adapter->devices, dev); + btd_adv_monitor_device_remove(adapter->adv_monitor_manager, dev); adapter->discovery_found = g_slist_remove(adapter->discovery_found, dev); diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 737da1c90..7baa5317f 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -35,6 +35,7 @@ #include "adapter.h" #include "dbus-common.h" +#include "device.h" #include "log.h" #include "src/error.h" #include "src/shared/ad.h" @@ -44,6 +45,8 @@ #include "adv_monitor.h" +static void monitor_device_free(void *data); + #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" @@ -104,15 +107,36 @@ struct adv_monitor { enum monitor_state state; /* MONITOR_STATE_* */ - int8_t high_rssi; /* high RSSI threshold */ - uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ - int8_t low_rssi; /* low RSSI threshold */ - uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ + int8_t high_rssi; /* High RSSI threshold */ + uint16_t high_rssi_timeout; /* High RSSI threshold timeout */ + int8_t low_rssi; /* Low RSSI threshold */ + uint16_t low_rssi_timeout; /* Low RSSI threshold timeout */ + struct queue *devices; /* List of adv_monitor_device objects */ enum monitor_type type; /* MONITOR_TYPE_* */ struct queue *patterns; }; +/* Some data like last_seen, timer/timeout values need to be maintained + * per device. struct adv_monitor_device maintains such data. + */ +struct adv_monitor_device { + struct adv_monitor *monitor; + struct btd_device *device; + + time_t high_rssi_first_seen; /* Start time when RSSI climbs above + * the high RSSI threshold + */ + time_t low_rssi_first_seen; /* Start time when RSSI drops below + * the low RSSI threshold + */ + time_t last_seen; /* Time when last Adv was received */ + bool device_found; /* State of the device - lost/found */ + guint device_lost_timer; /* Timer to track if the device goes + * offline/out-of-range + */ +}; + struct app_match_data { const char *owner; const char *path; @@ -159,6 +183,9 @@ static void monitor_free(void *data) g_dbus_proxy_unref(monitor->proxy); g_free(monitor->path); + queue_destroy(monitor->devices, monitor_device_free); + monitor->devices = NULL; + queue_destroy(monitor->patterns, pattern_free); free(monitor); @@ -257,6 +284,7 @@ static struct adv_monitor *monitor_new(struct adv_monitor_app *app, monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->devices = queue_new(); monitor->type = MONITOR_TYPE_NONE; monitor->patterns = NULL; @@ -932,3 +960,253 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) manager_destroy(manager); } + +/* Matches a device based on btd_device object */ +static bool monitor_device_match(const void *a, const void *b) +{ + const struct adv_monitor_device *dev = a; + const struct btd_device *device = b; + + if (!dev) + return false; + + if (dev->device != device) + return false; + + return true; +} + +/* Frees a monitor device object */ +static void monitor_device_free(void *data) +{ + struct adv_monitor_device *dev = data; + + if (!dev) + return; + + if (dev->device_lost_timer) { + g_source_remove(dev->device_lost_timer); + dev->device_lost_timer = 0; + } + + dev->monitor = NULL; + dev->device = NULL; + + g_free(dev); +} + +/* Removes a device from monitor->devices list */ +static void remove_device_from_monitor(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct btd_device *device = user_data; + struct adv_monitor_device *dev = NULL; + + if (!monitor) + return; + + dev = queue_remove_if(monitor->devices, monitor_device_match, device); + if (dev) { + DBG("Device removed from the Adv Monitor at path %s", + monitor->path); + monitor_device_free(dev); + } +} + +/* Removes a device from every monitor in an app */ +static void remove_device_from_app(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + struct btd_device *device = user_data; + + if (!app) + return; + + queue_foreach(app->monitors, remove_device_from_monitor, device); +} + +/* Removes a device from every monitor in all apps */ +void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, + struct btd_device *device) +{ + if (!manager || !device) + return; + + queue_foreach(manager->apps, remove_device_from_app, device); +} + +/* Creates a device object to track the per-device information */ +static struct adv_monitor_device *monitor_device_create( + struct adv_monitor *monitor, + struct btd_device *device) +{ + struct adv_monitor_device *dev = NULL; + + dev = g_try_malloc0(sizeof(struct adv_monitor_device)); + if (!dev) + return NULL; + + dev->monitor = monitor; + dev->device = device; + + queue_push_tail(monitor->devices, dev); + + return dev; +} + +/* Includes found/lost device's object path into the dbus message */ +static void report_device_state_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = device_get_path(user_data); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +/* Handles a situation where the device goes offline/out-of-range */ +static gboolean handle_device_lost_timeout(gpointer user_data) +{ + struct adv_monitor_device *dev = user_data; + struct adv_monitor *monitor = dev->monitor; + time_t curr_time = time(NULL); + + DBG("Device Lost timeout triggered for device %p " + "for the Adv Monitor at path %s", dev->device, monitor->path); + + dev->device_lost_timer = 0; + + if (dev->device_found && dev->last_seen) { + /* We were tracking for the Low RSSI filter. Check if there is + * any Adv received after the timeout function is invoked. + * If not, report the Device Lost event. + */ + if (difftime(curr_time, dev->last_seen) >= + monitor->low_rssi_timeout) { + dev->device_found = false; + + DBG("Calling DeviceLost() on Adv Monitor of owner %s " + "at path %s", monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "DeviceLost", + report_device_state_setup, + NULL, dev->device, NULL); + } + } + + return FALSE; +} + +/* Filters an Adv based on its RSSI value */ +static void adv_monitor_filter_rssi(struct adv_monitor *monitor, + struct btd_device *device, int8_t rssi) +{ + struct adv_monitor_device *dev = NULL; + time_t curr_time = time(NULL); + uint16_t adapter_id = monitor->app->manager->adapter_id; + + /* If the RSSI thresholds and timeouts are not specified, report the + * DeviceFound() event without tracking for the RSSI as the Adv has + * already matched the pattern filter. + */ + if (monitor->high_rssi == ADV_MONITOR_UNSET_RSSI && + monitor->low_rssi == ADV_MONITOR_UNSET_RSSI && + monitor->high_rssi_timeout == ADV_MONITOR_UNSET_TIMER && + monitor->low_rssi_timeout == ADV_MONITOR_UNSET_TIMER) { + DBG("Calling DeviceFound() on Adv Monitor of owner %s " + "at path %s", monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "DeviceFound", + report_device_state_setup, NULL, + device, NULL); + + return; + } + + dev = queue_find(monitor->devices, monitor_device_match, device); + if (!dev) + dev = monitor_device_create(monitor, device); + if (!dev) { + btd_error(adapter_id, "Failed to create Adv Monitor " + "device object."); + return; + } + + if (dev->device_lost_timer) { + g_source_remove(dev->device_lost_timer); + dev->device_lost_timer = 0; + } + + /* Reset the timings of found/lost if a device has been offline for + * longer than the high/low timeouts. + */ + if (dev->last_seen) { + if (difftime(curr_time, dev->last_seen) > + monitor->high_rssi_timeout) { + dev->high_rssi_first_seen = 0; + } + + if (difftime(curr_time, dev->last_seen) > + monitor->low_rssi_timeout) { + dev->low_rssi_first_seen = 0; + } + } + dev->last_seen = curr_time; + + /* Check for the found devices (if the device is not already found) */ + if (!dev->device_found && rssi > monitor->high_rssi) { + if (dev->high_rssi_first_seen) { + if (difftime(curr_time, dev->high_rssi_first_seen) >= + monitor->high_rssi_timeout) { + dev->device_found = true; + + DBG("Calling DeviceFound() on Adv Monitor " + "of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call( + monitor->proxy, "DeviceFound", + report_device_state_setup, NULL, + dev->device, NULL); + } + } else { + dev->high_rssi_first_seen = curr_time; + } + } else { + dev->high_rssi_first_seen = 0; + } + + /* Check for the lost devices (only if the device is already found, as + * it doesn't make any sense to report the Device Lost event if the + * device is not found yet) + */ + if (dev->device_found && rssi < monitor->low_rssi) { + if (dev->low_rssi_first_seen) { + if (difftime(curr_time, dev->low_rssi_first_seen) >= + monitor->low_rssi_timeout) { + dev->device_found = false; + + DBG("Calling DeviceLost() on Adv Monitor " + "of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call( + monitor->proxy, "DeviceLost", + report_device_state_setup, NULL, + dev->device, NULL); + } + } else { + dev->low_rssi_first_seen = curr_time; + } + } else { + dev->low_rssi_first_seen = 0; + } + + /* Setup a timer to track if the device goes offline/out-of-range, only + * if we are tracking for the Low RSSI Threshold. If we are tracking + * the High RSSI Threshold, nothing needs to be done. + */ + if (dev->device_found) { + dev->device_lost_timer = + g_timeout_add_seconds(monitor->low_rssi_timeout, + handle_device_lost_timeout, dev); + } +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 69ea348f8..14508e7d1 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -21,6 +21,7 @@ #define __ADV_MONITOR_H struct mgmt; +struct btd_device; struct btd_adapter; struct btd_adv_monitor_manager; @@ -29,4 +30,7 @@ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct mgmt *mgmt); void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); +void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, + struct btd_device *device); + #endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mIMYNS4AY1/87gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:20:30 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id mBIoMi4AY19JYQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:20:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 53F1740875; Thu, 17 Sep 2020 08:20:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726186AbgIQGUS (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:20:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQGUN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:20:13 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2957AC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:20:13 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id b124so539923pfg.13 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:20:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nWCXeK0FF/wh1L2v7xLpjjVFTYNjs8T1eeTnGvJ0r0Y=; b=VI9UCeV5wv8kTZmbw5xvdhwmJxqQa85YUscisadfKkzadXutrHdV2ZmkXFhyHh4e30 Ze1oWLgQzLkK4Se8YF+kZM0ApZLeOTjfUsJaDU/eA3deFtsWok0QmZ0QTRy5jZF6pej8 zarrLwTXxHyc/aRKRwr6YN7mEvrM5BPSE8e8A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nWCXeK0FF/wh1L2v7xLpjjVFTYNjs8T1eeTnGvJ0r0Y=; b=cbx3SEaN4qAhKp+FUrE8dvv7t8OXM3ku6ImAKVP9gXXXfDxhL+D15XB1PoLDU/HHCI BkwnMc7/JghLQqhHRyjgcTkuM+st3e4jQpXdnJ79prPC/kZW6nSLZqRMoYZf2lSGFgcV nKgzAtphfP4RsgqiHaHMFtgTb4SOEBthDiQnDSsOrYR1kDZRBsXvlKuSrw5uAPqbpHBX L9NFyvmMKsAIKvsINS+1shMvwimEw6tHbqNx1iWgl/S5nqly/OOEK4R24n7PbhzFaIFi ssdBaV0Vx5p0g5ayMjrBJLoMsJvAVdjYvI0coMx9roTYiXYJxBt37U6YM81f4jynUU6s n64Q== X-Gm-Message-State: AOAM533blBX7diVstZVPqoFIO89zt7Tk9fJDDBo8tnpCAoAorbis6pQ1 xPNJHsxhaxV/JhNx6m4xkPpvuB7h28rhOg== X-Google-Smtp-Source: ABdhPJzMKQpcxTlAD7FYp3sZv5iwT3Oof/zEU52BQJGOSCdCGRHIl0umSae6uNZOXyvRixiuhNYSYQ== X-Received: by 2002:a62:7a14:0:b029:13e:d13d:a0f5 with SMTP id v20-20020a627a140000b029013ed13da0f5mr25009487pfc.17.1600323612085; Wed, 16 Sep 2020 23:20:12 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id g23sm19264943pfh.133.2020.09.16.23.20.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 23:20:11 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v2 2/8] adv_monitor: Implement unit tests for RSSI Filter Date: Wed, 16 Sep 2020 23:19:42 -0700 Message-Id: <20200916231935.BlueZ.v2.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.52 / 15.00 / 15.00 X-Rspamd-Queue-Id: 53F1740875 X-Rspamd-UID: 18fed2 From: Manish Mandlik <mmandlik@google.com> This patch implements unit tests for the background scanning RSSI Filtering logic. Verified all tests PASS by running tests in unit/test-adv-monitor.c USE="-bluez-next bluez-upstream" FEATURES=test emerge-hatch bluez Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Changes in v2: - Cast test data to void * Makefile.am | 9 + doc/test-coverage.txt | 3 +- src/adv_monitor.c | 79 ++++++++ src/adv_monitor.h | 10 + unit/test-adv-monitor.c | 391 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 491 insertions(+), 1 deletion(-) create mode 100644 unit/test-adv-monitor.c diff --git a/Makefile.am b/Makefile.am index 22b4fa30c..6918f02b0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -527,6 +527,15 @@ unit_test_gattrib_LDADD = lib/libbluetooth-internal.la \ src/libshared-glib.la \ $(GLIB_LIBS) $(DBUS_LIBS) -ldl -lrt +unit_tests += unit/test-adv-monitor + +unit_test_adv_monitor_SOURCES = unit/test-adv-monitor.c \ + src/adv_monitor.h src/adv_monitor.c \ + src/device.h src/device.c \ + src/log.h src/log.c +unit_test_adv_monitor_LDADD = gdbus/libgdbus-internal.la \ + src/libshared-glib.la $(GLIB_LIBS) $(DBUS_LIBS) + if MIDI unit_tests += unit/test-midi unit_test_midi_CPPFLAGS = $(AM_CPPFLAGS) $(ALSA_CFLAGS) -DMIDI_TEST diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt index 741492a3e..5296983e6 100644 --- a/doc/test-coverage.txt +++ b/doc/test-coverage.txt @@ -30,8 +30,9 @@ test-gobex-transfer 36 OBEX transfer handling test-gdbus-client 13 D-Bus client handling test-gatt 180 GATT qualification test cases test-hog 6 HID Over GATT qualification test cases +test-adv-monitor 5 Advertisement Monitor test cases ----- - 761 + 766 Automated end-to-end testing diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 7baa5317f..046f5953f 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -1210,3 +1210,82 @@ static void adv_monitor_filter_rssi(struct adv_monitor *monitor, handle_device_lost_timeout, dev); } } + +/* Creates the dummy adv_monitor object for unit tests */ +void *btd_adv_monitor_rssi_test_setup(int8_t high_rssi, uint16_t high_timeout, + int8_t low_rssi, uint16_t low_timeout) +{ + struct adv_monitor *test_monitor = NULL; + + test_monitor = g_new0(struct adv_monitor, 1); + if (!test_monitor) + return NULL; + + test_monitor->app = g_new0(struct adv_monitor_app, 1); + if (!test_monitor->app) + goto app_failed; + + test_monitor->app->manager = g_new0(struct btd_adv_monitor_manager, 1); + if (!test_monitor->app->manager) + goto manager_failed; + + test_monitor->high_rssi = high_rssi; + test_monitor->high_rssi_timeout = high_timeout; + test_monitor->low_rssi = low_rssi; + test_monitor->low_rssi_timeout = low_timeout; + test_monitor->devices = queue_new(); + + return test_monitor; + +manager_failed: + g_free(test_monitor->app); + +app_failed: + g_free(test_monitor); + + return NULL; +} + +/* Cleanup after unit test is done */ +void btd_adv_monitor_rssi_test_teardown(void *monitor_obj) +{ + struct adv_monitor *monitor = monitor_obj; + + if (!monitor) + return; + + queue_destroy(monitor->devices, monitor_device_free); + g_free(monitor); +} + +/* Returns the current state of device - found/lost, used in unit tests */ +bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj) +{ + struct adv_monitor *monitor = monitor_obj; + struct btd_device *device = device_obj; + struct adv_monitor_device *dev = NULL; + + if (!monitor || !device) + return false; + + dev = queue_find(monitor->devices, monitor_device_match, device); + if (!dev) + return false; + + return dev->device_found; +} + +/* Helper function for the RSSI Filter unit tests */ +bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, + int8_t adv_rssi) +{ + struct adv_monitor *monitor = monitor_obj; + struct btd_device *device = device_obj; + + if (!monitor || !device) + return false; + + adv_monitor_filter_rssi(monitor, device, adv_rssi); + + return btd_adv_monitor_test_device_state(monitor, device); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 14508e7d1..351e7f9aa 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -33,4 +33,14 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, struct btd_device *device); +/* Following functions are the helper functions used for RSSI Filter unit tests + * defined in unit/test-adv-monitor.c + */ +void *btd_adv_monitor_rssi_test_setup(int8_t high_rssi, uint16_t high_timeout, + int8_t low_rssi, uint16_t low_timeout); +void btd_adv_monitor_rssi_test_teardown(void *monitor_obj); +bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj); +bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, + int8_t adv_rssi); + #endif /* __ADV_MONITOR_H */ diff --git a/unit/test-adv-monitor.c b/unit/test-adv-monitor.c new file mode 100644 index 000000000..970be84b0 --- /dev/null +++ b/unit/test-adv-monitor.c @@ -0,0 +1,391 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <glib.h> +#include <stdbool.h> +#include <stdint.h> +#include <unistd.h> + +#include "src/log.h" +#include "src/shared/tester.h" + +#include "src/adv_monitor.h" + +#define define_test(name, type, data, setup_fn, test_fn, teardown_fn) \ + do { \ + static struct test_data test; \ + test.test_type = type; \ + test.test_name = g_strdup(name); \ + if (type == TEST_RSSI_FILTER) { \ + test.rssi_filter_test_data = (void *)&data; \ + test.rssi_filter_test_data->test_info = &test; \ + } \ + tester_add(name, &test, setup_fn, test_fn, teardown_fn);\ + } while (0) + +#define ADV_INTERVAL 1 /* Advertisement interval in seconds */ +#define OUT_OF_RANGE -128 +#define END_OF_RSSI_TEST {0} + +#define RSSI_TEST_DONE(test_step) \ + (!test_step.adv_rssi && !test_step.duration && !test_step.result) + +#define DUMMY_BTD_DEVICE_OBJ ((void *) 0xF00) + +enum test_type { + TEST_RSSI_FILTER = 0, + TEST_CONTENT_FILTER, +}; + +enum result { + RESULT_DEVICE_NOT_FOUND = false, /* Initial state of a device */ + RESULT_DEVICE_FOUND = true, /* Device state when the + * Content/RSSI Filter match + */ + RESULT_DEVICE_LOST = false, /* Device state when the Low + * RSSI Filter match or if it + * goes offline/out-of-range + */ +}; + +struct rssi_filter_test { + void *adv_monitor_obj; /* struct adv_monitor object */ + void *btd_device_obj; /* struct btd_device object */ + struct test_data *test_info; + + const struct { + int8_t high_rssi_threshold; /* High RSSI threshold */ + uint16_t high_rssi_timeout; /* High RSSI threshold timeout*/ + int8_t low_rssi_threshold; /* Low RSSI threshold */ + uint16_t low_rssi_timeout; /* Low RSSI threshold timeout */ + } rssi_filter; + + time_t start_time; /* Start time of the test */ + uint16_t resume_step; /* Store the current sub-step of the + * test before suspending that test + */ + guint out_of_range_timer; /* Timer to simulate device offline */ + + const struct { + int8_t adv_rssi; /* Advertisement RSSI */ + uint16_t duration; /* Advertisement duration in seconds */ + enum result result; /* Device state after every step */ + } test_steps[]; +}; + +/* Parent data structure to hold the test data and information, + * used by tester_* functions and callbacks. + */ +struct test_data { + enum test_type test_type; + char *test_name; + + union { + struct rssi_filter_test *rssi_filter_test_data; + }; +}; + +/* RSSI Filter Test 1: + * - The Device Lost event should NOT get triggered even if the Adv RSSI is + * lower than LowRSSIThresh for more than LowRSSITimeout before finding + * the device first. + * - Similarly, the Device Found event should NOT get triggered if the Adv RSSI + * is greater than LowRSSIThresh but lower than HighRSSIThresh. + */ +static struct rssi_filter_test rssi_data_1 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-70, 6, RESULT_DEVICE_NOT_FOUND}, + {-50, 6, RESULT_DEVICE_NOT_FOUND}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 2: + * - The Device Found event should get triggered when the Adv RSSI is higher + * than HighRSSIThresh for more than HighRSSITimeout. + * - Once the device is found, the Device Lost event should NOT get triggered + * if the Adv RSSI drops below HighRSSIThresh but it is not lower than + * LowRSSIThresh. + * - When the Adv RSSI drops below LowRSSIThresh for more than LowRSSITimeout, + * the Device Lost event should get triggered. + */ +static struct rssi_filter_test rssi_data_2 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-30, 6, RESULT_DEVICE_FOUND}, + {-50, 6, RESULT_DEVICE_FOUND}, + {-70, 6, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 3: + * - The Device Found event should get triggered only when the Adv RSSI is + * higher than HighRSSIThresh for more than HighRSSITimeout. + * - If the Adv RSSI drops below HighRSSIThresh, timer should reset and start + * counting once the Adv RSSI is above HighRSSIThresh. + * - Similarly, when tracking the Low RSSI, timer should reset when the Adv RSSI + * goes above LowRSSIThresh. The Device Lost event should get triggered only + * when the Adv RSSI is lower than LowRSSIThresh for more than LowRSSITimeout. + */ +static struct rssi_filter_test rssi_data_3 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-30, 2, RESULT_DEVICE_NOT_FOUND}, + {-50, 6, RESULT_DEVICE_NOT_FOUND}, + {-30, 4, RESULT_DEVICE_NOT_FOUND}, + {-30, 2, RESULT_DEVICE_FOUND}, + {-70, 2, RESULT_DEVICE_FOUND}, + {-50, 6, RESULT_DEVICE_FOUND}, + {-70, 4, RESULT_DEVICE_FOUND}, + {-70, 2, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 4: + * - While tracking the High RSSI, timer should reset if the device goes + * offline/out-of-range for more than HighRSSITimeout. + * - Once the device is found, if the device goes offline/out-of-range for + * more than LowRSSITimeout, the Device Lost event should get triggered. + */ +static struct rssi_filter_test rssi_data_4 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + { -30, 2, RESULT_DEVICE_NOT_FOUND}, + {OUT_OF_RANGE, 6, RESULT_DEVICE_NOT_FOUND}, + { -30, 4, RESULT_DEVICE_NOT_FOUND}, + { -30, 2, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 6, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 5: + * - The Device Found event should get triggered only once even if the Adv RSSI + * stays higher than HighRSSIThresh for a longer period of time. + * - Once the device is found, while tracking the Low RSSI, timer should reset + * when the Adv RSSI goes above LowRSSIThresh. + * - The timer should NOT reset if the device goes offline/out-of-range for + * a very short period of time and comes back online/in-range before + * the timeouts. + */ +static struct rssi_filter_test rssi_data_5 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + { -30, 2, RESULT_DEVICE_NOT_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_NOT_FOUND}, + { -30, 2, RESULT_DEVICE_FOUND}, + { -30, 3, RESULT_DEVICE_FOUND}, + { -30, 3, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_FOUND}, + { -50, 6, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* Initialize the data required for RSSI Filter test */ +static void setup_rssi_filter_test(gpointer data) +{ + struct rssi_filter_test *test = data; + + test->adv_monitor_obj = btd_adv_monitor_rssi_test_setup( + test->rssi_filter.high_rssi_threshold, + test->rssi_filter.high_rssi_timeout, + test->rssi_filter.low_rssi_threshold, + test->rssi_filter.low_rssi_timeout); + + /* The RSSI Filter logic uses btd_device object only as a key in the + * adv_monitor->devices list, it is never dereferenced nor used to + * perform any operations related to btd_device. So we can use any + * dummy address for unit testing. + */ + test->btd_device_obj = DUMMY_BTD_DEVICE_OBJ; + + tester_setup_complete(); +} + +/* Cleanup after the RSSI Filter test is done */ +static void teardown_rssi_filter_test(gpointer data) +{ + struct rssi_filter_test *test = data; + + btd_adv_monitor_rssi_test_teardown(test->adv_monitor_obj); + + tester_teardown_complete(); +} + +/* Execute the sub-steps of RSSI Filter test */ +static gboolean test_rssi_filter(gpointer data) +{ + struct rssi_filter_test *test = data; + time_t start_time = time(NULL); + bool ret = false; + + uint16_t i = 0; + uint16_t j = 0; + + /* If this is not the beginning of test, return to the sub-step + * before that test was suspended + */ + if (test->resume_step) { + start_time = test->start_time; + i = test->resume_step; + + /* Clear the test resume timer */ + g_source_remove(test->out_of_range_timer); + test->out_of_range_timer = 0; + + /* Check state of the device - found/lost, while device was + * offline/out-of-range + */ + ret = btd_adv_monitor_test_device_state(test->adv_monitor_obj, + test->btd_device_obj); + tester_debug("%s: [t=%.0lf, step=%d] Test resume, " + "device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + ret ? "true" : "false"); + g_assert(ret == test->test_steps[i].result); + + i++; + } + + while (!RSSI_TEST_DONE(test->test_steps[i])) { + if (test->test_steps[i].adv_rssi == OUT_OF_RANGE) { + /* Simulate device offline/out-of-range by suspending + * the test. + * + * Note: All tester_* functions run sequentially by + * adding a next function to the main loop using + * g_idle_add(). If a timeout function is added using + * g_timeout_add_*(), it doesn't really get invoked as + * soon as the timer expires. Instead, it is invoked + * once the current function returns and the timer has + * expired. So, to give handle_device_lost_timeout() + * function a chance to run at the correct time, we + * must save the current state and exit from this + * function while we simulate the device offline. We can + * come back later to continue with the remaining steps. + */ + test->resume_step = i; + test->start_time = start_time; + test->out_of_range_timer = g_timeout_add_seconds( + test->test_steps[i].duration, + test_rssi_filter, data); + + /* Check the device state before suspending the test */ + ret = btd_adv_monitor_test_device_state( + test->adv_monitor_obj, + test->btd_device_obj); + tester_debug("%s: [t=%.0lf, step=%d] Test suspend, " + "device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + ret ? "true" : "false"); + return FALSE; + } + + for (j = 0; j < test->test_steps[i].duration; j++) { + ret = btd_adv_monitor_test_rssi( + test->adv_monitor_obj, + test->btd_device_obj, + test->test_steps[i].adv_rssi); + tester_debug("%s: [t=%.0lf, step=%d] Test " + "advertisement RSSI %d, device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + test->test_steps[i].adv_rssi, + ret ? "true" : "false"); + + /* Sleep for a second to simulate receiving + * advertisement once every second + */ + sleep(ADV_INTERVAL); + } + g_assert(ret == test->test_steps[i].result); + + i++; + } + + tester_debug("%s: [t=%.0lf] Test done", test->test_info->test_name, + difftime(time(NULL), start_time)); + + tester_test_passed(); + + return FALSE; +} + +/* Handler function to prepare for a test */ +static void setup_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + setup_rssi_filter_test(test->rssi_filter_test_data); +} + +/* Handler function to cleanup after the test is done */ +static void teardown_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + teardown_rssi_filter_test(test->rssi_filter_test_data); +} + +/* Handler function to execute a test with the given data set */ +static void test_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + test_rssi_filter(test->rssi_filter_test_data); +} + +int main(int argc, char *argv[]) +{ + tester_init(&argc, &argv); + + __btd_log_init("*", 0); + + define_test("/advmon/rssi/1", TEST_RSSI_FILTER, rssi_data_1, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/2", TEST_RSSI_FILTER, rssi_data_2, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/3", TEST_RSSI_FILTER, rssi_data_3, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/4", TEST_RSSI_FILTER, rssi_data_4, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/5", TEST_RSSI_FILTER, rssi_data_5, + setup_handler, test_handler, teardown_handler); + + return tester_run(); +} -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gCTTIzkAY18OwgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:20:41 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id ANgWIDkAY18C3QEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:20:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 18D4E4086D; Thu, 17 Sep 2020 08:20:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726191AbgIQGUe (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:20:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQGU3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:20:29 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C8BBC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:20:29 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id 67so734874pgd.12 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WRB9d8sFpm7OeJs49fmtNU3aVk+UhWdaM5u0PPyaIgI=; b=hzYL6RjJ2Zz+9OWHEU/OsTYKM88urF4Q3CpOM8PuwD3cMrHrCu1wtahX4DJCuMvmI0 SuGeoA/fC3yqipkHHp/6nEa9BrQsxN1DGg+m6QhWX0D+7wmMOAjE679ShmsjsihmgjGN xlNXea3mK9FA0/Q7Eo/Qz83SpNDZ7cS6Kgt00= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WRB9d8sFpm7OeJs49fmtNU3aVk+UhWdaM5u0PPyaIgI=; b=hMQGv9bdY0lhOod8p2OAr68E9fQnaAAqBLnLjmsekP5iCjZaaOWR7oiuSd27onhPRF 3PvyVmZQEqRlUuamMA0NesDZ0YIoYO0y6UhMwbK6+VklKoOuTykqd6qmxH5E4fov7E5S brqxxkVWrFWgoFwpdNUywD6kt0b0HeEgBjF1NoQ5lY3r24B2TMZSQeaCqPSzu5WL2uQX 3C4gcZAhwPoxl9Mw32vt3m0ZHl8SneEVVQwexy6NwhTpVkc1lP6nl6J7GE82vQbFjSmJ klHynZrT4ezoTS4yqLFbqRXK7CtGbKW12sQlroTw9hnDZ8UJDc/1z2q4u9SkPhakS6xk X6xQ== X-Gm-Message-State: AOAM533dRReZG3d4OdbZn/Uzz0P5MyrHfyYJ1Qg8B5zM+oc8ezslzcqG 9WXZAAe4cGOdiWtb2Vn73qEDGgTn8jAG6A== X-Google-Smtp-Source: ABdhPJwBf9Takk8G0nQ3oixpPzvzfJpPsLAwjBRtsNdRMnEc371bVroVN2EOsmlFi30iv9SZi4rD/w== X-Received: by 2002:a63:c543:: with SMTP id g3mr21693999pgd.203.1600323628141; Wed, 16 Sep 2020 23:20:28 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id g23sm19264943pfh.133.2020.09.16.23.20.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 23:20:27 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v2 3/8] adv_monitor: Implement Adv matching based on stored monitors Date: Wed, 16 Sep 2020 23:19:44 -0700 Message-Id: <20200916231935.BlueZ.v2.3.I578ae5e76fcf7243206a27d4f5a25783662a5f14@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: 18D4E4086D X-Rspamd-UID: cb433f This implements create an entry point in adapter to start the matching of Adv based on all monitors and invoke the RSSI tracking for Adv reporting. Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adapter.c | 35 +++++-- src/adv_monitor.c | 238 +++++++++++++++++++++++++++++++++++++++++----- src/adv_monitor.h | 19 ++++ 3 files changed, 260 insertions(+), 32 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 415d6e06b..d33ce7124 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6614,6 +6614,15 @@ static void update_found_devices(struct btd_adapter *adapter, bool name_known, discoverable; char addr[18]; bool duplicate = false; + GSList *matched_monitors; + + /* During the background scanning, update the device only when the data + * match at least one Adv monitor + */ + matched_monitors = btd_adv_monitor_content_filter( + adapter->adv_monitor_manager, data, data_len); + if (!adapter->discovering && !matched_monitors) + return; memset(&eir_data, 0, sizeof(eir_data)); eir_parse(&eir_data, data, data_len); @@ -6659,18 +6668,22 @@ static void update_found_devices(struct btd_adapter *adapter, device_store_cached_name(dev, eir_data.name); /* - * Only skip devices that are not connected, are temporary and there - * is no active discovery session ongoing. + * Only skip devices that are not connected, are temporary, and there + * is no active discovery session ongoing and no matched Adv monitors */ - if (!btd_device_is_connected(dev) && (device_is_temporary(dev) && - !adapter->discovery_list)) { + if (!btd_device_is_connected(dev) && + (device_is_temporary(dev) && !adapter->discovery_list) && + !matched_monitors) { eir_data_free(&eir_data); return; } - /* Don't continue if not discoverable or if filter don't match */ - if (!discoverable || (adapter->filtered_discovery && - !is_filter_match(adapter->discovery_list, &eir_data, rssi))) { + /* If there is no matched Adv monitors, don't continue if not + * discoverable or if active discovery filter don't match. + */ + if (!matched_monitors && (!discoverable || + (adapter->filtered_discovery && !is_filter_match( + adapter->discovery_list, &eir_data, rssi)))) { eir_data_free(&eir_data); return; } @@ -6727,6 +6740,14 @@ static void update_found_devices(struct btd_adapter *adapter, eir_data_free(&eir_data); + /* After the device is updated, notify the matched Adv monitors */ + if (matched_monitors) { + btd_adv_monitor_notify_monitors(adapter->adv_monitor_manager, + dev, rssi, matched_monitors); + g_slist_free(matched_monitors); + matched_monitors = NULL; + } + /* * Only if at least one client has requested discovery, maintain * list of found devices and name confirming for legacy devices. diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 046f5953f..4f86384e9 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -38,15 +38,12 @@ #include "device.h" #include "log.h" #include "src/error.h" -#include "src/shared/ad.h" #include "src/shared/mgmt.h" #include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" -static void monitor_device_free(void *data); - #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" @@ -93,7 +90,7 @@ enum monitor_state { MONITOR_STATE_HONORED, /* Accepted by kernel */ }; -struct pattern { +struct btd_adv_monitor_pattern { uint8_t ad_type; uint8_t offset; uint8_t length; @@ -142,6 +139,23 @@ struct app_match_data { const char *path; }; +struct adv_content_filter_info { + uint8_t eir_len; + const uint8_t *eir; + + bool matched; /* Intermediate state per monitor */ + GSList *matched_monitors; /* List of matched monitors */ +}; + +struct adv_rssi_filter_info { + struct btd_device *device; + int8_t rssi; +}; + +static void monitor_device_free(void *data); +static void adv_monitor_filter_rssi(struct adv_monitor *monitor, + struct btd_device *device, int8_t rssi); + const struct adv_monitor_type { enum monitor_type type; const char *name; @@ -164,7 +178,7 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) /* Frees a pattern */ static void pattern_free(void *data) { - struct pattern *pattern = data; + struct btd_adv_monitor_pattern *pattern = data; if (!pattern) return; @@ -172,6 +186,12 @@ static void pattern_free(void *data) free(pattern); } +void btd_adv_monitor_test_pattern_destroy( + struct btd_adv_monitor_pattern *pattern) +{ + pattern_free(pattern); +} + /* Frees a monitor object */ static void monitor_free(void *data) { @@ -444,6 +464,42 @@ failed: return false; } +/* Allocates and initiates a pattern with the given content */ +static struct btd_adv_monitor_pattern *pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value) +{ + struct btd_adv_monitor_pattern *pattern; + + if (offset > BT_AD_MAX_DATA_LEN - 1) + return NULL; + + if ((ad_type > BT_AD_3D_INFO_DATA && + ad_type != BT_AD_MANUFACTURER_DATA) || + ad_type < BT_AD_FLAGS) { + return NULL; + } + + if (!value || !length || offset + length > BT_AD_MAX_DATA_LEN) + return NULL; + + pattern = new0(struct btd_adv_monitor_pattern, 1); + if (!pattern) + return NULL; + + pattern->ad_type = ad_type; + pattern->offset = offset; + pattern->length = length; + memcpy(pattern->value, value, pattern->length); + + return pattern; +} + +struct btd_adv_monitor_pattern *btd_adv_monitor_test_pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value) +{ + return pattern_create(ad_type, offset, length, value); +} + /* Retrieves Patterns from the remote Adv Monitor object, verifies the values * and update the local Adv Monitor */ @@ -473,7 +529,7 @@ static bool parse_patterns(struct adv_monitor *monitor, const char *path) int value_len; uint8_t *value; uint8_t offset, ad_type; - struct pattern *pattern; + struct btd_adv_monitor_pattern *pattern; DBusMessageIter struct_iter, value_iter; dbus_message_iter_recurse(&array_iter, &struct_iter); @@ -505,28 +561,10 @@ static bool parse_patterns(struct adv_monitor *monitor, const char *path) dbus_message_iter_get_fixed_array(&value_iter, &value, &value_len); - // Verify the values - if (offset > BT_AD_MAX_DATA_LEN - 1) - goto failed; - - if ((ad_type > BT_AD_3D_INFO_DATA && - ad_type != BT_AD_MANUFACTURER_DATA) || - ad_type < BT_AD_FLAGS) { - goto failed; - } - - if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) - goto failed; - - pattern = new0(struct pattern, 1); + pattern = pattern_create(ad_type, offset, value_len, value); if (!pattern) goto failed; - pattern->ad_type = ad_type; - pattern->offset = offset; - pattern->length = value_len; - memcpy(pattern->value, value, pattern->length); - queue_push_tail(monitor->patterns, pattern); dbus_message_iter_next(&array_iter); @@ -961,6 +999,156 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) manager_destroy(manager); } +/* Matches the content based on the given pattern */ +bool btd_adv_monitor_pattern_match( + const uint8_t *eir, uint8_t eir_len, + const struct btd_adv_monitor_pattern *pattern) +{ + const uint8_t *data; + uint8_t idx = 0; + uint8_t field_len, data_len, data_type; + + while (idx < eir_len - 1) { + field_len = eir[0]; + + /* Check for the end of EIR */ + if (field_len == 0) + break; + + idx += field_len + 1; + + /* Do not continue filtering if got incorrect length */ + if (idx >= eir_len) + break; + + data = &eir[2]; + data_type = eir[1]; + data_len = field_len - 1; + + eir += field_len + 1; + + if (data_type != pattern->ad_type) + continue; + + if (data_len < pattern->offset + pattern->length) + continue; + + if (pattern->offset + pattern->length > BT_AD_MAX_DATA_LEN) + continue; + + if (!memcmp(data + pattern->offset, pattern->value, + pattern->length)) + return true; + } + + return false; +} + +/* Processes the content matching based on a pattern */ +static void adv_match_per_pattern(void *data, void *user_data) +{ + struct btd_adv_monitor_pattern *pattern = data; + struct adv_content_filter_info *info = user_data; + const uint8_t *eir = info->eir; + + if (!pattern || info->matched) + return; + + info->matched = btd_adv_monitor_pattern_match(info->eir, info->eir_len, + pattern); +} + +/* Processes the content matching based pattern(s) of a monitor */ +static void adv_match_per_monitor(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct adv_content_filter_info *info = user_data; + + if (!monitor && monitor->state != MONITOR_STATE_HONORED) + return; + + /* Reset the intermediate matched status */ + info->matched = false; + + if (monitor->type == MONITOR_TYPE_OR_PATTERNS) { + queue_foreach(monitor->patterns, adv_match_per_pattern, info); + if (info->matched) + goto matched; + } + + return; + +matched: + info->matched_monitors = g_slist_prepend(info->matched_monitors, + monitor); +} + +/* Processes the content matching for the monitor(s) of an app */ +static void adv_match_per_app(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + + if (!app) + return; + + queue_foreach(app->monitors, adv_match_per_monitor, user_data); +} + +/* Processes the content matching for every app without RSSI filtering and + * notifying monitors. The caller is responsible of releasing the memory of the + * list but not the data. + * Returns the list of monitors whose content match eir. + */ +GSList *btd_adv_monitor_content_filter(struct btd_adv_monitor_manager *manager, + const uint8_t *eir, uint8_t eir_len) +{ + if (!manager || !eir || !eir_len) + return NULL; + + struct adv_content_filter_info info = { + .eir_len = eir_len, + .eir = eir, + .matched_monitors = NULL, + }; + + queue_foreach(manager->apps, adv_match_per_app, &info); + + return info.matched_monitors; +} + +/* Wraps adv_monitor_filter_rssi() to processes the content-matched monitor with + * RSSI filtering and notifies it on device found/lost event + */ +static void monitor_filter_rssi(gpointer a, gpointer b) +{ + struct adv_monitor *monitor = a; + struct adv_rssi_filter_info *info = b; + + if (!monitor || !info) + return; + + adv_monitor_filter_rssi(monitor, info->device, info->rssi); +} + +/* Processes every content-matched monitor with RSSI filtering and notifies on + * device found/lost event. The caller is responsible of releasing the memory + * of matched_monitors list but not its data. + */ +void btd_adv_monitor_notify_monitors(struct btd_adv_monitor_manager *manager, + struct btd_device *device, int8_t rssi, + GSList *matched_monitors) +{ + if (!manager || !device || !matched_monitors) + return; + + struct adv_rssi_filter_info info = { + .device = device, + .rssi = rssi, + }; + + g_slist_foreach(matched_monitors, monitor_filter_rssi, &info); +} + /* Matches a device based on btd_device object */ static bool monitor_device_match(const void *a, const void *b) { diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 351e7f9aa..b660f5941 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -20,16 +20,28 @@ #ifndef __ADV_MONITOR_H #define __ADV_MONITOR_H +#include <glib.h> + +#include "src/shared/ad.h" + struct mgmt; struct btd_device; struct btd_adapter; struct btd_adv_monitor_manager; +struct btd_adv_monitor_pattern; struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct btd_adapter *adapter, struct mgmt *mgmt); void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); +GSList *btd_adv_monitor_content_filter(struct btd_adv_monitor_manager *manager, + const uint8_t *eir, uint8_t eir_len); + +void btd_adv_monitor_notify_monitors(struct btd_adv_monitor_manager *manager, + struct btd_device *device, int8_t rssi, + GSList *matched_monitors); + void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, struct btd_device *device); @@ -42,5 +54,12 @@ void btd_adv_monitor_rssi_test_teardown(void *monitor_obj); bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj); bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, int8_t adv_rssi); +struct btd_adv_monitor_pattern *btd_adv_monitor_test_pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value); +void btd_adv_monitor_test_pattern_destroy( + struct btd_adv_monitor_pattern *pattern); +bool btd_adv_monitor_pattern_match( + const uint8_t *eir, uint8_t eir_len, + const struct btd_adv_monitor_pattern *pattern); #endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CBYKAEEAY18OwgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:20:49 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 6LabOEAAY1+NnQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:20:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A3C1240973; Thu, 17 Sep 2020 08:20:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726196AbgIQGUl (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQGUk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:20:40 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F412C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:20:40 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id w7so564558pfi.4 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=urxZ2rQiREysBZDsBfYv1mq1DlCqCzpkhYSxNmpbsOc=; b=i5xl7K0C5CNXkzayq3ed0y1+AXkzc7WG1UWoTzALh69qcaL4WNAyfVqICaxRAdrMzk rwj1bFQl3EL/OGtZFbcV8JypJhXBrY9hYuJdn/SPFWYkUZq+6gLQ44JqlTiiU3Vc9LmG wVtZRdiQkcF0BzGTHQdWRo1TnpTP+jotb4aLI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=urxZ2rQiREysBZDsBfYv1mq1DlCqCzpkhYSxNmpbsOc=; b=YZFjMcIHkmiifKVM8zxGqidxBUV4evCeupYfpkZfFekoI/1V2f1vokilr7J88aguAS YcRI5X4h3mv1B+DtAh/r+CbGDhFDdmdeCWKMzyaqxN8sXe4aVHlVID2LnQcwdKG1iVVZ MSYYLN4m7bEMcAj64zoFCxxgnKN85dAVfXo5JgngV1BO+Rtm4ZiqJwkznAE21iMY39Sd z/eJpHwMpmeezAED4ge6s3eFS0AzpFMTkEGGfyXx10SV7apmYhmnOXc4tpQEEiX2JwQ9 r187eQyU7EoFvzVBsB39oJy10Clqf3hk8wvqC0CxreZQ1b3l1wYKHJUdcjKM0mGkK2lF DzRw== X-Gm-Message-State: AOAM531Zh0lkI3akWkC3iWWok+c2KKzDSEYDaDn33h3MTECs/MnIymNF mGyZUP/YyCGxcLCxatDpbf0C2enuWDSrdA== X-Google-Smtp-Source: ABdhPJxiML9PQ3edHPyKvJFZQ+AgtCY8EQG5tkuqV+in1yHbEJOBc55w5RN1BZIriYADSl36t58d1Q== X-Received: by 2002:a63:4d48:: with SMTP id n8mr22118848pgl.70.1600323639161; Wed, 16 Sep 2020 23:20:39 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id g23sm19264943pfh.133.2020.09.16.23.20.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 23:20:38 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v2 4/8] adv_monitor: Implement unit tests for content filter Date: Wed, 16 Sep 2020 23:19:46 -0700 Message-Id: <20200916231935.BlueZ.v2.4.I7f88b6e4c63c14d77974438eb2f07326aedbfd9b@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: A3C1240973 X-Rspamd-UID: 7ca4f0 This implements the unit tests for verifying the correctness of advertisement data fields matching against a pattern. Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v2: - Cast test data to void * doc/test-coverage.txt | 4 +- unit/test-adv-monitor.c | 144 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 2 deletions(-) diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt index 5296983e6..e15474a44 100644 --- a/doc/test-coverage.txt +++ b/doc/test-coverage.txt @@ -30,9 +30,9 @@ test-gobex-transfer 36 OBEX transfer handling test-gdbus-client 13 D-Bus client handling test-gatt 180 GATT qualification test cases test-hog 6 HID Over GATT qualification test cases -test-adv-monitor 5 Advertisement Monitor test cases +test-adv-monitor 9 Advertisement Monitor test cases ----- - 766 + 770 Automated end-to-end testing diff --git a/unit/test-adv-monitor.c b/unit/test-adv-monitor.c index 970be84b0..a19a3092b 100644 --- a/unit/test-adv-monitor.c +++ b/unit/test-adv-monitor.c @@ -40,6 +40,8 @@ if (type == TEST_RSSI_FILTER) { \ test.rssi_filter_test_data = (void *)&data; \ test.rssi_filter_test_data->test_info = &test; \ + } else if (type == TEST_CONTENT_FILTER) { \ + test.content_filter_test_data = (void *)&data; \ } \ tester_add(name, &test, setup_fn, test_fn, teardown_fn);\ } while (0) @@ -94,6 +96,22 @@ struct rssi_filter_test { } test_steps[]; }; +struct content_filter_test { + void *advmon_pattern; /* btd_adv_monitor_pattern */ + + bool expected_match; + + const struct { + uint8_t ad_type; + uint8_t offset; + uint8_t length; + uint8_t value[BT_AD_MAX_DATA_LEN]; + } pattern; + + uint8_t eir_len; + uint8_t eir[]; +}; + /* Parent data structure to hold the test data and information, * used by tester_* functions and callbacks. */ @@ -103,6 +121,7 @@ struct test_data { union { struct rssi_filter_test *rssi_filter_test_data; + struct content_filter_test *content_filter_test_data; }; }; @@ -211,6 +230,62 @@ static struct rssi_filter_test rssi_data_5 = { }, }; +/* Content Filter Test 1: + * The valid EIR data contains the given pattern whose content is a UUID16 AD + * data. + */ +static struct content_filter_test content_data_1 = { + .expected_match = true, + .pattern = {0x03, 0x02, 0x02, {0x09, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 2: + * The valid EIR data does not match the given pattern whose content is a UUID16 + * AD data. + */ +static struct content_filter_test content_data_2 = { + .expected_match = false, + .pattern = {0x03, 0x02, 0x02, {0x0d, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 3: + * The valid EIR data does not have the given pattern whose content is a UUID32 + * AD data. + */ +static struct content_filter_test content_data_3 = { + .expected_match = false, + .pattern = {0x05, 0x00, 0x04, {0x09, 0x18, 0x00, 0x00} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 4: + * The valid EIR data does not match the given pattern whose content is a + * UUID16 AD data due to invalid starting position of matching. + */ +static struct content_filter_test content_data_4 = { + .expected_match = false, + .pattern = {0x03, 0x02, 0x02, {0x09, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x03, 0x03, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + /* Initialize the data required for RSSI Filter test */ static void setup_rssi_filter_test(gpointer data) { @@ -343,6 +418,60 @@ static gboolean test_rssi_filter(gpointer data) return FALSE; } +/* Initialize the data required for Content Filter test */ +static void setup_content_filter_test(gpointer data) +{ + struct content_filter_test *test = data; + struct btd_adv_monitor_pattern *pattern = NULL; + + pattern = btd_adv_monitor_test_pattern_create(test->pattern.ad_type, + test->pattern.offset, + test->pattern.length, + test->pattern.value); + if (!pattern) { + tester_setup_failed(); + return; + } + + test->advmon_pattern = pattern; + tester_setup_complete(); +} + +/* Cleanup after the Content Filter test is done */ +static void teardown_content_filter_test(gpointer data) +{ + struct content_filter_test *test = data; + + if (!test) + tester_teardown_complete(); + + btd_adv_monitor_test_pattern_destroy(test->advmon_pattern); + test->advmon_pattern = NULL; + + tester_teardown_complete(); +} + +/* Execute the sub-steps of Content Filter test */ +static void test_content_filter(gpointer data) +{ + struct content_filter_test *test = data; + struct btd_adv_monitor_pattern *pattern = test->advmon_pattern; + + if (!pattern) { + tester_test_abort(); + return; + } + + if (btd_adv_monitor_pattern_match(test->eir, test->eir_len, + test->advmon_pattern) == + test->expected_match) { + tester_test_passed(); + return; + } + + tester_test_failed(); +} + /* Handler function to prepare for a test */ static void setup_handler(gconstpointer data) { @@ -350,6 +479,8 @@ static void setup_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) setup_rssi_filter_test(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + setup_content_filter_test(test->content_filter_test_data); } /* Handler function to cleanup after the test is done */ @@ -359,6 +490,8 @@ static void teardown_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) teardown_rssi_filter_test(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + teardown_content_filter_test(test->content_filter_test_data); } /* Handler function to execute a test with the given data set */ @@ -368,6 +501,8 @@ static void test_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) test_rssi_filter(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + test_content_filter(test->content_filter_test_data); } int main(int argc, char *argv[]) @@ -387,5 +522,14 @@ int main(int argc, char *argv[]) define_test("/advmon/rssi/5", TEST_RSSI_FILTER, rssi_data_5, setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/1", TEST_CONTENT_FILTER, content_data_1, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/2", TEST_CONTENT_FILTER, content_data_2, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/3", TEST_CONTENT_FILTER, content_data_3, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/4", TEST_CONTENT_FILTER, content_data_4, + setup_handler, test_handler, teardown_handler); + return tester_run(); } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IH+mHl8AY1/87gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:21:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YLa0G18AY19tkAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:21:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6F02540971; Thu, 17 Sep 2020 08:21:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726180AbgIQGVF (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQGVA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:21:00 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98B68C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:20:59 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id gf14so687217pjb.5 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u+E1bUX0uVxPcQEsE71u1Ro0+1uBNDa00K7AzDVg6ww=; b=JzMmoTcWN8r9fSmiCYVyLPGHh/4yWvxDpYqk069/aA0JUhS+nsf6IGucPO3ltdzFJf jASugceVLWrXVfiKMemt1bQEDNMTQMYzcqxO9sljNItL71/ackDP1tql0loY1YvzdZ64 /6lCuBdKbw81qjgDCBt1Ma4YGQDcBXd8gt8RI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u+E1bUX0uVxPcQEsE71u1Ro0+1uBNDa00K7AzDVg6ww=; b=GBKqUpsIqgmMz6hE7xKd1a1SUflt95085FsNLZKMd3LWIw41iEcu0O/o8+5EYUTBnb ne10RvCNadO/6k6WRYUb3L6safW6ISa9r/Do3BFPlqB4XtoguLehhsFnRueTVOztvEmr mw7vDvXQvoHD9Dzle48hODoGaeiEuBBdFnqJlvYtg58rRcfKsCMALJybQyrNw7DBmmGa akhDhVA5FjKTNw+QaxrssaYfn0D5BovkkO2xCTLElw6DRpmU33oeaoNGP1VqcY9N+t7q zd1wcKM8rai8OJxY7bPMqZiWNs5YV+9nQMiErJfdibYD9mjwTixplO9yPI19jKSj6uH5 pnlg== X-Gm-Message-State: AOAM532r4YpaUBrZVBW/Yz6IbZLBP3g7Wh2fOK569oQcJAXwvT7zdkV6 NXM3JaJp3yG6KMkH4mNRaBb7UVwULJyCbA== X-Google-Smtp-Source: ABdhPJxDipMIHXKpm3c6DmFyUw4IIzmnEx8rFamxqZGXE0sjF0YXtQziINFn+lAgKiCQcbITt0UhEg== X-Received: by 2002:a17:90a:297:: with SMTP id w23mr6897687pja.44.1600323658882; Wed, 16 Sep 2020 23:20:58 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id g23sm19264943pfh.133.2020.09.16.23.20.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 23:20:58 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v2 5/8] adapter: Clear all Adv monitors upon bring-up Date: Wed, 16 Sep 2020 23:19:48 -0700 Message-Id: <20200916231935.BlueZ.v2.5.Id6bfe7838831ae01fddc8605689dd77b51673960@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.72 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6F02540971 X-Rspamd-UID: 34155e This clears all Adv monitors upon daemon bring-up by issuing MGMT_OP_REMOVE_ADV_MONITOR command with monitor_handle 0. The following test was performed: - Add an Adv Monitor using btmgmt, restart bluetoothd and observe the monitor got removed. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Howard Chung <howardchung@google.com> --- (no changes since v1) src/adapter.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index d33ce7124..191467048 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -9513,6 +9513,43 @@ failed: btd_adapter_unref(adapter); } +static void reset_adv_monitors_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct mgmt_rp_remove_adv_monitor *rp = param; + + if (status != MGMT_STATUS_SUCCESS) { + error("Failed to reset Adv Monitors: %s (0x%02x)", + mgmt_errstr(status), status); + return; + } + + if (length < sizeof(*rp)) { + error("Wrong size of remove Adv Monitor response for reset " + "all Adv Monitors"); + return; + } + + DBG("Removed all Adv Monitors"); +} + +static void reset_adv_monitors(uint16_t index) +{ + struct mgmt_cp_remove_adv_monitor cp; + + DBG("sending remove Adv Monitor command with handle 0"); + + /* Handle 0 indicates to remove all */ + cp.monitor_handle = 0; + if (mgmt_send(mgmt_master, MGMT_OP_REMOVE_ADV_MONITOR, index, + sizeof(cp), &cp, reset_adv_monitors_complete, NULL, + NULL) > 0) { + return; + } + + error("Failed to reset Adv Monitors"); +} + static void index_added(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9527,6 +9564,8 @@ static void index_added(uint16_t index, uint16_t length, const void *param, return; } + reset_adv_monitors(index); + adapter = btd_adapter_new(index); if (!adapter) { btd_error(index, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kPa6GIvmYl/RYAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 06:31:07 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UKxrFYvmYl+rlgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 06:31:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 783BEA03FD; Thu, 17 Sep 2020 06:31:01 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726055AbgIQEbA (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 00:31:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQEa6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 00:30:58 -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 5F2F3C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:30:58 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id e4so434287pln.10 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c2LfisGBodWJ2VZe+1lCK+rnzd4eXqo9WSxoMVUCa+A=; b=C6BoqJW8HzN/JdBMMYMJwANuIaXmKjIYWiJqEkva4VrLKe2HVhsPAIU2zbPK3HaM91 7UdFKKjGMdzGUzQcwsr5bMk8sZjOn605IQreJCLcMV/xtt/LRjKIZGEXtXjh1RlS6Ct7 qFeubnwDSVtbDKaUMFif9yGkAcsR7OOo5GwQo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c2LfisGBodWJ2VZe+1lCK+rnzd4eXqo9WSxoMVUCa+A=; b=II2+M9VDjbL1s3uFF1pbhFq5Al3jF9fIZhRmGaLDj0C7CXkQ2dnwc9qVr0Xli33QjD Lux4e4fpLchXAn0wYvgmxymuxfOMeEfljCWlnm+/HxeJ5KgzMONKqr+Qw2EdLmCK/CZW rEw8nFYrdWxaaeKiMShTGPJc6ETr4x3QYiS6NAO7ri+IC0g/7edQ3LupuvVvXPjtPmX2 V0nVY2XXQt3HqdTbw9pJvxa4AhhtrA6TKWcFuddtmGOHSYwHSpysdeWcggil3cRi1Bk1 Nj23mFk7LIgbFzWo+nWZdqRADmT/cqE0cyx9quJrAS7X3Ir41V+9Er3ED+6FAZwkz9ha /qIw== X-Gm-Message-State: AOAM532119OOWc+9/Rvv8/3eJ4CzpupOgtHR0zP21dCidBRuBE8Q1o6g 0OsSPCNhyLdzB0AMV0pt3IUntFJDwUgRJA== X-Google-Smtp-Source: ABdhPJxMUpDFfwlDZOiF2a+AFgta3DKsIXC/g9MQddLuxOUuV0VPsSfdDRR/nEw9Sg16g8T5QwVXTA== X-Received: by 2002:a17:90a:db0f:: with SMTP id g15mr6861211pjv.145.1600317057552; Wed, 16 Sep 2020 21:30:57 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id 99sm4169562pjo.40.2020.09.16.21.30.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 21:30:56 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, chromeos-bluetooth-upstreaming@chromium.org, Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v1 4/8] adv_monitor: Implement unit tests for content filter Date: Wed, 16 Sep 2020 21:29:51 -0700 Message-Id: <20200916212926.BlueZ.v1.4.I7f88b6e4c63c14d77974438eb2f07326aedbfd9b@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: 783BEA03FD X-Rspamd-UID: 8711b0 This implements the unit tests for verifying the correctness of advertisement data fields matching against a pattern. Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- doc/test-coverage.txt | 4 +- unit/test-adv-monitor.c | 144 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 2 deletions(-) diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt index 5296983e6..e15474a44 100644 --- a/doc/test-coverage.txt +++ b/doc/test-coverage.txt @@ -30,9 +30,9 @@ test-gobex-transfer 36 OBEX transfer handling test-gdbus-client 13 D-Bus client handling test-gatt 180 GATT qualification test cases test-hog 6 HID Over GATT qualification test cases -test-adv-monitor 5 Advertisement Monitor test cases +test-adv-monitor 9 Advertisement Monitor test cases ----- - 766 + 770 Automated end-to-end testing diff --git a/unit/test-adv-monitor.c b/unit/test-adv-monitor.c index c9aab2bee..2182ec5c9 100644 --- a/unit/test-adv-monitor.c +++ b/unit/test-adv-monitor.c @@ -40,6 +40,8 @@ if (type == TEST_RSSI_FILTER) { \ test.rssi_filter_test_data = &data; \ test.rssi_filter_test_data->test_info = &test; \ + } else if (type == TEST_CONTENT_FILTER) { \ + test.content_filter_test_data = &data; \ } \ tester_add(name, &test, setup_fn, test_fn, teardown_fn);\ } while (0) @@ -94,6 +96,22 @@ struct rssi_filter_test { } test_steps[]; }; +struct content_filter_test { + void *advmon_pattern; /* btd_adv_monitor_pattern */ + + bool expected_match; + + const struct { + uint8_t ad_type; + uint8_t offset; + uint8_t length; + uint8_t value[BT_AD_MAX_DATA_LEN]; + } pattern; + + uint8_t eir_len; + uint8_t eir[]; +}; + /* Parent data structure to hold the test data and information, * used by tester_* functions and callbacks. */ @@ -103,6 +121,7 @@ struct test_data { union { struct rssi_filter_test *rssi_filter_test_data; + struct content_filter_test *content_filter_test_data; }; }; @@ -211,6 +230,62 @@ static struct rssi_filter_test rssi_data_5 = { }, }; +/* Content Filter Test 1: + * The valid EIR data contains the given pattern whose content is a UUID16 AD + * data. + */ +static struct content_filter_test content_data_1 = { + .expected_match = true, + .pattern = {0x03, 0x02, 0x02, {0x09, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 2: + * The valid EIR data does not match the given pattern whose content is a UUID16 + * AD data. + */ +static struct content_filter_test content_data_2 = { + .expected_match = false, + .pattern = {0x03, 0x02, 0x02, {0x0d, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 3: + * The valid EIR data does not have the given pattern whose content is a UUID32 + * AD data. + */ +static struct content_filter_test content_data_3 = { + .expected_match = false, + .pattern = {0x05, 0x00, 0x04, {0x09, 0x18, 0x00, 0x00} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 4: + * The valid EIR data does not match the given pattern whose content is a + * UUID16 AD data due to invalid starting position of matching. + */ +static struct content_filter_test content_data_4 = { + .expected_match = false, + .pattern = {0x03, 0x02, 0x02, {0x09, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x03, 0x03, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + /* Initialize the data required for RSSI Filter test */ static void setup_rssi_filter_test(gpointer data) { @@ -343,6 +418,60 @@ static gboolean test_rssi_filter(gpointer data) return FALSE; } +/* Initialize the data required for Content Filter test */ +static void setup_content_filter_test(gpointer data) +{ + struct content_filter_test *test = data; + struct btd_adv_monitor_pattern *pattern = NULL; + + pattern = btd_adv_monitor_test_pattern_create(test->pattern.ad_type, + test->pattern.offset, + test->pattern.length, + test->pattern.value); + if (!pattern) { + tester_setup_failed(); + return; + } + + test->advmon_pattern = pattern; + tester_setup_complete(); +} + +/* Cleanup after the Content Filter test is done */ +static void teardown_content_filter_test(gpointer data) +{ + struct content_filter_test *test = data; + + if (!test) + tester_teardown_complete(); + + btd_adv_monitor_test_pattern_destroy(test->advmon_pattern); + test->advmon_pattern = NULL; + + tester_teardown_complete(); +} + +/* Execute the sub-steps of Content Filter test */ +static void test_content_filter(gpointer data) +{ + struct content_filter_test *test = data; + struct btd_adv_monitor_pattern *pattern = test->advmon_pattern; + + if (!pattern) { + tester_test_abort(); + return; + } + + if (btd_adv_monitor_pattern_match(test->eir, test->eir_len, + test->advmon_pattern) == + test->expected_match) { + tester_test_passed(); + return; + } + + tester_test_failed(); +} + /* Handler function to prepare for a test */ static void setup_handler(gconstpointer data) { @@ -350,6 +479,8 @@ static void setup_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) setup_rssi_filter_test(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + setup_content_filter_test(test->content_filter_test_data); } /* Handler function to cleanup after the test is done */ @@ -359,6 +490,8 @@ static void teardown_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) teardown_rssi_filter_test(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + teardown_content_filter_test(test->content_filter_test_data); } /* Handler function to execute a test with the given data set */ @@ -368,6 +501,8 @@ static void test_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) test_rssi_filter(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + test_content_filter(test->content_filter_test_data); } int main(int argc, char *argv[]) @@ -387,5 +522,14 @@ int main(int argc, char *argv[]) define_test("/advmon/rssi/5", TEST_RSSI_FILTER, rssi_data_5, setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/1", TEST_CONTENT_FILTER, content_data_1, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/2", TEST_CONTENT_FILTER, content_data_2, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/3", TEST_CONTENT_FILTER, content_data_3, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/4", TEST_CONTENT_FILTER, content_data_4, + setup_handler, test_handler, teardown_handler); + return tester_run(); } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IEJUHJzmYl8ZqgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 06:31:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gBkCGZzmYl9tkAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 06:31:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D3330A0979; Thu, 17 Sep 2020 06:31:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726112AbgIQEbR (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 00:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQEbN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 00:31:13 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C16BC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:31:13 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id gf14so561288pjb.5 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tEXRaSOfGPBWZAounuJS1sb2LnFVUvkMbj2zMShq8aQ=; b=C3KJbgay55aBCx9y+3YFTpfwOBcZM90pYido0meEPcUkWBvktvZLOPVYFLkBDdDgHy hOFAT6dASZNLlompkLyQVJjO2nxjV5z50Wwy+AOASbOAXag3RF+oUaoKZ6/6LOY/22ev 8hZZunh6g1gd7ARH65wQUItmC6DENvrO3wLXY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tEXRaSOfGPBWZAounuJS1sb2LnFVUvkMbj2zMShq8aQ=; b=Ni3YDo+wX+RZx+h8IClElxdk3vDJz0vv2rhm30gkiYaESqxvMig6jCF5YK4mhG2vwV dVKRiGl7F+23HHipwhgHKJPA3JwXjZ9VqZ3SqeAfjun9WkAogmmAr+1BF0ByWjOy4Lh/ 3/suecFt9XoHioBfG1G5Zg8nk0X5vDi1pmP9CqHrGQ6lZbZSdj0e+ktxsXoxm3N2F3x/ bngHoSGh4VkDTd+ykbuXIhfxOfWWbQbpmlxgr1CTar3zo41EC7lBSLXlrAI3zi9jmbvj q8UU/pkEAtJsD+3YT7XyqXQnFgupj4uOq4jM3Z4ObxDnyQkN/97dbhuE2nXombRgo4UZ zT2w== X-Gm-Message-State: AOAM531SdnkD6IdtyyGBAn+nFfsZ2xbpyLFaXIMjSJsA0SFHqIIFBM7b G+jJhLGVpuJSNMzsLePu5xUtOHTLap7o5A== X-Google-Smtp-Source: ABdhPJzRwolEkmo3mUzGJuEW6NcFnszrrID0p1meEpm/7hR4+ZqSfgIvJDP0/nfFksTMU/dqBuxYVg== X-Received: by 2002:a17:90a:f187:: with SMTP id bv7mr6182491pjb.63.1600317071864; Wed, 16 Sep 2020 21:31:11 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id 99sm4169562pjo.40.2020.09.16.21.31.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 21:31:11 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, chromeos-bluetooth-upstreaming@chromium.org, Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v1 5/8] adapter: Clear all Adv monitors upon bring-up Date: Wed, 16 Sep 2020 21:29:53 -0700 Message-Id: <20200916212926.BlueZ.v1.5.Id6bfe7838831ae01fddc8605689dd77b51673960@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.70 / 15.00 / 15.00 X-Rspamd-Queue-Id: D3330A0979 X-Rspamd-UID: 21318b This clears all Adv monitors upon daemon bring-up by issuing MGMT_OP_REMOVE_ADV_MONITOR command with monitor_handle 0. The following test was performed: - Add an Adv Monitor using btmgmt, restart bluetoothd and observe the monitor got removed. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Howard Chung <howardchung@google.com> --- src/adapter.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index d33ce7124..191467048 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -9513,6 +9513,43 @@ failed: btd_adapter_unref(adapter); } +static void reset_adv_monitors_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct mgmt_rp_remove_adv_monitor *rp = param; + + if (status != MGMT_STATUS_SUCCESS) { + error("Failed to reset Adv Monitors: %s (0x%02x)", + mgmt_errstr(status), status); + return; + } + + if (length < sizeof(*rp)) { + error("Wrong size of remove Adv Monitor response for reset " + "all Adv Monitors"); + return; + } + + DBG("Removed all Adv Monitors"); +} + +static void reset_adv_monitors(uint16_t index) +{ + struct mgmt_cp_remove_adv_monitor cp; + + DBG("sending remove Adv Monitor command with handle 0"); + + /* Handle 0 indicates to remove all */ + cp.monitor_handle = 0; + if (mgmt_send(mgmt_master, MGMT_OP_REMOVE_ADV_MONITOR, index, + sizeof(cp), &cp, reset_adv_monitors_complete, NULL, + NULL) > 0) { + return; + } + + error("Failed to reset Adv Monitors"); +} + static void index_added(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9527,6 +9564,8 @@ static void index_added(uint16_t index, uint16_t length, const void *param, return; } + reset_adv_monitors(index); + adapter = btd_adapter_new(index); if (!adapter) { btd_error(index, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EOlIO6fmYl8ZqgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 06:31:35 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id mMqMOKfmYl8MqwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 06:31:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D82B6A016D; Thu, 17 Sep 2020 06:31:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726126AbgIQEb2 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 00:31:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQEbZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 00:31:25 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7BEFC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:31:24 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id u13so622637pgh.1 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AxRRQixA+r8jYAnKnxedVkrfYWv28pUQ9umLhhqumDQ=; b=UfEX1MYBZeK4JIkR7WOpvghwCM8b2F8+OVlsPdnYJ2tFUhwfpMnOjHroTkyGJuE1fK Vx3JABbinNcGXC1lsrQV/s8BDA7BJdId6MGcwygxj0sSV+5cT5cBf1QXjwJZ1VccWVzQ swZA/QtLM9EOxZt4srNB6Ky5JKE671/tAoUZo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AxRRQixA+r8jYAnKnxedVkrfYWv28pUQ9umLhhqumDQ=; b=W6ry0tWkbpdn+T+BtGlae/oilMBNgqW5Yra+0ftdi23hsv7KXgkntvhHAySbkP6Rz9 IFqqNegUf8ywB7Bff8FgjygzMk4e2+MJg+ReTv29Pn/3YqSJ9uybKFASooyZ/l7DVEUO tvvCuCO61mStKE2dSiL3yd0Laz1BykSj72jdx3JyT+fT7biKXDKtUEqZekLNSux8A5+r faHJnM3O+wfS1hAum5tPCA7f214Orni6JvwqD+Dr+Kwf33x5wOP9pQ30SsrY9G4KxDeK zRZ3to7PnYf4/tOAYF7Hpinn8aduB5s9xIieti/YR/kQUKLNYAlcmI6eMFew3U8C+Bm9 y+mQ== X-Gm-Message-State: AOAM532QwkbWvnaD226hUQbwzNCaQDdd1tytOk2PZhCpjNbWR6BruOfd SsWXfGyWFe+JmCpPOOgjJqkKzbySAICuFg== X-Google-Smtp-Source: ABdhPJzm2B8V1IuTCw8mN1nqn7h2fcG9/f8R1P1JIf4lW7qvxzwi4+uibS4DAJhnofl7WTqzAw9Q8w== X-Received: by 2002:a63:5943:: with SMTP id j3mr19941574pgm.392.1600317084168; Wed, 16 Sep 2020 21:31:24 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id 99sm4169562pjo.40.2020.09.16.21.31.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 21:31:23 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, chromeos-bluetooth-upstreaming@chromium.org, Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v1 6/8] adv_monitor: Implement Add Adv Patterns Monitor cmd handler Date: Wed, 16 Sep 2020 21:29:55 -0700 Message-Id: <20200916212926.BlueZ.v1.6.Ibbcb11712b613ef95c31b41207c3ea945c830018@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.41 / 15.00 / 15.00 X-Rspamd-Queue-Id: D82B6A016D X-Rspamd-UID: c27224 From: Howard Chung <howardchung@google.com> - Send the MGMT_OP command to kernel upon registration of a Adv patterns monitor. - Call Activate() or Release() to client depending on the reply from kernel the call through syslog Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- src/adv_monitor.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 4f86384e9..bce99eace 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -609,11 +609,59 @@ done: return monitor->state != MONITOR_STATE_FAILED; } +/* Handles the callback of Add Adv Patterns Monitor command */ +static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_rp_add_adv_patterns_monitor *rp = param; + struct adv_monitor *monitor = user_data; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(adapter_id, "Failed to Add Adv Patterns Monitor " + "with status 0x%02x", status); + monitor_release(monitor, NULL); + return; + } + + if (length < sizeof(*rp)) { + btd_error(adapter_id, "Wrong size of Add Adv Patterns Monitor " + "response"); + monitor_release(monitor, NULL); + return; + } + + monitor->state = MONITOR_STATE_HONORED; + + DBG("Calling Activate() on Adv Monitor of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "Activate", NULL, NULL, NULL, + NULL); + + DBG("Adv Monitor with handle:0x%04x added", + le16_to_cpu(rp->monitor_handle)); +} + +static void monitor_copy_patterns(void *data, void *user_data) +{ + struct btd_adv_monitor_pattern *pattern = data; + struct mgmt_cp_add_adv_monitor *cp = user_data; + + if (!pattern) + return; + + memcpy(cp->patterns + cp->pattern_count, pattern, sizeof(*pattern)); + cp->pattern_count++; +} + /* Handles an Adv Monitor D-Bus proxy added event */ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) { struct adv_monitor *monitor; struct adv_monitor_app *app = user_data; + struct mgmt_cp_add_adv_monitor *cp = NULL; + uint8_t pattern_count, cp_len; uint16_t adapter_id = app->manager->adapter_id; const char *path = g_dbus_proxy_get_path(proxy); const char *iface = g_dbus_proxy_get_interface(proxy); @@ -646,7 +694,24 @@ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) queue_push_tail(app->monitors, monitor); + pattern_count = queue_length(monitor->patterns); + cp_len = sizeof(struct mgmt_cp_add_adv_monitor) + + pattern_count * sizeof(struct mgmt_adv_pattern); + + cp = malloc0(cp_len); + queue_foreach(monitor->patterns, monitor_copy_patterns, cp); + + if (!mgmt_send(app->manager->mgmt, MGMT_OP_ADD_ADV_PATTERNS_MONITOR, + adapter_id, cp_len, cp, add_adv_patterns_monitor_cb, + monitor, NULL)) { + error("Unable to send Add Adv Patterns Monitor command"); + goto done; + } + DBG("Adv Monitor allocated for the object at path %s", path); + +done: + free(cp); } /* Handles the removal of an Adv Monitor D-Bus proxy */ @@ -1064,7 +1129,7 @@ static void adv_match_per_monitor(void *data, void *user_data) struct adv_monitor *monitor = data; struct adv_content_filter_info *info = user_data; - if (!monitor && monitor->state != MONITOR_STATE_HONORED) + if (!monitor || monitor->state != MONITOR_STATE_HONORED) return; /* Reset the intermediate matched status */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CKTHIrLmYl8ZqgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 06:31:46 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 6BW6H7LmYl9tkAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 06:31:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9AD88A0B18; Thu, 17 Sep 2020 06:31:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726129AbgIQEbj (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 00:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQEbi (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 00:31:38 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F7D0C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:31:36 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id r19so457274pls.1 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=daf2BKPAlz2gjCKtI6e7fRoHHFts5ohWp7Y5onbVEMw=; b=Hg94jSRxB93Bf3QUq5EqQJOgpMoYUXxTZ4GZszy0HgFWjUy1d8qtN4CxZ0fTzlLMk8 Ob3TJ1XzaXUs3Lhpm284ZT+hOfF2uREFmK7IhthdeeuM8P4U96A+zl1zl1mjeCM3lsUN mAV4xvnALEINayHu3e4RZA0zC7uhuBjpu1vqo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=daf2BKPAlz2gjCKtI6e7fRoHHFts5ohWp7Y5onbVEMw=; b=IhrN7AnJAJw1GUnKDT3LjktzO7gdO3CqWTzuUHzB7JV35+zWVa89LOn6ruSLe8yfbj L6KBRx1dV2EHI0O0TzfALvd6My1ts472MpBxa4whQTbO30iIPxEW31vtzvDRdrZN+2Vv rRqD3yr7G9yQZaA749IgcDkwMGztChoSZJ9RXIYcIlH30B1ZaxodU3JFDSTUhfkaWasH G+jiWalZ5yXgRe3cEtg4n16iO23bmaGUHkgERenA5RstrskHrLH6faN3Y+UG45TJhv78 sJmbfG1kdf4IHcRHHxdVCZj+8UXOeJxGd8qHgK7iahSpN8Rp7sVddlX5vl1gyDNF+vbh /B3Q== X-Gm-Message-State: AOAM533mk4zxuvnKsBDW7eQIsKodkfe/QUBO9ZfilFkLwT6ssB2qd1Pp mZbXBE6s8nj1/wbO0hk90IiOJykO2lRaDQ== X-Google-Smtp-Source: ABdhPJwlQo3pqW45z8q09vDedKqvHdnSwAUCZpaX3n6orI+wn81wenClMCJ6BAWwQQOdAxjLsiK4sg== X-Received: by 2002:a17:902:b103:b029:d1:e5e7:be06 with SMTP id q3-20020a170902b103b02900d1e5e7be06mr9410808plr.57.1600317095317; Wed, 16 Sep 2020 21:31:35 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id 99sm4169562pjo.40.2020.09.16.21.31.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 21:31:34 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, chromeos-bluetooth-upstreaming@chromium.org, Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v1 7/8] adv_monitor: Fix return type of RegisterMonitor() method Date: Wed, 16 Sep 2020 21:29:57 -0700 Message-Id: <20200916212926.BlueZ.v1.7.Ic8dbe9115e82704b4c0c860eee27ad897db13237@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.73 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9AD88A0B18 X-Rspamd-UID: dcfaf6 This modifies the D-Bus call return type to be asynchronous for RegisterMonitor() method call. The following test was performed: - Enter bluetoothctl, exit the console and re-enter the console without AlreadyExist error for RegisterMonitor() upon bring-up of the console. Reviewed-by: Howard Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- src/adv_monitor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index bce99eace..6dfb777b2 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -758,6 +758,8 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, app->monitors = queue_new(); + app->reg = dbus_message_ref(msg); + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); /* Note that any property changes on a monitor object would not affect @@ -769,8 +771,6 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); - app->reg = dbus_message_ref(msg); - return app; } @@ -864,7 +864,7 @@ static DBusMessage *unregister_monitor(DBusConnection *conn, } static const GDBusMethodTable adv_monitor_methods[] = { - { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qCr0BsDmYl+drgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 06:32:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iKF9A8DmYl9wnwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 06:32:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C2703A01F5; Thu, 17 Sep 2020 06:31:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726135AbgIQEbw (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 00:31:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQEbt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 00:31:49 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5389BC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:31:49 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id y1so604295pgk.8 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:31:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PRVAYlW9F2+p3NelGjnNxfWtRphiywOUmHbfTokD++M=; b=cLsWEDf2vhWzm/Vnk/zcC2+DJpsgg8HLQvP0WSLNp4A0M1Q+fKA8aKNCJo7AvMCCd0 h01g9zUwdVi8M/g16JnW6MqfaXsz+1ypVWGQyZXXncuErXv2XQgR/sHCYMgUcnLP8M8n XjKTcAvDTH7a/y3ZGFccie2JRmR2zJwybv9gk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PRVAYlW9F2+p3NelGjnNxfWtRphiywOUmHbfTokD++M=; b=YnYJg1FL0WwdHVRXkac4vDBxS9551mGv0qGWzoGXUbZvqM00XwnJt9xGyE4fXgivmj JAq25qrQ7crD1DRwM28a15/vfc7GcyWMOfj7FQDAPuIfGO1//H3G4VyVZnh5JKtEkL7G yrCp4JWO+Tr5nMFba0IcR8a2I2tE20KQjkiDJstF8BF67J3f2TNDY/bOXFzmP6qeHfxL sNKW9l1LxAduu7FQ0C/8XpOemwbQRU8j5RjBBIv4LnMxUSzOQ6wZxBN2dCOQ9u1ykyk6 pU38OPGYZepDHRaTjz9m0GrY5gL0NUV1Ea5wbGoQX1ZKtZPhbcmM+N0meMBMSpMiGqZ3 918Q== X-Gm-Message-State: AOAM533l96ngYe4+mkUCaaVpKR7QkuLVpqmSwY4I1rBPQ8aT9VR7t1gI spZsLGEQ/CRn5U+pZ6RqNNc4Pgwz3dPRsA== X-Google-Smtp-Source: ABdhPJyg9sZO570pNiRCaa3UYkpM9n0B9Jf3RnDrA82Jy7oxzv9+PWqM1A16GxqQ6D3uZcvSG6pASQ== X-Received: by 2002:aa7:989a:0:b029:142:2501:34da with SMTP id r26-20020aa7989a0000b0290142250134damr9781521pfl.51.1600317108502; Wed, 16 Sep 2020 21:31:48 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id 99sm4169562pjo.40.2020.09.16.21.31.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 21:31:47 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, chromeos-bluetooth-upstreaming@chromium.org, Alain Michaud <alainm@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org> Subject: [BlueZ PATCH v1 8/8] adv_monitor: Issue Remove Adv Monitor mgmt call Date: Wed, 16 Sep 2020 21:29:59 -0700 Message-Id: <20200916212926.BlueZ.v1.8.Ifda683c92ff520bf58ac37c02dc40b8d9598d1b0@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.17 / 15.00 / 15.00 X-Rspamd-Queue-Id: C2703A01F5 X-Rspamd-UID: 10ea0f From: Alain Michaud <alainm@chromium.org> This calls Remove Adv Monitor command to kernel and handles the callback during a monitor removal initiated by a D-Bus client. This also registers callback for getting notified on Adv Monitor Removed event, so that the Adv monitor manager can invalidate the monitor by calling Release() on its proxy. The following tests were performed. - In bluetoothctl console, add a monitor and remove the monitor by its index and verify the removal in both the output of btmgmt and syslog. - In bluetoothctl console, add a monitor, remove the monitor via btmgmt and verify the removal in syslog. Reviewed-by: Howard Chung <howardchung@google.com> --- src/adv_monitor.c | 129 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 121 insertions(+), 8 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 6dfb777b2..d599e91c2 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -88,6 +88,7 @@ enum monitor_state { MONITOR_STATE_FAILED, /* Failed to be init'ed */ MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ MONITOR_STATE_HONORED, /* Accepted by kernel */ + MONITOR_STATE_REMOVING, /* Removing from kernel */ }; struct btd_adv_monitor_pattern { @@ -103,6 +104,7 @@ struct adv_monitor { char *path; enum monitor_state state; /* MONITOR_STATE_* */ + uint16_t monitor_handle; /* Kernel Monitor Handle */ int8_t high_rssi; /* High RSSI threshold */ uint16_t high_rssi_timeout; /* High RSSI threshold timeout */ @@ -631,6 +633,7 @@ static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, return; } + monitor->monitor_handle = le16_to_cpu(rp->monitor_handle); monitor->state = MONITOR_STATE_HONORED; DBG("Calling Activate() on Adv Monitor of owner %s at path %s", @@ -639,8 +642,7 @@ static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, g_dbus_proxy_method_call(monitor->proxy, "Activate", NULL, NULL, NULL, NULL); - DBG("Adv Monitor with handle:0x%04x added", - le16_to_cpu(rp->monitor_handle)); + DBG("Adv monitor with handle:0x%04x added", monitor->monitor_handle); } static void monitor_copy_patterns(void *data, void *user_data) @@ -714,20 +716,78 @@ done: free(cp); } +/* Handles the callback of Remove Adv Monitor command */ +static void remove_adv_monitor_cb(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct adv_monitor *monitor = user_data; + const struct mgmt_rp_remove_adv_monitor *rp = param; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(adapter_id, "Failed to Remove Adv Monitor with " + "status 0x%02x", status); + goto done; + } + + if (length < sizeof(*rp)) { + btd_error(adapter_id, "Wrong size of Remove Adv Monitor " + "response"); + goto done; + } + +done: + queue_remove(monitor->app->monitors, monitor); + + DBG("Adv Monitor removed with handle:0x%04x, path %s", + monitor->monitor_handle, monitor->path); + + monitor_free(monitor); +} + + /* Handles the removal of an Adv Monitor D-Bus proxy */ static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) { struct adv_monitor *monitor; + struct mgmt_cp_remove_adv_monitor cp; struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + const char *path = g_dbus_proxy_get_path(proxy); - monitor = queue_remove_if(app->monitors, monitor_match, proxy); - if (monitor) { - DBG("Adv Monitor removed for the object at path %s", - monitor->path); + monitor = queue_find(app->monitors, monitor_match, proxy); - /* The object was gone, so we don't need to call Release() */ - monitor_free(monitor); + /* A monitor removed event from kernel can remove a monitor and notify + * the app on Release() where this callback can be invoked, so we + * simply skip here. + */ + if (!monitor) + return; + + if (monitor->state != MONITOR_STATE_HONORED) + goto done; + + monitor->state = MONITOR_STATE_REMOVING; + + cp.monitor_handle = cpu_to_le16(monitor->monitor_handle); + + if (!mgmt_send(app->manager->mgmt, MGMT_OP_REMOVE_ADV_MONITOR, + adapter_id, sizeof(cp), &cp, remove_adv_monitor_cb, + monitor, NULL)) { + btd_error(adapter_id, "Unable to send Remove Advt Monitor " + "command"); + goto done; } + + return; + +done: + queue_remove(app->monitors, monitor); + + DBG("Adv Monitor removed in state %02x with path %s", monitor->state, + monitor->path); + + monitor_free(monitor); } /* Creates an app object, initiates it and sets D-Bus event handlers */ @@ -936,6 +996,55 @@ static const GDBusPropertyTable adv_monitor_properties[] = { { } }; +/* Matches a monitor based on its handle */ +static bool removed_monitor_match(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct mgmt_ev_adv_monitor_removed *ev = user_data; + + return monitor->monitor_handle == ev->monitor_handle; +} + +/* Remove the matched monitor and reports the removal to the app */ +static void app_remove_monitor(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + struct adv_monitor *monitor; + + monitor = queue_find(app->monitors, removed_monitor_match, user_data); + if (monitor) { + if (monitor->state == MONITOR_STATE_HONORED) + monitor_release(monitor, NULL); + + queue_remove(app->monitors, monitor); + + DBG("Adv Monitor at path %s removed", monitor->path); + + monitor_free(monitor); + } +} + +/* Processes Adv Monitor removed event from kernel */ +static void adv_monitor_removed_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + struct mgmt_ev_adv_monitor_removed *ev = param; + struct btd_adv_monitor_manager *manager = user_data; + const uint16_t adapter_id = manager->adapter_id; + + if (length < sizeof(*ev)) { + btd_error(adapter_id, "Wrong size of Adv Monitor Removed " + "event"); + return; + } + + /* Traverse the apps to find the monitor */ + queue_foreach(manager->apps, app_remove_monitor, ev); + + DBG("Adv Monitor removed event with handle 0x%04x processed", + ev->monitor_handle); +} + /* Allocates a manager object */ static struct btd_adv_monitor_manager *manager_new( struct btd_adapter *adapter, @@ -955,6 +1064,10 @@ static struct btd_adv_monitor_manager *manager_new( manager->adapter_id = btd_adapter_get_index(adapter); manager->apps = queue_new(); + mgmt_register(manager->mgmt, MGMT_EV_ADV_MONITOR_REMOVED, + manager->adapter_id, adv_monitor_removed_callback, + manager, NULL); + return manager; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sWxAKyPrYl8J8wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 06:50:43 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QGaWJyPrYl8PWgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 06:50:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E1FD740876; Thu, 17 Sep 2020 06:50:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726007AbgIQEuh (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 00:50:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQEuh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 00:50:37 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55D81C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:50:37 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id w12so1012201qki.6 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=i9Sl0F9P8LkdySdG8WzA0EgTK0D2DDOLL0jbDf3Ahc4=; b=VsJM4Z5uv3efGt8AlKBgZ4XohZOPDD7vzGBkUR0vDVSGeLNbkeQ0Z++/qylAlynege RwR/vknVR/UHoeMDc6ymv5Tf0Ktag+DA+d4pAsqzAxREfM60YvukIvlxkU7J0Dpj201q FyZX+bkaj184vj6jZKOPsBxWKy9v8zz6ha2XhDVWm4GhaAywhjmfBd+6avqADJajDYco +IO64iH4cGfY0uOGBXSp2t1lWndNb7SsdvbVfqD2eH9Pl8Nnf8TOFGpA0UT2/bStVITl TvWxQPUXxXn84tcyCauw1XybbqWkNVDfa/2snrx/BUPX/pY/j9eWcezXkdJgU6W0cOSG AZjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=i9Sl0F9P8LkdySdG8WzA0EgTK0D2DDOLL0jbDf3Ahc4=; b=EFKGddQG3CBkygq+bimmec7QP/gVDwPSyo0GXUI3/jUqUfV5Rd2ZTMfawDVUWBz7FM UqTywVmW+Q2+zKSKGncRPLf3aNh0lna/XDH1RyLEwuVGLOfkLSvAmPDSq56rgBAXUDfE PxPZr+fBhbYgM17Sn9aOTgj9rovjfqqfQcNfrVE18tKX+YV6+eA/3nTT9x0e77fsCeKK Hrto4NgEvoziv4QEc7z42d7iLEc4bGPC3xYrxOGixl0hiMu0eWy0AcyikG0uOQ3vcniD 46arCexCBcFS4NL3CUn2qCm7QMtYbg5a+wRG1uNJRSbQ+qBEapiBeR6iauEjVplfWYJ5 KQmw== X-Gm-Message-State: AOAM531OLr+bF2VnSYF3PXXWG5vNuTbgM13p/kLD8AhmrQ7SPE7zitwK ZPpkqoX+v5c3EZXya6GGPZDHU5RMUuTyog== X-Google-Smtp-Source: ABdhPJxD2+aU/a3I2Of7YIUAYsIX+eVRMeWVNxIUaK/68dpL1V/VZ+B922NWlZegoFjJLX3HTZppgA== X-Received: by 2002:a37:4a94:: with SMTP id x142mr25294285qka.27.1600318236465; Wed, 16 Sep 2020 21:50:36 -0700 (PDT) Received: from [172.17.0.2] ([13.68.17.141]) by smtp.gmail.com with ESMTPSA id k26sm3666560qtf.35.2020.09.16.21.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 21:50:35 -0700 (PDT) Message-ID: <5f62eb1b.1c69fb81.fd05e.6157@mx.google.com> Date: Wed, 16 Sep 2020 21:50:35 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============5288157599522859432==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v1,2/8] adv_monitor: Implement unit tests for RSSI Filter Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200916212926.BlueZ.v1.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> References: <20200916212926.BlueZ.v1.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.58 / 15.00 / 15.00 X-Rspamd-Queue-Id: E1FD740876 X-Rspamd-UID: db52af --===============5288157599522859432== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #163: FILE: unit/test-adv-monitor.c:1: +/* - total: 0 errors, 1 warnings, 512 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============5288157599522859432==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wLJaAKnrYl+f1gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 06:52:57 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2HnyOKjrYl+NnQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 06:52:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 87A7240618; Thu, 17 Sep 2020 06:52:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726157AbgIQEwu (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 00:52:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbgIQEws (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 00:52:48 -0400 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E752EC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:52:47 -0700 (PDT) Received: by mail-qv1-xf32.google.com with SMTP id j3so368141qvi.7 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 21:52:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=nM8KYr/2ZlTZDc2W1I2j6QpgsiikYXp5ZZ/92MsC3yQ=; b=hGbEuOiNccTaS9tIqCGCVDnKRonPrFuQ/UqHolxa2Ko5e/6SysVw95avNRVtx/drRW gj2yI1B5LPomgiNSTZQ5FgZy3nLEerRm/gcKDGQpuqCyPX4RE4JEplxjhzDdPqqh/zAv e5+9D6PcvRR64P9g8La+7USeEv8F0QxMByI2qd/k/wi1OPmvJ0DApNhjoMXxBFmwkjHR B69VPgvytIVbcmxA40w97lyawGafuunk88xucM+QUPFiv9Y+yb3HmkVX7IYk1aSyjm0F KJ6KJ9MVeHI48yH0xHjP+gY8Ep6+NwJywlPwIBPE4s8HYq4ZsLhjdEF1KNeQyZrmZ25+ apxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=nM8KYr/2ZlTZDc2W1I2j6QpgsiikYXp5ZZ/92MsC3yQ=; b=NFgYPzfuBQATSgl8NXA687FpwH4bl2wKlconJE5GUZwR/y5A7HVHKdUk91S7Oe+au4 59thMI81SwJgS00EqGQP9rP56Kp3BfGQMRKAxcL1dkfzcQZ/ZGu/bgyb2otkziww90J8 QKtMPfsE60ePoJtjDn/WX7qUvk+VJhDdTECAmxLUB82vT/cjsjUFJsR6b5ZP0cqyKFE9 X87zC8bL79BHqCayQd/MC5iBXz6Xsxq7dTIsaiCszm/Wt4j8mafVcjDhwmPT8eli17D0 jhtyI5k38TentgluqPPzu2bpJ1Vu0a7IMWTu1sHYsiJCWoNqR261Q5UEn8VKSLYtx42E Nrjg== X-Gm-Message-State: AOAM5322/b7RJ/g83CL3OC64UEVGv7jv4D81X18h/++KRSrvZDHMsC5z P+wUGkQGikHXebwl4bZJf98w+EtttEQ2mQ== X-Google-Smtp-Source: ABdhPJzS7tjsE6J2mPi1bFkNbXtfFBDoNjy56uwP4oogtvBPepV/9UUj+K/lh4MzbACRKaZpfwBkgA== X-Received: by 2002:a0c:ac4c:: with SMTP id m12mr10618644qvb.39.1600318366933; Wed, 16 Sep 2020 21:52:46 -0700 (PDT) Received: from [172.17.0.2] ([13.68.17.141]) by smtp.gmail.com with ESMTPSA id 7sm21133680qkh.60.2020.09.16.21.52.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 21:52:46 -0700 (PDT) Message-ID: <5f62eb9e.1c69fb81.2c581.2a2a@mx.google.com> Date: Wed, 16 Sep 2020 21:52:46 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============6331770682660432333==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v1,1/8] adv_monitor: Implement RSSI Filter logic for background scanning Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916212926.BlueZ.v1.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.25 / 15.00 / 15.00 X-Rspamd-Queue-Id: 87A7240618 X-Rspamd-UID: c41965 --===============6331770682660432333== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnVuaXQvdGVzdC1hZHYtbW9uaXRvci5jOiBJbiBmdW5jdGlvbiDigJht YWlu4oCZOgp1bml0L3Rlc3QtYWR2LW1vbml0b3IuYzo0NDozNDogZXJyb3I6IGFzc2lnbm1lbnQg dG8g4oCYc3RydWN0IGNvbnRlbnRfZmlsdGVyX3Rlc3QgKuKAmSBmcm9tIGluY29tcGF0aWJsZSBw b2ludGVyIHR5cGUg4oCYc3RydWN0IHJzc2lfZmlsdGVyX3Rlc3QgKuKAmSBbLVdlcnJvcj1pbmNv bXBhdGlibGUtcG9pbnRlci10eXBlc10KICAgNDQgfCAgICB0ZXN0LmNvbnRlbnRfZmlsdGVyX3Rl c3RfZGF0YSA9ICZkYXRhOyAgXAogICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIF4KdW5pdC90ZXN0LWFkdi1tb25pdG9yLmM6NTE0OjI6IG5vdGU6IGluIGV4cGFuc2lvbiBv ZiBtYWNybyDigJhkZWZpbmVfdGVzdOKAmQogIDUxNCB8ICBkZWZpbmVfdGVzdCgiL2Fkdm1vbi9y c3NpLzEiLCBURVNUX1JTU0lfRklMVEVSLCByc3NpX2RhdGFfMSwKICAgICAgfCAgXn5+fn5+fn5+ fn4KdW5pdC90ZXN0LWFkdi1tb25pdG9yLmM6NDQ6MzQ6IGVycm9yOiBhc3NpZ25tZW50IHRvIOKA mHN0cnVjdCBjb250ZW50X2ZpbHRlcl90ZXN0ICrigJkgZnJvbSBpbmNvbXBhdGlibGUgcG9pbnRl ciB0eXBlIOKAmHN0cnVjdCByc3NpX2ZpbHRlcl90ZXN0ICrigJkgWy1XZXJyb3I9aW5jb21wYXRp YmxlLXBvaW50ZXItdHlwZXNdCiAgIDQ0IHwgICAgdGVzdC5jb250ZW50X2ZpbHRlcl90ZXN0X2Rh dGEgPSAmZGF0YTsgIFwKICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBe CnVuaXQvdGVzdC1hZHYtbW9uaXRvci5jOjUxNjoyOiBub3RlOiBpbiBleHBhbnNpb24gb2YgbWFj cm8g4oCYZGVmaW5lX3Rlc3TigJkKICA1MTYgfCAgZGVmaW5lX3Rlc3QoIi9hZHZtb24vcnNzaS8y IiwgVEVTVF9SU1NJX0ZJTFRFUiwgcnNzaV9kYXRhXzIsCiAgICAgIHwgIF5+fn5+fn5+fn5+CnVu aXQvdGVzdC1hZHYtbW9uaXRvci5jOjQ0OjM0OiBlcnJvcjogYXNzaWdubWVudCB0byDigJhzdHJ1 Y3QgY29udGVudF9maWx0ZXJfdGVzdCAq4oCZIGZyb20gaW5jb21wYXRpYmxlIHBvaW50ZXIgdHlw ZSDigJhzdHJ1Y3QgcnNzaV9maWx0ZXJfdGVzdCAq4oCZIFstV2Vycm9yPWluY29tcGF0aWJsZS1w b2ludGVyLXR5cGVzXQogICA0NCB8ICAgIHRlc3QuY29udGVudF9maWx0ZXJfdGVzdF9kYXRhID0g JmRhdGE7ICBcCiAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXgp1bml0 L3Rlc3QtYWR2LW1vbml0b3IuYzo1MTg6Mjogbm90ZTogaW4gZXhwYW5zaW9uIG9mIG1hY3JvIOKA mGRlZmluZV90ZXN04oCZCiAgNTE4IHwgIGRlZmluZV90ZXN0KCIvYWR2bW9uL3Jzc2kvMyIsIFRF U1RfUlNTSV9GSUxURVIsIHJzc2lfZGF0YV8zLAogICAgICB8ICBefn5+fn5+fn5+fgp1bml0L3Rl c3QtYWR2LW1vbml0b3IuYzo0NDozNDogZXJyb3I6IGFzc2lnbm1lbnQgdG8g4oCYc3RydWN0IGNv bnRlbnRfZmlsdGVyX3Rlc3QgKuKAmSBmcm9tIGluY29tcGF0aWJsZSBwb2ludGVyIHR5cGUg4oCY c3RydWN0IHJzc2lfZmlsdGVyX3Rlc3QgKuKAmSBbLVdlcnJvcj1pbmNvbXBhdGlibGUtcG9pbnRl ci10eXBlc10KICAgNDQgfCAgICB0ZXN0LmNvbnRlbnRfZmlsdGVyX3Rlc3RfZGF0YSA9ICZkYXRh OyAgXAogICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF4KdW5pdC90ZXN0 LWFkdi1tb25pdG9yLmM6NTIwOjI6IG5vdGU6IGluIGV4cGFuc2lvbiBvZiBtYWNybyDigJhkZWZp bmVfdGVzdOKAmQogIDUyMCB8ICBkZWZpbmVfdGVzdCgiL2Fkdm1vbi9yc3NpLzQiLCBURVNUX1JT U0lfRklMVEVSLCByc3NpX2RhdGFfNCwKICAgICAgfCAgXn5+fn5+fn5+fn4KdW5pdC90ZXN0LWFk di1tb25pdG9yLmM6NDQ6MzQ6IGVycm9yOiBhc3NpZ25tZW50IHRvIOKAmHN0cnVjdCBjb250ZW50 X2ZpbHRlcl90ZXN0ICrigJkgZnJvbSBpbmNvbXBhdGlibGUgcG9pbnRlciB0eXBlIOKAmHN0cnVj dCByc3NpX2ZpbHRlcl90ZXN0ICrigJkgWy1XZXJyb3I9aW5jb21wYXRpYmxlLXBvaW50ZXItdHlw ZXNdCiAgIDQ0IHwgICAgdGVzdC5jb250ZW50X2ZpbHRlcl90ZXN0X2RhdGEgPSAmZGF0YTsgIFwK ICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBeCnVuaXQvdGVzdC1hZHYt bW9uaXRvci5jOjUyMjoyOiBub3RlOiBpbiBleHBhbnNpb24gb2YgbWFjcm8g4oCYZGVmaW5lX3Rl c3TigJkKICA1MjIgfCAgZGVmaW5lX3Rlc3QoIi9hZHZtb24vcnNzaS81IiwgVEVTVF9SU1NJX0ZJ TFRFUiwgcnNzaV9kYXRhXzUsCiAgICAgIHwgIF5+fn5+fn5+fn5+CnVuaXQvdGVzdC1hZHYtbW9u aXRvci5jOjQxOjMxOiBlcnJvcjogYXNzaWdubWVudCB0byDigJhzdHJ1Y3QgcnNzaV9maWx0ZXJf dGVzdCAq4oCZIGZyb20gaW5jb21wYXRpYmxlIHBvaW50ZXIgdHlwZSDigJhzdHJ1Y3QgY29udGVu dF9maWx0ZXJfdGVzdCAq4oCZIFstV2Vycm9yPWluY29tcGF0aWJsZS1wb2ludGVyLXR5cGVzXQog ICA0MSB8ICAgIHRlc3QucnNzaV9maWx0ZXJfdGVzdF9kYXRhID0gJmRhdGE7ICBcCiAgICAgIHwg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXgp1bml0L3Rlc3QtYWR2LW1vbml0b3IuYzo1 MjU6Mjogbm90ZTogaW4gZXhwYW5zaW9uIG9mIG1hY3JvIOKAmGRlZmluZV90ZXN04oCZCiAgNTI1 IHwgIGRlZmluZV90ZXN0KCIvYWR2bW9uL2NvbnRlbnQvMSIsIFRFU1RfQ09OVEVOVF9GSUxURVIs IGNvbnRlbnRfZGF0YV8xLAogICAgICB8ICBefn5+fn5+fn5+fgp1bml0L3Rlc3QtYWR2LW1vbml0 b3IuYzo0MTozMTogZXJyb3I6IGFzc2lnbm1lbnQgdG8g4oCYc3RydWN0IHJzc2lfZmlsdGVyX3Rl c3QgKuKAmSBmcm9tIGluY29tcGF0aWJsZSBwb2ludGVyIHR5cGUg4oCYc3RydWN0IGNvbnRlbnRf ZmlsdGVyX3Rlc3QgKuKAmSBbLVdlcnJvcj1pbmNvbXBhdGlibGUtcG9pbnRlci10eXBlc10KICAg NDEgfCAgICB0ZXN0LnJzc2lfZmlsdGVyX3Rlc3RfZGF0YSA9ICZkYXRhOyAgXAogICAgICB8ICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIF4KdW5pdC90ZXN0LWFkdi1tb25pdG9yLmM6NTI3 OjI6IG5vdGU6IGluIGV4cGFuc2lvbiBvZiBtYWNybyDigJhkZWZpbmVfdGVzdOKAmQogIDUyNyB8 ICBkZWZpbmVfdGVzdCgiL2Fkdm1vbi9jb250ZW50LzIiLCBURVNUX0NPTlRFTlRfRklMVEVSLCBj b250ZW50X2RhdGFfMiwKICAgICAgfCAgXn5+fn5+fn5+fn4KdW5pdC90ZXN0LWFkdi1tb25pdG9y LmM6NDE6MzE6IGVycm9yOiBhc3NpZ25tZW50IHRvIOKAmHN0cnVjdCByc3NpX2ZpbHRlcl90ZXN0 ICrigJkgZnJvbSBpbmNvbXBhdGlibGUgcG9pbnRlciB0eXBlIOKAmHN0cnVjdCBjb250ZW50X2Zp bHRlcl90ZXN0ICrigJkgWy1XZXJyb3I9aW5jb21wYXRpYmxlLXBvaW50ZXItdHlwZXNdCiAgIDQx IHwgICAgdGVzdC5yc3NpX2ZpbHRlcl90ZXN0X2RhdGEgPSAmZGF0YTsgIFwKICAgICAgfCAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBeCnVuaXQvdGVzdC1hZHYtbW9uaXRvci5jOjUyOToy OiBub3RlOiBpbiBleHBhbnNpb24gb2YgbWFjcm8g4oCYZGVmaW5lX3Rlc3TigJkKICA1MjkgfCAg ZGVmaW5lX3Rlc3QoIi9hZHZtb24vY29udGVudC8zIiwgVEVTVF9DT05URU5UX0ZJTFRFUiwgY29u dGVudF9kYXRhXzMsCiAgICAgIHwgIF5+fn5+fn5+fn5+CnVuaXQvdGVzdC1hZHYtbW9uaXRvci5j OjQxOjMxOiBlcnJvcjogYXNzaWdubWVudCB0byDigJhzdHJ1Y3QgcnNzaV9maWx0ZXJfdGVzdCAq 4oCZIGZyb20gaW5jb21wYXRpYmxlIHBvaW50ZXIgdHlwZSDigJhzdHJ1Y3QgY29udGVudF9maWx0 ZXJfdGVzdCAq4oCZIFstV2Vycm9yPWluY29tcGF0aWJsZS1wb2ludGVyLXR5cGVzXQogICA0MSB8 ICAgIHRlc3QucnNzaV9maWx0ZXJfdGVzdF9kYXRhID0gJmRhdGE7ICBcCiAgICAgIHwgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgXgp1bml0L3Rlc3QtYWR2LW1vbml0b3IuYzo1MzE6Mjog bm90ZTogaW4gZXhwYW5zaW9uIG9mIG1hY3JvIOKAmGRlZmluZV90ZXN04oCZCiAgNTMxIHwgIGRl ZmluZV90ZXN0KCIvYWR2bW9uL2NvbnRlbnQvNCIsIFRFU1RfQ09OVEVOVF9GSUxURVIsIGNvbnRl bnRfZGF0YV80LAogICAgICB8ICBefn5+fn5+fn5+fgpjYzE6IGFsbCB3YXJuaW5ncyBiZWluZyB0 cmVhdGVkIGFzIGVycm9ycwptYWtlWzFdOiAqKiogW01ha2VmaWxlOjY4NjM6IHVuaXQvdGVzdC1h ZHYtbW9uaXRvci5vXSBFcnJvciAxCm1ha2U6ICoqKiBbTWFrZWZpbGU6NDA1NjogYWxsXSBFcnJv ciAyCgoKCi0tLQpSZWdhcmRzLApMaW51eCBCbHVldG9vdGgK --===============6331770682660432333==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0K/ELmX0Yl/a4AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 07:30:13 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id MEDmK2X0Yl9rvAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 07:30:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A0B444096B; Thu, 17 Sep 2020 07:30:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726236AbgIQFaB (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 01:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQF35 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 01:29:57 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2EF9C06178B for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:29:56 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id c197so687706pfb.23 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 22:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=YQ1655qN+qhX6YCMDSPy+e2SuugQXtZ9Fa++9er50gQ=; b=VSqNFvjA/X3aLl2qE0HJI68GKOFNKiAMMyz4/syIfFQ5NrOAfOh86MZhBh2o78ZBYg agGANrpqmC9BOGUDUf4McWX7j5LM4pSSDKJxEAd++MVeCmO9bvSs1PPyMM+rRGLZ9W1w IlTQxJuGf2rBK7PJ/CrcntP1Wg4p5bA25Dy1T0WBsXavJAUeV1ITIiI+7eHvt4amVPpR G0e2dqir/lLtZAL7EqGLFFggwAgcu93+RFoSFp5TRH/BvrYy0HE9laVfx2uD+E5rlq4h hDkKaW3Y+m5g7fOIjvNrYYE6fY+/hyTBwER0S14z8tlMC5+zwMmyOEliC/dire9A7rbt FQuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=YQ1655qN+qhX6YCMDSPy+e2SuugQXtZ9Fa++9er50gQ=; b=OGDLt5ef8GA3Lnh0UTpZJ24PNbkQvMGrvw8Wy0G89vCBDp9peHZpVUAVLBbunE0V8/ KE/sIGOPJrPusewzJETsIfCIl3hr4tkJnIzB6AKm3iEF6r+GyizxvkjQ4J5LMPxxNZT5 3C9sVvRud29arrSRpQGa6wP+Mu67kutUEfvLEnKjAE12pBEcuvhwhKoo0bp60J69t1a6 oN6qXojcwis7ATRDfQZ6Bv0vU75HWpC/R3w6ECJ4YfmNHKZUgIanJRrhXFskS/7FL2R5 rAHSLdOaL3KeMPXv6FM/7rEXPpvn1YDr4/4pyCaZygbismaG/kzbxXdGcoEgLst8MGmK M+pQ== X-Gm-Message-State: AOAM5321qZ9zgMg3JUvcsz68/7CV4FHxt+LGkkK+JaYSk0rduLJTqhp5 d9WmvY6NsxVH1V3y212VkltoKZe6DrIFhyikSUmDHXY5gMZzz+1wD1mk8D1B/vmjZGasTRYjLQw cew/+S6B+ABWatzL8Q15pxVo9WEN+ZLnT5iuDvkU3YEHS6NHqx/C7qC4TtJBDy71xFJhEiExvNg A9ZtNMKyFnHY0= X-Google-Smtp-Source: ABdhPJwMtqDMRo/qzuQTUjmjcUBuXEHB34dSJ2yFT85VAU4hVI+C9CpisXk2IT48G4YNLAq++aB4VptZnE9BnOBGnA== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:902:c401:b029:d1:e603:1bf3 with SMTP id k1-20020a170902c401b02900d1e6031bf3mr9554753plk.47.1600320595984; Wed, 16 Sep 2020 22:29:55 -0700 (PDT) Date: Thu, 17 Sep 2020 13:29:40 +0800 In-Reply-To: <20200917132836.BlueZ.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200917132836.BlueZ.3.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Mime-Version: 1.0 References: <20200917132836.BlueZ.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH 3/6] Bluetooth: Interleave with allowlist scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, marcel@holtmann.org, mmandlik@chromium.org, howardchung@google.com, luiz.dentz@gmail.com, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: A0B444096B X-Rspamd-UID: 1c70aa This patch implements the interleaving between allowlist scan and no-filter scan. It'll be used to save power when at least one monitor is registered and at least one pending connection or one device to be scanned for. The durations of the allowlist scan and the no-filter scan are controlled by MGMT command: Set Default System Configuration. The default values are set randomly for now. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- include/net/bluetooth/hci_core.h | 10 +++ net/bluetooth/hci_core.c | 4 + net/bluetooth/hci_request.c | 137 +++++++++++++++++++++++++++++-- net/bluetooth/mgmt_config.c | 13 +++ 4 files changed, 156 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9873e1c8cd163..179350f869fdb 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -361,6 +361,8 @@ struct hci_dev { __u8 ssp_debug_mode; __u8 hw_error_code; __u32 clock; + __u16 advmon_allowlist_duration; + __u16 advmon_no_filter_duration; __u16 devid_source; __u16 devid_vendor; @@ -542,6 +544,14 @@ struct hci_dev { struct delayed_work rpa_expired; bdaddr_t rpa; + enum { + ADV_MONITOR_SCAN_NONE, + ADV_MONITOR_SCAN_NO_FILTER, + ADV_MONITOR_SCAN_ALLOWLIST + } adv_monitor_scan_state; + + struct delayed_work interleave_adv_monitor_scan; + #if IS_ENABLED(CONFIG_BT_LEDS) struct led_trigger *power_led; #endif diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f30a1f5950e15..6c8850149265a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3592,6 +3592,10 @@ struct hci_dev *hci_alloc_dev(void) hdev->cur_adv_instance = 0x00; hdev->adv_instance_timeout = 0; + /* The default values will be chosen in the future */ + hdev->advmon_allowlist_duration = 300; + hdev->advmon_no_filter_duration = 500; + hdev->sniff_max_interval = 800; hdev->sniff_min_interval = 80; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index d2b06f5c93804..89443b48d90ce 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -378,6 +378,57 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable) hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type); } +static void start_interleave_scan(struct hci_dev *hdev) +{ + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; + queue_delayed_work(hdev->req_workqueue, + &hdev->interleave_adv_monitor_scan, 0); +} + +static bool is_interleave_scanning(struct hci_dev *hdev) +{ + return hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_NONE; +} + +static void cancel_interleave_scan(struct hci_dev *hdev) +{ + bt_dev_dbg(hdev, "%s cancelling interleave scan", hdev->name); + + cancel_delayed_work_sync(&hdev->interleave_adv_monitor_scan); + + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NONE; +} + +/* Return true if interleave_scan is running after exiting this function, + * otherwise, return false + */ +static bool update_adv_monitor_scan_state(struct hci_dev *hdev) +{ + if (!hci_is_adv_monitoring(hdev) || + (list_empty(&hdev->pend_le_conns) && + list_empty(&hdev->pend_le_reports))) { + if (is_interleave_scanning(hdev)) { + /* If the interleave condition no longer holds, cancel + * the existed interleave scan. + */ + cancel_interleave_scan(hdev); + } + return false; + } + + if (!is_interleave_scanning(hdev)) { + /* If there is at least one ADV monitors and one pending LE + * connection or one device to be scanned for, we should + * alternate between allowlist scan and one without any filters + * to save power. + */ + start_interleave_scan(hdev); + bt_dev_dbg(hdev, "%s starting interleave scan", hdev->name); + } + + return true; +} + /* This function controls the background scanning based on hdev->pend_le_conns * list. If there are pending LE connection we start the background scanning, * otherwise we stop it. @@ -449,9 +500,11 @@ static void __hci_update_background_scan(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) hci_req_add_le_scan_disable(req, false); - hci_req_add_le_passive_scan(req); - - BT_DBG("%s starting background scanning", hdev->name); + if (!update_adv_monitor_scan_state(hdev)) { + hci_req_add_le_passive_scan(req); + bt_dev_dbg(hdev, "%s starting background scanning", + hdev->name); + } } } @@ -844,12 +897,17 @@ static u8 update_white_list(struct hci_request *req) return 0x00; } - /* Once the controller offloading of advertisement monitor is in place, - * the if condition should include the support of MSFT extension - * support. If suspend is ongoing, whitelist should be the default to - * prevent waking by random advertisements. + /* Use the allowlist unless the following conditions are all true: + * - We are not currently suspending + * - There are 1 or more ADV monitors registered + * - Interleaved scanning is not currently using the allowlist + * + * Once the controller offloading of advertisement monitor is in place, + * the above condition should include the support of MSFT extension + * support. */ - if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended) + if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended && + hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_ALLOWLIST) return 0x00; /* Select filter policy to use white list */ @@ -1002,6 +1060,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) &own_addr_type)) return; + bt_dev_dbg(hdev, "interleave state %d", hdev->adv_monitor_scan_state); /* Adding or removing entries from the white list must * happen before enabling scanning. The controller does * not allow white list modification while scanning. @@ -1871,6 +1930,64 @@ static void adv_timeout_expire(struct work_struct *work) hci_dev_unlock(hdev); } +static int add_le_interleave_adv_monitor_scan(struct hci_request *req, + unsigned long opt) +{ + struct hci_dev *hdev = req->hdev; + int ret = 0; + + hci_dev_lock(hdev); + + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + hci_req_add_le_scan_disable(req, false); + hci_req_add_le_passive_scan(req); + + switch (hdev->adv_monitor_scan_state) { + case ADV_MONITOR_SCAN_ALLOWLIST: + bt_dev_dbg(hdev, "next state: allowlist"); + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; + break; + case ADV_MONITOR_SCAN_NO_FILTER: + bt_dev_dbg(hdev, "next state: no filter"); + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_ALLOWLIST; + break; + case ADV_MONITOR_SCAN_NONE: + default: + BT_ERR("unexpected error"); + ret = -1; + } + + hci_dev_unlock(hdev); + + return ret; +} + +static void interleave_adv_monitor_scan_work(struct work_struct *work) +{ + struct hci_dev *hdev = container_of(work, struct hci_dev, + interleave_adv_monitor_scan.work); + u8 status; + unsigned long timeout; + + if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_ALLOWLIST) { + timeout = msecs_to_jiffies(hdev->advmon_allowlist_duration); + } else if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_NO_FILTER) { + timeout = msecs_to_jiffies(hdev->advmon_no_filter_duration); + } else { + bt_dev_err(hdev, "unexpected error"); + return; + } + + hci_req_sync(hdev, add_le_interleave_adv_monitor_scan, 0, + HCI_CMD_TIMEOUT, &status); + + /* Don't continue interleaving if it was canceled */ + if (is_interleave_scanning(hdev)) { + queue_delayed_work(hdev->req_workqueue, + &hdev->interleave_adv_monitor_scan, timeout); + } +} + int hci_get_random_address(struct hci_dev *hdev, bool require_privacy, bool use_rpa, struct adv_info *adv_instance, u8 *own_addr_type, bdaddr_t *rand_addr) @@ -3292,6 +3409,8 @@ void hci_request_setup(struct hci_dev *hdev) INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); INIT_DELAYED_WORK(&hdev->le_scan_restart, le_scan_restart_work); INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire); + INIT_DELAYED_WORK(&hdev->interleave_adv_monitor_scan, + interleave_adv_monitor_scan_work); } void hci_request_cancel_all(struct hci_dev *hdev) @@ -3311,4 +3430,6 @@ void hci_request_cancel_all(struct hci_dev *hdev) cancel_delayed_work_sync(&hdev->adv_instance_expire); hdev->adv_instance_timeout = 0; } + + cancel_interleave_scan(hdev); } diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index b30b571f8caf8..6dc3e43dcaa9f 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -67,6 +67,8 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, HDEV_PARAM_U16(0x001a, le_supv_timeout), HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b, def_le_autoconnect_timeout), + HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), + HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -138,6 +140,9 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x0019: case 0x001a: case 0x001b: + case 0x001c: + case 0x001d: + case 0x001e: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -251,6 +256,14 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, hdev->def_le_autoconnect_timeout = msecs_to_jiffies(TLV_GET_LE16(buffer)); break; + case 0x0001d: + hdev->advmon_allowlist_duration = + TLV_GET_LE16(buffer); + break; + case 0x0001e: + hdev->advmon_no_filter_duration = + TLV_GET_LE16(buffer); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2BnNLGUAY1/87gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:21:25 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id qGpBKWUAY18ImgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:21:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A7FCF4096F; Thu, 17 Sep 2020 08:21:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726198AbgIQGVO (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:21:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQGVL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:21:11 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74837C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:21:11 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id y1so745935pgk.8 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nI1lwirMpvm4vWon80g2srfXuKwwNNQq9kNumv3r5qY=; b=THOmwBKwB518USHayCzZrRr6x/02THcFpkMElLTjp/ufUahUJfK30pwOyJZVXd5qPn OnIKrS7HkMPcUt1fKWkIRbKRu5umCUlN8DJhNzNxAbHB5JgqFgP/vzRoQwOLba/bfJbM rXMoBpVeor3inCxIIeNmfGQ5G05F/HlYn6P8U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nI1lwirMpvm4vWon80g2srfXuKwwNNQq9kNumv3r5qY=; b=ZEITvzUR13LKI+X5I78ImR3SiMeLFxGmpMmERzTP6xws7LLbW5wkQQWp3AuIfxB3Q9 1yvNqGZf8lUeYVPN6jl7MZGxLdIArxINZow7lUvJZzxrwJFOOKT9RkBc4/Tqpo7tucbb x+3f0O+93geem6JUXzq+BW7bqxrtJF74yvOJxluOSD8GBo6ywsqIP2qpU1KOwINElTgP ++rXL67qvx8Z0x/26i+fGkF10aRpgmcgtK3sfy9dLhEzhlYLRHJ18PIEO+lVKASgUE3s as6weLPonyMYi2EO0KLtf/5GYAj07MDpPf59mBoRyF9TdieYKtiu/AWisl9PYvsi8LkB mUuQ== X-Gm-Message-State: AOAM5328QFbm6+koL9vgkaXEXYesT0gqC7H4xBH7EB3bNvyAEL6fVffx ySm48waEBOA5b7q1gOl0200AQLBcJj96tA== X-Google-Smtp-Source: ABdhPJxDpG0XjkjxYIVQTvZGbLfHSPGwHaS7+nvDjI+36+/0QTYfmrxRKoLe68xxm3B4pvN9YbY/tw== X-Received: by 2002:a63:c543:: with SMTP id g3mr21695867pgd.203.1600323670533; Wed, 16 Sep 2020 23:21:10 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id g23sm19264943pfh.133.2020.09.16.23.21.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 23:21:09 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v2 6/8] adv_monitor: Implement Add Adv Patterns Monitor cmd handler Date: Wed, 16 Sep 2020 23:19:50 -0700 Message-Id: <20200916231935.BlueZ.v2.6.Ibbcb11712b613ef95c31b41207c3ea945c830018@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.82 / 15.00 / 15.00 X-Rspamd-Queue-Id: A7FCF4096F X-Rspamd-UID: ad7575 From: Howard Chung <howardchung@google.com> - Send the MGMT_OP command to kernel upon registration of a Adv patterns monitor. - Call Activate() or Release() to client depending on the reply from kernel the call through syslog Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 4f86384e9..bce99eace 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -609,11 +609,59 @@ done: return monitor->state != MONITOR_STATE_FAILED; } +/* Handles the callback of Add Adv Patterns Monitor command */ +static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_rp_add_adv_patterns_monitor *rp = param; + struct adv_monitor *monitor = user_data; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(adapter_id, "Failed to Add Adv Patterns Monitor " + "with status 0x%02x", status); + monitor_release(monitor, NULL); + return; + } + + if (length < sizeof(*rp)) { + btd_error(adapter_id, "Wrong size of Add Adv Patterns Monitor " + "response"); + monitor_release(monitor, NULL); + return; + } + + monitor->state = MONITOR_STATE_HONORED; + + DBG("Calling Activate() on Adv Monitor of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "Activate", NULL, NULL, NULL, + NULL); + + DBG("Adv Monitor with handle:0x%04x added", + le16_to_cpu(rp->monitor_handle)); +} + +static void monitor_copy_patterns(void *data, void *user_data) +{ + struct btd_adv_monitor_pattern *pattern = data; + struct mgmt_cp_add_adv_monitor *cp = user_data; + + if (!pattern) + return; + + memcpy(cp->patterns + cp->pattern_count, pattern, sizeof(*pattern)); + cp->pattern_count++; +} + /* Handles an Adv Monitor D-Bus proxy added event */ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) { struct adv_monitor *monitor; struct adv_monitor_app *app = user_data; + struct mgmt_cp_add_adv_monitor *cp = NULL; + uint8_t pattern_count, cp_len; uint16_t adapter_id = app->manager->adapter_id; const char *path = g_dbus_proxy_get_path(proxy); const char *iface = g_dbus_proxy_get_interface(proxy); @@ -646,7 +694,24 @@ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) queue_push_tail(app->monitors, monitor); + pattern_count = queue_length(monitor->patterns); + cp_len = sizeof(struct mgmt_cp_add_adv_monitor) + + pattern_count * sizeof(struct mgmt_adv_pattern); + + cp = malloc0(cp_len); + queue_foreach(monitor->patterns, monitor_copy_patterns, cp); + + if (!mgmt_send(app->manager->mgmt, MGMT_OP_ADD_ADV_PATTERNS_MONITOR, + adapter_id, cp_len, cp, add_adv_patterns_monitor_cb, + monitor, NULL)) { + error("Unable to send Add Adv Patterns Monitor command"); + goto done; + } + DBG("Adv Monitor allocated for the object at path %s", path); + +done: + free(cp); } /* Handles the removal of an Adv Monitor D-Bus proxy */ @@ -1064,7 +1129,7 @@ static void adv_match_per_monitor(void *data, void *user_data) struct adv_monitor *monitor = data; struct adv_content_filter_info *info = user_data; - if (!monitor && monitor->state != MONITOR_STATE_HONORED) + if (!monitor || monitor->state != MONITOR_STATE_HONORED) return; /* Reset the intermediate matched status */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oJ9XLHUAY1/87gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:21:41 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uCXQKXUAY19JYQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:21:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 385B840973; Thu, 17 Sep 2020 08:21:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726241AbgIQGVZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQGVW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:21:22 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0945DC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:21:22 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id kk9so694501pjb.2 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:21:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rfbzG45/ZVPfYtToxz75HKregAJxFeEORwOPk5JyveQ=; b=axSQUbfyl9x3BKPvQg2jJ3Ksay0a3BAIYeOe8Yrle7yEPBSq2vlysygzIO4jNNOE7V PZWHYREG/LbBBUGDAYuDctfolhRjELn7fj35SCoU+MMRokBoPAw4nJUlgbdgXfSR3vQN o9XrlDW2zvrGGBiOBnAucQ7Xq+J+fZACJWxN0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rfbzG45/ZVPfYtToxz75HKregAJxFeEORwOPk5JyveQ=; b=VmxItUPHTAK+FJCrtt0GqE1mypV9nYn4/XzQin7121XWR9oMzaKpruZYLK9AtIqJDw jNb4f4FsF+LBA9kUsrS2UaZeGpoDkJl8Yrv3/OqA7nGt72AnYqOYYagop4QKro1wjNuN gtr3pmLGwI1mGdLOYKAVkVBxRlk8+5bSVjt4o4z1N3FFCkNqwQwOx/jsm0iQOSPV9pMZ x7AwxqYINb4i9OSI6oPhLHO24TTNM5Kzdh1TTorw5YeKOkD6Xu/lr+bPweu5ggETiLI4 +CGvdg7nZMoinLXdsprIviS5kdIvSKp2fNHTg+losdgrAjQPyTHRctutd6zUuhd+Bo5C DLXw== X-Gm-Message-State: AOAM531i6uwdfkkE6j+P8kl7pfLl7DKKQmClF4nivfIArOzLzmicm3bp gbjKz4EUpsRDFsKX/b3RVX1NdnZPH/JATQ== X-Google-Smtp-Source: ABdhPJzJw1cyvl6uNDprStCioRfBpLRgwLsRU164kN/g6Dl/VjaL6zhzlxbv+TtL4lhKXpZG5Pe3CA== X-Received: by 2002:a17:902:a585:b029:d0:afd3:d851 with SMTP id az5-20020a170902a585b02900d0afd3d851mr27942255plb.2.1600323681292; Wed, 16 Sep 2020 23:21:21 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id g23sm19264943pfh.133.2020.09.16.23.21.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 23:21:20 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v2 7/8] adv_monitor: Fix return type of RegisterMonitor() method Date: Wed, 16 Sep 2020 23:19:52 -0700 Message-Id: <20200916231935.BlueZ.v2.7.Ic8dbe9115e82704b4c0c860eee27ad897db13237@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.83 / 15.00 / 15.00 X-Rspamd-Queue-Id: 385B840973 X-Rspamd-UID: d1bbf2 This modifies the D-Bus call return type to be asynchronous for RegisterMonitor() method call. The following test was performed: - Enter bluetoothctl, exit the console and re-enter the console without AlreadyExist error for RegisterMonitor() upon bring-up of the console. Reviewed-by: Howard Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index bce99eace..6dfb777b2 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -758,6 +758,8 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, app->monitors = queue_new(); + app->reg = dbus_message_ref(msg); + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); /* Note that any property changes on a monitor object would not affect @@ -769,8 +771,6 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); - app->reg = dbus_message_ref(msg); - return app; } @@ -864,7 +864,7 @@ static DBusMessage *unregister_monitor(DBusConnection *conn, } static const GDBusMethodTable adv_monitor_methods[] = { - { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QGUpE3wAY1/87gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:21:48 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id uJFaEHwAY18fCQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:21:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E39C040966; Thu, 17 Sep 2020 08:21:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726249AbgIQGVj (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:21:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgIQGVj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:21:39 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E3C3C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:21:38 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id c3so575893plz.5 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vhAjw9iYH+HwEhcHX+OUR7w1h7BFvlaDCjF8rrfdvdM=; b=R5W+KZCr0YguQHAnaPX5jjriJ4OCgJMBhAZr/sT5PKf4+g33RBzu/Wnl1RxxvaQl1K FSMwVUEW2xn7JbgR1TG1MW6G2tRokr93jSOT8XX6+ejY16Cq/gCGN1w9LKneixnpmGFx FBCMN9bidR1crblkL/K8IdVMHm5xggqwB/3QM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vhAjw9iYH+HwEhcHX+OUR7w1h7BFvlaDCjF8rrfdvdM=; b=kDTKnOeEJXptPnS3e5BRGyKxJGBV8oT76xyZpxCx0CBWpN+rKW/GMpCrBGxQ5pd3YO eo6g3K4q+16Vqi8rIiJ8r+CVqO7Q5RqcBXcRwLDbY8u84+234MUq3geEIkvutmIXrZhM Zhu9VLQXLIXziCvp2qAxLLBHB2pn8+pUVpU4ONI5ZpqxyPLQK6XAf8H6iSR/RFx2s5Uy 6JAwlVu1uE/4Xtni3O0pJLjNEnh6Tq6mp7Y+GGhFjfga186+1XAw9ixWwNVaBJ6GIKPB RK2hVxPLrIb9LK1kR/fBB9d2XPDhbH2wioood06zGNU9ZOB2JfuX7mrvGtsOdhVm7igi gdpg== X-Gm-Message-State: AOAM530dk/dth+5iKgPX2cwbvQ65DCVIQUdUYzLG73HsmPWUJZHFfQXq wzStNUJQgxSTGRzkNGtv0Rqyw1gilfFfmA== X-Google-Smtp-Source: ABdhPJxIN6D0htTeJ/ubYGsmvTOl2KqoPfw7/P7eJzygFeK9TAnRZjBo1DwbrusgxKWvPMhr8iKk+A== X-Received: by 2002:a17:902:a509:b029:d0:cb2d:f26e with SMTP id s9-20020a170902a509b02900d0cb2df26emr26192755plq.7.1600323696144; Wed, 16 Sep 2020 23:21:36 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id g23sm19264943pfh.133.2020.09.16.23.21.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 23:21:35 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Subject: [BlueZ PATCH v2 8/8] adv_monitor: Issue Remove Adv Monitor mgmt call Date: Wed, 16 Sep 2020 23:19:54 -0700 Message-Id: <20200916231935.BlueZ.v2.8.Ifda683c92ff520bf58ac37c02dc40b8d9598d1b0@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.17 / 15.00 / 15.00 X-Rspamd-Queue-Id: E39C040966 X-Rspamd-UID: 228f50 From: Alain Michaud <alainm@chromium.org> This calls Remove Adv Monitor command to kernel and handles the callback during a monitor removal initiated by a D-Bus client. This also registers callback for getting notified on Adv Monitor Removed event, so that the Adv monitor manager can invalidate the monitor by calling Release() on its proxy. The following tests were performed. - In bluetoothctl console, add a monitor and remove the monitor by its index and verify the removal in both the output of btmgmt and syslog. - In bluetoothctl console, add a monitor, remove the monitor via btmgmt and verify the removal in syslog. Reviewed-by: Howard Chung <howardchung@google.com> --- (no changes since v1) src/adv_monitor.c | 129 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 121 insertions(+), 8 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 6dfb777b2..d599e91c2 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -88,6 +88,7 @@ enum monitor_state { MONITOR_STATE_FAILED, /* Failed to be init'ed */ MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ MONITOR_STATE_HONORED, /* Accepted by kernel */ + MONITOR_STATE_REMOVING, /* Removing from kernel */ }; struct btd_adv_monitor_pattern { @@ -103,6 +104,7 @@ struct adv_monitor { char *path; enum monitor_state state; /* MONITOR_STATE_* */ + uint16_t monitor_handle; /* Kernel Monitor Handle */ int8_t high_rssi; /* High RSSI threshold */ uint16_t high_rssi_timeout; /* High RSSI threshold timeout */ @@ -631,6 +633,7 @@ static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, return; } + monitor->monitor_handle = le16_to_cpu(rp->monitor_handle); monitor->state = MONITOR_STATE_HONORED; DBG("Calling Activate() on Adv Monitor of owner %s at path %s", @@ -639,8 +642,7 @@ static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, g_dbus_proxy_method_call(monitor->proxy, "Activate", NULL, NULL, NULL, NULL); - DBG("Adv Monitor with handle:0x%04x added", - le16_to_cpu(rp->monitor_handle)); + DBG("Adv monitor with handle:0x%04x added", monitor->monitor_handle); } static void monitor_copy_patterns(void *data, void *user_data) @@ -714,20 +716,78 @@ done: free(cp); } +/* Handles the callback of Remove Adv Monitor command */ +static void remove_adv_monitor_cb(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct adv_monitor *monitor = user_data; + const struct mgmt_rp_remove_adv_monitor *rp = param; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(adapter_id, "Failed to Remove Adv Monitor with " + "status 0x%02x", status); + goto done; + } + + if (length < sizeof(*rp)) { + btd_error(adapter_id, "Wrong size of Remove Adv Monitor " + "response"); + goto done; + } + +done: + queue_remove(monitor->app->monitors, monitor); + + DBG("Adv Monitor removed with handle:0x%04x, path %s", + monitor->monitor_handle, monitor->path); + + monitor_free(monitor); +} + + /* Handles the removal of an Adv Monitor D-Bus proxy */ static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) { struct adv_monitor *monitor; + struct mgmt_cp_remove_adv_monitor cp; struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; + const char *path = g_dbus_proxy_get_path(proxy); - monitor = queue_remove_if(app->monitors, monitor_match, proxy); - if (monitor) { - DBG("Adv Monitor removed for the object at path %s", - monitor->path); + monitor = queue_find(app->monitors, monitor_match, proxy); - /* The object was gone, so we don't need to call Release() */ - monitor_free(monitor); + /* A monitor removed event from kernel can remove a monitor and notify + * the app on Release() where this callback can be invoked, so we + * simply skip here. + */ + if (!monitor) + return; + + if (monitor->state != MONITOR_STATE_HONORED) + goto done; + + monitor->state = MONITOR_STATE_REMOVING; + + cp.monitor_handle = cpu_to_le16(monitor->monitor_handle); + + if (!mgmt_send(app->manager->mgmt, MGMT_OP_REMOVE_ADV_MONITOR, + adapter_id, sizeof(cp), &cp, remove_adv_monitor_cb, + monitor, NULL)) { + btd_error(adapter_id, "Unable to send Remove Advt Monitor " + "command"); + goto done; } + + return; + +done: + queue_remove(app->monitors, monitor); + + DBG("Adv Monitor removed in state %02x with path %s", monitor->state, + monitor->path); + + monitor_free(monitor); } /* Creates an app object, initiates it and sets D-Bus event handlers */ @@ -936,6 +996,55 @@ static const GDBusPropertyTable adv_monitor_properties[] = { { } }; +/* Matches a monitor based on its handle */ +static bool removed_monitor_match(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct mgmt_ev_adv_monitor_removed *ev = user_data; + + return monitor->monitor_handle == ev->monitor_handle; +} + +/* Remove the matched monitor and reports the removal to the app */ +static void app_remove_monitor(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + struct adv_monitor *monitor; + + monitor = queue_find(app->monitors, removed_monitor_match, user_data); + if (monitor) { + if (monitor->state == MONITOR_STATE_HONORED) + monitor_release(monitor, NULL); + + queue_remove(app->monitors, monitor); + + DBG("Adv Monitor at path %s removed", monitor->path); + + monitor_free(monitor); + } +} + +/* Processes Adv Monitor removed event from kernel */ +static void adv_monitor_removed_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + struct mgmt_ev_adv_monitor_removed *ev = param; + struct btd_adv_monitor_manager *manager = user_data; + const uint16_t adapter_id = manager->adapter_id; + + if (length < sizeof(*ev)) { + btd_error(adapter_id, "Wrong size of Adv Monitor Removed " + "event"); + return; + } + + /* Traverse the apps to find the monitor */ + queue_foreach(manager->apps, app_remove_monitor, ev); + + DBG("Adv Monitor removed event with handle 0x%04x processed", + ev->monitor_handle); +} + /* Allocates a manager object */ static struct btd_adv_monitor_manager *manager_new( struct btd_adapter *adapter, @@ -955,6 +1064,10 @@ static struct btd_adv_monitor_manager *manager_new( manager->adapter_id = btd_adapter_get_index(adapter); manager->apps = queue_new(); + mgmt_register(manager->mgmt, MGMT_EV_ADV_MONITOR_REMOVED, + manager->adapter_id, adv_monitor_removed_callback, + manager, NULL); + return manager; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EIDoBNYCY18YoQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:31:50 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4AKoAdYCY1/h3gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:31:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D71EB40973; Thu, 17 Sep 2020 08:31:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726202AbgIQGbn (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:31:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgIQGbn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:31:43 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15302C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:31:43 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id w186so1204933qkd.1 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=M9HsWmGaYc362hnOhx8k59DhoQP5scWZuWggFfKUr7U=; b=owCBqehQkZ70rYhdafb0oO6XevkSPUwfWh7c+RfcVXMeIx3zlVGdvS0aZGX7QmL33B Ib3CZX0AdletXm5JdblJDTGGY5N4+p8u2LT9Y+kz3ZBjUiLyP81GmckF7NRt4PS7ZBMp ys3ooi5HroqQd2Xi4U9RfVXizOX76h6Bs/Mtkt13KPdcsEf41KrVZQ4U2BiarNElQ+rl FT8N0SAKQFe09MgLVM+mmopoh8cH6JCHLAGeD08Ogl1Z87I86bZB/AjVFJvli4uTKB9a xXu1Fm+KikN5m0DgtMTNVJXGTqY1NfQOZbglJdu01nefjeyQf/vXkWGtVMM+umpaUtWi vRXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=M9HsWmGaYc362hnOhx8k59DhoQP5scWZuWggFfKUr7U=; b=EH+Ia1BmjL1SbNQqTzFkLt6nqBK6/BM35YiNjZ8omUXDX3GJuxmhBD795Ul9U4BqRO VMz7yVukFmRoIrKw/FsWO1aXJHOHzTUWWOoRzAGA0uUvPcVt3/poEXkcXdjbRI0EMEee u/nfEUjlYLh56nOqsohELtFI93EAxYt3C50PevgDcEc33hW6oKAm3LAfGa38cJweOrrF Q0APve3sgrf24nehJB21zRbEQI6npZM0OpTyjLCJobeUCMWMZf7YheRAyvmwXagt5rsc hJpDYag/INUOL5zmkROnzLEMWRIwRq6Fg9d80iicMDkD3i1Szga++qrX8lXLnLIIeVEL JUdg== X-Gm-Message-State: AOAM531rSgnyNpErftFFB8oO3miaXecBtLCr0XPOd0soQ7Sl+I4TOJ/c 0JJW+WRX2AiqUoffRa1UJqDZ8CeFNfOKJg== X-Google-Smtp-Source: ABdhPJw4O/T+qIYoTCmXupd5p11YxERo++uMatYPWLoGuqULNSJNmZaUtPJFy0qkAhO8Nvz0QnSyow== X-Received: by 2002:a05:620a:1266:: with SMTP id b6mr26896996qkl.371.1600324302217; Wed, 16 Sep 2020 23:31:42 -0700 (PDT) Received: from [172.17.0.2] ([40.84.42.1]) by smtp.gmail.com with ESMTPSA id w2sm20215859qki.115.2020.09.16.23.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 23:31:41 -0700 (PDT) Message-ID: <5f6302cd.1c69fb81.3aaf4.fba0@mx.google.com> Date: Wed, 16 Sep 2020 23:31:41 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============0070315470866689327==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v2,2/8] adv_monitor: Implement unit tests for RSSI Filter Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200916231935.BlueZ.v2.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> References: <20200916231935.BlueZ.v2.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 3.00 / 15.00 / 15.00 X-Rspamd-Queue-Id: D71EB40973 X-Rspamd-UID: 42ff24 --===============0070315470866689327== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #163: FILE: unit/test-adv-monitor.c:1: +/* - total: 0 errors, 1 warnings, 512 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============0070315470866689327==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cMR/KHEDY18YoQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:34:25 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id UNUZJXEDY18ImgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:34:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6D1BB4096D; Thu, 17 Sep 2020 08:34:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726149AbgIQGeT (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:34:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbgIQGeS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:34:18 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 252BFC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:34:18 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id f142so1139753qke.13 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=MLZRku4DfRw64LX+GeeUW6eGps0g6UeTokwTfvlpdkE=; b=JYunj8MX256cj8JEvhLyhSlXrlY+NvFwhRC/g6h7lC4XBBy9+a+a3WQWGuj6q2M3AY kdX5zxQbSl28YPAyzY/cnHs560PoREqD4+LmKWzjPYnsY3Oy20eXtxMGuHb6CeFYg7dw QPU9FbY4xtmxTBL9R/YPfZgVbM7tM7Rc0wbTOoRuSutOfppzyyuJuCFh4OAegdxi9UOJ yHIdzCoEtJdYmeEUjFZ4ap1NqPXOm6SWr+vrFt9n+IjWrTwgC/CwFDTevMWJMnM5ax+6 pGW5CMnO8WXYwTu2A5wTXCybRy+hYwu/D7Tg4T9XxEURF1qdfaOsk2xixpZKIentz0N7 V+ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=MLZRku4DfRw64LX+GeeUW6eGps0g6UeTokwTfvlpdkE=; b=Gp4U2pmu/t4j+SqJYQQDcJj6WqpvhLho/Vw4RtlF38PuJqEsr4zIERUrqn8O7P5+Oi 6XFLDth7v5t1blLRoL8qOi+wE3VP2Cpfd427T0PNU3Wmg0aukrYOT7zo2wHMPT/6JtXW RhV4MeOhGG/Szftv89kCO6wHCadx2vM4KCxUCGVAwQoIpk3sqZ5XlTnkdnwo8FQ+Hl2e BgvDzBtky/M9iz9DRC2zxi8VXcTmMx007zlM5XA80gtuCuZxN6gxxeQp3lxF7m0XNZJ2 b4K7kzJAiRe/TYkGyM6o+tjfb0aKl1mOApximYeYiHfyOk1C+EpNxzrarzaJMdrT6Ry3 4haw== X-Gm-Message-State: AOAM532fNTyGp+E4S8Nqv+KJBti2YgH3EiAa9VlMyyFCq2XEqsNWWazJ Bk6utlKo0Lu8JSzB//xlQXbq9qTvAKXgtg== X-Google-Smtp-Source: ABdhPJzcPyl9HRhudLRTcl11qsf4bpVfBypHG3xmVmx9/B8DtNr8sa3SfHhQ/S5yakxah/23gJIOjw== X-Received: by 2002:a37:6347:: with SMTP id x68mr27235254qkb.474.1600324457281; Wed, 16 Sep 2020 23:34:17 -0700 (PDT) Received: from [172.17.0.2] ([40.84.42.1]) by smtp.gmail.com with ESMTPSA id p30sm19813557qtd.89.2020.09.16.23.34.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 23:34:16 -0700 (PDT) Message-ID: <5f630368.1c69fb81.83a55.ad9c@mx.google.com> Date: Wed, 16 Sep 2020 23:34:16 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============8624326796211237173==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v2,1/8] adv_monitor: Implement RSSI Filter logic for background scanning Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200916231935.BlueZ.v2.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.15 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6D1BB4096D X-Rspamd-UID: b98737 --===============8624326796211237173== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnNyYy9hZHZfbW9uaXRvci5jOiBJbiBmdW5jdGlvbiDigJhtb25pdG9y X3Byb3h5X3JlbW92ZWRfY2LigJk6CnNyYy9hZHZfbW9uaXRvci5jOjc1NjoxNDogZXJyb3I6IHVu dXNlZCB2YXJpYWJsZSDigJhwYXRo4oCZIFstV2Vycm9yPXVudXNlZC12YXJpYWJsZV0KICA3NTYg fCAgY29uc3QgY2hhciAqcGF0aCA9IGdfZGJ1c19wcm94eV9nZXRfcGF0aChwcm94eSk7CiAgICAg IHwgICAgICAgICAgICAgIF5+fn4Kc3JjL2Fkdl9tb25pdG9yLmM6IEluIGZ1bmN0aW9uIOKAmGFw cF9yZW1vdmVfbW9uaXRvcuKAmToKc3JjL2Fkdl9tb25pdG9yLmM6MTAxNDozODogZXJyb3I6IHBh c3NpbmcgYXJndW1lbnQgMiBvZiDigJhxdWV1ZV9maW5k4oCZIGZyb20gaW5jb21wYXRpYmxlIHBv aW50ZXIgdHlwZSBbLVdlcnJvcj1pbmNvbXBhdGlibGUtcG9pbnRlci10eXBlc10KIDEwMTQgfCAg bW9uaXRvciA9IHF1ZXVlX2ZpbmQoYXBwLT5tb25pdG9ycywgcmVtb3ZlZF9tb25pdG9yX21hdGNo LCB1c2VyX2RhdGEpOwogICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBefn5+fn5+fn5+fn5+fn5+fn5+fn4KICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgfAogICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBfQm9vbCAoKikodm9pZCAqLCB2b2lkICopCkluIGZpbGUgaW5jbHVkZWQgZnJvbSBzcmMvYWR2 X21vbml0b3IuYzo0MjoKLi9zcmMvc2hhcmVkL3F1ZXVlLmg6NTI6Nzogbm90ZTogZXhwZWN0ZWQg 4oCYcXVldWVfbWF0Y2hfZnVuY1904oCZIHtha2Eg4oCYX0Jvb2wgKCopKGNvbnN0IHZvaWQgKiwg Y29uc3Qgdm9pZCAqKeKAmX0gYnV0IGFyZ3VtZW50IGlzIG9mIHR5cGUg4oCYX0Jvb2wgKCopKHZv aWQgKiwgdm9pZCAqKeKAmQogICA1MiB8IHZvaWQgKnF1ZXVlX2ZpbmQoc3RydWN0IHF1ZXVlICpx dWV1ZSwgcXVldWVfbWF0Y2hfZnVuY190IGZ1bmN0aW9uLAogICAgICB8ICAgICAgIF5+fn5+fn5+ fn4Kc3JjL2Fkdl9tb25pdG9yLmM6IEluIGZ1bmN0aW9uIOKAmGFkdl9tb25pdG9yX3JlbW92ZWRf Y2FsbGJhY2vigJk6CnNyYy9hZHZfbW9uaXRvci5jOjEwMzE6NDM6IGVycm9yOiBpbml0aWFsaXph dGlvbiBkaXNjYXJkcyDigJhjb25zdOKAmSBxdWFsaWZpZXIgZnJvbSBwb2ludGVyIHRhcmdldCB0 eXBlIFstV2Vycm9yPWRpc2NhcmRlZC1xdWFsaWZpZXJzXQogMTAzMSB8ICBzdHJ1Y3QgbWdtdF9l dl9hZHZfbW9uaXRvcl9yZW1vdmVkICpldiA9IHBhcmFtOwogICAgICB8ICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIF5+fn5+CnNyYy9hZHZfbW9uaXRvci5jOiBJbiBm dW5jdGlvbiDigJhhZHZfbWF0Y2hfcGVyX3BhdHRlcm7igJk6CnNyYy9hZHZfbW9uaXRvci5jOjEy MzA6MTc6IGVycm9yOiB1bnVzZWQgdmFyaWFibGUg4oCYZWly4oCZIFstV2Vycm9yPXVudXNlZC12 YXJpYWJsZV0KIDEyMzAgfCAgY29uc3QgdWludDhfdCAqZWlyID0gaW5mby0+ZWlyOwogICAgICB8 ICAgICAgICAgICAgICAgICBefn4Kc3JjL2Fkdl9tb25pdG9yLmM6IEluIGZ1bmN0aW9uIOKAmGJ0 ZF9hZHZfbW9uaXRvcl9jb250ZW50X2ZpbHRlcuKAmToKc3JjL2Fkdl9tb25pdG9yLmM6MTI4Njoy OiBlcnJvcjogSVNPIEM5MCBmb3JiaWRzIG1peGVkIGRlY2xhcmF0aW9ucyBhbmQgY29kZSBbLVdl cnJvcj1kZWNsYXJhdGlvbi1hZnRlci1zdGF0ZW1lbnRdCiAxMjg2IHwgIHN0cnVjdCBhZHZfY29u dGVudF9maWx0ZXJfaW5mbyBpbmZvID0gewogICAgICB8ICBefn5+fn4Kc3JjL2Fkdl9tb25pdG9y LmM6IEluIGZ1bmN0aW9uIOKAmGJ0ZF9hZHZfbW9uaXRvcl9ub3RpZnlfbW9uaXRvcnPigJk6CnNy Yy9hZHZfbW9uaXRvci5jOjEzMjI6MjogZXJyb3I6IElTTyBDOTAgZm9yYmlkcyBtaXhlZCBkZWNs YXJhdGlvbnMgYW5kIGNvZGUgWy1XZXJyb3I9ZGVjbGFyYXRpb24tYWZ0ZXItc3RhdGVtZW50XQog MTMyMiB8ICBzdHJ1Y3QgYWR2X3Jzc2lfZmlsdGVyX2luZm8gaW5mbyA9IHsKICAgICAgfCAgXn5+ fn5+CmNjMTogYWxsIHdhcm5pbmdzIGJlaW5nIHRyZWF0ZWQgYXMgZXJyb3JzCm1ha2VbMV06ICoq KiBbTWFrZWZpbGU6Njg2Mzogc3JjL2Fkdl9tb25pdG9yLm9dIEVycm9yIDEKbWFrZTogKioqIFtN YWtlZmlsZTo0MDU2OiBhbGxdIEVycm9yIDIKCgoKLS0tClJlZ2FyZHMsCkxpbnV4IEJsdWV0b290 aAo= --===============8624326796211237173==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +OwIHKAGY1+GOAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:48:00 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SIU9GKAGY1+NnQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:48:00 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2E0F9A0B17; Thu, 17 Sep 2020 08:47:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726265AbgIQGrh (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:47:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbgIQGrf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:47:35 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9A33C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:47:34 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id a16so984935qtj.7 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=e3Ng92DmlzyUG7acvtBMlEmT/DHSWBCFO/IyCWcsolY=; b=GUOxIraY5bahPU5r353/Z/Njg8JVTU+4ltLFwCaWwOYGnqLjFvoXHey+rlHXfrLSj0 mUU36RB5pKDfS8HK4cZw+5qyBHWfBAtvtA437+Se5Ny+cuM9WeAJ3LZBsyy0T30z9Xzl VH0l/ajmMLnoR0k26RtX3G+UW3oZ1qMX5hTWVHG+BbTR+UhoyNyFccuwwgvs2PMEFmGr PqTXbvLonkpEOWPqDMQIRHCiooRpurEPaaMePu35ETu2OSoeV5n38ZGDCmSWxex+9lYq fxfcrir2Ryed8dvRLm5Ej+sFPTMB2sKkeNQFxwRvv5Bmg6FJebcLGTIgUe4QIfn1pYp0 u2ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=e3Ng92DmlzyUG7acvtBMlEmT/DHSWBCFO/IyCWcsolY=; b=ud4SClmQczjVA7jc0hIVvkw290Ve2QLr/CYgtg1TLAbYSDllvJlS2nq2uAY3FnvAlm iDoho5fxp6hnknCMg4cVX437k34m2ad5QrLgjHmawN7t9bHNI8GN6uWzskL00sEeXIUs l/hbAU+YhQvv2T51yosbbD9qH9oWJ9aLXdvcayHc7wK0ZGFyQW5V0DvFVfNJ8Ii5mypw wZ0SQpbHJMu2fCE2k99FWr0T0sRO31AOZRAzBy10e/0/8oB7SGOVLZrxGdeqbanDXpst bCFCRgurrZ8d0uzXXnGZ2mQ0zyGVIylN3NYTBFgpgTwwxEygjV1Cd77XuT1+Oppuiw0M ku5Q== X-Gm-Message-State: AOAM5319n01D3dGl5iuMQO5l7AzDWj0Yk4Gp6DPzHPYkN8LPuyKPSpEp BINrbRq40mUQwxzT4y8DUDKdx/owxB+hetCHsr1P6hRQeAwKB/bYRBjzOk9URumMTawfZa8nuaV lc5ZPg0UxB2INlF276Bmetr6/Hplmhh5IqcuYmMWHOKm3AWBE2jJoizQ6y/q/iXvjx7E0Vs9QZC JGECNach2OE/g= X-Google-Smtp-Source: ABdhPJz2ZeYqJoAzMv0NEf5Q0uORxxjToMj3h33BAV9zcwX6MrtEnA4FuxVr8N5UbI8Ms9mO4GMfZFt5a4yfK8gacg== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:5745:: with SMTP id q5mr27078772qvx.29.1600325253789; Wed, 16 Sep 2020 23:47:33 -0700 (PDT) Date: Thu, 17 Sep 2020 14:47:29 +0800 Message-Id: <20200917144712.BlueZ.1.I9a1342e299d78f88c2fc8f8ce61fac84baa61a05@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH] core: Correct namings of LEScanAdvMonitor params From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, mmandlik@chromium.org, mcchou@chromium.org, luiz.dentz@gmail.com, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.70 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2E0F9A0B17 X-Rspamd-UID: c43823 LEScan.*AdvMonitor is already used in src/main.c and src/main.conf --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 038f867b5a6d..d45aed0d9569 100644 --- a/src/main.c +++ b/src/main.c @@ -114,8 +114,8 @@ static const char *controller_options[] = { "LEScanWindowSuspend", "LEScanIntervalDiscovery", "LEScanWindowDiscovery", - "LEScanIntervalAdvMonitoring", - "LEScanWindowAdvMonitoring", + "LEScanIntervalAdvMonitor", + "LEScanWindowAdvMonitor", "LEScanIntervalConnect", "LEScanWindowConnect", "LEMinConnectionInterval", -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KBjsFMEGY19oXAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:48:33 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id SPxiEsEGY1+AfgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:48:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2822BA0118; Thu, 17 Sep 2020 08:48:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726186AbgIQGsZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbgIQGsX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:48:23 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAA87C06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:48:23 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id q2so796280pfc.17 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=Ihi2082NxuAZnwPlDWpKybiyW3ApajnMKdIt5g5t49s=; b=UOPSevjbAMTngIb8psMDG/2VcsmQu9QDW4TSaKD3SwVtnxlb0hWdZnls40NMcHw2wQ HBnB9OSbi2YtisRZdy/eGMbEed2U7iVS+e3F4xjXVJ3RRMs0xBs9b+V9Q/X5ovccyL4L Na2l1G5Z2Ln0p5rrSaEbO5muz0x1hs0eaKh0wWjbPgKbI1a3poUb70iu4vLy9G8/AsCD qfWOWZUS3muNM+dWF4gCSv3YtlC+NXtD7W04O4pMaNAescv5mhRjEgGRbb68ZNc8JDbt LNJHtovPpnttbXwUhlUr61rMEhZX8dmQ0gk074DixjTFDo8SjadjAChCQx2a6wfziVsu Pxqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=Ihi2082NxuAZnwPlDWpKybiyW3ApajnMKdIt5g5t49s=; b=GPDsXtb7mj/NGmApL8sWavwBfT2n4JxAVeAdPFIwTsA6XXdDZRC6faDJamBMevfr3O XxtJNp0DVN+ICdiXmgygJiJ7n3wmmmcNx6MPwaEBc2qrNH85IRzxQvmbRHAXtM7i2l8e 99/tw2BdSkQVZZ9UF3p7vjC9jJ+hWolCoKyjZbgqekL+1HGPyutTy/nRggFLUOLOPd+N bFREodNrBADNFddQeJ0LGq6KjYYGrp5e1//WEyL1IMcXQPneYmONGwP8cKLJ4540Jlyn HDLaUGhQ/dqmwf6hm6pwQlZeG8XtvVyyfWW4hzo39kwp1JICR1AlJQtwLSWQqOkSJ3pm U99w== X-Gm-Message-State: AOAM5325Eh7kw1CZHmuwAZ+teCcQLQ8PSzI+dIdNPOiqc1ZyYzxTJbea 0XBqYnKXT/CFACE+PGd3DbOh7KXFJPM5cagu6iZCDf2D4+8sibFHdoAhK+vkw6c7AKIvJxiQt2v +ThsbV1QufStWR77QNuposmJUrnktuKhfC9nSRMSHKjHB8OdtcVRvvcHbm1OB88R85RdjkZ4nIy zQnkHNLUyogKo= X-Google-Smtp-Source: ABdhPJxHpoFRBdAfV8RevCzA9pjqOCASbwDYK5xArVgBdQUhQnHsSYmO6hDumpYRy643bmIbfB+kC2t+u36QsGsnqQ== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:aa7:934e:0:b029:13f:d056:593 with SMTP id 14-20020aa7934e0000b029013fd0560593mr20182654pfn.15.1600325303181; Wed, 16 Sep 2020 23:48:23 -0700 (PDT) Date: Thu, 17 Sep 2020 14:48:15 +0800 Message-Id: <20200917144759.BlueZ.1.I1f083629d41c747a33a3937fbc199ea37dccde12@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH 1/2] core: Add parmas to set interleaving durations From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, luiz.dentz@gmail.com, mcchou@chromium.org, mmandlik@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2822BA0118 X-Rspamd-UID: eb99d3 This patch adds parameters to control the durations of allowlist scan and no-filter scan when the kernel is doing interleaving scan. --- src/adapter.c | 18 ++++++++++++++++++ src/hcid.h | 3 +++ src/main.c | 10 ++++++++++ src/main.conf | 7 +++++++ 4 files changed, 38 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index b2bd8b3f1d01..c0e95b48a1c4 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -4431,6 +4431,24 @@ static void load_default_system_params(struct btd_adapter *adapter) len += sizeof(params[i].u16); } + if (main_opts.default_params.advmon_allowlist_scan_duration) { + params[i].entry.type = 0x001d; + params[i].entry.length = sizeof(params[i].u16); + params[i].u16 = + main_opts.default_params.advmon_allowlist_scan_duration; + ++i; + len += sizeof(params[i].u16); + } + + if (main_opts.default_params.advmon_no_filter_scan_duration) { + params[i].entry.type = 0x001e; + params[i].entry.length = sizeof(params[i].u16); + params[i].u16 = + main_opts.default_params.advmon_no_filter_scan_duration; + ++i; + len += sizeof(params[i].u16); + } + err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG, adapter->dev_id, len, params, NULL, NULL, NULL); if (!err) diff --git a/src/hcid.h b/src/hcid.h index 3624ba6ea163..c3e5fe803543 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -93,6 +93,9 @@ struct main_opts { uint16_t le_conn_latency; uint16_t le_conn_lsto; uint16_t le_autoconnect_timeout; + + uint16_t advmon_allowlist_scan_duration; + uint16_t advmon_no_filter_scan_duration; } default_params; diff --git a/src/main.c b/src/main.c index 038f867b5a6d..e222ed3bf855 100644 --- a/src/main.c +++ b/src/main.c @@ -123,6 +123,8 @@ static const char *controller_options[] = { "LEConnectionLatency", "LEConnectionSupervisionTimeout", "LEAutoconnecttimeout", + "AdvMonAllowlistScanDuration", + "AdvMonNoFilterScanDuration", NULL }; @@ -434,6 +436,14 @@ static void parse_controller_config(GKeyFile *config) &main_opts.default_params.le_autoconnect_timeout, 0x0001, 0x4000}, + { "AdvMonAllowlistScanDuration", + &main_opts.default_params.advmon_allowlist_scan_duration, + 1, + 10000}, + { "AdvMonNoFilterScanDuration", + &main_opts.default_params.advmon_no_filter_scan_duration, + 1, + 10000}, }; uint16_t i; diff --git a/src/main.conf b/src/main.conf index 8d85702d4316..3b341f44c9cf 100644 --- a/src/main.conf +++ b/src/main.conf @@ -152,6 +152,13 @@ #LEConnectionSupervisionTimeout= #LEAutoconnecttimeout= +# Scan duration during interleaving scan. Only used when scanning for ADV +# monitors. The units are msec. +# Default: 300 +#AdvMonAllowlistScanDuration= +# Default: 500 +#AdvMonNoFilterScanDuration= + [GATT] # GATT attribute cache. # Possible values: -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qJVgNMoGY19oXAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 08:48:42 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id KNG3MMoGY18MzwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 08:48:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D152CA0B17; Thu, 17 Sep 2020 08:48:36 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726211AbgIQGsd (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 02:48:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgIQGs2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 02:48:28 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA6EEC06174A for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:48:27 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id c5so972041qtd.12 for <linux-bluetooth@vger.kernel.org>; Wed, 16 Sep 2020 23:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=0WYATeNozfS1LrKcApAsG4ah2AmW/WN4JP8kkkzL7Xg=; b=nXL/btYDdOTe3RqTF7F1o0A3mLF1iEazCm+hkVNT9yfSD0QtMNbCwlke6m6OFpmsnd NF7OmwZdrazpOFH9XNGZFaCZpaPNxNfWIqOkmqjPjqeJi66fGUmA+mMhWWK7YlMFoMs8 ltp7lQTWzf/1CyZNQu3TZTAA/TBWB85jL5YsVAS2b+yJ5CeEeMs+CCelodaP4DwLlmr3 Iq5JWPKJPKjwvzamGeplKOUx1rpltmKiJef8AxMjFrkqD67SLQP2JUd2eVklnQpfcGM9 JZMB8k3x44z3MWek4HGGRCH8ORpbeiLyW3aLfdrlK+ApyEKYMPp00Ap7dldxIiHC/Xxz 4PbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=0WYATeNozfS1LrKcApAsG4ah2AmW/WN4JP8kkkzL7Xg=; b=CY1FtNYdlxLF8DZE2OzZb1SUwgtZefUyocD/kvaic1vLlKeI3+cCQePN7dyQNh33N7 2lVCLhNWRxmNSxYrNxR1872XVgz99rEA78YG/g5uBHdZF9esCtnQdAmLkUOl78GUBKQT fYgpF/JkVQBhcdWFP2TJyeTihyAMD2V/ulYG68PWdRWmQde4/ZMVWQ1T0av6814lSyWE vu5S7lmNt8L5LtNE/k+wAv0X1ia1haAV82Xod/OChKdlwGFKO6cEvCVmyCO9Rj5kgZHW RovMFq16aaNdiS4JTbrl+OPsIePevo8+U4TS9WHn4QZN/bB0U8Ej9mtYgp2Ca4d0+N6f Estw== X-Gm-Message-State: AOAM533P4QNIMPq/ISlqXyXeDc8FlbAMDJEgD140zGfCf0SRtjCTC4K9 elZ1rc+hjlcrpRHijxC3KSmgvoKH1kKc6LyMPHlYyWEcMEdb7EmXI7w3tYcxHWrcShLurpFqmqH Es6N40ong2aRuuDl4mMCCS9DADTX0g/Aiyhtao1TChxBd31rCIYDBu5Kfs4GgmGpbO1TZ5Das5k BGhmNBRUMaivI= X-Google-Smtp-Source: ABdhPJyJGDPFWBnCXooPeOMQScT7DpWbH6eXfCImE6bn0zllPRQ7Z39sDCFg9JE49/P2EY3qjlyFCcDGR0aexI8yXA== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:4e4e:: with SMTP id eb14mr10745407qvb.41.1600325307008; Wed, 16 Sep 2020 23:48:27 -0700 (PDT) Date: Thu, 17 Sep 2020 14:48:16 +0800 In-Reply-To: <20200917144759.BlueZ.1.I1f083629d41c747a33a3937fbc199ea37dccde12@changeid> Message-Id: <20200917144759.BlueZ.2.Iac5207375d22fb7b96ae4ef73b49ae4ab457219c@changeid> Mime-Version: 1.0 References: <20200917144759.BlueZ.1.I1f083629d41c747a33a3937fbc199ea37dccde12@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH 2/2] core: Add param to disable interleave scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, luiz.dentz@gmail.com, mcchou@chromium.org, mmandlik@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.69 / 15.00 / 15.00 X-Rspamd-Queue-Id: D152CA0B17 X-Rspamd-UID: 947353 This patch adds parameter to enable/disable the interleave scan feature. --- src/adapter.c | 9 +++++++++ src/hcid.h | 1 + src/main.c | 6 ++++++ src/main.conf | 6 ++++++ 4 files changed, 22 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index c0e95b48a1c4..a2c782e308bb 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -4449,6 +4449,15 @@ static void load_default_system_params(struct btd_adapter *adapter) len += sizeof(params[i].u16); } + if (main_opts.default_params.enable_advmon_interleave_scan != 0xFFFF) { + params[i].entry.type = 0x001f; + params[i].entry.length = sizeof(params[i].u16); + params[i].u16 = + main_opts.default_params.enable_advmon_interleave_scan; + ++i; + len += sizeof(params[i].u16); + } + err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG, adapter->dev_id, len, params, NULL, NULL, NULL); if (!err) diff --git a/src/hcid.h b/src/hcid.h index c3e5fe803543..c6717be62c48 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -96,6 +96,7 @@ struct main_opts { uint16_t advmon_allowlist_scan_duration; uint16_t advmon_no_filter_scan_duration; + uint16_t enable_advmon_interleave_scan; } default_params; diff --git a/src/main.c b/src/main.c index e222ed3bf855..3433130bc419 100644 --- a/src/main.c +++ b/src/main.c @@ -125,6 +125,7 @@ static const char *controller_options[] = { "LEAutoconnecttimeout", "AdvMonAllowlistScanDuration", "AdvMonNoFilterScanDuration", + "EnableAdvMonInterleaveScan", NULL }; @@ -444,6 +445,10 @@ static void parse_controller_config(GKeyFile *config) &main_opts.default_params.advmon_no_filter_scan_duration, 1, 10000}, + { "EnableAdvMonInterleaveScan", + &main_opts.default_params.enable_advmon_interleave_scan, + 0, + 1}, }; uint16_t i; @@ -711,6 +716,7 @@ static void init_defaults(void) main_opts.default_params.num_entries = 0; main_opts.default_params.br_page_scan_type = 0xFFFF; main_opts.default_params.br_scan_type = 0xFFFF; + main_opts.default_params.enable_advmon_interleave_scan = 0xFFFF; if (sscanf(VERSION, "%hhu.%hhu", &major, &minor) != 2) return; diff --git a/src/main.conf b/src/main.conf index 3b341f44c9cf..c300a3b81086 100644 --- a/src/main.conf +++ b/src/main.conf @@ -159,6 +159,12 @@ # Default: 500 #AdvMonNoFilterScanDuration= +# Enable/Disable Advertisement Monitor interleave scan for power saving. +# 0: disable +# 1: enable +# Defaults to 1 +#EnableAdvMonInterleaveScan= + [GATT] # GATT attribute cache. # Possible values: -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IOBpIvgKY19nggAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:06:32 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4AwiHvgKY1+lDQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:06:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A591840998; Thu, 17 Sep 2020 09:06:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726340AbgIQHFy (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726338AbgIQHFn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:05:43 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5BECC061788 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:05:29 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id k13so639658plk.3 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:05:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g4Q9cQfaccpCkdKyQEmYtzcu/CIIxb1GgrFvPgXKyHU=; b=Ejwsp/b1DVq5N+LNM8pu2SJDhPug72tgbjYBftqRdWDhY+nW53r6bVkd1OfGPeTRDr M+mVOdDddbbA3CNeHKwgNpFXrCemkBM3+bSDVHHIUvubpsp0ioijQJUKGwS3/vw4lwC3 C/orUpplf808C9LT6ccLqupd6KuuppApqfB1c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g4Q9cQfaccpCkdKyQEmYtzcu/CIIxb1GgrFvPgXKyHU=; b=ACiC2NWNIr7Wv49v15gVUCdOU5G31EIxJKfwqxk8r+DY0XJFGdsgy13M19uijKf6cE K7B2c04547KgQ/q4KlYKexzd0swr94lfv8ybBsjtEVeVAfe0qx5lbXEqOZFrzQpg/nuj EpYPDtu2PMKoDMjcL3MMzD7r/BVRWsnfU1d3QxHqZRp93KcX4GTcUCcsw9alDwSVn/KK pXF2dErJeOYuoiJaxoRnZ0ibrpbjXehV6Jizd9c0IHRgfnaPfl3LXG17lYYU3FjWTl2t TwsxrkzmXboJVu6qefr4hgtnDzMcnhCxbjVAYmldtomByZPvnDbfx2a8mVNNqw4dRAgA WMbQ== X-Gm-Message-State: AOAM53295P7SfsiegGhenIFLCqvuS3WHwoIwwBsiN+i0zuM9d0sy9t4Q SvCgJLqOLMVMCEIUphb0gKGVnjFOtgl4OQ== X-Google-Smtp-Source: ABdhPJwZi13AZyHZ3XGCBim3VJaek8jjToWj4D0TGXC6bHBbuYGzCQ6shsuWZ3FP5vIbSfbdoHzRGQ== X-Received: by 2002:a17:90b:3c7:: with SMTP id go7mr7124856pjb.97.1600326328712; Thu, 17 Sep 2020 00:05:28 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y197sm5407372pfc.220.2020.09.17.00.05.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:05:28 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Marcel Holtmann <marcel@holtmann.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v3 3/8] adv_monitor: Implement Adv matching based on stored monitors Date: Thu, 17 Sep 2020 00:04:57 -0700 Message-Id: <20200917000448.BlueZ.v3.3.I578ae5e76fcf7243206a27d4f5a25783662a5f14@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: A591840998 X-Rspamd-UID: c74b32 This implements create an entry point in adapter to start the matching of Adv based on all monitors and invoke the RSSI tracking for Adv reporting. Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v3: - Remove unused variables - Fix signature of queue_find() src/adapter.c | 35 +++++-- src/adv_monitor.c | 237 +++++++++++++++++++++++++++++++++++++++++----- src/adv_monitor.h | 19 ++++ 3 files changed, 259 insertions(+), 32 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 415d6e06b..d33ce7124 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6614,6 +6614,15 @@ static void update_found_devices(struct btd_adapter *adapter, bool name_known, discoverable; char addr[18]; bool duplicate = false; + GSList *matched_monitors; + + /* During the background scanning, update the device only when the data + * match at least one Adv monitor + */ + matched_monitors = btd_adv_monitor_content_filter( + adapter->adv_monitor_manager, data, data_len); + if (!adapter->discovering && !matched_monitors) + return; memset(&eir_data, 0, sizeof(eir_data)); eir_parse(&eir_data, data, data_len); @@ -6659,18 +6668,22 @@ static void update_found_devices(struct btd_adapter *adapter, device_store_cached_name(dev, eir_data.name); /* - * Only skip devices that are not connected, are temporary and there - * is no active discovery session ongoing. + * Only skip devices that are not connected, are temporary, and there + * is no active discovery session ongoing and no matched Adv monitors */ - if (!btd_device_is_connected(dev) && (device_is_temporary(dev) && - !adapter->discovery_list)) { + if (!btd_device_is_connected(dev) && + (device_is_temporary(dev) && !adapter->discovery_list) && + !matched_monitors) { eir_data_free(&eir_data); return; } - /* Don't continue if not discoverable or if filter don't match */ - if (!discoverable || (adapter->filtered_discovery && - !is_filter_match(adapter->discovery_list, &eir_data, rssi))) { + /* If there is no matched Adv monitors, don't continue if not + * discoverable or if active discovery filter don't match. + */ + if (!matched_monitors && (!discoverable || + (adapter->filtered_discovery && !is_filter_match( + adapter->discovery_list, &eir_data, rssi)))) { eir_data_free(&eir_data); return; } @@ -6727,6 +6740,14 @@ static void update_found_devices(struct btd_adapter *adapter, eir_data_free(&eir_data); + /* After the device is updated, notify the matched Adv monitors */ + if (matched_monitors) { + btd_adv_monitor_notify_monitors(adapter->adv_monitor_manager, + dev, rssi, matched_monitors); + g_slist_free(matched_monitors); + matched_monitors = NULL; + } + /* * Only if at least one client has requested discovery, maintain * list of found devices and name confirming for legacy devices. diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 046f5953f..211094c89 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -38,15 +38,12 @@ #include "device.h" #include "log.h" #include "src/error.h" -#include "src/shared/ad.h" #include "src/shared/mgmt.h" #include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" -static void monitor_device_free(void *data); - #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" @@ -93,7 +90,7 @@ enum monitor_state { MONITOR_STATE_HONORED, /* Accepted by kernel */ }; -struct pattern { +struct btd_adv_monitor_pattern { uint8_t ad_type; uint8_t offset; uint8_t length; @@ -142,6 +139,23 @@ struct app_match_data { const char *path; }; +struct adv_content_filter_info { + uint8_t eir_len; + const uint8_t *eir; + + bool matched; /* Intermediate state per monitor */ + GSList *matched_monitors; /* List of matched monitors */ +}; + +struct adv_rssi_filter_info { + struct btd_device *device; + int8_t rssi; +}; + +static void monitor_device_free(void *data); +static void adv_monitor_filter_rssi(struct adv_monitor *monitor, + struct btd_device *device, int8_t rssi); + const struct adv_monitor_type { enum monitor_type type; const char *name; @@ -164,7 +178,7 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) /* Frees a pattern */ static void pattern_free(void *data) { - struct pattern *pattern = data; + struct btd_adv_monitor_pattern *pattern = data; if (!pattern) return; @@ -172,6 +186,12 @@ static void pattern_free(void *data) free(pattern); } +void btd_adv_monitor_test_pattern_destroy( + struct btd_adv_monitor_pattern *pattern) +{ + pattern_free(pattern); +} + /* Frees a monitor object */ static void monitor_free(void *data) { @@ -444,6 +464,42 @@ failed: return false; } +/* Allocates and initiates a pattern with the given content */ +static struct btd_adv_monitor_pattern *pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value) +{ + struct btd_adv_monitor_pattern *pattern; + + if (offset > BT_AD_MAX_DATA_LEN - 1) + return NULL; + + if ((ad_type > BT_AD_3D_INFO_DATA && + ad_type != BT_AD_MANUFACTURER_DATA) || + ad_type < BT_AD_FLAGS) { + return NULL; + } + + if (!value || !length || offset + length > BT_AD_MAX_DATA_LEN) + return NULL; + + pattern = new0(struct btd_adv_monitor_pattern, 1); + if (!pattern) + return NULL; + + pattern->ad_type = ad_type; + pattern->offset = offset; + pattern->length = length; + memcpy(pattern->value, value, pattern->length); + + return pattern; +} + +struct btd_adv_monitor_pattern *btd_adv_monitor_test_pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value) +{ + return pattern_create(ad_type, offset, length, value); +} + /* Retrieves Patterns from the remote Adv Monitor object, verifies the values * and update the local Adv Monitor */ @@ -473,7 +529,7 @@ static bool parse_patterns(struct adv_monitor *monitor, const char *path) int value_len; uint8_t *value; uint8_t offset, ad_type; - struct pattern *pattern; + struct btd_adv_monitor_pattern *pattern; DBusMessageIter struct_iter, value_iter; dbus_message_iter_recurse(&array_iter, &struct_iter); @@ -505,28 +561,10 @@ static bool parse_patterns(struct adv_monitor *monitor, const char *path) dbus_message_iter_get_fixed_array(&value_iter, &value, &value_len); - // Verify the values - if (offset > BT_AD_MAX_DATA_LEN - 1) - goto failed; - - if ((ad_type > BT_AD_3D_INFO_DATA && - ad_type != BT_AD_MANUFACTURER_DATA) || - ad_type < BT_AD_FLAGS) { - goto failed; - } - - if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) - goto failed; - - pattern = new0(struct pattern, 1); + pattern = pattern_create(ad_type, offset, value_len, value); if (!pattern) goto failed; - pattern->ad_type = ad_type; - pattern->offset = offset; - pattern->length = value_len; - memcpy(pattern->value, value, pattern->length); - queue_push_tail(monitor->patterns, pattern); dbus_message_iter_next(&array_iter); @@ -961,6 +999,155 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) manager_destroy(manager); } +/* Matches the content based on the given pattern */ +bool btd_adv_monitor_pattern_match( + const uint8_t *eir, uint8_t eir_len, + const struct btd_adv_monitor_pattern *pattern) +{ + const uint8_t *data; + uint8_t idx = 0; + uint8_t field_len, data_len, data_type; + + while (idx < eir_len - 1) { + field_len = eir[0]; + + /* Check for the end of EIR */ + if (field_len == 0) + break; + + idx += field_len + 1; + + /* Do not continue filtering if got incorrect length */ + if (idx >= eir_len) + break; + + data = &eir[2]; + data_type = eir[1]; + data_len = field_len - 1; + + eir += field_len + 1; + + if (data_type != pattern->ad_type) + continue; + + if (data_len < pattern->offset + pattern->length) + continue; + + if (pattern->offset + pattern->length > BT_AD_MAX_DATA_LEN) + continue; + + if (!memcmp(data + pattern->offset, pattern->value, + pattern->length)) + return true; + } + + return false; +} + +/* Processes the content matching based on a pattern */ +static void adv_match_per_pattern(void *data, void *user_data) +{ + struct btd_adv_monitor_pattern *pattern = data; + struct adv_content_filter_info *info = user_data; + + if (!pattern || info->matched) + return; + + info->matched = btd_adv_monitor_pattern_match(info->eir, info->eir_len, + pattern); +} + +/* Processes the content matching based pattern(s) of a monitor */ +static void adv_match_per_monitor(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct adv_content_filter_info *info = user_data; + + if (!monitor && monitor->state != MONITOR_STATE_HONORED) + return; + + /* Reset the intermediate matched status */ + info->matched = false; + + if (monitor->type == MONITOR_TYPE_OR_PATTERNS) { + queue_foreach(monitor->patterns, adv_match_per_pattern, info); + if (info->matched) + goto matched; + } + + return; + +matched: + info->matched_monitors = g_slist_prepend(info->matched_monitors, + monitor); +} + +/* Processes the content matching for the monitor(s) of an app */ +static void adv_match_per_app(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + + if (!app) + return; + + queue_foreach(app->monitors, adv_match_per_monitor, user_data); +} + +/* Processes the content matching for every app without RSSI filtering and + * notifying monitors. The caller is responsible of releasing the memory of the + * list but not the data. + * Returns the list of monitors whose content match eir. + */ +GSList *btd_adv_monitor_content_filter(struct btd_adv_monitor_manager *manager, + const uint8_t *eir, uint8_t eir_len) +{ + struct adv_content_filter_info info; + + if (!manager || !eir || !eir_len) + return NULL; + + info.eir_len = eir_len; + info.eir = eir; + info.matched_monitors = NULL; + + queue_foreach(manager->apps, adv_match_per_app, &info); + + return info.matched_monitors; +} + +/* Wraps adv_monitor_filter_rssi() to processes the content-matched monitor with + * RSSI filtering and notifies it on device found/lost event + */ +static void monitor_filter_rssi(gpointer a, gpointer b) +{ + struct adv_monitor *monitor = a; + struct adv_rssi_filter_info *info = b; + + if (!monitor || !info) + return; + + adv_monitor_filter_rssi(monitor, info->device, info->rssi); +} + +/* Processes every content-matched monitor with RSSI filtering and notifies on + * device found/lost event. The caller is responsible of releasing the memory + * of matched_monitors list but not its data. + */ +void btd_adv_monitor_notify_monitors(struct btd_adv_monitor_manager *manager, + struct btd_device *device, int8_t rssi, + GSList *matched_monitors) +{ + struct adv_rssi_filter_info info; + + if (!manager || !device || !matched_monitors) + return; + + info.device = device; + info.rssi = rssi; + + g_slist_foreach(matched_monitors, monitor_filter_rssi, &info); +} + /* Matches a device based on btd_device object */ static bool monitor_device_match(const void *a, const void *b) { diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 351e7f9aa..b660f5941 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -20,16 +20,28 @@ #ifndef __ADV_MONITOR_H #define __ADV_MONITOR_H +#include <glib.h> + +#include "src/shared/ad.h" + struct mgmt; struct btd_device; struct btd_adapter; struct btd_adv_monitor_manager; +struct btd_adv_monitor_pattern; struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct btd_adapter *adapter, struct mgmt *mgmt); void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); +GSList *btd_adv_monitor_content_filter(struct btd_adv_monitor_manager *manager, + const uint8_t *eir, uint8_t eir_len); + +void btd_adv_monitor_notify_monitors(struct btd_adv_monitor_manager *manager, + struct btd_device *device, int8_t rssi, + GSList *matched_monitors); + void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, struct btd_device *device); @@ -42,5 +54,12 @@ void btd_adv_monitor_rssi_test_teardown(void *monitor_obj); bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj); bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, int8_t adv_rssi); +struct btd_adv_monitor_pattern *btd_adv_monitor_test_pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value); +void btd_adv_monitor_test_pattern_destroy( + struct btd_adv_monitor_pattern *pattern); +bool btd_adv_monitor_pattern_match( + const uint8_t *eir, uint8_t eir_len, + const struct btd_adv_monitor_pattern *pattern); #endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8A/5EAcLY1/4hwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:06:47 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 4DjUDQcLY1+AfgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:06:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4B4164096C; Thu, 17 Sep 2020 09:06:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgIQHGN (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:06:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726318AbgIQHGE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:06:04 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09FD6C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:06:04 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id z18so644196pfg.0 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u+E1bUX0uVxPcQEsE71u1Ro0+1uBNDa00K7AzDVg6ww=; b=S2eLc/rvaepND8Icr0cBILxS+QGa1uFhTFmd65QO/R5XHGqAutzWOK/X0Gq1ePvGTH sGZxpejzUWulmO7S38fEzqEXU0IYhtJwN6YDVGjFwU2mACSS8kc3rP8g21AaRuoo70aG KW8MUeTXKsKnIdcQBUz4/rLga2cdAN1H+GW5I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u+E1bUX0uVxPcQEsE71u1Ro0+1uBNDa00K7AzDVg6ww=; b=cWmxwTIDTNNtYpji80ylmlaeG/qzEBiSGwLCSdJ2QhytrB0qlzY/GFWpPhjnAzMHJ6 3+YWXn8lTu2FKQeWwuhdEiIvK2HJMSZo+Mw5LEHYqzmIe4w0hA8HM+ioWl7JJTq2JDpB in4sJKxgr0uKtUaeO0dOgC4a0m56uCnNSAhz0E7eaKcpnmWI05r1lZUyYcp7TkJxrTrA tzZbGkpiMBQpPeZNmNBRp0pXqtsWA32vpwTB6HtiMDzz4EgCG2QaMIkoj7UFdmHmwJYu Z/x+fya7cCTyYF5U5PvWHQKInA5R3eGxTiaNCfiyf9wF2TlhOXECC2sQNaAlNJ3psYoe 0Wvw== X-Gm-Message-State: AOAM530/fzpOwv2peLMgrH3dZ0ykz8/M+66CGWNNesLjbxCXeLO2zuvp 5ydsO/Wx5GRKABnVxO+9Wf7pZcIAL2962g== X-Google-Smtp-Source: ABdhPJwxlR1tasWj8I4dTGhLmdFaC+kEF8dazPqIRuKiWZCfyfybzBHPNljq3cdI+ltW5Hocp7ZDZg== X-Received: by 2002:a63:e802:: with SMTP id s2mr21569528pgh.350.1600326363295; Thu, 17 Sep 2020 00:06:03 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y197sm5407372pfc.220.2020.09.17.00.06.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:06:02 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Marcel Holtmann <marcel@holtmann.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v3 5/8] adapter: Clear all Adv monitors upon bring-up Date: Thu, 17 Sep 2020 00:05:01 -0700 Message-Id: <20200917000448.BlueZ.v3.5.Id6bfe7838831ae01fddc8605689dd77b51673960@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.71 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4B4164096C X-Rspamd-UID: 51ffa7 This clears all Adv monitors upon daemon bring-up by issuing MGMT_OP_REMOVE_ADV_MONITOR command with monitor_handle 0. The following test was performed: - Add an Adv Monitor using btmgmt, restart bluetoothd and observe the monitor got removed. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Howard Chung <howardchung@google.com> --- (no changes since v1) src/adapter.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index d33ce7124..191467048 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -9513,6 +9513,43 @@ failed: btd_adapter_unref(adapter); } +static void reset_adv_monitors_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct mgmt_rp_remove_adv_monitor *rp = param; + + if (status != MGMT_STATUS_SUCCESS) { + error("Failed to reset Adv Monitors: %s (0x%02x)", + mgmt_errstr(status), status); + return; + } + + if (length < sizeof(*rp)) { + error("Wrong size of remove Adv Monitor response for reset " + "all Adv Monitors"); + return; + } + + DBG("Removed all Adv Monitors"); +} + +static void reset_adv_monitors(uint16_t index) +{ + struct mgmt_cp_remove_adv_monitor cp; + + DBG("sending remove Adv Monitor command with handle 0"); + + /* Handle 0 indicates to remove all */ + cp.monitor_handle = 0; + if (mgmt_send(mgmt_master, MGMT_OP_REMOVE_ADV_MONITOR, index, + sizeof(cp), &cp, reset_adv_monitors_complete, NULL, + NULL) > 0) { + return; + } + + error("Failed to reset Adv Monitors"); +} + static void index_added(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9527,6 +9564,8 @@ static void index_added(uint16_t index, uint16_t length, const void *param, return; } + reset_adv_monitors(index); + adapter = btd_adapter_new(index); if (!adapter) { btd_error(index, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kO0TAA4LY1+GOAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:06:54 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id mKyROA0LY1/vIgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:06:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 635304098F; Thu, 17 Sep 2020 09:06:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726210AbgIQHGR (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:06:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726304AbgIQHFo (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:05:44 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 523A6C06178C for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:05:40 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id k15so609933pfc.12 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B/ouiIw1nB2enIW/ZatYxPRatkXG5fstTpxr8JwcAuo=; b=FWSGI9seLjRPq378LH58UuVvp9LhqCP8/rlpHULO4jQ8/4NIdec+B74iiVMzEPLv40 rhEXEiTrlLC3PKgg7/fZbVOQCTP6nvINLtk6lfKssdjYExVCNCL7/G1SeP8lcTfwhJrS jfSN6+ZvrHqK72DVSBzJhnESrZ0ZKMZAn3DZA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B/ouiIw1nB2enIW/ZatYxPRatkXG5fstTpxr8JwcAuo=; b=A8AegrghwYOo5QirVWRj5SPM4iSI8+4RUIPP6+0NU2waq5tMAELjPKkp8YRiE6citE f+Q0Mj1AF+GmWOVQ661HX7RELG4jqbdkwAE1gzNCuctCdu+z2udUwAQxGEiocTEwm5o7 Fy4KDbmJ3PIxI/5R9YSJf+2KiSc+znL+p32Ofv2iecd0XEOAghXI/0+2GP1CgK0Ie7+A 4+tl6cUQ+VL2OU6rjUSxXFajt6n0Yh2f5do7uH94bWej3/V0nkzeMc5idLOmY6xDwgyQ q7YifhFgd3pfaYGWTCCawjeYo6EMoz5lUjYuUrcdwEspSyZ4ySpUhfhF8P+TjBM6QPmF qQYQ== X-Gm-Message-State: AOAM533RjMtqvHCpK0R/ieoafYPcF2OPJuTEJxq+fHXBO35QlE9CrE3h vJBUsBX63e+0uGaONE4/iRIBeF3aWl9TTA== X-Google-Smtp-Source: ABdhPJwatx7PVbk0sBgFVpEbUhikQqEXLMgESAxu82WQBj98rl1vZAWZQO0Yfm02+CtzhqwNLt80ZQ== X-Received: by 2002:a65:64cc:: with SMTP id t12mr22072756pgv.106.1600326339451; Thu, 17 Sep 2020 00:05:39 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y197sm5407372pfc.220.2020.09.17.00.05.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:05:38 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Marcel Holtmann <marcel@holtmann.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v3 4/8] adv_monitor: Implement unit tests for content filter Date: Thu, 17 Sep 2020 00:04:59 -0700 Message-Id: <20200917000448.BlueZ.v3.4.I7f88b6e4c63c14d77974438eb2f07326aedbfd9b@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: 635304098F X-Rspamd-UID: 3d6fc5 This implements the unit tests for verifying the correctness of advertisement data fields matching against a pattern. Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v3: - Fix mixed declarations and assignments Changes in v2: - Cast test data to void * doc/test-coverage.txt | 4 +- unit/test-adv-monitor.c | 144 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 2 deletions(-) diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt index 5296983e6..e15474a44 100644 --- a/doc/test-coverage.txt +++ b/doc/test-coverage.txt @@ -30,9 +30,9 @@ test-gobex-transfer 36 OBEX transfer handling test-gdbus-client 13 D-Bus client handling test-gatt 180 GATT qualification test cases test-hog 6 HID Over GATT qualification test cases -test-adv-monitor 5 Advertisement Monitor test cases +test-adv-monitor 9 Advertisement Monitor test cases ----- - 766 + 770 Automated end-to-end testing diff --git a/unit/test-adv-monitor.c b/unit/test-adv-monitor.c index 970be84b0..a19a3092b 100644 --- a/unit/test-adv-monitor.c +++ b/unit/test-adv-monitor.c @@ -40,6 +40,8 @@ if (type == TEST_RSSI_FILTER) { \ test.rssi_filter_test_data = (void *)&data; \ test.rssi_filter_test_data->test_info = &test; \ + } else if (type == TEST_CONTENT_FILTER) { \ + test.content_filter_test_data = (void *)&data; \ } \ tester_add(name, &test, setup_fn, test_fn, teardown_fn);\ } while (0) @@ -94,6 +96,22 @@ struct rssi_filter_test { } test_steps[]; }; +struct content_filter_test { + void *advmon_pattern; /* btd_adv_monitor_pattern */ + + bool expected_match; + + const struct { + uint8_t ad_type; + uint8_t offset; + uint8_t length; + uint8_t value[BT_AD_MAX_DATA_LEN]; + } pattern; + + uint8_t eir_len; + uint8_t eir[]; +}; + /* Parent data structure to hold the test data and information, * used by tester_* functions and callbacks. */ @@ -103,6 +121,7 @@ struct test_data { union { struct rssi_filter_test *rssi_filter_test_data; + struct content_filter_test *content_filter_test_data; }; }; @@ -211,6 +230,62 @@ static struct rssi_filter_test rssi_data_5 = { }, }; +/* Content Filter Test 1: + * The valid EIR data contains the given pattern whose content is a UUID16 AD + * data. + */ +static struct content_filter_test content_data_1 = { + .expected_match = true, + .pattern = {0x03, 0x02, 0x02, {0x09, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 2: + * The valid EIR data does not match the given pattern whose content is a UUID16 + * AD data. + */ +static struct content_filter_test content_data_2 = { + .expected_match = false, + .pattern = {0x03, 0x02, 0x02, {0x0d, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 3: + * The valid EIR data does not have the given pattern whose content is a UUID32 + * AD data. + */ +static struct content_filter_test content_data_3 = { + .expected_match = false, + .pattern = {0x05, 0x00, 0x04, {0x09, 0x18, 0x00, 0x00} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 4: + * The valid EIR data does not match the given pattern whose content is a + * UUID16 AD data due to invalid starting position of matching. + */ +static struct content_filter_test content_data_4 = { + .expected_match = false, + .pattern = {0x03, 0x02, 0x02, {0x09, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x03, 0x03, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + /* Initialize the data required for RSSI Filter test */ static void setup_rssi_filter_test(gpointer data) { @@ -343,6 +418,60 @@ static gboolean test_rssi_filter(gpointer data) return FALSE; } +/* Initialize the data required for Content Filter test */ +static void setup_content_filter_test(gpointer data) +{ + struct content_filter_test *test = data; + struct btd_adv_monitor_pattern *pattern = NULL; + + pattern = btd_adv_monitor_test_pattern_create(test->pattern.ad_type, + test->pattern.offset, + test->pattern.length, + test->pattern.value); + if (!pattern) { + tester_setup_failed(); + return; + } + + test->advmon_pattern = pattern; + tester_setup_complete(); +} + +/* Cleanup after the Content Filter test is done */ +static void teardown_content_filter_test(gpointer data) +{ + struct content_filter_test *test = data; + + if (!test) + tester_teardown_complete(); + + btd_adv_monitor_test_pattern_destroy(test->advmon_pattern); + test->advmon_pattern = NULL; + + tester_teardown_complete(); +} + +/* Execute the sub-steps of Content Filter test */ +static void test_content_filter(gpointer data) +{ + struct content_filter_test *test = data; + struct btd_adv_monitor_pattern *pattern = test->advmon_pattern; + + if (!pattern) { + tester_test_abort(); + return; + } + + if (btd_adv_monitor_pattern_match(test->eir, test->eir_len, + test->advmon_pattern) == + test->expected_match) { + tester_test_passed(); + return; + } + + tester_test_failed(); +} + /* Handler function to prepare for a test */ static void setup_handler(gconstpointer data) { @@ -350,6 +479,8 @@ static void setup_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) setup_rssi_filter_test(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + setup_content_filter_test(test->content_filter_test_data); } /* Handler function to cleanup after the test is done */ @@ -359,6 +490,8 @@ static void teardown_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) teardown_rssi_filter_test(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + teardown_content_filter_test(test->content_filter_test_data); } /* Handler function to execute a test with the given data set */ @@ -368,6 +501,8 @@ static void test_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) test_rssi_filter(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + test_content_filter(test->content_filter_test_data); } int main(int argc, char *argv[]) @@ -387,5 +522,14 @@ int main(int argc, char *argv[]) define_test("/advmon/rssi/5", TEST_RSSI_FILTER, rssi_data_5, setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/1", TEST_CONTENT_FILTER, content_data_1, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/2", TEST_CONTENT_FILTER, content_data_2, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/3", TEST_CONTENT_FILTER, content_data_3, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/4", TEST_CONTENT_FILTER, content_data_4, + setup_handler, test_handler, teardown_handler); + return tester_run(); } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iAVDER4LY1/4hwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:07:10 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8ClaDh4LY1+QJwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:07:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 174DF40941; Thu, 17 Sep 2020 09:07:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726373AbgIQHGr (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:06:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726217AbgIQHGe (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:06:34 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4835BC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:06:34 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id j34so811692pgi.7 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A+EJCB6WY4TQKa6gHOsgkF94rPPA4eTIhn24gfOv1nI=; b=FF2N56PeIxVmnF0nGltOa7r6EMHha58z7gvoJwo7mWCQvJtkmgIdJkq+qLADDM1zNL QAkRpePyXvdBSBtA/2w8BmSnWeVuG8LpiIGsIOlD1qnMQ/D3exppan5R1XgrfGn59lkb QAgjQERN6iF3VsS8STtpcU9jHBMvnChdsnknI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A+EJCB6WY4TQKa6gHOsgkF94rPPA4eTIhn24gfOv1nI=; b=Hv7RlNibDtSwrSIi/mKFfbWMZ6nN4MriVldrAviWngmS7hRrSaL2VrNUoGI/Sg2EBz ltKoBv/swTNqSkstWhaoTxxIVUt1sb8/o4oFER7/4Yqm7/zeoJQb25U1vFVR2IkSUYBt xazBpoF7CgueukZB6SsEWOKM1wCso0D34/Mi5qE17BBgKSEtRaIVvGG4M75PF9l9RHGY k+5ZtMTWv/Pn+jiWqkcgtq/Sw09h6snxIRMwrnocoGjQWKHcbFNln3r9tEINGjrmgJY9 xthA6WoANhES8cniwEwVreGeiswSo1gwsM25hXbysKFPq7HPu9DB2zG+Xhe3J9yyFAh4 ZPpQ== X-Gm-Message-State: AOAM53204N+y8E9o7P2G3/AwUXrs5hCJJ2WZaFEEDTfuuBLg2WTRk+E8 jUxian+U2fNhLyvpb3MZ1pU92k8/j1iBhA== X-Google-Smtp-Source: ABdhPJxaxXAPMJwgOVtYfC2bOjtHTHJ/6SnYQZuOFUwcNEEaIlNcw06Uj8kP/FClvULzQNUARTCm9w== X-Received: by 2002:a63:30c:: with SMTP id 12mr21539115pgd.66.1600326393586; Thu, 17 Sep 2020 00:06:33 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y197sm5407372pfc.220.2020.09.17.00.06.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:06:32 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Marcel Holtmann <marcel@holtmann.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v3 7/8] adv_monitor: Fix return type of RegisterMonitor() method Date: Thu, 17 Sep 2020 00:05:05 -0700 Message-Id: <20200917000448.BlueZ.v3.7.Ic8dbe9115e82704b4c0c860eee27ad897db13237@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.85 / 15.00 / 15.00 X-Rspamd-Queue-Id: 174DF40941 X-Rspamd-UID: ab2989 This modifies the D-Bus call return type to be asynchronous for RegisterMonitor() method call. The following test was performed: - Enter bluetoothctl, exit the console and re-enter the console without AlreadyExist error for RegisterMonitor() upon bring-up of the console. Reviewed-by: Howard Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index deaa1894a..b4fe39eff 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -758,6 +758,8 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, app->monitors = queue_new(); + app->reg = dbus_message_ref(msg); + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); /* Note that any property changes on a monitor object would not affect @@ -769,8 +771,6 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); - app->reg = dbus_message_ref(msg); - return app; } @@ -864,7 +864,7 @@ static DBusMessage *unregister_monitor(DBusConnection *conn, } static const GDBusMethodTable adv_monitor_methods[] = { - { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YKSMNycLY1/4hwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:07:19 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8HJPNCcLY19W6QAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:07:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1FB8B40971; Thu, 17 Sep 2020 09:07:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726365AbgIQHG1 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbgIQHGX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:06:23 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59356C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:06:16 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id fa1so784307pjb.0 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wXANRElz/qKLo+YPc/C/DfIhCrjha/xK9SJq8ld3Zj4=; b=T4OokhgkkLb70sIJ4Vu1jrs/pSTuQdsCkaJPGUGOguOoSNoousmbf0KR4yE3pzycSf 0a8DoDn8SMQRpO/XjeKogSdfA3u3GnhMKRAgl6jJFPAGUy2OBkaR19Z9WfsEQf3m/rwh rAEVqY1pLilDcermnvDjFT/kHgd21M92cUH84= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wXANRElz/qKLo+YPc/C/DfIhCrjha/xK9SJq8ld3Zj4=; b=TBihOXZCdg1CtWXmQjdTg7cXWolnztG/JG7eN7PXeiLgn0jFrh8e5DdovU/P1m8H4M Q+QQX5sgqficxOdWBAqTn+MWVqMjzFH1YGfMN0ajedeqacz2s4eAqyf1AaISVeh6SVFw vq+FbAIGbPlmT0kBVBinfsFpoj7Zxe7IHRk4z/ky5bOkuIf+2KBymFNPrzzaye3p5iyv mO8pOHM3uSPnYF1qtmiACzKWFnGG4g8UXs9pv11d61yBZV0zWSVymH2Ksp8vQ14Tay/g UNJyLGEaUTWZZ5SaCS8OVrr/vzDfbraw4Jl2qdm9Xh040GZPGO7u6F+8Gp7hwxm+4qNy ZfLA== X-Gm-Message-State: AOAM53110+QNQbPQCxYvG88dOVj93lPkr3MtZG2cBq2AvTuzi8KMXTm8 7GrOvYayr5R/7BEzuFw7qp3E0jm/H9QXjA== X-Google-Smtp-Source: ABdhPJzkvlJzek6dp6JUIFQVfbsZK1n/uh8OpC8PeOTydIRmCO/QKy2OCyy0WlGCzd6LsuVcA4726g== X-Received: by 2002:a17:90a:e02:: with SMTP id v2mr7104250pje.6.1600326374869; Thu, 17 Sep 2020 00:06:14 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y197sm5407372pfc.220.2020.09.17.00.06.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:06:14 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Marcel Holtmann <marcel@holtmann.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v3 6/8] adv_monitor: Implement Add Adv Patterns Monitor cmd handler Date: Thu, 17 Sep 2020 00:05:03 -0700 Message-Id: <20200917000448.BlueZ.v3.6.Ibbcb11712b613ef95c31b41207c3ea945c830018@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.46 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1FB8B40971 X-Rspamd-UID: fbe76a From: Howard Chung <howardchung@google.com> - Send the MGMT_OP command to kernel upon registration of a Adv patterns monitor. - Call Activate() or Release() to client depending on the reply from kernel the call through syslog Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 211094c89..deaa1894a 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -609,11 +609,59 @@ done: return monitor->state != MONITOR_STATE_FAILED; } +/* Handles the callback of Add Adv Patterns Monitor command */ +static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_rp_add_adv_patterns_monitor *rp = param; + struct adv_monitor *monitor = user_data; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(adapter_id, "Failed to Add Adv Patterns Monitor " + "with status 0x%02x", status); + monitor_release(monitor, NULL); + return; + } + + if (length < sizeof(*rp)) { + btd_error(adapter_id, "Wrong size of Add Adv Patterns Monitor " + "response"); + monitor_release(monitor, NULL); + return; + } + + monitor->state = MONITOR_STATE_HONORED; + + DBG("Calling Activate() on Adv Monitor of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "Activate", NULL, NULL, NULL, + NULL); + + DBG("Adv Monitor with handle:0x%04x added", + le16_to_cpu(rp->monitor_handle)); +} + +static void monitor_copy_patterns(void *data, void *user_data) +{ + struct btd_adv_monitor_pattern *pattern = data; + struct mgmt_cp_add_adv_monitor *cp = user_data; + + if (!pattern) + return; + + memcpy(cp->patterns + cp->pattern_count, pattern, sizeof(*pattern)); + cp->pattern_count++; +} + /* Handles an Adv Monitor D-Bus proxy added event */ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) { struct adv_monitor *monitor; struct adv_monitor_app *app = user_data; + struct mgmt_cp_add_adv_monitor *cp = NULL; + uint8_t pattern_count, cp_len; uint16_t adapter_id = app->manager->adapter_id; const char *path = g_dbus_proxy_get_path(proxy); const char *iface = g_dbus_proxy_get_interface(proxy); @@ -646,7 +694,24 @@ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) queue_push_tail(app->monitors, monitor); + pattern_count = queue_length(monitor->patterns); + cp_len = sizeof(struct mgmt_cp_add_adv_monitor) + + pattern_count * sizeof(struct mgmt_adv_pattern); + + cp = malloc0(cp_len); + queue_foreach(monitor->patterns, monitor_copy_patterns, cp); + + if (!mgmt_send(app->manager->mgmt, MGMT_OP_ADD_ADV_PATTERNS_MONITOR, + adapter_id, cp_len, cp, add_adv_patterns_monitor_cb, + monitor, NULL)) { + error("Unable to send Add Adv Patterns Monitor command"); + goto done; + } + DBG("Adv Monitor allocated for the object at path %s", path); + +done: + free(cp); } /* Handles the removal of an Adv Monitor D-Bus proxy */ @@ -1063,7 +1128,7 @@ static void adv_match_per_monitor(void *data, void *user_data) struct adv_monitor *monitor = data; struct adv_content_filter_info *info = user_data; - if (!monitor && monitor->state != MONITOR_STATE_HONORED) + if (!monitor || monitor->state != MONITOR_STATE_HONORED) return; /* Reset the intermediate matched status */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wKZ4JS4LY1+GOAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:07:26 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id iInNIC4LY1/cGgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:07:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 086C14098F; Thu, 17 Sep 2020 09:07:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726249AbgIQHHH (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:07:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbgIQHGu (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:06:50 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1420C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:06:49 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 7so802003pgm.11 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NdeK9jrlbDmnJ07T/Z6f3zn8nKeo+Ri2ioiOM8etDYk=; b=mU3QgRhGh7VqA72Z6FfXfRR7d3d3ExVV0jY6g5UZusp0tHnOdhxE5fyJYI7L7KD9R8 E301OSe2P+uI6uH0+c8j8VHoxsHJ/O2RZXIVh/H7Rx/3+vNOgZaGBG9+6m56a23qrWCY nkPVmJIv9i+uaf+HQhZCt8dAy8oQGZlaYlop8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NdeK9jrlbDmnJ07T/Z6f3zn8nKeo+Ri2ioiOM8etDYk=; b=Lk+l2q/lHNglyfS0bVJs1swXHqolfj/FuIljFt1xZ2ONeF4JLuI4y8r2+mIOBiqw6L HxSrhf6AAZ6+4plaaGrCjPO5lef5x8oqNjfAnPGzcCf58EJx56ZxhZphkmcIj2YG1qlH Hmz8C+Ge1Es9u63s5V+JTpVOThZWBJAIf1YiW65fi0p63ba+IKyOiZHpBd39ni3m6qbS S/LFJiqbygXrvJGripLaadhzfpzrz8qOblPc91TML208Hx8seMjMOVwuzqZCUzAdwP9J TQeSgzN4DuJFDzhWJGtsnJx+pmWdxoLb1KmCw3VeWGUse4y8nlVB24IUl5GOjiW5oxNi yvyg== X-Gm-Message-State: AOAM531Q9smGIcfsFfucJtQoYFI+JM9FglATAVr8q3Bvulo6gYTLmoAy k1nbNmSx9phpNiINHxbw7Ez2ez8tiiZQFA== X-Google-Smtp-Source: ABdhPJzCj2mdX7DUBKZmn2Ro004df9GNjfmoXTF3DbYgKPRK8nr4eipKPKT2AJ5krVgf+EirCaqD0w== X-Received: by 2002:a63:4404:: with SMTP id r4mr19954616pga.29.1600326409123; Thu, 17 Sep 2020 00:06:49 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y197sm5407372pfc.220.2020.09.17.00.06.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:06:48 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Marcel Holtmann <marcel@holtmann.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Subject: [BlueZ PATCH v3 8/8] adv_monitor: Issue Remove Adv Monitor mgmt call Date: Thu, 17 Sep 2020 00:05:07 -0700 Message-Id: <20200917000448.BlueZ.v3.8.Ifda683c92ff520bf58ac37c02dc40b8d9598d1b0@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.17 / 15.00 / 15.00 X-Rspamd-Queue-Id: 086C14098F X-Rspamd-UID: 9d6ef0 From: Alain Michaud <alainm@chromium.org> This calls Remove Adv Monitor command to kernel and handles the callback during a monitor removal initiated by a D-Bus client. This also registers callback for getting notified on Adv Monitor Removed event, so that the Adv monitor manager can invalidate the monitor by calling Release() on its proxy. The following tests were performed. - In bluetoothctl console, add a monitor and remove the monitor by its index and verify the removal in both the output of btmgmt and syslog. - In bluetoothctl console, add a monitor, remove the monitor via btmgmt and verify the removal in syslog. Reviewed-by: Howard Chung <howardchung@google.com> --- Changes in v3: - Fix const qualifier of a pointer src/adv_monitor.c | 128 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 120 insertions(+), 8 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index b4fe39eff..27da30b51 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -88,6 +88,7 @@ enum monitor_state { MONITOR_STATE_FAILED, /* Failed to be init'ed */ MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ MONITOR_STATE_HONORED, /* Accepted by kernel */ + MONITOR_STATE_REMOVING, /* Removing from kernel */ }; struct btd_adv_monitor_pattern { @@ -103,6 +104,7 @@ struct adv_monitor { char *path; enum monitor_state state; /* MONITOR_STATE_* */ + uint16_t monitor_handle; /* Kernel Monitor Handle */ int8_t high_rssi; /* High RSSI threshold */ uint16_t high_rssi_timeout; /* High RSSI threshold timeout */ @@ -631,6 +633,7 @@ static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, return; } + monitor->monitor_handle = le16_to_cpu(rp->monitor_handle); monitor->state = MONITOR_STATE_HONORED; DBG("Calling Activate() on Adv Monitor of owner %s at path %s", @@ -639,8 +642,7 @@ static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, g_dbus_proxy_method_call(monitor->proxy, "Activate", NULL, NULL, NULL, NULL); - DBG("Adv Monitor with handle:0x%04x added", - le16_to_cpu(rp->monitor_handle)); + DBG("Adv monitor with handle:0x%04x added", monitor->monitor_handle); } static void monitor_copy_patterns(void *data, void *user_data) @@ -714,20 +716,77 @@ done: free(cp); } +/* Handles the callback of Remove Adv Monitor command */ +static void remove_adv_monitor_cb(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct adv_monitor *monitor = user_data; + const struct mgmt_rp_remove_adv_monitor *rp = param; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(adapter_id, "Failed to Remove Adv Monitor with " + "status 0x%02x", status); + goto done; + } + + if (length < sizeof(*rp)) { + btd_error(adapter_id, "Wrong size of Remove Adv Monitor " + "response"); + goto done; + } + +done: + queue_remove(monitor->app->monitors, monitor); + + DBG("Adv Monitor removed with handle:0x%04x, path %s", + monitor->monitor_handle, monitor->path); + + monitor_free(monitor); +} + + /* Handles the removal of an Adv Monitor D-Bus proxy */ static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) { struct adv_monitor *monitor; + struct mgmt_cp_remove_adv_monitor cp; struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; - monitor = queue_remove_if(app->monitors, monitor_match, proxy); - if (monitor) { - DBG("Adv Monitor removed for the object at path %s", - monitor->path); + monitor = queue_find(app->monitors, monitor_match, proxy); - /* The object was gone, so we don't need to call Release() */ - monitor_free(monitor); + /* A monitor removed event from kernel can remove a monitor and notify + * the app on Release() where this callback can be invoked, so we + * simply skip here. + */ + if (!monitor) + return; + + if (monitor->state != MONITOR_STATE_HONORED) + goto done; + + monitor->state = MONITOR_STATE_REMOVING; + + cp.monitor_handle = cpu_to_le16(monitor->monitor_handle); + + if (!mgmt_send(app->manager->mgmt, MGMT_OP_REMOVE_ADV_MONITOR, + adapter_id, sizeof(cp), &cp, remove_adv_monitor_cb, + monitor, NULL)) { + btd_error(adapter_id, "Unable to send Remove Advt Monitor " + "command"); + goto done; } + + return; + +done: + queue_remove(app->monitors, monitor); + + DBG("Adv Monitor removed in state %02x with path %s", monitor->state, + monitor->path); + + monitor_free(monitor); } /* Creates an app object, initiates it and sets D-Bus event handlers */ @@ -936,6 +995,55 @@ static const GDBusPropertyTable adv_monitor_properties[] = { { } }; +/* Matches a monitor based on its handle */ +static bool removed_monitor_match(const void *data, const void *user_data) +{ + const struct adv_monitor *monitor = data; + const struct mgmt_ev_adv_monitor_removed *ev = user_data; + + return monitor->monitor_handle == ev->monitor_handle; +} + +/* Remove the matched monitor and reports the removal to the app */ +static void app_remove_monitor(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + struct adv_monitor *monitor; + + monitor = queue_find(app->monitors, removed_monitor_match, user_data); + if (monitor) { + if (monitor->state == MONITOR_STATE_HONORED) + monitor_release(monitor, NULL); + + queue_remove(app->monitors, monitor); + + DBG("Adv Monitor at path %s removed", monitor->path); + + monitor_free(monitor); + } +} + +/* Processes Adv Monitor removed event from kernel */ +static void adv_monitor_removed_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const uint16_t adapter_id = manager->adapter_id; + struct btd_adv_monitor_manager *manager = user_data; + const struct mgmt_ev_adv_monitor_removed *ev = param; + + if (length < sizeof(*ev)) { + btd_error(adapter_id, "Wrong size of Adv Monitor Removed " + "event"); + return; + } + + /* Traverse the apps to find the monitor */ + queue_foreach(manager->apps, app_remove_monitor, ev); + + DBG("Adv Monitor removed event with handle 0x%04x processed", + ev->monitor_handle); +} + /* Allocates a manager object */ static struct btd_adv_monitor_manager *manager_new( struct btd_adapter *adapter, @@ -955,6 +1063,10 @@ static struct btd_adv_monitor_manager *manager_new( manager->adapter_id = btd_adapter_get_index(adapter); manager->apps = queue_new(); + mgmt_register(manager->mgmt, MGMT_EV_ADV_MONITOR_REMOVED, + manager->adapter_id, adv_monitor_removed_callback, + manager, NULL); + return manager; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GJ8vBU8LY19dkwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:07:59 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id oDyuAU8LY1/3YgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:07:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B074040979; Thu, 17 Sep 2020 09:07:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbgIQHHZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:07:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbgIQHFQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:05:16 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEADBC061756 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:05:15 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id d6so616707pfn.9 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H7eLYbynmsBUI1UoFuec+l/tjAeYp3ROWKGfqKXo9sI=; b=glp6m07BDvBaMGfFiy8thPNq0L2d4712Lt58z4JzrcFHdXvSjKVb5dJhFBt2UtW0GY 7l80mWzPTSL4ayQ2zZA6ik+Rh3ns/JIT3JbFGxYaehfBcgs8mlJvwylWIDJdDuqYoTiR uhoFQwKy57Nb2Q3A7Tg+kYgQFINIWe1PhaI20= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H7eLYbynmsBUI1UoFuec+l/tjAeYp3ROWKGfqKXo9sI=; b=tCtJgH/2dQ54mLarnPChBvWd8F+5lb3CH/EirBTK4ADd9j4NTC5tHfUgrwWLQfCqQS 3dfGuAhUkNSItBzHB9TWS7+HYlVLBr/YG1Ee5rvtQLkWSz+b7OCoZq2VHA603lgS14mg 6Xf+05WqAauAGDSj7NbPs0Tw5lPuLsmaIIGr4+w0yyY3jhshB8wQ0m2Vgueadkl6N5AW un8E1DPbohY5sKDOHEyNuwKW7kAV7Eis5soHL9M9AqivJTbIBkl/caWBi6UmLqlnKvs0 maAIhyuioIvi4QN1XHIbnmH0YK3WoG3RpjUsz2vv5plHmuM/ULg5hn3dkkWrMDoJcwAy pKzg== X-Gm-Message-State: AOAM533VIJFdKep7RsBdCXdojL7HG14WiIJ11mtvZQufeZP7QldC5fD6 WI6zhyhJCoiBpTaHBUuI7/XvTB4sukhsFA== X-Google-Smtp-Source: ABdhPJz4meJHrYfAtEypFKAubM7NM+hFLlQWFXT51HBg3VkRJ3j6POTFaU1r0mqNxoIMpscvr3xR+Q== X-Received: by 2002:a63:f84c:: with SMTP id v12mr5867963pgj.125.1600326314673; Thu, 17 Sep 2020 00:05:14 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y197sm5407372pfc.220.2020.09.17.00.05.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:05:14 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Marcel Holtmann <marcel@holtmann.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v3 2/8] adv_monitor: Implement unit tests for RSSI Filter Date: Thu, 17 Sep 2020 00:04:55 -0700 Message-Id: <20200917000448.BlueZ.v3.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.52 / 15.00 / 15.00 X-Rspamd-Queue-Id: B074040979 X-Rspamd-UID: c35901 From: Manish Mandlik <mmandlik@google.com> This patch implements unit tests for the background scanning RSSI Filtering logic. Verified all tests PASS by running tests in unit/test-adv-monitor.c USE="-bluez-next bluez-upstream" FEATURES=test emerge-hatch bluez Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Changes in v3: - Fix commit message Changes in v2: - Cast test data to void * Makefile.am | 9 + doc/test-coverage.txt | 3 +- src/adv_monitor.c | 79 ++++++++ src/adv_monitor.h | 10 + unit/test-adv-monitor.c | 391 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 491 insertions(+), 1 deletion(-) create mode 100644 unit/test-adv-monitor.c diff --git a/Makefile.am b/Makefile.am index 22b4fa30c..6918f02b0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -527,6 +527,15 @@ unit_test_gattrib_LDADD = lib/libbluetooth-internal.la \ src/libshared-glib.la \ $(GLIB_LIBS) $(DBUS_LIBS) -ldl -lrt +unit_tests += unit/test-adv-monitor + +unit_test_adv_monitor_SOURCES = unit/test-adv-monitor.c \ + src/adv_monitor.h src/adv_monitor.c \ + src/device.h src/device.c \ + src/log.h src/log.c +unit_test_adv_monitor_LDADD = gdbus/libgdbus-internal.la \ + src/libshared-glib.la $(GLIB_LIBS) $(DBUS_LIBS) + if MIDI unit_tests += unit/test-midi unit_test_midi_CPPFLAGS = $(AM_CPPFLAGS) $(ALSA_CFLAGS) -DMIDI_TEST diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt index 741492a3e..5296983e6 100644 --- a/doc/test-coverage.txt +++ b/doc/test-coverage.txt @@ -30,8 +30,9 @@ test-gobex-transfer 36 OBEX transfer handling test-gdbus-client 13 D-Bus client handling test-gatt 180 GATT qualification test cases test-hog 6 HID Over GATT qualification test cases +test-adv-monitor 5 Advertisement Monitor test cases ----- - 761 + 766 Automated end-to-end testing diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 7baa5317f..046f5953f 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -1210,3 +1210,82 @@ static void adv_monitor_filter_rssi(struct adv_monitor *monitor, handle_device_lost_timeout, dev); } } + +/* Creates the dummy adv_monitor object for unit tests */ +void *btd_adv_monitor_rssi_test_setup(int8_t high_rssi, uint16_t high_timeout, + int8_t low_rssi, uint16_t low_timeout) +{ + struct adv_monitor *test_monitor = NULL; + + test_monitor = g_new0(struct adv_monitor, 1); + if (!test_monitor) + return NULL; + + test_monitor->app = g_new0(struct adv_monitor_app, 1); + if (!test_monitor->app) + goto app_failed; + + test_monitor->app->manager = g_new0(struct btd_adv_monitor_manager, 1); + if (!test_monitor->app->manager) + goto manager_failed; + + test_monitor->high_rssi = high_rssi; + test_monitor->high_rssi_timeout = high_timeout; + test_monitor->low_rssi = low_rssi; + test_monitor->low_rssi_timeout = low_timeout; + test_monitor->devices = queue_new(); + + return test_monitor; + +manager_failed: + g_free(test_monitor->app); + +app_failed: + g_free(test_monitor); + + return NULL; +} + +/* Cleanup after unit test is done */ +void btd_adv_monitor_rssi_test_teardown(void *monitor_obj) +{ + struct adv_monitor *monitor = monitor_obj; + + if (!monitor) + return; + + queue_destroy(monitor->devices, monitor_device_free); + g_free(monitor); +} + +/* Returns the current state of device - found/lost, used in unit tests */ +bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj) +{ + struct adv_monitor *monitor = monitor_obj; + struct btd_device *device = device_obj; + struct adv_monitor_device *dev = NULL; + + if (!monitor || !device) + return false; + + dev = queue_find(monitor->devices, monitor_device_match, device); + if (!dev) + return false; + + return dev->device_found; +} + +/* Helper function for the RSSI Filter unit tests */ +bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, + int8_t adv_rssi) +{ + struct adv_monitor *monitor = monitor_obj; + struct btd_device *device = device_obj; + + if (!monitor || !device) + return false; + + adv_monitor_filter_rssi(monitor, device, adv_rssi); + + return btd_adv_monitor_test_device_state(monitor, device); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 14508e7d1..351e7f9aa 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -33,4 +33,14 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, struct btd_device *device); +/* Following functions are the helper functions used for RSSI Filter unit tests + * defined in unit/test-adv-monitor.c + */ +void *btd_adv_monitor_rssi_test_setup(int8_t high_rssi, uint16_t high_timeout, + int8_t low_rssi, uint16_t low_timeout); +void btd_adv_monitor_rssi_test_teardown(void *monitor_obj); +bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj); +bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, + int8_t adv_rssi); + #endif /* __ADV_MONITOR_H */ diff --git a/unit/test-adv-monitor.c b/unit/test-adv-monitor.c new file mode 100644 index 000000000..970be84b0 --- /dev/null +++ b/unit/test-adv-monitor.c @@ -0,0 +1,391 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <glib.h> +#include <stdbool.h> +#include <stdint.h> +#include <unistd.h> + +#include "src/log.h" +#include "src/shared/tester.h" + +#include "src/adv_monitor.h" + +#define define_test(name, type, data, setup_fn, test_fn, teardown_fn) \ + do { \ + static struct test_data test; \ + test.test_type = type; \ + test.test_name = g_strdup(name); \ + if (type == TEST_RSSI_FILTER) { \ + test.rssi_filter_test_data = (void *)&data; \ + test.rssi_filter_test_data->test_info = &test; \ + } \ + tester_add(name, &test, setup_fn, test_fn, teardown_fn);\ + } while (0) + +#define ADV_INTERVAL 1 /* Advertisement interval in seconds */ +#define OUT_OF_RANGE -128 +#define END_OF_RSSI_TEST {0} + +#define RSSI_TEST_DONE(test_step) \ + (!test_step.adv_rssi && !test_step.duration && !test_step.result) + +#define DUMMY_BTD_DEVICE_OBJ ((void *) 0xF00) + +enum test_type { + TEST_RSSI_FILTER = 0, + TEST_CONTENT_FILTER, +}; + +enum result { + RESULT_DEVICE_NOT_FOUND = false, /* Initial state of a device */ + RESULT_DEVICE_FOUND = true, /* Device state when the + * Content/RSSI Filter match + */ + RESULT_DEVICE_LOST = false, /* Device state when the Low + * RSSI Filter match or if it + * goes offline/out-of-range + */ +}; + +struct rssi_filter_test { + void *adv_monitor_obj; /* struct adv_monitor object */ + void *btd_device_obj; /* struct btd_device object */ + struct test_data *test_info; + + const struct { + int8_t high_rssi_threshold; /* High RSSI threshold */ + uint16_t high_rssi_timeout; /* High RSSI threshold timeout*/ + int8_t low_rssi_threshold; /* Low RSSI threshold */ + uint16_t low_rssi_timeout; /* Low RSSI threshold timeout */ + } rssi_filter; + + time_t start_time; /* Start time of the test */ + uint16_t resume_step; /* Store the current sub-step of the + * test before suspending that test + */ + guint out_of_range_timer; /* Timer to simulate device offline */ + + const struct { + int8_t adv_rssi; /* Advertisement RSSI */ + uint16_t duration; /* Advertisement duration in seconds */ + enum result result; /* Device state after every step */ + } test_steps[]; +}; + +/* Parent data structure to hold the test data and information, + * used by tester_* functions and callbacks. + */ +struct test_data { + enum test_type test_type; + char *test_name; + + union { + struct rssi_filter_test *rssi_filter_test_data; + }; +}; + +/* RSSI Filter Test 1: + * - The Device Lost event should NOT get triggered even if the Adv RSSI is + * lower than LowRSSIThresh for more than LowRSSITimeout before finding + * the device first. + * - Similarly, the Device Found event should NOT get triggered if the Adv RSSI + * is greater than LowRSSIThresh but lower than HighRSSIThresh. + */ +static struct rssi_filter_test rssi_data_1 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-70, 6, RESULT_DEVICE_NOT_FOUND}, + {-50, 6, RESULT_DEVICE_NOT_FOUND}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 2: + * - The Device Found event should get triggered when the Adv RSSI is higher + * than HighRSSIThresh for more than HighRSSITimeout. + * - Once the device is found, the Device Lost event should NOT get triggered + * if the Adv RSSI drops below HighRSSIThresh but it is not lower than + * LowRSSIThresh. + * - When the Adv RSSI drops below LowRSSIThresh for more than LowRSSITimeout, + * the Device Lost event should get triggered. + */ +static struct rssi_filter_test rssi_data_2 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-30, 6, RESULT_DEVICE_FOUND}, + {-50, 6, RESULT_DEVICE_FOUND}, + {-70, 6, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 3: + * - The Device Found event should get triggered only when the Adv RSSI is + * higher than HighRSSIThresh for more than HighRSSITimeout. + * - If the Adv RSSI drops below HighRSSIThresh, timer should reset and start + * counting once the Adv RSSI is above HighRSSIThresh. + * - Similarly, when tracking the Low RSSI, timer should reset when the Adv RSSI + * goes above LowRSSIThresh. The Device Lost event should get triggered only + * when the Adv RSSI is lower than LowRSSIThresh for more than LowRSSITimeout. + */ +static struct rssi_filter_test rssi_data_3 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-30, 2, RESULT_DEVICE_NOT_FOUND}, + {-50, 6, RESULT_DEVICE_NOT_FOUND}, + {-30, 4, RESULT_DEVICE_NOT_FOUND}, + {-30, 2, RESULT_DEVICE_FOUND}, + {-70, 2, RESULT_DEVICE_FOUND}, + {-50, 6, RESULT_DEVICE_FOUND}, + {-70, 4, RESULT_DEVICE_FOUND}, + {-70, 2, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 4: + * - While tracking the High RSSI, timer should reset if the device goes + * offline/out-of-range for more than HighRSSITimeout. + * - Once the device is found, if the device goes offline/out-of-range for + * more than LowRSSITimeout, the Device Lost event should get triggered. + */ +static struct rssi_filter_test rssi_data_4 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + { -30, 2, RESULT_DEVICE_NOT_FOUND}, + {OUT_OF_RANGE, 6, RESULT_DEVICE_NOT_FOUND}, + { -30, 4, RESULT_DEVICE_NOT_FOUND}, + { -30, 2, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 6, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 5: + * - The Device Found event should get triggered only once even if the Adv RSSI + * stays higher than HighRSSIThresh for a longer period of time. + * - Once the device is found, while tracking the Low RSSI, timer should reset + * when the Adv RSSI goes above LowRSSIThresh. + * - The timer should NOT reset if the device goes offline/out-of-range for + * a very short period of time and comes back online/in-range before + * the timeouts. + */ +static struct rssi_filter_test rssi_data_5 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + { -30, 2, RESULT_DEVICE_NOT_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_NOT_FOUND}, + { -30, 2, RESULT_DEVICE_FOUND}, + { -30, 3, RESULT_DEVICE_FOUND}, + { -30, 3, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_FOUND}, + { -50, 6, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* Initialize the data required for RSSI Filter test */ +static void setup_rssi_filter_test(gpointer data) +{ + struct rssi_filter_test *test = data; + + test->adv_monitor_obj = btd_adv_monitor_rssi_test_setup( + test->rssi_filter.high_rssi_threshold, + test->rssi_filter.high_rssi_timeout, + test->rssi_filter.low_rssi_threshold, + test->rssi_filter.low_rssi_timeout); + + /* The RSSI Filter logic uses btd_device object only as a key in the + * adv_monitor->devices list, it is never dereferenced nor used to + * perform any operations related to btd_device. So we can use any + * dummy address for unit testing. + */ + test->btd_device_obj = DUMMY_BTD_DEVICE_OBJ; + + tester_setup_complete(); +} + +/* Cleanup after the RSSI Filter test is done */ +static void teardown_rssi_filter_test(gpointer data) +{ + struct rssi_filter_test *test = data; + + btd_adv_monitor_rssi_test_teardown(test->adv_monitor_obj); + + tester_teardown_complete(); +} + +/* Execute the sub-steps of RSSI Filter test */ +static gboolean test_rssi_filter(gpointer data) +{ + struct rssi_filter_test *test = data; + time_t start_time = time(NULL); + bool ret = false; + + uint16_t i = 0; + uint16_t j = 0; + + /* If this is not the beginning of test, return to the sub-step + * before that test was suspended + */ + if (test->resume_step) { + start_time = test->start_time; + i = test->resume_step; + + /* Clear the test resume timer */ + g_source_remove(test->out_of_range_timer); + test->out_of_range_timer = 0; + + /* Check state of the device - found/lost, while device was + * offline/out-of-range + */ + ret = btd_adv_monitor_test_device_state(test->adv_monitor_obj, + test->btd_device_obj); + tester_debug("%s: [t=%.0lf, step=%d] Test resume, " + "device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + ret ? "true" : "false"); + g_assert(ret == test->test_steps[i].result); + + i++; + } + + while (!RSSI_TEST_DONE(test->test_steps[i])) { + if (test->test_steps[i].adv_rssi == OUT_OF_RANGE) { + /* Simulate device offline/out-of-range by suspending + * the test. + * + * Note: All tester_* functions run sequentially by + * adding a next function to the main loop using + * g_idle_add(). If a timeout function is added using + * g_timeout_add_*(), it doesn't really get invoked as + * soon as the timer expires. Instead, it is invoked + * once the current function returns and the timer has + * expired. So, to give handle_device_lost_timeout() + * function a chance to run at the correct time, we + * must save the current state and exit from this + * function while we simulate the device offline. We can + * come back later to continue with the remaining steps. + */ + test->resume_step = i; + test->start_time = start_time; + test->out_of_range_timer = g_timeout_add_seconds( + test->test_steps[i].duration, + test_rssi_filter, data); + + /* Check the device state before suspending the test */ + ret = btd_adv_monitor_test_device_state( + test->adv_monitor_obj, + test->btd_device_obj); + tester_debug("%s: [t=%.0lf, step=%d] Test suspend, " + "device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + ret ? "true" : "false"); + return FALSE; + } + + for (j = 0; j < test->test_steps[i].duration; j++) { + ret = btd_adv_monitor_test_rssi( + test->adv_monitor_obj, + test->btd_device_obj, + test->test_steps[i].adv_rssi); + tester_debug("%s: [t=%.0lf, step=%d] Test " + "advertisement RSSI %d, device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + test->test_steps[i].adv_rssi, + ret ? "true" : "false"); + + /* Sleep for a second to simulate receiving + * advertisement once every second + */ + sleep(ADV_INTERVAL); + } + g_assert(ret == test->test_steps[i].result); + + i++; + } + + tester_debug("%s: [t=%.0lf] Test done", test->test_info->test_name, + difftime(time(NULL), start_time)); + + tester_test_passed(); + + return FALSE; +} + +/* Handler function to prepare for a test */ +static void setup_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + setup_rssi_filter_test(test->rssi_filter_test_data); +} + +/* Handler function to cleanup after the test is done */ +static void teardown_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + teardown_rssi_filter_test(test->rssi_filter_test_data); +} + +/* Handler function to execute a test with the given data set */ +static void test_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + test_rssi_filter(test->rssi_filter_test_data); +} + +int main(int argc, char *argv[]) +{ + tester_init(&argc, &argv); + + __btd_log_init("*", 0); + + define_test("/advmon/rssi/1", TEST_RSSI_FILTER, rssi_data_1, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/2", TEST_RSSI_FILTER, rssi_data_2, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/3", TEST_RSSI_FILTER, rssi_data_3, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/4", TEST_RSSI_FILTER, rssi_data_4, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/5", TEST_RSSI_FILTER, rssi_data_5, + setup_handler, test_handler, teardown_handler); + + return tester_run(); +} -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MJuMNFYLY1+GOAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:08:06 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UISaMVYLY1+QJwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:08:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2D03A40968; Thu, 17 Sep 2020 09:07:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726196AbgIQHH1 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:07:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbgIQHFF (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:05:05 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FF6AC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:05:05 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id y6so623557plt.9 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sDqXCkXQZ7goM0PwAfEYoxwVPgx97yi616G18CFZ3Sk=; b=GDdTL9uEj3UCNT72uLZaYOKc1PuHKWWfKJuaJnljsb6EE7HvyNfLPe39xIYc/oPXI/ tiY18wyNGhQLmYLCMc2zmZ4KKdBY7A0mVnKejniU2aUZquWH09VwAc2qPmeGV12Q6JkE vWTdcrCZi9sHJSe/T57iCFI9rRBgvCTI2mqpA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sDqXCkXQZ7goM0PwAfEYoxwVPgx97yi616G18CFZ3Sk=; b=qJJ18YpavXGd0LULCm3L8qCMY7QnRR149J7YQ3D15zSKbJaUJK3I9KpH2In/a0qMpz DtHpcg7aMjEBwe3+JStebw2bFVIM/+aGkTKqQaZKFm58xAABqy1ZTCY/pAg/+OmYWUg5 JtVUY9SPAU0s7wdHoHepCTLxBQ6xCDvLYNNqDJqCofKWeYYboek0OM9y8ZwkMv9iRqKd jiAStZOud9xiVTFqE8LFyELZ/x3bjmo4ZTZ9Poxv+14MNSXChZauDSgzzc7FSCKFq7Qv 8ig+sWqu/WgztOe4a2KxEcR93fF8u/RKlAs1qhsOK2APrqs5xWI+2+ipXf9Dr2EXqvaS qikg== X-Gm-Message-State: AOAM530giQtO5NvLRJPeUMbfVzqlEx+JtnptPyXgECStQZLYGXLb+8eC 5v08xjHVey+LL9yYAY3e1dlS8zvBN+B9yA== X-Google-Smtp-Source: ABdhPJwbPMfTJh4txTCdjsrEdkLYb5/0QUliYmgwfoYRCYOq5RA1ZSaJ0rZSkOyhaq4OfNm1RugkgQ== X-Received: by 2002:a17:902:161:b029:d1:9bc8:15f1 with SMTP id 88-20020a1709020161b02900d19bc815f1mr27324878plb.39.1600326304290; Thu, 17 Sep 2020 00:05:04 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y197sm5407372pfc.220.2020.09.17.00.05.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:05:03 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Howard Chung <howardchung@google.com>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Marcel Holtmann <marcel@holtmann.org>, Manish Mandlik <mmandlik@chromium.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v3 1/8] adv_monitor: Implement RSSI Filter logic for background scanning Date: Thu, 17 Sep 2020 00:04:53 -0700 Message-Id: <20200917000448.BlueZ.v3.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.90 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2D03A40968 X-Rspamd-UID: 02eb0b From: Manish Mandlik <mmandlik@google.com> This patch implements the RSSI Filter logic for background scanning. This was unit-tested by running tests in unit/test-adv-monitor.c unit/test-adv-monitor.c file. Verified all tests PASS by running: USE="-bluez-next bluez-upstream" FEATURES=test emerge-hatch bluez Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Howard Chung <howardchung@google.com> --- Changes in v3: - Fix commit message doc/advertisement-monitor-api.txt | 5 + src/adapter.c | 1 + src/adv_monitor.c | 286 +++++++++++++++++++++++++++++- src/adv_monitor.h | 4 + 4 files changed, 292 insertions(+), 4 deletions(-) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index e09b6fd25..92c8ffc38 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -70,6 +70,11 @@ Properties string Type [read-only] dBm indicates unset. The valid range of a timer is 1 to 300 seconds while 0 indicates unset. + If the peer device advertising interval is greater than the + HighRSSIThresholdTimer, the device will never be found. Similarly, + if it is greater than LowRSSIThresholdTimer, the device will be + considered as lost. Consider configuring these values accordingly. + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] If Type is set to 0x01, this must exist and has at least diff --git a/src/adapter.c b/src/adapter.c index b2bd8b3f1..415d6e06b 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -1227,6 +1227,7 @@ void btd_adapter_remove_device(struct btd_adapter *adapter, adapter->connect_list = g_slist_remove(adapter->connect_list, dev); adapter->devices = g_slist_remove(adapter->devices, dev); + btd_adv_monitor_device_remove(adapter->adv_monitor_manager, dev); adapter->discovery_found = g_slist_remove(adapter->discovery_found, dev); diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 737da1c90..7baa5317f 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -35,6 +35,7 @@ #include "adapter.h" #include "dbus-common.h" +#include "device.h" #include "log.h" #include "src/error.h" #include "src/shared/ad.h" @@ -44,6 +45,8 @@ #include "adv_monitor.h" +static void monitor_device_free(void *data); + #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" @@ -104,15 +107,36 @@ struct adv_monitor { enum monitor_state state; /* MONITOR_STATE_* */ - int8_t high_rssi; /* high RSSI threshold */ - uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ - int8_t low_rssi; /* low RSSI threshold */ - uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ + int8_t high_rssi; /* High RSSI threshold */ + uint16_t high_rssi_timeout; /* High RSSI threshold timeout */ + int8_t low_rssi; /* Low RSSI threshold */ + uint16_t low_rssi_timeout; /* Low RSSI threshold timeout */ + struct queue *devices; /* List of adv_monitor_device objects */ enum monitor_type type; /* MONITOR_TYPE_* */ struct queue *patterns; }; +/* Some data like last_seen, timer/timeout values need to be maintained + * per device. struct adv_monitor_device maintains such data. + */ +struct adv_monitor_device { + struct adv_monitor *monitor; + struct btd_device *device; + + time_t high_rssi_first_seen; /* Start time when RSSI climbs above + * the high RSSI threshold + */ + time_t low_rssi_first_seen; /* Start time when RSSI drops below + * the low RSSI threshold + */ + time_t last_seen; /* Time when last Adv was received */ + bool device_found; /* State of the device - lost/found */ + guint device_lost_timer; /* Timer to track if the device goes + * offline/out-of-range + */ +}; + struct app_match_data { const char *owner; const char *path; @@ -159,6 +183,9 @@ static void monitor_free(void *data) g_dbus_proxy_unref(monitor->proxy); g_free(monitor->path); + queue_destroy(monitor->devices, monitor_device_free); + monitor->devices = NULL; + queue_destroy(monitor->patterns, pattern_free); free(monitor); @@ -257,6 +284,7 @@ static struct adv_monitor *monitor_new(struct adv_monitor_app *app, monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->devices = queue_new(); monitor->type = MONITOR_TYPE_NONE; monitor->patterns = NULL; @@ -932,3 +960,253 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) manager_destroy(manager); } + +/* Matches a device based on btd_device object */ +static bool monitor_device_match(const void *a, const void *b) +{ + const struct adv_monitor_device *dev = a; + const struct btd_device *device = b; + + if (!dev) + return false; + + if (dev->device != device) + return false; + + return true; +} + +/* Frees a monitor device object */ +static void monitor_device_free(void *data) +{ + struct adv_monitor_device *dev = data; + + if (!dev) + return; + + if (dev->device_lost_timer) { + g_source_remove(dev->device_lost_timer); + dev->device_lost_timer = 0; + } + + dev->monitor = NULL; + dev->device = NULL; + + g_free(dev); +} + +/* Removes a device from monitor->devices list */ +static void remove_device_from_monitor(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct btd_device *device = user_data; + struct adv_monitor_device *dev = NULL; + + if (!monitor) + return; + + dev = queue_remove_if(monitor->devices, monitor_device_match, device); + if (dev) { + DBG("Device removed from the Adv Monitor at path %s", + monitor->path); + monitor_device_free(dev); + } +} + +/* Removes a device from every monitor in an app */ +static void remove_device_from_app(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + struct btd_device *device = user_data; + + if (!app) + return; + + queue_foreach(app->monitors, remove_device_from_monitor, device); +} + +/* Removes a device from every monitor in all apps */ +void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, + struct btd_device *device) +{ + if (!manager || !device) + return; + + queue_foreach(manager->apps, remove_device_from_app, device); +} + +/* Creates a device object to track the per-device information */ +static struct adv_monitor_device *monitor_device_create( + struct adv_monitor *monitor, + struct btd_device *device) +{ + struct adv_monitor_device *dev = NULL; + + dev = g_try_malloc0(sizeof(struct adv_monitor_device)); + if (!dev) + return NULL; + + dev->monitor = monitor; + dev->device = device; + + queue_push_tail(monitor->devices, dev); + + return dev; +} + +/* Includes found/lost device's object path into the dbus message */ +static void report_device_state_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = device_get_path(user_data); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +/* Handles a situation where the device goes offline/out-of-range */ +static gboolean handle_device_lost_timeout(gpointer user_data) +{ + struct adv_monitor_device *dev = user_data; + struct adv_monitor *monitor = dev->monitor; + time_t curr_time = time(NULL); + + DBG("Device Lost timeout triggered for device %p " + "for the Adv Monitor at path %s", dev->device, monitor->path); + + dev->device_lost_timer = 0; + + if (dev->device_found && dev->last_seen) { + /* We were tracking for the Low RSSI filter. Check if there is + * any Adv received after the timeout function is invoked. + * If not, report the Device Lost event. + */ + if (difftime(curr_time, dev->last_seen) >= + monitor->low_rssi_timeout) { + dev->device_found = false; + + DBG("Calling DeviceLost() on Adv Monitor of owner %s " + "at path %s", monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "DeviceLost", + report_device_state_setup, + NULL, dev->device, NULL); + } + } + + return FALSE; +} + +/* Filters an Adv based on its RSSI value */ +static void adv_monitor_filter_rssi(struct adv_monitor *monitor, + struct btd_device *device, int8_t rssi) +{ + struct adv_monitor_device *dev = NULL; + time_t curr_time = time(NULL); + uint16_t adapter_id = monitor->app->manager->adapter_id; + + /* If the RSSI thresholds and timeouts are not specified, report the + * DeviceFound() event without tracking for the RSSI as the Adv has + * already matched the pattern filter. + */ + if (monitor->high_rssi == ADV_MONITOR_UNSET_RSSI && + monitor->low_rssi == ADV_MONITOR_UNSET_RSSI && + monitor->high_rssi_timeout == ADV_MONITOR_UNSET_TIMER && + monitor->low_rssi_timeout == ADV_MONITOR_UNSET_TIMER) { + DBG("Calling DeviceFound() on Adv Monitor of owner %s " + "at path %s", monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "DeviceFound", + report_device_state_setup, NULL, + device, NULL); + + return; + } + + dev = queue_find(monitor->devices, monitor_device_match, device); + if (!dev) + dev = monitor_device_create(monitor, device); + if (!dev) { + btd_error(adapter_id, "Failed to create Adv Monitor " + "device object."); + return; + } + + if (dev->device_lost_timer) { + g_source_remove(dev->device_lost_timer); + dev->device_lost_timer = 0; + } + + /* Reset the timings of found/lost if a device has been offline for + * longer than the high/low timeouts. + */ + if (dev->last_seen) { + if (difftime(curr_time, dev->last_seen) > + monitor->high_rssi_timeout) { + dev->high_rssi_first_seen = 0; + } + + if (difftime(curr_time, dev->last_seen) > + monitor->low_rssi_timeout) { + dev->low_rssi_first_seen = 0; + } + } + dev->last_seen = curr_time; + + /* Check for the found devices (if the device is not already found) */ + if (!dev->device_found && rssi > monitor->high_rssi) { + if (dev->high_rssi_first_seen) { + if (difftime(curr_time, dev->high_rssi_first_seen) >= + monitor->high_rssi_timeout) { + dev->device_found = true; + + DBG("Calling DeviceFound() on Adv Monitor " + "of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call( + monitor->proxy, "DeviceFound", + report_device_state_setup, NULL, + dev->device, NULL); + } + } else { + dev->high_rssi_first_seen = curr_time; + } + } else { + dev->high_rssi_first_seen = 0; + } + + /* Check for the lost devices (only if the device is already found, as + * it doesn't make any sense to report the Device Lost event if the + * device is not found yet) + */ + if (dev->device_found && rssi < monitor->low_rssi) { + if (dev->low_rssi_first_seen) { + if (difftime(curr_time, dev->low_rssi_first_seen) >= + monitor->low_rssi_timeout) { + dev->device_found = false; + + DBG("Calling DeviceLost() on Adv Monitor " + "of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call( + monitor->proxy, "DeviceLost", + report_device_state_setup, NULL, + dev->device, NULL); + } + } else { + dev->low_rssi_first_seen = curr_time; + } + } else { + dev->low_rssi_first_seen = 0; + } + + /* Setup a timer to track if the device goes offline/out-of-range, only + * if we are tracking for the Low RSSI Threshold. If we are tracking + * the High RSSI Threshold, nothing needs to be done. + */ + if (dev->device_found) { + dev->device_lost_timer = + g_timeout_add_seconds(monitor->low_rssi_timeout, + handle_device_lost_timeout, dev); + } +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 69ea348f8..14508e7d1 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -21,6 +21,7 @@ #define __ADV_MONITOR_H struct mgmt; +struct btd_device; struct btd_adapter; struct btd_adv_monitor_manager; @@ -29,4 +30,7 @@ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct mgmt *mgmt); void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); +void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, + struct btd_device *device); + #endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mFhHHQwMY19dkwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:11:08 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id KJekGQwMY19LWgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:11:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 16EE5A0BB6; Thu, 17 Sep 2020 09:11:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726290AbgIQHK6 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:10:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgIQHKn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:10:43 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACD64C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:10:43 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id jw11so764549pjb.0 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KMSIqu+V+YjNzhdgBvaOXQy1sPDxSNzTGf9LnWQU5i0=; b=dLTJoTzz519qI6K4IdhzgCSpJkntcRAMEvm5v6eTYNvWxY15sXNksO0TyfPo4i4zMq gnUXIEbzQ0scbJ5E98q8Bj8onCvbMmX9Tr5w2RI43AW9QTY0lh+NnSHtgKIApZ+MULPW i4xqiKj+76v2MQMNUXA+hZoeQJefpEHWv8F1Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KMSIqu+V+YjNzhdgBvaOXQy1sPDxSNzTGf9LnWQU5i0=; b=BvjldVM3PwjV7Llg9pju7BCd/i+2Wo86Yt18fyjbbWhsW5/4fCVfJvrlIdXwiz1o9b mZT+bgibp/DeM/OpahNhU3D1zSDb5p5cBzXGAlMSLpNv52EVF7J3O4QQpjruEMH0sPNx 5wkllPfDMmVVdiq9BpiW7EG1964s6rs8xtBirw7Sz0ZcMtET1DJ1yxtX9okAF2GOFZ5g ThjoDBbbJjVccXo8nTkrD9AYxsnpKhBMCbs+lc6Vw8O9YHGW5OFftFH+8h2qJwfumUEt KTO2yGuTW3dp6CEamjAxc1mVIoRvC8Wo0gLH+jZUW5aivrX/jOs22E2V8gTdVPPgrRIQ aUsQ== X-Gm-Message-State: AOAM533mdSAg88ol6KYvtaZ7iTkSmQuOJWxZHtfyLfs1Dyp8NiVzP1mq NAbVcadvMe1inkqRjgo3RlXOpB8mvnHMmg== X-Google-Smtp-Source: ABdhPJxyUhrzfnGjrD04cIsb8SrH06BKkaXFI597rQ8NdukHNzwae4jWi4XCv27juOkyX4i6GzsLrA== X-Received: by 2002:a17:90b:4b11:: with SMTP id lx17mr7263778pjb.22.1600326642771; Thu, 17 Sep 2020 00:10:42 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id j26sm933478pgl.91.2020.09.17.00.10.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:10:42 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Manish Mandlik <mmandlik@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 1/8] adv_monitor: Implement RSSI Filter logic for background scanning Date: Thu, 17 Sep 2020 00:10:31 -0700 Message-Id: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.90 / 15.00 / 15.00 X-Rspamd-Queue-Id: 16EE5A0BB6 X-Rspamd-UID: 5bcb73 From: Manish Mandlik <mmandlik@google.com> This patch implements the RSSI Filter logic for background scanning. This was unit-tested by running tests in unit/test-adv-monitor.c Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Howard Chung <howardchung@google.com> --- Changes in v4: - Fix commit message Changes in v3: - Fix commit message doc/advertisement-monitor-api.txt | 5 + src/adapter.c | 1 + src/adv_monitor.c | 286 +++++++++++++++++++++++++++++- src/adv_monitor.h | 4 + 4 files changed, 292 insertions(+), 4 deletions(-) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index e09b6fd25..92c8ffc38 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -70,6 +70,11 @@ Properties string Type [read-only] dBm indicates unset. The valid range of a timer is 1 to 300 seconds while 0 indicates unset. + If the peer device advertising interval is greater than the + HighRSSIThresholdTimer, the device will never be found. Similarly, + if it is greater than LowRSSIThresholdTimer, the device will be + considered as lost. Consider configuring these values accordingly. + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] If Type is set to 0x01, this must exist and has at least diff --git a/src/adapter.c b/src/adapter.c index b2bd8b3f1..415d6e06b 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -1227,6 +1227,7 @@ void btd_adapter_remove_device(struct btd_adapter *adapter, adapter->connect_list = g_slist_remove(adapter->connect_list, dev); adapter->devices = g_slist_remove(adapter->devices, dev); + btd_adv_monitor_device_remove(adapter->adv_monitor_manager, dev); adapter->discovery_found = g_slist_remove(adapter->discovery_found, dev); diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 737da1c90..7baa5317f 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -35,6 +35,7 @@ #include "adapter.h" #include "dbus-common.h" +#include "device.h" #include "log.h" #include "src/error.h" #include "src/shared/ad.h" @@ -44,6 +45,8 @@ #include "adv_monitor.h" +static void monitor_device_free(void *data); + #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" @@ -104,15 +107,36 @@ struct adv_monitor { enum monitor_state state; /* MONITOR_STATE_* */ - int8_t high_rssi; /* high RSSI threshold */ - uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ - int8_t low_rssi; /* low RSSI threshold */ - uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ + int8_t high_rssi; /* High RSSI threshold */ + uint16_t high_rssi_timeout; /* High RSSI threshold timeout */ + int8_t low_rssi; /* Low RSSI threshold */ + uint16_t low_rssi_timeout; /* Low RSSI threshold timeout */ + struct queue *devices; /* List of adv_monitor_device objects */ enum monitor_type type; /* MONITOR_TYPE_* */ struct queue *patterns; }; +/* Some data like last_seen, timer/timeout values need to be maintained + * per device. struct adv_monitor_device maintains such data. + */ +struct adv_monitor_device { + struct adv_monitor *monitor; + struct btd_device *device; + + time_t high_rssi_first_seen; /* Start time when RSSI climbs above + * the high RSSI threshold + */ + time_t low_rssi_first_seen; /* Start time when RSSI drops below + * the low RSSI threshold + */ + time_t last_seen; /* Time when last Adv was received */ + bool device_found; /* State of the device - lost/found */ + guint device_lost_timer; /* Timer to track if the device goes + * offline/out-of-range + */ +}; + struct app_match_data { const char *owner; const char *path; @@ -159,6 +183,9 @@ static void monitor_free(void *data) g_dbus_proxy_unref(monitor->proxy); g_free(monitor->path); + queue_destroy(monitor->devices, monitor_device_free); + monitor->devices = NULL; + queue_destroy(monitor->patterns, pattern_free); free(monitor); @@ -257,6 +284,7 @@ static struct adv_monitor *monitor_new(struct adv_monitor_app *app, monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->devices = queue_new(); monitor->type = MONITOR_TYPE_NONE; monitor->patterns = NULL; @@ -932,3 +960,253 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) manager_destroy(manager); } + +/* Matches a device based on btd_device object */ +static bool monitor_device_match(const void *a, const void *b) +{ + const struct adv_monitor_device *dev = a; + const struct btd_device *device = b; + + if (!dev) + return false; + + if (dev->device != device) + return false; + + return true; +} + +/* Frees a monitor device object */ +static void monitor_device_free(void *data) +{ + struct adv_monitor_device *dev = data; + + if (!dev) + return; + + if (dev->device_lost_timer) { + g_source_remove(dev->device_lost_timer); + dev->device_lost_timer = 0; + } + + dev->monitor = NULL; + dev->device = NULL; + + g_free(dev); +} + +/* Removes a device from monitor->devices list */ +static void remove_device_from_monitor(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct btd_device *device = user_data; + struct adv_monitor_device *dev = NULL; + + if (!monitor) + return; + + dev = queue_remove_if(monitor->devices, monitor_device_match, device); + if (dev) { + DBG("Device removed from the Adv Monitor at path %s", + monitor->path); + monitor_device_free(dev); + } +} + +/* Removes a device from every monitor in an app */ +static void remove_device_from_app(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + struct btd_device *device = user_data; + + if (!app) + return; + + queue_foreach(app->monitors, remove_device_from_monitor, device); +} + +/* Removes a device from every monitor in all apps */ +void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, + struct btd_device *device) +{ + if (!manager || !device) + return; + + queue_foreach(manager->apps, remove_device_from_app, device); +} + +/* Creates a device object to track the per-device information */ +static struct adv_monitor_device *monitor_device_create( + struct adv_monitor *monitor, + struct btd_device *device) +{ + struct adv_monitor_device *dev = NULL; + + dev = g_try_malloc0(sizeof(struct adv_monitor_device)); + if (!dev) + return NULL; + + dev->monitor = monitor; + dev->device = device; + + queue_push_tail(monitor->devices, dev); + + return dev; +} + +/* Includes found/lost device's object path into the dbus message */ +static void report_device_state_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = device_get_path(user_data); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +/* Handles a situation where the device goes offline/out-of-range */ +static gboolean handle_device_lost_timeout(gpointer user_data) +{ + struct adv_monitor_device *dev = user_data; + struct adv_monitor *monitor = dev->monitor; + time_t curr_time = time(NULL); + + DBG("Device Lost timeout triggered for device %p " + "for the Adv Monitor at path %s", dev->device, monitor->path); + + dev->device_lost_timer = 0; + + if (dev->device_found && dev->last_seen) { + /* We were tracking for the Low RSSI filter. Check if there is + * any Adv received after the timeout function is invoked. + * If not, report the Device Lost event. + */ + if (difftime(curr_time, dev->last_seen) >= + monitor->low_rssi_timeout) { + dev->device_found = false; + + DBG("Calling DeviceLost() on Adv Monitor of owner %s " + "at path %s", monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "DeviceLost", + report_device_state_setup, + NULL, dev->device, NULL); + } + } + + return FALSE; +} + +/* Filters an Adv based on its RSSI value */ +static void adv_monitor_filter_rssi(struct adv_monitor *monitor, + struct btd_device *device, int8_t rssi) +{ + struct adv_monitor_device *dev = NULL; + time_t curr_time = time(NULL); + uint16_t adapter_id = monitor->app->manager->adapter_id; + + /* If the RSSI thresholds and timeouts are not specified, report the + * DeviceFound() event without tracking for the RSSI as the Adv has + * already matched the pattern filter. + */ + if (monitor->high_rssi == ADV_MONITOR_UNSET_RSSI && + monitor->low_rssi == ADV_MONITOR_UNSET_RSSI && + monitor->high_rssi_timeout == ADV_MONITOR_UNSET_TIMER && + monitor->low_rssi_timeout == ADV_MONITOR_UNSET_TIMER) { + DBG("Calling DeviceFound() on Adv Monitor of owner %s " + "at path %s", monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "DeviceFound", + report_device_state_setup, NULL, + device, NULL); + + return; + } + + dev = queue_find(monitor->devices, monitor_device_match, device); + if (!dev) + dev = monitor_device_create(monitor, device); + if (!dev) { + btd_error(adapter_id, "Failed to create Adv Monitor " + "device object."); + return; + } + + if (dev->device_lost_timer) { + g_source_remove(dev->device_lost_timer); + dev->device_lost_timer = 0; + } + + /* Reset the timings of found/lost if a device has been offline for + * longer than the high/low timeouts. + */ + if (dev->last_seen) { + if (difftime(curr_time, dev->last_seen) > + monitor->high_rssi_timeout) { + dev->high_rssi_first_seen = 0; + } + + if (difftime(curr_time, dev->last_seen) > + monitor->low_rssi_timeout) { + dev->low_rssi_first_seen = 0; + } + } + dev->last_seen = curr_time; + + /* Check for the found devices (if the device is not already found) */ + if (!dev->device_found && rssi > monitor->high_rssi) { + if (dev->high_rssi_first_seen) { + if (difftime(curr_time, dev->high_rssi_first_seen) >= + monitor->high_rssi_timeout) { + dev->device_found = true; + + DBG("Calling DeviceFound() on Adv Monitor " + "of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call( + monitor->proxy, "DeviceFound", + report_device_state_setup, NULL, + dev->device, NULL); + } + } else { + dev->high_rssi_first_seen = curr_time; + } + } else { + dev->high_rssi_first_seen = 0; + } + + /* Check for the lost devices (only if the device is already found, as + * it doesn't make any sense to report the Device Lost event if the + * device is not found yet) + */ + if (dev->device_found && rssi < monitor->low_rssi) { + if (dev->low_rssi_first_seen) { + if (difftime(curr_time, dev->low_rssi_first_seen) >= + monitor->low_rssi_timeout) { + dev->device_found = false; + + DBG("Calling DeviceLost() on Adv Monitor " + "of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call( + monitor->proxy, "DeviceLost", + report_device_state_setup, NULL, + dev->device, NULL); + } + } else { + dev->low_rssi_first_seen = curr_time; + } + } else { + dev->low_rssi_first_seen = 0; + } + + /* Setup a timer to track if the device goes offline/out-of-range, only + * if we are tracking for the Low RSSI Threshold. If we are tracking + * the High RSSI Threshold, nothing needs to be done. + */ + if (dev->device_found) { + dev->device_lost_timer = + g_timeout_add_seconds(monitor->low_rssi_timeout, + handle_device_lost_timeout, dev); + } +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 69ea348f8..14508e7d1 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -21,6 +21,7 @@ #define __ADV_MONITOR_H struct mgmt; +struct btd_device; struct btd_adapter; struct btd_adv_monitor_manager; @@ -29,4 +30,7 @@ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct mgmt *mgmt); void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); +void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, + struct btd_device *device); + #endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0EqoMhMMY1+GOAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:11:15 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id wMo8LhMMY1+EGQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:11:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8ECFBA0B7A; Thu, 17 Sep 2020 09:11:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbgIQHLA (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:11:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbgIQHK5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:10:57 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4560EC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:10:57 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id r19so652542pls.1 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cKsMX997q72m3h0dSrTTor4DQOmqWhuxr0fHnTUpCZQ=; b=i76Mfhb5xT9kWmgWnwZ6moBMH26ND+pEfD29YXbxGtEyRFll0Ha77yt0qTsjPOZVDc CJ0f4C6TXqkhwM+mFqCXdPZ6KeZbI1QPrWozlho2+9PsIk3iL3/q664F18Y7i/w54Op6 QExsVYTfde9Ad5RIt0VhhcoPdyKDjOJ9oqmaM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cKsMX997q72m3h0dSrTTor4DQOmqWhuxr0fHnTUpCZQ=; b=QVJbsw9EYl0Emp35H0xVd0MF49kStTeObmR7p4UDvUFhvSqRTDXfgdEQQDFqm34CQx U1D3RJk6U4C48Umre89wR3pIqELoeS9JA/+5v4/ZmKIn2dC9Ke4KiodbhkNngH3sqiwT /jZmxDzcEiSN8Ao8XNilZu2mxE2rr9MAyh4Gk6Phz3zhtynS+mb+7wRgaUhezBFvMwbz TcTJgXeXjzIsWcAKFxViGe571L4sqWtxWwvfCxpWWmfs85Hol7M14ovycAU8/essgAcf QLodfliUI5rkw3N81J8mF8HUHQPFa23wWhp3/zvzk6QwfbEhVdpPV0eaABoHZzJ48hEJ Xtbg== X-Gm-Message-State: AOAM532g2kj+tJYIZcEc26IAQ+q85ZKEgEi0KCArR7z4NEODUDX3TGJ1 qF8eYITBEsK7gi8257z1wMDvu1WSEUIfYQ== X-Google-Smtp-Source: ABdhPJx0THzqeCEa8p7GQMT6xPGYHUHL+IpIuzlMsYdrzRwm0khOaqJn9+r5zYNuSTKw/jqcqvg/CA== X-Received: by 2002:a17:90a:de92:: with SMTP id n18mr7145201pjv.35.1600326656180; Thu, 17 Sep 2020 00:10:56 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id j26sm933478pgl.91.2020.09.17.00.10.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:10:55 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Manish Mandlik <mmandlik@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 2/8] adv_monitor: Implement unit tests for RSSI Filter Date: Thu, 17 Sep 2020 00:10:33 -0700 Message-Id: <20200917001020.BlueZ.v4.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.52 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8ECFBA0B7A X-Rspamd-UID: 77d424 From: Manish Mandlik <mmandlik@google.com> This patch implements unit tests for the background scanning RSSI Filtering logic. Verified all tests PASS by running tests in unit/test-adv-monitor.c Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Changes in v4: - Fix commit message Changes in v3: - Fix commit message Changes in v2: - Cast test data to void * Makefile.am | 9 + doc/test-coverage.txt | 3 +- src/adv_monitor.c | 79 ++++++++ src/adv_monitor.h | 10 + unit/test-adv-monitor.c | 391 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 491 insertions(+), 1 deletion(-) create mode 100644 unit/test-adv-monitor.c diff --git a/Makefile.am b/Makefile.am index 22b4fa30c..6918f02b0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -527,6 +527,15 @@ unit_test_gattrib_LDADD = lib/libbluetooth-internal.la \ src/libshared-glib.la \ $(GLIB_LIBS) $(DBUS_LIBS) -ldl -lrt +unit_tests += unit/test-adv-monitor + +unit_test_adv_monitor_SOURCES = unit/test-adv-monitor.c \ + src/adv_monitor.h src/adv_monitor.c \ + src/device.h src/device.c \ + src/log.h src/log.c +unit_test_adv_monitor_LDADD = gdbus/libgdbus-internal.la \ + src/libshared-glib.la $(GLIB_LIBS) $(DBUS_LIBS) + if MIDI unit_tests += unit/test-midi unit_test_midi_CPPFLAGS = $(AM_CPPFLAGS) $(ALSA_CFLAGS) -DMIDI_TEST diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt index 741492a3e..5296983e6 100644 --- a/doc/test-coverage.txt +++ b/doc/test-coverage.txt @@ -30,8 +30,9 @@ test-gobex-transfer 36 OBEX transfer handling test-gdbus-client 13 D-Bus client handling test-gatt 180 GATT qualification test cases test-hog 6 HID Over GATT qualification test cases +test-adv-monitor 5 Advertisement Monitor test cases ----- - 761 + 766 Automated end-to-end testing diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 7baa5317f..046f5953f 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -1210,3 +1210,82 @@ static void adv_monitor_filter_rssi(struct adv_monitor *monitor, handle_device_lost_timeout, dev); } } + +/* Creates the dummy adv_monitor object for unit tests */ +void *btd_adv_monitor_rssi_test_setup(int8_t high_rssi, uint16_t high_timeout, + int8_t low_rssi, uint16_t low_timeout) +{ + struct adv_monitor *test_monitor = NULL; + + test_monitor = g_new0(struct adv_monitor, 1); + if (!test_monitor) + return NULL; + + test_monitor->app = g_new0(struct adv_monitor_app, 1); + if (!test_monitor->app) + goto app_failed; + + test_monitor->app->manager = g_new0(struct btd_adv_monitor_manager, 1); + if (!test_monitor->app->manager) + goto manager_failed; + + test_monitor->high_rssi = high_rssi; + test_monitor->high_rssi_timeout = high_timeout; + test_monitor->low_rssi = low_rssi; + test_monitor->low_rssi_timeout = low_timeout; + test_monitor->devices = queue_new(); + + return test_monitor; + +manager_failed: + g_free(test_monitor->app); + +app_failed: + g_free(test_monitor); + + return NULL; +} + +/* Cleanup after unit test is done */ +void btd_adv_monitor_rssi_test_teardown(void *monitor_obj) +{ + struct adv_monitor *monitor = monitor_obj; + + if (!monitor) + return; + + queue_destroy(monitor->devices, monitor_device_free); + g_free(monitor); +} + +/* Returns the current state of device - found/lost, used in unit tests */ +bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj) +{ + struct adv_monitor *monitor = monitor_obj; + struct btd_device *device = device_obj; + struct adv_monitor_device *dev = NULL; + + if (!monitor || !device) + return false; + + dev = queue_find(monitor->devices, monitor_device_match, device); + if (!dev) + return false; + + return dev->device_found; +} + +/* Helper function for the RSSI Filter unit tests */ +bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, + int8_t adv_rssi) +{ + struct adv_monitor *monitor = monitor_obj; + struct btd_device *device = device_obj; + + if (!monitor || !device) + return false; + + adv_monitor_filter_rssi(monitor, device, adv_rssi); + + return btd_adv_monitor_test_device_state(monitor, device); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 14508e7d1..351e7f9aa 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -33,4 +33,14 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, struct btd_device *device); +/* Following functions are the helper functions used for RSSI Filter unit tests + * defined in unit/test-adv-monitor.c + */ +void *btd_adv_monitor_rssi_test_setup(int8_t high_rssi, uint16_t high_timeout, + int8_t low_rssi, uint16_t low_timeout); +void btd_adv_monitor_rssi_test_teardown(void *monitor_obj); +bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj); +bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, + int8_t adv_rssi); + #endif /* __ADV_MONITOR_H */ diff --git a/unit/test-adv-monitor.c b/unit/test-adv-monitor.c new file mode 100644 index 000000000..970be84b0 --- /dev/null +++ b/unit/test-adv-monitor.c @@ -0,0 +1,391 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <glib.h> +#include <stdbool.h> +#include <stdint.h> +#include <unistd.h> + +#include "src/log.h" +#include "src/shared/tester.h" + +#include "src/adv_monitor.h" + +#define define_test(name, type, data, setup_fn, test_fn, teardown_fn) \ + do { \ + static struct test_data test; \ + test.test_type = type; \ + test.test_name = g_strdup(name); \ + if (type == TEST_RSSI_FILTER) { \ + test.rssi_filter_test_data = (void *)&data; \ + test.rssi_filter_test_data->test_info = &test; \ + } \ + tester_add(name, &test, setup_fn, test_fn, teardown_fn);\ + } while (0) + +#define ADV_INTERVAL 1 /* Advertisement interval in seconds */ +#define OUT_OF_RANGE -128 +#define END_OF_RSSI_TEST {0} + +#define RSSI_TEST_DONE(test_step) \ + (!test_step.adv_rssi && !test_step.duration && !test_step.result) + +#define DUMMY_BTD_DEVICE_OBJ ((void *) 0xF00) + +enum test_type { + TEST_RSSI_FILTER = 0, + TEST_CONTENT_FILTER, +}; + +enum result { + RESULT_DEVICE_NOT_FOUND = false, /* Initial state of a device */ + RESULT_DEVICE_FOUND = true, /* Device state when the + * Content/RSSI Filter match + */ + RESULT_DEVICE_LOST = false, /* Device state when the Low + * RSSI Filter match or if it + * goes offline/out-of-range + */ +}; + +struct rssi_filter_test { + void *adv_monitor_obj; /* struct adv_monitor object */ + void *btd_device_obj; /* struct btd_device object */ + struct test_data *test_info; + + const struct { + int8_t high_rssi_threshold; /* High RSSI threshold */ + uint16_t high_rssi_timeout; /* High RSSI threshold timeout*/ + int8_t low_rssi_threshold; /* Low RSSI threshold */ + uint16_t low_rssi_timeout; /* Low RSSI threshold timeout */ + } rssi_filter; + + time_t start_time; /* Start time of the test */ + uint16_t resume_step; /* Store the current sub-step of the + * test before suspending that test + */ + guint out_of_range_timer; /* Timer to simulate device offline */ + + const struct { + int8_t adv_rssi; /* Advertisement RSSI */ + uint16_t duration; /* Advertisement duration in seconds */ + enum result result; /* Device state after every step */ + } test_steps[]; +}; + +/* Parent data structure to hold the test data and information, + * used by tester_* functions and callbacks. + */ +struct test_data { + enum test_type test_type; + char *test_name; + + union { + struct rssi_filter_test *rssi_filter_test_data; + }; +}; + +/* RSSI Filter Test 1: + * - The Device Lost event should NOT get triggered even if the Adv RSSI is + * lower than LowRSSIThresh for more than LowRSSITimeout before finding + * the device first. + * - Similarly, the Device Found event should NOT get triggered if the Adv RSSI + * is greater than LowRSSIThresh but lower than HighRSSIThresh. + */ +static struct rssi_filter_test rssi_data_1 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-70, 6, RESULT_DEVICE_NOT_FOUND}, + {-50, 6, RESULT_DEVICE_NOT_FOUND}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 2: + * - The Device Found event should get triggered when the Adv RSSI is higher + * than HighRSSIThresh for more than HighRSSITimeout. + * - Once the device is found, the Device Lost event should NOT get triggered + * if the Adv RSSI drops below HighRSSIThresh but it is not lower than + * LowRSSIThresh. + * - When the Adv RSSI drops below LowRSSIThresh for more than LowRSSITimeout, + * the Device Lost event should get triggered. + */ +static struct rssi_filter_test rssi_data_2 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-30, 6, RESULT_DEVICE_FOUND}, + {-50, 6, RESULT_DEVICE_FOUND}, + {-70, 6, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 3: + * - The Device Found event should get triggered only when the Adv RSSI is + * higher than HighRSSIThresh for more than HighRSSITimeout. + * - If the Adv RSSI drops below HighRSSIThresh, timer should reset and start + * counting once the Adv RSSI is above HighRSSIThresh. + * - Similarly, when tracking the Low RSSI, timer should reset when the Adv RSSI + * goes above LowRSSIThresh. The Device Lost event should get triggered only + * when the Adv RSSI is lower than LowRSSIThresh for more than LowRSSITimeout. + */ +static struct rssi_filter_test rssi_data_3 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-30, 2, RESULT_DEVICE_NOT_FOUND}, + {-50, 6, RESULT_DEVICE_NOT_FOUND}, + {-30, 4, RESULT_DEVICE_NOT_FOUND}, + {-30, 2, RESULT_DEVICE_FOUND}, + {-70, 2, RESULT_DEVICE_FOUND}, + {-50, 6, RESULT_DEVICE_FOUND}, + {-70, 4, RESULT_DEVICE_FOUND}, + {-70, 2, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 4: + * - While tracking the High RSSI, timer should reset if the device goes + * offline/out-of-range for more than HighRSSITimeout. + * - Once the device is found, if the device goes offline/out-of-range for + * more than LowRSSITimeout, the Device Lost event should get triggered. + */ +static struct rssi_filter_test rssi_data_4 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + { -30, 2, RESULT_DEVICE_NOT_FOUND}, + {OUT_OF_RANGE, 6, RESULT_DEVICE_NOT_FOUND}, + { -30, 4, RESULT_DEVICE_NOT_FOUND}, + { -30, 2, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 6, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 5: + * - The Device Found event should get triggered only once even if the Adv RSSI + * stays higher than HighRSSIThresh for a longer period of time. + * - Once the device is found, while tracking the Low RSSI, timer should reset + * when the Adv RSSI goes above LowRSSIThresh. + * - The timer should NOT reset if the device goes offline/out-of-range for + * a very short period of time and comes back online/in-range before + * the timeouts. + */ +static struct rssi_filter_test rssi_data_5 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + { -30, 2, RESULT_DEVICE_NOT_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_NOT_FOUND}, + { -30, 2, RESULT_DEVICE_FOUND}, + { -30, 3, RESULT_DEVICE_FOUND}, + { -30, 3, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_FOUND}, + { -50, 6, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* Initialize the data required for RSSI Filter test */ +static void setup_rssi_filter_test(gpointer data) +{ + struct rssi_filter_test *test = data; + + test->adv_monitor_obj = btd_adv_monitor_rssi_test_setup( + test->rssi_filter.high_rssi_threshold, + test->rssi_filter.high_rssi_timeout, + test->rssi_filter.low_rssi_threshold, + test->rssi_filter.low_rssi_timeout); + + /* The RSSI Filter logic uses btd_device object only as a key in the + * adv_monitor->devices list, it is never dereferenced nor used to + * perform any operations related to btd_device. So we can use any + * dummy address for unit testing. + */ + test->btd_device_obj = DUMMY_BTD_DEVICE_OBJ; + + tester_setup_complete(); +} + +/* Cleanup after the RSSI Filter test is done */ +static void teardown_rssi_filter_test(gpointer data) +{ + struct rssi_filter_test *test = data; + + btd_adv_monitor_rssi_test_teardown(test->adv_monitor_obj); + + tester_teardown_complete(); +} + +/* Execute the sub-steps of RSSI Filter test */ +static gboolean test_rssi_filter(gpointer data) +{ + struct rssi_filter_test *test = data; + time_t start_time = time(NULL); + bool ret = false; + + uint16_t i = 0; + uint16_t j = 0; + + /* If this is not the beginning of test, return to the sub-step + * before that test was suspended + */ + if (test->resume_step) { + start_time = test->start_time; + i = test->resume_step; + + /* Clear the test resume timer */ + g_source_remove(test->out_of_range_timer); + test->out_of_range_timer = 0; + + /* Check state of the device - found/lost, while device was + * offline/out-of-range + */ + ret = btd_adv_monitor_test_device_state(test->adv_monitor_obj, + test->btd_device_obj); + tester_debug("%s: [t=%.0lf, step=%d] Test resume, " + "device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + ret ? "true" : "false"); + g_assert(ret == test->test_steps[i].result); + + i++; + } + + while (!RSSI_TEST_DONE(test->test_steps[i])) { + if (test->test_steps[i].adv_rssi == OUT_OF_RANGE) { + /* Simulate device offline/out-of-range by suspending + * the test. + * + * Note: All tester_* functions run sequentially by + * adding a next function to the main loop using + * g_idle_add(). If a timeout function is added using + * g_timeout_add_*(), it doesn't really get invoked as + * soon as the timer expires. Instead, it is invoked + * once the current function returns and the timer has + * expired. So, to give handle_device_lost_timeout() + * function a chance to run at the correct time, we + * must save the current state and exit from this + * function while we simulate the device offline. We can + * come back later to continue with the remaining steps. + */ + test->resume_step = i; + test->start_time = start_time; + test->out_of_range_timer = g_timeout_add_seconds( + test->test_steps[i].duration, + test_rssi_filter, data); + + /* Check the device state before suspending the test */ + ret = btd_adv_monitor_test_device_state( + test->adv_monitor_obj, + test->btd_device_obj); + tester_debug("%s: [t=%.0lf, step=%d] Test suspend, " + "device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + ret ? "true" : "false"); + return FALSE; + } + + for (j = 0; j < test->test_steps[i].duration; j++) { + ret = btd_adv_monitor_test_rssi( + test->adv_monitor_obj, + test->btd_device_obj, + test->test_steps[i].adv_rssi); + tester_debug("%s: [t=%.0lf, step=%d] Test " + "advertisement RSSI %d, device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + test->test_steps[i].adv_rssi, + ret ? "true" : "false"); + + /* Sleep for a second to simulate receiving + * advertisement once every second + */ + sleep(ADV_INTERVAL); + } + g_assert(ret == test->test_steps[i].result); + + i++; + } + + tester_debug("%s: [t=%.0lf] Test done", test->test_info->test_name, + difftime(time(NULL), start_time)); + + tester_test_passed(); + + return FALSE; +} + +/* Handler function to prepare for a test */ +static void setup_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + setup_rssi_filter_test(test->rssi_filter_test_data); +} + +/* Handler function to cleanup after the test is done */ +static void teardown_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + teardown_rssi_filter_test(test->rssi_filter_test_data); +} + +/* Handler function to execute a test with the given data set */ +static void test_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + test_rssi_filter(test->rssi_filter_test_data); +} + +int main(int argc, char *argv[]) +{ + tester_init(&argc, &argv); + + __btd_log_init("*", 0); + + define_test("/advmon/rssi/1", TEST_RSSI_FILTER, rssi_data_1, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/2", TEST_RSSI_FILTER, rssi_data_2, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/3", TEST_RSSI_FILTER, rssi_data_3, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/4", TEST_RSSI_FILTER, rssi_data_4, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/5", TEST_RSSI_FILTER, rssi_data_5, + setup_handler, test_handler, teardown_handler); + + return tester_run(); +} -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ADf3OhoMY1+GOAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:11:22 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id UMqUNxoMY19NTwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:11:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EB9D5A0B60; Thu, 17 Sep 2020 09:11:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726304AbgIQHLK (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:11:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbgIQHLK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:11:10 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B822EC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:11:09 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id a9so789904pjg.1 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U8bdngXt881UuqJCGhnQokdCSvIzYyCqfzNdhYpGGbo=; b=ErzYNetPdaX112MfkJKVW1hZzreattJwzLXXKEuKLqlEL4UVVy4zvfhfFgfWmyd/SS H4JzBzdNUKF95L7ppiVq3IcN8kcfWFIoAg8T4ouTIGkUrkwaHOYWFrRNi1w1716mOW55 EQDParbTRl8zpJ3CYdiObno9kuWflS/TntUM4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U8bdngXt881UuqJCGhnQokdCSvIzYyCqfzNdhYpGGbo=; b=bVVRhn8CVKOfBLPbgkA1xyjoJ3M/y0zla5q85hhQs/ZQOTCJJs8mQBLwcNby/jFMa5 XLajd04zT5/J+/2MWFUQS4bbPkxujVWpA90joh0741JggAvktzABfpeF7S4ysR+RNpYn mA5oDMrJH6nc5WaCDDGq2nizgxkHTKS8EBAgFwzYKVtlDUmMhkU6ss0resJbhwksWtd1 IGatB5EdEyxNPGdC/Yx4yH+0psJmdC1AzbI+16GDhrvsm7IiUeqP9eV7qtcRF8DTeIf+ IPOFTHib8XYtYNxOW9zOQbar7Lsa+wsJQIQaenftBDCk8mJcI/x/qslPmcBw47Jg+z06 V1NA== X-Gm-Message-State: AOAM530am8y+QaszcpRzn0hmLz+iP8N77MnTS1x8OQDol53y3YsApO4u Ack6bVZsVY5GnxdnBJOREZ/Igbi5SngGpg== X-Google-Smtp-Source: ABdhPJz4RNKGrloMHhO8Um3qy/gewV0TjACLIxQ1NAmIMxBwdj2IIG7511P0nV3sc00k3LnBJ8uJdQ== X-Received: by 2002:a17:902:eb54:b029:d1:f365:a5d2 with SMTP id i20-20020a170902eb54b02900d1f365a5d2mr4864798pli.73.1600326668810; Thu, 17 Sep 2020 00:11:08 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id j26sm933478pgl.91.2020.09.17.00.11.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:11:07 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v4 3/8] adv_monitor: Implement Adv matching based on stored monitors Date: Thu, 17 Sep 2020 00:10:35 -0700 Message-Id: <20200917001020.BlueZ.v4.3.I578ae5e76fcf7243206a27d4f5a25783662a5f14@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: EB9D5A0B60 X-Rspamd-UID: 653075 This implements create an entry point in adapter to start the matching of Adv based on all monitors and invoke the RSSI tracking for Adv reporting. Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v3) Changes in v3: - Remove unused variables - Fix signature of queue_find() src/adapter.c | 35 +++++-- src/adv_monitor.c | 237 +++++++++++++++++++++++++++++++++++++++++----- src/adv_monitor.h | 19 ++++ 3 files changed, 259 insertions(+), 32 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 415d6e06b..d33ce7124 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6614,6 +6614,15 @@ static void update_found_devices(struct btd_adapter *adapter, bool name_known, discoverable; char addr[18]; bool duplicate = false; + GSList *matched_monitors; + + /* During the background scanning, update the device only when the data + * match at least one Adv monitor + */ + matched_monitors = btd_adv_monitor_content_filter( + adapter->adv_monitor_manager, data, data_len); + if (!adapter->discovering && !matched_monitors) + return; memset(&eir_data, 0, sizeof(eir_data)); eir_parse(&eir_data, data, data_len); @@ -6659,18 +6668,22 @@ static void update_found_devices(struct btd_adapter *adapter, device_store_cached_name(dev, eir_data.name); /* - * Only skip devices that are not connected, are temporary and there - * is no active discovery session ongoing. + * Only skip devices that are not connected, are temporary, and there + * is no active discovery session ongoing and no matched Adv monitors */ - if (!btd_device_is_connected(dev) && (device_is_temporary(dev) && - !adapter->discovery_list)) { + if (!btd_device_is_connected(dev) && + (device_is_temporary(dev) && !adapter->discovery_list) && + !matched_monitors) { eir_data_free(&eir_data); return; } - /* Don't continue if not discoverable or if filter don't match */ - if (!discoverable || (adapter->filtered_discovery && - !is_filter_match(adapter->discovery_list, &eir_data, rssi))) { + /* If there is no matched Adv monitors, don't continue if not + * discoverable or if active discovery filter don't match. + */ + if (!matched_monitors && (!discoverable || + (adapter->filtered_discovery && !is_filter_match( + adapter->discovery_list, &eir_data, rssi)))) { eir_data_free(&eir_data); return; } @@ -6727,6 +6740,14 @@ static void update_found_devices(struct btd_adapter *adapter, eir_data_free(&eir_data); + /* After the device is updated, notify the matched Adv monitors */ + if (matched_monitors) { + btd_adv_monitor_notify_monitors(adapter->adv_monitor_manager, + dev, rssi, matched_monitors); + g_slist_free(matched_monitors); + matched_monitors = NULL; + } + /* * Only if at least one client has requested discovery, maintain * list of found devices and name confirming for legacy devices. diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 046f5953f..211094c89 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -38,15 +38,12 @@ #include "device.h" #include "log.h" #include "src/error.h" -#include "src/shared/ad.h" #include "src/shared/mgmt.h" #include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" -static void monitor_device_free(void *data); - #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" @@ -93,7 +90,7 @@ enum monitor_state { MONITOR_STATE_HONORED, /* Accepted by kernel */ }; -struct pattern { +struct btd_adv_monitor_pattern { uint8_t ad_type; uint8_t offset; uint8_t length; @@ -142,6 +139,23 @@ struct app_match_data { const char *path; }; +struct adv_content_filter_info { + uint8_t eir_len; + const uint8_t *eir; + + bool matched; /* Intermediate state per monitor */ + GSList *matched_monitors; /* List of matched monitors */ +}; + +struct adv_rssi_filter_info { + struct btd_device *device; + int8_t rssi; +}; + +static void monitor_device_free(void *data); +static void adv_monitor_filter_rssi(struct adv_monitor *monitor, + struct btd_device *device, int8_t rssi); + const struct adv_monitor_type { enum monitor_type type; const char *name; @@ -164,7 +178,7 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) /* Frees a pattern */ static void pattern_free(void *data) { - struct pattern *pattern = data; + struct btd_adv_monitor_pattern *pattern = data; if (!pattern) return; @@ -172,6 +186,12 @@ static void pattern_free(void *data) free(pattern); } +void btd_adv_monitor_test_pattern_destroy( + struct btd_adv_monitor_pattern *pattern) +{ + pattern_free(pattern); +} + /* Frees a monitor object */ static void monitor_free(void *data) { @@ -444,6 +464,42 @@ failed: return false; } +/* Allocates and initiates a pattern with the given content */ +static struct btd_adv_monitor_pattern *pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value) +{ + struct btd_adv_monitor_pattern *pattern; + + if (offset > BT_AD_MAX_DATA_LEN - 1) + return NULL; + + if ((ad_type > BT_AD_3D_INFO_DATA && + ad_type != BT_AD_MANUFACTURER_DATA) || + ad_type < BT_AD_FLAGS) { + return NULL; + } + + if (!value || !length || offset + length > BT_AD_MAX_DATA_LEN) + return NULL; + + pattern = new0(struct btd_adv_monitor_pattern, 1); + if (!pattern) + return NULL; + + pattern->ad_type = ad_type; + pattern->offset = offset; + pattern->length = length; + memcpy(pattern->value, value, pattern->length); + + return pattern; +} + +struct btd_adv_monitor_pattern *btd_adv_monitor_test_pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value) +{ + return pattern_create(ad_type, offset, length, value); +} + /* Retrieves Patterns from the remote Adv Monitor object, verifies the values * and update the local Adv Monitor */ @@ -473,7 +529,7 @@ static bool parse_patterns(struct adv_monitor *monitor, const char *path) int value_len; uint8_t *value; uint8_t offset, ad_type; - struct pattern *pattern; + struct btd_adv_monitor_pattern *pattern; DBusMessageIter struct_iter, value_iter; dbus_message_iter_recurse(&array_iter, &struct_iter); @@ -505,28 +561,10 @@ static bool parse_patterns(struct adv_monitor *monitor, const char *path) dbus_message_iter_get_fixed_array(&value_iter, &value, &value_len); - // Verify the values - if (offset > BT_AD_MAX_DATA_LEN - 1) - goto failed; - - if ((ad_type > BT_AD_3D_INFO_DATA && - ad_type != BT_AD_MANUFACTURER_DATA) || - ad_type < BT_AD_FLAGS) { - goto failed; - } - - if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) - goto failed; - - pattern = new0(struct pattern, 1); + pattern = pattern_create(ad_type, offset, value_len, value); if (!pattern) goto failed; - pattern->ad_type = ad_type; - pattern->offset = offset; - pattern->length = value_len; - memcpy(pattern->value, value, pattern->length); - queue_push_tail(monitor->patterns, pattern); dbus_message_iter_next(&array_iter); @@ -961,6 +999,155 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) manager_destroy(manager); } +/* Matches the content based on the given pattern */ +bool btd_adv_monitor_pattern_match( + const uint8_t *eir, uint8_t eir_len, + const struct btd_adv_monitor_pattern *pattern) +{ + const uint8_t *data; + uint8_t idx = 0; + uint8_t field_len, data_len, data_type; + + while (idx < eir_len - 1) { + field_len = eir[0]; + + /* Check for the end of EIR */ + if (field_len == 0) + break; + + idx += field_len + 1; + + /* Do not continue filtering if got incorrect length */ + if (idx >= eir_len) + break; + + data = &eir[2]; + data_type = eir[1]; + data_len = field_len - 1; + + eir += field_len + 1; + + if (data_type != pattern->ad_type) + continue; + + if (data_len < pattern->offset + pattern->length) + continue; + + if (pattern->offset + pattern->length > BT_AD_MAX_DATA_LEN) + continue; + + if (!memcmp(data + pattern->offset, pattern->value, + pattern->length)) + return true; + } + + return false; +} + +/* Processes the content matching based on a pattern */ +static void adv_match_per_pattern(void *data, void *user_data) +{ + struct btd_adv_monitor_pattern *pattern = data; + struct adv_content_filter_info *info = user_data; + + if (!pattern || info->matched) + return; + + info->matched = btd_adv_monitor_pattern_match(info->eir, info->eir_len, + pattern); +} + +/* Processes the content matching based pattern(s) of a monitor */ +static void adv_match_per_monitor(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct adv_content_filter_info *info = user_data; + + if (!monitor && monitor->state != MONITOR_STATE_HONORED) + return; + + /* Reset the intermediate matched status */ + info->matched = false; + + if (monitor->type == MONITOR_TYPE_OR_PATTERNS) { + queue_foreach(monitor->patterns, adv_match_per_pattern, info); + if (info->matched) + goto matched; + } + + return; + +matched: + info->matched_monitors = g_slist_prepend(info->matched_monitors, + monitor); +} + +/* Processes the content matching for the monitor(s) of an app */ +static void adv_match_per_app(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + + if (!app) + return; + + queue_foreach(app->monitors, adv_match_per_monitor, user_data); +} + +/* Processes the content matching for every app without RSSI filtering and + * notifying monitors. The caller is responsible of releasing the memory of the + * list but not the data. + * Returns the list of monitors whose content match eir. + */ +GSList *btd_adv_monitor_content_filter(struct btd_adv_monitor_manager *manager, + const uint8_t *eir, uint8_t eir_len) +{ + struct adv_content_filter_info info; + + if (!manager || !eir || !eir_len) + return NULL; + + info.eir_len = eir_len; + info.eir = eir; + info.matched_monitors = NULL; + + queue_foreach(manager->apps, adv_match_per_app, &info); + + return info.matched_monitors; +} + +/* Wraps adv_monitor_filter_rssi() to processes the content-matched monitor with + * RSSI filtering and notifies it on device found/lost event + */ +static void monitor_filter_rssi(gpointer a, gpointer b) +{ + struct adv_monitor *monitor = a; + struct adv_rssi_filter_info *info = b; + + if (!monitor || !info) + return; + + adv_monitor_filter_rssi(monitor, info->device, info->rssi); +} + +/* Processes every content-matched monitor with RSSI filtering and notifies on + * device found/lost event. The caller is responsible of releasing the memory + * of matched_monitors list but not its data. + */ +void btd_adv_monitor_notify_monitors(struct btd_adv_monitor_manager *manager, + struct btd_device *device, int8_t rssi, + GSList *matched_monitors) +{ + struct adv_rssi_filter_info info; + + if (!manager || !device || !matched_monitors) + return; + + info.device = device; + info.rssi = rssi; + + g_slist_foreach(matched_monitors, monitor_filter_rssi, &info); +} + /* Matches a device based on btd_device object */ static bool monitor_device_match(const void *a, const void *b) { diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 351e7f9aa..b660f5941 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -20,16 +20,28 @@ #ifndef __ADV_MONITOR_H #define __ADV_MONITOR_H +#include <glib.h> + +#include "src/shared/ad.h" + struct mgmt; struct btd_device; struct btd_adapter; struct btd_adv_monitor_manager; +struct btd_adv_monitor_pattern; struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct btd_adapter *adapter, struct mgmt *mgmt); void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); +GSList *btd_adv_monitor_content_filter(struct btd_adv_monitor_manager *manager, + const uint8_t *eir, uint8_t eir_len); + +void btd_adv_monitor_notify_monitors(struct btd_adv_monitor_manager *manager, + struct btd_device *device, int8_t rssi, + GSList *matched_monitors); + void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, struct btd_device *device); @@ -42,5 +54,12 @@ void btd_adv_monitor_rssi_test_teardown(void *monitor_obj); bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj); bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, int8_t adv_rssi); +struct btd_adv_monitor_pattern *btd_adv_monitor_test_pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value); +void btd_adv_monitor_test_pattern_destroy( + struct btd_adv_monitor_pattern *pattern); +bool btd_adv_monitor_pattern_match( + const uint8_t *eir, uint8_t eir_len, + const struct btd_adv_monitor_pattern *pattern); #endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EPZ/LiQMY1+vrwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:11:32 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id sHJxKiQMY18MzwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:11:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E5A5BA0B9B; Thu, 17 Sep 2020 09:11:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726196AbgIQHLZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:11:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726306AbgIQHLW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:11:22 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D160C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:11:21 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id u9so644529plk.4 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UgExmGJD0WUGNTW5ZOzNd/c9xQ0pED0xft63St+aD78=; b=H4deZI11SuubrwPDhXp0JP35c2fGNgTQ8J2YBbJlWPmLpNBavhgVaYZJYd4qs6i9e2 MiaiTEM5MegjK9/am9k2/Rs1O5hpr0Bzv9kabYTmlxKi7NPIZI+2cNFVjF6xkgKwUyVY o1/8Nh5icpWP3Qq58LCEHoLnRCfjA2knVzQyM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UgExmGJD0WUGNTW5ZOzNd/c9xQ0pED0xft63St+aD78=; b=FGtcM78ka11LjLa1WMYZ0U/SGXdfLl1fj/ESfXw7ECrfgsZN2BUZMTGGY+OMNFvJiy sGKJ7E2dXC2dw5ko8HeCWnPVLf/JHjQRky6rOO3tQT8JPl4laF1ESHJ5p2szC95AFyWu +3y0ItX+ACelmR3fBMQNKs0FVYHQnuGhquajg91Hw9KgraW+tQBIGFtOeH2dYWru8K4Y 1Q1FJ8Fkx6aYfCFdy3UREu5pgx8WhUdMRr5RcidhkEMhJX29z+1qDBMu4KP009ABPRLd RZlaKLEU+hB0EgVwjD2sbrV58vjRv2GXVRAaVRk5IExrbcLEwghqH66CJLH+I1UBt7HD FSzg== X-Gm-Message-State: AOAM533Hp+cJNHzziw0HAsmRR4fPWrGFblNvhOMDGNEuE5Hdj/yUt4OV KHD3vBbgIM+Chc78yrEs7d3s+17+pLzdjA== X-Google-Smtp-Source: ABdhPJzOb98UE0Mm94MyqND52bFFemPfGRpAbe+aHAzinIOYpE9ek65jKdtJawQ/EjaEvim5GzA0Pw== X-Received: by 2002:a17:90a:ea08:: with SMTP id w8mr7438751pjy.124.1600326680393; Thu, 17 Sep 2020 00:11:20 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id j26sm933478pgl.91.2020.09.17.00.11.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:11:19 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v4 4/8] adv_monitor: Implement unit tests for content filter Date: Thu, 17 Sep 2020 00:10:37 -0700 Message-Id: <20200917001020.BlueZ.v4.4.I7f88b6e4c63c14d77974438eb2f07326aedbfd9b@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: E5A5BA0B9B X-Rspamd-UID: ce6494 This implements the unit tests for verifying the correctness of advertisement data fields matching against a pattern. Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v3) Changes in v3: - Fix mixed declarations and assignments Changes in v2: - Cast test data to void * doc/test-coverage.txt | 4 +- unit/test-adv-monitor.c | 144 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 2 deletions(-) diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt index 5296983e6..e15474a44 100644 --- a/doc/test-coverage.txt +++ b/doc/test-coverage.txt @@ -30,9 +30,9 @@ test-gobex-transfer 36 OBEX transfer handling test-gdbus-client 13 D-Bus client handling test-gatt 180 GATT qualification test cases test-hog 6 HID Over GATT qualification test cases -test-adv-monitor 5 Advertisement Monitor test cases +test-adv-monitor 9 Advertisement Monitor test cases ----- - 766 + 770 Automated end-to-end testing diff --git a/unit/test-adv-monitor.c b/unit/test-adv-monitor.c index 970be84b0..a19a3092b 100644 --- a/unit/test-adv-monitor.c +++ b/unit/test-adv-monitor.c @@ -40,6 +40,8 @@ if (type == TEST_RSSI_FILTER) { \ test.rssi_filter_test_data = (void *)&data; \ test.rssi_filter_test_data->test_info = &test; \ + } else if (type == TEST_CONTENT_FILTER) { \ + test.content_filter_test_data = (void *)&data; \ } \ tester_add(name, &test, setup_fn, test_fn, teardown_fn);\ } while (0) @@ -94,6 +96,22 @@ struct rssi_filter_test { } test_steps[]; }; +struct content_filter_test { + void *advmon_pattern; /* btd_adv_monitor_pattern */ + + bool expected_match; + + const struct { + uint8_t ad_type; + uint8_t offset; + uint8_t length; + uint8_t value[BT_AD_MAX_DATA_LEN]; + } pattern; + + uint8_t eir_len; + uint8_t eir[]; +}; + /* Parent data structure to hold the test data and information, * used by tester_* functions and callbacks. */ @@ -103,6 +121,7 @@ struct test_data { union { struct rssi_filter_test *rssi_filter_test_data; + struct content_filter_test *content_filter_test_data; }; }; @@ -211,6 +230,62 @@ static struct rssi_filter_test rssi_data_5 = { }, }; +/* Content Filter Test 1: + * The valid EIR data contains the given pattern whose content is a UUID16 AD + * data. + */ +static struct content_filter_test content_data_1 = { + .expected_match = true, + .pattern = {0x03, 0x02, 0x02, {0x09, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 2: + * The valid EIR data does not match the given pattern whose content is a UUID16 + * AD data. + */ +static struct content_filter_test content_data_2 = { + .expected_match = false, + .pattern = {0x03, 0x02, 0x02, {0x0d, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 3: + * The valid EIR data does not have the given pattern whose content is a UUID32 + * AD data. + */ +static struct content_filter_test content_data_3 = { + .expected_match = false, + .pattern = {0x05, 0x00, 0x04, {0x09, 0x18, 0x00, 0x00} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 4: + * The valid EIR data does not match the given pattern whose content is a + * UUID16 AD data due to invalid starting position of matching. + */ +static struct content_filter_test content_data_4 = { + .expected_match = false, + .pattern = {0x03, 0x02, 0x02, {0x09, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x03, 0x03, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + /* Initialize the data required for RSSI Filter test */ static void setup_rssi_filter_test(gpointer data) { @@ -343,6 +418,60 @@ static gboolean test_rssi_filter(gpointer data) return FALSE; } +/* Initialize the data required for Content Filter test */ +static void setup_content_filter_test(gpointer data) +{ + struct content_filter_test *test = data; + struct btd_adv_monitor_pattern *pattern = NULL; + + pattern = btd_adv_monitor_test_pattern_create(test->pattern.ad_type, + test->pattern.offset, + test->pattern.length, + test->pattern.value); + if (!pattern) { + tester_setup_failed(); + return; + } + + test->advmon_pattern = pattern; + tester_setup_complete(); +} + +/* Cleanup after the Content Filter test is done */ +static void teardown_content_filter_test(gpointer data) +{ + struct content_filter_test *test = data; + + if (!test) + tester_teardown_complete(); + + btd_adv_monitor_test_pattern_destroy(test->advmon_pattern); + test->advmon_pattern = NULL; + + tester_teardown_complete(); +} + +/* Execute the sub-steps of Content Filter test */ +static void test_content_filter(gpointer data) +{ + struct content_filter_test *test = data; + struct btd_adv_monitor_pattern *pattern = test->advmon_pattern; + + if (!pattern) { + tester_test_abort(); + return; + } + + if (btd_adv_monitor_pattern_match(test->eir, test->eir_len, + test->advmon_pattern) == + test->expected_match) { + tester_test_passed(); + return; + } + + tester_test_failed(); +} + /* Handler function to prepare for a test */ static void setup_handler(gconstpointer data) { @@ -350,6 +479,8 @@ static void setup_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) setup_rssi_filter_test(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + setup_content_filter_test(test->content_filter_test_data); } /* Handler function to cleanup after the test is done */ @@ -359,6 +490,8 @@ static void teardown_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) teardown_rssi_filter_test(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + teardown_content_filter_test(test->content_filter_test_data); } /* Handler function to execute a test with the given data set */ @@ -368,6 +501,8 @@ static void test_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) test_rssi_filter(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + test_content_filter(test->content_filter_test_data); } int main(int argc, char *argv[]) @@ -387,5 +522,14 @@ int main(int argc, char *argv[]) define_test("/advmon/rssi/5", TEST_RSSI_FILTER, rssi_data_5, setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/1", TEST_CONTENT_FILTER, content_data_1, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/2", TEST_CONTENT_FILTER, content_data_2, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/3", TEST_CONTENT_FILTER, content_data_3, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/4", TEST_CONTENT_FILTER, content_data_4, + setup_handler, test_handler, teardown_handler); + return tester_run(); } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id COGLEjAMY1+vrwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:11:44 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id KGlBDzAMY1/3YgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:11:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2B3A8A0B55; Thu, 17 Sep 2020 09:11:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726219AbgIQHLe (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:11:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbgIQHLd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:11:33 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9A3DC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:11:33 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id y1so820108pgk.8 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u+E1bUX0uVxPcQEsE71u1Ro0+1uBNDa00K7AzDVg6ww=; b=Fxpt9Lsqqy/qt2V4rsBntDZKzXyPMUu4spQvy1eli92Q67cswoxdLOQkfJtNQRSpfi uN4taFBp2ufLpclzc7aYMFMYAZsEY7a1zBdBqmKwnCBxIUWtdJJLSeWBn3gF7vN5Er2M ZgVpZwwWj8NF7cyKym6vF+FVKwvvIXseH+c7k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u+E1bUX0uVxPcQEsE71u1Ro0+1uBNDa00K7AzDVg6ww=; b=r4m1RlEDHECV0HuLf+0jg2A5euPEWhKDHwiOlXtmUoAEoY3cP1VOApFGBALN2BGKXl U2XAHW7JYes6J+iY7U4fLoU+LPNuX6M8UTtSLmYpXFHC8xK3NVjI4twU4QB55y6cPhDY sxR376PtWgJ22KfmI6PP6KC1+U5TUux0Qg89JfnrnLzV0viaVqzpHgyTlKEODI3OJFRI 05szeY8vfYUFcyTqUBHQ9SwbhlxrseQMqP7BHIhsrmatTQibcZw+o87e3h8tnKffsYa1 mDgRqSKZF3HdMmUilY6ICnQmCgyFyBj9+5kPSRtLIjaJQu0jE8nRm3e/ceSk9VUGGkpN fvVA== X-Gm-Message-State: AOAM532lWKGQbXbbCcqT/+JXnGlF9mj/VkzmbKAU5OBpbmMPlOWn0tAD Lg95+7cL6nqchpSqDNbKDD2QT7pbjBrWrA== X-Google-Smtp-Source: ABdhPJzuPzGZjOYnm97uN1eTAdJM1rMD/ScX0sop+qE7UogxWgvVbzn0UhZfVR4eTbAXi3D+6I0ikA== X-Received: by 2002:a65:5282:: with SMTP id y2mr10948307pgp.132.1600326693066; Thu, 17 Sep 2020 00:11:33 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id j26sm933478pgl.91.2020.09.17.00.11.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:11:32 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 5/8] adapter: Clear all Adv monitors upon bring-up Date: Thu, 17 Sep 2020 00:10:39 -0700 Message-Id: <20200917001020.BlueZ.v4.5.Id6bfe7838831ae01fddc8605689dd77b51673960@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.71 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2B3A8A0B55 X-Rspamd-UID: 111f96 This clears all Adv monitors upon daemon bring-up by issuing MGMT_OP_REMOVE_ADV_MONITOR command with monitor_handle 0. The following test was performed: - Add an Adv Monitor using btmgmt, restart bluetoothd and observe the monitor got removed. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Howard Chung <howardchung@google.com> --- (no changes since v1) src/adapter.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index d33ce7124..191467048 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -9513,6 +9513,43 @@ failed: btd_adapter_unref(adapter); } +static void reset_adv_monitors_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct mgmt_rp_remove_adv_monitor *rp = param; + + if (status != MGMT_STATUS_SUCCESS) { + error("Failed to reset Adv Monitors: %s (0x%02x)", + mgmt_errstr(status), status); + return; + } + + if (length < sizeof(*rp)) { + error("Wrong size of remove Adv Monitor response for reset " + "all Adv Monitors"); + return; + } + + DBG("Removed all Adv Monitors"); +} + +static void reset_adv_monitors(uint16_t index) +{ + struct mgmt_cp_remove_adv_monitor cp; + + DBG("sending remove Adv Monitor command with handle 0"); + + /* Handle 0 indicates to remove all */ + cp.monitor_handle = 0; + if (mgmt_send(mgmt_master, MGMT_OP_REMOVE_ADV_MONITOR, index, + sizeof(cp), &cp, reset_adv_monitors_complete, NULL, + NULL) > 0) { + return; + } + + error("Failed to reset Adv Monitors"); +} + static void index_added(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9527,6 +9564,8 @@ static void index_added(uint16_t index, uint16_t length, const void *param, return; } + reset_adv_monitors(index); + adapter = btd_adapter_new(index); if (!adapter) { btd_error(index, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iJfuKDwMY1+vrwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:11:56 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YAIZJTwMY1/cGgAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:11:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 44D78A0B74; Thu, 17 Sep 2020 09:11:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726299AbgIQHLt (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:11:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgIQHLp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:11:45 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B75AC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:11:45 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id y1so820422pgk.8 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wXANRElz/qKLo+YPc/C/DfIhCrjha/xK9SJq8ld3Zj4=; b=bW5Iw/vqKkEA4l5FHtbwoJDv+D76RItaw3xlrppATUyWw7hs22EjQnVigtFnlznoPa 5antFM5KrFFkEYSBHEk+HuBfrzfUDej8pw2vwPMRmEDR+EMSUaLoGeNdhe+vOesJH7R9 cAKPmZRxjh0ZUwDXsUIdiWHyYh+OMY+FpubBg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wXANRElz/qKLo+YPc/C/DfIhCrjha/xK9SJq8ld3Zj4=; b=j4/zymIHTJRSrsFKcdOg7jBvmMEFjoVi8CwQ927gd4sTigj0Oa2Dkl73aUj+ITDgCH C1YIvhvIkJo4JDcux6FszIYhATdH120vV13HoXbrdo6bU6kv+qJjsMKihBrw+pikzSqO GEAw8d+WW10vm8Je/zZTguNUJAN6wp92eg17hPD1O4gtR9ztEeQ18kX5mO1GSzB7HfHq bzHzN3PitfFu4uhAd88TqBc4kI2uyP4oJ05uXsg6QA0UCMDiuY0A7BA6qcnYXkpphjGh XaPs6YkqWcUNd+w6dr5Bcd9aavBQOxaanP8JQzdhWfMKHLIWIaGLZSV+6APGLnYQsf/B F3Sw== X-Gm-Message-State: AOAM532i9Q5v0ZEli1Y4TcyZbzedob+CMuvJQe+v8oCoZ1SfpSCfZ54Q CjisaGo5ol3DpkNeWtoMZvojPsmmnN/ROA== X-Google-Smtp-Source: ABdhPJy5mTj/3YOTN3YiJ2C5EptuBHmiJRAcCbDDb36vydCXONr6xkWB48A5w8VjxvewK4/PV4Hziw== X-Received: by 2002:a62:7c82:0:b029:13c:1611:66b9 with SMTP id x124-20020a627c820000b029013c161166b9mr25094985pfc.4.1600326704726; Thu, 17 Sep 2020 00:11:44 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id j26sm933478pgl.91.2020.09.17.00.11.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:11:44 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 6/8] adv_monitor: Implement Add Adv Patterns Monitor cmd handler Date: Thu, 17 Sep 2020 00:10:41 -0700 Message-Id: <20200917001020.BlueZ.v4.6.Ibbcb11712b613ef95c31b41207c3ea945c830018@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.46 / 15.00 / 15.00 X-Rspamd-Queue-Id: 44D78A0B74 X-Rspamd-UID: be21c4 From: Howard Chung <howardchung@google.com> - Send the MGMT_OP command to kernel upon registration of a Adv patterns monitor. - Call Activate() or Release() to client depending on the reply from kernel the call through syslog Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 211094c89..deaa1894a 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -609,11 +609,59 @@ done: return monitor->state != MONITOR_STATE_FAILED; } +/* Handles the callback of Add Adv Patterns Monitor command */ +static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_rp_add_adv_patterns_monitor *rp = param; + struct adv_monitor *monitor = user_data; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(adapter_id, "Failed to Add Adv Patterns Monitor " + "with status 0x%02x", status); + monitor_release(monitor, NULL); + return; + } + + if (length < sizeof(*rp)) { + btd_error(adapter_id, "Wrong size of Add Adv Patterns Monitor " + "response"); + monitor_release(monitor, NULL); + return; + } + + monitor->state = MONITOR_STATE_HONORED; + + DBG("Calling Activate() on Adv Monitor of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "Activate", NULL, NULL, NULL, + NULL); + + DBG("Adv Monitor with handle:0x%04x added", + le16_to_cpu(rp->monitor_handle)); +} + +static void monitor_copy_patterns(void *data, void *user_data) +{ + struct btd_adv_monitor_pattern *pattern = data; + struct mgmt_cp_add_adv_monitor *cp = user_data; + + if (!pattern) + return; + + memcpy(cp->patterns + cp->pattern_count, pattern, sizeof(*pattern)); + cp->pattern_count++; +} + /* Handles an Adv Monitor D-Bus proxy added event */ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) { struct adv_monitor *monitor; struct adv_monitor_app *app = user_data; + struct mgmt_cp_add_adv_monitor *cp = NULL; + uint8_t pattern_count, cp_len; uint16_t adapter_id = app->manager->adapter_id; const char *path = g_dbus_proxy_get_path(proxy); const char *iface = g_dbus_proxy_get_interface(proxy); @@ -646,7 +694,24 @@ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) queue_push_tail(app->monitors, monitor); + pattern_count = queue_length(monitor->patterns); + cp_len = sizeof(struct mgmt_cp_add_adv_monitor) + + pattern_count * sizeof(struct mgmt_adv_pattern); + + cp = malloc0(cp_len); + queue_foreach(monitor->patterns, monitor_copy_patterns, cp); + + if (!mgmt_send(app->manager->mgmt, MGMT_OP_ADD_ADV_PATTERNS_MONITOR, + adapter_id, cp_len, cp, add_adv_patterns_monitor_cb, + monitor, NULL)) { + error("Unable to send Add Adv Patterns Monitor command"); + goto done; + } + DBG("Adv Monitor allocated for the object at path %s", path); + +done: + free(cp); } /* Handles the removal of an Adv Monitor D-Bus proxy */ @@ -1063,7 +1128,7 @@ static void adv_match_per_monitor(void *data, void *user_data) struct adv_monitor *monitor = data; struct adv_content_filter_info *info = user_data; - if (!monitor && monitor->state != MONITOR_STATE_HONORED) + if (!monitor || monitor->state != MONITOR_STATE_HONORED) return; /* Reset the intermediate matched status */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wCpGFUwMY19dkwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:12:12 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id IPHhEUwMY19hLgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:12:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E900EA0BC8; Thu, 17 Sep 2020 09:12:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726301AbgIQHL7 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:11:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbgIQHL4 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:11:56 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB3EEC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:11:55 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id d19so658520pld.0 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A+EJCB6WY4TQKa6gHOsgkF94rPPA4eTIhn24gfOv1nI=; b=GifaBBpuFjX6X7JtyOKmFFoqpi/bkFkXctb0DyH/7sa6RMIdidXGyEsi+rmFEJjtex hwb5Jb1HppE6dzM4Ubm+z9kcwRsvr9kGtbcwpGp6CfgbvHnAbxn7OgsIcPCqDmGw35sY Env5v8nZ+bLw41rFERYtE73ucHAGLirZro4PM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A+EJCB6WY4TQKa6gHOsgkF94rPPA4eTIhn24gfOv1nI=; b=Bs2nWNo4WyyohMcw0aQUiJC60+q4f1BRGI/Wx3jvvz/fIXQBccLIw3gXcIuLtYYwAc UzUMODAERaGureS3+6E6KEOyAMgf/Or5j2rYYZPXZDZNnPcpxxP/alTOQbvK8PiaA6Kf hyoJUCSVV+ku3EpPS6D5Ej8l2Q5fpJidqdfU5jzz9IKYgircfzO1bIhmt5RprS7I+/lF mRSf0gOLe8DtYn6UYZWYhQM1kyZ2+XYJm3nXUosmuKnYSZa6ZK/HgD+8T5WfFAYfQV30 /ufegCDuMbJgCGA2Rluj7pDINAgTNVvZYItLUKIW8OR1LQoccQahAqlQJUyYfxMvN7Sv L/zw== X-Gm-Message-State: AOAM531XzsswXyvhTn96foq4haLAlXLaBCzJumJvXOYuHMJn4p5lltQL WOG8p8R1z08UKmHANnF7GBZYwe8i2Lp7eQ== X-Google-Smtp-Source: ABdhPJyboupGRuOCEHWaXxCA+qSGVvSbuCz87tNmakvoM8fvm+Bz3X4KW0p4CnNlu6QObrd20GG+lQ== X-Received: by 2002:a17:90a:9103:: with SMTP id k3mr7247981pjo.4.1600326714960; Thu, 17 Sep 2020 00:11:54 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id j26sm933478pgl.91.2020.09.17.00.11.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:11:54 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 7/8] adv_monitor: Fix return type of RegisterMonitor() method Date: Thu, 17 Sep 2020 00:10:43 -0700 Message-Id: <20200917001020.BlueZ.v4.7.Ic8dbe9115e82704b4c0c860eee27ad897db13237@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.85 / 15.00 / 15.00 X-Rspamd-Queue-Id: E900EA0BC8 X-Rspamd-UID: d3ddfa This modifies the D-Bus call return type to be asynchronous for RegisterMonitor() method call. The following test was performed: - Enter bluetoothctl, exit the console and re-enter the console without AlreadyExist error for RegisterMonitor() upon bring-up of the console. Reviewed-by: Howard Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index deaa1894a..b4fe39eff 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -758,6 +758,8 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, app->monitors = queue_new(); + app->reg = dbus_message_ref(msg); + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); /* Note that any property changes on a monitor object would not affect @@ -769,8 +771,6 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); - app->reg = dbus_message_ref(msg); - return app; } @@ -864,7 +864,7 @@ static DBusMessage *unregister_monitor(DBusConnection *conn, } static const GDBusMethodTable adv_monitor_methods[] = { - { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mAKKMFMMY1/4hwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:12:19 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id mGtMLVMMY1+AfgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:12:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 35C25A0B7B; Thu, 17 Sep 2020 09:12:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbgIQHMI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:12:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbgIQHMH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:12:07 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9561C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:12:06 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id z18so653256pfg.0 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8rRwiC+DDU1Y36GFikHuTKEZhj0osqiQgXYTeZEu+do=; b=DElzKW60fXrp36aMCuwLCroEmRdI/QLe4f+mF6g2FWosJuaX/BF5B3uUQfwTlEjI9F xBRJHk7GBuFgtcE7eMe1zfkrQedSlmE0joUUxexwNYL9/dpyfeXzrYosbu49x4mclhOL TfBj3bI5Zsbx/kAq7ocPJ2xaZx7UgJGDcDoM4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8rRwiC+DDU1Y36GFikHuTKEZhj0osqiQgXYTeZEu+do=; b=XV4Ji5ZTPslDn9jWmJFlnhhqe8t8eP2mYP3fhKMmNmRYc6MYhEi1//7hqRMVcfqQvh wCHgIN6MAhn/0IgVC1GWYjdeZr6M/EBjCs0N1wcnxZkpltd0qGRDn+wsu+Dewn7SW0T0 YTOlvH6uvKprZx6I1NUdkqePvaFE/EMvDIwJ8MqR+NEvlc1Nn0gjrVdtGEowxVfK8rfE cMsM94TvzJACAkQiQOmpR3jjmUJ4WneWdvFVmrVWMpCnrsXLl1Kpt6Vw/lSlbQmS/Oua 09vmmIqMV0Nd+JVRfXlNb71fpOfmYQIPjKA5LYlazk6nIGfkiHPOG7PeqRePVpoGeOxf Zrcw== X-Gm-Message-State: AOAM5301bR8nX/5AzQr/zxtlRMtPMaUmgYVWkjD+G+kNjZDr/HESXiRa CMa/2wGI8xU/KmPJd0chCQu1kvAQfod3EQ== X-Google-Smtp-Source: ABdhPJzx9zzM0V7Xsu7M5ozkvlJNQZYAMUIGCIFdhb5cmPAW9IbizanGc4ZYyNGjngjsc0zPF1BqyA== X-Received: by 2002:a05:6a00:14cc:b029:142:2501:3988 with SMTP id w12-20020a056a0014ccb029014225013988mr9829677pfu.77.1600326725778; Thu, 17 Sep 2020 00:12:05 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id j26sm933478pgl.91.2020.09.17.00.12.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 00:12:05 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, Howard Chung <howardchung@google.com>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Manish Mandlik <mmandlik@chromium.org> Subject: [BlueZ PATCH v4 8/8] adv_monitor: Issue Remove Adv Monitor mgmt call Date: Thu, 17 Sep 2020 00:10:45 -0700 Message-Id: <20200917001020.BlueZ.v4.8.Ifda683c92ff520bf58ac37c02dc40b8d9598d1b0@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.17 / 15.00 / 15.00 X-Rspamd-Queue-Id: 35C25A0B7B X-Rspamd-UID: 7d5a1a From: Alain Michaud <alainm@chromium.org> This calls Remove Adv Monitor command to kernel and handles the callback during a monitor removal initiated by a D-Bus client. This also registers callback for getting notified on Adv Monitor Removed event, so that the Adv monitor manager can invalidate the monitor by calling Release() on its proxy. The following tests were performed. - In bluetoothctl console, add a monitor and remove the monitor by its index and verify the removal in both the output of btmgmt and syslog. - In bluetoothctl console, add a monitor, remove the monitor via btmgmt and verify the removal in syslog. Reviewed-by: Howard Chung <howardchung@google.com> --- (no changes since v3) Changes in v3: - Fix const qualifier of a pointer src/adv_monitor.c | 128 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 120 insertions(+), 8 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index b4fe39eff..27da30b51 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -88,6 +88,7 @@ enum monitor_state { MONITOR_STATE_FAILED, /* Failed to be init'ed */ MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ MONITOR_STATE_HONORED, /* Accepted by kernel */ + MONITOR_STATE_REMOVING, /* Removing from kernel */ }; struct btd_adv_monitor_pattern { @@ -103,6 +104,7 @@ struct adv_monitor { char *path; enum monitor_state state; /* MONITOR_STATE_* */ + uint16_t monitor_handle; /* Kernel Monitor Handle */ int8_t high_rssi; /* High RSSI threshold */ uint16_t high_rssi_timeout; /* High RSSI threshold timeout */ @@ -631,6 +633,7 @@ static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, return; } + monitor->monitor_handle = le16_to_cpu(rp->monitor_handle); monitor->state = MONITOR_STATE_HONORED; DBG("Calling Activate() on Adv Monitor of owner %s at path %s", @@ -639,8 +642,7 @@ static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, g_dbus_proxy_method_call(monitor->proxy, "Activate", NULL, NULL, NULL, NULL); - DBG("Adv Monitor with handle:0x%04x added", - le16_to_cpu(rp->monitor_handle)); + DBG("Adv monitor with handle:0x%04x added", monitor->monitor_handle); } static void monitor_copy_patterns(void *data, void *user_data) @@ -714,20 +716,77 @@ done: free(cp); } +/* Handles the callback of Remove Adv Monitor command */ +static void remove_adv_monitor_cb(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct adv_monitor *monitor = user_data; + const struct mgmt_rp_remove_adv_monitor *rp = param; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(adapter_id, "Failed to Remove Adv Monitor with " + "status 0x%02x", status); + goto done; + } + + if (length < sizeof(*rp)) { + btd_error(adapter_id, "Wrong size of Remove Adv Monitor " + "response"); + goto done; + } + +done: + queue_remove(monitor->app->monitors, monitor); + + DBG("Adv Monitor removed with handle:0x%04x, path %s", + monitor->monitor_handle, monitor->path); + + monitor_free(monitor); +} + + /* Handles the removal of an Adv Monitor D-Bus proxy */ static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) { struct adv_monitor *monitor; + struct mgmt_cp_remove_adv_monitor cp; struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; - monitor = queue_remove_if(app->monitors, monitor_match, proxy); - if (monitor) { - DBG("Adv Monitor removed for the object at path %s", - monitor->path); + monitor = queue_find(app->monitors, monitor_match, proxy); - /* The object was gone, so we don't need to call Release() */ - monitor_free(monitor); + /* A monitor removed event from kernel can remove a monitor and notify + * the app on Release() where this callback can be invoked, so we + * simply skip here. + */ + if (!monitor) + return; + + if (monitor->state != MONITOR_STATE_HONORED) + goto done; + + monitor->state = MONITOR_STATE_REMOVING; + + cp.monitor_handle = cpu_to_le16(monitor->monitor_handle); + + if (!mgmt_send(app->manager->mgmt, MGMT_OP_REMOVE_ADV_MONITOR, + adapter_id, sizeof(cp), &cp, remove_adv_monitor_cb, + monitor, NULL)) { + btd_error(adapter_id, "Unable to send Remove Advt Monitor " + "command"); + goto done; } + + return; + +done: + queue_remove(app->monitors, monitor); + + DBG("Adv Monitor removed in state %02x with path %s", monitor->state, + monitor->path); + + monitor_free(monitor); } /* Creates an app object, initiates it and sets D-Bus event handlers */ @@ -936,6 +995,55 @@ static const GDBusPropertyTable adv_monitor_properties[] = { { } }; +/* Matches a monitor based on its handle */ +static bool removed_monitor_match(const void *data, const void *user_data) +{ + const struct adv_monitor *monitor = data; + const struct mgmt_ev_adv_monitor_removed *ev = user_data; + + return monitor->monitor_handle == ev->monitor_handle; +} + +/* Remove the matched monitor and reports the removal to the app */ +static void app_remove_monitor(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + struct adv_monitor *monitor; + + monitor = queue_find(app->monitors, removed_monitor_match, user_data); + if (monitor) { + if (monitor->state == MONITOR_STATE_HONORED) + monitor_release(monitor, NULL); + + queue_remove(app->monitors, monitor); + + DBG("Adv Monitor at path %s removed", monitor->path); + + monitor_free(monitor); + } +} + +/* Processes Adv Monitor removed event from kernel */ +static void adv_monitor_removed_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const uint16_t adapter_id = manager->adapter_id; + struct btd_adv_monitor_manager *manager = user_data; + const struct mgmt_ev_adv_monitor_removed *ev = param; + + if (length < sizeof(*ev)) { + btd_error(adapter_id, "Wrong size of Adv Monitor Removed " + "event"); + return; + } + + /* Traverse the apps to find the monitor */ + queue_foreach(manager->apps, app_remove_monitor, ev); + + DBG("Adv Monitor removed event with handle 0x%04x processed", + ev->monitor_handle); +} + /* Allocates a manager object */ static struct btd_adv_monitor_manager *manager_new( struct btd_adapter *adapter, @@ -955,6 +1063,10 @@ static struct btd_adv_monitor_manager *manager_new( manager->adapter_id = btd_adapter_get_index(adapter); manager->apps = queue_new(); + mgmt_register(manager->mgmt, MGMT_EV_ADV_MONITOR_REMOVED, + manager->adapter_id, adv_monitor_removed_callback, + manager, NULL); + return manager; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ED7lMHcQY1+GOAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:29:59 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id WJaNLncQY1+AfgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:29:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 93374A0B7B; Thu, 17 Sep 2020 09:29:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726202AbgIQH3w (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:29:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbgIQH3v (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:29:51 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECD73C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:29:49 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id d20so1298338qka.5 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=V21v6IHH7VWvFFcnd+saX6v3K+b8G4CsnPueVNLEgAU=; b=fTVOfMhUMnjpXASNdfFkPyEvGswSCpjJwXeszCon7c5FVs4BzpiIuuBeT4GwgahSPL hbztXvL26g29yCoKWghcSFVKLz3psiYAN2DF1kM7nLfIlpeh5PkFOADivTvavrZMPJjU wj47ooH1xUIns3bBr+5Pn9YAf+RBIk2nDlcK5rvi0QmylIQTPFcqRtsXDMHpX6eTfsHh hG7DSTZnKQAnKhvnklvoDBr/wpBVu4a+cK5NvSUJJT5Vw+kkRs40bJB21iZswThXJYkq ULnZT4dXZSxDnVHR8gtBeUPsqe5srL3Jedpgo4nt0wzTx7O+AYnS2XL+fl+s2ZAISCHv C0ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=V21v6IHH7VWvFFcnd+saX6v3K+b8G4CsnPueVNLEgAU=; b=da7r+rdgG7ET1QUHnjt067IGqrvh+Sxp6QbFEExaToBx/XM+nE7V7PkrZ9gYaqTYn1 46nhQ4sJlrEhsD6dWVsxYPmIDAYunlu8+rCDpPbJvJkXVdcpko1sxQIEVD00i4hJAbtm HYUvdJqe6rNdYClkthtPvTsaMz9LI+fJWclS+Ig0QchRYZb5PJyMVQYdn40jG0wfCsPV 0FJPc0d0U+ITVASkjR2vK2nnsCMLCVp568dp4h2dYXws0OI6EndQ/RCcdtmC0Q2joNxf cYblNFl7Cw5jeTV9wC9lmRh48ZOLzrMxg+taud8FjE7nLuMBAlqCLdPtNfz8pv7X6jNo gfhw== X-Gm-Message-State: AOAM530A0qDB4sm6mgerJXUUI9NAcv5AHL/0BSgE/sOilIMb35o6HLBw FBUwDN4RceHW/axk4BT/gSEXb97fQehe+g== X-Google-Smtp-Source: ABdhPJwlLv3KTNTjJhsY2LtY0guurbjW3fHVC4/dqZp0Mg2gPykWDUO3esmqQjejaaUUhPWhzzarhA== X-Received: by 2002:a37:a414:: with SMTP id n20mr27404635qke.332.1600327786701; Thu, 17 Sep 2020 00:29:46 -0700 (PDT) Received: from [172.17.0.2] ([52.177.203.159]) by smtp.gmail.com with ESMTPSA id e13sm20429563qtr.85.2020.09.17.00.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 00:29:46 -0700 (PDT) Message-ID: <5f63106a.1c69fb81.7d82.ee0e@mx.google.com> Date: Thu, 17 Sep 2020 00:29:46 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============5572227676192822176==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v4,2/8] adv_monitor: Implement unit tests for RSSI Filter Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200917001020.BlueZ.v4.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> References: <20200917001020.BlueZ.v4.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.89 / 15.00 / 15.00 X-Rspamd-Queue-Id: 93374A0B7B X-Rspamd-UID: b35020 --===============5572227676192822176== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #161: FILE: unit/test-adv-monitor.c:1: +/* - total: 0 errors, 1 warnings, 512 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============5572227676192822176==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EKm/IhMRY19dkwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:32:35 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8JpzHxMRY19iVQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:32:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7227EA0B48; Thu, 17 Sep 2020 09:32:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726192AbgIQHc0 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:32:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726187AbgIQHcZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:32:25 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBE3CC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:32:24 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id q63so1309311qkf.3 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 00:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=+NwzptSIXt/pdjgSqGbczzEDrsAWbpRNE2NRKc4DI/8=; b=XUffPafB161ORIcplYmDp04CoQFj9Kxt8FmsGhmefqxdTtnlgjsRuMW7i8WGzX2OUJ mGv+nz20RGtz1clCWINeaF0vzI5y4y4wTv6u29xKr9MKiQt2NYebRLLQcdamFiHB0DKO RTm0ASPkesC4rypeRZSk/RFzFi98f/rIVGmNKqXdPxe4VEvdwGEkr/ZnevEC+KpXnUMX yYuqMpoMToKzhFuBJtSnLbBkJGx9bG1K43IXGyZM54QLjK9zwjQmosLUjnL9q7pNiwnH LzCiSf33bzw/6CbjiXoW/tNtNxdaNC3PKslfL8KixECQ1E24Bwh/tpRqsgrRdzqPeG0G GmpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=+NwzptSIXt/pdjgSqGbczzEDrsAWbpRNE2NRKc4DI/8=; b=KlFXEqWQykW3V6nlLnZpGozXRxAzIy2TQDxLQRH5gAoaDVVuhbESbYfrKHmoq4vIrD 84m2TteU1fQoUC93McSFfgj8Po98ft9MOYlvMV6M/4NvmuaSmVWDatSKC5ufd1zpJ/b5 EvZlYUDalieuAXhHOkG6uHbONm3F23NODwnE14iqX5wp5Ae142J/GJBQ5K6T2ndsA2QY OSSqe2WLYjP+9uooK9ZLUFulj1Mx/0xFqpnr/DocR+wyFOFzoiD9V0qUMa3kMbO0Zjwq 6ExD49daCwccATAJZIj5feNzxJuAOYwCHWaJRwCRdzvLwbLisK5vl+ThsjWh2lX4x87b JROw== X-Gm-Message-State: AOAM530GWpEpGDysHU+5z9S5miy5Y+qaSnsZL6xGbhxJ+pukS7j+i4eC iTkCus6ceE6x0hD5Zoc8kS++5bPPrHepPw== X-Google-Smtp-Source: ABdhPJwxLCd9QtgPe2ErvbB+iIaDYtAJqqhNM/sqP4RDKb2Hl7i1fHyWOLu1uxDVUxeMToFzyyzC2g== X-Received: by 2002:a37:a1cb:: with SMTP id k194mr26434459qke.354.1600327944074; Thu, 17 Sep 2020 00:32:24 -0700 (PDT) Received: from [172.17.0.2] ([52.177.203.159]) by smtp.gmail.com with ESMTPSA id m6sm20832528qkh.106.2020.09.17.00.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 00:32:23 -0700 (PDT) Message-ID: <5f631107.1c69fb81.7353d.f98c@mx.google.com> Date: Thu, 17 Sep 2020 00:32:23 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============6930316136080252613==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v4,1/8] adv_monitor: Implement RSSI Filter logic for background scanning Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917001020.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.01 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7227EA0B48 X-Rspamd-UID: 420349 --===============6930316136080252613== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 ClRoaXMgaXMgYXV0b21hdGVkIGVtYWlsIGFuZCBwbGVhc2UgZG8gbm90IHJlcGx5IHRvIHRoaXMg ZW1haWwhCgpEZWFyIHN1Ym1pdHRlciwKClRoYW5rIHlvdSBmb3Igc3VibWl0dGluZyB0aGUgcGF0 Y2hlcyB0byB0aGUgbGludXggYmx1ZXRvb3RoIG1haWxpbmcgbGlzdC4KV2hpbGUgd2UgYXJlIHBy ZXBhcmluZyBmb3IgcmV2aWV3aW5nIHRoZSBwYXRjaGVzLCB3ZSBmb3VuZCB0aGUgZm9sbG93aW5n Cmlzc3VlL3dhcm5pbmcuCgpUZXN0IFJlc3VsdDoKY2hlY2tidWlsZCBGYWlsZWQKCk91dHB1dHM6 CmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNlZSBg VScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQgKHNl ZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1bHQg KHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRlZmF1 bHQgKHNlZSBgVScpCmFyOiBgdScgbW9kaWZpZXIgaWdub3JlZCBzaW5jZSBgRCcgaXMgdGhlIGRl ZmF1bHQgKHNlZSBgVScpCnNyYy9hZHZfbW9uaXRvci5jOiBJbiBmdW5jdGlvbiDigJhhZHZfbW9u aXRvcl9yZW1vdmVkX2NhbGxiYWNr4oCZOgpzcmMvYWR2X21vbml0b3IuYzoxMDMwOjMwOiBlcnJv cjog4oCYbWFuYWdlcuKAmSB1bmRlY2xhcmVkIChmaXJzdCB1c2UgaW4gdGhpcyBmdW5jdGlvbikK IDEwMzAgfCAgY29uc3QgdWludDE2X3QgYWRhcHRlcl9pZCA9IG1hbmFnZXItPmFkYXB0ZXJfaWQ7 CiAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBefn5+fn5+CnNyYy9hZHZfbW9u aXRvci5jOjEwMzA6MzA6IG5vdGU6IGVhY2ggdW5kZWNsYXJlZCBpZGVudGlmaWVyIGlzIHJlcG9y dGVkIG9ubHkgb25jZSBmb3IgZWFjaCBmdW5jdGlvbiBpdCBhcHBlYXJzIGluCnNyYy9hZHZfbW9u aXRvci5jOjEwNDE6NTE6IGVycm9yOiBwYXNzaW5nIGFyZ3VtZW50IDMgb2Yg4oCYcXVldWVfZm9y ZWFjaOKAmSBkaXNjYXJkcyDigJhjb25zdOKAmSBxdWFsaWZpZXIgZnJvbSBwb2ludGVyIHRhcmdl dCB0eXBlIFstV2Vycm9yPWRpc2NhcmRlZC1xdWFsaWZpZXJzXQogMTA0MSB8ICBxdWV1ZV9mb3Jl YWNoKG1hbmFnZXItPmFwcHMsIGFwcF9yZW1vdmVfbW9uaXRvciwgZXYpOwogICAgICB8ICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXn4KSW4gZmlsZSBp bmNsdWRlZCBmcm9tIHNyYy9hZHZfbW9uaXRvci5jOjQyOgouL3NyYy9zaGFyZWQvcXVldWUuaDo0 ODoxNDogbm90ZTogZXhwZWN0ZWQg4oCYdm9pZCAq4oCZIGJ1dCBhcmd1bWVudCBpcyBvZiB0eXBl IOKAmGNvbnN0IHN0cnVjdCBtZ210X2V2X2Fkdl9tb25pdG9yX3JlbW92ZWQgKuKAmQogICA0OCB8 ICAgICAgICB2b2lkICp1c2VyX2RhdGEpOwogICAgICB8ICAgICAgICB+fn5+fn5efn5+fn5+fn4K Y2MxOiBhbGwgd2FybmluZ3MgYmVpbmcgdHJlYXRlZCBhcyBlcnJvcnMKbWFrZVsxXTogKioqIFtN YWtlZmlsZTo2ODYzOiBzcmMvYWR2X21vbml0b3Iub10gRXJyb3IgMQptYWtlOiAqKiogW01ha2Vm aWxlOjQwNTY6IGFsbF0gRXJyb3IgMgoKCgotLS0KUmVnYXJkcywKTGludXggQmx1ZXRvb3RoCg== --===============6930316136080252613==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QHJSMioRY19dkwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 09:32:58 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id sMMHLyoRY1+rZQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 09:32:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 01B4CA0B6B; Thu, 17 Sep 2020 09:32:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbgIQHce (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 03:32:34 -0400 Received: from mga02.intel.com ([134.134.136.20]:34014 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726262AbgIQHca (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 03:32:30 -0400 X-Greylist: delayed 447 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Sep 2020 03:26:55 EDT IronPort-SDR: QVEdakbEy/kD29J0HltJUU7hGUpmwYYWUFjLSaEmZesD7XOE7PdF27BIBuCG2drk2L2HKPpbAa 83H1m33fe87A== X-IronPort-AV: E=McAfee;i="6000,8403,9746"; a="147325381" X-IronPort-AV: E=Sophos;i="5.76,436,1592895600"; d="gz'50?scan'50,208,50";a="147325381" X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2020 00:19:08 -0700 IronPort-SDR: h/Xi5C3x07kXDxvnnDhqmCUkPFvEx1DqO18WZtbvZlmZ0XdHicSUp2T8ZVjbQl8hL42eoMx62i Q0WJQcZf5xCA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,436,1592895600"; d="gz'50?scan'50,208,50";a="346528395" Received: from lkp-server02.sh.intel.com (HELO bdcb92cf8b4e) ([10.239.97.151]) by orsmga007.jf.intel.com with ESMTP; 17 Sep 2020 00:19:05 -0700 Received: from kbuild by bdcb92cf8b4e with local (Exim 4.92) (envelope-from <lkp@intel.com>) id 1kIoC8-0000Sl-HY; Thu, 17 Sep 2020 07:19:04 +0000 Date: Thu, 17 Sep 2020 15:18:03 +0800 From: kernel test robot <lkp@intel.com> To: Daniel Winkler <danielwinkler@google.com>, linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: kbuild-all@lists.01.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH 6/6] Bluetooth: Add MGMT command for controller capabilities Message-ID: <202009171517.p8Egcc0h%lkp@intel.com> References: <20200916131430.6.I5068c01cae3cea674a96e103a0cf4d8c81425a4f@changeid> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="VS++wcV0S1rZb1Fb" Content-Disposition: inline In-Reply-To: <20200916131430.6.I5068c01cae3cea674a96e103a0cf4d8c81425a4f@changeid> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.97 / 15.00 / 15.00 X-Rspamd-Queue-Id: 01B4CA0B6B X-Rspamd-UID: cdda8e --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Daniel, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on bluetooth-next/master] [also build test WARNING on next-20200916] [cannot apply to net-next/master net/master v5.9-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Daniel-Winkler/Bluetooth-Add-new-MGMT-interface-for-advertising-add/20200917-042141 base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master config: x86_64-randconfig-s022-20200917 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.2-201-g24bdaac6-dirty # save the attached .config to linux build tree make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> sparse warnings: (new ones prefixed by >>) net/bluetooth/mgmt.c:3647:29: sparse: sparse: restricted __le16 degrades to integer net/bluetooth/mgmt.c:4104:9: sparse: sparse: cast to restricted __le32 >> net/bluetooth/mgmt.c:4386:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le16 [usertype] type @@ got int @@ >> net/bluetooth/mgmt.c:4386:27: sparse: expected restricted __le16 [usertype] type >> net/bluetooth/mgmt.c:4386:27: sparse: got int # https://github.com/0day-ci/linux/commit/171d4465b1f2811c76267c2f0acbcd0f77b5e99a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Daniel-Winkler/Bluetooth-Add-new-MGMT-interface-for-advertising-add/20200917-042141 git checkout 171d4465b1f2811c76267c2f0acbcd0f77b5e99a vim +4386 net/bluetooth/mgmt.c 4360 4361 static int read_controller_cap(struct sock *sk, struct hci_dev *hdev, 4362 void *data, u16 len) 4363 { 4364 u8 i = 0; 4365 4366 /* This command will return its data in TVL format. Currently we only 4367 * wish to include LE tx power parameters, so this struct can be given 4368 * a fixed size as data types are not changing. 4369 */ 4370 struct { 4371 struct mgmt_tlv entry; 4372 __s8 value; 4373 } __packed cap[2]; 4374 4375 BT_DBG("request for %s", hdev->name); 4376 memset(cap, 0, sizeof(cap)); 4377 4378 hci_dev_lock(hdev); 4379 4380 /* Append LE tx power bounds */ 4381 cap[i].entry.type = MGMT_CAP_LE_TX_PWR_MIN; 4382 cap[i].entry.length = sizeof(__s8); 4383 cap[i].value = hdev->min_le_tx_power; 4384 i++; 4385 > 4386 cap[i].entry.type = MGMT_CAP_LE_TX_PWR_MAX; 4387 cap[i].entry.length = sizeof(__s8); 4388 cap[i].value = hdev->max_le_tx_power; 4389 i++; 4390 4391 hci_dev_unlock(hdev); 4392 4393 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_READ_CONTROLLER_CAP, 4394 MGMT_STATUS_SUCCESS, cap, sizeof(cap)); 4395 } 4396 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org --VS++wcV0S1rZb1Fb Content-Type: application/gzip Content-Disposition: attachment; filename=".config.gz" Content-Transfer-Encoding: base64 H4sICKUDY18AAy5jb25maWcAjDxJc9w2s/f8iinnkhzsT5JlPade6QCS4AwyJMEA4Cy6sBR5 7KiixW8kfbH//esGuDRAULEPiQbdaGy9o8Gff/p5wV6eH++vn29vru/uvi++HB4Ox+vnw6fF 59u7w/8uMrmopFnwTJh3gFzcPrx8+8+3jxftxfniw7uP707eHm8uFuvD8eFwt0gfHz7ffnmB /rePDz/9/FMqq1ws2zRtN1xpIavW8J25fPPl5ubtb4tfssOft9cPi9/evQcypx9+dX+9Id2E bpdpevm9b1qOpC5/O3l/ctIDimxoP3v/4cT+G+gUrFoO4BNCPmVVW4hqPQ5AGlttmBGpB1sx 3TJdtktpZBQgKujKCUhW2qgmNVLpsVWoP9qtVGTcpBFFZkTJW8OSgrdaKjNCzUpxlgHxXMJ/ AEVjV9jgnxdLe153i6fD88vXccsTJde8amHHdVmTgSthWl5tWqZgz0QpzOX7M6AyzLasBYxu uDaL26fFw+MzEu57N6wW7QpmwpVFGekWMmVFv8Nv3sSaW9bQPbMLbjUrDMFfsQ1v11xVvGiX V4JMnEISgJzFQcVVyeKQ3dVcDzkHOAfAsDVkVnRnQrid22sIOMPI1tJZTrvI1ymeRwhmPGdN YeyJkx3um1dSm4qV/PLNLw+PD4dfBwS9ZWTb9V5vRJ1OGvD/qSnG9lpqsWvLPxre8Hjr2GVY wJaZdNVaaHSBqZJatyUvpdq3zBiWrmJcqXkhEkqXNaCtIpj2eJmCMS0GTogVRS9JIJSLp5c/ n74/PR/uR0la8oorkVqZrZVMyPIoSK/kljKSyqBVw3a2imteZfFe6YoyObZksmSi8tu0KGNI 7UpwhcvZT4mXWiDmLGAyDp1VyYyCc4O9AfkFzRXHwnWpDahIkO1SZtyfYi5VyrNOc4lqSVio ZkrzbnbDmVHKGU+aZa59njg8fFo8fg5OaVTxMl1r2cCYjqsySUa0R05RrFB8j3XesEJkzPC2 YNq06T4tIudt9fRmZJ8AbOnxDa+MfhWISpplKaOKNIZWwlGz7PcmildK3TY1TrnnY3N7fzg+ xVgZrNkaTAIHXiWkVldtDbRkZm3dcCCVRIjIirhsWnBMxsRyhaxhN8navOHoJhMbqdWK87I2 QLXiEaI9eCOLpjJM7elEO+Ar3VIJvfrtSevmP+b66e/FM0xncQ1Te3q+fn5aXN/cPL48PN8+ fAk2DDq0LLU0HB8PI2+EMgEYDyYyE+RqyzVxQonOULekHNQdYMTWgjYfHRLCUtgEslKwve1E CVrQLiQ1bpkWUeH6gb2xe6jSZqFj/FXtW4CNU4QfLd8BexF+0x6G7RM04VJt147LI6BJU5Px WLtRLH0d0FrXqkwop/rrGw5x7f4gim49cJpMabNzkvTl/egJocuTg5kQubk8OxlZVFQGXE2W 8wDn9L1nthrwI51nmK5Ar1r90LO0vvnr8Onl7nBcfD5cP78cD0+2uVtMBOopRt3UNXibuq2a krUJA2859RS2xdqyygDQ2NGbqmR1a4qkzYtGryaeMKzp9OxjQGEYJ4SmSyWbmjB2zZbcCS0n tgf8gHQZ/AzcFde2hv8RR7NYdyOEI7ZbJQxPWLqeQOwmj605E6r1IaOTkoMiZ1W2FZlZRaUN lATpG5HtbtBaZHoyE5VZj3YczjXnoNquuIq7TQ5l1Sw5HNFrKBnfiHTG93IYoBFmFFI/aa7y yaSTetpmjTrRAjJdDyBmiNeObin4CKAMx7YG2ZOqPtSllaYbg15ppeP+ofI6wz57vytuAlpw Tum6lsCoaMrAA4oZJSeIGNX03DX0B9cAuCLjYIDAgfLPfGQL1NwRusiwcDDWSVGECe1vVgJh 56sQr15lQbgEDUGUBC1+cAQNNCaycBn89iKgREo0pfh3nGPSVtZwMOKKo/dnOUOqErRJbPdC bA1/eGGGF16432BKUl5bh9Oq7yBwq1Ndr2HcghkcmKgAy47DRJ1BisyphMhIILuQgUGGSjSm E2/PnfGkOV+BLigmMdDgDXl6P/zdVqWgITKRF17ksPmKEp5dLgP3Om+8WTWG74KfIAeEfC29 xYllxYo88yVO0QbrnNIGvfL0LhOEm4RsG+UblWwjNO/3TwdHaQ0GnoSNVvOs3fpaPmFKCXpO aySyL/W0pfWOZ2i1m4QiaMSGe2xe522hy5hgAmRy3qNx7ENrRPtdmJAmNMFUtmyvwQWfoY44 PRlJgjOyE8HIaG3H/YDpVWnAJhBreYEWIPMsi9ohJ0UwVBtGL7YRZtFuShsV9p5Hl/erD8fP j8f764ebw4L/9/AALiMD5yNFpxFc/tFDjBK3liE2xODC/OAwPcFN6cbofQhft8uyZnBKah3T 6QXzMgm6aJIZNNh2BW5Kd1xEDBCG5rkQEEEq0AaypELS5Dl4cdbFiQTYwF+Gl9YiYsZS5CK1 EbYf8MhcFCBNsTAB9aK1XF7o5WcJe+SL84TGwTub1fV+U+vj8piofDOeQrxPZi0bUzemtere XL453H2+OH/77ePF24tzmgtcg0Xs3UCyZAMemHPHJ7CybAKGL9HzVBXYN+FC48uzj68hsB1m OKMIPSf0hGboeGhA7vQiDMKFZm1GbWsP8DQ4aRwUT2uPyrMMbnCI6Tqb1uZZOiUCSkgkChMV NgCMaAWMS3GYXQzGwHfBJDcP7O6AAQwG02rrJTAbzRXgnDQ3zvFzsS/ET9SXAp+oB1lVA6QU plJWDc2ze3hWGKJobj4i4apyiSawplokRThl3eiaw1nNgK1+tlvHit4vHlGuJOwDnN974i7Z BKHtPBfFdFoLpt6rq8HEaFaBoLNMbluZ57BdlyffPn2Gfzcnw7840cZmGAk35OA7cKaKfYpZ Nmpf66WLBwtQdWA/z4MQDObAnWjhCfLUaRmrtOvj483h6enxuHj+/tWF+SRuDDbF04ZlHVE5 qDZyzkyjuPPdaRcE7s5YLdKZnmVt04G0z1IWWS50LNeruAFHxbthQSKO18FFVEU4ON8ZYAxk ts5PivquiImCWLRFrfUsCitHOpHgaXB2dN6WCfGu+pYhCBq31AYRsgRmy8G5HxRCzDrvQV7A aQJnedl4ty+wgwxzUZ6R6NrckDObv9qgIikwBAZr0/HIuOJoKmsN1jUY3+VX6waThcB8hemc yXEym9hhDlOcZsZCjD7dMVD8nYliJdFdsHOJUGepqoaJDv3K9cfo6Za1TuMA9KbiNzpg62TM Txx0dN34bGpPtgLT2Slgl+i5oCjF6TzM6DRg+7LepatlYLMxJ7zxW8C6ibIprZzkrBTF/vLi nCJYJoEIq9TEqgvQiFayWy8WQ/xNuZvIfK9/YAzQZ06cps0gQtPG1X5J3d2+OQUfjjVqCrha Mbmjtxermjs2IsiZjaVGrcKAj4QEjyJyZJU1RBrdNTBFCV8C8dM4EO9yJqDeCwwBYwPMukBz 7V892CPHS9IWVWTALTLSqLgCZ8uFzN0dr43L8bIpVH2lr52c7icu9P3jw+3z49HLeBMHvVOI TWXjift5DMVqehM4gaeYt56hYDWq3HJFvdWZSdJ9OL2YuK5c12AtQ2Hor2nAGWmK3pX2drku 8D+cRtDio6dsSpEqiS7vnA0Dqbn3995qw1k78sEa7RlqmVCgittlgr6FDkS7Zq4sQRuRegeO Gwn+AbBnqvbR2xDnaVhr6xBZxI8awJO4xsF5gXPrrmTx1i8MhTET3q6RZVytx7inRcGXwOid gcObtoajY3S4/nRyMnWMcLk1zgS7pfvO3PrbQeAje9l9wgQeuOxSYzSsmjqMoRAJBQctTNmv Z0R1BGYOyF18Yr5+S9RoaZRnPfE3emHCiKuoPbcLYOEOg0nT4Nuh2DE/CW3BYTyJRHRJc+DY 0pSiDlfrZLFbaecT4krXfD/v8LhORu/sWaM3+8OoMd8hgtdVhYzpiVzEAm6eYhhGEVdX7enJ SXQ6ADr7MAt67/fyyJ0Qk3J1eUrY0TlqK4VXgnQaa77jcc/BQjCQiqY/FdOrNmtocU692muB tgAkXGHMcNpJBE0ZY8IABTfmT/X9ITZcVtD/zBOoTo4Cheh53iHKTlbFPrq4EDO8uB3TLWVm 40wQtpjCAx4Q+b4tMjNNrdlgs4AoucZrJ89AvBLBTEJZlmVtoEotzCnAXiJWoAuKJrz16nB0 XYCDXqOtMp0nGsHCwNKGsqVYqt7UOKv7+M/huACDdv3lcH94eLYzZmktFo9fsVSOxF1dJEvS I11o2934eCIwBsYxdihbXXDuCQ20ocDZ9vjNcAnB8prbiogoTcKuZXing9SzDSb8swjIDhpp D1L5fUurTOq1poUneNs/nOMAGiMXqeBjBnbW9vVRNu48OcLJr567raBp0PNyTW8PXYZGLFem S1Zjl5pmaWxLl8pzk7QukCYJrtFwI67dlWXUTDhadarcdMKZ1tQNcrjhobv5gV3OtZvN3CiK b1q54UqJjNNUik8JlFqkQIdisHArEmbA5O/D1sYY6o7Zxg2MLUdjbttyVk1mYVjcvXLbKaPG 28JsDKQ4cI/WwdhdCQa41p3LOgcW2eQgBmB05103tlwq4CwIs+cmZ1bgh7LQp7JazC0a9UxT g3rJwgmEsAiDzW9YnSLfyHi1iNs2CbEYKPLZqXcKFHzpLmrx++sk7mW4vjNXpG7kRkOcDXra rOQraPDXfM2f5cqaEzn327uLN58iAqLjZbXJp5JEdKjAy0046kAxT3YU/o5KkfNth4B2zBb5 zlFfz7TIj4f/ezk83HxfPN1c33kBXc/ufhBtBQB5PNLcX0At5Ybe4dJ5xHFxQzRsa9wPiHXB ey171f/jXWSVcZhPnBGiPQDWFSpuop5Y3+dH1ju7zhjisLpZUj+2mNcWMbDA55AFFp+Ot/91 l28RP722Cm7Wma9Tm77C4eeToZ02fRUJfBeegR10yRwlqngpsx3z3KX5Sl/K7fyf/ro+Hj4R b4mWrEXYf9gW8enu4AuDr7v7FrvJBbiKvsB54JJXzexJDViGx5foIfVJ0qjCcqA+oUr93mFF pOzFHue0TLP3lP/V87Rblbw89Q2LX8AYLA7PN+9+JWkhsA8uL0FcMmgrS/djbHUtmGU8PSF3 J90VGWa0iN0Ch7oiFzGWYfY692rxZqbmpn37cH38vuD3L3fXI2f0Q2L6csj6zGjZHb30cTd9 4W+ba2suzl1YBUxA7y67cvih5zjtydTs3PLb4/0/wMuLbJDOPvDNaHEFxCwQbNN7IFVumbLh igv3R2tUChG7zYd2V6TipUQhkGVVW7J0hVEZhG0YccNxuVsAMuC2TfNlSIC29qHdCF1KuSz4 MFf/TseCdBm3qB0Y00Y2nTkJcUNMrPQDlSjhT5tDtQ57ZBNwcf39WR+NmcOX4/Xic38STk9S nTKD0IMnZ+j5FOtNSReO1xcNcM7VHBeib7fZfTill48arw9P20qEbWcfLsJWU7NGD8Xf/UX/ 9fHmr9vnww3GxG8/Hb7C1FH6J+Gmy0P4FSN2GdJVGZDmvgV9pTDXvh7uLccbmqbElHcSzXPK 2oQ3nZOrTzuNMbhrKit/WHKXoj89zZvZN0VGVG3iV4Wu8dYwRlzAsvGWP3LHvY52mKUUWQ8l g++w8ljJWt5ULgsHQRfGFdXvLisXoHllYWOBlKW4gug0AKKiRX9dLBvZRN4gaDgZa4rc64xI tAEqz2Bepqs0nCJo3meBZ4BdFttLTZKZuwdtrqSk3a6EseUyAS28ttdttq8YetS2pt31CEnq EhNJ3UOz8AzADwcRqzJ3G95xj2+IHJ6mXrJ/PPhcbrbjatsmsBxXMBrASrEDjh3B2k4nQLIV qsBajapAI8PGe6VtYVVWhBvwuRG6TrbM1l32B4W5I5HI+H3pleq2yE9Ljqc2ivTrUFpXN7gF TQuR74p3aQybzoqCsSQ/htJxl5MGVzDf3X8Gk+la3b3aDCyTjZdLGVfRZZq7Ahhi6WfaSU/c uwIOOgBOijB61dsVanhgm0glo870DTqBVMgq3AcnQsKAoe/O1VYYhIePioLvjFUmazGhMvPG JdSk0fctniBIZDR6+evpsQpvnlDN90nUH8Vr6yZKE+FYShjm7WwpkAViOhdM6sTyucOUudVh Zj9ZR9ZflfEUy/MIE8uswXwhmiIs10UpiGhHC7LXOF7p1Ti2V8EW2sOdMHG17fcai+IidElF 2xwRihIh1YEtOlbSTpmq3vdK3kyqex03dk/tptYO9k24tPtQGegHEkkTqOFuOu/PEuHKAGLb iszgSI7QWNtoxiBeBevUPbNV2x2Vv1lQ2N1xRbR7DDTOt4Z9gAimu/PxDdvg8oANjvkwaAxo DWzYtSsb7m+LB+8xlZu3f14/Qaj9tyu5/Xp8/HzrZ5QQqVt5hKqF9p4i88uAQlg0Yn1tDt4m 4bcAMOMoqmip6794wD0p0G4lVsNTFra14RrLkMevBXTCTZfTHZ996Qo7zmJBWIfTVAgPVUXX dQBSyr0zE688ct21SofH9eFuBpgzbzY6MMqP4jqWiuwwsMZxC96M1mgAhic6rSjtlQpx4ytg S1Cs+zKRVPB75WjAqE9uVBL/Ug1fwIBBsXWVgTgjSKca7yr+8IvQxndeIFB+arN/UZPoZbTR PR8P2jGxslSCGoAJqDWnJ/TcegQsnown9XoM0I3SmJkibruU7t7UFmSocJBtEk/Vk00QEm93 q2hU7KGl0i+Rc1PE4tbwCTY9A6xarFmc6RDBfQijVzBB6OsuRa+Pz7cojAvz/SstPYUlG+Hc 7u42kegZCFWrEWMW0KZNySo2D+dcy9082FXXzABZlr8CtflhcMzmMZTQqaCDi523pGEjsWx0 AMRyB6VYsnhXZpgS8c6kgDH9NwydSf3qFIqsjE8AAfO3Tno5M7lejRT2EwSRg9ZN9PzXTJUz W4E5oNeXiWm8i4+vTojIIxmhz7IGrOzptUlaEcWj/APzp5M29Lbpuylstnfu7gsVcnzMS+QF +gnp6lMycLi6nNx4hiN4vU+iF3g9PMlJBAw/2l5HTF69IpA+7Iyacn++Y86qOqX2otMUuoY4 BU3hxBcb7+2NxESAKreXU0/IfkYks2Rs9cI8itrGENB5wXQoXoAXrK7RzrEsQ7PY9rc4Exev f27VJjzH/2EQ7X8Lg+C6SpmtAuI0ghwLO+wh82+Hm5fn6z/vDvYLTAtbCflMjjsRVV4aDCNG GvDDz+HZSWEcP1yFYdjRP0v/HtDSqRK1bwQcAAx+rHAfqXdJguGw5+ZtF1Ue7h+P3xfleA8x LXx5rbRwrEsErd6wGCSM0/pCN/z6iolRgqAXXGceA21cln1SIznBCPNF+NGQZeO/VcRpCC2L yTsuv/IoVvXmyo6M0yJYTnwe0E3QR/Kpdk1O66Rz2mwAjlO10bTiKGpe+E6rmYbumFxsg4cv WH9mRaY14dOyBIIQKkGu7F9iJEfnvo6+u+w52B6J+xhKpi7PT367GHvGUgNzdUAurWhWdfD1 AO9N0trL4qcFZ64gM0I0V7AdPqk0eLQPpmnuHcYAoz4FNuLDKn35PyOVKxwjQuGqlrIYS2au EpoRuXqfyyKj5clX2j2wfOXlgr0x6dPjdCE2a2wZpU8XzW0yqrzaPk/zkzDulcsmyGfBrtva /u4DJ2PEiB8TAB9yVbLoe01vKJuRobqh7NS4zeOA8ivq4Is082pp5AlDGQS/p7VU3u2DXifu kVGfe7YKrzo8//N4/Bvv4eml9SBq6ZpHv7BWUb8Qf4Fu9jjRtmWCxd0qU0TLSXJa3I6/8HLR j0htKyuWXjGubUSbFr+0R6gt5s5Z9CGURdBN0uKbrXQfDOb0Cp+MN9a3z5Fkq4AUBKOk/ttO q7b1wvf06NZ8T+Wga+rnERssq+13KrjPlKR5chK9nDi+GeWmdh8XwI89xdDrsXDSvu+gr3Aw 55yAvAk+lY+ebl10Hw6MR2yA5p6NOGQ286GSAQ1coETq6Nu2uq2r2psd/G6zVVoH8/p/zp6s uXEj57+i2oetpGqzkShLlr+qeaBISuqYl0lKpueF5fEoG1d8TNmeJPvvF0DzaDTRUup7mMQC 0Af7QANoAI1g8rB3NYUEhV9IHI02Wq5ye7pUvkWxJkr2tbNUU+1TZprCMdKfBUsi4YclCHAA za6VY+B0lYdK8klH3D4ct4fwTbYfAYa+mZkgEQnr+ZkB2HruIP2eNQalw8EuDKSBVPoD+F4g IO2Stusc038Pb8XNc4IcBYJtv4SFfvQ0wX5tmsy7o73Df/rHw/cvjw//4LUn4cIyYPVTe1jy ZXdYthsIJT85WIGIdO4R5DJNKBru8JuXmtOwcaA4I7lewurBdjecqHzp+JJGmfcFujphMpBS XpGEKk25q4M0S5ZJBqFpCLJ9g9GI1V0eWcjxHgIgW9QdxNXDE2yJkdFsWdUmJrPqq7CIcpWU IId7o5bLaLts4lvdL/dEEBnIFXLwhl5JeSxWNOxr6zI0yasgt352i3QohJlf8T4RZRrOJfIq x2y1Zak2d+MiIF+TNRROgSRnIjpQ9PeSJu9qo/iljanFkde3I4oqoLB9HN9c6XuHikbCz4DC wVA8wr9D6YhTkNXyEwUx+xlj95juJk1JzJTGfkPp0sYcvUVArSB5ygXb5cQba339cdfJJ0FP cqLqCnOo4e3oswnrMpkxoP5cE0DZeFmnOl7s6FDVZOtfLC5nIG/2WeXzNooI/Uvs3pF1isFA ot5xCImQVue0DORoHf1h6jsmgLUTXvfjT2uwJpvB++Th9fnL48vx6+T5FQ1G79L6q9GhBDaN VfTj/u0/xw9XicovtpE94AJBujlL0m3ak0Sw55Ny9HnP9x8Pv534KsyEi3otMeNnaRf3ZFqa Fi1uJze0IRCVETsktDuPX3/yFksLCmo8qt0qH9H3mMSM9+BIO9ilxeL6ahyJlDmJQ+/jRDxn zBgndN7Aoqj+7G7fdT4MVBaNQJFi2grdktgR3QUZcaoQfbiroEKtbISlrETlSDs5lKPDQeX/ 9zfOhg3KcIVPJ+aFxVM1gyCMgxMTk9BF/yuyY3dRTcAPFejMPu+q4weCTYgwocuaQ47aNYcK qFQuKVud1fvEuLUD+8fy1NDKQyhJjWwIl44TzVm0HSu73DAEjnLt0JnJofKlOSzmoiOE5ltY RlugRwSt9MK24VJ/BPFU3Sdxl7UNpNs4EsoX/q1jkk7NQW+2zG13rw7S7JMd25ZhQJIfTR/+ PQkCFb67tk1boEEiz46JNJFzB9hVptoUQcPusxlmyD/TjoOzq8OHtMnXdvcPv2s/EHMzUNXu GyCpApMhBZWZbB5+NeF6i2JNkDIOpVGtsqgVdpLdUTWUDOcucnSr/lv1OuOZqcTf7MGplotQ 0okqTLb/bP5qkgg0bzQ0DANFcLpXZ9Y6AjsMUn6VGEGVFUbTqnwMwbTeKuCB9oiLfTEvN6LW hbdcXfCqNAxm2N4+sVcZreKv3vbNoYc5L8QEEAJElSGilma1W+T1/a+kYGakdaFC8WpAu5ai oaNktvsWJJQ4wKg0q6k3uxlaG2DN9mAeOQYi0YghgCMKUlGOjmMWRwk/PXES/NjQu9C7xM9B bSaw8eVxlcuyTJDlsn4ehjlnqQBAjw7xFqL2Fqw1P5cyJ+a7zDKNLuPsNvfFpOlRFOGILZhw MECbNG7/oIyuCkNzHB4pRiGn1gK7dNwazv4obfMwc4H0jWGKXt5lhi+fsKUHW8MnpxYxIiJK D+WtqsyMc4fO+mzUcjhjeu7xcZblFNMzLE7yLjBrlRGdWs3VENLSHY0mecytAgRptqXhy0AQ tOyg6cKomuAgOpwwszRpyQxxu1K+kaDZojG0NHRGEc9hrks8xF1UN0XlbiAN7Oz53T7S/hBk yClUJnyKQaHNPCEftKLGG9G7hifjXd/ETACRssuWVRH5SestNhLl29uoycfxnT9wQH29rrTJ grO8IssbWATKilbvj/ZRnRbCvPoaeGxS+CE5uLQuYA+/Hz8mxf3Xx1d08/x4fXh9MnRkH5mK eRTB7yb0Ex+zrIoBuND1ImOWisK6yKCG/frf3mLy0n7C1+Mfjw9HI2C2W5nXqmTXLctctkat 85sIgxeMafLvYBM1GFOxCWsRviO4wR0IAzMoNHDn629qh/hk940FKbLVtaEyrjERbhSaHYdV uMH9zzhXB2yqSvQnhGrSKLeKIKhJgla4lz0FWyr0Xs4EwoFsp8Kc9XtXsk6bbhr0M2QzB6Ck 3GCgg6sf7pwWa1SY4w1/8coANlEQ7qzGelzpuAwAmi6B3kh81rGtT9+PH6+vH785lycOQqDW VYk7ig89wPe+mONcIw/wj41mUhxiqw4ENVi3XEtSXfcNdzGvri73+xkUsrowRdwOMrrKGRAU Ewenmeie3JONMmsW9bV4sQMlrgMzI7PJOQ0/BbVuij27drhVRRRHnCMEmy0KDbOxab1DvByP X98nH6+TL0cYJzQGfkXfqEkrbswMdtNC8Jq3syzVOkHvdOhDYmb0pZ+tty7llPu0MkZgc63E EHPk71fcGA+/R86HLdjSNANfbcyVgr9POHoSemwy5/h9KclRQZTvSJc1W2theL0HvMjpVNOR odsfk8eYmUmy2+WlDxJJxIdBbQxAdyXEZPMWhoexJBJiamN0HxpqAVEAuslS3298FWcH0zwC p0qVZfH4dkUHAw3CgFbX9a4bhZZrYlUat4vjX6Ch4KiqxHqbiHAY649/iFOoS+s4ZzhuM4nt EE0qhJ8xL1j7R/tKGdtxACYfNRCUpNkDrF+yNFUtxMhoyOoi3OncJZwM/VH/FrH8/gUjbPJK 8nij1AqlNRaul9sQd7NXxbU9TE6XM8QVOm11l7vMTsNHCYGqvfx6DCJJ5hST4yOWvVOFAHRh RN7ZZr3hSEX5ann1hXTBTRific1UeXsLO+gHbS4iTBdhM2aEPby+fLy9PuGbSEKWlEMyvikN j++P/3m5xah/rIDuWcrv3769vn2wLBnAbW752gMAvbY4hmImaRk6LtDAzuE+56d6pH1uX7/A pz0+Ifpo93hwgXNT6TG5/3rEPKyEHsYNn3Eb1XWetneYlyehn6Do5eu318eXD+Y0hzwoDSmM WtRIWMG+qvc/Hz8efjsz5bTcb1vdsbITOhr1u2szKwv8QhI9Cj9XoXnCtoCGXDHwah+0409z M+FjS9DuUtAPq5ou1STe19cG+lGUbq0wgB7rYApDU/sEI+CUIaV1OPTDTMfdpxiwJoAjvrv1 LO6/PX5F9389XCPRtStZlWpxWQsN5WVT10yNM0osVyf6j0VBn/XGlRY1YeamyOro6JBL4/Gh PU8nme2xvtcBltqvdBgVBsYMrzv2/uqhSvINY9UdDNTtfSodniAPpqEfZ3xCQQKihvrUMPSk 7ohz9dlKnl5he74N3d/cUtAiE3o7EPn4hvganSEk1FXhD8ldhm8aSlEOAXs8RLSZcab/ooHy REAipqBpJalxRpb2G3vxWL/LczADFjo1gAIaZZwFNSYK5eywUAeHOtsSRIfC4U+oCUgx1NXA OYyR8bJjHZL5FGPSElM2EWFMjIzzdJI73qlF9GEf4zMYaxWrSpnSWBFtmaO2/t0oz+QDGlaa sdc9LFEjwtvZCJQkjAG2jZgv1XYVBsF6KI08jYL1aVFuuCCPyE0EcpbOiCIyb8dm7rNfaY2V HQrJDnNUype8ZhHTkg46QCDnd9ympWFxTSozGrgKabJ7p5Ehnuzb/ds7t0lVmH/gkuLQSl6F GaLGTMaIhJGjzEqElI+3UaPUlz38CVIC+eTQc0vV2/3Lu05qNYnv/zvq3Tq+hh1g9U1H+D6P QKAvGJzCfGYgHf1qCkO0UoQfVtcmbIsPN3XlJpQvPMoEaSUzNnQry/LR4NmBFwzZRwTC2tR2 5REPLvzk5yJLft483b+D8PDb4zfB2IgzuGFZKBH0SxRGgWvfIwFs7v5dalYSKsO7BnJ1zcSX EZFKZ3BIrxt6v7KZ8WmzsN5J7IW1HKF9NRNgngDDLHaYLv7ZxvgJ6M7hGA5noj+G7isV89ph 6C1AlvBy/poixEyhwD1dWrK+//bNyLBI5hyiun/AtNTWnGZoTqi7YJTSniaMmkpOLK9yHTTb WvJ3p9Jkx2MFdEbAA6aSkfgQlQIdQw/MoAec+Sb90Ozx6defUPa9J089qMptO8dmkmCxmI0+ mKD4DNZG1e5dpalc0iqS4CNpm9jnV0MMoV941Q+pyXnMObkrWoEWe7DLvfm1t1i6p6qsvIWL r5Rx4VsrL9+NVif8s8nwgYIqqzAvPJoCKe6NY+E8L9uXvGbeiveJuKyHMzVSaR/ff/8pe/kp wFl2mY5ofLJgOzesxZT/JQXZJPk0uxhDq08Xw7I6v2LMllKfUs8UI14GzDV15UnVu/y2sQnM scf8wD5lVadPj/MwLCb/1P/3QLFLJs86FExcx0TG5+kGzp/M4Lvt556veNQtnjHaAJPt8oI8 xUGikPg3EurdjhLZswhuOYSM6p4OtTjIfi0ZXxBDb1Bh0KZRIpMMnnaO9JwyDXBHzQ7wbAEa uiAY9JweCsrHRk6uatCQdU6dJvPr1erySt7IHQ3sJMn1kEU/UegTifQJKCvtGwPdG2v2ZSYQ 81TzbS4QdnPUpgdJ93GMP6Srl5ZkYxyKQWhdesJHqFDWKrryaG8qS+Q4Kp974gHTke51ePWo CvQwOFEsLNaGkIu/Gu1oJaQ57D/cLNIBy2vjW3tgvRpTMn5qALUPvvF0o4kb2OogyOOA4s14 EB7ES6TKp0QBrRfSYDrUjhTWzI0GDobixLgVJZk+9M39IYnGhkaEWkk7+wE8mCHtRNgH/bHL D8TsbhMxPJyQG39dsDQoGhpYABbxoiHks2k4yQ9AWjIyZhO44O4y2LYht7HB0pLa4/uDodp1 XDBKS+Co6As9jw9Tz1hdfrjwFnUT5lklArk+bCIYCw73SXJHaq3pP7VOMFWl6BXlp5Upl1Zq kzT83S0CXdb1jFUZlFdzr7yYzoRaQSOOsxJvmDF1uApMx9wdKN2x+c5CHpZXq6nnx6b3bhl7 V9Pp3IZ4U7MP3WhWgFsspLd1Oor1bnZ5KZal5q+mEhPaJcFyvjDMeWE5W66M33CIVfBxDahJ 8+56YTjwOjG3G2nDiEw6t+TJho/r1k0ZbiJ+EB1yP1ViPgyPn2z6N6wCaN0vGm+2mHYHQxSB 0JAY1vNusggOjMUzfCkH4MKww2lg/+zVcA+nEYlfL1eXC5EBtSRX86CWnLt7dF1fLEfdACWv WV3t8qishWajaDadWk7zXWoQ/s39KK0vZ1OLjWmYfeU8AGEDlfskr8xY++r41/37RL28f7x9 f6ZXodt08R9oqcAmJ08gfU6+AjN4/IZ/mlaeCnVJsdv/j3olDtOyDO13hM7m95NNvvWN/NKv f76g4bKNfJr8gOnsH9+O0LYX/Gj21Uf/GHoBLpfUjO6JL2ZE6IHw71SZpqqZ2H3QRuVDItyh qZeP49Mkgb3wz8nb8en+AwZltKLbmunFYzNfQqA2dt6PQ5aPLW0GvTg9pzoxFN9G6e2N9OFR sGNeM5jqBgY4wNS5gezgRyQFPl1mUXSsyl/7qd/4bPz3mDdY/AB2OA11YDpVM4OQ/qGlyqfj /fsRagFN7fWBFiXZ4X5+/HrEf/9+e/8gzf2349O3nx9ffn2dvL5MUBIk9cM4AvGFn3oDAgzP VoTgilwASg4EgSdXkgyIyBKwststILenE+EBSXBKGAI8NM1COwwUvWQgLGr8DEwXrbKAGwXp ZSN8onAjBDzBOKHJAwDdQvr5y/f//Pr4lz1yrUFdGg/pmWGLJEjC5cVU+iKNgQNqN4rXlb4e NIrTI0dWc3pGoL8ONT7yfbxnzcoDZQ0c3b4HCrOvZkXo8uhra8g2m3UmX4N2JMMo2mWBvy89 4+6gl4w/8zf6rE+1utxh/ShYWgrOmCZWs0U9P9FbPwkvL+p63Cm/UqrOx52iyazH8KpQmzgS Ktrl1Xy5HBf4hd4fFZSlXCmhflWtZpfeuHqAe7O5Ay7Uk5ary4vZYlwgDwNvCgPaYGIhaQt0 +DS6PTGg5eH2uhzXXiqVsPzPA6JcLGZzqcUyDq6m0VJW6IdxT0B2PdGhg/JXXlDX0pwFq2Uw nc5cS6/bYZiatDNwjTYX5S0FfmteoKsQ1k9VGOOAVOZpCWV0AyZk8AczzslSOVkb9avtkH4z 8QeQWn7/1+Tj/tvxX5Mg/AkEtB/HfKBk2UaCXaGhomNpV8RwX+sLmMJcBwt2o+73GotDEiiV tjFiAi9Jz0CCONtuWXIEgtKrJ3SXyqaq6iS5d2ua0DymJ4bXswl6MO+Xov8SztWzEp/6EOpE eKzW8D+mGg1F5MO1J0BnIaefsaYq8nHXBhutNRJW4Ti7HT1XzCnCnbteazMYBhRjFNCcYrk8 IWiQRAYJGMBtdiL9ZobDOEOZlY3bfgC1xreh6wj8nGehdEYRMk/6kM7A8Gb68/HjN6B/+QmO 1skLCGB/HCePIIy+/Xr/YDw2RVX4O9OlkUBJtsb81zH5E1JerOmoiGmaNXEK9M8ZHGaj7/DR 5YiKytOENKWKPTmqmbCOt30TMZ+Ptr+0FopBlwpAS6QbB9mhAdCY+1t0KUdkTszv2QShz4jH AsvasKa2D5L0R4vStkJt9iWzOOrf3GzTwkwbV0fmlyMYeWdvrTuXFheI98stcmBRWu6Momgy m19dTH7YgNp3C/9+ZO51XWlVROiDLo5th2zSrJRzQ5xsputh4gegt2X4NjG5nJjX+H6Az2kl GUzJujJznJB3N9mXmNO0fZGzztLQyhg4uHCgwUzE4Edt95YkORgfbuhxJYcwSpm3ZB8AynQV +Ym85v0A4zVlnSZ3og61C4OirsPLZw1a9j6UmffWdR/pB6Xj1Wn4rkA/jCWiC/RTkGNgqr3c d4A3B5rPIivhpJIrPkSOpHKtSdyZVydOXI9kFo6wWIwwHlanwcSSE8sIsVaONIaDmfNl3onY KHXjcOfpIBInyWe/ciOBpeOD3068CqvLS2/hOQn8ZO2XpR/agXoGyS4r1GfXOGMbsohBnwe7 2JtO5Vmnut0oWIaZbNXRUSN6EqWb6Y+3xy/f0aLTOmb6xmsOzIG384b+m0V66w+G642Sex6i FEaxmQcZMxpH8Vxe2llRRbJeWd3lu0y+Wxna8UM/14nih1HTIHoCfmPxeqGCbcRZbFTN5jNX bsSuUOwH6BZhyd8gicghVqxoFVlp5oPIMonbxspKzCNpVpr4n62E7anfT9C5skwDhZ+r2WzW uHhRjhxl7thJSdjUW9HNymwQzpu0UixDgH/jyLJslisCcanRm1eZxcdi116PZ06EaxPGM9fs nFsme5Cu+XcSpEnXq9VU0qONwusi80NrF60vZOFzHWDKNMfxsE5reTAC17Kr1DZL5f2Klcnb Vb/Vjpc2roJnFiJ8cGC9u71OpaQRRhksYD00DAe7FFLDCh3Uno1rtdun6DMNA9LksgxvkhzO k6y3DqZm0BQOmljd7FXo8L/okFYnhK/cRXGpWERSC2oqeQ/0aHnqe7S8Bgf02Z6pouCXF0G5 uvrrzH4IQCfJOItT0kWiWYTysPM04nUTBb68RMOzvDLkJ41O9RorV/7drpRtZwpjT9buSlgc drDbuD58kDfige+Rd7bv0edgp3KRg+oHYc0Kt67MAF2R3d6/5ZdkO3V2PtTKW5imQROFN11s dmcig4xa6zWjc0hWaivH3gHcsYNV7SpiH2sc46ruwtUzQLjKOEIdN8lsKi8atZW5+C/iZaUx 5olfHCL+vFhySFyMp7zeOmyK13dSTh2zIWjFTzO2ZJO4voAtLOtmcb0g1deFLW9PojeSzdzs jwoKvtquy9XqQj4lEbWQGaZGQYuyYe+6/Ay1um46rf5k7e402FvgrX5ZTsWqAVl7F4CV0TDa lxfzM9IJtVpG5kuoJvau4I708Hs2dSyBTeTH6ZnmUr9qGxv4pwbJSm25mq+8M2cC/ImOijwf uedYwIdaTFrFqyuyNEsYK0w3Z9h7yr9JgQgcYTY90CwwnVJjC2bjGlbzqyk/V7zr86smPYAc wA43stiGluQ+Lphdsx4DvfiShVFCP7bQRkSyk3vn0zvo4oDfRRggtlFn5Po8Skt8y5NdlWZn D5ObONvy++Ob2J/XjkvKm9gp7UKddZQ2LvSNmI3d7MgeXR4SJlDeYB6ayJX5tEjOLokiZJ9W LKcXZ/YCRqNXEZMzfIftazWbXznsOIiqMnkDFavZ8upcJ2B9+KXIUQrMjFWIqNJPQPRhORNK PFdtLVQoGZkvTpuILAb1H/6xzVw6TJkAx3DK4JwOWqrY59wmuPKmc8l1kJXil12qvHIwbkDN xAtWs7akZGsjylUwc9UHtFezmUNjQ+TFOR5bZgEaPGvZzlNWdIywz6sSsnOfnbp9yjlJnt8l kSP7HC6PSDYABpgFzGFcTNX+TCfu0iwH1ZWJ57dBU8dbOSexUbaKdvuKsVINOVOKl1AYbX1L ielLxwVhFYtJqIw6D/wcgJ9NAfK4w8ys8P4vhmn9H2NX0uQ2rqT/io8zB09zXw59oEBKRRdJ sQhKYtWFUd32vHaMt7DdM+5/P0gAJLEkqOcIO6z8PmLfkchEDVEpwd7qF8PSoJDMt9jV4FZC eO98Q6iIqoFLpdFiqt1Dp+Q0DStrF+dYlnhrYCus3tFOwOrdAbYS+JpSvPq/uhbnrPaaGt85 iLUmLBXzPG7xM+K+cRjy7nvHjbTxAT/Gffj64+fbHx/ff3gDtoAWTQVgffjwXlpMAmSxOle8 f/0GdnstJYtbo1oogF/baWsrphgM05Xj2c8dk0YMjV1LHD3QVnUOoULK+RiCLqcFCLRsNR3Q QGvDEAroiuLVM9S0jbEnLmqg2zYLA8E0rbNM1Y0BAg+FbtFIw9blAAaq+jEqoOoPqPLRwX95 LtXZXoX4KW/Vdatiz+1jW0xv4M7004cfP94cvn99ff/H65f3yuMCod7NLXxpjfjn1zegsClC AAC5vrgbvDJI3bGVil2NKeixeKwaxznBxirGLBmOQYiPKAqxZazoXXSXR0gQB3dZRXlMA8dW Vg2syAL/ftLIEHgOvdSN9XCjNT41X9sJbgvwUfryrh7pZXa7jYIn8I6A+a20NPWFJ4+Wjlc5 yjLm2s79odGWzIvMYVGw/vLt759O7bS66y+qpwH4KcwoftZlxyN4n2w0PzACAbOl4kGbJhZe Mx816xICaQvw8iuR1drAJ2j4q0LNDyOJM1dAELZmUDlYcLtMVlQLStmUxnZM0+++F0T7nOff 00RR7RCkd+dn3P2LgKur8aRvEbtrxPX2Vnz5WD1zRVrtxEfKWIfBVxEKoY/jLPt3SNjuaKOM jwc8CU+j78V4Z9Q46V1O4DsOjFZOKW0QD0mGv29Zmc3j4wHXGFkpp95x1qIxeKN2qGKvxJEU SeTj6qcqKYv8O1UhesSdvLVZGODjksYJ73DYlJOGcX6HRPAhbiP0gx84jhgXTlfdRof2wcoB A9hwLnonOrnbvkMaz7fiVuCaIBvr0t1tJGMbzOP5Qh6YZJ85jXcDgyPL2aG3o4xAOzgbfMBn neMsnVO4Cw78jkgSIDtihHOOYvDSxRxBs6xvM2+az51wpKmBRZn6kTXoCqn+ZlJDNEtCAjm0 BTyX+2yNoOHkzYfLOKLHHHICIrR/HOxvW+KHaRbO/W24EwLb/WcRFn3RF7h5cgHzoeJQVb1u mUgBy4qcS9z7+ka61gf9zl1GznbRdD6MHd45FlLNrUmNlWMBtUwnbD7uJNOZmsdpfJfbpcAN YLaGt1SD81zxlf0Og7S+h802AgV1v6YY4Z6u6Ef9lHRhjJd/oy4vYknz2Wwjx9hLQtYY2guC ZXEa2fnmlTOcx2J4huuL3Yosi5yFv3YTI6QbG5h96EQ7jdheKBXl1IRY/+Ji2cHM9iBB6jg2 EKz6iQZJjmkqLHVVhMatpQZA3M6P4YVWX4DtE/a/QzGY5V0O1yBhQ4qoaGulyeEkVmAjDYKQ LgQkHUNbR5aaMhca6dZBV5kJsMV0NDh09BS/JYsEnl/XyltrLg9K+UjU5Pu+JQlMSehZEs1r hZChm3sJxcuC++H1+3v+CrX+7fzGfAnB070p0ds2PQwG/znXmRdpbjmFmP1rKthoOBmzgKS+ p6i8cznbPcDa87MZXk/qnmKXtwJu6gOD7WQYHqE0TKqswXdmImgAZhRMMSsSjC0Wjqr8YrSB U9FW+pvxRTJ3lC3GNX2GBWmwCl3Rqr343qOPhHhk87avGkrAKn17VovsEoUa+l+v31//hFM3 y6LCOCr+Sq/qS3ihiwyG+TrKRnX5bntlLgRMxoYNNqFuyMMNZW/i+VBzDfMNBm/peTb347MS q3g57xRKWyGKK8SG22cFw4rSZ7o0hvX94+sn22IQ1HTRzFUxNM9EfXEggSyIPbNZSjFbJPQD qPhU5Y7ZNvUDYY4GDctP4tgr5mvBRJ1p8w/hH+EAEbM4o5KsCtBS3xauxOCnpSqjZRvuVjX5 qILdMF+4VcMIQwdWX3VbrRQ0BdU0Vl2J3odqebgJ72l49biGjjUlY5BlE146Ta+emGhZr8vV 3svXL29BxiLgrYufINovCcXHbAMX+up7WE0+mUMmQ6CEmhpd90mGbo5BESpVb4b6juIHXRJu QGP2yR0lJaSbsGYsgCXivSgo8ZOapo77c0mSo/u7sTiZzjEc1Hu0+jglU4LdFS3hDMRq0DBn sPbMrTj/7lthDr1rTmPgkbLi7CFZVrAcqjt4WixxM2ToYS9+iJ+cLAXZmw9tVkNu2mhntjgy Dg2f9qy204kHm2WheiDn1+mjYTTlmTRFqRqpIc8vcKuhml47T4W4A2nUqLiYtgX3X6Fm/Lkj 5l7EgFS7v4tsPqm7BvVFWjc/lLpTtm4+OVp/d345t+h9Khj3ghlTfTkHhmul63rkEwFTuDDZ TPhcF7vASNeBU0yHh4Sh1r1RNz3WtfseP+WUz3mQL+q+rdnCsCsb17F23x7kRaS4rDoWqLYo m9AH0KlRHj+uIm4lna2kwCKZUnwbzhvHXqD8zQASMFxDoyGKHCNBgpe9mmjmRG9sXaxYKqqu huU0JnlsHaoA3XUoMLMRYNtwreclomIScjC0q6xU2G/T5fJDj6rrsIo6kYcK3lFCiW5Bj4T9 7R2lywCsdcInNTUNVgmp/j5UEF3bqwVnezNxe3qXxQa8uqscZ4sqsbtcz/hhAbA6SvSEi7tb I+l3IyMDtjME5DrCc1/dJfpaGmMYvvSq3ScTMTf4Fu4s0Koh5nNcCU110zwLU46GhJsGVLcL 9sJf2WrKhjFcwMVNf0GToZHADLUw827fh7A9uX0xpZ0esqrkh6lgf1M5DmFi6chelz0wqnZV xITtZTWv1/796efHb58+/GJ5g8i5LVQsBfCRmN/UQwgpb0YShR5+/L9welLkcYTpWumMX1Za 4UAMi7VtJtI3+Gy9my89KGmPH3Y3jsTRVjSTtYqKT//6+v3jz78+/9DLqGhO50M9mokFcU+w dxUbWqjtzYhjjXfdtoL19a2WpG2bNyydTP7X1x8/cW8fWqS1H4exXtZcmISIcAqtPLVlGmMm 1CQIz9CQb+YWXd3xkWzZo6sySjA9NAG1o55SsAYT6aKOK9UGqHCmUZ7FZoxCL5e1dEz1jDcG sMKSGyXHhEnoWbI8mXSZmGN1ARsUV+toYM0J8c7CgyMtYocMxot/fvz88PnNH2CQX9qu/o/P rA18+ufNh89/fHgP2kO/SdZbtrsC40f/qbcGAoOe7NyKmK1F61PHraCZJ4gGbHmjdBF3rEOZ TNVsL2BVW12NmsTGI370pJpZRU1kAPOxatnwYX5/tu7g1CZGCsQyhajtdqyMcVoqycnKrX6x CeQL20Iw6DfRVV+lEhfaRTfrwFr6xgLu0K6t1RbOP/8Sg50MXGkQxkguxk09rfJqbpae3YzB CB14jPaJO8PiELQObaW8CKXtxJ2WAyYPna9FNgoMoncoLk8W6pyrfBdip/rUsKDSu32MASa8 ISj7K5DxBbE4QGO9vX39AS1gM69iq0FwUzx8P65t7UA6CUM9QrXfkQg2IR0KQz0bxJcRdiAN fqsLDPk80xHs1lWtErnBQZjrs5ttkJvJuFcUI3dw9AG7eYqauAOG2f9B1rSpNzeNQ/WSEc7g aapzZ7ufCtwaNICwb+cqfVoGKPEzNgN4gSGuj/W1Mqp/Uv1KgWSSzmZV0TJwKLKX5+6p7efT kzDYorcDxGEbb1zKKgixp8LTc5nQTxf73bKBGs2R/dX0nHjBr3ZpwE+slvaxqZJg8syG4vJh zF3pqDs4ivrC63V/fz119sVu7CVdLJV6+ubPTx+FRVPLhx0LhzQ1vP15XHaGWiQS5GfieLIW im3ffcNk013T8y9wz/P68+t3e2E39iy1X//8H6wKGTj7cZbN1i5H1caUGs6gVtZV4+08PHKV dcgeHYsW3HIsWppsEmHT0nvuB4fNVTziH/+lqmra6VmzV3dwDLY1CyZoVU00ILD/KTc00jHT BignBTBoyyDRzioxs/VbOL+PxladC6ElfRBSL9N3WhaqWUoyUbVLLtiheB6Hot5PPXmohuH5 WuumAi1a88yGQ9vznxkj22C7FI3WCIuuO3dN8ejQhl9oVVmA/05cj2Et26q7VsO9KE9VW3f1 3ShrUt3lvCso263dpTXVraaHy4DrSS0seumGmlb3y3WsT3akZkuAHX1htxBCo7TxY70XrEDo AnLl0hsGC3ErowvYOpeOYNh+buqW7TtjP1AZs+5uYfmoHp7M56qis5kKgWpQ9JkeqR6Wbb+U S7lWnbedMAj3H59fv31jGxEeBbLDEcltyx47qhPqQ7eiP+AJ2JbkOlxzCy9a2g5ZQlV/i0Ja dS9+kBpcWp9N4nXK4tiQ2S9hlrzMR4LbBdwpEjHis0H1rUThgtooNDWaY+pr920i32OWGqmk VlEwSej72h0Zl9/qDuyUuarhRv2EROJ6fpkQ9pK7blO59MOvb2wSQut+R09XaVa4fuxGcJg3 EfoIcL4U7hJA+wlb+nF47GsSZL5nbo6MnIlWfyzv5phbpMLWyRxed6eqsOnDPAotYZaGVps2 RiOZA5rEXpZg4twPrLYwPrVThh3yiKbANbmMsJgwzyO1iJCiWI0xW0VkdCF5iqRKD2M2WZll c8f5wUo+d60Mj78cmskLqRKsANUu4YpvJQmFiWDNFy6WK1g77+aK303nVrmJ5m1mtiVhmGWe Nbr0NT1T/JJJDEpD4UdeiI4+SArNlnk6DdWpcLhx5Olii82Lsgnifi55/v23//dRnhNYO4eb L3fEXMv7rI09G1bSIMqw5ZpK8W8t/rVjDtsI9FSrrRNJr5oP+un1f3WnmCwkcXQBhquwc6yV QMUdnSmG/HmxC8iMbKkQPAsrYYu1FytQ/dAdCt4VNE6AmQFXGZkXOyMIMW0AneE7Mh+6kx2G MxlwfUWdh3lGVhmxN+Gxp5nnAnxXsrLKQ98PahQ/RdqbbFfryg/Uiufiqu1ouRkC0mOdUPCH iuoPfBUx/DsWqLahYNFL3zeK0poqNf2PaBj3maRgZSFwZeiSy7KiJGwPBMdM2lW/1ACGhnzB rHNIXASqvc+mUgEb+Qguuk5Qhmwd4SVajckkzOQWeH6MfLsQoLITD/tUtA+0+WkU7HpLIwRY 6PTgsBEp82TgEhVGSjiKBXp4CtIJ92q2JKjIxUMDQ86mIj/1IjcSOJBAndWWxC/q5moaF4x9 leUeNtosDFjbBKkdqnnyt4XIC2W3OJsxTBw2gZSEpWmS76WMlW/kxxOWCA6hhiBURhAj+QIg DWNHqHG2GyptD2GU2pVzKi6nCi5pgzzy7TiHMY/Ubc0i51cCF3roSzQ5ZZ7nqIa1MUDwn/O1 Lk2RPNwXW1Gh/CdsiSMapdJL1qEeL6fLcFGVrAxIWR2vWJmGfoR8U6aRrz120BB8M7JRWt9z vPvSOdiQozMSPA0A4a/TNE54PxF+mu4nIg8iDyu4MZ18BxD6uCczBkU+rhKoMnw81CgJnKGm d0NNYyRUGqZYFihJhY8VO7Kpno9FBzpebJmKKVMtzMcMrGbq6mcS8T2AdmvmWLR+/GBPaXaC 2hIMUQ0nzOTH5kKubyraEqSdc+MYWBH0VVUi/HHq0YLhWlh3s1XSxPHSfWP4SYDNlSuhaho2 nLVYydbxI1h83vkaDkW8+GhnjJ+WBMcThsRhGlMs08vbOeOpsRkAJQ+qXt0iPzWxn9EWC5hB gYe6Q1wZbDlSIGGmSWBLH+qHxA/RPlmzLZvL1eVWrLGuSS3EcPfK2zgW7JjtDSvvSIQkk7X2 wQ8CpDk2dVeB4xsb4DNXjCVBQKnzMZPJc+mJaTx0klUYbN5HRi8AAt+VyigIcLVmhREhoxcH ErRWBbQ/+MO6jP3ZiRkYiZeg6eaYvz8FcU6CbbtURp7aWeMnIWmAjvcCc5jfUEhJcmcK5pwQ e2ypMSJXKpLE8bZf4+TpPQ7LzW6zakkfegHSrEaSxBFSeFV3DPxDS+RyC5lMyTShzaZNsHXt BmOzJZMiCysmxZpsmyK1zaQZJs3wts32gLuJzNCIMzTiHM1QjlY5k+9HnMdBiNQHByJsWOAA 2r16kqWhw+SDyomC/ebVjUScRtUUP7NbiWRkXTW0R3kA0hRNJIPY1ndv7Op60qbTZIfKz9Nz pUz61nCdvjJbXFdfXcMGePoOVTP3R9fjGDlRHdqZHI/9XhR1R/vLMNc97aldi/UQxgHWPRmQ eQnSIOqhp3HkYZ/QJsnYmgJrKwHbKyfoLBDkaeaYBQDaXo3fm9/CzHe9gNFmBNxQuD7se3cH 38BL0RNBnYLNp2LQzFwTUxhFqFFNhZIlGTLk9FPFJjXcg3NPIy/anagZJQ6TNLfDvZAy97Bl NgCBh0Y4lX3l78b30iTo2p0+jD4yBDIxvqdhQPhrt7IYg+wtFBbFV6ubl23FpmqkOVds6Rx5 yLzBgMB3AAmc0iEZaymJ0nYHwcdzgR7CfG+lSseRom2QbUGSBNtTlsQPsjLzkfZVlDTNArSv cijdK+SCFUCG12DdFYG3vxYDCq66thFCdBgbSYqMYeNDS2Kk8Y1t73tocXNkbwLlBKTUmBwd LEGOlwdDYn8vKjCVSfqLa/fC4CRLUD3FhTH6gWqNYJNnQehje9NbFqZpiKqDKozMRzaKAOR+ iaWUQwH+cFdhIP2Jy5H2K+RwyKErbCl4w4beEZ2sBZh0d7KZBOnDEY2aIdUDsj1fL5R3leHX rkJAWfP+2cn46PnoeRRfMhWauUgpAu9DY00dJjUWUtVWw6nq4NE8pOJ8PMK5RfE8t3TzaLiQ l0NRK6rbUHOLReAWF12gLMSyElrtpzM4IK36+VbTCgtRJR6LemAje+FQoMY+AUsNYLLOYS11 +cQdOkLcTS8QQEOZ/3M3zjvJ43qQywcoo6yux6F62uVsVXwRNhtUluIBHlTuP2s2ENYghPd3 3jJIUziOzASJnslcjhRL0dYTGDWMvOlOlEDBcybvH3fDslJPHnYDwwtB0SZQLgL3ivtWjOSh PKMDCj2wQqS0PmhGF6hqJ4FRKDwj0HBQ7OCOYdGvF1QX0rI+73yzwLpUPE2FALmVAPxTnYRi +uPxAwF/3lZYIDZIIsHgMhVlrzgmZi3PEG8JNQB6bAqqGQlW+WBveyYtdsCo0Xrdp5HAUGOd XHf9v//+8idoIi/mWKybofZYGhYbQMKCjXNPP/7g8jKPU7+9XdFWCIxi6gNvcth04pHJdzLa o0oAVoUrLTwhdR5PKhT8lQOP0lQgXYVceVQLjIsdtiFXHD2I2tDADBQUqONgJ4VCw9rMu7AD 5v5Eu3zmJUF8cAFhlaEQ78S/MIxXwhzqg8Rxicb2O3Nf0Jq40igGwadLMTyqz80ko+mJrmEK AsOp9za+920Nr3FHGAld2RBsbibFyMWG8GXP3e/lGxskjL4l82HCtZ0564kmDiVKgN8V3Qvr 5+cS1bIChtRb1BqrsJzomSkSYndjhTOGKEavLiXML+nNfgg6BanVDsbEddS2wOgWkYPLWesW U/UyGXbqgAh2+fTUYNoPqwE+/EZphfXmxsNX9BBV8Rh7oasR0zpKk8kwTcCBNtYf3K5ClxId Jzw+Z6xStM5eHKbY86xneupXz5SoOgEgG+HdUhjGbL1CSVESHTU1XeUXDbdZuK3Tepr4Xuzw 1se1XR12sgWIKvvyqCxN2SUBhrLtShb6s4hUf1WiIdqLEkBujR+kofXalhdIG8bOShaKunpY QlldK1SpcowK7WQugPHgbJ0oHL7UeT7a2PdwK5wL7KgXAWe5szNyMNOzIDeOiEw3sLp+H5kZ upEyDyOjHam2BFwrkSXo9fhV7ZybJU/Xy7SNcaynilXauRnhDvQfmwBmWC7cFlVHL62qb7dx YHPE90a7LDbunjL1aboGyZHaggoyZpl+T6iAZRzmuMLMRlqWZbvlsK4lMCTQz20NDDtYUwq4 6OIwVhWdNkxfe2/ymjZ56KGfwCl+kPoFnh7WWxPHUwOFxMY49DTQoKClwTXj0DoEJHbUE5z/ G5bOHawkxRT/Nw5MznGW4NHww/cIu3U1OAna1LY5HIditESU9QCepDTNgjuZkgtJfbbU8TRz xcDALMdHPYXVZ1l8p2TYYkS3nrFhsOi4E8OygNiNoz9eXiof7+n9Ncs8vGY4lDk6IQfRzcXG 4UrN8oGvBSqLCxtrTrHv4QmGSxk/CQM8WTDdBiFqpU4nxV4QOoLnawU35uoHHPVD7ILHIAWR O3htabFh66yHRCxmOSxasuyXt68I6xx4o/p/1p5suXVbyV9R3YdJbtXNRLvkhzxAJEQx5maC lKW8sBRbx0d1fCyX7DMTz9dPN8AFABty5tY8JMfqbizE2t3oJQodRve518Tzpk2XJR4DnVEa TY971g5DSJIW4To0Tb5lgh2JzUmBvEWjbboV90u2ciXgvCwG30AiS1QRlZHgS6RzkuQsTMSG +em9TWb0sOnddxIMV39khIlosCs/38q4RIJH3CsaK9n4+Hg6NHzI+8erHoe2HhEWS5VCf1AU niUsSoEH3jYkNCsmaf0wCAtgO2higzRn6EblbFX4+d9or/Hl/Buk0iGAJGsdLXsj1fR4G/o8 tbQ4auxSafQZyQmR4709PR7P0+j08uOvwfkVmUBtwFU922mkbdEOJplqI7dbi8Hp5TC9DoM0 Rcn87ZU8XIpGMY5xmMicUklAbjnZ5Po+gR37m+aNQn2atsa0KFLdh1ujS9Doq7RV2ElgHdtk 8OX0/H68HB8Hhzfo5fPx4R3/fh/8tJaIwXe98E+6jrteJF54dX2olch8lhW9E8pcGxYbr6rf wMDCJvHCKMKA92onmtvv8PJwen4+XD4InaTaY0XBpDJIPRfk0lVU0Q4OP97Pv7Tf/efH4CcG EAXo1/yTvdrCvBbWZNWHH4+n878G/4VTKUM8XA4A0Jp7+zfa6xa+rFK2ARvp4fyozaZ3+H68 HGBYX97Oekxsa4FuwtmM9jqrPyfejUe0LKkR0DxrRzCjpY+OYPFZEze0RNoSTD7rA0gXVwjS 7XjuyBPWETiy0XQEDi8kjeCTPiw+6cNsPqVE7waN9pA6r9MVc+Q30ggoR4gOfTOj6l2MZ5SE 1KINGaiFznVvhg66oKCLKflBwKVfW7Tp9uaz2bxxmY42BCAuzCjD2fqWEPP5eNrvWlzcxEOH 4ZVGQTKdHd4Kz9ciMpc7SUtRWI338CPTk7xFbIejT6reftLrreEOrsAiH06GmTchJjFJ02Q4 kshr7c7iNCLvTInOf59NE2KsxOx2zujsehoBnYGqJZhyL6C1BC3JbMXW1yjikDnyjCoCXiz5 7bWzUcy8xSSmfcXpE14e8RHAqEfohnGZLR1OIDXB7WKyuHZU+fc3i6u3AhAsh4tq68Vk143+ yQ6unw9vX93XFPOz0Xx2bcJQBet4Q2gJ5tM52R2z8TZUwP/DLa34EayszglLMGkG1uRTijKR WkJZqPjx0oUj/PfZFK1mDIyYRdzmshWu8NlyrFtn95C60G0hR4AdObE3S90W3EByNlvMXSUl 0lEyLsbDnaNDO288HC9duJmhuDBxUycu9qZTsRxOdI7dxX3K6Qsuh9evp4c3KlIYCyhf620A nGquxdWpATLAdpCV4rdRF1tbj3kJP0DmwOB9q9CE+hnIrLs28rAeZQix0ukTBNo1Sm9Ej5Do NhZ1WF6zaoSvVw3qQ0etpTTV2utQSEw3yqIo9X4bDYdmrzAccwUj74M0lccY1JA2HVKfR4v6 iCwKa4gAgMEQq4wFaBqSRmbHMOI5+aVYjoIHPK6k9QYxBDg6LhyWE5uYxyRWz6uKv4W34W1G Djyiji+S8x/AJfD1+PwKf2EUWU3mwVIq3vRiODSUYQ1GhNFoTmmkGgIM94gb92a5M7/ZQM56 4XdcfVOmU3lsnPiNFZQGNrsKkqMrwDmiWezToYERmaTlljPjgbIGNdl1vGJ3RYvSEKvoCzMS 3Jjq/Tah0XFc2luuIcCACxFmr3J+XXhDxkeQSyTg1tLewnqzIPF9sN7Zk6+gsAc90v9Qrs6Y zUzzgBo6dwR8qtGTOZmnXk6UHoNSHlYBC8b9Ru52lH8vYlapt7E/UOV+gBVgwjNMjdiI+v7p 7fX58DHIDi/HZ2PVWRijsTz09We/ttYOY1QeNtmBB6vL6fHpaG1FpeALd/DHbmHESzKwfqZv JnfdemFeJGwbbu1xrMGUmZ9G5YV5XorqjlvP+GGyR/Rmt5zMFpShc0MRRuHNeKw9yOmIyXRE 1YqoKRnGqqGIQ7i7J3cFVTrnGcscNsYNjSgWsyUtLWoki8mMcs6SC2uV7iQLaU6UOjXs/Vz4 a+oJVXZ2ZDoe1Avf1aoejVx2km0NB9xuFaY5Ri2VV2t1V4b5bRsPf30BGWHw548vXzB2sZ0X DW5rL8asxdraBpjU9e91kN7r5g6WNzLRd6jA9zVjBWwE/luHUZSjntxGeGm2h+pYDxHG8Lmr KDSLiL2g60IEWRci6LrWac7DIKl4AmydYf8NyFVabGoMuXaQBP7pU3R4aK+IeFe99RWp7suG w8bXPM+5X+nP3ZKj8sqV9U3ACWLMSR0Wpz6vGQhhlC/CSH57oZLP9RfG1yaAeE9bilMhTwWj pSwe279hTtYg9YVoSZSo5xCtiv2K5+Oheb7rcFwx9BCqFFV6IfjyEXVc4MKdmnoTHDtyfwGi TehsjuvIb6wctWpl1gECZD8gdAj3s0BHQ974HVUebs02EVC3aAGbgFB6IxLxSRPhQtfE4YLl y+FM9wTGSWI5bDfMTJl4G3PB9eLEtUA4tKOIJ2FJR4/X6DBj9F1Jc/QdmXMsa7zLhBcHoscz aqur2Ftncgv8bOxYsTcGg2FqRnPZI6gxso8835ogiaXVSzX2OkuIq5WyIkB4c1MYxBLoMJ7u 8MzzeGR1VYT0OzLuxpDWsuEy5ymcuqFzYm73OWXHCJiJv7aXFYJU31zVSQrn123T1E/TkTFl 22I5120K8KgEfg6uUnNm81vrtJvY5xhILHSIfxy82pJT23Yr4I93xXQ2NHdfbUNmbygOKzxJ Y0f1GDR3bB1YNUw+xAW+eWA0uP7RJeLFyLKPadRjFBchr5HV4eHb8+np6/vgPwawxO3ErO09 ArjKi5gQteGB/o2Ii6br4XA8HRd2WEydJhbABwZrh02yJCm2k9nwjvYgQALFoVIMWoOdjId2 5wo/HU/pgwzR2yAYTydjRonPiO+nJEEoi8VkfrMOhnMTDl8J6+V2rTvgIlxx3yYsLeIJ8Nva NdEeGeZof/TxvfDQWlHrxG+/tiOR4YzIEelopDHRfUTmNO2oBNuwnFHdsO1Gtdb9bLm0YwEa SDIYVUejGX73cNI48IbCUNbV2oDSZtlaxdvZeLiIMrr4yp+PhtTbnvZlubfzkkSXCj/Zf5re EJ0mNeFh40sjL6WDPL+8nZ+B+6tFzPodvLeJUfvo9TMrAhj+qkS6hiHy0DrDEQXVL+N438/R a4Dh36iME/Hbckjj8/Qecwq2J1rOYuB+1msMiWfXTCBhRxTAnmKeyZjl++u0eVo0+sru0eX6 YGlHQ2onvalr6OmBmy6ItExMF+OknzlkA0JXb2Y2oVEOfnbhK4ucJ0GxITcrENIJx0tVo1Zf c17UgqV4PT5gxlXsTk9qQHo2hXHemHUwLy93dkclsFpTCdgkOjMeKCSoBBEvMmErHt2GiQlT yRvs9rxNCL/oDDMSn5YBozUKiI6Zx6KICvUmC8sXAqsb+wzEDGECYdyDVOY3MDUCDdQ9IBzV 7GuzNrRAS2P7S/kft9z9nQGPV2FOHc4Su8579QVRmoepnahJI4DmirS04+rrBHv60kDcPYuK lHoFQSRm4BBpomfnkT3a52qDGtAQcyNZoMIC/M5WuTVPxX2YbFhif/UtTwQIznR2TiSIPCvC rgTy3o4EeSjdUleERKZBWG8Ys1ANxx8ZNTotwVrz2UdgXsariGfMH/dQwc102APebziPhAFW 6x1Y+Bhm3RrAGKYrt0c+ZnvliGpAc67WtUUbov0nXBoWOMXcu3xvQcuoCOXasgcoIR32EJPm Bb+1yTOWoBIUVrJr5We8YJjPxexABocGynAUEBVkHxS8vbpptJIJKQT3BY3xwtxCYPryHHeG dcDIC6532AoGi4VOGqPQsSgdbv4SjyEpHSmrJb7gLDb7ASBYVnB1cKuD0FAWlRYQ5Chrh+ec J0yY2Y9boPuUlOm2f0/3dRPdlarB3aWLcJtah0OaCc6t+S82cDDENgzTyNa55TpFuAZVW8wY 1xKv4Soj5Xl5NoZhnNpH2C5MYquXf/A8tb+4gVlfa7T/x96Ha9h5wqloHdWmXFlTqOAefBr6 Dchf1lUdZULnVym2oUugSrE2Mglszd7oOQ81Wi3kQyg2jmqkfy2gK4Oz6cCtWttP7xOVANho k66+QRvdaXgosarSDYjgDjUw4glzbATDAYCqCHojIkEZySSB9FWMBPBn4hJJEA+yBAwFE9XG VEwBzlFCBR2QY41E+Km2ATHCs68fb6cHmOLo8GEkz9ReXTNZ4c7jIS2pI1al9HF9YsE229Tu bDsbV/phNcL8gNPqtWKfXXMtQPFA3IcFmQE3jg3dSoxe3Y481xi1oiqZ4X4A5DJLX2PSHHu/ Cv9XpBxsMH3wtXSUWLinDkag8GEp0n2t7lfCt+mLcA1bms7dJuujHd1jzFe7GA3t6rbSxQD+ chQqoX/hHIa1V9K7szpuYDfizlFjkYpNuGI9Z3tAxQU1FTFw1kXoacq+BtKOqJYzS7yfHr5R y7stVCaCrTmmeihJ5V2MYVHUwtCaFC2k19jnk980LScvNgMVNLjfJeOVVJMl6V7dkOWzG+2R J+H3FleCv5SSiYJVTTwSHbPKkRdKQBaqNvdogpQEMsC1sljkPjWasiAjjToUSkzmU10DJqHS HdvU47Vgyoa1wc71mMgtcKhnTpBQlazKpq2hlr+qRBEg6UM/7fcRwDPaTbHGz2aOqLod3qFE bfDzq/UvZ6QJcT25fIvpkMKI+nYz4YIO711FfSrLI1dHN97iBStKIwmLxALrMhpPxXBJWcdI CtL9Wy1Jf7x0uMJLfB0iREzHpC2LpOncTnVo4TF0S7ShkTe7Ge3s9YQLc/aXBdQDW1hbZPDl fBn8+Xx6+fbz6J/yusuD1aBWtf7AtFEUpzX4uWNatRzjaiCQq4/tHti5qBsoDKgFRN/23uSD VLJYrpzTqiJGVJhhV7cJbPfdeNHfHiKIJyPTtL8dm+JyenoyDkTVDBw7gfEmroOrJo0shUvh sNqkRW/ZNHg/FLQwZVDFBSVrGiQbDizAirPC0RFdkqQb8dxnZEPCPJBrwmLvaMMO/2R+aR2D jgi2dnp9xzy2b4N3Nf7dGkyO78qXDP3QvpyeBj/jNL0fLk/Hd3sBttORs0SgOYujl8p70oEE 6V5/0jBwCS+MrMhWQdSWJvZubQau9M2ENvgQieG8QmDtaQ1bCP9PgP0gczVyOLIqOI8w6pDw 8lJTH0gUIRUgnKgpL7zKyD2KAAzsOl+OljWmrQNx8namdPMY6Eq6BBsGTS3UEQcMU4n3zIrQ pFYlPdeU/ABrY2TAzZ/wSDffA6yZDlWlVAceJgBcT14D2Nw4Gxr4jhruGpmygqgL52A3QhMU GbutrTGLdnai9BYnX7Y22IsqDmJafuhoqNGWSdg9KzhaDe0BzJzsAOTGd9QAmStRk75FWSmy TvexrjKrP+0keirjtmGTLvYJsNG9YejmrJZSetOOntctYwfgVbnu++bK2tehEYvvXkINebQu Tg2xQlVxuuW1zdo1ssaqnRYoayI4hzPaI9X6jPajPW0mWLmDGyGLmHbEbvzpdGEmibwVw9GQ ci0LYxx1LwxN1WCdqbw2ZP3egdH2r0ljPrTAeSrHdmaCFdMNrIUQRiAbhV2ladHi/vGPrsfo LiAVmlGVOtRIOgmlR9LwlmxgfVZNqOlJdNYZflReaCjQEJShM37AkzC/I3uHND4a2PdpNArG PbMlYGq8VBjmHmWdurR+D3PUBJfNrtfHvBQOhQ0m7VzPHSGbtmsH64znaR27kfaQQ3tozXlE 2UcDW1n2gMYJ08E6G1cLZSTPrIErdN/Qtfw1PEyy0jDebToSu77Lz6gDZyuDYtbd74glNHFo cRRWeMLhxy/RW2HpZiw8vlOIWn1Xj0jvDI1PD5fz2/nL+2Dz8Xq8/LIdPP04grhO+Pps9hnP t+Qh81ktzVAEOd+vdN05iEaBsu7sNmSKb5HkZ+VFBKwByU6I2VgGAFc6VZigt/fD0+nlyVb1 sYeH4/Pxcv5+NLPIMjgAR/Oxbr1Sg6aGb4hVXtX5cng+Pw3ez4PH09PpHYQXYBuhUbuFxXJk OLEAZGx7XjfNXKtSb7RB/3n65fF0OapoYkbzWnOYXo12JPybtdUO+q+HByB7wfAXn36zEY8T fi+mc308P6+s9lDA3sA/Ci0+Xt6/Ht9O1vfdLCe0TCxRU/p+dNWscgce3//7fPkmx+fjf46X fw3C76/HR9ldzzHKs5sJ7ff6Nyur16lMWnh8OV6ePgZyteFqDj19cPliOZuaK0qCHOaEDbYJ vdcuaVdTsif58e38jLL7p3M9FqOxmcj8s7LtKwWxYZt6lYWfXEWNBcfh249XrEcatLy9Ho8P X41Y7hlnVhJY/SGHKq0VVieScpnsHZfs5fFyPj1qXy393/TzK7Qdvdotpoq2Z6Go1lnAkHcx btwkFHshMocpB9p6ruk741YsXHEp63NXCYRXKbA7eUobDTY0lDejRWIZ9jRgl11yi081/UwH TDPUI1AVuhL3Nvic3VPFtuEqd2UibwZCekj5VbbZ97tkBlFtoEasywYofIrUin7ZgEtHbuUQ s1jXcklwePt2fNf8D62FGzBxywtlF3af5reamFJTsIzvav5LtxCzKm73X8gjHztn+d3eZh66 QNBCZBRQq2O3nHeRmDqxvdlKmHrhXn9Ihx/VKk7XxhEXhTyRD56ApR+GS3bPQydaic9YtUCe /r4qMx8kwk9oi02Z+DxfpREZqWoX1z3v5HDO7px92IUsjd1dZB7PNz4tryCuug9zHnEHV64o XFWjWVoVxCVtwc8EbjiWWRZNJp5qvRUr/RXTFSQq5eYqTGmgHLUPCqHydOoI1S3D7AzB+aok u1pXli6XLndPJLDGyULBH8LLw6xI8167iGaO07QlsKyIu2O8/D0sRHltqBsSmceDPvGDDM4n kAFwuzu8vTbZFe+DTXZ9JSHetYtWMbLj1MtwnSJl47PMeMlDBf5txnxXsHG12aR6UWRjkNWM W1UipXXglif0cNT6sqSAY2lcbZ1PN7UCjSdRen+FYLsq6DEVZb6GTTZxDk5NUE3qHPdplvOg xxdYxFmeTqpVWRQOuli4D4zMUwos+eRIJv5SBlLEHmowdw7WQZ7K9Zs0bXBQv1eviipf34aR I/dJTbXp6aksAveZCP3w4oy2bYiCa1spYwmTVpjXiIDrKni8mPeWp9bFDK7Q/FolaPUjbf4w 81/BkiK0rpZmMqOd7l9hL2HHGClsLq4tf2ko5ilnxh77qqyBgAc+Pg6EirhSAPv7cgbh72Nw al20Cem/rh0N6SoVOVKC5Nol+d3/a1t2U6V0c6xkVh1AOHJmd/kHTJ10DQduGvqZef0xFl6J mqJrI4kU9RxRTFms3kK6NrVMHrpaENhp3lak8TsKk4puU9qIDDNvGj4LLapYkSYpTfN6kTq3 iMvVsMWLTUEv6obClea4wUfZlS7h+VakvY7drqTZ6FWvxaaGJvjLdxshC65Y3sfI15+16CPU LWVYBraoveiVKMUqk0bNAbdbUaja99wwXIkilqS7a2tow7a88iKNR4cfGFUGZB6QYDVtfE0I o8hBNNQWunqFtippYUQ4Xw0Zs93NlDQ/0IhEOJvoKWgt1MyJmk5JjOd7fGFGc9GxQvpVe6RB /T2swERaGTUeQM/nh28Dcf5xodL4QH18C9t/OZ5p2Wnlz6qupaNcRX5L2WmnqPrb7c7CaJUa Y5t59B5rXgWBnDrD4PNLjNmqdVKCuvdUJfmhiub0MJDIQXZ4OsoH7IHQTutGlvuEVFdXYEv1 PqFPw5pCPaRnTIgCTqEyoN0lWOyrEtdYNDc+v6tybgWOrtVQ38/vx9fL+aE/0VAiLTgcMJ4+ eUQJVdPr97cnopIsFpr2Qf6UR44Nky+kAdqduDEIsLH1u4auHjN6orEi6FCFnHlvFETqDX4W H2/vx++D9GXgfT29/hN1WA+nLzDbvqXr/g5XLYDF2TNM1BqFFIFW5d7Upe0o1scql9rL+fD4 cP7uKkfilZJ1l/26vhyPbw8HWKJ350t456rkM1Jl2PGf8c5VQQ8nkXc/Ds/QNWffSXzLW6do ddps0t3p+fTyl1VRK/bD2thVW6/UVwFVolVX/q357liSJg9h+4itfg6CMxD+L2vP0tw4zuN9 f0VqTrtVMzV62LJ9mIMsybbaerUkO04uqkzi7ri+TpzN45vp79cvQYoSQYLunqq9JBYAvkkQ BEHg+axWRkYs5JEUuTu9rixitvaKWD14j0QVE/bYNhYW+Bk0IoHjTsP2KvJMPdINEUUsJTEe k+4TvRGG3ejYXnEqVMxRDiADywySv9/vz8+9wYeSzdAGQc4jCn4KLXdqPc2qCdmeSRnV9QS9 blBPNxxO/cmCdurTE0IUapvP35GEx6SwV6Jqiym6eenhdTtfzPyQqF+TT6dkQPYeL23bjSwZ IqLkzpwx5Zp6b5iqmaRwActfryqb3wDroiVFys1wjVA0gN9ydy6MCoN7gyiQM0VZCCt+qjKf kgZXS5bawGoYSDyVpLkmfAX0iD4B3SlKLcVsfvq5K0vkOkYCaY/PYXzI/JkRdM/A0/dHyzz0 sJcBBplYtGvsfMIm4AXlUxx65DKKQy1MScxOtLFDBTfhGFeZ5crjHl5w58faUPcyvsD2VgL6 OLUycXiwOBDZHpqYqtD2EH3auo6rhhiLfM9XXXHm4WyCA+n0IFt8yB6rB8xi4IAMP8IwcxTu hAEW06lrBgATcDoLhkH2Izn3KUqdFRgm8NQISE0U+jhmfbtlpxAc2puBlqHuyvr/4ZKd7WVr Hv4za0O8MGbOwq1pvgr31B7lBwMQ6nsCuLIPjEv8BW3XzlEUS+WIOcp1MgvQd+AY310q9IQh +BtVLY8QWpsmcOMe0PsNR807avwBhePxAGRhI10gq4kZcpLLvhcexi8mC/y9OOCiFpNgZqly 2rFFaYlxGEUQyscFLOIfPCgo27zoVJt0PvGV2bs5zFR/4GkRgtuZUHUNl7WRN5khJsVBFi/5 HLegfH8JjOoYODy4jqcBXBRRSUCQ8ycAeRNyITOMH/go9SJQ25dHle85BwyYeB4GLDBLzpOi u3Xnc30gBoIi3M3mpDjBz0h7kLR6+3kl2yGMU5faMh5J9vRwjgQMj1w6AsCZu5EJU1/ESNik cTxXB7ue688NoDNv2KChq46eet44U6oTenzgNoEXaPmxvFy93s1soQpzY5BLNC0ZuM2iyRQ7 rOwPHQejR/+pqdHq9fz8fpU8P+DjoIHsz54v39gZxTCOmfsWbrTJo4k3pWs45iUyezw+8SeS Dfcgr7L/NguZaLYZ3/SORXNUclv2OFK+SYK50s3iG1/r9zAUYzOKmjliGeFnfauFMtMa/Fw2 68qndu2malQxYX8777miVEXpjabEGnn3huNgERQXkV0GL6CLNfdfIpy3nB76crmpTsSOwudn 7DelF7uEkNwvbBotpWalcXT+ahXzZqidEqWmaSqZbqgTluWaalT1kpPLzAIJ861WLI1D00HD 9WPRm7GJFfYOAXD4uqGFmKkTKMpTCIMZOPhb352nE4/enaeTCZIk2PdCSzpdeLSxEcf5dpxD i0zTwJvUpiAyDebBhZPHNFgEVsO16UwVMPn3HH+rvvf5t2YYN53NHGrRA2aB0s58x8dp53Py ZWHcTCaeMk5sN3cD7N4LNviAfLqZB56PYwuyrXnq0nIP24InM48Uvhlm4embTxyyHcyzPC0U +Ol0hrc3Bpv5rgkLesF9sJe8MIUH69uHj6cn6WNKcWYAK0OomrhzLOPkpeDEGdiikdZpxame vobUa9O7kT3+78fx+f77YPD5H3hoGMfN71WWSQWqUP9zXfrd+/n19/j09v56+vMDzGLV5bqY eiicwsV0POfq8e7t+FvGyI4PV9n5/HL136zc/7n6MtTrTakX3kJXTFyldhCO6aXSviL/tJjR ceLF7kG87Ov31/Pb/fnlePVmbMdcGeHMEe8CkOsTIO1YxfUY5AE3jA91M5minXrtBsa3vnNz GGLVq0PYeEy6VulGGE6vwFEeyu62vqlLoXIYV261852pY7197TcLkdKqb0jbte/pihZtQZrj ILbu492390dFVJLQ1/er+u79eJWfn0/veNhWyWSi8UAOotg9qCsdF7tI7mG0U06yaAWp1lbU 9ePp9HB6/67ML+W2yfPp6AKbFh9ZNiCoO9T1G/IUk6dx2mLfa23jkXvrpt15qIgmnTkWJ5+A 0iMXySbrzestNRhLhXfQT8e7t4/X49ORidcfrLs0ZgCrxKaC67GW4EI9loyf1uOwMJxqSywl llg6LrGhoNWhbOasZ+zOjiUB7Ztjmx8CdCDfw6oK+KpCqmQVgYQ1BaHVrV9+WZMHcUMHar8w Euq+Bl3WIdfmKnTUcYtX39z1JTWfwcopzCyGnfEnNlN9S7yzMN6B7sAy2Jmv2YaPCMZZsKas ipuFb5tTgFyQbHm5cWc4jB9ASB1vlPueO1ctBxhAPYWzb1/VGrHvIFBNDdRjS+8bVfPpva68 sHJIHYRAsWY7jnJRMAj6TeYtHKxhwTiPjnzGkS4ppqmK6Ux3KCbgev0/NaHr6Y6Ne1xd1c6U ZEpZWyO3zdmejftEdbLGmPNk4hgMG2D0pUFRhmy/plpVVi2bJ0ppFauy52BYk7qu6rEWvieq trjd+r6LtMXdbp823pQA4YU9gtGO3EaNP3GR/M9BM7oz5di2bPimAe2ChOPm1IUbYGYzVYHU ZJOpr3TArpm6cw9JBfuoyCYO6ZpDoHwctjLJs8CxxRvkSFuczCxwLcE9b9noscFySaaHGZR4 KXj39fn4LnTyhKi3nS9m6hFt6ywW6mmivw/Kw3VBAvuR1e+POMrisylcM16I5rGynCBh0pZ5 Ap7rfKs/KH/qTahh6DcGXjyXy4zzvaz0JTSruI4ezKPzaDqf+FaE3h862naQlnR17rsX9lyN zMhNPuykBl1Mh49v76eXb8e/9dCAKrwXZe6/nZ5tE0dVDhVRlhbDkJFcUlytjh6Okas7ohxe A+lg5eo3eGX2/MCOrc9HXVXErVnrXdX+4JaWmwdSSiy6lH6/f2ZSrwh6/Pz14xv7/XJ+O/Hn laoUMKy+H5OjM9jL+Z1JJSfiinjqqbwpbty5g28DphNTCzGZ0yKGwFHOvkENIbZMBeD6+J6h Z4tIq+HSYklbZY7UqWvnHK2tZD+w/n9X3enk1cKVW54lO5FEHM5fj28g6ZEC2rJyAidfU/JP XnlYYoZvXULmMENfKEWZZVgj45E42zDmTnOvuGKyINV5SKjAHpwrfKxLowoGgLxFrjJXvYcQ 37g1PQy1hsF8nLCZBtrtEYfYrrsFEufJYP7MYLFa41Qoqa0VGO0E0E4nDum+tPKcQMnjtgqZ hBoYAFySBGpPbI0ZNZ4CnuHNq7mdNv6ilwHUHRkR93P1/PfpCY6PwC0eTm/iKbWRIZdNp9hW JEtjeM2Qtkm3J1WUS9fDzKFKC2rm1yt4142vwJp65dB+IZrDwrc8NmGoKTkbITckkIOY5NtO O/ts6mcOEV1nGI6LnfaPnz0vkDYLnkE7/+QZtNijjk8voC608B1QJC/mtHDK2HKaixh5ZVTu tAgXJlNok1x5bZBnh4UTYHFZwEi9dZtXjmqbwL9naEWxHdISSZyjPIswFh581wiPLvdWondk DYoWeYtin/BWiqg6YMJckSsAkMbIxwcHgakefRRiWOE9tSWjtQIe1khVYp8WAG9L8gELT5LU K70S3J+YHtJznOF5YnWjW12jpwZCBqs/8wCmpoNh8JRVh2B4jWQpnX7gI1UYbTvkw2NZhnXM duwo9ZDRT1KnIbxlKqNWjXrAmHDSyhc9WYJ8Gwrcso7yhnUB+4rIoI+CrE1BFou4ECh44ebm qvn4842by44tlKGs4CX3GJQlyrttWYRgvuhhFPvoqkPYefMi7zaN6pgNoSAlMv5nyKiKwsr0 76tQCDvQRPMoO7Im1IahXLCrZTnr75vqsMrIh0+AQM8n4yxhqE/ao7BBEFM8sbGP3meyIqgt 9cc9osOPr1/Or0+ceT4JXS56OibbdIFsGNIQOXBjPTgxijOdLxRxXaaKuXIP6JYpPNbmD78s uFVjTSUfpv/y5wm8Af76+Ff/49/PD+KX4mHKLJEMQ231ApGly2Ifpzl6BbjMwHXvnrsrolgG eKNC7hCWLRn0OlTMeoq98FOhfvZPnVRGJcBgPtPEoclHNtdX769391wM0TlJ0yr5sw/x4ouJ tGIJKaZ/EgXRJKmKA4W4INSSNeWujhIZ58aSsiciXFMq2BXjr5GxbNqNCdEdMQ9w6zvRgcIW vmYgaH5EkDeUd8yxai1dNSKMo7xtMAdQ5greSBQ5RjxZqmBOG5ajQNrl63qgaqz6CJ002lue u0u63l6J1vkMVHkYbQ6lp13nAbYPbaw3ZFUnyW1iYPvSKlj2QnaqtfzE020NGK8yE9KtcrOX ejhU2t5uSSRq92M68zm5ThWudkQFtancJtQaqvKurCrTJ023T5n0qEkdcmWlpcJr4Ksz/aQ0 WZpj718MIAz2orZWOpSrYiI9ICsbHoCjjam0sFntqYe48z+Bvx++sarPYCI2k5Luuqzj3j0q 8tIWwiGJHZBWDRjeNqRWiOHSMld35+TQet0KeT/oQd0hbFt6JjAKv7O8wWO4iYbrMZ+WMZJC 4PtCGNc6SRvY/SyZccTYDviuygZCfkdIngBEk0S7WvMjq6Cl73k1BSjtwE27UsRBKxK+P+/K Fjk1Paj1INsFFBZZGVBlAdGihdNaor5Ach3WhV6mvR/Xq8aj+7CMBGpskoR0pae+ZxnAw2uo Lsp2Tau+ORlooOuMLHn1GCtstuA4Sam7irbMqGVrnQVFmvVNUJmZZ5CPOHBmTl2ta9NnmMxw rlF7SEJEDIEOAkyPAe5SJroCWPgJHI4tRQwenG4s+BU4Pozqm6qPgzeC90ktfEmr1RdAc7wN iuUuzdq0gFcGRdjuatWB0arRI5DHOiAVAOF2XK1CaDqC7VFyMaif4DeSPzMdXDAoZ5SaAXsy mNOae0WBsDVUYFu2V6I0q7zt9tR1o8B4WvWiNjMhYBZaqdJYuGvLVTNBS0XAOiyUrnYQV46e eiUblyy80dC9n8L7RxQ1vuGsXtkWBUBfWxK8YayqXNdhbqLMwNU9olzCEYtJ9Q3pyABoYL6i lTVCrcOikKi1Urwo8qaKZse/1WX+e7yP+Y5nbHhsE18EgaP18acySy1ehm5ZCpJP7OKVZBKy HnTZQkdfNr+vwvb35AB/i5auHcN16ku8vGHpNFa0F0TUOmUI+VA9KuOkAofAE3828pk+/+8Y ItOkJTz4bpL2j18+3r/MlXNe0RLsTwobl1omDspvx4+H89UXqsXwbB1ViQO2keb5g0P3OYAp mQ2woA1RVx4HQhdAcLpUCyPBkdEmzeI6oSRJkRgMwSHi0hDCAqWudlxHA7LbgNkmdaG2Rh4x pciZV3jicQC9uSMKLjcpDjF2a8YCl2rWPYi3WNkoEuGWJYEwsiOfkWGk1ukavPREWirxb+RE UpNhjqMijKaNcAwuPAnR/IoxbnDKZ6OTVJnSLvYhJ+gfv5zezvP5dPGbq87NrBlme8dmO12w SjTzqUs8TDJDJggINyftTzUSNQoPxkyRxgHjfqLyc9L6SCNxbaUHHu5ZBeNb00ysaS60JaBe fGkkC0uRCz+wFLnAJlZaKkpjj0kmC3uNZ/SFDRCxPQDmXUe5f0eZuN6FCjIkfTEAVNyD/A8r YE8vKWx9IPHaMEvwhAZP8ThIcKD3okTYFpbEL+j8XN+WofvjQXFpo1Mg2ZbpvKMOrQNyh9sN cRvYHh4WJjhKmOgbUXAmhe7qksDUJTvxqcEDB8wNxGrHikGJW4cJw1jqzAmYfLo180xZBcMi NquRFru0tTRT1M6oAxPttxA10davu3ZFLYU4Q14L2eeFM+SuSGFlUAq+srv+rG48SHchnj4d 7z9e4QrTCFCxTW4adT++gUBSn3cJeITnArAqBbCTJxMo2QACITs5rC3e+SAMaMIjJVsUFOKw dYmEIbp4ww53iQh+TFNJrQKEPWj4VU9bp+SthaRUZI0eguQPmV+/86LWA0/i/jVhKWW8Vpcr Jbfvw6qmfSQPlOyoQ4VY5I68uB+zgvXVjgdqqG46CEEQ9ZG+BkqNSK25mcMqtMavX7GzNRw6 heob69RDkH0gk5zNxE2SVfozGr1dTW5zkDKQtGVe3tCuNweasKpCVibFmQYaiGZapWh56jg2 71jrdA+EOvFNSEaCGdsUruBGMY0tRUVbCK4KVuJWbf3aogmTJ4txWquBcliOf/wCj4Uezn89 //r97unu12/nu4eX0/Ovb3dfjiyf08Ov4CrxKyz1X8TK3x5fn4/frh7vXh+O3CBk5AD/NYZe vDo9n8Bs/fSfO/xcKQWXiGzgo21XlAW6AkkhTpaYi0rgLHSP2NOANt0SW2u0BKTrIdH2ZgxP M3UWN0jnwGpKaUwfvX5/eT9f3Z9fj1fn16vH47cX9dGZIGatWiMPawjsmfAkjEmgSdpso7Ta qFo7DWEm2aBAMgrQJK1VrdYIIwmHY4JRcWtNQlvlt1VlUm+ryswB9DomKdtawzWRbw83E/SR +EhqCFjH2TQPhGQkXa9cb57vMgNR7DIaaBbP/xFDvms3SREZcB5CSq9tk+ZmDutsB5eRwFnB AbqctdXHn99O97/96/j96p5P4K+vdy+P3415WzdIE95DY2pv6XFJZFY3iWJzwiVRHZO5M1a1 T7zp1KUfBBhU0C7ztv7j/REsK+/v3o8PV8kzbyVYsP51en+8Ct/ezvcnjorv3u+MZkdRbvZk lFOV3TChJvScqsxuLO8UhuW7Ths2U4xxkwj2oynSrmkSYpUnn9M90YWbkPHEvTRBWfKXn0/n B1XxKCu6NMclWi1NWGuumoiY9Ulkps3qa6N15WppwCqojA48tA3Rv0xsu66xQ0ZtPW1k1xOp RyTv1p/JpQv3B4/IKoQ4Ru2OsoiQPQJu4+QC29y9PdpGAqLV6a3fiBB2eqkH1lP2EvcikTRC Pr69m4XVke8RI8/B4sqeRtJQNnSZYHVGTQ+wg1xascss3CYebZuESGjRHJPoi96oa+s6MY94 ZsHIlugDsSZ3xwtzbJg4EF8ioB6pyt0knpg7TExlmadsYYsoi5e6os5j16POgQoeOwQYEd70 QvcxvO855gazCV2TMzEgW1xN4hMNYUhWkEBfagmjm7qeSUflRtWAJaZLv5Rb7ptZwd3TsjRl nnZdgycuHXxdiZKJKdTx6dUV6bDIhLh4ennEboLlJmCyWAYTrj1N8JCtObhhsVumlFpX4uto YuS5zMrrVcomvj7mEmHEG9bxYvab6y0ET9RpaGQsETKhFS92RcaVf57Ss5OCGoJuCeCmNFQt nSIIyIKCS5WOifFmML9L4sSWZsX/m2LxJrwNY2r+h1kTeuQLWCy8mI3qEbZGN0kSm+whqSvh OJKE8x14bJpR2Z5q7LOLDGOk9n6GPL+IbhPqgC6R1yW5Mnq4bTpJtKUHMbrzr9XopxoNmn2C i5yfXuBRBzpaD7NolcFtk17f7LYk5sh8ckEqym4nRBIG3VwQSm6bNpYCaX33/HB+uio+nv48 vkqXJCfsKGlgW03aRVVNPvGQTauXay0Sp4rZoDDACEPt6RxDibuAMICfUoh1nYDdeGUOFRwf O+qELxGyCnqzB7w8rttbP5BSh/IB2asOjBUAVgb2vPmOlRYrXa3x7fTn693r96vX88f76ZkQ ZsG7ALV3cbjYaYz5Aw4JTEHP2KU2Ql0J5IIfkYUIlDSztxQniC6xAE5FHjxNOop3A3yQBOsm vU3+cN1LNJcrTB0n7Q37meMnUA8ClJ7V5ppIGDY3eZ6A/psrz9ubSr3CHpHVbpn1NM1uickO U2fRRQlogNMILBmFGeNIUG2jZg5WQ3vAQh4UxUzGV7ZgQR8CiRXFe7oGBXWVCAstsJ/iNUhH v9wReNb4wjUEb1df4FXA6euzeORz/3i8/9fp+atiXs5vy9WbiBpZfJn4BmJBY2xyaMEGeewO I71B0fGpNHEWAdINl0Uc1jd6dSgts8iXrTeIcNK01pqPFJwXwC8RzFoa1/xEb8ksl2kBteO2 YKs/Bq8jNlYCxpFh3dUQZBvpAOC1D92sZcokdYjgrHShfGnDhPgigjuJusylqRtBkiWFBVsk bbdrU9UKQqJWaRFDBErWTawKChco6xgvZtb4POmKXb6k40yLW6gwM8uACNKaRa9EaWDOJME8 LcqrQ7RZ88uCOllpFGBpsgLJl8eGqrJUbfSQB1vQbBMu+qftiMNFXRSx7Q+B3ABTmOdtVt12 1+FUWK8ACgX5XgWLhBzDuEqyvKEPuAqBtsdwTFhf26IqCgo2enS+WO7GR6VIeQXM+KmpW4kU 7Z5QiKjNYhM8LnOlzUQNboFPs404Q9zhVmw7mmDHJLr/q+xYdiPHjff9Ch8TIBm4J4bXG2AO akndrW1JlPVw274IzmzHMHY9M/Bj0Z+fqiIlFsmi1jkMPM0q8c1ivUluja12G2elGE0Qll+I 2BciNnJxFv3ZKWb4drT3WMwIP/02Kme3jMLJmhC3SDifbAqTtpLK+h0crACA79aG9a7TX/kO MaWR+bdjG7f3BTtrDLAGwGcRUt5XiQi4vY/gq0j5RXj4BSvtOmVyCfyg2KSeknTzt76SrlNp Aeca2KmkbbmogbQBqAoPztJF6BI9OtQGyzM+vppeY6NE+CNQ0y2PXyIYAqAKYj599zeEJVnW jj3INQ4t7Q6F6ku2uoiaUsNa03n878P7H28Yw/z29Pj+/f317Fkb+x5ejg9nmC3w34xPhY/x Dh2r9R2s+ZfzANDkLfqQoAfeOSMTE7hDRRx9K5MTjmerkoiLU6NrWXZhojc7oiQlsDUVCtlX zM0DAU0Rdd/ttqXeO4xS7fJ0b73I2VRf8wupVGv3l6XWdqFL1zWybIfZ0WNqrbxHPwdbgO8s AcfKmqqaArOXzb8xqBHDjOCidjYrbODpONxknQoPyTbve7h41Sbju5x/M/Z0MXOXa4Xaifm1 K1bqOoIj2tVJuo8MaHUZ4F+eIgnTCPrzKeJfRdAGuKJyqcUE2I4aEYJmYXsV48VJTnY9dUzS DBFsdX5ahXV2Q41DjFcJCKvPp89ynivCAAl6dXkS/QQ7jDNWpUclkOZgHKorW0OBiYsLsQcd RjVuyqHbeRtxciZO94ekdJ+mTvdZ3ihOhYAmafLH/FWQc16OsA24XNdpYpIqqPTHy9O3t991 Fojn4+tj6ExFHPSedqzHW2Jxii8xiAoDHaGKLwaWwCWXs2X+5yjG9VDk/ZcLO8Na3ApqmDHw qfapI1leJo6DUHZXJ1WRLnifORhjxK8cWNK1Qtkyb1tAd95rws/g3w2+it3p2TFLEJ3WWXX2 9Mfxn29Pz0ZyeSXUr7r8JVwE3ZZRjgRlQKayIc0dnQuDTld65CVmhtkBYy6HQDCk7JC0G5lk bLP1qJ+LlsSNvCYPhmpABThSf0bo8K12HYB2tfrl809stzfAOmCcNmcm2jzJqC4AMdKcYyaH Tj88yym77jyIrChVoJd6lfQpYxR8CHUEI+buvPM5RUMWrk+QCTNDN6zxkCd7ehopbQbxdH54 8X/iLx6a05sd//P++Ii+QsW317eXd0zFybZJlWwLioJorxmlsoWzw5Jeii9AYyUsnbhCrsEk tejQnxLfQbMKhinYzrsrieDtYWfwGcPfkrpnpqDrLqlBhKqLHjkSZzUJxivTyL1sotfANb4n 2Hl1ULxCWBFvVfZaJbSZD5LdRVEbRIjiJvjQsroTi2ElebCpzRC429tcGaPhSEfz2x7fYJC2 LsKJPRPHQl+rQx1xjCRwowp8X7qOUNq5FTi6mwWUVsHpSmKC0bw9NPLh1p8NXjKrMvpsqJgI oX+PQXSRLhaeAXVa0OFtXTiFBhC5mUVUdCH8ABrevK3M+LuI6Jf7AbQ2HYhU/tUYSZJoBhZ1 LmIZqj5dziu/2a5MpKNOtMHsbOClSiCb4aROkGhXNVUeOid0qYPLJTOgvM78u8bbRTfV2GzJ Bdof4U0VlpC/i8vRzaB2HY6Aat+UyTa+paQO+H0s2n5IgsMfKdbvDpKnqkiLk47HI3gAHKAn qKXUEw21JgMXinsPGdNaWfIJkrWjz/Ea9iu0lwMB1IABvhJLpuEFBbT71dGqf1m5hXZILn0m 6JLnriWlwa7eYYIo3+OP8M/U9x+v/zjDNwfef+i7fffw7ZGz1DBFKToRKyfO2ylGVmPI7Ug0 kOTKobcaBNS2Dki2ejiMXC3TqU0fBSLjTAoajkYtfATH7xq64hu4Fuqxl7AQlSO5MKypQxFi hcBxN8Bu6pNOpmiHa+DRgFPLlHzh0PLq1sT1XV4oHV4CvNlv78iQ8QvVCmJEZKL6DoIaft39 JrCCWm9voUV/3+HU7vPcT0OorRvoeWlZib+9/nj6ht6YMMbn97fj6Qj/Ob59/fTp09+Z4QPT DVDdWxIsfRVE06obnl2ACYAIaJODrqKGGZftJATGUft0CpV7Q5/fclOmOV32lXOXssnoh4OG wF2jDhh2ErR06PIq+Iw65hE7CnXIm5CQG0CUiie9QlmyK/O8kRrCySUbu+EPHBaCegIHAhVh MebHDpJbKyaR//9Y+qlCyv+EejC6njxJx0sORQIRTNU41Oh3A3tbGxKEK1vzBRHS+Lvmd397 eHs4Q0b3KxrvAjmXDH8hk+rnFPBJ8hLvScklihgfRfxMPRLvCYwh5kAOAqEcyhEZh99qCoI5 SAiF956B9ktJB5FV18cqHYSzBoxbJK8C3zuOuQc+wdyKsU2F8KVvaRuIU4bQ/FpMEDPl/HQG 6J3YayMutyQoh4ut06CAyIJp4ORVR0NUnd71ShT70BfF7uSQrtWq0aNzAs5gljdDrbUBy9At iJs7GWfSK/kZ1gTgeCj6HWqZfalZQsuKFm9GVLn56AatIl4d6kNbsIeCuRHwBBMmiGt1H1SC nkW+qjs1temqLVCPHO0EozdM3ZXUpd+ktfSfuaYHrgjf8QaAPz2uvM4zGswxq4qo9wEQuY2o AbGqggPcXstjDdqbJEW/IYMoqOWnEVsCAswS6fTNN5JWO9hXVi8tbapFleUmfjDnyoBooN+J GGBIspE/XpgxYPU2QblmZsJu7w5wBIXeGnBVFSqYKLNRzWaUhCKzsbo6abqdCnfcBJiUbN7q 6/rXcD3B1tFT4DEuDiynEEChGxPYuCPgw+n0XR7uJAFi2gjnbEpsSa9AxpZwD42vc+H9t4m4 cThrtNkEZdOG8cu9Gmz/oA7TPCYWagsxOnsauGOb7e5qIFJ+Q5itZ3orwE17QgulSUA0L6s9 wOMaiP2uSlqZqDDwc9hGUpINGBdU1lun6mZe8aWzZXZvn8CV2QSXqr0cWcdiyP4p8QLqGBUj 00ZwPbPpRgoW74yzAgvmEGQyYLlHtUuL1b9+uSCjLioRROwuwdcHpd3JFAqpI/AzpQYlWS06 Tb9dw4WOdjc4Add0urqUuCaXlw0pNlox7yZT0dBxt42ry9EYcIiKD438VaSubL2NfIDNjLfZ 2lE7GCGuXJNpMDZ5dk/YgVjfEegwumlgst0FJ55CmX1zfnt1zr9ngIhBaMYY6M8yToR8Gi6O DHSTJ4j1NGiE/GveHBEvssTQV8WyrlXPE5kkGimFbDNgJDeKbSaZmX2uqD7oXMaqdc0DU7m2 VhFZiry56W5Tbn/tj69vKKKhtiH9/ufx5eHReYhlP9SiW9gkwKAdkl6K+VUbrRjFqGQklvYj 7/Hu+QusmYHwW7L8j04VJgGKEvW9bolW/AcqOAJVyT6fknPIJBexCjVpviTGCjE2KBq7tTt9 FFNB+nRpD9dAoNkEEoa3gz6PjauoBIAkVAGjTLygVolM0QJWcNlnvZxHQautkF53sbz3hFIV Narw5TzChBH9Xl/unbZy3cVvjbUVneCULVx1a4xXW4CTg5YqVaUW7ig6SXhNL1dmLBJRuFbC XF4sUwaaoF1+iwafhRnUnhY6bj2SE8bgdWkjkyqtZQaMXknuVASePZR5Yej4MRXDwS1lsq1N jkOxAL0lz7s4HFm+DdzIcYwWHUrJWLEwtbEgXIIWmRTopHf+3kkCPw1ZNQvTb3T7sSpJD0C5 Y4KKm03sI/JD3ymyat04KWDR9Rp6ZLnNeMc2RVsdEtGnRO8bnavQ71Z457qbjdLVkGu//+W+ UgtL71iMFihLXqUg1EkqlakDqMss+qB5+DLKLAIs6q20eC8GqVK089L/ABXewipfDAIA --VS++wcV0S1rZb1Fb-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QHjuA6siY1+RlwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 10:47:39 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6FlFAKsiY19NTwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 10:47:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DD51DA0B76; Thu, 17 Sep 2020 10:47:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726373AbgIQIrY (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 04:47:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726241AbgIQIrX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 04:47:23 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA7D0C061756 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:22 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id w69so995034pgw.7 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=TA6OcLEDFUQ9qpFM/VfmsZehtp68guNS6V1Wug38hMA=; b=HG/p8OtMNJt3DU2dQ9qbZrDYYfxtJ1yHfmzDGy2+DvKn5KAtYBklDNcgaWqriMJR7T QKi/tQrMIzGJUomQakhUysfJPgrC3N/hmHFw+jMpo6aaRYRQU3PBn0OtGDpqVDPaRyV1 K64lZnsIL4rAsvBvNsjRsRVWVDTYU2UeqxcCAFuloKVKMXiUuaVUAYQk+bWGK0FBpLtX qMMxxjVsIn7aEdaeYEDjYGjKJJkdH8hblUgpPbwFrg6UpeMF+MP+4GU+gWDvwGRcVlHa IFkTYGGulSgbqwlFsRZXAjoE9Wn81CYYbQfvyhbTZ6WjrETt0igM0XKNY5RWIkQC5Qqv fPbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=TA6OcLEDFUQ9qpFM/VfmsZehtp68guNS6V1Wug38hMA=; b=cqeyp2KAWaSVw5F6QkXTDrOACQ186QZaspfcmrvRCl5YIPJQDz4tpi02v46efPDUrJ l6WcIAlM6ItGSNX7xjhoAN8o9Lk+asspbyhX56ZD2jktvRzl/WCKfFM2vvFkVqxkWk1X iG/IK9Bxti7q5Qq+WM52/aZaeNCP7kO7nS0UXL8WSHcI+q5+nMli4xcv7TYi5BLyQyBe 9RnzIpRu0YXwfgLgp5Q24rKjHmjFhEN4lApEsMSeXt3ZZGHdYzYYMPqgLEjZgAc6pY4/ m9I6Phvs7QORPUDpk9GvZm7ZrnHbAdadq6HIHu9gMbenTvZLX3RtfqKnLxy2MZ1BmhhJ Uj1g== X-Gm-Message-State: AOAM530GWiaNhjXEEKjGrQD4vqCW4nuvtdvu6a6pZgecm0SBbJtDRxQ0 rr5pxyy7py8XGcDO0zNTqoWK8ezs+m4YrWa8HCAx9h2LDMTWTncm5Bk8tH1EK8Un2uBIur43yOY oaKBBZGgHlLGXj0iVupv74xVw1mGjTv75CEg4a7ktTadvCM2rSVq0fM5tmDpl4Rbx1QwB+dtfJ9 7FLeguJeN08DA= X-Google-Smtp-Source: ABdhPJy+2YhIYObzfV77phmcp2UmHDPK1RrJqmYemdv0On6uAglDARSoIJlhbey92KAYkU+onC3EkUEhGJ6zxG2F6g== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:90b:15c6:: with SMTP id lh6mr715470pjb.0.1600332441228; Thu, 17 Sep 2020 01:47:21 -0700 (PDT) Date: Thu, 17 Sep 2020 16:47:10 +0800 Message-Id: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v2 1/6] Bluetooth: Update Adv monitor count upon removal From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: marcel@holtmann.org, luiz.dentz@gmail.com, mmandlik@chromium.org, mcchou@chromium.org, howardchung@google.com, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.66 / 15.00 / 15.00 X-Rspamd-Queue-Id: DD51DA0B76 X-Rspamd-UID: b9be06 From: Miao-chen Chou <mcchou@chromium.org> This fixes the count of Adv monitor upon monitor removal. The following test was performed. - Start two btmgmt consoles, issue a btmgmt advmon-remove command on one console and observe a MGMT_EV_ADV_MONITOR_REMOVED event on the other. Signed-off-by: Miao-chen Chou <mcchou@chromium.org> Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: - delete 'case 0x001c' in mgmt_config.c net/bluetooth/hci_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 8a2645a833013..f30a1f5950e15 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3061,6 +3061,7 @@ static int free_adv_monitor(int id, void *ptr, void *data) idr_remove(&hdev->adv_monitors_idr, monitor->handle); hci_free_adv_monitor(monitor); + hdev->adv_monitors_cnt--; return 0; } @@ -3077,6 +3078,7 @@ int hci_remove_adv_monitor(struct hci_dev *hdev, u16 handle) idr_remove(&hdev->adv_monitors_idr, monitor->handle); hci_free_adv_monitor(monitor); + hdev->adv_monitors_cnt--; } else { /* Remove all monitors if handle is 0. */ idr_for_each(&hdev->adv_monitors_idr, &free_adv_monitor, hdev); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sJU6DMoiY19uYAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 10:48:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MBRsCcoiY1+EGQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 10:48:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BA0F8A0979; Thu, 17 Sep 2020 10:48:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726498AbgIQIrj (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 04:47:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726493AbgIQIri (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 04:47:38 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B01DC061351 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:37 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id a14so1129810qtp.15 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=UhuK6+MhkgaxqFHbZntBmCr9unC/T/VqbfwHczdbfRY=; b=qXt5f0VOk1NuPgsYlWvkIK0xsQnwgp2Ib9s9qNNRYd2jjziI2ZkbqiZEZBy98FogDJ VkQH+qcfsU34O/22zMmtsfltxbnOCDtMgwsX5Lc/8k2R7cjQi1onQqjZ851o8nTg/Dv8 oZeMwO8/vKRK61+eC+t0c1rnhq1va2f3hQ2nYCo+jNWzFQ8GtCX7sZLpwf5M7C8vhWZA pqk86IdYJNlRUkB6lyzfodAMn0NZvW7zupX/Q2VOt2ig2Jxt5lVTT9aUjoEfUj49um6v Zbl2j7AfHKhKAPRyRigq2h7vqLeyDTWtGAJwyewpwVbDjlj8KD16Dh7BRY9T3yxWXmd9 uLbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=UhuK6+MhkgaxqFHbZntBmCr9unC/T/VqbfwHczdbfRY=; b=WqgZqH79BXzJZe0y2J6p092I0e3qspT1VbNA8Wc59uKaD8LyPB+vIFwIHQnya45DnF 0heI46P+fEAW0oVGruia23vJlFGcnAdYQCckT5qJ8YWKuLidKc6F0y2Onon7psi6x4cx ezqf3/rgnwTZpBBrvjbVg63ZMroOCSOanbjhhfpV7jSmpslzfvhp3/BTEBSokoP5yUUD QLIlVDeAUujvuVeXX0eU0+t8+RZVxcXqKWtiuLV9FV9gZHFODo/qK84iZrH0DoEBNI14 JkhdXy+0gzN+TnVJDzOxRA0PgML7cDFTHeI7SShhin34K4FkezR3bFwovBJbvDWDxSxW TkPw== X-Gm-Message-State: AOAM532fjYyHqNrtRNHrpmCLI+3lbrzq631jGRMERBKpknTvQWbIOeXN EYP1cBp1lOkNiwfRENQnEuqKJCvIaT3mFexVNogUWUXUp/NGwegEFpMrOP47DuKwjYrPInKLFKp d/ad8E8GawW6CdUA1UiS8YpkjfDi0USBvUuaWy6pQVa82P9zumB9qrFOMXRd1AHD+MiJNJYnSez AYcnMw80xO7A0= X-Google-Smtp-Source: ABdhPJzmrOX6EdMHFDJQGtaf1jHPst8t8hO4cIyNRCqT0Rc+SxpDoI51AMdKKtlEiFVuWa5OuFK9wrM0HWg3g2dx/g== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:58e3:: with SMTP id di3mr11174814qvb.54.1600332456529; Thu, 17 Sep 2020 01:47:36 -0700 (PDT) Date: Thu, 17 Sep 2020 16:47:14 +0800 In-Reply-To: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200917164632.BlueZ.v2.5.I21e5741249e78c560ca377499ba06b56c7214985@changeid> Mime-Version: 1.0 References: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v2 5/6] Bluetooth: Handle active scan case From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: marcel@holtmann.org, luiz.dentz@gmail.com, mmandlik@chromium.org, mcchou@chromium.org, howardchung@google.com, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.52 / 15.00 / 15.00 X-Rspamd-Queue-Id: BA0F8A0979 X-Rspamd-UID: 92cf7c This patch adds code to handle the active scan during interleave scan. The interleave scan will be canceled when users start active scan, and it will be restarted after active scan stopped. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) net/bluetooth/hci_request.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index d9082019b6386..1fcf6736811e4 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -3085,8 +3085,10 @@ static int active_scan(struct hci_request *req, unsigned long opt) * running. Thus, we should temporarily stop it in order to set the * discovery scanning parameters. */ - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { hci_req_add_le_scan_disable(req, false); + cancel_interleave_scan(hdev); + } /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AOVdOtUiY19uYAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 10:48:21 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 4BAyN9UiY18bowAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 10:48:21 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6D116A0B96; Thu, 17 Sep 2020 10:48:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726526AbgIQIro (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 04:47:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbgIQIrl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 04:47:41 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 387CBC061788 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:41 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id 139so1058004qkl.11 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=kL2AQmKmQ8DRMKjtBMJBwyEAwBYPLpPCmkHC9nftMgY=; b=fgXrxwl5WGPHQG8YKqyWsKa+CPdKEMhNFS4ZyclxNkVJqc25wKfupVBKvCKG6haRzC 0TBWGdEgUhbiblMCalHV7r39WltR8n+867Sh825ejjZPfMAUeAOVcCA8uWA91UdO1q09 rBfY0YRvul6BhI5xFScawLndUs39LHNgfoS6sMd2OOQ0BBsL8fWi56CjRgKL7w74mZLT WdjeAueIV0Z9LX+87sesrytlq2Xa6FS3WpVUqbyiukolI7Y/2GE3ArMPaUux2JBaHiQ/ SvjeabzpQfozVT//Xr828aSEJVLIVBv+6TtSP5G6PTem8xH83EcFNnwWhXE4XEBLPv6p rWvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=kL2AQmKmQ8DRMKjtBMJBwyEAwBYPLpPCmkHC9nftMgY=; b=XRD129lU1D0ZknlZXT16Ra2oFfxAUSiOW8uFTsnTy8nM45IOOW/xRABfRgMIBpsVY/ QWUf4T7MZW4Uy4uH/wVuktSaqNx+T5YG7i5S4GTlt9+ElsK9NdqKskdVTTImRAM8fLUc UTpteN5jZQBF8tmj5q8UCkO47oEhSW/1B3udQ22gW5Lhd7HyLYzPgCvn4bw1ZbEU0J5d I/6j0QpHQvXKfOH5o3LnS+ZgvEVQOEsgj0dzEld3fsa5grWzXASSxb/cg2918FKoBJ07 9LQN+Bi1jaAvwUy0aN3mrYh2xvUV4ZzGFFQAleA2m0yl5q6qkYLOm4V2UglidYLHRQtJ E2OA== X-Gm-Message-State: AOAM5336AsPNCKGaxQ2nfbIr5aG1d1pBQilwAsrdnZhG7d0zXPVITmdq 6KQ6lBNBu05HgAu1NCyPnx7JeoBH8zOVI2oyB4ThmlpsDvjR9TnFABjQ621NcA1ItMDSLrdp0h1 0LHZMPFeLjIkBZKw9eVBisWk+D8Ru98j9gP1dFr+MjnHH/3jN5QJ+bhkx1RnrdsCLSt5L6E2VUa 76szbgrIhKnQE= X-Google-Smtp-Source: ABdhPJyNGGCWI5ydqkiZgandDqVu55u47O7nGmUqX2w1Bd9eqbdqO7yMoMa6S7yTGTAh34aYZvpS9plvu9PUEnoVRw== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:5a0e:: with SMTP id ei14mr12731226qvb.15.1600332460122; Thu, 17 Sep 2020 01:47:40 -0700 (PDT) Date: Thu, 17 Sep 2020 16:47:15 +0800 In-Reply-To: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200917164632.BlueZ.v2.6.I756c1fecc03bcc0cd94400b4992cd7e743f4b3e2@changeid> Mime-Version: 1.0 References: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v2 6/6] Bluetooth: Add toggle to switch off interleave scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: marcel@holtmann.org, luiz.dentz@gmail.com, mmandlik@chromium.org, mcchou@chromium.org, howardchung@google.com, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.95 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6D116A0B96 X-Rspamd-UID: b7f0eb This patch add a configurable parameter to switch off the interleave scan feature. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> --- (no changes since v1) include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 1 + net/bluetooth/hci_request.c | 3 ++- net/bluetooth/mgmt_config.c | 6 ++++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 179350f869fdb..c3253f1cac0c2 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -363,6 +363,7 @@ struct hci_dev { __u32 clock; __u16 advmon_allowlist_duration; __u16 advmon_no_filter_duration; + __u16 enable_advmon_interleave_scan; __u16 devid_source; __u16 devid_vendor; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6c8850149265a..4608715860cce 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3595,6 +3595,7 @@ struct hci_dev *hci_alloc_dev(void) /* The default values will be chosen in the future */ hdev->advmon_allowlist_duration = 300; hdev->advmon_no_filter_duration = 500; + hdev->enable_advmon_interleave_scan = 0x0001; /* Default to enable */ hdev->sniff_max_interval = 800; hdev->sniff_min_interval = 80; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 1fcf6736811e4..bb38e1dead68f 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -500,7 +500,8 @@ static void __hci_update_background_scan(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) hci_req_add_le_scan_disable(req, false); - if (!update_adv_monitor_scan_state(hdev)) { + if (!hdev->enable_advmon_interleave_scan || + !update_adv_monitor_scan_state(hdev)) { hci_req_add_le_passive_scan(req); bt_dev_dbg(hdev, "%s starting background scanning", hdev->name); diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index 1802f7023158c..b4198c33a1b72 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -69,6 +69,7 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, def_le_autoconnect_timeout), HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), + HDEV_PARAM_U16(0x001f, enable_advmon_interleave_scan), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -142,6 +143,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x001b: case 0x001d: case 0x001e: + case 0x001f: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -263,6 +265,10 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, hdev->advmon_no_filter_duration = TLV_GET_LE16(buffer); break; + case 0x0001f: + hdev->enable_advmon_interleave_scan = + TLV_GET_LE16(buffer); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WM18FyYjY1+RlwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 10:49:42 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wKDfFCYjY19iVQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 10:49:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F3906A0B81; Thu, 17 Sep 2020 10:49:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726609AbgIQIs4 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 04:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726474AbgIQIrf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 04:47:35 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1682DC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:35 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id s204so956872pfs.18 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=FNIQ4TwzUmm1KHmokSEwCEB+0kpJ2JKM9cy2f0sja/s=; b=msz2NcBEHBn4//yvvlA9BvhRf9AbMQ4vFBBmV31mMDu/xsybwVA8JKpGL8YwGWRTkK C9dMyGQvzuutz7TlFpLoA/NBVj2arKtETcrRIRgihU50mn/CbHx1GuXnNSXeQZToOvKr YfRth3WHQ5gRXi3M9OmExnLIummqxyxMu0WVTQtHleO6IvGYoT/6KrbRB23ajEqNSYlt uwvdVtyB7wgxutDSPNaNMOR1uZ9qjBusTRqcHREfQEbW9EdmF75ccCe/O0rTbmVKNA+L yyMcvXj3zUc1QNX3ERlxjWJfytcDFCAJAYvEwPhE7O8YXBuY/PGfqTB10LGtUyzhK/r0 aTsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=FNIQ4TwzUmm1KHmokSEwCEB+0kpJ2JKM9cy2f0sja/s=; b=CHZ1QYQdlN7RP1c4Wm+Cx1Am5iZT2bc8QWjv/yRL+ZVQPhVZ82tzOoZNfMU54BKdHE fS97S+QEM5oXQ8QNIK8h1XEWdYUokHKHB8VL4HgFZFWe5VTG5zxLOhdDWqCPyGVp6Uaz Zs1xk1+ejGa8Pd5zt6Uq0G8tjpXf5G9+bA75O8oqY3/6h+1DJ3kxjjRw4ZZSnn/5cqr3 +k9Zcrdfwm6fE38VkScdsFDTmjMkvkgENmlekwBVFbhzsz0ECDbcNTt9m8TbuGw1miur EPGK6hOjHUBCbZCUUAAeqeTh1FJD2QdGHZYBeDI0NFIGs55B1F4Pqn9+CHobvQsd4fnt oKYw== X-Gm-Message-State: AOAM53091YL0FhIb4ajGTjCKIpNCf+5Q4VQi+Kh0grXlywTFJY1mSzyy 8pNd+c/o9ZdT8d9/gi0vgwKWJYKYmZSb0IUzyElI+Iy+hkqDF+UbyWN1qt4kuTeOMY3I9RFKO/q aa04eUWyFdITAskV5GZEscAcjfpPIW70+vcwuW+mMhYuZ0p+5/bchVQVDrCEtopGdxbkCcY6KRP if7o0rrO+QpYY= X-Google-Smtp-Source: ABdhPJyZ5zr8aCmSNqrsGqhZ7eOqE5l90QCLj+GHKNbZg3/YWweber23RTxxs6jdmYjWgzSEI1Z9EfXTAg39J3fMNw== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:90b:941:: with SMTP id dw1mr715085pjb.1.1600332452758; Thu, 17 Sep 2020 01:47:32 -0700 (PDT) Date: Thu, 17 Sep 2020 16:47:13 +0800 In-Reply-To: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200917164632.BlueZ.v2.4.I3774a8f0d748c7c6ec3402c4adcead32810c9164@changeid> Mime-Version: 1.0 References: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v2 4/6] Bluetooth: Handle system suspend resume case From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: marcel@holtmann.org, luiz.dentz@gmail.com, mmandlik@chromium.org, mcchou@chromium.org, howardchung@google.com, alainm@chromium.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.97 / 15.00 / 15.00 X-Rspamd-Queue-Id: F3906A0B81 X-Rspamd-UID: b187db This patch adds code to handle the system suspension during interleave scan. The interleave scan will be canceled when the system is going to sleep, and will be restarted after waking up. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- (no changes since v1) net/bluetooth/hci_request.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 89443b48d90ce..d9082019b6386 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1081,6 +1081,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) filter_policy |= 0x02; if (hdev->suspended) { + /* Block suspend notifier on response */ + set_bit(SUSPEND_SCAN_ENABLE, hdev->suspend_tasks); + window = hdev->le_scan_window_suspend; interval = hdev->le_scan_int_suspend; } else if (hci_is_le_conn_scanning(hdev)) { @@ -1167,10 +1170,8 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ - hci_req_add_le_passive_scan(req); + __hci_update_background_scan(req); - /* Block suspend notifier on response */ - set_bit(SUSPEND_SCAN_ENABLE, req->hdev->suspend_tasks); } static void cancel_adv_timeout(struct hci_dev *hdev) @@ -1282,8 +1283,10 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan); /* Disable LE passive scan if enabled */ - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { + cancel_interleave_scan(hdev); hci_req_add_le_scan_disable(&req, false); + } /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0DwpEFQjY1/2LwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 10:50:28 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wJv7DFQjY182NAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 10:50:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5C4BBA0B12; Thu, 17 Sep 2020 10:50:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726619AbgIQItP (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 04:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgIQIra (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 04:47:30 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6747C06178A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:29 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id di5so967277qvb.13 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=wGykX3HXy8uSGQU5AA3HqLAsLKRSAYz8xcbgVSMez4w=; b=GG59YQAeIPF3uMOrO5tePJPwi80CAvyUoaYrB+PKM3NLo811iPRwRTWaJxgdrwiYuO mbUxWfBFtKeOlTuPzSnSkmtHKIL0LYjjf9WoXrsNMkbshNCX2IT5VL+AsV1D7BeGPYjt wha0GOuRy3kaKTX+qYosplB5xCq50AuF6+eB21odgFjn9CLViL31XeJhCV9wTHV0dM+c 2qVqvHKi4qBSmXKeIzjcFYcCkravGPskJoDkkv88BSQx5bXLgeaXkl7DWEDy/qY+n7ES mYqHjcKmR8AbcaWnXR+ObYGQ5f7MX5fQWRHKKXe+XeqOAvMkQ3zgeOEAMkUw3nRyhBgD ZlJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=wGykX3HXy8uSGQU5AA3HqLAsLKRSAYz8xcbgVSMez4w=; b=tjuGsuVDrvOJ4/jFOjmYcc6fXeCkvFuJyXXu3OyzBD4u2Jw0G4YIgF9SU4S8XisXKn fx08Bt6/DbC4IrN7pFZMP023C68u+ho1WoUqUQQ0OyWUia9GAodhNy91OI6J2MbooB6k CW61x7UpeMZJ2L/KEVNE8Gg2LdZ5o7Keesa/nq/lDVS9cvXLxGRg2vPP3dx+UEegL8bQ u7slZWFVLf3oefIH/iSQDmM8Uua9sYJ5HPSmabIh3IBGauqvV3GEM/tNZFDW0dvYCRKj XvDPNDMThAsUOcS6fa0H/Z9y/Z1InE+BzFxBSVZ/BuYBV7NzCEcZexNa5jYJCocnZgbj 4BvA== X-Gm-Message-State: AOAM531D5jpRuVFzxIUzVsO8GGyyejZ1MKkXhekDKdjAgRl7IzYOQwUH Rg4hFO4/DDKc6hZF92DnxQ69XNVXKFie12K+2A+R/WFD8v1siMOjqafqenPkt2NGcniY/ryCjbl 3Ctsbbn+0cSI1SSPmFd3VVVQPMqGUIdi5TeAfs6+UwAP/EtsFiRDGpMphawPcD8u8dGMd7yTGjJ l3vDywOmNid8A= X-Google-Smtp-Source: ABdhPJxGj+Q9BZ6wsmjP938dzB3v+npuVzH0FOG5OvkRUnc8Ltl2fmZFJzYqkmYpZVE6l4JQ/QwGWFdMn2k2vK7cTw== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:57a7:: with SMTP id g7mr27601946qvx.10.1600332448783; Thu, 17 Sep 2020 01:47:28 -0700 (PDT) Date: Thu, 17 Sep 2020 16:47:12 +0800 In-Reply-To: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200917164632.BlueZ.v2.3.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Mime-Version: 1.0 References: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v2 3/6] Bluetooth: Interleave with allowlist scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: marcel@holtmann.org, luiz.dentz@gmail.com, mmandlik@chromium.org, mcchou@chromium.org, howardchung@google.com, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.72 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5C4BBA0B12 X-Rspamd-UID: fccd88 This patch implements the interleaving between allowlist scan and no-filter scan. It'll be used to save power when at least one monitor is registered and at least one pending connection or one device to be scanned for. The durations of the allowlist scan and the no-filter scan are controlled by MGMT command: Set Default System Configuration. The default values are set randomly for now. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v2: - remove 'case 0x001c' in mgmt_config.c include/net/bluetooth/hci_core.h | 10 +++ net/bluetooth/hci_core.c | 4 + net/bluetooth/hci_request.c | 137 +++++++++++++++++++++++++++++-- net/bluetooth/mgmt_config.c | 12 +++ 4 files changed, 155 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9873e1c8cd163..179350f869fdb 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -361,6 +361,8 @@ struct hci_dev { __u8 ssp_debug_mode; __u8 hw_error_code; __u32 clock; + __u16 advmon_allowlist_duration; + __u16 advmon_no_filter_duration; __u16 devid_source; __u16 devid_vendor; @@ -542,6 +544,14 @@ struct hci_dev { struct delayed_work rpa_expired; bdaddr_t rpa; + enum { + ADV_MONITOR_SCAN_NONE, + ADV_MONITOR_SCAN_NO_FILTER, + ADV_MONITOR_SCAN_ALLOWLIST + } adv_monitor_scan_state; + + struct delayed_work interleave_adv_monitor_scan; + #if IS_ENABLED(CONFIG_BT_LEDS) struct led_trigger *power_led; #endif diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f30a1f5950e15..6c8850149265a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3592,6 +3592,10 @@ struct hci_dev *hci_alloc_dev(void) hdev->cur_adv_instance = 0x00; hdev->adv_instance_timeout = 0; + /* The default values will be chosen in the future */ + hdev->advmon_allowlist_duration = 300; + hdev->advmon_no_filter_duration = 500; + hdev->sniff_max_interval = 800; hdev->sniff_min_interval = 80; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index d2b06f5c93804..89443b48d90ce 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -378,6 +378,57 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable) hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type); } +static void start_interleave_scan(struct hci_dev *hdev) +{ + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; + queue_delayed_work(hdev->req_workqueue, + &hdev->interleave_adv_monitor_scan, 0); +} + +static bool is_interleave_scanning(struct hci_dev *hdev) +{ + return hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_NONE; +} + +static void cancel_interleave_scan(struct hci_dev *hdev) +{ + bt_dev_dbg(hdev, "%s cancelling interleave scan", hdev->name); + + cancel_delayed_work_sync(&hdev->interleave_adv_monitor_scan); + + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NONE; +} + +/* Return true if interleave_scan is running after exiting this function, + * otherwise, return false + */ +static bool update_adv_monitor_scan_state(struct hci_dev *hdev) +{ + if (!hci_is_adv_monitoring(hdev) || + (list_empty(&hdev->pend_le_conns) && + list_empty(&hdev->pend_le_reports))) { + if (is_interleave_scanning(hdev)) { + /* If the interleave condition no longer holds, cancel + * the existed interleave scan. + */ + cancel_interleave_scan(hdev); + } + return false; + } + + if (!is_interleave_scanning(hdev)) { + /* If there is at least one ADV monitors and one pending LE + * connection or one device to be scanned for, we should + * alternate between allowlist scan and one without any filters + * to save power. + */ + start_interleave_scan(hdev); + bt_dev_dbg(hdev, "%s starting interleave scan", hdev->name); + } + + return true; +} + /* This function controls the background scanning based on hdev->pend_le_conns * list. If there are pending LE connection we start the background scanning, * otherwise we stop it. @@ -449,9 +500,11 @@ static void __hci_update_background_scan(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) hci_req_add_le_scan_disable(req, false); - hci_req_add_le_passive_scan(req); - - BT_DBG("%s starting background scanning", hdev->name); + if (!update_adv_monitor_scan_state(hdev)) { + hci_req_add_le_passive_scan(req); + bt_dev_dbg(hdev, "%s starting background scanning", + hdev->name); + } } } @@ -844,12 +897,17 @@ static u8 update_white_list(struct hci_request *req) return 0x00; } - /* Once the controller offloading of advertisement monitor is in place, - * the if condition should include the support of MSFT extension - * support. If suspend is ongoing, whitelist should be the default to - * prevent waking by random advertisements. + /* Use the allowlist unless the following conditions are all true: + * - We are not currently suspending + * - There are 1 or more ADV monitors registered + * - Interleaved scanning is not currently using the allowlist + * + * Once the controller offloading of advertisement monitor is in place, + * the above condition should include the support of MSFT extension + * support. */ - if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended) + if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended && + hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_ALLOWLIST) return 0x00; /* Select filter policy to use white list */ @@ -1002,6 +1060,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) &own_addr_type)) return; + bt_dev_dbg(hdev, "interleave state %d", hdev->adv_monitor_scan_state); /* Adding or removing entries from the white list must * happen before enabling scanning. The controller does * not allow white list modification while scanning. @@ -1871,6 +1930,64 @@ static void adv_timeout_expire(struct work_struct *work) hci_dev_unlock(hdev); } +static int add_le_interleave_adv_monitor_scan(struct hci_request *req, + unsigned long opt) +{ + struct hci_dev *hdev = req->hdev; + int ret = 0; + + hci_dev_lock(hdev); + + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + hci_req_add_le_scan_disable(req, false); + hci_req_add_le_passive_scan(req); + + switch (hdev->adv_monitor_scan_state) { + case ADV_MONITOR_SCAN_ALLOWLIST: + bt_dev_dbg(hdev, "next state: allowlist"); + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; + break; + case ADV_MONITOR_SCAN_NO_FILTER: + bt_dev_dbg(hdev, "next state: no filter"); + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_ALLOWLIST; + break; + case ADV_MONITOR_SCAN_NONE: + default: + BT_ERR("unexpected error"); + ret = -1; + } + + hci_dev_unlock(hdev); + + return ret; +} + +static void interleave_adv_monitor_scan_work(struct work_struct *work) +{ + struct hci_dev *hdev = container_of(work, struct hci_dev, + interleave_adv_monitor_scan.work); + u8 status; + unsigned long timeout; + + if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_ALLOWLIST) { + timeout = msecs_to_jiffies(hdev->advmon_allowlist_duration); + } else if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_NO_FILTER) { + timeout = msecs_to_jiffies(hdev->advmon_no_filter_duration); + } else { + bt_dev_err(hdev, "unexpected error"); + return; + } + + hci_req_sync(hdev, add_le_interleave_adv_monitor_scan, 0, + HCI_CMD_TIMEOUT, &status); + + /* Don't continue interleaving if it was canceled */ + if (is_interleave_scanning(hdev)) { + queue_delayed_work(hdev->req_workqueue, + &hdev->interleave_adv_monitor_scan, timeout); + } +} + int hci_get_random_address(struct hci_dev *hdev, bool require_privacy, bool use_rpa, struct adv_info *adv_instance, u8 *own_addr_type, bdaddr_t *rand_addr) @@ -3292,6 +3409,8 @@ void hci_request_setup(struct hci_dev *hdev) INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); INIT_DELAYED_WORK(&hdev->le_scan_restart, le_scan_restart_work); INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire); + INIT_DELAYED_WORK(&hdev->interleave_adv_monitor_scan, + interleave_adv_monitor_scan_work); } void hci_request_cancel_all(struct hci_dev *hdev) @@ -3311,4 +3430,6 @@ void hci_request_cancel_all(struct hci_dev *hdev) cancel_delayed_work_sync(&hdev->adv_instance_expire); hdev->adv_instance_timeout = 0; } + + cancel_interleave_scan(hdev); } diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index b30b571f8caf8..1802f7023158c 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -67,6 +67,8 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, HDEV_PARAM_U16(0x001a, le_supv_timeout), HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b, def_le_autoconnect_timeout), + HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), + HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -138,6 +140,8 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x0019: case 0x001a: case 0x001b: + case 0x001d: + case 0x001e: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -251,6 +255,14 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, hdev->def_le_autoconnect_timeout = msecs_to_jiffies(TLV_GET_LE16(buffer)); break; + case 0x0001d: + hdev->advmon_allowlist_duration = + TLV_GET_LE16(buffer); + break; + case 0x0001e: + hdev->advmon_no_filter_duration = + TLV_GET_LE16(buffer); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6EsREGcjY1/2LwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 10:50:47 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +M7qDGcjY19pmQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 10:50:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6F880A0B17; Thu, 17 Sep 2020 10:50:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726421AbgIQIuA (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 04:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbgIQIr1 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 04:47:27 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D272C061756 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:26 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id 60so1103673qtf.21 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 01:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=jbS6cNnfIa6p5stK1Reth2jOjANie62zi7bf38pOt7A=; b=VU8ABKyVEn1Vi1rt82lQk6xUqNGfYRWs/LonOCMsKotTAWQFAHyIc3lbKvYZpbOPbG MLBq1euoqVyrQDSTl1Hn497WOw8rPdkkXdwAPRWLRoO3izaUQ0UjsEBZy0e7IMHQMQwO IRMVs+oBTadkQl6tMo4NjAv7adnZrNFsliwjAXXvdoS3ZjEEyXB5LYnmzQG0ysyMOqa6 OpiqVFGN9mOfW0wyj9iRsAc6gYLNQC3atiD3JNtZgIht32e/aAOSTI4TTSlxkHc6NTVx t4DZGgU30FskG66Z23ockLs4ZBISMfw5G8QRp1cWpKjOSB7/Db0YOb6yROSj2czhoPRG iDLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jbS6cNnfIa6p5stK1Reth2jOjANie62zi7bf38pOt7A=; b=gJeaUnWqdVnFta1KzmvmM7TifCeoqroYpqyiDo5+uLacyi/Jvuo+Fgn74sU6n2X98Z BSKnZzpINdbotiTYvK1CFqROiHRpLyklupVLrrmaILg1+KHr2zIwGFcRYShVMzVoCoFS vvZi2tyc8ImzToitVsZpFA2bkz2f80NncC2BCQYHaKnDiGA7Rrl4AG3RzSITJN7y/8yB GgRpeLlP332ZZXPuWQhfioA1KPCZRR5YrXZrwiDvD2veZryWpQ97Af2w1o9eeLx6f2P1 ACs+ADkbRC+H3l0eoM6opQxJXVlGcc7uQ0k0v91TpjQFJgdgArPr1RJz7zljP4BO6GSu p+Mw== X-Gm-Message-State: AOAM530pA7WnDAVoQjAz6vf8ZRYc+mebT1grJAsJ8F/OppspFan5dsxV WiqhuvDoJhWidLKDEBYWUWA9+UOghbIjuZNI0uKeVMHPCH1REcmKhZRhvrhOifWhFZKxjwn5XR9 tFWhCc3kwXAwC5kvngATP+0HDgkIwtrh32EyItjmoUH4H9ehzXl1qqqEzZ/C/7mQ20LyjS5DTLt Woki071xIlb80= X-Google-Smtp-Source: ABdhPJwTNXeoAZcmFbhFvyRqDwANRZEt20ZmHgLpLRvnL2hVahKmCTmSyY44Xr1VsvT7WQAf5nhMs5ts+tK5asWQow== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a05:6214:14e8:: with SMTP id k8mr17144487qvw.19.1600332445243; Thu, 17 Sep 2020 01:47:25 -0700 (PDT) Date: Thu, 17 Sep 2020 16:47:11 +0800 In-Reply-To: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200917164632.BlueZ.v2.2.I8aafface41460f81241717da0498419a533bd165@changeid> Mime-Version: 1.0 References: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [BlueZ PATCH v2 2/6] Bluetooth: Set scan parameters for ADV Monitor From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: marcel@holtmann.org, luiz.dentz@gmail.com, mmandlik@chromium.org, mcchou@chromium.org, howardchung@google.com, alainm@chromium.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.22 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6F880A0B17 X-Rspamd-UID: 18b365 Set scan parameters when there is at least one Advertisement monitor. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- (no changes since v1) net/bluetooth/hci_request.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 413e3a5aabf54..d2b06f5c93804 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1027,6 +1027,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) } else if (hci_is_le_conn_scanning(hdev)) { window = hdev->le_scan_window_connect; interval = hdev->le_scan_int_connect; + } else if (hci_is_adv_monitoring(hdev)) { + window = hdev->le_scan_window_adv_monitor; + interval = hdev->le_scan_int_adv_monitor; } else { window = hdev->le_scan_window; interval = hdev->le_scan_interval; -- 2.28.0.618.gf4bc123cb7-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mLGVEbIwY1+YwgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 11:47:30 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qJEhDrIwY1/KDQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 11:47:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1009AA0B55; Thu, 17 Sep 2020 11:47:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726385AbgIQJrV (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 05:47:21 -0400 Received: from mslow2.mail.gandi.net ([217.70.178.242]:52592 "EHLO mslow2.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbgIQJrU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 05:47:20 -0400 X-Greylist: delayed 2229 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Sep 2020 05:47:20 EDT Received: from relay7-d.mail.gandi.net (unknown [217.70.183.200]) by mslow2.mail.gandi.net (Postfix) with ESMTP id 96A3C3A3028 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 08:56:29 +0000 (UTC) X-Originating-IP: 82.255.60.242 Received: from [192.168.0.28] (lns-bzn-39-82-255-60-242.adsl.proxad.net [82.255.60.242]) (Authenticated sender: hadess@hadess.net) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 8C0F620010; Thu, 17 Sep 2020 08:56:06 +0000 (UTC) Message-ID: <f1be58f4af1465d4790990b9b310ca394e63f2a9.camel@hadess.net> Subject: Re: [PATCH BlueZ v2] sixaxis: Fix crash caused by return of udev_device_get_property_value From: Bastien Nocera <hadess@hadess.net> To: Sonny Sasaka <sonnysasaka@chromium.org>, linux-bluetooth@vger.kernel.org Cc: Miao-chen Chou <mcchou@chromium.org>, Yoni Shavit <yshavit@chromium.org>, Alain Michaud <alainm@chromium.org> Date: Thu, 17 Sep 2020 10:56:05 +0200 In-Reply-To: <20200916223453.22537-1-sonnysasaka@chromium.org> References: <20200916223453.22537-1-sonnysasaka@chromium.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.37.90 (3.37.90-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.85 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1009AA0B55 X-Rspamd-UID: 3f6514 On Wed, 2020-09-16 at 15:34 -0700, Sonny Sasaka wrote: > From: Miao-chen Chou <mcchou@chromium.org> > > This adds a NULL check before calling sscanf(). > > Reviewed-by: Yoni Shavit <yshavit@chromium.org> > Reviewed-by: Alain Michaud <alainm@chromium.org> Looks good. Reviewed-by: Bastien Nocera <hadess@hadess.net> Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KNytIFM2Y19OCQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 12:11:31 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 2AY/HlM2Y1/DCgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 12:11:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9DC34A0B31; Thu, 17 Sep 2020 12:11:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbgIQKLO (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 06:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726606AbgIQKLE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 06:11:04 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21409C061788 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 03:11:03 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id p43so1207993qtb.23 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 03:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=sJWgbUXV7tBH1Nrf3exc56L3qAUgK89a+WyZAGRDQ00=; b=tXr9kxBN+1DeO1NclFjz9P101oud7t9jr3/SYWFi1j6/l5qz1wD1aBjR6Evbi5L3jk ff6Lcl9QX369PdkhkpA0YOrnur/T6DDY6jWssxKdtYZfAbFBr0UDFlnFJJ01GdP+PNoj Tu//Wr5W6u7hxL8BHBAd73T9GLPEjrMbXK2i4CQIFZL9DKPoTpNkF3ZcCJd+qsx3QlNR mJzU+HdkqCf/RqZ9ZA9873PFQHCdKBUvL6yT6Kbz/sLhAhZPy6Jva6H9iOG6Xkis6diW Q/N0sxvBEnz89hzOZXtdCQM9G3MYCGM5G2Os1hdTsT4POlQdIgUgnihH7hhBW/BpOIKp Au3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=sJWgbUXV7tBH1Nrf3exc56L3qAUgK89a+WyZAGRDQ00=; b=r5fWNIfGnCEDMLOOSqBY6GYfOFfk9tIL2qBi/y+zCw18JiLuoZgeqnAZO6R4RyILvp e93sgexbX8XvwSZriXeaBl5CEHIDYm3IlDMf/D9VCNzI0g74yyuyMLL/2KclSV1ewsib oI/S2QXnQIfsdA9T6R9QYyLjgh8nJTwmaEVcRMfSz708gI8IpLqPotP6R+iXTDc3e0++ PJu9cmFZt17GiNAgwtrBdI2qwRVrcDc58L6yxdwo7K54YAXpIzKpQ3+ZkYntkWJiD6r4 hLBYOd9Kf+zLP6hNxyzIIJ+FBZE6rsCWkso/c4yjQ/Kx78OcQCUKSu95Ht1iu3niHCc4 37NA== X-Gm-Message-State: AOAM533L0E42KQmrRrUOqQK+rZwVm0tWbyIXZhz0kkJddGR8ngB5SmDN FgxkHZa9i/gF/9YscZ78yJIk2e+2qC0QCQDgMr9NszoiReSVrMPwME46aF41NBYdJAcGzxnOfvY RhNc9+J87fbLXbfCrDNAWZ2qnTnVKuY/UgbRQOoW/y2Y+1+pBTO04e3gZBF7UeuogAX3B29qaLb mY X-Google-Smtp-Source: ABdhPJz/eapZ/gc9UKSZaUAcY88gjIx/FwwW9+oDol/bMcUBxGLnlzngSiMypax4DUu9AAewZIGVH/QutXyK X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a05:6214:c2:: with SMTP id f2mr11115403qvs.44.1600337462181; Thu, 17 Sep 2020 03:11:02 -0700 (PDT) Date: Thu, 17 Sep 2020 18:10:56 +0800 Message-Id: <20200917181031.v1.1.I67a8b8cd4def8166970ca37109db46d731b62bb6@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v1] Bluetooth: Check for encryption key size on connect From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.55 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9DC34A0B31 X-Rspamd-UID: e6d95d From: Archie Pusaka <apusaka@chromium.org> When receiving connection, we only check whether the link has been encrypted, but not the encryption key size of the link. This patch adds check for encryption key size, and reject L2CAP connection which size is below the specified threshold (default 7) with security block. Signed-off-by: Archie Pusaka <apusaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index ade83e224567..b4fc0ad38aaa 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4101,7 +4101,8 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn, /* Check if the ACL is secure enough (if not SDP) */ if (psm != cpu_to_le16(L2CAP_PSM_SDP) && - !hci_conn_check_link_mode(conn->hcon)) { + (!hci_conn_check_link_mode(conn->hcon) || + !l2cap_check_enc_key_size(conn->hcon))) { conn->disc_reason = HCI_ERROR_AUTH_FAILURE; result = L2CAP_CR_SEC_BLOCK; goto response; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mAw1MJthY18V6QEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 15:16:11 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id yARHLZthY194hQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 15:16:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=mg.codeaurora.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2340CA0B8E; Thu, 17 Sep 2020 15:16:07 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726741AbgIQNQE (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 09:16:04 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:64492 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726786AbgIQNP7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 09:15:59 -0400 X-Greylist: delayed 317 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Sep 2020 09:15:57 EDT DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1600348544; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=+exb4SkAt82PbgJkbLQGaVlcoCDQLiY2MVs1jWjuReQ=; b=EU43U2NOYf0JpJ/9zvhsmDS0fJ4UMIFgzrHaARfDczYu1Nlhs/pvOlR7J9g/da2EUniTqWXI O7pFsQgbVeBfqWqXAlUItyWyuSw+zwhDuA/oz0YmYactt+O2DW84IxpTJrRMTroLtQQV8s3X Ot3eXIPw/uzPYXNMLGMox671AVU= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI2MTA3ZSIsICJsaW51eC1ibHVldG9vdGhAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n06.prod.us-east-1.postgun.com with SMTP id 5f63603af1e3eb89c7f05a89 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 17 Sep 2020 13:10:18 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 7145AC433F1; Thu, 17 Sep 2020 13:10:17 +0000 (UTC) Received: from localhost.localdomain (unknown [139.227.220.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rjliao) by smtp.codeaurora.org (Postfix) with ESMTPSA id 79E1DC433CA; Thu, 17 Sep 2020 13:10:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 79E1DC433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=rjliao@codeaurora.org From: Rocky Liao <rjliao@codeaurora.org> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, Rocky Liao <rjliao@codeaurora.org> Subject: [PATCH v1] Bluetooth: btusb: Enable wide band speech support for BTUSB_QCA_ROME Date: Thu, 17 Sep 2020 21:09:23 +0800 Message-Id: <20200917130923.15237-1-rjliao@codeaurora.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.55 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2340CA0B8E X-Rspamd-UID: b72d32 QCA Rome supports wide band speech, this patch enables the wide band speech support by set the BTUSB_WIDEBAND_SPEECH flag. Signed-off-by: Rocky Liao <rjliao@codeaurora.org> --- drivers/bluetooth/btusb.c | 54 ++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index fe80588c7bd3..9f294b941943 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -254,24 +254,42 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 }, /* QCA ROME chipset */ - { USB_DEVICE(0x0cf3, 0x535b), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x0cf3, 0xe007), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x0cf3, 0xe009), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x0cf3, 0xe010), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x0cf3, 0xe300), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x0cf3, 0xe301), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x0cf3, 0xe360), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x0489, 0xe092), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x0489, 0xe09f), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x0489, 0xe0a2), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x04ca, 0x3011), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x04ca, 0x3015), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x04ca, 0x3016), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x04ca, 0x301a), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x04ca, 0x3021), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x13d3, 0x3491), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME }, - { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME }, + { USB_DEVICE(0x0cf3, 0x535b), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0cf3, 0xe007), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0cf3, 0xe009), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0cf3, 0xe010), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0cf3, 0xe300), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0cf3, 0xe301), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0cf3, 0xe360), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0489, 0xe092), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0489, 0xe09f), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0489, 0xe0a2), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x04ca, 0x3011), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x04ca, 0x3015), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x04ca, 0x3016), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x04ca, 0x301a), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x04ca, 0x3021), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3491), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, /* Broadcom BCM2035 */ { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kClzLYeXY1//WQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 19:06:15 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2MxTKoeXY18vvAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 19:06:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 72307A0B66; Thu, 17 Sep 2020 19:06:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726915AbgIQRF5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 13:05:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726861AbgIQRFw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 13:05:52 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E29CFC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 10:05:51 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id z26so3245715oih.12 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 10:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VMLVYDWBjclWEI28bzU/NR4Kp0EA+W5FtgNf/T9DsOg=; b=GObppxl7EHVcxkMQH/tGWkHFLMBMj976QXJ7ndlydzrYsFK133i1KUNdtxoHrIPEWu azoZtDTfb/r9tN2JbVLFXrWOOBhJ2RXa1Ud9vmm8GE1D/JShQmGpP9mVvdiXCJrCBJIt SeJtay1TLvInMktHm2ZxMqrPyV64GJBJcsFf83hDkfjKwdGcYUVC6lh7HpwMRaWCGE/T A4Pq+TCZVVM54/4iB/gaYrOIHRjEKoEz3hyc9HkTdDcRZY8IEmNMQY2jJVWL6/D/QbvC 7djGCpSJgglEbRtspeSk8HrcyKZ4XHsdcGotvaFPCqag6/XtxomnWyfwQ675XJcW/2x3 b9vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VMLVYDWBjclWEI28bzU/NR4Kp0EA+W5FtgNf/T9DsOg=; b=a3WvzHpDniDyBQgaqwXSNF9kN6UYbqcbSojLH0HkN/r94ls0xXHV2xB/3qTYrQQwuW hQ7BQNfFwAIQxaEox/xaKwTM/jsWsFiNHvMraaZwqAKMw7NhGt20liA7GP524ZQMisiy UFWBkegj+Hgn6M64WM7eEiEsjGmxNrKcv/vynl9kb1ZtHibHYZaNQ7Pm3+CCT0NPY2+1 h50gF2S8yJQUKdaizb+qUDwMrQgNVAQ8HB8fMlZQma05FnGFOjwaP9mSE9jxRh435RC5 hyI30tHMhboAJZdn6kDhtbCta1FtqxZtql1nlvF/m/iy4FMmmPxlr+GNKtONuxtco15A PQLQ== X-Gm-Message-State: AOAM5308WpoIaqpKicDpSaY1Svql+36b5YF2p5+D7jv71eIWM5S0QFQr oSLPQHD63o89JwTRMY4Si532+TF6/DcvEbSEKqw= X-Google-Smtp-Source: ABdhPJzheNq2MocKsTYsqrMs6tBwmI6+gMwymsa+ynFew2IsLxrlzSl3csuDov7LcHAc3iUEQ6TbIwKLvu8Z2LUhv78= X-Received: by 2002:aca:1b01:: with SMTP id b1mr7170307oib.137.1600362350939; Thu, 17 Sep 2020 10:05:50 -0700 (PDT) MIME-Version: 1.0 References: <20200916223453.22537-1-sonnysasaka@chromium.org> In-Reply-To: <20200916223453.22537-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 17 Sep 2020 10:05:39 -0700 Message-ID: <CABBYNZ+Vjs0R+Vxhk0V4rbf_kQ7sFdDZtaM0+pjtfN4hz-maxA@mail.gmail.com> Subject: Re: [PATCH BlueZ v2] sixaxis: Fix crash caused by return of udev_device_get_property_value To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Miao-chen Chou <mcchou@chromium.org>, Yoni Shavit <yshavit@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.85 / 15.00 / 15.00 X-Rspamd-Queue-Id: 72307A0B66 X-Rspamd-UID: 3d568b Hi Sonny, On Wed, Sep 16, 2020 at 3:37 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > From: Miao-chen Chou <mcchou@chromium.org> > > This adds a NULL check before calling sscanf(). > > Reviewed-by: Yoni Shavit <yshavit@chromium.org> > Reviewed-by: Alain Michaud <alainm@chromium.org> > > --- > plugins/sixaxis.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c > index 939fed759..996f85dd6 100644 > --- a/plugins/sixaxis.c > +++ b/plugins/sixaxis.c > @@ -411,7 +411,7 @@ get_pairing_type_for_device(struct udev_device *udevice, uint16_t *bus, > > hid_id = udev_device_get_property_value(hid_parent, "HID_ID"); > > - if (sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3) > + if (!hid_id || sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3) > return NULL; > > cp = get_pairing(vid, pid); > -- > 2.26.2 Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MGpWLQSYY18BYAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 19:08:20 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id MJ90KgSYY1/tggEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 19:08:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 05A4040984; Thu, 17 Sep 2020 19:08:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727115AbgIQRH5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 13:07:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727102AbgIQRHq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 13:07:46 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB732C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 10:07:11 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id 60so2597313otw.3 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 10:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xL7o0moQLOuLb4VqMYy2UOe7s5yYUhMOpghHZTauRKY=; b=BYLgtnPNv0pLD4FyaMzO05l5MnZGGgI0g45likrAMwmuZEKXA9Ms9EKVXv2kBKM1Da 6VsKxziCITqzYKmmusc0jLl7noB7Cx0uQWXOFKlV4xARdJKdPBLFLBOZc13DxXwlHLRL nrsc9KMFPThHKgKpErq0jd/My5jEfL8VQ/fOrRRrNfazXZxQjIx9Qp+WFxVXNpCz567y KiaoLWIJHNsLT8wTO39Iulyv3YDTtHWRPqVl7KN2qTrsdwW44zd33bCO7nzkIOwdEI+U AF9AzGV190vVhvG7TDD/vrObRXOVGtwkW6xxOYGeW0aZkBrw6wmrK70+OAyliOgt721x JQbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xL7o0moQLOuLb4VqMYy2UOe7s5yYUhMOpghHZTauRKY=; b=uTT8t1ty6hO1D4pyekk/5lVeXW3o9W5SPywQzE1NnQr+yuyej/yEfKhCI+m3gxRB3t 1rC2RKXb51vAhPUNlpkkxKvFoJbmexxw8v+qwohpvWiMFkUr6e8LwUZcF9oBHEsT1FNB sRlobQPjnP4nm4mDyjc5kY35W/wExl+lNsgX8xKtRDum4Ug42yyU1L73OV18fZVxXjB3 AFnIpSI61tBy9Zie+zKkrJRiaWlI0dvvev1RYOTFZL2/+j2YXgq1qIprWrDFVxUNq4Hq KTmwxYVNVREJf3irQeNjOazDpatxBTDF9zfD7gz75CH7+fIYth/R/9YfwIzKDmDJsrKC 5m2g== X-Gm-Message-State: AOAM5303tDcSSaZ3tb9uFN3aXxQiHcBdkU4u++/5vwQ+AS8Op1Ew7OmI bxFc9sQCjQokdBUJPFH5fu8dZeVfvYVged6TmHfldThM X-Google-Smtp-Source: ABdhPJzUU8XH1ylyspqTz1T553d9v7tK2lBT7n+a0J1Hf6Mb6U4J2TsA0xvbD7uPso9V0z/HpZR8mdAAoBcalsvC6GU= X-Received: by 2002:a05:6830:22e6:: with SMTP id t6mr13833025otc.88.1600362431032; Thu, 17 Sep 2020 10:07:11 -0700 (PDT) MIME-Version: 1.0 References: <5f5baddc.1c69fb81.8c960.760a@mx.google.com> In-Reply-To: <5f5baddc.1c69fb81.8c960.760a@mx.google.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 17 Sep 2020 10:06:59 -0700 Message-ID: <CABBYNZ+sKWktscabOwRMQ6q=FyVoPr_vuADsUJzmkMXHM=VXQw@mail.gmail.com> Subject: Re: [RESEND Bluez PATCH v2] doc: Add Suspend and Resume events To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Marcel Holtmann <marcel@holtmann.org>, ChromeOS Bluetooth Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.09 / 15.00 / 15.00 X-Rspamd-Queue-Id: 05A4040984 X-Rspamd-UID: c7d036 Hi Abhishek, On Fri, Sep 11, 2020 at 10:03 AM Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Add Controller Suspend Event and Controller Resume Event to identify > suspend or resume of the Bluetooth stack has occurred. > > Also update Device Disconnected Event to indicate a new disconnect > reason: "Connection terminated by local host for suspend" > > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > --- > Re-sending along with kernel changes. > > Changes in v2: > - Moved Wake_Reason to first value > - Reduced Wake_Reason to not Bluetooth, unexpected event and remote wake > > doc/mgmt-api.txt | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 48 insertions(+) > > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt > index ca0d38469..e7a713824 100644 > --- a/doc/mgmt-api.txt > +++ b/doc/mgmt-api.txt > @@ -3834,6 +3834,7 @@ Device Disconnected Event > 2 Connection terminated by local host > 3 Connection terminated by remote host > 4 Connection terminated due to authentication failure > + 5 Connection terminated by local host for suspend > > Note that the local/remote distinction just determines which side > terminated the low-level connection, regardless of the > @@ -4577,3 +4578,50 @@ Advertisement Monitor Removed Event > > The event will only be sent to management sockets other than the > one through which the command was sent. > + > + > +Controller Suspend Event > +======================== > + > + Event code: 0x002d > + Controller Index: <controller_id> > + Event Parameters: Suspend_State (1 octet) > + > + This event indicates that the controller is suspended for host suspend. > + > + Possible values for the Suspend_State parameter: > + 0 Running (not disconnected) > + 1 Disconnected and not scanning > + 2 Page scanning and/or passive scanning. > + > + The value 0 is used for the running state and may be sent if the > + controller could not be configured to suspend properly. > + > + This event will be sent to all management sockets. > + > + > +Controller Resume Event > +======================= > + > + Event code: 0x002e > + Controller Index: <controller_id> > + Event Parameters: Wake_Reason (1 octet) > + Address (6 octets) > + Address_Type (1 octet) > + > + This event indicates that the controller has resumed from suspend. > + > + Possible values for the Wake_Reason parameter: > + 0 Resume from non-Bluetooth wake source > + 1 Wake due to unexpected event > + 2 Remote wake due to peer device connection > + > + Currently, we expect that only peer reconnections should wake us from > + the suspended state. Any other events that occurred while the system > + should have been suspended results in wake due to unexpected event. > + > + If the Wake_Reason is Remote wake due to connection, the address of the > + peer device that caused the event will be shared in Address and > + Address_Type. Otherwise, Address and Address_Type will both be zero. > + > + This event will be sent to all management sockets. > -- > 2.28.0.618.gf4bc123cb7-goog Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wDaWMaiYY19fQQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 19:11:04 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cLWiLaiYY18avAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 19:11:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1D9CA4096B; Thu, 17 Sep 2020 19:10:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727123AbgIQRKy (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 13:10:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727061AbgIQRGe (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 13:06:34 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 891E0C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 10:06:33 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id z26so3248280oih.12 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 10:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bEgouR3aTTkFIdM4Xvtxuyazd73zVsUgCpq6GdG2H78=; b=gHzsCq6Od2+sEboslx74I8Q6Pr9LR3f/79iJgY3oTzc42b9CN+yrZFDWEU1474nl10 drjJ+yfxEGtGLIAzTDzA/kvtPQeZBCNmyWSZIsa1CHxmKuNh3OLOC5MTHc1PKI/R21E2 BSl6s9ZgOg6jghOhIgU3n/aMIof0F9mTLef4dg1kapxqi701iPZOkspnSnCenHfFy+u7 MXvapWwAz+rYNOvIRBcKbQh+PdoBNi5QRbk2IfnlTTCMiwQYi3+TF2NRxu8vImv22MUw nPDpe4guXj3A78dS6Lb+CgFOa52nWckGl1cQtN7k+vFUvNHYcXFChEycHKCHrTwxGRQq aLgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bEgouR3aTTkFIdM4Xvtxuyazd73zVsUgCpq6GdG2H78=; b=D3NWtDP4G5aowDw1xysHWBO3rZwzIVw7qOrJr2SsxkcZ2Kz9JHFzo8a8cSJ46SFmbt ifDrtdBNIBGVyrlGEYvml80wRfYY5EtgKpROm3nx+XU+uvrfKkfwRCYf4L5Cw4MPmDmb 072yDiInt9CjpiBAgp41j9jMRgQW+6iFZlbN1Ob10/J5w62BeeGUrDvYkmXmKPzbHujR A+6O2QEdRJtPdZnwyyEk9r1pCOaXHHydRP5ZxPInTzBIuZDwW8ddnzKnusL6IXe3vLTH 9ntXNGfx8DrrC41WzMgC19tfVM+/jZV/0DY7qeHTtoW/EdXmjgsPDn3Mkf5MEnYttKL3 1hMg== X-Gm-Message-State: AOAM532Cwy/Az6QdOOY64MAxT8wRfr/64BMVQ/egD4MloFz4ViivhRWT 8LYWLByX5nfnX+EFyOAPIMNVtresH0dXeI2VAsQ= X-Google-Smtp-Source: ABdhPJx3Y2WJ3B+7PpdUg/QF9BIgzwfGATccvsB36Zf8jd1+k7xQALiMwweE+DyWdE5gg7A2cMLfcOKaEa2Dq0jv7xA= X-Received: by 2002:aca:1b01:: with SMTP id b1mr7172607oib.137.1600362392923; Thu, 17 Sep 2020 10:06:32 -0700 (PDT) MIME-Version: 1.0 References: <20200821061643.16278-1-sonnysasaka@chromium.org> <CAO271m=UWgjM1nLWzrwfvG4r3V7c6wdPDJk7EvRtW4cgsLXqhg@mail.gmail.com> In-Reply-To: <CAO271m=UWgjM1nLWzrwfvG4r3V7c6wdPDJk7EvRtW4cgsLXqhg@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 17 Sep 2020 10:06:21 -0700 Message-ID: <CABBYNZLwa74_xP_98vD6SvDu1d+YJ3yC=NxrPLB+SLy5AfwmDw@mail.gmail.com> Subject: Re: [PATCH BlueZ 1/2] gatt: StartNotify is not allowed when device is disconnecting To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: BlueZ <linux-bluetooth@vger.kernel.org>, Joseph Hwang <josephsih@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.85 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1D9CA4096B X-Rspamd-UID: 604ce8 Hi Sonny, On Wed, Sep 16, 2020 at 3:40 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > Dear BlueZ maintainers, > > Friendly ping to review this patch. Thanks! > > > On Thu, Aug 20, 2020 at 11:17 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > > > From: Joseph Hwang <josephsih@chromium.org> > > > > This patch fixed a bluetoothd crash in register_notify_cb(). The > > crash is incurred by an exception that under some situation, a > > characteristic may be freed when register_notify_cb() is invoked. > > > > When a device is disconnecting, the device interface would hold valid > > for a while until the disconnection procedure between the client and > > the server is completed. If another process happens to request to start > > notification of a characteristic on the disconnecting device, it may > > incur a problem. In this case, the client would still send the > > StartNotify request since the characteristic object is still valid. > > However, the characteristic may be freed soon and become invalid > > when the corresponding callback function is invoked later. This > > leads to the bluetoothd crash due to the segmentation fault. > > > > To handle the exception, if another process requests to start > > notification when the device is disconnecting, it should reject the > > request. > > > > Tested on Chrome OS that this patch fixes bluetoothd crash in > > register_notify_cb(). > > > > --- > > src/gatt-client.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/src/gatt-client.c b/src/gatt-client.c > > index 20c3fbec2..c706307c7 100644 > > --- a/src/gatt-client.c > > +++ b/src/gatt-client.c > > @@ -1545,6 +1545,12 @@ static DBusMessage *characteristic_start_notify(DBusConnection *conn, > > const char *sender = dbus_message_get_sender(msg); > > struct async_dbus_op *op; > > struct notify_client *client; > > + struct btd_device *device = chrc->service->client->device; > > + > > + if (device_is_disconnecting(device)) { > > + error("Device is disconnecting. StartNotify is not allowed."); > > + return btd_error_not_connected(msg); > > + } > > > > if (chrc->notify_io) > > return btd_error_not_permitted(msg, "Notify acquired"); > > -- > > 2.26.2 > > Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8MITICfSY19etwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:16:23 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id kIUdHSfSY18UuwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:16:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 02E34A0AAE; Thu, 17 Sep 2020 23:16:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726396AbgIQVQL (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:16:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbgIQVQL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:16:11 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19CFAC061351; Thu, 17 Sep 2020 14:16:11 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id x14so4168885oic.9; Thu, 17 Sep 2020 14:16:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AsrYKbcsJijPEVDhNCGN3B0ZQvVsWmRif4gtcVM+Ig8=; b=FtUH6ig8YVS7H8bq0navRcZiYF49TxzPX9fRzW7JKIGPgQLl2EM8/yhiD5j44bQ5N3 8KxclSLs7LhUcRssHDeyWFLIYh/uUBJpKkgAU36525ji5vAeQzRB2FNDpU416v06C7O9 r6h2rNPcrVHuP+G36S31dawRBJH6qkk/R0P9ZfpLNtlslHwcOGxepemxn5QBrd5j/zSm Plw7DpGnqv3XvZFroop5Ggan5mCF3sjgN5rFNIjFUXQKcpRYC7LPZbdygTtB3TUgeK87 Q5B0imxW6aNeVDmtvxlylz6TgcmnDq4LT0ys5o+2dYDdPm52aKc5S8w5FjKpqktuSPv0 QhtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AsrYKbcsJijPEVDhNCGN3B0ZQvVsWmRif4gtcVM+Ig8=; b=Ch6/oOMXUDydS65yn08UX0gPfm4UMLWtOPJiAHJvxhHvX7rhxoeIer+acGEVQHXlN8 i+k/+NGGfX4wdipLa61K91Jm9lmaYbAOmUNIn7xR4NuFHhTf26N+7zBTQvIX/a1qpGZd uNulk190FtSDLgxfrU6xXz7virIPKiAiQ4RPnLCob0EHvpJIf8Z5R2Od2xfJpL50pUjX K/JH4IYDZe69ycD28KWGfiZ/C/P8suPJRMCub6hG8hPVcD1XHbHJkN5JXStyP8cteD/I EhFzNBtrZcoj3+N5rFu181pf5rEP+1xTtjsB4ELhR4wZNioVxvTtk2S1ZNt46+BXsbkl 7hsA== X-Gm-Message-State: AOAM5304z7F2dsfkTbJDPkWqqqQnUxQXQGKYl3Yqm5ame1K3fkEE2O4b yl/fF1SCYt7WQxu9+1RuqW8cwMK1eHX5saFEDZk= X-Google-Smtp-Source: ABdhPJwgDDnl5tN43fme5AYZxwAY7UH2LIKkocXlWvtrFI5ouRKFJxpFRz92OcU3mU5hG8H7yUd4lgTV6f3PMlvsUpc= X-Received: by 2002:aca:1b01:: with SMTP id b1mr7789495oib.137.1600377370438; Thu, 17 Sep 2020 14:16:10 -0700 (PDT) MIME-Version: 1.0 References: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> In-Reply-To: <20200917164632.BlueZ.v2.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 17 Sep 2020 14:15:59 -0700 Message-ID: <CABBYNZJv2-GAsfOrUVjb+ZcTQz5TJBDvuCjFzMQm=N7_F0VYPg@mail.gmail.com> Subject: Re: [BlueZ PATCH v2 1/6] Bluetooth: Update Adv monitor count upon removal To: Howard Chung <howardchung@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.10 / 15.00 / 15.00 X-Rspamd-Queue-Id: 02E34A0AAE X-Rspamd-UID: aba0cd Hi Howard, On Thu, Sep 17, 2020 at 1:47 AM Howard Chung <howardchung@google.com> wrote: > > From: Miao-chen Chou <mcchou@chromium.org> > > This fixes the count of Adv monitor upon monitor removal. > > The following test was performed. > - Start two btmgmt consoles, issue a btmgmt advmon-remove command on one > console and observe a MGMT_EV_ADV_MONITOR_REMOVED event on the other. > > Signed-off-by: Miao-chen Chou <mcchou@chromium.org> > Signed-off-by: Howard Chung <howardchung@google.com> > Reviewed-by: Alain Michaud <alainm@chromium.org> > --- > > Changes in v2: > - delete 'case 0x001c' in mgmt_config.c > > net/bluetooth/hci_core.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index 8a2645a833013..f30a1f5950e15 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -3061,6 +3061,7 @@ static int free_adv_monitor(int id, void *ptr, void *data) > > idr_remove(&hdev->adv_monitors_idr, monitor->handle); > hci_free_adv_monitor(monitor); > + hdev->adv_monitors_cnt--; > > return 0; > } > @@ -3077,6 +3078,7 @@ int hci_remove_adv_monitor(struct hci_dev *hdev, u16 handle) > > idr_remove(&hdev->adv_monitors_idr, monitor->handle); > hci_free_adv_monitor(monitor); > + hdev->adv_monitors_cnt--; > } else { > /* Remove all monitors if handle is 0. */ > idr_for_each(&hdev->adv_monitors_idr, &free_adv_monitor, hdev); > -- > 2.28.0.618.gf4bc123cb7-goog This looks like a kernel patch so you shouldn't be prefixing it with BlueZ as it might confuse CI. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cNMDHWXUY19etwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:25:57 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 6E0uGWXUY190nQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:25:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E7D6D408B5; Thu, 17 Sep 2020 23:25:51 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726267AbgIQVZt (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:25:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbgIQVZt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:25:49 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A864C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:25:49 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id l126so2041206pfd.5 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pYiJqqe3wYtqpxCLyBujKkZywaydPj5U6fE9MQlRw7E=; b=ofPfODPAQV25WIz4OvuijyH7Fy8UxLmQ73KrnSTJFe4VHh/P/LWS6lC79uzDaU0sIS oMxPYdE7WdSpxPvdqp8AElCZX5ht3WWJNhuMf6PLEJRjMTijl1nATedO8WljdbhR+uNJ Jg3LY6BnI+OfaXUiBbfsXNeY7XCpPHU8O0148= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pYiJqqe3wYtqpxCLyBujKkZywaydPj5U6fE9MQlRw7E=; b=G8mX+k5s2GyT3b3J1QANfU8GZlkbktU+OGePe8rTBpyvX+tdXHb0647WpvCPe0sJaM ZVLEE9vapph2s3OYP+mIKg1KdnXbPXNyS0JZ0EcDvJ0ZBEuZhFkRnrlPye/HUxirdukp HmPZboBCF3RxLWyzMXbtfh7Ib2KFDtJUZvcgd8u1NRoN9jX0WOfhnh6+qvFw+nNuPhhl +k/iJdh3KQkgqn78C/Ya6asWbA5UqRNiQh0TaOVd7WubGvV/DpmcLqDtPaeV1fCxfLau TTbYNmVYrkUApiynZ1/fVmyZqje9QM3sGQtsa62cRE5o/KChMzzTG8Th5KWa/VO2r3w0 h5NQ== X-Gm-Message-State: AOAM533iVKnRv6s87QfVH7ucrT8teN/Xbz1JrDP48LIhsUnbCvEak4Yp yhln9eL2HFFxBNtNF9FytDH6TQRqmR46Vw== X-Google-Smtp-Source: ABdhPJx8w0pHTKxvQ5WNr33TKkNivSPrv/8Yop10S3iu3pp3kr08K5hwWSwWh737OyNsVTO+gNLSig== X-Received: by 2002:a62:3146:0:b029:13e:d13d:a08e with SMTP id x67-20020a6231460000b029013ed13da08emr28888368pfx.37.1600377948026; Thu, 17 Sep 2020 14:25:48 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y3sm645308pfb.18.2020.09.17.14.25.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 14:25:47 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 1/8] adv_monitor: Implement RSSI Filter logic for background scanning Date: Thu, 17 Sep 2020 14:25:29 -0700 Message-Id: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.91 / 15.00 / 15.00 X-Rspamd-Queue-Id: E7D6D408B5 X-Rspamd-UID: c9e2bf From: Manish Mandlik <mmandlik@google.com> This patch implements the RSSI Filter logic for background scanning. This was unit-tested by running tests in unit/test-adv-monitor.c Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Howard Chung <howardchung@google.com> --- (no changes since v3) Changes in v3: - Fix commit message doc/advertisement-monitor-api.txt | 5 + src/adapter.c | 1 + src/adv_monitor.c | 286 +++++++++++++++++++++++++++++- src/adv_monitor.h | 4 + 4 files changed, 292 insertions(+), 4 deletions(-) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index e09b6fd25..92c8ffc38 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -70,6 +70,11 @@ Properties string Type [read-only] dBm indicates unset. The valid range of a timer is 1 to 300 seconds while 0 indicates unset. + If the peer device advertising interval is greater than the + HighRSSIThresholdTimer, the device will never be found. Similarly, + if it is greater than LowRSSIThresholdTimer, the device will be + considered as lost. Consider configuring these values accordingly. + array{(uint8, uint8, array{byte})} Patterns [read-only, optional] If Type is set to 0x01, this must exist and has at least diff --git a/src/adapter.c b/src/adapter.c index b2bd8b3f1..415d6e06b 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -1227,6 +1227,7 @@ void btd_adapter_remove_device(struct btd_adapter *adapter, adapter->connect_list = g_slist_remove(adapter->connect_list, dev); adapter->devices = g_slist_remove(adapter->devices, dev); + btd_adv_monitor_device_remove(adapter->adv_monitor_manager, dev); adapter->discovery_found = g_slist_remove(adapter->discovery_found, dev); diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 737da1c90..7baa5317f 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -35,6 +35,7 @@ #include "adapter.h" #include "dbus-common.h" +#include "device.h" #include "log.h" #include "src/error.h" #include "src/shared/ad.h" @@ -44,6 +45,8 @@ #include "adv_monitor.h" +static void monitor_device_free(void *data); + #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" @@ -104,15 +107,36 @@ struct adv_monitor { enum monitor_state state; /* MONITOR_STATE_* */ - int8_t high_rssi; /* high RSSI threshold */ - uint16_t high_rssi_timeout; /* high RSSI threshold timeout */ - int8_t low_rssi; /* low RSSI threshold */ - uint16_t low_rssi_timeout; /* low RSSI threshold timeout */ + int8_t high_rssi; /* High RSSI threshold */ + uint16_t high_rssi_timeout; /* High RSSI threshold timeout */ + int8_t low_rssi; /* Low RSSI threshold */ + uint16_t low_rssi_timeout; /* Low RSSI threshold timeout */ + struct queue *devices; /* List of adv_monitor_device objects */ enum monitor_type type; /* MONITOR_TYPE_* */ struct queue *patterns; }; +/* Some data like last_seen, timer/timeout values need to be maintained + * per device. struct adv_monitor_device maintains such data. + */ +struct adv_monitor_device { + struct adv_monitor *monitor; + struct btd_device *device; + + time_t high_rssi_first_seen; /* Start time when RSSI climbs above + * the high RSSI threshold + */ + time_t low_rssi_first_seen; /* Start time when RSSI drops below + * the low RSSI threshold + */ + time_t last_seen; /* Time when last Adv was received */ + bool device_found; /* State of the device - lost/found */ + guint device_lost_timer; /* Timer to track if the device goes + * offline/out-of-range + */ +}; + struct app_match_data { const char *owner; const char *path; @@ -159,6 +183,9 @@ static void monitor_free(void *data) g_dbus_proxy_unref(monitor->proxy); g_free(monitor->path); + queue_destroy(monitor->devices, monitor_device_free); + monitor->devices = NULL; + queue_destroy(monitor->patterns, pattern_free); free(monitor); @@ -257,6 +284,7 @@ static struct adv_monitor *monitor_new(struct adv_monitor_app *app, monitor->high_rssi_timeout = ADV_MONITOR_UNSET_TIMER; monitor->low_rssi = ADV_MONITOR_UNSET_RSSI; monitor->low_rssi_timeout = ADV_MONITOR_UNSET_TIMER; + monitor->devices = queue_new(); monitor->type = MONITOR_TYPE_NONE; monitor->patterns = NULL; @@ -932,3 +960,253 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) manager_destroy(manager); } + +/* Matches a device based on btd_device object */ +static bool monitor_device_match(const void *a, const void *b) +{ + const struct adv_monitor_device *dev = a; + const struct btd_device *device = b; + + if (!dev) + return false; + + if (dev->device != device) + return false; + + return true; +} + +/* Frees a monitor device object */ +static void monitor_device_free(void *data) +{ + struct adv_monitor_device *dev = data; + + if (!dev) + return; + + if (dev->device_lost_timer) { + g_source_remove(dev->device_lost_timer); + dev->device_lost_timer = 0; + } + + dev->monitor = NULL; + dev->device = NULL; + + g_free(dev); +} + +/* Removes a device from monitor->devices list */ +static void remove_device_from_monitor(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct btd_device *device = user_data; + struct adv_monitor_device *dev = NULL; + + if (!monitor) + return; + + dev = queue_remove_if(monitor->devices, monitor_device_match, device); + if (dev) { + DBG("Device removed from the Adv Monitor at path %s", + monitor->path); + monitor_device_free(dev); + } +} + +/* Removes a device from every monitor in an app */ +static void remove_device_from_app(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + struct btd_device *device = user_data; + + if (!app) + return; + + queue_foreach(app->monitors, remove_device_from_monitor, device); +} + +/* Removes a device from every monitor in all apps */ +void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, + struct btd_device *device) +{ + if (!manager || !device) + return; + + queue_foreach(manager->apps, remove_device_from_app, device); +} + +/* Creates a device object to track the per-device information */ +static struct adv_monitor_device *monitor_device_create( + struct adv_monitor *monitor, + struct btd_device *device) +{ + struct adv_monitor_device *dev = NULL; + + dev = g_try_malloc0(sizeof(struct adv_monitor_device)); + if (!dev) + return NULL; + + dev->monitor = monitor; + dev->device = device; + + queue_push_tail(monitor->devices, dev); + + return dev; +} + +/* Includes found/lost device's object path into the dbus message */ +static void report_device_state_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = device_get_path(user_data); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +/* Handles a situation where the device goes offline/out-of-range */ +static gboolean handle_device_lost_timeout(gpointer user_data) +{ + struct adv_monitor_device *dev = user_data; + struct adv_monitor *monitor = dev->monitor; + time_t curr_time = time(NULL); + + DBG("Device Lost timeout triggered for device %p " + "for the Adv Monitor at path %s", dev->device, monitor->path); + + dev->device_lost_timer = 0; + + if (dev->device_found && dev->last_seen) { + /* We were tracking for the Low RSSI filter. Check if there is + * any Adv received after the timeout function is invoked. + * If not, report the Device Lost event. + */ + if (difftime(curr_time, dev->last_seen) >= + monitor->low_rssi_timeout) { + dev->device_found = false; + + DBG("Calling DeviceLost() on Adv Monitor of owner %s " + "at path %s", monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "DeviceLost", + report_device_state_setup, + NULL, dev->device, NULL); + } + } + + return FALSE; +} + +/* Filters an Adv based on its RSSI value */ +static void adv_monitor_filter_rssi(struct adv_monitor *monitor, + struct btd_device *device, int8_t rssi) +{ + struct adv_monitor_device *dev = NULL; + time_t curr_time = time(NULL); + uint16_t adapter_id = monitor->app->manager->adapter_id; + + /* If the RSSI thresholds and timeouts are not specified, report the + * DeviceFound() event without tracking for the RSSI as the Adv has + * already matched the pattern filter. + */ + if (monitor->high_rssi == ADV_MONITOR_UNSET_RSSI && + monitor->low_rssi == ADV_MONITOR_UNSET_RSSI && + monitor->high_rssi_timeout == ADV_MONITOR_UNSET_TIMER && + monitor->low_rssi_timeout == ADV_MONITOR_UNSET_TIMER) { + DBG("Calling DeviceFound() on Adv Monitor of owner %s " + "at path %s", monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "DeviceFound", + report_device_state_setup, NULL, + device, NULL); + + return; + } + + dev = queue_find(monitor->devices, monitor_device_match, device); + if (!dev) + dev = monitor_device_create(monitor, device); + if (!dev) { + btd_error(adapter_id, "Failed to create Adv Monitor " + "device object."); + return; + } + + if (dev->device_lost_timer) { + g_source_remove(dev->device_lost_timer); + dev->device_lost_timer = 0; + } + + /* Reset the timings of found/lost if a device has been offline for + * longer than the high/low timeouts. + */ + if (dev->last_seen) { + if (difftime(curr_time, dev->last_seen) > + monitor->high_rssi_timeout) { + dev->high_rssi_first_seen = 0; + } + + if (difftime(curr_time, dev->last_seen) > + monitor->low_rssi_timeout) { + dev->low_rssi_first_seen = 0; + } + } + dev->last_seen = curr_time; + + /* Check for the found devices (if the device is not already found) */ + if (!dev->device_found && rssi > monitor->high_rssi) { + if (dev->high_rssi_first_seen) { + if (difftime(curr_time, dev->high_rssi_first_seen) >= + monitor->high_rssi_timeout) { + dev->device_found = true; + + DBG("Calling DeviceFound() on Adv Monitor " + "of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call( + monitor->proxy, "DeviceFound", + report_device_state_setup, NULL, + dev->device, NULL); + } + } else { + dev->high_rssi_first_seen = curr_time; + } + } else { + dev->high_rssi_first_seen = 0; + } + + /* Check for the lost devices (only if the device is already found, as + * it doesn't make any sense to report the Device Lost event if the + * device is not found yet) + */ + if (dev->device_found && rssi < monitor->low_rssi) { + if (dev->low_rssi_first_seen) { + if (difftime(curr_time, dev->low_rssi_first_seen) >= + monitor->low_rssi_timeout) { + dev->device_found = false; + + DBG("Calling DeviceLost() on Adv Monitor " + "of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call( + monitor->proxy, "DeviceLost", + report_device_state_setup, NULL, + dev->device, NULL); + } + } else { + dev->low_rssi_first_seen = curr_time; + } + } else { + dev->low_rssi_first_seen = 0; + } + + /* Setup a timer to track if the device goes offline/out-of-range, only + * if we are tracking for the Low RSSI Threshold. If we are tracking + * the High RSSI Threshold, nothing needs to be done. + */ + if (dev->device_found) { + dev->device_lost_timer = + g_timeout_add_seconds(monitor->low_rssi_timeout, + handle_device_lost_timeout, dev); + } +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 69ea348f8..14508e7d1 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -21,6 +21,7 @@ #define __ADV_MONITOR_H struct mgmt; +struct btd_device; struct btd_adapter; struct btd_adv_monitor_manager; @@ -29,4 +30,7 @@ struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct mgmt *mgmt); void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); +void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, + struct btd_device *device); + #endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KNgsBXvUY19b3AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:26:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id EIFiAnvUY1/FcgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:26:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 46CD2408B5; Thu, 17 Sep 2020 23:26:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726222AbgIQV0F (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbgIQV0F (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:26:05 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83E52C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:26:05 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id r19so1822654pls.1 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/4w8gfFvZt8nNefTVXy2SbDxs7Q+/YJVDAOSUetIBZo=; b=h8i2v28dP60I8ZuWWrPSMB440wPHEh+y7JzLKbjoZ87S8bzKoBunJwDVfS2y1iVP+A QCMbO1G1kxWRMeC95fgkC95ojLGEd416cKk2hrTUmNuN5a1gIMx9pT53W/rtiU0gRm/4 +dVh8HlrXOwt4SHAA7nMYf0vrfIylij4VKqTA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/4w8gfFvZt8nNefTVXy2SbDxs7Q+/YJVDAOSUetIBZo=; b=Ow8pql5sP1tAEUfWQGqlu0Lsbdc+NpDy7kwjaUCAzLfHsrC7YhLH1ivosw780HX3vb Kugw2ltAnVaKgnFsKQGP9c0YORMPbNQ+r3OHu8lihzr+8GmNpl/72g6UJ6GTjB1s+RMg i9Q8PbgnZBc/qNq71fa7hbKBzDlbTtwXTAswEbrneiqT+eDm8iMUr7ksFUKEMX0zaOpc 6TYFRJgGFSMhMW9K8F7AyFLJLwjzNyZa1oQiKthm+I7wn71bAE6CTP9b40gAhLNcTo7P cg4Mn149zQsjqC4UcE7XsT4aWjQKpTOEGNBTseJNARYu8cO3T7vLxLw71zpAKWDbLoPy wvbg== X-Gm-Message-State: AOAM531Ko/7lGIJTx4uQuzUmyRBokBpIog+wgdKmVeVlMFe9o1FXIBip N4OeyKftWnbVi4XMSz4LJ8HCR73idZTisQ== X-Google-Smtp-Source: ABdhPJy/YOyViZvjgYqHo33m/MtovNHfHbmAzhYcEpGDKl9sOPj57ufEeUMuVwuj5If/NajzMQAn4Q== X-Received: by 2002:a17:902:bb82:b029:d1:e5e7:bde6 with SMTP id m2-20020a170902bb82b02900d1e5e7bde6mr12981155pls.70.1600377964400; Thu, 17 Sep 2020 14:26:04 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y3sm645308pfb.18.2020.09.17.14.26.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 14:26:03 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 2/8] adv_monitor: Implement unit tests for RSSI Filter Date: Thu, 17 Sep 2020 14:25:31 -0700 Message-Id: <20200917142456.BlueZ.v4.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.53 / 15.00 / 15.00 X-Rspamd-Queue-Id: 46CD2408B5 X-Rspamd-UID: c27d8d From: Manish Mandlik <mmandlik@google.com> This patch implements unit tests for the background scanning RSSI Filtering logic. Verified all tests PASS by running tests in unit/test-adv-monitor.c Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- (no changes since v3) Changes in v3: - Fix commit message Changes in v2: - Cast test data to void * Makefile.am | 9 + doc/test-coverage.txt | 3 +- src/adv_monitor.c | 79 ++++++++ src/adv_monitor.h | 10 + unit/test-adv-monitor.c | 391 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 491 insertions(+), 1 deletion(-) create mode 100644 unit/test-adv-monitor.c diff --git a/Makefile.am b/Makefile.am index 22b4fa30c..6918f02b0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -527,6 +527,15 @@ unit_test_gattrib_LDADD = lib/libbluetooth-internal.la \ src/libshared-glib.la \ $(GLIB_LIBS) $(DBUS_LIBS) -ldl -lrt +unit_tests += unit/test-adv-monitor + +unit_test_adv_monitor_SOURCES = unit/test-adv-monitor.c \ + src/adv_monitor.h src/adv_monitor.c \ + src/device.h src/device.c \ + src/log.h src/log.c +unit_test_adv_monitor_LDADD = gdbus/libgdbus-internal.la \ + src/libshared-glib.la $(GLIB_LIBS) $(DBUS_LIBS) + if MIDI unit_tests += unit/test-midi unit_test_midi_CPPFLAGS = $(AM_CPPFLAGS) $(ALSA_CFLAGS) -DMIDI_TEST diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt index 741492a3e..5296983e6 100644 --- a/doc/test-coverage.txt +++ b/doc/test-coverage.txt @@ -30,8 +30,9 @@ test-gobex-transfer 36 OBEX transfer handling test-gdbus-client 13 D-Bus client handling test-gatt 180 GATT qualification test cases test-hog 6 HID Over GATT qualification test cases +test-adv-monitor 5 Advertisement Monitor test cases ----- - 761 + 766 Automated end-to-end testing diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 7baa5317f..046f5953f 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -1210,3 +1210,82 @@ static void adv_monitor_filter_rssi(struct adv_monitor *monitor, handle_device_lost_timeout, dev); } } + +/* Creates the dummy adv_monitor object for unit tests */ +void *btd_adv_monitor_rssi_test_setup(int8_t high_rssi, uint16_t high_timeout, + int8_t low_rssi, uint16_t low_timeout) +{ + struct adv_monitor *test_monitor = NULL; + + test_monitor = g_new0(struct adv_monitor, 1); + if (!test_monitor) + return NULL; + + test_monitor->app = g_new0(struct adv_monitor_app, 1); + if (!test_monitor->app) + goto app_failed; + + test_monitor->app->manager = g_new0(struct btd_adv_monitor_manager, 1); + if (!test_monitor->app->manager) + goto manager_failed; + + test_monitor->high_rssi = high_rssi; + test_monitor->high_rssi_timeout = high_timeout; + test_monitor->low_rssi = low_rssi; + test_monitor->low_rssi_timeout = low_timeout; + test_monitor->devices = queue_new(); + + return test_monitor; + +manager_failed: + g_free(test_monitor->app); + +app_failed: + g_free(test_monitor); + + return NULL; +} + +/* Cleanup after unit test is done */ +void btd_adv_monitor_rssi_test_teardown(void *monitor_obj) +{ + struct adv_monitor *monitor = monitor_obj; + + if (!monitor) + return; + + queue_destroy(monitor->devices, monitor_device_free); + g_free(monitor); +} + +/* Returns the current state of device - found/lost, used in unit tests */ +bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj) +{ + struct adv_monitor *monitor = monitor_obj; + struct btd_device *device = device_obj; + struct adv_monitor_device *dev = NULL; + + if (!monitor || !device) + return false; + + dev = queue_find(monitor->devices, monitor_device_match, device); + if (!dev) + return false; + + return dev->device_found; +} + +/* Helper function for the RSSI Filter unit tests */ +bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, + int8_t adv_rssi) +{ + struct adv_monitor *monitor = monitor_obj; + struct btd_device *device = device_obj; + + if (!monitor || !device) + return false; + + adv_monitor_filter_rssi(monitor, device, adv_rssi); + + return btd_adv_monitor_test_device_state(monitor, device); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 14508e7d1..351e7f9aa 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -33,4 +33,14 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, struct btd_device *device); +/* Following functions are the helper functions used for RSSI Filter unit tests + * defined in unit/test-adv-monitor.c + */ +void *btd_adv_monitor_rssi_test_setup(int8_t high_rssi, uint16_t high_timeout, + int8_t low_rssi, uint16_t low_timeout); +void btd_adv_monitor_rssi_test_teardown(void *monitor_obj); +bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj); +bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, + int8_t adv_rssi); + #endif /* __ADV_MONITOR_H */ diff --git a/unit/test-adv-monitor.c b/unit/test-adv-monitor.c new file mode 100644 index 000000000..970be84b0 --- /dev/null +++ b/unit/test-adv-monitor.c @@ -0,0 +1,391 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2020 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <glib.h> +#include <stdbool.h> +#include <stdint.h> +#include <unistd.h> + +#include "src/log.h" +#include "src/shared/tester.h" + +#include "src/adv_monitor.h" + +#define define_test(name, type, data, setup_fn, test_fn, teardown_fn) \ + do { \ + static struct test_data test; \ + test.test_type = type; \ + test.test_name = g_strdup(name); \ + if (type == TEST_RSSI_FILTER) { \ + test.rssi_filter_test_data = (void *)&data; \ + test.rssi_filter_test_data->test_info = &test; \ + } \ + tester_add(name, &test, setup_fn, test_fn, teardown_fn);\ + } while (0) + +#define ADV_INTERVAL 1 /* Advertisement interval in seconds */ +#define OUT_OF_RANGE -128 +#define END_OF_RSSI_TEST {0} + +#define RSSI_TEST_DONE(test_step) \ + (!test_step.adv_rssi && !test_step.duration && !test_step.result) + +#define DUMMY_BTD_DEVICE_OBJ ((void *) 0xF00) + +enum test_type { + TEST_RSSI_FILTER = 0, + TEST_CONTENT_FILTER, +}; + +enum result { + RESULT_DEVICE_NOT_FOUND = false, /* Initial state of a device */ + RESULT_DEVICE_FOUND = true, /* Device state when the + * Content/RSSI Filter match + */ + RESULT_DEVICE_LOST = false, /* Device state when the Low + * RSSI Filter match or if it + * goes offline/out-of-range + */ +}; + +struct rssi_filter_test { + void *adv_monitor_obj; /* struct adv_monitor object */ + void *btd_device_obj; /* struct btd_device object */ + struct test_data *test_info; + + const struct { + int8_t high_rssi_threshold; /* High RSSI threshold */ + uint16_t high_rssi_timeout; /* High RSSI threshold timeout*/ + int8_t low_rssi_threshold; /* Low RSSI threshold */ + uint16_t low_rssi_timeout; /* Low RSSI threshold timeout */ + } rssi_filter; + + time_t start_time; /* Start time of the test */ + uint16_t resume_step; /* Store the current sub-step of the + * test before suspending that test + */ + guint out_of_range_timer; /* Timer to simulate device offline */ + + const struct { + int8_t adv_rssi; /* Advertisement RSSI */ + uint16_t duration; /* Advertisement duration in seconds */ + enum result result; /* Device state after every step */ + } test_steps[]; +}; + +/* Parent data structure to hold the test data and information, + * used by tester_* functions and callbacks. + */ +struct test_data { + enum test_type test_type; + char *test_name; + + union { + struct rssi_filter_test *rssi_filter_test_data; + }; +}; + +/* RSSI Filter Test 1: + * - The Device Lost event should NOT get triggered even if the Adv RSSI is + * lower than LowRSSIThresh for more than LowRSSITimeout before finding + * the device first. + * - Similarly, the Device Found event should NOT get triggered if the Adv RSSI + * is greater than LowRSSIThresh but lower than HighRSSIThresh. + */ +static struct rssi_filter_test rssi_data_1 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-70, 6, RESULT_DEVICE_NOT_FOUND}, + {-50, 6, RESULT_DEVICE_NOT_FOUND}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 2: + * - The Device Found event should get triggered when the Adv RSSI is higher + * than HighRSSIThresh for more than HighRSSITimeout. + * - Once the device is found, the Device Lost event should NOT get triggered + * if the Adv RSSI drops below HighRSSIThresh but it is not lower than + * LowRSSIThresh. + * - When the Adv RSSI drops below LowRSSIThresh for more than LowRSSITimeout, + * the Device Lost event should get triggered. + */ +static struct rssi_filter_test rssi_data_2 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-30, 6, RESULT_DEVICE_FOUND}, + {-50, 6, RESULT_DEVICE_FOUND}, + {-70, 6, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 3: + * - The Device Found event should get triggered only when the Adv RSSI is + * higher than HighRSSIThresh for more than HighRSSITimeout. + * - If the Adv RSSI drops below HighRSSIThresh, timer should reset and start + * counting once the Adv RSSI is above HighRSSIThresh. + * - Similarly, when tracking the Low RSSI, timer should reset when the Adv RSSI + * goes above LowRSSIThresh. The Device Lost event should get triggered only + * when the Adv RSSI is lower than LowRSSIThresh for more than LowRSSITimeout. + */ +static struct rssi_filter_test rssi_data_3 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + {-30, 2, RESULT_DEVICE_NOT_FOUND}, + {-50, 6, RESULT_DEVICE_NOT_FOUND}, + {-30, 4, RESULT_DEVICE_NOT_FOUND}, + {-30, 2, RESULT_DEVICE_FOUND}, + {-70, 2, RESULT_DEVICE_FOUND}, + {-50, 6, RESULT_DEVICE_FOUND}, + {-70, 4, RESULT_DEVICE_FOUND}, + {-70, 2, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 4: + * - While tracking the High RSSI, timer should reset if the device goes + * offline/out-of-range for more than HighRSSITimeout. + * - Once the device is found, if the device goes offline/out-of-range for + * more than LowRSSITimeout, the Device Lost event should get triggered. + */ +static struct rssi_filter_test rssi_data_4 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + { -30, 2, RESULT_DEVICE_NOT_FOUND}, + {OUT_OF_RANGE, 6, RESULT_DEVICE_NOT_FOUND}, + { -30, 4, RESULT_DEVICE_NOT_FOUND}, + { -30, 2, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 6, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* RSSI Filter Test 5: + * - The Device Found event should get triggered only once even if the Adv RSSI + * stays higher than HighRSSIThresh for a longer period of time. + * - Once the device is found, while tracking the Low RSSI, timer should reset + * when the Adv RSSI goes above LowRSSIThresh. + * - The timer should NOT reset if the device goes offline/out-of-range for + * a very short period of time and comes back online/in-range before + * the timeouts. + */ +static struct rssi_filter_test rssi_data_5 = { + .rssi_filter = {-40, 5, -60, 5}, + .test_steps = { + { -30, 2, RESULT_DEVICE_NOT_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_NOT_FOUND}, + { -30, 2, RESULT_DEVICE_FOUND}, + { -30, 3, RESULT_DEVICE_FOUND}, + { -30, 3, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_FOUND}, + { -50, 6, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_FOUND}, + {OUT_OF_RANGE, 2, RESULT_DEVICE_FOUND}, + { -70, 2, RESULT_DEVICE_LOST}, + END_OF_RSSI_TEST, + }, +}; + +/* Initialize the data required for RSSI Filter test */ +static void setup_rssi_filter_test(gpointer data) +{ + struct rssi_filter_test *test = data; + + test->adv_monitor_obj = btd_adv_monitor_rssi_test_setup( + test->rssi_filter.high_rssi_threshold, + test->rssi_filter.high_rssi_timeout, + test->rssi_filter.low_rssi_threshold, + test->rssi_filter.low_rssi_timeout); + + /* The RSSI Filter logic uses btd_device object only as a key in the + * adv_monitor->devices list, it is never dereferenced nor used to + * perform any operations related to btd_device. So we can use any + * dummy address for unit testing. + */ + test->btd_device_obj = DUMMY_BTD_DEVICE_OBJ; + + tester_setup_complete(); +} + +/* Cleanup after the RSSI Filter test is done */ +static void teardown_rssi_filter_test(gpointer data) +{ + struct rssi_filter_test *test = data; + + btd_adv_monitor_rssi_test_teardown(test->adv_monitor_obj); + + tester_teardown_complete(); +} + +/* Execute the sub-steps of RSSI Filter test */ +static gboolean test_rssi_filter(gpointer data) +{ + struct rssi_filter_test *test = data; + time_t start_time = time(NULL); + bool ret = false; + + uint16_t i = 0; + uint16_t j = 0; + + /* If this is not the beginning of test, return to the sub-step + * before that test was suspended + */ + if (test->resume_step) { + start_time = test->start_time; + i = test->resume_step; + + /* Clear the test resume timer */ + g_source_remove(test->out_of_range_timer); + test->out_of_range_timer = 0; + + /* Check state of the device - found/lost, while device was + * offline/out-of-range + */ + ret = btd_adv_monitor_test_device_state(test->adv_monitor_obj, + test->btd_device_obj); + tester_debug("%s: [t=%.0lf, step=%d] Test resume, " + "device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + ret ? "true" : "false"); + g_assert(ret == test->test_steps[i].result); + + i++; + } + + while (!RSSI_TEST_DONE(test->test_steps[i])) { + if (test->test_steps[i].adv_rssi == OUT_OF_RANGE) { + /* Simulate device offline/out-of-range by suspending + * the test. + * + * Note: All tester_* functions run sequentially by + * adding a next function to the main loop using + * g_idle_add(). If a timeout function is added using + * g_timeout_add_*(), it doesn't really get invoked as + * soon as the timer expires. Instead, it is invoked + * once the current function returns and the timer has + * expired. So, to give handle_device_lost_timeout() + * function a chance to run at the correct time, we + * must save the current state and exit from this + * function while we simulate the device offline. We can + * come back later to continue with the remaining steps. + */ + test->resume_step = i; + test->start_time = start_time; + test->out_of_range_timer = g_timeout_add_seconds( + test->test_steps[i].duration, + test_rssi_filter, data); + + /* Check the device state before suspending the test */ + ret = btd_adv_monitor_test_device_state( + test->adv_monitor_obj, + test->btd_device_obj); + tester_debug("%s: [t=%.0lf, step=%d] Test suspend, " + "device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + ret ? "true" : "false"); + return FALSE; + } + + for (j = 0; j < test->test_steps[i].duration; j++) { + ret = btd_adv_monitor_test_rssi( + test->adv_monitor_obj, + test->btd_device_obj, + test->test_steps[i].adv_rssi); + tester_debug("%s: [t=%.0lf, step=%d] Test " + "advertisement RSSI %d, device_found = %s", + test->test_info->test_name, + difftime(time(NULL), start_time), i, + test->test_steps[i].adv_rssi, + ret ? "true" : "false"); + + /* Sleep for a second to simulate receiving + * advertisement once every second + */ + sleep(ADV_INTERVAL); + } + g_assert(ret == test->test_steps[i].result); + + i++; + } + + tester_debug("%s: [t=%.0lf] Test done", test->test_info->test_name, + difftime(time(NULL), start_time)); + + tester_test_passed(); + + return FALSE; +} + +/* Handler function to prepare for a test */ +static void setup_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + setup_rssi_filter_test(test->rssi_filter_test_data); +} + +/* Handler function to cleanup after the test is done */ +static void teardown_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + teardown_rssi_filter_test(test->rssi_filter_test_data); +} + +/* Handler function to execute a test with the given data set */ +static void test_handler(gconstpointer data) +{ + const struct test_data *test = data; + + if (test->test_type == TEST_RSSI_FILTER) + test_rssi_filter(test->rssi_filter_test_data); +} + +int main(int argc, char *argv[]) +{ + tester_init(&argc, &argv); + + __btd_log_init("*", 0); + + define_test("/advmon/rssi/1", TEST_RSSI_FILTER, rssi_data_1, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/2", TEST_RSSI_FILTER, rssi_data_2, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/3", TEST_RSSI_FILTER, rssi_data_3, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/4", TEST_RSSI_FILTER, rssi_data_4, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/rssi/5", TEST_RSSI_FILTER, rssi_data_5, + setup_handler, test_handler, teardown_handler); + + return tester_run(); +} -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +J/jC4LUY19etwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:26:26 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id KKifCILUY18UuwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:26:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C190540618; Thu, 17 Sep 2020 23:26:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbgIQV0T (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:26:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbgIQV0S (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:26:18 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37A54C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:26:18 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id x123so2036021pfc.7 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U8bdngXt881UuqJCGhnQokdCSvIzYyCqfzNdhYpGGbo=; b=DykQubO6oaYfHbpF1xYfb02amy+Y8CG7bzFYKTWTVEfNVCeAYq+sMxRJzPrSMqy6P4 4wcpjI+9B5eR5kCoIxnNTapipXaGBJth4lwUw1RUyNMYBqVME22iWCPESlz3TjaElgXc yIMcHt0RnFRId8B6Ta5pOoH4acEDE8eCJX1Kc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U8bdngXt881UuqJCGhnQokdCSvIzYyCqfzNdhYpGGbo=; b=CiOZDFff5BMmZio+T8J3rHWg+hD0KVABmpxbm5djptOY80niOywIwp9lvOTifFHgvG OYVazrg8LN/WjxrzbM/X2/7LOgWGtk5/fn5MoN9HCRckoUFELvv7TnCTEY13EASCgKtt 6t5gZKmGoGGc+cMj2QIu6iZPBRTmq8F1H4q3g0ECBnsH2i+xirkWdg1aDMl8CBlTjL5u A3VcdnR54ThKh7Qree6+Q6KkMwsQzes7RftejlkCXiUvDjcuHxL/ymuZsFgaMl2miUGu NRR50xNVh33WaPws1GkXGgnuvZYrv/EoQfVieur2oFG/25I8yf3zowzZHHKmG/MVHU6D A4XA== X-Gm-Message-State: AOAM532zzUP3RJgLOsoQDx2/jSIvTPuhZ4rMvQnnOysimqO864PjUqmE ecCr6idaL6xVRIHHSaLlzcUwS8tOICZ8xA== X-Google-Smtp-Source: ABdhPJxmhhkfz+60xQBUEPS1tusmc0UAxPHDZ6usgzp6/n9uuQmbGYHcjnnDvixORG9wAR25wx4LBg== X-Received: by 2002:a63:b17:: with SMTP id 23mr8625827pgl.112.1600377977287; Thu, 17 Sep 2020 14:26:17 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y3sm645308pfb.18.2020.09.17.14.26.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 14:26:16 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v4 3/8] adv_monitor: Implement Adv matching based on stored monitors Date: Thu, 17 Sep 2020 14:25:33 -0700 Message-Id: <20200917142456.BlueZ.v4.3.I578ae5e76fcf7243206a27d4f5a25783662a5f14@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.36 / 15.00 / 15.00 X-Rspamd-Queue-Id: C190540618 X-Rspamd-UID: 83f9ad This implements create an entry point in adapter to start the matching of Adv based on all monitors and invoke the RSSI tracking for Adv reporting. Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v3) Changes in v3: - Remove unused variables - Fix signature of queue_find() src/adapter.c | 35 +++++-- src/adv_monitor.c | 237 +++++++++++++++++++++++++++++++++++++++++----- src/adv_monitor.h | 19 ++++ 3 files changed, 259 insertions(+), 32 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 415d6e06b..d33ce7124 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6614,6 +6614,15 @@ static void update_found_devices(struct btd_adapter *adapter, bool name_known, discoverable; char addr[18]; bool duplicate = false; + GSList *matched_monitors; + + /* During the background scanning, update the device only when the data + * match at least one Adv monitor + */ + matched_monitors = btd_adv_monitor_content_filter( + adapter->adv_monitor_manager, data, data_len); + if (!adapter->discovering && !matched_monitors) + return; memset(&eir_data, 0, sizeof(eir_data)); eir_parse(&eir_data, data, data_len); @@ -6659,18 +6668,22 @@ static void update_found_devices(struct btd_adapter *adapter, device_store_cached_name(dev, eir_data.name); /* - * Only skip devices that are not connected, are temporary and there - * is no active discovery session ongoing. + * Only skip devices that are not connected, are temporary, and there + * is no active discovery session ongoing and no matched Adv monitors */ - if (!btd_device_is_connected(dev) && (device_is_temporary(dev) && - !adapter->discovery_list)) { + if (!btd_device_is_connected(dev) && + (device_is_temporary(dev) && !adapter->discovery_list) && + !matched_monitors) { eir_data_free(&eir_data); return; } - /* Don't continue if not discoverable or if filter don't match */ - if (!discoverable || (adapter->filtered_discovery && - !is_filter_match(adapter->discovery_list, &eir_data, rssi))) { + /* If there is no matched Adv monitors, don't continue if not + * discoverable or if active discovery filter don't match. + */ + if (!matched_monitors && (!discoverable || + (adapter->filtered_discovery && !is_filter_match( + adapter->discovery_list, &eir_data, rssi)))) { eir_data_free(&eir_data); return; } @@ -6727,6 +6740,14 @@ static void update_found_devices(struct btd_adapter *adapter, eir_data_free(&eir_data); + /* After the device is updated, notify the matched Adv monitors */ + if (matched_monitors) { + btd_adv_monitor_notify_monitors(adapter->adv_monitor_manager, + dev, rssi, matched_monitors); + g_slist_free(matched_monitors); + matched_monitors = NULL; + } + /* * Only if at least one client has requested discovery, maintain * list of found devices and name confirming for legacy devices. diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 046f5953f..211094c89 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -38,15 +38,12 @@ #include "device.h" #include "log.h" #include "src/error.h" -#include "src/shared/ad.h" #include "src/shared/mgmt.h" #include "src/shared/queue.h" #include "src/shared/util.h" #include "adv_monitor.h" -static void monitor_device_free(void *data); - #define ADV_MONITOR_INTERFACE "org.bluez.AdvertisementMonitor1" #define ADV_MONITOR_MGR_INTERFACE "org.bluez.AdvertisementMonitorManager1" @@ -93,7 +90,7 @@ enum monitor_state { MONITOR_STATE_HONORED, /* Accepted by kernel */ }; -struct pattern { +struct btd_adv_monitor_pattern { uint8_t ad_type; uint8_t offset; uint8_t length; @@ -142,6 +139,23 @@ struct app_match_data { const char *path; }; +struct adv_content_filter_info { + uint8_t eir_len; + const uint8_t *eir; + + bool matched; /* Intermediate state per monitor */ + GSList *matched_monitors; /* List of matched monitors */ +}; + +struct adv_rssi_filter_info { + struct btd_device *device; + int8_t rssi; +}; + +static void monitor_device_free(void *data); +static void adv_monitor_filter_rssi(struct adv_monitor *monitor, + struct btd_device *device, int8_t rssi); + const struct adv_monitor_type { enum monitor_type type; const char *name; @@ -164,7 +178,7 @@ static void app_reply_msg(struct adv_monitor_app *app, DBusMessage *reply) /* Frees a pattern */ static void pattern_free(void *data) { - struct pattern *pattern = data; + struct btd_adv_monitor_pattern *pattern = data; if (!pattern) return; @@ -172,6 +186,12 @@ static void pattern_free(void *data) free(pattern); } +void btd_adv_monitor_test_pattern_destroy( + struct btd_adv_monitor_pattern *pattern) +{ + pattern_free(pattern); +} + /* Frees a monitor object */ static void monitor_free(void *data) { @@ -444,6 +464,42 @@ failed: return false; } +/* Allocates and initiates a pattern with the given content */ +static struct btd_adv_monitor_pattern *pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value) +{ + struct btd_adv_monitor_pattern *pattern; + + if (offset > BT_AD_MAX_DATA_LEN - 1) + return NULL; + + if ((ad_type > BT_AD_3D_INFO_DATA && + ad_type != BT_AD_MANUFACTURER_DATA) || + ad_type < BT_AD_FLAGS) { + return NULL; + } + + if (!value || !length || offset + length > BT_AD_MAX_DATA_LEN) + return NULL; + + pattern = new0(struct btd_adv_monitor_pattern, 1); + if (!pattern) + return NULL; + + pattern->ad_type = ad_type; + pattern->offset = offset; + pattern->length = length; + memcpy(pattern->value, value, pattern->length); + + return pattern; +} + +struct btd_adv_monitor_pattern *btd_adv_monitor_test_pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value) +{ + return pattern_create(ad_type, offset, length, value); +} + /* Retrieves Patterns from the remote Adv Monitor object, verifies the values * and update the local Adv Monitor */ @@ -473,7 +529,7 @@ static bool parse_patterns(struct adv_monitor *monitor, const char *path) int value_len; uint8_t *value; uint8_t offset, ad_type; - struct pattern *pattern; + struct btd_adv_monitor_pattern *pattern; DBusMessageIter struct_iter, value_iter; dbus_message_iter_recurse(&array_iter, &struct_iter); @@ -505,28 +561,10 @@ static bool parse_patterns(struct adv_monitor *monitor, const char *path) dbus_message_iter_get_fixed_array(&value_iter, &value, &value_len); - // Verify the values - if (offset > BT_AD_MAX_DATA_LEN - 1) - goto failed; - - if ((ad_type > BT_AD_3D_INFO_DATA && - ad_type != BT_AD_MANUFACTURER_DATA) || - ad_type < BT_AD_FLAGS) { - goto failed; - } - - if (!value || value_len <= 0 || value_len > BT_AD_MAX_DATA_LEN) - goto failed; - - pattern = new0(struct pattern, 1); + pattern = pattern_create(ad_type, offset, value_len, value); if (!pattern) goto failed; - pattern->ad_type = ad_type; - pattern->offset = offset; - pattern->length = value_len; - memcpy(pattern->value, value, pattern->length); - queue_push_tail(monitor->patterns, pattern); dbus_message_iter_next(&array_iter); @@ -961,6 +999,155 @@ void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager) manager_destroy(manager); } +/* Matches the content based on the given pattern */ +bool btd_adv_monitor_pattern_match( + const uint8_t *eir, uint8_t eir_len, + const struct btd_adv_monitor_pattern *pattern) +{ + const uint8_t *data; + uint8_t idx = 0; + uint8_t field_len, data_len, data_type; + + while (idx < eir_len - 1) { + field_len = eir[0]; + + /* Check for the end of EIR */ + if (field_len == 0) + break; + + idx += field_len + 1; + + /* Do not continue filtering if got incorrect length */ + if (idx >= eir_len) + break; + + data = &eir[2]; + data_type = eir[1]; + data_len = field_len - 1; + + eir += field_len + 1; + + if (data_type != pattern->ad_type) + continue; + + if (data_len < pattern->offset + pattern->length) + continue; + + if (pattern->offset + pattern->length > BT_AD_MAX_DATA_LEN) + continue; + + if (!memcmp(data + pattern->offset, pattern->value, + pattern->length)) + return true; + } + + return false; +} + +/* Processes the content matching based on a pattern */ +static void adv_match_per_pattern(void *data, void *user_data) +{ + struct btd_adv_monitor_pattern *pattern = data; + struct adv_content_filter_info *info = user_data; + + if (!pattern || info->matched) + return; + + info->matched = btd_adv_monitor_pattern_match(info->eir, info->eir_len, + pattern); +} + +/* Processes the content matching based pattern(s) of a monitor */ +static void adv_match_per_monitor(void *data, void *user_data) +{ + struct adv_monitor *monitor = data; + struct adv_content_filter_info *info = user_data; + + if (!monitor && monitor->state != MONITOR_STATE_HONORED) + return; + + /* Reset the intermediate matched status */ + info->matched = false; + + if (monitor->type == MONITOR_TYPE_OR_PATTERNS) { + queue_foreach(monitor->patterns, adv_match_per_pattern, info); + if (info->matched) + goto matched; + } + + return; + +matched: + info->matched_monitors = g_slist_prepend(info->matched_monitors, + monitor); +} + +/* Processes the content matching for the monitor(s) of an app */ +static void adv_match_per_app(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + + if (!app) + return; + + queue_foreach(app->monitors, adv_match_per_monitor, user_data); +} + +/* Processes the content matching for every app without RSSI filtering and + * notifying monitors. The caller is responsible of releasing the memory of the + * list but not the data. + * Returns the list of monitors whose content match eir. + */ +GSList *btd_adv_monitor_content_filter(struct btd_adv_monitor_manager *manager, + const uint8_t *eir, uint8_t eir_len) +{ + struct adv_content_filter_info info; + + if (!manager || !eir || !eir_len) + return NULL; + + info.eir_len = eir_len; + info.eir = eir; + info.matched_monitors = NULL; + + queue_foreach(manager->apps, adv_match_per_app, &info); + + return info.matched_monitors; +} + +/* Wraps adv_monitor_filter_rssi() to processes the content-matched monitor with + * RSSI filtering and notifies it on device found/lost event + */ +static void monitor_filter_rssi(gpointer a, gpointer b) +{ + struct adv_monitor *monitor = a; + struct adv_rssi_filter_info *info = b; + + if (!monitor || !info) + return; + + adv_monitor_filter_rssi(monitor, info->device, info->rssi); +} + +/* Processes every content-matched monitor with RSSI filtering and notifies on + * device found/lost event. The caller is responsible of releasing the memory + * of matched_monitors list but not its data. + */ +void btd_adv_monitor_notify_monitors(struct btd_adv_monitor_manager *manager, + struct btd_device *device, int8_t rssi, + GSList *matched_monitors) +{ + struct adv_rssi_filter_info info; + + if (!manager || !device || !matched_monitors) + return; + + info.device = device; + info.rssi = rssi; + + g_slist_foreach(matched_monitors, monitor_filter_rssi, &info); +} + /* Matches a device based on btd_device object */ static bool monitor_device_match(const void *a, const void *b) { diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 351e7f9aa..b660f5941 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -20,16 +20,28 @@ #ifndef __ADV_MONITOR_H #define __ADV_MONITOR_H +#include <glib.h> + +#include "src/shared/ad.h" + struct mgmt; struct btd_device; struct btd_adapter; struct btd_adv_monitor_manager; +struct btd_adv_monitor_pattern; struct btd_adv_monitor_manager *btd_adv_monitor_manager_create( struct btd_adapter *adapter, struct mgmt *mgmt); void btd_adv_monitor_manager_destroy(struct btd_adv_monitor_manager *manager); +GSList *btd_adv_monitor_content_filter(struct btd_adv_monitor_manager *manager, + const uint8_t *eir, uint8_t eir_len); + +void btd_adv_monitor_notify_monitors(struct btd_adv_monitor_manager *manager, + struct btd_device *device, int8_t rssi, + GSList *matched_monitors); + void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, struct btd_device *device); @@ -42,5 +54,12 @@ void btd_adv_monitor_rssi_test_teardown(void *monitor_obj); bool btd_adv_monitor_test_device_state(void *monitor_obj, void *device_obj); bool btd_adv_monitor_test_rssi(void *monitor_obj, void *device_obj, int8_t adv_rssi); +struct btd_adv_monitor_pattern *btd_adv_monitor_test_pattern_create( + uint8_t ad_type, uint8_t offset, uint8_t length, const uint8_t *value); +void btd_adv_monitor_test_pattern_destroy( + struct btd_adv_monitor_pattern *pattern); +bool btd_adv_monitor_pattern_match( + const uint8_t *eir, uint8_t eir_len, + const struct btd_adv_monitor_pattern *pattern); #endif /* __ADV_MONITOR_H */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ULXqCpLUY19etwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:26:42 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 0IlnB5LUY18YrgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:26:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F3A7240873; Thu, 17 Sep 2020 23:26:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726102AbgIQV0f (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:26:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbgIQV0f (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:26:35 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A2DEC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:26:35 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id k15so2023515pfc.12 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:26:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UgExmGJD0WUGNTW5ZOzNd/c9xQ0pED0xft63St+aD78=; b=XwGwXUurEuP3Z4rlHd7dzhsmZuFfRMguRDIbEJ0WJsHC4zm6hwdcJRtlpIhV8Y4EHa Yvy/QrPfk7uZVM9OsiDdzPWymls1oscmzxQ28ETLB0287DRevRWIwsJJ2Ev1jbIm2+Lj iNw4ICaiKtzC1aP/tddDo3S5JHiW0tbU6oCo4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UgExmGJD0WUGNTW5ZOzNd/c9xQ0pED0xft63St+aD78=; b=P6FbZryxnE+kzYMqH4hiW2/yZTf4x9avn7GS/oESmqG1VgRVBONgMQMyA1JA2f0dD1 Cz288ewyEhSKDYsFuOdsV7heanDllExW0238dR31xCUMvinUK7c260zrvp20F0vva4cY 5yUOb1x8k3++TrDppVxMBWem8rNg+N2aDemePRs5rznK9o/KOIsZs0rVmcq3VU3LNZ6s o6K3sCH/rK53lFQkJgBC0AUlM1ykI0dyDRcvMDHho19p7/Q5vJ8LeLMbZLm/ytINhhvD yXK3wSKWYHWIWkJo07c71oF4oZ5PbZmzzSsHB/Fq89jMANlb3+zdiRSuoxA11ye70Sa2 a9JQ== X-Gm-Message-State: AOAM533Ym0t4idzRGgfxPSDV2/AiB+H9K8PCqO/Qg64+JB9yPia+8CvI heRl0zFumM++COH3yFugSuyoOsddpFUqZg== X-Google-Smtp-Source: ABdhPJw6uiQ06WD3ARuZ6UuW7wd1Swz7N47s1WH28eqFreipOw6K1518HVMrkbJGraw1rE8rfw1xxQ== X-Received: by 2002:a63:725d:: with SMTP id c29mr1318380pgn.234.1600377994450; Thu, 17 Sep 2020 14:26:34 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y3sm645308pfb.18.2020.09.17.14.26.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 14:26:33 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Subject: [BlueZ PATCH v4 4/8] adv_monitor: Implement unit tests for content filter Date: Thu, 17 Sep 2020 14:25:35 -0700 Message-Id: <20200917142456.BlueZ.v4.4.I7f88b6e4c63c14d77974438eb2f07326aedbfd9b@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.36 / 15.00 / 15.00 X-Rspamd-Queue-Id: F3A7240873 X-Rspamd-UID: 2f01c0 This implements the unit tests for verifying the correctness of advertisement data fields matching against a pattern. Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v3) Changes in v3: - Fix mixed declarations and assignments Changes in v2: - Cast test data to void * doc/test-coverage.txt | 4 +- unit/test-adv-monitor.c | 144 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 2 deletions(-) diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt index 5296983e6..e15474a44 100644 --- a/doc/test-coverage.txt +++ b/doc/test-coverage.txt @@ -30,9 +30,9 @@ test-gobex-transfer 36 OBEX transfer handling test-gdbus-client 13 D-Bus client handling test-gatt 180 GATT qualification test cases test-hog 6 HID Over GATT qualification test cases -test-adv-monitor 5 Advertisement Monitor test cases +test-adv-monitor 9 Advertisement Monitor test cases ----- - 766 + 770 Automated end-to-end testing diff --git a/unit/test-adv-monitor.c b/unit/test-adv-monitor.c index 970be84b0..a19a3092b 100644 --- a/unit/test-adv-monitor.c +++ b/unit/test-adv-monitor.c @@ -40,6 +40,8 @@ if (type == TEST_RSSI_FILTER) { \ test.rssi_filter_test_data = (void *)&data; \ test.rssi_filter_test_data->test_info = &test; \ + } else if (type == TEST_CONTENT_FILTER) { \ + test.content_filter_test_data = (void *)&data; \ } \ tester_add(name, &test, setup_fn, test_fn, teardown_fn);\ } while (0) @@ -94,6 +96,22 @@ struct rssi_filter_test { } test_steps[]; }; +struct content_filter_test { + void *advmon_pattern; /* btd_adv_monitor_pattern */ + + bool expected_match; + + const struct { + uint8_t ad_type; + uint8_t offset; + uint8_t length; + uint8_t value[BT_AD_MAX_DATA_LEN]; + } pattern; + + uint8_t eir_len; + uint8_t eir[]; +}; + /* Parent data structure to hold the test data and information, * used by tester_* functions and callbacks. */ @@ -103,6 +121,7 @@ struct test_data { union { struct rssi_filter_test *rssi_filter_test_data; + struct content_filter_test *content_filter_test_data; }; }; @@ -211,6 +230,62 @@ static struct rssi_filter_test rssi_data_5 = { }, }; +/* Content Filter Test 1: + * The valid EIR data contains the given pattern whose content is a UUID16 AD + * data. + */ +static struct content_filter_test content_data_1 = { + .expected_match = true, + .pattern = {0x03, 0x02, 0x02, {0x09, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 2: + * The valid EIR data does not match the given pattern whose content is a UUID16 + * AD data. + */ +static struct content_filter_test content_data_2 = { + .expected_match = false, + .pattern = {0x03, 0x02, 0x02, {0x0d, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 3: + * The valid EIR data does not have the given pattern whose content is a UUID32 + * AD data. + */ +static struct content_filter_test content_data_3 = { + .expected_match = false, + .pattern = {0x05, 0x00, 0x04, {0x09, 0x18, 0x00, 0x00} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x05, 0x03, 0x0d, 0x18, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + +/* Content Filter Test 4: + * The valid EIR data does not match the given pattern whose content is a + * UUID16 AD data due to invalid starting position of matching. + */ +static struct content_filter_test content_data_4 = { + .expected_match = false, + .pattern = {0x03, 0x02, 0x02, {0x09, 0x18} }, + .eir_len = 20, + .eir = {0x02, 0x01, 0x02, // flags + 0x06, 0xff, 0x96, 0xfd, 0xab, 0xcd, 0xef, // Mfr. Data + 0x03, 0x03, 0x09, 0x18, // 16-bit UUIDs + 0x05, 0x16, 0x0d, 0x18, 0x12, 0x34}, // Service Data +}; + /* Initialize the data required for RSSI Filter test */ static void setup_rssi_filter_test(gpointer data) { @@ -343,6 +418,60 @@ static gboolean test_rssi_filter(gpointer data) return FALSE; } +/* Initialize the data required for Content Filter test */ +static void setup_content_filter_test(gpointer data) +{ + struct content_filter_test *test = data; + struct btd_adv_monitor_pattern *pattern = NULL; + + pattern = btd_adv_monitor_test_pattern_create(test->pattern.ad_type, + test->pattern.offset, + test->pattern.length, + test->pattern.value); + if (!pattern) { + tester_setup_failed(); + return; + } + + test->advmon_pattern = pattern; + tester_setup_complete(); +} + +/* Cleanup after the Content Filter test is done */ +static void teardown_content_filter_test(gpointer data) +{ + struct content_filter_test *test = data; + + if (!test) + tester_teardown_complete(); + + btd_adv_monitor_test_pattern_destroy(test->advmon_pattern); + test->advmon_pattern = NULL; + + tester_teardown_complete(); +} + +/* Execute the sub-steps of Content Filter test */ +static void test_content_filter(gpointer data) +{ + struct content_filter_test *test = data; + struct btd_adv_monitor_pattern *pattern = test->advmon_pattern; + + if (!pattern) { + tester_test_abort(); + return; + } + + if (btd_adv_monitor_pattern_match(test->eir, test->eir_len, + test->advmon_pattern) == + test->expected_match) { + tester_test_passed(); + return; + } + + tester_test_failed(); +} + /* Handler function to prepare for a test */ static void setup_handler(gconstpointer data) { @@ -350,6 +479,8 @@ static void setup_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) setup_rssi_filter_test(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + setup_content_filter_test(test->content_filter_test_data); } /* Handler function to cleanup after the test is done */ @@ -359,6 +490,8 @@ static void teardown_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) teardown_rssi_filter_test(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + teardown_content_filter_test(test->content_filter_test_data); } /* Handler function to execute a test with the given data set */ @@ -368,6 +501,8 @@ static void test_handler(gconstpointer data) if (test->test_type == TEST_RSSI_FILTER) test_rssi_filter(test->rssi_filter_test_data); + else if (test->test_type == TEST_CONTENT_FILTER) + test_content_filter(test->content_filter_test_data); } int main(int argc, char *argv[]) @@ -387,5 +522,14 @@ int main(int argc, char *argv[]) define_test("/advmon/rssi/5", TEST_RSSI_FILTER, rssi_data_5, setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/1", TEST_CONTENT_FILTER, content_data_1, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/2", TEST_CONTENT_FILTER, content_data_2, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/3", TEST_CONTENT_FILTER, content_data_3, + setup_handler, test_handler, teardown_handler); + define_test("/advmon/content/4", TEST_CONTENT_FILTER, content_data_4, + setup_handler, test_handler, teardown_handler); + return tester_run(); } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ENF+CarUY19etwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:27:06 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wOZXBqrUY191+gEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:27:06 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DD4CCA0AAE; Thu, 17 Sep 2020 23:26:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725900AbgIQV0z (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:26:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726093AbgIQV0y (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:26:54 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9480C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:26:54 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id f2so2125095pgd.3 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u+E1bUX0uVxPcQEsE71u1Ro0+1uBNDa00K7AzDVg6ww=; b=Ji12d2I+xIP9TkuKMxzY7lLdez/m917yxrVd+LOosDiPypATXUteVq2nu47hU6p96r z1Ev92MYfhGl5y9VZScViBFV0o3AgOSKVleifHo794bUupBP3Wt0/6AMGmMrT6N0r4wf ZT0JwVBzzQnmVLw9sQA7B8wGKX0rQHeLpu8z4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u+E1bUX0uVxPcQEsE71u1Ro0+1uBNDa00K7AzDVg6ww=; b=GPu2TUClsO1IZ02MFEPm/aNCokERrcCFcAqiSXsZ/BEbRrfBNX27rlThHLjxfBpYkd 37WGyV5yFWstLduLS6PqRNLHrLLh/D9652XHeBHKliYy9QsMqgGcL5b287vm34/4FAUY 2gzyaYDix8cfEexJOZtx/s+tgUO2JQhD5IfL/PzcSNl1iikYtUadGeMteDSzeWXZIdpL U5igGryCRGgntxQaEyNxx7aCa5tUsLkQX3UkaP0fIEyoz1AMxWd+ct4j2IZhDMJt7e2C PaV4eQsgK0mDPBKr6Sr4FuWXKns/vY/VOmOZQkDD8BJhQcDp8ksrF1I1hxZEMrwaBdbc C5MQ== X-Gm-Message-State: AOAM532jgMIselg6ueuEmfaY8WGbBgm29kjnrURttwQ+CuYDWuaB4akd Bx+7RXkOD7OqhxBjspizbFFkngw4271HJg== X-Google-Smtp-Source: ABdhPJzYHT3fD29H0wEN9tNmxNBB7H7dyI88AQoN3ZBT0bxosOdGO8gcjWBfdL7uLDIWUVGN/i3HLg== X-Received: by 2002:a63:4b63:: with SMTP id k35mr25002876pgl.235.1600378013897; Thu, 17 Sep 2020 14:26:53 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y3sm645308pfb.18.2020.09.17.14.26.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 14:26:53 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 5/8] adapter: Clear all Adv monitors upon bring-up Date: Thu, 17 Sep 2020 14:25:37 -0700 Message-Id: <20200917142456.BlueZ.v4.5.Id6bfe7838831ae01fddc8605689dd77b51673960@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.73 / 15.00 / 15.00 X-Rspamd-Queue-Id: DD4CCA0AAE X-Rspamd-UID: 4d7e95 This clears all Adv monitors upon daemon bring-up by issuing MGMT_OP_REMOVE_ADV_MONITOR command with monitor_handle 0. The following test was performed: - Add an Adv Monitor using btmgmt, restart bluetoothd and observe the monitor got removed. Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Howard Chung <howardchung@google.com> --- (no changes since v1) src/adapter.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index d33ce7124..191467048 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -9513,6 +9513,43 @@ failed: btd_adapter_unref(adapter); } +static void reset_adv_monitors_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct mgmt_rp_remove_adv_monitor *rp = param; + + if (status != MGMT_STATUS_SUCCESS) { + error("Failed to reset Adv Monitors: %s (0x%02x)", + mgmt_errstr(status), status); + return; + } + + if (length < sizeof(*rp)) { + error("Wrong size of remove Adv Monitor response for reset " + "all Adv Monitors"); + return; + } + + DBG("Removed all Adv Monitors"); +} + +static void reset_adv_monitors(uint16_t index) +{ + struct mgmt_cp_remove_adv_monitor cp; + + DBG("sending remove Adv Monitor command with handle 0"); + + /* Handle 0 indicates to remove all */ + cp.monitor_handle = 0; + if (mgmt_send(mgmt_master, MGMT_OP_REMOVE_ADV_MONITOR, index, + sizeof(cp), &cp, reset_adv_monitors_complete, NULL, + NULL) > 0) { + return; + } + + error("Failed to reset Adv Monitors"); +} + static void index_added(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9527,6 +9564,8 @@ static void index_added(uint16_t index, uint16_t length, const void *param, return; } + reset_adv_monitors(index); + adapter = btd_adapter_new(index); if (!adapter) { btd_error(index, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GLqeEbrUY19etwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:27:22 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2NJ9DrrUY19oUQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:27:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 18595A0B1B; Thu, 17 Sep 2020 23:27:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726097AbgIQV1P (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbgIQV1P (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:27:15 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DD05C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:27:15 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id g29so2130220pgl.2 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:27:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jpH7NYjDXQwuZdzQVcmilO29fJlXT96VJgzaA+Ly14g=; b=Xcp1U/2JY6ctAXYqidaaNFFD/JB48aTqnfyIVkF5Uuc4UJVxTwBv6VX95unKAy/d+s gNIguLkU+LnvMWqR4mYiZ1hVe3JA0VaB/knc4+TX1A3Zx7aOIXVR615pyMjdJ1zepK6p M9/7tvQMwV9aD1VvQIVNExbhPNpm+g39DEC5E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jpH7NYjDXQwuZdzQVcmilO29fJlXT96VJgzaA+Ly14g=; b=UvDSag3/nvyBec2z4koWqhN29AbJLl/n71NBchHmrcGIHX9AjY4Q9OPDvPHVNOqzHh elbSi/eFrrkYfaHX6mnL7b2ZpGYIWe2Kabx1dJSHIZXE7O4CozUHN+TirwlGntWArAEh k3AKDd41WTlfXCXwv6fptBslcfMlX95F8/HBf3V8YvHyDTVpXIL2nn55Ucc6npaO84fx iNAIfO6lQyLapAWG8E+VGljfQR97HnuWfpORM2fftzmeqLrwjOlvGdSs0DEwwke5HSIj ZXuUVUQWXmgDnyd0drwbApSykbRW2Qpf0zvXIDWLi+7a+knMvqrCGQLriWQmSeEHrGpq jHbQ== X-Gm-Message-State: AOAM530+AQYGTZuHMlB2L0drBe9NASYBGuvpjtPsg1DyCJqXRKRCO+Zf RbxrzIiJCiVdCTKFrTPxF3qRw55dzNs+Kw== X-Google-Smtp-Source: ABdhPJyK8fvClQgg1mcvN0ndZxNBNvM6VNuYyo8n63WFmU/BpsWdKdT57bb0huRDhaRKxNYM+99hKw== X-Received: by 2002:a62:1d51:0:b029:13e:d13d:a0fc with SMTP id d78-20020a621d510000b029013ed13da0fcmr29459212pfd.24.1600378034575; Thu, 17 Sep 2020 14:27:14 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y3sm645308pfb.18.2020.09.17.14.27.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 14:27:13 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 6/8] adv_monitor: Implement Add Adv Patterns Monitor cmd handler Date: Thu, 17 Sep 2020 14:25:39 -0700 Message-Id: <20200917142456.BlueZ.v4.6.Ibbcb11712b613ef95c31b41207c3ea945c830018@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.47 / 15.00 / 15.00 X-Rspamd-Queue-Id: 18595A0B1B X-Rspamd-UID: 74cb56 From: Howard Chung <howardchung@google.com> - Send the MGMT_OP command to kernel upon registration of a Adv patterns monitor. - Call Activate() or Release() to client depending on the reply from kernel Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 211094c89..deaa1894a 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -609,11 +609,59 @@ done: return monitor->state != MONITOR_STATE_FAILED; } +/* Handles the callback of Add Adv Patterns Monitor command */ +static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_rp_add_adv_patterns_monitor *rp = param; + struct adv_monitor *monitor = user_data; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(adapter_id, "Failed to Add Adv Patterns Monitor " + "with status 0x%02x", status); + monitor_release(monitor, NULL); + return; + } + + if (length < sizeof(*rp)) { + btd_error(adapter_id, "Wrong size of Add Adv Patterns Monitor " + "response"); + monitor_release(monitor, NULL); + return; + } + + monitor->state = MONITOR_STATE_HONORED; + + DBG("Calling Activate() on Adv Monitor of owner %s at path %s", + monitor->app->owner, monitor->path); + + g_dbus_proxy_method_call(monitor->proxy, "Activate", NULL, NULL, NULL, + NULL); + + DBG("Adv Monitor with handle:0x%04x added", + le16_to_cpu(rp->monitor_handle)); +} + +static void monitor_copy_patterns(void *data, void *user_data) +{ + struct btd_adv_monitor_pattern *pattern = data; + struct mgmt_cp_add_adv_monitor *cp = user_data; + + if (!pattern) + return; + + memcpy(cp->patterns + cp->pattern_count, pattern, sizeof(*pattern)); + cp->pattern_count++; +} + /* Handles an Adv Monitor D-Bus proxy added event */ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) { struct adv_monitor *monitor; struct adv_monitor_app *app = user_data; + struct mgmt_cp_add_adv_monitor *cp = NULL; + uint8_t pattern_count, cp_len; uint16_t adapter_id = app->manager->adapter_id; const char *path = g_dbus_proxy_get_path(proxy); const char *iface = g_dbus_proxy_get_interface(proxy); @@ -646,7 +694,24 @@ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) queue_push_tail(app->monitors, monitor); + pattern_count = queue_length(monitor->patterns); + cp_len = sizeof(struct mgmt_cp_add_adv_monitor) + + pattern_count * sizeof(struct mgmt_adv_pattern); + + cp = malloc0(cp_len); + queue_foreach(monitor->patterns, monitor_copy_patterns, cp); + + if (!mgmt_send(app->manager->mgmt, MGMT_OP_ADD_ADV_PATTERNS_MONITOR, + adapter_id, cp_len, cp, add_adv_patterns_monitor_cb, + monitor, NULL)) { + error("Unable to send Add Adv Patterns Monitor command"); + goto done; + } + DBG("Adv Monitor allocated for the object at path %s", path); + +done: + free(cp); } /* Handles the removal of an Adv Monitor D-Bus proxy */ @@ -1063,7 +1128,7 @@ static void adv_match_per_monitor(void *data, void *user_data) struct adv_monitor *monitor = data; struct adv_content_filter_info *info = user_data; - if (!monitor && monitor->state != MONITOR_STATE_HONORED) + if (!monitor || monitor->state != MONITOR_STATE_HONORED) return; /* Reset the intermediate matched status */ -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UBQmAs3UY19b3AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:27:41 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id KMFOO8zUY1+OPwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:27:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id ECBD9A0B1B; Thu, 17 Sep 2020 23:27:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726102AbgIQV1e (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:27:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbgIQV1e (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:27:34 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4969DC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:27:34 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id s14so3346272pju.1 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A+EJCB6WY4TQKa6gHOsgkF94rPPA4eTIhn24gfOv1nI=; b=Zani3H6VtsaUJcruJQsYMYEOUqG9tZpNV+x9+oLeYJcY5Hl8dlvq3dZCk2+ttcr3DA +x2Bk87hhK9mv7eNUjJRSAyv0mIl/MAzcVpHuGVfSa/MZEDSGOEF+jrrKel4kTk2EcZd UecOW+uxl6T4UeRQZ/5/NHxTl6QjaBu2N0xPs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A+EJCB6WY4TQKa6gHOsgkF94rPPA4eTIhn24gfOv1nI=; b=X+XsbwpCTY1WxrDDMzi5WhpekhJrNHwc0VCLynmW99b0kbeZLWQCuGuga5Rq1Upk2M yB7+jMX6i/yAbMaT+KHX9xYA8KYUoshjy5zUCY0BINqMNyIebMbj5X9l/yjvI6ZG9HUn BWjecKmvLNAmXRmCgN1Cia/YxdsC4EOaHvzyBF1BDSFlH/rG/MKwCtiiTQLCt3lel6os WkSbEaKX7mjKCIQ+DEtmvA5jsSGJ5u38HCuL8NGGoIfYgvWHK4PRfh+U8RAkmhRoTkIF kKMF7tIsSaakh0cjnq94knmO18iC4gfcwHtJ7G+CQ5jlt9oAPqUUJxEaGHG+rA+Vjdgo /CMQ== X-Gm-Message-State: AOAM530Uh5UctAfkdAAVb0EUwvzGrECezycr9dJpblk1Fym58W/ZSwka xE4AhN1Hw+cpu27Y0Nm4cO1sqpGMD2guNg== X-Google-Smtp-Source: ABdhPJwZwZK40sLv14d+Pa5o2OW2rKyUXFrwhqwx/dqOCwA0fE9szlX4rR6MSLneDZVl7Swt7fhx8A== X-Received: by 2002:a17:90b:208b:: with SMTP id hb11mr10315623pjb.201.1600378053358; Thu, 17 Sep 2020 14:27:33 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y3sm645308pfb.18.2020.09.17.14.27.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 14:27:32 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com>, Miao-chen Chou <mcchou@chromium.org> Subject: [BlueZ PATCH v4 7/8] adv_monitor: Fix return type of RegisterMonitor() method Date: Thu, 17 Sep 2020 14:25:41 -0700 Message-Id: <20200917142456.BlueZ.v4.7.Ic8dbe9115e82704b4c0c860eee27ad897db13237@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.93 / 15.00 / 15.00 X-Rspamd-Queue-Id: ECBD9A0B1B X-Rspamd-UID: f05777 This modifies the D-Bus call return type to be asynchronous for RegisterMonitor() method call. The following test was performed: - Enter bluetoothctl, exit the console and re-enter the console without AlreadyExist error for RegisterMonitor() upon bring-up of the console. Reviewed-by: Howard Chung <howardchung@google.com> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) src/adv_monitor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index deaa1894a..b4fe39eff 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -758,6 +758,8 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, app->monitors = queue_new(); + app->reg = dbus_message_ref(msg); + g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app); /* Note that any property changes on a monitor object would not affect @@ -769,8 +771,6 @@ static struct adv_monitor_app *app_create(DBusConnection *conn, g_dbus_client_set_ready_watch(app->client, app_ready_cb, app); - app->reg = dbus_message_ref(msg); - return app; } @@ -864,7 +864,7 @@ static DBusMessage *unregister_monitor(DBusConnection *conn, } static const GDBusMethodTable adv_monitor_methods[] = { - { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor", + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("RegisterMonitor", GDBUS_ARGS({ "application", "o" }), NULL, register_monitor) }, { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor", -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uAuBKePUY19etwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:28:03 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id OLhXJuPUY191+gEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:28:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 479FAA0B42; Thu, 17 Sep 2020 23:27:54 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726037AbgIQV1y (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbgIQV1y (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:27:54 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE2F9C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:27:53 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id c3so1815976plz.5 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IGXBdByqD7HsOqnIbwtUTK9E1HPMAMGL/lLtrjYKF80=; b=i0mQ02h0jVRSsMR1YOmryJD/nlg7wBMGJy60iD6cxCsSbK/1Qpsz1XefGbsX/5qW+a eVRbemE7bKkjY5sFmmAD2AeLzU27Zt5LaRF/zvACRXMtrEoJMeDAxmHEDRN/+KGe4KZL ESCAzrlaKsgH8R00JfD2B6hL84J/a+u4M11LA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IGXBdByqD7HsOqnIbwtUTK9E1HPMAMGL/lLtrjYKF80=; b=Kb5RyXdFfSOloLsfbYT43O5fmuCbMrCk8cZ9OBcnSd1ZwNyyVXMBxISvKaxx1ADWFq LLlnOTmt0rdmeB+LXPvgfcHcKmIi/71F6kXpOG0SVP+cQO21SdyBR8cOkmmQ4Svqqaf1 QXh7fQun26Y9vkPpry6+c1YGYfK8Q/ANSY30TB0PbYAyxd3eTku7/FlWoSNVT4JUDbJ2 PK1WEDUCFDCcxR32yhZkPydtTGy0BMTNu/1S7PQ4HxrdUettGlX8/o2S772vMYuMCBT2 FSCn3d1EhDZ4tHKQ0YaEPLt93k5889ZdnAhmmuMNDuPoBeHbGwWq9Rs8I+YvGjtEidwh FnqQ== X-Gm-Message-State: AOAM530MfLG7SArXkkTHQ8/4csnE+Mw9SjO2N1vpqGQnoNtXc9Swiqcs /urA+x2mHw4lmNSIKFbkRISTLfLWNTpIMg== X-Google-Smtp-Source: ABdhPJwWR7ZHwKRo5RWUkpmXtjRo3XFbxX0OiP1WalQPL2QydRyxsMzUUdr7RyNSWar0ixFriJK47Q== X-Received: by 2002:a17:902:6a81:b029:d1:e5e7:be60 with SMTP id n1-20020a1709026a81b02900d1e5e7be60mr12583812plk.58.1600378073125; Thu, 17 Sep 2020 14:27:53 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:de4a:3eff:fe75:1314]) by smtp.gmail.com with ESMTPSA id y3sm645308pfb.18.2020.09.17.14.27.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 14:27:52 -0700 (PDT) From: Miao-chen Chou <mcchou@chromium.org> To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org> Cc: Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, chromeos-bluetooth-upstreaming@chromium.org, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Marcel Holtmann <marcel@holtmann.org>, Howard Chung <howardchung@google.com> Subject: [BlueZ PATCH v4 8/8] adv_monitor: Issue Remove Adv Monitor mgmt call Date: Thu, 17 Sep 2020 14:25:43 -0700 Message-Id: <20200917142456.BlueZ.v4.8.Ifda683c92ff520bf58ac37c02dc40b8d9598d1b0@changeid> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.18 / 15.00 / 15.00 X-Rspamd-Queue-Id: 479FAA0B42 X-Rspamd-UID: 02317c From: Alain Michaud <alainm@chromium.org> This calls Remove Adv Monitor command to kernel and handles the callback during a monitor removal initiated by a D-Bus client. This also registers callback for getting notified on Adv Monitor Removed event, so that the Adv monitor manager can invalidate the monitor by calling Release() on its proxy. The following tests were performed. - In bluetoothctl console, add a monitor and remove the monitor by its index and verify the removal in both the output of btmgmt and syslog. - In bluetoothctl console, add a monitor, remove the monitor via btmgmt and verify the removal in syslog. Reviewed-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v4: - Fix build error Changes in v3: - Fix const qualifier of a pointer src/adv_monitor.c | 132 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 124 insertions(+), 8 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index b4fe39eff..e2ad907cf 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -88,6 +88,7 @@ enum monitor_state { MONITOR_STATE_FAILED, /* Failed to be init'ed */ MONITOR_STATE_INITED, /* Init'ed but not yet sent to kernel */ MONITOR_STATE_HONORED, /* Accepted by kernel */ + MONITOR_STATE_REMOVING, /* Removing from kernel */ }; struct btd_adv_monitor_pattern { @@ -103,6 +104,7 @@ struct adv_monitor { char *path; enum monitor_state state; /* MONITOR_STATE_* */ + uint16_t monitor_handle; /* Kernel Monitor Handle */ int8_t high_rssi; /* High RSSI threshold */ uint16_t high_rssi_timeout; /* High RSSI threshold timeout */ @@ -631,6 +633,7 @@ static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, return; } + monitor->monitor_handle = le16_to_cpu(rp->monitor_handle); monitor->state = MONITOR_STATE_HONORED; DBG("Calling Activate() on Adv Monitor of owner %s at path %s", @@ -639,8 +642,7 @@ static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, g_dbus_proxy_method_call(monitor->proxy, "Activate", NULL, NULL, NULL, NULL); - DBG("Adv Monitor with handle:0x%04x added", - le16_to_cpu(rp->monitor_handle)); + DBG("Adv monitor with handle:0x%04x added", monitor->monitor_handle); } static void monitor_copy_patterns(void *data, void *user_data) @@ -714,20 +716,77 @@ done: free(cp); } +/* Handles the callback of Remove Adv Monitor command */ +static void remove_adv_monitor_cb(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct adv_monitor *monitor = user_data; + const struct mgmt_rp_remove_adv_monitor *rp = param; + uint16_t adapter_id = monitor->app->manager->adapter_id; + + if (status != MGMT_STATUS_SUCCESS || !param) { + btd_error(adapter_id, "Failed to Remove Adv Monitor with " + "status 0x%02x", status); + goto done; + } + + if (length < sizeof(*rp)) { + btd_error(adapter_id, "Wrong size of Remove Adv Monitor " + "response"); + goto done; + } + +done: + queue_remove(monitor->app->monitors, monitor); + + DBG("Adv Monitor removed with handle:0x%04x, path %s", + monitor->monitor_handle, monitor->path); + + monitor_free(monitor); +} + + /* Handles the removal of an Adv Monitor D-Bus proxy */ static void monitor_proxy_removed_cb(GDBusProxy *proxy, void *user_data) { struct adv_monitor *monitor; + struct mgmt_cp_remove_adv_monitor cp; struct adv_monitor_app *app = user_data; + uint16_t adapter_id = app->manager->adapter_id; - monitor = queue_remove_if(app->monitors, monitor_match, proxy); - if (monitor) { - DBG("Adv Monitor removed for the object at path %s", - monitor->path); + monitor = queue_find(app->monitors, monitor_match, proxy); - /* The object was gone, so we don't need to call Release() */ - monitor_free(monitor); + /* A monitor removed event from kernel can remove a monitor and notify + * the app on Release() where this callback can be invoked, so we + * simply skip here. + */ + if (!monitor) + return; + + if (monitor->state != MONITOR_STATE_HONORED) + goto done; + + monitor->state = MONITOR_STATE_REMOVING; + + cp.monitor_handle = cpu_to_le16(monitor->monitor_handle); + + if (!mgmt_send(app->manager->mgmt, MGMT_OP_REMOVE_ADV_MONITOR, + adapter_id, sizeof(cp), &cp, remove_adv_monitor_cb, + monitor, NULL)) { + btd_error(adapter_id, "Unable to send Remove Advt Monitor " + "command"); + goto done; } + + return; + +done: + queue_remove(app->monitors, monitor); + + DBG("Adv Monitor removed in state %02x with path %s", monitor->state, + monitor->path); + + monitor_free(monitor); } /* Creates an app object, initiates it and sets D-Bus event handlers */ @@ -936,6 +995,59 @@ static const GDBusPropertyTable adv_monitor_properties[] = { { } }; +/* Matches a monitor based on its handle */ +static bool removed_monitor_match(const void *data, const void *user_data) +{ + const uint16_t *handle = user_data; + const struct adv_monitor *monitor = data; + + if (!data || !handle) + return false; + + return monitor->monitor_handle == *handle; +} + +/* Remove the matched monitor and reports the removal to the app */ +static void app_remove_monitor(void *data, void *user_data) +{ + struct adv_monitor_app *app = data; + struct adv_monitor *monitor; + + monitor = queue_find(app->monitors, removed_monitor_match, user_data); + if (monitor) { + if (monitor->state == MONITOR_STATE_HONORED) + monitor_release(monitor, NULL); + + queue_remove(app->monitors, monitor); + + DBG("Adv Monitor at path %s removed", monitor->path); + + monitor_free(monitor); + } +} + +/* Processes Adv Monitor removed event from kernel */ +static void adv_monitor_removed_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + struct btd_adv_monitor_manager *manager = user_data; + const struct mgmt_ev_adv_monitor_removed *ev = param; + uint16_t handle = ev->monitor_handle; + const uint16_t adapter_id = manager->adapter_id; + + if (length < sizeof(*ev)) { + btd_error(adapter_id, "Wrong size of Adv Monitor Removed " + "event"); + return; + } + + /* Traverse the apps to find the monitor */ + queue_foreach(manager->apps, app_remove_monitor, &handle); + + DBG("Adv Monitor removed event with handle 0x%04x processed", + ev->monitor_handle); +} + /* Allocates a manager object */ static struct btd_adv_monitor_manager *manager_new( struct btd_adapter *adapter, @@ -955,6 +1067,10 @@ static struct btd_adv_monitor_manager *manager_new( manager->adapter_id = btd_adapter_get_index(adapter); manager->apps = queue_new(); + mgmt_register(manager->mgmt, MGMT_EV_ADV_MONITOR_REMOVED, + manager->adapter_id, adv_monitor_removed_callback, + manager, NULL); + return manager; } -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YGYKAtbZY1/a9wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:49:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SMWKOtXZY1+p0wEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:49:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DE68B40014; Thu, 17 Sep 2020 23:49:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725987AbgIQVtD (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbgIQVtD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:49:03 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83E79C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:49:02 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id p15so1811121qvk.5 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=I7JMbI6mhJEkXtALsnZMYNxrFH0u/Eq4oP/lweS505Y=; b=Uh5l6VV/UhIOvB5xZcw9B79q5066Qc9cbcNs9hIakymcKJVP0S+30s/BZRRc8mOLgf cBhZspT5diTbdR5wJioSGLpsdOB+ty6Z4DiXPP5lq0V3QgRser0fS5SztLZbFMqPE2sD TZ3+YVsCXQ7tJnjCymcS3+GmgusF6pFL4ss73WW/Cs10vAsoOQ26V6/QRHNJTYa0+wET yKBv7skZOHYEUregexDs2WkFwPQFVrBl6l0PCPQEq9t7gsUZroptB8WHvT2+zsbcDGVz SNoGAyV9ih7lId7FaiaJwyobTuQqwMQT2fWyUVzFlgu6D76XiAOPPcj9sBXIMaSCSmtQ yqxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=I7JMbI6mhJEkXtALsnZMYNxrFH0u/Eq4oP/lweS505Y=; b=uAXQszvCK/+jYctD0elAB8kCVqK5UHQlFmH9ELvFkhlZixBhQBE+kHJsoQKULIp3zJ LQlJDyHGIfn9ktpqTq6xnTcfqk+cHRN1e3Bqos2/biL3ofcsV4xQWezIDxfqBbY3Xv5d 1kt4var/lbPPyBCUZ9fK4qdYfDYGsVkokcsLoH1SfFmuFuZ+w77UKrdUZN9kEnWDW4VH Bw+RV69hXKAnzaQcQ8+kO4cQ7BENmTL9FaQJ4ihdr+p66kzYaiYEADY3eg16GnF3ZBE9 GZA7Yjz1iwxqXaPJj8feW+4iHetdWI2xbZ+GLwKxbrIWdNJ4nHgebS6b8F/EN9I8Bdls rPKw== X-Gm-Message-State: AOAM533EVCivDAfl3N1+YSBG+S33mNhD0saliUkLlwkvLKLudaKg6EC2 h+TWxC0dOvin78vJUqJt6FOv1n2ORPWA/g== X-Google-Smtp-Source: ABdhPJwBHiBsY0RHg8qUO1vw9DxpyeOYQlUQFR4wqiyBxZ6hD7DLqE+LrW6VbyV/Wjn39oI+SVmXRg== X-Received: by 2002:a0c:c244:: with SMTP id w4mr30898973qvh.12.1600379340668; Thu, 17 Sep 2020 14:49:00 -0700 (PDT) Received: from [172.17.0.2] ([20.186.152.21]) by smtp.gmail.com with ESMTPSA id d10sm775201qkk.1.2020.09.17.14.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 14:49:00 -0700 (PDT) Message-ID: <5f63d9cc.1c69fb81.8ea44.56ca@mx.google.com> Date: Thu, 17 Sep 2020 14:49:00 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============2336312357875185178==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v4,2/8] adv_monitor: Implement unit tests for RSSI Filter Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200917142456.BlueZ.v4.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> References: <20200917142456.BlueZ.v4.2.I5ae05701b2b792a3ea2ca98f4a5d977645b1afc2@changeid> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.08 / 15.00 / 15.00 X-Rspamd-Queue-Id: DE68B40014 X-Rspamd-UID: 2b2632 --===============2336312357875185178== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #161: FILE: unit/test-adv-monitor.c:1: +/* - total: 0 errors, 1 warnings, 512 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============2336312357875185178==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mHWZEjPaY1/a9wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:50:43 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SNClDzPaY1+4RgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:50:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 788FD4086A; Thu, 17 Sep 2020 23:50:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725987AbgIQVue (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbgIQVud (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:50:33 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0F6BC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:50:33 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id c13so4304018oiy.6 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=dcDuhIOEctqtMrFH6PKkvye8CWMXaDHL8OqmOzknPBI=; b=EumneyznLxWcruiV5drfP15DvQzG9CroOActUdJe2VXbrC3BXKYKWSJvP8T71B4ZET PuASyRs7tKzdSKb6uZ/u8E1HyoYCxppAUQHrV/Uwfb4F//s5++GPtjyK0dBjY2TusQWP SSxoiTq9kEN3nsqhjA285VDZKZ4NrCpTvP6RTFukKFS/ourvwjrXjFZBGq23xHz9O5Ut CoA/7yfq0g+dzmIlxAB11ndssVFR/zr7sefMTayftph0ypIfVc6n5q4dDFdCcnh836jE 9w7goB4Up+S1wul1kcUNnhNV6J44K3yH+/rC6Y/JGV7t+g01fGpdXQqFs2is7qxmmdUl LkZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=dcDuhIOEctqtMrFH6PKkvye8CWMXaDHL8OqmOzknPBI=; b=pMakqVytKJLxcM7U/A1LjU5bf36TLuQMYlp5bDOzsVXdE+FFpmOpwmxW4wEib/XCuK zREL3Ah3DSq1DK8QWyqSNVEcxyHy2GMbP90jBsQUe+noBPFgcE3hJh0HohUdcMtHLKUH hzLMP/GwoRFurEDA5uSgZJJmt4AUJle3CahOykRJKpORRKFkGn/48g5N/1hjMa5k17ra vPqPCCPP5xZVOSeNA5erq2OPEyz6DBz6brqhwxaQvJApUWez1VIxwYpedhQY8obLrPWO /mFaseVVvHfVJ0GpQw+tZkKfzz32Pt1Q/SCDIWomcEVmtVMVbU4W4Mpxk+fkcyuOkEzy Gx3A== X-Gm-Message-State: AOAM530cmvEUP6l2Wi1L+jnekoLyxUF0r1Y9HGNL6R1hlZ5hFXnTjRXM rvt2ZAzsVvyrzr+I2M6oTJZ4BsKZzUvBLTiTpom5LeRm X-Google-Smtp-Source: ABdhPJwc8RFtYVuMCdSkH3MPHXPVARDRHDjCeRvJ7SToh/COrKUuWPiUb6KDeyObFDhIEdeuxfpryN/ElW++EMT4BCs= X-Received: by 2002:aca:1b01:: with SMTP id b1mr7861925oib.137.1600379432736; Thu, 17 Sep 2020 14:50:32 -0700 (PDT) MIME-Version: 1.0 References: <20200819000212.211485-1-luiz.dentz@gmail.com> In-Reply-To: <20200819000212.211485-1-luiz.dentz@gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Thu, 17 Sep 2020 14:50:21 -0700 Message-ID: <CABBYNZ+E-AaS1-GTmq6CJv-GD2+pj5PDm5tuhzPJa-syYZUyXA@mail.gmail.com> Subject: Re: [PATCH v2 1/3] sbc: Add initial code for SSE primitives To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.80 / 15.00 / 15.00 X-Rspamd-Queue-Id: 788FD4086A X-Rspamd-UID: bd9a99 Hi, On Tue, Aug 18, 2020 at 5:02 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > --- > Makefile.am | 1 + > sbc/sbc_primitives.c | 18 +- > sbc/sbc_primitives_mmx.c | 49 +----- > sbc/sbc_primitives_sse.c | 365 +++++++++++++++++++++++++++++++++++++++ > sbc/sbc_primitives_sse.h | 38 ++++ > 5 files changed, 428 insertions(+), 43 deletions(-) > create mode 100644 sbc/sbc_primitives_sse.c > create mode 100644 sbc/sbc_primitives_sse.h > > diff --git a/Makefile.am b/Makefile.am > index 342043d..7ff0c7d 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -14,6 +14,7 @@ sbc_headers = sbc/sbc.h > > sbc_sources = sbc/sbc.c sbc/sbc_private.h sbc/sbc_math.h sbc/sbc_tables.h \ > sbc/sbc_primitives.h sbc/sbc_primitives.c \ > + sbc/sbc_primitives_sse.h sbc/sbc_primitives_sse.c \ > sbc/sbc_primitives_mmx.h sbc/sbc_primitives_mmx.c \ > sbc/sbc_primitives_iwmmxt.h sbc/sbc_primitives_iwmmxt.c \ > sbc/sbc_primitives_neon.h sbc/sbc_primitives_neon.c \ > diff --git a/sbc/sbc_primitives.c b/sbc/sbc_primitives.c > index ff343cf..c9d1045 100644 > --- a/sbc/sbc_primitives.c > +++ b/sbc/sbc_primitives.c > @@ -33,6 +33,7 @@ > #include "sbc_tables.h" > > #include "sbc_primitives.h" > +#include "sbc_primitives_sse.h" > #include "sbc_primitives_mmx.h" > #include "sbc_primitives_iwmmxt.h" > #include "sbc_primitives_neon.h" > @@ -590,6 +591,19 @@ static int sbc_calc_scalefactors_j( > return joint; > } > > +static void sbc_init_primitives_x86(struct sbc_encoder_state *state) > +{ > + __builtin_cpu_init(); > + > + if (__builtin_cpu_supports("mmx")) > + sbc_init_primitives_mmx(state); > + > +#ifdef SBC_BUILD_WITH_SSE_SUPPORT > + if (__builtin_cpu_supports("sse4.2")) > + sbc_init_primitives_sse(state); > +#endif > +} > + > /* > * Detect CPU features and setup function pointers > */ > @@ -614,9 +628,7 @@ void sbc_init_primitives(struct sbc_encoder_state *state) > state->implementation_info = "Generic C"; > > /* X86/AMD64 optimizations */ > -#ifdef SBC_BUILD_WITH_MMX_SUPPORT > - sbc_init_primitives_mmx(state); > -#endif > + sbc_init_primitives_x86(state); > > /* ARM optimizations */ > #ifdef SBC_BUILD_WITH_ARMV6_SUPPORT > diff --git a/sbc/sbc_primitives_mmx.c b/sbc/sbc_primitives_mmx.c > index e2c3e56..6984ce5 100644 > --- a/sbc/sbc_primitives_mmx.c > +++ b/sbc/sbc_primitives_mmx.c > @@ -350,50 +350,19 @@ static void sbc_calc_scalefactors_mmx( > __asm__ volatile ("emms\n"); > } > > -static int check_mmx_support(void) > +void sbc_init_primitives_mmx(struct sbc_encoder_state *state) > { > -#ifdef __amd64__ > - return 1; /* We assume that all 64-bit processors have MMX support */ > -#else > - int cpuid_feature_information; > - __asm__ volatile ( > - /* According to Intel manual, CPUID instruction is supported > - * if the value of ID bit (bit 21) in EFLAGS can be modified */ > - "pushf\n" > - "movl (%%esp), %0\n" > - "xorl $0x200000, (%%esp)\n" /* try to modify ID bit */ > - "popf\n" > - "pushf\n" > - "xorl (%%esp), %0\n" /* check if ID bit changed */ > - "jz 1f\n" > - "push %%eax\n" > - "push %%ebx\n" > - "push %%ecx\n" > - "mov $1, %%eax\n" > - "cpuid\n" > - "pop %%ecx\n" > - "pop %%ebx\n" > - "pop %%eax\n" > - "1:\n" > - "popf\n" > - : "=d" (cpuid_feature_information) > - : > - : "cc"); > - return cpuid_feature_information & (1 << 23); > -#endif > + state->sbc_analyze_4s = sbc_analyze_4b_4s_mmx; > + if (state->increment == 1) > + state->sbc_analyze_8s = sbc_analyze_1b_8s_mmx_odd; > + else > + state->sbc_analyze_8s = sbc_analyze_4b_8s_mmx; > + state->sbc_calc_scalefactors = sbc_calc_scalefactors_mmx; > + state->implementation_info = "MMX"; > } > > +#else > void sbc_init_primitives_mmx(struct sbc_encoder_state *state) > { > - if (check_mmx_support()) { > - state->sbc_analyze_4s = sbc_analyze_4b_4s_mmx; > - if (state->increment == 1) > - state->sbc_analyze_8s = sbc_analyze_1b_8s_mmx_odd; > - else > - state->sbc_analyze_8s = sbc_analyze_4b_8s_mmx; > - state->sbc_calc_scalefactors = sbc_calc_scalefactors_mmx; > - state->implementation_info = "MMX"; > - } > } > - > #endif > diff --git a/sbc/sbc_primitives_sse.c b/sbc/sbc_primitives_sse.c > new file mode 100644 > index 0000000..42cdb03 > --- /dev/null > +++ b/sbc/sbc_primitives_sse.c > @@ -0,0 +1,365 @@ > +/* > + * > + * Bluetooth low-complexity, subband codec (SBC) library > + * > + * Copyright (C) 2020 Intel Corporation > + * > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > + * > + */ > + > +#include <stdint.h> > +#include <limits.h> > +#include "sbc.h" > +#include "sbc_math.h" > +#include "sbc_tables.h" > + > +#include "sbc_primitives_sse.h" > + > +/* > + * SSE optimizations > + */ > + > +#ifdef SBC_BUILD_WITH_SSE_SUPPORT > + > +static inline void sbc_analyze_four_sse(const int16_t *in, int32_t *out, > + const FIXED_T *consts) > +{ > + static const SBC_ALIGNED int32_t round_c[2] = { > + 1 << (SBC_PROTO_FIXED4_SCALE - 1), > + 1 << (SBC_PROTO_FIXED4_SCALE - 1), > + }; > + __asm__ volatile ( > + "movq (%0), %%mm0\n" > + "movq 8(%0), %%mm1\n" > + "pmaddwd (%1), %%mm0\n" > + "pmaddwd 8(%1), %%mm1\n" > + "paddd (%2), %%mm0\n" > + "paddd (%2), %%mm1\n" > + "\n" > + "movq 16(%0), %%mm2\n" > + "movq 24(%0), %%mm3\n" > + "pmaddwd 16(%1), %%mm2\n" > + "pmaddwd 24(%1), %%mm3\n" > + "paddd %%mm2, %%mm0\n" > + "paddd %%mm3, %%mm1\n" > + "\n" > + "movq 32(%0), %%mm2\n" > + "movq 40(%0), %%mm3\n" > + "pmaddwd 32(%1), %%mm2\n" > + "pmaddwd 40(%1), %%mm3\n" > + "paddd %%mm2, %%mm0\n" > + "paddd %%mm3, %%mm1\n" > + "\n" > + "movq 48(%0), %%mm2\n" > + "movq 56(%0), %%mm3\n" > + "pmaddwd 48(%1), %%mm2\n" > + "pmaddwd 56(%1), %%mm3\n" > + "paddd %%mm2, %%mm0\n" > + "paddd %%mm3, %%mm1\n" > + "\n" > + "movq 64(%0), %%mm2\n" > + "movq 72(%0), %%mm3\n" > + "pmaddwd 64(%1), %%mm2\n" > + "pmaddwd 72(%1), %%mm3\n" > + "paddd %%mm2, %%mm0\n" > + "paddd %%mm3, %%mm1\n" > + "\n" > + "psrad %4, %%mm0\n" > + "psrad %4, %%mm1\n" > + "packssdw %%mm0, %%mm0\n" > + "packssdw %%mm1, %%mm1\n" > + "\n" > + "movq %%mm0, %%mm2\n" > + "pmaddwd 80(%1), %%mm0\n" > + "pmaddwd 88(%1), %%mm2\n" > + "\n" > + "movq %%mm1, %%mm3\n" > + "pmaddwd 96(%1), %%mm1\n" > + "pmaddwd 104(%1), %%mm3\n" > + "paddd %%mm1, %%mm0\n" > + "paddd %%mm3, %%mm2\n" > + "\n" > + "movq %%mm0, (%3)\n" > + "movq %%mm2, 8(%3)\n" > + : > + : "r" (in), "r" (consts), "r" (&round_c), "r" (out), > + "i" (SBC_PROTO_FIXED4_SCALE) > + : "cc", "memory"); > +} > + > +static inline void sbc_analyze_eight_sse(const int16_t *in, int32_t *out, > + const FIXED_T *consts) > +{ > + static const SBC_ALIGNED int32_t round_c[2] = { > + 1 << (SBC_PROTO_FIXED8_SCALE - 1), > + 1 << (SBC_PROTO_FIXED8_SCALE - 1), > + }; > + __asm__ volatile ( > + "movq (%0), %%mm0\n" > + "movq 8(%0), %%mm1\n" > + "movq 16(%0), %%mm2\n" > + "movq 24(%0), %%mm3\n" > + "pmaddwd (%1), %%mm0\n" > + "pmaddwd 8(%1), %%mm1\n" > + "pmaddwd 16(%1), %%mm2\n" > + "pmaddwd 24(%1), %%mm3\n" > + "paddd (%2), %%mm0\n" > + "paddd (%2), %%mm1\n" > + "paddd (%2), %%mm2\n" > + "paddd (%2), %%mm3\n" > + "\n" > + "movq 32(%0), %%mm4\n" > + "movq 40(%0), %%mm5\n" > + "movq 48(%0), %%mm6\n" > + "movq 56(%0), %%mm7\n" > + "pmaddwd 32(%1), %%mm4\n" > + "pmaddwd 40(%1), %%mm5\n" > + "pmaddwd 48(%1), %%mm6\n" > + "pmaddwd 56(%1), %%mm7\n" > + "paddd %%mm4, %%mm0\n" > + "paddd %%mm5, %%mm1\n" > + "paddd %%mm6, %%mm2\n" > + "paddd %%mm7, %%mm3\n" > + "\n" > + "movq 64(%0), %%mm4\n" > + "movq 72(%0), %%mm5\n" > + "movq 80(%0), %%mm6\n" > + "movq 88(%0), %%mm7\n" > + "pmaddwd 64(%1), %%mm4\n" > + "pmaddwd 72(%1), %%mm5\n" > + "pmaddwd 80(%1), %%mm6\n" > + "pmaddwd 88(%1), %%mm7\n" > + "paddd %%mm4, %%mm0\n" > + "paddd %%mm5, %%mm1\n" > + "paddd %%mm6, %%mm2\n" > + "paddd %%mm7, %%mm3\n" > + "\n" > + "movq 96(%0), %%mm4\n" > + "movq 104(%0), %%mm5\n" > + "movq 112(%0), %%mm6\n" > + "movq 120(%0), %%mm7\n" > + "pmaddwd 96(%1), %%mm4\n" > + "pmaddwd 104(%1), %%mm5\n" > + "pmaddwd 112(%1), %%mm6\n" > + "pmaddwd 120(%1), %%mm7\n" > + "paddd %%mm4, %%mm0\n" > + "paddd %%mm5, %%mm1\n" > + "paddd %%mm6, %%mm2\n" > + "paddd %%mm7, %%mm3\n" > + "\n" > + "movq 128(%0), %%mm4\n" > + "movq 136(%0), %%mm5\n" > + "movq 144(%0), %%mm6\n" > + "movq 152(%0), %%mm7\n" > + "pmaddwd 128(%1), %%mm4\n" > + "pmaddwd 136(%1), %%mm5\n" > + "pmaddwd 144(%1), %%mm6\n" > + "pmaddwd 152(%1), %%mm7\n" > + "paddd %%mm4, %%mm0\n" > + "paddd %%mm5, %%mm1\n" > + "paddd %%mm6, %%mm2\n" > + "paddd %%mm7, %%mm3\n" > + "\n" > + "psrad %4, %%mm0\n" > + "psrad %4, %%mm1\n" > + "psrad %4, %%mm2\n" > + "psrad %4, %%mm3\n" > + "\n" > + "packssdw %%mm0, %%mm0\n" > + "packssdw %%mm1, %%mm1\n" > + "packssdw %%mm2, %%mm2\n" > + "packssdw %%mm3, %%mm3\n" > + "\n" > + "movq %%mm0, %%mm4\n" > + "movq %%mm0, %%mm5\n" > + "pmaddwd 160(%1), %%mm4\n" > + "pmaddwd 168(%1), %%mm5\n" > + "\n" > + "movq %%mm1, %%mm6\n" > + "movq %%mm1, %%mm7\n" > + "pmaddwd 192(%1), %%mm6\n" > + "pmaddwd 200(%1), %%mm7\n" > + "paddd %%mm6, %%mm4\n" > + "paddd %%mm7, %%mm5\n" > + "\n" > + "movq %%mm2, %%mm6\n" > + "movq %%mm2, %%mm7\n" > + "pmaddwd 224(%1), %%mm6\n" > + "pmaddwd 232(%1), %%mm7\n" > + "paddd %%mm6, %%mm4\n" > + "paddd %%mm7, %%mm5\n" > + "\n" > + "movq %%mm3, %%mm6\n" > + "movq %%mm3, %%mm7\n" > + "pmaddwd 256(%1), %%mm6\n" > + "pmaddwd 264(%1), %%mm7\n" > + "paddd %%mm6, %%mm4\n" > + "paddd %%mm7, %%mm5\n" > + "\n" > + "movq %%mm4, (%3)\n" > + "movq %%mm5, 8(%3)\n" > + "\n" > + "movq %%mm0, %%mm5\n" > + "pmaddwd 176(%1), %%mm0\n" > + "pmaddwd 184(%1), %%mm5\n" > + "\n" > + "movq %%mm1, %%mm7\n" > + "pmaddwd 208(%1), %%mm1\n" > + "pmaddwd 216(%1), %%mm7\n" > + "paddd %%mm1, %%mm0\n" > + "paddd %%mm7, %%mm5\n" > + "\n" > + "movq %%mm2, %%mm7\n" > + "pmaddwd 240(%1), %%mm2\n" > + "pmaddwd 248(%1), %%mm7\n" > + "paddd %%mm2, %%mm0\n" > + "paddd %%mm7, %%mm5\n" > + "\n" > + "movq %%mm3, %%mm7\n" > + "pmaddwd 272(%1), %%mm3\n" > + "pmaddwd 280(%1), %%mm7\n" > + "paddd %%mm3, %%mm0\n" > + "paddd %%mm7, %%mm5\n" > + "\n" > + "movq %%mm0, 16(%3)\n" > + "movq %%mm5, 24(%3)\n" > + : > + : "r" (in), "r" (consts), "r" (&round_c), "r" (out), > + "i" (SBC_PROTO_FIXED8_SCALE) > + : "cc", "memory"); > +} > + > +static inline void sbc_analyze_4b_4s_sse(struct sbc_encoder_state *state, > + int16_t *x, int32_t *out, int out_stride) > +{ > + /* Analyze blocks */ > + sbc_analyze_four_sse(x + 12, out, analysis_consts_fixed4_simd_odd); > + out += out_stride; > + sbc_analyze_four_sse(x + 8, out, analysis_consts_fixed4_simd_even); > + out += out_stride; > + sbc_analyze_four_sse(x + 4, out, analysis_consts_fixed4_simd_odd); > + out += out_stride; > + sbc_analyze_four_sse(x + 0, out, analysis_consts_fixed4_simd_even); > + > + __asm__ volatile ("emms\n"); > +} > + > +static inline void sbc_analyze_4b_8s_sse(struct sbc_encoder_state *state, > + int16_t *x, int32_t *out, int out_stride) > +{ > + /* Analyze blocks */ > + sbc_analyze_eight_sse(x + 24, out, analysis_consts_fixed8_simd_odd); > + out += out_stride; > + sbc_analyze_eight_sse(x + 16, out, analysis_consts_fixed8_simd_even); > + out += out_stride; > + sbc_analyze_eight_sse(x + 8, out, analysis_consts_fixed8_simd_odd); > + out += out_stride; > + sbc_analyze_eight_sse(x + 0, out, analysis_consts_fixed8_simd_even); > + > + __asm__ volatile ("emms\n"); > +} > + > +static inline void sbc_analyze_1b_8s_sse_even(struct sbc_encoder_state *state, > + int16_t *x, int32_t *out, int out_stride); > + > +static inline void sbc_analyze_1b_8s_sse_odd(struct sbc_encoder_state *state, > + int16_t *x, int32_t *out, int out_stride) > +{ > + sbc_analyze_eight_sse(x, out, analysis_consts_fixed8_simd_odd); > + state->sbc_analyze_8s = sbc_analyze_1b_8s_sse_even; > + > + __asm__ volatile ("emms\n"); > +} > + > +static inline void sbc_analyze_1b_8s_sse_even(struct sbc_encoder_state *state, > + int16_t *x, int32_t *out, int out_stride) > +{ > + sbc_analyze_eight_sse(x, out, analysis_consts_fixed8_simd_even); > + state->sbc_analyze_8s = sbc_analyze_1b_8s_sse_odd; > + > + __asm__ volatile ("emms\n"); > +} > + > +static void sbc_calc_scalefactors_sse( > + int32_t sb_sample_f[16][2][8], > + uint32_t scale_factor[2][8], > + int blocks, int channels, int subbands) > +{ > + static const SBC_ALIGNED int32_t consts[2] = { > + 1 << SCALE_OUT_BITS, > + 1 << SCALE_OUT_BITS, > + }; > + int ch, sb; > + intptr_t blk; > + for (ch = 0; ch < channels; ch++) { > + for (sb = 0; sb < subbands; sb += 2) { > + blk = (blocks - 1) * (((char *) &sb_sample_f[1][0][0] - > + (char *) &sb_sample_f[0][0][0])); > + __asm__ volatile ( > + "movq (%4), %%mm0\n" > + "1:\n" > + "movq (%1, %0), %%mm1\n" > + "pxor %%mm2, %%mm2\n" > + "pcmpgtd %%mm2, %%mm1\n" > + "paddd (%1, %0), %%mm1\n" > + "pcmpgtd %%mm1, %%mm2\n" > + "pxor %%mm2, %%mm1\n" > + > + "por %%mm1, %%mm0\n" > + > + "sub %2, %0\n" > + "jns 1b\n" > + > + "movd %%mm0, %k0\n" > + "psrlq $32, %%mm0\n" > + "bsrl %k0, %k0\n" > + "subl %5, %k0\n" > + "movl %k0, (%3)\n" > + > + "movd %%mm0, %k0\n" > + "bsrl %k0, %k0\n" > + "subl %5, %k0\n" > + "movl %k0, 4(%3)\n" > + : "+r" (blk) > + : "r" (&sb_sample_f[0][ch][sb]), > + "i" ((char *) &sb_sample_f[1][0][0] - > + (char *) &sb_sample_f[0][0][0]), > + "r" (&scale_factor[ch][sb]), > + "r" (&consts), > + "i" (SCALE_OUT_BITS) > + : "cc", "memory"); > + } > + } > + __asm__ volatile ("emms\n"); > +} > + > +void sbc_init_primitives_sse(struct sbc_encoder_state *state) > +{ > + state->sbc_analyze_4s = sbc_analyze_4b_4s_sse; > + if (state->increment == 1) > + state->sbc_analyze_8s = sbc_analyze_1b_8s_sse_odd; > + else > + state->sbc_analyze_8s = sbc_analyze_4b_8s_sse; > + state->sbc_calc_scalefactors = sbc_calc_scalefactors_sse; > + state->implementation_info = "SSE"; > +} > + > +#else > +void sbc_init_primitives_sse(struct sbc_encoder_state *state) > +{ > +} > +#endif > diff --git a/sbc/sbc_primitives_sse.h b/sbc/sbc_primitives_sse.h > new file mode 100644 > index 0000000..8830cfd > --- /dev/null > +++ b/sbc/sbc_primitives_sse.h > @@ -0,0 +1,38 @@ > +/* > + * > + * Bluetooth low-complexity, subband codec (SBC) library > + * > + * Copyright (C) 2020 Intel Corporation > + * > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > + * > + */ > + > +#ifndef __SBC_PRIMITIVES_SSE_H > +#define __SBC_PRIMITIVES_SSE_H > + > +#include "sbc_primitives.h" > + > +#if defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) && \ > + !defined(SBC_HIGH_PRECISION) && (SCALE_OUT_BITS == 15) > + > +#define SBC_BUILD_WITH_SSE_SUPPORT > + > +void sbc_init_primitives_sse(struct sbc_encoder_state *encoder_state); > + > +#endif > + > +#endif > -- > 2.26.2 Pushed. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0DLGBHraY1/a9wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 17 Sep 2020 23:51:54 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4Ph/AXraY19oUQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 17 Sep 2020 23:51:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E9EFA40869; Thu, 17 Sep 2020 23:51:47 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726002AbgIQVvp (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 17:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbgIQVvp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 17:51:45 -0400 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE00DC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:51:44 -0700 (PDT) Received: by mail-qv1-xf2f.google.com with SMTP id ef16so1807763qvb.8 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 14:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=1dy9pId6C6wOeNWf4V5IzS0StCIiVpbomRAUrnj/khM=; b=bjdAcii3Gjvw8KxrI15xjWTo+8TH0sW5i/OssaHBrv5aB6kbJJuimX1dVY52ERbb7d l4wBtC8VqsQXu9gaph9rdH7y+9BngUnsweaGMWMCdOrYnI0zCi3j6qC4ImmOz5yQzk12 uI+X0dKHcuGwgXJmggeIYwkj9M6wnBnmefGtm23HKbCrKJSeSw23AFBXDQll++psyir5 VEkga9S1FeIhLif4Y0mKownMX1MKcoD/5sFqFwHLJt94wfMutKUDkYS5BV6ihqsjVx/8 mhjPZYSCFl9LGg076+cIQg0kNtwf8tXFx48MnASrpt0B7OTUUXKX9vLGT6cP750/HBGz 3SdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=1dy9pId6C6wOeNWf4V5IzS0StCIiVpbomRAUrnj/khM=; b=qKvqUssRXJLLdclWRvkJuixY4KmTzlVdpw5+rmPNCB+V6wdWmnYEWCI6Tm6la47CbM GVMFQp0KxSaUDAX+hm6xhYeD7KXo/dZUTCu43qPjC/na8P9uckDQ9YQwmoaT+k6mgI4r ErdCKflA/iMzR+xsd+SiU63HagmNQjY4P+EW+hJaIObZeR6MGRNe3HAvErOMKzqV2uDA gStj7On1DFCGeuRnLHzbFFSsTRh3EdvXBxXBdA+YNeOAJzqF1/VCMdXm9mQxpVNx45cl zHI4tEP7bgjOYPcAjZyCwdbVWdlE8Tw8PLt5okfZ0sDMDtkZ1FdQ4RqFIJfCoxa8us1X pYSA== X-Gm-Message-State: AOAM53021kq5mD5RDEYxYLoSBWVEukkJFq/cPh4vp1cF5loJ9LtqF4ea 2MivUA45ElueaB0Uyv/CcS+UCjRuLcNAfw== X-Google-Smtp-Source: ABdhPJwU+2vFKUNvlOXXWpT9NwtTFQgBjfz1rn0ngAUBJV+s7IGBXEl7lUjXzg/KAcZSmmGzjcGJLA== X-Received: by 2002:a0c:f54e:: with SMTP id p14mr27098773qvm.28.1600379503162; Thu, 17 Sep 2020 14:51:43 -0700 (PDT) Received: from [172.17.0.2] ([20.186.152.21]) by smtp.gmail.com with ESMTPSA id s10sm762071qkg.61.2020.09.17.14.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 14:51:42 -0700 (PDT) Message-ID: <5f63da6e.1c69fb81.9de0.5489@mx.google.com> Date: Thu, 17 Sep 2020 14:51:42 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============4429390691823547765==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, mcchou@chromium.org Subject: RE: [BlueZ,v4,1/8] adv_monitor: Implement RSSI Filter logic for background scanning Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> References: <20200917142456.BlueZ.v4.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.50 / 15.00 / 15.00 X-Rspamd-Queue-Id: E9EFA40869 X-Rspamd-UID: 2da6d4 --===============4429390691823547765== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkbuild Failed Outputs: ar: `u' modifier ignored since `D' is the default (see `U') ar: `u' modifier ignored since `D' is the default (see `U') ar: `u' modifier ignored since `D' is the default (see `U') ar: `u' modifier ignored since `D' is the default (see `U') ar: `u' modifier ignored since `D' is the default (see `U') /usr/bin/ld: src/adv_monitor.o: in function `app_destroy': /github/workspace/src/adv_monitor.c:245: undefined reference to `btd_error_failed' /usr/bin/ld: src/adv_monitor.o: in function `app_reply_msg': /github/workspace/src/adv_monitor.c:175: undefined reference to `btd_get_dbus_connection' /usr/bin/ld: src/adv_monitor.o: in function `unregister_monitor': /github/workspace/src/adv_monitor.c:908: undefined reference to `btd_error_invalid_args' /usr/bin/ld: /github/workspace/src/adv_monitor.c:914: undefined reference to `btd_error_does_not_exist' /usr/bin/ld: src/adv_monitor.o: in function `register_monitor': /github/workspace/src/adv_monitor.c:869: undefined reference to `btd_error_invalid_args' /usr/bin/ld: /github/workspace/src/adv_monitor.c:874: undefined reference to `btd_error_already_exists' /usr/bin/ld: /github/workspace/src/adv_monitor.c:881: undefined reference to `btd_error_failed' /usr/bin/ld: src/adv_monitor.o: in function `manager_destroy': /github/workspace/src/adv_monitor.c:1093: undefined reference to `adapter_get_path' /usr/bin/ld: /github/workspace/src/adv_monitor.c:1093: undefined reference to `btd_get_dbus_connection' /usr/bin/ld: src/adv_monitor.o: in function `app_reply_msg': /github/workspace/src/adv_monitor.c:175: undefined reference to `btd_get_dbus_connection' /usr/bin/ld: src/adv_monitor.o: in function `manager_new': /github/workspace/src/adv_monitor.c:1067: undefined reference to `btd_adapter_get_index' /usr/bin/ld: src/adv_monitor.o: in function `btd_adv_monitor_manager_create': /github/workspace/src/adv_monitor.c:1147: undefined reference to `adapter_get_path' /usr/bin/ld: /github/workspace/src/adv_monitor.c:1147: undefined reference to `btd_get_dbus_connection' /usr/bin/ld: src/device.o: in function `store_device_info_cb': /github/workspace/src/device.c:403: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:404: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: /github/workspace/src/device.c:479: undefined reference to `create_file' /usr/bin/ld: src/device.o: in function `browse_request_free': /github/workspace/src/device.c:562: undefined reference to `sdp_record_free' /usr/bin/ld: /github/workspace/src/device.c:562: undefined reference to `sdp_list_free' /usr/bin/ld: src/device.o: in function `service_prio_cmp': /github/workspace/src/device.c:1929: undefined reference to `btd_service_get_profile' /usr/bin/ld: /github/workspace/src/device.c:1930: undefined reference to `btd_service_get_profile' /usr/bin/ld: src/device.o: in function `find_service_with_uuid': /github/workspace/src/device.c:343: undefined reference to `btd_service_get_profile' /usr/bin/ld: /github/workspace/src/device.c:345: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: src/device.o: in function `disconnect_gatt_service': /github/workspace/src/device.c:5075: undefined reference to `btd_service_get_profile' /usr/bin/ld: src/device.o: in function `device_disappeared': /github/workspace/src/device.c:4281: undefined reference to `btd_adapter_remove_device' /usr/bin/ld: src/device.o: in function `store_service': /github/workspace/src/device.c:2447: undefined reference to `bt_uuid_to_string' /usr/bin/ld: src/device.o: in function `store_chrc': /github/workspace/src/device.c:2365: undefined reference to `bt_uuid_to_string' /usr/bin/ld: /github/workspace/src/device.c:2368: undefined reference to `bt_uuid16_create' /usr/bin/ld: /github/workspace/src/device.c:2369: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/device.o: in function `store_desc': /github/workspace/src/device.c:2337: undefined reference to `bt_uuid_to_string' /usr/bin/ld: /github/workspace/src/device.c:2339: undefined reference to `bt_uuid16_create' /usr/bin/ld: /github/workspace/src/device.c:2340: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/device.o: in function `store_incl': /github/workspace/src/device.c:2422: undefined reference to `bt_uuid_to_string' /usr/bin/ld: src/device.o: in function `dev_property_get_adapter': /github/workspace/src/device.c:1224: undefined reference to `adapter_get_path' /usr/bin/ld: src/device.o: in function `dev_property_get_alias': /github/workspace/src/device.c:812: undefined reference to `ba2str' /usr/bin/ld: src/device.o: in function `dev_property_get_address': /github/workspace/src/device.c:758: undefined reference to `ba2str' /usr/bin/ld: src/device.o: in function `append_service_data': /github/workspace/src/device.c:1278: undefined reference to `bt_uuid_to_string' /usr/bin/ld: /github/workspace/src/device.c:1280: undefined reference to `dict_append_array' /usr/bin/ld: src/device.o: in function `bonding_request_free': /github/workspace/src/device.c:2741: undefined reference to `agent_cancel' /usr/bin/ld: /github/workspace/src/device.c:2742: undefined reference to `agent_unref' /usr/bin/ld: src/device.o: in function `select_conn_bearer': /github/workspace/src/device.c:2098: undefined reference to `btd_adapter_get_bredr' /usr/bin/ld: src/device.o: in function `new_auth': /github/workspace/src/device.c:6350: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:6359: undefined reference to `agent_ref' /usr/bin/ld: /github/workspace/src/device.c:6361: undefined reference to `agent_get' /usr/bin/ld: src/device.o: in function `store_services': /github/workspace/src/device.c:2251: undefined reference to `sdp_uuid16_create' /usr/bin/ld: /github/workspace/src/device.c:2252: undefined reference to `bt_uuid2string' /usr/bin/ld: /github/workspace/src/device.c:2256: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:2258: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: /github/workspace/src/device.c:2270: undefined reference to `bt_string2uuid' /usr/bin/ld: /github/workspace/src/device.c:2271: undefined reference to `sdp_uuid128_to_uuid' /usr/bin/ld: /github/workspace/src/device.c:2297: undefined reference to `create_file' /usr/bin/ld: src/device.o: in function `device_set_auto_connect': /github/workspace/src/device.c:1674: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:1691: undefined reference to `adapter_auto_connect_add' /usr/bin/ld: /github/workspace/src/device.c:1698: undefined reference to `adapter_connect_list_add' /usr/bin/ld: /github/workspace/src/device.c:1685: undefined reference to `adapter_connect_list_remove' /usr/bin/ld: /github/workspace/src/device.c:1686: undefined reference to `adapter_auto_connect_remove' /usr/bin/ld: src/device.o: in function `pincode_cb': /github/workspace/src/device.c:6286: undefined reference to `btd_adapter_pincode_reply' /usr/bin/ld: /github/workspace/src/device.c:6289: undefined reference to `agent_unref' /usr/bin/ld: src/device.o: in function `passkey_cb': /github/workspace/src/device.c:6323: undefined reference to `btd_adapter_passkey_reply' /usr/bin/ld: /github/workspace/src/device.c:6326: undefined reference to `agent_unref' /usr/bin/ld: src/device.o: in function `confirm_cb': /github/workspace/src/device.c:6302: undefined reference to `btd_adapter_confirm_reply' /usr/bin/ld: /github/workspace/src/device.c:6306: undefined reference to `agent_unref' /usr/bin/ld: src/device.o: in function `read_device_records': /github/workspace/src/device.c:6679: undefined reference to `btd_adapter_get_address' /usr/bin/ld: /github/workspace/src/device.c:6679: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:6680: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:6694: undefined reference to `record_from_string' /usr/bin/ld: /github/workspace/src/device.c:6695: undefined reference to `sdp_list_append' /usr/bin/ld: src/device.o: in function `disconnect_all': /github/workspace/src/device.c:1483: undefined reference to `btd_adapter_disconnect_device' /usr/bin/ld: /github/workspace/src/device.c:1487: undefined reference to `btd_adapter_disconnect_device' /usr/bin/ld: src/device.o: in function `gatt_server_cleanup': /github/workspace/src/device.c:611: undefined reference to `btd_adapter_get_database' /usr/bin/ld: /github/workspace/src/device.c:611: undefined reference to `btd_gatt_database_att_disconnected' /usr/bin/ld: src/device.o: in function `add_service_data': /github/workspace/src/device.c:1866: undefined reference to `bt_string_to_uuid' /usr/bin/ld: src/device.o: in function `find_connectable_service': /github/workspace/src/device.c:1915: undefined reference to `btd_service_get_profile' /usr/bin/ld: src/device.o: in function `disconnect_profile': /github/workspace/src/device.c:2201: undefined reference to `bt_name2string' /usr/bin/ld: /github/workspace/src/device.c:2212: undefined reference to `btd_error_in_progress' /usr/bin/ld: /github/workspace/src/device.c:2209: undefined reference to `btd_error_invalid_args' /usr/bin/ld: /github/workspace/src/device.c:2214: undefined reference to `btd_service_get_state' /usr/bin/ld: /github/workspace/src/device.c:2219: undefined reference to `btd_service_disconnect' /usr/bin/ld: /github/workspace/src/device.c:2231: undefined reference to `btd_error_failed' /usr/bin/ld: /github/workspace/src/device.c:2227: undefined reference to `btd_error_not_supported' /usr/bin/ld: src/device.o: in function `create_pending_list': /github/workspace/src/device.c:1951: undefined reference to `btd_service_get_profile' /usr/bin/ld: /github/workspace/src/device.c:1959: undefined reference to `btd_service_get_state' /usr/bin/ld: src/device.o: in function `connect_next': /github/workspace/src/device.c:1728: undefined reference to `btd_service_connect' /usr/bin/ld: src/device.o: in function `add_primary': /github/workspace/src/device.c:3474: undefined reference to `bt_uuid_to_string' /usr/bin/ld: src/device.o: in function `device_auth_req_free': /github/workspace/src/device.c:6018: undefined reference to `agent_unref' /usr/bin/ld: src/device.o: in function `record_has_uuid': /github/workspace/src/device.c:4581: undefined reference to `bt_uuid2string' /usr/bin/ld: src/device.o: in function `load_services': /github/workspace/src/device.c:3179: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: src/device.o: in function `convert_info': /github/workspace/src/device.c:3218: undefined reference to `btd_adapter_get_address' /usr/bin/ld: /github/workspace/src/device.c:3218: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:3219: undefined reference to `ba2str' /usr/bin/ld: src/device.o: in function `load_att_info': /github/workspace/src/device.c:3377: undefined reference to `sdp_uuid16_create' /usr/bin/ld: /github/workspace/src/device.c:3378: undefined reference to `bt_uuid2string' /usr/bin/ld: /github/workspace/src/device.c:3440: undefined reference to `bt_uuid2string' /usr/bin/ld: src/device.o: in function `device_match_profile': /github/workspace/src/device.c:3819: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: src/device.o: in function `probe_service': /github/workspace/src/device.c:4623: undefined reference to `service_create' /usr/bin/ld: /github/workspace/src/device.c:4625: undefined reference to `service_probe' /usr/bin/ld: src/device.o: in function `find_service_with_profile': /github/workspace/src/device.c:315: undefined reference to `btd_service_get_profile' /usr/bin/ld: src/device.o: in function `probe_service': /github/workspace/src/device.c:4626: undefined reference to `btd_service_unref' /usr/bin/ld: src/device.o: in function `device_store_cached_name': /github/workspace/src/device.c:533: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:534: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: /github/workspace/src/device.c:536: undefined reference to `create_file' /usr/bin/ld: src/device.o: in function `gatt_cache_is_enabled': /github/workspace/src/device.c:569: undefined reference to `main_opts' /usr/bin/ld: src/device.o: in function `store_gatt_db': /github/workspace/src/device.c:2480: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:2482: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: /github/workspace/src/device.c:2485: undefined reference to `create_file' /usr/bin/ld: src/device.o: in function `gatt_service_removed': /github/workspace/src/device.c:4009: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: /github/workspace/src/device.c:4034: undefined reference to `btd_gatt_client_service_removed' /usr/bin/ld: src/device.o: in function `device_remove_gatt_service': /github/workspace/src/device.c:3899: undefined reference to `bt_uuid_to_string' /usr/bin/ld: /github/workspace/src/device.c:3908: undefined reference to `service_remove' /usr/bin/ld: src/device.o: in function `gatt_cache_is_enabled': /github/workspace/src/device.c:569: undefined reference to `main_opts' /usr/bin/ld: src/device.o: in function `attio_cleanup': /github/workspace/src/device.c:642: undefined reference to `g_attrib_cancel_all' /usr/bin/ld: src/device.o: in function `browse_request_cancel': /github/workspace/src/device.c:654: undefined reference to `btd_adapter_get_address' /usr/bin/ld: /github/workspace/src/device.c:654: undefined reference to `bt_cancel_discovery' /usr/bin/ld: src/device.o: in function `device_free': /github/workspace/src/device.c:677: undefined reference to `btd_gatt_client_destroy' /usr/bin/ld: /github/workspace/src/device.c:694: undefined reference to `sdp_record_free' /usr/bin/ld: /github/workspace/src/device.c:694: undefined reference to `sdp_list_free' /usr/bin/ld: /github/workspace/src/device.c:716: undefined reference to `agent_unref' /usr/bin/ld: src/device.o: in function `att_disconnected_cb': /github/workspace/src/device.c:5097: undefined reference to `btd_gatt_client_disconnected' /usr/bin/ld: /github/workspace/src/device.c:5110: undefined reference to `adapter_connect_list_add' /usr/bin/ld: src/device.o: in function `gatt_cache_is_enabled': /github/workspace/src/device.c:569: undefined reference to `main_opts' /usr/bin/ld: src/device.o: in function `load_service': /github/workspace/src/device.c:3651: undefined reference to `bt_string_to_uuid' /usr/bin/ld: src/device.o: in function `load_gatt_db_impl': /github/workspace/src/device.c:3733: undefined reference to `bt_uuid_to_string' /usr/bin/ld: src/device.o: in function `load_chrc': /github/workspace/src/device.c:3572: undefined reference to `bt_string_to_uuid' /usr/bin/ld: src/device.o: in function `load_desc': /github/workspace/src/device.c:3522: undefined reference to `bt_string_to_uuid' /usr/bin/ld: /github/workspace/src/device.c:3523: undefined reference to `bt_uuid16_create' /usr/bin/ld: /github/workspace/src/device.c:3526: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/device.o: in function `load_chrc': /github/workspace/src/device.c:3572: undefined reference to `bt_string_to_uuid' /usr/bin/ld: /github/workspace/src/device.c:3572: undefined reference to `bt_string_to_uuid' /usr/bin/ld: src/device.o: in function `device_add_eir_uuids': /github/workspace/src/device.c:1825: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: src/device.o: in function `btd_device_connect_services': /github/workspace/src/device.c:1977: undefined reference to `btd_adapter_get_powered' /usr/bin/ld: src/device.o: in function `bonding_request_cancel': /github/workspace/src/device.c:1587: undefined reference to `adapter_cancel_bonding' /usr/bin/ld: src/device.o: in function `device_request_disconnect': /github/workspace/src/device.c:1610: undefined reference to `btd_error_failed' /usr/bin/ld: src/device.o: in function `btd_device_get_storage_path': /github/workspace/src/device.c:4169: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:4176: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: /github/workspace/src/device.c:4172: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: src/device.o: in function `device_browse_sdp': /github/workspace/src/device.c:5614: undefined reference to `sdp_uuid16_create' /usr/bin/ld: src/device.o: in function `get_sdp_flags': /github/workspace/src/device.c:5592: undefined reference to `btd_adapter_ssp_enabled' /usr/bin/ld: src/device.o: in function `device_browse_sdp': /github/workspace/src/device.c:5618: undefined reference to `btd_adapter_get_address' /usr/bin/ld: /github/workspace/src/device.c:5618: undefined reference to `bt_search' /usr/bin/ld: src/device.o: in function `device_address_cmp': /github/workspace/src/device.c:4516: undefined reference to `ba2str' /usr/bin/ld: src/device.o: in function `find_service_with_profile': /github/workspace/src/device.c:315: undefined reference to `btd_service_get_profile' /usr/bin/ld: src/device.o: in function `device_probe_profiles': /github/workspace/src/device.c:4694: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:4703: undefined reference to `btd_profile_foreach' /usr/bin/ld: src/device.o: in function `device_add_uuids': /github/workspace/src/device.c:3795: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: src/device.o: in function `device_unblock': /github/workspace/src/device.c:1548: undefined reference to `btd_adapter_unblock_address' /usr/bin/ld: /github/workspace/src/device.c:1552: undefined reference to `btd_adapter_unblock_address' /usr/bin/ld: src/device.o: in function `device_connect_le': /github/workspace/src/device.c:5455: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:5472: undefined reference to `btd_adapter_get_address_type' /usr/bin/ld: /github/workspace/src/device.c:5468: undefined reference to `btd_adapter_get_address' /usr/bin/ld: /github/workspace/src/device.c:5468: undefined reference to `bt_io_connect' /usr/bin/ld: /github/workspace/src/device.c:5481: undefined reference to `btd_error_failed' /usr/bin/ld: src/device.o: in function `bonding_request_cancel': /github/workspace/src/device.c:1587: undefined reference to `adapter_cancel_bonding' /usr/bin/ld: src/device.o: in function `device_attach_att': /github/workspace/src/device.c:5287: undefined reference to `bt_io_get' /usr/bin/ld: /github/workspace/src/device.c:5299: undefined reference to `main_opts' /usr/bin/ld: /github/workspace/src/device.c:5327: undefined reference to `main_opts' /usr/bin/ld: /github/workspace/src/device.c:5328: undefined reference to `g_attrib_new' /usr/bin/ld: /github/workspace/src/device.c:5337: undefined reference to `g_attrib_get_att' /usr/bin/ld: /github/workspace/src/device.c:5353: undefined reference to `btd_adapter_get_database' /usr/bin/ld: /github/workspace/src/device.c:5356: undefined reference to `ba2str' /usr/bin/ld: src/device.o: in function `device_accept_gatt_profiles': /github/workspace/src/device.c:3887: undefined reference to `service_accept' /usr/bin/ld: src/device.o: in function `gatt_server_init': /github/workspace/src/device.c:5226: undefined reference to `btd_gatt_database_get_db' /usr/bin/ld: /github/workspace/src/device.c:5245: undefined reference to `btd_gatt_database_server_connected' /usr/bin/ld: src/device.o: in function `device_attach_att': /github/workspace/src/device.c:5370: undefined reference to `adapter_connect_list_remove' /usr/bin/ld: /github/workspace/src/device.c:5318: undefined reference to `bt_io_set' /usr/bin/ld: /github/workspace/src/device.c:5359: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: src/device.o: in function `gatt_client_init': /github/workspace/src/device.c:5220: undefined reference to `btd_gatt_client_connected' /usr/bin/ld: src/device.o: in function `device_update_last_seen': /github/workspace/src/device.c:4300: undefined reference to `main_opts' /usr/bin/ld: src/device.o: in function `device_add_connection': /github/workspace/src/device.c:2977: undefined reference to `ba2str' /usr/bin/ld: src/device.o: in function `device_remove_connection': /github/workspace/src/device.c:3031: undefined reference to `btd_error_failed' /usr/bin/ld: /github/workspace/src/device.c:3050: undefined reference to `btd_adapter_remove_bonding' /usr/bin/ld: src/device.o: in function `btd_device_set_temporary': /github/workspace/src/device.c:5699: undefined reference to `adapter_connect_list_remove' /usr/bin/ld: /github/workspace/src/device.c:5700: undefined reference to `main_opts' /usr/bin/ld: /github/workspace/src/device.c:5707: undefined reference to `adapter_whitelist_add' /usr/bin/ld: /github/workspace/src/device.c:5698: undefined reference to `adapter_whitelist_remove' /usr/bin/ld: src/device.o: in function `device_block': /github/workspace/src/device.c:1509: undefined reference to `service_remove' /usr/bin/ld: /github/workspace/src/device.c:1514: undefined reference to `btd_adapter_block_address' /usr/bin/ld: /github/workspace/src/device.c:1518: undefined reference to `btd_adapter_block_address' /usr/bin/ld: src/device.o: in function `pair_device': /github/workspace/src/device.c:2786: undefined reference to `btd_error_already_exists' /usr/bin/ld: /github/workspace/src/device.c:2790: undefined reference to `agent_get' /usr/bin/ld: /github/workspace/src/device.c:2792: undefined reference to `agent_get_io_capability' /usr/bin/ld: src/device.o: in function `bonding_request_new': /github/workspace/src/device.c:2649: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:2657: undefined reference to `btd_adapter_pin_cb_iter_new' /usr/bin/ld: /github/workspace/src/device.c:2665: undefined reference to `agent_ref' /usr/bin/ld: src/device.o: in function `pair_device': /github/workspace/src/device.c:2799: undefined reference to `agent_unref' /usr/bin/ld: /github/workspace/src/device.c:2814: undefined reference to `btd_le_connect_before_pairing' /usr/bin/ld: /github/workspace/src/device.c:2817: undefined reference to `adapter_create_bonding' /usr/bin/ld: /github/workspace/src/device.c:2827: undefined reference to `btd_error_failed' /usr/bin/ld: /github/workspace/src/device.c:2774: undefined reference to `btd_error_in_progress' /usr/bin/ld: /github/workspace/src/device.c:2771: undefined reference to `btd_error_invalid_args' /usr/bin/ld: /github/workspace/src/device.c:2821: undefined reference to `adapter_create_bonding' /usr/bin/ld: src/device.o: in function `find_service_with_state': /github/workspace/src/device.c:330: undefined reference to `btd_service_get_state' /usr/bin/ld: src/device.o: in function `browse_request_complete': /github/workspace/src/device.c:2544: undefined reference to `btd_error_failed' /usr/bin/ld: /github/workspace/src/device.c:2521: undefined reference to `btd_error_failed' /usr/bin/ld: src/device.o: in function `device_browse_gatt': /github/workspace/src/device.c:5563: undefined reference to `btd_adapter_get_address_type' /usr/bin/ld: /github/workspace/src/device.c:5558: undefined reference to `btd_adapter_get_address' /usr/bin/ld: /github/workspace/src/device.c:5558: undefined reference to `bt_io_connect' /usr/bin/ld: src/device.o: in function `connect_profiles': /github/workspace/src/device.c:2008: undefined reference to `btd_adapter_get_powered' /usr/bin/ld: src/device.o: in function `find_service_with_state': /github/workspace/src/device.c:330: undefined reference to `btd_service_get_state' /usr/bin/ld: src/device.o: in function `connect_profile': /github/workspace/src/device.c:2163: undefined reference to `bt_name2string' /usr/bin/ld: /github/workspace/src/device.c:2161: undefined reference to `btd_error_invalid_args' /usr/bin/ld: src/device.o: in function `att_connect_cb': /github/workspace/src/device.c:5388: undefined reference to `bt_io_error_quark' /usr/bin/ld: /github/workspace/src/device.c:5421: undefined reference to `btd_error_failed' /usr/bin/ld: src/device.o: in function `bonding_request_cancel': /github/workspace/src/device.c:1587: undefined reference to `adapter_cancel_bonding' /usr/bin/ld: src/device.o: in function `att_connect_cb': /github/workspace/src/device.c:5432: undefined reference to `btd_error_failed' /usr/bin/ld: /github/workspace/src/device.c:5393: undefined reference to `adapter_connect_list_add' /usr/bin/ld: /github/workspace/src/device.c:5413: undefined reference to `agent_get_io_capability' /usr/bin/ld: /github/workspace/src/device.c:5417: undefined reference to `adapter_create_bonding' /usr/bin/ld: src/device.o: in function `device_remove_stored': /github/workspace/src/device.c:4429: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:4431: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: /github/workspace/src/device.c:4436: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: /github/workspace/src/device.c:4446: undefined reference to `create_file' /usr/bin/ld: src/device.o: in function `gatt_client_ready_cb': /github/workspace/src/device.c:5160: undefined reference to `btd_gatt_client_ready' /usr/bin/ld: src/device.o: in function `device_add_gatt_services': /github/workspace/src/device.c:3872: undefined reference to `ba2str' /usr/bin/ld: src/device.o: in function `service_state_changed': /github/workspace/src/device.c:6870: undefined reference to `btd_service_get_profile' /usr/bin/ld: /github/workspace/src/device.c:6871: undefined reference to `btd_service_get_device' /usr/bin/ld: /github/workspace/src/device.c:6872: undefined reference to `btd_service_get_error' /usr/bin/ld: src/device.o: in function `find_service_with_profile': /github/workspace/src/device.c:315: undefined reference to `btd_service_get_profile' /usr/bin/ld: src/device.o: in function `device_profile_connected': /github/workspace/src/device.c:1771: undefined reference to `btd_service_get_profile' /usr/bin/ld: src/device.o: in function `device_profile_disconnected': /github/workspace/src/device.c:2177: undefined reference to `btd_error_failed' /usr/bin/ld: src/device.o: in function `device_profile_connected': /github/workspace/src/device.c:1804: undefined reference to `btd_error_failed' /usr/bin/ld: src/device.o: in function `find_service_with_state': /github/workspace/src/device.c:330: undefined reference to `btd_service_get_state' /usr/bin/ld: src/device.o: in function `device_store_svc_chng_ccc': /github/workspace/src/device.c:5777: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:5778: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: /github/workspace/src/device.c:5806: undefined reference to `create_file' /usr/bin/ld: src/device.o: in function `device_load_svc_chng_ccc': /github/workspace/src/device.c:5822: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:5823: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: src/device.o: in function `device_wait_for_svc_complete': /github/workspace/src/device.c:6145: undefined reference to `main_opts' /usr/bin/ld: src/device.o: in function `device_bonding_attempt_retry': /github/workspace/src/device.c:6240: undefined reference to `btd_adapter_pin_cb_iter_end' /usr/bin/ld: src/device.o: in function `device_request_pincode': /github/workspace/src/device.c:6388: undefined reference to `agent_request_pincode' /usr/bin/ld: src/device.o: in function `device_request_passkey': /github/workspace/src/device.c:6407: undefined reference to `agent_request_passkey' /usr/bin/ld: src/device.o: in function `device_confirm_passkey': /github/workspace/src/device.c:6449: undefined reference to `btd_adapter_confirm_reply' /usr/bin/ld: /github/workspace/src/device.c:6458: undefined reference to `agent_request_confirmation' /usr/bin/ld: /github/workspace/src/device.c:6425: undefined reference to `main_opts' /usr/bin/ld: /github/workspace/src/device.c:6455: undefined reference to `agent_request_authorization' /usr/bin/ld: /github/workspace/src/device.c:6426: undefined reference to `btd_adapter_confirm_reply' /usr/bin/ld: src/device.o: in function `device_notify_passkey': /github/workspace/src/device.c:6492: undefined reference to `agent_display_passkey' /usr/bin/ld: src/device.o: in function `device_notify_pincode': /github/workspace/src/device.c:6513: undefined reference to `agent_display_pincode' /usr/bin/ld: src/device.o: in function `device_cancel_authentication': /github/workspace/src/device.c:6572: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:6576: undefined reference to `agent_cancel' /usr/bin/ld: src/device.o: in function `device_cancel_bonding': /github/workspace/src/device.c:2878: undefined reference to `ba2str' /usr/bin/ld: src/device.o: in function `bonding_request_cancel': /github/workspace/src/device.c:1587: undefined reference to `adapter_cancel_bonding' /usr/bin/ld: src/device.o: in function `create_bond_req_exit': /github/workspace/src/device.c:2714: undefined reference to `ba2str' /usr/bin/ld: src/device.o: in function `device_bonding_complete': /github/workspace/src/device.c:6043: undefined reference to `agent_cancel' /usr/bin/ld: /github/workspace/src/device.c:6101: undefined reference to `main_opts' /usr/bin/ld: src/device.o: in function `device_bonding_retry': /github/workspace/src/device.c:6212: undefined reference to `agent_get_io_capability' /usr/bin/ld: /github/workspace/src/device.c:6216: undefined reference to `adapter_bonding_attempt' /usr/bin/ld: src/device.o: in function `btd_device_get_primary': /github/workspace/src/device.c:6594: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: src/device.o: in function `btd_device_add_uuid': /github/workspace/src/device.c:6652: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: src/device.o: in function `add_gatt_service': /github/workspace/src/device.c:3836: undefined reference to `bt_uuid_to_string' /usr/bin/ld: /github/workspace/src/device.c:3856: undefined reference to `btd_service_get_profile' /usr/bin/ld: /github/workspace/src/device.c:3865: undefined reference to `service_accept' /usr/bin/ld: src/device.o: in function `gatt_service_added': /github/workspace/src/device.c:3945: undefined reference to `btd_gatt_client_service_added' /usr/bin/ld: src/device.o: in function `device_new': /github/workspace/src/device.c:4044: undefined reference to `adapter_get_path' /usr/bin/ld: /github/workspace/src/device.c:4073: undefined reference to `str2ba' /usr/bin/ld: /github/workspace/src/device.c:4075: undefined reference to `btd_gatt_client_new' /usr/bin/ld: /github/workspace/src/device.c:4100: undefined reference to `main_opts' /usr/bin/ld: src/device.o: in function `device_create': /github/workspace/src/device.c:4134: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:4148: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: src/device.o: in function `device_remove': /github/workspace/src/device.c:4481: undefined reference to `service_remove' /usr/bin/ld: src/device.o: in function `device_set_appearance': /github/workspace/src/device.c:6786: undefined reference to `gap_appearance_to_icon' /usr/bin/ld: src/device.o: in function `btd_device_set_pnpid': /github/workspace/src/device.c:6815: undefined reference to `bt_modalias' /usr/bin/ld: src/device.o: in function `update_bredr_services': /github/workspace/src/device.c:4827: undefined reference to `btd_adapter_get_address' /usr/bin/ld: /github/workspace/src/device.c:4827: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:4828: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:4852: undefined reference to `bt_uuid2string' /usr/bin/ld: /github/workspace/src/device.c:4857: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: src/device.o: in function `update_record': /github/workspace/src/device.c:4799: undefined reference to `sdp_copy_record' /usr/bin/ld: /github/workspace/src/device.c:4799: undefined reference to `sdp_list_append' /usr/bin/ld: /github/workspace/src/device.c:4802: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: src/device.o: in function `store_sdp_record': /github/workspace/src/device.c:4718: undefined reference to `sdp_gen_record_pdu' /usr/bin/ld: src/device.o: in function `store_primaries_from_sdp_record': /github/workspace/src/device.c:4743: undefined reference to `sdp_uuid16_create' /usr/bin/ld: /github/workspace/src/device.c:4744: undefined reference to `bt_uuid2string' /usr/bin/ld: /github/workspace/src/device.c:4746: undefined reference to `sdp_uuid16_create' /usr/bin/ld: /github/workspace/src/device.c:4747: undefined reference to `bt_uuid2string' /usr/bin/ld: /github/workspace/src/device.c:4752: undefined reference to `gatt_parse_record' /usr/bin/ld: src/device.o: in function `update_bredr_services': /github/workspace/src/device.c:4861: undefined reference to `sdp_data_get' /usr/bin/ld: /github/workspace/src/device.c:4864: undefined reference to `sdp_data_get' /usr/bin/ld: /github/workspace/src/device.c:4867: undefined reference to `sdp_data_get' /usr/bin/ld: /github/workspace/src/device.c:4870: undefined reference to `sdp_data_get' /usr/bin/ld: src/device.o: in function `update_record': /github/workspace/src/device.c:4804: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: src/device.o: in function `update_bredr_services': /github/workspace/src/device.c:4894: undefined reference to `create_file' /usr/bin/ld: /github/workspace/src/device.c:4905: undefined reference to `create_file' /usr/bin/ld: src/device.o: in function `search_cb': /github/workspace/src/device.c:4988: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:4999: undefined reference to `sdp_record_free' /usr/bin/ld: /github/workspace/src/device.c:4999: undefined reference to `sdp_list_free' /usr/bin/ld: src/device.o: in function `device_services_from_record': /github/workspace/src/device.c:4948: undefined reference to `sdp_uuid16_create' /usr/bin/ld: /github/workspace/src/device.c:4949: undefined reference to `bt_uuid2string' /usr/bin/ld: /github/workspace/src/device.c:4965: undefined reference to `gatt_parse_record' /usr/bin/ld: /github/workspace/src/device.c:4971: undefined reference to `sdp_uuid2strn' /usr/bin/ld: src/device.o: in function `search_cb': /github/workspace/src/device.c:4988: undefined reference to `ba2str' /usr/bin/ld: /github/workspace/src/device.c:4988: undefined reference to `ba2str' /usr/bin/ld: src/device.o: in function `browse_cb': /github/workspace/src/device.c:5052: undefined reference to `sdp_uuid16_create' /usr/bin/ld: /github/workspace/src/device.c:5053: undefined reference to `btd_adapter_get_address' /usr/bin/ld: /github/workspace/src/device.c:5053: undefined reference to `bt_search_service' /usr/bin/ld: src/device.o: in function `btd_device_set_record': /github/workspace/src/device.c:6721: undefined reference to `record_from_string' /usr/bin/ld: /github/workspace/src/device.c:6722: undefined reference to `sdp_list_append' /usr/bin/ld: /github/workspace/src/device.c:6724: undefined reference to `sdp_list_free' /usr/bin/ld: src/device.o: in function `device_create_from_storage': /github/workspace/src/device.c:4119: undefined reference to `btd_adapter_get_storage_dir' /usr/bin/ld: src/device.o: in function `btd_device_get_service': /github/workspace/src/device.c:6891: undefined reference to `btd_service_get_profile' /usr/bin/ld: src/device.o: in function `btd_device_init': /github/workspace/src/device.c:6902: undefined reference to `btd_get_dbus_connection' /usr/bin/ld: /github/workspace/src/device.c:6903: undefined reference to `btd_service_add_state_cb' /usr/bin/ld: src/device.o: in function `dev_disconn_service': /github/workspace/src/device.c:1592: undefined reference to `btd_service_disconnect' /usr/bin/ld: src/device.o: in function `prim_uuid_cmp': /github/workspace/src/device.c:3966: undefined reference to `bt_uuid_strcmp' /usr/bin/ld: src/device.o: in function `disconnect_gatt_service': /github/workspace/src/device.c:5081: undefined reference to `btd_service_disconnect' /usr/bin/ld: src/device.o: in function `get_icon': /github/workspace/src/device.c:930: undefined reference to `gap_appearance_to_icon' /usr/bin/ld: /github/workspace/src/device.c:928: undefined reference to `class_to_icon' /usr/bin/ld: src/device.o: in function `attio_cleanup': /github/workspace/src/device.c:643: undefined reference to `g_attrib_unref' /usr/bin/ld: src/device.o: in function `device_remove_profile': /github/workspace/src/device.c:4686: undefined reference to `service_remove' /usr/bin/ld: src/device.o: in function `device_set_wake_allowed': /github/workspace/src/device.c:1399: undefined reference to `adapter_set_device_wakeable' /usr/bin/ld: src/device.o: in function `device_remove_connection': /github/workspace/src/device.c:3071: undefined reference to `btd_adapter_remove_device' /usr/bin/ld: src/device.o: in function `dev_connect': /github/workspace/src/device.c:2141: undefined reference to `btd_error_failed' /usr/bin/ld: src/device.o: in function `connect_profiles': /github/workspace/src/device.c:2006: undefined reference to `btd_error_in_progress' /usr/bin/ld: /github/workspace/src/device.c:2050: undefined reference to `btd_error_failed' /usr/bin/ld: /github/workspace/src/device.c:2009: undefined reference to `btd_error_not_ready' /usr/bin/ld: /github/workspace/src/device.c:2025: undefined reference to `btd_error_not_available' /usr/bin/ld: src/device.o: in function `device_remove_bonding': /github/workspace/src/device.c:4405: undefined reference to `btd_adapter_remove_bonding' /usr/bin/ld: src/device.o: in function `device_set_unpaired': /github/workspace/src/device.c:6007: undefined reference to `btd_adapter_remove_device' /usr/bin/ld: src/device.o: in function `cancel_pairing': /github/workspace/src/device.c:2900: undefined reference to `btd_error_does_not_exist' /usr/bin/ld: src/device.o: in function `btd_device_get_record': /github/workspace/src/device.c:6748: undefined reference to `find_record_in_list' /usr/bin/ld: src/device.o: in function `btd_device_cleanup': /github/workspace/src/device.c:6909: undefined reference to `btd_service_remove_state_cb' /usr/bin/ld: src/.libs/libshared-glib.a(ad.o): in function `serialize_uuids': /github/workspace/src/shared/ad.c:322: undefined reference to `bt_uuid_to_le' /usr/bin/ld: src/.libs/libshared-glib.a(ad.o): in function `uuid_match': /github/workspace/src/shared/ad.c:527: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(ad.o): in function `service_uuid_match': /github/workspace/src/shared/ad.c:713: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(ad.o): in function `uuid_data_match': /github/workspace/src/shared/ad.c:84: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(ad.o): in function `service_data_match': /github/workspace/src/shared/ad.c:764: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(ad.o): in function `serialize_service_data': /github/workspace/src/shared/ad.c:404: undefined reference to `bt_uuid_to_le' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `find_ccc': /github/workspace/src/shared/gatt-client.c:233: undefined reference to `bt_uuid16_create' /usr/bin/ld: /github/workspace/src/shared/gatt-client.c:235: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `discovery_parse_services': /github/workspace/src/shared/gatt-client.c:1121: undefined reference to `bt_uuid128_create' /usr/bin/ld: /github/workspace/src/shared/gatt-client.c:1124: undefined reference to `bt_uuid_to_string' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `discover_descs': /github/workspace/src/shared/gatt-client.c:716: undefined reference to `bt_uuid16_create' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `read_server_feat': /github/workspace/src/shared/gatt-client.c:1511: undefined reference to `bt_uuid16_create' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `read_db_hash': /github/workspace/src/shared/gatt-client.c:1452: undefined reference to `bt_uuid16_create' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `discover_incl_cb': /github/workspace/src/shared/gatt-client.c:567: undefined reference to `bt_uuid128_create' /usr/bin/ld: /github/workspace/src/shared/gatt-client.c:570: undefined reference to `bt_uuid_to_string' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `discover_chrcs_cb': /github/workspace/src/shared/gatt-client.c:970: undefined reference to `bt_uuid128_create' /usr/bin/ld: /github/workspace/src/shared/gatt-client.c:973: undefined reference to `bt_uuid_to_string' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `notify_chrc_create': /github/workspace/src/shared/gatt-client.c:299: undefined reference to `bt_uuid16_create' /usr/bin/ld: /github/workspace/src/shared/gatt-client.c:300: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `register_service_changed': /github/workspace/src/shared/gatt-client.c:1786: undefined reference to `bt_uuid16_create' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `discover_descs_cb': /github/workspace/src/shared/gatt-client.c:875: undefined reference to `bt_uuid16_create' /usr/bin/ld: /github/workspace/src/shared/gatt-client.c:878: undefined reference to `bt_uuid128_create' /usr/bin/ld: /github/workspace/src/shared/gatt-client.c:881: undefined reference to `bt_uuid_to_string' /usr/bin/ld: /github/workspace/src/shared/gatt-client.c:904: undefined reference to `bt_uuid_cmp' /usr/bin/ld: /github/workspace/src/shared/gatt-client.c:891: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `write_client_features': /github/workspace/src/shared/gatt-client.c:1969: undefined reference to `bt_uuid16_create' /usr/bin/ld: /github/workspace/src/shared/gatt-client.c:1980: undefined reference to `bt_uuid16_create' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-client.o): in function `write_server_features': /github/workspace/src/shared/gatt-client.c:1947: undefined reference to `bt_uuid16_create' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-server.o): in function `find_by_type_val_cb': /github/workspace/src/shared/gatt-server.c:757: undefined reference to `bt_uuid16_create' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-server.o): in function `get_uuid_le': /github/workspace/src/shared/gatt-server.c:179: undefined reference to `bt_uuid128_create' /usr/bin/ld: /github/workspace/src/shared/gatt-server.c:175: undefined reference to `bt_uuid16_create' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-server.o): in function `encode_find_info_rsp': /github/workspace/src/shared/gatt-server.c:612: undefined reference to `bt_uuid_to_le' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-server.o): in function `read_by_grp_type_cb': /github/workspace/src/shared/gatt-server.c:306: undefined reference to `bt_uuid16_create' /usr/bin/ld: /github/workspace/src/shared/gatt-server.c:307: undefined reference to `bt_uuid16_create' /usr/bin/ld: /github/workspace/src/shared/gatt-server.c:308: undefined reference to `bt_uuid_cmp' /usr/bin/ld: /github/workspace/src/shared/gatt-server.c:308: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-db.o): in function `uuid_to_le': /github/workspace/src/shared/gatt-db.c:491: undefined reference to `bt_uuid_to_uuid128' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-db.o): in function `gen_hash_m': /github/workspace/src/shared/gatt-db.c:333: undefined reference to `bt_uuid_to_le' /usr/bin/ld: /github/workspace/src/shared/gatt-db.c:321: undefined reference to `bt_uuid_to_le' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-db.o): in function `le_to_uuid': /github/workspace/src/shared/gatt-db.c:514: undefined reference to `bt_uuid128_create' /usr/bin/ld: /github/workspace/src/shared/gatt-db.c:501: undefined reference to `bt_uuid16_create' /usr/bin/ld: /github/workspace/src/shared/gatt-db.c:506: undefined reference to `bt_uuid32_create' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-db.o): in function `gatt_db_service_foreach': /github/workspace/src/shared/gatt-db.c:1452: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-db.o): in function `gatt_db_service_foreach_desc': /github/workspace/src/shared/gatt-db.c:1478: undefined reference to `bt_uuid_cmp' /usr/bin/ld: /github/workspace/src/shared/gatt-db.c:1497: undefined reference to `bt_uuid_cmp' /usr/bin/ld: /github/workspace/src/shared/gatt-db.c:1498: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-db.o): in function `gatt_db_attribute_get_service_uuid': /github/workspace/src/shared/gatt-db.c:1630: undefined reference to `bt_uuid128_create' /usr/bin/ld: /github/workspace/src/shared/gatt-db.c:1621: undefined reference to `bt_uuid16_create' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-db.o): in function `gatt_db_insert_service': /github/workspace/src/shared/gatt-db.c:722: undefined reference to `bt_uuid_cmp' /usr/bin/ld: /github/workspace/src/shared/gatt-db.c:723: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-db.o): in function `foreach_in_range': /github/workspace/src/shared/gatt-db.c:1382: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-db.o): in function `foreach_service_in_range': /github/workspace/src/shared/gatt-db.c:1335: undefined reference to `bt_uuid_cmp' /usr/bin/ld: /github/workspace/src/shared/gatt-db.c:1339: undefined reference to `bt_uuid_cmp' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-db.o):/github/workspace/src/shared/gatt-db.c:1572: more undefined references to `bt_uuid_cmp' follow /usr/bin/ld: src/.libs/libshared-glib.a(gatt-helpers.o): in function `bt_gatt_iter_next_service': /github/workspace/src/shared/gatt-helpers.c:349: undefined reference to `bt_uuid_to_uuid128' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-helpers.o): in function `discover_services': /github/workspace/src/shared/gatt-helpers.c:856: undefined reference to `bt_uuid_to_le' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-helpers.o): in function `find_by_type_val_cb': /github/workspace/src/shared/gatt-helpers.c:786: undefined reference to `bt_uuid_to_le' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-helpers.o): in function `read_by_type_cb': /github/workspace/src/shared/gatt-helpers.c:1340: undefined reference to `bt_uuid_to_le' /usr/bin/ld: src/.libs/libshared-glib.a(gatt-helpers.o): in function `bt_gatt_read_by_type': /github/workspace/src/shared/gatt-helpers.c:1383: undefined reference to `bt_uuid_to_le' collect2: error: ld returned 1 exit status make[1]: *** [Makefile:6060: unit/test-adv-monitor] Error 1 make: *** [Makefile:4056: all] Error 2 --- Regards, Linux Bluetooth --===============4429390691823547765==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YLvHMObeY19Z8QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 00:10:46 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id SGVrLebeY1+4RgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 00:10:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 80748A01B4; Fri, 18 Sep 2020 00:10:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726009AbgIQWKj (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 18:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbgIQWKj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 18:10:39 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84919C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:10:39 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id k15so2090592pfc.12 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nuKbT2MkJWv7INdk0/k3X3j6IVsocXvyZrAPLLJg8Ys=; b=BXsYk4jZ3oZKfOInNKFKKn4yBUT1wWKiNMe4UXNzN/6bZ+l5LP2n+aV6hlZ0pfIKTd 5ypNm+aS/v1zZNLGb2IUZY7ht9OAkRT+wM/GGz43ffsS++V9bqGWu4J2o4VL4h95314I jpuPHFcu0u1c+tLgu54sFs4bzgKuIaZggD4cQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nuKbT2MkJWv7INdk0/k3X3j6IVsocXvyZrAPLLJg8Ys=; b=LXuDW6ur6u77IcWZaqJOYMNw4+WyRDZXLHLTw+HN9zLt9PE6cjwyMSrcdooMfQjXS/ Jb2Xk+k7TINY90qlxN7gZTWR4tzLdZEZo251FtFROgmtBUMhEAk30i53vnldxOpaTi7Q cDn8ZOTD0jk485lJNzYWwRib3Io1D/r7HafV+UDLz6DdaaSn8vZzStGmAYC/v55fAM5t q8u65zfciIvkZ3OL+sWsmeDrrlAMmriyMrKrQdHG5aqBUz85t8JaETYSOfASvmMrRG2T z+o77G1yHn3RH9zGhAJx5WhJW6wZRhBQNc/E9MnGHR8krJT6/L++JGE7ZzvWpn3DnKzZ zyrg== X-Gm-Message-State: AOAM53284nmWK1z83SNDhoU2q2nWMdEHl+BERWjf2jVUfg+PmWiaIIw0 Po0uJt0Cr7ljFp/LFfyB4BC8g55amDdpTw== X-Google-Smtp-Source: ABdhPJwPW5G/O6dfvfwgRAXR/Jc2NC28IgZDwHLrb2MBCYCFChRXaO8BwSqTEXDnBLTsgowcVrelxw== X-Received: by 2002:aa7:9635:0:b029:142:2501:3980 with SMTP id r21-20020aa796350000b029014225013980mr13055500pfg.69.1600380638543; Thu, 17 Sep 2020 15:10:38 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id gd14sm650289pjb.0.2020.09.17.15.10.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 15:10:37 -0700 (PDT) From: Sonny Sasaka <sonnysasaka@chromium.org> To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Subject: [PATCH BlueZ v2] a2dp: Keep track of ref ownership of a2dp_setup Date: Thu, 17 Sep 2020 15:10:34 -0700 Message-Id: <20200917221034.154218-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.14 / 15.00 / 15.00 X-Rspamd-Queue-Id: 80748A01B4 X-Rspamd-UID: 5a8baa Currently transport_cb and abort_cfm make assumption that they have an a2dp_setup reference held as a result of open_ind invocation. In the field this is not always true, for example when the peer device opens an L2CAP channel for AVDTP transport channel without sending AVDTP_OPEN request through the AVDTP signaling channel first. Although in this case the peer device does not behave correctly, we should protect this possible crash from happening by making sure that transport_cb and abort_cfm are really holding a reference of a2dp_setup object before trying to unref them. After grabbing a reference, open_ind stores the pointer in stream->user_data. If this field is set, that means there is a pending AVDTP_OPEN command and it needs to be unref-fed later once and only once: when the transport channel is created (transport_cb) or when the AVDTP_OPEN command is aborted (abort_cfm). If this field is not set, nothing should unref it. This enforces that the reference counting is correct regardless of the behavior of the peer device. A sample crash stack trace from Chrome OS: * thread #1, stop reason = signal SIGSEGV * frame #0: 0x0c64f0e8 bluetoothd`queue_remove_all at queue.c:351 frame #1: 0x0c64f086 bluetoothd`queue_destroy at queue.c:73 frame #2: 0x0c6022b0 bluetoothd`setup_unref at a2dp.c:222 frame #3: 0x0c604942 bluetoothd`transport_cb at a2dp.c:2229 frame #4: 0x0c61e35c bluetoothd`accept_cb at btio.c:203 frame #5: 0xf679523c libglib-2.0.so.0`g_main_context_dispatch at gmain.c:3182 frame #6: 0xf67954aa libglib-2.0.so.0`g_main_context_iterate at gmain.c:3920 frame #7: 0xf679569a libglib-2.0.so.0`g_main_loop_run at gmain.c:4116 frame #8: 0x0c65a5a0 bluetoothd`mainloop_run at mainloop-glib.c:79 frame #9: 0x0c65a7ea bluetoothd`mainloop_run_with_signal at mainloop-notify.c:201 frame #10: 0x0c6477ec bluetoothd`main at main.c:772 frame #11: 0xf65bc0a2 libc.so.6`__libc_start_main at libc-start.c:308 Reviewed-by: Alain Michaud <alainm@chromium.org> --- profiles/audio/a2dp.c | 34 ++++++++++++++++++++++++++-------- profiles/audio/avdtp.c | 17 +++++++++++++++++ profiles/audio/avdtp.h | 5 +++++ 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c index 2feea66c0..26147f96e 100644 --- a/profiles/audio/a2dp.c +++ b/profiles/audio/a2dp.c @@ -915,6 +915,11 @@ static void update_last_used(struct a2dp_channel *chan, struct a2dp_sep *lsep, avdtp_get_seid(rsep)); } +static void destroy_setup(void *data) +{ + setup_unref(data); +} + static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep, struct avdtp_stream *stream, uint8_t *err, void *user_data) @@ -927,10 +932,21 @@ static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep, else DBG("Source %p: Open_Ind", sep); + if (avdtp_stream_get_user_data(stream)) { + warn("setup already exists"); + return FALSE; + } + setup = a2dp_setup_get(session); if (!setup) return FALSE; + /* + * Use avdtp_stream's user_data to keep the reference ownership of the + * setup object. This ensures that this reference will be unref-ed + * exactly once. + */ + avdtp_stream_set_user_data(stream, setup, destroy_setup); setup->stream = stream; if (!err && setup->chan) @@ -1285,14 +1301,13 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, void *user_data) { struct a2dp_sep *a2dp_sep = user_data; - struct a2dp_setup *setup; + struct a2dp_setup *setup = avdtp_stream_get_user_data(stream); if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK) DBG("Sink %p: Abort_Cfm", sep); else DBG("Source %p: Abort_Cfm", sep); - setup = find_setup_by_session(session); if (!setup) return; @@ -1302,6 +1317,7 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, } setup_unref(setup); + avdtp_stream_set_user_data(stream, NULL, NULL); } static gboolean reconf_ind(struct avdtp *session, struct avdtp_local_sep *sep, @@ -2216,11 +2232,12 @@ fail: static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) { - struct a2dp_setup *setup = user_data; + struct avdtp_stream *stream = user_data; + struct a2dp_setup *setup = avdtp_stream_get_user_data(stream); uint16_t omtu, imtu; - if (!g_slist_find(setups, setup)) { - warn("bt_io_accept: setup %p no longer valid", setup); + if (!setup) { + warn("transport_cb: setup does not exist"); g_io_channel_shutdown(io, TRUE, NULL); return; } @@ -2238,8 +2255,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) goto drop; } - if (!avdtp_stream_set_transport(setup->stream, - g_io_channel_unix_get_fd(io), + if (!avdtp_stream_set_transport(stream, g_io_channel_unix_get_fd(io), imtu, omtu)) goto drop; @@ -2249,6 +2265,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) setup->io = NULL; setup_unref(setup); + avdtp_stream_set_user_data(stream, NULL, NULL); return; @@ -2297,7 +2314,8 @@ static void confirm_cb(GIOChannel *io, gpointer data) goto drop; } - if (!bt_io_accept(io, transport_cb, setup, NULL, &err)) { + if (!bt_io_accept(io, transport_cb, setup->stream, NULL, + &err)) { error("bt_io_accept: %s", err->message); g_error_free(err); goto drop; diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 782268c08..76d06f47c 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -366,6 +366,8 @@ struct avdtp_stream { GSList *caps; GSList *callbacks; struct avdtp_service_capability *codec; + void *user_data; + avdtp_stream_user_data_destroy_t user_data_destroy; guint io_id; /* Transport GSource ID */ guint timer; /* Waiting for other side to close or open * the transport channel */ @@ -727,6 +729,9 @@ static void stream_free(void *data) g_slist_free_full(stream->callbacks, g_free); g_slist_free_full(stream->caps, g_free); + if (stream->user_data && stream->user_data_destroy) + stream->user_data_destroy(stream->user_data); + g_free(stream); } @@ -3147,6 +3152,18 @@ struct avdtp_remote_sep *avdtp_stream_get_remote_sep( return NULL; } +void avdtp_stream_set_user_data(struct avdtp_stream *stream, void *data, + avdtp_stream_user_data_destroy_t destroy) +{ + stream->user_data = data; + stream->user_data_destroy = destroy; +} + +void *avdtp_stream_get_user_data(struct avdtp_stream *stream) +{ + return stream->user_data; +} + gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd, size_t imtu, size_t omtu) { diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h index 011fea89e..247e9df75 100644 --- a/profiles/audio/avdtp.h +++ b/profiles/audio/avdtp.h @@ -133,6 +133,8 @@ typedef void (*avdtp_set_configuration_cb) (struct avdtp *session, struct avdtp_stream *stream, struct avdtp_error *err); +typedef void (*avdtp_stream_user_data_destroy_t)(void *data); + /* Callbacks for when a reply is received to a command that we sent */ struct avdtp_sep_cfm { void (*set_configuration) (struct avdtp *session, @@ -260,6 +262,9 @@ gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream, GSList *caps); struct avdtp_remote_sep *avdtp_stream_get_remote_sep( struct avdtp_stream *stream); +void avdtp_stream_set_user_data(struct avdtp_stream *stream, void *data, + avdtp_stream_user_data_destroy_t destroy); +void *avdtp_stream_get_user_data(struct avdtp_stream *stream); unsigned int avdtp_add_state_cb(struct btd_device *dev, avdtp_session_state_cb cb, void *user_data); -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sD2UN7HhY18p+wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 00:22:41 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id +PnYNLHhY191+gEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 00:22:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 477B4A0377; Fri, 18 Sep 2020 00:22:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbgIQWW3 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 18:22:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbgIQWW3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 18:22:29 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6F40C061788 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:28 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id i199so3474769ybg.22 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=R8WEgJrMetWJNrqEtzBhqLHZfLiSdt4Hll3zS+w3mL4=; b=LuOayWOT30KhGQ64pljmo3YZfT4n3AMOP/VuhP+krwnQDGkwHABX+yw/BJsJ+hLIIe Ulh6WTje8RSbruv70Sc+kpgMhfyVGiOcQdzEbA/zmIqOnyNoBGHbNLs27GaikevQvtz4 89asAVFiS2S7t6g2SJ41MWbbHseZIbwnoxtzpM2divOrFyqEnBTHt74tmz/8+/b62THJ B5sMI3P3XWOLDazTsZVJUlEi/yz46xEc5jTC+GbNKeb56ncrSey5uH41g54M6UfqiSPH 0EJnuth2sPqAPpRvVhY3lx4xR4LM/1qnN9buIPIy4MSHGr6Y89aPFkUt+2oA66ViB7qj 87Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=R8WEgJrMetWJNrqEtzBhqLHZfLiSdt4Hll3zS+w3mL4=; b=em3Ul2ZSh02QGmMh9YjT+eisuMqYBb4RCx9gEpFFGqiKr93lByL2wz/oGIDcedSFtK Dp0H28+ZoP45Z6MhLkCIrWZocE1ho/EIA7Y+Gq1BiefL7SF+vznFY7urtT/a/+oUcyxB WsNJ2Mcxhr0DW96uR/q+GsOA/wgifgVZibWx9775uzfsoJbfnSPR7jQwRLBOQHQ05zV1 yf65z0WFfoFStlW0pJMUUOA3LO7+b8Ehf563BUmU4L13ZgI3RplxVdf3mwGN80n4+z5E cS//fI/+SefbTH36Wsc6XNT+1XKZCt7/ivVKq+X00QKBiW0G/S1PD9S4B89WEHr06qnZ HQ8Q== X-Gm-Message-State: AOAM532u0J+VjoTW5Q88IXo5xO+ucSvhQELW3+xxdYxSE92SWXjCnpWn ocsqubLNT1Qb4vu8pfuzg0Xjgc3vqp8bk//w2If0 X-Google-Smtp-Source: ABdhPJwxgj4oj1GzHKD3/4dU+VhpN0mjUP7crNTQPhZayLjhtttuxehZiouwKLTbDrq27Bd6SbFZV61Q7bZj+I0+QlEY X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:ad46:: with SMTP id l6mr20065498ybe.492.1600381347766; Thu, 17 Sep 2020 15:22:27 -0700 (PDT) Date: Thu, 17 Sep 2020 15:22:11 -0700 Message-Id: <20200917222217.2534502-1-danielwinkler@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v2 0/6] Bluetooth: Add new MGMT interface for advertising add From: Daniel Winkler <danielwinkler@google.com> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.82 / 15.00 / 15.00 X-Rspamd-Queue-Id: 477B4A0377 X-Rspamd-UID: 032bfc Hi Maintainers, This patch series defines the new two-call MGMT interface for adding new advertising instances. Similarly to the hci advertising commands, a mgmt call to set parameters is expected to be first, followed by a mgmt call to set advertising data/scan response. The members of the parameters request are optional; the caller defines a "params" bitfield in the structure that indicates which parameters were intentionally set, and others are set to defaults. The main feature here is the introduction of min/max parameters and tx power that can be requested by the client. Min/max parameters will be used both with and without extended advertising support, and tx power will be used with extended advertising support. After a call for hci advertising parameters, a new TX_POWER_SELECTED event will be emitted to alert userspace to the actual chosen tx power. Additionally, to inform userspace of the controller LE Tx power capabilities for the client's benefit, this series also adds an MGMT command to query controller capabilities, which returns a flexible TLV format for future flexibility. All changes have been tested on hatch (extended advertising) and kukui (no extended advertising) chromebooks with manual testing verifying correctness of parameters/data in btmon traces, and our automated test suite of 25 single- and multi-advertising usage scenarios. A separate patch series will add support in bluetoothd. Thanks in advance for your feedback! Daniel Winkler Changes in v2: - Fixed sparse error in Capabilities MGMT command Daniel Winkler (6): Bluetooth: Add helper to set adv data Bluetooth: Break add adv into two mgmt commands Bluetooth: Use intervals and tx power from mgmt cmds Bluetooth: Emit tx power chosen on ext adv params completion Bluetooth: Query LE tx power on startup Bluetooth: Add MGMT command for controller capabilities include/net/bluetooth/hci.h | 7 + include/net/bluetooth/hci_core.h | 14 +- include/net/bluetooth/mgmt.h | 48 ++++ net/bluetooth/hci_core.c | 47 +++- net/bluetooth/hci_event.c | 22 ++ net/bluetooth/hci_request.c | 29 ++- net/bluetooth/mgmt.c | 420 ++++++++++++++++++++++++++++++- 7 files changed, 561 insertions(+), 26 deletions(-) -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SEzvMNjhY18p+wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 00:23:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 0FZHLdjhY19fbAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 00:23:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5F1FBA0377; Fri, 18 Sep 2020 00:23:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726368AbgIQWWm (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 18:22:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbgIQWWg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 18:22:36 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A49EC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:36 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id d15so3592704ybk.0 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=6KVYAtT8avJT6nGdwz/alAqsUTxpVl7DrmYqi+6Qdd8=; b=ZH0qQn3XVVbWQYzf0YQMBRIESHKTr2OukmgdWCO7WpgSghJMC5GBZgbU+O54fT590T eJ89xfjzBGJrWmmoaEn9a2UVFKV0pIgx0iT8sP9XfBjqnoozwvZ1y+AWHgLro7YkEUPB /O0KJ4TAhPmFnNalCuIctndomyQddXPjK9UwVLltnQukZkh1lx1df7mwHeAXwv3cp0Hs cehN093GPSs7uhvOasMD9SCBzbewXNAapHdl4uWY/UMFm4qBt0k4UCwVe8vdd0/SfFnp kZ+tk5yCrr1WDu4S1meI9P6KPsd4rW17FvpYpBT6KwzL8Nvhu8AS9YDFvsyNIx+TlWl5 RI/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=6KVYAtT8avJT6nGdwz/alAqsUTxpVl7DrmYqi+6Qdd8=; b=TKw/H17VI03USqiW1LoQbM3tjzX5le9i2vmJ27xmeE/9X0KO0qyhtnf0BNkZuWEHuk yzMPPLmZW5IhGSLQBy6TvZ6e739FnvYddyasx/dC83ca5476hFDwOzvwXYZh2seCTzQ4 V64VOrh5H/bWELZgiztDcmtLRp10FOITgNhv5Ls0MOX8dGsysIMaIJ38rzZ8/LN1SHdx z+lJD16C57Dq5Zwke/KvnyZQScB0shNM/swUHjNiFwW6QmCn909x1hbZOyeOr38adUsk e084XOeE4qSX3ZiL3hw7ltF3xTcbPY2wtnTsajBjdsgd/JCvj8EwIorxCux6p+hiDsEJ 30sw== X-Gm-Message-State: AOAM533BHsjqfl/8IugxqIWVEzPRc4wD+BBqUngeEnclExrGypVWXDy5 wU+H5t4PHZ7KOeeVbmPj4Yp6hsF7O4Mo6F1NU8SW X-Google-Smtp-Source: ABdhPJxC5/D/JnjQqVL5U6aZTf7ASRpfVuPf7sKnRKkHPapIb8ol4CGQKVQOcDJ5d2kUA1+KTfn8miyv1abmQCzMoMPo X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:c694:: with SMTP id k142mr18415607ybf.369.1600381355591; Thu, 17 Sep 2020 15:22:35 -0700 (PDT) Date: Thu, 17 Sep 2020 15:22:15 -0700 In-Reply-To: <20200917222217.2534502-1-danielwinkler@google.com> Message-Id: <20200917152052.v2.4.I34169001276125c476e86ece0b4802c36aa08bca@changeid> Mime-Version: 1.0 References: <20200917222217.2534502-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v2 4/6] Bluetooth: Emit tx power chosen on ext adv params completion From: Daniel Winkler <danielwinkler@google.com> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.58 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5F1FBA0377 X-Rspamd-UID: 4ce53b Our hci call to set extended advertising parameters returns the actual tx power selected by the controller. This patch signals a new TX_POWER_SELECTED mgmt event to alert the caller of the actual tx power that is being used. This is important because the power selected will not necessarily match the power requested by the user. This patch is manually verified by ensuring the tx power selected event is signalled and caught by bluetoothd. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- Changes in v2: None include/net/bluetooth/hci_core.h | 2 ++ include/net/bluetooth/mgmt.h | 6 ++++++ net/bluetooth/hci_event.c | 4 ++++ net/bluetooth/mgmt.c | 11 +++++++++++ 4 files changed, 23 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index ab168f46b6d909..667b9d37099dec 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1781,6 +1781,8 @@ void mgmt_advertising_added(struct sock *sk, struct hci_dev *hdev, u8 instance); void mgmt_advertising_removed(struct sock *sk, struct hci_dev *hdev, u8 instance); +void mgmt_adv_tx_power_selected(struct hci_dev *hdev, u8 instance, + s8 tx_power); int mgmt_phy_configuration_changed(struct hci_dev *hdev, struct sock *skip); u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency, diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 859f0d3cd6ea38..db64cf4747554c 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -1079,3 +1079,9 @@ struct mgmt_ev_controller_resume { #define MGMT_WAKE_REASON_NON_BT_WAKE 0x0 #define MGMT_WAKE_REASON_UNEXPECTED 0x1 #define MGMT_WAKE_REASON_REMOTE_WAKE 0x2 + +#define MGMT_EV_ADV_TX_POWER_SELECTED 0x002f +struct mgmt_ev_adv_tx_power_selected { + __u8 instance; + __s8 tx_power; +} __packed; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index bd306ba3ade545..9a24fd99d9e08e 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1749,6 +1749,10 @@ static void hci_cc_set_ext_adv_param(struct hci_dev *hdev, struct sk_buff *skb) } /* Update adv data as tx power is known now */ hci_req_update_adv_data(hdev, hdev->cur_adv_instance); + + if (cp->handle) + mgmt_adv_tx_power_selected(hdev, cp->handle, rp->tx_power); + hci_dev_unlock(hdev); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 717c97affb1554..b9347ff1a1e961 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -167,6 +167,7 @@ static const u16 mgmt_events[] = { MGMT_EV_DEVICE_FLAGS_CHANGED, MGMT_EV_CONTROLLER_SUSPEND, MGMT_EV_CONTROLLER_RESUME, + MGMT_EV_ADV_TX_POWER_SELECTED, }; static const u16 mgmt_untrusted_commands[] = { @@ -1152,6 +1153,16 @@ void mgmt_advertising_removed(struct sock *sk, struct hci_dev *hdev, mgmt_event(MGMT_EV_ADVERTISING_REMOVED, hdev, &ev, sizeof(ev), sk); } +void mgmt_adv_tx_power_selected(struct hci_dev *hdev, u8 instance, s8 tx_power) +{ + struct mgmt_ev_adv_tx_power_selected ev; + + ev.instance = instance; + ev.tx_power = tx_power; + + mgmt_event(MGMT_EV_ADV_TX_POWER_SELECTED, hdev, &ev, sizeof(ev), NULL); +} + static void cancel_adv_timeout(struct hci_dev *hdev) { if (hdev->adv_instance_timeout) { -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2IvYJ93hY18p+wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 00:23:25 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id QGTSJN3hY1/AZAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 00:23:25 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DB6D7A01AD; Fri, 18 Sep 2020 00:23:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726412AbgIQWWy (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 18:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbgIQWWk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 18:22:40 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36296C06178A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:40 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id a16so3146855qtj.7 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=vpeQrnRyFpcso3Go0c148N2CAz5LUM7IS8DzIr9rjw0=; b=BLmHf8lgtfZH6kZGQJD85ea4x92p5W0Yy2wtHHE7cbeP71+j/9wB+ylAEY8FUYx2XK WrVYu5jcC0DQrL8RT6sPc++G8E4dgPy5XU9Uiwe2SgdtIBbE1ywecTulk0/lhO8kGBY/ dBlMhhYocv74bKTKdGXyG1akZltRpNNsZblefuNvoDr9Zewg57YW3sGKzuf6xu76HWdi /MI8eAeYYAFMeptwyXixLDbqLf0KFFQjQev3/I4vIB42jLEHwFT31PlytmaVYTHikoiO lg0M74zZBNG/RlmNbJFAhhjzDLXKft32m+uXXFZtFHb70lwB1xQKe+wSX4gkr8Omuupx M7AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=vpeQrnRyFpcso3Go0c148N2CAz5LUM7IS8DzIr9rjw0=; b=RXGbxMFJkHSbvXXz2+QaLKmiDJdrLLlO8Ntt3FTJ8ZNyqgLASD1+khgcUUjpKTAQ4T jbTogvTFTmCeM/7u8gH0JTlHgQNH3Es4QIX7fhnMLyhseVu/Xx1Rmq2PDArvqTajyA4V kLUK+rpG4K9pAk3V/SrNEeZbfj5ejbCxqkY/qzaVbeMqSuvOQVe7SZQRq8WICJbXS4eI LRhkLv46HFELnRzvwVzsnxhszqmZAqHq+rrFPo9AFR4ls6BQeqNiWDqtZdh86QjOnsJ1 WiOvOgcl9VawrLQaeQSSGY8fZi8tniNrGZv4aSdKktYBDdlz+cZZwc3qCZ28suCTsvzU cUug== X-Gm-Message-State: AOAM533flewbrGk9SHHtnD2pMX9bVIRSbsi0bHDH8Jhh4ebRxwpf+Zl8 +45r1Gyb92CuYyqpfx7M3TFFABJP+7Zl/IitBqu7 X-Google-Smtp-Source: ABdhPJznIHjupkbf9wVia6kDLIjZPmdFNgfta/zP0S9Q5V+F8qxpYjCEIkdpcN5nLq6im/rgnFZsstI2TGdYwcwZNK7s X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:ad4:5745:: with SMTP id q5mr30565379qvx.29.1600381359399; Thu, 17 Sep 2020 15:22:39 -0700 (PDT) Date: Thu, 17 Sep 2020 15:22:17 -0700 In-Reply-To: <20200917222217.2534502-1-danielwinkler@google.com> Message-Id: <20200917152052.v2.6.I5068c01cae3cea674a96e103a0cf4d8c81425a4f@changeid> Mime-Version: 1.0 References: <20200917222217.2534502-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v2 6/6] Bluetooth: Add MGMT command for controller capabilities From: Daniel Winkler <danielwinkler@google.com> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.69 / 15.00 / 15.00 X-Rspamd-Queue-Id: DB6D7A01AD X-Rspamd-UID: c25627 For advertising, we wish to know the LE tx power capabilities of the controller in userspace, so this patch adds a new MGMT command to query controller capabilities. The data returned is in TLV format, so it can be easily used to convey any data determined to be useful in the future, but for now it simply contains LE min and max tx power. The change was tested by manually verifying that the new MGMT command returns the tx power range as expected in userspace. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- Changes in v2: - Fixed sparse error in Capabilities MGMT command include/net/bluetooth/mgmt.h | 9 +++++++++ net/bluetooth/mgmt.c | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index db64cf4747554c..9aa792e5efc8d0 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -815,6 +815,15 @@ struct mgmt_rp_add_ext_adv_data { __u8 instance; } __packed; +#define MGMT_CAP_LE_TX_PWR_MIN 0x0000 +#define MGMT_CAP_LE_TX_PWR_MAX 0x0001 + +#define MGMT_OP_READ_CONTROLLER_CAP 0x0056 +#define MGMT_OP_READ_CONTROLLER_CAP_SIZE 0 +struct mgmt_rp_read_controller_cap { + __u8 capabilities[0]; +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { __le16 opcode; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index b9347ff1a1e961..fd36acb973ba1f 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -124,6 +124,7 @@ static const u16 mgmt_commands[] = { MGMT_OP_REMOVE_ADV_MONITOR, MGMT_OP_ADD_EXT_ADV_PARAMS, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_OP_READ_CONTROLLER_CAP, }; static const u16 mgmt_events[] = { @@ -181,6 +182,7 @@ static const u16 mgmt_untrusted_commands[] = { MGMT_OP_READ_EXP_FEATURES_INFO, MGMT_OP_READ_DEF_SYSTEM_CONFIG, MGMT_OP_READ_DEF_RUNTIME_CONFIG, + MGMT_OP_READ_CONTROLLER_CAP, }; static const u16 mgmt_untrusted_events[] = { @@ -4356,6 +4358,42 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev, return err; } +static int read_controller_cap(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) +{ + u8 i = 0; + + /* This command will return its data in TVL format. Currently we only + * wish to include LE tx power parameters, so this struct can be given + * a fixed size as data types are not changing. + */ + struct { + struct mgmt_tlv entry; + __s8 value; + } __packed cap[2]; + + BT_DBG("request for %s", hdev->name); + memset(cap, 0, sizeof(cap)); + + hci_dev_lock(hdev); + + /* Append LE tx power bounds */ + cap[i].entry.type = cpu_to_le16(MGMT_CAP_LE_TX_PWR_MIN); + cap[i].entry.length = sizeof(__s8); + cap[i].value = hdev->min_le_tx_power; + i++; + + cap[i].entry.type = cpu_to_le16(MGMT_CAP_LE_TX_PWR_MAX); + cap[i].entry.length = sizeof(__s8); + cap[i].value = hdev->max_le_tx_power; + i++; + + hci_dev_unlock(hdev); + + return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_READ_CONTROLLER_CAP, + MGMT_STATUS_SUCCESS, cap, sizeof(cap)); +} + static void read_local_oob_data_complete(struct hci_dev *hdev, u8 status, u16 opcode, struct sk_buff *skb) { @@ -8208,6 +8246,7 @@ static const struct hci_mgmt_handler mgmt_handlers[] = { HCI_MGMT_VAR_LEN }, { add_ext_adv_data, MGMT_ADD_EXT_ADV_DATA_SIZE, HCI_MGMT_VAR_LEN }, + { read_controller_cap, MGMT_OP_READ_CONTROLLER_CAP_SIZE }, }; void mgmt_index_added(struct hci_dev *hdev) -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id UBJtEuLhY18p+wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 00:23:30 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6ElNDeLhY191+gEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 00:23:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B92E3A017C; Fri, 18 Sep 2020 00:23:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726421AbgIQWW6 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 18:22:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbgIQWWi (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 18:22:38 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EE31C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:38 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id y53so3169824qth.2 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=IaJ7+vsFyvrnLSPfue9ByLmu7bRRks/6xUYOpfJTdBM=; b=HjpZ03rr6c+5GqAa6ALQLVZe20uBr6rmFeyEfwkNwc1jUyv5Z24h0862guJtd4l53M xrs0+QluQQtaKYSCff4Z4wjMnYQ1k+Em6K+OO9Yx1CDxgQUlrPkIf+44MtnWrOgDY0FY BnHEDFNi70Oh1Ig05b7A3LYsWYx2MDFWOg8TQVRvyPjSPBabbetD2J0TmcEFLJKPXZO3 2Eo88P3iFD8MxZnI7el4tM96cAyD4C+GkLER/QnVRNsbvRiFK6GoKis/HIf89+w9KVf4 6KOmZu9gWEaXyJovkmgYmvhorctZsgsZrwKQXqABH/c18seDirVf0NWBQJI/uU54WKzd tdLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=IaJ7+vsFyvrnLSPfue9ByLmu7bRRks/6xUYOpfJTdBM=; b=DIvPE10fwpziVwnZSMfDiZJStHgK0W/KbGraKtVgGDnIP5LpGz8Addyi/1BT5bukfo 3ferbLDq8Iz64J/v32bpWRr8TIbArMSfevvQ/R/4s/rcjm01fVSNePgnvRE3a57z8WRw cLJaktf9+/nOIwsvdJXNvmAw/X0gF5inTpvFBsHzNE2vqHrvGSAoadmsnhKJctF9KfKq uCTv52CFRSZFzFTILPuzIAZDJ40HlvlkpnN2kT5us87S9Mi9TrIyjTwdh3fcDQx/LSep ts/VGO1JzgyYajEa70zROeH7TvfIOUc7Vw1uS6t+OTmpM0+gd6Ck4b0m7YP3PSjV2SDx ZrZA== X-Gm-Message-State: AOAM533RV6pjYdhV9tepihjDcLqQwWHXw5+6a2jQWbLbqBwIn2nqCfwJ QQsqhTYOuTXBvyv9WUKD/mMR1GYCicMNInHmLt5n X-Google-Smtp-Source: ABdhPJxO04i6TgoP1lLH0ob3dEGaTPbQWTgn04wotZaWZPj/xXlqEtFTx9ZyI4mTjtBNs67uGrvrNjaLcprBSDWSWQLg X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a05:6214:c2:: with SMTP id f2mr14131052qvs.44.1600381357429; Thu, 17 Sep 2020 15:22:37 -0700 (PDT) Date: Thu, 17 Sep 2020 15:22:16 -0700 In-Reply-To: <20200917222217.2534502-1-danielwinkler@google.com> Message-Id: <20200917152052.v2.5.Ibedcb7af24f1c01a680de4cc8cc5a98951588393@changeid> Mime-Version: 1.0 References: <20200917222217.2534502-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v2 5/6] Bluetooth: Query LE tx power on startup From: Daniel Winkler <danielwinkler@google.com> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.49 / 15.00 / 15.00 X-Rspamd-Queue-Id: B92E3A017C X-Rspamd-UID: 95a624 Queries tx power via HCI_LE_Read_Transmit_Power command when the hci device is initialized, and stores resulting min/max LE power in hdev struct. If command isn't available (< BT5 support), min/max values both default to HCI_TX_POWER_INVALID. This patch is manually verified by ensuring BT5 devices correctly query and receive controller tx power range. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- Changes in v2: None include/net/bluetooth/hci.h | 7 +++++++ include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_core.c | 8 ++++++++ net/bluetooth/hci_event.c | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index c8e67042a3b14c..c1504aa3d9cfd5 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1797,6 +1797,13 @@ struct hci_cp_le_set_adv_set_rand_addr { bdaddr_t bdaddr; } __packed; +#define HCI_OP_LE_READ_TRANSMIT_POWER 0x204b +struct hci_rp_le_read_transmit_power { + __u8 status; + __s8 min_le_tx_power; + __s8 max_le_tx_power; +} __packed; + #define HCI_OP_LE_READ_BUFFER_SIZE_V2 0x2060 struct hci_rp_le_read_buffer_size_v2 { __u8 status; diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 667b9d37099dec..c1f5b5c4109215 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -381,6 +381,8 @@ struct hci_dev { __u16 def_page_timeout; __u16 def_multi_adv_rotation_duration; __u16 def_le_autoconnect_timeout; + __s8 min_le_tx_power; + __s8 max_le_tx_power; __u16 pkt_type; __u16 esco_type; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 3a2332f4a9bba2..6bff1c09be3b42 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -741,6 +741,12 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt) hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL); } + if (hdev->commands[38] & 0x80) { + /* Read LE Min/Max Tx Power*/ + hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER, + 0, NULL); + } + if (hdev->commands[26] & 0x40) { /* Read LE White List Size */ hci_req_add(req, HCI_OP_LE_READ_WHITE_LIST_SIZE, @@ -3654,6 +3660,8 @@ struct hci_dev *hci_alloc_dev(void) hdev->le_num_of_adv_sets = HCI_MAX_ADV_INSTANCES; hdev->def_multi_adv_rotation_duration = HCI_DEFAULT_ADV_DURATION; hdev->def_le_autoconnect_timeout = HCI_LE_AUTOCONN_TIMEOUT; + hdev->min_le_tx_power = HCI_TX_POWER_INVALID; + hdev->max_le_tx_power = HCI_TX_POWER_INVALID; hdev->rpa_timeout = HCI_DEFAULT_RPA_TIMEOUT; hdev->discov_interleaved_timeout = DISCOV_INTERLEAVED_TIMEOUT; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 9a24fd99d9e08e..beb35680f3a83a 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1202,6 +1202,20 @@ static void hci_cc_le_set_adv_set_random_addr(struct hci_dev *hdev, hci_dev_unlock(hdev); } +static void hci_cc_le_read_transmit_power(struct hci_dev *hdev, + struct sk_buff *skb) +{ + struct hci_rp_le_read_transmit_power *rp = (void *)skb->data; + + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); + + if (rp->status) + return; + + hdev->min_le_tx_power = rp->min_le_tx_power; + hdev->max_le_tx_power = rp->max_le_tx_power; +} + static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb) { __u8 *sent, status = *((__u8 *) skb->data); @@ -3577,6 +3591,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, hci_cc_le_set_adv_set_random_addr(hdev, skb); break; + case HCI_OP_LE_READ_TRANSMIT_POWER: + hci_cc_le_read_transmit_power(hdev, skb); + break; + default: BT_DBG("%s opcode 0x%4.4x", hdev->name, *opcode); break; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oDpfKu/hY19Z8QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 00:23:43 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id uC23Ju/hY18UuwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 00:23:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BA1E8A0B28; Fri, 18 Sep 2020 00:23:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726249AbgIQWWg (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 18:22:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726159AbgIQWWf (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 18:22:35 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81C3BC061351 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:34 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id p20so2490870qvl.4 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=dMyD2Sq7F10swrnGfqG2TqnY6qjzVockjWVRQt769BU=; b=tXtZCyyW4RmxcWXDwgK2JturgUPEP2sg2YD37dNcUDk9MRafzgwcTYVIthDnWkYdL4 FxydKrJEV2OwEEUfv9eyz1yIL6IOXsmwmI9Lq4q+4WULEkWWKlWx2HABl5q8H/Rr6+UH rOQxHMwgCEnvWjjvJOeXGpETCpfYI6alEEYAB644kYtbWJjJvmhAQnAcyv1aGyKqaGAW sdI+AQOdtNNiv+UuX4LG9fAWa+njCxcaC+6prrzj+2dKcrK0+foviWMUFua9x7FhFujX P2N8WPUQeESLu13e23QMT4PapcHzBQZh8LXB29j/R/ot7T0b7YFBjpuHsud12w7wLrBP 4gKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=dMyD2Sq7F10swrnGfqG2TqnY6qjzVockjWVRQt769BU=; b=UsXSjtGWTdThzbX5J4AtuAKAb4CIvbASWVz+n4+DqZHmPoxtxVmNpn2+eLnQX64w9C 8Pui6aK84l1CNFH+cHBNFW2QjM0DEKIRlztRfqzegHwBf0fEImtPpwx0ou+okz/q8ohB 6UZ3Ejd3IP/GxC+2pGesKsmmlj9aVJWGMOKSFwgty411jwkFURiCufbTDyOnU3cS4axl tYW9SAwhJfcIANERSlDPDlMTI2oCpqcvUhNgZytiNZPdIfYrfi0AYYkEk3sgbQcgKTz0 AggWg8szgqT1PeJ6u72MGIfzCjHInyuj4pCQyvEWBzB/z3OXtAATlNOlCNefek3/hEmH BobQ== X-Gm-Message-State: AOAM530682gXpndMCqiLjoISVsGoMjG0CylWTWy72czdFn1SFTvxwliQ KOIcAgvkA1PCq7kkyLhARt6olBhxvkiSg5aPb9iJ X-Google-Smtp-Source: ABdhPJyIIYKTZap24jyaJgIZ8SsfOiDvmAidjycRvZAzByqm9k4w9YhDtZ25N6w0M0ih558I5spEsqeOq3mCmKlGZZFd X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:ad4:518c:: with SMTP id b12mr14647203qvp.38.1600381353663; Thu, 17 Sep 2020 15:22:33 -0700 (PDT) Date: Thu, 17 Sep 2020 15:22:14 -0700 In-Reply-To: <20200917222217.2534502-1-danielwinkler@google.com> Message-Id: <20200917152052.v2.3.I74255537fa99ed3c0025321008b361c6ad90a431@changeid> Mime-Version: 1.0 References: <20200917222217.2534502-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v2 3/6] Bluetooth: Use intervals and tx power from mgmt cmds From: Daniel Winkler <danielwinkler@google.com> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.06 / 15.00 / 15.00 X-Rspamd-Queue-Id: BA1E8A0B28 X-Rspamd-UID: e84f1f This patch takes the min/max intervals and tx power optionally provided in mgmt interface, stores them in the advertisement struct, and uses them when configuring the hci requests. While tx power is not used if extended advertising is unavailable, software rotation will use the min and max advertising intervals specified by the client. This change is validated manually by ensuring the min/max intervals are propagated to the controller on both hatch (extended advertising) and kukui (no extended advertising) chromebooks, and that tx power is propagated correctly on hatch. These tests are performed with multiple advertisements simultaneously. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- Changes in v2: None include/net/bluetooth/hci_core.h | 5 ++++- net/bluetooth/hci_core.c | 8 +++++--- net/bluetooth/hci_request.c | 29 +++++++++++++++++++---------- net/bluetooth/mgmt.c | 8 ++++++-- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 48d144ae8b57d6..ab168f46b6d909 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -230,6 +230,8 @@ struct adv_info { __u16 scan_rsp_len; __u8 scan_rsp_data[HCI_MAX_AD_LENGTH]; __s8 tx_power; + __u32 min_interval; + __u32 max_interval; bdaddr_t random_addr; bool rpa_expired; struct delayed_work rpa_expired_cb; @@ -1292,7 +1294,8 @@ struct adv_info *hci_get_next_instance(struct hci_dev *hdev, u8 instance); int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, u16 adv_data_len, u8 *adv_data, u16 scan_rsp_len, u8 *scan_rsp_data, - u16 timeout, u16 duration); + u16 timeout, u16 duration, s8 tx_power, + u32 min_interval, u32 max_interval); int hci_set_adv_instance_data(struct hci_dev *hdev, u8 instance, u16 adv_data_len, u8 *adv_data, u16 scan_rsp_len, u8 *scan_rsp_data); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 3f73f147826409..3a2332f4a9bba2 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2951,7 +2951,8 @@ static void adv_instance_rpa_expired(struct work_struct *work) int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, u16 adv_data_len, u8 *adv_data, u16 scan_rsp_len, u8 *scan_rsp_data, - u16 timeout, u16 duration) + u16 timeout, u16 duration, s8 tx_power, + u32 min_interval, u32 max_interval) { struct adv_info *adv_instance; @@ -2979,6 +2980,9 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, adv_instance->flags = flags; adv_instance->adv_data_len = adv_data_len; adv_instance->scan_rsp_len = scan_rsp_len; + adv_instance->min_interval = min_interval; + adv_instance->max_interval = max_interval; + adv_instance->tx_power = tx_power; if (adv_data_len) memcpy(adv_instance->adv_data, adv_data, adv_data_len); @@ -2995,8 +2999,6 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, else adv_instance->duration = duration; - adv_instance->tx_power = HCI_TX_POWER_INVALID; - INIT_DELAYED_WORK(&adv_instance->rpa_expired_cb, adv_instance_rpa_expired); diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 413e3a5aabf544..bd984b32e07553 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1425,6 +1425,7 @@ static bool is_advertising_allowed(struct hci_dev *hdev, bool connectable) void __hci_req_enable_advertising(struct hci_request *req) { struct hci_dev *hdev = req->hdev; + struct adv_info *adv_instance; struct hci_cp_le_set_adv_param cp; u8 own_addr_type, enable = 0x01; bool connectable; @@ -1432,6 +1433,7 @@ void __hci_req_enable_advertising(struct hci_request *req) u32 flags; flags = get_adv_instance_flags(hdev, hdev->cur_adv_instance); + adv_instance = hci_find_adv_instance(hdev, hdev->cur_adv_instance); /* If the "connectable" instance flag was not set, then choose between * ADV_IND and ADV_NONCONN_IND based on the global connectable setting. @@ -1463,11 +1465,16 @@ void __hci_req_enable_advertising(struct hci_request *req) memset(&cp, 0, sizeof(cp)); - if (connectable) { - cp.type = LE_ADV_IND; - + if (adv_instance) { + adv_min_interval = adv_instance->min_interval; + adv_max_interval = adv_instance->max_interval; + } else { adv_min_interval = hdev->le_adv_min_interval; adv_max_interval = hdev->le_adv_max_interval; + } + + if (connectable) { + cp.type = LE_ADV_IND; } else { if (get_cur_adv_instance_scan_rsp_len(hdev)) cp.type = LE_ADV_SCAN_IND; @@ -1478,9 +1485,6 @@ void __hci_req_enable_advertising(struct hci_request *req) hci_dev_test_flag(hdev, HCI_LIMITED_DISCOVERABLE)) { adv_min_interval = DISCOV_LE_FAST_ADV_INT_MIN; adv_max_interval = DISCOV_LE_FAST_ADV_INT_MAX; - } else { - adv_min_interval = hdev->le_adv_min_interval; - adv_max_interval = hdev->le_adv_max_interval; } } @@ -1997,9 +2001,15 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance) memset(&cp, 0, sizeof(cp)); - /* In ext adv set param interval is 3 octets */ - hci_cpu_to_le24(hdev->le_adv_min_interval, cp.min_interval); - hci_cpu_to_le24(hdev->le_adv_max_interval, cp.max_interval); + if (adv_instance) { + hci_cpu_to_le24(adv_instance->min_interval, cp.min_interval); + hci_cpu_to_le24(adv_instance->max_interval, cp.max_interval); + cp.tx_power = adv_instance->tx_power; + } else { + hci_cpu_to_le24(hdev->le_adv_min_interval, cp.min_interval); + hci_cpu_to_le24(hdev->le_adv_max_interval, cp.max_interval); + cp.tx_power = HCI_ADV_TX_POWER_NO_PREFERENCE; + } secondary_adv = (flags & MGMT_ADV_FLAG_SEC_MASK); @@ -2022,7 +2032,6 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance) cp.own_addr_type = own_addr_type; cp.channel_map = hdev->le_adv_channel_map; - cp.tx_power = 127; cp.handle = instance; if (flags & MGMT_ADV_FLAG_SEC_2M) { diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 421b6784a114f9..717c97affb1554 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -7524,7 +7524,10 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, cp->adv_data_len, cp->data, cp->scan_rsp_len, cp->data + cp->adv_data_len, - timeout, duration); + timeout, duration, + HCI_ADV_TX_POWER_NO_PREFERENCE, + hdev->le_adv_min_interval, + hdev->le_adv_max_interval); if (err < 0) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, MGMT_STATUS_FAILED); @@ -7722,7 +7725,8 @@ static int add_ext_adv_params(struct sock *sk, struct hci_dev *hdev, /* Create advertising instance with no advertising or response data */ err = hci_add_adv_instance(hdev, cp->instance, flags, - 0, NULL, 0, NULL, timeout, duration); + 0, NULL, 0, NULL, timeout, duration, + tx_power, min_interval, max_interval); if (err < 0) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id COO0GfThY19Z8QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 00:23:48 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id eI1wFvThY1/FfgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 00:23:48 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CC966A0377; Fri, 18 Sep 2020 00:23:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726187AbgIQWWf (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 18:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbgIQWWb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 18:22:31 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A25CC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:30 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id q131so2813866qke.22 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=F5sPlGRRVLln1OHpY3xzu4VxzaSsS7i3+4mGVYVmXPs=; b=GsPrOGW9MIc4kbFKIpt6UVGvX76M+zC0Ujv+anlq/wR4MJT8KJe8SxxNHS9su1xxgB CUTNyENmzO9M6XR7jyLq/7rWAnxI1lM1zmb/qoqFyZH86kr1oUF7DbQzMpI1oIxC2+Rd Foa6Sx7xdfThDYP1ukwt/RrhOCnyZaba/0awAFw52C/5pwSVMrUkGljwbJvnEveVOJDT Q4kBks1NSjEs+dOFqobEXIpV8ye1V95BuAewNdVz2Aw3P7opWSYTjRcZYsIZ6fzf8U17 1ZBkYe8iUnhkO0leJnlwvtGvC9zlG1uKKKtRBAV7sDdQz7NEJMsKB91mzcOtwQ9+hXur sWHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=F5sPlGRRVLln1OHpY3xzu4VxzaSsS7i3+4mGVYVmXPs=; b=D3AEGdRk0JWo3Ovt1L3qd5C85vSQZyB1wmc0XRfh43y/7bQnqyhHEuGRuc8Qff0hyo EMxVovFF4JPM51GIRogVEpqO/dZNNqJ4zZSIvLD4p5hbbwkvDc+KZ94YjT8QCrJncunA PbCf89qzfaoNiW0+pMiHo/8pdhRnfdXZClGeRf3w8orVVNu7W/CE2A6NNudhJ4aafvzh OjaXfU+JKjFDjO3EVuW/gUltLWOkkddvHp16zPZ9RLcSIMXCB9Y8YQT1Sgcm5hTVe8Zu q2MhR0bskYEprUyMybc45XvJIqfrmx35QJeXbEbto+cZXEY4jqmejcEw1p7sXlBlEknG up4Q== X-Gm-Message-State: AOAM531dpM5oIUgPgmZrGy1lsNQyTToEiKtMcaimrzOxrWsireVH6zm6 o1V5YgW6tnm2cFwwv7KrLMieKONnC9N5Ul7lo8He X-Google-Smtp-Source: ABdhPJwT7E54N7UW/26IfDYWjmdUbQmZVOUAzWq+3GViiH9dggVfK7OCbfrcvwGYeT5J98WLBWcNE+LDRxGn5fFTzLHz X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:ad4:5565:: with SMTP id w5mr30020818qvy.24.1600381349707; Thu, 17 Sep 2020 15:22:29 -0700 (PDT) Date: Thu, 17 Sep 2020 15:22:12 -0700 In-Reply-To: <20200917222217.2534502-1-danielwinkler@google.com> Message-Id: <20200917152052.v2.1.I5f4fa6a76fe81f977f78f06b7e68ff1c76c6bddf@changeid> Mime-Version: 1.0 References: <20200917222217.2534502-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v2 1/6] Bluetooth: Add helper to set adv data From: Daniel Winkler <danielwinkler@google.com> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: CC966A0377 X-Rspamd-UID: 17b2f3 We wish to handle advertising data separately from advertising parameters in our new MGMT requests. This change adds a helper that allows the advertising data and scan response to be updated for an existing advertising instance. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- Changes in v2: None include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_core.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9873e1c8cd163b..300b3572d479e1 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1291,6 +1291,9 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, u16 adv_data_len, u8 *adv_data, u16 scan_rsp_len, u8 *scan_rsp_data, u16 timeout, u16 duration); +int hci_set_adv_instance_data(struct hci_dev *hdev, u8 instance, + u16 adv_data_len, u8 *adv_data, + u16 scan_rsp_len, u8 *scan_rsp_data); int hci_remove_adv_instance(struct hci_dev *hdev, u8 instance); void hci_adv_instances_set_rpa_expired(struct hci_dev *hdev, bool rpa_expired); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 8a2645a8330137..3f73f147826409 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3005,6 +3005,37 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, return 0; } +/* This function requires the caller holds hdev->lock */ +int hci_set_adv_instance_data(struct hci_dev *hdev, u8 instance, + u16 adv_data_len, u8 *adv_data, + u16 scan_rsp_len, u8 *scan_rsp_data) +{ + struct adv_info *adv_instance; + + adv_instance = hci_find_adv_instance(hdev, instance); + + /* If advertisement doesn't exist, we can't modify its data */ + if (!adv_instance) + return -ENOENT; + + if (adv_data_len) { + memset(adv_instance->adv_data, 0, + sizeof(adv_instance->adv_data)); + memcpy(adv_instance->adv_data, adv_data, adv_data_len); + adv_instance->adv_data_len = adv_data_len; + } + + if (scan_rsp_len) { + memset(adv_instance->scan_rsp_data, 0, + sizeof(adv_instance->scan_rsp_data)); + memcpy(adv_instance->scan_rsp_data, + scan_rsp_data, scan_rsp_len); + adv_instance->scan_rsp_len = scan_rsp_len; + } + + return 0; +} + /* This function requires the caller holds hdev->lock */ void hci_adv_monitors_clear(struct hci_dev *hdev) { -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uMP9K7EeZF+ZfQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 04:42:57 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qApRKbEeZF+vWQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 04:42:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E398AA0B22; Fri, 18 Sep 2020 04:42:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729512AbgIRCRI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:17:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:47396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729505AbgIRCRH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:17:07 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A271B235F7; Fri, 18 Sep 2020 02:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395426; bh=YamJ42CTzUXcA/68T8zl+RlfKuwzl6i79W3ajwGiu/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YhlujG3+NgMc7vMV6Io1WfzDetSz+cNRZODhJyLsHpU9fridSBEsi3BYl6rgMwoMj JWihU0+2N+QLwkRVvk3XNVEgGj/gqzvpWaXhNQyimJaHaFZw+oaQqRgJBAVqryNJlD CC2zDN78a/tFM+pOEiSlyd7FCuO+TkvDT24rPxFg= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Manish Mandlik <mmandlik@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 20/64] Bluetooth: Fix refcount use-after-free issue Date: Thu, 17 Sep 2020 22:15:59 -0400 Message-Id: <20200918021643.2067895-20-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021643.2067895-1-sashal@kernel.org> References: <20200918021643.2067895-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.00 / 15.00 / 15.00 X-Rspamd-Queue-Id: E398AA0B22 X-Rspamd-UID: f691cc From: Manish Mandlik <mmandlik@google.com> [ Upstream commit 6c08fc896b60893c5d673764b0668015d76df462 ] There is no lock preventing both l2cap_sock_release() and chan->ops->close() from running at the same time. If we consider Thread A running l2cap_chan_timeout() and Thread B running l2cap_sock_release(), expected behavior is: A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill() where, sock_orphan() clears "sk->sk_socket" and l2cap_sock_teardown_cb() marks socket as SOCK_ZAPPED. In l2cap_sock_kill(), there is an "if-statement" that checks if both sock_orphan() and sock_teardown() has been run i.e. sk->sk_socket is NULL and socket is marked as SOCK_ZAPPED. Socket is killed if the condition is satisfied. In the race condition, following occurs: A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill() In this scenario, "if-statement" is true in both B::l2cap_sock_kill() and A::l2cap_sock_kill() and we hit "refcount: underflow; use-after-free" bug. Similar condition occurs at other places where teardown/sock_kill is happening: l2cap_disconnect_rsp()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_rsp()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_conn_del()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_conn_del()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_disconnect_req()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_req()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_sock_cleanup_listen()->l2cap_chan_close()->l2cap_sock_teardown_cb() l2cap_sock_cleanup_listen()->l2cap_sock_kill() Protect teardown/sock_kill and orphan/sock_kill by adding hold_lock on l2cap channel to ensure that the socket is killed only after marked as zapped and orphan. Signed-off-by: Manish Mandlik <mmandlik@google.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_core.c | 26 +++++++++++++++----------- net/bluetooth/l2cap_sock.c | 16 +++++++++++++--- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 0e31bbe1256cd..f6112f495a36c 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -403,6 +403,9 @@ static void l2cap_chan_timeout(struct work_struct *work) BT_DBG("chan %p state %s", chan, state_to_string(chan->state)); mutex_lock(&conn->chan_lock); + /* __set_chan_timer() calls l2cap_chan_hold(chan) while scheduling + * this work. No need to call l2cap_chan_hold(chan) here again. + */ l2cap_chan_lock(chan); if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) @@ -415,12 +418,12 @@ static void l2cap_chan_timeout(struct work_struct *work) l2cap_chan_close(chan, reason); - l2cap_chan_unlock(chan); - chan->ops->close(chan); - mutex_unlock(&conn->chan_lock); + l2cap_chan_unlock(chan); l2cap_chan_put(chan); + + mutex_unlock(&conn->chan_lock); } struct l2cap_chan *l2cap_chan_create(void) @@ -1714,9 +1717,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) l2cap_chan_del(chan, err); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); } @@ -4316,6 +4319,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, return 0; } + l2cap_chan_hold(chan); l2cap_chan_lock(chan); rsp.dcid = cpu_to_le16(chan->scid); @@ -4324,12 +4328,11 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, chan->ops->set_shutdown(chan); - l2cap_chan_hold(chan); l2cap_chan_del(chan, ECONNRESET); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); @@ -4361,20 +4364,21 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, return 0; } + l2cap_chan_hold(chan); l2cap_chan_lock(chan); if (chan->state != BT_DISCONN) { l2cap_chan_unlock(chan); + l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); return 0; } - l2cap_chan_hold(chan); l2cap_chan_del(chan, 0); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index d9bbbded49ef8..cb024c25530a3 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1038,7 +1038,7 @@ done: } /* Kill socket (only if zapped and orphan) - * Must be called on unlocked socket. + * Must be called on unlocked socket, with l2cap channel lock. */ static void l2cap_sock_kill(struct sock *sk) { @@ -1199,8 +1199,15 @@ static int l2cap_sock_release(struct socket *sock) err = l2cap_sock_shutdown(sock, 2); + l2cap_chan_hold(l2cap_pi(sk)->chan); + l2cap_chan_lock(l2cap_pi(sk)->chan); + sock_orphan(sk); l2cap_sock_kill(sk); + + l2cap_chan_unlock(l2cap_pi(sk)->chan); + l2cap_chan_put(l2cap_pi(sk)->chan); + return err; } @@ -1218,12 +1225,15 @@ static void l2cap_sock_cleanup_listen(struct sock *parent) BT_DBG("child chan %p state %s", chan, state_to_string(chan->state)); + l2cap_chan_hold(chan); l2cap_chan_lock(chan); + __clear_chan_timer(chan); l2cap_chan_close(chan, ECONNRESET); - l2cap_chan_unlock(chan); - l2cap_sock_kill(sk); + + l2cap_chan_unlock(chan); + l2cap_chan_put(chan); } } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WIAhEMsfZF+ZfQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 04:47:39 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id UA/QDMsfZF9R5QEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 04:47:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A4AF6A0170; Fri, 18 Sep 2020 04:47:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729402AbgIRCTJ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:19:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:48672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729574AbgIRCRo (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:17:44 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D929D238E6; Fri, 18 Sep 2020 02:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395463; bh=+rbdhmB+nELvAR5PBIrLE6yII0u3D4M+5+DERJ6SAOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KtmSdU9WfWSiJ3Yju7JULeo4dub65+glvyI421+3nFYeryMHVoRFD4SBt8nkJW99Q tGKMMGrn29Iq2AODK35yTJMUkisHKMJZJLRta0yQmUfWMyyoCbzjZ9sm4dYgij0Kwu KtWNAwZKnTfrqrLSFnBIXV2Uz7vcFVEQ88CxLeDg= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 49/64] Bluetooth: Handle Inquiry Cancel error after Inquiry Complete Date: Thu, 17 Sep 2020 22:16:28 -0400 Message-Id: <20200918021643.2067895-49-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021643.2067895-1-sashal@kernel.org> References: <20200918021643.2067895-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: A4AF6A0170 X-Rspamd-UID: 1d323d From: Sonny Sasaka <sonnysasaka@chromium.org> [ Upstream commit adf1d6926444029396861413aba8a0f2a805742a ] After sending Inquiry Cancel command to the controller, it is possible that Inquiry Complete event comes before Inquiry Cancel command complete event. In this case the Inquiry Cancel command will have status of Command Disallowed since there is no Inquiry session to be cancelled. This case should not be treated as error, otherwise we can reach an inconsistent state. Example of a btmon trace when this happened: < HCI Command: Inquiry Cancel (0x01|0x0002) plen 0 > HCI Event: Inquiry Complete (0x01) plen 1 Status: Success (0x00) > HCI Event: Command Complete (0x0e) plen 4 Inquiry Cancel (0x01|0x0002) ncmd 1 Status: Command Disallowed (0x0c) Signed-off-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/hci_event.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 04c77747a768d..03319ab8a7c6e 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -41,12 +41,27 @@ /* Handle HCI Event packets */ -static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) +static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb, + u8 *new_status) { __u8 status = *((__u8 *) skb->data); BT_DBG("%s status 0x%2.2x", hdev->name, status); + /* It is possible that we receive Inquiry Complete event right + * before we receive Inquiry Cancel Command Complete event, in + * which case the latter event should have status of Command + * Disallowed (0x0c). This should not be treated as error, since + * we actually achieve what Inquiry Cancel wants to achieve, + * which is to end the last Inquiry session. + */ + if (status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { + bt_dev_warn(hdev, "Ignoring error of Inquiry Cancel command"); + status = 0x00; + } + + *new_status = status; + if (status) return; @@ -2758,7 +2773,7 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, switch (*opcode) { case HCI_OP_INQUIRY_CANCEL: - hci_cc_inquiry_cancel(hdev, skb); + hci_cc_inquiry_cancel(hdev, skb, status); break; case HCI_OP_PERIODIC_INQ: -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id EJm8HJYgZF/IbwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 04:51:02 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CAGwGZYgZF89IwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 04:51:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8850DA0B31; Fri, 18 Sep 2020 04:50:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727824AbgIRCVd (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:21:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:48032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728438AbgIRCRZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:17:25 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2001E2396F; Fri, 18 Sep 2020 02:17:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395443; bh=4VeEx4Bn4wUKIRHmnGHk6hZdQ1MlXkjkfxA8fr7dEWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ylj6Zck70uiGvUJhZ05vtNGbwHMzYN2u6mztzeWtpM7iyGQJnWxrdDqd04lmsJzhj xNwPaj1X2o+iB17zK2yaNtI37jcI85m6okLIDZM+UHRQ01rxuk9xd4sDKIS2VuA843 KJ7wh5dH2pdGrrht0XYPy5PAbt2cIIGUZYgVOpTw= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Howard Chung <howardchung@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 32/64] Bluetooth: L2CAP: handle l2cap config request during open state Date: Thu, 17 Sep 2020 22:16:11 -0400 Message-Id: <20200918021643.2067895-32-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021643.2067895-1-sashal@kernel.org> References: <20200918021643.2067895-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8850DA0B31 X-Rspamd-UID: 3dc997 From: Howard Chung <howardchung@google.com> [ Upstream commit 96298f640104e4cd9a913a6e50b0b981829b94ff ] According to Core Spec Version 5.2 | Vol 3, Part A 6.1.5, the incoming L2CAP_ConfigReq should be handled during OPEN state. The section below shows the btmon trace when running L2CAP/COS/CFD/BV-12-C before and after this change. === Before === ... > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22 L2CAP: Connection Request (0x02) ident 2 len 4 PSM: 1 (0x0001) Source CID: 65 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23 L2CAP: Connection Response (0x03) ident 2 len 8 Destination CID: 64 Source CID: 65 Result: Connection successful (0x0000) Status: No further information available (0x0000) < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24 L2CAP: Configure Request (0x04) ident 2 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #25 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #26 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27 L2CAP: Configure Request (0x04) ident 3 len 8 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 .. < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 > HCI Event: Number of Completed Packets (0x13) plen 5 #29 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30 L2CAP: Configure Response (0x05) ident 2 len 6 Source CID: 64 Flags: 0x0000 Result: Success (0x0000) > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31 L2CAP: Configure Request (0x04) ident 3 len 12 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 91 02 11 11 ...... < ACL Data TX: Handle 256 flags 0x00 dlen 14 #32 L2CAP: Command Reject (0x01) ident 3 len 6 Reason: Invalid CID in request (0x0002) Destination CID: 64 Source CID: 65 > HCI Event: Number of Completed Packets (0x13) plen 5 #33 Num handles: 1 Handle: 256 Count: 1 ... === After === ... > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22 L2CAP: Connection Request (0x02) ident 2 len 4 PSM: 1 (0x0001) Source CID: 65 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23 L2CAP: Connection Response (0x03) ident 2 len 8 Destination CID: 64 Source CID: 65 Result: Connection successful (0x0000) Status: No further information available (0x0000) < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24 L2CAP: Configure Request (0x04) ident 2 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #25 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #26 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27 L2CAP: Configure Request (0x04) ident 3 len 8 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 .. < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 > HCI Event: Number of Completed Packets (0x13) plen 5 #29 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30 L2CAP: Configure Response (0x05) ident 2 len 6 Source CID: 64 Flags: 0x0000 Result: Success (0x0000) > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31 L2CAP: Configure Request (0x04) ident 3 len 12 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 91 02 11 11 ..... < ACL Data TX: Handle 256 flags 0x00 dlen 18 #32 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 < ACL Data TX: Handle 256 flags 0x00 dlen 12 #33 L2CAP: Configure Request (0x04) ident 3 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #34 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #35 Num handles: 1 Handle: 256 Count: 1 ... Signed-off-by: Howard Chung <howardchung@google.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index f6112f495a36c..f2db50da8ce2e 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4096,7 +4096,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, return 0; } - if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) { + if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2 && + chan->state != BT_CONNECTED) { cmd_reject_invalid_cid(conn, cmd->ident, chan->scid, chan->dcid); goto unlock; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YBNWCfMgZF//jwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 04:52:35 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id mO8mBvMgZF9igQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 04:52:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9F4D8A01ED; Fri, 18 Sep 2020 04:52:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729480AbgIRCWI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:22:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:47604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728995AbgIRCRM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:17:12 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF39C239EB; Fri, 18 Sep 2020 02:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395431; bh=SQaBKSkiYQ6kVs5Ju1rSEjGVPCqXz8ymsFbpTrxbToQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ePcYt4ZAK77l13q3zaCeYJ/6LZj8v/ugf5EVKW+sfJuVEa+0u0Ph0s2K3Cb0IuYYE zlABXnvgQq4HfvP23stSpMBDar+vHWlu1hDtPfL9XonP6Cj8UCHXy4oC9RSFKHcmfg jPjD8TzJy3VCW/G8OATDHIHWnPCFaZUciMYIhblU= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hillf Danton <hdanton@sina.com>, syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com, Manish Mandlik <mmandlik@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 22/64] Bluetooth: prefetch channel before killing sock Date: Thu, 17 Sep 2020 22:16:01 -0400 Message-Id: <20200918021643.2067895-22-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021643.2067895-1-sashal@kernel.org> References: <20200918021643.2067895-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.37 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9F4D8A01ED X-Rspamd-UID: 39fdeb From: Hillf Danton <hdanton@sina.com> [ Upstream commit 2a154903cec20fb64ff4d7d617ca53c16f8fd53a ] Prefetch channel before killing sock in order to fix UAF like BUG: KASAN: use-after-free in l2cap_sock_release+0x24c/0x290 net/bluetooth/l2cap_sock.c:1212 Read of size 8 at addr ffff8880944904a0 by task syz-fuzzer/9751 Reported-by: syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com Fixes: 6c08fc896b60 ("Bluetooth: Fix refcount use-after-free issue") Cc: Manish Mandlik <mmandlik@google.com> Signed-off-by: Hillf Danton <hdanton@sina.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_sock.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index cb024c25530a3..e562385d9440e 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1189,6 +1189,7 @@ static int l2cap_sock_release(struct socket *sock) { struct sock *sk = sock->sk; int err; + struct l2cap_chan *chan; BT_DBG("sock %p, sk %p", sock, sk); @@ -1198,15 +1199,16 @@ static int l2cap_sock_release(struct socket *sock) bt_sock_unlink(&l2cap_sk_list, sk); err = l2cap_sock_shutdown(sock, 2); + chan = l2cap_pi(sk)->chan; - l2cap_chan_hold(l2cap_pi(sk)->chan); - l2cap_chan_lock(l2cap_pi(sk)->chan); + l2cap_chan_hold(chan); + l2cap_chan_lock(chan); sock_orphan(sk); l2cap_sock_kill(sk); - l2cap_chan_unlock(l2cap_pi(sk)->chan); - l2cap_chan_put(l2cap_pi(sk)->chan); + l2cap_chan_unlock(chan); + l2cap_chan_put(chan); return err; } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uOOUCwLiY18p+wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 00:24:02 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id SLLaBwLiY1+SqQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 00:24:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2270FA0211; Fri, 18 Sep 2020 00:23:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726118AbgIQWXJ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 18:23:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbgIQWWc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 18:22:32 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95EA0C06178A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:32 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id i17so2498969qvj.22 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=qmVI31s7JGcs0xm0JK7PZ+kNyyWgasrAkO5mRaYyM6U=; b=HZNRhTJZv/jejk4PaAKGQqpxb/7WwtPPj7nFRCO/EgkMUSvcorkDRKG0vfc7kFX2rU pi/kGAON9lX/F8GKJAFNYLEFU8/61P6FGNqTSDSz0F0TlaydSzMaokXAFlUCT0XWdTWk 5bW+buTEWYETPxICFfHw4fZEe6qMHXn/LUwYJWUDbhngUnYLKlkf+S5tBdiv2ZxDoJph J053YukBmehDqzObSy3m3cc72CsBDTB2Opn6aSn991xhzU7wT1m5fho0HQ+ggQ42VsFb y9DjNZ6mxpVDDiTZnypVV3U4XzZg0EhfDGVSVYe0IV/VZOR+t7RAjJx6ZvnMiBSw7nsn x4iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qmVI31s7JGcs0xm0JK7PZ+kNyyWgasrAkO5mRaYyM6U=; b=kcNZm+NCfIIGVgtfWO1SJfYpgROTXsHhA54HnscR3LqgWNvHR4vwFNo5bqGyq642hX ECNukymisovV3BwZhnZ2clnsr2Z/HZTCOTHaLXIX3SPzYHQszCkri6Va7NQdhSuIb86H xu6bGDgwSUAUcUhFP4OY+Ms+q1p/iP87QrvQad2dpxO1nRWROVZgHSzQYgCLByKbbbwN s0hLt0LCHVyU7VguATzvOj28KuYO0iWJFUzKdeauOuNFq1m/OkSYF7ULxA9y6vPYzz+4 XNvUhWXxfOZLaVW1d9SspQfFl3E/IWi2KCdGMQKUeBaEJAcjbf3G4ZpaQAzEnk9oC5rg S3ZQ== X-Gm-Message-State: AOAM5338hPgIMip5Y5tx0Bazd/XzpUK1cR9DaG9GDBFtca6OzbaLL3/e 9aARhb+1neFKp65o2xNJD7dIX788aYplR84YkBMN X-Google-Smtp-Source: ABdhPJzvyWEfuNROhUpN2sX7oWoMwlsuJHn28j/GXur6mFI03OMHo2lqp3d3jM4kKj0G4OPw+u8QUiEauYZxK+e7bz8+ X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:ad4:458f:: with SMTP id x15mr14656507qvu.33.1600381351718; Thu, 17 Sep 2020 15:22:31 -0700 (PDT) Date: Thu, 17 Sep 2020 15:22:13 -0700 In-Reply-To: <20200917222217.2534502-1-danielwinkler@google.com> Message-Id: <20200917152052.v2.2.Id8bee28ed00d158d0894b32c0cd94baa5a012605@changeid> Mime-Version: 1.0 References: <20200917222217.2534502-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v2 2/6] Bluetooth: Break add adv into two mgmt commands From: Daniel Winkler <danielwinkler@google.com> To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.07 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2270FA0211 X-Rspamd-UID: 99f5b7 This patch adds support for the new advertising add interface, with the first command setting advertising parameters and the second to set advertising data. The set parameters command allows the caller to leave some fields "unset", with a params bitfield defining which params were purposefully set. Unset parameters will be given defaults when calling hci_add_adv_instance. The data passed to the param mgmt command is allowed to be flexible, so in the future if bluetoothd passes a larger structure with new params, the mgmt command will ignore the unknown members at the end. This change has been validated on both hatch (extended advertising) and kukui (no extended advertising) chromebooks running bluetoothd that support this new interface. I ran the following manual tests: - Set several (3) advertisements using modified test_advertisement.py - For each, validate correct data and parameters in btmon trace - Verified both for software rotation and extended adv Automatic test suite also run, testing many (25) scenarios of single and multi-advertising for data/parameter correctness. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Daniel Winkler <danielwinkler@google.com> --- Changes in v2: None include/net/bluetooth/hci_core.h | 2 + include/net/bluetooth/mgmt.h | 33 +++ net/bluetooth/mgmt.c | 364 ++++++++++++++++++++++++++++++- 3 files changed, 388 insertions(+), 11 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 300b3572d479e1..48d144ae8b57d6 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -238,6 +238,8 @@ struct adv_info { #define HCI_MAX_ADV_INSTANCES 5 #define HCI_DEFAULT_ADV_DURATION 2 +#define HCI_ADV_TX_POWER_NO_PREFERENCE 0x7F + struct adv_pattern { struct list_head list; __u8 ad_type; diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 6b55155e05e977..859f0d3cd6ea38 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -782,6 +782,39 @@ struct mgmt_rp_remove_adv_monitor { __le16 monitor_handle; } __packed; +#define MGMT_ADV_PARAM_DURATION BIT(0) +#define MGMT_ADV_PARAM_TIMEOUT BIT(1) +#define MGMT_ADV_PARAM_INTERVALS BIT(2) +#define MGMT_ADV_PARAM_TX_POWER BIT(3) + +#define MGMT_OP_ADD_EXT_ADV_PARAMS 0x0054 +struct mgmt_cp_add_ext_adv_params { + __u8 instance; + __le32 flags; + __le16 params; + __le16 duration; + __le16 timeout; + __le32 min_interval; + __le32 max_interval; + __s8 tx_power; +} __packed; +#define MGMT_ADD_EXT_ADV_PARAMS_MIN_SIZE 20 +struct mgmt_rp_add_ext_adv_params { + __u8 instance; +} __packed; + +#define MGMT_OP_ADD_EXT_ADV_DATA 0x0055 +struct mgmt_cp_add_ext_adv_data { + __u8 instance; + __u8 adv_data_len; + __u8 scan_rsp_len; + __u8 data[]; +} __packed; +#define MGMT_ADD_EXT_ADV_DATA_SIZE 3 +struct mgmt_rp_add_ext_adv_data { + __u8 instance; +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { __le16 opcode; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 0b711ad80f6bd1..421b6784a114f9 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -122,6 +122,8 @@ static const u16 mgmt_commands[] = { MGMT_OP_READ_ADV_MONITOR_FEATURES, MGMT_OP_ADD_ADV_PATTERNS_MONITOR, MGMT_OP_REMOVE_ADV_MONITOR, + MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_OP_ADD_EXT_ADV_DATA, }; static const u16 mgmt_events[] = { @@ -7372,6 +7374,31 @@ static bool tlv_data_is_valid(struct hci_dev *hdev, u32 adv_flags, u8 *data, return true; } +static bool requested_adv_flags_are_valid(struct hci_dev *hdev, u32 adv_flags) +{ + u32 supported_flags, phy_flags; + + /* The current implementation only supports a subset of the specified + * flags. Also need to check mutual exclusiveness of sec flags. + */ + supported_flags = get_supported_adv_flags(hdev); + phy_flags = adv_flags & MGMT_ADV_FLAG_SEC_MASK; + if (adv_flags & ~supported_flags || + ((phy_flags && (phy_flags ^ (phy_flags & -phy_flags))))) + return false; + + return true; +} + +static bool adv_busy(struct hci_dev *hdev) +{ + return (pending_find(MGMT_OP_ADD_ADVERTISING, hdev) || + pending_find(MGMT_OP_REMOVE_ADVERTISING, hdev) || + pending_find(MGMT_OP_SET_LE, hdev) || + pending_find(MGMT_OP_ADD_EXT_ADV_PARAMS, hdev) || + pending_find(MGMT_OP_ADD_EXT_ADV_DATA, hdev)); +} + static void add_advertising_complete(struct hci_dev *hdev, u8 status, u16 opcode) { @@ -7386,6 +7413,8 @@ static void add_advertising_complete(struct hci_dev *hdev, u8 status, hci_dev_lock(hdev); cmd = pending_find(MGMT_OP_ADD_ADVERTISING, hdev); + if (!cmd) + cmd = pending_find(MGMT_OP_ADD_EXT_ADV_DATA, hdev); list_for_each_entry_safe(adv_instance, n, &hdev->adv_instances, list) { if (!adv_instance->pending) @@ -7430,7 +7459,6 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, struct mgmt_cp_add_advertising *cp = data; struct mgmt_rp_add_advertising rp; u32 flags; - u32 supported_flags, phy_flags; u8 status; u16 timeout, duration; unsigned int prev_instance_cnt = hdev->adv_instance_cnt; @@ -7466,13 +7494,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, timeout = __le16_to_cpu(cp->timeout); duration = __le16_to_cpu(cp->duration); - /* The current implementation only supports a subset of the specified - * flags. Also need to check mutual exclusiveness of sec flags. - */ - supported_flags = get_supported_adv_flags(hdev); - phy_flags = flags & MGMT_ADV_FLAG_SEC_MASK; - if (flags & ~supported_flags || - ((phy_flags && (phy_flags ^ (phy_flags & -phy_flags))))) + if (!requested_adv_flags_are_valid(hdev, flags)) return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, MGMT_STATUS_INVALID_PARAMS); @@ -7484,9 +7506,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, goto unlock; } - if (pending_find(MGMT_OP_ADD_ADVERTISING, hdev) || - pending_find(MGMT_OP_REMOVE_ADVERTISING, hdev) || - pending_find(MGMT_OP_SET_LE, hdev)) { + if (adv_busy(hdev)) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, MGMT_STATUS_BUSY); goto unlock; @@ -7577,6 +7597,324 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, return err; } +static void add_ext_adv_params_complete(struct hci_dev *hdev, u8 status, + u16 opcode) +{ + struct mgmt_pending_cmd *cmd; + struct mgmt_cp_add_ext_adv_params *cp; + struct mgmt_rp_add_ext_adv_params rp; + struct adv_info *adv_instance; + + BT_DBG("%s", hdev->name); + + hci_dev_lock(hdev); + + cmd = pending_find(MGMT_OP_ADD_EXT_ADV_PARAMS, hdev); + + if (!cmd) + goto unlock; + + cp = cmd->param; + rp.instance = cp->instance; + + if (status) { + adv_instance = hci_find_adv_instance(hdev, cp->instance); + + /* If this advertisement was previously advertising and we + * failed to update it, we signal that it has been removed and + * delete its structure + */ + if (!adv_instance->pending) + mgmt_advertising_removed(cmd->sk, hdev, cp->instance); + + hci_remove_adv_instance(hdev, cp->instance); + + mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, + mgmt_status(status)); + + } else { + mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, + mgmt_status(status), &rp, sizeof(rp)); + } + + mgmt_pending_remove(cmd); + +unlock: + hci_dev_unlock(hdev); +} + +static int add_ext_adv_params(struct sock *sk, struct hci_dev *hdev, + void *data, u16 data_len) +{ + struct mgmt_cp_add_ext_adv_params *cp = data; + struct mgmt_rp_add_ext_adv_params rp; + struct mgmt_pending_cmd *cmd = NULL; + struct adv_info *adv_instance; + struct hci_request req; + u32 flags, min_interval, max_interval; + u16 params, timeout, duration; + u8 status; + s8 tx_power; + int err; + + BT_DBG("%s", hdev->name); + + status = mgmt_le_support(hdev); + if (status) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + status); + + if (cp->instance < 1 || cp->instance > hdev->le_num_of_adv_sets) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_INVALID_PARAMS); + + /* The purpose of breaking add_advertising into two separate MGMT calls + * for params and data is to allow more parameters to be added to this + * structure in the future. For this reason, we verify that we have the + * bare minimum structure we know of when the interface was defined. Any + * extra parameters we don't know about will be ignored in this request. + */ + if (data_len < MGMT_ADD_EXT_ADV_PARAMS_MIN_SIZE) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, + MGMT_STATUS_INVALID_PARAMS); + + flags = __le32_to_cpu(cp->flags); + params = __le16_to_cpu(cp->params); + + if (!requested_adv_flags_are_valid(hdev, flags)) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_INVALID_PARAMS); + + hci_dev_lock(hdev); + + /* In new interface, we require that we are powered to register */ + if (!hdev_is_powered(hdev)) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_REJECTED); + goto unlock; + } + + if (adv_busy(hdev)) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_BUSY); + goto unlock; + } + + /* Parse defined parameters from request, use defaults otherwise */ + timeout = (params & MGMT_ADV_PARAM_TIMEOUT) ? + __le16_to_cpu(cp->timeout) : 0; + + duration = (params & MGMT_ADV_PARAM_DURATION) ? + __le16_to_cpu(cp->duration) : + hdev->def_multi_adv_rotation_duration; + + min_interval = (params & MGMT_ADV_PARAM_INTERVALS) ? + __le32_to_cpu(cp->min_interval) : + hdev->le_adv_min_interval; + + max_interval = (params & MGMT_ADV_PARAM_INTERVALS) ? + __le32_to_cpu(cp->max_interval) : + hdev->le_adv_max_interval; + + tx_power = (params & MGMT_ADV_PARAM_INTERVALS) ? + cp->tx_power : + HCI_ADV_TX_POWER_NO_PREFERENCE; + + /* Create advertising instance with no advertising or response data */ + err = hci_add_adv_instance(hdev, cp->instance, flags, + 0, NULL, 0, NULL, timeout, duration); + + if (err < 0) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_FAILED); + goto unlock; + } + + hdev->cur_adv_instance = cp->instance; + /* Submit request for advertising params if ext adv available */ + if (ext_adv_capable(hdev)) { + hci_req_init(&req, hdev); + adv_instance = hci_find_adv_instance(hdev, cp->instance); + + /* Updating parameters of an active instance will return a + * Command Disallowed error, so we must first disable the + * instance if it is active. + */ + if (!adv_instance->pending) + __hci_req_disable_ext_adv_instance(&req, cp->instance); + + __hci_req_setup_ext_adv_instance(&req, cp->instance); + + err = hci_req_run(&req, add_ext_adv_params_complete); + + if (!err) + cmd = mgmt_pending_add(sk, MGMT_OP_ADD_EXT_ADV_PARAMS, + hdev, data, data_len); + if (!cmd) { + err = -ENOMEM; + hci_remove_adv_instance(hdev, cp->instance); + goto unlock; + } + + } else { + rp.instance = cp->instance; + err = mgmt_cmd_complete(sk, hdev->id, + MGMT_OP_ADD_EXT_ADV_PARAMS, + MGMT_STATUS_SUCCESS, &rp, sizeof(rp)); + } + +unlock: + hci_dev_unlock(hdev); + + return err; +} + +static int add_ext_adv_data(struct sock *sk, struct hci_dev *hdev, void *data, + u16 data_len) +{ + struct mgmt_cp_add_ext_adv_data *cp = data; + struct mgmt_rp_add_ext_adv_data rp; + u8 schedule_instance = 0; + struct adv_info *next_instance; + struct adv_info *adv_instance; + int err = 0; + struct mgmt_pending_cmd *cmd; + struct hci_request req; + + BT_DBG("%s", hdev->name); + + hci_dev_lock(hdev); + + adv_instance = hci_find_adv_instance(hdev, cp->instance); + + if (!adv_instance) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_INVALID_PARAMS); + goto unlock; + } + + /* In new interface, we require that we are powered to register */ + if (!hdev_is_powered(hdev)) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_REJECTED); + goto clear_new_instance; + } + + if (adv_busy(hdev)) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_BUSY); + goto clear_new_instance; + } + + /* Validate new data */ + if (!tlv_data_is_valid(hdev, adv_instance->flags, cp->data, + cp->adv_data_len, true) || + !tlv_data_is_valid(hdev, adv_instance->flags, cp->data + + cp->adv_data_len, cp->scan_rsp_len, false)) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_INVALID_PARAMS); + goto clear_new_instance; + } + + /* Set the data in the advertising instance */ + hci_set_adv_instance_data(hdev, cp->instance, cp->adv_data_len, + cp->data, cp->scan_rsp_len, + cp->data + cp->adv_data_len); + + /* We're good to go, update advertising data, parameters, and start + * advertising. + */ + + hci_req_init(&req, hdev); + + hci_req_add(&req, HCI_OP_READ_LOCAL_NAME, 0, NULL); + + if (ext_adv_capable(hdev)) { + __hci_req_update_adv_data(&req, cp->instance); + __hci_req_update_scan_rsp_data(&req, cp->instance); + __hci_req_enable_ext_advertising(&req, cp->instance); + + } else { + /* If using software rotation, determine next instance to use */ + + if (hdev->cur_adv_instance == cp->instance) { + /* If the currently advertised instance is being changed + * then cancel the current advertising and schedule the + * next instance. If there is only one instance then the + * overridden advertising data will be visible right + * away + */ + cancel_adv_timeout(hdev); + + next_instance = hci_get_next_instance(hdev, + cp->instance); + if (next_instance) + schedule_instance = next_instance->instance; + } else if (!hdev->adv_instance_timeout) { + /* Immediately advertise the new instance if no other + * instance is currently being advertised. + */ + schedule_instance = cp->instance; + } + + /* If the HCI_ADVERTISING flag is set or there is no instance to + * be advertised then we have no HCI communication to make. + * Simply return. + */ + if (hci_dev_test_flag(hdev, HCI_ADVERTISING) || + !schedule_instance) { + if (adv_instance->pending) { + mgmt_advertising_added(sk, hdev, cp->instance); + adv_instance->pending = false; + } + rp.instance = cp->instance; + err = mgmt_cmd_complete(sk, hdev->id, + MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_SUCCESS, &rp, + sizeof(rp)); + goto unlock; + } + + err = __hci_req_schedule_adv_instance(&req, schedule_instance, + true); + } + + cmd = mgmt_pending_add(sk, MGMT_OP_ADD_EXT_ADV_DATA, hdev, data, + data_len); + if (!cmd) { + err = -ENOMEM; + goto clear_new_instance; + } + + if (!err) + err = hci_req_run(&req, add_advertising_complete); + + if (err < 0) { + err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, + MGMT_STATUS_FAILED); + mgmt_pending_remove(cmd); + goto clear_new_instance; + } + + /* We were successful in updating data, so trigger advertising_added + * event if this is an instance that wasn't previously advertising. If + * a failure occurs in the requests we initiated, we will remove the + * instance again in add_advertising_complete + */ + if (adv_instance->pending) + mgmt_advertising_added(sk, hdev, cp->instance); + + goto unlock; + +clear_new_instance: + hci_remove_adv_instance(hdev, cp->instance); + +unlock: + hci_dev_unlock(hdev); + + return err; +} + static void remove_advertising_complete(struct hci_dev *hdev, u8 status, u16 opcode) { @@ -7851,6 +8189,10 @@ static const struct hci_mgmt_handler mgmt_handlers[] = { { add_adv_patterns_monitor,MGMT_ADD_ADV_PATTERNS_MONITOR_SIZE, HCI_MGMT_VAR_LEN }, { remove_adv_monitor, MGMT_REMOVE_ADV_MONITOR_SIZE }, + { add_ext_adv_params, MGMT_ADD_EXT_ADV_PARAMS_MIN_SIZE, + HCI_MGMT_VAR_LEN }, + { add_ext_adv_data, MGMT_ADD_EXT_ADV_DATA_SIZE, + HCI_MGMT_VAR_LEN }, }; void mgmt_index_added(struct hci_dev *hdev) -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qBoeOP0gZF/IbwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 04:52:45 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 8L/ONf0gZF+vWQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 04:52:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9D646A0B50; Fri, 18 Sep 2020 04:52:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726818AbgIRCWI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:22:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:48018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727937AbgIRCRY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:17:24 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C69F823998; Fri, 18 Sep 2020 02:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395441; bh=Hco7q7e69Yo5LGxGMrHGpP4cBxSJ2N88PDO+7MEVdSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jLJsKRXkggbX/ZIiyujwrA1HhTu8wdqW1P8F/kv0imK/TVQfOkv8DY/YyuDYpdO9S oxK4weFQkka4FKGs++UsIUQW7G0yx9gtAj3V5f1VOJNtFfsJ6gNmlqASrlFtKMomcU 7Oo3MVja60txF5eOCx6lLz5HSZkAZk8Q4H19tExQ= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alain Michaud <alainm@chromium.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 30/64] Bluetooth: guard against controllers sending zero'd events Date: Thu, 17 Sep 2020 22:16:09 -0400 Message-Id: <20200918021643.2067895-30-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021643.2067895-1-sashal@kernel.org> References: <20200918021643.2067895-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.97 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9D646A0B50 X-Rspamd-UID: 235f53 From: Alain Michaud <alainm@chromium.org> [ Upstream commit 08bb4da90150e2a225f35e0f642cdc463958d696 ] Some controllers have been observed to send zero'd events under some conditions. This change guards against this condition as well as adding a trace to facilitate diagnosability of this condition. Signed-off-by: Alain Michaud <alainm@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/hci_event.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 16cf5633eae3e..04c77747a768d 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5230,6 +5230,11 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) u8 status = 0, event = hdr->evt, req_evt = 0; u16 opcode = HCI_OP_NOP; + if (!event) { + bt_dev_warn(hdev, "Received unexpected HCI Event 00000000"); + goto done; + } + if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) { struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; opcode = __le16_to_cpu(cmd_hdr->opcode); @@ -5441,6 +5446,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) req_complete_skb(hdev, status, opcode, orig_skb); } +done: kfree_skb(orig_skb); kfree_skb(skb); hdev->stat.evt_rx++; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qK/OGqAiZF//jwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 04:59:44 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id oA/tF6AiZF9/TQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 04:59:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 84194A0AAE; Fri, 18 Sep 2020 04:59:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729379AbgIRCZG (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:25:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:45950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729369AbgIRCQU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:16:20 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 30C55238A0; Fri, 18 Sep 2020 02:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395379; bh=I9bS6SkRc7TyTmXyDzVNh/4sq7YSRbmQQLhzA2EijBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s5TB9exWnCPGQMVCGVHzqXE07PfxmJ8T9lFX429uKoP9A/JMf6raffK0zQjSWERHk iLfBqgYHFpnbyISw+mgrqbzaef7J2/P6AGIM1J6Wsejv6C2PPD83xZrIQl7/HhmAmt pk0D6QD3gaxthtW5Iq2pbrHD56dVjawA6cmwiG2M= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 71/90] Bluetooth: Handle Inquiry Cancel error after Inquiry Complete Date: Thu, 17 Sep 2020 22:14:36 -0400 Message-Id: <20200918021455.2067301-71-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021455.2067301-1-sashal@kernel.org> References: <20200918021455.2067301-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: 84194A0AAE X-Rspamd-UID: 7f01c3 From: Sonny Sasaka <sonnysasaka@chromium.org> [ Upstream commit adf1d6926444029396861413aba8a0f2a805742a ] After sending Inquiry Cancel command to the controller, it is possible that Inquiry Complete event comes before Inquiry Cancel command complete event. In this case the Inquiry Cancel command will have status of Command Disallowed since there is no Inquiry session to be cancelled. This case should not be treated as error, otherwise we can reach an inconsistent state. Example of a btmon trace when this happened: < HCI Command: Inquiry Cancel (0x01|0x0002) plen 0 > HCI Event: Inquiry Complete (0x01) plen 1 Status: Success (0x00) > HCI Event: Command Complete (0x0e) plen 4 Inquiry Cancel (0x01|0x0002) ncmd 1 Status: Command Disallowed (0x0c) Signed-off-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/hci_event.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 700a2eb161490..d6da119f5082e 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -41,12 +41,27 @@ /* Handle HCI Event packets */ -static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) +static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb, + u8 *new_status) { __u8 status = *((__u8 *) skb->data); BT_DBG("%s status 0x%2.2x", hdev->name, status); + /* It is possible that we receive Inquiry Complete event right + * before we receive Inquiry Cancel Command Complete event, in + * which case the latter event should have status of Command + * Disallowed (0x0c). This should not be treated as error, since + * we actually achieve what Inquiry Cancel wants to achieve, + * which is to end the last Inquiry session. + */ + if (status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { + bt_dev_warn(hdev, "Ignoring error of Inquiry Cancel command"); + status = 0x00; + } + + *new_status = status; + if (status) return; @@ -2772,7 +2787,7 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, switch (*opcode) { case HCI_OP_INQUIRY_CANCEL: - hci_cc_inquiry_cancel(hdev, skb); + hci_cc_inquiry_cancel(hdev, skb, status); break; case HCI_OP_PERIODIC_INQ: -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4EIBIm4jZF+YlgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:03:10 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id OJZdH24jZF+vWQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:03:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0388FA0B72; Fri, 18 Sep 2020 05:03:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729377AbgIRC0f (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:26:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:45112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729315AbgIRCQA (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:16:00 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED28B23787; Fri, 18 Sep 2020 02:15:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395353; bh=8kEAr+5ZaO6EHRIDN4ojcnL1eM+CwkacAoRryw7srp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K/JVOjSTzaT7Fdfz9/RxtgWLj8uDDZJOiMn2x+ecVLTJJELI1kzRnslHebV0GMv7K akkanD30yzJaywkFfOVaagIEFfAnNn2YWnKxw4vv6q5VU+hyeDsXLAMd6tK9NIaqwy 70ZZskbfySExhPZfw7qRCx+KKfQ7qJiWyyu9zRgM= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Howard Chung <howardchung@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 48/90] Bluetooth: L2CAP: handle l2cap config request during open state Date: Thu, 17 Sep 2020 22:14:13 -0400 Message-Id: <20200918021455.2067301-48-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021455.2067301-1-sashal@kernel.org> References: <20200918021455.2067301-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0388FA0B72 X-Rspamd-UID: 0b7716 From: Howard Chung <howardchung@google.com> [ Upstream commit 96298f640104e4cd9a913a6e50b0b981829b94ff ] According to Core Spec Version 5.2 | Vol 3, Part A 6.1.5, the incoming L2CAP_ConfigReq should be handled during OPEN state. The section below shows the btmon trace when running L2CAP/COS/CFD/BV-12-C before and after this change. === Before === ... > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22 L2CAP: Connection Request (0x02) ident 2 len 4 PSM: 1 (0x0001) Source CID: 65 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23 L2CAP: Connection Response (0x03) ident 2 len 8 Destination CID: 64 Source CID: 65 Result: Connection successful (0x0000) Status: No further information available (0x0000) < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24 L2CAP: Configure Request (0x04) ident 2 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #25 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #26 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27 L2CAP: Configure Request (0x04) ident 3 len 8 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 .. < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 > HCI Event: Number of Completed Packets (0x13) plen 5 #29 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30 L2CAP: Configure Response (0x05) ident 2 len 6 Source CID: 64 Flags: 0x0000 Result: Success (0x0000) > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31 L2CAP: Configure Request (0x04) ident 3 len 12 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 91 02 11 11 ...... < ACL Data TX: Handle 256 flags 0x00 dlen 14 #32 L2CAP: Command Reject (0x01) ident 3 len 6 Reason: Invalid CID in request (0x0002) Destination CID: 64 Source CID: 65 > HCI Event: Number of Completed Packets (0x13) plen 5 #33 Num handles: 1 Handle: 256 Count: 1 ... === After === ... > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22 L2CAP: Connection Request (0x02) ident 2 len 4 PSM: 1 (0x0001) Source CID: 65 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23 L2CAP: Connection Response (0x03) ident 2 len 8 Destination CID: 64 Source CID: 65 Result: Connection successful (0x0000) Status: No further information available (0x0000) < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24 L2CAP: Configure Request (0x04) ident 2 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #25 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #26 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27 L2CAP: Configure Request (0x04) ident 3 len 8 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 .. < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 > HCI Event: Number of Completed Packets (0x13) plen 5 #29 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30 L2CAP: Configure Response (0x05) ident 2 len 6 Source CID: 64 Flags: 0x0000 Result: Success (0x0000) > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31 L2CAP: Configure Request (0x04) ident 3 len 12 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 91 02 11 11 ..... < ACL Data TX: Handle 256 flags 0x00 dlen 18 #32 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 < ACL Data TX: Handle 256 flags 0x00 dlen 12 #33 L2CAP: Configure Request (0x04) ident 3 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #34 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #35 Num handles: 1 Handle: 256 Count: 1 ... Signed-off-by: Howard Chung <howardchung@google.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index de085947c19c2..5e3f5c1ba07d6 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4107,7 +4107,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, return 0; } - if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) { + if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2 && + chan->state != BT_CONNECTED) { cmd_reject_invalid_cid(conn, cmd->ident, chan->scid, chan->dcid); goto unlock; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6MJeLZwjZF//jwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:03:56 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id iMD2KZwjZF8YOAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:03:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6DD75A0B42; Fri, 18 Sep 2020 05:03:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728099AbgIRC04 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:26:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:45048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728996AbgIRCPv (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:15:51 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B27F3208DB; Fri, 18 Sep 2020 02:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395350; bh=8fLqQstoxhvoJyOdx8AsvgndDZfHBBtIglmws+g17sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SVm+rupZe4QonoSGmy/svpUxWWxNVSsuJ0nLOWBYXzkoj92CGQhKUCtByPqj9+15f LsQgRbZFcVUqeNgaUmZQxwF6nAOoYK2EDvAkMrIqARPYBsnGWJLXkWbg+jckFx3gs4 ZA6he91Mxlnp26IGjXMM7ZZ8p+ERsJ0IGDuo5j7k= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alain Michaud <alainm@chromium.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 45/90] Bluetooth: guard against controllers sending zero'd events Date: Thu, 17 Sep 2020 22:14:10 -0400 Message-Id: <20200918021455.2067301-45-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021455.2067301-1-sashal@kernel.org> References: <20200918021455.2067301-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.97 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6DD75A0B42 X-Rspamd-UID: 62d6ca From: Alain Michaud <alainm@chromium.org> [ Upstream commit 08bb4da90150e2a225f35e0f642cdc463958d696 ] Some controllers have been observed to send zero'd events under some conditions. This change guards against this condition as well as adding a trace to facilitate diagnosability of this condition. Signed-off-by: Alain Michaud <alainm@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/hci_event.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 757977c54d9ef..700a2eb161490 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5257,6 +5257,11 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) u8 status = 0, event = hdr->evt, req_evt = 0; u16 opcode = HCI_OP_NOP; + if (!event) { + bt_dev_warn(hdev, "Received unexpected HCI Event 00000000"); + goto done; + } + if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) { struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; opcode = __le16_to_cpu(cmd_hdr->opcode); @@ -5468,6 +5473,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) req_complete_skb(hdev, status, opcode, orig_skb); } +done: kfree_skb(orig_skb); kfree_skb(skb); hdev->stat.evt_rx++; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8O8rOmEkZF/IbwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:07:13 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id oP8FN2EkZF9qMQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:07:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id F24B9A0AAE; Fri, 18 Sep 2020 05:07:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728403AbgIRC2F (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:28:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:44332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728684AbgIRCP2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:15:28 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F10AB235F7; Fri, 18 Sep 2020 02:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395327; bh=M1/GztjogkDW1sQaySry20+xtBUmFDGE9cLdO4u6RNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IE3QN8pX3BIMXsME1BdpLFU+Vi3pVBK5xK5ZPWQcChLE3HyrQL3SSamQAjO+A5dbO 3Ipe14jkys1pi/5hHKj07VFuM/COH2to2cunbhuORJWSu8BTvEuIus4XAMz7AeZsO2 6dL0hmFW8V7cwox8lhW9Y/xXhAzFatdc9Pn5Ol2A= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Manish Mandlik <mmandlik@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 28/90] Bluetooth: Fix refcount use-after-free issue Date: Thu, 17 Sep 2020 22:13:53 -0400 Message-Id: <20200918021455.2067301-28-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021455.2067301-1-sashal@kernel.org> References: <20200918021455.2067301-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.99 / 15.00 / 15.00 X-Rspamd-Queue-Id: F24B9A0AAE X-Rspamd-UID: abbf5f From: Manish Mandlik <mmandlik@google.com> [ Upstream commit 6c08fc896b60893c5d673764b0668015d76df462 ] There is no lock preventing both l2cap_sock_release() and chan->ops->close() from running at the same time. If we consider Thread A running l2cap_chan_timeout() and Thread B running l2cap_sock_release(), expected behavior is: A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill() where, sock_orphan() clears "sk->sk_socket" and l2cap_sock_teardown_cb() marks socket as SOCK_ZAPPED. In l2cap_sock_kill(), there is an "if-statement" that checks if both sock_orphan() and sock_teardown() has been run i.e. sk->sk_socket is NULL and socket is marked as SOCK_ZAPPED. Socket is killed if the condition is satisfied. In the race condition, following occurs: A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill() In this scenario, "if-statement" is true in both B::l2cap_sock_kill() and A::l2cap_sock_kill() and we hit "refcount: underflow; use-after-free" bug. Similar condition occurs at other places where teardown/sock_kill is happening: l2cap_disconnect_rsp()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_rsp()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_conn_del()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_conn_del()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_disconnect_req()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_req()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_sock_cleanup_listen()->l2cap_chan_close()->l2cap_sock_teardown_cb() l2cap_sock_cleanup_listen()->l2cap_sock_kill() Protect teardown/sock_kill and orphan/sock_kill by adding hold_lock on l2cap channel to ensure that the socket is killed only after marked as zapped and orphan. Signed-off-by: Manish Mandlik <mmandlik@google.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_core.c | 26 +++++++++++++++----------- net/bluetooth/l2cap_sock.c | 16 +++++++++++++--- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 11012a5090708..de085947c19c2 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -414,6 +414,9 @@ static void l2cap_chan_timeout(struct work_struct *work) BT_DBG("chan %p state %s", chan, state_to_string(chan->state)); mutex_lock(&conn->chan_lock); + /* __set_chan_timer() calls l2cap_chan_hold(chan) while scheduling + * this work. No need to call l2cap_chan_hold(chan) here again. + */ l2cap_chan_lock(chan); if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) @@ -426,12 +429,12 @@ static void l2cap_chan_timeout(struct work_struct *work) l2cap_chan_close(chan, reason); - l2cap_chan_unlock(chan); - chan->ops->close(chan); - mutex_unlock(&conn->chan_lock); + l2cap_chan_unlock(chan); l2cap_chan_put(chan); + + mutex_unlock(&conn->chan_lock); } struct l2cap_chan *l2cap_chan_create(void) @@ -1725,9 +1728,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) l2cap_chan_del(chan, err); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); } @@ -4327,6 +4330,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, return 0; } + l2cap_chan_hold(chan); l2cap_chan_lock(chan); rsp.dcid = cpu_to_le16(chan->scid); @@ -4335,12 +4339,11 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, chan->ops->set_shutdown(chan); - l2cap_chan_hold(chan); l2cap_chan_del(chan, ECONNRESET); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); @@ -4372,20 +4375,21 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, return 0; } + l2cap_chan_hold(chan); l2cap_chan_lock(chan); if (chan->state != BT_DISCONN) { l2cap_chan_unlock(chan); + l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); return 0; } - l2cap_chan_hold(chan); l2cap_chan_del(chan, 0); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index a8ba752732c98..3db8cfebd069a 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1038,7 +1038,7 @@ done: } /* Kill socket (only if zapped and orphan) - * Must be called on unlocked socket. + * Must be called on unlocked socket, with l2cap channel lock. */ static void l2cap_sock_kill(struct sock *sk) { @@ -1199,8 +1199,15 @@ static int l2cap_sock_release(struct socket *sock) err = l2cap_sock_shutdown(sock, 2); + l2cap_chan_hold(l2cap_pi(sk)->chan); + l2cap_chan_lock(l2cap_pi(sk)->chan); + sock_orphan(sk); l2cap_sock_kill(sk); + + l2cap_chan_unlock(l2cap_pi(sk)->chan); + l2cap_chan_put(l2cap_pi(sk)->chan); + return err; } @@ -1218,12 +1225,15 @@ static void l2cap_sock_cleanup_listen(struct sock *parent) BT_DBG("child chan %p state %s", chan, state_to_string(chan->state)); + l2cap_chan_hold(chan); l2cap_chan_lock(chan); + __clear_chan_timer(chan); l2cap_chan_close(chan, ECONNRESET); - l2cap_chan_unlock(chan); - l2cap_sock_kill(sk); + + l2cap_chan_unlock(chan); + l2cap_chan_put(chan); } } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8Ka+J4gmZF8SngAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:16:24 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id eFXMJIgmZF+pkAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:16:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 1E347A015F; Fri, 18 Sep 2020 05:16:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728731AbgIRCbp (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:31:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:42244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729065AbgIRCOS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:14:18 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 88B0123977; Fri, 18 Sep 2020 02:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395257; bh=u9c61BB/SYikuE4euw2IsfCpiyy5RJgPbFEEYfWkLUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uWrnov7xDUoGXQNUwUFu+SpWMswA/njfZuMsBLu0x2vQj0yc9ljzDUgjN8gUuMXeQ 7KWaZpBFj0rmIOfN370hrh0SZ2c7B8uKUO6hgII3aBYyIFXGS2SlcYqWf24OZhj5Yv VGsriQ81fD6bg9VR+HjL5i8xI31J9Hj2OD2Glm6k= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 098/127] Bluetooth: Handle Inquiry Cancel error after Inquiry Complete Date: Thu, 17 Sep 2020 22:11:51 -0400 Message-Id: <20200918021220.2066485-98-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021220.2066485-1-sashal@kernel.org> References: <20200918021220.2066485-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1E347A015F X-Rspamd-UID: 52d864 From: Sonny Sasaka <sonnysasaka@chromium.org> [ Upstream commit adf1d6926444029396861413aba8a0f2a805742a ] After sending Inquiry Cancel command to the controller, it is possible that Inquiry Complete event comes before Inquiry Cancel command complete event. In this case the Inquiry Cancel command will have status of Command Disallowed since there is no Inquiry session to be cancelled. This case should not be treated as error, otherwise we can reach an inconsistent state. Example of a btmon trace when this happened: < HCI Command: Inquiry Cancel (0x01|0x0002) plen 0 > HCI Event: Inquiry Complete (0x01) plen 1 Status: Success (0x00) > HCI Event: Command Complete (0x0e) plen 4 Inquiry Cancel (0x01|0x0002) ncmd 1 Status: Command Disallowed (0x0c) Signed-off-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/hci_event.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 1d2f439043669..587b674bbcd64 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -41,12 +41,27 @@ /* Handle HCI Event packets */ -static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) +static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb, + u8 *new_status) { __u8 status = *((__u8 *) skb->data); BT_DBG("%s status 0x%2.2x", hdev->name, status); + /* It is possible that we receive Inquiry Complete event right + * before we receive Inquiry Cancel Command Complete event, in + * which case the latter event should have status of Command + * Disallowed (0x0c). This should not be treated as error, since + * we actually achieve what Inquiry Cancel wants to achieve, + * which is to end the last Inquiry session. + */ + if (status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { + bt_dev_warn(hdev, "Ignoring error of Inquiry Cancel command"); + status = 0x00; + } + + *new_status = status; + if (status) return; @@ -2772,7 +2787,7 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, switch (*opcode) { case HCI_OP_INQUIRY_CANCEL: - hci_cc_inquiry_cancel(hdev, skb); + hci_cc_inquiry_cancel(hdev, skb, status); break; case HCI_OP_PERIODIC_INQ: -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WIEGETwoZF/IbwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:23:40 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id IJUyDjwoZF/RmwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:23:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 458CEA01ED; Fri, 18 Sep 2020 05:23:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728940AbgIRCeq (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:34:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:40742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728930AbgIRCN2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:13:28 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E2816208DB; Fri, 18 Sep 2020 02:13:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395207; bh=lFCzPiwrwZi+2I/qPpv079tYMk9JTossO09i+z/sBqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TqKu+4nhks9QxzsavxVQx3+QLN0+F5dV9F+/Q9nz5HvFp1IbnK6Ls8HzM77BJDJ6d rigsD6LaMveBtZ4FxwCp+LA4D/hjzs7KU/lgAqlvXBmmyKadXjoWdavRip/63HK0No wzoS2+FE2uTlZNFuNWCNfuBRXwMmQ3tn6/LfDPc8= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alain Michaud <alainm@chromium.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 056/127] Bluetooth: guard against controllers sending zero'd events Date: Thu, 17 Sep 2020 22:11:09 -0400 Message-Id: <20200918021220.2066485-56-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021220.2066485-1-sashal@kernel.org> References: <20200918021220.2066485-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.31 / 15.00 / 15.00 X-Rspamd-Queue-Id: 458CEA01ED X-Rspamd-UID: 762072 From: Alain Michaud <alainm@chromium.org> [ Upstream commit 08bb4da90150e2a225f35e0f642cdc463958d696 ] Some controllers have been observed to send zero'd events under some conditions. This change guards against this condition as well as adding a trace to facilitate diagnosability of this condition. Signed-off-by: Alain Michaud <alainm@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/hci_event.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 70b8e2de40cf4..1d2f439043669 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5257,6 +5257,11 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) u8 status = 0, event = hdr->evt, req_evt = 0; u16 opcode = HCI_OP_NOP; + if (!event) { + bt_dev_warn(hdev, "Received unexpected HCI Event 00000000"); + goto done; + } + if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) { struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; opcode = __le16_to_cpu(cmd_hdr->opcode); @@ -5468,6 +5473,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) req_complete_skb(hdev, status, opcode, orig_skb); } +done: kfree_skb(orig_skb); kfree_skb(skb); hdev->stat.evt_rx++; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eKNlM7goZF8SngAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:25:44 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id mKIWMbgoZF9ieAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:25:44 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C2218A0B22; Fri, 18 Sep 2020 05:25:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730027AbgIRCfm (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:35:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:39998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728882AbgIRCNH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:13:07 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 560002388D; Fri, 18 Sep 2020 02:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395187; bh=Ms8lENlLnFZ6YwfFPHM65qrhWiEu1s7AEcXco8pP22w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ar4a0FoMD9TlGRNN8aKHIo1TI4K9TybOaqngd2za/hA9E+rq5xIms8aEEgE9kB/sV Xr+xlF/9Jgf270CHnHzLOk5EeVG0Kg87F8DUWvwHGRFxjMhVneESScaQfxBF2AcvlQ sURacDwesSdHRBVQZ+5FNkllgDOD3mlCRJ53S8R4= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hillf Danton <hdanton@sina.com>, syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com, Manish Mandlik <mmandlik@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 039/127] Bluetooth: prefetch channel before killing sock Date: Thu, 17 Sep 2020 22:10:52 -0400 Message-Id: <20200918021220.2066485-39-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021220.2066485-1-sashal@kernel.org> References: <20200918021220.2066485-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.01 / 15.00 / 15.00 X-Rspamd-Queue-Id: C2218A0B22 X-Rspamd-UID: fff0c7 From: Hillf Danton <hdanton@sina.com> [ Upstream commit 2a154903cec20fb64ff4d7d617ca53c16f8fd53a ] Prefetch channel before killing sock in order to fix UAF like BUG: KASAN: use-after-free in l2cap_sock_release+0x24c/0x290 net/bluetooth/l2cap_sock.c:1212 Read of size 8 at addr ffff8880944904a0 by task syz-fuzzer/9751 Reported-by: syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com Fixes: 6c08fc896b60 ("Bluetooth: Fix refcount use-after-free issue") Cc: Manish Mandlik <mmandlik@google.com> Signed-off-by: Hillf Danton <hdanton@sina.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_sock.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index a5e618add17f4..511a1da6ca971 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1191,6 +1191,7 @@ static int l2cap_sock_release(struct socket *sock) { struct sock *sk = sock->sk; int err; + struct l2cap_chan *chan; BT_DBG("sock %p, sk %p", sock, sk); @@ -1200,15 +1201,16 @@ static int l2cap_sock_release(struct socket *sock) bt_sock_unlink(&l2cap_sk_list, sk); err = l2cap_sock_shutdown(sock, 2); + chan = l2cap_pi(sk)->chan; - l2cap_chan_hold(l2cap_pi(sk)->chan); - l2cap_chan_lock(l2cap_pi(sk)->chan); + l2cap_chan_hold(chan); + l2cap_chan_lock(chan); sock_orphan(sk); l2cap_sock_kill(sk); - l2cap_chan_unlock(l2cap_pi(sk)->chan); - l2cap_chan_put(l2cap_pi(sk)->chan); + l2cap_chan_unlock(chan); + l2cap_chan_put(chan); return err; } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aFdqDQniY19Z8QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 00:24:09 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 4JudCQniY1+vnwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 00:24:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 3BE97A0B2D; Fri, 18 Sep 2020 00:24:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726174AbgIQWXO (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 18:23:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726304AbgIQWXN (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 18:23:13 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D7B6C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:23:13 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id g4so4176808edk.0 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=I6w1TUj9xOYczLkyrq5zxBjdqnRjwnwLIwEXm54w/Sk=; b=EHm7B/tDIwRdUzM9hhoNybasA38pxCuhexvO69Bsig4Qc23WEB+4GhZmXBn18jA7vU vil2r5qM/VedJlE6RYkDUEnk42H7zAP32tRn0bz68GSPt9Y8sl4uidIOAlKcpPzT/2kL vHGKkllyRS8oDWWT23ZJ9C42HlQgGLmO7ZnXo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=I6w1TUj9xOYczLkyrq5zxBjdqnRjwnwLIwEXm54w/Sk=; b=B8zMnk8VyQMC298UyDv8mEwDeMmxPPHOUR3G2rRScR48VxClpoyCCHfyVHEr7W7T7T NIqvd61E6fUsgDXzTrkC/moqc8xmvVEyUTwsk6CEzpaiR52IFCKlQoimv25fem63qNw5 HdA0Lt7xz02nIQvXL4bqQC6J6F5zWBnveQWJWp4yvM/2wZfefNk35Cvxec1nIb7BDk2d 5prmMALWCQc03o9i62XXc/kF27wWRuyJIuun8uzhIcFf+2qSMMefZnxpKiKlzRo5dGGy C6pWSry98qFlI5P0eNzPBs8MV54rmi2QnGNRYO5ahLzij97l9XK5IlmdBC7eBXPeKUn8 WtRg== X-Gm-Message-State: AOAM530s5gaKbxnXQo8xCpgXawcsRgJXTHuVNpa7sosMUt+yx/t/nXmx AX9+fs2dkVWcA+vEKR8qiM+BEElkTta6Hg== X-Google-Smtp-Source: ABdhPJxMOkWshWG7/so7Nbbkfeqh2aftcLnIAsqa2orAjyBXGjbLnUJymf/w7CxONn4Npq7V18YH+Q== X-Received: by 2002:a05:6402:16c9:: with SMTP id r9mr34630562edx.27.1600381391464; Thu, 17 Sep 2020 15:23:11 -0700 (PDT) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com. [209.85.128.44]) by smtp.gmail.com with ESMTPSA id os15sm795696ejb.61.2020.09.17.15.23.10 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Sep 2020 15:23:10 -0700 (PDT) Received: by mail-wm1-f44.google.com with SMTP id d4so3427004wmd.5 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:23:10 -0700 (PDT) X-Received: by 2002:a05:600c:2252:: with SMTP id a18mr13090168wmm.154.1600381389791; Thu, 17 Sep 2020 15:23:09 -0700 (PDT) MIME-Version: 1.0 References: <20200916211122.127881-1-sonnysasaka@chromium.org> <CABBYNZKwZBM-3=jBvNVL7oHa133GGnZ5f8roNyrAR-hXNOVuhA@mail.gmail.com> In-Reply-To: <CABBYNZKwZBM-3=jBvNVL7oHa133GGnZ5f8roNyrAR-hXNOVuhA@mail.gmail.com> From: Sonny Sasaka <sonnysasaka@chromium.org> Date: Thu, 17 Sep 2020 15:22:58 -0700 X-Gmail-Original-Message-ID: <CAO271mknf69CZyv8cbmiJR8_OLhC3qwjNByAeCSrcQrJkyy32w@mail.gmail.com> Message-ID: <CAO271mknf69CZyv8cbmiJR8_OLhC3qwjNByAeCSrcQrJkyy32w@mail.gmail.com> Subject: Re: [PATCH BlueZ] a2dp: Keep track of ref ownership of a2dp_setup To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.22 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3BE97A0B2D X-Rspamd-UID: ca5f72 Hi Luiz, On Wed, Sep 16, 2020 at 4:28 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Sonny, > > On Wed, Sep 16, 2020 at 3:31 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > > > Currently transport_cb and abort_cfm make assumption that they have an > > a2dp_setup reference held as a result of open_ind invocation. In the > > field this is not always true, for example when the peer device opens an > > L2CAP channel for AVDTP transport channel without sending AVDTP_OPEN > > request through the AVDTP signaling channel first. Although in this case > > the peer device does not behave correctly, we should protect this > > possible crash from happening by making sure that transport_cb and > > abort_cfm are really holding a reference of a2dp_setup object before > > trying to unref them. > > > > After grabbing a reference, open_ind stores the pointer in > > stream->pending_open_data. If this field is set, that means there is a > > pending AVDTP_OPEN command and it needs to be unref-fed later once and > > only once: when the transport channel is created (transport_cb) or when > > the AVDTP_OPEN command is aborted (abort_cfm). If this field is not set, > > nothing should unref it. This enforces that the reference counting is > > correct regardless of the behavior of the peer device. > > While I agree that we should handle this properly and never crash I > think we can take a more generic approach by attaching a user_data to > the stream, see my comments bellow. I sent a v2 to change to generic user_data instead of pending_open_data. > > > A sample crash stack trace from Chrome OS: > > * thread #1, stop reason = signal SIGSEGV > > * frame #0: 0x0c64f0e8 bluetoothd`queue_remove_all at queue.c:351 > > frame #1: 0x0c64f086 bluetoothd`queue_destroy at queue.c:73 > > frame #2: 0x0c6022b0 bluetoothd`setup_unref at a2dp.c:222 > > frame #3: 0x0c604942 bluetoothd`transport_cb at a2dp.c:2229 > > frame #4: 0x0c61e35c bluetoothd`accept_cb at btio.c:203 > > frame #5: 0xf679523c libglib-2.0.so.0`g_main_context_dispatch at gmain.c:3182 > > frame #6: 0xf67954aa libglib-2.0.so.0`g_main_context_iterate at gmain.c:3920 > > frame #7: 0xf679569a libglib-2.0.so.0`g_main_loop_run at gmain.c:4116 > > frame #8: 0x0c65a5a0 bluetoothd`mainloop_run at mainloop-glib.c:79 > > frame #9: 0x0c65a7ea bluetoothd`mainloop_run_with_signal at mainloop-notify.c:201 > > frame #10: 0x0c6477ec bluetoothd`main at main.c:772 > > frame #11: 0xf65bc0a2 libc.so.6`__libc_start_main at libc-start.c:308 > > > > --- > > profiles/audio/a2dp.c | 24 ++++++++++++++++-------- > > profiles/audio/avdtp.c | 17 +++++++++++++++++ > > profiles/audio/avdtp.h | 3 +++ > > 3 files changed, 36 insertions(+), 8 deletions(-) > > > > diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c > > index 2feea66c0..9e96f8c4b 100644 > > --- a/profiles/audio/a2dp.c > > +++ b/profiles/audio/a2dp.c > > @@ -927,10 +927,16 @@ static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep, > > else > > DBG("Source %p: Open_Ind", sep); > > > > + if (avdtp_stream_get_pending_open_data(stream)) { > > + warn("Pending open data already exists"); > > + return FALSE; > > + } > > + > > Not really clear why you need to check if there is a setup already in > pending state here, if that is the case then that should be fixed in > avdtp.c since it is not support to call open again if it is already > pending. It's one thing that avdtp.c should never allow open_ind to be invoked twice. But it's also another thing to ensure that a2dp.c guarantees the correctness of the ref counting of setup object regardless of the broader code area. What we do here is following the contract that stream->user_data being not NULL means that there is a reference taken on a setup object. We should either return early here, or unref that object before continuing to ensure that ref-counting is guaranteed to be correct even without looking/understanding the bigger picture. > > > setup = a2dp_setup_get(session); > > if (!setup) > > return FALSE; > > > > + avdtp_stream_set_pending_open_data(stream, setup); > > Id like this to be handle generically in with something like: > > avdtp_stream_set_user_data(session, setup, destroy) > setup = avdtp_stream_get_user_data(session) > > This should avoid lookups in the likes of a2dp_setup_get and ensure > that the setup lifetime is tied to the stream. I have sent a v2 to use generic user_data with destroy function. However I can't follow exactly what you recommend here because setup still needs to be looked up from a2dp_setup_get because this is the first time we assign stream->user_data. > > > setup->stream = stream; > > > > if (!err && setup->chan) > > @@ -1285,14 +1291,13 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, > > void *user_data) > > { > > struct a2dp_sep *a2dp_sep = user_data; > > - struct a2dp_setup *setup; > > + struct a2dp_setup *setup = avdtp_stream_get_pending_open_data(stream); > > Abort can be called while in configured state as well, anyway if we go > ahead with the idea of attaching the setup to the avdtp_stream then > this would be just a matter of calling avdtp_stream_get_user_data. > > > > > if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK) > > DBG("Sink %p: Abort_Cfm", sep); > > else > > DBG("Source %p: Abort_Cfm", sep); > > > > - setup = find_setup_by_session(session); > > if (!setup) > > return; > > > > @@ -1302,6 +1307,7 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, > > } > > > > setup_unref(setup); > > + avdtp_stream_set_pending_open_data(stream, NULL); > > This would then be avdtp_stream_set_user_data(stream, NULL, NULL), or > better yet wait the destroy function to be called which should then do > setup_unref to destroy the setup. > > > } > > > > static gboolean reconf_ind(struct avdtp *session, struct avdtp_local_sep *sep, > > @@ -2216,11 +2222,12 @@ fail: > > > > static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > > { > > - struct a2dp_setup *setup = user_data; > > + struct avdtp_stream *stream = user_data; > > + struct a2dp_setup *setup = avdtp_stream_get_pending_open_data(stream); > > uint16_t omtu, imtu; > > > > - if (!g_slist_find(setups, setup)) { > > - warn("bt_io_accept: setup %p no longer valid", setup); > > + if (!setup) { > > + warn("transport_cb: pending open data does not exist"); > > g_io_channel_shutdown(io, TRUE, NULL); > > return; > > } > > @@ -2238,8 +2245,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > > goto drop; > > } > > > > - if (!avdtp_stream_set_transport(setup->stream, > > - g_io_channel_unix_get_fd(io), > > + if (!avdtp_stream_set_transport(stream, g_io_channel_unix_get_fd(io), > > imtu, omtu)) > > goto drop; > > > > @@ -2249,6 +2255,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > > setup->io = NULL; > > > > setup_unref(setup); > > + avdtp_stream_set_pending_open_data(stream, NULL); > > Ditto. > > > return; > > > > @@ -2297,7 +2304,8 @@ static void confirm_cb(GIOChannel *io, gpointer data) > > goto drop; > > } > > > > - if (!bt_io_accept(io, transport_cb, setup, NULL, &err)) { > > + if (!bt_io_accept(io, transport_cb, setup->stream, NULL, > > + &err)) { > > error("bt_io_accept: %s", err->message); > > g_error_free(err); > > goto drop; > > diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c > > index 782268c08..74b9f8dfa 100644 > > --- a/profiles/audio/avdtp.c > > +++ b/profiles/audio/avdtp.c > > @@ -366,6 +366,8 @@ struct avdtp_stream { > > GSList *caps; > > GSList *callbacks; > > struct avdtp_service_capability *codec; > > + void *pending_open_data; /* Data when the transport channel > > + * opening is pending */ > > guint io_id; /* Transport GSource ID */ > > guint timer; /* Waiting for other side to close or open > > * the transport channel */ > > @@ -727,6 +729,11 @@ static void stream_free(void *data) > > g_slist_free_full(stream->callbacks, g_free); > > g_slist_free_full(stream->caps, g_free); > > > > + /* pending_open_data must have been unref-ed and unset before freeing > > + * avdtp_stream. Otherwise, it is a reference leak bug. > > + */ > > + assert(!stream->pending_open_data); > > + > > g_free(stream); > > } > > > > @@ -3147,6 +3154,16 @@ struct avdtp_remote_sep *avdtp_stream_get_remote_sep( > > return NULL; > > } > > > > +void avdtp_stream_set_pending_open_data(struct avdtp_stream *stream, void *data) > > +{ > > + stream->pending_open_data = data; > > +} > > + > > +void *avdtp_stream_get_pending_open_data(struct avdtp_stream *stream) > > +{ > > + return stream->pending_open_data; > > +} > > + > > gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd, > > size_t imtu, size_t omtu) > > { > > diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h > > index 011fea89e..92ce65ed3 100644 > > --- a/profiles/audio/avdtp.h > > +++ b/profiles/audio/avdtp.h > > @@ -260,6 +260,9 @@ gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream, > > GSList *caps); > > struct avdtp_remote_sep *avdtp_stream_get_remote_sep( > > struct avdtp_stream *stream); > > +void avdtp_stream_set_pending_open_data(struct avdtp_stream *stream, > > + void *data); > > +void *avdtp_stream_get_pending_open_data(struct avdtp_stream *stream); > > > > unsigned int avdtp_add_state_cb(struct btd_device *dev, > > avdtp_session_state_cb cb, void *user_data); > > -- > > 2.26.2 > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kFLmMc/iY19Z8QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 00:27:27 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id oKEbL8/iY1/RqgAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 00:27:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 86BBCA0B0C; Fri, 18 Sep 2020 00:27:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726126AbgIQW1N (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 18:27:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726055AbgIQW1M (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 18:27:12 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BBA7C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:27:12 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id z18so1853843qvp.6 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:27:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=MW1jIf4XW7dmvTkaEvdEHJkJjLhhazMtsSWWDiGFp6g=; b=fPI6YD8bwT/GfwNputLwt5rxvpp79qMpcqgIPyOLNNKd6H+NRSvxb/WE8t9AR+Hhfc 13vPkn8kBg5DBFRo4BdOCBkLHnW0V+0hpFQj/OnrSUX8LfO42gXla81yxk/y/GlVZK8N Ze2/uSm0hqldeMNLfO+mfTc5pmO6dvFWD0M5woyOJaB0AC+hZyv9Avu6uU1pmfGq3ULZ y33c8RjV7N1ZEbnCMythc0k7OtL67bSIHuCUXqXwoz1JxZQ535mJduU6M4ArEmSKqqRZ 6kaVU+PWhKfURRQmJYekKCMvdEYzA/paEkLz8aA1+YsXaFEYKlvkR9VVdHH1UaHFKxZ7 k/CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=MW1jIf4XW7dmvTkaEvdEHJkJjLhhazMtsSWWDiGFp6g=; b=nZqUN9XZ0pe/EA4boev3iLf9UTi9RTBOLI733yjx+P6AQfw6cGJdZQp92WzB+UTCg+ OEBu+XWLImFZJV0RSO/qMskBo3sdoqwnvvD9d6DW9SL33q2v4e1UIfz5AQhPplMJDhx/ qKecNq36Y2lPl4kyfQ+EB28QGqIDWuYeUEYfWk1xBmiUufbB9sRAXrnwPL1p30KBF7/m OmO8GHMf06Xa+zGRqBkuti3L3tYnc4WrpHiQdZY91TdmN5YsGRIHGv9/G9DhrbFlA6hH PJMIqNdgckRc2x1e0O/yUYrcJSqjEUxa1IwHyT59alsYen6qoEfvJrbosLF/dRD7j/th N6Ug== X-Gm-Message-State: AOAM532yNjx3ygvdfwqlYDKQvuOXQ372J+BipQL6nHVJVztGVkMBySzv mZgse/UUcsMa990vVUQRLFyAD6eFvfzSCg== X-Google-Smtp-Source: ABdhPJwNjueDcxiQs9RsWiZlAWVfeU2TwsZskizTXTBaeWw1mn+ahyT00EGD/oPHuTddrmLE0ul3pw== X-Received: by 2002:a0c:f1c5:: with SMTP id u5mr31009501qvl.10.1600381631227; Thu, 17 Sep 2020 15:27:11 -0700 (PDT) Received: from [172.17.0.2] ([52.138.83.123]) by smtp.gmail.com with ESMTPSA id m6sm818574qkh.106.2020.09.17.15.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 15:27:10 -0700 (PDT) Message-ID: <5f63e2be.1c69fb81.bb9b2.5acc@mx.google.com> Date: Thu, 17 Sep 2020 15:27:10 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============2147787060672591220==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, sonnysasaka@chromium.org Subject: RE: [BlueZ,v2] a2dp: Keep track of ref ownership of a2dp_setup Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200917221034.154218-1-sonnysasaka@chromium.org> References: <20200917221034.154218-1-sonnysasaka@chromium.org> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.10 / 15.00 / 15.00 X-Rspamd-Queue-Id: 86BBCA0B0C X-Rspamd-UID: 7eecd1 --===============2147787060672591220== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #31: frame #5: 0xf679523c libglib-2.0.so.0`g_main_context_dispatch at gmain.c:3182 - total: 0 errors, 1 warnings, 146 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============2147787060672591220==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +EF1GejiY18p+wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 00:27:52 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id sCglFujiY1/GfgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 00:27:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 37F49A017C; Fri, 18 Sep 2020 00:27:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726159AbgIQW1R (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 18:27:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbgIQW1P (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 18:27:15 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1464DC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:27:15 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id d20so4071692qka.5 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 15:27:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=/9jdAMRjU/sKH6BoW5zvxbly3xZVYmRR5UC7HJNZphk=; b=P99vaB7D7AkdIWx83xM8k85/yJnEDoO24YXcNYYfbPOC5GwzDCZDjw2HsHywpduB38 09i+Yssmg/dlgXeNNf1UALMHP1z2tNlVdPpU8L8zEkJJ87Kvguif9AV1CHdODIBiAo1o GlpdPMTaMix1C7ZfoLeCq5THw2bOOF2/0e2VEp53Dp6WxJ+5ZxpFruqeabZk6xKI5ZCy GiN6H8HzRm4fF6ulrlMePo/ejGgI2tvVxv7f/tAx/DpkI+vg+0z0tyJyOnwIoFTBzFEN vd5Z1Lusz87fCbthaXwuAJYhTERqZI7Db3+9kM+pkbGIwOoJF2dI8IbGxXvNeRDWt8CK Du0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=/9jdAMRjU/sKH6BoW5zvxbly3xZVYmRR5UC7HJNZphk=; b=S1U76M4uBkZnTdTlVvNhqliOMAV70XyZsZllwGyGVpbSf0ZuoCuJiNTvhrluhn35uy ofyEEZNQS6Rg+PaFpz1aiQRkrZ0dF4d8gFk6kjiXU3O87DfbL2Xo0cDtjRhIva9Y50We j3abG/8Ty3i02aeq6FDnr6lZF9vpcew6GOEBLZIP8l/gFKwuSnknny+I8otMxaq6XvrL NR6U7d1cXitQeaXoDkVv6W0fJyIaaJ90nCe7/dVt38uniXGeiC2/T2j6zySfjQvB88rS 5Z5/NwpxluqMue9lxSHMA5/tHijgbH/j7Hxc7twjL9Tw2gFSzs2FjsgmUicDjRbaAMbh PDnQ== X-Gm-Message-State: AOAM532GfEt+oxh+mXP6++9sXviYe/NL8ISayPTFoeMZJPIelO2ZMvFX XDr5WNsi6NEtzO+NTdppNuHS9XiSUZ6E/g== X-Google-Smtp-Source: ABdhPJxKOqj50PuwNkBzpDw1ekH2Wyh47BaOXrr2iGO8tqSbxYizZiZC3cY5x61WvFYE/8R5E4sGpA== X-Received: by 2002:a37:9c4f:: with SMTP id f76mr30933802qke.250.1600381634064; Thu, 17 Sep 2020 15:27:14 -0700 (PDT) Received: from [172.17.0.2] ([52.138.83.123]) by smtp.gmail.com with ESMTPSA id o13sm812840qkm.16.2020.09.17.15.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 15:27:13 -0700 (PDT) Message-ID: <5f63e2c1.1c69fb81.81a86.5be2@mx.google.com> Date: Thu, 17 Sep 2020 15:27:13 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============0979735859871204913==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, sonnysasaka@chromium.org Subject: RE: [BlueZ,v2] a2dp: Keep track of ref ownership of a2dp_setup Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200917221034.154218-1-sonnysasaka@chromium.org> References: <20200917221034.154218-1-sonnysasaka@chromium.org> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.72 / 15.00 / 15.00 X-Rspamd-Queue-Id: 37F49A017C X-Rspamd-UID: df5544 --===============0979735859871204913== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkgitlint Failed Outputs: 28: B1 Line exceeds max length (81>80): " frame #5: 0xf679523c libglib-2.0.so.0`g_main_context_dispatch at gmain.c:3182" 32: B1 Line exceeds max length (85>80): " frame #9: 0x0c65a7ea bluetoothd`mainloop_run_with_signal at mainloop-notify.c:201" --- Regards, Linux Bluetooth --===============0979735859871204913==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kM8tOy4JZF+APQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 03:11:10 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id qNXwNi4JZF+E6gEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 03:11:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1A85640869; Fri, 18 Sep 2020 03:10:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726239AbgIRBKp (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 21:10:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726244AbgIRBKp (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 21:10:45 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F03B2C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 18:10:44 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id r19so2099097pls.1 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 18:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=q0xM1qNB/p3ifzv7crdTb3hiZTxDeC5+s7eoLwsd2UE=; b=eH5/cCLHfbmch/MgBaNgIBL2EqhLlaOSlPDeHctnRwIYnvgKjMJBXY+olQpMfDlMUs TiSLM3DLd6pOUjtHpGMrIg1RZ1i3TEzl+8tDVApVnJg69aeQA6ThfA5t1QR7lurqbLyI /NfZRbUfeU7xH2DwWqlVyTEqRd8vEUIg0Tw7uEix10a9B18kOv/qPxf8NvpH6XsvYVld A+pOqTeFGyw4VkJ8H/y284gzsoDEqVcyhT5xQzkrAYAsk8tyNAU9VOwhmTQt2mvTucXm gtE5CF7UfP71c49ZzFN/jhJn8q+BEkUv7UwiaMzQU/1ajqd4a7QHNKfq69K1TNIYk3vq VLPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=q0xM1qNB/p3ifzv7crdTb3hiZTxDeC5+s7eoLwsd2UE=; b=YYFvBk22I8cqFa/89FrnwzI5e9u6PQNy/8nsyVBH68NTj+mDnvbkfoE+oVW8Ywxicy Cr74bRWbhuQdwNde5e09B+Ve/uD3efM3y0QWa4trDiFxosRIbv9Rbbxbni7yRRbycwPu M5GOUIB72r0Oo5WrEs9vWj35dd7lO5bIUH3XgJXi7BF4gd7v8RBd6Hh61kdGg6vl8RtA G8keI5D+zk2fqj1by4qrFrodcEhu1HHN0xmiDA7QiVk+8Dh9jDues7RVCLKJ7jnSnkwH Q3oMiuL5vvTwnv/1sKuKHz22iy/dmTxJIoxOrgILPYeWIx2w5G1bKjoJl1YDInUWsIo7 tvOg== X-Gm-Message-State: AOAM531NcgZXgf1YaTTwEdOyLpPRdcjlAyaxw7lKEmexy/gupnxva85H wIn5pdMYXDFrdwklotYm6GSfdA5Ak+E= X-Google-Smtp-Source: ABdhPJz13zmOXwlA4GPpDwzvM4dJHZ6RU5eV3hys5JyOSa6Na6tFcV4tTHXYXKmS6Sy33ZwfXI5axQ== X-Received: by 2002:a17:902:9b95:b029:d2:219:e438 with SMTP id y21-20020a1709029b95b02900d20219e438mr3747875plp.76.1600391444048; Thu, 17 Sep 2020 18:10:44 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id gi20sm850005pjb.28.2020.09.17.18.10.43 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 18:10:43 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] avdtp: Fix not checking if stream is already set as pending open Date: Thu, 17 Sep 2020 18:10:42 -0700 Message-Id: <20200918011042.3141447-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.87 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1A85640869 X-Rspamd-UID: 93558c From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> When receiving a Open command the stream will be set as pending_open but the remote may attempt to send yet another Open command in the meantime reseting resulting in another setup and yet another timer leaving the old timer active which will likely cause a crash when it expires. --- profiles/audio/avdtp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 782268c08..e0c6f44f0 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -1687,7 +1687,7 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction, stream = sep->stream; - if (sep->ind && sep->ind->open) { + if (sep->ind && sep->ind->open && !session->pending_open) { if (!sep->ind->open(session, sep, stream, &err, sep->user_data)) goto failed; @@ -1699,11 +1699,13 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction, AVDTP_OPEN, NULL, 0)) return FALSE; - stream->open_acp = TRUE; - session->pending_open = stream; - stream->timer = g_timeout_add_seconds(REQ_TIMEOUT, + if (!session->pending_open) { + stream->open_acp = TRUE; + session->pending_open = stream; + stream->timer = g_timeout_add_seconds(REQ_TIMEOUT, stream_open_timeout, stream); + } return TRUE; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0L6+OXUOZF/dTgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 03:33:41 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id +NpjN3UOZF+NTwAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 03:33:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id C215A400F9; Fri, 18 Sep 2020 03:33:35 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726093AbgIRBdf (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 21:33:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726040AbgIRBde (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 21:33:34 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6887C06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 18:33:34 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id w12so4469427qki.6 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 18:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:mime-version:from:to:subject:reply-to:in-reply-to :references; bh=d3H/e4nwFw4hpR6f9BWrd5+zgTfYJV7A4FUJzsEtRDo=; b=Mp8YSCvmq/iHGXYd+hckY27AirWyGmHQfa2Lsd0ScqarGQk5BnGvvjxOB/WATWG0OI fjgIFx0ZVJlemAiThfKsrdADQZup+fJ7T+heKrgkaJSlFmoRyVl4SzOUr+9/UPaV9XY/ pEmVAJtigDSXRO30WTVoJwNgwMZC+7lF0cQHjmyH+RB+V5es836+Qw6Z91T5tzp8NnWk KLzbhozwTgU5NQSXnaJ+CYdDHuh8AXoSOx8e0bzTPWMH4Li5y+UEeLE9LIr7TQXsKbRv kBJq6Ff0kAZemV/U2rqEs4oZ5gWXbiRLqDsmgu/BeLBPoAcq6d/qX8e7Q4YcRoP0/uIZ tLTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:from:to:subject :reply-to:in-reply-to:references; bh=d3H/e4nwFw4hpR6f9BWrd5+zgTfYJV7A4FUJzsEtRDo=; b=bMqc0Ff4TnlfsrDzwPRURyEepBwYHmCaqMST2yQO7yyJja1rH2ig+5qaIN58v41rrF a+1JLppfwI6TngMdthcykyn3+dIDEblgPdxa15msoIlkBFGuK0FCrI5SMbEbYM1Mw/AK mW844AEMq+m6onCAOTSYJpt85HSt4cbfR99npGF4IdfAiXEkBILBihs29KK8U/s3FLWC yjBjKoowujKqulFMPz45EJnNTGlDvEoyKTwdhlmCisT/7Uz0/3yCn94np/h2W7QXuB6W i7Uk57MZj7ZOGIonG04FTIl6xI6ZUEYduv4A/nb+9bi5JGuu1DUoI8EVOPuu7Uf6Y/KG VU0w== X-Gm-Message-State: AOAM532pbRZB+S0K/CAYGZhF+FetwGJV1gscH+AQ8rRNXQo0N+rBcKFe g/2qyuNdmEIXrT73zNFR8mAInTS6kSesEA== X-Google-Smtp-Source: ABdhPJzBpCE9NMEm2wQ71SG/s3mLQ0u7jUeCgTcbn8KzOFHj1bsALzogFS61nIq0i2hTupQ7/R3P7A== X-Received: by 2002:a37:674d:: with SMTP id b74mr32079193qkc.189.1600392813550; Thu, 17 Sep 2020 18:33:33 -0700 (PDT) Received: from [172.17.0.2] ([40.75.79.178]) by smtp.gmail.com with ESMTPSA id p205sm1099486qke.2.2020.09.17.18.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 18:33:33 -0700 (PDT) Message-ID: <5f640e6d.1c69fb81.2be96.793d@mx.google.com> Date: Thu, 17 Sep 2020 18:33:33 -0700 (PDT) Content-Type: multipart/mixed; boundary="===============3255440781536906701==" MIME-Version: 1.0 From: bluez.test.bot@gmail.com To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com Subject: RE: [BlueZ] avdtp: Fix not checking if stream is already set as pending open Reply-To: linux-bluetooth@vger.kernel.org In-Reply-To: <20200918011042.3141447-1-luiz.dentz@gmail.com> References: <20200918011042.3141447-1-luiz.dentz@gmail.com> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.24 / 15.00 / 15.00 X-Rspamd-Queue-Id: C215A400F9 X-Rspamd-UID: 2954c0 --===============3255440781536906701== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning. Test Result: checkpatch Failed Outputs: WARNING:TYPO_SPELLING: 'reseting' may be misspelled - perhaps 'resetting'? #9: reseting resulting in another setup and yet another timer leaving the - total: 0 errors, 1 warnings, 24 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Your patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. --- Regards, Linux Bluetooth --===============3255440781536906701==-- Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eBt9FzkWZF9tYgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 04:06:49 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id YDjzFDkWZF9hdQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 04:06:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BE2B2A0B2F; Fri, 18 Sep 2020 04:06:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727079AbgIRCD2 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:03:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727021AbgIRCDZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:03:25 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AADC122211; Fri, 18 Sep 2020 02:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394604; bh=sa8V9fKJRb/Z1mV9EvJW3toD3jyQYQ4KVzzTVJ304d8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SsV25oNMALy5xYn7UKXa9JD5vpSUrn+7+E7SInfYX56SoiteQXlgYKleXTaSHB+Ii hXxjUSEQprV03zQT7IXEQ8LOZuWxm/fD5JF0SvGOZLXdsRCaPGb/l1fgcP4ox/pu+W KI9fn0+/xvxt/rC9Mft0F86dfYhZ2SRJKz+leWxo= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Manish Mandlik <mmandlik@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 111/330] Bluetooth: Fix refcount use-after-free issue Date: Thu, 17 Sep 2020 21:57:31 -0400 Message-Id: <20200918020110.2063155-111-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.98 / 15.00 / 15.00 X-Rspamd-Queue-Id: BE2B2A0B2F X-Rspamd-UID: babfef From: Manish Mandlik <mmandlik@google.com> [ Upstream commit 6c08fc896b60893c5d673764b0668015d76df462 ] There is no lock preventing both l2cap_sock_release() and chan->ops->close() from running at the same time. If we consider Thread A running l2cap_chan_timeout() and Thread B running l2cap_sock_release(), expected behavior is: A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill() where, sock_orphan() clears "sk->sk_socket" and l2cap_sock_teardown_cb() marks socket as SOCK_ZAPPED. In l2cap_sock_kill(), there is an "if-statement" that checks if both sock_orphan() and sock_teardown() has been run i.e. sk->sk_socket is NULL and socket is marked as SOCK_ZAPPED. Socket is killed if the condition is satisfied. In the race condition, following occurs: A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill() In this scenario, "if-statement" is true in both B::l2cap_sock_kill() and A::l2cap_sock_kill() and we hit "refcount: underflow; use-after-free" bug. Similar condition occurs at other places where teardown/sock_kill is happening: l2cap_disconnect_rsp()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_rsp()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_conn_del()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_conn_del()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_disconnect_req()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_req()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_sock_cleanup_listen()->l2cap_chan_close()->l2cap_sock_teardown_cb() l2cap_sock_cleanup_listen()->l2cap_sock_kill() Protect teardown/sock_kill and orphan/sock_kill by adding hold_lock on l2cap channel to ensure that the socket is killed only after marked as zapped and orphan. Signed-off-by: Manish Mandlik <mmandlik@google.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_core.c | 26 +++++++++++++++----------- net/bluetooth/l2cap_sock.c | 16 +++++++++++++--- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index a845786258a0b..eb2804ac50756 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -419,6 +419,9 @@ static void l2cap_chan_timeout(struct work_struct *work) BT_DBG("chan %p state %s", chan, state_to_string(chan->state)); mutex_lock(&conn->chan_lock); + /* __set_chan_timer() calls l2cap_chan_hold(chan) while scheduling + * this work. No need to call l2cap_chan_hold(chan) here again. + */ l2cap_chan_lock(chan); if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) @@ -431,12 +434,12 @@ static void l2cap_chan_timeout(struct work_struct *work) l2cap_chan_close(chan, reason); - l2cap_chan_unlock(chan); - chan->ops->close(chan); - mutex_unlock(&conn->chan_lock); + l2cap_chan_unlock(chan); l2cap_chan_put(chan); + + mutex_unlock(&conn->chan_lock); } struct l2cap_chan *l2cap_chan_create(void) @@ -1734,9 +1737,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) l2cap_chan_del(chan, err); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); } @@ -4355,6 +4358,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, return 0; } + l2cap_chan_hold(chan); l2cap_chan_lock(chan); rsp.dcid = cpu_to_le16(chan->scid); @@ -4363,12 +4367,11 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, chan->ops->set_shutdown(chan); - l2cap_chan_hold(chan); l2cap_chan_del(chan, ECONNRESET); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); @@ -4400,20 +4403,21 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, return 0; } + l2cap_chan_hold(chan); l2cap_chan_lock(chan); if (chan->state != BT_DISCONN) { l2cap_chan_unlock(chan); + l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); return 0; } - l2cap_chan_hold(chan); l2cap_chan_del(chan, 0); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index a7be8b59b3c28..ab65304f3f637 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1042,7 +1042,7 @@ done: } /* Kill socket (only if zapped and orphan) - * Must be called on unlocked socket. + * Must be called on unlocked socket, with l2cap channel lock. */ static void l2cap_sock_kill(struct sock *sk) { @@ -1203,8 +1203,15 @@ static int l2cap_sock_release(struct socket *sock) err = l2cap_sock_shutdown(sock, 2); + l2cap_chan_hold(l2cap_pi(sk)->chan); + l2cap_chan_lock(l2cap_pi(sk)->chan); + sock_orphan(sk); l2cap_sock_kill(sk); + + l2cap_chan_unlock(l2cap_pi(sk)->chan); + l2cap_chan_put(l2cap_pi(sk)->chan); + return err; } @@ -1222,12 +1229,15 @@ static void l2cap_sock_cleanup_listen(struct sock *parent) BT_DBG("child chan %p state %s", chan, state_to_string(chan->state)); + l2cap_chan_hold(chan); l2cap_chan_lock(chan); + __clear_chan_timer(chan); l2cap_chan_close(chan, ECONNRESET); - l2cap_chan_unlock(chan); - l2cap_sock_kill(sk); + + l2cap_chan_unlock(chan); + l2cap_chan_put(chan); } } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iNbbH8UcZF/IbwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 04:34:45 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id IDMSHcUcZF9bPQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 04:34:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C8DA0A01ED; Fri, 18 Sep 2020 04:34:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728980AbgIRCNo (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:13:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:40986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728959AbgIRCNh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:13:37 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4938F2388D; Fri, 18 Sep 2020 02:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395216; bh=0NaHK30kRrR6UMyWl9usYfUJLUQ4H0zeHY3L+EQ56yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UU12DZz7L97yqWjULFaYOedmah/gzdC9B1Din9A1HtYfIxY4B5SA7Pwohu9UaUgmT 86sOB1UipNIYKDIOpWbpqobAU1zkOdWWuoggRZkuac0EHy0OEJYiNrO/kinpq6cyNO eRk2vs/A9fdpSYRK1h2niv10wt4ZKyDBr8BKBHb0= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Howard Chung <howardchung@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 063/127] Bluetooth: L2CAP: handle l2cap config request during open state Date: Thu, 17 Sep 2020 22:11:16 -0400 Message-Id: <20200918021220.2066485-63-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021220.2066485-1-sashal@kernel.org> References: <20200918021220.2066485-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: C8DA0A01ED X-Rspamd-UID: 183616 From: Howard Chung <howardchung@google.com> [ Upstream commit 96298f640104e4cd9a913a6e50b0b981829b94ff ] According to Core Spec Version 5.2 | Vol 3, Part A 6.1.5, the incoming L2CAP_ConfigReq should be handled during OPEN state. The section below shows the btmon trace when running L2CAP/COS/CFD/BV-12-C before and after this change. === Before === ... > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22 L2CAP: Connection Request (0x02) ident 2 len 4 PSM: 1 (0x0001) Source CID: 65 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23 L2CAP: Connection Response (0x03) ident 2 len 8 Destination CID: 64 Source CID: 65 Result: Connection successful (0x0000) Status: No further information available (0x0000) < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24 L2CAP: Configure Request (0x04) ident 2 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #25 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #26 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27 L2CAP: Configure Request (0x04) ident 3 len 8 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 .. < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 > HCI Event: Number of Completed Packets (0x13) plen 5 #29 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30 L2CAP: Configure Response (0x05) ident 2 len 6 Source CID: 64 Flags: 0x0000 Result: Success (0x0000) > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31 L2CAP: Configure Request (0x04) ident 3 len 12 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 91 02 11 11 ...... < ACL Data TX: Handle 256 flags 0x00 dlen 14 #32 L2CAP: Command Reject (0x01) ident 3 len 6 Reason: Invalid CID in request (0x0002) Destination CID: 64 Source CID: 65 > HCI Event: Number of Completed Packets (0x13) plen 5 #33 Num handles: 1 Handle: 256 Count: 1 ... === After === ... > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22 L2CAP: Connection Request (0x02) ident 2 len 4 PSM: 1 (0x0001) Source CID: 65 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23 L2CAP: Connection Response (0x03) ident 2 len 8 Destination CID: 64 Source CID: 65 Result: Connection successful (0x0000) Status: No further information available (0x0000) < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24 L2CAP: Configure Request (0x04) ident 2 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #25 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #26 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27 L2CAP: Configure Request (0x04) ident 3 len 8 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 .. < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 > HCI Event: Number of Completed Packets (0x13) plen 5 #29 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30 L2CAP: Configure Response (0x05) ident 2 len 6 Source CID: 64 Flags: 0x0000 Result: Success (0x0000) > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31 L2CAP: Configure Request (0x04) ident 3 len 12 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 91 02 11 11 ..... < ACL Data TX: Handle 256 flags 0x00 dlen 18 #32 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 < ACL Data TX: Handle 256 flags 0x00 dlen 12 #33 L2CAP: Configure Request (0x04) ident 3 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #34 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #35 Num handles: 1 Handle: 256 Count: 1 ... Signed-off-by: Howard Chung <howardchung@google.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 97175cddb1e04..c301b9debea7c 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4117,7 +4117,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, return 0; } - if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) { + if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2 && + chan->state != BT_CONNECTED) { cmd_reject_invalid_cid(conn, cmd->ident, chan->scid, chan->dcid); goto unlock; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6Pn6DtgdZF/JbwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 04:39:20 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SFsPDNgdZF9bPQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 04:39:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C0307A0AAE; Fri, 18 Sep 2020 04:39:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729258AbgIRCPe (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:15:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:44486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728540AbgIRCPd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:15:33 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED1A823718; Fri, 18 Sep 2020 02:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395332; bh=73XmBbL5kBfw8v5hmI7Y6kgq/EvxjfR/wQnjwChQaPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gz3fagPOzgarUo2LQ9tx1SVy3OMzPTFJR/SuFl0Oz/2+xiGyEXdD00GzVaHFnHrSJ xZNgn310hULGDBx5a3oHBjHb58mgK/Cex8P6Sy8ax5ivYBOWolVlcU5bMBtfX/DTH4 AcFCQmS32wki2Ez8gZkGoH4zdchgKFbqIAi8HDZM= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hillf Danton <hdanton@sina.com>, syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com, Manish Mandlik <mmandlik@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 30/90] Bluetooth: prefetch channel before killing sock Date: Thu, 17 Sep 2020 22:13:55 -0400 Message-Id: <20200918021455.2067301-30-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021455.2067301-1-sashal@kernel.org> References: <20200918021455.2067301-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.02 / 15.00 / 15.00 X-Rspamd-Queue-Id: C0307A0AAE X-Rspamd-UID: 1b96f0 From: Hillf Danton <hdanton@sina.com> [ Upstream commit 2a154903cec20fb64ff4d7d617ca53c16f8fd53a ] Prefetch channel before killing sock in order to fix UAF like BUG: KASAN: use-after-free in l2cap_sock_release+0x24c/0x290 net/bluetooth/l2cap_sock.c:1212 Read of size 8 at addr ffff8880944904a0 by task syz-fuzzer/9751 Reported-by: syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com Fixes: 6c08fc896b60 ("Bluetooth: Fix refcount use-after-free issue") Cc: Manish Mandlik <mmandlik@google.com> Signed-off-by: Hillf Danton <hdanton@sina.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_sock.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 3db8cfebd069a..bbf08c6092f4a 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1189,6 +1189,7 @@ static int l2cap_sock_release(struct socket *sock) { struct sock *sk = sock->sk; int err; + struct l2cap_chan *chan; BT_DBG("sock %p, sk %p", sock, sk); @@ -1198,15 +1199,16 @@ static int l2cap_sock_release(struct socket *sock) bt_sock_unlink(&l2cap_sk_list, sk); err = l2cap_sock_shutdown(sock, 2); + chan = l2cap_pi(sk)->chan; - l2cap_chan_hold(l2cap_pi(sk)->chan); - l2cap_chan_lock(l2cap_pi(sk)->chan); + l2cap_chan_hold(chan); + l2cap_chan_lock(chan); sock_orphan(sk); l2cap_sock_kill(sk); - l2cap_chan_unlock(l2cap_pi(sk)->chan); - l2cap_chan_put(l2cap_pi(sk)->chan); + l2cap_chan_unlock(chan); + l2cap_chan_put(chan); return err; } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aHaSAtwoZF8SngAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:26:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id GFQbANwoZF8ctAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:26:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CFAEBA0B6D; Fri, 18 Sep 2020 05:26:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729150AbgIRCf6 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:35:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:39852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728178AbgIRCND (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:13:03 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3A73B235F9; Fri, 18 Sep 2020 02:13:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395182; bh=DnEVwHe95iuDar6dwC4IkLtb9vIytDLEf0tS0ySNkoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RONVfdQiLH8FdAYc6/ch02iiLrNDiCPcK47pYr0wuUilX96EENT6QNt8vLxoizKqA konc3Z5qIA7NHlOvAVyL9nNQOlw1p/0kI9sDWJSl16yzWlSQ5RdnJNXpFC7NjZT3R/ HrbMEyuNyl/DOl8dhjuDDIAyRVhpKNsd/7YLaIoY= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Manish Mandlik <mmandlik@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 037/127] Bluetooth: Fix refcount use-after-free issue Date: Thu, 17 Sep 2020 22:10:50 -0400 Message-Id: <20200918021220.2066485-37-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021220.2066485-1-sashal@kernel.org> References: <20200918021220.2066485-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.99 / 15.00 / 15.00 X-Rspamd-Queue-Id: CFAEBA0B6D X-Rspamd-UID: 73e209 From: Manish Mandlik <mmandlik@google.com> [ Upstream commit 6c08fc896b60893c5d673764b0668015d76df462 ] There is no lock preventing both l2cap_sock_release() and chan->ops->close() from running at the same time. If we consider Thread A running l2cap_chan_timeout() and Thread B running l2cap_sock_release(), expected behavior is: A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill() where, sock_orphan() clears "sk->sk_socket" and l2cap_sock_teardown_cb() marks socket as SOCK_ZAPPED. In l2cap_sock_kill(), there is an "if-statement" that checks if both sock_orphan() and sock_teardown() has been run i.e. sk->sk_socket is NULL and socket is marked as SOCK_ZAPPED. Socket is killed if the condition is satisfied. In the race condition, following occurs: A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill() In this scenario, "if-statement" is true in both B::l2cap_sock_kill() and A::l2cap_sock_kill() and we hit "refcount: underflow; use-after-free" bug. Similar condition occurs at other places where teardown/sock_kill is happening: l2cap_disconnect_rsp()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_rsp()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_conn_del()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_conn_del()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_disconnect_req()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_req()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_sock_cleanup_listen()->l2cap_chan_close()->l2cap_sock_teardown_cb() l2cap_sock_cleanup_listen()->l2cap_sock_kill() Protect teardown/sock_kill and orphan/sock_kill by adding hold_lock on l2cap channel to ensure that the socket is killed only after marked as zapped and orphan. Signed-off-by: Manish Mandlik <mmandlik@google.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_core.c | 26 +++++++++++++++----------- net/bluetooth/l2cap_sock.c | 16 +++++++++++++--- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index ebdf1b0e576a5..97175cddb1e04 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -414,6 +414,9 @@ static void l2cap_chan_timeout(struct work_struct *work) BT_DBG("chan %p state %s", chan, state_to_string(chan->state)); mutex_lock(&conn->chan_lock); + /* __set_chan_timer() calls l2cap_chan_hold(chan) while scheduling + * this work. No need to call l2cap_chan_hold(chan) here again. + */ l2cap_chan_lock(chan); if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) @@ -426,12 +429,12 @@ static void l2cap_chan_timeout(struct work_struct *work) l2cap_chan_close(chan, reason); - l2cap_chan_unlock(chan); - chan->ops->close(chan); - mutex_unlock(&conn->chan_lock); + l2cap_chan_unlock(chan); l2cap_chan_put(chan); + + mutex_unlock(&conn->chan_lock); } struct l2cap_chan *l2cap_chan_create(void) @@ -1725,9 +1728,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) l2cap_chan_del(chan, err); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); } @@ -4337,6 +4340,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, return 0; } + l2cap_chan_hold(chan); l2cap_chan_lock(chan); rsp.dcid = cpu_to_le16(chan->scid); @@ -4345,12 +4349,11 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, chan->ops->set_shutdown(chan); - l2cap_chan_hold(chan); l2cap_chan_del(chan, ECONNRESET); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); @@ -4382,20 +4385,21 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, return 0; } + l2cap_chan_hold(chan); l2cap_chan_lock(chan); if (chan->state != BT_DISCONN) { l2cap_chan_unlock(chan); + l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); return 0; } - l2cap_chan_hold(chan); l2cap_chan_del(chan, 0); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 8c329c549ea60..a5e618add17f4 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1040,7 +1040,7 @@ done: } /* Kill socket (only if zapped and orphan) - * Must be called on unlocked socket. + * Must be called on unlocked socket, with l2cap channel lock. */ static void l2cap_sock_kill(struct sock *sk) { @@ -1201,8 +1201,15 @@ static int l2cap_sock_release(struct socket *sock) err = l2cap_sock_shutdown(sock, 2); + l2cap_chan_hold(l2cap_pi(sk)->chan); + l2cap_chan_lock(l2cap_pi(sk)->chan); + sock_orphan(sk); l2cap_sock_kill(sk); + + l2cap_chan_unlock(l2cap_pi(sk)->chan); + l2cap_chan_put(l2cap_pi(sk)->chan); + return err; } @@ -1220,12 +1227,15 @@ static void l2cap_sock_cleanup_listen(struct sock *parent) BT_DBG("child chan %p state %s", chan, state_to_string(chan->state)); + l2cap_chan_hold(chan); l2cap_chan_lock(chan); + __clear_chan_timer(chan); l2cap_chan_close(chan, ECONNRESET); - l2cap_chan_unlock(chan); - l2cap_sock_kill(sk); + + l2cap_chan_unlock(chan); + l2cap_chan_put(chan); } } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yGNUAiM8ZF9G7wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 06:48:35 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id eMkFOyI8ZF8jZAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 06:48:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id ECCBF40963; Fri, 18 Sep 2020 06:48:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730599AbgIRDIW (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 23:08:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:49898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727099AbgIRCDb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:03:31 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 50A6C2376F; Fri, 18 Sep 2020 02:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394611; bh=KYttkS2Umz7dHsgslJdO4PLnHstjNvLIcBm6I8m1c2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mce3ditgCxWM0INVbRznGIC5m9W9elP0MmpL6PzEze2wm9ZLNOnXpp02WSKGyXDQ4 2S9hdo5j71VDxBF0a/vF0A9n8YzuETJvMwEHhPQJ1QjgbEvxlbNt14Gv5HSFNdCBU3 5W8ynox64IMMly7auWUt0k1RQxjqoZBfpcHNWae4= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hillf Danton <hdanton@sina.com>, syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com, Manish Mandlik <mmandlik@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 114/330] Bluetooth: prefetch channel before killing sock Date: Thu, 17 Sep 2020 21:57:34 -0400 Message-Id: <20200918020110.2063155-114-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.01 / 15.00 / 15.00 X-Rspamd-Queue-Id: ECCBF40963 X-Rspamd-UID: 514bb2 From: Hillf Danton <hdanton@sina.com> [ Upstream commit 2a154903cec20fb64ff4d7d617ca53c16f8fd53a ] Prefetch channel before killing sock in order to fix UAF like BUG: KASAN: use-after-free in l2cap_sock_release+0x24c/0x290 net/bluetooth/l2cap_sock.c:1212 Read of size 8 at addr ffff8880944904a0 by task syz-fuzzer/9751 Reported-by: syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com Fixes: 6c08fc896b60 ("Bluetooth: Fix refcount use-after-free issue") Cc: Manish Mandlik <mmandlik@google.com> Signed-off-by: Hillf Danton <hdanton@sina.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_sock.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index ab65304f3f637..390a9afab6473 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1193,6 +1193,7 @@ static int l2cap_sock_release(struct socket *sock) { struct sock *sk = sock->sk; int err; + struct l2cap_chan *chan; BT_DBG("sock %p, sk %p", sock, sk); @@ -1202,15 +1203,16 @@ static int l2cap_sock_release(struct socket *sock) bt_sock_unlink(&l2cap_sk_list, sk); err = l2cap_sock_shutdown(sock, 2); + chan = l2cap_pi(sk)->chan; - l2cap_chan_hold(l2cap_pi(sk)->chan); - l2cap_chan_lock(l2cap_pi(sk)->chan); + l2cap_chan_hold(chan); + l2cap_chan_lock(chan); sock_orphan(sk); l2cap_sock_kill(sk); - l2cap_chan_unlock(l2cap_pi(sk)->chan); - l2cap_chan_put(l2cap_pi(sk)->chan); + l2cap_chan_unlock(chan); + l2cap_chan_put(chan); return err; } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sMZeFlk8ZF9M8QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 06:49:29 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CCvTElk8ZF8jZAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 06:49:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E36FE40886; Fri, 18 Sep 2020 06:49:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727593AbgIRDIx (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 23:08:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:49290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbgIRCDQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:03:16 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1F37A2311A; Fri, 18 Sep 2020 02:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394595; bh=45ox9onnmbXiXm6UdydB2JxE3ku3xC/QAXT2+dTKYKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X2WpcrHhs7nDl2+jbxry5raPqKtts0rXtH9m8kysHWqmeQJECbyB7qlVUPh29OkGp wFMCqFcWMa7nKDhT62K6tPRXcdxPMXppD0pSQPpPPpf0DKj8VDTNJHKmmXB84MDpxZ F+nB82f9gYofvO40S57GMU+F+5YumHd6Xjwib2gw= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Maxim Mikityanskiy <maxtram95@gmail.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 103/330] Bluetooth: btrtl: Use kvmalloc for FW allocations Date: Thu, 17 Sep 2020 21:57:23 -0400 Message-Id: <20200918020110.2063155-103-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.83 / 15.00 / 15.00 X-Rspamd-Queue-Id: E36FE40886 X-Rspamd-UID: fd5c4c From: Maxim Mikityanskiy <maxtram95@gmail.com> [ Upstream commit 268d3636dfb22254324774de1f8875174b3be064 ] Currently, kmemdup is applied to the firmware data, and it invokes kmalloc under the hood. The firmware size and patch_length are big (more than PAGE_SIZE), and on some low-end systems (like ASUS E202SA) kmalloc may fail to allocate a contiguous chunk under high memory usage and fragmentation: Bluetooth: hci0: RTL: examining hci_ver=06 hci_rev=000a lmp_ver=06 lmp_subver=8821 Bluetooth: hci0: RTL: rom_version status=0 version=1 Bluetooth: hci0: RTL: loading rtl_bt/rtl8821a_fw.bin kworker/u9:2: page allocation failure: order:4, mode:0x40cc0(GFP_KERNEL|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0 <stack trace follows> As firmware load happens on each resume, Bluetooth will stop working after several iterations, when the kernel fails to allocate an order-4 page. This patch replaces kmemdup with kvmalloc+memcpy. It's not required to have a contiguous chunk here, because it's not mapped to the device directly. Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/bluetooth/btrtl.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index bf3c02be69305..0dfaf90a31b06 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -370,11 +370,11 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev, * the end. */ len = patch_length; - buf = kmemdup(btrtl_dev->fw_data + patch_offset, patch_length, - GFP_KERNEL); + buf = kvmalloc(patch_length, GFP_KERNEL); if (!buf) return -ENOMEM; + memcpy(buf, btrtl_dev->fw_data + patch_offset, patch_length - 4); memcpy(buf + patch_length - 4, &epatch_info->fw_version, 4); *_buf = buf; @@ -460,8 +460,10 @@ static int rtl_load_file(struct hci_dev *hdev, const char *name, u8 **buff) if (ret < 0) return ret; ret = fw->size; - *buff = kmemdup(fw->data, ret, GFP_KERNEL); - if (!*buff) + *buff = kvmalloc(fw->size, GFP_KERNEL); + if (*buff) + memcpy(*buff, fw->data, ret); + else ret = -ENOMEM; release_firmware(fw); @@ -499,14 +501,14 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, goto out; if (btrtl_dev->cfg_len > 0) { - tbuff = kzalloc(ret + btrtl_dev->cfg_len, GFP_KERNEL); + tbuff = kvzalloc(ret + btrtl_dev->cfg_len, GFP_KERNEL); if (!tbuff) { ret = -ENOMEM; goto out; } memcpy(tbuff, fw_data, ret); - kfree(fw_data); + kvfree(fw_data); memcpy(tbuff + ret, btrtl_dev->cfg_data, btrtl_dev->cfg_len); ret += btrtl_dev->cfg_len; @@ -519,14 +521,14 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, ret = rtl_download_firmware(hdev, fw_data, ret); out: - kfree(fw_data); + kvfree(fw_data); return ret; } void btrtl_free(struct btrtl_device_info *btrtl_dev) { - kfree(btrtl_dev->fw_data); - kfree(btrtl_dev->cfg_data); + kvfree(btrtl_dev->fw_data); + kvfree(btrtl_dev->cfg_data); kfree(btrtl_dev); } EXPORT_SYMBOL_GPL(btrtl_free); -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +Ct/EU4+ZF9M8QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 06:57:50 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id UKpCDk4+ZF9qMQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 06:57:50 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E20B540962; Fri, 18 Sep 2020 06:57:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730717AbgIRDMg (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 23:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730648AbgIRDMg (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 23:12:36 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B373C061788 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:36 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id z4so2644548pgv.13 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=KBETbgHJRtwnWH3QRJ6V38Ec73b7Ro5YQIkQRswxAOg=; b=sqSOkvYdQz0bLJ85GB4EkovT6jlCCmlYEykWUeBxoQxZA4PlVZLmXwmB9i0onbdqit TTcX45XhJsaUfG7wH/eEFLawfOd90wTVbPeRPPTVVsLi6IUD8zOmcKlgEAFV9HkRHewj BJtTcn/8/2cfKBeXjQWNw8cj+bAOXpOBIy9UydMmEqeldzNUZpqkWliHFoKUvmtmNnh0 KNAfjKcpwLMaK/Vcr1+LE+6p7l8Ux6YsrJWs0ZNTI0hWF67rhKkCe4TNFWCphrlTtQ/q wmxo9aBYsaxvi2hHYU5RBQS2YYT2WHUoZT63zBrWSsmWKEx+qZFlnm5O3PCQkE7FWYst wSFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=KBETbgHJRtwnWH3QRJ6V38Ec73b7Ro5YQIkQRswxAOg=; b=pdvWHoLDxV5P8d55sBjiz4473pAInxS+NSXyUgD56b9GP4ncivR1IwS0EhPLOHryh7 gbqPXD/BQgWrupHnrEjRK9XqNzJyG6Hy0BODlznwhAJmAkESzE9YfMdCsh4knznQZSaQ bIWvcLOd+MlXcgNwnORsuNnP5v5sOYO9t+nni3XXtdT69kPqhgvGeseJB6oCxZ/1+r+U AHy7bpI/ppoBMjL2HHrr3WBGHHRPalcVW6p5fMzSrMjgJyT9KzbEtEjlCl6TRUjSD+IZ FkrhRBOBVmGSuF9Mupt2VNaOMNgh6oN3O3JShTrA5SnCjuVqKUze+eQmiGvvciM86rwV +9vA== X-Gm-Message-State: AOAM530tfCeE/SJBVsz3LVo8mzOHIb+qq3cYw4vQ4XM5ZfyVvO0uASeA ssz3ulWa6ZBalrcYLXn6wUck1Dg9nFa5tCmtlarFbh8ph5m68jOmc+MqKeuLOeusqp9Ig/ZO0hV NizDaqN8ARpH/PshGrm6/aaXvAdZ+B6Al3jwnRY2ix+uv0pvolCS3dYpMHj5qgyc601oCioaK2+ 9YNI9XXlzL5X0= X-Google-Smtp-Source: ABdhPJz8q7ZaKm9V2VZgpVb0caX5/T86owruSV8FapB6awBhiGaDKFzEi9cDhWtCM33XZJuEpv7O3wO5dzIPRdwnVw== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:902:a712:b029:d1:cbf4:c583 with SMTP id w18-20020a170902a712b02900d1cbf4c583mr20479592plq.16.1600398755362; Thu, 17 Sep 2020 20:12:35 -0700 (PDT) Date: Fri, 18 Sep 2020 11:11:52 +0800 In-Reply-To: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200918111110.v3.5.I21e5741249e78c560ca377499ba06b56c7214985@changeid> Mime-Version: 1.0 References: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 5/6] Bluetooth: Handle active scan case From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: howardchung@google.com, luiz.dentz@gmail.com, marcel@holtmann.org, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.20 / 15.00 / 15.00 X-Rspamd-Queue-Id: E20B540962 X-Rspamd-UID: 00f6ea This patch adds code to handle the active scan during interleave scan. The interleave scan will be canceled when users start active scan, and it will be restarted after active scan stopped. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) net/bluetooth/hci_request.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index d9082019b6386..1fcf6736811e4 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -3085,8 +3085,10 @@ static int active_scan(struct hci_request *req, unsigned long opt) * running. Thus, we should temporarily stop it in order to set the * discovery scanning parameters. */ - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { hci_req_add_le_scan_disable(req, false); + cancel_interleave_scan(hdev); + } /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WKviAGA+ZF9b9gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 06:58:08 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 2FmeOV8+ZF+w5gAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 06:58:07 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8E97240675; Fri, 18 Sep 2020 06:58:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729614AbgIRDMq (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 23:12:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727249AbgIRDMk (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 23:12:40 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0794EC061788 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:40 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 140so2820483ybf.2 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=64ZOoFGaOH0m/cPAtUtUGXYMPXoup8s7otAhkDt2H3M=; b=UEW/Lh9lpl7cJQgrlAzxT3Ymbi9kik5IAj7EVI1GY2T6uE0YvsPwYWJedj5Yjddxb2 Nf9za12XPUpgMNJbYMg3nxYfm7tIUa4E4ybFE5NmmN662fd1cbc8aIWNfJTGDeVCo9Wq 1WJwF/8g5Ie4JkrEp9yIEza/HU17XBEhrMrcZRi+O9Jy9X/8DLPtjMbgX1ooTVXaYZ9G 9BkQbDFFUO3xE+c8n671VgQ1E2yeVtyvKvMHC2aqjootukqzQUqvzZd7GwT9bLVII80l GbNwo30YIeEqvnUnUiLC8wEkHkGFP8RAbeLu0YLLKHJRU6RYHFMxIIgwCRY3z2vSxCxk iZxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=64ZOoFGaOH0m/cPAtUtUGXYMPXoup8s7otAhkDt2H3M=; b=CTQOMuOXQwPTPEDfprVN3ynKOJGXyQv0omWUBWsDEBToFZJlFc1lshuuMTeO2wMcI1 obnI6+Z6VBZwgn9E9qRJOeloUBYnS3va1/eptWo52VoL+B6MhSVB3sQ0xPbktyhdLavG fPTxLIXuWjiga5sMD1KuRbNYunJjYyg4o+wCFwYSuPAjTpSHa4y7EZGBQu9vbYxEzEsN qvOJH/sGVZ+uiLQZFqhiw7/OnU7jXpfy4Xhm+vgZhuCNnVbuVnLXVJUqfVkQQuT4q9j4 joGCoukp78ATUI/QJmukZVjYbZCgJ/B5NNQNeNWiQwEVDdgfY9D3/G1BOJ2i4mJi4oOG EZ/Q== X-Gm-Message-State: AOAM530hSVTRAzEQbkGeLxYGvJAgVWwJ1w4gopH6kM8M8RX36mMe8ac9 OILhFQ+CAkARZ4rVU1noqOabfeJ66YF4XAwX9Gw0sUiufxcjxRN4Q2lPTdQstNWqpr2hFTL7Yrn wUncylwn7tDUSTStlDtK8m0WyPme7ivRtld/vCrXquXqj5ZyYWAXlmGCob2UtQpEf9v71rHSc7l h87bwYrXOM/fE= X-Google-Smtp-Source: ABdhPJxxoVj4sVwb3Pqb1zFKEUNanXR2/70HGloVVRNpSIBlL1Bw+Xd+ataxUCDEF5kqhDcJIjajKb/vuIQfOrUh9A== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a25:d408:: with SMTP id m8mr41594928ybf.204.1600398759153; Thu, 17 Sep 2020 20:12:39 -0700 (PDT) Date: Fri, 18 Sep 2020 11:11:53 +0800 In-Reply-To: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200918111110.v3.6.I756c1fecc03bcc0cd94400b4992cd7e743f4b3e2@changeid> Mime-Version: 1.0 References: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 6/6] Bluetooth: Add toggle to switch off interleave scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: howardchung@google.com, luiz.dentz@gmail.com, marcel@holtmann.org, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.95 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8E97240675 X-Rspamd-UID: a2be20 This patch add a configurable parameter to switch off the interleave scan feature. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> --- (no changes since v1) include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 1 + net/bluetooth/hci_request.c | 3 ++- net/bluetooth/mgmt_config.c | 6 ++++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 179350f869fdb..c3253f1cac0c2 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -363,6 +363,7 @@ struct hci_dev { __u32 clock; __u16 advmon_allowlist_duration; __u16 advmon_no_filter_duration; + __u16 enable_advmon_interleave_scan; __u16 devid_source; __u16 devid_vendor; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6c8850149265a..4608715860cce 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3595,6 +3595,7 @@ struct hci_dev *hci_alloc_dev(void) /* The default values will be chosen in the future */ hdev->advmon_allowlist_duration = 300; hdev->advmon_no_filter_duration = 500; + hdev->enable_advmon_interleave_scan = 0x0001; /* Default to enable */ hdev->sniff_max_interval = 800; hdev->sniff_min_interval = 80; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 1fcf6736811e4..bb38e1dead68f 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -500,7 +500,8 @@ static void __hci_update_background_scan(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) hci_req_add_le_scan_disable(req, false); - if (!update_adv_monitor_scan_state(hdev)) { + if (!hdev->enable_advmon_interleave_scan || + !update_adv_monitor_scan_state(hdev)) { hci_req_add_le_passive_scan(req); bt_dev_dbg(hdev, "%s starting background scanning", hdev->name); diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index 1802f7023158c..b4198c33a1b72 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -69,6 +69,7 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, def_le_autoconnect_timeout), HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), + HDEV_PARAM_U16(0x001f, enable_advmon_interleave_scan), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -142,6 +143,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x001b: case 0x001d: case 0x001e: + case 0x001f: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -263,6 +265,10 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, hdev->advmon_no_filter_duration = TLV_GET_LE16(buffer); break; + case 0x0001f: + hdev->enable_advmon_interleave_scan = + TLV_GET_LE16(buffer); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cB34FbcrZF90rwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:38:31 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id wHJGE7crZF+pkAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:38:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B9769A0170; Fri, 18 Sep 2020 05:38:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728603AbgIRCLT (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:11:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:36670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728601AbgIRCLR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:11:17 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A86C208DB; Fri, 18 Sep 2020 02:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395076; bh=wsW5bWA/0d2aGuBI+3kVFdiUF693X8BFYmlHJZMNYUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YAxiUro4qiFqMv0n7xqdO+0PAJhBQ+6jfHYC1jUf3VuiAu01DSdAyYsZiw8NG+Yrz iiLf7YXKhh+hHiEfdkBmpBTkC2B7BbqAc0v8SLBXbtGzyq6e0qCRyVBGdIzYDXMPw1 uzLWO1mAIBIDe4vEBOi9L1mqx3uH2DMs+gbKjDtI= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 160/206] Bluetooth: Handle Inquiry Cancel error after Inquiry Complete Date: Thu, 17 Sep 2020 22:07:16 -0400 Message-Id: <20200918020802.2065198-160-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020802.2065198-1-sashal@kernel.org> References: <20200918020802.2065198-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: B9769A0170 X-Rspamd-UID: 97e2a6 From: Sonny Sasaka <sonnysasaka@chromium.org> [ Upstream commit adf1d6926444029396861413aba8a0f2a805742a ] After sending Inquiry Cancel command to the controller, it is possible that Inquiry Complete event comes before Inquiry Cancel command complete event. In this case the Inquiry Cancel command will have status of Command Disallowed since there is no Inquiry session to be cancelled. This case should not be treated as error, otherwise we can reach an inconsistent state. Example of a btmon trace when this happened: < HCI Command: Inquiry Cancel (0x01|0x0002) plen 0 > HCI Event: Inquiry Complete (0x01) plen 1 Status: Success (0x00) > HCI Event: Command Complete (0x0e) plen 4 Inquiry Cancel (0x01|0x0002) ncmd 1 Status: Command Disallowed (0x0c) Signed-off-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/hci_event.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index ec6b3a87b3e7f..310622086f74b 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -41,12 +41,27 @@ /* Handle HCI Event packets */ -static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) +static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb, + u8 *new_status) { __u8 status = *((__u8 *) skb->data); BT_DBG("%s status 0x%2.2x", hdev->name, status); + /* It is possible that we receive Inquiry Complete event right + * before we receive Inquiry Cancel Command Complete event, in + * which case the latter event should have status of Command + * Disallowed (0x0c). This should not be treated as error, since + * we actually achieve what Inquiry Cancel wants to achieve, + * which is to end the last Inquiry session. + */ + if (status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { + bt_dev_warn(hdev, "Ignoring error of Inquiry Cancel command"); + status = 0x00; + } + + *new_status = status; + if (status) return; @@ -3039,7 +3054,7 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, switch (*opcode) { case HCI_OP_INQUIRY_CANCEL: - hci_cc_inquiry_cancel(hdev, skb); + hci_cc_inquiry_cancel(hdev, skb, status); break; case HCI_OP_PERIODIC_INQ: -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +Cl/GGQ+ZF9b9gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 06:58:12 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id mCcXFWQ+ZF/NsgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 06:58:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1934A40875; Fri, 18 Sep 2020 06:58:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730071AbgIRDMe (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 23:12:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730621AbgIRDMU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 23:12:20 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F202C061756 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:20 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id y10so2555659pll.6 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=NxYLZaP4aGvAu+/UZ2/LCTJAGtRN+euo/YJvY78SnJI=; b=lPnbMx9MR7LP0g8yYqS8XX8PwdhoCbJLqS3Z0Z0JtuxwszJ9u0TKgULzYiNZpjdWBD 1pFWEgRbhds1BOQrRuitu8mMEDBNDuwU5LUhPPic6Zb0Oe8Cu9IUv4vX3N4HXaUTsqWN E3tLAgY5ThRFLx8JC8AtkuxBczzVFBpbeZu2koExJJHkSA5JVsuSRZSxuttC7ewNIl7W Yj4EwfyVNTayTJoqCUaNoujn8oMQLgP+QxsxmxT8TnmsrLc3wbbV03nlr+a1oxwen8aE Q7X003JemibbmOX6Tn5rBhnHC1uMggGUYmpZwFiCSGp9jwbAzfgo7EOJs9om+YsJ684o FBnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=NxYLZaP4aGvAu+/UZ2/LCTJAGtRN+euo/YJvY78SnJI=; b=HV4qUU0ntIzVYbvT7nEnsQkJ2XwucCMIjwYyNsQl9qXL8qxzGNyTewCZa+UpEX4hey obCCI6KscZjd1eMddp9x4gOqCjNfosNVGZ1mx1TC29hr7GMkdi0DaahKo1GPfhOPpYOj iq1kFVBvpIw8pJG7cKY1ZKszA6n9Gzh9p+8LX+SstPj8CWN2vbzg+SLBTK6GVt86W+Ws TMOfQD5KJ+5hkMOoNruWH2VKQmJJ27JXnDZdyhJ0AMmcmIhIniO2u9gHfvA2ptlLpcwr 3tk2OO9oSYQYMgBQiKK+g652QUMlEHpEDSuxdu3z+RStn0Ejho1tk8/KCsbePgmVNCHZ L62w== X-Gm-Message-State: AOAM530B23Ob4AdS4TgaoCmwjeGzUYb5EXywmdLxqfRnAexzj/mBX1Bi hwuIWoX9YhUx2nwq+FyMbYg3BBsEf5NlLKxv760H5l5HLeDdfOWYl6AIi2hUhIWlKSJPlfcpKqW qUg6Lp9mHywypmktxiKchOFSXd9HEaxLSwuZyPm3hjnvYNFayR4Xpr/1DKoaux0+ausyjlEC3zB LVLyNFEp8ceS0= X-Google-Smtp-Source: ABdhPJx6kM5DLLFGf2usi1qL12z1S/m8Hsz6v1BbQkAwPJVD0ivhgJmBq+H071e/KejErTX27f7V9MxscFhrpmdfXg== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:aa7:8583:0:b029:13f:7096:5eb with SMTP id w3-20020aa785830000b029013f709605ebmr30016944pfn.0.1600398739505; Thu, 17 Sep 2020 20:12:19 -0700 (PDT) Date: Fri, 18 Sep 2020 11:11:48 +0800 Message-Id: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 1/6] Bluetooth: Update Adv monitor count upon removal From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: howardchung@google.com, luiz.dentz@gmail.com, marcel@holtmann.org, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.00 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1934A40875 X-Rspamd-UID: 5cbc82 From: Miao-chen Chou <mcchou@chromium.org> This fixes the count of Adv monitor upon monitor removal. The following test was performed. - Start two btmgmt consoles, issue a btmgmt advmon-remove command on one console and observe a MGMT_EV_ADV_MONITOR_REMOVED event on the other. Signed-off-by: Miao-chen Chou <mcchou@chromium.org> Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v3: - Remove 'Bluez' prefix Changes in v2: - delete 'case 0x001c' in mgmt_config.c net/bluetooth/hci_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 8a2645a833013..f30a1f5950e15 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3061,6 +3061,7 @@ static int free_adv_monitor(int id, void *ptr, void *data) idr_remove(&hdev->adv_monitors_idr, monitor->handle); hci_free_adv_monitor(monitor); + hdev->adv_monitors_cnt--; return 0; } @@ -3077,6 +3078,7 @@ int hci_remove_adv_monitor(struct hci_dev *hdev, u16 handle) idr_remove(&hdev->adv_monitors_idr, monitor->handle); hci_free_adv_monitor(monitor); + hdev->adv_monitors_cnt--; } else { /* Remove all monitors if handle is 0. */ idr_for_each(&hdev->adv_monitors_idr, &free_adv_monitor, hdev); -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +CVPLmg+ZF94/AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 06:58:16 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id UJmCKmg+ZF/NsgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 06:58:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 776CD40873; Fri, 18 Sep 2020 06:58:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbgIRDM6 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 23:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729460AbgIRDMc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 23:12:32 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E66DCC06178C for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:23 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id w8so841001qvt.18 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=2XmRDQUdgiUCXLjgBSHndxfu/U3AL11i4Ub5lRoe7R0=; b=tzX8w74Fl69bkT1fuRekk3Yej9sz1p+sVINXDr737cRNWeMl+XLBVOK2a2H0/gbs18 Uteg1+HYcXiSdUfhbnQicvFRotx4pj43Yc4fW36tr8Heiz4fRD8sQpYKYSvllygVcd0A xkuT05qTA+JmIK5f05enmUZ28D5g3H9MHYFzxpZpBaDdUSpx7BYg+gM4Yw3d88FLJ1ms +Vx9hoczHxmCaA1IKAcuAWej+DHGVqZm/4w+QsYhlF6k3BQ5dr8m3Yfy+IR0h4u/6xkd dq4v9k/P82oknrNxUTpZMex+uiAB60T391HA8RB0MOdr02Im6N06aKG0sZmsi2N5CYBz 9SLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=2XmRDQUdgiUCXLjgBSHndxfu/U3AL11i4Ub5lRoe7R0=; b=J7uD2fOxDga5/o5EjHz+haH4utOtEDszGdd3iUunII1OiuG+VnV+FrmW4MEh0qyOZn oyDk+klw2g0xWC49S2I9eReD0LD9yf7O8DaG0m3+DQW2iDLb1Oo+XLCVn+OVjagyluPi t+PJg2MI3n1e6H7lAr+Ef7xob6eX46QKekKv65kveeMwRS3hTMTnFYktlQMKO4CI1Lhr pZsar832hCI2MeT8Dc9bfpyu3FSg2Arbb+W61F0vPOCcV9Cn/DGzFIGq47p6eHo3yeFe 3SxaVvUR/0+JDES0YoI0UtQgBmUZE3ovGhNwAdDUglL04/vDL/cSVwEMK/54s22OyEXP uAkQ== X-Gm-Message-State: AOAM530NGBVqChc6c41E3t/ImYjp5IxpfGTMK540pd/PbSyQ6LQAiCGE fwDySJndPqrdft5ibcBwSnad7JlViRhKQvTu0jVRpuErX8bLa6Ym/FpV9HR1JVJ+PKuiKScHjDF bpvnmEbWZ8GnfXz84mI18NqTNEAd/43msSpiXpA6X5rLkaYbncLeV5CEIylZCvJKlA2FHFzqQfw C8tE+cmpogjVc= X-Google-Smtp-Source: ABdhPJwmWJFJNTTBFBXGPrIZyuSqnx1dWqO6oAbGMDrw5KopjYBA2KwiHRZ355u4CWsVx/4UV2f90s26M6BxkZjhrg== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:458f:: with SMTP id x15mr15602557qvu.33.1600398742980; Thu, 17 Sep 2020 20:12:22 -0700 (PDT) Date: Fri, 18 Sep 2020 11:11:49 +0800 In-Reply-To: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200918111110.v3.2.I8aafface41460f81241717da0498419a533bd165@changeid> Mime-Version: 1.0 References: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 2/6] Bluetooth: Set scan parameters for ADV Monitor From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: howardchung@google.com, luiz.dentz@gmail.com, marcel@holtmann.org, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.29 / 15.00 / 15.00 X-Rspamd-Queue-Id: 776CD40873 X-Rspamd-UID: 979bf4 Set scan parameters when there is at least one Advertisement monitor. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- (no changes since v1) net/bluetooth/hci_request.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 413e3a5aabf54..d2b06f5c93804 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1027,6 +1027,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) } else if (hci_is_le_conn_scanning(hdev)) { window = hdev->le_scan_window_connect; interval = hdev->le_scan_int_connect; + } else if (hci_is_adv_monitoring(hdev)) { + window = hdev->le_scan_window_adv_monitor; + interval = hdev->le_scan_int_adv_monitor; } else { window = hdev->le_scan_window; interval = hdev->le_scan_interval; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QBNhBX8+ZF94/AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 06:58:39 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id KMrnAn8+ZF/a/wEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 06:58:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1247B40675; Fri, 18 Sep 2020 06:58:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726929AbgIRDM5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 23:12:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727448AbgIRDMc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 23:12:32 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62592C061352 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:28 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id i23so2139951pju.7 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=4GRQWsNIU/jHenWW4ZCuq5mW13v+1sfrQU9SoQzG2J0=; b=UDvmc0hClOv6DA9fjtWBIVx/f4NGl8Hn/m6zpMwklLW5CxFOqyyYAg1kQ9S4pPhTOU BJkKoWKuZwgPwgRA0V5ZXNhRUxvMUuZptpWTie8fslPbrGxnDC8Dz1mWCCfBJmIWV5L1 3m9gTAMjQEc+nEXGgmeBLQv3Ki9sg0gh9Zh5AzDlPw438y+EL3tbSbQIDnTIMzEQNGFB QVgKfyHXft/xfGtOoUjbUhaH08wT099ALKGLybBtBtaKE8cnni6r32Uhv0mCGOu7xXT4 0KVMwb68tQWovMDyN+dm7//mvTF4u22oUmqEKdR2/K5pgYsZY3y8cQfdUAC82TJteXUO y0zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=4GRQWsNIU/jHenWW4ZCuq5mW13v+1sfrQU9SoQzG2J0=; b=Q5mgxuPQ/tLMzsfmZH78sfsWeiRiIAF7IjnKrmEZU5kKPtL/5JJzmrpanKIQI/3QPM 2GWjV+6Rx0L2gpC2XlNUI77x1oNN8Jeu+dRq8U5Q9kuk5xj5novjDNMsu3PgZ7rtjFTx L1wXRO+ZRfVv8YQtcDri1tOg11RtA9PROMfJgdgDfzj0ZxsO3W5Xdy1Y8qm+pE4LfLOx 7Bq286AMTn6PkU9plrerJp5VGL7XDqLAcAmWYlCPyMOOOqo4WowheD6An8SiCoyY9Gdy At/0CAZUfOYOwBZQtXlZ/nYRQ5CEvHkPykzogMJ5yXpk8VLRNfoWwkyP9wYU6VPDQIr9 fBvg== X-Gm-Message-State: AOAM533PxkreZpLQy8qtOklQh3OFmzT8yqOoQQbSPUUDzofuJbdhp3ls mIGPJDXW1q3ko1Q8oDrrXJ0MWc2tsuMTWF9Ll8lI6S7oBvy8M0a5RqNpp8wgkNl5XJMuC+gBYi/ x3R8bWF+LvJfs0/g6QstTjcN8haTWXJEMpBpvsTwExEXhh7PugfjiNKS02oBQZE1ACCVe3XM07T 5/Ks2tbBkiHYc= X-Google-Smtp-Source: ABdhPJxqqi3wQROOSi27aaMQ2ONVuXz2bsdhQuvgA/j+eQbQneLGal7/WUPGOYcfTSZwxJ9yo2F+PmkVLUKGKidRhg== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:90b:15c6:: with SMTP id lh6mr207164pjb.0.1600398746992; Thu, 17 Sep 2020 20:12:26 -0700 (PDT) Date: Fri, 18 Sep 2020 11:11:50 +0800 In-Reply-To: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200918111110.v3.3.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Mime-Version: 1.0 References: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 3/6] Bluetooth: Interleave with allowlist scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: howardchung@google.com, luiz.dentz@gmail.com, marcel@holtmann.org, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.71 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1247B40675 X-Rspamd-UID: ff1666 This patch implements the interleaving between allowlist scan and no-filter scan. It'll be used to save power when at least one monitor is registered and at least one pending connection or one device to be scanned for. The durations of the allowlist scan and the no-filter scan are controlled by MGMT command: Set Default System Configuration. The default values are set randomly for now. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v2) Changes in v2: - remove 'case 0x001c' in mgmt_config.c include/net/bluetooth/hci_core.h | 10 +++ net/bluetooth/hci_core.c | 4 + net/bluetooth/hci_request.c | 137 +++++++++++++++++++++++++++++-- net/bluetooth/mgmt_config.c | 12 +++ 4 files changed, 155 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9873e1c8cd163..179350f869fdb 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -361,6 +361,8 @@ struct hci_dev { __u8 ssp_debug_mode; __u8 hw_error_code; __u32 clock; + __u16 advmon_allowlist_duration; + __u16 advmon_no_filter_duration; __u16 devid_source; __u16 devid_vendor; @@ -542,6 +544,14 @@ struct hci_dev { struct delayed_work rpa_expired; bdaddr_t rpa; + enum { + ADV_MONITOR_SCAN_NONE, + ADV_MONITOR_SCAN_NO_FILTER, + ADV_MONITOR_SCAN_ALLOWLIST + } adv_monitor_scan_state; + + struct delayed_work interleave_adv_monitor_scan; + #if IS_ENABLED(CONFIG_BT_LEDS) struct led_trigger *power_led; #endif diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f30a1f5950e15..6c8850149265a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3592,6 +3592,10 @@ struct hci_dev *hci_alloc_dev(void) hdev->cur_adv_instance = 0x00; hdev->adv_instance_timeout = 0; + /* The default values will be chosen in the future */ + hdev->advmon_allowlist_duration = 300; + hdev->advmon_no_filter_duration = 500; + hdev->sniff_max_interval = 800; hdev->sniff_min_interval = 80; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index d2b06f5c93804..89443b48d90ce 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -378,6 +378,57 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable) hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type); } +static void start_interleave_scan(struct hci_dev *hdev) +{ + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; + queue_delayed_work(hdev->req_workqueue, + &hdev->interleave_adv_monitor_scan, 0); +} + +static bool is_interleave_scanning(struct hci_dev *hdev) +{ + return hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_NONE; +} + +static void cancel_interleave_scan(struct hci_dev *hdev) +{ + bt_dev_dbg(hdev, "%s cancelling interleave scan", hdev->name); + + cancel_delayed_work_sync(&hdev->interleave_adv_monitor_scan); + + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NONE; +} + +/* Return true if interleave_scan is running after exiting this function, + * otherwise, return false + */ +static bool update_adv_monitor_scan_state(struct hci_dev *hdev) +{ + if (!hci_is_adv_monitoring(hdev) || + (list_empty(&hdev->pend_le_conns) && + list_empty(&hdev->pend_le_reports))) { + if (is_interleave_scanning(hdev)) { + /* If the interleave condition no longer holds, cancel + * the existed interleave scan. + */ + cancel_interleave_scan(hdev); + } + return false; + } + + if (!is_interleave_scanning(hdev)) { + /* If there is at least one ADV monitors and one pending LE + * connection or one device to be scanned for, we should + * alternate between allowlist scan and one without any filters + * to save power. + */ + start_interleave_scan(hdev); + bt_dev_dbg(hdev, "%s starting interleave scan", hdev->name); + } + + return true; +} + /* This function controls the background scanning based on hdev->pend_le_conns * list. If there are pending LE connection we start the background scanning, * otherwise we stop it. @@ -449,9 +500,11 @@ static void __hci_update_background_scan(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) hci_req_add_le_scan_disable(req, false); - hci_req_add_le_passive_scan(req); - - BT_DBG("%s starting background scanning", hdev->name); + if (!update_adv_monitor_scan_state(hdev)) { + hci_req_add_le_passive_scan(req); + bt_dev_dbg(hdev, "%s starting background scanning", + hdev->name); + } } } @@ -844,12 +897,17 @@ static u8 update_white_list(struct hci_request *req) return 0x00; } - /* Once the controller offloading of advertisement monitor is in place, - * the if condition should include the support of MSFT extension - * support. If suspend is ongoing, whitelist should be the default to - * prevent waking by random advertisements. + /* Use the allowlist unless the following conditions are all true: + * - We are not currently suspending + * - There are 1 or more ADV monitors registered + * - Interleaved scanning is not currently using the allowlist + * + * Once the controller offloading of advertisement monitor is in place, + * the above condition should include the support of MSFT extension + * support. */ - if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended) + if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended && + hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_ALLOWLIST) return 0x00; /* Select filter policy to use white list */ @@ -1002,6 +1060,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) &own_addr_type)) return; + bt_dev_dbg(hdev, "interleave state %d", hdev->adv_monitor_scan_state); /* Adding or removing entries from the white list must * happen before enabling scanning. The controller does * not allow white list modification while scanning. @@ -1871,6 +1930,64 @@ static void adv_timeout_expire(struct work_struct *work) hci_dev_unlock(hdev); } +static int add_le_interleave_adv_monitor_scan(struct hci_request *req, + unsigned long opt) +{ + struct hci_dev *hdev = req->hdev; + int ret = 0; + + hci_dev_lock(hdev); + + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + hci_req_add_le_scan_disable(req, false); + hci_req_add_le_passive_scan(req); + + switch (hdev->adv_monitor_scan_state) { + case ADV_MONITOR_SCAN_ALLOWLIST: + bt_dev_dbg(hdev, "next state: allowlist"); + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; + break; + case ADV_MONITOR_SCAN_NO_FILTER: + bt_dev_dbg(hdev, "next state: no filter"); + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_ALLOWLIST; + break; + case ADV_MONITOR_SCAN_NONE: + default: + BT_ERR("unexpected error"); + ret = -1; + } + + hci_dev_unlock(hdev); + + return ret; +} + +static void interleave_adv_monitor_scan_work(struct work_struct *work) +{ + struct hci_dev *hdev = container_of(work, struct hci_dev, + interleave_adv_monitor_scan.work); + u8 status; + unsigned long timeout; + + if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_ALLOWLIST) { + timeout = msecs_to_jiffies(hdev->advmon_allowlist_duration); + } else if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_NO_FILTER) { + timeout = msecs_to_jiffies(hdev->advmon_no_filter_duration); + } else { + bt_dev_err(hdev, "unexpected error"); + return; + } + + hci_req_sync(hdev, add_le_interleave_adv_monitor_scan, 0, + HCI_CMD_TIMEOUT, &status); + + /* Don't continue interleaving if it was canceled */ + if (is_interleave_scanning(hdev)) { + queue_delayed_work(hdev->req_workqueue, + &hdev->interleave_adv_monitor_scan, timeout); + } +} + int hci_get_random_address(struct hci_dev *hdev, bool require_privacy, bool use_rpa, struct adv_info *adv_instance, u8 *own_addr_type, bdaddr_t *rand_addr) @@ -3292,6 +3409,8 @@ void hci_request_setup(struct hci_dev *hdev) INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); INIT_DELAYED_WORK(&hdev->le_scan_restart, le_scan_restart_work); INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire); + INIT_DELAYED_WORK(&hdev->interleave_adv_monitor_scan, + interleave_adv_monitor_scan_work); } void hci_request_cancel_all(struct hci_dev *hdev) @@ -3311,4 +3430,6 @@ void hci_request_cancel_all(struct hci_dev *hdev) cancel_delayed_work_sync(&hdev->adv_instance_expire); hdev->adv_instance_timeout = 0; } + + cancel_interleave_scan(hdev); } diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index b30b571f8caf8..1802f7023158c 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -67,6 +67,8 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, HDEV_PARAM_U16(0x001a, le_supv_timeout), HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b, def_le_autoconnect_timeout), + HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), + HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -138,6 +140,8 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x0019: case 0x001a: case 0x001b: + case 0x001d: + case 0x001e: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -251,6 +255,14 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, hdev->def_le_autoconnect_timeout = msecs_to_jiffies(TLV_GET_LE16(buffer)); break; + case 0x0001d: + hdev->advmon_allowlist_duration = + TLV_GET_LE16(buffer); + break; + case 0x0001e: + hdev->advmon_no_filter_duration = + TLV_GET_LE16(buffer); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uGAXIIM+ZF9M8QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 06:58:43 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AM9uHIM+ZF81OAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 06:58:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 2C88C408B1; Fri, 18 Sep 2020 06:58:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730140AbgIRDM5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 23:12:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729846AbgIRDMc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 23:12:32 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BC7DC061788 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:32 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id d15so4130340ybk.0 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 20:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=Yq3AQHq0oby0gIEHvauwatHEbFOs+SQiwBq1B7FgTKo=; b=FWdnEbfoGFaKXpZHbnLC++79ZWY3a7aRIGxG2mH67sZoVYWZUYC4LcK2SJ2r8mq1IJ VN2fUkJ7EQnVl0TGDlhk3EWmIVC8FNtBt131mk65HSsyaCqmFj2XZ3dx837bKYLSTtTp KtiAl342ruTWqRQ7YjBWAyaixJN58jS/f+4kUhS9myHZl3p8TUEXUSbz/sbUF+agMq4K AAnNYh38Oh55uQbs3TtQ8IPZ8BVtJXVDqpmGk4u/rYTKeSVCH75gVy+RagaTyIrGQjPV ZQEzNtygW+Md++DGU88mU1D+gYeda6um7diigCHcmmmMcm3ee2Ge+VsOqtQCdC+PnjvA d8xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Yq3AQHq0oby0gIEHvauwatHEbFOs+SQiwBq1B7FgTKo=; b=jZh7cMQQTDJRT9eHbrPtY4vR0ubX4cyxmO5UJ0gie0qxdyd80MgW6NC42xusfc+EUO Iy9M+Gnu6V1SzQAfQ7eFvgEVX6wf8T9bTF4oYuK8919jLeicgy35XNtOGfdvc2bWhL5a 3jdWgfu5g/iGHsVObYQ2eMTzce39zsXOi9WCLnF+MHMoKjtSPvHccXjLitFcTNXPzvxA rcAknxErH7qw9779XIpfoBW6KVC+SejR1V8IL2qiMtkpgA/U94+eE6BVIxREduErJ5l6 gAM8yR6Q59arCNy/FGxytrEwHuvV7HvsLsp/QOVoAKs9jpnRX5QPTM0ssqLPPTo4uujl L3eA== X-Gm-Message-State: AOAM532RqhxZpQp1506mN+/cEHnqf24Nc61WfXeQKPpnn/IC0NY2q++A vntxUkXH/rPQwlmlW61fqYm5lckGfWeM8HXTXZ4Ifd0sxwQuvUd73ZHLQlYUWDhOPjC4wHMOIrh cjm5mNrxJ5HensMiIZVyy5mMTGNRb8o/GWPCUgjdWdOWe+XhTmAsi4Puq60PzErJmFRxC0ayUA2 E8HPa1x0aq8Nc= X-Google-Smtp-Source: ABdhPJxpXqOdPBoIYXkioBEuMajlBbzI5RIYR8yLeXTdm8sYgj7Z8KPEw60I7kFQuiavazH6jfQ/uumb1tiOo/5KnA== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a5b:3d2:: with SMTP id t18mr42152587ybp.333.1600398751314; Thu, 17 Sep 2020 20:12:31 -0700 (PDT) Date: Fri, 18 Sep 2020 11:11:51 +0800 In-Reply-To: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200918111110.v3.4.I3774a8f0d748c7c6ec3402c4adcead32810c9164@changeid> Mime-Version: 1.0 References: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 4/6] Bluetooth: Handle system suspend resume case From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: howardchung@google.com, luiz.dentz@gmail.com, marcel@holtmann.org, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2C88C408B1 X-Rspamd-UID: e02e99 This patch adds code to handle the system suspension during interleave scan. The interleave scan will be canceled when the system is going to sleep, and will be restarted after waking up. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- (no changes since v1) net/bluetooth/hci_request.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 89443b48d90ce..d9082019b6386 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1081,6 +1081,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) filter_policy |= 0x02; if (hdev->suspended) { + /* Block suspend notifier on response */ + set_bit(SUSPEND_SCAN_ENABLE, hdev->suspend_tasks); + window = hdev->le_scan_window_suspend; interval = hdev->le_scan_int_suspend; } else if (hci_is_le_conn_scanning(hdev)) { @@ -1167,10 +1170,8 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ - hci_req_add_le_passive_scan(req); + __hci_update_background_scan(req); - /* Block suspend notifier on response */ - set_bit(SUSPEND_SCAN_ENABLE, req->hdev->suspend_tasks); } static void cancel_adv_timeout(struct hci_dev *hdev) @@ -1282,8 +1283,10 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan); /* Disable LE passive scan if enabled */ - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { + cancel_interleave_scan(hdev); hci_req_add_le_scan_disable(&req, false); + } /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aNn1DhFBZF94/AAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 07:09:37 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iMpbCxFBZF/NsgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 07:09:37 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6337740618; Fri, 18 Sep 2020 07:09:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726617AbgIREOK (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 00:14:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726117AbgIREOK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 00:14:10 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94C8CC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 21:14:09 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id g10so4025816qto.1 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 21:14:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=cgmCevP9sFtnM8IsBARtN3AUZ+zxR6msvXrKQGyD+04=; b=ax3aqfRw8xzWeFQbdteKYQF0M9eeFnHZGr1upnF3y3SNO6CO6Rd0fzo15syqu6zRzM 0oFpYvwNPS+fOHCP4gqbtqVhFKynxepJZbY0urmOxEl7pJATx2EHGbOSeIW7IeS3tW5X tDCjwiqqS4MNt6EEXxNPjG7TLK2lhWq56PKXRW/ncpaFd67pKy8/kB3If/CTcDlPPmnF sdsfpyp9f+mqUH53OLTHmT+ukZXN1FRcgx0H3DsyAIxzllNEeOsDHAawgzArinDxMGrZ k8cPOYzBD+hIkX4DCNaPtFsbp3R78uNllzu/L0eG6WJBTqCwTI+k2AG+HSpc0jDDde1R j4Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=cgmCevP9sFtnM8IsBARtN3AUZ+zxR6msvXrKQGyD+04=; b=BVoc1abjVb3qBofUbXNgIJ3v4o6ATJU2i1lJHjtx4jsLYlNVT7dazkpr0fh5K06pBq bEdvEhdDgpCEoNtHvJe0GNXNZWdCJ41rTJQN47l/OXgjdXRPHjhtDA+1lkTHZVQse9Bm j54LnqcpsgDSrA/LWf2SbRB19J2+zAOSiIvfxRXxFGoIlMmEI8mfmm6vArGXAqoeNS18 E8nFlLW21nmGChW4p0RoOOBI8Vfni+miahJEmkzzB68fqGJr7J+uPaPdMLt8GzbfBFno 1K8gZB3vZHETtE+cq1VXehnM2Dqj0jH55BHhmXjUlL8u6T/7jhh/kqIHzENlo9yXHhLU Bi5Q== X-Gm-Message-State: AOAM5303QkP0GSg0tdAu6sN2ep2OCq+aBrJfzAnxRSr4abs+QME70tKb uq9KZK+rU1G3IAvKCjIE15/XdC9GLDhs1avmqg9P6xa2b4U2i87kvJ70JGu6Xum4v3E4u6hspqv 3kGQAUKnVEOrJ1ygAUdaIf40ZGJNfrVUZlFP23qrbc3ukRuMG2UQh3ES+oUhGyDALXVOHokaNWh yBXNM/fSHSk+Y= X-Google-Smtp-Source: ABdhPJxaad97caT2HU9lBCbj9PmSEznzYFFbbVOXxlSZYTlyP8hvg1EoprKnmT02dqY6oH6Ws9hjaQE0Tr5ELKygNQ== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:45b3:: with SMTP id y19mr15515155qvu.59.1600402448580; Thu, 17 Sep 2020 21:14:08 -0700 (PDT) Date: Fri, 18 Sep 2020 12:14:01 +0800 Message-Id: <20200918121348.BlueZ.v2.1.I1f083629d41c747a33a3937fbc199ea37dccde12@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [BlueZ PATCH v2 1/2] core: Add params to set interleaving durations From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mmandlik@chromium.org, mcchou@chromium.org, alainm@chromium.org, luiz.dentz@gmail.com, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.68 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6337740618 X-Rspamd-UID: 284d26 This patch adds parameters to control the durations of allowlist scan and no-filter scan when the kernel is doing interleaving scan. --- Changes in v2: - Fix typo in the commit title src/adapter.c | 18 ++++++++++++++++++ src/hcid.h | 3 +++ src/main.c | 10 ++++++++++ src/main.conf | 7 +++++++ 4 files changed, 38 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index b2bd8b3f1d01..c0e95b48a1c4 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -4431,6 +4431,24 @@ static void load_default_system_params(struct btd_adapter *adapter) len += sizeof(params[i].u16); } + if (main_opts.default_params.advmon_allowlist_scan_duration) { + params[i].entry.type = 0x001d; + params[i].entry.length = sizeof(params[i].u16); + params[i].u16 = + main_opts.default_params.advmon_allowlist_scan_duration; + ++i; + len += sizeof(params[i].u16); + } + + if (main_opts.default_params.advmon_no_filter_scan_duration) { + params[i].entry.type = 0x001e; + params[i].entry.length = sizeof(params[i].u16); + params[i].u16 = + main_opts.default_params.advmon_no_filter_scan_duration; + ++i; + len += sizeof(params[i].u16); + } + err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG, adapter->dev_id, len, params, NULL, NULL, NULL); if (!err) diff --git a/src/hcid.h b/src/hcid.h index 3624ba6ea163..c3e5fe803543 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -93,6 +93,9 @@ struct main_opts { uint16_t le_conn_latency; uint16_t le_conn_lsto; uint16_t le_autoconnect_timeout; + + uint16_t advmon_allowlist_scan_duration; + uint16_t advmon_no_filter_scan_duration; } default_params; diff --git a/src/main.c b/src/main.c index 038f867b5a6d..e222ed3bf855 100644 --- a/src/main.c +++ b/src/main.c @@ -123,6 +123,8 @@ static const char *controller_options[] = { "LEConnectionLatency", "LEConnectionSupervisionTimeout", "LEAutoconnecttimeout", + "AdvMonAllowlistScanDuration", + "AdvMonNoFilterScanDuration", NULL }; @@ -434,6 +436,14 @@ static void parse_controller_config(GKeyFile *config) &main_opts.default_params.le_autoconnect_timeout, 0x0001, 0x4000}, + { "AdvMonAllowlistScanDuration", + &main_opts.default_params.advmon_allowlist_scan_duration, + 1, + 10000}, + { "AdvMonNoFilterScanDuration", + &main_opts.default_params.advmon_no_filter_scan_duration, + 1, + 10000}, }; uint16_t i; diff --git a/src/main.conf b/src/main.conf index 8d85702d4316..3b341f44c9cf 100644 --- a/src/main.conf +++ b/src/main.conf @@ -152,6 +152,13 @@ #LEConnectionSupervisionTimeout= #LEAutoconnecttimeout= +# Scan duration during interleaving scan. Only used when scanning for ADV +# monitors. The units are msec. +# Default: 300 +#AdvMonAllowlistScanDuration= +# Default: 500 +#AdvMonNoFilterScanDuration= + [GATT] # GATT attribute cache. # Possible values: -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SPRjGRdBZF/6CQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 07:09:43 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 2Nx1FhdBZF+w5gAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 07:09:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 51B0140886; Fri, 18 Sep 2020 07:09:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726633AbgIREON (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 00:14:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726117AbgIREON (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 00:14:13 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2E7AC06174A for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 21:14:12 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id w126so3606216qka.5 for <linux-bluetooth@vger.kernel.org>; Thu, 17 Sep 2020 21:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=iblcy/QeLiCTNkqzDgNQtqvRJl2CHZ4/1gqki2SzBNs=; b=js3OZGbs5eVAi816fw8tBqqigsra0fwoOacOiAFm9Xs6Fllv8YDVKugjhDBoBiw5Ar HcZCRWH4Sz1i353rqD4hWyi13bi7zRNHdpVJLT9E86uG+AvOTvaT5bRF6AX7/lK4l7VO p95NUZ3GpeCxiHgUK+BtKbMlUB3Lv7AQyYGcB5/aZwPJJcFkgHAm8twxT9cCzDAHnaLP JHE7F1HrjkKrIVgtdkoKcAOmN6mAhuNVMFvekDEgx3VbWcMNinzNr2PpRI55/NSET1/9 DDljWv1dPJjh0rGnmmnxcisXNEivgd3yXmbu+iFvtDJzwvJ8fSo5qgGWK0wCurW0SXtX KPig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=iblcy/QeLiCTNkqzDgNQtqvRJl2CHZ4/1gqki2SzBNs=; b=AVYrHwwaHsQqnpBMbLceSo76u7fVVC3iVxLdc2a23V1LkdxCie23kfwa4i4eNP/RXw 98/XnBKLWDo/TbAxBLBcNwwqwQrX93o/XX7Y7JtQ5vxCcirRbZTDdcoCBddy82ecmLkw 0i67ZCtOvhJHqPEhO4EWjC9oJYA3ve/x2hUE1Hrq/51h8/synaYbE+YCL6UP7O2B2rbg anTnosk8q/8k3SIUkQgNxP6juq3zCKMFU7EBpauMfu/P3JrmVQcJE+45b+R/iHJK3T+B UsRLaPmKx2zQFhj6tg6CJvhqOaLsBHdxgmIHByEP/w+gqJ2+Gx0o433iWOHYH3A3rvHN 4CsA== X-Gm-Message-State: AOAM531LKh1YOmpXSE5LhhaJFrHFAGbWrfzDjCSX0w48TbXh6ol4p6mF NsuLwXAlOAk2fgaaL/frp9eAOB1U8mWSv0a8OvP3WqZER5+X3eb6hefPtiXwpaLCqxl/68SZ+bJ //ire1HndoFNz6Spw5Pi1f5brcOnvTMRc8XPvn4vgfh92Tu8rKBpxyJkXkDfXDfaiTxBEROOaFC YjJ+2InYTG1kI= X-Google-Smtp-Source: ABdhPJz7sxFlf66S7G61f40BD1pbeVYC1AY/XfsIviEsmS0WbBJfKkTR2De4Rv1ruJBYcQWqT0HGPdkxQWrJdZcASA== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a0c:cd0d:: with SMTP id b13mr15712173qvm.53.1600402452001; Thu, 17 Sep 2020 21:14:12 -0700 (PDT) Date: Fri, 18 Sep 2020 12:14:02 +0800 In-Reply-To: <20200918121348.BlueZ.v2.1.I1f083629d41c747a33a3937fbc199ea37dccde12@changeid> Message-Id: <20200918121348.BlueZ.v2.2.Iac5207375d22fb7b96ae4ef73b49ae4ab457219c@changeid> Mime-Version: 1.0 References: <20200918121348.BlueZ.v2.1.I1f083629d41c747a33a3937fbc199ea37dccde12@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [BlueZ PATCH v2 2/2] core: Add param to disable interleave scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mmandlik@chromium.org, mcchou@chromium.org, alainm@chromium.org, luiz.dentz@gmail.com, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.68 / 15.00 / 15.00 X-Rspamd-Queue-Id: 51B0140886 X-Rspamd-UID: dfc2fc This patch adds parameter to enable/disable the interleave scan feature. --- (no changes since v1) src/adapter.c | 9 +++++++++ src/hcid.h | 1 + src/main.c | 6 ++++++ src/main.conf | 6 ++++++ 4 files changed, 22 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index c0e95b48a1c4..a2c782e308bb 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -4449,6 +4449,15 @@ static void load_default_system_params(struct btd_adapter *adapter) len += sizeof(params[i].u16); } + if (main_opts.default_params.enable_advmon_interleave_scan != 0xFFFF) { + params[i].entry.type = 0x001f; + params[i].entry.length = sizeof(params[i].u16); + params[i].u16 = + main_opts.default_params.enable_advmon_interleave_scan; + ++i; + len += sizeof(params[i].u16); + } + err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG, adapter->dev_id, len, params, NULL, NULL, NULL); if (!err) diff --git a/src/hcid.h b/src/hcid.h index c3e5fe803543..c6717be62c48 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -96,6 +96,7 @@ struct main_opts { uint16_t advmon_allowlist_scan_duration; uint16_t advmon_no_filter_scan_duration; + uint16_t enable_advmon_interleave_scan; } default_params; diff --git a/src/main.c b/src/main.c index e222ed3bf855..3433130bc419 100644 --- a/src/main.c +++ b/src/main.c @@ -125,6 +125,7 @@ static const char *controller_options[] = { "LEAutoconnecttimeout", "AdvMonAllowlistScanDuration", "AdvMonNoFilterScanDuration", + "EnableAdvMonInterleaveScan", NULL }; @@ -444,6 +445,10 @@ static void parse_controller_config(GKeyFile *config) &main_opts.default_params.advmon_no_filter_scan_duration, 1, 10000}, + { "EnableAdvMonInterleaveScan", + &main_opts.default_params.enable_advmon_interleave_scan, + 0, + 1}, }; uint16_t i; @@ -711,6 +716,7 @@ static void init_defaults(void) main_opts.default_params.num_entries = 0; main_opts.default_params.br_page_scan_type = 0xFFFF; main_opts.default_params.br_scan_type = 0xFFFF; + main_opts.default_params.enable_advmon_interleave_scan = 0xFFFF; if (sscanf(VERSION, "%hhu.%hhu", &major, &minor) != 2) return; diff --git a/src/main.conf b/src/main.conf index 3b341f44c9cf..c300a3b81086 100644 --- a/src/main.conf +++ b/src/main.conf @@ -159,6 +159,12 @@ # Default: 500 #AdvMonNoFilterScanDuration= +# Enable/Disable Advertisement Monitor interleave scan for power saving. +# 0: disable +# 1: enable +# Defaults to 1 +#EnableAdvMonInterleaveScan= + [GATT] # GATT attribute cache. # Possible values: -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MFa/I78tZF/wrQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:47:11 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 8J97Ib8tZF9ieAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:47:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 01599A01ED; Fri, 18 Sep 2020 05:47:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727826AbgIRCKS (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:10:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:34082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727513AbgIRCJ6 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:09:58 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BDEB0239D1; Fri, 18 Sep 2020 02:09:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394997; bh=X7HvMDAeXbk7Y56Bs6YVhdAtjtsCFbi4aOnIKUSW0JQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XzOtc7c0w+3AL2Anp2r5onZ/S8j0TFuJv9roLQJGH2c694oEu75mZlXLjwY4Uu5mO uK3tGeT8OJjXeIP6VzlNbr7cPZfA7CEDSLMposBFZYmh93gw6xISz8gymEjg0vuvch TD1EUz3CJhjWDn6TlQZc+NG1B2VnafTWRZdVgWYA= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alain Michaud <alainm@chromium.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 095/206] Bluetooth: guard against controllers sending zero'd events Date: Thu, 17 Sep 2020 22:06:11 -0400 Message-Id: <20200918020802.2065198-95-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020802.2065198-1-sashal@kernel.org> References: <20200918020802.2065198-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.97 / 15.00 / 15.00 X-Rspamd-Queue-Id: 01599A01ED X-Rspamd-UID: 7d1e42 From: Alain Michaud <alainm@chromium.org> [ Upstream commit 08bb4da90150e2a225f35e0f642cdc463958d696 ] Some controllers have been observed to send zero'd events under some conditions. This change guards against this condition as well as adding a trace to facilitate diagnosability of this condition. Signed-off-by: Alain Michaud <alainm@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/hci_event.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 2b4a7cf03041b..ec6b3a87b3e7f 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5738,6 +5738,11 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) u8 status = 0, event = hdr->evt, req_evt = 0; u16 opcode = HCI_OP_NOP; + if (!event) { + bt_dev_warn(hdev, "Received unexpected HCI Event 00000000"); + goto done; + } + if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) { struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; opcode = __le16_to_cpu(cmd_hdr->opcode); @@ -5949,6 +5954,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) req_complete_skb(hdev, status, opcode, orig_skb); } +done: kfree_skb(orig_skb); kfree_skb(skb); hdev->stat.evt_rx++; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AC/uGeotZF/wrQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:47:54 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yAGTFuotZF90LwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:47:54 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 078A0A0AAE; Fri, 18 Sep 2020 05:47:48 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728421AbgIRCpO (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:45:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:34738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728415AbgIRCKS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:10:18 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 30DD423977; Fri, 18 Sep 2020 02:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395009; bh=Co2r5RQiN2Ize0jVU3icZTDc0tKWKljnPEkgNplGz4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e1JMWkGtnhnYLlh4VTzv+GAXAPHIGYWiTvozRIVG9JO86YeX/ZK152P0mn+tJ7Uoj Kfvh62rFu6aLtUrztSNm7iwZrfpmBE1eow+Bfokyj5eNxnHa75AHI6PJSz/+BRhB7e Fa1FOOMIBMgSnr0Ae35kAc/j9jQBJkRLJiK/D9Zs= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Howard Chung <howardchung@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 104/206] Bluetooth: L2CAP: handle l2cap config request during open state Date: Thu, 17 Sep 2020 22:06:20 -0400 Message-Id: <20200918020802.2065198-104-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020802.2065198-1-sashal@kernel.org> References: <20200918020802.2065198-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: 078A0A0AAE X-Rspamd-UID: 83c26a From: Howard Chung <howardchung@google.com> [ Upstream commit 96298f640104e4cd9a913a6e50b0b981829b94ff ] According to Core Spec Version 5.2 | Vol 3, Part A 6.1.5, the incoming L2CAP_ConfigReq should be handled during OPEN state. The section below shows the btmon trace when running L2CAP/COS/CFD/BV-12-C before and after this change. === Before === ... > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22 L2CAP: Connection Request (0x02) ident 2 len 4 PSM: 1 (0x0001) Source CID: 65 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23 L2CAP: Connection Response (0x03) ident 2 len 8 Destination CID: 64 Source CID: 65 Result: Connection successful (0x0000) Status: No further information available (0x0000) < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24 L2CAP: Configure Request (0x04) ident 2 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #25 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #26 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27 L2CAP: Configure Request (0x04) ident 3 len 8 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 .. < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 > HCI Event: Number of Completed Packets (0x13) plen 5 #29 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30 L2CAP: Configure Response (0x05) ident 2 len 6 Source CID: 64 Flags: 0x0000 Result: Success (0x0000) > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31 L2CAP: Configure Request (0x04) ident 3 len 12 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 91 02 11 11 ...... < ACL Data TX: Handle 256 flags 0x00 dlen 14 #32 L2CAP: Command Reject (0x01) ident 3 len 6 Reason: Invalid CID in request (0x0002) Destination CID: 64 Source CID: 65 > HCI Event: Number of Completed Packets (0x13) plen 5 #33 Num handles: 1 Handle: 256 Count: 1 ... === After === ... > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22 L2CAP: Connection Request (0x02) ident 2 len 4 PSM: 1 (0x0001) Source CID: 65 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23 L2CAP: Connection Response (0x03) ident 2 len 8 Destination CID: 64 Source CID: 65 Result: Connection successful (0x0000) Status: No further information available (0x0000) < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24 L2CAP: Configure Request (0x04) ident 2 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #25 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #26 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27 L2CAP: Configure Request (0x04) ident 3 len 8 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 .. < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 > HCI Event: Number of Completed Packets (0x13) plen 5 #29 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30 L2CAP: Configure Response (0x05) ident 2 len 6 Source CID: 64 Flags: 0x0000 Result: Success (0x0000) > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31 L2CAP: Configure Request (0x04) ident 3 len 12 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 91 02 11 11 ..... < ACL Data TX: Handle 256 flags 0x00 dlen 18 #32 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 < ACL Data TX: Handle 256 flags 0x00 dlen 12 #33 L2CAP: Configure Request (0x04) ident 3 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #34 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #35 Num handles: 1 Handle: 256 Count: 1 ... Signed-off-by: Howard Chung <howardchung@google.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index b1f51cb007ea6..c04107d446016 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4117,7 +4117,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, return 0; } - if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) { + if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2 && + chan->state != BT_CONNECTED) { cmd_reject_invalid_cid(conn, cmd->ident, chan->scid, chan->dcid); goto unlock; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oNcCCKMvZF+ZvQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:55:15 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id yIzTBKMvZF8MKwAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:55:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DAE7FA0B72; Fri, 18 Sep 2020 05:55:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728281AbgIRCJ2 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:09:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:33134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726757AbgIRCJ0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:09:26 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1D408239E5; Fri, 18 Sep 2020 02:09:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394966; bh=AZ8ZANYn2ayZhfHdgsNtX6pMLu7dDv5koNz1Gu18hNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uEzIeK3yYHM0s7Zas2WIg/07DVreiZ+oh7nIXUi2nlaHnlg7rvmV3GhhbrQyQGb3a At+KKXSFlPgm1I+rqksHP2WxK6tQgm2Txd+BgIpyckStFSB000mNSOeoRpltT0E1gr GZ8Wa4w5AbRN9/OmQrZx6z917gJJ+NhIPsUWQaK4= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hillf Danton <hdanton@sina.com>, syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com, Manish Mandlik <mmandlik@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 068/206] Bluetooth: prefetch channel before killing sock Date: Thu, 17 Sep 2020 22:05:44 -0400 Message-Id: <20200918020802.2065198-68-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020802.2065198-1-sashal@kernel.org> References: <20200918020802.2065198-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.01 / 15.00 / 15.00 X-Rspamd-Queue-Id: DAE7FA0B72 X-Rspamd-UID: b896d8 From: Hillf Danton <hdanton@sina.com> [ Upstream commit 2a154903cec20fb64ff4d7d617ca53c16f8fd53a ] Prefetch channel before killing sock in order to fix UAF like BUG: KASAN: use-after-free in l2cap_sock_release+0x24c/0x290 net/bluetooth/l2cap_sock.c:1212 Read of size 8 at addr ffff8880944904a0 by task syz-fuzzer/9751 Reported-by: syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com Fixes: 6c08fc896b60 ("Bluetooth: Fix refcount use-after-free issue") Cc: Manish Mandlik <mmandlik@google.com> Signed-off-by: Hillf Danton <hdanton@sina.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_sock.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index d128750e47305..5572042f04531 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1190,6 +1190,7 @@ static int l2cap_sock_release(struct socket *sock) { struct sock *sk = sock->sk; int err; + struct l2cap_chan *chan; BT_DBG("sock %p, sk %p", sock, sk); @@ -1199,15 +1200,16 @@ static int l2cap_sock_release(struct socket *sock) bt_sock_unlink(&l2cap_sk_list, sk); err = l2cap_sock_shutdown(sock, 2); + chan = l2cap_pi(sk)->chan; - l2cap_chan_hold(l2cap_pi(sk)->chan); - l2cap_chan_lock(l2cap_pi(sk)->chan); + l2cap_chan_hold(chan); + l2cap_chan_lock(chan); sock_orphan(sk); l2cap_sock_kill(sk); - l2cap_chan_unlock(l2cap_pi(sk)->chan); - l2cap_chan_put(l2cap_pi(sk)->chan); + l2cap_chan_unlock(chan); + l2cap_chan_put(chan); return err; } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eNJDJs4vZF/wrQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:55:58 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id uOIZI84vZF+LswAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:55:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E87DBA015F; Fri, 18 Sep 2020 05:55:53 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728553AbgIRCsP (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:48:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:60922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727241AbgIRCJT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:09:19 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 686FB2311A; Fri, 18 Sep 2020 02:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394959; bh=lkELpZy9Y12ASSKiv2e5CcnLv2YHI5t6jueN9U/7Ocs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OHXml0fgmGcXJb8344x3hogDUePTazNkVHZsol5vbEwevYnYhevCpZm9uF5RfiLVC Gtv8CSRGncvHVTXj39WB/RmVAg1MImO0emXO7p2tXPc/xNu7yTwy1cggFWkpVQgRGe 0yQPVzMT1+4Uv+hIK+DeESdLOUNvZv27ge4tHSrg= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Manish Mandlik <mmandlik@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 065/206] Bluetooth: Fix refcount use-after-free issue Date: Thu, 17 Sep 2020 22:05:41 -0400 Message-Id: <20200918020802.2065198-65-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020802.2065198-1-sashal@kernel.org> References: <20200918020802.2065198-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.99 / 15.00 / 15.00 X-Rspamd-Queue-Id: E87DBA015F X-Rspamd-UID: c70ff0 From: Manish Mandlik <mmandlik@google.com> [ Upstream commit 6c08fc896b60893c5d673764b0668015d76df462 ] There is no lock preventing both l2cap_sock_release() and chan->ops->close() from running at the same time. If we consider Thread A running l2cap_chan_timeout() and Thread B running l2cap_sock_release(), expected behavior is: A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill() where, sock_orphan() clears "sk->sk_socket" and l2cap_sock_teardown_cb() marks socket as SOCK_ZAPPED. In l2cap_sock_kill(), there is an "if-statement" that checks if both sock_orphan() and sock_teardown() has been run i.e. sk->sk_socket is NULL and socket is marked as SOCK_ZAPPED. Socket is killed if the condition is satisfied. In the race condition, following occurs: A::l2cap_chan_timeout()->l2cap_chan_close()->l2cap_sock_teardown_cb() B::l2cap_sock_release()->sock_orphan() B::l2cap_sock_release()->l2cap_sock_kill() A::l2cap_chan_timeout()->l2cap_sock_close_cb()->l2cap_sock_kill() In this scenario, "if-statement" is true in both B::l2cap_sock_kill() and A::l2cap_sock_kill() and we hit "refcount: underflow; use-after-free" bug. Similar condition occurs at other places where teardown/sock_kill is happening: l2cap_disconnect_rsp()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_rsp()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_conn_del()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_conn_del()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_disconnect_req()->l2cap_chan_del()->l2cap_sock_teardown_cb() l2cap_disconnect_req()->l2cap_sock_close_cb()->l2cap_sock_kill() l2cap_sock_cleanup_listen()->l2cap_chan_close()->l2cap_sock_teardown_cb() l2cap_sock_cleanup_listen()->l2cap_sock_kill() Protect teardown/sock_kill and orphan/sock_kill by adding hold_lock on l2cap channel to ensure that the socket is killed only after marked as zapped and orphan. Signed-off-by: Manish Mandlik <mmandlik@google.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_core.c | 26 +++++++++++++++----------- net/bluetooth/l2cap_sock.c | 16 +++++++++++++--- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 0d84d1f820d4c..b1f51cb007ea6 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -414,6 +414,9 @@ static void l2cap_chan_timeout(struct work_struct *work) BT_DBG("chan %p state %s", chan, state_to_string(chan->state)); mutex_lock(&conn->chan_lock); + /* __set_chan_timer() calls l2cap_chan_hold(chan) while scheduling + * this work. No need to call l2cap_chan_hold(chan) here again. + */ l2cap_chan_lock(chan); if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) @@ -426,12 +429,12 @@ static void l2cap_chan_timeout(struct work_struct *work) l2cap_chan_close(chan, reason); - l2cap_chan_unlock(chan); - chan->ops->close(chan); - mutex_unlock(&conn->chan_lock); + l2cap_chan_unlock(chan); l2cap_chan_put(chan); + + mutex_unlock(&conn->chan_lock); } struct l2cap_chan *l2cap_chan_create(void) @@ -1725,9 +1728,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) l2cap_chan_del(chan, err); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); } @@ -4337,6 +4340,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, return 0; } + l2cap_chan_hold(chan); l2cap_chan_lock(chan); rsp.dcid = cpu_to_le16(chan->scid); @@ -4345,12 +4349,11 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, chan->ops->set_shutdown(chan); - l2cap_chan_hold(chan); l2cap_chan_del(chan, ECONNRESET); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); @@ -4382,20 +4385,21 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, return 0; } + l2cap_chan_hold(chan); l2cap_chan_lock(chan); if (chan->state != BT_DISCONN) { l2cap_chan_unlock(chan); + l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); return 0; } - l2cap_chan_hold(chan); l2cap_chan_del(chan, 0); - l2cap_chan_unlock(chan); - chan->ops->close(chan); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); mutex_unlock(&conn->chan_lock); diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index a3a2cd55e23a9..d128750e47305 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1039,7 +1039,7 @@ done: } /* Kill socket (only if zapped and orphan) - * Must be called on unlocked socket. + * Must be called on unlocked socket, with l2cap channel lock. */ static void l2cap_sock_kill(struct sock *sk) { @@ -1200,8 +1200,15 @@ static int l2cap_sock_release(struct socket *sock) err = l2cap_sock_shutdown(sock, 2); + l2cap_chan_hold(l2cap_pi(sk)->chan); + l2cap_chan_lock(l2cap_pi(sk)->chan); + sock_orphan(sk); l2cap_sock_kill(sk); + + l2cap_chan_unlock(l2cap_pi(sk)->chan); + l2cap_chan_put(l2cap_pi(sk)->chan); + return err; } @@ -1219,12 +1226,15 @@ static void l2cap_sock_cleanup_listen(struct sock *parent) BT_DBG("child chan %p state %s", chan, state_to_string(chan->state)); + l2cap_chan_hold(chan); l2cap_chan_lock(chan); + __clear_chan_timer(chan); l2cap_chan_close(chan, ECONNRESET); - l2cap_chan_unlock(chan); - l2cap_sock_kill(sk); + + l2cap_chan_unlock(chan); + l2cap_chan_put(chan); } } -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0OGOBUAwZF/wrQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 05:57:52 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id +Ia1AkAwZF81OAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 05:57:52 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B96AFA0B31; Fri, 18 Sep 2020 05:57:45 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730185AbgIRCsv (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:48:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:60970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728244AbgIRCJK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:09:10 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ACDE1235F9; Fri, 18 Sep 2020 02:09:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394950; bh=XCVKC2D5jGlXjrXVSNma8mE0EpP0mze14kcCQj8lVXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kumyAyg9J/z6F4HhcW1fMcvNTk3b+74QSWM1TpgLoCIsz1MrsrfJmNJ4VevmMuYb8 rhtXPKknyb9ftgsnhAdpkNScOAwOQE4iI1+rbcnuV3Mh13fshq4KeyVsHhaorYwcyn TDypDdb/GHlrRKM/LJmPtM1MQnmYyI7sa0RteZt8= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Maxim Mikityanskiy <maxtram95@gmail.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 057/206] Bluetooth: btrtl: Use kvmalloc for FW allocations Date: Thu, 17 Sep 2020 22:05:33 -0400 Message-Id: <20200918020802.2065198-57-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020802.2065198-1-sashal@kernel.org> References: <20200918020802.2065198-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.90 / 15.00 / 15.00 X-Rspamd-Queue-Id: B96AFA0B31 X-Rspamd-UID: 397138 From: Maxim Mikityanskiy <maxtram95@gmail.com> [ Upstream commit 268d3636dfb22254324774de1f8875174b3be064 ] Currently, kmemdup is applied to the firmware data, and it invokes kmalloc under the hood. The firmware size and patch_length are big (more than PAGE_SIZE), and on some low-end systems (like ASUS E202SA) kmalloc may fail to allocate a contiguous chunk under high memory usage and fragmentation: Bluetooth: hci0: RTL: examining hci_ver=06 hci_rev=000a lmp_ver=06 lmp_subver=8821 Bluetooth: hci0: RTL: rom_version status=0 version=1 Bluetooth: hci0: RTL: loading rtl_bt/rtl8821a_fw.bin kworker/u9:2: page allocation failure: order:4, mode:0x40cc0(GFP_KERNEL|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0 <stack trace follows> As firmware load happens on each resume, Bluetooth will stop working after several iterations, when the kernel fails to allocate an order-4 page. This patch replaces kmemdup with kvmalloc+memcpy. It's not required to have a contiguous chunk here, because it's not mapped to the device directly. Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/bluetooth/btrtl.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index 8d1cd2479e36f..cc51395d8b0e5 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -343,11 +343,11 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev, * the end. */ len = patch_length; - buf = kmemdup(btrtl_dev->fw_data + patch_offset, patch_length, - GFP_KERNEL); + buf = kvmalloc(patch_length, GFP_KERNEL); if (!buf) return -ENOMEM; + memcpy(buf, btrtl_dev->fw_data + patch_offset, patch_length - 4); memcpy(buf + patch_length - 4, &epatch_info->fw_version, 4); *_buf = buf; @@ -415,8 +415,10 @@ static int rtl_load_file(struct hci_dev *hdev, const char *name, u8 **buff) if (ret < 0) return ret; ret = fw->size; - *buff = kmemdup(fw->data, ret, GFP_KERNEL); - if (!*buff) + *buff = kvmalloc(fw->size, GFP_KERNEL); + if (*buff) + memcpy(*buff, fw->data, ret); + else ret = -ENOMEM; release_firmware(fw); @@ -454,14 +456,14 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, goto out; if (btrtl_dev->cfg_len > 0) { - tbuff = kzalloc(ret + btrtl_dev->cfg_len, GFP_KERNEL); + tbuff = kvzalloc(ret + btrtl_dev->cfg_len, GFP_KERNEL); if (!tbuff) { ret = -ENOMEM; goto out; } memcpy(tbuff, fw_data, ret); - kfree(fw_data); + kvfree(fw_data); memcpy(tbuff + ret, btrtl_dev->cfg_data, btrtl_dev->cfg_len); ret += btrtl_dev->cfg_len; @@ -474,7 +476,7 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, ret = rtl_download_firmware(hdev, fw_data, ret); out: - kfree(fw_data); + kvfree(fw_data); return ret; } @@ -501,8 +503,8 @@ static struct sk_buff *btrtl_read_local_version(struct hci_dev *hdev) void btrtl_free(struct btrtl_device_info *btrtl_dev) { - kfree(btrtl_dev->fw_data); - kfree(btrtl_dev->cfg_data); + kvfree(btrtl_dev->fw_data); + kvfree(btrtl_dev->cfg_data); kfree(btrtl_dev); } EXPORT_SYMBOL_GPL(btrtl_free); -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wLyxDQI2ZF/9xgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 06:22:26 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id AFnECgI2ZF/IyQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 06:22:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 156EE4096D; Fri, 18 Sep 2020 06:22:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728994AbgIRC51 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:57:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:55196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727771AbgIRCGc (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:06:32 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3FD92239EC; Fri, 18 Sep 2020 02:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394791; bh=RK3AbwBa2NgsAA07P5kgrjrF7BKAX7Rf4zov5MVkw7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D5oXv4aUH36AbIwIB4WhEZN2HcQV3/56lwZMs1JlnssLDbHwtWSXYjJ9p0J5MOnMD KrxcBkdpSnAbqE4uonz0evrl3ShykEGnKqZSz+DdDb7CVYfxKe7sVgNxTgz6racKbW uc+LrntZ905fWeZ2AvQymgqqIE/yOG+NMk4bWvDA= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sonny Sasaka <sonnysasaka@chromium.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 261/330] Bluetooth: Handle Inquiry Cancel error after Inquiry Complete Date: Thu, 17 Sep 2020 22:00:01 -0400 Message-Id: <20200918020110.2063155-261-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: 156EE4096D X-Rspamd-UID: 0739ce From: Sonny Sasaka <sonnysasaka@chromium.org> [ Upstream commit adf1d6926444029396861413aba8a0f2a805742a ] After sending Inquiry Cancel command to the controller, it is possible that Inquiry Complete event comes before Inquiry Cancel command complete event. In this case the Inquiry Cancel command will have status of Command Disallowed since there is no Inquiry session to be cancelled. This case should not be treated as error, otherwise we can reach an inconsistent state. Example of a btmon trace when this happened: < HCI Command: Inquiry Cancel (0x01|0x0002) plen 0 > HCI Event: Inquiry Complete (0x01) plen 1 Status: Success (0x00) > HCI Event: Command Complete (0x0e) plen 4 Inquiry Cancel (0x01|0x0002) ncmd 1 Status: Command Disallowed (0x0c) Signed-off-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/hci_event.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 1bbeb14b8b64e..fd436e5d7b542 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -41,12 +41,27 @@ /* Handle HCI Event packets */ -static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) +static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb, + u8 *new_status) { __u8 status = *((__u8 *) skb->data); BT_DBG("%s status 0x%2.2x", hdev->name, status); + /* It is possible that we receive Inquiry Complete event right + * before we receive Inquiry Cancel Command Complete event, in + * which case the latter event should have status of Command + * Disallowed (0x0c). This should not be treated as error, since + * we actually achieve what Inquiry Cancel wants to achieve, + * which is to end the last Inquiry session. + */ + if (status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { + bt_dev_warn(hdev, "Ignoring error of Inquiry Cancel command"); + status = 0x00; + } + + *new_status = status; + if (status) return; @@ -3142,7 +3157,7 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, switch (*opcode) { case HCI_OP_INQUIRY_CANCEL: - hci_cc_inquiry_cancel(hdev, skb); + hci_cc_inquiry_cancel(hdev, skb, status); break; case HCI_OP_PERIODIC_INQ: -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qOofOfU5ZF+0zAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 06:39:17 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id sDy7NPU5ZF8eZAAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 06:39:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5B2E640963; Fri, 18 Sep 2020 06:39:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730587AbgIRDEo (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 23:04:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:52242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727361AbgIRCEj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:04:39 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 81DC823600; Fri, 18 Sep 2020 02:04:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394678; bh=u/HIXLYDCOfZAA+36lrxZDsx82CiwPJQ/fiXHDgICZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KXbbev/ZIzVBbQ1HQWPhvQxfE0EJf+q0vWD0NjSxGQ2NiXQZt7cEAxSgTmjiXz4oW 13G3MLf2lvX8FS9tlV09D2x9oksssMNEto76nCirz6fq1SeQqCjKjCV+Hyp0bibNyq uOp/RZ7Ytn/brlY/mL36SKj7vJIWqit+LBqW8y8E= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Howard Chung <howardchung@google.com>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 168/330] Bluetooth: L2CAP: handle l2cap config request during open state Date: Thu, 17 Sep 2020 21:58:28 -0400 Message-Id: <20200918020110.2063155-168-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5B2E640963 X-Rspamd-UID: a4c8af From: Howard Chung <howardchung@google.com> [ Upstream commit 96298f640104e4cd9a913a6e50b0b981829b94ff ] According to Core Spec Version 5.2 | Vol 3, Part A 6.1.5, the incoming L2CAP_ConfigReq should be handled during OPEN state. The section below shows the btmon trace when running L2CAP/COS/CFD/BV-12-C before and after this change. === Before === ... > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22 L2CAP: Connection Request (0x02) ident 2 len 4 PSM: 1 (0x0001) Source CID: 65 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23 L2CAP: Connection Response (0x03) ident 2 len 8 Destination CID: 64 Source CID: 65 Result: Connection successful (0x0000) Status: No further information available (0x0000) < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24 L2CAP: Configure Request (0x04) ident 2 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #25 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #26 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27 L2CAP: Configure Request (0x04) ident 3 len 8 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 .. < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 > HCI Event: Number of Completed Packets (0x13) plen 5 #29 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30 L2CAP: Configure Response (0x05) ident 2 len 6 Source CID: 64 Flags: 0x0000 Result: Success (0x0000) > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31 L2CAP: Configure Request (0x04) ident 3 len 12 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 91 02 11 11 ...... < ACL Data TX: Handle 256 flags 0x00 dlen 14 #32 L2CAP: Command Reject (0x01) ident 3 len 6 Reason: Invalid CID in request (0x0002) Destination CID: 64 Source CID: 65 > HCI Event: Number of Completed Packets (0x13) plen 5 #33 Num handles: 1 Handle: 256 Count: 1 ... === After === ... > ACL Data RX: Handle 256 flags 0x02 dlen 12 #22 L2CAP: Connection Request (0x02) ident 2 len 4 PSM: 1 (0x0001) Source CID: 65 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #23 L2CAP: Connection Response (0x03) ident 2 len 8 Destination CID: 64 Source CID: 65 Result: Connection successful (0x0000) Status: No further information available (0x0000) < ACL Data TX: Handle 256 flags 0x00 dlen 12 #24 L2CAP: Configure Request (0x04) ident 2 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #25 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #26 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 16 #27 L2CAP: Configure Request (0x04) ident 3 len 8 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 .. < ACL Data TX: Handle 256 flags 0x00 dlen 18 #28 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 > HCI Event: Number of Completed Packets (0x13) plen 5 #29 Num handles: 1 Handle: 256 Count: 1 > ACL Data RX: Handle 256 flags 0x02 dlen 14 #30 L2CAP: Configure Response (0x05) ident 2 len 6 Source CID: 64 Flags: 0x0000 Result: Success (0x0000) > ACL Data RX: Handle 256 flags 0x02 dlen 20 #31 L2CAP: Configure Request (0x04) ident 3 len 12 Destination CID: 64 Flags: 0x0000 Option: Unknown (0x10) [hint] 01 00 91 02 11 11 ..... < ACL Data TX: Handle 256 flags 0x00 dlen 18 #32 L2CAP: Configure Response (0x05) ident 3 len 10 Source CID: 65 Flags: 0x0000 Result: Success (0x0000) Option: Maximum Transmission Unit (0x01) [mandatory] MTU: 672 < ACL Data TX: Handle 256 flags 0x00 dlen 12 #33 L2CAP: Configure Request (0x04) ident 3 len 4 Destination CID: 65 Flags: 0x0000 > HCI Event: Number of Completed Packets (0x13) plen 5 #34 Num handles: 1 Handle: 256 Count: 1 > HCI Event: Number of Completed Packets (0x13) plen 5 #35 Num handles: 1 Handle: 256 Count: 1 ... Signed-off-by: Howard Chung <howardchung@google.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index eb2804ac50756..12a50e5a9f452 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4134,7 +4134,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, return 0; } - if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) { + if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2 && + chan->state != BT_CONNECTED) { cmd_reject_invalid_cid(conn, cmd->ident, chan->scid, chan->dcid); goto unlock; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WEtKHE86ZF9a6QAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 06:40:47 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SNxnGU86ZF9/TQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 06:40:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 02B574096B; Fri, 18 Sep 2020 06:40:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727279AbgIRCET (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 17 Sep 2020 22:04:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:51528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727265AbgIRCET (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 17 Sep 2020 22:04:19 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 45D3223772; Fri, 18 Sep 2020 02:04:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394655; bh=4Q7mw5KAqcmnZ9t/lXxKuMpRFZq7oX7lNAzl9x/GlCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BqVrmF9fPi1iYlGFY9omnu4mvC9FGE3KgAuA8Uz2MZROfMIoQy3O0q+NxHkuMY1no wTjOsbmvhqZqt+7QEp29RsE4AlZQAKbP7TD9WkC+iWPRu+rTHC8SPBEpqdLPL0S5o6 ZrT3s9HNus7RwWE3pVdpfm6PR0t0xHP5hubjkdZo= From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alain Michaud <alainm@chromium.org>, Marcel Holtmann <marcel@holtmann.org>, Sasha Levin <sashal@kernel.org>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 151/330] Bluetooth: guard against controllers sending zero'd events Date: Thu, 17 Sep 2020 21:58:11 -0400 Message-Id: <20200918020110.2063155-151-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.97 / 15.00 / 15.00 X-Rspamd-Queue-Id: 02B574096B X-Rspamd-UID: 760f93 From: Alain Michaud <alainm@chromium.org> [ Upstream commit 08bb4da90150e2a225f35e0f642cdc463958d696 ] Some controllers have been observed to send zero'd events under some conditions. This change guards against this condition as well as adding a trace to facilitate diagnosability of this condition. Signed-off-by: Alain Michaud <alainm@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/bluetooth/hci_event.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 7bf6860fed783..1bbeb14b8b64e 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5853,6 +5853,11 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) u8 status = 0, event = hdr->evt, req_evt = 0; u16 opcode = HCI_OP_NOP; + if (!event) { + bt_dev_warn(hdev, "Received unexpected HCI Event 00000000"); + goto done; + } + if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) { struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; opcode = __le16_to_cpu(cmd_hdr->opcode); @@ -6064,6 +6069,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) req_complete_skb(hdev, status, opcode, orig_skb); } +done: kfree_skb(orig_skb); kfree_skb(skb); hdev->stat.evt_rx++; -- 2.25.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kBB1HMKAZF92aAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 11:41:22 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 8EL/GMKAZF/6/wEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 11:41:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=oracle.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id DBF5AA0BAC; Fri, 18 Sep 2020 11:41:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbgIRJlO (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 05:41:14 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:54134 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbgIRJlO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 05:41:14 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08I9Os6m163718; Fri, 18 Sep 2020 09:41:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=vDBF5kFrgqmdPnZPlrHbxd9DtRdslvQv1y7jICfqxDw=; b=F56FMjbpDm/iShzCGMW7SrZG5PraP2yUgvS0H5xYmRNE1E2U1/M1BacXiCtTvPDll3Hg /qSAUoeHQtEWOBAwHy9sAmtq77vmlyrPIJ1MXOlxgH9gO6B4YaGunJRjXKU9hG2lCocf AJon8270mfDwuS4docu6jWFBMHzFlMP/EKwp7j45FLId+270pEzOaAdof1K5WLdZoZ1C n7qlYNLRNecl71neEhxJkt7MbNodNOBWlzQD7VdnaFSvpgOFtXEW6uVaRuLiceE/q1Z9 EHOv1jDsCJn8wmbXTXbeTof1koOS4duK0d3efdk0MeWKKVboTRJ8ZBbJFBnPguYf92S8 Rg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 33j91dyvvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 18 Sep 2020 09:41:11 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08I9Q6dH094197; Fri, 18 Sep 2020 09:39:10 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 33khppefxb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Sep 2020 09:39:10 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 08I9d8Iq021928; Fri, 18 Sep 2020 09:39:08 GMT Received: from mwanda (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 18 Sep 2020 09:39:07 +0000 Date: Fri, 18 Sep 2020 12:39:02 +0300 From: Dan Carpenter <dan.carpenter@oracle.com> To: kiraank@gmail.com Cc: linux-bluetooth@vger.kernel.org Subject: [bug report] Bluetooth: btintel: Add infrastructure to read controller information Message-ID: <20200918093902.GA882111@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9747 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=3 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9747 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 suspectscore=3 mlxlogscore=999 clxscore=1011 adultscore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009180079 Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.02 / 15.00 / 15.00 X-Rspamd-Queue-Id: DBF5AA0BAC X-Rspamd-UID: 9fb720 Hello Kiran K, The patch 57375beef71a: "Bluetooth: btintel: Add infrastructure to read controller information" from Sep 14, 2020, leads to the following static checker warning: drivers/bluetooth/btintel.c:490 btintel_read_version_tlv() error: 'tlv->len' from user is not capped properly drivers/bluetooth/btintel.c 426 /* Consume Command Complete Status field */ 427 skb_pull(skb, 1); 428 429 /* Event parameters contatin multiple TLVs. Read each of them 430 * and only keep the required data. Also, it use existing legacy 431 * version field like hw_platform, hw_variant, and fw_variant 432 * to keep the existing setup flow 433 */ 434 while (skb->len) { ^^^^^^^^ I feel like these days we are trying to not trust firmware... Smatch is complaining because it distrusts all skb->data information, but unless the devs at Google have a way to connect a fuzzer to this then trusting is probably harmless. Anyway, the rest of this email assumes that fuzzing is possible. If skb->len is less than sizeof(*tlv) then it will read beyond the end of the skb. while (skb->len >= sizeof(struct intel_tlv)) { But struct intel_tlv is variable length so it's more complicated than just testing while we need aditional tests below. 435 struct intel_tlv *tlv; 436 437 tlv = (struct intel_tlv *)skb->data; if (struct_size(tlv->len, val, tvl) > skb->len) return -EINVAL; The length has to be at least 1. if (tvl->len < 1) return -EINVAL; 438 switch (tlv->type) { 439 case INTEL_TLV_CNVI_TOP: Ever test which is reads more than 1 byte has to have a check: if (tvl->len < sizeof(u32)) return -EINVAL; 440 version->cnvi_top = get_unaligned_le32(tlv->val); 441 break; 442 case INTEL_TLV_CNVR_TOP: Here too, etc. 443 version->cnvr_top = get_unaligned_le32(tlv->val); 444 break; 445 case INTEL_TLV_CNVI_BT: 446 version->cnvi_bt = get_unaligned_le32(tlv->val); 447 break; 448 case INTEL_TLV_CNVR_BT: 449 version->cnvr_bt = get_unaligned_le32(tlv->val); 450 break; 451 case INTEL_TLV_DEV_REV_ID: 452 version->dev_rev_id = get_unaligned_le16(tlv->val); 453 break; 454 case INTEL_TLV_IMAGE_TYPE: 455 version->img_type = tlv->val[0]; 456 break; 457 case INTEL_TLV_TIME_STAMP: if (tvl->len < sizeof(u16)) return -EINVAL; 458 version->timestamp = get_unaligned_le16(tlv->val); 459 break; 460 case INTEL_TLV_BUILD_TYPE: 461 version->build_type = tlv->val[0]; 462 break; 463 case INTEL_TLV_BUILD_NUM: 464 version->build_num = get_unaligned_le32(tlv->val); 465 break; 466 case INTEL_TLV_SECURE_BOOT: 467 version->secure_boot = tlv->val[0]; 468 break; 469 case INTEL_TLV_OTP_LOCK: 470 version->otp_lock = tlv->val[0]; 471 break; 472 case INTEL_TLV_API_LOCK: 473 version->api_lock = tlv->val[0]; 474 break; 475 case INTEL_TLV_DEBUG_LOCK: 476 version->debug_lock = tlv->val[0]; 477 break; 478 case INTEL_TLV_MIN_FW: if (tvl->len < 3) return -EINVAL; 479 version->min_fw_build_nn = tlv->val[0]; 480 version->min_fw_build_cw = tlv->val[1]; 481 version->min_fw_build_yy = tlv->val[2]; 482 break; 483 case INTEL_TLV_LIMITED_CCE: 484 version->limited_cce = tlv->val[0]; 485 break; 486 case INTEL_TLV_SBE_TYPE: 487 version->sbe_type = tlv->val[0]; 488 break; 489 case INTEL_TLV_OTP_BDADDR: 490 memcpy(&version->otp_bd_addr, tlv->val, tlv->len); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tlv->len comes from the network and it's 0-255. If it's more than 6 then this will corrupt memory. There is no caller for this function yet in linux-next so if tvl->len is less than 6 will that leave uninitialized memory in ->otp_bd_addr? if (tlv->len != sizeof(version->otp_bd_addr)) return -EINVAL; 491 break; 492 default: 493 /* Ignore rest of information */ 494 break; 495 } 496 /* consume the current tlv and move to next*/ 497 skb_pull(skb, tlv->len + sizeof(*tlv)); 498 } 499 500 kfree_skb(skb); 501 return 0; regards, dan carpenter Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +PAsCM6VZF9BbQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 13:11:10 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id SN44Bc6VZF9cEQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 13:11:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id DCEE940963; Fri, 18 Sep 2020 13:11:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726118AbgIRLKz (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 07:10:55 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:54106 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbgIRLKy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 07:10:54 -0400 X-Greylist: delayed 319 seconds by postgrey-1.27 at vger.kernel.org; Fri, 18 Sep 2020 07:10:54 EDT X-SpamFilter-By: ArmorX SpamTrap 5.69 with qID 08IB5NfX4016857, This message is accepted by code: ctloc85258 Received: from RSEXMBS01.realsil.com.cn ([172.29.17.195]) by rtits2.realtek.com.tw (8.15.2/2.66/5.86) with ESMTPS id 08IB5NfX4016857 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 18 Sep 2020 19:05:23 +0800 Received: from laptop-alex (172.29.73.42) by RSEXMBS01.realsil.com.cn (172.29.17.195) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Fri, 18 Sep 2020 19:05:22 +0800 Date: Fri, 18 Sep 2020 19:02:23 +0800 From: Alex Lu <alex_lu@realsil.com.cn> To: Marcel Holtmann <marcel@holtmann.org> CC: Johan Hedberg <johan.hedberg@gmail.com>, <linux-bluetooth@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Max Chou <max.chou@realtek.com> Subject: [PATCH] Bluetooth: Fix the vulnerable issue on enc key size Message-ID: <20200918110223.GA10235@laptop-alex> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Originating-IP: [172.29.73.42] X-ClientProxiedBy: RSEXMBS01.realsil.com.cn (172.29.17.195) To RSEXMBS01.realsil.com.cn (172.29.17.195) Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.05 / 15.00 / 15.00 X-Rspamd-Queue-Id: DCEE940963 X-Rspamd-UID: b92562 When someone attacks the service provider, it creates connection, authenticates. Then it requests key size of one byte and it identifies the key with brute force methods. After l2cap info req/resp exchange is complete. the attacker sends l2cap connect with specific PSM. In above procedure, there is no chance for the service provider to check the encryption key size before l2cap_connect(). Because the state of l2cap chan in conn->chan_l is BT_LISTEN, there is no l2cap chan with the state of BT_CONNECT or BT_CONNECT2. So service provider should check the encryption key size in l2cap_connect() Signed-off-by: Alex Lu <alex_lu@realsil.com.cn> --- net/bluetooth/l2cap_core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index ade83e224567..63df961d402d 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4150,6 +4150,13 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn, if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) { if (l2cap_chan_check_security(chan, false)) { + if (!l2cap_check_enc_key_size(conn->hcon)) { + l2cap_state_change(chan, BT_DISCONN); + __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); + result = L2CAP_CR_SEC_BLOCK; + status = L2CAP_CS_NO_INFO; + goto response; + } if (test_bit(FLAG_DEFER_SETUP, &chan->flags)) { l2cap_state_change(chan, BT_CONNECT2); result = L2CAP_CR_PEND; -- 2.21.0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4Eu8DR7uZF8rngEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 19:27:58 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2Fm+Ch7uZF8ONgAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 19:27:58 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E29CBA0B2B; Fri, 18 Sep 2020 19:27:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726241AbgIRR1v (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 13:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbgIRR1u (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 13:27:50 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E94EC0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 10:27:50 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id 60so6113404otw.3 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 10:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0uTZEMN1xCM+J5UEYe9o/lYG2rXaLpeL7/RLjKrG2cc=; b=oDBlncBYKvJmxGjuPTCd49/4Tim7cgXOF0PFAYa+OOu7FW6Di0yIPKJ+vbSgtlagkt eZ3Hp6aGOIODUqrZyWRNGFTkBu/KllOQ0WSAokk7Sa0GNSkbImQtBd/zsMK74UejDKrw pBtNOjIjkxqZPH16gNpjBJD8xJqQ03HNDeHbJtBhRBPYkhQ3sLDjX0SvmDmB4xmT56lj OoVgFxm4wRD6SuZRZOWW8O7EpjLPSdhow1IYI4oYOcUkl6hbxvXb9xdMVxg7HVMf99G1 S2SdEhCTz5O6upOQRa9kzJAfalx37+D2JsU32exKinUedgbo8kPVYxpY0fEYA4HR4zI5 mY0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0uTZEMN1xCM+J5UEYe9o/lYG2rXaLpeL7/RLjKrG2cc=; b=H3gIYpSMHLdNHyTYT3iaRRCZAs9wX7KT3hUjMca4sI8A1U9mLU1peuUDxrX8cJQocd uoNHUnGauzaHW96w+4PtPUp8NMZxqjEOaHfo2z0TYyT8c9SZoy1MKqdISaBcvwpZTars /iEsSwJvDD4cAJ3TPmwOPtji9+8oBBjlmE4VP6CRnIAn8Q2WVfQii8Axj7w1h4zolk3Q +tQQXXe10l6TDjKnb6QwCxfpUdw30clVR+YuI4AoR1aNBgGy4ByIVE7MtrqKqJHAjuOJ JbWuFqyXaEse3IrHyYdeRY/+UE80AZszgyBMTu4HXWLmNHHtYsBh+ud04B0il8dARy3y mIhQ== X-Gm-Message-State: AOAM531lpUM5qP0FoIhuYFyVoHWl0n7L8WcysRarr+zs48E9wzwkXJz2 rIT8qm3rzPx6TqQwu/885HGknd1k7ovRIVTuDSU= X-Google-Smtp-Source: ABdhPJz55zjCGX0eAX3g0u1Hk3C3a5M8xxW5jaKdNW9XJyV+Yzvt4OsS577paFUqDZLNNJGNaE2F7V37gJWdcqT/Bto= X-Received: by 2002:a9d:4695:: with SMTP id z21mr23792736ote.91.1600450069296; Fri, 18 Sep 2020 10:27:49 -0700 (PDT) MIME-Version: 1.0 References: <20200918121348.BlueZ.v2.1.I1f083629d41c747a33a3937fbc199ea37dccde12@changeid> <20200918121348.BlueZ.v2.2.Iac5207375d22fb7b96ae4ef73b49ae4ab457219c@changeid> In-Reply-To: <20200918121348.BlueZ.v2.2.Iac5207375d22fb7b96ae4ef73b49ae4ab457219c@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 18 Sep 2020 10:27:37 -0700 Message-ID: <CABBYNZLvYtF6eB0K5VrvpTcZpgmsg3epYyZNr39aZrC-JK8PFQ@mail.gmail.com> Subject: Re: [BlueZ PATCH v2 2/2] core: Add param to disable interleave scan To: Howard Chung <howardchung@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Manish Mandlik <mmandlik@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.34 / 15.00 / 15.00 X-Rspamd-Queue-Id: E29CBA0B2B X-Rspamd-UID: 8f2ecb Hi Howard, On Thu, Sep 17, 2020 at 9:14 PM Howard Chung <howardchung@google.com> wrote: > > This patch adds parameter to enable/disable the interleave scan feature. > --- > > (no changes since v1) > > src/adapter.c | 9 +++++++++ > src/hcid.h | 1 + > src/main.c | 6 ++++++ > src/main.conf | 6 ++++++ > 4 files changed, 22 insertions(+) > > diff --git a/src/adapter.c b/src/adapter.c > index c0e95b48a1c4..a2c782e308bb 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -4449,6 +4449,15 @@ static void load_default_system_params(struct btd_adapter *adapter) > len += sizeof(params[i].u16); > } > > + if (main_opts.default_params.enable_advmon_interleave_scan != 0xFFFF) { > + params[i].entry.type = 0x001f; > + params[i].entry.length = sizeof(params[i].u16); > + params[i].u16 = > + main_opts.default_params.enable_advmon_interleave_scan; > + ++i; > + len += sizeof(params[i].u16); > + } > + > err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG, > adapter->dev_id, len, params, NULL, NULL, NULL); > if (!err) > diff --git a/src/hcid.h b/src/hcid.h > index c3e5fe803543..c6717be62c48 100644 > --- a/src/hcid.h > +++ b/src/hcid.h > @@ -96,6 +96,7 @@ struct main_opts { > > uint16_t advmon_allowlist_scan_duration; > uint16_t advmon_no_filter_scan_duration; > + uint16_t enable_advmon_interleave_scan; > } default_params; > > > diff --git a/src/main.c b/src/main.c > index e222ed3bf855..3433130bc419 100644 > --- a/src/main.c > +++ b/src/main.c > @@ -125,6 +125,7 @@ static const char *controller_options[] = { > "LEAutoconnecttimeout", > "AdvMonAllowlistScanDuration", > "AdvMonNoFilterScanDuration", > + "EnableAdvMonInterleaveScan", > NULL > }; > > @@ -444,6 +445,10 @@ static void parse_controller_config(GKeyFile *config) > &main_opts.default_params.advmon_no_filter_scan_duration, > 1, > 10000}, > + { "EnableAdvMonInterleaveScan", > + &main_opts.default_params.enable_advmon_interleave_scan, > + 0, > + 1}, > }; > uint16_t i; > > @@ -711,6 +716,7 @@ static void init_defaults(void) > main_opts.default_params.num_entries = 0; > main_opts.default_params.br_page_scan_type = 0xFFFF; > main_opts.default_params.br_scan_type = 0xFFFF; > + main_opts.default_params.enable_advmon_interleave_scan = 0xFFFF; > > if (sscanf(VERSION, "%hhu.%hhu", &major, &minor) != 2) > return; > diff --git a/src/main.conf b/src/main.conf > index 3b341f44c9cf..c300a3b81086 100644 > --- a/src/main.conf > +++ b/src/main.conf > @@ -159,6 +159,12 @@ > # Default: 500 > #AdvMonNoFilterScanDuration= > > +# Enable/Disable Advertisement Monitor interleave scan for power saving. > +# 0: disable > +# 1: enable > +# Defaults to 1 > +#EnableAdvMonInterleaveScan= This should probably ve defaulting to false until we consider the interface stable and document how this feature works. > [GATT] > # GATT attribute cache. > # Possible values: > -- > 2.28.0.681.g6f77f65b4e-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mMo7B7fvZF8ZEwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 19:34:47 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kHHgBLfvZF+E7gAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 19:34:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4778940963; Fri, 18 Sep 2020 19:34:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726139AbgIRRek (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 13:34:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbgIRRek (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 13:34:40 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7924C0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 10:34:39 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id 34so3866858pgo.13 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 10:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=497rb4WJT/kTaT9XLSWECcXtCLYhvkXiX7i51B/vhLw=; b=tdQ4G8Wyw8QiJjvyy9oHJdrGRn7AYwrzzvqCav2W87Nmxe4F6KaiWurIv0KY5YS2Ku 6/63J1UFasmO9dn+j3ZoKh8K7ylylQ4YoAREIMGrFJh/uCPhpIEgHX3P3KpBcGMdUQ6+ GdOvBU8jdpIY/pC9TrFGyyLnhF1bcwOeXJCd/UINyuYT1jiEyq54KFiFO8rvlbPPNLun VuDkAsRQ/q8bU3iGDYnXCcysllJWqHcO1UBHXZVwvadcbNQdj0WgFVM9AmrXaE8i3nAF RFQoGhcd5hUuU199+v2e6MDz+k+wA7ZNIXYIU5I/UGBnINaXU9VGDYluZ1Nn8Py7cXzb lUhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=497rb4WJT/kTaT9XLSWECcXtCLYhvkXiX7i51B/vhLw=; b=fR8rqkmTNVuh2oKH/zamohfS7jyx6oHp64GkMvj/3YB5lD3/qY6xLP9jBDUgE44d3x KPyL4ZzPHluhHD79Oge1L+vPhGWaajem67o1wL/Cq5a4+zostT/vhqWtLvBoYMxN2FHO C07A6210A+v+hNCnNdgaJlx/Iy4gVtvLBnB2kSVVciowiJs68xV0z7nZI1vca5J++rgL LjbIW4xvlGa6OvKRqSV8iP6AHY825b0bTgTlH9dxP5h23SthF+kiCBUsr0BImcxhDKSV UQTpwqZCBYCOoOHl7TYmJxrOIPXK4FlBa61XM03m02LpDMODhv2qfeFU2lGMIx2dnNDJ ZyxA== X-Gm-Message-State: AOAM530WQvGonchpZ4OV2TjuvwONN3kgl4pmNd8w+huSi0gNltTZgzFf t277+nrqsFhGlptQL//DTjN5bQKIXyA= X-Google-Smtp-Source: ABdhPJxWJL4CljxjQ8ztbLEoW1MH0CSBNJPAgk5eWBUZjlX32GXB2sq/decVlpsAWWUYkYVmKqNHow== X-Received: by 2002:a63:29c8:: with SMTP id p191mr10309440pgp.45.1600450478906; Fri, 18 Sep 2020 10:34:38 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id 5sm3780965pgf.21.2020.09.18.10.34.38 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 10:34:38 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2] avdtp: Fix not checking if stream is already set as pending open Date: Fri, 18 Sep 2020 10:34:36 -0700 Message-Id: <20200918173436.3184738-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 1.85 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4778940963 X-Rspamd-UID: 746957 From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> When receiving a Open command the stream will be set as pending_open but the remote may attempt to send yet another Open command in the meantime resulting in another setup and yet another timer leaving the old timer active which will likely cause a crash when it expires. --- profiles/audio/avdtp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 782268c08..e0c6f44f0 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -1687,7 +1687,7 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction, stream = sep->stream; - if (sep->ind && sep->ind->open) { + if (sep->ind && sep->ind->open && !session->pending_open) { if (!sep->ind->open(session, sep, stream, &err, sep->user_data)) goto failed; @@ -1699,11 +1699,13 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction, AVDTP_OPEN, NULL, 0)) return FALSE; - stream->open_acp = TRUE; - session->pending_open = stream; - stream->timer = g_timeout_add_seconds(REQ_TIMEOUT, + if (!session->pending_open) { + stream->open_acp = TRUE; + session->pending_open = stream; + stream->timer = g_timeout_add_seconds(REQ_TIMEOUT, stream_open_timeout, stream); + } return TRUE; -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wKJOOrDxZF+QCwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 19:43:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id mDAFN7DxZF+L6AAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 19:43:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id A3769A0BA8; Fri, 18 Sep 2020 19:43:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726118AbgIRRnE (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 13:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbgIRRnE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 13:43:04 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69BB1C0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 10:43:04 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id v20so7969003oiv.3 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 10:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h2SK2ruiDT8U5SSsr85d6fpub5Fo0LTc0NW0N6lMueg=; b=rq6DW8Bxv7+GmV8gqQryMJo7KGa9XUqMZFXmRBlIwtm0WNjH6FVf6W9+qxYP1772TT CNBHyQWWgKlEdmBE/oFnmaeXP2kus2KeazGP0kERuzsNDQ127PoTly2hTjBLzzYvV2Rz j6Dsswg2WFg5SESOGgAi9db8DVRfPvRy/ktrAiM5i2WD4iODZitiRkyv2ZMx0H0Vtdjn cpQptoteMdLQktFISwfkTeeyVFuL505Qp2lW8T3CR41R9OWgSJd5ntAzZ3hM3rtCl9FI 8nB/685FQSRxgt0DDfNNwe8nszK4sUmBUDF8RFhpE0g3uUNdKtO16RNS9wAkzTnKTxcJ dVMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h2SK2ruiDT8U5SSsr85d6fpub5Fo0LTc0NW0N6lMueg=; b=F5hs3X2VVPrRlWScWKUZ0uPEMmUrcNOijSEPWrN7NlkBGxFfzMMslmY4KZi7M6yvri X2pPHrAD3D+hjYbTq7MDoRUlQi8VDyzpF41Dh0yHn2C2jTdlK/FoDFdVHTXQzl8Iu2wJ 8fJBXtDIe98m2krsXi1S4gZUKTT63W2iSuShP7cjxWOaVQQiBrGt/tOujkGzrQKwAgN4 hKh0WG0CeV1mYyGjkxpQvhmu8rsqPnbh2wnuk/ebI0YwkI3ICDszicTo6RyIhXQyoXOf DHF9ryMJD9oGzdOM9uxtVItI46aGWqsp9qn2rF506RfCHjJMG0ntPouZUJ6i9t0B02ul M4mA== X-Gm-Message-State: AOAM5320ice1zq8CCX+mkjD2SqJ+FzY4r3rUGmLL5dxnK/6M2roqb7PH Kuu1Lt3iM7xHc0KLrWiz7I1iyDH5VGe+zH/jNwTJk5/s X-Google-Smtp-Source: ABdhPJzblDKCxIF1xuy+wcuHjzqN3JQsJeUlBtU41xxDtlCYlfXLorRDxvWquSQJ9e+oftKmhgpb4m7gMyWDXmOgAos= X-Received: by 2002:aca:3e08:: with SMTP id l8mr9522001oia.152.1600450983490; Fri, 18 Sep 2020 10:43:03 -0700 (PDT) MIME-Version: 1.0 References: <20200917221034.154218-1-sonnysasaka@chromium.org> In-Reply-To: <20200917221034.154218-1-sonnysasaka@chromium.org> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 18 Sep 2020 10:42:52 -0700 Message-ID: <CABBYNZ+d=dtHAtHOi7es_dGx4B7WnrE1dHnd_W1UvXRH0DVSog@mail.gmail.com> Subject: Re: [PATCH BlueZ v2] a2dp: Keep track of ref ownership of a2dp_setup To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.87 / 15.00 / 15.00 X-Rspamd-Queue-Id: A3769A0BA8 X-Rspamd-UID: ea72d1 Hi Sonny, On Thu, Sep 17, 2020 at 3:13 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > Currently transport_cb and abort_cfm make assumption that they have an > a2dp_setup reference held as a result of open_ind invocation. In the > field this is not always true, for example when the peer device opens an > L2CAP channel for AVDTP transport channel without sending AVDTP_OPEN > request through the AVDTP signaling channel first. Although in this case > the peer device does not behave correctly, we should protect this > possible crash from happening by making sure that transport_cb and > abort_cfm are really holding a reference of a2dp_setup object before > trying to unref them. > > After grabbing a reference, open_ind stores the pointer in > stream->user_data. If this field is set, that means there is a pending > AVDTP_OPEN command and it needs to be unref-fed later once and only > once: when the transport channel is created (transport_cb) or when the > AVDTP_OPEN command is aborted (abort_cfm). If this field is not set, > nothing should unref it. This enforces that the reference counting is > correct regardless of the behavior of the peer device. > > A sample crash stack trace from Chrome OS: > * thread #1, stop reason = signal SIGSEGV > * frame #0: 0x0c64f0e8 bluetoothd`queue_remove_all at queue.c:351 > frame #1: 0x0c64f086 bluetoothd`queue_destroy at queue.c:73 > frame #2: 0x0c6022b0 bluetoothd`setup_unref at a2dp.c:222 > frame #3: 0x0c604942 bluetoothd`transport_cb at a2dp.c:2229 > frame #4: 0x0c61e35c bluetoothd`accept_cb at btio.c:203 > frame #5: 0xf679523c libglib-2.0.so.0`g_main_context_dispatch at gmain.c:3182 > frame #6: 0xf67954aa libglib-2.0.so.0`g_main_context_iterate at gmain.c:3920 > frame #7: 0xf679569a libglib-2.0.so.0`g_main_loop_run at gmain.c:4116 > frame #8: 0x0c65a5a0 bluetoothd`mainloop_run at mainloop-glib.c:79 > frame #9: 0x0c65a7ea bluetoothd`mainloop_run_with_signal at mainloop-notify.c:201 > frame #10: 0x0c6477ec bluetoothd`main at main.c:772 > frame #11: 0xf65bc0a2 libc.so.6`__libc_start_main at libc-start.c:308 > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > --- > profiles/audio/a2dp.c | 34 ++++++++++++++++++++++++++-------- > profiles/audio/avdtp.c | 17 +++++++++++++++++ > profiles/audio/avdtp.h | 5 +++++ > 3 files changed, 48 insertions(+), 8 deletions(-) > > diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c > index 2feea66c0..26147f96e 100644 > --- a/profiles/audio/a2dp.c > +++ b/profiles/audio/a2dp.c > @@ -915,6 +915,11 @@ static void update_last_used(struct a2dp_channel *chan, struct a2dp_sep *lsep, > avdtp_get_seid(rsep)); > } > > +static void destroy_setup(void *data) > +{ > + setup_unref(data); > +} > + > static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep, > struct avdtp_stream *stream, uint8_t *err, > void *user_data) > @@ -927,10 +932,21 @@ static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep, > else > DBG("Source %p: Open_Ind", sep); > > + if (avdtp_stream_get_user_data(stream)) { > + warn("setup already exists"); > + return FALSE; > + } I've sent a patch fixing the code when Open is sent multiple times, we were actually overwriting pending_open and its timer, I think it might be the source of these crashes, not an unbalanced reference of the setup. Also it is possible that the headsets doing this sort of operation would like us to start the L2CAP connection procedure so we could perhaps attempt to connect it after a sorter timer, but it might be hard to check how well it would work without having such a headset to test if it really does help. > setup = a2dp_setup_get(session); > if (!setup) > return FALSE; > > + /* > + * Use avdtp_stream's user_data to keep the reference ownership of the > + * setup object. This ensures that this reference will be unref-ed > + * exactly once. > + */ > + avdtp_stream_set_user_data(stream, setup, destroy_setup); > setup->stream = stream; > > if (!err && setup->chan) > @@ -1285,14 +1301,13 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, > void *user_data) > { > struct a2dp_sep *a2dp_sep = user_data; > - struct a2dp_setup *setup; > + struct a2dp_setup *setup = avdtp_stream_get_user_data(stream); > > if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK) > DBG("Sink %p: Abort_Cfm", sep); > else > DBG("Source %p: Abort_Cfm", sep); > > - setup = find_setup_by_session(session); > if (!setup) > return; > > @@ -1302,6 +1317,7 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, > } > > setup_unref(setup); > + avdtp_stream_set_user_data(stream, NULL, NULL); > } > > static gboolean reconf_ind(struct avdtp *session, struct avdtp_local_sep *sep, > @@ -2216,11 +2232,12 @@ fail: > > static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > { > - struct a2dp_setup *setup = user_data; > + struct avdtp_stream *stream = user_data; > + struct a2dp_setup *setup = avdtp_stream_get_user_data(stream); > uint16_t omtu, imtu; > > - if (!g_slist_find(setups, setup)) { > - warn("bt_io_accept: setup %p no longer valid", setup); > + if (!setup) { > + warn("transport_cb: setup does not exist"); > g_io_channel_shutdown(io, TRUE, NULL); > return; > } > @@ -2238,8 +2255,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > goto drop; > } > > - if (!avdtp_stream_set_transport(setup->stream, > - g_io_channel_unix_get_fd(io), > + if (!avdtp_stream_set_transport(stream, g_io_channel_unix_get_fd(io), > imtu, omtu)) > goto drop; > > @@ -2249,6 +2265,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > setup->io = NULL; > > setup_unref(setup); > + avdtp_stream_set_user_data(stream, NULL, NULL); > > return; > > @@ -2297,7 +2314,8 @@ static void confirm_cb(GIOChannel *io, gpointer data) > goto drop; > } > > - if (!bt_io_accept(io, transport_cb, setup, NULL, &err)) { > + if (!bt_io_accept(io, transport_cb, setup->stream, NULL, > + &err)) { > error("bt_io_accept: %s", err->message); > g_error_free(err); > goto drop; > diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c > index 782268c08..76d06f47c 100644 > --- a/profiles/audio/avdtp.c > +++ b/profiles/audio/avdtp.c > @@ -366,6 +366,8 @@ struct avdtp_stream { > GSList *caps; > GSList *callbacks; > struct avdtp_service_capability *codec; > + void *user_data; > + avdtp_stream_user_data_destroy_t user_data_destroy; > guint io_id; /* Transport GSource ID */ > guint timer; /* Waiting for other side to close or open > * the transport channel */ > @@ -727,6 +729,9 @@ static void stream_free(void *data) > g_slist_free_full(stream->callbacks, g_free); > g_slist_free_full(stream->caps, g_free); > > + if (stream->user_data && stream->user_data_destroy) > + stream->user_data_destroy(stream->user_data); > + > g_free(stream); > } > > @@ -3147,6 +3152,18 @@ struct avdtp_remote_sep *avdtp_stream_get_remote_sep( > return NULL; > } > > +void avdtp_stream_set_user_data(struct avdtp_stream *stream, void *data, > + avdtp_stream_user_data_destroy_t destroy) > +{ > + stream->user_data = data; > + stream->user_data_destroy = destroy; > +} > + > +void *avdtp_stream_get_user_data(struct avdtp_stream *stream) > +{ > + return stream->user_data; > +} > + > gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd, > size_t imtu, size_t omtu) > { > diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h > index 011fea89e..247e9df75 100644 > --- a/profiles/audio/avdtp.h > +++ b/profiles/audio/avdtp.h > @@ -133,6 +133,8 @@ typedef void (*avdtp_set_configuration_cb) (struct avdtp *session, > struct avdtp_stream *stream, > struct avdtp_error *err); > > +typedef void (*avdtp_stream_user_data_destroy_t)(void *data); > + > /* Callbacks for when a reply is received to a command that we sent */ > struct avdtp_sep_cfm { > void (*set_configuration) (struct avdtp *session, > @@ -260,6 +262,9 @@ gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream, > GSList *caps); > struct avdtp_remote_sep *avdtp_stream_get_remote_sep( > struct avdtp_stream *stream); > +void avdtp_stream_set_user_data(struct avdtp_stream *stream, void *data, > + avdtp_stream_user_data_destroy_t destroy); > +void *avdtp_stream_get_user_data(struct avdtp_stream *stream); > > unsigned int avdtp_add_state_cb(struct btd_device *dev, > avdtp_session_state_cb cb, void *user_data); > -- > 2.26.2 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qFJGFFj/ZF/nUAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 20:41:28 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qFHwEFj/ZF9rWQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 20:41:28 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7E32840675; Fri, 18 Sep 2020 20:41:21 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726159AbgIRSlU (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 14:41:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbgIRSlU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 14:41:20 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32C21C0613CF for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 11:41:20 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id n13so6976417edo.10 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 11:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wms5trIpKfVccABLrif0z9aki5fMPBGPNTttsMku0Gg=; b=oCgi+35e+SGXJpQtP0aktvxdT+7faA+kec80zRzmZGxqO7HKYHkf0V4Yg5xFlIva4/ o+ork1MYbbbDtIpOHh5M4+3PrZWb8t0gjw65lZRQJ1HXnkEt7eQe4J57iISUOXUzeytv SVfY+4ptXwd6+OlascjkgvxtaJjhzupncoDW8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wms5trIpKfVccABLrif0z9aki5fMPBGPNTttsMku0Gg=; b=ilDagKq/tyvzR7FzdgXQncIS3TVQaxAc/A0LyyAJhqNAe4L0r4Xm69Lz1QugljUXaT VRQjSQBck9e8vK9mJ7EGOzDA1lKpVj1ndPlFxRGpMCTFwS6qT0QWKN6xCO0rqUed4Mni qiX2/GVFmJ3QRvCyffgOsdg1ceiLFACCWD6eMmHoo762/5bmpRxa+aS9Jd1xacXk2iOr uxakfgUavNabYG0sOxWFBatNj9gOWfNfOE2eoJ3vLDqsojvNvli78P69YXbzwXMH/MaO V6J0Z1ccK6HXIEz8DSy0OBnu/Kzybl1/ms7kzY4v0XXIT5izfFyPD1xJv/znx3XHVc2P bh9Q== X-Gm-Message-State: AOAM533jLjnVAIZgFmgHSWGtjXvL8R/UR0qY6lvki7V0GdA8DuC+KC0O 6DuUDR/LD2Ksd1An0AC+oWN/QYKVu8lOjg== X-Google-Smtp-Source: ABdhPJwW1saM/kskq2Xepr+thaxo/Rl9iyBJ4ZaHMQ6nhrOf7KnhzoGWZtxx+/1DnkWTvsC55orgYw== X-Received: by 2002:a05:6402:1151:: with SMTP id g17mr40854885edw.227.1600454478017; Fri, 18 Sep 2020 11:41:18 -0700 (PDT) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com. [209.85.221.54]) by smtp.gmail.com with ESMTPSA id qu11sm2827229ejb.15.2020.09.18.11.41.17 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Sep 2020 11:41:17 -0700 (PDT) Received: by mail-wr1-f54.google.com with SMTP id m6so6618790wrn.0 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 11:41:17 -0700 (PDT) X-Received: by 2002:a5d:468f:: with SMTP id u15mr38859518wrq.336.1600454476464; Fri, 18 Sep 2020 11:41:16 -0700 (PDT) MIME-Version: 1.0 References: <20200917221034.154218-1-sonnysasaka@chromium.org> <CABBYNZ+d=dtHAtHOi7es_dGx4B7WnrE1dHnd_W1UvXRH0DVSog@mail.gmail.com> In-Reply-To: <CABBYNZ+d=dtHAtHOi7es_dGx4B7WnrE1dHnd_W1UvXRH0DVSog@mail.gmail.com> From: Sonny Sasaka <sonnysasaka@chromium.org> Date: Fri, 18 Sep 2020 11:41:05 -0700 X-Gmail-Original-Message-ID: <CAO271mny2RkCtb8Cs6uEcLNHhSSVcFoCa24gMATubJXPRCmB2Q@mail.gmail.com> Message-ID: <CAO271mny2RkCtb8Cs6uEcLNHhSSVcFoCa24gMATubJXPRCmB2Q@mail.gmail.com> Subject: Re: [PATCH BlueZ v2] a2dp: Keep track of ref ownership of a2dp_setup To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.40 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7E32840675 X-Rspamd-UID: cee5a4 Hi Luiz, On Fri, Sep 18, 2020 at 10:43 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Sonny, > > On Thu, Sep 17, 2020 at 3:13 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > > > Currently transport_cb and abort_cfm make assumption that they have an > > a2dp_setup reference held as a result of open_ind invocation. In the > > field this is not always true, for example when the peer device opens an > > L2CAP channel for AVDTP transport channel without sending AVDTP_OPEN > > request through the AVDTP signaling channel first. Although in this case > > the peer device does not behave correctly, we should protect this > > possible crash from happening by making sure that transport_cb and > > abort_cfm are really holding a reference of a2dp_setup object before > > trying to unref them. > > > > After grabbing a reference, open_ind stores the pointer in > > stream->user_data. If this field is set, that means there is a pending > > AVDTP_OPEN command and it needs to be unref-fed later once and only > > once: when the transport channel is created (transport_cb) or when the > > AVDTP_OPEN command is aborted (abort_cfm). If this field is not set, > > nothing should unref it. This enforces that the reference counting is > > correct regardless of the behavior of the peer device. > > > > A sample crash stack trace from Chrome OS: > > * thread #1, stop reason = signal SIGSEGV > > * frame #0: 0x0c64f0e8 bluetoothd`queue_remove_all at queue.c:351 > > frame #1: 0x0c64f086 bluetoothd`queue_destroy at queue.c:73 > > frame #2: 0x0c6022b0 bluetoothd`setup_unref at a2dp.c:222 > > frame #3: 0x0c604942 bluetoothd`transport_cb at a2dp.c:2229 > > frame #4: 0x0c61e35c bluetoothd`accept_cb at btio.c:203 > > frame #5: 0xf679523c libglib-2.0.so.0`g_main_context_dispatch at gmain.c:3182 > > frame #6: 0xf67954aa libglib-2.0.so.0`g_main_context_iterate at gmain.c:3920 > > frame #7: 0xf679569a libglib-2.0.so.0`g_main_loop_run at gmain.c:4116 > > frame #8: 0x0c65a5a0 bluetoothd`mainloop_run at mainloop-glib.c:79 > > frame #9: 0x0c65a7ea bluetoothd`mainloop_run_with_signal at mainloop-notify.c:201 > > frame #10: 0x0c6477ec bluetoothd`main at main.c:772 > > frame #11: 0xf65bc0a2 libc.so.6`__libc_start_main at libc-start.c:308 > > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > > > --- > > profiles/audio/a2dp.c | 34 ++++++++++++++++++++++++++-------- > > profiles/audio/avdtp.c | 17 +++++++++++++++++ > > profiles/audio/avdtp.h | 5 +++++ > > 3 files changed, 48 insertions(+), 8 deletions(-) > > > > diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c > > index 2feea66c0..26147f96e 100644 > > --- a/profiles/audio/a2dp.c > > +++ b/profiles/audio/a2dp.c > > @@ -915,6 +915,11 @@ static void update_last_used(struct a2dp_channel *chan, struct a2dp_sep *lsep, > > avdtp_get_seid(rsep)); > > } > > > > +static void destroy_setup(void *data) > > +{ > > + setup_unref(data); > > +} > > + > > static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep, > > struct avdtp_stream *stream, uint8_t *err, > > void *user_data) > > @@ -927,10 +932,21 @@ static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep, > > else > > DBG("Source %p: Open_Ind", sep); > > > > + if (avdtp_stream_get_user_data(stream)) { > > + warn("setup already exists"); > > + return FALSE; > > + } > > I've sent a patch fixing the code when Open is sent multiple times, we > were actually overwriting pending_open and its timer, I think it might > be the source of these crashes, not an unbalanced reference of the > setup. Also it is possible that the headsets doing this sort of > operation would like us to start the L2CAP connection procedure so we > could perhaps attempt to connect it after a sorter timer, but it might > be hard to check how well it would work without having such a headset > to test if it really does help. Thanks for the patch. Although your patch "Fix not checking if stream is already set as pending open" solves an issue, this is not the issue that we are experiencing in the field. We don't have a device that can reproduce the crashes, but we got evidence from custom log messages that the crashes are caused by "the peer device opens an L2CAP channel for AVDTP transport channel without sending AVDTP_OPEN request through the AVDTP signaling channel first", as I described in the commit message of this patch. So, I believe we still need to fix that. We could solve that in avdtp by not allowing that peer behavior, but what this patch is fixing is the generic reference counting bug by having a proper reference ownership proof such that if we follow this principles, we can guarantee correct ref counting and avoid even other crashes due to unhandled unexpected peer behavior. > > > setup = a2dp_setup_get(session); > > if (!setup) > > return FALSE; > > > > + /* > > + * Use avdtp_stream's user_data to keep the reference ownership of the > > + * setup object. This ensures that this reference will be unref-ed > > + * exactly once. > > + */ > > + avdtp_stream_set_user_data(stream, setup, destroy_setup); > > setup->stream = stream; > > > > if (!err && setup->chan) > > @@ -1285,14 +1301,13 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, > > void *user_data) > > { > > struct a2dp_sep *a2dp_sep = user_data; > > - struct a2dp_setup *setup; > > + struct a2dp_setup *setup = avdtp_stream_get_user_data(stream); > > > > if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK) > > DBG("Sink %p: Abort_Cfm", sep); > > else > > DBG("Source %p: Abort_Cfm", sep); > > > > - setup = find_setup_by_session(session); > > if (!setup) > > return; > > > > @@ -1302,6 +1317,7 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, > > } > > > > setup_unref(setup); > > + avdtp_stream_set_user_data(stream, NULL, NULL); > > } > > > > static gboolean reconf_ind(struct avdtp *session, struct avdtp_local_sep *sep, > > @@ -2216,11 +2232,12 @@ fail: > > > > static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > > { > > - struct a2dp_setup *setup = user_data; > > + struct avdtp_stream *stream = user_data; > > + struct a2dp_setup *setup = avdtp_stream_get_user_data(stream); > > uint16_t omtu, imtu; > > > > - if (!g_slist_find(setups, setup)) { > > - warn("bt_io_accept: setup %p no longer valid", setup); > > + if (!setup) { > > + warn("transport_cb: setup does not exist"); > > g_io_channel_shutdown(io, TRUE, NULL); > > return; > > } > > @@ -2238,8 +2255,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > > goto drop; > > } > > > > - if (!avdtp_stream_set_transport(setup->stream, > > - g_io_channel_unix_get_fd(io), > > + if (!avdtp_stream_set_transport(stream, g_io_channel_unix_get_fd(io), > > imtu, omtu)) > > goto drop; > > > > @@ -2249,6 +2265,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > > setup->io = NULL; > > > > setup_unref(setup); > > + avdtp_stream_set_user_data(stream, NULL, NULL); > > > > return; > > > > @@ -2297,7 +2314,8 @@ static void confirm_cb(GIOChannel *io, gpointer data) > > goto drop; > > } > > > > - if (!bt_io_accept(io, transport_cb, setup, NULL, &err)) { > > + if (!bt_io_accept(io, transport_cb, setup->stream, NULL, > > + &err)) { > > error("bt_io_accept: %s", err->message); > > g_error_free(err); > > goto drop; > > diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c > > index 782268c08..76d06f47c 100644 > > --- a/profiles/audio/avdtp.c > > +++ b/profiles/audio/avdtp.c > > @@ -366,6 +366,8 @@ struct avdtp_stream { > > GSList *caps; > > GSList *callbacks; > > struct avdtp_service_capability *codec; > > + void *user_data; > > + avdtp_stream_user_data_destroy_t user_data_destroy; > > guint io_id; /* Transport GSource ID */ > > guint timer; /* Waiting for other side to close or open > > * the transport channel */ > > @@ -727,6 +729,9 @@ static void stream_free(void *data) > > g_slist_free_full(stream->callbacks, g_free); > > g_slist_free_full(stream->caps, g_free); > > > > + if (stream->user_data && stream->user_data_destroy) > > + stream->user_data_destroy(stream->user_data); > > + > > g_free(stream); > > } > > > > @@ -3147,6 +3152,18 @@ struct avdtp_remote_sep *avdtp_stream_get_remote_sep( > > return NULL; > > } > > > > +void avdtp_stream_set_user_data(struct avdtp_stream *stream, void *data, > > + avdtp_stream_user_data_destroy_t destroy) > > +{ > > + stream->user_data = data; > > + stream->user_data_destroy = destroy; > > +} > > + > > +void *avdtp_stream_get_user_data(struct avdtp_stream *stream) > > +{ > > + return stream->user_data; > > +} > > + > > gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd, > > size_t imtu, size_t omtu) > > { > > diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h > > index 011fea89e..247e9df75 100644 > > --- a/profiles/audio/avdtp.h > > +++ b/profiles/audio/avdtp.h > > @@ -133,6 +133,8 @@ typedef void (*avdtp_set_configuration_cb) (struct avdtp *session, > > struct avdtp_stream *stream, > > struct avdtp_error *err); > > > > +typedef void (*avdtp_stream_user_data_destroy_t)(void *data); > > + > > /* Callbacks for when a reply is received to a command that we sent */ > > struct avdtp_sep_cfm { > > void (*set_configuration) (struct avdtp *session, > > @@ -260,6 +262,9 @@ gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream, > > GSList *caps); > > struct avdtp_remote_sep *avdtp_stream_get_remote_sep( > > struct avdtp_stream *stream); > > +void avdtp_stream_set_user_data(struct avdtp_stream *stream, void *data, > > + avdtp_stream_user_data_destroy_t destroy); > > +void *avdtp_stream_get_user_data(struct avdtp_stream *stream); > > > > unsigned int avdtp_add_state_cb(struct btd_device *dev, > > avdtp_session_state_cb cb, void *user_data); > > -- > > 2.26.2 > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +IFvNMIMZV+CoQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 21:38:42 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 8JMXMsIMZV/IMgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 21:38:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CB028408B3; Fri, 18 Sep 2020 21:38:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726185AbgIRTig (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 15:38:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbgIRTig (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 15:38:36 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 247D0C0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 12:38:36 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id y11so7347827lfl.5 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 12:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:from:date:message-id:subject:to:cc; bh=aowMQxFjnMPe9KoJRtXpPFXt027PL0v5kj+8if/hy2Y=; b=OM6JmKTQK6gBrN1pHwKS/VzaMXomrAjWh0RzuvNEABH4NZJ3nUGNct9jRceXnQ82Uz bYa7gaLLkmAIKpZkHIZvo58NeVkbSmjBew8oqAHiIBNczkUOKuQFRmm3dsRRDmdR7R7W 2QlLmJTH2d0uarENgLJ7bOP5wfhnzGKzfOrrg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=aowMQxFjnMPe9KoJRtXpPFXt027PL0v5kj+8if/hy2Y=; b=n/FqvXavk1ob/kze3omF0w0KuBdrHq5iUDR5WmQgmORopb5hUBtiBFFCgXjytbL/tJ lcReAXVBC/nOxhJWGFyQh35B1IMHTqqMZJflbOABjOEQ4n3uEr3lrJ09c9rOMzVo59kq 7MDW597ArhLmVEslH+JsOstJT7rsPMjLNU1yV0xfAAT1XWDY9VbE3QjkAKjc9A9ppxEr h6d1pXgW9RDplLXxd98+pIC+GcMfFGjhLzzEF5aAtoI3+IxqXipN+c8dOEenPEBwV8oY 2xdzO9Jf2vxqzblpms+RzjAjck8E5wkzK3jkfMfNJVmOPPZDkFw7C0kJPHia6xdOXpl1 ryMQ== X-Gm-Message-State: AOAM531YUNF03rnnC7Uv5AZLLuuwJHE2G96eZdWkP81o+aSh566kWuUf NvCKfy5LN9QZT9FlQHBL4l082uGij+VZb6x+TSTHHG2D0CNFQw== X-Google-Smtp-Source: ABdhPJw0vtBqBTufsct7firNqecZrcgtk/BRdDRG6E67Sdt73OwitK81ckSwBBt8aJprNOPQ4H9Qrgk3EiN7zQI6arM= X-Received: by 2002:ac2:4559:: with SMTP id j25mr10565607lfm.484.1600457912893; Fri, 18 Sep 2020 12:38:32 -0700 (PDT) MIME-Version: 1.0 From: Miao-chen Chou <mcchou@chromium.org> Date: Fri, 18 Sep 2020 12:38:21 -0700 Message-ID: <CABmPvSHYi7WeWqgqxSe60omSyVXj_EezMhGi1GMXBBWM-TWeBw@mail.gmail.com> Subject: Modifying Makefile.am to facilitate test-adv-monitor and future unit tests. To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Cc: Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.40 / 15.00 / 15.00 X-Rspamd-Queue-Id: CB028408B3 X-Rspamd-UID: 4024e4 Hi Luiz and Marcel, Unlike the rest of the existing unit tests in BlueZ, the logic blocks tested in test-adv-monitor require dependencies of not only src/adv_monitor.c but also all the dependency tree of src/adv_monitor.c. The current convention in Makefile.am is to add all the extra dependencies one by one. However, the maintenance cost is high and not suitable in the case of test-adv-monitor. Therefore, we'd like to propose changes in Makefile.am to make the source of bluetoothd as a static library and link it for bluetoothd target and the unit test target. It would be great if you can provide feedback on this idea before the implementation. Thanks in advance! Regards, Miao Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SGEmCCUjZV/kGgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 23:14:13 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id YNAQBSUjZV/EcgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 23:14:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7054FA0118; Fri, 18 Sep 2020 23:14:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726361AbgIRVOC (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 17:14:02 -0400 Received: from mga01.intel.com ([192.55.52.88]:63639 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726327AbgIRVOB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 17:14:01 -0400 IronPort-SDR: GaoRs2LvbFfT4CEHaFOwxKsPKfqQF2TRQ6M28x4vxF3OgaC2CFfN1tG/IUTSthtSqTdgllhkcR NWeE2N1UjJlw== X-IronPort-AV: E=McAfee;i="6000,8403,9748"; a="178125456" X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="178125456" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:02 -0700 IronPort-SDR: y1M0EftXP0zmB1ZK2IM4dExeqWWzexSZgKl/FPl4CerFWQY7/uDWh/X5aH0p92CEBqr3Dpx1+D VMDWrKI7EIsg== X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="484377991" Received: from han1-mobl3.jf.intel.com ([10.255.229.3]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:02 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v4 04/20] client: Add SPDX License Identifier Date: Fri, 18 Sep 2020 14:08:30 -0700 Message-Id: <20200918210846.37797-5-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200918210846.37797-1-tedd.an@linux.intel.com> References: <20200918210846.37797-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7054FA0118 X-Rspamd-UID: c391d6 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 11 License: GPL-2.0-or-later client/adv_monitor.c client/adv_monitor.h client/advertising.h client/display.c client/main.c client/display.h client/agent.h client/gatt.c client/agent.c client/advertising.c client/gatt.h --- client/adv_monitor.c | 11 +---------- client/adv_monitor.h | 11 +---------- client/advertising.c | 15 +-------------- client/advertising.h | 15 +-------------- client/agent.c | 15 +-------------- client/agent.h | 15 +-------------- client/display.c | 15 +-------------- client/display.h | 15 +-------------- client/gatt.c | 15 +-------------- client/gatt.h | 15 +-------------- client/main.c | 15 +-------------- 11 files changed, 11 insertions(+), 146 deletions(-) diff --git a/client/adv_monitor.c b/client/adv_monitor.c index 22bb3c670..90ab0be09 100644 --- a/client/adv_monitor.c +++ b/client/adv_monitor.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Google LLC * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/client/adv_monitor.h b/client/adv_monitor.h index 12c01bd3f..dd6f61579 100644 --- a/client/adv_monitor.h +++ b/client/adv_monitor.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Google LLC * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #define RSSI_DEFAULT_HIGH_THRESHOLD -50 diff --git a/client/advertising.c b/client/advertising.c index 1aa28e749..c1a00502e 100644 --- a/client/advertising.c +++ b/client/advertising.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2016 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/advertising.h b/client/advertising.h index 9967e657b..25e6aee99 100644 --- a/client/advertising.h +++ b/client/advertising.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2016 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void ad_register(DBusConnection *conn, GDBusProxy *manager, const char *type); diff --git a/client/agent.c b/client/agent.c index 4def1b478..c8e1560e7 100644 --- a/client/agent.c +++ b/client/agent.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/agent.h b/client/agent.h index 30f302cdc..5d902a717 100644 --- a/client/agent.h +++ b/client/agent.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void agent_register(DBusConnection *conn, GDBusProxy *manager, diff --git a/client/display.c b/client/display.c index 05613865b..a590a1388 100644 --- a/client/display.c +++ b/client/display.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/display.h b/client/display.h index e991d191a..eb5bd1153 100644 --- a/client/display.h +++ b/client/display.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define COLOR_OFF "\x1B[0m" diff --git a/client/gatt.c b/client/gatt.c index e5bab6dd0..21fd38ecf 100644 --- a/client/gatt.c +++ b/client/gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/gatt.h b/client/gatt.h index 09ca618d3..fc2b8a8a6 100644 --- a/client/gatt.h +++ b/client/gatt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void gatt_add_service(GDBusProxy *proxy); diff --git a/client/main.c b/client/main.c index 2b0243308..60f1eb86e 100644 --- a/client/main.c +++ b/client/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KDxiKkIxZV/eVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:14:26 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 0E6WJ0IxZV8cRQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:14:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 439F8A0B7A; Sat, 19 Sep 2020 00:14:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726218AbgIRWOM (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:14:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbgIRWOL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:14:11 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7588C0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:11 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id bg4so4131630plb.7 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=586CwxIwip9aQsjlGXPSCFIvGMqQksANufQrDJuAX8U=; b=vHZxsTbvSiTYWVIgVNEB9LxnyM/UurF2VvsOBu4f4nVWLrr45dL/5YcQd8V8ebnppB lthUKHSvSwhRIbVYjQ2oobWdkOlqf/9BY57F9/gPbm1L4rkCpxKeq3MClys+USC9FgA+ U0ftouZ7xixZ+K4Ec58fOyPhEFsEPq3le3dwvyBlqc96nVRjndeyvLW6IGXtuSnKurTk Wqb/clH80XTrBxfxPfN6ZxCliSCJEC30swkkyTgVaNiGxm7o+cqtn4Twtz4gMEnImrkr BEITwC8+G4lDSZuiny7aq29zlgZluFZ9cYvWI/3wplO5l31a8pze6kL83ZTmw7EDMdjL NQmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=586CwxIwip9aQsjlGXPSCFIvGMqQksANufQrDJuAX8U=; b=HaJDEzXNskRfuSRMNCOfDxp52UatusM+Yvccsc8rrqe0v1OB9Q/Ql6B5NcJMlJSJdr RoEyC/BHM1llnvI4Qw/RifHKQ5j9K1lx5NXULGwhvZdrTfVmPY1hsnCMbnpar6vzHnRf pu9wmv416PgEDKBBJIwz3p8HWsVGB/w0G8Iav4muDTTxYzDTkfXlbiL/VSN7oYY3A4Rd SSm8TsTqymfRFi2lcJSTAdQxT5GCMKiyySo3E1zIoBCHNV83hRYVxAv0jlrfEVJhTnvp RY1DDlEBjqsZzz8EaOZ1vUT7KOXW/wQlZPTHULHJfNukdjCl07+NTlWpFBj/opVTeoeY cJUg== X-Gm-Message-State: AOAM532MfSt7Wp16BmRnYZQWQNeHdqgE2oZI0LrdP1Xl/VMGal1U95iQ 58yWJQLuaEz1vb96AVQMvp2/UsHCxi9RICnFkjFS X-Google-Smtp-Source: ABdhPJwYCLd1GVL56lPMI24DK/1YefnX5+UYQFz4Tndlk7vHnNyUcNEUfqNMriaYu9RAMvtO5P/qkwTVjK6AaKBzRUMB Sender: "danielwinkler via sendgmr" <danielwinkler@danielwinkler-linux.mtv.corp.google.com> X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a17:90b:15c6:: with SMTP id lh6mr548886pjb.0.1600467250934; Fri, 18 Sep 2020 15:14:10 -0700 (PDT) Date: Fri, 18 Sep 2020 15:13:49 -0700 In-Reply-To: <20200918221357.3436905-1-danielwinkler@google.com> Message-Id: <20200918151041.Bluez.v2.2.If15d3d09724ded2bcc7240d29f6888f2ad12e723@changeid> Mime-Version: 1.0 References: <20200918221357.3436905-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2 02/10] doc/mgmt-api: Add new MGMT interfaces to mgmt-api From: Daniel Winkler <danielwinkler@google.com> To: luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.87 / 15.00 / 15.00 X-Rspamd-Queue-Id: 439F8A0B7A X-Rspamd-UID: fa74fa This patch adds the following to mgmt-api: - Add Extended Advertising Parameters Command - Add Extended Advertising Data Command - Read Controller Capabilities Command - Advertisement Tx Power Selected Event Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: - Removed extra space in Add Extended Advertising Parameters API doc/mgmt-api.txt | 242 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 242 insertions(+) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index ca0d38469..62f976a11 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -3574,6 +3574,234 @@ Remove Advertisement Monitor Command Busy +Add Extended Advertising Parameters Command +=========================================== + + Command Code: 0x0054 + Controller Index: <controller id> + Command Parameters: Instance (1 Octet) + Flags (4 Octets) + Params (2 Octets) + Duration (2 Octets) + Timeout (2 Octets) + MinInterval (4 Octets) + MaxInterval (4 Octets) + TxPower (1 Octet) + Return Parameters: Instance (1 Octet) + + This command is used to configure the parameters for Bluetooth Low + Energy advertising instance. This command is expected to be followed + by an Add Extended Advertising Data command to complete and enable + the advertising instance. + + Added advertising information with this command will not be visible + immediately if advertising is enabled via the Set Advertising + command. The usage of the Set Advertising command takes precedence + over this command. Instance information is stored and will be + advertised once advertising via Set Advertising has been disabled. + + The Instance identifier is a value between 1 and the number of + supported instances. The value 0 is reserved. + + With the Flags value the type of advertising is controlled and + the following flags are defined: + + 0 Switch into Connectable mode + 1 Advertise as Discoverable + 2 Advertise as Limited Discoverable + 3 Add Flags field to Adv_Data + 4 Add TX Power field to Adv_Data + 5 Add Appearance field to Scan_Rsp + 6 Add Local Name in Scan_Rsp + 7 Secondary Channel with LE 1M + 8 Secondary Channel with LE 2M + 9 Secondary Channel with LE Coded + + When the connectable flag is set, then the controller will use + undirected connectable advertising. The value of the connectable + setting can be overwritten this way. This is useful to switch a + controller into connectable mode only for LE operation. This is + similar to the mode 0x02 from the Set Advertising command. + + When the connectable flag is not set, then the controller will + use advertising based on the connectable setting. When using + non-connectable or scannable advertising, the controller will + be programmed with a non-resolvable random address. When the + system is connectable, then the identity address or resolvable + private address will be used. + + Using the connectable flag is useful for peripheral mode support + where BR/EDR (and/or LE) is controlled by Add Device. This allows + making the peripheral connectable without having to interfere + with the global connectable setting. + + Secondary channel flags can be used to advertise in secondary + channel with the corresponding PHYs. These flag bits are mutually + exclusive and setting multiple will result in Invalid Parameter + error. Choosing either LE 1M or LE 2M will result in using + extended advertising on the primary channel with LE 1M and the + respectively LE 1M or LE 2M on the secondary channel. Choosing + LE Coded will result in using extended advertising on the primary + and secondary channels with LE Coded. Choosing none of these flags + will result in legacy advertising. + + To allow future parameters to be optionally extended in this structure, + the Params member is used to specify which of the structure fields were + purposefully set by the caller. Unspecified parameters will be given + sensible defaults by the kernel before the advertisement is registered. + The Params bit field uses the following bit to parameter relationship: + + 0 The Duration parameter should be used + 1 The Timeout parameter should be used + 2 The Interval parameters should be used + 3 The Tx Power parameter should be used + + The Duration parameter configures the length of an Instance. The + value is in seconds. The default is 2 seconds. + + If only one advertising Instance has been added, then the Duration + value will be ignored. It only applies for the case where multiple + Instances are configured. In that case every Instance will be + available for the Duration time and after that it switches to + the next one. This is a simple round-robin based approach. + + The Timeout parameter configures the life-time of an Instance. In + case the value 0 is used it indicates no expiration time. If a + timeout value is provided, then the advertising Instance will be + automatically removed when the timeout passes. The value for the + timeout is in seconds. Powering down a controller will invalidate + all advertising Instances and it is not possible to add a new + Instance with a timeout when the controller is powered down. + + When a Timeout is provided, then the Duration subtracts from + the actual Timeout value of that Instance. For example an Instance + with Timeout of 5 and Duration of 2 will be scheduled exactly 3 + times, twice with 2 seconds and once with one second. Other + Instances have no influence on the Timeout. + + MinInterval and MaxInterval define the minimum and maximum advertising + intervals, with units as number of .625ms advertising slots. The Max + interval is expected to be greater than or equal to the Min interval, + and both must have values in the range [0x000020, 0xFFFFFF]. If either + condition is not met, the registration will fail. + + The provided Tx Power parameter will only be used if the controller + supports it, which can be determined by the presence of the + CanSetTxPower member of the Read Advertising Features command. + + The acceptable range for requested Tx Power is defined in the spec + (Version 5.2 | Vol 4, Part E, page 2585) to be [-127, +20] dBm, and the + controller will select a power value up to the requested one. The + transmission power selected by the controller is not guaranteed + to match the requested one, but the caller can determine the power + chosen by the controller by listening for the Tx Power Selected MGMT + event that follows this command. If the requested Tx Power is outside + the valid range, the registration will fail. + + Re-adding an already existing instance (i.e. issuing the Add Extended + Advertising Parameters command with an Instance identifier of an + existing instance) will update that instance's configuration. + + An instance being added or changed while another instance is + being advertised will not be visible immediately but only when + the new/changed instance is being scheduled by the round robin + advertising algorithm. + + Changes to an instance that is currently being advertised will + cancel that instance and switch to the next instance. The changes + will be visible the next time the instance is scheduled for + advertising. In case a single instance is active, this means + that changes will be visible right away. + + LE must already be enabled, and the controller must be powered, + otherwise a "rejected" status will be returned. + + This command generates a Command Complete event on success or a + Command Status event on failure. + + Possible errors: Failed + Rejected + Not Supported + Invalid Parameters + Busy + + +Add Extended Advertising Data Command +===================================== + + Command Code: 0x0055 + Controller Index: <controller id> + Command Parameters: Instance (1 Octet) + Advertising Data Length (1 Octet) + Scan Response Length (1 Octet) + Advertising Data (0-255 Octets) + Scan Response (0-255 Octets) + Return Parameters: Instance (1 Octet) + + The Add Extended Advertising Data command is used to update the + advertising data of an existing advertising instance known to the + kernel. It is expected to be called after an Add Extended Advertising + Parameters command, as part of the advertisement registration + process. + + If extended advertising is available, this call will initiate HCI + commands to set the instance's advertising data, set scan response + data, and then enable the instance. If extended advertising is + unavailable, the advertising instance structure maintained in kernel + will have its advertising data and scan response updated, and the + instance will either be scheduled immediately or left in the queue + for later advertisement as part of round-robin advertisement rotation + in software. + + If Scan_Rsp_Len is zero and the flags defined in Add Extended + Advertising Parameters command do not have connectable flag set and + the global connectable setting is off, then non-connectable + advertising is used. If Scan_Rsp_Len is larger than zero and + connectable flag is not set and the global advertising is off, + then scannable advertising is used. This small difference is + supported to provide less air traffic for devices implementing + broadcaster role. + + If the Instance provided does not match a known instance, or if the + provided advertising data or scan response are in an unrecognized + format, an "Invalid Parameters" status will be returned. + + If a "Set LE" or Advertising command is still in progress, a "Busy" + status will be returned. + + If the controller is not powered, a "rejected" status will be returned. + + This command generates a Command Complete event on success or a + Command Status event on failure. + + Possible errors: Failed + Rejected + Invalid Parameters + Busy + + +Read Controller Capabilities Command +==================================== + + Command Code: 0x0056 + Controller Index: <controller id> + Command Parameters: + Return Parameters: Parameter1 { + Capability_Tag (2 Octet) + Value_Length (1 Octet) + Value (0-255 Octets) + } + Parameter2 { } + ... + + This command is used to read a list of controller capabilities. + + Currently defined Capability_Tag values are: + + 0x0000 Minimum Supported LE Tx Power (dBm) + 0x0001 Maximum Supported LE Tx Power (dBm) + + Command Complete Event ====================== @@ -4577,3 +4805,17 @@ Advertisement Monitor Removed Event The event will only be sent to management sockets other than the one through which the command was sent. + + +Advertisement Tx Power Selected Event +=================================== + + Event Code: 0x002d + Controller Index: <controller id> + Event Parameters: Instance (1 Octet) + TxPower (1 Octet) + + This event indicates that the controller selected a transmission + power for an advertising instance. The event is emitted on platforms + that support extended advertising after an Add Extended Advertising + Parameters command is submitted. \ No newline at end of file -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wGS+MEgxZV/eVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:14:32 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id cO1vLUgxZV/s+gAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:14:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id C0914A0B24; Sat, 19 Sep 2020 00:14:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726249AbgIRWOO (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:14:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgIRWOO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:14:14 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 166FEC0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:14 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id mv5so3603113pjb.5 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=hB0CpivhDfyrDY9Ky1oVzGJab7x3ciX7ZMWxakjiGGU=; b=TXQEXe1kV0LP+DE8LvhEzoe6PveY3xealaHWcfatqc7Z+oFPCdM3W7bHvpxITMkyb6 FVP8GyDdrCIHCm6y9U14hpuPaoxtIFv2j/HzEM9QjDRSt+Bzi8SGibRb4OeX4xFXCt7J fzEryB5WlRl09BFmAndUTGrwdEQrTSQrN/9O5lcelvPrlhOV4PWKZOg7vvrkhlaRJabq jA4OAAVFY74aumHbXbmIyKa/pfVbKuIb6WwdpVHriMxUkCFj8wtpIoKW/7dre3v12zY1 PU8sBhpRvTV5erpQt8xlskINtUHoG5V4XAHNFRqOjaVw4KjYtSxSXC33Ne8DZKUheF8V 2UyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=hB0CpivhDfyrDY9Ky1oVzGJab7x3ciX7ZMWxakjiGGU=; b=n/RT+/tzsyMWYnJCU9BiJVernYFHlQxL/XTxSCcuxnOw5g1vUCjH+C1TAzrs5XzSU2 mf2QQwH8ObinfYka5RHXv8VfEB6HgHOsrRfj0tyXoKWqwMHopnFcW3Zvw3KRtIE/eUh4 oQEwUS/BzK7iYQCCnlYU2bhrgc/S2M/Fpz61n9ygTZht7suCKd4OEGpoqq75yF73E8wV gePLm6zziBGY5b7DvZmIexULAg8cexP6GAlMW483zXWqErtj0ZMnyAt9VeyDcgYEWBlt xDG1vv9nIKkaqAPzgvYDd+os6CW5wdP6q/mabd6up6v+qlMs4ZXHiPVIrpm0jHAfuJwv r7sg== X-Gm-Message-State: AOAM532ZjwWnfBWiWNzPlGz4kD/GRXlqqGFRDmID42FdTc1ErIr9MjWt u0pSWuE6GbFJhK+oDduv6H7JPVgOMZi8l5JdV9pf X-Google-Smtp-Source: ABdhPJwPXMH/JE4kdxOYkSfG85dgz6sxitqLGz1qadcsD2L1zFZprCm6+yhaIOHi4sWb7J7zsg/wSekFHGYz8k/W9MLL Sender: "danielwinkler via sendgmr" <danielwinkler@danielwinkler-linux.mtv.corp.google.com> X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a63:f342:: with SMTP id t2mr28928663pgj.313.1600467253441; Fri, 18 Sep 2020 15:14:13 -0700 (PDT) Date: Fri, 18 Sep 2020 15:13:50 -0700 In-Reply-To: <20200918221357.3436905-1-danielwinkler@google.com> Message-Id: <20200918151041.Bluez.v2.3.I50d9faa25e9da6e71d77c83c7d47a5b135e88799@changeid> Mime-Version: 1.0 References: <20200918221357.3436905-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2 03/10] advertising: Detect if extended advertising mgmt commands are supported From: Daniel Winkler <danielwinkler@google.com> To: luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.87 / 15.00 / 15.00 X-Rspamd-Queue-Id: C0914A0B24 X-Rspamd-UID: 9bd6dc We need to know if kernel supports the new MGMT interface. To do so, we check the return from adapter's MGMT_OP_READ_COMMANDS call for the new commands. This will later be used to route our requests for new advertisements. The change is tested by manually verifying that the correct MGMT commands are used when the feature is and is not available in kernel. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: - Uses btd_has_kernel_features to detect kernel command support src/adapter.c | 4 ++++ src/adapter.h | 1 + src/advertising.c | 3 +++ 3 files changed, 8 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index b2bd8b3f1..7811122c4 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -9653,6 +9653,10 @@ static void read_commands_complete(uint8_t status, uint16_t length, DBG("kernel supports exp features"); kernel_features |= KERNEL_EXP_FEATURES; break; + case MGMT_OP_ADD_EXT_ADV_PARAMS: + DBG("kernel supports ext adv commands"); + kernel_features |= KERNEL_HAS_EXT_ADV_ADD_CMDS; + break; default: break; } diff --git a/src/adapter.h b/src/adapter.h index b4d872b15..99802e287 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -246,6 +246,7 @@ enum kernel_features { KERNEL_SET_SYSTEM_CONFIG = 1 << 2, KERNEL_EXP_FEATURES = 1 << 3, KERNEL_HAS_RESUME_EVT = 1 << 4, + KERNEL_HAS_EXT_ADV_ADD_CMDS = 1 << 5, }; bool btd_has_kernel_features(uint32_t feature); diff --git a/src/advertising.c b/src/advertising.c index e5f25948d..ad2eeefb9 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -57,6 +57,7 @@ struct btd_adv_manager { uint8_t max_ads; uint32_t supported_flags; unsigned int instance_bitmap; + bool extended_add_cmds; }; #define AD_TYPE_BROADCAST 0 @@ -1426,6 +1427,8 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, manager->mgmt_index = btd_adapter_get_index(adapter); manager->clients = queue_new(); manager->supported_flags = MGMT_ADV_FLAG_LOCAL_NAME; + manager->extended_add_cmds = + btd_has_kernel_features(KERNEL_HAS_EXT_ADV_ADD_CMDS); if (!g_dbus_register_interface(btd_get_dbus_connection(), adapter_get_path(manager->adapter), -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id ANSJBk8xZV/eVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:14:39 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id CMeWA08xZV+3dQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:14:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E0909A0B14; Sat, 19 Sep 2020 00:14:32 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726276AbgIRWOQ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:14:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726236AbgIRWOQ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:14:16 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 286ACC0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:16 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id e13so943131pgk.6 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=EhaYoylvVc+raL+jy8rDBp1lZa005/zR8HLyRALvsU4=; b=Gl67KLo4h5fcUFIE1zsaHBIu1GJ6qv4mVx4f1aDhwxahgApdPBHDuDIcy8RISX23uj +iwqXT/3JpHqVHu4RzfPUToyopnTTJbAn8syRhNx2e5PVSKfj2G6sbdaTrjzuyuqPmhb ecrp18ED0i4B03qp008sZae/qoa3MVq/BEC4pPRXK988Q9apxBlQXGzoIgbvqstWZZsi j+8EpEjVOZPWEsOuFbHN5S4+gYlWTdL5VqJX5oqy889MB4q61r6ZhgV+xELosHXda1JQ DRaP8ErEGMlU836b7L5fer9l1LLU8Mk7qJx0IOvZFUdEKoQinpVgR7zRsSWHPypkqhRc URDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=EhaYoylvVc+raL+jy8rDBp1lZa005/zR8HLyRALvsU4=; b=gVR6w99STzB2Fv8THNvXZxA7A6RuPhPwsZaadk5183ZGZtFw2ImJ9AsV1d4UU8Vafj Ewx/qVvESfxCc9xJChjacMIBS9YQhb+WcBT7ZhmjyxLlafNorlIlNUg2c6Cy4Z27R3SW oEEYVB1KnD6utrbv8Y8mevS/kg21gEXwjmsoN7OaVxH1lRA3TjBlpuC2afVhFs7a+dup IXuHXA68SBKpF/k5hWfTS7jKOohbbhUScjI2oj4XqKZHCjnAjIfiBF/xHEbOW9sA9W+H klGmltJRJAhLOM+3o8Wt+wcC3Mguy4ofKJtzAZN3R1zKPsSuB6JqClN4eG25fqPfImhW IV2A== X-Gm-Message-State: AOAM533EZ7hCWw2ZtRjUPneb/BBTEUmRP4z+IEO6EtPlgXvt2SQd0aog tliDOet/cm+J0gu+BEPq1In3IxK84ew1FgtEx6Ef X-Google-Smtp-Source: ABdhPJwWfHIj/rH4a1Z4vuDuSruR43CLulLTtpGQOYEkRnIIgY12CjmMo0O6BOAcYLzH2wW8sqXSgCF13kJ9IwINc3y7 Sender: "danielwinkler via sendgmr" <danielwinkler@danielwinkler-linux.mtv.corp.google.com> X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a17:90a:bc08:: with SMTP id w8mr14614965pjr.168.1600467255667; Fri, 18 Sep 2020 15:14:15 -0700 (PDT) Date: Fri, 18 Sep 2020 15:13:51 -0700 In-Reply-To: <20200918221357.3436905-1-danielwinkler@google.com> Message-Id: <20200918151041.Bluez.v2.4.Ic4a3667da774f5f34477d5168a68a9280657e2da@changeid> Mime-Version: 1.0 References: <20200918221357.3436905-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2 04/10] advertising: Parse intervals and tx power from adv From: Daniel Winkler <danielwinkler@google.com> To: luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.87 / 15.00 / 15.00 X-Rspamd-Queue-Id: E0909A0B14 X-Rspamd-UID: 966dfa This change adds parsers for the advertising intervals and tx power properties of the LEAdvertisement1 object. It validates that each field adheres to the 5.2 spec, and that min and max intervals are compatible with each other, i.e. that min interval is less than max interval. A note here for maintainers: The tx power that is sent in the hci parameter command is an int8_t, but as far as I can tell, there is no clean way to use a signed 8-bit integer in dbus. The dbus byte type seems incompatible with negative values in high-level languages (python) without awkward usage manipulation on the client side. For this reason, I chose to use an int16_t type for the tx power dbus field, which is then downcasted to the int8_t in bluetoothd, which at least makes the signed-ness of the type crystal clear to the dbus client that uses it. This change is manually verified by ensuring the intervals and tx power parameters are correctly parsed from the LEAdvertisement1 object, and that the parse fails if the parameters are incorrect or not compatible with each other. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: None src/advertising.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/src/advertising.c b/src/advertising.c index ad2eeefb9..3c173fef0 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -63,6 +63,11 @@ struct btd_adv_manager { #define AD_TYPE_BROADCAST 0 #define AD_TYPE_PERIPHERAL 1 +/* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2585 + * defines tx power value indicating no preference + */ +#define ADV_TX_POWER_NO_PREFERENCE 0x7F + struct btd_adv_client { struct btd_adv_manager *manager; char *owner; @@ -83,6 +88,9 @@ struct btd_adv_client { struct bt_ad *data; struct bt_ad *scan; uint8_t instance; + uint32_t min_interval; + uint32_t max_interval; + int8_t tx_power; }; struct dbus_obj_match { @@ -946,6 +954,74 @@ static bool parse_secondary(DBusMessageIter *iter, return false; } +static bool parse_min_interval(DBusMessageIter *iter, + struct btd_adv_client *client) +{ + if (!iter) + return false; + + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) + return false; + + dbus_message_iter_get_basic(iter, &client->min_interval); + + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2584 + * defines acceptable interval range + */ + if (client->min_interval < 0x20 || client->min_interval > 0xFFFFFF) { + client->min_interval = 0; + return false; + } + + return true; +} + +static bool parse_max_interval(DBusMessageIter *iter, + struct btd_adv_client *client) +{ + if (!iter) + return false; + + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) + return false; + + dbus_message_iter_get_basic(iter, &client->max_interval); + + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2584 + * defines acceptable interval range + */ + if (client->max_interval < 0x20 || client->max_interval > 0xFFFFFF) { + client->max_interval = 0; + return false; + } + + return true; +} + +static bool parse_tx_power(DBusMessageIter *iter, + struct btd_adv_client *client) +{ + int16_t val; + + if (!iter) + return false; + + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INT16) + return false; + + dbus_message_iter_get_basic(iter, &val); + + /* BLUETOOTH SPECIFICATION Version 5.2 | Vol 4, Part E, page 2585 + * defines acceptable tx power range + */ + if (val < -127 || val > 20) + return false; + + client->tx_power = val; + + return true; +} + static struct adv_parser { const char *name; bool (*func)(DBusMessageIter *iter, struct btd_adv_client *client); @@ -964,6 +1040,9 @@ static struct adv_parser { { "Discoverable", parse_discoverable }, { "DiscoverableTimeout", parse_discoverable_timeout }, { "SecondaryChannel", parse_secondary }, + { "MinInterval", parse_min_interval }, + { "MaxInterval", parse_max_interval }, + { "TxPower", parse_tx_power }, { }, }; @@ -1092,6 +1171,13 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client) goto fail; } + if (client->min_interval > client->max_interval) { + /* Min interval must not be bigger than max interval */ + error("MinInterval must be less than MaxInterval (%u > %u)", + client->min_interval, client->max_interval); + goto fail; + } + err = refresh_adv(client, add_adv_callback, &client->add_adv_id); if (!err) return NULL; @@ -1167,6 +1253,9 @@ static struct btd_adv_client *client_create(struct btd_adv_manager *manager, client->manager = manager; client->appearance = UINT16_MAX; + client->tx_power = ADV_TX_POWER_NO_PREFERENCE; + client->min_interval = 0; + client->max_interval = 0; return client; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4CNSBCwjZV/kGgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 23:14:20 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 8MHoACwjZV+51wAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 23:14:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 62971A0118; Fri, 18 Sep 2020 23:14:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726368AbgIRVOC (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 17:14:02 -0400 Received: from mga01.intel.com ([192.55.52.88]:63638 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726332AbgIRVOB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 17:14:01 -0400 IronPort-SDR: N4HZ+po8b9aOvIET6ct6qMjqLo1cvmwGvC0I6hdr9V21pYaoPMSiZlKwA5z7S98Gz+IV0D4Avk AYTlpZMo3Hrg== X-IronPort-AV: E=McAfee;i="6000,8403,9748"; a="178125452" X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="178125452" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:00 -0700 IronPort-SDR: EfimtVZ/qPkYOJRGCVC692RG5hObZpTijeHORGV3MljeBnW4krraC7sTEumW3ay485m28TCn/C g72fZMIEnpTA== X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="484377979" Received: from han1-mobl3.jf.intel.com ([10.255.229.3]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:00 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v4 03/20] btio: Add SPDX License Identifier Date: Fri, 18 Sep 2020 14:08:29 -0700 Message-Id: <20200918210846.37797-4-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200918210846.37797-1-tedd.an@linux.intel.com> References: <20200918210846.37797-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: 62971A0118 X-Rspamd-UID: 9fabad From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 2 License: GPL-2.0-or-later btio/btio.h btio/btio.c --- btio/btio.c | 15 +-------------- btio/btio.h | 15 +-------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/btio/btio.c b/btio/btio.c index 844d6007f..c18b6a012 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2009-2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/btio/btio.h b/btio/btio.h index 23e0ef72b..f0259cf1d 100644 --- a/btio/btio.h +++ b/btio/btio.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2009-2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef BT_IO_H #define BT_IO_H -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6BNDJTIjZV/kGgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 23:14:26 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AEgiIjIjZV/AwQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 23:14:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 265D0A0170; Fri, 18 Sep 2020 23:14:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726371AbgIRVOD (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 17:14:03 -0400 Received: from mga01.intel.com ([192.55.52.88]:63641 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726332AbgIRVOD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 17:14:03 -0400 IronPort-SDR: pnmdaIOqLiPV1iNHtEQct3ugLq+/O8mLCZG5Bc6I7WlyFVeDh15nxmaF1dEwJoo9V1fKjlyMTp bqLTmjTQRieA== X-IronPort-AV: E=McAfee;i="6000,8403,9748"; a="178125470" X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="178125470" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:07 -0700 IronPort-SDR: bjtq1f11MzKFbu3FMJ+ztFCNU2F7o7ASze4PXuRGMrmp7PTZ8IG9bs2YIgxJdkWEpMKF1QcD7l 6Zx+tNkogEFA== X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="484378039" Received: from han1-mobl3.jf.intel.com ([10.255.229.3]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:07 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v4 07/20] gobex: Add SPDX License Identifier Date: Fri, 18 Sep 2020 14:08:33 -0700 Message-Id: <20200918210846.37797-8-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200918210846.37797-1-tedd.an@linux.intel.com> References: <20200918210846.37797-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: 265D0A0170 X-Rspamd-UID: b6a139 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 12 License: GPL-2.0-or-later gobex/gobex-defs.h gobex/gobex-transfer.c gobex/gobex.c gobex/gobex-apparam.h gobex/gobex-header.h gobex/gobex-header.c gobex/gobex.h gobex/gobex-packet.h gobex/gobex-defs.c gobex/gobex-debug.h gobex/gobex-apparam.c gobex/gobex-packet.c --- gobex/gobex-apparam.c | 15 +-------------- gobex/gobex-apparam.h | 15 +-------------- gobex/gobex-debug.h | 15 +-------------- gobex/gobex-defs.c | 15 +-------------- gobex/gobex-defs.h | 15 +-------------- gobex/gobex-header.c | 15 +-------------- gobex/gobex-header.h | 15 +-------------- gobex/gobex-packet.c | 15 +-------------- gobex/gobex-packet.h | 15 +-------------- gobex/gobex-transfer.c | 15 +-------------- gobex/gobex.c | 15 +-------------- gobex/gobex.h | 15 +-------------- 12 files changed, 12 insertions(+), 168 deletions(-) diff --git a/gobex/gobex-apparam.c b/gobex/gobex-apparam.c index b16cee11a..818180cb1 100644 --- a/gobex/gobex-apparam.c +++ b/gobex/gobex-apparam.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2012 Intel Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-apparam.h b/gobex/gobex-apparam.h index 6c0860928..ace615225 100644 --- a/gobex/gobex-apparam.h +++ b/gobex/gobex-apparam.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2012 Intel Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_APPARAM_H diff --git a/gobex/gobex-debug.h b/gobex/gobex-debug.h index a98653d83..eeb2209f0 100644 --- a/gobex/gobex-debug.h +++ b/gobex/gobex-debug.h @@ -1,22 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_DEBUG_H diff --git a/gobex/gobex-defs.c b/gobex/gobex-defs.c index 1c7c39a16..811be762b 100644 --- a/gobex/gobex-defs.c +++ b/gobex/gobex-defs.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-defs.h b/gobex/gobex-defs.h index 326e3cb09..84351205d 100644 --- a/gobex/gobex-defs.h +++ b/gobex/gobex-defs.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_DEFS_H diff --git a/gobex/gobex-header.c b/gobex/gobex-header.c index c594999a5..011d33d1a 100644 --- a/gobex/gobex-header.c +++ b/gobex/gobex-header.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-header.h b/gobex/gobex-header.h index 6600b1b4a..129f35ba1 100644 --- a/gobex/gobex-header.h +++ b/gobex/gobex-header.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_HEADER_H diff --git a/gobex/gobex-packet.c b/gobex/gobex-packet.c index a89f5b6d3..11937a5a5 100644 --- a/gobex/gobex-packet.c +++ b/gobex/gobex-packet.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-packet.h b/gobex/gobex-packet.h index 1d94ccf20..ed153bac5 100644 --- a/gobex/gobex-packet.h +++ b/gobex/gobex-packet.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_PACKET_H diff --git a/gobex/gobex-transfer.c b/gobex/gobex-transfer.c index e96e61fbc..c94d018b2 100644 --- a/gobex/gobex-transfer.c +++ b/gobex/gobex-transfer.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex.c b/gobex/gobex.c index d68a85eb6..54e3b0814 100644 --- a/gobex/gobex.c +++ b/gobex/gobex.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex.h b/gobex/gobex.h index a94d9246e..f16e4426c 100644 --- a/gobex/gobex.h +++ b/gobex/gobex.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_H -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KDOdFk4kZV+xCwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 23:19:10 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id AKJtE04kZV/EcgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 23:19:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 086C2A0195; Fri, 18 Sep 2020 23:19:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726309AbgIRVTC (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 17:19:02 -0400 Received: from mga01.intel.com ([192.55.52.88]:64027 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726139AbgIRVTC (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 17:19:02 -0400 IronPort-SDR: zhsVoAo5Vk5yF/PicF9xOd+PUiO10M/8fM+v2jFOjVpf54VawT34hFM1M1KoAVG/nVJdfvoze8 8IOkqryMMe9A== X-IronPort-AV: E=McAfee;i="6000,8403,9748"; a="178125482" X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="178125482" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:11 -0700 IronPort-SDR: 88CINRs4CEhb/X6TWzRdqWo+K9eKN7V6M/cLYHc1rdYWVxEGqFaYJOizXvkNhtphgJ17uTHXob lYcxE2WIdULg== X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="484378068" Received: from han1-mobl3.jf.intel.com ([10.255.229.3]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:10 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v4 09/20] mesh: Add SPDX License Identifier Date: Fri, 18 Sep 2020 14:08:35 -0700 Message-Id: <20200918210846.37797-10-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200918210846.37797-1-tedd.an@linux.intel.com> References: <20200918210846.37797-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: 086C2A0195 X-Rspamd-UID: 1f8b0a From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 48 License: LGPL-2.1-or-later mesh/mesh-mgmt.h mesh/mesh-mgmt.c mesh/net-keys.c mesh/mesh-io-api.h mesh/mesh.h mesh/net-keys.h mesh/model.h mesh/util.h mesh/appkey.c mesh/cfgmod.h mesh/appkey.h mesh/prov.h mesh/prov-acceptor.c mesh/net.c mesh/dbus.h mesh/friend.h mesh/mesh-io-generic.c mesh/main.c mesh/util.c mesh/dbus.c mesh/error.h mesh/mesh-config-json.c mesh/agent.h mesh/pb-adv.c mesh/crypto.c mesh/crypto.h mesh/friend.c mesh/pb-adv.h mesh/provision.h mesh/mesh-config.h mesh/mesh-io-generic.h mesh/agent.c mesh/cfgmod-server.c mesh/mesh-io.h mesh/keyring.h mesh/net.h mesh/keyring.c mesh/mesh-defs.h mesh/mesh.c mesh/rpl.c mesh/manager.c mesh/model.c mesh/mesh-io.c mesh/node.c mesh/prov-initiator.c mesh/rpl.h mesh/node.h mesh/manager.h --- mesh/agent.c | 11 +---------- mesh/agent.h | 11 +---------- mesh/appkey.c | 11 +---------- mesh/appkey.h | 11 +---------- mesh/cfgmod-server.c | 11 +---------- mesh/cfgmod.h | 11 +---------- mesh/crypto.c | 11 +---------- mesh/crypto.h | 11 +---------- mesh/dbus.c | 11 +---------- mesh/dbus.h | 11 +---------- mesh/error.h | 11 +---------- mesh/friend.c | 11 +---------- mesh/friend.h | 11 +---------- mesh/keyring.c | 11 +---------- mesh/keyring.h | 11 +---------- mesh/main.c | 11 +---------- mesh/manager.c | 11 +---------- mesh/manager.h | 11 +---------- mesh/mesh-config-json.c | 11 +---------- mesh/mesh-config.h | 11 +---------- mesh/mesh-defs.h | 12 +----------- mesh/mesh-io-api.h | 11 +---------- mesh/mesh-io-generic.c | 11 +---------- mesh/mesh-io-generic.h | 11 +---------- mesh/mesh-io.c | 11 +---------- mesh/mesh-io.h | 11 +---------- mesh/mesh-mgmt.c | 11 +---------- mesh/mesh-mgmt.h | 11 +---------- mesh/mesh.c | 11 +---------- mesh/mesh.h | 11 +---------- mesh/model.c | 11 +---------- mesh/model.h | 11 +---------- mesh/net-keys.c | 11 +---------- mesh/net-keys.h | 11 +---------- mesh/net.c | 11 +---------- mesh/net.h | 11 +---------- mesh/node.c | 11 +---------- mesh/node.h | 11 +---------- mesh/pb-adv.c | 11 +---------- mesh/pb-adv.h | 11 +---------- mesh/prov-acceptor.c | 11 +---------- mesh/prov-initiator.c | 11 +---------- mesh/prov.h | 11 +---------- mesh/provision.h | 11 +---------- mesh/rpl.c | 11 +---------- mesh/rpl.h | 11 +---------- mesh/util.c | 11 +---------- mesh/util.h | 11 +---------- 48 files changed, 48 insertions(+), 481 deletions(-) diff --git a/mesh/agent.c b/mesh/agent.c index 4d200416f..b0d523d16 100644 --- a/mesh/agent.c +++ b/mesh/agent.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/agent.h b/mesh/agent.h index 6cc3d0f71..6664c2226 100644 --- a/mesh/agent.h +++ b/mesh/agent.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_agent; diff --git a/mesh/appkey.c b/mesh/appkey.c index a4771bd7d..7efb8f5c4 100644 --- a/mesh/appkey.c +++ b/mesh/appkey.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2017-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/appkey.h b/mesh/appkey.h index 23b474a0a..3bb70445b 100644 --- a/mesh/appkey.h +++ b/mesh/appkey.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ /* TODO: get this number from configuration */ diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 2e5da863a..0009a1bee 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 6d73656a7..f47a42c60 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define CONFIG_SRV_MODEL SET_ID(SIG_VENDOR, 0x0000) diff --git a/mesh/crypto.c b/mesh/crypto.c index 70b96c51b..da227ebbb 100644 --- a/mesh/crypto.c +++ b/mesh/crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/crypto.h b/mesh/crypto.h index 7d3f89cde..2f31dc3de 100644 --- a/mesh/crypto.h +++ b/mesh/crypto.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include <stdbool.h> diff --git a/mesh/dbus.c b/mesh/dbus.c index 63ea420ed..a7abdc428 100644 --- a/mesh/dbus.c +++ b/mesh/dbus.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/dbus.h b/mesh/dbus.h index 89d6b1d31..8f00434d6 100644 --- a/mesh/dbus.h +++ b/mesh/dbus.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define BLUEZ_MESH_PATH "/org/bluez/mesh" diff --git a/mesh/error.h b/mesh/error.h index 2809915b0..6d9ccdb59 100644 --- a/mesh/error.h +++ b/mesh/error.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ /* diff --git a/mesh/friend.c b/mesh/friend.c index d27da9592..1e67704b8 100644 --- a/mesh/friend.c +++ b/mesh/friend.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/friend.h b/mesh/friend.h index 2351dee31..ba6053426 100644 --- a/mesh/friend.h +++ b/mesh/friend.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define OP_FRND_REQUEST 0x8040 diff --git a/mesh/keyring.c b/mesh/keyring.c index e8dd1e463..bbe501063 100644 --- a/mesh/keyring.c +++ b/mesh/keyring.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/keyring.h b/mesh/keyring.h index 2fab6b0dc..c2d38e9ff 100644 --- a/mesh/keyring.h +++ b/mesh/keyring.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct keyring_net_key { diff --git a/mesh/main.c b/mesh/main.c index 5a3cbf290..4356e3f65 100644 --- a/mesh/main.c +++ b/mesh/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2017-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/manager.c b/mesh/manager.c index 8ef681366..d70993e3b 100644 --- a/mesh/manager.c +++ b/mesh/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/manager.h b/mesh/manager.h index 5a4c7d94a..a45a1f1c4 100644 --- a/mesh/manager.h +++ b/mesh/manager.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ bool manager_dbus_init(struct l_dbus *dbus); diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 30c90170d..ec9ecb786 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 738cff9dd..420775829 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define MIN_COMP_SIZE 14 diff --git a/mesh/mesh-defs.h b/mesh/mesh-defs.h index 1a41e987b..43bdf5aab 100644 --- a/mesh/mesh-defs.h +++ b/mesh/mesh-defs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,17 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * */ #define MESH_AD_TYPE_PROVISION 0x29 diff --git a/mesh/mesh-io-api.h b/mesh/mesh-io-api.h index 7a5b49c60..61f79f224 100644 --- a/mesh/mesh-io-api.h +++ b/mesh/mesh-io-api.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_io_private; diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c index 67304d201..4eb7f27ce 100644 --- a/mesh/mesh-io-generic.c +++ b/mesh/mesh-io-generic.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-io-generic.h b/mesh/mesh-io-generic.h index 4bf4d5cb7..915e376bf 100644 --- a/mesh/mesh-io-generic.h +++ b/mesh/mesh-io-generic.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ extern const struct mesh_io_api mesh_io_generic; diff --git a/mesh/mesh-io.c b/mesh/mesh-io.c index c4eaecefd..62fc5d12e 100644 --- a/mesh/mesh-io.c +++ b/mesh/mesh-io.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-io.h b/mesh/mesh-io.h index fc0422020..b11c6c6e1 100644 --- a/mesh/mesh-io.h +++ b/mesh/mesh-io.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_io; diff --git a/mesh/mesh-mgmt.c b/mesh/mesh-mgmt.c index 2cf2ebac2..754093dbc 100644 --- a/mesh/mesh-mgmt.c +++ b/mesh/mesh-mgmt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 SILVAIR sp. z o.o. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-mgmt.h b/mesh/mesh-mgmt.h index 93ad7995e..90ac14e73 100644 --- a/mesh/mesh-mgmt.h +++ b/mesh/mesh-mgmt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 SILVAIR sp. z o.o. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include <stdbool.h> diff --git a/mesh/mesh.c b/mesh/mesh.c index bc170371d..f29e8b6be 100644 --- a/mesh/mesh.c +++ b/mesh/mesh.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh.h b/mesh/mesh.h index eb887723d..0f77ebc58 100644 --- a/mesh/mesh.h +++ b/mesh/mesh.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define BLUEZ_MESH_NAME "org.bluez.mesh" diff --git a/mesh/model.c b/mesh/model.c index 5716f5e22..c8eb8c607 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/model.h b/mesh/model.h index 2eec761a0..8df4f205f 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_model; diff --git a/mesh/net-keys.c b/mesh/net-keys.c index 7dfabf922..e42cac70c 100644 --- a/mesh/net-keys.c +++ b/mesh/net-keys.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/net-keys.h b/mesh/net-keys.h index 4f480fcda..70b3d22c3 100644 --- a/mesh/net-keys.h +++ b/mesh/net-keys.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define BEACON_TYPE_SNB 0x01 diff --git a/mesh/net.c b/mesh/net.c index 6c7311732..01a475d74 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/net.h b/mesh/net.h index 7bec6d0fc..4dbc94b8b 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifndef __packed diff --git a/mesh/node.c b/mesh/node.c index f7ac5ff67..76d8fd6e9 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2017-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/node.h b/mesh/node.h index 7874b8692..30d53db33 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_net; diff --git a/mesh/pb-adv.c b/mesh/pb-adv.c index ae5b81391..c74dae79f 100644 --- a/mesh/pb-adv.c +++ b/mesh/pb-adv.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/pb-adv.h b/mesh/pb-adv.h index 80d53d234..5b1e03dae 100644 --- a/mesh/pb-adv.h +++ b/mesh/pb-adv.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ bool pb_adv_reg(bool initiator, mesh_prov_open_func_t open_cb, diff --git a/mesh/prov-acceptor.c b/mesh/prov-acceptor.c index 96f7e15ad..a03ee1ce5 100644 --- a/mesh/prov-acceptor.c +++ b/mesh/prov-acceptor.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/prov-initiator.c b/mesh/prov-initiator.c index 4de4df62d..8399282ee 100644 --- a/mesh/prov-initiator.c +++ b/mesh/prov-initiator.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/prov.h b/mesh/prov.h index 11b20b31f..99e864c50 100644 --- a/mesh/prov.h +++ b/mesh/prov.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifndef __packed diff --git a/mesh/provision.h b/mesh/provision.h index 1d78ed8e2..1a11b691b 100644 --- a/mesh/provision.h +++ b/mesh/provision.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ diff --git a/mesh/rpl.c b/mesh/rpl.c index 792c52ad6..7cea8e346 100644 --- a/mesh/rpl.c +++ b/mesh/rpl.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/rpl.h b/mesh/rpl.h index 2bbbdc9b9..9e988e7c5 100644 --- a/mesh/rpl.h +++ b/mesh/rpl.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_rpl { diff --git a/mesh/util.c b/mesh/util.c index 7d283331a..308e7d998 100644 --- a/mesh/util.c +++ b/mesh/util.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/util.h b/mesh/util.h index 93c2d8687..085ec3330 100644 --- a/mesh/util.h +++ b/mesh/util.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ uint32_t get_timestamp_secs(void); -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iIr6FagmZV/kGgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 23:29:12 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 2BcWE6gmZV+11gAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 23:29:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8C092A03FD; Fri, 18 Sep 2020 23:29:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726285AbgIRV3D (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 17:29:03 -0400 Received: from mga01.intel.com ([192.55.52.88]:64721 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726139AbgIRV3D (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 17:29:03 -0400 IronPort-SDR: 8mRZ8UHGvZ4iUyJsx4yWnOMhKypqZJc77XrKtw4e+DGBIK7Ur5BE+C9sFgi4Yvi7nNm85lWgSF bfx2KKyAYy8Q== X-IronPort-AV: E=McAfee;i="6000,8403,9748"; a="178125517" X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="178125517" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:24 -0700 IronPort-SDR: UCKpPnr2ca40+9zTh2VMcQU0NIzkXdICky/hwvexc3Z3ENEid2gEsz1kmxe8ZrTi6njokveZkF WCH4ItzucSMw== X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="484378182" Received: from han1-mobl3.jf.intel.com ([10.255.229.3]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:24 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v4 18/20] build: Add SPDX License Identifier Date: Fri, 18 Sep 2020 14:08:44 -0700 Message-Id: <20200918210846.37797-19-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200918210846.37797-1-tedd.an@linux.intel.com> References: <20200918210846.37797-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.15 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8C092A03FD X-Rspamd-UID: 9b6f91 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 6 License: GPL-2.0-or-later Makefile.am Makefile.mesh Makefile.obexd Makefile.plugins Makefile.tools configure.ac --- Makefile.am | 2 +- Makefile.mesh | 1 + Makefile.obexd | 1 + Makefile.plugins | 2 +- Makefile.tools | 2 +- configure.ac | 1 + 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 22b4fa30c..56279c4ba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ - +# SPDX-License-Identifier: GPL-2.0 AM_MAKEFLAGS = --no-print-directory AM_CPPFLAGS = diff --git a/Makefile.mesh b/Makefile.mesh index 10573b304..228dd1b5f 100644 --- a/Makefile.mesh +++ b/Makefile.mesh @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 if MESH if DATAFILES diff --git a/Makefile.obexd b/Makefile.obexd index de59d297b..6f5dc04c0 100644 --- a/Makefile.obexd +++ b/Makefile.obexd @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 if SYSTEMD systemduserunitdir = $(SYSTEMD_USERUNITDIR) systemduserunit_DATA = obexd/src/obex.service diff --git a/Makefile.plugins b/Makefile.plugins index 98eee9ec8..3b673bf85 100644 --- a/Makefile.plugins +++ b/Makefile.plugins @@ -1,4 +1,4 @@ - +# SPDX-License-Identifier: GPL-2.0 builtin_modules += hostname builtin_sources += plugins/hostname.c diff --git a/Makefile.tools b/Makefile.tools index e260a7f81..0423293d6 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -1,4 +1,4 @@ - +# SPDX-License-Identifier: GPL-2.0 if CLIENT bin_PROGRAMS += client/bluetoothctl diff --git a/configure.ac b/configure.ac index 292dca615..d6347c098 100644 --- a/configure.ac +++ b/configure.ac @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 AC_PREREQ(2.60) AC_INIT(bluez, 5.55) -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OI6bB7AmZV/kGgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Fri, 18 Sep 2020 23:29:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id YGQoBLAmZV/3AwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Fri, 18 Sep 2020 23:29:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 82294A0B14; Fri, 18 Sep 2020 23:29:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726298AbgIRV3E (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 17:29:04 -0400 Received: from mga01.intel.com ([192.55.52.88]:64721 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbgIRV3D (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 17:29:03 -0400 IronPort-SDR: YodmiyJ3xZZLuRIqGU2qEjkpgtfWSxK1iEosyRhIQJtc2DuWvcrlmW6fdv/dNUyX9DA9IfU2nl NW6ua4UEtaMw== X-IronPort-AV: E=McAfee;i="6000,8403,9748"; a="178125518" X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="178125518" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:26 -0700 IronPort-SDR: wYxpKbTJnx3ma0XeZAf1jx1rDnmcRV2hnKwD/3f84OCE4cROPcmmxQX0ilIeB/F9iWEqSpjQD5 Dms6dzhkZPeQ== X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="484378192" Received: from han1-mobl3.jf.intel.com ([10.255.229.3]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 14:09:25 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ v4 19/20] test: Add SPDX License Identifier Date: Fri, 18 Sep 2020 14:08:45 -0700 Message-Id: <20200918210846.37797-20-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200918210846.37797-1-tedd.an@linux.intel.com> References: <20200918210846.37797-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.06 / 15.00 / 15.00 X-Rspamd-Queue-Id: 82294A0B14 X-Rspamd-UID: 92bfdd From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 35 License: LGPL-2.1-or-later test/agent.py test/bluezutils.py test/dbusdef.py test/example-advertisement test/example-endpoint test/example-gatt-client test/example-gatt-server test/example-player test/exchange-business-cards test/ftp-client test/get-managed-objects test/get-obex-capabilities test/list-devices test/list-folders test/map-client test/monitor-bluetooth test/opp-client test/pbap-client test/sap_client.py test/simple-endpoint test/simple-obex-agent test/simple-player test/test-adapter test/test-device test/test-discovery test/test-gatt-profile test/test-health test/test-health-sink test/test-hfp test/test-manager test/test-mesh test/test-nap test/test-network test/test-profile test/test-sap-server --- test/agent.py | 1 + test/bluezutils.py | 2 ++ test/dbusdef.py | 2 ++ test/example-advertisement | 1 + test/example-endpoint | 1 + test/example-gatt-client | 1 + test/example-gatt-server | 1 + test/example-player | 1 + test/exchange-business-cards | 1 + test/ftp-client | 1 + test/get-managed-objects | 1 + test/get-obex-capabilities | 1 + test/list-devices | 1 + test/list-folders | 1 + test/map-client | 1 + test/monitor-bluetooth | 1 + test/opp-client | 1 + test/pbap-client | 1 + test/sap_client.py | 15 +-------------- test/simple-agent | 1 + test/simple-endpoint | 1 + test/simple-obex-agent | 1 + test/simple-player | 1 + test/test-adapter | 1 + test/test-device | 1 + test/test-discovery | 1 + test/test-gatt-profile | 1 + test/test-health | 1 + test/test-health-sink | 1 + test/test-hfp | 1 + test/test-join | 1 + test/test-manager | 1 + test/test-mesh | 1 + test/test-nap | 1 + test/test-network | 1 + test/test-profile | 1 + test/test-sap-server | 1 + 37 files changed, 39 insertions(+), 14 deletions(-) diff --git a/test/agent.py b/test/agent.py index d8e5534d8..b46cd95f4 100755 --- a/test/agent.py +++ b/test/agent.py @@ -1,4 +1,5 @@ #!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later import sys import dbus diff --git a/test/bluezutils.py b/test/bluezutils.py index cd8964082..85aa24277 100644 --- a/test/bluezutils.py +++ b/test/bluezutils.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + import dbus SERVICE_NAME = "org.bluez" diff --git a/test/dbusdef.py b/test/dbusdef.py index f1cd35adb..d317c18de 100644 --- a/test/dbusdef.py +++ b/test/dbusdef.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + import dbus import bluezutils diff --git a/test/example-advertisement b/test/example-advertisement index 96e410683..5f022ee67 100755 --- a/test/example-advertisement +++ b/test/example-advertisement @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import print_function diff --git a/test/example-endpoint b/test/example-endpoint index a5f0348a0..16651c683 100644 --- a/test/example-endpoint +++ b/test/example-endpoint @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/example-gatt-client b/test/example-gatt-client index b4bbaa9d9..5e6bef9d7 100755 --- a/test/example-gatt-client +++ b/test/example-gatt-client @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1-or-later import dbus try: diff --git a/test/example-gatt-server b/test/example-gatt-server index 689e86ff7..77231c3ad 100755 --- a/test/example-gatt-server +++ b/test/example-gatt-server @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1-or-later import dbus import dbus.exceptions diff --git a/test/example-player b/test/example-player index 2beb08e44..1497d1107 100644 --- a/test/example-player +++ b/test/example-player @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import print_function diff --git a/test/exchange-business-cards b/test/exchange-business-cards index 6805cf71e..9a3aa29fb 100755 --- a/test/exchange-business-cards +++ b/test/exchange-business-cards @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later import sys import dbus diff --git a/test/ftp-client b/test/ftp-client index 4540602a0..ef756ab2b 100755 --- a/test/ftp-client +++ b/test/ftp-client @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/get-managed-objects b/test/get-managed-objects index 3156f658f..5125ee524 100755 --- a/test/get-managed-objects +++ b/test/get-managed-objects @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/get-obex-capabilities b/test/get-obex-capabilities index e8afbad21..a7980a442 100755 --- a/test/get-obex-capabilities +++ b/test/get-obex-capabilities @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later import sys import dbus diff --git a/test/list-devices b/test/list-devices index 0aac217d1..b112556c3 100755 --- a/test/list-devices +++ b/test/list-devices @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/list-folders b/test/list-folders index 7321a1527..b4e3f100b 100755 --- a/test/list-folders +++ b/test/list-folders @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later import sys import dbus diff --git a/test/map-client b/test/map-client index b9695da66..a2d96ae5f 100755 --- a/test/map-client +++ b/test/map-client @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/monitor-bluetooth b/test/monitor-bluetooth index d9b5472f5..a3977e206 100755 --- a/test/monitor-bluetooth +++ b/test/monitor-bluetooth @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/opp-client b/test/opp-client index 62d5b8454..4f00a41c0 100755 --- a/test/opp-client +++ b/test/opp-client @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/pbap-client b/test/pbap-client index 16a786bb1..e6cafdd30 100755 --- a/test/pbap-client +++ b/test/pbap-client @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/sap_client.py b/test/sap_client.py index 413424c05..fed13aedc 100644 --- a/test/sap_client.py +++ b/test/sap_client.py @@ -1,21 +1,8 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later """ Copyright (C) 2010-2011 ST-Ericsson SA """ """ Author: Szymon Janc <szymon.janc@tieto.com> for ST-Ericsson. """ -""" This program is free software; you can redistribute it and/or modify """ -""" it under the terms of the GNU General Public License as published by """ -""" the Free Software Foundation; either version 2 of the License, or """ -""" (at your option) any later version. """ - -""" This program is distributed in the hope that it will be useful, """ -""" but WITHOUT ANY WARRANTY; without even the implied warranty of """ -""" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the """ -""" GNU General Public License for more details. """ - -""" You should have received a copy of the GNU General Public License """ -""" along with this program; if not, write to the Free Software """ -""" Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ - from array import array from bluetooth import * import time diff --git a/test/simple-agent b/test/simple-agent index a69299a3e..4fdaff1eb 100755 --- a/test/simple-agent +++ b/test/simple-agent @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/simple-endpoint b/test/simple-endpoint index 78fb5fda5..59ca189ce 100755 --- a/test/simple-endpoint +++ b/test/simple-endpoint @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/simple-obex-agent b/test/simple-obex-agent index 05ec4eda7..064f6d30b 100755 --- a/test/simple-obex-agent +++ b/test/simple-obex-agent @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/simple-player b/test/simple-player index 02754c2f4..92682844d 100755 --- a/test/simple-player +++ b/test/simple-player @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import print_function diff --git a/test/test-adapter b/test/test-adapter index 959a43703..a216140ba 100755 --- a/test/test-adapter +++ b/test/test-adapter @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-device b/test/test-device index b490d53f4..a1e508166 100755 --- a/test/test-device +++ b/test/test-device @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-discovery b/test/test-discovery index cea77683d..eccc7c7e3 100755 --- a/test/test-discovery +++ b/test/test-discovery @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-gatt-profile b/test/test-gatt-profile index 995a65913..a973ae14e 100755 --- a/test/test-gatt-profile +++ b/test/test-gatt-profile @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-health b/test/test-health index 24afa799e..d6b437ed8 100755 --- a/test/test-health +++ b/test/test-health @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals # -*- coding: utf-8 -*- diff --git a/test/test-health-sink b/test/test-health-sink index 37e630a21..57665d2ba 100755 --- a/test/test-health-sink +++ b/test/test-health-sink @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals # -*- coding: utf-8 -*- diff --git a/test/test-hfp b/test/test-hfp index a8060439e..11e328e54 100755 --- a/test/test-hfp +++ b/test/test-hfp @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-join b/test/test-join index 6dfb2e8c3..969795094 100644 --- a/test/test-join +++ b/test/test-join @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1-or-later import sys import struct diff --git a/test/test-manager b/test/test-manager index 4f5994f67..3fa7205a0 100755 --- a/test/test-manager +++ b/test/test-manager @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-mesh b/test/test-mesh index 1e1b8724d..9e4783734 100755 --- a/test/test-mesh +++ b/test/test-mesh @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1-or-later ################################################################### # diff --git a/test/test-nap b/test/test-nap index ab67a7509..d5c757b79 100755 --- a/test/test-nap +++ b/test/test-nap @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-network b/test/test-network index 6f0948649..acc7dff65 100755 --- a/test/test-network +++ b/test/test-network @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-profile b/test/test-profile index 27915806f..af1e23f76 100755 --- a/test/test-profile +++ b/test/test-profile @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-sap-server b/test/test-sap-server index ff178af22..ddb1efe9b 100755 --- a/test/test-sap-server +++ b/test/test-sap-server @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gAfzG9AwZV9lRgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:12:32 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id OJ3uGNAwZV+joAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:12:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D1AAD40677; Sat, 19 Sep 2020 00:12:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726276AbgIRWMY (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:12:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbgIRWMX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:12:23 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF577C0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:12:23 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id x14so8840930oic.9 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5nZKXAmQXOCYqMZ4lcdAaR9zafR1QMAlp0o9MGm/Juk=; b=Y5yyVV10zFxt7f0jQANZ2WHjs4d+K8ewhV4sY31a0fhwF1SAfvyHbnUse3CcLd412D PgBPs1pyNWhzcErZ8msrRiYjEOlCRX9X/CTKH4r5iBjMk9DaDTd0tzIgr3n8jJRNhH9x Mbkgtt7vLrxwzT/+VFuQRpWolCXF1/IZXYyzIJwOsLBDRheQqCdVsWt8gJ8L4HvtujSI E+0RhWvlY1lAlNPhQtS2MQJTg68XffCuyZUVB1rXWvETESOi1yqNDw4qo3VbzvGYZnTF MbJvW0ee49hIVTaqK/a7T5U4SrJarq/YUdv/8bdjhdDYlMKRXEFrzxETefoN2zWgiFwQ F4Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5nZKXAmQXOCYqMZ4lcdAaR9zafR1QMAlp0o9MGm/Juk=; b=VhgbpZqz4xpJz3BHBHS4Km2ctaPwFjeW02zJuI/T3vaxEFQZCRu7rMxowcm37eWfgH zqCf+qK2Vbb9wVb+42Dq94ZXJUAUGZhqOVVPDtLxVvzWsuXBxytKGaUvuYPgJOhunDyb 7Q187+Zdp5O22L1ScZxRpBQyGA97MAENkDadPw7EG7Ai0y1CBBuv8AOJMdaIx8A3FR4r TAWDDav9m0H1Bv9tgwgNAA1AGtBvljN7mvUGMyVrEtpXUP4Yw5CF8vB6VrvoWqkAEZ2/ MHlhp7680Vg0roEhgORMC3i1I5oRTL49+UYUcd2AmRuQtMrGPBesKZXCGa8i+1UZwX3Z SYZw== X-Gm-Message-State: AOAM533uPInjVYM8Ud5QTRWD2l/UGG+Ha+NcPnlr8CUzM3DQUkhOmYZM uA47WQpxRqyc5hh9qZUMXQM+LEt6UqkjQfoi83Y= X-Google-Smtp-Source: ABdhPJwJxaCqWVCDehe9yaMucVj5bGqUlPTlr2BruuG4fUfzvCw84GEsIyfpu93Q3QTyyV2XHVMIN8UpHDy44fb4lWQ= X-Received: by 2002:aca:3e08:: with SMTP id l8mr10147892oia.152.1600467143139; Fri, 18 Sep 2020 15:12:23 -0700 (PDT) MIME-Version: 1.0 References: <CABmPvSHYi7WeWqgqxSe60omSyVXj_EezMhGi1GMXBBWM-TWeBw@mail.gmail.com> In-Reply-To: <CABmPvSHYi7WeWqgqxSe60omSyVXj_EezMhGi1GMXBBWM-TWeBw@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 18 Sep 2020 15:12:12 -0700 Message-ID: <CABBYNZJDbPd83cx0KWLGMpE_KaA9xUbuMCDsuQVTNxV7xrowiw@mail.gmail.com> Subject: Re: Modifying Makefile.am to facilitate test-adv-monitor and future unit tests. To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.81 / 15.00 / 15.00 X-Rspamd-Queue-Id: D1AAD40677 X-Rspamd-UID: d21a60 Hi Miao, On Fri, Sep 18, 2020 at 12:44 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > Hi Luiz and Marcel, > > Unlike the rest of the existing unit tests in BlueZ, the logic blocks > tested in test-adv-monitor require dependencies of not only > src/adv_monitor.c but also all the dependency tree of > src/adv_monitor.c. The current convention in Makefile.am is to add all > the extra dependencies one by one. However, the maintenance cost is > high and not suitable in the case of test-adv-monitor. Therefore, we'd > like to propose changes in Makefile.am to make the source of > bluetoothd as a static library and link it for bluetoothd target and > the unit test target. It would be great if you can provide feedback on > this idea before the implementation. Thanks in advance! Then we should have had the code move to src/shared for unit testing, but how exactly are you planning to do that? For testing the kernel interface it normally done via a dedicated tester, but that again can be done with shared library. > Regards, > Miao -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qCbiFxQxZV/eVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:13:40 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id AK7iFBQxZV/MdQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:13:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id A49FB40873; Sat, 19 Sep 2020 00:13:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726157AbgIRWNe (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:13:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbgIRWNd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:13:33 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9665C0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:13:33 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id c13so8848655oiy.6 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+WhB1J1H9Gun1aW5BMN2B4pl+dxsJznMXuc3BkdzdfY=; b=iEdwJbw9CcHWPxcbKxW3+i99lSL4qtUG1zrEP6DHiLH1QM+acnQgAjYb/w3XuPAWkS M2ym1HO5Adj7DIP/PPF7U38PeYcmuLxHQap2WaEADUvluwTpO7T4SYTZY9OoDcqRl1gn uXEth0OLSeMWpkp7CfT3rrRT1boU0TQTO52WYEONkdCO51WTXqjYMstpMfqUoZA4B8pj K5jajG35T8EucRwir6GPyv5MJsI92lI75FGMimcusMz0iSH/benvWZABevHLqJhim5dD G8g7JdYY6g3md2d1gcecpm3eo2O9iy9qGv4tS9cpOG+Ug+mhE5BexfmUPCuatZM/t8U6 ci9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+WhB1J1H9Gun1aW5BMN2B4pl+dxsJznMXuc3BkdzdfY=; b=oLUCJmT0wgKZ37twWu5QkGNzMNQLaYGNPBBHOW7sEQZgPTjybMeRoEqLTBvnTuU0K/ Q6v5SNJbySUilH1OCYPaQk3GUBO+KvZazWTbyzMDQW2AY9TIN4qDlGIHlmZh27rRkn17 PEKcFF6527ASW7fiRoTF3sA91mcaJ8IEDGiMyOBunSEenPOXMyKFGEeL7t3GmrXLeFzM xbBJFb9AsfddSpRz/fpaKLyX/iusK2dJqkTJjtn2G1BS/uXP8l1XDI/U4howFpQj+b/b xfm+DY1Dasjw+LM2SHBzGcmRSgLdHfO1d09uvAjDPoRXw3c/N30zvJwELkMg3zupjYqI DGRw== X-Gm-Message-State: AOAM533VRDPrWJ5M9jAAdW66ghlQ7awMy1dZT1w06RE8lq3DPhdvdcmN F525MW/W8p8TJBAQtUHZGCIltXC/3KysPGf0wlc= X-Google-Smtp-Source: ABdhPJwF6xRVrVHfC68waoK79wJ5SG5A87GNk5svVgZ0Ushk93m8fmIpkKXiU8ZKvTvnwn1tWN9AjbkMrGLFrF0CEVI= X-Received: by 2002:aca:38d7:: with SMTP id f206mr10002631oia.48.1600467213164; Fri, 18 Sep 2020 15:13:33 -0700 (PDT) MIME-Version: 1.0 References: <20200918210846.37797-1-tedd.an@linux.intel.com> <20200918210846.37797-4-tedd.an@linux.intel.com> In-Reply-To: <20200918210846.37797-4-tedd.an@linux.intel.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Fri, 18 Sep 2020 15:13:22 -0700 Message-ID: <CABBYNZ+8-GsnTeJyCETo-3pGHSDxxDUS_6szMvbGfS8_ngyRVA@mail.gmail.com> Subject: Re: [BlueZ v4 03/20] btio: Add SPDX License Identifier To: Tedd Ho-Jeong An <tedd.an@linux.intel.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Tedd Ho-Jeong An <tedd.an@intel.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.94 / 15.00 / 15.00 X-Rspamd-Queue-Id: A49FB40873 X-Rspamd-UID: 560928 Hi Tedd, On Fri, Sep 18, 2020 at 2:17 PM <tedd.an@linux.intel.com> wrote: > > From: Tedd Ho-Jeong An <tedd.an@intel.com> > > This patch adds SPDX License Identifier and removes the license text. > > ------------------------------------- > License COUNT > ------------------------------------- > GPL-2.0-or-later : 2 > > License: GPL-2.0-or-later > btio/btio.h > btio/btio.c > --- > btio/btio.c | 15 +-------------- > btio/btio.h | 15 +-------------- > 2 files changed, 2 insertions(+), 28 deletions(-) > > diff --git a/btio/btio.c b/btio/btio.c > index 844d6007f..c18b6a012 100644 > --- a/btio/btio.c > +++ b/btio/btio.c > @@ -1,3 +1,4 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later It still appears to be using C++ comment style. > /* > * > * BlueZ - Bluetooth protocol stack for Linux > @@ -6,20 +7,6 @@ > * Copyright (C) 2009-2010 Nokia Corporation > * > * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; either version 2 of the License, or > - * (at your option) any later version. > - * > - * This program is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > - * GNU General Public License for more details. > - * > - * You should have received a copy of the GNU General Public License > - * along with this program; if not, write to the Free Software > - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > - * > */ > > #ifdef HAVE_CONFIG_H > diff --git a/btio/btio.h b/btio/btio.h > index 23e0ef72b..f0259cf1d 100644 > --- a/btio/btio.h > +++ b/btio/btio.h > @@ -1,3 +1,4 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > /* > * > * BlueZ - Bluetooth protocol stack for Linux > @@ -6,20 +7,6 @@ > * Copyright (C) 2009-2010 Nokia Corporation > * > * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; either version 2 of the License, or > - * (at your option) any later version. > - * > - * This program is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > - * GNU General Public License for more details. > - * > - * You should have received a copy of the GNU General Public License > - * along with this program; if not, write to the Free Software > - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > - * > */ > #ifndef BT_IO_H > #define BT_IO_H > -- > 2.17.1 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IO/cBDYxZV9lRgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:14:14 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iBl2ATYxZV/s+gAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:14:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0710BA0B84; Sat, 19 Sep 2020 00:14:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726159AbgIRWOH (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbgIRWOH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:14:07 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DD32C0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:07 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id y17so5848717qkf.15 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=JfKZ2fPSMMAR4yhaJbPJAgMbWeKJCTjpmBm0wD4pcOk=; b=Ixzu33te/Ix5TRQyhqx2UR3AmGEup276iG7YUI/MxHF5x+BSKcqpyMH7rWSADh/vBs YL3Hc4DWDZmLrmZ4Sf9vmWUDmbLmDADYC9UhXo4cGBnuqWZMsFeRhNtHcMC8Igj0UqBF fc2SXL6j6NixMF/6XigUmdaIm9h8tnJyiQhsy5+J6Hj4WX4/WhJlLLh5sYFf6lvowVhq 6I7FVitxSxb7Ba3HO5Mnljhg3dN0M4VzkoNZMpHH/1ztPFv21U1MUFxD2FYBhL4teuWS S+ws5C9LNaABJo46YSjhNndRCMnYeGmcpb9LodhTJHhH+lvfr6QHgSd+XP7mz/RlQ3kl nqcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=JfKZ2fPSMMAR4yhaJbPJAgMbWeKJCTjpmBm0wD4pcOk=; b=Q+sQWnkIj7/27n75XQsTP8kC0c4U91C2MYIaV2g+R7gAk4BOfkxrIy4ITep6T31yyp mVS0x7BRij3KL1bt117UKBEWsFE1JinBZ1FugDqFUk9gQx7q0kkZA6+UlYzRwEqdqB6T unN6aRF33zX27eUxE56gEq0KaQeDCN3jbpC0dxRrgwOo+hzS9OQsi0eZHxzuGo6eSfMF gyr8y/yfVom/mb3eVTY9CT9DPh+gipxvN5fFOSmYHPoVz+Sv6vOQUSDC/nsY8Wi282EW OEiuX8kIovb11wBvAtj01hA+jX58nVoEeFPAnroIecLJ7olx/xhlMNUz9NMv1i4Ik8NW ELzw== X-Gm-Message-State: AOAM5326ETmKja5WPMK99XfPeCj0EGAOpjOsfcMSZamlr2ftI45uATKf 69uTOAxnZQotK7kLxam4ZVMrPk3vwKoGUWqXPX5/ X-Google-Smtp-Source: ABdhPJwe2GzdOsCxs5Iy1AD6oDmvKncWnMsj2t/16x7n2CVTP724jNrN+Sl45xfK31MazxZU94+9GMk8FHiCX365o232 Sender: "danielwinkler via sendgmr" <danielwinkler@danielwinkler-linux.mtv.corp.google.com> X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:ad4:58e7:: with SMTP id di7mr19039339qvb.36.1600467246622; Fri, 18 Sep 2020 15:14:06 -0700 (PDT) Date: Fri, 18 Sep 2020 15:13:47 -0700 Message-Id: <20200918221357.3436905-1-danielwinkler@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2 00/10] Bluetooth: Add new MGMT interface for advertising add From: Daniel Winkler <danielwinkler@google.com> To: luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.98 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0710BA0B84 X-Rspamd-UID: 220ac9 Hi Maintainers, This patch series defines the new two-call MGMT interface in userspace for adding advertising instances. Bluez will detect if kernel supports the new MGMT commands, and use them if so. Each new advertising instance will be configured by a MGMT call to set advertising parameters, followed by a MGMT call to set advertising data. The new data pipeline is meant to be unnoticeable from the clients' perspective, with the exception of new intervals and tx power support, and new exposed advertising manager properties. All changes have been tested on hatch (extended advertising) and kukui (no extended advertising) chromebooks with manual testing verifying correctness of parameters/data in btmon traces, and our automated test suite of 25 single- and multi-advertising usage scenarios. V2 of the series puts documentation at the front as requested. Thank you in advance for your review! Daniel Winkler Changes in v2: - Removed extra space in Add Extended Advertising Parameters API - Uses btd_has_kernel_features to detect kernel command support - Cleaned fail path in add_adv_params_callback Daniel Winkler (10): doc/advertising-api: update API with new interface doc/mgmt-api: Add new MGMT interfaces to mgmt-api advertising: Detect if extended advertising mgmt commands are supported advertising: Parse intervals and tx power from adv advertising: Use new mgmt interface for advertising add advertising: Catch tx power selected event and handle it advertising: Query LE TX range at manager initialization advertising: Expose SupportedCapabilities for advertising client: Add SupportedCapabilities to bluetoothctl monitor: Add new MGMT adv commands and events to monitor client/main.c | 1 + doc/advertising-api.txt | 50 +++++ doc/mgmt-api.txt | 242 ++++++++++++++++++++++ lib/mgmt.h | 45 +++++ monitor/packet.c | 84 ++++++++ src/adapter.c | 4 + src/adapter.h | 1 + src/advertising.c | 433 ++++++++++++++++++++++++++++++++++++++-- 8 files changed, 845 insertions(+), 15 deletions(-) -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2PyOCjwxZV9lRgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:14:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id 8KaEBzwxZV9GpAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:14:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 26EC3A0B20; Sat, 19 Sep 2020 00:14:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbgIRWOK (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:14:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbgIRWOK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:14:10 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC24AC0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:09 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id k3so7020914ybp.1 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=bkV98mI6HTRBlveAwJJOx4rOMskQp0RNxjsBtvixoqs=; b=UjS+4Zpss152SNoNBSO32DHFsLojPtyJw3i+GuvleOYCi8hQ9rlM0ItVrh0W+MMFX4 D3YV+Ur+Rum2j6f6pVeJTflJV9uP7BNwJMZ8A/d6coeg0/0TI3HGh7vHtJ6A5fFPNvlO Y1PUWDjYIDflwyEOI9b6YjU6zhFEsas6lS2pYFakM5RD1+dxiPY+lRcvar8YS7xq+P6h BcZaxAdbTqniefdQJQOOQb9aNFW8nNIkzqob6TQBuDmtkaWJoF73eRFR/Neqwx0qQ7uz oP0nwEPkN2v2rqtiyK6uaAk3t3+OZbcO5GIujEHcXwnTANO/bL/aCTLs5GZ15y9I0Uiq FWvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bkV98mI6HTRBlveAwJJOx4rOMskQp0RNxjsBtvixoqs=; b=oiCuZpR8RKrQhTY29Cmy099mGavG2rbEv9gKw8AheLqxrGXU/dr7U366wDMyNzzT7f GnahM+ht2LnlIEB0PVBxbcwyTeh3X3/a9mfBlkVmbmfKHwes8KoqN9fYO3xL+Zw/USqv /rQFZUBxCSsRb5U8q9ZbMvNckKAdk3xh81qCgty0IJVRMJdxG/q5zho3/NU4jWp0RduV ZtYlvamxJ3sPonK2q1MDQzHK6BWoWLKwfeOkJo1UF6mwXsuVa5hKs1f6LNy5z4Oyz922 9UmRhfzKhUTy/2duxWAnzqsMhj+PiZGYSro4okr3E4hbs6OW8dH2jQMxpWOYGiOhlUag zYMg== X-Gm-Message-State: AOAM532m8QOINr7LphH3/ZC9JKnytTvOsx/wf8XD8ghy3hBy7l4q9hZ1 ahP8cFo+IO/caCnKlRBR5cKDqmFAP8TsFPOQBb7C X-Google-Smtp-Source: ABdhPJyNpbteRCiREnsaR7X6D0/wXYQ3N25hOoH+i+QUENmMweBb9oKlq1/2WVyF/e+oULjZwxv+X9vt7ZMqUH4Vz6/l Sender: "danielwinkler via sendgmr" <danielwinkler@danielwinkler-linux.mtv.corp.google.com> X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:6e87:: with SMTP id j129mr35630636ybc.424.1600467248869; Fri, 18 Sep 2020 15:14:08 -0700 (PDT) Date: Fri, 18 Sep 2020 15:13:48 -0700 In-Reply-To: <20200918221357.3436905-1-danielwinkler@google.com> Message-Id: <20200918151041.Bluez.v2.1.Ifaa96e71a871158e5d9d454073b2b6846eae339f@changeid> Mime-Version: 1.0 References: <20200918221357.3436905-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2 01/10] doc/advertising-api: update API with new interface From: Daniel Winkler <danielwinkler@google.com> To: luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.01 / 15.00 / 15.00 X-Rspamd-Queue-Id: 26EC3A0B20 X-Rspamd-UID: 890aee This updates the advertising documentation to include the following features: LE Advertising Manager: - New SupportedCapabilities property LE Advertisement: - New min/max interval properties - New tx power property Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: None doc/advertising-api.txt | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt index b0565eab2..3215a52f7 100644 --- a/doc/advertising-api.txt +++ b/doc/advertising-api.txt @@ -138,6 +138,33 @@ Properties string Type "2M" "Coded" + uint32 MinInterval + + Minimum advertising interval to be used by the + advertising set, in .625 millisecond slots. + Time = N * .625 ms, where N has range + [0x000020, 0xFFFFFF]. If the provided MinInterval is + larger than the provided MaxInterval, the registration + will return failure. + + uint32 MaxInterval + + Maximum advertising interval to be used by the + advertising set, in .625 millisecond slots. + Time = N * .625 ms, where N has range + [0x000020, 0xFFFFFF]. If the provided MinInterval is + larger than the provided MaxInterval, the registration + will return failure. + + int16 TxPower + + Requested transmission power of this advertising set. + The provided value is used only if the "CanSetTxPower" + feature is enabled on the Advertising Manager. The + provided value must be in range [-127 to +20], where + units are in dBm. + + LE Advertising Manager hierarchy ================================ @@ -209,3 +236,26 @@ Properties byte ActiveInstances Possible values: "1M" "2M" "Coded" + + dict SupportedCapabilities + + Enumerates Advertising-related controller capabilities + useful to the client. + + Possible Values: + + byte MaxAdvLen + + Max advertising data length + + byte MaxScnRspLen + + Max advertising scan response length + + int16 MinTxPower + + Min advertising tx power (dBm) + + int16 MaxTxPower + + Max advertising tx power (dBm) -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YPoNLlkxZV/eVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:14:49 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id 4IAUK1kxZV/MdQEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:14:49 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 36725A0B7A; Sat, 19 Sep 2020 00:14:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726285AbgIRWOT (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:14:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgIRWOS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:14:18 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 834AEC0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:18 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id g189so6894050ybg.9 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=lYHat5yuNdgK2r35k9Snf3w/9eMRmnd0NP1xrlEbnvo=; b=oYoSpkGhE0TUavlGl2zH9aae4F1lri8CSJUEKwp71c8PDGPDl/t+XrkdBa24bfztmc tc8QfOa2oomXU8qXK7hRl0VBvMlshl8ecL7UOuIc4sRw5MgZe19wXcODs/6gcb8IbuN9 YpJ4Un5XQd6HZdIZgHhHg0RZExxVK/WBlyf2aIs80PPGxxc3FkA8D4xM9F/K8pI+9oBa LL5hanKuq3kRq1g0dTOBn7lSifKJcatFGmr7v72wGYnPKwXCys9rBw69dufKIB9DJWRe UkrJgPRt+ABjCA7PJuDMatT4VK7FxKZNvLG26wf3Ue2tDupzHw3300s/J35qfg7uJHo1 e8Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=lYHat5yuNdgK2r35k9Snf3w/9eMRmnd0NP1xrlEbnvo=; b=Zigpe/2OGDrXVLG8UUJ/QcGwr9r+GXLj2UULf8QN4ktbykdN9YLSBOW5G63zKdWkoW uSFiSFlS+h48YFJ2Int2PnUfRHQppHbNJLDS3b/z1tA0ZPd3+oKaCdx1OYyHA42GpHel e4+4P8cnZthPXJDOM5/FiV+vFZZgtzTrlLOVYR9lpja8Nk2yyNYfeuxhd3KGQ4mvw0p2 KVWNh1To2GDRmjd1AmmYWDq07Kp+udawY730HvopTHoiMoOPV5FJxDpRWKQTdqdlQX2P FFC3n6FdE2fDpxMVGZrTrth6j8TjLxl2gQpsKV5Ww+4ubajBWdQE5HIgrRNcScWUaMdk 57og== X-Gm-Message-State: AOAM5315Bh0zJ/vGvPh1AL7Pi1Ze4imJ45U71egnZ08yrtIKSY7vmS+m THrSsqH41ujAsGcafQl5uK9WoTHtqUvTy7TgmLFL X-Google-Smtp-Source: ABdhPJxii+sQzb+fxsjADPDNPTBUXwumo9s7Jla1s8hwgJvkKfMazNb4Y+QccbDAoIXgef1lpdkUgXY1iXUNN52/Rr/+ Sender: "danielwinkler via sendgmr" <danielwinkler@danielwinkler-linux.mtv.corp.google.com> X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a5b:b07:: with SMTP id z7mr5265825ybp.318.1600467257760; Fri, 18 Sep 2020 15:14:17 -0700 (PDT) Date: Fri, 18 Sep 2020 15:13:52 -0700 In-Reply-To: <20200918221357.3436905-1-danielwinkler@google.com> Message-Id: <20200918151041.Bluez.v2.5.Ia49df7ccded97ceb4ff1d1b0decc49d03d088a84@changeid> Mime-Version: 1.0 References: <20200918221357.3436905-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2 05/10] advertising: Use new mgmt interface for advertising add From: Daniel Winkler <danielwinkler@google.com> To: luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.87 / 15.00 / 15.00 X-Rspamd-Queue-Id: 36725A0B7A X-Rspamd-UID: 452d85 This patch allows bluetoothd to use the new extended advertising add mgmt interface if it is available. The new interface will be used by default, as it allows the client to set advertising intervals, and tx power if the controller and kernel support extended advertising. Each new registered advertisement will submit two requests to kernel; the first sets the advertising parameters for the advertising instance, and the second sets the advertising data and scan response for the instance. This change has been tested extensively on Hatch (extended advertising) and Kukui (no extended advertising) chromebooks. Manual tests do the following: - Configure advertisement with custom intervals, tx power with valid and invalid values and combinations - Ensure that with valid parameters, they are propagated and set in hci requests. With invalid parameters, ensure that the registration fails. Automatic tests verify 25 advertising usage scenarios involving single and multi-advertising registration, over-registration, parameter validation, etc. These tests don't test new intervals and tx power, but validate that the new MGMT interface does not regress compatibility in these 25 scenarios. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: - Cleaned fail path in add_adv_params_callback lib/mgmt.h | 31 +++++++ src/advertising.c | 216 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 232 insertions(+), 15 deletions(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index 46d894ae9..9874be004 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -713,6 +713,37 @@ struct mgmt_rp_remove_adv_monitor { uint16_t monitor_handle; } __packed; +#define MGMT_ADV_PARAM_DURATION (1 << 0) +#define MGMT_ADV_PARAM_TIMEOUT (1 << 1) +#define MGMT_ADV_PARAM_INTERVALS (1 << 2) +#define MGMT_ADV_PARAM_TX_POWER (1 << 3) + +#define MGMT_OP_ADD_EXT_ADV_PARAMS 0x0054 +struct mgmt_cp_add_ext_adv_params { + uint8_t instance; + uint32_t flags; + uint16_t params; + uint16_t duration; + uint16_t timeout; + uint32_t min_interval; + uint32_t max_interval; + int8_t tx_power; +} __packed; +struct mgmt_rp_add_ext_adv_params { + uint8_t instance; +} __packed; + +#define MGMT_OP_ADD_EXT_ADV_DATA 0x0055 +struct mgmt_cp_add_ext_adv_data { + uint8_t instance; + uint8_t adv_data_len; + uint8_t scan_rsp_len; + uint8_t data[0]; +} __packed; +struct mgmt_rp_add_ext_adv_data { + uint8_t instance; +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { uint16_t opcode; diff --git a/src/advertising.c b/src/advertising.c index 3c173fef0..cab0b79de 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -91,6 +91,7 @@ struct btd_adv_client { uint32_t min_interval; uint32_t max_interval; int8_t tx_power; + mgmt_request_func_t refresh_done_func; }; struct dbus_obj_match { @@ -797,19 +798,9 @@ static uint8_t *generate_scan_rsp(struct btd_adv_client *client, return bt_ad_generate(client->scan, len); } -static int refresh_adv(struct btd_adv_client *client, mgmt_request_func_t func, - unsigned int *mgmt_id) +static int get_adv_flags(struct btd_adv_client *client) { - struct mgmt_cp_add_advertising *cp; - uint8_t param_len; - uint8_t *adv_data; - size_t adv_data_len; - uint8_t *scan_rsp; - size_t scan_rsp_len = -1; uint32_t flags = 0; - unsigned int mgmt_ret; - - DBG("Refreshing advertisement: %s", client->path); if (client->type == AD_TYPE_PERIPHERAL) { flags = MGMT_ADV_FLAG_CONNECTABLE; @@ -821,6 +812,26 @@ static int refresh_adv(struct btd_adv_client *client, mgmt_request_func_t func, flags |= client->flags; + return flags; +} + +static int refresh_legacy_adv(struct btd_adv_client *client, + mgmt_request_func_t func, + unsigned int *mgmt_id) +{ + struct mgmt_cp_add_advertising *cp; + uint8_t param_len; + uint8_t *adv_data; + size_t adv_data_len; + uint8_t *scan_rsp; + size_t scan_rsp_len = -1; + uint32_t flags = 0; + unsigned int mgmt_ret; + + DBG("Refreshing advertisement: %s", client->path); + + flags = get_adv_flags(client); + adv_data = generate_adv_data(client, &flags, &adv_data_len); if (!adv_data || (adv_data_len > calc_max_adv_len(client, flags))) { error("Advertising data too long or couldn't be generated."); @@ -873,6 +884,76 @@ static int refresh_adv(struct btd_adv_client *client, mgmt_request_func_t func, return 0; } +static void add_adv_params_callback(uint8_t status, uint16_t length, + const void *param, void *user_data); + +static int refresh_extended_adv(struct btd_adv_client *client, + mgmt_request_func_t func, unsigned int *mgmt_id) +{ + struct mgmt_cp_add_ext_adv_params cp; + uint32_t flags = 0; + uint16_t included_params = 0; + unsigned int mgmt_ret = 0; + + DBG("Refreshing advertisement parameters: %s", client->path); + + flags = get_adv_flags(client); + + memset(&cp, 0, sizeof(cp)); + cp.flags = htobl(flags); + cp.instance = client->instance; + + /* Not all advertising instances will use all possible parameters. The + * included_params bit field tells the kernel which parameters are + * relevant, and sensible defaults will be used for the rest + */ + + if (client->duration) { + cp.duration = client->duration; + included_params |= MGMT_ADV_PARAM_DURATION; + } + + if (client->min_interval && client->max_interval) { + cp.min_interval = client->min_interval; + cp.max_interval = client->max_interval; + included_params |= MGMT_ADV_PARAM_INTERVALS; + } + + if (client->tx_power != ADV_TX_POWER_NO_PREFERENCE) { + cp.tx_power = client->tx_power; + included_params |= MGMT_ADV_PARAM_TX_POWER; + } + + cp.params = included_params; + + mgmt_ret = mgmt_send(client->manager->mgmt, MGMT_OP_ADD_EXT_ADV_PARAMS, + client->manager->mgmt_index, sizeof(cp), &cp, + add_adv_params_callback, client, NULL); + + if (!mgmt_ret) { + error("Failed to request extended advertising parameters"); + return -EINVAL; + } + + /* Store callback, called after we set advertising data */ + client->refresh_done_func = func; + + if (mgmt_id) + *mgmt_id = mgmt_ret; + + + return 0; +} + +static int refresh_advertisement(struct btd_adv_client *client, + mgmt_request_func_t func, unsigned int *mgmt_id) +{ + if (client->manager->extended_add_cmds) + return refresh_extended_adv(client, func, mgmt_id); + + return refresh_legacy_adv(client, func, mgmt_id); +} + static gboolean client_discoverable_timeout(void *user_data) { struct btd_adv_client *client = user_data; @@ -883,7 +964,7 @@ static gboolean client_discoverable_timeout(void *user_data) bt_ad_clear_flags(client->data); - refresh_adv(client, NULL, NULL); + refresh_advertisement(client, NULL, NULL); return FALSE; } @@ -1057,7 +1138,8 @@ static void properties_changed(GDBusProxy *proxy, const char *name, continue; if (parser->func(iter, client)) { - refresh_adv(client, NULL, NULL); + refresh_advertisement(client, NULL, NULL); + break; } } @@ -1120,6 +1202,104 @@ done: add_client_complete(client, status); } +static void add_adv_params_callback(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct btd_adv_client *client = user_data; + const struct mgmt_rp_add_ext_adv_params *rp = param; + struct mgmt_cp_add_ext_adv_data *cp = NULL; + uint8_t param_len; + uint8_t *adv_data = NULL; + size_t adv_data_len; + uint8_t *scan_rsp = NULL; + size_t scan_rsp_len = -1; + uint32_t flags = 0; + unsigned int mgmt_ret; + + if (status) + goto fail; + + if (!param || length < sizeof(*rp)) { + status = MGMT_STATUS_FAILED; + goto fail; + } + + DBG("Refreshing advertisement data: %s", client->path); + + client->instance = rp->instance; + + flags = get_adv_flags(client); + + adv_data = generate_adv_data(client, &flags, &adv_data_len); + if (!adv_data || (adv_data_len > calc_max_adv_len(client, flags))) { + error("Advertising data too long or couldn't be generated."); + goto fail; + } + + scan_rsp = generate_scan_rsp(client, &flags, &scan_rsp_len); + if (!scan_rsp && scan_rsp_len) { + error("Scan data couldn't be generated."); + goto fail; + } + + param_len = sizeof(struct mgmt_cp_add_advertising) + adv_data_len + + scan_rsp_len; + + cp = malloc0(param_len); + if (!cp) { + error("Couldn't allocate for MGMT!"); + goto fail; + } + + cp->instance = client->instance; + cp->adv_data_len = adv_data_len; + cp->scan_rsp_len = scan_rsp_len; + memcpy(cp->data, adv_data, adv_data_len); + memcpy(cp->data + adv_data_len, scan_rsp, scan_rsp_len); + + free(adv_data); + free(scan_rsp); + adv_data = NULL; + scan_rsp = NULL; + + /* Submit request to update instance data */ + mgmt_ret = mgmt_send(client->manager->mgmt, MGMT_OP_ADD_EXT_ADV_DATA, + client->manager->mgmt_index, param_len, cp, + client->refresh_done_func, client, NULL); + + /* Clear the callback */ + client->refresh_done_func = NULL; + + if (!mgmt_ret) { + error("Failed to add Advertising Data"); + goto fail; + } + + if (client->add_adv_id) + client->add_adv_id = mgmt_ret; + + free(cp); + cp = NULL; + + return; + +fail: + if (adv_data) + free(adv_data); + + if (scan_rsp) + free(scan_rsp); + + if (cp) + free(cp); + + if (!status) + status = -EINVAL; + + /* Failure for any reason ends this advertising request */ + add_client_complete(client, status); +} + static DBusMessage *parse_advertisement(struct btd_adv_client *client) { struct adv_parser *parser; @@ -1178,7 +1358,9 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client) goto fail; } - err = refresh_adv(client, add_adv_callback, &client->add_adv_id); + err = refresh_advertisement(client, add_adv_callback, + &client->add_adv_id); + if (!err) return NULL; @@ -1257,6 +1439,8 @@ static struct btd_adv_client *client_create(struct btd_adv_manager *manager, client->min_interval = 0; client->max_interval = 0; + client->refresh_done_func = NULL; + return client; fail: @@ -1573,7 +1757,9 @@ void btd_adv_manager_destroy(struct btd_adv_manager *manager) static void manager_refresh(void *data, void *user_data) { - refresh_adv(data, user_data, NULL); + struct btd_adv_client *client = data; + + refresh_advertisement(client, user_data, NULL); } void btd_adv_manager_refresh(struct btd_adv_manager *manager) -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YNv3NV8xZV9lRgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:14:55 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id WO0iM18xZV/5gQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:14:55 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D5B37A03FD; Sat, 19 Sep 2020 00:14:49 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726298AbgIRWOV (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgIRWOU (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:14:20 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90EC6C0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:20 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id m203so5816433qke.16 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=91Zt9XP6Cj93+SBnN9YBrF7r0PR5X/CwV84AXjpBNuM=; b=Jb7aqUoKUmL8q5P7PCLnJOqU4JDR1t3xlCubss7xuiXoxa/7F6ceIDdbobl1zFPWok h1Yl2EQCkw3KjyDUSFgypen67KhwTWt7qTMV+9Z6nKJe0RHhMnIU1CHPTHrcNa1KQfgH xiOfSvyDwR+HivpcfTvJe0D0uO3A/XLOJyLzhkOXVv1aGy0Ukc8/tIx6crkVYs5aHXkr 07Y7Dzn6T/7/zwpQ/mWGeG38NqaKNJ8E7jErD8DMxSu0ctTeKXdMBDnaNEf2GK429A4s It6FyFmTDahFDoSXvKKfO84Vod1MgWuOAxO7hC/GCXGtGBH0oEtoa76LPSNsF5FNghSU XULQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=91Zt9XP6Cj93+SBnN9YBrF7r0PR5X/CwV84AXjpBNuM=; b=jjv6ZmyK5R3EzCFUl9lN5zX8QqV5BZPlmxDRDrfwsoVSGK4xwtvwEKWyZABVLGBr2w 12eQoVgELEN1f8Sj9G4OcwasPIosmNCSq67gxNEe0JQPC9N4p48YaTMHp4ZoDjl1iOlL iApcj+JiQfzUWcsfFggJGGw8DdJSnVm0n/caMzrYOg/pWsC2ktEzbXwuF4SOaVSOVhVw 5C9870swDLIpyCxjP0NDy6pPnJ/OR2thgCrrNW9LP9HInb+i/QQclf7KrrV83Bhf/yOw YUNr6u+t9I+AC0uQoEYOoPKcNZr5fz7BjvpUnJC+1bpuo1ZCWsR0wGr0E0EnCDoW92ni f/Ew== X-Gm-Message-State: AOAM530MbK2idoYKQMGkQ1cR3hFHIKqWixwVjCVmr09STeNJD00LCZvz Qqv8cjcoX6W0cv6Rkfl2/n+UIMYamSTI+bbm59P+ X-Google-Smtp-Source: ABdhPJyTE5ZqE2PBK8RXIbQZxL+nb4DoIbFYGtICCSYdAOtXzJkK2BAb4eOxZGzjB6egYKfg14I/C1qUbjj11AWiBfk2 Sender: "danielwinkler via sendgmr" <danielwinkler@danielwinkler-linux.mtv.corp.google.com> X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:ad4:5a0e:: with SMTP id ei14mr21140751qvb.15.1600467259757; Fri, 18 Sep 2020 15:14:19 -0700 (PDT) Date: Fri, 18 Sep 2020 15:13:53 -0700 In-Reply-To: <20200918221357.3436905-1-danielwinkler@google.com> Message-Id: <20200918151041.Bluez.v2.6.Ia7689bc6f45cf6b8e13a95cd1da4f96fbfc3ac14@changeid> Mime-Version: 1.0 References: <20200918221357.3436905-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2 06/10] advertising: Catch tx power selected event and handle it From: Daniel Winkler <danielwinkler@google.com> To: luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.87 / 15.00 / 15.00 X-Rspamd-Queue-Id: D5B37A03FD X-Rspamd-UID: e5de2f The new Tx Power Selected MGMT event will alert bluetoothd that an advertising instance has been assigned a tx power. This is intended to be used to then update the client of their instance's tx power. Towards this goal, this patch does the following: - When adv manager is created, register a handler for tx selected event - On callback, identify the relevant advertising instance, and call for a property set with the new value. If the client exposes this method, it will be called with the new value selected by the controller. To test, I modified the example-advertisement python script to implement the Set dbus method, and verified that it is called after advertisement registration on a device with extended advertising. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: None lib/mgmt.h | 6 ++++++ src/advertising.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index 9874be004..56f46ce93 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -1002,6 +1002,12 @@ struct mgmt_ev_controller_resume { uint8_t wake_reason; } __packed; +#define MGMT_EV_ADV_TX_POWER_SELECTED 0x002f +struct mgmt_ev_adv_tx_power_selected { + uint8_t instance; + int8_t tx_power; +} __packed; + static const char *mgmt_op[] = { "<0x0000>", "Read Version", diff --git a/src/advertising.c b/src/advertising.c index cab0b79de..c7deda1ad 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -113,6 +113,17 @@ static bool match_client(const void *a, const void *b) return true; } +static bool match_client_by_instance(const void *a, const void *b) +{ + const struct btd_adv_client *client = a; + const uint8_t *instance = b; + + if (client && client->instance == *instance) + return true; + + return false; +} + static void client_free(void *data) { struct btd_adv_client *client = data; @@ -1681,6 +1692,22 @@ static void read_adv_features_callback(uint8_t status, uint16_t length, remove_advertising(manager, 0); } +static void tx_power_selected(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_ev_adv_tx_power_selected *ev = param; + struct btd_adv_client *client; + struct btd_adv_manager *manager = user_data; + dbus_int16_t tx_power = ev->tx_power; + + client = queue_find(manager->clients, match_client_by_instance, + &ev->instance); + + if (client) + g_dbus_proxy_set_property_basic(client->proxy, "TxPower", + DBUS_TYPE_INT16, &tx_power, NULL, NULL, NULL); +} + static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, struct mgmt *mgmt) { @@ -1718,6 +1745,11 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, goto fail; } + if (manager->extended_add_cmds) + mgmt_register(manager->mgmt, MGMT_EV_ADV_TX_POWER_SELECTED, + manager->mgmt_index, tx_power_selected, + manager, NULL); + return manager; fail: -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kD2VC2YxZV/eVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:15:02 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id OFDPB2YxZV9pPwAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:15:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 00518A0BA8; Sat, 19 Sep 2020 00:14:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726301AbgIRWOX (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:14:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgIRWOW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:14:22 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F6ECC0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:22 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id v106so6975068ybi.6 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=+UYsjiFI/CQBXYMas9iBIuEs/wH6yGhZNNWuNxXrA70=; b=J/Bfsul9xGv5hj9OBtPkKSnLS5qbnVUUGCAqAI2l9bu9FkpVBQnF7Ohs3YtRsH0QdG mjdLtDAcCaixXwgqdg20RwJLH1ZrKHVF1l2UPq7D3PjI1xFJ+7Jn77mHRVHSQqznLiX8 4hEYyC+HPEG0hhVHQQvK4r5fovcz74hmLBjkNPE27BXKcF889kn7CYtsyViCWKYbIEdJ KzFLi3TR8Jwof9iacKcFEjP3XwOyWtgJvB0GKY/cMCR9PNsj+QXrRhzA+1ItSAFaJZ0y 09bAUq/Ktx8QeHwqL3b4Ae2wmRIHcaH35/vac6unqnT8Xa8nb9YL2Z86M0WuJq927ZtL c9jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+UYsjiFI/CQBXYMas9iBIuEs/wH6yGhZNNWuNxXrA70=; b=eMJK02E4J8XAj4J//EsjHyW63gaU8A1K/zsllX1cIwXsldhooFx19jqAXhdfG7Ic3k pNEm8PByp/aFaUYl803sH7ZIe2bnjkhlOsbc3KDKtHxKCwA/vZFdOp4xIPUYkr8kcuaa 7YQSdvrRh8mxJvjaNVd6n9OxqEiUjmlGSqsUmg0E6fA8Xw+BpUc3QUY37APm1NlEII2C m6RFMMKTOi4HewwVwMQF9wjz6EsbG6ctoju+i9vjsshdz88xt3P3B8gNJ0IqzvxuJ/n2 Y8IZKY8v6XI14m0m5MJS+pyt0bS91etqX+FANvh0rDGB8D/Bynd9Apk37OxurbS7m9MA YHeQ== X-Gm-Message-State: AOAM530Qyd3G20BasNZ5m0lx6PIhxF1fZxJoEeE31F0MJCx0MuO0AVPP DaIpBOZ5OBRhbxFNAnS4JLVfA7phxVMeJkjqwVx9 X-Google-Smtp-Source: ABdhPJz/spiKMlDvuZqviGpK3QGuRfLnbxYGhWF14vLgyCQE1DZyHyVO7eSRxCmF2M/Zw0+c+5FtUZVu1EXHLpa+LTWR Sender: "danielwinkler via sendgmr" <danielwinkler@danielwinkler-linux.mtv.corp.google.com> X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a5b:d09:: with SMTP id y9mr21019625ybp.258.1600467261906; Fri, 18 Sep 2020 15:14:21 -0700 (PDT) Date: Fri, 18 Sep 2020 15:13:54 -0700 In-Reply-To: <20200918221357.3436905-1-danielwinkler@google.com> Message-Id: <20200918151041.Bluez.v2.7.I187f71748b9bd93f6bf97ec4a195216109c3ea06@changeid> Mime-Version: 1.0 References: <20200918221357.3436905-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2 07/10] advertising: Query LE TX range at manager initialization From: Daniel Winkler <danielwinkler@google.com> To: luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.42 / 15.00 / 15.00 X-Rspamd-Queue-Id: 00518A0BA8 X-Rspamd-UID: 4870a2 This patch calls the new MGMT command to get controller capabilities, and parses the min and max LE tx power range when the manager is initialized. This will be used to populate a client-facing dbus entry so that the client will know the advertising capabilities of the controller before registering an advertisement. This patch is tested by manually verifying the data is parsed correctly from the MGMT response. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: None lib/mgmt.h | 8 +++++++ src/advertising.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index 56f46ce93..558452e9c 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -744,6 +744,14 @@ struct mgmt_rp_add_ext_adv_data { uint8_t instance; } __packed; +#define MGMT_CAP_LE_TX_PWR_MIN 0x0000 +#define MGMT_CAP_LE_TX_PWR_MAX 0x0001 + +#define MGMT_OP_READ_CONTROLLER_CAP 0x0056 +struct mgmt_rp_read_controller_cap { + uint8_t capabilities[0]; /* mgmt_tlv */ +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { uint16_t opcode; diff --git a/src/advertising.c b/src/advertising.c index c7deda1ad..a3e7f3d59 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -58,6 +58,8 @@ struct btd_adv_manager { uint32_t supported_flags; unsigned int instance_bitmap; bool extended_add_cmds; + int8_t min_tx_power; + int8_t max_tx_power; }; #define AD_TYPE_BROADCAST 0 @@ -1708,6 +1710,54 @@ static void tx_power_selected(uint16_t index, uint16_t length, DBUS_TYPE_INT16, &tx_power, NULL, NULL, NULL); } +static void read_controller_cap_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct btd_adv_manager *manager = user_data; + const uint8_t *ptr = param; + uint16_t offset = 0; + + /* Both capabilities we care about are stored as int8_t. If we later + * want to track other types, this structure will need to change + */ + const struct { + struct mgmt_tlv entry; + int8_t value; + } __packed * cap; + + while (offset < length) { + /* Since TLV entries can have variable length, offset tracks how + * far into the member we are, so that cap is always pointing + * to the beginning of a valid struct + */ + cap = (void *)&ptr[offset]; + switch (cap->entry.type) { + case MGMT_CAP_LE_TX_PWR_MIN: + if (cap->entry.length != + sizeof(manager->min_tx_power)) { + error("TX power had unexpected length %d", + cap->entry.length); + break; + } + memcpy(&manager->min_tx_power, &cap->value, + cap->entry.length); + break; + case MGMT_CAP_LE_TX_PWR_MAX: + if (cap->entry.length != + sizeof(manager->min_tx_power)) { + error("TX power had unexpected length %d", + cap->entry.length); + break; + } + memcpy(&manager->max_tx_power, &cap->value, + cap->entry.length); + break; + } + + offset += sizeof(cap->entry) + cap->entry.length; + } +} + static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, struct mgmt *mgmt) { @@ -1729,6 +1779,8 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, manager->supported_flags = MGMT_ADV_FLAG_LOCAL_NAME; manager->extended_add_cmds = btd_has_kernel_features(KERNEL_HAS_EXT_ADV_ADD_CMDS); + manager->min_tx_power = ADV_TX_POWER_NO_PREFERENCE; + manager->max_tx_power = ADV_TX_POWER_NO_PREFERENCE; if (!g_dbus_register_interface(btd_get_dbus_connection(), adapter_get_path(manager->adapter), @@ -1750,6 +1802,13 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, manager->mgmt_index, tx_power_selected, manager, NULL); + /* Query controller capabilities. This will be used to display valid + * advertising tx power range to the client. + */ + mgmt_send(manager->mgmt, MGMT_OP_READ_CONTROLLER_CAP, + manager->mgmt_index, 0, NULL, + read_controller_cap_complete, manager, NULL); + return manager; fail: -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MGN/FWwxZV9lRgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:15:08 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id IEGlEmwxZV8d6gEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:15:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 44A1CA0B9B; Sat, 19 Sep 2020 00:15:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726305AbgIRWOZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:14:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbgIRWOY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:14:24 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC222C0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:24 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id b127so6920322ybh.21 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=sJRM1WhxZbP9THVTVPuuP6KYJ5zZwp3ZEJNIYXffik0=; b=XlN9d5AUAtlD36K5CJ6mIjwdnbxvMlZ8hFITE5KCRxbHpvJ3N5nV333n4OiimGE9RW ijCk748AqzIUUfkDKF2K2nNB32dlXFCK1+O+YttmWeh2BH3mqliiJbt4ySps+/puICd/ 2E+bLRl407W7DV7guD531STYEjchnIV/XDhtZDj/ltKRV6GEd9qg7EiIQ4FiNAKnOFTW gB+QCfewrmHw4iiK1kwnnXLuDfvc+RR1wB3M2S5d1fbYZ4xI2y1SNACGpdDJ3eBAZfQv GuZPkHE+do69/cyKMtSxUaYHaSiC4N7I0VIHbXjtmJTCqyAD+h06L3tVCyWSGMYvOvXz EfYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=sJRM1WhxZbP9THVTVPuuP6KYJ5zZwp3ZEJNIYXffik0=; b=pfrf39lRUH/+VaVxuXCNS3iTlzFya4VtahIMR8g5BZk3/DLsV/VJlfD7wGvu1yYRbx ksh+MvHS1/lwwrO61e2clABB4FKunUbWOC3uzrcTtrcWBvSIhqRmR80YwZQkhz3pvH+3 3On7nVmPCHNzZTXw7Lp4zgdF7MNLDnU7M1tFcs1hJYFQvvcTgaKb2RJZS3TrzirR5KTo ClZ50kQvsPCUkOewPnPrrFBcMDBrwHV6mVGykDmM4zJgu9UGlAz+EPBNDy5iFq1dYm5W OQfNE2429HS2j5+/ZEeIaXBGSUf8p66uSKfllbD/RdRxahjSowg5lZXtvpUgzDoMr+XU 7LAA== X-Gm-Message-State: AOAM532o/ifnYhkRl0NZ4+JS6BS+/fpm1wP3wTmpXsmAuwtuHf/QaZE9 IkEArHexANMSZ5gEIuSZpyIdNIFQeXoTqPUX0GaB X-Google-Smtp-Source: ABdhPJwaLqVDElqHUKvwHsbykLqT6xg2J+Yk9iz8N/JJoTLUkgJ5OwaxrySP9BPBjkk2+jWTobge7fti14eV4picAv2y Sender: "danielwinkler via sendgmr" <danielwinkler@danielwinkler-linux.mtv.corp.google.com> X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:6a41:: with SMTP id f62mr24091118ybc.225.1600467263909; Fri, 18 Sep 2020 15:14:23 -0700 (PDT) Date: Fri, 18 Sep 2020 15:13:55 -0700 In-Reply-To: <20200918221357.3436905-1-danielwinkler@google.com> Message-Id: <20200918151041.Bluez.v2.8.I4e536cf2c9b6c5571b4b3800dfb8338fce8e4421@changeid> Mime-Version: 1.0 References: <20200918221357.3436905-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2 08/10] advertising: Expose SupportedCapabilities for advertising From: Daniel Winkler <danielwinkler@google.com> To: luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.36 / 15.00 / 15.00 X-Rspamd-Queue-Id: 44A1CA0B9B X-Rspamd-UID: 82290b To help our advertising clients understand the device capabilities, this patch adds a SupportedCapabilities dbus endpoint for the advertising manager. The primary reason behind this is to provide the valid LE tx power range the controller supports (populated if controller supports BT5), so a client can know the valid power range before requesting a tx power for their advertisement. I also thought it would be useful to indicate the max advertising data length and scan response length in this endpoint, since some clients will find it useful to set their advertising data (currently experimental feature) or scan response data (possible future feature) directly. This patch has been tested on Hatch (BT5 support) and Kukui (No BT5 support) chromebooks to verify that the dbus endpoint contains the correct data. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: None src/advertising.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/advertising.c b/src/advertising.c index a3e7f3d59..a736c409f 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -1632,12 +1632,46 @@ static gboolean get_supported_secondary(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_supported_cap(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct btd_adv_manager *manager = data; + DBusMessageIter dict; + int16_t min_tx_power = manager->min_tx_power; + int16_t max_tx_power = manager->max_tx_power; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, + &dict); + + if (min_tx_power != ADV_TX_POWER_NO_PREFERENCE) + dict_append_entry(&dict, "MinTxPower", DBUS_TYPE_INT16, + &min_tx_power); + + if (max_tx_power != ADV_TX_POWER_NO_PREFERENCE) + dict_append_entry(&dict, "MaxTxPower", DBUS_TYPE_INT16, + &max_tx_power); + + dict_append_entry(&dict, "MaxAdvLen", DBUS_TYPE_BYTE, + &manager->max_adv_len); + dict_append_entry(&dict, "MaxScnRspLen", DBUS_TYPE_BYTE, + &manager->max_scan_rsp_len); + + dbus_message_iter_close_container(iter, &dict); + + return TRUE; +} + static const GDBusPropertyTable properties[] = { { "ActiveInstances", "y", get_active_instances, NULL, NULL }, { "SupportedInstances", "y", get_instances, NULL, NULL }, { "SupportedIncludes", "as", get_supported_includes, NULL, NULL }, { "SupportedSecondaryChannels", "as", get_supported_secondary, NULL, secondary_exits }, + { "SupportedCapabilities", "a{sv}", get_supported_cap, NULL, NULL}, { } }; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +Lf8G3IxZV/eVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:15:14 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wJWuGXIxZV9/9wEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:15:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6F8A1A0AAE; Sat, 19 Sep 2020 00:15:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726307AbgIRWO0 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbgIRWO0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:14:26 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EF64C0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:26 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id 24so186757pgm.8 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=hBa/AroYAfFXZZcTqpW4A2vXre//hNzr99oZmnbGxrQ=; b=Pq8lYqFqir3rF0IxPvYdhbXhwXyoi4bmjIJYCOaSP9wiKYgzP4Qx0ysoqAwhGYalQa gDTrhWwlB4hIcXR/pJAv4iL3nXk49vRBRFPdAHbGUVYgf+3q6SdyzoA4uq15jQf+rH9t D1aiHFDEGhfkZ1zDVZI+ow6GKplhsG5K4RMxxvsMjEFeZMR87GfXfSYhy31ZKxrxEDxx v8vbKy6OlFqyEvxa6Lvu2Aahe/EflL+LEFFxZsBdozOa0t+08qnM0jdxclaGaRwJa+Hq 2HRAAKR5lds/Ccwk4gG+xr7Mm0mWCpkP4NHY8bXuHVVVtnx1iP8Q8y4PFyc5z91W03HJ K04A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=hBa/AroYAfFXZZcTqpW4A2vXre//hNzr99oZmnbGxrQ=; b=koQG4J0RZwhjRBy/YFWg7ZJiUShOxD8ulRxX9TiyS60fXrWmEzU2vf40u6J24m5TSZ wrSNEhLJIf2i1/TZ/qOOzyLop4/xHPTABUqzABZlJoMq3q6RsaIHE9ckMOXGQwmi/OKV uHf0jsyYHZfSynoeexPZr1vCiikgXw/i9Ve4LVxDgtnuAKqlNbVRiCv/Jyd1f59DlOsp +sHfSexbdvyD7iqfv2IegDvMNO6LlwlfH2jj5mPXlctYhN3b5piUpGtEuhhfFY9MxPA3 uDMHccnhI9ut0ZnZCBqi/cVBsbzMYk8fwqsMSv5vVx9YRAYXIoy0Y3ZfDgU1mwWiUIt1 Co1g== X-Gm-Message-State: AOAM5331IRWYgReaiVnUunmAYZbkPnzYZK9mpRKbEr6tMgGvclAoOCxL fx3g4qaDiH9+6iPFxXI8eU0btmBCt4lL4QSE9qBY X-Google-Smtp-Source: ABdhPJyzO3MizyV2jm3ejIn5Tdk/6NXv4+HhGlahhSSENSkSt6cc7dkPue0iRiX+NRQLuG/0Hwq9YnXzC7LCiyzeau3g Sender: "danielwinkler via sendgmr" <danielwinkler@danielwinkler-linux.mtv.corp.google.com> X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:aa7:9f04:0:b029:13e:d13d:a08c with SMTP id g4-20020aa79f040000b029013ed13da08cmr33080360pfr.35.1600467265920; Fri, 18 Sep 2020 15:14:25 -0700 (PDT) Date: Fri, 18 Sep 2020 15:13:56 -0700 In-Reply-To: <20200918221357.3436905-1-danielwinkler@google.com> Message-Id: <20200918151041.Bluez.v2.9.Ic9eec7749b769aa5bf73a0d8e9a31be83f232f1c@changeid> Mime-Version: 1.0 References: <20200918221357.3436905-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2 09/10] client: Add SupportedCapabilities to bluetoothctl From: Daniel Winkler <danielwinkler@google.com> To: luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6F8A1A0AAE X-Rspamd-UID: 8c2dfe This patch adds the new "SupportedCapabilities" property to the bluetoothctl "show" view. The change is tested by verifying bluetoothctl shows the desired properties. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: None client/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/main.c b/client/main.c index 2b0243308..cb8ef54ad 100644 --- a/client/main.c +++ b/client/main.c @@ -954,6 +954,7 @@ static void cmd_show(int argc, char *argv[]) print_property(adapter->ad_proxy, "SupportedInstances"); print_property(adapter->ad_proxy, "SupportedIncludes"); print_property(adapter->ad_proxy, "SupportedSecondaryChannels"); + print_property(adapter->ad_proxy, "SupportedCapabilities"); } if (adapter->adv_monitor_proxy) { -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kF43OXgxZV/eVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:15:20 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id aLz1NXgxZV9GpAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:15:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8EE88A0118; Sat, 19 Sep 2020 00:15:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726309AbgIRWO3 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:14:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbgIRWO2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:14:28 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC655C0613CE for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:28 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id z40so6901612ybi.3 for <linux-bluetooth@vger.kernel.org>; Fri, 18 Sep 2020 15:14:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=J9drwgPy+u2RdCrwGcexg5BWKopBb6gwvWAeo8EJ6zw=; b=LX5owZHSulCKx/HtzveTh6GC8JYO6n9t6YRoPjKZ4Dy8lydChwsBl5C0bG5QshekF+ VVAp+yFpdmOnfeH/BgYhJXOeamsmGw70pscql5gXqyWiKSjeVus+rRRN0dYIS4cT9Fcc eh7FH7vy9yMF2L1tXpOmtsQ5me3n5vYsXC7BTULmUYBUYIJB6Y8+StxzDmajNP/ZXpmk +V26LlDKqpRou7PL6gXqgxkwfsjoK1Wec5YgEUQ58YYGCu8kFsTTw78bipqaCLY9+0Cv Y3kTg3ImzJLgwwtJ0B9ZnS3JDbmFovaJwGvkWgkPeoa8Sce9LvhmMpbjAGG7NZRrASPN /mtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=J9drwgPy+u2RdCrwGcexg5BWKopBb6gwvWAeo8EJ6zw=; b=CInNNWqjg0+7iiCnmCWMdotxksuUdOPHQJgUkkHLvwV45O7bIcl1XF3WHZ7lerrpXQ BTzNCjWSArUNz16h7TQ8VJDSJCvGwlxGOkeFnX1fEKgB8h0SGyOU2XePU0nwTgMmdFxE 2IZhg8cSJ3XQFPUU+KpnP35r9d0WAv57ZgUAPzZ/IuBvqMgK32+spEA/KjzVec7wQWPk ZtNp+8YZ3Ay79pYHnUdukPBh4gTfJBe3bE8Ouy4h2cDiaWkk3lKqxOZy51oLd6Jgb97P xeiA/wLzQL3/19u2+EbJZD4pB+DdjDaiqNsln5yUjh65JRK+aq6DIjECnJTUB4BAiQZ+ OxyA== X-Gm-Message-State: AOAM533nwnMrYwg1pjMTLdxoSf06mBgYRLWSbD+CZJj5dRDf4vwOmxj6 X/IS+74OA1kuolDhVCi15GHxBs8AqgFimNxPxNNh X-Google-Smtp-Source: ABdhPJyEImXuHW26vYPy0cgbzxuJIP36uq3MyO4zARnZnpXVqruym//Ug1ejiDGB9CnaEchde6KCuEztUTado2E0dIEn Sender: "danielwinkler via sendgmr" <danielwinkler@danielwinkler-linux.mtv.corp.google.com> X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a25:c747:: with SMTP id w68mr20501310ybe.349.1600467267930; Fri, 18 Sep 2020 15:14:27 -0700 (PDT) Date: Fri, 18 Sep 2020 15:13:57 -0700 In-Reply-To: <20200918221357.3436905-1-danielwinkler@google.com> Message-Id: <20200918151041.Bluez.v2.10.I2884e6456c272dadb3d70a629674027f23b0393e@changeid> Mime-Version: 1.0 References: <20200918221357.3436905-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2 10/10] monitor: Add new MGMT adv commands and events to monitor From: Daniel Winkler <danielwinkler@google.com> To: luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Daniel Winkler <danielwinkler@google.com>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.81 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8EE88A0118 X-Rspamd-UID: 5bd3e7 This change adds the following to packet monitor: -Add Ext Adv Params command and response -Add Ext Adv Data command and response -Add Advertising Power Selected event This patch was manually tested by registering advertisements with various features and verifying in btmon log. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v2: None monitor/packet.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index bef134095..5d1e6868e 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -11872,6 +11872,26 @@ static void mgmt_print_adv_flags(uint32_t flags) " (0x%8.8x)", mask); } +static const struct bitfield_data mgmt_adv_params_table[] = { + { 0, "Use Duration parameter" }, + { 1, "Use Timeout parameter" }, + { 2, "Use Interval parameters" }, + { 3, "Use TX Power parameter" }, + { } +}; + +static void mgmt_print_adv_params(uint16_t flags) +{ + uint32_t mask; + + print_field("Enabled parameters: 0x%4.4x", flags); + + mask = print_bitfield(2, flags, mgmt_adv_params_table); + if (mask) + print_text(COLOR_UNKNOWN_ADV_FLAG, " Unknown advertising param" + " (0x%8.8x)", mask); +} + static void mgmt_print_store_hint(uint8_t hint) { const char *str; @@ -13163,6 +13183,53 @@ static void mgmt_set_device_flags_rsp(const void *data, uint16_t size) mgmt_print_address(data, type); } +static void mgmt_add_ext_adv_params_cmd(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + uint32_t flags = get_le32(data + 1); + uint16_t params = get_le16(data + 5); + uint16_t duration = get_le16(data + 7); + uint16_t timeout = get_le16(data + 9); + uint32_t min_interval = get_le32(data + 11); + uint32_t max_interval = get_le32(data + 15); + int8_t tx_power = get_s8(data + 19); + + print_field("Instance: %u", instance); + mgmt_print_adv_flags(flags); + mgmt_print_adv_params(params); + print_field("Duration: %u", duration); + print_field("Timeout: %u", timeout); + print_ext_slot_625("Min advertising interval", &min_interval); + print_ext_slot_625("Max advertising interval", &max_interval); + print_power_level(tx_power, NULL); +} + +static void mgmt_add_ext_adv_params_rsp(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + + print_field("Instance: %u", instance); +} + +static void mgmt_add_ext_adv_data_cmd(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + uint8_t adv_data_len = get_u8(data + 1); + uint8_t scan_rsp_len = get_u8(data + 2); + + print_field("Instance: %u", instance); + print_field("Advertising data length: %u", adv_data_len); + print_eir(data + 3, adv_data_len, false); + print_field("Scan response length: %u", scan_rsp_len); + print_eir(data + 3 + adv_data_len, scan_rsp_len, false); +} + +static void mgmt_add_ext_adv_data_rsp(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + + print_field("Instance: %u", instance); +} struct mgmt_data { uint16_t opcode; @@ -13395,6 +13462,12 @@ static const struct mgmt_data mgmt_command_table[] = { { 0x0050, "Set Device Flags", mgmt_set_device_flags_cmd, 11, true, mgmt_set_device_flags_rsp, 7, true}, + { 0x0054, "Add Ext Adv Params", + mgmt_add_ext_adv_params_cmd, 20, false, + mgmt_add_ext_adv_params_rsp, 1, true }, + { 0x0055, "Add Ext Adv Data", + mgmt_add_ext_adv_data_cmd, 3, false, + mgmt_add_ext_adv_data_rsp, 1, true }, { } }; @@ -13847,6 +13920,15 @@ static void mgmt_controller_resume_evt(const void *data, uint16_t size) mgmt_print_address(data, addr_type); } +static void mgmt_adv_power_selected_evt(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + int8_t tx_power = get_s8(data + 1); + + print_field("Instance: %u", instance); + print_power_level(tx_power, NULL); +} + static const struct mgmt_data mgmt_event_table[] = { { 0x0001, "Command Complete", mgmt_command_complete_evt, 3, false }, @@ -13932,6 +14014,8 @@ static const struct mgmt_data mgmt_event_table[] = { mgmt_controller_suspend_evt, 1, true }, { 0x002e, "Controller Resumed", mgmt_controller_resume_evt, 8, true }, + { 0x002f, "Advertising Power Selected", + mgmt_adv_power_selected_evt, 2, true }, { } }; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eGI3Ofc3ZV/eVAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sat, 19 Sep 2020 00:43:03 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id MAdvNvc3ZV9/9wEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sat, 19 Sep 2020 00:43:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3EFFA40677; Sat, 19 Sep 2020 00:42:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726097AbgIRWm4 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Fri, 18 Sep 2020 18:42:56 -0400 Received: from mga02.intel.com ([134.134.136.20]:46113 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbgIRWm4 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Fri, 18 Sep 2020 18:42:56 -0400 IronPort-SDR: 53TWkJBSrYvr7LzPu3y/Yl3n+LGRhu+DKjts2YaiqCl3jYRtUv1YN/q1/oekETyz93XeC5GAiL zYY/3TliyjnA== X-IronPort-AV: E=McAfee;i="6000,8403,9748"; a="147729531" X-IronPort-AV: E=Sophos;i="5.77,276,1596524400"; d="scan'208";a="147729531" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 15:42:48 -0700 IronPort-SDR: oozfPNG0+KHYsooF04kJO++GlpN7d1bC7DbgVyqOlZ3o/du4BHSLDQl5XqiVZDt/R5/ZUXtwtF IFlEY0mOc6Yg== X-IronPort-AV: E=Sophos;i="5.77,276,1596524400"; d="scan'208";a="340000393" Received: from hgreve-mobl.amr.corp.intel.com (HELO han1-mobl3.jf.intel.com) ([10.255.229.3]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 15:42:48 -0700 Message-ID: <3115c5127f4130fc3b304a302cc742ab97034479.camel@linux.intel.com> Subject: Re: [BlueZ v4 03/20] btio: Add SPDX License Identifier From: Tedd Ho-Jeong An <tedd.an@linux.intel.com> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Date: Fri, 18 Sep 2020 15:42:38 -0700 In-Reply-To: <CABBYNZ+8-GsnTeJyCETo-3pGHSDxxDUS_6szMvbGfS8_ngyRVA@mail.gmail.com> References: <20200918210846.37797-1-tedd.an@linux.intel.com> <20200918210846.37797-4-tedd.an@linux.intel.com> <CABBYNZ+8-GsnTeJyCETo-3pGHSDxxDUS_6szMvbGfS8_ngyRVA@mail.gmail.com> Organization: Intel Corporation Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.81 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3EFFA40677 X-Rspamd-UID: a26f0c Hi Luiz, On Fri, 2020-09-18 at 15:13 -0700, Luiz Augusto von Dentz wrote: > Hi Tedd, > > On Fri, Sep 18, 2020 at 2:17 PM <tedd.an@linux.intel.com> wrote: > > From: Tedd Ho-Jeong An <tedd.an@intel.com> > > > > This patch adds SPDX License Identifier and removes the license text. > > > > ------------------------------------- > > License COUNT > > ------------------------------------- > > GPL-2.0-or-later : 2 > > > > License: GPL-2.0-or-later > > btio/btio.h > > btio/btio.c > > --- > > btio/btio.c | 15 +-------------- > > btio/btio.h | 15 +-------------- > > 2 files changed, 2 insertions(+), 28 deletions(-) > > > > diff --git a/btio/btio.c b/btio/btio.c > > index 844d6007f..c18b6a012 100644 > > --- a/btio/btio.c > > +++ b/btio/btio.c > > @@ -1,3 +1,4 @@ > > +// SPDX-License-Identifier: GPL-2.0-or-later > > It still appears to be using C++ comment style. That's how Linux kernel uses and checkpatch.pl check based on this rule. If use "//" in header file, checkpatch willl fail with something like this: WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'src/agent.h', please use '/*' instead #16: FILE: src/agent.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #16: FILE: src/agent.h:1: +// SPDX-License-Identifier: GPL-2.0-or-later Then, we need to turn off "SPDX_LICENSE_TAG" flag from checkpatch rule... > > > /* > > * > > * BlueZ - Bluetooth protocol stack for Linux > > @@ -6,20 +7,6 @@ > > * Copyright (C) 2009-2010 Nokia Corporation > > * > > * > > - * This program is free software; you can redistribute it and/or modify > > - * it under the terms of the GNU General Public License as published by > > - * the Free Software Foundation; either version 2 of the License, or > > - * (at your option) any later version. > > - * > > - * This program is distributed in the hope that it will be useful, > > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > - * GNU General Public License for more details. > > - * > > - * You should have received a copy of the GNU General Public License > > - * along with this program; if not, write to the Free Software > > - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110- > > 1301 USA > > - * > > */ > > > > #ifdef HAVE_CONFIG_H > > diff --git a/btio/btio.h b/btio/btio.h > > index 23e0ef72b..f0259cf1d 100644 > > --- a/btio/btio.h > > +++ b/btio/btio.h > > @@ -1,3 +1,4 @@ > > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > > /* > > * > > * BlueZ - Bluetooth protocol stack for Linux > > @@ -6,20 +7,6 @@ > > * Copyright (C) 2009-2010 Nokia Corporation > > * > > * > > - * This program is free software; you can redistribute it and/or modify > > - * it under the terms of the GNU General Public License as published by > > - * the Free Software Foundation; either version 2 of the License, or > > - * (at your option) any later version. > > - * > > - * This program is distributed in the hope that it will be useful, > > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > - * GNU General Public License for more details. > > - * > > - * You should have received a copy of the GNU General Public License > > - * along with this program; if not, write to the Free Software > > - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110- > > 1301 USA > > - * > > */ > > #ifndef BT_IO_H > > #define BT_IO_H > > -- > > 2.17.1 > > > > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CCL6Kz/zZl9/mgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 20 Sep 2020 08:14:23 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MPyvKD/zZl9UawEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 20 Sep 2020 08:14:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 9E044A010E; Sun, 20 Sep 2020 08:14:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726222AbgITGOO convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 20 Sep 2020 02:14:14 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:51631 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbgITGOO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 20 Sep 2020 02:14:14 -0400 X-Greylist: delayed 412 seconds by postgrey-1.27 at vger.kernel.org; Sun, 20 Sep 2020 02:14:13 EDT Received: from marcel-macbook.fritz.box (p4fefc7f4.dip0.t-ipconnect.de [79.239.199.244]) by mail.holtmann.org (Postfix) with ESMTPSA id E4DBECECBE; Sun, 20 Sep 2020 08:21:09 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v3 3/6] Bluetooth: Interleave with allowlist scan From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200918111110.v3.3.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Date: Sun, 20 Sep 2020 08:14:11 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <0E76689A-D523-4D75-AC7E-2F835E74E08E@holtmann.org> References: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> <20200918111110.v3.3.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> To: Howard Chung <howardchung@google.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.65 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9E044A010E X-Rspamd-UID: de2b2e Hi Howard, > This patch implements the interleaving between allowlist scan and > no-filter scan. It'll be used to save power when at least one monitor is > registered and at least one pending connection or one device to be > scanned for. > > The durations of the allowlist scan and the no-filter scan are > controlled by MGMT command: Set Default System Configuration. The > default values are set randomly for now. > > Signed-off-by: Howard Chung <howardchung@google.com> > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > --- > > (no changes since v2) > > Changes in v2: > - remove 'case 0x001c' in mgmt_config.c > > include/net/bluetooth/hci_core.h | 10 +++ > net/bluetooth/hci_core.c | 4 + > net/bluetooth/hci_request.c | 137 +++++++++++++++++++++++++++++-- > net/bluetooth/mgmt_config.c | 12 +++ > 4 files changed, 155 insertions(+), 8 deletions(-) > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h > index 9873e1c8cd163..179350f869fdb 100644 > --- a/include/net/bluetooth/hci_core.h > +++ b/include/net/bluetooth/hci_core.h > @@ -361,6 +361,8 @@ struct hci_dev { > __u8 ssp_debug_mode; > __u8 hw_error_code; > __u32 clock; > + __u16 advmon_allowlist_duration; > + __u16 advmon_no_filter_duration; > > __u16 devid_source; > __u16 devid_vendor; > @@ -542,6 +544,14 @@ struct hci_dev { > struct delayed_work rpa_expired; > bdaddr_t rpa; > > + enum { > + ADV_MONITOR_SCAN_NONE, > + ADV_MONITOR_SCAN_NO_FILTER, > + ADV_MONITOR_SCAN_ALLOWLIST > + } adv_monitor_scan_state; > + > + struct delayed_work interleave_adv_monitor_scan; > + > #if IS_ENABLED(CONFIG_BT_LEDS) > struct led_trigger *power_led; > #endif > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index f30a1f5950e15..6c8850149265a 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -3592,6 +3592,10 @@ struct hci_dev *hci_alloc_dev(void) > hdev->cur_adv_instance = 0x00; > hdev->adv_instance_timeout = 0; > > + /* The default values will be chosen in the future */ > + hdev->advmon_allowlist_duration = 300; > + hdev->advmon_no_filter_duration = 500; > + > hdev->sniff_max_interval = 800; > hdev->sniff_min_interval = 80; > > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > index d2b06f5c93804..89443b48d90ce 100644 > --- a/net/bluetooth/hci_request.c > +++ b/net/bluetooth/hci_request.c > @@ -378,6 +378,57 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable) > hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type); > } > > +static void start_interleave_scan(struct hci_dev *hdev) > +{ > + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; > + queue_delayed_work(hdev->req_workqueue, > + &hdev->interleave_adv_monitor_scan, 0); > +} > + > +static bool is_interleave_scanning(struct hci_dev *hdev) > +{ > + return hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_NONE; > +} > + > +static void cancel_interleave_scan(struct hci_dev *hdev) > +{ > + bt_dev_dbg(hdev, "%s cancelling interleave scan", hdev->name); > + > + cancel_delayed_work_sync(&hdev->interleave_adv_monitor_scan); > + > + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NONE; > +} > + > +/* Return true if interleave_scan is running after exiting this function, > + * otherwise, return false > + */ > +static bool update_adv_monitor_scan_state(struct hci_dev *hdev) > +{ > + if (!hci_is_adv_monitoring(hdev) || > + (list_empty(&hdev->pend_le_conns) && > + list_empty(&hdev->pend_le_reports))) { > + if (is_interleave_scanning(hdev)) { > + /* If the interleave condition no longer holds, cancel > + * the existed interleave scan. > + */ > + cancel_interleave_scan(hdev); > + } > + return false; > + } > + > + if (!is_interleave_scanning(hdev)) { > + /* If there is at least one ADV monitors and one pending LE > + * connection or one device to be scanned for, we should > + * alternate between allowlist scan and one without any filters > + * to save power. > + */ > + start_interleave_scan(hdev); > + bt_dev_dbg(hdev, "%s starting interleave scan", hdev->name); > + } > + > + return true; > +} > + > /* This function controls the background scanning based on hdev->pend_le_conns > * list. If there are pending LE connection we start the background scanning, > * otherwise we stop it. > @@ -449,9 +500,11 @@ static void __hci_update_background_scan(struct hci_request *req) > if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) > hci_req_add_le_scan_disable(req, false); > > - hci_req_add_le_passive_scan(req); > - > - BT_DBG("%s starting background scanning", hdev->name); > + if (!update_adv_monitor_scan_state(hdev)) { > + hci_req_add_le_passive_scan(req); > + bt_dev_dbg(hdev, "%s starting background scanning", > + hdev->name); > + } > } > } > > @@ -844,12 +897,17 @@ static u8 update_white_list(struct hci_request *req) > return 0x00; > } > > - /* Once the controller offloading of advertisement monitor is in place, > - * the if condition should include the support of MSFT extension > - * support. If suspend is ongoing, whitelist should be the default to > - * prevent waking by random advertisements. > + /* Use the allowlist unless the following conditions are all true: > + * - We are not currently suspending > + * - There are 1 or more ADV monitors registered > + * - Interleaved scanning is not currently using the allowlist > + * > + * Once the controller offloading of advertisement monitor is in place, > + * the above condition should include the support of MSFT extension > + * support. > */ > - if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended) > + if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended && > + hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_ALLOWLIST) > return 0x00; > > /* Select filter policy to use white list */ > @@ -1002,6 +1060,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) > &own_addr_type)) > return; > > + bt_dev_dbg(hdev, "interleave state %d", hdev->adv_monitor_scan_state); > /* Adding or removing entries from the white list must > * happen before enabling scanning. The controller does > * not allow white list modification while scanning. > @@ -1871,6 +1930,64 @@ static void adv_timeout_expire(struct work_struct *work) > hci_dev_unlock(hdev); > } > > +static int add_le_interleave_adv_monitor_scan(struct hci_request *req, > + unsigned long opt) > +{ > + struct hci_dev *hdev = req->hdev; > + int ret = 0; > + > + hci_dev_lock(hdev); > + > + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) > + hci_req_add_le_scan_disable(req, false); > + hci_req_add_le_passive_scan(req); > + > + switch (hdev->adv_monitor_scan_state) { > + case ADV_MONITOR_SCAN_ALLOWLIST: > + bt_dev_dbg(hdev, "next state: allowlist"); > + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; > + break; > + case ADV_MONITOR_SCAN_NO_FILTER: > + bt_dev_dbg(hdev, "next state: no filter"); > + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_ALLOWLIST; > + break; > + case ADV_MONITOR_SCAN_NONE: > + default: > + BT_ERR("unexpected error"); > + ret = -1; > + } > + > + hci_dev_unlock(hdev); > + > + return ret; > +} > + > +static void interleave_adv_monitor_scan_work(struct work_struct *work) > +{ > + struct hci_dev *hdev = container_of(work, struct hci_dev, > + interleave_adv_monitor_scan.work); > + u8 status; > + unsigned long timeout; > + > + if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_ALLOWLIST) { > + timeout = msecs_to_jiffies(hdev->advmon_allowlist_duration); > + } else if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_NO_FILTER) { > + timeout = msecs_to_jiffies(hdev->advmon_no_filter_duration); > + } else { > + bt_dev_err(hdev, "unexpected error"); > + return; > + } > + > + hci_req_sync(hdev, add_le_interleave_adv_monitor_scan, 0, > + HCI_CMD_TIMEOUT, &status); > + > + /* Don't continue interleaving if it was canceled */ > + if (is_interleave_scanning(hdev)) { > + queue_delayed_work(hdev->req_workqueue, > + &hdev->interleave_adv_monitor_scan, timeout); > + } > +} > + > int hci_get_random_address(struct hci_dev *hdev, bool require_privacy, > bool use_rpa, struct adv_info *adv_instance, > u8 *own_addr_type, bdaddr_t *rand_addr) > @@ -3292,6 +3409,8 @@ void hci_request_setup(struct hci_dev *hdev) > INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); > INIT_DELAYED_WORK(&hdev->le_scan_restart, le_scan_restart_work); > INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire); > + INIT_DELAYED_WORK(&hdev->interleave_adv_monitor_scan, > + interleave_adv_monitor_scan_work); > } > > void hci_request_cancel_all(struct hci_dev *hdev) > @@ -3311,4 +3430,6 @@ void hci_request_cancel_all(struct hci_dev *hdev) > cancel_delayed_work_sync(&hdev->adv_instance_expire); > hdev->adv_instance_timeout = 0; > } > + > + cancel_interleave_scan(hdev); > } > diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c > index b30b571f8caf8..1802f7023158c 100644 > --- a/net/bluetooth/mgmt_config.c > +++ b/net/bluetooth/mgmt_config.c > @@ -67,6 +67,8 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > HDEV_PARAM_U16(0x001a, le_supv_timeout), > HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b, > def_le_autoconnect_timeout), > + HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), > + HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), > }; > struct mgmt_rp_read_def_system_config *rp = (void *)params; > > @@ -138,6 +140,8 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > case 0x0019: > case 0x001a: > case 0x001b: > + case 0x001d: > + case 0x001e: > if (len != sizeof(u16)) { > bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", > len, sizeof(u16), type); > @@ -251,6 +255,14 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > hdev->def_le_autoconnect_timeout = > msecs_to_jiffies(TLV_GET_LE16(buffer)); > break; > + case 0x0001d: > + hdev->advmon_allowlist_duration = > + TLV_GET_LE16(buffer); > + break; > + case 0x0001e: > + hdev->advmon_no_filter_duration = > + TLV_GET_LE16(buffer); > + break; in these case break the 80 chars limit. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yHpfA23zZl9/mgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 20 Sep 2020 08:15:09 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id GFsFAG3zZl9LpAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 20 Sep 2020 08:15:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 7F1A2A010E; Sun, 20 Sep 2020 08:15:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726250AbgITGOy (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 20 Sep 2020 02:14:54 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:60514 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbgITGOy (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 20 Sep 2020 02:14:54 -0400 X-Greylist: delayed 317 seconds by postgrey-1.27 at vger.kernel.org; Sun, 20 Sep 2020 02:14:53 EDT Received: from marcel-macbook.fritz.box (p4fefc7f4.dip0.t-ipconnect.de [79.239.199.244]) by mail.holtmann.org (Postfix) with ESMTPSA id BC368CECC3; Sun, 20 Sep 2020 08:21:49 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v3 1/6] Bluetooth: Update Adv monitor count upon removal From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Date: Sun, 20 Sep 2020 08:14:52 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, Miao-chen Chou <mcchou@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, open list <linux-kernel@vger.kernel.org>, netdev@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <AEC53846-5041-4292-8958-4AC1CAAEBE23@holtmann.org> References: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> To: Howard Chung <howardchung@google.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.76 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7F1A2A010E X-Rspamd-UID: 17438d Hi Howard, > This fixes the count of Adv monitor upon monitor removal. > > The following test was performed. > - Start two btmgmt consoles, issue a btmgmt advmon-remove command on one > console and observe a MGMT_EV_ADV_MONITOR_REMOVED event on the other. > > Signed-off-by: Miao-chen Chou <mcchou@chromium.org> > Signed-off-by: Howard Chung <howardchung@google.com> > Reviewed-by: Alain Michaud <alainm@chromium.org> > --- > > Changes in v3: > - Remove 'Bluez' prefix > > Changes in v2: > - delete 'case 0x001c' in mgmt_config.c > > net/bluetooth/hci_core.c | 2 ++ > 1 file changed, 2 insertions(+) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mO5FLn7zZl9/mgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 20 Sep 2020 08:15:26 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id wHgsLH7zZl+LAwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 20 Sep 2020 08:15:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 76836A0BD9; Sun, 20 Sep 2020 08:15:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726306AbgITGPC (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 20 Sep 2020 02:15:02 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:36522 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbgITGPB (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 20 Sep 2020 02:15:01 -0400 Received: from marcel-macbook.fritz.box (p4fefc7f4.dip0.t-ipconnect.de [79.239.199.244]) by mail.holtmann.org (Postfix) with ESMTPSA id 9727CCECC4; Sun, 20 Sep 2020 08:21:57 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v3 2/6] Bluetooth: Set scan parameters for ADV Monitor From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200918111110.v3.2.I8aafface41460f81241717da0498419a533bd165@changeid> Date: Sun, 20 Sep 2020 08:14:59 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, Miao-chen Chou <mcchou@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, alainm@chromium.org, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <A78820F2-CA17-452A-88E4-0BF670BE1BB4@holtmann.org> References: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> <20200918111110.v3.2.I8aafface41460f81241717da0498419a533bd165@changeid> To: Howard Chung <howardchung@google.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.28 / 15.00 / 15.00 X-Rspamd-Queue-Id: 76836A0BD9 X-Rspamd-UID: 077c45 Hi Howard, > Set scan parameters when there is at least one Advertisement monitor. > > Signed-off-by: Howard Chung <howardchung@google.com> > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > --- > > (no changes since v1) > > net/bluetooth/hci_request.c | 3 +++ > 1 file changed, 3 insertions(+) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6MssAfvzZl9/mgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 20 Sep 2020 08:17:31 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id KNJmOvrzZl+LAwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 20 Sep 2020 08:17:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6D64A4096E; Sun, 20 Sep 2020 08:17:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726280AbgITGRR convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 20 Sep 2020 02:17:17 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:58571 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbgITGRP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 20 Sep 2020 02:17:15 -0400 Received: from marcel-macbook.fritz.box (p4fefc7f4.dip0.t-ipconnect.de [79.239.199.244]) by mail.holtmann.org (Postfix) with ESMTPSA id CDD6CCEC92; Sun, 20 Sep 2020 08:14:17 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [Bluez PATCH v2 02/10] doc/mgmt-api: Add new MGMT interfaces to mgmt-api From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200918151041.Bluez.v2.2.If15d3d09724ded2bcc7240d29f6888f2ad12e723@changeid> Date: Sun, 20 Sep 2020 08:07:19 +0200 Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Transfer-Encoding: 8BIT Message-Id: <0E891E36-FA71-414C-9E60-596D253A82A5@holtmann.org> References: <20200918221357.3436905-1-danielwinkler@google.com> <20200918151041.Bluez.v2.2.If15d3d09724ded2bcc7240d29f6888f2ad12e723@changeid> To: Daniel Winkler <danielwinkler@google.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.52 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6D64A4096E X-Rspamd-UID: 4cf94c Hi Daniel, > This patch adds the following to mgmt-api: > - Add Extended Advertising Parameters Command > - Add Extended Advertising Data Command > - Read Controller Capabilities Command > - Advertisement Tx Power Selected Event > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > Reviewed-by: Alain Michaud <alainm@chromium.org> > --- > > Changes in v2: > - Removed extra space in Add Extended Advertising Parameters API > > doc/mgmt-api.txt | 242 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 242 insertions(+) > > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt > index ca0d38469..62f976a11 100644 > --- a/doc/mgmt-api.txt > +++ b/doc/mgmt-api.txt > @@ -3574,6 +3574,234 @@ Remove Advertisement Monitor Command > Busy > > > +Add Extended Advertising Parameters Command > +=========================================== > + > + Command Code: 0x0054 > + Controller Index: <controller id> > + Command Parameters: Instance (1 Octet) > + Flags (4 Octets) > + Params (2 Octets) > + Duration (2 Octets) > + Timeout (2 Octets) > + MinInterval (4 Octets) > + MaxInterval (4 Octets) > + TxPower (1 Octet) > + Return Parameters: Instance (1 Octet) didn’t you also want to return the selected TxPower? We then also have to agree to allow this command only when the controller is powered. > + > + This command is used to configure the parameters for Bluetooth Low > + Energy advertising instance. This command is expected to be followed > + by an Add Extended Advertising Data command to complete and enable > + the advertising instance. > + > + Added advertising information with this command will not be visible > + immediately if advertising is enabled via the Set Advertising > + command. The usage of the Set Advertising command takes precedence > + over this command. Instance information is stored and will be > + advertised once advertising via Set Advertising has been disabled. > + > + The Instance identifier is a value between 1 and the number of > + supported instances. The value 0 is reserved. > + > + With the Flags value the type of advertising is controlled and > + the following flags are defined: > + > + 0 Switch into Connectable mode > + 1 Advertise as Discoverable > + 2 Advertise as Limited Discoverable > + 3 Add Flags field to Adv_Data > + 4 Add TX Power field to Adv_Data > + 5 Add Appearance field to Scan_Rsp > + 6 Add Local Name in Scan_Rsp > + 7 Secondary Channel with LE 1M > + 8 Secondary Channel with LE 2M > + 9 Secondary Channel with LE Coded > + > + When the connectable flag is set, then the controller will use > + undirected connectable advertising. The value of the connectable > + setting can be overwritten this way. This is useful to switch a > + controller into connectable mode only for LE operation. This is > + similar to the mode 0x02 from the Set Advertising command. > + > + When the connectable flag is not set, then the controller will > + use advertising based on the connectable setting. When using > + non-connectable or scannable advertising, the controller will > + be programmed with a non-resolvable random address. When the > + system is connectable, then the identity address or resolvable > + private address will be used. > + > + Using the connectable flag is useful for peripheral mode support > + where BR/EDR (and/or LE) is controlled by Add Device. This allows > + making the peripheral connectable without having to interfere > + with the global connectable setting. > + > + Secondary channel flags can be used to advertise in secondary > + channel with the corresponding PHYs. These flag bits are mutually > + exclusive and setting multiple will result in Invalid Parameter > + error. Choosing either LE 1M or LE 2M will result in using > + extended advertising on the primary channel with LE 1M and the > + respectively LE 1M or LE 2M on the secondary channel. Choosing > + LE Coded will result in using extended advertising on the primary > + and secondary channels with LE Coded. Choosing none of these flags > + will result in legacy advertising. > + > + To allow future parameters to be optionally extended in this structure, > + the Params member is used to specify which of the structure fields were > + purposefully set by the caller. Unspecified parameters will be given > + sensible defaults by the kernel before the advertisement is registered. > + The Params bit field uses the following bit to parameter relationship: > + > + 0 The Duration parameter should be used > + 1 The Timeout parameter should be used > + 2 The Interval parameters should be used > + 3 The Tx Power parameter should be used > + > + The Duration parameter configures the length of an Instance. The > + value is in seconds. The default is 2 seconds. > + > + If only one advertising Instance has been added, then the Duration > + value will be ignored. It only applies for the case where multiple > + Instances are configured. In that case every Instance will be > + available for the Duration time and after that it switches to > + the next one. This is a simple round-robin based approach. > + > + The Timeout parameter configures the life-time of an Instance. In > + case the value 0 is used it indicates no expiration time. If a > + timeout value is provided, then the advertising Instance will be > + automatically removed when the timeout passes. The value for the > + timeout is in seconds. Powering down a controller will invalidate > + all advertising Instances and it is not possible to add a new > + Instance with a timeout when the controller is powered down. > + > + When a Timeout is provided, then the Duration subtracts from > + the actual Timeout value of that Instance. For example an Instance > + with Timeout of 5 and Duration of 2 will be scheduled exactly 3 > + times, twice with 2 seconds and once with one second. Other > + Instances have no influence on the Timeout. > + > + MinInterval and MaxInterval define the minimum and maximum advertising > + intervals, with units as number of .625ms advertising slots. The Max > + interval is expected to be greater than or equal to the Min interval, > + and both must have values in the range [0x000020, 0xFFFFFF]. If either > + condition is not met, the registration will fail. > + > + The provided Tx Power parameter will only be used if the controller > + supports it, which can be determined by the presence of the > + CanSetTxPower member of the Read Advertising Features command. > + > + The acceptable range for requested Tx Power is defined in the spec > + (Version 5.2 | Vol 4, Part E, page 2585) to be [-127, +20] dBm, and the > + controller will select a power value up to the requested one. The > + transmission power selected by the controller is not guaranteed > + to match the requested one, but the caller can determine the power > + chosen by the controller by listening for the Tx Power Selected MGMT > + event that follows this command. If the requested Tx Power is outside > + the valid range, the registration will fail. > + > + Re-adding an already existing instance (i.e. issuing the Add Extended > + Advertising Parameters command with an Instance identifier of an > + existing instance) will update that instance's configuration. > + > + An instance being added or changed while another instance is > + being advertised will not be visible immediately but only when > + the new/changed instance is being scheduled by the round robin > + advertising algorithm. > + > + Changes to an instance that is currently being advertised will > + cancel that instance and switch to the next instance. The changes > + will be visible the next time the instance is scheduled for > + advertising. In case a single instance is active, this means > + that changes will be visible right away. > + > + LE must already be enabled, and the controller must be powered, > + otherwise a "rejected" status will be returned. > + > + This command generates a Command Complete event on success or a > + Command Status event on failure. > + > + Possible errors: Failed > + Rejected > + Not Supported > + Invalid Parameters > + Busy > + > + > +Add Extended Advertising Data Command > +===================================== > + > + Command Code: 0x0055 > + Controller Index: <controller id> > + Command Parameters: Instance (1 Octet) > + Advertising Data Length (1 Octet) > + Scan Response Length (1 Octet) > + Advertising Data (0-255 Octets) > + Scan Response (0-255 Octets) > + Return Parameters: Instance (1 Octet) > + > + The Add Extended Advertising Data command is used to update the > + advertising data of an existing advertising instance known to the > + kernel. It is expected to be called after an Add Extended Advertising > + Parameters command, as part of the advertisement registration > + process. > + > + If extended advertising is available, this call will initiate HCI > + commands to set the instance's advertising data, set scan response > + data, and then enable the instance. If extended advertising is > + unavailable, the advertising instance structure maintained in kernel > + will have its advertising data and scan response updated, and the > + instance will either be scheduled immediately or left in the queue > + for later advertisement as part of round-robin advertisement rotation > + in software. > + > + If Scan_Rsp_Len is zero and the flags defined in Add Extended > + Advertising Parameters command do not have connectable flag set and > + the global connectable setting is off, then non-connectable > + advertising is used. If Scan_Rsp_Len is larger than zero and > + connectable flag is not set and the global advertising is off, > + then scannable advertising is used. This small difference is > + supported to provide less air traffic for devices implementing > + broadcaster role. > + > + If the Instance provided does not match a known instance, or if the > + provided advertising data or scan response are in an unrecognized > + format, an "Invalid Parameters" status will be returned. > + > + If a "Set LE" or Advertising command is still in progress, a "Busy" > + status will be returned. > + > + If the controller is not powered, a "rejected" status will be returned. > + > + This command generates a Command Complete event on success or a > + Command Status event on failure. > + > + Possible errors: Failed > + Rejected > + Invalid Parameters > + Busy > + > + > +Read Controller Capabilities Command > +==================================== > + > + Command Code: 0x0056 > + Controller Index: <controller id> > + Command Parameters: > + Return Parameters: Parameter1 { > + Capability_Tag (2 Octet) > + Value_Length (1 Octet) > + Value (0-255 Octets) > + } > + Parameter2 { } > + ... > + > + This command is used to read a list of controller capabilities. > + > + Currently defined Capability_Tag values are: > + > + 0x0000 Minimum Supported LE Tx Power (dBm) > + 0x0001 Maximum Supported LE Tx Power (dBm) > + > + I was thinking we rename Read Security Information Command and also return these values there. I think it is a bit of waste to introduce yet another command to return controller capabilities. > Command Complete Event > ====================== > > @@ -4577,3 +4805,17 @@ Advertisement Monitor Removed Event > > The event will only be sent to management sockets other than the > one through which the command was sent. > + > + > +Advertisement Tx Power Selected Event > +=================================== > + > + Event Code: 0x002d > + Controller Index: <controller id> > + Event Parameters: Instance (1 Octet) > + TxPower (1 Octet) > + > + This event indicates that the controller selected a transmission > + power for an advertising instance. The event is emitted on platforms > + that support extended advertising after an Add Extended Advertising > + Parameters command is submitted. I would rather return the value right away and only allow it when powered on. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oNqwH//zZl9hqgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 20 Sep 2020 08:17:35 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id oA9SHP/zZl92lgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 20 Sep 2020 08:17:35 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 20CF140971; Sun, 20 Sep 2020 08:17:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726327AbgITGRP convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 20 Sep 2020 02:17:15 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:38841 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbgITGRP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 20 Sep 2020 02:17:15 -0400 Received: from marcel-macbook.fritz.box (p4fefc7f4.dip0.t-ipconnect.de [79.239.199.244]) by mail.holtmann.org (Postfix) with ESMTPSA id 820EECECA3; Sun, 20 Sep 2020 08:16:32 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: Fix the vulnerable issue on enc key size From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200918110223.GA10235@laptop-alex> Date: Sun, 20 Sep 2020 08:09:34 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, open list <linux-kernel@vger.kernel.org>, Max Chou <max.chou@realtek.com> Content-Transfer-Encoding: 8BIT Message-Id: <2E345B0D-5412-4DC1-9E22-452939DD7D2B@holtmann.org> References: <20200918110223.GA10235@laptop-alex> To: Alex Lu <alex_lu@realsil.com.cn> X-Mailer: Apple Mail (2.3608.120.23.2.1) Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.72 / 15.00 / 15.00 X-Rspamd-Queue-Id: 20CF140971 X-Rspamd-UID: 5efc7c Hi Alex, > When someone attacks the service provider, it creates connection, > authenticates. Then it requests key size of one byte and it identifies > the key with brute force methods. > > After l2cap info req/resp exchange is complete. the attacker sends l2cap > connect with specific PSM. > > In above procedure, there is no chance for the service provider to check > the encryption key size before l2cap_connect(). Because the state of > l2cap chan in conn->chan_l is BT_LISTEN, there is no l2cap chan with the > state of BT_CONNECT or BT_CONNECT2. > > So service provider should check the encryption key size in > l2cap_connect() > > Signed-off-by: Alex Lu <alex_lu@realsil.com.cn> > --- > net/bluetooth/l2cap_core.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > index ade83e224567..63df961d402d 100644 > --- a/net/bluetooth/l2cap_core.c > +++ b/net/bluetooth/l2cap_core.c > @@ -4150,6 +4150,13 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn, > > if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) { > if (l2cap_chan_check_security(chan, false)) { > + if (!l2cap_check_enc_key_size(conn->hcon)) { > + l2cap_state_change(chan, BT_DISCONN); > + __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); > + result = L2CAP_CR_SEC_BLOCK; > + status = L2CAP_CS_NO_INFO; > + goto response; > + } > if (test_bit(FLAG_DEFER_SETUP, &chan->flags)) { > l2cap_state_change(chan, BT_CONNECT2); > result = L2CAP_CR_PEND; I am not following what you are trying to fix here. Can you show this with a btmon trace from an attacking device? Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8EUAOB30Zl+dpAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 20 Sep 2020 08:18:05 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id SDecNB30Zl9LpAAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 20 Sep 2020 08:18:05 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 62337A0BE4; Sun, 20 Sep 2020 08:18:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726306AbgITGRs (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 20 Sep 2020 02:17:48 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:47918 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbgITGRs (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 20 Sep 2020 02:17:48 -0400 Received: from marcel-macbook.fritz.box (p4fefc7f4.dip0.t-ipconnect.de [79.239.199.244]) by mail.holtmann.org (Postfix) with ESMTPSA id B8E5ACEC92; Sun, 20 Sep 2020 08:24:44 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v1] Bluetooth: btusb: Enable wide band speech support for BTUSB_QCA_ROME From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200917130923.15237-1-rjliao@codeaurora.org> Date: Sun, 20 Sep 2020 08:17:46 +0200 Cc: Johan Hedberg <johan.hedberg@gmail.com>, open list <linux-kernel@vger.kernel.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, linux-arm-msm@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <6D9F38F1-D350-4D32-8D30-A316AD1A9400@holtmann.org> References: <20200917130923.15237-1-rjliao@codeaurora.org> To: Rocky Liao <rjliao@codeaurora.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.55 / 15.00 / 15.00 X-Rspamd-Queue-Id: 62337A0BE4 X-Rspamd-UID: 44988e Hi Rocky, > QCA Rome supports wide band speech, this patch enables the wide band > speech support by set the BTUSB_WIDEBAND_SPEECH flag. > > Signed-off-by: Rocky Liao <rjliao@codeaurora.org> > --- > drivers/bluetooth/btusb.c | 54 ++++++++++++++++++++++++++------------- > 1 file changed, 36 insertions(+), 18 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eA+QKVP0Zl9/mgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 20 Sep 2020 08:18:59 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2DdvJlP0Zl/SxQEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 20 Sep 2020 08:18:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6A68740973; Sun, 20 Sep 2020 08:18:55 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726249AbgITGSr (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 20 Sep 2020 02:18:47 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:36698 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbgITGSr (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 20 Sep 2020 02:18:47 -0400 Received: from marcel-macbook.fritz.box (p4fefc7f4.dip0.t-ipconnect.de [79.239.199.244]) by mail.holtmann.org (Postfix) with ESMTPSA id 1E7B8CECA3; Sun, 20 Sep 2020 08:25:43 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v1] Bluetooth: Check for encryption key size on connect From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200917181031.v1.1.I67a8b8cd4def8166970ca37109db46d731b62bb6@changeid> Date: Sun, 20 Sep 2020 08:18:45 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <428C3B9F-1C03-4BD9-A1AF-21D2F99A7F3C@holtmann.org> References: <20200917181031.v1.1.I67a8b8cd4def8166970ca37109db46d731b62bb6@changeid> To: Archie Pusaka <apusaka@google.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.37 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6A68740973 X-Rspamd-UID: 3b846f Hi Archie, > When receiving connection, we only check whether the link has been > encrypted, but not the encryption key size of the link. > > This patch adds check for encryption key size, and reject L2CAP > connection which size is below the specified threshold (default 7) > with security block. please include btmon trace in the commit message to demonstrate this. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cPmkDzD1Zl+dpAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Sun, 20 Sep 2020 08:22:40 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QM0SDTD1Zl/MLwEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Sun, 20 Sep 2020 08:22:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id BC52F408AE; Sun, 20 Sep 2020 08:22:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726314AbgITGWd (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 20 Sep 2020 02:22:33 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:32788 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbgITGWd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 20 Sep 2020 02:22:33 -0400 Received: from marcel-macbook.fritz.box (p4fefc7f4.dip0.t-ipconnect.de [79.239.199.244]) by mail.holtmann.org (Postfix) with ESMTPSA id 86496CECBE; Sun, 20 Sep 2020 08:29:29 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v2] Bluetooth: Fix auto-creation of hci_conn at Conn Complete event From: Marcel Holtmann <marcel@holtmann.org> In-Reply-To: <20200814190909.361764-1-sonnysasaka@chromium.org> Date: Sun, 20 Sep 2020 08:22:31 +0200 Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Transfer-Encoding: 7bit Message-Id: <AD524EC5-2AC9-4B3A-ACC9-E896E5EFCB2A@holtmann.org> References: <20200814190909.361764-1-sonnysasaka@chromium.org> To: Sonny Sasaka <sonnysasaka@chromium.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.17 / 15.00 / 15.00 X-Rspamd-Queue-Id: BC52F408AE X-Rspamd-UID: 446748 Hi Sonny, > Currently the code auto-creates hci_conn only if the remote address has > been discovered before. This may not be the case. For example, the > remote device may trigger connection after reboot at already-paired > state so there is no inquiry result found, but it is still correct to > create the hci_conn when Connection Complete event is received. > > A better guard is to check against bredr allowlist. Devices in the > allowlist have been given permission to auto-connect. > > Fixes: 4f40afc6c764 ("Bluetooth: Handle BR/EDR devices during suspend") > Signed-off-by: Sonny Sasaka <sonnysasaka@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > > --- > net/bluetooth/hci_event.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wJclFEAYaF8PuQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 05:04:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id KFe1EUAYaF+m8gEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 05:04:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7457940675; Mon, 21 Sep 2020 05:04:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726324AbgIUDEN (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Sun, 20 Sep 2020 23:04:13 -0400 Received: from mga05.intel.com ([192.55.52.43]:54918 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbgIUDEM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Sun, 20 Sep 2020 23:04:12 -0400 IronPort-SDR: 2Zn0NidZr0NStf0tudzIDywcWEAAhHiKYjxF555Ql0OuiVlIJA3LyMhIuxqWHtPoN7HID0spP+ 6eTPy6lrMPwg== X-IronPort-AV: E=McAfee;i="6000,8403,9750"; a="245134170" X-IronPort-AV: E=Sophos;i="5.77,285,1596524400"; d="scan'208";a="245134170" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2020 20:04:09 -0700 IronPort-SDR: Lv9dkA8TM4MP09WVuCpgMZDpZzrunECkqyGpZNixutWK0o38IEv+DiI7dU/e85WFvPIVNu3SiO dgUPtXPksyTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,285,1596524400"; d="scan'208";a="321540740" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga002.jf.intel.com with ESMTP; 20 Sep 2020 20:04:08 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 20 Sep 2020 20:03:58 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 20 Sep 2020 20:03:58 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.171) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Sun, 20 Sep 2020 20:03:55 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZDd9vn17WNUQGcush3w0lrNqtJUSq2lyd1TW02m+JRg3wbp0Vz+OO8WZqh7z3hFJJUyuTFuX9D6uUvPCLSMpeRf/2wspEqeaPLyAIyTIfpbuY02no+BENz/JdURW0Ve0wYHFOgJwgGANfpj//Kj3QjtY3TrmFP3BOuK/TGx8CKYSBV+R00543IEQmU0MysAJzC1ZZpxVefm7ZCh+ozHe6W7jX4O5KdoRp1Kl6W+Fmd5S9gCONP9wDaVFAt+RQmkx+CJJdpwIuR6LPrSqOmvgdsKe4WEtCL7jhk5DQ4xdrhpGuipxju8bdTWUPKdnoP1YEQ6KAlMbuyy+GOUJ+HRVEg== 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-SenderADCheck; bh=xUaSbaAN//PPpfk0fApwPF0suG0Sf+jA4NmUJeeVnrE=; b=fuqdN8e1XgB6ex4zajzWFN8UOhivdV6omI/0dbT/yrec4iYBrzVZG5JcnMCV798j3nxf25XNobigtBEZLPMkAK+jhORiKDoscZrTF/IBE58bkMqB00IUwMkxYpR5+s+ODghvXecp5x1zgqDrYdMyiFzNh2+0GswqEtCWnpUrwGoQOi+H9HyHQ2CYHrXACvGDh6FDM+duv1UwfUAsbl1xI3t2aOvtbTMPBH96GJgmjUtNEZ/ir28OOZD4WkqzT9taU+qfKF8RX/SNB7hR1O1q9Kl+USZtmSuACi/NRQCvH7HCUGS4ErXrySKilY5kdeKEOArVuoG1F4wUOs2fu+YOUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xUaSbaAN//PPpfk0fApwPF0suG0Sf+jA4NmUJeeVnrE=; b=aCCVb2N5XBFL6g1Dk2LznXmpFCZpouw78D6EBdWaL2JhRQa4rllL3YKB00I98ClSsOP4QRGAYuaPx47gNMolOnuCch+9HKarYVZ0d5i7oXn/gUGIimr7w78BXOBW40OeR8CyTLeNLMIiLEpMIGCI8X/FVfwbgFj7CyslubfOxWw= Received: from BYAPR11MB3141.namprd11.prod.outlook.com (2603:10b6:a03:8d::13) by BYAPR11MB3494.namprd11.prod.outlook.com (2603:10b6:a03:86::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.19; Mon, 21 Sep 2020 03:03:54 +0000 Received: from BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::c8d8:a3c5:9876:d589]) by BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::c8d8:a3c5:9876:d589%7]) with mapi id 15.20.3391.019; Mon, 21 Sep 2020 03:03:54 +0000 From: "K, Kiran" <kiran.k@intel.com> To: Dan Carpenter <dan.carpenter@oracle.com>, "kiraank@gmail.com" <kiraank@gmail.com> CC: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Srivatsa, Ravishankar" <ravishankar.srivatsa@intel.com>, "Tumkur Narayan, Chethan" <chethan.tumkur.narayan@intel.com> Subject: RE: [bug report] Bluetooth: btintel: Add infrastructure to read controller information Thread-Topic: [bug report] Bluetooth: btintel: Add infrastructure to read controller information Thread-Index: AQHWjZ/gVkmoNz+emESKM63nVsqm26lya27g Date: Mon, 21 Sep 2020 03:03:54 +0000 Message-ID: <BYAPR11MB3141AF55929E6AE9CC0225DDF53A0@BYAPR11MB3141.namprd11.prod.outlook.com> References: <20200918093902.GA882111@mwanda> In-Reply-To: <20200918093902.GA882111@mwanda> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows authentication-results: oracle.com; dkim=none (message not signed) header.d=none;oracle.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [122.182.228.193] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8c1c491e-6d32-4faa-63cb-08d85ddaf992 x-ms-traffictypediagnostic: BYAPR11MB3494: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <BYAPR11MB3494E12C3CB75B8DD943B5E3F53A0@BYAPR11MB3494.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: s9joGlFKt1W59naR+OFTdDV7rLZzmwDllxtm24rQQqgdLItPtI9dbPnbpHamHKdTgKeVICiaXqiBGv2JAd7MHRoJsLgPGQBavhBbB9AOdbn6hpTrLWXba/1XOfnCIbX5Y2Rr6UTjuodDyCZ5XYgoQYaEB7qWKt1nmxSW4uAEveBnoXzykpY+LjELo/kUcxRFLkubCArai8XH2SlGeGRco8hiCi4PvoEdJQ4Ekcxl9bED8UItwuGIzzkYWUKebKgKblbSXopCxqHVetkegbwBO6TzbK0NNoECf8dtMLMsZV1Zj9JkW9yXjNb9GnaXgjuOudHIFCnGiABvW4PlBdXkbg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3141.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(376002)(136003)(396003)(346002)(366004)(71200400001)(5660300002)(53546011)(6506007)(316002)(107886003)(86362001)(33656002)(8676002)(478600001)(52536014)(55016002)(7696005)(64756008)(186003)(66446008)(4326008)(66556008)(66476007)(54906003)(76116006)(9686003)(8936002)(66946007)(26005)(2906002)(110136005)(83380400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: NZNi4JGUoIodIH0EE7sGoUKTPBp8/57ryu5+YoHh2SoGnYS+vCN3U9QogkKTDSdwuXZAfI/feIem/npDmwsYXr16G0QJj1gjol+SG0l2ebzUs+SDctSFuYRnf0SyczDstY516rxBVuaWjAo5Brva0TuwFp+nvNFKUBlOzp9UCn6GWvyIiyQUaoCLSn6xDXjPbPTqC6flL6wUfmxp74Le/UQXMq6CRFQ6a6Ud0NLiwAAiyrhGcNpB2M/dbIicH3fkXzq1o8uw/gaF1G3H1PcyzawCXMpd2y6EIx+mUEJfii4/LN7V528gTykz4nh9+6+kXGZerKTc2ggKSw+YqMpQYN4s3qVCtCfabViXKsJ1/Ea/244N8T/Va4Fc9by7jkDz2gYzxIXSuDI7NKwChArPsjz9wEeCm8AIhnmxxM0EjUd9ylHHAwb+yf8uYA+OqRVOSPy2EhVSeGygqLPtf6vIDBB2W28UVTRLLS9OOICehZ1W/EmWIHDd+hno+7AChD00ffLaikPLgemDX9Uu4w+PZKYMbGAfXiiJ/Epwwg6IIvBs+1fURzKCThSB1C5j8u5Hs5zAfOHrUXvM5G0zx9sjU++Q42dYGyAl5czqhrivnNhUhFmQzzFlWSTyEYkkwTTJDJkAlK82H1nV/d92v1AoDQ== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3141.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8c1c491e-6d32-4faa-63cb-08d85ddaf992 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Sep 2020 03:03:54.1880 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: FWIfAMO69FQTh0tvi7hBVrMPPO6ZJnIPdvzzdFf2YvNXvXRDp36j7Ur1GvpHNrhoEoI0P/y/2wjM0MSoAyBQ3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3494 X-OriginatorOrg: intel.com Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.96 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7457940675 X-Rspamd-UID: 446250 Hi Dan, Thanks for the comments. For some reason, the static analysis tool I am us= ing didn't report these issues. I will submit a patch soon to address these= issues. Regards, Kiran > -----Original Message----- > From: Dan Carpenter <dan.carpenter@oracle.com> > Sent: Friday, September 18, 2020 3:09 PM > To: kiraank@gmail.com > Cc: linux-bluetooth@vger.kernel.org > Subject: [bug report] Bluetooth: btintel: Add infrastructure to read cont= roller > information >=20 > Hello Kiran K, >=20 > The patch 57375beef71a: "Bluetooth: btintel: Add infrastructure to read > controller information" from Sep 14, 2020, leads to the following static > checker warning: >=20 > drivers/bluetooth/btintel.c:490 btintel_read_version_tlv() > error: 'tlv->len' from user is not capped properly >=20 > drivers/bluetooth/btintel.c > 426 /* Consume Command Complete Status field */ > 427 skb_pull(skb, 1); > 428 > 429 /* Event parameters contatin multiple TLVs. Read each of = them > 430 * and only keep the required data. Also, it use existing= legacy > 431 * version field like hw_platform, hw_variant, and fw_var= iant > 432 * to keep the existing setup flow > 433 */ > 434 while (skb->len) { > ^^^^^^^^ > I feel like these days we are trying to not trust firmware... Smatch is > complaining because it distrusts all skb->data information, but unless th= e > devs at Google have a way to connect a fuzzer to this then trusting is > probably harmless. Anyway, the rest of this email assumes that fuzzing i= s > possible. >=20 > If skb->len is less than sizeof(*tlv) then it will read beyond the end of= the skb. >=20 > while (skb->len >=3D sizeof(struct intel_tlv)) { >=20 > But struct intel_tlv is variable length so it's more complicated than jus= t testing > while we need aditional tests below. >=20 > 435 struct intel_tlv *tlv; > 436 > 437 tlv =3D (struct intel_tlv *)skb->data; >=20 > if (struct_size(tlv->len, val, tvl) > skb->len) > return -EINVAL; >=20 > The length has to be at least 1. >=20 > if (tvl->len < 1) > return -EINVAL; >=20 > 438 switch (tlv->type) { > 439 case INTEL_TLV_CNVI_TOP: >=20 > Ever test which is reads more than 1 byte has to have a check: >=20 > if (tvl->len < sizeof(u32)) > return -EINVAL; >=20 > 440 version->cnvi_top =3D get_unaligned_le32(= tlv->val); > 441 break; > 442 case INTEL_TLV_CNVR_TOP: >=20 > Here too, etc. >=20 > 443 version->cnvr_top =3D get_unaligned_le32(= tlv->val); > 444 break; > 445 case INTEL_TLV_CNVI_BT: > 446 version->cnvi_bt =3D get_unaligned_le32(t= lv->val); > 447 break; > 448 case INTEL_TLV_CNVR_BT: > 449 version->cnvr_bt =3D get_unaligned_le32(t= lv->val); > 450 break; > 451 case INTEL_TLV_DEV_REV_ID: > 452 version->dev_rev_id =3D get_unaligned_le1= 6(tlv->val); > 453 break; > 454 case INTEL_TLV_IMAGE_TYPE: > 455 version->img_type =3D tlv->val[0]; > 456 break; > 457 case INTEL_TLV_TIME_STAMP: >=20 > if (tvl->len < sizeof(u16)) > return -EINVAL; >=20 > 458 version->timestamp =3D get_unaligned_le16= (tlv->val); > 459 break; > 460 case INTEL_TLV_BUILD_TYPE: > 461 version->build_type =3D tlv->val[0]; > 462 break; > 463 case INTEL_TLV_BUILD_NUM: > 464 version->build_num =3D get_unaligned_le32= (tlv->val); > 465 break; > 466 case INTEL_TLV_SECURE_BOOT: > 467 version->secure_boot =3D tlv->val[0]; > 468 break; > 469 case INTEL_TLV_OTP_LOCK: > 470 version->otp_lock =3D tlv->val[0]; > 471 break; > 472 case INTEL_TLV_API_LOCK: > 473 version->api_lock =3D tlv->val[0]; > 474 break; > 475 case INTEL_TLV_DEBUG_LOCK: > 476 version->debug_lock =3D tlv->val[0]; > 477 break; > 478 case INTEL_TLV_MIN_FW: >=20 > if (tvl->len < 3) > return -EINVAL; >=20 > 479 version->min_fw_build_nn =3D tlv->val[0]; > 480 version->min_fw_build_cw =3D tlv->val[1]; > 481 version->min_fw_build_yy =3D tlv->val[2]; > 482 break; > 483 case INTEL_TLV_LIMITED_CCE: > 484 version->limited_cce =3D tlv->val[0]; > 485 break; > 486 case INTEL_TLV_SBE_TYPE: > 487 version->sbe_type =3D tlv->val[0]; > 488 break; > 489 case INTEL_TLV_OTP_BDADDR: > 490 memcpy(&version->otp_bd_addr, tlv->val, t= lv->len); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^= ^^^^^^^^ > tlv->len comes from the network and it's 0-255. If it's more than 6 > then this will corrupt memory. There is no caller for this function yet = in linux- > next so if tvl->len is less than 6 will that leave uninitialized memory i= n - > >otp_bd_addr? >=20 > if (tlv->len !=3D sizeof(version->otp_bd_addr)) > return -EINVAL; >=20 > 491 break; > 492 default: > 493 /* Ignore rest of information */ > 494 break; > 495 } > 496 /* consume the current tlv and move to next*/ > 497 skb_pull(skb, tlv->len + sizeof(*tlv)); > 498 } > 499 > 500 kfree_skb(skb); > 501 return 0; >=20 > regards, > dan carpenter Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OBRyLdEqaF+Z/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 06:23:45 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id CAmcKtEqaF95UgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 06:23:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 747A940967; Mon, 21 Sep 2020 06:23:41 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726297AbgIUEXV (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 00:23:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbgIUEXV (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 00:23:21 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72DECC0613CF for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:23:21 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id j35so12069448qtk.14 for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=3g+5sRcRx+zydE8jyArP2ZUJ3JXfB06DrKVQlQmrsfs=; b=v2Z7R8/2TESra8dV9i4yZrm8WhqxqdyKcgqxjNQhmPH2IP5lRl+ot0qMEp6XeEyRTN /nU8ZfDVfxPm2N5cmsSM1znYTPtvSSeFiUjiVLP2FlHXtY99PJMCs5lt7t6KTutRBlwD l7lQVvPl/T6jNKUgy2eTEJhH0P7a+ct6asHDmgbwLUNLJNa3JUfaKKS3Mzc8q4y5Otik QtEhWXZgwoJfvSxmT2Ti2QBmMzzeqWB8Vmw3xxf2M1Mp7VpGJjZREiiyKmYbclOf9WBQ mNZrOl8iPr08QgPgiBDxoIp3NbWOwFavn4Hg48hn9KKYWdvfUCVbdK9nnFNduHMcPcjy 3Uvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=3g+5sRcRx+zydE8jyArP2ZUJ3JXfB06DrKVQlQmrsfs=; b=t8d3M6Lk8XzoeTnB2YksRf4AYrimlQ7vFqs9ohShapqGsC48+PXhjhdCu8nojAi7ua Oj3lP97rWvrBkF44iiqvOSYvp+mYMp3AwbCQAj41i+czbwnf5cemTfJNdatjuZKldksu BIMl7tQeuM5eB6d3I8cCSOpOIzKjC6KJvq6CWKGyePxPARqob28PF0lVori4eGzqASLG C2j+cIOTR7BSFCn0WMacjd22khTAM3RZNCMpFxxptMyt1Y8j6ufF1v7QpyA+hi0Og0B1 uprvsZi52VFETt3yefSYm45stIK9BDa7A+gzsoRDOzT2fuqAR+yX8PSULQEjhb0JfaZa 7ODw== X-Gm-Message-State: AOAM5302mDfdN4GLlbwPgtjrykp+8NDQgrSSRCBVBlyPLkLVhJP9B0Kc RlrJV3fYpYemOyDMZGxcmDHyQZFPzVomFAbB88kxmeC+bglZq9giaxdEB3/u7ivDi5rGtEWP4o+ vhVKZlD6q1hmececXYu6NepEnArSq29AbjTrxqylUlvUcQlaB0OtZUSjDmE8NTtG406q0yWFz2v 6ZyOsDH08TBks= X-Google-Smtp-Source: ABdhPJyfocm+H2O7GsmOmmx135CTp5XEn6aR/0Blkuk0TSlbdfFJiizpSKXB4VtozgsYaTlxS4PXlNuoXUQTfHJurA== Sender: "howardchung via sendgmr" <howardchung@howardchung-p920.tpe.corp.google.com> X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a0c:ab4a:: with SMTP id i10mr27943621qvb.39.1600662200242; Sun, 20 Sep 2020 21:23:20 -0700 (PDT) Date: Mon, 21 Sep 2020 12:23:05 +0800 Message-Id: <20200921122216.v4.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v4 1/4] Bluetooth: Interleave with allowlist scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: alainm@chromium.org, mcchou@chromium.org, mmandlik@chromium.orgi, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.05 / 15.00 / 15.00 X-Rspamd-Queue-Id: 747A940967 X-Rspamd-UID: 509360 This patch implements the interleaving between allowlist scan and no-filter scan. It'll be used to save power when at least one monitor is registered and at least one pending connection or one device to be scanned for. The durations of the allowlist scan and the no-filter scan are controlled by MGMT command: Set Default System Configuration. The default values are set randomly for now. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v4: - Rebase to bluetooth-next/master (previous 2 patches are applied) - Fix over 80 chars limit in mgmt_config.c - Set EnableAdvMonInterleaveScan default to Disable Changes in v3: - Remove 'Bluez' prefix Changes in v2: - remove 'case 0x001c' in mgmt_config.c include/net/bluetooth/hci_core.h | 10 +++ net/bluetooth/hci_core.c | 4 + net/bluetooth/hci_request.c | 137 +++++++++++++++++++++++++++++-- net/bluetooth/mgmt_config.c | 10 +++ 4 files changed, 153 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9873e1c8cd163..179350f869fdb 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -361,6 +361,8 @@ struct hci_dev { __u8 ssp_debug_mode; __u8 hw_error_code; __u32 clock; + __u16 advmon_allowlist_duration; + __u16 advmon_no_filter_duration; __u16 devid_source; __u16 devid_vendor; @@ -542,6 +544,14 @@ struct hci_dev { struct delayed_work rpa_expired; bdaddr_t rpa; + enum { + ADV_MONITOR_SCAN_NONE, + ADV_MONITOR_SCAN_NO_FILTER, + ADV_MONITOR_SCAN_ALLOWLIST + } adv_monitor_scan_state; + + struct delayed_work interleave_adv_monitor_scan; + #if IS_ENABLED(CONFIG_BT_LEDS) struct led_trigger *power_led; #endif diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f30a1f5950e15..6c8850149265a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3592,6 +3592,10 @@ struct hci_dev *hci_alloc_dev(void) hdev->cur_adv_instance = 0x00; hdev->adv_instance_timeout = 0; + /* The default values will be chosen in the future */ + hdev->advmon_allowlist_duration = 300; + hdev->advmon_no_filter_duration = 500; + hdev->sniff_max_interval = 800; hdev->sniff_min_interval = 80; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index d2b06f5c93804..89443b48d90ce 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -378,6 +378,57 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable) hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type); } +static void start_interleave_scan(struct hci_dev *hdev) +{ + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; + queue_delayed_work(hdev->req_workqueue, + &hdev->interleave_adv_monitor_scan, 0); +} + +static bool is_interleave_scanning(struct hci_dev *hdev) +{ + return hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_NONE; +} + +static void cancel_interleave_scan(struct hci_dev *hdev) +{ + bt_dev_dbg(hdev, "%s cancelling interleave scan", hdev->name); + + cancel_delayed_work_sync(&hdev->interleave_adv_monitor_scan); + + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NONE; +} + +/* Return true if interleave_scan is running after exiting this function, + * otherwise, return false + */ +static bool update_adv_monitor_scan_state(struct hci_dev *hdev) +{ + if (!hci_is_adv_monitoring(hdev) || + (list_empty(&hdev->pend_le_conns) && + list_empty(&hdev->pend_le_reports))) { + if (is_interleave_scanning(hdev)) { + /* If the interleave condition no longer holds, cancel + * the existed interleave scan. + */ + cancel_interleave_scan(hdev); + } + return false; + } + + if (!is_interleave_scanning(hdev)) { + /* If there is at least one ADV monitors and one pending LE + * connection or one device to be scanned for, we should + * alternate between allowlist scan and one without any filters + * to save power. + */ + start_interleave_scan(hdev); + bt_dev_dbg(hdev, "%s starting interleave scan", hdev->name); + } + + return true; +} + /* This function controls the background scanning based on hdev->pend_le_conns * list. If there are pending LE connection we start the background scanning, * otherwise we stop it. @@ -449,9 +500,11 @@ static void __hci_update_background_scan(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) hci_req_add_le_scan_disable(req, false); - hci_req_add_le_passive_scan(req); - - BT_DBG("%s starting background scanning", hdev->name); + if (!update_adv_monitor_scan_state(hdev)) { + hci_req_add_le_passive_scan(req); + bt_dev_dbg(hdev, "%s starting background scanning", + hdev->name); + } } } @@ -844,12 +897,17 @@ static u8 update_white_list(struct hci_request *req) return 0x00; } - /* Once the controller offloading of advertisement monitor is in place, - * the if condition should include the support of MSFT extension - * support. If suspend is ongoing, whitelist should be the default to - * prevent waking by random advertisements. + /* Use the allowlist unless the following conditions are all true: + * - We are not currently suspending + * - There are 1 or more ADV monitors registered + * - Interleaved scanning is not currently using the allowlist + * + * Once the controller offloading of advertisement monitor is in place, + * the above condition should include the support of MSFT extension + * support. */ - if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended) + if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended && + hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_ALLOWLIST) return 0x00; /* Select filter policy to use white list */ @@ -1002,6 +1060,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) &own_addr_type)) return; + bt_dev_dbg(hdev, "interleave state %d", hdev->adv_monitor_scan_state); /* Adding or removing entries from the white list must * happen before enabling scanning. The controller does * not allow white list modification while scanning. @@ -1871,6 +1930,64 @@ static void adv_timeout_expire(struct work_struct *work) hci_dev_unlock(hdev); } +static int add_le_interleave_adv_monitor_scan(struct hci_request *req, + unsigned long opt) +{ + struct hci_dev *hdev = req->hdev; + int ret = 0; + + hci_dev_lock(hdev); + + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + hci_req_add_le_scan_disable(req, false); + hci_req_add_le_passive_scan(req); + + switch (hdev->adv_monitor_scan_state) { + case ADV_MONITOR_SCAN_ALLOWLIST: + bt_dev_dbg(hdev, "next state: allowlist"); + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; + break; + case ADV_MONITOR_SCAN_NO_FILTER: + bt_dev_dbg(hdev, "next state: no filter"); + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_ALLOWLIST; + break; + case ADV_MONITOR_SCAN_NONE: + default: + BT_ERR("unexpected error"); + ret = -1; + } + + hci_dev_unlock(hdev); + + return ret; +} + +static void interleave_adv_monitor_scan_work(struct work_struct *work) +{ + struct hci_dev *hdev = container_of(work, struct hci_dev, + interleave_adv_monitor_scan.work); + u8 status; + unsigned long timeout; + + if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_ALLOWLIST) { + timeout = msecs_to_jiffies(hdev->advmon_allowlist_duration); + } else if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_NO_FILTER) { + timeout = msecs_to_jiffies(hdev->advmon_no_filter_duration); + } else { + bt_dev_err(hdev, "unexpected error"); + return; + } + + hci_req_sync(hdev, add_le_interleave_adv_monitor_scan, 0, + HCI_CMD_TIMEOUT, &status); + + /* Don't continue interleaving if it was canceled */ + if (is_interleave_scanning(hdev)) { + queue_delayed_work(hdev->req_workqueue, + &hdev->interleave_adv_monitor_scan, timeout); + } +} + int hci_get_random_address(struct hci_dev *hdev, bool require_privacy, bool use_rpa, struct adv_info *adv_instance, u8 *own_addr_type, bdaddr_t *rand_addr) @@ -3292,6 +3409,8 @@ void hci_request_setup(struct hci_dev *hdev) INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); INIT_DELAYED_WORK(&hdev->le_scan_restart, le_scan_restart_work); INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire); + INIT_DELAYED_WORK(&hdev->interleave_adv_monitor_scan, + interleave_adv_monitor_scan_work); } void hci_request_cancel_all(struct hci_dev *hdev) @@ -3311,4 +3430,6 @@ void hci_request_cancel_all(struct hci_dev *hdev) cancel_delayed_work_sync(&hdev->adv_instance_expire); hdev->adv_instance_timeout = 0; } + + cancel_interleave_scan(hdev); } diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index b30b571f8caf8..2d3ad288c78ac 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -67,6 +67,8 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, HDEV_PARAM_U16(0x001a, le_supv_timeout), HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b, def_le_autoconnect_timeout), + HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), + HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -138,6 +140,8 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x0019: case 0x001a: case 0x001b: + case 0x001d: + case 0x001e: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -251,6 +255,12 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, hdev->def_le_autoconnect_timeout = msecs_to_jiffies(TLV_GET_LE16(buffer)); break; + case 0x0001d: + hdev->advmon_allowlist_duration = TLV_GET_LE16(buffer); + break; + case 0x0001e: + hdev->advmon_no_filter_duration = TLV_GET_LE16(buffer); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cI3BIuIqaF+Z/gEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 06:24:02 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id EIY/IOIqaF+sDgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 06:24:02 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B0D2A40618; Mon, 21 Sep 2020 06:23:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726415AbgIUEXf (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 00:23:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbgIUEX2 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 00:23:28 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF826C0613CF for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:23:28 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id a16so7811806pfk.2 for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=KBETbgHJRtwnWH3QRJ6V38Ec73b7Ro5YQIkQRswxAOg=; b=tJuzUxiw1SA9quuoXjslcjTek27JhLsC98t22DS3rNXHxHyfi9QHtNqsTtmZebk5e2 /HWmclAyu8Ro01J4F3vQdTRr8Jf0YA64+XmaMQB+6hfU3cc2wD9YLcjdKkrHWZtG14JI IBs7U/3kpXNKUjzQ2sW1NLMHCSYlWvjI07HWDrMVWOoHrj5yxKVLXalI12rSBb+l7UaP R8WdyoYjR8SAWLwBiPluWLb6DbrVE/4OZyh04mOKQEDfBySB9lJ+0lEUZvRElvj0g6Qq g2VCB9QK//uRtVAgrUIBlTa4gqWQLqIIygz3Db2uNxtZfm8Oy77jxM6mOenqgIaPRpbP sDNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=KBETbgHJRtwnWH3QRJ6V38Ec73b7Ro5YQIkQRswxAOg=; b=ALW3U14sFyL2eiIXghH71krrxscImGJe5WsPxtxslMOjYAIr1ZARNTzVq/5d0DbqZ7 lPyIqWtfXW5IIKJtgma1SEJHmtfjLzKKhVNDmlXsu9NXAzj1WqLgIJggASWP9hW9lTic 3lzIDb4SfQ6/If4QBy4kz+OurDy+f9p7z/jeGjJ6bJD1rhyLCseIZNBp/CRHidmv9aVd rloH+SJioR2pUN42ZZJAGmSAbG9Qe9OrPEcJuxRAQXIgiw+XYdMY8ypXMrOV7g0wsIh3 eRhRMb9UWBoEUNsoiY7MFjrC50IrvvjjpCmtvcK7t6nFXHGuERhR09L7F6XwAtxHjQTl D1Ig== X-Gm-Message-State: AOAM532VQln+4kg6YY/nSi/C1C/jB6wtbQRQBC9ya28bJINBWF6YnB5o cXAsNlPshXy5BP74vV7R7l76PRgMcpKAJV+SVSnII/ShmUuaDToRMQWtR+wP8Lim008dSWJkx1Q 47NUL/s/OVapkhkxmN1bG+8kjkxq2IDVKEmJ4FdUfsaRXa7i5RtlUnh14HNWQLUIuhg6HIW/h7A lmfZmjQGcKWVo= X-Google-Smtp-Source: ABdhPJyBY4AJhf1noantDjUICD2bTO6IE5Zw0P4pyRPtpEdk8XdZ3Ir4ib1DpFYqwc56u6U0F6GiYNnFgaIJLfN9hg== Sender: "howardchung via sendgmr" <howardchung@howardchung-p920.tpe.corp.google.com> X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:902:a418:b029:d1:e598:4009 with SMTP id p24-20020a170902a418b02900d1e5984009mr26109409plq.67.1600662207933; Sun, 20 Sep 2020 21:23:27 -0700 (PDT) Date: Mon, 21 Sep 2020 12:23:07 +0800 In-Reply-To: <20200921122216.v4.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Message-Id: <20200921122216.v4.3.I21e5741249e78c560ca377499ba06b56c7214985@changeid> Mime-Version: 1.0 References: <20200921122216.v4.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v4 3/4] Bluetooth: Handle active scan case From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: alainm@chromium.org, mcchou@chromium.org, mmandlik@chromium.orgi, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.01 / 15.00 / 15.00 X-Rspamd-Queue-Id: B0D2A40618 X-Rspamd-UID: f7709b This patch adds code to handle the active scan during interleave scan. The interleave scan will be canceled when users start active scan, and it will be restarted after active scan stopped. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) net/bluetooth/hci_request.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index d9082019b6386..1fcf6736811e4 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -3085,8 +3085,10 @@ static int active_scan(struct hci_request *req, unsigned long opt) * running. Thus, we should temporarily stop it in order to set the * discovery scanning parameters. */ - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { hci_req_add_le_scan_disable(req, false); + cancel_interleave_scan(hdev); + } /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id OFICN+wqaF9I7wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 06:24:12 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id KH6eM+wqaF9zWQAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 06:24:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E285740967; Mon, 21 Sep 2020 06:24:08 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726419AbgIUEXh (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 00:23:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbgIUEXd (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 00:23:33 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A734DC0613CF for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:23:32 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id q2so11959774ybo.5 for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=epV5Kf267asYL9EhY6AdeHNontynwjSLiF3gUn0z2B0=; b=NrHx8f/+pxqzILxbiJcQa7zh9LcPo1bS/hZTFXyHHyuFKJAfummZGCmO7UjcYW7Bto oHJLUrOYH1a7HSTXqwKXU9FC5QxUAmPvT3Qb/TmMQk6AZSF2VGXAqP2cM3Qq0kbCLiw0 cOkhpOmk0BAYqZ4FMN7Vl2NS1Mc+KoLZuQxCU/RFmmN1E9NfghqIjT/0ryHWFkIILjXA eDCRz4+v/A2KJ7hRgz7b6JDh8Ayv3JkM2V4+ipR3XxXW+0wA5xEn0qxFohle890HJjof 4kksU0m3A2OD5gtFthYOQKE9hNaK7FFDEchwk8CgprAXx7DkSV3vKICyyEWFYKVaV8Q9 YZNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=epV5Kf267asYL9EhY6AdeHNontynwjSLiF3gUn0z2B0=; b=uO5znCZ9haXHGPnq+tnzTmziN1E+2CPz/jIG5gnp9XR+70F3pF6ywHKD3l2CAKo1PP Jt44dLmeXRk8VVAYsBal3A1Tbd2o/KMgCtRl77PPmeUdkFkvhU9WIWEe/07Hvs0BhuUm LPQtZ9ZL5tzM5aDZblvcGF1gx8UUUPOVSzAPjX/GKNal5UlhlKU8on1CZbyJlYJCbfvR PKCXiYHR31wVf72c/7/4oe0eVbfiCWcym/ycvbyjqv5v8XW6ShqPOHEyGpnijo5EBg2Y TNbjv6s8X1uIbjlkbGq7VR+KnkDtqaSRF0ISPXSoxFOwT0p4T3QDbXZwAuINDxs6EIeu 0TZw== X-Gm-Message-State: AOAM532j00JxJ6OVtlkvc55rXbnGfISCja8dUu8IrsRWSLkOoa87P8BW 7igwDOXEbLoqd26UrIXSYg6Z07NZWE6gk8Tk0QYbxE+MomokGTVIq7yKZJ/MLKbYMdhm4CyLY3f wmYSiZvUIYWidY2QsQEPIMtqrKv+FSfgT+FeG2MdD416s7KwvfwR5jl9mErG4xkc2BKvtCmIvb9 rilmFoaH2KqDY= X-Google-Smtp-Source: ABdhPJyyCNP9bHpy8nwOUFwlrx6vXZ/QBNe3dSUwlLKUeoogRqulu5Xd8SJnXa/GaEVHDNG3YZwzCLtP4OeTaMsvBQ== Sender: "howardchung via sendgmr" <howardchung@howardchung-p920.tpe.corp.google.com> X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a25:e83:: with SMTP id 125mr65805362ybo.376.1600662211746; Sun, 20 Sep 2020 21:23:31 -0700 (PDT) Date: Mon, 21 Sep 2020 12:23:08 +0800 In-Reply-To: <20200921122216.v4.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Message-Id: <20200921122216.v4.4.I756c1fecc03bcc0cd94400b4992cd7e743f4b3e2@changeid> Mime-Version: 1.0 References: <20200921122216.v4.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v4 4/4] Bluetooth: Add toggle to switch off interleave scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: alainm@chromium.org, mcchou@chromium.org, mmandlik@chromium.orgi, Howard Chung <howardchung@google.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.23 / 15.00 / 15.00 X-Rspamd-Queue-Id: E285740967 X-Rspamd-UID: 275596 This patch add a configurable parameter to switch off the interleave scan feature. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Changes in v4: - Set EnableAdvMonInterleaveScan default to Disable - Fix 80 chars limit in mgmt_config.c include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 1 + net/bluetooth/hci_request.c | 3 ++- net/bluetooth/mgmt_config.c | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 179350f869fdb..c3253f1cac0c2 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -363,6 +363,7 @@ struct hci_dev { __u32 clock; __u16 advmon_allowlist_duration; __u16 advmon_no_filter_duration; + __u16 enable_advmon_interleave_scan; __u16 devid_source; __u16 devid_vendor; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6c8850149265a..d5769ae682893 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3595,6 +3595,7 @@ struct hci_dev *hci_alloc_dev(void) /* The default values will be chosen in the future */ hdev->advmon_allowlist_duration = 300; hdev->advmon_no_filter_duration = 500; + hdev->enable_advmon_interleave_scan = 0x0000; /* Default to disable */ hdev->sniff_max_interval = 800; hdev->sniff_min_interval = 80; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 1fcf6736811e4..bb38e1dead68f 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -500,7 +500,8 @@ static void __hci_update_background_scan(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) hci_req_add_le_scan_disable(req, false); - if (!update_adv_monitor_scan_state(hdev)) { + if (!hdev->enable_advmon_interleave_scan || + !update_adv_monitor_scan_state(hdev)) { hci_req_add_le_passive_scan(req); bt_dev_dbg(hdev, "%s starting background scanning", hdev->name); diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index 2d3ad288c78ac..34585ab4680b5 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -69,6 +69,7 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, def_le_autoconnect_timeout), HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), + HDEV_PARAM_U16(0x001f, enable_advmon_interleave_scan), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -142,6 +143,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x001b: case 0x001d: case 0x001e: + case 0x001f: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -261,6 +263,9 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x0001e: hdev->advmon_no_filter_duration = TLV_GET_LE16(buffer); break; + case 0x0001f: + hdev->enable_advmon_interleave_scan = TLV_GET_LE16(buffer); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6BViBPEqaF9I7wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 06:24:17 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id MKkhAPEqaF9N1QEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 06:24:17 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 166464097C; Mon, 21 Sep 2020 06:24:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726343AbgIUEX1 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 00:23:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbgIUEXZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 00:23:25 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE0D2C0613CF for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:23:24 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id h9so8338764qvr.3 for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=Yq3AQHq0oby0gIEHvauwatHEbFOs+SQiwBq1B7FgTKo=; b=LKoEVcaLu9J1s6MC0b/XU0LBbNUgQCSb9C/Gu8Ngkvh1qchoHOqiUZeTCvxbqADEEr 8HN4+XPGK92MEZgQ6pSijf3ZPuTuV8ue9rmc3lNM27s8n2j9068gHzZP7rN7yIf33RAk 84MSu6m5JkR8bblDYVXxwMtsHBGVFxcBBHdk/JErR8jcdJxefVt1JtNeK7Q/0JittbhG Mgcral7UzED8/qt0+UpJuVFSx2gtT5q62w4wCpMjCGVcNrPmM3ZWRReeuGOh2AEbjl8F hCa1RY+SwLDjb0Q+8hUzatNLFYnhWnIMo635KhiILGh0M54/aWO8g4FrsXe+7KEkSrjP 9Dxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Yq3AQHq0oby0gIEHvauwatHEbFOs+SQiwBq1B7FgTKo=; b=BgVpkdyurzo2ZKhQbNMKFw32aYzCby1LUjLw6trxDtuErV1CRmLWSX4ntJQE604Zz9 Ao20WCojeVDHBxjp/nvpYUZQ3YWP4MYDr2zWECnSDIA4dj1pmxwPVIrZNSS49DSefSFB L8cf1rzCyH8HnfsPj1GYTg9dCGWNah26C+g6GuQhhWVC7+C1+ZdcJw+wTHcf5AOASSPX h9xCL+Wn0I0mlOwogS1bB0KlfX4njnTAG/v13dA4UOnr5NWyv2uWNTWLr5z6kdt8h5OV 1BloCfpa68Cm7sIrQseU6E2CxUb9N1qnyQreYal1wthcBq0HeuQTjyFWNtm/qZSeNbc1 gIwg== X-Gm-Message-State: AOAM531rcIEEV+s4yIJd9r5MciKeqQxc/h3TyDpZd/ZHD9S+o5YrGPoP qG2v/6v/AjGWNRmT8PeOZwhXDeeiBSnwVQB1ZduOF2qeAshC6jJ3/SGk7aMtXCyAkyzhBHnbY3g 4saHsDk19BQtrRLyt3DsFrORcPAZshXVRnqeVlLeHclPUc/Hfz7AYT4IUvJhzQXZsODekviJWAZ 5f3xx2fBuiHw0= X-Google-Smtp-Source: ABdhPJwXym3Sd1aSSPHJkyGYexID/m6rqleizJLZo+K6wjMy6lVl1Yw6hCwfp6/l28NUN8/ovKMkGGJCwzOk6pE85g== Sender: "howardchung via sendgmr" <howardchung@howardchung-p920.tpe.corp.google.com> X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:58e3:: with SMTP id di3mr28838122qvb.54.1600662203923; Sun, 20 Sep 2020 21:23:23 -0700 (PDT) Date: Mon, 21 Sep 2020 12:23:06 +0800 In-Reply-To: <20200921122216.v4.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Message-Id: <20200921122216.v4.2.I3774a8f0d748c7c6ec3402c4adcead32810c9164@changeid> Mime-Version: 1.0 References: <20200921122216.v4.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v4 2/4] Bluetooth: Handle system suspend resume case From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: alainm@chromium.org, mcchou@chromium.org, mmandlik@chromium.orgi, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.19 / 15.00 / 15.00 X-Rspamd-Queue-Id: 166464097C X-Rspamd-UID: 6f0c79 This patch adds code to handle the system suspension during interleave scan. The interleave scan will be canceled when the system is going to sleep, and will be restarted after waking up. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- (no changes since v1) net/bluetooth/hci_request.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 89443b48d90ce..d9082019b6386 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1081,6 +1081,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) filter_policy |= 0x02; if (hdev->suspended) { + /* Block suspend notifier on response */ + set_bit(SUSPEND_SCAN_ENABLE, hdev->suspend_tasks); + window = hdev->le_scan_window_suspend; interval = hdev->le_scan_int_suspend; } else if (hci_is_le_conn_scanning(hdev)) { @@ -1167,10 +1170,8 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ - hci_req_add_le_passive_scan(req); + __hci_update_background_scan(req); - /* Block suspend notifier on response */ - set_bit(SUSPEND_SCAN_ENABLE, req->hdev->suspend_tasks); } static void cancel_adv_timeout(struct hci_dev *hdev) @@ -1282,8 +1283,10 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan); /* Disable LE passive scan if enabled */ - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { + cancel_interleave_scan(hdev); hci_req_add_le_scan_disable(&req, false); + } /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wLCmJP4raF9yCgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 06:28:46 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id aKBOIf4raF/aegAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 06:28:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 5FAA04097C; Mon, 21 Sep 2020 06:28:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726367AbgIUE2g (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 00:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbgIUE2g (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 00:28:36 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02760C061755 for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:28:35 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id w126so10170719qka.5 for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:28:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=V8nNi7zfmcWJJjBYsa7DjWc16mvd/UtWiaZva2BXHgE=; b=lqb4N6fL0sItNVV8DWKGgfLE/zT1KXXeTlk29E0gOvYCRNKPNbdki11MZktr0uLVxw f2QlTJR7POPDqerDyLMyGYVqIycXp5z3nc3LgypAvlzbuY109MmzqhE6bE5KErFXYGbY DbnPtbmRxk4gnSaGzennP6V7TjpZXV4YObCU6eNCqArC2zw4pp3OBYNo7ZGkp+Ka+RKs gH20VG2KWDgEKUMnvoYvoUE9ZHt3gdn3W4dseMMPfKPZ1aABpbDLEt4fNEeEAn+RnR07 MVClrUf7+nqq+CDWPMjAPYlGl04AQMD/a0hmmjTNPeC7nTncYcYptw6KPJTIukYeg8BO fuqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=V8nNi7zfmcWJJjBYsa7DjWc16mvd/UtWiaZva2BXHgE=; b=UUG6akoDWUa7d3bjda/8aT1fV6Zyb+utZMryGJ1bQczY74WyJPT+3bzooBLHEdOVbe zBdTi4lwrNAAqEN5gX8vvxPzfNpV6eTQR9mXzj/P6/zwqx1Dxi8Ah3RQm05+hNMuZJRj WeqUguXaIuf05tOHV/LCeuKo0Qroq2+sntdjbmVve/u00gjuUZbyAmwbsofwybRkZvlU 0iVlb65K1lcjRybp/I95Wm5yy46Ki7T7+jpFJc4LS52kfs37SckQa3BJAwn//u5aAbG7 gVs9XxHKvZXsz3VcI5S5LP7YYOiQlL4lcvVPo8rX0bG00KgVKr8tC51P/WgQb6q2H9s3 3LPg== X-Gm-Message-State: AOAM532Sua4fV/SWKd8fR5jwxA6m87xm8dHzsewn3+/mh0ahpPf+86Du JSHsPK6dVm2Dnd6VGgrMNz31brwc90FYUvuQ1ku0s19Hk713Vh+0v9EhS9gb0f74FWHcrfkLjBr F60JA5JrOhB6usWIBZJyZgXmqR/e2/kNoo9ZhVEuK+m/hTgwz4v1OQhXzDKWA9Cq3uBcVRUOLxk +X9ybhg6h0s8E= X-Google-Smtp-Source: ABdhPJwsAJTnQm1wxIx73RJv0k0QkSIb5hZiOq8/hchJfxuEMhsncumiYFjWHkhedMdb+kWEruilz6kMptPjAdDUwQ== Sender: "howardchung via sendgmr" <howardchung@howardchung-p920.tpe.corp.google.com> X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:57cc:: with SMTP id y12mr28804449qvx.48.1600662515000; Sun, 20 Sep 2020 21:28:35 -0700 (PDT) Date: Mon, 21 Sep 2020 12:28:24 +0800 In-Reply-To: <20200921042824.1265006-1-howardchung@google.com> Message-Id: <20200921122757.BlueZ.v3.2.Iac5207375d22fb7b96ae4ef73b49ae4ab457219c@changeid> Mime-Version: 1.0 References: <20200921042824.1265006-1-howardchung@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [BlueZ PATCH v3 2/2] core: Add param to disable interleave scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, mmandlik@chromium.org, luiz.dentz@gmail.com, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.02 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5FAA04097C X-Rspamd-UID: 70de1d This patch adds parameter to enable/disable the interleave scan feature. --- Changes in v3: - Set EnableAdvMonInterleaveScan default to Disable src/adapter.c | 9 +++++++++ src/hcid.h | 1 + src/main.c | 6 ++++++ src/main.conf | 6 ++++++ 4 files changed, 22 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index c0e95b48a1c4..a2c782e308bb 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -4449,6 +4449,15 @@ static void load_default_system_params(struct btd_adapter *adapter) len += sizeof(params[i].u16); } + if (main_opts.default_params.enable_advmon_interleave_scan != 0xFFFF) { + params[i].entry.type = 0x001f; + params[i].entry.length = sizeof(params[i].u16); + params[i].u16 = + main_opts.default_params.enable_advmon_interleave_scan; + ++i; + len += sizeof(params[i].u16); + } + err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG, adapter->dev_id, len, params, NULL, NULL, NULL); if (!err) diff --git a/src/hcid.h b/src/hcid.h index c3e5fe803543..c6717be62c48 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -96,6 +96,7 @@ struct main_opts { uint16_t advmon_allowlist_scan_duration; uint16_t advmon_no_filter_scan_duration; + uint16_t enable_advmon_interleave_scan; } default_params; diff --git a/src/main.c b/src/main.c index e222ed3bf855..3433130bc419 100644 --- a/src/main.c +++ b/src/main.c @@ -125,6 +125,7 @@ static const char *controller_options[] = { "LEAutoconnecttimeout", "AdvMonAllowlistScanDuration", "AdvMonNoFilterScanDuration", + "EnableAdvMonInterleaveScan", NULL }; @@ -444,6 +445,10 @@ static void parse_controller_config(GKeyFile *config) &main_opts.default_params.advmon_no_filter_scan_duration, 1, 10000}, + { "EnableAdvMonInterleaveScan", + &main_opts.default_params.enable_advmon_interleave_scan, + 0, + 1}, }; uint16_t i; @@ -711,6 +716,7 @@ static void init_defaults(void) main_opts.default_params.num_entries = 0; main_opts.default_params.br_page_scan_type = 0xFFFF; main_opts.default_params.br_scan_type = 0xFFFF; + main_opts.default_params.enable_advmon_interleave_scan = 0xFFFF; if (sscanf(VERSION, "%hhu.%hhu", &major, &minor) != 2) return; diff --git a/src/main.conf b/src/main.conf index 3b341f44c9cf..82ffc5813204 100644 --- a/src/main.conf +++ b/src/main.conf @@ -159,6 +159,12 @@ # Default: 500 #AdvMonNoFilterScanDuration= +# Enable/Disable Advertisement Monitor interleave scan for power saving. +# 0: disable +# 1: enable +# Defaults to 0 +#EnableAdvMonInterleaveScan= + [GATT] # GATT attribute cache. # Possible values: -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aOVoOvcraF+1CQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 06:28:39 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kDCeN/craF/TMwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 06:28:39 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CAA1A40976; Mon, 21 Sep 2020 06:28:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726365AbgIUE2d (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 00:28:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbgIUE2d (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 00:28:33 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B2C1C061755 for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:28:33 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id a16so12025651qtj.7 for <linux-bluetooth@vger.kernel.org>; Sun, 20 Sep 2020 21:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=fC9C6NlE7ABAb/uqOE5M5b3A+T5ojcafIgUq12Ln5lA=; b=qhDWnzfOcDtYQw+no0IcMQyNUUEor4MAOuTA/mq2GZggIG38AXuHtVXDB+ZnCou2Hd I+Ahu+HI66UYI0SB16kXe67Ig9fErqxxCUWdZ2WXszokxrwEHhQbh/2uidptAgYCMY1y XaGxZwz0LU19Co3ScHClqkUSR5b/lhf8v7bcDbUkMrCh2VzPwIWUsId+W3wQDh+okEIp V6um9u4ooNsloi/eBYRqpekX+CieQr3ENgJAUwqq30b0fw2JSEM71APtL8L/i4Mzp+Z2 x5qlMnW0xOcosnnajUMp+Z4Bnk7MK4NXM41HGp44JAgcxYW6iA2b8l3k3a54dBIRtJgy aqYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=fC9C6NlE7ABAb/uqOE5M5b3A+T5ojcafIgUq12Ln5lA=; b=kTTS0z7IyMdJ8oNg70nGK0UIfUIrGSEtmjfCg+YmMI1i89a5F5AWkKkVCQRgqiGzM2 03zMdGloi5MbqfYGkKRPf77dajYsfyAraq/CclNARJpAKvA29qKc3pMMGlyu/7qHToUk OZZHkhueOHWgLPTcdL3Y9TcVHXEFoTgS1+f8ejUGVrNY5zv3cWXxIWortQuy+uH8lxwg TtSFJKFRYuHSfV/JkribIeAxiUUEzz6jYQH7Fu1NQdttx9F62mHxUcxopiggcFva3ntF 7ELal9JnmbABpgeRGrBQcZUei/dNBgvmIE9UkcCTUX7C/rFehHcCFjZheKq68ILoOp0O yzCw== X-Gm-Message-State: AOAM530mlDNZXcJ9t7Cm7EUGpu1/t1mIZqQmA9SqXQlry5jMWNjcIEaN 447Y0AYuoOyvoJHryXaJZJ/W8+De6W2th3S6El5G4/CWaSm4tOOg1DODXpmXlxpkV8bdu4FHWWy i4Y5YmVs+CLp818glYerchStXntpTUNmf65ZjIQNgOHJQEY/Iposa+jEpv7+ah/Z5XciE9V+8WR GqEf+6YS4qimo= X-Google-Smtp-Source: ABdhPJxgk/8S0bxhQGnBj5Ve94q24v904tgYlwf2XHZllId+zTIL4JajhnToSWxaaXfU45waSOgsN/QUtVk2Sae6YQ== Sender: "howardchung via sendgmr" <howardchung@howardchung-p920.tpe.corp.google.com> X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:43e5:: with SMTP id f5mr44353106qvu.12.1600662511449; Sun, 20 Sep 2020 21:28:31 -0700 (PDT) Date: Mon, 21 Sep 2020 12:28:23 +0800 Message-Id: <20200921042824.1265006-1-howardchung@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [BlueZ PATCH v3 1/2] core: Add params to set interleaving durations From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org Cc: mcchou@chromium.org, mmandlik@chromium.org, luiz.dentz@gmail.com, alainm@chromium.org, Howard Chung <howardchung@google.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.52 / 15.00 / 15.00 X-Rspamd-Queue-Id: CAA1A40976 X-Rspamd-UID: 2b41be This patch adds parameters to control the durations of allowlist scan and no-filter scan when the kernel is doing interleaving scan. --- Changes in v3: - Set EnableAdvMonInterleaveScan default to Disable Changes in v2: - Fix typo in the commit title src/adapter.c | 18 ++++++++++++++++++ src/hcid.h | 3 +++ src/main.c | 10 ++++++++++ src/main.conf | 7 +++++++ 4 files changed, 38 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index b2bd8b3f1d01..c0e95b48a1c4 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -4431,6 +4431,24 @@ static void load_default_system_params(struct btd_adapter *adapter) len += sizeof(params[i].u16); } + if (main_opts.default_params.advmon_allowlist_scan_duration) { + params[i].entry.type = 0x001d; + params[i].entry.length = sizeof(params[i].u16); + params[i].u16 = + main_opts.default_params.advmon_allowlist_scan_duration; + ++i; + len += sizeof(params[i].u16); + } + + if (main_opts.default_params.advmon_no_filter_scan_duration) { + params[i].entry.type = 0x001e; + params[i].entry.length = sizeof(params[i].u16); + params[i].u16 = + main_opts.default_params.advmon_no_filter_scan_duration; + ++i; + len += sizeof(params[i].u16); + } + err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG, adapter->dev_id, len, params, NULL, NULL, NULL); if (!err) diff --git a/src/hcid.h b/src/hcid.h index 3624ba6ea163..c3e5fe803543 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -93,6 +93,9 @@ struct main_opts { uint16_t le_conn_latency; uint16_t le_conn_lsto; uint16_t le_autoconnect_timeout; + + uint16_t advmon_allowlist_scan_duration; + uint16_t advmon_no_filter_scan_duration; } default_params; diff --git a/src/main.c b/src/main.c index 038f867b5a6d..e222ed3bf855 100644 --- a/src/main.c +++ b/src/main.c @@ -123,6 +123,8 @@ static const char *controller_options[] = { "LEConnectionLatency", "LEConnectionSupervisionTimeout", "LEAutoconnecttimeout", + "AdvMonAllowlistScanDuration", + "AdvMonNoFilterScanDuration", NULL }; @@ -434,6 +436,14 @@ static void parse_controller_config(GKeyFile *config) &main_opts.default_params.le_autoconnect_timeout, 0x0001, 0x4000}, + { "AdvMonAllowlistScanDuration", + &main_opts.default_params.advmon_allowlist_scan_duration, + 1, + 10000}, + { "AdvMonNoFilterScanDuration", + &main_opts.default_params.advmon_no_filter_scan_duration, + 1, + 10000}, }; uint16_t i; diff --git a/src/main.conf b/src/main.conf index 8d85702d4316..3b341f44c9cf 100644 --- a/src/main.conf +++ b/src/main.conf @@ -152,6 +152,13 @@ #LEConnectionSupervisionTimeout= #LEAutoconnecttimeout= +# Scan duration during interleaving scan. Only used when scanning for ADV +# monitors. The units are msec. +# Default: 300 +#AdvMonAllowlistScanDuration= +# Default: 500 +#AdvMonNoFilterScanDuration= + [GATT] # GATT attribute cache. # Possible values: -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KCsQC19DaF8ucAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 08:08:31 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id WEKLB19DaF/algAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 08:08:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 41FD440976; Mon, 21 Sep 2020 08:08:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726244AbgIUGIX (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 02:08:23 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:60217 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbgIUGIX (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 02:08:23 -0400 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.69 with qID 08L687JB0009549, This message is accepted by code: ctloc85258 Received: from RSEXMBS02.realsil.com.cn ([172.29.17.196]) by rtits2.realtek.com.tw (8.15.2/2.66/5.86) with ESMTPS id 08L687JB0009549 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 21 Sep 2020 14:08:07 +0800 Received: from RSEXMBS01.realsil.com.cn (172.29.17.195) by RSEXMBS02.realsil.com.cn (172.29.17.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Mon, 21 Sep 2020 14:08:07 +0800 Received: from RSEXMBS01.realsil.com.cn ([fe80::9bf:166d:2689:5847]) by RSEXMBS01.realsil.com.cn ([fe80::9bf:166d:2689:5847%7]) with mapi id 15.01.2044.004; Mon, 21 Sep 2020 14:08:06 +0800 From: =?gb2312?B?wr3W7M6w?= <alex_lu@realsil.com.cn> To: Marcel Holtmann <marcel@holtmann.org> CC: Johan Hedberg <johan.hedberg@gmail.com>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, open list <linux-kernel@vger.kernel.org>, Max Chou <max.chou@realtek.com> Subject: Re: [PATCH] Bluetooth: Fix the vulnerable issue on enc key size Thread-Topic: [PATCH] Bluetooth: Fix the vulnerable issue on enc key size Thread-Index: AdaP2rT2rqRD8iEeQ421X+FBubBc7w== Date: Mon, 21 Sep 2020 06:08:06 +0000 Message-ID: <21f9469eda2747eca351a1cb811a4834@realsil.com.cn> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.29.36.107] Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: base64 MIME-Version: 1.0 Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.70 / 15.00 / 15.00 X-Rspamd-Queue-Id: 41FD440976 X-Rspamd-UID: 10c482 SGkgTWFyY2VsLA0KDQo+IE9uIFNlcHRlbWJlciAyMCwgMjAyMCAxNDoxMCwgTWFyY2VsIEhvbHRt YW5uIHdyb3RlOg0KPiANCj4gSGkgQWxleCwNCj4gDQo+ID4gV2hlbiBzb21lb25lIGF0dGFja3Mg dGhlIHNlcnZpY2UgcHJvdmlkZXIsIGl0IGNyZWF0ZXMgY29ubmVjdGlvbiwNCj4gPiBhdXRoZW50 aWNhdGVzLiBUaGVuIGl0IHJlcXVlc3RzIGtleSBzaXplIG9mIG9uZSBieXRlIGFuZCBpdCBpZGVu dGlmaWVzDQo+ID4gdGhlIGtleSB3aXRoIGJydXRlIGZvcmNlIG1ldGhvZHMuDQo+ID4NCj4gPiBB ZnRlciBsMmNhcCBpbmZvIHJlcS9yZXNwIGV4Y2hhbmdlIGlzIGNvbXBsZXRlLiB0aGUgYXR0YWNr ZXIgc2VuZHMgbDJjYXANCj4gPiBjb25uZWN0IHdpdGggc3BlY2lmaWMgUFNNLg0KPiA+DQo+ID4g SW4gYWJvdmUgcHJvY2VkdXJlLCB0aGVyZSBpcyBubyBjaGFuY2UgZm9yIHRoZSBzZXJ2aWNlIHBy b3ZpZGVyIHRvIGNoZWNrDQo+ID4gdGhlIGVuY3J5cHRpb24ga2V5IHNpemUgYmVmb3JlIGwyY2Fw X2Nvbm5lY3QoKS4gQmVjYXVzZSB0aGUgc3RhdGUgb2YNCj4gPiBsMmNhcCBjaGFuIGluIGNvbm4t PmNoYW5fbCBpcyBCVF9MSVNURU4sIHRoZXJlIGlzIG5vIGwyY2FwIGNoYW4gd2l0aCB0aGUNCj4g PiBzdGF0ZSBvZiBCVF9DT05ORUNUIG9yIEJUX0NPTk5FQ1QyLg0KPiA+DQo+ID4gU28gc2Vydmlj ZSBwcm92aWRlciBzaG91bGQgY2hlY2sgdGhlIGVuY3J5cHRpb24ga2V5IHNpemUgaW4NCj4gPiBs MmNhcF9jb25uZWN0KCkNCj4gPg0KPiA+IFNpZ25lZC1vZmYtYnk6IEFsZXggTHUgPGFsZXhfbHVA cmVhbHNpbC5jb20uY24+DQo+ID4gLS0tDQo+ID4gbmV0L2JsdWV0b290aC9sMmNhcF9jb3JlLmMg fCA3ICsrKysrKysNCj4gPiAxIGZpbGUgY2hhbmdlZCwgNyBpbnNlcnRpb25zKCspDQo+ID4NCj4g PiBkaWZmIC0tZ2l0IGEvbmV0L2JsdWV0b290aC9sMmNhcF9jb3JlLmMgYi9uZXQvYmx1ZXRvb3Ro L2wyY2FwX2NvcmUuYw0KPiA+IGluZGV4IGFkZTgzZTIyNDU2Ny4uNjNkZjk2MWQ0MDJkIDEwMDY0 NA0KPiA+IC0tLSBhL25ldC9ibHVldG9vdGgvbDJjYXBfY29yZS5jDQo+ID4gKysrIGIvbmV0L2Js dWV0b290aC9sMmNhcF9jb3JlLmMNCj4gPiBAQCAtNDE1MCw2ICs0MTUwLDEzIEBAIHN0YXRpYyBz dHJ1Y3QgbDJjYXBfY2hhbiAqbDJjYXBfY29ubmVjdChzdHJ1Y3QNCj4gbDJjYXBfY29ubiAqY29u biwNCj4gPg0KPiA+IAlpZiAoY29ubi0+aW5mb19zdGF0ZSAmIEwyQ0FQX0lORk9fRkVBVF9NQVNL X1JFUV9ET05FKSB7DQo+ID4gCQlpZiAobDJjYXBfY2hhbl9jaGVja19zZWN1cml0eShjaGFuLCBm YWxzZSkpIHsNCj4gPiArCQkJaWYgKCFsMmNhcF9jaGVja19lbmNfa2V5X3NpemUoY29ubi0+aGNv bikpIHsNCj4gPiArCQkJCWwyY2FwX3N0YXRlX2NoYW5nZShjaGFuLCBCVF9ESVNDT05OKTsNCj4g PiArCQkJCV9fc2V0X2NoYW5fdGltZXIoY2hhbiwNCj4gTDJDQVBfRElTQ19USU1FT1VUKTsNCj4g PiArCQkJCXJlc3VsdCA9IEwyQ0FQX0NSX1NFQ19CTE9DSzsNCj4gPiArCQkJCXN0YXR1cyA9IEwy Q0FQX0NTX05PX0lORk87DQo+ID4gKwkJCQlnb3RvIHJlc3BvbnNlOw0KPiA+ICsJCQl9DQo+ID4g CQkJaWYgKHRlc3RfYml0KEZMQUdfREVGRVJfU0VUVVAsICZjaGFuLT5mbGFncykpIHsNCj4gPiAJ CQkJbDJjYXBfc3RhdGVfY2hhbmdlKGNoYW4sIEJUX0NPTk5FQ1QyKTsNCj4gPiAJCQkJcmVzdWx0 ID0gTDJDQVBfQ1JfUEVORDsNCj4gDQo+IEkgYW0gbm90IGZvbGxvd2luZyB3aGF0IHlvdSBhcmUg dHJ5aW5nIHRvIGZpeCBoZXJlLiBDYW4geW91IHNob3cgdGhpcyB3aXRoIGENCj4gYnRtb24gdHJh Y2UgZnJvbSBhbiBhdHRhY2tpbmcgZGV2aWNlPw0KPiANCj4gUmVnYXJkcw0KPiANCj4gTWFyY2Vs DQo+IA0KPiANCg0KSSdtIHNvcnJ5LCBJIGRpZG4ndCBoYXZlIGJ0bW9uIHRyYWNlIGZyb20gYW4g YXR0YWNraW5nIGRldmljZS4NCkkgZGlkbid0IGhhdmUgdGhlIHJlYWwgYXR0YWNraW5nIGRldmlj ZS4gSSBqdXN0IHNpbXVsYXRlIHRoZSBhdHRhY2tpbmcuDQpJIGhhdmUgYSBkZXZpY2UgdGhhdCBj YW4gY3JlYXRlIG9uZSBieXRlIHNpemUgZW5jcnlwdGlvbiBrZXkuDQpJdCB1c2VzIHRoZSBsaW5r IGtleSB0aGF0IHdhcyBwcm9kdWNlZCBieSBwYWlyaW5nIHdpdGggdGhlIHNlcnZpY2UgcHJvdmlk ZXIuIEFjdHVhbGx5IHRoZSBLTk9CIChLZXkgTmVnb3RpYXRpb24gb2YgQmx1ZXRvb3RoIEF0dGFj aykgc2F5cywgdGhlIGxpbmsga2V5IGlzIHVubmVjZXNzYXJ5IGZvciB0aGUgcmVjb25uZWN0aW9u Lg0KSSB1c2UgdGhpcyBkZXZpY2UgdG8gcmVjb25uZWN0IHRvIHNlcnZpY2UgcHJvdmlkZXIsIGFu ZCB0aGVuIGluaXRpYXRlIHRoZSBLZXkgTmVnb3RpYXRpb24gZm9yIG9uZSBieXRlIHNpemUgZW5j cnlwdGlvbiBrZXkuIEFjdHVhbGx5IHRoZSBhdHRhY2tlciBpZGVudGlmaWVkIHRoZSBlbmNyeXB0 aW9uIGtleSB3aXRoIHNvbWUgYnJ1dGUgZm9yY2UgbWV0aG9kcy4NCg0KSSB3YW50IHRvIHByb3Zp ZGUgdGhlIHRyYWNlIG9uIHNlcnZpY2UgcHJvdmlkZXIgc2lkZS4NCg0KPiBIQ0kgRXZlbnQ6IENv bm5lY3QgUmVxdWVzdCAoMHgwNCkgcGxlbiAxMCAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAjMSBbaGNpMF0gNDIuOTMyNTg1DQogICAgICAgIEFkZHJlc3M6 IDAwOjNGOjIyOkVFOjExOjMzIChPVUkgMDAtM0YtMjIpDQogICAgICAgIENsYXNzOiAweDAwMDEw Yw0KICAgICAgICAgIE1ham9yIGNsYXNzOiBDb21wdXRlciAoZGVza3RvcCwgbm90ZWJvb2ssIFBE QSwgb3JnYW5pemVycykNCiAgICAgICAgICBNaW5vciBjbGFzczogTGFwdG9wDQogICAgICAgIExp bmsgdHlwZTogQUNMICgweDAxKQ0KPCBIQ0kgQ29tbWFuZDogQWNjZXB0IENvbm5lY3Rpb24gUmVx dWVzdCAoMHgwMXwweDAwMDkpIHBsZW4gNyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAj MiBbaGNpMF0gNDIuOTMyNzk1DQogICAgICAgIEFkZHJlc3M6IDAwOjNGOjIyOkVFOjExOjMzIChP VUkgMDAtM0YtMjIpDQogICAgICAgIFJvbGU6IFNsYXZlICgweDAxKQ0KPiBIQ0kgRXZlbnQ6IENv bW1hbmQgU3RhdHVzICgweDBmKSBwbGVuIDQgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAjMyBbaGNpMF0gNDIuOTM0NTA5DQogICAgICBBY2NlcHQgQ29u bmVjdGlvbiBSZXF1ZXN0ICgweDAxfDB4MDAwOSkgbmNtZCAyDQogICAgICAgIFN0YXR1czogU3Vj Y2VzcyAoMHgwMCkNCj4gSENJIEV2ZW50OiBDb25uZWN0IENvbXBsZXRlICgweDAzKSBwbGVuIDEx ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIzQgW2hjaTBd IDQyLjk2NDU2OA0KICAgICAgICBTdGF0dXM6IFN1Y2Nlc3MgKDB4MDApDQogICAgICAgIEhhbmRs ZTogMQ0KICAgICAgICBBZGRyZXNzOiAwMDozRjoyMjpFRToxMTozMyAoT1VJIDAwLTNGLTIyKQ0K ICAgICAgICBMaW5rIHR5cGU6IEFDTCAoMHgwMSkNCiAgICAgICAgRW5jcnlwdGlvbjogRGlzYWJs ZWQgKDB4MDApDQo8IEhDSSBDb21tYW5kOiBSZWFkIFJlbW90ZSBTdXBwb3J0ZWQgRmVhdHVyZXMg KDB4MDF8MHgwMDFiKSBwbGVuIDIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICM1IFtoY2kwXSA0 Mi45NjQ4MTUNCiAgICAgICAgSGFuZGxlOiAxDQo+IEhDSSBFdmVudDogTWF4IFNsb3RzIENoYW5n ZSAoMHgxYikgcGxlbiAzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICM2IFtoY2kwXSA0Mi45NzA1MTYNCiAgICAgICAgSGFuZGxlOiAxDQogICAgICAgIE1h eCBzbG90czogNQ0KPiBIQ0kgRXZlbnQ6IENvbW1hbmQgU3RhdHVzICgweDBmKSBwbGVuIDQgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAjNyBbaGNpMF0g NDIuOTcxNTkyDQogICAgICBSZWFkIFJlbW90ZSBTdXBwb3J0ZWQgRmVhdHVyZXMgKDB4MDF8MHgw MDFiKSBuY21kIDINCiAgICAgICAgU3RhdHVzOiBTdWNjZXNzICgweDAwKQ0KPiBIQ0kgRXZlbnQ6 IE1heCBTbG90cyBDaGFuZ2UgKDB4MWIpIHBsZW4gMyAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAjOCBbaGNpMF0gNDIuOTc2NTE2DQogICAgICAgIEhhbmRs ZTogMQ0KICAgICAgICBNYXggc2xvdHM6IDUNCj4gSENJIEV2ZW50OiBSZWFkIFJlbW90ZSBTdXBw b3J0ZWQgRmVhdHVyZXMgKDB4MGIpIHBsZW4gMTEgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIzkgW2hjaTBdIDQyLjk4MDUyMQ0KICAgICAgICBTdGF0dXM6IFN1Y2Nlc3MgKDB4MDAp DQogICAgICAgIEhhbmRsZTogMQ0KICAgICAgICBGZWF0dXJlczogMHhmZiAweGZmIDB4ZmYgMHhm ZSAweGRiIDB4ZmQgMHg3YiAweDg3DQogICAgICAgICAgMyBzbG90IHBhY2tldHMNCiAgICAgICAg ICA1IHNsb3QgcGFja2V0cw0KICAgICAgICAgIEVuY3J5cHRpb24NCiAgICAgICAgICBTbG90IG9m ZnNldA0KICAgICAgICAgIFRpbWluZyBhY2N1cmFjeQ0KICAgICAgICAgIFJvbGUgc3dpdGNoDQog ICAgICAgICAgSG9sZCBtb2RlDQogICAgICAgICAgU25pZmYgbW9kZQ0KICAgICAgICAgIFBhcmsg c3RhdGUNCiAgICAgICAgICBQb3dlciBjb250cm9sIHJlcXVlc3RzDQogICAgICAgICAgQ2hhbm5l bCBxdWFsaXR5IGRyaXZlbiBkYXRhIHJhdGUgKENRRERSKQ0KICAgICAgICAgIFNDTyBsaW5rDQog ICAgICAgICAgSFYyIHBhY2tldHMNCiAgICAgICAgICBIVjMgcGFja2V0cw0KICAgICAgICAgIHUt bGF3IGxvZyBzeW5jaHJvbm91cyBkYXRhDQogICAgICAgICAgQS1sYXcgbG9nIHN5bmNocm9ub3Vz IGRhdGENCiAgICAgICAgICBDVlNEIHN5bmNocm9ub3VzIGRhdGENCiAgICAgICAgICBQYWdpbmcg cGFyYW1ldGVyIG5lZ290aWF0aW9uDQogICAgICAgICAgUG93ZXIgY29udHJvbA0KICAgICAgICAg IFRyYW5zcGFyZW50IHN5bmNocm9ub3VzIGRhdGENCiAgICAgICAgICBGbG93IGNvbnRyb2wgbGFn IChsZWFzdCBzaWduaWZpY2FudCBiaXQpDQogICAgICAgICAgRmxvdyBjb250cm9sIGxhZyAobWlk ZGxlIGJpdCkNCiAgICAgICAgICBGbG93IGNvbnRyb2wgbGFnIChtb3N0IHNpZ25pZmljYW50IGJp dCkNCiAgICAgICAgICBCcm9hZGNhc3QgRW5jcnlwdGlvbg0KICAgICAgICAgIEVuaGFuY2VkIERh dGEgUmF0ZSBBQ0wgMiBNYnBzIG1vZGUNCiAgICAgICAgICBFbmhhbmNlZCBEYXRhIFJhdGUgQUNM IDMgTWJwcyBtb2RlDQogICAgICAgICAgRW5oYW5jZWQgaW5xdWlyeSBzY2FuDQogICAgICAgICAg SW50ZXJsYWNlZCBpbnF1aXJ5IHNjYW4NCiAgICAgICAgICBJbnRlcmxhY2VkIHBhZ2Ugc2Nhbg0K ICAgICAgICAgIFJTU0kgd2l0aCBpbnF1aXJ5IHJlc3VsdHMNCiAgICAgICAgICBFeHRlbmRlZCBT Q08gbGluayAoRVYzIHBhY2tldHMpDQogICAgICAgICAgRVY0IHBhY2tldHMNCiAgICAgICAgICBF VjUgcGFja2V0cw0KICAgICAgICAgIEFGSCBjYXBhYmxlIHNsYXZlDQogICAgICAgICAgQUZIIGNs YXNzaWZpY2F0aW9uIHNsYXZlDQogICAgICAgICAgTEUgU3VwcG9ydGVkIChDb250cm9sbGVyKQ0K ICAgICAgICAgIDMtc2xvdCBFbmhhbmNlZCBEYXRhIFJhdGUgQUNMIHBhY2tldHMNCiAgICAgICAg ICA1LXNsb3QgRW5oYW5jZWQgRGF0YSBSYXRlIEFDTCBwYWNrZXRzDQogICAgICAgICAgUGF1c2Ug ZW5jcnlwdGlvbg0KICAgICAgICAgIEFGSCBjYXBhYmxlIG1hc3Rlcg0KICAgICAgICAgIEFGSCBj bGFzc2lmaWNhdGlvbiBtYXN0ZXINCiAgICAgICAgICBFbmhhbmNlZCBEYXRhIFJhdGUgZVNDTyAy IE1icHMgbW9kZQ0KICAgICAgICAgIEVuaGFuY2VkIERhdGEgUmF0ZSBlU0NPIDMgTWJwcyBtb2Rl DQogICAgICAgICAgMy1zbG90IEVuaGFuY2VkIERhdGEgUmF0ZSBlU0NPIHBhY2tldHMNCiAgICAg ICAgICBFeHRlbmRlZCBJbnF1aXJ5IFJlc3BvbnNlDQogICAgICAgICAgU2ltdWx0YW5lb3VzIExF IGFuZCBCUi9FRFIgKENvbnRyb2xsZXIpDQogICAgICAgICAgU2VjdXJlIFNpbXBsZSBQYWlyaW5n DQogICAgICAgICAgRW5jYXBzdWxhdGVkIFBEVQ0KICAgICAgICAgIEVycm9uZW91cyBEYXRhIFJl cG9ydGluZw0KICAgICAgICAgIE5vbi1mbHVzaGFibGUgUGFja2V0IEJvdW5kYXJ5IEZsYWcNCiAg ICAgICAgICBMaW5rIFN1cGVydmlzaW9uIFRpbWVvdXQgQ2hhbmdlZCBFdmVudA0KICAgICAgICAg IElucXVpcnkgVFggUG93ZXIgTGV2ZWwNCiAgICAgICAgICBFbmhhbmNlZCBQb3dlciBDb250cm9s DQogICAgICAgICAgRXh0ZW5kZWQgZmVhdHVyZXMNCjwgSENJIENvbW1hbmQ6IFJlYWQgUmVtb3Rl IEV4dGVuZGVkIEZlYXR1cmVzICgweDAxfDB4MDAxYykgcGxlbiAzICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAjMTAgW2hjaTBdIDQyLjk4MDY3Nw0KICAgICAgICBIYW5kbGU6IDENCiAgICAgICAg UGFnZTogMQ0KPiBIQ0kgRXZlbnQ6IENvbW1hbmQgU3RhdHVzICgweDBmKSBwbGVuIDQgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMxMSBbaGNpMF0gNDIu OTgyNTEwDQogICAgICBSZWFkIFJlbW90ZSBFeHRlbmRlZCBGZWF0dXJlcyAoMHgwMXwweDAwMWMp IG5jbWQgMg0KICAgICAgICBTdGF0dXM6IFN1Y2Nlc3MgKDB4MDApDQo+IEhDSSBFdmVudDogUmVh ZCBSZW1vdGUgRXh0ZW5kZWQgRmVhdHVyZXMgKDB4MjMpIHBsZW4gMTMgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIzEyIFtoY2kwXSA0Mi45ODk1MjMNCiAgICAgICAgU3RhdHVzOiBT dWNjZXNzICgweDAwKQ0KICAgICAgICBIYW5kbGU6IDENCiAgICAgICAgUGFnZTogMS8yDQogICAg ICAgIEZlYXR1cmVzOiAweDAzIDB4MDAgMHgwMCAweDAwIDB4MDAgMHgwMCAweDAwIDB4MDANCiAg ICAgICAgICBTZWN1cmUgU2ltcGxlIFBhaXJpbmcgKEhvc3QgU3VwcG9ydCkNCiAgICAgICAgICBM RSBTdXBwb3J0ZWQgKEhvc3QpDQo8IEhDSSBDb21tYW5kOiBSZW1vdGUgTmFtZSBSZXF1ZXN0ICgw eDAxfDB4MDAxOSkgcGxlbiAxMCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIzEz IFtoY2kwXSA0Mi45ODk2OTcNCiAgICAgICAgQWRkcmVzczogMDA6M0Y6MjI6RUU6MTE6MzMgKE9V SSAwMC0zRi0yMikNCiAgICAgICAgUGFnZSBzY2FuIHJlcGV0aXRpb24gbW9kZTogUjIgKDB4MDIp DQogICAgICAgIFBhZ2Ugc2NhbiBtb2RlOiBNYW5kYXRvcnkgKDB4MDApDQogICAgICAgIENsb2Nr IG9mZnNldDogMHgwMDAwDQo8IEFDTCBEYXRhIFRYOiBIYW5kbGUgMSBmbGFncyAweDAwIGRsZW4g MTAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIzE0IFto Y2kwXSA0Mi45ODk3MjANCiAgICAgIEwyQ0FQOiBJbmZvcm1hdGlvbiBSZXF1ZXN0ICgweDBhKSBp ZGVudCAxIGxlbiAyDQogICAgICAgIFR5cGU6IEV4dGVuZGVkIGZlYXR1cmVzIHN1cHBvcnRlZCAo MHgwMDAyKQ0KPiBIQ0kgRXZlbnQ6IENvbW1hbmQgU3RhdHVzICgweDBmKSBwbGVuIDQgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMxNSBbaGNpMF0gNDIu OTkxNTEwDQogICAgICBSZW1vdGUgTmFtZSBSZXF1ZXN0ICgweDAxfDB4MDAxOSkgbmNtZCAyDQog ICAgICAgIFN0YXR1czogU3VjY2VzcyAoMHgwMCkNCj4gSENJIEV2ZW50OiBOdW1iZXIgb2YgQ29t cGxldGVkIFBhY2tldHMgKDB4MTMpIHBsZW4gNSAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAjMTYgW2hjaTBdIDQyLjk5MjQ5OA0KICAgICAgICBOdW0gaGFuZGxlczogMQ0KICAg ICAgICBIYW5kbGU6IDENCiAgICAgICAgQ291bnQ6IDENCj4gSENJIEV2ZW50OiBSZW1vdGUgTmFt ZSBSZXEgQ29tcGxldGUgKDB4MDcpIHBsZW4gMjU1ICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAjMTcgW2hjaTBdIDQzLjAxMTUxNA0KICAgICAgICBTdGF0dXM6IFN1Y2Nlc3Mg KDB4MDApDQogICAgICAgIEFkZHJlc3M6IDAwOjNGOjIyOkVFOjExOjMzIChPVUkgMDAtM0YtMjIp DQogICAgICAgIE5hbWU6IGRlbGwNCkAgTUdNVCBFdmVudDogRGV2aWNlIENvbm5lY3RlZCAoMHgw MDBiKSBwbGVuIDI0ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgezB4MDAw Mn0gW2hjaTBdIDQzLjAxMTU3OA0KICAgICAgICBCUi9FRFIgQWRkcmVzczogMDA6M0Y6MjI6RUU6 MTE6MzMgKE9VSSAwMC0zRi0yMikNCiAgICAgICAgRmxhZ3M6IDB4MDAwMDAwMDANCiAgICAgICAg RGF0YSBsZW5ndGg6IDExDQogICAgICAgIE5hbWUgKGNvbXBsZXRlKTogZGVsbA0KICAgICAgICBD bGFzczogMHgwMDAxMGMNCiAgICAgICAgICBNYWpvciBjbGFzczogQ29tcHV0ZXIgKGRlc2t0b3As IG5vdGVib29rLCBQREEsIG9yZ2FuaXplcnMpDQogICAgICAgICAgTWlub3IgY2xhc3M6IExhcHRv cA0KQCBNR01UIEV2ZW50OiBEZXZpY2UgQ29ubmVjdGVkICgweDAwMGIpIHBsZW4gMjQgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7MHgwMDAxfSBbaGNpMF0gNDMuMDExNTc4 DQogICAgICAgIEJSL0VEUiBBZGRyZXNzOiAwMDozRjoyMjpFRToxMTozMyAoT1VJIDAwLTNGLTIy KQ0KICAgICAgICBGbGFnczogMHgwMDAwMDAwMA0KICAgICAgICBEYXRhIGxlbmd0aDogMTENCiAg ICAgICAgTmFtZSAoY29tcGxldGUpOiBkZWxsDQogICAgICAgIENsYXNzOiAweDAwMDEwYw0KICAg ICAgICAgIE1ham9yIGNsYXNzOiBDb21wdXRlciAoZGVza3RvcCwgbm90ZWJvb2ssIFBEQSwgb3Jn YW5pemVycykNCiAgICAgICAgICBNaW5vciBjbGFzczogTGFwdG9wDQo+IEhDSSBFdmVudDogTGlu ayBLZXkgUmVxdWVzdCAoMHgxNykgcGxlbiA2ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIzE4IFtoY2kwXSA0My4wMjE1MTANCiAgICAgICAgQWRkcmVzczog MDA6M0Y6MjI6RUU6MTE6MzMgKE9VSSAwMC0zRi0yMikNCjwgSENJIENvbW1hbmQ6IExpbmsgS2V5 IFJlcXVlc3QgUmVwbHkgKDB4MDF8MHgwMDBiKSBwbGVuIDIyICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAjMTkgW2hjaTBdIDQzLjAyMTU4MA0KICAgICAgICBBZGRyZXNzOiAwMDozRjoy MjpFRToxMTozMyAoT1VJIDAwLTNGLTIyKQ0KICAgICAgICBMaW5rIGtleTogOGVkY2JiY2ZiZmQ5 YmUxMDJiYWMwMDA0Y2M4ODdjODgNCj4gSENJIEV2ZW50OiBDb21tYW5kIENvbXBsZXRlICgweDBl KSBwbGVuIDEwICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAj MjAgW2hjaTBdIDQzLjAyNzU0NA0KICAgICAgTGluayBLZXkgUmVxdWVzdCBSZXBseSAoMHgwMXww eDAwMGIpIG5jbWQgMg0KICAgICAgICBTdGF0dXM6IFN1Y2Nlc3MgKDB4MDApDQogICAgICAgIEFk ZHJlc3M6IDAwOjNGOjIyOkVFOjExOjMzIChPVUkgMDAtM0YtMjIpDQo+IEhDSSBFdmVudDogRW5j cnlwdGlvbiBDaGFuZ2UgKDB4MDgpIHBsZW4gNCAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIzIxIFtoY2kwXSA0My4wODk2OTINCiAgICAgICAgU3RhdHVzOiBT dWNjZXNzICgweDAwKQ0KICAgICAgICBIYW5kbGU6IDENCiAgICAgICAgRW5jcnlwdGlvbjogRW5h YmxlZCB3aXRoIEUwICgweDAxKQ0KPCBIQ0kgQ29tbWFuZDogUmVhZCBFbmNyeXB0aW9uIEtleSBT aXplICgweDA1fDB4MDAwOCkgcGxlbiAyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMy MiBbaGNpMF0gNDMuMDg5ODU5DQogICAgICAgIEhhbmRsZTogMQ0KPiBIQ0kgRXZlbnQ6IENvbW1h bmQgQ29tcGxldGUgKDB4MGUpIHBsZW4gNyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICMyMyBbaGNpMF0gNDMuMDkxNTI4DQogICAgICBSZWFkIEVuY3J5cHRp b24gS2V5IFNpemUgKDB4MDV8MHgwMDA4KSBuY21kIDINCiAgICAgICAgU3RhdHVzOiBTdWNjZXNz ICgweDAwKQ0KICAgICAgICBIYW5kbGU6IDENCiAgICAgICAgS2V5IHNpemU6IDENCj4gQUNMIERh dGEgUlg6IEhhbmRsZSAxIGZsYWdzIDB4MDIgZGxlbiAxMCAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAjMjQgW2hjaTBdIDQzLjE0MDg4OA0KICAgICAgTDJD QVA6IEluZm9ybWF0aW9uIFJlcXVlc3QgKDB4MGEpIGlkZW50IDEgbGVuIDINCiAgICAgICAgVHlw ZTogRXh0ZW5kZWQgZmVhdHVyZXMgc3VwcG9ydGVkICgweDAwMDIpDQo8IEFDTCBEYXRhIFRYOiBI YW5kbGUgMSBmbGFncyAweDAwIGRsZW4gMTYgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIzI1IFtoY2kwXSA0My4xNDA5NTENCiAgICAgIEwyQ0FQOiBJbmZv cm1hdGlvbiBSZXNwb25zZSAoMHgwYikgaWRlbnQgMSBsZW4gOA0KICAgICAgICBUeXBlOiBFeHRl bmRlZCBmZWF0dXJlcyBzdXBwb3J0ZWQgKDB4MDAwMikNCiAgICAgICAgUmVzdWx0OiBTdWNjZXNz ICgweDAwMDApDQogICAgICAgIEZlYXR1cmVzOiAweDAwMDAwMmI4DQogICAgICAgICAgRW5oYW5j ZWQgUmV0cmFuc21pc3Npb24gTW9kZQ0KICAgICAgICAgIFN0cmVhbWluZyBNb2RlDQogICAgICAg ICAgRkNTIE9wdGlvbg0KICAgICAgICAgIEZpeGVkIENoYW5uZWxzDQogICAgICAgICAgVW5pY2Fz dCBDb25uZWN0aW9ubGVzcyBEYXRhIFJlY2VwdGlvbg0KPiBBQ0wgRGF0YSBSWDogSGFuZGxlIDEg ZmxhZ3MgMHgwMiBkbGVuIDE2ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICMyNiBbaGNpMF0gNDMuMTQyMzA4DQogICAgICBMMkNBUDogSW5mb3JtYXRpb24g UmVzcG9uc2UgKDB4MGIpIGlkZW50IDEgbGVuIDgNCiAgICAgICAgVHlwZTogRXh0ZW5kZWQgZmVh dHVyZXMgc3VwcG9ydGVkICgweDAwMDIpDQogICAgICAgIFJlc3VsdDogU3VjY2VzcyAoMHgwMDAw KQ0KICAgICAgICBGZWF0dXJlczogMHgwMDAwMDJiOA0KICAgICAgICAgIEVuaGFuY2VkIFJldHJh bnNtaXNzaW9uIE1vZGUNCiAgICAgICAgICBTdHJlYW1pbmcgTW9kZQ0KICAgICAgICAgIEZDUyBP cHRpb24NCiAgICAgICAgICBGaXhlZCBDaGFubmVscw0KICAgICAgICAgIFVuaWNhc3QgQ29ubmVj dGlvbmxlc3MgRGF0YSBSZWNlcHRpb24NCjwgQUNMIERhdGEgVFg6IEhhbmRsZSAxIGZsYWdzIDB4 MDAgZGxlbiAxMCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAjMjcgW2hjaTBdIDQzLjE0MjM2OQ0KICAgICAgTDJDQVA6IEluZm9ybWF0aW9uIFJlcXVlc3Qg KDB4MGEpIGlkZW50IDIgbGVuIDINCiAgICAgICAgVHlwZTogRml4ZWQgY2hhbm5lbHMgc3VwcG9y dGVkICgweDAwMDMpDQo+IEhDSSBFdmVudDogTnVtYmVyIG9mIENvbXBsZXRlZCBQYWNrZXRzICgw eDEzKSBwbGVuIDUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIzI4IFtoY2kw XSA0My4xNDM1NjcNCiAgICAgICAgTnVtIGhhbmRsZXM6IDENCiAgICAgICAgSGFuZGxlOiAxDQog ICAgICAgIENvdW50OiAxDQo+IEFDTCBEYXRhIFJYOiBIYW5kbGUgMSBmbGFncyAweDAyIGRsZW4g MTAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIzI5IFto Y2kwXSA0My4xNDUwMzQNCiAgICAgIEwyQ0FQOiBJbmZvcm1hdGlvbiBSZXF1ZXN0ICgweDBhKSBp ZGVudCAyIGxlbiAyDQogICAgICAgIFR5cGU6IEZpeGVkIGNoYW5uZWxzIHN1cHBvcnRlZCAoMHgw MDAzKQ0KPCBBQ0wgRGF0YSBUWDogSGFuZGxlIDEgZmxhZ3MgMHgwMCBkbGVuIDIwICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMzMCBbaGNpMF0gNDMuMTQ1 MDkzDQogICAgICBMMkNBUDogSW5mb3JtYXRpb24gUmVzcG9uc2UgKDB4MGIpIGlkZW50IDIgbGVu IDEyDQogICAgICAgIFR5cGU6IEZpeGVkIGNoYW5uZWxzIHN1cHBvcnRlZCAoMHgwMDAzKQ0KICAg ICAgICBSZXN1bHQ6IFN1Y2Nlc3MgKDB4MDAwMCkNCiAgICAgICAgQ2hhbm5lbHM6IDB4MDAwMDAw MDAwMDAwMDAwNg0KICAgICAgICAgIEwyQ0FQIFNpZ25hbGluZyAoQlIvRURSKQ0KICAgICAgICAg IENvbm5lY3Rpb25sZXNzIHJlY2VwdGlvbg0KPiBIQ0kgRXZlbnQ6IE51bWJlciBvZiBDb21wbGV0 ZWQgUGFja2V0cyAoMHgxMykgcGxlbiA1ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICMzMSBbaGNpMF0gNDMuMTQ1NTIzDQogICAgICAgIE51bSBoYW5kbGVzOiAxDQogICAgICAg IEhhbmRsZTogMQ0KICAgICAgICBDb3VudDogMQ0KPiBBQ0wgRGF0YSBSWDogSGFuZGxlIDEgZmxh Z3MgMHgwMiBkbGVuIDIwICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICMzMiBbaGNpMF0gNDMuMTQ1OTIyDQogICAgICBMMkNBUDogSW5mb3JtYXRpb24gUmVz cG9uc2UgKDB4MGIpIGlkZW50IDIgbGVuIDEyDQogICAgICAgIFR5cGU6IEZpeGVkIGNoYW5uZWxz IHN1cHBvcnRlZCAoMHgwMDAzKQ0KICAgICAgICBSZXN1bHQ6IFN1Y2Nlc3MgKDB4MDAwMCkNCiAg ICAgICAgQ2hhbm5lbHM6IDB4MDAwMDAwMDAwMDAwMDAwNg0KICAgICAgICAgIEwyQ0FQIFNpZ25h bGluZyAoQlIvRURSKQ0KICAgICAgICAgIENvbm5lY3Rpb25sZXNzIHJlY2VwdGlvbg0KPiBIQ0kg RXZlbnQ6IE51bWJlciBvZiBDb21wbGV0ZWQgUGFja2V0cyAoMHgxMykgcGxlbiA1ICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMzMyBbaGNpMF0gNDMuMTQ3NTQ4DQogICAgICAg IE51bSBoYW5kbGVzOiAxDQogICAgICAgIEhhbmRsZTogMQ0KICAgICAgICBDb3VudDogMQ0KPiBB Q0wgRGF0YSBSWDogSGFuZGxlIDEgZmxhZ3MgMHgwMiBkbGVuIDEyICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMzNCBbaGNpMF0gNDMuMTQ4NDA1DQogICAg ICBMMkNBUDogQ29ubmVjdGlvbiBSZXF1ZXN0ICgweDAyKSBpZGVudCAzIGxlbiA0DQogICAgICAg IFBTTTogMyAoMHgwMDAzKQ0KICAgICAgICBTb3VyY2UgQ0lEOiA2NA0KPCBBQ0wgRGF0YSBUWDog SGFuZGxlIDEgZmxhZ3MgMHgwMCBkbGVuIDE2ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICMzNSBbaGNpMF0gNDMuMTQ4NTk0DQogICAgICBMMkNBUDogQ29u bmVjdGlvbiBSZXNwb25zZSAoMHgwMykgaWRlbnQgMyBsZW4gOA0KICAgICAgICBEZXN0aW5hdGlv biBDSUQ6IDY0DQogICAgICAgIFNvdXJjZSBDSUQ6IDY0DQogICAgICAgIFJlc3VsdDogQ29ubmVj dGlvbiBzdWNjZXNzZnVsICgweDAwMDApDQogICAgICAgIFN0YXR1czogTm8gZnVydGhlciBpbmZv cm1hdGlvbiBhdmFpbGFibGUgKDB4MDAwMCkNCjwgQUNMIERhdGEgVFg6IEhhbmRsZSAxIGZsYWdz IDB4MDAgZGxlbiAyMyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAjMzYgW2hjaTBdIDQzLjE0ODYyMg0KICAgICAgTDJDQVA6IENvbmZpZ3VyZSBSZXF1ZXN0 ICgweDA0KSBpZGVudCAzIGxlbiAxNQ0KICAgICAgICBEZXN0aW5hdGlvbiBDSUQ6IDY0DQogICAg ICAgIEZsYWdzOiAweDAwMDANCiAgICAgICAgT3B0aW9uOiBSZXRyYW5zbWlzc2lvbiBhbmQgRmxv dyBDb250cm9sICgweDA0KSBbbWFuZGF0b3J5XQ0KICAgICAgICAgIE1vZGU6IEJhc2ljICgweDAw KQ0KICAgICAgICAgIFRYIHdpbmRvdyBzaXplOiAwDQogICAgICAgICAgTWF4IHRyYW5zbWl0OiAw DQogICAgICAgICAgUmV0cmFuc21pc3Npb24gdGltZW91dDogMA0KICAgICAgICAgIE1vbml0b3Ig dGltZW91dDogMA0KICAgICAgICAgIE1heGltdW0gUERVIHNpemU6IDANCjwgSENJIENvbW1hbmQ6 IFZlbmRvciAoMHgzZnwweDAwMTkpIHBsZW4gNSAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAjMzcgW2hjaTBdIDQzLjE0ODc0MQ0KICAgICAgICAwMSAwMSAw MCAwOCAwMCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLi4uLi4gICAgICAgICAg IA0KPiBIQ0kgRXZlbnQ6IENvbW1hbmQgQ29tcGxldGUgKDB4MGUpIHBsZW4gNCAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMzOCBbaGNpMF0gNDMuMTUwNTA2 DQogICAgICBWZW5kb3IgKDB4M2Z8MHgwMDE5KSBuY21kIDINCiAgICAgICAgU3RhdHVzOiBTdWNj ZXNzICgweDAwKQ0KPiBIQ0kgRXZlbnQ6IE51bWJlciBvZiBDb21wbGV0ZWQgUGFja2V0cyAoMHgx MykgcGxlbiA1ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMzOSBbaGNpMF0g NDMuMTUxNTAyDQogICAgICAgIE51bSBoYW5kbGVzOiAxDQogICAgICAgIEhhbmRsZTogMQ0KICAg ICAgICBDb3VudDogMQ0KPiBBQ0wgRGF0YSBSWDogSGFuZGxlIDEgZmxhZ3MgMHgwMiBkbGVuIDIz ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICM0MCBbaGNp MF0gNDMuMTUyNDI5DQogICAgICBMMkNBUDogQ29uZmlndXJlIFJlcXVlc3QgKDB4MDQpIGlkZW50 IDQgbGVuIDE1DQogICAgICAgIERlc3RpbmF0aW9uIENJRDogNjQNCiAgICAgICAgRmxhZ3M6IDB4 MDAwMA0KICAgICAgICBPcHRpb246IFJldHJhbnNtaXNzaW9uIGFuZCBGbG93IENvbnRyb2wgKDB4 MDQpIFttYW5kYXRvcnldDQogICAgICAgICAgTW9kZTogQmFzaWMgKDB4MDApDQogICAgICAgICAg VFggd2luZG93IHNpemU6IDANCiAgICAgICAgICBNYXggdHJhbnNtaXQ6IDANCiAgICAgICAgICBS ZXRyYW5zbWlzc2lvbiB0aW1lb3V0OiAwDQogICAgICAgICAgTW9uaXRvciB0aW1lb3V0OiAwDQog ICAgICAgICAgTWF4aW11bSBQRFUgc2l6ZTogMA0KPiBIQ0kgRXZlbnQ6IE51bWJlciBvZiBDb21w bGV0ZWQgUGFja2V0cyAoMHgxMykgcGxlbiA1ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICM0MSBbaGNpMF0gNDMuMTUyNDk0DQogICAgICAgIE51bSBoYW5kbGVzOiAxDQogICAg ICAgIEhhbmRsZTogMQ0KICAgICAgICBDb3VudDogMQ0KPCBBQ0wgRGF0YSBUWDogSGFuZGxlIDEg ZmxhZ3MgMHgwMCBkbGVuIDE4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICM0MiBbaGNpMF0gNDMuMTUyNTA4DQogICAgICBMMkNBUDogQ29uZmlndXJlIFJl c3BvbnNlICgweDA1KSBpZGVudCA0IGxlbiAxMA0KICAgICAgICBTb3VyY2UgQ0lEOiA2NA0KICAg ICAgICBGbGFnczogMHgwMDAwDQogICAgICAgIFJlc3VsdDogU3VjY2VzcyAoMHgwMDAwKQ0KICAg ICAgICBPcHRpb246IE1heGltdW0gVHJhbnNtaXNzaW9uIFVuaXQgKDB4MDEpIFttYW5kYXRvcnld DQogICAgICAgICAgTVRVOiA2NzINCj4gQUNMIERhdGEgUlg6IEhhbmRsZSAxIGZsYWdzIDB4MDIg ZGxlbiAxOCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAj NDMgW2hjaTBdIDQzLjE1NDU2Nw0KICAgICAgTDJDQVA6IENvbmZpZ3VyZSBSZXNwb25zZSAoMHgw NSkgaWRlbnQgMyBsZW4gMTANCiAgICAgICAgU291cmNlIENJRDogNjQNCiAgICAgICAgRmxhZ3M6 IDB4MDAwMA0KICAgICAgICBSZXN1bHQ6IFN1Y2Nlc3MgKDB4MDAwMCkNCiAgICAgICAgT3B0aW9u OiBNYXhpbXVtIFRyYW5zbWlzc2lvbiBVbml0ICgweDAxKSBbbWFuZGF0b3J5XQ0KICAgICAgICAg IE1UVTogNjcyDQo+IEhDSSBFdmVudDogTnVtYmVyIG9mIENvbXBsZXRlZCBQYWNrZXRzICgweDEz KSBwbGVuIDUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIzQ0IFtoY2kwXSA0 My4xNTU0OTYNCiAgICAgICAgTnVtIGhhbmRsZXM6IDENCiAgICAgICAgSGFuZGxlOiAxDQogICAg ICAgIENvdW50OiAxDQoNClRoYW5rcywNCkJScywNCkFsZXggTHUuDQo= Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id +ICjGn5caF9DIAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 09:55:42 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id OD/yE35caF8yBgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 09:55:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 8D9EDA0E54; Mon, 21 Sep 2020 09:55:37 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726358AbgIUHz1 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 03:55:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726334AbgIUHz0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 03:55:26 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE831C0613CE for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 00:55:26 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id n13so15063ybk.9 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 00:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=B8Y+8LBTHvimJHhWZ6leFbSjmB7HBaNUGneyF5qrNVo=; b=gOJ3w0XHUt1s3W/NcjVERHtyUU3jGhxFOnp8sS+05/lJFkXW+s40ehvq5oB96ePwIC MpI5l56oe1ntuYW+xJYsqAmokEXaXAnNxdujOlrrYmhCZ3+WLBzVNCmyyrn+ZgdzVcJO dvECH2CICLBFjJTd7yxPoCobHJ4l0HKo9zYeMHUXAuRHxdTCTzkmIu84Ht1Ij2LlgiJ/ u5YxPprocwoo150Xe7F0/lIMFKPjGvvCSOia931htTWKPPjzf/H9oBvChnbVBoZoJjA0 qps3HpOXjoVf8N8AybhVQgzixkbH7Prg91vQpWpHUTEx57bpY1V0o4mlXfA3SBQgEefm 1fQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=B8Y+8LBTHvimJHhWZ6leFbSjmB7HBaNUGneyF5qrNVo=; b=YoHIc+S0NRhGKc48OyVdKFnx2PQsodabP3x/wRjymWMGHN2F6jUu4HwRNEE5C7Q8yo 1dZtEfxo47gwlVu2gD0NUJH+TIaWY5esrCWXTTvxGGhYSgl2LrqaoJA3/pvlp0VSQ6oA hZ4j6rUDiE4LAkSw8pOZ4sPASLAQVLagdGSQDyW4oJUFp334zwDnf93JYGibMnuP5NZv j3opuUsGKjyN/LHvnr+D8RUPo82YCokt4cdfoo5qO+JEwa0q7IcoNER/XUwtHN9vHg+2 IIUCCZygwHhdslPvCmoclLlxpmxGJBhtlleF9JnrB7gdpT2bYQwAvE0wJWB8EKvMyPrX WWEg== X-Gm-Message-State: AOAM5305mNt2ZajfKl1i7zmuBYmiMEcv20sRdOxc4DQRV02euR3euIKC 5/Qn9yuO8teGqdpMRC+H2WZXb8G5iYAjy8vzXdo08Ch4UrxsvFJsSN5iZvxVEUIR/UHFlyB/nSY gaQq+Nt+lf9Qt5cwo4XCGzP5ECj44G70R62hhXNyYW9EchyneEULz2wdpUZ9zxZMmV6V1v1jy7d Lx X-Google-Smtp-Source: ABdhPJwV9JhyQlgRTnlAmCvqsr0GwqhawJY3RB7xBcTvOGIUVrnohTplzXPDf5Odx+1QvTrhjj3sWzqVJ0Oo Sender: "apusaka via sendgmr" <apusaka@apusaka-p920.tpe.corp.google.com> X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a25:9c82:: with SMTP id y2mr28393404ybo.364.1600674925897; Mon, 21 Sep 2020 00:55:25 -0700 (PDT) Date: Mon, 21 Sep 2020 15:55:13 +0800 Message-Id: <20200921155004.v2.1.I67a8b8cd4def8166970ca37109db46d731b62bb6@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v2] Bluetooth: Check for encryption key size on connect From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.30 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8D9EDA0E54 X-Rspamd-UID: 2537ff From: Archie Pusaka <apusaka@chromium.org> When receiving connection, we only check whether the link has been encrypted, but not the encryption key size of the link. This patch adds check for encryption key size, and reject L2CAP connection which size is below the specified threshold (default 7) with security block. Here is some btmon trace. @ MGMT Event: New Link Key (0x0009) plen 26 {0x0001} [hci0] 5.847722 Store hint: No (0x00) BR/EDR Address: 38:00:25:F7:F1:B0 (OUI 38-00-25) Key type: Unauthenticated Combination key from P-192 (0x04) Link key: 7bf2f68c81305d63a6b0ee2c5a7a34bc PIN length: 0 > HCI Event: Encryption Change (0x08) plen 4 #29 [hci0] 5.871537 Status: Success (0x00) Handle: 256 Encryption: Enabled with E0 (0x01) < HCI Command: Read Encryp... (0x05|0x0008) plen 2 #30 [hci0] 5.871609 Handle: 256 > HCI Event: Command Complete (0x0e) plen 7 #31 [hci0] 5.872524 Read Encryption Key Size (0x05|0x0008) ncmd 1 Status: Success (0x00) Handle: 256 Key size: 3 ////// WITHOUT PATCH ////// > ACL Data RX: Handle 256 flags 0x02 dlen 12 #42 [hci0] 5.895023 L2CAP: Connection Request (0x02) ident 3 len 4 PSM: 4097 (0x1001) Source CID: 64 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #43 [hci0] 5.895213 L2CAP: Connection Response (0x03) ident 3 len 8 Destination CID: 64 Source CID: 64 Result: Connection successful (0x0000) Status: No further information available (0x0000) ////// WITH PATCH ////// > ACL Data RX: Handle 256 flags 0x02 dlen 12 #42 [hci0] 4.887024 L2CAP: Connection Request (0x02) ident 3 len 4 PSM: 4097 (0x1001) Source CID: 64 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #43 [hci0] 4.887127 L2CAP: Connection Response (0x03) ident 3 len 8 Destination CID: 0 Source CID: 64 Result: Connection refused - security block (0x0003) Status: No further information available (0x0000) Signed-off-by: Archie Pusaka <apusaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- Btw, it looks like the patch sent by Alex Lu with the title [PATCH] Bluetooth: Fix the vulnerable issue on enc key size also solves the exact same issue. Changes in v2: * Add btmon trace to the commit message net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index ade83e224567..b4fc0ad38aaa 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4101,7 +4101,8 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn, /* Check if the ACL is secure enough (if not SDP) */ if (psm != cpu_to_le16(L2CAP_PSM_SDP) && - !hci_conn_check_link_mode(conn->hcon)) { + (!hci_conn_check_link_mode(conn->hcon) || + !l2cap_check_enc_key_size(conn->hcon))) { conn->disc_reason = HCI_ERROR_AUTH_FAILURE; result = L2CAP_CR_SEC_BLOCK; goto response; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cDr2GNhkaF+HFwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 10:31:20 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id IFxQFdhkaF/HUQEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 10:31:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id EBE9AA0B22; Mon, 21 Sep 2020 10:31:15 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726478AbgIUIbI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 04:31:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbgIUIbH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 04:31:07 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28814C0613D0 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 01:31:07 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 193so12385231ybi.8 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 01:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=y6MksErW1U8dQLfp/yZPir1AuwWyhaQIui/vcwOhDaY=; b=nDddbb4lOurMWfZchX8bakzQqMzgLCy5k60NEpVpshy1+6sjpaH1Jan7Gr9g/3lYVe E0ywF/hmG85PqwXGrVYH2bJne20r5r+6M9nWiSzUET45XT1aFOA1ELDCOCFsQGlgZaM9 AQ0504d3Kl8jqx6DAyJyDG9scU47A3JOrAmW5JwHQGf3Su/Nd+7LiPzqkFVDwP20HP1J FtvowVJygsL08RlJ0XaaoB81o9lh/Z3turMCMCqAx14zUsIJdQsRQ1tkbrqm5tZ9WsWU hRABre/H6H/2rpfIORzlZ7SU6cQgd9PgtfAAw0evBBAYfouIV/MVBOh6yf2Ht9s0iTwO ZEXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=y6MksErW1U8dQLfp/yZPir1AuwWyhaQIui/vcwOhDaY=; b=HZUsy5TnICTpC1QRuIGG+WFlrDT2eeyfEPTE2SyUye/PciaTOkjnfjaDbInsNHBaEU iuJzhOngPqEdnaELrggVIdURuKvfwxykP5KcDxwhnb5Tpgp7r92sH0Q2mytMmcBzY4en JYBi0LUqKwc5xsDlN2q4iSDW5r3ehCddMPitrppvQVhgtJlljIeHUqmrO+afu1yCP6iM 9z/6Dh784VEDZeN0134h1Wz+Uev8P6Gm1ktltuWuhmLhepW0xCOb+kQdy87Av2FCQL2S X4l2o6+BWiC89NiqL2cwbdUbQPkfXiM6YPC7OwWj+aN6QE6VCLjoNwqwTWqDhTkMalK6 7EvA== X-Gm-Message-State: AOAM5319P+wT0W2S3zYPnjOxluMDv4VD1uffEilhGimk0U6JuQ0oOVqV IAWY8KQfofMZ2gf9j8llaK4KnXVn3NmUt9OnYT6H9kwRElRPT3k60yD0MkWXWG4VDWrJDzLUEkv uUM2Vp0Ni7g5C+YVdDTelnI2LMTnobhtCpWlruRQBb2WyDd3tDWeoKMI81yjVKZUA30Fs5HN/fo qj X-Google-Smtp-Source: ABdhPJzkBC8MGwfsvKuV6X2blgHQy6tiWJ+vqkRMWva5R+ydmkE2UbP7Ot9gmDBXr1ckABkKMRu8YpHcONYX Sender: "apusaka via sendgmr" <apusaka@apusaka-p920.tpe.corp.google.com> X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a25:b946:: with SMTP id s6mr61046214ybm.266.1600677066176; Mon, 21 Sep 2020 01:31:06 -0700 (PDT) Date: Mon, 21 Sep 2020 16:31:00 +0800 Message-Id: <20200921163021.v1.1.Id3160295d33d44a59fa3f2a444d74f40d132ea5c@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v1] Bluetooth: Enforce key size of 16 bytes on FIPS level From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: EBE9AA0B22 X-Rspamd-UID: 89fb7a From: Archie Pusaka <apusaka@chromium.org> According to the spec Ver 5.2, Vol 3, Part C, Sec 5.2.2.8: Device in security mode 4 level 4 shall enforce: 128-bit equivalent strength for link and encryption keys required using FIPS approved algorithms (E0 not allowed, SAFER+ not allowed, and P-192 not allowed; encryption key not shortened) This patch rejects connection with key size below 16 for FIPS level services. Signed-off-by: Archie Pusaka <apusaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- net/bluetooth/l2cap_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index ade83e224567..306616ec26e6 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1515,8 +1515,13 @@ static bool l2cap_check_enc_key_size(struct hci_conn *hcon) * that have no key size requirements. Ensure that the link is * actually encrypted before enforcing a key size. */ + int min_key_size = hcon->hdev->min_enc_key_size; + + if (hcon->sec_level == BT_SECURITY_FIPS) + min_key_size = 16; + return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) || - hcon->enc_key_size >= hcon->hdev->min_enc_key_size); + hcon->enc_key_size >= min_key_size); } static void l2cap_do_start(struct l2cap_chan *chan) -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AGJxIhLAaF90rQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 17:00:34 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id CKPuHxLAaF82cAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 17:00:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 9D69640968; Mon, 21 Sep 2020 17:00:27 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbgIUOvY (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 10:51:24 -0400 Received: from mail-io1-f80.google.com ([209.85.166.80]:47755 "EHLO mail-io1-f80.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727345AbgIUOvY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 10:51:24 -0400 Received: by mail-io1-f80.google.com with SMTP id a15so10062266ioc.14 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 07:51:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=X82mpFSYNXw8KiQzwN46zmsn9KUcYuqFASM4Rm2vW3I=; b=Z2+MJSL7jos3B+UinvHmsTBJ3DDqPxNDFWNUViiEFi0fleJF36Aa5pzi8Y5LkGn4+a VzFt9WTmdJtPbd95Ip0fXps5Y+Idotz/ig116GU78OhFRFuji4AcYmLCrbb25PQFhr7S xvVuzqIinYZuY9DCdQymVISApJ8F2WlEPznX9CUxPGlR80kIVTzXH/6gxzxWT9Qp0clq HSU5a4TfRsvxQlAcrHL5kWgWDklwEDVkqbwqmnGgtvEmg5NEwuXcg0e0idEym3xkP2jo A42MZ6xUNmetm3nOF8ki0/IGihWSixH0kmPH+PnXe1FVmP1Q3n5HNVYesQTiiNvY9eq+ jflA== X-Gm-Message-State: AOAM532951m0Sv2eyxpgbcUzTcX+FxQx7ufNUxzIeOaFLMIrlJLyrAOw Qanf0hW679V6olBXH/pe+r4PKw7nlCewWuRHj5ae8t/sibUw X-Google-Smtp-Source: ABdhPJx9GfnJQla92w2TYwa2GGE1k6o1j824dPE1UVO0QEVKZwifrmXxEYa0Fi95RKrtNmWIKJmwL7OJByfnvKHfqI3u2mZJEMmE MIME-Version: 1.0 X-Received: by 2002:a92:1a03:: with SMTP id a3mr228720ila.105.1600699881989; Mon, 21 Sep 2020 07:51:21 -0700 (PDT) Date: Mon, 21 Sep 2020 07:51:21 -0700 X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000dbab3a05afd3fb60@google.com> Subject: KMSAN: uninit-value in hci_event_packet (2) From: syzbot <syzbot+54f68ac8e259a8af4f12@syzkaller.appspotmail.com> To: davem@davemloft.net, glider@google.com, johan.hedberg@gmail.com, kuba@kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.00 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9D69640968 X-Rspamd-UID: d75bc8 Hello, syzbot found the following issue on: HEAD commit: c5a13b33 kmsan: clang-format core git tree: https://github.com/google/kmsan.git master console output: https://syzkaller.appspot.com/x/log.txt?x=1622db65900000 kernel config: https://syzkaller.appspot.com/x/.config?x=20f149ad694ba4be dashboard link: https://syzkaller.appspot.com/bug?extid=54f68ac8e259a8af4f12 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) userspace arch: i386 Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+54f68ac8e259a8af4f12@syzkaller.appspotmail.com ===================================================== BUG: KMSAN: uninit-value in hci_conn_hash_lookup_ba include/net/bluetooth/hci_core.h:960 [inline] BUG: KMSAN: uninit-value in hci_conn_complete_evt net/bluetooth/hci_event.c:2579 [inline] BUG: KMSAN: uninit-value in hci_event_packet+0x1438/0x39e30 net/bluetooth/hci_event.c:6058 CPU: 1 PID: 8513 Comm: kworker/u5:1 Not tainted 5.9.0-rc4-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: hci4 hci_rx_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x21c/0x280 lib/dump_stack.c:118 kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:122 __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:219 hci_conn_hash_lookup_ba include/net/bluetooth/hci_core.h:960 [inline] hci_conn_complete_evt net/bluetooth/hci_event.c:2579 [inline] hci_event_packet+0x1438/0x39e30 net/bluetooth/hci_event.c:6058 hci_rx_work+0x745/0xd20 net/bluetooth/hci_core.c:4889 process_one_work+0x1688/0x2140 kernel/workqueue.c:2269 worker_thread+0x10bc/0x2730 kernel/workqueue.c:2415 kthread+0x551/0x590 kernel/kthread.c:293 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Uninit was created at: kmsan_save_stack_with_flags mm/kmsan/kmsan.c:143 [inline] kmsan_internal_poison_shadow+0x66/0xd0 mm/kmsan/kmsan.c:126 kmsan_slab_alloc+0x8a/0xe0 mm/kmsan/kmsan_hooks.c:80 slab_alloc_node mm/slub.c:2907 [inline] __kmalloc_node_track_caller+0x9aa/0x12f0 mm/slub.c:4511 __kmalloc_reserve net/core/skbuff.c:142 [inline] __alloc_skb+0x35f/0xb30 net/core/skbuff.c:210 alloc_skb include/linux/skbuff.h:1094 [inline] bt_skb_alloc include/net/bluetooth/bluetooth.h:389 [inline] vhci_get_user drivers/bluetooth/hci_vhci.c:165 [inline] vhci_write+0x18a/0x890 drivers/bluetooth/hci_vhci.c:285 call_write_iter include/linux/fs.h:1882 [inline] new_sync_write fs/read_write.c:503 [inline] vfs_write+0xfa8/0x1860 fs/read_write.c:578 ksys_write+0x275/0x500 fs/read_write.c:631 __do_sys_write fs/read_write.c:643 [inline] __se_sys_write+0x92/0xb0 fs/read_write.c:640 __ia32_sys_write+0x4a/0x70 fs/read_write.c:640 do_syscall_32_irqs_on arch/x86/entry/common.c:80 [inline] __do_fast_syscall_32+0x129/0x180 arch/x86/entry/common.c:139 do_fast_syscall_32+0x6a/0xc0 arch/x86/entry/common.c:162 do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:205 entry_SYSENTER_compat_after_hwframe+0x4d/0x5c ===================================================== --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YMJ8JBzqaF8WtgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 19:59:56 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 6Ou0IRzqaF9XnAEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 19:59:56 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B1311A0B5B; Mon, 21 Sep 2020 19:59:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728054AbgIURNi (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 13:13:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbgIURNh (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 13:13:37 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FC3CC061755; Mon, 21 Sep 2020 10:13:37 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id r4so3439809ooq.7; Mon, 21 Sep 2020 10:13:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=waRqiEfNwADZ1q0cmQitfG4RqgPbX6G81DVZ4varhT0=; b=vM7jnxC86Ny/7N3SW7lZdKuOZ0XTttvm7sv9dQGlR8pSLu62Vns1DdDkyskygMe9pA pQR76F0ryFNX80RH4jDexp7P7iO6ho+kFd8D3SDhpgdpSY8qhfA1YkNKSBAi5Fj8dbG4 on+zFk8cKIC5CGjjsO/vrf4eIwQWNwvsKyKNekUnf+pEJhXjKQG3lhJeEQIUrAH/uQEJ +nfqgQKRnkeYzSM5FbT82h/RS+QpcSrD4NAnfLsgYrbeZ6ZI/kusNjfz7itHHVHL6sL6 qQ31xRstr2DIeSGy3KYjwo8Fii1RC91vsitDmTJdF+F0ZhDgo9q9/XURInkk+VVJOozL qiEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=waRqiEfNwADZ1q0cmQitfG4RqgPbX6G81DVZ4varhT0=; b=pK33SsMPM/Z6srYOBOAXMcnBchZnyhtl6WCL5vYRzAmtF4aYS8vtWE8ZenpSqr+Kh5 Au96Iwx+n/E2Mw8nWgG7B7XhSOpctvn1LEspRQkFygoOok8lpCShCF6zqi4PewMIEk8a oP3iFblKo+DxYKV3i+Te01jJeeaBkqM9TrdHLodYG8HENl6J5/x1Ur4+RApdSryjBRLd kpo9uB8AXQXXS/3+J9OBOdyTfxPAAnBBIdHPdyr9Cc5XaQoa0cflmrsKh/wZsrjdX1bt /2SAqHBwJLv0zPEHorR5CG6AKjGmhYZg69NDLFicmpVQ6jyo3LjPeklak2+g1JRZXaYw 7DmA== X-Gm-Message-State: AOAM5306Tb7PLCDFia7qx6/AjaZbcWN21aeY4ip0u6c4org6v9fK66rR 1rwupxqYL/RbyCJVylj8G/++pv3HsM+L1jmPP8U= X-Google-Smtp-Source: ABdhPJxDFrUXooxQY3Awa9RYKnX7uqza0e4QwpmnOBBuqu7J5l3yYSbquJwybOPrnpU6sEFukuM5+wYsmhhy3dgESSs= X-Received: by 2002:a4a:5896:: with SMTP id f144mr250480oob.49.1600708416655; Mon, 21 Sep 2020 10:13:36 -0700 (PDT) MIME-Version: 1.0 References: <20200921163021.v1.1.Id3160295d33d44a59fa3f2a444d74f40d132ea5c@changeid> In-Reply-To: <20200921163021.v1.1.Id3160295d33d44a59fa3f2a444d74f40d132ea5c@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 21 Sep 2020 10:13:24 -0700 Message-ID: <CABBYNZJGfDoV+E-f6T=ZQ2RT0doXDdOB7tgVrt=4fpvKcpmH4w@mail.gmail.com> Subject: Re: [PATCH v1] Bluetooth: Enforce key size of 16 bytes on FIPS level To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.50 / 15.00 / 15.00 X-Rspamd-Queue-Id: B1311A0B5B X-Rspamd-UID: 06be18 Hi Archie, On Mon, Sep 21, 2020 at 1:31 AM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > According to the spec Ver 5.2, Vol 3, Part C, Sec 5.2.2.8: > Device in security mode 4 level 4 shall enforce: > 128-bit equivalent strength for link and encryption keys required > using FIPS approved algorithms (E0 not allowed, SAFER+ not allowed, > and P-192 not allowed; encryption key not shortened) > > This patch rejects connection with key size below 16 for FIPS level > services. > > Signed-off-by: Archie Pusaka <apusaka@chromium.org> > Reviewed-by: Alain Michaud <alainm@chromium.org> > > --- > > net/bluetooth/l2cap_core.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > index ade83e224567..306616ec26e6 100644 > --- a/net/bluetooth/l2cap_core.c > +++ b/net/bluetooth/l2cap_core.c > @@ -1515,8 +1515,13 @@ static bool l2cap_check_enc_key_size(struct hci_conn *hcon) > * that have no key size requirements. Ensure that the link is > * actually encrypted before enforcing a key size. > */ > + int min_key_size = hcon->hdev->min_enc_key_size; > + > + if (hcon->sec_level == BT_SECURITY_FIPS) > + min_key_size = 16; > + > return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) || > - hcon->enc_key_size >= hcon->hdev->min_enc_key_size); > + hcon->enc_key_size >= min_key_size); While this looks fine to me, it looks like this should be placed elsewhere since it takes an hci_conn and it is not L2CAP specific. > } > > static void l2cap_do_start(struct l2cap_chan *chan) > -- > 2.28.0.681.g6f77f65b4e-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GID1EjbqaF+UzgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 20:00:22 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 6BjVEDbqaF+yVgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 20:00:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 66A5FA0B48; Mon, 21 Sep 2020 20:00:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728340AbgIURPT (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 13:15:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbgIURPS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 13:15:18 -0400 Received: from mail-oo1-xc44.google.com (mail-oo1-xc44.google.com [IPv6:2607:f8b0:4864:20::c44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B63A2C061755; Mon, 21 Sep 2020 10:15:18 -0700 (PDT) Received: by mail-oo1-xc44.google.com with SMTP id r10so3444661oor.5; Mon, 21 Sep 2020 10:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=truTd7ocTX1PuSU7rQErYxWj/dIz+vHpcLReSTcVRLQ=; b=IYFOmOTKym3fEevV+/lfQdwIKr9kOO2wdlYQum+pLsRktlMnxdpso9HSJO4RH+0s2Z UxdUvle1oIN9eZzFit3mrq1OLX6d6iALBByS9J5ZvPg9kIYodA/Y5hxmHLx2y8G9aLHa XBkE8XLvSRG7FhDVFcmAWEaRVY7cX/DThKDmj1RPBNPcowTFcnC7IflE/Bsdu8VoFKo6 Dti1Um01dTCkT0pKU7d7ikjpJRMqtZgN2W98og0TSAYLUfph/LvHClaJBOy24XhrwsUC 9H6bxtIjo+qPVr90hroYJAVkjzs6qe+Z15zGspfqB0rWO7is4lftdAXREnIlyuOdXNGp H6Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=truTd7ocTX1PuSU7rQErYxWj/dIz+vHpcLReSTcVRLQ=; b=KxXYUcLBYrrA+BYG+D+7SDItZx7OkzWOX7yNZlGXZCGEAUvLMCr99FXEOW2xfYtYC+ pCTh6LoLfCl38yT/ELPrW/3g9kd9fyy0jq0Tc1GSx7tqqf/OOi0FkZW6syXRquV9gVEd W9fDvOlMj8WXbshOE5waL0dt5eiaDbnj5z3/uICPP00ZuWNB4k1PVm0uYU8gW+FHxLO4 rcPXko06t/jXpMx8TEohw5vveAXI0qkBcjIBaCK9d0NhoqDr/U8jQ4LzO0KMVYmYzIc6 Ym+ilwJTgJu6CTqmnO7a+q1WgCiNERrUl4yHNX7PVIgQjCGBd0+wKINFPgynemOqrqEy 7rfg== X-Gm-Message-State: AOAM533cBYPLxAqCXt6GeaT9aHaZ6x5TCNiTUALp+XBnvj7dphrs9V3q oNqBK6dXRYB8ejFBLEI7kaDDi7VnGtc2pO9i4TM= X-Google-Smtp-Source: ABdhPJyBqC+wVOljuLdYILZoSwG9EtUz6TgN/dCaURqlCsUz+SvJOXocTrSwYx0YZGWVVFvO/VyCzZosJhR5hyMqqpM= X-Received: by 2002:a4a:bf12:: with SMTP id r18mr272835oop.9.1600708517923; Mon, 21 Sep 2020 10:15:17 -0700 (PDT) MIME-Version: 1.0 References: <20200921155004.v2.1.I67a8b8cd4def8166970ca37109db46d731b62bb6@changeid> In-Reply-To: <20200921155004.v2.1.I67a8b8cd4def8166970ca37109db46d731b62bb6@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 21 Sep 2020 10:15:04 -0700 Message-ID: <CABBYNZLTZbwyL0ykmFezWrkNVnHoZt2KPtz+aQwo7TvhdC7TiQ@mail.gmail.com> Subject: Re: [PATCH v2] Bluetooth: Check for encryption key size on connect To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.80 / 15.00 / 15.00 X-Rspamd-Queue-Id: 66A5FA0B48 X-Rspamd-UID: 6bc504 Hi Archie, On Mon, Sep 21, 2020 at 12:56 AM Archie Pusaka <apusaka@google.com> wrote: > > From: Archie Pusaka <apusaka@chromium.org> > > When receiving connection, we only check whether the link has been > encrypted, but not the encryption key size of the link. > > This patch adds check for encryption key size, and reject L2CAP > connection which size is below the specified threshold (default 7) > with security block. > > Here is some btmon trace. > @ MGMT Event: New Link Key (0x0009) plen 26 {0x0001} [hci0] 5.847722 > Store hint: No (0x00) > BR/EDR Address: 38:00:25:F7:F1:B0 (OUI 38-00-25) > Key type: Unauthenticated Combination key from P-192 (0x04) > Link key: 7bf2f68c81305d63a6b0ee2c5a7a34bc > PIN length: 0 > > HCI Event: Encryption Change (0x08) plen 4 #29 [hci0] 5.871537 > Status: Success (0x00) > Handle: 256 > Encryption: Enabled with E0 (0x01) > < HCI Command: Read Encryp... (0x05|0x0008) plen 2 #30 [hci0] 5.871609 > Handle: 256 > > HCI Event: Command Complete (0x0e) plen 7 #31 [hci0] 5.872524 > Read Encryption Key Size (0x05|0x0008) ncmd 1 > Status: Success (0x00) > Handle: 256 > Key size: 3 > > ////// WITHOUT PATCH ////// > > ACL Data RX: Handle 256 flags 0x02 dlen 12 #42 [hci0] 5.895023 > L2CAP: Connection Request (0x02) ident 3 len 4 > PSM: 4097 (0x1001) > Source CID: 64 > < ACL Data TX: Handle 256 flags 0x00 dlen 16 #43 [hci0] 5.895213 > L2CAP: Connection Response (0x03) ident 3 len 8 > Destination CID: 64 > Source CID: 64 > Result: Connection successful (0x0000) > Status: No further information available (0x0000) > > ////// WITH PATCH ////// > > ACL Data RX: Handle 256 flags 0x02 dlen 12 #42 [hci0] 4.887024 > L2CAP: Connection Request (0x02) ident 3 len 4 > PSM: 4097 (0x1001) > Source CID: 64 > < ACL Data TX: Handle 256 flags 0x00 dlen 16 #43 [hci0] 4.887127 > L2CAP: Connection Response (0x03) ident 3 len 8 > Destination CID: 0 > Source CID: 64 > Result: Connection refused - security block (0x0003) > Status: No further information available (0x0000) > > Signed-off-by: Archie Pusaka <apusaka@chromium.org> > Reviewed-by: Alain Michaud <alainm@chromium.org> > > --- > Btw, it looks like the patch sent by Alex Lu with the title > [PATCH] Bluetooth: Fix the vulnerable issue on enc key size > also solves the exact same issue. > > Changes in v2: > * Add btmon trace to the commit message > > net/bluetooth/l2cap_core.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > index ade83e224567..b4fc0ad38aaa 100644 > --- a/net/bluetooth/l2cap_core.c > +++ b/net/bluetooth/l2cap_core.c > @@ -4101,7 +4101,8 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn, > > /* Check if the ACL is secure enough (if not SDP) */ > if (psm != cpu_to_le16(L2CAP_PSM_SDP) && > - !hci_conn_check_link_mode(conn->hcon)) { > + (!hci_conn_check_link_mode(conn->hcon) || > + !l2cap_check_enc_key_size(conn->hcon))) { I wonder if we couldn't incorporate the check of key size into hci_conn_check_link_mode, like I said in the first patch checking the enc key size should not be specific to L2CAP. > conn->disc_reason = HCI_ERROR_AUTH_FAILURE; > result = L2CAP_CR_SEC_BLOCK; > goto response; > -- > 2.28.0.681.g6f77f65b4e-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sNgNI9X4aF8DLwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:02:45 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id aDVXH9X4aF9avQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:02:45 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F388B40987; Mon, 21 Sep 2020 21:02:38 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727474AbgIUTCi (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:02:38 -0400 Received: from mga07.intel.com ([134.134.136.100]:22104 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727382AbgIUTCi (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:02:38 -0400 IronPort-SDR: DUcivvGASZo+Du2qjGmLpLAv4xA+8uOqXBh+5J/fUeLqwM9g75UO3rdfrgbG52uSLJVh6Bmgxl lml9/n8K13GQ== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="224608863" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="224608863" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:02:36 -0700 IronPort-SDR: 3aK2AMUVTXG/auNi7q9GJzmfI503MkPLT4cIA2yAYpfArnfME/SIbOGW7j/pISg1llQ03itkVT 0iFYn1+U8I9Q== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485623673" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:02:36 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 02/20] attrib: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:22 -0700 Message-Id: <20200921190040.45309-3-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.38 / 15.00 / 15.00 X-Rspamd-Queue-Id: F388B40987 X-Rspamd-UID: dbe201 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 13 License: GPL-2.0-or-later attrib/att-database.h attrib/gattrib.h attrib/gatttool.h attrib/gatt-service.c attrib/interactive.c attrib/utils.c attrib/gatt.c attrib/gattrib.c attrib/gatt-service.h attrib/att.c attrib/gatt.h attrib/att.h attrib/gatttool.c --- attrib/att-database.h | 15 +-------------- attrib/att.c | 15 +-------------- attrib/att.h | 15 +-------------- attrib/gatt-service.c | 15 +-------------- attrib/gatt-service.h | 15 +-------------- attrib/gatt.c | 15 +-------------- attrib/gatt.h | 15 +-------------- attrib/gattrib.c | 15 +-------------- attrib/gattrib.h | 15 +-------------- attrib/gatttool.c | 15 +-------------- attrib/gatttool.h | 15 +-------------- attrib/interactive.c | 15 +-------------- attrib/utils.c | 15 +-------------- 13 files changed, 13 insertions(+), 182 deletions(-) diff --git a/attrib/att-database.h b/attrib/att-database.h index 48c50e385..bb30933ea 100644 --- a/attrib/att-database.h +++ b/attrib/att-database.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012 Texas Instruments Corporation * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ /* Requirements for read/write operations */ diff --git a/attrib/att.c b/attrib/att.c index c0438a382..fa53c90aa 100644 --- a/attrib/att.c +++ b/attrib/att.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/attrib/att.h b/attrib/att.h index 2311aafb6..13a0c3a31 100644 --- a/attrib/att.h +++ b/attrib/att.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include "src/shared/crypto.h" diff --git a/attrib/gatt-service.c b/attrib/gatt-service.c index 629d9cfd2..741ff1acb 100644 --- a/attrib/gatt-service.c +++ b/attrib/gatt-service.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/attrib/gatt-service.h b/attrib/gatt-service.h index 728d3a8e7..17031d466 100644 --- a/attrib/gatt-service.h +++ b/attrib/gatt-service.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef enum { diff --git a/attrib/gatt.c b/attrib/gatt.c index 480f87425..46b2ca381 100644 --- a/attrib/gatt.c +++ b/attrib/gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/attrib/gatt.h b/attrib/gatt.h index 63b2940dc..e2c8c90a8 100644 --- a/attrib/gatt.h +++ b/attrib/gatt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ /* diff --git a/attrib/gattrib.c b/attrib/gattrib.c index 8aa0f5eff..bc7d4f22c 100644 --- a/attrib/gattrib.c +++ b/attrib/gattrib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/attrib/gattrib.h b/attrib/gattrib.h index 611f95260..c2877d757 100644 --- a/attrib/gattrib.h +++ b/attrib/gattrib.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GATTRIB_H #define __GATTRIB_H diff --git a/attrib/gatttool.c b/attrib/gatttool.c index 95bd20a63..6a0ddfaad 100644 --- a/attrib/gatttool.c +++ b/attrib/gatttool.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/attrib/gatttool.h b/attrib/gatttool.h index 8f0913ceb..20cb42417 100644 --- a/attrib/gatttool.h +++ b/attrib/gatttool.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int interactive(const char *src, const char *dst, const char *dst_type, diff --git a/attrib/interactive.c b/attrib/interactive.c index 9a7976d34..171b95738 100644 --- a/attrib/interactive.c +++ b/attrib/interactive.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/attrib/utils.c b/attrib/utils.c index a74902959..317331b4b 100644 --- a/attrib/utils.c +++ b/attrib/utils.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id KKZRHPL4aF8WtgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:03:14 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id ePyKGfL4aF/OfgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:03:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id BB894A0B96; Mon, 21 Sep 2020 21:03:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727286AbgIUTDH (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:03:07 -0400 Received: from mga03.intel.com ([134.134.136.65]:57864 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbgIUTDH (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:03:07 -0400 IronPort-SDR: LRLJkg56fYuxHa/NpXj+hI5kd5+AafBQ17T6tgrMj25dil2bwUxfj63EUWHJCqrTZjwIsbt4ZI 2Ne7UcwPKOZQ== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="160524432" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="160524432" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:03:07 -0700 IronPort-SDR: oyr83ejzxp1YjnBTMWLOmLH6dk5OEBG25L22LVxVkeNpIHSj2SCeEyTSGHVKwBjwLYWdM2mMLp MX7io6dOihbQ== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485624042" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:03:06 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 03/20] btio: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:23 -0700 Message-Id: <20200921190040.45309-4-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.51 / 15.00 / 15.00 X-Rspamd-Queue-Id: BB894A0B96 X-Rspamd-UID: 488dfa From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 2 License: GPL-2.0-or-later btio/btio.h btio/btio.c --- btio/btio.c | 15 +-------------- btio/btio.h | 15 +-------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/btio/btio.c b/btio/btio.c index 844d6007f..c18b6a012 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2009-2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/btio/btio.h b/btio/btio.h index 23e0ef72b..f0259cf1d 100644 --- a/btio/btio.h +++ b/btio/btio.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2009-2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef BT_IO_H #define BT_IO_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 6D/iLCv5aF8cMwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:04:11 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 0OZHKSv5aF8+uwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:04:11 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 63422A0B48; Mon, 21 Sep 2020 21:04:06 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727517AbgIUTEF (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:04:05 -0400 Received: from mga09.intel.com ([134.134.136.24]:2086 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbgIUTEE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:04:04 -0400 IronPort-SDR: u/grhmBW63CwJlViANZr6Dh1XJpQ7RAnqlra/mOFE7s+xveVHVUlOvHUoUPwv1j6xFZ+O9R6z6 0lZfEkJ6EKgA== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="161383794" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="161383794" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:03:52 -0700 IronPort-SDR: a6D8IORZcB3fkZZbWTHZTNTipxNcogpxNNcWZTDQBDMuzGMkrhiDA4eTJExp8F3Wof7W1G1W+R jvgV3a+q6VIQ== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485624564" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:03:51 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 04/20] client: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:24 -0700 Message-Id: <20200921190040.45309-5-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: 63422A0B48 X-Rspamd-UID: d8c965 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 11 License: GPL-2.0-or-later client/adv_monitor.c client/adv_monitor.h client/advertising.h client/display.c client/main.c client/display.h client/agent.h client/gatt.c client/agent.c client/advertising.c client/gatt.h --- client/adv_monitor.c | 11 +---------- client/adv_monitor.h | 11 +---------- client/advertising.c | 15 +-------------- client/advertising.h | 15 +-------------- client/agent.c | 15 +-------------- client/agent.h | 15 +-------------- client/display.c | 15 +-------------- client/display.h | 15 +-------------- client/gatt.c | 15 +-------------- client/gatt.h | 15 +-------------- client/main.c | 15 +-------------- 11 files changed, 11 insertions(+), 146 deletions(-) diff --git a/client/adv_monitor.c b/client/adv_monitor.c index 22bb3c670..90ab0be09 100644 --- a/client/adv_monitor.c +++ b/client/adv_monitor.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Google LLC * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/client/adv_monitor.h b/client/adv_monitor.h index 12c01bd3f..dd6f61579 100644 --- a/client/adv_monitor.h +++ b/client/adv_monitor.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Google LLC * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #define RSSI_DEFAULT_HIGH_THRESHOLD -50 diff --git a/client/advertising.c b/client/advertising.c index 1aa28e749..c1a00502e 100644 --- a/client/advertising.c +++ b/client/advertising.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2016 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/advertising.h b/client/advertising.h index 9967e657b..25e6aee99 100644 --- a/client/advertising.h +++ b/client/advertising.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2016 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void ad_register(DBusConnection *conn, GDBusProxy *manager, const char *type); diff --git a/client/agent.c b/client/agent.c index 4def1b478..c8e1560e7 100644 --- a/client/agent.c +++ b/client/agent.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/agent.h b/client/agent.h index 30f302cdc..5d902a717 100644 --- a/client/agent.h +++ b/client/agent.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void agent_register(DBusConnection *conn, GDBusProxy *manager, diff --git a/client/display.c b/client/display.c index 05613865b..a590a1388 100644 --- a/client/display.c +++ b/client/display.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/display.h b/client/display.h index e991d191a..eb5bd1153 100644 --- a/client/display.h +++ b/client/display.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define COLOR_OFF "\x1B[0m" diff --git a/client/gatt.c b/client/gatt.c index e5bab6dd0..21fd38ecf 100644 --- a/client/gatt.c +++ b/client/gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/client/gatt.h b/client/gatt.h index 09ca618d3..fc2b8a8a6 100644 --- a/client/gatt.h +++ b/client/gatt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void gatt_add_service(GDBusProxy *proxy); diff --git a/client/main.c b/client/main.c index 2b0243308..60f1eb86e 100644 --- a/client/main.c +++ b/client/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id wP/BBTT5aF8DLwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:04:20 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id mINKAzT5aF/YvwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:04:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 61A6DA0B7B; Mon, 21 Sep 2020 21:04:13 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727711AbgIUTEN (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:04:13 -0400 Received: from mga18.intel.com ([134.134.136.126]:15404 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbgIUTEM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:04:12 -0400 IronPort-SDR: KGHEZx0xjQHCkiVfyImx5LtGxCEIr6ozkORd7FiRD32bkb1lwmHwMacIZDwqbqIH6uWdUXjrkg LFE2gJiUWsYw== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="148216095" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="148216095" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:04:10 -0700 IronPort-SDR: /an2Cdr+4SdAq/rGUh1AEITBJ8maBctMLeZ6rfeNBc4O94Dk3UK5xJuugn+kD4bcCloRaV7jH+ 2RpMug+2Jsww== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485624814" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:04:10 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 05/20] emulator: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:25 -0700 Message-Id: <20200921190040.45309-6-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: 61A6DA0B7B X-Rspamd-UID: 461e60 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 20 GPL-2.0-or-later : 2 License: LGPL-2.1-or-later emulator/server.c emulator/amp.c emulator/hciemu.c emulator/vhci.c emulator/btdev.c emulator/serial.h emulator/le.h emulator/le.c emulator/main.c emulator/amp.h emulator/hciemu.h emulator/bthost.h emulator/btdev.h emulator/vhci.h emulator/serial.c emulator/phy.c emulator/smp.c emulator/phy.h emulator/bthost.c emulator/server.h License: GPL-2.0-or-later emulator/b1ee.c emulator/hfp.c --- emulator/amp.c | 15 +-------------- emulator/amp.h | 15 +-------------- emulator/b1ee.c | 15 +-------------- emulator/btdev.c | 15 +-------------- emulator/btdev.h | 15 +-------------- emulator/bthost.c | 15 +-------------- emulator/bthost.h | 15 +-------------- emulator/hciemu.c | 15 +-------------- emulator/hciemu.h | 15 +-------------- emulator/hfp.c | 15 +-------------- emulator/le.c | 15 +-------------- emulator/le.h | 15 +-------------- emulator/main.c | 15 +-------------- emulator/phy.c | 15 +-------------- emulator/phy.h | 15 +-------------- emulator/serial.c | 15 +-------------- emulator/serial.h | 15 +-------------- emulator/server.c | 15 +-------------- emulator/server.h | 15 +-------------- emulator/smp.c | 15 +-------------- emulator/vhci.c | 15 +-------------- emulator/vhci.h | 15 +-------------- 22 files changed, 22 insertions(+), 308 deletions(-) diff --git a/emulator/amp.c b/emulator/amp.c index 605c6c825..49d2df7b3 100644 --- a/emulator/amp.c +++ b/emulator/amp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/amp.h b/emulator/amp.h index 189dfb7d4..cee360c44 100644 --- a/emulator/amp.h +++ b/emulator/amp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/emulator/b1ee.c b/emulator/b1ee.c index 377181b01..53b85f221 100644 --- a/emulator/b1ee.c +++ b/emulator/b1ee.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/btdev.c b/emulator/btdev.c index e9c3811f8..9a8c9b654 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/btdev.h b/emulator/btdev.h index a9f71b281..7cb265f1c 100644 --- a/emulator/btdev.h +++ b/emulator/btdev.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/emulator/bthost.c b/emulator/bthost.c index 71d5f97bb..1c05c7496 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/bthost.h b/emulator/bthost.h index 2b347136f..3841f98a1 100644 --- a/emulator/bthost.h +++ b/emulator/bthost.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/emulator/hciemu.c b/emulator/hciemu.c index ac861cce2..fa8905ed7 100644 --- a/emulator/hciemu.c +++ b/emulator/hciemu.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/hciemu.h b/emulator/hciemu.h index 4c8858bb6..c8ec80d8d 100644 --- a/emulator/hciemu.h +++ b/emulator/hciemu.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/emulator/hfp.c b/emulator/hfp.c index 29ec63e7d..bbf785ee3 100644 --- a/emulator/hfp.c +++ b/emulator/hfp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/le.c b/emulator/le.c index 1c8ba280b..4ffe3b16d 100644 --- a/emulator/le.c +++ b/emulator/le.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/le.h b/emulator/le.h index 5e832e8e5..21d2b4828 100644 --- a/emulator/le.h +++ b/emulator/le.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/emulator/main.c b/emulator/main.c index 75cb79c7b..cb77025aa 100644 --- a/emulator/main.c +++ b/emulator/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/phy.c b/emulator/phy.c index beb8bbbe4..4517ad107 100644 --- a/emulator/phy.c +++ b/emulator/phy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/phy.h b/emulator/phy.h index d5efa5180..9ee8f397c 100644 --- a/emulator/phy.h +++ b/emulator/phy.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/emulator/serial.c b/emulator/serial.c index 1c324d531..b44af0dcc 100644 --- a/emulator/serial.c +++ b/emulator/serial.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/serial.h b/emulator/serial.h index 4e5a56f88..1dce15f51 100644 --- a/emulator/serial.h +++ b/emulator/serial.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/emulator/server.c b/emulator/server.c index c28b15ebf..3b07a7156 100644 --- a/emulator/server.c +++ b/emulator/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/server.h b/emulator/server.h index bf725e788..294e86525 100644 --- a/emulator/server.h +++ b/emulator/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/emulator/smp.c b/emulator/smp.c index c30de3666..7c05ba342 100644 --- a/emulator/smp.c +++ b/emulator/smp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/vhci.c b/emulator/vhci.c index f79b34f46..84e16330f 100644 --- a/emulator/vhci.c +++ b/emulator/vhci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/emulator/vhci.h b/emulator/vhci.h index 1ec7191f8..24b36bd60 100644 --- a/emulator/vhci.h +++ b/emulator/vhci.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kMAzMGX5aF+TFQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:05:09 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id yPBzLWX5aF8+uwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:05:09 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 49B2E40984; Mon, 21 Sep 2020 21:05:03 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727363AbgIUTE5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:04:57 -0400 Received: from mga11.intel.com ([192.55.52.93]:55287 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726810AbgIUTE5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:04:57 -0400 IronPort-SDR: RyKoEmoVRwlqHYFH+sB1D7NIDVFscg16RwfE+Q4U2OzbLBlgGOuCdM5fyW+EuVDK0i7DwyMsYW 6FMp0cw+Mpfg== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="157832641" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="157832641" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:04:57 -0700 IronPort-SDR: UWVCBGSj2GQpxEd0JFTnsVFyKlIHFA3D5z6uHSkIoYKtane+AAiqtB9uUxSiveNoXB/AEULT+Z ljIUegMbxZaw== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485625375" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:04:56 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 07/20] gobex: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:27 -0700 Message-Id: <20200921190040.45309-8-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: 49B2E40984 X-Rspamd-UID: 7fbbe1 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 12 License: GPL-2.0-or-later gobex/gobex-defs.h gobex/gobex-transfer.c gobex/gobex.c gobex/gobex-apparam.h gobex/gobex-header.h gobex/gobex-header.c gobex/gobex.h gobex/gobex-packet.h gobex/gobex-defs.c gobex/gobex-debug.h gobex/gobex-apparam.c gobex/gobex-packet.c --- gobex/gobex-apparam.c | 15 +-------------- gobex/gobex-apparam.h | 15 +-------------- gobex/gobex-debug.h | 15 +-------------- gobex/gobex-defs.c | 15 +-------------- gobex/gobex-defs.h | 15 +-------------- gobex/gobex-header.c | 15 +-------------- gobex/gobex-header.h | 15 +-------------- gobex/gobex-packet.c | 15 +-------------- gobex/gobex-packet.h | 15 +-------------- gobex/gobex-transfer.c | 15 +-------------- gobex/gobex.c | 15 +-------------- gobex/gobex.h | 15 +-------------- 12 files changed, 12 insertions(+), 168 deletions(-) diff --git a/gobex/gobex-apparam.c b/gobex/gobex-apparam.c index b16cee11a..818180cb1 100644 --- a/gobex/gobex-apparam.c +++ b/gobex/gobex-apparam.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2012 Intel Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-apparam.h b/gobex/gobex-apparam.h index 6c0860928..ace615225 100644 --- a/gobex/gobex-apparam.h +++ b/gobex/gobex-apparam.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2012 Intel Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_APPARAM_H diff --git a/gobex/gobex-debug.h b/gobex/gobex-debug.h index a98653d83..eeb2209f0 100644 --- a/gobex/gobex-debug.h +++ b/gobex/gobex-debug.h @@ -1,22 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_DEBUG_H diff --git a/gobex/gobex-defs.c b/gobex/gobex-defs.c index 1c7c39a16..811be762b 100644 --- a/gobex/gobex-defs.c +++ b/gobex/gobex-defs.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-defs.h b/gobex/gobex-defs.h index 326e3cb09..84351205d 100644 --- a/gobex/gobex-defs.h +++ b/gobex/gobex-defs.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_DEFS_H diff --git a/gobex/gobex-header.c b/gobex/gobex-header.c index c594999a5..011d33d1a 100644 --- a/gobex/gobex-header.c +++ b/gobex/gobex-header.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-header.h b/gobex/gobex-header.h index 6600b1b4a..129f35ba1 100644 --- a/gobex/gobex-header.h +++ b/gobex/gobex-header.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_HEADER_H diff --git a/gobex/gobex-packet.c b/gobex/gobex-packet.c index a89f5b6d3..11937a5a5 100644 --- a/gobex/gobex-packet.c +++ b/gobex/gobex-packet.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex-packet.h b/gobex/gobex-packet.h index 1d94ccf20..ed153bac5 100644 --- a/gobex/gobex-packet.h +++ b/gobex/gobex-packet.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_PACKET_H diff --git a/gobex/gobex-transfer.c b/gobex/gobex-transfer.c index e96e61fbc..c94d018b2 100644 --- a/gobex/gobex-transfer.c +++ b/gobex/gobex-transfer.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex.c b/gobex/gobex.c index d68a85eb6..54e3b0814 100644 --- a/gobex/gobex.c +++ b/gobex/gobex.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gobex/gobex.h b/gobex/gobex.h index a94d9246e..f16e4426c 100644 --- a/gobex/gobex.h +++ b/gobex/gobex.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GOBEX_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WD01Enf5aF8DLwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:05:27 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id 2Ea4D3f5aF9J1wEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:05:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 6A36F40992; Mon, 21 Sep 2020 21:05:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727300AbgIUTFU (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:05:20 -0400 Received: from mga02.intel.com ([134.134.136.20]:53059 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726810AbgIUTFT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:05:19 -0400 IronPort-SDR: 2sSX7VGrehh5yxl/BO9AQ5o3IrEssrnR/HPyh0neVGKsInIJqCqTOWQQnFj207CPfmMva7j+Ax gS42HcgrW3gQ== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="148118703" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="148118703" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:05:14 -0700 IronPort-SDR: M2K0K9LzQiCBPVPFb8ikd8P3XuLjwWbuWREv3T2JDa/r61cN3R/V7YlwnF/bfeG1ZLktnDtwwE 8hg0/Wws7lWA== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485625679" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:05:14 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 08/20] lib: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:28 -0700 Message-Id: <20200921190040.45309-9-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6A36F40992 X-Rspamd-UID: b1c553 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 18 GPL-2.0-only : 1 License: GPL-2.0-or-later lib/sco.h lib/sdp.c lib/a2mp.h lib/uuid.h lib/bluetooth.h lib/hidp.h lib/rfcomm.h lib/hci.c lib/sdp.h lib/sdp_lib.h lib/bluetooth.c lib/mgmt.h lib/hci.h lib/uuid.c lib/l2cap.h lib/bnep.h lib/hci_lib.h lib/cmtp.h License: GPL-2.0-only lib/amp.h --- lib/a2mp.h | 15 +-------------- lib/amp.h | 10 +--------- lib/bluetooth.c | 15 +-------------- lib/bluetooth.h | 15 +-------------- lib/bnep.h | 15 +-------------- lib/cmtp.h | 15 +-------------- lib/hci.c | 15 +-------------- lib/hci.h | 15 +-------------- lib/hci_lib.h | 15 +-------------- lib/hidp.h | 15 +-------------- lib/l2cap.h | 15 +-------------- lib/mgmt.h | 15 +-------------- lib/rfcomm.h | 15 +-------------- lib/sco.h | 15 +-------------- lib/sdp.c | 15 +-------------- lib/sdp.h | 15 +-------------- lib/sdp_lib.h | 15 +-------------- lib/uuid.c | 15 +-------------- lib/uuid.h | 15 +-------------- 19 files changed, 19 insertions(+), 261 deletions(-) diff --git a/lib/a2mp.h b/lib/a2mp.h index da937d133..556b342f7 100644 --- a/lib/a2mp.h +++ b/lib/a2mp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * Copyright (c) 2012 Code Aurora Forum. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __A2MP_H diff --git a/lib/amp.h b/lib/amp.h index 27aab1de0..8acb5ab40 100644 --- a/lib/amp.h +++ b/lib/amp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,15 +6,6 @@ * Copyright (C) 2010-2011 Code Aurora Forum. All rights reserved. * Copyright (C) 2012 Intel Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifndef __AMP_H diff --git a/lib/bluetooth.c b/lib/bluetooth.c index 5a8b57f25..0aecb50e1 100644 --- a/lib/bluetooth.c +++ b/lib/bluetooth.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/lib/bluetooth.h b/lib/bluetooth.h index 4a52ecb78..1619f5f08 100644 --- a/lib/bluetooth.h +++ b/lib/bluetooth.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __BLUETOOTH_H diff --git a/lib/bnep.h b/lib/bnep.h index e7c2c87cf..a0d39058c 100644 --- a/lib/bnep.h +++ b/lib/bnep.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __BNEP_H diff --git a/lib/cmtp.h b/lib/cmtp.h index ce937bd0d..7ba8bfc3b 100644 --- a/lib/cmtp.h +++ b/lib/cmtp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __CMTP_H diff --git a/lib/hci.c b/lib/hci.c index 9960c4490..4bd33f241 100644 --- a/lib/hci.c +++ b/lib/hci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/lib/hci.h b/lib/hci.h index 232d5bd9e..0ca20421a 100644 --- a/lib/hci.h +++ b/lib/hci.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HCI_H diff --git a/lib/hci_lib.h b/lib/hci_lib.h index 55aeb1760..6b1a548b5 100644 --- a/lib/hci_lib.h +++ b/lib/hci_lib.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HCI_LIB_H diff --git a/lib/hidp.h b/lib/hidp.h index c5e6a7808..da42a1b9e 100644 --- a/lib/hidp.h +++ b/lib/hidp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HIDP_H diff --git a/lib/l2cap.h b/lib/l2cap.h index 5ce94c4ee..9197800df 100644 --- a/lib/l2cap.h +++ b/lib/l2cap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (c) 2012 Code Aurora Forum. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __L2CAP_H diff --git a/lib/mgmt.h b/lib/mgmt.h index 46d894ae9..6aa0f5f88 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * BlueZ - Bluetooth protocol stack for Linux * @@ -5,20 +6,6 @@ * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __packed diff --git a/lib/rfcomm.h b/lib/rfcomm.h index ad6c0e1c3..0347ddc36 100644 --- a/lib/rfcomm.h +++ b/lib/rfcomm.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __RFCOMM_H diff --git a/lib/sco.h b/lib/sco.h index 75336a50e..307d81f81 100644 --- a/lib/sco.h +++ b/lib/sco.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __SCO_H diff --git a/lib/sdp.c b/lib/sdp.c index 84311eda1..532039a23 100644 --- a/lib/sdp.c +++ b/lib/sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/lib/sdp.h b/lib/sdp.h index f586eb5eb..6f05d4321 100644 --- a/lib/sdp.h +++ b/lib/sdp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __SDP_H diff --git a/lib/sdp_lib.h b/lib/sdp_lib.h index 3ded3934c..22776b678 100644 --- a/lib/sdp_lib.h +++ b/lib/sdp_lib.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __SDP_LIB_H diff --git a/lib/uuid.c b/lib/uuid.c index d4c7002f5..a09321dc6 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/lib/uuid.h b/lib/uuid.h index c7e6269f1..1a4029b68 100644 --- a/lib/uuid.h +++ b/lib/uuid.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __BLUETOOTH_UUID_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id cPTMBaD5aF8DLwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:06:08 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 0GFiAqD5aF9avQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:06:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id CB0DDA0B82; Mon, 21 Sep 2020 21:06:00 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727231AbgIUTF7 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:05:59 -0400 Received: from mga06.intel.com ([134.134.136.31]:41531 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726969AbgIUTF7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:05:59 -0400 IronPort-SDR: sK86yommw+QAFei+P7y686Kk7ojOCIWV53UWKlec9iKwj6fmSebLaLIdAW6yMeQ7U0LX1Bz4Ze 7aCtLl4OpLSA== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="222055849" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="222055849" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:05:56 -0700 IronPort-SDR: m67agbvupxlTesauMBn4djOshW/cy4g5zhryhPOm0E4KMcKcBBBEhpftXaNVC6J+ajCsNS97+B NoES8EtgDVYQ== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485626127" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:05:56 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 10/20] monitor: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:30 -0700 Message-Id: <20200921190040.45309-11-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.69 / 15.00 / 15.00 X-Rspamd-Queue-Id: CB0DDA0B82 X-Rspamd-UID: 97abe5 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 47 License: LGPL-2.1-or-later monitor/bt.h monitor/hcidump.h monitor/avdtp.h monitor/crc.c monitor/sdp.c monitor/hwdb.c monitor/intel.h monitor/avctp.c monitor/control.h monitor/display.c monitor/a2dp.c monitor/ll.c monitor/ll.h monitor/jlink.h monitor/broadcom.h monitor/lmp.c monitor/keys.c monitor/ellisys.c monitor/main.c monitor/ellisys.h monitor/hwdb.h monitor/display.h monitor/jlink.c monitor/rfcomm.h monitor/packet.c monitor/crc.h monitor/keys.h monitor/sdp.h monitor/rfcomm.c monitor/avdtp.c monitor/a2dp.h monitor/avctp.h monitor/vendor.h monitor/hcidump.c monitor/intel.c monitor/tty.h monitor/control.c monitor/lmp.h monitor/analyze.c monitor/bnep.c monitor/l2cap.c monitor/vendor.c monitor/packet.h monitor/broadcom.c monitor/analyze.h monitor/l2cap.h monitor/bnep.h --- monitor/a2dp.c | 15 +-------------- monitor/a2dp.h | 15 +-------------- monitor/analyze.c | 15 +-------------- monitor/analyze.h | 15 +-------------- monitor/avctp.c | 15 +-------------- monitor/avctp.h | 15 +-------------- monitor/avdtp.c | 15 +-------------- monitor/avdtp.h | 15 +-------------- monitor/bnep.c | 15 +-------------- monitor/bnep.h | 15 +-------------- monitor/broadcom.c | 15 +-------------- monitor/broadcom.h | 15 +-------------- monitor/bt.h | 15 +-------------- monitor/control.c | 15 +-------------- monitor/control.h | 15 +-------------- monitor/crc.c | 15 +-------------- monitor/crc.h | 15 +-------------- monitor/display.c | 15 +-------------- monitor/display.h | 15 +-------------- monitor/ellisys.c | 15 +-------------- monitor/ellisys.h | 15 +-------------- monitor/hcidump.c | 15 +-------------- monitor/hcidump.h | 15 +-------------- monitor/hwdb.c | 15 +-------------- monitor/hwdb.h | 15 +-------------- monitor/intel.c | 15 +-------------- monitor/intel.h | 15 +-------------- monitor/jlink.c | 15 +-------------- monitor/jlink.h | 15 +-------------- monitor/keys.c | 15 +-------------- monitor/keys.h | 15 +-------------- monitor/l2cap.c | 15 +-------------- monitor/l2cap.h | 15 +-------------- monitor/ll.c | 15 +-------------- monitor/ll.h | 15 +-------------- monitor/lmp.c | 15 +-------------- monitor/lmp.h | 15 +-------------- monitor/main.c | 15 +-------------- monitor/packet.c | 15 +-------------- monitor/packet.h | 15 +-------------- monitor/rfcomm.c | 15 +-------------- monitor/rfcomm.h | 15 +-------------- monitor/sdp.c | 15 +-------------- monitor/sdp.h | 15 +-------------- monitor/tty.h | 15 +-------------- monitor/vendor.c | 15 +-------------- monitor/vendor.h | 15 +-------------- 47 files changed, 47 insertions(+), 658 deletions(-) diff --git a/monitor/a2dp.c b/monitor/a2dp.c index 4a1d0e1c4..ac2e1a228 100644 --- a/monitor/a2dp.c +++ b/monitor/a2dp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2018 Pali Rohár <pali.rohar@gmail.com> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/a2dp.h b/monitor/a2dp.h index 72a8f1f45..814c8ed90 100644 --- a/monitor/a2dp.h +++ b/monitor/a2dp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool a2dp_codec_cap(uint8_t codec, uint8_t losc, struct l2cap_frame *frame); diff --git a/monitor/analyze.c b/monitor/analyze.c index 4dc2891a1..784f9a0a4 100644 --- a/monitor/analyze.c +++ b/monitor/analyze.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/analyze.h b/monitor/analyze.h index c643d3502..774ac9db5 100644 --- a/monitor/analyze.h +++ b/monitor/analyze.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void analyze_trace(const char *path); diff --git a/monitor/avctp.c b/monitor/avctp.c index 6c2c2cac0..dc03195a8 100644 --- a/monitor/avctp.c +++ b/monitor/avctp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/avctp.h b/monitor/avctp.h index 2613f14f3..1cca5a756 100644 --- a/monitor/avctp.h +++ b/monitor/avctp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void avctp_packet(const struct l2cap_frame *frame); diff --git a/monitor/avdtp.c b/monitor/avdtp.c index 6a342a282..9fe72d240 100644 --- a/monitor/avdtp.c +++ b/monitor/avdtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/avdtp.h b/monitor/avdtp.h index f77d82ee2..1bc4dd03d 100644 --- a/monitor/avdtp.h +++ b/monitor/avdtp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void avdtp_packet(const struct l2cap_frame *frame); diff --git a/monitor/bnep.c b/monitor/bnep.c index 6af54e0c5..3b8b284a9 100644 --- a/monitor/bnep.c +++ b/monitor/bnep.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/bnep.h b/monitor/bnep.h index 38340d6c1..3ccc1b766 100644 --- a/monitor/bnep.h +++ b/monitor/bnep.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void bnep_packet(const struct l2cap_frame *frame); diff --git a/monitor/broadcom.c b/monitor/broadcom.c index 787ff2950..4f8455583 100644 --- a/monitor/broadcom.c +++ b/monitor/broadcom.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/broadcom.h b/monitor/broadcom.h index ceda0e18b..5cb51d81d 100644 --- a/monitor/broadcom.h +++ b/monitor/broadcom.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/bt.h b/monitor/bt.h index 37e81e8a3..aca847d7c 100644 --- a/monitor/bt.h +++ b/monitor/bt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/control.c b/monitor/control.c index 273075888..962da4980 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/control.h b/monitor/control.h index ddf485f1f..29616c4f1 100644 --- a/monitor/control.h +++ b/monitor/control.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/crc.c b/monitor/crc.c index 912b37ebc..8d0e31db9 100644 --- a/monitor/crc.c +++ b/monitor/crc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/crc.h b/monitor/crc.h index 772388b80..c59775100 100644 --- a/monitor/crc.h +++ b/monitor/crc.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/display.c b/monitor/display.c index 990395425..b11b71d5d 100644 --- a/monitor/display.c +++ b/monitor/display.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/display.h b/monitor/display.h index 98073b99e..f3a614b81 100644 --- a/monitor/display.h +++ b/monitor/display.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/monitor/ellisys.c b/monitor/ellisys.c index e533eeceb..61ac24c23 100644 --- a/monitor/ellisys.c +++ b/monitor/ellisys.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/ellisys.h b/monitor/ellisys.h index 8be888dfe..c0c4ff192 100644 --- a/monitor/ellisys.h +++ b/monitor/ellisys.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/hcidump.c b/monitor/hcidump.c index 8b6f846d3..690b9b913 100644 --- a/monitor/hcidump.c +++ b/monitor/hcidump.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/hcidump.h b/monitor/hcidump.h index c90865068..d32b33c81 100644 --- a/monitor/hcidump.h +++ b/monitor/hcidump.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int hcidump_tracing(void); diff --git a/monitor/hwdb.c b/monitor/hwdb.c index f2431fad8..22de9edfb 100644 --- a/monitor/hwdb.c +++ b/monitor/hwdb.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/hwdb.h b/monitor/hwdb.h index 79f505a2d..5789b6507 100644 --- a/monitor/hwdb.h +++ b/monitor/hwdb.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/intel.c b/monitor/intel.c index 41e70ba0c..18840f3e7 100644 --- a/monitor/intel.c +++ b/monitor/intel.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/intel.h b/monitor/intel.h index 573b23f3f..bf00ad491 100644 --- a/monitor/intel.h +++ b/monitor/intel.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/jlink.c b/monitor/jlink.c index afa9d9323..9aaa4ebd8 100644 --- a/monitor/jlink.c +++ b/monitor/jlink.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2018 Codecoup * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/jlink.h b/monitor/jlink.h index d7c76704c..e445e553c 100644 --- a/monitor/jlink.h +++ b/monitor/jlink.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2018 Codecoup * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int jlink_init(void); diff --git a/monitor/keys.c b/monitor/keys.c index e60aa9386..d2fa3b23f 100644 --- a/monitor/keys.c +++ b/monitor/keys.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/keys.h b/monitor/keys.h index 61ec50a4c..e40c90fa9 100644 --- a/monitor/keys.h +++ b/monitor/keys.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/l2cap.c b/monitor/l2cap.c index 41c766863..ca1997a0c 100644 --- a/monitor/l2cap.c +++ b/monitor/l2cap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/l2cap.h b/monitor/l2cap.h index 07864caee..e46042db4 100644 --- a/monitor/l2cap.h +++ b/monitor/l2cap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/ll.c b/monitor/ll.c index 4b3f567bd..cf93647e0 100644 --- a/monitor/ll.c +++ b/monitor/ll.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/ll.h b/monitor/ll.h index 98e0bf489..35d631363 100644 --- a/monitor/ll.h +++ b/monitor/ll.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/lmp.c b/monitor/lmp.c index 3088c5ee2..0d17f5c98 100644 --- a/monitor/lmp.c +++ b/monitor/lmp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/lmp.h b/monitor/lmp.h index 9564c7779..d29ad8e46 100644 --- a/monitor/lmp.h +++ b/monitor/lmp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/main.c b/monitor/main.c index 24ec3c567..e6a40703c 100644 --- a/monitor/main.c +++ b/monitor/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/packet.c b/monitor/packet.c index bef134095..d83552f74 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/packet.h b/monitor/packet.h index 3a139ecb7..409bf0e54 100644 --- a/monitor/packet.h +++ b/monitor/packet.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c index 94d28de31..9b88a3440 100644 --- a/monitor/rfcomm.c +++ b/monitor/rfcomm.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/rfcomm.h b/monitor/rfcomm.h index c15735234..81ab55b21 100644 --- a/monitor/rfcomm.h +++ b/monitor/rfcomm.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define RFCOMM_SABM 0x2f diff --git a/monitor/sdp.c b/monitor/sdp.c index 575eda536..10bc0a121 100644 --- a/monitor/sdp.c +++ b/monitor/sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/sdp.h b/monitor/sdp.h index c8a9bb0cd..4fffb30f9 100644 --- a/monitor/sdp.h +++ b/monitor/sdp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void sdp_packet(const struct l2cap_frame *frame); diff --git a/monitor/tty.h b/monitor/tty.h index f0ba0c5c0..87b3fd53c 100644 --- a/monitor/tty.h +++ b/monitor/tty.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2016 Intel Corporation * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/monitor/vendor.c b/monitor/vendor.c index 3dda2ae3b..ecbfcf2eb 100644 --- a/monitor/vendor.c +++ b/monitor/vendor.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/monitor/vendor.h b/monitor/vendor.h index f5792b3c5..c70552b66 100644 --- a/monitor/vendor.h +++ b/monitor/vendor.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 2Ls3As75aF+TFQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:06:54 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id wPa9Os35aF+mkQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:06:53 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D95DD40886; Mon, 21 Sep 2020 21:06:44 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727681AbgIUTGn (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:06:43 -0400 Received: from mga18.intel.com ([134.134.136.126]:15627 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727382AbgIUTGn (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:06:43 -0400 IronPort-SDR: xrroyfHe6oY2RJDvM35ewLBBySO/Lsweo3WiZdwgtyG0+rlwUECFIis0epkxS3oUnPmHOI06Ms idOSfntN+FOw== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="148216388" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="148216388" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:06:23 -0700 IronPort-SDR: E17W54yW7Av6jjXcox5IVlSIovDLu8YCFtnjeuM/vv91OOgICz2XI/mfZ7Zt2KgFqMmfhau6yV DQhN1BtR1uMw== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485626301" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:06:23 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 11/20] obexd: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:31 -0700 Message-Id: <20200921190040.45309-12-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.13 / 15.00 / 15.00 X-Rspamd-Queue-Id: D95DD40886 X-Rspamd-UID: 0e2fb1 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 65 License: GPL-2.0-or-later obexd/src/mimetype.c obexd/src/transport.h obexd/src/server.c obexd/src/obex.c obexd/src/log.h obexd/src/service.h obexd/src/plugin.h obexd/src/plugin.c obexd/src/main.c obexd/src/mimetype.h obexd/src/transport.c obexd/src/obexd.h obexd/src/obex.h obexd/src/obex-priv.h obexd/src/log.c obexd/src/map_ap.h obexd/src/manager.c obexd/src/service.c obexd/src/server.h obexd/src/manager.h obexd/plugins/opp.c obexd/plugins/vcard.h obexd/plugins/pbap.c obexd/plugins/vcard.c obexd/plugins/messages.h obexd/plugins/phonebook.h obexd/plugins/pcsuite.c obexd/plugins/messages-tracker.c obexd/plugins/phonebook-tracker.c obexd/plugins/irmc.c obexd/plugins/ftp.c obexd/plugins/ftp.h obexd/plugins/filesystem.c obexd/plugins/messages-dummy.c obexd/plugins/phonebook-ebook.c obexd/plugins/syncevolution.c obexd/plugins/bluetooth.c obexd/plugins/phonebook-dummy.c obexd/plugins/filesystem.h obexd/plugins/mas.c obexd/client/transport.h obexd/client/opp.c obexd/client/pbap.c obexd/client/transfer.h obexd/client/opp.h obexd/client/driver.c obexd/client/map-event.h obexd/client/bluetooth.h obexd/client/sync.h obexd/client/transport.c obexd/client/pbap.h obexd/client/driver.h obexd/client/transfer.c obexd/client/ftp.c obexd/client/map.h obexd/client/ftp.h obexd/client/bluetooth.c obexd/client/manager.c obexd/client/session.h obexd/client/session.c obexd/client/map.c obexd/client/sync.c obexd/client/map-event.c obexd/client/mns.c obexd/client/manager.h --- obexd/client/bluetooth.c | 15 +-------------- obexd/client/bluetooth.h | 15 +-------------- obexd/client/driver.c | 15 +-------------- obexd/client/driver.h | 15 +-------------- obexd/client/ftp.c | 15 +-------------- obexd/client/ftp.h | 15 +-------------- obexd/client/manager.c | 15 +-------------- obexd/client/manager.h | 15 +-------------- obexd/client/map-event.c | 15 +-------------- obexd/client/map-event.h | 15 +-------------- obexd/client/map.c | 15 +-------------- obexd/client/map.h | 15 +-------------- obexd/client/mns.c | 15 +-------------- obexd/client/opp.c | 15 +-------------- obexd/client/opp.h | 15 +-------------- obexd/client/pbap.c | 15 +-------------- obexd/client/pbap.h | 15 +-------------- obexd/client/session.c | 15 +-------------- obexd/client/session.h | 15 +-------------- obexd/client/sync.c | 15 +-------------- obexd/client/sync.h | 15 +-------------- obexd/client/transfer.c | 15 +-------------- obexd/client/transfer.h | 15 +-------------- obexd/client/transport.c | 15 +-------------- obexd/client/transport.h | 15 +-------------- obexd/plugins/bluetooth.c | 15 +-------------- obexd/plugins/filesystem.c | 15 +-------------- obexd/plugins/filesystem.h | 15 +-------------- obexd/plugins/ftp.c | 15 +-------------- obexd/plugins/ftp.h | 15 +-------------- obexd/plugins/irmc.c | 15 +-------------- obexd/plugins/mas.c | 15 +-------------- obexd/plugins/messages-dummy.c | 15 +-------------- obexd/plugins/messages-tracker.c | 15 +-------------- obexd/plugins/messages.h | 15 +-------------- obexd/plugins/opp.c | 15 +-------------- obexd/plugins/pbap.c | 15 +-------------- obexd/plugins/pcsuite.c | 15 +-------------- obexd/plugins/phonebook-dummy.c | 15 +-------------- obexd/plugins/phonebook-ebook.c | 15 +-------------- obexd/plugins/phonebook-tracker.c | 15 +-------------- obexd/plugins/phonebook.h | 15 +-------------- obexd/plugins/syncevolution.c | 15 +-------------- obexd/plugins/vcard.c | 15 +-------------- obexd/plugins/vcard.h | 15 +-------------- obexd/src/log.c | 15 +-------------- obexd/src/log.h | 15 +-------------- obexd/src/main.c | 15 +-------------- obexd/src/manager.c | 15 +-------------- obexd/src/manager.h | 15 +-------------- obexd/src/map_ap.h | 15 +-------------- obexd/src/mimetype.c | 15 +-------------- obexd/src/mimetype.h | 15 +-------------- obexd/src/obex-priv.h | 15 +-------------- obexd/src/obex.c | 15 +-------------- obexd/src/obex.h | 15 +-------------- obexd/src/obexd.h | 15 +-------------- obexd/src/plugin.c | 15 +-------------- obexd/src/plugin.h | 15 +-------------- obexd/src/server.c | 15 +-------------- obexd/src/server.h | 15 +-------------- obexd/src/service.c | 15 +-------------- obexd/src/service.h | 15 +-------------- obexd/src/transport.c | 15 +-------------- obexd/src/transport.h | 15 +-------------- 65 files changed, 65 insertions(+), 910 deletions(-) diff --git a/obexd/client/bluetooth.c b/obexd/client/bluetooth.c index 0c043e0ac..ca2c023fb 100644 --- a/obexd/client/bluetooth.c +++ b/obexd/client/bluetooth.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/bluetooth.h b/obexd/client/bluetooth.h index 968e131e0..4d5ba9c21 100644 --- a/obexd/client/bluetooth.h +++ b/obexd/client/bluetooth.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int bluetooth_init(void); diff --git a/obexd/client/driver.c b/obexd/client/driver.c index 0dae35601..195cdd2f1 100644 --- a/obexd/client/driver.c +++ b/obexd/client/driver.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/driver.h b/obexd/client/driver.h index 0112219d5..cc4cace7b 100644 --- a/obexd/client/driver.h +++ b/obexd/client/driver.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obc_driver { diff --git a/obexd/client/ftp.c b/obexd/client/ftp.c index 5e30654af..160e0636a 100644 --- a/obexd/client/ftp.c +++ b/obexd/client/ftp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/ftp.h b/obexd/client/ftp.h index 3d9096863..1326c8522 100644 --- a/obexd/client/ftp.h +++ b/obexd/client/ftp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int ftp_init(void); diff --git a/obexd/client/manager.c b/obexd/client/manager.c index fbcad6da4..75f1bfb04 100644 --- a/obexd/client/manager.c +++ b/obexd/client/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/manager.h b/obexd/client/manager.h index e4068de44..d4fdf8a1b 100644 --- a/obexd/client/manager.h +++ b/obexd/client/manager.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int client_manager_init(void); diff --git a/obexd/client/map-event.c b/obexd/client/map-event.c index e164e863c..c988ef3dd 100644 --- a/obexd/client/map-event.c +++ b/obexd/client/map-event.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX @@ -5,20 +6,6 @@ * Copyright (C) 2013 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/map-event.h b/obexd/client/map-event.h index 5414b2621..bb127b0f4 100644 --- a/obexd/client/map-event.h +++ b/obexd/client/map-event.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX @@ -5,20 +6,6 @@ * Copyright (C) 2013 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obc_session; diff --git a/obexd/client/map.c b/obexd/client/map.c index 23be2d6b2..74828cddb 100644 --- a/obexd/client/map.c +++ b/obexd/client/map.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client * * Copyright (C) 2011 Bartosz Szatkowski <bulislaw@linux.com> for Comarch * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/map.h b/obexd/client/map.h index 86f6b9512..15228ed0a 100644 --- a/obexd/client/map.h +++ b/obexd/client/map.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client * * Copyright (C) 2011 Bartosz Szatkowski <bulislaw@linux.com> for Comarch * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int map_init(void); diff --git a/obexd/client/mns.c b/obexd/client/mns.c index 4912cb90f..e52505642 100644 --- a/obexd/client/mns.c +++ b/obexd/client/mns.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2013 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/opp.c b/obexd/client/opp.c index 92785f66e..90d0c0c8e 100644 --- a/obexd/client/opp.c +++ b/obexd/client/opp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/opp.h b/obexd/client/opp.h index a23e94e00..ecc3e05ed 100644 --- a/obexd/client/opp.h +++ b/obexd/client/opp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int opp_init(void); diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c index 3f5665fcd..1a2bacc9f 100644 --- a/obexd/client/pbap.c +++ b/obexd/client/pbap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/pbap.h b/obexd/client/pbap.h index ce56258b5..8107f81bf 100644 --- a/obexd/client/pbap.h +++ b/obexd/client/pbap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int pbap_init(void); diff --git a/obexd/client/session.c b/obexd/client/session.c index 5bd2d2670..6955a8089 100644 --- a/obexd/client/session.c +++ b/obexd/client/session.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2011-2012 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/session.h b/obexd/client/session.h index b561b7e58..2c646df1a 100644 --- a/obexd/client/session.h +++ b/obexd/client/session.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2011-2012 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/obexd/client/sync.c b/obexd/client/sync.c index 548c318c3..92faf4434 100644 --- a/obexd/client/sync.c +++ b/obexd/client/sync.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/sync.h b/obexd/client/sync.h index 8adc5f8d6..5d8844c4f 100644 --- a/obexd/client/sync.h +++ b/obexd/client/sync.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int sync_init(void); diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c index b53dffa21..744d8f106 100644 --- a/obexd/client/transfer.c +++ b/obexd/client/transfer.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2011-2012 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/transfer.h b/obexd/client/transfer.h index b6b835d18..323332a62 100644 --- a/obexd/client/transfer.h +++ b/obexd/client/transfer.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Client @@ -6,20 +7,6 @@ * Copyright (C) 2011-2012 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obc_transfer; diff --git a/obexd/client/transport.c b/obexd/client/transport.c index 4cd770672..4e442e9b5 100644 --- a/obexd/client/transport.c +++ b/obexd/client/transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/client/transport.h b/obexd/client/transport.h index b035cfc45..e1f1a5c53 100644 --- a/obexd/client/transport.h +++ b/obexd/client/transport.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef void (*obc_transport_func)(GIOChannel *io, GError *err, diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c index ba1e0a99a..d232d3fd5 100644 --- a/obexd/plugins/bluetooth.c +++ b/obexd/plugins/bluetooth.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c index 48239a8bc..8e53c181c 100644 --- a/obexd/plugins/filesystem.c +++ b/obexd/plugins/filesystem.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/filesystem.h b/obexd/plugins/filesystem.h index f95773beb..63cda985e 100644 --- a/obexd/plugins/filesystem.h +++ b/obexd/plugins/filesystem.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ ssize_t string_read(void *object, void *buf, size_t count); diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c index 3ee18a619..f60cf143d 100644 --- a/obexd/plugins/ftp.c +++ b/obexd/plugins/ftp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/ftp.h b/obexd/plugins/ftp.h index f06de8490..b9934b23b 100644 --- a/obexd/plugins/ftp.h +++ b/obexd/plugins/ftp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void *ftp_connect(struct obex_session *os, int *err); diff --git a/obexd/plugins/irmc.c b/obexd/plugins/irmc.c index fcf5340e7..cd143e7a3 100644 --- a/obexd/plugins/irmc.c +++ b/obexd/plugins/irmc.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX IrMC Sync Server * * Copyright (C) 2010 Marcel Mol <marcel@mesa.nl> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c index f73c3e9d8..5d00bc563 100644 --- a/obexd/plugins/mas.c +++ b/obexd/plugins/mas.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2010-2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c index 3eca9ef4c..34199fa05 100644 --- a/obexd/plugins/messages-dummy.c +++ b/obexd/plugins/messages-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2010-2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/messages-tracker.c b/obexd/plugins/messages-tracker.c index 60f3a807e..4ce9f221d 100644 --- a/obexd/plugins/messages-tracker.c +++ b/obexd/plugins/messages-tracker.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2010-2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/messages.h b/obexd/plugins/messages.h index 00a16b1ae..535ec303c 100644 --- a/obexd/plugins/messages.h +++ b/obexd/plugins/messages.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2010-2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <glib.h> diff --git a/obexd/plugins/opp.c b/obexd/plugins/opp.c index 5bb766770..860161303 100644 --- a/obexd/plugins/opp.c +++ b/obexd/plugins/opp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c index d5a3046ae..efae92cd8 100644 --- a/obexd/plugins/pbap.c +++ b/obexd/plugins/pbap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c index 43ab409e9..b2232ea09 100644 --- a/obexd/plugins/pcsuite.c +++ b/obexd/plugins/pcsuite.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c index 9279ef29a..4d0b70504 100644 --- a/obexd/plugins/phonebook-dummy.c +++ b/obexd/plugins/phonebook-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/phonebook-ebook.c b/obexd/plugins/phonebook-ebook.c index c422585df..30be9d921 100644 --- a/obexd/plugins/phonebook-ebook.c +++ b/obexd/plugins/phonebook-ebook.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c index c1d14078b..30f945b84 100644 --- a/obexd/plugins/phonebook-tracker.c +++ b/obexd/plugins/phonebook-tracker.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Phonebook access through D-Bus vCard and call history service * * Copyright (C) 2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/phonebook.h b/obexd/plugins/phonebook.h index 70a9cb797..c73ae73b8 100644 --- a/obexd/plugins/phonebook.h +++ b/obexd/plugins/phonebook.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define EOL "\r\n" diff --git a/obexd/plugins/syncevolution.c b/obexd/plugins/syncevolution.c index 854505a58..88744f28a 100644 --- a/obexd/plugins/syncevolution.c +++ b/obexd/plugins/syncevolution.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c index dc7c3b3e6..0a727b729 100644 --- a/obexd/plugins/vcard.c +++ b/obexd/plugins/vcard.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * OBEX Server * * Copyright (C) 2008-2010 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/plugins/vcard.h b/obexd/plugins/vcard.h index 22c3f6899..880660ffa 100644 --- a/obexd/plugins/vcard.h +++ b/obexd/plugins/vcard.h @@ -1,22 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * OBEX Server * * Copyright (C) 2008-2010 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ enum phonebook_number_type { diff --git a/obexd/src/log.c b/obexd/src/log.c index 8e2ebaab2..6c29064e3 100644 --- a/obexd/src/log.c +++ b/obexd/src/log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/log.h b/obexd/src/log.h index d9fb8678f..7dc74d542 100644 --- a/obexd/src/log.h +++ b/obexd/src/log.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void info(const char *format, ...) __attribute__((format(printf, 1, 2))); diff --git a/obexd/src/main.c b/obexd/src/main.c index 139f1412c..629a3b4c1 100644 --- a/obexd/src/main.c +++ b/obexd/src/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/manager.c b/obexd/src/manager.c index a4af627cb..01741fe62 100644 --- a/obexd/src/manager.c +++ b/obexd/src/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/manager.h b/obexd/src/manager.h index d709af5a8..8fa12d15d 100644 --- a/obexd/src/manager.h +++ b/obexd/src/manager.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <dbus/dbus.h> diff --git a/obexd/src/map_ap.h b/obexd/src/map_ap.h index da108fe6e..59efc49de 100644 --- a/obexd/src/map_ap.h +++ b/obexd/src/map_ap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2010-2011 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ /* List of OBEX application parameters tags as per MAP specification. */ diff --git a/obexd/src/mimetype.c b/obexd/src/mimetype.c index c8b040a43..212f24b18 100644 --- a/obexd/src/mimetype.c +++ b/obexd/src/mimetype.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/mimetype.h b/obexd/src/mimetype.h index 79529b890..e1c14f405 100644 --- a/obexd/src/mimetype.h +++ b/obexd/src/mimetype.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef gboolean (*obex_object_io_func) (void *object, int flags, int err, diff --git a/obexd/src/obex-priv.h b/obexd/src/obex-priv.h index 355a7f87b..db409e7e4 100644 --- a/obexd/src/obex-priv.h +++ b/obexd/src/obex-priv.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obex_session { diff --git a/obexd/src/obex.c b/obexd/src/obex.c index 2850d3a37..9f992ec18 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/obex.h b/obexd/src/obex.h index 67593f11b..755be1caf 100644 --- a/obexd/src/obex.h +++ b/obexd/src/obex.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <unistd.h> diff --git a/obexd/src/obexd.h b/obexd/src/obexd.h index 42c3c4d97..fe312a65b 100644 --- a/obexd/src/obexd.h +++ b/obexd/src/obexd.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define OBEX_OPP (1 << 1) diff --git a/obexd/src/plugin.c b/obexd/src/plugin.c index a1962b91d..0df9d5258 100644 --- a/obexd/src/plugin.c +++ b/obexd/src/plugin.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/plugin.h b/obexd/src/plugin.h index 13d77695f..703878460 100644 --- a/obexd/src/plugin.h +++ b/obexd/src/plugin.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obex_plugin_desc { diff --git a/obexd/src/server.c b/obexd/src/server.c index db854233b..a8fc45092 100644 --- a/obexd/src/server.c +++ b/obexd/src/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/server.h b/obexd/src/server.h index 278c35fce..c31236ec0 100644 --- a/obexd/src/server.h +++ b/obexd/src/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -6,20 +7,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obex_server { diff --git a/obexd/src/service.c b/obexd/src/service.c index c088535e9..0f4e420e8 100644 --- a/obexd/src/service.c +++ b/obexd/src/service.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/service.h b/obexd/src/service.h index 5d9d325fb..e3aee3bf3 100644 --- a/obexd/src/service.h +++ b/obexd/src/service.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define OBEX_PORT_RANDOM UINT16_MAX diff --git a/obexd/src/transport.c b/obexd/src/transport.c index 4984643e2..4b5895e5d 100644 --- a/obexd/src/transport.c +++ b/obexd/src/transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/obexd/src/transport.h b/obexd/src/transport.h index 97e10d05f..3a16b7620 100644 --- a/obexd/src/transport.h +++ b/obexd/src/transport.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * OBEX Server @@ -5,20 +6,6 @@ * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct obex_transport_driver { -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id IBv4Ier5aF+TFQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:07:22 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 0G6XH+r5aF9avQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:07:22 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id EE0724097D; Mon, 21 Sep 2020 21:07:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727869AbgIUTHP (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:07:15 -0400 Received: from mga05.intel.com ([192.55.52.43]:8705 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbgIUTHP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:07:15 -0400 IronPort-SDR: HJQlsNi+3EFQuwTLJrsGpfrzw1WgER3C5/oj/Q1oIhvLv7hEyKCZMdgILjXZjnTgEsCu4JiCZE cFVs3VfwtQag== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="245298266" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="245298266" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:06:59 -0700 IronPort-SDR: lpvxgaP5jjElJBywVu8JcUPQL2yqYZz1hKoO4NhO0iwW1EgLkcB00xGY3RabW+QmEkVKvJJ2Oi HTuqNyU08H+g== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485626547" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:06:58 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 12/20] peripheral: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:32 -0700 Message-Id: <20200921190040.45309-13-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: EE0724097D X-Rspamd-UID: 450443 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 11 License: LGPL-2.1-or-later peripheral/log.h peripheral/main.c peripheral/efivars.c peripheral/attach.h peripheral/gatt.c peripheral/attach.c peripheral/log.c peripheral/gap.h peripheral/efivars.h peripheral/gap.c peripheral/gatt.h --- peripheral/attach.c | 15 +-------------- peripheral/attach.h | 15 +-------------- peripheral/efivars.c | 15 +-------------- peripheral/efivars.h | 15 +-------------- peripheral/gap.c | 15 +-------------- peripheral/gap.h | 15 +-------------- peripheral/gatt.c | 15 +-------------- peripheral/gatt.h | 15 +-------------- peripheral/log.c | 15 +-------------- peripheral/log.h | 15 +-------------- peripheral/main.c | 15 +-------------- 11 files changed, 11 insertions(+), 154 deletions(-) diff --git a/peripheral/attach.c b/peripheral/attach.c index 1de02ac04..f7dc7ecea 100644 --- a/peripheral/attach.c +++ b/peripheral/attach.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/peripheral/attach.h b/peripheral/attach.h index f76e2fba2..c8d787d76 100644 --- a/peripheral/attach.h +++ b/peripheral/attach.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void attach_start(void); diff --git a/peripheral/efivars.c b/peripheral/efivars.c index 3cc213c0c..74fceed3e 100644 --- a/peripheral/efivars.c +++ b/peripheral/efivars.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/peripheral/efivars.h b/peripheral/efivars.h index 430d14330..5dac95395 100644 --- a/peripheral/efivars.h +++ b/peripheral/efivars.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define EFIVARS_NON_VOLATILE 0x00000001 diff --git a/peripheral/gap.c b/peripheral/gap.c index 52a7bed9b..b12e08b3d 100644 --- a/peripheral/gap.c +++ b/peripheral/gap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/peripheral/gap.h b/peripheral/gap.h index 6d6737810..da307a2ad 100644 --- a/peripheral/gap.h +++ b/peripheral/gap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/peripheral/gatt.c b/peripheral/gatt.c index bbbf3f59f..ff1354cb4 100644 --- a/peripheral/gatt.c +++ b/peripheral/gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/peripheral/gatt.h b/peripheral/gatt.h index 5b68f3573..7e2418a70 100644 --- a/peripheral/gatt.h +++ b/peripheral/gatt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/peripheral/log.c b/peripheral/log.c index d5834eb72..ac674b2df 100644 --- a/peripheral/log.c +++ b/peripheral/log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/peripheral/log.h b/peripheral/log.h index 36619b36e..29d1d6ac0 100644 --- a/peripheral/log.h +++ b/peripheral/log.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void log_open(void); diff --git a/peripheral/main.c b/peripheral/main.c index 75427ab3a..6ce729178 100644 --- a/peripheral/main.c +++ b/peripheral/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WFj3Jfz5aF8WtgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:07:40 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 4JjDIvz5aF+4IAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:07:40 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E3B37A0B89; Mon, 21 Sep 2020 21:07:33 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727870AbgIUTHc (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:07:32 -0400 Received: from mga09.intel.com ([134.134.136.24]:2463 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbgIUTHb (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:07:31 -0400 IronPort-SDR: h3rHhkWrXQgd3BakwqvyX70Aqk26ndRv3WK/hijPAQoo7PdLYRiFVUiAfepREyZSZx3weogiuf Jo7XgFrYKxPA== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="161384277" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="161384277" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:07:31 -0700 IronPort-SDR: I83WMMCFb4vnwx+OlmRdBAf1n8xHVUo3CEq4RgjuHDXYUtEphlPN/Jg8dWHiyMQ34uWxq55lXK onkPKsLKbjjw== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485626805" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:07:30 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 13/20] plugins: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:33 -0700 Message-Id: <20200921190040.45309-14-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.83 / 15.00 / 15.00 X-Rspamd-Queue-Id: E3B37A0B89 X-Rspamd-UID: 2f68cb From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 7 License: GPL-2.0-or-later plugins/autopair.c plugins/hostname.c plugins/neard.c plugins/policy.c plugins/sixaxis.c plugins/wiimote.c plugins/external-dummy.c --- plugins/autopair.c | 15 +-------------- plugins/external-dummy.c | 15 +-------------- plugins/hostname.c | 15 +-------------- plugins/neard.c | 15 +-------------- plugins/policy.c | 15 +-------------- plugins/sixaxis.c | 15 +-------------- plugins/wiimote.c | 15 +-------------- 7 files changed, 7 insertions(+), 98 deletions(-) diff --git a/plugins/autopair.c b/plugins/autopair.c index 3089430a8..665a4f4a6 100644 --- a/plugins/autopair.c +++ b/plugins/autopair.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/external-dummy.c b/plugins/external-dummy.c index 536ad0663..1c209e8b7 100644 --- a/plugins/external-dummy.c +++ b/plugins/external-dummy.c @@ -1,21 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/hostname.c b/plugins/hostname.c index 4f9dfe6d8..f7ab9e8bc 100644 --- a/plugins/hostname.c +++ b/plugins/hostname.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/neard.c b/plugins/neard.c index 6ffcd6e10..ff5de11f4 100644 --- a/plugins/neard.c +++ b/plugins/neard.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2013 Tieto Poland * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/policy.c b/plugins/policy.c index 3ce6f1deb..dac1b7a24 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013 Intel Corporation. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c index 996f85dd6..d693a86c0 100644 --- a/plugins/sixaxis.c +++ b/plugins/sixaxis.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2013 Szymon Janc <szymon.janc@gmail.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/plugins/wiimote.c b/plugins/wiimote.c index 0ced27514..9c4e0a58b 100644 --- a/plugins/wiimote.c +++ b/plugins/wiimote.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011-2012 David Herrmann <dh.herrmann@googlemail.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qJ3YBCP6aF+TFQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:08:19 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id gKw1AiP6aF/OfgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:08:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E9CADA0B11; Mon, 21 Sep 2020 21:08:04 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727269AbgIUTIE (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:08:04 -0400 Received: from mga05.intel.com ([192.55.52.43]:8773 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726969AbgIUTIE (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:08:04 -0400 IronPort-SDR: Tc+QK4KOLdIHv7mLbCY27W8qGe0klK5TEI2PDprdDxJ6yTb1Do6YitTN0DbzILFXUq1338eUBg JoIgoDOokFQA== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="245298370" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="245298370" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:07:52 -0700 IronPort-SDR: xA1Q7aLTvbhODfMv7J1gnmT4Bbf7v1WBKq2JfDAEi4l/d2iraI5eXdzYJ1rsHflrG5H2WBlpPo qy6i7X2nBKRw== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485626969" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:07:51 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 14/20] profiles: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:34 -0700 Message-Id: <20200921190040.45309-15-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.73 / 15.00 / 15.00 X-Rspamd-Queue-Id: E9CADA0B11 X-Rspamd-UID: d63d6b From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 72 LGPL-2.1-or-later : 6 License: GPL-2.0-or-later profiles/deviceinfo/dis.c profiles/deviceinfo/deviceinfo.c profiles/health/hdp_types.h profiles/health/mcap.c profiles/health/hdp_manager.c profiles/health/hdp_main.c profiles/health/mcap.h profiles/health/hdp_util.h profiles/health/hdp_manager.h profiles/health/hdp_util.c profiles/health/hdp.c profiles/health/hdp.h profiles/network/server.c profiles/network/connection.h profiles/network/connection.c profiles/network/manager.c profiles/network/bnep.c profiles/network/server.h profiles/network/bnep.h profiles/battery/battery.c profiles/cups/cups.h profiles/cups/sdp.c profiles/cups/main.c profiles/cups/spp.c profiles/cups/hcrp.c profiles/scanparam/scpp.c profiles/scanparam/scan.c profiles/audio/transport.h profiles/audio/avdtp.h profiles/audio/source.c profiles/audio/player.c profiles/audio/avctp.c profiles/audio/control.h profiles/audio/a2dp.c profiles/audio/source.h profiles/audio/transport.c profiles/audio/sink.c profiles/audio/avrcp.h profiles/audio/avdtp.c profiles/audio/a2dp.h profiles/audio/avrcp.c profiles/audio/media.h profiles/audio/avctp.h profiles/audio/control.c profiles/audio/sink.h profiles/audio/player.h profiles/audio/media.c profiles/sap/server.c profiles/sap/sap-dummy.c profiles/sap/main.c profiles/sap/sap.h profiles/sap/manager.c profiles/sap/server.h profiles/sap/manager.h profiles/iap/main.c profiles/gap/gas.c profiles/midi/midi.c profiles/midi/libmidi.c profiles/midi/libmidi.h profiles/input/server.c profiles/input/suspend.h profiles/input/uhid_copy.h profiles/input/device.c profiles/input/hog.c profiles/input/device.h profiles/input/hidp_defs.h profiles/input/manager.c profiles/input/suspend-none.c profiles/input/sixaxis.h profiles/input/hog-lib.c profiles/input/suspend-dummy.c profiles/input/server.h License: LGPL-2.1-or-later profiles/deviceinfo/dis.h profiles/battery/bas.h profiles/battery/bas.c profiles/scanparam/scpp.h profiles/audio/a2dp-codecs.h profiles/input/hog-lib.h --- profiles/audio/a2dp-codecs.h | 15 +-------------- profiles/audio/a2dp.c | 15 +-------------- profiles/audio/a2dp.h | 15 +-------------- profiles/audio/avctp.c | 15 +-------------- profiles/audio/avctp.h | 15 +-------------- profiles/audio/avdtp.c | 15 +-------------- profiles/audio/avdtp.h | 15 +-------------- profiles/audio/avrcp.c | 15 +-------------- profiles/audio/avrcp.h | 15 +-------------- profiles/audio/control.c | 15 +-------------- profiles/audio/control.h | 15 +-------------- profiles/audio/media.c | 15 +-------------- profiles/audio/media.h | 15 +-------------- profiles/audio/player.c | 15 +-------------- profiles/audio/player.h | 15 +-------------- profiles/audio/sink.c | 15 +-------------- profiles/audio/sink.h | 15 +-------------- profiles/audio/source.c | 15 +-------------- profiles/audio/source.h | 15 +-------------- profiles/audio/transport.c | 15 +-------------- profiles/audio/transport.h | 15 +-------------- profiles/battery/bas.c | 15 +-------------- profiles/battery/bas.h | 15 +-------------- profiles/battery/battery.c | 10 +--------- profiles/cups/cups.h | 15 +-------------- profiles/cups/hcrp.c | 15 +-------------- profiles/cups/main.c | 15 +-------------- profiles/cups/sdp.c | 15 +-------------- profiles/cups/spp.c | 15 +-------------- profiles/deviceinfo/deviceinfo.c | 15 +-------------- profiles/deviceinfo/dis.c | 15 +-------------- profiles/deviceinfo/dis.h | 15 +-------------- profiles/gap/gas.c | 10 +--------- profiles/health/hdp.c | 15 +-------------- profiles/health/hdp.h | 15 +-------------- profiles/health/hdp_main.c | 15 +-------------- profiles/health/hdp_manager.c | 15 +-------------- profiles/health/hdp_manager.h | 15 +-------------- profiles/health/hdp_types.h | 15 +-------------- profiles/health/hdp_util.c | 15 +-------------- profiles/health/hdp_util.h | 15 +-------------- profiles/health/mcap.c | 15 +-------------- profiles/health/mcap.h | 15 +-------------- profiles/iap/main.c | 15 +-------------- profiles/input/device.c | 15 +-------------- profiles/input/device.h | 15 +-------------- profiles/input/hidp_defs.h | 15 +-------------- profiles/input/hog-lib.c | 15 +-------------- profiles/input/hog-lib.h | 15 +-------------- profiles/input/hog.c | 15 +-------------- profiles/input/manager.c | 15 +-------------- profiles/input/server.c | 15 +-------------- profiles/input/server.h | 15 +-------------- profiles/input/sixaxis.h | 15 +-------------- profiles/input/suspend-dummy.c | 15 +-------------- profiles/input/suspend-none.c | 15 +-------------- profiles/input/suspend.h | 15 +-------------- profiles/midi/libmidi.c | 16 +--------------- profiles/midi/libmidi.h | 16 +--------------- profiles/midi/midi.c | 20 +------------------- profiles/network/bnep.c | 15 +-------------- profiles/network/bnep.h | 15 +-------------- profiles/network/connection.c | 15 +-------------- profiles/network/connection.h | 15 +-------------- profiles/network/manager.c | 15 +-------------- profiles/network/server.c | 15 +-------------- profiles/network/server.h | 15 +-------------- profiles/sap/main.c | 14 +------------- profiles/sap/manager.c | 14 +------------- profiles/sap/manager.h | 14 +------------- profiles/sap/sap-dummy.c | 14 +------------- profiles/sap/sap.h | 14 +------------- profiles/sap/server.c | 14 +------------- profiles/sap/server.h | 14 +------------- profiles/scanparam/scan.c | 15 +-------------- profiles/scanparam/scpp.c | 15 +-------------- profiles/scanparam/scpp.h | 15 +-------------- 77 files changed, 77 insertions(+), 1068 deletions(-) diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h index 93e9d3523..6f5670947 100644 --- a/profiles/audio/a2dp-codecs.h +++ b/profiles/audio/a2dp-codecs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2018 Pali Rohár <pali.rohar@gmail.com> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <endian.h> diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c index 2feea66c0..4ec99278a 100644 --- a/profiles/audio/a2dp.c +++ b/profiles/audio/a2dp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/a2dp.h b/profiles/audio/a2dp.h index 19466a428..b40bd4736 100644 --- a/profiles/audio/a2dp.h +++ b/profiles/audio/a2dp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct a2dp_sep; diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c index f096d22b0..c959b4f49 100644 --- a/profiles/audio/avctp.c +++ b/profiles/audio/avctp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 Texas Instruments, Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/avctp.h b/profiles/audio/avctp.h index 95d95bbbe..23e3732cd 100644 --- a/profiles/audio/avctp.h +++ b/profiles/audio/avctp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define AVCTP_CONTROL_PSM 23 diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 782268c08..5fbe50761 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h index 011fea89e..7a1c109c2 100644 --- a/profiles/audio/avdtp.h +++ b/profiles/audio/avdtp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef enum { diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 5ef98acd1..ed436de3b 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 Texas Instruments, Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h index 159ccf846..dcc580e37 100644 --- a/profiles/audio/avrcp.h +++ b/profiles/audio/avrcp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ /* player attributes */ diff --git a/profiles/audio/control.c b/profiles/audio/control.c index 14744ea94..619afc13d 100644 --- a/profiles/audio/control.c +++ b/profiles/audio/control.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 Texas Instruments, Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/control.h b/profiles/audio/control.h index aab2631b6..b9207a7b7 100644 --- a/profiles/audio/control.h +++ b/profiles/audio/control.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define AUDIO_CONTROL_INTERFACE "org.bluez.MediaControl1" diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 02bf82a49..74064d398 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/media.h b/profiles/audio/media.h index 53694f4c6..96bea9db4 100644 --- a/profiles/audio/media.h +++ b/profiles/audio/media.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct media_endpoint; diff --git a/profiles/audio/player.c b/profiles/audio/player.c index 27a7efb7e..d34b39168 100644 --- a/profiles/audio/player.c +++ b/profiles/audio/player.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> * Copyright (C) 2012-2012 Intel Corporation * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/player.h b/profiles/audio/player.h index e98550064..69f08735b 100644 --- a/profiles/audio/player.h +++ b/profiles/audio/player.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2012-2012 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef enum { diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c index 7c5e77577..134d157bc 100644 --- a/profiles/audio/sink.c +++ b/profiles/audio/sink.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/sink.h b/profiles/audio/sink.h index 93c62a206..495e612f1 100644 --- a/profiles/audio/sink.h +++ b/profiles/audio/sink.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef enum { diff --git a/profiles/audio/source.c b/profiles/audio/source.c index 0ac20fe40..fca85d4cb 100644 --- a/profiles/audio/source.c +++ b/profiles/audio/source.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2009 Joao Paulo Rechi Vita * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/source.h b/profiles/audio/source.h index a014c68d6..35ce0b163 100644 --- a/profiles/audio/source.h +++ b/profiles/audio/source.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2009 Joao Paulo Rechi Vita * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef enum { diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index dd1c553a2..8248014ae 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index 78024372f..51a67ea74 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct media_transport; diff --git a/profiles/battery/bas.c b/profiles/battery/bas.c index de369fd3c..3c6173b61 100644 --- a/profiles/battery/bas.c +++ b/profiles/battery/bas.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can rebastribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is bastributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/battery/bas.h b/profiles/battery/bas.h index 3e175b5b5..cd503a498 100644 --- a/profiles/battery/bas.h +++ b/profiles/battery/bas.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can rebastribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is bastributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct bt_bas; diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c index c9a1af4b9..13c80d05c 100644 --- a/profiles/battery/battery.c +++ b/profiles/battery/battery.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,15 +7,6 @@ * Copyright (C) 2014 Google Inc. * Copyright (C) 2017 Red Hat Inc. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifdef HAVE_CONFIG_H diff --git a/profiles/cups/cups.h b/profiles/cups/cups.h index f4e0c01cd..bdaa89498 100644 --- a/profiles/cups/cups.h +++ b/profiles/cups/cups.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ enum { /**** Backend exit codes ****/ diff --git a/profiles/cups/hcrp.c b/profiles/cups/hcrp.c index edaa2cdfd..3038fe2f8 100644 --- a/profiles/cups/hcrp.c +++ b/profiles/cups/hcrp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/cups/main.c b/profiles/cups/main.c index 1fac7267f..144a0fd78 100644 --- a/profiles/cups/main.c +++ b/profiles/cups/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/cups/sdp.c b/profiles/cups/sdp.c index de9cd4eeb..81a26281c 100644 --- a/profiles/cups/sdp.c +++ b/profiles/cups/sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/cups/spp.c b/profiles/cups/spp.c index 2f1e270f4..6e910a722 100644 --- a/profiles/cups/spp.c +++ b/profiles/cups/spp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/deviceinfo/deviceinfo.c b/profiles/deviceinfo/deviceinfo.c index fa94efe7f..b6dc0ab2e 100644 --- a/profiles/deviceinfo/deviceinfo.c +++ b/profiles/deviceinfo/deviceinfo.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Texas Instruments, Inc. * Copyright (C) 2015 Google Inc. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/deviceinfo/dis.c b/profiles/deviceinfo/dis.c index 6126a776c..87fa63306 100644 --- a/profiles/deviceinfo/dis.c +++ b/profiles/deviceinfo/dis.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012 Texas Instruments, Inc. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/deviceinfo/dis.h b/profiles/deviceinfo/dis.h index 305ba1ad0..7b6f4f123 100644 --- a/profiles/deviceinfo/dis.h +++ b/profiles/deviceinfo/dis.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct bt_dis; diff --git a/profiles/gap/gas.c b/profiles/gap/gas.c index dffa31314..ea3249be9 100644 --- a/profiles/gap/gas.c +++ b/profiles/gap/gas.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,15 +6,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * Copyright (C) 2014 Google Inc. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c index a8354936b..9f906932d 100644 --- a/profiles/health/hdp.c +++ b/profiles/health/hdp.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/hdp.h b/profiles/health/hdp.h index 6e78b0947..114453493 100644 --- a/profiles/health/hdp.h +++ b/profiles/health/hdp.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int hdp_adapter_register(struct btd_adapter *btd_adapter); diff --git a/profiles/health/hdp_main.c b/profiles/health/hdp_main.c index 2c4bbe298..4a0edf9c8 100644 --- a/profiles/health/hdp_main.c +++ b/profiles/health/hdp_main.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/hdp_manager.c b/profiles/health/hdp_manager.c index 401adf6e9..23c6a4926 100644 --- a/profiles/health/hdp_manager.c +++ b/profiles/health/hdp_manager.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/hdp_manager.h b/profiles/health/hdp_manager.h index 1cab4d008..55b51ef34 100644 --- a/profiles/health/hdp_manager.h +++ b/profiles/health/hdp_manager.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int hdp_manager_init(void); diff --git a/profiles/health/hdp_types.h b/profiles/health/hdp_types.h index b34b5e031..805b3bae2 100644 --- a/profiles/health/hdp_types.h +++ b/profiles/health/hdp_types.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HDP_TYPES_H__ diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c index 64debfc6b..ab3b78f6a 100644 --- a/profiles/health/hdp_util.c +++ b/profiles/health/hdp_util.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/hdp_util.h b/profiles/health/hdp_util.h index 35e1196b2..0b556f568 100644 --- a/profiles/health/hdp_util.h +++ b/profiles/health/hdp_util.h @@ -1,23 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HDP_UTIL_H__ diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c index ba43e6e96..32365fd50 100644 --- a/profiles/health/mcap.c +++ b/profiles/health/mcap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Signove * Copyright (C) 2014 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/health/mcap.h b/profiles/health/mcap.h index 69873ca82..5a94c8b63 100644 --- a/profiles/health/mcap.h +++ b/profiles/health/mcap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Signove * Copyright (C) 2014 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define MCAP_VERSION 0x0100 /* current version 01.00 */ diff --git a/profiles/iap/main.c b/profiles/iap/main.c index 2fd34c067..9a04f5cc0 100644 --- a/profiles/iap/main.c +++ b/profiles/iap/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/device.c b/profiles/input/device.c index 375314e7d..326a3bcb9 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2014 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/device.h b/profiles/input/device.h index f61e8a558..cf0389417 100644 --- a/profiles/input/device.h +++ b/profiles/input/device.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define L2CAP_PSM_HIDP_CTRL 0x11 diff --git a/profiles/input/hidp_defs.h b/profiles/input/hidp_defs.h index bb9231dbb..0d1febdff 100644 --- a/profiles/input/hidp_defs.h +++ b/profiles/input/hidp_defs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2014 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __HIDP_DEFS_H diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c index e96c969b7..78018aad3 100644 --- a/profiles/input/hog-lib.c +++ b/profiles/input/hog-lib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/hog-lib.h b/profiles/input/hog-lib.h index 415dc63d2..a79648976 100644 --- a/profiles/input/hog-lib.h +++ b/profiles/input/hog-lib.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct bt_hog; diff --git a/profiles/input/hog.c b/profiles/input/hog.c index 130f696a9..91de4c70f 100644 --- a/profiles/input/hog.c +++ b/profiles/input/hog.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/manager.c b/profiles/input/manager.c index bf4acb4ed..92789a003 100644 --- a/profiles/input/manager.c +++ b/profiles/input/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/server.c b/profiles/input/server.c index 2bd5e92e4..d8b413744 100644 --- a/profiles/input/server.c +++ b/profiles/input/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/server.h b/profiles/input/server.h index 74159bbd7..50f4b6135 100644 --- a/profiles/input/server.h +++ b/profiles/input/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int server_start(const bdaddr_t *src); diff --git a/profiles/input/sixaxis.h b/profiles/input/sixaxis.h index 8e6f3cc18..a3cda70e4 100644 --- a/profiles/input/sixaxis.h +++ b/profiles/input/sixaxis.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2013 Szymon Janc <szymon.janc@gmail.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef _SIXAXIS_H_ diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-dummy.c index 542ae2592..c6527ee88 100644 --- a/profiles/input/suspend-dummy.c +++ b/profiles/input/suspend-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/suspend-none.c b/profiles/input/suspend-none.c index c619bb11e..9da0111c8 100644 --- a/profiles/input/suspend-none.c +++ b/profiles/input/suspend-none.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/input/suspend.h b/profiles/input/suspend.h index bfee3cfef..1de1aeacd 100644 --- a/profiles/input/suspend.h +++ b/profiles/input/suspend.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef void (*suspend_event) (void); diff --git a/profiles/midi/libmidi.c b/profiles/midi/libmidi.c index cb2787db1..5b77cd3f5 100644 --- a/profiles/midi/libmidi.c +++ b/profiles/midi/libmidi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,21 +6,6 @@ * Copyright (C) 2015,2016 Felipe F. Tonello <eu@felipetonello.com> * Copyright (C) 2016 ROLI Ltd. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * */ #include <glib.h> diff --git a/profiles/midi/libmidi.h b/profiles/midi/libmidi.h index 9d94065b6..41f522dd4 100644 --- a/profiles/midi/libmidi.h +++ b/profiles/midi/libmidi.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,21 +6,6 @@ * Copyright (C) 2015,2016 Felipe F. Tonello <eu@felipetonello.com> * Copyright (C) 2016 ROLI Ltd. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * */ #ifndef LIBMIDI_H diff --git a/profiles/midi/midi.c b/profiles/midi/midi.c index 1ee5cb16f..737d1b5f6 100644 --- a/profiles/midi/midi.c +++ b/profiles/midi/midi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,25 +6,6 @@ * Copyright (C) 2015,2016 Felipe F. Tonello <eu@felipetonello.com> * Copyright (C) 2016 ROLI Ltd. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Information about this plugin: - * - * This plugin implements the MIDI over Bluetooth Low-Energy (BLE-MIDI) 1.0 - * specification as published by MMA in November/2015. - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c index d0ad9e483..4dde55786 100644 --- a/profiles/network/bnep.c +++ b/profiles/network/bnep.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/network/bnep.h b/profiles/network/bnep.h index e9f4c1cf2..493a2b036 100644 --- a/profiles/network/bnep.h +++ b/profiles/network/bnep.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct bnep; diff --git a/profiles/network/connection.c b/profiles/network/connection.c index 170841de6..74d9d8944 100644 --- a/profiles/network/connection.c +++ b/profiles/network/connection.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/network/connection.h b/profiles/network/connection.h index 4a8b43bc8..aa7e36e37 100644 --- a/profiles/network/connection.h +++ b/profiles/network/connection.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int connection_register(struct btd_service *service); diff --git a/profiles/network/manager.c b/profiles/network/manager.c index 41377fb83..a2650d6f0 100644 --- a/profiles/network/manager.c +++ b/profiles/network/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/network/server.c b/profiles/network/server.c index c462677ed..96738f26c 100644 --- a/profiles/network/server.c +++ b/profiles/network/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/network/server.h b/profiles/network/server.h index a76e6f7b2..32369219d 100644 --- a/profiles/network/server.h +++ b/profiles/network/server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int server_init(gboolean secure); diff --git a/profiles/sap/main.c b/profiles/sap/main.c index cd707ff3e..321ed3282 100644 --- a/profiles/sap/main.c +++ b/profiles/sap/main.c @@ -1,21 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 Instituto Nokia de Tecnologia - INdT * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H diff --git a/profiles/sap/manager.c b/profiles/sap/manager.c index b62239780..6670f397c 100644 --- a/profiles/sap/manager.c +++ b/profiles/sap/manager.c @@ -1,21 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 Instituto Nokia de Tecnologia - INdT * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H diff --git a/profiles/sap/manager.h b/profiles/sap/manager.h index 6601a034e..2a1f5a6d1 100644 --- a/profiles/sap/manager.h +++ b/profiles/sap/manager.h @@ -1,21 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 Instituto Nokia de Tecnologia - INdT * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ int sap_manager_init(void); diff --git a/profiles/sap/sap-dummy.c b/profiles/sap/sap-dummy.c index 53463ca7c..92adea384 100644 --- a/profiles/sap/sap-dummy.c +++ b/profiles/sap/sap-dummy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * @@ -7,19 +8,6 @@ * Author: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> * for ST-Ericsson * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H diff --git a/profiles/sap/sap.h b/profiles/sap/sap.h index 6e78d6c2d..30ed7c50c 100644 --- a/profiles/sap/sap.h +++ b/profiles/sap/sap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * BlueZ - Bluetooth protocol stack for Linux * @@ -8,19 +9,6 @@ * Author: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> * for ST-Ericsson. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdint.h> diff --git a/profiles/sap/server.c b/profiles/sap/server.c index 5de682a33..b0a454ced 100644 --- a/profiles/sap/server.c +++ b/profiles/sap/server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * @@ -9,19 +10,6 @@ * Author: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> * for ST-Ericsson. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H diff --git a/profiles/sap/server.h b/profiles/sap/server.h index 4bf9296ad..b774230f5 100644 --- a/profiles/sap/server.h +++ b/profiles/sap/server.h @@ -1,21 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2010 ST-Ericsson SA * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ int sap_server_register(struct btd_adapter *adapter); diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c index d72be3dff..004783bf7 100644 --- a/profiles/scanparam/scan.c +++ b/profiles/scanparam/scan.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/scanparam/scpp.c b/profiles/scanparam/scpp.c index df65d2c1e..da38a6aaa 100644 --- a/profiles/scanparam/scpp.c +++ b/profiles/scanparam/scpp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/profiles/scanparam/scpp.h b/profiles/scanparam/scpp.h index 048fb9f23..c3cc5f156 100644 --- a/profiles/scanparam/scpp.h +++ b/profiles/scanparam/scpp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can rescpptribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is scpptributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct bt_scpp; -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id uExLCjr6aF8DLwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:08:42 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id cMPjBjr6aF+VsAEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:08:42 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 736ACA0B9B; Mon, 21 Sep 2020 21:08:34 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726969AbgIUTId (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:08:33 -0400 Received: from mga09.intel.com ([134.134.136.24]:2547 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726611AbgIUTId (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:08:33 -0400 IronPort-SDR: 7ZOmUElF0M68uc2Evat/XJOn4xNAnfTMwo+ma2ho0nJnE2Okrh1KASCyeqRjzMkyj5j4V3fsw9 F6hu5m/dM2DA== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="161384395" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="161384395" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:08:17 -0700 IronPort-SDR: exmjsAPUf8spFGO8w8vQUmLonLT6sPg4rrdXFjN7RCxzYoqsFxQoFCwPyO0I3+5iC/ukEjq4PH myQJtbHWiFtA== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485627104" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:08:17 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 15/20] unit: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:35 -0700 Message-Id: <20200921190040.45309-16-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: 736ACA0B9B X-Rspamd-UID: d72d55 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 25 LGPL-2.1-or-later : 1 GPL-2.0-only : 2 BSD-2-Clause : 1 License: GPL-2.0-or-later unit/test-hog.c unit/test-eir.c unit/test-gobex-header.c unit/test-crc.c unit/test-avrcp.c unit/test-ringbuf.c unit/test-gobex-apparam.c unit/test-gobex.c unit/test-hfp.c unit/test-textfile.c unit/test-avdtp.c unit/test-sdp.c unit/test-gatt.c unit/test-avctp.c unit/test-gattrib.c unit/test-queue.c unit/test-gobex-packet.c unit/test-uuid.c unit/test-crypto.c unit/test-uhid.c unit/test-gdbus-client.c unit/test-midi.c unit/test-lib.c unit/test-mgmt.c unit/test-gobex-transfer.c License: LGPL-2.1-or-later unit/test-mesh-crypto.c License: GPL-2.0-only unit/util.h unit/util.c License: BSD-2-Clause unit/test-ecc.c --- unit/test-avctp.c | 15 +-------------- unit/test-avdtp.c | 15 +-------------- unit/test-avrcp.c | 15 +-------------- unit/test-crc.c | 15 +-------------- unit/test-crypto.c | 15 +-------------- unit/test-ecc.c | 21 +-------------------- unit/test-eir.c | 15 +-------------- unit/test-gatt.c | 15 +-------------- unit/test-gattrib.c | 15 +-------------- unit/test-gdbus-client.c | 15 +-------------- unit/test-gobex-apparam.c | 15 +-------------- unit/test-gobex-header.c | 15 +-------------- unit/test-gobex-packet.c | 15 +-------------- unit/test-gobex-transfer.c | 15 +-------------- unit/test-gobex.c | 15 +-------------- unit/test-hfp.c | 15 +-------------- unit/test-hog.c | 15 +-------------- unit/test-lib.c | 15 +-------------- unit/test-mesh-crypto.c | 11 +---------- unit/test-mgmt.c | 15 +-------------- unit/test-midi.c | 16 +--------------- unit/test-queue.c | 15 +-------------- unit/test-ringbuf.c | 15 +-------------- unit/test-sdp.c | 15 +-------------- unit/test-textfile.c | 15 +-------------- unit/test-uhid.c | 15 +-------------- unit/test-uuid.c | 15 +-------------- unit/util.c | 14 +------------- unit/util.h | 14 +------------- 29 files changed, 29 insertions(+), 407 deletions(-) diff --git a/unit/test-avctp.c b/unit/test-avctp.c index c92618bab..fa7db59c8 100644 --- a/unit/test-avctp.c +++ b/unit/test-avctp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c index 13c03d037..f5340d6f3 100644 --- a/unit/test-avdtp.c +++ b/unit/test-avdtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c index adf25f002..34a70377d 100644 --- a/unit/test-avrcp.c +++ b/unit/test-avrcp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-crc.c b/unit/test-crc.c index 791fa5137..107c95e13 100644 --- a/unit/test-crc.c +++ b/unit/test-crc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-crypto.c b/unit/test-crypto.c index 46c7c0e5c..3a88b4a52 100644 --- a/unit/test-crypto.c +++ b/unit/test-crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-ecc.c b/unit/test-ecc.c index d9136814d..b838cc29b 100644 --- a/unit/test-ecc.c +++ b/unit/test-ecc.c @@ -1,27 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause /* * Copyright (c) 2013, Kenneth MacKay * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-eir.c b/unit/test-eir.c index 421d0db13..e05a37d01 100644 --- a/unit/test-eir.c +++ b/unit/test-eir.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gatt.c b/unit/test-gatt.c index 0b77df51c..6a49210c5 100644 --- a/unit/test-gatt.c +++ b/unit/test-gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gattrib.c b/unit/test-gattrib.c index 416e59635..9c7dea094 100644 --- a/unit/test-gattrib.c +++ b/unit/test-gattrib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Google, Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c index ccf706713..514c58b8e 100644 --- a/unit/test-gdbus-client.c +++ b/unit/test-gdbus-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gobex-apparam.c b/unit/test-gobex-apparam.c index 59393c681..330a7819a 100644 --- a/unit/test-gobex-apparam.c +++ b/unit/test-gobex-apparam.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2012 Intel Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gobex-header.c b/unit/test-gobex-header.c index 3450f8123..941e18d47 100644 --- a/unit/test-gobex-header.c +++ b/unit/test-gobex-header.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gobex-packet.c b/unit/test-gobex-packet.c index d382ee5b3..2664bef4e 100644 --- a/unit/test-gobex-packet.c +++ b/unit/test-gobex-packet.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c index 3f8905c0b..4f652dea8 100644 --- a/unit/test-gobex-transfer.c +++ b/unit/test-gobex-transfer.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-gobex.c b/unit/test-gobex.c index 1afb7ceff..6fbfa183e 100644 --- a/unit/test-gobex.c +++ b/unit/test-gobex.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-hfp.c b/unit/test-hfp.c index 890eee659..f504724d7 100644 --- a/unit/test-hfp.c +++ b/unit/test-hfp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <sys/socket.h> diff --git a/unit/test-hog.c b/unit/test-hog.c index e257fbd88..e6d4affc4 100644 --- a/unit/test-hog.c +++ b/unit/test-hog.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-lib.c b/unit/test-lib.c index 1dd5d92cf..8395c2a73 100644 --- a/unit/test-lib.c +++ b/unit/test-lib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2013 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-mesh-crypto.c b/unit/test-mesh-crypto.c index ed37ae1a7..12709dace 100644 --- a/unit/test-mesh-crypto.c +++ b/unit/test-mesh-crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-mgmt.c b/unit/test-mgmt.c index c67678b9a..1b71e562f 100644 --- a/unit/test-mgmt.c +++ b/unit/test-mgmt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-midi.c b/unit/test-midi.c index 593bc5a5c..644fcdc6d 100644 --- a/unit/test-midi.c +++ b/unit/test-midi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,21 +6,6 @@ * Copyright (C) 2015,2016 Felipe F. Tonello <eu@felipetonello.com> * Copyright (C) 2016 ROLI Ltd. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-queue.c b/unit/test-queue.c index d912a6416..46018ef9c 100644 --- a/unit/test-queue.c +++ b/unit/test-queue.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-ringbuf.c b/unit/test-ringbuf.c index ef3bf0a50..b1cf51115 100644 --- a/unit/test-ringbuf.c +++ b/unit/test-ringbuf.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-sdp.c b/unit/test-sdp.c index 03501d021..d3a885f19 100644 --- a/unit/test-sdp.c +++ b/unit/test-sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-textfile.c b/unit/test-textfile.c index 4b43898d6..a1485a543 100644 --- a/unit/test-textfile.c +++ b/unit/test-textfile.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-uhid.c b/unit/test-uhid.c index 320cd54d4..001d39a3d 100644 --- a/unit/test-uhid.c +++ b/unit/test-uhid.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/test-uuid.c b/unit/test-uuid.c index 7c6789e39..0889630cf 100644 --- a/unit/test-uuid.c +++ b/unit/test-uuid.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/util.c b/unit/util.c index c8054d2e4..e7804d884 100644 --- a/unit/util.c +++ b/unit/util.c @@ -1,22 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/unit/util.h b/unit/util.h index b13fd2f16..d5d0f19c5 100644 --- a/unit/util.h +++ b/unit/util.h @@ -1,22 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define TEST_BUF_MAX 5 -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id iOgaFdv6aF+TFQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:11:23 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id oMVGEtv6aF9avQEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:11:23 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3A9CB4096A; Mon, 21 Sep 2020 21:11:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbgIUTLL convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:11:11 -0400 Received: from mga09.intel.com ([134.134.136.24]:2647 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726886AbgIUTLK (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:11:10 -0400 IronPort-SDR: LGMXiXec79dis16kGgYHt0FDPB2TyN7O7ufw96S4evnDm0rHUA3AjJCse1EA1lXI35LhwIbn0b 1jOIgeGBV0Hg== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="161384514" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="161384514" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:09:50 -0700 IronPort-SDR: wJoTILYR2coJ+ZgM0aJdCur1/ZGJAtaogbNacdQmOcJVe4DKXBh2nFQpfqpL4ad9M3+TBXzxtm rjdJI62dHBTw== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485627646" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:09:49 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 17/20] tools: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:37 -0700 Message-Id: <20200921190040.45309-18-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.34 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3A9CB4096A X-Rspamd-UID: cd0ccd From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 103 MIT : 2 LGPL-2.1-or-later : 40 GPL-2.0-only : 2 License: GPL-2.0-or-later tools/csr_usb.c tools/l2cap-tester.c tools/hcisecfilter.c tools/ciptool.c tools/csr_bcsp.c tools/btsnoop.c tools/check-selftest.c tools/bccmd.c tools/btpclientctl.c tools/hci-tester.c tools/hcitool.c tools/btiotest.c tools/oobtest.c tools/btinfo.c tools/hwdb.c tools/hciattach_bcm43xx.c tools/mgmt-tester.c tools/hex2hcd.c tools/hciattach_st.c tools/smp-tester.c tools/bluetooth-player.c tools/hciattach_tialt.c tools/gap-tester.c tools/bluemoon.c tools/bneptest.c tools/gatt-service.c tools/csr_3wire.c tools/rctest.c tools/rfcomm-tester.c tools/hcieventmask.c tools/hciattach_ti.c tools/seq2bseq.c tools/scotest.c tools/bcmfw.c tools/hciconfig.c tools/btattach.c tools/l2ping.c tools/obexctl.c tools/l2test.c tools/hciattach_intel.c tools/csr.h tools/hciattach.h tools/create-image.c tools/bnep-tester.c tools/userchan-tester.c tools/rfcomm.c tools/btmon-logger.c tools/hcidump.c tools/csr_hci.c tools/rtlfw.c tools/hciattach_qualcomm.c tools/btproxy.c tools/nokfw.c tools/hciattach_ath3k.c tools/3dsp.c tools/bdaddr.c tools/sco-tester.c tools/hciattach.c tools/amptest.c tools/btgatt-server.c tools/btgatt-client.c tools/cltest.c tools/ibeacon.c tools/mcaptest.c tools/hid2hci.c tools/btmgmt.c tools/advtest.c tools/eddystone.c tools/csr_h4.c tools/avtest.c tools/mpris-proxy.c tools/csr.c tools/avinfo.c tools/sdptool.c tools/btconfig.c tools/parser/parser.h tools/parser/obex.c tools/parser/amp.c tools/parser/sdp.c tools/parser/tcpip.c tools/parser/sap.c tools/parser/cmtp.c tools/parser/avctp.c tools/parser/lmp.c tools/parser/ppp.c tools/parser/rfcomm.h tools/parser/hci.c tools/parser/sdp.h tools/parser/parser.c tools/parser/rfcomm.c tools/parser/avdtp.c tools/parser/avrcp.c tools/parser/ericsson.c tools/parser/hcrp.c tools/parser/bpa.c tools/parser/hidp.c tools/parser/bnep.c tools/parser/capi.c tools/parser/att.c tools/parser/l2cap.c tools/parser/smp.c tools/parser/csr.c tools/parser/l2cap.h License: MIT tools/ubcsp.c tools/ubcsp.h License: LGPL-2.1-or-later tools/test-runner.c tools/btpclient.c tools/meshctl.c tools/mesh-cfgclient.c tools/parse_companies.pl tools/update_compids.sh tools/mesh/model.h tools/mesh/util.h tools/mesh/config-model.h tools/mesh/cfgcli.h tools/mesh/mesh-db.c tools/mesh/mesh-db.h tools/mesh/keys.c tools/mesh/util.c tools/mesh/agent.h tools/mesh/remote.c tools/mesh/keys.h tools/mesh/agent.c tools/mesh/cfgcli.c tools/mesh/remote.h tools/mesh-gatt/prov.c tools/mesh-gatt/util.h tools/mesh-gatt/prov.h tools/mesh-gatt/net.c tools/mesh-gatt/util.c tools/mesh-gatt/prov-db.h tools/mesh-gatt/crypto.c tools/mesh-gatt/crypto.h tools/mesh-gatt/gatt.c tools/mesh-gatt/config-server.c tools/mesh-gatt/keys.h tools/mesh-gatt/onoff-model.c tools/mesh-gatt/net.h tools/mesh-gatt/gatt.h tools/mesh-gatt/node.c tools/mesh-gatt/config-client.c tools/mesh-gatt/mesh-net.h tools/mesh-gatt/node.h tools/mesh-gatt/onoff-model.h tools/mesh-gatt/prov-db.c License: GPL-2.0-only tools/obex-server-tool.c tools/obex-client-tool.c --- tools/3dsp.c | 15 +-------------- tools/advtest.c | 15 +-------------- tools/amptest.c | 15 +-------------- tools/avinfo.c | 15 +-------------- tools/avtest.c | 15 +-------------- tools/bccmd.c | 15 +-------------- tools/bcmfw.c | 15 +-------------- tools/bdaddr.c | 15 +-------------- tools/bluemoon.c | 15 +-------------- tools/bluetooth-player.c | 15 +-------------- tools/bnep-tester.c | 15 +-------------- tools/bneptest.c | 15 +-------------- tools/btattach.c | 15 +-------------- tools/btconfig.c | 15 +-------------- tools/btgatt-client.c | 15 +-------------- tools/btgatt-server.c | 11 +---------- tools/btinfo.c | 15 +-------------- tools/btiotest.c | 15 +-------------- tools/btmgmt.c | 15 +-------------- tools/btmon-logger.c | 15 +-------------- tools/btpclient.c | 15 +-------------- tools/btpclientctl.c | 15 +-------------- tools/btproxy.c | 15 +-------------- tools/btsnoop.c | 15 +-------------- tools/check-selftest.c | 15 +-------------- tools/ciptool.c | 15 +-------------- tools/cltest.c | 15 +-------------- tools/create-image.c | 15 +-------------- tools/csr.c | 15 +-------------- tools/csr.h | 15 +-------------- tools/csr_3wire.c | 15 +-------------- tools/csr_bcsp.c | 15 +-------------- tools/csr_h4.c | 15 +-------------- tools/csr_hci.c | 15 +-------------- tools/csr_usb.c | 15 +-------------- tools/eddystone.c | 15 +-------------- tools/gap-tester.c | 15 +-------------- tools/gatt-service.c | 15 +-------------- tools/hci-tester.c | 15 +-------------- tools/hciattach.c | 15 +-------------- tools/hciattach.h | 15 +-------------- tools/hciattach_ath3k.c | 15 +-------------- tools/hciattach_bcm43xx.c | 15 +-------------- tools/hciattach_intel.c | 15 +-------------- tools/hciattach_qualcomm.c | 15 +-------------- tools/hciattach_st.c | 15 +-------------- tools/hciattach_ti.c | 15 +-------------- tools/hciattach_tialt.c | 15 +-------------- tools/hciconfig.c | 15 +-------------- tools/hcidump.c | 15 +-------------- tools/hcieventmask.c | 15 +-------------- tools/hcisecfilter.c | 15 +-------------- tools/hcitool.c | 15 +-------------- tools/hex2hcd.c | 15 +-------------- tools/hid2hci.c | 15 +-------------- tools/hwdb.c | 15 +-------------- tools/ibeacon.c | 15 +-------------- tools/l2cap-tester.c | 15 +-------------- tools/l2ping.c | 15 +-------------- tools/l2test.c | 15 +-------------- tools/mcaptest.c | 15 +-------------- tools/mesh-cfgclient.c | 11 +---------- tools/mesh-gatt/config-client.c | 15 +-------------- tools/mesh-gatt/config-server.c | 15 +-------------- tools/mesh-gatt/crypto.c | 15 +-------------- tools/mesh-gatt/crypto.h | 15 +-------------- tools/mesh-gatt/gatt.c | 15 +-------------- tools/mesh-gatt/gatt.h | 15 +-------------- tools/mesh-gatt/keys.h | 15 +-------------- tools/mesh-gatt/mesh-net.h | 15 +-------------- tools/mesh-gatt/net.c | 15 +-------------- tools/mesh-gatt/net.h | 15 +-------------- tools/mesh-gatt/node.c | 15 +-------------- tools/mesh-gatt/node.h | 15 +-------------- tools/mesh-gatt/onoff-model.c | 15 +-------------- tools/mesh-gatt/onoff-model.h | 15 +-------------- tools/mesh-gatt/prov-db.c | 15 +-------------- tools/mesh-gatt/prov-db.h | 15 +-------------- tools/mesh-gatt/prov.c | 15 +-------------- tools/mesh-gatt/prov.h | 15 +-------------- tools/mesh-gatt/util.c | 15 +-------------- tools/mesh-gatt/util.h | 15 +-------------- tools/mesh/agent.c | 15 +-------------- tools/mesh/agent.h | 15 +-------------- tools/mesh/cfgcli.c | 12 +----------- tools/mesh/cfgcli.h | 12 +----------- tools/mesh/config-model.h | 15 +-------------- tools/mesh/keys.c | 12 +----------- tools/mesh/keys.h | 12 +----------- tools/mesh/mesh-db.c | 11 +---------- tools/mesh/mesh-db.h | 11 +---------- tools/mesh/model.h | 12 +----------- tools/mesh/remote.c | 11 +---------- tools/mesh/remote.h | 11 +---------- tools/mesh/util.c | 11 +---------- tools/mesh/util.h | 11 +---------- tools/meshctl.c | 15 +-------------- tools/mgmt-tester.c | 15 +-------------- tools/mpris-proxy.c | 15 +-------------- tools/nokfw.c | 15 +-------------- tools/obex-client-tool.c | 14 +------------- tools/obex-server-tool.c | 14 +------------- tools/obexctl.c | 15 +-------------- tools/oobtest.c | 15 +-------------- tools/parse_companies.pl | 2 +- tools/parser/amp.c | 15 +-------------- tools/parser/att.c | 15 +-------------- tools/parser/avctp.c | 15 +-------------- tools/parser/avdtp.c | 15 +-------------- tools/parser/avrcp.c | 15 +-------------- tools/parser/bnep.c | 15 +-------------- tools/parser/bpa.c | 15 +-------------- tools/parser/capi.c | 15 +-------------- tools/parser/cmtp.c | 15 +-------------- tools/parser/csr.c | 15 +-------------- tools/parser/ericsson.c | 15 +-------------- tools/parser/hci.c | 15 +-------------- tools/parser/hcrp.c | 15 +-------------- tools/parser/hidp.c | 15 +-------------- tools/parser/l2cap.c | 15 +-------------- tools/parser/l2cap.h | 15 +-------------- tools/parser/lmp.c | 15 +-------------- tools/parser/obex.c | 15 +-------------- tools/parser/parser.c | 15 +-------------- tools/parser/parser.h | 15 +-------------- tools/parser/ppp.c | 15 +-------------- tools/parser/rfcomm.c | 15 +-------------- tools/parser/rfcomm.h | 15 +-------------- tools/parser/sap.c | 15 +-------------- tools/parser/sdp.c | 15 +-------------- tools/parser/sdp.h | 15 +-------------- tools/parser/smp.c | 15 +-------------- tools/parser/tcpip.c | 15 +-------------- tools/rctest.c | 15 +-------------- tools/rfcomm-tester.c | 15 +-------------- tools/rfcomm.c | 15 +-------------- tools/rtlfw.c | 15 +-------------- tools/sco-tester.c | 15 +-------------- tools/scotest.c | 15 +-------------- tools/sdptool.c | 15 +-------------- tools/seq2bseq.c | 15 +-------------- tools/smp-tester.c | 15 +-------------- tools/test-runner.c | 15 +-------------- tools/ubcsp.c | 20 +------------------- tools/ubcsp.h | 20 +------------------- tools/update_compids.sh | 1 + tools/userchan-tester.c | 15 +-------------- 147 files changed, 147 insertions(+), 1992 deletions(-) diff --git a/tools/3dsp.c b/tools/3dsp.c index 77a70c037..99c1ac82b 100644 --- a/tools/3dsp.c +++ b/tools/3dsp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/advtest.c b/tools/advtest.c index 050b570df..de036e783 100644 --- a/tools/advtest.c +++ b/tools/advtest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/amptest.c b/tools/amptest.c index 557470781..193cadd25 100644 --- a/tools/amptest.c +++ b/tools/amptest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/avinfo.c b/tools/avinfo.c index e45b50918..2f68f53e7 100644 --- a/tools/avinfo.c +++ b/tools/avinfo.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2018 Pali Rohár <pali.rohar@gmail.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/avtest.c b/tools/avtest.c index 59fb1da8a..ca37b3b46 100644 --- a/tools/avtest.c +++ b/tools/avtest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2009-2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/bccmd.c b/tools/bccmd.c index 2c215ace7..be6a5dffc 100644 --- a/tools/bccmd.c +++ b/tools/bccmd.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/bcmfw.c b/tools/bcmfw.c index 80d8e71a2..f9d2ef363 100644 --- a/tools/bcmfw.c +++ b/tools/bcmfw.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2013 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/bdaddr.c b/tools/bdaddr.c index 952e99077..bc0478d46 100644 --- a/tools/bdaddr.c +++ b/tools/bdaddr.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/bluemoon.c b/tools/bluemoon.c index 800541110..8b62b1e7b 100644 --- a/tools/bluemoon.c +++ b/tools/bluemoon.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c index c1005c9b7..bdfd9aa46 100644 --- a/tools/bluetooth-player.c +++ b/tools/bluetooth-player.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/bnep-tester.c b/tools/bnep-tester.c index ec4ad2668..dfeb0ed0b 100644 --- a/tools/bnep-tester.c +++ b/tools/bnep-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/bneptest.c b/tools/bneptest.c index 8bc7596b6..76ec1cfcd 100644 --- a/tools/bneptest.c +++ b/tools/bneptest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btattach.c b/tools/btattach.c index 56315d050..4ce1be78d 100644 --- a/tools/btattach.c +++ b/tools/btattach.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btconfig.c b/tools/btconfig.c index c1ef5834a..f75899777 100644 --- a/tools/btconfig.c +++ b/tools/btconfig.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c index bc762dba1..523d6ec30 100644 --- a/tools/btgatt-client.c +++ b/tools/btgatt-client.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2014 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btgatt-server.c b/tools/btgatt-server.c index 5b7857b00..aa3448765 100644 --- a/tools/btgatt-server.c +++ b/tools/btgatt-server.c @@ -1,19 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2014 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btinfo.c b/tools/btinfo.c index 5e609739c..5f3650c78 100644 --- a/tools/btinfo.c +++ b/tools/btinfo.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btiotest.c b/tools/btiotest.c index 6c778e3c5..cb8cc3534 100644 --- a/tools/btiotest.c +++ b/tools/btiotest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2009-2010 Nokia Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 48c9e5887..b0b837d34 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btmon-logger.c b/tools/btmon-logger.c index 9c23d3c5e..a770ad575 100644 --- a/tools/btmon-logger.c +++ b/tools/btmon-logger.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btpclient.c b/tools/btpclient.c index 38e326670..bdfff5df8 100644 --- a/tools/btpclient.c +++ b/tools/btpclient.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2011-2017 Intel Corporation. All rights reserved. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btpclientctl.c b/tools/btpclientctl.c index 519d81c0d..6553f2f3a 100644 --- a/tools/btpclientctl.c +++ b/tools/btpclientctl.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btproxy.c b/tools/btproxy.c index a98bbb73f..f6143038c 100644 --- a/tools/btproxy.c +++ b/tools/btproxy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/btsnoop.c b/tools/btsnoop.c index 9f304377c..41baf6e3d 100644 --- a/tools/btsnoop.c +++ b/tools/btsnoop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/check-selftest.c b/tools/check-selftest.c index 0de6362da..9a6f22d57 100644 --- a/tools/check-selftest.c +++ b/tools/check-selftest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/ciptool.c b/tools/ciptool.c index b898ae8b7..0d6272da9 100644 --- a/tools/ciptool.c +++ b/tools/ciptool.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/cltest.c b/tools/cltest.c index 44a17a892..2766fcd23 100644 --- a/tools/cltest.c +++ b/tools/cltest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/create-image.c b/tools/create-image.c index ca9d0112c..3f2cf03d8 100644 --- a/tools/create-image.c +++ b/tools/create-image.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/csr.c b/tools/csr.c index 61bdaa0cf..891f8ee00 100644 --- a/tools/csr.c +++ b/tools/csr.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/csr.h b/tools/csr.h index cc245a550..0c4d4a1c5 100644 --- a/tools/csr.h +++ b/tools/csr.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/tools/csr_3wire.c b/tools/csr_3wire.c index 33fcf389a..fe349e152 100644 --- a/tools/csr_3wire.c +++ b/tools/csr_3wire.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/csr_bcsp.c b/tools/csr_bcsp.c index e3eea34df..453b2d82b 100644 --- a/tools/csr_bcsp.c +++ b/tools/csr_bcsp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/csr_h4.c b/tools/csr_h4.c index 2dcaec1e5..321dfdb41 100644 --- a/tools/csr_h4.c +++ b/tools/csr_h4.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/csr_hci.c b/tools/csr_hci.c index d2e4ab9c6..4e6623261 100644 --- a/tools/csr_hci.c +++ b/tools/csr_hci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/csr_usb.c b/tools/csr_usb.c index 32fdf1f14..cd65952e1 100644 --- a/tools/csr_usb.c +++ b/tools/csr_usb.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/eddystone.c b/tools/eddystone.c index 4764c677c..4a593e823 100644 --- a/tools/eddystone.c +++ b/tools/eddystone.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/gap-tester.c b/tools/gap-tester.c index 2aa404267..942c37d27 100644 --- a/tools/gap-tester.c +++ b/tools/gap-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/gatt-service.c b/tools/gatt-service.c index 374a4c9df..631c4f249 100644 --- a/tools/gatt-service.c +++ b/tools/gatt-service.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Instituto Nokia de Tecnologia - INdT * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hci-tester.c b/tools/hci-tester.c index 7873e7aea..0fb74e69c 100644 --- a/tools/hci-tester.c +++ b/tools/hci-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hciattach.c b/tools/hciattach.c index 9a02173bf..276a4e56e 100644 --- a/tools/hciattach.c +++ b/tools/hciattach.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hciattach.h b/tools/hciattach.h index 249aab49e..26c0d5424 100644 --- a/tools/hciattach.h +++ b/tools/hciattach.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <termios.h> diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c index eb2a2aeb6..d119155bb 100644 --- a/tools/hciattach_ath3k.c +++ b/tools/hciattach_ath3k.c @@ -1,20 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2009-2010 Atheros Communications Inc. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hciattach_bcm43xx.c b/tools/hciattach_bcm43xx.c index be82cd011..dbb5a3fe3 100644 --- a/tools/hciattach_bcm43xx.c +++ b/tools/hciattach_bcm43xx.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hciattach_intel.c b/tools/hciattach_intel.c index 0f0b60f2b..e243b3d07 100644 --- a/tools/hciattach_intel.c +++ b/tools/hciattach_intel.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hciattach_qualcomm.c b/tools/hciattach_qualcomm.c index 29d15a5fe..77b6db170 100644 --- a/tools/hciattach_qualcomm.c +++ b/tools/hciattach_qualcomm.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (c) 2010, Code Aurora Forum. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hciattach_st.c b/tools/hciattach_st.c index b34964cb7..4a7186aa6 100644 --- a/tools/hciattach_st.c +++ b/tools/hciattach_st.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2005-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hciattach_ti.c b/tools/hciattach_ti.c index 183839443..24efceaa1 100644 --- a/tools/hciattach_ti.c +++ b/tools/hciattach_ti.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2005-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hciattach_tialt.c b/tools/hciattach_tialt.c index 78498edcf..520b383a1 100644 --- a/tools/hciattach_tialt.c +++ b/tools/hciattach_tialt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2005-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hciconfig.c b/tools/hciconfig.c index ddc17c4b5..63444aa62 100644 --- a/tools/hciconfig.c +++ b/tools/hciconfig.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hcidump.c b/tools/hcidump.c index 33d429b6c..2b08056ea 100644 --- a/tools/hcidump.c +++ b/tools/hcidump.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hcieventmask.c b/tools/hcieventmask.c index b5f818d30..0e7fe5fd7 100644 --- a/tools/hcieventmask.c +++ b/tools/hcieventmask.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hcisecfilter.c b/tools/hcisecfilter.c index 18c903334..46cdbf381 100644 --- a/tools/hcisecfilter.c +++ b/tools/hcisecfilter.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hcitool.c b/tools/hcitool.c index 9250c41f2..c6a909373 100644 --- a/tools/hcitool.c +++ b/tools/hcitool.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hex2hcd.c b/tools/hex2hcd.c index 1148bbb46..674d62744 100644 --- a/tools/hex2hcd.c +++ b/tools/hex2hcd.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2013 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hid2hci.c b/tools/hid2hci.c index 1e0f7aa2a..80aee9ed6 100644 --- a/tools/hid2hci.c +++ b/tools/hid2hci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * hid2hci : switch the radio on devices that support * it from HID to HCI and back @@ -6,20 +7,6 @@ * Copyright (C) 2008-2009 Mario Limonciello <mario_limonciello@dell.com> * Copyright (C) 2009-2011 Kay Sievers <kay.sievers@vrfy.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/hwdb.c b/tools/hwdb.c index 8a42dce39..4b37c753d 100644 --- a/tools/hwdb.c +++ b/tools/hwdb.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/ibeacon.c b/tools/ibeacon.c index 40078d5ed..8dd1f4616 100644 --- a/tools/ibeacon.c +++ b/tools/ibeacon.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c index 1ef4e9213..42d2b5615 100644 --- a/tools/l2cap-tester.c +++ b/tools/l2cap-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/l2ping.c b/tools/l2ping.c index db120a550..c44ce872f 100644 --- a/tools/l2ping.c +++ b/tools/l2ping.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/l2test.c b/tools/l2test.c index 0d846ed93..6e07f7b84 100644 --- a/tools/l2test.c +++ b/tools/l2test.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mcaptest.c b/tools/mcaptest.c index 82663d8de..dcef0b908 100644 --- a/tools/mcaptest.c +++ b/tools/mcaptest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 3987e3179..28465a679 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh-gatt/config-client.c b/tools/mesh-gatt/config-client.c index bfc788258..3ec42d94a 100644 --- a/tools/mesh-gatt/config-client.c +++ b/tools/mesh-gatt/config-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh-gatt/config-server.c b/tools/mesh-gatt/config-server.c index 9e9b93959..a53f4c200 100644 --- a/tools/mesh-gatt/config-server.c +++ b/tools/mesh-gatt/config-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh-gatt/crypto.c b/tools/mesh-gatt/crypto.c index 493b502ca..c65974bb0 100644 --- a/tools/mesh-gatt/crypto.c +++ b/tools/mesh-gatt/crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh-gatt/crypto.h b/tools/mesh-gatt/crypto.h index e8f16f35d..f1cb7af26 100644 --- a/tools/mesh-gatt/crypto.h +++ b/tools/mesh-gatt/crypto.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/tools/mesh-gatt/gatt.c b/tools/mesh-gatt/gatt.c index 1bd9868df..b99234f91 100644 --- a/tools/mesh-gatt/gatt.c +++ b/tools/mesh-gatt/gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh-gatt/gatt.h b/tools/mesh-gatt/gatt.h index 2878587b1..5af02f408 100644 --- a/tools/mesh-gatt/gatt.h +++ b/tools/mesh-gatt/gatt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include "gdbus/gdbus.h" diff --git a/tools/mesh-gatt/keys.h b/tools/mesh-gatt/keys.h index 477ff1309..8921909e2 100644 --- a/tools/mesh-gatt/keys.h +++ b/tools/mesh-gatt/keys.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define KR_PHASE_NONE 0x00 diff --git a/tools/mesh-gatt/mesh-net.h b/tools/mesh-gatt/mesh-net.h index 76a98224c..29c8de06c 100644 --- a/tools/mesh-gatt/mesh-net.h +++ b/tools/mesh-gatt/mesh-net.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ /* Proxy PDU Types */ diff --git a/tools/mesh-gatt/net.c b/tools/mesh-gatt/net.c index d74e1f5a5..2fdd0d4be 100644 --- a/tools/mesh-gatt/net.c +++ b/tools/mesh-gatt/net.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh-gatt/net.h b/tools/mesh-gatt/net.h index b388d616c..980e4bb3d 100644 --- a/tools/mesh-gatt/net.h +++ b/tools/mesh-gatt/net.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include "gdbus/gdbus.h" diff --git a/tools/mesh-gatt/node.c b/tools/mesh-gatt/node.c index 6afa6d6ab..6afda3387 100644 --- a/tools/mesh-gatt/node.c +++ b/tools/mesh-gatt/node.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh-gatt/node.h b/tools/mesh-gatt/node.h index a5b5c7520..073bd8133 100644 --- a/tools/mesh-gatt/node.h +++ b/tools/mesh-gatt/node.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct mesh_node; diff --git a/tools/mesh-gatt/onoff-model.c b/tools/mesh-gatt/onoff-model.c index be519c969..9dfedd85a 100644 --- a/tools/mesh-gatt/onoff-model.c +++ b/tools/mesh-gatt/onoff-model.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh-gatt/onoff-model.h b/tools/mesh-gatt/onoff-model.h index 31599056d..a5e01ed40 100644 --- a/tools/mesh-gatt/onoff-model.h +++ b/tools/mesh-gatt/onoff-model.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define GENERIC_ONOFF_SERVER_MODEL_ID 0x1000 diff --git a/tools/mesh-gatt/prov-db.c b/tools/mesh-gatt/prov-db.c index 44096e1e1..2fb08f799 100644 --- a/tools/mesh-gatt/prov-db.c +++ b/tools/mesh-gatt/prov-db.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh-gatt/prov-db.h b/tools/mesh-gatt/prov-db.h index b8584a8c3..288211220 100644 --- a/tools/mesh-gatt/prov-db.h +++ b/tools/mesh-gatt/prov-db.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool prov_db_show(const char *filename); diff --git a/tools/mesh-gatt/prov.c b/tools/mesh-gatt/prov.c index 598c94ebf..1f3f62dfd 100644 --- a/tools/mesh-gatt/prov.c +++ b/tools/mesh-gatt/prov.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H #include <config.h> diff --git a/tools/mesh-gatt/prov.h b/tools/mesh-gatt/prov.h index 2587df8fb..83156dd71 100644 --- a/tools/mesh-gatt/prov.h +++ b/tools/mesh-gatt/prov.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct prov; diff --git a/tools/mesh-gatt/util.c b/tools/mesh-gatt/util.c index 564665e5d..e845c4112 100644 --- a/tools/mesh-gatt/util.c +++ b/tools/mesh-gatt/util.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh-gatt/util.h b/tools/mesh-gatt/util.h index dba2c480b..51698a8ed 100644 --- a/tools/mesh-gatt/util.h +++ b/tools/mesh-gatt/util.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/tools/mesh/agent.c b/tools/mesh/agent.c index 0258a3803..ee0fade24 100644 --- a/tools/mesh/agent.c +++ b/tools/mesh/agent.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh/agent.h b/tools/mesh/agent.h index 7f95798f1..aa1fbb0eb 100644 --- a/tools/mesh/agent.h +++ b/tools/mesh/agent.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define MAX_HEXADECIMAL_OOB_LEN 128 diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c index 292bb7e19..1c20db85a 100644 --- a/tools/mesh/cfgcli.c +++ b/tools/mesh/cfgcli.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,17 +6,6 @@ * Copyright (C) 2019-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh/cfgcli.h b/tools/mesh/cfgcli.h index 89a67f5de..7281caa46 100644 --- a/tools/mesh/cfgcli.h +++ b/tools/mesh/cfgcli.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,17 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * */ struct mesh_group { diff --git a/tools/mesh/config-model.h b/tools/mesh/config-model.h index f08d3b890..584c5934a 100644 --- a/tools/mesh/config-model.h +++ b/tools/mesh/config-model.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017, 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define CONFIG_SERVER_MODEL_ID 0x0000 diff --git a/tools/mesh/keys.c b/tools/mesh/keys.c index c4070cb75..c08348bff 100644 --- a/tools/mesh/keys.c +++ b/tools/mesh/keys.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,17 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh/keys.h b/tools/mesh/keys.h index fa51044ef..f59705601 100644 --- a/tools/mesh/keys.h +++ b/tools/mesh/keys.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,17 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * */ void keys_add_net_key(uint16_t net_idx); diff --git a/tools/mesh/mesh-db.c b/tools/mesh/mesh-db.c index 7f2d5b358..d86913006 100644 --- a/tools/mesh/mesh-db.c +++ b/tools/mesh/mesh-db.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh/mesh-db.h b/tools/mesh/mesh-db.h index 49af33e87..d1d734bf3 100644 --- a/tools/mesh/mesh-db.h +++ b/tools/mesh/mesh-db.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include "mesh/mesh-config.h" diff --git a/tools/mesh/model.h b/tools/mesh/model.h index 35bb80efc..7359ea7df 100644 --- a/tools/mesh/model.h +++ b/tools/mesh/model.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,17 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * */ #define VENDOR_ID_INVALID 0xFFFF diff --git a/tools/mesh/remote.c b/tools/mesh/remote.c index f68ef4b41..9b265bee4 100644 --- a/tools/mesh/remote.c +++ b/tools/mesh/remote.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh/remote.h b/tools/mesh/remote.h index 482817c5a..bb4fb1191 100644 --- a/tools/mesh/remote.h +++ b/tools/mesh/remote.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ bool remote_add_node(const uint8_t uuid[16], uint16_t unicast, diff --git a/tools/mesh/util.c b/tools/mesh/util.c index 41a629177..29641439f 100644 --- a/tools/mesh/util.c +++ b/tools/mesh/util.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2017, 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mesh/util.h b/tools/mesh/util.h index 3b6a2f521..f075ffc6f 100644 --- a/tools/mesh/util.h +++ b/tools/mesh/util.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2017, 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include <stdbool.h> diff --git a/tools/meshctl.c b/tools/meshctl.c index 57998fded..9d7df2ccd 100644 --- a/tools/meshctl.c +++ b/tools/meshctl.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index 337a05b45..3b722207f 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/mpris-proxy.c b/tools/mpris-proxy.c index 617f80586..91a25501d 100644 --- a/tools/mpris-proxy.c +++ b/tools/mpris-proxy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/nokfw.c b/tools/nokfw.c index 6209642b5..629c15794 100644 --- a/tools/nokfw.c +++ b/tools/nokfw.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2013 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/obex-client-tool.c b/tools/obex-client-tool.c index 3d61c00d7..ab9332896 100644 --- a/tools/obex-client-tool.c +++ b/tools/obex-client-tool.c @@ -1,22 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/obex-server-tool.c b/tools/obex-server-tool.c index b20dfaa6b..ec280cc7b 100644 --- a/tools/obex-server-tool.c +++ b/tools/obex-server-tool.c @@ -1,22 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/obexctl.c b/tools/obexctl.c index 0709f692c..e671d253b 100644 --- a/tools/obexctl.c +++ b/tools/obexctl.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/oobtest.c b/tools/oobtest.c index c228b65b1..c095036fe 100644 --- a/tools/oobtest.c +++ b/tools/oobtest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parse_companies.pl b/tools/parse_companies.pl index d5b281505..9a78d292d 100755 --- a/tools/parse_companies.pl +++ b/tools/parse_companies.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl - +# SPDX-License-Identifier: LGPL-2.1-or-later # parse companies from # https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers diff --git a/tools/parser/amp.c b/tools/parser/amp.c index 7c85fb96c..797531470 100644 --- a/tools/parser/amp.c +++ b/tools/parser/amp.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012 Intel Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/att.c b/tools/parser/att.c index 688ed48a2..bef583a1a 100644 --- a/tools/parser/att.c +++ b/tools/parser/att.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 André Dieb Martins <andre.dieb@gmail.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/avctp.c b/tools/parser/avctp.c index 5038443a4..ef2067b5d 100644 --- a/tools/parser/avctp.c +++ b/tools/parser/avctp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/avdtp.c b/tools/parser/avdtp.c index 18569c895..bb7bbadab 100644 --- a/tools/parser/avdtp.c +++ b/tools/parser/avdtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/avrcp.c b/tools/parser/avrcp.c index dfc6d0580..e73a6317e 100644 --- a/tools/parser/avrcp.c +++ b/tools/parser/avrcp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/bnep.c b/tools/parser/bnep.c index c3bbae74f..ee1c9ec80 100644 --- a/tools/parser/bnep.c +++ b/tools/parser/bnep.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/bpa.c b/tools/parser/bpa.c index aac010b39..ab24cf645 100644 --- a/tools/parser/bpa.c +++ b/tools/parser/bpa.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/capi.c b/tools/parser/capi.c index ef6ac0664..2a2445e4a 100644 --- a/tools/parser/capi.c +++ b/tools/parser/capi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/cmtp.c b/tools/parser/cmtp.c index e7ac4b55c..09a30f8d2 100644 --- a/tools/parser/cmtp.c +++ b/tools/parser/cmtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2002-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/csr.c b/tools/parser/csr.c index 718baab32..c112e138b 100644 --- a/tools/parser/csr.c +++ b/tools/parser/csr.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/ericsson.c b/tools/parser/ericsson.c index d148c93f7..09b7cec68 100644 --- a/tools/parser/ericsson.c +++ b/tools/parser/ericsson.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/hci.c b/tools/parser/hci.c index 41f6fe087..d395e37f5 100644 --- a/tools/parser/hci.c +++ b/tools/parser/hci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/hcrp.c b/tools/parser/hcrp.c index 7c46cb6ea..7a5a19237 100644 --- a/tools/parser/hcrp.c +++ b/tools/parser/hcrp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/hidp.c b/tools/parser/hidp.c index 703049a7a..696b1eb87 100644 --- a/tools/parser/hidp.c +++ b/tools/parser/hidp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/l2cap.c b/tools/parser/l2cap.c index e43761cf7..562093ad0 100644 --- a/tools/parser/l2cap.c +++ b/tools/parser/l2cap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/l2cap.h b/tools/parser/l2cap.h index 788aef006..43da7c6b4 100644 --- a/tools/parser/l2cap.h +++ b/tools/parser/l2cap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __L2CAP_H diff --git a/tools/parser/lmp.c b/tools/parser/lmp.c index a7879fb37..e99902b0e 100644 --- a/tools/parser/lmp.c +++ b/tools/parser/lmp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/obex.c b/tools/parser/obex.c index 51719aa9c..157ea2cce 100644 --- a/tools/parser/obex.c +++ b/tools/parser/obex.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/parser.c b/tools/parser/parser.c index 61c5b1cda..5ed6a42d0 100644 --- a/tools/parser/parser.c +++ b/tools/parser/parser.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/parser.h b/tools/parser/parser.h index b7e1d7568..c5d9cf9a6 100644 --- a/tools/parser/parser.h +++ b/tools/parser/parser.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __PARSER_H diff --git a/tools/parser/ppp.c b/tools/parser/ppp.c index 55aaa60fe..43075575a 100644 --- a/tools/parser/ppp.c +++ b/tools/parser/ppp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/rfcomm.c b/tools/parser/rfcomm.c index d800b7e6d..6f2952021 100644 --- a/tools/parser/rfcomm.c +++ b/tools/parser/rfcomm.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/rfcomm.h b/tools/parser/rfcomm.h index a9faa0bf8..c3a1dfb22 100644 --- a/tools/parser/rfcomm.h +++ b/tools/parser/rfcomm.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __RFCOMM_H diff --git a/tools/parser/sap.c b/tools/parser/sap.c index 0a875fc7c..0b91bc08d 100644 --- a/tools/parser/sap.c +++ b/tools/parser/sap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Tieto Poland * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/sdp.c b/tools/parser/sdp.c index 7477037b8..90af47e5b 100644 --- a/tools/parser/sdp.c +++ b/tools/parser/sdp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/sdp.h b/tools/parser/sdp.h index ed55a23ea..1b5b3bb71 100644 --- a/tools/parser/sdp.h +++ b/tools/parser/sdp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __SDP_H diff --git a/tools/parser/smp.c b/tools/parser/smp.c index 817e08e85..a372e5e5f 100644 --- a/tools/parser/smp.c +++ b/tools/parser/smp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2011 Intel Corporation. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/parser/tcpip.c b/tools/parser/tcpip.c index 8ccfb007c..91de10458 100644 --- a/tools/parser/tcpip.c +++ b/tools/parser/tcpip.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/rctest.c b/tools/rctest.c index bc8ed875d..494359a88 100644 --- a/tools/rctest.c +++ b/tools/rctest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/rfcomm-tester.c b/tools/rfcomm-tester.c index 2d3be27d8..dcf19ecd2 100644 --- a/tools/rfcomm-tester.c +++ b/tools/rfcomm-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/rfcomm.c b/tools/rfcomm.c index 177d8f828..8e1db8eba 100644 --- a/tools/rfcomm.c +++ b/tools/rfcomm.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/rtlfw.c b/tools/rtlfw.c index 375f07592..7ff2dabf9 100644 --- a/tools/rtlfw.c +++ b/tools/rtlfw.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2013 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/sco-tester.c b/tools/sco-tester.c index 651fbe01d..471f89418 100644 --- a/tools/sco-tester.c +++ b/tools/sco-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/scotest.c b/tools/scotest.c index 08bc8a8d2..e6a88770f 100644 --- a/tools/scotest.c +++ b/tools/scotest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/sdptool.c b/tools/sdptool.c index 3c5d840d9..686d28362 100644 --- a/tools/sdptool.c +++ b/tools/sdptool.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -9,20 +10,6 @@ * Copyright (C) 2002-2003 Jean Tourrilhes <jt@hpl.hp.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/seq2bseq.c b/tools/seq2bseq.c index 9268ecd06..1806fd5a6 100644 --- a/tools/seq2bseq.c +++ b/tools/seq2bseq.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2013 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/smp-tester.c b/tools/smp-tester.c index c32519e0c..f64c1ab63 100644 --- a/tools/smp-tester.c +++ b/tools/smp-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/test-runner.c b/tools/test-runner.c index bd3c73001..6b7c33734 100644 --- a/tools/test-runner.c +++ b/tools/test-runner.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/ubcsp.c b/tools/ubcsp.c index b3f883a03..b01a749fd 100644 --- a/tools/ubcsp.c +++ b/tools/ubcsp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: MIT /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,25 +6,6 @@ * Copyright (C) 2000-2005 CSR Ltd. * * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * */ #ifdef HAVE_CONFIG_H diff --git a/tools/ubcsp.h b/tools/ubcsp.h index 6a74e9a16..47766e095 100644 --- a/tools/ubcsp.h +++ b/tools/ubcsp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: MIT */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,25 +6,6 @@ * Copyright (C) 2000-2005 CSR Ltd. * * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * */ #ifndef UBCSP_INCLUDE_H diff --git a/tools/update_compids.sh b/tools/update_compids.sh index be39f8858..38aaf641b 100755 --- a/tools/update_compids.sh +++ b/tools/update_compids.sh @@ -1,4 +1,5 @@ #!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-or-later # Download the list of company IDs from bluetooth.org and generate a diff which # can be applied to source tree to update bt_compidtostr(). Usage: # diff --git a/tools/userchan-tester.c b/tools/userchan-tester.c index 8fb088827..c17644fb8 100644 --- a/tools/userchan-tester.c +++ b/tools/userchan-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014-2015 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gAdGI+L6aF+TFQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:11:30 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id CHXMH+L6aF+0+AAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:11:30 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 718EB40618; Mon, 21 Sep 2020 21:11:23 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727805AbgIUTLS (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:11:18 -0400 Received: from mga04.intel.com ([192.55.52.120]:8592 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726886AbgIUTLR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:11:17 -0400 IronPort-SDR: 3+CIjR4N2VHie+mrJNVH5C8iz/lUEx1KNtG4FyZwdTy5Lu+hj15Uc6wz4MsnCu14NwpKj+iZX2 m+jCpMzHsmsg== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="157839593" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="157839593" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:11:16 -0700 IronPort-SDR: xc6oV/hgh4CxABhFcDyWeN55wcQBvCviHq9tHthjHPbL87EbdrZ3v0FkCPw3iWmDuXzTMUvqg2 dB4jv7FZdwOg== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485628141" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:11:16 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 18/20] build: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:00:38 -0700 Message-Id: <20200921190040.45309-19-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.17 / 15.00 / 15.00 X-Rspamd-Queue-Id: 718EB40618 X-Rspamd-UID: f93475 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 6 License: GPL-2.0-or-later Makefile.am Makefile.mesh Makefile.obexd Makefile.plugins Makefile.tools configure.ac --- Makefile.am | 2 +- Makefile.mesh | 1 + Makefile.obexd | 1 + Makefile.plugins | 2 +- Makefile.tools | 2 +- configure.ac | 1 + 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 22b4fa30c..56279c4ba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ - +# SPDX-License-Identifier: GPL-2.0 AM_MAKEFLAGS = --no-print-directory AM_CPPFLAGS = diff --git a/Makefile.mesh b/Makefile.mesh index 10573b304..228dd1b5f 100644 --- a/Makefile.mesh +++ b/Makefile.mesh @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 if MESH if DATAFILES diff --git a/Makefile.obexd b/Makefile.obexd index de59d297b..6f5dc04c0 100644 --- a/Makefile.obexd +++ b/Makefile.obexd @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 if SYSTEMD systemduserunitdir = $(SYSTEMD_USERUNITDIR) systemduserunit_DATA = obexd/src/obex.service diff --git a/Makefile.plugins b/Makefile.plugins index 98eee9ec8..3b673bf85 100644 --- a/Makefile.plugins +++ b/Makefile.plugins @@ -1,4 +1,4 @@ - +# SPDX-License-Identifier: GPL-2.0 builtin_modules += hostname builtin_sources += plugins/hostname.c diff --git a/Makefile.tools b/Makefile.tools index e260a7f81..0423293d6 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -1,4 +1,4 @@ - +# SPDX-License-Identifier: GPL-2.0 if CLIENT bin_PROGRAMS += client/bluetoothctl diff --git a/configure.ac b/configure.ac index 292dca615..d6347c098 100644 --- a/configure.ac +++ b/configure.ac @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 AC_PREREQ(2.60) AC_INIT(bluez, 5.55) -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sXC+KCz9aF+wTgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:21:16 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id AGdzJSz9aF+jKgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:21:16 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6B278A0B8D; Mon, 21 Sep 2020 21:21:09 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726537AbgIUTVI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726810AbgIUTVI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:21:08 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20B4BC061755 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 12:21:08 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id z19so15331684lfr.4 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 12:21:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w1PaecozHR4M5eRnCxHIbVVrIPnLcorg/Z74qyJThlI=; b=bGt4t/Uqsgw1OIj0LPjhocd+TK25QWC2VDpeLdDGa5QZ/alI/Fcm41FivflnSS/EQR FJJDzx7XRLHMLvVBU1mHyMpt6X6B0IplukuGNhvzwnLYO3meYDtfka9tDZX6/J86Fp0y x5be2rnLGsBIvrqvHogKxErUR5LK0WSU9IW4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w1PaecozHR4M5eRnCxHIbVVrIPnLcorg/Z74qyJThlI=; b=WGJP5zLptVHKvUHv8PYgrGQOnJdLs2gn+sR0nI/yDiB30IBNC/tPvTSgpQnbiKpDlf WZpZNf/YChUgO2W1nt/BvC41btodn7Af8wzL70V/mlgtoWbJplZM4QoU/yB9h8hURtjj vC6qLOS/BsRbcXIo1DoQ5PaY+J0wPOxIDi7+HQJjYK1+9wVR+KguoWJJEd5CR4lNLpDP Alw1lz3nwwx4eY0IrSG2ly5+OU4IMcu4y4kcWHBx5ivSKK9q5XGtm6Q1bohfY9MGTbhJ CUix5DM8Zdm18TV1Vt7P3ogS/ypXntUSIVrV2FojoXe3ASsgIh1vjopG3MmMgwdsSdPN wmdw== X-Gm-Message-State: AOAM530vnF/35gJf9eA/ObDoyLAzYRC1Hwuv0LAoKQFEWwieJV5DTkOU 83jdOTy/7+3kE70HS3dPsLwxU1kaQhMkeRuEBoFj1A== X-Google-Smtp-Source: ABdhPJx9iNwHUD4jQ7sy8ksPDVIRjrKYGykQqN7IrMIfj609rOhgwARaVe3Vtab90/Lzy9R5xQCjlRSjklElcE5fhys= X-Received: by 2002:a19:5619:: with SMTP id k25mr445034lfb.324.1600716065399; Mon, 21 Sep 2020 12:21:05 -0700 (PDT) MIME-Version: 1.0 References: <CABmPvSHYi7WeWqgqxSe60omSyVXj_EezMhGi1GMXBBWM-TWeBw@mail.gmail.com> <CABBYNZJDbPd83cx0KWLGMpE_KaA9xUbuMCDsuQVTNxV7xrowiw@mail.gmail.com> In-Reply-To: <CABBYNZJDbPd83cx0KWLGMpE_KaA9xUbuMCDsuQVTNxV7xrowiw@mail.gmail.com> From: Miao-chen Chou <mcchou@chromium.org> Date: Mon, 21 Sep 2020 12:20:54 -0700 Message-ID: <CABmPvSEgnWoyijsA=ZsNeJoJdbz5YJTZHtEGWp6JTj3dKxxMrQ@mail.gmail.com> Subject: Re: Modifying Makefile.am to facilitate test-adv-monitor and future unit tests. To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.37 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6B278A0B8D X-Rspamd-UID: ce8678 Hi Luiz, On Fri, Sep 18, 2020 at 3:12 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Miao, > > On Fri, Sep 18, 2020 at 12:44 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > Hi Luiz and Marcel, > > > > Unlike the rest of the existing unit tests in BlueZ, the logic blocks > > tested in test-adv-monitor require dependencies of not only > > src/adv_monitor.c but also all the dependency tree of > > src/adv_monitor.c. The current convention in Makefile.am is to add all > > the extra dependencies one by one. However, the maintenance cost is > > high and not suitable in the case of test-adv-monitor. Therefore, we'd > > like to propose changes in Makefile.am to make the source of > > bluetoothd as a static library and link it for bluetoothd target and > > the unit test target. It would be great if you can provide feedback on > > this idea before the implementation. Thanks in advance! > > Then we should have had the code move to src/shared for unit testing, > but how exactly are you planning to do that? For testing the kernel > interface it normally done via a dedicated tester, but that again can > be done with shared library. > In series https://patchwork.kernel.org/project/bluetooth/list/?series=351021, we introduced some helper functions in adv_monitor.h to perform unit testing and test-adv-monitor to facilitate the unit tests of adv_monitor. We are encountering an expected build check failure on this series. There are two categories in test-adv-monitor, content filtering and RSSI tracking, and content filter is easy to be moved to a standalone shared component while RSSI tracking involves the use of timer, D-Bus method calls and adv_monitor's internal structures, and that makes it strongly coupled with the adv_monitor implementation which require a tree of dependencies apart from adv_monitor. There are two options to resolve the build failures in our case. (1) Reorganize Makefile.am This option is to make the sources (except src/main.c) into a static lib and link this lib in bluetoothd executable target and whichever unit test the sources are required. (2) Create src/shared/am to facilitate helpers and core logic This option is to create a new source under src/shared/ to facilitate helper functions and core logic for src/adv_monitor. The interface of src/shared/am may have the following functions. - Create/destroy functions of struct adv_monitor - Create/destroy functions of struct adv_monitor_device - Helper function for monitor content matching. - Helper function for RSSI tracking However, the logic of RSSI tracking is hard to be ripped off and moved to src/shared/am. One example would be the use of timer in RSSI tracking, and there is currently no previous example of the timer use in the shared library. Series https://patchwork.kernel.org/project/bluetooth/list/?series=351021 is up for review. Our next step here would be ripped off the unit test for now and submit v5 of the series. Once we reach an conclusion on advmon unit test, we can submit a separate series including the refactoring and unit tests. Looking forward to any feedbacks. Thanks! Regards, Miao Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mIFWCJD+aF9gSwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:27:12 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id kMN5BZD+aF+4IAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:27:12 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1FE2240987; Mon, 21 Sep 2020 21:27:02 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727766AbgIUT1B (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:27:01 -0400 Received: from mga05.intel.com ([192.55.52.43]:10394 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbgIUT1A (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:27:00 -0400 IronPort-SDR: FD2+p1G00gpwIusJG5PPEc2hADwrfJynpHXa5gM7sCo8iYgTiSeS6/6uLO/g08yASqnpLyozyS 6WBvTW5+AKpw== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="245301712" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="245301712" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:26:56 -0700 IronPort-SDR: TLu7aZwbsQE/BBX3FyJPyaTYc9xNNtHDfMVdF3ynX4l/es1vxP7v/JdcMkopUMrPZ+ydVc+pCz TuRnrzNmuHsg== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="454192530" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:26:55 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 00/20] Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:26:39 -0700 Message-Id: <20200921190040.45309-1-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.03 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1FE2240987 X-Rspamd-UID: 7fff6a From: Tedd Ho-Jeong An <tedd.an@intel.com> This series adds SPDX License Identifer to the relavant files and creates LICENSES folder with full text of licenses used by the BlueZ tree. The following files were updated with SPDX License Identifier: - Source and header files (.c/.h) - Build files (Makefile.*) - Test scripts (python, bash, and etc) The SDPX License Identifier is added in form of a comment based on file type with the same rule from the Linxu kernel source, and added to the first line of the file or the second line after '#!PATH_TO_INTERPRETER'. C source: // SPDX-License-Identifer: <License id> C header: /* SPDX-License-Identifer: <License id> */ scripts: # SPDX-License-Identifier: <License id> For SPDX-License Identifier, it used the identifer from the SPDX License list page(https://spdx.org/licenses). For the summary, currently BlueZ sources have following licenses: ------------------------------------------- License File Count ------------------------------------------- GPL-2.0-or-later : 403 LGPL-2.1-or-later : 308 BSD-2-Clause : 3 GPL-2.0-only : 5 MIT : 2 Apache-2.0 : 80 Note that these folder/files were ignored: - .git/ - document files - configuration files Tedd Ho-Jeong An (20): android: Add SPDX License Identifier attrib: Add SPDX License Identifier btio: Add SPDX License Identifier client: Add SPDX License Identifier emulator: Add SPDX License Identifier gdbus: Add SPDX License Identifier gobex: Add SPDX License Identifier lib: Add SPDX License Identifier mesh: Add SPDX License Identifier monitor: Add SPDX License Identifier obexd: Add SPDX License Identifier peripheral: Add SPDX License Identifier plugins: Add SPDX License Identifier profiles: Add SPDX License Identifier unit: Add SPDX License Identifier src: Add SPDX License Identifier tools: Add SPDX License Identifier build: Add SPDX License Identifier test: Add SPDX License Identifier LICENSES: Add License files LICENSES/dual/Apache-2.0 | 187 +++++++++++ LICENSES/preferred/BSD-2-Clause | 32 ++ LICENSES/preferred/GPL-2.0 | 354 ++++++++++++++++++++ LICENSES/preferred/LGPL-2.1 | 503 +++++++++++++++++++++++++++++ LICENSES/preferred/MIT | 30 ++ Makefile.am | 2 +- Makefile.mesh | 1 + Makefile.obexd | 1 + Makefile.plugins | 2 +- Makefile.tools | 2 +- android/a2dp-sink.c | 15 +- android/a2dp-sink.h | 15 +- android/a2dp.c | 15 +- android/a2dp.h | 15 +- android/audio-msg.h | 15 +- android/audio_utils/resampler.c | 12 +- android/audio_utils/resampler.h | 12 +- android/avctp.c | 15 +- android/avctp.h | 15 +- android/avdtp.c | 15 +- android/avdtp.h | 15 +- android/avdtptest.c | 15 +- android/avrcp-lib.c | 15 +- android/avrcp-lib.h | 15 +- android/avrcp.c | 15 +- android/avrcp.h | 15 +- android/bluetooth.c | 15 +- android/bluetooth.h | 15 +- android/bluetoothd-snoop.c | 15 +- android/bluetoothd-wrapper.c | 13 +- android/client/haltest.c | 13 +- android/client/history.c | 13 +- android/client/history.h | 13 +- android/client/if-audio.c | 13 +- android/client/if-av-sink.c | 13 +- android/client/if-av.c | 13 +- android/client/if-bt.c | 13 +- android/client/if-gatt.c | 13 +- android/client/if-hf-client.c | 13 +- android/client/if-hf.c | 13 +- android/client/if-hh.c | 13 +- android/client/if-hl.c | 13 +- android/client/if-main.h | 13 +- android/client/if-mce.c | 13 +- android/client/if-pan.c | 13 +- android/client/if-rc-ctrl.c | 13 +- android/client/if-rc.c | 13 +- android/client/if-sco.c | 13 +- android/client/if-sock.c | 13 +- android/client/pollhandler.c | 13 +- android/client/pollhandler.h | 13 +- android/client/tabcompletion.c | 13 +- android/client/terminal.c | 13 +- android/client/terminal.h | 13 +- android/compat/readline/history.h | 15 +- android/compat/readline/readline.h | 15 +- android/compat/wordexp.h | 15 +- android/cutils/properties.h | 15 +- android/gatt.c | 15 +- android/gatt.h | 15 +- android/hal-a2dp-sink.c | 13 +- android/hal-a2dp.c | 13 +- android/hal-audio-aptx.c | 13 +- android/hal-audio-sbc.c | 13 +- android/hal-audio.c | 13 +- android/hal-audio.h | 13 +- android/hal-avrcp-ctrl.c | 13 +- android/hal-avrcp.c | 13 +- android/hal-bluetooth.c | 13 +- android/hal-gatt.c | 13 +- android/hal-handsfree-client.c | 13 +- android/hal-handsfree.c | 13 +- android/hal-health.c | 13 +- android/hal-hidhost.c | 13 +- android/hal-ipc.c | 13 +- android/hal-ipc.h | 13 +- android/hal-log.h | 13 +- android/hal-map-client.c | 13 +- android/hal-msg.h | 15 +- android/hal-pan.c | 13 +- android/hal-sco.c | 13 +- android/hal-socket.c | 13 +- android/hal-utils.c | 13 +- android/hal-utils.h | 13 +- android/hal.h | 13 +- android/handsfree-client.c | 15 +- android/handsfree-client.h | 15 +- android/handsfree.c | 15 +- android/handsfree.h | 15 +- android/hardware/audio.h | 12 +- android/hardware/audio_effect.h | 12 +- android/hardware/bluetooth.h | 12 +- android/hardware/bt_av.h | 12 +- android/hardware/bt_gatt.h | 12 +- android/hardware/bt_gatt_client.h | 12 +- android/hardware/bt_gatt_server.h | 12 +- android/hardware/bt_gatt_types.h | 12 +- android/hardware/bt_hf.h | 12 +- android/hardware/bt_hf_client.h | 12 +- android/hardware/bt_hh.h | 12 +- android/hardware/bt_hl.h | 12 +- android/hardware/bt_mce.h | 12 +- android/hardware/bt_pan.h | 12 +- android/hardware/bt_rc.h | 12 +- android/hardware/bt_sock.h | 12 +- android/hardware/hardware.c | 12 +- android/hardware/hardware.h | 12 +- android/health.c | 15 +- android/health.h | 15 +- android/hidhost.c | 15 +- android/hidhost.h | 15 +- android/ipc-common.h | 15 +- android/ipc-tester.c | 15 +- android/ipc.c | 15 +- android/ipc.h | 15 +- android/log.c | 15 +- android/main.c | 15 +- android/map-client.c | 15 +- android/map-client.h | 15 +- android/pan.c | 15 +- android/pan.h | 15 +- android/sco-msg.h | 15 +- android/sco.c | 15 +- android/sco.h | 15 +- android/socket.c | 15 +- android/socket.h | 15 +- android/system-emulator.c | 15 +- android/system/audio.h | 12 +- android/test-ipc.c | 15 +- android/tester-a2dp.c | 13 +- android/tester-avrcp.c | 13 +- android/tester-bluetooth.c | 13 +- android/tester-gatt.c | 13 +- android/tester-hdp.c | 13 +- android/tester-hidhost.c | 13 +- android/tester-main.c | 13 +- android/tester-main.h | 15 +- android/tester-map-client.c | 13 +- android/tester-pan.c | 13 +- android/tester-socket.c | 13 +- android/utils.h | 15 +- attrib/att-database.h | 15 +- attrib/att.c | 15 +- attrib/att.h | 15 +- attrib/gatt-service.c | 15 +- attrib/gatt-service.h | 15 +- attrib/gatt.c | 15 +- attrib/gatt.h | 15 +- attrib/gattrib.c | 15 +- attrib/gattrib.h | 15 +- attrib/gatttool.c | 15 +- attrib/gatttool.h | 15 +- attrib/interactive.c | 15 +- attrib/utils.c | 15 +- btio/btio.c | 15 +- btio/btio.h | 15 +- client/adv_monitor.c | 11 +- client/adv_monitor.h | 11 +- client/advertising.c | 15 +- client/advertising.h | 15 +- client/agent.c | 15 +- client/agent.h | 15 +- client/display.c | 15 +- client/display.h | 15 +- client/gatt.c | 15 +- client/gatt.h | 15 +- client/main.c | 15 +- configure.ac | 1 + emulator/amp.c | 15 +- emulator/amp.h | 15 +- emulator/b1ee.c | 15 +- emulator/btdev.c | 15 +- emulator/btdev.h | 15 +- emulator/bthost.c | 15 +- emulator/bthost.h | 15 +- emulator/hciemu.c | 15 +- emulator/hciemu.h | 15 +- emulator/hfp.c | 15 +- emulator/le.c | 15 +- emulator/le.h | 15 +- emulator/main.c | 15 +- emulator/phy.c | 15 +- emulator/phy.h | 15 +- emulator/serial.c | 15 +- emulator/serial.h | 15 +- emulator/server.c | 15 +- emulator/server.h | 15 +- emulator/smp.c | 15 +- emulator/vhci.c | 15 +- emulator/vhci.h | 15 +- gdbus/client.c | 15 +- gdbus/gdbus.h | 15 +- gdbus/mainloop.c | 15 +- gdbus/object.c | 15 +- gdbus/polkit.c | 15 +- gdbus/watch.c | 15 +- gobex/gobex-apparam.c | 15 +- gobex/gobex-apparam.h | 15 +- gobex/gobex-debug.h | 15 +- gobex/gobex-defs.c | 15 +- gobex/gobex-defs.h | 15 +- gobex/gobex-header.c | 15 +- gobex/gobex-header.h | 15 +- gobex/gobex-packet.c | 15 +- gobex/gobex-packet.h | 15 +- gobex/gobex-transfer.c | 15 +- gobex/gobex.c | 15 +- gobex/gobex.h | 15 +- lib/a2mp.h | 15 +- lib/amp.h | 10 +- lib/bluetooth.c | 15 +- lib/bluetooth.h | 15 +- lib/bnep.h | 15 +- lib/cmtp.h | 15 +- lib/hci.c | 15 +- lib/hci.h | 15 +- lib/hci_lib.h | 15 +- lib/hidp.h | 15 +- lib/l2cap.h | 15 +- lib/mgmt.h | 15 +- lib/rfcomm.h | 15 +- lib/sco.h | 15 +- lib/sdp.c | 15 +- lib/sdp.h | 15 +- lib/sdp_lib.h | 15 +- lib/uuid.c | 15 +- lib/uuid.h | 15 +- mesh/agent.c | 11 +- mesh/agent.h | 11 +- mesh/appkey.c | 11 +- mesh/appkey.h | 11 +- mesh/cfgmod-server.c | 11 +- mesh/cfgmod.h | 11 +- mesh/crypto.c | 11 +- mesh/crypto.h | 11 +- mesh/dbus.c | 11 +- mesh/dbus.h | 11 +- mesh/error.h | 11 +- mesh/friend.c | 11 +- mesh/friend.h | 11 +- mesh/keyring.c | 11 +- mesh/keyring.h | 11 +- mesh/main.c | 11 +- mesh/manager.c | 11 +- mesh/manager.h | 11 +- mesh/mesh-config-json.c | 11 +- mesh/mesh-config.h | 11 +- mesh/mesh-defs.h | 12 +- mesh/mesh-io-api.h | 11 +- mesh/mesh-io-generic.c | 11 +- mesh/mesh-io-generic.h | 11 +- mesh/mesh-io.c | 11 +- mesh/mesh-io.h | 11 +- mesh/mesh-mgmt.c | 11 +- mesh/mesh-mgmt.h | 11 +- mesh/mesh.c | 11 +- mesh/mesh.h | 11 +- mesh/model.c | 11 +- mesh/model.h | 11 +- mesh/net-keys.c | 11 +- mesh/net-keys.h | 11 +- mesh/net.c | 11 +- mesh/net.h | 11 +- mesh/node.c | 11 +- mesh/node.h | 11 +- mesh/pb-adv.c | 11 +- mesh/pb-adv.h | 11 +- mesh/prov-acceptor.c | 11 +- mesh/prov-initiator.c | 11 +- mesh/prov.h | 11 +- mesh/provision.h | 11 +- mesh/rpl.c | 11 +- mesh/rpl.h | 11 +- mesh/util.c | 11 +- mesh/util.h | 11 +- monitor/a2dp.c | 15 +- monitor/a2dp.h | 15 +- monitor/analyze.c | 15 +- monitor/analyze.h | 15 +- monitor/avctp.c | 15 +- monitor/avctp.h | 15 +- monitor/avdtp.c | 15 +- monitor/avdtp.h | 15 +- monitor/bnep.c | 15 +- monitor/bnep.h | 15 +- monitor/broadcom.c | 15 +- monitor/broadcom.h | 15 +- monitor/bt.h | 15 +- monitor/control.c | 15 +- monitor/control.h | 15 +- monitor/crc.c | 15 +- monitor/crc.h | 15 +- monitor/display.c | 15 +- monitor/display.h | 15 +- monitor/ellisys.c | 15 +- monitor/ellisys.h | 15 +- monitor/hcidump.c | 15 +- monitor/hcidump.h | 15 +- monitor/hwdb.c | 15 +- monitor/hwdb.h | 15 +- monitor/intel.c | 15 +- monitor/intel.h | 15 +- monitor/jlink.c | 15 +- monitor/jlink.h | 15 +- monitor/keys.c | 15 +- monitor/keys.h | 15 +- monitor/l2cap.c | 15 +- monitor/l2cap.h | 15 +- monitor/ll.c | 15 +- monitor/ll.h | 15 +- monitor/lmp.c | 15 +- monitor/lmp.h | 15 +- monitor/main.c | 15 +- monitor/packet.c | 15 +- monitor/packet.h | 15 +- monitor/rfcomm.c | 15 +- monitor/rfcomm.h | 15 +- monitor/sdp.c | 15 +- monitor/sdp.h | 15 +- monitor/tty.h | 15 +- monitor/vendor.c | 15 +- monitor/vendor.h | 15 +- obexd/client/bluetooth.c | 15 +- obexd/client/bluetooth.h | 15 +- obexd/client/driver.c | 15 +- obexd/client/driver.h | 15 +- obexd/client/ftp.c | 15 +- obexd/client/ftp.h | 15 +- obexd/client/manager.c | 15 +- obexd/client/manager.h | 15 +- obexd/client/map-event.c | 15 +- obexd/client/map-event.h | 15 +- obexd/client/map.c | 15 +- obexd/client/map.h | 15 +- obexd/client/mns.c | 15 +- obexd/client/opp.c | 15 +- obexd/client/opp.h | 15 +- obexd/client/pbap.c | 15 +- obexd/client/pbap.h | 15 +- obexd/client/session.c | 15 +- obexd/client/session.h | 15 +- obexd/client/sync.c | 15 +- obexd/client/sync.h | 15 +- obexd/client/transfer.c | 15 +- obexd/client/transfer.h | 15 +- obexd/client/transport.c | 15 +- obexd/client/transport.h | 15 +- obexd/plugins/bluetooth.c | 15 +- obexd/plugins/filesystem.c | 15 +- obexd/plugins/filesystem.h | 15 +- obexd/plugins/ftp.c | 15 +- obexd/plugins/ftp.h | 15 +- obexd/plugins/irmc.c | 15 +- obexd/plugins/mas.c | 15 +- obexd/plugins/messages-dummy.c | 15 +- obexd/plugins/messages-tracker.c | 15 +- obexd/plugins/messages.h | 15 +- obexd/plugins/opp.c | 15 +- obexd/plugins/pbap.c | 15 +- obexd/plugins/pcsuite.c | 15 +- obexd/plugins/phonebook-dummy.c | 15 +- obexd/plugins/phonebook-ebook.c | 15 +- obexd/plugins/phonebook-tracker.c | 15 +- obexd/plugins/phonebook.h | 15 +- obexd/plugins/syncevolution.c | 15 +- obexd/plugins/vcard.c | 15 +- obexd/plugins/vcard.h | 15 +- obexd/src/log.c | 15 +- obexd/src/log.h | 15 +- obexd/src/main.c | 15 +- obexd/src/manager.c | 15 +- obexd/src/manager.h | 15 +- obexd/src/map_ap.h | 15 +- obexd/src/mimetype.c | 15 +- obexd/src/mimetype.h | 15 +- obexd/src/obex-priv.h | 15 +- obexd/src/obex.c | 15 +- obexd/src/obex.h | 15 +- obexd/src/obexd.h | 15 +- obexd/src/plugin.c | 15 +- obexd/src/plugin.h | 15 +- obexd/src/server.c | 15 +- obexd/src/server.h | 15 +- obexd/src/service.c | 15 +- obexd/src/service.h | 15 +- obexd/src/transport.c | 15 +- obexd/src/transport.h | 15 +- peripheral/attach.c | 15 +- peripheral/attach.h | 15 +- peripheral/efivars.c | 15 +- peripheral/efivars.h | 15 +- peripheral/gap.c | 15 +- peripheral/gap.h | 15 +- peripheral/gatt.c | 15 +- peripheral/gatt.h | 15 +- peripheral/log.c | 15 +- peripheral/log.h | 15 +- peripheral/main.c | 15 +- plugins/autopair.c | 15 +- plugins/external-dummy.c | 15 +- plugins/hostname.c | 15 +- plugins/neard.c | 15 +- plugins/policy.c | 15 +- plugins/sixaxis.c | 15 +- plugins/wiimote.c | 15 +- profiles/audio/a2dp-codecs.h | 15 +- profiles/audio/a2dp.c | 15 +- profiles/audio/a2dp.h | 15 +- profiles/audio/avctp.c | 15 +- profiles/audio/avctp.h | 15 +- profiles/audio/avdtp.c | 15 +- profiles/audio/avdtp.h | 15 +- profiles/audio/avrcp.c | 15 +- profiles/audio/avrcp.h | 15 +- profiles/audio/control.c | 15 +- profiles/audio/control.h | 15 +- profiles/audio/media.c | 15 +- profiles/audio/media.h | 15 +- profiles/audio/player.c | 15 +- profiles/audio/player.h | 15 +- profiles/audio/sink.c | 15 +- profiles/audio/sink.h | 15 +- profiles/audio/source.c | 15 +- profiles/audio/source.h | 15 +- profiles/audio/transport.c | 15 +- profiles/audio/transport.h | 15 +- profiles/battery/bas.c | 15 +- profiles/battery/bas.h | 15 +- profiles/battery/battery.c | 10 +- profiles/cups/cups.h | 15 +- profiles/cups/hcrp.c | 15 +- profiles/cups/main.c | 15 +- profiles/cups/sdp.c | 15 +- profiles/cups/spp.c | 15 +- profiles/deviceinfo/deviceinfo.c | 15 +- profiles/deviceinfo/dis.c | 15 +- profiles/deviceinfo/dis.h | 15 +- profiles/gap/gas.c | 10 +- profiles/health/hdp.c | 15 +- profiles/health/hdp.h | 15 +- profiles/health/hdp_main.c | 15 +- profiles/health/hdp_manager.c | 15 +- profiles/health/hdp_manager.h | 15 +- profiles/health/hdp_types.h | 15 +- profiles/health/hdp_util.c | 15 +- profiles/health/hdp_util.h | 15 +- profiles/health/mcap.c | 15 +- profiles/health/mcap.h | 15 +- profiles/iap/main.c | 15 +- profiles/input/device.c | 15 +- profiles/input/device.h | 15 +- profiles/input/hidp_defs.h | 15 +- profiles/input/hog-lib.c | 15 +- profiles/input/hog-lib.h | 15 +- profiles/input/hog.c | 15 +- profiles/input/manager.c | 15 +- profiles/input/server.c | 15 +- profiles/input/server.h | 15 +- profiles/input/sixaxis.h | 15 +- profiles/input/suspend-dummy.c | 15 +- profiles/input/suspend-none.c | 15 +- profiles/input/suspend.h | 15 +- profiles/midi/libmidi.c | 16 +- profiles/midi/libmidi.h | 16 +- profiles/midi/midi.c | 20 +- profiles/network/bnep.c | 15 +- profiles/network/bnep.h | 15 +- profiles/network/connection.c | 15 +- profiles/network/connection.h | 15 +- profiles/network/manager.c | 15 +- profiles/network/server.c | 15 +- profiles/network/server.h | 15 +- profiles/sap/main.c | 14 +- profiles/sap/manager.c | 14 +- profiles/sap/manager.h | 14 +- profiles/sap/sap-dummy.c | 14 +- profiles/sap/sap.h | 14 +- profiles/sap/server.c | 14 +- profiles/sap/server.h | 14 +- profiles/scanparam/scan.c | 15 +- profiles/scanparam/scpp.c | 15 +- profiles/scanparam/scpp.h | 15 +- src/adapter.c | 15 +- src/adapter.h | 15 +- src/adv_monitor.c | 11 +- src/adv_monitor.h | 11 +- src/advertising.c | 11 +- src/advertising.h | 11 +- src/agent.c | 15 +- src/agent.h | 15 +- src/attrib-server.c | 15 +- src/attrib-server.h | 15 +- src/backtrace.c | 15 +- src/backtrace.h | 15 +- src/dbus-common.c | 15 +- src/dbus-common.h | 15 +- src/device.c | 15 +- src/device.h | 15 +- src/eir.c | 15 +- src/eir.h | 15 +- src/error.c | 15 +- src/error.h | 15 +- src/gatt-client.c | 11 +- src/gatt-client.h | 11 +- src/gatt-database.c | 11 +- src/gatt-database.h | 11 +- src/hcid.h | 15 +- src/log.c | 15 +- src/log.h | 15 +- src/main.c | 15 +- src/oui.c | 15 +- src/oui.h | 15 +- src/plugin.c | 15 +- src/plugin.h | 15 +- src/profile.c | 15 +- src/profile.h | 15 +- src/rfkill.c | 15 +- src/sdp-client.c | 15 +- src/sdp-client.h | 15 +- src/sdp-xml.c | 15 +- src/sdp-xml.h | 15 +- src/sdpd-database.c | 15 +- src/sdpd-request.c | 15 +- src/sdpd-server.c | 15 +- src/sdpd-service.c | 15 +- src/sdpd.h | 15 +- src/service.c | 15 +- src/service.h | 15 +- src/shared/ad.c | 15 +- src/shared/ad.h | 15 +- src/shared/att-types.h | 15 +- src/shared/att.c | 15 +- src/shared/att.h | 15 +- src/shared/btp.c | 15 +- src/shared/btp.h | 15 +- src/shared/btsnoop.c | 15 +- src/shared/btsnoop.h | 15 +- src/shared/crypto.c | 15 +- src/shared/crypto.h | 15 +- src/shared/ecc.c | 21 +- src/shared/ecc.h | 21 +- src/shared/gap.c | 15 +- src/shared/gap.h | 15 +- src/shared/gatt-client.c | 15 +- src/shared/gatt-client.h | 15 +- src/shared/gatt-db.c | 15 +- src/shared/gatt-db.h | 15 +- src/shared/gatt-helpers.c | 15 +- src/shared/gatt-helpers.h | 15 +- src/shared/gatt-server.c | 15 +- src/shared/gatt-server.h | 15 +- src/shared/hci-crypto.c | 15 +- src/shared/hci-crypto.h | 15 +- src/shared/hci.c | 15 +- src/shared/hci.h | 15 +- src/shared/hfp.c | 15 +- src/shared/hfp.h | 15 +- src/shared/io-ell.c | 15 +- src/shared/io-glib.c | 15 +- src/shared/io-mainloop.c | 15 +- src/shared/io.h | 15 +- src/shared/log.c | 15 +- src/shared/log.h | 15 +- src/shared/mainloop-ell.c | 12 +- src/shared/mainloop-glib.c | 15 +- src/shared/mainloop-notify.c | 15 +- src/shared/mainloop-notify.h | 15 +- src/shared/mainloop.c | 15 +- src/shared/mainloop.h | 15 +- src/shared/mgmt.c | 15 +- src/shared/mgmt.h | 15 +- src/shared/pcap.c | 15 +- src/shared/pcap.h | 15 +- src/shared/queue.c | 15 +- src/shared/queue.h | 15 +- src/shared/ringbuf.c | 15 +- src/shared/ringbuf.h | 15 +- src/shared/shell.c | 15 +- src/shared/shell.h | 15 +- src/shared/tester.c | 15 +- src/shared/tester.h | 15 +- src/shared/timeout-ell.c | 11 +- src/shared/timeout-glib.c | 11 +- src/shared/timeout-mainloop.c | 11 +- src/shared/timeout.h | 11 +- src/shared/tty.h | 15 +- src/shared/uhid.c | 15 +- src/shared/uhid.h | 15 +- src/shared/util.c | 15 +- src/shared/util.h | 15 +- src/storage.c | 15 +- src/storage.h | 15 +- src/textfile.c | 15 +- src/textfile.h | 15 +- src/uinput.h | 15 +- src/uuid-helper.c | 15 +- src/uuid-helper.h | 15 +- test/agent.py | 1 + test/bluezutils.py | 2 + test/dbusdef.py | 2 + test/example-advertisement | 1 + test/example-endpoint | 1 + test/example-gatt-client | 1 + test/example-gatt-server | 1 + test/example-player | 1 + test/exchange-business-cards | 1 + test/ftp-client | 1 + test/get-managed-objects | 1 + test/get-obex-capabilities | 1 + test/list-devices | 1 + test/list-folders | 1 + test/map-client | 1 + test/monitor-bluetooth | 1 + test/opp-client | 1 + test/pbap-client | 1 + test/sap_client.py | 15 +- test/simple-agent | 1 + test/simple-endpoint | 1 + test/simple-obex-agent | 1 + test/simple-player | 1 + test/test-adapter | 1 + test/test-device | 1 + test/test-discovery | 1 + test/test-gatt-profile | 1 + test/test-health | 1 + test/test-health-sink | 1 + test/test-hfp | 1 + test/test-join | 1 + test/test-manager | 1 + test/test-mesh | 1 + test/test-nap | 1 + test/test-network | 1 + test/test-profile | 1 + test/test-sap-server | 1 + tools/3dsp.c | 15 +- tools/advtest.c | 15 +- tools/amptest.c | 15 +- tools/avinfo.c | 15 +- tools/avtest.c | 15 +- tools/bccmd.c | 15 +- tools/bcmfw.c | 15 +- tools/bdaddr.c | 15 +- tools/bluemoon.c | 15 +- tools/bluetooth-player.c | 15 +- tools/bnep-tester.c | 15 +- tools/bneptest.c | 15 +- tools/btattach.c | 15 +- tools/btconfig.c | 15 +- tools/btgatt-client.c | 15 +- tools/btgatt-server.c | 11 +- tools/btinfo.c | 15 +- tools/btiotest.c | 15 +- tools/btmgmt.c | 15 +- tools/btmon-logger.c | 15 +- tools/btpclient.c | 15 +- tools/btpclientctl.c | 15 +- tools/btproxy.c | 15 +- tools/btsnoop.c | 15 +- tools/check-selftest.c | 15 +- tools/ciptool.c | 15 +- tools/cltest.c | 15 +- tools/create-image.c | 15 +- tools/csr.c | 15 +- tools/csr.h | 15 +- tools/csr_3wire.c | 15 +- tools/csr_bcsp.c | 15 +- tools/csr_h4.c | 15 +- tools/csr_hci.c | 15 +- tools/csr_usb.c | 15 +- tools/eddystone.c | 15 +- tools/gap-tester.c | 15 +- tools/gatt-service.c | 15 +- tools/hci-tester.c | 15 +- tools/hciattach.c | 15 +- tools/hciattach.h | 15 +- tools/hciattach_ath3k.c | 15 +- tools/hciattach_bcm43xx.c | 15 +- tools/hciattach_intel.c | 15 +- tools/hciattach_qualcomm.c | 15 +- tools/hciattach_st.c | 15 +- tools/hciattach_ti.c | 15 +- tools/hciattach_tialt.c | 15 +- tools/hciconfig.c | 15 +- tools/hcidump.c | 15 +- tools/hcieventmask.c | 15 +- tools/hcisecfilter.c | 15 +- tools/hcitool.c | 15 +- tools/hex2hcd.c | 15 +- tools/hid2hci.c | 15 +- tools/hwdb.c | 15 +- tools/ibeacon.c | 15 +- tools/l2cap-tester.c | 15 +- tools/l2ping.c | 15 +- tools/l2test.c | 15 +- tools/mcaptest.c | 15 +- tools/mesh-cfgclient.c | 11 +- tools/mesh-gatt/config-client.c | 15 +- tools/mesh-gatt/config-server.c | 15 +- tools/mesh-gatt/crypto.c | 15 +- tools/mesh-gatt/crypto.h | 15 +- tools/mesh-gatt/gatt.c | 15 +- tools/mesh-gatt/gatt.h | 15 +- tools/mesh-gatt/keys.h | 15 +- tools/mesh-gatt/mesh-net.h | 15 +- tools/mesh-gatt/net.c | 15 +- tools/mesh-gatt/net.h | 15 +- tools/mesh-gatt/node.c | 15 +- tools/mesh-gatt/node.h | 15 +- tools/mesh-gatt/onoff-model.c | 15 +- tools/mesh-gatt/onoff-model.h | 15 +- tools/mesh-gatt/prov-db.c | 15 +- tools/mesh-gatt/prov-db.h | 15 +- tools/mesh-gatt/prov.c | 15 +- tools/mesh-gatt/prov.h | 15 +- tools/mesh-gatt/util.c | 15 +- tools/mesh-gatt/util.h | 15 +- tools/mesh/agent.c | 15 +- tools/mesh/agent.h | 15 +- tools/mesh/cfgcli.c | 12 +- tools/mesh/cfgcli.h | 12 +- tools/mesh/config-model.h | 15 +- tools/mesh/keys.c | 12 +- tools/mesh/keys.h | 12 +- tools/mesh/mesh-db.c | 11 +- tools/mesh/mesh-db.h | 11 +- tools/mesh/model.h | 12 +- tools/mesh/remote.c | 11 +- tools/mesh/remote.h | 11 +- tools/mesh/util.c | 11 +- tools/mesh/util.h | 11 +- tools/meshctl.c | 15 +- tools/mgmt-tester.c | 15 +- tools/mpris-proxy.c | 15 +- tools/nokfw.c | 15 +- tools/obex-client-tool.c | 14 +- tools/obex-server-tool.c | 14 +- tools/obexctl.c | 15 +- tools/oobtest.c | 15 +- tools/parse_companies.pl | 2 +- tools/parser/amp.c | 15 +- tools/parser/att.c | 15 +- tools/parser/avctp.c | 15 +- tools/parser/avdtp.c | 15 +- tools/parser/avrcp.c | 15 +- tools/parser/bnep.c | 15 +- tools/parser/bpa.c | 15 +- tools/parser/capi.c | 15 +- tools/parser/cmtp.c | 15 +- tools/parser/csr.c | 15 +- tools/parser/ericsson.c | 15 +- tools/parser/hci.c | 15 +- tools/parser/hcrp.c | 15 +- tools/parser/hidp.c | 15 +- tools/parser/l2cap.c | 15 +- tools/parser/l2cap.h | 15 +- tools/parser/lmp.c | 15 +- tools/parser/obex.c | 15 +- tools/parser/parser.c | 15 +- tools/parser/parser.h | 15 +- tools/parser/ppp.c | 15 +- tools/parser/rfcomm.c | 15 +- tools/parser/rfcomm.h | 15 +- tools/parser/sap.c | 15 +- tools/parser/sdp.c | 15 +- tools/parser/sdp.h | 15 +- tools/parser/smp.c | 15 +- tools/parser/tcpip.c | 15 +- tools/rctest.c | 15 +- tools/rfcomm-tester.c | 15 +- tools/rfcomm.c | 15 +- tools/rtlfw.c | 15 +- tools/sco-tester.c | 15 +- tools/scotest.c | 15 +- tools/sdptool.c | 15 +- tools/seq2bseq.c | 15 +- tools/smp-tester.c | 15 +- tools/test-runner.c | 15 +- tools/ubcsp.c | 20 +- tools/ubcsp.h | 20 +- tools/update_compids.sh | 1 + tools/userchan-tester.c | 15 +- unit/test-avctp.c | 15 +- unit/test-avdtp.c | 15 +- unit/test-avrcp.c | 15 +- unit/test-crc.c | 15 +- unit/test-crypto.c | 15 +- unit/test-ecc.c | 21 +- unit/test-eir.c | 15 +- unit/test-gatt.c | 15 +- unit/test-gattrib.c | 15 +- unit/test-gdbus-client.c | 15 +- unit/test-gobex-apparam.c | 15 +- unit/test-gobex-header.c | 15 +- unit/test-gobex-packet.c | 15 +- unit/test-gobex-transfer.c | 15 +- unit/test-gobex.c | 15 +- unit/test-hfp.c | 15 +- unit/test-hog.c | 15 +- unit/test-lib.c | 15 +- unit/test-mesh-crypto.c | 11 +- unit/test-mgmt.c | 15 +- unit/test-midi.c | 16 +- unit/test-queue.c | 15 +- unit/test-ringbuf.c | 15 +- unit/test-sdp.c | 15 +- unit/test-textfile.c | 15 +- unit/test-uhid.c | 15 +- unit/test-uuid.c | 15 +- unit/util.c | 14 +- unit/util.h | 14 +- 810 files changed, 1913 insertions(+), 10186 deletions(-) create mode 100644 LICENSES/dual/Apache-2.0 create mode 100644 LICENSES/preferred/BSD-2-Clause create mode 100644 LICENSES/preferred/GPL-2.0 create mode 100644 LICENSES/preferred/LGPL-2.1 create mode 100644 LICENSES/preferred/MIT -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YD69CI0AaV9gSwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:35:41 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id CBfRBY0AaV+VygAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:35:41 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E0492A0B37; Mon, 21 Sep 2020 21:35:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727519AbgIUTfP (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:35:15 -0400 Received: from mga05.intel.com ([192.55.52.43]:11000 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727197AbgIUTfP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:35:15 -0400 IronPort-SDR: g1rNRAT5TdrbAbBoK77cwP7YZlJgGOR07+M9sIWDngZNGb1Ofzc8F+zZm0+peYFo4LvKUFH1ra TWbh/25NZL9w== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="245302482" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="245302482" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:35:15 -0700 IronPort-SDR: 5kR6CNo82v41PlzxMpJ0q4fIXKtuw7EQQqortJiOkoBYHjTTMvVaaLySgX1Uv4PenH4O25pWND OqOJvjpnvuHA== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="510848358" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:35:15 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 06/20] gdbus: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:35:09 -0700 Message-Id: <20200921193509.47073-1-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -0.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: E0492A0B37 X-Rspamd-UID: dfdfd8 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 6 License: GPL-2.0-or-later gdbus/mainloop.c gdbus/object.c gdbus/polkit.c gdbus/client.c gdbus/watch.c gdbus/gdbus.h --- gdbus/client.c | 15 +-------------- gdbus/gdbus.h | 15 +-------------- gdbus/mainloop.c | 15 +-------------- gdbus/object.c | 15 +-------------- gdbus/polkit.c | 15 +-------------- gdbus/watch.c | 15 +-------------- 6 files changed, 6 insertions(+), 84 deletions(-) diff --git a/gdbus/client.c b/gdbus/client.c index 84e076994..3b7faa4e4 100644 --- a/gdbus/client.c +++ b/gdbus/client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h index 9bdff9eba..28b802296 100644 --- a/gdbus/gdbus.h +++ b/gdbus/gdbus.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __GDBUS_H diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c index b90a8447c..a04ebb19b 100644 --- a/gdbus/mainloop.c +++ b/gdbus/mainloop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gdbus/object.c b/gdbus/object.c index 49b578087..50a8b4ff1 100644 --- a/gdbus/object.c +++ b/gdbus/object.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gdbus/polkit.c b/gdbus/polkit.c index 9e95fa384..80e024fad 100644 --- a/gdbus/polkit.c +++ b/gdbus/polkit.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/gdbus/watch.c b/gdbus/watch.c index 447e48671..25f367613 100644 --- a/gdbus/watch.c +++ b/gdbus/watch.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * D-Bus helper library @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QM6ENcsAaV+wTgAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:36:43 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id yO9qMssAaV/OfgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:36:43 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 83499A0377; Mon, 21 Sep 2020 21:36:18 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728104AbgIUTfo (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:35:44 -0400 Received: from mga18.intel.com ([134.134.136.126]:18041 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727197AbgIUTfo (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:35:44 -0400 IronPort-SDR: 6/cfUjo+DPsrUtv4l8yh9IgqRetufFFUY+b5q4Aa7CEQ5q9s1Exyz1vYXntGZ9it4TcOch0X07 son6HMo3fhWg== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="148221645" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="148221645" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:35:40 -0700 IronPort-SDR: NGfRTILaVRrxTyyy3RLQDh5++z+kp+QuvwSp6/IfBT/72MQQttifDelBXuqBWt/BnGcc8/7FLz YMdTA5q8Y3rA== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="334681709" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:35:40 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 09/20] mesh: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:35:33 -0700 Message-Id: <20200921193533.47135-1-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: 83499A0377 X-Rspamd-UID: eb718d From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 48 License: LGPL-2.1-or-later mesh/mesh-mgmt.h mesh/mesh-mgmt.c mesh/net-keys.c mesh/mesh-io-api.h mesh/mesh.h mesh/net-keys.h mesh/model.h mesh/util.h mesh/appkey.c mesh/cfgmod.h mesh/appkey.h mesh/prov.h mesh/prov-acceptor.c mesh/net.c mesh/dbus.h mesh/friend.h mesh/mesh-io-generic.c mesh/main.c mesh/util.c mesh/dbus.c mesh/error.h mesh/mesh-config-json.c mesh/agent.h mesh/pb-adv.c mesh/crypto.c mesh/crypto.h mesh/friend.c mesh/pb-adv.h mesh/provision.h mesh/mesh-config.h mesh/mesh-io-generic.h mesh/agent.c mesh/cfgmod-server.c mesh/mesh-io.h mesh/keyring.h mesh/net.h mesh/keyring.c mesh/mesh-defs.h mesh/mesh.c mesh/rpl.c mesh/manager.c mesh/model.c mesh/mesh-io.c mesh/node.c mesh/prov-initiator.c mesh/rpl.h mesh/node.h mesh/manager.h --- mesh/agent.c | 11 +---------- mesh/agent.h | 11 +---------- mesh/appkey.c | 11 +---------- mesh/appkey.h | 11 +---------- mesh/cfgmod-server.c | 11 +---------- mesh/cfgmod.h | 11 +---------- mesh/crypto.c | 11 +---------- mesh/crypto.h | 11 +---------- mesh/dbus.c | 11 +---------- mesh/dbus.h | 11 +---------- mesh/error.h | 11 +---------- mesh/friend.c | 11 +---------- mesh/friend.h | 11 +---------- mesh/keyring.c | 11 +---------- mesh/keyring.h | 11 +---------- mesh/main.c | 11 +---------- mesh/manager.c | 11 +---------- mesh/manager.h | 11 +---------- mesh/mesh-config-json.c | 11 +---------- mesh/mesh-config.h | 11 +---------- mesh/mesh-defs.h | 12 +----------- mesh/mesh-io-api.h | 11 +---------- mesh/mesh-io-generic.c | 11 +---------- mesh/mesh-io-generic.h | 11 +---------- mesh/mesh-io.c | 11 +---------- mesh/mesh-io.h | 11 +---------- mesh/mesh-mgmt.c | 11 +---------- mesh/mesh-mgmt.h | 11 +---------- mesh/mesh.c | 11 +---------- mesh/mesh.h | 11 +---------- mesh/model.c | 11 +---------- mesh/model.h | 11 +---------- mesh/net-keys.c | 11 +---------- mesh/net-keys.h | 11 +---------- mesh/net.c | 11 +---------- mesh/net.h | 11 +---------- mesh/node.c | 11 +---------- mesh/node.h | 11 +---------- mesh/pb-adv.c | 11 +---------- mesh/pb-adv.h | 11 +---------- mesh/prov-acceptor.c | 11 +---------- mesh/prov-initiator.c | 11 +---------- mesh/prov.h | 11 +---------- mesh/provision.h | 11 +---------- mesh/rpl.c | 11 +---------- mesh/rpl.h | 11 +---------- mesh/util.c | 11 +---------- mesh/util.h | 11 +---------- 48 files changed, 48 insertions(+), 481 deletions(-) diff --git a/mesh/agent.c b/mesh/agent.c index 4d200416f..b0d523d16 100644 --- a/mesh/agent.c +++ b/mesh/agent.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/agent.h b/mesh/agent.h index 6cc3d0f71..6664c2226 100644 --- a/mesh/agent.h +++ b/mesh/agent.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_agent; diff --git a/mesh/appkey.c b/mesh/appkey.c index a4771bd7d..7efb8f5c4 100644 --- a/mesh/appkey.c +++ b/mesh/appkey.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2017-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/appkey.h b/mesh/appkey.h index 23b474a0a..3bb70445b 100644 --- a/mesh/appkey.h +++ b/mesh/appkey.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ /* TODO: get this number from configuration */ diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 2e5da863a..0009a1bee 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 6d73656a7..f47a42c60 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define CONFIG_SRV_MODEL SET_ID(SIG_VENDOR, 0x0000) diff --git a/mesh/crypto.c b/mesh/crypto.c index 70b96c51b..da227ebbb 100644 --- a/mesh/crypto.c +++ b/mesh/crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/crypto.h b/mesh/crypto.h index 7d3f89cde..2f31dc3de 100644 --- a/mesh/crypto.h +++ b/mesh/crypto.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include <stdbool.h> diff --git a/mesh/dbus.c b/mesh/dbus.c index 63ea420ed..a7abdc428 100644 --- a/mesh/dbus.c +++ b/mesh/dbus.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/dbus.h b/mesh/dbus.h index 89d6b1d31..8f00434d6 100644 --- a/mesh/dbus.h +++ b/mesh/dbus.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define BLUEZ_MESH_PATH "/org/bluez/mesh" diff --git a/mesh/error.h b/mesh/error.h index 2809915b0..6d9ccdb59 100644 --- a/mesh/error.h +++ b/mesh/error.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ /* diff --git a/mesh/friend.c b/mesh/friend.c index d27da9592..1e67704b8 100644 --- a/mesh/friend.c +++ b/mesh/friend.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/friend.h b/mesh/friend.h index 2351dee31..ba6053426 100644 --- a/mesh/friend.h +++ b/mesh/friend.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define OP_FRND_REQUEST 0x8040 diff --git a/mesh/keyring.c b/mesh/keyring.c index e8dd1e463..bbe501063 100644 --- a/mesh/keyring.c +++ b/mesh/keyring.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/keyring.h b/mesh/keyring.h index 2fab6b0dc..c2d38e9ff 100644 --- a/mesh/keyring.h +++ b/mesh/keyring.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct keyring_net_key { diff --git a/mesh/main.c b/mesh/main.c index 5a3cbf290..4356e3f65 100644 --- a/mesh/main.c +++ b/mesh/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2017-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/manager.c b/mesh/manager.c index 8ef681366..d70993e3b 100644 --- a/mesh/manager.c +++ b/mesh/manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/manager.h b/mesh/manager.h index 5a4c7d94a..a45a1f1c4 100644 --- a/mesh/manager.h +++ b/mesh/manager.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ bool manager_dbus_init(struct l_dbus *dbus); diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 30c90170d..ec9ecb786 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index 738cff9dd..420775829 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define MIN_COMP_SIZE 14 diff --git a/mesh/mesh-defs.h b/mesh/mesh-defs.h index 1a41e987b..43bdf5aab 100644 --- a/mesh/mesh-defs.h +++ b/mesh/mesh-defs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,17 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * */ #define MESH_AD_TYPE_PROVISION 0x29 diff --git a/mesh/mesh-io-api.h b/mesh/mesh-io-api.h index 7a5b49c60..61f79f224 100644 --- a/mesh/mesh-io-api.h +++ b/mesh/mesh-io-api.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_io_private; diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c index 67304d201..4eb7f27ce 100644 --- a/mesh/mesh-io-generic.c +++ b/mesh/mesh-io-generic.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-io-generic.h b/mesh/mesh-io-generic.h index 4bf4d5cb7..915e376bf 100644 --- a/mesh/mesh-io-generic.h +++ b/mesh/mesh-io-generic.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ extern const struct mesh_io_api mesh_io_generic; diff --git a/mesh/mesh-io.c b/mesh/mesh-io.c index c4eaecefd..62fc5d12e 100644 --- a/mesh/mesh-io.c +++ b/mesh/mesh-io.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-io.h b/mesh/mesh-io.h index fc0422020..b11c6c6e1 100644 --- a/mesh/mesh-io.h +++ b/mesh/mesh-io.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_io; diff --git a/mesh/mesh-mgmt.c b/mesh/mesh-mgmt.c index 2cf2ebac2..754093dbc 100644 --- a/mesh/mesh-mgmt.c +++ b/mesh/mesh-mgmt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 SILVAIR sp. z o.o. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh-mgmt.h b/mesh/mesh-mgmt.h index 93ad7995e..90ac14e73 100644 --- a/mesh/mesh-mgmt.h +++ b/mesh/mesh-mgmt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 SILVAIR sp. z o.o. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include <stdbool.h> diff --git a/mesh/mesh.c b/mesh/mesh.c index bc170371d..f29e8b6be 100644 --- a/mesh/mesh.c +++ b/mesh/mesh.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/mesh.h b/mesh/mesh.h index eb887723d..0f77ebc58 100644 --- a/mesh/mesh.h +++ b/mesh/mesh.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define BLUEZ_MESH_NAME "org.bluez.mesh" diff --git a/mesh/model.c b/mesh/model.c index 5716f5e22..c8eb8c607 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/model.h b/mesh/model.h index 2eec761a0..8df4f205f 100644 --- a/mesh/model.h +++ b/mesh/model.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_model; diff --git a/mesh/net-keys.c b/mesh/net-keys.c index 7dfabf922..e42cac70c 100644 --- a/mesh/net-keys.c +++ b/mesh/net-keys.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/net-keys.h b/mesh/net-keys.h index 4f480fcda..70b3d22c3 100644 --- a/mesh/net-keys.h +++ b/mesh/net-keys.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #define BEACON_TYPE_SNB 0x01 diff --git a/mesh/net.c b/mesh/net.c index 6c7311732..01a475d74 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/net.h b/mesh/net.h index 7bec6d0fc..4dbc94b8b 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifndef __packed diff --git a/mesh/node.c b/mesh/node.c index f7ac5ff67..76d8fd6e9 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2017-2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/node.h b/mesh/node.h index 7874b8692..30d53db33 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_net; diff --git a/mesh/pb-adv.c b/mesh/pb-adv.c index ae5b81391..c74dae79f 100644 --- a/mesh/pb-adv.c +++ b/mesh/pb-adv.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/pb-adv.h b/mesh/pb-adv.h index 80d53d234..5b1e03dae 100644 --- a/mesh/pb-adv.h +++ b/mesh/pb-adv.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ bool pb_adv_reg(bool initiator, mesh_prov_open_func_t open_cb, diff --git a/mesh/prov-acceptor.c b/mesh/prov-acceptor.c index 96f7e15ad..a03ee1ce5 100644 --- a/mesh/prov-acceptor.c +++ b/mesh/prov-acceptor.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/prov-initiator.c b/mesh/prov-initiator.c index 4de4df62d..8399282ee 100644 --- a/mesh/prov-initiator.c +++ b/mesh/prov-initiator.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/prov.h b/mesh/prov.h index 11b20b31f..99e864c50 100644 --- a/mesh/prov.h +++ b/mesh/prov.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifndef __packed diff --git a/mesh/provision.h b/mesh/provision.h index 1d78ed8e2..1a11b691b 100644 --- a/mesh/provision.h +++ b/mesh/provision.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ diff --git a/mesh/rpl.c b/mesh/rpl.c index 792c52ad6..7cea8e346 100644 --- a/mesh/rpl.c +++ b/mesh/rpl.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/rpl.h b/mesh/rpl.h index 2bbbdc9b9..9e988e7c5 100644 --- a/mesh/rpl.h +++ b/mesh/rpl.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ struct mesh_rpl { diff --git a/mesh/util.c b/mesh/util.c index 7d283331a..308e7d998 100644 --- a/mesh/util.c +++ b/mesh/util.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/mesh/util.h b/mesh/util.h index 93c2d8687..085ec3330 100644 --- a/mesh/util.h +++ b/mesh/util.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ uint32_t get_timestamp_secs(void); -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 0GLaKfkAaV96YAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:37:29 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id APDoJvkAaV8xRwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:37:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 42CEAA0B37; Mon, 21 Sep 2020 21:36:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727858AbgIUTgj (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:36:39 -0400 Received: from mga02.intel.com ([134.134.136.20]:55608 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727197AbgIUTgj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:36:39 -0400 IronPort-SDR: N+wZoC86PM11aBfIkKzlXWmwRTP1Ul2DLsALfdKA1OcJTFEqOpjH9kjHWUqxRDnPEw/r8qpMMx yVbSmrWLkjNA== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="148125169" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="148125169" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:36:26 -0700 IronPort-SDR: DtqzlWA3+KHF9rwKEji2CVFSuDMNireH6lNxQJvD2fJ8Kg3/EPp/6TBmYrs//HH3CpcXoWkRZk eQ+AgDjlM3kQ== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="309189074" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:36:25 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 16/20] src: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:36:20 -0700 Message-Id: <20200921193620.47219-1-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.10 / 15.00 / 15.00 X-Rspamd-Queue-Id: 42CEAA0B37 X-Rspamd-UID: 1cbbab From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 62 GPL-2.0-or-later : 51 BSD-2-Clause : 2 License: LGPL-2.1-or-later src/adv_monitor.c src/adv_monitor.h src/shared/mainloop-glib.c src/shared/btp.c src/shared/tester.c src/shared/btsnoop.c src/shared/gatt-helpers.h src/shared/log.h src/shared/util.h src/shared/mainloop-ell.c src/shared/hci-crypto.c src/shared/mainloop.c src/shared/hfp.h src/shared/mainloop-notify.c src/shared/io-mainloop.c src/shared/btsnoop.h src/shared/uhid.h src/shared/util.c src/shared/ringbuf.c src/shared/btp.h src/shared/shell.h src/shared/io-glib.c src/shared/queue.h src/shared/gatt-server.h src/shared/crypto.c src/shared/crypto.h src/shared/io-ell.c src/shared/timeout-glib.c src/shared/mgmt.c src/shared/gatt-db.c src/shared/mainloop-notify.h src/shared/hfp.c src/shared/timeout-ell.c src/shared/shell.c src/shared/hci.c src/shared/log.c src/shared/ringbuf.h src/shared/gatt-helpers.c src/shared/queue.c src/shared/tty.h src/shared/timeout-mainloop.c src/shared/tester.h src/shared/gap.h src/shared/mgmt.h src/shared/gatt-db.h src/shared/uhid.c src/shared/mainloop.h src/shared/timeout.h src/shared/att-types.h src/shared/pcap.c src/shared/gap.c src/shared/att.c src/shared/pcap.h src/shared/hci.h src/shared/gatt-client.h src/shared/io.h src/shared/gatt-client.c src/shared/ad.c src/shared/att.h src/shared/gatt-server.c src/shared/hci-crypto.h src/shared/ad.h License: GPL-2.0-or-later src/attrib-server.h src/advertising.h src/textfile.c src/attrib-server.c src/uinput.h src/log.h src/eir.h src/sdpd.h src/sdpd-request.c src/service.h src/sdpd-database.c src/adapter.h src/plugin.h src/uuid-helper.h src/plugin.c src/main.c src/sdp-xml.c src/error.h src/oui.c src/device.c src/agent.h src/sdp-client.c src/oui.h src/device.h src/gatt-database.c src/error.c src/backtrace.c src/sdpd-server.c src/adapter.c src/log.c src/agent.c src/backtrace.h src/sdp-xml.h src/hcid.h src/dbus-common.h src/uuid-helper.c src/storage.c src/profile.c src/advertising.c src/storage.h src/dbus-common.c src/profile.h src/sdpd-service.c src/eir.c src/sdp-client.h src/gatt-database.h src/gatt-client.h src/rfkill.c src/gatt-client.c src/service.c src/textfile.h License: BSD-2-Clause src/shared/ecc.h src/shared/ecc.c --- src/adapter.c | 15 +-------------- src/adapter.h | 15 +-------------- src/adv_monitor.c | 11 +---------- src/adv_monitor.h | 11 +---------- src/advertising.c | 11 +---------- src/advertising.h | 11 +---------- src/agent.c | 15 +-------------- src/agent.h | 15 +-------------- src/attrib-server.c | 15 +-------------- src/attrib-server.h | 15 +-------------- src/backtrace.c | 15 +-------------- src/backtrace.h | 15 +-------------- src/dbus-common.c | 15 +-------------- src/dbus-common.h | 15 +-------------- src/device.c | 15 +-------------- src/device.h | 15 +-------------- src/eir.c | 15 +-------------- src/eir.h | 15 +-------------- src/error.c | 15 +-------------- src/error.h | 15 +-------------- src/gatt-client.c | 11 +---------- src/gatt-client.h | 11 +---------- src/gatt-database.c | 11 +---------- src/gatt-database.h | 11 +---------- src/hcid.h | 15 +-------------- src/log.c | 15 +-------------- src/log.h | 15 +-------------- src/main.c | 15 +-------------- src/oui.c | 15 +-------------- src/oui.h | 15 +-------------- src/plugin.c | 15 +-------------- src/plugin.h | 15 +-------------- src/profile.c | 15 +-------------- src/profile.h | 15 +-------------- src/rfkill.c | 15 +-------------- src/sdp-client.c | 15 +-------------- src/sdp-client.h | 15 +-------------- src/sdp-xml.c | 15 +-------------- src/sdp-xml.h | 15 +-------------- src/sdpd-database.c | 15 +-------------- src/sdpd-request.c | 15 +-------------- src/sdpd-server.c | 15 +-------------- src/sdpd-service.c | 15 +-------------- src/sdpd.h | 15 +-------------- src/service.c | 15 +-------------- src/service.h | 15 +-------------- src/shared/ad.c | 15 +-------------- src/shared/ad.h | 15 +-------------- src/shared/att-types.h | 15 +-------------- src/shared/att.c | 15 +-------------- src/shared/att.h | 15 +-------------- src/shared/btp.c | 15 +-------------- src/shared/btp.h | 15 +-------------- src/shared/btsnoop.c | 15 +-------------- src/shared/btsnoop.h | 15 +-------------- src/shared/crypto.c | 15 +-------------- src/shared/crypto.h | 15 +-------------- src/shared/ecc.c | 21 +-------------------- src/shared/ecc.h | 21 +-------------------- src/shared/gap.c | 15 +-------------- src/shared/gap.h | 15 +-------------- src/shared/gatt-client.c | 15 +-------------- src/shared/gatt-client.h | 15 +-------------- src/shared/gatt-db.c | 15 +-------------- src/shared/gatt-db.h | 15 +-------------- src/shared/gatt-helpers.c | 15 +-------------- src/shared/gatt-helpers.h | 15 +-------------- src/shared/gatt-server.c | 15 +-------------- src/shared/gatt-server.h | 15 +-------------- src/shared/hci-crypto.c | 15 +-------------- src/shared/hci-crypto.h | 15 +-------------- src/shared/hci.c | 15 +-------------- src/shared/hci.h | 15 +-------------- src/shared/hfp.c | 15 +-------------- src/shared/hfp.h | 15 +-------------- src/shared/io-ell.c | 15 +-------------- src/shared/io-glib.c | 15 +-------------- src/shared/io-mainloop.c | 15 +-------------- src/shared/io.h | 15 +-------------- src/shared/log.c | 15 +-------------- src/shared/log.h | 15 +-------------- src/shared/mainloop-ell.c | 12 +----------- src/shared/mainloop-glib.c | 15 +-------------- src/shared/mainloop-notify.c | 15 +-------------- src/shared/mainloop-notify.h | 15 +-------------- src/shared/mainloop.c | 15 +-------------- src/shared/mainloop.h | 15 +-------------- src/shared/mgmt.c | 15 +-------------- src/shared/mgmt.h | 15 +-------------- src/shared/pcap.c | 15 +-------------- src/shared/pcap.h | 15 +-------------- src/shared/queue.c | 15 +-------------- src/shared/queue.h | 15 +-------------- src/shared/ringbuf.c | 15 +-------------- src/shared/ringbuf.h | 15 +-------------- src/shared/shell.c | 15 +-------------- src/shared/shell.h | 15 +-------------- src/shared/tester.c | 15 +-------------- src/shared/tester.h | 15 +-------------- src/shared/timeout-ell.c | 11 +---------- src/shared/timeout-glib.c | 11 +---------- src/shared/timeout-mainloop.c | 11 +---------- src/shared/timeout.h | 11 +---------- src/shared/tty.h | 15 +-------------- src/shared/uhid.c | 15 +-------------- src/shared/uhid.h | 15 +-------------- src/shared/util.c | 15 +-------------- src/shared/util.h | 15 +-------------- src/storage.c | 15 +-------------- src/storage.h | 15 +-------------- src/textfile.c | 15 +-------------- src/textfile.h | 15 +-------------- src/uinput.h | 15 +-------------- src/uuid-helper.c | 15 +-------------- src/uuid-helper.h | 15 +-------------- 115 files changed, 115 insertions(+), 1571 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index b2bd8b3f1..c0053000a 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/adapter.h b/src/adapter.h index b4d872b15..dcc574857 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 737da1c90..e441a5566 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Google LLC * * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/src/adv_monitor.h b/src/adv_monitor.h index 69ea348f8..5cb372217 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2020 Google LLC * * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #ifndef __ADV_MONITOR_H diff --git a/src/advertising.c b/src/advertising.c index e5f25948d..c03869e50 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2015 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/src/advertising.h b/src/advertising.h index 50d86674b..0e31a277b 100644 --- a/src/advertising.h +++ b/src/advertising.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2015 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ struct btd_adapter; diff --git a/src/agent.c b/src/agent.c index e0ffcd22f..770a63838 100644 --- a/src/agent.c +++ b/src/agent.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/agent.h b/src/agent.h index 1438b9e6d..bd0502030 100644 --- a/src/agent.h +++ b/src/agent.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define IO_CAPABILITY_DISPLAYONLY 0x00 diff --git a/src/attrib-server.c b/src/attrib-server.c index 7c15a4e8f..91a10b274 100644 --- a/src/attrib-server.c +++ b/src/attrib-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/attrib-server.h b/src/attrib-server.h index 063cb6621..7cdbe3b96 100644 --- a/src/attrib-server.h +++ b/src/attrib-server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ uint16_t attrib_db_find_avail(struct btd_adapter *adapter, bt_uuid_t *svc_uuid, diff --git a/src/backtrace.c b/src/backtrace.c index c43873354..50f71e88a 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/backtrace.h b/src/backtrace.h index b3eef6dd9..d6a1dab5b 100644 --- a/src/backtrace.h +++ b/src/backtrace.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/src/dbus-common.c b/src/dbus-common.c index 6e2097a2d..384f27700 100644 --- a/src/dbus-common.c +++ b/src/dbus-common.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2005-2007 Johan Hedberg <johan.hedberg@nokia.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/dbus-common.h b/src/dbus-common.h index fbf4acd28..11c64cc77 100644 --- a/src/dbus-common.h +++ b/src/dbus-common.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void dict_append_entry(DBusMessageIter *dict, diff --git a/src/device.c b/src/device.c index 3e7784034..a4b5968d4 100644 --- a/src/device.c +++ b/src/device.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/device.h b/src/device.h index 3cd090786..4ae9abe0d 100644 --- a/src/device.h +++ b/src/device.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define DEVICE_INTERFACE "org.bluez.Device1" diff --git a/src/eir.c b/src/eir.c index fa52a2bd8..0f5d14fcd 100644 --- a/src/eir.c +++ b/src/eir.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/eir.h b/src/eir.h index c868177a6..6154e23ec 100644 --- a/src/eir.h +++ b/src/eir.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <glib.h> diff --git a/src/error.c b/src/error.c index 89517075e..dd85cd288 100644 --- a/src/error.c +++ b/src/error.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2007-2008 Fabien Chevalier <fabchevalier@free.fr> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/error.h b/src/error.h index 7c8cad066..7fcddaf4a 100644 --- a/src/error.h +++ b/src/error.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2007-2008 Fabien Chevalier <fabchevalier@free.fr> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <dbus/dbus.h> diff --git a/src/gatt-client.c b/src/gatt-client.c index c706307c7..38b0b5170 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2014 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/src/gatt-client.h b/src/gatt-client.h index 92a925546..b6539207e 100644 --- a/src/gatt-client.h +++ b/src/gatt-client.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2014 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ struct btd_gatt_client; diff --git a/src/gatt-database.c b/src/gatt-database.c index e7e4a36a6..2b22add88 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2015 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifdef HAVE_CONFIG_H diff --git a/src/gatt-database.h b/src/gatt-database.h index 154d3243f..30ae68e7e 100644 --- a/src/gatt-database.h +++ b/src/gatt-database.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2015 Google Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ struct btd_gatt_database; diff --git a/src/hcid.h b/src/hcid.h index 3624ba6ea..95d4b9665 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef enum { diff --git a/src/log.c b/src/log.c index a42c5941d..0155a6bba 100644 --- a/src/log.c +++ b/src/log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/log.h b/src/log.h index e83431151..74941beb2 100644 --- a/src/log.h +++ b/src/log.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/src/main.c b/src/main.c index 038f867b5..77be77668 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/oui.c b/src/oui.c index 8059c0a89..c434f416f 100644 --- a/src/oui.c +++ b/src/oui.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/oui.h b/src/oui.h index 2ddc27fef..bde933f4c 100644 --- a/src/oui.h +++ b/src/oui.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ char *batocomp(const bdaddr_t *ba); diff --git a/src/plugin.c b/src/plugin.c index 39310a7db..6fe394f5f 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/plugin.h b/src/plugin.h index 89c7b8515..a5f92a557 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define BLUETOOTH_PLUGIN_PRIORITY_LOW -100 #define BLUETOOTH_PLUGIN_PRIORITY_DEFAULT 0 diff --git a/src/profile.c b/src/profile.c index 6961a107b..5e460b639 100644 --- a/src/profile.c +++ b/src/profile.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/profile.h b/src/profile.h index 95523e50a..6827f8481 100644 --- a/src/profile.h +++ b/src/profile.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define BTD_PROFILE_PRIORITY_LOW 0 diff --git a/src/rfkill.c b/src/rfkill.c index fb2d11306..6309a7768 100644 --- a/src/rfkill.c +++ b/src/rfkill.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/sdp-client.c b/src/sdp-client.c index b92a083af..55f5bc323 100644 --- a/src/sdp-client.c +++ b/src/sdp-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/sdp-client.h b/src/sdp-client.h index 3a7212fd2..9ad182e37 100644 --- a/src/sdp-client.h +++ b/src/sdp-client.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef void (*bt_callback_t) (sdp_list_t *recs, int err, gpointer user_data); diff --git a/src/sdp-xml.c b/src/sdp-xml.c index 6f831737d..5efa62ab8 100644 --- a/src/sdp-xml.c +++ b/src/sdp-xml.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2005-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/sdp-xml.h b/src/sdp-xml.h index 80a4f446d..d9cdbccc4 100644 --- a/src/sdp-xml.h +++ b/src/sdp-xml.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2005-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void convert_sdp_record_to_xml(sdp_record_t *rec, diff --git a/src/sdpd-database.c b/src/sdpd-database.c index 843b6d02b..35617abec 100644 --- a/src/sdpd-database.c +++ b/src/sdpd-database.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/sdpd-request.c b/src/sdpd-request.c index deaed266f..033d1e5bf 100644 --- a/src/sdpd-request.c +++ b/src/sdpd-request.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/sdpd-server.c b/src/sdpd-server.c index ef35309ce..dfd8b1f00 100644 --- a/src/sdpd-server.c +++ b/src/sdpd-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/sdpd-service.c b/src/sdpd-service.c index c3ee3eb48..012438558 100644 --- a/src/sdpd-service.c +++ b/src/sdpd-service.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/sdpd.h b/src/sdpd.h index 49cd98a2b..257411f03 100644 --- a/src/sdpd.h +++ b/src/sdpd.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -8,20 +9,6 @@ * Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef SDP_DEBUG diff --git a/src/service.c b/src/service.c index e4d747a6e..d810fc3b0 100644 --- a/src/service.c +++ b/src/service.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2013 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/service.h b/src/service.h index 6f1edfb8f..88530cc17 100644 --- a/src/service.h +++ b/src/service.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2013 BMW Car IT GmbH. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef enum { diff --git a/src/shared/ad.c b/src/shared/ad.c index 14a2709b1..a34d7a147 100644 --- a/src/shared/ad.c +++ b/src/shared/ad.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Google Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/ad.h b/src/shared/ad.h index 17e3b631b..83eacab66 100644 --- a/src/shared/ad.h +++ b/src/shared/ad.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2015 Google Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <inttypes.h> diff --git a/src/shared/att-types.h b/src/shared/att-types.h index 99b108990..7108b4e94 100644 --- a/src/shared/att-types.h +++ b/src/shared/att-types.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Google Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/src/shared/att.c b/src/shared/att.c index 58f23dfcb..429ba6696 100644 --- a/src/shared/att.c +++ b/src/shared/att.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Google Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/att.h b/src/shared/att.h index ed20bb5b8..1938fc724 100644 --- a/src/shared/att.h +++ b/src/shared/att.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Google Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/btp.c b/src/shared/btp.c index 7eea241a2..e54eb830f 100644 --- a/src/shared/btp.c +++ b/src/shared/btp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/btp.h b/src/shared/btp.h index cc71a71df..a99fdf075 100644 --- a/src/shared/btp.h +++ b/src/shared/btp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/btsnoop.c b/src/shared/btsnoop.c index f0d074743..e2b3747e3 100644 --- a/src/shared/btsnoop.c +++ b/src/shared/btsnoop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/btsnoop.h b/src/shared/btsnoop.h index 5fb084aa2..80f0d5d82 100644 --- a/src/shared/btsnoop.h +++ b/src/shared/btsnoop.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/src/shared/crypto.c b/src/shared/crypto.c index 5cc88ce4a..6d14903e4 100644 --- a/src/shared/crypto.c +++ b/src/shared/crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/crypto.h b/src/shared/crypto.h index d17daa835..356326d75 100644 --- a/src/shared/crypto.h +++ b/src/shared/crypto.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/ecc.c b/src/shared/ecc.c index 1b45e0d0a..adaae2082 100644 --- a/src/shared/ecc.c +++ b/src/shared/ecc.c @@ -1,27 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause /* * Copyright (c) 2013, Kenneth MacKay * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/ecc.h b/src/shared/ecc.h index 8c15e4ee8..5d7b25d75 100644 --- a/src/shared/ecc.h +++ b/src/shared/ecc.h @@ -1,27 +1,8 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ /* * Copyright (c) 2013, Kenneth MacKay * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdbool.h> diff --git a/src/shared/gap.c b/src/shared/gap.c index 0b8d073c5..6fb1b7b69 100644 --- a/src/shared/gap.c +++ b/src/shared/gap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/gap.h b/src/shared/gap.h index 52c264a8e..4a75d26e4 100644 --- a/src/shared/gap.h +++ b/src/shared/gap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index f15466673..8becf1c6c 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Google Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/gatt-client.h b/src/shared/gatt-client.h index 10900168b..dc5102394 100644 --- a/src/shared/gatt-client.h +++ b/src/shared/gatt-client.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Google Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index e939ddc3a..54e64d0e0 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h index 5bf19d302..a0da33065 100644 --- a/src/shared/gatt-db.h +++ b/src/shared/gatt-db.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct gatt_db; diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c index 6b39bb161..50fcb269b 100644 --- a/src/shared/gatt-helpers.c +++ b/src/shared/gatt-helpers.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Google Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ diff --git a/src/shared/gatt-helpers.h b/src/shared/gatt-helpers.h index dd9dd1c44..7623862e9 100644 --- a/src/shared/gatt-helpers.h +++ b/src/shared/gatt-helpers.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Google Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ /* This file defines helpers for performing client-side procedures defined by diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c index 28ac2d68d..0ce994be3 100644 --- a/src/shared/gatt-server.c +++ b/src/shared/gatt-server.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Google Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/gatt-server.h b/src/shared/gatt-server.h index a2492d275..de98a0d04 100644 --- a/src/shared/gatt-server.h +++ b/src/shared/gatt-server.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Google Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/src/shared/hci-crypto.c b/src/shared/hci-crypto.c index f7507472b..5e6dd3e20 100644 --- a/src/shared/hci-crypto.c +++ b/src/shared/hci-crypto.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/hci-crypto.h b/src/shared/hci-crypto.h index b090c2410..d10812bdc 100644 --- a/src/shared/hci-crypto.h +++ b/src/shared/hci-crypto.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/hci.c b/src/shared/hci.c index 262e93d5a..f741a2bf5 100644 --- a/src/shared/hci.c +++ b/src/shared/hci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/hci.h b/src/shared/hci.h index dba0f11db..9298442e5 100644 --- a/src/shared/hci.h +++ b/src/shared/hci.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/hfp.c b/src/shared/hfp.c index f4747b4ca..f41c70dfe 100644 --- a/src/shared/hfp.c +++ b/src/shared/hfp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/hfp.h b/src/shared/hfp.h index 2eb783849..1fb3ee8d3 100644 --- a/src/shared/hfp.h +++ b/src/shared/hfp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/io-ell.c b/src/shared/io-ell.c index 6748982c7..c4a115478 100644 --- a/src/shared/io-ell.c +++ b/src/shared/io-ell.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/io-glib.c b/src/shared/io-glib.c index d62de4e10..754043db1 100644 --- a/src/shared/io-glib.c +++ b/src/shared/io-glib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/io-mainloop.c b/src/shared/io-mainloop.c index 2306c3479..ad461843c 100644 --- a/src/shared/io-mainloop.c +++ b/src/shared/io-mainloop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/io.h b/src/shared/io.h index 8bc1111d0..bad899ff7 100644 --- a/src/shared/io.h +++ b/src/shared/io.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/log.c b/src/shared/log.c index 7c8b71220..3f18e803d 100644 --- a/src/shared/log.c +++ b/src/shared/log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/log.h b/src/shared/log.h index c72ab735b..4a8bd4b6e 100644 --- a/src/shared/log.h +++ b/src/shared/log.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int bt_log_open(void); diff --git a/src/shared/mainloop-ell.c b/src/shared/mainloop-ell.c index 63e254ac6..5cc0311c2 100644 --- a/src/shared/mainloop-ell.c +++ b/src/shared/mainloop-ell.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,17 +6,6 @@ * Copyright (C) 2019 Intel Corporation * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/mainloop-glib.c b/src/shared/mainloop-glib.c index 2508a1fb2..7d4b057bf 100644 --- a/src/shared/mainloop-glib.c +++ b/src/shared/mainloop-glib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2018 Intel Corporation * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/mainloop-notify.c b/src/shared/mainloop-notify.c index 1de714a0e..33be3cf8d 100644 --- a/src/shared/mainloop-notify.c +++ b/src/shared/mainloop-notify.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/mainloop-notify.h b/src/shared/mainloop-notify.h index 721b5fbed..c2cf34c44 100644 --- a/src/shared/mainloop-notify.h +++ b/src/shared/mainloop-notify.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2018 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ void mainloop_notify_init(void); diff --git a/src/shared/mainloop.c b/src/shared/mainloop.c index 8a8e2c022..b71707cae 100644 --- a/src/shared/mainloop.c +++ b/src/shared/mainloop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/mainloop.h b/src/shared/mainloop.h index 1ede62797..fb02dd341 100644 --- a/src/shared/mainloop.h +++ b/src/shared/mainloop.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <signal.h> diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c index 277e361a6..b327b4088 100644 --- a/src/shared/mgmt.c +++ b/src/shared/mgmt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h index 7caeb3844..6608faa7e 100644 --- a/src/shared/mgmt.h +++ b/src/shared/mgmt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/pcap.c b/src/shared/pcap.c index 0d887e24c..2596a498e 100644 --- a/src/shared/pcap.c +++ b/src/shared/pcap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/pcap.h b/src/shared/pcap.h index b47de62e8..936c3b145 100644 --- a/src/shared/pcap.h +++ b/src/shared/pcap.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/src/shared/queue.c b/src/shared/queue.c index 60df11143..0b53b5b79 100644 --- a/src/shared/queue.c +++ b/src/shared/queue.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/queue.h b/src/shared/queue.h index 8cd817cc0..122f4eaa6 100644 --- a/src/shared/queue.h +++ b/src/shared/queue.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/ringbuf.c b/src/shared/ringbuf.c index 8cf0b5b19..3dc7ed71b 100644 --- a/src/shared/ringbuf.c +++ b/src/shared/ringbuf.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/ringbuf.h b/src/shared/ringbuf.h index adf471a43..ee30ff430 100644 --- a/src/shared/ringbuf.h +++ b/src/shared/ringbuf.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdlib.h> diff --git a/src/shared/shell.c b/src/shared/shell.c index d58e2d7d1..c0de1640d 100644 --- a/src/shared/shell.c +++ b/src/shared/shell.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/shell.h b/src/shared/shell.h index e14d58381..415194a40 100644 --- a/src/shared/shell.h +++ b/src/shared/shell.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2017 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <getopt.h> diff --git a/src/shared/tester.c b/src/shared/tester.c index 62e5c1aae..bd42c8bad 100644 --- a/src/shared/tester.c +++ b/src/shared/tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/tester.h b/src/shared/tester.h index 96e8dc901..a304d89fe 100644 --- a/src/shared/tester.h +++ b/src/shared/tester.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/timeout-ell.c b/src/shared/timeout-ell.c index 8419d4617..c2da387e2 100644 --- a/src/shared/timeout-ell.c +++ b/src/shared/timeout-ell.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include <ell/ell.h> diff --git a/src/shared/timeout-glib.c b/src/shared/timeout-glib.c index fd71ca430..8bdb7a662 100644 --- a/src/shared/timeout-glib.c +++ b/src/shared/timeout-glib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include "timeout.h" diff --git a/src/shared/timeout-mainloop.c b/src/shared/timeout-mainloop.c index 971124a2e..5ffa65c2a 100644 --- a/src/shared/timeout-mainloop.c +++ b/src/shared/timeout-mainloop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include <stdlib.h> diff --git a/src/shared/timeout.h b/src/shared/timeout.h index 4930ce162..7e22345dd 100644 --- a/src/shared/timeout.h +++ b/src/shared/timeout.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,16 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * */ #include <stdbool.h> diff --git a/src/shared/tty.h b/src/shared/tty.h index 66ec09f31..3392f9ba6 100644 --- a/src/shared/tty.h +++ b/src/shared/tty.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2016 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <termios.h> diff --git a/src/shared/uhid.c b/src/shared/uhid.c index 71a4e04ba..1f15443cd 100644 --- a/src/shared/uhid.c +++ b/src/shared/uhid.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/uhid.h b/src/shared/uhid.h index dbdca852d..839809d9a 100644 --- a/src/shared/uhid.h +++ b/src/shared/uhid.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdbool.h> diff --git a/src/shared/util.c b/src/shared/util.c index 4ecf31a03..525302164 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/shared/util.h b/src/shared/util.h index 9193068d1..8a920bc12 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <stdint.h> diff --git a/src/storage.c b/src/storage.c index 8cbb5b270..d819c2c1e 100644 --- a/src/storage.c +++ b/src/storage.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/storage.h b/src/storage.h index 1c0ad57ec..011916671 100644 --- a/src/storage.h +++ b/src/storage.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int read_discoverable_timeout(const char *src, int *timeout); diff --git a/src/textfile.c b/src/textfile.c index 371651bd8..7dd62392b 100644 --- a/src/textfile.c +++ b/src/textfile.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/textfile.h b/src/textfile.h index f01629e43..b4e2e0248 100644 --- a/src/textfile.h +++ b/src/textfile.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ int create_file(const char *filename, const mode_t mode); diff --git a/src/uinput.h b/src/uinput.h index 20e0941d1..75d791bc6 100644 --- a/src/uinput.h +++ b/src/uinput.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef __UINPUT_H diff --git a/src/uuid-helper.c b/src/uuid-helper.c index 2c897d86c..b62b1af82 100644 --- a/src/uuid-helper.c +++ b/src/uuid-helper.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/src/uuid-helper.h b/src/uuid-helper.h index c0d7f9eec..0b99098c8 100644 --- a/src/uuid-helper.h +++ b/src/uuid-helper.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ char *bt_modalias(uint16_t source, uint16_t vendor, -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id mHRzB2EBaV96YAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:39:13 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id CF14BGEBaV+VygAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:39:13 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5A3D1A0218; Mon, 21 Sep 2020 21:38:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727807AbgIUTiX (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:38:23 -0400 Received: from mga07.intel.com ([134.134.136.100]:24989 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726471AbgIUTiW (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:38:22 -0400 IronPort-SDR: REE8uOCoeTEfYthlGto3MyooTezWA+O7pckm2+kppdybE6t3P0rIdb2mlzvpOqRp/AOPsnnABa EHg3ndF0p6Zw== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="224613218" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="224613218" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:38:07 -0700 IronPort-SDR: 1IBt7ZlBeSGoO0XmUJ5TPh1MgTsOOx8UsyRbcI1Iaf1XEsC/mA1mJU3bFh0Xocjer8/L40KvLt DBOqCZ8+zqLg== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="309189383" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:38:06 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 01/20] android: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:37:46 -0700 Message-Id: <20200921193745.47422-1-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5A3D1A0218 X-Rspamd-UID: 9e7448 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- Apache-2.0 : 80 LGPL-2.1-or-later : 42 GPL-2.0-or-later : 9 License: Apache-2.0 android/bluetoothd-wrapper.c android/tester-hidhost.c android/tester-map-client.c android/hal-audio-aptx.c android/hal-audio.c android/hal-handsfree-client.c android/tester-gatt.c android/hal-pan.c android/hal-socket.c android/tester-hdp.c android/tester-pan.c android/tester-avrcp.c android/hal-a2dp-sink.c android/hal-gatt.c android/hal-avrcp.c android/tester-a2dp.c android/hal-audio.h android/hal-bluetooth.c android/tester-socket.c android/hal-health.c android/hal-a2dp.c android/hal-ipc.c android/hal-avrcp-ctrl.c android/hal-sco.c android/hal-ipc.h android/tester-main.c android/hal-audio-sbc.c android/hal-utils.c android/hal-map-client.c android/hal-handsfree.c android/hal-log.h android/hal.h android/hal-utils.h android/tester-bluetooth.c android/hal-hidhost.c android/audio_utils/resampler.h android/audio_utils/resampler.c android/system/audio.h android/hardware/bt_sock.h android/hardware/bt_gatt_client.h android/hardware/bt_hh.h android/hardware/bluetooth.h android/hardware/hardware.h android/hardware/bt_hf_client.h android/hardware/bt_rc.h android/hardware/bt_hf.h android/hardware/bt_pan.h android/hardware/bt_gatt_types.h android/hardware/hardware.c android/hardware/audio_effect.h android/hardware/audio.h android/hardware/bt_gatt_server.h android/hardware/bt_gatt.h android/hardware/bt_hl.h android/hardware/bt_mce.h android/hardware/bt_av.h android/client/if-hh.c android/client/if-sco.c android/client/pollhandler.h android/client/haltest.c android/client/tabcompletion.c android/client/if-hf-client.c android/client/history.h android/client/if-audio.c android/client/terminal.h android/client/if-av.c android/client/if-main.h android/client/if-av-sink.c android/client/terminal.c android/client/if-mce.c android/client/if-hf.c android/client/pollhandler.c android/client/if-sock.c android/client/if-rc-ctrl.c android/client/if-rc.c android/client/history.c android/client/if-pan.c android/client/if-gatt.c android/client/if-bt.c android/client/if-hl.c License: LGPL-2.1-or-later android/sco.h android/socket.c android/tester-main.h android/hidhost.h android/map-client.h android/utils.h android/hal-msg.h android/health.h android/avrcp-lib.c android/bluetoothd-snoop.c android/a2dp.c android/bluetooth.h android/a2dp-sink.c android/handsfree-client.c android/audio-msg.h android/main.c android/pan.c android/ipc-tester.c android/health.c android/socket.h android/handsfree.h android/avrcp-lib.h android/a2dp-sink.h android/system-emulator.c android/gatt.c android/avrcp.h android/pan.h android/test-ipc.c android/hidhost.c android/a2dp.h android/avrcp.c android/sco-msg.h android/bluetooth.c android/map-client.c android/handsfree-client.h android/ipc.c android/handsfree.c android/gatt.h android/ipc.h android/ipc-common.h android/compat/wordexp.h android/cutils/properties.h License: GPL-2.0-or-later android/avdtp.h android/avctp.c android/avdtptest.c android/sco.c android/log.c android/avdtp.c android/avctp.h android/compat/readline/history.h android/compat/readline/readline.h --- android/a2dp-sink.c | 15 +-------------- android/a2dp-sink.h | 15 +-------------- android/a2dp.c | 15 +-------------- android/a2dp.h | 15 +-------------- android/audio-msg.h | 15 +-------------- android/audio_utils/resampler.c | 12 +----------- android/audio_utils/resampler.h | 12 +----------- android/avctp.c | 15 +-------------- android/avctp.h | 15 +-------------- android/avdtp.c | 15 +-------------- android/avdtp.h | 15 +-------------- android/avdtptest.c | 15 +-------------- android/avrcp-lib.c | 15 +-------------- android/avrcp-lib.h | 15 +-------------- android/avrcp.c | 15 +-------------- android/avrcp.h | 15 +-------------- android/bluetooth.c | 15 +-------------- android/bluetooth.h | 15 +-------------- android/bluetoothd-snoop.c | 15 +-------------- android/bluetoothd-wrapper.c | 13 +------------ android/client/haltest.c | 13 +------------ android/client/history.c | 13 +------------ android/client/history.h | 13 +------------ android/client/if-audio.c | 13 +------------ android/client/if-av-sink.c | 13 +------------ android/client/if-av.c | 13 +------------ android/client/if-bt.c | 13 +------------ android/client/if-gatt.c | 13 +------------ android/client/if-hf-client.c | 13 +------------ android/client/if-hf.c | 13 +------------ android/client/if-hh.c | 13 +------------ android/client/if-hl.c | 13 +------------ android/client/if-main.h | 13 +------------ android/client/if-mce.c | 13 +------------ android/client/if-pan.c | 13 +------------ android/client/if-rc-ctrl.c | 13 +------------ android/client/if-rc.c | 13 +------------ android/client/if-sco.c | 13 +------------ android/client/if-sock.c | 13 +------------ android/client/pollhandler.c | 13 +------------ android/client/pollhandler.h | 13 +------------ android/client/tabcompletion.c | 13 +------------ android/client/terminal.c | 13 +------------ android/client/terminal.h | 13 +------------ android/compat/readline/history.h | 15 +-------------- android/compat/readline/readline.h | 15 +-------------- android/compat/wordexp.h | 15 +-------------- android/cutils/properties.h | 15 +-------------- android/gatt.c | 15 +-------------- android/gatt.h | 15 +-------------- android/hal-a2dp-sink.c | 13 +------------ android/hal-a2dp.c | 13 +------------ android/hal-audio-aptx.c | 13 +------------ android/hal-audio-sbc.c | 13 +------------ android/hal-audio.c | 13 +------------ android/hal-audio.h | 13 +------------ android/hal-avrcp-ctrl.c | 13 +------------ android/hal-avrcp.c | 13 +------------ android/hal-bluetooth.c | 13 +------------ android/hal-gatt.c | 13 +------------ android/hal-handsfree-client.c | 13 +------------ android/hal-handsfree.c | 13 +------------ android/hal-health.c | 13 +------------ android/hal-hidhost.c | 13 +------------ android/hal-ipc.c | 13 +------------ android/hal-ipc.h | 13 +------------ android/hal-log.h | 13 +------------ android/hal-map-client.c | 13 +------------ android/hal-msg.h | 15 +-------------- android/hal-pan.c | 13 +------------ android/hal-sco.c | 13 +------------ android/hal-socket.c | 13 +------------ android/hal-utils.c | 13 +------------ android/hal-utils.h | 13 +------------ android/hal.h | 13 +------------ android/handsfree-client.c | 15 +-------------- android/handsfree-client.h | 15 +-------------- android/handsfree.c | 15 +-------------- android/handsfree.h | 15 +-------------- android/hardware/audio.h | 12 +----------- android/hardware/audio_effect.h | 12 +----------- android/hardware/bluetooth.h | 12 +----------- android/hardware/bt_av.h | 12 +----------- android/hardware/bt_gatt.h | 12 +----------- android/hardware/bt_gatt_client.h | 12 +----------- android/hardware/bt_gatt_server.h | 12 +----------- android/hardware/bt_gatt_types.h | 12 +----------- android/hardware/bt_hf.h | 12 +----------- android/hardware/bt_hf_client.h | 12 +----------- android/hardware/bt_hh.h | 12 +----------- android/hardware/bt_hl.h | 12 +----------- android/hardware/bt_mce.h | 12 +----------- android/hardware/bt_pan.h | 12 +----------- android/hardware/bt_rc.h | 12 +----------- android/hardware/bt_sock.h | 12 +----------- android/hardware/hardware.c | 12 +----------- android/hardware/hardware.h | 12 +----------- android/health.c | 15 +-------------- android/health.h | 15 +-------------- android/hidhost.c | 15 +-------------- android/hidhost.h | 15 +-------------- android/ipc-common.h | 15 +-------------- android/ipc-tester.c | 15 +-------------- android/ipc.c | 15 +-------------- android/ipc.h | 15 +-------------- android/log.c | 15 +-------------- android/main.c | 15 +-------------- android/map-client.c | 15 +-------------- android/map-client.h | 15 +-------------- android/pan.c | 15 +-------------- android/pan.h | 15 +-------------- android/sco-msg.h | 15 +-------------- android/sco.c | 15 +-------------- android/sco.h | 15 +-------------- android/socket.c | 15 +-------------- android/socket.h | 15 +-------------- android/system-emulator.c | 15 +-------------- android/system/audio.h | 12 +----------- android/test-ipc.c | 15 +-------------- android/tester-a2dp.c | 13 +------------ android/tester-avrcp.c | 13 +------------ android/tester-bluetooth.c | 13 +------------ android/tester-gatt.c | 13 +------------ android/tester-hdp.c | 13 +------------ android/tester-hidhost.c | 13 +------------ android/tester-main.c | 13 +------------ android/tester-main.h | 15 +-------------- android/tester-map-client.c | 13 +------------ android/tester-pan.c | 13 +------------ android/tester-socket.c | 13 +------------ android/utils.h | 15 +-------------- 131 files changed, 131 insertions(+), 1653 deletions(-) diff --git a/android/a2dp-sink.c b/android/a2dp-sink.c index 7c1e1a03a..0ecb5c392 100644 --- a/android/a2dp-sink.c +++ b/android/a2dp-sink.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/a2dp-sink.h b/android/a2dp-sink.h index d2c5ff423..f6da58627 100644 --- a/android/a2dp-sink.h +++ b/android/a2dp-sink.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool bt_a2dp_sink_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode); diff --git a/android/a2dp.c b/android/a2dp.c index 8bcdfd20f..e24f79348 100644 --- a/android/a2dp.c +++ b/android/a2dp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/a2dp.h b/android/a2dp.h index 8a7040736..f99779657 100644 --- a/android/a2dp.h +++ b/android/a2dp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool bt_a2dp_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode); diff --git a/android/audio-msg.h b/android/audio-msg.h index 7b9553ba3..9a7f78bac 100644 --- a/android/audio-msg.h +++ b/android/audio-msg.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define BLUEZ_AUDIO_MTU 1024 diff --git a/android/audio_utils/resampler.c b/android/audio_utils/resampler.c index ce303750c..c55e910fb 100644 --- a/android/audio_utils/resampler.c +++ b/android/audio_utils/resampler.c @@ -1,17 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* ** Copyright 2011, The Android Open-Source Project ** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. */ //#define LOG_NDEBUG 0 diff --git a/android/audio_utils/resampler.h b/android/audio_utils/resampler.h index 0c7046f51..4ceb3485a 100644 --- a/android/audio_utils/resampler.h +++ b/android/audio_utils/resampler.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* ** Copyright 2008, The Android Open-Source Project ** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. */ #ifndef ANDROID_RESAMPLER_H diff --git a/android/avctp.c b/android/avctp.c index 6aa64cf02..c2ea5f4a2 100644 --- a/android/avctp.c +++ b/android/avctp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -7,20 +8,6 @@ * Copyright (C) 2011 Texas Instruments, Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/avctp.h b/android/avctp.h index f0da2b33c..e82e024f1 100644 --- a/android/avctp.h +++ b/android/avctp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define AVCTP_CONTROL_PSM 23 diff --git a/android/avdtp.c b/android/avdtp.c index 7fb8cb731..8c2930ec1 100644 --- a/android/avdtp.c +++ b/android/avdtp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/avdtp.h b/android/avdtp.h index 07516a87c..f45edaead 100644 --- a/android/avdtp.h +++ b/android/avdtp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct avdtp; diff --git a/android/avdtptest.c b/android/avdtptest.c index 98b9ef0fa..e6668bc3c 100644 --- a/android/avdtptest.c +++ b/android/avdtptest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c index 21d01955d..2007d09d2 100644 --- a/android/avrcp-lib.c +++ b/android/avrcp-lib.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h index 6554b122d..5adb32188 100644 --- a/android/avrcp-lib.h +++ b/android/avrcp-lib.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ /* Control PDU ids */ diff --git a/android/avrcp.c b/android/avrcp.c index f4b138bab..fe092f02d 100644 --- a/android/avrcp.c +++ b/android/avrcp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/avrcp.h b/android/avrcp.h index 11e79b7d7..474413b7c 100644 --- a/android/avrcp.h +++ b/android/avrcp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool bt_avrcp_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode); diff --git a/android/bluetooth.c b/android/bluetooth.c index fb027bf34..c3ad50349 100644 --- a/android/bluetooth.c +++ b/android/bluetooth.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/bluetooth.h b/android/bluetooth.h index b139cb15f..13a3f2936 100644 --- a/android/bluetooth.h +++ b/android/bluetooth.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ typedef void (*bt_bluetooth_ready)(int err, const bdaddr_t *addr); diff --git a/android/bluetoothd-snoop.c b/android/bluetoothd-snoop.c index 25cddee34..0321e69bc 100644 --- a/android/bluetoothd-snoop.c +++ b/android/bluetoothd-snoop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/bluetoothd-wrapper.c b/android/bluetoothd-wrapper.c index 7f668daca..8929df075 100644 --- a/android/bluetoothd-wrapper.c +++ b/android/bluetoothd-wrapper.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdio.h> diff --git a/android/client/haltest.c b/android/client/haltest.c index e9a92a29a..cb5f68833 100644 --- a/android/client/haltest.c +++ b/android/client/haltest.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #ifdef HAVE_CONFIG_H diff --git a/android/client/history.c b/android/client/history.c index ca4664cfe..1bc26e3cd 100644 --- a/android/client/history.c +++ b/android/client/history.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdlib.h> diff --git a/android/client/history.h b/android/client/history.h index 26085b511..b95c69822 100644 --- a/android/client/history.h +++ b/android/client/history.h @@ -1,18 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ void history_store(const char *filename); diff --git a/android/client/if-audio.c b/android/client/if-audio.c index 630b5e685..91008927e 100644 --- a/android/client/if-audio.c +++ b/android/client/if-audio.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-av-sink.c b/android/client/if-av-sink.c index a6c867985..5b8c208fb 100644 --- a/android/client/if-av-sink.c +++ b/android/client/if-av-sink.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-av.c b/android/client/if-av.c index 798a47aff..c3c91b94b 100644 --- a/android/client/if-av.c +++ b/android/client/if-av.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-bt.c b/android/client/if-bt.c index 75403ec4a..68001a151 100644 --- a/android/client/if-bt.c +++ b/android/client/if-bt.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c index fbd938166..d00afffcb 100644 --- a/android/client/if-gatt.c +++ b/android/client/if-gatt.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-hf-client.c b/android/client/if-hf-client.c index f701a814c..e3793aaf0 100644 --- a/android/client/if-hf-client.c +++ b/android/client/if-hf-client.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-hf.c b/android/client/if-hf.c index 68df00b46..581d54248 100644 --- a/android/client/if-hf.c +++ b/android/client/if-hf.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-hh.c b/android/client/if-hh.c index 04a54dea2..fac314bd5 100644 --- a/android/client/if-hh.c +++ b/android/client/if-hh.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-hl.c b/android/client/if-hl.c index 1498fd5b0..826c81750 100644 --- a/android/client/if-hl.c +++ b/android/client/if-hl.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-main.h b/android/client/if-main.h index d239bb2bf..6463be0d6 100644 --- a/android/client/if-main.h +++ b/android/client/if-main.h @@ -1,18 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdio.h> diff --git a/android/client/if-mce.c b/android/client/if-mce.c index ef1968920..38d3770a3 100644 --- a/android/client/if-mce.c +++ b/android/client/if-mce.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-pan.c b/android/client/if-pan.c index b3098ba45..4b47ce23d 100644 --- a/android/client/if-pan.c +++ b/android/client/if-pan.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-rc-ctrl.c b/android/client/if-rc-ctrl.c index 39e4b9051..a155ea8d2 100644 --- a/android/client/if-rc-ctrl.c +++ b/android/client/if-rc-ctrl.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-rc.c b/android/client/if-rc.c index 6a5bffb6c..9a65f948b 100644 --- a/android/client/if-rc.c +++ b/android/client/if-rc.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-sco.c b/android/client/if-sco.c index 6b570d229..fa370c1e9 100644 --- a/android/client/if-sco.c +++ b/android/client/if-sco.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/if-sock.c b/android/client/if-sock.c index a188cf680..ce0e981f8 100644 --- a/android/client/if-sock.c +++ b/android/client/if-sock.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/pollhandler.c b/android/client/pollhandler.c index 6160921d9..ca21a02bf 100644 --- a/android/client/pollhandler.c +++ b/android/client/pollhandler.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdio.h> diff --git a/android/client/pollhandler.h b/android/client/pollhandler.h index e2f22dfb0..89736640e 100644 --- a/android/client/pollhandler.h +++ b/android/client/pollhandler.h @@ -1,18 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <poll.h> diff --git a/android/client/tabcompletion.c b/android/client/tabcompletion.c index dc6faa887..b79a9830b 100644 --- a/android/client/tabcompletion.c +++ b/android/client/tabcompletion.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/client/terminal.c b/android/client/terminal.c index f7b56de4c..cc8a9c3a4 100644 --- a/android/client/terminal.c +++ b/android/client/terminal.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdio.h> diff --git a/android/client/terminal.h b/android/client/terminal.h index 0e63936d3..3ce4a7e03 100644 --- a/android/client/terminal.h +++ b/android/client/terminal.h @@ -1,18 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdarg.h> diff --git a/android/compat/readline/history.h b/android/compat/readline/history.h index decc2f443..555e37aa1 100644 --- a/android/compat/readline/history.h +++ b/android/compat/readline/history.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 1987-2011 Free Software Foundation, Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef _HISTORY_H_ diff --git a/android/compat/readline/readline.h b/android/compat/readline/readline.h index aaf6f31ec..2d2fa37c0 100644 --- a/android/compat/readline/readline.h +++ b/android/compat/readline/readline.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 1987-2011 Free Software Foundation, Inc. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef _READLINE_H_ diff --git a/android/compat/wordexp.h b/android/compat/wordexp.h index ff1f21c7e..08c59ee02 100644 --- a/android/compat/wordexp.h +++ b/android/compat/wordexp.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 1991-2013 Free Software Foundation, Inc. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifndef _WORDEXP_H_ diff --git a/android/cutils/properties.h b/android/cutils/properties.h index 0163eb5cb..3f6229cba 100644 --- a/android/cutils/properties.h +++ b/android/cutils/properties.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <unistd.h> diff --git a/android/gatt.c b/android/gatt.c index 9351a667d..a8a0c488b 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/gatt.h b/android/gatt.h index 3382df9b2..d16ea5f26 100644 --- a/android/gatt.h +++ b/android/gatt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool bt_gatt_register(struct ipc *ipc, const bdaddr_t *addr); diff --git a/android/hal-a2dp-sink.c b/android/hal-a2dp-sink.c index a0b7ed1c4..0eecd1ac8 100644 --- a/android/hal-a2dp-sink.c +++ b/android/hal-a2dp-sink.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdbool.h> diff --git a/android/hal-a2dp.c b/android/hal-a2dp.c index f572875e8..34ca52fc8 100644 --- a/android/hal-a2dp.c +++ b/android/hal-a2dp.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdbool.h> diff --git a/android/hal-audio-aptx.c b/android/hal-audio-aptx.c index 4e364fc65..254ddf61c 100644 --- a/android/hal-audio-aptx.c +++ b/android/hal-audio-aptx.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Tieto Poland * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c index b06cafb7b..9c64d339c 100644 --- a/android/hal-audio-sbc.c +++ b/android/hal-audio-sbc.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-audio.c b/android/hal-audio.c index 2b25b6e08..d37d6098c 100644 --- a/android/hal-audio.c +++ b/android/hal-audio.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-audio.h b/android/hal-audio.h index 2b47412fc..389d14fc1 100644 --- a/android/hal-audio.h +++ b/android/hal-audio.h @@ -1,18 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <time.h> diff --git a/android/hal-avrcp-ctrl.c b/android/hal-avrcp-ctrl.c index a6137a5ad..41bdf9e7d 100644 --- a/android/hal-avrcp-ctrl.c +++ b/android/hal-avrcp-ctrl.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c index b2127ade9..709ebf835 100644 --- a/android/hal-avrcp.c +++ b/android/hal-avrcp.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c index ee3a5e054..d4442e620 100644 --- a/android/hal-bluetooth.c +++ b/android/hal-bluetooth.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-gatt.c b/android/hal-gatt.c index 2e706cf24..c471f795c 100644 --- a/android/hal-gatt.c +++ b/android/hal-gatt.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c index 93b5746b6..759164bde 100644 --- a/android/hal-handsfree-client.c +++ b/android/hal-handsfree-client.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdbool.h> diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c index af21b675f..d602df988 100644 --- a/android/hal-handsfree.c +++ b/android/hal-handsfree.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-health.c b/android/hal-health.c index 5d5b11137..2da389187 100644 --- a/android/hal-health.c +++ b/android/hal-health.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdbool.h> diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c index 1a603269c..2840ce559 100644 --- a/android/hal-hidhost.c +++ b/android/hal-hidhost.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdbool.h> diff --git a/android/hal-ipc.c b/android/hal-ipc.c index 363072cfc..8b37b7e0e 100644 --- a/android/hal-ipc.c +++ b/android/hal-ipc.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <pthread.h> diff --git a/android/hal-ipc.h b/android/hal-ipc.h index 08ed7cc85..a7a8dce51 100644 --- a/android/hal-ipc.h +++ b/android/hal-ipc.h @@ -1,18 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ struct hal_ipc_handler { diff --git a/android/hal-log.h b/android/hal-log.h index 63ff61b13..2d5abd752 100644 --- a/android/hal-log.h +++ b/android/hal-log.h @@ -1,18 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define LOG_TAG "BlueZ" diff --git a/android/hal-map-client.c b/android/hal-map-client.c index adf04fcef..0956e80aa 100644 --- a/android/hal-map-client.c +++ b/android/hal-map-client.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <stdlib.h> diff --git a/android/hal-msg.h b/android/hal-msg.h index ea79fa7df..c6c1e6118 100644 --- a/android/hal-msg.h +++ b/android/hal-msg.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket"; diff --git a/android/hal-pan.c b/android/hal-pan.c index 5e1afc80a..ca30911db 100644 --- a/android/hal-pan.c +++ b/android/hal-pan.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-sco.c b/android/hal-sco.c index f4b4d3160..d7c08a68b 100644 --- a/android/hal-sco.c +++ b/android/hal-sco.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-socket.c b/android/hal-socket.c index b971074f9..8d47fdd45 100644 --- a/android/hal-socket.c +++ b/android/hal-socket.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-utils.c b/android/hal-utils.c index 74f292756..453922be7 100644 --- a/android/hal-utils.c +++ b/android/hal-utils.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/hal-utils.h b/android/hal-utils.h index 9c5994855..4289d431c 100644 --- a/android/hal-utils.h +++ b/android/hal-utils.h @@ -1,18 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <endian.h> diff --git a/android/hal.h b/android/hal.h index 709c19758..df2f45db2 100644 --- a/android/hal.h +++ b/android/hal.h @@ -1,18 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #include <hardware/bluetooth.h> diff --git a/android/handsfree-client.c b/android/handsfree-client.c index 65659b899..4c682fbb8 100644 --- a/android/handsfree-client.c +++ b/android/handsfree-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/handsfree-client.h b/android/handsfree-client.h index 1eb69ff36..344d68520 100644 --- a/android/handsfree-client.h +++ b/android/handsfree-client.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr); diff --git a/android/handsfree.c b/android/handsfree.c index ebe03728e..2365356c2 100644 --- a/android/handsfree.c +++ b/android/handsfree.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/handsfree.h b/android/handsfree.h index d4fd649b0..d45bdb69a 100644 --- a/android/handsfree.h +++ b/android/handsfree.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool bt_handsfree_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode, diff --git a/android/hardware/audio.h b/android/hardware/audio.h index 3cc2be545..b612b9d11 100644 --- a/android/hardware/audio.h +++ b/android/hardware/audio.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2011 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ diff --git a/android/hardware/audio_effect.h b/android/hardware/audio_effect.h index 69ea89617..2c63f1ccf 100644 --- a/android/hardware/audio_effect.h +++ b/android/hardware/audio_effect.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2011 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ diff --git a/android/hardware/bluetooth.h b/android/hardware/bluetooth.h index 74cd1fce6..21253e00a 100644 --- a/android/hardware/bluetooth.h +++ b/android/hardware/bluetooth.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2012 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef ANDROID_INCLUDE_BLUETOOTH_H diff --git a/android/hardware/bt_av.h b/android/hardware/bt_av.h index 5252a179b..427244d48 100644 --- a/android/hardware/bt_av.h +++ b/android/hardware/bt_av.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2012 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_AV_H diff --git a/android/hardware/bt_gatt.h b/android/hardware/bt_gatt.h index 42e14c2f1..c48a446c2 100644 --- a/android/hardware/bt_gatt.h +++ b/android/hardware/bt_gatt.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ diff --git a/android/hardware/bt_gatt_client.h b/android/hardware/bt_gatt_client.h index 8073dd1d6..414e7b075 100644 --- a/android/hardware/bt_gatt_client.h +++ b/android/hardware/bt_gatt_client.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ diff --git a/android/hardware/bt_gatt_server.h b/android/hardware/bt_gatt_server.h index 0d6cc1e8d..fbb8fe6b8 100644 --- a/android/hardware/bt_gatt_server.h +++ b/android/hardware/bt_gatt_server.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ diff --git a/android/hardware/bt_gatt_types.h b/android/hardware/bt_gatt_types.h index e037ddcdb..c7c000e8d 100644 --- a/android/hardware/bt_gatt_types.h +++ b/android/hardware/bt_gatt_types.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2013 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ diff --git a/android/hardware/bt_hf.h b/android/hardware/bt_hf.h index 7dcb40a4b..c3f952415 100644 --- a/android/hardware/bt_hf.h +++ b/android/hardware/bt_hf.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2012 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_HF_H diff --git a/android/hardware/bt_hf_client.h b/android/hardware/bt_hf_client.h index 8acf1b2c5..4a0ec364b 100644 --- a/android/hardware/bt_hf_client.h +++ b/android/hardware/bt_hf_client.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2012-2014 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_HF_CLIENT_H diff --git a/android/hardware/bt_hh.h b/android/hardware/bt_hh.h index dad958680..2dd61beac 100644 --- a/android/hardware/bt_hh.h +++ b/android/hardware/bt_hh.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2012 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_HH_H diff --git a/android/hardware/bt_hl.h b/android/hardware/bt_hl.h index bd29e3abf..d26c054a7 100644 --- a/android/hardware/bt_hl.h +++ b/android/hardware/bt_hl.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2012 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_HL_H diff --git a/android/hardware/bt_mce.h b/android/hardware/bt_mce.h index 5d159b336..4d30ecd87 100644 --- a/android/hardware/bt_mce.h +++ b/android/hardware/bt_mce.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2014 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_MCE_H diff --git a/android/hardware/bt_pan.h b/android/hardware/bt_pan.h index 83e7949b2..2f9f4fb77 100644 --- a/android/hardware/bt_pan.h +++ b/android/hardware/bt_pan.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2012 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_PAN_H diff --git a/android/hardware/bt_rc.h b/android/hardware/bt_rc.h index c565c4875..c1290aeb1 100644 --- a/android/hardware/bt_rc.h +++ b/android/hardware/bt_rc.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2012 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_RC_H diff --git a/android/hardware/bt_sock.h b/android/hardware/bt_sock.h index a4aa046f2..cb2ff072a 100644 --- a/android/hardware/bt_sock.h +++ b/android/hardware/bt_sock.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2012 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_SOCK_H diff --git a/android/hardware/hardware.c b/android/hardware/hardware.c index 42d03ba52..db5696297 100644 --- a/android/hardware/hardware.c +++ b/android/hardware/hardware.c @@ -1,17 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2008 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #define _GNU_SOURCE diff --git a/android/hardware/hardware.h b/android/hardware/hardware.h index c7e8cc7e9..74470a31a 100644 --- a/android/hardware/hardware.h +++ b/android/hardware/hardware.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2008 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HARDWARE_H diff --git a/android/health.c b/android/health.c index 90253ac00..9a29964b1 100644 --- a/android/health.c +++ b/android/health.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -6,20 +7,6 @@ * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/health.h b/android/health.h index 0b32fd318..b221677d3 100644 --- a/android/health.h +++ b/android/health.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool bt_health_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode); diff --git a/android/hidhost.c b/android/hidhost.c index 7bc484f11..016382e17 100644 --- a/android/hidhost.c +++ b/android/hidhost.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/hidhost.h b/android/hidhost.h index e6b87ed2b..ee5dc8024 100644 --- a/android/hidhost.h +++ b/android/hidhost.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool bt_hid_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode); diff --git a/android/ipc-common.h b/android/ipc-common.h index 27736e4d6..599b63a94 100644 --- a/android/ipc-common.h +++ b/android/ipc-common.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #define IPC_MTU 1024 diff --git a/android/ipc-tester.c b/android/ipc-tester.c index c1d0e8ad6..780e1dc4c 100644 --- a/android/ipc-tester.c +++ b/android/ipc-tester.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/ipc.c b/android/ipc.c index 2e674284e..3b3c95293 100644 --- a/android/ipc.c +++ b/android/ipc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/ipc.h b/android/ipc.h index fd2b98521..02510e5f1 100644 --- a/android/ipc.h +++ b/android/ipc.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct ipc_handler { diff --git a/android/log.c b/android/log.c index 35917c601..ae172cf73 100644 --- a/android/log.c +++ b/android/log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H #include <config.h> diff --git a/android/main.c b/android/main.c index b505c2f77..b85709a1d 100644 --- a/android/main.c +++ b/android/main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/map-client.c b/android/map-client.c index e3ad148a0..3360bcd38 100644 --- a/android/map-client.c +++ b/android/map-client.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/map-client.h b/android/map-client.h index 0e63072f9..9dc237767 100644 --- a/android/map-client.h +++ b/android/map-client.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool bt_map_client_register(struct ipc *ipc, const bdaddr_t *addr, diff --git a/android/pan.c b/android/pan.c index 1e6d87641..ab4434710 100644 --- a/android/pan.c +++ b/android/pan.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/pan.h b/android/pan.h index cfbea96a2..0dc0c1c6f 100644 --- a/android/pan.h +++ b/android/pan.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ bool bt_pan_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode); diff --git a/android/sco-msg.h b/android/sco-msg.h index d1b13d70d..3eea210d9 100644 --- a/android/sco-msg.h +++ b/android/sco-msg.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ static const char BLUEZ_SCO_SK_PATH[] = "\0bluez_sco_socket"; diff --git a/android/sco.c b/android/sco.c index e8ac6854f..f3e03c605 100644 --- a/android/sco.c +++ b/android/sco.c @@ -1,23 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2014 Intel Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/sco.h b/android/sco.h index 4e1a2b3cf..4c7291fbe 100644 --- a/android/sco.h +++ b/android/sco.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ enum sco_status { diff --git a/android/socket.c b/android/socket.c index 15e1bfcc9..74cbcf4ef 100644 --- a/android/socket.c +++ b/android/socket.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/socket.h b/android/socket.h index b0e78c6d7..347bc30e3 100644 --- a/android/socket.h +++ b/android/socket.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ struct hal_sock_connect_signal { diff --git a/android/system-emulator.c b/android/system-emulator.c index edf3e89e0..bf1499df0 100644 --- a/android/system-emulator.c +++ b/android/system-emulator.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/system/audio.h b/android/system/audio.h index d2da76db1..0c5af5e84 100644 --- a/android/system/audio.h +++ b/android/system/audio.h @@ -1,17 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (C) 2011 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ diff --git a/android/test-ipc.c b/android/test-ipc.c index bb7d15fe0..f11c8f650 100644 --- a/android/test-ipc.c +++ b/android/test-ipc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #ifdef HAVE_CONFIG_H diff --git a/android/tester-a2dp.c b/android/tester-a2dp.c index 554a3941d..c25809245 100644 --- a/android/tester-a2dp.c +++ b/android/tester-a2dp.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/tester-avrcp.c b/android/tester-avrcp.c index e0e7b7f6a..f2292d4e4 100644 --- a/android/tester-avrcp.c +++ b/android/tester-avrcp.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c index 6db337a94..f7a6b40d7 100644 --- a/android/tester-bluetooth.c +++ b/android/tester-bluetooth.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/tester-gatt.c b/android/tester-gatt.c index c10609732..30db7684d 100644 --- a/android/tester-gatt.c +++ b/android/tester-gatt.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/tester-hdp.c b/android/tester-hdp.c index b4d14a339..0cc805eac 100644 --- a/android/tester-hdp.c +++ b/android/tester-hdp.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c index 73092cda8..f9daf5590 100644 --- a/android/tester-hidhost.c +++ b/android/tester-hidhost.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/tester-main.c b/android/tester-main.c index 9a14b2899..2bfa770bb 100644 --- a/android/tester-main.c +++ b/android/tester-main.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/tester-main.h b/android/tester-main.h index 6bdfdbcdb..9b835d5eb 100644 --- a/android/tester-main.h +++ b/android/tester-main.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ #include <glib.h> diff --git a/android/tester-map-client.c b/android/tester-map-client.c index ff3f272fc..63ec319b6 100644 --- a/android/tester-map-client.c +++ b/android/tester-map-client.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/tester-pan.c b/android/tester-pan.c index 74ad107a8..f70ab95b8 100644 --- a/android/tester-pan.c +++ b/android/tester-pan.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/tester-socket.c b/android/tester-socket.c index ac77e5aeb..540ee70d4 100644 --- a/android/tester-socket.c +++ b/android/tester-socket.c @@ -1,18 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2014 Intel Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * */ #define _GNU_SOURCE diff --git a/android/utils.h b/android/utils.h index 7adc2dabc..1902e15f8 100644 --- a/android/utils.h +++ b/android/utils.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux @@ -5,20 +6,6 @@ * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. * * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * */ static inline void android2bdaddr(const void *buf, bdaddr_t *dst) -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qH7kMJ4BaV9gSwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:40:14 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id qFzSLZ4BaV8s9wEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:40:14 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 6417CA0B31; Mon, 21 Sep 2020 21:39:50 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbgIUTj0 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:39:26 -0400 Received: from mga02.intel.com ([134.134.136.20]:55844 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbgIUTj0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:39:26 -0400 IronPort-SDR: yQWklN+d6zeZogJvA3ve4bQGtun+2673bJjnbj0wyKA7yhdiy/mlP4ei7BDPxGujZ4Lmb3mpcU A9YifRXohRBA== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="148125419" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="148125419" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:39:26 -0700 IronPort-SDR: fVzGheHxjtRkIItC7o5+935/I0K+2waPD+6qi4InJyfd3vq4J7JUUkHE+7NiF+n+78PQhacEH1 p322m2jd226Q== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="321917110" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:39:25 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 19/20] test: Add SPDX License Identifier Date: Mon, 21 Sep 2020 12:39:18 -0700 Message-Id: <20200921193918.47529-1-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.18 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6417CA0B31 X-Rspamd-UID: c6c047 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 35 License: LGPL-2.1-or-later test/agent.py test/bluezutils.py test/dbusdef.py test/example-advertisement test/example-endpoint test/example-gatt-client test/example-gatt-server test/example-player test/exchange-business-cards test/ftp-client test/get-managed-objects test/get-obex-capabilities test/list-devices test/list-folders test/map-client test/monitor-bluetooth test/opp-client test/pbap-client test/sap_client.py test/simple-endpoint test/simple-obex-agent test/simple-player test/test-adapter test/test-device test/test-discovery test/test-gatt-profile test/test-health test/test-health-sink test/test-hfp test/test-manager test/test-mesh test/test-nap test/test-network test/test-profile test/test-sap-server --- test/agent.py | 1 + test/bluezutils.py | 2 ++ test/dbusdef.py | 2 ++ test/example-advertisement | 1 + test/example-endpoint | 1 + test/example-gatt-client | 1 + test/example-gatt-server | 1 + test/example-player | 1 + test/exchange-business-cards | 1 + test/ftp-client | 1 + test/get-managed-objects | 1 + test/get-obex-capabilities | 1 + test/list-devices | 1 + test/list-folders | 1 + test/map-client | 1 + test/monitor-bluetooth | 1 + test/opp-client | 1 + test/pbap-client | 1 + test/sap_client.py | 15 +-------------- test/simple-agent | 1 + test/simple-endpoint | 1 + test/simple-obex-agent | 1 + test/simple-player | 1 + test/test-adapter | 1 + test/test-device | 1 + test/test-discovery | 1 + test/test-gatt-profile | 1 + test/test-health | 1 + test/test-health-sink | 1 + test/test-hfp | 1 + test/test-join | 1 + test/test-manager | 1 + test/test-mesh | 1 + test/test-nap | 1 + test/test-network | 1 + test/test-profile | 1 + test/test-sap-server | 1 + 37 files changed, 39 insertions(+), 14 deletions(-) diff --git a/test/agent.py b/test/agent.py index d8e5534d8..b46cd95f4 100755 --- a/test/agent.py +++ b/test/agent.py @@ -1,4 +1,5 @@ #!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later import sys import dbus diff --git a/test/bluezutils.py b/test/bluezutils.py index cd8964082..85aa24277 100644 --- a/test/bluezutils.py +++ b/test/bluezutils.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + import dbus SERVICE_NAME = "org.bluez" diff --git a/test/dbusdef.py b/test/dbusdef.py index f1cd35adb..d317c18de 100644 --- a/test/dbusdef.py +++ b/test/dbusdef.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + import dbus import bluezutils diff --git a/test/example-advertisement b/test/example-advertisement index 96e410683..5f022ee67 100755 --- a/test/example-advertisement +++ b/test/example-advertisement @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import print_function diff --git a/test/example-endpoint b/test/example-endpoint index a5f0348a0..16651c683 100644 --- a/test/example-endpoint +++ b/test/example-endpoint @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/example-gatt-client b/test/example-gatt-client index b4bbaa9d9..5e6bef9d7 100755 --- a/test/example-gatt-client +++ b/test/example-gatt-client @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1-or-later import dbus try: diff --git a/test/example-gatt-server b/test/example-gatt-server index 689e86ff7..77231c3ad 100755 --- a/test/example-gatt-server +++ b/test/example-gatt-server @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1-or-later import dbus import dbus.exceptions diff --git a/test/example-player b/test/example-player index 2beb08e44..1497d1107 100644 --- a/test/example-player +++ b/test/example-player @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import print_function diff --git a/test/exchange-business-cards b/test/exchange-business-cards index 6805cf71e..9a3aa29fb 100755 --- a/test/exchange-business-cards +++ b/test/exchange-business-cards @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later import sys import dbus diff --git a/test/ftp-client b/test/ftp-client index 4540602a0..ef756ab2b 100755 --- a/test/ftp-client +++ b/test/ftp-client @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/get-managed-objects b/test/get-managed-objects index 3156f658f..5125ee524 100755 --- a/test/get-managed-objects +++ b/test/get-managed-objects @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/get-obex-capabilities b/test/get-obex-capabilities index e8afbad21..a7980a442 100755 --- a/test/get-obex-capabilities +++ b/test/get-obex-capabilities @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later import sys import dbus diff --git a/test/list-devices b/test/list-devices index 0aac217d1..b112556c3 100755 --- a/test/list-devices +++ b/test/list-devices @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/list-folders b/test/list-folders index 7321a1527..b4e3f100b 100755 --- a/test/list-folders +++ b/test/list-folders @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later import sys import dbus diff --git a/test/map-client b/test/map-client index b9695da66..a2d96ae5f 100755 --- a/test/map-client +++ b/test/map-client @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/monitor-bluetooth b/test/monitor-bluetooth index d9b5472f5..a3977e206 100755 --- a/test/monitor-bluetooth +++ b/test/monitor-bluetooth @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/opp-client b/test/opp-client index 62d5b8454..4f00a41c0 100755 --- a/test/opp-client +++ b/test/opp-client @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/pbap-client b/test/pbap-client index 16a786bb1..e6cafdd30 100755 --- a/test/pbap-client +++ b/test/pbap-client @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/sap_client.py b/test/sap_client.py index 413424c05..fed13aedc 100644 --- a/test/sap_client.py +++ b/test/sap_client.py @@ -1,21 +1,8 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later """ Copyright (C) 2010-2011 ST-Ericsson SA """ """ Author: Szymon Janc <szymon.janc@tieto.com> for ST-Ericsson. """ -""" This program is free software; you can redistribute it and/or modify """ -""" it under the terms of the GNU General Public License as published by """ -""" the Free Software Foundation; either version 2 of the License, or """ -""" (at your option) any later version. """ - -""" This program is distributed in the hope that it will be useful, """ -""" but WITHOUT ANY WARRANTY; without even the implied warranty of """ -""" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the """ -""" GNU General Public License for more details. """ - -""" You should have received a copy of the GNU General Public License """ -""" along with this program; if not, write to the Free Software """ -""" Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ - from array import array from bluetooth import * import time diff --git a/test/simple-agent b/test/simple-agent index a69299a3e..4fdaff1eb 100755 --- a/test/simple-agent +++ b/test/simple-agent @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/simple-endpoint b/test/simple-endpoint index 78fb5fda5..59ca189ce 100755 --- a/test/simple-endpoint +++ b/test/simple-endpoint @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/simple-obex-agent b/test/simple-obex-agent index 05ec4eda7..064f6d30b 100755 --- a/test/simple-obex-agent +++ b/test/simple-obex-agent @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/simple-player b/test/simple-player index 02754c2f4..92682844d 100755 --- a/test/simple-player +++ b/test/simple-player @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import print_function diff --git a/test/test-adapter b/test/test-adapter index 959a43703..a216140ba 100755 --- a/test/test-adapter +++ b/test/test-adapter @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-device b/test/test-device index b490d53f4..a1e508166 100755 --- a/test/test-device +++ b/test/test-device @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-discovery b/test/test-discovery index cea77683d..eccc7c7e3 100755 --- a/test/test-discovery +++ b/test/test-discovery @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-gatt-profile b/test/test-gatt-profile index 995a65913..a973ae14e 100755 --- a/test/test-gatt-profile +++ b/test/test-gatt-profile @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-health b/test/test-health index 24afa799e..d6b437ed8 100755 --- a/test/test-health +++ b/test/test-health @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals # -*- coding: utf-8 -*- diff --git a/test/test-health-sink b/test/test-health-sink index 37e630a21..57665d2ba 100755 --- a/test/test-health-sink +++ b/test/test-health-sink @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals # -*- coding: utf-8 -*- diff --git a/test/test-hfp b/test/test-hfp index a8060439e..11e328e54 100755 --- a/test/test-hfp +++ b/test/test-hfp @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-join b/test/test-join index 6dfb2e8c3..969795094 100644 --- a/test/test-join +++ b/test/test-join @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1-or-later import sys import struct diff --git a/test/test-manager b/test/test-manager index 4f5994f67..3fa7205a0 100755 --- a/test/test-manager +++ b/test/test-manager @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-mesh b/test/test-mesh index 1e1b8724d..9e4783734 100755 --- a/test/test-mesh +++ b/test/test-mesh @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1-or-later ################################################################### # diff --git a/test/test-nap b/test/test-nap index ab67a7509..d5c757b79 100755 --- a/test/test-nap +++ b/test/test-nap @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-network b/test/test-network index 6f0948649..acc7dff65 100755 --- a/test/test-network +++ b/test/test-network @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-profile b/test/test-profile index 27915806f..af1e23f76 100755 --- a/test/test-profile +++ b/test/test-profile @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals diff --git a/test/test-sap-server b/test/test-sap-server index ff178af22..ddb1efe9b 100755 --- a/test/test-sap-server +++ b/test/test-sap-server @@ -1,4 +1,5 @@ #!/usr/bin/python +# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import absolute_import, print_function, unicode_literals -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eNtvFDEDaV96YAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Mon, 21 Sep 2020 21:46:57 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id uCMNEjEDaV+d3AEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Mon, 21 Sep 2020 21:46:57 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 004A5A0B5B; Mon, 21 Sep 2020 21:46:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727393AbgIUTq0 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 15:46:26 -0400 Received: from mga07.intel.com ([134.134.136.100]:25670 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727059AbgIUTq0 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 15:46:26 -0400 IronPort-SDR: M8qiNzcw3eOu/6IPw5BokjATLfC6MzyyDNuYSsL/wG8Xro1dAJMthVVElJCecMP4nE6CccwLPk ABdJqN6KgOag== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="224614163" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="224614163" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:46:23 -0700 IronPort-SDR: u1igqp7DgeWDtsyG5Hc0DJzs5c/zY4mlWsqtaLiptRuZ0d/Q7Dno0+0KDwd8wtO4UodQCbrzyD tQljS+MQ/wOA== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="334683906" Received: from han1-mobl3.jf.intel.com ([10.254.86.223]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:46:22 -0700 From: tedd.an@linux.intel.com To: linux-bluetooth@vger.kernel.org Cc: Tedd Ho-Jeong An <tedd.an@intel.com> Subject: [BlueZ V4 RESEND 20/20] LICENSES: Add License files Date: Mon, 21 Sep 2020 12:46:16 -0700 Message-Id: <20200921194616.48146-1-tedd.an@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> References: <20200921190040.45309-1-tedd.an@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.89 / 15.00 / 15.00 X-Rspamd-Queue-Id: 004A5A0B5B X-Rspamd-UID: bcec89 From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch adds the full text of licenses used in the BlueZ. --- LICENSES/dual/Apache-2.0 | 187 ++++++++++++ LICENSES/preferred/BSD-2-Clause | 32 ++ LICENSES/preferred/GPL-2.0 | 354 ++++++++++++++++++++++ LICENSES/preferred/LGPL-2.1 | 503 ++++++++++++++++++++++++++++++++ LICENSES/preferred/MIT | 30 ++ 5 files changed, 1106 insertions(+) create mode 100644 LICENSES/dual/Apache-2.0 create mode 100644 LICENSES/preferred/BSD-2-Clause create mode 100644 LICENSES/preferred/GPL-2.0 create mode 100644 LICENSES/preferred/LGPL-2.1 create mode 100644 LICENSES/preferred/MIT diff --git a/LICENSES/dual/Apache-2.0 b/LICENSES/dual/Apache-2.0 new file mode 100644 index 000000000..6e89ddeab --- /dev/null +++ b/LICENSES/dual/Apache-2.0 @@ -0,0 +1,187 @@ +Valid-License-Identifier: Apache-2.0 +SPDX-URL: https://spdx.org/licenses/Apache-2.0.html +Usage-Guide: + Do NOT use. The Apache-2.0 is not GPL2 compatible. It may only be used + for dual-licensed files where the other license is GPL2 compatible. + If you end up using this it MUST be used together with a GPL2 compatible + license using "OR". + To use the Apache License version 2.0 put the following SPDX tag/value + pair into a comment according to the placement guidelines in the + licensing rules documentation: + SPDX-License-Identifier: Apache-2.0 +License-Text: + +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the +copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other +entities that control, are controlled by, or are under common control with +that entity. For the purposes of this definition, "control" means (i) the +power, direct or indirect, to cause the direction or management of such +entity, whether by contract or otherwise, or (ii) ownership of fifty +percent (50%) or more of the outstanding shares, or (iii) beneficial +ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation +or translation of a Source form, including but not limited to compiled +object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice that +is included in or attached to the work (an example is provided in the +Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, as +a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, or +merely link (or bind by name) to the interfaces of, the Work and Derivative +Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor for +inclusion in the Work by the copyright owner or by an individual or Legal +Entity authorized to submit on behalf of the copyright owner. For the +purposes of this definition, "submitted" means any form of electronic, +verbal, or written communication sent to the Licensor or its +representatives, including but not limited to communication on electronic +mailing lists, source code control systems, and issue tracking systems that +are managed by, or on behalf of, the Licensor for the purpose of discussing +and improving the Work, but excluding communication that is conspicuously +marked or otherwise designated in writing by the copyright owner as "Not a +Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on +behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this + License, each Contributor hereby grants to You a perpetual, worldwide, + non-exclusive, no-charge, royalty-free, irrevocable copyright license to + reproduce, prepare Derivative Works of, publicly display, publicly + perform, sublicense, and distribute the Work and such Derivative Works + in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this + License, each Contributor hereby grants to You a perpetual, worldwide, + non-exclusive, no-charge, royalty-free, irrevocable (except as stated in + this section) patent license to make, have made, use, offer to sell, + sell, import, and otherwise transfer the Work, where such license + applies only to those patent claims licensable by such Contributor that + are necessarily infringed by their Contribution(s) alone or by + combination of their Contribution(s) with the Work to which such + Contribution(s) was submitted. If You institute patent litigation + against any entity (including a cross-claim or counterclaim in a + lawsuit) alleging that the Work or a Contribution incorporated within + the Work constitutes direct or contributory patent infringement, then + any patent licenses granted to You under this License for that Work + shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or + Derivative Works thereof in any medium, with or without modifications, + and in Source or Object form, provided that You meet the following + conditions: + + a. You must give any other recipients of the Work or Derivative Works a + copy of this License; and + + b. You must cause any modified files to carry prominent notices stating + that You changed the files; and + + c. You must retain, in the Source form of any Derivative Works that You + distribute, all copyright, patent, trademark, and attribution notices + from the Source form of the Work, excluding those notices that do not + pertain to any part of the Derivative Works; and + + d. If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained within + such NOTICE file, excluding those notices that do not pertain to any + part of the Derivative Works, in at least one of the following + places: within a NOTICE text file distributed as part of the + Derivative Works; within the Source form or documentation, if + provided along with the Derivative Works; or, within a display + generated by the Derivative Works, if and wherever such third-party + notices normally appear. The contents of the NOTICE file are for + informational purposes only and do not modify the License. You may + add Your own attribution notices within Derivative Works that You + distribute, alongside or as an addendum to the NOTICE text from the + Work, provided that such additional attribution notices cannot be + construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may + provide additional or different license terms and conditions for use, + reproduction, or distribution of Your modifications, or for any such + Derivative Works as a whole, provided Your use, reproduction, and + distribution of the Work otherwise complies with the conditions stated + in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any + Contribution intentionally submitted for inclusion in the Work by You to + the Licensor shall be under the terms and conditions of this License, + without any additional terms or conditions. Notwithstanding the above, + nothing herein shall supersede or modify the terms of any separate + license agreement you may have executed with Licensor regarding such + Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to + in writing, Licensor provides the Work (and each Contributor provides + its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied, including, without limitation, + any warranties or conditions of TITLE, NON-INFRINGEMENT, + MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely + responsible for determining the appropriateness of using or + redistributing the Work and assume any risks associated with Your + exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether + in tort (including negligence), contract, or otherwise, unless required + by applicable law (such as deliberate and grossly negligent acts) or + agreed to in writing, shall any Contributor be liable to You for + damages, including any direct, indirect, special, incidental, or + consequential damages of any character arising as a result of this + License or out of the use or inability to use the Work (including but + not limited to damages for loss of goodwill, work stoppage, computer + failure or malfunction, or any and all other commercial damages or + losses), even if such Contributor has been advised of the possibility of + such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the + Work or Derivative Works thereof, You may choose to offer, and charge a + fee for, acceptance of support, warranty, indemnity, or other liability + obligations and/or rights consistent with this License. However, in + accepting such obligations, You may act only on Your own behalf and on + Your sole responsibility, not on behalf of any other Contributor, and + only if You agree to indemnify, defend, and hold each Contributor + harmless for any liability incurred by, or claims asserted against, such + Contributor by reason of your accepting any such warranty or additional + liability. + +END OF TERMS AND CONDITIONS diff --git a/LICENSES/preferred/BSD-2-Clause b/LICENSES/preferred/BSD-2-Clause new file mode 100644 index 000000000..da366e2ce --- /dev/null +++ b/LICENSES/preferred/BSD-2-Clause @@ -0,0 +1,32 @@ +Valid-License-Identifier: BSD-2-Clause +SPDX-URL: https://spdx.org/licenses/BSD-2-Clause.html +Usage-Guide: + To use the BSD 2-clause "Simplified" License put the following SPDX + tag/value pair into a comment according to the placement guidelines in + the licensing rules documentation: + SPDX-License-Identifier: BSD-2-Clause +License-Text: + +Copyright (c) <year> <owner> . All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENSES/preferred/GPL-2.0 b/LICENSES/preferred/GPL-2.0 new file mode 100644 index 000000000..d1128f659 --- /dev/null +++ b/LICENSES/preferred/GPL-2.0 @@ -0,0 +1,354 @@ +Valid-License-Identifier: GPL-2.0 +Valid-License-Identifier: GPL-2.0-only +Valid-License-Identifier: GPL-2.0-or-later +SPDX-URL: https://spdx.org/licenses/GPL-2.0.html +Usage-Guide: + To use this license in source code, put one of the following SPDX + tag/value pairs into a comment according to the placement + guidelines in the licensing rules documentation. + For 'GNU General Public License (GPL) version 2 only' use: + SPDX-License-Identifier: GPL-2.0-only + For 'GNU General Public License (GPL) version 2 or any later version' use: + SPDX-License-Identifier: GPL-2.0-or-later +License-Text: + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/LICENSES/preferred/LGPL-2.1 b/LICENSES/preferred/LGPL-2.1 new file mode 100644 index 000000000..8e08d6ea5 --- /dev/null +++ b/LICENSES/preferred/LGPL-2.1 @@ -0,0 +1,503 @@ +Valid-License-Identifier: LGPL-2.1 +Valid-License-Identifier: LGPL-2.1-or-later +SPDX-URL: https://spdx.org/licenses/LGPL-2.1.html +Usage-Guide: + To use this license in source code, put one of the following SPDX + tag/value pairs into a comment according to the placement + guidelines in the licensing rules documentation. + For 'GNU Lesser General Public License (LGPL) version 2.1 only' use: + SPDX-License-Identifier: LGPL-2.1 + For 'GNU Lesser General Public License (LGPL) version 2.1 or any later + version' use: + SPDX-License-Identifier: LGPL-2.1-or-later +License-Text: + +GNU LESSER GENERAL PUBLIC LICENSE +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as +the successor of the GNU Library Public License, version 2, hence the +version number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to +share and change it. By contrast, the GNU General Public Licenses are +intended to guarantee your freedom to share and change free software--to +make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some specially +designated software packages--typically libraries--of the Free Software +Foundation and other authors who decide to use it. You can use it too, but +we suggest you first think carefully about whether this license or the +ordinary General Public License is the better strategy to use in any +particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not +price. Our General Public Licenses are designed to make sure that you have +the freedom to distribute copies of free software (and charge for this +service if you wish); that you receive source code or can get it if you +want it; that you can change the software and use pieces of it in new free +programs; and that you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for you if +you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for +a fee, you must give the recipients all the rights that we gave you. You +must make sure that they, too, receive or can get the source code. If you +link other code with the library, you must provide complete object files to +the recipients, so that they can relink them with the library after making +changes to the library and recompiling it. And you must show them these +terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no +warranty for the free library. Also, if the library is modified by someone +else and passed on, the recipients should know that what they have is not +the original version, so that the original author's reputation will not be +affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any +free program. We wish to make sure that a company cannot effectively +restrict the users of a free program by obtaining a restrictive license +from a patent holder. Therefore, we insist that any patent license obtained +for a version of the library must be consistent with the full freedom of +use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary GNU +General Public License. This license, the GNU Lesser General Public +License, applies to certain designated libraries, and is quite different +from the ordinary General Public License. We use this license for certain +libraries in order to permit linking those libraries into non-free +programs. + +When a program is linked with a library, whether statically or using a +shared library, the combination of the two is legally speaking a combined +work, a derivative of the original library. The ordinary General Public +License therefore permits such linking only if the entire combination fits +its criteria of freedom. The Lesser General Public License permits more lax +criteria for linking other code with the library. + +We call this license the "Lesser" General Public License because it does +Less to protect the user's freedom than the ordinary General Public +License. It also provides other free software developers Less of an +advantage over competing non-free programs. These disadvantages are the +reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + +For example, on rare occasions, there may be a special need to encourage +the widest possible use of a certain library, so that it becomes a de-facto +standard. To achieve this, non-free programs must be allowed to use the +library. A more frequent case is that a free library does the same job as +widely used non-free libraries. In this case, there is little to gain by +limiting the free library to free software only, so we use the Lesser +General Public License. + +In other cases, permission to use a particular library in non-free programs +enables a greater number of people to use a large body of free +software. For example, permission to use the GNU C Library in non-free +programs enables many more people to use the whole GNU operating system, as +well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' +freedom, it does ensure that the user of a program that is linked with the +Library has the freedom and the wherewithal to run that program using a +modified version of the Library. + +The precise terms and conditions for copying, distribution and modification +follow. Pay close attention to the difference between a "work based on the +library" and a "work that uses the library". The former contains code +derived from the library, whereas the latter must be combined with the +library in order to run. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program + which contains a notice placed by the copyright holder or other + authorized party saying it may be distributed under the terms of this + Lesser General Public License (also called "this License"). Each + licensee is addressed as "you". + + A "library" means a collection of software functions and/or data + prepared so as to be conveniently linked with application programs + (which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work which + has been distributed under these terms. A "work based on the Library" + means either the Library or any derivative work under copyright law: + that is to say, a work containing the Library or a portion of it, either + verbatim or with modifications and/or translated straightforwardly into + another language. (Hereinafter, translation is included without + limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for making + modifications to it. For a library, complete source code means all the + source code for all modules it contains, plus any associated interface + definition files, plus the scripts used to control compilation and + installation of the library. + + Activities other than copying, distribution and modification are not + covered by this License; they are outside its scope. The act of running + a program using the Library is not restricted, and output from such a + program is covered only if its contents constitute a work based on the + Library (independent of the use of the Library in a tool for writing + it). Whether that is true depends on what the Library does and what the + program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete + source code as you receive it, in any medium, provided that you + conspicuously and appropriately publish on each copy an appropriate + copyright notice and disclaimer of warranty; keep intact all the notices + that refer to this License and to the absence of any warranty; and + distribute a copy of this License along with the Library. + + You may charge a fee for the physical act of transferring a copy, and + you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, + thus forming a work based on the Library, and copy and distribute such + modifications or work under the terms of Section 1 above, provided that + you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices stating + that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no charge to + all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a table + of data to be supplied by an application program that uses the + facility, other than as an argument passed when the facility is + invoked, then you must make a good faith effort to ensure that, in + the event an application does not supply such function or table, the + facility still operates, and performs whatever part of its purpose + remains meaningful. + + (For example, a function in a library to compute square roots has a + purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must be + optional: if the application does not supply it, the square root + function must still compute square roots.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Library, and + can be reasonably considered independent and separate works in + themselves, then this License, and its terms, do not apply to those + sections when you distribute them as separate works. But when you + distribute the same sections as part of a whole which is a work based on + the Library, the distribution of the whole must be on the terms of this + License, whose permissions for other licensees extend to the entire + whole, and thus to each and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or contest + your rights to work written entirely by you; rather, the intent is to + exercise the right to control the distribution of derivative or + collective works based on the Library. + + In addition, mere aggregation of another work not based on the Library + with the Library (or with a work based on the Library) on a volume of a + storage or distribution medium does not bring the other work under the + scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public + License instead of this License to a given copy of the Library. To do + this, you must alter all the notices that refer to this License, so that + they refer to the ordinary GNU General Public License, version 2, + instead of to this License. (If a newer version than version 2 of the + ordinary GNU General Public License has appeared, then you can specify + that version instead if you wish.) Do not make any other change in these + notices. + + Once this change is made in a given copy, it is irreversible for that + copy, so the ordinary GNU General Public License applies to all + subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of the + Library into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of + it, under Section 2) in object code or executable form under the terms + of Sections 1 and 2 above provided that you accompany it with the + complete corresponding machine-readable source code, which must be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange. + + If distribution of object code is made by offering access to copy from a + designated place, then offering equivalent access to copy the source + code from the same place satisfies the requirement to distribute the + source code, even though third parties are not compelled to copy the + source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but + is designed to work with the Library by being compiled or linked with + it, is called a "work that uses the Library". Such a work, in isolation, + is not a derivative work of the Library, and therefore falls outside the + scope of this License. + + However, linking a "work that uses the Library" with the Library creates + an executable that is a derivative of the Library (because it contains + portions of the Library), rather than a "work that uses the + library". The executable is therefore covered by this License. Section 6 + states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file + that is part of the Library, the object code for the work may be a + derivative work of the Library even though the source code is + not. Whether this is true is especially significant if the work can be + linked without the Library, or if the work is itself a library. The + threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data structure + layouts and accessors, and small macros and small inline functions (ten + lines or less in length), then the use of the object file is + unrestricted, regardless of whether it is legally a derivative + work. (Executables containing this object code plus portions of the + Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may + distribute the object code for the work under the terms of Section + 6. Any executables containing that work also fall under Section 6, + whether or not they are linked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a + "work that uses the Library" with the Library to produce a work + containing portions of the Library, and distribute that work under terms + of your choice, provided that the terms permit modification of the work + for the customer's own use and reverse engineering for debugging such + modifications. + + You must give prominent notice with each copy of the work that the + Library is used in it and that the Library and its use are covered by + this License. You must supply a copy of this License. If the work during + execution displays copyright notices, you must include the copyright + notice for the Library among them, as well as a reference directing the + user to the copy of this License. Also, you must do one of these things: + + a) Accompany the work with the complete corresponding machine-readable + source code for the Library including whatever changes were used in + the work (which must be distributed under Sections 1 and 2 above); + and, if the work is an executable linked with the Library, with the + complete machine-readable "work that uses the Library", as object + code and/or source code, so that the user can modify the Library and + then relink to produce a modified executable containing the modified + Library. (It is understood that the user who changes the contents of + definitions files in the Library will not necessarily be able to + recompile the application to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a copy + of the library already present on the user's computer system, rather + than copying library functions into the executable, and (2) will + operate properly with a modified version of the library, if the user + installs one, as long as the modified version is interface-compatible + with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least three + years, to give the same user the materials specified in Subsection + 6a, above, for a charge no more than the cost of performing this + distribution. + + d) If distribution of the work is made by offering access to copy from a + designated place, offer equivalent access to copy the above specified + materials from the same place. + + e) Verify that the user has already received a copy of these materials + or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the Library" + must include any data and utility programs needed for reproducing the + executable from it. However, as a special exception, the materials to be + distributed need not include anything that is normally distributed (in + either source or binary form) with the major components (compiler, + kernel, and so on) of the operating system on which the executable runs, + unless that component itself accompanies the executable. + + It may happen that this requirement contradicts the license restrictions + of other proprietary libraries that do not normally accompany the + operating system. Such a contradiction means you cannot use both them + and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library + side-by-side in a single library together with other library facilities + not covered by this License, and distribute such a combined library, + provided that the separate distribution of the work based on the Library + and of the other library facilities is otherwise permitted, and provided + that you do these two things: + + a) Accompany the combined library with a copy of the same work based on + the Library, uncombined with any other library facilities. This must + be distributed under the terms of the Sections above. + + b) Give prominent notice with the combined library of the fact that part + of it is a work based on the Library, and explaining where to find + the accompanying uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the + Library except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense, link with, or distribute the + Library is void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, from you + under this License will not have their licenses terminated so long as + such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed + it. However, nothing else grants you permission to modify or distribute + the Library or its derivative works. These actions are prohibited by law + if you do not accept this License. Therefore, by modifying or + distributing the Library (or any work based on the Library), you + indicate your acceptance of this License to do so, and all its terms and + conditions for copying, distributing or modifying the Library or works + based on it. + +10. Each time you redistribute the Library (or any work based on the + Library), the recipient automatically receives a license from the + original licensor to copy, distribute, link with or modify the Library + subject to these terms and conditions. You may not impose any further + restrictions on the recipients' exercise of the rights granted + herein. You are not responsible for enforcing compliance by third + parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent issues), + conditions are imposed on you (whether by court order, agreement or + otherwise) that contradict the conditions of this License, they do not + excuse you from the conditions of this License. If you cannot + distribute so as to satisfy simultaneously your obligations under this + License and any other pertinent obligations, then as a consequence you + may not distribute the Library at all. For example, if a patent license + would not permit royalty-free redistribution of the Library by all + those who receive copies directly or indirectly through you, then the + only way you could satisfy both it and this License would be to refrain + entirely from distribution of the Library. + + If any portion of this section is held invalid or unenforceable under + any particular circumstance, the balance of the section is intended to + apply, and the section as a whole is intended to apply in other + circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of any + such claims; this section has the sole purpose of protecting the + integrity of the free software distribution system which is implemented + by public license practices. Many people have made generous + contributions to the wide range of software distributed through that + system in reliance on consistent application of that system; it is up + to the author/donor to decide if he or she is willing to distribute + software through any other system and a licensee cannot impose that + choice. + + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain + countries either by patents or by copyrighted interfaces, the original + copyright holder who places the Library under this License may add an + explicit geographical distribution limitation excluding those + countries, so that distribution is permitted only in or among countries + not thus excluded. In such case, this License incorporates the + limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of + the Lesser General Public License from time to time. Such new versions + will be similar in spirit to the present version, but may differ in + detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the Library + specifies a version number of this License which applies to it and "any + later version", you have the option of following the terms and + conditions either of that version or of any later version published by + the Free Software Foundation. If the Library does not specify a license + version number, you may choose any version ever published by the Free + Software Foundation. + +14. If you wish to incorporate parts of the Library into other free + programs whose distribution conditions are incompatible with these, + write to the author to ask for permission. For software which is + copyrighted by the Free Software Foundation, write to the Free Software + Foundation; we sometimes make exceptions for this. Our decision will be + guided by the two goals of preserving the free status of all + derivatives of our free software and of promoting the sharing and reuse + of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY + FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN + OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES + PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER + EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE + ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH + YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL + NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING + WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR + REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR + DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL + DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY + (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED + INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF + THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR + OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + +To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + +one line to give the library's name and an idea of what it does. +Copyright (C) year name of author + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License +for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add +information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice +That's all there is to it! diff --git a/LICENSES/preferred/MIT b/LICENSES/preferred/MIT new file mode 100644 index 000000000..f33a68ceb --- /dev/null +++ b/LICENSES/preferred/MIT @@ -0,0 +1,30 @@ +Valid-License-Identifier: MIT +SPDX-URL: https://spdx.org/licenses/MIT.html +Usage-Guide: + To use the MIT License put the following SPDX tag/value pair into a + comment according to the placement guidelines in the licensing rules + documentation: + SPDX-License-Identifier: MIT +License-Text: + +MIT License + +Copyright (c) <year> <copyright holders> + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. -- 2.25.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MFPgKMAtaV+DSgEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 00:48:32 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id gOJOJsAtaV92WQAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 00:48:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 239C9A0B37; Tue, 22 Sep 2020 00:48:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728679AbgIUWsZ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 18:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728379AbgIUWsZ (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 18:48:25 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B116AC061755 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 15:48:24 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id lo4so20038360ejb.8 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 15:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=O2JOOITUfpWLPA5zXdb0+ns87uh6CGGLPvAJg7yQd5k=; b=RO+BU+mpqke5C2KFcp5+MTAN7fWnd4BA0dbHtF9NQnc4wSQR3bA9UDg8MbNhbIFiQY 89plITRITznsab8HGed6ITnW1VeEtmuqUoConOneS8SKt19DKmb5bWoZxcLx8WnmHiMR H5L95Pt2PaFpoa4Liz4xMhYWpGXi1dzMLcpkbenpvqViN/QDJhpK6IKnDrh4bH6iMhcT BzosaJb1nivrGmblFnN0L7cHykEMHvKnJ1g/Ws40TJsnJ3ycorQFijGFgrWFx991Aqn8 W/Z/zZdkP+ci6aHju5XNWIGhB0H5vn11Accf8OsIJnZFq8hPI14mYR3+bmNL4KM+aTZM aFdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=O2JOOITUfpWLPA5zXdb0+ns87uh6CGGLPvAJg7yQd5k=; b=SBFcyuC6Bu99Kw1LwCi9sybCJrH9FO1WcXCAEzeam33vdgKp3tIczcNZXcVTyNxtbs oo5TcIEw2NneF3u2U0DAHqpyfNH21B1znZDH71qNmJx8UUSxDUibwaCDjH5t6ynvEex+ eg0zyO4e9zrCTHtO72NyBHVdx8QxKvO6MdPqladP2q41kin+2ARcuIfPa10WNG+JxG58 KnyCAnLUZiJNnzfj30aYkjeGsU8nA5FfFhT5h1lhfses/KQTVp36SHwH124eo4eF41Iw bqJJXdvFaWFZy0YBkVs3hdl133sHu1ZPqu8bzFOcWZv7iZPgxUacLpa+yTeWAVaY9y91 Bb5g== X-Gm-Message-State: AOAM531X7EUZXtBallrJ0FSSS39gXUpPhsK2uvJ5Qsy1zT1b4bLr3TEg +SOonzzvbFC+sM5Ih/xVRIHyYRzBTcSsSbQc0ku1UQ== X-Google-Smtp-Source: ABdhPJw6Eq8CakgyvE4cuTbOrLLZPFXimnTYZLnTsseNtrKeGaJ6ptoQimWdIWrTbiSe98OgGadDCWWQND3/GYPSSJM= X-Received: by 2002:a17:906:6b95:: with SMTP id l21mr1714603ejr.317.1600728503012; Mon, 21 Sep 2020 15:48:23 -0700 (PDT) MIME-Version: 1.0 References: <20200918221357.3436905-1-danielwinkler@google.com> <20200918151041.Bluez.v2.2.If15d3d09724ded2bcc7240d29f6888f2ad12e723@changeid> <0E891E36-FA71-414C-9E60-596D253A82A5@holtmann.org> In-Reply-To: <0E891E36-FA71-414C-9E60-596D253A82A5@holtmann.org> From: Daniel Winkler <danielwinkler@google.com> Date: Mon, 21 Sep 2020 15:48:11 -0700 Message-ID: <CAP2xMbuXo0FMvi1Sv9bv2+neXaRMB=aAQ1F6N=fDEF7P2mP5dw@mail.gmail.com> Subject: Re: [Bluez PATCH v2 02/10] doc/mgmt-api: Add new MGMT interfaces to mgmt-api To: Marcel Holtmann <marcel@holtmann.org> Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, linux-bluetooth <linux-bluetooth@vger.kernel.org>, Sonny Sasaka <sonnysasaka@chromium.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.48 / 15.00 / 15.00 X-Rspamd-Queue-Id: 239C9A0B37 X-Rspamd-UID: 7ba351 Hello Marcel, thank you very much for the feedback! Some responses below: > I would rather return the value right away and only allow it when powered= on. I have already imposed a "powered" requirement for both MGMT advertising commands and in the documentation here. In our discussions regarding this feature, we had chosen to emit a Tx Power Selected event because these "extended" advertising commands may be used even on platforms without controller support for extended advertising features. In other words, we thought it would make more sense to emit a Tx Power Selected event when relevant, rather than always returning a Tx power in the MGMT response, even if it is not relevant. If you think I should return the selected Tx Power directly, I can do so. Perhaps we can populate the response with HCI_ADV_TX_POWER_NO_PREFERENCE if extended advertising is not available. Please let me know your thoughts. > I was thinking we rename Read Security Information Command and also retur= n these values there. I think it is a bit of waste to introduce yet another= command to return controller capabilities. My mistake, I was under the impression that you preferred adding a new command. I will look into adding the new Tx power range parameters to the "Read Security Information Command". Please let me know your preferred new name for the command. Thank you in advance for your help! Best, Daniel Winkler On Sat, Sep 19, 2020 at 11:07 PM Marcel Holtmann <marcel@holtmann.org> wrot= e: > > Hi Daniel, > > > This patch adds the following to mgmt-api: > > - Add Extended Advertising Parameters Command > > - Add Extended Advertising Data Command > > - Read Controller Capabilities Command > > - Advertisement Tx Power Selected Event > > > > Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > --- > > > > Changes in v2: > > - Removed extra space in Add Extended Advertising Parameters API > > > > doc/mgmt-api.txt | 242 +++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 242 insertions(+) > > > > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt > > index ca0d38469..62f976a11 100644 > > --- a/doc/mgmt-api.txt > > +++ b/doc/mgmt-api.txt > > @@ -3574,6 +3574,234 @@ Remove Advertisement Monitor Command > > Busy > > > > > > +Add Extended Advertising Parameters Command > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > + Command Code: 0x0054 > > + Controller Index: <controller id> > > + Command Parameters: Instance (1 Octet) > > + Flags (4 Octets) > > + Params (2 Octets) > > + Duration (2 Octets) > > + Timeout (2 Octets) > > + MinInterval (4 Octets) > > + MaxInterval (4 Octets) > > + TxPower (1 Octet) > > + Return Parameters: Instance (1 Octet) > > didn=E2=80=99t you also want to return the selected TxPower? We then also= have to agree to allow this command only when the controller is powered. > > > + > > + This command is used to configure the parameters for Bluetooth Lo= w > > + Energy advertising instance. This command is expected to be follo= wed > > + by an Add Extended Advertising Data command to complete and enabl= e > > + the advertising instance. > > + > > + Added advertising information with this command will not be visib= le > > + immediately if advertising is enabled via the Set Advertising > > + command. The usage of the Set Advertising command takes precedenc= e > > + over this command. Instance information is stored and will be > > + advertised once advertising via Set Advertising has been disabled= . > > + > > + The Instance identifier is a value between 1 and the number of > > + supported instances. The value 0 is reserved. > > + > > + With the Flags value the type of advertising is controlled and > > + the following flags are defined: > > + > > + 0 Switch into Connectable mode > > + 1 Advertise as Discoverable > > + 2 Advertise as Limited Discoverable > > + 3 Add Flags field to Adv_Data > > + 4 Add TX Power field to Adv_Data > > + 5 Add Appearance field to Scan_Rsp > > + 6 Add Local Name in Scan_Rsp > > + 7 Secondary Channel with LE 1M > > + 8 Secondary Channel with LE 2M > > + 9 Secondary Channel with LE Coded > > + > > + When the connectable flag is set, then the controller will use > > + undirected connectable advertising. The value of the connectable > > + setting can be overwritten this way. This is useful to switch a > > + controller into connectable mode only for LE operation. This is > > + similar to the mode 0x02 from the Set Advertising command. > > + > > + When the connectable flag is not set, then the controller will > > + use advertising based on the connectable setting. When using > > + non-connectable or scannable advertising, the controller will > > + be programmed with a non-resolvable random address. When the > > + system is connectable, then the identity address or resolvable > > + private address will be used. > > + > > + Using the connectable flag is useful for peripheral mode support > > + where BR/EDR (and/or LE) is controlled by Add Device. This allows > > + making the peripheral connectable without having to interfere > > + with the global connectable setting. > > + > > + Secondary channel flags can be used to advertise in secondary > > + channel with the corresponding PHYs. These flag bits are mutually > > + exclusive and setting multiple will result in Invalid Parameter > > + error. Choosing either LE 1M or LE 2M will result in using > > + extended advertising on the primary channel with LE 1M and the > > + respectively LE 1M or LE 2M on the secondary channel. Choosing > > + LE Coded will result in using extended advertising on the primary > > + and secondary channels with LE Coded. Choosing none of these flag= s > > + will result in legacy advertising. > > + > > + To allow future parameters to be optionally extended in this stru= cture, > > + the Params member is used to specify which of the structure field= s were > > + purposefully set by the caller. Unspecified parameters will be gi= ven > > + sensible defaults by the kernel before the advertisement is regis= tered. > > + The Params bit field uses the following bit to parameter relation= ship: > > + > > + 0 The Duration parameter should be used > > + 1 The Timeout parameter should be used > > + 2 The Interval parameters should be used > > + 3 The Tx Power parameter should be used > > + > > + The Duration parameter configures the length of an Instance. The > > + value is in seconds. The default is 2 seconds. > > + > > + If only one advertising Instance has been added, then the Duratio= n > > + value will be ignored. It only applies for the case where multipl= e > > + Instances are configured. In that case every Instance will be > > + available for the Duration time and after that it switches to > > + the next one. This is a simple round-robin based approach. > > + > > + The Timeout parameter configures the life-time of an Instance. In > > + case the value 0 is used it indicates no expiration time. If a > > + timeout value is provided, then the advertising Instance will be > > + automatically removed when the timeout passes. The value for the > > + timeout is in seconds. Powering down a controller will invalidate > > + all advertising Instances and it is not possible to add a new > > + Instance with a timeout when the controller is powered down. > > + > > + When a Timeout is provided, then the Duration subtracts from > > + the actual Timeout value of that Instance. For example an Instanc= e > > + with Timeout of 5 and Duration of 2 will be scheduled exactly 3 > > + times, twice with 2 seconds and once with one second. Other > > + Instances have no influence on the Timeout. > > + > > + MinInterval and MaxInterval define the minimum and maximum advert= ising > > + intervals, with units as number of .625ms advertising slots. The = Max > > + interval is expected to be greater than or equal to the Min inter= val, > > + and both must have values in the range [0x000020, 0xFFFFFF]. If e= ither > > + condition is not met, the registration will fail. > > + > > + The provided Tx Power parameter will only be used if the controll= er > > + supports it, which can be determined by the presence of the > > + CanSetTxPower member of the Read Advertising Features command. > > + > > + The acceptable range for requested Tx Power is defined in the spe= c > > + (Version 5.2 | Vol 4, Part E, page 2585) to be [-127, +20] dBm, a= nd the > > + controller will select a power value up to the requested one. The > > + transmission power selected by the controller is not guaranteed > > + to match the requested one, but the caller can determine the powe= r > > + chosen by the controller by listening for the Tx Power Selected M= GMT > > + event that follows this command. If the requested Tx Power is out= side > > + the valid range, the registration will fail. > > + > > + Re-adding an already existing instance (i.e. issuing the Add Exte= nded > > + Advertising Parameters command with an Instance identifier of an > > + existing instance) will update that instance's configuration. > > + > > + An instance being added or changed while another instance is > > + being advertised will not be visible immediately but only when > > + the new/changed instance is being scheduled by the round robin > > + advertising algorithm. > > + > > + Changes to an instance that is currently being advertised will > > + cancel that instance and switch to the next instance. The changes > > + will be visible the next time the instance is scheduled for > > + advertising. In case a single instance is active, this means > > + that changes will be visible right away. > > + > > + LE must already be enabled, and the controller must be powered, > > + otherwise a "rejected" status will be returned. > > + > > + This command generates a Command Complete event on success or a > > + Command Status event on failure. > > + > > + Possible errors: Failed > > + Rejected > > + Not Supported > > + Invalid Parameters > > + Busy > > + > > + > > +Add Extended Advertising Data Command > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > + Command Code: 0x0055 > > + Controller Index: <controller id> > > + Command Parameters: Instance (1 Octet) > > + Advertising Data Length (1 Octet) > > + Scan Response Length (1 Octet) > > + Advertising Data (0-255 Octets) > > + Scan Response (0-255 Octets) > > + Return Parameters: Instance (1 Octet) > > + > > + The Add Extended Advertising Data command is used to update the > > + advertising data of an existing advertising instance known to the > > + kernel. It is expected to be called after an Add Extended Adverti= sing > > + Parameters command, as part of the advertisement registration > > + process. > > + > > + If extended advertising is available, this call will initiate HCI > > + commands to set the instance's advertising data, set scan respons= e > > + data, and then enable the instance. If extended advertising is > > + unavailable, the advertising instance structure maintained in ker= nel > > + will have its advertising data and scan response updated, and the > > + instance will either be scheduled immediately or left in the queu= e > > + for later advertisement as part of round-robin advertisement rota= tion > > + in software. > > + > > + If Scan_Rsp_Len is zero and the flags defined in Add Extended > > + Advertising Parameters command do not have connectable flag set a= nd > > + the global connectable setting is off, then non-connectable > > + advertising is used. If Scan_Rsp_Len is larger than zero and > > + connectable flag is not set and the global advertising is off, > > + then scannable advertising is used. This small difference is > > + supported to provide less air traffic for devices implementing > > + broadcaster role. > > + > > + If the Instance provided does not match a known instance, or if t= he > > + provided advertising data or scan response are in an unrecognized > > + format, an "Invalid Parameters" status will be returned. > > + > > + If a "Set LE" or Advertising command is still in progress, a "Bus= y" > > + status will be returned. > > + > > + If the controller is not powered, a "rejected" status will be ret= urned. > > + > > + This command generates a Command Complete event on success or a > > + Command Status event on failure. > > + > > + Possible errors: Failed > > + Rejected > > + Invalid Parameters > > + Busy > > + > > + > > +Read Controller Capabilities Command > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > + Command Code: 0x0056 > > + Controller Index: <controller id> > > + Command Parameters: > > + Return Parameters: Parameter1 { > > + Capability_Tag (2 Octet) > > + Value_Length (1 Octet) > > + Value (0-255 Octets) > > + } > > + Parameter2 { } > > + ... > > + > > + This command is used to read a list of controller capabilities. > > + > > + Currently defined Capability_Tag values are: > > + > > + 0x0000 Minimum Supported LE Tx Power (dBm) > > + 0x0001 Maximum Supported LE Tx Power (dBm) > > + > > + > > I was thinking we rename Read Security Information Command and also retur= n these values there. I think it is a bit of waste to introduce yet another= command to return controller capabilities. > > > Command Complete Event > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > @@ -4577,3 +4805,17 @@ Advertisement Monitor Removed Event > > > > The event will only be sent to management sockets other than the > > one through which the command was sent. > > + > > + > > +Advertisement Tx Power Selected Event > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > + Event Code: 0x002d > > + Controller Index: <controller id> > > + Event Parameters: Instance (1 Octet) > > + TxPower (1 Octet) > > + > > + This event indicates that the controller selected a transmission > > + power for an advertising instance. The event is emitted on platfo= rms > > + that support extended advertising after an Add Extended Advertisi= ng > > + Parameters command is submitted. > > I would rather return the value right away and only allow it when powered= on. > > Regards > > Marcel > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GGKlNd0vaV81UwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 00:57:33 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id cLLJMd0vaV+6jwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 00:57:33 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 18A9DA0B30; Tue, 22 Sep 2020 00:57:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728740AbgIUW5Z (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 18:57:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728692AbgIUW5Z (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 18:57:25 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12FFAC061755 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 15:57:25 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id h17so13940302otr.1 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 15:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MH0P0r0uSlPsLN6aTeqm3l1nxVCj3FoC86O/mxqg72Q=; b=DgqgY/yovmO65SlHtlUuEt+Kye7ElQDc+3chGHV6SK+Q9uIwhY/1SVb/hZMmaUA4pR daeU+Pp6RB8aSdM+jHTrWVPZ1jYer3T0ISaI2TvrLNFS5pM1sUTDrUPtKrLDVVp9Q0b4 EK50NfcdHKduP70JVF1UbVl9VVepyYfO36YWVHB8+sJcWPkBtT+0SO9wSihmSaQt3t7W Ky2/sgG36f9TzD5Cts80L5aMztr4LnmCQhnUC+eS8Qq09sDh9iLvjGe6EMn9F4NJzCe4 3CvXJkw2kEBKnM9QBBPj/KRqgfrIJMldHC5b5brXsJb9/eTYdE8adfE22dWdJMsqB44l pGTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MH0P0r0uSlPsLN6aTeqm3l1nxVCj3FoC86O/mxqg72Q=; b=Cy1xr+Scr9XLfDPA4FcwVFUg6lLsqk8KF5GeCfjMVDZSIO9BN2VZ78Kmg3AB0kLxCz E7xpumnntEn0uyJGty2FnlXl8rA/bGU1hMycEhu3JNxsadP9FK2W6JyfrD9Uf51ebWL0 5Mpc0IBBKrFu0OojgFYN+MMnUAwT1Jtvd77JxRVZMktMi0Bl9BMRCvKDcmRXrXiGz2vg HqUZtcdDqts/NveY4PxFOwVhM/2Yu/z42MZJ7EGyfmf2bazCnk9uv534aeMI/DAdsvl/ FVRtKSp4lf0gKhFk76cM3x0E0xPoAAgTJo8c4Y3J+9h6lua4OrAHmsuXiuFT6WJ4Sgob Wicg== X-Gm-Message-State: AOAM532WkZ2MEY2063JrkML1PwRVnZFelas+84lBiahWn73UHvB281zs rTmP2TOntsozwcPF5ZfZcfNOpa/cq6VsOC5RtzE= X-Google-Smtp-Source: ABdhPJwc1zD+/muV2b0NT0+BUnyBOXUAHvaAaajAh3LFPuPmGb3+0IpA4+9Rax994b5EJOcV/rI3hMd3BvyKuArDyUs= X-Received: by 2002:a05:6830:22e6:: with SMTP id t6mr1023305otc.88.1600729044181; Mon, 21 Sep 2020 15:57:24 -0700 (PDT) MIME-Version: 1.0 References: <20200917221034.154218-1-sonnysasaka@chromium.org> <CABBYNZ+d=dtHAtHOi7es_dGx4B7WnrE1dHnd_W1UvXRH0DVSog@mail.gmail.com> <CAO271mny2RkCtb8Cs6uEcLNHhSSVcFoCa24gMATubJXPRCmB2Q@mail.gmail.com> In-Reply-To: <CAO271mny2RkCtb8Cs6uEcLNHhSSVcFoCa24gMATubJXPRCmB2Q@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 21 Sep 2020 15:57:11 -0700 Message-ID: <CABBYNZK637+AfVfFVrdv9X_PEw9qrXTp5+r1EuG+50acqH39kw@mail.gmail.com> Subject: Re: [PATCH BlueZ v2] a2dp: Keep track of ref ownership of a2dp_setup To: Sonny Sasaka <sonnysasaka@chromium.org> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Alain Michaud <alainm@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.45 / 15.00 / 15.00 X-Rspamd-Queue-Id: 18A9DA0B30 X-Rspamd-UID: 8ae047 Hi Sonny, On Fri, Sep 18, 2020 at 11:41 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > Hi Luiz, > > On Fri, Sep 18, 2020 at 10:43 AM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Sonny, > > > > On Thu, Sep 17, 2020 at 3:13 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote: > > > > > > Currently transport_cb and abort_cfm make assumption that they have an > > > a2dp_setup reference held as a result of open_ind invocation. In the > > > field this is not always true, for example when the peer device opens an > > > L2CAP channel for AVDTP transport channel without sending AVDTP_OPEN > > > request through the AVDTP signaling channel first. Although in this case > > > the peer device does not behave correctly, we should protect this > > > possible crash from happening by making sure that transport_cb and > > > abort_cfm are really holding a reference of a2dp_setup object before > > > trying to unref them. > > > > > > After grabbing a reference, open_ind stores the pointer in > > > stream->user_data. If this field is set, that means there is a pending > > > AVDTP_OPEN command and it needs to be unref-fed later once and only > > > once: when the transport channel is created (transport_cb) or when the > > > AVDTP_OPEN command is aborted (abort_cfm). If this field is not set, > > > nothing should unref it. This enforces that the reference counting is > > > correct regardless of the behavior of the peer device. > > > > > > A sample crash stack trace from Chrome OS: > > > * thread #1, stop reason = signal SIGSEGV > > > * frame #0: 0x0c64f0e8 bluetoothd`queue_remove_all at queue.c:351 > > > frame #1: 0x0c64f086 bluetoothd`queue_destroy at queue.c:73 > > > frame #2: 0x0c6022b0 bluetoothd`setup_unref at a2dp.c:222 > > > frame #3: 0x0c604942 bluetoothd`transport_cb at a2dp.c:2229 > > > frame #4: 0x0c61e35c bluetoothd`accept_cb at btio.c:203 > > > frame #5: 0xf679523c libglib-2.0.so.0`g_main_context_dispatch at gmain.c:3182 > > > frame #6: 0xf67954aa libglib-2.0.so.0`g_main_context_iterate at gmain.c:3920 > > > frame #7: 0xf679569a libglib-2.0.so.0`g_main_loop_run at gmain.c:4116 > > > frame #8: 0x0c65a5a0 bluetoothd`mainloop_run at mainloop-glib.c:79 > > > frame #9: 0x0c65a7ea bluetoothd`mainloop_run_with_signal at mainloop-notify.c:201 > > > frame #10: 0x0c6477ec bluetoothd`main at main.c:772 > > > frame #11: 0xf65bc0a2 libc.so.6`__libc_start_main at libc-start.c:308 > > > > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > > > > > --- > > > profiles/audio/a2dp.c | 34 ++++++++++++++++++++++++++-------- > > > profiles/audio/avdtp.c | 17 +++++++++++++++++ > > > profiles/audio/avdtp.h | 5 +++++ > > > 3 files changed, 48 insertions(+), 8 deletions(-) > > > > > > diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c > > > index 2feea66c0..26147f96e 100644 > > > --- a/profiles/audio/a2dp.c > > > +++ b/profiles/audio/a2dp.c > > > @@ -915,6 +915,11 @@ static void update_last_used(struct a2dp_channel *chan, struct a2dp_sep *lsep, > > > avdtp_get_seid(rsep)); > > > } > > > > > > +static void destroy_setup(void *data) > > > +{ > > > + setup_unref(data); > > > +} > > > + > > > static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep, > > > struct avdtp_stream *stream, uint8_t *err, > > > void *user_data) > > > @@ -927,10 +932,21 @@ static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep, > > > else > > > DBG("Source %p: Open_Ind", sep); > > > > > > + if (avdtp_stream_get_user_data(stream)) { > > > + warn("setup already exists"); > > > + return FALSE; > > > + } > > > > I've sent a patch fixing the code when Open is sent multiple times, we > > were actually overwriting pending_open and its timer, I think it might > > be the source of these crashes, not an unbalanced reference of the > > setup. Also it is possible that the headsets doing this sort of > > operation would like us to start the L2CAP connection procedure so we > > could perhaps attempt to connect it after a sorter timer, but it might > > be hard to check how well it would work without having such a headset > > to test if it really does help. > > Thanks for the patch. Although your patch "Fix not checking if stream > is already set as pending open" solves an issue, this is not the issue > that we are experiencing in the field. We don't have a device that can > reproduce the crashes, but we got evidence from custom log messages > that the crashes are caused by "the peer device opens an L2CAP channel > for AVDTP transport channel without sending AVDTP_OPEN request through > the AVDTP signaling channel first", as I described in the commit > message of this patch. So, I believe we still need to fix that. We > could solve that in avdtp by not allowing that peer behavior, but what > this patch is fixing is the generic reference counting bug by having a > proper reference ownership proof such that if we follow this > principles, we can guarantee correct ref counting and avoid even other > crashes due to unhandled unexpected peer behavior. Well if we had received an Open request without pending_open being set that afaik will never reach cfm->open callback since the connection is dropped when that happens: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/profiles/audio/avdtp.c#n3155 https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/profiles/audio/a2dp.c#n2244 Or perhaps what you are actually suggesting that setup_unref will free the setup and then the subsequent cfm->open will attempt to access it? If the setup_free has been called then find_setup_by_session should no longer be able to find it so this shouldn't cause any crash afaik. That said it may be a better idea to actually treat the L2CAP connection request as Open since they may be dispatched together, that way we make this headset also work even though they not really following the spec to the letter. > > > > > setup = a2dp_setup_get(session); > > > if (!setup) > > > return FALSE; > > > > > > + /* > > > + * Use avdtp_stream's user_data to keep the reference ownership of the > > > + * setup object. This ensures that this reference will be unref-ed > > > + * exactly once. > > > + */ > > > + avdtp_stream_set_user_data(stream, setup, destroy_setup); > > > setup->stream = stream; > > > > > > if (!err && setup->chan) > > > @@ -1285,14 +1301,13 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, > > > void *user_data) > > > { > > > struct a2dp_sep *a2dp_sep = user_data; > > > - struct a2dp_setup *setup; > > > + struct a2dp_setup *setup = avdtp_stream_get_user_data(stream); > > > > > > if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK) > > > DBG("Sink %p: Abort_Cfm", sep); > > > else > > > DBG("Source %p: Abort_Cfm", sep); > > > > > > - setup = find_setup_by_session(session); > > > if (!setup) > > > return; > > > > > > @@ -1302,6 +1317,7 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep, > > > } > > > > > > setup_unref(setup); > > > + avdtp_stream_set_user_data(stream, NULL, NULL); > > > } > > > > > > static gboolean reconf_ind(struct avdtp *session, struct avdtp_local_sep *sep, > > > @@ -2216,11 +2232,12 @@ fail: > > > > > > static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > > > { > > > - struct a2dp_setup *setup = user_data; > > > + struct avdtp_stream *stream = user_data; > > > + struct a2dp_setup *setup = avdtp_stream_get_user_data(stream); > > > uint16_t omtu, imtu; > > > > > > - if (!g_slist_find(setups, setup)) { > > > - warn("bt_io_accept: setup %p no longer valid", setup); > > > + if (!setup) { > > > + warn("transport_cb: setup does not exist"); > > > g_io_channel_shutdown(io, TRUE, NULL); > > > return; > > > } > > > @@ -2238,8 +2255,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > > > goto drop; > > > } > > > > > > - if (!avdtp_stream_set_transport(setup->stream, > > > - g_io_channel_unix_get_fd(io), > > > + if (!avdtp_stream_set_transport(stream, g_io_channel_unix_get_fd(io), > > > imtu, omtu)) > > > goto drop; > > > > > > @@ -2249,6 +2265,7 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data) > > > setup->io = NULL; > > > > > > setup_unref(setup); > > > + avdtp_stream_set_user_data(stream, NULL, NULL); > > > > > > return; > > > > > > @@ -2297,7 +2314,8 @@ static void confirm_cb(GIOChannel *io, gpointer data) > > > goto drop; > > > } > > > > > > - if (!bt_io_accept(io, transport_cb, setup, NULL, &err)) { > > > + if (!bt_io_accept(io, transport_cb, setup->stream, NULL, > > > + &err)) { > > > error("bt_io_accept: %s", err->message); > > > g_error_free(err); > > > goto drop; > > > diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c > > > index 782268c08..76d06f47c 100644 > > > --- a/profiles/audio/avdtp.c > > > +++ b/profiles/audio/avdtp.c > > > @@ -366,6 +366,8 @@ struct avdtp_stream { > > > GSList *caps; > > > GSList *callbacks; > > > struct avdtp_service_capability *codec; > > > + void *user_data; > > > + avdtp_stream_user_data_destroy_t user_data_destroy; > > > guint io_id; /* Transport GSource ID */ > > > guint timer; /* Waiting for other side to close or open > > > * the transport channel */ > > > @@ -727,6 +729,9 @@ static void stream_free(void *data) > > > g_slist_free_full(stream->callbacks, g_free); > > > g_slist_free_full(stream->caps, g_free); > > > > > > + if (stream->user_data && stream->user_data_destroy) > > > + stream->user_data_destroy(stream->user_data); > > > + > > > g_free(stream); > > > } > > > > > > @@ -3147,6 +3152,18 @@ struct avdtp_remote_sep *avdtp_stream_get_remote_sep( > > > return NULL; > > > } > > > > > > +void avdtp_stream_set_user_data(struct avdtp_stream *stream, void *data, > > > + avdtp_stream_user_data_destroy_t destroy) > > > +{ > > > + stream->user_data = data; > > > + stream->user_data_destroy = destroy; > > > +} > > > + > > > +void *avdtp_stream_get_user_data(struct avdtp_stream *stream) > > > +{ > > > + return stream->user_data; > > > +} > > > + > > > gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd, > > > size_t imtu, size_t omtu) > > > { > > > diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h > > > index 011fea89e..247e9df75 100644 > > > --- a/profiles/audio/avdtp.h > > > +++ b/profiles/audio/avdtp.h > > > @@ -133,6 +133,8 @@ typedef void (*avdtp_set_configuration_cb) (struct avdtp *session, > > > struct avdtp_stream *stream, > > > struct avdtp_error *err); > > > > > > +typedef void (*avdtp_stream_user_data_destroy_t)(void *data); > > > + > > > /* Callbacks for when a reply is received to a command that we sent */ > > > struct avdtp_sep_cfm { > > > void (*set_configuration) (struct avdtp *session, > > > @@ -260,6 +262,9 @@ gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream, > > > GSList *caps); > > > struct avdtp_remote_sep *avdtp_stream_get_remote_sep( > > > struct avdtp_stream *stream); > > > +void avdtp_stream_set_user_data(struct avdtp_stream *stream, void *data, > > > + avdtp_stream_user_data_destroy_t destroy); > > > +void *avdtp_stream_get_user_data(struct avdtp_stream *stream); > > > > > > unsigned int avdtp_add_state_cb(struct btd_device *dev, > > > avdtp_session_state_cb cb, void *user_data); > > > -- > > > 2.26.2 > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kOOvCSgxaV+zVQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 01:03:04 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id QMG7BigxaV+6jwAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 01:03:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8D85D40942; Tue, 22 Sep 2020 01:02:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728750AbgIUXC5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 19:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727693AbgIUXC5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 19:02:57 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A50EEC061755 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 16:02:57 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id m7so18934896oie.0 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 16:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=jIpvO3JBFKmFmDmgHQ+JYCNJpS0NlN/6NqbpCynEYPs=; b=Jm6XHRuIGVjJ/J+SEng04dSRuY4v74HvyQncP/xU7H6gsskGsldyDmYFtcxdjesr09 Guepsvtcqnzk83QwP4zbGfqDoJBg10vOvBmlxDpyDTymeUMyLkdFvdiwKJToBw165nEe HM9b9W6l6EjctuWnVjkfXwqS8PNxlR2u/lQYwiw3wjFw9pjoBXR8x61WTQ22zk97X7pU xw6xrzg/7KJL6dXTEPIU6qjIhZHuNDMK6SAxxJ4zk8fwV2oEApQb9MsbULsLvsNATINE 1CMs4Vn92L8fQhnVnpxkeLuNRIxFZ7QtFfJcMaHQEPIl/ZoFOhwyJf5lkDO9cIqECndy A6+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=jIpvO3JBFKmFmDmgHQ+JYCNJpS0NlN/6NqbpCynEYPs=; b=VLjJdLOd9D4QscL7i8MxDaphkNbUDkvD9hxQbJR7ZzycWvyNNZ/k/zfFhnZzK9xP7R TiTsm4ch6vUrbmo+7bSUkVHHEyKTjFai7WDRS1TaNVoOd0hRSzrqZ4cTrSsX2RX3FdQx 3I0L/0fy0Go6JWhstMTSMSvshNEb6siUHrp9qV2N4iY/VvgHfMuiLbmirFwlnS2TEUbF ogxUDyx223P+08/S4TQj9JIOXMO+bVydWwhxEZIH3Q0ndmrK/TV7h+2Myk6FjiLIWmqj gQcDlY6KjrvnK8S3rp0NPHVSR6kxdNnrN/E5OQZ7xKgjOSS0qnw1/9kqv1m09+04rJsH Bvkg== X-Gm-Message-State: AOAM532gI37Wzhv7LqFESVV+ZyM4Td/ojGLV2T/KsH3wksYnU5UrJqme o+BTzSSbGgJaHgFmYi8XC71m5u+67zGqlz34bYOdkJvk X-Google-Smtp-Source: ABdhPJxl/T+udIPnOSyW5u4ATnf9awci9wmi49hkgMSTq6T+2aeGb53SODfpmUNGvOVbyn0IFBMJQyoHSGLXXko9JVw= X-Received: by 2002:aca:3e08:: with SMTP id l8mr942302oia.152.1600729376768; Mon, 21 Sep 2020 16:02:56 -0700 (PDT) MIME-Version: 1.0 References: <20200918173436.3184738-1-luiz.dentz@gmail.com> In-Reply-To: <20200918173436.3184738-1-luiz.dentz@gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 21 Sep 2020 16:02:45 -0700 Message-ID: <CABBYNZLuWifcGnf-LbquAu5+9bPb6Ft=TgzAGSLB-yXMXqMSRA@mail.gmail.com> Subject: Re: [PATCH v2] avdtp: Fix not checking if stream is already set as pending open To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.66 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8D85D40942 X-Rspamd-UID: cffd4c Hi, On Fri, Sep 18, 2020 at 10:34 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > When receiving a Open command the stream will be set as pending_open but > the remote may attempt to send yet another Open command in the meantime > resulting in another setup and yet another timer leaving the old timer > active which will likely cause a crash when it expires. > --- > profiles/audio/avdtp.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c > index 782268c08..e0c6f44f0 100644 > --- a/profiles/audio/avdtp.c > +++ b/profiles/audio/avdtp.c > @@ -1687,7 +1687,7 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction, > > stream = sep->stream; > > - if (sep->ind && sep->ind->open) { > + if (sep->ind && sep->ind->open && !session->pending_open) { > if (!sep->ind->open(session, sep, stream, &err, > sep->user_data)) > goto failed; > @@ -1699,11 +1699,13 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction, > AVDTP_OPEN, NULL, 0)) > return FALSE; > > - stream->open_acp = TRUE; > - session->pending_open = stream; > - stream->timer = g_timeout_add_seconds(REQ_TIMEOUT, > + if (!session->pending_open) { > + stream->open_acp = TRUE; > + session->pending_open = stream; > + stream->timer = g_timeout_add_seconds(REQ_TIMEOUT, > stream_open_timeout, > stream); > + } > > return TRUE; > > -- > 2.26.2 Pushed. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id AA+fLkA4aV+HkwEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 01:33:20 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id oIuKK0A4aV8lOAEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 01:33:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 75F54A0B37; Tue, 22 Sep 2020 01:33:12 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728824AbgIUXdL (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 19:33:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbgIUXdL (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 19:33:11 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E35FFC061755 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 16:33:10 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id i17so18949385oig.10 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 16:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/lCR/DG6ejVXsZo6kKWKWFFT9K3eyakkFtTCd1YSpk4=; b=Ke8H/JNNdRwiK40qZYgKUik82DOXGnsxw7f79f+R2zhG8ymH60Y0anLTblWwBSamzQ iIfJ6B3CsNcicdXfRkSBZbt9HSm2jDU0HqwEfIRrpGVq0jxNn8yDgVq3s79V8Z1kahMY ic639HNPUO4GvzvRBXxLw8Y7OYm8d0FhopABM/gu6r14bzMH9bQmCxOaVoQD469Kv03n 2HbZo+zvSJ/h070wppkHyd5PkFFsfu88EAvCGFFkxpOo+uRVEhQzlYzQ1nspTxBxz3gP IaVfG69T2rePR3sv698kVrLa2eqRhJJNCexH5pNoWK8iTsVAKVCBR1jXHEmSc+nw68xX oE+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/lCR/DG6ejVXsZo6kKWKWFFT9K3eyakkFtTCd1YSpk4=; b=FYcH0AtMDYeuZaRKDGLOUzN8Pa7R+hkyaAsUHfod772kl91VHUKxdCdeQOyZEU+F6m IkDpF4+s+lzyPzT9lyMfQy6CH3Gp2GusFyvKc/OVWUR8pYWggklvKildAXeIbrBUvdGI FmSIs64Fpf3bSzZs/VRqItTIGmsnbQuhWxRG0lRambxk6RDMShAKzjX2UG5pmiscuVwq fXg+rwq+qctghNJmFi3mYjfxuA9W370nE+kZOauX2E9ckBMA0zNqjkUX98fSRb3nfU/9 Eb/tWDHMOmTT+9PoDW12UqdPnOobb9JdNOIedw9E7x9w0UBZ8pkSbNdi5MBDkCCq3DFp HXXQ== X-Gm-Message-State: AOAM533tuhwHAczdtvD3NdArRorPBhmGZcAUYqM6yxr8Hix2I11rt2yq uCbat27xjpVjFT6RpiwFgaAF+oLcbrv2eIAS97Y= X-Google-Smtp-Source: ABdhPJy88nVhkBR78ee09KQ8DDy7fnnCVzUWtRCQEo33R3WqNxULFx2fO7mS1esWKJQlfaF/xjl0QpDs020WoPQuL2k= X-Received: by 2002:aca:38d7:: with SMTP id f206mr998895oia.48.1600731190076; Mon, 21 Sep 2020 16:33:10 -0700 (PDT) MIME-Version: 1.0 References: <20200921190040.45309-1-tedd.an@linux.intel.com> In-Reply-To: <20200921190040.45309-1-tedd.an@linux.intel.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 21 Sep 2020 16:32:57 -0700 Message-ID: <CABBYNZKX+a1DfbwN8=NLd=PNVU9KZcQ+=XVntbX5gYHBa5wW1A@mail.gmail.com> Subject: Re: [BlueZ V4 RESEND 00/20] Add SPDX License Identifier To: Tedd Ho-Jeong An <tedd.an@linux.intel.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Tedd Ho-Jeong An <tedd.an@intel.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -7.21 / 15.00 / 15.00 X-Rspamd-Queue-Id: 75F54A0B37 X-Rspamd-UID: 0a3012 HI Tedd, On Mon, Sep 21, 2020 at 12:28 PM <tedd.an@linux.intel.com> wrote: > > From: Tedd Ho-Jeong An <tedd.an@intel.com> > > This series adds SPDX License Identifer to the relavant files and > creates LICENSES folder with full text of licenses used by the BlueZ > tree. The following files were updated with SPDX License Identifier: > - Source and header files (.c/.h) > - Build files (Makefile.*) > - Test scripts (python, bash, and etc) > > The SDPX License Identifier is added in form of a comment based on file > type with the same rule from the Linxu kernel source, and added to the > first line of the file or the second line after '#!PATH_TO_INTERPRETER'. > > C source: // SPDX-License-Identifer: <License id> > C header: /* SPDX-License-Identifer: <License id> */ > scripts: # SPDX-License-Identifier: <License id> > > For SPDX-License Identifier, it used the identifer from the SPDX License > list page(https://spdx.org/licenses). > > For the summary, currently BlueZ sources have following licenses: > > ------------------------------------------- > License File Count > ------------------------------------------- > GPL-2.0-or-later : 403 > LGPL-2.1-or-later : 308 > BSD-2-Clause : 3 > GPL-2.0-only : 5 > MIT : 2 > Apache-2.0 : 80 > > Note that these folder/files were ignored: > - .git/ > - document files > - configuration files > > Tedd Ho-Jeong An (20): > android: Add SPDX License Identifier > attrib: Add SPDX License Identifier > btio: Add SPDX License Identifier > client: Add SPDX License Identifier > emulator: Add SPDX License Identifier > gdbus: Add SPDX License Identifier > gobex: Add SPDX License Identifier > lib: Add SPDX License Identifier > mesh: Add SPDX License Identifier > monitor: Add SPDX License Identifier > obexd: Add SPDX License Identifier > peripheral: Add SPDX License Identifier > plugins: Add SPDX License Identifier > profiles: Add SPDX License Identifier > unit: Add SPDX License Identifier > src: Add SPDX License Identifier > tools: Add SPDX License Identifier > build: Add SPDX License Identifier > test: Add SPDX License Identifier > LICENSES: Add License files > > LICENSES/dual/Apache-2.0 | 187 +++++++++++ > LICENSES/preferred/BSD-2-Clause | 32 ++ > LICENSES/preferred/GPL-2.0 | 354 ++++++++++++++++++++ > LICENSES/preferred/LGPL-2.1 | 503 +++++++++++++++++++++++++++++ > LICENSES/preferred/MIT | 30 ++ > Makefile.am | 2 +- > Makefile.mesh | 1 + > Makefile.obexd | 1 + > Makefile.plugins | 2 +- > Makefile.tools | 2 +- > android/a2dp-sink.c | 15 +- > android/a2dp-sink.h | 15 +- > android/a2dp.c | 15 +- > android/a2dp.h | 15 +- > android/audio-msg.h | 15 +- > android/audio_utils/resampler.c | 12 +- > android/audio_utils/resampler.h | 12 +- > android/avctp.c | 15 +- > android/avctp.h | 15 +- > android/avdtp.c | 15 +- > android/avdtp.h | 15 +- > android/avdtptest.c | 15 +- > android/avrcp-lib.c | 15 +- > android/avrcp-lib.h | 15 +- > android/avrcp.c | 15 +- > android/avrcp.h | 15 +- > android/bluetooth.c | 15 +- > android/bluetooth.h | 15 +- > android/bluetoothd-snoop.c | 15 +- > android/bluetoothd-wrapper.c | 13 +- > android/client/haltest.c | 13 +- > android/client/history.c | 13 +- > android/client/history.h | 13 +- > android/client/if-audio.c | 13 +- > android/client/if-av-sink.c | 13 +- > android/client/if-av.c | 13 +- > android/client/if-bt.c | 13 +- > android/client/if-gatt.c | 13 +- > android/client/if-hf-client.c | 13 +- > android/client/if-hf.c | 13 +- > android/client/if-hh.c | 13 +- > android/client/if-hl.c | 13 +- > android/client/if-main.h | 13 +- > android/client/if-mce.c | 13 +- > android/client/if-pan.c | 13 +- > android/client/if-rc-ctrl.c | 13 +- > android/client/if-rc.c | 13 +- > android/client/if-sco.c | 13 +- > android/client/if-sock.c | 13 +- > android/client/pollhandler.c | 13 +- > android/client/pollhandler.h | 13 +- > android/client/tabcompletion.c | 13 +- > android/client/terminal.c | 13 +- > android/client/terminal.h | 13 +- > android/compat/readline/history.h | 15 +- > android/compat/readline/readline.h | 15 +- > android/compat/wordexp.h | 15 +- > android/cutils/properties.h | 15 +- > android/gatt.c | 15 +- > android/gatt.h | 15 +- > android/hal-a2dp-sink.c | 13 +- > android/hal-a2dp.c | 13 +- > android/hal-audio-aptx.c | 13 +- > android/hal-audio-sbc.c | 13 +- > android/hal-audio.c | 13 +- > android/hal-audio.h | 13 +- > android/hal-avrcp-ctrl.c | 13 +- > android/hal-avrcp.c | 13 +- > android/hal-bluetooth.c | 13 +- > android/hal-gatt.c | 13 +- > android/hal-handsfree-client.c | 13 +- > android/hal-handsfree.c | 13 +- > android/hal-health.c | 13 +- > android/hal-hidhost.c | 13 +- > android/hal-ipc.c | 13 +- > android/hal-ipc.h | 13 +- > android/hal-log.h | 13 +- > android/hal-map-client.c | 13 +- > android/hal-msg.h | 15 +- > android/hal-pan.c | 13 +- > android/hal-sco.c | 13 +- > android/hal-socket.c | 13 +- > android/hal-utils.c | 13 +- > android/hal-utils.h | 13 +- > android/hal.h | 13 +- > android/handsfree-client.c | 15 +- > android/handsfree-client.h | 15 +- > android/handsfree.c | 15 +- > android/handsfree.h | 15 +- > android/hardware/audio.h | 12 +- > android/hardware/audio_effect.h | 12 +- > android/hardware/bluetooth.h | 12 +- > android/hardware/bt_av.h | 12 +- > android/hardware/bt_gatt.h | 12 +- > android/hardware/bt_gatt_client.h | 12 +- > android/hardware/bt_gatt_server.h | 12 +- > android/hardware/bt_gatt_types.h | 12 +- > android/hardware/bt_hf.h | 12 +- > android/hardware/bt_hf_client.h | 12 +- > android/hardware/bt_hh.h | 12 +- > android/hardware/bt_hl.h | 12 +- > android/hardware/bt_mce.h | 12 +- > android/hardware/bt_pan.h | 12 +- > android/hardware/bt_rc.h | 12 +- > android/hardware/bt_sock.h | 12 +- > android/hardware/hardware.c | 12 +- > android/hardware/hardware.h | 12 +- > android/health.c | 15 +- > android/health.h | 15 +- > android/hidhost.c | 15 +- > android/hidhost.h | 15 +- > android/ipc-common.h | 15 +- > android/ipc-tester.c | 15 +- > android/ipc.c | 15 +- > android/ipc.h | 15 +- > android/log.c | 15 +- > android/main.c | 15 +- > android/map-client.c | 15 +- > android/map-client.h | 15 +- > android/pan.c | 15 +- > android/pan.h | 15 +- > android/sco-msg.h | 15 +- > android/sco.c | 15 +- > android/sco.h | 15 +- > android/socket.c | 15 +- > android/socket.h | 15 +- > android/system-emulator.c | 15 +- > android/system/audio.h | 12 +- > android/test-ipc.c | 15 +- > android/tester-a2dp.c | 13 +- > android/tester-avrcp.c | 13 +- > android/tester-bluetooth.c | 13 +- > android/tester-gatt.c | 13 +- > android/tester-hdp.c | 13 +- > android/tester-hidhost.c | 13 +- > android/tester-main.c | 13 +- > android/tester-main.h | 15 +- > android/tester-map-client.c | 13 +- > android/tester-pan.c | 13 +- > android/tester-socket.c | 13 +- > android/utils.h | 15 +- > attrib/att-database.h | 15 +- > attrib/att.c | 15 +- > attrib/att.h | 15 +- > attrib/gatt-service.c | 15 +- > attrib/gatt-service.h | 15 +- > attrib/gatt.c | 15 +- > attrib/gatt.h | 15 +- > attrib/gattrib.c | 15 +- > attrib/gattrib.h | 15 +- > attrib/gatttool.c | 15 +- > attrib/gatttool.h | 15 +- > attrib/interactive.c | 15 +- > attrib/utils.c | 15 +- > btio/btio.c | 15 +- > btio/btio.h | 15 +- > client/adv_monitor.c | 11 +- > client/adv_monitor.h | 11 +- > client/advertising.c | 15 +- > client/advertising.h | 15 +- > client/agent.c | 15 +- > client/agent.h | 15 +- > client/display.c | 15 +- > client/display.h | 15 +- > client/gatt.c | 15 +- > client/gatt.h | 15 +- > client/main.c | 15 +- > configure.ac | 1 + > emulator/amp.c | 15 +- > emulator/amp.h | 15 +- > emulator/b1ee.c | 15 +- > emulator/btdev.c | 15 +- > emulator/btdev.h | 15 +- > emulator/bthost.c | 15 +- > emulator/bthost.h | 15 +- > emulator/hciemu.c | 15 +- > emulator/hciemu.h | 15 +- > emulator/hfp.c | 15 +- > emulator/le.c | 15 +- > emulator/le.h | 15 +- > emulator/main.c | 15 +- > emulator/phy.c | 15 +- > emulator/phy.h | 15 +- > emulator/serial.c | 15 +- > emulator/serial.h | 15 +- > emulator/server.c | 15 +- > emulator/server.h | 15 +- > emulator/smp.c | 15 +- > emulator/vhci.c | 15 +- > emulator/vhci.h | 15 +- > gdbus/client.c | 15 +- > gdbus/gdbus.h | 15 +- > gdbus/mainloop.c | 15 +- > gdbus/object.c | 15 +- > gdbus/polkit.c | 15 +- > gdbus/watch.c | 15 +- > gobex/gobex-apparam.c | 15 +- > gobex/gobex-apparam.h | 15 +- > gobex/gobex-debug.h | 15 +- > gobex/gobex-defs.c | 15 +- > gobex/gobex-defs.h | 15 +- > gobex/gobex-header.c | 15 +- > gobex/gobex-header.h | 15 +- > gobex/gobex-packet.c | 15 +- > gobex/gobex-packet.h | 15 +- > gobex/gobex-transfer.c | 15 +- > gobex/gobex.c | 15 +- > gobex/gobex.h | 15 +- > lib/a2mp.h | 15 +- > lib/amp.h | 10 +- > lib/bluetooth.c | 15 +- > lib/bluetooth.h | 15 +- > lib/bnep.h | 15 +- > lib/cmtp.h | 15 +- > lib/hci.c | 15 +- > lib/hci.h | 15 +- > lib/hci_lib.h | 15 +- > lib/hidp.h | 15 +- > lib/l2cap.h | 15 +- > lib/mgmt.h | 15 +- > lib/rfcomm.h | 15 +- > lib/sco.h | 15 +- > lib/sdp.c | 15 +- > lib/sdp.h | 15 +- > lib/sdp_lib.h | 15 +- > lib/uuid.c | 15 +- > lib/uuid.h | 15 +- > mesh/agent.c | 11 +- > mesh/agent.h | 11 +- > mesh/appkey.c | 11 +- > mesh/appkey.h | 11 +- > mesh/cfgmod-server.c | 11 +- > mesh/cfgmod.h | 11 +- > mesh/crypto.c | 11 +- > mesh/crypto.h | 11 +- > mesh/dbus.c | 11 +- > mesh/dbus.h | 11 +- > mesh/error.h | 11 +- > mesh/friend.c | 11 +- > mesh/friend.h | 11 +- > mesh/keyring.c | 11 +- > mesh/keyring.h | 11 +- > mesh/main.c | 11 +- > mesh/manager.c | 11 +- > mesh/manager.h | 11 +- > mesh/mesh-config-json.c | 11 +- > mesh/mesh-config.h | 11 +- > mesh/mesh-defs.h | 12 +- > mesh/mesh-io-api.h | 11 +- > mesh/mesh-io-generic.c | 11 +- > mesh/mesh-io-generic.h | 11 +- > mesh/mesh-io.c | 11 +- > mesh/mesh-io.h | 11 +- > mesh/mesh-mgmt.c | 11 +- > mesh/mesh-mgmt.h | 11 +- > mesh/mesh.c | 11 +- > mesh/mesh.h | 11 +- > mesh/model.c | 11 +- > mesh/model.h | 11 +- > mesh/net-keys.c | 11 +- > mesh/net-keys.h | 11 +- > mesh/net.c | 11 +- > mesh/net.h | 11 +- > mesh/node.c | 11 +- > mesh/node.h | 11 +- > mesh/pb-adv.c | 11 +- > mesh/pb-adv.h | 11 +- > mesh/prov-acceptor.c | 11 +- > mesh/prov-initiator.c | 11 +- > mesh/prov.h | 11 +- > mesh/provision.h | 11 +- > mesh/rpl.c | 11 +- > mesh/rpl.h | 11 +- > mesh/util.c | 11 +- > mesh/util.h | 11 +- > monitor/a2dp.c | 15 +- > monitor/a2dp.h | 15 +- > monitor/analyze.c | 15 +- > monitor/analyze.h | 15 +- > monitor/avctp.c | 15 +- > monitor/avctp.h | 15 +- > monitor/avdtp.c | 15 +- > monitor/avdtp.h | 15 +- > monitor/bnep.c | 15 +- > monitor/bnep.h | 15 +- > monitor/broadcom.c | 15 +- > monitor/broadcom.h | 15 +- > monitor/bt.h | 15 +- > monitor/control.c | 15 +- > monitor/control.h | 15 +- > monitor/crc.c | 15 +- > monitor/crc.h | 15 +- > monitor/display.c | 15 +- > monitor/display.h | 15 +- > monitor/ellisys.c | 15 +- > monitor/ellisys.h | 15 +- > monitor/hcidump.c | 15 +- > monitor/hcidump.h | 15 +- > monitor/hwdb.c | 15 +- > monitor/hwdb.h | 15 +- > monitor/intel.c | 15 +- > monitor/intel.h | 15 +- > monitor/jlink.c | 15 +- > monitor/jlink.h | 15 +- > monitor/keys.c | 15 +- > monitor/keys.h | 15 +- > monitor/l2cap.c | 15 +- > monitor/l2cap.h | 15 +- > monitor/ll.c | 15 +- > monitor/ll.h | 15 +- > monitor/lmp.c | 15 +- > monitor/lmp.h | 15 +- > monitor/main.c | 15 +- > monitor/packet.c | 15 +- > monitor/packet.h | 15 +- > monitor/rfcomm.c | 15 +- > monitor/rfcomm.h | 15 +- > monitor/sdp.c | 15 +- > monitor/sdp.h | 15 +- > monitor/tty.h | 15 +- > monitor/vendor.c | 15 +- > monitor/vendor.h | 15 +- > obexd/client/bluetooth.c | 15 +- > obexd/client/bluetooth.h | 15 +- > obexd/client/driver.c | 15 +- > obexd/client/driver.h | 15 +- > obexd/client/ftp.c | 15 +- > obexd/client/ftp.h | 15 +- > obexd/client/manager.c | 15 +- > obexd/client/manager.h | 15 +- > obexd/client/map-event.c | 15 +- > obexd/client/map-event.h | 15 +- > obexd/client/map.c | 15 +- > obexd/client/map.h | 15 +- > obexd/client/mns.c | 15 +- > obexd/client/opp.c | 15 +- > obexd/client/opp.h | 15 +- > obexd/client/pbap.c | 15 +- > obexd/client/pbap.h | 15 +- > obexd/client/session.c | 15 +- > obexd/client/session.h | 15 +- > obexd/client/sync.c | 15 +- > obexd/client/sync.h | 15 +- > obexd/client/transfer.c | 15 +- > obexd/client/transfer.h | 15 +- > obexd/client/transport.c | 15 +- > obexd/client/transport.h | 15 +- > obexd/plugins/bluetooth.c | 15 +- > obexd/plugins/filesystem.c | 15 +- > obexd/plugins/filesystem.h | 15 +- > obexd/plugins/ftp.c | 15 +- > obexd/plugins/ftp.h | 15 +- > obexd/plugins/irmc.c | 15 +- > obexd/plugins/mas.c | 15 +- > obexd/plugins/messages-dummy.c | 15 +- > obexd/plugins/messages-tracker.c | 15 +- > obexd/plugins/messages.h | 15 +- > obexd/plugins/opp.c | 15 +- > obexd/plugins/pbap.c | 15 +- > obexd/plugins/pcsuite.c | 15 +- > obexd/plugins/phonebook-dummy.c | 15 +- > obexd/plugins/phonebook-ebook.c | 15 +- > obexd/plugins/phonebook-tracker.c | 15 +- > obexd/plugins/phonebook.h | 15 +- > obexd/plugins/syncevolution.c | 15 +- > obexd/plugins/vcard.c | 15 +- > obexd/plugins/vcard.h | 15 +- > obexd/src/log.c | 15 +- > obexd/src/log.h | 15 +- > obexd/src/main.c | 15 +- > obexd/src/manager.c | 15 +- > obexd/src/manager.h | 15 +- > obexd/src/map_ap.h | 15 +- > obexd/src/mimetype.c | 15 +- > obexd/src/mimetype.h | 15 +- > obexd/src/obex-priv.h | 15 +- > obexd/src/obex.c | 15 +- > obexd/src/obex.h | 15 +- > obexd/src/obexd.h | 15 +- > obexd/src/plugin.c | 15 +- > obexd/src/plugin.h | 15 +- > obexd/src/server.c | 15 +- > obexd/src/server.h | 15 +- > obexd/src/service.c | 15 +- > obexd/src/service.h | 15 +- > obexd/src/transport.c | 15 +- > obexd/src/transport.h | 15 +- > peripheral/attach.c | 15 +- > peripheral/attach.h | 15 +- > peripheral/efivars.c | 15 +- > peripheral/efivars.h | 15 +- > peripheral/gap.c | 15 +- > peripheral/gap.h | 15 +- > peripheral/gatt.c | 15 +- > peripheral/gatt.h | 15 +- > peripheral/log.c | 15 +- > peripheral/log.h | 15 +- > peripheral/main.c | 15 +- > plugins/autopair.c | 15 +- > plugins/external-dummy.c | 15 +- > plugins/hostname.c | 15 +- > plugins/neard.c | 15 +- > plugins/policy.c | 15 +- > plugins/sixaxis.c | 15 +- > plugins/wiimote.c | 15 +- > profiles/audio/a2dp-codecs.h | 15 +- > profiles/audio/a2dp.c | 15 +- > profiles/audio/a2dp.h | 15 +- > profiles/audio/avctp.c | 15 +- > profiles/audio/avctp.h | 15 +- > profiles/audio/avdtp.c | 15 +- > profiles/audio/avdtp.h | 15 +- > profiles/audio/avrcp.c | 15 +- > profiles/audio/avrcp.h | 15 +- > profiles/audio/control.c | 15 +- > profiles/audio/control.h | 15 +- > profiles/audio/media.c | 15 +- > profiles/audio/media.h | 15 +- > profiles/audio/player.c | 15 +- > profiles/audio/player.h | 15 +- > profiles/audio/sink.c | 15 +- > profiles/audio/sink.h | 15 +- > profiles/audio/source.c | 15 +- > profiles/audio/source.h | 15 +- > profiles/audio/transport.c | 15 +- > profiles/audio/transport.h | 15 +- > profiles/battery/bas.c | 15 +- > profiles/battery/bas.h | 15 +- > profiles/battery/battery.c | 10 +- > profiles/cups/cups.h | 15 +- > profiles/cups/hcrp.c | 15 +- > profiles/cups/main.c | 15 +- > profiles/cups/sdp.c | 15 +- > profiles/cups/spp.c | 15 +- > profiles/deviceinfo/deviceinfo.c | 15 +- > profiles/deviceinfo/dis.c | 15 +- > profiles/deviceinfo/dis.h | 15 +- > profiles/gap/gas.c | 10 +- > profiles/health/hdp.c | 15 +- > profiles/health/hdp.h | 15 +- > profiles/health/hdp_main.c | 15 +- > profiles/health/hdp_manager.c | 15 +- > profiles/health/hdp_manager.h | 15 +- > profiles/health/hdp_types.h | 15 +- > profiles/health/hdp_util.c | 15 +- > profiles/health/hdp_util.h | 15 +- > profiles/health/mcap.c | 15 +- > profiles/health/mcap.h | 15 +- > profiles/iap/main.c | 15 +- > profiles/input/device.c | 15 +- > profiles/input/device.h | 15 +- > profiles/input/hidp_defs.h | 15 +- > profiles/input/hog-lib.c | 15 +- > profiles/input/hog-lib.h | 15 +- > profiles/input/hog.c | 15 +- > profiles/input/manager.c | 15 +- > profiles/input/server.c | 15 +- > profiles/input/server.h | 15 +- > profiles/input/sixaxis.h | 15 +- > profiles/input/suspend-dummy.c | 15 +- > profiles/input/suspend-none.c | 15 +- > profiles/input/suspend.h | 15 +- > profiles/midi/libmidi.c | 16 +- > profiles/midi/libmidi.h | 16 +- > profiles/midi/midi.c | 20 +- > profiles/network/bnep.c | 15 +- > profiles/network/bnep.h | 15 +- > profiles/network/connection.c | 15 +- > profiles/network/connection.h | 15 +- > profiles/network/manager.c | 15 +- > profiles/network/server.c | 15 +- > profiles/network/server.h | 15 +- > profiles/sap/main.c | 14 +- > profiles/sap/manager.c | 14 +- > profiles/sap/manager.h | 14 +- > profiles/sap/sap-dummy.c | 14 +- > profiles/sap/sap.h | 14 +- > profiles/sap/server.c | 14 +- > profiles/sap/server.h | 14 +- > profiles/scanparam/scan.c | 15 +- > profiles/scanparam/scpp.c | 15 +- > profiles/scanparam/scpp.h | 15 +- > src/adapter.c | 15 +- > src/adapter.h | 15 +- > src/adv_monitor.c | 11 +- > src/adv_monitor.h | 11 +- > src/advertising.c | 11 +- > src/advertising.h | 11 +- > src/agent.c | 15 +- > src/agent.h | 15 +- > src/attrib-server.c | 15 +- > src/attrib-server.h | 15 +- > src/backtrace.c | 15 +- > src/backtrace.h | 15 +- > src/dbus-common.c | 15 +- > src/dbus-common.h | 15 +- > src/device.c | 15 +- > src/device.h | 15 +- > src/eir.c | 15 +- > src/eir.h | 15 +- > src/error.c | 15 +- > src/error.h | 15 +- > src/gatt-client.c | 11 +- > src/gatt-client.h | 11 +- > src/gatt-database.c | 11 +- > src/gatt-database.h | 11 +- > src/hcid.h | 15 +- > src/log.c | 15 +- > src/log.h | 15 +- > src/main.c | 15 +- > src/oui.c | 15 +- > src/oui.h | 15 +- > src/plugin.c | 15 +- > src/plugin.h | 15 +- > src/profile.c | 15 +- > src/profile.h | 15 +- > src/rfkill.c | 15 +- > src/sdp-client.c | 15 +- > src/sdp-client.h | 15 +- > src/sdp-xml.c | 15 +- > src/sdp-xml.h | 15 +- > src/sdpd-database.c | 15 +- > src/sdpd-request.c | 15 +- > src/sdpd-server.c | 15 +- > src/sdpd-service.c | 15 +- > src/sdpd.h | 15 +- > src/service.c | 15 +- > src/service.h | 15 +- > src/shared/ad.c | 15 +- > src/shared/ad.h | 15 +- > src/shared/att-types.h | 15 +- > src/shared/att.c | 15 +- > src/shared/att.h | 15 +- > src/shared/btp.c | 15 +- > src/shared/btp.h | 15 +- > src/shared/btsnoop.c | 15 +- > src/shared/btsnoop.h | 15 +- > src/shared/crypto.c | 15 +- > src/shared/crypto.h | 15 +- > src/shared/ecc.c | 21 +- > src/shared/ecc.h | 21 +- > src/shared/gap.c | 15 +- > src/shared/gap.h | 15 +- > src/shared/gatt-client.c | 15 +- > src/shared/gatt-client.h | 15 +- > src/shared/gatt-db.c | 15 +- > src/shared/gatt-db.h | 15 +- > src/shared/gatt-helpers.c | 15 +- > src/shared/gatt-helpers.h | 15 +- > src/shared/gatt-server.c | 15 +- > src/shared/gatt-server.h | 15 +- > src/shared/hci-crypto.c | 15 +- > src/shared/hci-crypto.h | 15 +- > src/shared/hci.c | 15 +- > src/shared/hci.h | 15 +- > src/shared/hfp.c | 15 +- > src/shared/hfp.h | 15 +- > src/shared/io-ell.c | 15 +- > src/shared/io-glib.c | 15 +- > src/shared/io-mainloop.c | 15 +- > src/shared/io.h | 15 +- > src/shared/log.c | 15 +- > src/shared/log.h | 15 +- > src/shared/mainloop-ell.c | 12 +- > src/shared/mainloop-glib.c | 15 +- > src/shared/mainloop-notify.c | 15 +- > src/shared/mainloop-notify.h | 15 +- > src/shared/mainloop.c | 15 +- > src/shared/mainloop.h | 15 +- > src/shared/mgmt.c | 15 +- > src/shared/mgmt.h | 15 +- > src/shared/pcap.c | 15 +- > src/shared/pcap.h | 15 +- > src/shared/queue.c | 15 +- > src/shared/queue.h | 15 +- > src/shared/ringbuf.c | 15 +- > src/shared/ringbuf.h | 15 +- > src/shared/shell.c | 15 +- > src/shared/shell.h | 15 +- > src/shared/tester.c | 15 +- > src/shared/tester.h | 15 +- > src/shared/timeout-ell.c | 11 +- > src/shared/timeout-glib.c | 11 +- > src/shared/timeout-mainloop.c | 11 +- > src/shared/timeout.h | 11 +- > src/shared/tty.h | 15 +- > src/shared/uhid.c | 15 +- > src/shared/uhid.h | 15 +- > src/shared/util.c | 15 +- > src/shared/util.h | 15 +- > src/storage.c | 15 +- > src/storage.h | 15 +- > src/textfile.c | 15 +- > src/textfile.h | 15 +- > src/uinput.h | 15 +- > src/uuid-helper.c | 15 +- > src/uuid-helper.h | 15 +- > test/agent.py | 1 + > test/bluezutils.py | 2 + > test/dbusdef.py | 2 + > test/example-advertisement | 1 + > test/example-endpoint | 1 + > test/example-gatt-client | 1 + > test/example-gatt-server | 1 + > test/example-player | 1 + > test/exchange-business-cards | 1 + > test/ftp-client | 1 + > test/get-managed-objects | 1 + > test/get-obex-capabilities | 1 + > test/list-devices | 1 + > test/list-folders | 1 + > test/map-client | 1 + > test/monitor-bluetooth | 1 + > test/opp-client | 1 + > test/pbap-client | 1 + > test/sap_client.py | 15 +- > test/simple-agent | 1 + > test/simple-endpoint | 1 + > test/simple-obex-agent | 1 + > test/simple-player | 1 + > test/test-adapter | 1 + > test/test-device | 1 + > test/test-discovery | 1 + > test/test-gatt-profile | 1 + > test/test-health | 1 + > test/test-health-sink | 1 + > test/test-hfp | 1 + > test/test-join | 1 + > test/test-manager | 1 + > test/test-mesh | 1 + > test/test-nap | 1 + > test/test-network | 1 + > test/test-profile | 1 + > test/test-sap-server | 1 + > tools/3dsp.c | 15 +- > tools/advtest.c | 15 +- > tools/amptest.c | 15 +- > tools/avinfo.c | 15 +- > tools/avtest.c | 15 +- > tools/bccmd.c | 15 +- > tools/bcmfw.c | 15 +- > tools/bdaddr.c | 15 +- > tools/bluemoon.c | 15 +- > tools/bluetooth-player.c | 15 +- > tools/bnep-tester.c | 15 +- > tools/bneptest.c | 15 +- > tools/btattach.c | 15 +- > tools/btconfig.c | 15 +- > tools/btgatt-client.c | 15 +- > tools/btgatt-server.c | 11 +- > tools/btinfo.c | 15 +- > tools/btiotest.c | 15 +- > tools/btmgmt.c | 15 +- > tools/btmon-logger.c | 15 +- > tools/btpclient.c | 15 +- > tools/btpclientctl.c | 15 +- > tools/btproxy.c | 15 +- > tools/btsnoop.c | 15 +- > tools/check-selftest.c | 15 +- > tools/ciptool.c | 15 +- > tools/cltest.c | 15 +- > tools/create-image.c | 15 +- > tools/csr.c | 15 +- > tools/csr.h | 15 +- > tools/csr_3wire.c | 15 +- > tools/csr_bcsp.c | 15 +- > tools/csr_h4.c | 15 +- > tools/csr_hci.c | 15 +- > tools/csr_usb.c | 15 +- > tools/eddystone.c | 15 +- > tools/gap-tester.c | 15 +- > tools/gatt-service.c | 15 +- > tools/hci-tester.c | 15 +- > tools/hciattach.c | 15 +- > tools/hciattach.h | 15 +- > tools/hciattach_ath3k.c | 15 +- > tools/hciattach_bcm43xx.c | 15 +- > tools/hciattach_intel.c | 15 +- > tools/hciattach_qualcomm.c | 15 +- > tools/hciattach_st.c | 15 +- > tools/hciattach_ti.c | 15 +- > tools/hciattach_tialt.c | 15 +- > tools/hciconfig.c | 15 +- > tools/hcidump.c | 15 +- > tools/hcieventmask.c | 15 +- > tools/hcisecfilter.c | 15 +- > tools/hcitool.c | 15 +- > tools/hex2hcd.c | 15 +- > tools/hid2hci.c | 15 +- > tools/hwdb.c | 15 +- > tools/ibeacon.c | 15 +- > tools/l2cap-tester.c | 15 +- > tools/l2ping.c | 15 +- > tools/l2test.c | 15 +- > tools/mcaptest.c | 15 +- > tools/mesh-cfgclient.c | 11 +- > tools/mesh-gatt/config-client.c | 15 +- > tools/mesh-gatt/config-server.c | 15 +- > tools/mesh-gatt/crypto.c | 15 +- > tools/mesh-gatt/crypto.h | 15 +- > tools/mesh-gatt/gatt.c | 15 +- > tools/mesh-gatt/gatt.h | 15 +- > tools/mesh-gatt/keys.h | 15 +- > tools/mesh-gatt/mesh-net.h | 15 +- > tools/mesh-gatt/net.c | 15 +- > tools/mesh-gatt/net.h | 15 +- > tools/mesh-gatt/node.c | 15 +- > tools/mesh-gatt/node.h | 15 +- > tools/mesh-gatt/onoff-model.c | 15 +- > tools/mesh-gatt/onoff-model.h | 15 +- > tools/mesh-gatt/prov-db.c | 15 +- > tools/mesh-gatt/prov-db.h | 15 +- > tools/mesh-gatt/prov.c | 15 +- > tools/mesh-gatt/prov.h | 15 +- > tools/mesh-gatt/util.c | 15 +- > tools/mesh-gatt/util.h | 15 +- > tools/mesh/agent.c | 15 +- > tools/mesh/agent.h | 15 +- > tools/mesh/cfgcli.c | 12 +- > tools/mesh/cfgcli.h | 12 +- > tools/mesh/config-model.h | 15 +- > tools/mesh/keys.c | 12 +- > tools/mesh/keys.h | 12 +- > tools/mesh/mesh-db.c | 11 +- > tools/mesh/mesh-db.h | 11 +- > tools/mesh/model.h | 12 +- > tools/mesh/remote.c | 11 +- > tools/mesh/remote.h | 11 +- > tools/mesh/util.c | 11 +- > tools/mesh/util.h | 11 +- > tools/meshctl.c | 15 +- > tools/mgmt-tester.c | 15 +- > tools/mpris-proxy.c | 15 +- > tools/nokfw.c | 15 +- > tools/obex-client-tool.c | 14 +- > tools/obex-server-tool.c | 14 +- > tools/obexctl.c | 15 +- > tools/oobtest.c | 15 +- > tools/parse_companies.pl | 2 +- > tools/parser/amp.c | 15 +- > tools/parser/att.c | 15 +- > tools/parser/avctp.c | 15 +- > tools/parser/avdtp.c | 15 +- > tools/parser/avrcp.c | 15 +- > tools/parser/bnep.c | 15 +- > tools/parser/bpa.c | 15 +- > tools/parser/capi.c | 15 +- > tools/parser/cmtp.c | 15 +- > tools/parser/csr.c | 15 +- > tools/parser/ericsson.c | 15 +- > tools/parser/hci.c | 15 +- > tools/parser/hcrp.c | 15 +- > tools/parser/hidp.c | 15 +- > tools/parser/l2cap.c | 15 +- > tools/parser/l2cap.h | 15 +- > tools/parser/lmp.c | 15 +- > tools/parser/obex.c | 15 +- > tools/parser/parser.c | 15 +- > tools/parser/parser.h | 15 +- > tools/parser/ppp.c | 15 +- > tools/parser/rfcomm.c | 15 +- > tools/parser/rfcomm.h | 15 +- > tools/parser/sap.c | 15 +- > tools/parser/sdp.c | 15 +- > tools/parser/sdp.h | 15 +- > tools/parser/smp.c | 15 +- > tools/parser/tcpip.c | 15 +- > tools/rctest.c | 15 +- > tools/rfcomm-tester.c | 15 +- > tools/rfcomm.c | 15 +- > tools/rtlfw.c | 15 +- > tools/sco-tester.c | 15 +- > tools/scotest.c | 15 +- > tools/sdptool.c | 15 +- > tools/seq2bseq.c | 15 +- > tools/smp-tester.c | 15 +- > tools/test-runner.c | 15 +- > tools/ubcsp.c | 20 +- > tools/ubcsp.h | 20 +- > tools/update_compids.sh | 1 + > tools/userchan-tester.c | 15 +- > unit/test-avctp.c | 15 +- > unit/test-avdtp.c | 15 +- > unit/test-avrcp.c | 15 +- > unit/test-crc.c | 15 +- > unit/test-crypto.c | 15 +- > unit/test-ecc.c | 21 +- > unit/test-eir.c | 15 +- > unit/test-gatt.c | 15 +- > unit/test-gattrib.c | 15 +- > unit/test-gdbus-client.c | 15 +- > unit/test-gobex-apparam.c | 15 +- > unit/test-gobex-header.c | 15 +- > unit/test-gobex-packet.c | 15 +- > unit/test-gobex-transfer.c | 15 +- > unit/test-gobex.c | 15 +- > unit/test-hfp.c | 15 +- > unit/test-hog.c | 15 +- > unit/test-lib.c | 15 +- > unit/test-mesh-crypto.c | 11 +- > unit/test-mgmt.c | 15 +- > unit/test-midi.c | 16 +- > unit/test-queue.c | 15 +- > unit/test-ringbuf.c | 15 +- > unit/test-sdp.c | 15 +- > unit/test-textfile.c | 15 +- > unit/test-uhid.c | 15 +- > unit/test-uuid.c | 15 +- > unit/util.c | 14 +- > unit/util.h | 14 +- > 810 files changed, 1913 insertions(+), 10186 deletions(-) > create mode 100644 LICENSES/dual/Apache-2.0 > create mode 100644 LICENSES/preferred/BSD-2-Clause > create mode 100644 LICENSES/preferred/GPL-2.0 > create mode 100644 LICENSES/preferred/LGPL-2.1 > create mode 100644 LICENSES/preferred/MIT > > -- > 2.25.4 Applied, thanks. -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CN/TDe92aV+puAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 06:00:47 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id UOKkCu92aV9UigEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 06:00:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter06.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 19061A0BC5; Tue, 22 Sep 2020 06:00:40 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727393AbgIVEAj (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 22 Sep 2020 00:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726738AbgIVEAj (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 22 Sep 2020 00:00:39 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 957CCC061755 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 21:00:39 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id u24so32017pgi.1 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 21:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=WcyHzFEGyqBLAySN0HYRdtNWlWJxR0ZmcbFLUbUq37s=; b=e5QYFQjousD7sregzqOzTp6sl2MlVVya7HAb9l3FbKb7EFWRHYIdHmA8igtmtEyTDq Uq0XXFufe64WhMrvei8p4WetHdDiwnNLVqW81H5oG0kqEUdJfOC5iAY9Yl7yw4O84NHn ssjsGB2gK9mit647y7u7LxnE6PVQXcY0RLHwT4vMxSeyqdbDMddvwIm+kKIJICenbKPB O1RvgAcKacrTEUBqcTYastbG+xwrHgxGSXRvJ2VEzdExgOIhSyNUwUF9QvLI103zhdME 77g7rxr+/chjdJZItjUqkVkZtIvmoDt77kkNcb5PaidKk6nEuevZcOOIGtMXZ5DDDq12 VWrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WcyHzFEGyqBLAySN0HYRdtNWlWJxR0ZmcbFLUbUq37s=; b=VyY3dByelLRMK070AM9K3o9HbiTTU2BT0bZodyyd+HSLPJZeIKTLU5ox4wB01SDGx1 aAp2DgPiJVJB2em31uQiYfPMTkN8LRvjmDYD0qiVF+JykSaTEohWrWCDzmbvJTkDvDt8 h0SeiRH0lSaeJKfRJ1twSVzFsLRSb9hKS9G2E2AdaLq1M3qMsaH4xkd1Z9SJcMgyksAZ YNqaAa6R4RIuUKcxf0IpbsAJoFPBun4Ib3a3luTc3gP+uxJHnYdSG+NVI3W7Jy1p2bL1 J67aH70/sPzSN+eev2VY5bdBH+pqlI9LdPnq+eZi+3EblhkkHPKVp0NGQZ2DcWj4BeGx vFZg== X-Gm-Message-State: AOAM530q098xHziUw8eIrOe+S6Dej5JDieh84Upocxd0JnXmfQ9Pa202 PZnDXS7CGfqmecj1Ag29FnF6dkJkamA= X-Google-Smtp-Source: ABdhPJxi605/Q5q6cSKrHK+Jdmu0NehmEhVzKL9XLPzpm5xei5XeZg69DG317lkGt5OKkTb17bHrvg== X-Received: by 2002:a62:6444:0:b029:13e:d13d:a12d with SMTP id y65-20020a6264440000b029013ed13da12dmr2569002pfb.21.1600747238429; Mon, 21 Sep 2020 21:00:38 -0700 (PDT) Received: from localhost.localdomain ([122.179.23.229]) by smtp.gmail.com with ESMTPSA id w19sm13637324pfq.60.2020.09.21.21.00.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2020 21:00:37 -0700 (PDT) From: Kiran K <kiraank@gmail.com> X-Google-Original-From: Kiran K <kiran.k@intel.com> To: linux-bluetooth@vger.kernel.org Cc: chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com, dan.carpenter@oracle.com, kiraank@gmail.com, Kiran K <kiran.k@intel.com> Subject: [PATCH v1] Bluetooth: btintel: Fix issue reported by static analysis tool Date: Tue, 22 Sep 2020 09:30:19 +0530 Message-Id: <1600747219-11626-1-git-send-email-kiran.k@intel.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.29 / 15.00 / 15.00 X-Rspamd-Queue-Id: 19061A0BC5 X-Rspamd-UID: a44972 Smatch tool reported the below issue: drivers/bluetooth/btintel.c:490 btintel_read_version_tlv() error: 'tlv->len' from user is not capped properly Additional details in the below link https://www.spinics.net/lists/linux-bluetooth/msg87786.html Signed-off-by: Kiran K <kiran.k@intel.com> --- drivers/bluetooth/btintel.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index 88ce5f0..47f2b3d 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -431,62 +431,99 @@ int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *ver * version field like hw_platform, hw_variant, and fw_variant * to keep the existing setup flow */ - while (skb->len) { + while (skb->len >= sizeof(struct intel_tlv)) { struct intel_tlv *tlv; tlv = (struct intel_tlv *)skb->data; + if (struct_size(tlv, val, tlv->len) > skb->len) + goto failed; + switch (tlv->type) { case INTEL_TLV_CNVI_TOP: + if (tlv->len < sizeof(u32)) + goto failed; version->cnvi_top = get_unaligned_le32(tlv->val); break; case INTEL_TLV_CNVR_TOP: + if (tlv->len < sizeof(u32)) + goto failed; version->cnvr_top = get_unaligned_le32(tlv->val); break; case INTEL_TLV_CNVI_BT: + if (tlv->len < sizeof(u32)) + goto failed; version->cnvi_bt = get_unaligned_le32(tlv->val); break; case INTEL_TLV_CNVR_BT: + if (tlv->len < sizeof(u32)) + goto failed; version->cnvr_bt = get_unaligned_le32(tlv->val); break; case INTEL_TLV_DEV_REV_ID: + if (tlv->len < sizeof(u16)) + goto failed; version->dev_rev_id = get_unaligned_le16(tlv->val); break; case INTEL_TLV_IMAGE_TYPE: + if (tlv->len < sizeof(u8)) + goto failed; version->img_type = tlv->val[0]; break; case INTEL_TLV_TIME_STAMP: + if (tlv->len < sizeof(u16)) + goto failed; version->timestamp = get_unaligned_le16(tlv->val); break; case INTEL_TLV_BUILD_TYPE: + if (tlv->len < sizeof(u8)) + goto failed; version->build_type = tlv->val[0]; break; case INTEL_TLV_BUILD_NUM: + if (tlv->len < sizeof(u32)) + goto failed; version->build_num = get_unaligned_le32(tlv->val); break; case INTEL_TLV_SECURE_BOOT: + if (tlv->len < sizeof(u8)) + goto failed; version->secure_boot = tlv->val[0]; break; case INTEL_TLV_OTP_LOCK: + if (tlv->len < sizeof(u8)) + goto failed; version->otp_lock = tlv->val[0]; break; case INTEL_TLV_API_LOCK: + if (tlv->len < sizeof(u8)) + goto failed; version->api_lock = tlv->val[0]; break; case INTEL_TLV_DEBUG_LOCK: + if (tlv->len < sizeof(u8)) + goto failed; version->debug_lock = tlv->val[0]; break; case INTEL_TLV_MIN_FW: + if (tlv->len < 3) + goto failed; version->min_fw_build_nn = tlv->val[0]; version->min_fw_build_cw = tlv->val[1]; version->min_fw_build_yy = tlv->val[2]; break; case INTEL_TLV_LIMITED_CCE: + if (tlv->len < sizeof(u8)) + goto failed; version->limited_cce = tlv->val[0]; break; case INTEL_TLV_SBE_TYPE: + if (tlv->len < sizeof(u8)) + goto failed; version->sbe_type = tlv->val[0]; break; case INTEL_TLV_OTP_BDADDR: + if (tlv->len != sizeof(version->otp_bd_addr)) + goto failed; memcpy(&version->otp_bd_addr, tlv->val, tlv->len); break; default: @@ -499,6 +536,10 @@ int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *ver kfree_skb(skb); return 0; + +failed: + kfree_skb(skb); + return -EINVAL; } EXPORT_SYMBOL_GPL(btintel_read_version_tlv); -- 2.7.4 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eFrDFPNWaV82TAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 03:44:19 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id GOv+EfNWaV8L7wAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 03:44:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 4FB554096F; Tue, 22 Sep 2020 03:44:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728854AbgIVBoI (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Mon, 21 Sep 2020 21:44:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728497AbgIVBoI (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Mon, 21 Sep 2020 21:44:08 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8170C061755 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 18:44:07 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id w16so19258283oia.2 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 18:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nnystwRGA77c1y/A1dFdil02soJNePvzvHddszLW6VU=; b=qZfwSRReRvRujKpNbyaHCuMTuDJ0CNRzkDjPUUCYMpJWROixPiM1isCJg2VZqeJkkq cMZv2rPO02+QmRQWLos6dWj/y+UM5HaHLP8IWt2V+/TkC1UnSM9kfUUZDs+HGdY3CZs3 AAuAjgXALKT8GVlctFPF7pSYuZmougYQivuH/tAKfheA8Z/gMaOKvJzrmPN3BJ7f0FjK onTjZij6U3Q6M1ZB4p+/wcAVftAxDqnrTSxdiebCqAecGguDRoHFumyX7qKxePKxNFO3 6X1y0NKVlzkytJ9qulNFxGX2XCdgQgC9FkUjc8B+i9Ns6R7oLuQMYu8YP6Y7ZmdBgro7 LDBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nnystwRGA77c1y/A1dFdil02soJNePvzvHddszLW6VU=; b=iVETX2lP7aTH79OmCFZYbwiwnBZCX3iCdyWukvaAhaQRQ0VsAsv2rz9Zaz9aEEUNwA L7rhQrfSMlgP74VcPeQzon9f9uRzHGtGRu4btUPsDV0aJkJUPKUoWL2rXwdyVo5V4xZL w8QydNLkuYt/nfUHFa9Wskv5MEYZDOK8oa6JiBq2ZjR8UTkn2kf5SYc0tpNx4h48k1tk 0/XRCt4rvn6Q4yAgcQoCk/FHkMg3Jojg9TingvLXknUTllPmIo4UiG4JT3sauaD8H7kf Nh7FT2fo3zlahqx0I0SCdqM0kC8PrMDkCHmMtdxhqkk7ZEjl/3ColGbssX/NILcBfXgQ 8W4A== X-Gm-Message-State: AOAM532GJvHRKU2HI/k8XqTAAoCgcdHocLQjgxnSHzW2jDg76Fq6jTaL R85C8DybRsXRJ4J8PJwo5B9CXxPatn34/jx3Ai0= X-Google-Smtp-Source: ABdhPJzdqqKU0DBDzelyGfvn3gCvrPS4rlMxVCI/Vam41KkOrhL7qZ/r2gDKa227/bcgGKRm6l0fcQbsG+VrcEk9E5A= X-Received: by 2002:aca:3e08:: with SMTP id l8mr1242763oia.152.1600739046443; Mon, 21 Sep 2020 18:44:06 -0700 (PDT) MIME-Version: 1.0 References: <CABmPvSHYi7WeWqgqxSe60omSyVXj_EezMhGi1GMXBBWM-TWeBw@mail.gmail.com> <CABBYNZJDbPd83cx0KWLGMpE_KaA9xUbuMCDsuQVTNxV7xrowiw@mail.gmail.com> <CABmPvSEgnWoyijsA=ZsNeJoJdbz5YJTZHtEGWp6JTj3dKxxMrQ@mail.gmail.com> In-Reply-To: <CABmPvSEgnWoyijsA=ZsNeJoJdbz5YJTZHtEGWp6JTj3dKxxMrQ@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 21 Sep 2020 18:43:53 -0700 Message-ID: <CABBYNZJKT8mf8RP5ZVt3M2hUNRkzyiwGvpFm7n3WBayt-kbsyA@mail.gmail.com> Subject: Re: Modifying Makefile.am to facilitate test-adv-monitor and future unit tests. To: Miao-chen Chou <mcchou@chromium.org> Cc: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Alain Michaud <alainm@chromium.org>, Manish Mandlik <mmandlik@chromium.org>, Howard Chung <howardchung@google.com>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.88 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4FB554096F X-Rspamd-UID: 2e9eea Hi Miao, On Mon, Sep 21, 2020 at 12:21 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > Hi Luiz, > > On Fri, Sep 18, 2020 at 3:12 PM Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Miao, > > > > On Fri, Sep 18, 2020 at 12:44 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > > > Hi Luiz and Marcel, > > > > > > Unlike the rest of the existing unit tests in BlueZ, the logic blocks > > > tested in test-adv-monitor require dependencies of not only > > > src/adv_monitor.c but also all the dependency tree of > > > src/adv_monitor.c. The current convention in Makefile.am is to add all > > > the extra dependencies one by one. However, the maintenance cost is > > > high and not suitable in the case of test-adv-monitor. Therefore, we'd > > > like to propose changes in Makefile.am to make the source of > > > bluetoothd as a static library and link it for bluetoothd target and > > > the unit test target. It would be great if you can provide feedback on > > > this idea before the implementation. Thanks in advance! > > > > Then we should have had the code move to src/shared for unit testing, > > but how exactly are you planning to do that? For testing the kernel > > interface it normally done via a dedicated tester, but that again can > > be done with shared library. > > > In series https://patchwork.kernel.org/project/bluetooth/list/?series=351021, > we introduced some helper functions in adv_monitor.h to perform unit > testing and test-adv-monitor to facilitate the unit tests of > adv_monitor. We are encountering an expected build check failure on > this series. > > There are two categories in test-adv-monitor, content filtering and > RSSI tracking, and content filter is easy to be moved to a standalone > shared component while RSSI tracking involves the use of timer, D-Bus > method calls and adv_monitor's internal structures, and that makes it > strongly coupled with the adv_monitor implementation which require a > tree of dependencies apart from adv_monitor. > > There are two options to resolve the build failures in our case. > (1) Reorganize Makefile.am > This option is to make the sources (except src/main.c) into a static > lib and link this lib in bluetoothd executable target and whichever > unit test the sources are required. > (2) Create src/shared/am to facilitate helpers and core logic > This option is to create a new source under src/shared/ to facilitate > helper functions and core logic for src/adv_monitor. The interface of > src/shared/am may have the following functions. > - Create/destroy functions of struct adv_monitor > - Create/destroy functions of struct adv_monitor_device > - Helper function for monitor content matching. > - Helper function for RSSI tracking > However, the logic of RSSI tracking is hard to be ripped off and moved > to src/shared/am. One example would be the use of timer in RSSI > tracking, and there is currently no previous example of the timer use > in the shared library. Not really following regarding the dependency on D-Bus, usually shared don't have dependency on that because the code would be part of the deamon and in that case you would be better of testing that direct via a tester that does exercise its D-Bus API. Lets be clear here, except for gbus itself all our tests under unit directory are for C function testing, if you want to test a D-Bus interface then we need a tester that would do that over D-Bus. > Series https://patchwork.kernel.org/project/bluetooth/list/?series=351021 > is up for review. Our next step here would be ripped off the unit test > for now and submit v5 of the series. Once we reach an conclusion on > advmon unit test, we can submit a separate series including the > refactoring and unit tests. Looking forward to any feedbacks. Thanks! I'd strip the testing for now since it doesn't seem we are on sync to how we test things apparently. > Regards, > Miao -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kMj+B9CIaV/e+gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 07:17:04 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id OPkzBNCIaV9tugEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 07:17:04 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 79FFFA0B9B; Tue, 22 Sep 2020 07:16:58 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727681AbgIVFQ5 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 22 Sep 2020 01:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726480AbgIVFQ5 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 22 Sep 2020 01:16:57 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 026D7C061755 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 22:16:57 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id k13so3851337oor.2 for <linux-bluetooth@vger.kernel.org>; Mon, 21 Sep 2020 22:16:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RjVaM5PSRHjTOEGeN+/MmSR4gTJjjQyWdg1LfaUxZTk=; b=Xoq7Fsl5Ruttj7LNNOXNKb3p/E+Oxahfj2BylqbhPV5/f9mT+xoJMj4U97w4Y5I12J 2cvIV/7dC2UwYG9G1F3eHU42B+2KJX5D1zU436KsNV1Ir7ZvDJsVbacHwts8sVPgfqGR wj+Revga7umISYdcFAQ7DsJrXigI54R+1PmF0iONH3g6Su3U79FBKiOlnMt2+l5IYAQk UPQRAglU7RrlzZF6t76Dx1ys5yZnrnNVpl8WX88AxBgO6WfYaDU6CNn89RvptE4hUXfU JgwLAtH7gFORWTRGXBENM9VMOzenxJ2ro8a6FgC0W/CcxIbtYKGC+68aaGIKDIlwhTHW b4WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RjVaM5PSRHjTOEGeN+/MmSR4gTJjjQyWdg1LfaUxZTk=; b=YDbqpD4QX2ZXKx8FMgWW0r63oMoxbyKB1F6WTj0QrtTlGXgACN4i2WWz0JNxODZBkT T70/BuX4QCLlqJMtBuZ1AN348VekIpTUKp4jxrwFx335rdsulf6GxUHacdctS+Mlnu2K NXfOnEmpZZQo2iy1/FWewekFS0U4Y9oJvHaki+r0Ze1j2dFA5ItbUIdoilcwE0kOsqw/ YYDdmlps1hqjZifxDh1zshIK+CaflA4RwmtEoc3p1EQ+1CP5hZpyvkkFl8fOTTAdq9u9 AcUol39r8rCTwYGOovzm8uZpPbgG0MFU7cJa32wdae6F01aEd7fg1EJbzyzN3HAUXM6j noQQ== X-Gm-Message-State: AOAM530VmILHgLSzaG63zApWA5leQLOoySYbQknqzSDIwCx7kmHe4VA6 SEuuh353eBiX+Gj5vCa3WWEX1ln6Dqadi91dtTRNCP7j X-Google-Smtp-Source: ABdhPJwZbchNvarGE+tn5W1qbKmV2AuWHV0nBacxCrD+AhaKVFFBQNggZIoMPLdbU7qqOlkUJ4NEI7pIfd4pi9Pz7u0= X-Received: by 2002:a4a:bf12:: with SMTP id r18mr1876346oop.9.1600751816136; Mon, 21 Sep 2020 22:16:56 -0700 (PDT) MIME-Version: 1.0 References: <1600747219-11626-1-git-send-email-kiran.k@intel.com> In-Reply-To: <1600747219-11626-1-git-send-email-kiran.k@intel.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Mon, 21 Sep 2020 22:16:44 -0700 Message-ID: <CABBYNZKTQeZZkVCGaCvnL661Qsxc1cFGNggEuM3pD7p0S8yRwQ@mail.gmail.com> Subject: Re: [PATCH v1] Bluetooth: btintel: Fix issue reported by static analysis tool To: Kiran K <kiraank@gmail.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Chethan T N <chethan.tumkur.narayan@intel.com>, ravishankar.srivatsa@intel.com, dan.carpenter@oracle.com, Kiran K <kiran.k@intel.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.68 / 15.00 / 15.00 X-Rspamd-Queue-Id: 79FFFA0B9B X-Rspamd-UID: 3b4aa8 Hi Kiran, On Mon, Sep 21, 2020 at 9:03 PM Kiran K <kiraank@gmail.com> wrote: > > Smatch tool reported the below issue: > > drivers/bluetooth/btintel.c:490 btintel_read_version_tlv() > error: 'tlv->len' from user is not capped properly > > Additional details in the below link > https://www.spinics.net/lists/linux-bluetooth/msg87786.html > > Signed-off-by: Kiran K <kiran.k@intel.com> > --- > drivers/bluetooth/btintel.c | 43 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 42 insertions(+), 1 deletion(-) > > diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c > index 88ce5f0..47f2b3d 100644 > --- a/drivers/bluetooth/btintel.c > +++ b/drivers/bluetooth/btintel.c > @@ -431,62 +431,99 @@ int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *ver > * version field like hw_platform, hw_variant, and fw_variant > * to keep the existing setup flow > */ > - while (skb->len) { > + while (skb->len >= sizeof(struct intel_tlv)) { > struct intel_tlv *tlv; > > tlv = (struct intel_tlv *)skb->data; > + if (struct_size(tlv, val, tlv->len) > skb->len) > + goto failed; > + > switch (tlv->type) { > case INTEL_TLV_CNVI_TOP: > + if (tlv->len < sizeof(u32)) > + goto failed; > version->cnvi_top = get_unaligned_le32(tlv->val); > break; > case INTEL_TLV_CNVR_TOP: > + if (tlv->len < sizeof(u32)) > + goto failed; > version->cnvr_top = get_unaligned_le32(tlv->val); > break; > case INTEL_TLV_CNVI_BT: > + if (tlv->len < sizeof(u32)) > + goto failed; > version->cnvi_bt = get_unaligned_le32(tlv->val); > break; > case INTEL_TLV_CNVR_BT: > + if (tlv->len < sizeof(u32)) > + goto failed; > version->cnvr_bt = get_unaligned_le32(tlv->val); > break; > case INTEL_TLV_DEV_REV_ID: > + if (tlv->len < sizeof(u16)) > + goto failed; > version->dev_rev_id = get_unaligned_le16(tlv->val); > break; > case INTEL_TLV_IMAGE_TYPE: > + if (tlv->len < sizeof(u8)) > + goto failed; > version->img_type = tlv->val[0]; > break; > case INTEL_TLV_TIME_STAMP: > + if (tlv->len < sizeof(u16)) > + goto failed; > version->timestamp = get_unaligned_le16(tlv->val); > break; > case INTEL_TLV_BUILD_TYPE: > + if (tlv->len < sizeof(u8)) > + goto failed; > version->build_type = tlv->val[0]; > break; > case INTEL_TLV_BUILD_NUM: > + if (tlv->len < sizeof(u32)) > + goto failed; > version->build_num = get_unaligned_le32(tlv->val); > break; > case INTEL_TLV_SECURE_BOOT: > + if (tlv->len < sizeof(u8)) > + goto failed; > version->secure_boot = tlv->val[0]; > break; > case INTEL_TLV_OTP_LOCK: > + if (tlv->len < sizeof(u8)) > + goto failed; > version->otp_lock = tlv->val[0]; > break; > case INTEL_TLV_API_LOCK: > + if (tlv->len < sizeof(u8)) > + goto failed; > version->api_lock = tlv->val[0]; > break; > case INTEL_TLV_DEBUG_LOCK: > + if (tlv->len < sizeof(u8)) > + goto failed; > version->debug_lock = tlv->val[0]; > break; > case INTEL_TLV_MIN_FW: > + if (tlv->len < 3) > + goto failed; > version->min_fw_build_nn = tlv->val[0]; > version->min_fw_build_cw = tlv->val[1]; > version->min_fw_build_yy = tlv->val[2]; > break; > case INTEL_TLV_LIMITED_CCE: > + if (tlv->len < sizeof(u8)) > + goto failed; > version->limited_cce = tlv->val[0]; > break; > case INTEL_TLV_SBE_TYPE: > + if (tlv->len < sizeof(u8)) > + goto failed; > version->sbe_type = tlv->val[0]; > break; > case INTEL_TLV_OTP_BDADDR: > + if (tlv->len != sizeof(version->otp_bd_addr)) > + goto failed; Do we really want to fail here? The advantage of using a TLV is that we can skip if the type is not understood or is malformed but with this checks the length becomes useless since the types will always have a fixed value, also we cannot extend the types later on since it would not be backward compatible if we maintain such strict checks. > memcpy(&version->otp_bd_addr, tlv->val, tlv->len); > break; > default: > @@ -499,6 +536,10 @@ int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *ver > > kfree_skb(skb); > return 0; > + > +failed: > + kfree_skb(skb); > + return -EINVAL; > } > EXPORT_SYMBOL_GPL(btintel_read_version_tlv); > > -- > 2.7.4 > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id sIn6FoaTaV8rSQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 08:02:46 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id gEdCFIaTaV9tugEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 08:02:46 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=intel.onmicrosoft.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id D5B1FA0E2D; Tue, 22 Sep 2020 08:02:39 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729151AbgIVGCi (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 22 Sep 2020 02:02:38 -0400 Received: from mga18.intel.com ([134.134.136.126]:59467 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbgIVGCi (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 22 Sep 2020 02:02:38 -0400 IronPort-SDR: QHIzMcGyfG+4HbEEAFgdoCLqUQGhkkPTb4NiCR3oXyMD961N4A0MKvEwGLAf5L40RLpe/aG4Ws SwXCPHGikX2Q== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="148293533" X-IronPort-AV: E=Sophos;i="5.77,289,1596524400"; d="scan'208";a="148293533" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 23:02:36 -0700 IronPort-SDR: Iu/y91Q6i13fQK0JdBdMgAuylHYy1zjP6sWlz9ZPEv24spmDDE+nl3EEA0SJDfnt6zpiRsGdcL +ZyOAEf9ArOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,289,1596524400"; d="scan'208";a="334870681" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga004.fm.intel.com with ESMTP; 21 Sep 2020 23:02:36 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 21 Sep 2020 23:02:35 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 21 Sep 2020 23:02:35 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.105) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Mon, 21 Sep 2020 23:02:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OkBE3TdGijT75kXgm6rAO2elIBdfosneu9CDcRUMbLBaxtq1JJU9jYxxZMGff1kH1RA+VoEpFZI4vMOyshFQwqOfW97nh7C4ytZUo/SolFFiObaGDZ2sdxP5hZq2stRqmF22sKjjO2Ek3Sy7siVPTw7Ykeyv3iYRpo9XVkXsEr4ZoohcUldcwNf5CnYh5yW5g0jZQzvXIb6RAs1azcQKrb1a6U6O8dqBxXzqjdCYsAoFwF1t65ccz9UmN7SmEIjz5kiLxeHJBza1yWJMjJq++3sXDaDcY0at34YVufIsV3YvZ27v1a1ZfLcKSn7xPPVSczcr+fCpVXlZ1BlSCq/d/A== 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-SenderADCheck; bh=FemeFjV4BHm8LhBsR+dDLlFukBJe6Eq+dylZ5q0WfvI=; b=WagEMa5D0WFa1B2r/18wQ4AVmS4OOFruOJrIcktzE17grT7mZ9+V6Mca9EoRPm/GmnjNfTOphQ9POKuFlC9RCrP4X7+hX8FSesWOethTDNsFdxX1yZR/TQJrvm8br+jjFDGVGtEAzPBnJrhlZbJWfy5n03phlcGxTh6/fTWOXMNq2KrrgTNwYg7c1bX6hoOp8c9rggD9aqpIZ/ruon9DQL+TZGm25elXv4tnouInjDL6dm6rxamtc2aCHqER6dnC54W29VruStYz90yPbbXGCK4EuFW4RBvISrXYgrovomotVMvL7df3vqF11i8WIgSn6bb6Vgit+P0i/ZnfjEx6jQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FemeFjV4BHm8LhBsR+dDLlFukBJe6Eq+dylZ5q0WfvI=; b=jol4HaDP5PfdYZCMwvIlZgLwZHk5Nq68fg3BIPhz2DdJYQUGqKjRmWQslgPebfClFJq8xJhNnZkLa+X9oM32oqe4g1SHxAokMrQHvxMMWrULvP3JvXq+ZCt8u5x8hJ5HTEsySiZjp1mFYiDCEbKbVrPSwKwDLYHNrphdGDdf/XE= Received: from BYAPR11MB3141.namprd11.prod.outlook.com (2603:10b6:a03:8d::13) by BYAPR11MB3527.namprd11.prod.outlook.com (2603:10b6:a03:8b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.24; Tue, 22 Sep 2020 06:02:31 +0000 Received: from BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::c8d8:a3c5:9876:d589]) by BYAPR11MB3141.namprd11.prod.outlook.com ([fe80::c8d8:a3c5:9876:d589%7]) with mapi id 15.20.3391.019; Tue, 22 Sep 2020 06:02:31 +0000 From: "K, Kiran" <kiran.k@intel.com> To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>, Kiran K <kiraank@gmail.com> CC: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Tumkur Narayan, Chethan" <chethan.tumkur.narayan@intel.com>, "Srivatsa, Ravishankar" <ravishankar.srivatsa@intel.com>, "dan.carpenter@oracle.com" <dan.carpenter@oracle.com> Subject: RE: [PATCH v1] Bluetooth: btintel: Fix issue reported by static analysis tool Thread-Topic: [PATCH v1] Bluetooth: btintel: Fix issue reported by static analysis tool Thread-Index: AQHWkJUJikI7QCk8XUmiQtbNOopXyql0HfUAgAAGfmA= Date: Tue, 22 Sep 2020 06:02:31 +0000 Message-ID: <BYAPR11MB3141CF1A1F129710852DD2B8F53B0@BYAPR11MB3141.namprd11.prod.outlook.com> References: <1600747219-11626-1-git-send-email-kiran.k@intel.com> <CABBYNZKTQeZZkVCGaCvnL661Qsxc1cFGNggEuM3pD7p0S8yRwQ@mail.gmail.com> In-Reply-To: <CABBYNZKTQeZZkVCGaCvnL661Qsxc1cFGNggEuM3pD7p0S8yRwQ@mail.gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [122.179.23.229] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8e2deeb7-6c11-4001-9487-08d85ebd1815 x-ms-traffictypediagnostic: BYAPR11MB3527: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <BYAPR11MB352765119AAAE1E492E58ECCF53B0@BYAPR11MB3527.namprd11.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qp7oDg37fXZ4P9JjKt+SnKGy9b6rNqENRIDP18L57IWb9Pko9/w3JW4zBxczQ4iDEhmRKNPgXFWtAxZY/qwy2xO+bvIB4PMNNAPYv/Gg0+V/VovM1odNdlFnU9A5Vp9UYWMH6Ev3JVqnlrvuAjDJmPqQTlqXa9arOgMTcWlNnsCSPPgENeKEaS7srcwSKBIYzPDC4/fxGEXEzQicu4A9mwN9uDTPniUGK9qXfu2K2zW2GABFo8mkcq31k4Qpe+/TejBBh9guMt2Kasb5Tx4DiIKDLF3krqBzQ1UWY3jhqL1v/SjBeCCT5lNy6Pkl8Oi4xMzaVKF7kIUhnhqWvykFDmKJusNRwp0CsEgnBRvpJ2xfiI/R3vjQnQrEoSLL8OlSpgVVyEy9KcbrZdjKEYMBVw5JYAZgFLjyvvE5G7LCllAlbR/VUoo1u7LFbrMY+k3c1yp7amaEW/n+ScCa+AM/tQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3141.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(39860400002)(346002)(396003)(4326008)(76116006)(66946007)(52536014)(66476007)(9686003)(64756008)(66556008)(71200400001)(8936002)(5660300002)(83380400001)(66446008)(186003)(478600001)(54906003)(6506007)(2906002)(33656002)(86362001)(55016002)(110136005)(8676002)(26005)(316002)(7696005)(966005)(53546011);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: kIwcydMriLpaV5pBRfbUJxbw5Llyc/kaeA8L7q6hlWTykam6JacUucj8iZAcTszZqrGeU7HDyS2hZUtu8nv13Iz+XQ8DZUEXKEVZ3Hq9S2kFSP0kilmabBJ/pl6qgq5DrGCT70qjZD6+zImlyMybuIokYNASxF17Vvk/Osv8cJGeaIq/2yqXIO4cK285f7zA3T6cMqVHPjahq+2deiVOITUkoJa1u8ahURJ/1vrsWcQ5J/c2EUgg1wmJmn1j8mmVeTIOLRjI1NX7sKb1TD6I7J3+1kfO3cTggLXUsFeA7nj4PPWfIUqYWib2zLugNpvY8N7uVb9RRSWcfiZ/Me0zR9WhMriRdJG6WeynlH8ag52b9uO0WbiDQgcT0U4BAEy4fpN59cvEgS+Xu0OpmLeENNCHzh6v5a9HmLousmZvTxW0K6Qc7WqrxxJlMPDBjnsqNqHi7FI3vrYE+DW3u8b2izi1w9C5dq6jEV9gl0BwLSBn/10gtOGGPGZh7Z0enNMnjygDZFStcJJx8XiCVQ5j0d5AMUTOMDzCTJMo8WJmahLPkg2UDXKZLI9Up+QORdZgCZS/31a7lcxDZ9aw6s65p0RPP9I0g2p6QNyY56pE9YhJlr+xuf53NfJ78IW603fewJ7xA2CvjrwoMB1evUlyVg== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3141.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e2deeb7-6c11-4001-9487-08d85ebd1815 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Sep 2020 06:02:31.6433 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: WfvExdWGqxowjFEQgCTEfyhSjSHT+OKnV3vdpofvOJirGAS/v9pbt8RPRM2V6IJZMSUkKLMFj6TF2K0AdsDYVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3527 X-OriginatorOrg: intel.com Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: D5B1FA0E2D X-Rspamd-UID: 211fdf SGkgTHVpeiwNCg0KPiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBMdWl6IEF1 Z3VzdG8gdm9uIERlbnR6IDxsdWl6LmRlbnR6QGdtYWlsLmNvbT4NCj4gU2VudDogVHVlc2RheSwg U2VwdGVtYmVyIDIyLCAyMDIwIDEwOjQ3IEFNDQo+IFRvOiBLaXJhbiBLIDxraXJhYW5rQGdtYWls LmNvbT4NCj4gQ2M6IGxpbnV4LWJsdWV0b290aEB2Z2VyLmtlcm5lbC5vcmc7IFR1bWt1ciBOYXJh eWFuLCBDaGV0aGFuDQo+IDxjaGV0aGFuLnR1bWt1ci5uYXJheWFuQGludGVsLmNvbT47IFNyaXZh dHNhLCBSYXZpc2hhbmthcg0KPiA8cmF2aXNoYW5rYXIuc3JpdmF0c2FAaW50ZWwuY29tPjsgZGFu LmNhcnBlbnRlckBvcmFjbGUuY29tOyBLLCBLaXJhbg0KPiA8a2lyYW4ua0BpbnRlbC5jb20+DQo+ IFN1YmplY3Q6IFJlOiBbUEFUQ0ggdjFdIEJsdWV0b290aDogYnRpbnRlbDogRml4IGlzc3VlIHJl cG9ydGVkIGJ5IHN0YXRpYw0KPiBhbmFseXNpcyB0b29sDQo+IA0KPiBIaSBLaXJhbiwNCj4gDQo+ IE9uIE1vbiwgU2VwIDIxLCAyMDIwIGF0IDk6MDMgUE0gS2lyYW4gSyA8a2lyYWFua0BnbWFpbC5j b20+IHdyb3RlOg0KPiA+DQo+ID4gU21hdGNoIHRvb2wgcmVwb3J0ZWQgdGhlIGJlbG93IGlzc3Vl Og0KPiA+DQo+ID4gZHJpdmVycy9ibHVldG9vdGgvYnRpbnRlbC5jOjQ5MCBidGludGVsX3JlYWRf dmVyc2lvbl90bHYoKQ0KPiA+IGVycm9yOiAndGx2LT5sZW4nIGZyb20gdXNlciBpcyBub3QgY2Fw cGVkIHByb3Blcmx5DQo+ID4NCj4gPiBBZGRpdGlvbmFsIGRldGFpbHMgaW4gdGhlIGJlbG93IGxp bmsNCj4gPiBodHRwczovL3d3dy5zcGluaWNzLm5ldC9saXN0cy9saW51eC1ibHVldG9vdGgvbXNn ODc3ODYuaHRtbA0KPiA+DQo+ID4gU2lnbmVkLW9mZi1ieTogS2lyYW4gSyA8a2lyYW4ua0BpbnRl bC5jb20+DQo+ID4gLS0tDQo+ID4gIGRyaXZlcnMvYmx1ZXRvb3RoL2J0aW50ZWwuYyB8IDQzDQo+ ID4gKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrLQ0KPiA+ICAxIGZp bGUgY2hhbmdlZCwgNDIgaW5zZXJ0aW9ucygrKSwgMSBkZWxldGlvbigtKQ0KPiA+DQo+ID4gZGlm ZiAtLWdpdCBhL2RyaXZlcnMvYmx1ZXRvb3RoL2J0aW50ZWwuYyBiL2RyaXZlcnMvYmx1ZXRvb3Ro L2J0aW50ZWwuYw0KPiA+IGluZGV4IDg4Y2U1ZjAuLjQ3ZjJiM2QgMTAwNjQ0DQo+ID4gLS0tIGEv ZHJpdmVycy9ibHVldG9vdGgvYnRpbnRlbC5jDQo+ID4gKysrIGIvZHJpdmVycy9ibHVldG9vdGgv YnRpbnRlbC5jDQo+ID4gQEAgLTQzMSw2MiArNDMxLDk5IEBAIGludCBidGludGVsX3JlYWRfdmVy c2lvbl90bHYoc3RydWN0IGhjaV9kZXYNCj4gKmhkZXYsIHN0cnVjdCBpbnRlbF92ZXJzaW9uX3Rs diAqdmVyDQo+ID4gICAgICAgICAgKiB2ZXJzaW9uIGZpZWxkIGxpa2UgaHdfcGxhdGZvcm0sIGh3 X3ZhcmlhbnQsIGFuZCBmd192YXJpYW50DQo+ID4gICAgICAgICAgKiB0byBrZWVwIHRoZSBleGlz dGluZyBzZXR1cCBmbG93DQo+ID4gICAgICAgICAgKi8NCj4gPiAtICAgICAgIHdoaWxlIChza2It Pmxlbikgew0KPiA+ICsgICAgICAgd2hpbGUgKHNrYi0+bGVuID49IHNpemVvZihzdHJ1Y3QgaW50 ZWxfdGx2KSkgew0KPiA+ICAgICAgICAgICAgICAgICBzdHJ1Y3QgaW50ZWxfdGx2ICp0bHY7DQo+ ID4NCj4gPiAgICAgICAgICAgICAgICAgdGx2ID0gKHN0cnVjdCBpbnRlbF90bHYgKilza2ItPmRh dGE7DQo+ID4gKyAgICAgICAgICAgICAgIGlmIChzdHJ1Y3Rfc2l6ZSh0bHYsIHZhbCwgdGx2LT5s ZW4pID4gc2tiLT5sZW4pDQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgZ290byBmYWlsZWQ7 DQo+ID4gKw0KPiA+ICAgICAgICAgICAgICAgICBzd2l0Y2ggKHRsdi0+dHlwZSkgew0KPiA+ICAg ICAgICAgICAgICAgICBjYXNlIElOVEVMX1RMVl9DTlZJX1RPUDoNCj4gPiArICAgICAgICAgICAg ICAgICAgICAgICBpZiAodGx2LT5sZW4gPCBzaXplb2YodTMyKSkNCj4gPiArICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIGdvdG8gZmFpbGVkOw0KPiA+ICAgICAgICAgICAgICAgICAgICAg ICAgIHZlcnNpb24tPmNudmlfdG9wID0gZ2V0X3VuYWxpZ25lZF9sZTMyKHRsdi0+dmFsKTsNCj4g PiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCj4gPiAgICAgICAgICAgICAgICAgY2Fz ZSBJTlRFTF9UTFZfQ05WUl9UT1A6DQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRs di0+bGVuIDwgc2l6ZW9mKHUzMikpDQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBnb3RvIGZhaWxlZDsNCj4gPiAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uLT5jbnZy X3RvcCA9IGdldF91bmFsaWduZWRfbGUzMih0bHYtPnZhbCk7DQo+ID4gICAgICAgICAgICAgICAg ICAgICAgICAgYnJlYWs7DQo+ID4gICAgICAgICAgICAgICAgIGNhc2UgSU5URUxfVExWX0NOVklf QlQ6DQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRsdi0+bGVuIDwgc2l6ZW9mKHUz MikpDQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnb3RvIGZhaWxlZDsNCj4g PiAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uLT5jbnZpX2J0ID0gZ2V0X3VuYWxpZ25l ZF9sZTMyKHRsdi0+dmFsKTsNCj4gPiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCj4g PiAgICAgICAgICAgICAgICAgY2FzZSBJTlRFTF9UTFZfQ05WUl9CVDoNCj4gPiArICAgICAgICAg ICAgICAgICAgICAgICBpZiAodGx2LT5sZW4gPCBzaXplb2YodTMyKSkNCj4gPiArICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIGdvdG8gZmFpbGVkOw0KPiA+ICAgICAgICAgICAgICAgICAg ICAgICAgIHZlcnNpb24tPmNudnJfYnQgPSBnZXRfdW5hbGlnbmVkX2xlMzIodGx2LT52YWwpOw0K PiA+ICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOw0KPiA+ICAgICAgICAgICAgICAgICBj YXNlIElOVEVMX1RMVl9ERVZfUkVWX0lEOg0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgIGlm ICh0bHYtPmxlbiA8IHNpemVvZih1MTYpKQ0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgZ290byBmYWlsZWQ7DQo+ID4gICAgICAgICAgICAgICAgICAgICAgICAgdmVyc2lvbi0+ ZGV2X3Jldl9pZCA9IGdldF91bmFsaWduZWRfbGUxNih0bHYtPnZhbCk7DQo+ID4gICAgICAgICAg ICAgICAgICAgICAgICAgYnJlYWs7DQo+ID4gICAgICAgICAgICAgICAgIGNhc2UgSU5URUxfVExW X0lNQUdFX1RZUEU6DQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRsdi0+bGVuIDwg c2l6ZW9mKHU4KSkNCj4gPiArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8gZmFp bGVkOw0KPiA+ICAgICAgICAgICAgICAgICAgICAgICAgIHZlcnNpb24tPmltZ190eXBlID0gdGx2 LT52YWxbMF07DQo+ID4gICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQo+ID4gICAgICAg ICAgICAgICAgIGNhc2UgSU5URUxfVExWX1RJTUVfU1RBTVA6DQo+ID4gKyAgICAgICAgICAgICAg ICAgICAgICAgaWYgKHRsdi0+bGVuIDwgc2l6ZW9mKHUxNikpDQo+ID4gKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICBnb3RvIGZhaWxlZDsNCj4gPiAgICAgICAgICAgICAgICAgICAgICAg ICB2ZXJzaW9uLT50aW1lc3RhbXAgPSBnZXRfdW5hbGlnbmVkX2xlMTYodGx2LT52YWwpOw0KPiA+ ICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOw0KPiA+ICAgICAgICAgICAgICAgICBjYXNl IElOVEVMX1RMVl9CVUlMRF9UWVBFOg0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgIGlmICh0 bHYtPmxlbiA8IHNpemVvZih1OCkpDQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBnb3RvIGZhaWxlZDsNCj4gPiAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uLT5idWls ZF90eXBlID0gdGx2LT52YWxbMF07DQo+ID4gICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7 DQo+ID4gICAgICAgICAgICAgICAgIGNhc2UgSU5URUxfVExWX0JVSUxEX05VTToNCj4gPiArICAg ICAgICAgICAgICAgICAgICAgICBpZiAodGx2LT5sZW4gPCBzaXplb2YodTMyKSkNCj4gPiArICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8gZmFpbGVkOw0KPiA+ICAgICAgICAgICAg ICAgICAgICAgICAgIHZlcnNpb24tPmJ1aWxkX251bSA9IGdldF91bmFsaWduZWRfbGUzMih0bHYt PnZhbCk7DQo+ID4gICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQo+ID4gICAgICAgICAg ICAgICAgIGNhc2UgSU5URUxfVExWX1NFQ1VSRV9CT09UOg0KPiA+ICsgICAgICAgICAgICAgICAg ICAgICAgIGlmICh0bHYtPmxlbiA8IHNpemVvZih1OCkpDQo+ID4gKyAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICBnb3RvIGZhaWxlZDsNCj4gPiAgICAgICAgICAgICAgICAgICAgICAgICB2 ZXJzaW9uLT5zZWN1cmVfYm9vdCA9IHRsdi0+dmFsWzBdOw0KPiA+ICAgICAgICAgICAgICAgICAg ICAgICAgIGJyZWFrOw0KPiA+ICAgICAgICAgICAgICAgICBjYXNlIElOVEVMX1RMVl9PVFBfTE9D SzoNCj4gPiArICAgICAgICAgICAgICAgICAgICAgICBpZiAodGx2LT5sZW4gPCBzaXplb2YodTgp KQ0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ290byBmYWlsZWQ7DQo+ID4g ICAgICAgICAgICAgICAgICAgICAgICAgdmVyc2lvbi0+b3RwX2xvY2sgPSB0bHYtPnZhbFswXTsN Cj4gPiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCj4gPiAgICAgICAgICAgICAgICAg Y2FzZSBJTlRFTF9UTFZfQVBJX0xPQ0s6DQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgaWYg KHRsdi0+bGVuIDwgc2l6ZW9mKHU4KSkNCj4gPiArICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIGdvdG8gZmFpbGVkOw0KPiA+ICAgICAgICAgICAgICAgICAgICAgICAgIHZlcnNpb24tPmFw aV9sb2NrID0gdGx2LT52YWxbMF07DQo+ID4gICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7 DQo+ID4gICAgICAgICAgICAgICAgIGNhc2UgSU5URUxfVExWX0RFQlVHX0xPQ0s6DQo+ID4gKyAg ICAgICAgICAgICAgICAgICAgICAgaWYgKHRsdi0+bGVuIDwgc2l6ZW9mKHU4KSkNCj4gPiArICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8gZmFpbGVkOw0KPiA+ICAgICAgICAgICAg ICAgICAgICAgICAgIHZlcnNpb24tPmRlYnVnX2xvY2sgPSB0bHYtPnZhbFswXTsNCj4gPiAgICAg ICAgICAgICAgICAgICAgICAgICBicmVhazsNCj4gPiAgICAgICAgICAgICAgICAgY2FzZSBJTlRF TF9UTFZfTUlOX0ZXOg0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgIGlmICh0bHYtPmxlbiA8 IDMpDQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnb3RvIGZhaWxlZDsNCj4g PiAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uLT5taW5fZndfYnVpbGRfbm4gPSB0bHYt PnZhbFswXTsNCj4gPiAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uLT5taW5fZndfYnVp bGRfY3cgPSB0bHYtPnZhbFsxXTsNCj4gPiAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9u LT5taW5fZndfYnVpbGRfeXkgPSB0bHYtPnZhbFsyXTsNCj4gPiAgICAgICAgICAgICAgICAgICAg ICAgICBicmVhazsNCj4gPiAgICAgICAgICAgICAgICAgY2FzZSBJTlRFTF9UTFZfTElNSVRFRF9D Q0U6DQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRsdi0+bGVuIDwgc2l6ZW9mKHU4 KSkNCj4gPiArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8gZmFpbGVkOw0KPiA+ ICAgICAgICAgICAgICAgICAgICAgICAgIHZlcnNpb24tPmxpbWl0ZWRfY2NlID0gdGx2LT52YWxb MF07DQo+ID4gICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQo+ID4gICAgICAgICAgICAg ICAgIGNhc2UgSU5URUxfVExWX1NCRV9UWVBFOg0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAg IGlmICh0bHYtPmxlbiA8IHNpemVvZih1OCkpDQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICBnb3RvIGZhaWxlZDsNCj4gPiAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9u LT5zYmVfdHlwZSA9IHRsdi0+dmFsWzBdOw0KPiA+ICAgICAgICAgICAgICAgICAgICAgICAgIGJy ZWFrOw0KPiA+ICAgICAgICAgICAgICAgICBjYXNlIElOVEVMX1RMVl9PVFBfQkRBRERSOg0KPiA+ ICsgICAgICAgICAgICAgICAgICAgICAgIGlmICh0bHYtPmxlbiAhPSBzaXplb2YodmVyc2lvbi0+ b3RwX2JkX2FkZHIpKQ0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ290byBm YWlsZWQ7DQo+IA0KPiBEbyB3ZSByZWFsbHkgd2FudCB0byBmYWlsIGhlcmU/IFRoZSBhZHZhbnRh Z2Ugb2YgdXNpbmcgYSBUTFYgaXMgdGhhdCB3ZSBjYW4NCj4gc2tpcCBpZiB0aGUgdHlwZSBpcyBu b3QgdW5kZXJzdG9vZCBvciBpcyBtYWxmb3JtZWQgYnV0IHdpdGggdGhpcyBjaGVja3MgdGhlDQo+ IGxlbmd0aCBiZWNvbWVzIHVzZWxlc3Mgc2luY2UgdGhlIHR5cGVzIHdpbGwgYWx3YXlzIGhhdmUg YSBmaXhlZCB2YWx1ZSwgYWxzbw0KDQpBZ3JlZSB0aGF0IHRoZSB0eXBlcyBhcmUgZml4ZWQgaGVy ZS4gQnV0IGlmIGR1ZSB0byBzb21lIHJlYXNvbiBpZiBjb250cm9sbGVyIGlzIG5vdCBob25vcmlu ZyB0aGUgc2FtZSwgdGhlbiBkcml2ZXIgbWlnaHQgZW5kIHVwIHJlYWRpbmcgdW53YW50ZWQgZGF0 YS4gVGhlIGNoZWNrIGlzIG1vcmUgYWJvdXQgZHJpdmVyIGJlaW5nIGRlZmVuc2l2ZSByYXRoZXIg dGhhbiBiZWxpZXZpbmcgIHdoYXQgY29tZXMgb24gd2lyZS4NCg0KPiB3ZSBjYW5ub3QgZXh0ZW5k IHRoZSB0eXBlcyBsYXRlciBvbiBzaW5jZSBpdCB3b3VsZCBub3QgYmUgYmFja3dhcmQNCj4gY29t cGF0aWJsZSBpZiB3ZSBtYWludGFpbiBzdWNoIHN0cmljdCBjaGVja3MuDQoNCkkgZGlkbuKAmXQg Z2V0IHRoaXMgcGFydC4gQ291bGQgeW91IHBsZWFzZSBiZSBtb3JlIHNwZWNpZmljID8NCg0KPiAN Cj4gPiAgICAgICAgICAgICAgICAgICAgICAgICBtZW1jcHkoJnZlcnNpb24tPm90cF9iZF9hZGRy LCB0bHYtPnZhbCwgdGx2LT5sZW4pOw0KPiA+ICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFr Ow0KPiA+ICAgICAgICAgICAgICAgICBkZWZhdWx0Og0KPiA+IEBAIC00OTksNiArNTM2LDEwIEBA IGludCBidGludGVsX3JlYWRfdmVyc2lvbl90bHYoc3RydWN0IGhjaV9kZXYNCj4gPiAqaGRldiwg c3RydWN0IGludGVsX3ZlcnNpb25fdGx2ICp2ZXINCj4gPg0KPiA+ICAgICAgICAga2ZyZWVfc2ti KHNrYik7DQo+ID4gICAgICAgICByZXR1cm4gMDsNCj4gPiArDQo+ID4gK2ZhaWxlZDoNCj4gPiAr ICAgICAgIGtmcmVlX3NrYihza2IpOw0KPiA+ICsgICAgICAgcmV0dXJuIC1FSU5WQUw7DQo+ID4g IH0NCj4gPiAgRVhQT1JUX1NZTUJPTF9HUEwoYnRpbnRlbF9yZWFkX3ZlcnNpb25fdGx2KTsNCj4g Pg0KPiA+IC0tDQo+ID4gMi43LjQNCj4gPg0KPiANCj4gDQo+IC0tDQo+IEx1aXogQXVndXN0byB2 b24gRGVudHoNCg0KVGhhbmtzLA0KS2lyYW4NCg== Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id eIlZE7ypaV8TMAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 09:37:32 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id eNFfELypaV8ldQAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 09:37:32 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 3166C409B9; Tue, 22 Sep 2020 09:37:26 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729972AbgIVHhP (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 22 Sep 2020 03:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729751AbgIVHhO (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 22 Sep 2020 03:37:14 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A6CEC061755 for <linux-bluetooth@vger.kernel.org>; Tue, 22 Sep 2020 00:37:14 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id e17so2265508wme.0 for <linux-bluetooth@vger.kernel.org>; Tue, 22 Sep 2020 00:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=f6NEte3lutGwCOE6JLOavb/M9H8I1XfzDGWcZi3Iq7Q=; b=XNaPLn0t+kxDTIOfVoPVBX4FPKsDFUw4iGC5BV0MEuJKWj/BvrlvjgHDauwC0X3iri klyOdAfM43Y3kMVpgvFWfFpwgIgy/4bLbHMv2iaKFjCSacJv5dHinCvYaGYW+H7Anrgo DHcq25ogTZUd/m5pG0b1NjM6JTn/fFVJtDY1E6vPZ89HxAi8vGOVIFVxL7tlHk0Hznp3 FDoQs92XNxUgQ80msZD3Axv/B0hTL33ZPIga+06PWwEN4jw3bXdGUlhja3t6o6+NCzHF /3q6zFTs5kMF70vvrisNhfHUbgH90fmb0A5Nz6HggmxQdyRPyUBYqQWE5ndgyOqCXGuP azEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=f6NEte3lutGwCOE6JLOavb/M9H8I1XfzDGWcZi3Iq7Q=; b=GR8+uutyS4phn6S9oNiAlSrJwdjDmxzUAEPiJdQu5owbg+hVz4X4JHU3668/LCaY9b r0zb4V9Yt77WHuPOhsKkMz5PYci4Ofcj8eFZubgguXnLHH+G7PAfJObX1jSiIVKGXzFb mw0QDxUKbh9cjDps/NmIH+WJTU5EIB1VmuoVzl0bB/8euBBhBGb9hTh6grdgaZIf4NQp vbBuPGdmG9/Liw4CXQMTCApNuoPx+Pht3RBsF/KNBAcgudgX9CiGQUQYDuRb/9yzVjAU W9T40cgZ9Dc3iPc7AdY19vyomjRuEwtTBKTt5ZubLA1vJ/Zwih929XaVpLkEPbO9uNw0 XPuw== X-Gm-Message-State: AOAM532JNZLWZeXqTvkL+y0Ol4WjDvxObqt/EFUI7loIbV7LFIBBwjum naALKcwlSJD7ejywxEJhBCeENLK8OxeAT/9pw9hKAQ== X-Google-Smtp-Source: ABdhPJzVWqCDtrVv7PLgmds+KflwVNovPQCQJ66ow/a2qlmcY4wT3p6qVfV9Z66NlM7m5l2WQeWjU4ZdmDud0sjo51k= X-Received: by 2002:a1c:7308:: with SMTP id d8mr3081805wmb.55.1600760232528; Tue, 22 Sep 2020 00:37:12 -0700 (PDT) MIME-Version: 1.0 References: <20200921163021.v1.1.Id3160295d33d44a59fa3f2a444d74f40d132ea5c@changeid> <CABBYNZJGfDoV+E-f6T=ZQ2RT0doXDdOB7tgVrt=4fpvKcpmH4w@mail.gmail.com> In-Reply-To: <CABBYNZJGfDoV+E-f6T=ZQ2RT0doXDdOB7tgVrt=4fpvKcpmH4w@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Tue, 22 Sep 2020 15:37:01 +0800 Message-ID: <CAJQfnxHcvm_-iCP-2Y6GR1vG4ZmMr==ZuMHBua8TeeiNbqAJgA@mail.gmail.com> Subject: Re: [PATCH v1] Bluetooth: Enforce key size of 16 bytes on FIPS level To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.85 / 15.00 / 15.00 X-Rspamd-Queue-Id: 3166C409B9 X-Rspamd-UID: 0103c7 Hi Luiz, On Tue, 22 Sep 2020 at 01:13, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Archie, > > On Mon, Sep 21, 2020 at 1:31 AM Archie Pusaka <apusaka@google.com> wrote: > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > According to the spec Ver 5.2, Vol 3, Part C, Sec 5.2.2.8: > > Device in security mode 4 level 4 shall enforce: > > 128-bit equivalent strength for link and encryption keys required > > using FIPS approved algorithms (E0 not allowed, SAFER+ not allowed, > > and P-192 not allowed; encryption key not shortened) > > > > This patch rejects connection with key size below 16 for FIPS level > > services. > > > > Signed-off-by: Archie Pusaka <apusaka@chromium.org> > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > > > --- > > > > net/bluetooth/l2cap_core.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > > index ade83e224567..306616ec26e6 100644 > > --- a/net/bluetooth/l2cap_core.c > > +++ b/net/bluetooth/l2cap_core.c > > @@ -1515,8 +1515,13 @@ static bool l2cap_check_enc_key_size(struct hci_conn *hcon) > > * that have no key size requirements. Ensure that the link is > > * actually encrypted before enforcing a key size. > > */ > > + int min_key_size = hcon->hdev->min_enc_key_size; > > + > > + if (hcon->sec_level == BT_SECURITY_FIPS) > > + min_key_size = 16; > > + > > return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) || > > - hcon->enc_key_size >= hcon->hdev->min_enc_key_size); > > + hcon->enc_key_size >= min_key_size); > > While this looks fine to me, it looks like this should be placed > elsewhere since it takes an hci_conn and it is not L2CAP specific. From what I understood, it is permissible to use AES-CCM P-256 encryption with key length < 16 when encrypting the link, but such a connection does not satisfy security level 4, and therefore must not be given access to level 4 services. However, I think it is permissible to give them access to level 3 services or below. Should I use l2cap chan->sec_level for this purpose? I'm kind of lost on the difference between hcon->sec_level and chan->sec_level. > > > } > > > > static void l2cap_do_start(struct l2cap_chan *chan) > > -- > > 2.28.0.681.g6f77f65b4e-goog > > > > > -- > Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 8HIaKEOsaV8TMAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 09:48:19 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id sN6JI0OsaV+KYAEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 09:48:19 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter04.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CA7EC4096A; Tue, 22 Sep 2020 09:48:14 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730142AbgIVHsG (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 22 Sep 2020 03:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729991AbgIVHsG (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 22 Sep 2020 03:48:06 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3000C0613CF for <linux-bluetooth@vger.kernel.org>; Tue, 22 Sep 2020 00:48:05 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id t10so15911891wrv.1 for <linux-bluetooth@vger.kernel.org>; Tue, 22 Sep 2020 00:48:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=q1gQqWOf8efX9sJ/D/OIGJtauHg2OW2WzxS92JQ9fUE=; b=SaYeIC5H1bZZrAM9cTd8lgo4ssxkGmovpX/F7UooYhJY5se0onVq7DcsZWbIEA7P0G vh6ACScYRo58pGOAVob/93wUzZlpzmSqHUQ/vdULPkYQf/Q4douhr+MNNofETAPKutxF BrOnZPs/AJlRF3td8lsmCuI8WCUBiu0d3iULvvf8koDIdQl7BaSR8ObXIR0mJdjYj3pU qducdvrUrXgYbN+dTe2IT/NdrlHAdftvvhJhdq+enO4jVvxE0nvVY3JhradQW6o0n1xW DdTHcekuqGwi4PRoZfDxytwawSu3zG9mj7oAXHyuNSJjv8VJV7OoOckgXCw/KB+P32NF kokA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=q1gQqWOf8efX9sJ/D/OIGJtauHg2OW2WzxS92JQ9fUE=; b=OxFhsw3gYsEg3J9aSINqTyN+43RGiNlFjc28mK8vOXjMKmDmRtCvP2frRJvQ3vvXjP S8pzXVx+pv4wQpzWDaJxnANMbCzOWWDbeuMP3LiWGmzlW7BzVMiSXURSmYmbzx9LU/Gr B8Syc5fJVgIn4kxYkiddtGLOV8smGsmMwE65hH3PdLns1gm1i4fNp+leY4roW5elJd9g LpbREQh7U+GnebPU+6zAMKdHppuj1R0RWnB1JgETEvEL48/z8LmhLlsAMInOJ7VCuso0 W2AhM5SZkAYXjyxH9HI9Sr4fX+m64zuBTbSZyljKA0JTBUoFah+iSvoWTHb+tnv8rHho dlWw== X-Gm-Message-State: AOAM530TX5ceAB4gJYsajOvhvoxwDacTIa7c2WPRgsVP4xA7whcfRI/R 9l2d+7ltHZk2oLs76siEnF+lozVP4xDZ0yg+mPor/Q== X-Google-Smtp-Source: ABdhPJxIFcifPYTJgkB/1B0+MTkMJ8QpqxtS1lOV0sAjIFDXfiY1b5BBtBuYd8Oy1YlH+O1VByBdp+Wk+CK7bzpq3A4= X-Received: by 2002:adf:dcc3:: with SMTP id x3mr3778468wrm.120.1600760884252; Tue, 22 Sep 2020 00:48:04 -0700 (PDT) MIME-Version: 1.0 References: <20200921155004.v2.1.I67a8b8cd4def8166970ca37109db46d731b62bb6@changeid> <CABBYNZLTZbwyL0ykmFezWrkNVnHoZt2KPtz+aQwo7TvhdC7TiQ@mail.gmail.com> In-Reply-To: <CABBYNZLTZbwyL0ykmFezWrkNVnHoZt2KPtz+aQwo7TvhdC7TiQ@mail.gmail.com> From: Archie Pusaka <apusaka@google.com> Date: Tue, 22 Sep 2020 15:47:53 +0800 Message-ID: <CAJQfnxFjL6RicwHyFgYzNp7WPrMePEOa2fgOX9TMju-z5AWsPg@mail.gmail.com> Subject: Re: [PATCH v2] Bluetooth: Check for encryption key size on connect To: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.69 / 15.00 / 15.00 X-Rspamd-Queue-Id: CA7EC4096A X-Rspamd-UID: 5e6b54 Hi Luiz, On Tue, 22 Sep 2020 at 01:15, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Archie, > > > On Mon, Sep 21, 2020 at 12:56 AM Archie Pusaka <apusaka@google.com> wrote: > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > When receiving connection, we only check whether the link has been > > encrypted, but not the encryption key size of the link. > > > > This patch adds check for encryption key size, and reject L2CAP > > connection which size is below the specified threshold (default 7) > > with security block. > > > > Here is some btmon trace. > > @ MGMT Event: New Link Key (0x0009) plen 26 {0x0001} [hci0] 5.847722 > > Store hint: No (0x00) > > BR/EDR Address: 38:00:25:F7:F1:B0 (OUI 38-00-25) > > Key type: Unauthenticated Combination key from P-192 (0x04) > > Link key: 7bf2f68c81305d63a6b0ee2c5a7a34bc > > PIN length: 0 > > > HCI Event: Encryption Change (0x08) plen 4 #29 [hci0] 5.871537 > > Status: Success (0x00) > > Handle: 256 > > Encryption: Enabled with E0 (0x01) > > < HCI Command: Read Encryp... (0x05|0x0008) plen 2 #30 [hci0] 5.871609 > > Handle: 256 > > > HCI Event: Command Complete (0x0e) plen 7 #31 [hci0] 5.872524 > > Read Encryption Key Size (0x05|0x0008) ncmd 1 > > Status: Success (0x00) > > Handle: 256 > > Key size: 3 > > > > ////// WITHOUT PATCH ////// > > > ACL Data RX: Handle 256 flags 0x02 dlen 12 #42 [hci0] 5.895023 > > L2CAP: Connection Request (0x02) ident 3 len 4 > > PSM: 4097 (0x1001) > > Source CID: 64 > > < ACL Data TX: Handle 256 flags 0x00 dlen 16 #43 [hci0] 5.895213 > > L2CAP: Connection Response (0x03) ident 3 len 8 > > Destination CID: 64 > > Source CID: 64 > > Result: Connection successful (0x0000) > > Status: No further information available (0x0000) > > > > ////// WITH PATCH ////// > > > ACL Data RX: Handle 256 flags 0x02 dlen 12 #42 [hci0] 4.887024 > > L2CAP: Connection Request (0x02) ident 3 len 4 > > PSM: 4097 (0x1001) > > Source CID: 64 > > < ACL Data TX: Handle 256 flags 0x00 dlen 16 #43 [hci0] 4.887127 > > L2CAP: Connection Response (0x03) ident 3 len 8 > > Destination CID: 0 > > Source CID: 64 > > Result: Connection refused - security block (0x0003) > > Status: No further information available (0x0000) > > > > Signed-off-by: Archie Pusaka <apusaka@chromium.org> > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > > > --- > > Btw, it looks like the patch sent by Alex Lu with the title > > [PATCH] Bluetooth: Fix the vulnerable issue on enc key size > > also solves the exact same issue. > > > > Changes in v2: > > * Add btmon trace to the commit message > > > > net/bluetooth/l2cap_core.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > > index ade83e224567..b4fc0ad38aaa 100644 > > --- a/net/bluetooth/l2cap_core.c > > +++ b/net/bluetooth/l2cap_core.c > > @@ -4101,7 +4101,8 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn, > > > > /* Check if the ACL is secure enough (if not SDP) */ > > if (psm != cpu_to_le16(L2CAP_PSM_SDP) && > > - !hci_conn_check_link_mode(conn->hcon)) { > > + (!hci_conn_check_link_mode(conn->hcon) || > > + !l2cap_check_enc_key_size(conn->hcon))) { > > I wonder if we couldn't incorporate the check of key size into > hci_conn_check_link_mode, like I said in the first patch checking the > enc key size should not be specific to L2CAP. Yes, I could move the check into hci_conn_check_link_mode. At first look, this function is also called by AMP which I am not familiar with. In addition, I found this patch which moves this check outside hci_conn, so I have my doubts there. https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/commit/?id=693cd8ce3f882524a5d06f7800dd8492411877b3 > > > conn->disc_reason = HCI_ERROR_AUTH_FAILURE; > > result = L2CAP_CR_SEC_BLOCK; > > goto response; > > -- > > 2.28.0.681.g6f77f65b4e-goog > > > > > -- > Luiz Augusto von Dentz Thanks, Archie Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id oKDuOS2uaV8TMAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 09:56:29 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id ON3WNi2uaV9rngAADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 09:56:29 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id D7A49400B3; Tue, 22 Sep 2020 09:56:25 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726567AbgIVH4S (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 22 Sep 2020 03:56:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726424AbgIVH4S (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 22 Sep 2020 03:56:18 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18BF4C0613D0 for <linux-bluetooth@vger.kernel.org>; Tue, 22 Sep 2020 00:56:18 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id b18so15405723qto.4 for <linux-bluetooth@vger.kernel.org>; Tue, 22 Sep 2020 00:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=ClKheBsVPCjUi1w0lCfGtWlJh8qfJBEdB5PCy2ar4eQ=; b=AucI3MRGxCu1uQ3YwRyhbF9AV90VUSbzOq+E13sGK46lv3zhafkIXVxlaRdbZkMOFp uD+RQhz++rvrSt6zSCfX/jNrMzRJDUKglbhV+XnvrPhf8d5vfmHukiMUmnCgNCeVYv0d 13PDmn7qysJV03qMFOEe+mdUoYRLiowtLKjq44/u9/viZqJFz8tM9/zjxebu5IypWNw1 as2UZN+TQH0E3iuIDsafThBzdP7AFwsToQprz9uMK1YtM7n35824NKcJnf3OLaAQESqV IPhbZNrRqs/Tmj6NLv8mloisoRhBVAzbirZftx6ipmL+J3MELZiMjgu7h51BMWwg6aoq 8xFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=ClKheBsVPCjUi1w0lCfGtWlJh8qfJBEdB5PCy2ar4eQ=; b=ENkYAGAKLy62snvzdHDwjgZng8GmlD7g3QnIjSgs1qSQZRovPiyGAODCPGrKmDHO57 dTdt5UGp+2An9RHcJbjq4stEM0hG3tNL6DKHH/TXenzf5L4vbjuh1LZ39EED86iXeUvr RFSj0cnM5XvRdr7V6SB0NUcgrPUa2kvhooEGoZNsa99OuBkKjyfqe6VFaAL09aG8LZ7h n93MKiMdMPuYhYfpmqlYI3Y0IdDNksk6uQSQIbUP0je4WvlhOxUcrxboBxJWKATFrz/g ltgsWgP3YYrN5z/s1TTNYPV/lrkHGaAwsRMnufrMFZpLupMaD4wR7O++bwWEfTQwLCPb Re9Q== X-Gm-Message-State: AOAM533Ql5ap7sGIGUVzPpFJ7IQ3z2kt7EzyXWOQBrJ63NUeaeMfM9gH 3wXBfYoGxe73WQUIJf8mwrCjfS2dPOXJC4W6XIOJ3ELzckVP+SAVm3E0VUxCLTBAQ8XH2eM7zct +I+P5SiWbQzWVW2u4fKSPHsbk4N5OzQHOpMGyCZH+wWR7fyojgIZ6Nx3Qe7b3x3d3ink+TJvArH zs X-Google-Smtp-Source: ABdhPJyR9yLwG5vy6sWNnj6uUqoZ9+AuNeiZPDSyud1VBRfooMC47509/9C+6TBmwN4TjtWXTMXV0zSHSyMT Sender: "apusaka via sendgmr" <apusaka@apusaka-p920.tpe.corp.google.com> X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:ad4:57cc:: with SMTP id y12mr4563202qvx.48.1600761376969; Tue, 22 Sep 2020 00:56:16 -0700 (PDT) Date: Tue, 22 Sep 2020 15:56:11 +0800 Message-Id: <20200922155548.v3.1.I67a8b8cd4def8166970ca37109db46d731b62bb6@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3] Bluetooth: Check for encryption key size on connect From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: D7A49400B3 X-Rspamd-UID: f5d0a7 From: Archie Pusaka <apusaka@chromium.org> When receiving connection, we only check whether the link has been encrypted, but not the encryption key size of the link. This patch adds check for encryption key size, and reject L2CAP connection which size is below the specified threshold (default 7) with security block. Here is some btmon trace. @ MGMT Event: New Link Key (0x0009) plen 26 {0x0001} [hci0] 5.847722 Store hint: No (0x00) BR/EDR Address: 38:00:25:F7:F1:B0 (OUI 38-00-25) Key type: Unauthenticated Combination key from P-192 (0x04) Link key: 7bf2f68c81305d63a6b0ee2c5a7a34bc PIN length: 0 > HCI Event: Encryption Change (0x08) plen 4 #29 [hci0] 5.871537 Status: Success (0x00) Handle: 256 Encryption: Enabled with E0 (0x01) < HCI Command: Read Encryp... (0x05|0x0008) plen 2 #30 [hci0] 5.871609 Handle: 256 > HCI Event: Command Complete (0x0e) plen 7 #31 [hci0] 5.872524 Read Encryption Key Size (0x05|0x0008) ncmd 1 Status: Success (0x00) Handle: 256 Key size: 3 ////// WITHOUT PATCH ////// > ACL Data RX: Handle 256 flags 0x02 dlen 12 #42 [hci0] 5.895023 L2CAP: Connection Request (0x02) ident 3 len 4 PSM: 4097 (0x1001) Source CID: 64 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #43 [hci0] 5.895213 L2CAP: Connection Response (0x03) ident 3 len 8 Destination CID: 64 Source CID: 64 Result: Connection successful (0x0000) Status: No further information available (0x0000) ////// WITH PATCH ////// > ACL Data RX: Handle 256 flags 0x02 dlen 12 #42 [hci0] 4.887024 L2CAP: Connection Request (0x02) ident 3 len 4 PSM: 4097 (0x1001) Source CID: 64 < ACL Data TX: Handle 256 flags 0x00 dlen 16 #43 [hci0] 4.887127 L2CAP: Connection Response (0x03) ident 3 len 8 Destination CID: 0 Source CID: 64 Result: Connection refused - security block (0x0003) Status: No further information available (0x0000) Signed-off-by: Archie Pusaka <apusaka@chromium.org> --- Changes in v3: * Move the check to hci_conn_check_link_mode() Changes in v2: * Add btmon trace to the commit message net/bluetooth/hci_conn.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 9832f8445d43..89085fac797c 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1348,6 +1348,10 @@ int hci_conn_check_link_mode(struct hci_conn *conn) !test_bit(HCI_CONN_ENCRYPT, &conn->flags)) return 0; + if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && + conn->enc_key_size < conn->hdev->min_enc_key_size) + return 0; + return 1; } -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id CKRuHI8ual8dUQAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 19:04:15 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id cJRkGY8ual/CugEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 19:04:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 92577A0E3F; Tue, 22 Sep 2020 19:04:10 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726758AbgIVRDp (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 22 Sep 2020 13:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726727AbgIVRDo (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 22 Sep 2020 13:03:44 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2A79C061755; Tue, 22 Sep 2020 10:03:44 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id n2so21813478oij.1; Tue, 22 Sep 2020 10:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q/1noB1uoT0q1MEAyYLRUUrUwwNCmPj3LxtXlQWic5o=; b=YVIEvxgn5fRl0Xc7++NnbeWpp9rLCTLN5PXSu6zneodfFyC61GSIJ02Pu1Jp96qIdb ZouE2V73ARmGETS2+yiangAhtI7jXRAsqjNwoCqsg2v9QSF2hMz6CiGkQSrmQKrDUpsl tGw0rnWCT2P4G067jGWVgHfh0qHnVnfBQqTfrGrUuPnm1QNhEvTt8CUeOUSATdGjjGHK SMLEX8r3HuQJ2l3L/NuvagSrxFTS5WDSeyGuz5opVpwIHwphTFVc1qtaTvF7CtbEdQI6 WBijEm+Es89lqoyi1qlZeOkpzH4+uLN0cxuY/Ds12MJR8e0ADosWKYKQ0lMJoJr8KkoE 9AeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q/1noB1uoT0q1MEAyYLRUUrUwwNCmPj3LxtXlQWic5o=; b=blkDf+meC0SD13a+XldVPXZo4RlyVCxIZiDTe8RNJFfg2YX4mekubJPfhNyuvpObVz fyCiu3TsyOE7BI3ahkdyjAl/45pNecYBZ2zOMouqV4/YkzTUA/nkBnpWOdiJNeTZ+hUV PhycGC8diHl1PNZbfA/A0EibRGuI6OyNrBxDmf8Hu4YtvELGCle+1wKXhMppIV8fObWX x9lLTCEvrgedzKiCkfdvsx4aOn3uK7K3ChId1Pn70LkCha5b92SDyAaEzgyTx7YU+TcA 9zQMgycSdn6VpIlcrnqqBRnINFyUA8F19SoNA0LoUz5j5IEqj7CotJTrnfIarnv2XEDh fh4g== X-Gm-Message-State: AOAM533QNt3lfLup1JAW39l37GW2TFq/pR+z4VaXTA8nIs+2WCg7+Bdc db5Te2qCaCRs/U35PTA0UEzoVj9M+es8G00ad8g= X-Google-Smtp-Source: ABdhPJwnU01jlc8sgDyjiU4lgWFdsQURLkMJsTdCG+CUOHALcxnBr0/m39qct+e91SzH8hNn4klqCv6/4x90pnH6Y1Q= X-Received: by 2002:aca:38d7:: with SMTP id f206mr3035639oia.48.1600794223658; Tue, 22 Sep 2020 10:03:43 -0700 (PDT) MIME-Version: 1.0 References: <20200921155004.v2.1.I67a8b8cd4def8166970ca37109db46d731b62bb6@changeid> <CABBYNZLTZbwyL0ykmFezWrkNVnHoZt2KPtz+aQwo7TvhdC7TiQ@mail.gmail.com> <CAJQfnxFjL6RicwHyFgYzNp7WPrMePEOa2fgOX9TMju-z5AWsPg@mail.gmail.com> In-Reply-To: <CAJQfnxFjL6RicwHyFgYzNp7WPrMePEOa2fgOX9TMju-z5AWsPg@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 22 Sep 2020 10:03:31 -0700 Message-ID: <CABBYNZJdY+QBiCk9nBhJ-gUm-K0ZF6U=03f+tqKvs7c+oG=axA@mail.gmail.com> Subject: Re: [PATCH v2] Bluetooth: Check for encryption key size on connect To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.70 / 15.00 / 15.00 X-Rspamd-Queue-Id: 92577A0E3F X-Rspamd-UID: 5bcd3a Hi Archie, On Tue, Sep 22, 2020 at 12:48 AM Archie Pusaka <apusaka@google.com> wrote: > > Hi Luiz, > > On Tue, 22 Sep 2020 at 01:15, Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Archie, > > > > > > On Mon, Sep 21, 2020 at 12:56 AM Archie Pusaka <apusaka@google.com> wrote: > > > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > > > When receiving connection, we only check whether the link has been > > > encrypted, but not the encryption key size of the link. > > > > > > This patch adds check for encryption key size, and reject L2CAP > > > connection which size is below the specified threshold (default 7) > > > with security block. > > > > > > Here is some btmon trace. > > > @ MGMT Event: New Link Key (0x0009) plen 26 {0x0001} [hci0] 5.847722 > > > Store hint: No (0x00) > > > BR/EDR Address: 38:00:25:F7:F1:B0 (OUI 38-00-25) > > > Key type: Unauthenticated Combination key from P-192 (0x04) > > > Link key: 7bf2f68c81305d63a6b0ee2c5a7a34bc > > > PIN length: 0 > > > > HCI Event: Encryption Change (0x08) plen 4 #29 [hci0] 5.871537 > > > Status: Success (0x00) > > > Handle: 256 > > > Encryption: Enabled with E0 (0x01) > > > < HCI Command: Read Encryp... (0x05|0x0008) plen 2 #30 [hci0] 5.871609 > > > Handle: 256 > > > > HCI Event: Command Complete (0x0e) plen 7 #31 [hci0] 5.872524 > > > Read Encryption Key Size (0x05|0x0008) ncmd 1 > > > Status: Success (0x00) > > > Handle: 256 > > > Key size: 3 > > > > > > ////// WITHOUT PATCH ////// > > > > ACL Data RX: Handle 256 flags 0x02 dlen 12 #42 [hci0] 5.895023 > > > L2CAP: Connection Request (0x02) ident 3 len 4 > > > PSM: 4097 (0x1001) > > > Source CID: 64 > > > < ACL Data TX: Handle 256 flags 0x00 dlen 16 #43 [hci0] 5.895213 > > > L2CAP: Connection Response (0x03) ident 3 len 8 > > > Destination CID: 64 > > > Source CID: 64 > > > Result: Connection successful (0x0000) > > > Status: No further information available (0x0000) > > > > > > ////// WITH PATCH ////// > > > > ACL Data RX: Handle 256 flags 0x02 dlen 12 #42 [hci0] 4.887024 > > > L2CAP: Connection Request (0x02) ident 3 len 4 > > > PSM: 4097 (0x1001) > > > Source CID: 64 > > > < ACL Data TX: Handle 256 flags 0x00 dlen 16 #43 [hci0] 4.887127 > > > L2CAP: Connection Response (0x03) ident 3 len 8 > > > Destination CID: 0 > > > Source CID: 64 > > > Result: Connection refused - security block (0x0003) > > > Status: No further information available (0x0000) > > > > > > Signed-off-by: Archie Pusaka <apusaka@chromium.org> > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > > > > > --- > > > Btw, it looks like the patch sent by Alex Lu with the title > > > [PATCH] Bluetooth: Fix the vulnerable issue on enc key size > > > also solves the exact same issue. > > > > > > Changes in v2: > > > * Add btmon trace to the commit message > > > > > > net/bluetooth/l2cap_core.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > > > index ade83e224567..b4fc0ad38aaa 100644 > > > --- a/net/bluetooth/l2cap_core.c > > > +++ b/net/bluetooth/l2cap_core.c > > > @@ -4101,7 +4101,8 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn, > > > > > > /* Check if the ACL is secure enough (if not SDP) */ > > > if (psm != cpu_to_le16(L2CAP_PSM_SDP) && > > > - !hci_conn_check_link_mode(conn->hcon)) { > > > + (!hci_conn_check_link_mode(conn->hcon) || > > > + !l2cap_check_enc_key_size(conn->hcon))) { > > > > I wonder if we couldn't incorporate the check of key size into > > hci_conn_check_link_mode, like I said in the first patch checking the > > enc key size should not be specific to L2CAP. > > Yes, I could move the check into hci_conn_check_link_mode. > At first look, this function is also called by AMP which I am not > familiar with. In addition, I found this patch which moves this check > outside hci_conn, so I have my doubts there. > https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/commit/?id=693cd8ce3f882524a5d06f7800dd8492411877b3 Right, I think we can have it as part of the hci_conn_check_link_mode, that said it is perhaps better to have it as hci_conn_check_enc_key_size instead as it is not L2CAP expecific. Other than that it looks good to me. > > > > > conn->disc_reason = HCI_ERROR_AUTH_FAILURE; > > > result = L2CAP_CR_SEC_BLOCK; > > > goto response; > > > -- > > > 2.28.0.681.g6f77f65b4e-goog > > > > > > > > > -- > > Luiz Augusto von Dentz > > Thanks, > Archie -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yFk9FE8yal+YTAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 19:20:15 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id iFHdEU8yal+lKAAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 19:20:15 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 4B3BAA0B0B; Tue, 22 Sep 2020 19:20:11 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726632AbgIVRUD (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 22 Sep 2020 13:20:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726526AbgIVRUD (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 22 Sep 2020 13:20:03 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D51C061755; Tue, 22 Sep 2020 10:20:03 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id e23so16334811otk.7; Tue, 22 Sep 2020 10:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EItoq1kaiHeWVc5lky8YhdzGpyspzkaqvTZAN+0uG8s=; b=ek1BIZZyVl3RntwXpKxZKVRy7AjMYd2t5ZjDu0Gkr+83ZXPJiTnzcLSziQYU5YQi9M zz5wOAudN8qHSec8RMYhz3079Sg2fztpxsFVlYPTbpjJj4NEFIouF6csvy38nV6qdvO4 LHFyhEB6+sDeNLM20tDikE0MdOwP+PWOSb8F52houXJNiMI3wO2FMRTniR98K97dgkZ4 EtCLz1jHbknfXgrX6t3JeREbjP8noQCnc9wvt1K0D+0uAg6Q1ij30KxXkn+n5pJw/Wot Jh3lFs3CaqraBeH+JP3TFUsIDL8If4ZRXHdII6p6FMHRs1zjGRt8K18vJWC8slKoX1wA E1DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EItoq1kaiHeWVc5lky8YhdzGpyspzkaqvTZAN+0uG8s=; b=l0+h5lLkvRLkkQnFYZ/5cFi7WhDHwLkvwEFVEfINT1DSl/+zies1OznIRuV0Z3BaAm VMW7M1QEcE/c+uYsf4J7xr40L7fWLWvTZCF9QyOlr9Rn+l3Sr9gaJfMBR0JmQs4nVwCO GCnbhXSf+mCRQ9RLoN1YynMgH1+q3YEhCOyQ4eDJU3l28AQaJqoFHRBZeUvM+e9SfW2E /fjlgdJT2fFZQHT9FVJs8cWCK6j+H2i7jYQ5xkljd0rZqTlQoBekJDflzEhHwhBWkCDK 6F2H/BMaQ0ow0OL5GQS0lsikYszpOZZ1rr36FOdSX3Bu0sl/MOYZUFXmrlefP7WyjPj2 sxMQ== X-Gm-Message-State: AOAM531IjbME+drraLp1MfJkm4ZexmoZ4pmEMl0/g0cNPoV07MNnQGYY FARMH/iwbZAPDa7qQcElOtrbgJJ2SAZrguiEfbk= X-Google-Smtp-Source: ABdhPJwNcpShFc8c3V/UC1bmKbpnJq1sPySTQ40fTrCHUXJ486Nscbfvc9yXAnnr7C/wr8kImZHNzbiYtV9UD4Td08Q= X-Received: by 2002:a9d:4695:: with SMTP id z21mr3525657ote.91.1600795202320; Tue, 22 Sep 2020 10:20:02 -0700 (PDT) MIME-Version: 1.0 References: <20200921163021.v1.1.Id3160295d33d44a59fa3f2a444d74f40d132ea5c@changeid> <CABBYNZJGfDoV+E-f6T=ZQ2RT0doXDdOB7tgVrt=4fpvKcpmH4w@mail.gmail.com> <CAJQfnxHcvm_-iCP-2Y6GR1vG4ZmMr==ZuMHBua8TeeiNbqAJgA@mail.gmail.com> In-Reply-To: <CAJQfnxHcvm_-iCP-2Y6GR1vG4ZmMr==ZuMHBua8TeeiNbqAJgA@mail.gmail.com> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 22 Sep 2020 10:19:50 -0700 Message-ID: <CABBYNZKuXtf5Z_zHG1h2c6_0to8o2MqvmQvt-8mmX0hdb3_B9g@mail.gmail.com> Subject: Re: [PATCH v1] Bluetooth: Enforce key size of 16 bytes on FIPS level To: Archie Pusaka <apusaka@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.14 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4B3BAA0B0B X-Rspamd-UID: 97341c Hi Archie, On Tue, Sep 22, 2020 at 12:37 AM Archie Pusaka <apusaka@google.com> wrote: > > Hi Luiz, > > On Tue, 22 Sep 2020 at 01:13, Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: > > > > Hi Archie, > > > > On Mon, Sep 21, 2020 at 1:31 AM Archie Pusaka <apusaka@google.com> wrote: > > > > > > From: Archie Pusaka <apusaka@chromium.org> > > > > > > According to the spec Ver 5.2, Vol 3, Part C, Sec 5.2.2.8: > > > Device in security mode 4 level 4 shall enforce: > > > 128-bit equivalent strength for link and encryption keys required > > > using FIPS approved algorithms (E0 not allowed, SAFER+ not allowed, > > > and P-192 not allowed; encryption key not shortened) > > > > > > This patch rejects connection with key size below 16 for FIPS level > > > services. > > > > > > Signed-off-by: Archie Pusaka <apusaka@chromium.org> > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > > > > > --- > > > > > > net/bluetooth/l2cap_core.c | 7 ++++++- > > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > > > index ade83e224567..306616ec26e6 100644 > > > --- a/net/bluetooth/l2cap_core.c > > > +++ b/net/bluetooth/l2cap_core.c > > > @@ -1515,8 +1515,13 @@ static bool l2cap_check_enc_key_size(struct hci_conn *hcon) > > > * that have no key size requirements. Ensure that the link is > > > * actually encrypted before enforcing a key size. > > > */ > > > + int min_key_size = hcon->hdev->min_enc_key_size; > > > + > > > + if (hcon->sec_level == BT_SECURITY_FIPS) > > > + min_key_size = 16; > > > + > > > return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) || > > > - hcon->enc_key_size >= hcon->hdev->min_enc_key_size); > > > + hcon->enc_key_size >= min_key_size); > > > > While this looks fine to me, it looks like this should be placed > > elsewhere since it takes an hci_conn and it is not L2CAP specific. > > From what I understood, it is permissible to use AES-CCM P-256 > encryption with key length < 16 when encrypting the link, but such a > connection does not satisfy security level 4, and therefore must not > be given access to level 4 services. However, I think it is > permissible to give them access to level 3 services or below. > > Should I use l2cap chan->sec_level for this purpose? I'm kind of lost > on the difference between hcon->sec_level and chan->sec_level. The chan->sec_level is L2CAP channel required sec_level while hcon->sec_level is the current secure level in effect, at some point I guess we assign the hcon->sec_level with chan->sec_level but Im not sure if that has already happened here or not. > > > > > } > > > > > > static void l2cap_do_start(struct l2cap_chan *chan) > > > -- > > > 2.28.0.681.g6f77f65b4e-goog > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id QOSIESRyal/+yQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Tue, 22 Sep 2020 23:52:36 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id mNCNDiRyal/3KgEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Tue, 22 Sep 2020 23:52:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 41CE64097C; Tue, 22 Sep 2020 23:52:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726676AbgIVVwS (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 22 Sep 2020 17:52:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726652AbgIVVwS (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 22 Sep 2020 17:52:18 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 438A0C061755; Tue, 22 Sep 2020 14:52:18 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id 60so17077374otw.3; Tue, 22 Sep 2020 14:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rJHrPEHFU9xGNOs6dBT3ctuUX+KiWneaN/TtemOxD48=; b=XUlaIHRgQ/59eTDcn7l5Aty8oF3LuZp8+aNbX8pn5qMwxsJkdZMwDPje5PM3XUex+o xmNbTIeOUZtfmiSW4DmZ5ijuKRVWdLwVSr8gWOf0tv9mAmDO8Geah7jZR4XsSzN0Fame zm+kd20vEQ6bt5h3TQuYjvrwfGrJ+8/ZNQdkR00UsPGNwjaLLpofdjtgaVsUgDKH9Nmo 6JEK8XZynhU62XkoKGnXu1opb/h7EHzYRIluQy4enwYc9PfyHDSTvs7BNj0eDWJs+isI WxPOVuuUh6AvJBpPaef4qN26fpn2DjYERZT/WQ+hEpTbuEZ/y++0EQnge8LeI8Bf1H7S T6EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rJHrPEHFU9xGNOs6dBT3ctuUX+KiWneaN/TtemOxD48=; b=YFE+Ele5sMIvfa77likG2Znosr3e2ud37OruAUOE55ctW9xjPbbhC0FwLYOSd/dyJS Ma7vzRI99Unc7EohvoQJFOb/yJ3+Y6tbQi53lCBvcpWibl+cm5I3tVJsW3gUD+evPd3X IpNnu9vS7k4kpBkbGmdav2ONepr4fMSxys3tN8PBgltMP8U2E6XkPsAG3led6d18n6MS C+fKAQb69K9Ybu+pBiPk/2lnVDUxe2+qpKLBnspoDWef16QEHz69YwfTb3sQ5XehLkUl /NCoDGj8Wl8/ipn7zZxjrKcPPh+AiNvaAkmop6pwjDJjOrfBTkhkHeuJKeJzBfiUIN9L B8wQ== X-Gm-Message-State: AOAM533TfDO1dN8ytv4lF9Af2P5FMl09SLUnirGUlNcHgLcTsCnqniWz vZFIYGw0BpFfmBWyiDbiH8tTWDCsBsGNGzVHJXI= X-Google-Smtp-Source: ABdhPJxohETf9B11qf8NYpRMANewcjBX3Vy0Zb0EnB+27vbDOutc4ruHVR/zuHUEMJNhUizjvlNVgT7ZIVv+APKwdUQ= X-Received: by 2002:a9d:4695:: with SMTP id z21mr4195654ote.91.1600811537405; Tue, 22 Sep 2020 14:52:17 -0700 (PDT) MIME-Version: 1.0 References: <20200921122216.v4.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> In-Reply-To: <20200921122216.v4.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: Tue, 22 Sep 2020 14:52:04 -0700 Message-ID: <CABBYNZJ5PeecubNH_heeUsO8P4w7_27aFUt_bHFKtSgF36Fcyw@mail.gmail.com> Subject: Re: [PATCH v4 1/4] Bluetooth: Interleave with allowlist scan To: Howard Chung <howardchung@google.com> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Alain Michaud <alainm@chromium.org>, Miao-chen Chou <mcchou@chromium.org>, mmandlik@chromium.orgi, Manish Mandlik <mmandlik@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -4.11 / 15.00 / 15.00 X-Rspamd-Queue-Id: 41CE64097C X-Rspamd-UID: 5de6b5 Hi Howard, On Sun, Sep 20, 2020 at 9:23 PM Howard Chung <howardchung@google.com> wrote: > > This patch implements the interleaving between allowlist scan and > no-filter scan. It'll be used to save power when at least one monitor is > registered and at least one pending connection or one device to be > scanned for. > > The durations of the allowlist scan and the no-filter scan are > controlled by MGMT command: Set Default System Configuration. The > default values are set randomly for now. > > Signed-off-by: Howard Chung <howardchung@google.com> > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > --- > > Changes in v4: > - Rebase to bluetooth-next/master (previous 2 patches are applied) > - Fix over 80 chars limit in mgmt_config.c > - Set EnableAdvMonInterleaveScan default to Disable > > Changes in v3: > - Remove 'Bluez' prefix > > Changes in v2: > - remove 'case 0x001c' in mgmt_config.c > > include/net/bluetooth/hci_core.h | 10 +++ > net/bluetooth/hci_core.c | 4 + > net/bluetooth/hci_request.c | 137 +++++++++++++++++++++++++++++-- > net/bluetooth/mgmt_config.c | 10 +++ > 4 files changed, 153 insertions(+), 8 deletions(-) > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h > index 9873e1c8cd163..179350f869fdb 100644 > --- a/include/net/bluetooth/hci_core.h > +++ b/include/net/bluetooth/hci_core.h > @@ -361,6 +361,8 @@ struct hci_dev { > __u8 ssp_debug_mode; > __u8 hw_error_code; > __u32 clock; > + __u16 advmon_allowlist_duration; > + __u16 advmon_no_filter_duration; > > __u16 devid_source; > __u16 devid_vendor; > @@ -542,6 +544,14 @@ struct hci_dev { > struct delayed_work rpa_expired; > bdaddr_t rpa; > > + enum { > + ADV_MONITOR_SCAN_NONE, > + ADV_MONITOR_SCAN_NO_FILTER, > + ADV_MONITOR_SCAN_ALLOWLIST > + } adv_monitor_scan_state; > + > + struct delayed_work interleave_adv_monitor_scan; > + > #if IS_ENABLED(CONFIG_BT_LEDS) > struct led_trigger *power_led; > #endif > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index f30a1f5950e15..6c8850149265a 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -3592,6 +3592,10 @@ struct hci_dev *hci_alloc_dev(void) > hdev->cur_adv_instance = 0x00; > hdev->adv_instance_timeout = 0; > > + /* The default values will be chosen in the future */ > + hdev->advmon_allowlist_duration = 300; > + hdev->advmon_no_filter_duration = 500; > + > hdev->sniff_max_interval = 800; > hdev->sniff_min_interval = 80; > > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > index d2b06f5c93804..89443b48d90ce 100644 > --- a/net/bluetooth/hci_request.c > +++ b/net/bluetooth/hci_request.c > @@ -378,6 +378,57 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable) > hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type); > } > > +static void start_interleave_scan(struct hci_dev *hdev) > +{ > + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; > + queue_delayed_work(hdev->req_workqueue, > + &hdev->interleave_adv_monitor_scan, 0); > +} > + > +static bool is_interleave_scanning(struct hci_dev *hdev) > +{ > + return hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_NONE; > +} > + > +static void cancel_interleave_scan(struct hci_dev *hdev) > +{ > + bt_dev_dbg(hdev, "%s cancelling interleave scan", hdev->name); > + > + cancel_delayed_work_sync(&hdev->interleave_adv_monitor_scan); > + > + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NONE; > +} > + > +/* Return true if interleave_scan is running after exiting this function, > + * otherwise, return false > + */ > +static bool update_adv_monitor_scan_state(struct hci_dev *hdev) > +{ > + if (!hci_is_adv_monitoring(hdev) || > + (list_empty(&hdev->pend_le_conns) && > + list_empty(&hdev->pend_le_reports))) { > + if (is_interleave_scanning(hdev)) { > + /* If the interleave condition no longer holds, cancel > + * the existed interleave scan. > + */ > + cancel_interleave_scan(hdev); > + } > + return false; > + } > + > + if (!is_interleave_scanning(hdev)) { > + /* If there is at least one ADV monitors and one pending LE > + * connection or one device to be scanned for, we should > + * alternate between allowlist scan and one without any filters > + * to save power. > + */ > + start_interleave_scan(hdev); > + bt_dev_dbg(hdev, "%s starting interleave scan", hdev->name); > + } > + > + return true; > +} > + > /* This function controls the background scanning based on hdev->pend_le_conns > * list. If there are pending LE connection we start the background scanning, > * otherwise we stop it. > @@ -449,9 +500,11 @@ static void __hci_update_background_scan(struct hci_request *req) > if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) > hci_req_add_le_scan_disable(req, false); > > - hci_req_add_le_passive_scan(req); > - > - BT_DBG("%s starting background scanning", hdev->name); > + if (!update_adv_monitor_scan_state(hdev)) { > + hci_req_add_le_passive_scan(req); > + bt_dev_dbg(hdev, "%s starting background scanning", > + hdev->name); > + } We should probably try to follow the same names as used for background_scan here, e.g. name it __hci_update_interleaved_scan, also perhaps that should fallback to hci_req_add_le_passive_scan on its own. > } > } > > @@ -844,12 +897,17 @@ static u8 update_white_list(struct hci_request *req) > return 0x00; > } > > - /* Once the controller offloading of advertisement monitor is in place, > - * the if condition should include the support of MSFT extension > - * support. If suspend is ongoing, whitelist should be the default to > - * prevent waking by random advertisements. > + /* Use the allowlist unless the following conditions are all true: > + * - We are not currently suspending > + * - There are 1 or more ADV monitors registered > + * - Interleaved scanning is not currently using the allowlist > + * > + * Once the controller offloading of advertisement monitor is in place, > + * the above condition should include the support of MSFT extension > + * support. > */ > - if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended) > + if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended && > + hdev->adv_monitor_scan_state != ADV_MONITOR_SCAN_ALLOWLIST) > return 0x00; > > /* Select filter policy to use white list */ > @@ -1002,6 +1060,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) > &own_addr_type)) > return; > > + bt_dev_dbg(hdev, "interleave state %d", hdev->adv_monitor_scan_state); Is this really needed here, I though hci_req_add_le_passive_scan would only be used if interleaved scanning was not used. > /* Adding or removing entries from the white list must > * happen before enabling scanning. The controller does > * not allow white list modification while scanning. > @@ -1871,6 +1930,64 @@ static void adv_timeout_expire(struct work_struct *work) > hci_dev_unlock(hdev); > } > > +static int add_le_interleave_adv_monitor_scan(struct hci_request *req, > + unsigned long opt) Rename to hci_req_add_le_interleaved_scan > +{ > + struct hci_dev *hdev = req->hdev; > + int ret = 0; > + > + hci_dev_lock(hdev); > + > + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) > + hci_req_add_le_scan_disable(req, false); > + hci_req_add_le_passive_scan(req); > + > + switch (hdev->adv_monitor_scan_state) { > + case ADV_MONITOR_SCAN_ALLOWLIST: > + bt_dev_dbg(hdev, "next state: allowlist"); > + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_NO_FILTER; > + break; > + case ADV_MONITOR_SCAN_NO_FILTER: > + bt_dev_dbg(hdev, "next state: no filter"); > + hdev->adv_monitor_scan_state = ADV_MONITOR_SCAN_ALLOWLIST; > + break; > + case ADV_MONITOR_SCAN_NONE: > + default: > + BT_ERR("unexpected error"); > + ret = -1; > + } > + > + hci_dev_unlock(hdev); > + > + return ret; > +} > + > +static void interleave_adv_monitor_scan_work(struct work_struct *work) Rename to interleave_scan_work > +{ > + struct hci_dev *hdev = container_of(work, struct hci_dev, > + interleave_adv_monitor_scan.work); > + u8 status; > + unsigned long timeout; > + > + if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_ALLOWLIST) { > + timeout = msecs_to_jiffies(hdev->advmon_allowlist_duration); > + } else if (hdev->adv_monitor_scan_state == ADV_MONITOR_SCAN_NO_FILTER) { > + timeout = msecs_to_jiffies(hdev->advmon_no_filter_duration); > + } else { > + bt_dev_err(hdev, "unexpected error"); > + return; > + } > + > + hci_req_sync(hdev, add_le_interleave_adv_monitor_scan, 0, > + HCI_CMD_TIMEOUT, &status); > + > + /* Don't continue interleaving if it was canceled */ > + if (is_interleave_scanning(hdev)) { > + queue_delayed_work(hdev->req_workqueue, > + &hdev->interleave_adv_monitor_scan, timeout); > + } > +} > + > int hci_get_random_address(struct hci_dev *hdev, bool require_privacy, > bool use_rpa, struct adv_info *adv_instance, > u8 *own_addr_type, bdaddr_t *rand_addr) > @@ -3292,6 +3409,8 @@ void hci_request_setup(struct hci_dev *hdev) > INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); > INIT_DELAYED_WORK(&hdev->le_scan_restart, le_scan_restart_work); > INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire); > + INIT_DELAYED_WORK(&hdev->interleave_adv_monitor_scan, > + interleave_adv_monitor_scan_work); We can probably remove adv_monitor term on functions/variables and just use interleave_scan. > } > > void hci_request_cancel_all(struct hci_dev *hdev) > @@ -3311,4 +3430,6 @@ void hci_request_cancel_all(struct hci_dev *hdev) > cancel_delayed_work_sync(&hdev->adv_instance_expire); > hdev->adv_instance_timeout = 0; > } > + > + cancel_interleave_scan(hdev); > } > diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c > index b30b571f8caf8..2d3ad288c78ac 100644 > --- a/net/bluetooth/mgmt_config.c > +++ b/net/bluetooth/mgmt_config.c > @@ -67,6 +67,8 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > HDEV_PARAM_U16(0x001a, le_supv_timeout), > HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b, > def_le_autoconnect_timeout), > + HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), > + HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), > }; > struct mgmt_rp_read_def_system_config *rp = (void *)params; > > @@ -138,6 +140,8 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > case 0x0019: > case 0x001a: > case 0x001b: > + case 0x001d: > + case 0x001e: > if (len != sizeof(u16)) { > bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", > len, sizeof(u16), type); > @@ -251,6 +255,12 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, > hdev->def_le_autoconnect_timeout = > msecs_to_jiffies(TLV_GET_LE16(buffer)); > break; > + case 0x0001d: > + hdev->advmon_allowlist_duration = TLV_GET_LE16(buffer); > + break; > + case 0x0001e: > + hdev->advmon_no_filter_duration = TLV_GET_LE16(buffer); > + break; > default: > bt_dev_warn(hdev, "unsupported parameter %u", type); > break; > -- > 2.28.0.681.g6f77f65b4e-goog > -- Luiz Augusto von Dentz Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aGgzLoeDal9rKAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 01:06:47 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id 2JMSLIeDal+TjgEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 01:06:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 8BE3C40964; Wed, 23 Sep 2020 01:06:42 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726758AbgIVXGl (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Tue, 22 Sep 2020 19:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgIVXGl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Tue, 22 Sep 2020 19:06:41 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01F7FC061755 for <linux-bluetooth@vger.kernel.org>; Tue, 22 Sep 2020 16:06:41 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id x22so9024241pfo.12 for <linux-bluetooth@vger.kernel.org>; Tue, 22 Sep 2020 16:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Laiihs0AaECfje2oIsybon2jtD4LrGoqde0EkeWBcm8=; b=vZT5JI/XNcducT0pHahqZmRltPIWSubHo1F+RzHGtpelrZfKwZbsyaPvNbwB5FAqfC OI1l2/g99Klre1ejYlkxV3THKDBSCmBO/ZGYT7h74Hv8sKsL8Vngh6G6K0gf8+984ZC+ 0Cn/zvU4LOc21Sn6Z7IqqQGXdCpzAANpFzohwG27bjF6hPDgeloOhmd2n+Q/g1ZbizN4 /qEeSZSOxyxrSE5P+zVy7dlyxRSWlFN+btxOHo4wgAgKM6q5xlohQzUkD7WlPBmrSaJq EUtt/7Px3EedEszkZoA8ZkrGdxvljDF/fE9BLxaUtO0ZvAziBsQC6sizSySuxZSptjyO xaOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Laiihs0AaECfje2oIsybon2jtD4LrGoqde0EkeWBcm8=; b=UIVc9Xllz0rq8IFw2wKpOS1cV3Atn7TiiDICUXttgLkXW8f809HfoxZkRpL+wwROD9 F/kE4MBot9EFx4qUv2642rd1czcN9miYoTI3HyqckplDvcCoqxaSq+JK4Hu4xVXVedzS iDWcWFSFYbeEsVCFjqFI0Eh57qoXShucEgJ2GDmrDKXNy3pACKC2tPbyYFOZtueAhQVj A5fE2sLdp2kr/SiStzwTSxM2B/ZCPoRJjS8BaeqwYYQwv7EMAGD9RgTpKHzVwU3LvXCu YVRgEyaFvzGZEmjFxAuTIKDGDG8NHT5JRN7OocMrKr+isj2gtrV3PFQqKCqyLFXen45U snCQ== X-Gm-Message-State: AOAM5325mQPZjbqDA7Rg1ejKrV7dSi6T/S+N2BPhVVp6DFPgcfTJKS2D jNfwz4dS4hIHjIBl5p0bTPumOcMUtPM= X-Google-Smtp-Source: ABdhPJwP8BYHpc39GuUOt2oiBU65TGr1smWsde7aUNFRpA/DWOSwqjwAYJF0qAvKOBHtfYF36pRWxA== X-Received: by 2002:a63:4416:: with SMTP id r22mr5444989pga.248.1600816000113; Tue, 22 Sep 2020 16:06:40 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id y29sm17464823pfq.207.2020.09.22.16.06.39 for <linux-bluetooth@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 16:06:39 -0700 (PDT) From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> To: linux-bluetooth@vger.kernel.org Subject: [RFC BlueZ] avdtp: Handle case where remote send L2CAP connect ahead of Open Date: Tue, 22 Sep 2020 16:06:37 -0700 Message-Id: <20200922230637.3524806-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.38 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8BE3C40964 X-Rspamd-UID: bf4eb7 From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This stores the channel if it had been connected ahead of Open procedure so it can later be processed. --- profiles/audio/avdtp.c | 75 +++++++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 11 deletions(-) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index b44a23c48..ae93fb26f 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -388,6 +388,7 @@ struct avdtp { GSList *prio_queue; /* Same as req_queue but is processed before it */ struct avdtp_stream *pending_open; + GIOChannel *pending_open_io; uint32_t phy; uint16_t imtu; @@ -609,11 +610,33 @@ static gboolean stream_open_timeout(gpointer user_data) stream->session->pending_open = NULL; + if (stream->session->pending_open_io) { + g_io_channel_unref(stream->session->pending_open_io); + stream->session->pending_open_io = NULL; + } + avdtp_abort(stream->session, stream); return FALSE; } +static void stream_set_timer(struct avdtp_stream *stream, guint timeout, + GSourceFunc func) +{ + if (stream->timer) + g_source_remove(stream->timer); + + stream->timer = g_timeout_add_seconds(timeout, func, stream); +} + +static void stream_set_pending_open(struct avdtp_stream *stream, GIOChannel *io) +{ + stream->open_acp = TRUE; + stream->session->pending_open = stream; + stream->session->pending_open_io = io; + stream_set_timer(stream, REQ_TIMEOUT, stream_open_timeout); +} + void avdtp_error_init(struct avdtp_error *err, uint8_t category, int id) { err->category = category; @@ -836,6 +859,12 @@ proceed: stream->io_id = g_io_add_watch(io, G_IO_ERR | G_IO_HUP | G_IO_NVAL, (GIOFunc) transport_cb, stream); + + /* Release pending IO */ + if (session->pending_open_io) { + g_io_channel_unref(session->pending_open_io); + session->pending_open_io = NULL; + } } static int pending_req_cmp(gconstpointer a, gconstpointer b) @@ -1674,6 +1703,14 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction, stream = sep->stream; + /* Check if the stream is pending and there is an IO set already */ + if (stream == session->pending_open && session->pending_open_io) { + handle_transport_connect(session, session->pending_open_io, + stream->imtu, stream->omtu); + return avdtp_send(session, transaction, AVDTP_MSG_TYPE_ACCEPT, + AVDTP_OPEN, NULL, 0); + } + if (sep->ind && sep->ind->open && !session->pending_open) { if (!sep->ind->open(session, sep, stream, &err, sep->user_data)) @@ -1686,13 +1723,8 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction, AVDTP_OPEN, NULL, 0)) return FALSE; - if (!session->pending_open) { - stream->open_acp = TRUE; - session->pending_open = stream; - stream->timer = g_timeout_add_seconds(REQ_TIMEOUT, - stream_open_timeout, - stream); - } + if (!session->pending_open) + stream_set_pending_open(stream, NULL); return TRUE; @@ -3139,18 +3171,39 @@ struct avdtp_remote_sep *avdtp_stream_get_remote_sep( gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd, size_t imtu, size_t omtu) { - GIOChannel *io; + GIOChannel *io = g_io_channel_unix_new(fd); - if (stream != stream->session->pending_open) - return FALSE; + if (stream != stream->session->pending_open) { + uint8_t err; + + if (stream->session->pending_open) + goto failed; + + /* Attempt to Open there is no pending stream set yet */ + if (stream->lsep->ind && stream->lsep->ind->open) { + if (!stream->lsep->ind->open(stream->session, + stream->lsep, + stream, &err, + stream->lsep->user_data)) + goto failed; + } - io = g_io_channel_unix_new(fd); + stream_set_pending_open(stream, io); + stream->imtu = imtu; + stream->omtu = omtu; + + return TRUE; + } handle_transport_connect(stream->session, io, imtu, omtu); g_io_channel_unref(io); return TRUE; + +failed: + g_io_channel_unref(io); + return FALSE; } gboolean avdtp_stream_get_transport(struct avdtp_stream *stream, int *sock, -- 2.26.2 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YMfpKqP+al8arwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 09:52:03 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id aBY7KKP+al9wLwEAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 09:52:03 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 2C946A0BD4; Wed, 23 Sep 2020 09:51:57 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726221AbgIWHv4 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 03:51:56 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:52155 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726151AbgIWHv4 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 03:51:56 -0400 Received: from [192.168.0.8] ([78.35.53.233]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MF39S-1kEKfL080O-00FTJi for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 09:51:55 +0200 From: Bisseling <spam@bisseling.de> Subject: [BUG] in tools/hcitool.c:cmd_scan To: linux-bluetooth@vger.kernel.org Message-ID: <ec38f619-0785-7814-8f68-11526b59d9a5@bisseling.de> Date: Wed, 23 Sep 2020 09:51:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Provags-ID: V03:K1:FyxajrrV/xT9UNTbJYEEK8cuG6lPGDD0c8gGQDnbH9CqSW0n+Ok gOjMODWkfaAWlR2kMhjNA7cVjEA9kYCztKpUDso8/uyiNHQ4F+vkWS1IWHB1S0EQ96ZShnH JSs3GFKoL8rl8xpnrWPdIn+rBeYT6fKDeme3bzVh3eefENDOriiUlZU5gD7DEZNvoiJdPlf Debp3Kf85cjVcNi0gKLfQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:64IWVAXJEZs=:uAsn9/biWf9yEBEuwS1VGS /upwfn3Bt8GfOlYc/hrUfTN3M/l7zSxx+M3sH8Ek7YQ744MtL/ugaZkWUTGJciDMhE6NY+hmL Tk5yDka3e1V39qKyZ0hL7f2ByXQTYQ6s5fiEne9K2rvDpHcQbbzzpI9riSsi0RXR74W3dJo1h 7/lm9JUlPkYDBL/ByXMzHI8nWPSEOeXjw2V/pmy9/vXjnHt8AI3huMxILKT1MXIFeZd3aBTek ooBLksaYe1VmKXP2FvQFSdRTjSEbQt103L2+/ifRHjeq9yRpY2Hvu3kt6BSq5+zDueD/BvyXY ae4R3cYPlPg7SK9JcvxR8UvG34RHsYCKfMddsipqlvFkbl9ngKQQo0bcuy2s8dsRm1/JKS6gP 5j22dH/Ss/FIgCApboEGi8Ss6eFR1QbtI9DHtpj26jnA1zu3W/6OvOngCiZoyenDw1DtEyJQz puXnhl9B/ORPLAGukea+Oj1kiqHH+nqi3RU+oMJdIHkd4G3tS97X+7qz75QLEcpMNPo3ba8bN 9RS35/A4Tipaa9E4srUXuULW0x5pEhU2fNmaZXBWzLwsHwqIbrkvM8b1aaMT/6HHxV23LdY9o cAYcRxlWFlg1UKIDi2cx5qhj0cvVcTEXvc43g/nkFBjGwwa5vlhiLxre4Fia9Ux2M7t+07yG0 ir0oqYA1sg3Hvq4k7v5QBuZ1wzQNgrFoTDxBydG4JkXR7EmVqugER4wz3LhrK20TT8zHnQs3q iJV7sie+fLMwzbUvZTXBKhs3DVCVCUyQ58faYYSbi7tdrMve1isFrjZjoWeUNxXwVjFaj5ub6 DxLPvDoCvqKwqBNtPa4voKOzeYCnQ4NXae0urWx/9Bs/YR5zK2oeY5kTE5EubU12j7fTSES Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.69 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2C946A0BD4 X-Rspamd-UID: a9ea78 [BUG] in tools/hcitool.c:cmd_scan Hi guys and gals, I found a little bug in the above function and would like to have it fixed. I could not find any other way to submit a bug than this mailing list. The function contains the following code: | for (n = 0; n < 248 && name[n]; n++) { if ((unsigned char) name[i] < 32 || name[i] == 127) name[i] = '.'; } | || || |It is pretty obvious that the loop should use the index variable n instead of i in all three places. The variable i is the index variable of the outer loop running over all responses. This mistake leads to garbled names and sometimes even to SIGSEGV on x86_AMD64. How would I fork your project and commit a pull request like on github? Thanks in advance Georg | || Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qLeAC+sTa1/u2AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 11:22:51 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id eIXvCOsTa1+IbgAA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 11:22:51 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id B40974097D; Wed, 23 Sep 2020 11:22:46 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726638AbgIWJWi (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 05:22:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726632AbgIWJWi (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 05:22:38 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 695ACC0613D2 for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 02:22:38 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id m23so16073161qkh.10 for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 02:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=p7FjT0Z9TxDxmogWu7RwZqin4A2u/8/n4a0QLXm41QA=; b=Uhd7zm4jAdOqVK+DWeJ+IDn2X0JgRtQslGb9WVWiZ+pxswl3yJa9hEdb07XF+oyyBv XBmN1WH1TanTM+p+7gXInyzYwtdSVuKas6QBcngfwM5ktxE1ahUdUAGM3mZlJYKjNQs0 TXTXykUU5v82HEHhO5ruXWh8BvaDLgRTDrMfrB327CyKxzAv8AF40McieQU880zBCbJK sTsUsZNYsq8y0XMTAu45HFiqCYFjJ5zSSFvJYRzJpQmUOQ0FuzMSdnOcnI6Sd7RCWWVf R+7P5jDx8/Nplup0Ur5CFcPSKYz8BCVKEc+L5FbsZynSXaiMnuhj3XdiqxpBi39E52ae OBDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=p7FjT0Z9TxDxmogWu7RwZqin4A2u/8/n4a0QLXm41QA=; b=W0SYvo7i9CYWEYNnGagVSH2WqOyKOqnJ/ddeksD44gSKsLyIlYEw7YBfKYOT7CQmtz dtXUZQQUSVXAPuOTyyypUE1tY9QYLb5kgK4rMK5YZ0rqzF3NYkk/Fau6Kxt6DM4rTjSi FfW5JJt7ST6fZ6cnZZUCOQXvE+lQcBUGdtR3wFip8uk5pWEW8ZqgInaUYcgV7P/J5fnl 53/ijqM3LDv07CZ7artX+SYHgzgVsAbhHRKw7qdv9HbBvOvOFCbnD2hXtaTA+tJl459z zMdkdtTUivhj3Of+Od4FLpp2DkTlm2kBeJrQUBdf8IeHdxw7uLhdStSjX5C98xuN0C4F n5hQ== X-Gm-Message-State: AOAM531ImsBQswXC8w5cQVYwAb/tBN7eALg4S0v15Li/4OPUIcmGizyY ZPGi9ia8ONTxWcDS62ouOS0S17nETo++M18c//ooDkjpM7IC0kHd3n/hVlGzFBujyEkiv9sN1+g Zr4YUEy/US7JdH4YO8Z1JXnxX8/BWXT/LzUR/oGjqFkARLqUVrgFDx1n7JzNJHRPvpMkyiql8YX o5lrVx4yrlQvY= X-Google-Smtp-Source: ABdhPJzhH4foqTq1nf/zVlsqPGwf8FxHK07J9KHYUL616ICVa2IMbSLTZp54XM6QVxylb4INYaathIrZyZNfuwst+Q== Sender: "howardchung via sendgmr" <howardchung@howardchung-p920.tpe.corp.google.com> X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a0c:abc7:: with SMTP id k7mr9794492qvb.45.1600852957349; Wed, 23 Sep 2020 02:22:37 -0700 (PDT) Date: Wed, 23 Sep 2020 17:22:29 +0800 Message-Id: <20200923172129.v5.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v5 1/4] Bluetooth: Interleave with allowlist scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: mmandlik@chromium.orgi, mcchou@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.82 / 15.00 / 15.00 X-Rspamd-Queue-Id: B40974097D X-Rspamd-UID: 8308cc This patch implements the interleaving between allowlist scan and no-filter scan. It'll be used to save power when at least one monitor is registered and at least one pending connection or one device to be scanned for. The durations of the allowlist scan and the no-filter scan are controlled by MGMT command: Set Default System Configuration. The default values are set randomly for now. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- Changes in v5: - Rename 'adv_monitor' from many functions/variables - Move __hci_update_interleaved_scan into hci_req_add_le_passive_scan - Update the logic of update_adv_monitor_scan_state Changes in v4: - Rebase to bluetooth-next/master (previous 2 patches are applied) - Fix over 80 chars limit in mgmt_config.c - Set EnableAdvMonInterleaveScan default to Disable Changes in v3: - Remove 'Bluez' prefix Changes in v2: - remove 'case 0x001c' in mgmt_config.c include/net/bluetooth/hci_core.h | 10 +++ net/bluetooth/hci_core.c | 4 + net/bluetooth/hci_request.c | 133 +++++++++++++++++++++++++++++-- net/bluetooth/mgmt_config.c | 10 +++ 4 files changed, 150 insertions(+), 7 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9873e1c8cd163..cfede18709d8f 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -361,6 +361,8 @@ struct hci_dev { __u8 ssp_debug_mode; __u8 hw_error_code; __u32 clock; + __u16 advmon_allowlist_duration; + __u16 advmon_no_filter_duration; __u16 devid_source; __u16 devid_vendor; @@ -542,6 +544,14 @@ struct hci_dev { struct delayed_work rpa_expired; bdaddr_t rpa; + enum { + INTERLEAVE_SCAN_NONE, + INTERLEAVE_SCAN_NO_FILTER, + INTERLEAVE_SCAN_ALLOWLIST + } interleave_scan_state; + + struct delayed_work interleave_scan; + #if IS_ENABLED(CONFIG_BT_LEDS) struct led_trigger *power_led; #endif diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f30a1f5950e15..6c8850149265a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3592,6 +3592,10 @@ struct hci_dev *hci_alloc_dev(void) hdev->cur_adv_instance = 0x00; hdev->adv_instance_timeout = 0; + /* The default values will be chosen in the future */ + hdev->advmon_allowlist_duration = 300; + hdev->advmon_no_filter_duration = 500; + hdev->sniff_max_interval = 800; hdev->sniff_min_interval = 80; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index d2b06f5c93804..ba3016cc0b573 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -378,6 +378,56 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable) hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type); } +static void start_interleave_scan(struct hci_dev *hdev) +{ + hdev->interleave_scan_state = INTERLEAVE_SCAN_NO_FILTER; + queue_delayed_work(hdev->req_workqueue, + &hdev->interleave_scan, 0); +} + +static bool is_interleave_scanning(struct hci_dev *hdev) +{ + return hdev->interleave_scan_state != INTERLEAVE_SCAN_NONE; +} + +static void cancel_interleave_scan(struct hci_dev *hdev) +{ + bt_dev_dbg(hdev, "%s cancelling interleave scan", hdev->name); + + cancel_delayed_work_sync(&hdev->interleave_scan); + + hdev->interleave_scan_state = INTERLEAVE_SCAN_NONE; +} + +/* Return true if interleave_scan wasn't started until exiting this function, + * otherwise, return false + */ +static bool __hci_update_interleaved_scan(struct hci_dev *hdev) +{ + if (hci_is_adv_monitoring(hdev) && + !(list_empty(&hdev->pend_le_conns) && + list_empty(&hdev->pend_le_reports))) { + if (!is_interleave_scanning(hdev)) { + /* If there is at least one ADV monitors and one pending + * LE connection or one device to be scanned for, we + * should alternate between allowlist scan and one + * without any filters to save power. + */ + start_interleave_scan(hdev); + bt_dev_dbg(hdev, "%s starting interleave scan", + hdev->name); + return true; + } + } else if (is_interleave_scanning(hdev)) { + /* If the interleave condition no longer holds, cancel + * the existed interleave scan. + */ + cancel_interleave_scan(hdev); + } + + return false; +} + /* This function controls the background scanning based on hdev->pend_le_conns * list. If there are pending LE connection we start the background scanning, * otherwise we stop it. @@ -450,8 +500,8 @@ static void __hci_update_background_scan(struct hci_request *req) hci_req_add_le_scan_disable(req, false); hci_req_add_le_passive_scan(req); - - BT_DBG("%s starting background scanning", hdev->name); + bt_dev_dbg(hdev, "%s starting background scanning", + hdev->name); } } @@ -844,12 +894,17 @@ static u8 update_white_list(struct hci_request *req) return 0x00; } - /* Once the controller offloading of advertisement monitor is in place, - * the if condition should include the support of MSFT extension - * support. If suspend is ongoing, whitelist should be the default to - * prevent waking by random advertisements. + /* Use the allowlist unless the following conditions are all true: + * - We are not currently suspending + * - There are 1 or more ADV monitors registered + * - Interleaved scanning is not currently using the allowlist + * + * Once the controller offloading of advertisement monitor is in place, + * the above condition should include the support of MSFT extension + * support. */ - if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended) + if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended && + hdev->interleave_scan_state != INTERLEAVE_SCAN_ALLOWLIST) return 0x00; /* Select filter policy to use white list */ @@ -1002,6 +1057,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) &own_addr_type)) return; + if (__hci_update_interleaved_scan(hdev)) + return; + /* Adding or removing entries from the white list must * happen before enabling scanning. The controller does * not allow white list modification while scanning. @@ -1871,6 +1929,64 @@ static void adv_timeout_expire(struct work_struct *work) hci_dev_unlock(hdev); } +static int hci_req_add_le_interleaved_scan(struct hci_request *req, + unsigned long opt) +{ + struct hci_dev *hdev = req->hdev; + int ret = 0; + + hci_dev_lock(hdev); + + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + hci_req_add_le_scan_disable(req, false); + hci_req_add_le_passive_scan(req); + + switch (hdev->interleave_scan_state) { + case INTERLEAVE_SCAN_ALLOWLIST: + bt_dev_dbg(hdev, "next state: allowlist"); + hdev->interleave_scan_state = INTERLEAVE_SCAN_NO_FILTER; + break; + case INTERLEAVE_SCAN_NO_FILTER: + bt_dev_dbg(hdev, "next state: no filter"); + hdev->interleave_scan_state = INTERLEAVE_SCAN_ALLOWLIST; + break; + case INTERLEAVE_SCAN_NONE: + default: + BT_ERR("unexpected error"); + ret = -1; + } + + hci_dev_unlock(hdev); + + return ret; +} + +static void interleave_scan_work(struct work_struct *work) +{ + struct hci_dev *hdev = container_of(work, struct hci_dev, + interleave_scan.work); + u8 status; + unsigned long timeout; + + if (hdev->interleave_scan_state == INTERLEAVE_SCAN_ALLOWLIST) { + timeout = msecs_to_jiffies(hdev->advmon_allowlist_duration); + } else if (hdev->interleave_scan_state == INTERLEAVE_SCAN_NO_FILTER) { + timeout = msecs_to_jiffies(hdev->advmon_no_filter_duration); + } else { + bt_dev_err(hdev, "unexpected error"); + return; + } + + hci_req_sync(hdev, hci_req_add_le_interleaved_scan, 0, + HCI_CMD_TIMEOUT, &status); + + /* Don't continue interleaving if it was canceled */ + if (is_interleave_scanning(hdev)) { + queue_delayed_work(hdev->req_workqueue, + &hdev->interleave_scan, timeout); + } +} + int hci_get_random_address(struct hci_dev *hdev, bool require_privacy, bool use_rpa, struct adv_info *adv_instance, u8 *own_addr_type, bdaddr_t *rand_addr) @@ -3292,6 +3408,7 @@ void hci_request_setup(struct hci_dev *hdev) INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); INIT_DELAYED_WORK(&hdev->le_scan_restart, le_scan_restart_work); INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire); + INIT_DELAYED_WORK(&hdev->interleave_scan, interleave_scan_work); } void hci_request_cancel_all(struct hci_dev *hdev) @@ -3311,4 +3428,6 @@ void hci_request_cancel_all(struct hci_dev *hdev) cancel_delayed_work_sync(&hdev->adv_instance_expire); hdev->adv_instance_timeout = 0; } + + cancel_interleave_scan(hdev); } diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index b30b571f8caf8..2d3ad288c78ac 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -67,6 +67,8 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, HDEV_PARAM_U16(0x001a, le_supv_timeout), HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b, def_le_autoconnect_timeout), + HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), + HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -138,6 +140,8 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x0019: case 0x001a: case 0x001b: + case 0x001d: + case 0x001e: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -251,6 +255,12 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, hdev->def_le_autoconnect_timeout = msecs_to_jiffies(TLV_GET_LE16(buffer)); break; + case 0x0001d: + hdev->advmon_allowlist_duration = TLV_GET_LE16(buffer); + break; + case 0x0001e: + hdev->advmon_no_filter_duration = TLV_GET_LE16(buffer); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-02.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id aCI6E/4Ta18fAwAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 11:23:10 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-02.heinlein-hosting.de with LMTPS id kJdoEP4Ta19uCAAAlp8NpQ (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 11:23:10 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id E29654099D; Wed, 23 Sep 2020 11:23:05 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726731AbgIWJWr (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 05:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726672AbgIWJWl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 05:22:41 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8802C0613D2 for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 02:22:41 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id l1so13498102qvr.0 for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 02:22:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=ZXC6RIjQzvP4+2I2ajwE91pKSZgn0JwFP6uprOUMdtE=; b=KwBf6MdWhP0CknbKFW6SdYmhjmeKufVFeUTMS58YpG65Fa57LKDmq4GU4j1dXsqiIK KC7BzISj8ncc0A4zxKTitK5MCmXO218SNreBVdugutCob9UXG4C58Z2tRQeVF9EKNb2J HiBgyUGwChc7JqQKrA3Qq9ErOSHpPE/+rggv4QgrniULhscUIqiA0hrqw0rasVk5MzfA jLq6LVKHSx7vS1L664xoRfUvtfZidSSGCdb5Ds39MS9676fDRPgWxgdPcl7p0OjvaxVj dSTcruurTkrqS/H7wO7O2n8UQiS/8MAH0rIQdWjb3NUjXfb5cK5SAlj7AXAIPz1g0aAO CF7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ZXC6RIjQzvP4+2I2ajwE91pKSZgn0JwFP6uprOUMdtE=; b=O41IE6liyDqSlw+HDi3xj4+U1zjwNFS3GLPRItHJUcTMSYMjHNAnj0EnGTbOEsvQm5 hbUTkML85s194L6PVYjZhISi9wy4Enb3QKawsGEbQEe/4lVw6JKhglQ2o8Uk3dUb/6om DDmlWgERbIbd5PFAYizqhDiwTzKgV42VhYe69MpO2J8Dq9QtQ7KjJuOSry1UmshfCDQO Crq2gt5aAH7WHjRS+vBlOzYL5Dn3vj6SKzbKZQLquBpl3ybobdbQRfbh7yBrCNZeo/ot bK9h1JoNZ42ae/CzmclaGpF8xwM74Yg8K6TiUR74EKIuOw7wP0AlhKUp3dD5Cm+WLgZJ uPAw== X-Gm-Message-State: AOAM532UiCJ7eLCGeLQKSDs42PR3UYTQmEFiemLacGX+xwZhNrqXK1om LvBaXzqr3JZjYoaQepgy3jg290cJlQWo3Lv9ugFjAVxrqoI/jUWUaMfvZ51JGLVcrJ1ktHy0bAh USIhuNO1aqxJU9/aDCua26L30GwaSJnbExR8BHe01fK8cu7xF7LJBVj1S5RBfjoTjSPJgHpV8Yf QBOL8mkq3bOtE= X-Google-Smtp-Source: ABdhPJw1JOPfZUWsb7sDXsDlMt//WE8y5Wm/J1mYW+p6E2cWqB3Sq1npvUx4u1vVd4USLPXEAs8GttiO5VkHSkIeJA== Sender: "howardchung via sendgmr" <howardchung@howardchung-p920.tpe.corp.google.com> X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a0c:f687:: with SMTP id p7mr10292000qvn.15.1600852960833; Wed, 23 Sep 2020 02:22:40 -0700 (PDT) Date: Wed, 23 Sep 2020 17:22:30 +0800 In-Reply-To: <20200923172129.v5.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Message-Id: <20200923172129.v5.2.I3774a8f0d748c7c6ec3402c4adcead32810c9164@changeid> Mime-Version: 1.0 References: <20200923172129.v5.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v5 2/4] Bluetooth: Handle system suspend resume case From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: mmandlik@chromium.orgi, mcchou@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.48 / 15.00 / 15.00 X-Rspamd-Queue-Id: E29654099D X-Rspamd-UID: 590411 This patch adds code to handle the system suspension during interleave scan. The interleave scan will be canceled when the system is going to sleep, and will be restarted after waking up. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Changes in v5: - Remove the change in hci_req_config_le_suspend_scan net/bluetooth/hci_request.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index ba3016cc0b573..db44680fbe9c9 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1281,8 +1281,10 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan); /* Disable LE passive scan if enabled */ - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { + cancel_interleave_scan(hdev); hci_req_add_le_scan_disable(&req, false); + } /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id GEeQGggUa1/t2AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 11:23:20 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id uGE4FwgUa1+hXgEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 11:23:20 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 7BAD64098A; Wed, 23 Sep 2020 11:23:16 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbgIWJWz (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 05:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726476AbgIWJWt (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 05:22:49 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B583C0613D2 for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 02:22:49 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id ng5so3338428pjb.0 for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 02:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=u7Z83DLDrasY402Nxfc9qjNLJvZzmNwdhFfCA3B0FJM=; b=QSLk/unrtSuMTNkb4x94DkM1UH5ttzeHlXRiV3zLnLMp0xuP9FNwce/+58fN+WhPHZ vy0OdIcIbOa3b1s4ji9mfMm1oXHfZOFtu8WJjbhPYwScPv6zVGiv0gDTrwU01iNkDzKd 3uzEN2hB9x+OYMJOolUs20QkRqOpqZTXBYiaMEVNxMu95FG8qkxQBO9a/gkCtp5YL7/S aUsRMwxqW/lyQU+rF/LC2vTzXDbuiDUy3uDKvdBof2KZqY2SiFsGUalNYeEDegURlbMM +xTXWwdi7cOX0dqk9ILPaM4s/XlojQeJuUvuU4zciteOa31sXKlTJAqls2f2Vw4qRjUh cbaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=u7Z83DLDrasY402Nxfc9qjNLJvZzmNwdhFfCA3B0FJM=; b=mrugqq380hTEySND284EYOrmtG+uQfC/dulBRI6GbBd5RlKX0we0bzSdVSXVDH4mYZ OBinbdhqCXSNEEtR/kCx4z/1OcVy7cJKGmTxd9wLYt8cVQQftK9/AK193NQDJsTaT9NI mYX+wTQD/R0YOt21UuEB5yICii1/CWQYIlPRpqo2zTGJ+crqnFyCfC72YmV0fxYjg1G6 1CUbr1BhrXR5xXbDwe7slV77bA8rIS83eFaJ6YhdbhaeyP7puk/2rct+o4tqHTIXKwMU yBU1E9H2Oym3CFggLJRJ9NT46qcYPNYQ6/fojzvcMwzl8iq8n6FLc6fmg5mYD682ylfc PzbQ== X-Gm-Message-State: AOAM530q5LJWNW4e8VbNuIavcQXBt24nL8fjC7KRum10a68wD9hjdzoR bnvDU1iqRKZ9KZ4knBxbMn4nFZVprmQQeQqXJij5gxJm4Oayavv+5SXHzlKHpaw7g7fUZLYSxAJ rvC06he4e7R1/KDmMkPwdQrHo7ec3vbe3G7VkafPdDrfUBgU+zoX8f4a9xjCvmyER98bge5Kk4U i2cJlHx6P9iW8= X-Google-Smtp-Source: ABdhPJy/dWhO3vnXwvNo0D+dQKNFhW0lwByxTvX6ctgRDLo0I+9tg61Cop7KCcLEcHJGCu+H4H3bkWftl7yG9DLGwg== Sender: "howardchung via sendgmr" <howardchung@howardchung-p920.tpe.corp.google.com> X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a17:902:bd90:b029:d2:439c:385a with SMTP id q16-20020a170902bd90b02900d2439c385amr5997037pls.35.1600852968539; Wed, 23 Sep 2020 02:22:48 -0700 (PDT) Date: Wed, 23 Sep 2020 17:22:32 +0800 In-Reply-To: <20200923172129.v5.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Message-Id: <20200923172129.v5.4.I756c1fecc03bcc0cd94400b4992cd7e743f4b3e2@changeid> Mime-Version: 1.0 References: <20200923172129.v5.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v5 4/4] Bluetooth: Add toggle to switch off interleave scan From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: mmandlik@chromium.orgi, mcchou@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.63 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7BAD64098A X-Rspamd-UID: 0bc6d1 This patch add a configurable parameter to switch off the interleave scan feature. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> --- (no changes since v4) Changes in v4: - Set EnableAdvMonInterleaveScan default to Disable - Fix 80 chars limit in mgmt_config.c include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 1 + net/bluetooth/hci_request.c | 3 ++- net/bluetooth/mgmt_config.c | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index cfede18709d8f..b0225b80152cc 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -363,6 +363,7 @@ struct hci_dev { __u32 clock; __u16 advmon_allowlist_duration; __u16 advmon_no_filter_duration; + __u16 enable_advmon_interleave_scan; __u16 devid_source; __u16 devid_vendor; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6c8850149265a..d5769ae682893 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3595,6 +3595,7 @@ struct hci_dev *hci_alloc_dev(void) /* The default values will be chosen in the future */ hdev->advmon_allowlist_duration = 300; hdev->advmon_no_filter_duration = 500; + hdev->enable_advmon_interleave_scan = 0x0000; /* Default to disable */ hdev->sniff_max_interval = 800; hdev->sniff_min_interval = 80; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 4048c82d4257f..23381f263678b 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1057,7 +1057,8 @@ void hci_req_add_le_passive_scan(struct hci_request *req) &own_addr_type)) return; - if (__hci_update_interleaved_scan(hdev)) + if (hdev->enable_advmon_interleave_scan && + __hci_update_interleaved_scan(hdev)) return; /* Adding or removing entries from the white list must diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index 2d3ad288c78ac..34585ab4680b5 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -69,6 +69,7 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, def_le_autoconnect_timeout), HDEV_PARAM_U16(0x001d, advmon_allowlist_duration), HDEV_PARAM_U16(0x001e, advmon_no_filter_duration), + HDEV_PARAM_U16(0x001f, enable_advmon_interleave_scan), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -142,6 +143,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x001b: case 0x001d: case 0x001e: + case 0x001f: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -261,6 +263,9 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x0001e: hdev->advmon_no_filter_duration = TLV_GET_LE16(buffer); break; + case 0x0001f: + hdev->enable_advmon_interleave_scan = TLV_GET_LE16(buffer); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id qF/yMkYYa1/t2AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 11:41:26 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id KDvWL0YYa18G5wAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 11:41:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id CD9D240976; Wed, 23 Sep 2020 11:41:17 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726513AbgIWJlR convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 05:41:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:53092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726253AbgIWJlR (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 05:41:17 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 198919] Xbox (One) Wireless Controller won't connect Date: Wed, 23 Sep 2020 09:41:16 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: high X-Bugzilla-Who: hurikhan77+bko@gmail.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-198919-62941-ZMY1AV5AH4@https.bugzilla.kernel.org/> In-Reply-To: <bug-198919-62941@https.bugzilla.kernel.org/> References: <bug-198919-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.83 / 15.00 / 15.00 X-Rspamd-Queue-Id: CD9D240976 X-Rspamd-UID: d57e79 https://bugzilla.kernel.org/show_bug.cgi?id=198919 Kai Krakow (hurikhan77+bko@gmail.com) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hurikhan77+bko@gmail.com --- Comment #6 from Kai Krakow (hurikhan77+bko@gmail.com) --- Yeah, it seems to get worse with every 5.4 LTS update. Worked almost flawless about some months ago (despite taking something from 30-60s to successfully connect). But I don't see a correlation to any commits. But now, it's almost impossible to connect successfully, it usually disconnects after a 1-2 minutes (coincidentally just when entering a game). I usually also see messages like this: During use of the controller (probably around disconnect time): [ 5304.480502] Bluetooth: Unexpected continuation frame (len 52) When plugging the BT dongle: [ 5241.926752] Bluetooth: hci0: unexpected event for opcode 0x0000 While it's in a loop of constantly connecting and disconnecting: [ 1120.736530] Bluetooth: hci0: hardware error 0x58 [ 1120.923550] debugfs: File 'le_min_key_size' in directory 'hci0' already present! [ 1120.923555] debugfs: File 'le_max_key_size' in directory 'hci0' already present! [ 1120.923557] debugfs: File 'force_bredr_smp' in directory 'hci0' already present! Other BT devices seem to just work fine tho I don't use a lot of them and only occasionally. It seems that the Xbox One S firmware does something strange in the BT protocol. It also needs either ERTM disabled to connect. Alternatively, one can apply this patch to be able to use ERTM: https://github.com/kakra/linux/commit/c8b24d83f227a7fecfa9420d6756074e8f9b542c I'm also feeling there's some internal state getting messed up within the controller on each BT pairing: Results are not really reproducible. I managed to get it to work flawlessly one time (stable connection despite 20-30s connect handshake time), then purged my Bluetooth config from /var/lib, re-paired the controller and now it's a mess - still with the same kernel version. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-06.heinlein-hosting.de ([10.192.2.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id MNk7JAwUa1/t2AEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 11:23:24 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-06.heinlein-hosting.de with LMTPS id QLlEIQwUa1/62QEADc0bRg (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 11:23:24 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 90CE940994; Wed, 23 Sep 2020 11:23:20 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726716AbgIWJWq (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 05:22:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726676AbgIWJWq (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 05:22:46 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66395C0613D5 for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 02:22:45 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id e2so581387ybc.17 for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 02:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=OYN0waWCzIpz4ouqNQwOPc0HvVqV4aulKVgXstFC8pM=; b=UTEylZUZ5updRxJyyE1aYQG2MB/kp+pzMWY5DhOtjk4PMP63yPQX5Vh2r0Nx4gPB/1 V9zrBiDN+pQkVLjlflvjNSdooxWO4yGD3nHAzZ7CQNQ/gkOk2/DccLeqY0U7p37oAanE HYrMNwgimP/NEksULzdrBxeNR8m+30WlcQf8eUzLQ3oteCOE7BPiRlV0qCmZ77rX7QZJ 1w2brV8qQ6HMyZXR6jkJdQsLRBEcefQT3hIXJlOu5K21VItm12/SvWm552hMC42DmvFz hYfl3JtNg2oaINdq4AZSFZzhyIHN4rU3btDdpttPcGEmxPsuGmWKTBXc8BqQ3zcFnme6 4sbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=OYN0waWCzIpz4ouqNQwOPc0HvVqV4aulKVgXstFC8pM=; b=JaS7oq/K8vrfZ9DeFS0BYRncEHTwSuFKYZ+atrFZz/c/yVsm+s/SvqptAuSpE6+gs3 e79nO5YnLZ3U/rzoOi23II4Kga3xCtduc4dMFGVDsfV7yzkhr3Anj9cRxzlD/poKpq4P MsSzUOfC4KQdtBN6tT2y5j6ExVN0fc+gOznkP+q8GZ+kBZYQn+Gb+rfg9gSkghcWjm1T nCjgQqDCkP7fezXGFmFvJ0MsamWmLOyTP1AcXxJ+rZ92Oi5vOVrXZIKGEjOnVDLqWRm8 Wng/YIpY5a4pjMexVlCt4I9Eopx05PcPB0BgtT08+L4tQsk9uv3vW56HUnUptT+FQLlS CKmA== X-Gm-Message-State: AOAM532BTt8716l1KLtRcVbhBzQE7z34rdCwlVKeHE8hqWGhLRamFaHe 0x3mvmvmWdoIMF5vrTyeHx93K7kgljOwglYooS+WaxwQ3Er5dl4ixmz8PwGSKjQzscoMzZnDdES kssMuS1z8gNa4+s0h6aPeNh1MR72oKoMp0YHuK/Os3oamugcgn+Go04omfg3mnJELriOXLY/8va VrH3yFXDju8LA= X-Google-Smtp-Source: ABdhPJzI1T8McZlIoA0sf6bztLH3WBdup6fzS5cp23Ntzzcb/8oA+VMcbFtGnTpIynAxzj4FvQFFnE7BM8+AvHZ9jQ== Sender: "howardchung via sendgmr" <howardchung@howardchung-p920.tpe.corp.google.com> X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a25:8746:: with SMTP id e6mr11266110ybn.89.1600852964527; Wed, 23 Sep 2020 02:22:44 -0700 (PDT) Date: Wed, 23 Sep 2020 17:22:31 +0800 In-Reply-To: <20200923172129.v5.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> Message-Id: <20200923172129.v5.3.I21e5741249e78c560ca377499ba06b56c7214985@changeid> Mime-Version: 1.0 References: <20200923172129.v5.1.Ib75f58e90c477f9b82c5598f00c59f0e95a1a352@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v5 3/4] Bluetooth: Handle active scan case From: Howard Chung <howardchung@google.com> To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: mmandlik@chromium.orgi, mcchou@chromium.org, alainm@chromium.org, Howard Chung <howardchung@google.com>, Manish Mandlik <mmandlik@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.87 / 15.00 / 15.00 X-Rspamd-Queue-Id: 90CE940994 X-Rspamd-UID: 46e691 This patch adds code to handle the active scan during interleave scan. The interleave scan will be canceled when users start active scan, and it will be restarted after active scan stopped. Signed-off-by: Howard Chung <howardchung@google.com> Reviewed-by: Alain Michaud <alainm@chromium.org> Reviewed-by: Manish Mandlik <mmandlik@chromium.org> --- (no changes since v1) net/bluetooth/hci_request.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index db44680fbe9c9..4048c82d4257f 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -3083,8 +3083,10 @@ static int active_scan(struct hci_request *req, unsigned long opt) * running. Thus, we should temporarily stop it in order to set the * discovery scanning parameters. */ - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { hci_req_add_le_scan_disable(req, false); + cancel_interleave_scan(hdev); + } /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kHiAOpwZa19hEAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 11:47:08 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id +PqxN5wZa1+KhwEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 11:47:08 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id F0955409A0; Wed, 23 Sep 2020 11:46:59 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726178AbgIWJq7 convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 05:46:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:54112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgIWJq7 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 05:46:59 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 198919] Xbox (One) Wireless Controller won't connect Date: Wed, 23 Sep 2020 09:46:58 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: high X-Bugzilla-Who: Matthias.Pritschet@escrypt.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-198919-62941-a575PcdUgy@https.bugzilla.kernel.org/> In-Reply-To: <bug-198919-62941@https.bugzilla.kernel.org/> References: <bug-198919-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -5.00 / 15.00 / 15.00 X-Rspamd-Queue-Id: F0955409A0 X-Rspamd-UID: 17ed75 https://bugzilla.kernel.org/show_bug.cgi?id=198919 --- Comment #7 from Matthias.Pritschet@escrypt.com --- Dear sender! Thank you for your message! Unfortunately, I am out of office until 27.9.2020 and hence will not be able to reply immediately. Your email will not be forwarded, but I will answer your email as soon as possible on my return. In very urgent cases, however, please contact our service center via email <info@escrypt.com<mailto:service@escrypt.com>> or phone +49 234 43870-200. Yours sincerely, Matthias Pritschet Sehr geehrte Damen und Herren, Vielen Dank für Ihre E-Mail! Ich bin leider bis zum 27.9.2020 nicht erreichbar und kann daher nicht unmittelbar antworten. Ihre Nachricht wird nicht weitergeleitet. In dringenden Fällen können Sie sich jedoch gern an unser Service-Center (<info@escrypt.com<mailto:service@escrypt.com>> oder +49 234 43870-200) wenden. Mit freundlichen Grüßen Matthias Pritschet -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SP87Duoha19c+gAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 12:22:34 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id gGg0C+oha18vFwEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 12:22:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=kernel.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id E4849A0B78; Wed, 23 Sep 2020 12:22:29 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbgIWKWU (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 06:22:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:43194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726709AbgIWKWT (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 06:22:19 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 675632388B; Wed, 23 Sep 2020 10:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600856538; bh=f0ytXXEucpGE93ViGHIALMJMUGZXXZ/3klZgXM9sYQ0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PzHhAWPVRv6Ifdafcex0l+oJub9ySqOhEZUvP0/V4il+89AE1vfzTohvWFqcH/Y/6 cT4eBmoM/OZfi6zW7i1v0O2VT7rwvdfzkpl9IbJ3xaYyh0iUonPZp2UxJusk3/VS8A NPFoG9QwIi7RK8ZYUomhKJpvZqqVmxNbRnvdAXYs= Received: by pali.im (Postfix) id 1D8F8D0F; Wed, 23 Sep 2020 12:22:16 +0200 (CEST) Date: Wed, 23 Sep 2020 12:22:15 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= <pali@kernel.org> To: Joseph Hwang <josephsih@google.com> Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, chromeos-bluetooth-upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Alain Michaud <alainm@chromium.org>, Abhishek Pandit-Subedi <abhishekpandit@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v3 1/2] Bluetooth: btusb: define HCI packet sizes of USB Alts Message-ID: <20200923102215.hrfzl7c7q2omeiws@pali> References: <20200910060403.144524-1-josephsih@chromium.org> <20200910140342.v3.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> <20200910081842.yunymr2l4fnle5nl@pali> <CAHFy418Ln9ONHGVhg513g0v+GxUZMDtLpe5NFONO3HuAZz=r7g@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <CAHFy418Ln9ONHGVhg513g0v+GxUZMDtLpe5NFONO3HuAZz=r7g@mail.gmail.com> User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -6.43 / 15.00 / 15.00 X-Rspamd-Queue-Id: E4849A0B78 X-Rspamd-UID: c0bdc5 Hello! On Monday 14 September 2020 20:18:27 Joseph Hwang wrote: > On Thu, Sep 10, 2020 at 4:18 PM Pali Rohár <pali@kernel.org> wrote: > > And this part of code which you write is Realtek specific. > > We currently only have Intel and Realtek platforms to test with. If > making it generic without proper testing platforms is fine, I will > make it generic. Or do you think it might be better to make it > customized with particular vendors for now; and make it generic later > when it works well with sufficient vendors? I understood that those packet size changes are generic to bluetooth specification and therefore it is not vendor specific code. Those packet sizes for me really seems to be USB specific. Therefore it should apply for all vendors, not only for Realtek and Intel. I would propose to fix it globally for all USB adapters and not only for Intel and Realtek USB adapters. > > > > I thought that this is something generic to bluetooth usb as you pointed > > to bluetooth documentation "core spec 5, vol 4, part B, table 2.1". > > > > > + } else > > > bt_dev_err(hdev, "Device does not support ALT setting 1"); > > > } > > > > Also this patch seems to be for me incomplete or not fully correct as > > USB altsetting is chosen in function btusb_work() and it depends on > > selected AIR mode (which is configured by another setsockopt). > > > > So despite what is written in commit message, this patch looks for me > > like some hack for Intel and Realtek bluetooth adapters and does not > > solve problems in vendor independent manner. > > You are right that sco_mtu should be changed according to the air > mode. Here are some issues to handle and what I plan to do. I would > like to solicit your comments before I submit the next series. > > [Issue 1] The air mode is determined in btusb_work() which is > triggered by hci_sync_conn_complete_evt(). So “conn->mtu = > hdev->sco_mtu” should not be done in sco_conn_add() in the early > connecting stage. Instead, it will be moved to near the end of > hci_sync_conn_complete_evt(). > > [Issue 2] The btusb_work() is performed by a worker. There would be a > timing issue here if we let btusb_work() to do “hdev->sco_mtu = > hci_packet_size_usb_alt[i]” because there is no guarantee how soon the > btusb_work() can be finished and get “hdev->sco_mtu” value set > correctly. In order to avoid the potential race condition, I suggest > to determine air_mode in btusb_notify() before > schedule_work(&data->work) is executed so that “hdev->sco_mtu = > hci_packet_size_usb_alt[i]” is guaranteed to be performed when > btusb_notify() finished. In this way, hci_sync_conn_complete_evt() can > set conn->mtu correctly as described in [Issue 1] above. If it really fixes this issue, I'm fine with it. You have Realtek and Intel HW for testing, so I think if doing some heavy tests did not trigger any issue / race condition then it should be fine. > [Issue 3] Concerning CVSD: The above flow is good when the transparent > mode is selected. When it is the CVSD mode, we should set > hdev->sco_mtu and conn->mtu back to the original mtu size returned by > hci_cc_read_buffer_size(). Beware that kernel does not support CVSD mode between (USB) bluetooth adapter and kernel yet. Therefore it does not make sense to discussion this option. MTU size affects packets between kernel (or userspace) and bluetooth adapter. Bluetooth adapter then do HW encoding/decoding if non-transparent mode is used. So I think you rather mean PCMs16 mode between bluetooth adapter and kernel because this mode is used for CVSD air codec (between two bluetooth adapters over the air). This is default mode, userspace application pass PCMs16 data to kernel which pass it over USB to bluetooth adapter. And bluetooth adapter then do HW encoding, encodes PCMs16 to CVSD codec and transmit it over the air. So over USB are sent PCM data, not CVSD. > This is because we do not have a reliable > way to determine what size is used with CVSD. AFAIK, controllers > connected through USB use 48 bytes; and controllers connected through > UART use 60 bytes. I think for USB adapters we have that size. From bluetooth specification I understood that it is that size which you calculated in that array based on alt interface. I understood that bluetooth specification that packet size on USB depends only on chosen alt interface. And choice of alt interface depends on voice codec (PCM or transparent) and on number of active transports. But correct me, if I'm wrong. Maybe I did not understand bluetooth specification correctly. And for UART I do not know, I have not looked at it it yet. > It seems to me that these numbers are not recorded > in the kernel(?). It seems beyond the scope of this patch to set the > proper value for CVSD. So we will let hdev->sco_mtu and conn->mtu go > back to their original values and are not affected by this patch. > > I am wondering if such directions of fixing this patch look good to you? > > Thanks and regards! > Joseph Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id WKsVN4NWa1+e/wAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 16:06:59 +0200 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id WEpSM4NWa1+FUQAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 16:06:59 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 1F363409A2; Wed, 23 Sep 2020 16:06:52 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726514AbgIWOGw convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 10:06:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:51028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgIWOGw (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 10:06:52 -0400 From: bugzilla-daemon@bugzilla.kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-bluetooth@vger.kernel.org Subject: [Bug 60824] [PATCH][regression] Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable Date: Wed, 23 Sep 2020 14:06:48 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Drivers X-Bugzilla-Component: Bluetooth X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: flole@flole.de X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: linux-bluetooth@vger.kernel.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: <bug-60824-62941-ao6Rt7RHvd@https.bugzilla.kernel.org/> In-Reply-To: <bug-60824-62941@https.bugzilla.kernel.org/> References: <bug-60824-62941@https.bugzilla.kernel.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.77 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1F363409A2 X-Rspamd-UID: 282985 https://bugzilla.kernel.org/show_bug.cgi?id=60824 Flole (flole@flole.de) changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |flole@flole.de --- Comment #154 from Flole (flole@flole.de) --- (In reply to Alex from comment #86) > Hi Swyter, > > I also tried your patch v2 and actually in my case see no difference with > the previous ones I tried (see my comments 55/56 > https://bugzilla.kernel.org/show_bug.cgi?id=60824#c55 ) > > Linux recognizes the controller, but it's unusable: > > Can't init device hci0: Invalid argument (22) > > > HCI Event: Command Complete (0x0e) plen 4 > > #22 [hci0] > > 11.191461 > Set Event Filter (0x03|0x0005) ncmd 1 > Status: Invalid HCI Command Parameters (0x12) > = Close Index: 00:1A:7D:DA:71:12 > [hci0] 11.191493 > > > I've seen several people here have this issue, and I believe that comment 59 > may be quite relevant here: > > > Set Event fails, looking at hci_core.c the set filter and previous calls > are > > made only if device supports BREDR, is there any way to tell device doesn't > > support, or patch this ? I have the same device, and my fix was simply changing the #define that checks if a device supports BREDR to "false" (aka disabling BREDR support completely) and that solved it. -- You are receiving this mail because: You are the assignee for the bug. Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id SPJ7HP5ua191SAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 17:51:26 +0200 Received: from mx1.mailbox.org ([80.241.60.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id EChPGf5ua1/wMQAAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 17:51:26 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter01.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=samsung.com X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx1.mailbox.org (Postfix) with ESMTP id 63E714097D; Wed, 23 Sep 2020 17:51:19 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726572AbgIWPvQ (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 11:51:16 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:14011 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgIWPvP (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 11:51:15 -0400 X-Greylist: delayed 480 seconds by postgrey-1.27 at vger.kernel.org; Wed, 23 Sep 2020 11:51:14 EDT Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200923154313epoutp032baef8564e332642821b2630e4387adf~3dA1Yi-Fh1017210172epoutp03Y for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 15:43:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200923154313epoutp032baef8564e332642821b2630e4387adf~3dA1Yi-Fh1017210172epoutp03Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1600875793; bh=o8TmnvCqFo7wT77dhVK6ICzeRgA1HKhWHsU1u3ETDE4=; h=Subject:Reply-To:From:To:CC:Date:References:From; b=dtw11gvRUuWxA+VSN7YWNp+s9vOJGAurjFY0k6SWootNREkeY648bJSSw4x2d1FF7 Izc0UEWx536PQvRNRxqCKtnydi/W4HVD4huHy6G27eVQAf6AGokCzv4ImVmyJFv/uU QFHc7FGzmBjzl8lWey/S7cO+cfj5VX/0xphoMCXA= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20200923154312epcas5p28897ec0808a760890b1d78c6076ea447~3dA0TX_2T1222812228epcas5p2C; Wed, 23 Sep 2020 15:43:12 +0000 (GMT) X-AuditID: b6c32a4b-2f3ff7000000255f-63-5f6b6d0fe8ee Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 5C.CA.09567.F0D6B6F5; Thu, 24 Sep 2020 00:43:11 +0900 (KST) Mime-Version: 1.0 Subject: Regarding 'unicast notification' by GATT server Reply-To: anupam.r@samsung.com Sender: Anupam Roy <anupam.r@samsung.com> From: Anupam Roy <anupam.r@samsung.com> To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org> CC: Nitin Jhanwar <nitin.j@samsung.com>, AMIT KUMAR JAISWAL <amit.jaiswal@samsung.com> X-Priority: 3 X-Content-Kind-Code: NORMAL X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20200923143412epcms5p2103ec8f62fc97334f46d92f36490e61f@epcms5p2> Date: Wed, 23 Sep 2020 20:04:12 +0530 X-CMS-MailID: 20200923143412epcms5p2103ec8f62fc97334f46d92f36490e61f Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHIsWRmVeSWpSXmKPExsWy7bCmui5/bna8QftpC4t3XdPZLOZc62O2 2LaundmB2aNvyypGj8+b5AKYorhsUlJzMstSi/TtErgyFsxZx1RwmL3iyNUHjA2My9m7GDk5 JARMJA5OeM8MYgsJ7GaUWHgwrIuRg4NXQFDi7w5hkLCwgIXE/DerWSFK5CQWT13LBlIiLKAp cXNjCkiYTUBd4tfDHSwgtoiAu8Se/bcZQUqYBSIk7m3OhVjEKzGj/SkLhC0tsX35VkYIW1Ti 5uq37DD2+2PzoeIiEq33zjJD2IISD37uZoTp3brgKVCcC8juZpR4vWM9E4QzhVHi48W3TBBV 5hL/u9+CdfAK+Er863kIZrMIqEqcP7MeqsZF4uPVs2B/MQtoSyxb+JoZ4mhNifW79CFKZCWm nlrHBFHCJ9H7+wkTzDM75sHYShJbr89nhbAlJPo274KKe0gsOA7RKyQQKPHt1RTmCYzysxCB OwvJ4lkIixcwMq9ilEwtKM5NTy02LTDOSy3XK07MLS7NS9dLzs/dxAhOAlreOxgfPfigd4iR iYPxEKMEB7OSCO8Ntex4Id6UxMqq1KL8+KLSnNTiQ4zSHCxK4rxKP87ECQmkJ5akZqemFqQW wWSZODilGpjMvFz8pyzS6fTPSdIXcn/Z3phv2VcYu/BP0LrSTw2X9F5wKUzqEZmauXGyWv5R Eft5FtFud2bUz3h5b931Q0b5CsWBaqsEqv2Zso4pBc2e/CxT+LjDh5UV4fYfbuzq26pjWHgz f/mXwNYOyV3fb6xVny7/9sWjLQoHT01y2OW/wPdZ97zln3nSU6peP/eJrs94dX29aPM1q+8N 6pPc9KMz/E9dM1dhcr50lu3p7WNnY3a1ynmJ/rb/tPvfwpus5w42rCyc8M3po2Nmndpp86aF cYdOJFd7sk1YUH22z0SD4eSjt6tzvzbM77E9oW32IpOZk/kD3yGtipmixlMWrnjaqXVxvcbU /I8c/Hxf9hQosRRnJBpqMRcVJwIA9b2xzXEDAAA= X-CMS-RootMailID: 20200923143122epcms5p8e33d120d02df9dedb5b905426664b899 References: <CGME20200923143122epcms5p8e33d120d02df9dedb5b905426664b899@epcms5p2> Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.55 / 15.00 / 15.00 X-Rspamd-Queue-Id: 63E714097D X-Rspamd-UID: 696d42 Hi, =C2=A0Presently=C2=A0I=C2=A0am=C2=A0checking=C2=A0notification=C2=A0for=C2= =A0multiple=C2=A0GATT=C2=A0clients,=C2=A0connected=C2=A0to=C2=A0my=C2=A0loc= al=C2=A0GATT=C2=A0server=C2=A0(using=C2=A0'AcquireNotify')=0D=0AIt=C2=A0see= ms,=C2=A0notifications=C2=A0are=C2=A0multicasted=C2=A0to=C2=A0all=C2=A0conn= ected=C2=A0remote=C2=A0GATT=C2=A0clients,=C2=A0which=C2=A0have=C2=A0CCCD=C2= =A0enabled=C2=A0at=C2=A0any=C2=A0given=C2=A0time=0D=0A=C2=A0=0D=0AIf=C2=A0B= luez's=C2=A0DBUS=C2=A0client=C2=A0wants=C2=A0to=C2=A0do=C2=A0selective/unic= ast=C2=A0notifcation,=C2=A0is=C2=A0there=C2=A0any=C2=A0way=C2=A0to=C2=A0ach= ieve=C2=A0this=C2=A0via=C2=A0'Acquirenotify'?=0D=0AAny=C2=A0insights=C2=A0o= n=C2=A0this=C2=A0will=C2=A0be=C2=A0really=C2=A0helpful=C2=A0for=C2=A0me,=C2= =A0or=C2=A0please=C2=A0let=C2=A0me=C2=A0know=C2=A0if=C2=A0i=C2=A0am=C2=A0mi= ssing=C2=A0something.=C2=A0Thank=C2=A0you=0D=0A=C2=A0=0D=0ABR,=0D=0A-Anupam= =C2=A0Roy=0D=0A=C2=A0 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from localhost ([10.192.2.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id YEmOE0uMa1/mygAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 19:56:27 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by localhost with LMTPS id oD6nEEuMa19IigEA0J78UA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 19:56:27 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 13BC1A0B11; Wed, 23 Sep 2020 19:56:22 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726537AbgIWR4P (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 13:56:15 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:58081 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726234AbgIWR4P (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 13:56:15 -0400 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from <kai.heng.feng@canonical.com>) id 1kL8zz-0005V0-Hn; Wed, 23 Sep 2020 17:56:12 +0000 From: Kai-Heng Feng <kai.heng.feng@canonical.com> To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: alex_lu@realsil.com.cn, Kai-Heng Feng <kai.heng.feng@canonical.com>, linux-bluetooth@vger.kernel.org (open list:BLUETOOTH DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] Bluetooth: btusb: Avoid unnecessary reset upon system resume Date: Thu, 24 Sep 2020 01:56:02 +0800 Message-Id: <20200923175602.9523-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.13 / 15.00 / 15.00 X-Rspamd-Queue-Id: 13BC1A0B11 X-Rspamd-UID: 6cdbb0 Realtek bluetooth controller may fail to work after system sleep: [ 1272.707670] Bluetooth: hci0: command 0x1001 tx timeout [ 1280.835712] Bluetooth: hci0: RTL: HCI_OP_READ_LOCAL_VERSION failed (-110) If platform firmware doesn't cut power off during suspend, the firmware is considered retained in controller but the driver is still asking USB core to perform a reset-resume. This can make bluetooth controller unusable. So avoid unnecessary reset to resolve the issue. For devices that really lose power during suspend, USB core will detect and handle reset-resume correctly. Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> --- drivers/bluetooth/btusb.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 8d2608ddfd08..de86ef4388f9 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -4255,17 +4255,15 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message) enable_irq(data->oob_wake_irq); } - /* For global suspend, Realtek devices lose the loaded fw - * in them. But for autosuspend, firmware should remain. - * Actually, it depends on whether the usb host sends + /* For global suspend, Realtek devices lose the loaded fw in them if + * platform firmware cut power off. But for autosuspend, firmware + * should remain. Actually, it depends on whether the usb host sends * set feature (enable wakeup) or not. */ if (test_bit(BTUSB_WAKEUP_DISABLE, &data->flags)) { if (PMSG_IS_AUTO(message) && device_can_wakeup(&data->udev->dev)) data->udev->do_remote_wakeup = 1; - else if (!PMSG_IS_AUTO(message)) - data->udev->reset_resume = 1; } return 0; -- 2.17.1 Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id yDFiCACza1+W6wEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Wed, 23 Sep 2020 22:41:36 +0200 Received: from mx2.mailbox.org ([80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id 2Kg9BQCza1+pUgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Wed, 23 Sep 2020 22:41:36 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter02.heinlein-hosting.de (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 05F3CA0B37; Wed, 23 Sep 2020 22:41:31 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726716AbgIWUlY (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Wed, 23 Sep 2020 16:41:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726599AbgIWUlY (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Wed, 23 Sep 2020 16:41:24 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CDD5C0613D1 for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 13:41:24 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id e23so802410vsk.2 for <linux-bluetooth@vger.kernel.org>; Wed, 23 Sep 2020 13:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WtnMpKEFk8XdbisKvZAYgb55+Tp7Iu2JFYEB4yZJj24=; b=FkDj/yGDWO7dTaq0x0xSMUm5/lbKNuWMUJOEmj8IECuFSkAIZqsWYybVdHKjdkeG+Q PKnmtqkRABkKepN55NXhuZlD+hNLVxGr6gYYQqdHZO3hMixceQBlVYZpBlk8m39QsHjx 5Ag5qUa6bJnhUbOhNMnfFNd7xu7F/RWZibwtA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WtnMpKEFk8XdbisKvZAYgb55+Tp7Iu2JFYEB4yZJj24=; b=nEfocc+s+4+luwUUneznrfgTsSWlVRFcx0GF9YJde8EwAuPs/io/s0dbfrSsxpXKml RIpjvVGtKTV56EgL86crPxxDDH/I7yfUdHSSTSUjyzZUbIvQZn9SFrPycPvegnh5HJeb MQOW27i2VELI6RxCfw8MKAFtIEaKAC7qE6v2nYjqCZs/6D5qVX9h4ou9c7/ruHpvjY8x Z0L+/YW1exgbnVo33CziM8y/YwX7KAZ25Lrqnx000/t3Ja7oLlRfeHkIzQV1s0HT/6fq AI0/aInbuwYxWYIlImZGh+wCpRlhFprOhw0/UUTKWcIGtNrMxRj4iFex1fLDLSDCMJJW 7G4g== X-Gm-Message-State: AOAM533ga0ZU9aSGN25Atj8PctR95z68Us0nHsG76H1dJgcRXTeEZ0kp 56zs3/CG7tAR1IwZV4oPQ44MO1v+NJoyPmejdlbNBQ== X-Google-Smtp-Source: ABdhPJy1qHbMclCv7vZN6/lw/+U4LzgqSa4XqBBOMOZgiEtM/Qeqh9eXwEZyUNz5dovHgqE1wibrzduraTVAN4qNN4E= X-Received: by 2002:a67:fc48:: with SMTP id p8mr1728292vsq.53.1600893683267; Wed, 23 Sep 2020 13:41:23 -0700 (PDT) MIME-Version: 1.0 References: <20200923175602.9523-1-kai.heng.feng@canonical.com> In-Reply-To: <20200923175602.9523-1-kai.heng.feng@canonical.com> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Date: Wed, 23 Sep 2020 13:41:11 -0700 Message-ID: <CANFp7mV7fC9_EZHd7B0Cu-owgCVdA6CNd2bb7XwFf5+6b7FVpg@mail.gmail.com> Subject: Re: [PATCH] Bluetooth: btusb: Avoid unnecessary reset upon system resume To: Kai-Heng Feng <kai.heng.feng@canonical.com> Cc: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, Alex Lu <alex_lu@realsil.com.cn>, "open list:BLUETOOTH DRIVERS" <linux-bluetooth@vger.kernel.org>, open list <linux-kernel@vger.kernel.org> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -2.91 / 15.00 / 15.00 X-Rspamd-Queue-Id: 05F3CA0B37 X-Rspamd-UID: cb66cf Hi Kai-Heng, Which Realtek controller is this on? Specifically for RTL8822CE, we tested without reset_resume being set and that was causing the controller being reset without bluez ever learning about it (resulting in devices being unusable without toggling the BT power). If the firmware doesn't cut off power during suspend, maybe you shouldn't set the BTUSB_WAKEUP_DISABLE flag for that controller. I would prefer this doesn't get accepted in its current state. Abhishek On Wed, Sep 23, 2020 at 10:56 AM Kai-Heng Feng <kai.heng.feng@canonical.com> wrote: > > Realtek bluetooth controller may fail to work after system sleep: > [ 1272.707670] Bluetooth: hci0: command 0x1001 tx timeout > [ 1280.835712] Bluetooth: hci0: RTL: HCI_OP_READ_LOCAL_VERSION failed (-110) > > If platform firmware doesn't cut power off during suspend, the firmware > is considered retained in controller but the driver is still asking USB > core to perform a reset-resume. This can make bluetooth controller > unusable. > > So avoid unnecessary reset to resolve the issue. > > For devices that really lose power during suspend, USB core will detect > and handle reset-resume correctly. > > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> > --- > drivers/bluetooth/btusb.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index 8d2608ddfd08..de86ef4388f9 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -4255,17 +4255,15 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message) > enable_irq(data->oob_wake_irq); > } > > - /* For global suspend, Realtek devices lose the loaded fw > - * in them. But for autosuspend, firmware should remain. > - * Actually, it depends on whether the usb host sends > + /* For global suspend, Realtek devices lose the loaded fw in them if > + * platform firmware cut power off. But for autosuspend, firmware > + * should remain. Actually, it depends on whether the usb host sends > * set feature (enable wakeup) or not. > */ > if (test_bit(BTUSB_WAKEUP_DISABLE, &data->flags)) { > if (PMSG_IS_AUTO(message) && > device_can_wakeup(&data->udev->dev)) > data->udev->do_remote_wakeup = 1; > - else if (!PMSG_IS_AUTO(message)) > - data->udev->reset_resume = 1; > } > > return 0; > -- > 2.17.1 > Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-04.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id gEckGXdGbF+bYQEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 24 Sep 2020 09:10:47 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-04.heinlein-hosting.de with LMTPS id oM/ZFXdGbF9zDgEAgupzMw (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 24 Sep 2020 09:10:47 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 0232FA0BE8; Thu, 24 Sep 2020 09:10:43 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727092AbgIXHKl convert rfc822-to-8bit (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 24 Sep 2020 03:10:41 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:45491 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727014AbgIXHKl (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 24 Sep 2020 03:10:41 -0400 Received: from mail-pf1-f198.google.com ([209.85.210.198]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from <kai.heng.feng@canonical.com>) id 1kLLOo-0003b6-Ky for linux-bluetooth@vger.kernel.org; Thu, 24 Sep 2020 07:10:38 +0000 Received: by mail-pf1-f198.google.com with SMTP id q5so1269315pfl.16 for <linux-bluetooth@vger.kernel.org>; Thu, 24 Sep 2020 00:10:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Nbrq59GvwtLcN9qKevu8+3dfH8r78wKpe+smKwZezME=; b=fcxPMeoHyMCaT1UFyUIUgdMmCiNIDouti3QG3r0ZVkandCZTABJrs4SOZCMtPLxodd 90Tf7/POfDab7QyvFZsoua9pJ2nxXdBx8Hw6+ijSJljcfwtVqvqaztOre7KXBnURVT0Q lbegwu7VeSqgM4WrT/mWVGcuVBZCZg3bzZ6p6N2hqb0NX95zcV4vJYeVmF94bPUlASt5 oZa5cVJCTrKcno8YdZpc0HGnx8TUlQ2zlYq5AHOxbNsGkdRWPJ3IphYN5/9c4fZe4e8W X3qnPZqYQ9E6uLTgLH7Eb4CpEmHKgWV26rApGzKD1n/khGQPGTOhelqzG0Qj2544hdPG d3+w== X-Gm-Message-State: AOAM532rOmT2Tz9isJBbKuv7tV2d2bkbQso+XqSOFqBXaUq8qX8mAC4T UEK9g7XUB1V3kQVIT6hug47/MS7TpbQTy6kCzNmXphtg3n+sCmw1Qm+GFfVwUFnXrF169t5+JHf y/6w7MGtgqGNZDgu+ziIE4ytpHmvlOwxNoFmfcWAsQ/TnwA== X-Received: by 2002:a17:90a:2ecb:: with SMTP id h11mr2601220pjs.195.1600931436188; Thu, 24 Sep 2020 00:10:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCk7vzCBN/l74QQtaNp+k0MuChSSLUgg5AfeBO3OsjJTBVY/G00Wpe7vMaVKlvc6su9uo1Ig== X-Received: by 2002:a17:90a:2ecb:: with SMTP id h11mr2601198pjs.195.1600931435690; Thu, 24 Sep 2020 00:10:35 -0700 (PDT) Received: from [192.168.1.208] (220-133-187-190.HINET-IP.hinet.net. [220.133.187.190]) by smtp.gmail.com with ESMTPSA id q10sm1351546pja.48.2020.09.24.00.10.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2020 00:10:35 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: btusb: Avoid unnecessary reset upon system resume From: Kai-Heng Feng <kai.heng.feng@canonical.com> In-Reply-To: <CANFp7mV7fC9_EZHd7B0Cu-owgCVdA6CNd2bb7XwFf5+6b7FVpg@mail.gmail.com> Date: Thu, 24 Sep 2020 15:10:31 +0800 Cc: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, Alex Lu <alex_lu@realsil.com.cn>, "open list:BLUETOOTH DRIVERS" <linux-bluetooth@vger.kernel.org>, open list <linux-kernel@vger.kernel.org>, "open list:USB XHCI DRIVER" <linux-usb@vger.kernel.org> Content-Transfer-Encoding: 8BIT Message-Id: <A6F728DB-A07B-4323-83A5-3DABA8FDC156@canonical.com> References: <20200923175602.9523-1-kai.heng.feng@canonical.com> <CANFp7mV7fC9_EZHd7B0Cu-owgCVdA6CNd2bb7XwFf5+6b7FVpg@mail.gmail.com> To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -3.35 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0232FA0BE8 X-Rspamd-UID: 3f1437 [+Cc linux-usb] Hi Abhishek, > On Sep 24, 2020, at 04:41, Abhishek Pandit-Subedi <abhishekpandit@chromium.org> wrote: > > Hi Kai-Heng, > > Which Realtek controller is this on?' The issue happens on 8821CE. > > Specifically for RTL8822CE, we tested without reset_resume being set > and that was causing the controller being reset without bluez ever > learning about it (resulting in devices being unusable without > toggling the BT power). The reset is done by the kernel, so how does that affect bluez? From what you described, it sounds more like runtime resume since bluez is already running. If we need reset resume for runtime resume, maybe it's another bug which needs to be addressed? > If the firmware doesn't cut off power during suspend, maybe you > shouldn't set the BTUSB_WAKEUP_DISABLE flag for that controller. We don't know beforehand if the platform firmware (BIOS for my case) will cut power off or not. In general, laptops will cut off the USB power during S3. When AC is plugged, some laptops cuts USB power off and some don't. This also applies to many desktops. Not to mention there can be BIOS options to control USB power under S3/S4/S5... So we don't know beforehand. > > I would prefer this doesn't get accepted in its current state. Of course. I think we need to find the root cause for your case before applying this one. Kai-Heng > > Abhishek > > On Wed, Sep 23, 2020 at 10:56 AM Kai-Heng Feng > <kai.heng.feng@canonical.com> wrote: >> >> Realtek bluetooth controller may fail to work after system sleep: >> [ 1272.707670] Bluetooth: hci0: command 0x1001 tx timeout >> [ 1280.835712] Bluetooth: hci0: RTL: HCI_OP_READ_LOCAL_VERSION failed (-110) >> >> If platform firmware doesn't cut power off during suspend, the firmware >> is considered retained in controller but the driver is still asking USB >> core to perform a reset-resume. This can make bluetooth controller >> unusable. >> >> So avoid unnecessary reset to resolve the issue. >> >> For devices that really lose power during suspend, USB core will detect >> and handle reset-resume correctly. >> >> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> >> --- >> drivers/bluetooth/btusb.c | 8 +++----- >> 1 file changed, 3 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c >> index 8d2608ddfd08..de86ef4388f9 100644 >> --- a/drivers/bluetooth/btusb.c >> +++ b/drivers/bluetooth/btusb.c >> @@ -4255,17 +4255,15 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message) >> enable_irq(data->oob_wake_irq); >> } >> >> - /* For global suspend, Realtek devices lose the loaded fw >> - * in them. But for autosuspend, firmware should remain. >> - * Actually, it depends on whether the usb host sends >> + /* For global suspend, Realtek devices lose the loaded fw in them if >> + * platform firmware cut power off. But for autosuspend, firmware >> + * should remain. Actually, it depends on whether the usb host sends >> * set feature (enable wakeup) or not. >> */ >> if (test_bit(BTUSB_WAKEUP_DISABLE, &data->flags)) { >> if (PMSG_IS_AUTO(message) && >> device_can_wakeup(&data->udev->dev)) >> data->udev->do_remote_wakeup = 1; >> - else if (!PMSG_IS_AUTO(message)) >> - data->udev->reset_resume = 1; >> } >> >> return 0; >> -- >> 2.17.1 >> Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id 4ONEAR+/bF8eqAEAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 24 Sep 2020 17:45:35 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id iIO1OR6/bF9vuwEAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 24 Sep 2020 17:45:34 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de Authentication-Results: spamfilter03.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) header.d=google.com X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id 5E5DBA013F; Thu, 24 Sep 2020 17:45:30 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728459AbgIXPp3 (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 24 Sep 2020 11:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728379AbgIXPp3 (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 24 Sep 2020 11:45:29 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E73DEC0613D4 for <linux-bluetooth@vger.kernel.org>; Thu, 24 Sep 2020 08:45:28 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id r128so2191130qkc.9 for <linux-bluetooth@vger.kernel.org>; Thu, 24 Sep 2020 08:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=IPIdIz5OhfOKSKcHOSaPSxaObhox3VIBNFJW0Bv678o=; b=GC41UOarc4WKhNYnxvEW/4WUAlLIVnDiP96nIWBJWBZKSCqNVAq3etCfs00XVAU6AJ qKGVXR+SNJhdjWGZ84xvp0BXMqbuDUl/dXEHJTxwV5wC/0hF9icow2DrQBwQDXIwUQws HWrIA4EUxWsmD9VX/BXuLORjybycNkDeU3XfJ6mYiSffPLnmFpCuy8wYzKAdozQOBAL+ 4YBRt47erpnQgKRPMfC4Fguks/j/NLzvUsQsyBE+MTIBWmq6vUVCW1QXp+oD+C4CceNB tmG6ldsoxxNvykMMEEscD5BOfHBPidaT2DCmO2hUUE/+AszVU7IbSF/zgjSKkf98o4ou ALtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=IPIdIz5OhfOKSKcHOSaPSxaObhox3VIBNFJW0Bv678o=; b=Q5zoBhZI0zjfNfJPv5UQnck+S1yAVJ9ytjd6tcL5vSjxLr6bjcRSxXmTh2rtXjGqv7 yGjp4lr1tRE9Gz1I/haRLxtZ6huqQRyh/ohqtICy/4pq1+c7W/hMPVB8jZ6iItsGflLd /JfhyAFdvN1JImPqJT0BO8ej1/3DOIMZoXP+J30qtFm5Fc93PS5jEyJrWUBkHeFCAEdy tUdMWMnrEaeQj50oooO3iNAm+rVK0tbtOiO3Ht9nV9GG5PtHEARCOB3X7yqKmuCO6jBY 4DHTmL4EATscMWg7k6NrcrB3eqvivAx2CrHYz+nWumsxm6OKu8ntmMhj8eTaL31lpMLi 0naA== X-Gm-Message-State: AOAM531qNElEaS+DKysXHiZIxvZC1LSfY43BHhOhRhBr45RQ90cKkz6f 9R1g58oKhsscvPqjZ+Rd/SoIwOf1DAytsZ0TGABt+GJZbDL0Bh7i66vuA5XH5GDBlpSiOqidMNn ptMytx4mhdIRpOssakBldGfAKyi7l8cvmcZ6TU25c7hjYJATv99k9ChKdaHnGdzylY7D3eqs+qP 4s X-Google-Smtp-Source: ABdhPJyY5JZ0S9e/owclSjTYngJe2UFwWvvVt9uCChNotfeqC5Yqdv/aynxsmCjHsAiVtJNANInw5H+phbuZ Sender: "apusaka via sendgmr" <apusaka@apusaka-p920.tpe.corp.google.com> X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a0c:8001:: with SMTP id 1mr5750424qva.21.1600962327869; Thu, 24 Sep 2020 08:45:27 -0700 (PDT) Date: Thu, 24 Sep 2020 23:45:01 +0800 Message-Id: <20200924234422.v1.1.Id1d24a896cd1d20f9ce7a4eb74523fe7896af89d@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v1] Bluetooth: send proper config param to unknown config request From: Archie Pusaka <apusaka@google.com> To: linux-bluetooth <linux-bluetooth@vger.kernel.org>, Marcel Holtmann <marcel@holtmann.org> Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>, Archie Pusaka <apusaka@chromium.org>, Alain Michaud <alainm@chromium.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Johan Hedberg <johan.hedberg@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: X-Rspamd-Score: -1.88 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5E5DBA013F X-Rspamd-UID: f90140 From: Archie Pusaka <apusaka@chromium.org> When receiving an L2CAP_CONFIGURATION_REQ with an unknown config type, currently we will reply with L2CAP_CONFIGURATION_RSP with a list of unknown types as the config param. However, this is not a correct format of config param. As described in the bluetooth spec v5.2, Vol 3, Part A, Sec 5, the config param should consists of type, length, and optionally data. This patch copies the length and data from the received L2CAP_CONFIGURATION_REQ and also appends them to the config param of the corresponding L2CAP_CONFIGURATION_RSP to match the format of the config param according to the spec. Signed-off-by: Archie Pusaka <apusaka@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> --- net/bluetooth/l2cap_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index ade83e224567..2f3ddd4f0f4c 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -3627,7 +3627,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data if (hint) break; result = L2CAP_CONF_UNKNOWN; - *((u8 *) ptr++) = type; + l2cap_add_conf_opt(&ptr, type, olen, val, + endptr - ptr); break; } } @@ -3658,7 +3659,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data } done: - if (chan->mode != rfc.mode) { + if (chan->mode != rfc.mode && result != L2CAP_CONF_UNKNOWN) { result = L2CAP_CONF_UNACCEPT; rfc.mode = chan->mode; -- 2.28.0.681.g6f77f65b4e-goog Return-Path: <linux-bluetooth-owner@vger.kernel.org> Delivered-To: woutergordts@mailbox.org Received: from director-03.heinlein-hosting.de ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by dobby26b.heinlein-hosting.de with LMTPS id kL/YGG/jbF9amAAAvsO+Rg (envelope-from <linux-bluetooth-owner@vger.kernel.org>) for <woutergordts@mailbox.org>; Thu, 24 Sep 2020 20:20:31 +0200 Received: from mx2.mailbox.org ([2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by director-03.heinlein-hosting.de with LMTPS id qK0cFW/jbF+lfgAAlScrYA (envelope-from <linux-bluetooth-owner@vger.kernel.org>); Thu, 24 Sep 2020 20:20:31 +0200 X-Virus-Scanned: amavisd-new at heinlein-support.de X-policyd-weight: using cached result; rate: -4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx2.mailbox.org (Postfix) with ESMTP id B6D1BA0B6C; Thu, 24 Sep 2020 20:20:24 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728739AbgIXSUN (ORCPT <rfc822;jtctestly1@mailbox.org> + 2 others); Thu, 24 Sep 2020 14:20:13 -0400 Received: from mga01.intel.com ([192.55.52.88]:62030 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727753AbgIXSUM (ORCPT <rfc822;linux-bluetooth@vger.kernel.org>); Thu, 24 Sep 2020 14:20:12 -0400 IronPort-SDR: tz83bI2GBWY1wsziebgSSRoA9Fa16cnAIqX10ref14N4rBmpiEOyMpYkZFYs5Hn1C4O8OtQ3Ie 6hURWhpiOmrA== X-IronPort-AV: E=McAfee;i="6000,8403,9754"; a="179388563" X-IronPort-AV: E=Sophos;i="5.77,298,1596524400"; d="scan'208";a="179388563" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2020 11:20:11 -0700 IronPort-SDR: lcugOTTOcgyb2KqkBSHyFGzGf5bk22rJresY+K5jXCKkCQ5wffybItd/zo5zx+Weh++KU1f6OR JfjG8WoDI3iw== X-IronPort-AV: E=Sophos;i="5.77,298,1596524400"; d="scan'208";a="291325245" Received: from ypan13-mobl1.ccr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.97.189]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2020 11:20:11 -0700 From: Inga Stotland <inga.stotland@intel.com> To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, Inga Stotland <inga.stotland@intel.com> Subject: [PATCH BlueZ] shared/io-ell: Fix ELL io wrapper Date: Thu, 24 Sep 2020 11:20:02 -0700 Message-Id: <20200924182002.22978-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-bluetooth.vger.kernel.org> X-Mailing-List: linux-bluetooth@vger.kernel.org X-MBO-SPAM-Probability: ** X-Rspamd-Score: 2.40 / 15.00 / 15.00 X-Rspamd-Queue-Id: B6D1BA0B6C X-Rspamd-UID: dd03b6 This modifies the internal io structure inside io-ell to retain correct user data associated with write and read handlers and to return these data with the corresponding callbacks. --- src/shared/io-ell.c | 54 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/src/shared/io-ell.c b/src/shared/io-ell.c index c4a115478..485c613e0 100644 --- a/src/shared/io-ell.c +++ b/src/shared/io-ell.c @@ -22,8 +22,48 @@ struct io { struct l_io *l_io; + io_callback_func_t read_cb; + io_destroy_func_t read_destroy; + void *read_data; + io_callback_func_t write_cb; + io_destroy_func_t write_destroy; + void *write_data; }; +static bool read_callback(struct l_io *l_io, void *user_data) +{ + struct io *io = user_data; + bool result = false; + + if (!io) + return false; + + if (io->read_cb) + result = io->read_cb(io, io->read_data); + + if (io->read_destroy) + io->read_destroy(io->read_data); + + return result; +} + +static bool write_callback(struct l_io *l_io, void *user_data) +{ + struct io *io = user_data; + bool result = false; + + if (!io) + return false; + + if (io->write_cb) + result = io->write_cb(io, io->write_data); + + if (io->write_destroy) + io->write_destroy(io->write_data); + + return result; +} + struct io *io_new(int fd) { struct io *io; @@ -80,8 +120,11 @@ bool io_set_read_handler(struct io *io, io_callback_func_t callback, if (!io || !io->l_io) return false; - return l_io_set_read_handler(io->l_io, (l_io_read_cb_t) callback, - user_data, destroy); + io->read_cb = callback; + io->read_data = user_data; + io->read_destroy = destroy; + + return l_io_set_read_handler(io->l_io, read_callback, io, NULL); } bool io_set_write_handler(struct io *io, io_callback_func_t callback, @@ -90,8 +133,11 @@ bool io_set_write_handler(struct io *io, io_callback_func_t callback, if (!io || !io->l_io) return false; - return l_io_set_write_handler(io->l_io, (l_io_write_cb_t) callback, - user_data, destroy); + io->write_cb = callback; + io->write_data = user_data; + io->write_destroy = destroy; + + return l_io_set_write_handler(io->l_io, write_callback, io, NULL); } bool io_set_disconnect_handler(struct io *io, io_callback_func_t callback, -- 2.26.2